LLVM 23.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
14#include <variant>
15
16namespace llvm {
17
18class LLT;
19class raw_ostream;
22
24private:
25 friend struct AMDGPUFunctionArgInfo;
26
27 std::variant<std::monostate, MCRegister, unsigned> Val;
28
29 // Bitmask to locate argument within the register.
30 unsigned Mask;
31
32public:
33 ArgDescriptor(unsigned Mask = ~0u) : Mask(Mask) {}
34
35 static ArgDescriptor createRegister(Register Reg, unsigned Mask = ~0u) {
36 ArgDescriptor Ret(Mask);
37 Ret.Val = Reg.asMCReg();
38 return Ret;
39 }
40
41 static ArgDescriptor createStack(unsigned Offset, unsigned Mask = ~0u) {
42 ArgDescriptor Ret(Mask);
43 Ret.Val = Offset;
44 return Ret;
45 }
46
47 static ArgDescriptor createArg(const ArgDescriptor &Arg, unsigned Mask) {
48 // Copy the descriptor, then change the mask.
49 ArgDescriptor Ret(Arg);
50 Ret.Mask = Mask;
51 return Ret;
52 }
53
54 bool isSet() const { return !std::holds_alternative<std::monostate>(Val); }
55
56 explicit operator bool() const {
57 return isSet();
58 }
59
60 bool isRegister() const { return std::holds_alternative<MCRegister>(Val); }
61
62 MCRegister getRegister() const { return std::get<MCRegister>(Val); }
63
64 unsigned getStackOffset() const { return std::get<unsigned>(Val); }
65
66 unsigned getMask() const {
67 // None of the target SGPRs or VGPRs are expected to have a 'zero' mask.
68 assert(Mask && "Invalid mask.");
69 return Mask;
70 }
71
72 bool isMasked() const {
73 return Mask != ~0u;
74 }
75
76 void print(raw_ostream &OS, const TargetRegisterInfo *TRI = nullptr) const;
77};
78
80 Arg.print(OS);
81 return OS;
82}
83
88
90 // clang-format off
121 // clang-format on
122
123 // Kernel input registers setup for the HSA ABI in allocation order.
124
125 // User SGPRs in kernels
126 // XXX - Can these require argument spills?
135
136 // System SGPRs in kernels.
142
143 // Pointer with offset from kernargsegmentptr to where special ABI arguments
144 // are passed to callable functions.
146
147 // Input registers for non-HSA ABI
149
150 // VGPRs inputs. For entry functions these are either v0, v1 and v2 or packed
151 // into v0, 10 bits per dimension if packed-tid is set.
155
156 // Map the index of preloaded kernel arguments to its descriptor.
158 // The first user SGPR allocated for kernarg preloading.
160
161 std::tuple<const ArgDescriptor *, const TargetRegisterClass *, LLT>
163
166};
167
168} // end namespace llvm
169
170#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Provides AMDGPU specific target descriptions.
Register Reg
Register const TargetRegisterInfo * TRI
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:41
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.
Definition Types.h:26
@ 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 const AMDGPUFunctionArgInfo FixedABIFunctionInfo
static ArgDescriptor createStack(unsigned Offset, unsigned Mask=~0u)
MCRegister getRegister() const
static ArgDescriptor createArg(const ArgDescriptor &Arg, unsigned Mask)
ArgDescriptor(unsigned Mask=~0u)
static ArgDescriptor createRegister(Register Reg, unsigned Mask=~0u)
unsigned getStackOffset() const
void print(raw_ostream &OS, const TargetRegisterInfo *TRI=nullptr) const