LLVM 22.0.0git
DXILResource.h
Go to the documentation of this file.
1//===- DXILResource.h - Representations of DXIL resources -------*- 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_ANALYSIS_DXILRESOURCE_H
10#define LLVM_ANALYSIS_DXILRESOURCE_H
11
12#include "llvm/ADT/MapVector.h"
14#include "llvm/ADT/StringRef.h"
18#include "llvm/IR/PassManager.h"
19#include "llvm/Pass.h"
23#include <cstdint>
24
25namespace llvm {
26class CallInst;
27class DataLayout;
28class LLVMContext;
29class MDTuple;
30class Value;
31
32class DXILResourceTypeMap;
33
34namespace dxil {
35
36// Returns the resource name from dx_resource_handlefrombinding or
37// dx_resource_handlefromimplicitbinding call
38LLVM_ABI StringRef getResourceNameFromBindingCall(CallInst *CI);
39
40/// The dx.RawBuffer target extension type
41///
42/// `target("dx.RawBuffer", Type, IsWriteable, IsROV)`
44public:
45 RawBufferExtType() = delete;
48
49 bool isStructured() const {
50 // TODO: We need to be more prescriptive here, but since there's some debate
51 // over whether byte address buffer should have a void type or an i8 type,
52 // accept either for now.
53 Type *Ty = getTypeParameter(0);
54 return !Ty->isVoidTy() && !Ty->isIntegerTy(8);
55 }
56
58 return isStructured() ? getTypeParameter(0) : nullptr;
59 }
60 bool isWriteable() const { return getIntParameter(0); }
61 bool isROV() const { return getIntParameter(1); }
62
63 static bool classof(const TargetExtType *T) {
64 return T->getName() == "dx.RawBuffer";
65 }
66 static bool classof(const Type *T) {
67 return isa<TargetExtType>(T) && classof(cast<TargetExtType>(T));
68 }
69};
70
71/// The dx.TypedBuffer target extension type
72///
73/// `target("dx.TypedBuffer", Type, IsWriteable, IsROV, IsSigned)`
75public:
79
80 Type *getResourceType() const { return getTypeParameter(0); }
81 bool isWriteable() const { return getIntParameter(0); }
82 bool isROV() const { return getIntParameter(1); }
83 bool isSigned() const { return getIntParameter(2); }
84
85 static bool classof(const TargetExtType *T) {
86 return T->getName() == "dx.TypedBuffer";
87 }
88 static bool classof(const Type *T) {
89 return isa<TargetExtType>(T) && classof(cast<TargetExtType>(T));
90 }
91};
92
93/// The dx.Texture target extension type
94///
95/// `target("dx.Texture", Type, IsWriteable, IsROV, IsSigned, Dimension)`
97public:
98 TextureExtType() = delete;
99 TextureExtType(const TextureExtType &) = delete;
101
102 Type *getResourceType() const { return getTypeParameter(0); }
103 bool isWriteable() const { return getIntParameter(0); }
104 bool isROV() const { return getIntParameter(1); }
105 bool isSigned() const { return getIntParameter(2); }
107 return static_cast<dxil::ResourceKind>(getIntParameter(3));
108 }
109
110 static bool classof(const TargetExtType *T) {
111 return T->getName() == "dx.Texture";
112 }
113 static bool classof(const Type *T) {
114 return isa<TargetExtType>(T) && classof(cast<TargetExtType>(T));
115 }
116};
117
118/// The dx.MSTexture target extension type
119///
120/// `target("dx.MSTexture", Type, IsWriteable, Samples, IsSigned, Dimension)`
122public:
126
127 Type *getResourceType() const { return getTypeParameter(0); }
128 bool isWriteable() const { return getIntParameter(0); }
130 bool isSigned() const { return getIntParameter(2); }
132 return static_cast<dxil::ResourceKind>(getIntParameter(3));
133 }
134
135 static bool classof(const TargetExtType *T) {
136 return T->getName() == "dx.MSTexture";
137 }
138 static bool classof(const Type *T) {
139 return isa<TargetExtType>(T) && classof(cast<TargetExtType>(T));
140 }
141};
142
143/// The dx.FeedbackTexture target extension type
144///
145/// `target("dx.FeedbackTexture", FeedbackType, Dimension)`
147public:
151
153 return static_cast<dxil::SamplerFeedbackType>(getIntParameter(0));
154 }
156 return static_cast<dxil::ResourceKind>(getIntParameter(1));
157 }
158
159 static bool classof(const TargetExtType *T) {
160 return T->getName() == "dx.FeedbackTexture";
161 }
162 static bool classof(const Type *T) {
163 return isa<TargetExtType>(T) && classof(cast<TargetExtType>(T));
164 }
165};
166
167/// The dx.CBuffer target extension type
168///
169/// `target("dx.CBuffer", <Type>, ...)`
171public:
172 CBufferExtType() = delete;
175
176 Type *getResourceType() const { return getTypeParameter(0); }
177
178 static bool classof(const TargetExtType *T) {
179 return T->getName() == "dx.CBuffer";
180 }
181 static bool classof(const Type *T) {
182 return isa<TargetExtType>(T) && classof(cast<TargetExtType>(T));
183 }
184};
185
186/// The dx.Sampler target extension type
187///
188/// `target("dx.Sampler", SamplerType)`
190public:
191 SamplerExtType() = delete;
194
196 return static_cast<dxil::SamplerType>(getIntParameter(0));
197 }
198
199 static bool classof(const TargetExtType *T) {
200 return T->getName() == "dx.Sampler";
201 }
202 static bool classof(const Type *T) {
203 return isa<TargetExtType>(T) && classof(cast<TargetExtType>(T));
204 }
205};
206
208public:
212
213 static bool classof(const TargetExtType *T) {
214 return isa<RawBufferExtType>(T) || isa<TypedBufferExtType>(T) ||
215 isa<TextureExtType>(T) || isa<MSTextureExtType>(T) ||
216 isa<FeedbackTextureExtType>(T) || isa<CBufferExtType>(T) ||
217 isa<SamplerExtType>(T);
218 }
219
220 static bool classof(const Type *T) {
221 return isa<TargetExtType>(T) && classof(cast<TargetExtType>(T));
222 }
223};
224
225/// The dx.Layout target extension type
226///
227/// `target("dx.Layout", <Type>, <size>, [offsets...])`
229public:
230 LayoutExtType() = delete;
231 LayoutExtType(const LayoutExtType &) = delete;
233
234 Type *getWrappedType() const { return getTypeParameter(0); }
235 uint32_t getSize() const { return getIntParameter(0); }
236 uint32_t getOffsetOfElement(int I) const { return getIntParameter(I + 1); }
237
238 static bool classof(const TargetExtType *T) {
239 return T->getName() == "dx.Layout";
240 }
241 static bool classof(const Type *T) {
242 return isa<TargetExtType>(T) && classof(cast<TargetExtType>(T));
243 }
244};
245
246//===----------------------------------------------------------------------===//
247
249public:
250 struct UAVInfo {
251 bool IsROV;
252
253 bool operator==(const UAVInfo &RHS) const { return IsROV == RHS.IsROV; }
254 bool operator!=(const UAVInfo &RHS) const { return !(*this == RHS); }
255 bool operator<(const UAVInfo &RHS) const { return IsROV < RHS.IsROV; }
256 };
257
258 struct StructInfo {
260 // Note: we store an integer here rather than using `MaybeAlign` because in
261 // GCC 7 MaybeAlign isn't trivial so having one in this union would delete
262 // our move constructor.
263 // See https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0602r4.html
265
266 bool operator==(const StructInfo &RHS) const {
267 return std::tie(Stride, AlignLog2) == std::tie(RHS.Stride, RHS.AlignLog2);
268 }
269 bool operator!=(const StructInfo &RHS) const { return !(*this == RHS); }
270 bool operator<(const StructInfo &RHS) const {
271 return std::tie(Stride, AlignLog2) < std::tie(RHS.Stride, RHS.AlignLog2);
272 }
273 };
274
275 struct TypedInfo {
278
279 bool operator==(const TypedInfo &RHS) const {
280 return std::tie(ElementTy, ElementCount) ==
281 std::tie(RHS.ElementTy, RHS.ElementCount);
282 }
283 bool operator!=(const TypedInfo &RHS) const { return !(*this == RHS); }
284 bool operator<(const TypedInfo &RHS) const {
285 return std::tie(ElementTy, ElementCount) <
286 std::tie(RHS.ElementTy, RHS.ElementCount);
287 }
288 };
289
290private:
291 TargetExtType *HandleTy;
292
295
296public:
298 const dxil::ResourceClass RC,
299 const dxil::ResourceKind Kind);
302
303 TargetExtType *getHandleTy() const { return HandleTy; }
305
306 // Conditions to check before accessing specific views.
307 LLVM_ABI bool isUAV() const;
308 LLVM_ABI bool isCBuffer() const;
309 LLVM_ABI bool isSampler() const;
310 LLVM_ABI bool isStruct() const;
311 LLVM_ABI bool isTyped() const;
312 LLVM_ABI bool isFeedback() const;
313 LLVM_ABI bool isMultiSample() const;
314
315 // Views into the type.
316 LLVM_ABI UAVInfo getUAV() const;
319 LLVM_ABI StructInfo getStruct(const DataLayout &DL) const;
320 LLVM_ABI TypedInfo getTyped() const;
323
325 dxil::ResourceKind getResourceKind() const { return Kind; }
326
327 LLVM_ABI bool operator==(const ResourceTypeInfo &RHS) const;
328 bool operator!=(const ResourceTypeInfo &RHS) const { return !(*this == RHS); }
329 LLVM_ABI bool operator<(const ResourceTypeInfo &RHS) const;
330
331 LLVM_ABI void print(raw_ostream &OS, const DataLayout &DL) const;
332};
333
334//===----------------------------------------------------------------------===//
335
337 Increment,
338 Decrement,
339 Unknown,
340 Invalid,
341};
342
344public:
350
351 bool operator==(const ResourceBinding &RHS) const {
352 return std::tie(RecordID, Space, LowerBound, Size) ==
353 std::tie(RHS.RecordID, RHS.Space, RHS.LowerBound, RHS.Size);
354 }
355 bool operator!=(const ResourceBinding &RHS) const {
356 return !(*this == RHS);
357 }
358 bool operator<(const ResourceBinding &RHS) const {
359 return std::tie(RecordID, Space, LowerBound, Size) <
360 std::tie(RHS.RecordID, RHS.Space, RHS.LowerBound, RHS.Size);
361 }
362 bool overlapsWith(const ResourceBinding &RHS) const {
363 if (Space != RHS.Space)
364 return false;
365 if (Size == UINT32_MAX)
366 return LowerBound < RHS.LowerBound;
367 return LowerBound + Size - 1 >= RHS.LowerBound;
368 }
369 };
370
371private:
372 ResourceBinding Binding;
373 TargetExtType *HandleTy;
374 StringRef Name;
375 GlobalVariable *Symbol = nullptr;
376
377public:
378 bool GloballyCoherent = false;
380
381 ResourceInfo(uint32_t RecordID, uint32_t Space, uint32_t LowerBound,
382 uint32_t Size, TargetExtType *HandleTy, StringRef Name = "",
383 GlobalVariable *Symbol = nullptr)
384 : Binding{RecordID, Space, LowerBound, Size}, HandleTy(HandleTy),
385 Name(Name), Symbol(Symbol) {}
386
387 void setBindingID(unsigned ID) { Binding.RecordID = ID; }
388
389 bool hasCounter() const {
391 }
392
393 const ResourceBinding &getBinding() const { return Binding; }
394 TargetExtType *getHandleTy() const { return HandleTy; }
395 StringRef getName() const { return Name; }
396
397 bool hasSymbol() const { return Symbol; }
400
401 LLVM_ABI std::pair<uint32_t, uint32_t>
403
404 bool operator==(const ResourceInfo &RHS) const {
405 return std::tie(Binding, HandleTy, Symbol, Name) ==
406 std::tie(RHS.Binding, RHS.HandleTy, RHS.Symbol, RHS.Name);
407 }
408 bool operator!=(const ResourceInfo &RHS) const { return !(*this == RHS); }
409 bool operator<(const ResourceInfo &RHS) const {
410 return Binding < RHS.Binding;
411 }
412
414 const DataLayout &DL) const;
415};
416
417} // namespace dxil
418
419//===----------------------------------------------------------------------===//
420
423
424public:
425 LLVM_ABI bool invalidate(Module &M, const PreservedAnalyses &PA,
427
429 auto It = Infos.find(Ty);
430 if (It != Infos.end())
431 return It->second;
432 auto [NewIt, Inserted] = Infos.try_emplace(Ty, Ty);
433 return NewIt->second;
434 }
435};
436
438 : public AnalysisInfoMixin<DXILResourceTypeAnalysis> {
440
441 LLVM_ABI static AnalysisKey Key;
442
443public:
445
447 // Running the pass just generates an empty map, which will be filled when
448 // users of the pass query the results.
449 return Result();
450 }
451};
452
455
456 virtual void anchor();
457
458public:
459 static char ID;
461
463 const DXILResourceTypeMap &getResourceTypeMap() const { return DRTM; }
464};
465
467
468//===----------------------------------------------------------------------===//
469
472
474 CallMapTy CallMap;
475 unsigned FirstUAV = 0;
476 unsigned FirstCBuffer = 0;
477 unsigned FirstSampler = 0;
478 bool HasInvalidDirection = false;
479
480 /// Populate all the resource instance data.
481 void populate(Module &M, DXILResourceTypeMap &DRTM);
482 /// Populate the map given the resource binding calls in the given module.
483 void populateResourceInfos(Module &M, DXILResourceTypeMap &DRTM);
484 /// Analyze and populate the directions of the resource counters.
485 void populateCounterDirections(Module &M);
486
487 /// Resolves a resource handle into a vector of ResourceInfos that
488 /// represent the possible unique creations of the handle. Certain cases are
489 /// ambiguous so multiple creation instructions may be returned. The resulting
490 /// ResourceInfo can be used to depuplicate unique handles that
491 /// reference the same resource
492 SmallVector<dxil::ResourceInfo *> findByUse(const Value *Key);
493
494public:
497
498 iterator begin() { return Infos.begin(); }
499 const_iterator begin() const { return Infos.begin(); }
500 iterator end() { return Infos.end(); }
501 const_iterator end() const { return Infos.end(); }
502
503 bool empty() const { return Infos.empty(); }
504
505 iterator find(const CallInst *Key) {
506 auto Pos = CallMap.find(Key);
507 return Pos == CallMap.end() ? Infos.end() : (Infos.begin() + Pos->second);
508 }
509
510 const_iterator find(const CallInst *Key) const {
511 auto Pos = CallMap.find(Key);
512 return Pos == CallMap.end() ? Infos.end() : (Infos.begin() + Pos->second);
513 }
514
515 iterator srv_begin() { return begin(); }
516 const_iterator srv_begin() const { return begin(); }
517 iterator srv_end() { return begin() + FirstUAV; }
518 const_iterator srv_end() const { return begin() + FirstUAV; }
521 return make_range(srv_begin(), srv_end());
522 }
523
524 iterator uav_begin() { return begin() + FirstUAV; }
525 const_iterator uav_begin() const { return begin() + FirstUAV; }
526 iterator uav_end() { return begin() + FirstCBuffer; }
527 const_iterator uav_end() const { return begin() + FirstCBuffer; }
530 return make_range(uav_begin(), uav_end());
531 }
532
533 iterator cbuffer_begin() { return begin() + FirstCBuffer; }
534 const_iterator cbuffer_begin() const { return begin() + FirstCBuffer; }
535 iterator cbuffer_end() { return begin() + FirstSampler; }
536 const_iterator cbuffer_end() const { return begin() + FirstSampler; }
539 }
542 }
543
544 iterator sampler_begin() { return begin() + FirstSampler; }
545 const_iterator sampler_begin() const { return begin() + FirstSampler; }
546 iterator sampler_end() { return end(); }
547 const_iterator sampler_end() const { return end(); }
550 }
553 }
554
556 : iterator_adaptor_base<call_iterator, CallMapTy::iterator> {
557 call_iterator() = default;
560
561 CallInst *operator*() const { return I->first; }
562 };
563
565 call_iterator call_end() { return call_iterator(CallMap.end()); }
567 return make_range(call_begin(), call_end());
568 }
569
570 bool hasInvalidCounterDirection() const { return HasInvalidDirection; }
571
573 const DataLayout &DL) const;
574
577};
578
579class DXILResourceAnalysis : public AnalysisInfoMixin<DXILResourceAnalysis> {
581
582 LLVM_ABI static AnalysisKey Key;
583
584public:
586
587 /// Gather resource info for the module \c M.
589};
590
591/// Printer pass for the \c DXILResourceAnalysis results.
592class DXILResourcePrinterPass : public PassInfoMixin<DXILResourcePrinterPass> {
593 raw_ostream &OS;
594
595public:
597
599
600 static bool isRequired() { return true; }
601};
602
604 std::unique_ptr<DXILResourceMap> Map;
606
607public:
608 static char ID; // Class identification, replacement for typeinfo
609
612
613 const DXILResourceMap &getResourceMap() const { return *Map; }
614 DXILResourceMap &getResourceMap() { return *Map; }
615
616 void getAnalysisUsage(AnalysisUsage &AU) const override;
617 bool runOnModule(Module &M) override;
618 void releaseMemory() override;
619
620 void print(raw_ostream &OS, const Module *M) const override;
621 void dump() const;
622};
623
625
626//===----------------------------------------------------------------------===//
627
628// DXILResourceBindingInfo stores the results of DXILResourceBindingAnalysis
629// which analyses all llvm.dx.resource.handlefrombinding calls in the module
630// and puts together lists of used virtual register spaces and available
631// virtual register slot ranges for each binding type.
632// It also stores additional information found during the analysis such as
633// whether the module uses implicit bindings or if any of the bindings overlap.
634//
635// This information will be used in DXILResourceImplicitBindings pass to assign
636// register slots to resources with implicit bindings, and in a
637// post-optimization validation pass that will raise diagnostic about
638// overlapping bindings.
640 hlsl::BindingInfo Bindings;
641 bool HasImplicitBinding = false;
642 bool HasOverlappingBinding = false;
643
644 // Populate the resource binding info given explicit resource binding calls
645 // in the module.
646 void populate(Module &M, DXILResourceTypeMap &DRTM);
647
648public:
649 bool hasImplicitBinding() const { return HasImplicitBinding; }
650 void setHasImplicitBinding(bool Value) { HasImplicitBinding = Value; }
651 bool hasOverlappingBinding() const { return HasOverlappingBinding; }
652 void setHasOverlappingBinding(bool Value) { HasOverlappingBinding = Value; }
653
654 std::optional<uint32_t> findAvailableBinding(dxil::ResourceClass RC,
655 uint32_t Space, int32_t Size) {
656 return Bindings.findAvailableBinding(RC, Space, Size);
657 }
658
661};
662
664 : public AnalysisInfoMixin<DXILResourceBindingAnalysis> {
666
667 LLVM_ABI static AnalysisKey Key;
668
669public:
671
673};
674
676 std::unique_ptr<DXILResourceBindingInfo> BindingInfo;
677
678public:
679 static char ID;
680
683
684 DXILResourceBindingInfo &getBindingInfo() { return *BindingInfo; }
685 const DXILResourceBindingInfo &getBindingInfo() const { return *BindingInfo; }
686
687 void getAnalysisUsage(AnalysisUsage &AU) const override;
688 bool runOnModule(Module &M) override;
689 void releaseMemory() override;
690};
691
693
694} // namespace llvm
695
696#endif // LLVM_ANALYSIS_DXILRESOURCE_H
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
#define LLVM_ABI
Definition: Compiler.h:213
DXIL Resource Implicit Binding
uint64_t Size
This header defines various interfaces for pass management in LLVM.
#define I(x, y, z)
Definition: MD5.cpp:58
This file implements a map that provides insertion order iteration.
raw_pwrite_stream & OS
This file defines the SmallVector class.
Value * RHS
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:294
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:255
Represent the analysis usage information of a pass.
This class represents a function call, abstracting a target machine's calling convention.
LLVM_ABI DXILResourceMap run(Module &M, ModuleAnalysisManager &AM)
Gather resource info for the module M.
LLVM_ABI DXILResourceBindingInfo run(Module &M, ModuleAnalysisManager &AM)
void setHasImplicitBinding(bool Value)
Definition: DXILResource.h:650
std::optional< uint32_t > findAvailableBinding(dxil::ResourceClass RC, uint32_t Space, int32_t Size)
Definition: DXILResource.h:654
void setHasOverlappingBinding(bool Value)
Definition: DXILResource.h:652
const DXILResourceBindingInfo & getBindingInfo() const
Definition: DXILResource.h:685
DXILResourceBindingInfo & getBindingInfo()
Definition: DXILResource.h:684
const_iterator sampler_end() const
Definition: DXILResource.h:547
iterator find(const CallInst *Key)
Definition: DXILResource.h:505
bool hasInvalidCounterDirection() const
Definition: DXILResource.h:570
const_iterator find(const CallInst *Key) const
Definition: DXILResource.h:510
iterator_range< iterator > samplers()
Definition: DXILResource.h:548
iterator_range< const_iterator > uavs() const
Definition: DXILResource.h:529
const_iterator cbuffer_end() const
Definition: DXILResource.h:536
iterator_range< const_iterator > srvs() const
Definition: DXILResource.h:520
call_iterator call_begin()
Definition: DXILResource.h:564
const_iterator uav_begin() const
Definition: DXILResource.h:525
const_iterator begin() const
Definition: DXILResource.h:499
iterator_range< const_iterator > samplers() const
Definition: DXILResource.h:551
LLVM_ABI void print(raw_ostream &OS, DXILResourceTypeMap &DRTM, const DataLayout &DL) const
call_iterator call_end()
Definition: DXILResource.h:565
const_iterator srv_begin() const
Definition: DXILResource.h:516
iterator_range< iterator > srvs()
Definition: DXILResource.h:519
iterator_range< iterator > cbuffers()
Definition: DXILResource.h:537
iterator_range< iterator > uavs()
Definition: DXILResource.h:528
iterator_range< call_iterator > calls()
Definition: DXILResource.h:566
iterator cbuffer_begin()
Definition: DXILResource.h:533
const_iterator uav_end() const
Definition: DXILResource.h:527
const_iterator sampler_begin() const
Definition: DXILResource.h:545
const_iterator cbuffer_begin() const
Definition: DXILResource.h:534
iterator sampler_begin()
Definition: DXILResource.h:544
const_iterator srv_end() const
Definition: DXILResource.h:518
iterator_range< const_iterator > cbuffers() const
Definition: DXILResource.h:540
const_iterator end() const
Definition: DXILResource.h:501
Printer pass for the DXILResourceAnalysis results.
Definition: DXILResource.h:592
DXILResourcePrinterPass(raw_ostream &OS)
Definition: DXILResource.h:596
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
DXILResourceTypeMap run(Module &M, ModuleAnalysisManager &AM)
Definition: DXILResource.h:446
DXILResourceTypeMap Result
Definition: DXILResource.h:444
dxil::ResourceTypeInfo & operator[](TargetExtType *Ty)
Definition: DXILResource.h:428
LLVM_ABI bool invalidate(Module &M, const PreservedAnalyses &PA, ModuleAnalysisManager::Invalidator &Inv)
DXILResourceTypeMap & getResourceTypeMap()
Definition: DXILResource.h:462
const DXILResourceTypeMap & getResourceTypeMap() const
Definition: DXILResource.h:463
DXILResourceMap & getResourceMap()
Definition: DXILResource.h:614
const DXILResourceMap & getResourceMap() const
Definition: DXILResource.h:613
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:63
iterator find(const_arg_type_t< KeyT > Val)
Definition: DenseMap.h:177
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
Definition: DenseMap.h:245
iterator begin()
Definition: DenseMap.h:78
iterator end()
Definition: DenseMap.h:87
ImmutablePass class - This class is used to provide information that does not need to be run.
Definition: Pass.h:285
Tuple of metadata.
Definition: Metadata.h:1493
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition: Pass.h:255
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
A set of analyses that are preserved following a run of a transformation pass.
Definition: Analysis.h:112
bool empty() const
Definition: SmallVector.h:82
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1197
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
Class to represent struct types.
Definition: DerivedTypes.h:218
Class to represent target extensions types, which are generally unintrospectable from target-independ...
Definition: DerivedTypes.h:781
Type * getTypeParameter(unsigned i) const
Definition: DerivedTypes.h:828
unsigned getIntParameter(unsigned i) const
Definition: DerivedTypes.h:837
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
bool isIntegerTy() const
True if this is an instance of IntegerType.
Definition: Type.h:240
bool isVoidTy() const
Return true if this is 'void'.
Definition: Type.h:139
LLVM Value Representation.
Definition: Value.h:75
static bool classof(const Type *T)
Definition: DXILResource.h:220
AnyResourceExtType & operator=(const AnyResourceExtType &)=delete
static bool classof(const TargetExtType *T)
Definition: DXILResource.h:213
AnyResourceExtType(const AnyResourceExtType &)=delete
The dx.CBuffer target extension type.
Definition: DXILResource.h:170
static bool classof(const TargetExtType *T)
Definition: DXILResource.h:178
CBufferExtType & operator=(const CBufferExtType &)=delete
CBufferExtType(const CBufferExtType &)=delete
static bool classof(const Type *T)
Definition: DXILResource.h:181
Type * getResourceType() const
Definition: DXILResource.h:176
The dx.FeedbackTexture target extension type.
Definition: DXILResource.h:146
dxil::SamplerFeedbackType getFeedbackType() const
Definition: DXILResource.h:152
FeedbackTextureExtType(const FeedbackTextureExtType &)=delete
dxil::ResourceKind getDimension() const
Definition: DXILResource.h:155
FeedbackTextureExtType & operator=(const FeedbackTextureExtType &)=delete
static bool classof(const TargetExtType *T)
Definition: DXILResource.h:159
static bool classof(const Type *T)
Definition: DXILResource.h:162
The dx.Layout target extension type.
Definition: DXILResource.h:228
static bool classof(const Type *T)
Definition: DXILResource.h:241
LayoutExtType(const LayoutExtType &)=delete
uint32_t getSize() const
Definition: DXILResource.h:235
LayoutExtType & operator=(const LayoutExtType &)=delete
static bool classof(const TargetExtType *T)
Definition: DXILResource.h:238
uint32_t getOffsetOfElement(int I) const
Definition: DXILResource.h:236
Type * getWrappedType() const
Definition: DXILResource.h:234
The dx.MSTexture target extension type.
Definition: DXILResource.h:121
dxil::ResourceKind getDimension() const
Definition: DXILResource.h:131
MSTextureExtType(const MSTextureExtType &)=delete
static bool classof(const TargetExtType *T)
Definition: DXILResource.h:135
Type * getResourceType() const
Definition: DXILResource.h:127
uint32_t getSampleCount() const
Definition: DXILResource.h:129
static bool classof(const Type *T)
Definition: DXILResource.h:138
MSTextureExtType & operator=(const MSTextureExtType &)=delete
The dx.RawBuffer target extension type.
Definition: DXILResource.h:43
static bool classof(const TargetExtType *T)
Definition: DXILResource.h:63
RawBufferExtType(const RawBufferExtType &)=delete
static bool classof(const Type *T)
Definition: DXILResource.h:66
RawBufferExtType & operator=(const RawBufferExtType &)=delete
Type * getResourceType() const
Definition: DXILResource.h:57
StringRef getName() const
Definition: DXILResource.h:395
bool operator<(const ResourceInfo &RHS) const
Definition: DXILResource.h:409
bool operator!=(const ResourceInfo &RHS) const
Definition: DXILResource.h:408
TargetExtType * getHandleTy() const
Definition: DXILResource.h:394
LLVM_ABI std::pair< uint32_t, uint32_t > getAnnotateProps(Module &M, dxil::ResourceTypeInfo &RTI) const
LLVM_ABI void print(raw_ostream &OS, dxil::ResourceTypeInfo &RTI, const DataLayout &DL) const
ResourceInfo(uint32_t RecordID, uint32_t Space, uint32_t LowerBound, uint32_t Size, TargetExtType *HandleTy, StringRef Name="", GlobalVariable *Symbol=nullptr)
Definition: DXILResource.h:381
void setBindingID(unsigned ID)
Definition: DXILResource.h:387
bool operator==(const ResourceInfo &RHS) const
Definition: DXILResource.h:404
const ResourceBinding & getBinding() const
Definition: DXILResource.h:393
LLVM_ABI GlobalVariable * createSymbol(Module &M, StructType *Ty)
LLVM_ABI MDTuple * getAsMetadata(Module &M, dxil::ResourceTypeInfo &RTI) const
ResourceCounterDirection CounterDirection
Definition: DXILResource.h:379
dxil::ResourceClass getResourceClass() const
Definition: DXILResource.h:324
LLVM_ABI uint32_t getMultiSampleCount() const
LLVM_ABI uint32_t getCBufferSize(const DataLayout &DL) const
LLVM_ABI bool operator<(const ResourceTypeInfo &RHS) const
LLVM_ABI bool isUAV() const
LLVM_ABI bool isMultiSample() const
LLVM_ABI bool isSampler() const
LLVM_ABI bool isTyped() const
LLVM_ABI dxil::SamplerType getSamplerType() const
LLVM_ABI bool isCBuffer() const
LLVM_ABI TypedInfo getTyped() const
bool operator!=(const ResourceTypeInfo &RHS) const
Definition: DXILResource.h:328
LLVM_ABI StructType * createElementStruct(StringRef CBufferName="")
TargetExtType * getHandleTy() const
Definition: DXILResource.h:303
LLVM_ABI bool isFeedback() const
ResourceTypeInfo(TargetExtType *HandleTy)
Definition: DXILResource.h:300
LLVM_ABI UAVInfo getUAV() const
LLVM_ABI StructInfo getStruct(const DataLayout &DL) const
LLVM_ABI bool isStruct() const
LLVM_ABI dxil::SamplerFeedbackType getFeedbackType() const
dxil::ResourceKind getResourceKind() const
Definition: DXILResource.h:325
LLVM_ABI void print(raw_ostream &OS, const DataLayout &DL) const
The dx.Sampler target extension type.
Definition: DXILResource.h:189
SamplerExtType(const SamplerExtType &)=delete
static bool classof(const Type *T)
Definition: DXILResource.h:202
dxil::SamplerType getSamplerType() const
Definition: DXILResource.h:195
SamplerExtType & operator=(const SamplerExtType &)=delete
static bool classof(const TargetExtType *T)
Definition: DXILResource.h:199
The dx.Texture target extension type.
Definition: DXILResource.h:96
static bool classof(const TargetExtType *T)
Definition: DXILResource.h:110
dxil::ResourceKind getDimension() const
Definition: DXILResource.h:106
Type * getResourceType() const
Definition: DXILResource.h:102
TextureExtType & operator=(const TextureExtType &)=delete
TextureExtType(const TextureExtType &)=delete
static bool classof(const Type *T)
Definition: DXILResource.h:113
The dx.TypedBuffer target extension type.
Definition: DXILResource.h:74
TypedBufferExtType & operator=(const TypedBufferExtType &)=delete
static bool classof(const TargetExtType *T)
Definition: DXILResource.h:85
TypedBufferExtType(const TypedBufferExtType &)=delete
static bool classof(const Type *T)
Definition: DXILResource.h:88
BindingInfo represents the ranges of bindings and free space for each dxil::ResourceClass.
Definition: HLSLBinding.h:46
LLVM_ABI std::optional< uint32_t > findAvailableBinding(dxil::ResourceClass RC, uint32_t Space, int32_t Size)
Definition: HLSLBinding.cpp:16
CRTP base class for adapting an iterator to a different type.
Definition: iterator.h:237
A range adaptor for a pair of iterators.
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
ResourceKind
The kind of resource for an SRV or UAV resource.
Definition: DXILABI.h:35
ResourceClass
Definition: DXILABI.h:26
ResourceCounterDirection
Definition: DXILResource.h:336
SamplerFeedbackType
Definition: DXILABI.h:95
ElementType
The element type of an SRV or UAV resource.
Definition: DXILABI.h:59
LLVM_ABI StringRef getResourceNameFromBindingCall(CallInst *CI)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
LLVM_ABI ModulePass * createDXILResourceBindingWrapperPassPass()
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
LLVM_ABI ModulePass * createDXILResourceTypeWrapperPassPass()
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1886
LLVM_ABI ModulePass * createDXILResourceWrapperPassPass()
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:856
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:93
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: Analysis.h:29
call_iterator(CallMapTy::iterator Iter)
Definition: DXILResource.h:558
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:70
bool operator!=(const ResourceBinding &RHS) const
Definition: DXILResource.h:355
bool operator==(const ResourceBinding &RHS) const
Definition: DXILResource.h:351
bool overlapsWith(const ResourceBinding &RHS) const
Definition: DXILResource.h:362
bool operator<(const ResourceBinding &RHS) const
Definition: DXILResource.h:358
bool operator==(const StructInfo &RHS) const
Definition: DXILResource.h:266
bool operator!=(const StructInfo &RHS) const
Definition: DXILResource.h:269
bool operator<(const StructInfo &RHS) const
Definition: DXILResource.h:270
bool operator<(const TypedInfo &RHS) const
Definition: DXILResource.h:284
bool operator==(const TypedInfo &RHS) const
Definition: DXILResource.h:279
bool operator!=(const TypedInfo &RHS) const
Definition: DXILResource.h:283
bool operator!=(const UAVInfo &RHS) const
Definition: DXILResource.h:254
bool operator==(const UAVInfo &RHS) const
Definition: DXILResource.h:253
bool operator<(const UAVInfo &RHS) const
Definition: DXILResource.h:255