[llvm] [tools] Cleanup spirv-sim (PR #151705)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 1 07:29:16 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-spir-v
Author: Nathan Gauër (Keenuts)
<details>
<summary>Changes</summary>
spirv-sim was supposed to be used to test cross-lane interactions. This utility was in the end never used for testing, and as we move to proper end-to-end testing through the llvm/offload-test-suite project, this becomes obsolete.
Cleaning this up.
---
Patch is 55.00 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/151705.diff
14 Files Affected:
- (modified) llvm/test/CodeGen/SPIRV/lit.local.cfg (-10)
- (removed) llvm/test/Other/spirv-sim/branch.spv (-42)
- (removed) llvm/test/Other/spirv-sim/call.spv (-36)
- (removed) llvm/test/Other/spirv-sim/constant.spv (-36)
- (removed) llvm/test/Other/spirv-sim/lit.local.cfg (-8)
- (removed) llvm/test/Other/spirv-sim/loop.spv (-58)
- (removed) llvm/test/Other/spirv-sim/simple-bad-result.spv (-26)
- (removed) llvm/test/Other/spirv-sim/simple.spv (-22)
- (removed) llvm/test/Other/spirv-sim/simulator-args.spv (-36)
- (removed) llvm/test/Other/spirv-sim/switch.spv (-42)
- (removed) llvm/test/Other/spirv-sim/wave-get-lane-index.spv (-30)
- (removed) llvm/test/Other/spirv-sim/wave-read-lane-first.spv (-83)
- (removed) llvm/utils/spirv-sim/instructions.py (-381)
- (removed) llvm/utils/spirv-sim/spirv-sim.py (-658)
``````````diff
diff --git a/llvm/test/CodeGen/SPIRV/lit.local.cfg b/llvm/test/CodeGen/SPIRV/lit.local.cfg
index f139d13268af2..51795425cc887 100644
--- a/llvm/test/CodeGen/SPIRV/lit.local.cfg
+++ b/llvm/test/CodeGen/SPIRV/lit.local.cfg
@@ -1,16 +1,6 @@
if not "SPIRV" in config.root.targets:
config.unsupported = True
-spirv_sim_root = os.path.join(config.llvm_src_root, "utils", "spirv-sim")
-
-config.substitutions.append(
- (
- "spirv-sim",
- "'%s' %s" % (config.python_executable,
- os.path.join(spirv_sim_root, "spirv-sim.py")),
- )
-)
-
if config.spirv_tools_tests:
config.available_features.add("spirv-tools")
config.substitutions.append(("spirv-dis", os.path.join(config.llvm_tools_dir, "spirv-dis")))
diff --git a/llvm/test/Other/spirv-sim/branch.spv b/llvm/test/Other/spirv-sim/branch.spv
deleted file mode 100644
index 7ee0ebcad249d..0000000000000
--- a/llvm/test/Other/spirv-sim/branch.spv
+++ /dev/null
@@ -1,42 +0,0 @@
-; RUN: %if spirv-tools %{ spirv-as %s -o - | spirv-val - %}
-; RUN: spirv-sim --function=simple --wave=3 --expects=5,6,6 -i %s
- OpCapability Shader
- OpCapability GroupNonUniform
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %main "main" %WaveIndex
- OpExecutionMode %main LocalSize 1 1 1
- OpSource HLSL 670
- OpName %simple "simple"
- OpName %main "main"
- OpDecorate %WaveIndex BuiltIn SubgroupLocalInvocationId
- %int = OpTypeInt 32 1
- %uint = OpTypeInt 32 0
- %bool = OpTypeBool
- %int_2 = OpConstant %int 2
- %int_5 = OpConstant %int 5
- %int_6 = OpConstant %int 6
- %uint_0 = OpConstant %uint 0
- %void = OpTypeVoid
- %main_type = OpTypeFunction %void
-%simple_type = OpTypeFunction %int
- %uint_iptr = OpTypePointer Input %uint
- %WaveIndex = OpVariable %uint_iptr Input
- %main = OpFunction %void None %main_type
- %entry = OpLabel
- OpReturn
- OpFunctionEnd
- %simple = OpFunction %int None %simple_type
- %1 = OpLabel
- %2 = OpLoad %uint %WaveIndex
- %3 = OpIEqual %bool %uint_0 %2
- OpSelectionMerge %merge None
- OpBranchConditional %3 %true %false
- %true = OpLabel
- OpBranch %merge
- %false = OpLabel
- OpBranch %merge
- %merge = OpLabel
- %4 = OpPhi %int %int_5 %true %int_6 %false
- OpReturnValue %4
- OpFunctionEnd
-
diff --git a/llvm/test/Other/spirv-sim/call.spv b/llvm/test/Other/spirv-sim/call.spv
deleted file mode 100644
index 320b048f95296..0000000000000
--- a/llvm/test/Other/spirv-sim/call.spv
+++ /dev/null
@@ -1,36 +0,0 @@
-; RUN: %if spirv-tools %{ spirv-as %s -o - | spirv-val - %}
-; RUN: spirv-sim --function=simple --wave=1 --expects=2 -i %s
- OpCapability Shader
- OpCapability GroupNonUniform
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %main "main" %WaveIndex
- OpExecutionMode %main LocalSize 1 1 1
- OpSource HLSL 670
- OpName %simple "simple"
- OpName %main "main"
- OpDecorate %WaveIndex BuiltIn SubgroupLocalInvocationId
- %int = OpTypeInt 32 1
- %uint = OpTypeInt 32 0
- %uint_2 = OpConstant %uint 2
- %void = OpTypeVoid
- %main_type = OpTypeFunction %void
-%simple_type = OpTypeFunction %int
- %sub_type = OpTypeFunction %uint
- %uint_iptr = OpTypePointer Input %uint
- %WaveIndex = OpVariable %uint_iptr Input
- %main = OpFunction %void None %main_type
- %entry = OpLabel
- OpReturn
- OpFunctionEnd
- %sub = OpFunction %uint None %sub_type
- %a = OpLabel
- OpReturnValue %uint_2
- OpFunctionEnd
- %simple = OpFunction %int None %simple_type
- %1 = OpLabel
- %2 = OpFunctionCall %uint %sub
- %3 = OpBitcast %int %2
- OpReturnValue %3
- OpFunctionEnd
-
-
diff --git a/llvm/test/Other/spirv-sim/constant.spv b/llvm/test/Other/spirv-sim/constant.spv
deleted file mode 100644
index 1002427943a8d..0000000000000
--- a/llvm/test/Other/spirv-sim/constant.spv
+++ /dev/null
@@ -1,36 +0,0 @@
-; RUN: %if spirv-tools %{ spirv-as %s -o - | spirv-val - %}
-; RUN: spirv-sim --function=a --wave=1 --expects=2 -i %s
-; RUN: spirv-sim --function=b --wave=1 --expects=1 -i %s
- OpCapability Shader
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %main "main"
- OpExecutionMode %main LocalSize 1 1 1
- OpSource HLSL 670
- OpName %a "a"
- OpName %b "b"
- OpName %main "main"
- %int = OpTypeInt 32 1
- %s1 = OpTypeStruct %int %int %int
- %s2 = OpTypeStruct %s1
- %int_1 = OpConstant %int 1
- %int_2 = OpConstant %int 2
- %s1_1_2 = OpConstantComposite %s1 %int_1 %int_2 %int_1
- %s2_s1 = OpConstantComposite %s2 %s1_1_2
- %void = OpTypeVoid
- %main_type = OpTypeFunction %void
- %simple_type = OpTypeFunction %int
- %main = OpFunction %void None %main_type
- %entry = OpLabel
- OpReturn
- OpFunctionEnd
- %a = OpFunction %int None %simple_type
- %1 = OpLabel
- %2 = OpCompositeExtract %int %s1_1_2 1
- OpReturnValue %2
- OpFunctionEnd
- %b = OpFunction %int None %simple_type
- %3 = OpLabel
- %4 = OpCompositeExtract %int %s2_s1 0 2
- OpReturnValue %4
- OpFunctionEnd
-
diff --git a/llvm/test/Other/spirv-sim/lit.local.cfg b/llvm/test/Other/spirv-sim/lit.local.cfg
deleted file mode 100644
index 67a8d9196f588..0000000000000
--- a/llvm/test/Other/spirv-sim/lit.local.cfg
+++ /dev/null
@@ -1,8 +0,0 @@
-spirv_sim_root = os.path.join(config.llvm_src_root, "utils", "spirv-sim")
-config.substitutions.append(
- (
- "spirv-sim",
- "'%s' %s"
- % (config.python_executable, os.path.join(spirv_sim_root, "spirv-sim.py")),
- )
-)
diff --git a/llvm/test/Other/spirv-sim/loop.spv b/llvm/test/Other/spirv-sim/loop.spv
deleted file mode 100644
index 4fd0f1a7c96a3..0000000000000
--- a/llvm/test/Other/spirv-sim/loop.spv
+++ /dev/null
@@ -1,58 +0,0 @@
-; RUN: %if spirv-tools %{ spirv-as %s -o - | spirv-val - %}
-; RUN: spirv-sim --function=simple --wave=4 --expects=0,2,2,4 -i %s
- OpCapability Shader
- OpCapability GroupNonUniform
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %main "main" %WaveIndex
- OpExecutionMode %main LocalSize 1 1 1
- OpSource HLSL 670
- OpName %simple "simple"
- OpName %main "main"
- OpDecorate %WaveIndex BuiltIn SubgroupLocalInvocationId
- %int = OpTypeInt 32 1
- %uint = OpTypeInt 32 0
- %bool = OpTypeBool
- %int_2 = OpConstant %int 2
- %int_5 = OpConstant %int 5
- %int_6 = OpConstant %int 6
- %uint_0 = OpConstant %uint 0
- %uint_2 = OpConstant %uint 2
- %void = OpTypeVoid
- %main_type = OpTypeFunction %void
-%simple_type = OpTypeFunction %int
- %uint_iptr = OpTypePointer Input %uint
- %uint_fptr = OpTypePointer Function %uint
- %WaveIndex = OpVariable %uint_iptr Input
- %main = OpFunction %void None %main_type
- %unused = OpLabel
- OpReturn
- OpFunctionEnd
- %simple = OpFunction %int None %simple_type
- %entry = OpLabel
-; uint i = 0;
- %i = OpVariable %uint_fptr Function
- %1 = OpLoad %uint %WaveIndex
- OpStore %i %uint_0
- OpBranch %header
- %header = OpLabel
- %2 = OpLoad %uint %i
- %3 = OpULessThan %bool %2 %1
- OpLoopMerge %merge %continue None
- OpBranchConditional %3 %body %merge
-; while (i < WaveGetLaneIndex()) {
-; i += 2;
-; }
- %body = OpLabel
- OpBranch %continue
- %continue = OpLabel
- %4 = OpIAdd %uint %2 %uint_2
- OpStore %i %4
- OpBranch %header
- %merge = OpLabel
-; return (int) i;
- %5 = OpLoad %uint %i
- %6 = OpBitcast %int %5
- OpReturnValue %6
- OpFunctionEnd
-
-
diff --git a/llvm/test/Other/spirv-sim/simple-bad-result.spv b/llvm/test/Other/spirv-sim/simple-bad-result.spv
deleted file mode 100644
index f4dd046cc078b..0000000000000
--- a/llvm/test/Other/spirv-sim/simple-bad-result.spv
+++ /dev/null
@@ -1,26 +0,0 @@
-; RUN: %if spirv-tools %{ spirv-as %s -o - | spirv-val - %}
-; RUN: not spirv-sim --function=simple --wave=1 --expects=1 -i %s 2>&1 | FileCheck %s
-
-; CHECK: Expected != Observed
-; CHECK: [1] != [2]
- OpCapability Shader
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %main "main"
- OpExecutionMode %main LocalSize 1 1 1
- OpSource HLSL 670
- OpName %simple "simple"
- OpName %main "main"
- %int = OpTypeInt 32 1
- %int_2 = OpConstant %int 2
- %void = OpTypeVoid
- %main_type = OpTypeFunction %void
- %simple_type = OpTypeFunction %int
- %main = OpFunction %void None %main_type
- %entry = OpLabel
- OpReturn
- OpFunctionEnd
- %simple = OpFunction %int None %simple_type
- %1 = OpLabel
- OpReturnValue %int_2
- OpFunctionEnd
-
diff --git a/llvm/test/Other/spirv-sim/simple.spv b/llvm/test/Other/spirv-sim/simple.spv
deleted file mode 100644
index 8c06192ea6e3d..0000000000000
--- a/llvm/test/Other/spirv-sim/simple.spv
+++ /dev/null
@@ -1,22 +0,0 @@
-; RUN: %if spirv-tools %{ spirv-as %s -o - | spirv-val - %}
-; RUN: spirv-sim --function=simple --wave=1 --expects=2 -i %s
- OpCapability Shader
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %main "main"
- OpExecutionMode %main LocalSize 1 1 1
- OpSource HLSL 670
- OpName %simple "simple"
- OpName %main "main"
- %int = OpTypeInt 32 1
- %int_2 = OpConstant %int 2
- %void = OpTypeVoid
- %main_type = OpTypeFunction %void
- %simple_type = OpTypeFunction %int
- %main = OpFunction %void None %main_type
- %entry = OpLabel
- OpReturn
- OpFunctionEnd
- %simple = OpFunction %int None %simple_type
- %1 = OpLabel
- OpReturnValue %int_2
- OpFunctionEnd
diff --git a/llvm/test/Other/spirv-sim/simulator-args.spv b/llvm/test/Other/spirv-sim/simulator-args.spv
deleted file mode 100644
index d8b1018064158..0000000000000
--- a/llvm/test/Other/spirv-sim/simulator-args.spv
+++ /dev/null
@@ -1,36 +0,0 @@
-; RUN: not spirv-sim --function=simple --wave=a --expects=2 -i %s 2>&1 | FileCheck %s --check-prefixes=CHECK-WAVE
-; RUN: not spirv-sim --function=simple --wave=1 --expects=a -i %s 2>&1 | FileCheck %s --check-prefixes=CHECK-EXPECT
-; RUN: not spirv-sim --function=simple --wave=1 --expects=1, -i %s 2>&1 | FileCheck %s --check-prefixes=CHECK-EXPECT
-; RUN: not spirv-sim --function=simple --wave=2 --expects=1 -i %s 2>&1 | FileCheck %s --check-prefixes=CHECK-SIZE
-; RUN: not spirv-sim --function=foo --wave=1 --expects=1 -i %s 2>&1 | FileCheck %s --check-prefixes=CHECK-NAME
-
-; CHECK-WAVE: Invalid format for --wave/-w flag.
-
-; CHECK-EXPECT: Invalid format for --expects/-e flag.
-
-; CHECK-SIZE: Wave size != expected result array size
-
-; CHECK-NAME: 'foo' function not found. Known functions are:
-; CHECK-NAME-NEXT: - main
-; CHECK-NAME-NEXT: - simple
-; CHECK-NANE-NOT-NEXT: -
- OpCapability Shader
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %main "main"
- OpExecutionMode %main LocalSize 1 1 1
- OpSource HLSL 670
- OpName %simple "simple"
- OpName %main "main"
- %int = OpTypeInt 32 1
- %int_2 = OpConstant %int 2
- %void = OpTypeVoid
- %main_type = OpTypeFunction %void
- %simple_type = OpTypeFunction %int
- %main = OpFunction %void None %main_type
- %entry = OpLabel
- OpReturn
- OpFunctionEnd
- %simple = OpFunction %int None %simple_type
- %1 = OpLabel
- OpReturnValue %int_2
- OpFunctionEnd
diff --git a/llvm/test/Other/spirv-sim/switch.spv b/llvm/test/Other/spirv-sim/switch.spv
deleted file mode 100644
index 83dc56cecef2a..0000000000000
--- a/llvm/test/Other/spirv-sim/switch.spv
+++ /dev/null
@@ -1,42 +0,0 @@
-; RUN: %if spirv-tools %{ spirv-as %s -o - | spirv-val - %}
-; RUN: spirv-sim --function=simple --wave=4 --expects=0,1,2,0 -i %s
- OpCapability Shader
- OpCapability GroupNonUniform
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %main "main" %WaveIndex
- OpExecutionMode %main LocalSize 1 1 1
- OpSource HLSL 670
- OpName %simple "simple"
- OpName %main "main"
- OpDecorate %WaveIndex BuiltIn SubgroupLocalInvocationId
- %int = OpTypeInt 32 1
- %uint = OpTypeInt 32 0
- %bool = OpTypeBool
- %int_0 = OpConstant %int 0
- %int_1 = OpConstant %int 1
- %int_2 = OpConstant %int 2
- %uint_0 = OpConstant %uint 0
- %void = OpTypeVoid
- %main_type = OpTypeFunction %void
-%simple_type = OpTypeFunction %int
- %uint_iptr = OpTypePointer Input %uint
- %WaveIndex = OpVariable %uint_iptr Input
- %main = OpFunction %void None %main_type
- %entry = OpLabel
- OpReturn
- OpFunctionEnd
- %simple = OpFunction %int None %simple_type
- %1 = OpLabel
- %2 = OpLoad %uint %WaveIndex
- OpSelectionMerge %merge None
- OpSwitch %2 %default 1 %case_1 2 %case_2
- %default = OpLabel
- OpBranch %merge
- %case_1 = OpLabel
- OpBranch %merge
- %case_2 = OpLabel
- OpBranch %merge
- %merge = OpLabel
- %4 = OpPhi %int %int_0 %default %int_1 %case_1 %int_2 %case_2
- OpReturnValue %4
- OpFunctionEnd
diff --git a/llvm/test/Other/spirv-sim/wave-get-lane-index.spv b/llvm/test/Other/spirv-sim/wave-get-lane-index.spv
deleted file mode 100644
index 1c1e5e8aefd4f..0000000000000
--- a/llvm/test/Other/spirv-sim/wave-get-lane-index.spv
+++ /dev/null
@@ -1,30 +0,0 @@
-; RUN: %if spirv-tools %{ spirv-as %s -o - | spirv-val - %}
-; RUN: spirv-sim --function=simple --wave=4 --expects=0,1,2,3 -i %s
- OpCapability Shader
- OpCapability GroupNonUniform
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %main "main" %WaveIndex
- OpExecutionMode %main LocalSize 1 1 1
- OpSource HLSL 670
- OpName %simple "simple"
- OpName %main "main"
- OpDecorate %WaveIndex BuiltIn SubgroupLocalInvocationId
- %int = OpTypeInt 32 1
- %uint = OpTypeInt 32 0
- %int_2 = OpConstant %int 2
- %void = OpTypeVoid
- %main_type = OpTypeFunction %void
-%simple_type = OpTypeFunction %int
- %uint_iptr = OpTypePointer Input %uint
- %WaveIndex = OpVariable %uint_iptr Input
- %main = OpFunction %void None %main_type
- %entry = OpLabel
- OpReturn
- OpFunctionEnd
- %simple = OpFunction %int None %simple_type
- %1 = OpLabel
- %2 = OpLoad %uint %WaveIndex
- %3 = OpBitcast %int %2
- OpReturnValue %3
- OpFunctionEnd
-
diff --git a/llvm/test/Other/spirv-sim/wave-read-lane-first.spv b/llvm/test/Other/spirv-sim/wave-read-lane-first.spv
deleted file mode 100644
index 801fb55fbaa9f..0000000000000
--- a/llvm/test/Other/spirv-sim/wave-read-lane-first.spv
+++ /dev/null
@@ -1,83 +0,0 @@
-; RUN: %if spirv-tools %{ spirv-as %s -o - | spirv-val - %}
-; RUN: spirv-sim --function=simple --wave=4 --expects=0,1,2,0 -i %s
-
-; int simple() {
-; int m[4] = { 0, 1, 2, 0 };
-; int idx = WaveGetLaneIndex();
-; for (int i = 0; i < 4; i++) {
-; if (i == m[idx]) {
-; return WaveReadLaneFirst(idx);
-; }
-; }
-; return 0;
-; }
- OpCapability Shader
- OpCapability GroupNonUniform
- OpCapability GroupNonUniformBallot
- OpMemoryModel Logical GLSL450
- OpEntryPoint GLCompute %main "main" %WaveIndex
- OpExecutionMode %main LocalSize 1 1 1
- OpSource HLSL 670
- OpName %simple "simple"
- OpName %main "main"
- OpDecorate %WaveIndex BuiltIn SubgroupLocalInvocationId
- %int = OpTypeInt 32 1
- %uint = OpTypeInt 32 0
- %bool = OpTypeBool
- %int_0 = OpConstant %int 0
- %int_1 = OpConstant %int 1
- %int_2 = OpConstant %int 2
- %int_4 = OpConstant %int 4
- %uint_3 = OpConstant %uint 3
- %uint_4 = OpConstant %uint 4
- %void = OpTypeVoid
- %main_type = OpTypeFunction %void
- %simple_type = OpTypeFunction %int
- %uint_iptr = OpTypePointer Input %uint
- %int_fptr = OpTypePointer Function %int
- %arr_int_uint_4 = OpTypeArray %int %uint_4
-%arr_int_uint_4_fptr = OpTypePointer Function %arr_int_uint_4
- %WaveIndex = OpVariable %uint_iptr Input
- %main = OpFunction %void None %main_type
- %entry = OpLabel
- OpReturn
- OpFunctionEnd
- %simple = OpFunction %int None %simple_type
- %bb_entry_0 = OpLabel
- %m = OpVariable %arr_int_uint_4_fptr Function
- %idx = OpVariable %int_fptr Function
- %i = OpVariable %int_fptr Function
- %27 = OpCompositeConstruct %arr_int_uint_4 %int_0 %int_1 %int_2 %int_0
- OpStore %m %27
- %28 = OpLoad %uint %WaveIndex
- %29 = OpBitcast %int %28
- OpStore %idx %29
- OpStore %i %int_0
- OpBranch %for_check
- %for_check = OpLabel
- %31 = OpLoad %int %i
- %33 = OpSLessThan %bool %31 %int_4
- OpLoopMerge %for_merge %for_continue None
- OpBranchConditional %33 %for_body %for_merge
- %for_body = OpLabel
- %37 = OpLoad %int %i
- %38 = OpLoad %int %idx
- %39 = OpAccessChain %int_fptr %m %38
- %40 = OpLoad %int %39
- %41 = OpIEqual %bool %37 %40
- OpSelectionMerge %if_merge None
- OpBranchConditional %41 %if_true %if_merge
- %if_true = OpLabel
- %44 = OpLoad %int %idx
- %45 = OpGroupNonUniformBroadcastFirst %int %uint_3 %44
- OpReturnValue %45
- %if_merge = OpLabel
- OpBranch %for_continue
- %for_continue = OpLabel
- %47 = OpLoad %int %i
- %48 = OpIAdd %int %47 %int_1
- OpStore %i %48
- OpBranch %for_check
- %for_merge = OpLabel
- OpReturnValue %int_0
- OpFunctionEnd
diff --git a/llvm/utils/spirv-sim/instructions.py b/llvm/utils/spirv-sim/instructions.py
deleted file mode 100644
index 5e64a480a2be6..0000000000000
--- a/llvm/utils/spirv-sim/instructions.py
+++ /dev/null
@@ -1,381 +0,0 @@
-from typing import Optional, List
-
-
-# Base class for an instruction. To implement a basic instruction that doesn't
-# impact the control-flow, create a new class inheriting from this.
-class Instruction:
- # Contains the name of the output register, if any.
- _result: Optional[str]
- # Contains the instruction opcode.
- _opcode: str
- # Contains all the i...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/151705
More information about the llvm-commits
mailing list