Skip to content

Commit a41ce10

Browse files
committed
fix tests relying on spirv-as
Signed-off-by: Nathan Gauër <[email protected]>
1 parent de6b4df commit a41ce10

File tree

5 files changed

+29
-5
lines changed

5 files changed

+29
-5
lines changed

llvm/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ endif()
230230
if (LLVM_INCLUDE_SPIRV_TOOLS_TESTS)
231231
list(APPEND LLVM_TEST_DEPENDS spirv-dis)
232232
list(APPEND LLVM_TEST_DEPENDS spirv-val)
233+
list(APPEND LLVM_TEST_DEPENDS spirv-as)
233234
endif()
234235

235236
add_custom_target(llvm-test-depends DEPENDS ${LLVM_TEST_DEPENDS})

llvm/test/CodeGen/SPIRV/lit.local.cfg

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
if not "SPIRV" in config.root.targets:
22
config.unsupported = True
33

4+
config.suffixes = [".ll", ".hlsl"]
5+
6+
spirv_sim_root = os.path.join(config.llvm_src_root, "utils", "spirv-sim")
7+
48
if config.spirv_tools_tests:
59
config.available_features.add("spirv-tools")
610
config.substitutions.append(("spirv-dis", os.path.join(config.llvm_tools_dir, "spirv-dis")))
711
config.substitutions.append(("spirv-val", os.path.join(config.llvm_tools_dir, "spirv-val")))
12+
config.substitutions.append(("spirv-as", os.path.join(config.llvm_tools_dir, "spirv-as")))
13+
config.substitutions.append( ('%clang', 'clang'))
14+
config.substitutions.append(
15+
(
16+
"spirv-sim",
17+
"'%s' %s"
18+
% (config.python_executable, os.path.join(spirv_sim_root, "spirv-sim.py")),
19+
)
20+
)

llvm/test/CodeGen/SPIRV/structurizer/cf.switch.opswitch.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang --driver-mode=dxc -T cs_6_0 -fspv-target-env=vulkan1.3 %s -spirv | spirv-as --preserve-numeric-ids - -o - | spirv-val
1+
// RUN: %if spirv-tools %{ %clang --driver-mode=dxc -T cs_6_0 -fspv-target-env=vulkan1.3 %s -spirv | spirv-as --preserve-numeric-ids - -o - | spirv-val %}
22

33
int foo() { return 200; }
44

llvm/test/CodeGen/SPIRV/structurizer/cf.switch.opswitch.literal.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang --driver-mode=dxc -T cs_6_0 -fspv-target-env=vulkan1.3 %s -spirv | spirv-as --preserve-numeric-ids - -o - | spirv-val
1+
// RUN: %if spirv-tools %{ %clang --driver-mode=dxc -T cs_6_0 -fspv-target-env=vulkan1.3 %s -spirv | spirv-as --preserve-numeric-ids - -o - | spirv-val %}
22

33
[numthreads(1, 1, 1)]
44
void main() {

llvm/tools/spirv-tools/CMakeLists.txt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ endif ()
1212
# SPIRV_DIS and SPIRV_VAL variables can be used to provide paths to existing
1313
# spirv-dis and spirv-val binaries, respectively. Otherwise, build them from
1414
# SPIRV-Tools source.
15-
if (NOT SPIRV_DIS OR NOT SPIRV_VAL)
15+
if (NOT SPIRV_DIS OR NOT SPIRV_VAL OR NOT SPIRV_AS)
1616
include(ExternalProject)
1717

1818
set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/SPIRVTools-bin)
@@ -21,8 +21,8 @@ if (NOT SPIRV_DIS OR NOT SPIRV_VAL)
2121
GIT_REPOSITORY https://github.com/KhronosGroup/SPIRV-Tools.git
2222
GIT_TAG main
2323
BINARY_DIR ${BINARY_DIR}
24-
BUILD_COMMAND ${CMAKE_COMMAND} --build ${BINARY_DIR} --target spirv-dis spirv-val
25-
BUILD_BYPRODUCTS ${BINARY_DIR}/tools/spirv-dis ${BINARY_DIR}/tools/spirv-val
24+
BUILD_COMMAND ${CMAKE_COMMAND} --build ${BINARY_DIR} --target spirv-dis spirv-val spirv-as
25+
BUILD_BYPRODUCTS ${BINARY_DIR}/tools/spirv-dis ${BINARY_DIR}/tools/spirv-val ${BINARY_DIR}/tools/spirv-as
2626
DOWNLOAD_COMMAND git clone https://github.com/KhronosGroup/SPIRV-Tools.git SPIRVTools &&
2727
cd SPIRVTools &&
2828
${Python3_EXECUTABLE} utils/git-sync-deps
@@ -63,3 +63,13 @@ else ()
6363
DEPENDS SPIRVTools
6464
)
6565
endif ()
66+
67+
if (SPIRV_AS)
68+
add_custom_target(spirv-as
69+
COMMAND ${CMAKE_COMMAND} -E ${LLVM_LINK_OR_COPY} "${SPIRV_VAL}" "${LLVM_RUNTIME_OUTPUT_INTDIR}/spirv-as")
70+
else ()
71+
add_custom_target(spirv-as
72+
COMMAND ${CMAKE_COMMAND} -E ${LLVM_LINK_OR_COPY} "${BINARY_DIR}/tools/spirv-as${CMAKE_EXECUTABLE_SUFFIX}" "${LLVM_RUNTIME_OUTPUT_INTDIR}/spirv-as${CMAKE_EXECUTABLE_SUFFIX}"
73+
DEPENDS SPIRVTools
74+
)
75+
endif ()

0 commit comments

Comments
 (0)