Reorganize printing interface a bit
authorChris Lattner <sabre@nondot.org>
Sun, 17 Nov 2002 22:53:13 +0000 (22:53 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 17 Nov 2002 22:53:13 +0000 (22:53 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4728 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/Printer.cpp
lib/Target/X86/X86AsmPrinter.cpp
lib/Target/X86/X86InstrInfo.cpp
lib/Target/X86/X86InstrInfo.h

index fdb444e54eef44a82a667d96df5776ccabadd136..f4c9833af555a2abd577d21f3e5d1b4ca30de039 100644 (file)
@@ -11,7 +11,7 @@
 #include "llvm/Function.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/CodeGen/MachineFunction.h"
-#include <iostream>
+#include "llvm/CodeGen/MachineInstr.h"
 
 namespace {
   struct Printer : public FunctionPass {
@@ -24,6 +24,15 @@ namespace {
   };
 }
 
+/// createX86CodePrinterPass - Print out the specified machine code function to
+/// the specified stream.  This function should work regardless of whether or
+/// not the function is in SSA form or not.
+///
+Pass *createX86CodePrinterPass(TargetMachine &TM, std::ostream &O) {
+  return new Printer(TM, O);
+}
+
+
 /// runOnFunction - This uses the X86InstructionInfo::print method
 /// to print assembly for each instruction.
 bool Printer::runOnFunction (Function & F)
@@ -31,9 +40,8 @@ bool Printer::runOnFunction (Function & F)
   static unsigned bbnumber = 0;
   MachineFunction & MF = MachineFunction::get (&F);
   const MachineInstrInfo & MII = TM.getInstrInfo ();
-  const X86InstrInfo & x86ii = dynamic_cast <const X86InstrInfo &> (MII);
 
-  O << "# x86 printing not implemented yet!\n";
+  O << "# x86 printing only sorta implemented so far!\n";
 
   // Print out labels for the function.
   O << "\t.globl\t" << F.getName () << "\n";
@@ -51,7 +59,7 @@ bool Printer::runOnFunction (Function & F)
        {
          // Print the assembly for the instruction.
          O << "\t";
-         x86ii.print (*i_i, O);
+          MII.print(*i_i, O);
        }
     }
 
@@ -59,10 +67,9 @@ bool Printer::runOnFunction (Function & F)
   return false;
 }
 
-/// createX86CodePrinterPass - Print out the specified machine code function to
-/// the specified stream.  This function should work regardless of whether or
-/// not the function is in SSA form or not.
-///
-Pass *createX86CodePrinterPass(TargetMachine &TM, std::ostream &O) {
-  return new Printer(TM, O);
+
+// print - Print out an x86 instruction in intel syntax
+void X86InstrInfo::print(const MachineInstr *MI, std::ostream &O) const {
+  // FIXME: This sucks.
+  O << getName(MI->getOpCode()) << "\n";
 }
index fdb444e54eef44a82a667d96df5776ccabadd136..f4c9833af555a2abd577d21f3e5d1b4ca30de039 100644 (file)
@@ -11,7 +11,7 @@
 #include "llvm/Function.h"
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/CodeGen/MachineFunction.h"
-#include <iostream>
+#include "llvm/CodeGen/MachineInstr.h"
 
 namespace {
   struct Printer : public FunctionPass {
@@ -24,6 +24,15 @@ namespace {
   };
 }
 
+/// createX86CodePrinterPass - Print out the specified machine code function to
+/// the specified stream.  This function should work regardless of whether or
+/// not the function is in SSA form or not.
+///
+Pass *createX86CodePrinterPass(TargetMachine &TM, std::ostream &O) {
+  return new Printer(TM, O);
+}
+
+
 /// runOnFunction - This uses the X86InstructionInfo::print method
 /// to print assembly for each instruction.
 bool Printer::runOnFunction (Function & F)
@@ -31,9 +40,8 @@ bool Printer::runOnFunction (Function & F)
   static unsigned bbnumber = 0;
   MachineFunction & MF = MachineFunction::get (&F);
   const MachineInstrInfo & MII = TM.getInstrInfo ();
-  const X86InstrInfo & x86ii = dynamic_cast <const X86InstrInfo &> (MII);
 
-  O << "# x86 printing not implemented yet!\n";
+  O << "# x86 printing only sorta implemented so far!\n";
 
   // Print out labels for the function.
   O << "\t.globl\t" << F.getName () << "\n";
@@ -51,7 +59,7 @@ bool Printer::runOnFunction (Function & F)
        {
          // Print the assembly for the instruction.
          O << "\t";
-         x86ii.print (*i_i, O);
+          MII.print(*i_i, O);
        }
     }
 
@@ -59,10 +67,9 @@ bool Printer::runOnFunction (Function & F)
   return false;
 }
 
-/// createX86CodePrinterPass - Print out the specified machine code function to
-/// the specified stream.  This function should work regardless of whether or
-/// not the function is in SSA form or not.
-///
-Pass *createX86CodePrinterPass(TargetMachine &TM, std::ostream &O) {
-  return new Printer(TM, O);
+
+// print - Print out an x86 instruction in intel syntax
+void X86InstrInfo::print(const MachineInstr *MI, std::ostream &O) const {
+  // FIXME: This sucks.
+  O << getName(MI->getOpCode()) << "\n";
 }
index c81ddb19003ee82dbdc1d170a177b211a695eb05..e54883395d2d76e0f1a7b525cf4824b6cca272a7 100644 (file)
@@ -25,9 +25,3 @@ X86InstrInfo::X86InstrInfo()
 }
 
 
-// print - Print out an x86 instruction in GAS syntax
-void X86InstrInfo::print(const MachineInstr *MI, std::ostream &O) const {
-  // FIXME: This sucks.
-  O << getName(MI->getOpCode()) << "\n";
-}
-
index 4850d5ee662d490e7210245d4db90c2ab30ba0e5..c0451643a57b8aa4353357209550ed8fbde8d5ae 100644 (file)
@@ -30,7 +30,7 @@ public:
   ///
   virtual const MRegisterInfo &getRegisterInfo() const { return RI; }
 
-  /// print - Print out an x86 instruction in GAS syntax
+  /// print - Print out an x86 instruction in intel syntax
   ///
   virtual void print(const MachineInstr *MI, std::ostream &O) const;