Commit 9f9e7728 authored by Joel E. Denny's avatar Joel E. Denny
Browse files

[Clacc][OpenACC] Implement acc wait

It's not useful yet, but it will be when future patches implement
async features.
parent eb43881f
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -2065,6 +2065,14 @@ to OpenMP is as follows:
In the Clang AST, a single `OMPDeclareTargetDeclAttr` represents an
`omp declare target` and `omp end declare target` pair.

Wait Directive
--------------

Clacc's current mapping of an `acc wait` directive and its clauses to OpenMP is
as follows:

* `acc wait` -> `omp taskwait`

Potentially Unmappable Features
-------------------------------

+8 −0
Original line number Diff line number Diff line
@@ -680,6 +680,14 @@ Run-Time Environment Variables
        * A `new` expression's calls to a `new` operator, constructor, and
          `delete` operator.

`wait` Directive
------------------

* Lexical context
    * Appearing outside any OpenACC construct is supported.
    * Appearing within a `data` construct is supported.
* Only usage without clauses is supported so far.

Data Expressions in Clauses
---------------------------

+9 −5
Original line number Diff line number Diff line
@@ -2149,25 +2149,29 @@ enum CXCursorKind {
   */
  CXCursor_ACCExitDataDirective = 308,

  /** OpenACC wait directive.
   */
  CXCursor_ACCWaitDirective = 309,

  /** OpenACC data directive.
   */
  CXCursor_ACCDataDirective = 309,
  CXCursor_ACCDataDirective = 310,

  /** OpenACC parallel directive.
   */
  CXCursor_ACCParallelDirective = 310,
  CXCursor_ACCParallelDirective = 311,

  /** OpenACC loop directive.
   */
  CXCursor_ACCLoopDirective = 311,
  CXCursor_ACCLoopDirective = 312,

  /** OpenACC parallel loop directive.
   */
  CXCursor_ACCParallelLoopDirective = 312,
  CXCursor_ACCParallelLoopDirective = 313,

  /** OpenACC atomic directive.
   */
  CXCursor_ACCAtomicDirective = 313,
  CXCursor_ACCAtomicDirective = 314,

  CXCursor_LastStmt = CXCursor_ACCAtomicDirective,

+2 −0
Original line number Diff line number Diff line
@@ -3888,6 +3888,8 @@ DEF_TRAVERSE_STMT(ACCEnterDataDirective,
DEF_TRAVERSE_STMT(ACCExitDataDirective,
                  { TRY_TO(TraverseACCDirectiveStmt(S)); })

DEF_TRAVERSE_STMT(ACCWaitDirective, { TRY_TO(TraverseACCDirectiveStmt(S)); })

DEF_TRAVERSE_STMT(ACCDataDirective, { TRY_TO(TraverseACCDirectiveStmt(S)); })

DEF_TRAVERSE_STMT(ACCParallelDirective,
+41 −0
Original line number Diff line number Diff line
@@ -496,6 +496,47 @@ public:
  }
};

/// This represents '#pragma acc wait' directive.
class ACCWaitDirective : public ACCDirectiveStmt {
  /// Build directive with the given start and end location.
  ///
  /// \param StartLoc Starting location of the directive (directive keyword).
  /// \param EndLoc Ending Location of the directive.
  /// \param NumClauses Number of clauses.
  ACCWaitDirective(SourceLocation StartLoc, SourceLocation EndLoc,
                   unsigned NumClauses)
      : ACCDirectiveStmt(this, ACCWaitDirectiveClass, ACCD_wait, StartLoc,
                         EndLoc, NumClauses, 0, 0) {}

  /// Build an empty directive.
  explicit ACCWaitDirective(unsigned NumClauses)
      : ACCDirectiveStmt(this, ACCWaitDirectiveClass, ACCD_wait,
                         SourceLocation(), SourceLocation(), NumClauses, 0, 0) {
  }

public:
  /// Creates directive.
  ///
  /// \param C AST context.
  /// \param StartLoc Starting location of the directive kind.
  /// \param EndLoc Ending Location of the directive.
  /// \param Clauses List of clauses.
  static ACCWaitDirective *Create(const ASTContext &C, SourceLocation StartLoc,
                                  SourceLocation EndLoc,
                                  ArrayRef<ACCClause *> Clauses);

  /// Creates an empty directive.
  ///
  /// \param C AST context.
  /// \param NumClauses Number of clauses.
  static ACCWaitDirective *CreateEmpty(const ASTContext &C, unsigned NumClauses,
                                       EmptyShell);

  static bool classof(const Stmt *T) {
    return T->getStmtClass() == ACCWaitDirectiveClass;
  }
};

/// This represents '#pragma acc data' directive.
///
class ACCDataDirective : public ACCDirectiveStmt {
Loading