[llvm-commits] [llvm] r80890 - in /llvm/trunk: include/llvm/MC/MCExpr.h include/llvm/MC/MCInst.h include/llvm/MC/MCSymbol.h include/llvm/MC/MCValue.h lib/MC/MCAsmStreamer.cpp lib/MC/MCExpr.cpp lib/MC/MCInst.cpp lib/MC/MCSymbol.cpp lib/MC/MCValue.cpp lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp

Chris Lattner sabre at nondot.org
Wed Sep 2 22:46:52 PDT 2009


Author: lattner
Date: Thu Sep  3 00:46:51 2009
New Revision: 80890

URL: http://llvm.org/viewvc/llvm-project?rev=80890&view=rev
Log:
Thread an MCAsmInfo pointer through the various MC printing APIs, 
and fix a few things using << on MCSymbols to use ->print(). No
functionality change other than unbreaking my previous patch.

Modified:
    llvm/trunk/include/llvm/MC/MCExpr.h
    llvm/trunk/include/llvm/MC/MCInst.h
    llvm/trunk/include/llvm/MC/MCSymbol.h
    llvm/trunk/include/llvm/MC/MCValue.h
    llvm/trunk/lib/MC/MCAsmStreamer.cpp
    llvm/trunk/lib/MC/MCExpr.cpp
    llvm/trunk/lib/MC/MCInst.cpp
    llvm/trunk/lib/MC/MCSymbol.cpp
    llvm/trunk/lib/MC/MCValue.cpp
    llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp

Modified: llvm/trunk/include/llvm/MC/MCExpr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCExpr.h?rev=80890&r1=80889&r2=80890&view=diff

==============================================================================
--- llvm/trunk/include/llvm/MC/MCExpr.h (original)
+++ llvm/trunk/include/llvm/MC/MCExpr.h Thu Sep  3 00:46:51 2009
@@ -14,6 +14,7 @@
 #include "llvm/Support/DataTypes.h"
 
 namespace llvm {
+class MCAsmInfo;
 class MCContext;
 class MCSymbol;
 class MCValue;
@@ -49,7 +50,7 @@
   /// @name Utility Methods
   /// @{
 
-  void print(raw_ostream &OS) const;
+  void print(raw_ostream &OS, const MCAsmInfo *MAI) const;
   void dump() const;
 
   /// @}

Modified: llvm/trunk/include/llvm/MC/MCInst.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCInst.h?rev=80890&r1=80889&r2=80890&view=diff

==============================================================================
--- llvm/trunk/include/llvm/MC/MCInst.h (original)
+++ llvm/trunk/include/llvm/MC/MCInst.h Thu Sep  3 00:46:51 2009
@@ -22,6 +22,7 @@
 
 namespace llvm {
 class raw_ostream;
+class MCAsmInfo;
 class MCExpr;
 
 /// MCOperand - Instances of this class represent operands of the MCInst class.
@@ -121,7 +122,7 @@
     return Op;
   }
 
-  void print(raw_ostream &OS) const;
+  void print(raw_ostream &OS, const MCAsmInfo *MAI) const;
   void dump() const;
 };
 
@@ -147,7 +148,7 @@
     Operands.push_back(Op);
   }
 
-  void print(raw_ostream &OS) const;
+  void print(raw_ostream &OS, const MCAsmInfo *MAI) const;
   void dump() const;
 };
 

Modified: llvm/trunk/include/llvm/MC/MCSymbol.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSymbol.h?rev=80890&r1=80889&r2=80890&view=diff

==============================================================================
--- llvm/trunk/include/llvm/MC/MCSymbol.h (original)
+++ llvm/trunk/include/llvm/MC/MCSymbol.h Thu Sep  3 00:46:51 2009
@@ -19,6 +19,7 @@
 #include "llvm/Support/DataTypes.h"
 
 namespace llvm {
+  class MCAsmInfo;
   class MCSection;
   class MCContext;
   class raw_ostream;
@@ -106,7 +107,7 @@
     /// @}
 
     /// print - Print the value to the stream \arg OS.
-    void print(raw_ostream &OS) const;
+    void print(raw_ostream &OS, const MCAsmInfo *MAI) const;
 
     /// dump - Print the value to stderr.
     void dump() const;

Modified: llvm/trunk/include/llvm/MC/MCValue.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCValue.h?rev=80890&r1=80889&r2=80890&view=diff

==============================================================================
--- llvm/trunk/include/llvm/MC/MCValue.h (original)
+++ llvm/trunk/include/llvm/MC/MCValue.h Thu Sep  3 00:46:51 2009
@@ -55,7 +55,7 @@
   const MCSection *getAssociatedSection() const;
 
   /// print - Print the value to the stream \arg OS.
-  void print(raw_ostream &OS) const;
+  void print(raw_ostream &OS, const MCAsmInfo *MAI) const;
   
   /// dump - Print the value to stderr.
   void dump() const;

Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=80890&r1=80889&r2=80890&view=diff

==============================================================================
--- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Thu Sep  3 00:46:51 2009
@@ -101,7 +101,8 @@
   assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
   assert(CurSection && "Cannot emit before setting section!");
 
-  OS << Symbol << ":\n";
+  Symbol->print(OS, &MAI);
+  OS << ":\n";
   Symbol->setSection(*CurSection);
 }
 
@@ -118,8 +119,9 @@
   assert((Symbol->isUndefined() || Symbol->isAbsolute()) &&
          "Cannot define a symbol twice!");
 
-  OS << Symbol << " = ";
-  Value->print(OS);
+  Symbol->print(OS, &MAI);
+  OS << " = ";
+  Value->print(OS, &MAI);
   OS << '\n';
 }
 
@@ -140,17 +142,22 @@
   case WeakReference: OS << ".weak_reference"; break;
   }
 
-  OS << ' ' << Symbol << '\n';
+  OS << ' ';
+  Symbol->print(OS, &MAI);
+  OS << '\n';
 }
 
 void MCAsmStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
-  OS << ".desc" << ' ' << Symbol << ',' << DescValue << '\n';
+  OS << ".desc" << ' ';
+  Symbol->print(OS, &MAI);
+  OS << ',' << DescValue << '\n';
 }
 
 void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, unsigned Size,
                                      unsigned ByteAlignment) {
-  OS << ".comm";
-  OS << ' ' << Symbol << ',' << Size;
+  OS << ".comm ";
+  Symbol->print(OS, &MAI);
+  OS << ',' << Size;
   if (ByteAlignment != 0)
     OS << ',' << Log2_32(ByteAlignment);
   OS << '\n';
@@ -166,7 +173,9 @@
   OS << MOSection->getSegmentName() << "," << MOSection->getSectionName();
   
   if (Symbol != NULL) {
-    OS << ',' << Symbol << ',' << Size;
+    OS << ',';
+    Symbol->print(OS, &MAI);
+    OS << ',' << Size;
     if (ByteAlignment != 0)
       OS << ',' << Log2_32(ByteAlignment);
   }
@@ -192,7 +201,7 @@
   }
 
   OS << ' ';
-  truncateToSize(Value, Size)->print(OS);
+  truncateToSize(Value, Size)->print(OS, &MAI);
   OS << '\n';
 }
 
@@ -248,7 +257,7 @@
                                       unsigned char Value) {
   // FIXME: Verify that Offset is associated with the current section.
   OS << ".org ";
-  Offset->print(OS);
+  Offset->print(OS, &MAI);
   OS << ", " << (unsigned) Value << '\n';
 }
 
@@ -281,7 +290,7 @@
 
   // Otherwise fall back to a structural printing for now. Eventually we should
   // always have access to the target specific printer.
-  Inst.print(OS);
+  Inst.print(OS, &MAI);
   OS << '\n';
 }
 

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

==============================================================================
--- llvm/trunk/lib/MC/MCExpr.cpp (original)
+++ llvm/trunk/lib/MC/MCExpr.cpp Thu Sep  3 00:46:51 2009
@@ -14,14 +14,14 @@
 #include "llvm/Support/raw_ostream.h"
 using namespace llvm;
 
-void MCExpr::print(raw_ostream &OS) const {
+void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
   switch (getKind()) {
   case MCExpr::Constant:
     OS << cast<MCConstantExpr>(*this).getValue();
     return;
 
   case MCExpr::SymbolRef:
-    cast<MCSymbolRefExpr>(*this).getSymbol().print(OS);
+    cast<MCSymbolRefExpr>(*this).getSymbol().print(OS, MAI);
     return;
 
   case MCExpr::Unary: {
@@ -33,14 +33,14 @@
     case MCUnaryExpr::Not:   OS << '~'; break;
     case MCUnaryExpr::Plus:  OS << '+'; break;
     }
-    UE.getSubExpr()->print(OS);
+    UE.getSubExpr()->print(OS, MAI);
     return;
   }
 
   case MCExpr::Binary: {
     const MCBinaryExpr &BE = cast<MCBinaryExpr>(*this);
     OS << '(';
-    BE.getLHS()->print(OS);
+    BE.getLHS()->print(OS, MAI);
     OS << ' ';
     switch (BE.getOpcode()) {
     default: assert(0 && "Invalid opcode!");
@@ -64,7 +64,7 @@
     case MCBinaryExpr::Xor:  OS <<  '^'; break;
     }
     OS << ' ';
-    BE.getRHS()->print(OS);
+    BE.getRHS()->print(OS, MAI);
     OS << ')';
     return;
   }
@@ -74,7 +74,7 @@
 }
 
 void MCExpr::dump() const {
-  print(errs());
+  print(errs(), 0);
   errs() << '\n';
 }
 

Modified: llvm/trunk/lib/MC/MCInst.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCInst.cpp?rev=80890&r1=80889&r2=80890&view=diff

==============================================================================
--- llvm/trunk/lib/MC/MCInst.cpp (original)
+++ llvm/trunk/lib/MC/MCInst.cpp Thu Sep  3 00:46:51 2009
@@ -13,7 +13,7 @@
 
 using namespace llvm;
 
-void MCOperand::print(raw_ostream &OS) const {
+void MCOperand::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
   OS << "<MCOperand ";
   if (!isValid())
     OS << "INVALID";
@@ -26,7 +26,7 @@
        << getMBBLabelBlock() << ")";
   else if (isExpr()) {
     OS << "Expr:(";
-    getExpr()->print(OS);
+    getExpr()->print(OS, MAI);
     OS << ")";
   } else
     OS << "UNDEFINED";
@@ -34,20 +34,20 @@
 }
 
 void MCOperand::dump() const {
-  print(errs());
+  print(errs(), 0);
   errs() << "\n";
 }
 
-void MCInst::print(raw_ostream &OS) const {
+void MCInst::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
   OS << "<MCInst " << getOpcode();
   for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
     OS << " ";
-    getOperand(i).print(OS);
+    getOperand(i).print(OS, MAI);
   }
   OS << ">";
 }
 
 void MCInst::dump() const {
-  print(errs());
+  print(errs(), 0);
   errs() << "\n";
 }

Modified: llvm/trunk/lib/MC/MCSymbol.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCSymbol.cpp?rev=80890&r1=80889&r2=80890&view=diff

==============================================================================
--- llvm/trunk/lib/MC/MCSymbol.cpp (original)
+++ llvm/trunk/lib/MC/MCSymbol.cpp Thu Sep  3 00:46:51 2009
@@ -41,7 +41,7 @@
   return false;
 }
 
-void MCSymbol::print(raw_ostream &OS) const {
+void MCSymbol::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
   if (NeedsQuoting(getName()))
     OS << '"' << getName() << '"';
   else
@@ -49,5 +49,5 @@
 }
 
 void MCSymbol::dump() const {
-  print(errs());
+  print(errs(), 0);
 }

Modified: llvm/trunk/lib/MC/MCValue.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCValue.cpp?rev=80890&r1=80889&r2=80890&view=diff

==============================================================================
--- llvm/trunk/lib/MC/MCValue.cpp (original)
+++ llvm/trunk/lib/MC/MCValue.cpp Thu Sep  3 00:46:51 2009
@@ -12,17 +12,17 @@
 
 using namespace llvm;
 
-void MCValue::print(raw_ostream &OS) const {
+void MCValue::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
   if (isAbsolute()) {
     OS << getConstant();
     return;
   }
 
-  getSymA()->print(OS);
+  getSymA()->print(OS, MAI);
 
   if (getSymB()) {
     OS << " - "; 
-    getSymB()->print(OS);
+    getSymB()->print(OS, MAI);
   }
 
   if (getConstant())
@@ -30,5 +30,5 @@
 }
 
 void MCValue::dump() const {
-  print(errs());
+  print(errs(), 0);
 }

Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp?rev=80890&r1=80889&r2=80890&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp Thu Sep  3 00:46:51 2009
@@ -57,7 +57,7 @@
   if (Op.isImm())
     O << Op.getImm();
   else if (Op.isExpr())
-    Op.getExpr()->print(O);
+    Op.getExpr()->print(O, MAI);
   else if (Op.isMBBLabel())
     // FIXME: Keep in sync with printBasicBlockLabel.  printBasicBlockLabel
     // should eventually call into this code, not the other way around.
@@ -93,7 +93,7 @@
     return;
   } else if (Op.isExpr()) {
     O << '$';
-    Op.getExpr()->print(O);
+    Op.getExpr()->print(O, MAI);
     return;
   }
   
@@ -111,7 +111,7 @@
     if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg()))
       O << DispVal;
   } else if (DispSpec.isExpr()) {
-    DispSpec.getExpr()->print(O);
+    DispSpec.getExpr()->print(O, MAI);
   } else {
     llvm_unreachable("non-immediate displacement for LEA?");
     //assert(DispSpec.isGlobal() || DispSpec.isCPI() ||





More information about the llvm-commits mailing list