Skip to content

Commit

Permalink
[flang][codegen] Add fir.end conversion placeholder
Browse files Browse the repository at this point in the history
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@nvidia.com>

Differential Revision: https://reviews.llvm.org/D113295
  • Loading branch information
banach-space committed Nov 18, 2021
1 parent dead1c1 commit 22d332a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
18 changes: 15 additions & 3 deletions flang/lib/Optimizer/CodeGen/CodeGen.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions flang/test/Fir/convert-to-llvm-invalid.fir
Expand Up @@ -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@+1{{failed to legalize operation 'fir.end'}}
"fir.end"() : () -> ()

0 comments on commit 22d332a

Please sign in to comment.