@@ -427,52 +427,57 @@ def VectorSplatArg : MemRefOf<[VectorEltTy]>;
427
427
// SYCL GRID OPERATIONS
428
428
////////////////////////////////////////////////////////////////////////////////
429
429
430
- def SYCLNumWorkItemsOp : SYCL_Op<"num_work_items", [SYCLIndexSpaceGetRange]> {
430
+ class SYCL1DGridOp<string mnemonic, list<Trait> traits = []>
431
+ : SYCL_Op<mnemonic, traits> {
432
+ let arguments = (ins);
433
+ let results = (outs I32:$result);
434
+ let assemblyFormat = "attr-dict `:` type($result)";
435
+ }
436
+
437
+ class SYCL3DGridOp<string mnemonic, list<Trait> traits = []>
438
+ : SYCL_Op<mnemonic, traits> {
439
+ let arguments = (ins Optional<I32>:$dimension);
440
+ let assemblyFormat = "$dimension attr-dict `:` type($result)";
441
+ }
442
+
443
+ class SYCL3DIDGridOp<string mnemonic>
444
+ : SYCL3DGridOp<mnemonic, [SYCLIndexSpaceGetID]> {
445
+ let results = (outs SYCLIndexSpaceGetIDResult:$result);
446
+ }
447
+
448
+ class SYCL3DRangeGridOp<string mnemonic>
449
+ : SYCL3DGridOp<mnemonic, [SYCLIndexSpaceGetRange]> {
450
+ let results = (outs SYCLIndexSpaceGetRangeResult:$result);
451
+ }
452
+
453
+ def SYCLNumWorkItemsOp : SYCL3DRangeGridOp<"num_work_items"> {
431
454
let summary = "Retrieve the number of work-items.";
432
455
let description = [{
433
456
This operation returns the number of work-items in the index space. If the
434
457
optional argument is passed, the number of work-items in the given dimension
435
458
is returned.
436
459
}];
437
-
438
- let arguments = (ins Optional<I32>:$dimension);
439
- let results = (outs SYCLIndexSpaceGetRangeResult:$result);
440
- let assemblyFormat = [{
441
- `(` operands `)` attr-dict `:` functional-type(operands, results)
442
- }];
443
460
}
444
461
445
- def SYCLGlobalIDOp : SYCL_Op <"global_id", [SYCLIndexSpaceGetID] > {
462
+ def SYCLGlobalIDOp : SYCL3DIDGridOp <"global_id"> {
446
463
let summary = "Retrieve the global ID of the item.";
447
464
let description = [{
448
465
This operation returns the global ID of the item in the index space. If the
449
466
optional argument is passed, the global ID of the item in the given
450
467
dimension is returned.
451
468
}];
452
-
453
- let arguments = (ins Optional<I32>:$dimension);
454
- let results = (outs SYCLIndexSpaceGetIDResult:$result);
455
- let assemblyFormat = [{
456
- `(` operands `)` attr-dict `:` functional-type(operands, results)
457
- }];
458
469
}
459
470
460
- def SYCLLocalIDOp : SYCL_Op <"local_id", [SYCLIndexSpaceGetID] > {
471
+ def SYCLLocalIDOp : SYCL3DIDGridOp <"local_id"> {
461
472
let summary = "Retrieve the local ID of the item.";
462
473
let description = [{
463
474
This operation returns the local ID of the item within the work-group. If
464
475
the optional argument is passed, the local ID of the item in the given
465
476
dimension is returned.
466
477
}];
467
-
468
- let arguments = (ins Optional<I32>:$dimension);
469
- let results = (outs SYCLIndexSpaceGetIDResult:$result);
470
- let assemblyFormat = [{
471
- `(` operands `)` attr-dict `:` functional-type(operands, results)
472
- }];
473
478
}
474
479
475
- def SYCLGlobalOffsetOp : SYCL_Op <"global_offset", [SYCLIndexSpaceGetID] >,
480
+ def SYCLGlobalOffsetOp : SYCL3DIDGridOp <"global_offset">,
476
481
Deprecated<"deprecated in SYCL 2020"> {
477
482
let summary = "Retrieve the global offset of the item.";
478
483
let description = [{
@@ -482,121 +487,67 @@ def SYCLGlobalOffsetOp : SYCL_Op<"global_offset", [SYCLIndexSpaceGetID]>,
482
487
483
488
Note that this is deprecated in SYCL 2020.
484
489
}];
485
-
486
- let arguments = (ins Optional<I32>:$dimension);
487
- let results = (outs SYCLIndexSpaceGetIDResult:$result);
488
- let assemblyFormat = [{
489
- `(` operands `)` attr-dict `:` functional-type(operands, results)
490
- }];
491
490
}
492
491
493
- def SYCLNumWorkGroupsOp : SYCL_Op <"num_work_groups", [SYCLIndexSpaceGetRange] > {
492
+ def SYCLNumWorkGroupsOp : SYCL3DRangeGridOp <"num_work_groups"> {
494
493
let summary = "Retrieve the number of work-groups.";
495
494
let description = [{
496
495
This operation returns the number of work-groups in the index space. If the
497
496
optional argument is passed, the number of work-groups in the given
498
497
dimension is returned.
499
498
}];
500
-
501
- let arguments = (ins Optional<I32>:$dimension);
502
- let results = (outs SYCLIndexSpaceGetRangeResult:$result);
503
- let assemblyFormat = [{
504
- `(` operands `)` attr-dict `:` functional-type(operands, results)
505
- }];
506
499
}
507
500
508
- def SYCLWorkGroupSizeOp : SYCL_Op <"work_group_size", [SYCLIndexSpaceGetRange] > {
501
+ def SYCLWorkGroupSizeOp : SYCL3DRangeGridOp <"work_group_size"> {
509
502
let summary = "Retrieve the number of work-items in a work-group.";
510
503
let description = [{
511
504
This operation returns the number of work-items per work-group. If the
512
505
optional argument is passed, the number of work-items per work-group in the
513
506
given dimension is returned.
514
507
}];
515
-
516
- let arguments = (ins Optional<I32>:$dimension);
517
- let results = (outs SYCLIndexSpaceGetRangeResult:$result);
518
- let assemblyFormat = [{
519
- `(` operands `)` attr-dict `:` functional-type(operands, results)
520
- }];
521
508
}
522
509
523
- def SYCLWorkGroupIDOp : SYCL_Op <"work_group_id", [SYCLIndexSpaceGetID] > {
510
+ def SYCLWorkGroupIDOp : SYCL3DIDGridOp <"work_group_id"> {
524
511
let summary = "Retrieve the ID of the work-group.";
525
512
let description = [{
526
513
This operation returns the ID of the work-group. If the optional argument is
527
514
passed, the ID of the work-group in the given dimension is returned.
528
515
}];
529
-
530
- let arguments = (ins Optional<I32>:$dimension);
531
- let results = (outs SYCLIndexSpaceGetIDResult:$result);
532
- let assemblyFormat = [{
533
- `(` operands `)` attr-dict `:` functional-type(operands, results)
534
- }];
535
516
}
536
517
537
- def SYCLNumSubGroupsOp : SYCL_Op <"num_sub_groups"> {
518
+ def SYCLNumSubGroupsOp : SYCL1DGridOp <"num_sub_groups"> {
538
519
let summary = "Retrieve the number of sub-groups.";
539
520
let description = [{
540
521
This operation returns the number of sub-groups.
541
522
}];
542
-
543
- let arguments = (ins);
544
- let results = (outs I32:$result);
545
- let assemblyFormat = [{
546
- attr-dict `:` functional-type(operands, results)
547
- }];
548
523
}
549
524
550
- def SYCLSubGroupMaxSizeOp : SYCL_Op <"sub_group_max_size"> {
525
+ def SYCLSubGroupMaxSizeOp : SYCL1DGridOp <"sub_group_max_size"> {
551
526
let summary = "Retrieve the maximum size of a sub-group.";
552
527
let description = [{
553
528
This operation returns the maximum size of a sub-group.
554
529
}];
555
-
556
- let arguments = (ins);
557
- let results = (outs I32:$result);
558
- let assemblyFormat = [{
559
- attr-dict `:` functional-type(operands, results)
560
- }];
561
530
}
562
531
563
- def SYCLSubGroupSizeOp : SYCL_Op <"sub_group_size"> {
532
+ def SYCLSubGroupSizeOp : SYCL1DGridOp <"sub_group_size"> {
564
533
let summary = "Retrieve the sub-group size.";
565
534
let description = [{
566
535
This operation returns the sub-group size.
567
536
}];
568
-
569
- let arguments = (ins);
570
- let results = (outs I32:$result);
571
- let assemblyFormat = [{
572
- attr-dict `:` functional-type(operands, results)
573
- }];
574
537
}
575
538
576
- def SYCLSubGroupIDOp : SYCL_Op <"sub_group_id"> {
539
+ def SYCLSubGroupIDOp : SYCL1DGridOp <"sub_group_id"> {
577
540
let summary = "Retrieve the ID of the sub-group.";
578
541
let description = [{
579
542
This operation returns the ID of the sub-group.
580
543
}];
581
-
582
- let arguments = (ins);
583
- let results = (outs I32:$result);
584
- let assemblyFormat = [{
585
- attr-dict `:` functional-type(operands, results)
586
- }];
587
544
}
588
545
589
- def SYCLSubGroupLocalIDOp : SYCL_Op <"sub_group_local_id"> {
546
+ def SYCLSubGroupLocalIDOp : SYCL1DGridOp <"sub_group_local_id"> {
590
547
let summary = "Retrieve the local ID of the sub-group.";
591
548
let description = [{
592
549
This operation returns the local ID of the sub-group.
593
550
}];
594
-
595
- let arguments = (ins);
596
- let results = (outs I32:$result);
597
- let assemblyFormat = [{
598
- attr-dict `:` functional-type(operands, results)
599
- }];
600
551
}
601
552
602
553
////////////////////////////////////////////////////////////////////////////////
0 commit comments