1// RUN: mlir-opt -convert-spirv-to-llvm %s | FileCheck %s 2 3//===----------------------------------------------------------------------===// 4// spv.constant 5//===----------------------------------------------------------------------===// 6 7// CHECK-LABEL: @bool_constant_scalar 8spv.func @bool_constant_scalar() "None" { 9 // CHECK: llvm.mlir.constant(true) : !llvm.i1 10 %0 = spv.constant true 11 // CHECK: llvm.mlir.constant(false) : !llvm.i1 12 %1 = spv.constant false 13 spv.Return 14} 15 16// CHECK-LABEL: @bool_constant_vector 17spv.func @bool_constant_vector() "None" { 18 // CHECK: llvm.mlir.constant(dense<[true, false]> : vector<2xi1>) : !llvm.vec<2 x i1> 19 %0 = spv.constant dense<[true, false]> : vector<2xi1> 20 // CHECK: llvm.mlir.constant(dense<false> : vector<3xi1>) : !llvm.vec<3 x i1> 21 %1 = spv.constant dense<false> : vector<3xi1> 22 spv.Return 23} 24 25// CHECK-LABEL: @integer_constant_scalar 26spv.func @integer_constant_scalar() "None" { 27 // CHECK: llvm.mlir.constant(0 : i8) : !llvm.i8 28 %0 = spv.constant 0 : i8 29 // CHECK: llvm.mlir.constant(-5 : i64) : !llvm.i64 30 %1 = spv.constant -5 : si64 31 // CHECK: llvm.mlir.constant(10 : i16) : !llvm.i16 32 %2 = spv.constant 10 : ui16 33 spv.Return 34} 35 36// CHECK-LABEL: @integer_constant_vector 37spv.func @integer_constant_vector() "None" { 38 // CHECK: llvm.mlir.constant(dense<[2, 3]> : vector<2xi32>) : !llvm.vec<2 x i32> 39 %0 = spv.constant dense<[2, 3]> : vector<2xi32> 40 // CHECK: llvm.mlir.constant(dense<-4> : vector<2xi32>) : !llvm.vec<2 x i32> 41 %1 = spv.constant dense<-4> : vector<2xsi32> 42 // CHECK: llvm.mlir.constant(dense<[2, 3, 4]> : vector<3xi32>) : !llvm.vec<3 x i32> 43 %2 = spv.constant dense<[2, 3, 4]> : vector<3xui32> 44 spv.Return 45} 46 47// CHECK-LABEL: @float_constant_scalar 48spv.func @float_constant_scalar() "None" { 49 // CHECK: llvm.mlir.constant(5.000000e+00 : f16) : !llvm.half 50 %0 = spv.constant 5.000000e+00 : f16 51 // CHECK: llvm.mlir.constant(5.000000e+00 : f64) : !llvm.double 52 %1 = spv.constant 5.000000e+00 : f64 53 spv.Return 54} 55 56// CHECK-LABEL: @float_constant_vector 57spv.func @float_constant_vector() "None" { 58 // CHECK: llvm.mlir.constant(dense<[2.000000e+00, 3.000000e+00]> : vector<2xf32>) : !llvm.vec<2 x float> 59 %0 = spv.constant dense<[2.000000e+00, 3.000000e+00]> : vector<2xf32> 60 spv.Return 61} 62