brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 45f38d4 Raw
50 lines · plain
1// RUN: mlir-opt -split-input-file -convert-complex-to-spirv %s | FileCheck %s2 3func.func @create_complex(%real: f32, %imag: f32) -> complex<f32> {4  %0 = complex.create %real, %imag : complex<f32>5  return %0 : complex<f32>6}7 8// CHECK-LABEL: func.func @create_complex9//  CHECK-SAME: (%[[RE:.+]]: f32, %[[IM:.+]]: f32)10//       CHECK:   %[[CC:.+]] = spirv.CompositeConstruct %[[RE]], %[[IM]] : (f32, f32) -> vector<2xf32>11//       CHECK:   %[[CAST:.+]] = builtin.unrealized_conversion_cast %[[CC]] : vector<2xf32> to complex<f32>12//       CHECK:   return %[[CAST]] : complex<f32>13 14 15// -----16 17func.func @real_number(%arg: complex<f32>) -> f32 {18  %real = complex.re %arg : complex<f32>19  return %real : f3220}21 22// CHECK-LABEL: func.func @real_number23//  CHECK-SAME: %[[ARG:.+]]: complex<f32>24//       CHECK:   %[[CAST:.+]] = builtin.unrealized_conversion_cast %[[ARG]] : complex<f32> to vector<2xf32>25//       CHECK:   %[[RE:.+]] = spirv.CompositeExtract %[[CAST]][0 : i32] : vector<2xf32>26//       CHECK:   return %[[RE]] : f3227 28// -----29 30func.func @imaginary_number(%arg: complex<f32>) -> f32 {31  %imaginary = complex.im %arg : complex<f32>32  return %imaginary: f3233}34 35// CHECK-LABEL: func.func @imaginary_number36//  CHECK-SAME: %[[ARG:.+]]: complex<f32>37//       CHECK:   %[[CAST:.+]] = builtin.unrealized_conversion_cast %[[ARG]] : complex<f32> to vector<2xf32>38//       CHECK:   %[[IM:.+]] = spirv.CompositeExtract %[[CAST]][1 : i32] : vector<2xf32>39//       CHECK:   return %[[IM]] : f3240 41// -----42 43func.func @complex_const() -> complex<f32> {44  %cst = complex.constant [0x7FC00000 : f32, 0.000000e+00 : f32] : complex<f32>45  return %cst : complex<f32>46}47 48// CHECK-LABEL: func.func @complex_const()49//       CHECK:   spirv.Constant dense<[0x7FC00000, 0.000000e+00]> : vector<2xf32>50