LLVM 22.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#include <variant>
17
18namespace llvm {
19
20class Function;
21class LLT;
22class raw_ostream;
25
27private:
28 friend struct AMDGPUFunctionArgInfo;
30
31 std::variant<std::monostate, MCRegister, unsigned> Val;
32
33 // Bitmask to locate argument within the register.
34 unsigned Mask;
35
36public:
37 ArgDescriptor(unsigned Mask = ~0u) : Mask(Mask) {}
38
39 static ArgDescriptor createRegister(Register Reg, unsigned Mask = ~0u) {
40 ArgDescriptor Ret(Mask);
41 Ret.Val = Reg.asMCReg();
42 return Ret;
43 }
44
45 static ArgDescriptor createStack(unsigned Offset, unsigned Mask = ~0u) {
46 ArgDescriptor Ret(Mask);
47 Ret.Val = Offset;
48 return Ret;
49 }
50
51 static ArgDescriptor createArg(const ArgDescriptor &Arg, unsigned Mask) {
52 // Copy the descriptor, then change the mask.
53 ArgDescriptor Ret(Arg);
54 Ret.Mask = Mask;
55 return Ret;
56 }
57
58 bool isSet() const { return !std::holds_alternative<std::monostate>(Val); }
59
60 explicit operator bool() const {
61 return isSet();
62 }
63
64 bool isRegister() const { return std::holds_alternative<MCRegister>(Val); }
65
66 MCRegister getRegister() const { return std::get<MCRegister>(Val); }
67
68 unsigned getStackOffset() const { return std::get<unsigned>(Val); }
69
70 unsigned getMask() const {
71 // None of the target SGPRs or VGPRs are expected to have a 'zero' mask.
72 assert(Mask && "Invalid mask.");
73 return Mask;
74 }
75
76 bool isMasked() const {
77 return Mask != ~0u;
78 }
79
80 void print(raw_ostream &OS, const TargetRegisterInfo *TRI = nullptr) const;
81};
82
84 Arg.print(OS);
85 return OS;
86}
87
92
94 // clang-format off
125 // clang-format on
126
127 // Kernel input registers setup for the HSA ABI in allocation order.
128
129 // User SGPRs in kernels
130 // XXX - Can these require argument spills?
139
140 // System SGPRs in kernels.
146
147 // Pointer with offset from kernargsegmentptr to where special ABI arguments
148 // are passed to callable functions.
150
151 // Input registers for non-HSA ABI
153
154 // VGPRs inputs. For entry functions these are either v0, v1 and v2 or packed
155 // into v0, 10 bits per dimension if packed-tid is set.
159
160 // Map the index of preloaded kernel arguments to its descriptor.
162 // The first user SGPR allocated for kernarg preloading.
164
165 std::tuple<const ArgDescriptor *, const TargetRegisterClass *, LLT>
167
169};
170
172private:
174
175public:
176 static char ID;
177
180
182
183 void getAnalysisUsage(AnalysisUsage &AU) const override {
184 AU.setPreservesAll();
185 }
186
187 bool doInitialization(Module &M) override;
188 bool doFinalization(Module &M) override;
189
190 void print(raw_ostream &OS, const Module *M = nullptr) const override;
191
193 ArgInfoMap[&F] = ArgInfo;
194 }
195
197};
198
199} // end namespace llvm
200
201#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Provides AMDGPU specific target descriptions.
This file defines the DenseMap class.
#define F(x, y, z)
Definition MD5.cpp:54
Register Reg
Register const TargetRegisterInfo * TRI
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(char &pid)
Definition Pass.h:287
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:41
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
Wrapper class representing virtual and physical registers.
Definition Register.h:20
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
LLVM Value Representation.
Definition Value.h:75
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:532
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
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)
ArgDescriptor(unsigned Mask=~0u)
void print(raw_ostream &OS, const TargetRegisterInfo *TRI=nullptr) const
static ArgDescriptor createRegister(Register Reg, unsigned Mask=~0u)
unsigned getStackOffset() const
Helper struct shared between Function Specialization and SCCP Solver.
Definition SCCPSolver.h:42