[llvm-commits] [llvm] r81203 - /llvm/trunk/lib/MC/MCExpr.cpp

Chris Lattner sabre at nondot.org
Mon Sep 7 23:37:35 PDT 2009


Author: lattner
Date: Tue Sep  8 01:37:35 2009
New Revision: 81203

URL: http://llvm.org/viewvc/llvm-project?rev=81203&view=rev
Log:
Print "X-42" instead of "X+-42".

Modified:
    llvm/trunk/lib/MC/MCExpr.cpp

Modified: llvm/trunk/lib/MC/MCExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCExpr.cpp?rev=81203&r1=81202&r2=81203&view=diff

==============================================================================
--- llvm/trunk/lib/MC/MCExpr.cpp (original)
+++ llvm/trunk/lib/MC/MCExpr.cpp Tue Sep  8 01:37:35 2009
@@ -51,7 +51,17 @@
     
     switch (BE.getOpcode()) {
     default: assert(0 && "Invalid opcode!");
-    case MCBinaryExpr::Add:  OS <<  '+'; break;
+    case MCBinaryExpr::Add:
+      // Print "X-42" instead of "X+-42".
+      if (const MCConstantExpr *RHSC = dyn_cast<MCConstantExpr>(BE.getRHS())) {
+        if (RHSC->getValue() < 0) {
+          OS << RHSC->getValue();
+          return;
+        }
+      }
+        
+      OS <<  '+';
+      break;
     case MCBinaryExpr::And:  OS <<  '&'; break;
     case MCBinaryExpr::Div:  OS <<  '/'; break;
     case MCBinaryExpr::EQ:   OS << "=="; break;





More information about the llvm-commits mailing list