xref: /llvm-project/flang/include/flang/Lower/LoweringOptions.h (revision 8f3f15c1a208932689a8bdef22d6ca3d4c3408c5)
1 //===- LoweringOptions.h ----------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 ///
9 /// \file
10 /// Options controlling lowering of front-end fragments to the FIR dialect
11 /// of MLIR
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef FLANG_LOWER_LOWERINGOPTIONS_H
16 #define FLANG_LOWER_LOWERINGOPTIONS_H
17 
18 #include "flang/Common/MathOptionsBase.h"
19 
20 namespace Fortran::lower {
21 
22 class LoweringOptionsBase {
23 public:
24 #define LOWERINGOPT(Name, Bits, Default) unsigned Name : Bits;
25 #define ENUM_LOWERINGOPT(Name, Type, Bits, Default)
26 #include "flang/Lower/LoweringOptions.def"
27 
28 protected:
29 #define LOWERINGOPT(Name, Bits, Default)
30 #define ENUM_LOWERINGOPT(Name, Type, Bits, Default) unsigned Name : Bits;
31 #include "flang/Lower/LoweringOptions.def"
32 };
33 
34 class LoweringOptions : public LoweringOptionsBase {
35 
36 public:
37 #define LOWERINGOPT(Name, Bits, Default)
38 #define ENUM_LOWERINGOPT(Name, Type, Bits, Default)                            \
39   Type get##Name() const { return static_cast<Type>(Name); }                   \
40   LoweringOptions &set##Name(Type Value) {                                     \
41     Name = static_cast<unsigned>(Value);                                       \
42     return *this;                                                              \
43   }
44 #include "flang/Lower/LoweringOptions.def"
45 
46   LoweringOptions();
47 
getMathOptions()48   const Fortran::common::MathOptionsBase &getMathOptions() const {
49     return MathOptions;
50   }
51 
getMathOptions()52   Fortran::common::MathOptionsBase &getMathOptions() { return MathOptions; }
53 
54 private:
55   /// Options for handling/optimizing mathematical computations.
56   Fortran::common::MathOptionsBase MathOptions;
57 };
58 
59 } // namespace Fortran::lower
60 
61 #endif // FLANG_LOWER_LOWERINGOPTIONS_H
62