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