Skip to content

Commit 8d82a7f

Browse files
committed
add SPIR-V codegen tests
1 parent cb477ce commit 8d82a7f

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv-vulkan-unknown %s -o - | FileCheck %s
2+
3+
%struct.S = type <{ float }>
4+
5+
; CHECK-DAG: %[[#PTR_PCS:]] = OpTypePointer PushConstant %[[#S_S:]]
6+
7+
; CHECK-DAG: %[[#F32:]] = OpTypeFloat 32
8+
; CHECK-DAG: %[[#UINT:]] = OpTypeInt 32 0
9+
10+
; CHECK-DAG: %[[#S_S]] = OpTypeStruct %[[#F32]]
11+
12+
; CHECK-DAG: OpMemberDecorate %[[#S_S]] 0 Offset 0
13+
; CHECK-DAG: OpDecorate %[[#S_S]] Block
14+
15+
16+
@pcs = external hidden addrspace(13) externally_initialized global %struct.S, align 1
17+
; CHECK: %[[#PCS:]] = OpVariable %[[#PTR_PCS]] PushConstant
18+
19+
define void @main() #1 {
20+
entry:
21+
%0 = call token @llvm.experimental.convergence.entry()
22+
%1 = alloca float, align 4
23+
%2 = load float, ptr addrspace(13) @pcs, align 1
24+
store float %2, ptr %1
25+
ret void
26+
}
27+
28+
declare token @llvm.experimental.convergence.entry() #2
29+
30+
attributes #1 = { convergent noinline norecurse optnone "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
31+
attributes #2 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }
32+
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
; RUN: llc -O0 -verify-machineinstrs -mtriple=spirv-vulkan-unknown %s -o - | FileCheck %s
2+
; XFAIL: *
3+
; FIXME(168401): fix the offset of last struct S field.
4+
5+
%struct.T = type { [3 x <2 x float>] }
6+
%struct.S = type <{ float, <3 x float>, %struct.T }>
7+
8+
; CHECK-DAG: %[[#PTR_PCS:]] = OpTypePointer PushConstant %[[#S_S:]]
9+
10+
; CHECK-DAG: %[[#F32:]] = OpTypeFloat 32
11+
; CHECK-DAG: %[[#V3F32:]] = OpTypeVector %[[#F32]] 3
12+
; CHECK-DAG: %[[#V2F32:]] = OpTypeVector %[[#F32]] 2
13+
; CHECK-DAG: %[[#UINT:]] = OpTypeInt 32 0
14+
; CHECK-DAG: %[[#UINT_3:]] = OpConstant %[[#UINT]] 3
15+
16+
; CHECK-DAG: %[[#S_S]] = OpTypeStruct %[[#F32]] %[[#V3F32]] %[[#S_T:]]
17+
; CHECK-DAG: %[[#S_T]] = OpTypeStruct %[[#ARR:]]
18+
; CHECK-DAG: %[[#ARR]] = OpTypeArray %[[#V2F32]] %[[#UINT_3]]
19+
20+
; CHECK-DAG: OpMemberDecorate %[[#S_T]] 0 Offset 0
21+
; CHECK-DAG: OpMemberDecorate %[[#S_S]] 0 Offset 0
22+
; CHECK-DAG: OpMemberDecorate %[[#S_S]] 1 Offset 4
23+
; CHECK-DAG: OpMemberDecorate %[[#S_S]] 2 Offset 16
24+
; CHECK-DAG: OpDecorate %[[#S_S]] Block
25+
; CHECK-DAG: OpDecorate %[[#ARR]] ArrayStride 8
26+
27+
28+
@pcs = external hidden addrspace(13) externally_initialized global %struct.S, align 1
29+
; CHECK: %[[#PCS:]] = OpVariable %[[#PTR_PCS]] PushConstant
30+
31+
define void @main() #1 {
32+
entry:
33+
%0 = call token @llvm.experimental.convergence.entry()
34+
ret void
35+
}
36+
37+
declare token @llvm.experimental.convergence.entry() #2
38+
39+
attributes #1 = { convergent noinline norecurse optnone "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
40+
attributes #2 = { convergent nocallback nofree nosync nounwind willreturn memory(none) }

0 commit comments

Comments
 (0)