/// expression value. The clean-up for this temporary is added to \p context.
virtual fir::ExtendedValue genExprAddr(const SomeExpr &expr,
StatementContext &context,
- mlir::Location *loc = nullptr) = 0;
+ mlir::Location *locPtr = nullptr) = 0;
/// Generate the address of the location holding the expression, \p expr.
fir::ExtendedValue genExprAddr(mlir::Location loc, const SomeExpr *expr,
/// Generate the computations of the expression to produce a value.
virtual fir::ExtendedValue genExprValue(const SomeExpr &expr,
StatementContext &context,
- mlir::Location *loc = nullptr) = 0;
+ mlir::Location *locPtr = nullptr) = 0;
/// Generate the computations of the expression, \p expr, to produce a value.
fir::ExtendedValue genExprValue(mlir::Location loc, const SomeExpr *expr,
/// If true, enable polymorphic type lowering feature. Off by default.
unsigned polymorphicTypeImpl : 1;
+ /// If true, lower to High level FIR before lowering to FIR.
+ /// Off by default until fully ready.
+ unsigned lowerToHighLevelFIR : 1;
+
public:
- LoweringOptions() : optimizeTranspose(true), polymorphicTypeImpl(false) {}
+ LoweringOptions()
+ : optimizeTranspose(true), polymorphicTypeImpl(false),
+ lowerToHighLevelFIR(false) {}
bool getOptimizeTranspose() const { return optimizeTranspose; }
LoweringOptions &setOptimizeTranspose(bool v) {
polymorphicTypeImpl = v;
return *this;
}
+
+ bool getLowerToHighLevelFIR() const { return lowerToHighLevelFIR; }
+ LoweringOptions &setLowerToHighLevelFIR(bool v) {
+ lowerToHighLevelFIR = v;
+ return *this;
+ }
};
} // namespace Fortran::lower
return iter->second;
}
- fir::ExtendedValue genExprAddr(const Fortran::lower::SomeExpr &expr,
- Fortran::lower::StatementContext &context,
- mlir::Location *loc = nullptr) override final {
- return Fortran::lower::createSomeExtendedAddress(
- loc ? *loc : toLocation(), *this, expr, localSymbols, context);
+ fir::ExtendedValue
+ genExprAddr(const Fortran::lower::SomeExpr &expr,
+ Fortran::lower::StatementContext &context,
+ mlir::Location *locPtr = nullptr) override final {
+ mlir::Location loc = locPtr ? *locPtr : toLocation();
+ if (bridge.getLoweringOptions().getLowerToHighLevelFIR())
+ TODO(loc, "lower expr to HLFIR address");
+ return Fortran::lower::createSomeExtendedAddress(loc, *this, expr,
+ localSymbols, context);
}
fir::ExtendedValue
genExprValue(const Fortran::lower::SomeExpr &expr,
Fortran::lower::StatementContext &context,
- mlir::Location *loc = nullptr) override final {
- return Fortran::lower::createSomeExtendedExpression(
- loc ? *loc : toLocation(), *this, expr, localSymbols, context);
+ mlir::Location *locPtr = nullptr) override final {
+ mlir::Location loc = locPtr ? *locPtr : toLocation();
+ if (bridge.getLoweringOptions().getLowerToHighLevelFIR())
+ TODO(loc, "lower expr to HLFIR value");
+ return Fortran::lower::createSomeExtendedExpression(loc, *this, expr,
+ localSymbols, context);
}
fir::ExtendedValue
genExprBox(mlir::Location loc, const Fortran::lower::SomeExpr &expr,
Fortran::lower::StatementContext &stmtCtx) override final {
+ if (bridge.getLoweringOptions().getLowerToHighLevelFIR())
+ TODO(loc, "lower expr to HLFIR box");
return Fortran::lower::createBoxValue(loc, *this, expr, localSymbols,
stmtCtx);
}
--- /dev/null
+! Test lowering of of expressions as address
+! RUN: %not_todo_cmd bbc -emit-fir -hlfir -o - %s 2>&1 | FileCheck %s
+
+subroutine foo(x)
+ integer :: x
+ ! CHECK: not yet implemented: lower expr to HLFIR address
+ read (*,*) x
+end subroutine
--- /dev/null
+! Test lowering of of expressions as fir.box
+! RUN: %not_todo_cmd bbc -emit-fir -hlfir -o - %s 2>&1 | FileCheck %s
+
+subroutine foo(x)
+ integer :: x(:)
+ ! CHECK: not yet implemented: lower expr to HLFIR box
+ print *, x
+end subroutine
--- /dev/null
+! Test lowering of of expressions as values
+! RUN: %not_todo_cmd bbc -emit-fir -hlfir -o - %s 2>&1 | FileCheck %s
+
+subroutine foo()
+ ! CHECK: not yet implemented: lower expr to HLFIR value
+ print *, 42
+end subroutine
llvm::cl::desc("enable polymorphic type lowering (experimental)"),
llvm::cl::init(false));
+static llvm::cl::opt<bool> useHLFIR("hlfir",
+ llvm::cl::desc("Lower to high level FIR"),
+ llvm::cl::init(false));
+
#define FLANG_EXCLUDE_CODEGEN
#include "flang/Tools/CLOptions.inc"
// Use default lowering options for bbc.
Fortran::lower::LoweringOptions loweringOptions{};
loweringOptions.setPolymorphicTypeImpl(enablePolymorphic);
+ loweringOptions.setLowerToHighLevelFIR(useHLFIR);
auto burnside = Fortran::lower::LoweringBridge::create(
ctx, semanticsContext, defKinds, semanticsContext.intrinsics(),
semanticsContext.targetCharacteristics(), parsing.allCooked(), "",