Skip to content

Commit 29a03a7

Browse files
committed
[Comgr] Update test CMake to support generating bitcodes
Previously, the test CMakeLists only supported generating bitcode bundles and archives. In this patch, we add support for generating non-bundled bitcode. These can be used in future tests that start with LLVM IR bitcode as inputs. Change-Id: I51c42460e5e1f3d5d472a864353764cbb784d5e8
1 parent 31377a7 commit 29a03a7

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

amd/comgr/test/CMakeLists.txt

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
set(TEST_INPUT_BINARIES)
22
set(TEST_INPUT_BITCODES)
3+
set(TEST_INPUT_BUNDLES)
4+
set(TEST_INPUT_ARCHIVES)
35
# Create target ${name} which depends on a clang command to compile ${input} to
46
# ${output}, with any additional arguments from ${ARGN}, and add it to the
57
# TEST_INPUT_BINARIES target list.
@@ -39,8 +41,9 @@ endmacro()
3941
macro(add_test_input_bitcode name input output)
4042
add_custom_command(
4143
OUTPUT "${output}"
42-
COMMAND "$<TARGET_FILE:clang>" -c --offload-arch=gfx906 -emit-llvm -fgpu-rdc
43-
--gpu-bundle-output ${ARGN} "${CMAKE_CURRENT_SOURCE_DIR}/${input}"
44+
COMMAND "$<TARGET_FILE:clang>" -c -emit-llvm -target amdgcn-amd-amdhsa
45+
-mcpu=gfx900
46+
${ARGN} "${CMAKE_CURRENT_SOURCE_DIR}/${input}"
4447
-o "${output}"
4548
VERBATIM
4649
DEPENDS clang lld "${input}")
@@ -50,6 +53,23 @@ macro(add_test_input_bitcode name input output)
5053
list(APPEND TEST_INPUT_BITCODES "${name}")
5154
endmacro()
5255

56+
# Creates target ${name} which depends on a clang command to compile ${input} to
57+
# ${output}, with any additional arguments from ${ARGN}, and add it to the
58+
# TEST_INPUT_BUNDLES target list.
59+
macro(add_test_input_bundle name input output)
60+
add_custom_command(
61+
OUTPUT "${output}"
62+
COMMAND "$<TARGET_FILE:clang>" -c --offload-arch=gfx900 -emit-llvm -fgpu-rdc
63+
--gpu-bundle-output ${ARGN} "${CMAKE_CURRENT_SOURCE_DIR}/${input}"
64+
-o "${output}"
65+
VERBATIM
66+
DEPENDS clang lld "${input}")
67+
add_custom_target("${name}"
68+
DEPENDS "${output}"
69+
SOURCES "${input}")
70+
list(APPEND TEST_INPUT_BUNDLES "${name}")
71+
endmacro()
72+
5373
# Creates target ${name} and output ${output} by archiving a file.
5474
# ${target} should refer to the a target created in the above
5575
# add_test_input_bitcode() macro, and ${input} should refer
@@ -63,7 +83,7 @@ macro(add_test_archive name target input output)
6383
add_custom_target("${name}"
6484
DEPENDS "${output}"
6585
SOURCES "${input}")
66-
list(APPEND TEST_INPUT_BITCODES "${name}")
86+
list(APPEND TEST_INPUT_ARCHIVES "${name}")
6787
endmacro()
6888

6989
add_test_input_binary(reloc1 source/reloc1.cl source/reloc1.o -c -mcode-object-version=4)
@@ -134,7 +154,8 @@ endif()
134154
target_link_libraries("${name}"
135155
amd_comgr)
136156
add_dependencies("${name}"
137-
${TEST_INPUT_BINARIES};${TEST_INPUT_BITCODES})
157+
${TEST_INPUT_BINARIES};${TEST_INPUT_BITCODES};${TEST_INPUT_BUNDLES};
158+
${TEST_INPUT_ARCHIVES})
138159
add_test(NAME ${test_name}
139160
COMMAND "${name}")
140161
add_dependencies(check-comgr ${name})
@@ -183,9 +204,9 @@ add_comgr_test(map_elf_virtual_address_test c)
183204

184205
# Test : Compile HIP tests only if HIP-Clang is installed.
185206
if (DEFINED HIP_COMPILER AND "${HIP_COMPILER}" STREQUAL "clang")
186-
add_test_input_bitcode(cube source/cube.hip source/cube.bc)
187-
add_test_input_bitcode(square source/square.hip source/square.bc)
188-
add_test_input_bitcode(double source/double.hip source/double.bc)
207+
add_test_input_bundle(cube source/cube.hip source/cube.bc)
208+
add_test_input_bundle(square source/square.hip source/square.bc)
209+
add_test_input_bundle(double source/double.hip source/double.bc)
189210

190211
add_test_archive(cube_archive cube source/cube.bc source/cube.a)
191212

0 commit comments

Comments
 (0)