forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OpenACC] Implement 'if' clause sema for 'data' constructs
This is another one that has no additional sema work other than enabling it, so this patch does just that.
- Loading branch information
1 parent
3392774
commit 6cfad63
Showing
8 changed files
with
200 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
// 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 | ||
void NormalFunc(int j, float f) { | ||
// CHECK: FunctionDecl{{.*}}NormalFunc | ||
// CHECK-NEXT: ParmVarDecl | ||
// CHECK-NEXT: ParmVarDecl | ||
// CHECK-NEXT: CompoundStmt | ||
#pragma acc data if( j < f) default(none) | ||
; | ||
// CHECK-NEXT: OpenACCDataConstruct{{.*}}data | ||
// CHECK-NEXT: if clause | ||
// CHECK-NEXT: BinaryOperator{{.*}} 'bool' '<' | ||
// CHECK-NEXT: ImplicitCastExpr{{.*}} 'float' <IntegralToFloating> | ||
// CHECK-NEXT: ImplicitCastExpr{{.*}} 'int' <LValueToRValue> | ||
// CHECK-NEXT: DeclRefExpr{{.*}} 'int' lvalue ParmVar{{.*}} 'j' 'int' | ||
// CHECK-NEXT: ImplicitCastExpr{{.*}} 'float' <LValueToRValue> | ||
// CHECK-NEXT: DeclRefExpr{{.*}} 'float' lvalue ParmVar{{.*}} 'f' 'float' | ||
// CHECK-NEXT: NullStmt | ||
|
||
} | ||
|
||
int Global; | ||
|
||
template<typename T> | ||
void TemplFunc() { | ||
// CHECK: FunctionTemplateDecl{{.*}}TemplFunc | ||
// CHECK-NEXT: TemplateTypeParmDecl | ||
|
||
// Match the prototype: | ||
// CHECK-NEXT: FunctionDecl{{.*}}TemplFunc | ||
// CHECK-NEXT: CompoundStmt | ||
|
||
#pragma acc data default(none) if(T::SomeFloat < typename T::IntTy{}) | ||
; | ||
// CHECK-NEXT: OpenACCDataConstruct{{.*}}data | ||
// CHECK-NEXT: if clause | ||
// CHECK-NEXT: BinaryOperator{{.*}} '<dependent type>' '<' | ||
// CHECK-NEXT: DependentScopeDeclRefExpr{{.*}} '<dependent type>' lvalue | ||
// CHECK-NEXT: NestedNameSpecifier TypeSpec 'T' | ||
// CHECK-NEXT: CXXUnresolvedConstructExpr{{.*}} 'typename T::IntTy' 'typename T::IntTy' | ||
// CHECK-NEXT: InitListExpr{{.*}} 'void' | ||
// CHECK-NEXT: NullStmt | ||
|
||
#pragma acc enter data copyin(Global) if(typename T::IntTy{}) | ||
; | ||
// CHECK-NEXT: OpenACCEnterDataConstruct{{.*}}enter data | ||
// CHECK-NEXT: if clause | ||
// CHECK-NEXT: CXXUnresolvedConstructExpr{{.*}} 'typename T::IntTy' 'typename T::IntTy' | ||
// CHECK-NEXT: InitListExpr{{.*}} 'void' | ||
// CHECK-NEXT: NullStmt | ||
|
||
#pragma acc exit data copyout(Global) if(T::SomeFloat) | ||
; | ||
// CHECK-NEXT: OpenACCExitDataConstruct{{.*}}exit data | ||
// CHECK-NEXT: if clause | ||
// CHECK-NEXT: DependentScopeDeclRefExpr{{.*}} '<dependent type>' lvalue | ||
// CHECK-NEXT: NestedNameSpecifier TypeSpec 'T' | ||
// CHECK-NEXT: NullStmt | ||
|
||
#pragma acc host_data use_device(Global) if(T::BC) | ||
; | ||
// CHECK-NEXT: OpenACCHostDataConstruct{{.*}}host_data | ||
// CHECK-NEXT: if clause | ||
// CHECK-NEXT: DependentScopeDeclRefExpr{{.*}} '<dependent type>' lvalue | ||
// CHECK-NEXT: NestedNameSpecifier TypeSpec 'T' | ||
// CHECK-NEXT: NullStmt | ||
|
||
// Match the instantiation: | ||
// CHECK: FunctionDecl{{.*}}TemplFunc{{.*}}implicit_instantiation | ||
// CHECK-NEXT: TemplateArgument type 'InstTy' | ||
// CHECK-NEXT: RecordType{{.*}} 'InstTy' | ||
// CHECK-NEXT: CXXRecord{{.*}} 'InstTy' | ||
// CHECK-NEXT: CompoundStmt | ||
|
||
// CHECK-NEXT: OpenACCDataConstruct{{.*}}data | ||
// CHECK-NEXT: if clause | ||
// CHECK-NEXT: BinaryOperator{{.*}} 'bool' '<' | ||
// CHECK-NEXT: ImplicitCastExpr{{.*}} 'float' <LValueToRValue> | ||
// CHECK-NEXT: DeclRefExpr{{.*}} 'const float' lvalue Var{{.*}} 'SomeFloat' 'const float' | ||
// CHECK-NEXT: NestedNameSpecifier TypeSpec 'InstTy' | ||
// CHECK-NEXT: ImplicitCastExpr{{.*}} 'float' <IntegralToFloating> | ||
// CHECK-NEXT: CXXFunctionalCastExpr{{.*}}'typename InstTy::IntTy':'int' functional cast to typename struct InstTy::IntTy <NoOp> | ||
// CHECK-NEXT: InitListExpr {{.*}}'typename InstTy::IntTy':'int' | ||
// CHECK-NEXT: NullStmt | ||
|
||
// CHECK-NEXT: OpenACCEnterDataConstruct{{.*}}enter data | ||
// CHECK-NEXT: if clause | ||
// CHECK-NEXT: ImplicitCastExpr{{.*}}'bool' <IntegralToBoolean> | ||
// CHECK-NEXT: CXXFunctionalCastExpr{{.*}}'typename InstTy::IntTy':'int' functional cast to typename struct InstTy::IntTy <NoOp> | ||
// CHECK-NEXT: InitListExpr {{.*}}'typename InstTy::IntTy':'int' | ||
// CHECK-NEXT: NullStmt | ||
|
||
// CHECK-NEXT: OpenACCExitDataConstruct{{.*}}exit data | ||
// CHECK-NEXT: if clause | ||
// CHECK-NEXT: ImplicitCastExpr{{.*}}'bool' <FloatingToBoolean> | ||
// CHECK-NEXT: ImplicitCastExpr{{.*}}'float' <LValueToRValue> | ||
// CHECK-NEXT: DeclRefExpr{{.*}} 'const float' lvalue Var{{.*}} 'SomeFloat' 'const float' | ||
// CHECK-NEXT: NestedNameSpecifier TypeSpec 'InstTy' | ||
// CHECK-NEXT: NullStmt | ||
|
||
// CHECK-NEXT: OpenACCHostDataConstruct{{.*}}host_data | ||
// CHECK-NEXT: if clause | ||
// CHECK-NEXT: ImplicitCastExpr{{.*}} 'bool' <UserDefinedConversion> | ||
// CHECK-NEXT: CXXMemberCallExpr{{.*}} 'bool' | ||
// CHECK-NEXT: MemberExpr{{.*}} .operator bool | ||
// CHECK-NEXT: DeclRefExpr{{.*}} 'const BoolConversion' lvalue Var{{.*}} 'BC' 'const BoolConversion' | ||
// CHECK-NEXT: NestedNameSpecifier TypeSpec 'InstTy' | ||
// CHECK-NEXT: NullStmt | ||
|
||
} | ||
|
||
struct BoolConversion{ operator bool() const;}; | ||
struct InstTy { | ||
using IntTy = int; | ||
static constexpr float SomeFloat = 5.0; | ||
static constexpr BoolConversion BC; | ||
}; | ||
|
||
void Instantiate() { | ||
TemplFunc<InstTy>(); | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// RUN: %clang_cc1 %s -fopenacc -verify | ||
|
||
void Foo() { | ||
int Var; | ||
// expected-warning@+1{{OpenACC clause 'default' not yet implemented}} | ||
#pragma acc data default(present) if(1) | ||
; | ||
// expected-warning@+3{{OpenACC clause 'default' not yet implemented}} | ||
// expected-error@+2{{OpenACC 'if' clause cannot appear more than once on a 'data' directive}} | ||
// expected-note@+1{{previous clause is here}} | ||
#pragma acc data default(present) if(1) if (2) | ||
; | ||
|
||
// expected-warning@+1{{OpenACC clause 'copyin' not yet implemented}} | ||
#pragma acc enter data copyin(Var) if(1) | ||
|
||
// expected-warning@+3{{OpenACC clause 'copyin' not yet implemented}} | ||
// expected-error@+2{{OpenACC 'if' clause cannot appear more than once on a 'enter data' directive}} | ||
// expected-note@+1{{previous clause is here}} | ||
#pragma acc enter data copyin(Var) if(1) if (2) | ||
|
||
// expected-warning@+1{{OpenACC clause 'copyout' not yet implemented}} | ||
#pragma acc exit data copyout(Var) if(1) | ||
// expected-warning@+3{{OpenACC clause 'copyout' not yet implemented}} | ||
// expected-error@+2{{OpenACC 'if' clause cannot appear more than once on a 'exit data' directive}} | ||
// expected-note@+1{{previous clause is here}} | ||
#pragma acc exit data copyout(Var) if(1) if (2) | ||
|
||
// expected-warning@+1{{OpenACC clause 'use_device' not yet implemented}} | ||
#pragma acc host_data use_device(Var) if(1) | ||
; | ||
// expected-warning@+3{{OpenACC clause 'use_device' not yet implemented}} | ||
// expected-error@+2{{OpenACC 'if' clause cannot appear more than once on a 'host_data' directive}} | ||
// expected-note@+1{{previous clause is here}} | ||
#pragma acc host_data use_device(Var) if(1) if (2) | ||
; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters