[llvm] 1fc78d6 - [DirectX backend] [NFC] Change Resources::write to const.
Xiang Li via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 13 12:38:23 PDT 2022
Author: Xiang Li
Date: 2022-10-13T12:38:12-07:00
New Revision: 1fc78d66eac164e2bc274a8628b266237bbd9fb3
URL: https://github.com/llvm/llvm-project/commit/1fc78d66eac164e2bc274a8628b266237bbd9fb3
DIFF: https://github.com/llvm/llvm-project/commit/1fc78d66eac164e2bc274a8628b266237bbd9fb3.diff
LOG: [DirectX backend] [NFC] Change Resources::write to const.
Change Resources::write to const.
Also fix parameter name.
Reviewed By: beanz
Differential Revision: https://reviews.llvm.org/D135705
Added:
Modified:
llvm/lib/Target/DirectX/DXILResource.cpp
llvm/lib/Target/DirectX/DXILResource.h
llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/DirectX/DXILResource.cpp b/llvm/lib/Target/DirectX/DXILResource.cpp
index 0527430763d24..8aeda1e499afc 100644
--- a/llvm/lib/Target/DirectX/DXILResource.cpp
+++ b/llvm/lib/Target/DirectX/DXILResource.cpp
@@ -99,21 +99,21 @@ StringRef ResourceBase::getComponentTypeName(ComponentType CompType) {
}
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 @@ StringRef ResourceBase::getKindName(Kinds Kind) {
}
}
-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 @@ void UAVResource::parseSourceType(StringRef S) {
ExtProps.ElementType = ElTy;
}
-MDNode *ResourceBase::ExtendedProperties::write(LLVMContext &Ctx) {
+MDNode *ResourceBase::ExtendedProperties::write(LLVMContext &Ctx) const {
IRBuilder<> B(Ctx);
SmallVector<Metadata *> Entries;
if (ElementType) {
@@ -302,7 +302,7 @@ MDNode *ResourceBase::ExtendedProperties::write(LLVMContext &Ctx) {
}
void ResourceBase::write(LLVMContext &Ctx,
- MutableArrayRef<Metadata *> Entries) {
+ MutableArrayRef<Metadata *> Entries) const {
IRBuilder<> B(Ctx);
Entries[0] = ConstantAsMetadata::get(B.getInt32(ID));
Entries[1] = ConstantAsMetadata::get(GV);
@@ -312,7 +312,7 @@ void ResourceBase::write(LLVMContext &Ctx,
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 @@ MDNode *UAVResource::write() {
return MDNode::get(Ctx, Entries);
}
-void Resources::write(Module &M) {
+void Resources::write(Module &M) const {
Metadata *ResourceMDs[4] = {nullptr, nullptr, nullptr, nullptr};
SmallVector<Metadata *> UAVMDs;
for (auto &UAV : UAVs)
diff --git a/llvm/lib/Target/DirectX/DXILResource.h b/llvm/lib/Target/DirectX/DXILResource.h
index 792decb6bbe8c..d8ea9bfbdb314 100644
--- a/llvm/lib/Target/DirectX/DXILResource.h
+++ b/llvm/lib/Target/DirectX/DXILResource.h
@@ -52,7 +52,7 @@ class ResourceBase {
uint32_t RangeSize;
ResourceBase(uint32_t I, FrontendResource R);
- void write(LLVMContext &Ctx, MutableArrayRef<Metadata *> Entries);
+ void write(LLVMContext &Ctx, MutableArrayRef<Metadata *> Entries) const;
void print(raw_ostream &O, StringRef IDPrefix, StringRef BindingPrefix) const;
@@ -82,7 +82,7 @@ class ResourceBase {
};
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 @@ class ResourceBase {
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 @@ class ResourceBase {
Atomic64Use
};
- MDNode *write(LLVMContext &Ctx);
+ MDNode *write(LLVMContext &Ctx) const;
};
};
@@ -144,7 +144,7 @@ class UAVResource : public ResourceBase {
public:
UAVResource(uint32_t I, FrontendResource R);
- MDNode *write();
+ MDNode *write() const;
void print(raw_ostream &O) const;
};
@@ -159,8 +159,7 @@ class Resources {
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/DXILTranslateMetadata.cpp b/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
index fd5b740da0bb5..37074ff88ce23 100644
--- a/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
+++ b/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
@@ -46,7 +46,8 @@ bool DXILTranslateMetadata::runOnModule(Module &M) {
ValVerMD.update(VersionTuple(1, 0));
dxil::createShaderModelMD(M);
- dxil::Resources &Res = getAnalysis<DXILResourceWrapper>().getDXILResource();
+ const dxil::Resources &Res =
+ getAnalysis<DXILResourceWrapper>().getDXILResource();
Res.write(M);
return false;
}
More information about the llvm-commits
mailing list