Debian Codegraph @

llvm-project/llvm/projects/llvm-spirv/test/isubborrow_builtin.ll

raw
1 ; REQUIRES: spirv-dis
2 ; RUN: llvm-as %s -o %t.bc
3 ; RUN: llvm-spirv %t.bc -o %t.spv
4 ; RUN: spirv-dis --raw-id %t.spv | FileCheck --check-prefix CHECK-SPIRV %s
5 ; RUN: spirv-val %t.spv
6 ; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
7 ; RUN: llvm-dis %t.rev.bc -o - | FileCheck --check-prefix CHECK-LLVM %s
8
9 target triple = "spir64-unknown-unknown"
10
11 %i8struct = type {i8, i8}
12 %i16struct = type {i16, i16}
13 %i32struct = type {i32, i32}
14 %i64struct = type {i64, i64}
15 %vecstruct = type {<4 x i32>, <4 x i32>}
16 %struct.anon = type { i32, i32 }
17
18 ; CHECK-SPIRV-DAG: [[uchar:%[a-z0-9_]+]] = OpTypeInt 8
19 ; CHECK-SPIRV-DAG: [[ushort:%[a-z0-9_]+]] = OpTypeInt 16
20 ; CHECK-SPIRV-DAG: [[uint:%[a-z0-9_]+]] = OpTypeInt 32
21 ; CHECK-SPIRV-DAG: [[ulong:%[a-z0-9_]+]] = OpTypeInt 64
22 ; CHECK-SPIRV-DAG: [[void:%[a-z0-9_]+]] = OpTypeVoid
23 ; CHECK-SPIRV-DAG: [[i8struct:%[a-z0-9_]+]] = OpTypeStruct [[uchar]] [[uchar]]
24 ; CHECK-SPIRV-DAG: [[_ptr_Function_i8struct:%[a-z0-9_]+]] = OpTypePointer Function [[i8struct]]
25 ; CHECK-SPIRV-DAG: [[i16struct:%[a-z0-9_]+]] = OpTypeStruct [[ushort]] [[ushort]]
26 ; CHECK-SPIRV-DAG: [[_ptr_Function_i16struct:%[a-z0-9_]+]] = OpTypePointer Function [[i16struct]]
27 ; CHECK-SPIRV-DAG: [[i32struct:%[a-z0-9_]+]] = OpTypeStruct [[uint]] [[uint]]
28 ; CHECK-SPIRV-DAG: [[_ptr_Function_i32struct:%[a-z0-9_]+]] = OpTypePointer Function [[i32struct]]
29 ; CHECK-SPIRV-DAG: [[i64struct:%[a-z0-9_]+]] = OpTypeStruct [[ulong]] [[ulong]]
30 ; CHECK-SPIRV-DAG: [[_ptr_Function_i64struct:%[a-z0-9_]+]] = OpTypePointer Function [[i64struct]]
31 ; CHECK-SPIRV-DAG: [[v4uint:%[a-z0-9_]+]] = OpTypeVector [[uint]] 4
32 ; CHECK-SPIRV-DAG: [[vecstruct:%[a-z0-9_]+]] = OpTypeStruct [[v4uint]] [[v4uint]]
33 ; CHECK-SPIRV-DAG: [[_ptr_Function_vecstruct:%[a-z0-9_]+]] = OpTypePointer Function [[vecstruct]]
34 ; CHECK-SPIRV-DAG: [[struct_anon:%[a-z0-9_.]+]] = OpTypeStruct [[uint]] [[uint]]
35 ; CHECK-SPIRV-DAG: [[_ptr_Function_struct_anon:%[a-z0-9_]+]] = OpTypePointer Function [[struct_anon]]
36 ; CHECK-SPIRV-DAG: [[_ptr_Generic_struct_anon:%[a-z0-9_]+]] = OpTypePointer Generic [[struct_anon]]
37
38 ; CHECK-LLVM-DAG: [[i8struct:%[a-z0-9_.]+]] = type { i8, i8 }
39 ; CHECK-LLVM-DAG: [[i16struct:%[a-z0-9_.]+]] = type { i16, i16 }
40 ; CHECK-LLVM-DAG: [[i32struct:%[a-z0-9_.]+]] = type { i32, i32 }
41 ; CHECK-LLVM-DAG: [[i64struct:%[a-z0-9_.]+]] = type { i64, i64 }
42 ; CHECK-LLVM-DAG: [[vecstruct:%[a-z0-9_.]+]] = type { <4 x i32>, <4 x i32> }
43 ; CHECK-LLVM-DAG: [[struct_anon:%[a-z0-9_.]+]] = type { i32, i32 }
44
45 define spir_func void @test_builtin_isubborrowcc(i8 %a, i8 %b) {
46 entry:
47 %0 = alloca %i8struct
48 call void @_Z18__spirv_ISubBorrowcc(ptr sret (%i8struct) %0, i8 %a, i8 %b)
49 ret void
50 }
51 ; CHECK-SPIRV: [[a:%[a-z0-9_]+]] = OpFunctionParameter [[uchar]]
52 ; CHECK-SPIRV: [[b:%[a-z0-9_]+]] = OpFunctionParameter [[uchar]]
53 ; CHECK-SPIRV: [[entry:%[a-z0-9_]+]] = OpLabel
54 ; CHECK-SPIRV: [[var_11:%[a-z0-9_]+]] = OpVariable [[_ptr_Function_i8struct]] Function
55 ; CHECK-SPIRV: [[var_12:%[a-z0-9_]+]] = OpISubBorrow [[i8struct]] [[a]] [[b]]
56 ; CHECK-SPIRV: OpStore [[var_11]] [[var_12]]
57 ; CHECK-SPIRV: OpReturn
58 ; CHECK-SPIRV: OpFunctionEnd
59
60 ; CHECK-LLVM: %0 = alloca [[i8struct]], align 8
61 ; CHECK-LLVM: call spir_func void @_Z18__spirv_ISubBorrowcc(ptr sret([[i8struct]]) %0, i8 %a, i8 %b)
62 ; CHECK-LLVM: ret void
63 define spir_func void @test_builtin_isubborrowss(i16 %a, i16 %b) {
64 entry:
65 %0 = alloca %i16struct
66 call void @_Z18__spirv_ISubBorrowss(ptr sret (%i16struct) %0, i16 %a, i16 %b)
67 ret void
68 }
69 ; CHECK-SPIRV: [[a_0:%[a-z0-9_]+]] = OpFunctionParameter [[ushort]]
70 ; CHECK-SPIRV: [[b_0:%[a-z0-9_]+]] = OpFunctionParameter [[ushort]]
71 ; CHECK-SPIRV: [[entry_0:%[a-z0-9_]+]] = OpLabel
72 ; CHECK-SPIRV: [[var_21:%[a-z0-9_]+]] = OpVariable [[_ptr_Function_i16struct]] Function
73 ; CHECK-SPIRV: [[var_22:%[a-z0-9_]+]] = OpISubBorrow [[i16struct]] [[a_0]] [[b_0]]
74 ; CHECK-SPIRV: OpStore [[var_21]] [[var_22]]
75 ; CHECK-SPIRV: OpReturn
76 ; CHECK-SPIRV: OpFunctionEnd
77
78 ; CHECK-LLVM: %0 = alloca [[i16struct]], align 8
79 ; CHECK-LLVM: call spir_func void @_Z18__spirv_ISubBorrowss(ptr sret([[i16struct]]) %0, i16 %a, i16 %b)
80 ; CHECK-LLVM: ret void
81 define spir_func void @test_builtin_isubborrowii(i32 %a, i32 %b) {
82 entry:
83 %0 = alloca %i32struct
84 call void @_Z18__spirv_ISubBorrowii(ptr sret (%i32struct) %0, i32 %a, i32 %b)
85 ret void
86 }
87 ; CHECK-SPIRV: [[a_1:%[a-z0-9_]+]] = OpFunctionParameter [[uint]]
88 ; CHECK-SPIRV: [[b_1:%[a-z0-9_]+]] = OpFunctionParameter [[uint]]
89 ; CHECK-SPIRV: [[entry_1:%[a-z0-9_]+]] = OpLabel
90 ; CHECK-SPIRV: [[var_31:%[a-z0-9_]+]] = OpVariable [[_ptr_Function_i32struct]] Function
91 ; CHECK-SPIRV: [[var_32:%[a-z0-9_]+]] = OpISubBorrow [[i32struct]] [[a_1]] [[b_1]]
92 ; CHECK-SPIRV: OpStore [[var_31]] [[var_32]]
93 ; CHECK-SPIRV: OpReturn
94 ; CHECK-SPIRV: OpFunctionEnd
95
96 ; CHECK-LLVM: %0 = alloca [[i32struct]], align 8
97 ; CHECK-LLVM: call spir_func void @_Z18__spirv_ISubBorrowii(ptr sret([[i32struct]]) %0, i32 %a, i32 %b)
98 ; CHECK-LLVM: ret void
99 define spir_func void @test_builtin_isubborrowll(i64 %a, i64 %b) {
100 entry:
101 %0 = alloca %i64struct
102 call void @_Z18__spirv_ISubBorrowll(ptr sret (%i64struct) %0, i64 %a, i64 %b)
103 ret void
104 }
105 ; CHECK-SPIRV: [[a_2:%[a-z0-9_]+]] = OpFunctionParameter [[ulong]]
106 ; CHECK-SPIRV: [[b_2:%[a-z0-9_]+]] = OpFunctionParameter [[ulong]]
107 ; CHECK-SPIRV: [[entry_2:%[a-z0-9_]+]] = OpLabel
108 ; CHECK-SPIRV: [[var_41:%[a-z0-9_]+]] = OpVariable [[_ptr_Function_i64struct]] Function
109 ; CHECK-SPIRV: [[var_42:%[a-z0-9_]+]] = OpISubBorrow [[i64struct]] [[a_2]] [[b_2]]
110 ; CHECK-SPIRV: OpStore [[var_41]] [[var_42]]
111 ; CHECK-SPIRV: OpReturn
112 ; CHECK-SPIRV: OpFunctionEnd
113
114 ; CHECK-LLVM: %0 = alloca [[i64struct]]
115 ; CHECK-LLVM: call spir_func void @_Z18__spirv_ISubBorrowll(ptr sret([[i64struct]]) %0, i64 %a, i64 %b)
116 ; CHECK-LLVM: ret void
117 define spir_func void @test_builtin_isubborrowDv4_xS_(<4 x i32> %a, <4 x i32> %b) {
118 entry:
119 %0 = alloca %vecstruct
120 call void @_Z18__spirv_ISubBorrowDv4_iS_(ptr sret (%vecstruct) %0, <4 x i32> %a, <4 x i32> %b)
121 ret void
122 }
123 ; CHECK-SPIRV: [[a_3:%[a-z0-9_]+]] = OpFunctionParameter [[v4uint]]
124 ; CHECK-SPIRV: [[b_3:%[a-z0-9_]+]] = OpFunctionParameter [[v4uint]]
125 ; CHECK-SPIRV: [[entry_3:%[a-z0-9_]+]] = OpLabel
126 ; CHECK-SPIRV: [[var_51:%[a-z0-9_]+]] = OpVariable [[_ptr_Function_vecstruct]] Function
127 ; CHECK-SPIRV: [[var_52:%[a-z0-9_]+]] = OpISubBorrow [[vecstruct]] [[a_3]] [[b_3]]
128 ; CHECK-SPIRV: OpStore [[var_51]] [[var_52]]
129 ; CHECK-SPIRV: OpReturn
130 ; CHECK-SPIRV: OpFunctionEnd
131
132 ; CHECK-LLVM: %0 = alloca [[vecstruct]]
133 ; CHECK-LLVM: call spir_func void @_Z18__spirv_ISubBorrowDv4_iS_(ptr sret([[vecstruct]]) %0, <4 x i32> %a, <4 x i32> %b)
134 ; CHECK-LLVM: ret void
135
136
137 define spir_func void @test_builtin_isubborrow_anon(i32 %a, i32 %b) {
138 entry:
139 %0 = alloca %struct.anon
140 %1 = addrspacecast ptr %0 to ptr addrspace(4)
141 call spir_func void @_Z18__spirv_ISubBorrowIiiE4anonIT_T0_ES1_S2_(ptr addrspace(4) sret(%struct.anon) align 4 %1, i32 %a, i32 %b)
142 ret void
143 }
144 ; CHECK-SPIRV: [[a_4:%[a-z0-9_]+]] = OpFunctionParameter [[uint]]
145 ; CHECK-SPIRV: [[b_4:%[a-z0-9_]+]] = OpFunctionParameter [[uint]]
146 ; CHECK-SPIRV: [[entry_4:%[a-z0-9_]+]] = OpLabel
147 ; CHECK-SPIRV: [[var_59:%[a-z0-9_]+]] = OpVariable [[_ptr_Function_struct_anon]] Function
148 ; CHECK-SPIRV: [[var_61:%[a-z0-9_]+]] = OpPtrCastToGeneric [[_ptr_Generic_struct_anon]] [[var_59]]
149 ; CHECK-SPIRV: [[var_62:%[a-z0-9_]+]] = OpISubBorrow [[struct_anon]] [[a_4]] [[b_4]]
150 ; CHECK-SPIRV: OpStore [[var_61]] [[var_62]]
151
152 ; CHECK-LLVM: %0 = alloca [[struct_anon]], align 8
153 ; CHECK-LLVM: %1 = addrspacecast ptr %0 to ptr addrspace(4)
154 ; CHECK-LLVM: call spir_func void @_Z18__spirv_ISubBorrowii.1(ptr addrspace(4) sret([[struct_anon]]) %1, i32 %a, i32 %b)
155 ; CHECK-LLVM: ret void
156
157 declare void @_Z18__spirv_ISubBorrowIiiE4anonIT_T0_ES1_S2_(ptr addrspace(4) sret(%struct.anon) align 4, i32, i32)
158 declare void @_Z18__spirv_ISubBorrowcc(ptr sret(%i8struct), i8, i8)
159 declare void @_Z18__spirv_ISubBorrowss(ptr sret(%i16struct), i16, i16)
160 declare void @_Z18__spirv_ISubBorrowii(ptr sret(%i32struct), i32, i32)
161 declare void @_Z18__spirv_ISubBorrowll(ptr sret(%i64struct), i64, i64)
162 declare void @_Z18__spirv_ISubBorrowDv4_iS_(ptr sret (%vecstruct), <4 x i32>, <4 x i32>)