xref: /llvm-project/llvm/test/CodeGen/SPIRV/pointers/argument-ptr-to-struct.ll (revision 67d3ef74b31e1517d4f679e754cc2b3041c95901)
1; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
2; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
3
4; CHECK-DAG: %[[#VOID:]] = OpTypeVoid
5; CHECK-DAG: %[[#FLOAT:]] = OpTypeFloat 32
6; CHECK-DAG: %[[#UCHAR:]] = OpTypeInt 8 0
7; CHECK-DAG: %[[#UINT:]] = OpTypeInt 32 0
8; CHECK-DAG: %[[#STRUCT_S:]] = OpTypeStruct %[[#FLOAT]] %[[#UCHAR]] %[[#UINT]]
9; CHECK-DAG: %[[#PTR_STRUCT_S:]] = OpTypePointer Function %[[#STRUCT_S]]
10; CHECK-DAG: %[[#FUNC_TYPE_K:]] = OpTypeFunction %[[#VOID]] %[[#PTR_STRUCT_S]]
11; CHECK-DAG: %[[#FUNC_TYPE_H:]] = OpTypeFunction %[[#UINT]] %[[#PTR_STRUCT_S]]
12
13; CHECK: %[[#]] = OpFunction %[[#VOID]] None %[[#FUNC_TYPE_K]]
14; CHECK: %[[#]] = OpFunctionParameter %[[#PTR_STRUCT_S]]
15
16; CHECK: %[[#]] = OpFunction %[[#UINT]] None %[[#FUNC_TYPE_H]]
17; CHECK: %[[#]] = OpFunctionParameter %[[#PTR_STRUCT_S]]
18
19%struct.s = type { float, i8, i32 }
20
21define spir_kernel void @k(ptr noundef byval(%struct.s) align 4 %x) {
22entry:
23  %c = getelementptr inbounds %struct.s, ptr %x, i32 0, i32 2
24  %l = load i32, ptr %c, align 4
25  %add = add nsw i32 %l, 1
26  %c1 = getelementptr inbounds %struct.s, ptr %x, i32 0, i32 2
27  store i32 %add, ptr %c1, align 4
28  ret void
29}
30
31define spir_func i32 @h(ptr noundef byval(%struct.s) align 4 %x) {
32entry:
33  %c = getelementptr inbounds %struct.s, ptr %x, i32 0, i32 2
34  %l = load i32, ptr %c, align 4
35  %add = add nsw i32 %l, 1
36  ret i32 %add
37}
38