LLVM: include/llvm/Analysis/DXILResource.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9#ifndef LLVM_ANALYSIS_DXILRESOURCE_H

10#define LLVM_ANALYSIS_DXILRESOURCE_H

11

23#include

24

25namespace llvm {

31

33

34namespace dxil {

35

36

37

39

40

41

42

44public:

48

50

51

52

54 return !Ty->isVoidTy() && !Ty->isIntegerTy(8);

55 }

56

62

63 static bool classof(const TargetExtType *T) {

64 return T->getName() == "dx.RawBuffer";

65 }

69};

70

71

72

73

75public:

79

84

85 static bool classof(const TargetExtType *T) {

86 return T->getName() == "dx.TypedBuffer";

87 }

91};

92

93

94

95

97public:

101

109

110 static bool classof(const TargetExtType *T) {

111 return T->getName() == "dx.Texture";

112 }

116};

117

118

119

120

122public:

126

134

135 static bool classof(const TargetExtType *T) {

136 return T->getName() == "dx.MSTexture";

137 }

141};

142

143

144

145

147public:

151

158

159 static bool classof(const TargetExtType *T) {

160 return T->getName() == "dx.FeedbackTexture";

161 }

165};

166

167

168

169

171public:

175

177

178 static bool classof(const TargetExtType *T) {

179 return T->getName() == "dx.CBuffer";

180 }

184};

185

186

187

188

190public:

194

198

199 static bool classof(const TargetExtType *T) {

200 return T->getName() == "dx.Sampler";

201 }

205};

206

208public:

212

213 static bool classof(const TargetExtType *T) {

218 }

219

223};

224

225

226

227

229public:

233

237

238 static bool classof(const TargetExtType *T) {

239 return T->getName() == "dx.Layout";

240 }

244};

245

246

247

248

250public:

254

256

257 static bool classof(const TargetExtType *T) {

258 return T->getName() == "dx.Padding";

259 }

263};

264

265

266

268public:

276

279

280

281

282

284

292 };

293

298

301 std::tie(RHS.ElementTy, RHS.ElementCount);

302 }

306 std::tie(RHS.ElementTy, RHS.ElementCount);

307 }

308 };

309

310private:

312

315

316public:

322

325

326

334

335

343

346

350

352};

353

354

355

362

364public:

370

373 std::tie(RHS.RecordID, RHS.Space, RHS.LowerBound, RHS.Size);

374 }

376 return !(*this == RHS);

377 }

380 std::tie(RHS.RecordID, RHS.Space, RHS.LowerBound, RHS.Size);

381 }

384 return false;

385 if (Size == UINT32_MAX)

388 }

389 };

390

391private:

396

397public:

400

404 : Binding{RecordID, Space, LowerBound, Size}, HandleTy(HandleTy),

405 Name(Name), Symbol(Symbol) {}

406

408

412

416

420

421 LLVM_ABI std::pair<uint32_t, uint32_t>

423

425 return std::tie(Binding, HandleTy, Symbol, Name) ==

426 std::tie(RHS.Binding, RHS.HandleTy, RHS.Symbol, RHS.Name);

427 }

430 return Binding < RHS.Binding;

431 }

432

435};

436

437}

438

439

440

443

444public:

446 ModuleAnalysisManager::Invalidator &Inv);

447

449 auto It = Infos.find(Ty);

450 if (It != Infos.end())

451 return It->second;

452 auto [NewIt, Inserted] = Infos.try_emplace(Ty, Ty);

453 return NewIt->second;

454 }

455};

456

460

462

463public:

465

471};

472

475

476 virtual void anchor();

477

478public:

481

484};

485

487

488

489

492

494 CallMapTy CallMap;

495 unsigned FirstUAV = 0;

496 unsigned FirstCBuffer = 0;

497 unsigned FirstSampler = 0;

498 bool HasInvalidDirection = false;

499

500

502

504

505 void populateCounterDirections(Module &M);

506

507

508

509

510

511

513

514public:

517

522

523 bool empty() const { return Infos.empty(); }

524

526 auto Pos = CallMap.find(Key);

527 return Pos == CallMap.end() ? Infos.end() : (Infos.begin() + Pos->second);

528 }

529

531 auto Pos = CallMap.find(Key);

532 return Pos == CallMap.end() ? Infos.end() : (Infos.begin() + Pos->second);

533 }

534

543

552

563

574

583

589

591

594

597};

598

601

603

604public:

606

607

609};

610

611

614

615public:

617

619

621};

622

624 std::unique_ptr Map;

626

627public:

628 static char ID;

629

632

635

636 void getAnalysisUsage(AnalysisUsage &AU) const override;

637 bool runOnModule(Module &M) override;

638 void releaseMemory() override;

639

641 void dump() const;

642};

643

645

646

647

648

649

650

651

652

653

654

655

656

657

658

661 bool HasImplicitBinding = false;

662 bool HasOverlappingBinding = false;

663

664

665

667

668public:

673

676 return Bindings.findAvailableBinding(RC, Space, Size);

677 }

678

681};

682

686

688

689public:

691

693};

694

696 std::unique_ptr BindingInfo;

697

698public:

700

703

706

707 void getAnalysisUsage(AnalysisUsage &AU) const override;

708 bool runOnModule(Module &M) override;

709 void releaseMemory() override;

710};

711

713

714}

715

716#endif

MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL

static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)

DXIL Resource Implicit Binding

This header defines various interfaces for pass management in LLVM.

This file implements a map that provides insertion order iteration.

This file defines the SmallVector class.

Represent the analysis usage information of a pass.

This class represents a function call, abstracting a target machine's calling convention.

Definition DXILResource.h:599

LLVM_ABI DXILResourceMap run(Module &M, ModuleAnalysisManager &AM)

Gather resource info for the module M.

DXILResourceMap Result

Definition DXILResource.h:605

Definition DXILResource.h:684

DXILResourceBindingInfo Result

Definition DXILResource.h:690

LLVM_ABI DXILResourceBindingInfo run(Module &M, ModuleAnalysisManager &AM)

Definition DXILResource.h:659

bool hasOverlappingBinding() const

Definition DXILResource.h:671

bool hasImplicitBinding() const

Definition DXILResource.h:669

friend class DXILResourceBindingWrapperPass

Definition DXILResource.h:680

void setHasImplicitBinding(bool Value)

Definition DXILResource.h:670

std::optional< uint32_t > findAvailableBinding(dxil::ResourceClass RC, uint32_t Space, int32_t Size)

Definition DXILResource.h:674

friend class DXILResourceBindingAnalysis

Definition DXILResource.h:679

void setHasOverlappingBinding(bool Value)

Definition DXILResource.h:672

const DXILResourceBindingInfo & getBindingInfo() const

Definition DXILResource.h:705

DXILResourceBindingInfo & getBindingInfo()

Definition DXILResource.h:704

~DXILResourceBindingWrapperPass() override

DXILResourceBindingWrapperPass()

static char ID

Definition DXILResource.h:699

Definition DXILResource.h:490

iterator uav_begin()

Definition DXILResource.h:544

const_iterator sampler_end() const

Definition DXILResource.h:567

iterator find(const CallInst *Key)

Definition DXILResource.h:525

bool hasInvalidCounterDirection() const

Definition DXILResource.h:590

const_iterator find(const CallInst *Key) const

Definition DXILResource.h:530

iterator_range< iterator > samplers()

Definition DXILResource.h:568

iterator_range< const_iterator > uavs() const

Definition DXILResource.h:549

friend class DXILResourceAnalysis

Definition DXILResource.h:595

const_iterator cbuffer_end() const

Definition DXILResource.h:556

iterator_range< const_iterator > srvs() const

Definition DXILResource.h:540

bool empty() const

Definition DXILResource.h:523

call_iterator call_begin()

Definition DXILResource.h:584

iterator srv_end()

Definition DXILResource.h:537

const_iterator uav_begin() const

Definition DXILResource.h:545

const_iterator begin() const

Definition DXILResource.h:519

iterator_range< const_iterator > samplers() const

Definition DXILResource.h:571

LLVM_ABI void print(raw_ostream &OS, DXILResourceTypeMap &DRTM, const DataLayout &DL) const

call_iterator call_end()

Definition DXILResource.h:585

const_iterator srv_begin() const

Definition DXILResource.h:536

iterator_range< iterator > srvs()

Definition DXILResource.h:539

iterator cbuffer_end()

Definition DXILResource.h:555

iterator_range< iterator > cbuffers()

Definition DXILResource.h:557

iterator_range< iterator > uavs()

Definition DXILResource.h:548

iterator_range< call_iterator > calls()

Definition DXILResource.h:586

iterator cbuffer_begin()

Definition DXILResource.h:553

iterator sampler_end()

Definition DXILResource.h:566

const_iterator uav_end() const

Definition DXILResource.h:547

iterator begin()

Definition DXILResource.h:518

const_iterator sampler_begin() const

Definition DXILResource.h:565

iterator srv_begin()

Definition DXILResource.h:535

SmallVector< dxil::ResourceInfo >::iterator iterator

Definition DXILResource.h:515

iterator uav_end()

Definition DXILResource.h:546

friend class DXILResourceWrapperPass

Definition DXILResource.h:596

const_iterator cbuffer_begin() const

Definition DXILResource.h:554

iterator sampler_begin()

Definition DXILResource.h:564

iterator end()

Definition DXILResource.h:520

const_iterator srv_end() const

Definition DXILResource.h:538

iterator_range< const_iterator > cbuffers() const

Definition DXILResource.h:560

SmallVector< dxil::ResourceInfo >::const_iterator const_iterator

Definition DXILResource.h:516

const_iterator end() const

Definition DXILResource.h:521

DXILResourcePrinterPass(raw_ostream &OS)

Definition DXILResource.h:616

static bool isRequired()

Definition DXILResource.h:620

LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)

Definition DXILResource.h:458

DXILResourceTypeMap run(Module &M, ModuleAnalysisManager &AM)

Definition DXILResource.h:466

DXILResourceTypeMap Result

Definition DXILResource.h:464

Definition DXILResource.h:441

dxil::ResourceTypeInfo & operator[](TargetExtType *Ty)

Definition DXILResource.h:448

LLVM_ABI bool invalidate(Module &M, const PreservedAnalyses &PA, ModuleAnalysisManager::Invalidator &Inv)

DXILResourceTypeWrapperPass()

DXILResourceTypeMap & getResourceTypeMap()

Definition DXILResource.h:482

static char ID

Definition DXILResource.h:479

const DXILResourceTypeMap & getResourceTypeMap() const

Definition DXILResource.h:483

DXILResourceMap & getResourceMap()

Definition DXILResource.h:634

DXILResourceWrapperPass()

~DXILResourceWrapperPass() override

static char ID

Definition DXILResource.h:628

const DXILResourceMap & getResourceMap() const

Definition DXILResource.h:633

A parsed version of the target data layout string in and methods for querying it.

DenseMapIterator< KeyT, ValueT, KeyInfoT, BucketT > iterator

This is an important class for using LLVM in a threaded context.

ModulePass class - This class is used to implement unstructured interprocedural optimizations and ana...

A Module instance is used to store all the information related to an LLVM module.

A set of analyses that are preserved following a run of a transformation pass.

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.

Class to represent struct types.

Class to represent target extensions types, which are generally unintrospectable from target-independ...

Type * getTypeParameter(unsigned i) const

unsigned getIntParameter(unsigned i) const

Type(LLVMContext &C, TypeID tid)

LLVM Value Representation.

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

AnyResourceExtType()=delete

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

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

FeedbackTextureExtType()=delete

static bool classof(const Type *T)

Definition DXILResource.h:162

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

dxil::ResourceKind getDimension() const

Definition DXILResource.h:131

MSTextureExtType(const MSTextureExtType &)=delete

static bool classof(const TargetExtType *T)

Definition DXILResource.h:135

MSTextureExtType()=delete

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

bool isSigned() const

Definition DXILResource.h:130

bool isWriteable() const

Definition DXILResource.h:128

MSTextureExtType & operator=(const MSTextureExtType &)=delete

static bool classof(const TargetExtType *T)

Definition DXILResource.h:257

PaddingExtType & operator=(const PaddingExtType &)=delete

PaddingExtType(const PaddingExtType &)=delete

unsigned getNumBytes() const

Definition DXILResource.h:255

static bool classof(const Type *T)

Definition DXILResource.h:260

static bool classof(const TargetExtType *T)

Definition DXILResource.h:63

bool isStructured() const

Definition DXILResource.h:49

bool isWriteable() const

Definition DXILResource.h:60

RawBufferExtType()=delete

RawBufferExtType(const RawBufferExtType &)=delete

static bool classof(const Type *T)

Definition DXILResource.h:66

RawBufferExtType & operator=(const RawBufferExtType &)=delete

bool isROV() const

Definition DXILResource.h:61

Type * getResourceType() const

Definition DXILResource.h:57

StringRef getName() const

Definition DXILResource.h:415

bool operator<(const ResourceInfo &RHS) const

Definition DXILResource.h:429

bool operator!=(const ResourceInfo &RHS) const

Definition DXILResource.h:428

TargetExtType * getHandleTy() const

Definition DXILResource.h:414

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

bool hasSymbol() const

Definition DXILResource.h:417

ResourceInfo(uint32_t RecordID, uint32_t Space, uint32_t LowerBound, uint32_t Size, TargetExtType *HandleTy, StringRef Name="", GlobalVariable *Symbol=nullptr)

Definition DXILResource.h:401

void setBindingID(unsigned ID)

Definition DXILResource.h:407

bool operator==(const ResourceInfo &RHS) const

Definition DXILResource.h:424

const ResourceBinding & getBinding() const

Definition DXILResource.h:413

LLVM_ABI GlobalVariable * createSymbol(Module &M, StructType *Ty)

bool GloballyCoherent

Definition DXILResource.h:398

bool hasCounter() const

Definition DXILResource.h:409

LLVM_ABI MDTuple * getAsMetadata(Module &M, dxil::ResourceTypeInfo &RTI) const

ResourceCounterDirection CounterDirection

Definition DXILResource.h:399

Definition DXILResource.h:267

dxil::ResourceClass getResourceClass() const

Definition DXILResource.h:344

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 ResourceTypeInfo(TargetExtType *HandleTy, const dxil::ResourceClass RC, const dxil::ResourceKind Kind)

LLVM_ABI bool isCBuffer() const

LLVM_ABI TypedInfo getTyped() const

bool operator!=(const ResourceTypeInfo &RHS) const

Definition DXILResource.h:348

LLVM_ABI StructType * createElementStruct(StringRef CBufferName="")

TargetExtType * getHandleTy() const

Definition DXILResource.h:323

LLVM_ABI bool isFeedback() const

ResourceTypeInfo(TargetExtType *HandleTy)

Definition DXILResource.h:320

LLVM_ABI UAVInfo getUAV() const

LLVM_ABI StructInfo getStruct(const DataLayout &DL) const

LLVM_ABI bool isStruct() const

LLVM_ABI dxil::SamplerFeedbackType getFeedbackType() const

LLVM_ABI bool operator==(const ResourceTypeInfo &RHS) const

dxil::ResourceKind getResourceKind() const

Definition DXILResource.h:345

LLVM_ABI void print(raw_ostream &OS, const DataLayout &DL) const

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

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

bool isWriteable() const

Definition DXILResource.h:103

TextureExtType & operator=(const TextureExtType &)=delete

TextureExtType(const TextureExtType &)=delete

static bool classof(const Type *T)

Definition DXILResource.h:113

bool isSigned() const

Definition DXILResource.h:105

bool isROV() const

Definition DXILResource.h:104

Type * getResourceType() const

Definition DXILResource.h:80

bool isROV() const

Definition DXILResource.h:82

bool isSigned() const

Definition DXILResource.h:83

TypedBufferExtType & operator=(const TypedBufferExtType &)=delete

TypedBufferExtType()=delete

bool isWriteable() const

Definition DXILResource.h:81

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.

iterator_adaptor_base()=default

A range adaptor for a pair of iterators.

This class implements an extremely fast bulk output stream that can only output to a stream.

unsigned ID

LLVM IR allows to use arbitrary numbers as calling convention identifiers.

ResourceKind

The kind of resource for an SRV or UAV resource.

ResourceCounterDirection

Definition DXILResource.h:356

@ Invalid

Definition DXILResource.h:360

@ Decrement

Definition DXILResource.h:358

@ Increment

Definition DXILResource.h:357

@ Unknown

Definition DXILResource.h:359

ElementType

The element type of an SRV or UAV resource.

LLVM_ABI StringRef getResourceNameFromBindingCall(CallInst *CI)

This is an optimization pass for GlobalISel generic memory operations.

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()

bool isa(const From &Val)

isa - Return true if the parameter to the template is an instance of one of the template type argu...

LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key

OutputIt move(R &&Range, OutputIt Out)

Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.

decltype(auto) cast(const From &Val)

cast - Return the argument parameter cast to the specified type.

LLVM_ABI ModulePass * createDXILResourceWrapperPassPass()

AnalysisManager< Module > ModuleAnalysisManager

Convenience typedef for the Module analysis manager.

Implement std::hash so that hash_code can be used in STL containers.

A CRTP mix-in that provides informational APIs needed for analysis passes.

A special type used by analysis passes to provide an address that identifies that particular analysis...

Definition DXILResource.h:576

CallInst * operator*() const

Definition DXILResource.h:581

call_iterator(CallMapTy::iterator Iter)

Definition DXILResource.h:578

A CRTP mix-in to automatically provide informational APIs needed for passes.

Definition DXILResource.h:365

bool operator!=(const ResourceBinding &RHS) const

Definition DXILResource.h:375

uint32_t Size

Definition DXILResource.h:369

uint32_t RecordID

Definition DXILResource.h:366

bool operator==(const ResourceBinding &RHS) const

Definition DXILResource.h:371

uint32_t LowerBound

Definition DXILResource.h:368

bool overlapsWith(const ResourceBinding &RHS) const

Definition DXILResource.h:382

bool operator<(const ResourceBinding &RHS) const

Definition DXILResource.h:378

uint32_t Space

Definition DXILResource.h:367

Definition DXILResource.h:277

bool operator==(const StructInfo &RHS) const

Definition DXILResource.h:285

bool operator!=(const StructInfo &RHS) const

Definition DXILResource.h:288

uint32_t AlignLog2

Definition DXILResource.h:283

uint32_t Stride

Definition DXILResource.h:278

bool operator<(const StructInfo &RHS) const

Definition DXILResource.h:289

Definition DXILResource.h:294

dxil::ElementType DXILStorageTy

Definition DXILResource.h:296

uint32_t ElementCount

Definition DXILResource.h:297

bool operator<(const TypedInfo &RHS) const

Definition DXILResource.h:304

bool operator==(const TypedInfo &RHS) const

Definition DXILResource.h:299

dxil::ElementType ElementTy

Definition DXILResource.h:295

bool operator!=(const TypedInfo &RHS) const

Definition DXILResource.h:303

Definition DXILResource.h:269

bool IsROV

Definition DXILResource.h:270

bool operator!=(const UAVInfo &RHS) const

Definition DXILResource.h:273

bool operator==(const UAVInfo &RHS) const

Definition DXILResource.h:272

bool operator<(const UAVInfo &RHS) const

Definition DXILResource.h:274