[mlir][py] Enable loading only specified dialects during creation. (#121421)
[llvm-project.git] / lld / COFF / COFFLinkerContext.h
blobbdd625b8c3916bb38fdfadce42bc1af37e34c090
1 //===- COFFLinkerContext.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_COFF_COFFLINKERCONTEXT_H
10 #define LLD_COFF_COFFLINKERCONTEXT_H
12 #include "Chunks.h"
13 #include "Config.h"
14 #include "DebugTypes.h"
15 #include "Driver.h"
16 #include "InputFiles.h"
17 #include "SymbolTable.h"
18 #include "Writer.h"
19 #include "lld/Common/CommonLinkerContext.h"
20 #include "lld/Common/Timer.h"
22 namespace lld::coff {
24 class COFFLinkerContext : public CommonLinkerContext {
25 public:
26 COFFLinkerContext();
27 COFFLinkerContext(const COFFLinkerContext &) = delete;
28 COFFLinkerContext &operator=(const COFFLinkerContext &) = delete;
29 ~COFFLinkerContext() = default;
31 LinkerDriver driver;
32 SymbolTable symtab;
33 COFFOptTable optTable;
35 // A hybrid ARM64EC symbol table on ARM64X target.
36 std::optional<SymbolTable> hybridSymtab;
38 // Pointer to the ARM64EC symbol table: either symtab for an ARM64EC target or
39 // hybridSymtab for an ARM64X target.
40 SymbolTable *symtabEC = nullptr;
42 // Returns the appropriate symbol table for the specified machine type.
43 SymbolTable &getSymtab(llvm::COFF::MachineTypes machine) {
44 if (hybridSymtab && (machine == ARM64EC || machine == AMD64))
45 return *hybridSymtab;
46 return symtab;
49 // Invoke the specified callback for each symbol table.
50 void forEachSymtab(std::function<void(SymbolTable &symtab)> f) {
51 f(symtab);
52 if (hybridSymtab)
53 f(*hybridSymtab);
56 std::vector<ObjFile *> objFileInstances;
57 std::map<std::string, PDBInputFile *> pdbInputFileInstances;
58 std::vector<ImportFile *> importFileInstances;
59 std::vector<BitcodeFile *> bitcodeFileInstances;
61 MergeChunk *mergeChunkInstances[Log2MaxSectionAlignment + 1] = {};
63 /// All sources of type information in the program.
64 std::vector<TpiSource *> tpiSourceList;
66 void addTpiSource(TpiSource *tpi) { tpiSourceList.push_back(tpi); }
68 std::map<llvm::codeview::GUID, TpiSource *> typeServerSourceMappings;
69 std::map<uint32_t, TpiSource *> precompSourceMappings;
71 /// List of all output sections. After output sections are finalized, this
72 /// can be indexed by getOutputSection.
73 std::vector<OutputSection *> outputSections;
75 OutputSection *getOutputSection(const Chunk *c) const {
76 return c->osidx == 0 ? nullptr : outputSections[c->osidx - 1];
79 // Fake sections for parsing bitcode files.
80 FakeSection ltoTextSection;
81 FakeSection ltoDataSection;
82 FakeSectionChunk ltoTextSectionChunk;
83 FakeSectionChunk ltoDataSectionChunk;
85 // All timers used in the COFF linker.
86 Timer rootTimer;
87 Timer inputFileTimer;
88 Timer ltoTimer;
89 Timer gcTimer;
90 Timer icfTimer;
92 // Writer timers.
93 Timer codeLayoutTimer;
94 Timer outputCommitTimer;
95 Timer totalMapTimer;
96 Timer symbolGatherTimer;
97 Timer symbolStringsTimer;
98 Timer writeTimer;
100 // PDB timers.
101 Timer totalPdbLinkTimer;
102 Timer addObjectsTimer;
103 Timer typeMergingTimer;
104 Timer loadGHashTimer;
105 Timer mergeGHashTimer;
106 Timer symbolMergingTimer;
107 Timer publicsLayoutTimer;
108 Timer tpiStreamLayoutTimer;
109 Timer diskCommitTimer;
111 Configuration config;
113 DynamicRelocsChunk *dynamicRelocs = nullptr;
116 } // namespace lld::coff
118 #endif