Skip to content

Commit 8cf8565

Browse files
authored
[DirectX] Make DXILOpBuilder's API more useable
This adjusts the DXILOpBuilder API in a couple of ways: 1. Remove the need to call `getOverloadTy` before creating Ops 2. Introduce `tryCreateOp` to parallel `createOp` but propagate errors 3. Introduce specialized createOp methods for each DXIL Op This will simplify usage of the builder in upcoming changes, and also allows us to propagate errors via DiagnosticInfo rather than using fatal errors. Pull Request: #101250
1 parent 6c783e1 commit 8cf8565

31 files changed

+205
-211
lines changed

llvm/lib/Target/DirectX/DXIL.td

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ class DXILOp<int opcode, DXILOpClass opclass> {
318318
def Abs : DXILOp<6, unary> {
319319
let Doc = "Returns the absolute value of the input.";
320320
let LLVMIntrinsic = int_fabs;
321-
let arguments = [LLVMMatchType<0>];
321+
let arguments = [overloadTy];
322322
let result = overloadTy;
323323
let overloads = [Overloads<DXIL1_0, [halfTy, floatTy, doubleTy]>];
324324
let stages = [Stages<DXIL1_0, [all_stages]>];
@@ -338,7 +338,7 @@ def IsInf : DXILOp<9, isSpecialFloat> {
338338
def Cos : DXILOp<12, unary> {
339339
let Doc = "Returns cosine(theta) for theta in radians.";
340340
let LLVMIntrinsic = int_cos;
341-
let arguments = [LLVMMatchType<0>];
341+
let arguments = [overloadTy];
342342
let result = overloadTy;
343343
let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
344344
let stages = [Stages<DXIL1_0, [all_stages]>];
@@ -348,7 +348,7 @@ def Cos : DXILOp<12, unary> {
348348
def Sin : DXILOp<13, unary> {
349349
let Doc = "Returns sine(theta) for theta in radians.";
350350
let LLVMIntrinsic = int_sin;
351-
let arguments = [LLVMMatchType<0>];
351+
let arguments = [overloadTy];
352352
let result = overloadTy;
353353
let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
354354
let stages = [Stages<DXIL1_0, [all_stages]>];
@@ -358,7 +358,7 @@ def Sin : DXILOp<13, unary> {
358358
def Tan : DXILOp<14, unary> {
359359
let Doc = "Returns tangent(theta) for theta in radians.";
360360
let LLVMIntrinsic = int_tan;
361-
let arguments = [LLVMMatchType<0>];
361+
let arguments = [overloadTy];
362362
let result = overloadTy;
363363
let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
364364
let stages = [Stages<DXIL1_0, [all_stages]>];
@@ -368,7 +368,7 @@ def Tan : DXILOp<14, unary> {
368368
def ACos : DXILOp<15, unary> {
369369
let Doc = "Returns the arccosine of the specified value.";
370370
let LLVMIntrinsic = int_acos;
371-
let arguments = [LLVMMatchType<0>];
371+
let arguments = [overloadTy];
372372
let result = overloadTy;
373373
let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
374374
let stages = [Stages<DXIL1_0, [all_stages]>];
@@ -378,7 +378,7 @@ def ACos : DXILOp<15, unary> {
378378
def ASin : DXILOp<16, unary> {
379379
let Doc = "Returns the arcsine of the specified value.";
380380
let LLVMIntrinsic = int_asin;
381-
let arguments = [LLVMMatchType<0>];
381+
let arguments = [overloadTy];
382382
let result = overloadTy;
383383
let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
384384
let stages = [Stages<DXIL1_0, [all_stages]>];
@@ -388,7 +388,7 @@ def ASin : DXILOp<16, unary> {
388388
def ATan : DXILOp<17, unary> {
389389
let Doc = "Returns the arctangent of the specified value.";
390390
let LLVMIntrinsic = int_atan;
391-
let arguments = [LLVMMatchType<0>];
391+
let arguments = [overloadTy];
392392
let result = overloadTy;
393393
let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
394394
let stages = [Stages<DXIL1_0, [all_stages]>];
@@ -398,7 +398,7 @@ def ATan : DXILOp<17, unary> {
398398
def HCos : DXILOp<18, unary> {
399399
let Doc = "Returns the hyperbolic cosine of the specified value.";
400400
let LLVMIntrinsic = int_cosh;
401-
let arguments = [LLVMMatchType<0>];
401+
let arguments = [overloadTy];
402402
let result = overloadTy;
403403
let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
404404
let stages = [Stages<DXIL1_0, [all_stages]>];
@@ -408,7 +408,7 @@ def HCos : DXILOp<18, unary> {
408408
def HSin : DXILOp<19, unary> {
409409
let Doc = "Returns the hyperbolic sine of the specified value.";
410410
let LLVMIntrinsic = int_sinh;
411-
let arguments = [LLVMMatchType<0>];
411+
let arguments = [overloadTy];
412412
let result = overloadTy;
413413
let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
414414
let stages = [Stages<DXIL1_0, [all_stages]>];
@@ -418,7 +418,7 @@ def HSin : DXILOp<19, unary> {
418418
def HTan : DXILOp<20, unary> {
419419
let Doc = "Returns the hyperbolic tan of the specified value.";
420420
let LLVMIntrinsic = int_tanh;
421-
let arguments = [LLVMMatchType<0>];
421+
let arguments = [overloadTy];
422422
let result = overloadTy;
423423
let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
424424
let stages = [Stages<DXIL1_0, [all_stages]>];
@@ -429,7 +429,7 @@ def Exp2 : DXILOp<21, unary> {
429429
let Doc = "Returns the base 2 exponential, or 2**x, of the specified value. "
430430
"exp2(x) = 2**x.";
431431
let LLVMIntrinsic = int_exp2;
432-
let arguments = [LLVMMatchType<0>];
432+
let arguments = [overloadTy];
433433
let result = overloadTy;
434434
let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
435435
let stages = [Stages<DXIL1_0, [all_stages]>];
@@ -440,7 +440,7 @@ def Frac : DXILOp<22, unary> {
440440
let Doc = "Returns a fraction from 0 to 1 that represents the decimal part "
441441
"of the input.";
442442
let LLVMIntrinsic = int_dx_frac;
443-
let arguments = [LLVMMatchType<0>];
443+
let arguments = [overloadTy];
444444
let result = overloadTy;
445445
let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
446446
let stages = [Stages<DXIL1_0, [all_stages]>];
@@ -450,7 +450,7 @@ def Frac : DXILOp<22, unary> {
450450
def Log2 : DXILOp<23, unary> {
451451
let Doc = "Returns the base-2 logarithm of the specified value.";
452452
let LLVMIntrinsic = int_log2;
453-
let arguments = [LLVMMatchType<0>];
453+
let arguments = [overloadTy];
454454
let result = overloadTy;
455455
let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
456456
let stages = [Stages<DXIL1_0, [all_stages]>];
@@ -461,7 +461,7 @@ def Sqrt : DXILOp<24, unary> {
461461
let Doc = "Returns the square root of the specified floating-point value, "
462462
"per component.";
463463
let LLVMIntrinsic = int_sqrt;
464-
let arguments = [LLVMMatchType<0>];
464+
let arguments = [overloadTy];
465465
let result = overloadTy;
466466
let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
467467
let stages = [Stages<DXIL1_0, [all_stages]>];
@@ -472,7 +472,7 @@ def RSqrt : DXILOp<25, unary> {
472472
let Doc = "Returns the reciprocal of the square root of the specified value. "
473473
"rsqrt(x) = 1 / sqrt(x).";
474474
let LLVMIntrinsic = int_dx_rsqrt;
475-
let arguments = [LLVMMatchType<0>];
475+
let arguments = [overloadTy];
476476
let result = overloadTy;
477477
let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
478478
let stages = [Stages<DXIL1_0, [all_stages]>];
@@ -483,7 +483,7 @@ def Round : DXILOp<26, unary> {
483483
let Doc = "Returns the input rounded to the nearest integer within a "
484484
"floating-point type.";
485485
let LLVMIntrinsic = int_roundeven;
486-
let arguments = [LLVMMatchType<0>];
486+
let arguments = [overloadTy];
487487
let result = overloadTy;
488488
let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
489489
let stages = [Stages<DXIL1_0, [all_stages]>];
@@ -494,7 +494,7 @@ def Floor : DXILOp<27, unary> {
494494
let Doc =
495495
"Returns the largest integer that is less than or equal to the input.";
496496
let LLVMIntrinsic = int_floor;
497-
let arguments = [LLVMMatchType<0>];
497+
let arguments = [overloadTy];
498498
let result = overloadTy;
499499
let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
500500
let stages = [Stages<DXIL1_0, [all_stages]>];
@@ -505,7 +505,7 @@ def Ceil : DXILOp<28, unary> {
505505
let Doc = "Returns the smallest integer that is greater than or equal to the "
506506
"input.";
507507
let LLVMIntrinsic = int_ceil;
508-
let arguments = [LLVMMatchType<0>];
508+
let arguments = [overloadTy];
509509
let result = overloadTy;
510510
let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
511511
let stages = [Stages<DXIL1_0, [all_stages]>];
@@ -515,7 +515,7 @@ def Ceil : DXILOp<28, unary> {
515515
def Trunc : DXILOp<29, unary> {
516516
let Doc = "Returns the specified value truncated to the integer component.";
517517
let LLVMIntrinsic = int_trunc;
518-
let arguments = [LLVMMatchType<0>];
518+
let arguments = [overloadTy];
519519
let result = overloadTy;
520520
let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
521521
let stages = [Stages<DXIL1_0, [all_stages]>];
@@ -525,7 +525,7 @@ def Trunc : DXILOp<29, unary> {
525525
def Rbits : DXILOp<30, unary> {
526526
let Doc = "Returns the specified value with its bits reversed.";
527527
let LLVMIntrinsic = int_bitreverse;
528-
let arguments = [LLVMMatchType<0>];
528+
let arguments = [overloadTy];
529529
let result = overloadTy;
530530
let overloads =
531531
[Overloads<DXIL1_0, [i16Ty, i32Ty, i64Ty]>];
@@ -536,7 +536,7 @@ def Rbits : DXILOp<30, unary> {
536536
def FMax : DXILOp<35, binary> {
537537
let Doc = "Float maximum. FMax(a,b) = a > b ? a : b";
538538
let LLVMIntrinsic = int_maxnum;
539-
let arguments = [LLVMMatchType<0>, LLVMMatchType<0>];
539+
let arguments = [overloadTy, overloadTy];
540540
let result = overloadTy;
541541
let overloads =
542542
[Overloads<DXIL1_0, [halfTy, floatTy, doubleTy]>];
@@ -547,7 +547,7 @@ def FMax : DXILOp<35, binary> {
547547
def FMin : DXILOp<36, binary> {
548548
let Doc = "Float minimum. FMin(a,b) = a < b ? a : b";
549549
let LLVMIntrinsic = int_minnum;
550-
let arguments = [LLVMMatchType<0>, LLVMMatchType<0>];
550+
let arguments = [overloadTy, overloadTy];
551551
let result = overloadTy;
552552
let overloads =
553553
[Overloads<DXIL1_0, [halfTy, floatTy, doubleTy]>];
@@ -558,7 +558,7 @@ def FMin : DXILOp<36, binary> {
558558
def SMax : DXILOp<37, binary> {
559559
let Doc = "Signed integer maximum. SMax(a,b) = a > b ? a : b";
560560
let LLVMIntrinsic = int_smax;
561-
let arguments = [LLVMMatchType<0>, LLVMMatchType<0>];
561+
let arguments = [overloadTy, overloadTy];
562562
let result = overloadTy;
563563
let overloads =
564564
[Overloads<DXIL1_0, [i16Ty, i32Ty, i64Ty]>];
@@ -569,7 +569,7 @@ def SMax : DXILOp<37, binary> {
569569
def SMin : DXILOp<38, binary> {
570570
let Doc = "Signed integer minimum. SMin(a,b) = a < b ? a : b";
571571
let LLVMIntrinsic = int_smin;
572-
let arguments = [LLVMMatchType<0>, LLVMMatchType<0>];
572+
let arguments = [overloadTy, overloadTy];
573573
let result = overloadTy;
574574
let overloads =
575575
[Overloads<DXIL1_0, [i16Ty, i32Ty, i64Ty]>];
@@ -580,7 +580,7 @@ def SMin : DXILOp<38, binary> {
580580
def UMax : DXILOp<39, binary> {
581581
let Doc = "Unsigned integer maximum. UMax(a,b) = a > b ? a : b";
582582
let LLVMIntrinsic = int_umax;
583-
let arguments = [LLVMMatchType<0>, LLVMMatchType<0>];
583+
let arguments = [overloadTy, overloadTy];
584584
let result = overloadTy;
585585
let overloads =
586586
[Overloads<DXIL1_0, [i16Ty, i32Ty, i64Ty]>];
@@ -591,7 +591,7 @@ def UMax : DXILOp<39, binary> {
591591
def UMin : DXILOp<40, binary> {
592592
let Doc = "Unsigned integer minimum. UMin(a,b) = a < b ? a : b";
593593
let LLVMIntrinsic = int_umin;
594-
let arguments = [LLVMMatchType<0>, LLVMMatchType<0>];
594+
let arguments = [overloadTy, overloadTy];
595595
let result = overloadTy;
596596
let overloads =
597597
[Overloads<DXIL1_0, [i16Ty, i32Ty, i64Ty]>];
@@ -603,7 +603,7 @@ def FMad : DXILOp<46, tertiary> {
603603
let Doc = "Floating point arithmetic multiply/add operation. fmad(m,a,b) = m "
604604
"* a + b.";
605605
let LLVMIntrinsic = int_fmuladd;
606-
let arguments = [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>];
606+
let arguments = [overloadTy, overloadTy, overloadTy];
607607
let result = overloadTy;
608608
let overloads =
609609
[Overloads<DXIL1_0, [halfTy, floatTy, doubleTy]>];
@@ -615,7 +615,7 @@ def IMad : DXILOp<48, tertiary> {
615615
let Doc = "Signed integer arithmetic multiply/add operation. imad(m,a,b) = m "
616616
"* a + b.";
617617
let LLVMIntrinsic = int_dx_imad;
618-
let arguments = [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>];
618+
let arguments = [overloadTy, overloadTy, overloadTy];
619619
let result = overloadTy;
620620
let overloads =
621621
[Overloads<DXIL1_0, [i16Ty, i32Ty, i64Ty]>];
@@ -627,7 +627,7 @@ def UMad : DXILOp<49, tertiary> {
627627
let Doc = "Unsigned integer arithmetic multiply/add operation. umad(m,a, = m "
628628
"* a + b.";
629629
let LLVMIntrinsic = int_dx_umad;
630-
let arguments = [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>];
630+
let arguments = [overloadTy, overloadTy, overloadTy];
631631
let result = overloadTy;
632632
let overloads =
633633
[Overloads<DXIL1_0, [i16Ty, i32Ty, i64Ty]>];

0 commit comments

Comments
 (0)