Movatterモバイル変換


[0]ホーム

URL:


LLVM 20.0.0git
DXILResource.cpp
Go to the documentation of this file.
1//===- DXILResource.cpp - Representations of DXIL resources ---------------===//
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#include "llvm/Analysis/DXILResource.h"
10#include "llvm/ADT/APInt.h"
11#include "llvm/ADT/SmallString.h"
12#include "llvm/IR/Constants.h"
13#include "llvm/IR/DerivedTypes.h"
14#include "llvm/IR/DiagnosticInfo.h"
15#include "llvm/IR/Instructions.h"
16#include "llvm/IR/Intrinsics.h"
17#include "llvm/IR/IntrinsicsDirectX.h"
18#include "llvm/IR/Metadata.h"
19#include "llvm/IR/Module.h"
20#include "llvm/InitializePasses.h"
21#include "llvm/Support/FormatVariadic.h"
22
23#define DEBUG_TYPE "dxil-resource"
24
25using namespacellvm;
26using namespacedxil;
27
28staticStringRefgetResourceClassName(ResourceClass RC) {
29switch (RC) {
30case ResourceClass::SRV:
31return"SRV";
32case ResourceClass::UAV:
33return"UAV";
34case ResourceClass::CBuffer:
35return"CBuffer";
36case ResourceClass::Sampler:
37return"Sampler";
38 }
39llvm_unreachable("Unhandled ResourceClass");
40}
41
42staticStringRefgetResourceKindName(ResourceKind RK) {
43switch (RK) {
44case ResourceKind::Texture1D:
45return"Texture1D";
46case ResourceKind::Texture2D:
47return"Texture2D";
48case ResourceKind::Texture2DMS:
49return"Texture2DMS";
50case ResourceKind::Texture3D:
51return"Texture3D";
52case ResourceKind::TextureCube:
53return"TextureCube";
54case ResourceKind::Texture1DArray:
55return"Texture1DArray";
56case ResourceKind::Texture2DArray:
57return"Texture2DArray";
58case ResourceKind::Texture2DMSArray:
59return"Texture2DMSArray";
60case ResourceKind::TextureCubeArray:
61return"TextureCubeArray";
62case ResourceKind::TypedBuffer:
63return"TypedBuffer";
64case ResourceKind::RawBuffer:
65return"RawBuffer";
66case ResourceKind::StructuredBuffer:
67return"StructuredBuffer";
68case ResourceKind::CBuffer:
69return"CBuffer";
70case ResourceKind::Sampler:
71return"Sampler";
72case ResourceKind::TBuffer:
73return"TBuffer";
74case ResourceKind::RTAccelerationStructure:
75return"RTAccelerationStructure";
76case ResourceKind::FeedbackTexture2D:
77return"FeedbackTexture2D";
78case ResourceKind::FeedbackTexture2DArray:
79return"FeedbackTexture2DArray";
80case ResourceKind::NumEntries:
81case ResourceKind::Invalid:
82return"<invalid>";
83 }
84llvm_unreachable("Unhandled ResourceKind");
85}
86
87staticStringRefgetElementTypeName(ElementType ET) {
88switch (ET) {
89case ElementType::I1:
90return"i1";
91case ElementType::I16:
92return"i16";
93case ElementType::U16:
94return"u16";
95case ElementType::I32:
96return"i32";
97case ElementType::U32:
98return"u32";
99case ElementType::I64:
100return"i64";
101case ElementType::U64:
102return"u64";
103case ElementType::F16:
104return"f16";
105case ElementType::F32:
106return"f32";
107case ElementType::F64:
108return"f64";
109case ElementType::SNormF16:
110return"snorm_f16";
111case ElementType::UNormF16:
112return"unorm_f16";
113case ElementType::SNormF32:
114return"snorm_f32";
115case ElementType::UNormF32:
116return"unorm_f32";
117case ElementType::SNormF64:
118return"snorm_f64";
119case ElementType::UNormF64:
120return"unorm_f64";
121case ElementType::PackedS8x32:
122return"p32i8";
123case ElementType::PackedU8x32:
124return"p32u8";
125case ElementType::Invalid:
126return"<invalid>";
127 }
128llvm_unreachable("Unhandled ElementType");
129}
130
131staticStringRefgetSamplerTypeName(SamplerType ST) {
132switch (ST) {
133case SamplerType::Default:
134return"Default";
135case SamplerType::Comparison:
136return"Comparison";
137case SamplerType::Mono:
138return"Mono";
139 }
140llvm_unreachable("Unhandled SamplerType");
141}
142
143staticStringRefgetSamplerFeedbackTypeName(SamplerFeedbackType SFT) {
144switch (SFT) {
145case SamplerFeedbackType::MinMip:
146return"MinMip";
147case SamplerFeedbackType::MipRegionUsed:
148return"MipRegionUsed";
149 }
150llvm_unreachable("Unhandled SamplerFeedbackType");
151}
152
153staticdxil::ElementTypetoDXILElementType(Type *Ty,bool IsSigned) {
154// TODO: Handle unorm, snorm, and packed.
155 Ty = Ty->getScalarType();
156
157if (Ty->isIntegerTy()) {
158switch (Ty->getIntegerBitWidth()) {
159case 16:
160return IsSigned ? ElementType::I16 : ElementType::U16;
161case 32:
162return IsSigned ? ElementType::I32 : ElementType::U32;
163case 64:
164return IsSigned ? ElementType::I64 : ElementType::U64;
165case 1:
166default:
167return ElementType::Invalid;
168 }
169 }elseif (Ty->isFloatTy()) {
170return ElementType::F32;
171 }elseif (Ty->isDoubleTy()) {
172return ElementType::F64;
173 }elseif (Ty->isHalfTy()) {
174return ElementType::F16;
175 }
176
177return ElementType::Invalid;
178}
179
180ResourceTypeInfo::ResourceTypeInfo(TargetExtType *HandleTy,
181constdxil::ResourceClass RC_,
182constdxil::ResourceKind Kind_,
183bool GloballyCoherent,bool HasCounter)
184 : HandleTy(HandleTy), GloballyCoherent(GloballyCoherent),
185 HasCounter(HasCounter) {
186// If we're provided a resource class and kind, trust them.
187if (Kind_ !=dxil::ResourceKind::Invalid) {
188 RC = RC_;
189 Kind = Kind_;
190return;
191 }
192
193if (auto *Ty = dyn_cast<RawBufferExtType>(HandleTy)) {
194 RC = Ty->isWriteable() ?ResourceClass::UAV :ResourceClass::SRV;
195 Kind = Ty->isStructured() ?ResourceKind::StructuredBuffer
196 :ResourceKind::RawBuffer;
197 }elseif (auto *Ty = dyn_cast<TypedBufferExtType>(HandleTy)) {
198 RC = Ty->isWriteable() ?ResourceClass::UAV :ResourceClass::SRV;
199 Kind =ResourceKind::TypedBuffer;
200 }elseif (auto *Ty = dyn_cast<TextureExtType>(HandleTy)) {
201 RC = Ty->isWriteable() ?ResourceClass::UAV :ResourceClass::SRV;
202 Kind = Ty->getDimension();
203 }elseif (auto *Ty = dyn_cast<MSTextureExtType>(HandleTy)) {
204 RC = Ty->isWriteable() ?ResourceClass::UAV :ResourceClass::SRV;
205 Kind = Ty->getDimension();
206 }elseif (auto *Ty = dyn_cast<FeedbackTextureExtType>(HandleTy)) {
207 RC =ResourceClass::UAV;
208 Kind = Ty->getDimension();
209 }elseif (isa<CBufferExtType>(HandleTy)) {
210 RC =ResourceClass::CBuffer;
211 Kind =ResourceKind::CBuffer;
212 }elseif (isa<SamplerExtType>(HandleTy)) {
213 RC =ResourceClass::Sampler;
214 Kind =ResourceKind::Sampler;
215 }else
216llvm_unreachable("Unknown handle type");
217}
218
219staticvoidformatTypeName(SmallString<64> &Dest,StringRefName,
220bool isWriteable,boolisROV) {
221 Dest = isWriteable ? (isROV ?"RasterizerOrdered" :"RW") :"";
222 Dest +=Name;
223}
224
225StructType *ResourceTypeInfo::createElementStruct() {
226SmallString<64> TypeName;
227
228switch (Kind) {
229caseResourceKind::Texture1D:
230caseResourceKind::Texture2D:
231caseResourceKind::Texture3D:
232caseResourceKind::TextureCube:
233caseResourceKind::Texture1DArray:
234caseResourceKind::Texture2DArray:
235caseResourceKind::TextureCubeArray: {
236auto *RTy = cast<TextureExtType>(HandleTy);
237formatTypeName(TypeName,getResourceKindName(Kind), RTy->isWriteable(),
238 RTy->isROV());
239returnStructType::create(RTy->getResourceType(), TypeName);
240 }
241caseResourceKind::Texture2DMS:
242caseResourceKind::Texture2DMSArray: {
243auto *RTy = cast<MSTextureExtType>(HandleTy);
244formatTypeName(TypeName,getResourceKindName(Kind), RTy->isWriteable(),
245/*IsROV=*/false);
246returnStructType::create(RTy->getResourceType(), TypeName);
247 }
248caseResourceKind::TypedBuffer: {
249auto *RTy = cast<TypedBufferExtType>(HandleTy);
250formatTypeName(TypeName,getResourceKindName(Kind), RTy->isWriteable(),
251 RTy->isROV());
252returnStructType::create(RTy->getResourceType(), TypeName);
253 }
254caseResourceKind::RawBuffer: {
255auto *RTy = cast<RawBufferExtType>(HandleTy);
256formatTypeName(TypeName,"ByteAddressBuffer", RTy->isWriteable(),
257 RTy->isROV());
258returnStructType::create(Type::getInt32Ty(HandleTy->getContext()),
259 TypeName);
260 }
261caseResourceKind::StructuredBuffer: {
262auto *RTy = cast<RawBufferExtType>(HandleTy);
263formatTypeName(TypeName,"StructuredBuffer", RTy->isWriteable(),
264 RTy->isROV());
265returnStructType::create(RTy->getResourceType(), TypeName);
266 }
267caseResourceKind::FeedbackTexture2D:
268caseResourceKind::FeedbackTexture2DArray: {
269auto *RTy = cast<FeedbackTextureExtType>(HandleTy);
270 TypeName =formatv("{0}<{1}>",getResourceKindName(Kind),
271llvm::to_underlying(RTy->getFeedbackType()));
272returnStructType::create(Type::getInt32Ty(HandleTy->getContext()),
273 TypeName);
274 }
275caseResourceKind::CBuffer:
276returnStructType::create(HandleTy->getContext(),"cbuffer");
277caseResourceKind::Sampler: {
278auto *RTy = cast<SamplerExtType>(HandleTy);
279 TypeName =formatv("SamplerState<{0}>",
280llvm::to_underlying(RTy->getSamplerType()));
281returnStructType::create(Type::getInt32Ty(HandleTy->getContext()),
282 TypeName);
283 }
284caseResourceKind::TBuffer:
285caseResourceKind::RTAccelerationStructure:
286llvm_unreachable("Unhandled resource kind");
287caseResourceKind::Invalid:
288caseResourceKind::NumEntries:
289llvm_unreachable("Invalid resource kind");
290 }
291llvm_unreachable("Unhandled ResourceKind enum");
292}
293
294boolResourceTypeInfo::isUAV() const{return RC ==ResourceClass::UAV; }
295
296boolResourceTypeInfo::isCBuffer() const{
297return RC ==ResourceClass::CBuffer;
298}
299
300boolResourceTypeInfo::isSampler() const{
301return RC ==ResourceClass::Sampler;
302}
303
304boolResourceTypeInfo::isStruct() const{
305return Kind ==ResourceKind::StructuredBuffer;
306}
307
308boolResourceTypeInfo::isTyped() const{
309switch (Kind) {
310caseResourceKind::Texture1D:
311caseResourceKind::Texture2D:
312caseResourceKind::Texture2DMS:
313caseResourceKind::Texture3D:
314caseResourceKind::TextureCube:
315caseResourceKind::Texture1DArray:
316caseResourceKind::Texture2DArray:
317caseResourceKind::Texture2DMSArray:
318caseResourceKind::TextureCubeArray:
319caseResourceKind::TypedBuffer:
320returntrue;
321caseResourceKind::RawBuffer:
322caseResourceKind::StructuredBuffer:
323caseResourceKind::FeedbackTexture2D:
324caseResourceKind::FeedbackTexture2DArray:
325caseResourceKind::CBuffer:
326caseResourceKind::Sampler:
327caseResourceKind::TBuffer:
328caseResourceKind::RTAccelerationStructure:
329returnfalse;
330caseResourceKind::Invalid:
331caseResourceKind::NumEntries:
332llvm_unreachable("Invalid resource kind");
333 }
334llvm_unreachable("Unhandled ResourceKind enum");
335}
336
337boolResourceTypeInfo::isFeedback() const{
338return Kind ==ResourceKind::FeedbackTexture2D ||
339 Kind ==ResourceKind::FeedbackTexture2DArray;
340}
341
342boolResourceTypeInfo::isMultiSample() const{
343return Kind ==ResourceKind::Texture2DMS ||
344 Kind ==ResourceKind::Texture2DMSArray;
345}
346
347staticboolisROV(dxil::ResourceKind Kind,TargetExtType *Ty) {
348switch (Kind) {
349caseResourceKind::Texture1D:
350caseResourceKind::Texture2D:
351caseResourceKind::Texture3D:
352caseResourceKind::TextureCube:
353caseResourceKind::Texture1DArray:
354caseResourceKind::Texture2DArray:
355caseResourceKind::TextureCubeArray:
356return cast<TextureExtType>(Ty)->isROV();
357caseResourceKind::TypedBuffer:
358return cast<TypedBufferExtType>(Ty)->isROV();
359caseResourceKind::RawBuffer:
360caseResourceKind::StructuredBuffer:
361return cast<RawBufferExtType>(Ty)->isROV();
362caseResourceKind::Texture2DMS:
363caseResourceKind::Texture2DMSArray:
364caseResourceKind::FeedbackTexture2D:
365caseResourceKind::FeedbackTexture2DArray:
366returnfalse;
367caseResourceKind::CBuffer:
368caseResourceKind::Sampler:
369caseResourceKind::TBuffer:
370caseResourceKind::RTAccelerationStructure:
371caseResourceKind::Invalid:
372caseResourceKind::NumEntries:
373llvm_unreachable("Resource cannot be ROV");
374 }
375llvm_unreachable("Unhandled ResourceKind enum");
376}
377
378ResourceTypeInfo::UAVInfoResourceTypeInfo::getUAV() const{
379assert(isUAV() &&"Not a UAV");
380return {GloballyCoherent, HasCounter,isROV(Kind, HandleTy)};
381}
382
383uint32_tResourceTypeInfo::getCBufferSize(constDataLayout &DL) const{
384assert(isCBuffer() &&"Not a CBuffer");
385return cast<CBufferExtType>(HandleTy)->getCBufferSize();
386}
387
388dxil::SamplerTypeResourceTypeInfo::getSamplerType() const{
389assert(isSampler() &&"Not a Sampler");
390return cast<SamplerExtType>(HandleTy)->getSamplerType();
391}
392
393ResourceTypeInfo::StructInfo
394ResourceTypeInfo::getStruct(constDataLayout &DL) const{
395assert(isStruct() &&"Not a Struct");
396
397Type *ElTy = cast<RawBufferExtType>(HandleTy)->getResourceType();
398
399uint32_t Stride =DL.getTypeAllocSize(ElTy);
400MaybeAlign Alignment;
401if (auto *STy = dyn_cast<StructType>(ElTy))
402 Alignment =DL.getStructLayout(STy)->getAlignment();
403uint32_t AlignLog2 = Alignment ?Log2(*Alignment) : 0;
404return {Stride, AlignLog2};
405}
406
407static std::pair<Type *, bool>getTypedElementType(dxil::ResourceKind Kind,
408TargetExtType *Ty) {
409switch (Kind) {
410caseResourceKind::Texture1D:
411caseResourceKind::Texture2D:
412caseResourceKind::Texture3D:
413caseResourceKind::TextureCube:
414caseResourceKind::Texture1DArray:
415caseResourceKind::Texture2DArray:
416caseResourceKind::TextureCubeArray: {
417auto *RTy = cast<TextureExtType>(Ty);
418return {RTy->getResourceType(), RTy->isSigned()};
419 }
420caseResourceKind::Texture2DMS:
421caseResourceKind::Texture2DMSArray: {
422auto *RTy = cast<MSTextureExtType>(Ty);
423return {RTy->getResourceType(), RTy->isSigned()};
424 }
425caseResourceKind::TypedBuffer: {
426auto *RTy = cast<TypedBufferExtType>(Ty);
427return {RTy->getResourceType(), RTy->isSigned()};
428 }
429caseResourceKind::RawBuffer:
430caseResourceKind::StructuredBuffer:
431caseResourceKind::FeedbackTexture2D:
432caseResourceKind::FeedbackTexture2DArray:
433caseResourceKind::CBuffer:
434caseResourceKind::Sampler:
435caseResourceKind::TBuffer:
436caseResourceKind::RTAccelerationStructure:
437caseResourceKind::Invalid:
438caseResourceKind::NumEntries:
439llvm_unreachable("Resource is not typed");
440 }
441llvm_unreachable("Unhandled ResourceKind enum");
442}
443
444ResourceTypeInfo::TypedInfoResourceTypeInfo::getTyped() const{
445assert(isTyped() &&"Not typed");
446
447auto [ElTy, IsSigned] =getTypedElementType(Kind, HandleTy);
448dxil::ElementType ET =toDXILElementType(ElTy, IsSigned);
449uint32_t Count = 1;
450if (auto *VTy = dyn_cast<FixedVectorType>(ElTy))
451 Count = VTy->getNumElements();
452return {ET, Count};
453}
454
455dxil::SamplerFeedbackTypeResourceTypeInfo::getFeedbackType() const{
456assert(isFeedback() &&"Not Feedback");
457return cast<FeedbackTextureExtType>(HandleTy)->getFeedbackType();
458}
459uint32_tResourceTypeInfo::getMultiSampleCount() const{
460assert(isMultiSample() &&"Not MultiSampled");
461return cast<MSTextureExtType>(HandleTy)->getSampleCount();
462}
463
464boolResourceTypeInfo::operator==(constResourceTypeInfo &RHS) const{
465return std::tie(HandleTy, GloballyCoherent, HasCounter) ==
466 std::tie(RHS.HandleTy,RHS.GloballyCoherent,RHS.HasCounter);
467}
468
469boolResourceTypeInfo::operator<(constResourceTypeInfo &RHS) const{
470// An empty datalayout is sufficient for sorting purposes.
471DataLayout DummyDL;
472if (std::tie(RC, Kind) < std::tie(RHS.RC,RHS.Kind))
473returntrue;
474if (isCBuffer() &&RHS.isCBuffer() &&
475getCBufferSize(DummyDL) <RHS.getCBufferSize(DummyDL))
476returntrue;
477if (isSampler() &&RHS.isSampler() &&getSamplerType() <RHS.getSamplerType())
478returntrue;
479if (isUAV() &&RHS.isUAV() &&getUAV() <RHS.getUAV())
480returntrue;
481if (isStruct() &&RHS.isStruct() &&
482getStruct(DummyDL) <RHS.getStruct(DummyDL))
483returntrue;
484if (isFeedback() &&RHS.isFeedback() &&
485getFeedbackType() <RHS.getFeedbackType())
486returntrue;
487if (isTyped() &&RHS.isTyped() &&getTyped() <RHS.getTyped())
488returntrue;
489if (isMultiSample() &&RHS.isMultiSample() &&
490getMultiSampleCount() <RHS.getMultiSampleCount())
491returntrue;
492returnfalse;
493}
494
495voidResourceTypeInfo::print(raw_ostream &OS,constDataLayout &DL) const{
496OS <<" Class: " <<getResourceClassName(RC) <<"\n"
497 <<" Kind: " <<getResourceKindName(Kind) <<"\n";
498
499if (isCBuffer()) {
500OS <<" CBuffer size: " <<getCBufferSize(DL) <<"\n";
501 }elseif (isSampler()) {
502OS <<" Sampler Type: " <<getSamplerTypeName(getSamplerType()) <<"\n";
503 }else {
504if (isUAV()) {
505UAVInfo UAVFlags =getUAV();
506OS <<" Globally Coherent: " << UAVFlags.GloballyCoherent <<"\n"
507 <<" HasCounter: " << UAVFlags.HasCounter <<"\n"
508 <<" IsROV: " << UAVFlags.IsROV <<"\n";
509 }
510if (isMultiSample())
511OS <<" Sample Count: " <<getMultiSampleCount() <<"\n";
512
513if (isStruct()) {
514StructInfoStruct =getStruct(DL);
515OS <<" Buffer Stride: " <<Struct.Stride <<"\n";
516OS <<" Alignment: " <<Struct.AlignLog2 <<"\n";
517 }elseif (isTyped()) {
518TypedInfo Typed =getTyped();
519OS <<" Element Type: " <<getElementTypeName(Typed.ElementTy) <<"\n"
520 <<" Element Count: " << Typed.ElementCount <<"\n";
521 }elseif (isFeedback())
522OS <<" Feedback Type: " <<getSamplerFeedbackTypeName(getFeedbackType())
523 <<"\n";
524 }
525}
526
527GlobalVariable *ResourceBindingInfo::createSymbol(Module &M,StructType *Ty,
528StringRefName) {
529assert(!Symbol &&"Symbol has already been created");
530 Symbol =newGlobalVariable(M, Ty,/*isConstant=*/true,
531GlobalValue::ExternalLinkage,
532/*Initializer=*/nullptr,Name);
533return Symbol;
534}
535
536MDTuple *ResourceBindingInfo::getAsMetadata(Module &M,
537dxil::ResourceTypeInfo &RTI) const{
538LLVMContext &Ctx = M.getContext();
539constDataLayout &DL = M.getDataLayout();
540
541SmallVector<Metadata *, 11> MDVals;
542
543Type *I32Ty =Type::getInt32Ty(Ctx);
544Type *I1Ty =Type::getInt1Ty(Ctx);
545auto getIntMD = [&I32Ty](uint32_t V) {
546returnConstantAsMetadata::get(
547Constant::getIntegerValue(I32Ty,APInt(32, V)));
548 };
549auto getBoolMD = [&I1Ty](uint32_t V) {
550returnConstantAsMetadata::get(
551Constant::getIntegerValue(I1Ty,APInt(1, V)));
552 };
553
554 MDVals.push_back(getIntMD(Binding.RecordID));
555assert(Symbol &&"Cannot yet create useful resource metadata without symbol");
556 MDVals.push_back(ValueAsMetadata::get(Symbol));
557 MDVals.push_back(MDString::get(Ctx, Symbol->getName()));
558 MDVals.push_back(getIntMD(Binding.Space));
559 MDVals.push_back(getIntMD(Binding.LowerBound));
560 MDVals.push_back(getIntMD(Binding.Size));
561
562if (RTI.isCBuffer()) {
563 MDVals.push_back(getIntMD(RTI.getCBufferSize(DL)));
564 MDVals.push_back(nullptr);
565 }elseif (RTI.isSampler()) {
566 MDVals.push_back(getIntMD(llvm::to_underlying(RTI.getSamplerType())));
567 MDVals.push_back(nullptr);
568 }else {
569 MDVals.push_back(getIntMD(llvm::to_underlying(RTI.getResourceKind())));
570
571if (RTI.isUAV()) {
572ResourceTypeInfo::UAVInfo UAVFlags = RTI.getUAV();
573 MDVals.push_back(getBoolMD(UAVFlags.GloballyCoherent));
574 MDVals.push_back(getBoolMD(UAVFlags.HasCounter));
575 MDVals.push_back(getBoolMD(UAVFlags.IsROV));
576 }else {
577// All SRVs include sample count in the metadata, but it's only meaningful
578// for multi-sampled textured. Also, UAVs can be multisampled in SM6.7+,
579// but this just isn't reflected in the metadata at all.
580uint32_t SampleCount =
581 RTI.isMultiSample() ? RTI.getMultiSampleCount() : 0;
582 MDVals.push_back(getIntMD(SampleCount));
583 }
584
585// Further properties are attached to a metadata list of tag-value pairs.
586SmallVector<Metadata *> Tags;
587if (RTI.isStruct()) {
588 Tags.push_back(
589 getIntMD(llvm::to_underlying(ExtPropTags::StructuredBufferStride)));
590 Tags.push_back(getIntMD(RTI.getStruct(DL).Stride));
591 }elseif (RTI.isTyped()) {
592 Tags.push_back(getIntMD(llvm::to_underlying(ExtPropTags::ElementType)));
593 Tags.push_back(getIntMD(llvm::to_underlying(RTI.getTyped().ElementTy)));
594 }elseif (RTI.isFeedback()) {
595 Tags.push_back(
596 getIntMD(llvm::to_underlying(ExtPropTags::SamplerFeedbackKind)));
597 Tags.push_back(getIntMD(llvm::to_underlying(RTI.getFeedbackType())));
598 }
599 MDVals.push_back(Tags.empty() ?nullptr :MDNode::get(Ctx, Tags));
600 }
601
602returnMDNode::get(Ctx, MDVals);
603}
604
605std::pair<uint32_t, uint32_t>
606ResourceBindingInfo::getAnnotateProps(Module &M,
607dxil::ResourceTypeInfo &RTI) const{
608constDataLayout &DL = M.getDataLayout();
609
610uint32_tResourceKind =llvm::to_underlying(RTI.getResourceKind());
611uint32_t AlignLog2 = RTI.isStruct() ? RTI.getStruct(DL).AlignLog2 : 0;
612bool IsUAV = RTI.isUAV();
613ResourceTypeInfo::UAVInfo UAVFlags =
614 IsUAV ? RTI.getUAV() :ResourceTypeInfo::UAVInfo{};
615bool IsROV = IsUAV && UAVFlags.IsROV;
616bool IsGloballyCoherent = IsUAV && UAVFlags.GloballyCoherent;
617uint8_t SamplerCmpOrHasCounter = 0;
618if (IsUAV)
619 SamplerCmpOrHasCounter = UAVFlags.HasCounter;
620elseif (RTI.isSampler())
621 SamplerCmpOrHasCounter = RTI.getSamplerType() ==SamplerType::Comparison;
622
623// TODO: Document this format. Currently the only reference is the
624// implementation of dxc's DxilResourceProperties struct.
625uint32_t Word0 = 0;
626 Word0 |=ResourceKind & 0xFF;
627 Word0 |= (AlignLog2 & 0xF) << 8;
628 Word0 |= (IsUAV & 1) << 12;
629 Word0 |= (IsROV & 1) << 13;
630 Word0 |= (IsGloballyCoherent & 1) << 14;
631 Word0 |= (SamplerCmpOrHasCounter & 1) << 15;
632
633uint32_t Word1 = 0;
634if (RTI.isStruct())
635 Word1 = RTI.getStruct(DL).Stride;
636elseif (RTI.isCBuffer())
637 Word1 = RTI.getCBufferSize(DL);
638elseif (RTI.isFeedback())
639 Word1 =llvm::to_underlying(RTI.getFeedbackType());
640elseif (RTI.isTyped()) {
641ResourceTypeInfo::TypedInfo Typed = RTI.getTyped();
642uint32_t CompType =llvm::to_underlying(Typed.ElementTy);
643uint32_t CompCount = Typed.ElementCount;
644uint32_t SampleCount = RTI.isMultiSample() ? RTI.getMultiSampleCount() : 0;
645
646 Word1 |= (CompType & 0xFF) << 0;
647 Word1 |= (CompCount & 0xFF) << 8;
648 Word1 |= (SampleCount & 0xFF) << 16;
649 }
650
651return {Word0, Word1};
652}
653
654voidResourceBindingInfo::print(raw_ostream &OS,dxil::ResourceTypeInfo &RTI,
655constDataLayout &DL) const{
656if (Symbol) {
657OS <<" Symbol: ";
658 Symbol->printAsOperand(OS);
659OS <<"\n";
660 }
661
662OS <<" Binding:\n"
663 <<" Record ID: " << Binding.RecordID <<"\n"
664 <<" Space: " << Binding.Space <<"\n"
665 <<" Lower Bound: " << Binding.LowerBound <<"\n"
666 <<" Size: " << Binding.Size <<"\n";
667
668 RTI.print(OS,DL);
669}
670
671//===----------------------------------------------------------------------===//
672
673boolDXILResourceTypeMap::invalidate(Module &M,constPreservedAnalyses &PA,
674ModuleAnalysisManager::Invalidator &Inv) {
675// Passes that introduce resource types must explicitly invalidate this pass.
676auto PAC = PA.getChecker<DXILResourceTypeAnalysis>();
677return !PAC.preservedWhenStateless();
678}
679
680//===----------------------------------------------------------------------===//
681
682void DXILBindingMap::populate(Module &M,DXILResourceTypeMap &DRTM) {
683SmallVector<std::tuple<CallInst *, ResourceBindingInfo, ResourceTypeInfo>>
684 CIToInfos;
685
686for (Function &F : M.functions()) {
687if (!F.isDeclaration())
688continue;
689LLVM_DEBUG(dbgs() <<"Function: " <<F.getName() <<"\n");
690Intrinsic::IDID =F.getIntrinsicID();
691switch (ID) {
692default:
693continue;
694case Intrinsic::dx_resource_handlefrombinding: {
695auto *HandleTy = cast<TargetExtType>(F.getReturnType());
696ResourceTypeInfo &RTI = DRTM[HandleTy];
697
698for (User *U :F.users())
699if (CallInst *CI = dyn_cast<CallInst>(U)) {
700LLVM_DEBUG(dbgs() <<" Visiting: " << *U <<"\n");
701uint32_t Space =
702 cast<ConstantInt>(CI->getArgOperand(0))->getZExtValue();
703uint32_t LowerBound =
704 cast<ConstantInt>(CI->getArgOperand(1))->getZExtValue();
705uint32_tSize =
706 cast<ConstantInt>(CI->getArgOperand(2))->getZExtValue();
707ResourceBindingInfo RBI =ResourceBindingInfo{
708/*RecordID=*/0, Space, LowerBound,Size, HandleTy};
709
710 CIToInfos.emplace_back(CI, RBI, RTI);
711 }
712
713break;
714 }
715 }
716 }
717
718llvm::stable_sort(CIToInfos, [](auto &LHS,auto &RHS) {
719constauto &[LCI, LRBI, LRTI] =LHS;
720constauto &[RCI, RRBI, RRTI] =RHS;
721// Sort by resource class first for grouping purposes, and then by the
722// binding and type so we can remove duplicates.
723ResourceClass LRC = LRTI.getResourceClass();
724ResourceClassRRC = RRTI.getResourceClass();
725
726return std::tie(LRC, LRBI, LRTI) < std::tie(RRC, RRBI, RRTI);
727 });
728for (auto [CI, RBI, RTI] : CIToInfos) {
729if (Infos.empty() || RBI != Infos.back())
730 Infos.push_back(RBI);
731 CallMap[CI] = Infos.size() - 1;
732 }
733
734unsignedSize = Infos.size();
735// In DXC, Record ID is unique per resource type. Match that.
736 FirstUAV = FirstCBuffer = FirstSampler =Size;
737uint32_t NextID = 0;
738for (unsignedI = 0, E =Size;I != E; ++I) {
739ResourceBindingInfo &RBI = Infos[I];
740ResourceTypeInfo &RTI = DRTM[RBI.getHandleTy()];
741if (RTI.isUAV() && FirstUAV ==Size) {
742 FirstUAV =I;
743 NextID = 0;
744 }elseif (RTI.isCBuffer() && FirstCBuffer ==Size) {
745 FirstCBuffer =I;
746 NextID = 0;
747 }elseif (RTI.isSampler() && FirstSampler ==Size) {
748 FirstSampler =I;
749 NextID = 0;
750 }
751
752// Adjust the resource binding to use the next ID.
753 RBI.setBindingID(NextID++);
754 }
755}
756
757voidDXILBindingMap::print(raw_ostream &OS,DXILResourceTypeMap &DRTM,
758constDataLayout &DL) const{
759for (unsignedI = 0, E = Infos.size();I != E; ++I) {
760OS <<"Binding " <<I <<":\n";
761constdxil::ResourceBindingInfo &RBI = Infos[I];
762 RBI.print(OS, DRTM[RBI.getHandleTy()],DL);
763OS <<"\n";
764 }
765
766for (constauto &[CI, Index] : CallMap) {
767OS <<"Call bound to " << Index <<":";
768 CI->print(OS);
769OS <<"\n";
770 }
771}
772
773//===----------------------------------------------------------------------===//
774
775AnalysisKey DXILResourceTypeAnalysis::Key;
776AnalysisKey DXILResourceBindingAnalysis::Key;
777
778DXILBindingMapDXILResourceBindingAnalysis::run(Module &M,
779ModuleAnalysisManager &AM) {
780DXILBindingMapData;
781DXILResourceTypeMap &DRTM = AM.getResult<DXILResourceTypeAnalysis>(M);
782Data.populate(M, DRTM);
783returnData;
784}
785
786PreservedAnalyses
787DXILResourceBindingPrinterPass::run(Module &M,ModuleAnalysisManager &AM) {
788DXILBindingMap &DBM = AM.getResult<DXILResourceBindingAnalysis>(M);
789DXILResourceTypeMap &DRTM = AM.getResult<DXILResourceTypeAnalysis>(M);
790
791 DBM.print(OS, DRTM, M.getDataLayout());
792returnPreservedAnalyses::all();
793}
794
795void DXILResourceTypeWrapperPass::anchor() {}
796
797DXILResourceTypeWrapperPass::DXILResourceTypeWrapperPass() :ImmutablePass(ID) {
798initializeDXILResourceTypeWrapperPassPass(*PassRegistry::getPassRegistry());
799}
800
801INITIALIZE_PASS(DXILResourceTypeWrapperPass,"dxil-resource-type",
802"DXIL Resource Type Analysis",false,true)
803charDXILResourceTypeWrapperPass::ID = 0;
804
805ModulePass *llvm::createDXILResourceTypeWrapperPassPass() {
806returnnewDXILResourceTypeWrapperPass();
807}
808
809DXILResourceBindingWrapperPass::DXILResourceBindingWrapperPass()
810 :ModulePass(ID) {
811initializeDXILResourceBindingWrapperPassPass(
812 *PassRegistry::getPassRegistry());
813}
814
815DXILResourceBindingWrapperPass::~DXILResourceBindingWrapperPass() =default;
816
817voidDXILResourceBindingWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const{
818 AU.addRequiredTransitive<DXILResourceTypeWrapperPass>();
819 AU.setPreservesAll();
820}
821
822boolDXILResourceBindingWrapperPass::runOnModule(Module &M) {
823 Map.reset(newDXILBindingMap());
824
825 DRTM = &getAnalysis<DXILResourceTypeWrapperPass>().getResourceTypeMap();
826 Map->populate(M, *DRTM);
827
828returnfalse;
829}
830
831voidDXILResourceBindingWrapperPass::releaseMemory() { Map.reset(); }
832
833voidDXILResourceBindingWrapperPass::print(raw_ostream &OS,
834constModule *M) const{
835if (!Map) {
836OS <<"No resource map has been built!\n";
837return;
838 }
839 Map->print(OS, *DRTM, M->getDataLayout());
840}
841
842#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
843LLVM_DUMP_METHOD
844voidDXILResourceBindingWrapperPass::dump() const{print(dbgs(),nullptr); }
845#endif
846
847INITIALIZE_PASS(DXILResourceBindingWrapperPass,"dxil-resource-binding",
848"DXIL Resource Binding Analysis",false,true)
849charDXILResourceBindingWrapperPass::ID = 0;
850
851ModulePass *llvm::createDXILResourceBindingWrapperPassPass() {
852returnnewDXILResourceBindingWrapperPass();
853}
APInt.h
This file implements a class to represent arbitrary precision integral constant values and operations...
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition:ARMSLSHardening.cpp:73
toDXILElementType
static dxil::ElementType toDXILElementType(Type *Ty, bool IsSigned)
Definition:DXILResource.cpp:153
getResourceClassName
static StringRef getResourceClassName(ResourceClass RC)
Definition:DXILResource.cpp:28
getElementTypeName
static StringRef getElementTypeName(ElementType ET)
Definition:DXILResource.cpp:87
formatTypeName
static void formatTypeName(SmallString< 64 > &Dest, StringRef Name, bool isWriteable, bool isROV)
Definition:DXILResource.cpp:219
getTypedElementType
static std::pair< Type *, bool > getTypedElementType(dxil::ResourceKind Kind, TargetExtType *Ty)
Definition:DXILResource.cpp:407
isROV
static bool isROV(dxil::ResourceKind Kind, TargetExtType *Ty)
Definition:DXILResource.cpp:347
getResourceKindName
static StringRef getResourceKindName(ResourceKind RK)
Definition:DXILResource.cpp:42
getSamplerTypeName
static StringRef getSamplerTypeName(SamplerType ST)
Definition:DXILResource.cpp:131
getSamplerFeedbackTypeName
static StringRef getSamplerFeedbackTypeName(SamplerFeedbackType SFT)
Definition:DXILResource.cpp:143
LLVM_DUMP_METHOD
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition:Compiler.h:622
Constants.h
This file contains the declarations for the subclasses of Constant, which represent the different fla...
LLVM_DEBUG
#define LLVM_DEBUG(...)
Definition:Debug.h:106
DerivedTypes.h
DiagnosticInfo.h
Name
std::string Name
Definition:ELFObjHandler.cpp:77
Size
uint64_t Size
Definition:ELFObjHandler.cpp:81
FormatVariadic.h
Module.h
Module.h This file contains the declarations for the Module class.
InitializePasses.h
Instructions.h
Intrinsics.h
F
#define F(x, y, z)
Definition:MD5.cpp:55
I
#define I(x, y, z)
Definition:MD5.cpp:58
Metadata.h
This file contains the declarations for metadata subclasses.
INITIALIZE_PASS
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition:PassSupport.h:38
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
OS
raw_pwrite_stream & OS
Definition:SampleProfWriter.cpp:51
SmallString.h
This file defines the SmallString class.
Struct
@ Struct
Definition:TargetLibraryInfo.cpp:78
RHS
Value * RHS
Definition:X86PartialReduction.cpp:74
LHS
Value * LHS
Definition:X86PartialReduction.cpp:73
char
llvm::APInt
Class for arbitrary precision integers.
Definition:APInt.h:78
llvm::AnalysisManager::Invalidator
API to communicate dependencies between analyses during invalidation.
Definition:PassManager.h:292
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition:PassManager.h:253
llvm::AnalysisManager::getResult
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Definition:PassManager.h:410
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition:PassAnalysisSupport.h:47
llvm::AnalysisUsage::setPreservesAll
void setPreservesAll()
Set by analyses that do not transform their input at all.
Definition:PassAnalysisSupport.h:130
llvm::AnalysisUsage::addRequiredTransitive
AnalysisUsage & addRequiredTransitive()
Definition:PassAnalysisSupport.h:81
llvm::CallInst
This class represents a function call, abstracting a target machine's calling convention.
Definition:Instructions.h:1479
llvm::ConstantAsMetadata::get
static ConstantAsMetadata * get(Constant *C)
Definition:Metadata.h:532
llvm::Constant::getIntegerValue
static Constant * getIntegerValue(Type *Ty, const APInt &V)
Return the value for an integer or pointer constant, or a vector thereof, with the given scalar value...
Definition:Constants.cpp:403
llvm::DXILBindingMap
Definition:DXILResource.h:423
llvm::DXILBindingMap::print
void print(raw_ostream &OS, DXILResourceTypeMap &DRTM, const DataLayout &DL) const
Definition:DXILResource.cpp:757
llvm::DXILResourceBindingAnalysis
Definition:DXILResource.h:502
llvm::DXILResourceBindingAnalysis::run
DXILBindingMap run(Module &M, ModuleAnalysisManager &AM)
Gather resource info for the module M.
Definition:DXILResource.cpp:778
llvm::DXILResourceBindingPrinterPass::run
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Definition:DXILResource.cpp:787
llvm::DXILResourceBindingWrapperPass
Definition:DXILResource.h:527
llvm::DXILResourceBindingWrapperPass::runOnModule
bool runOnModule(Module &M) override
runOnModule - Virtual method overriden by subclasses to process the module being operated on.
Definition:DXILResource.cpp:822
llvm::DXILResourceBindingWrapperPass::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Definition:DXILResource.cpp:817
llvm::DXILResourceBindingWrapperPass::~DXILResourceBindingWrapperPass
~DXILResourceBindingWrapperPass() override
llvm::DXILResourceBindingWrapperPass::dump
void dump() const
Definition:DXILResource.cpp:844
llvm::DXILResourceBindingWrapperPass::DXILResourceBindingWrapperPass
DXILResourceBindingWrapperPass()
Definition:DXILResource.cpp:809
llvm::DXILResourceBindingWrapperPass::print
void print(raw_ostream &OS, const Module *M) const override
print - Print out the internal state of the pass.
Definition:DXILResource.cpp:833
llvm::DXILResourceBindingWrapperPass::releaseMemory
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
Definition:DXILResource.cpp:831
llvm::DXILResourceTypeAnalysis
Definition:DXILResource.h:391
llvm::DXILResourceTypeMap
Definition:DXILResource.h:374
llvm::DXILResourceTypeMap::invalidate
bool invalidate(Module &M, const PreservedAnalyses &PA, ModuleAnalysisManager::Invalidator &Inv)
Definition:DXILResource.cpp:673
llvm::DXILResourceTypeWrapperPass
Definition:DXILResource.h:406
llvm::DXILResourceTypeWrapperPass::DXILResourceTypeWrapperPass
DXILResourceTypeWrapperPass()
Definition:DXILResource.cpp:797
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition:DataLayout.h:63
llvm::Function
Definition:Function.h:63
llvm::GlobalValue::ExternalLinkage
@ ExternalLinkage
Externally visible function.
Definition:GlobalValue.h:52
llvm::GlobalVariable
Definition:GlobalVariable.h:39
llvm::ImmutablePass
ImmutablePass class - This class is used to provide information that does not need to be run.
Definition:Pass.h:281
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition:LLVMContext.h:67
llvm::MDNode::get
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Definition:Metadata.h:1549
llvm::MDString::get
static MDString * get(LLVMContext &Context, StringRef Str)
Definition:Metadata.cpp:606
llvm::MDTuple
Tuple of metadata.
Definition:Metadata.h:1479
llvm::MachineBasicBlock::getAlignment
Align getAlignment() const
Return alignment of the basic block.
Definition:MachineBasicBlock.h:614
llvm::ModulePass
ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...
Definition:Pass.h:251
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition:Module.h:65
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition:PassRegistry.cpp:24
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition:Analysis.h:111
llvm::PreservedAnalyses::all
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition:Analysis.h:117
llvm::PreservedAnalyses::getChecker
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
Definition:Analysis.h:264
llvm::SmallString
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition:SmallString.h:26
llvm::SmallVectorBase::empty
bool empty() const
Definition:SmallVector.h:81
llvm::SmallVectorImpl::emplace_back
reference emplace_back(ArgTypes &&... Args)
Definition:SmallVector.h:937
llvm::SmallVectorTemplateBase::push_back
void push_back(const T &Elt)
Definition:SmallVector.h:413
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition:SmallVector.h:1196
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:StringRef.h:51
llvm::StructType
Class to represent struct types.
Definition:DerivedTypes.h:218
llvm::StructType::create
static StructType * create(LLVMContext &Context, StringRef Name)
This creates an identified struct.
Definition:Type.cpp:612
llvm::TargetExtType
Class to represent target extensions types, which are generally unintrospectable from target-independ...
Definition:DerivedTypes.h:744
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition:Type.h:45
llvm::Type::getIntegerBitWidth
unsigned getIntegerBitWidth() const
llvm::Type::getInt1Ty
static IntegerType * getInt1Ty(LLVMContext &C)
llvm::Type::isFloatTy
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
Definition:Type.h:153
llvm::Type::isHalfTy
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
Definition:Type.h:142
llvm::Type::getContext
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Definition:Type.h:128
llvm::Type::isDoubleTy
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
Definition:Type.h:156
llvm::Type::getInt32Ty
static IntegerType * getInt32Ty(LLVMContext &C)
llvm::Type::isIntegerTy
bool isIntegerTy() const
True if this is an instance of IntegerType.
Definition:Type.h:237
llvm::Type::getScalarType
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
Definition:Type.h:355
llvm::User
Definition:User.h:44
llvm::ValueAsMetadata::get
static ValueAsMetadata * get(Value *V)
Definition:Metadata.cpp:501
llvm::Value::printAsOperand
void printAsOperand(raw_ostream &O, bool PrintType=true, const Module *M=nullptr) const
Print the name of this Value out to the specified raw_ostream.
Definition:AsmWriter.cpp:5144
llvm::Value::getName
StringRef getName() const
Return a constant reference to the value's name.
Definition:Value.cpp:309
llvm::dxil::ResourceBindingInfo
Definition:DXILResource.h:309
llvm::dxil::ResourceBindingInfo::setBindingID
void setBindingID(unsigned ID)
Definition:DXILResource.h:342
llvm::dxil::ResourceBindingInfo::createSymbol
GlobalVariable * createSymbol(Module &M, StructType *Ty, StringRef Name="")
Definition:DXILResource.cpp:527
llvm::dxil::ResourceBindingInfo::getAnnotateProps
std::pair< uint32_t, uint32_t > getAnnotateProps(Module &M, dxil::ResourceTypeInfo &RTI) const
Definition:DXILResource.cpp:606
llvm::dxil::ResourceBindingInfo::getHandleTy
TargetExtType * getHandleTy() const
Definition:DXILResource.h:345
llvm::dxil::ResourceBindingInfo::getAsMetadata
MDTuple * getAsMetadata(Module &M, dxil::ResourceTypeInfo &RTI) const
Definition:DXILResource.cpp:536
llvm::dxil::ResourceBindingInfo::print
void print(raw_ostream &OS, dxil::ResourceTypeInfo &RTI, const DataLayout &DL) const
Definition:DXILResource.cpp:654
llvm::dxil::ResourceTypeInfo
Definition:DXILResource.h:202
llvm::dxil::ResourceTypeInfo::getMultiSampleCount
uint32_t getMultiSampleCount() const
Definition:DXILResource.cpp:459
llvm::dxil::ResourceTypeInfo::getCBufferSize
uint32_t getCBufferSize(const DataLayout &DL) const
Definition:DXILResource.cpp:383
llvm::dxil::ResourceTypeInfo::operator<
bool operator<(const ResourceTypeInfo &RHS) const
Definition:DXILResource.cpp:469
llvm::dxil::ResourceTypeInfo::isUAV
bool isUAV() const
Definition:DXILResource.cpp:294
llvm::dxil::ResourceTypeInfo::isMultiSample
bool isMultiSample() const
Definition:DXILResource.cpp:342
llvm::dxil::ResourceTypeInfo::isSampler
bool isSampler() const
Definition:DXILResource.cpp:300
llvm::dxil::ResourceTypeInfo::isTyped
bool isTyped() const
Definition:DXILResource.cpp:308
llvm::dxil::ResourceTypeInfo::getSamplerType
dxil::SamplerType getSamplerType() const
Definition:DXILResource.cpp:388
llvm::dxil::ResourceTypeInfo::isCBuffer
bool isCBuffer() const
Definition:DXILResource.cpp:296
llvm::dxil::ResourceTypeInfo::getTyped
TypedInfo getTyped() const
Definition:DXILResource.cpp:444
llvm::dxil::ResourceTypeInfo::createElementStruct
StructType * createElementStruct()
Definition:DXILResource.cpp:225
llvm::dxil::ResourceTypeInfo::isFeedback
bool isFeedback() const
Definition:DXILResource.cpp:337
llvm::dxil::ResourceTypeInfo::getUAV
UAVInfo getUAV() const
Definition:DXILResource.cpp:378
llvm::dxil::ResourceTypeInfo::getStruct
StructInfo getStruct(const DataLayout &DL) const
Definition:DXILResource.cpp:394
llvm::dxil::ResourceTypeInfo::ResourceTypeInfo
ResourceTypeInfo(TargetExtType *HandleTy, const dxil::ResourceClass RC, const dxil::ResourceKind Kind, bool GloballyCoherent=false, bool HasCounter=false)
Definition:DXILResource.cpp:180
llvm::dxil::ResourceTypeInfo::isStruct
bool isStruct() const
Definition:DXILResource.cpp:304
llvm::dxil::ResourceTypeInfo::getFeedbackType
dxil::SamplerFeedbackType getFeedbackType() const
Definition:DXILResource.cpp:455
llvm::dxil::ResourceTypeInfo::operator==
bool operator==(const ResourceTypeInfo &RHS) const
Definition:DXILResource.cpp:464
llvm::dxil::ResourceTypeInfo::getResourceKind
dxil::ResourceKind getResourceKind() const
Definition:DXILResource.h:295
llvm::dxil::ResourceTypeInfo::print
void print(raw_ostream &OS, const DataLayout &DL) const
Definition:DXILResource.cpp:495
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition:raw_ostream.h:52
uint32_t
uint8_t
unsigned
DXILResource.h
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition:ErrorHandling.h:143
llvm::MSP430ISD::RRC
@ RRC
Y = RRC X, rotate right via carry.
Definition:MSP430ISelLowering.h:36
llvm::dxil::ResourceKind
ResourceKind
The kind of resource for an SRV or UAV resource.
Definition:DXILABI.h:34
llvm::dxil::ResourceKind::FeedbackTexture2D
@ FeedbackTexture2D
llvm::dxil::ResourceKind::TextureCube
@ TextureCube
llvm::dxil::ResourceKind::TypedBuffer
@ TypedBuffer
llvm::dxil::ResourceKind::FeedbackTexture2DArray
@ FeedbackTexture2DArray
llvm::dxil::ResourceKind::NumEntries
@ NumEntries
llvm::dxil::ResourceKind::Invalid
@ Invalid
llvm::dxil::ResourceKind::Texture2DArray
@ Texture2DArray
llvm::dxil::ResourceKind::Sampler
@ Sampler
llvm::dxil::ResourceKind::TBuffer
@ TBuffer
llvm::dxil::ResourceKind::Texture2DMS
@ Texture2DMS
llvm::dxil::ResourceKind::CBuffer
@ CBuffer
llvm::dxil::ResourceKind::Texture3D
@ Texture3D
llvm::dxil::ResourceKind::RTAccelerationStructure
@ RTAccelerationStructure
llvm::dxil::ResourceKind::Texture1DArray
@ Texture1DArray
llvm::dxil::ResourceKind::Texture2D
@ Texture2D
llvm::dxil::ResourceKind::TextureCubeArray
@ TextureCubeArray
llvm::dxil::ResourceKind::StructuredBuffer
@ StructuredBuffer
llvm::dxil::ResourceKind::RawBuffer
@ RawBuffer
llvm::dxil::ResourceKind::Texture2DMSArray
@ Texture2DMSArray
llvm::dxil::ResourceKind::Texture1D
@ Texture1D
llvm::dxil::ResourceClass
ResourceClass
Definition:DXILABI.h:25
llvm::dxil::ResourceClass::Sampler
@ Sampler
llvm::dxil::ResourceClass::UAV
@ UAV
llvm::dxil::ResourceClass::CBuffer
@ CBuffer
llvm::dxil::ResourceClass::SRV
@ SRV
llvm::dxil::ExtPropTags::SamplerFeedbackKind
@ SamplerFeedbackKind
llvm::dxil::ExtPropTags::ElementType
@ ElementType
llvm::dxil::ExtPropTags::StructuredBufferStride
@ StructuredBufferStride
llvm::dxil::SamplerType
SamplerType
Definition:DXILABI.h:88
llvm::dxil::SamplerType::Comparison
@ Comparison
llvm::dxil::SamplerFeedbackType
SamplerFeedbackType
Definition:DXILABI.h:94
llvm::dxil::ElementType
ElementType
The element type of an SRV or UAV resource.
Definition:DXILABI.h:58
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:AddressRanges.h:18
llvm::stable_sort
void stable_sort(R &&Range)
Definition:STLExtras.h:2037
llvm::initializeDXILResourceTypeWrapperPassPass
void initializeDXILResourceTypeWrapperPassPass(PassRegistry &)
llvm::createDXILResourceTypeWrapperPassPass
ModulePass * createDXILResourceTypeWrapperPassPass()
llvm::formatv
auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)
Definition:FormatVariadic.h:252
llvm::initializeDXILResourceBindingWrapperPassPass
void initializeDXILResourceBindingWrapperPassPass(PassRegistry &)
llvm::dbgs
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition:Debug.cpp:163
llvm::to_underlying
constexpr std::underlying_type_t< Enum > to_underlying(Enum E)
Returns underlying integer value of an enum.
Definition:STLForwardCompat.h:66
llvm::Log2
unsigned Log2(Align A)
Returns the log2 of the alignment.
Definition:Alignment.h:208
llvm::Data
@ Data
Definition:SIMachineScheduler.h:55
llvm::createDXILResourceBindingWrapperPassPass
ModulePass * createDXILResourceBindingWrapperPassPass()
llvm::AnalysisKey
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition:Analysis.h:28
llvm::MaybeAlign
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition:Alignment.h:117
llvm::dxil::ResourceBindingInfo::ResourceBinding::LowerBound
uint32_t LowerBound
Definition:DXILResource.h:314
llvm::dxil::ResourceBindingInfo::ResourceBinding::RecordID
uint32_t RecordID
Definition:DXILResource.h:312
llvm::dxil::ResourceBindingInfo::ResourceBinding::Size
uint32_t Size
Definition:DXILResource.h:315
llvm::dxil::ResourceBindingInfo::ResourceBinding::Space
uint32_t Space
Definition:DXILResource.h:313
llvm::dxil::ResourceTypeInfo::StructInfo
Definition:DXILResource.h:220
llvm::dxil::ResourceTypeInfo::StructInfo::AlignLog2
uint32_t AlignLog2
Definition:DXILResource.h:226
llvm::dxil::ResourceTypeInfo::StructInfo::Stride
uint32_t Stride
Definition:DXILResource.h:221
llvm::dxil::ResourceTypeInfo::TypedInfo
Definition:DXILResource.h:237
llvm::dxil::ResourceTypeInfo::TypedInfo::ElementCount
uint32_t ElementCount
Definition:DXILResource.h:239
llvm::dxil::ResourceTypeInfo::TypedInfo::ElementTy
dxil::ElementType ElementTy
Definition:DXILResource.h:238
llvm::dxil::ResourceTypeInfo::UAVInfo
Definition:DXILResource.h:204
llvm::dxil::ResourceTypeInfo::UAVInfo::GloballyCoherent
bool GloballyCoherent
Definition:DXILResource.h:205
llvm::dxil::ResourceTypeInfo::UAVInfo::IsROV
bool IsROV
Definition:DXILResource.h:207
llvm::dxil::ResourceTypeInfo::UAVInfo::HasCounter
bool HasCounter
Definition:DXILResource.h:206

Generated on Thu Jul 17 2025 14:43:53 for LLVM by doxygen 1.9.6
[8]ページ先頭

©2009-2025 Movatter.jp