Add all arithmetic operators to ConstantExprToString().
authorVikram S. Adve <vadve@cs.uiuc.edu>
Fri, 1 Aug 2003 15:55:53 +0000 (15:55 +0000)
committerVikram S. Adve <vadve@cs.uiuc.edu>
Fri, 1 Aug 2003 15:55:53 +0000 (15:55 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7476 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/SparcV9/SparcV9AsmPrinter.cpp

index 6cd28cf005e6a6da9f0e3b3ce6d7fbeaa3370998..cb44ca6cd4feec11f02fb9ed94a6086ef40d4e3b 100644 (file)
@@ -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;