43 return CI->getZExtValue();
72 NamedMDNode *RootSignatureNode = M.getNamedMetadata(
"dx.rootsignatures");
73 if (RootSignatureNode ==
nullptr)
76 bool AllowNullFunctions =
false;
77 if (M.getTargetTriple().getEnvironment() ==
80 AllowNullFunctions =
true;
83 for (
const auto &RSDefNode : RootSignatureNode->
operands()) {
84 if (RSDefNode->getNumOperands() != 3) {
85 reportError(Ctx,
"Invalid Root Signature metadata - expected function, "
86 "signature, and version.");
93 if (!AllowNullFunctions) {
94 const MDOperand &FunctionPointerMdNode = RSDefNode->getOperand(0);
95 if (FunctionPointerMdNode ==
nullptr) {
97 Ctx,
"Function associated with Root Signature definition is null.");
103 if (VAM ==
nullptr) {
104 reportError(Ctx,
"First element of root signature is not a Value");
110 reportError(Ctx,
"First element of root signature is not a Function");
115 Metadata *RootElementListOperand = RSDefNode->getOperand(1).get();
117 if (RootElementListOperand ==
nullptr) {
123 if (RootElementListNode ==
nullptr) {
124 reportError(Ctx,
"Root Element is not a metadata node.");
128 if (!V.has_value()) {
129 reportError(Ctx,
"Invalid RSDefNode value, expected constant int");
144 Ctx->emitError(EIB.message());
149 auto &RSD = *RSDOrErr;
157 RSD.StaticSamplersOffset = 0u;
159 RSDMap.
insert(std::make_pair(
F, RSD));
181 OS <<
"Root Signature Definitions"
184 auto It = RSDMap.
find(&
F);
185 if (It == RSDMap.
end())
187 const auto &RS = It->second;
188 OS <<
"Definition for '" <<
F.getName() <<
"':\n";
190 OS <<
"Flags: " <<
format_hex(RS.Flags, 8) <<
"\n"
191 <<
"Version: " << RS.Version <<
"\n"
192 <<
"RootParametersOffset: " << RS.RootParameterOffset <<
"\n"
193 <<
"NumParameters: " << RS.ParametersContainer.size() <<
"\n";
194 for (
size_t I = 0;
I < RS.ParametersContainer.size();
I++) {
197 OS <<
"- Parameter Type: "
199 <<
" Shader Visibility: "
203 case dxbc::RootParameterType::Constants32Bit: {
205 RS.ParametersContainer.getConstant(Info.Location);
206 OS <<
" Register Space: " << Constants.RegisterSpace <<
"\n"
207 <<
" Shader Register: " << Constants.ShaderRegister <<
"\n"
208 <<
" Num 32 Bit Values: " << Constants.Num32BitValues <<
"\n";
211 case dxbc::RootParameterType::CBV:
212 case dxbc::RootParameterType::UAV:
213 case dxbc::RootParameterType::SRV: {
215 RS.ParametersContainer.getRootDescriptor(Info.Location);
216 OS <<
" Register Space: " << Descriptor.
RegisterSpace <<
"\n"
219 OS <<
" Flags: " << Descriptor.
Flags <<
"\n";
222 case dxbc::RootParameterType::DescriptorTable: {
224 RS.ParametersContainer.getDescriptorTable(Info.Location);
225 OS <<
" NumRanges: " << Table.
Ranges.size() <<
"\n";
228 OS <<
" - Range Type: "
230 <<
" Register Space: " <<
Range.RegisterSpace <<
"\n"
231 <<
" Base Shader Register: " <<
Range.BaseShaderRegister <<
"\n"
232 <<
" Num Descriptors: " <<
Range.NumDescriptors <<
"\n"
233 <<
" Offset In Descriptors From Table Start: "
234 <<
Range.OffsetInDescriptorsFromTableStart <<
"\n";
236 OS <<
" Flags: " <<
Range.Flags <<
"\n";
242 OS <<
"NumStaticSamplers: " << 0 <<
"\n";
243 OS <<
"StaticSamplersOffset: " << RS.StaticSamplersOffset <<
"\n";
250 FuncToRsMap = std::make_unique<RootSignatureBindingInfo>(
263 "dxil-root-signature-analysis",
264 "DXIL Root Signature Analysis",
true,
true)
266 "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)
LLVM_ABI bool verifyVersion(uint32_t Version)
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