Tom Stellard | cb6ba62 | 2016-04-30 00:23:06 +0000 | [diff] [blame] | 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/CodeGen/ScheduleHazardRecognizer.h" |
| 18 | #include <functional> |
| 19 | #include <list> |
| 20 | |
| 21 | namespace llvm { |
| 22 | |
| 23 | class MachineFunction; |
| 24 | class MachineInstr; |
| 25 | class ScheduleDAG; |
| 26 | class SIInstrInfo; |
| 27 | |
| 28 | class GCNHazardRecognizer final : public ScheduleHazardRecognizer { |
| 29 | |
| 30 | // This variable stores the instruction that has been emitted this cycle. |
| 31 | // It 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 | |
| 37 | int getWaitStatesSinceDef(unsigned Reg, |
| 38 | std::function<bool(MachineInstr*)> IsHazardDef = |
| 39 | [](MachineInstr*) {return true;}); |
| 40 | |
| 41 | int checkSMRDHazards(MachineInstr *SMRD); |
| 42 | int checkVMEMHazards(MachineInstr* VMEM); |
Tom Stellard | a27007e | 2016-05-02 16:23:09 +0000 | [diff] [blame^] | 43 | int checkDPPHazards(MachineInstr *DPP); |
Tom Stellard | cb6ba62 | 2016-04-30 00:23:06 +0000 | [diff] [blame] | 44 | public: |
| 45 | GCNHazardRecognizer(const MachineFunction &MF); |
| 46 | // We can only issue one instruction per cycle. |
| 47 | bool atIssueLimit() const override { return true; } |
| 48 | void EmitInstruction(SUnit *SU) override; |
| 49 | void EmitInstruction(MachineInstr *MI) override; |
| 50 | HazardType getHazardType(SUnit *SU, int Stalls) override; |
| 51 | void EmitNoop() override; |
| 52 | unsigned PreEmitNoops(SUnit *SU) override; |
| 53 | unsigned PreEmitNoops(MachineInstr *) override; |
| 54 | void AdvanceCycle() override; |
| 55 | void RecedeCycle() override; |
| 56 | }; |
| 57 | |
| 58 | } // end namespace llvm |
| 59 | |
| 60 | #endif //LLVM_LIB_TARGET_AMDGPUHAZARDRECOGNIZERS_H |