1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
|
// RUN: mlir-opt -convert-spirv-to-llvm='use-opaque-pointers=1' %s | FileCheck %s
//===----------------------------------------------------------------------===//
// spirv.Bitcast
//===----------------------------------------------------------------------===//
// CHECK-LABEL: @bitcast_float_to_integer_scalar
spirv.func @bitcast_float_to_integer_scalar(%arg0 : f32) "None" {
// CHECK: llvm.bitcast {{.*}} : f32 to i32
%0 = spirv.Bitcast %arg0: f32 to i32
spirv.Return
}
// CHECK-LABEL: @bitcast_float_to_integer_vector
spirv.func @bitcast_float_to_integer_vector(%arg0 : vector<3xf32>) "None" {
// CHECK: {{.*}} = llvm.bitcast {{.*}} : vector<3xf32> to vector<3xi32>
%0 = spirv.Bitcast %arg0: vector<3xf32> to vector<3xi32>
spirv.Return
}
// CHECK-LABEL: @bitcast_vector_to_scalar
spirv.func @bitcast_vector_to_scalar(%arg0 : vector<2xf32>) "None" {
// CHECK: {{.*}} = llvm.bitcast {{.*}} : vector<2xf32> to i64
%0 = spirv.Bitcast %arg0: vector<2xf32> to i64
spirv.Return
}
// CHECK-LABEL: @bitcast_scalar_to_vector
spirv.func @bitcast_scalar_to_vector(%arg0 : f64) "None" {
// CHECK: {{.*}} = llvm.bitcast {{.*}} : f64 to vector<2xi32>
%0 = spirv.Bitcast %arg0: f64 to vector<2xi32>
spirv.Return
}
// CHECK-LABEL: @bitcast_vector_to_vector
spirv.func @bitcast_vector_to_vector(%arg0 : vector<4xf32>) "None" {
// CHECK: {{.*}} = llvm.bitcast {{.*}} : vector<4xf32> to vector<2xi64>
%0 = spirv.Bitcast %arg0: vector<4xf32> to vector<2xi64>
spirv.Return
}
// CHECK-LABEL: @bitcast_pointer
spirv.func @bitcast_pointer(%arg0: !spirv.ptr<f32, Function>) "None" {
// CHECK-NOT: llvm.bitcast
%0 = spirv.Bitcast %arg0 : !spirv.ptr<f32, Function> to !spirv.ptr<i32, Function>
spirv.Return
}
//===----------------------------------------------------------------------===//
// spirv.ConvertFToS
//===----------------------------------------------------------------------===//
// CHECK-LABEL: @convert_float_to_signed_scalar
spirv.func @convert_float_to_signed_scalar(%arg0: f32) "None" {
// CHECK: llvm.fptosi %{{.*}} : f32 to i32
%0 = spirv.ConvertFToS %arg0: f32 to i32
spirv.Return
}
// CHECK-LABEL: @convert_float_to_signed_vector
spirv.func @convert_float_to_signed_vector(%arg0: vector<2xf32>) "None" {
// CHECK: llvm.fptosi %{{.*}} : vector<2xf32> to vector<2xi32>
%0 = spirv.ConvertFToS %arg0: vector<2xf32> to vector<2xi32>
spirv.Return
}
//===----------------------------------------------------------------------===//
// spirv.ConvertFToU
//===----------------------------------------------------------------------===//
// CHECK-LABEL: @convert_float_to_unsigned_scalar
spirv.func @convert_float_to_unsigned_scalar(%arg0: f32) "None" {
// CHECK: llvm.fptoui %{{.*}} : f32 to i32
%0 = spirv.ConvertFToU %arg0: f32 to i32
spirv.Return
}
// CHECK-LABEL: @convert_float_to_unsigned_vector
spirv.func @convert_float_to_unsigned_vector(%arg0: vector<2xf32>) "None" {
// CHECK: llvm.fptoui %{{.*}} : vector<2xf32> to vector<2xi32>
%0 = spirv.ConvertFToU %arg0: vector<2xf32> to vector<2xi32>
spirv.Return
}
//===----------------------------------------------------------------------===//
// spirv.ConvertSToF
//===----------------------------------------------------------------------===//
// CHECK-LABEL: @convert_signed_to_float_scalar
spirv.func @convert_signed_to_float_scalar(%arg0: i32) "None" {
// CHECK: llvm.sitofp %{{.*}} : i32 to f32
%0 = spirv.ConvertSToF %arg0: i32 to f32
spirv.Return
}
// CHECK-LABEL: @convert_signed_to_float_vector
spirv.func @convert_signed_to_float_vector(%arg0: vector<3xi32>) "None" {
// CHECK: llvm.sitofp %{{.*}} : vector<3xi32> to vector<3xf32>
%0 = spirv.ConvertSToF %arg0: vector<3xi32> to vector<3xf32>
spirv.Return
}
//===----------------------------------------------------------------------===//
// spirv.ConvertUToF
//===----------------------------------------------------------------------===//
// CHECK-LABEL: @convert_unsigned_to_float_scalar
spirv.func @convert_unsigned_to_float_scalar(%arg0: i32) "None" {
// CHECK: llvm.uitofp %{{.*}} : i32 to f32
%0 = spirv.ConvertUToF %arg0: i32 to f32
spirv.Return
}
// CHECK-LABEL: @convert_unsigned_to_float_vector
spirv.func @convert_unsigned_to_float_vector(%arg0: vector<3xi32>) "None" {
// CHECK: llvm.uitofp %{{.*}} : vector<3xi32> to vector<3xf32>
%0 = spirv.ConvertUToF %arg0: vector<3xi32> to vector<3xf32>
spirv.Return
}
//===----------------------------------------------------------------------===//
// spirv.FConvert
//===----------------------------------------------------------------------===//
// CHECK-LABEL: @fconvert_scalar
spirv.func @fconvert_scalar(%arg0: f32, %arg1: f64) "None" {
// CHECK: llvm.fpext %{{.*}} : f32 to f64
%0 = spirv.FConvert %arg0: f32 to f64
// CHECK: llvm.fptrunc %{{.*}} : f64 to f32
%1 = spirv.FConvert %arg1: f64 to f32
spirv.Return
}
// CHECK-LABEL: @fconvert_vector
spirv.func @fconvert_vector(%arg0: vector<2xf32>, %arg1: vector<2xf64>) "None" {
// CHECK: llvm.fpext %{{.*}} : vector<2xf32> to vector<2xf64>
%0 = spirv.FConvert %arg0: vector<2xf32> to vector<2xf64>
// CHECK: llvm.fptrunc %{{.*}} : vector<2xf64> to vector<2xf32>
%1 = spirv.FConvert %arg1: vector<2xf64> to vector<2xf32>
spirv.Return
}
//===----------------------------------------------------------------------===//
// spirv.SConvert
//===----------------------------------------------------------------------===//
// CHECK-LABEL: @sconvert_scalar
spirv.func @sconvert_scalar(%arg0: i32, %arg1: i64) "None" {
// CHECK: llvm.sext %{{.*}} : i32 to i64
%0 = spirv.SConvert %arg0: i32 to i64
// CHECK: llvm.trunc %{{.*}} : i64 to i32
%1 = spirv.SConvert %arg1: i64 to i32
spirv.Return
}
// CHECK-LABEL: @sconvert_vector
spirv.func @sconvert_vector(%arg0: vector<3xi32>, %arg1: vector<3xi64>) "None" {
// CHECK: llvm.sext %{{.*}} : vector<3xi32> to vector<3xi64>
%0 = spirv.SConvert %arg0: vector<3xi32> to vector<3xi64>
// CHECK: llvm.trunc %{{.*}} : vector<3xi64> to vector<3xi32>
%1 = spirv.SConvert %arg1: vector<3xi64> to vector<3xi32>
spirv.Return
}
//===----------------------------------------------------------------------===//
// spirv.UConvert
//===----------------------------------------------------------------------===//
// CHECK-LABEL: @uconvert_scalar
spirv.func @uconvert_scalar(%arg0: i32, %arg1: i64) "None" {
// CHECK: llvm.zext %{{.*}} : i32 to i64
%0 = spirv.UConvert %arg0: i32 to i64
// CHECK: llvm.trunc %{{.*}} : i64 to i32
%1 = spirv.UConvert %arg1: i64 to i32
spirv.Return
}
// CHECK-LABEL: @uconvert_vector
spirv.func @uconvert_vector(%arg0: vector<3xi32>, %arg1: vector<3xi64>) "None" {
// CHECK: llvm.zext %{{.*}} : vector<3xi32> to vector<3xi64>
%0 = spirv.UConvert %arg0: vector<3xi32> to vector<3xi64>
// CHECK: llvm.trunc %{{.*}} : vector<3xi64> to vector<3xi32>
%1 = spirv.UConvert %arg1: vector<3xi64> to vector<3xi32>
spirv.Return
}
|