[llvm] [NFC][HLSL] Rename ResourceBinding Types (PR #134165)
Ashley Coleman via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 3 12:25:07 PDT 2025
https://github.com/V-FEXrt updated https://github.com/llvm/llvm-project/pull/134165
>From 2ec3db0109672933df3ac8f940a57f83799415df Mon Sep 17 00:00:00 2001
From: Ashley Coleman <ascoleman at microsoft.com>
Date: Wed, 2 Apr 2025 16:28:47 -0600
Subject: [PATCH 1/2] [NFC][HLSL] Rename ResourceBinding Types
---
llvm/include/llvm/Analysis/DXILResource.h | 42 +++---
llvm/lib/Analysis/DXILResource.cpp | 65 +++++-----
llvm/lib/Passes/PassRegistry.def | 6 +-
.../lib/Target/DirectX/DXContainerGlobals.cpp | 26 ++--
llvm/lib/Target/DirectX/DXILOpLowering.cpp | 10 +-
llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp | 32 ++---
.../Target/DirectX/DXILTranslateMetadata.cpp | 12 +-
.../DXILResource/buffer-frombinding.ll | 2 +-
llvm/unittests/Analysis/DXILResourceTest.cpp | 120 +++++++++---------
.../DirectX/UniqueResourceFromUseTests.cpp | 10 +-
10 files changed, 157 insertions(+), 168 deletions(-)
diff --git a/llvm/include/llvm/Analysis/DXILResource.h b/llvm/include/llvm/Analysis/DXILResource.h
index d399457e16916..6a7be779cb2a3 100644
--- a/llvm/include/llvm/Analysis/DXILResource.h
+++ b/llvm/include/llvm/Analysis/DXILResource.h
@@ -326,7 +326,7 @@ class ResourceTypeInfo {
//===----------------------------------------------------------------------===//
-class ResourceBindingInfo {
+class ResourceInfo {
public:
struct ResourceBinding {
uint32_t RecordID;
@@ -353,9 +353,9 @@ class ResourceBindingInfo {
GlobalVariable *Symbol = nullptr;
public:
- ResourceBindingInfo(uint32_t RecordID, uint32_t Space, uint32_t LowerBound,
- uint32_t Size, TargetExtType *HandleTy,
- GlobalVariable *Symbol = nullptr)
+ ResourceInfo(uint32_t RecordID, uint32_t Space, uint32_t LowerBound,
+ uint32_t Size, TargetExtType *HandleTy,
+ GlobalVariable *Symbol = nullptr)
: Binding{RecordID, Space, LowerBound, Size}, HandleTy(HandleTy),
Symbol(Symbol) {}
@@ -372,14 +372,12 @@ class ResourceBindingInfo {
std::pair<uint32_t, uint32_t>
getAnnotateProps(Module &M, dxil::ResourceTypeInfo &RTI) const;
- bool operator==(const ResourceBindingInfo &RHS) const {
+ bool operator==(const ResourceInfo &RHS) const {
return std::tie(Binding, HandleTy, Symbol) ==
std::tie(RHS.Binding, RHS.HandleTy, RHS.Symbol);
}
- bool operator!=(const ResourceBindingInfo &RHS) const {
- return !(*this == RHS);
- }
- bool operator<(const ResourceBindingInfo &RHS) const {
+ bool operator!=(const ResourceInfo &RHS) const { return !(*this == RHS); }
+ bool operator<(const ResourceInfo &RHS) const {
return Binding < RHS.Binding;
}
@@ -441,7 +439,7 @@ ModulePass *createDXILResourceTypeWrapperPassPass();
//===----------------------------------------------------------------------===//
class DXILBindingMap {
- SmallVector<dxil::ResourceBindingInfo> Infos;
+ SmallVector<dxil::ResourceInfo> Infos;
DenseMap<CallInst *, unsigned> CallMap;
unsigned FirstUAV = 0;
unsigned FirstCBuffer = 0;
@@ -451,8 +449,8 @@ class DXILBindingMap {
void populate(Module &M, DXILResourceTypeMap &DRTM);
public:
- using iterator = SmallVector<dxil::ResourceBindingInfo>::iterator;
- using const_iterator = SmallVector<dxil::ResourceBindingInfo>::const_iterator;
+ using iterator = SmallVector<dxil::ResourceInfo>::iterator;
+ using const_iterator = SmallVector<dxil::ResourceInfo>::const_iterator;
iterator begin() { return Infos.begin(); }
const_iterator begin() const { return Infos.begin(); }
@@ -466,12 +464,12 @@ class DXILBindingMap {
return Pos == CallMap.end() ? Infos.end() : (Infos.begin() + Pos->second);
}
- /// Resolves a resource handle into a vector of ResourceBindingInfos that
+ /// Resolves a resource handle into a vector of ResourceInfos that
/// represent the possible unique creations of the handle. Certain cases are
/// ambiguous so multiple creation instructions may be returned. The resulting
- /// ResourceBindingInfo can be used to depuplicate unique handles that
+ /// ResourceInfo can be used to depuplicate unique handles that
/// reference the same resource
- SmallVector<dxil::ResourceBindingInfo> findByUse(const Value *Key) const;
+ SmallVector<dxil::ResourceInfo> findByUse(const Value *Key) const;
const_iterator find(const CallInst *Key) const {
auto Pos = CallMap.find(Key);
@@ -521,13 +519,12 @@ class DXILBindingMap {
void print(raw_ostream &OS, DXILResourceTypeMap &DRTM,
const DataLayout &DL) const;
- friend class DXILResourceBindingAnalysis;
+ friend class DXILResourceAnalysis;
friend class DXILResourceBindingWrapperPass;
};
-class DXILResourceBindingAnalysis
- : public AnalysisInfoMixin<DXILResourceBindingAnalysis> {
- friend AnalysisInfoMixin<DXILResourceBindingAnalysis>;
+class DXILResourceAnalysis : public AnalysisInfoMixin<DXILResourceAnalysis> {
+ friend AnalysisInfoMixin<DXILResourceAnalysis>;
static AnalysisKey Key;
@@ -538,13 +535,12 @@ class DXILResourceBindingAnalysis
DXILBindingMap run(Module &M, ModuleAnalysisManager &AM);
};
-/// Printer pass for the \c DXILResourceBindingAnalysis results.
-class DXILResourceBindingPrinterPass
- : public PassInfoMixin<DXILResourceBindingPrinterPass> {
+/// Printer pass for the \c DXILResourceAnalysis results.
+class DXILResourcePrinterPass : public PassInfoMixin<DXILResourcePrinterPass> {
raw_ostream &OS;
public:
- explicit DXILResourceBindingPrinterPass(raw_ostream &OS) : OS(OS) {}
+ explicit DXILResourcePrinterPass(raw_ostream &OS) : OS(OS) {}
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
diff --git a/llvm/lib/Analysis/DXILResource.cpp b/llvm/lib/Analysis/DXILResource.cpp
index 22afb4cba6f26..8f2cae1f53f70 100644
--- a/llvm/lib/Analysis/DXILResource.cpp
+++ b/llvm/lib/Analysis/DXILResource.cpp
@@ -531,8 +531,8 @@ void ResourceTypeInfo::print(raw_ostream &OS, const DataLayout &DL) const {
}
}
-GlobalVariable *ResourceBindingInfo::createSymbol(Module &M, StructType *Ty,
- StringRef Name) {
+GlobalVariable *ResourceInfo::createSymbol(Module &M, StructType *Ty,
+ StringRef Name) {
assert(!Symbol && "Symbol has already been created");
Symbol = new GlobalVariable(M, Ty, /*isConstant=*/true,
GlobalValue::ExternalLinkage,
@@ -540,8 +540,8 @@ GlobalVariable *ResourceBindingInfo::createSymbol(Module &M, StructType *Ty,
return Symbol;
}
-MDTuple *ResourceBindingInfo::getAsMetadata(Module &M,
- dxil::ResourceTypeInfo &RTI) const {
+MDTuple *ResourceInfo::getAsMetadata(Module &M,
+ dxil::ResourceTypeInfo &RTI) const {
LLVMContext &Ctx = M.getContext();
const DataLayout &DL = M.getDataLayout();
@@ -610,8 +610,7 @@ MDTuple *ResourceBindingInfo::getAsMetadata(Module &M,
}
std::pair<uint32_t, uint32_t>
-ResourceBindingInfo::getAnnotateProps(Module &M,
- dxil::ResourceTypeInfo &RTI) const {
+ResourceInfo::getAnnotateProps(Module &M, dxil::ResourceTypeInfo &RTI) const {
const DataLayout &DL = M.getDataLayout();
uint32_t ResourceKind = llvm::to_underlying(RTI.getResourceKind());
@@ -658,8 +657,8 @@ ResourceBindingInfo::getAnnotateProps(Module &M,
return {Word0, Word1};
}
-void ResourceBindingInfo::print(raw_ostream &OS, dxil::ResourceTypeInfo &RTI,
- const DataLayout &DL) const {
+void ResourceInfo::print(raw_ostream &OS, dxil::ResourceTypeInfo &RTI,
+ const DataLayout &DL) const {
if (Symbol) {
OS << " Symbol: ";
Symbol->printAsOperand(OS);
@@ -687,8 +686,7 @@ bool DXILResourceTypeMap::invalidate(Module &M, const PreservedAnalyses &PA,
//===----------------------------------------------------------------------===//
void DXILBindingMap::populate(Module &M, DXILResourceTypeMap &DRTM) {
- SmallVector<std::tuple<CallInst *, ResourceBindingInfo, ResourceTypeInfo>>
- CIToInfos;
+ SmallVector<std::tuple<CallInst *, ResourceInfo, ResourceTypeInfo>> CIToInfos;
for (Function &F : M.functions()) {
if (!F.isDeclaration())
@@ -711,10 +709,10 @@ void DXILBindingMap::populate(Module &M, DXILResourceTypeMap &DRTM) {
cast<ConstantInt>(CI->getArgOperand(1))->getZExtValue();
uint32_t Size =
cast<ConstantInt>(CI->getArgOperand(2))->getZExtValue();
- ResourceBindingInfo RBI = ResourceBindingInfo{
- /*RecordID=*/0, Space, LowerBound, Size, HandleTy};
+ ResourceInfo RI =
+ ResourceInfo{/*RecordID=*/0, Space, LowerBound, Size, HandleTy};
- CIToInfos.emplace_back(CI, RBI, RTI);
+ CIToInfos.emplace_back(CI, RI, RTI);
}
break;
@@ -723,18 +721,18 @@ void DXILBindingMap::populate(Module &M, DXILResourceTypeMap &DRTM) {
}
llvm::stable_sort(CIToInfos, [](auto &LHS, auto &RHS) {
- const auto &[LCI, LRBI, LRTI] = LHS;
- const auto &[RCI, RRBI, RRTI] = RHS;
+ const auto &[LCI, LRI, LRTI] = LHS;
+ const auto &[RCI, RRI, RRTI] = RHS;
// Sort by resource class first for grouping purposes, and then by the
// binding and type so we can remove duplicates.
ResourceClass LRC = LRTI.getResourceClass();
ResourceClass RRC = RRTI.getResourceClass();
- return std::tie(LRC, LRBI, LRTI) < std::tie(RRC, RRBI, RRTI);
+ return std::tie(LRC, LRI, LRTI) < std::tie(RRC, RRI, RRTI);
});
- for (auto [CI, RBI, RTI] : CIToInfos) {
- if (Infos.empty() || RBI != Infos.back())
- Infos.push_back(RBI);
+ for (auto [CI, RI, RTI] : CIToInfos) {
+ if (Infos.empty() || RI != Infos.back())
+ Infos.push_back(RI);
CallMap[CI] = Infos.size() - 1;
}
@@ -743,8 +741,8 @@ void DXILBindingMap::populate(Module &M, DXILResourceTypeMap &DRTM) {
FirstUAV = FirstCBuffer = FirstSampler = Size;
uint32_t NextID = 0;
for (unsigned I = 0, E = Size; I != E; ++I) {
- ResourceBindingInfo &RBI = Infos[I];
- ResourceTypeInfo &RTI = DRTM[RBI.getHandleTy()];
+ ResourceInfo &RI = Infos[I];
+ ResourceTypeInfo &RTI = DRTM[RI.getHandleTy()];
if (RTI.isUAV() && FirstUAV == Size) {
FirstUAV = I;
NextID = 0;
@@ -762,7 +760,7 @@ void DXILBindingMap::populate(Module &M, DXILResourceTypeMap &DRTM) {
FirstUAV = std::min({FirstUAV, FirstCBuffer});
// Adjust the resource binding to use the next ID.
- RBI.setBindingID(NextID++);
+ RI.setBindingID(NextID++);
}
}
@@ -770,8 +768,8 @@ void DXILBindingMap::print(raw_ostream &OS, DXILResourceTypeMap &DRTM,
const DataLayout &DL) const {
for (unsigned I = 0, E = Infos.size(); I != E; ++I) {
OS << "Binding " << I << ":\n";
- const dxil::ResourceBindingInfo &RBI = Infos[I];
- RBI.print(OS, DRTM[RBI.getHandleTy()], DL);
+ const dxil::ResourceInfo &RI = Infos[I];
+ RI.print(OS, DRTM[RI.getHandleTy()], DL);
OS << "\n";
}
@@ -782,10 +780,10 @@ void DXILBindingMap::print(raw_ostream &OS, DXILResourceTypeMap &DRTM,
}
}
-SmallVector<dxil::ResourceBindingInfo>
+SmallVector<dxil::ResourceInfo>
DXILBindingMap::findByUse(const Value *Key) const {
if (const PHINode *Phi = dyn_cast<PHINode>(Key)) {
- SmallVector<dxil::ResourceBindingInfo> Children;
+ SmallVector<dxil::ResourceInfo> Children;
for (const Value *V : Phi->operands()) {
Children.append(findByUse(V));
}
@@ -810,7 +808,7 @@ DXILBindingMap::findByUse(const Value *Key) const {
// Check if any of the parameters are the resource we are following. If so
// keep searching. If none of them are return an empty list
const Type *UseType = CI->getType();
- SmallVector<dxil::ResourceBindingInfo> Children;
+ SmallVector<dxil::ResourceInfo> Children;
for (const Value *V : CI->args()) {
if (V->getType() != UseType)
continue;
@@ -824,19 +822,18 @@ DXILBindingMap::findByUse(const Value *Key) const {
//===----------------------------------------------------------------------===//
AnalysisKey DXILResourceTypeAnalysis::Key;
-AnalysisKey DXILResourceBindingAnalysis::Key;
+AnalysisKey DXILResourceAnalysis::Key;
-DXILBindingMap DXILResourceBindingAnalysis::run(Module &M,
- ModuleAnalysisManager &AM) {
+DXILBindingMap DXILResourceAnalysis::run(Module &M, ModuleAnalysisManager &AM) {
DXILBindingMap Data;
DXILResourceTypeMap &DRTM = AM.getResult<DXILResourceTypeAnalysis>(M);
Data.populate(M, DRTM);
return Data;
}
-PreservedAnalyses
-DXILResourceBindingPrinterPass::run(Module &M, ModuleAnalysisManager &AM) {
- DXILBindingMap &DBM = AM.getResult<DXILResourceBindingAnalysis>(M);
+PreservedAnalyses DXILResourcePrinterPass::run(Module &M,
+ ModuleAnalysisManager &AM) {
+ DXILBindingMap &DBM = AM.getResult<DXILResourceAnalysis>(M);
DXILResourceTypeMap &DRTM = AM.getResult<DXILResourceTypeAnalysis>(M);
DBM.print(OS, DRTM, M.getDataLayout());
@@ -895,7 +892,7 @@ LLVM_DUMP_METHOD
void DXILResourceBindingWrapperPass::dump() const { print(dbgs(), nullptr); }
#endif
-INITIALIZE_PASS(DXILResourceBindingWrapperPass, "dxil-resource-binding",
+INITIALIZE_PASS(DXILResourceBindingWrapperPass, "dxil-resource",
"DXIL Resource Binding Analysis", false, true)
char DXILResourceBindingWrapperPass::ID = 0;
diff --git a/llvm/lib/Passes/PassRegistry.def b/llvm/lib/Passes/PassRegistry.def
index 510a505995304..a34ea45bad7de 100644
--- a/llvm/lib/Passes/PassRegistry.def
+++ b/llvm/lib/Passes/PassRegistry.def
@@ -22,7 +22,7 @@ MODULE_ANALYSIS("callgraph", CallGraphAnalysis())
MODULE_ANALYSIS("collector-metadata", CollectorMetadataAnalysis())
MODULE_ANALYSIS("ctx-prof-analysis", CtxProfAnalysis())
MODULE_ANALYSIS("dxil-metadata", DXILMetadataAnalysis())
-MODULE_ANALYSIS("dxil-resource-binding", DXILResourceBindingAnalysis())
+MODULE_ANALYSIS("dxil-resource", DXILResourceAnalysis())
MODULE_ANALYSIS("dxil-resource-type", DXILResourceTypeAnalysis())
MODULE_ANALYSIS("inline-advisor", InlineAdvisorAnalysis())
MODULE_ANALYSIS("ir-similarity", IRSimilarityAnalysis())
@@ -128,8 +128,8 @@ MODULE_PASS("print-must-be-executed-contexts",
MODULE_PASS("print-profile-summary", ProfileSummaryPrinterPass(errs()))
MODULE_PASS("print-stack-safety", StackSafetyGlobalPrinterPass(errs()))
MODULE_PASS("print<dxil-metadata>", DXILMetadataAnalysisPrinterPass(errs()))
-MODULE_PASS("print<dxil-resource-binding>",
- DXILResourceBindingPrinterPass(errs()))
+MODULE_PASS("print<dxil-resource>",
+ DXILResourcePrinterPass(errs()))
MODULE_PASS("print<inline-advisor>", InlineAdvisorAnalysisPrinterPass(errs()))
MODULE_PASS("print<module-debuginfo>", ModuleDebugInfoPrinterPass(errs()))
MODULE_PASS("print<reg-usage>", PhysicalRegisterUsageInfoPrinterPass(errs()))
diff --git a/llvm/lib/Target/DirectX/DXContainerGlobals.cpp b/llvm/lib/Target/DirectX/DXContainerGlobals.cpp
index c7a130a1f9c8a..8ab9352986fd9 100644
--- a/llvm/lib/Target/DirectX/DXContainerGlobals.cpp
+++ b/llvm/lib/Target/DirectX/DXContainerGlobals.cpp
@@ -187,7 +187,7 @@ void DXContainerGlobals::addResourcesForPSV(Module &M, PSVRuntimeInfo &PSV) {
getAnalysis<DXILResourceTypeWrapperPass>().getResourceTypeMap();
auto MakeBinding =
- [](const dxil::ResourceBindingInfo::ResourceBinding &Binding,
+ [](const dxil::ResourceInfo::ResourceBinding &Binding,
const dxbc::PSV::ResourceType Type, const dxil::ResourceKind Kind,
const dxbc::PSV::ResourceFlags Flags = dxbc::PSV::ResourceFlags()) {
dxbc::PSV::v2::ResourceBindInfo BindInfo;
@@ -200,24 +200,21 @@ void DXContainerGlobals::addResourcesForPSV(Module &M, PSVRuntimeInfo &PSV) {
return BindInfo;
};
- for (const dxil::ResourceBindingInfo &RBI : DBM.cbuffers()) {
- const dxil::ResourceBindingInfo::ResourceBinding &Binding =
- RBI.getBinding();
+ for (const dxil::ResourceInfo &RI : DBM.cbuffers()) {
+ const dxil::ResourceInfo::ResourceBinding &Binding = RI.getBinding();
PSV.Resources.push_back(MakeBinding(Binding, dxbc::PSV::ResourceType::CBV,
dxil::ResourceKind::CBuffer));
}
- for (const dxil::ResourceBindingInfo &RBI : DBM.samplers()) {
- const dxil::ResourceBindingInfo::ResourceBinding &Binding =
- RBI.getBinding();
+ for (const dxil::ResourceInfo &RI : DBM.samplers()) {
+ const dxil::ResourceInfo::ResourceBinding &Binding = RI.getBinding();
PSV.Resources.push_back(MakeBinding(Binding,
dxbc::PSV::ResourceType::Sampler,
dxil::ResourceKind::Sampler));
}
- for (const dxil::ResourceBindingInfo &RBI : DBM.srvs()) {
- const dxil::ResourceBindingInfo::ResourceBinding &Binding =
- RBI.getBinding();
+ for (const dxil::ResourceInfo &RI : DBM.srvs()) {
+ const dxil::ResourceInfo::ResourceBinding &Binding = RI.getBinding();
- dxil::ResourceTypeInfo &TypeInfo = DRTM[RBI.getHandleTy()];
+ dxil::ResourceTypeInfo &TypeInfo = DRTM[RI.getHandleTy()];
dxbc::PSV::ResourceType ResType;
if (TypeInfo.isStruct())
ResType = dxbc::PSV::ResourceType::SRVStructured;
@@ -229,11 +226,10 @@ void DXContainerGlobals::addResourcesForPSV(Module &M, PSVRuntimeInfo &PSV) {
PSV.Resources.push_back(
MakeBinding(Binding, ResType, TypeInfo.getResourceKind()));
}
- for (const dxil::ResourceBindingInfo &RBI : DBM.uavs()) {
- const dxil::ResourceBindingInfo::ResourceBinding &Binding =
- RBI.getBinding();
+ for (const dxil::ResourceInfo &RI : DBM.uavs()) {
+ const dxil::ResourceInfo::ResourceBinding &Binding = RI.getBinding();
- dxil::ResourceTypeInfo &TypeInfo = DRTM[RBI.getHandleTy()];
+ dxil::ResourceTypeInfo &TypeInfo = DRTM[RI.getHandleTy()];
dxbc::PSV::ResourceType ResType;
if (TypeInfo.getUAV().HasCounter)
ResType = dxbc::PSV::ResourceType::UAVStructuredWithCounter;
diff --git a/llvm/lib/Target/DirectX/DXILOpLowering.cpp b/llvm/lib/Target/DirectX/DXILOpLowering.cpp
index dff9f3e03079e..096157e6b90e9 100644
--- a/llvm/lib/Target/DirectX/DXILOpLowering.cpp
+++ b/llvm/lib/Target/DirectX/DXILOpLowering.cpp
@@ -268,7 +268,7 @@ class OpLowerer {
auto *It = DBM.find(CI);
assert(It != DBM.end() && "Resource not in map?");
- dxil::ResourceBindingInfo &RI = *It;
+ dxil::ResourceInfo &RI = *It;
const auto &Binding = RI.getBinding();
dxil::ResourceClass RC = DRTM[RI.getHandleTy()].getResourceClass();
@@ -306,7 +306,7 @@ class OpLowerer {
auto *It = DBM.find(CI);
assert(It != DBM.end() && "Resource not in map?");
- dxil::ResourceBindingInfo &RI = *It;
+ dxil::ResourceInfo &RI = *It;
const auto &Binding = RI.getBinding();
dxil::ResourceTypeInfo &RTI = DRTM[RI.getHandleTy()];
@@ -355,7 +355,7 @@ class OpLowerer {
/// Lower `dx.resource.handlefrombinding` intrinsics depending on the shader
/// model and taking into account binding information from
- /// DXILResourceBindingAnalysis.
+ /// DXILResourceAnalysis.
bool lowerHandleFromBinding(Function &F) {
const Triple &TT = M.getTargetTriple();
if (TT.getDXILVersion() < VersionTuple(1, 6))
@@ -856,14 +856,14 @@ class OpLowerer {
} // namespace
PreservedAnalyses DXILOpLowering::run(Module &M, ModuleAnalysisManager &MAM) {
- DXILBindingMap &DBM = MAM.getResult<DXILResourceBindingAnalysis>(M);
+ DXILBindingMap &DBM = MAM.getResult<DXILResourceAnalysis>(M);
DXILResourceTypeMap &DRTM = MAM.getResult<DXILResourceTypeAnalysis>(M);
bool MadeChanges = OpLowerer(M, DBM, DRTM).lowerIntrinsics();
if (!MadeChanges)
return PreservedAnalyses::all();
PreservedAnalyses PA;
- PA.preserve<DXILResourceBindingAnalysis>();
+ PA.preserve<DXILResourceAnalysis>();
PA.preserve<DXILMetadataAnalysis>();
PA.preserve<ShaderFlagsAnalysis>();
return PA;
diff --git a/llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp b/llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp
index 4d1832f44bb63..2c0c2d4ae39f9 100644
--- a/llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp
+++ b/llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp
@@ -174,12 +174,12 @@ struct FormatResourceDimension
};
struct FormatBindingID
- : public llvm::FormatAdapter<const dxil::ResourceBindingInfo &> {
+ : public llvm::FormatAdapter<const dxil::ResourceInfo &> {
dxil::ResourceClass RC;
- explicit FormatBindingID(const dxil::ResourceBindingInfo &RBI,
+ explicit FormatBindingID(const dxil::ResourceInfo &RI,
const dxil::ResourceTypeInfo &RTI)
- : llvm::FormatAdapter<const dxil::ResourceBindingInfo &>(RBI),
+ : llvm::FormatAdapter<const dxil::ResourceInfo &>(RI),
RC(RTI.getResourceClass()) {}
void format(llvm::raw_ostream &OS, StringRef Style) override {
@@ -188,12 +188,12 @@ struct FormatBindingID
};
struct FormatBindingLocation
- : public llvm::FormatAdapter<const dxil::ResourceBindingInfo &> {
+ : public llvm::FormatAdapter<const dxil::ResourceInfo &> {
dxil::ResourceClass RC;
- explicit FormatBindingLocation(const dxil::ResourceBindingInfo &RBI,
+ explicit FormatBindingLocation(const dxil::ResourceInfo &RI,
const dxil::ResourceTypeInfo &RTI)
- : llvm::FormatAdapter<const dxil::ResourceBindingInfo &>(RBI),
+ : llvm::FormatAdapter<const dxil::ResourceInfo &>(RI),
RC(RTI.getResourceClass()) {}
void format(llvm::raw_ostream &OS, StringRef Style) override {
@@ -205,9 +205,9 @@ struct FormatBindingLocation
};
struct FormatBindingSize
- : public llvm::FormatAdapter<const dxil::ResourceBindingInfo &> {
- explicit FormatBindingSize(const dxil::ResourceBindingInfo &RI)
- : llvm::FormatAdapter<const dxil::ResourceBindingInfo &>(RI) {}
+ : public llvm::FormatAdapter<const dxil::ResourceInfo &> {
+ explicit FormatBindingSize(const dxil::ResourceInfo &RI)
+ : llvm::FormatAdapter<const dxil::ResourceInfo &>(RI) {}
void format(llvm::raw_ostream &OS, StringRef Style) override {
uint32_t Size = Item.getBinding().Size;
@@ -231,17 +231,17 @@ static void prettyPrintResources(raw_ostream &OS, const DXILBindingMap &DBM,
"", "", "", "", "");
// TODO: Do we want to sort these by binding or something like that?
- for (const dxil::ResourceBindingInfo &RBI : DBM) {
- const dxil::ResourceTypeInfo &RTI = DRTM[RBI.getHandleTy()];
+ for (const dxil::ResourceInfo &RI : DBM) {
+ const dxil::ResourceTypeInfo &RTI = DRTM[RI.getHandleTy()];
dxil::ResourceClass RC = RTI.getResourceClass();
- StringRef Name(RBI.getName());
+ StringRef Name(RI.getName());
StringRef Type(getRCName(RC));
StringRef Format(getFormatName(RTI));
FormatResourceDimension Dim(RTI);
- FormatBindingID ID(RBI, RTI);
- FormatBindingLocation Bind(RBI, RTI);
- FormatBindingSize Count(RBI);
+ FormatBindingID ID(RI, RTI);
+ FormatBindingLocation Bind(RI, RTI);
+ FormatBindingSize Count(RI);
OS << formatv("; {0,-30} {1,10} {2,7} {3,11} {4,7} {5,14} {6,9}\n", Name,
Type, Format, Dim, ID, Bind, Count);
}
@@ -250,7 +250,7 @@ static void prettyPrintResources(raw_ostream &OS, const DXILBindingMap &DBM,
PreservedAnalyses DXILPrettyPrinterPass::run(Module &M,
ModuleAnalysisManager &MAM) {
- const DXILBindingMap &DBM = MAM.getResult<DXILResourceBindingAnalysis>(M);
+ const DXILBindingMap &DBM = MAM.getResult<DXILResourceAnalysis>(M);
DXILResourceTypeMap &DRTM = MAM.getResult<DXILResourceTypeAnalysis>(M);
prettyPrintResources(OS, DBM, DRTM);
return PreservedAnalyses::all();
diff --git a/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp b/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
index ed510c5856bf6..abd7a1ebc479a 100644
--- a/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
+++ b/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
@@ -76,18 +76,18 @@ static NamedMDNode *emitResourceMetadata(Module &M, DXILBindingMap &DBM,
DXILResourceTypeMap &DRTM) {
LLVMContext &Context = M.getContext();
- for (ResourceBindingInfo &RI : DBM)
+ for (ResourceInfo &RI : DBM)
if (!RI.hasSymbol())
RI.createSymbol(M, DRTM[RI.getHandleTy()].createElementStruct());
SmallVector<Metadata *> SRVs, UAVs, CBufs, Smps;
- for (const ResourceBindingInfo &RI : DBM.srvs())
+ for (const ResourceInfo &RI : DBM.srvs())
SRVs.push_back(RI.getAsMetadata(M, DRTM[RI.getHandleTy()]));
- for (const ResourceBindingInfo &RI : DBM.uavs())
+ for (const ResourceInfo &RI : DBM.uavs())
UAVs.push_back(RI.getAsMetadata(M, DRTM[RI.getHandleTy()]));
- for (const ResourceBindingInfo &RI : DBM.cbuffers())
+ for (const ResourceInfo &RI : DBM.cbuffers())
CBufs.push_back(RI.getAsMetadata(M, DRTM[RI.getHandleTy()]));
- for (const ResourceBindingInfo &RI : DBM.samplers())
+ for (const ResourceInfo &RI : DBM.samplers())
Smps.push_back(RI.getAsMetadata(M, DRTM[RI.getHandleTy()]));
Metadata *SRVMD = SRVs.empty() ? nullptr : MDNode::get(Context, SRVs);
@@ -381,7 +381,7 @@ static void translateMetadata(Module &M, DXILBindingMap &DBM,
PreservedAnalyses DXILTranslateMetadata::run(Module &M,
ModuleAnalysisManager &MAM) {
- DXILBindingMap &DBM = MAM.getResult<DXILResourceBindingAnalysis>(M);
+ DXILBindingMap &DBM = MAM.getResult<DXILResourceAnalysis>(M);
DXILResourceTypeMap &DRTM = MAM.getResult<DXILResourceTypeAnalysis>(M);
const ModuleShaderFlags &ShaderFlags = MAM.getResult<ShaderFlagsAnalysis>(M);
const dxil::ModuleMetadataInfo MMDI = MAM.getResult<DXILMetadataAnalysis>(M);
diff --git a/llvm/test/Analysis/DXILResource/buffer-frombinding.ll b/llvm/test/Analysis/DXILResource/buffer-frombinding.ll
index a416124221dcb..41737653eaa87 100644
--- a/llvm/test/Analysis/DXILResource/buffer-frombinding.ll
+++ b/llvm/test/Analysis/DXILResource/buffer-frombinding.ll
@@ -1,4 +1,4 @@
-; RUN: opt -S -disable-output -passes="print<dxil-resource-binding>" < %s 2>&1 | FileCheck %s
+; RUN: opt -S -disable-output -passes="print<dxil-resource>" < %s 2>&1 | FileCheck %s
@G = external constant <4 x float>, align 4
diff --git a/llvm/unittests/Analysis/DXILResourceTest.cpp b/llvm/unittests/Analysis/DXILResourceTest.cpp
index b0f6b631a0339..66549067a354c 100644
--- a/llvm/unittests/Analysis/DXILResourceTest.cpp
+++ b/llvm/unittests/Analysis/DXILResourceTest.cpp
@@ -93,14 +93,14 @@ TEST(DXILResource, AnnotationsAndMetadata) {
EXPECT_EQ(RTI.getResourceClass(), ResourceClass::SRV);
EXPECT_EQ(RTI.getResourceKind(), ResourceKind::RawBuffer);
- ResourceBindingInfo RBI(
+ ResourceInfo RI(
/*RecordID=*/0, /*Space=*/0, /*LowerBound=*/0, /*Size=*/1,
RTI.getHandleTy());
- GlobalVariable *GV = RBI.createSymbol(M, RTI.createElementStruct(), "Buffer");
- std::pair<uint32_t, uint32_t> Props = RBI.getAnnotateProps(M, RTI);
+ GlobalVariable *GV = RI.createSymbol(M, RTI.createElementStruct(), "Buffer");
+ std::pair<uint32_t, uint32_t> Props = RI.getAnnotateProps(M, RTI);
EXPECT_EQ(Props.first, 0x0000000bU);
EXPECT_EQ(Props.second, 0U);
- MDTuple *MD = RBI.getAsMetadata(M, RTI);
+ MDTuple *MD = RI.getAsMetadata(M, RTI);
EXPECT_MDEQ(MD, TestMD.get(0, GV, "Buffer", 0, 0, 1, 11, 0, nullptr));
// RWByteAddressBuffer BufferOut : register(u3, space2);
@@ -112,14 +112,14 @@ TEST(DXILResource, AnnotationsAndMetadata) {
EXPECT_EQ(RTI.getUAV().IsROV, false);
EXPECT_EQ(RTI.getResourceKind(), ResourceKind::RawBuffer);
- RBI = ResourceBindingInfo(
+ RI = ResourceInfo(
/*RecordID=*/1, /*Space=*/2, /*LowerBound=*/3, /*Size=*/1,
RTI.getHandleTy());
- GV = RBI.createSymbol(M, RTI.createElementStruct(), "BufferOut");
- Props = RBI.getAnnotateProps(M, RTI);
+ GV = RI.createSymbol(M, RTI.createElementStruct(), "BufferOut");
+ Props = RI.getAnnotateProps(M, RTI);
EXPECT_EQ(Props.first, 0x0000100bU);
EXPECT_EQ(Props.second, 0U);
- MD = RBI.getAsMetadata(M, RTI);
+ MD = RI.getAsMetadata(M, RTI);
EXPECT_MDEQ(MD, TestMD.get(1, GV, "BufferOut", 2, 3, 1, 11, false, false,
false, nullptr));
@@ -135,14 +135,14 @@ TEST(DXILResource, AnnotationsAndMetadata) {
EXPECT_EQ(RTI.getStruct(DL).AlignLog2, Log2(Align(8)));
EXPECT_EQ(RTI.getResourceKind(), ResourceKind::StructuredBuffer);
- RBI = ResourceBindingInfo(
+ RI = ResourceInfo(
/*RecordID=*/0, /*Space=*/0, /*LowerBound=*/0, /*Size=*/1,
RTI.getHandleTy());
- GV = RBI.createSymbol(M, RTI.createElementStruct(), "Buffer0");
- Props = RBI.getAnnotateProps(M, RTI);
+ GV = RI.createSymbol(M, RTI.createElementStruct(), "Buffer0");
+ Props = RI.getAnnotateProps(M, RTI);
EXPECT_EQ(Props.first, 0x0000030cU);
EXPECT_EQ(Props.second, 0x00000010U);
- MD = RBI.getAsMetadata(M, RTI);
+ MD = RI.getAsMetadata(M, RTI);
EXPECT_MDEQ(MD,
TestMD.get(0, GV, "Buffer0", 0, 0, 1, 12, 0, TestMD.get(1, 16)));
@@ -155,14 +155,14 @@ TEST(DXILResource, AnnotationsAndMetadata) {
EXPECT_EQ(RTI.getStruct(DL).AlignLog2, 0u);
EXPECT_EQ(RTI.getResourceKind(), ResourceKind::StructuredBuffer);
- RBI = ResourceBindingInfo(
+ RI = ResourceInfo(
/*RecordID=*/1, /*Space=*/0, /*LowerBound=*/1, /*Size=*/1,
RTI.getHandleTy());
- GV = RBI.createSymbol(M, RTI.createElementStruct(), "Buffer1");
- Props = RBI.getAnnotateProps(M, RTI);
+ GV = RI.createSymbol(M, RTI.createElementStruct(), "Buffer1");
+ Props = RI.getAnnotateProps(M, RTI);
EXPECT_EQ(Props.first, 0x0000000cU);
EXPECT_EQ(Props.second, 0x0000000cU);
- MD = RBI.getAsMetadata(M, RTI);
+ MD = RI.getAsMetadata(M, RTI);
EXPECT_MDEQ(MD,
TestMD.get(1, GV, "Buffer1", 0, 1, 1, 12, 0, TestMD.get(1, 12)));
@@ -177,14 +177,14 @@ TEST(DXILResource, AnnotationsAndMetadata) {
EXPECT_EQ(RTI.getTyped().ElementCount, 4u);
EXPECT_EQ(RTI.getResourceKind(), ResourceKind::Texture2D);
- RBI = ResourceBindingInfo(
+ RI = ResourceInfo(
/*RecordID=*/2, /*Space=*/0, /*LowerBound=*/2, /*Size=*/1,
RTI.getHandleTy());
- GV = RBI.createSymbol(M, RTI.createElementStruct(), "ColorMapTexture");
- Props = RBI.getAnnotateProps(M, RTI);
+ GV = RI.createSymbol(M, RTI.createElementStruct(), "ColorMapTexture");
+ Props = RI.getAnnotateProps(M, RTI);
EXPECT_EQ(Props.first, 0x00000002U);
EXPECT_EQ(Props.second, 0x00000409U);
- MD = RBI.getAsMetadata(M, RTI);
+ MD = RI.getAsMetadata(M, RTI);
EXPECT_MDEQ(MD, TestMD.get(2, GV, "ColorMapTexture", 0, 2, 1, 2, 0,
TestMD.get(0, 9)));
@@ -201,14 +201,14 @@ TEST(DXILResource, AnnotationsAndMetadata) {
EXPECT_EQ(RTI.getMultiSampleCount(), 8u);
EXPECT_EQ(RTI.getResourceKind(), ResourceKind::Texture2DMS);
- RBI = ResourceBindingInfo(
+ RI = ResourceInfo(
/*RecordID=*/0, /*Space=*/0, /*LowerBound=*/0, /*Size=*/1,
RTI.getHandleTy());
- GV = RBI.createSymbol(M, RTI.createElementStruct(), "DepthBuffer");
- Props = RBI.getAnnotateProps(M, RTI);
+ GV = RI.createSymbol(M, RTI.createElementStruct(), "DepthBuffer");
+ Props = RI.getAnnotateProps(M, RTI);
EXPECT_EQ(Props.first, 0x00000003U);
EXPECT_EQ(Props.second, 0x00080109U);
- MD = RBI.getAsMetadata(M, RTI);
+ MD = RI.getAsMetadata(M, RTI);
EXPECT_MDEQ(
MD, TestMD.get(0, GV, "DepthBuffer", 0, 0, 1, 3, 8, TestMD.get(0, 9)));
@@ -222,14 +222,14 @@ TEST(DXILResource, AnnotationsAndMetadata) {
EXPECT_EQ(RTI.getFeedbackType(), SamplerFeedbackType::MinMip);
EXPECT_EQ(RTI.getResourceKind(), ResourceKind::FeedbackTexture2D);
- RBI = ResourceBindingInfo(
+ RI = ResourceInfo(
/*RecordID=*/0, /*Space=*/0, /*LowerBound=*/0, /*Size=*/1,
RTI.getHandleTy());
- GV = RBI.createSymbol(M, RTI.createElementStruct(), "feedbackMinMip");
- Props = RBI.getAnnotateProps(M, RTI);
+ GV = RI.createSymbol(M, RTI.createElementStruct(), "feedbackMinMip");
+ Props = RI.getAnnotateProps(M, RTI);
EXPECT_EQ(Props.first, 0x00001011U);
EXPECT_EQ(Props.second, 0U);
- MD = RBI.getAsMetadata(M, RTI);
+ MD = RI.getAsMetadata(M, RTI);
EXPECT_MDEQ(MD, TestMD.get(0, GV, "feedbackMinMip", 0, 0, 1, 17, false, false,
false, TestMD.get(2, 0)));
@@ -243,14 +243,14 @@ TEST(DXILResource, AnnotationsAndMetadata) {
EXPECT_EQ(RTI.getFeedbackType(), SamplerFeedbackType::MipRegionUsed);
EXPECT_EQ(RTI.getResourceKind(), ResourceKind::FeedbackTexture2DArray);
- RBI = ResourceBindingInfo(
+ RI = ResourceInfo(
/*RecordID=*/0, /*Space=*/0, /*LowerBound=*/0, /*Size=*/1,
RTI.getHandleTy());
- GV = RBI.createSymbol(M, RTI.createElementStruct(), "feedbackMipRegion");
- Props = RBI.getAnnotateProps(M, RTI);
+ GV = RI.createSymbol(M, RTI.createElementStruct(), "feedbackMipRegion");
+ Props = RI.getAnnotateProps(M, RTI);
EXPECT_EQ(Props.first, 0x00001012U);
EXPECT_EQ(Props.second, 0x00000001U);
- MD = RBI.getAsMetadata(M, RTI);
+ MD = RI.getAsMetadata(M, RTI);
EXPECT_MDEQ(MD, TestMD.get(0, GV, "feedbackMipRegion", 0, 0, 1, 18, false,
false, false, TestMD.get(2, 1)));
@@ -268,14 +268,14 @@ TEST(DXILResource, AnnotationsAndMetadata) {
EXPECT_EQ(RTI.getUAV().IsROV, false);
EXPECT_EQ(RTI.getResourceKind(), ResourceKind::Texture2D);
- RBI = ResourceBindingInfo(
+ RI = ResourceInfo(
/*RecordID=*/0, /*Space=*/2, /*LowerBound=*/0, /*Size=*/1,
RTI.getHandleTy());
- GV = RBI.createSymbol(M, RTI.createElementStruct(), "OutputTexture");
- Props = RBI.getAnnotateProps(M, RTI);
+ GV = RI.createSymbol(M, RTI.createElementStruct(), "OutputTexture");
+ Props = RI.getAnnotateProps(M, RTI);
EXPECT_EQ(Props.first, 0x00005002U);
EXPECT_EQ(Props.second, 0x00000204U);
- MD = RBI.getAsMetadata(M, RTI);
+ MD = RI.getAsMetadata(M, RTI);
EXPECT_MDEQ(MD, TestMD.get(0, GV, "OutputTexture", 2, 0, 1, 2, true, false,
false, TestMD.get(0, 4)));
@@ -292,14 +292,14 @@ TEST(DXILResource, AnnotationsAndMetadata) {
EXPECT_EQ(RTI.getTyped().ElementCount, 4u);
EXPECT_EQ(RTI.getResourceKind(), ResourceKind::TypedBuffer);
- RBI = ResourceBindingInfo(
+ RI = ResourceInfo(
/*RecordID=*/0, /*Space=*/0, /*LowerBound=*/0, /*Size=*/1,
RTI.getHandleTy());
- GV = RBI.createSymbol(M, RTI.createElementStruct(), "ROB");
- Props = RBI.getAnnotateProps(M, RTI);
+ GV = RI.createSymbol(M, RTI.createElementStruct(), "ROB");
+ Props = RI.getAnnotateProps(M, RTI);
EXPECT_EQ(Props.first, 0x0000300aU);
EXPECT_EQ(Props.second, 0x00000409U);
- MD = RBI.getAsMetadata(M, RTI);
+ MD = RI.getAsMetadata(M, RTI);
EXPECT_MDEQ(MD, TestMD.get(0, GV, "ROB", 0, 0, 1, 10, false, false, true,
TestMD.get(0, 9)));
@@ -319,14 +319,14 @@ TEST(DXILResource, AnnotationsAndMetadata) {
EXPECT_EQ(RTI.getStruct(DL).AlignLog2, Log2(Align(4)));
EXPECT_EQ(RTI.getResourceKind(), ResourceKind::StructuredBuffer);
- RBI = ResourceBindingInfo(
+ RI = ResourceInfo(
/*RecordID=*/0, /*Space=*/0, /*LowerBound=*/2, /*Size=*/1,
RTI.getHandleTy());
- GV = RBI.createSymbol(M, RTI.createElementStruct(), "g_OutputBuffer");
- Props = RBI.getAnnotateProps(M, RTI);
+ GV = RI.createSymbol(M, RTI.createElementStruct(), "g_OutputBuffer");
+ Props = RI.getAnnotateProps(M, RTI);
EXPECT_EQ(Props.first, 0x0000920cU);
EXPECT_EQ(Props.second, 0x00000014U);
- MD = RBI.getAsMetadata(M, RTI);
+ MD = RI.getAsMetadata(M, RTI);
EXPECT_MDEQ(MD, TestMD.get(0, GV, "g_OutputBuffer", 0, 2, 1, 12, false, true,
false, TestMD.get(1, 20)));
@@ -346,14 +346,14 @@ TEST(DXILResource, AnnotationsAndMetadata) {
EXPECT_EQ(RTI.getMultiSampleCount(), 8u);
EXPECT_EQ(RTI.getResourceKind(), ResourceKind::Texture2DMSArray);
- RBI = ResourceBindingInfo(
+ RI = ResourceInfo(
/*RecordID=*/0, /*Space=*/0, /*LowerBound=*/0, /*Size=*/1,
RTI.getHandleTy());
- GV = RBI.createSymbol(M, RTI.createElementStruct(), "g_rw_t2dmsa");
- Props = RBI.getAnnotateProps(M, RTI);
+ GV = RI.createSymbol(M, RTI.createElementStruct(), "g_rw_t2dmsa");
+ Props = RI.getAnnotateProps(M, RTI);
EXPECT_EQ(Props.first, 0x00001008U);
EXPECT_EQ(Props.second, 0x00080105U);
- MD = RBI.getAsMetadata(M, RTI);
+ MD = RI.getAsMetadata(M, RTI);
EXPECT_MDEQ(MD, TestMD.get(0, GV, "g_rw_t2dmsa", 0, 0, 1, 8, false, false,
false, TestMD.get(0, 5)));
@@ -366,14 +366,14 @@ TEST(DXILResource, AnnotationsAndMetadata) {
EXPECT_EQ(RTI.getCBufferSize(DL), 32u);
EXPECT_EQ(RTI.getResourceKind(), ResourceKind::CBuffer);
- RBI = ResourceBindingInfo(
+ RI = ResourceInfo(
/*RecordID=*/0, /*Space=*/0, /*LowerBound=*/0, /*Size=*/1,
RTI.getHandleTy());
- GV = RBI.createSymbol(M, RTI.createElementStruct(), "");
- Props = RBI.getAnnotateProps(M, RTI);
+ GV = RI.createSymbol(M, RTI.createElementStruct(), "");
+ Props = RI.getAnnotateProps(M, RTI);
EXPECT_EQ(Props.first, 0x0000000dU);
EXPECT_EQ(Props.second, 0x00000020U);
- MD = RBI.getAsMetadata(M, RTI);
+ MD = RI.getAsMetadata(M, RTI);
EXPECT_MDEQ(MD, TestMD.get(0, GV, "", 0, 0, 1, 32, nullptr));
// SamplerState ColorMapSampler : register(s0);
@@ -384,14 +384,14 @@ TEST(DXILResource, AnnotationsAndMetadata) {
EXPECT_EQ(RTI.getSamplerType(), dxil::SamplerType::Default);
EXPECT_EQ(RTI.getResourceKind(), ResourceKind::Sampler);
- RBI = ResourceBindingInfo(
+ RI = ResourceInfo(
/*RecordID=*/0, /*Space=*/0, /*LowerBound=*/0, /*Size=*/1,
RTI.getHandleTy());
- GV = RBI.createSymbol(M, RTI.createElementStruct(), "ColorMapSampler");
- Props = RBI.getAnnotateProps(M, RTI);
+ GV = RI.createSymbol(M, RTI.createElementStruct(), "ColorMapSampler");
+ Props = RI.getAnnotateProps(M, RTI);
EXPECT_EQ(Props.first, 0x0000000eU);
EXPECT_EQ(Props.second, 0U);
- MD = RBI.getAsMetadata(M, RTI);
+ MD = RI.getAsMetadata(M, RTI);
EXPECT_MDEQ(MD, TestMD.get(0, GV, "ColorMapSampler", 0, 0, 1, 0, nullptr));
RTI = ResourceTypeInfo(llvm::TargetExtType::get(
@@ -401,13 +401,13 @@ TEST(DXILResource, AnnotationsAndMetadata) {
EXPECT_EQ(RTI.getSamplerType(), dxil::SamplerType::Comparison);
EXPECT_EQ(RTI.getResourceKind(), ResourceKind::Sampler);
- RBI = ResourceBindingInfo(
+ RI = ResourceInfo(
/*RecordID=*/0, /*Space=*/0, /*LowerBound=*/0, /*Size=*/1,
RTI.getHandleTy());
- GV = RBI.createSymbol(M, RTI.createElementStruct(), "CmpSampler");
- Props = RBI.getAnnotateProps(M, RTI);
+ GV = RI.createSymbol(M, RTI.createElementStruct(), "CmpSampler");
+ Props = RI.getAnnotateProps(M, RTI);
EXPECT_EQ(Props.first, 0x0000800eU);
EXPECT_EQ(Props.second, 0U);
- MD = RBI.getAsMetadata(M, RTI);
+ MD = RI.getAsMetadata(M, RTI);
EXPECT_MDEQ(MD, TestMD.get(0, GV, "CmpSampler", 0, 0, 1, 1, nullptr));
}
diff --git a/llvm/unittests/Target/DirectX/UniqueResourceFromUseTests.cpp b/llvm/unittests/Target/DirectX/UniqueResourceFromUseTests.cpp
index f272381c0c250..475847c11d373 100644
--- a/llvm/unittests/Target/DirectX/UniqueResourceFromUseTests.cpp
+++ b/llvm/unittests/Target/DirectX/UniqueResourceFromUseTests.cpp
@@ -34,7 +34,7 @@ class UniqueResourceFromUseTest : public testing::Test {
PB = new PassBuilder();
PB->registerModuleAnalyses(*MAM);
MAM->registerPass([&] { return DXILResourceTypeAnalysis(); });
- MAM->registerPass([&] { return DXILResourceBindingAnalysis(); });
+ MAM->registerPass([&] { return DXILResourceAnalysis(); });
}
virtual void TearDown() {
@@ -62,7 +62,7 @@ declare void @a.func(target("dx.RawBuffer", float, 1, 0) %handle)
auto M = parseAssemblyString(Assembly, Error, Context);
ASSERT_TRUE(M) << "Bad assembly?";
- const DXILBindingMap &DBM = MAM->getResult<DXILResourceBindingAnalysis>(*M);
+ const DXILBindingMap &DBM = MAM->getResult<DXILResourceAnalysis>(*M);
for (const Function &F : M->functions()) {
if (F.getName() != "a.func") {
continue;
@@ -112,7 +112,7 @@ declare target("dx.RawBuffer", float, 1, 0) @ind.func(target("dx.RawBuffer", flo
auto M = parseAssemblyString(Assembly, Error, Context);
ASSERT_TRUE(M) << "Bad assembly?";
- const DXILBindingMap &DBM = MAM->getResult<DXILResourceBindingAnalysis>(*M);
+ const DXILBindingMap &DBM = MAM->getResult<DXILResourceAnalysis>(*M);
for (const Function &F : M->functions()) {
if (F.getName() != "a.func") {
continue;
@@ -165,7 +165,7 @@ declare target("dx.RawBuffer", float, 1, 0) @ind.func(target("dx.RawBuffer", flo
auto M = parseAssemblyString(Assembly, Error, Context);
ASSERT_TRUE(M) << "Bad assembly?";
- const DXILBindingMap &DBM = MAM->getResult<DXILResourceBindingAnalysis>(*M);
+ const DXILBindingMap &DBM = MAM->getResult<DXILResourceAnalysis>(*M);
for (const Function &F : M->functions()) {
if (F.getName() != "a.func") {
continue;
@@ -245,7 +245,7 @@ declare target("dx.RawBuffer", float, 1, 0) @ind.func(target("dx.RawBuffer", flo
auto M = parseAssemblyString(Assembly, Error, Context);
ASSERT_TRUE(M) << "Bad assembly?";
- const DXILBindingMap &DBM = MAM->getResult<DXILResourceBindingAnalysis>(*M);
+ const DXILBindingMap &DBM = MAM->getResult<DXILResourceAnalysis>(*M);
for (const Function &F : M->functions()) {
if (F.getName() != "a.func") {
continue;
>From 0604891cd3b84cc8f7c016de8b319b5dc6b95211 Mon Sep 17 00:00:00 2001
From: Ashley Coleman <ascoleman at microsoft.com>
Date: Thu, 3 Apr 2025 13:24:04 -0600
Subject: [PATCH 2/2] More renames
---
llvm/include/llvm/Analysis/DXILResource.h | 22 ++++-----
llvm/include/llvm/InitializePasses.h | 2 +-
llvm/include/llvm/LinkAllPasses.h | 2 +-
llvm/lib/Analysis/Analysis.cpp | 2 +-
llvm/lib/Analysis/DXILResource.cpp | 46 +++++++++----------
.../lib/Target/DirectX/DXContainerGlobals.cpp | 16 +++----
llvm/lib/Target/DirectX/DXILOpLowering.cpp | 30 ++++++------
llvm/lib/Target/DirectX/DXILPrepare.cpp | 2 +-
llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp | 18 ++++----
.../Target/DirectX/DXILTranslateMetadata.cpp | 34 +++++++-------
.../DirectX/UniqueResourceFromUseTests.cpp | 16 +++----
11 files changed, 94 insertions(+), 96 deletions(-)
diff --git a/llvm/include/llvm/Analysis/DXILResource.h b/llvm/include/llvm/Analysis/DXILResource.h
index 6a7be779cb2a3..ff7961c9ad51c 100644
--- a/llvm/include/llvm/Analysis/DXILResource.h
+++ b/llvm/include/llvm/Analysis/DXILResource.h
@@ -438,7 +438,7 @@ ModulePass *createDXILResourceTypeWrapperPassPass();
//===----------------------------------------------------------------------===//
-class DXILBindingMap {
+class DXILResourceMap {
SmallVector<dxil::ResourceInfo> Infos;
DenseMap<CallInst *, unsigned> CallMap;
unsigned FirstUAV = 0;
@@ -520,7 +520,7 @@ class DXILBindingMap {
const DataLayout &DL) const;
friend class DXILResourceAnalysis;
- friend class DXILResourceBindingWrapperPass;
+ friend class DXILResourceWrapperPass;
};
class DXILResourceAnalysis : public AnalysisInfoMixin<DXILResourceAnalysis> {
@@ -529,10 +529,10 @@ class DXILResourceAnalysis : public AnalysisInfoMixin<DXILResourceAnalysis> {
static AnalysisKey Key;
public:
- using Result = DXILBindingMap;
+ using Result = DXILResourceMap;
/// Gather resource info for the module \c M.
- DXILBindingMap run(Module &M, ModuleAnalysisManager &AM);
+ DXILResourceMap run(Module &M, ModuleAnalysisManager &AM);
};
/// Printer pass for the \c DXILResourceAnalysis results.
@@ -547,18 +547,18 @@ class DXILResourcePrinterPass : public PassInfoMixin<DXILResourcePrinterPass> {
static bool isRequired() { return true; }
};
-class DXILResourceBindingWrapperPass : public ModulePass {
- std::unique_ptr<DXILBindingMap> Map;
+class DXILResourceWrapperPass : public ModulePass {
+ std::unique_ptr<DXILResourceMap> Map;
DXILResourceTypeMap *DRTM;
public:
static char ID; // Class identification, replacement for typeinfo
- DXILResourceBindingWrapperPass();
- ~DXILResourceBindingWrapperPass() override;
+ DXILResourceWrapperPass();
+ ~DXILResourceWrapperPass() override;
- const DXILBindingMap &getBindingMap() const { return *Map; }
- DXILBindingMap &getBindingMap() { return *Map; }
+ const DXILResourceMap &getBindingMap() const { return *Map; }
+ DXILResourceMap &getBindingMap() { return *Map; }
void getAnalysisUsage(AnalysisUsage &AU) const override;
bool runOnModule(Module &M) override;
@@ -568,7 +568,7 @@ class DXILResourceBindingWrapperPass : public ModulePass {
void dump() const;
};
-ModulePass *createDXILResourceBindingWrapperPassPass();
+ModulePass *createDXILResourceWrapperPassPass();
} // namespace llvm
diff --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h
index fb27867176788..c6110aa298893 100644
--- a/llvm/include/llvm/InitializePasses.h
+++ b/llvm/include/llvm/InitializePasses.h
@@ -84,7 +84,7 @@ void initializeDAHPass(PassRegistry &);
void initializeDCELegacyPassPass(PassRegistry &);
void initializeDXILMetadataAnalysisWrapperPassPass(PassRegistry &);
void initializeDXILMetadataAnalysisWrapperPrinterPass(PassRegistry &);
-void initializeDXILResourceBindingWrapperPassPass(PassRegistry &);
+void initializeDXILResourceWrapperPassPass(PassRegistry &);
void initializeDXILResourceTypeWrapperPassPass(PassRegistry &);
void initializeDeadMachineInstructionElimPass(PassRegistry &);
void initializeDebugifyMachineModulePass(PassRegistry &);
diff --git a/llvm/include/llvm/LinkAllPasses.h b/llvm/include/llvm/LinkAllPasses.h
index ac1970334de0c..5965be676ea69 100644
--- a/llvm/include/llvm/LinkAllPasses.h
+++ b/llvm/include/llvm/LinkAllPasses.h
@@ -70,7 +70,7 @@ struct ForcePassLinking {
(void)llvm::createCallGraphViewerPass();
(void)llvm::createCFGSimplificationPass();
(void)llvm::createStructurizeCFGPass();
- (void)llvm::createDXILResourceBindingWrapperPassPass();
+ (void)llvm::createDXILResourceWrapperPassPass();
(void)llvm::createDXILResourceTypeWrapperPassPass();
(void)llvm::createDeadArgEliminationPass();
(void)llvm::createDeadCodeEliminationPass();
diff --git a/llvm/lib/Analysis/Analysis.cpp b/llvm/lib/Analysis/Analysis.cpp
index bc2b8a57f83a7..5cd5115bc4cd4 100644
--- a/llvm/lib/Analysis/Analysis.cpp
+++ b/llvm/lib/Analysis/Analysis.cpp
@@ -25,7 +25,7 @@ void llvm::initializeAnalysis(PassRegistry &Registry) {
initializeCallGraphDOTPrinterPass(Registry);
initializeCallGraphViewerPass(Registry);
initializeCycleInfoWrapperPassPass(Registry);
- initializeDXILResourceBindingWrapperPassPass(Registry);
+ initializeDXILResourceWrapperPassPass(Registry);
initializeDXILResourceTypeWrapperPassPass(Registry);
initializeDependenceAnalysisWrapperPassPass(Registry);
initializeDominanceFrontierWrapperPassPass(Registry);
diff --git a/llvm/lib/Analysis/DXILResource.cpp b/llvm/lib/Analysis/DXILResource.cpp
index 8f2cae1f53f70..ebfed6ae656b7 100644
--- a/llvm/lib/Analysis/DXILResource.cpp
+++ b/llvm/lib/Analysis/DXILResource.cpp
@@ -685,7 +685,7 @@ bool DXILResourceTypeMap::invalidate(Module &M, const PreservedAnalyses &PA,
//===----------------------------------------------------------------------===//
-void DXILBindingMap::populate(Module &M, DXILResourceTypeMap &DRTM) {
+void DXILResourceMap::populate(Module &M, DXILResourceTypeMap &DRTM) {
SmallVector<std::tuple<CallInst *, ResourceInfo, ResourceTypeInfo>> CIToInfos;
for (Function &F : M.functions()) {
@@ -764,8 +764,8 @@ void DXILBindingMap::populate(Module &M, DXILResourceTypeMap &DRTM) {
}
}
-void DXILBindingMap::print(raw_ostream &OS, DXILResourceTypeMap &DRTM,
- const DataLayout &DL) const {
+void DXILResourceMap::print(raw_ostream &OS, DXILResourceTypeMap &DRTM,
+ const DataLayout &DL) const {
for (unsigned I = 0, E = Infos.size(); I != E; ++I) {
OS << "Binding " << I << ":\n";
const dxil::ResourceInfo &RI = Infos[I];
@@ -781,7 +781,7 @@ void DXILBindingMap::print(raw_ostream &OS, DXILResourceTypeMap &DRTM,
}
SmallVector<dxil::ResourceInfo>
-DXILBindingMap::findByUse(const Value *Key) const {
+DXILResourceMap::findByUse(const Value *Key) const {
if (const PHINode *Phi = dyn_cast<PHINode>(Key)) {
SmallVector<dxil::ResourceInfo> Children;
for (const Value *V : Phi->operands()) {
@@ -824,8 +824,9 @@ DXILBindingMap::findByUse(const Value *Key) const {
AnalysisKey DXILResourceTypeAnalysis::Key;
AnalysisKey DXILResourceAnalysis::Key;
-DXILBindingMap DXILResourceAnalysis::run(Module &M, ModuleAnalysisManager &AM) {
- DXILBindingMap Data;
+DXILResourceMap DXILResourceAnalysis::run(Module &M,
+ ModuleAnalysisManager &AM) {
+ DXILResourceMap Data;
DXILResourceTypeMap &DRTM = AM.getResult<DXILResourceTypeAnalysis>(M);
Data.populate(M, DRTM);
return Data;
@@ -833,10 +834,10 @@ DXILBindingMap DXILResourceAnalysis::run(Module &M, ModuleAnalysisManager &AM) {
PreservedAnalyses DXILResourcePrinterPass::run(Module &M,
ModuleAnalysisManager &AM) {
- DXILBindingMap &DBM = AM.getResult<DXILResourceAnalysis>(M);
+ DXILResourceMap &DRM = AM.getResult<DXILResourceAnalysis>(M);
DXILResourceTypeMap &DRTM = AM.getResult<DXILResourceTypeAnalysis>(M);
- DBM.print(OS, DRTM, M.getDataLayout());
+ DRM.print(OS, DRTM, M.getDataLayout());
return PreservedAnalyses::all();
}
@@ -854,21 +855,19 @@ ModulePass *llvm::createDXILResourceTypeWrapperPassPass() {
return new DXILResourceTypeWrapperPass();
}
-DXILResourceBindingWrapperPass::DXILResourceBindingWrapperPass()
- : ModulePass(ID) {
- initializeDXILResourceBindingWrapperPassPass(
- *PassRegistry::getPassRegistry());
+DXILResourceWrapperPass::DXILResourceWrapperPass() : ModulePass(ID) {
+ initializeDXILResourceWrapperPassPass(*PassRegistry::getPassRegistry());
}
-DXILResourceBindingWrapperPass::~DXILResourceBindingWrapperPass() = default;
+DXILResourceWrapperPass::~DXILResourceWrapperPass() = default;
-void DXILResourceBindingWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
+void DXILResourceWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequiredTransitive<DXILResourceTypeWrapperPass>();
AU.setPreservesAll();
}
-bool DXILResourceBindingWrapperPass::runOnModule(Module &M) {
- Map.reset(new DXILBindingMap());
+bool DXILResourceWrapperPass::runOnModule(Module &M) {
+ Map.reset(new DXILResourceMap());
DRTM = &getAnalysis<DXILResourceTypeWrapperPass>().getResourceTypeMap();
Map->populate(M, *DRTM);
@@ -876,10 +875,9 @@ bool DXILResourceBindingWrapperPass::runOnModule(Module &M) {
return false;
}
-void DXILResourceBindingWrapperPass::releaseMemory() { Map.reset(); }
+void DXILResourceWrapperPass::releaseMemory() { Map.reset(); }
-void DXILResourceBindingWrapperPass::print(raw_ostream &OS,
- const Module *M) const {
+void DXILResourceWrapperPass::print(raw_ostream &OS, const Module *M) const {
if (!Map) {
OS << "No resource map has been built!\n";
return;
@@ -889,13 +887,13 @@ void DXILResourceBindingWrapperPass::print(raw_ostream &OS,
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD
-void DXILResourceBindingWrapperPass::dump() const { print(dbgs(), nullptr); }
+void DXILResourceWrapperPass::dump() const { print(dbgs(), nullptr); }
#endif
-INITIALIZE_PASS(DXILResourceBindingWrapperPass, "dxil-resource",
+INITIALIZE_PASS(DXILResourceWrapperPass, "dxil-resource",
"DXIL Resource Binding Analysis", false, true)
-char DXILResourceBindingWrapperPass::ID = 0;
+char DXILResourceWrapperPass::ID = 0;
-ModulePass *llvm::createDXILResourceBindingWrapperPassPass() {
- return new DXILResourceBindingWrapperPass();
+ModulePass *llvm::createDXILResourceWrapperPassPass() {
+ return new DXILResourceWrapperPass();
}
diff --git a/llvm/lib/Target/DirectX/DXContainerGlobals.cpp b/llvm/lib/Target/DirectX/DXContainerGlobals.cpp
index 8ab9352986fd9..5279847419a81 100644
--- a/llvm/lib/Target/DirectX/DXContainerGlobals.cpp
+++ b/llvm/lib/Target/DirectX/DXContainerGlobals.cpp
@@ -67,7 +67,7 @@ class DXContainerGlobals : public llvm::ModulePass {
AU.addRequired<RootSignatureAnalysisWrapper>();
AU.addRequired<DXILMetadataAnalysisWrapperPass>();
AU.addRequired<DXILResourceTypeWrapperPass>();
- AU.addRequired<DXILResourceBindingWrapperPass>();
+ AU.addRequired<DXILResourceWrapperPass>();
}
};
@@ -181,8 +181,8 @@ void DXContainerGlobals::addRootSignature(Module &M,
}
void DXContainerGlobals::addResourcesForPSV(Module &M, PSVRuntimeInfo &PSV) {
- const DXILBindingMap &DBM =
- getAnalysis<DXILResourceBindingWrapperPass>().getBindingMap();
+ const DXILResourceMap &DRM =
+ getAnalysis<DXILResourceWrapperPass>().getBindingMap();
DXILResourceTypeMap &DRTM =
getAnalysis<DXILResourceTypeWrapperPass>().getResourceTypeMap();
@@ -200,18 +200,18 @@ void DXContainerGlobals::addResourcesForPSV(Module &M, PSVRuntimeInfo &PSV) {
return BindInfo;
};
- for (const dxil::ResourceInfo &RI : DBM.cbuffers()) {
+ for (const dxil::ResourceInfo &RI : DRM.cbuffers()) {
const dxil::ResourceInfo::ResourceBinding &Binding = RI.getBinding();
PSV.Resources.push_back(MakeBinding(Binding, dxbc::PSV::ResourceType::CBV,
dxil::ResourceKind::CBuffer));
}
- for (const dxil::ResourceInfo &RI : DBM.samplers()) {
+ for (const dxil::ResourceInfo &RI : DRM.samplers()) {
const dxil::ResourceInfo::ResourceBinding &Binding = RI.getBinding();
PSV.Resources.push_back(MakeBinding(Binding,
dxbc::PSV::ResourceType::Sampler,
dxil::ResourceKind::Sampler));
}
- for (const dxil::ResourceInfo &RI : DBM.srvs()) {
+ for (const dxil::ResourceInfo &RI : DRM.srvs()) {
const dxil::ResourceInfo::ResourceBinding &Binding = RI.getBinding();
dxil::ResourceTypeInfo &TypeInfo = DRTM[RI.getHandleTy()];
@@ -226,7 +226,7 @@ void DXContainerGlobals::addResourcesForPSV(Module &M, PSVRuntimeInfo &PSV) {
PSV.Resources.push_back(
MakeBinding(Binding, ResType, TypeInfo.getResourceKind()));
}
- for (const dxil::ResourceInfo &RI : DBM.uavs()) {
+ for (const dxil::ResourceInfo &RI : DRM.uavs()) {
const dxil::ResourceInfo::ResourceBinding &Binding = RI.getBinding();
dxil::ResourceTypeInfo &TypeInfo = DRTM[RI.getHandleTy()];
@@ -298,7 +298,7 @@ INITIALIZE_PASS_BEGIN(DXContainerGlobals, "dxil-globals",
INITIALIZE_PASS_DEPENDENCY(ShaderFlagsAnalysisWrapper)
INITIALIZE_PASS_DEPENDENCY(DXILMetadataAnalysisWrapperPass)
INITIALIZE_PASS_DEPENDENCY(DXILResourceTypeWrapperPass)
-INITIALIZE_PASS_DEPENDENCY(DXILResourceBindingWrapperPass)
+INITIALIZE_PASS_DEPENDENCY(DXILResourceWrapperPass)
INITIALIZE_PASS_END(DXContainerGlobals, "dxil-globals",
"DXContainer Global Emitter", false, true)
diff --git a/llvm/lib/Target/DirectX/DXILOpLowering.cpp b/llvm/lib/Target/DirectX/DXILOpLowering.cpp
index 096157e6b90e9..63243ead8da07 100644
--- a/llvm/lib/Target/DirectX/DXILOpLowering.cpp
+++ b/llvm/lib/Target/DirectX/DXILOpLowering.cpp
@@ -79,13 +79,13 @@ namespace {
class OpLowerer {
Module &M;
DXILOpBuilder OpBuilder;
- DXILBindingMap &DBM;
+ DXILResourceMap &DRM;
DXILResourceTypeMap &DRTM;
SmallVector<CallInst *> CleanupCasts;
public:
- OpLowerer(Module &M, DXILBindingMap &DBM, DXILResourceTypeMap &DRTM)
- : M(M), OpBuilder(M), DBM(DBM), DRTM(DRTM) {}
+ OpLowerer(Module &M, DXILResourceMap &DRM, DXILResourceTypeMap &DRTM)
+ : M(M), OpBuilder(M), DRM(DRM), DRTM(DRTM) {}
/// Replace every call to \c F using \c ReplaceCall, and then erase \c F. If
/// there is an error replacing a call, we emit a diagnostic and return true.
@@ -266,8 +266,8 @@ class OpLowerer {
return replaceFunction(F, [&](CallInst *CI) -> Error {
IRB.SetInsertPoint(CI);
- auto *It = DBM.find(CI);
- assert(It != DBM.end() && "Resource not in map?");
+ auto *It = DRM.find(CI);
+ assert(It != DRM.end() && "Resource not in map?");
dxil::ResourceInfo &RI = *It;
const auto &Binding = RI.getBinding();
@@ -304,8 +304,8 @@ class OpLowerer {
return replaceFunction(F, [&](CallInst *CI) -> Error {
IRB.SetInsertPoint(CI);
- auto *It = DBM.find(CI);
- assert(It != DBM.end() && "Resource not in map?");
+ auto *It = DRM.find(CI);
+ assert(It != DRM.end() && "Resource not in map?");
dxil::ResourceInfo &RI = *It;
const auto &Binding = RI.getBinding();
@@ -856,10 +856,10 @@ class OpLowerer {
} // namespace
PreservedAnalyses DXILOpLowering::run(Module &M, ModuleAnalysisManager &MAM) {
- DXILBindingMap &DBM = MAM.getResult<DXILResourceAnalysis>(M);
+ DXILResourceMap &DRM = MAM.getResult<DXILResourceAnalysis>(M);
DXILResourceTypeMap &DRTM = MAM.getResult<DXILResourceTypeAnalysis>(M);
- bool MadeChanges = OpLowerer(M, DBM, DRTM).lowerIntrinsics();
+ bool MadeChanges = OpLowerer(M, DRM, DRTM).lowerIntrinsics();
if (!MadeChanges)
return PreservedAnalyses::all();
PreservedAnalyses PA;
@@ -873,12 +873,12 @@ namespace {
class DXILOpLoweringLegacy : public ModulePass {
public:
bool runOnModule(Module &M) override {
- DXILBindingMap &DBM =
- getAnalysis<DXILResourceBindingWrapperPass>().getBindingMap();
+ DXILResourceMap &DRM =
+ getAnalysis<DXILResourceWrapperPass>().getBindingMap();
DXILResourceTypeMap &DRTM =
getAnalysis<DXILResourceTypeWrapperPass>().getResourceTypeMap();
- return OpLowerer(M, DBM, DRTM).lowerIntrinsics();
+ return OpLowerer(M, DRM, DRTM).lowerIntrinsics();
}
StringRef getPassName() const override { return "DXIL Op Lowering"; }
DXILOpLoweringLegacy() : ModulePass(ID) {}
@@ -886,8 +886,8 @@ class DXILOpLoweringLegacy : public ModulePass {
static char ID; // Pass identification.
void getAnalysisUsage(llvm::AnalysisUsage &AU) const override {
AU.addRequired<DXILResourceTypeWrapperPass>();
- AU.addRequired<DXILResourceBindingWrapperPass>();
- AU.addPreserved<DXILResourceBindingWrapperPass>();
+ AU.addRequired<DXILResourceWrapperPass>();
+ AU.addPreserved<DXILResourceWrapperPass>();
AU.addPreserved<DXILMetadataAnalysisWrapperPass>();
AU.addPreserved<ShaderFlagsAnalysisWrapper>();
}
@@ -898,7 +898,7 @@ char DXILOpLoweringLegacy::ID = 0;
INITIALIZE_PASS_BEGIN(DXILOpLoweringLegacy, DEBUG_TYPE, "DXIL Op Lowering",
false, false)
INITIALIZE_PASS_DEPENDENCY(DXILResourceTypeWrapperPass)
-INITIALIZE_PASS_DEPENDENCY(DXILResourceBindingWrapperPass)
+INITIALIZE_PASS_DEPENDENCY(DXILResourceWrapperPass)
INITIALIZE_PASS_END(DXILOpLoweringLegacy, DEBUG_TYPE, "DXIL Op Lowering", false,
false)
diff --git a/llvm/lib/Target/DirectX/DXILPrepare.cpp b/llvm/lib/Target/DirectX/DXILPrepare.cpp
index 0014cc9e1f67c..de97de209048b 100644
--- a/llvm/lib/Target/DirectX/DXILPrepare.cpp
+++ b/llvm/lib/Target/DirectX/DXILPrepare.cpp
@@ -248,7 +248,7 @@ class DXILPrepareModule : public ModulePass {
AU.addRequired<DXILMetadataAnalysisWrapperPass>();
AU.addPreserved<ShaderFlagsAnalysisWrapper>();
AU.addPreserved<DXILMetadataAnalysisWrapperPass>();
- AU.addPreserved<DXILResourceBindingWrapperPass>();
+ AU.addPreserved<DXILResourceWrapperPass>();
}
static char ID; // Pass identification.
};
diff --git a/llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp b/llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp
index 2c0c2d4ae39f9..cf3fb34bba437 100644
--- a/llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp
+++ b/llvm/lib/Target/DirectX/DXILPrettyPrinter.cpp
@@ -220,7 +220,7 @@ struct FormatBindingSize
} // namespace
-static void prettyPrintResources(raw_ostream &OS, const DXILBindingMap &DBM,
+static void prettyPrintResources(raw_ostream &OS, const DXILResourceMap &DRM,
DXILResourceTypeMap &DRTM) {
// Column widths are arbitrary but match the widths DXC uses.
OS << ";\n; Resource Bindings:\n;\n";
@@ -231,7 +231,7 @@ static void prettyPrintResources(raw_ostream &OS, const DXILBindingMap &DBM,
"", "", "", "", "");
// TODO: Do we want to sort these by binding or something like that?
- for (const dxil::ResourceInfo &RI : DBM) {
+ for (const dxil::ResourceInfo &RI : DRM) {
const dxil::ResourceTypeInfo &RTI = DRTM[RI.getHandleTy()];
dxil::ResourceClass RC = RTI.getResourceClass();
@@ -250,9 +250,9 @@ static void prettyPrintResources(raw_ostream &OS, const DXILBindingMap &DBM,
PreservedAnalyses DXILPrettyPrinterPass::run(Module &M,
ModuleAnalysisManager &MAM) {
- const DXILBindingMap &DBM = MAM.getResult<DXILResourceAnalysis>(M);
+ const DXILResourceMap &DRM = MAM.getResult<DXILResourceAnalysis>(M);
DXILResourceTypeMap &DRTM = MAM.getResult<DXILResourceTypeAnalysis>(M);
- prettyPrintResources(OS, DBM, DRTM);
+ prettyPrintResources(OS, DRM, DRTM);
return PreservedAnalyses::all();
}
@@ -278,7 +278,7 @@ class DXILPrettyPrinterLegacy : public llvm::ModulePass {
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.setPreservesAll();
AU.addRequired<DXILResourceTypeWrapperPass>();
- AU.addRequired<DXILResourceBindingWrapperPass>();
+ AU.addRequired<DXILResourceWrapperPass>();
}
};
} // namespace
@@ -287,16 +287,16 @@ char DXILPrettyPrinterLegacy::ID = 0;
INITIALIZE_PASS_BEGIN(DXILPrettyPrinterLegacy, "dxil-pretty-printer",
"DXIL Metadata Pretty Printer", true, true)
INITIALIZE_PASS_DEPENDENCY(DXILResourceTypeWrapperPass)
-INITIALIZE_PASS_DEPENDENCY(DXILResourceBindingWrapperPass)
+INITIALIZE_PASS_DEPENDENCY(DXILResourceWrapperPass)
INITIALIZE_PASS_END(DXILPrettyPrinterLegacy, "dxil-pretty-printer",
"DXIL Metadata Pretty Printer", true, true)
bool DXILPrettyPrinterLegacy::runOnModule(Module &M) {
- const DXILBindingMap &DBM =
- getAnalysis<DXILResourceBindingWrapperPass>().getBindingMap();
+ const DXILResourceMap &DRM =
+ getAnalysis<DXILResourceWrapperPass>().getBindingMap();
DXILResourceTypeMap &DRTM =
getAnalysis<DXILResourceTypeWrapperPass>().getResourceTypeMap();
- prettyPrintResources(OS, DBM, DRTM);
+ prettyPrintResources(OS, DRM, DRTM);
return false;
}
diff --git a/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp b/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
index abd7a1ebc479a..e177fcb0520e8 100644
--- a/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
+++ b/llvm/lib/Target/DirectX/DXILTranslateMetadata.cpp
@@ -72,22 +72,22 @@ enum class EntryPropsTag {
} // namespace
-static NamedMDNode *emitResourceMetadata(Module &M, DXILBindingMap &DBM,
+static NamedMDNode *emitResourceMetadata(Module &M, DXILResourceMap &DRM,
DXILResourceTypeMap &DRTM) {
LLVMContext &Context = M.getContext();
- for (ResourceInfo &RI : DBM)
+ for (ResourceInfo &RI : DRM)
if (!RI.hasSymbol())
RI.createSymbol(M, DRTM[RI.getHandleTy()].createElementStruct());
SmallVector<Metadata *> SRVs, UAVs, CBufs, Smps;
- for (const ResourceInfo &RI : DBM.srvs())
+ for (const ResourceInfo &RI : DRM.srvs())
SRVs.push_back(RI.getAsMetadata(M, DRTM[RI.getHandleTy()]));
- for (const ResourceInfo &RI : DBM.uavs())
+ for (const ResourceInfo &RI : DRM.uavs())
UAVs.push_back(RI.getAsMetadata(M, DRTM[RI.getHandleTy()]));
- for (const ResourceInfo &RI : DBM.cbuffers())
+ for (const ResourceInfo &RI : DRM.cbuffers())
CBufs.push_back(RI.getAsMetadata(M, DRTM[RI.getHandleTy()]));
- for (const ResourceInfo &RI : DBM.samplers())
+ for (const ResourceInfo &RI : DRM.samplers())
Smps.push_back(RI.getAsMetadata(M, DRTM[RI.getHandleTy()]));
Metadata *SRVMD = SRVs.empty() ? nullptr : MDNode::get(Context, SRVs);
@@ -95,7 +95,7 @@ static NamedMDNode *emitResourceMetadata(Module &M, DXILBindingMap &DBM,
Metadata *CBufMD = CBufs.empty() ? nullptr : MDNode::get(Context, CBufs);
Metadata *SmpMD = Smps.empty() ? nullptr : MDNode::get(Context, Smps);
- if (DBM.empty())
+ if (DRM.empty())
return nullptr;
NamedMDNode *ResourceMD = M.getOrInsertNamedMetadata("dx.resources");
@@ -318,7 +318,7 @@ static void translateBranchMetadata(Module &M) {
}
}
-static void translateMetadata(Module &M, DXILBindingMap &DBM,
+static void translateMetadata(Module &M, DXILResourceMap &DRM,
DXILResourceTypeMap &DRTM,
const ModuleShaderFlags &ShaderFlags,
const ModuleMetadataInfo &MMDI) {
@@ -329,7 +329,7 @@ static void translateMetadata(Module &M, DXILBindingMap &DBM,
emitValidatorVersionMD(M, MMDI);
emitShaderModelVersionMD(M, MMDI);
emitDXILVersionTupleMD(M, MMDI);
- NamedMDNode *NamedResourceMD = emitResourceMetadata(M, DBM, DRTM);
+ NamedMDNode *NamedResourceMD = emitResourceMetadata(M, DRM, DRTM);
auto *ResourceMD =
(NamedResourceMD != nullptr) ? NamedResourceMD->getOperand(0) : nullptr;
// FIXME: Add support to construct Signatures
@@ -381,12 +381,12 @@ static void translateMetadata(Module &M, DXILBindingMap &DBM,
PreservedAnalyses DXILTranslateMetadata::run(Module &M,
ModuleAnalysisManager &MAM) {
- DXILBindingMap &DBM = MAM.getResult<DXILResourceAnalysis>(M);
+ DXILResourceMap &DRM = MAM.getResult<DXILResourceAnalysis>(M);
DXILResourceTypeMap &DRTM = MAM.getResult<DXILResourceTypeAnalysis>(M);
const ModuleShaderFlags &ShaderFlags = MAM.getResult<ShaderFlagsAnalysis>(M);
const dxil::ModuleMetadataInfo MMDI = MAM.getResult<DXILMetadataAnalysis>(M);
- translateMetadata(M, DBM, DRTM, ShaderFlags, MMDI);
+ translateMetadata(M, DRM, DRTM, ShaderFlags, MMDI);
translateBranchMetadata(M);
return PreservedAnalyses::all();
@@ -402,17 +402,17 @@ class DXILTranslateMetadataLegacy : public ModulePass {
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addRequired<DXILResourceTypeWrapperPass>();
- AU.addRequired<DXILResourceBindingWrapperPass>();
+ AU.addRequired<DXILResourceWrapperPass>();
AU.addRequired<ShaderFlagsAnalysisWrapper>();
AU.addRequired<DXILMetadataAnalysisWrapperPass>();
- AU.addPreserved<DXILResourceBindingWrapperPass>();
+ AU.addPreserved<DXILResourceWrapperPass>();
AU.addPreserved<DXILMetadataAnalysisWrapperPass>();
AU.addPreserved<ShaderFlagsAnalysisWrapper>();
}
bool runOnModule(Module &M) override {
- DXILBindingMap &DBM =
- getAnalysis<DXILResourceBindingWrapperPass>().getBindingMap();
+ DXILResourceMap &DRM =
+ getAnalysis<DXILResourceWrapperPass>().getBindingMap();
DXILResourceTypeMap &DRTM =
getAnalysis<DXILResourceTypeWrapperPass>().getResourceTypeMap();
const ModuleShaderFlags &ShaderFlags =
@@ -420,7 +420,7 @@ class DXILTranslateMetadataLegacy : public ModulePass {
dxil::ModuleMetadataInfo MMDI =
getAnalysis<DXILMetadataAnalysisWrapperPass>().getModuleMetadata();
- translateMetadata(M, DBM, DRTM, ShaderFlags, MMDI);
+ translateMetadata(M, DRM, DRTM, ShaderFlags, MMDI);
translateBranchMetadata(M);
return true;
}
@@ -436,7 +436,7 @@ ModulePass *llvm::createDXILTranslateMetadataLegacyPass() {
INITIALIZE_PASS_BEGIN(DXILTranslateMetadataLegacy, "dxil-translate-metadata",
"DXIL Translate Metadata", false, false)
-INITIALIZE_PASS_DEPENDENCY(DXILResourceBindingWrapperPass)
+INITIALIZE_PASS_DEPENDENCY(DXILResourceWrapperPass)
INITIALIZE_PASS_DEPENDENCY(ShaderFlagsAnalysisWrapper)
INITIALIZE_PASS_DEPENDENCY(DXILMetadataAnalysisWrapperPass)
INITIALIZE_PASS_END(DXILTranslateMetadataLegacy, "dxil-translate-metadata",
diff --git a/llvm/unittests/Target/DirectX/UniqueResourceFromUseTests.cpp b/llvm/unittests/Target/DirectX/UniqueResourceFromUseTests.cpp
index 475847c11d373..675a3dc19b912 100644
--- a/llvm/unittests/Target/DirectX/UniqueResourceFromUseTests.cpp
+++ b/llvm/unittests/Target/DirectX/UniqueResourceFromUseTests.cpp
@@ -62,7 +62,7 @@ declare void @a.func(target("dx.RawBuffer", float, 1, 0) %handle)
auto M = parseAssemblyString(Assembly, Error, Context);
ASSERT_TRUE(M) << "Bad assembly?";
- const DXILBindingMap &DBM = MAM->getResult<DXILResourceAnalysis>(*M);
+ const DXILResourceMap &DRM = MAM->getResult<DXILResourceAnalysis>(*M);
for (const Function &F : M->functions()) {
if (F.getName() != "a.func") {
continue;
@@ -73,7 +73,7 @@ declare void @a.func(target("dx.RawBuffer", float, 1, 0) %handle)
for (const User *U : F.users()) {
const CallInst *CI = cast<CallInst>(U);
const Value *Handle = CI->getArgOperand(0);
- const auto Bindings = DBM.findByUse(Handle);
+ const auto Bindings = DRM.findByUse(Handle);
ASSERT_EQ(Bindings.size(), 1u)
<< "Handle should resolve into one resource";
@@ -112,7 +112,7 @@ declare target("dx.RawBuffer", float, 1, 0) @ind.func(target("dx.RawBuffer", flo
auto M = parseAssemblyString(Assembly, Error, Context);
ASSERT_TRUE(M) << "Bad assembly?";
- const DXILBindingMap &DBM = MAM->getResult<DXILResourceAnalysis>(*M);
+ const DXILResourceMap &DRM = MAM->getResult<DXILResourceAnalysis>(*M);
for (const Function &F : M->functions()) {
if (F.getName() != "a.func") {
continue;
@@ -123,7 +123,7 @@ declare target("dx.RawBuffer", float, 1, 0) @ind.func(target("dx.RawBuffer", flo
for (const User *U : F.users()) {
const CallInst *CI = cast<CallInst>(U);
const Value *Handle = CI->getArgOperand(0);
- const auto Bindings = DBM.findByUse(Handle);
+ const auto Bindings = DRM.findByUse(Handle);
ASSERT_EQ(Bindings.size(), 1u)
<< "Handle should resolve into one resource";
@@ -165,7 +165,7 @@ declare target("dx.RawBuffer", float, 1, 0) @ind.func(target("dx.RawBuffer", flo
auto M = parseAssemblyString(Assembly, Error, Context);
ASSERT_TRUE(M) << "Bad assembly?";
- const DXILBindingMap &DBM = MAM->getResult<DXILResourceAnalysis>(*M);
+ const DXILResourceMap &DRM = MAM->getResult<DXILResourceAnalysis>(*M);
for (const Function &F : M->functions()) {
if (F.getName() != "a.func") {
continue;
@@ -176,7 +176,7 @@ declare target("dx.RawBuffer", float, 1, 0) @ind.func(target("dx.RawBuffer", flo
for (const User *U : F.users()) {
const CallInst *CI = cast<CallInst>(U);
const Value *Handle = CI->getArgOperand(0);
- const auto Bindings = DBM.findByUse(Handle);
+ const auto Bindings = DRM.findByUse(Handle);
ASSERT_EQ(Bindings.size(), 4u)
<< "Handle should resolve into four resources";
@@ -245,7 +245,7 @@ declare target("dx.RawBuffer", float, 1, 0) @ind.func(target("dx.RawBuffer", flo
auto M = parseAssemblyString(Assembly, Error, Context);
ASSERT_TRUE(M) << "Bad assembly?";
- const DXILBindingMap &DBM = MAM->getResult<DXILResourceAnalysis>(*M);
+ const DXILResourceMap &DRM = MAM->getResult<DXILResourceAnalysis>(*M);
for (const Function &F : M->functions()) {
if (F.getName() != "a.func") {
continue;
@@ -256,7 +256,7 @@ declare target("dx.RawBuffer", float, 1, 0) @ind.func(target("dx.RawBuffer", flo
for (const User *U : F.users()) {
const CallInst *CI = cast<CallInst>(U);
const Value *Handle = CI->getArgOperand(0);
- const auto Bindings = DBM.findByUse(Handle);
+ const auto Bindings = DRM.findByUse(Handle);
ASSERT_EQ(Bindings.size(), 2u)
<< "Handle should resolve into four resources";
More information about the llvm-commits
mailing list