@@ -3424,7 +3424,20 @@ struct AssignedGotoStmt {
3424
3424
3425
3425
WRAPPER_CLASS (PauseStmt, std::optional<StopCode>);
3426
3426
3427
- // Parse tree nodes for OpenMP 5.2 directives and clauses
3427
+ // Parse tree nodes for OpenMP directives and clauses
3428
+
3429
+ // --- Common definitions
3430
+
3431
+ // 2.1 Directives or clauses may accept a list or extended-list.
3432
+ // A list item is a variable, array section or common block name (enclosed
3433
+ // in slashes). An extended list item is a list item or a procedure Name.
3434
+ // variable-name | / common-block / | array-sections
3435
+ struct OmpObject {
3436
+ UNION_CLASS_BOILERPLATE (OmpObject);
3437
+ std::variant<Designator, /* common block*/ Name> u;
3438
+ };
3439
+
3440
+ WRAPPER_CLASS (OmpObjectList, std::list<OmpObject>);
3428
3441
3429
3442
// [5.0] 2.1.6 iterator-specifier -> type-declaration-stmt = subscript-triple
3430
3443
// iterator-modifier -> iterator-specifier-list
@@ -3436,50 +3449,54 @@ struct OmpIteratorSpecifier {
3436
3449
3437
3450
WRAPPER_CLASS (OmpIteratorModifier, std::list<OmpIteratorSpecifier>);
3438
3451
3439
- // 2.5 proc-bind-clause -> PROC_BIND (MASTER | CLOSE | SPREAD)
3440
- struct OmpProcBindClause {
3441
- ENUM_CLASS (Type, Close, Master, Spread, Primary)
3442
- WRAPPER_CLASS_BOILERPLATE (OmpProcBindClause, Type);
3452
+ // 2.15.3.6 reduction-identifier -> + | - | * | .AND. | .OR. | .EQV. | .NEQV. |
3453
+ // MAX | MIN | IAND | IOR | IEOR
3454
+ struct OmpReductionOperator {
3455
+ UNION_CLASS_BOILERPLATE (OmpReductionOperator);
3456
+ std::variant<DefinedOperator, ProcedureDesignator> u;
3443
3457
};
3444
3458
3445
- // 2.15.3.1 default-clause -> DEFAULT (PRIVATE | FIRSTPRIVATE | SHARED | NONE)
3446
- struct OmpDefaultClause {
3447
- ENUM_CLASS (Type, Private, Firstprivate, Shared, None)
3448
- WRAPPER_CLASS_BOILERPLATE (OmpDefaultClause, Type);
3449
- };
3459
+ // --- Clauses
3450
3460
3451
- // 2.1 Directives or clauses may accept a list or extended-list.
3452
- // A list item is a variable, array section or common block name (enclosed
3453
- // in slashes). An extended list item is a list item or a procedure Name.
3454
- // variable-name | / common-block / | array-sections
3455
- struct OmpObject {
3456
- UNION_CLASS_BOILERPLATE (OmpObject);
3457
- std::variant<Designator, /* common block*/ Name> u;
3461
+ // 2.8.1 aligned-clause -> ALIGNED (variable-name-list[ : scalar-constant])
3462
+ struct OmpAlignedClause {
3463
+ TUPLE_CLASS_BOILERPLATE (OmpAlignedClause);
3464
+ CharBlock source;
3465
+ std::tuple<OmpObjectList, std::optional<ScalarIntConstantExpr>> t;
3458
3466
};
3459
3467
3460
- WRAPPER_CLASS (OmpObjectList, std::list<OmpObject>);
3468
+ // OMP 5.0 2.11.4 allocate-clause -> ALLOCATE ([allocator:] variable-name-list)
3469
+ // OMP 5.2 2.13.4 allocate-clause -> ALLOCATE ([allocate-modifier [,
3470
+ // allocate-modifier] :]
3471
+ // variable-name-list)
3472
+ // allocate-modifier -> allocator | align
3473
+ struct OmpAllocateClause {
3474
+ struct AllocateModifier {
3475
+ WRAPPER_CLASS (Allocator, ScalarIntExpr);
3476
+ WRAPPER_CLASS (Align, ScalarIntExpr);
3477
+ struct ComplexModifier {
3478
+ TUPLE_CLASS_BOILERPLATE (ComplexModifier);
3479
+ std::tuple<Allocator, Align> t;
3480
+ };
3481
+ UNION_CLASS_BOILERPLATE (AllocateModifier);
3482
+ std::variant<Allocator, ComplexModifier, Align> u;
3483
+ };
3484
+ TUPLE_CLASS_BOILERPLATE (OmpAllocateClause);
3485
+ std::tuple<std::optional<AllocateModifier>, OmpObjectList> t;
3486
+ };
3461
3487
3462
- // 2.15.5.1 map ->
3463
- // MAP ([[map-type-modifier-list [,]] [iterator-modifier [,]] map-type : ]
3464
- // variable-name-list)
3465
- // map-type-modifier-list -> map-type-modifier [,] [...]
3466
- // map-type-modifier -> ALWAYS | CLOSE | PRESENT | OMPX_HOLD
3467
- // map-type -> TO | FROM | TOFROM | ALLOC | RELEASE | DELETE
3468
- struct OmpMapClause {
3469
- ENUM_CLASS (TypeModifier, Always, Close, Present, Ompx_Hold);
3470
- ENUM_CLASS (Type, To, From, Tofrom, Alloc, Release, Delete)
3471
- TUPLE_CLASS_BOILERPLATE (OmpMapClause);
3488
+ // OMP 5.0 2.4 atomic-default-mem-order-clause ->
3489
+ // ATOMIC_DEFAULT_MEM_ORDER (SEQ_CST | ACQ_REL |
3490
+ // RELAXED)
3491
+ struct OmpAtomicDefaultMemOrderClause {
3492
+ WRAPPER_CLASS_BOILERPLATE (
3493
+ OmpAtomicDefaultMemOrderClause, common::OmpAtomicDefaultMemOrderType);
3494
+ };
3472
3495
3473
- // All modifiers are parsed into optional lists, even if they are unique.
3474
- // The checks for satisfying those constraints are deferred to semantics.
3475
- // In OpenMP 5.2 the non-comma syntax has been deprecated: keep the
3476
- // information about separator presence to emit a diagnostic if needed.
3477
- std::tuple<std::optional<std::list<TypeModifier>>,
3478
- std::optional<std::list<OmpIteratorModifier>>, // unique
3479
- std::optional<std::list<Type>>, // unique
3480
- OmpObjectList,
3481
- bool > // were the modifiers comma-separated?
3482
- t;
3496
+ // 2.15.3.1 default-clause -> DEFAULT (PRIVATE | FIRSTPRIVATE | SHARED | NONE)
3497
+ struct OmpDefaultClause {
3498
+ ENUM_CLASS (Type, Private, Firstprivate, Shared, None)
3499
+ WRAPPER_CLASS_BOILERPLATE (OmpDefaultClause, Type);
3483
3500
};
3484
3501
3485
3502
// 2.15.5.2 defaultmap -> DEFAULTMAP (implicit-behavior[:variable-category])
@@ -3491,29 +3508,6 @@ struct OmpDefaultmapClause {
3491
3508
std::tuple<ImplicitBehavior, std::optional<VariableCategory>> t;
3492
3509
};
3493
3510
3494
- // 2.7.1 sched-modifier -> MONOTONIC | NONMONOTONIC | SIMD
3495
- struct OmpScheduleModifierType {
3496
- ENUM_CLASS (ModType, Monotonic, Nonmonotonic, Simd)
3497
- WRAPPER_CLASS_BOILERPLATE (OmpScheduleModifierType, ModType);
3498
- };
3499
-
3500
- struct OmpScheduleModifier {
3501
- TUPLE_CLASS_BOILERPLATE (OmpScheduleModifier);
3502
- WRAPPER_CLASS (Modifier1, OmpScheduleModifierType);
3503
- WRAPPER_CLASS (Modifier2, OmpScheduleModifierType);
3504
- std::tuple<Modifier1, std::optional<Modifier2>> t;
3505
- };
3506
-
3507
- // 2.7.1 schedule-clause -> SCHEDULE ([sched-modifier1] [, sched-modifier2]:]
3508
- // kind[, chunk_size])
3509
- struct OmpScheduleClause {
3510
- TUPLE_CLASS_BOILERPLATE (OmpScheduleClause);
3511
- ENUM_CLASS (ScheduleType, Static, Dynamic, Guided, Auto, Runtime)
3512
- std::tuple<std::optional<OmpScheduleModifier>, ScheduleType,
3513
- std::optional<ScalarIntExpr>>
3514
- t;
3515
- };
3516
-
3517
3511
// device([ device-modifier :] scalar-integer-expression)
3518
3512
struct OmpDeviceClause {
3519
3513
TUPLE_CLASS_BOILERPLATE (OmpDeviceClause);
@@ -3527,6 +3521,37 @@ struct OmpDeviceTypeClause {
3527
3521
WRAPPER_CLASS_BOILERPLATE (OmpDeviceTypeClause, Type);
3528
3522
};
3529
3523
3524
+ // 2.13.9 depend-vec-length -> +/- non-negative-constant
3525
+ struct OmpDependSinkVecLength {
3526
+ TUPLE_CLASS_BOILERPLATE (OmpDependSinkVecLength);
3527
+ std::tuple<DefinedOperator, ScalarIntConstantExpr> t;
3528
+ };
3529
+
3530
+ // 2.13.9 depend-vec -> iterator [+/- depend-vec-length],...,iterator[...]
3531
+ struct OmpDependSinkVec {
3532
+ TUPLE_CLASS_BOILERPLATE (OmpDependSinkVec);
3533
+ std::tuple<Name, std::optional<OmpDependSinkVecLength>> t;
3534
+ };
3535
+
3536
+ // 2.13.9 depend-type -> IN | OUT | INOUT | SOURCE | SINK
3537
+ struct OmpDependenceType {
3538
+ ENUM_CLASS (Type, In, Out, Inout, Source, Sink)
3539
+ WRAPPER_CLASS_BOILERPLATE (OmpDependenceType, Type);
3540
+ };
3541
+
3542
+ // 2.13.9 depend-clause -> DEPEND (((IN | OUT | INOUT) : variable-name-list) |
3543
+ // SOURCE | SINK : depend-vec)
3544
+ struct OmpDependClause {
3545
+ UNION_CLASS_BOILERPLATE (OmpDependClause);
3546
+ EMPTY_CLASS (Source);
3547
+ WRAPPER_CLASS (Sink, std::list<OmpDependSinkVec>);
3548
+ struct InOut {
3549
+ TUPLE_CLASS_BOILERPLATE (InOut);
3550
+ std::tuple<OmpDependenceType, std::list<Designator>> t;
3551
+ };
3552
+ std::variant<Source, Sink, InOut> u;
3553
+ };
3554
+
3530
3555
// 2.12 if-clause -> IF ([ directive-name-modifier :] scalar-logical-expr)
3531
3556
struct OmpIfClause {
3532
3557
TUPLE_CLASS_BOILERPLATE (OmpIfClause);
@@ -3535,24 +3560,20 @@ struct OmpIfClause {
3535
3560
std::tuple<std::optional<DirectiveNameModifier>, ScalarLogicalExpr> t;
3536
3561
};
3537
3562
3538
- // 2.8.1 aligned-clause -> ALIGNED (variable-name-list[ : scalar-constant])
3539
- struct OmpAlignedClause {
3540
- TUPLE_CLASS_BOILERPLATE (OmpAlignedClause);
3541
- CharBlock source;
3542
- std::tuple<OmpObjectList, std::optional<ScalarIntConstantExpr>> t;
3543
- };
3544
-
3545
- // 2.9.5 order-clause -> ORDER ([order-modifier :]concurrent)
3546
- struct OmpOrderModifier {
3547
- UNION_CLASS_BOILERPLATE (OmpOrderModifier);
3548
- ENUM_CLASS (Kind, Reproducible, Unconstrained)
3549
- std::variant<Kind> u;
3563
+ // OMP 5.0 2.19.5.6 in_reduction-clause -> IN_REDUCTION (reduction-identifier:
3564
+ // variable-name-list)
3565
+ struct OmpInReductionClause {
3566
+ TUPLE_CLASS_BOILERPLATE (OmpInReductionClause);
3567
+ std::tuple<OmpReductionOperator, OmpObjectList> t;
3550
3568
};
3551
3569
3552
- struct OmpOrderClause {
3553
- TUPLE_CLASS_BOILERPLATE (OmpOrderClause);
3554
- ENUM_CLASS (Type, Concurrent)
3555
- std::tuple<std::optional<OmpOrderModifier>, Type> t;
3570
+ // OMP 5.0 2.19.4.5 lastprivate-clause ->
3571
+ // LASTPRIVATE ([lastprivate-modifier :] list)
3572
+ // lastprivate-modifier -> CONDITIONAL
3573
+ struct OmpLastprivateClause {
3574
+ TUPLE_CLASS_BOILERPLATE (OmpLastprivateClause);
3575
+ ENUM_CLASS (LastprivateModifier, Conditional);
3576
+ std::tuple<std::optional<LastprivateModifier>, OmpObjectList> t;
3556
3577
};
3557
3578
3558
3579
// 2.15.3.7 linear-modifier -> REF | VAL | UVAL
@@ -3585,96 +3606,79 @@ struct OmpLinearClause {
3585
3606
std::variant<WithModifier, WithoutModifier> u;
3586
3607
};
3587
3608
3588
- // 2.15.3.6 reduction-identifier -> + | - | * | .AND. | .OR. | .EQV. | .NEQV. |
3589
- // MAX | MIN | IAND | IOR | IEOR
3590
- struct OmpReductionOperator {
3591
- UNION_CLASS_BOILERPLATE (OmpReductionOperator);
3592
- std::variant<DefinedOperator, ProcedureDesignator> u;
3593
- };
3609
+ // 2.15.5.1 map ->
3610
+ // MAP ([[map-type-modifier-list [,]] [iterator-modifier [,]] map-type : ]
3611
+ // variable-name-list)
3612
+ // map-type-modifier-list -> map-type-modifier [,] [...]
3613
+ // map-type-modifier -> ALWAYS | CLOSE | PRESENT | OMPX_HOLD
3614
+ // map-type -> TO | FROM | TOFROM | ALLOC | RELEASE | DELETE
3615
+ struct OmpMapClause {
3616
+ ENUM_CLASS (TypeModifier, Always, Close, Present, Ompx_Hold);
3617
+ ENUM_CLASS (Type, To, From, Tofrom, Alloc, Release, Delete)
3618
+ TUPLE_CLASS_BOILERPLATE (OmpMapClause);
3594
3619
3595
- // 2.15.3.6 reduction-clause -> REDUCTION (reduction-identifier:
3596
- // variable-name-list)
3597
- struct OmpReductionClause {
3598
- TUPLE_CLASS_BOILERPLATE (OmpReductionClause);
3599
- ENUM_CLASS (ReductionModifier, Inscan, Task, Default)
3600
- std::tuple<std::optional<ReductionModifier>, OmpReductionOperator,
3601
- OmpObjectList>
3620
+ // All modifiers are parsed into optional lists, even if they are unique.
3621
+ // The checks for satisfying those constraints are deferred to semantics.
3622
+ // In OpenMP 5.2 the non-comma syntax has been deprecated: keep the
3623
+ // information about separator presence to emit a diagnostic if needed.
3624
+ std::tuple<std::optional<std::list<TypeModifier>>,
3625
+ std::optional<std::list<OmpIteratorModifier>>, // unique
3626
+ std::optional<std::list<Type>>, // unique
3627
+ OmpObjectList,
3628
+ bool > // were the modifiers comma-separated?
3602
3629
t;
3603
3630
};
3604
3631
3605
- // OMP 5.0 2.19.5.6 in_reduction-clause -> IN_REDUCTION (reduction-identifier:
3606
- // variable-name-list)
3607
- struct OmpInReductionClause {
3608
- TUPLE_CLASS_BOILERPLATE (OmpInReductionClause);
3609
- std::tuple<OmpReductionOperator, OmpObjectList> t;
3610
- };
3611
-
3612
- // OMP 5.0 2.11.4 allocate-clause -> ALLOCATE ([allocator:] variable-name-list)
3613
- // OMP 5.2 2.13.4 allocate-clause -> ALLOCATE ([allocate-modifier [,
3614
- // allocate-modifier] :]
3615
- // variable-name-list)
3616
- // allocate-modifier -> allocator | align
3617
- struct OmpAllocateClause {
3618
- struct AllocateModifier {
3619
- WRAPPER_CLASS (Allocator, ScalarIntExpr);
3620
- WRAPPER_CLASS (Align, ScalarIntExpr);
3621
- struct ComplexModifier {
3622
- TUPLE_CLASS_BOILERPLATE (ComplexModifier);
3623
- std::tuple<Allocator, Align> t;
3624
- };
3625
- UNION_CLASS_BOILERPLATE (AllocateModifier);
3626
- std::variant<Allocator, ComplexModifier, Align> u;
3627
- };
3628
- TUPLE_CLASS_BOILERPLATE (OmpAllocateClause);
3629
- std::tuple<std::optional<AllocateModifier>, OmpObjectList> t;
3632
+ // 2.9.5 order-clause -> ORDER ([order-modifier :]concurrent)
3633
+ struct OmpOrderModifier {
3634
+ UNION_CLASS_BOILERPLATE (OmpOrderModifier);
3635
+ ENUM_CLASS (Kind, Reproducible, Unconstrained)
3636
+ std::variant<Kind> u;
3630
3637
};
3631
3638
3632
- // 2.13.9 depend-vec-length -> +/- non-negative-constant
3633
- struct OmpDependSinkVecLength {
3634
- TUPLE_CLASS_BOILERPLATE (OmpDependSinkVecLength);
3635
- std::tuple<DefinedOperator, ScalarIntConstantExpr > t;
3639
+ struct OmpOrderClause {
3640
+ TUPLE_CLASS_BOILERPLATE (OmpOrderClause);
3641
+ ENUM_CLASS (Type, Concurrent)
3642
+ std::tuple<std::optional<OmpOrderModifier>, Type > t;
3636
3643
};
3637
3644
3638
- // 2.13.9 depend-vec -> iterator [+/- depend-vec-length],...,iterator[...]
3639
- struct OmpDependSinkVec {
3640
- TUPLE_CLASS_BOILERPLATE (OmpDependSinkVec);
3641
- std::tuple<Name, std::optional<OmpDependSinkVecLength>> t ;
3645
+ // 2.5 proc-bind-clause -> PROC_BIND (MASTER | CLOSE | SPREAD)
3646
+ struct OmpProcBindClause {
3647
+ ENUM_CLASS (Type, Close, Master, Spread, Primary)
3648
+ WRAPPER_CLASS_BOILERPLATE (OmpProcBindClause, Type) ;
3642
3649
};
3643
3650
3644
- // 2.13.9 depend-type -> IN | OUT | INOUT | SOURCE | SINK
3645
- struct OmpDependenceType {
3646
- ENUM_CLASS (Type, In, Out, Inout, Source, Sink)
3647
- WRAPPER_CLASS_BOILERPLATE (OmpDependenceType, Type);
3651
+ // 2.15.3.6 reduction-clause -> REDUCTION (reduction-identifier:
3652
+ // variable-name-list)
3653
+ struct OmpReductionClause {
3654
+ TUPLE_CLASS_BOILERPLATE (OmpReductionClause);
3655
+ ENUM_CLASS (ReductionModifier, Inscan, Task, Default)
3656
+ std::tuple<std::optional<ReductionModifier>, OmpReductionOperator,
3657
+ OmpObjectList>
3658
+ t;
3648
3659
};
3649
3660
3650
- // 2.13.9 depend-clause -> DEPEND (((IN | OUT | INOUT) : variable-name-list) |
3651
- // SOURCE | SINK : depend-vec)
3652
- struct OmpDependClause {
3653
- UNION_CLASS_BOILERPLATE (OmpDependClause);
3654
- EMPTY_CLASS (Source);
3655
- WRAPPER_CLASS (Sink, std::list<OmpDependSinkVec>);
3656
- struct InOut {
3657
- TUPLE_CLASS_BOILERPLATE (InOut);
3658
- std::tuple<OmpDependenceType, std::list<Designator>> t;
3659
- };
3660
- std::variant<Source, Sink, InOut> u;
3661
+ // 2.7.1 sched-modifier -> MONOTONIC | NONMONOTONIC | SIMD
3662
+ struct OmpScheduleModifierType {
3663
+ ENUM_CLASS (ModType, Monotonic, Nonmonotonic, Simd)
3664
+ WRAPPER_CLASS_BOILERPLATE (OmpScheduleModifierType, ModType);
3661
3665
};
3662
3666
3663
- // OMP 5.0 2.4 atomic-default-mem-order-clause ->
3664
- // ATOMIC_DEFAULT_MEM_ORDER (SEQ_CST | ACQ_REL |
3665
- // RELAXED)
3666
- struct OmpAtomicDefaultMemOrderClause {
3667
- WRAPPER_CLASS_BOILERPLATE (
3668
- OmpAtomicDefaultMemOrderClause, common::OmpAtomicDefaultMemOrderType);
3667
+ struct OmpScheduleModifier {
3668
+ TUPLE_CLASS_BOILERPLATE (OmpScheduleModifier);
3669
+ WRAPPER_CLASS (Modifier1, OmpScheduleModifierType);
3670
+ WRAPPER_CLASS (Modifier2, OmpScheduleModifierType);
3671
+ std::tuple<Modifier1, std::optional<Modifier2>> t;
3669
3672
};
3670
3673
3671
- // OMP 5.0 2.19.4.5 lastprivate-clause ->
3672
- // LASTPRIVATE ([lastprivate-modifier :] list)
3673
- // lastprivate-modifier -> CONDITIONAL
3674
- struct OmpLastprivateClause {
3675
- TUPLE_CLASS_BOILERPLATE (OmpLastprivateClause);
3676
- ENUM_CLASS (LastprivateModifier, Conditional);
3677
- std::tuple<std::optional<LastprivateModifier>, OmpObjectList> t;
3674
+ // 2.7.1 schedule-clause -> SCHEDULE ([sched-modifier1] [, sched-modifier2]:]
3675
+ // kind[, chunk_size])
3676
+ struct OmpScheduleClause {
3677
+ TUPLE_CLASS_BOILERPLATE (OmpScheduleClause);
3678
+ ENUM_CLASS (ScheduleType, Static, Dynamic, Guided, Auto, Runtime)
3679
+ std::tuple<std::optional<OmpScheduleModifier>, ScheduleType,
3680
+ std::optional<ScalarIntExpr>>
3681
+ t;
3678
3682
};
3679
3683
3680
3684
// OpenMP Clauses
@@ -3699,6 +3703,8 @@ struct OmpClauseList {
3699
3703
CharBlock source;
3700
3704
};
3701
3705
3706
+ // --- Directives and constructs
3707
+
3702
3708
// 2.7.2 SECTIONS
3703
3709
// 2.11.2 PARALLEL SECTIONS
3704
3710
struct OmpSectionsDirective {
0 commit comments