diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2018-04-11 18:05:17 +0000 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2018-04-11 18:05:17 +0000 |
commit | 7f321d8c24e6e70af594c12cafe7cc2fe132ce67 (patch) | |
tree | 187d01820855b84b94e8204000a30f26ff3ef867 /llvm/lib/Target/X86/X86PadShortFunction.cpp | |
parent | b7a747e6a3b86aba0e72c2b8aaff77cd206ded68 (diff) | |
download | bcm5719-llvm-7f321d8c24e6e70af594c12cafe7cc2fe132ce67.tar.gz bcm5719-llvm-7f321d8c24e6e70af594c12cafe7cc2fe132ce67.zip |
[X86] Generalize X86PadShortFunction to work with TargetSchedModel
Pre-commit for D45486, don't rely on itinerary scheduler model to determine latencies for padding, use the generic TargetSchedModel::computeInstrLatency call.
Also, replace hard coded (atom specific) 2*uop creation per padding cycle with a version based on the scheduler model's issue width.
Differential Revision: https://reviews.llvm.org/D45486
llvm-svn: 329834
Diffstat (limited to 'llvm/lib/Target/X86/X86PadShortFunction.cpp')
-rw-r--r-- | llvm/lib/Target/X86/X86PadShortFunction.cpp | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/llvm/lib/Target/X86/X86PadShortFunction.cpp b/llvm/lib/Target/X86/X86PadShortFunction.cpp index 1da0fad8b6c..2fe5cb973da 100644 --- a/llvm/lib/Target/X86/X86PadShortFunction.cpp +++ b/llvm/lib/Target/X86/X86PadShortFunction.cpp @@ -21,7 +21,7 @@ #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/Passes.h" -#include "llvm/CodeGen/TargetInstrInfo.h" +#include "llvm/CodeGen/TargetSchedule.h" #include "llvm/IR/Function.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" @@ -49,7 +49,7 @@ namespace { struct PadShortFunc : public MachineFunctionPass { static char ID; PadShortFunc() : MachineFunctionPass(ID) - , Threshold(4), STI(nullptr), TII(nullptr) {} + , Threshold(4) {} bool runOnMachineFunction(MachineFunction &MF) override; @@ -82,8 +82,7 @@ namespace { // VisitedBBs - Cache of previously visited BBs. DenseMap<MachineBasicBlock*, VisitedBBInfo> VisitedBBs; - const X86Subtarget *STI; - const TargetInstrInfo *TII; + TargetSchedModel TSM; }; char PadShortFunc::ID = 0; @@ -99,15 +98,13 @@ bool PadShortFunc::runOnMachineFunction(MachineFunction &MF) { if (skipFunction(MF.getFunction())) return false; - if (MF.getFunction().optForSize()) { + if (MF.getFunction().optForSize()) return false; - } - STI = &MF.getSubtarget<X86Subtarget>(); - if (!STI->padShortFunctions()) + if (!MF.getSubtarget<X86Subtarget>().padShortFunctions()) return false; - TII = STI->getInstrInfo(); + TSM.init(&MF.getSubtarget()); // Search through basic blocks and mark the ones that have early returns ReturnBBs.clear(); @@ -195,7 +192,7 @@ bool PadShortFunc::cyclesUntilReturn(MachineBasicBlock *MBB, return true; } - CyclesToEnd += TII->getInstrLatency(STI->getInstrItineraryData(), MI); + CyclesToEnd += TSM.computeInstrLatency(&MI); } VisitedBBs[MBB] = VisitedBBInfo(false, CyclesToEnd); @@ -209,9 +206,8 @@ void PadShortFunc::addPadding(MachineBasicBlock *MBB, MachineBasicBlock::iterator &MBBI, unsigned int NOOPsToAdd) { DebugLoc DL = MBBI->getDebugLoc(); + unsigned IssueWidth = TSM.getIssueWidth(); - while (NOOPsToAdd-- > 0) { - BuildMI(*MBB, MBBI, DL, TII->get(X86::NOOP)); - BuildMI(*MBB, MBBI, DL, TII->get(X86::NOOP)); - } + for (unsigned i = 0, e = IssueWidth * NOOPsToAdd; i != e; ++i) + BuildMI(*MBB, MBBI, DL, TSM.getInstrInfo()->get(X86::NOOP)); } |