xref: /llvm-project/flang/lib/Frontend/CodeGenOptions.cpp (revision 9e6b46a9846cf5051c2aaef361af0fe1a76c856e)
1 //===--- CodeGenOptions.cpp -----------------------------------------------===//
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 // Coding style: https://mlir.llvm.org/getting_started/DeveloperGuide/
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "flang/Frontend/CodeGenOptions.h"
14 #include <optional>
15 #include <string.h>
16 
17 namespace Fortran::frontend {
18 
CodeGenOptions()19 CodeGenOptions::CodeGenOptions() {
20 #define CODEGENOPT(Name, Bits, Default) Name = Default;
21 #define ENUM_CODEGENOPT(Name, Type, Bits, Default) set##Name(Default);
22 #include "flang/Frontend/CodeGenOptions.def"
23 }
24 
getCodeModel(llvm::StringRef string)25 std::optional<llvm::CodeModel::Model> getCodeModel(llvm::StringRef string) {
26   return llvm::StringSwitch<std::optional<llvm::CodeModel::Model>>(string)
27       .Case("tiny", llvm::CodeModel::Model::Tiny)
28       .Case("small", llvm::CodeModel::Model::Small)
29       .Case("kernel", llvm::CodeModel::Model::Kernel)
30       .Case("medium", llvm::CodeModel::Model::Medium)
31       .Case("large", llvm::CodeModel::Model::Large)
32       .Default(std::nullopt);
33 }
34 
35 } // end namespace Fortran::frontend
36