summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/CBackend/Writer.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-03-03 21:12:04 +0000
committerChris Lattner <sabre@nondot.org>2005-03-03 21:12:04 +0000
commit00ee68c612c8e85eb155f8c4d960d96cf9af8550 (patch)
tree1a1f627d1339d28bbf43daeda7bab2f63b18819c /llvm/lib/Target/CBackend/Writer.cpp
parent00348ce902fc26c84671fe02255263fe38c6619e (diff)
downloadbcm5719-llvm-00ee68c612c8e85eb155f8c4d960d96cf9af8550.tar.gz
bcm5719-llvm-00ee68c612c8e85eb155f8c4d960d96cf9af8550.zip
Print -X like this:
double test(double l1_X) { return (-l1_X); } instead of like this: double test(double l1_X) { return (-0x0p+0 - l1_X); } llvm-svn: 20423
Diffstat (limited to 'llvm/lib/Target/CBackend/Writer.cpp')
-rw-r--r--llvm/lib/Target/CBackend/Writer.cpp52
1 files changed, 30 insertions, 22 deletions
diff --git a/llvm/lib/Target/CBackend/Writer.cpp b/llvm/lib/Target/CBackend/Writer.cpp
index 8505917a44e..af478d9bfdb 100644
--- a/llvm/lib/Target/CBackend/Writer.cpp
+++ b/llvm/lib/Target/CBackend/Writer.cpp
@@ -1358,30 +1358,38 @@ void CWriter::visitBinaryOperator(Instruction &I) {
printType(Out, I.getType());
Out << ")(";
}
-
- writeOperand(I.getOperand(0));
- switch (I.getOpcode()) {
- case Instruction::Add: Out << " + "; break;
- case Instruction::Sub: Out << " - "; break;
- case Instruction::Mul: Out << '*'; break;
- case Instruction::Div: Out << '/'; break;
- case Instruction::Rem: Out << '%'; break;
- case Instruction::And: Out << " & "; break;
- case Instruction::Or: Out << " | "; break;
- case Instruction::Xor: Out << " ^ "; break;
- case Instruction::SetEQ: Out << " == "; break;
- case Instruction::SetNE: Out << " != "; break;
- case Instruction::SetLE: Out << " <= "; break;
- case Instruction::SetGE: Out << " >= "; break;
- case Instruction::SetLT: Out << " < "; break;
- case Instruction::SetGT: Out << " > "; break;
- case Instruction::Shl : Out << " << "; break;
- case Instruction::Shr : Out << " >> "; break;
- default: std::cerr << "Invalid operator type!" << I; abort();
- }
+ // If this is a negation operation, print it out as such. For FP, we don't
+ // want to print "-0.0 - X".
+ if (BinaryOperator::isNeg(&I)) {
+ Out << "-";
+ writeOperand(BinaryOperator::getNegArgument(cast<BinaryOperator>(&I)));
- writeOperand(I.getOperand(1));
+ } else {
+ writeOperand(I.getOperand(0));
+
+ switch (I.getOpcode()) {
+ case Instruction::Add: Out << " + "; break;
+ case Instruction::Sub: Out << " - "; break;
+ case Instruction::Mul: Out << '*'; break;
+ case Instruction::Div: Out << '/'; break;
+ case Instruction::Rem: Out << '%'; break;
+ case Instruction::And: Out << " & "; break;
+ case Instruction::Or: Out << " | "; break;
+ case Instruction::Xor: Out << " ^ "; break;
+ case Instruction::SetEQ: Out << " == "; break;
+ case Instruction::SetNE: Out << " != "; break;
+ case Instruction::SetLE: Out << " <= "; break;
+ case Instruction::SetGE: Out << " >= "; break;
+ case Instruction::SetLT: Out << " < "; break;
+ case Instruction::SetGT: Out << " > "; break;
+ case Instruction::Shl : Out << " << "; break;
+ case Instruction::Shr : Out << " >> "; break;
+ default: std::cerr << "Invalid operator type!" << I; abort();
+ }
+
+ writeOperand(I.getOperand(1));
+ }
if (needsCast) {
Out << "))";
OpenPOWER on IntegriCloud