2022-11-15 23:25:39 +08:00
|
|
|
// RUN: torch-mlir-opt %s -refback-munge-calling-conventions -split-input-file -verify-diagnostics | FileCheck %s
|
2021-09-23 00:55:09 +08:00
|
|
|
|
2022-05-17 03:54:35 +08:00
|
|
|
// CHECK-LABEL: func.func @f(
|
2021-09-23 00:55:09 +08:00
|
|
|
// CHECK-SAME: %[[ARG0:.*]]: memref<*xf32>) attributes {llvm.emit_c_interface} {
|
|
|
|
// CHECK: %[[VAL:.*]] = memref.cast %[[ARG0]] : memref<*xf32> to memref<?xf32>
|
|
|
|
// CHECK: %[[RESULT:.*]] = memref.cast %[[VAL]] : memref<?xf32> to memref<*xf32>
|
2021-11-08 23:56:40 +08:00
|
|
|
// CHECK: call @refbackend_consume_func_return_mrf32(%[[RESULT]]) : (memref<*xf32>) -> ()
|
2021-09-23 00:55:09 +08:00
|
|
|
// CHECK: return
|
2022-05-17 03:54:35 +08:00
|
|
|
func.func @f(%arg0: memref<?xf32>) -> memref<?xf32> {
|
2021-09-23 00:55:09 +08:00
|
|
|
return %arg0 : memref<?xf32>
|
|
|
|
}
|
2021-10-05 10:06:59 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2022-05-17 03:54:35 +08:00
|
|
|
// CHECK-LABEL: func.func @i(
|
2021-10-05 10:06:59 +08:00
|
|
|
// CHECK-SAME: %[[ARG0:.*]]: memref<*xi64>) attributes {llvm.emit_c_interface} {
|
|
|
|
// CHECK: %[[VAL:.*]] = memref.cast %[[ARG0]] : memref<*xi64> to memref<?xi64>
|
|
|
|
// CHECK: %[[RESULT:.*]] = memref.cast %[[VAL]] : memref<?xi64> to memref<*xi64>
|
2021-11-08 23:56:40 +08:00
|
|
|
// CHECK: call @refbackend_consume_func_return_mri64(%[[RESULT]]) : (memref<*xi64>) -> ()
|
2021-10-05 10:06:59 +08:00
|
|
|
// CHECK: return
|
2022-05-17 03:54:35 +08:00
|
|
|
func.func @i(%arg0: memref<?xi64>) -> memref<?xi64> {
|
2021-10-05 10:06:59 +08:00
|
|
|
return %arg0 : memref<?xi64>
|
|
|
|
}
|
2021-11-07 03:25:06 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2022-05-17 03:54:35 +08:00
|
|
|
// CHECK-LABEL: func.func @elemental_type(
|
2021-11-07 03:25:06 +08:00
|
|
|
// CHECK-SAME: %[[ARG0:.*]]: memref<*xi64>) attributes {llvm.emit_c_interface} {
|
|
|
|
// CHECK: %[[VAL:.*]] = memref.cast %[[ARG0]] : memref<*xi64> to memref<i64>
|
|
|
|
// CHECK: %[[RESULT:.*]] = memref.load %[[VAL]][] : memref<i64>
|
2021-11-08 23:56:40 +08:00
|
|
|
// CHECK: call @refbackend_consume_func_return_i64(%[[RESULT]]) : (i64) -> ()
|
2021-11-07 03:25:06 +08:00
|
|
|
// CHECK: return
|
2022-05-17 03:54:35 +08:00
|
|
|
func.func @elemental_type(%arg0: memref<i64>) -> i64 {
|
2021-11-07 03:25:06 +08:00
|
|
|
%0 = memref.load %arg0[] : memref<i64>
|
|
|
|
return %0 : i64
|
|
|
|
}
|
2021-11-08 23:56:40 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2022-05-17 03:54:35 +08:00
|
|
|
// CHECK-LABEL: func.func @multiple_return_values(
|
2021-11-08 23:56:40 +08:00
|
|
|
// CHECK-SAME: %[[ARG0:.*]]: memref<*xf32>, %[[ARG1:.*]]: memref<*xf32>,
|
|
|
|
// CHECK-SAME: %[[ARG2:.*]]: memref<*xf32>) attributes {llvm.emit_c_interface} {
|
|
|
|
// CHECK: %[[VAL0:.*]] = memref.cast %[[ARG0]] : memref<*xf32> to memref<?xf32>
|
|
|
|
// CHECK: %[[VAL1:.*]] = memref.cast %[[ARG1]] : memref<*xf32> to memref<?xf32>
|
|
|
|
// CHECK: %[[VAL2:.*]] = memref.cast %[[ARG2]] : memref<*xf32> to memref<?xf32>
|
|
|
|
// CHECK: %[[RET0:.*]] = memref.cast %[[VAL0]] : memref<?xf32> to memref<*xf32>
|
|
|
|
// CHECK: %[[RET1:.*]] = memref.cast %[[VAL1]] : memref<?xf32> to memref<*xf32>
|
|
|
|
// CHECK: %[[RET2:.*]] = memref.cast %[[VAL2]] : memref<?xf32> to memref<*xf32>
|
|
|
|
// CHECK: call @refbackend_consume_func_return_mrf32_mrf32_mrf32(%[[RET0]], %[[RET1]], %[[RET2]])
|
|
|
|
// CHECK-SAME: : (memref<*xf32>, memref<*xf32>, memref<*xf32>) -> ()
|
|
|
|
// CHECK: return
|
|
|
|
|
2022-05-17 03:54:35 +08:00
|
|
|
func.func @multiple_return_values(%arg0: memref<?xf32>, %arg1: memref<?xf32>, %arg2: memref<?xf32>) -> (memref<?xf32>, memref<?xf32>, memref<?xf32>) {
|
2021-11-08 23:56:40 +08:00
|
|
|
return %arg0 ,%arg1, %arg2 : memref<?xf32>, memref<?xf32>, memref<?xf32>
|
|
|
|
}
|
2022-01-10 21:24:08 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2022-05-17 03:54:35 +08:00
|
|
|
// CHECK-LABEL: func.func @two_return_values(
|
2022-01-10 21:24:08 +08:00
|
|
|
// CHECK-SAME: %[[ARG0:.*]]: memref<*xf32>, %[[ARG1:.*]]: memref<*xi64>)
|
|
|
|
// CHECK-SAME: attributes {llvm.emit_c_interface} {
|
|
|
|
// CHECK: %[[VAL0:.*]] = memref.cast %[[ARG0]] : memref<*xf32> to memref<?xf32>
|
|
|
|
// CHECK: %[[VAL1:.*]] = memref.cast %[[ARG1]] : memref<*xi64> to memref<?xi64>
|
|
|
|
// CHECK: %[[RET0:.*]] = memref.cast %[[VAL0]] : memref<?xf32> to memref<*xf32>
|
|
|
|
// CHECK: %[[RET1:.*]] = memref.cast %[[VAL1]] : memref<?xi64> to memref<*xi64>
|
|
|
|
// CHECK: call @refbackend_consume_func_return_mrf32_mri64(%[[RET0]], %[[RET1]])
|
|
|
|
// CHECK-SAME: : (memref<*xf32>, memref<*xi64>) -> ()
|
|
|
|
// CHECK: return
|
|
|
|
|
2022-05-17 03:54:35 +08:00
|
|
|
func.func @two_return_values(%arg0: memref<?xf32>, %arg1: memref<?xi64>) -> (memref<?xf32>, memref<?xi64>) {
|
2022-01-10 21:24:08 +08:00
|
|
|
return %arg0 ,%arg1 : memref<?xf32>, memref<?xi64>
|
|
|
|
}
|
2022-11-15 23:25:39 +08:00
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
// expected-error-re @+1 {{argument must be a memref of {{.*}} but got 'tensor<?xf32>'}}
|
|
|
|
func.func @f(%arg0: tensor<?xf32>) {
|
|
|
|
return
|
|
|
|
}
|