Skip to content

Commit 7a23989

Browse files
add tests
1 parent 7f48a48 commit 7a23989

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
; The goal of the test is to ensure that type inference doesn't break validity of the generated SPIR-V code.
2+
; The only pass criterion is that spirv-val considers output valid.
3+
4+
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
5+
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
6+
7+
; CHECK-DAG: %[[#Int:]] = OpTypeInt 32 0
8+
; CHECK-DAG: %[[#Char:]] = OpTypeInt 8 0
9+
; CHECK-DAG: %[[#PtrChar:]] = OpTypePointer Function %[[#Char]]
10+
; CHECK-DAG: %[[#PtrCharCW:]] = OpTypePointer CrossWorkgroup %[[#Char]]
11+
; CHECK-DAG: %[[#PtrCharGen:]] = OpTypePointer Generic %[[#Char]]
12+
; CHECK-DAG: %[[#Struct:]] = OpTypeStruct %[[#]] %[[#]] %[[#]]
13+
; CHECK-DAG: %[[#PtrInt:]] = OpTypePointer Function %[[#Int]]
14+
; CHECK-DAG: %[[#PtrPtrCharGen:]] = OpTypePointer Function %[[#PtrCharGen]]
15+
; CHECK-DAG: %[[#PtrStruct:]] = OpTypePointer Function %[[#Struct]]
16+
; CHECK: OpFunction
17+
; CHECK: %[[#Arg1:]] = OpFunctionParameter %[[#Int]]
18+
; CHECK: %[[#Arg2:]] = OpFunctionParameter %[[#PtrCharCW]]
19+
; CHECK: %[[#Kernel:]] = OpVariable %[[#PtrStruct]] Function
20+
; CHECK: %[[#IntKernel:]] = OpBitcast %[[#PtrInt]] %[[#Kernel]]
21+
; CHECK: OpStore %[[#IntKernel]] %[[#Arg1]]
22+
; CHECK: %[[#CharKernel:]] = OpBitcast %[[#PtrChar]] %[[#Kernel]]
23+
; CHECK: %[[#P:]] = OpInBoundsPtrAccessChain %[[#PtrChar]] %[[#CharKernel]] %[[#]]
24+
; CHECK: %[[#R0:]] = OpPtrCastToGeneric %[[#PtrCharGen]] %[[#Arg2]]
25+
; CHECK: %[[#P2:]] = OpBitcast %[[#PtrPtrCharGen]] %[[#P]]
26+
; CHECK: OpStore %[[#P2]] %[[#R0]]
27+
; CHECK: %[[#P3:]] = OpBitcast %[[#PtrPtrCharGen]] %[[#P]]
28+
; CHECK: %[[#]] = OpLoad %[[#PtrCharGen]] %[[#P3]]
29+
30+
%"class.std::complex" = type { { double, double } }
31+
%class.anon = type { i32, ptr addrspace(4), [2 x [2 x %"class.std::complex"]] }
32+
33+
define weak_odr dso_local spir_kernel void @foo(i32 noundef %_arg_N, ptr addrspace(1) noundef align 8 %_arg_p) {
34+
entry:
35+
%Kernel = alloca %class.anon, align 8
36+
store i32 %_arg_N, ptr %Kernel, align 8
37+
%p = getelementptr inbounds i8, ptr %Kernel, i64 8
38+
%r0 = addrspacecast ptr addrspace(1) %_arg_p to ptr addrspace(4)
39+
store ptr addrspace(4) %r0, ptr %p, align 8
40+
%r3 = load ptr addrspace(4), ptr %p, align 8
41+
ret void
42+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
; The goal of the test is to ensure that type inference doesn't break validity of the generated SPIR-V code.
2+
; The only pass criterion is that spirv-val considers output valid.
3+
4+
; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
5+
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
6+
7+
; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
8+
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}
9+
10+
; CHECK: OpFunction
11+
12+
%class.anon = type { i32, ptr addrspace(4)}
13+
14+
define weak_odr dso_local spir_kernel void @foo(i32 noundef %_arg_N, i1 %fl) {
15+
entry:
16+
%__SYCLKernel = alloca %class.anon, align 8
17+
store i32 %_arg_N, ptr %__SYCLKernel, align 8
18+
br label %arinit
19+
20+
arinit:
21+
%scevgep3 = getelementptr nuw i8, ptr %__SYCLKernel, i64 24
22+
br label %for.cond.i
23+
24+
for.cond.i:
25+
%lsr.iv4 = phi ptr [ %scevgep5, %for.body.i ], [ %scevgep3, %arinit ]
26+
br i1 %fl, label %for.body.i, label %exit
27+
28+
for.body.i:
29+
%scevgep6 = getelementptr i8, ptr %lsr.iv4, i64 -8
30+
%_M_value.imag.i.i = load double, ptr %lsr.iv4, align 8
31+
%scevgep5 = getelementptr i8, ptr %lsr.iv4, i64 32
32+
br label %for.cond.i
33+
34+
exit:
35+
ret void
36+
}

0 commit comments

Comments
 (0)