Skip to content

Commit 576161b

Browse files
authored
Merge branch 'main' into Ziccamoc
2 parents 95da403 + d859cb6 commit 576161b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1409
-625
lines changed

clang/lib/Basic/Targets/SPIR.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ static const unsigned SPIRDefIsPrivMap[] = {
5858
// Used by both the SPIR and SPIR-V targets.
5959
static const unsigned SPIRDefIsGenMap[] = {
6060
4, // Default
61-
// OpenCL address space values for this map are dummy and they can't be used
62-
0, // opencl_global
61+
// Some OpenCL address space values for this map are dummy and they can't be
62+
// used
63+
1, // opencl_global
6364
0, // opencl_local
6465
0, // opencl_constant
6566
0, // opencl_private

clang/lib/Sema/SemaOpenACCClause.cpp

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2085,32 +2085,31 @@ bool SemaOpenACC::CheckDeclareClause(SemaOpenACC::OpenACCParsedClause &Clause,
20852085
}
20862086
} else {
20872087
const auto *DRE = cast<DeclRefExpr>(VarExpr);
2088-
const VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl());
2089-
if (Var)
2088+
if (const auto *Var = dyn_cast<VarDecl>(DRE->getDecl())) {
20902089
CurDecl = Var->getCanonicalDecl();
20912090

2092-
// OpenACC3.3 2.13:
2093-
// A 'declare' directive must be in the same scope as the declaration of
2094-
// any var that appears in the clauses of the directive or any scope
2095-
// within a C/C++ function.
2096-
// We can't really check 'scope' here, so we check declaration context,
2097-
// which is a reasonable approximation, but misses scopes inside of
2098-
// functions.
2099-
if (removeLinkageSpecDC(Var->getCanonicalDecl()
2100-
->getLexicalDeclContext()
2101-
->getPrimaryContext()) != DC) {
2102-
Diag(VarExpr->getBeginLoc(), diag::err_acc_declare_same_scope)
2103-
<< Clause.getClauseKind();
2104-
continue;
2105-
}
2106-
// OpenACC3.3 2.13:
2107-
// C and C++ extern variables may only appear in 'create',
2108-
// 'copyin', 'deviceptr', 'device_resident', or 'link' clauses on a
2109-
// 'declare' directive.
2110-
if (!IsSpecialClause && Var && Var->hasExternalStorage()) {
2111-
Diag(VarExpr->getBeginLoc(), diag::err_acc_declare_extern)
2112-
<< Clause.getClauseKind();
2113-
continue;
2091+
// OpenACC3.3 2.13:
2092+
// A 'declare' directive must be in the same scope as the declaration of
2093+
// any var that appears in the clauses of the directive or any scope
2094+
// within a C/C++ function.
2095+
// We can't really check 'scope' here, so we check declaration context,
2096+
// which is a reasonable approximation, but misses scopes inside of
2097+
// functions.
2098+
if (removeLinkageSpecDC(
2099+
Var->getLexicalDeclContext()->getPrimaryContext()) != DC) {
2100+
Diag(VarExpr->getBeginLoc(), diag::err_acc_declare_same_scope)
2101+
<< Clause.getClauseKind();
2102+
continue;
2103+
}
2104+
// OpenACC3.3 2.13:
2105+
// C and C++ extern variables may only appear in 'create',
2106+
// 'copyin', 'deviceptr', 'device_resident', or 'link' clauses on a
2107+
// 'declare' directive.
2108+
if (!IsSpecialClause && Var->hasExternalStorage()) {
2109+
Diag(VarExpr->getBeginLoc(), diag::err_acc_declare_extern)
2110+
<< Clause.getClauseKind();
2111+
continue;
2112+
}
21142113
}
21152114

21162115
// OpenACC3.3 2.13:
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %clang_cc1 -fcuda-is-device -triple spirv32 -o - -emit-llvm -x cuda %s | FileCheck --check-prefix=CHECK-SPIRV32 %s
2+
// RUN: %clang_cc1 -fcuda-is-device -triple spirv64 -o - -emit-llvm -x cuda %s | FileCheck --check-prefix=CHECK-SPIRV64 %s
3+
4+
// CHECK-SPIRV32: @.str = private unnamed_addr addrspace(4) constant [13 x i8] c"Hello World\0A\00", align 1
5+
// CHECK-SPIRV64: @.str = private unnamed_addr addrspace(1) constant [13 x i8] c"Hello World\0A\00", align 1
6+
7+
extern "C" __attribute__((device)) int printf(const char* format, ...);
8+
9+
__attribute__((global)) void printf_kernel() {
10+
printf("Hello World\n");
11+
}

libclc/amdgpu/lib/SOURCES_3.9

Lines changed: 0 additions & 2 deletions
This file was deleted.

libclc/amdgpu/lib/SOURCES_4.0

Lines changed: 0 additions & 2 deletions
This file was deleted.

libclc/amdgpu/lib/SOURCES_5.0

Lines changed: 0 additions & 2 deletions
This file was deleted.

libclc/amdgpu/lib/shared/vload_half_helpers.ll

Lines changed: 0 additions & 31 deletions
This file was deleted.

libclc/amdgpu/lib/shared/vstore_half_helpers.ll

Lines changed: 0 additions & 43 deletions
This file was deleted.

libclc/generic/lib/shared/vload.cl

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,7 @@ VLOAD_ADDR_SPACES(half)
8181

8282
/* vload_half are legal even without cl_khr_fp16 */
8383
/* no vload_half for double */
84-
#if __clang_major__ < 6
85-
float __clc_vload_half_float_helper__constant(const __constant half *);
86-
float __clc_vload_half_float_helper__global(const __global half *);
87-
float __clc_vload_half_float_helper__local(const __local half *);
88-
float __clc_vload_half_float_helper__private(const __private half *);
89-
90-
#define VEC_LOAD1(val, AS) \
91-
val = __clc_vload_half_float_helper##AS(&mem[offset++]);
92-
#else
9384
#define VEC_LOAD1(val, AS) val = __builtin_load_halff(&mem[offset++]);
94-
#endif
95-
9685
#define VEC_LOAD2(val, AS) \
9786
VEC_LOAD1(val.lo, AS) \
9887
VEC_LOAD1(val.hi, AS)

libclc/generic/lib/shared/vstore.cl

Lines changed: 30 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -75,57 +75,35 @@ VSTORE_ADDR_SPACES(double)
7575
VSTORE_ADDR_SPACES(half)
7676
#endif
7777

78-
/* vstore_half are legal even without cl_khr_fp16 */
79-
#if __clang_major__ < 6
80-
#define DECLARE_HELPER(STYPE, AS, builtin) \
81-
void __clc_vstore_half_##STYPE##_helper##AS(STYPE, AS half *);
82-
#else
83-
#define DECLARE_HELPER(STYPE, AS, __builtin) \
84-
_CLC_DEF void __clc_vstore_half_##STYPE##_helper##AS(STYPE s, AS half *d) { \
85-
__builtin(s, d); \
86-
}
87-
#endif
88-
89-
DECLARE_HELPER(float, __private, __builtin_store_halff);
90-
DECLARE_HELPER(float, __global, __builtin_store_halff);
91-
DECLARE_HELPER(float, __local, __builtin_store_halff);
92-
93-
#ifdef cl_khr_fp64
94-
DECLARE_HELPER(double, __private, __builtin_store_half);
95-
DECLARE_HELPER(double, __global, __builtin_store_half);
96-
DECLARE_HELPER(double, __local, __builtin_store_half);
97-
#endif
98-
99-
#define VEC_STORE1(STYPE, AS, val, ROUNDF) \
100-
__clc_vstore_half_##STYPE##_helper##AS(ROUNDF(val), &mem[offset++]);
101-
102-
#define VEC_STORE2(STYPE, AS, val, ROUNDF) \
103-
VEC_STORE1(STYPE, AS, val.lo, ROUNDF) \
104-
VEC_STORE1(STYPE, AS, val.hi, ROUNDF)
105-
#define VEC_STORE3(STYPE, AS, val, ROUNDF) \
106-
VEC_STORE1(STYPE, AS, val.s0, ROUNDF) \
107-
VEC_STORE1(STYPE, AS, val.s1, ROUNDF) \
108-
VEC_STORE1(STYPE, AS, val.s2, ROUNDF)
109-
#define VEC_STORE4(STYPE, AS, val, ROUNDF) \
110-
VEC_STORE2(STYPE, AS, val.lo, ROUNDF) \
111-
VEC_STORE2(STYPE, AS, val.hi, ROUNDF)
112-
#define VEC_STORE8(STYPE, AS, val, ROUNDF) \
113-
VEC_STORE4(STYPE, AS, val.lo, ROUNDF) \
114-
VEC_STORE4(STYPE, AS, val.hi, ROUNDF)
115-
#define VEC_STORE16(STYPE, AS, val, ROUNDF) \
116-
VEC_STORE8(STYPE, AS, val.lo, ROUNDF) \
117-
VEC_STORE8(STYPE, AS, val.hi, ROUNDF)
118-
119-
#define __FUNC(SUFFIX, VEC_SIZE, OFFSET, TYPE, STYPE, AS, ROUNDF) \
78+
#define VEC_STORE1(val, ROUNDF, BUILTIN) BUILTIN(ROUNDF(val), &mem[offset++]);
79+
80+
#define VEC_STORE2(val, ROUNDF, BUILTIN) \
81+
VEC_STORE1(val.lo, ROUNDF, BUILTIN) \
82+
VEC_STORE1(val.hi, ROUNDF, BUILTIN)
83+
#define VEC_STORE3(val, ROUNDF, BUILTIN) \
84+
VEC_STORE1(val.s0, ROUNDF, BUILTIN) \
85+
VEC_STORE1(val.s1, ROUNDF, BUILTIN) \
86+
VEC_STORE1(val.s2, ROUNDF, BUILTIN)
87+
#define VEC_STORE4(val, ROUNDF, BUILTIN) \
88+
VEC_STORE2(val.lo, ROUNDF, BUILTIN) \
89+
VEC_STORE2(val.hi, ROUNDF, BUILTIN)
90+
#define VEC_STORE8(val, ROUNDF, BUILTIN) \
91+
VEC_STORE4(val.lo, ROUNDF, BUILTIN) \
92+
VEC_STORE4(val.hi, ROUNDF, BUILTIN)
93+
#define VEC_STORE16(val, ROUNDF, BUILTIN) \
94+
VEC_STORE8(val.lo, ROUNDF, BUILTIN) \
95+
VEC_STORE8(val.hi, ROUNDF, BUILTIN)
96+
97+
#define __FUNC(SUFFIX, VEC_SIZE, OFFSET, TYPE, AS, ROUNDF, BUILTIN) \
12098
_CLC_OVERLOAD _CLC_DEF void vstore_half##SUFFIX(TYPE vec, size_t offset, \
12199
AS half *mem) { \
122100
offset *= VEC_SIZE; \
123-
VEC_STORE##VEC_SIZE(STYPE, AS, vec, ROUNDF) \
101+
VEC_STORE##VEC_SIZE(vec, ROUNDF, BUILTIN) \
124102
} \
125103
_CLC_OVERLOAD _CLC_DEF void vstorea_half##SUFFIX(TYPE vec, size_t offset, \
126104
AS half *mem) { \
127105
offset *= OFFSET; \
128-
VEC_STORE##VEC_SIZE(STYPE, AS, vec, ROUNDF) \
106+
VEC_STORE##VEC_SIZE(vec, ROUNDF, BUILTIN) \
129107
}
130108

131109
_CLC_DEF _CLC_OVERLOAD float __clc_noop(float x) { return x; }
@@ -246,15 +224,15 @@ _CLC_DEF _CLC_OVERLOAD double __clc_rte(double x) {
246224
}
247225
#endif
248226

249-
#define __XFUNC(SUFFIX, VEC_SIZE, OFFSET, TYPE, STYPE, AS) \
250-
__FUNC(SUFFIX, VEC_SIZE, OFFSET, TYPE, STYPE, AS, __clc_noop) \
251-
__FUNC(SUFFIX##_rtz, VEC_SIZE, OFFSET, TYPE, STYPE, AS, __clc_rtz) \
252-
__FUNC(SUFFIX##_rtn, VEC_SIZE, OFFSET, TYPE, STYPE, AS, __clc_rtn) \
253-
__FUNC(SUFFIX##_rtp, VEC_SIZE, OFFSET, TYPE, STYPE, AS, __clc_rtp) \
254-
__FUNC(SUFFIX##_rte, VEC_SIZE, OFFSET, TYPE, STYPE, AS, __clc_rte)
227+
#define __XFUNC(SUFFIX, VEC_SIZE, OFFSET, TYPE, AS, BUILTIN) \
228+
__FUNC(SUFFIX, VEC_SIZE, OFFSET, TYPE, AS, __clc_noop, BUILTIN) \
229+
__FUNC(SUFFIX##_rtz, VEC_SIZE, OFFSET, TYPE, AS, __clc_rtz, BUILTIN) \
230+
__FUNC(SUFFIX##_rtn, VEC_SIZE, OFFSET, TYPE, AS, __clc_rtn, BUILTIN) \
231+
__FUNC(SUFFIX##_rtp, VEC_SIZE, OFFSET, TYPE, AS, __clc_rtp, BUILTIN) \
232+
__FUNC(SUFFIX##_rte, VEC_SIZE, OFFSET, TYPE, AS, __clc_rte, BUILTIN)
255233

256-
#define FUNC(SUFFIX, VEC_SIZE, OFFSET, TYPE, STYPE, AS) \
257-
__XFUNC(SUFFIX, VEC_SIZE, OFFSET, TYPE, STYPE, AS)
234+
#define FUNC(SUFFIX, VEC_SIZE, OFFSET, TYPE, AS, BUILTIN) \
235+
__XFUNC(SUFFIX, VEC_SIZE, OFFSET, TYPE, AS, BUILTIN)
258236

259237
#define __CLC_BODY "vstore_half.inc"
260238
#include <clc/math/gentype.inc>

0 commit comments

Comments
 (0)