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