1919#include " llvm/IR/Constants.h"
2020#include " llvm/MC/DXContainerRootSignature.h"
2121#include " llvm/Support/Compiler.h"
22+ #include " llvm/Support/FormatVariadic.h"
2223
2324namespace llvm {
2425class LLVMContext ;
@@ -27,113 +28,20 @@ class Metadata;
2728
2829namespace hlsl {
2930namespace rootsig {
31+ class RootSignatureValidationError
32+ : public ErrorInfo<RootSignatureValidationError> {
33+ public:
34+ static char ID;
35+ std::string Msg;
3036
31- enum class RSErrorKind {
32- Validation,
33- AppendAfterUnboundedRange,
34- ShaderRegisterOverflow,
35- OffsetOverflow,
36- SamplerMixin,
37- GenericMetadata,
38- InvalidMetadataFormat,
39- InvalidMetadataValue
40- };
37+ RootSignatureValidationError (const Twine &Msg) : Msg(Msg.str()) {}
4138
42- template <typename T>
43- void formatImpl (raw_string_ostream &Buff,
44- std::integral_constant<RSErrorKind, RSErrorKind::Validation>,
45- StringRef ParamName, T Value);
46-
47- void formatImpl (
48- raw_string_ostream &Buff,
49- std::integral_constant<RSErrorKind, RSErrorKind::AppendAfterUnboundedRange>,
50- dxil::ResourceClass Type, uint32_t Register, uint32_t Space);
51-
52- void formatImpl (
53- raw_string_ostream &Buff,
54- std::integral_constant<RSErrorKind, RSErrorKind::ShaderRegisterOverflow>,
55- dxil::ResourceClass Type, uint32_t Register, uint32_t Space);
56-
57- void formatImpl (
58- raw_string_ostream &Buff,
59- std::integral_constant<RSErrorKind, RSErrorKind::OffsetOverflow>,
60- dxil::ResourceClass Type, uint32_t Register, uint32_t Space);
61-
62- void formatImpl (raw_string_ostream &Buff,
63- std::integral_constant<RSErrorKind, RSErrorKind::SamplerMixin>,
64- dxil::ResourceClass Type, uint32_t Location);
65-
66- void formatImpl (
67- raw_string_ostream &Buff,
68- std::integral_constant<RSErrorKind, RSErrorKind::InvalidMetadataFormat>,
69- StringRef ElementName);
70-
71- void formatImpl (
72- raw_string_ostream &Buff,
73- std::integral_constant<RSErrorKind, RSErrorKind::InvalidMetadataValue>,
74- StringRef ParamName);
75-
76- void formatImpl (
77- raw_string_ostream &Buff,
78- std::integral_constant<RSErrorKind, RSErrorKind::GenericMetadata>,
79- StringRef Message, MDNode *MD);
80-
81- template <typename ... ArgsTs>
82- inline void formatImpl (raw_string_ostream &Buff, RSErrorKind Kind,
83- ArgsTs... Args) {
84- switch (Kind) {
85- case RSErrorKind::Validation:
86- return formatImpl (
87- Buff, std::integral_constant<RSErrorKind, RSErrorKind::Validation>(),
88- Args...);
89- case RSErrorKind::AppendAfterUnboundedRange:
90- return formatImpl (
91- Buff,
92- std::integral_constant<RSErrorKind,
93- RSErrorKind::AppendAfterUnboundedRange>(),
94- Args...);
95- case RSErrorKind::ShaderRegisterOverflow:
96- return formatImpl (
97- Buff,
98- std::integral_constant<RSErrorKind,
99- RSErrorKind::ShaderRegisterOverflow>(),
100- Args...);
101- case RSErrorKind::OffsetOverflow:
102- return formatImpl (
103- Buff,
104- std::integral_constant<RSErrorKind, RSErrorKind::OffsetOverflow>(),
105- Args...);
106- case RSErrorKind::SamplerMixin:
107- return formatImpl (
108- Buff, std::integral_constant<RSErrorKind, RSErrorKind::SamplerMixin>(),
109- Args...);
110- case RSErrorKind::InvalidMetadataFormat:
111- return formatImpl (
112- Buff,
113- std::integral_constant<RSErrorKind,
114- RSErrorKind::InvalidMetadataFormat>(),
115- Args...);
116- case RSErrorKind::InvalidMetadataValue:
117- return formatImpl (
118- Buff,
119- std::integral_constant<RSErrorKind,
120- RSErrorKind::InvalidMetadataValue>(),
121- Args...);
122- case RSErrorKind::GenericMetadata:
123- return formatImpl (
124- Buff,
125- std::integral_constant<RSErrorKind, RSErrorKind::GenericMetadata>(),
126- Args...);
127- }
128- }
39+ void log (raw_ostream &OS) const override { OS << Msg; }
12940
130- template <typename ... ArgsTs>
131- static llvm::Error createRSError (RSErrorKind Kind, ArgsTs... Args) {
132- std::string Msg;
133- raw_string_ostream Buff (Msg);
134- formatImpl (Buff, Kind, Args...);
135- return createStringError (std::move (Buff.str ()), inconvertibleErrorCode ());
136- }
41+ std::error_code convertToErrorCode () const override {
42+ return llvm::inconvertibleErrorCode ();
43+ }
44+ };
13745
13846class MetadataBuilder {
13947public:
0 commit comments