@@ -505,6 +505,9 @@ def WsLoopOp : OpenMP_Op<"wsloop", [AttrSizedOperandSegments,
505
505
506
506
/// Returns the number of reduction variables.
507
507
unsigned getNumReductionVars() { return getReductionVars().size(); }
508
+
509
+ /// Returns its nested 'omp.simd' operation, if present.
510
+ SimdOp getNestedSimd();
508
511
}];
509
512
let hasCustomAssemblyFormat = 1;
510
513
let assemblyFormat = [{
@@ -617,11 +620,84 @@ def SimdLoopOp : OpenMP_Op<"simdloop", [AttrSizedOperandSegments,
617
620
let hasVerifier = 1;
618
621
}
619
622
623
+ def SimdOp : OpenMP_Op<"simd",
624
+ [AttrSizedOperandSegments, MemoryEffects<[MemWrite]>,
625
+ HasParent<"WsLoopOp">]> {
626
+ let summary = "simd construct";
627
+ let description = [{
628
+ The simd construct can be applied to a loop to indicate that the loop can be
629
+ transformed into a SIMD loop (that is, multiple iterations of the loop can
630
+ be executed concurrently using SIMD instructions).
631
+
632
+ This operation is intended to hold SIMD information for a worksharing loop
633
+ (i.e. "omp for simd"), so it must always be nested inside of a parent
634
+ "omp.wsloop" operation as its only child. For SIMD loops not combined with a
635
+ worksharing loop (i.e. "omp simd"), the "omp.simdloop" is used instead.
636
+
637
+ The body region can contain any number of blocks. The region is terminated
638
+ by "omp.yield" instruction without operands.
639
+
640
+ The `alignment_values` attribute additionally specifies alignment of each
641
+ corresponding aligned operand. Note that `aligned_vars` and
642
+ `alignment_values` should contain the same number of elements.
643
+
644
+ When an if clause is present and evaluates to false, the preferred number of
645
+ iterations to be executed concurrently is one, regardless of whether
646
+ a simdlen clause is specified.
647
+
648
+ The optional `nontemporal` attribute specifies variables which have low
649
+ temporal locality across the iterations where they are accessed.
650
+
651
+ The optional `order` attribute specifies which order the iterations of the
652
+ associate loops are executed in. Currently the only option for this
653
+ attribute is "concurrent".
654
+
655
+ When a simdlen clause is present, the preferred number of iterations to be
656
+ executed concurrently is the value provided to the simdlen clause.
657
+
658
+ The safelen clause specifies that no two concurrent iterations within a
659
+ SIMD chunk can have a distance in the logical iteration space that is
660
+ greater than or equal to the value given in the clause.
661
+ ```
662
+ omp.wsloop for (%i) : index = (%c0) to (%c10) step (%c1) {
663
+ omp.simd <clauses> {
664
+ // block operations
665
+ omp.yield
666
+ }
667
+ omp.yield
668
+ ```
669
+ }];
670
+
671
+ // TODO: Add other clauses
672
+ let arguments = (ins Variadic<OpenMP_PointerLikeType>:$aligned_vars,
673
+ OptionalAttr<I64ArrayAttr>:$alignment_values,
674
+ Optional<I1>:$if_expr,
675
+ Variadic<OpenMP_PointerLikeType>:$nontemporal_vars,
676
+ OptionalAttr<OrderKindAttr>:$order_val,
677
+ ConfinedAttr<OptionalAttr<I64Attr>, [IntPositive]>:$simdlen,
678
+ ConfinedAttr<OptionalAttr<I64Attr>, [IntPositive]>:$safelen
679
+ );
680
+
681
+ let regions = (region AnyRegion:$region);
682
+ let assemblyFormat = [{
683
+ oilist(`aligned` `(`
684
+ custom<AlignedClause>($aligned_vars, type($aligned_vars),
685
+ $alignment_values) `)`
686
+ |`if` `(` $if_expr `)`
687
+ |`nontemporal` `(` $nontemporal_vars `:` type($nontemporal_vars) `)`
688
+ |`order` `(` custom<ClauseAttr>($order_val) `)`
689
+ |`simdlen` `(` $simdlen `)`
690
+ |`safelen` `(` $safelen `)`
691
+ ) $region attr-dict
692
+ }];
693
+
694
+ let hasVerifier = 1;
695
+ }
620
696
621
697
def YieldOp : OpenMP_Op<"yield",
622
698
[Pure, ReturnLike, Terminator,
623
699
ParentOneOf<["WsLoopOp", "ReductionDeclareOp",
624
- "AtomicUpdateOp", "SimdLoopOp"]>]> {
700
+ "AtomicUpdateOp", "SimdLoopOp", "SimdOp" ]>]> {
625
701
let summary = "loop yield and termination operation";
626
702
let description = [{
627
703
"omp.yield" yields SSA values from the OpenMP dialect op region and
0 commit comments