[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
This commit is contained in:
parent
d1b6c1b1a9
commit
1fc78d66ea
@ -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)
|
||||
|
||||
@ -52,7 +52,7 @@ protected:
|
||||
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 @@ protected:
|
||||
};
|
||||
|
||||
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 @@ protected:
|
||||
|
||||
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 @@ public:
|
||||
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;
|
||||
};
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user