OSDN Git Service

Print "X-42" instead of "X+-42".
authorChris Lattner <sabre@nondot.org>
Tue, 8 Sep 2009 06:37:35 +0000 (06:37 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 8 Sep 2009 06:37:35 +0000 (06:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81203 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCExpr.cpp

index 2bb674f..3eae6bd 100644 (file)
@@ -51,7 +51,17 @@ void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
     
     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;