xref: /aosp_15_r20/external/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.h (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker //===-- AMDGPUMachineFunctionInfo.h -------------------------------*- C++ -*-=//
2*9880d681SAndroid Build Coastguard Worker //
3*9880d681SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker //
5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker //
8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker 
10*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUMACHINEFUNCTION_H
11*9880d681SAndroid Build Coastguard Worker #define LLVM_LIB_TARGET_AMDGPU_AMDGPUMACHINEFUNCTION_H
12*9880d681SAndroid Build Coastguard Worker 
13*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/MachineFunction.h"
14*9880d681SAndroid Build Coastguard Worker #include <map>
15*9880d681SAndroid Build Coastguard Worker 
16*9880d681SAndroid Build Coastguard Worker namespace llvm {
17*9880d681SAndroid Build Coastguard Worker 
18*9880d681SAndroid Build Coastguard Worker class AMDGPUMachineFunction : public MachineFunctionInfo {
19*9880d681SAndroid Build Coastguard Worker   uint64_t KernArgSize;
20*9880d681SAndroid Build Coastguard Worker   unsigned MaxKernArgAlign;
21*9880d681SAndroid Build Coastguard Worker 
22*9880d681SAndroid Build Coastguard Worker   virtual void anchor();
23*9880d681SAndroid Build Coastguard Worker 
24*9880d681SAndroid Build Coastguard Worker public:
25*9880d681SAndroid Build Coastguard Worker   AMDGPUMachineFunction(const MachineFunction &MF);
26*9880d681SAndroid Build Coastguard Worker 
allocateKernArg(uint64_t Size,unsigned Align)27*9880d681SAndroid Build Coastguard Worker   uint64_t allocateKernArg(uint64_t Size, unsigned Align) {
28*9880d681SAndroid Build Coastguard Worker     assert(isPowerOf2_32(Align));
29*9880d681SAndroid Build Coastguard Worker     KernArgSize = alignTo(KernArgSize, Align);
30*9880d681SAndroid Build Coastguard Worker 
31*9880d681SAndroid Build Coastguard Worker     uint64_t Result = KernArgSize;
32*9880d681SAndroid Build Coastguard Worker     KernArgSize += Size;
33*9880d681SAndroid Build Coastguard Worker 
34*9880d681SAndroid Build Coastguard Worker     MaxKernArgAlign = std::max(Align, MaxKernArgAlign);
35*9880d681SAndroid Build Coastguard Worker     return Result;
36*9880d681SAndroid Build Coastguard Worker   }
37*9880d681SAndroid Build Coastguard Worker 
38*9880d681SAndroid Build Coastguard Worker   /// A map to keep track of local memory objects and their offsets within
39*9880d681SAndroid Build Coastguard Worker   /// the local memory space.
40*9880d681SAndroid Build Coastguard Worker   std::map<const GlobalValue *, unsigned> LocalMemoryObjects;
41*9880d681SAndroid Build Coastguard Worker   /// Number of bytes in the LDS that are being used.
42*9880d681SAndroid Build Coastguard Worker   unsigned LDSSize;
43*9880d681SAndroid Build Coastguard Worker 
44*9880d681SAndroid Build Coastguard Worker   /// Start of implicit kernel args
45*9880d681SAndroid Build Coastguard Worker   unsigned ABIArgOffset;
46*9880d681SAndroid Build Coastguard Worker 
47*9880d681SAndroid Build Coastguard Worker   bool isKernel() const;
48*9880d681SAndroid Build Coastguard Worker 
49*9880d681SAndroid Build Coastguard Worker   unsigned ScratchSize;
50*9880d681SAndroid Build Coastguard Worker   bool IsKernel;
51*9880d681SAndroid Build Coastguard Worker };
52*9880d681SAndroid Build Coastguard Worker 
53*9880d681SAndroid Build Coastguard Worker }
54*9880d681SAndroid Build Coastguard Worker #endif
55