LLVM 24.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 "llvm/IR/CallingConv.h"
15#include <variant>
16
17namespace llvm {
18
19class LLT;
20class raw_ostream;
21class MCRegisterClass;
24
26private:
27 friend struct AMDGPUFunctionArgInfo;
28
29 std::variant<std::monostate, MCRegister, unsigned> Val;
30
31 // Bitmask to locate argument within the register.
32 unsigned Mask;
33
34public:
35 ArgDescriptor(unsigned Mask = ~0u) : Mask(Mask) {}
36
37 static ArgDescriptor createRegister(Register Reg, unsigned Mask = ~0u) {
38 ArgDescriptor Ret(Mask);
39 Ret.Val = Reg.asMCReg();
40 return Ret;
41 }
42
43 static ArgDescriptor createStack(unsigned Offset, unsigned Mask = ~0u) {
44 ArgDescriptor Ret(Mask);
45 Ret.Val = Offset;
46 return Ret;
47 }
48
49 static ArgDescriptor createArg(const ArgDescriptor &Arg, unsigned Mask) {
50 // Copy the descriptor, then change the mask.
51 ArgDescriptor Ret(Arg);
52 Ret.Mask = Mask;
53 return Ret;
54 }
55
56 bool isSet() const { return !std::holds_alternative<std::monostate>(Val); }
57
58 explicit operator bool() const {
59 return isSet();
60 }
61
62 bool isRegister() const { return std::holds_alternative<MCRegister>(Val); }
63
64 MCRegister getRegister() const { return std::get<MCRegister>(Val); }
65
66 unsigned getStackOffset() const { return std::get<unsigned>(Val); }
67
68 unsigned getMask() const {
69 // None of the target SGPRs or VGPRs are expected to have a 'zero' mask.
70 assert(Mask && "Invalid mask.");
71 return Mask;
72 }
73
74 bool isMasked() const {
75 return Mask != ~0u;
76 }
77
78 void print(raw_ostream &OS, const TargetRegisterInfo *TRI = nullptr) const;
79};
80
82 Arg.print(OS);
83 return OS;
84}
85
90
92 // clang-format off
123 // clang-format on
124
125 // Kernel input registers setup for the HSA ABI in allocation order.
126
127 // User SGPRs in kernels
128 // XXX - Can these require argument spills?
137
138 // System SGPRs in kernels.
144
145 // Pointer with offset from kernargsegmentptr to where special ABI arguments
146 // are passed to callable functions.
148
149 // Input registers for non-HSA ABI
151
152 // VGPRs inputs. For entry functions these are either v0, v1 and v2 or packed
153 // into v0, 10 bits per dimension if packed-tid is set.
157
158 // Map the index of preloaded kernel arguments to its descriptor.
160 // The first user SGPR allocated for kernarg preloading.
162
163 std::tuple<const ArgDescriptor *, const TargetRegisterClass *, LLT>
165
166 /// Returns the register a non-entry function with calling convention \p CC
167 /// expects the private segment buffer in.
169
172};
173
174} // end namespace llvm
175
176#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
Provides AMDGPU specific target descriptions.
Register Reg
Register const TargetRegisterInfo * TRI
RISCVCC::CondCode CC
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
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
This is an optimization pass for GlobalISel generic memory operations.
@ Offset
Definition DWP.cpp:577
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 MCRegister getPrivateSegmentBufferReg(CallingConv::ID CC)
Returns the register a non-entry function with calling convention CC expects the private segment buff...
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