blob: 7fde1d9116b0b5a39be8429fc435518ee89ce0a1 [file] [log] [blame]
Tom Stellardcb6ba622016-04-30 00:23:06 +00001//===-- 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
21namespace llvm {
22
23class MachineFunction;
24class MachineInstr;
25class ScheduleDAG;
26class SIInstrInfo;
27
28class 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
Tom Stellard1f520e52016-05-02 17:39:06 +000041 int checkSMEMSoftClauseHazards(MachineInstr *SMEM);
Tom Stellardcb6ba622016-04-30 00:23:06 +000042 int checkSMRDHazards(MachineInstr *SMRD);
43 int checkVMEMHazards(MachineInstr* VMEM);
Tom Stellarda27007e2016-05-02 16:23:09 +000044 int checkDPPHazards(MachineInstr *DPP);
Tom Stellardcb6ba622016-04-30 00:23:06 +000045public:
46 GCNHazardRecognizer(const MachineFunction &MF);
47 // We can only issue one instruction per cycle.
48 bool atIssueLimit() const override { return true; }
49 void EmitInstruction(SUnit *SU) override;
50 void EmitInstruction(MachineInstr *MI) override;
51 HazardType getHazardType(SUnit *SU, int Stalls) override;
52 void EmitNoop() override;
53 unsigned PreEmitNoops(SUnit *SU) override;
54 unsigned PreEmitNoops(MachineInstr *) override;
55 void AdvanceCycle() override;
56 void RecedeCycle() override;
57};
58
59} // end namespace llvm
60
61#endif //LLVM_LIB_TARGET_AMDGPUHAZARDRECOGNIZERS_H