@@ -3701,14 +3701,18 @@ class OMPSharedClause final
37013701class OMPReductionClause final
37023702 : public OMPVarListClause<OMPReductionClause>,
37033703 public OMPClauseWithPostUpdate,
3704- private llvm::TrailingObjects<OMPReductionClause, Expr *> {
3704+ private llvm::TrailingObjects<OMPReductionClause, Expr *, bool > {
37053705 friend class OMPClauseReader ;
37063706 friend OMPVarListClause;
37073707 friend TrailingObjects;
37083708
37093709 // / Reduction modifier.
37103710 OpenMPReductionClauseModifier Modifier = OMPC_REDUCTION_unknown;
37113711
3712+ // / Original Sharing modifier.
3713+ OpenMPOriginalSharingModifier OriginalSharingModifier =
3714+ OMPC_ORIGINAL_SHARING_default;
3715+
37123716 // / Reduction modifier location.
37133717 SourceLocation ModifierLoc;
37143718
@@ -3734,12 +3738,14 @@ class OMPReductionClause final
37343738 OMPReductionClause (SourceLocation StartLoc, SourceLocation LParenLoc,
37353739 SourceLocation ModifierLoc, SourceLocation ColonLoc,
37363740 SourceLocation EndLoc,
3737- OpenMPReductionClauseModifier Modifier, unsigned N,
3738- NestedNameSpecifierLoc QualifierLoc,
3741+ OpenMPReductionClauseModifier Modifier,
3742+ OpenMPOriginalSharingModifier OriginalSharingModifier,
3743+ unsigned N, NestedNameSpecifierLoc QualifierLoc,
37393744 const DeclarationNameInfo &NameInfo)
37403745 : OMPVarListClause<OMPReductionClause>(llvm::omp::OMPC_reduction,
37413746 StartLoc, LParenLoc, EndLoc, N),
37423747 OMPClauseWithPostUpdate (this ), Modifier(Modifier),
3748+ OriginalSharingModifier (OriginalSharingModifier),
37433749 ModifierLoc (ModifierLoc), ColonLoc(ColonLoc),
37443750 QualifierLoc (QualifierLoc), NameInfo(NameInfo) {}
37453751
@@ -3755,6 +3761,11 @@ class OMPReductionClause final
37553761 // / Sets reduction modifier.
37563762 void setModifier (OpenMPReductionClauseModifier M) { Modifier = M; }
37573763
3764+ // / Sets Original Sharing modifier.
3765+ void setOriginalSharingModifier (OpenMPOriginalSharingModifier M) {
3766+ OriginalSharingModifier = M;
3767+ }
3768+
37583769 // / Sets location of the modifier.
37593770 void setModifierLoc (SourceLocation Loc) { ModifierLoc = Loc; }
37603771
@@ -3800,6 +3811,31 @@ class OMPReductionClause final
38003811 // / reduction copies.
38013812 void setRHSExprs (ArrayRef<Expr *> RHSExprs);
38023813
3814+ // / Set the list private reduction flags
3815+ void setPrivateVariableReductionFlags (ArrayRef<bool > Flags) {
3816+ assert (Flags.size () == varlist_size () &&
3817+ " Number of private flags does not match vars" );
3818+ llvm::copy (Flags, getTrailingObjects<bool >());
3819+ }
3820+
3821+ // / Get the list of help private variable reduction flags
3822+ MutableArrayRef<bool > getPrivateVariableReductionFlags () {
3823+ return MutableArrayRef (getTrailingObjects<bool >(), varlist_size ());
3824+ }
3825+ ArrayRef<bool > getPrivateVariableReductionFlags () const {
3826+ return ArrayRef (getTrailingObjects<bool >(), varlist_size ());
3827+ }
3828+
3829+ // / Returns the number of Expr* objects in trailing storage
3830+ size_t numTrailingObjects (OverloadToken<Expr *>) const {
3831+ return varlist_size () * (Modifier == OMPC_REDUCTION_inscan ? 8 : 5 );
3832+ }
3833+
3834+ // / Returns the number of bool flags in trailing storage
3835+ size_t numTrailingObjects (OverloadToken<bool >) const {
3836+ return varlist_size ();
3837+ }
3838+
38033839 // / Get the list of helper destination expressions.
38043840 MutableArrayRef<Expr *> getRHSExprs () {
38053841 return MutableArrayRef<Expr *>(getLHSExprs ().end (), varlist_size ());
@@ -3897,6 +3933,7 @@ class OMPReductionClause final
38973933 // / region with this clause.
38983934 // / \param PostUpdate Expression that must be executed after exit from the
38993935 // / OpenMP region with this clause.
3936+ // / \param IsPrivateVarReduction array for private variable reduction flags
39003937 static OMPReductionClause *
39013938 Create (const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
39023939 SourceLocation ModifierLoc, SourceLocation ColonLoc,
@@ -3906,7 +3943,8 @@ class OMPReductionClause final
39063943 ArrayRef<Expr *> LHSExprs, ArrayRef<Expr *> RHSExprs,
39073944 ArrayRef<Expr *> ReductionOps, ArrayRef<Expr *> CopyOps,
39083945 ArrayRef<Expr *> CopyArrayTemps, ArrayRef<Expr *> CopyArrayElems,
3909- Stmt *PreInit, Expr *PostUpdate);
3946+ Stmt *PreInit, Expr *PostUpdate, ArrayRef<bool > IsPrivateVarReduction,
3947+ OpenMPOriginalSharingModifier OriginalSharingModifier);
39103948
39113949 // / Creates an empty clause with the place for \a N variables.
39123950 // /
@@ -3920,6 +3958,11 @@ class OMPReductionClause final
39203958 // / Returns modifier.
39213959 OpenMPReductionClauseModifier getModifier () const { return Modifier; }
39223960
3961+ // / Returns Original Sharing Modifier.
3962+ OpenMPOriginalSharingModifier getOriginalSharingModifier () const {
3963+ return OriginalSharingModifier;
3964+ }
3965+
39233966 // / Returns modifier location.
39243967 SourceLocation getModifierLoc () const { return ModifierLoc; }
39253968
@@ -3937,6 +3980,11 @@ class OMPReductionClause final
39373980 using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
39383981 using helper_expr_const_range =
39393982 llvm::iterator_range<helper_expr_const_iterator>;
3983+ using helper_flag_iterator = MutableArrayRef<bool >::iterator;
3984+ using helper_flag_const_iterator = ArrayRef<bool >::iterator;
3985+ using helper_flag_range = llvm::iterator_range<helper_flag_iterator>;
3986+ using helper_flag_const_range =
3987+ llvm::iterator_range<helper_flag_const_iterator>;
39403988
39413989 helper_expr_const_range privates () const {
39423990 return helper_expr_const_range (getPrivates ().begin (), getPrivates ().end ());
@@ -3962,6 +4010,16 @@ class OMPReductionClause final
39624010 return helper_expr_range (getRHSExprs ().begin (), getRHSExprs ().end ());
39634011 }
39644012
4013+ helper_flag_const_range private_var_reduction_flags () const {
4014+ return helper_flag_const_range (getPrivateVariableReductionFlags ().begin (),
4015+ getPrivateVariableReductionFlags ().end ());
4016+ }
4017+
4018+ helper_flag_range private_var_reduction_flags () {
4019+ return helper_flag_range (getPrivateVariableReductionFlags ().begin (),
4020+ getPrivateVariableReductionFlags ().end ());
4021+ }
4022+
39654023 helper_expr_const_range reduction_ops () const {
39664024 return helper_expr_const_range (getReductionOps ().begin (),
39674025 getReductionOps ().end ());
0 commit comments