42 return CI->getZExtValue();
71 NamedMDNode *RootSignatureNode = M.getNamedMetadata(
"dx.rootsignatures");
72 if (RootSignatureNode ==
nullptr)
75 bool AllowNullFunctions =
false;
76 if (M.getTargetTriple().getEnvironment() ==
79 AllowNullFunctions =
true;
82 for (
const auto &RSDefNode : RootSignatureNode->
operands()) {
83 if (RSDefNode->getNumOperands() != 3) {
84 reportError(Ctx,
"Invalid Root Signature metadata - expected function, "
85 "signature, and version.");
92 if (!AllowNullFunctions) {
93 const MDOperand &FunctionPointerMdNode = RSDefNode->getOperand(0);
94 if (FunctionPointerMdNode ==
nullptr) {
96 Ctx,
"Function associated with Root Signature definition is null.");
102 if (VAM ==
nullptr) {
103 reportError(Ctx,
"First element of root signature is not a Value");
109 reportError(Ctx,
"First element of root signature is not a Function");
114 Metadata *RootElementListOperand = RSDefNode->getOperand(1).get();
116 if (RootElementListOperand ==
nullptr) {
122 if (RootElementListNode ==
nullptr) {
123 reportError(Ctx,
"Root Element is not a metadata node.");
127 if (!V.has_value()) {
128 reportError(Ctx,
"Invalid RSDefNode value, expected constant int");
138 Ctx->emitError(EIB.message());
143 auto &RSD = *RSDOrErr;
151 RSD.StaticSamplersOffset = 0u;
153 RSDMap.
insert(std::make_pair(
F, RSD));
173 OS <<
"Root Signature Definitions"
176 auto It = RSDMap.
find(&
F);
177 if (It == RSDMap.
end())
179 const auto &RS = It->second;
180 OS <<
"Definition for '" <<
F.getName() <<
"':\n";
182 OS <<
"Flags: " <<
format_hex(RS.Flags, 8) <<
"\n"
183 <<
"Version: " << RS.Version <<
"\n"
184 <<
"RootParametersOffset: " << RS.RootParameterOffset <<
"\n"
185 <<
"NumParameters: " << RS.ParametersContainer.size() <<
"\n";
186 for (
size_t I = 0;
I < RS.ParametersContainer.size();
I++) {
189 OS <<
"- Parameter Type: "
191 <<
" Shader Visibility: "
195 case dxbc::RootParameterType::Constants32Bit: {
197 RS.ParametersContainer.getConstant(Info.Location);
199 <<
" Shader Register: " << Constants.ShaderRegister <<
"\n"
200 <<
" Num 32 Bit Values: " << Constants.Num32BitValues <<
"\n";
203 case dxbc::RootParameterType::CBV:
204 case dxbc::RootParameterType::UAV:
205 case dxbc::RootParameterType::SRV: {
207 RS.ParametersContainer.getRootDescriptor(Info.Location);
208 OS <<
" Register Space: " << Descriptor.
RegisterSpace <<
"\n"
211 OS <<
" Flags: " << Descriptor.
Flags <<
"\n";
214 case dxbc::RootParameterType::DescriptorTable: {
216 RS.ParametersContainer.getDescriptorTable(Info.Location);
217 OS <<
" NumRanges: " << Table.
Ranges.size() <<
"\n";
220 OS <<
" - Range Type: "
222 <<
" Register Space: " <<
Range.RegisterSpace <<
"\n"
223 <<
" Base Shader Register: " <<
Range.BaseShaderRegister <<
"\n"
224 <<
" Num Descriptors: " <<
Range.NumDescriptors <<
"\n"
225 <<
" Offset In Descriptors From Table Start: "
226 <<
Range.OffsetInDescriptorsFromTableStart <<
"\n";
228 OS <<
" Flags: " <<
Range.Flags <<
"\n";
234 OS <<
"NumStaticSamplers: " << 0 <<
"\n";
235 OS <<
"StaticSamplersOffset: " << RS.StaticSamplersOffset <<
"\n";
242 FuncToRsMap = std::make_unique<RootSignatureBindingInfo>(
255 "dxil-root-signature-analysis",
256 "DXIL Root Signature Analysis",
true,
true)
258 "dxil-root-signature-analysis",
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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...
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.
Tracking metadata reference owned by Metadata.
A Module instance is used to store all the information related to an LLVM module.
LLVM_ABI unsigned getNumOperands() const
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.
RootSignatureBindingInfo Result
Result run(Module &M, ModuleAnalysisManager &AM)
iterator find(const Function *F)
LLVM_ABI ArrayRef< EnumEntry< ShaderVisibility > > getShaderVisibility()
LLVM_ABI ArrayRef< EnumEntry< RootParameterType > > getRootParameterTypes()
LLVM_ABI StringRef getResourceClassName(ResourceClass RC)
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > dyn_extract(Y &&MD)
Extract a Value from Metadata, if any.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
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.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
A special type used by analysis passes to provide an address that identifies that particular analysis...
SmallVector< DescriptorRange > Ranges