Update and remove a few calls to TargetMachine::getSubtargetImpl

out of the asm printer.

llvm-svn: 229883
This commit is contained in:
Eric Christopher 2015-02-19 18:46:23 +00:00
parent 016852c396
commit 504f388a84
1 changed files with 12 additions and 9 deletions

View File

@ -100,10 +100,13 @@ static unsigned getGVAlignmentLog2(const GlobalValue *GV, const DataLayout &TD,
AsmPrinter::AsmPrinter(TargetMachine &tm, std::unique_ptr<MCStreamer> Streamer) AsmPrinter::AsmPrinter(TargetMachine &tm, std::unique_ptr<MCStreamer> Streamer)
: MachineFunctionPass(ID), TM(tm), MAI(tm.getMCAsmInfo()), : MachineFunctionPass(ID), TM(tm), MAI(tm.getMCAsmInfo()),
MII(tm.getSubtargetImpl()->getInstrInfo()),
OutContext(Streamer->getContext()), OutStreamer(*Streamer.release()), OutContext(Streamer->getContext()), OutStreamer(*Streamer.release()),
LastMI(nullptr), LastFn(0), Counter(~0U), SetCounter(0) { LastMI(nullptr), LastFn(0), Counter(~0U), SetCounter(0) {
DD = nullptr; MMI = nullptr; LI = nullptr; MF = nullptr; MII = nullptr;
DD = nullptr;
MMI = nullptr;
LI = nullptr;
MF = nullptr;
CurrentFnSym = CurrentFnSymForSize = nullptr; CurrentFnSym = CurrentFnSymForSize = nullptr;
GCMetadataPrinters = nullptr; GCMetadataPrinters = nullptr;
VerboseAsm = OutStreamer.isVerboseAsm(); VerboseAsm = OutStreamer.isVerboseAsm();
@ -915,8 +918,9 @@ bool AsmPrinter::doFinalization(Module &M) {
if (JITI && !JITI->getTables().empty()) { if (JITI && !JITI->getTables().empty()) {
unsigned Arch = Triple(getTargetTriple()).getArch(); unsigned Arch = Triple(getTargetTriple()).getArch();
bool IsThumb = (Arch == Triple::thumb || Arch == Triple::thumbeb); bool IsThumb = (Arch == Triple::thumb || Arch == Triple::thumbeb);
const TargetInstrInfo *TII = TM.getSubtargetImpl()->getInstrInfo();
MCInst TrapInst; MCInst TrapInst;
TM.getSubtargetImpl()->getInstrInfo()->getTrap(TrapInst); TII->getTrap(TrapInst);
unsigned LogAlignment = llvm::Log2_64(JITI->entryByteAlignment()); unsigned LogAlignment = llvm::Log2_64(JITI->entryByteAlignment());
// Emit the right section for these functions. // Emit the right section for these functions.
@ -942,8 +946,7 @@ bool AsmPrinter::doFinalization(Module &M) {
const MCSymbolRefExpr *TargetSymRef = const MCSymbolRefExpr *TargetSymRef =
MCSymbolRefExpr::Create(TargetSymbol, MCSymbolRefExpr::VK_PLT, MCSymbolRefExpr::Create(TargetSymbol, MCSymbolRefExpr::VK_PLT,
OutContext); OutContext);
TM.getSubtargetImpl()->getInstrInfo()->getUnconditionalBranch( TII->getUnconditionalBranch(JumpToFun, TargetSymRef);
JumpToFun, TargetSymRef);
OutStreamer.EmitInstruction(JumpToFun, getSubtargetInfo()); OutStreamer.EmitInstruction(JumpToFun, getSubtargetInfo());
++Count; ++Count;
} }
@ -1062,6 +1065,7 @@ bool AsmPrinter::doFinalization(Module &M) {
void AsmPrinter::SetupMachineFunction(MachineFunction &MF) { void AsmPrinter::SetupMachineFunction(MachineFunction &MF) {
this->MF = &MF; this->MF = &MF;
MII = MF.getSubtarget().getInstrInfo();
// Get the function symbol. // Get the function symbol.
CurrentFnSym = getSymbol(MF.getFunction()); CurrentFnSym = getSymbol(MF.getFunction());
CurrentFnSymForSize = CurrentFnSym; CurrentFnSymForSize = CurrentFnSym;
@ -1209,7 +1213,7 @@ void AsmPrinter::EmitJumpTableInfo() {
if (MJTI->getEntryKind() == MachineJumpTableInfo::EK_LabelDifference32 && if (MJTI->getEntryKind() == MachineJumpTableInfo::EK_LabelDifference32 &&
MAI->doesSetDirectiveSuppressesReloc()) { MAI->doesSetDirectiveSuppressesReloc()) {
SmallPtrSet<const MachineBasicBlock*, 16> EmittedSets; SmallPtrSet<const MachineBasicBlock*, 16> EmittedSets;
const TargetLowering *TLI = TM.getSubtargetImpl()->getTargetLowering(); const TargetLowering *TLI = MF->getSubtarget().getTargetLowering();
const MCExpr *Base = TLI->getPICJumpTableRelocBaseExpr(MF,JTI,OutContext); const MCExpr *Base = TLI->getPICJumpTableRelocBaseExpr(MF,JTI,OutContext);
for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) { for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) {
const MachineBasicBlock *MBB = JTBBs[ii]; const MachineBasicBlock *MBB = JTBBs[ii];
@ -1253,8 +1257,7 @@ void AsmPrinter::EmitJumpTableEntry(const MachineJumpTableInfo *MJTI,
case MachineJumpTableInfo::EK_Inline: case MachineJumpTableInfo::EK_Inline:
llvm_unreachable("Cannot emit EK_Inline jump table entry"); llvm_unreachable("Cannot emit EK_Inline jump table entry");
case MachineJumpTableInfo::EK_Custom32: case MachineJumpTableInfo::EK_Custom32:
Value = Value = MF->getSubtarget().getTargetLowering()->LowerCustomJumpTableEntry(
TM.getSubtargetImpl()->getTargetLowering()->LowerCustomJumpTableEntry(
MJTI, MBB, UID, OutContext); MJTI, MBB, UID, OutContext);
break; break;
case MachineJumpTableInfo::EK_BlockAddress: case MachineJumpTableInfo::EK_BlockAddress: