[Beignet] [PATCH 3/3] add llvm intrinsic call translate.

Zhigang Gong zhigang.gong at linux.intel.com
Thu Jan 15 00:13:17 PST 2015



> -----Original Message-----
> From: Beignet [mailto:beignet-bounces at lists.freedesktop.org] On Behalf Of
> Song, Ruiling
> Sent: Thursday, January 15, 2015 4:00 PM
> To: Luo, Xionghu; beignet at lists.freedesktop.org
> Cc: Luo, Xionghu
> Subject: Re: [Beignet] [PATCH 3/3] add llvm intrinsic call translate.
> 
> > +          case Intrinsic::trunc:
> > +          {
> > +            Type *llvmDstType = I.getType();
> > +            Type *llvmSrcType = I.getOperand(0)->getType();
> > +            ir::Type dstType = getType(ctx, llvmDstType);
> > +            ir::Type srcType = getType(ctx, llvmSrcType);
> > +            GBE_ASSERT(srcType == dstType);
> > +
> > +            const ir::Register tmp = ctx.reg(getFamily(ir::TYPE_S32));
> > +            const ir::Register dst = this->getRegister(&I);
> > +            const ir::Register src = this->getRegister(I.getOperand(0));
> > +            ctx.CVT(ir::TYPE_S32, srcType, tmp, src);
> > +            ctx.CVT(dstType, ir::TYPE_S32, dst, tmp);
> Why do we need to convert to TYPE_S32 to convert from TYPE_S32 to dstType?
This is what llvm.trunc's purpose:

‘llvm.trunc.*‘ Intrinsic

Syntax:

This is an overloaded intrinsic. You can use llvm.trunc on any floating point or vector of floating point type. Not all targets support all types however.

declare float     @llvm.trunc.f32(float  %Val)
declare double    @llvm.trunc.f64(double %Val)
declare x86_fp80  @llvm.trunc.f80(x86_fp80  %Val)
declare fp128     @llvm.trunc.f128(fp128 %Val)
declare ppc_fp128 @llvm.trunc.ppcf128(ppc_fp128  %Val)
Overview:

The ‘llvm.trunc.*‘ intrinsics returns the operand rounded to the nearest integer not larger in magnitude than the operand.

> 
> _______________________________________________
> Beignet mailing list
> Beignet at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/beignet



More information about the Beignet mailing list