40 CurrCycleInstr(nullptr),
43 TII(*
ST.getInstrInfo()) {
56 return Opcode == AMDGPU::V_DIV_FMAS_F32 || Opcode == AMDGPU::V_DIV_FMAS_F64;
60 return Opcode == AMDGPU::S_GETREG_B32;
64 return Opcode == AMDGPU::S_SETREG_B32 || Opcode == AMDGPU::S_SETREG_IMM32_B32;
68 return Opcode == AMDGPU::V_READLANE_B32 || Opcode == AMDGPU::V_WRITELANE_B32;
71 static bool isRFE(
unsigned Opcode) {
72 return Opcode == AMDGPU::S_RFE_B64;
77 case AMDGPU::S_MOVRELS_B32:
78 case AMDGPU::S_MOVRELS_B64:
79 case AMDGPU::S_MOVRELD_B32:
80 case AMDGPU::S_MOVRELD_B64:
89 AMDGPU::OpName::simm16);
125 checkReadM0Hazards(MI) > 0)
128 if (checkAnyInstHazards(MI) > 0)
139 int WaitStates =
std::max(0, checkAnyInstHazards(MI));
142 return std::max(WaitStates, checkSMRDHazards(MI));
145 WaitStates =
std::max(WaitStates, checkVALUHazards(MI));
148 WaitStates =
std::max(WaitStates, checkVMEMHazards(MI));
151 WaitStates =
std::max(WaitStates, checkDPPHazards(MI));
154 WaitStates =
std::max(WaitStates, checkDivFMasHazards(MI));
157 WaitStates =
std::max(WaitStates, checkRWLaneHazards(MI));
160 WaitStates =
std::max(WaitStates, checkReadM0Hazards(MI));
166 return std::max(WaitStates, checkGetRegHazards(MI));
169 return std::max(WaitStates, checkSetRegHazards(MI));
172 return std::max(WaitStates, checkRFEHazards(MI));
175 return std::max(WaitStates, checkReadM0Hazards(MI));
181 EmittedInstrs.push_front(
nullptr);
193 EmittedInstrs.push_front(CurrCycleInstr);
200 EmittedInstrs.push_front(
nullptr);
208 CurrCycleInstr =
nullptr;
212 llvm_unreachable(
"hazard recognizer does not support bottom-up scheduling.");
219 int GCNHazardRecognizer::getWaitStatesSince(
224 if (!
MI || !IsHazard(
MI))
231 int GCNHazardRecognizer::getWaitStatesSinceDef(
236 return IsHazardDef(
MI) &&
MI->modifiesRegister(Reg, TRI);
239 return getWaitStatesSince(IsHazardFn);
242 int GCNHazardRecognizer::getWaitStatesSinceSetReg(
248 return getWaitStatesSince(IsHazardFn);
256 std::set<unsigned> &Set) {
259 Set.insert(
Op.getReg());
263 int GCNHazardRecognizer::checkSMEMSoftClauseHazards(
MachineInstr *SMEM) {
278 std::set<unsigned> ClauseDefs;
279 std::set<unsigned> ClauseUses;
292 if (ClauseDefs.empty())
304 std::vector<unsigned> Result(
std::max(ClauseDefs.size(), ClauseUses.size()));
305 std::vector<unsigned>::iterator
End;
307 End = std::set_intersection(ClauseDefs.begin(), ClauseDefs.end(),
308 ClauseUses.begin(), ClauseUses.end(), Result.begin());
312 if (End != Result.begin())
320 int WaitStatesNeeded = 0;
322 WaitStatesNeeded = checkSMEMSoftClauseHazards(SMRD);
326 return WaitStatesNeeded;
330 int SmrdSgprWaitStates = 4;
336 int WaitStatesNeededForUse =
337 SmrdSgprWaitStates - getWaitStatesSinceDef(
Use.getReg(), IsHazardDefFn);
338 WaitStatesNeeded =
std::max(WaitStatesNeeded, WaitStatesNeededForUse);
340 return WaitStatesNeeded;
343 int GCNHazardRecognizer::checkVMEMHazards(
MachineInstr* VMEM) {
353 int VmemSgprWaitStates = 5;
354 int WaitStatesNeeded = 0;
361 int WaitStatesNeededForUse =
362 VmemSgprWaitStates - getWaitStatesSinceDef(
Use.getReg(), IsHazardDefFn);
363 WaitStatesNeeded =
std::max(WaitStatesNeeded, WaitStatesNeededForUse);
365 return WaitStatesNeeded;
372 int DppVgprWaitStates = 2;
373 int WaitStatesNeeded = 0;
378 int WaitStatesNeededForUse =
379 DppVgprWaitStates - getWaitStatesSinceDef(
Use.getReg());
380 WaitStatesNeeded =
std::max(WaitStatesNeeded, WaitStatesNeededForUse);
383 return WaitStatesNeeded;
386 int GCNHazardRecognizer::checkDivFMasHazards(
MachineInstr *DivFMas) {
391 const int DivFMasWaitStates = 4;
393 int WaitStatesNeeded = getWaitStatesSinceDef(AMDGPU::VCC, IsHazardDefFn);
395 return DivFMasWaitStates - WaitStatesNeeded;
398 int GCNHazardRecognizer::checkGetRegHazards(
MachineInstr *GetRegInstr) {
400 unsigned GetRegHWReg =
getHWReg(TII, *GetRegInstr);
402 const int GetRegWaitStates = 2;
406 int WaitStatesNeeded = getWaitStatesSinceSetReg(IsHazardFn);
408 return GetRegWaitStates - WaitStatesNeeded;
411 int GCNHazardRecognizer::checkSetRegHazards(
MachineInstr *SetRegInstr) {
413 unsigned HWReg =
getHWReg(TII, *SetRegInstr);
415 const int SetRegWaitStates =
420 int WaitStatesNeeded = getWaitStatesSinceSetReg(IsHazardFn);
421 return SetRegWaitStates - WaitStatesNeeded;
424 int GCNHazardRecognizer::createsVALUHazard(
const MachineInstr &
MI) {
449 (!SOffset || !SOffset->
isReg()))
482 const int VALUWaitStates = 1;
483 int WaitStatesNeeded = 0;
488 unsigned Reg =
Def.getReg();
490 int DataIdx = createsVALUHazard(*MI);
491 return DataIdx >= 0 &&
494 int WaitStatesNeededForDef =
495 VALUWaitStates - getWaitStatesSince(IsHazardFn);
496 WaitStatesNeeded =
std::max(WaitStatesNeeded, WaitStatesNeededForDef);
498 return WaitStatesNeeded;
501 int GCNHazardRecognizer::checkRWLaneHazards(
MachineInstr *RWLane) {
513 unsigned LaneSelectReg = LaneSelectOp->
getReg();
518 const int RWLaneWaitStates = 4;
519 int WaitStatesSince = getWaitStatesSinceDef(LaneSelectReg, IsHazardFn);
520 return RWLaneWaitStates - WaitStatesSince;
523 int GCNHazardRecognizer::checkRFEHazards(
MachineInstr *RFE) {
529 const int RFEWaitStates = 1;
534 int WaitStatesNeeded = getWaitStatesSinceSetReg(IsHazardFn);
535 return RFEWaitStates - WaitStatesNeeded;
538 int GCNHazardRecognizer::checkAnyInstHazards(
MachineInstr *MI) {
548 int MovFedWaitStates = 1;
549 int WaitStatesNeeded = 0;
555 return MI->
getOpcode() == AMDGPU::S_MOV_FED_B32;
557 int WaitStatesNeededForUse =
558 MovFedWaitStates - getWaitStatesSinceDef(
Use.getReg(), IsHazardFn);
559 WaitStatesNeeded =
std::max(WaitStatesNeeded, WaitStatesNeededForUse);
562 return WaitStatesNeeded;
565 int GCNHazardRecognizer::checkReadM0Hazards(
MachineInstr *MI) {
570 int SMovRelWaitStates = 1;
574 return SMovRelWaitStates - getWaitStatesSinceDef(AMDGPU::M0, IsHazardFn);
static bool isSMovRel(unsigned Opcode)
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
Interface definition for SIRegisterInfo.
bool hasSMovFedHazard() const
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
AMDGPU specific subclass of TargetSubtarget.
iterator_range< mop_iterator > uses()
Returns a range that includes all operands that are register uses.
bool isVGPR(const MachineRegisterInfo &MRI, unsigned Reg) const
Maximum length of the test input libFuzzer tries to guess a good value based on the corpus and reports it always prefer smaller inputs during the corpus shuffle When libFuzzer itself reports a bug this exit code will be used If indicates the maximal total time in seconds to run the fuzzer minimizes the provided crash input Use with tries to cleanse the provided crash input to make it contain fewer original bytes Use with exact_artifact_path to specify the output Experimental Use value profile to guide fuzzing Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
Describe properties that are true of each instruction in the target description file.
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
static bool isVINTRP(const MachineInstr &MI)
MachineInstrBuilder MachineInstrBuilder &DefMI const MCInstrDesc & Desc
MachineInstr * getInstr() const
Returns the representative MachineInstr for this SUnit.
const SIInstrInfo * getInstrInfo() const override
unsigned getRegBitWidth(unsigned RCID)
Get the size in bits of a register from the register class RC.
An efficient, type-erasing, non-owning reference to a callable.
static bool isRFE(unsigned Opcode)
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
static bool isSMRD(const MachineInstr &MI)
LLVM_READONLY int16_t getNamedOperandIdx(uint16_t Opcode, uint16_t NamedIdx)
void EmitNoop() override
EmitNoop - This callback is invoked when a noop was added to the instruction stream.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
static bool isFLAT(const MachineInstr &MI)
const HexagonInstrInfo * TII
static bool isMIMG(const MachineInstr &MI)
A Use represents the edge between a Value definition and its users.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
LLVM_READONLY MachineOperand * getNamedOperand(MachineInstr &MI, unsigned OperandName) const
Returns the operand named Op.
Reg
All possible values of the reg field in the ModR/M byte.
unsigned getMaxLookAhead() const
static bool isVALU(const MachineInstr &MI)
static bool isMUBUF(const MachineInstr &MI)
static bool isSSetReg(unsigned Opcode)
unsigned PreEmitNoops(SUnit *SU) override
PreEmitNoops - This callback is invoked prior to emitting an instruction.
Generation getGeneration() const
const SIRegisterInfo & getRegisterInfo() const
void RecedeCycle() override
RecedeCycle - This callback is invoked whenever the next bottom-up instruction to be scheduled cannot...
void EmitInstruction(SUnit *SU) override
EmitInstruction - This callback is invoked when an instruction is emitted, to advance the hazard stat...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MachineBasicBlock * getParent() const
unsigned MaxLookAhead
MaxLookAhead - Indicate the number of cycles in the scoreboard state.
bool isDebugValue() const
static bool isDPP(const MachineInstr &MI)
static void addRegsToSet(iterator_range< MachineInstr::const_mop_iterator > Ops, std::set< unsigned > &Set)
unsigned const MachineRegisterInfo * MRI
const MachineOperand & getOperand(unsigned i) const
iterator_range< mop_iterator > defs()
Returns a range over all explicit operands that are register definitions.
static const unsigned End
const SIRegisterInfo * getRegisterInfo() const override
static bool isSALU(const MachineInstr &MI)
HazardType getHazardType(SUnit *SU, int Stalls) override
getHazardType - Return the hazard type of emitting this node.
MachineOperand class - Representation of each machine instruction operand.
GCNHazardRecognizer(const MachineFunction &MF)
bool isSGPRReg(const MachineRegisterInfo &MRI, unsigned Reg) const
A range adaptor for a pair of iterators.
void AdvanceCycle() override
AdvanceCycle - This callback is invoked whenever the next top-down instruction to be scheduled cannot...
static bool isRWLane(unsigned Opcode)
llvm_unreachable("Unknown RegBank!")
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Representation of each machine instruction.
Interface definition for SIInstrInfo.
static bool isMTBUF(const MachineInstr &MI)
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
int16_t RegClass
This specifies the register class enumeration of the operand if the operand is a register.
unsigned getNumWaitStates(const MachineInstr &MI) const
Return the number of wait states that result from executing this instruction.
static bool isVMEM(const MachineInstr &MI)
bool hasReadM0Hazard() const
unsigned getReg() const
getReg - Returns the register number.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool isSGetReg(unsigned Opcode)
const MCOperandInfo * OpInfo
static unsigned getHWReg(const SIInstrInfo *TII, const MachineInstr &RegInstr)
Scheduling unit. This is a node in the scheduling DAG.
bool has12DWordStoreHazard() const
static bool isDivFMas(unsigned Opcode)