Skip to content

Commit b977937

Browse files
committed
[libclc] Sync latest sycl-web to pulldown branch
1 parent ea3768c commit b977937

File tree

901 files changed

+5378
-1801
lines changed

Some content is hidden

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

901 files changed

+5378
-1801
lines changed

libclc/CMakeLists.txt

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ set( LIBCLC_TARGETS_TO_BUILD "all"
4949

5050
option( ENABLE_RUNTIME_SUBNORMAL "Enable runtime linking of subnormal support." OFF )
5151

52+
# Top level target used to build all Libclc libraries.
53+
add_custom_target( libclc ALL )
54+
55+
add_custom_target( libclc-opencl-builtins COMMENT "Build libclc OpenCL builtins" )
56+
add_dependencies( libclc libclc-opencl-builtins )
57+
5258
if( LIBCLC_STANDALONE_BUILD OR CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
5359
# Out-of-tree configuration
5460
set( LIBCLC_STANDALONE_BUILD TRUE )
@@ -92,9 +98,6 @@ else()
9298
endif()
9399
endif()
94100

95-
# Setup the paths where libclc runtimes should be stored.
96-
set( LIBCLC_OUTPUT_LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR} )
97-
98101
if( EXISTS ${LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR} )
99102
message( WARNING "Using custom LLVM tools to build libclc: "
100103
"${LIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR}, "
@@ -176,7 +179,6 @@ if( "spirv-mesa3d-" IN_LIST LIBCLC_TARGETS_TO_BUILD OR "spirv64-mesa3d-" IN_LIST
176179
endif()
177180

178181
add_custom_target(libspirv-builtins COMMENT "Build libspirv builtins")
179-
add_custom_target(libopencl-builtins COMMENT "Build libclc builtins")
180182

181183
if( LIBCLC_TARGETS_TO_BUILD STREQUAL "all" )
182184
set( LIBCLC_TARGETS_TO_BUILD ${LIBCLC_TARGETS_ALL} )
@@ -197,9 +199,6 @@ endif()
197199

198200
list( SORT LIBCLC_TARGETS_TO_BUILD )
199201

200-
# Construct LLVM version define
201-
set( LLVM_VERSION_DEFINE "-DHAVE_LLVM=0x${LLVM_VERSION_MAJOR}0${LLVM_VERSION_MINOR}" )
202-
203202
set(LIBCLC_TARGET_TO_TEST)
204203

205204
foreach ( t ${LIBCLC_TEST_TARGETS_ALL})
@@ -208,8 +207,14 @@ foreach ( t ${LIBCLC_TEST_TARGETS_ALL})
208207
endif()
209208
endforeach(t)
210209

210+
# This needs to be set before any target that needs it
211+
# We need to use LLVM_INCLUDE_DIRS here, because if we are linking to an
212+
# llvm build directory, this includes $src/llvm/include which is where all the
213+
# headers are not $build/include/ which is what LLVM_INCLUDE_DIR is set to.
214+
include_directories( ${LLVM_INCLUDE_DIRS} )
215+
211216
# Configure prepare_builtins
212-
add_subdirectory(utils)
217+
add_subdirectory( utils )
213218

214219
# Setup arch devices
215220
set( r600--_devices cedar cypress barts cayman )
@@ -250,7 +255,6 @@ if( ENABLE_RUNTIME_SUBNORMAL )
250255
foreach( file IN ITEMS subnormal_use_default subnormal_disable )
251256
link_bc(
252257
TARGET ${file}
253-
RSP_DIR ${LIBCLC_ARCH_OBJFILE_DIR}
254258
INPUTS ${CMAKE_CURRENT_SOURCE_DIR}/opencl/lib/generic/${file}.ll
255259
)
256260
install(
@@ -342,6 +346,10 @@ else(LIBCLC_STANDALONE_BUILD)
342346
endif(LIBCLC_STANDALONE_BUILD)
343347
file( TO_CMAKE_PATH ${LIBCLC_LIBRARY_OUTPUT_INTDIR}/clc LIBCLC_LIBRARY_OUTPUT_INTDIR )
344348

349+
# Setup the paths where libclc runtimes should be stored.
350+
# FIXME: Align with upstream
351+
set( LIBCLC_OUTPUT_LIBRARY_DIR ${LIBCLC_LIBRARY_OUTPUT_INTDIR} )
352+
345353
foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
346354
message( STATUS "libclc target '${t}' is enabled" )
347355
string( REPLACE "-" ";" TRIPLE ${t}-- )
@@ -517,6 +525,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
517525
-I${CMAKE_CURRENT_SOURCE_DIR}/clc/include
518526
# Error on undefined macros
519527
-Werror=undef
528+
-fdiscard-value-names
520529
)
521530

522531
if( NOT "${cpu}" STREQUAL "" )
@@ -575,7 +584,6 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
575584
ARCH ${ARCH}
576585
ARCH_SUFFIX libspirv-${arch_suffix}
577586
TRIPLE ${clang_triple}
578-
TARGET_ENV libspirv-
579587
REMANGLE ${LIBCLC_GENERATE_REMANGLED_VARIANTS}
580588
COMPILE_FLAGS ${spirv_build_flags}
581589
OPT_FLAGS ${opt_flags}
@@ -602,7 +610,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
602610
LIB_FILES ${opencl_lib_files}
603611
GEN_FILES ${opencl_gen_files}
604612
ALIASES ${${d}_aliases}
605-
PARENT_TARGET libopencl-builtins
613+
PARENT_TARGET libclc-opencl-builtins
606614
# Link in the CLC builtins and internalize their symbols
607615
INTERNAL_LINK_DEPENDENCIES builtins.link.clc-${arch_suffix}
608616
)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// MemoryOrder is memory order supported by Clang __scoped_atomic* builtins.
10+
// MemoryScope is memory scope supported by Clang __scoped_atomic* builtins.
11+
12+
#ifdef __CLC_SCALAR
13+
#if defined(__CLC_FPSIZE) || (__CLC_GENSIZE >= 32)
14+
15+
#ifdef __CLC_NO_VALUE_ARG
16+
#define __CLC_DECLARE_ATOMIC(ADDRSPACE) \
17+
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION( \
18+
volatile ADDRSPACE __CLC_GENTYPE *Ptr, int MemoryOrder, \
19+
int MemoryScope);
20+
#elif defined(__CLC_RETURN_VOID)
21+
#define __CLC_DECLARE_ATOMIC(ADDRSPACE) \
22+
_CLC_OVERLOAD _CLC_DECL void FUNCTION(volatile ADDRSPACE __CLC_GENTYPE *Ptr, \
23+
__CLC_GENTYPE Value, int MemoryOrder, \
24+
int MemoryScope);
25+
#elif defined(__CLC_COMPARE_EXCHANGE)
26+
#define __CLC_DECLARE_ATOMIC(ADDRSPACE) \
27+
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION( \
28+
volatile ADDRSPACE __CLC_GENTYPE *Ptr, __CLC_GENTYPE Comparator, \
29+
__CLC_GENTYPE Value, int MemoryOrderEqual, int MemoryOrderUnequal, \
30+
int MemoryScope);
31+
#else
32+
#define __CLC_DECLARE_ATOMIC(ADDRSPACE) \
33+
_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE FUNCTION( \
34+
volatile ADDRSPACE __CLC_GENTYPE *Ptr, __CLC_GENTYPE Value, \
35+
int MemoryOrder, int MemoryScope);
36+
#endif
37+
38+
__CLC_DECLARE_ATOMIC(global)
39+
__CLC_DECLARE_ATOMIC(local)
40+
#if _CLC_GENERIC_AS_SUPPORTED
41+
__CLC_DECLARE_ATOMIC()
42+
#endif
43+
44+
#undef __CLC_DECLARE_ATOMIC
45+
46+
#endif // defined(__CLC_FPSIZE) || (__CLC_GENSIZE >= 32)
47+
#endif // __CLC_SCALAR
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef __CLC_ATOMIC_CLC_ATOMIC_COMPARE_EXCHANGE_H__
10+
#define __CLC_ATOMIC_CLC_ATOMIC_COMPARE_EXCHANGE_H__
11+
12+
#include <clc/internal/clc.h>
13+
14+
#define FUNCTION __clc_atomic_compare_exchange
15+
#define __CLC_COMPARE_EXCHANGE
16+
17+
#define __CLC_BODY <clc/atomic/atomic_decl.inc>
18+
#include <clc/integer/gentype.inc>
19+
20+
#define __CLC_BODY <clc/atomic/atomic_decl.inc>
21+
#include <clc/math/gentype.inc>
22+
23+
#undef __CLC_COMPARE_EXCHANGE
24+
#undef FUNCTION
25+
26+
#endif // __CLC_ATOMIC_CLC_ATOMIC_COMPARE_EXCHANGE_H__
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef __CLC_ATOMIC_CLC_ATOMIC_DEC_H__
10+
#define __CLC_ATOMIC_CLC_ATOMIC_DEC_H__
11+
12+
#include <clc/internal/clc.h>
13+
14+
#define FUNCTION __clc_atomic_dec
15+
#define __CLC_NO_VALUE_ARG
16+
17+
#define __CLC_BODY <clc/atomic/atomic_decl.inc>
18+
#include <clc/integer/gentype.inc>
19+
20+
#undef __CLC_NO_VALUE_ARG
21+
#undef FUNCTION
22+
23+
#endif // __CLC_ATOMIC_CLC_ATOMIC_DEC_H__
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef __CLC_ATOMIC_CLC_ATOMIC_EXCHANGE_H__
10+
#define __CLC_ATOMIC_CLC_ATOMIC_EXCHANGE_H__
11+
12+
#include <clc/internal/clc.h>
13+
14+
#define FUNCTION __clc_atomic_exchange
15+
16+
#define __CLC_BODY <clc/atomic/atomic_decl.inc>
17+
#include <clc/integer/gentype.inc>
18+
19+
#define __CLC_BODY <clc/atomic/atomic_decl.inc>
20+
#include <clc/math/gentype.inc>
21+
22+
#undef FUNCTION
23+
24+
#endif // __CLC_ATOMIC_CLC_ATOMIC_EXCHANGE_H__
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef __CLC_ATOMIC_CLC_ATOMIC_FETCH_ADD_H__
10+
#define __CLC_ATOMIC_CLC_ATOMIC_FETCH_ADD_H__
11+
12+
#include <clc/internal/clc.h>
13+
14+
#define FUNCTION __clc_atomic_fetch_add
15+
16+
#define __CLC_BODY <clc/atomic/atomic_decl.inc>
17+
#include <clc/integer/gentype.inc>
18+
19+
#define __CLC_BODY <clc/atomic/atomic_decl.inc>
20+
#include <clc/math/gentype.inc>
21+
22+
#undef FUNCTION
23+
24+
#endif // __CLC_ATOMIC_CLC_ATOMIC_FETCH_ADD_H__
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef __CLC_ATOMIC_CLC_ATOMIC_FETCH_AND_H__
10+
#define __CLC_ATOMIC_CLC_ATOMIC_FETCH_AND_H__
11+
12+
#include <clc/internal/clc.h>
13+
14+
#define FUNCTION __clc_atomic_fetch_and
15+
16+
#define __CLC_BODY <clc/atomic/atomic_decl.inc>
17+
#include <clc/integer/gentype.inc>
18+
19+
#undef FUNCTION
20+
21+
#endif // __CLC_ATOMIC_CLC_ATOMIC_FETCH_AND_H__
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef __CLC_ATOMIC_CLC_ATOMIC_FETCH_MAX_H__
10+
#define __CLC_ATOMIC_CLC_ATOMIC_FETCH_MAX_H__
11+
12+
#include <clc/internal/clc.h>
13+
14+
#define FUNCTION __clc_atomic_fetch_max
15+
16+
#define __CLC_BODY <clc/atomic/atomic_decl.inc>
17+
#include <clc/integer/gentype.inc>
18+
19+
#define __CLC_BODY <clc/atomic/atomic_decl.inc>
20+
#include <clc/math/gentype.inc>
21+
22+
#undef FUNCTION
23+
24+
#endif // __CLC_ATOMIC_CLC_ATOMIC_FETCH_MAX_H__
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef __CLC_ATOMIC_CLC_ATOMIC_FETCH_MIN_H__
10+
#define __CLC_ATOMIC_CLC_ATOMIC_FETCH_MIN_H__
11+
12+
#include <clc/internal/clc.h>
13+
14+
#define FUNCTION __clc_atomic_fetch_min
15+
16+
#define __CLC_BODY <clc/atomic/atomic_decl.inc>
17+
#include <clc/integer/gentype.inc>
18+
19+
#define __CLC_BODY <clc/atomic/atomic_decl.inc>
20+
#include <clc/math/gentype.inc>
21+
22+
#undef FUNCTION
23+
24+
#endif // __CLC_ATOMIC_CLC_ATOMIC_FETCH_MIN_H__
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef __CLC_ATOMIC_CLC_ATOMIC_FETCH_OR_H__
10+
#define __CLC_ATOMIC_CLC_ATOMIC_FETCH_OR_H__
11+
12+
#include <clc/internal/clc.h>
13+
14+
#define FUNCTION __clc_atomic_fetch_or
15+
16+
#define __CLC_BODY <clc/atomic/atomic_decl.inc>
17+
#include <clc/integer/gentype.inc>
18+
19+
#undef FUNCTION
20+
21+
#endif // __CLC_ATOMIC_CLC_ATOMIC_FETCH_OR_H__

0 commit comments

Comments
 (0)