1 // RUN: mlir-opt %s -test-convert-func-op --split-input-file | FileCheck %s
3 // CHECK-LABEL: llvm.func @add
4 func.func @add(%arg0: i32, %arg1: i32) -> i32 attributes { llvm.emit_c_interface } {
5 %res = arith.addi %arg0, %arg1 : i32
8 // CHECK-LABEL: llvm.func @_mlir_ciface_add
9 // CHECK-SAME: [[ARG0:%[a-zA-Z0-9_]+]]: i32
10 // CHECK-SAME: [[ARG1:%[a-zA-Z0-9_]+]]: i32
11 // CHECK-NEXT: [[RES:%.*]] = llvm.call @add([[ARG0]], [[ARG1]])
12 // CHECK-NEXT: llvm.return [[RES]]
16 // Test that `llvm.byval` arguments are converted to `llvm.ptr` and the actual
17 // value is retrieved within the `llvm.func`.
19 // CHECK-LABEL: llvm.func @byval
20 func.func @byval(%arg0: !test.smpla {llvm.byval = !test.smpla}) -> !test.smpla {
21 return %arg0 : !test.smpla
24 // CHECK-SAME: (%[[ARG0:.*]]: !llvm.ptr {llvm.byval = !llvm.struct<(i8, i8)>}) -> !llvm.struct<(i8, i8)>
25 // CHECK: %[[LD:.*]] = llvm.load %[[ARG0]] : !llvm.ptr -> !llvm.struct<(i8, i8)>
26 // CHECK: llvm.return %[[LD]] : !llvm.struct<(i8, i8)>
30 // Test that `llvm.byref` arguments are converted to `llvm.ptr` and the actual
31 // value is retrieved within the `llvm.func`.
33 // CHECK-LABEL: llvm.func @byref
34 func.func @byref(%arg0: !test.smpla {llvm.byref = !test.smpla}) -> !test.smpla {
35 return %arg0 : !test.smpla
38 // CHECK-SAME: (%[[ARG0:.*]]: !llvm.ptr {llvm.byref = !llvm.struct<(i8, i8)>}) -> !llvm.struct<(i8, i8)>
39 // CHECK: %[[LD:.*]] = llvm.load %[[ARG0]] : !llvm.ptr -> !llvm.struct<(i8, i8)>
40 // CHECK: llvm.return %[[LD]] : !llvm.struct<(i8, i8)>