LLVM  14.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 
12 #include "llvm/CodeGen/Register.h"
13 #include "llvm/Pass.h"
14 
15 namespace llvm {
16 
17 class Function;
18 class LLT;
19 class raw_ostream;
20 class TargetRegisterClass;
21 class TargetRegisterInfo;
22 
23 struct ArgDescriptor {
24 private:
25  friend struct AMDGPUFunctionArgInfo;
27 
28  union {
30  unsigned StackOffset;
31  };
32 
33  // Bitmask to locate argument within the register.
34  unsigned Mask;
35 
36  bool IsStack : 1;
37  bool IsSet : 1;
38 
39 public:
40  constexpr ArgDescriptor(unsigned Val = 0, unsigned Mask = ~0u,
41  bool IsStack = false, bool IsSet = false)
42  : Reg(Val), Mask(Mask), IsStack(IsStack), IsSet(IsSet) {}
43 
45  unsigned Mask = ~0u) {
46  return ArgDescriptor(Reg, Mask, false, true);
47  }
48 
49  static constexpr ArgDescriptor createStack(unsigned Offset,
50  unsigned Mask = ~0u) {
51  return ArgDescriptor(Offset, Mask, true, true);
52  }
53 
54  static constexpr ArgDescriptor createArg(const ArgDescriptor &Arg,
55  unsigned Mask) {
56  return ArgDescriptor(Arg.Reg, Mask, Arg.IsStack, Arg.IsSet);
57  }
58 
59  bool isSet() const {
60  return IsSet;
61  }
62 
63  explicit operator bool() const {
64  return isSet();
65  }
66 
67  bool isRegister() const {
68  return !IsStack;
69  }
70 
72  assert(!IsStack);
73  return Reg;
74  }
75 
76  unsigned getStackOffset() const {
77  assert(IsStack);
78  return StackOffset;
79  }
80 
81  unsigned getMask() const {
82  return Mask;
83  }
84 
85  bool isMasked() const {
86  return Mask != ~0u;
87  }
88 
89  void print(raw_ostream &OS, const TargetRegisterInfo *TRI = nullptr) const;
90 };
91 
93  Arg.print(OS);
94  return OS;
95 }
96 
99  // SGPRS:
112 
113  // VGPRS:
118  };
119 
120  // Kernel input registers setup for the HSA ABI in allocation order.
121 
122  // User SGPRs in kernels
123  // XXX - Can these require argument spills?
131 
132  // System SGPRs in kernels.
138 
139  // Pointer with offset from kernargsegmentptr to where special ABI arguments
140  // are passed to callable functions.
142 
143  // Input registers for non-HSA ABI
145 
146  // VGPRs inputs. For entry functions these are either v0, v1 and v2 or packed
147  // into v0, 10 bits per dimension if packed-tid is set.
151 
152  std::tuple<const ArgDescriptor *, const TargetRegisterClass *, LLT>
154 
155  static constexpr AMDGPUFunctionArgInfo fixedABILayout();
156 };
157 
159 private:
161 
162 public:
163  static char ID;
164 
167 
169 
170  void getAnalysisUsage(AnalysisUsage &AU) const override {
171  AU.setPreservesAll();
172  }
173 
174  bool doInitialization(Module &M) override;
175  bool doFinalization(Module &M) override;
176 
177  void print(raw_ostream &OS, const Module *M = nullptr) const override;
178 
179  void setFuncArgInfo(const Function &F, const AMDGPUFunctionArgInfo &ArgInfo) {
180  ArgInfoMap[&F] = ArgInfo;
181  }
182 
183  const AMDGPUFunctionArgInfo &lookupFuncArgInfo(const Function &F) const;
184 };
185 
186 } // end namespace llvm
187 
188 #endif
llvm::AMDGPUFunctionArgInfo::PreloadedValue
PreloadedValue
Definition: AMDGPUArgumentUsageInfo.h:98
llvm::AMDGPUFunctionArgInfo::QUEUE_PTR
@ QUEUE_PTR
Definition: AMDGPUArgumentUsageInfo.h:102
llvm::ArgDescriptor::createStack
static constexpr ArgDescriptor createStack(unsigned Offset, unsigned Mask=~0u)
Definition: AMDGPUArgumentUsageInfo.h:49
llvm::AMDGPUFunctionArgInfo::QueuePtr
ArgDescriptor QueuePtr
Definition: AMDGPUArgumentUsageInfo.h:126
llvm::AMDGPUFunctionArgInfo::FLAT_SCRATCH_INIT
@ FLAT_SCRATCH_INIT
Definition: AMDGPUArgumentUsageInfo.h:105
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::ImmutablePass
ImmutablePass class - This class is used to provide information that does not need to be run.
Definition: Pass.h:269
llvm::ArgDescriptor::createArg
static constexpr ArgDescriptor createArg(const ArgDescriptor &Arg, unsigned Mask)
Definition: AMDGPUArgumentUsageInfo.h:54
llvm::ArgDescriptor
Definition: AMDGPUArgumentUsageInfo.h:23
llvm::Function
Definition: Function.h:61
Pass.h
llvm::AMDGPUArgumentUsageInfo::FixedABIFunctionInfo
static const AMDGPUFunctionArgInfo FixedABIFunctionInfo
Definition: AMDGPUArgumentUsageInfo.h:166
llvm::AMDGPUFunctionArgInfo::FlatScratchInit
ArgDescriptor FlatScratchInit
Definition: AMDGPUArgumentUsageInfo.h:129
llvm::TargetRegisterInfo
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Definition: TargetRegisterInfo.h:231
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
llvm::AMDGPUFunctionArgInfo::PrivateSegmentSize
ArgDescriptor PrivateSegmentSize
Definition: AMDGPUArgumentUsageInfo.h:130
llvm::AMDGPUFunctionArgInfo::DispatchPtr
ArgDescriptor DispatchPtr
Definition: AMDGPUArgumentUsageInfo.h:125
TRI
unsigned const TargetRegisterInfo * TRI
Definition: MachineSink.cpp:1567
llvm::AMDGPUFunctionArgInfo::WORKGROUP_ID_X
@ WORKGROUP_ID_X
Definition: AMDGPUArgumentUsageInfo.h:106
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::AMDGPUFunctionArgInfo::DispatchID
ArgDescriptor DispatchID
Definition: AMDGPUArgumentUsageInfo.h:128
llvm::ArgDescriptor::print
void print(raw_ostream &OS, const TargetRegisterInfo *TRI=nullptr) const
llvm::AMDGPUFunctionArgInfo::ImplicitArgPtr
ArgDescriptor ImplicitArgPtr
Definition: AMDGPUArgumentUsageInfo.h:141
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition: AMDGPULibCalls.cpp:206
llvm::AMDGPUFunctionArgInfo::WorkGroupIDX
ArgDescriptor WorkGroupIDX
Definition: AMDGPUArgumentUsageInfo.h:133
llvm::ArgDescriptor::isSet
bool isSet() const
Definition: AMDGPUArgumentUsageInfo.h:59
llvm::AMDGPUFunctionArgInfo::KERNARG_SEGMENT_PTR
@ KERNARG_SEGMENT_PTR
Definition: AMDGPUArgumentUsageInfo.h:103
llvm::AMDGPUFunctionArgInfo
Definition: AMDGPUArgumentUsageInfo.h:97
llvm::ArgDescriptor::getMask
unsigned getMask() const
Definition: AMDGPUArgumentUsageInfo.h:81
llvm::AMDGPUArgumentUsageInfo::lookupFuncArgInfo
const AMDGPUFunctionArgInfo & lookupFuncArgInfo(const Function &F) const
Definition: AMDGPUArgumentUsageInfo.cpp:174
llvm::AMDGPUFunctionArgInfo::IMPLICIT_ARG_PTR
@ IMPLICIT_ARG_PTR
Definition: AMDGPUArgumentUsageInfo.h:111
llvm::AMDGPUFunctionArgInfo::IMPLICIT_BUFFER_PTR
@ IMPLICIT_BUFFER_PTR
Definition: AMDGPUArgumentUsageInfo.h:110
llvm::AMDGPUFunctionArgInfo::FIRST_VGPR_VALUE
@ FIRST_VGPR_VALUE
Definition: AMDGPUArgumentUsageInfo.h:117
llvm::AMDGPUFunctionArgInfo::WorkItemIDX
ArgDescriptor WorkItemIDX
Definition: AMDGPUArgumentUsageInfo.h:148
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition: PassAnalysisSupport.h:47
llvm::AMDGPUArgumentUsageInfo::doInitialization
bool doInitialization(Module &M) override
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
Definition: AMDGPUArgumentUsageInfo.cpp:54
llvm::AMDGPUFunctionArgInfo::WORKITEM_ID_Y
@ WORKITEM_ID_Y
Definition: AMDGPUArgumentUsageInfo.h:115
llvm::AMDGPUArgumentUsageInfo::ID
static char ID
Definition: AMDGPUArgumentUsageInfo.h:163
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::operator<<
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
Definition: APFixedPoint.h:230
llvm::AMDGPUFunctionArgInfo::getPreloadedValue
std::tuple< const ArgDescriptor *, const TargetRegisterClass *, LLT > getPreloadedValue(PreloadedValue Value) const
Definition: AMDGPUArgumentUsageInfo.cpp:89
llvm::AMDGPUFunctionArgInfo::WORKGROUP_ID_Z
@ WORKGROUP_ID_Z
Definition: AMDGPUArgumentUsageInfo.h:108
llvm::AMDGPUFunctionArgInfo::WORKITEM_ID_Z
@ WORKITEM_ID_Z
Definition: AMDGPUArgumentUsageInfo.h:116
llvm::AMDGPUFunctionArgInfo::WorkGroupIDZ
ArgDescriptor WorkGroupIDZ
Definition: AMDGPUArgumentUsageInfo.h:135
llvm::AMDGPUFunctionArgInfo::PrivateSegmentBuffer
ArgDescriptor PrivateSegmentBuffer
Definition: AMDGPUArgumentUsageInfo.h:124
llvm::AMDGPUFunctionArgInfo::PRIVATE_SEGMENT_WAVE_BYTE_OFFSET
@ PRIVATE_SEGMENT_WAVE_BYTE_OFFSET
Definition: AMDGPUArgumentUsageInfo.h:109
llvm::AMDGPUFunctionArgInfo::WORKITEM_ID_X
@ WORKITEM_ID_X
Definition: AMDGPUArgumentUsageInfo.h:114
llvm::DenseMap
Definition: DenseMap.h:714
llvm::AMDGPUFunctionArgInfo::PrivateSegmentWaveByteOffset
ArgDescriptor PrivateSegmentWaveByteOffset
Definition: AMDGPUArgumentUsageInfo.h:137
llvm::AMDGPUArgumentUsageInfo
Definition: AMDGPUArgumentUsageInfo.h:158
llvm::AMDGPUFunctionArgInfo::WorkGroupIDY
ArgDescriptor WorkGroupIDY
Definition: AMDGPUArgumentUsageInfo.h:134
llvm::ArgDescriptor::getStackOffset
unsigned getStackOffset() const
Definition: AMDGPUArgumentUsageInfo.h:76
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::AMDGPUArgumentUsageInfo::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Definition: AMDGPUArgumentUsageInfo.h:170
llvm::AMDGPUFunctionArgInfo::WorkItemIDZ
ArgDescriptor WorkItemIDZ
Definition: AMDGPUArgumentUsageInfo.h:150
llvm::ArgDescriptor::isRegister
bool isRegister() const
Definition: AMDGPUArgumentUsageInfo.h:67
llvm::AMDGPUFunctionArgInfo::DISPATCH_ID
@ DISPATCH_ID
Definition: AMDGPUArgumentUsageInfo.h:104
llvm::ArgDescriptor::isMasked
bool isMasked() const
Definition: AMDGPUArgumentUsageInfo.h:85
llvm::AMDGPUFunctionArgInfo::ImplicitBufferPtr
ArgDescriptor ImplicitBufferPtr
Definition: AMDGPUArgumentUsageInfo.h:144
llvm::AMDGPUArgumentUsageInfo::print
void print(raw_ostream &OS, const Module *M=nullptr) const override
print - Print out the internal state of the pass.
Definition: AMDGPUArgumentUsageInfo.cpp:63
llvm::AMDGPUArgumentUsageInfo::setFuncArgInfo
void setFuncArgInfo(const Function &F, const AMDGPUFunctionArgInfo &ArgInfo)
Definition: AMDGPUArgumentUsageInfo.h:179
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
llvm::AMDGPUFunctionArgInfo::WorkGroupInfo
ArgDescriptor WorkGroupInfo
Definition: AMDGPUArgumentUsageInfo.h:136
llvm::ArgDescriptor::Reg
MCRegister Reg
Definition: AMDGPUArgumentUsageInfo.h:29
llvm::AMDGPUFunctionArgInfo::WORKGROUP_ID_Y
@ WORKGROUP_ID_Y
Definition: AMDGPUArgumentUsageInfo.h:107
llvm::AnalysisUsage::setPreservesAll
void setPreservesAll()
Set by analyses that do not transform their input at all.
Definition: PassAnalysisSupport.h:130
llvm::ArgDescriptor::StackOffset
unsigned StackOffset
Definition: AMDGPUArgumentUsageInfo.h:30
llvm::ArgDescriptor::createRegister
static constexpr ArgDescriptor createRegister(Register Reg, unsigned Mask=~0u)
Definition: AMDGPUArgumentUsageInfo.h:44
llvm::AMDGPUFunctionArgInfo::KernargSegmentPtr
ArgDescriptor KernargSegmentPtr
Definition: AMDGPUArgumentUsageInfo.h:127
llvm::AMDGPUFunctionArgInfo::DISPATCH_PTR
@ DISPATCH_PTR
Definition: AMDGPUArgumentUsageInfo.h:101
llvm::AMDGPUFunctionArgInfo::WorkItemIDY
ArgDescriptor WorkItemIDY
Definition: AMDGPUArgumentUsageInfo.h:149
llvm::AMDGPUArgumentUsageInfo::doFinalization
bool doFinalization(Module &M) override
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes...
Definition: AMDGPUArgumentUsageInfo.cpp:58
llvm::ArgDescriptor::getRegister
MCRegister getRegister() const
Definition: AMDGPUArgumentUsageInfo.h:71
llvm::AMDGPUArgumentUsageInfo::ExternFunctionInfo
static const AMDGPUFunctionArgInfo ExternFunctionInfo
Definition: AMDGPUArgumentUsageInfo.h:165
llvm::AMDGPUFunctionArgInfo::PRIVATE_SEGMENT_BUFFER
@ PRIVATE_SEGMENT_BUFFER
Definition: AMDGPUArgumentUsageInfo.h:100
llvm::ArgDescriptor::ArgDescriptor
constexpr ArgDescriptor(unsigned Val=0, unsigned Mask=~0u, bool IsStack=false, bool IsSet=false)
Definition: AMDGPUArgumentUsageInfo.h:40
Register.h
llvm::AMDGPUFunctionArgInfo::fixedABILayout
static constexpr AMDGPUFunctionArgInfo fixedABILayout()
Definition: AMDGPUArgumentUsageInfo.cpp:149
llvm::Value
LLVM Value Representation.
Definition: Value.h:75
llvm::AMDGPUArgumentUsageInfo::AMDGPUArgumentUsageInfo
AMDGPUArgumentUsageInfo()
Definition: AMDGPUArgumentUsageInfo.h:168
llvm::codeview::PublicSymFlags::Function
@ Function
llvm::MCRegister
Wrapper class representing physical registers. Should be passed by value.
Definition: MCRegister.h:23