41 lines · plain
1// RUN: mlir-opt %s -test-convert-func-op --split-input-file | FileCheck %s2 3// CHECK-LABEL: llvm.func @add4func.func @add(%arg0: i32, %arg1: i32) -> i32 attributes { llvm.emit_c_interface } {5 %res = arith.addi %arg0, %arg1 : i326 return %res : i327}8// CHECK-LABEL: llvm.func @_mlir_ciface_add9// CHECK-SAME: [[ARG0:%[a-zA-Z0-9_]+]]: i3210// CHECK-SAME: [[ARG1:%[a-zA-Z0-9_]+]]: i3211// CHECK-NEXT: [[RES:%.*]] = llvm.call @add([[ARG0]], [[ARG1]])12// CHECK-NEXT: llvm.return [[RES]]13 14// -----15 16// Test that `llvm.byval` arguments are converted to `llvm.ptr` and the actual17// value is retrieved within the `llvm.func`.18 19// CHECK-LABEL: llvm.func @byval20func.func @byval(%arg0: !test.smpla {llvm.byval = !test.smpla}) -> !test.smpla {21 return %arg0 : !test.smpla22}23 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)>27 28// -----29 30// Test that `llvm.byref` arguments are converted to `llvm.ptr` and the actual31// value is retrieved within the `llvm.func`.32 33// CHECK-LABEL: llvm.func @byref34func.func @byref(%arg0: !test.smpla {llvm.byref = !test.smpla}) -> !test.smpla {35 return %arg0 : !test.smpla36}37 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)>41