From: Valentin Clement Date: Mon, 15 Nov 2021 13:35:44 +0000 (+0100) Subject: [fir] Add fir.select_type conversion placeholder X-Git-Tag: upstream/15.0.7~25711 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2a299e4f0636bd6664ddabb36a8a1dfa8cbd59e5;p=platform%2Fupstream%2Fllvm.git [fir] Add fir.select_type conversion placeholder As for D113662, this patch just add a place holder for the `fir.select_type` operation conversion. This operation is part of F20xx and is not implemented yet. This patch is part of the upstreaming effort from fir-dev branch. Reviewed By: kiranchandramohan Differential Revision: https://reviews.llvm.org/D113878 --- diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp index fdf8449..855af9ea 100644 --- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp +++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp @@ -930,6 +930,19 @@ struct LoadOpConversion : public FIROpConversion { } }; +/// Lower `fir.select_type` to LLVM IR dialect. +struct SelectTypeOpConversion : public FIROpConversion { + using FIROpConversion::FIROpConversion; + + 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"); + return failure(); + } +}; + /// conversion of fir::SelectRankOp to an if-then-else ladder struct SelectRankOpConversion : public FIROpConversion { using FIROpConversion::FIROpConversion; @@ -1456,9 +1469,9 @@ public: InsertOnRangeOpConversion, InsertValueOpConversion, IsPresentOpConversion, LoadOpConversion, NegcOpConversion, MulcOpConversion, SelectCaseOpConversion, SelectOpConversion, - SelectRankOpConversion, StoreOpConversion, SubcOpConversion, - UndefOpConversion, UnreachableOpConversion, ZeroOpConversion>( - typeConverter); + SelectRankOpConversion, SelectTypeOpConversion, StoreOpConversion, + SubcOpConversion, UndefOpConversion, UnreachableOpConversion, + ZeroOpConversion>(typeConverter); mlir::populateStdToLLVMConversionPatterns(typeConverter, pattern); mlir::arith::populateArithmeticToLLVMConversionPatterns(typeConverter, pattern); diff --git a/flang/test/Fir/convert-to-llvm-invalid.fir b/flang/test/Fir/convert-to-llvm-invalid.fir index c219111..8c38cab 100644 --- a/flang/test/Fir/convert-to-llvm-invalid.fir +++ b/flang/test/Fir/convert-to-llvm-invalid.fir @@ -50,3 +50,25 @@ func @select_case_charachter(%arg0: !fir.char<2, 10>, %arg1: !fir.char<2, 10>, % ^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 +}