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. This class is used by the tool llvm-mca to enforce 12 /// target specific behaviour that is not expressed well enough in the 13 /// scheduling model for mca to enforce it automatically. 14 /// 15 //===----------------------------------------------------------------------===// 16 17 #ifndef LLVM_LIB_TARGET_AMDGPU_MCA_AMDGPUCUSTOMBEHAVIOUR_H 18 #define LLVM_LIB_TARGET_AMDGPU_MCA_AMDGPUCUSTOMBEHAVIOUR_H 19 20 #include "llvm/ADT/SmallVector.h" 21 #include "llvm/MCA/CustomBehaviour.h" 22 #include "llvm/Support/TargetParser.h" 23 24 namespace llvm { 25 namespace mca { 26 27 class AMDGPUInstrPostProcess : public InstrPostProcess { 28 public: 29 AMDGPUInstrPostProcess(const MCSubtargetInfo &STI, const MCInstrInfo &MCII) 30 : InstrPostProcess(STI, MCII) {} 31 32 ~AMDGPUInstrPostProcess() {} 33 34 void postProcessInstruction(std::unique_ptr<mca::Instruction> &Inst, 35 const MCInst &MCI) override {} 36 }; 37 38 class AMDGPUCustomBehaviour : public CustomBehaviour { 39 public: 40 AMDGPUCustomBehaviour(const MCSubtargetInfo &STI, 41 const mca::SourceMgr &SrcMgr, const MCInstrInfo &MCII); 42 43 ~AMDGPUCustomBehaviour() {} 44 45 /// This method is used to determine if an instruction 46 /// should be allowed to be dispatched. The return value is 47 /// how many cycles until the instruction can be dispatched. 48 /// This method is called after MCA has already checked for 49 /// register and hardware dependencies so this method should only 50 /// implement custom behaviour and dependencies that are not picked up 51 /// by MCA naturally. 52 unsigned checkCustomHazard(ArrayRef<mca::InstRef> IssuedInst, 53 const mca::InstRef &IR) override; 54 }; 55 56 } // namespace mca 57 } // namespace llvm 58 59 #endif 60