llvm/clang/include/clang/AST/OpenACCClause.h

//===- OpenACCClause.h - Classes for OpenACC clauses ------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// \file
// This file defines OpenACC AST classes for clauses.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_CLANG_AST_OPENACCCLAUSE_H
#define LLVM_CLANG_AST_OPENACCCLAUSE_H
#include "clang/AST/ASTContext.h"
#include "clang/AST/StmtIterator.h"
#include "clang/Basic/OpenACCKinds.h"

#include <utility>

namespace clang {
/// This is the base type for all OpenACC Clauses.
class OpenACCClause {};

// Represents the 'auto' clause.
class OpenACCAutoClause : public OpenACCClause {};

// Represents the 'independent' clause.
class OpenACCIndependentClause : public OpenACCClause {};
// Represents the 'seq' clause.
class OpenACCSeqClause : public OpenACCClause {};

// Not yet implemented, but the type name is necessary for 'seq' diagnostics, so
// this provides a basic, do-nothing implementation. We still need to add this
// type to the visitors/etc, as well as get it to take its proper arguments.
class OpenACCGangClause : public OpenACCClause {};

// Not yet implemented, but the type name is necessary for 'seq' diagnostics, so
// this provides a basic, do-nothing implementation. We still need to add this
// type to the visitors/etc, as well as get it to take its proper arguments.
class OpenACCVectorClause : public OpenACCClause {};

// Not yet implemented, but the type name is necessary for 'seq' diagnostics, so
// this provides a basic, do-nothing implementation. We still need to add this
// type to the visitors/etc, as well as get it to take its proper arguments.
class OpenACCWorkerClause : public OpenACCClause {};

/// Represents a clause that has a list of parameters.
class OpenACCClauseWithParams : public OpenACCClause {};

DeviceTypeArgument;
/// A 'device_type' or 'dtype' clause, takes a list of either an 'asterisk' or
/// an identifier. The 'asterisk' means 'the rest'.
class OpenACCDeviceTypeClause final
    : public OpenACCClauseWithParams,
      public llvm::TrailingObjects<OpenACCDeviceTypeClause,
                                   DeviceTypeArgument> {};

/// A 'default' clause, has the optional 'none' or 'present' argument.
class OpenACCDefaultClause : public OpenACCClauseWithParams {};

/// Represents one of the handful of classes that has an optional/required
/// 'condition' expression as an argument.
class OpenACCClauseWithCondition : public OpenACCClauseWithParams {};

/// An 'if' clause, which has a required condition expression.
class OpenACCIfClause : public OpenACCClauseWithCondition {};

/// A 'self' clause, which has an optional condition expression.
class OpenACCSelfClause : public OpenACCClauseWithCondition {};

/// Represents a clause that has one or more expressions associated with it.
class OpenACCClauseWithExprs : public OpenACCClauseWithParams {};

// Represents the 'devnum' and expressions lists for the 'wait' clause.
class OpenACCWaitClause final
    : public OpenACCClauseWithExprs,
      public llvm::TrailingObjects<OpenACCWaitClause, Expr *> {};

class OpenACCNumGangsClause final
    : public OpenACCClauseWithExprs,
      public llvm::TrailingObjects<OpenACCNumGangsClause, Expr *> {};

/// Represents one of a handful of clauses that have a single integer
/// expression.
class OpenACCClauseWithSingleIntExpr : public OpenACCClauseWithExprs {};

class OpenACCNumWorkersClause : public OpenACCClauseWithSingleIntExpr {};

class OpenACCVectorLengthClause : public OpenACCClauseWithSingleIntExpr {};

class OpenACCAsyncClause : public OpenACCClauseWithSingleIntExpr {};

/// Represents a 'collapse' clause on a 'loop' construct. This clause takes an
/// integer constant expression 'N' that represents how deep to collapse the
/// construct. It also takes an optional 'force' tag that permits intervening
/// code in the loops.
class OpenACCCollapseClause : public OpenACCClauseWithSingleIntExpr {};

/// Represents a clause with one or more 'var' objects, represented as an expr,
/// as its arguments. Var-list is expected to be stored in trailing storage.
/// For now, we're just storing the original expression in its entirety, unlike
/// OMP which has to do a bunch of work to create a private.
class OpenACCClauseWithVarList : public OpenACCClauseWithExprs {};

class OpenACCPrivateClause final
    : public OpenACCClauseWithVarList,
      public llvm::TrailingObjects<OpenACCPrivateClause, Expr *> {};

class OpenACCFirstPrivateClause final
    : public OpenACCClauseWithVarList,
      public llvm::TrailingObjects<OpenACCFirstPrivateClause, Expr *> {};

class OpenACCDevicePtrClause final
    : public OpenACCClauseWithVarList,
      public llvm::TrailingObjects<OpenACCDevicePtrClause, Expr *> {};

class OpenACCAttachClause final
    : public OpenACCClauseWithVarList,
      public llvm::TrailingObjects<OpenACCAttachClause, Expr *> {};

class OpenACCNoCreateClause final
    : public OpenACCClauseWithVarList,
      public llvm::TrailingObjects<OpenACCNoCreateClause, Expr *> {};

class OpenACCPresentClause final
    : public OpenACCClauseWithVarList,
      public llvm::TrailingObjects<OpenACCPresentClause, Expr *> {};

class OpenACCCopyClause final
    : public OpenACCClauseWithVarList,
      public llvm::TrailingObjects<OpenACCCopyClause, Expr *> {};

class OpenACCCopyInClause final
    : public OpenACCClauseWithVarList,
      public llvm::TrailingObjects<OpenACCCopyInClause, Expr *> {};

class OpenACCCopyOutClause final
    : public OpenACCClauseWithVarList,
      public llvm::TrailingObjects<OpenACCCopyOutClause, Expr *> {};

class OpenACCCreateClause final
    : public OpenACCClauseWithVarList,
      public llvm::TrailingObjects<OpenACCCreateClause, Expr *> {};

class OpenACCReductionClause final
    : public OpenACCClauseWithVarList,
      public llvm::TrailingObjects<OpenACCReductionClause, Expr *> {};

template <class Impl> class OpenACCClauseVisitor {};

class OpenACCClausePrinter final
    : public OpenACCClauseVisitor<OpenACCClausePrinter> {};

} // namespace clang

#endif // LLVM_CLANG_AST_OPENACCCLAUSE_H