xref: /src/contrib/llvm-project/clang/lib/Basic/CodeGenOptions.cpp (revision 7a6dacaca14b62ca4b74406814becb87a3fefac0)
106d4ba38SDimitry Andric //===--- CodeGenOptions.cpp -----------------------------------------------===//
206d4ba38SDimitry Andric //
322989816SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
422989816SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
522989816SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
606d4ba38SDimitry Andric //
706d4ba38SDimitry Andric //===----------------------------------------------------------------------===//
806d4ba38SDimitry Andric 
9676fbe81SDimitry Andric #include "clang/Basic/CodeGenOptions.h"
1006d4ba38SDimitry Andric #include <string.h>
1106d4ba38SDimitry Andric 
1206d4ba38SDimitry Andric namespace clang {
1306d4ba38SDimitry Andric 
CodeGenOptions()1406d4ba38SDimitry Andric CodeGenOptions::CodeGenOptions() {
1506d4ba38SDimitry Andric #define CODEGENOPT(Name, Bits, Default) Name = Default;
1606d4ba38SDimitry Andric #define ENUM_CODEGENOPT(Name, Type, Bits, Default) set##Name(Default);
17676fbe81SDimitry Andric #include "clang/Basic/CodeGenOptions.def"
1806d4ba38SDimitry Andric 
1948675466SDimitry Andric   RelocationModel = llvm::Reloc::PIC_;
20cfca06d7SDimitry Andric   memcpy(CoverageVersion, "408*", 4);
2106d4ba38SDimitry Andric }
2206d4ba38SDimitry Andric 
resetNonModularOptions(StringRef ModuleFormat)23b1c73532SDimitry Andric void CodeGenOptions::resetNonModularOptions(StringRef ModuleFormat) {
24b1c73532SDimitry Andric   // First reset all CodeGen options only. The Debug options are handled later.
25b1c73532SDimitry Andric #define DEBUGOPT(Name, Bits, Default)
26b1c73532SDimitry Andric #define VALUE_DEBUGOPT(Name, Bits, Default)
27b1c73532SDimitry Andric #define ENUM_DEBUGOPT(Name, Type, Bits, Default)
28b1c73532SDimitry Andric #define CODEGENOPT(Name, Bits, Default) Name = Default;
29b1c73532SDimitry Andric #define ENUM_CODEGENOPT(Name, Type, Bits, Default) set##Name(Default);
304df029ccSDimitry Andric // Do not reset AST affecting code generation options.
314df029ccSDimitry Andric #define AFFECTING_VALUE_CODEGENOPT(Name, Bits, Default)
32b1c73532SDimitry Andric #include "clang/Basic/CodeGenOptions.def"
33b1c73532SDimitry Andric 
34b1c73532SDimitry Andric   // Next reset all debug options that can always be reset, because they never
35b1c73532SDimitry Andric   // affect the PCM.
36b1c73532SDimitry Andric #define DEBUGOPT(Name, Bits, Default)
37b1c73532SDimitry Andric #define VALUE_DEBUGOPT(Name, Bits, Default)
38b1c73532SDimitry Andric #define ENUM_DEBUGOPT(Name, Type, Bits, Default)
39b1c73532SDimitry Andric #define BENIGN_DEBUGOPT(Name, Bits, Default) Name = Default;
40b1c73532SDimitry Andric #define BENIGN_VALUE_DEBUGOPT(Name, Bits, Default) Name = Default;
41b1c73532SDimitry Andric #define BENIGN_ENUM_DEBUGOPT(Name, Type, Bits, Default) set##Name(Default);
42b1c73532SDimitry Andric #include "clang/Basic/DebugOptions.def"
43b1c73532SDimitry Andric 
44b1c73532SDimitry Andric   // Conditionally reset debug options that only matter when the debug info is
45b1c73532SDimitry Andric   // emitted into the PCM (-gmodules).
46b1c73532SDimitry Andric   if (ModuleFormat == "raw" && !DebugTypeExtRefs) {
47b1c73532SDimitry Andric #define DEBUGOPT(Name, Bits, Default) Name = Default;
48b1c73532SDimitry Andric #define VALUE_DEBUGOPT(Name, Bits, Default) Name = Default;
49b1c73532SDimitry Andric #define ENUM_DEBUGOPT(Name, Type, Bits, Default) set##Name(Default);
50b1c73532SDimitry Andric #define BENIGN_DEBUGOPT(Name, Bits, Default)
51b1c73532SDimitry Andric #define BENIGN_VALUE_DEBUGOPT(Name, Bits, Default)
52b1c73532SDimitry Andric #define BENIGN_ENUM_DEBUGOPT(Name, Type, Bits, Default)
53b1c73532SDimitry Andric #include "clang/Basic/DebugOptions.def"
54b1c73532SDimitry Andric   }
55b1c73532SDimitry Andric 
56b1c73532SDimitry Andric   RelocationModel = llvm::Reloc::PIC_;
57b1c73532SDimitry Andric   memcpy(CoverageVersion, "408*", 4);
58b1c73532SDimitry Andric }
59b1c73532SDimitry Andric 
6006d4ba38SDimitry Andric }  // end namespace clang
61