@@ -181,7 +181,7 @@ if( "spirv-mesa3d-" IN_LIST LIBCLC_TARGETS_TO_BUILD OR "spirv64-mesa3d-" IN_LIST
181
181
endif ()
182
182
183
183
add_custom_target (libspirv-builtins COMMENT "Build libspirv builtins" )
184
- add_custom_target (libclc -builtins COMMENT "Build libclc builtins" )
184
+ add_custom_target (libopencl -builtins COMMENT "Build libclc builtins" )
185
185
186
186
set (LIBCLC_TARGET_TO_TEST )
187
187
@@ -329,19 +329,40 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
329
329
" configuration, some SYCL programs may fail to build." )
330
330
endif ()
331
331
332
- set ( lib_files )
333
- set ( lib_gen_files )
334
- libclc_configure_lib_source (lib_files lib_gen_files
335
- LIB_DIR lib
332
+ set ( opencl_lib_files )
333
+ set ( opencl_gen_files )
334
+
335
+ if ( NOT ARCH STREQUAL spirv AND NOT ARCH STREQUAL spirv64 )
336
+ if ( ARCH STREQUAL clspv OR ARCH STREQUAL clspv64 )
337
+ list ( APPEND opencl_gen_files clspv-convert.cl )
338
+ elseif ( NOT ENABLE_RUNTIME_SUBNORMAL )
339
+ list ( APPEND opencl_gen_files convert-clc.cl )
340
+ list ( APPEND opencl_lib_files generic/libspirv/subnormal_use_default.ll )
341
+ endif ()
342
+ endif ()
343
+
344
+ libclc_configure_lib_source (
345
+ opencl_lib_files
336
346
DIRS ${dirs} ${DARCH} ${DARCH} -${OS} ${DARCH} -${VENDOR}-${OS}
337
- DEPS convert-clc.cl )
347
+ )
338
348
339
- set ( libspirv_files )
349
+ set ( libspirv_lib_files )
340
350
set ( libspirv_gen_files )
341
- libclc_configure_lib_source (libspirv_files libspirv_gen_files
351
+
352
+ if ( NOT ARCH STREQUAL spirv AND NOT ARCH STREQUAL spirv64 )
353
+ if ( ARCH STREQUAL clspv OR ARCH STREQUAL clspv64 )
354
+ list ( APPEND libspirv_gen_files clspv-convert.cl )
355
+ elseif ( NOT ENABLE_RUNTIME_SUBNORMAL )
356
+ list ( APPEND libspirv_gen_files convert-spirv.cl convert-core.cl )
357
+ list ( APPEND libspirv_lib_files generic/libspirv/subnormal_use_default.ll )
358
+ endif ()
359
+ endif ()
360
+
361
+ libclc_configure_lib_source (
362
+ libspirv_lib_files
342
363
LIB_DIR libspirv
343
364
DIRS ${dirs} ${DARCH} ${DARCH} -${OS} ${DARCH} -${VENDOR}-${OS}
344
- DEPS convert-spirv.cl convert-core.cl )
365
+ )
345
366
346
367
foreach ( d ${${t}_devices} )
347
368
get_libclc_device_info (
@@ -353,29 +374,25 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
353
374
)
354
375
355
376
# Some targets don't have a specific GPU to target
356
- set ( flags )
377
+ set ( build_flags )
357
378
if ( d STREQUAL none OR ARCH STREQUAL spirv OR ARCH STREQUAL spirv64 )
358
379
# FIXME: Ideally we would not be tied to a specific PTX ISA version
359
380
if ( ARCH STREQUAL nvptx OR ARCH STREQUAL nvptx64 )
360
381
# Disables NVVM reflection to defer to after linking
361
- list ( APPEND flags -Xclang -target-feature -Xclang +ptx72
382
+ list ( APPEND build_flags -Xclang -target-feature -Xclang +ptx72
362
383
-march=sm_86 -mllvm --nvvm-reflect-enable=false )
363
384
elseif ( ARCH STREQUAL amdgcn )
364
385
# AMDGCN needs libclc to be compiled to high bc version since all atomic
365
386
# clang builtins need to be accessible
366
- list ( APPEND flags -mcpu=gfx940 -mllvm --amdgpu-oclc-reflect-enable=false )
387
+ list ( APPEND build_flags -mcpu=gfx940 -mllvm --amdgpu-oclc-reflect-enable=false )
367
388
elseif ( IS_NATIVE_CPU_ARCH )
368
- list ( APPEND flags -Xclang -fsycl-is-native-cpu )
389
+ list ( APPEND build_flags -Xclang -fsycl-is-native-cpu )
369
390
if ( ARCH STREQUAL x86_64 )
370
- list ( APPEND flags ${LIBCLC_NATIVECPU_FLAGS_X86_64} )
391
+ list ( APPEND build_flags ${LIBCLC_NATIVECPU_FLAGS_X86_64} )
371
392
endif ()
372
393
endif ()
373
394
endif ()
374
395
375
- if ( NOT "${cpu} " STREQUAL "" )
376
- list ( APPEND flags -mcpu=${cpu} )
377
- endif ()
378
-
379
396
message ( STATUS " device: ${d} ( ${${d} _aliases} )" )
380
397
381
398
# Note: when declaring builtins, we must consider that even if a target
@@ -410,7 +427,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
410
427
411
428
# Enable SPIR-V builtin function declarations, so they don't
412
429
# have to be explicity declared in the soruce.
413
- list ( APPEND flags -Xclang -fdeclare-spirv-builtins )
430
+ list ( APPEND build_flags -Xclang -fdeclare-spirv-builtins )
414
431
set ( LIBCLC_ARCH_OBJFILE_DIR "${LIBCLC_OBJFILE_DIR} /${arch_suffix} " )
415
432
file ( MAKE_DIRECTORY ${LIBCLC_ARCH_OBJFILE_DIR} )
416
433
@@ -428,7 +445,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
428
445
if ( supports_generic_addrspace )
429
446
string ( APPEND CL_3_0_EXTENSIONS ",+__opencl_c_generic_address_space" )
430
447
if ( has_distinct_generic_addrspace )
431
- list ( APPEND flags -D__CLC_DISTINCT_GENERIC_ADDRSPACE__ )
448
+ list ( APPEND build_flags -D__CLC_DISTINCT_GENERIC_ADDRSPACE__ )
432
449
endif ()
433
450
else ()
434
451
# Explictly disable opencl_c_generic_address_space (it may be enabled
@@ -438,42 +455,60 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
438
455
string ( APPEND CL_3_0_EXTENSIONS ",-__opencl_c_pipes" )
439
456
string ( APPEND CL_3_0_EXTENSIONS ",-__opencl_c_device_enqueue" )
440
457
endif ()
441
- list ( APPEND flags -cl-std=CL3.0 "-Xclang" ${CL_3_0_EXTENSIONS} )
458
+ list ( APPEND build_flags -cl-std=CL3.0 "-Xclang" ${CL_3_0_EXTENSIONS} )
442
459
443
460
# Add platform specific flags
444
461
if (WIN32 )
445
- list (APPEND flags -D_WIN32 )
462
+ list (APPEND build_flags -D_WIN32 )
446
463
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
447
- list (APPEND flags -D__APPLE__ )
464
+ list (APPEND build_flags -D__APPLE__ )
448
465
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux" )
449
- list (APPEND flags -D__unix__ -D__linux__ )
466
+ list (APPEND build_flags -D__unix__ -D__linux__ )
450
467
else ()
451
468
# Assume some UNIX system otherwise
452
- list (APPEND flags -D__unix__ )
469
+ list (APPEND build_flags -D__unix__ )
453
470
endif ()
454
471
455
- add_libclc_builtin_set (libspirv-${arch_suffix}
472
+ string ( TOUPPER "CLC_${ARCH} " CLC_TARGET_DEFINE )
473
+
474
+ list ( APPEND build_flags
475
+ -D__CLC_INTERNAL
476
+ -D${CLC_TARGET_DEFINE}
477
+ -I${CMAKE_CURRENT_SOURCE_DIR}/generic/include
478
+ # FIXME: Fix libclc to not require disabling this noisy warning
479
+ -Wno-bitwise-conditional-parentheses
480
+ )
481
+
482
+ if ( NOT "${cpu} " STREQUAL "" )
483
+ list ( APPEND build_flags -mcpu=${cpu} )
484
+ endif ()
485
+
486
+ add_libclc_builtin_set (
487
+ ARCH ${ARCH}
488
+ ARCH_SUFFIX libspirv-${arch_suffix}
456
489
TRIPLE ${clang_triple}
457
- TARGET_ENV libspirv
458
- COMPILE_OPT ${flags }
490
+ TARGET_ENV libspirv-
491
+ COMPILE_FLAGS ${build_flags }
459
492
OPT_FLAGS ${opt_flags}
460
- FILES ${libspirv_files }
493
+ LIB_FILES ${libspirv_lib_files }
461
494
GEN_FILES ${libspirv_gen_files}
462
495
ALIASES ${${d}_aliases}
463
496
GENERATE_TARGET "generate_convert_spirv.cl" "generate_convert_core.cl"
464
- PARENT_TARGET libspirv-builtins )
497
+ PARENT_TARGET libspirv-builtins
498
+ )
465
499
466
- add_libclc_builtin_set (clc-${arch_suffix}
500
+ add_libclc_builtin_set (
501
+ ARCH ${ARCH}
502
+ ARCH_SUFFIX ${arch_suffix}
467
503
TRIPLE ${clang_triple}
468
- TARGET_ENV clc
469
- COMPILE_OPT ${flags}
504
+ COMPILE_FLAGS ${build_flags}
470
505
OPT_FLAGS ${opt_flags}
471
- FILES ${lib_files}
472
- GEN_FILES ${lib_gen_files}
473
- LIB_DEP libspirv-${arch_suffix}
506
+ LIB_FILES ${opencl_lib_files}
507
+ GEN_FILES ${opencl_gen_files}
474
508
ALIASES ${${d}_aliases}
475
509
GENERATE_TARGET "generate_convert_clc.cl"
476
- PARENT_TARGET libclc-builtins )
510
+ PARENT_TARGET libopencl-builtins
511
+ )
477
512
endforeach ( d )
478
513
endforeach ( t )
479
514
0 commit comments