Files
clang-p2996/mlir/test/Target/Cpp/invalid.mlir
Simon Camphausen e47b507562 [mlir][EmitC] Model lvalues as a type in EmitC (#91475)
This adds an `emitc.lvalue` type which models assignable lvlaues in the
type system. Operations modifying memory are restricted to this type
accordingly.

See also the discussion on
[discourse](https://discourse.llvm.org/t/rfc-separate-variables-from-ssa-values-in-emitc/75224/9).
The most notable changes are as follows.

- `emitc.variable` and `emitc.global` ops are restricted to return
`emitc.array` or `emitc.lvalue` types
- Taking the address of a value is restricted to operands with lvalue
type
- Conversion from lvalues into SSA values is done with the new
`emitc.load` op
- The var operand of the `emitc.assign` op is restricted to lvalue type 
- The result of the `emitc.subscript` and `emitc.get_global` ops is a
lvalue type
- The operands and results of the `emitc.member` and
`emitc.member_of_ptr` ops are restricted to lvalue types

---------

Co-authored-by: Matthias Gehre <matthias.gehre@amd.com>
2024-08-20 11:52:16 +02:00

96 lines
2.1 KiB
MLIR

// RUN: mlir-translate -split-input-file -mlir-to-cpp -verify-diagnostics %s
// expected-error@+1 {{'func.func' op with multiple blocks needs variables declared at top}}
func.func @multiple_blocks() {
^bb1:
cf.br ^bb2
^bb2:
return
}
// -----
func.func @unsupported_op(%arg0: i1) {
// expected-error@+1 {{'cf.assert' op unable to find printer for op}}
cf.assert %arg0, "assertion foo"
return
}
// -----
// expected-error@+1 {{cannot emit integer type 'i80'}}
func.func @unsupported_integer_type(%arg0 : i80) {
return
}
// -----
// expected-error@+1 {{cannot emit float type 'f80'}}
func.func @unsupported_float_type(%arg0 : f80) {
return
}
// -----
// expected-error@+1 {{cannot emit type 'memref<100xf32>'}}
func.func @memref_type(%arg0 : memref<100xf32>) {
return
}
// -----
// expected-error@+1 {{cannot emit type 'vector<100xf32>'}}
func.func @vector_type(%arg0 : vector<100xf32>) {
return
}
// -----
// expected-error@+1 {{cannot emit tensor type with non static shape}}
func.func @non_static_shape(%arg0 : tensor<?xf32>) {
return
}
// -----
// expected-error@+1 {{cannot emit unranked tensor type}}
func.func @unranked_tensor(%arg0 : tensor<*xf32>) {
return
}
// -----
// expected-error@+1 {{cannot emit tensor of array type}}
func.func @tensor_of_array(%arg0 : tensor<4x!emitc.array<4xf32>>) {
return
}
// -----
// expected-error@+1 {{cannot emit pointer to array type}}
func.func @pointer_to_array(%arg0 : !emitc.ptr<!emitc.array<4xf32>>) {
return
}
// -----
// expected-error@+1 {{cannot emit lvalue type as argument type}}
func.func @lvalue_as_argument(%arg: !emitc.lvalue<i8>) {
return
}
// -----
// expected-error@+1 {{cannot emit array type as result type}}
func.func @array_as_result(%arg: !emitc.array<4xi8>) -> (!emitc.array<4xi8>) {
return %arg : !emitc.array<4xi8>
}
// -----
func.func @ptr_to_array() {
// expected-error@+1 {{cannot emit pointer to array type '!emitc.ptr<!emitc.array<9xi16>>'}}
%v = "emitc.variable"(){value = #emitc.opaque<"NULL">} : () -> !emitc.lvalue<!emitc.ptr<!emitc.array<9xi16>>>
return
}