[flang-commits] [flang] 2a299e4 - [fir] Add fir.select_type conversion placeholder
Valentin Clement via flang-commits
flang-commits at lists.llvm.org
Mon Nov 15 05:36:03 PST 2021
Author: Valentin Clement
Date: 2021-11-15T14:35:57+01:00
New Revision: 2a299e4f0636bd6664ddabb36a8a1dfa8cbd59e5
URL: https://github.com/llvm/llvm-project/commit/2a299e4f0636bd6664ddabb36a8a1dfa8cbd59e5
DIFF: https://github.com/llvm/llvm-project/commit/2a299e4f0636bd6664ddabb36a8a1dfa8cbd59e5.diff
LOG: [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
Added:
Modified:
flang/lib/Optimizer/CodeGen/CodeGen.cpp
flang/test/Fir/convert-to-llvm-invalid.fir
Removed:
################################################################################
diff --git a/flang/lib/Optimizer/CodeGen/CodeGen.cpp b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
index fdf8449a64d9..855af9ea5857 100644
--- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -930,6 +930,19 @@ struct LoadOpConversion : public FIROpConversion<fir::LoadOp> {
}
};
+/// Lower `fir.select_type` to LLVM IR dialect.
+struct SelectTypeOpConversion : public FIROpConversion<fir::SelectTypeOp> {
+ 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<fir::SelectRankOp> {
using FIROpConversion::FIROpConversion;
@@ -1456,9 +1469,9 @@ class FIRToLLVMLowering : public fir::FIRToLLVMLoweringBase<FIRToLLVMLowering> {
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 c219111817e6..8c38cab68fb6 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<!fir.type<derived3{f:f32}>>) -> i32 {
+ %0 = arith.constant 1 : i32
+ %2 = arith.constant 3 : i32
+
+ // expected-error at +1{{failed to legalize operation 'fir.select_type'}}
+ fir.select_type %arg : !fir.box<!fir.type<derived3{f:f32}>> [
+ #fir.instance<!fir.int<4>>,^bb1(%0:i32),
+ #fir.instance<!fir.int<8>>,^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
+}
More information about the flang-commits
mailing list