This upstreams the EmitC dialect and the corresponding Cpp target, both initially presented with [1], from [2] to MLIR core. For the related discussion, see [3]. [1] https://reviews.llvm.org/D76571 [2] https://github.com/iml130/mlir-emitc [3] https://llvm.discourse.group/t/emitc-generating-c-c-from-mlir/3388 Co-authored-by: Jacques Pienaar <jpienaar@google.com> Co-authored-by: Simon Camphausen <simon.camphausen@iml.fraunhofer.de> Co-authored-by: Oliver Scherf <oliver.scherf@iml.fraunhofer.de> Reviewed By: rriddle Differential Revision: https://reviews.llvm.org/D103969
80 lines
2.3 KiB
MLIR
80 lines
2.3 KiB
MLIR
// RUN: mlir-opt %s -split-input-file -verify-diagnostics
|
|
|
|
func @const_attribute_return_type_1() {
|
|
// expected-error @+1 {{'emitc.constant' op requires attribute's type ('i64') to match op's return type ('i32')}}
|
|
%c0 = "emitc.constant"(){value = 42: i64} : () -> i32
|
|
return
|
|
}
|
|
|
|
// -----
|
|
|
|
func @const_attribute_return_type_2() {
|
|
// expected-error @+1 {{'emitc.constant' op requires attribute's type ('!emitc.opaque<"int32_t*">') to match op's return type ('!emitc.opaque<"int32_t">')}}
|
|
%c0 = "emitc.constant"(){value = "nullptr" : !emitc.opaque<"int32_t*">} : () -> !emitc.opaque<"int32_t">
|
|
return
|
|
}
|
|
|
|
// -----
|
|
|
|
func @index_args_out_of_range_1() {
|
|
// expected-error @+1 {{'emitc.call' op index argument is out of range}}
|
|
emitc.call "test" () {args = [0 : index]} : () -> ()
|
|
return
|
|
}
|
|
|
|
// -----
|
|
|
|
func @index_args_out_of_range_2(%arg : i32) {
|
|
// expected-error @+1 {{'emitc.call' op index argument is out of range}}
|
|
emitc.call "test" (%arg, %arg) {args = [2 : index]} : (i32, i32) -> ()
|
|
return
|
|
}
|
|
|
|
// -----
|
|
|
|
func @empty_callee() {
|
|
// expected-error @+1 {{'emitc.call' op callee must not be empty}}
|
|
emitc.call "" () : () -> ()
|
|
return
|
|
}
|
|
|
|
// -----
|
|
|
|
func @nonetype_arg(%arg : i32) {
|
|
// expected-error @+1 {{'emitc.call' op array argument has no type}}
|
|
emitc.call "nonetype_arg"(%arg) {args = [0 : index, [0, 1, 2]]} : (i32) -> i32
|
|
return
|
|
}
|
|
|
|
// -----
|
|
|
|
func @array_template_arg(%arg : i32) {
|
|
// expected-error @+1 {{'emitc.call' op template argument has invalid type}}
|
|
emitc.call "nonetype_template_arg"(%arg) {template_args = [[0, 1, 2]]} : (i32) -> i32
|
|
return
|
|
}
|
|
|
|
// -----
|
|
|
|
func @dense_template_argument(%arg : i32) {
|
|
// expected-error @+1 {{'emitc.call' op template argument has invalid type}}
|
|
emitc.call "dense_template_argument"(%arg) {template_args = [dense<[1.0, 1.0]> : tensor<2xf32>]} : (i32) -> i32
|
|
return
|
|
}
|
|
|
|
// -----
|
|
|
|
func @empty_operator(%arg : i32) {
|
|
// expected-error @+1 {{'emitc.apply' op applicable operator must not be empty}}
|
|
%2 = emitc.apply ""(%arg) : (i32) -> !emitc.opaque<"int32_t*">
|
|
return
|
|
}
|
|
|
|
// -----
|
|
|
|
func @illegal_operator(%arg : i32) {
|
|
// expected-error @+1 {{'emitc.apply' op applicable operator is illegal}}
|
|
%2 = emitc.apply "+"(%arg) : (i32) -> !emitc.opaque<"int32_t*">
|
|
return
|
|
}
|