Give MCInstPrinter a MCAsmInfo member, make X86ATTInstPrinter
authorChris Lattner <sabre@nondot.org>
Mon, 14 Sep 2009 01:49:26 +0000 (01:49 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 14 Sep 2009 01:49:26 +0000 (01:49 +0000)
be a MCInstPrinter.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81746 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCInstPrinter.h
lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
lib/Target/X86/AsmPrinter/X86ATTInstPrinter.cpp
lib/Target/X86/AsmPrinter/X86ATTInstPrinter.h

index 1c04564ebc575d50c5c43f0b8b1481297420a882..d62a9dae7c540e838af0a7d980f830700d5ca9b4 100644 (file)
 namespace llvm {
 class MCInst;
 class raw_ostream;
+class MCAsmInfo;
+
   
 /// MCInstPrinter - This is an instance of a target assembly language printer
 /// that converts an MCInst to valid target assembly syntax.
 class MCInstPrinter {
+protected:
   raw_ostream &O;
+  const MCAsmInfo &MAI;
 public:
-  MCInstPrinter(raw_ostream &o) : O(o) {}
+  MCInstPrinter(raw_ostream &o, const MCAsmInfo &mai) : O(o), MAI(mai) {}
   
   virtual ~MCInstPrinter();
   
index 4aef27e3303171d96046448ae79b266f7075f3ff..c2c3855df72cdc33b40c0bf66b134d9c7e6af6cb 100644 (file)
@@ -48,7 +48,7 @@ STATISTIC(EmittedInsts, "Number of machine instrs printed");
 //===----------------------------------------------------------------------===//
 
 void X86ATTAsmPrinter::printMCInst(const MCInst *MI) {
-  X86ATTInstPrinter(O, MAI).printInstruction(MI);
+  X86ATTInstPrinter(O, *MAI).printInstruction(MI);
 }
 
 void X86ATTAsmPrinter::PrintPICBaseSymbol() const {
index f943ccf7e354b32616da645ed2044b4eff7f6a58..7576ab371d021128518f870b1eb98a7b088baab7 100644 (file)
@@ -27,6 +27,8 @@ using namespace llvm;
 #include "X86GenAsmWriter.inc"
 #undef MachineInstr
 
+void X86ATTInstPrinter::printInst(const MCInst *MI) { printInstruction(MI); }
+
 void X86ATTInstPrinter::printSSECC(const MCInst *MI, unsigned Op) {
   switch (MI->getOperand(Op).getImm()) {
   default: llvm_unreachable("Invalid ssecc argument!");
@@ -55,7 +57,7 @@ void X86ATTInstPrinter::print_pcrel_imm(const MCInst *MI, unsigned OpNo) {
     O << Op.getImm();
   else {
     assert(Op.isExpr() && "unknown pcrel immediate operand");
-    Op.getExpr()->print(O, MAI);
+    Op.getExpr()->print(O, &MAI);
   }
 }
 
@@ -71,7 +73,7 @@ void X86ATTInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
   } else {
     assert(Op.isExpr() && "unknown operand kind in printOperand");
     O << '$';
-    Op.getExpr()->print(O, MAI);
+    Op.getExpr()->print(O, &MAI);
   }
 }
 
@@ -86,7 +88,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);
+    DispSpec.getExpr()->print(O, &MAI);
   }
   
   if (IndexReg.getReg() || BaseReg.getReg()) {
index 5969ca939a1312f887353c3bd315c9ac782811b8..4aa738e61e8766a653b8c9cadf88b5aa5045047e 100644 (file)
 #ifndef X86_ATT_INST_PRINTER_H
 #define X86_ATT_INST_PRINTER_H
 
+#include "llvm/MC/MCInstPrinter.h"
+
 namespace llvm {
-  class MCAsmInfo;
-  class MCInst;
   class MCOperand;
-  class raw_ostream;
   
-class X86ATTInstPrinter {
-  raw_ostream &O;
-  const MCAsmInfo *MAI;
+class X86ATTInstPrinter : public MCInstPrinter {
 public:
-  X86ATTInstPrinter(raw_ostream &o, const MCAsmInfo *mai) : O(o), MAI(mai) {}
+  X86ATTInstPrinter(raw_ostream &O, const MCAsmInfo &MAI)
+    : MCInstPrinter(O, MAI) {}
 
+  
+  virtual void printInst(const MCInst *MI);
+  
   // Autogenerated by tblgen.
   void printInstruction(const MCInst *MI);
   static const char *getRegisterName(unsigned RegNo);