LLVM  5.0.0
GCNHazardRecognizer.h
Go to the documentation of this file.
1 //===-- GCNHazardRecognizers.h - GCN Hazard Recognizers ---------*- C++ -*-===//
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 defines hazard recognizers for scheduling on GCN processors.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_LIB_TARGET_AMDGPUHAZARDRECOGNIZERS_H
15 #define LLVM_LIB_TARGET_AMDGPUHAZARDRECOGNIZERS_H
16 
17 #include "llvm/ADT/STLExtras.h"
19 #include <list>
20 
21 namespace llvm {
22 
23 class MachineFunction;
24 class MachineInstr;
25 class ScheduleDAG;
26 class SIInstrInfo;
27 class SISubtarget;
28 
30  // This variable stores the instruction that has been emitted this cycle. It
31  // will be added to EmittedInstrs, when AdvanceCycle() or RecedeCycle() is
32  // called.
33  MachineInstr *CurrCycleInstr;
34  std::list<MachineInstr*> EmittedInstrs;
35  const MachineFunction &MF;
36  const SISubtarget &ST;
37  const SIInstrInfo &TII;
38 
39  int getWaitStatesSince(function_ref<bool(MachineInstr *)> IsHazard);
40  int getWaitStatesSinceDef(unsigned Reg,
41  function_ref<bool(MachineInstr *)> IsHazardDef =
42  [](MachineInstr *) { return true; });
43  int getWaitStatesSinceSetReg(function_ref<bool(MachineInstr *)> IsHazard);
44 
45  int checkSMEMSoftClauseHazards(MachineInstr *SMEM);
46  int checkSMRDHazards(MachineInstr *SMRD);
47  int checkVMEMHazards(MachineInstr* VMEM);
48  int checkDPPHazards(MachineInstr *DPP);
49  int checkDivFMasHazards(MachineInstr *DivFMas);
50  int checkGetRegHazards(MachineInstr *GetRegInstr);
51  int checkSetRegHazards(MachineInstr *SetRegInstr);
52  int createsVALUHazard(const MachineInstr &MI);
53  int checkVALUHazards(MachineInstr *VALU);
54  int checkRWLaneHazards(MachineInstr *RWLane);
55  int checkRFEHazards(MachineInstr *RFE);
56  int checkAnyInstHazards(MachineInstr *MI);
57  int checkReadM0Hazards(MachineInstr *SMovRel);
58 public:
60  // We can only issue one instruction per cycle.
61  bool atIssueLimit() const override { return true; }
62  void EmitInstruction(SUnit *SU) override;
63  void EmitInstruction(MachineInstr *MI) override;
64  HazardType getHazardType(SUnit *SU, int Stalls) override;
65  void EmitNoop() override;
66  unsigned PreEmitNoops(SUnit *SU) override;
67  unsigned PreEmitNoops(MachineInstr *) override;
68  void AdvanceCycle() override;
69  void RecedeCycle() override;
70 };
71 
72 } // end namespace llvm
73 
74 #endif //LLVM_LIB_TARGET_AMDGPUHAZARDRECOGNIZERS_H
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:89
void EmitNoop() override
EmitNoop - This callback is invoked when a noop was added to the instruction stream.
Reg
All possible values of the reg field in the ModR/M byte.
unsigned PreEmitNoops(SUnit *SU) override
PreEmitNoops - This callback is invoked prior to emitting an instruction.
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...
HazardRecognizer - This determines whether or not an instruction can be issued this cycle...
HazardType getHazardType(SUnit *SU, int Stalls) override
getHazardType - Return the hazard type of emitting this node.
GCNHazardRecognizer(const MachineFunction &MF)
void AdvanceCycle() override
AdvanceCycle - This callback is invoked whenever the next top-down instruction to be scheduled cannot...
Representation of each machine instruction.
Definition: MachineInstr.h:59
bool atIssueLimit() const override
atIssueLimit - Return true if no more instructions may be issued in this cycle.
IRTranslator LLVM IR MI
Scheduling unit. This is a node in the scheduling DAG.
Definition: ScheduleDAG.h:247