@@ -6131,60 +6131,77 @@ class OMPMapClause final : public OMPMappableExprListClause<OMPMapClause>,
6131
6131
// / \endcode
6132
6132
// / In this example directive '#pragma omp teams' has clause 'num_teams'
6133
6133
// / with single expression 'n'.
6134
- class OMPNumTeamsClause : public OMPClause , public OMPClauseWithPreInit {
6135
- friend class OMPClauseReader ;
6134
+ // /
6135
+ // / When 'ompx_bare' clause exists on a 'target' directive, 'num_teams' clause
6136
+ // / can accept up to three expressions.
6137
+ // /
6138
+ // / \code
6139
+ // / #pragma omp target teams ompx_bare num_teams(x, y, z)
6140
+ // / \endcode
6141
+ class OMPNumTeamsClause final
6142
+ : public OMPVarListClause<OMPNumTeamsClause>,
6143
+ public OMPClauseWithPreInit,
6144
+ private llvm::TrailingObjects<OMPNumTeamsClause, Expr *> {
6145
+ friend OMPVarListClause;
6146
+ friend TrailingObjects;
6136
6147
6137
6148
// / Location of '('.
6138
6149
SourceLocation LParenLoc;
6139
6150
6140
- // / NumTeams number.
6141
- Stmt *NumTeams = nullptr ;
6151
+ OMPNumTeamsClause (const ASTContext &C, SourceLocation StartLoc,
6152
+ SourceLocation LParenLoc, SourceLocation EndLoc, unsigned N)
6153
+ : OMPVarListClause(llvm::omp::OMPC_num_teams, StartLoc, LParenLoc, EndLoc,
6154
+ N),
6155
+ OMPClauseWithPreInit (this ) {}
6142
6156
6143
- // / Set the NumTeams number.
6144
- // /
6145
- // / \param E NumTeams number.
6146
- void setNumTeams (Expr *E) { NumTeams = E; }
6157
+ // / Build an empty clause.
6158
+ OMPNumTeamsClause (unsigned N)
6159
+ : OMPVarListClause(llvm::omp::OMPC_num_teams, SourceLocation(),
6160
+ SourceLocation(), SourceLocation(), N),
6161
+ OMPClauseWithPreInit(this ) {}
6147
6162
6148
6163
public:
6149
- // / Build 'num_teams' clause.
6164
+ // / Creates clause with a list of variables \a VL .
6150
6165
// /
6151
- // / \param E Expression associated with this clause.
6152
- // / \param HelperE Helper Expression associated with this clause.
6153
- // / \param CaptureRegion Innermost OpenMP region where expressions in this
6154
- // / clause must be captured.
6166
+ // / \param C AST context.
6155
6167
// / \param StartLoc Starting location of the clause.
6156
6168
// / \param LParenLoc Location of '('.
6157
6169
// / \param EndLoc Ending location of the clause.
6158
- OMPNumTeamsClause (Expr *E, Stmt *HelperE, OpenMPDirectiveKind CaptureRegion,
6159
- SourceLocation StartLoc, SourceLocation LParenLoc,
6160
- SourceLocation EndLoc)
6161
- : OMPClause(llvm::omp::OMPC_num_teams, StartLoc, EndLoc),
6162
- OMPClauseWithPreInit (this ), LParenLoc(LParenLoc), NumTeams(E) {
6163
- setPreInitStmt (HelperE, CaptureRegion);
6164
- }
6170
+ // / \param VL List of references to the variables.
6171
+ // / \param PreInit
6172
+ static OMPNumTeamsClause *
6173
+ Create (const ASTContext &C, OpenMPDirectiveKind CaptureRegion,
6174
+ SourceLocation StartLoc, SourceLocation LParenLoc,
6175
+ SourceLocation EndLoc, ArrayRef<Expr *> VL, Stmt *PreInit);
6165
6176
6166
- // / Build an empty clause.
6167
- OMPNumTeamsClause ()
6168
- : OMPClause(llvm::omp::OMPC_num_teams, SourceLocation(),
6169
- SourceLocation()),
6170
- OMPClauseWithPreInit( this ) {}
6177
+ // / Creates an empty clause with \a N variables .
6178
+ // /
6179
+ // / \param C AST context.
6180
+ // / \param N The number of variables.
6181
+ static OMPNumTeamsClause * CreateEmpty ( const ASTContext &C, unsigned N);
6171
6182
6172
6183
// / Sets the location of '('.
6173
6184
void setLParenLoc (SourceLocation Loc) { LParenLoc = Loc; }
6174
6185
6175
6186
// / Returns the location of '('.
6176
6187
SourceLocation getLParenLoc () const { return LParenLoc; }
6177
6188
6178
- // / Return NumTeams number .
6179
- Expr *getNumTeams () { return cast<Expr>(NumTeams ); }
6189
+ // / Return NumTeams expressions .
6190
+ ArrayRef< Expr *> getNumTeams () { return getVarRefs ( ); }
6180
6191
6181
- // / Return NumTeams number.
6182
- Expr *getNumTeams () const { return cast<Expr>(NumTeams); }
6192
+ // / Return NumTeams expressions.
6193
+ ArrayRef<Expr *> getNumTeams () const {
6194
+ return const_cast <OMPNumTeamsClause *>(this )->getNumTeams ();
6195
+ }
6183
6196
6184
- child_range children () { return child_range (&NumTeams, &NumTeams + 1 ); }
6197
+ child_range children () {
6198
+ return child_range (reinterpret_cast <Stmt **>(varlist_begin ()),
6199
+ reinterpret_cast <Stmt **>(varlist_end ()));
6200
+ }
6185
6201
6186
6202
const_child_range children () const {
6187
- return const_child_range (&NumTeams, &NumTeams + 1 );
6203
+ auto Children = const_cast <OMPNumTeamsClause *>(this )->children ();
6204
+ return const_child_range (Children.begin (), Children.end ());
6188
6205
}
6189
6206
6190
6207
child_range used_children () {
0 commit comments