1
- // ===- DXILRootSignature.cpp - DXIL Root Signature helper objects ---------------===//
1
+ // ===- DXILRootSignature.cpp - DXIL Root Signature helper objects
2
+ // ---------------===//
2
3
//
3
4
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
5
// See https://llvm.org/LICENSE.txt for license information.
@@ -28,15 +29,17 @@ static bool parseRootFlags(ModuleRootSignature *MRS, MDNode *RootFlagNode) {
28
29
auto *Flag = mdconst::extract<ConstantInt>(RootFlagNode->getOperand (1 ));
29
30
auto Value = Flag->getZExtValue ();
30
31
31
- // Root Element validation, as specified: https://github.com/llvm/wg-hlsl/blob/main/proposals/0002-root-signature-in-clang.md#validations-during-dxil-generation
32
+ // Root Element validation, as specified:
33
+ // https://github.com/llvm/wg-hlsl/blob/main/proposals/0002-root-signature-in-clang.md#validations-during-dxil-generation
32
34
if ((Value & ~0x80000fff ) != 0 )
33
35
return true ;
34
36
35
37
MRS->Flags = Value;
36
38
return false ;
37
39
}
38
40
39
- static bool parseRootSignatureElement (ModuleRootSignature *MRS, MDNode *Element) {
41
+ static bool parseRootSignatureElement (ModuleRootSignature *MRS,
42
+ MDNode *Element) {
40
43
MDString *ElementText = cast<MDString>(Element->getOperand (0 ));
41
44
42
45
assert (ElementText != nullptr && " First preoperty of element is not " );
@@ -72,8 +75,7 @@ static bool parseRootSignatureElement(ModuleRootSignature *MRS, MDNode *Element)
72
75
return true ;
73
76
}
74
77
75
- bool ModuleRootSignature::parse ( int32_t Version,
76
- NamedMDNode *Root) {
78
+ bool ModuleRootSignature::parse (int32_t Version, NamedMDNode *Root) {
77
79
this ->Version = Version;
78
80
bool HasError = false ;
79
81
@@ -103,37 +105,35 @@ void ModuleRootSignature::write(raw_ostream &OS) {
103
105
Out.swapBytes ();
104
106
}
105
107
106
- OS.write (reinterpret_cast <const char *>(&Out), sizeof (dxbc::RootSignatureDesc));
108
+ OS.write (reinterpret_cast <const char *>(&Out),
109
+ sizeof (dxbc::RootSignatureDesc));
107
110
}
108
111
109
112
AnalysisKey RootSignatureAnalysis::Key;
110
113
111
114
ModuleRootSignature RootSignatureAnalysis::run (Module &M,
112
- ModuleAnalysisManager &AM) {
113
- ModuleRootSignature MRSI;
115
+ ModuleAnalysisManager &AM) {
116
+ ModuleRootSignature MRSI;
114
117
115
- NamedMDNode *RootSignatureNode = M.getNamedMetadata (" dx.rootsignatures" );
116
- if (RootSignatureNode) {
117
- MRSI.parse (1 , RootSignatureNode);
118
- }
119
-
120
- return MRSI;
118
+ NamedMDNode *RootSignatureNode = M.getNamedMetadata (" dx.rootsignatures" );
119
+ if (RootSignatureNode) {
120
+ MRSI.parse (1 , RootSignatureNode);
121
+ }
121
122
123
+ return MRSI;
122
124
}
123
125
124
-
125
126
// ===----------------------------------------------------------------------===//
126
127
bool RootSignatureAnalysisWrapper::runOnModule (Module &M) {
127
128
ModuleRootSignature MRS;
128
129
129
- NamedMDNode *RootSignatureNode = M.getNamedMetadata (" dx.rootsignatures" );
130
- if (RootSignatureNode) {
131
- MRS.parse (1 , RootSignatureNode);
132
- this ->MRS = MRS;
133
- }
134
-
130
+ NamedMDNode *RootSignatureNode = M.getNamedMetadata (" dx.rootsignatures" );
131
+ if (RootSignatureNode) {
132
+ MRS.parse (1 , RootSignatureNode);
133
+ this ->MRS = MRS;
134
+ }
135
135
136
- return false ;
136
+ return false ;
137
137
}
138
138
139
139
void RootSignatureAnalysisWrapper::getAnalysisUsage (AnalysisUsage &AU) const {
@@ -142,5 +142,5 @@ void RootSignatureAnalysisWrapper::getAnalysisUsage(AnalysisUsage &AU) const {
142
142
143
143
char RootSignatureAnalysisWrapper::ID = 0 ;
144
144
145
- INITIALIZE_PASS (RootSignatureAnalysisWrapper, " dx-root-signature-analysis" ,
146
- " DXIL Root Signature Analysis" , true , true )
145
+ INITIALIZE_PASS (RootSignatureAnalysisWrapper, " dx-root-signature-analysis" ,
146
+ " DXIL Root Signature Analysis" , true , true )
0 commit comments