LLVM  8.0.1
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/BitVector.h"
18 #include "llvm/ADT/STLExtras.h"
20 #include <list>
21 
22 namespace llvm {
23 
24 class MachineFunction;
25 class MachineInstr;
26 class MachineOperand;
27 class MachineRegisterInfo;
28 class ScheduleDAG;
29 class SIInstrInfo;
30 class SIRegisterInfo;
31 class GCNSubtarget;
32 
34  // This variable stores the instruction that has been emitted this cycle. It
35  // will be added to EmittedInstrs, when AdvanceCycle() or RecedeCycle() is
36  // called.
37  MachineInstr *CurrCycleInstr;
38  std::list<MachineInstr*> EmittedInstrs;
39  const MachineFunction &MF;
40  const GCNSubtarget &ST;
41  const SIInstrInfo &TII;
42  const SIRegisterInfo &TRI;
43 
44  /// RegUnits of uses in the current soft memory clause.
45  BitVector ClauseUses;
46 
47  /// RegUnits of defs in the current soft memory clause.
48  BitVector ClauseDefs;
49 
50  void resetClause() {
51  ClauseUses.reset();
52  ClauseDefs.reset();
53  }
54 
55  void addClauseInst(const MachineInstr &MI);
56 
57  int getWaitStatesSince(function_ref<bool(MachineInstr *)> IsHazard);
58  int getWaitStatesSinceDef(unsigned Reg,
59  function_ref<bool(MachineInstr *)> IsHazardDef =
60  [](MachineInstr *) { return true; });
61  int getWaitStatesSinceSetReg(function_ref<bool(MachineInstr *)> IsHazard);
62 
63  int checkSoftClauseHazards(MachineInstr *SMEM);
64  int checkSMRDHazards(MachineInstr *SMRD);
65  int checkVMEMHazards(MachineInstr* VMEM);
66  int checkDPPHazards(MachineInstr *DPP);
67  int checkDivFMasHazards(MachineInstr *DivFMas);
68  int checkGetRegHazards(MachineInstr *GetRegInstr);
69  int checkSetRegHazards(MachineInstr *SetRegInstr);
70  int createsVALUHazard(const MachineInstr &MI);
71  int checkVALUHazards(MachineInstr *VALU);
72  int checkVALUHazardsHelper(const MachineOperand &Def, const MachineRegisterInfo &MRI);
73  int checkRWLaneHazards(MachineInstr *RWLane);
74  int checkRFEHazards(MachineInstr *RFE);
75  int checkInlineAsmHazards(MachineInstr *IA);
76  int checkAnyInstHazards(MachineInstr *MI);
77  int checkReadM0Hazards(MachineInstr *SMovRel);
78 public:
80  // We can only issue one instruction per cycle.
81  bool atIssueLimit() const override { return true; }
82  void EmitInstruction(SUnit *SU) override;
83  void EmitInstruction(MachineInstr *MI) override;
84  HazardType getHazardType(SUnit *SU, int Stalls) override;
85  void EmitNoop() override;
86  unsigned PreEmitNoops(SUnit *SU) override;
87  unsigned PreEmitNoops(MachineInstr *) override;
88  void AdvanceCycle() override;
89  void RecedeCycle() override;
90 };
91 
92 } // end namespace llvm
93 
94 #endif //LLVM_LIB_TARGET_AMDGPUHAZARDRECOGNIZERS_H
This class represents lattice values for constants.
Definition: AllocatorList.h:24
unsigned Reg
An efficient, type-erasing, non-owning reference to a callable.
Definition: STLExtras.h:117
void EmitNoop() override
EmitNoop - This callback is invoked when a noop was added to the instruction stream.
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...
unsigned const MachineRegisterInfo * MRI
HazardRecognizer - This determines whether or not an instruction can be issued this cycle...
BitVector & reset()
Definition: BitVector.h:439
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)
void AdvanceCycle() override
AdvanceCycle - This callback is invoked whenever the next top-down instruction to be scheduled cannot...
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:64
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:246