diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp --- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp +++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp @@ -541,8 +541,8 @@ mlir::LogicalResult matchAndRewrite(fir::BoxProcHostOp boxprochost, OpAdaptor adaptor, mlir::ConversionPatternRewriter &rewriter) const override { - return rewriter.notifyMatchFailure( - boxprochost, "fir.boxproc_host codegen is not implemented yet"); + TODO(boxprochost.getLoc(), "fir.boxproc_host codegen"); + return failure(); } }; @@ -783,8 +783,8 @@ mlir::LogicalResult matchAndRewrite(fir::DispatchOp dispatch, OpAdaptor adaptor, mlir::ConversionPatternRewriter &rewriter) const override { - return rewriter.notifyMatchFailure( - dispatch, "fir.dispatch codegen is not implemented yet"); + TODO(dispatch.getLoc(), "fir.dispatch codegen"); + return failure(); } }; @@ -797,8 +797,8 @@ mlir::LogicalResult matchAndRewrite(fir::DispatchTableOp dispTab, OpAdaptor adaptor, mlir::ConversionPatternRewriter &rewriter) const override { - return rewriter.notifyMatchFailure( - dispTab, "fir.dispatch_table codegen is not implemented yet"); + TODO(dispTab.getLoc(), "fir.dispatch_table codegen"); + return failure(); } }; @@ -810,8 +810,8 @@ mlir::LogicalResult matchAndRewrite(fir::DTEntryOp dtEnt, OpAdaptor adaptor, mlir::ConversionPatternRewriter &rewriter) const override { - return rewriter.notifyMatchFailure( - dtEnt, "fir.dt_entry codegen is not implemented yet"); + TODO(dtEnt.getLoc(), "fir.dt_entry codegen"); + return failure(); } }; @@ -822,8 +822,8 @@ mlir::LogicalResult matchAndRewrite(fir::GlobalLenOp globalLen, OpAdaptor adaptor, mlir::ConversionPatternRewriter &rewriter) const override { - return rewriter.notifyMatchFailure( - globalLen, "fir.global_len codegen is not implemented yet"); + TODO(globalLen.getLoc(), "fir.global_len codegen"); + return failure(); } }; @@ -834,8 +834,8 @@ mlir::LogicalResult matchAndRewrite(fir::GenTypeDescOp gentypedesc, OpAdaptor adaptor, mlir::ConversionPatternRewriter &rewriter) const override { - return rewriter.notifyMatchFailure( - gentypedesc, "fir.fir.gentypedesc codegen is not implemented yet"); + TODO(gentypedesc.getLoc(), "fir.gentypedesc codegen"); + return failure(); } }; @@ -846,8 +846,8 @@ mlir::LogicalResult matchAndRewrite(fir::FirEndOp firEnd, OpAdaptor, mlir::ConversionPatternRewriter &rewriter) const override { - return rewriter.notifyMatchFailure( - firEnd, "fir.end codegen is not implemented yet"); + TODO(firEnd.getLoc(), "fir.end codegen"); + return failure(); } }; @@ -1005,11 +1005,11 @@ unsigned conds = caseOp.getNumConditions(); llvm::ArrayRef cases = caseOp.getCases().getValue(); // Type can be CHARACTER, INTEGER, or LOGICAL (C1145) - LLVM_ATTRIBUTE_UNUSED auto ty = caseOp.getSelector().getType(); - if (ty.isa()) - return rewriter.notifyMatchFailure(caseOp, - "conversion of fir.select_case with " - "character type not implemented yet"); + auto ty = caseOp.getSelector().getType(); + if (ty.isa()) { + TODO(caseOp.getLoc(), "fir.select_case codegen with character type"); + return failure(); + } mlir::Value selector = caseOp.getSelector(adaptor.getOperands()); auto loc = caseOp.getLoc(); for (unsigned t = 0; t != conds; ++t) { @@ -1166,8 +1166,8 @@ mlir::LogicalResult matchAndRewrite(fir::SelectTypeOp select, OpAdaptor adaptor, mlir::ConversionPatternRewriter &rewriter) const override { - return rewriter.notifyMatchFailure( - select, "fir.select_type codegen is not implemented yet"); + TODO(select.getLoc(), "fir.select_type codegen"); + return failure(); } }; @@ -1559,10 +1559,10 @@ /*lenParams=*/adaptor.getOperands().drop_front(1)); dest = insertBaseAddress(rewriter, embox.getLoc(), dest, adaptor.getOperands()[0]); - if (isDerivedTypeWithLenParams(boxTy)) - return rewriter.notifyMatchFailure( - embox, "fir.embox codegen of derived with length parameters not " - "implemented yet"); + if (isDerivedTypeWithLenParams(boxTy)) { + TODO(embox.getLoc(), "fir.embox codegen of derived with length parameters"); + return failure(); + } auto result = placeInMemoryIfNotGlobalInit(rewriter, embox.getLoc(), dest); rewriter.replaceOp(embox, result); return success(); @@ -1577,8 +1577,8 @@ mlir::LogicalResult matchAndRewrite(fir::EmboxProcOp emboxproc, OpAdaptor adaptor, mlir::ConversionPatternRewriter &rewriter) const override { - return rewriter.notifyMatchFailure( - emboxproc, "fir.emboxproc codegen is not implemented yet"); + TODO(emboxproc.getLoc(), "fir.emboxproc codegen"); + return failure(); } }; @@ -2098,8 +2098,8 @@ mlir::LogicalResult matchAndRewrite(fir::UnboxProcOp unboxproc, OpAdaptor adaptor, mlir::ConversionPatternRewriter &rewriter) const override { - return rewriter.notifyMatchFailure( - unboxproc, "fir.unboxproc codegen is not implemented yet"); + TODO(unboxproc.getLoc(), "fir.unboxproc codegen"); + return failure(); } }; diff --git a/flang/test/Fir/Todo/boxprochost.fir b/flang/test/Fir/Todo/boxprochost.fir new file mode 100644 --- /dev/null +++ b/flang/test/Fir/Todo/boxprochost.fir @@ -0,0 +1,10 @@ +// RUN: fir-opt --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" %s +// XFAIL:* + +// Test that `fir.boxproc_host` fails conversion to llvm. +// At the moment this test fails since `fir.boxproc` type does not have a conversion. + +func @test(%bproc: !fir.boxproc<(i32) -> ()>) { + %tuple = fir.boxproc_host %bproc : (!fir.boxproc<(i32) -> ()>) -> (!fir.ref>) + return +} diff --git a/flang/test/Fir/Todo/dispatch.fir b/flang/test/Fir/Todo/dispatch.fir new file mode 100644 --- /dev/null +++ b/flang/test/Fir/Todo/dispatch.fir @@ -0,0 +1,10 @@ +// RUN: fir-opt --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" %s +// XFAIL:* + +// Test that `fir.dispatch` fails conversion to llvm. + +func @dispatch(%arg0: !fir.box>) { + // expected-error@+1{{failed to legalize operation 'fir.dispatch'}} + %0 = fir.dispatch "method"(%arg0) : (!fir.box>) -> i32 + return +} diff --git a/flang/test/Fir/Todo/dispatch_table.fir b/flang/test/Fir/Todo/dispatch_table.fir new file mode 100644 --- /dev/null +++ b/flang/test/Fir/Todo/dispatch_table.fir @@ -0,0 +1,10 @@ +// RUN: fir-opt --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" %s +// XFAIL:* + +// Test that `fir.dispatch_table fails conversion to llvm. +// Not implemented yet. + +fir.dispatch_table @dispatch_tbl { + fir.dt_entry "method", @method_impl +} + diff --git a/flang/test/Fir/Todo/emboxproc.fir b/flang/test/Fir/Todo/emboxproc.fir new file mode 100644 --- /dev/null +++ b/flang/test/Fir/Todo/emboxproc.fir @@ -0,0 +1,11 @@ +// RUN: fir-opt --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" %s +// XFAIL:* + +// Test `fir.emboxproc` conversion to llvm. +// Not implemented yet. + +func @emboxproc_test() { + %host_vars = fir.alloca tuple + %bproc = fir.emboxproc @method_impl, %host_vars : ((i32) -> (), !fir.ref>) -> !fir.boxproc<(i32) -> ()> + return +} diff --git a/flang/test/Fir/Todo/end.fir b/flang/test/Fir/Todo/end.fir new file mode 100644 --- /dev/null +++ b/flang/test/Fir/Todo/end.fir @@ -0,0 +1,7 @@ +// RUN: fir-opt --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" %s +// XFAIL:* + +// Test `fir.end` conversion to llvm. +// Not implemented yet. + +"fir.end"() : () -> () diff --git a/flang/test/Fir/Todo/gentypedesc.fir b/flang/test/Fir/Todo/gentypedesc.fir new file mode 100644 --- /dev/null +++ b/flang/test/Fir/Todo/gentypedesc.fir @@ -0,0 +1,10 @@ +// RUN: fir-opt --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" %s +// XFAIL:* + +// Test `fir.gentypedesc` conversion to llvm. +// Not implemented yet. + +func @gentypedesc() { + %0 = fir.gentypedesc !fir.type + return +} diff --git a/flang/test/Fir/Todo/global_len.fir b/flang/test/Fir/Todo/global_len.fir new file mode 100644 --- /dev/null +++ b/flang/test/Fir/Todo/global_len.fir @@ -0,0 +1,11 @@ +// RUN: fir-opt --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" %s +// XFAIL:* + +// Test `fir.global_len` conversion to llvm. +// Not implemented yet. + +fir.global @global_derived : !fir.type { + fir.global_len f, 1 : i32 + %0 = fir.undefined !fir.type + fir.has_value %0 : !fir.type +} diff --git a/flang/test/Fir/Todo/select_case_char.fir b/flang/test/Fir/Todo/select_case_char.fir new file mode 100644 --- /dev/null +++ b/flang/test/Fir/Todo/select_case_char.fir @@ -0,0 +1,19 @@ +// RUN: fir-opt --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" %s +// XFAIL:* + +// Test `fir.select_case` conversion to llvm with character type. +// Not implemented yet. + +func @select_case_charachter(%arg0: !fir.char<2, 10>, %arg1: !fir.char<2, 10>, %arg2: !fir.char<2, 10>) { + fir.select_case %arg0 : !fir.char<2, 10> [#fir.point, %arg1, ^bb1, + #fir.point, %arg2, ^bb2, + unit, ^bb3] +^bb1: + %c1_i32 = arith.constant 1 : i32 + br ^bb3 +^bb2: + %c2_i32 = arith.constant 2 : i32 + br ^bb3 +^bb3: + return +} diff --git a/flang/test/Fir/Todo/select_type.fir b/flang/test/Fir/Todo/select_type.fir new file mode 100644 --- /dev/null +++ b/flang/test/Fir/Todo/select_type.fir @@ -0,0 +1,22 @@ +// RUN: fir-opt --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" %s +// XFAIL:* + +// Test `fir.select_type` conversion to llvm. +// Not implemented yet. + +func @bar_select_type(%arg : !fir.box>) -> i32 { + %0 = arith.constant 1 : i32 + %2 = arith.constant 3 : i32 + + fir.select_type %arg : !fir.box> [ + #fir.instance>,^bb1(%0:i32), + #fir.instance>,^bb2(%2:i32), + unit,^bb5 ] +^bb1(%a : i32) : + return %a : i32 +^bb2(%b : i32) : + return %b : i32 +^bb5 : + %zero = arith.constant 0 : i32 + return %zero : i32 +} diff --git a/flang/test/Fir/Todo/unboxproc.fir b/flang/test/Fir/Todo/unboxproc.fir new file mode 100644 --- /dev/null +++ b/flang/test/Fir/Todo/unboxproc.fir @@ -0,0 +1,11 @@ +// RUN: fir-opt --fir-to-llvm-ir="target=x86_64-unknown-linux-gnu" %s +// XFAIL:* + +// Test `fir.unboxproc` conversion to llvm. +// Not implemented yet. +// Currently fails since coversion for boxproc type is not implemented. + +func @boxing_match(%bproc: !fir.boxproc<(i32) -> ()>) { + %ubproc:2 = fir.unboxproc %bproc : (!fir.boxproc<(i32) -> ()>) -> ((i32) -> (), !fir.ref>) + return +} diff --git a/flang/test/Fir/convert-to-llvm-invalid.fir b/flang/test/Fir/convert-to-llvm-invalid.fir --- a/flang/test/Fir/convert-to-llvm-invalid.fir +++ b/flang/test/Fir/convert-to-llvm-invalid.fir @@ -13,89 +13,6 @@ // ----- -// Test that `fir.dispatch` fails to be legalized. Not implemented yet. - -func @dispatch(%arg0: !fir.box>) { - // expected-error@+1{{failed to legalize operation 'fir.dispatch'}} - %0 = fir.dispatch "method"(%arg0) : (!fir.box>) -> i32 - return -} - -// ----- - -// Test that `fir.dispatch_table`/`fir.dt_entry` fails to be legalized. -// Not implemented yet. - -// expected-error@+1{{failed to legalize operation 'fir.dispatch_table'}} -fir.dispatch_table @dispatch_tbl { - fir.dt_entry "method", @method_impl -} - -// ----- - -// Test `fir.select_case` conversion failure with character type. -// Not implemented yet. - -func @select_case_charachter(%arg0: !fir.char<2, 10>, %arg1: !fir.char<2, 10>, %arg2: !fir.char<2, 10>) { - // expected-error@+1{{failed to legalize operation 'fir.select_case'}} - fir.select_case %arg0 : !fir.char<2, 10> [#fir.point, %arg1, ^bb1, - #fir.point, %arg2, ^bb2, - unit, ^bb3] -^bb1: - %c1_i32 = arith.constant 1 : i32 - br ^bb3 -^bb2: - %c2_i32 = arith.constant 2 : i32 - br ^bb3 -^bb3: - return -} - -// ----- - -// Test `fir.select_type` conversion failure. Not implemented yet. - -func @bar_select_type(%arg : !fir.box>) -> i32 { - %0 = arith.constant 1 : i32 - %2 = arith.constant 3 : i32 - - // expected-error@+1{{failed to legalize operation 'fir.select_type'}} - fir.select_type %arg : !fir.box> [ - #fir.instance>,^bb1(%0:i32), - #fir.instance>,^bb2(%2:i32), - unit,^bb5 ] -^bb1(%a : i32) : - return %a : i32 -^bb2(%b : i32) : - return %b : i32 -^bb5 : - %zero = arith.constant 0 : i32 - return %zero : i32 -} - -// ----- - -// Test `fir.global_len` conversion failure. Not implemented yet. - -fir.global @global_derived : !fir.type { - // expected-error@+1{{failed to legalize operation 'fir.global_len'}} - fir.global_len f, 1 : i32 - %0 = fir.undefined !fir.type - fir.has_value %0 : !fir.type -} - -// ----- - -// Test `fir.gentypedesc` conversion failure. Not implemented yet. - -func @gentypedesc() { - // expected-error@+1{{failed to legalize operation 'fir.gentypedesc'}} - %0 = fir.gentypedesc !fir.type - return -} - -// ----- - // Verify that `fir.dt_entry` requires a parent op // expected-error@+1{{'fir.dt_entry' op expects parent op 'fir.dispatch_table'}} @@ -148,35 +65,3 @@ %1 = fir.array_coor %arg0(%0) %i, %j : (!fir.ref>, !fir.shapeshift<2>, index, index) -> !fir.ref return } - -// ----- - -// Test that the type `fir.boxproc` fails to be legalized. -// Not implemented yet. - -// expected-error@+1{{failed to legalize operation 'builtin.func'}} -func private @foo0(%arg0: !fir.boxproc<() -> ()>) - -// ----- - -// Test that `fir.emboxproc` fails to be legalized. -// Not implemented yet. - -func private @method_impl(i32) - -func @emboxproc_test() { - %host_vars = fir.alloca tuple -// expected-error@+1{{failed to legalize operation 'fir.emboxproc'}} - %bproc = fir.emboxproc @method_impl, %host_vars : ((i32) -> (), !fir.ref>) -> !fir.boxproc<(i32) -> ()> - return -} - -// Test that `fir.unboxproc` and `fir.boxproc_host` also fails to be legalized. -// At the moment these cannot be tested since the `fir.boxproc` type does not have a conversion. - -// ----- - -// Test `fir.end` conversion failure. Not implemented yet. - -// expected-error@+1{{failed to legalize operation 'fir.end'}} -"fir.end"() : () -> ()