--- /dev/null
+//===--- LoweringOptions.def - Lowering options database ---------- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file defines the lowering options. Users of this file must define
+/// LOWERINGOPT macro to make use of this information.
+///
+//===----------------------------------------------------------------------===//
+
+#ifndef LOWERINGOPT
+# error Define the LOWERINGOPT macro to handle lowering options
+#endif
+
+#ifndef ENUM_LOWERINGOPT
+# define ENUM_LOWERINGOPT(Name, Type, Bits, Default) \
+LOWERINGOPT(Name, Bits, Default)
+#endif
+
+/// If true, lower transpose without a runtime call.
+ENUM_LOWERINGOPT(OptimizeTranspose, unsigned, 1, 1)
+
+/// If true, enable polymorphic type lowering feature. Off by default.
+ENUM_LOWERINGOPT(PolymorphicTypeImpl, unsigned, 1, 0)
+
+/// If true, lower to High level FIR before lowering to FIR.
+/// Off by default until fully ready.
+ENUM_LOWERINGOPT(LowerToHighLevelFIR, unsigned, 1, 0)
+
+#undef LOWERINGOPT
+#undef ENUM_LOWERINGOPT
namespace Fortran::lower {
-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;
+class LoweringOptionsBase {
+public:
+#define LOWERINGOPT(Name, Bits, Default) unsigned Name : Bits;
+#define ENUM_LOWERINGOPT(Name, Type, Bits, Default)
+#include "flang/Lower/LoweringOptions.def"
+
+protected:
+#define LOWERINGOPT(Name, Bits, Default)
+#define ENUM_LOWERINGOPT(Name, Type, Bits, Default) unsigned Name : Bits;
+#include "flang/Lower/LoweringOptions.def"
+};
- /// If true, lower to High level FIR before lowering to FIR.
- /// Off by default until fully ready.
- unsigned lowerToHighLevelFIR : 1;
+class LoweringOptions : public LoweringOptionsBase {
public:
- LoweringOptions()
- : optimizeTranspose(true), polymorphicTypeImpl(false),
- lowerToHighLevelFIR(false) {}
-
- bool getOptimizeTranspose() const { return optimizeTranspose; }
- LoweringOptions &setOptimizeTranspose(bool v) {
- optimizeTranspose = v;
- return *this;
+#define LOWERINGOPT(Name, Bits, Default)
+#define ENUM_LOWERINGOPT(Name, Type, Bits, Default) \
+ Type get##Name() const { return static_cast<Type>(Name); } \
+ LoweringOptions &set##Name(Type Value) { \
+ Name = static_cast<unsigned>(Value); \
+ return *this; \
}
+#include "flang/Lower/LoweringOptions.def"
- bool isPolymorphicTypeImplEnabled() const { return polymorphicTypeImpl; }
- LoweringOptions &setPolymorphicTypeImpl(bool v) {
- polymorphicTypeImpl = v;
- return *this;
- }
-
- bool getLowerToHighLevelFIR() const { return lowerToHighLevelFIR; }
- LoweringOptions &setLowerToHighLevelFIR(bool v) {
- lowerToHighLevelFIR = v;
- return *this;
- }
+ LoweringOptions();
};
} // namespace Fortran::lower
IntrinsicCall.cpp
IO.cpp
IterationSpace.cpp
+ LoweringOptions.cpp
Mangler.cpp
OpenACC.cpp
OpenMP.cpp
if (cat == Fortran::common::TypeCategory::Derived) {
// TODO is kept under experimental flag until feature is complete.
if (dynamicType.IsPolymorphic() &&
- !getConverter().getLoweringOptions().isPolymorphicTypeImplEnabled())
+ !getConverter().getLoweringOptions().getPolymorphicTypeImpl())
TODO(interface.converter.getCurrentLocation(),
"support for polymorphic types");
translateLenParameters(params, tySpec->category(), ultimate);
ty = genFIRType(context, tySpec->category(), kind, params);
} else if (type->IsPolymorphic() &&
- !converter.getLoweringOptions()
- .isPolymorphicTypeImplEnabled()) {
+ !converter.getLoweringOptions().getPolymorphicTypeImpl()) {
// TODO is kept under experimental flag until feature is complete.
TODO(loc, "support for polymorphic types");
} else if (type->IsUnlimitedPolymorphic()) {
--- /dev/null
+//===--- LoweringOptions.cpp ----------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// Coding style: https://mlir.llvm.org/getting_started/DeveloperGuide/
+//
+//===----------------------------------------------------------------------===//
+
+#include "flang/Lower/LoweringOptions.h"
+
+namespace Fortran::lower {
+
+LoweringOptions::LoweringOptions() {
+#define LOWERINGOPT(Name, Bits, Default) Name = Default;
+#define ENUM_LOWERINGOPT(Name, Type, Bits, Default) set##Name(Default);
+#include "flang/Lower/LoweringOptions.def"
+}
+
+} // namespace Fortran::lower
clangBasic
flangFrontend
flangFrontendTool
+ FortranLower
FortranParser
FortranSemantics
FortranCommon