mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 12:56:06 +00:00

The 'declare' construct is the first of two 'declaration' level constructs, so it is legal in any place a declaration is, including as a statement, which this accomplishes by wrapping it in a DeclStmt. All clauses on this have a 'same scope' requirement, which this enforces as declaration context instead, which makes it possible to implement these as a template. The 'link' and 'device_resident' clauses are also added, which have some similar/small restrictions, but are otherwise pretty rote. This patch implements all of the above.
53 lines
1.5 KiB
C++
53 lines
1.5 KiB
C++
// RUN: %clang_cc1 -fopenacc -ast-print %s -o - | FileCheck %s
|
|
|
|
int *Global, *Global2;
|
|
int GlobalArray[5];
|
|
int GlobalArray2[5];
|
|
// CHECK: #pragma acc declare deviceptr(Global) copyin(GlobalArray)
|
|
#pragma acc declare deviceptr(Global), copyin(GlobalArray)
|
|
// CHECK: #pragma acc declare create(Global2, GlobalArray2)
|
|
#pragma acc declare create(Global2, GlobalArray2)
|
|
|
|
namespace NS {
|
|
int NSVar;
|
|
int NSArray[5];
|
|
// CHECK: #pragma acc declare create(NSVar, NSArray)
|
|
#pragma acc declare create(NSVar, NSArray)
|
|
}
|
|
|
|
struct Struct {
|
|
static const int StaticMem = 5;
|
|
static const int StaticMemArray[5];
|
|
// CHECK: #pragma acc declare copyin(StaticMem, StaticMemArray)
|
|
#pragma acc declare copyin(StaticMem, StaticMemArray)
|
|
|
|
void MemFunc1(int Arg) {
|
|
int Local;
|
|
int LocalArray[5];
|
|
// CHECK: #pragma acc declare present(Arg, Local, LocalArray)
|
|
#pragma acc declare present(Arg, Local, LocalArray)
|
|
}
|
|
void MemFunc2(int Arg);
|
|
};
|
|
void Struct::MemFunc2(int Arg) {
|
|
int Local;
|
|
int LocalArray[5];
|
|
// CHECK: #pragma acc declare present(Arg, Local, LocalArray)
|
|
#pragma acc declare present(Arg, Local, LocalArray)
|
|
}
|
|
|
|
void NormalFunc(int Arg) {
|
|
int Local;
|
|
int LocalArray[5];
|
|
// CHECK: #pragma acc declare present(Arg, Local, LocalArray)
|
|
#pragma acc declare present(Arg, Local, LocalArray)
|
|
}
|
|
|
|
void NormalFunc2(int *Arg) {
|
|
int Local;
|
|
int LocalArray[5];
|
|
extern int ExternLocal;
|
|
// CHECK: #pragma acc declare deviceptr(Arg) device_resident(Local) link(ExternLocal)
|
|
#pragma acc declare deviceptr(Arg) device_resident(Local) link(ExternLocal)
|
|
}
|