remove the MAI argument to MCExpr::print and switch overthing to use << when printing...
authorChris Lattner <sabre@nondot.org>
Mon, 18 Jan 2010 00:37:40 +0000 (00:37 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 18 Jan 2010 00:37:40 +0000 (00:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93699 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCExpr.h
lib/CodeGen/AsmPrinter/DwarfException.cpp
lib/MC/MCAsmStreamer.cpp
lib/MC/MCExpr.cpp
lib/MC/MCInst.cpp
lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp
lib/Target/MSP430/AsmPrinter/MSP430InstPrinter.cpp
lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp
lib/Target/X86/AsmPrinter/X86IntelInstPrinter.cpp

index 13d40eca7c968e74266b71109719e1f1a56c4b65..73d5f8ef51516b055647ce5784c089bd6dc0e2d2 100644 (file)
@@ -51,7 +51,7 @@ public:
   /// @name Utility Methods
   /// @{
 
-  void print(raw_ostream &OS, const MCAsmInfo *MAI) const;
+  void print(raw_ostream &OS) const;
   void dump() const;
 
   /// @}
@@ -75,6 +75,11 @@ public:
 
   static bool classof(const MCExpr *) { return true; }
 };
+  
+inline raw_ostream &operator<<(raw_ostream &OS, const MCExpr &E) {
+  E.print(OS);
+  return OS;
+}
 
 //// MCConstantExpr - Represent a constant integer expression.
 class MCConstantExpr : public MCExpr {
index ad6df15c443dcf5e70724c5baa0d8b5b28486d6c..8de9bd65cac5ff9a22cf3c05e0cfa28334efb0d1 100644 (file)
@@ -194,8 +194,7 @@ void DwarfException::EmitCIE(const Function *PersonalityFn, unsigned Index) {
       PersonalityRef = CreateLabelDiff(PersonalityRef, "personalityref_addr",
                                        Index);
 
-    O << MAI->getData32bitsDirective();
-    PersonalityRef->print(O, MAI);
+    O << MAI->getData32bitsDirective() << *PersonalityRef;
     Asm->EOL("Personality");
 
     Asm->EmitInt8(LSDAEncoding);
index 9e8c7ce59eba0169682ea1bc6117059368477c68..4768c623552b91fdf69255a3798bf7ba71caa4f5 100644 (file)
@@ -118,9 +118,7 @@ void MCAsmStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
   assert((Symbol->isUndefined() || Symbol->isAbsolute()) &&
          "Cannot define a symbol twice!");
 
-  OS << *Symbol << " = ";
-  Value->print(OS, &MAI);
-  OS << '\n';
+  OS << *Symbol << " = " << *Value << '\n';
 
   // FIXME: Lift context changes into super class.
   // FIXME: Set associated section.
@@ -194,9 +192,7 @@ void MCAsmStreamer::EmitValue(const MCExpr *Value, unsigned Size) {
   case 8: OS << ".quad"; break;
   }
 
-  OS << ' ';
-  truncateToSize(Value, Size)->print(OS, &MAI);
-  OS << '\n';
+  OS << ' ' << *truncateToSize(Value, Size) << '\n';
 }
 
 void MCAsmStreamer::EmitValueToAlignment(unsigned ByteAlignment, int64_t Value,
@@ -250,9 +246,7 @@ void MCAsmStreamer::EmitValueToAlignment(unsigned ByteAlignment, int64_t Value,
 void MCAsmStreamer::EmitValueToOffset(const MCExpr *Offset,
                                       unsigned char Value) {
   // FIXME: Verify that Offset is associated with the current section.
-  OS << ".org ";
-  Offset->print(OS, &MAI);
-  OS << ", " << (unsigned) Value << '\n';
+  OS << ".org " << *Offset << ", " << (unsigned) Value << '\n';
 }
 
 void MCAsmStreamer::EmitInstruction(const MCInst &Inst) {
index 57d02c95f13a87a1f8c82709a79e54aa5a393f4a..1ee1b1bddb7b10da7a0e5ae11f0addc7fa20ffb8 100644 (file)
@@ -15,7 +15,7 @@
 #include "llvm/Support/raw_ostream.h"
 using namespace llvm;
 
-void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
+void MCExpr::print(raw_ostream &OS) const {
   switch (getKind()) {
   case MCExpr::Constant:
     OS << cast<MCConstantExpr>(*this).getValue();
@@ -42,7 +42,7 @@ void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
     case MCUnaryExpr::Not:   OS << '~'; break;
     case MCUnaryExpr::Plus:  OS << '+'; break;
     }
-    UE.getSubExpr()->print(OS, MAI);
+    OS << *UE.getSubExpr();
     return;
   }
 
@@ -51,11 +51,9 @@ void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
     
     // Only print parens around the LHS if it is non-trivial.
     if (isa<MCConstantExpr>(BE.getLHS()) || isa<MCSymbolRefExpr>(BE.getLHS())) {
-      BE.getLHS()->print(OS, MAI);
+      OS << *BE.getLHS();
     } else {
-      OS << '(';
-      BE.getLHS()->print(OS, MAI);
-      OS << ')';
+      OS << '(' << *BE.getLHS() << ')';
     }
     
     switch (BE.getOpcode()) {
@@ -92,11 +90,9 @@ void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
     
     // Only print parens around the LHS if it is non-trivial.
     if (isa<MCConstantExpr>(BE.getRHS()) || isa<MCSymbolRefExpr>(BE.getRHS())) {
-      BE.getRHS()->print(OS, MAI);
+      OS << *BE.getRHS();
     } else {
-      OS << '(';
-      BE.getRHS()->print(OS, MAI);
-      OS << ')';
+      OS << '(' << *BE.getRHS() << ')';
     }
     return;
   }
@@ -106,7 +102,7 @@ void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
 }
 
 void MCExpr::dump() const {
-  print(dbgs(), 0);
+  print(dbgs());
   dbgs() << '\n';
 }
 
index 7c7a6447736c507e80c08f1a04bd8f0db69261d1..0634c9faf6fad26e2db09ae964a4858e00d0bec6 100644 (file)
@@ -23,9 +23,7 @@ void MCOperand::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
   else if (isImm())
     OS << "Imm:" << getImm();
   else if (isExpr()) {
-    OS << "Expr:(";
-    getExpr()->print(OS, MAI);
-    OS << ")";
+    OS << "Expr:(" << *getExpr() << ")";
   } else
     OS << "UNDEFINED";
   OS << ">";
index 9fc57e0de59dc5b75562708a9e921b6877ccfc2b..6885ecb25d4a0a7948e49e118908898f5d6fd637 100644 (file)
@@ -62,7 +62,7 @@ void ARMInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
   } else {
     assert((Modifier == 0 || Modifier[0] == 0) && "No modifiers supported");
     assert(Op.isExpr() && "unknown operand kind in printOperand");
-    Op.getExpr()->print(O, &MAI);
+    O << *Op.getExpr();
   }
 }
 
index 0a403c4d29ebc83e9e66efefb3483c26a8d5d4bf..a4803071523e08b23b008d5f16541b2945766b90 100644 (file)
@@ -39,7 +39,7 @@ void MSP430InstPrinter::printPCRelImmOperand(const MCInst *MI, unsigned OpNo) {
     O << Op.getImm();
   else {
     assert(Op.isExpr() && "unknown pcrel immediate operand");
-    Op.getExpr()->print(O, &MAI);
+    O << *Op.getExpr();
   }
 }
 
@@ -53,8 +53,7 @@ void MSP430InstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
     O << '#' << Op.getImm();
   } else {
     assert(Op.isExpr() && "unknown operand kind in printOperand");
-    O << '#';
-    Op.getExpr()->print(O, &MAI);
+    O << '#' << *Op.getExpr();
   }
 }
 
@@ -65,8 +64,7 @@ void MSP430InstPrinter::printSrcMemOperand(const MCInst *MI, unsigned OpNo,
 
   // Print displacement first
   if (Disp.isExpr()) {
-    O << '&';
-    Disp.getExpr()->print(O, &MAI);
+    O << '&' << *Disp.getExpr();
   } else {
     assert(Disp.isImm() && "Expected immediate in displacement field");
     if (!Base.getReg())
index c74b97af308d274bad1a640ec45076a9589d4480..804dbb927e896b116eda0d1bf0583917b269b302 100644 (file)
@@ -55,7 +55,7 @@ void X86ATTInstPrinter::print_pcrel_imm(const MCInst *MI, unsigned OpNo) {
     O << (int)Op.getImm();
   else {
     assert(Op.isExpr() && "unknown pcrel immediate operand");
-    Op.getExpr()->print(O, &MAI);
+    O << *Op.getExpr();
   }
 }
 
@@ -68,8 +68,7 @@ void X86ATTInstPrinter::printOperand(const MCInst *MI, unsigned OpNo) {
     O << '$' << Op.getImm();
   } else {
     assert(Op.isExpr() && "unknown operand kind in printOperand");
-    O << '$';
-    Op.getExpr()->print(O, &MAI);
+    O << '$' << *Op.getExpr();
   }
 }
 
@@ -84,7 +83,7 @@ void X86ATTInstPrinter::printLeaMemReference(const MCInst *MI, unsigned Op) {
       O << DispVal;
   } else {
     assert(DispSpec.isExpr() && "non-immediate displacement for LEA?");
-    DispSpec.getExpr()->print(O, &MAI);
+    O << *DispSpec.getExpr();
   }
   
   if (IndexReg.getReg() || BaseReg.getReg()) {
index fde5902357b28490d5107e5e17d06fe564b725e1..4efb5294fb8a6a1412f1d882812d19a041c0b1a8 100644 (file)
@@ -52,7 +52,7 @@ void X86IntelInstPrinter::print_pcrel_imm(const MCInst *MI, unsigned OpNo) {
     O << Op.getImm();
   else {
     assert(Op.isExpr() && "unknown pcrel immediate operand");
-    Op.getExpr()->print(O, &MAI);
+    O << *Op.getExpr();
   }
 }
 
@@ -72,7 +72,7 @@ void X86IntelInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
     O << Op.getImm();
   } else {
     assert(Op.isExpr() && "unknown operand kind in printOperand");
-    Op.getExpr()->print(O, &MAI);
+    O << *Op.getExpr();
   }
 }
 
@@ -102,7 +102,7 @@ void X86IntelInstPrinter::printLeaMemReference(const MCInst *MI, unsigned Op) {
   if (!DispSpec.isImm()) {
     if (NeedPlus) O << " + ";
     assert(DispSpec.isExpr() && "non-immediate displacement for LEA?");
-    DispSpec.getExpr()->print(O, &MAI);
+    O << *DispSpec.getExpr();
   } else {
     int64_t DispVal = DispSpec.getImm();
     if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg())) {