LLVM 20.0.0git
AMDGPUArgumentUsageInfo.h
Go to the documentation of this file.
1//==- AMDGPUArgumentrUsageInfo.h - Function Arg Usage Info -------*- 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
9#ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUARGUMENTUSAGEINFO_H
10#define LLVM_LIB_TARGET_AMDGPU_AMDGPUARGUMENTUSAGEINFO_H
11
13#include "llvm/ADT/DenseMap.h"
15#include "llvm/Pass.h"
16
17namespace llvm {
18
19class Function;
20class LLT;
21class raw_ostream;
22class TargetRegisterClass;
23class TargetRegisterInfo;
24
26private:
27 friend struct AMDGPUFunctionArgInfo;
29
30 union {
32 unsigned StackOffset;
33 };
34
35 // Bitmask to locate argument within the register.
36 unsigned Mask;
37
38 bool IsStack : 1;
39 bool IsSet : 1;
40
41public:
42 ArgDescriptor(unsigned Val = 0, unsigned Mask = ~0u, bool IsStack = false,
43 bool IsSet = false)
44 : Reg(Val), Mask(Mask), IsStack(IsStack), IsSet(IsSet) {}
45
46 static ArgDescriptor createRegister(Register Reg, unsigned Mask = ~0u) {
47 return ArgDescriptor(Reg, Mask, false, true);
48 }
49
50 static ArgDescriptor createStack(unsigned Offset, unsigned Mask = ~0u) {
51 return ArgDescriptor(Offset, Mask, true, true);
52 }
53
54 static ArgDescriptor createArg(const ArgDescriptor &Arg, unsigned Mask) {
55 return ArgDescriptor(Arg.Reg, Mask, Arg.IsStack, Arg.IsSet);
56 }
57
58 bool isSet() const {
59 return IsSet;
60 }
61
62 explicit operator bool() const {
63 return isSet();
64 }
65
66 bool isRegister() const {
67 return !IsStack;
68 }
69
71 assert(!IsStack);
72 return Reg;
73 }
74
75 unsigned getStackOffset() const {
76 assert(IsStack);
77 return StackOffset;
78 }
79
80 unsigned getMask() const {
81 // None of the target SGPRs or VGPRs are expected to have a 'zero' mask.
82 assert(Mask && "Invalid mask.");
83 return Mask;
84 }
85
86 bool isMasked() const {
87 return Mask != ~0u;
88 }
89
90 void print(raw_ostream &OS, const TargetRegisterInfo *TRI = nullptr) const;
91};
92
94 Arg.print(OS);
95 return OS;
96}
97
101};
102
104 // clang-format off
106 // SGPRS:
113 LDS_KERNEL_ID = 6, // LLVM internal, not part of the ABI
121
122 // VGPRS:
127 };
128 // clang-format on
129
130 // Kernel input registers setup for the HSA ABI in allocation order.
131
132 // User SGPRs in kernels
133 // XXX - Can these require argument spills?
142
143 // System SGPRs in kernels.
149
150 // Pointer with offset from kernargsegmentptr to where special ABI arguments
151 // are passed to callable functions.
153
154 // Input registers for non-HSA ABI
156
157 // VGPRs inputs. For entry functions these are either v0, v1 and v2 or packed
158 // into v0, 10 bits per dimension if packed-tid is set.
162
163 // Map the index of preloaded kernel arguments to its descriptor.
165 // The first user SGPR allocated for kernarg preloading.
167
168 std::tuple<const ArgDescriptor *, const TargetRegisterClass *, LLT>
170
172};
173
175private:
177
178public:
179 static char ID;
180
183
185
186 void getAnalysisUsage(AnalysisUsage &AU) const override {
187 AU.setPreservesAll();
188 }
189
190 bool doInitialization(Module &M) override;
191 bool doFinalization(Module &M) override;
192
193 void print(raw_ostream &OS, const Module *M = nullptr) const override;
194
196 ArgInfoMap[&F] = ArgInfo;
197 }
198
200};
201
202} // end namespace llvm
203
204#endif
Provides AMDGPU specific target descriptions.
This file defines the DenseMap class.
#define F(x, y, z)
Definition: MD5.cpp:55
unsigned const TargetRegisterInfo * TRI
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
static const AMDGPUFunctionArgInfo ExternFunctionInfo
static const AMDGPUFunctionArgInfo FixedABIFunctionInfo
const AMDGPUFunctionArgInfo & lookupFuncArgInfo(const Function &F) const
void setFuncArgInfo(const Function &F, const AMDGPUFunctionArgInfo &ArgInfo)
void print(raw_ostream &OS, const Module *M=nullptr) const override
print - Print out the internal state of the pass.
bool doInitialization(Module &M) override
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
bool doFinalization(Module &M) override
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes...
Represent the analysis usage information of a pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
ImmutablePass class - This class is used to provide information that does not need to be run.
Definition: Pass.h:281
Wrapper class representing physical registers. Should be passed by value.
Definition: MCRegister.h:33
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
LLVM Value Representation.
Definition: Value.h:74
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:480
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:303
SmallDenseMap< int, KernArgPreloadDescriptor > PreloadKernArgs
static AMDGPUFunctionArgInfo fixedABILayout()
std::tuple< const ArgDescriptor *, const TargetRegisterClass *, LLT > getPreloadedValue(PreloadedValue Value) const
static ArgDescriptor createStack(unsigned Offset, unsigned Mask=~0u)
MCRegister getRegister() const
static ArgDescriptor createArg(const ArgDescriptor &Arg, unsigned Mask)
void print(raw_ostream &OS, const TargetRegisterInfo *TRI=nullptr) const
static ArgDescriptor createRegister(Register Reg, unsigned Mask=~0u)
unsigned getStackOffset() const
ArgDescriptor(unsigned Val=0, unsigned Mask=~0u, bool IsStack=false, bool IsSet=false)
Helper struct shared between Function Specialization and SCCP Solver.
Definition: SCCPSolver.h:41