private static void EmitI2I( EmitterContext context, ISrcDstFmt srcType, ISrcDstFmt dstType, Operand src, ByteSel byteSelection, int rd, bool absolute, bool negate, bool saturate, bool writeCC) { if ((srcType & ~ISrcDstFmt.S8) > ISrcDstFmt.U32 || (dstType & ~ISrcDstFmt.S8) > ISrcDstFmt.U32) { context.Config.GpuAccessor.Log("Invalid I2I encoding."); return; } bool srcIsSignedInt = srcType == ISrcDstFmt.S8 || srcType == ISrcDstFmt.S16 || srcType == ISrcDstFmt.S32; bool dstIsSignedInt = dstType == ISrcDstFmt.S8 || dstType == ISrcDstFmt.S16 || dstType == ISrcDstFmt.S32; bool srcIsSmallInt = srcType == ISrcDstFmt.U16 || srcType == ISrcDstFmt.S16 || srcType == ISrcDstFmt.U8 || srcType == ISrcDstFmt.S8; if (srcIsSmallInt) { int size = srcType == ISrcDstFmt.U16 || srcType == ISrcDstFmt.S16 ? 16 : 8; src = srcIsSignedInt ? context.BitfieldExtractS32(src, Const((int)byteSelection * 8), Const(size)) : context.BitfieldExtractU32(src, Const((int)byteSelection * 8), Const(size)); } src = context.IAbsNeg(src, absolute, negate); if (saturate) { int min = (int)GetIntMin(dstType); int max = (int)GetIntMax(dstType); src = dstIsSignedInt ? context.IClampS32(src, Const(min), Const(max)) : context.IClampU32(src, Const(min), Const(max)); } context.Copy(GetDest(rd), src); SetZnFlags(context, src, writeCC); }
private static void EmitI2F( EmitterContext context, ISrcFmt srcType, DstFmt dstType, Operand src, ByteSel byteSelection, int rd, bool absolute, bool negate) { bool isSignedInt = srcType == ISrcFmt.S8 || srcType == ISrcFmt.S16 || srcType == ISrcFmt.S32 || srcType == ISrcFmt.S64; bool isSmallInt = srcType == ISrcFmt.U16 || srcType == ISrcFmt.S16 || srcType == ISrcFmt.U8 || srcType == ISrcFmt.S8; // TODO: Handle S/U64. Operand srcB = context.IAbsNeg(src, absolute, negate); if (isSmallInt) { int size = srcType == ISrcFmt.U16 || srcType == ISrcFmt.S16 ? 16 : 8; srcB = isSignedInt ? context.BitfieldExtractS32(srcB, Const((int)byteSelection * 8), Const(size)) : context.BitfieldExtractU32(srcB, Const((int)byteSelection * 8), Const(size)); } if (dstType == DstFmt.F64) { srcB = isSignedInt ? context.IConvertS32ToFP64(srcB) : context.IConvertU32ToFP64(srcB); } else { srcB = isSignedInt ? context.IConvertS32ToFP32(srcB) : context.IConvertU32ToFP32(srcB); } WriteFP(context, dstType, srcB, rd); // TODO: CC. }
private static void EmitR2p(EmitterContext context, Operand value, Operand mask, ByteSel byteSel, bool ccpr) { Operand Test(Operand value, int bit) { return(context.ICompareNotEqual(context.BitwiseAnd(value, Const(1 << bit)), Const(0))); } if (ccpr) { // TODO: Support Register to condition code flags copy. context.Config.GpuAccessor.Log("R2P.CC not implemented."); } else { int shift = (int)byteSel * 8; for (int bit = 0; bit < RegisterConsts.PredsCount; bit++) { Operand pred = Register(bit, RegisterType.Predicate); Operand res = context.ConditionalSelect(Test(mask, bit), Test(value, bit + shift), pred); context.Copy(pred, res); } } }