diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-09 18:49:54 +0900 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2025-01-09 18:49:54 +0900 |
commit | e2810c9a248f4c7fbfae84bb32b6f7e01027458b (patch) | |
tree | ae0b02a8491b969a1cee94ea16ffe42c559143c5 /clang/lib/AST/OpenACCClause.cpp | |
parent | fa04eb4af95c1ca7377279728cb004bcd2324d01 (diff) | |
parent | bdcf47e4bcb92889665825654bb80a8bbe30379e (diff) | |
download | llvm-users/chapuni/cov/single/switch.zip llvm-users/chapuni/cov/single/switch.tar.gz llvm-users/chapuni/cov/single/switch.tar.bz2 |
Merge branch 'users/chapuni/cov/single/base' into users/chapuni/cov/single/switchusers/chapuni/cov/single/switch
Diffstat (limited to 'clang/lib/AST/OpenACCClause.cpp')
-rw-r--r-- | clang/lib/AST/OpenACCClause.cpp | 75 |
1 files changed, 68 insertions, 7 deletions
diff --git a/clang/lib/AST/OpenACCClause.cpp b/clang/lib/AST/OpenACCClause.cpp index d69fab5..da63b47 100644 --- a/clang/lib/AST/OpenACCClause.cpp +++ b/clang/lib/AST/OpenACCClause.cpp @@ -20,7 +20,7 @@ using namespace clang; bool OpenACCClauseWithParams::classof(const OpenACCClause *C) { return OpenACCDeviceTypeClause::classof(C) || OpenACCClauseWithCondition::classof(C) || - OpenACCClauseWithExprs::classof(C); + OpenACCClauseWithExprs::classof(C) || OpenACCSelfClause::classof(C); } bool OpenACCClauseWithExprs::classof(const OpenACCClause *C) { return OpenACCWaitClause::classof(C) || OpenACCNumGangsClause::classof(C) || @@ -41,12 +41,13 @@ bool OpenACCClauseWithVarList::classof(const OpenACCClause *C) { OpenACCReductionClause::classof(C) || OpenACCCreateClause::classof(C); } bool OpenACCClauseWithCondition::classof(const OpenACCClause *C) { - return OpenACCIfClause::classof(C) || OpenACCSelfClause::classof(C); + return OpenACCIfClause::classof(C); } bool OpenACCClauseWithSingleIntExpr::classof(const OpenACCClause *C) { return OpenACCNumWorkersClause::classof(C) || OpenACCVectorLengthClause::classof(C) || OpenACCDeviceNumClause::classof(C) || + OpenACCDefaultAsyncClause::classof(C) || OpenACCVectorClause::classof(C) || OpenACCWorkerClause::classof(C) || OpenACCCollapseClause::classof(C) || OpenACCAsyncClause::classof(C); } @@ -86,19 +87,43 @@ OpenACCSelfClause *OpenACCSelfClause::Create(const ASTContext &C, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc) { - void *Mem = C.Allocate(sizeof(OpenACCIfClause), alignof(OpenACCIfClause)); + void *Mem = C.Allocate(OpenACCSelfClause::totalSizeToAlloc<Expr *>(1)); return new (Mem) OpenACCSelfClause(BeginLoc, LParenLoc, ConditionExpr, EndLoc); } +OpenACCSelfClause *OpenACCSelfClause::Create(const ASTContext &C, + SourceLocation BeginLoc, + SourceLocation LParenLoc, + ArrayRef<Expr *> VarList, + SourceLocation EndLoc) { + void *Mem = + C.Allocate(OpenACCSelfClause::totalSizeToAlloc<Expr *>(VarList.size())); + return new (Mem) OpenACCSelfClause(BeginLoc, LParenLoc, VarList, EndLoc); +} + +OpenACCSelfClause::OpenACCSelfClause(SourceLocation BeginLoc, + SourceLocation LParenLoc, + llvm::ArrayRef<Expr *> VarList, + SourceLocation EndLoc) + : OpenACCClauseWithParams(OpenACCClauseKind::Self, BeginLoc, LParenLoc, + EndLoc), + HasConditionExpr(std::nullopt), NumExprs(VarList.size()) { + std::uninitialized_copy(VarList.begin(), VarList.end(), + getTrailingObjects<Expr *>()); +} + OpenACCSelfClause::OpenACCSelfClause(SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *ConditionExpr, SourceLocation EndLoc) - : OpenACCClauseWithCondition(OpenACCClauseKind::Self, BeginLoc, LParenLoc, - ConditionExpr, EndLoc) { + : OpenACCClauseWithParams(OpenACCClauseKind::Self, BeginLoc, LParenLoc, + EndLoc), + HasConditionExpr(ConditionExpr != nullptr), NumExprs(1) { assert((!ConditionExpr || ConditionExpr->isInstantiationDependent() || ConditionExpr->getType()->isScalarType()) && "Condition expression type not scalar/dependent"); + std::uninitialized_copy(&ConditionExpr, &ConditionExpr + 1, + getTrailingObjects<Expr *>()); } OpenACCClause::child_range OpenACCClause::children() { @@ -239,6 +264,27 @@ OpenACCDeviceNumClause *OpenACCDeviceNumClause::Create(const ASTContext &C, return new (Mem) OpenACCDeviceNumClause(BeginLoc, LParenLoc, IntExpr, EndLoc); } +OpenACCDefaultAsyncClause::OpenACCDefaultAsyncClause(SourceLocation BeginLoc, + SourceLocation LParenLoc, + Expr *IntExpr, + SourceLocation EndLoc) + : OpenACCClauseWithSingleIntExpr(OpenACCClauseKind::DefaultAsync, BeginLoc, + LParenLoc, IntExpr, EndLoc) { + assert((IntExpr->isInstantiationDependent() || + IntExpr->getType()->isIntegerType()) && + "default_async expression type not scalar/dependent"); +} + +OpenACCDefaultAsyncClause * +OpenACCDefaultAsyncClause::Create(const ASTContext &C, SourceLocation BeginLoc, + SourceLocation LParenLoc, Expr *IntExpr, + SourceLocation EndLoc) { + void *Mem = C.Allocate(sizeof(OpenACCDefaultAsyncClause), + alignof(OpenACCDefaultAsyncClause)); + return new (Mem) + OpenACCDefaultAsyncClause(BeginLoc, LParenLoc, IntExpr, EndLoc); +} + OpenACCWaitClause *OpenACCWaitClause::Create( const ASTContext &C, SourceLocation BeginLoc, SourceLocation LParenLoc, Expr *DevNumExpr, SourceLocation QueuesLoc, ArrayRef<Expr *> QueueIdExprs, @@ -533,9 +579,17 @@ void OpenACCClausePrinter::VisitIfClause(const OpenACCIfClause &C) { void OpenACCClausePrinter::VisitSelfClause(const OpenACCSelfClause &C) { OS << "self"; - if (const Expr *CondExpr = C.getConditionExpr()) { + + if (C.isConditionExprClause()) { + if (const Expr *CondExpr = C.getConditionExpr()) { + OS << "("; + printExpr(CondExpr); + OS << ")"; + } + } else { OS << "("; - printExpr(CondExpr); + llvm::interleaveComma(C.getVarList(), OS, + [&](const Expr *E) { printExpr(E); }); OS << ")"; } } @@ -575,6 +629,13 @@ void OpenACCClausePrinter::VisitDeviceNumClause( OS << ")"; } +void OpenACCClausePrinter::VisitDefaultAsyncClause( + const OpenACCDefaultAsyncClause &C) { + OS << "default_async("; + printExpr(C.getIntExpr()); + OS << ")"; +} + void OpenACCClausePrinter::VisitAsyncClause(const OpenACCAsyncClause &C) { OS << "async"; if (C.hasIntExpr()) { |