@@ -101,7 +101,7 @@ endfunction()
101
101
function (link_bc )
102
102
cmake_parse_arguments (ARG
103
103
"INTERNALIZE"
104
- "TARGET;RSP_DIR "
104
+ "TARGET"
105
105
"INPUTS;DEPENDENCIES"
106
106
${ARGN}
107
107
)
@@ -110,7 +110,7 @@ function(link_bc)
110
110
if ( WIN32 OR CYGWIN )
111
111
# Create a response file in case the number of inputs exceeds command-line
112
112
# character limits on certain platforms.
113
- file ( TO_CMAKE_PATH ${ARG_RSP_DIR } /${ARG_TARGET}.rsp RSP_FILE )
113
+ file ( TO_CMAKE_PATH ${LIBCLC_ARCH_OBJFILE_DIR } /${ARG_TARGET}.rsp RSP_FILE )
114
114
# Turn it into a space-separate list of input files
115
115
list ( JOIN ARG_INPUTS " " RSP_INPUT )
116
116
file ( GENERATE OUTPUT ${RSP_FILE} CONTENT ${RSP_INPUT} )
@@ -205,78 +205,6 @@ function(get_libclc_device_info)
205
205
endif ()
206
206
endfunction ()
207
207
208
- function (add_libclc_alias alias target )
209
- cmake_parse_arguments (ARG "" "" PARENT_TARGET "" ${ARGN} )
210
-
211
- if (CMAKE_HOST_UNIX AND NOT CMAKE_SYSTEM_NAME STREQUAL Windows )
212
- set (LIBCLC_LINK_OR_COPY create_symlink )
213
- else ()
214
- set (LIBCLC_LINK_OR_COPY copy )
215
- endif ()
216
-
217
- add_custom_command (
218
- OUTPUT ${LIBCLC_LIBRARY_OUTPUT_INTDIR} /${alias_suffix}
219
- COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBCLC_LIBRARY_OUTPUT_INTDIR}
220
- COMMAND ${CMAKE_COMMAND} -E
221
- ${LIBCLC_LINK_OR_COPY} ${target} .bc
222
- ${alias_suffix}
223
- WORKING_DIRECTORY
224
- ${LIBCLC_LIBRARY_OUTPUT_INTDIR}
225
- DEPENDS "prepare-${target} "
226
- )
227
- add_custom_target ( alias-${alias_suffix} ALL
228
- DEPENDS "${LIBCLC_LIBRARY_OUTPUT_INTDIR} /${alias_suffix} " )
229
- add_dependencies (${ARG_PARENT_TARGET} alias-${alias_suffix} )
230
-
231
- install ( FILES ${LIBCLC_LIBRARY_OUTPUT_INTDIR} /${alias_suffix}
232
- DESTINATION ${CMAKE_INSTALL_DATADIR} /clc )
233
-
234
- endfunction (add_libclc_alias alias target )
235
-
236
- # Runs opt and prepare-builtins on a bitcode file specified by lib_tgt
237
- #
238
- # ARGUMENTS:
239
- # * LIB_TGT string
240
- # Target name that becomes dependent on the out file named LIB_TGT.bc
241
- # * IN_FILE string
242
- # Target name of the input bytecode file
243
- # * OUT_DIR string
244
- # Name of the directory where the output should be placed
245
- # * DEPENDENCIES <string> ...
246
- # List of extra dependencies to inject
247
- function (process_bc out_file )
248
- cmake_parse_arguments (ARG
249
- ""
250
- "LIB_TGT;IN_FILE;OUT_DIR"
251
- "OPT_FLAGS;DEPENDENCIES"
252
- ${ARGN} )
253
- add_custom_command ( OUTPUT ${ARG_LIB_TGT} .bc
254
- COMMAND ${opt_exe} ${ARG_OPT_FLAGS} -o ${ARG_LIB_TGT} .bc
255
- ${ARG_IN_FILE}
256
- DEPENDS ${opt_target} ${ARG_IN_FILE} ${ARG_DEPENDENCIES}
257
- )
258
- add_custom_target ( ${ARG_LIB_TGT}
259
- ALL DEPENDS ${ARG_LIB_TGT} .bc
260
- )
261
- set_target_properties ( ${ARG_LIB_TGT}
262
- PROPERTIES TARGET_FILE ${ARG_LIB_TGT} .bc
263
- )
264
-
265
- set ( builtins_opt_lib $< TARGET_PROPERTY:${ARG_LIB_TGT} ,TARGET_FILE> )
266
-
267
- # Add prepare target
268
- add_custom_command ( OUTPUT ${ARG_OUT_DIR} /${out_file}
269
- COMMAND ${prepare_builtins_exe} -o ${ARG_OUT_DIR} /${out_file}
270
- ${builtins_opt_lib}
271
- DEPENDS ${builtins_opt_lib} ${ARG_LIB_TGT} ${prepare_builtins_target} )
272
- add_custom_target ( prepare-${out_file} ALL
273
- DEPENDS ${ARG_OUT_DIR} /${out_file}
274
- )
275
- set_target_properties ( prepare-${out_file}
276
- PROPERTIES TARGET_FILE ${ARG_OUT_DIR} /${out_file}
277
- )
278
- endfunction ()
279
-
280
208
# Compiles a list of library source files (provided by LIB_FILES/GEN_FILES) and
281
209
# compiles them to LLVM bytecode (or SPIR-V), links them together and optimizes
282
210
# them.
@@ -411,7 +339,6 @@ function(add_libclc_builtin_set)
411
339
link_bc (
412
340
TARGET ${builtins_link_lib_tgt}
413
341
INPUTS ${bytecode_files}
414
- RSP_DIR ${LIBCLC_ARCH_OBJFILE_DIR}
415
342
DEPENDENCIES ${builtins_comp_lib_tgt}
416
343
)
417
344
else ()
@@ -422,7 +349,6 @@ function(add_libclc_builtin_set)
422
349
link_bc (
423
350
TARGET ${builtins_link_lib_tmp_tgt}
424
351
INPUTS ${bytecode_files}
425
- RSP_DIR ${LIBCLC_ARCH_OBJFILE_DIR}
426
352
DEPENDENCIES ${builtins_comp_lib_tgt}
427
353
)
428
354
set ( internal_link_depend_files )
@@ -434,7 +360,6 @@ function(add_libclc_builtin_set)
434
360
TARGET ${builtins_link_lib_tgt}
435
361
INPUTS $< TARGET_PROPERTY:${builtins_link_lib_tmp_tgt} ,TARGET_FILE>
436
362
${internal_link_depend_files}
437
- RSP_DIR ${LIBCLC_ARCH_OBJFILE_DIR}
438
363
DEPENDENCIES ${builtins_link_lib_tmp_tgt} ${ARG_INTERNAL_LINK_DEPENDENCIES}
439
364
)
440
365
endif ()
@@ -447,9 +372,15 @@ function(add_libclc_builtin_set)
447
372
448
373
set ( builtins_link_lib $< TARGET_PROPERTY:${builtins_link_lib_tgt} ,TARGET_FILE> )
449
374
375
+ add_custom_command ( OUTPUT ${LIBCLC_OUTPUT_LIBRARY_DIR}
376
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBCLC_OUTPUT_LIBRARY_DIR}
377
+ DEPENDS ${builtins_link_lib} prepare_builtins )
378
+
379
+ # For SPIR-V targets we diverage at this point and generate SPIR-V using the
380
+ # llvm-spirv tool.
450
381
if ( ARG_ARCH STREQUAL spirv OR ARG_ARCH STREQUAL spirv64 )
451
382
set ( obj_suffix ${ARG_ARCH_SUFFIX} .spv )
452
- set ( libclc_builtins_lib ${LIBCLC_LIBRARY_OUTPUT_INTDIR } /${obj_suffix} )
383
+ set ( libclc_builtins_lib ${LIBCLC_OUTPUT_LIBRARY_DIR } /${obj_suffix} )
453
384
add_custom_command ( OUTPUT ${libclc_builtins_lib}
454
385
COMMAND ${llvm-spirv_exe} ${spvflags} -o ${libclc_builtins_lib} ${builtins_link_lib}
455
386
DEPENDS ${llvm-spirv_target} ${builtins_link_lib} ${builtins_link_lib_tgt}
@@ -474,7 +405,7 @@ function(add_libclc_builtin_set)
474
405
set ( builtins_opt_lib $< TARGET_PROPERTY:${builtins_opt_lib_tgt} ,TARGET_FILE> )
475
406
476
407
set ( obj_suffix ${ARG_ARCH_SUFFIX} .bc )
477
- set ( libclc_builtins_lib ${LIBCLC_LIBRARY_OUTPUT_INTDIR } /${obj_suffix} )
408
+ set ( libclc_builtins_lib ${LIBCLC_OUTPUT_LIBRARY_DIR } /${obj_suffix} )
478
409
add_custom_command ( OUTPUT ${libclc_builtins_lib}
479
410
COMMAND ${prepare_builtins_exe} -o ${libclc_builtins_lib} ${builtins_opt_lib}
480
411
DEPENDS ${builtins_opt_lib} ${builtins_opt_lib_tgt} ${prepare_builtins_target}
@@ -489,11 +420,6 @@ function(add_libclc_builtin_set)
489
420
# targets dependent on libclc.
490
421
add_dependencies (${ARG_PARENT_TARGET} prepare-${obj_suffix} )
491
422
492
- # SPIR-V targets can exit early here
493
- if ( ARG_ARCH STREQUAL spirv OR ARG_ARCH STREQUAL spirv64 )
494
- return ()
495
- endif ()
496
-
497
423
# Also add a 'prepare' target for the triple. Since a triple may have
498
424
# multiple devices, ensure we only try to create the triple target once. The
499
425
# triple's target will build all of the bytecode for its constituent devices.
@@ -512,49 +438,11 @@ function(add_libclc_builtin_set)
512
438
return ()
513
439
endif ()
514
440
515
- # Add a test for whether or not the libraries contain unresolved calls which
516
- # would usually indicate a build problem. Note that we don't perform this
517
- # test for all libclc targets:
518
- # * nvptx-- targets don't include workitem builtins
519
- # * clspv targets don't include all OpenCL builtins
520
- if ( NOT ARG_ARCH MATCHES "^(nvptx|clspv)(64)?$" )
521
- add_test ( NAME external-calls-${obj_suffix}
522
- COMMAND ./check_external_calls.sh ${libclc_builtins_lib} ${LLVM_TOOLS_BINARY_DIR}
523
- WORKING_DIRECTORY ${LIBCLC_LIBRARY_OUTPUT_INTDIR} )
524
- set_tests_properties ( external-calls-${obj_suffix}
525
- PROPERTIES ENVIRONMENT "LLVM_CONFIG=${LLVM_CONFIG} " )
526
- endif ()
527
-
528
- if (CMAKE_HOST_UNIX OR LLVM_USE_SYMLINKS )
529
- set (LIBCLC_LINK_OR_COPY create_symlink )
530
- else ()
531
- set (LIBCLC_LINK_OR_COPY copy )
532
- endif ()
533
-
534
- foreach ( a IN LISTS ARG_ALIASES )
535
- set ( alias_suffix "${a} -${ARG_TRIPLE} .bc" )
536
- add_custom_command (
537
- OUTPUT ${LIBCLC_OUTPUT_LIBRARY_DIR} /${alias_suffix}
538
- COMMAND ${CMAKE_COMMAND} -E ${LIBCLC_LINK_OR_COPY} ${libclc_builtins_lib} ${LIBCLC_OUTPUT_LIBRARY_DIR} /${alias_suffix}
539
- DEPENDS prepare-${obj_suffix}
540
- )
541
- add_custom_target ( alias-${alias_suffix} ALL
542
- DEPENDS ${LIBCLC_OUTPUT_LIBRARY_DIR} /${alias_suffix}
543
- )
544
- set_target_properties ( alias-${alias_suffix}
545
- PROPERTIES FOLDER "libclc/Device IR/Aliases"
546
- )
547
- install (
548
- FILES ${LIBCLC_OUTPUT_LIBRARY_DIR} /${alias_suffix}
549
- DESTINATION "${CMAKE_INSTALL_DATADIR} /clc"
550
- )
551
- endforeach ( a )
552
-
553
441
# Generate remangled variants if requested
554
442
if ( ARG_REMANGLE )
555
- set ( dummy_in ${LIBCLC_LIBRARY_OUTPUT_INTDIR } /libclc_dummy_in.cc )
443
+ set ( dummy_in ${LIBCLC_OUTPUT_LIBRARY_DIR } /libclc_dummy_in.cc )
556
444
add_custom_command ( OUTPUT ${dummy_in}
557
- COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBCLC_LIBRARY_OUTPUT_INTDIR }
445
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBCLC_OUTPUT_LIBRARY_DIR }
558
446
COMMAND ${CMAKE_COMMAND} -E touch ${dummy_in}
559
447
)
560
448
set (long_widths l32 l64 )
@@ -571,9 +459,9 @@ function(add_libclc_builtin_set)
571
459
foreach (signedness ${char_signedness} )
572
460
# Remangle
573
461
set ( builtins_remangle_path
574
- "${LIBCLC_LIBRARY_OUTPUT_INTDIR } /remangled-${long_width} -${signedness} _char.${obj_suffix_mangled} " )
462
+ "${LIBCLC_OUTPUT_LIBRARY_DIR } /remangled-${long_width} -${signedness} _char.${obj_suffix_mangled} " )
575
463
add_custom_command ( OUTPUT "${builtins_remangle_path} "
576
- COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBCLC_LIBRARY_OUTPUT_INTDIR }
464
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBCLC_OUTPUT_LIBRARY_DIR }
577
465
COMMAND ${libclc-remangler_exe}
578
466
-o "${builtins_remangle_path} "
579
467
--triple=${ARG_TRIPLE}
@@ -618,6 +506,36 @@ function(add_libclc_builtin_set)
618
506
endforeach ()
619
507
endif ()
620
508
509
+ # Add a test for whether or not the libraries contain unresolved calls which
510
+ # would usually indicate a build problem. Note that we don't perform this
511
+ # test for all libclc targets:
512
+ # * nvptx-- targets don't include workitem builtins
513
+ # * clspv targets don't include all OpenCL builtins
514
+ if ( NOT ARG_ARCH MATCHES "^(nvptx|clspv)(64)?$" )
515
+ add_test ( NAME external-calls-${obj_suffix}
516
+ COMMAND ./check_external_calls.sh ${libclc_builtins_lib} ${LLVM_TOOLS_BINARY_DIR}
517
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
518
+ endif ()
519
+
520
+ foreach ( a ${ARG_ALIASES} )
521
+ set ( alias_suffix "${a} -${ARG_TRIPLE} .bc" )
522
+ add_custom_command (
523
+ OUTPUT ${LIBCLC_OUTPUT_LIBRARY_DIR} /${alias_suffix}
524
+ COMMAND ${CMAKE_COMMAND} -E create_symlink ${libclc_builtins_lib} ${LIBCLC_OUTPUT_LIBRARY_DIR} /${alias_suffix}
525
+ DEPENDS prepare-${obj_suffix}
526
+ )
527
+ add_custom_target ( alias-${alias_suffix} ALL
528
+ DEPENDS ${LIBCLC_OUTPUT_LIBRARY_DIR} /${alias_suffix}
529
+ )
530
+ set_target_properties ( alias-${alias_suffix}
531
+ PROPERTIES FOLDER "libclc/Device IR/Aliases"
532
+ )
533
+ add_dependencies (${ARG_PARENT_TARGET} alias-${alias_suffix} )
534
+ install (
535
+ FILES ${LIBCLC_OUTPUT_LIBRARY_DIR} /${alias_suffix}
536
+ DESTINATION "${CMAKE_INSTALL_DATADIR} /clc"
537
+ )
538
+ endforeach ( a )
621
539
endfunction (add_libclc_builtin_set )
622
540
623
541
# Produces a list of libclc source files by walking over SOURCES files in a
0 commit comments