2021-11-02 16:53:18 +01:00
|
|
|
// Test FIR to LLVM IR conversion invalid cases and diagnostics.
|
|
|
|
|
2021-11-09 14:26:40 +01:00
|
|
|
// RUN: fir-opt --split-input-file --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" --verify-diagnostics %s
|
2021-11-02 16:53:18 +01:00
|
|
|
|
2021-11-17 10:34:38 +01:00
|
|
|
|
|
|
|
// Test `fir.shape` conversion failure because the op has uses.
|
|
|
|
|
2022-04-20 21:39:22 -07:00
|
|
|
func.func @shape_not_dead(%arg0: !fir.ref<!fir.array<?x?xf32>>, %i: index, %j: index) {
|
2021-11-17 10:34:38 +01:00
|
|
|
%c0 = arith.constant 1 : index
|
|
|
|
// expected-error@+1{{failed to legalize operation 'fir.shape'}}
|
|
|
|
%0 = fir.shape %c0, %c0 : (index, index) -> !fir.shape<2>
|
|
|
|
%1 = fir.array_coor %arg0(%0) %i, %j : (!fir.ref<!fir.array<?x?xf32>>, !fir.shape<2>, index, index) -> !fir.ref<f32>
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
// Test `fir.slice` conversion failure because the op has uses.
|
|
|
|
|
2022-04-20 21:39:22 -07:00
|
|
|
func.func @slice_not_dead(%arg0: !fir.ref<!fir.array<?x?xf32>>, %i: index, %j: index) {
|
2021-11-17 10:34:38 +01:00
|
|
|
%c0 = arith.constant 1 : index
|
|
|
|
// expected-error@+1{{failed to legalize operation 'fir.slice'}}
|
|
|
|
%0 = fir.slice %c0, %c0, %c0, %c0, %c0, %c0 : (index, index, index, index, index, index) -> !fir.slice<2>
|
|
|
|
%1 = fir.array_coor %arg0[%0] %i, %j : (!fir.ref<!fir.array<?x?xf32>>, !fir.slice<2>, index, index) -> !fir.ref<f32>
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
// Test `fir.shift` conversion failure because the op has uses.
|
|
|
|
|
2022-04-20 21:39:22 -07:00
|
|
|
func.func @shift_not_dead(%arg0: !fir.box<!fir.array<?xf32>>, %i: index) {
|
2021-11-17 10:34:38 +01:00
|
|
|
%c0 = arith.constant 1 : index
|
|
|
|
// expected-error@+1{{failed to legalize operation 'fir.shift'}}
|
|
|
|
%0 = fir.shift %c0 : (index) -> !fir.shift<1>
|
|
|
|
%1 = fir.array_coor %arg0(%0) %i : (!fir.box<!fir.array<?xf32>>, !fir.shift<1>, index) -> !fir.ref<f32>
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
// Test `fir.shape_shift` conversion failure because the op has uses.
|
|
|
|
|
2022-04-20 21:39:22 -07:00
|
|
|
func.func @shape_shift_not_dead(%arg0: !fir.ref<!fir.array<?x?xf32>>, %i: index, %j: index) {
|
2021-11-17 10:34:38 +01:00
|
|
|
%c0 = arith.constant 1 : index
|
|
|
|
// expected-error@+1{{failed to legalize operation 'fir.shape_shift'}}
|
|
|
|
%0 = fir.shape_shift %c0, %c0, %c0, %c0 : (index, index, index, index) -> !fir.shapeshift<2>
|
|
|
|
%1 = fir.array_coor %arg0(%0) %i, %j : (!fir.ref<!fir.array<?x?xf32>>, !fir.shapeshift<2>, index, index) -> !fir.ref<f32>
|
|
|
|
return
|
|
|
|
}
|
2021-11-18 11:26:53 +00:00
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2021-12-01 22:12:12 +00:00
|
|
|
// Test `fir.select_type` conversion to llvm.
|
|
|
|
// Should have been converted.
|
2021-12-01 14:23:48 +00:00
|
|
|
|
2022-11-04 14:59:37 +01:00
|
|
|
func.func @bar_select_type(%arg : !fir.class<!fir.type<derivedst{a:f32}>>) -> i32 {
|
2021-12-01 22:12:12 +00:00
|
|
|
%0 = arith.constant 1 : i32
|
|
|
|
%2 = arith.constant 3 : i32
|
|
|
|
// expected-error@+2{{fir.select_type should have already been converted}}
|
|
|
|
// expected-error@+1{{failed to legalize operation 'fir.select_type'}}
|
2022-11-04 14:59:37 +01:00
|
|
|
fir.select_type %arg : !fir.class<!fir.type<derivedst{a:f32}>> [
|
|
|
|
#fir.type_is<!fir.int<4>>,^bb1(%0:i32),
|
|
|
|
#fir.type_is<!fir.int<8>>,^bb2(%2:i32),
|
2021-12-01 22:12:12 +00:00
|
|
|
unit,^bb5 ]
|
|
|
|
^bb1(%a : i32) :
|
|
|
|
return %a : i32
|
|
|
|
^bb2(%b : i32) :
|
|
|
|
return %b : i32
|
|
|
|
^bb5 :
|
|
|
|
%zero = arith.constant 0 : i32
|
|
|
|
return %zero : i32
|
2021-11-18 11:26:53 +00:00
|
|
|
}
|
2021-11-23 18:13:51 +00:00
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2022-06-22 09:38:32 +02:00
|
|
|
// Verify that `fir.dt_entry` requires a parent op
|
|
|
|
|
2023-10-06 09:29:57 +02:00
|
|
|
// expected-error@+1{{'fir.dt_entry' op expects parent op 'fir.type_info'}}
|
2022-06-22 09:38:32 +02:00
|
|
|
fir.dt_entry "method", @method_impl
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2023-10-06 09:29:57 +02:00
|
|
|
// expected-error@+1{{'fir.type_info' op type must be a fir.type}}
|
|
|
|
fir.type_info @bad : i32
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
// expected-error@+1{{'fir.type_info' op parent_type must be a fir.type}}
|
|
|
|
fir.type_info @bad extends f32 : !fir.type<t1{i:i32}>
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
|
|
fir.type_info @bad : !fir.type<bad{i:i32}> dispatch_table {
|
|
|
|
// expected-error@+1{{dispatch table must contain dt_entry}}
|
|
|
|
%zero = arith.constant 0 : i32
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
2021-11-23 18:13:51 +00:00
|
|
|
// `fir.coordinate_of` - dynamically sized arrays are not supported
|
2022-04-20 21:39:22 -07:00
|
|
|
func.func @coordinate_of_dynamic_array(%arg0: !fir.ref<!fir.array<1x!fir.char<4,?>>>, %arg1: index) {
|
2021-11-23 18:13:51 +00:00
|
|
|
// expected-error@+2{{fir.coordinate_of with a dynamic element size is unsupported}}
|
|
|
|
// expected-error@+1{{failed to legalize operation 'fir.coordinate_of'}}
|
|
|
|
%p = fir.coordinate_of %arg0, %arg1 : (!fir.ref<!fir.array<1x!fir.char<4,?>>>, index) -> !fir.ref<f32>
|
|
|
|
return
|
|
|
|
}
|