This models a one or multi-dimensional C/C++ array. The type implements the `ShapedTypeInterface` and prints similar to memref/tensor: ``` %arg0: !emitc.array<1xf32>, %arg1: !emitc.array<10x20x30xi32>, %arg2: !emitc.array<30x!emitc.ptr<i32>>, %arg3: !emitc.array<30x!emitc.opaque<"int">> ``` It can be translated to a C array type when used as function parameter or as `emitc.variable` type.
25 lines
704 B
MLIR
25 lines
704 B
MLIR
// RUN: mlir-translate -mlir-to-cpp %s | FileCheck %s
|
|
|
|
// CHECK: int32_t bar(int32_t [[V1:[^ ]*]]);
|
|
emitc.declare_func @bar
|
|
// CHECK: int32_t bar(int32_t [[V1:[^ ]*]]) {
|
|
emitc.func @bar(%arg0: i32) -> i32 {
|
|
emitc.return %arg0 : i32
|
|
}
|
|
|
|
|
|
// CHECK: static inline int32_t foo(int32_t [[V1:[^ ]*]]);
|
|
emitc.declare_func @foo
|
|
// CHECK: static inline int32_t foo(int32_t [[V1:[^ ]*]]) {
|
|
emitc.func @foo(%arg0: i32) -> i32 attributes {specifiers = ["static","inline"]} {
|
|
emitc.return %arg0 : i32
|
|
}
|
|
|
|
|
|
// CHECK: void array_arg(int32_t [[V2:[^ ]*]][3]);
|
|
emitc.declare_func @array_arg
|
|
// CHECK: void array_arg(int32_t [[V2:[^ ]*]][3]) {
|
|
emitc.func @array_arg(%arg0: !emitc.array<3xi32>) {
|
|
emitc.return
|
|
}
|