1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

Make MCInstrInfo available to the MCInstPrinter. This will be used to remove getInstructionName and the static data it contains since the same tables are already in MCInstrInfo.

llvm-svn: 153860
This commit is contained in:
Craig Topper 2012-04-02 06:09:36 +00:00
parent 8ee5b8754f
commit dbc259a436
27 changed files with 89 additions and 41 deletions

View File

@ -14,6 +14,7 @@ namespace llvm {
class MCInst; class MCInst;
class raw_ostream; class raw_ostream;
class MCAsmInfo; class MCAsmInfo;
class MCInstrInfo;
class MCRegisterInfo; class MCRegisterInfo;
class StringRef; class StringRef;
@ -26,6 +27,7 @@ protected:
/// assembly emission is disable. /// assembly emission is disable.
raw_ostream *CommentStream; raw_ostream *CommentStream;
const MCAsmInfo &MAI; const MCAsmInfo &MAI;
const MCInstrInfo &MII;
const MCRegisterInfo &MRI; const MCRegisterInfo &MRI;
/// The current set of available features. /// The current set of available features.
@ -34,8 +36,9 @@ protected:
/// Utility function for printing annotations. /// Utility function for printing annotations.
void printAnnotation(raw_ostream &OS, StringRef Annot); void printAnnotation(raw_ostream &OS, StringRef Annot);
public: public:
MCInstPrinter(const MCAsmInfo &mai, const MCRegisterInfo &mri) MCInstPrinter(const MCAsmInfo &mai, const MCInstrInfo &mii,
: CommentStream(0), MAI(mai), MRI(mri), AvailableFeatures(0) {} const MCRegisterInfo &mri)
: CommentStream(0), MAI(mai), MII(mii), MRI(mri), AvailableFeatures(0) {}
virtual ~MCInstPrinter(); virtual ~MCInstPrinter();

View File

@ -104,6 +104,7 @@ namespace llvm {
typedef MCInstPrinter *(*MCInstPrinterCtorTy)(const Target &T, typedef MCInstPrinter *(*MCInstPrinterCtorTy)(const Target &T,
unsigned SyntaxVariant, unsigned SyntaxVariant,
const MCAsmInfo &MAI, const MCAsmInfo &MAI,
const MCInstrInfo &MII,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI,
const MCSubtargetInfo &STI); const MCSubtargetInfo &STI);
typedef MCCodeEmitter *(*MCCodeEmitterCtorTy)(const MCInstrInfo &II, typedef MCCodeEmitter *(*MCCodeEmitterCtorTy)(const MCInstrInfo &II,
@ -393,11 +394,12 @@ namespace llvm {
MCInstPrinter *createMCInstPrinter(unsigned SyntaxVariant, MCInstPrinter *createMCInstPrinter(unsigned SyntaxVariant,
const MCAsmInfo &MAI, const MCAsmInfo &MAI,
const MCInstrInfo &MII,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI,
const MCSubtargetInfo &STI) const { const MCSubtargetInfo &STI) const {
if (!MCInstPrinterCtorFn) if (!MCInstPrinterCtorFn)
return 0; return 0;
return MCInstPrinterCtorFn(*this, SyntaxVariant, MAI, MRI, STI); return MCInstPrinterCtorFn(*this, SyntaxVariant, MAI, MII, MRI, STI);
} }

View File

@ -172,6 +172,7 @@ bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
case CGFT_AssemblyFile: { case CGFT_AssemblyFile: {
MCInstPrinter *InstPrinter = MCInstPrinter *InstPrinter =
getTarget().createMCInstPrinter(MAI.getAssemblerDialect(), MAI, getTarget().createMCInstPrinter(MAI.getAssemblerDialect(), MAI,
*getInstrInfo(),
Context->getRegisterInfo(), STI); Context->getRegisterInfo(), STI);
// Create a code emitter if asked to show the encoding. // Create a code emitter if asked to show the encoding.

View File

@ -57,6 +57,9 @@ LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
const MCAsmInfo *MAI = TheTarget->createMCAsmInfo(TripleName); const MCAsmInfo *MAI = TheTarget->createMCAsmInfo(TripleName);
assert(MAI && "Unable to create target asm info!"); assert(MAI && "Unable to create target asm info!");
const MCInstrInfo *MII = TheTarget->createMCInstrInfo();
assert(MII && "Unable to create target instruction info!");
const MCRegisterInfo *MRI = TheTarget->createMCRegInfo(TripleName); const MCRegisterInfo *MRI = TheTarget->createMCRegInfo(TripleName);
assert(MRI && "Unable to create target register info!"); assert(MRI && "Unable to create target register info!");
@ -80,7 +83,7 @@ LLVMDisasmContextRef LLVMCreateDisasm(const char *TripleName, void *DisInfo,
// Set up the instruction printer. // Set up the instruction printer.
int AsmPrinterVariant = MAI->getAssemblerDialect(); int AsmPrinterVariant = MAI->getAssemblerDialect();
MCInstPrinter *IP = TheTarget->createMCInstPrinter(AsmPrinterVariant, MCInstPrinter *IP = TheTarget->createMCInstPrinter(AsmPrinterVariant,
*MAI, *MRI, *STI); *MAI, *MII, *MRI, *STI);
assert(IP && "Unable to create instruction printer!"); assert(IP && "Unable to create instruction printer!");
LLVMDisasmContext *DC = new LLVMDisasmContext(TripleName, DisInfo, TagType, LLVMDisasmContext *DC = new LLVMDisasmContext(TripleName, DisInfo, TagType,

View File

@ -22,6 +22,7 @@
#include "llvm/MC/MCExpr.h" #include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInst.h" #include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstPrinter.h" #include "llvm/MC/MCInstPrinter.h"
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCRegisterInfo.h" #include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSubtargetInfo.h" #include "llvm/MC/MCSubtargetInfo.h"
@ -166,10 +167,15 @@ EDDisassembler::EDDisassembler(CPUKey &key) :
InstInfos = Disassembler->getEDInfo(); InstInfos = Disassembler->getEDInfo();
MII.reset(Tgt->createMCInstrInfo());
if (!MII)
return;
InstString.reset(new std::string); InstString.reset(new std::string);
InstStream.reset(new raw_string_ostream(*InstString)); InstStream.reset(new raw_string_ostream(*InstString));
InstPrinter.reset(Tgt->createMCInstPrinter(LLVMSyntaxVariant, *AsmInfo, InstPrinter.reset(Tgt->createMCInstPrinter(LLVMSyntaxVariant, *AsmInfo,
*MRI, *STI)); *MII, *MRI, *STI));
if (!InstPrinter) if (!InstPrinter)
return; return;

View File

@ -36,8 +36,9 @@ class MCContext;
class MCAsmInfo; class MCAsmInfo;
class MCAsmLexer; class MCAsmLexer;
class MCDisassembler; class MCDisassembler;
class MCInstPrinter;
class MCInst; class MCInst;
class MCInstPrinter;
class MCInstrInfo;
class MCParsedAsmOperand; class MCParsedAsmOperand;
class MCRegisterInfo; class MCRegisterInfo;
class MCStreamer; class MCStreamer;
@ -137,6 +138,8 @@ struct EDDisassembler {
llvm::OwningPtr<const llvm::MCAsmInfo> AsmInfo; llvm::OwningPtr<const llvm::MCAsmInfo> AsmInfo;
/// The subtarget information for the target architecture /// The subtarget information for the target architecture
llvm::OwningPtr<const llvm::MCSubtargetInfo> STI; llvm::OwningPtr<const llvm::MCSubtargetInfo> STI;
// The instruction information for the target architecture.
llvm::OwningPtr<const llvm::MCInstrInfo> MII;
// The register information for the target architecture. // The register information for the target architecture.
llvm::OwningPtr<const llvm::MCRegisterInfo> MRI; llvm::OwningPtr<const llvm::MCRegisterInfo> MRI;
/// The disassembler for the target architecture /// The disassembler for the target architecture

View File

@ -36,9 +36,10 @@ static unsigned translateShiftImm(unsigned imm) {
ARMInstPrinter::ARMInstPrinter(const MCAsmInfo &MAI, ARMInstPrinter::ARMInstPrinter(const MCAsmInfo &MAI,
const MCInstrInfo &MII,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI,
const MCSubtargetInfo &STI) : const MCSubtargetInfo &STI) :
MCInstPrinter(MAI, MRI) { MCInstPrinter(MAI, MII, MRI) {
// Initialize the set of available features. // Initialize the set of available features.
setAvailableFeatures(STI.getFeatureBits()); setAvailableFeatures(STI.getFeatureBits());
} }

View File

@ -23,8 +23,8 @@ class MCOperand;
class ARMInstPrinter : public MCInstPrinter { class ARMInstPrinter : public MCInstPrinter {
public: public:
ARMInstPrinter(const MCAsmInfo &MAI, const MCRegisterInfo &MRI, ARMInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
const MCSubtargetInfo &STI); const MCRegisterInfo &MRI, const MCSubtargetInfo &STI);
virtual void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot); virtual void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot);
virtual StringRef getOpcodeName(unsigned Opcode) const; virtual StringRef getOpcodeName(unsigned Opcode) const;

View File

@ -163,10 +163,11 @@ static MCStreamer *createMCStreamer(const Target &T, StringRef TT,
static MCInstPrinter *createARMMCInstPrinter(const Target &T, static MCInstPrinter *createARMMCInstPrinter(const Target &T,
unsigned SyntaxVariant, unsigned SyntaxVariant,
const MCAsmInfo &MAI, const MCAsmInfo &MAI,
const MCInstrInfo &MII,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI,
const MCSubtargetInfo &STI) { const MCSubtargetInfo &STI) {
if (SyntaxVariant == 0) if (SyntaxVariant == 0)
return new ARMInstPrinter(MAI, MRI, STI); return new ARMInstPrinter(MAI, MII, MRI, STI);
return 0; return 0;
} }

View File

@ -21,8 +21,9 @@ namespace llvm {
class MBlazeInstPrinter : public MCInstPrinter { class MBlazeInstPrinter : public MCInstPrinter {
public: public:
MBlazeInstPrinter(const MCAsmInfo &MAI, const MCRegisterInfo &MRI) MBlazeInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
: MCInstPrinter(MAI, MRI) {} const MCRegisterInfo &MRI)
: MCInstPrinter(MAI, MII, MRI) {}
virtual void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot); virtual void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot);

View File

@ -95,10 +95,11 @@ static MCStreamer *createMCStreamer(const Target &T, StringRef TT,
static MCInstPrinter *createMBlazeMCInstPrinter(const Target &T, static MCInstPrinter *createMBlazeMCInstPrinter(const Target &T,
unsigned SyntaxVariant, unsigned SyntaxVariant,
const MCAsmInfo &MAI, const MCAsmInfo &MAI,
const MCInstrInfo &MII,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI,
const MCSubtargetInfo &STI) { const MCSubtargetInfo &STI) {
if (SyntaxVariant == 0) if (SyntaxVariant == 0)
return new MBlazeInstPrinter(MAI, MRI); return new MBlazeInstPrinter(MAI, MII, MRI);
return 0; return 0;
} }

View File

@ -21,8 +21,9 @@ namespace llvm {
class MSP430InstPrinter : public MCInstPrinter { class MSP430InstPrinter : public MCInstPrinter {
public: public:
MSP430InstPrinter(const MCAsmInfo &MAI, const MCRegisterInfo &MRI) MSP430InstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
: MCInstPrinter(MAI, MRI) {} const MCRegisterInfo &MRI)
: MCInstPrinter(MAI, MII, MRI) {}
virtual void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot); virtual void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot);

View File

@ -61,10 +61,11 @@ static MCCodeGenInfo *createMSP430MCCodeGenInfo(StringRef TT, Reloc::Model RM,
static MCInstPrinter *createMSP430MCInstPrinter(const Target &T, static MCInstPrinter *createMSP430MCInstPrinter(const Target &T,
unsigned SyntaxVariant, unsigned SyntaxVariant,
const MCAsmInfo &MAI, const MCAsmInfo &MAI,
const MCInstrInfo &MII,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI,
const MCSubtargetInfo &STI) { const MCSubtargetInfo &STI) {
if (SyntaxVariant == 0) if (SyntaxVariant == 0)
return new MSP430InstPrinter(MAI, MRI); return new MSP430InstPrinter(MAI, MII, MRI);
return 0; return 0;
} }

View File

@ -77,8 +77,9 @@ class TargetMachine;
class MipsInstPrinter : public MCInstPrinter { class MipsInstPrinter : public MCInstPrinter {
public: public:
MipsInstPrinter(const MCAsmInfo &MAI, const MCRegisterInfo &MRI) : MipsInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
MCInstPrinter(MAI, MRI) {} const MCRegisterInfo &MRI)
: MCInstPrinter(MAI, MII, MRI) {}
// Autogenerated by tblgen. // Autogenerated by tblgen.
void printInstruction(const MCInst *MI, raw_ostream &O); void printInstruction(const MCInst *MI, raw_ostream &O);

View File

@ -78,9 +78,10 @@ static MCCodeGenInfo *createMipsMCCodeGenInfo(StringRef TT, Reloc::Model RM,
static MCInstPrinter *createMipsMCInstPrinter(const Target &T, static MCInstPrinter *createMipsMCInstPrinter(const Target &T,
unsigned SyntaxVariant, unsigned SyntaxVariant,
const MCAsmInfo &MAI, const MCAsmInfo &MAI,
const MCInstrInfo &MII,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI,
const MCSubtargetInfo &STI) { const MCSubtargetInfo &STI) {
return new MipsInstPrinter(MAI, MRI); return new MipsInstPrinter(MAI, MII, MRI);
} }
static MCStreamer *createMCStreamer(const Target &T, StringRef TT, static MCStreamer *createMCStreamer(const Target &T, StringRef TT,

View File

@ -28,9 +28,10 @@ using namespace llvm;
#include "PTXGenAsmWriter.inc" #include "PTXGenAsmWriter.inc"
PTXInstPrinter::PTXInstPrinter(const MCAsmInfo &MAI, PTXInstPrinter::PTXInstPrinter(const MCAsmInfo &MAI,
const MCInstrInfo &MII,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI,
const MCSubtargetInfo &STI) : const MCSubtargetInfo &STI) :
MCInstPrinter(MAI, MRI) { MCInstPrinter(MAI, MII, MRI) {
// Initialize the set of available features. // Initialize the set of available features.
setAvailableFeatures(STI.getFeatureBits()); setAvailableFeatures(STI.getFeatureBits());
} }

View File

@ -23,8 +23,8 @@ class MCOperand;
class PTXInstPrinter : public MCInstPrinter { class PTXInstPrinter : public MCInstPrinter {
public: public:
PTXInstPrinter(const MCAsmInfo &MAI, const MCRegisterInfo &MRI, PTXInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
const MCSubtargetInfo &STI); const MCRegisterInfo &MRI, const MCSubtargetInfo &STI);
virtual void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot); virtual void printInst(const MCInst *MI, raw_ostream &O, StringRef Annot);
virtual StringRef getOpcodeName(unsigned Opcode) const; virtual StringRef getOpcodeName(unsigned Opcode) const;

View File

@ -62,10 +62,11 @@ static MCCodeGenInfo *createPTXMCCodeGenInfo(StringRef TT, Reloc::Model RM,
static MCInstPrinter *createPTXMCInstPrinter(const Target &T, static MCInstPrinter *createPTXMCInstPrinter(const Target &T,
unsigned SyntaxVariant, unsigned SyntaxVariant,
const MCAsmInfo &MAI, const MCAsmInfo &MAI,
const MCInstrInfo &MII,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI,
const MCSubtargetInfo &STI) { const MCSubtargetInfo &STI) {
assert(SyntaxVariant == 0 && "We only have one syntax variant"); assert(SyntaxVariant == 0 && "We only have one syntax variant");
return new PTXInstPrinter(MAI, MRI, STI); return new PTXInstPrinter(MAI, MII, MRI, STI);
} }
extern "C" void LLVMInitializePTXTargetMC() { extern "C" void LLVMInitializePTXTargetMC() {

View File

@ -24,9 +24,9 @@ class PPCInstPrinter : public MCInstPrinter {
// 0 -> AIX, 1 -> Darwin. // 0 -> AIX, 1 -> Darwin.
unsigned SyntaxVariant; unsigned SyntaxVariant;
public: public:
PPCInstPrinter(const MCAsmInfo &MAI, const MCRegisterInfo &MRI, PPCInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
unsigned syntaxVariant) const MCRegisterInfo &MRI, unsigned syntaxVariant)
: MCInstPrinter(MAI, MRI), SyntaxVariant(syntaxVariant) {} : MCInstPrinter(MAI, MII, MRI), SyntaxVariant(syntaxVariant) {}
bool isDarwinSyntax() const { bool isDarwinSyntax() const {
return SyntaxVariant == 1; return SyntaxVariant == 1;

View File

@ -108,9 +108,10 @@ static MCStreamer *createMCStreamer(const Target &T, StringRef TT,
static MCInstPrinter *createPPCMCInstPrinter(const Target &T, static MCInstPrinter *createPPCMCInstPrinter(const Target &T,
unsigned SyntaxVariant, unsigned SyntaxVariant,
const MCAsmInfo &MAI, const MCAsmInfo &MAI,
const MCInstrInfo &MII,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI,
const MCSubtargetInfo &STI) { const MCSubtargetInfo &STI) {
return new PPCInstPrinter(MAI, MRI, SyntaxVariant); return new PPCInstPrinter(MAI, MII, MRI, SyntaxVariant);
} }
extern "C" void LLVMInitializePowerPCTargetMC() { extern "C" void LLVMInitializePowerPCTargetMC() {

View File

@ -22,8 +22,9 @@ class MCOperand;
class X86ATTInstPrinter : public MCInstPrinter { class X86ATTInstPrinter : public MCInstPrinter {
public: public:
X86ATTInstPrinter(const MCAsmInfo &MAI, const MCRegisterInfo &MRI) X86ATTInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
: MCInstPrinter(MAI, MRI) {} const MCRegisterInfo &MRI)
: MCInstPrinter(MAI, MII, MRI) {}
virtual void printRegName(raw_ostream &OS, unsigned RegNo) const; virtual void printRegName(raw_ostream &OS, unsigned RegNo) const;
virtual void printInst(const MCInst *MI, raw_ostream &OS, StringRef Annot); virtual void printInst(const MCInst *MI, raw_ostream &OS, StringRef Annot);

View File

@ -23,8 +23,9 @@ class MCOperand;
class X86IntelInstPrinter : public MCInstPrinter { class X86IntelInstPrinter : public MCInstPrinter {
public: public:
X86IntelInstPrinter(const MCAsmInfo &MAI, const MCRegisterInfo &MRI) X86IntelInstPrinter(const MCAsmInfo &MAI, const MCInstrInfo &MII,
: MCInstPrinter(MAI, MRI) {} const MCRegisterInfo &MRI)
: MCInstPrinter(MAI, MII, MRI) {}
virtual void printRegName(raw_ostream &OS, unsigned RegNo) const; virtual void printRegName(raw_ostream &OS, unsigned RegNo) const;
virtual void printInst(const MCInst *MI, raw_ostream &OS, StringRef Annot); virtual void printInst(const MCInst *MI, raw_ostream &OS, StringRef Annot);

View File

@ -474,12 +474,13 @@ static MCStreamer *createMCStreamer(const Target &T, StringRef TT,
static MCInstPrinter *createX86MCInstPrinter(const Target &T, static MCInstPrinter *createX86MCInstPrinter(const Target &T,
unsigned SyntaxVariant, unsigned SyntaxVariant,
const MCAsmInfo &MAI, const MCAsmInfo &MAI,
const MCInstrInfo &MII,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI,
const MCSubtargetInfo &STI) { const MCSubtargetInfo &STI) {
if (SyntaxVariant == 0) if (SyntaxVariant == 0)
return new X86ATTInstPrinter(MAI, MRI); return new X86ATTInstPrinter(MAI, MII, MRI);
if (SyntaxVariant == 1) if (SyntaxVariant == 1)
return new X86IntelInstPrinter(MAI, MRI); return new X86IntelInstPrinter(MAI, MII, MRI);
return 0; return 0;
} }

View File

@ -21,6 +21,7 @@
#include "llvm/MC/MCDisassembler.h" #include "llvm/MC/MCDisassembler.h"
#include "llvm/MC/MCInst.h" #include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstPrinter.h" #include "llvm/MC/MCInstPrinter.h"
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCRegisterInfo.h" #include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSubtargetInfo.h" #include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/OwningPtr.h"
@ -156,7 +157,8 @@ int Disassembler::disassemble(const Target &T,
return -1; return -1;
} }
OwningPtr<const MCSubtargetInfo> STI(T.createMCSubtargetInfo(Triple, Cpu, FeaturesStr)); OwningPtr<const MCSubtargetInfo> STI(T.createMCSubtargetInfo(Triple, Cpu,
FeaturesStr));
if (!STI) { if (!STI) {
errs() << "error: no subtarget info for target " << Triple << "\n"; errs() << "error: no subtarget info for target " << Triple << "\n";
return -1; return -1;
@ -174,9 +176,15 @@ int Disassembler::disassemble(const Target &T,
return -1; return -1;
} }
OwningPtr<const MCInstrInfo> MII(T.createMCInstrInfo());
if (!MII) {
errs() << "error: no instruction info for target " << Triple << "\n";
return -1;
}
int AsmPrinterVariant = AsmInfo->getAssemblerDialect(); int AsmPrinterVariant = AsmInfo->getAssemblerDialect();
OwningPtr<MCInstPrinter> IP(T.createMCInstPrinter(AsmPrinterVariant, OwningPtr<MCInstPrinter> IP(T.createMCInstPrinter(AsmPrinterVariant, *AsmInfo,
*AsmInfo, *MRI, *STI)); *MII, *MRI, *STI));
if (!IP) { if (!IP) {
errs() << "error: no instruction printer for target " << Triple << '\n'; errs() << "error: no instruction printer for target " << Triple << '\n';
return -1; return -1;

View File

@ -416,7 +416,7 @@ static int AssembleInput(const char *ProgName) {
// FIXME: There is a bit of code duplication with addPassesToEmitFile. // FIXME: There is a bit of code duplication with addPassesToEmitFile.
if (FileType == OFT_AssemblyFile) { if (FileType == OFT_AssemblyFile) {
MCInstPrinter *IP = MCInstPrinter *IP =
TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI, *MRI, *STI); TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI, *MCII, *MRI, *STI);
MCCodeEmitter *CE = 0; MCCodeEmitter *CE = 0;
MCAsmBackend *MAB = 0; MCAsmBackend *MAB = 0;
if (ShowEncoding) { if (ShowEncoding) {

View File

@ -260,8 +260,9 @@ void llvm::DisassembleInputMachO(StringRef Filename) {
OwningPtr<const MCDisassembler> DisAsm(TheTarget->createMCDisassembler(*STI)); OwningPtr<const MCDisassembler> DisAsm(TheTarget->createMCDisassembler(*STI));
OwningPtr<const MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TripleName)); OwningPtr<const MCRegisterInfo> MRI(TheTarget->createMCRegInfo(TripleName));
int AsmPrinterVariant = AsmInfo->getAssemblerDialect(); int AsmPrinterVariant = AsmInfo->getAssemblerDialect();
OwningPtr<MCInstPrinter> IP(TheTarget->createMCInstPrinter( OwningPtr<MCInstPrinter>
AsmPrinterVariant, *AsmInfo, *MRI, *STI)); IP(TheTarget->createMCInstPrinter(AsmPrinterVariant, *AsmInfo, *InstrInfo,
*MRI, *STI));
if (!InstrAnalysis || !AsmInfo || !STI || !DisAsm || !IP) { if (!InstrAnalysis || !AsmInfo || !STI || !DisAsm || !IP) {
errs() << "error: couldn't initialize disassembler for target " errs() << "error: couldn't initialize disassembler for target "

View File

@ -26,6 +26,7 @@
#include "llvm/MC/MCDisassembler.h" #include "llvm/MC/MCDisassembler.h"
#include "llvm/MC/MCInst.h" #include "llvm/MC/MCInst.h"
#include "llvm/MC/MCInstPrinter.h" #include "llvm/MC/MCInstPrinter.h"
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCRegisterInfo.h" #include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSubtargetInfo.h" #include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/Support/Casting.h" #include "llvm/Support/Casting.h"
@ -254,9 +255,15 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
return; return;
} }
OwningPtr<const MCInstrInfo> MII(TheTarget->createMCInstrInfo());
if (!MII) {
errs() << "error: no instruction info for target " << TripleName << "\n";
return;
}
int AsmPrinterVariant = AsmInfo->getAssemblerDialect(); int AsmPrinterVariant = AsmInfo->getAssemblerDialect();
OwningPtr<MCInstPrinter> IP(TheTarget->createMCInstPrinter( OwningPtr<MCInstPrinter> IP(TheTarget->createMCInstPrinter(
AsmPrinterVariant, *AsmInfo, *MRI, *STI)); AsmPrinterVariant, *AsmInfo, *MII, *MRI, *STI));
if (!IP) { if (!IP) {
errs() << "error: no instruction printer for target " << TripleName errs() << "error: no instruction printer for target " << TripleName
<< '\n'; << '\n';