forked from OSchip/llvm-project
[flang] Keep current polymorphic implementation under a flag
It is useful for couple of test suite like NAG to keep failing with a TODO until the polymorphic entities is implemented all the way done to codegen. This pass adds a flag to LoweringOptions for experimental development. This flag is off by default and can be enable in `bbc` with `-polymorphic-type`. Options can be added in the driver and tco when needed. Reviewed By: PeteSteinfeld Differential Revision: https://reviews.llvm.org/D135283
This commit is contained in:
parent
60b4b39f5a
commit
91dd872ea6
|
@ -21,14 +21,23 @@ class LoweringOptions {
|
|||
/// If true, lower transpose without a runtime call.
|
||||
unsigned optimizeTranspose : 1;
|
||||
|
||||
/// If true, enable polymorphic type lowering feature. Off by default.
|
||||
unsigned polymorphicTypeImpl : 1;
|
||||
|
||||
public:
|
||||
LoweringOptions() : optimizeTranspose(true) {}
|
||||
LoweringOptions() : optimizeTranspose(true), polymorphicTypeImpl(false) {}
|
||||
|
||||
bool getOptimizeTranspose() const { return optimizeTranspose; }
|
||||
LoweringOptions &setOptimizeTranspose(bool v) {
|
||||
optimizeTranspose = v;
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool isPolymorphicTypeImplEnabled() const { return polymorphicTypeImpl; }
|
||||
LoweringOptions &setPolymorphicTypeImpl(bool v) {
|
||||
polymorphicTypeImpl = v;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace Fortran::lower
|
||||
|
|
|
@ -797,6 +797,12 @@ private:
|
|||
Fortran::common::TypeCategory cat = dynamicType.category();
|
||||
// DERIVED
|
||||
if (cat == Fortran::common::TypeCategory::Derived) {
|
||||
// TODO is kept under experimental flag until feature is complete.
|
||||
if (dynamicType.IsPolymorphic() &&
|
||||
!getConverter().getLoweringOptions().isPolymorphicTypeImplEnabled())
|
||||
TODO(interface.converter.getCurrentLocation(),
|
||||
"support for polymorphic types");
|
||||
|
||||
if (dynamicType.IsUnlimitedPolymorphic())
|
||||
return mlir::NoneType::get(&mlirContext);
|
||||
return getConverter().genType(dynamicType.GetDerivedTypeSpec());
|
||||
|
|
|
@ -233,6 +233,11 @@ struct TypeBuilder {
|
|||
llvm::SmallVector<Fortran::lower::LenParameterTy> params;
|
||||
translateLenParameters(params, tySpec->category(), ultimate);
|
||||
ty = genFIRType(context, tySpec->category(), kind, params);
|
||||
} else if (type->IsPolymorphic() &&
|
||||
!converter.getLoweringOptions()
|
||||
.isPolymorphicTypeImplEnabled()) {
|
||||
// TODO is kept under experimental flag until feature is complete.
|
||||
TODO(loc, "support for polymorphic types");
|
||||
} else if (type->IsUnlimitedPolymorphic()) {
|
||||
ty = mlir::NoneType::get(context);
|
||||
} else if (const Fortran::semantics::DerivedTypeSpec *tySpec =
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
! RUN: bbc -emit-fir %s -o - | FileCheck %s
|
||||
! RUN: bbc -polymorphic-type -emit-fir %s -o - | FileCheck %s
|
||||
|
||||
! Tests the different possible type involving polymorphic entities.
|
||||
|
||||
|
|
|
@ -126,6 +126,11 @@ static llvm::cl::opt<bool> enableOpenACC("fopenacc",
|
|||
llvm::cl::desc("enable openacc"),
|
||||
llvm::cl::init(false));
|
||||
|
||||
static llvm::cl::opt<bool> enablePolymorphic(
|
||||
"polymorphic-type",
|
||||
llvm::cl::desc("enable polymorphic type lowering (experimental)"),
|
||||
llvm::cl::init(false));
|
||||
|
||||
#define FLANG_EXCLUDE_CODEGEN
|
||||
#include "flang/Tools/CLOptions.inc"
|
||||
|
||||
|
@ -221,6 +226,7 @@ static mlir::LogicalResult convertFortranSourceToMLIR(
|
|||
&ctx, llvm::ArrayRef<fir::KindTy>{fir::fromDefaultKinds(defKinds)});
|
||||
// Use default lowering options for bbc.
|
||||
Fortran::lower::LoweringOptions loweringOptions{};
|
||||
loweringOptions.setPolymorphicTypeImpl(enablePolymorphic);
|
||||
auto burnside = Fortran::lower::LoweringBridge::create(
|
||||
ctx, semanticsContext, defKinds, semanticsContext.intrinsics(),
|
||||
semanticsContext.targetCharacteristics(), parsing.allCooked(), "",
|
||||
|
|
Loading…
Reference in New Issue