LLVM: lib/Target/DirectX/DXILResource.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
21
22using namespace llvm;
24
26 NamedMDNode *Entry = M.getNamedMetadata(MDName);
27 if (!Entry || Entry->getNumOperands() == 0)
28 return;
29
31 for (auto *Res : Entry->operands()) {
33 }
34}
35
37 NamedMDNode *Entry = M.getNamedMetadata(MDName);
38 if (!Entry || Entry->getNumOperands() == 0)
39 return;
40
42 for (auto *Res : Entry->operands()) {
43 Data.push_back(
45 }
46
47
49 for (auto &CB : Data)
50 CB.setSize(CBDL);
51}
52
54 UAVs.collect(M);
55 CBuffers.collect(M);
56}
57
60 LowerBound(R.getResourceIndex()), RangeSize(1) {
61 if (auto *ArrTy = dyn_cast(GV->getValueType()))
62 RangeSize = ArrTy->getNumElements();
63}
64
66 switch (ElTy) {
68 return "invalid";
70 return "i1";
72 return "i16";
74 return "u16";
76 return "i32";
78 return "u32";
80 return "i64";
82 return "u64";
84 return "f16";
86 return "f32";
88 return "f64";
90 return "snorm_f16";
92 return "unorm_f16";
94 return "snorm_f32";
96 return "unorm_f32";
98 return "snorm_f64";
100 return "unorm_f64";
102 return "p32i8";
104 return "p32u8";
106 llvm_unreachable("All ElementType enums are handled in switch");
111 switch (Kind) {
112 default:
113
115 break;
118 break;
121 break;
125 break;
128 break;
129 }
130}
131
133 switch (Kind) {
136 return "invalid";
138 return "1d";
140 return "2d";
142 return "2dMS";
144 return "3d";
146 return "cube";
148 return "1darray";
150 return "2darray";
152 return "2darrayMS";
154 return "cubearray";
156 return "buf";
158 return "rawbuf";
160 return "structbuf";
162 return "cbuffer";
164 return "sampler";
166 return "tbuffer";
168 return "ras";
170 return "fbtex2d";
172 return "fbtex2darray";
173 }
174 llvm_unreachable("All ResourceKind enums are handled in switch");
175}
176
180 switch (Kind) {
181 default:
183 break;
184
189 else {
190 if (!HasCounter)
192 else
194 }
195 break;
198 break;
202 if (SampleCount)
203 DimName += std::to_string(SampleCount);
205 } break;
209 break;
212 break;
213 }
214}
215
218 std::string ResID = IDPrefix.str();
219 ResID += std::to_string(ID);
221
222 std::string Bind = BindingPrefix.str();
225 Bind += ",space" + std::to_string(Space);
226
230 else
232}
233
236
238
240 8, OS);
241
242
243
244 printKind(Shape, 12, OS, false, HasCounter);
245
247}
248
251
253 CBufferSizeInBytes = DL.getTypeAllocSizeInBytes(GV->getValueType());
254}
255
258
260
262
264
266}
267
269 for (auto &Res : Data)
270 Res.print(OS);
271}
272
277 Entries.emplace_back(
281 }
282 if (Entries.empty())
283 return nullptr;
285}
286
296}
297
303 Entries[6] =
308 Entries[10] = ExtProps.write(Ctx);
310}
311
317
320}
321
323 if (Data.empty())
324 return nullptr;
326 for (auto &Res : Data)
328
329 NamedMDNode *Entry = M.getNamedMetadata(MDName);
330 if (Entry)
331 Entry->eraseFromParent();
332
334}
335
339 return CBuffers.write(M);
340}
342
344 printCBuffers(dbgs());
345 printUAVs(dbgs());
346}
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Module.h This file contains the declarations for the Module class.
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
static GlobalVariable * getGlobalVariable(Module &M, Type *Ty, WebAssemblyTargetMachine &TM, const char *Name)
Type * getValueType() const
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
This is an important class for using LLVM in a threaded context.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
static MDString * get(LLVMContext &Context, StringRef Str)
A Module instance is used to store all the information related to an LLVM module.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
reference emplace_back(ArgTypes &&... Args)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
std::string str() const
str - Get the contents as an std::string.
LLVMContext & getContext() const
All values hold a context through their type.
ConstantBuffer(uint32_t I, hlsl::FrontendResource R)
void setSize(CBufferDataLayout &DL)
void print(raw_ostream &O) const
static StringRef getElementTypeName(dxil::ElementType CompType)
void print(raw_ostream &O, StringRef IDPrefix, StringRef BindingPrefix) const
ResourceBase(uint32_t I, hlsl::FrontendResource R)
static void printElementType(dxil::ResourceKind Kind, dxil::ElementType CompType, unsigned Alignment, raw_ostream &OS)
static void printKind(dxil::ResourceKind Kind, unsigned Alignment, raw_ostream &OS, bool SRV=false, bool HasCounter=false, uint32_t SampleCount=0)
static StringRef getKindName(dxil::ResourceKind Kind)
void write(LLVMContext &Ctx, MutableArrayRef< Metadata * > Entries) const
void print(raw_ostream &O) const
MDNode * write(Module &M) const
LLVM_DUMP_METHOD void dump() const
Metadata * writeUAVs(Module &M) const
Metadata * writeCBuffers(Module &M) const
void printUAVs(raw_ostream &OS) const
void printCBuffers(raw_ostream &OS) const
void print(raw_ostream &O) const
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
ResourceKind
The kind of resource for an SRV or UAV resource.
@ RTAccelerationStructure
ElementType
The element type of an SRV or UAV resource.
This is an optimization pass for GlobalISel generic memory operations.
FormattedString right_justify(StringRef Str, unsigned Width)
right_justify - add spaces before string so total output is Width characters.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FormattedString left_justify(StringRef Str, unsigned Width)
left_justify - append spaces after string so total output is Width characters.
MDNode * write(LLVMContext &Ctx) const
std::optional< dxil::ElementType > ElementType