Skip to content

Commit 5d2fa92

Browse files
llvm-beanzGreg Roth
andauthored
[SM6.9] Enable trivial native vector Dxil Operations plus a few (microsoft#7324)
This enables the generation of native vector DXIL Operations that are "trivial", meaning they take only a single DXOp Call instruction to implement as well as a few others that either only took such a call and some llvm operations or were of particular interest for other reasons. This involves allowing the overloads by adding the vector indication in hctdb, altering the lowering to maintain the vectors instead of scalarizing them, and a few sundry changes to fix issues along the way. The "trivial" dxil operations that return a different value from the overload type had to be moved out of the way and given their own lowering function so that the main function could generate vectors conditional on the version and vector type. These will be added in a later change. While the long vector supporting intrinsics that weren't given this treatment will continue to generate scalarized operations, some of them needed some work as well. The dot product for float vectors longer than 4 had to take the integer fallback path, which required some small modificaitons and a rename. Additionally, a heuristic for pow that malfunctioned with too many elements had to have a limit placed on it. Since the or()/and()/select() intrinsics translate directly to LLVM ops, they can have their lowering scalarization removed and what future scalarization might be needed by the current version can be done by later passes as with other LLVM operators. An issue with a special value used to represent unassined dimensions had to be addressed since new dimensions can exceed that value. It's now MAX_INT. Contributes to microsoft#7120, but I'd prefer to leave it open until all intrinsics are covered Primary work by @pow2clk Fixes microsoft#7297 & microsoft#7120 --------- Co-authored-by: Greg Roth <[email protected]>
1 parent c940161 commit 5d2fa92

15 files changed

+1983
-163
lines changed

lib/DXIL/DxilOperations.cpp

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -96,16 +96,16 @@ const OP::OpCodeProperty OP::m_OpCodeProps[(unsigned)OP::OpCode::NumOpCodes] = {
9696
"unary",
9797
Attribute::ReadNone,
9898
1,
99-
{{0x7}},
100-
{{0x0}}}, // Overloads: hfd
99+
{{0x407}},
100+
{{0x7}}}, // Overloads: hfd<hfd
101101
{OC::Saturate,
102102
"Saturate",
103103
OCC::Unary,
104104
"unary",
105105
Attribute::ReadNone,
106106
1,
107-
{{0x7}},
108-
{{0x0}}}, // Overloads: hfd
107+
{{0x407}},
108+
{{0x7}}}, // Overloads: hfd<hfd
109109
{OC::IsNaN,
110110
"IsNaN",
111111
OCC::IsSpecialFloat,
@@ -144,112 +144,112 @@ const OP::OpCodeProperty OP::m_OpCodeProps[(unsigned)OP::OpCode::NumOpCodes] = {
144144
"unary",
145145
Attribute::ReadNone,
146146
1,
147-
{{0x3}},
148-
{{0x0}}}, // Overloads: hf
147+
{{0x403}},
148+
{{0x3}}}, // Overloads: hf<hf
149149
{OC::Sin,
150150
"Sin",
151151
OCC::Unary,
152152
"unary",
153153
Attribute::ReadNone,
154154
1,
155-
{{0x3}},
156-
{{0x0}}}, // Overloads: hf
155+
{{0x403}},
156+
{{0x3}}}, // Overloads: hf<hf
157157
{OC::Tan,
158158
"Tan",
159159
OCC::Unary,
160160
"unary",
161161
Attribute::ReadNone,
162162
1,
163-
{{0x3}},
164-
{{0x0}}}, // Overloads: hf
163+
{{0x403}},
164+
{{0x3}}}, // Overloads: hf<hf
165165
{OC::Acos,
166166
"Acos",
167167
OCC::Unary,
168168
"unary",
169169
Attribute::ReadNone,
170170
1,
171-
{{0x3}},
172-
{{0x0}}}, // Overloads: hf
171+
{{0x403}},
172+
{{0x3}}}, // Overloads: hf<hf
173173
{OC::Asin,
174174
"Asin",
175175
OCC::Unary,
176176
"unary",
177177
Attribute::ReadNone,
178178
1,
179-
{{0x3}},
180-
{{0x0}}}, // Overloads: hf
179+
{{0x403}},
180+
{{0x3}}}, // Overloads: hf<hf
181181
{OC::Atan,
182182
"Atan",
183183
OCC::Unary,
184184
"unary",
185185
Attribute::ReadNone,
186186
1,
187-
{{0x3}},
188-
{{0x0}}}, // Overloads: hf
187+
{{0x403}},
188+
{{0x3}}}, // Overloads: hf<hf
189189
{OC::Hcos,
190190
"Hcos",
191191
OCC::Unary,
192192
"unary",
193193
Attribute::ReadNone,
194194
1,
195-
{{0x3}},
196-
{{0x0}}}, // Overloads: hf
195+
{{0x403}},
196+
{{0x3}}}, // Overloads: hf<hf
197197
{OC::Hsin,
198198
"Hsin",
199199
OCC::Unary,
200200
"unary",
201201
Attribute::ReadNone,
202202
1,
203-
{{0x3}},
204-
{{0x0}}}, // Overloads: hf
203+
{{0x403}},
204+
{{0x3}}}, // Overloads: hf<hf
205205
{OC::Htan,
206206
"Htan",
207207
OCC::Unary,
208208
"unary",
209209
Attribute::ReadNone,
210210
1,
211-
{{0x3}},
212-
{{0x0}}}, // Overloads: hf
211+
{{0x403}},
212+
{{0x3}}}, // Overloads: hf<hf
213213
{OC::Exp,
214214
"Exp",
215215
OCC::Unary,
216216
"unary",
217217
Attribute::ReadNone,
218218
1,
219-
{{0x3}},
220-
{{0x0}}}, // Overloads: hf
219+
{{0x403}},
220+
{{0x3}}}, // Overloads: hf<hf
221221
{OC::Frc,
222222
"Frc",
223223
OCC::Unary,
224224
"unary",
225225
Attribute::ReadNone,
226226
1,
227-
{{0x3}},
228-
{{0x0}}}, // Overloads: hf
227+
{{0x403}},
228+
{{0x3}}}, // Overloads: hf<hf
229229
{OC::Log,
230230
"Log",
231231
OCC::Unary,
232232
"unary",
233233
Attribute::ReadNone,
234234
1,
235-
{{0x3}},
236-
{{0x0}}}, // Overloads: hf
235+
{{0x403}},
236+
{{0x3}}}, // Overloads: hf<hf
237237
{OC::Sqrt,
238238
"Sqrt",
239239
OCC::Unary,
240240
"unary",
241241
Attribute::ReadNone,
242242
1,
243-
{{0x3}},
244-
{{0x0}}}, // Overloads: hf
243+
{{0x403}},
244+
{{0x3}}}, // Overloads: hf<hf
245245
{OC::Rsqrt,
246246
"Rsqrt",
247247
OCC::Unary,
248248
"unary",
249249
Attribute::ReadNone,
250250
1,
251-
{{0x3}},
252-
{{0x0}}}, // Overloads: hf
251+
{{0x403}},
252+
{{0x3}}}, // Overloads: hf<hf
253253

254254
// Unary float - rounding
255255
{OC::Round_ne,
@@ -258,32 +258,32 @@ const OP::OpCodeProperty OP::m_OpCodeProps[(unsigned)OP::OpCode::NumOpCodes] = {
258258
"unary",
259259
Attribute::ReadNone,
260260
1,
261-
{{0x3}},
262-
{{0x0}}}, // Overloads: hf
261+
{{0x403}},
262+
{{0x3}}}, // Overloads: hf<hf
263263
{OC::Round_ni,
264264
"Round_ni",
265265
OCC::Unary,
266266
"unary",
267267
Attribute::ReadNone,
268268
1,
269-
{{0x3}},
270-
{{0x0}}}, // Overloads: hf
269+
{{0x403}},
270+
{{0x3}}}, // Overloads: hf<hf
271271
{OC::Round_pi,
272272
"Round_pi",
273273
OCC::Unary,
274274
"unary",
275275
Attribute::ReadNone,
276276
1,
277-
{{0x3}},
278-
{{0x0}}}, // Overloads: hf
277+
{{0x403}},
278+
{{0x3}}}, // Overloads: hf<hf
279279
{OC::Round_z,
280280
"Round_z",
281281
OCC::Unary,
282282
"unary",
283283
Attribute::ReadNone,
284284
1,
285-
{{0x3}},
286-
{{0x0}}}, // Overloads: hf
285+
{{0x403}},
286+
{{0x3}}}, // Overloads: hf<hf
287287

288288
// Unary int
289289
{OC::Bfrev,
@@ -292,8 +292,8 @@ const OP::OpCodeProperty OP::m_OpCodeProps[(unsigned)OP::OpCode::NumOpCodes] = {
292292
"unary",
293293
Attribute::ReadNone,
294294
1,
295-
{{0xe0}},
296-
{{0x0}}}, // Overloads: wil
295+
{{0x4e0}},
296+
{{0xe0}}}, // Overloads: wil<wil
297297
{OC::Countbits,
298298
"Countbits",
299299
OCC::UnaryBits,
@@ -338,16 +338,16 @@ const OP::OpCodeProperty OP::m_OpCodeProps[(unsigned)OP::OpCode::NumOpCodes] = {
338338
"binary",
339339
Attribute::ReadNone,
340340
1,
341-
{{0x7}},
342-
{{0x0}}}, // Overloads: hfd
341+
{{0x407}},
342+
{{0x7}}}, // Overloads: hfd<hfd
343343
{OC::FMin,
344344
"FMin",
345345
OCC::Binary,
346346
"binary",
347347
Attribute::ReadNone,
348348
1,
349-
{{0x7}},
350-
{{0x0}}}, // Overloads: hfd
349+
{{0x407}},
350+
{{0x7}}}, // Overloads: hfd<hfd
351351

352352
// Binary int
353353
{OC::IMax,
@@ -356,16 +356,16 @@ const OP::OpCodeProperty OP::m_OpCodeProps[(unsigned)OP::OpCode::NumOpCodes] = {
356356
"binary",
357357
Attribute::ReadNone,
358358
1,
359-
{{0xe0}},
360-
{{0x0}}}, // Overloads: wil
359+
{{0x4e0}},
360+
{{0xe0}}}, // Overloads: wil<wil
361361
{OC::IMin,
362362
"IMin",
363363
OCC::Binary,
364364
"binary",
365365
Attribute::ReadNone,
366366
1,
367-
{{0xe0}},
368-
{{0x0}}}, // Overloads: wil
367+
{{0x4e0}},
368+
{{0xe0}}}, // Overloads: wil<wil
369369

370370
// Binary uint
371371
{OC::UMax,
@@ -374,16 +374,16 @@ const OP::OpCodeProperty OP::m_OpCodeProps[(unsigned)OP::OpCode::NumOpCodes] = {
374374
"binary",
375375
Attribute::ReadNone,
376376
1,
377-
{{0xe0}},
378-
{{0x0}}}, // Overloads: wil
377+
{{0x4e0}},
378+
{{0xe0}}}, // Overloads: wil<wil
379379
{OC::UMin,
380380
"UMin",
381381
OCC::Binary,
382382
"binary",
383383
Attribute::ReadNone,
384384
1,
385-
{{0xe0}},
386-
{{0x0}}}, // Overloads: wil
385+
{{0x4e0}},
386+
{{0xe0}}}, // Overloads: wil<wil
387387

388388
// Binary int with two outputs
389389
{OC::IMul,
@@ -438,16 +438,16 @@ const OP::OpCodeProperty OP::m_OpCodeProps[(unsigned)OP::OpCode::NumOpCodes] = {
438438
"tertiary",
439439
Attribute::ReadNone,
440440
1,
441-
{{0x7}},
442-
{{0x0}}}, // Overloads: hfd
441+
{{0x407}},
442+
{{0x7}}}, // Overloads: hfd<hfd
443443
{OC::Fma,
444444
"Fma",
445445
OCC::Tertiary,
446446
"tertiary",
447447
Attribute::ReadNone,
448448
1,
449-
{{0x4}},
450-
{{0x0}}}, // Overloads: d
449+
{{0x404}},
450+
{{0x4}}}, // Overloads: d<d
451451

452452
// Tertiary int
453453
{OC::IMad,
@@ -456,8 +456,8 @@ const OP::OpCodeProperty OP::m_OpCodeProps[(unsigned)OP::OpCode::NumOpCodes] = {
456456
"tertiary",
457457
Attribute::ReadNone,
458458
1,
459-
{{0xe0}},
460-
{{0x0}}}, // Overloads: wil
459+
{{0x4e0}},
460+
{{0xe0}}}, // Overloads: wil<wil
461461

462462
// Tertiary uint
463463
{OC::UMad,
@@ -466,8 +466,8 @@ const OP::OpCodeProperty OP::m_OpCodeProps[(unsigned)OP::OpCode::NumOpCodes] = {
466466
"tertiary",
467467
Attribute::ReadNone,
468468
1,
469-
{{0xe0}},
470-
{{0x0}}}, // Overloads: wil
469+
{{0x4e0}},
470+
{{0xe0}}}, // Overloads: wil<wil
471471

472472
// Tertiary int
473473
{OC::Msad,
@@ -764,32 +764,32 @@ const OP::OpCodeProperty OP::m_OpCodeProps[(unsigned)OP::OpCode::NumOpCodes] = {
764764
"unary",
765765
Attribute::ReadNone,
766766
1,
767-
{{0x3}},
768-
{{0x0}}}, // Overloads: hf
767+
{{0x403}},
768+
{{0x3}}}, // Overloads: hf<hf
769769
{OC::DerivCoarseY,
770770
"DerivCoarseY",
771771
OCC::Unary,
772772
"unary",
773773
Attribute::ReadNone,
774774
1,
775-
{{0x3}},
776-
{{0x0}}}, // Overloads: hf
775+
{{0x403}},
776+
{{0x3}}}, // Overloads: hf<hf
777777
{OC::DerivFineX,
778778
"DerivFineX",
779779
OCC::Unary,
780780
"unary",
781781
Attribute::ReadNone,
782782
1,
783-
{{0x3}},
784-
{{0x0}}}, // Overloads: hf
783+
{{0x403}},
784+
{{0x3}}}, // Overloads: hf<hf
785785
{OC::DerivFineY,
786786
"DerivFineY",
787787
OCC::Unary,
788788
"unary",
789789
Attribute::ReadNone,
790790
1,
791-
{{0x3}},
792-
{{0x0}}}, // Overloads: hf
791+
{{0x403}},
792+
{{0x3}}}, // Overloads: hf<hf
793793

794794
// Pixel shader
795795
{OC::EvalSnapped,

0 commit comments

Comments
 (0)