1 ; Adapted from Khronos Translator test suite: test/iaddcarry_builtin.ll
3 ; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
4 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
6 %i8struct = type {i8, i8}
7 %i16struct = type {i16, i16}
8 %i32struct = type {i32, i32}
9 %i64struct = type {i64, i64}
10 %vecstruct = type {<4 x i32>, <4 x i32>}
12 ; CHECK-SPIRV-DAG: [[uchar:%[a-z0-9_]+]] = OpTypeInt 8
13 ; CHECK-SPIRV-DAG: [[ushort:%[a-z0-9_]+]] = OpTypeInt 16
14 ; CHECK-SPIRV-DAG: [[uint:%[a-z0-9_]+]] = OpTypeInt 32
15 ; CHECK-SPIRV-DAG: [[ulong:%[a-z0-9_]+]] = OpTypeInt 64
16 ; CHECK-SPIRV-DAG: [[void:%[a-z0-9_]+]] = OpTypeVoid
17 ; CHECK-SPIRV-DAG: [[i8struct:%[a-z0-9_]+]] = OpTypeStruct [[uchar]] [[uchar]]
18 ; CHECK-SPIRV-DAG: [[_ptr_Function_i8struct:%[a-z0-9_]+]] = OpTypePointer Function [[i8struct]]
19 ; CHECK-SPIRV-DAG: [[i16struct:%[a-z0-9_]+]] = OpTypeStruct [[ushort]] [[ushort]]
20 ; CHECK-SPIRV-DAG: [[_ptr_Function_i16struct:%[a-z0-9_]+]] = OpTypePointer Function [[i16struct]]
21 ; CHECK-SPIRV-DAG: [[i32struct:%[a-z0-9_]+]] = OpTypeStruct [[uint]] [[uint]]
22 ; CHECK-SPIRV-DAG: [[_ptr_Function_i32struct:%[a-z0-9_]+]] = OpTypePointer Function [[i32struct]]
23 ; CHECK-SPIRV-DAG: [[i64struct:%[a-z0-9_]+]] = OpTypeStruct [[ulong]] [[ulong]]
24 ; CHECK-SPIRV-DAG: [[_ptr_Function_i64struct:%[a-z0-9_]+]] = OpTypePointer Function [[i64struct]]
25 ; CHECK-SPIRV-DAG: [[v4uint:%[a-z0-9_]+]] = OpTypeVector [[uint]] 4
26 ; CHECK-SPIRV-DAG: [[vecstruct:%[a-z0-9_]+]] = OpTypeStruct [[v4uint]] [[v4uint]]
27 ; CHECK-SPIRV-DAG: [[_ptr_Function_vecstruct:%[a-z0-9_]+]] = OpTypePointer Function [[vecstruct]]
28 ; CHECK-SPIRV-DAG: [[struct_anon:%[a-z0-9_.]+]] = OpTypeStruct [[uint]] [[uint]]
29 ; CHECK-SPIRV-DAG: [[_ptr_Function_struct_anon:%[a-z0-9_]+]] = OpTypePointer Function [[struct_anon]]
30 ; CHECK-SPIRV-DAG: [[_ptr_Generic_struct_anon:%[a-z0-9_]+]] = OpTypePointer Generic [[struct_anon]]
32 define spir_func void @test_builtin_iaddcarrycc(i8 %a, i8 %b) {
35 call void @_Z17__spirv_IAddCarrycc(ptr sret (%i8struct) %0, i8 %a, i8 %b)
38 ; CHECK-SPIRV: [[a:%[a-z0-9_]+]] = OpFunctionParameter [[uchar]]
39 ; CHECK-SPIRV: [[b:%[a-z0-9_]+]] = OpFunctionParameter [[uchar]]
40 ; CHECK-SPIRV: [[entry:%[a-z0-9_]+]] = OpLabel
41 ; CHECK-SPIRV: [[var_11:%[a-z0-9_]+]] = OpVariable [[_ptr_Function_i8struct]] Function
42 ; CHECK-SPIRV: [[var_12:%[a-z0-9_]+]] = OpIAddCarry [[i8struct]] [[a]] [[b]]
43 ; CHECK-SPIRV: OpStore [[var_11]] [[var_12]]
44 ; CHECK-SPIRV: OpReturn
45 ; CHECK-SPIRV: OpFunctionEnd
47 define spir_func void @test_builtin_iaddcarryss(i16 %a, i16 %b) {
49 %0 = alloca %i16struct
50 call void @_Z17__spirv_IAddCarryss(ptr sret (%i16struct) %0, i16 %a, i16 %b)
53 ; CHECK-SPIRV: [[a_0:%[a-z0-9_]+]] = OpFunctionParameter [[ushort]]
54 ; CHECK-SPIRV: [[b_0:%[a-z0-9_]+]] = OpFunctionParameter [[ushort]]
55 ; CHECK-SPIRV: [[entry_0:%[a-z0-9_]+]] = OpLabel
56 ; CHECK-SPIRV: [[var_21:%[a-z0-9_]+]] = OpVariable [[_ptr_Function_i16struct]] Function
57 ; CHECK-SPIRV: [[var_22:%[a-z0-9_]+]] = OpIAddCarry [[i16struct]] [[a_0]] [[b_0]]
58 ; CHECK-SPIRV: OpStore [[var_21]] [[var_22]]
59 ; CHECK-SPIRV: OpReturn
60 ; CHECK-SPIRV: OpFunctionEnd
62 define spir_func void @test_builtin_iaddcarryii(i32 %a, i32 %b) {
64 %0 = alloca %i32struct
65 call void @_Z17__spirv_IAddCarryii(ptr sret (%i32struct) %0, i32 %a, i32 %b)
68 ; CHECK-SPIRV: [[a_1:%[a-z0-9_]+]] = OpFunctionParameter [[uint]]
69 ; CHECK-SPIRV: [[b_1:%[a-z0-9_]+]] = OpFunctionParameter [[uint]]
70 ; CHECK-SPIRV: [[entry_1:%[a-z0-9_]+]] = OpLabel
71 ; CHECK-SPIRV: [[var_31:%[a-z0-9_]+]] = OpVariable [[_ptr_Function_i32struct]] Function
72 ; CHECK-SPIRV: [[var_32:%[a-z0-9_]+]] = OpIAddCarry [[i32struct]] [[a_1]] [[b_1]]
73 ; CHECK-SPIRV: OpStore [[var_31]] [[var_32]]
74 ; CHECK-SPIRV: OpReturn
75 ; CHECK-SPIRV: OpFunctionEnd
77 define spir_func void @test_builtin_iaddcarryll(i64 %a, i64 %b) {
79 %0 = alloca %i64struct
80 call void @_Z17__spirv_IAddCarryll(ptr sret (%i64struct) %0, i64 %a, i64 %b)
83 ; CHECK-SPIRV: [[a_2:%[a-z0-9_]+]] = OpFunctionParameter [[ulong]]
84 ; CHECK-SPIRV: [[b_2:%[a-z0-9_]+]] = OpFunctionParameter [[ulong]]
85 ; CHECK-SPIRV: [[entry_2:%[a-z0-9_]+]] = OpLabel
86 ; CHECK-SPIRV: [[var_41:%[a-z0-9_]+]] = OpVariable [[_ptr_Function_i64struct]] Function
87 ; CHECK-SPIRV: [[var_42:%[a-z0-9_]+]] = OpIAddCarry [[i64struct]] [[a_2]] [[b_2]]
88 ; CHECK-SPIRV: OpStore [[var_41]] [[var_42]]
89 ; CHECK-SPIRV: OpReturn
90 ; CHECK-SPIRV: OpFunctionEnd
92 define spir_func void @test_builtin_iaddcarryDv4_xS_(<4 x i32> %a, <4 x i32> %b) {
94 %0 = alloca %vecstruct
95 call void @_Z17__spirv_IAddCarryDv4_iS_(ptr sret (%vecstruct) %0, <4 x i32> %a, <4 x i32> %b)
98 ; CHECK-SPIRV: [[a_3:%[a-z0-9_]+]] = OpFunctionParameter [[v4uint]]
99 ; CHECK-SPIRV: [[b_3:%[a-z0-9_]+]] = OpFunctionParameter [[v4uint]]
100 ; CHECK-SPIRV: [[entry_3:%[a-z0-9_]+]] = OpLabel
101 ; CHECK-SPIRV: [[var_51:%[a-z0-9_]+]] = OpVariable [[_ptr_Function_vecstruct]] Function
102 ; CHECK-SPIRV: [[var_52:%[a-z0-9_]+]] = OpIAddCarry [[vecstruct]] [[a_3]] [[b_3]]
103 ; CHECK-SPIRV: OpStore [[var_51]] [[var_52]]
104 ; CHECK-SPIRV: OpReturn
105 ; CHECK-SPIRV: OpFunctionEnd
107 %struct.anon = type { i32, i32 }
109 define spir_func void @test_builtin_iaddcarry_anon(i32 %a, i32 %b) {
111 %0 = alloca %struct.anon
112 %1 = addrspacecast ptr %0 to ptr addrspace(4)
113 call spir_func void @_Z17__spirv_IAddCarryIiiE4anonIT_T0_ES1_S2_(ptr addrspace(4) sret(%struct.anon) align 4 %1, i32 %a, i32 %b)
116 ; CHECK-SPIRV: [[a_4:%[a-z0-9_]+]] = OpFunctionParameter [[uint]]
117 ; CHECK-SPIRV: [[b_4:%[a-z0-9_]+]] = OpFunctionParameter [[uint]]
118 ; CHECK-SPIRV: [[entry_4:%[a-z0-9_]+]] = OpLabel
119 ; CHECK-SPIRV: [[var_59:%[a-z0-9_]+]] = OpVariable [[_ptr_Function_struct_anon]] Function
120 ; CHECK-SPIRV: [[var_61:%[a-z0-9_]+]] = OpPtrCastToGeneric [[_ptr_Generic_struct_anon]] [[var_59]]
121 ; CHECK-SPIRV: [[var_62:%[a-z0-9_]+]] = OpIAddCarry [[struct_anon]] [[a_4]] [[b_4]]
122 ; CHECK-SPIRV: OpStore [[var_61]] [[var_62]]
124 declare void @_Z17__spirv_IAddCarryIiiE4anonIT_T0_ES1_S2_(ptr addrspace(4) sret(%struct.anon) align 4, i32, i32)
125 declare void @_Z17__spirv_IAddCarrycc(ptr sret(%i8struct), i8, i8)
126 declare void @_Z17__spirv_IAddCarryss(ptr sret(%i16struct), i16, i16)
127 declare void @_Z17__spirv_IAddCarryii(ptr sret(%i32struct), i32, i32)
128 declare void @_Z17__spirv_IAddCarryll(ptr sret(%i64struct), i64, i64)
129 declare void @_Z17__spirv_IAddCarryDv4_iS_(ptr sret (%vecstruct), <4 x i32>, <4 x i32>)