1 //===------------------- AMDGPUCustomBehaviour.h ----------------*-C++ -* -===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 /// \file
9 ///
10 /// This file defines the AMDGPUCustomBehaviour class which inherits from
11 /// CustomBehaviour.
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_TOOLS_LLVM_MCA_LIB_AMDGPU_AMDGPUCUSTOMBEHAVIOUR_H
16 #define LLVM_TOOLS_LLVM_MCA_LIB_AMDGPU_AMDGPUCUSTOMBEHAVIOUR_H
17 
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/MCA/CustomBehaviour.h"
20 #include "llvm/Support/TargetParser.h"
21 
22 namespace llvm {
23 namespace mca {
24 
25 class AMDGPUInstrPostProcess : public InstrPostProcess {
26 public:
AMDGPUInstrPostProcess(const MCSubtargetInfo & STI,const MCInstrInfo & MCII)27   AMDGPUInstrPostProcess(const MCSubtargetInfo &STI, const MCInstrInfo &MCII)
28       : InstrPostProcess(STI, MCII) {}
29 
~AMDGPUInstrPostProcess()30   ~AMDGPUInstrPostProcess() {}
31 
postProcessInstruction(std::unique_ptr<Instruction> & Inst,const MCInst & MCI)32   void postProcessInstruction(std::unique_ptr<Instruction> &Inst,
33                               const MCInst &MCI) override {}
34 };
35 
36 class AMDGPUCustomBehaviour : public CustomBehaviour {
37 public:
38   AMDGPUCustomBehaviour(const MCSubtargetInfo &STI, const SourceMgr &SrcMgr,
39                         const MCInstrInfo &MCII);
40 
~AMDGPUCustomBehaviour()41   ~AMDGPUCustomBehaviour() {}
42 
43   /// This method is used to determine if an instruction
44   /// should be allowed to be dispatched. The return value is
45   /// how many cycles until the instruction can be dispatched.
46   /// This method is called after MCA has already checked for
47   /// register and hardware dependencies so this method should only
48   /// implement custom behaviour and dependencies that are not picked up
49   /// by MCA naturally.
50   unsigned checkCustomHazard(ArrayRef<InstRef> IssuedInst,
51                              const InstRef &IR) override;
52 };
53 
54 } // namespace mca
55 } // namespace llvm
56 
57 #endif /* LLVM_TOOLS_LLVM_MCA_LIB_AMDGPU_AMDGPUCUSTOMBEHAVIOUR_H */
58