LLVM  5.0.0
GCNHazardRecognizer.cpp
Go to the documentation of this file.
1 //===-- GCNHazardRecognizers.cpp - GCN Hazard Recognizer Impls ------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements hazard recognizers for scheduling on GCN processors.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "GCNHazardRecognizer.h"
15 #include "AMDGPUSubtarget.h"
16 #include "SIDefines.h"
17 #include "SIInstrInfo.h"
18 #include "SIRegisterInfo.h"
19 #include "Utils/AMDGPUBaseInfo.h"
25 #include "llvm/MC/MCInstrDesc.h"
27 #include <algorithm>
28 #include <cassert>
29 #include <limits>
30 #include <set>
31 #include <vector>
32 
33 using namespace llvm;
34 
35 //===----------------------------------------------------------------------===//
36 // Hazard Recoginizer Implementation
37 //===----------------------------------------------------------------------===//
38 
40  CurrCycleInstr(nullptr),
41  MF(MF),
42  ST(MF.getSubtarget<SISubtarget>()),
43  TII(*ST.getInstrInfo()) {
44  MaxLookAhead = 5;
45 }
46 
49 }
50 
52  CurrCycleInstr = MI;
53 }
54 
55 static bool isDivFMas(unsigned Opcode) {
56  return Opcode == AMDGPU::V_DIV_FMAS_F32 || Opcode == AMDGPU::V_DIV_FMAS_F64;
57 }
58 
59 static bool isSGetReg(unsigned Opcode) {
60  return Opcode == AMDGPU::S_GETREG_B32;
61 }
62 
63 static bool isSSetReg(unsigned Opcode) {
64  return Opcode == AMDGPU::S_SETREG_B32 || Opcode == AMDGPU::S_SETREG_IMM32_B32;
65 }
66 
67 static bool isRWLane(unsigned Opcode) {
68  return Opcode == AMDGPU::V_READLANE_B32 || Opcode == AMDGPU::V_WRITELANE_B32;
69 }
70 
71 static bool isRFE(unsigned Opcode) {
72  return Opcode == AMDGPU::S_RFE_B64;
73 }
74 
75 static bool isSMovRel(unsigned Opcode) {
76  switch (Opcode) {
77  case AMDGPU::S_MOVRELS_B32:
78  case AMDGPU::S_MOVRELS_B64:
79  case AMDGPU::S_MOVRELD_B32:
80  case AMDGPU::S_MOVRELD_B64:
81  return true;
82  default:
83  return false;
84  }
85 }
86 
87 static unsigned getHWReg(const SIInstrInfo *TII, const MachineInstr &RegInstr) {
88  const MachineOperand *RegOp = TII->getNamedOperand(RegInstr,
89  AMDGPU::OpName::simm16);
90  return RegOp->getImm() & AMDGPU::Hwreg::ID_MASK_;
91 }
92 
95  MachineInstr *MI = SU->getInstr();
96 
97  if (SIInstrInfo::isSMRD(*MI) && checkSMRDHazards(MI) > 0)
98  return NoopHazard;
99 
100  if (SIInstrInfo::isVMEM(*MI) && checkVMEMHazards(MI) > 0)
101  return NoopHazard;
102 
103  if (SIInstrInfo::isVALU(*MI) && checkVALUHazards(MI) > 0)
104  return NoopHazard;
105 
106  if (SIInstrInfo::isDPP(*MI) && checkDPPHazards(MI) > 0)
107  return NoopHazard;
108 
109  if (isDivFMas(MI->getOpcode()) && checkDivFMasHazards(MI) > 0)
110  return NoopHazard;
111 
112  if (isRWLane(MI->getOpcode()) && checkRWLaneHazards(MI) > 0)
113  return NoopHazard;
114 
115  if (isSGetReg(MI->getOpcode()) && checkGetRegHazards(MI) > 0)
116  return NoopHazard;
117 
118  if (isSSetReg(MI->getOpcode()) && checkSetRegHazards(MI) > 0)
119  return NoopHazard;
120 
121  if (isRFE(MI->getOpcode()) && checkRFEHazards(MI) > 0)
122  return NoopHazard;
123 
124  if ((TII.isVINTRP(*MI) || isSMovRel(MI->getOpcode())) &&
125  checkReadM0Hazards(MI) > 0)
126  return NoopHazard;
127 
128  if (checkAnyInstHazards(MI) > 0)
129  return NoopHazard;
130 
131  return NoHazard;
132 }
133 
135  return PreEmitNoops(SU->getInstr());
136 }
137 
139  int WaitStates = std::max(0, checkAnyInstHazards(MI));
140 
141  if (SIInstrInfo::isSMRD(*MI))
142  return std::max(WaitStates, checkSMRDHazards(MI));
143 
144  if (SIInstrInfo::isVALU(*MI)) {
145  WaitStates = std::max(WaitStates, checkVALUHazards(MI));
146 
147  if (SIInstrInfo::isVMEM(*MI))
148  WaitStates = std::max(WaitStates, checkVMEMHazards(MI));
149 
150  if (SIInstrInfo::isDPP(*MI))
151  WaitStates = std::max(WaitStates, checkDPPHazards(MI));
152 
153  if (isDivFMas(MI->getOpcode()))
154  WaitStates = std::max(WaitStates, checkDivFMasHazards(MI));
155 
156  if (isRWLane(MI->getOpcode()))
157  WaitStates = std::max(WaitStates, checkRWLaneHazards(MI));
158 
159  if (TII.isVINTRP(*MI))
160  WaitStates = std::max(WaitStates, checkReadM0Hazards(MI));
161 
162  return WaitStates;
163  }
164 
165  if (isSGetReg(MI->getOpcode()))
166  return std::max(WaitStates, checkGetRegHazards(MI));
167 
168  if (isSSetReg(MI->getOpcode()))
169  return std::max(WaitStates, checkSetRegHazards(MI));
170 
171  if (isRFE(MI->getOpcode()))
172  return std::max(WaitStates, checkRFEHazards(MI));
173 
174  if (TII.isVINTRP(*MI) || isSMovRel(MI->getOpcode()))
175  return std::max(WaitStates, checkReadM0Hazards(MI));
176 
177  return WaitStates;
178 }
179 
181  EmittedInstrs.push_front(nullptr);
182 }
183 
185  // When the scheduler detects a stall, it will call AdvanceCycle() without
186  // emitting any instructions.
187  if (!CurrCycleInstr)
188  return;
189 
190  unsigned NumWaitStates = TII.getNumWaitStates(*CurrCycleInstr);
191 
192  // Keep track of emitted instructions
193  EmittedInstrs.push_front(CurrCycleInstr);
194 
195  // Add a nullptr for each additional wait state after the first. Make sure
196  // not to add more than getMaxLookAhead() items to the list, since we
197  // truncate the list to that size right after this loop.
198  for (unsigned i = 1, e = std::min(NumWaitStates, getMaxLookAhead());
199  i < e; ++i) {
200  EmittedInstrs.push_front(nullptr);
201  }
202 
203  // getMaxLookahead() is the largest number of wait states we will ever need
204  // to insert, so there is no point in keeping track of more than that many
205  // wait states.
206  EmittedInstrs.resize(getMaxLookAhead());
207 
208  CurrCycleInstr = nullptr;
209 }
210 
212  llvm_unreachable("hazard recognizer does not support bottom-up scheduling.");
213 }
214 
215 //===----------------------------------------------------------------------===//
216 // Helper Functions
217 //===----------------------------------------------------------------------===//
218 
219 int GCNHazardRecognizer::getWaitStatesSince(
220  function_ref<bool(MachineInstr *)> IsHazard) {
221  int WaitStates = -1;
222  for (MachineInstr *MI : EmittedInstrs) {
223  ++WaitStates;
224  if (!MI || !IsHazard(MI))
225  continue;
226  return WaitStates;
227  }
229 }
230 
231 int GCNHazardRecognizer::getWaitStatesSinceDef(
232  unsigned Reg, function_ref<bool(MachineInstr *)> IsHazardDef) {
233  const SIRegisterInfo *TRI = ST.getRegisterInfo();
234 
235  auto IsHazardFn = [IsHazardDef, TRI, Reg] (MachineInstr *MI) {
236  return IsHazardDef(MI) && MI->modifiesRegister(Reg, TRI);
237  };
238 
239  return getWaitStatesSince(IsHazardFn);
240 }
241 
242 int GCNHazardRecognizer::getWaitStatesSinceSetReg(
243  function_ref<bool(MachineInstr *)> IsHazard) {
244  auto IsHazardFn = [IsHazard] (MachineInstr *MI) {
245  return isSSetReg(MI->getOpcode()) && IsHazard(MI);
246  };
247 
248  return getWaitStatesSince(IsHazardFn);
249 }
250 
251 //===----------------------------------------------------------------------===//
252 // No-op Hazard Detection
253 //===----------------------------------------------------------------------===//
254 
256  std::set<unsigned> &Set) {
257  for (const MachineOperand &Op : Ops) {
258  if (Op.isReg())
259  Set.insert(Op.getReg());
260  }
261 }
262 
263 int GCNHazardRecognizer::checkSMEMSoftClauseHazards(MachineInstr *SMEM) {
264  // SMEM soft clause are only present on VI+
266  return 0;
267 
268  // A soft-clause is any group of consecutive SMEM instructions. The
269  // instructions in this group may return out of order and/or may be
270  // replayed (i.e. the same instruction issued more than once).
271  //
272  // In order to handle these situations correctly we need to make sure
273  // that when a clause has more than one instruction, no instruction in the
274  // clause writes to a register that is read another instruction in the clause
275  // (including itself). If we encounter this situaion, we need to break the
276  // clause by inserting a non SMEM instruction.
277 
278  std::set<unsigned> ClauseDefs;
279  std::set<unsigned> ClauseUses;
280 
281  for (MachineInstr *MI : EmittedInstrs) {
282 
283  // When we hit a non-SMEM instruction then we have passed the start of the
284  // clause and we can stop.
285  if (!MI || !SIInstrInfo::isSMRD(*MI))
286  break;
287 
288  addRegsToSet(MI->defs(), ClauseDefs);
289  addRegsToSet(MI->uses(), ClauseUses);
290  }
291 
292  if (ClauseDefs.empty())
293  return 0;
294 
295  // FIXME: When we support stores, we need to make sure not to put loads and
296  // stores in the same clause if they use the same address. For now, just
297  // start a new clause whenever we see a store.
298  if (SMEM->mayStore())
299  return 1;
300 
301  addRegsToSet(SMEM->defs(), ClauseDefs);
302  addRegsToSet(SMEM->uses(), ClauseUses);
303 
304  std::vector<unsigned> Result(std::max(ClauseDefs.size(), ClauseUses.size()));
305  std::vector<unsigned>::iterator End;
306 
307  End = std::set_intersection(ClauseDefs.begin(), ClauseDefs.end(),
308  ClauseUses.begin(), ClauseUses.end(), Result.begin());
309 
310  // If the set of defs and uses intersect then we cannot add this instruction
311  // to the clause, so we have a hazard.
312  if (End != Result.begin())
313  return 1;
314 
315  return 0;
316 }
317 
318 int GCNHazardRecognizer::checkSMRDHazards(MachineInstr *SMRD) {
319  const SISubtarget &ST = MF.getSubtarget<SISubtarget>();
320  int WaitStatesNeeded = 0;
321 
322  WaitStatesNeeded = checkSMEMSoftClauseHazards(SMRD);
323 
324  // This SMRD hazard only affects SI.
326  return WaitStatesNeeded;
327 
328  // A read of an SGPR by SMRD instruction requires 4 wait states when the
329  // SGPR was written by a VALU instruction.
330  int SmrdSgprWaitStates = 4;
331  auto IsHazardDefFn = [this] (MachineInstr *MI) { return TII.isVALU(*MI); };
332 
333  for (const MachineOperand &Use : SMRD->uses()) {
334  if (!Use.isReg())
335  continue;
336  int WaitStatesNeededForUse =
337  SmrdSgprWaitStates - getWaitStatesSinceDef(Use.getReg(), IsHazardDefFn);
338  WaitStatesNeeded = std::max(WaitStatesNeeded, WaitStatesNeededForUse);
339  }
340  return WaitStatesNeeded;
341 }
342 
343 int GCNHazardRecognizer::checkVMEMHazards(MachineInstr* VMEM) {
344  const SIInstrInfo *TII = ST.getInstrInfo();
345 
347  return 0;
348 
349  const SIRegisterInfo &TRI = TII->getRegisterInfo();
350 
351  // A read of an SGPR by a VMEM instruction requires 5 wait states when the
352  // SGPR was written by a VALU Instruction.
353  int VmemSgprWaitStates = 5;
354  int WaitStatesNeeded = 0;
355  auto IsHazardDefFn = [TII] (MachineInstr *MI) { return TII->isVALU(*MI); };
356 
357  for (const MachineOperand &Use : VMEM->uses()) {
358  if (!Use.isReg() || TRI.isVGPR(MF.getRegInfo(), Use.getReg()))
359  continue;
360 
361  int WaitStatesNeededForUse =
362  VmemSgprWaitStates - getWaitStatesSinceDef(Use.getReg(), IsHazardDefFn);
363  WaitStatesNeeded = std::max(WaitStatesNeeded, WaitStatesNeededForUse);
364  }
365  return WaitStatesNeeded;
366 }
367 
368 int GCNHazardRecognizer::checkDPPHazards(MachineInstr *DPP) {
369  const SIRegisterInfo *TRI = ST.getRegisterInfo();
370 
371  // Check for DPP VGPR read after VALU VGPR write.
372  int DppVgprWaitStates = 2;
373  int WaitStatesNeeded = 0;
374 
375  for (const MachineOperand &Use : DPP->uses()) {
376  if (!Use.isReg() || !TRI->isVGPR(MF.getRegInfo(), Use.getReg()))
377  continue;
378  int WaitStatesNeededForUse =
379  DppVgprWaitStates - getWaitStatesSinceDef(Use.getReg());
380  WaitStatesNeeded = std::max(WaitStatesNeeded, WaitStatesNeededForUse);
381  }
382 
383  return WaitStatesNeeded;
384 }
385 
386 int GCNHazardRecognizer::checkDivFMasHazards(MachineInstr *DivFMas) {
387  const SIInstrInfo *TII = ST.getInstrInfo();
388 
389  // v_div_fmas requires 4 wait states after a write to vcc from a VALU
390  // instruction.
391  const int DivFMasWaitStates = 4;
392  auto IsHazardDefFn = [TII] (MachineInstr *MI) { return TII->isVALU(*MI); };
393  int WaitStatesNeeded = getWaitStatesSinceDef(AMDGPU::VCC, IsHazardDefFn);
394 
395  return DivFMasWaitStates - WaitStatesNeeded;
396 }
397 
398 int GCNHazardRecognizer::checkGetRegHazards(MachineInstr *GetRegInstr) {
399  const SIInstrInfo *TII = ST.getInstrInfo();
400  unsigned GetRegHWReg = getHWReg(TII, *GetRegInstr);
401 
402  const int GetRegWaitStates = 2;
403  auto IsHazardFn = [TII, GetRegHWReg] (MachineInstr *MI) {
404  return GetRegHWReg == getHWReg(TII, *MI);
405  };
406  int WaitStatesNeeded = getWaitStatesSinceSetReg(IsHazardFn);
407 
408  return GetRegWaitStates - WaitStatesNeeded;
409 }
410 
411 int GCNHazardRecognizer::checkSetRegHazards(MachineInstr *SetRegInstr) {
412  const SIInstrInfo *TII = ST.getInstrInfo();
413  unsigned HWReg = getHWReg(TII, *SetRegInstr);
414 
415  const int SetRegWaitStates =
417  auto IsHazardFn = [TII, HWReg] (MachineInstr *MI) {
418  return HWReg == getHWReg(TII, *MI);
419  };
420  int WaitStatesNeeded = getWaitStatesSinceSetReg(IsHazardFn);
421  return SetRegWaitStates - WaitStatesNeeded;
422 }
423 
424 int GCNHazardRecognizer::createsVALUHazard(const MachineInstr &MI) {
425  if (!MI.mayStore())
426  return -1;
427 
428  const SIInstrInfo *TII = ST.getInstrInfo();
429  unsigned Opcode = MI.getOpcode();
430  const MCInstrDesc &Desc = MI.getDesc();
431 
432  int VDataIdx = AMDGPU::getNamedOperandIdx(Opcode, AMDGPU::OpName::vdata);
433  int VDataRCID = -1;
434  if (VDataIdx != -1)
435  VDataRCID = Desc.OpInfo[VDataIdx].RegClass;
436 
437  if (TII->isMUBUF(MI) || TII->isMTBUF(MI)) {
438  // There is no hazard if the instruction does not use vector regs
439  // (like wbinvl1)
440  if (VDataIdx == -1)
441  return -1;
442  // For MUBUF/MTBUF instructions this hazard only exists if the
443  // instruction is not using a register in the soffset field.
444  const MachineOperand *SOffset =
445  TII->getNamedOperand(MI, AMDGPU::OpName::soffset);
446  // If we have no soffset operand, then assume this field has been
447  // hardcoded to zero.
448  if (AMDGPU::getRegBitWidth(VDataRCID) > 64 &&
449  (!SOffset || !SOffset->isReg()))
450  return VDataIdx;
451  }
452 
453  // MIMG instructions create a hazard if they don't use a 256-bit T# and
454  // the store size is greater than 8 bytes and they have more than two bits
455  // of their dmask set.
456  // All our MIMG definitions use a 256-bit T#, so we can skip checking for them.
457  if (TII->isMIMG(MI)) {
458  int SRsrcIdx = AMDGPU::getNamedOperandIdx(Opcode, AMDGPU::OpName::srsrc);
459  assert(SRsrcIdx != -1 &&
460  AMDGPU::getRegBitWidth(Desc.OpInfo[SRsrcIdx].RegClass) == 256);
461  (void)SRsrcIdx;
462  }
463 
464  if (TII->isFLAT(MI)) {
465  int DataIdx = AMDGPU::getNamedOperandIdx(Opcode, AMDGPU::OpName::vdata);
466  if (AMDGPU::getRegBitWidth(Desc.OpInfo[DataIdx].RegClass) > 64)
467  return DataIdx;
468  }
469 
470  return -1;
471 }
472 
473 int GCNHazardRecognizer::checkVALUHazards(MachineInstr *VALU) {
474  // This checks for the hazard where VMEM instructions that store more than
475  // 8 bytes can have there store data over written by the next instruction.
476  if (!ST.has12DWordStoreHazard())
477  return 0;
478 
479  const SIRegisterInfo *TRI = ST.getRegisterInfo();
480  const MachineRegisterInfo &MRI = VALU->getParent()->getParent()->getRegInfo();
481 
482  const int VALUWaitStates = 1;
483  int WaitStatesNeeded = 0;
484 
485  for (const MachineOperand &Def : VALU->defs()) {
486  if (!TRI->isVGPR(MRI, Def.getReg()))
487  continue;
488  unsigned Reg = Def.getReg();
489  auto IsHazardFn = [this, Reg, TRI] (MachineInstr *MI) {
490  int DataIdx = createsVALUHazard(*MI);
491  return DataIdx >= 0 &&
492  TRI->regsOverlap(MI->getOperand(DataIdx).getReg(), Reg);
493  };
494  int WaitStatesNeededForDef =
495  VALUWaitStates - getWaitStatesSince(IsHazardFn);
496  WaitStatesNeeded = std::max(WaitStatesNeeded, WaitStatesNeededForDef);
497  }
498  return WaitStatesNeeded;
499 }
500 
501 int GCNHazardRecognizer::checkRWLaneHazards(MachineInstr *RWLane) {
502  const SIInstrInfo *TII = ST.getInstrInfo();
503  const SIRegisterInfo *TRI = ST.getRegisterInfo();
504  const MachineRegisterInfo &MRI =
505  RWLane->getParent()->getParent()->getRegInfo();
506 
507  const MachineOperand *LaneSelectOp =
508  TII->getNamedOperand(*RWLane, AMDGPU::OpName::src1);
509 
510  if (!LaneSelectOp->isReg() || !TRI->isSGPRReg(MRI, LaneSelectOp->getReg()))
511  return 0;
512 
513  unsigned LaneSelectReg = LaneSelectOp->getReg();
514  auto IsHazardFn = [TII] (MachineInstr *MI) {
515  return TII->isVALU(*MI);
516  };
517 
518  const int RWLaneWaitStates = 4;
519  int WaitStatesSince = getWaitStatesSinceDef(LaneSelectReg, IsHazardFn);
520  return RWLaneWaitStates - WaitStatesSince;
521 }
522 
523 int GCNHazardRecognizer::checkRFEHazards(MachineInstr *RFE) {
525  return 0;
526 
527  const SIInstrInfo *TII = ST.getInstrInfo();
528 
529  const int RFEWaitStates = 1;
530 
531  auto IsHazardFn = [TII] (MachineInstr *MI) {
532  return getHWReg(TII, *MI) == AMDGPU::Hwreg::ID_TRAPSTS;
533  };
534  int WaitStatesNeeded = getWaitStatesSinceSetReg(IsHazardFn);
535  return RFEWaitStates - WaitStatesNeeded;
536 }
537 
538 int GCNHazardRecognizer::checkAnyInstHazards(MachineInstr *MI) {
539  if (MI->isDebugValue())
540  return 0;
541 
542  const SIRegisterInfo *TRI = ST.getRegisterInfo();
543  if (!ST.hasSMovFedHazard())
544  return 0;
545 
546  // Check for any instruction reading an SGPR after a write from
547  // s_mov_fed_b32.
548  int MovFedWaitStates = 1;
549  int WaitStatesNeeded = 0;
550 
551  for (const MachineOperand &Use : MI->uses()) {
552  if (!Use.isReg() || TRI->isVGPR(MF.getRegInfo(), Use.getReg()))
553  continue;
554  auto IsHazardFn = [] (MachineInstr *MI) {
555  return MI->getOpcode() == AMDGPU::S_MOV_FED_B32;
556  };
557  int WaitStatesNeededForUse =
558  MovFedWaitStates - getWaitStatesSinceDef(Use.getReg(), IsHazardFn);
559  WaitStatesNeeded = std::max(WaitStatesNeeded, WaitStatesNeededForUse);
560  }
561 
562  return WaitStatesNeeded;
563 }
564 
565 int GCNHazardRecognizer::checkReadM0Hazards(MachineInstr *MI) {
566  if (!ST.hasReadM0Hazard())
567  return 0;
568 
569  const SIInstrInfo *TII = ST.getInstrInfo();
570  int SMovRelWaitStates = 1;
571  auto IsHazardFn = [TII] (MachineInstr *MI) {
572  return TII->isSALU(*MI);
573  };
574  return SMovRelWaitStates - getWaitStatesSinceDef(AMDGPU::M0, IsHazardFn);
575 }
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.
Definition: MachineInstr.h:339
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.
Definition: MCInstrDesc.h:163
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
Definition: MachineInstr.h:613
static bool isVINTRP(const MachineInstr &MI)
Definition: SIInstrInfo.h:483
MachineInstrBuilder MachineInstrBuilder &DefMI const MCInstrDesc & Desc
MachineInstr * getInstr() const
Returns the representative MachineInstr for this SUnit.
Definition: ScheduleDAG.h:378
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.
Definition: STLExtras.h:89
static bool isRFE(unsigned Opcode)
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
Definition: MachineInstr.h:276
static bool isSMRD(const MachineInstr &MI)
Definition: SIInstrInfo.h:387
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)
Definition: SIInstrInfo.h:419
const HexagonInstrInfo * TII
static bool isMIMG(const MachineInstr &MI)
Definition: SIInstrInfo.h:403
A Use represents the edge between a Value definition and its users.
Definition: Use.h:56
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.
static bool isVALU(const MachineInstr &MI)
Definition: SIInstrInfo.h:275
static bool isMUBUF(const MachineInstr &MI)
Definition: SIInstrInfo.h:371
static bool isSSetReg(unsigned Opcode)
unsigned PreEmitNoops(SUnit *SU) override
PreEmitNoops - This callback is invoked prior to emitting an instruction.
int64_t getImm() const
Generation getGeneration() const
const SIRegisterInfo & getRegisterInfo() const
Definition: SIInstrInfo.h:125
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.
Definition: MachineInstr.h:279
const MachineBasicBlock * getParent() const
Definition: MachineInstr.h:139
unsigned MaxLookAhead
MaxLookAhead - Indicate the number of cycles in the scoreboard state.
bool isDebugValue() const
Definition: MachineInstr.h:785
static bool isDPP(const MachineInstr &MI)
Definition: SIInstrInfo.h:467
static void addRegsToSet(iterator_range< MachineInstr::const_mop_iterator > Ops, std::set< unsigned > &Set)
unsigned const MachineRegisterInfo * MRI
const MachineOperand & getOperand(unsigned i) const
Definition: MachineInstr.h:284
iterator_range< mop_iterator > defs()
Returns a range over all explicit operands that are register definitions.
Definition: MachineInstr.h:328
static const unsigned End
const SIRegisterInfo * getRegisterInfo() const override
static bool isSALU(const MachineInstr &MI)
Definition: SIInstrInfo.h:267
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.
Definition: MachineInstr.h:59
Interface definition for SIInstrInfo.
static bool isMTBUF(const MachineInstr &MI)
Definition: SIInstrInfo.h:379
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.
Definition: MCInstrDesc.h:76
unsigned getNumWaitStates(const MachineInstr &MI) const
Return the number of wait states that result from executing this instruction.
static bool isVMEM(const MachineInstr &MI)
Definition: SIInstrInfo.h:283
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
Definition: MCInstrDesc.h:174
IRTranslator LLVM IR MI
static unsigned getHWReg(const SIInstrInfo *TII, const MachineInstr &RegInstr)
Scheduling unit. This is a node in the scheduling DAG.
Definition: ScheduleDAG.h:247
bool has12DWordStoreHazard() const
static bool isDivFMas(unsigned Opcode)