[OpenACC] enable 'present' clause for 'data' construct
No additional sema is required once again, so this patch adds testing and enables the clause.
This commit is contained in:
@@ -926,11 +926,13 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitNoCreateClause(
|
||||
|
||||
OpenACCClause *SemaOpenACCClauseVisitor::VisitPresentClause(
|
||||
SemaOpenACC::OpenACCParsedClause &Clause) {
|
||||
// Restrictions only properly implemented on 'compute'/'combined constructs,
|
||||
// and 'compute'/'combined' constructs are the only construct that can do
|
||||
// anything with this yet, so skip/treat as unimplemented in this case.
|
||||
// Restrictions only properly implemented on 'compute'/'combined'/'data'
|
||||
// constructs, and 'compute'/'combined'/'data' constructs are the only
|
||||
// construct that can do anything with this yet, so skip/treat as
|
||||
// unimplemented in this case.
|
||||
if (!isOpenACCComputeDirectiveKind(Clause.getDirectiveKind()) &&
|
||||
!isOpenACCCombinedDirectiveKind(Clause.getDirectiveKind()))
|
||||
!isOpenACCCombinedDirectiveKind(Clause.getDirectiveKind()) &&
|
||||
!isOpenACCDataDirectiveKind(Clause.getDirectiveKind()))
|
||||
return isNotImplemented();
|
||||
// ActOnVar ensured that everything is a valid variable reference, so there
|
||||
// really isn't anything to do here. GCC does some duplicate-finding, though
|
||||
|
||||
@@ -82,10 +82,12 @@ void foo() {
|
||||
#pragma acc data default(none) no_create(i, array[1], array, array[1:2])
|
||||
;
|
||||
|
||||
// CHECK: #pragma acc data default(none) no_create(i, array[1], array, array[1:2])
|
||||
// CHECK-NOT: present(i, array[1], array, array[1:2])
|
||||
// CHECK: #pragma acc data default(none) no_create(i, array[1], array, array[1:2]) present(i, array[1], array, array[1:2])
|
||||
#pragma acc data default(none) no_create(i, array[1], array, array[1:2]) present(i, array[1], array, array[1:2])
|
||||
;
|
||||
// CHECK: #pragma acc data present(i, array[1], array, array[1:2])
|
||||
#pragma acc data present(i, array[1], array, array[1:2])
|
||||
;
|
||||
|
||||
// CHECK: #pragma acc data default(none) copy(i, array[1], array, array[1:2]) pcopy(i, array[1], array, array[1:2]) present_or_copy(i, array[1], array, array[1:2])
|
||||
#pragma acc data default(none) copy(i, array[1], array, array[1:2]) pcopy(i, array[1], array, array[1:2]) present_or_copy(i, array[1], array, array[1:2])
|
||||
|
||||
@@ -44,9 +44,9 @@ void TemplUses(T t, U u) {
|
||||
// CHECK-NEXT: OpenACCDataConstruct{{.*}} data
|
||||
// CHECK-NEXT: no_create clause
|
||||
// CHECK-NEXT: DeclRefExpr{{.*}}'T' lvalue ParmVar{{.*}} 't' 'T'
|
||||
// TODO_CHECK-NEXT: present clause
|
||||
// TODO_CHECK-NEXT: DeclRefExpr{{.*}}'auto' lvalue NonTypeTemplateParm{{.*}} 'NTTP' 'auto &'
|
||||
// TODO_CHECK-NEXT: DeclRefExpr{{.*}}'U' lvalue ParmVar{{.*}} 'u' 'U'
|
||||
// CHECK-NEXT: present clause
|
||||
// CHECK-NEXT: DeclRefExpr{{.*}}'auto' lvalue NonTypeTemplateParm{{.*}} 'NTTP' 'auto &'
|
||||
// CHECK-NEXT: DeclRefExpr{{.*}}'U' lvalue ParmVar{{.*}} 'u' 'U'
|
||||
// CHECK-NEXT: NullStmt
|
||||
|
||||
// Check the instantiated versions of the above.
|
||||
@@ -66,11 +66,11 @@ void TemplUses(T t, U u) {
|
||||
// CHECK-NEXT: OpenACCDataConstruct{{.*}} data
|
||||
// CHECK-NEXT: no_create clause
|
||||
// CHECK-NEXT: DeclRefExpr{{.*}}'int' lvalue ParmVar{{.*}} 't' 'int'
|
||||
// TODO_CHECK-NEXT: present clause
|
||||
// TODO_CHECK-NEXT: SubstNonTypeTemplateParmExpr{{.*}}'const unsigned int' lvalue
|
||||
// TODO_CHECK-NEXT: NonTypeTemplateParmDecl{{.*}} referenced 'auto &' depth 0 index 0 NTTP
|
||||
// TODO_CHECK-NEXT: DeclRefExpr{{.*}}'const unsigned int' lvalue Var{{.*}} 'CEVar' 'const unsigned int'
|
||||
// TODO_CHECK-NEXT: DeclRefExpr{{.*}}'int *' lvalue ParmVar{{.*}} 'u' 'int *'
|
||||
// CHECK-NEXT: present clause
|
||||
// CHECK-NEXT: SubstNonTypeTemplateParmExpr{{.*}}'const unsigned int' lvalue
|
||||
// CHECK-NEXT: NonTypeTemplateParmDecl{{.*}} referenced 'auto &' depth 0 index 0 NTTP
|
||||
// CHECK-NEXT: DeclRefExpr{{.*}}'const unsigned int' lvalue Var{{.*}} 'CEVar' 'const unsigned int'
|
||||
// CHECK-NEXT: DeclRefExpr{{.*}}'int *' lvalue ParmVar{{.*}} 'u' 'int *'
|
||||
// CHECK-NEXT: NullStmt
|
||||
}
|
||||
|
||||
|
||||
79
clang/test/SemaOpenACC/data-construct-present-ast.cpp
Normal file
79
clang/test/SemaOpenACC/data-construct-present-ast.cpp
Normal file
@@ -0,0 +1,79 @@
|
||||
// RUN: %clang_cc1 %s -fopenacc -ast-dump | FileCheck %s
|
||||
|
||||
// Test this with PCH.
|
||||
// RUN: %clang_cc1 %s -fopenacc -emit-pch -o %t %s
|
||||
// RUN: %clang_cc1 %s -fopenacc -include-pch %t -ast-dump-all | FileCheck %s
|
||||
|
||||
#ifndef PCH_HELPER
|
||||
#define PCH_HELPER
|
||||
|
||||
int Global;
|
||||
short GlobalArray[5];
|
||||
|
||||
void NormalUses(float *PointerParam) {
|
||||
// CHECK: FunctionDecl{{.*}}NormalUses
|
||||
// CHECK: ParmVarDecl
|
||||
// CHECK-NEXT: CompoundStmt
|
||||
|
||||
#pragma acc data default(none) present(GlobalArray, PointerParam[Global])
|
||||
for(int i = 0; i < 5; ++i);
|
||||
// CHECK-NEXT: OpenACCDataConstruct{{.*}} data
|
||||
// CHECK-NEXT: default(none)
|
||||
// CHECK-NEXT: present clause
|
||||
// CHECK-NEXT: DeclRefExpr{{.*}}'short[5]' lvalue Var{{.*}}'GlobalArray' 'short[5]'
|
||||
// CHECK-NEXT: ArraySubscriptExpr{{.*}}'float' lvalue
|
||||
// CHECK-NEXT: ImplicitCastExpr{{.*}} 'float *' <LValueToRValue>
|
||||
// CHECK-NEXT: DeclRefExpr{{.*}}'float *' lvalue ParmVar{{.*}}'PointerParam' 'float *'
|
||||
// CHECK-NEXT: ImplicitCastExpr{{.*}} 'int' <LValueToRValue>
|
||||
// CHECK-NEXT: DeclRefExpr{{.*}}'int' lvalue Var{{.*}}'Global' 'int'
|
||||
// CHECK-NEXT: ForStmt
|
||||
// CHECK: NullStmt
|
||||
}
|
||||
|
||||
template<auto &NTTP, typename T>
|
||||
void TemplUses(T t) {
|
||||
// CHECK-NEXT: FunctionTemplateDecl
|
||||
// CHECK-NEXT: NonTypeTemplateParmDecl {{.*}}referenced 'auto &' depth 0 index 0 NTTP
|
||||
// CHECK-NEXT: TemplateTypeParmDecl{{.*}}typename depth 0 index 1 T
|
||||
// CHECK-NEXT: FunctionDecl{{.*}} TemplUses 'void (T)'
|
||||
// CHECK-NEXT: ParmVarDecl{{.*}} referenced t 'T'
|
||||
// CHECK-NEXT: CompoundStmt
|
||||
|
||||
#pragma acc data default(none) present(NTTP, t)
|
||||
for(int i = 0; i < 5; ++i);
|
||||
// CHECK-NEXT: OpenACCDataConstruct{{.*}} data
|
||||
// CHECK-NEXT: default(none)
|
||||
// CHECK-NEXT: present clause
|
||||
// CHECK-NEXT: DeclRefExpr{{.*}}'auto' lvalue NonTypeTemplateParm{{.*}} 'NTTP' 'auto &'
|
||||
// CHECK-NEXT: DeclRefExpr{{.*}}'T' lvalue ParmVar{{.*}} 't' 'T'
|
||||
// CHECK-NEXT: ForStmt
|
||||
// CHECK: NullStmt
|
||||
|
||||
|
||||
// Check the instantiated versions of the above.
|
||||
// CHECK-NEXT: FunctionDecl{{.*}} used TemplUses 'void (int)' implicit_instantiation
|
||||
// CHECK-NEXT: TemplateArgument decl
|
||||
// CHECK-NEXT: Var{{.*}} 'CEVar' 'const unsigned int'
|
||||
// CHECK-NEXT: TemplateArgument type 'int'
|
||||
// CHECK-NEXT: BuiltinType{{.*}} 'int'
|
||||
// CHECK-NEXT: ParmVarDecl{{.*}} used t 'int'
|
||||
// CHECK-NEXT: CompoundStmt
|
||||
|
||||
// #pragma acc parallel seq present(NTTP, t)
|
||||
// CHECK-NEXT: OpenACCDataConstruct{{.*}} data
|
||||
// CHECK-NEXT: default(none)
|
||||
// CHECK-NEXT: present clause
|
||||
// CHECK-NEXT: SubstNonTypeTemplateParmExpr{{.*}}'const unsigned int' lvalue
|
||||
// CHECK-NEXT: NonTypeTemplateParmDecl{{.*}} referenced 'auto &' depth 0 index 0 NTTP
|
||||
// CHECK-NEXT: DeclRefExpr{{.*}}'const unsigned int' lvalue Var{{.*}} 'CEVar' 'const unsigned int'
|
||||
// CHECK-NEXT: DeclRefExpr{{.*}}'int' lvalue ParmVar{{.*}} 't' 'int'
|
||||
// CHECK-NEXT: ForStmt
|
||||
// CHECK: NullStmt
|
||||
|
||||
}
|
||||
|
||||
void Inst() {
|
||||
static constexpr unsigned CEVar = 1;
|
||||
TemplUses<CEVar>(5);
|
||||
}
|
||||
#endif
|
||||
59
clang/test/SemaOpenACC/data-construct-present-clause.c
Normal file
59
clang/test/SemaOpenACC/data-construct-present-clause.c
Normal file
@@ -0,0 +1,59 @@
|
||||
// RUN: %clang_cc1 %s -fopenacc -verify
|
||||
|
||||
typedef struct IsComplete {
|
||||
struct S { int A; } CompositeMember;
|
||||
int ScalarMember;
|
||||
float ArrayMember[5];
|
||||
void *PointerMember;
|
||||
} Complete;
|
||||
void uses(int IntParam, short *PointerParam, float ArrayParam[5], Complete CompositeParam) {
|
||||
int LocalInt;
|
||||
short *LocalPointer;
|
||||
float LocalArray[5];
|
||||
Complete LocalComposite;
|
||||
// Check Appertainment:
|
||||
#pragma acc data default(none) present(LocalInt)
|
||||
;
|
||||
|
||||
// Valid cases:
|
||||
#pragma acc data default(none) present(LocalInt, LocalPointer, LocalArray)
|
||||
;
|
||||
#pragma acc data default(none) present(LocalArray[2:1])
|
||||
;
|
||||
|
||||
#pragma acc data default(none) present(LocalComposite.ScalarMember, LocalComposite.ScalarMember)
|
||||
;
|
||||
|
||||
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
|
||||
#pragma acc data default(none) present(1 + IntParam)
|
||||
;
|
||||
|
||||
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
|
||||
#pragma acc data default(none) present(+IntParam)
|
||||
;
|
||||
|
||||
// expected-error@+1{{OpenACC sub-array length is unspecified and cannot be inferred because the subscripted value is not an array}}
|
||||
#pragma acc data default(none) present(PointerParam[2:])
|
||||
;
|
||||
|
||||
// expected-error@+1{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
|
||||
#pragma acc data default(none) present(ArrayParam[2:5])
|
||||
;
|
||||
|
||||
// expected-error@+2{{OpenACC sub-array specified range [2:5] would be out of the range of the subscripted array size of 5}}
|
||||
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
|
||||
#pragma acc data default(none) present((float*)ArrayParam[2:5])
|
||||
;
|
||||
// expected-error@+1{{OpenACC variable is not a valid variable name, sub-array, array element, member of a composite variable, or composite variable member}}
|
||||
#pragma acc data default(none) present((float)ArrayParam[2])
|
||||
;
|
||||
|
||||
// expected-error@+1{{OpenACC 'present' clause is not valid on 'enter data' directive}}
|
||||
#pragma acc enter data copyin(LocalInt) present(LocalInt)
|
||||
// expected-error@+1{{OpenACC 'present' clause is not valid on 'exit data' directive}}
|
||||
#pragma acc exit data copyout(LocalInt) present(LocalInt)
|
||||
// expected-warning@+2{{OpenACC clause 'use_device' not yet implemented}}
|
||||
// expected-error@+1{{OpenACC 'present' clause is not valid on 'host_data' directive}}
|
||||
#pragma acc host_data use_device(LocalInt) present(LocalInt)
|
||||
;
|
||||
}
|
||||
@@ -31,7 +31,6 @@ void AtLeastOneOf() {
|
||||
;
|
||||
#pragma acc data no_create(Var)
|
||||
;
|
||||
// expected-warning@+1{{OpenACC clause 'present' not yet implemented}}
|
||||
#pragma acc data present(Var)
|
||||
;
|
||||
// expected-warning@+1{{OpenACC clause 'deviceptr' not yet implemented}}
|
||||
|
||||
Reference in New Issue
Block a user