Commit 93dc40dd authored by Alexey Bataev's avatar Alexey Bataev
Browse files

[OPENMP50]Basic support for conditional lastprivate.

Added parsing/sema checks for conditional lastprivates.
parent 0d473991
Loading
Loading
Loading
Loading
+31 −3
Original line number Diff line number Diff line
@@ -2152,6 +2152,13 @@ class OMPLastprivateClause final
  friend OMPVarListClause;
  friend TrailingObjects;

  /// Optional lastprivate kind, e.g. 'conditional', if specified by user.
  OpenMPLastprivateModifier LPKind;
  /// Optional location of the lasptrivate kind, if specified by user.
  SourceLocation LPKindLoc;
  /// Optional colon location, if specified by user.
  SourceLocation ColonLoc;

  /// Build clause with number of variables \a N.
  ///
  /// \param StartLoc Starting location of the clause.
@@ -2159,10 +2166,13 @@ class OMPLastprivateClause final
  /// \param EndLoc Ending location of the clause.
  /// \param N Number of the variables in the clause.
  OMPLastprivateClause(SourceLocation StartLoc, SourceLocation LParenLoc,
                       SourceLocation EndLoc, unsigned N)
                       SourceLocation EndLoc, OpenMPLastprivateModifier LPKind,
                       SourceLocation LPKindLoc, SourceLocation ColonLoc,
                       unsigned N)
      : OMPVarListClause<OMPLastprivateClause>(OMPC_lastprivate, StartLoc,
                                               LParenLoc, EndLoc, N),
        OMPClauseWithPostUpdate(this) {}
        OMPClauseWithPostUpdate(this), LPKind(LPKind), LPKindLoc(LPKindLoc),
        ColonLoc(ColonLoc) {}

  /// Build an empty clause.
  ///
@@ -2223,6 +2233,13 @@ class OMPLastprivateClause final
    return llvm::makeArrayRef(getDestinationExprs().end(), varlist_size());
  }

  /// Sets lastprivate kind.
  void setKind(OpenMPLastprivateModifier Kind) { LPKind = Kind; }
  /// Sets location of the lastprivate kind.
  void setKindLoc(SourceLocation Loc) { LPKindLoc = Loc; }
  /// Sets colon symbol location.
  void setColonLoc(SourceLocation Loc) { ColonLoc = Loc; }

public:
  /// Creates clause with a list of variables \a VL.
  ///
@@ -2244,6 +2261,9 @@ public:
  /// \endcode
  /// Required for proper codegen of final assignment performed by the
  /// lastprivate clause.
  /// \param LPKind Lastprivate kind, e.g. 'conditional'.
  /// \param LPKindLoc Location of the lastprivate kind.
  /// \param ColonLoc Location of the ':' symbol if lastprivate kind is used.
  /// \param PreInit Statement that must be executed before entering the OpenMP
  /// region with this clause.
  /// \param PostUpdate Expression that must be executed after exit from the
@@ -2252,7 +2272,8 @@ public:
  Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc,
         SourceLocation EndLoc, ArrayRef<Expr *> VL, ArrayRef<Expr *> SrcExprs,
         ArrayRef<Expr *> DstExprs, ArrayRef<Expr *> AssignmentOps,
         Stmt *PreInit, Expr *PostUpdate);
         OpenMPLastprivateModifier LPKind, SourceLocation LPKindLoc,
         SourceLocation ColonLoc, Stmt *PreInit, Expr *PostUpdate);

  /// Creates an empty clause with the place for \a N variables.
  ///
@@ -2260,6 +2281,13 @@ public:
  /// \param N The number of variables.
  static OMPLastprivateClause *CreateEmpty(const ASTContext &C, unsigned N);

  /// Lastprivate kind.
  OpenMPLastprivateModifier getKind() const { return LPKind; }
  /// Returns the location of the lastprivate kind.
  SourceLocation getKindLoc() const { return LPKindLoc; }
  /// Returns the location of the ':' symbol, if any.
  SourceLocation getColonLoc() const { return ColonLoc; }

  using helper_expr_iterator = MutableArrayRef<Expr *>::iterator;
  using helper_expr_const_iterator = ArrayRef<const Expr *>::iterator;
  using helper_expr_range = llvm::iterator_range<helper_expr_iterator>;
+3 −0
Original line number Diff line number Diff line
@@ -9768,6 +9768,9 @@ def warn_omp_declare_variant_marked_as_declare_variant : Warning<
def note_omp_marked_declare_variant_here : Note<"marked as 'declare variant' here">;
def err_omp_one_defaultmap_each_category: Error<
  "at most one defaultmap clause for each variable-category can appear on the directive">;
def err_omp_lastprivate_conditional_non_scalar : Error<
  "expected list item of scalar type in 'lastprivate' clause with 'conditional' modifier"
  >;
} // end of OpenMP category
let CategoryName = "Related Result Type Issue" in {
+7 −0
Original line number Diff line number Diff line
@@ -212,6 +212,9 @@
#ifndef OPENMP_CONTEXT_SELECTOR
#define OPENMP_CONTEXT_SELECTOR(Name)
#endif
#ifndef OPENMP_LASTPRIVATE_KIND
#define OPENMP_LASTPRIVATE_KIND(Name)
#endif

// OpenMP context selector sets.
OPENMP_CONTEXT_SELECTOR_SET(implementation)
@@ -1057,6 +1060,10 @@ OPENMP_DEVICE_TYPE_KIND(any)
// Clauses allowed for OpenMP directive 'declare variant'.
OPENMP_DECLARE_VARIANT_CLAUSE(match)

// Type of the 'lastprivate' clause.
OPENMP_LASTPRIVATE_KIND(conditional)

#undef OPENMP_LASTPRIVATE_KIND
#undef OPENMP_CONTEXT_SELECTOR
#undef OPENMP_CONTEXT_SELECTOR_SET
#undef OPENMP_DECLARE_VARIANT_CLAUSE
+7 −0
Original line number Diff line number Diff line
@@ -195,6 +195,13 @@ enum OpenMPDeviceType {
  OMPC_DEVICE_TYPE_unknown
};

/// OpenMP 'lastprivate' clause modifier.
enum OpenMPLastprivateModifier {
#define OPENMP_LASTPRIVATE_KIND(Name) OMPC_LASTPRIVATE_##Name,
#include "clang/Basic/OpenMPKinds.def"
  OMPC_LASTPRIVATE_unknown,
};

/// Scheduling data for loop-based OpenMP directives.
struct OpenMPScheduleTy final {
  OpenMPScheduleClauseKind Schedule = OMPC_SCHEDULE_unknown;
+3 −4
Original line number Diff line number Diff line
@@ -2970,15 +2970,14 @@ public:
    SourceLocation RLoc;
    CXXScopeSpec ReductionOrMapperIdScopeSpec;
    DeclarationNameInfo ReductionOrMapperId;
    OpenMPDependClauseKind DepKind = OMPC_DEPEND_unknown;
    OpenMPLinearClauseKind LinKind = OMPC_LINEAR_val;
    int ExtraModifier = -1; ///< Additional modifier for linear, map, depend or
                            ///< lastprivate clause.
    SmallVector<OpenMPMapModifierKind, OMPMapClause::NumberOfModifiers>
    MapTypeModifiers;
    SmallVector<SourceLocation, OMPMapClause::NumberOfModifiers>
    MapTypeModifiersLoc;
    OpenMPMapClauseKind MapType = OMPC_MAP_unknown;
    bool IsMapTypeImplicit = false;
    SourceLocation DepLinMapLoc;
    SourceLocation DepLinMapLastLoc;
  };

  /// Parses clauses with list.
Loading