Exemplo n.º 1
0
        internal override void Transform(LLFunction pFunction)
        {
            LLLocation locationLeftOperand  = mLeftOperandSource.Load(pFunction);
            LLLocation locationRightOperand = mRightOperandSource.Load(pFunction);

            LLType typeOperands = LLModule.BinaryResult(locationLeftOperand.Type, locationRightOperand.Type);

            locationLeftOperand  = pFunction.CurrentBlock.EmitConversion(locationLeftOperand, typeOperands);
            locationRightOperand = pFunction.CurrentBlock.EmitConversion(locationRightOperand, typeOperands);

            LLLocation locationTemporary = LLTemporaryLocation.Create(pFunction.CreateTemporary(LLModule.BooleanType));

            if (typeOperands.Primitive == LLPrimitive.Float)
            {
                LLCompareFloatsCondition condition = LLCompareFloatsCondition.oeq;
                switch (mCompareType)
                {
                case HLCompareType.Equal: condition = LLCompareFloatsCondition.oeq; break;

                case HLCompareType.NotEqual: condition = LLCompareFloatsCondition.one; break;

                case HLCompareType.GreaterThan: condition = LLCompareFloatsCondition.ogt; break;

                case HLCompareType.GreaterThanOrEqual: condition = LLCompareFloatsCondition.oge; break;

                case HLCompareType.LessThan: condition = LLCompareFloatsCondition.olt; break;

                case HLCompareType.LessThanOrEqual: condition = LLCompareFloatsCondition.ole; break;

                default: throw new NotSupportedException();
                }
                pFunction.CurrentBlock.EmitCompareFloats(locationTemporary, locationLeftOperand, locationRightOperand, condition);
            }
            else
            {
                LLCompareIntegersCondition condition = LLCompareIntegersCondition.eq;
                switch (mCompareType)
                {
                case HLCompareType.Equal: condition = LLCompareIntegersCondition.eq; break;

                case HLCompareType.NotEqual: condition = LLCompareIntegersCondition.ne; break;

                case HLCompareType.GreaterThan: condition = typeOperands.Primitive == LLPrimitive.Unsigned ? LLCompareIntegersCondition.ugt : LLCompareIntegersCondition.sgt; break;

                case HLCompareType.GreaterThanOrEqual: condition = typeOperands.Primitive == LLPrimitive.Unsigned ? LLCompareIntegersCondition.uge : LLCompareIntegersCondition.sge; break;

                case HLCompareType.LessThan: condition = typeOperands.Primitive == LLPrimitive.Unsigned ? LLCompareIntegersCondition.ult : LLCompareIntegersCondition.slt; break;

                case HLCompareType.LessThanOrEqual: condition = typeOperands.Primitive == LLPrimitive.Unsigned ? LLCompareIntegersCondition.ule : LLCompareIntegersCondition.sle; break;

                default: throw new NotSupportedException();
                }
                pFunction.CurrentBlock.EmitCompareIntegers(locationTemporary, locationLeftOperand, locationRightOperand, condition);
            }

            mDestination.Store(pFunction, locationTemporary);
        }
 public static LLCompareFloatsInstruction Create(LLFunction pFunction, LLLocation pDestination, LLLocation pLeftSource, LLLocation pRightSource, LLCompareFloatsCondition pCondition)
 {
     LLCompareFloatsInstruction instruction = new LLCompareFloatsInstruction(pFunction);
     instruction.mDestination = pDestination;
     instruction.mLeftSource = pLeftSource;
     instruction.mRightSource = pRightSource;
     instruction.mCondition = pCondition;
     return instruction;
 }
Exemplo n.º 3
0
 public void EmitCompareFloats(LLLocation pDestination, LLLocation pLeftSource, LLLocation pRightSource, LLCompareFloatsCondition pCondition)
 {
     Emit(LLCompareFloatsInstruction.Create(mFunction, pDestination, pLeftSource, pRightSource, pCondition));
 }
Exemplo n.º 4
0
 public void EmitCompareFloats(LLLocation pDestination, LLLocation pLeftSource, LLLocation pRightSource, LLCompareFloatsCondition pCondition)
 {
     Emit(LLCompareFloatsInstruction.Create(mFunction, pDestination, pLeftSource, pRightSource, pCondition));
 }
        public static LLCompareFloatsInstruction Create(LLFunction pFunction, LLLocation pDestination, LLLocation pLeftSource, LLLocation pRightSource, LLCompareFloatsCondition pCondition)
        {
            LLCompareFloatsInstruction instruction = new LLCompareFloatsInstruction(pFunction);

            instruction.mDestination = pDestination;
            instruction.mLeftSource  = pLeftSource;
            instruction.mRightSource = pRightSource;
            instruction.mCondition   = pCondition;
            return(instruction);
        }