diff --git a/llvm/lib/Target/DirectX/DXILResource.h b/llvm/lib/Target/DirectX/DXILResource.h --- a/llvm/lib/Target/DirectX/DXILResource.h +++ b/llvm/lib/Target/DirectX/DXILResource.h @@ -52,7 +52,7 @@ uint32_t RangeSize; ResourceBase(uint32_t I, FrontendResource R); - void write(LLVMContext &Ctx, MutableArrayRef Entries); + void write(LLVMContext &Ctx, MutableArrayRef Entries) const; void print(raw_ostream &O, StringRef IDPrefix, StringRef BindingPrefix) const; @@ -82,7 +82,7 @@ }; static StringRef getKindName(Kinds Kind); - static void printKind(Kinds Kind, unsigned alignment, raw_ostream &OS, + static void printKind(Kinds Kind, unsigned Alignment, raw_ostream &OS, bool SRV = false, bool HasCounter = false, uint32_t SampleCount = 0); @@ -113,7 +113,7 @@ static StringRef getComponentTypeName(ComponentType CompType); static void printComponentType(Kinds Kind, ComponentType CompType, - unsigned alignment, raw_ostream &OS); + unsigned Alignment, raw_ostream &OS); public: struct ExtendedProperties { @@ -128,7 +128,7 @@ Atomic64Use }; - MDNode *write(LLVMContext &Ctx); + MDNode *write(LLVMContext &Ctx) const; }; }; @@ -144,7 +144,7 @@ public: UAVResource(uint32_t I, FrontendResource R); - MDNode *write(); + MDNode *write() const; void print(raw_ostream &O) const; }; @@ -159,8 +159,7 @@ public: void collect(Module &M); - - void write(Module &M); + void write(Module &M) const; void print(raw_ostream &O) const; LLVM_DUMP_METHOD void dump() const; }; diff --git a/llvm/lib/Target/DirectX/DXILResource.cpp b/llvm/lib/Target/DirectX/DXILResource.cpp --- a/llvm/lib/Target/DirectX/DXILResource.cpp +++ b/llvm/lib/Target/DirectX/DXILResource.cpp @@ -99,21 +99,21 @@ } void ResourceBase::printComponentType(Kinds Kind, ComponentType CompType, - unsigned alignment, raw_ostream &OS) { + unsigned Alignment, raw_ostream &OS) { switch (Kind) { default: // TODO: add vector size. - OS << right_justify(getComponentTypeName(CompType), alignment); + OS << right_justify(getComponentTypeName(CompType), Alignment); break; case Kinds::RawBuffer: - OS << right_justify("byte", alignment); + OS << right_justify("byte", Alignment); break; case Kinds::StructuredBuffer: - OS << right_justify("struct", alignment); + OS << right_justify("struct", Alignment); break; case Kinds::CBuffer: case Kinds::Sampler: - OS << right_justify("NA", alignment); + OS << right_justify("NA", Alignment); break; case Kinds::Invalid: case Kinds::NumEntries: @@ -165,37 +165,37 @@ } } -void ResourceBase::printKind(Kinds Kind, unsigned alignment, raw_ostream &OS, +void ResourceBase::printKind(Kinds Kind, unsigned Alignment, raw_ostream &OS, bool SRV, bool HasCounter, uint32_t SampleCount) { switch (Kind) { default: - OS << right_justify(getKindName(Kind), alignment); + OS << right_justify(getKindName(Kind), Alignment); break; case Kinds::RawBuffer: case Kinds::StructuredBuffer: if (SRV) - OS << right_justify("r/o", alignment); + OS << right_justify("r/o", Alignment); else { if (!HasCounter) - OS << right_justify("r/w", alignment); + OS << right_justify("r/w", Alignment); else - OS << right_justify("r/w+cnt", alignment); + OS << right_justify("r/w+cnt", Alignment); } break; case Kinds::TypedBuffer: - OS << right_justify("buf", alignment); + OS << right_justify("buf", Alignment); break; case Kinds::Texture2DMS: case Kinds::Texture2DMSArray: { - std::string dimName = getKindName(Kind).str(); + std::string DimName = getKindName(Kind).str(); if (SampleCount) - dimName += std::to_string(SampleCount); - OS << right_justify(dimName, alignment); + DimName += std::to_string(SampleCount); + OS << right_justify(DimName, Alignment); } break; case Kinds::CBuffer: case Kinds::Sampler: - OS << right_justify("NA", alignment); + OS << right_justify("NA", Alignment); break; case Kinds::Invalid: case Kinds::NumEntries: @@ -287,7 +287,7 @@ ExtProps.ElementType = ElTy; } -MDNode *ResourceBase::ExtendedProperties::write(LLVMContext &Ctx) { +MDNode *ResourceBase::ExtendedProperties::write(LLVMContext &Ctx) const { IRBuilder<> B(Ctx); SmallVector Entries; if (ElementType) { @@ -302,7 +302,7 @@ } void ResourceBase::write(LLVMContext &Ctx, - MutableArrayRef Entries) { + MutableArrayRef Entries) const { IRBuilder<> B(Ctx); Entries[0] = ConstantAsMetadata::get(B.getInt32(ID)); Entries[1] = ConstantAsMetadata::get(GV); @@ -312,7 +312,7 @@ Entries[5] = ConstantAsMetadata::get(B.getInt32(RangeSize)); } -MDNode *UAVResource::write() { +MDNode *UAVResource::write() const { auto &Ctx = GV->getContext(); IRBuilder<> B(Ctx); Metadata *Entries[11]; @@ -326,7 +326,7 @@ return MDNode::get(Ctx, Entries); } -void Resources::write(Module &M) { +void Resources::write(Module &M) const { Metadata *ResourceMDs[4] = {nullptr, nullptr, nullptr, nullptr}; SmallVector UAVMDs; for (auto &UAV : UAVs) diff --git a/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp b/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp --- a/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp +++ b/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp @@ -46,7 +46,8 @@ ValVerMD.update(VersionTuple(1, 0)); dxil::createShaderModelMD(M); - dxil::Resources &Res = getAnalysis().getDXILResource(); + const dxil::Resources &Res = + getAnalysis().getDXILResource(); Res.write(M); return false; }