diff options
| author | Vikram S. Adve <vadve@cs.uiuc.edu> | 2003-08-01 15:55:53 +0000 |
|---|---|---|
| committer | Vikram S. Adve <vadve@cs.uiuc.edu> | 2003-08-01 15:55:53 +0000 |
| commit | 89f93976689925fdd8c6456c3f3aa0f20fdb9c0f (patch) | |
| tree | a3d13ffe0550f9d2dc1647eb735b7bbcc60f2622 /llvm/lib/Target/Sparc | |
| parent | 16c2b62d13b70bc48636b6250bde35feb453098c (diff) | |
| download | bcm5719-llvm-89f93976689925fdd8c6456c3f3aa0f20fdb9c0f.tar.gz bcm5719-llvm-89f93976689925fdd8c6456c3f3aa0f20fdb9c0f.zip | |
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
Diffstat (limited to 'llvm/lib/Target/Sparc')
| -rw-r--r-- | llvm/lib/Target/Sparc/EmitAssembly.cpp | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/llvm/lib/Target/Sparc/EmitAssembly.cpp b/llvm/lib/Target/Sparc/EmitAssembly.cpp index 6cd28cf005e..cb44ca6cd4f 100644 --- a/llvm/lib/Target/Sparc/EmitAssembly.cpp +++ b/llvm/lib/Target/Sparc/EmitAssembly.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; |

