예제 #1
0
 // branchOpCode: the normal case: (a<b) therefore BLT
 // flipOpCode: the flipped case: (a<b)==(b>a), therefore BGT
 // inverseOpCode: the inverse case: (a<b)==!(a>=b), therefore BGE
 // flipInverseOpCode: the flipped inverse case: (a<b)==!(b<=a), therefore BLE
 private static CompareOp CreateHelper(IntExpression lhs, IntExpression rhs,
                                       Format16OpCode branchOpCode, Format16OpCode flipOpCode, Format16OpCode inverseOpCode, Format16OpCode flipInverseOpCode)
 {
     if (lhs.IsConstant())
     {
         if (rhs.IsConstant())
         {
             throw new Exception("ridiculous");
         }
         //flip the constant over to the right side, for better code generation
         return(new CompareOp(rhs, lhs, flipOpCode, flipInverseOpCode));
     }
     return(new CompareOp(lhs, rhs, branchOpCode, inverseOpCode));
 }