1
- // ===- DXILRootSignature.cpp - DXIL Root Signature helper objects ----===//
1
+ // ===- DXILRootSignature.cpp - DXIL Root Signature helper objects ------- ===//
2
2
//
3
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
4
// See https://llvm.org/LICENSE.txt for license information.
@@ -68,8 +68,8 @@ static bool parseRootSignatureElement(LLVMContext *Ctx,
68
68
case RootSignatureElementKind::RootFlags:
69
69
return parseRootFlags (Ctx, MRS, Element);
70
70
case RootSignatureElementKind::None:
71
- return reportError (Ctx,
72
- " Invalid Root Element: " + ElementText->getString ());
71
+ return reportError (Ctx, " Invalid Root Signature Element: " +
72
+ ElementText->getString ());
73
73
}
74
74
75
75
llvm_unreachable (" Root signature element kind not expected." );
@@ -78,20 +78,6 @@ static bool parseRootSignatureElement(LLVMContext *Ctx,
78
78
static bool parse (LLVMContext *Ctx, ModuleRootSignature &MRS, MDNode *Node) {
79
79
bool HasError = false ;
80
80
81
- /* * Root Signature are specified as following in the metadata:
82
-
83
- !dx.rootsignatures = !{!2} ; list of function/root signature pairs
84
- !2 = !{ ptr @main, !3 } ; function, root signature
85
- !3 = !{ !4, !5, !6, !7 } ; list of root signature elements
86
-
87
- So for each MDNode inside dx.rootsignatures NamedMDNode
88
- (the Root parameter of this function), the parsing process needs
89
- to loop through each of its operands and process the function,
90
- signature pair.
91
- */
92
-
93
- // Get the Root Signature Description from the function signature pair.
94
-
95
81
// Loop through the Root Elements of the root signature.
96
82
for (const auto &Operand : Node->operands ()) {
97
83
MDNode *Element = dyn_cast<MDNode>(Operand);
@@ -114,6 +100,18 @@ static bool validate(LLVMContext *Ctx, const ModuleRootSignature &MRS) {
114
100
static SmallDenseMap<const Function *, ModuleRootSignature>
115
101
analyzeModule (Module &M) {
116
102
103
+ /* * Root Signature are specified as following in the metadata:
104
+
105
+ !dx.rootsignatures = !{!2} ; list of function/root signature pairs
106
+ !2 = !{ ptr @main, !3 } ; function, root signature
107
+ !3 = !{ !4, !5, !6, !7 } ; list of root signature elements
108
+
109
+ So for each MDNode inside dx.rootsignatures NamedMDNode
110
+ (the Root parameter of this function), the parsing process needs
111
+ to loop through each of its operands and process the function,
112
+ signature pair.
113
+ */
114
+
117
115
LLVMContext *Ctx = &M.getContext ();
118
116
119
117
SmallDenseMap<const Function *, ModuleRootSignature> MRSMap;
@@ -129,22 +127,22 @@ analyzeModule(Module &M) {
129
127
continue ;
130
128
}
131
129
130
+ // Function was pruned during compilation.
132
131
const MDOperand &FunctionPointerMdNode = RSDefNode->getOperand (0 );
133
132
if (FunctionPointerMdNode == nullptr ) {
134
- // Function was pruned during compilation.
135
133
continue ;
136
134
}
137
135
138
136
ValueAsMetadata *VAM =
139
137
llvm::dyn_cast<ValueAsMetadata>(FunctionPointerMdNode.get ());
140
138
if (VAM == nullptr ) {
141
- reportError (Ctx, " First element of root signature is not a value " );
139
+ reportError (Ctx, " First element of root signature is not a Value " );
142
140
continue ;
143
141
}
144
142
145
143
Function *F = dyn_cast<Function>(VAM->getValue ());
146
144
if (F == nullptr ) {
147
- reportError (Ctx, " First element of root signature is not a function " );
145
+ reportError (Ctx, " First element of root signature is not a Function " );
148
146
continue ;
149
147
}
150
148
0 commit comments