[PATCH] D113878: [fir] Add fir.select_type conversion placeholder
Valentin Clement via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 15 05:19:37 PST 2021
clementval updated this revision to Diff 387225.
clementval added a comment.
Rebase
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113878/new/
https://reviews.llvm.org/D113878
Files:
flang/lib/Optimizer/CodeGen/CodeGen.cpp
flang/test/Fir/convert-to-llvm-invalid.fir
Index: flang/test/Fir/convert-to-llvm-invalid.fir
===================================================================
--- flang/test/Fir/convert-to-llvm-invalid.fir
+++ flang/test/Fir/convert-to-llvm-invalid.fir
@@ -50,3 +50,25 @@
^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
+}
Index: flang/lib/Optimizer/CodeGen/CodeGen.cpp
===================================================================
--- flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -930,6 +930,19 @@
}
};
+/// 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 @@
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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113878.387225.patch
Type: text/x-patch
Size: 2564 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211115/5c77eb9d/attachment.bin>
More information about the llvm-commits
mailing list