[flang-commits] [flang] 22d332a - [flang][codegen] Add `fir.end` conversion placeholder
Andrzej Warzynski via flang-commits
flang-commits at lists.llvm.org
Thu Nov 18 06:20:04 PST 2021
Author: Andrzej Warzynski
Date: 2021-11-18T14:19:26Z
New Revision: 22d332a0a20f1d25d24bdefc6be2a71e91275224
URL: https://github.com/llvm/llvm-project/commit/22d332a0a20f1d25d24bdefc6be2a71e91275224
DIFF: https://github.com/llvm/llvm-project/commit/22d332a0a20f1d25d24bdefc6be2a71e91275224.diff
LOG: [flang][codegen] Add `fir.end` conversion placeholder
This patch extends the FIRToLLVMLowering pass in Flang by adding a hook
to transform fir.end. This is just a placeholder for now as fir.end is
not required yet.
This is part of the upstreaming effort from the `fir-dev` branch in [1].
[1] https://github.com/flang-compiler/f18-llvm-project
Patch originally written by:
Co-authored-by: Eric Schweitz <eschweitz at nvidia.com>
Differential Revision: https://reviews.llvm.org/D113295
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 f14c0a612a89..5346dda6b8d4 100644
--- a/flang/lib/Optimizer/CodeGen/CodeGen.cpp
+++ b/flang/lib/Optimizer/CodeGen/CodeGen.cpp
@@ -839,6 +839,18 @@ struct GenTypeDescOpConversion : public FIROpConversion<fir::GenTypeDescOp> {
}
};
+/// Convert `fir.end`
+struct FirEndOpConversion : public FIROpConversion<fir::FirEndOp> {
+ using FIROpConversion::FIROpConversion;
+
+ mlir::LogicalResult
+ matchAndRewrite(fir::FirEndOp firEnd, OpAdaptor,
+ mlir::ConversionPatternRewriter &rewriter) const override {
+ return rewriter.notifyMatchFailure(
+ firEnd, "fir.end codegen is not implemented yet");
+ }
+};
+
/// Lower `fir.has_value` operation to `llvm.return` operation.
struct HasValueOpConversion : public FIROpConversion<fir::HasValueOp> {
using FIROpConversion::FIROpConversion;
@@ -2108,9 +2120,9 @@ class FIRToLLVMLowering : public fir::FIRToLLVMLoweringBase<FIRToLLVMLowering> {
CmpcOpConversion, ConstcOpConversion, ConvertOpConversion,
DispatchOpConversion, DispatchTableOpConversion, DTEntryOpConversion,
DivcOpConversion, EmboxOpConversion, EmboxCharOpConversion,
- EmboxProcOpConversion, ExtractValueOpConversion, HasValueOpConversion,
- GenTypeDescOpConversion, GlobalLenOpConversion, GlobalOpConversion,
- InsertOnRangeOpConversion, InsertValueOpConversion,
+ EmboxProcOpConversion, ExtractValueOpConversion, FirEndOpConversion,
+ HasValueOpConversion, GenTypeDescOpConversion, GlobalLenOpConversion,
+ GlobalOpConversion, InsertOnRangeOpConversion, InsertValueOpConversion,
IsPresentOpConversion, LoadOpConversion, NegcOpConversion,
MulcOpConversion, SelectCaseOpConversion, SelectOpConversion,
SelectRankOpConversion, SelectTypeOpConversion, ShapeOpConversion,
diff --git a/flang/test/Fir/convert-to-llvm-invalid.fir b/flang/test/Fir/convert-to-llvm-invalid.fir
index 3c657d3f3a01..0b6a39f1b6cd 100644
--- a/flang/test/Fir/convert-to-llvm-invalid.fir
+++ b/flang/test/Fir/convert-to-llvm-invalid.fir
@@ -173,3 +173,10 @@ func @emboxproc_test() {
// 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 at +1{{failed to legalize operation 'fir.end'}}
+"fir.end"() : () -> ()
More information about the flang-commits
mailing list