OSDN Git Service

wire up support for MCContext/MCStreamer in -experimental-asm-printer mode.
authorChris Lattner <sabre@nondot.org>
Wed, 24 Jun 2009 05:46:28 +0000 (05:46 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 24 Jun 2009 05:46:28 +0000 (05:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74066 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.h

index 60ed4f0..f4196fd 100644 (file)
@@ -26,7 +26,9 @@
 #include "llvm/Type.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/MC/MCContext.h"
 #include "llvm/MC/MCInst.h"
+#include "llvm/MC/MCStreamer.h"
 #include "llvm/CodeGen/DwarfWriter.h"
 #include "llvm/CodeGen/MachineJumpTableInfo.h"
 #include "llvm/Support/CommandLine.h"
@@ -933,6 +935,14 @@ void X86ATTAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
 bool X86ATTAsmPrinter::doInitialization(Module &M) {
   if (TAI->doesSupportDebugInformation() || TAI->doesSupportExceptionHandling()) 
     MMI = getAnalysisIfAvailable<MachineModuleInfo>();
+  
+  if (NewAsmPrinter) {
+    Context = new MCContext();
+    // FIXME: Send this to "O" instead of outs().  For now, we force it to
+    // stdout to make it easy to compare.
+    Streamer = createAsmStreamer(*Context, outs());
+  }
+  
   return AsmPrinter::doInitialization(M);
 }
 
@@ -1214,6 +1224,15 @@ bool X86ATTAsmPrinter::doFinalization(Module &M) {
       DW->EndModule();
   }
 
+  if (NewAsmPrinter) {
+    Streamer->Finish();
+    
+    delete Streamer;
+    delete Context;
+    Streamer = 0;
+    Context = 0;
+  }
+  
   return AsmPrinter::doFinalization(M);
 }
 
index 68a6bc8..051adf7 100644 (file)
 namespace llvm {
 
 class MachineJumpTableInfo;
+class MCContext;
 class MCInst;
+class MCStreamer;
 
 class VISIBILITY_HIDDEN X86ATTAsmPrinter : public AsmPrinter {
   MachineModuleInfo *MMI;
   const X86Subtarget *Subtarget;
+  
+  MCContext *Context;
+  MCStreamer *Streamer;
  public:
   explicit X86ATTAsmPrinter(raw_ostream &O, X86TargetMachine &TM,
                             const TargetAsmInfo *T, CodeGenOpt::Level OL,
                             bool V)
     : AsmPrinter(O, TM, T, OL, V), MMI(0) {
     Subtarget = &TM.getSubtarget<X86Subtarget>();
+    Context = 0;
+    Streamer = 0;
   }
 
   virtual const char *getPassName() const {