| 1 |
; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV |
| 2 |
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %} |
| 3 |
|
| 4 |
%i8struct = type {i8, i8} |
| 5 |
%i16struct = type {i16, i16} |
| 6 |
%i32struct = type {i32, i32} |
| 7 |
%i64struct = type {i64, i64} |
| 8 |
%vecstruct = type {<4 x i32>, <4 x i32>} |
| 9 |
|
| 10 |
; CHECK-SPIRV-DAG: [[uchar:%[a-z0-9_]+]] = OpTypeInt 8 |
| 11 |
; CHECK-SPIRV-DAG: [[ushort:%[a-z0-9_]+]] = OpTypeInt 16 |
| 12 |
; CHECK-SPIRV-DAG: [[uint:%[a-z0-9_]+]] = OpTypeInt 32 |
| 13 |
; CHECK-SPIRV-DAG: [[ulong:%[a-z0-9_]+]] = OpTypeInt 64 |
| 14 |
; CHECK-SPIRV-DAG: [[void:%[a-z0-9_]+]] = OpTypeVoid |
| 15 |
; CHECK-SPIRV-DAG: [[i8struct:%[a-z0-9_]+]] = OpTypeStruct [[uchar]] [[uchar]] |
| 16 |
; CHECK-SPIRV-DAG: [[_ptr_Function_i8struct:%[a-z0-9_]+]] = OpTypePointer Function [[i8struct]] |
| 17 |
; CHECK-SPIRV-DAG: [[i16struct:%[a-z0-9_]+]] = OpTypeStruct [[ushort]] [[ushort]] |
| 18 |
; CHECK-SPIRV-DAG: [[_ptr_Function_i16struct:%[a-z0-9_]+]] = OpTypePointer Function [[i16struct]] |
| 19 |
; CHECK-SPIRV-DAG: [[i32struct:%[a-z0-9_]+]] = OpTypeStruct [[uint]] [[uint]] |
| 20 |
; CHECK-SPIRV-DAG: [[_ptr_Function_i32struct:%[a-z0-9_]+]] = OpTypePointer Function [[i32struct]] |
| 21 |
; CHECK-SPIRV-DAG: [[i64struct:%[a-z0-9_]+]] = OpTypeStruct [[ulong]] [[ulong]] |
| 22 |
; CHECK-SPIRV-DAG: [[_ptr_Function_i64struct:%[a-z0-9_]+]] = OpTypePointer Function [[i64struct]] |
| 23 |
; CHECK-SPIRV-DAG: [[v4uint:%[a-z0-9_]+]] = OpTypeVector [[uint]] 4 |
| 24 |
; CHECK-SPIRV-DAG: [[vecstruct:%[a-z0-9_]+]] = OpTypeStruct [[v4uint]] [[v4uint]] |
| 25 |
; CHECK-SPIRV-DAG: [[_ptr_Function_vecstruct:%[a-z0-9_]+]] = OpTypePointer Function [[vecstruct]] |
| 26 |
; CHECK-SPIRV-DAG: [[_ptr_Generic_i32struct:%[a-z0-9_]+]] = OpTypePointer Generic [[i32struct]] |
| 27 |
|
| 28 |
define spir_func void @test_builtin_isubborrowcc(i8 %a, i8 %b) { |
| 29 |
entry: |
| 30 |
%0 = alloca %i8struct |
| 31 |
call void @_Z18__spirv_ISubBorrowcc(ptr sret (%i8struct) %0, i8 %a, i8 %b) |
| 32 |
ret void |
| 33 |
} |
| 34 |
; CHECK-SPIRV: [[a:%[a-z0-9_]+]] = OpFunctionParameter [[uchar]] |
| 35 |
; CHECK-SPIRV: [[b:%[a-z0-9_]+]] = OpFunctionParameter [[uchar]] |
| 36 |
; CHECK-SPIRV: [[entry:%[a-z0-9_]+]] = OpLabel |
| 37 |
; CHECK-SPIRV: [[var_11:%[a-z0-9_]+]] = OpVariable [[_ptr_Function_i8struct]] Function |
| 38 |
; CHECK-SPIRV: [[var_12:%[a-z0-9_]+]] = OpISubBorrow [[i8struct]] [[a]] [[b]] |
| 39 |
; CHECK-SPIRV: OpStore [[var_11]] [[var_12]] |
| 40 |
; CHECK-SPIRV: OpReturn |
| 41 |
; CHECK-SPIRV: OpFunctionEnd |
| 42 |
|
| 43 |
define spir_func void @test_builtin_isubborrowss(i16 %a, i16 %b) { |
| 44 |
entry: |
| 45 |
%0 = alloca %i16struct |
| 46 |
call void @_Z18__spirv_ISubBorrowss(ptr sret (%i16struct) %0, i16 %a, i16 %b) |
| 47 |
ret void |
| 48 |
} |
| 49 |
; CHECK-SPIRV: [[a_0:%[a-z0-9_]+]] = OpFunctionParameter [[ushort]] |
| 50 |
; CHECK-SPIRV: [[b_0:%[a-z0-9_]+]] = OpFunctionParameter [[ushort]] |
| 51 |
; CHECK-SPIRV: [[entry_0:%[a-z0-9_]+]] = OpLabel |
| 52 |
; CHECK-SPIRV: [[var_21:%[a-z0-9_]+]] = OpVariable [[_ptr_Function_i16struct]] Function |
| 53 |
; CHECK-SPIRV: [[var_22:%[a-z0-9_]+]] = OpISubBorrow [[i16struct]] [[a_0]] [[b_0]] |
| 54 |
; CHECK-SPIRV: OpStore [[var_21]] [[var_22]] |
| 55 |
; CHECK-SPIRV: OpReturn |
| 56 |
; CHECK-SPIRV: OpFunctionEnd |
| 57 |
|
| 58 |
define spir_func void @test_builtin_isubborrowii(i32 %a, i32 %b) { |
| 59 |
entry: |
| 60 |
%0 = alloca %i32struct |
| 61 |
call void @_Z18__spirv_ISubBorrowii(ptr sret (%i32struct) %0, i32 %a, i32 %b) |
| 62 |
ret void |
| 63 |
} |
| 64 |
; CHECK-SPIRV: [[a_1:%[a-z0-9_]+]] = OpFunctionParameter [[uint]] |
| 65 |
; CHECK-SPIRV: [[b_1:%[a-z0-9_]+]] = OpFunctionParameter [[uint]] |
| 66 |
; CHECK-SPIRV: [[entry_1:%[a-z0-9_]+]] = OpLabel |
| 67 |
; CHECK-SPIRV: [[var_31:%[a-z0-9_]+]] = OpVariable [[_ptr_Function_i32struct]] Function |
| 68 |
; CHECK-SPIRV: [[var_32:%[a-z0-9_]+]] = OpISubBorrow [[i32struct]] [[a_1]] [[b_1]] |
| 69 |
; CHECK-SPIRV: OpStore [[var_31]] [[var_32]] |
| 70 |
; CHECK-SPIRV: OpReturn |
| 71 |
; CHECK-SPIRV: OpFunctionEnd |
| 72 |
|
| 73 |
define spir_func void @test_builtin_isubborrowll(i64 %a, i64 %b) { |
| 74 |
entry: |
| 75 |
%0 = alloca %i64struct |
| 76 |
call void @_Z18__spirv_ISubBorrowll(ptr sret (%i64struct) %0, i64 %a, i64 %b) |
| 77 |
ret void |
| 78 |
} |
| 79 |
; CHECK-SPIRV: [[a_2:%[a-z0-9_]+]] = OpFunctionParameter [[ulong]] |
| 80 |
; CHECK-SPIRV: [[b_2:%[a-z0-9_]+]] = OpFunctionParameter [[ulong]] |
| 81 |
; CHECK-SPIRV: [[entry_2:%[a-z0-9_]+]] = OpLabel |
| 82 |
; CHECK-SPIRV: [[var_41:%[a-z0-9_]+]] = OpVariable [[_ptr_Function_i64struct]] Function |
| 83 |
; CHECK-SPIRV: [[var_42:%[a-z0-9_]+]] = OpISubBorrow [[i64struct]] [[a_2]] [[b_2]] |
| 84 |
; CHECK-SPIRV: OpStore [[var_41]] [[var_42]] |
| 85 |
; CHECK-SPIRV: OpReturn |
| 86 |
; CHECK-SPIRV: OpFunctionEnd |
| 87 |
|
| 88 |
define spir_func void @test_builtin_isubborrowDv4_xS_(<4 x i32> %a, <4 x i32> %b) { |
| 89 |
entry: |
| 90 |
%0 = alloca %vecstruct |
| 91 |
call void @_Z18__spirv_ISubBorrowDv4_iS_(ptr sret (%vecstruct) %0, <4 x i32> %a, <4 x i32> %b) |
| 92 |
ret void |
| 93 |
} |
| 94 |
; CHECK-SPIRV: [[a_3:%[a-z0-9_]+]] = OpFunctionParameter [[v4uint]] |
| 95 |
; CHECK-SPIRV: [[b_3:%[a-z0-9_]+]] = OpFunctionParameter [[v4uint]] |
| 96 |
; CHECK-SPIRV: [[entry_3:%[a-z0-9_]+]] = OpLabel |
| 97 |
; CHECK-SPIRV: [[var_51:%[a-z0-9_]+]] = OpVariable [[_ptr_Function_vecstruct]] Function |
| 98 |
; CHECK-SPIRV: [[var_52:%[a-z0-9_]+]] = OpISubBorrow [[vecstruct]] [[a_3]] [[b_3]] |
| 99 |
; CHECK-SPIRV: OpStore [[var_51]] [[var_52]] |
| 100 |
; CHECK-SPIRV: OpReturn |
| 101 |
; CHECK-SPIRV: OpFunctionEnd |
| 102 |
|
| 103 |
%struct.anon = type { i32, i32 } |
| 104 |
|
| 105 |
define spir_func void @test_builtin_isubborrow_anon(i32 %a, i32 %b) { |
| 106 |
entry: |
| 107 |
%0 = alloca %struct.anon |
| 108 |
%1 = addrspacecast ptr %0 to ptr addrspace(4) |
| 109 |
call spir_func void @_Z18__spirv_ISubBorrowIiiE4anonIT_T0_ES1_S2_(ptr addrspace(4) sret(%struct.anon) align 4 %1, i32 %a, i32 %b) |
| 110 |
ret void |
| 111 |
} |
| 112 |
; CHECK-SPIRV: [[a_4:%[a-z0-9_]+]] = OpFunctionParameter [[uint]] |
| 113 |
; CHECK-SPIRV: [[b_4:%[a-z0-9_]+]] = OpFunctionParameter [[uint]] |
| 114 |
; CHECK-SPIRV: [[entry_4:%[a-z0-9_]+]] = OpLabel |
| 115 |
; CHECK-SPIRV: [[var_59:%[a-z0-9_]+]] = OpVariable [[_ptr_Function_i32struct]] Function |
| 116 |
; CHECK-SPIRV: [[var_61:%[a-z0-9_]+]] = OpPtrCastToGeneric [[_ptr_Generic_i32struct]] [[var_59]] |
| 117 |
; CHECK-SPIRV: [[var_62:%[a-z0-9_]+]] = OpISubBorrow [[i32struct]] [[a_4]] [[b_4]] |
| 118 |
; CHECK-SPIRV: OpStore [[var_61]] [[var_62]] |
| 119 |
|
| 120 |
declare void @_Z18__spirv_ISubBorrowIiiE4anonIT_T0_ES1_S2_(ptr addrspace(4) sret(%struct.anon) align 4, i32, i32) |
| 121 |
declare void @_Z18__spirv_ISubBorrowcc(ptr sret(%i8struct), i8, i8) |
| 122 |
declare void @_Z18__spirv_ISubBorrowss(ptr sret(%i16struct), i16, i16) |
| 123 |
declare void @_Z18__spirv_ISubBorrowii(ptr sret(%i32struct), i32, i32) |
| 124 |
declare void @_Z18__spirv_ISubBorrowll(ptr sret(%i64struct), i64, i64) |
| 125 |
declare void @_Z18__spirv_ISubBorrowDv4_iS_(ptr sret (%vecstruct), <4 x i32>, <4 x i32>) |