Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / wasm / Config.h
blob876c7e80ba80d936739428841b3d2c78ee75ac4c
1 //===- Config.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 //===----------------------------------------------------------------------===//
9 #ifndef LLD_WASM_CONFIG_H
10 #define LLD_WASM_CONFIG_H
12 #include "llvm/ADT/SmallVector.h"
13 #include "llvm/ADT/StringRef.h"
14 #include "llvm/ADT/StringSet.h"
15 #include "llvm/BinaryFormat/Wasm.h"
16 #include "llvm/Support/CachePruning.h"
17 #include <optional>
19 namespace llvm {
20 enum class CodeGenOptLevel;
21 } // namespace llvm
23 namespace lld::wasm {
25 class InputFile;
26 class Symbol;
28 // For --unresolved-symbols.
29 enum class UnresolvedPolicy { ReportError, Warn, Ignore, ImportDynamic };
31 // For --build-id.
32 enum class BuildIdKind { None, Fast, Sha1, Hexstring, Uuid };
34 // This struct contains the global configuration for the linker.
35 // Most fields are direct mapping from the command line options
36 // and such fields have the same name as the corresponding options.
37 // Most fields are initialized by the driver.
38 struct Configuration {
39 bool bsymbolic;
40 bool checkFeatures;
41 bool compressRelocations;
42 bool demangle;
43 bool disableVerify;
44 bool experimentalPic;
45 bool emitRelocs;
46 bool exportAll;
47 bool exportDynamic;
48 bool exportTable;
49 bool extendedConst;
50 bool growableTable;
51 bool gcSections;
52 std::optional<std::pair<llvm::StringRef, llvm::StringRef>> memoryImport;
53 std::optional<llvm::StringRef> memoryExport;
54 bool sharedMemory;
55 bool importTable;
56 bool importUndefined;
57 std::optional<bool> is64;
58 bool mergeDataSegments;
59 bool pie;
60 bool printGcSections;
61 bool relocatable;
62 bool saveTemps;
63 bool shared;
64 bool stripAll;
65 bool stripDebug;
66 bool stackFirst;
67 bool isStatic = false;
68 bool trace;
69 uint64_t globalBase;
70 uint64_t initialMemory;
71 uint64_t maxMemory;
72 uint64_t zStackSize;
73 unsigned ltoPartitions;
74 unsigned ltoo;
75 llvm::CodeGenOptLevel ltoCgo;
76 unsigned optimize;
77 llvm::StringRef thinLTOJobs;
78 bool ltoDebugPassManager;
79 UnresolvedPolicy unresolvedSymbols;
80 BuildIdKind buildId = BuildIdKind::None;
82 llvm::StringRef entry;
83 llvm::StringRef mapFile;
84 llvm::StringRef outputFile;
85 llvm::StringRef soName;
86 llvm::StringRef thinLTOCacheDir;
87 llvm::StringRef whyExtract;
89 llvm::StringSet<> allowUndefinedSymbols;
90 llvm::StringSet<> exportedSymbols;
91 std::vector<llvm::StringRef> requiredExports;
92 llvm::SmallVector<llvm::StringRef, 0> searchPaths;
93 llvm::CachePruningPolicy thinLTOCachePolicy;
94 std::optional<std::vector<std::string>> features;
95 std::optional<std::vector<std::string>> extraFeatures;
96 llvm::SmallVector<uint8_t, 0> buildIdVector;
98 // The following config options do not directly correspond to any
99 // particular command line options, and should probably be moved to separate
100 // Ctx struct as in ELF/Config.h
102 // True if we are creating position-independent code.
103 bool isPic;
105 // True if we have an MVP input that uses __indirect_function_table and which
106 // requires it to be allocated to table number 0.
107 bool legacyFunctionTable = false;
109 // The table offset at which to place function addresses. We reserve zero
110 // for the null function pointer. This gets set to 1 for executables and 0
111 // for shared libraries (since they always added to a dynamic offset at
112 // runtime).
113 uint32_t tableBase = 0;
115 // Will be set to true if bss data segments should be emitted. In most cases
116 // this is not necessary.
117 bool emitBssSegments = false;
119 // A tuple of (reference, extractedFile, sym). Used by --why-extract=.
120 llvm::SmallVector<std::tuple<std::string, const InputFile *, const Symbol &>,
122 whyExtractRecords;
125 // The only instance of Configuration struct.
126 extern Configuration *config;
128 } // namespace lld::wasm
130 #endif