/// 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
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());
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 =
-! 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.
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"
&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(), "",