@@ -25,97 +25,6 @@ class Metadata;
25
25
26
26
namespace hlsl {
27
27
namespace rootsig {
28
-
29
- inline std::optional<uint32_t > extractMdIntValue (MDNode *Node,
30
- unsigned int OpId) {
31
- if (auto *CI =
32
- mdconst::dyn_extract<ConstantInt>(Node->getOperand (OpId).get ()))
33
- return CI->getZExtValue ();
34
- return std::nullopt;
35
- }
36
-
37
- inline std::optional<float > extractMdFloatValue (MDNode *Node,
38
- unsigned int OpId) {
39
- if (auto *CI = mdconst::dyn_extract<ConstantFP>(Node->getOperand (OpId).get ()))
40
- return CI->getValueAPF ().convertToFloat ();
41
- return std::nullopt;
42
- }
43
-
44
- inline std::optional<StringRef> extractMdStringValue (MDNode *Node,
45
- unsigned int OpId) {
46
- MDString *NodeText = dyn_cast<MDString>(Node->getOperand (OpId));
47
- if (NodeText == nullptr )
48
- return std::nullopt;
49
- return NodeText->getString ();
50
- }
51
-
52
- template <typename T>
53
- class RootSignatureValidationError
54
- : public ErrorInfo<RootSignatureValidationError<T>> {
55
- public:
56
- static char ID;
57
- std::string ParamName;
58
- T Value;
59
-
60
- RootSignatureValidationError (StringRef ParamName, T Value)
61
- : ParamName(ParamName.str()), Value(Value) {}
62
-
63
- void log (raw_ostream &OS) const override {
64
- OS << " Invalid value for " << ParamName << " : " << Value;
65
- }
66
-
67
- std::error_code convertToErrorCode () const override {
68
- return llvm::inconvertibleErrorCode ();
69
- }
70
- };
71
-
72
- class GenericRSMetadataError : public ErrorInfo <GenericRSMetadataError> {
73
- public:
74
- static char ID;
75
- std::string Message;
76
-
77
- GenericRSMetadataError (Twine Message) : Message(Message.str()) {}
78
-
79
- void log (raw_ostream &OS) const override { OS << Message; }
80
-
81
- std::error_code convertToErrorCode () const override {
82
- return llvm::inconvertibleErrorCode ();
83
- }
84
- };
85
-
86
- class InvalidRSMetadataFormat : public ErrorInfo <InvalidRSMetadataFormat> {
87
- public:
88
- static char ID;
89
- std::string ElementName;
90
-
91
- InvalidRSMetadataFormat (StringRef ElementName)
92
- : ElementName(ElementName.str()) {}
93
-
94
- void log (raw_ostream &OS) const override {
95
- OS << " Invalid format for " << ElementName;
96
- }
97
-
98
- std::error_code convertToErrorCode () const override {
99
- return llvm::inconvertibleErrorCode ();
100
- }
101
- };
102
-
103
- class InvalidRSMetadataValue : public ErrorInfo <InvalidRSMetadataValue> {
104
- public:
105
- static char ID;
106
- std::string ParamName;
107
-
108
- InvalidRSMetadataValue (StringRef ParamName) : ParamName(ParamName.str()) {}
109
-
110
- void log (raw_ostream &OS) const override {
111
- OS << " Invalid value for " << ParamName;
112
- }
113
-
114
- std::error_code convertToErrorCode () const override {
115
- return llvm::inconvertibleErrorCode ();
116
- }
117
- };
118
-
119
28
class MetadataBuilder {
120
29
public:
121
30
MetadataBuilder (llvm::LLVMContext &Ctx, ArrayRef<RootElement> Elements)
@@ -157,27 +66,29 @@ class MetadataParser {
157
66
MetadataParser (MDNode *Root) : Root(Root) {}
158
67
159
68
// / Iterates through root signature and converts them into MapT
160
- LLVM_ABI llvm::Expected<llvm::mcdxbc::RootSignatureDesc>
161
- ParseRootSignature ( uint32_t Version );
69
+ LLVM_ABI bool ParseRootSignature (LLVMContext *Ctx,
70
+ mcdxbc::RootSignatureDesc &RSD );
162
71
163
72
private:
164
- llvm::Error parseRootFlags (mcdxbc::RootSignatureDesc &RSD,
165
- MDNode *RootFlagNode);
166
- llvm::Error parseRootConstants (mcdxbc::RootSignatureDesc &RSD,
167
- MDNode *RootConstantNode);
168
- llvm::Error parseRootDescriptors (mcdxbc::RootSignatureDesc &RSD,
169
- MDNode *RootDescriptorNode,
170
- RootSignatureElementKind ElementKind);
171
- llvm::Error parseDescriptorRange (mcdxbc::DescriptorTable &Table,
172
- MDNode *RangeDescriptorNode);
173
- llvm::Error parseDescriptorTable (mcdxbc::RootSignatureDesc &RSD,
174
- MDNode *DescriptorTableNode);
175
- llvm::Error parseRootSignatureElement (mcdxbc::RootSignatureDesc &RSD,
176
- MDNode *Element);
177
- llvm::Error parseStaticSampler (mcdxbc::RootSignatureDesc &RSD,
178
- MDNode *StaticSamplerNode);
179
-
180
- llvm::Error validateRootSignature (const llvm::mcdxbc::RootSignatureDesc &RSD);
73
+ bool parseRootFlags (LLVMContext *Ctx, mcdxbc::RootSignatureDesc &RSD,
74
+ MDNode *RootFlagNode);
75
+ bool parseRootConstants (LLVMContext *Ctx, mcdxbc::RootSignatureDesc &RSD,
76
+ MDNode *RootConstantNode);
77
+ bool parseRootDescriptors (LLVMContext *Ctx, mcdxbc::RootSignatureDesc &RSD,
78
+ MDNode *RootDescriptorNode,
79
+ RootSignatureElementKind ElementKind);
80
+ bool parseDescriptorRange (LLVMContext *Ctx, mcdxbc::DescriptorTable &Table,
81
+ MDNode *RangeDescriptorNode);
82
+ bool parseDescriptorTable (LLVMContext *Ctx, mcdxbc::RootSignatureDesc &RSD,
83
+ MDNode *DescriptorTableNode);
84
+ bool parseRootSignatureElement (LLVMContext *Ctx,
85
+ mcdxbc::RootSignatureDesc &RSD,
86
+ MDNode *Element);
87
+ bool parseStaticSampler (LLVMContext *Ctx, mcdxbc::RootSignatureDesc &RSD,
88
+ MDNode *StaticSamplerNode);
89
+
90
+ bool validateRootSignature (LLVMContext *Ctx,
91
+ const llvm::mcdxbc::RootSignatureDesc &RSD);
181
92
182
93
MDNode *Root;
183
94
};
0 commit comments