Replace the MCSubtargetInfo parameter with a Triple when creating

an MCInstPrinter. Update all callers and use where we wanted a Triple
previously.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233648 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Christopher 2015-03-31 00:10:04 +00:00
parent 6dd9e8563b
commit e2424b02b2
21 changed files with 60 additions and 63 deletions

View File

@ -124,11 +124,11 @@ namespace llvm {
typedef MCDisassembler *(*MCDisassemblerCtorTy)(const Target &T, typedef MCDisassembler *(*MCDisassemblerCtorTy)(const Target &T,
const MCSubtargetInfo &STI, const MCSubtargetInfo &STI,
MCContext &Ctx); MCContext &Ctx);
typedef MCInstPrinter *(*MCInstPrinterCtorTy)(unsigned SyntaxVariant, typedef MCInstPrinter *(*MCInstPrinterCtorTy)(const Triple &T,
unsigned SyntaxVariant,
const MCAsmInfo &MAI, const MCAsmInfo &MAI,
const MCInstrInfo &MII, const MCInstrInfo &MII,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI);
const MCSubtargetInfo &STI);
typedef MCCodeEmitter *(*MCCodeEmitterCtorTy)(const MCInstrInfo &II, typedef MCCodeEmitter *(*MCCodeEmitterCtorTy)(const MCInstrInfo &II,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI,
MCContext &Ctx); MCContext &Ctx);
@ -408,14 +408,13 @@ namespace llvm {
return MCDisassemblerCtorFn(*this, STI, Ctx); return MCDisassemblerCtorFn(*this, STI, Ctx);
} }
MCInstPrinter *createMCInstPrinter(unsigned SyntaxVariant, MCInstPrinter *createMCInstPrinter(const Triple &T, unsigned SyntaxVariant,
const MCAsmInfo &MAI, const MCAsmInfo &MAI,
const MCInstrInfo &MII, const MCInstrInfo &MII,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI) const {
const MCSubtargetInfo &STI) const {
if (!MCInstPrinterCtorFn) if (!MCInstPrinterCtorFn)
return nullptr; return nullptr;
return MCInstPrinterCtorFn(SyntaxVariant, MAI, MII, MRI, STI); return MCInstPrinterCtorFn(T, SyntaxVariant, MAI, MII, MRI);
} }

View File

@ -175,7 +175,7 @@ bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
switch (FileType) { switch (FileType) {
case CGFT_AssemblyFile: { case CGFT_AssemblyFile: {
MCInstPrinter *InstPrinter = getTarget().createMCInstPrinter( MCInstPrinter *InstPrinter = getTarget().createMCInstPrinter(
MAI.getAssemblerDialect(), MAI, MII, MRI, STI); Triple(getTargetTriple()), MAI.getAssemblerDialect(), MAI, MII, MRI);
// Create a code emitter if asked to show the encoding. // Create a code emitter if asked to show the encoding.
MCCodeEmitter *MCE = nullptr; MCCodeEmitter *MCE = nullptr;

View File

@ -82,8 +82,8 @@ LLVMCreateDisasmCPUFeatures(const char *TT, const char *CPU,
// 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(
*MAI, *MII, *MRI, *STI); Triple(TT), AsmPrinterVariant, *MAI, *MII, *MRI);
if (!IP) if (!IP)
return nullptr; return nullptr;
@ -311,11 +311,10 @@ int LLVMSetDisasmOptions(LLVMDisasmContextRef DCR, uint64_t Options){
const MCAsmInfo *MAI = DC->getAsmInfo(); const MCAsmInfo *MAI = DC->getAsmInfo();
const MCInstrInfo *MII = DC->getInstrInfo(); const MCInstrInfo *MII = DC->getInstrInfo();
const MCRegisterInfo *MRI = DC->getRegisterInfo(); const MCRegisterInfo *MRI = DC->getRegisterInfo();
const MCSubtargetInfo *STI = DC->getSubtargetInfo();
int AsmPrinterVariant = MAI->getAssemblerDialect(); int AsmPrinterVariant = MAI->getAssemblerDialect();
AsmPrinterVariant = AsmPrinterVariant == 0 ? 1 : 0; AsmPrinterVariant = AsmPrinterVariant == 0 ? 1 : 0;
MCInstPrinter *IP = DC->getTarget()->createMCInstPrinter( MCInstPrinter *IP = DC->getTarget()->createMCInstPrinter(
AsmPrinterVariant, *MAI, *MII, *MRI, *STI); Triple(DC->getTripleName()), AsmPrinterVariant, *MAI, *MII, *MRI);
if (IP) { if (IP) {
DC->setIP(IP); DC->setIP(IP);
DC->addOptions(LLVMDisassembler_Option_AsmPrinterVariant); DC->addOptions(LLVMDisassembler_Option_AsmPrinterVariant);

View File

@ -109,11 +109,11 @@ static MCCodeGenInfo *createAArch64MCCodeGenInfo(StringRef TT, Reloc::Model RM,
return X; return X;
} }
static MCInstPrinter *createAArch64MCInstPrinter(unsigned SyntaxVariant, static MCInstPrinter *createAArch64MCInstPrinter(const Triple &T,
unsigned SyntaxVariant,
const MCAsmInfo &MAI, const MCAsmInfo &MAI,
const MCInstrInfo &MII, const MCInstrInfo &MII,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI) {
const MCSubtargetInfo &STI) {
if (SyntaxVariant == 0) if (SyntaxVariant == 0)
return new AArch64InstPrinter(MAI, MII, MRI); return new AArch64InstPrinter(MAI, MII, MRI);
if (SyntaxVariant == 1) if (SyntaxVariant == 1)

View File

@ -323,11 +323,11 @@ static MCStreamer *createARMMachOStreamer(MCContext &Ctx, MCAsmBackend &MAB,
return createMachOStreamer(Ctx, MAB, OS, Emitter, false, DWARFMustBeAtTheEnd); return createMachOStreamer(Ctx, MAB, OS, Emitter, false, DWARFMustBeAtTheEnd);
} }
static MCInstPrinter *createARMMCInstPrinter(unsigned SyntaxVariant, static MCInstPrinter *createARMMCInstPrinter(const Triple &T,
unsigned SyntaxVariant,
const MCAsmInfo &MAI, const MCAsmInfo &MAI,
const MCInstrInfo &MII, const MCInstrInfo &MII,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI) {
const MCSubtargetInfo &STI) {
if (SyntaxVariant == 0) if (SyntaxVariant == 0)
return new ARMInstPrinter(MAI, MII, MRI); return new ARMInstPrinter(MAI, MII, MRI);
return nullptr; return nullptr;

View File

@ -68,11 +68,11 @@ static MCStreamer *createBPFMCStreamer(const Triple &T,
return createELFStreamer(Ctx, MAB, OS, Emitter, RelaxAll); return createELFStreamer(Ctx, MAB, OS, Emitter, RelaxAll);
} }
static MCInstPrinter *createBPFMCInstPrinter(unsigned SyntaxVariant, static MCInstPrinter *createBPFMCInstPrinter(const Triple &T,
unsigned SyntaxVariant,
const MCAsmInfo &MAI, const MCAsmInfo &MAI,
const MCInstrInfo &MII, const MCInstrInfo &MII,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI) {
const MCSubtargetInfo &STI) {
if (SyntaxVariant == 0) if (SyntaxVariant == 0)
return new BPFInstPrinter(MAI, MII, MRI); return new BPFInstPrinter(MAI, MII, MRI);
return 0; return 0;

View File

@ -222,11 +222,11 @@ void HexagonAsmPrinter::EmitInstruction(const MachineInstr *MI) {
return; return;
} }
static MCInstPrinter *createHexagonMCInstPrinter(unsigned SyntaxVariant, static MCInstPrinter *createHexagonMCInstPrinter(const Triple &T,
unsigned SyntaxVariant,
const MCAsmInfo &MAI, const MCAsmInfo &MAI,
const MCInstrInfo &MII, const MCInstrInfo &MII,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI) {
const MCSubtargetInfo &STI) {
if (SyntaxVariant == 0) if (SyntaxVariant == 0)
return(new HexagonInstPrinter(MAI, MII, MRI)); return(new HexagonInstPrinter(MAI, MII, MRI));
else else

View File

@ -75,11 +75,11 @@ static MCCodeGenInfo *createHexagonMCCodeGenInfo(StringRef TT, Reloc::Model RM,
X->InitMCCodeGenInfo(Reloc::Static, CM, OL); X->InitMCCodeGenInfo(Reloc::Static, CM, OL);
return X; return X;
} }
static MCInstPrinter *createHexagonMCInstPrinter(unsigned SyntaxVariant, static MCInstPrinter *createHexagonMCInstPrinter(const Triple &T,
unsigned SyntaxVariant,
const MCAsmInfo &MAI, const MCAsmInfo &MAI,
const MCInstrInfo &MII, const MCInstrInfo &MII,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI) {
const MCSubtargetInfo &STI) {
return new HexagonInstPrinter(MAI, MII, MRI); return new HexagonInstPrinter(MAI, MII, MRI);
} }

View File

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

View File

@ -97,11 +97,11 @@ static MCCodeGenInfo *createMipsMCCodeGenInfo(StringRef TT, Reloc::Model RM,
return X; return X;
} }
static MCInstPrinter *createMipsMCInstPrinter(unsigned SyntaxVariant, static MCInstPrinter *createMipsMCInstPrinter(const Triple &T,
unsigned SyntaxVariant,
const MCAsmInfo &MAI, const MCAsmInfo &MAI,
const MCInstrInfo &MII, const MCInstrInfo &MII,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI) {
const MCSubtargetInfo &STI) {
return new MipsInstPrinter(MAI, MII, MRI); return new MipsInstPrinter(MAI, MII, MRI);
} }

View File

@ -58,11 +58,11 @@ static MCCodeGenInfo *createNVPTXMCCodeGenInfo(
return X; return X;
} }
static MCInstPrinter *createNVPTXMCInstPrinter(unsigned SyntaxVariant, static MCInstPrinter *createNVPTXMCInstPrinter(const Triple &T,
unsigned SyntaxVariant,
const MCAsmInfo &MAI, const MCAsmInfo &MAI,
const MCInstrInfo &MII, const MCInstrInfo &MII,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI) {
const MCSubtargetInfo &STI) {
if (SyntaxVariant == 0) if (SyntaxVariant == 0)
return new NVPTXInstPrinter(MAI, MII, MRI); return new NVPTXInstPrinter(MAI, MII, MRI);
return nullptr; return nullptr;

View File

@ -238,13 +238,12 @@ createObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI) {
return new PPCTargetMachOStreamer(S); return new PPCTargetMachOStreamer(S);
} }
static MCInstPrinter *createPPCMCInstPrinter(unsigned SyntaxVariant, static MCInstPrinter *createPPCMCInstPrinter(const Triple &T,
unsigned SyntaxVariant,
const MCAsmInfo &MAI, const MCAsmInfo &MAI,
const MCInstrInfo &MII, const MCInstrInfo &MII,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI) {
const MCSubtargetInfo &STI) { return new PPCInstPrinter(MAI, MII, MRI, T.isOSDarwin());
bool isDarwin = Triple(STI.getTargetTriple()).isOSDarwin();
return new PPCInstPrinter(MAI, MII, MRI, isDarwin);
} }
extern "C" void LLVMInitializePowerPCTargetMC() { extern "C" void LLVMInitializePowerPCTargetMC() {

View File

@ -64,11 +64,11 @@ static MCCodeGenInfo *createAMDGPUMCCodeGenInfo(StringRef TT, Reloc::Model RM,
return X; return X;
} }
static MCInstPrinter *createAMDGPUMCInstPrinter(unsigned SyntaxVariant, static MCInstPrinter *createAMDGPUMCInstPrinter(const Triple &T,
unsigned SyntaxVariant,
const MCAsmInfo &MAI, const MCAsmInfo &MAI,
const MCInstrInfo &MII, const MCInstrInfo &MII,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI) {
const MCSubtargetInfo &STI) {
return new AMDGPUInstPrinter(MAI, MII, MRI); return new AMDGPUInstPrinter(MAI, MII, MRI);
} }

View File

@ -134,11 +134,11 @@ static MCTargetStreamer *createTargetAsmStreamer(MCStreamer &S,
return new SparcTargetAsmStreamer(S, OS); return new SparcTargetAsmStreamer(S, OS);
} }
static MCInstPrinter *createSparcMCInstPrinter(unsigned SyntaxVariant, static MCInstPrinter *createSparcMCInstPrinter(const Triple &T,
unsigned SyntaxVariant,
const MCAsmInfo &MAI, const MCAsmInfo &MAI,
const MCInstrInfo &MII, const MCInstrInfo &MII,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI) {
const MCSubtargetInfo &STI) {
return new SparcInstPrinter(MAI, MII, MRI); return new SparcInstPrinter(MAI, MII, MRI);
} }

View File

@ -172,11 +172,11 @@ static MCCodeGenInfo *createSystemZMCCodeGenInfo(StringRef TT, Reloc::Model RM,
return X; return X;
} }
static MCInstPrinter *createSystemZMCInstPrinter(unsigned SyntaxVariant, static MCInstPrinter *createSystemZMCInstPrinter(const Triple &T,
unsigned SyntaxVariant,
const MCAsmInfo &MAI, const MCAsmInfo &MAI,
const MCInstrInfo &MII, const MCInstrInfo &MII,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI) {
const MCSubtargetInfo &STI) {
return new SystemZInstPrinter(MAI, MII, MRI); return new SystemZInstPrinter(MAI, MII, MRI);
} }

View File

@ -207,11 +207,11 @@ static MCCodeGenInfo *createX86MCCodeGenInfo(StringRef TT, Reloc::Model RM,
return X; return X;
} }
static MCInstPrinter *createX86MCInstPrinter(unsigned SyntaxVariant, static MCInstPrinter *createX86MCInstPrinter(const Triple &T,
unsigned SyntaxVariant,
const MCAsmInfo &MAI, const MCAsmInfo &MAI,
const MCInstrInfo &MII, const MCInstrInfo &MII,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI) {
const MCSubtargetInfo &STI) {
if (SyntaxVariant == 0) if (SyntaxVariant == 0)
return new X86ATTInstPrinter(MAI, MII, MRI); return new X86ATTInstPrinter(MAI, MII, MRI);
if (SyntaxVariant == 1) if (SyntaxVariant == 1)

View File

@ -81,11 +81,11 @@ static MCCodeGenInfo *createXCoreMCCodeGenInfo(StringRef TT, Reloc::Model RM,
return X; return X;
} }
static MCInstPrinter *createXCoreMCInstPrinter(unsigned SyntaxVariant, static MCInstPrinter *createXCoreMCInstPrinter(const Triple &T,
unsigned SyntaxVariant,
const MCAsmInfo &MAI, const MCAsmInfo &MAI,
const MCInstrInfo &MII, const MCInstrInfo &MII,
const MCRegisterInfo &MRI, const MCRegisterInfo &MRI) {
const MCSubtargetInfo &STI) {
return new XCoreInstPrinter(MAI, MII, MRI); return new XCoreInstPrinter(MAI, MII, MRI);
} }

View File

@ -448,8 +448,8 @@ int main(int argc, char **argv) {
MCInstPrinter *IP = nullptr; MCInstPrinter *IP = nullptr;
if (FileType == OFT_AssemblyFile) { if (FileType == OFT_AssemblyFile) {
IP = IP = TheTarget->createMCInstPrinter(Triple(TripleName), OutputAsmVariant,
TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI, *MCII, *MRI, *STI); *MAI, *MCII, *MRI);
// Set the display preference for hex vs. decimal immediates. // Set the display preference for hex vs. decimal immediates.
IP->setPrintImmHex(PrintImmHex); IP->setPrintImmHex(PrintImmHex);

View File

@ -3032,7 +3032,7 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
} }
int AsmPrinterVariant = AsmInfo->getAssemblerDialect(); int AsmPrinterVariant = AsmInfo->getAssemblerDialect();
std::unique_ptr<MCInstPrinter> IP(TheTarget->createMCInstPrinter( std::unique_ptr<MCInstPrinter> IP(TheTarget->createMCInstPrinter(
AsmPrinterVariant, *AsmInfo, *InstrInfo, *MRI, *STI)); Triple(TripleName), AsmPrinterVariant, *AsmInfo, *InstrInfo, *MRI));
// Set the display preference for hex vs. decimal immediates. // Set the display preference for hex vs. decimal immediates.
IP->setPrintImmHex(PrintImmHex); IP->setPrintImmHex(PrintImmHex);
// Comment stream and backing vector. // Comment stream and backing vector.
@ -3080,8 +3080,8 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
} }
int ThumbAsmPrinterVariant = ThumbAsmInfo->getAssemblerDialect(); int ThumbAsmPrinterVariant = ThumbAsmInfo->getAssemblerDialect();
ThumbIP.reset(ThumbTarget->createMCInstPrinter( ThumbIP.reset(ThumbTarget->createMCInstPrinter(
ThumbAsmPrinterVariant, *ThumbAsmInfo, *ThumbInstrInfo, *ThumbMRI, Triple(ThumbTripleName), ThumbAsmPrinterVariant, *ThumbAsmInfo,
*ThumbSTI)); *ThumbInstrInfo, *ThumbMRI));
// Set the display preference for hex vs. decimal immediates. // Set the display preference for hex vs. decimal immediates.
ThumbIP->setPrintImmHex(PrintImmHex); ThumbIP->setPrintImmHex(PrintImmHex);
} }

View File

@ -274,7 +274,7 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
int AsmPrinterVariant = AsmInfo->getAssemblerDialect(); int AsmPrinterVariant = AsmInfo->getAssemblerDialect();
std::unique_ptr<MCInstPrinter> IP(TheTarget->createMCInstPrinter( std::unique_ptr<MCInstPrinter> IP(TheTarget->createMCInstPrinter(
AsmPrinterVariant, *AsmInfo, *MII, *MRI, *STI)); Triple(TripleName), AsmPrinterVariant, *AsmInfo, *MII, *MRI));
if (!IP) { if (!IP) {
errs() << "error: no instruction printer for target " << TripleName errs() << "error: no instruction printer for target " << TripleName
<< '\n'; << '\n';

View File

@ -507,7 +507,7 @@ static int linkAndVerify() {
std::unique_ptr<MCInstrInfo> MII(TheTarget->createMCInstrInfo()); std::unique_ptr<MCInstrInfo> MII(TheTarget->createMCInstrInfo());
std::unique_ptr<MCInstPrinter> InstPrinter( std::unique_ptr<MCInstPrinter> InstPrinter(
TheTarget->createMCInstPrinter(0, *MAI, *MII, *MRI, *STI)); TheTarget->createMCInstPrinter(Triple(TripleName), 0, *MAI, *MII, *MRI));
// Load any dylibs requested on the command line. // Load any dylibs requested on the command line.
loadDylibs(); loadDylibs();