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 AMDGPUMachineFunction : public MachineFunctionInfo {
19   /// A map to keep track of local memory objects and their offsets within the
20   /// local memory space.
21   SmallDenseMap<const GlobalValue *, unsigned, 4> LocalMemoryObjects;
22 
23 protected:
24   uint64_t KernArgSize;
25   unsigned MaxKernArgAlign;
26 
27   /// Number of bytes in the LDS that are being used.
28   unsigned LDSSize;
29 
30   // FIXME: This should probably be removed.
31   /// Start of implicit kernel args
32   unsigned ABIArgOffset;
33 
34   // Kernels + shaders. i.e. functions called by the driver and not called
35   // by other functions.
36   bool IsEntryFunction;
37 
38   bool NoSignedZerosFPMath;
39 
40   // Function may be memory bound.
41   bool MemoryBound;
42 
43   // Kernel may need limited waves per EU for better performance.
44   bool WaveLimiter;
45 
46 public:
47   AMDGPUMachineFunction(const MachineFunction &MF);
48 
49   uint64_t allocateKernArg(uint64_t Size, unsigned Align) {
50     assert(isPowerOf2_32(Align));
51     KernArgSize = alignTo(KernArgSize, Align);
52 
53     uint64_t Result = KernArgSize;
54     KernArgSize += Size;
55 
56     MaxKernArgAlign = std::max(Align, MaxKernArgAlign);
57     return Result;
58   }
59 
60   uint64_t getKernArgSize() const {
61     return KernArgSize;
62   }
63 
64   unsigned getMaxKernArgAlign() const {
65     return MaxKernArgAlign;
66   }
67 
68   void setABIArgOffset(unsigned NewOffset) {
69     ABIArgOffset = NewOffset;
70   }
71 
72   unsigned getABIArgOffset() const {
73     return ABIArgOffset;
74   }
75 
76   unsigned getLDSSize() const {
77     return LDSSize;
78   }
79 
80   bool isEntryFunction() const {
81     return IsEntryFunction;
82   }
83 
84   bool hasNoSignedZerosFPMath() const {
85     return NoSignedZerosFPMath;
86   }
87 
88   bool isMemoryBound() const {
89     return MemoryBound;
90   }
91 
92   bool needsWaveLimiter() const {
93     return WaveLimiter;
94   }
95 
96   unsigned allocateLDSGlobal(const DataLayout &DL, const GlobalValue &GV);
97 };
98 
99 }
100 #endif
101