Skip to content

Commit b34b140

Browse files
committed
update macro usage
1 parent 70f8478 commit b34b140

File tree

6 files changed

+32
-5
lines changed

6 files changed

+32
-5
lines changed

libclc/CMakeLists.txt

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -440,13 +440,19 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
440440
# to declare certain builtins in that address space.
441441
# Note: we assume that if there is no distinct generic address space, it
442442
# maps to the private address space.
443-
set ( has_distinct_generic_addrspace TRUE )
444-
if( ARCH STREQUAL nvptx OR ARCH STREQUAL nvptx64 )
445-
set ( has_distinct_generic_addrspace FALSE )
443+
set ( private_addrspace_val 0 )
444+
set ( generic_addrspace_val 0 )
445+
if( ARCH STREQUAL amdgcn OR ARCH STREQUAL r600 OR ARCH STREQUAL amdgcn-amdhsa )
446+
set ( private_addrspace_val 5 )
446447
endif()
447-
if( has_distinct_generic_addrspace )
448-
list( APPEND build_flags -D__CLC_DISTINCT_GENERIC_ADDRSPACE__ )
448+
if( ARCH STREQUAL spirv OR ARCH STREQUAL spirv64
449+
OR ARCH STREQUAL clspv OR ARCH STREQUAL clspv64 )
450+
set ( generic_addrspace_val 4 )
449451
endif()
452+
list( APPEND build_flags
453+
-D__CLC_PRIVATE_ADDRSPACE_VAL=${private_addrspace_val}
454+
-D__CLC_GENERIC_ADDRSPACE_VAL=${generic_addrspace_val}
455+
)
450456

451457
set( clc_build_flags ${build_flags} -DCLC_INTERNAL )
452458

libclc/clc/include/clc/clcfunc.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,14 @@
2727
(__OPENCL_C_VERSION__ >= CL_VERSION_3_0 && \
2828
defined(__opencl_c_generic_address_space))
2929
#define _CLC_GENERIC_AS_SUPPORTED 1
30+
#if __CLC_PRIVATE_ADDRSPACE_VAL != __CLC_GENERIC_ADDRSPACE_VAL
31+
#define _CLC_DISTINCT_GENERIC_AS_SUPPORTED 1
32+
#else
33+
#define _CLC_DISTINCT_GENERIC_AS_SUPPORTED 0
34+
#endif
3035
#else
3136
#define _CLC_GENERIC_AS_SUPPORTED 0
37+
#define _CLC_DISTINCT_GENERIC_AS_SUPPORTED 0
3238
#endif
3339

3440
#endif // __CLC_CLCFUNC_H_

libclc/clc/include/clc/math/remquo_decl.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,8 @@ _CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION(__CLC_GENTYPE x,
1717
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION(__CLC_GENTYPE x,
1818
__CLC_GENTYPE y,
1919
local __CLC_INTN *q);
20+
#if _CLC_GENERIC_AS_SUPPORTED
21+
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE __CLC_FUNCTION(__CLC_GENTYPE x,
22+
__CLC_GENTYPE y,
23+
generic __CLC_INTN *q);
24+
#endif

libclc/clc/lib/generic/math/clc_fract.inc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,8 @@ _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE __clc_fract(__CLC_GENTYPE x,
3434

3535
FRACT_DEF(local);
3636
FRACT_DEF(global);
37+
#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED
38+
FRACT_DEF(generic);
39+
#endif
3740

3841
#undef MIN_CONSTANT

libclc/clc/lib/generic/math/clc_frexp.cl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
#include <clc/clcfunc.h>
910
#include <clc/clc_convert.h>
1011
#include <clc/internal/clc.h>
1112
#include <clc/math/math.h>

libclc/clc/lib/generic/math/clc_remquo.cl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,9 @@
2929
#define __CLC_ADDRESS_SPACE local
3030
#include <clc_remquo.inc>
3131
#undef __CLC_ADDRESS_SPACE
32+
33+
#if _CLC_DISTINCT_GENERIC_AS_SUPPORTED
34+
#define __CLC_ADDRESS_SPACE generic
35+
#include <clc_remquo.inc>
36+
#undef __CLC_ADDRESS_SPACE
37+
#endif

0 commit comments

Comments
 (0)