[TableGen] Fix validateOperandClass for non Phyical Reg (#118146)
[llvm-project.git] / llvm / lib / DWARFLinker / Parallel / DWARFLinkerGlobalData.h
blob7ca81eb34f005ef54a96a87e1066f76b215dbe7e
1 //===- DWARFLinkerGlobalData.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 LLVM_LIB_DWARFLINKER_PARALLEL_DWARFLINKERGLOBALDATA_H
10 #define LLVM_LIB_DWARFLINKER_PARALLEL_DWARFLINKERGLOBALDATA_H
12 #include "TypePool.h"
13 #include "llvm/DWARFLinker/Parallel/DWARFLinker.h"
14 #include "llvm/DWARFLinker/StringPool.h"
15 #include "llvm/Support/PerThreadBumpPtrAllocator.h"
17 namespace llvm {
19 class DWARFDie;
21 namespace dwarf_linker {
22 namespace parallel {
24 using MessageHandlerTy = std::function<void(
25 const Twine &Warning, StringRef Context, const DWARFDie *DIE)>;
27 /// linking options
28 struct DWARFLinkerOptions {
29 /// DWARF version for the output.
30 uint16_t TargetDWARFVersion = 0;
32 /// Generate processing log to the standard output.
33 bool Verbose = false;
35 /// Print statistics.
36 bool Statistics = false;
38 /// Verify the input DWARF.
39 bool VerifyInputDWARF = false;
41 /// Do not unique types according to ODR
42 bool NoODR = false;
44 /// Update index tables.
45 bool UpdateIndexTablesOnly = false;
47 /// Whether we want a static variable to force us to keep its enclosing
48 /// function.
49 bool KeepFunctionForStatic = false;
51 /// Allow to generate valid, but non deterministic output.
52 bool AllowNonDeterministicOutput = false;
54 /// Number of threads.
55 unsigned Threads = 1;
57 /// The accelerator table kinds
58 SmallVector<DWARFLinkerBase::AccelTableKind, 1> AccelTables;
60 /// Prepend path for the clang modules.
61 std::string PrependPath;
63 /// input verification handler(it might be called asynchronously).
64 DWARFLinkerBase::InputVerificationHandlerTy InputVerificationHandler =
65 nullptr;
67 /// A list of all .swiftinterface files referenced by the debug
68 /// info, mapping Module name to path on disk. The entries need to
69 /// be uniqued and sorted and there are only few entries expected
70 /// per compile unit, which is why this is a std::map.
71 /// this is dsymutil specific fag.
72 ///
73 /// (it might be called asynchronously).
74 DWARFLinkerBase::SwiftInterfacesMapTy *ParseableSwiftInterfaces = nullptr;
76 /// A list of remappings to apply to file paths.
77 ///
78 /// (it might be called asynchronously).
79 DWARFLinkerBase::ObjectPrefixMapTy *ObjectPrefixMap = nullptr;
82 class DWARFLinkerImpl;
84 /// This class keeps data and services common for the whole linking process.
85 class LinkingGlobalData {
86 friend DWARFLinkerImpl;
88 public:
89 /// Returns global per-thread allocator.
90 llvm::parallel::PerThreadBumpPtrAllocator &getAllocator() {
91 return Allocator;
94 /// Returns global string pool.
95 StringPool &getStringPool() { return Strings; }
97 /// Returns linking options.
98 const DWARFLinkerOptions &getOptions() const { return Options; }
100 /// Set warning handler.
101 void setWarningHandler(MessageHandlerTy Handler) { WarningHandler = Handler; }
103 /// Set error handler.
104 void setErrorHandler(MessageHandlerTy Handler) { ErrorHandler = Handler; }
106 /// Report warning.
107 void warn(const Twine &Warning, StringRef Context,
108 const DWARFDie *DIE = nullptr) {
109 if (WarningHandler)
110 (WarningHandler)(Warning, Context, DIE);
113 /// Report warning.
114 void warn(Error Warning, StringRef Context, const DWARFDie *DIE = nullptr) {
115 handleAllErrors(std::move(Warning), [&](ErrorInfoBase &Info) {
116 warn(Info.message(), Context, DIE);
120 /// Report error.
121 void error(const Twine &Err, StringRef Context,
122 const DWARFDie *DIE = nullptr) {
123 if (ErrorHandler)
124 (ErrorHandler)(Err, Context, DIE);
127 /// Report error.
128 void error(Error Err, StringRef Context, const DWARFDie *DIE = nullptr) {
129 handleAllErrors(std::move(Err), [&](ErrorInfoBase &Info) {
130 error(Info.message(), Context, DIE);
134 /// Set target triple.
135 void setTargetTriple(const Triple &TargetTriple) {
136 this->TargetTriple = TargetTriple;
139 /// Optionally return target triple.
140 std::optional<std::reference_wrapper<const Triple>> getTargetTriple() {
141 if (TargetTriple)
142 return std::cref(*TargetTriple);
144 return std::nullopt;
147 protected:
148 llvm::parallel::PerThreadBumpPtrAllocator Allocator;
149 StringPool Strings;
150 DWARFLinkerOptions Options;
151 MessageHandlerTy WarningHandler;
152 MessageHandlerTy ErrorHandler;
154 /// Triple for output data. May be not set if generation of output
155 /// data is not requested.
156 std::optional<Triple> TargetTriple;
159 } // end of namespace parallel
160 } // end of namespace dwarf_linker
161 } // end of namespace llvm
163 #endif // LLVM_LIB_DWARFLINKER_PARALLEL_DWARFLINKERGLOBALDATA_H