41 mdconst::dyn_extract<ConstantInt>(
Node->getOperand(OpId).get()))
42 return CI->getZExtValue();
71 NamedMDNode *RootSignatureNode = M.getNamedMetadata(
"dx.rootsignatures");
72 if (RootSignatureNode ==
nullptr)
75 for (
const auto &RSDefNode : RootSignatureNode->
operands()) {
76 if (RSDefNode->getNumOperands() != 3) {
77 reportError(Ctx,
"Invalid Root Signature metadata - expected function, "
78 "signature, and version.");
83 const MDOperand &FunctionPointerMdNode = RSDefNode->getOperand(0);
84 if (FunctionPointerMdNode ==
nullptr) {
86 Ctx,
"Function associated with Root Signature definition is null.");
91 llvm::dyn_cast<ValueAsMetadata>(FunctionPointerMdNode.
get());
93 reportError(Ctx,
"First element of root signature is not a Value");
99 reportError(Ctx,
"First element of root signature is not a Function");
103 Metadata *RootElementListOperand = RSDefNode->getOperand(1).get();
105 if (RootElementListOperand ==
nullptr) {
110 MDNode *RootElementListNode = dyn_cast<MDNode>(RootElementListOperand);
111 if (RootElementListNode ==
nullptr) {
112 reportError(Ctx,
"Root Element is not a metadata node.");
116 if (!V.has_value()) {
117 reportError(Ctx,
"Invalid RSDefNode value, expected constant int");
127 Ctx->emitError(EIB.message());
132 auto &RSD = *RSDOrErr;
140 RSD.StaticSamplersOffset = 0u;
142 RSDMap.
insert(std::make_pair(
F, RSD));
162 OS <<
"Root Signature Definitions"
165 auto It = RSDMap.
find(&
F);
166 if (It == RSDMap.
end())
168 const auto &RS = It->second;
169 OS <<
"Definition for '" <<
F.getName() <<
"':\n";
172 <<
"Version: " << RS.Version <<
"\n"
173 <<
"RootParametersOffset: " << RS.RootParameterOffset <<
"\n"
174 <<
"NumParameters: " << RS.ParametersContainer.size() <<
"\n";
175 for (
size_t I = 0;
I < RS.ParametersContainer.size();
I++) {
178 OS <<
"- Parameter Type: "
180 <<
" Shader Visibility: "
184 case dxbc::RootParameterType::Constants32Bit: {
186 RS.ParametersContainer.getConstant(
Info.Location);
187 OS <<
" Register Space: " << Constants.RegisterSpace <<
"\n"
188 <<
" Shader Register: " << Constants.ShaderRegister <<
"\n"
189 <<
" Num 32 Bit Values: " << Constants.Num32BitValues <<
"\n";
192 case dxbc::RootParameterType::CBV:
193 case dxbc::RootParameterType::UAV:
194 case dxbc::RootParameterType::SRV: {
196 RS.ParametersContainer.getRootDescriptor(
Info.Location);
200 OS <<
" Flags: " << Descriptor.
Flags <<
"\n";
203 case dxbc::RootParameterType::DescriptorTable: {
205 RS.ParametersContainer.getDescriptorTable(
Info.Location);
206 OS <<
" NumRanges: " << Table.
Ranges.size() <<
"\n";
209 OS <<
" - Range Type: " <<
Range.RangeType <<
"\n"
210 <<
" Register Space: " <<
Range.RegisterSpace <<
"\n"
211 <<
" Base Shader Register: " <<
Range.BaseShaderRegister <<
"\n"
212 <<
" Num Descriptors: " <<
Range.NumDescriptors <<
"\n"
213 <<
" Offset In Descriptors From Table Start: "
214 <<
Range.OffsetInDescriptorsFromTableStart <<
"\n";
216 OS <<
" Flags: " <<
Range.Flags <<
"\n";
222 OS <<
"NumStaticSamplers: " << 0 <<
"\n";
223 OS <<
"StaticSamplersOffset: " << RS.StaticSamplersOffset <<
"\n";
230 FuncToRsMap = std::make_unique<RootSignatureBindingInfo>(
243 "dxil-root-signature-analysis",
244 "DXIL Root Signature Analysis",
true,
true)
block Block Frequency Analysis
Analysis containing CSE Info
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static std::optional< uint32_t > extractMdIntValue(MDNode *Node, unsigned int OpId)
static SmallDenseMap< const Function *, mcdxbc::RootSignatureDesc > analyzeModule(Module &M)
static bool reportError(LLVMContext *Ctx, Twine Message, DiagnosticSeverity Severity=DS_Error)
Module.h This file contains the declarations for the Module class.
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
This file implements the StringSwitch template, which mimics a switch() statement whose cases are str...
A container for analyses that lazily runs them and caches their results.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Base class for error info classes.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
This is an important class for using LLVM in a threaded context.
LLVM_ABI void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
Tracking metadata reference owned by Metadata.
A Module instance is used to store all the information related to an LLVM module.
iterator_range< op_iterator > operands()
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Wrapper pass for the legacy pass manager.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
bool runOnModule(Module &M) override
runOnModule - Virtual method overriden by subclasses to process the module being operated on.
Result run(Module &M, ModuleAnalysisManager &AM)
iterator find(const Function *F)
LLVM_ABI ArrayRef< EnumEntry< ShaderVisibility > > getShaderVisibility()
LLVM_ABI ArrayRef< EnumEntry< RootParameterType > > getRootParameterTypes()
This is an optimization pass for GlobalISel generic memory operations.
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...
FormattedNumber format_hex(uint64_t N, unsigned Width, bool Upper=false)
format_hex - Output N as a fixed width hexadecimal.
DiagnosticSeverity
Defines the different supported severity of a diagnostic.
StringRef enumToStringRef(T Value, ArrayRef< EnumEntry< TEnum > > EnumValues)
Retrieves the Value's enum name.
A special type used by analysis passes to provide an address that identifies that particular analysis...
SmallVector< dxbc::RTS0::v2::DescriptorRange > Ranges