LLVM 20.0.0git
MCMachOStreamer.cpp
Go to the documentation of this file.
1//===- MCMachOStreamer.cpp - MachO Streamer -------------------------------===//
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//===----------------------------------------------------------------------===//
8
9#include "llvm/ADT/DenseMap.h"
12#include "llvm/ADT/StringRef.h"
15#include "llvm/MC/MCAssembler.h"
17#include "llvm/MC/MCContext.h"
19#include "llvm/MC/MCExpr.h"
20#include "llvm/MC/MCFixup.h"
21#include "llvm/MC/MCFragment.h"
27#include "llvm/MC/MCSection.h"
29#include "llvm/MC/MCSymbol.h"
31#include "llvm/MC/MCValue.h"
32#include "llvm/MC/SectionKind.h"
36#include <cassert>
37#include <vector>
38
39namespace llvm {
40class MCInst;
41class MCStreamer;
42class MCSubtargetInfo;
43class Triple;
44} // namespace llvm
45
46using namespace llvm;
47
48namespace {
49
50class MCMachOStreamer : public MCObjectStreamer {
51private:
52 /// LabelSections - true if each section change should emit a linker local
53 /// label for use in relocations for assembler local references. Obviates the
54 /// need for local relocations. False by default.
55 bool LabelSections;
56
57 /// HasSectionLabel - map of which sections have already had a non-local
58 /// label emitted to them. Used so we don't emit extraneous linker local
59 /// labels in the middle of the section.
61
62 void emitInstToData(const MCInst &Inst, const MCSubtargetInfo &STI) override;
63
64 void emitDataRegion(MachO::DataRegionType Kind);
65 void emitDataRegionEnd();
66
67public:
68 MCMachOStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> MAB,
69 std::unique_ptr<MCObjectWriter> OW,
70 std::unique_ptr<MCCodeEmitter> Emitter, bool label)
71 : MCObjectStreamer(Context, std::move(MAB), std::move(OW),
72 std::move(Emitter)),
73 LabelSections(label) {}
74
75 /// state management
76 void reset() override {
77 HasSectionLabel.clear();
79 }
80
81 MachObjectWriter &getWriter() {
82 return static_cast<MachObjectWriter &>(getAssembler().getWriter());
83 }
84
85 /// @name MCStreamer Interface
86 /// @{
87
88 void changeSection(MCSection *Sect, uint32_t Subsection = 0) override;
89 void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
90 void emitAssignment(MCSymbol *Symbol, const MCExpr *Value) override;
91 void emitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol) override;
92 void emitAssemblerFlag(MCAssemblerFlag Flag) override;
93 void emitLinkerOptions(ArrayRef<std::string> Options) override;
94 void emitDataRegion(MCDataRegionType Kind) override;
95 void emitVersionMin(MCVersionMinType Kind, unsigned Major, unsigned Minor,
96 unsigned Update, VersionTuple SDKVersion) override;
97 void emitBuildVersion(unsigned Platform, unsigned Major, unsigned Minor,
98 unsigned Update, VersionTuple SDKVersion) override;
99 void emitDarwinTargetVariantBuildVersion(unsigned Platform, unsigned Major,
100 unsigned Minor, unsigned Update,
101 VersionTuple SDKVersion) override;
102 void emitThumbFunc(MCSymbol *Func) override;
103 bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
104 void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
105 void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
106 Align ByteAlignment) override;
107
108 void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
109 Align ByteAlignment) override;
110 void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
111 uint64_t Size = 0, Align ByteAlignment = Align(1),
112 SMLoc Loc = SMLoc()) override;
113 void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
114 Align ByteAlignment = Align(1)) override;
115
116 void emitIdent(StringRef IdentString) override {
117 llvm_unreachable("macho doesn't support this directive");
118 }
119
120 void emitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args) override {
121 getWriter().getLOHContainer().addDirective(Kind, Args);
122 }
123 void emitCGProfileEntry(const MCSymbolRefExpr *From,
124 const MCSymbolRefExpr *To, uint64_t Count) override {
125 if (!From->getSymbol().isTemporary() && !To->getSymbol().isTemporary())
126 getWriter().getCGProfile().push_back({From, To, Count});
127 }
128
129 void finishImpl() override;
130
131 void finalizeCGProfileEntry(const MCSymbolRefExpr *&SRE);
132 void finalizeCGProfile();
133 void createAddrSigSection();
134};
135
136} // end anonymous namespace.
137
138void MCMachOStreamer::changeSection(MCSection *Section, uint32_t Subsection) {
139 // Change the section normally.
140 changeSectionImpl(Section, Subsection);
141
142 // Output a linker-local symbol so we don't need section-relative local
143 // relocations. The linker hates us when we do that.
144 if (LabelSections && !HasSectionLabel[Section] &&
145 !Section->getBeginSymbol()) {
146 MCSymbol *Label = getContext().createLinkerPrivateTempSymbol();
147 Section->setBeginSymbol(Label);
148 HasSectionLabel[Section] = true;
149 }
150}
151
152void MCMachOStreamer::emitEHSymAttributes(const MCSymbol *Symbol,
153 MCSymbol *EHSymbol) {
154 auto *Sym = cast<MCSymbolMachO>(Symbol);
155 getAssembler().registerSymbol(*Symbol);
156 if (Symbol->isExternal())
157 emitSymbolAttribute(EHSymbol, MCSA_Global);
158 if (Sym->isWeakDefinition())
159 emitSymbolAttribute(EHSymbol, MCSA_WeakDefinition);
160 if (Sym->isPrivateExtern())
161 emitSymbolAttribute(EHSymbol, MCSA_PrivateExtern);
162}
163
164void MCMachOStreamer::emitLabel(MCSymbol *Symbol, SMLoc Loc) {
165 // We have to create a new fragment if this is an atom defining symbol,
166 // fragments cannot span atoms.
167 if (cast<MCSymbolMachO>(Symbol)->isSymbolLinkerVisible())
168 insert(getContext().allocFragment<MCDataFragment>());
169
170 MCObjectStreamer::emitLabel(Symbol, Loc);
171
172 // This causes the reference type flag to be cleared. Darwin 'as' was "trying"
173 // to clear the weak reference and weak definition bits too, but the
174 // implementation was buggy. For now we just try to match 'as', for
175 // diffability.
176 //
177 // FIXME: Cleanup this code, these bits should be emitted based on semantic
178 // properties, not on the order of definition, etc.
179 cast<MCSymbolMachO>(Symbol)->clearReferenceType();
180}
181
182void MCMachOStreamer::emitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
183 MCValue Res;
184
185 if (Value->evaluateAsRelocatable(Res, nullptr, nullptr)) {
186 if (const MCSymbolRefExpr *SymAExpr = Res.getSymA()) {
187 const MCSymbol &SymA = SymAExpr->getSymbol();
188 if (!Res.getSymB() && (SymA.getName() == "" || Res.getConstant() != 0))
189 cast<MCSymbolMachO>(Symbol)->setAltEntry();
190 }
191 }
193}
194
195void MCMachOStreamer::emitDataRegion(MachO::DataRegionType Kind) {
196 // Create a temporary label to mark the start of the data region.
197 MCSymbol *Start = getContext().createTempSymbol();
198 emitLabel(Start);
199 // Record the region for the object writer to use.
200 getWriter().getDataRegions().push_back({Kind, Start, nullptr});
201}
202
203void MCMachOStreamer::emitDataRegionEnd() {
204 auto &Regions = getWriter().getDataRegions();
205 assert(!Regions.empty() && "Mismatched .end_data_region!");
206 auto &Data = Regions.back();
207 assert(!Data.End && "Mismatched .end_data_region!");
208 // Create a temporary label to mark the end of the data region.
209 Data.End = getContext().createTempSymbol();
210 emitLabel(Data.End);
211}
212
213void MCMachOStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {
214 // Let the target do whatever target specific stuff it needs to do.
215 getAssembler().getBackend().handleAssemblerFlag(Flag);
216 // Do any generic stuff we need to do.
217 switch (Flag) {
218 case MCAF_SyntaxUnified: return; // no-op here.
219 case MCAF_Code16: return; // Change parsing mode; no-op here.
220 case MCAF_Code32: return; // Change parsing mode; no-op here.
221 case MCAF_Code64: return; // Change parsing mode; no-op here.
223 getWriter().setSubsectionsViaSymbols(true);
224 return;
225 }
226}
227
228void MCMachOStreamer::emitLinkerOptions(ArrayRef<std::string> Options) {
229 getWriter().getLinkerOptions().push_back(Options);
230}
231
232void MCMachOStreamer::emitDataRegion(MCDataRegionType Kind) {
233 switch (Kind) {
234 case MCDR_DataRegion:
235 emitDataRegion(MachO::DataRegionType::DICE_KIND_DATA);
236 return;
238 emitDataRegion(MachO::DataRegionType::DICE_KIND_JUMP_TABLE8);
239 return;
241 emitDataRegion(MachO::DataRegionType::DICE_KIND_JUMP_TABLE16);
242 return;
244 emitDataRegion(MachO::DataRegionType::DICE_KIND_JUMP_TABLE32);
245 return;
247 emitDataRegionEnd();
248 return;
249 }
250}
251
252void MCMachOStreamer::emitVersionMin(MCVersionMinType Kind, unsigned Major,
253 unsigned Minor, unsigned Update,
254 VersionTuple SDKVersion) {
255 getWriter().setVersionMin(Kind, Major, Minor, Update, SDKVersion);
256}
257
258void MCMachOStreamer::emitBuildVersion(unsigned Platform, unsigned Major,
259 unsigned Minor, unsigned Update,
260 VersionTuple SDKVersion) {
261 getWriter().setBuildVersion((MachO::PlatformType)Platform, Major, Minor,
262 Update, SDKVersion);
263}
264
265void MCMachOStreamer::emitDarwinTargetVariantBuildVersion(
266 unsigned Platform, unsigned Major, unsigned Minor, unsigned Update,
267 VersionTuple SDKVersion) {
268 getWriter().setTargetVariantBuildVersion((MachO::PlatformType)Platform, Major,
269 Minor, Update, SDKVersion);
270}
271
272void MCMachOStreamer::emitThumbFunc(MCSymbol *Symbol) {
273 // Remember that the function is a thumb function. Fixup and relocation
274 // values will need adjusted.
275 getAssembler().setIsThumbFunc(Symbol);
276 cast<MCSymbolMachO>(Symbol)->setThumbFunc();
277}
278
279bool MCMachOStreamer::emitSymbolAttribute(MCSymbol *Sym,
281 MCSymbolMachO *Symbol = cast<MCSymbolMachO>(Sym);
282
283 // Indirect symbols are handled differently, to match how 'as' handles
284 // them. This makes writing matching .o files easier.
286 // Note that we intentionally cannot use the symbol data here; this is
287 // important for matching the string table that 'as' generates.
288 getWriter().getIndirectSymbols().push_back(
289 {Symbol, getCurrentSectionOnly()});
290 return true;
291 }
292
293 // Adding a symbol attribute always introduces the symbol, note that an
294 // important side effect of calling registerSymbol here is to register
295 // the symbol with the assembler.
296 getAssembler().registerSymbol(*Symbol);
297
298 // The implementation of symbol attributes is designed to match 'as', but it
299 // leaves much to desired. It doesn't really make sense to arbitrarily add and
300 // remove flags, but 'as' allows this (in particular, see .desc).
301 //
302 // In the future it might be worth trying to make these operations more well
303 // defined.
304 switch (Attribute) {
305 case MCSA_Invalid:
309 case MCSA_ELF_TypeTLS:
313 case MCSA_Extern:
314 case MCSA_Hidden:
316 case MCSA_Internal:
317 case MCSA_Protected:
318 case MCSA_Weak:
319 case MCSA_Local:
320 case MCSA_LGlobal:
321 case MCSA_Exported:
322 case MCSA_Memtag:
323 case MCSA_WeakAntiDep:
324 return false;
325
326 case MCSA_Global:
327 Symbol->setExternal(true);
328 // This effectively clears the undefined lazy bit, in Darwin 'as', although
329 // it isn't very consistent because it implements this as part of symbol
330 // lookup.
331 //
332 // FIXME: Cleanup this code, these bits should be emitted based on semantic
333 // properties, not on the order of definition, etc.
334 Symbol->setReferenceTypeUndefinedLazy(false);
335 break;
336
338 // FIXME: This requires -dynamic.
339 Symbol->setNoDeadStrip();
340 if (Symbol->isUndefined())
341 Symbol->setReferenceTypeUndefinedLazy(true);
342 break;
343
344 // Since .reference sets the no dead strip bit, it is equivalent to
345 // .no_dead_strip in practice.
346 case MCSA_Reference:
347 case MCSA_NoDeadStrip:
348 Symbol->setNoDeadStrip();
349 break;
350
352 Symbol->setSymbolResolver();
353 break;
354
355 case MCSA_AltEntry:
356 Symbol->setAltEntry();
357 break;
358
360 Symbol->setExternal(true);
361 Symbol->setPrivateExtern(true);
362 break;
363
365 // FIXME: This requires -dynamic.
366 if (Symbol->isUndefined())
367 Symbol->setWeakReference();
368 break;
369
371 // FIXME: 'as' enforces that this is defined and global. The manual claims
372 // it has to be in a coalesced section, but this isn't enforced.
373 Symbol->setWeakDefinition();
374 break;
375
377 Symbol->setWeakDefinition();
378 Symbol->setWeakReference();
379 break;
380
381 case MCSA_Cold:
382 Symbol->setCold();
383 break;
384 }
385
386 return true;
387}
388
389void MCMachOStreamer::emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
390 // Encode the 'desc' value into the lowest implementation defined bits.
391 getAssembler().registerSymbol(*Symbol);
392 cast<MCSymbolMachO>(Symbol)->setDesc(DescValue);
393}
394
395void MCMachOStreamer::emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
396 Align ByteAlignment) {
397 // FIXME: Darwin 'as' does appear to allow redef of a .comm by itself.
398 assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
399
400 getAssembler().registerSymbol(*Symbol);
401 Symbol->setExternal(true);
402 Symbol->setCommon(Size, ByteAlignment);
403}
404
405void MCMachOStreamer::emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
406 Align ByteAlignment) {
407 // '.lcomm' is equivalent to '.zerofill'.
408 return emitZerofill(getContext().getObjectFileInfo()->getDataBSSSection(),
409 Symbol, Size, ByteAlignment);
410}
411
412void MCMachOStreamer::emitZerofill(MCSection *Section, MCSymbol *Symbol,
413 uint64_t Size, Align ByteAlignment,
414 SMLoc Loc) {
415 // On darwin all virtual sections have zerofill type. Disallow the usage of
416 // .zerofill in non-virtual functions. If something similar is needed, use
417 // .space or .zero.
418 if (!Section->isVirtualSection()) {
419 getContext().reportError(
420 Loc, "The usage of .zerofill is restricted to sections of "
421 "ZEROFILL type. Use .zero or .space instead.");
422 return; // Early returning here shouldn't harm. EmitZeros should work on any
423 // section.
424 }
425
426 pushSection();
427 switchSection(Section);
428
429 // The symbol may not be present, which only creates the section.
430 if (Symbol) {
431 emitValueToAlignment(ByteAlignment, 0, 1, 0);
432 emitLabel(Symbol);
433 emitZeros(Size);
434 }
435 popSection();
436}
437
438// This should always be called with the thread local bss section. Like the
439// .zerofill directive this doesn't actually switch sections on us.
440void MCMachOStreamer::emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
441 uint64_t Size, Align ByteAlignment) {
442 emitZerofill(Section, Symbol, Size, ByteAlignment);
443}
444
445void MCMachOStreamer::emitInstToData(const MCInst &Inst,
446 const MCSubtargetInfo &STI) {
447 MCDataFragment *DF = getOrCreateDataFragment();
448
451 getAssembler().getEmitter().encodeInstruction(Inst, Code, Fixups, STI);
452
453 // Add the fixups and data.
454 for (MCFixup &Fixup : Fixups) {
455 Fixup.setOffset(Fixup.getOffset() + DF->getContents().size());
456 DF->getFixups().push_back(Fixup);
457 }
458 DF->setHasInstructions(STI);
459 DF->getContents().append(Code.begin(), Code.end());
460}
461
462void MCMachOStreamer::finishImpl() {
463 emitFrames(&getAssembler().getBackend());
464
465 // We have to set the fragment atom associations so we can relax properly for
466 // Mach-O.
467
468 // First, scan the symbol table to build a lookup table from fragments to
469 // defining symbols.
471 for (const MCSymbol &Symbol : getAssembler().symbols()) {
472 auto &Sym = cast<MCSymbolMachO>(Symbol);
473 if (Sym.isSymbolLinkerVisible() && Sym.isInSection() && !Sym.isVariable() &&
474 !Sym.isAltEntry()) {
475 // An atom defining symbol should never be internal to a fragment.
476 assert(Symbol.getOffset() == 0 &&
477 "Invalid offset in atom defining symbol!");
478 DefiningSymbolMap[Symbol.getFragment()] = &Symbol;
479 }
480 }
481
482 // Set the fragment atom associations by tracking the last seen atom defining
483 // symbol.
484 for (MCSection &Sec : getAssembler()) {
485 cast<MCSectionMachO>(Sec).allocAtoms();
486 const MCSymbol *CurrentAtom = nullptr;
487 size_t I = 0;
488 for (MCFragment &Frag : Sec) {
489 if (const MCSymbol *Symbol = DefiningSymbolMap.lookup(&Frag))
490 CurrentAtom = Symbol;
491 cast<MCSectionMachO>(Sec).setAtom(I++, CurrentAtom);
492 }
493 }
494
495 finalizeCGProfile();
496
497 createAddrSigSection();
499}
500
501void MCMachOStreamer::finalizeCGProfileEntry(const MCSymbolRefExpr *&SRE) {
502 const MCSymbol *S = &SRE->getSymbol();
503 if (getAssembler().registerSymbol(*S))
504 S->setExternal(true);
505}
506
507void MCMachOStreamer::finalizeCGProfile() {
508 MCAssembler &Asm = getAssembler();
509 MCObjectWriter &W = getWriter();
510 if (W.getCGProfile().empty())
511 return;
512 for (auto &E : W.getCGProfile()) {
513 finalizeCGProfileEntry(E.From);
514 finalizeCGProfileEntry(E.To);
515 }
516 // We can't write the section out until symbol indices are finalized which
517 // doesn't happen until after section layout. We need to create the section
518 // and set its size now so that it's accounted for in layout.
519 MCSection *CGProfileSection = Asm.getContext().getMachOSection(
520 "__LLVM", "__cg_profile", 0, SectionKind::getMetadata());
521 changeSection(CGProfileSection);
522 // For each entry, reserve space for 2 32-bit indices and a 64-bit count.
523 size_t SectionBytes =
524 W.getCGProfile().size() * (2 * sizeof(uint32_t) + sizeof(uint64_t));
525 cast<MCDataFragment>(*CGProfileSection->begin())
526 .getContents()
527 .resize(SectionBytes);
528}
529
531 std::unique_ptr<MCAsmBackend> &&MAB,
532 std::unique_ptr<MCObjectWriter> &&OW,
533 std::unique_ptr<MCCodeEmitter> &&CE,
534 bool DWARFMustBeAtTheEnd,
535 bool LabelSections) {
536 return new MCMachOStreamer(Context, std::move(MAB), std::move(OW),
537 std::move(CE), LabelSections);
538}
539
540// The AddrSig section uses a series of relocations to refer to the symbols that
541// should be considered address-significant. The only interesting content of
542// these relocations is their symbol; the type, length etc will be ignored by
543// the linker. The reason we are not referring to the symbol indices directly is
544// that those indices will be invalidated by tools that update the symbol table.
545// Symbol relocations OTOH will have their indices updated by e.g. llvm-strip.
546void MCMachOStreamer::createAddrSigSection() {
547 MCAssembler &Asm = getAssembler();
548 MCObjectWriter &writer = Asm.getWriter();
549 if (!writer.getEmitAddrsigSection())
550 return;
551 // Create the AddrSig section and first data fragment here as its layout needs
552 // to be computed immediately after in order for it to be exported correctly.
553 MCSection *AddrSigSection =
554 Asm.getContext().getObjectFileInfo()->getAddrSigSection();
555 changeSection(AddrSigSection);
556 auto *Frag = cast<MCDataFragment>(AddrSigSection->curFragList()->Head);
557 // We will generate a series of pointer-sized symbol relocations at offset
558 // 0x0. Set the section size to be large enough to contain a single pointer
559 // (instead of emitting a zero-sized section) so these relocations are
560 // technically valid, even though we don't expect these relocations to
561 // actually be applied by the linker.
562 Frag->getContents().resize(8);
563}
BlockVerifier::State From
dxil DXContainer Global Emitter
static RegisterPass< DebugifyFunctionPass > DF("debugify-function", "Attach debug info to a function")
This file defines the DenseMap class.
uint64_t Size
Symbol * Sym
Definition: ELF_riscv.cpp:479
static LVOptions Options
Definition: LVOptions.cpp:25
#define I(x, y, z)
Definition: MD5.cpp:58
static bool isSymbolLinkerVisible(const MCSymbol &Symbol)
PowerPC TLS Dynamic Call Fixup
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallString class.
This file defines the SmallVector class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Definition: DenseMap.h:194
Context object for machine code objects.
Definition: MCContext.h:83
Fragment for data and encoded instructions.
Definition: MCFragment.h:219
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:34
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:71
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:185
Streaming object file generation interface.
void reset() override
state management
void emitAssignment(MCSymbol *Symbol, const MCExpr *Value) override
Emit an assignment of Value to Symbol.
void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override
Emit a label for Symbol into the current section.
void finishImpl() override
Streamer specific finalization.
Defines the object file and target independent interfaces used by the assembler backend to write nati...
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:36
FragList * curFragList() const
Definition: MCSection.h:181
iterator begin() const
Definition: MCSection.h:182
Streaming machine code generation interface.
Definition: MCStreamer.h:213
Generic base class for all target subtargets.
Represent a reference to a symbol from inside an expression.
Definition: MCExpr.h:192
const MCSymbol & getSymbol() const
Definition: MCExpr.h:411
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
void setExternal(bool Value) const
Definition: MCSymbol.h:408
StringRef getName() const
getName - Get the symbol name.
Definition: MCSymbol.h:205
bool isTemporary() const
isTemporary - Check if this is an assembler temporary symbol.
Definition: MCSymbol.h:222
This represents an "assembler immediate".
Definition: MCValue.h:36
int64_t getConstant() const
Definition: MCValue.h:43
const MCSymbolRefExpr * getSymB() const
Definition: MCValue.h:45
const MCSymbolRefExpr * getSymA() const
Definition: MCValue.h:44
Represents a location in source code.
Definition: SMLoc.h:23
static SectionKind getMetadata()
Definition: SectionKind.h:188
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
Definition: SmallString.h:26
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:573
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
LLVM Value Representation.
Definition: Value.h:74
Represents a version number in the form major[.minor[.subminor[.build]]].
Definition: VersionTuple.h:29
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
PlatformType
Definition: MachO.h:500
DataRegionType
Definition: MachO.h:225
NodeAddr< CodeNode * > Code
Definition: RDFGraph.h:388
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
MCDataRegionType
Definition: MCDirectives.h:61
@ MCDR_DataRegionEnd
.end_data_region
Definition: MCDirectives.h:66
@ MCDR_DataRegion
.data_region
Definition: MCDirectives.h:62
@ MCDR_DataRegionJT8
.data_region jt8
Definition: MCDirectives.h:63
@ MCDR_DataRegionJT32
.data_region jt32
Definition: MCDirectives.h:65
@ MCDR_DataRegionJT16
.data_region jt16
Definition: MCDirectives.h:64
MCStreamer * createMachOStreamer(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&CE, bool DWARFMustBeAtTheEnd, bool LabelSections=false)
MCVersionMinType
Definition: MCDirectives.h:69
MCAssemblerFlag
Definition: MCDirectives.h:53
@ MCAF_SyntaxUnified
.syntax (ARM/ELF)
Definition: MCDirectives.h:54
@ MCAF_Code64
.code64 (X86)
Definition: MCDirectives.h:58
@ MCAF_Code16
.code16 (X86) / .code 16 (ARM)
Definition: MCDirectives.h:56
@ MCAF_Code32
.code32 (X86) / .code 32 (ARM)
Definition: MCDirectives.h:57
@ MCAF_SubsectionsViaSymbols
.subsections_via_symbols (MachO)
Definition: MCDirectives.h:55
MCLOHType
Linker Optimization Hint Type.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1873
MCSymbolAttr
Definition: MCDirectives.h:18
@ MCSA_Local
.local (ELF)
Definition: MCDirectives.h:38
@ MCSA_WeakDefAutoPrivate
.weak_def_can_be_hidden (MachO)
Definition: MCDirectives.h:48
@ MCSA_Memtag
.memtag (ELF)
Definition: MCDirectives.h:50
@ MCSA_Protected
.protected (ELF)
Definition: MCDirectives.h:43
@ MCSA_Exported
.globl _foo, exported (XCOFF)
Definition: MCDirectives.h:34
@ MCSA_PrivateExtern
.private_extern (MachO)
Definition: MCDirectives.h:42
@ MCSA_Internal
.internal (ELF)
Definition: MCDirectives.h:36
@ MCSA_WeakReference
.weak_reference (MachO)
Definition: MCDirectives.h:47
@ MCSA_AltEntry
.alt_entry (MachO)
Definition: MCDirectives.h:41
@ MCSA_ELF_TypeIndFunction
.type _foo, STT_GNU_IFUNC
Definition: MCDirectives.h:24
@ MCSA_LazyReference
.lazy_reference (MachO)
Definition: MCDirectives.h:37
@ MCSA_ELF_TypeNoType
.type _foo, STT_NOTYPE # aka @notype
Definition: MCDirectives.h:28
@ MCSA_Reference
.reference (MachO)
Definition: MCDirectives.h:44
@ MCSA_SymbolResolver
.symbol_resolver (MachO)
Definition: MCDirectives.h:40
@ MCSA_Weak
.weak
Definition: MCDirectives.h:45
@ MCSA_ELF_TypeTLS
.type _foo, STT_TLS # aka @tls_object
Definition: MCDirectives.h:26
@ MCSA_IndirectSymbol
.indirect_symbol (MachO)
Definition: MCDirectives.h:35
@ MCSA_WeakDefinition
.weak_definition (MachO)
Definition: MCDirectives.h:46
@ MCSA_ELF_TypeCommon
.type _foo, STT_COMMON # aka @common
Definition: MCDirectives.h:27
@ MCSA_Global
.type _foo, @gnu_unique_object
Definition: MCDirectives.h:30
@ MCSA_WeakAntiDep
.weak_anti_dep (COFF)
Definition: MCDirectives.h:49
@ MCSA_Extern
.extern (XCOFF)
Definition: MCDirectives.h:32
@ MCSA_Cold
.cold (MachO)
Definition: MCDirectives.h:22
@ MCSA_ELF_TypeObject
.type _foo, STT_OBJECT # aka @object
Definition: MCDirectives.h:25
@ MCSA_ELF_TypeGnuUniqueObject
Definition: MCDirectives.h:29
@ MCSA_ELF_TypeFunction
.type _foo, STT_FUNC # aka @function
Definition: MCDirectives.h:23
@ MCSA_Hidden
.hidden (ELF)
Definition: MCDirectives.h:33
@ MCSA_LGlobal
.lglobl (XCOFF)
Definition: MCDirectives.h:31
@ MCSA_Invalid
Not a valid directive.
Definition: MCDirectives.h:19
@ MCSA_NoDeadStrip
.no_dead_strip (MachO)
Definition: MCDirectives.h:39
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39