mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
Add all arithmetic operators to ConstantExprToString().
Note that some generated operators (like &, | or ^) may not be supported by the assembler -- but if they've got this far, it's better to generate them and let the assembler decide. llvm-svn: 7476
This commit is contained in:
parent
b68bd55363
commit
eda4d9cb09
@ -213,6 +213,46 @@ public:
|
||||
+ valToExprString(CE->getOperand(1), target) + ")";
|
||||
break;
|
||||
|
||||
case Instruction::Sub:
|
||||
S += "(" + valToExprString(CE->getOperand(0), target) + ") - ("
|
||||
+ valToExprString(CE->getOperand(1), target) + ")";
|
||||
break;
|
||||
|
||||
case Instruction::Mul:
|
||||
S += "(" + valToExprString(CE->getOperand(0), target) + ") * ("
|
||||
+ valToExprString(CE->getOperand(1), target) + ")";
|
||||
break;
|
||||
|
||||
case Instruction::Div:
|
||||
S += "(" + valToExprString(CE->getOperand(0), target) + ") / ("
|
||||
+ valToExprString(CE->getOperand(1), target) + ")";
|
||||
break;
|
||||
|
||||
case Instruction::Rem:
|
||||
S += "(" + valToExprString(CE->getOperand(0), target) + ") % ("
|
||||
+ valToExprString(CE->getOperand(1), target) + ")";
|
||||
break;
|
||||
|
||||
case Instruction::And:
|
||||
// Logical && for booleans; bitwise & otherwise
|
||||
S += "(" + valToExprString(CE->getOperand(0), target)
|
||||
+ ((CE->getType() == Type::BoolTy)? ") && (" : ") & (")
|
||||
+ valToExprString(CE->getOperand(1), target) + ")";
|
||||
break;
|
||||
|
||||
case Instruction::Or:
|
||||
// Logical || for booleans; bitwise | otherwise
|
||||
S += "(" + valToExprString(CE->getOperand(0), target)
|
||||
+ ((CE->getType() == Type::BoolTy)? ") || (" : ") | (")
|
||||
+ valToExprString(CE->getOperand(1), target) + ")";
|
||||
break;
|
||||
|
||||
case Instruction::Xor:
|
||||
// Bitwise ^ for all types
|
||||
S += "(" + valToExprString(CE->getOperand(0), target) + ") ^ ("
|
||||
+ valToExprString(CE->getOperand(1), target) + ")";
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0 && "Unsupported operator in ConstantExprToString()");
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user