Allow target to provide its own hazard recognizer to post-ra scheduler.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105862 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Evan Cheng
2010-06-12 00:12:18 +00:00
parent 44acc24117
commit 729aab3dd3
2 changed files with 27 additions and 6 deletions

View File

@@ -20,12 +20,14 @@
namespace llvm { namespace llvm {
class CalleeSavedInfo; class CalleeSavedInfo;
class InstrItineraryData;
class LiveVariables; class LiveVariables;
class MCAsmInfo; class MCAsmInfo;
class MachineMemOperand; class MachineMemOperand;
class MDNode; class MDNode;
class MCInst; class MCInst;
class SDNode; class SDNode;
class ScheduleHazardRecognizer;
class SelectionDAG; class SelectionDAG;
class TargetRegisterClass; class TargetRegisterClass;
class TargetRegisterInfo; class TargetRegisterInfo;
@@ -575,6 +577,12 @@ public:
/// length. /// length.
virtual unsigned getInlineAsmLength(const char *Str, virtual unsigned getInlineAsmLength(const char *Str,
const MCAsmInfo &MAI) const; const MCAsmInfo &MAI) const;
/// CreateTargetHazardRecognizer - Allocate and return a hazard recognizer
/// to use for this target when scheduling the machine instructions after
/// register allocation.
virtual ScheduleHazardRecognizer*
CreateTargetPostRAHazardRecognizer(const InstrItineraryData&) const = 0;
}; };
/// TargetInstrInfoImpl - This is the default implementation of /// TargetInstrInfoImpl - This is the default implementation of
@@ -602,6 +610,9 @@ public:
virtual bool produceSameValue(const MachineInstr *MI0, virtual bool produceSameValue(const MachineInstr *MI0,
const MachineInstr *MI1) const; const MachineInstr *MI1) const;
virtual unsigned GetFunctionSizeInBytes(const MachineFunction &MF) const; virtual unsigned GetFunctionSizeInBytes(const MachineFunction &MF) const;
virtual ScheduleHazardRecognizer *
CreateTargetPostRAHazardRecognizer(const InstrItineraryData&) const;
}; };
} // End llvm namespace } // End llvm namespace

View File

@@ -67,8 +67,8 @@ EnableAntiDepBreaking("break-anti-dependencies",
cl::init("none"), cl::Hidden); cl::init("none"), cl::Hidden);
static cl::opt<bool> static cl::opt<bool>
EnablePostRAHazardAvoidance("avoid-hazards", EnablePostRAHazardAvoidance("avoid-hazards",
cl::desc("Enable exact hazard avoidance"), cl::desc("Enable exact hazard avoidance"),
cl::init(true), cl::Hidden); cl::init(true), cl::Hidden);
// If DebugDiv > 0 then only schedule MBB with (ID % DebugDiv) == DebugMod // If DebugDiv > 0 then only schedule MBB with (ID % DebugDiv) == DebugMod
static cl::opt<int> static cl::opt<int>
@@ -237,10 +237,10 @@ bool PostRAScheduler::runOnMachineFunction(MachineFunction &Fn) {
const MachineLoopInfo &MLI = getAnalysis<MachineLoopInfo>(); const MachineLoopInfo &MLI = getAnalysis<MachineLoopInfo>();
const MachineDominatorTree &MDT = getAnalysis<MachineDominatorTree>(); const MachineDominatorTree &MDT = getAnalysis<MachineDominatorTree>();
const InstrItineraryData &InstrItins = Fn.getTarget().getInstrItineraryData(); const TargetMachine &TM = Fn.getTarget();
ScheduleHazardRecognizer *HR = EnablePostRAHazardAvoidance ? const InstrItineraryData &InstrItins = TM.getInstrItineraryData();
(ScheduleHazardRecognizer *)new ExactHazardRecognizer(InstrItins) : ScheduleHazardRecognizer *HR =
(ScheduleHazardRecognizer *)new SimpleHazardRecognizer(); TM.getInstrInfo()->CreateTargetPostRAHazardRecognizer(InstrItins);
AntiDepBreaker *ADB = AntiDepBreaker *ADB =
((AntiDepMode == TargetSubtarget::ANTIDEP_ALL) ? ((AntiDepMode == TargetSubtarget::ANTIDEP_ALL) ?
(AntiDepBreaker *)new AggressiveAntiDepBreaker(Fn, CriticalPathRCs) : (AntiDepBreaker *)new AggressiveAntiDepBreaker(Fn, CriticalPathRCs) :
@@ -719,6 +719,16 @@ void SchedulePostRATDList::ListScheduleTopDown() {
#endif #endif
} }
// Default implementation of CreateTargetPostRAHazardRecognizer. This should
// be in TargetInstrInfoImpl.cpp except it reference local command line
// option EnablePostRAHazardAvoidance
ScheduleHazardRecognizer *TargetInstrInfoImpl::
CreateTargetPostRAHazardRecognizer(const InstrItineraryData &II) const {
if (EnablePostRAHazardAvoidance)
return (ScheduleHazardRecognizer *)new ExactHazardRecognizer(II);
return (ScheduleHazardRecognizer *)new SimpleHazardRecognizer();
}
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Public Constructor Functions // Public Constructor Functions
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//