1 //===-- AMDGPUMachineFunctionInfo.h -------------------------------*- 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 #ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUMACHINEFUNCTION_H
11 #define LLVM_LIB_TARGET_AMDGPU_AMDGPUMACHINEFUNCTION_H
12 
13 #include "llvm/ADT/DenseMap.h"
14 #include "llvm/CodeGen/MachineFunction.h"
15 
16 namespace llvm {
17 
18 class GCNSubtarget;
19 
20 class AMDGPUMachineFunction : public MachineFunctionInfo {
21   /// A map to keep track of local memory objects and their offsets within the
22   /// local memory space.
23   SmallDenseMap<const GlobalValue *, unsigned, 4> LocalMemoryObjects;
24 
25 protected:
26   uint64_t ExplicitKernArgSize;
27   unsigned MaxKernArgAlign;
28 
29   /// Number of bytes in the LDS that are being used.
30   unsigned LDSSize;
31 
32   // Kernels + shaders. i.e. functions called by the driver and not called
33   // by other functions.
34   bool IsEntryFunction;
35 
36   bool NoSignedZerosFPMath;
37 
38   // Function may be memory bound.
39   bool MemoryBound;
40 
41   // Kernel may need limited waves per EU for better performance.
42   bool WaveLimiter;
43 
44 public:
45   AMDGPUMachineFunction(const MachineFunction &MF);
46 
47   uint64_t allocateKernArg(uint64_t Size, unsigned Align) {
48     assert(isPowerOf2_32(Align));
49     ExplicitKernArgSize = alignTo(ExplicitKernArgSize, Align);
50 
51     uint64_t Result = ExplicitKernArgSize;
52     ExplicitKernArgSize += Size;
53 
54     MaxKernArgAlign = std::max(Align, MaxKernArgAlign);
55     return Result;
56   }
57 
58   uint64_t getExplicitKernArgSize() const {
59     return ExplicitKernArgSize;
60   }
61 
62   unsigned getMaxKernArgAlign() const {
63     return MaxKernArgAlign;
64   }
65 
66   unsigned getLDSSize() const {
67     return LDSSize;
68   }
69 
70   bool isEntryFunction() const {
71     return IsEntryFunction;
72   }
73 
74   bool hasNoSignedZerosFPMath() const {
75     return NoSignedZerosFPMath;
76   }
77 
78   bool isMemoryBound() const {
79     return MemoryBound;
80   }
81 
82   bool needsWaveLimiter() const {
83     return WaveLimiter;
84   }
85 
86   unsigned allocateLDSGlobal(const DataLayout &DL, const GlobalValue &GV);
87 };
88 
89 }
90 #endif
91