1 //===- MathOptionsBase.h - Math options config ------------------*- 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 mathematical computations generated in FIR. 11 /// This is intended to be header-only implementation without extra 12 /// dependencies so that multiple components can use it to exchange 13 /// math configuration. 14 /// 15 //===----------------------------------------------------------------------===// 16 17 #ifndef FORTRAN_COMMON_MATHOPTIONSBASE_H 18 #define FORTRAN_COMMON_MATHOPTIONSBASE_H 19 20 namespace Fortran::common { 21 22 class MathOptionsBase { 23 public: 24 #define ENUM_MATHOPT(Name, Type, Bits, Default) \ 25 Type get##Name() const { return static_cast<Type>(Name); } \ 26 MathOptionsBase &set##Name(Type Value) { \ 27 Name = static_cast<unsigned>(Value); \ 28 return *this; \ 29 } 30 #include "flang/Common/MathOptionsBase.def" 31 MathOptionsBase()32 MathOptionsBase() { 33 #define ENUM_MATHOPT(Name, Type, Bits, Default) set##Name(Default); 34 #include "flang/Common/MathOptionsBase.def" 35 } 36 37 private: 38 #define ENUM_MATHOPT(Name, Type, Bits, Default) unsigned Name : Bits; 39 #include "flang/Common/MathOptionsBase.def" 40 }; 41 42 } // namespace Fortran::common 43 44 #endif // FORTRAN_COMMON_MATHOPTIONSBASE_H 45