xref: /netbsd-src/external/apache2/llvm/dist/llvm/lib/Target/AMDGPU/AMDGPUPerfHintAnalysis.h (revision 82d56013d7b633d116a93943de88e08335357a7c)
1*7330f729Sjoerg //===- AMDGPUPerfHintAnalysis.h ---- analysis of memory traffic -*- C++ -*-===//
2*7330f729Sjoerg //
3*7330f729Sjoerg // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*7330f729Sjoerg // See https://llvm.org/LICENSE.txt for license information.
5*7330f729Sjoerg // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*7330f729Sjoerg //
7*7330f729Sjoerg //===----------------------------------------------------------------------===//
8*7330f729Sjoerg //
9*7330f729Sjoerg /// \file
10*7330f729Sjoerg /// \brief Analyzes if a function potentially memory bound and if a kernel
11*7330f729Sjoerg /// kernel may benefit from limiting number of waves to reduce cache thrashing.
12*7330f729Sjoerg ///
13*7330f729Sjoerg //===----------------------------------------------------------------------===//
14*7330f729Sjoerg 
15*7330f729Sjoerg #ifndef LLVM_LIB_TARGET_AMDGPU_MDGPUPERFHINTANALYSIS_H
16*7330f729Sjoerg #define LLVM_LIB_TARGET_AMDGPU_MDGPUPERFHINTANALYSIS_H
17*7330f729Sjoerg 
18*7330f729Sjoerg #include "llvm/Analysis/CallGraphSCCPass.h"
19*7330f729Sjoerg #include "llvm/IR/ValueMap.h"
20*7330f729Sjoerg 
21*7330f729Sjoerg namespace llvm {
22*7330f729Sjoerg 
23*7330f729Sjoerg struct AMDGPUPerfHintAnalysis : public CallGraphSCCPass {
24*7330f729Sjoerg   static char ID;
25*7330f729Sjoerg 
26*7330f729Sjoerg public:
AMDGPUPerfHintAnalysisAMDGPUPerfHintAnalysis27*7330f729Sjoerg   AMDGPUPerfHintAnalysis() : CallGraphSCCPass(ID) {}
28*7330f729Sjoerg 
29*7330f729Sjoerg   bool runOnSCC(CallGraphSCC &SCC) override;
30*7330f729Sjoerg 
getAnalysisUsageAMDGPUPerfHintAnalysis31*7330f729Sjoerg   void getAnalysisUsage(AnalysisUsage &AU) const override {
32*7330f729Sjoerg     AU.setPreservesAll();
33*7330f729Sjoerg   }
34*7330f729Sjoerg 
35*7330f729Sjoerg   bool isMemoryBound(const Function *F) const;
36*7330f729Sjoerg 
37*7330f729Sjoerg   bool needsWaveLimiter(const Function *F) const;
38*7330f729Sjoerg 
39*7330f729Sjoerg   struct FuncInfo {
40*7330f729Sjoerg     unsigned MemInstCount;
41*7330f729Sjoerg     unsigned InstCount;
42*7330f729Sjoerg     unsigned IAMInstCount; // Indirect access memory instruction count
43*7330f729Sjoerg     unsigned LSMInstCount; // Large stride memory instruction count
FuncInfoAMDGPUPerfHintAnalysis::FuncInfo44*7330f729Sjoerg     FuncInfo() : MemInstCount(0), InstCount(0), IAMInstCount(0),
45*7330f729Sjoerg                  LSMInstCount(0) {}
46*7330f729Sjoerg   };
47*7330f729Sjoerg 
48*7330f729Sjoerg   typedef ValueMap<const Function*, FuncInfo> FuncInfoMap;
49*7330f729Sjoerg 
50*7330f729Sjoerg private:
51*7330f729Sjoerg 
52*7330f729Sjoerg   FuncInfoMap FIM;
53*7330f729Sjoerg };
54*7330f729Sjoerg } // namespace llvm
55*7330f729Sjoerg #endif // LLVM_LIB_TARGET_AMDGPU_MDGPUPERFHINTANALYSIS_H
56