0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 //===- MCContext.h - Machine Code Context -----------------------*- C++ -*-===//
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
2 //
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
3 // The LLVM Compiler Infrastructure
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4 //
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 // This file is distributed under the University of Illinois Open Source
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 // License. See LICENSE.TXT for details.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 //
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 //===----------------------------------------------------------------------===//
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 #ifndef LLVM_MC_MCCONTEXT_H
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11 #define LLVM_MC_MCCONTEXT_H
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
13 #include "llvm/ADT/DenseMap.h"
|
77
|
14 #include "llvm/ADT/SetVector.h"
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 #include "llvm/ADT/SmallString.h"
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 #include "llvm/ADT/SmallVector.h"
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
17 #include "llvm/ADT/StringMap.h"
|
121
|
18 #include "llvm/ADT/StringRef.h"
|
95
|
19 #include "llvm/ADT/Twine.h"
|
121
|
20 #include "llvm/BinaryFormat/Dwarf.h"
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
21 #include "llvm/MC/MCDwarf.h"
|
100
|
22 #include "llvm/MC/MCSubtargetInfo.h"
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 #include "llvm/MC/SectionKind.h"
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
24 #include "llvm/Support/Allocator.h"
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
25 #include "llvm/Support/Compiler.h"
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
26 #include "llvm/Support/raw_ostream.h"
|
121
|
27 #include <algorithm>
|
|
28 #include <cassert>
|
|
29 #include <cstddef>
|
|
30 #include <cstdint>
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
31 #include <map>
|
121
|
32 #include <memory>
|
|
33 #include <string>
|
|
34 #include <utility>
|
|
35 #include <vector>
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
36
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
37 namespace llvm {
|
121
|
38
|
|
39 class CodeViewContext;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
40 class MCAsmInfo;
|
121
|
41 class MCLabel;
|
|
42 class MCObjectFileInfo;
|
|
43 class MCRegisterInfo;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
44 class MCSection;
|
121
|
45 class MCSectionCOFF;
|
|
46 class MCSectionELF;
|
|
47 class MCSectionMachO;
|
|
48 class MCSectionWasm;
|
|
49 class MCStreamer;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
50 class MCSymbol;
|
95
|
51 class MCSymbolELF;
|
121
|
52 class MCSymbolWasm;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
53 class SMLoc;
|
121
|
54 class SourceMgr;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
55
|
95
|
56 /// Context object for machine code objects. This class owns all of the
|
|
57 /// sections that it creates.
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
58 ///
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
59 class MCContext {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
60 public:
|
121
|
61 using SymbolTable = StringMap<MCSymbol *, BumpPtrAllocator &>;
|
95
|
62
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
63 private:
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
64 /// The SourceMgr for this object, if any.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
65 const SourceMgr *SrcMgr;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
66
|
121
|
67 /// The SourceMgr for inline assembly, if any.
|
|
68 SourceMgr *InlineSrcMgr;
|
|
69
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
70 /// The MCAsmInfo for this target.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
71 const MCAsmInfo *MAI;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
72
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
73 /// The MCRegisterInfo for this target.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
74 const MCRegisterInfo *MRI;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
75
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
76 /// The MCObjectFileInfo for this target.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
77 const MCObjectFileInfo *MOFI;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
78
|
120
|
79 std::unique_ptr<CodeViewContext> CVContext;
|
|
80
|
95
|
81 /// Allocator object used for creating machine code objects.
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
82 ///
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
83 /// We use a bump pointer allocator to avoid the need to track all allocated
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
84 /// objects.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
85 BumpPtrAllocator Allocator;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
86
|
95
|
87 SpecificBumpPtrAllocator<MCSectionCOFF> COFFAllocator;
|
|
88 SpecificBumpPtrAllocator<MCSectionELF> ELFAllocator;
|
|
89 SpecificBumpPtrAllocator<MCSectionMachO> MachOAllocator;
|
121
|
90 SpecificBumpPtrAllocator<MCSectionWasm> WasmAllocator;
|
95
|
91
|
|
92 /// Bindings of names to symbols.
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
93 SymbolTable Symbols;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
94
|
95
|
95 /// A mapping from a local label number and an instance count to a symbol.
|
77
|
96 /// For example, in the assembly
|
|
97 /// 1:
|
|
98 /// 2:
|
|
99 /// 1:
|
|
100 /// We have three labels represented by the pairs (1, 0), (2, 0) and (1, 1)
|
95
|
101 DenseMap<std::pair<unsigned, unsigned>, MCSymbol *> LocalSymbols;
|
77
|
102
|
95
|
103 /// Keeps tracks of names that were used both for used declared and
|
120
|
104 /// artificial symbols. The value is "true" if the name has been used for a
|
|
105 /// non-section symbol (there can be at most one of those, plus an unlimited
|
|
106 /// number of section symbols with the same name).
|
95
|
107 StringMap<bool, BumpPtrAllocator &> UsedNames;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
108
|
95
|
109 /// The next ID to dole out to an unnamed assembler temporary symbol with
|
|
110 /// a given prefix.
|
|
111 StringMap<unsigned> NextID;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
112
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
113 /// Instances of directional local labels.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
114 DenseMap<unsigned, MCLabel *> Instances;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
115 /// NextInstance() creates the next instance of the directional local label
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
116 /// for the LocalLabelVal and adds it to the map if needed.
|
77
|
117 unsigned NextInstance(unsigned LocalLabelVal);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
118 /// GetInstance() gets the current instance of the directional local label
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
119 /// for the LocalLabelVal and adds it to the map if needed.
|
77
|
120 unsigned GetInstance(unsigned LocalLabelVal);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
121
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
122 /// The file name of the log file from the environment variable
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
123 /// AS_SECURE_LOG_FILE. Which must be set before the .secure_log_unique
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
124 /// directive is used or it is an error.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
125 char *SecureLogFile;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
126 /// The stream that gets written to for the .secure_log_unique directive.
|
100
|
127 std::unique_ptr<raw_fd_ostream> SecureLog;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
128 /// Boolean toggled when .secure_log_unique / .secure_log_reset is seen to
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
129 /// catch errors if .secure_log_unique appears twice without
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
130 /// .secure_log_reset appearing between them.
|
121
|
131 bool SecureLogUsed = false;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
132
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
133 /// The compilation directory to use for DW_AT_comp_dir.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
134 SmallString<128> CompilationDir;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
135
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
136 /// The main file name if passed in explicitly.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
137 std::string MainFileName;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
138
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
139 /// The dwarf file and directory tables from the dwarf .file directive.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
140 /// We now emit a line table for each compile unit. To reduce the prologue
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
141 /// size of each line table, the files and directories used by each compile
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
142 /// unit are separated.
|
77
|
143 std::map<unsigned, MCDwarfLineTable> MCDwarfLineTablesCUMap;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
144
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
145 /// The current dwarf line information from the last dwarf .loc directive.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
146 MCDwarfLoc CurrentDwarfLoc;
|
121
|
147 bool DwarfLocSeen = false;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
148
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
149 /// Generate dwarf debugging info for assembly source files.
|
121
|
150 bool GenDwarfForAssembly = false;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
151
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
152 /// The current dwarf file number when generate dwarf debugging info for
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
153 /// assembly source files.
|
121
|
154 unsigned GenDwarfFileNumber = 0;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
155
|
95
|
156 /// Sections for generating the .debug_ranges and .debug_aranges sections.
|
|
157 SetVector<MCSection *> SectionsForRanges;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
158
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
159 /// The information gathered from labels that will have dwarf label
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
160 /// entries when generating dwarf assembly source files.
|
77
|
161 std::vector<MCGenDwarfLabelEntry> MCGenDwarfLabelEntries;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
162
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
163 /// The string to embed in the debug information for the compile unit, if
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
164 /// non-empty.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
165 StringRef DwarfDebugFlags;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
166
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
167 /// The string to embed in as the dwarf AT_producer for the compile unit, if
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
168 /// non-empty.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
169 StringRef DwarfDebugProducer;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
170
|
77
|
171 /// The maximum version of dwarf that we should emit.
|
121
|
172 uint16_t DwarfVersion = 4;
|
77
|
173
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
174 /// Honor temporary labels, this is useful for debugging semantic
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
175 /// differences between temporary and non-temporary labels (primarily on
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
176 /// Darwin).
|
121
|
177 bool AllowTemporaryLabels = true;
|
95
|
178 bool UseNamesOnTempLabels = true;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
179
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
180 /// The Compile Unit ID that we are currently processing.
|
121
|
181 unsigned DwarfCompileUnitID = 0;
|
77
|
182
|
95
|
183 struct ELFSectionKey {
|
|
184 std::string SectionName;
|
|
185 StringRef GroupName;
|
|
186 unsigned UniqueID;
|
121
|
187
|
95
|
188 ELFSectionKey(StringRef SectionName, StringRef GroupName,
|
|
189 unsigned UniqueID)
|
|
190 : SectionName(SectionName), GroupName(GroupName), UniqueID(UniqueID) {
|
|
191 }
|
121
|
192
|
95
|
193 bool operator<(const ELFSectionKey &Other) const {
|
|
194 if (SectionName != Other.SectionName)
|
|
195 return SectionName < Other.SectionName;
|
|
196 if (GroupName != Other.GroupName)
|
|
197 return GroupName < Other.GroupName;
|
|
198 return UniqueID < Other.UniqueID;
|
|
199 }
|
|
200 };
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
201
|
95
|
202 struct COFFSectionKey {
|
|
203 std::string SectionName;
|
|
204 StringRef GroupName;
|
|
205 int SelectionKey;
|
120
|
206 unsigned UniqueID;
|
121
|
207
|
95
|
208 COFFSectionKey(StringRef SectionName, StringRef GroupName,
|
120
|
209 int SelectionKey, unsigned UniqueID)
|
95
|
210 : SectionName(SectionName), GroupName(GroupName),
|
120
|
211 SelectionKey(SelectionKey), UniqueID(UniqueID) {}
|
121
|
212
|
95
|
213 bool operator<(const COFFSectionKey &Other) const {
|
|
214 if (SectionName != Other.SectionName)
|
|
215 return SectionName < Other.SectionName;
|
|
216 if (GroupName != Other.GroupName)
|
|
217 return GroupName < Other.GroupName;
|
120
|
218 if (SelectionKey != Other.SelectionKey)
|
|
219 return SelectionKey < Other.SelectionKey;
|
|
220 return UniqueID < Other.UniqueID;
|
95
|
221 }
|
|
222 };
|
|
223
|
121
|
224 struct WasmSectionKey {
|
|
225 std::string SectionName;
|
|
226 StringRef GroupName;
|
|
227 unsigned UniqueID;
|
|
228
|
|
229 WasmSectionKey(StringRef SectionName, StringRef GroupName,
|
|
230 unsigned UniqueID)
|
|
231 : SectionName(SectionName), GroupName(GroupName), UniqueID(UniqueID) {
|
|
232 }
|
|
233
|
|
234 bool operator<(const WasmSectionKey &Other) const {
|
|
235 if (SectionName != Other.SectionName)
|
|
236 return SectionName < Other.SectionName;
|
|
237 if (GroupName != Other.GroupName)
|
|
238 return GroupName < Other.GroupName;
|
|
239 return UniqueID < Other.UniqueID;
|
|
240 }
|
|
241 };
|
|
242
|
95
|
243 StringMap<MCSectionMachO *> MachOUniquingMap;
|
|
244 std::map<ELFSectionKey, MCSectionELF *> ELFUniquingMap;
|
|
245 std::map<COFFSectionKey, MCSectionCOFF *> COFFUniquingMap;
|
121
|
246 std::map<WasmSectionKey, MCSectionWasm *> WasmUniquingMap;
|
|
247 StringMap<bool> RelSecNames;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
248
|
100
|
249 SpecificBumpPtrAllocator<MCSubtargetInfo> MCSubtargetAllocator;
|
|
250
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
251 /// Do automatic reset in destructor
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
252 bool AutoReset;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
253
|
121
|
254 bool HadError = false;
|
100
|
255
|
95
|
256 MCSymbol *createSymbolImpl(const StringMapEntry<bool> *Name,
|
|
257 bool CanBeUnnamed);
|
|
258 MCSymbol *createSymbol(StringRef Name, bool AlwaysAddSuffix,
|
|
259 bool IsTemporary);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
260
|
77
|
261 MCSymbol *getOrCreateDirectionalLocalSymbol(unsigned LocalLabelVal,
|
|
262 unsigned Instance);
|
|
263
|
121
|
264 MCSectionELF *createELFSectionImpl(StringRef Section, unsigned Type,
|
|
265 unsigned Flags, SectionKind K,
|
|
266 unsigned EntrySize,
|
|
267 const MCSymbolELF *Group,
|
|
268 unsigned UniqueID,
|
|
269 const MCSymbolELF *Associated);
|
|
270
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
271 public:
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
272 explicit MCContext(const MCAsmInfo *MAI, const MCRegisterInfo *MRI,
|
77
|
273 const MCObjectFileInfo *MOFI,
|
|
274 const SourceMgr *Mgr = nullptr, bool DoAutoReset = true);
|
121
|
275 MCContext(const MCContext &) = delete;
|
|
276 MCContext &operator=(const MCContext &) = delete;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
277 ~MCContext();
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
278
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
279 const SourceMgr *getSourceManager() const { return SrcMgr; }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
280
|
121
|
281 void setInlineSourceManager(SourceMgr *SM) { InlineSrcMgr = SM; }
|
|
282
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
283 const MCAsmInfo *getAsmInfo() const { return MAI; }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
284
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
285 const MCRegisterInfo *getRegisterInfo() const { return MRI; }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
286
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
287 const MCObjectFileInfo *getObjectFileInfo() const { return MOFI; }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
288
|
120
|
289 CodeViewContext &getCVContext();
|
|
290
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
291 void setAllowTemporaryLabels(bool Value) { AllowTemporaryLabels = Value; }
|
95
|
292 void setUseNamesOnTempLabels(bool Value) { UseNamesOnTempLabels = Value; }
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
293
|
95
|
294 /// \name Module Lifetime Management
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
295 /// @{
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
296
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
297 /// reset - return object to right after construction state to prepare
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
298 /// to process a new module
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
299 void reset();
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
300
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
301 /// @}
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
302
|
95
|
303 /// \name Symbol Management
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
304 /// @{
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
305
|
95
|
306 /// Create and return a new linker temporary symbol with a unique but
|
|
307 /// unspecified name.
|
|
308 MCSymbol *createLinkerPrivateTempSymbol();
|
77
|
309
|
95
|
310 /// Create and return a new assembler temporary symbol with a unique but
|
|
311 /// unspecified name.
|
|
312 MCSymbol *createTempSymbol(bool CanBeUnnamed = true);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
313
|
95
|
314 MCSymbol *createTempSymbol(const Twine &Name, bool AlwaysAddSuffix,
|
|
315 bool CanBeUnnamed = true);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
316
|
77
|
317 /// Create the definition of a directional local symbol for numbered label
|
|
318 /// (used for "1:" definitions).
|
95
|
319 MCSymbol *createDirectionalLocalSymbol(unsigned LocalLabelVal);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
320
|
77
|
321 /// Create and return a directional local symbol for numbered label (used
|
|
322 /// for "1b" or 1f" references).
|
95
|
323 MCSymbol *getDirectionalLocalSymbol(unsigned LocalLabelVal, bool Before);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
324
|
95
|
325 /// Lookup the symbol inside with the specified \p Name. If it exists,
|
|
326 /// return it. If not, create a forward reference and return it.
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
327 ///
|
95
|
328 /// \param Name - The symbol name, which must be unique across all symbols.
|
|
329 MCSymbol *getOrCreateSymbol(const Twine &Name);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
330
|
95
|
331 /// Gets a symbol that will be defined to the final stack offset of a local
|
|
332 /// variable after codegen.
|
|
333 ///
|
|
334 /// \param Idx - The index of a local variable passed to @llvm.localescape.
|
|
335 MCSymbol *getOrCreateFrameAllocSymbol(StringRef FuncName, unsigned Idx);
|
83
|
336
|
95
|
337 MCSymbol *getOrCreateParentFrameOffsetSymbol(StringRef FuncName);
|
|
338
|
|
339 MCSymbol *getOrCreateLSDASymbol(StringRef FuncName);
|
|
340
|
|
341 /// Get the symbol for \p Name, or null.
|
|
342 MCSymbol *lookupSymbol(const Twine &Name) const;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
343
|
121
|
344 /// Set value for a symbol.
|
|
345 void setSymbolValue(MCStreamer &Streamer, StringRef Sym, uint64_t Val);
|
|
346
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
347 /// getSymbols - Get a reference for the symbol table for clients that
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
348 /// want to, for example, iterate over all symbols. 'const' because we
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
349 /// still want any modifications to the table itself to use the MCContext
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
350 /// APIs.
|
95
|
351 const SymbolTable &getSymbols() const { return Symbols; }
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
352
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
353 /// @}
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
354
|
95
|
355 /// \name Section Management
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
356 /// @{
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
357
|
120
|
358 enum : unsigned {
|
|
359 /// Pass this value as the UniqueID during section creation to get the
|
|
360 /// generic section with the given name and characteristics. The usual
|
|
361 /// sections such as .text use this ID.
|
|
362 GenericSectionID = ~0U
|
|
363 };
|
|
364
|
95
|
365 /// Return the MCSection for the specified mach-o section. This requires
|
|
366 /// the operands to be valid.
|
|
367 MCSectionMachO *getMachOSection(StringRef Segment, StringRef Section,
|
|
368 unsigned TypeAndAttributes,
|
|
369 unsigned Reserved2, SectionKind K,
|
|
370 const char *BeginSymName = nullptr);
|
|
371
|
|
372 MCSectionMachO *getMachOSection(StringRef Segment, StringRef Section,
|
|
373 unsigned TypeAndAttributes, SectionKind K,
|
|
374 const char *BeginSymName = nullptr) {
|
|
375 return getMachOSection(Segment, Section, TypeAndAttributes, 0, K,
|
|
376 BeginSymName);
|
|
377 }
|
|
378
|
120
|
379 MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
|
95
|
380 unsigned Flags) {
|
121
|
381 return getELFSection(Section, Type, Flags, 0, "");
|
95
|
382 }
|
|
383
|
120
|
384 MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
|
95
|
385 unsigned Flags, unsigned EntrySize,
|
120
|
386 const Twine &Group) {
|
121
|
387 return getELFSection(Section, Type, Flags, EntrySize, Group, ~0);
|
95
|
388 }
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
389
|
120
|
390 MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
|
95
|
391 unsigned Flags, unsigned EntrySize,
|
120
|
392 const Twine &Group, unsigned UniqueID) {
|
95
|
393 return getELFSection(Section, Type, Flags, EntrySize, Group, UniqueID,
|
|
394 nullptr);
|
|
395 }
|
83
|
396
|
120
|
397 MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
|
95
|
398 unsigned Flags, unsigned EntrySize,
|
120
|
399 const Twine &Group, unsigned UniqueID,
|
121
|
400 const MCSymbolELF *Associated);
|
77
|
401
|
120
|
402 MCSectionELF *getELFSection(const Twine &Section, unsigned Type,
|
95
|
403 unsigned Flags, unsigned EntrySize,
|
|
404 const MCSymbolELF *Group, unsigned UniqueID,
|
121
|
405 const MCSymbolELF *Associated);
|
95
|
406
|
120
|
407 /// Get a section with the provided group identifier. This section is
|
|
408 /// named by concatenating \p Prefix with '.' then \p Suffix. The \p Type
|
|
409 /// describes the type of the section and \p Flags are used to further
|
|
410 /// configure this named section.
|
|
411 MCSectionELF *getELFNamedSection(const Twine &Prefix, const Twine &Suffix,
|
|
412 unsigned Type, unsigned Flags,
|
|
413 unsigned EntrySize = 0);
|
|
414
|
|
415 MCSectionELF *createELFRelSection(const Twine &Name, unsigned Type,
|
95
|
416 unsigned Flags, unsigned EntrySize,
|
|
417 const MCSymbolELF *Group,
|
121
|
418 const MCSectionELF *RelInfoSection);
|
95
|
419
|
|
420 void renameELFSection(MCSectionELF *Section, StringRef Name);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
421
|
95
|
422 MCSectionELF *createELFGroupSection(const MCSymbolELF *Group);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
423
|
95
|
424 MCSectionCOFF *getCOFFSection(StringRef Section, unsigned Characteristics,
|
|
425 SectionKind Kind, StringRef COMDATSymName,
|
|
426 int Selection,
|
120
|
427 unsigned UniqueID = GenericSectionID,
|
95
|
428 const char *BeginSymName = nullptr);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
429
|
95
|
430 MCSectionCOFF *getCOFFSection(StringRef Section, unsigned Characteristics,
|
|
431 SectionKind Kind,
|
|
432 const char *BeginSymName = nullptr);
|
|
433
|
|
434 MCSectionCOFF *getCOFFSection(StringRef Section);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
435
|
77
|
436 /// Gets or creates a section equivalent to Sec that is associated with the
|
|
437 /// section containing KeySym. For example, to create a debug info section
|
|
438 /// associated with an inline function, pass the normal debug info section
|
|
439 /// as Sec and the function symbol as KeySym.
|
120
|
440 MCSectionCOFF *
|
|
441 getAssociativeCOFFSection(MCSectionCOFF *Sec, const MCSymbol *KeySym,
|
|
442 unsigned UniqueID = GenericSectionID);
|
77
|
443
|
121
|
444 MCSectionWasm *getWasmSection(const Twine &Section, SectionKind K) {
|
|
445 return getWasmSection(Section, K, nullptr);
|
|
446 }
|
|
447
|
|
448 MCSectionWasm *getWasmSection(const Twine &Section, SectionKind K,
|
|
449 const char *BeginSymName) {
|
|
450 return getWasmSection(Section, K, "", ~0, BeginSymName);
|
|
451 }
|
|
452
|
|
453 MCSectionWasm *getWasmSection(const Twine &Section, SectionKind K,
|
|
454 const Twine &Group, unsigned UniqueID) {
|
|
455 return getWasmSection(Section, K, Group, UniqueID, nullptr);
|
|
456 }
|
|
457
|
|
458 MCSectionWasm *getWasmSection(const Twine &Section, SectionKind K,
|
|
459 const Twine &Group, unsigned UniqueID,
|
|
460 const char *BeginSymName);
|
|
461
|
|
462 MCSectionWasm *getWasmSection(const Twine &Section, SectionKind K,
|
|
463 const MCSymbolWasm *Group, unsigned UniqueID,
|
|
464 const char *BeginSymName);
|
|
465
|
100
|
466 // Create and save a copy of STI and return a reference to the copy.
|
|
467 MCSubtargetInfo &getSubtargetCopy(const MCSubtargetInfo &STI);
|
|
468
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
469 /// @}
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
470
|
95
|
471 /// \name Dwarf Management
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
472 /// @{
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
473
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
474 /// \brief Get the compilation directory for DW_AT_comp_dir
|
120
|
475 /// The compilation directory should be set with \c setCompilationDir before
|
|
476 /// calling this function. If it is unset, an empty string will be returned.
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
477 StringRef getCompilationDir() const { return CompilationDir; }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
478
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
479 /// \brief Set the compilation directory for DW_AT_comp_dir
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
480 void setCompilationDir(StringRef S) { CompilationDir = S.str(); }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
481
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
482 /// \brief Get the main file name for use in error messages and debug
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
483 /// info. This can be set to ensure we've got the correct file name
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
484 /// after preprocessing or for -save-temps.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
485 const std::string &getMainFileName() const { return MainFileName; }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
486
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
487 /// \brief Set the main file name and override the default.
|
77
|
488 void setMainFileName(StringRef S) { MainFileName = S; }
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
489
|
95
|
490 /// Creates an entry in the dwarf file and directory tables.
|
|
491 unsigned getDwarfFile(StringRef Directory, StringRef FileName,
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
492 unsigned FileNumber, unsigned CUID);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
493
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
494 bool isValidDwarfFileNumber(unsigned FileNumber, unsigned CUID = 0);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
495
|
77
|
496 const std::map<unsigned, MCDwarfLineTable> &getMCDwarfLineTables() const {
|
|
497 return MCDwarfLineTablesCUMap;
|
|
498 }
|
|
499
|
|
500 MCDwarfLineTable &getMCDwarfLineTable(unsigned CUID) {
|
|
501 return MCDwarfLineTablesCUMap[CUID];
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
502 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
503
|
77
|
504 const MCDwarfLineTable &getMCDwarfLineTable(unsigned CUID) const {
|
|
505 auto I = MCDwarfLineTablesCUMap.find(CUID);
|
|
506 assert(I != MCDwarfLineTablesCUMap.end());
|
|
507 return I->second;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
508 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
509
|
77
|
510 const SmallVectorImpl<MCDwarfFile> &getMCDwarfFiles(unsigned CUID = 0) {
|
|
511 return getMCDwarfLineTable(CUID).getMCDwarfFiles();
|
|
512 }
|
121
|
513
|
77
|
514 const SmallVectorImpl<std::string> &getMCDwarfDirs(unsigned CUID = 0) {
|
|
515 return getMCDwarfLineTable(CUID).getMCDwarfDirs();
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
516 }
|
77
|
517
|
|
518 bool hasMCLineSections() const {
|
|
519 for (const auto &Table : MCDwarfLineTablesCUMap)
|
|
520 if (!Table.second.getMCDwarfFiles().empty() || Table.second.getLabel())
|
|
521 return true;
|
|
522 return false;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
523 }
|
121
|
524
|
95
|
525 unsigned getDwarfCompileUnitID() { return DwarfCompileUnitID; }
|
121
|
526
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
527 void setDwarfCompileUnitID(unsigned CUIndex) {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
528 DwarfCompileUnitID = CUIndex;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
529 }
|
121
|
530
|
77
|
531 void setMCLineTableCompilationDir(unsigned CUID, StringRef CompilationDir) {
|
|
532 getMCDwarfLineTable(CUID).setCompilationDir(CompilationDir);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
533 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
534
|
95
|
535 /// Saves the information from the currently parsed dwarf .loc directive
|
|
536 /// and sets DwarfLocSeen. When the next instruction is assembled an entry
|
|
537 /// in the line number table with this information and the address of the
|
|
538 /// instruction will be created.
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
539 void setCurrentDwarfLoc(unsigned FileNum, unsigned Line, unsigned Column,
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
540 unsigned Flags, unsigned Isa,
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
541 unsigned Discriminator) {
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
542 CurrentDwarfLoc.setFileNum(FileNum);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
543 CurrentDwarfLoc.setLine(Line);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
544 CurrentDwarfLoc.setColumn(Column);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
545 CurrentDwarfLoc.setFlags(Flags);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
546 CurrentDwarfLoc.setIsa(Isa);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
547 CurrentDwarfLoc.setDiscriminator(Discriminator);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
548 DwarfLocSeen = true;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
549 }
|
121
|
550
|
95
|
551 void clearDwarfLocSeen() { DwarfLocSeen = false; }
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
552
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
553 bool getDwarfLocSeen() { return DwarfLocSeen; }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
554 const MCDwarfLoc &getCurrentDwarfLoc() { return CurrentDwarfLoc; }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
555
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
556 bool getGenDwarfForAssembly() { return GenDwarfForAssembly; }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
557 void setGenDwarfForAssembly(bool Value) { GenDwarfForAssembly = Value; }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
558 unsigned getGenDwarfFileNumber() { return GenDwarfFileNumber; }
|
121
|
559
|
77
|
560 void setGenDwarfFileNumber(unsigned FileNumber) {
|
|
561 GenDwarfFileNumber = FileNumber;
|
|
562 }
|
121
|
563
|
95
|
564 const SetVector<MCSection *> &getGenDwarfSectionSyms() {
|
|
565 return SectionsForRanges;
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
566 }
|
121
|
567
|
95
|
568 bool addGenDwarfSection(MCSection *Sec) {
|
|
569 return SectionsForRanges.insert(Sec);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
570 }
|
95
|
571
|
77
|
572 void finalizeDwarfSections(MCStreamer &MCOS);
|
121
|
573
|
77
|
574 const std::vector<MCGenDwarfLabelEntry> &getMCGenDwarfLabelEntries() const {
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
575 return MCGenDwarfLabelEntries;
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
576 }
|
121
|
577
|
77
|
578 void addMCGenDwarfLabelEntry(const MCGenDwarfLabelEntry &E) {
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
579 MCGenDwarfLabelEntries.push_back(E);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
580 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
581
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
582 void setDwarfDebugFlags(StringRef S) { DwarfDebugFlags = S; }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
583 StringRef getDwarfDebugFlags() { return DwarfDebugFlags; }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
584
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
585 void setDwarfDebugProducer(StringRef S) { DwarfDebugProducer = S; }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
586 StringRef getDwarfDebugProducer() { return DwarfDebugProducer; }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
587
|
121
|
588 dwarf::DwarfFormat getDwarfFormat() const {
|
|
589 // TODO: Support DWARF64
|
|
590 return dwarf::DWARF32;
|
|
591 }
|
|
592
|
77
|
593 void setDwarfVersion(uint16_t v) { DwarfVersion = v; }
|
|
594 uint16_t getDwarfVersion() const { return DwarfVersion; }
|
|
595
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
596 /// @}
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
597
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
598 char *getSecureLogFile() { return SecureLogFile; }
|
100
|
599 raw_fd_ostream *getSecureLog() { return SecureLog.get(); }
|
121
|
600
|
100
|
601 void setSecureLog(std::unique_ptr<raw_fd_ostream> Value) {
|
|
602 SecureLog = std::move(Value);
|
|
603 }
|
121
|
604
|
|
605 bool getSecureLogUsed() { return SecureLogUsed; }
|
95
|
606 void setSecureLogUsed(bool Value) { SecureLogUsed = Value; }
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
607
|
95
|
608 void *allocate(unsigned Size, unsigned Align = 8) {
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
609 return Allocator.Allocate(Size, Align);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
610 }
|
121
|
611
|
95
|
612 void deallocate(void *Ptr) {}
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
613
|
100
|
614 bool hadError() { return HadError; }
|
|
615 void reportError(SMLoc L, const Twine &Msg);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
616 // Unrecoverable error has occurred. Display the best diagnostic we can
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
617 // and bail via exit(1). For now, most MC backend errors are unrecoverable.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
618 // FIXME: We should really do something about that.
|
95
|
619 LLVM_ATTRIBUTE_NORETURN void reportFatalError(SMLoc L,
|
100
|
620 const Twine &Msg);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
621 };
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
622
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
623 } // end namespace llvm
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
624
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
625 // operator new and delete aren't allowed inside namespaces.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
626 // The throw specifications are mandated by the standard.
|
95
|
627 /// \brief Placement new for using the MCContext's allocator.
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
628 ///
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
629 /// This placement form of operator new uses the MCContext's allocator for
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
630 /// obtaining memory. It is a non-throwing new, which means that it returns
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
631 /// null on error. (If that is what the allocator does. The current does, so if
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
632 /// this ever changes, this operator will have to be changed, too.)
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
633 /// Usage looks like this (assuming there's an MCContext 'Context' in scope):
|
95
|
634 /// \code
|
|
635 /// // Default alignment (8)
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
636 /// IntegerLiteral *Ex = new (Context) IntegerLiteral(arguments);
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
637 /// // Specific alignment
|
95
|
638 /// IntegerLiteral *Ex2 = new (Context, 4) IntegerLiteral(arguments);
|
|
639 /// \endcode
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
640 /// Please note that you cannot use delete on the pointer; it must be
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
641 /// deallocated using an explicit destructor call followed by
|
95
|
642 /// \c Context.Deallocate(Ptr).
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
643 ///
|
95
|
644 /// \param Bytes The number of bytes to allocate. Calculated by the compiler.
|
|
645 /// \param C The MCContext that provides the allocator.
|
|
646 /// \param Alignment The alignment of the allocated memory (if the underlying
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
647 /// allocator supports it).
|
95
|
648 /// \return The allocated memory. Could be NULL.
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
649 inline void *operator new(size_t Bytes, llvm::MCContext &C,
|
120
|
650 size_t Alignment = 8) noexcept {
|
95
|
651 return C.allocate(Bytes, Alignment);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
652 }
|
95
|
653 /// \brief Placement delete companion to the new above.
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
654 ///
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
655 /// This operator is just a companion to the new above. There is no way of
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
656 /// invoking it directly; see the new operator for more details. This operator
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
657 /// is called implicitly by the compiler if a placement new expression using
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
658 /// the MCContext throws in the object constructor.
|
120
|
659 inline void operator delete(void *Ptr, llvm::MCContext &C, size_t) noexcept {
|
95
|
660 C.deallocate(Ptr);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
661 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
662
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
663 /// This placement form of operator new[] uses the MCContext's allocator for
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
664 /// obtaining memory. It is a non-throwing new[], which means that it returns
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
665 /// null on error.
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
666 /// Usage looks like this (assuming there's an MCContext 'Context' in scope):
|
95
|
667 /// \code
|
|
668 /// // Default alignment (8)
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
669 /// char *data = new (Context) char[10];
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
670 /// // Specific alignment
|
95
|
671 /// char *data = new (Context, 4) char[10];
|
|
672 /// \endcode
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
673 /// Please note that you cannot use delete on the pointer; it must be
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
674 /// deallocated using an explicit destructor call followed by
|
95
|
675 /// \c Context.Deallocate(Ptr).
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
676 ///
|
95
|
677 /// \param Bytes The number of bytes to allocate. Calculated by the compiler.
|
|
678 /// \param C The MCContext that provides the allocator.
|
|
679 /// \param Alignment The alignment of the allocated memory (if the underlying
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
680 /// allocator supports it).
|
95
|
681 /// \return The allocated memory. Could be NULL.
|
|
682 inline void *operator new[](size_t Bytes, llvm::MCContext &C,
|
120
|
683 size_t Alignment = 8) noexcept {
|
95
|
684 return C.allocate(Bytes, Alignment);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
685 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
686
|
95
|
687 /// \brief Placement delete[] companion to the new[] above.
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
688 ///
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
689 /// This operator is just a companion to the new[] above. There is no way of
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
690 /// invoking it directly; see the new[] operator for more details. This operator
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
691 /// is called implicitly by the compiler if a placement new[] expression using
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
692 /// the MCContext throws in the object constructor.
|
120
|
693 inline void operator delete[](void *Ptr, llvm::MCContext &C) noexcept {
|
95
|
694 C.deallocate(Ptr);
|
0
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
695 }
|
Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
696
|
121
|
697 #endif // LLVM_MC_MCCONTEXT_H
|