createMCInstPrinter doesn't need TargetMachine anymore.
authorEvan Cheng <evan.cheng@apple.com>
Wed, 6 Jul 2011 19:45:42 +0000 (19:45 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Wed, 6 Jul 2011 19:45:42 +0000 (19:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134525 91177308-0d34-0410-b5e6-96231b3b80d8

22 files changed:
include/llvm/Target/TargetRegistry.h
lib/CodeGen/LLVMTargetMachine.cpp
lib/CodeGen/ScheduleDAGEmit.cpp
lib/MC/MCDisassembler/Disassembler.cpp
lib/MC/MCDisassembler/EDDisassembler.cpp
lib/Target/ARM/ARMAsmPrinter.cpp
lib/Target/ARM/InstPrinter/ARMInstPrinter.h
lib/Target/MBlaze/InstPrinter/MBlazeInstPrinter.h
lib/Target/MBlaze/MBlazeAsmPrinter.cpp
lib/Target/MSP430/InstPrinter/MSP430InstPrinter.h
lib/Target/MSP430/MSP430AsmPrinter.cpp
lib/Target/PowerPC/InstPrinter/PPCInstPrinter.h
lib/Target/PowerPC/PPCAsmPrinter.cpp
lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp
lib/Target/X86/InstPrinter/X86ATTInstPrinter.h
lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp
lib/Target/X86/InstPrinter/X86IntelInstPrinter.h
lib/Target/X86/X86AsmPrinter.cpp
tools/llvm-mc/Disassembler.cpp
tools/llvm-mc/Disassembler.h
tools/llvm-mc/llvm-mc.cpp
tools/llvm-objdump/llvm-objdump.cpp

index 2e79488ecbb21b7075ea88bb6b055f19c3fbea2b..4c7783559a72e49b13958b9363e86c6103541f4b 100644 (file)
@@ -85,7 +85,6 @@ namespace llvm {
                                                 TargetMachine &TM);
     typedef MCDisassembler *(*MCDisassemblerCtorTy)(const Target &T);
     typedef MCInstPrinter *(*MCInstPrinterCtorTy)(const Target &T,
-                                                  TargetMachine &TM,
                                                   unsigned SyntaxVariant,
                                                   const MCAsmInfo &MAI);
     typedef MCCodeEmitter *(*CodeEmitterCtorTy)(const Target &T,
@@ -334,12 +333,11 @@ namespace llvm {
       return MCDisassemblerCtorFn(*this);
     }
 
-    MCInstPrinter *createMCInstPrinter(TargetMachine &TM,
-                                       unsigned SyntaxVariant,
+    MCInstPrinter *createMCInstPrinter(unsigned SyntaxVariant,
                                        const MCAsmInfo &MAI) const {
       if (!MCInstPrinterCtorFn)
         return 0;
-      return MCInstPrinterCtorFn(*this, TM, SyntaxVariant, MAI);
+      return MCInstPrinterCtorFn(*this, SyntaxVariant, MAI);
     }
 
 
index b1033312ca344ce96c004a862e9f8bf6a255f367..318bf976d4080e194cb3878d509a881eb06a6ecc 100644 (file)
@@ -136,7 +136,7 @@ bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
   default: return true;
   case CGFT_AssemblyFile: {
     MCInstPrinter *InstPrinter =
-      getTarget().createMCInstPrinter(*this, MAI.getAssemblerDialect(), MAI);
+      getTarget().createMCInstPrinter(MAI.getAssemblerDialect(), MAI);
 
     // Create a code emitter if asked to show the encoding.
     MCCodeEmitter *MCE = 0;
index 6b7a8c6491bd1b699e067bfe45ffdd9adac8441d..f8b1bc76eb8bb3b9a86b86dd4ab48f340c4d0a32 100644 (file)
@@ -45,6 +45,7 @@ void ScheduleDAG::EmitPhysRegCopy(SUnit *SU,
       unsigned Reg = 0;
       for (SUnit::const_succ_iterator II = SU->Succs.begin(),
              EE = SU->Succs.end(); II != EE; ++II) {
+        if (II->isCtrl()) continue;  // ignore chain preds
         if (II->getReg()) {
           Reg = II->getReg();
           break;
index 6d6777e03c6da517d24d62f5e0e2b37221345a6c..154b653f701314573283d43360e2fc2b81599899 100644 (file)
@@ -79,7 +79,7 @@ LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
 
   // Set up the instruction printer.
   int AsmPrinterVariant = MAI->getAssemblerDialect();
-  MCInstPrinter *IP = TheTarget->createMCInstPrinter(*TM, AsmPrinterVariant,
+  MCInstPrinter *IP = TheTarget->createMCInstPrinter(AsmPrinterVariant,
                                                      *MAI);
   assert(IP && "Unable to create instruction printer!");
 
index 2a46d37c14917f5fa37f24ff70a19fa4bc3bc9a8..7f9fcc3af5ebfa0c62d25b6dd89a0613fc657628 100644 (file)
@@ -193,8 +193,7 @@ EDDisassembler::EDDisassembler(CPUKey &key) :
   
   InstString.reset(new std::string);
   InstStream.reset(new raw_string_ostream(*InstString));
-  InstPrinter.reset(Tgt->createMCInstPrinter(*TargetMachine, LLVMSyntaxVariant,
-                                             *AsmInfo));
+  InstPrinter.reset(Tgt->createMCInstPrinter(LLVMSyntaxVariant, *AsmInfo));
   
   if (!InstPrinter)
     return;
index 72408378be7a945e04c151f5b26d220720ebb160..0c08c15597b72c35afa478df05e772e498b6788c 100644 (file)
@@ -1954,11 +1954,10 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) {
 //===----------------------------------------------------------------------===//
 
 static MCInstPrinter *createARMMCInstPrinter(const Target &T,
-                                             TargetMachine &TM,
                                              unsigned SyntaxVariant,
                                              const MCAsmInfo &MAI) {
   if (SyntaxVariant == 0)
-    return new ARMInstPrinter(TM, MAI);
+    return new ARMInstPrinter(MAI);
   return 0;
 }
 
index bde0eb9199a9c817cd2576c2ae7263ec67df5d6f..f227f4a836dd90d33dc3d14974492381fbb6ba6e 100644 (file)
 namespace llvm {
 
 class MCOperand;
-class TargetMachine;
 
 class ARMInstPrinter : public MCInstPrinter {
 public:
-  ARMInstPrinter(TargetMachine &TM, const MCAsmInfo &MAI)
+  ARMInstPrinter(const MCAsmInfo &MAI)
     : MCInstPrinter(MAI) {}
 
   virtual void printInst(const MCInst *MI, raw_ostream &O);
index 13c4b49f981cfc5e6a37cf4fd89caba55c030aac..eacca410b9867e238c2aaa6b2d934b8747220e95 100644 (file)
 
 namespace llvm {
   class MCOperand;
-  class TargetMachine;
 
   class MBlazeInstPrinter : public MCInstPrinter {
   public:
-    MBlazeInstPrinter(TargetMachine &TM, const MCAsmInfo &MAI)
+    MBlazeInstPrinter(const MCAsmInfo &MAI)
       : MCInstPrinter(MAI) {}
 
     virtual void printInst(const MCInst *MI, raw_ostream &O);
index 0f0f60e69f082f6f34b6e2fa6d10067cf16747fd..0016df569b93e935a8cd90635495c7020bb19c87 100644 (file)
@@ -319,11 +319,10 @@ isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const {
 }
 
 static MCInstPrinter *createMBlazeMCInstPrinter(const Target &T,
-                                                TargetMachine &TM,
                                                 unsigned SyntaxVariant,
                                                 const MCAsmInfo &MAI) {
   if (SyntaxVariant == 0)
-    return new MBlazeInstPrinter(TM, MAI);
+    return new MBlazeInstPrinter(MAI);
   return 0;
 }
 
index 63860dcc7e3ade0ce2a8f1637080db17ef69df80..50d98b7c41fde87e91042d426c73c698cf07328f 100644 (file)
 
 namespace llvm {
   class MCOperand;
-  class TargetMachine;
 
   class MSP430InstPrinter : public MCInstPrinter {
   public:
-    MSP430InstPrinter(TargetMachine &TM, const MCAsmInfo &MAI)
+    MSP430InstPrinter(const MCAsmInfo &MAI)
       : MCInstPrinter(MAI) {}
 
     virtual void printInst(const MCInst *MI, raw_ostream &O);
index 5264d680d8b391183e7119ea0731cdcb7be7953f..a1a7f44c19c484cab303e35dd08b2890cb75952a 100644 (file)
@@ -164,11 +164,10 @@ void MSP430AsmPrinter::EmitInstruction(const MachineInstr *MI) {
 }
 
 static MCInstPrinter *createMSP430MCInstPrinter(const Target &T,
-                                                TargetMachine &TM,
                                                 unsigned SyntaxVariant,
                                                 const MCAsmInfo &MAI) {
   if (SyntaxVariant == 0)
-    return new MSP430InstPrinter(TM, MAI);
+    return new MSP430InstPrinter(MAI);
   return 0;
 }
 
index adfa0aa6306b48a7e94589bda784dfe7bd0c8868..d022a4496e84025de5c1b7e4882270ee7e67e461 100644 (file)
 namespace llvm {
 
 class MCOperand;
-class TargetMachine;
 
 class PPCInstPrinter : public MCInstPrinter {
   // 0 -> AIX, 1 -> Darwin.
   unsigned SyntaxVariant;
 public:
-  PPCInstPrinter(TargetMachine &TM, const MCAsmInfo &MAI,
-                 unsigned syntaxVariant)
+  PPCInstPrinter(const MCAsmInfo &MAI, unsigned syntaxVariant)
     : MCInstPrinter(MAI), SyntaxVariant(syntaxVariant) {}
   
   bool isDarwinSyntax() const {
index b795db9594ffcede1b7bbdb82fa18d5242b60d89..9de2200296e80977c4b7acf685bfeb9b4160f770 100644 (file)
@@ -680,10 +680,9 @@ static AsmPrinter *createPPCAsmPrinterPass(TargetMachine &tm,
 }
 
 static MCInstPrinter *createPPCMCInstPrinter(const Target &T,
-                                             TargetMachine &TM,
                                              unsigned SyntaxVariant,
                                              const MCAsmInfo &MAI) {
-  return new PPCInstPrinter(TM, MAI, SyntaxVariant);
+  return new PPCInstPrinter(MAI, SyntaxVariant);
 }
 
 
index 761707186cec0babb84e2a4632acb787fb309843..d748e2cb3a816e581c113d371a5b27de28e889d5 100644 (file)
@@ -15,7 +15,6 @@
 #define DEBUG_TYPE "asm-printer"
 #include "X86ATTInstPrinter.h"
 #include "X86InstComments.h"
-#include "X86Subtarget.h"
 #include "MCTargetDesc/X86TargetDesc.h"
 #include "llvm/MC/MCInst.h"
 #include "llvm/MC/MCAsmInfo.h"
@@ -31,7 +30,7 @@ using namespace llvm;
 #define PRINT_ALIAS_INSTR
 #include "X86GenAsmWriter.inc"
 
-X86ATTInstPrinter::X86ATTInstPrinter(TargetMachine &TM, const MCAsmInfo &MAI)
+X86ATTInstPrinter::X86ATTInstPrinter(const MCAsmInfo &MAI)
   : MCInstPrinter(MAI) {
 }
 
index 59bc08bbbd80f7ca193605d75896fa0987344c49..5426e5cf38d9a7c28599dcb5fbe75e2ce12b4972 100644 (file)
 namespace llvm {
 
 class MCOperand;
-class X86Subtarget;
-class TargetMachine;
   
 class X86ATTInstPrinter : public MCInstPrinter {
 public:
-  X86ATTInstPrinter(TargetMachine &TM, const MCAsmInfo &MAI);
+  X86ATTInstPrinter(const MCAsmInfo &MAI);
   
   virtual void printRegName(raw_ostream &OS, unsigned RegNo) const;
   virtual void printInst(const MCInst *MI, raw_ostream &OS);
index 411d832f278169971ee4cf41cc96daf02b3c9a89..e3c7bf6559131ad475ae43ba408b204ef91fefd4 100644 (file)
@@ -15,7 +15,6 @@
 #define DEBUG_TYPE "asm-printer"
 #include "X86IntelInstPrinter.h"
 #include "X86InstComments.h"
-#include "X86Subtarget.h"
 #include "MCTargetDesc/X86TargetDesc.h"
 #include "llvm/MC/MCInst.h"
 #include "llvm/MC/MCAsmInfo.h"
index c8030c3ecdacdb96791a904141438eea342e1249..e84a1940017d25f5149c0fa293cc662590c9cc22 100644 (file)
 namespace llvm {
 
 class MCOperand;
-class TargetMachine;
   
 class X86IntelInstPrinter : public MCInstPrinter {
 public:
-  X86IntelInstPrinter(TargetMachine &TM, const MCAsmInfo &MAI)
+  X86IntelInstPrinter(const MCAsmInfo &MAI)
     : MCInstPrinter(MAI) {}
 
   virtual void printRegName(raw_ostream &OS, unsigned RegNo) const;
index c2d53c4dd26cf1b9bb5883d00bf39e50c76beb39..99b4479a9fc9ba9a67ca89d3b17c0a9bf744cf76 100644 (file)
@@ -709,13 +709,12 @@ void X86AsmPrinter::PrintDebugValueComment(const MachineInstr *MI,
 //===----------------------------------------------------------------------===//
 
 static MCInstPrinter *createX86MCInstPrinter(const Target &T,
-                                             TargetMachine &TM,
                                              unsigned SyntaxVariant,
                                              const MCAsmInfo &MAI) {
   if (SyntaxVariant == 0)
-    return new X86ATTInstPrinter(TM, MAI);
+    return new X86ATTInstPrinter(MAI);
   if (SyntaxVariant == 1)
-    return new X86IntelInstPrinter(TM, MAI);
+    return new X86IntelInstPrinter(MAI);
   return 0;
 }
 
index 93b9723902a3b791f11e8164c3885dfe7fe08121..801991221a2577e894a87ee43065125a6bf4d356 100644 (file)
@@ -127,7 +127,7 @@ static bool ByteArrayFromString(ByteArrayTy &ByteArray,
   return false;
 }
 
-int Disassembler::disassemble(const Target &T,  TargetMachine &TM,
+int Disassembler::disassemble(const Target &T,
                               const std::string &Triple,
                               MemoryBuffer &Buffer,
                               raw_ostream &Out) {
@@ -146,7 +146,7 @@ int Disassembler::disassemble(const Target &T,  TargetMachine &TM,
   }
 
   int AsmPrinterVariant = AsmInfo->getAssemblerDialect();
-  OwningPtr<MCInstPrinter> IP(T.createMCInstPrinter(TM, AsmPrinterVariant,
+  OwningPtr<MCInstPrinter> IP(T.createMCInstPrinter(AsmPrinterVariant,
                                                     *AsmInfo));
   if (!IP) {
     errs() << "error: no instruction printer for target " << Triple << '\n';
index d738ee767e0f6f71241f4a19f804d8f3e39daf03..433e71bf2783e3fd63119d1d42443d9bab66e231 100644 (file)
@@ -21,13 +21,11 @@ namespace llvm {
 
 class MemoryBuffer;
 class Target;
-class TargetMachine;
 class raw_ostream;
 
 class Disassembler {
 public:
   static int disassemble(const Target &target,
-                         TargetMachine &TM,
                          const std::string &tripleString,
                          MemoryBuffer &buffer,
                          raw_ostream &Out);
index b1d9a60ede80033196e4967fd242c60e24359deb..cf260480f335805dfbcc88ed3c5692d35b13a033 100644 (file)
@@ -343,7 +343,7 @@ static int AssembleInput(const char *ProgName) {
   // FIXME: There is a bit of code duplication with addPassesToEmitFile.
   if (FileType == OFT_AssemblyFile) {
     MCInstPrinter *IP =
-      TheTarget->createMCInstPrinter(*TM, OutputAsmVariant, *MAI);
+      TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI);
     MCCodeEmitter *CE = 0;
     TargetAsmBackend *TAB = 0;
     if (ShowEncoding) {
@@ -426,7 +426,7 @@ static int DisassembleInput(const char *ProgName, bool Enhanced) {
       return 1;
     }
 
-    Res = Disassembler::disassemble(*TheTarget, *TM, TripleName,
+    Res = Disassembler::disassemble(*TheTarget, TripleName,
                                     *Buffer.take(), Out->os());
   }
 
index a125c91c359d776455072eb66d535700dd866ec3..9cb3fee8059a232385ac67680c61ddf6dbca6c59 100644 (file)
@@ -38,7 +38,6 @@
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/system_error.h"
-#include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetRegistry.h"
 #include "llvm/Target/TargetSelect.h"
 #include <algorithm>
@@ -196,22 +195,9 @@ static void DisassembleInput(const StringRef &Filename) {
       return;
     }
 
-    // FIXME: We shouldn't need to do this (and link in codegen).
-    //        When we split this out, we should do it in a way that makes
-    //        it straightforward to switch subtargets on the fly (.e.g,
-    //        the .cpu and .code16 directives).
-    std::string FeaturesStr;
-    std::string CPU;
-    OwningPtr<TargetMachine> TM(TheTarget->createTargetMachine(TripleName, CPU,
-                                                               FeaturesStr));
-    if (!TM) {
-      errs() << "error: could not create target for triple " << TripleName << "\n";
-      return;
-    }
-
     int AsmPrinterVariant = AsmInfo->getAssemblerDialect();
     OwningPtr<MCInstPrinter> IP(TheTarget->createMCInstPrinter(
-                                  *TM, AsmPrinterVariant, *AsmInfo));
+                                  AsmPrinterVariant, *AsmInfo));
     if (!IP) {
       errs() << "error: no instruction printer for target " << TripleName << '\n';
       return;