@@ -32,20 +32,6 @@ using namespace llvm::dxil;
32
32
33
33
namespace {
34
34
35
- struct DXILArgSelect {
36
- enum class Type {
37
- Index,
38
- I32,
39
- I8,
40
- };
41
- Type Type = Type::Index;
42
- int Value = -1 ;
43
- };
44
- struct DXILIntrinsicSelect {
45
- StringRef Intrinsic;
46
- SmallVector<DXILArgSelect, 4 > Args;
47
- };
48
-
49
35
struct DXILOperationDesc {
50
36
std::string OpName; // name of DXIL operation
51
37
int OpCode; // ID of DXIL operation
@@ -56,7 +42,8 @@ struct DXILOperationDesc {
56
42
SmallVector<const Record *> OverloadRecs;
57
43
SmallVector<const Record *> StageRecs;
58
44
SmallVector<const Record *> AttrRecs;
59
- SmallVector<DXILIntrinsicSelect> IntrinsicSelects;
45
+ StringRef Intrinsic; // The llvm intrinsic map to OpName. Default is "" which
46
+ // means no map exists
60
47
SmallVector<StringRef, 4 >
61
48
ShaderStages; // shader stages to which this applies, empty for all.
62
49
int OverloadParamIndex; // Index of parameter with overload type.
@@ -84,21 +71,6 @@ static void ascendingSortByVersion(std::vector<const Record *> &Recs) {
84
71
});
85
72
}
86
73
87
- // / Take a `int_{intrinsic_name}` and return just the intrinsic_name part if
88
- // / available. Otherwise return the empty string.
89
- static StringRef GetIntrinsicName (const RecordVal *RV) {
90
- if (RV && RV->getValue ()) {
91
- if (const DefInit *DI = dyn_cast<DefInit>(RV->getValue ())) {
92
- auto *IntrinsicDef = DI->getDef ();
93
- auto DefName = IntrinsicDef->getName ();
94
- assert (DefName.starts_with (" int_" ) && " invalid intrinsic name" );
95
- // Remove the int_ from intrinsic name.
96
- return DefName.substr (4 );
97
- }
98
- }
99
- return " " ;
100
- }
101
-
102
74
// / Construct an object using the DXIL Operation records specified
103
75
// / in DXIL.td. This serves as the single source of reference of
104
76
// / the information extracted from the specified Record R, for
@@ -185,63 +157,14 @@ DXILOperationDesc::DXILOperationDesc(const Record *R) {
185
157
OpName);
186
158
}
187
159
188
- {
189
- DXILIntrinsicSelect IntrSelect;
190
- IntrSelect.Intrinsic = GetIntrinsicName (R->getValue (" LLVMIntrinsic" ));
191
- if (IntrSelect.Intrinsic .size ())
192
- IntrinsicSelects.emplace_back (std::move (IntrSelect));
193
- }
194
-
195
- auto IntrinsicSelectRecords = R->getValueAsListOfDefs (" intrinsic_selects" );
196
- if (IntrinsicSelectRecords.size ()) {
197
- if (IntrinsicSelects.size ()) {
198
- PrintFatalError (
199
- R, Twine (" LLVMIntrinsic and intrinsic_selects cannot be both "
200
- " defined for DXIL operation - " ) +
201
- OpName);
202
- } else {
203
- for (const Record *R : IntrinsicSelectRecords) {
204
- DXILIntrinsicSelect IntrSelect;
205
- IntrSelect.Intrinsic = GetIntrinsicName (R->getValue (" intrinsic" ));
206
- auto Args = R->getValueAsListOfDefs (" args" );
207
- for (const Record *Arg : Args) {
208
- bool IsI8 = Arg->getValueAsBit (" is_i8" );
209
- bool IsI32 = Arg->getValueAsBit (" is_i32" );
210
- int Index = Arg->getValueAsInt (" index" );
211
- const Record *ValueRec = Arg->getValueAsOptionalDef (" value" );
212
-
213
- DXILArgSelect ArgSelect;
214
- if (IsI8) {
215
- if (!ValueRec) {
216
- PrintFatalError (R, Twine (" 'value' must be defined for i8 "
217
- " ArgSelect for DXIL operation - " ) +
218
- OpName);
219
- }
220
- ArgSelect.Type = DXILArgSelect::Type::I8;
221
- ArgSelect.Value = ValueRec->getValueAsInt (" value" );
222
- } else if (IsI32) {
223
- if (!ValueRec) {
224
- PrintFatalError (R, Twine (" 'value' must be defined for i32 "
225
- " ArgSelect for DXIL operation - " ) +
226
- OpName);
227
- }
228
- ArgSelect.Type = DXILArgSelect::Type::I32;
229
- ArgSelect.Value = ValueRec->getValueAsInt (" value" );
230
- } else {
231
- if (Index < 0 ) {
232
- PrintFatalError (
233
- R, Twine (" Index in ArgSelect<index> must be equal to or "
234
- " greater than 0 for DXIL operation - " ) +
235
- OpName);
236
- }
237
- ArgSelect.Type = DXILArgSelect::Type::Index;
238
- ArgSelect.Value = Index;
239
- }
240
-
241
- IntrSelect.Args .emplace_back (std::move (ArgSelect));
242
- }
243
- IntrinsicSelects.emplace_back (std::move (IntrSelect));
244
- }
160
+ const RecordVal *RV = R->getValue (" LLVMIntrinsic" );
161
+ if (RV && RV->getValue ()) {
162
+ if (const DefInit *DI = dyn_cast<DefInit>(RV->getValue ())) {
163
+ auto *IntrinsicDef = DI->getDef ();
164
+ auto DefName = IntrinsicDef->getName ();
165
+ assert (DefName.starts_with (" int_" ) && " invalid intrinsic name" );
166
+ // Remove the int_ from intrinsic name.
167
+ Intrinsic = DefName.substr (4 );
245
168
}
246
169
}
247
170
}
@@ -454,29 +377,10 @@ static void emitDXILIntrinsicMap(ArrayRef<DXILOperationDesc> Ops,
454
377
OS << " #ifdef DXIL_OP_INTRINSIC\n " ;
455
378
OS << " \n " ;
456
379
for (const auto &Op : Ops) {
457
- if (Op.IntrinsicSelects .empty ()) {
380
+ if (Op.Intrinsic .empty ())
458
381
continue ;
459
- }
460
- for (const DXILIntrinsicSelect &MappedIntr : Op.IntrinsicSelects ) {
461
- OS << " DXIL_OP_INTRINSIC(dxil::OpCode::" << Op.OpName
462
- << " , Intrinsic::" << MappedIntr.Intrinsic ;
463
- for (const DXILArgSelect &ArgSelect : MappedIntr.Args ) {
464
- OS << " , (ArgSelect { " ;
465
- switch (ArgSelect.Type ) {
466
- case DXILArgSelect::Type::Index:
467
- OS << " ArgSelect::Type::Index, " ;
468
- break ;
469
- case DXILArgSelect::Type::I8:
470
- OS << " ArgSelect::Type::I8, " ;
471
- break ;
472
- case DXILArgSelect::Type::I32:
473
- OS << " ArgSelect::Type::I32, " ;
474
- break ;
475
- }
476
- OS << ArgSelect.Value << " })" ;
477
- }
478
- OS << " )\n " ;
479
- }
382
+ OS << " DXIL_OP_INTRINSIC(dxil::OpCode::" << Op.OpName
383
+ << " , Intrinsic::" << Op.Intrinsic << " )\n " ;
480
384
}
481
385
OS << " \n " ;
482
386
OS << " #undef DXIL_OP_INTRINSIC\n " ;
0 commit comments