-
Notifications
You must be signed in to change notification settings - Fork 14.4k
[DirectX][NFC] Refactor DXILRootSignature
to follow the same pattern as other analysis
#146783
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
0e8828c
2edd215
242545e
3f8dec4
3b1ce3b
f5720af
ea54904
881dd36
c7d5be7
cc5afae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ | |
/// Root Signatures. | ||
/// | ||
//===----------------------------------------------------------------------===// | ||
#ifndef LLVM_LIB_TARGET_DIRECTX_DXILROOTSIGNATURE_H | ||
#define LLVM_LIB_TARGET_DIRECTX_DXILROOTSIGNATURE_H | ||
|
||
#include "llvm/ADT/DenseMap.h" | ||
#include "llvm/Analysis/DXILMetadataAnalysis.h" | ||
|
@@ -33,17 +35,44 @@ enum class RootSignatureElementKind { | |
CBV = 5, | ||
DescriptorTable = 6, | ||
}; | ||
|
||
class RootSignatureBindingInfo { | ||
private: | ||
SmallDenseMap<const Function *, mcdxbc::RootSignatureDesc> FuncToRsMap; | ||
|
||
public: | ||
using iterator = | ||
SmallDenseMap<const Function *, mcdxbc::RootSignatureDesc>::iterator; | ||
|
||
RootSignatureBindingInfo() = default; | ||
RootSignatureBindingInfo( | ||
SmallDenseMap<const Function *, mcdxbc::RootSignatureDesc> Map) | ||
: FuncToRsMap(Map) {}; | ||
|
||
iterator find(const Function *F) { return FuncToRsMap.find(F); } | ||
|
||
iterator end() { return FuncToRsMap.end(); } | ||
|
||
std::optional<mcdxbc::RootSignatureDesc> | ||
getDescForFunction(const Function *F) { | ||
const auto FuncRs = find(F); | ||
if (FuncRs == end()) | ||
return std::nullopt; | ||
|
||
return FuncRs->second; | ||
} | ||
}; | ||
|
||
class RootSignatureAnalysis : public AnalysisInfoMixin<RootSignatureAnalysis> { | ||
friend AnalysisInfoMixin<RootSignatureAnalysis>; | ||
static AnalysisKey Key; | ||
|
||
public: | ||
RootSignatureAnalysis() = default; | ||
|
||
using Result = SmallDenseMap<const Function *, mcdxbc::RootSignatureDesc>; | ||
using Result = RootSignatureBindingInfo; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why create a type alias here? Why not just put 'RootSignatureBindingInfo' inline? It looks like its only used one place. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
SmallDenseMap<const Function *, mcdxbc::RootSignatureDesc> | ||
run(Module &M, ModuleAnalysisManager &AM); | ||
Result run(Module &M, ModuleAnalysisManager &AM); | ||
}; | ||
|
||
/// Wrapper pass for the legacy pass manager. | ||
|
@@ -52,19 +81,13 @@ class RootSignatureAnalysis : public AnalysisInfoMixin<RootSignatureAnalysis> { | |
/// passes which run through the legacy pass manager. | ||
class RootSignatureAnalysisWrapper : public ModulePass { | ||
private: | ||
SmallDenseMap<const Function *, mcdxbc::RootSignatureDesc> FuncToRsMap; | ||
std::unique_ptr<RootSignatureBindingInfo> FuncToRsMap; | ||
|
||
public: | ||
static char ID; | ||
|
||
RootSignatureAnalysisWrapper() : ModulePass(ID) {} | ||
|
||
using iterator = | ||
SmallDenseMap<const Function *, mcdxbc::RootSignatureDesc>::iterator; | ||
|
||
iterator find(const Function *F) { return FuncToRsMap.find(F); } | ||
|
||
iterator end() { return FuncToRsMap.end(); } | ||
RootSignatureBindingInfo &getRSInfo() { return *FuncToRsMap; } | ||
|
||
bool runOnModule(Module &M) override; | ||
|
||
|
@@ -83,3 +106,4 @@ class RootSignatureAnalysisPrinter | |
|
||
} // namespace dxil | ||
} // namespace llvm | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't RS a reference, why are you using the arrow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the type to make it clearer, but the type is
const std::optional<mcdxbc::RootSignatureDesc> &RS