aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVikram S. Adve <vadve@cs.uiuc.edu>2003-08-01 15:55:53 +0000
committerVikram S. Adve <vadve@cs.uiuc.edu>2003-08-01 15:55:53 +0000
commit72666e6c30e9d23bc7aec3856661c1a13719b7c7 (patch)
treeee633b601f0d56bd9b1c084f8dc608eb7b5cc8cc
parent97e02ebd8677a3d6a959fbe528419f36e1622023 (diff)
downloadexternal_llvm-72666e6c30e9d23bc7aec3856661c1a13719b7c7.zip
external_llvm-72666e6c30e9d23bc7aec3856661c1a13719b7c7.tar.gz
external_llvm-72666e6c30e9d23bc7aec3856661c1a13719b7c7.tar.bz2
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7476 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/SparcV9/SparcV9AsmPrinter.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp
index 6cd28cf..cb44ca6 100644
--- a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp
+++ b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp
@@ -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;