xref: /aosp_15_r20/external/llvm/lib/Target/AMDGPU/GCNHazardRecognizer.h (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker //===-- GCNHazardRecognizers.h - GCN Hazard Recognizers ---------*- C++ -*-===//
2*9880d681SAndroid Build Coastguard Worker //
3*9880d681SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker //
5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker //
8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker //
10*9880d681SAndroid Build Coastguard Worker // This file defines hazard recognizers for scheduling on GCN processors.
11*9880d681SAndroid Build Coastguard Worker //
12*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
13*9880d681SAndroid Build Coastguard Worker 
14*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_LIB_TARGET_AMDGPUHAZARDRECOGNIZERS_H
15*9880d681SAndroid Build Coastguard Worker #define LLVM_LIB_TARGET_AMDGPUHAZARDRECOGNIZERS_H
16*9880d681SAndroid Build Coastguard Worker 
17*9880d681SAndroid Build Coastguard Worker #include "llvm/ADT/STLExtras.h"
18*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/ScheduleHazardRecognizer.h"
19*9880d681SAndroid Build Coastguard Worker #include <list>
20*9880d681SAndroid Build Coastguard Worker 
21*9880d681SAndroid Build Coastguard Worker namespace llvm {
22*9880d681SAndroid Build Coastguard Worker 
23*9880d681SAndroid Build Coastguard Worker class MachineFunction;
24*9880d681SAndroid Build Coastguard Worker class MachineInstr;
25*9880d681SAndroid Build Coastguard Worker class ScheduleDAG;
26*9880d681SAndroid Build Coastguard Worker class SIInstrInfo;
27*9880d681SAndroid Build Coastguard Worker class SISubtarget;
28*9880d681SAndroid Build Coastguard Worker 
29*9880d681SAndroid Build Coastguard Worker class GCNHazardRecognizer final : public ScheduleHazardRecognizer {
30*9880d681SAndroid Build Coastguard Worker   // This variable stores the instruction that has been emitted this cycle. It
31*9880d681SAndroid Build Coastguard Worker   // will be added to EmittedInstrs, when AdvanceCycle() or RecedeCycle() is
32*9880d681SAndroid Build Coastguard Worker   // called.
33*9880d681SAndroid Build Coastguard Worker   MachineInstr *CurrCycleInstr;
34*9880d681SAndroid Build Coastguard Worker   std::list<MachineInstr*> EmittedInstrs;
35*9880d681SAndroid Build Coastguard Worker   const MachineFunction &MF;
36*9880d681SAndroid Build Coastguard Worker   const SISubtarget &ST;
37*9880d681SAndroid Build Coastguard Worker 
38*9880d681SAndroid Build Coastguard Worker   int getWaitStatesSinceDef(unsigned Reg,
39*9880d681SAndroid Build Coastguard Worker                             function_ref<bool(MachineInstr *)> IsHazardDef =
40*9880d681SAndroid Build Coastguard Worker                                 [](MachineInstr *) { return true; });
41*9880d681SAndroid Build Coastguard Worker 
42*9880d681SAndroid Build Coastguard Worker   int checkSMEMSoftClauseHazards(MachineInstr *SMEM);
43*9880d681SAndroid Build Coastguard Worker   int checkSMRDHazards(MachineInstr *SMRD);
44*9880d681SAndroid Build Coastguard Worker   int checkVMEMHazards(MachineInstr* VMEM);
45*9880d681SAndroid Build Coastguard Worker   int checkDPPHazards(MachineInstr *DPP);
46*9880d681SAndroid Build Coastguard Worker public:
47*9880d681SAndroid Build Coastguard Worker   GCNHazardRecognizer(const MachineFunction &MF);
48*9880d681SAndroid Build Coastguard Worker   // We can only issue one instruction per cycle.
atIssueLimit()49*9880d681SAndroid Build Coastguard Worker   bool atIssueLimit() const override { return true; }
50*9880d681SAndroid Build Coastguard Worker   void EmitInstruction(SUnit *SU) override;
51*9880d681SAndroid Build Coastguard Worker   void EmitInstruction(MachineInstr *MI) override;
52*9880d681SAndroid Build Coastguard Worker   HazardType getHazardType(SUnit *SU, int Stalls) override;
53*9880d681SAndroid Build Coastguard Worker   void EmitNoop() override;
54*9880d681SAndroid Build Coastguard Worker   unsigned PreEmitNoops(SUnit *SU) override;
55*9880d681SAndroid Build Coastguard Worker   unsigned PreEmitNoops(MachineInstr *) override;
56*9880d681SAndroid Build Coastguard Worker   void AdvanceCycle() override;
57*9880d681SAndroid Build Coastguard Worker   void RecedeCycle() override;
58*9880d681SAndroid Build Coastguard Worker };
59*9880d681SAndroid Build Coastguard Worker 
60*9880d681SAndroid Build Coastguard Worker } // end namespace llvm
61*9880d681SAndroid Build Coastguard Worker 
62*9880d681SAndroid Build Coastguard Worker #endif //LLVM_LIB_TARGET_AMDGPUHAZARDRECOGNIZERS_H
63