LLVM 19.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 bool DWARFMustBeAtTheEnd;
58 bool CreatedADWARFSection;
59
60 /// HasSectionLabel - map of which sections have already had a non-local
61 /// label emitted to them. Used so we don't emit extraneous linker local
62 /// labels in the middle of the section.
64
65 void emitInstToData(const MCInst &Inst, const MCSubtargetInfo &STI) override;
66
67 void emitDataRegion(MachO::DataRegionType Kind);
68 void emitDataRegionEnd();
69
70public:
71 MCMachOStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> MAB,
72 std::unique_ptr<MCObjectWriter> OW,
73 std::unique_ptr<MCCodeEmitter> Emitter,
74 bool DWARFMustBeAtTheEnd, bool label)
75 : MCObjectStreamer(Context, std::move(MAB), std::move(OW),
76 std::move(Emitter)),
77 LabelSections(label), DWARFMustBeAtTheEnd(DWARFMustBeAtTheEnd),
78 CreatedADWARFSection(false) {}
79
80 /// state management
81 void reset() override {
82 CreatedADWARFSection = false;
83 HasSectionLabel.clear();
85 }
86
87 MachObjectWriter &getWriter() {
88 return static_cast<MachObjectWriter &>(getAssembler().getWriter());
89 }
90
91 /// @name MCStreamer Interface
92 /// @{
93
94 void changeSection(MCSection *Sect, uint32_t Subsection = 0) override;
95 void emitLabel(MCSymbol *Symbol, SMLoc Loc = SMLoc()) override;
96 void emitAssignment(MCSymbol *Symbol, const MCExpr *Value) override;
97 void emitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol) override;
98 void emitAssemblerFlag(MCAssemblerFlag Flag) override;
99 void emitLinkerOptions(ArrayRef<std::string> Options) override;
100 void emitDataRegion(MCDataRegionType Kind) override;
101 void emitVersionMin(MCVersionMinType Kind, unsigned Major, unsigned Minor,
102 unsigned Update, VersionTuple SDKVersion) override;
103 void emitBuildVersion(unsigned Platform, unsigned Major, unsigned Minor,
104 unsigned Update, VersionTuple SDKVersion) override;
105 void emitDarwinTargetVariantBuildVersion(unsigned Platform, unsigned Major,
106 unsigned Minor, unsigned Update,
107 VersionTuple SDKVersion) override;
108 void emitThumbFunc(MCSymbol *Func) override;
109 bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
110 void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
111 void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
112 Align ByteAlignment) override;
113
114 void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
115 Align ByteAlignment) override;
116 void emitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
117 uint64_t Size = 0, Align ByteAlignment = Align(1),
118 SMLoc Loc = SMLoc()) override;
119 void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
120 Align ByteAlignment = Align(1)) override;
121
122 void emitIdent(StringRef IdentString) override {
123 llvm_unreachable("macho doesn't support this directive");
124 }
125
126 void emitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args) override {
127 getAssembler().getLOHContainer().addDirective(Kind, Args);
128 }
129 void emitCGProfileEntry(const MCSymbolRefExpr *From,
130 const MCSymbolRefExpr *To, uint64_t Count) override {
131 if (!From->getSymbol().isTemporary() && !To->getSymbol().isTemporary())
132 getAssembler().CGProfile.push_back({From, To, Count});
133 }
134
135 void finishImpl() override;
136
137 void finalizeCGProfileEntry(const MCSymbolRefExpr *&SRE);
138 void finalizeCGProfile();
139 void createAddrSigSection();
140};
141
142} // end anonymous namespace.
143
144static bool canGoAfterDWARF(const MCSectionMachO &MSec) {
145 // These sections are created by the assembler itself after the end of
146 // the .s file.
147 StringRef SegName = MSec.getSegmentName();
148 StringRef SecName = MSec.getName();
149
150 if (SegName == "__LD" && SecName == "__compact_unwind")
151 return true;
152
153 if (SegName == "__IMPORT") {
154 if (SecName == "__jump_table")
155 return true;
156
157 if (SecName == "__pointers")
158 return true;
159 }
160
161 if (SegName == "__TEXT" && SecName == "__eh_frame")
162 return true;
163
164 if (SegName == "__DATA" &&
165 (SecName == "__llvm_addrsig" || SecName == "__nl_symbol_ptr" ||
166 SecName == "__thread_ptr"))
167 return true;
168 if (SegName == "__LLVM" && (SecName == "__cg_profile"))
169 return true;
170
171 if (SegName == "__DATA" && SecName == "__auth_ptr")
172 return true;
173
174 return false;
175}
176
177void MCMachOStreamer::changeSection(MCSection *Section, uint32_t Subsection) {
178 // Change the section normally.
179 bool Created = changeSectionImpl(Section, Subsection);
180 const MCSectionMachO &MSec = *cast<MCSectionMachO>(Section);
181 StringRef SegName = MSec.getSegmentName();
182 if (SegName == "__DWARF")
183 CreatedADWARFSection = true;
184 else if (Created && DWARFMustBeAtTheEnd && !canGoAfterDWARF(MSec))
185 assert(!CreatedADWARFSection && "Creating regular section after DWARF");
186
187 // Output a linker-local symbol so we don't need section-relative local
188 // relocations. The linker hates us when we do that.
189 if (LabelSections && !HasSectionLabel[Section] &&
190 !Section->getBeginSymbol()) {
191 MCSymbol *Label = getContext().createLinkerPrivateTempSymbol();
192 Section->setBeginSymbol(Label);
193 HasSectionLabel[Section] = true;
194 }
195}
196
197void MCMachOStreamer::emitEHSymAttributes(const MCSymbol *Symbol,
198 MCSymbol *EHSymbol) {
199 getAssembler().registerSymbol(*Symbol);
200 if (Symbol->isExternal())
201 emitSymbolAttribute(EHSymbol, MCSA_Global);
202 if (cast<MCSymbolMachO>(Symbol)->isWeakDefinition())
203 emitSymbolAttribute(EHSymbol, MCSA_WeakDefinition);
204 if (Symbol->isPrivateExtern())
205 emitSymbolAttribute(EHSymbol, MCSA_PrivateExtern);
206}
207
208void MCMachOStreamer::emitLabel(MCSymbol *Symbol, SMLoc Loc) {
209 // We have to create a new fragment if this is an atom defining symbol,
210 // fragments cannot span atoms.
211 if (cast<MCSymbolMachO>(Symbol)->isSymbolLinkerVisible())
212 insert(getContext().allocFragment<MCDataFragment>());
213
214 MCObjectStreamer::emitLabel(Symbol, Loc);
215
216 // This causes the reference type flag to be cleared. Darwin 'as' was "trying"
217 // to clear the weak reference and weak definition bits too, but the
218 // implementation was buggy. For now we just try to match 'as', for
219 // diffability.
220 //
221 // FIXME: Cleanup this code, these bits should be emitted based on semantic
222 // properties, not on the order of definition, etc.
223 cast<MCSymbolMachO>(Symbol)->clearReferenceType();
224}
225
226void MCMachOStreamer::emitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
227 MCValue Res;
228
229 if (Value->evaluateAsRelocatable(Res, nullptr, nullptr)) {
230 if (const MCSymbolRefExpr *SymAExpr = Res.getSymA()) {
231 const MCSymbol &SymA = SymAExpr->getSymbol();
232 if (!Res.getSymB() && (SymA.getName() == "" || Res.getConstant() != 0))
233 cast<MCSymbolMachO>(Symbol)->setAltEntry();
234 }
235 }
237}
238
239void MCMachOStreamer::emitDataRegion(MachO::DataRegionType Kind) {
240 // Create a temporary label to mark the start of the data region.
241 MCSymbol *Start = getContext().createTempSymbol();
242 emitLabel(Start);
243 // Record the region for the object writer to use.
244 getWriter().getDataRegions().push_back({Kind, Start, nullptr});
245}
246
247void MCMachOStreamer::emitDataRegionEnd() {
248 auto &Regions = getWriter().getDataRegions();
249 assert(!Regions.empty() && "Mismatched .end_data_region!");
250 auto &Data = Regions.back();
251 assert(!Data.End && "Mismatched .end_data_region!");
252 // Create a temporary label to mark the end of the data region.
253 Data.End = getContext().createTempSymbol();
254 emitLabel(Data.End);
255}
256
257void MCMachOStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {
258 // Let the target do whatever target specific stuff it needs to do.
259 getAssembler().getBackend().handleAssemblerFlag(Flag);
260 // Do any generic stuff we need to do.
261 switch (Flag) {
262 case MCAF_SyntaxUnified: return; // no-op here.
263 case MCAF_Code16: return; // Change parsing mode; no-op here.
264 case MCAF_Code32: return; // Change parsing mode; no-op here.
265 case MCAF_Code64: return; // Change parsing mode; no-op here.
267 getAssembler().setSubsectionsViaSymbols(true);
268 return;
269 }
270}
271
272void MCMachOStreamer::emitLinkerOptions(ArrayRef<std::string> Options) {
273 getAssembler().getLinkerOptions().push_back(Options);
274}
275
276void MCMachOStreamer::emitDataRegion(MCDataRegionType Kind) {
277 switch (Kind) {
278 case MCDR_DataRegion:
279 emitDataRegion(MachO::DataRegionType::DICE_KIND_DATA);
280 return;
282 emitDataRegion(MachO::DataRegionType::DICE_KIND_JUMP_TABLE8);
283 return;
285 emitDataRegion(MachO::DataRegionType::DICE_KIND_JUMP_TABLE16);
286 return;
288 emitDataRegion(MachO::DataRegionType::DICE_KIND_JUMP_TABLE32);
289 return;
291 emitDataRegionEnd();
292 return;
293 }
294}
295
296void MCMachOStreamer::emitVersionMin(MCVersionMinType Kind, unsigned Major,
297 unsigned Minor, unsigned Update,
298 VersionTuple SDKVersion) {
299 getAssembler().setVersionMin(Kind, Major, Minor, Update, SDKVersion);
300}
301
302void MCMachOStreamer::emitBuildVersion(unsigned Platform, unsigned Major,
303 unsigned Minor, unsigned Update,
304 VersionTuple SDKVersion) {
305 getAssembler().setBuildVersion((MachO::PlatformType)Platform, Major, Minor,
306 Update, SDKVersion);
307}
308
309void MCMachOStreamer::emitDarwinTargetVariantBuildVersion(
310 unsigned Platform, unsigned Major, unsigned Minor, unsigned Update,
311 VersionTuple SDKVersion) {
312 getAssembler().setDarwinTargetVariantBuildVersion(
313 (MachO::PlatformType)Platform, Major, Minor, Update, SDKVersion);
314}
315
316void MCMachOStreamer::emitThumbFunc(MCSymbol *Symbol) {
317 // Remember that the function is a thumb function. Fixup and relocation
318 // values will need adjusted.
319 getAssembler().setIsThumbFunc(Symbol);
320 cast<MCSymbolMachO>(Symbol)->setThumbFunc();
321}
322
323bool MCMachOStreamer::emitSymbolAttribute(MCSymbol *Sym,
325 MCSymbolMachO *Symbol = cast<MCSymbolMachO>(Sym);
326
327 // Indirect symbols are handled differently, to match how 'as' handles
328 // them. This makes writing matching .o files easier.
330 // Note that we intentionally cannot use the symbol data here; this is
331 // important for matching the string table that 'as' generates.
332 getWriter().getIndirectSymbols().push_back(
333 {Symbol, getCurrentSectionOnly()});
334 return true;
335 }
336
337 // Adding a symbol attribute always introduces the symbol, note that an
338 // important side effect of calling registerSymbol here is to register
339 // the symbol with the assembler.
340 getAssembler().registerSymbol(*Symbol);
341
342 // The implementation of symbol attributes is designed to match 'as', but it
343 // leaves much to desired. It doesn't really make sense to arbitrarily add and
344 // remove flags, but 'as' allows this (in particular, see .desc).
345 //
346 // In the future it might be worth trying to make these operations more well
347 // defined.
348 switch (Attribute) {
349 case MCSA_Invalid:
353 case MCSA_ELF_TypeTLS:
357 case MCSA_Extern:
358 case MCSA_Hidden:
360 case MCSA_Internal:
361 case MCSA_Protected:
362 case MCSA_Weak:
363 case MCSA_Local:
364 case MCSA_LGlobal:
365 case MCSA_Exported:
366 case MCSA_Memtag:
367 case MCSA_WeakAntiDep:
368 return false;
369
370 case MCSA_Global:
371 Symbol->setExternal(true);
372 // This effectively clears the undefined lazy bit, in Darwin 'as', although
373 // it isn't very consistent because it implements this as part of symbol
374 // lookup.
375 //
376 // FIXME: Cleanup this code, these bits should be emitted based on semantic
377 // properties, not on the order of definition, etc.
378 Symbol->setReferenceTypeUndefinedLazy(false);
379 break;
380
382 // FIXME: This requires -dynamic.
383 Symbol->setNoDeadStrip();
384 if (Symbol->isUndefined())
385 Symbol->setReferenceTypeUndefinedLazy(true);
386 break;
387
388 // Since .reference sets the no dead strip bit, it is equivalent to
389 // .no_dead_strip in practice.
390 case MCSA_Reference:
391 case MCSA_NoDeadStrip:
392 Symbol->setNoDeadStrip();
393 break;
394
396 Symbol->setSymbolResolver();
397 break;
398
399 case MCSA_AltEntry:
400 Symbol->setAltEntry();
401 break;
402
404 Symbol->setExternal(true);
405 Symbol->setPrivateExtern(true);
406 break;
407
409 // FIXME: This requires -dynamic.
410 if (Symbol->isUndefined())
411 Symbol->setWeakReference();
412 break;
413
415 // FIXME: 'as' enforces that this is defined and global. The manual claims
416 // it has to be in a coalesced section, but this isn't enforced.
417 Symbol->setWeakDefinition();
418 break;
419
421 Symbol->setWeakDefinition();
422 Symbol->setWeakReference();
423 break;
424
425 case MCSA_Cold:
426 Symbol->setCold();
427 break;
428 }
429
430 return true;
431}
432
433void MCMachOStreamer::emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
434 // Encode the 'desc' value into the lowest implementation defined bits.
435 getAssembler().registerSymbol(*Symbol);
436 cast<MCSymbolMachO>(Symbol)->setDesc(DescValue);
437}
438
439void MCMachOStreamer::emitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
440 Align ByteAlignment) {
441 // FIXME: Darwin 'as' does appear to allow redef of a .comm by itself.
442 assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
443
444 getAssembler().registerSymbol(*Symbol);
445 Symbol->setExternal(true);
446 Symbol->setCommon(Size, ByteAlignment);
447}
448
449void MCMachOStreamer::emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
450 Align ByteAlignment) {
451 // '.lcomm' is equivalent to '.zerofill'.
452 return emitZerofill(getContext().getObjectFileInfo()->getDataBSSSection(),
453 Symbol, Size, ByteAlignment);
454}
455
456void MCMachOStreamer::emitZerofill(MCSection *Section, MCSymbol *Symbol,
457 uint64_t Size, Align ByteAlignment,
458 SMLoc Loc) {
459 // On darwin all virtual sections have zerofill type. Disallow the usage of
460 // .zerofill in non-virtual functions. If something similar is needed, use
461 // .space or .zero.
462 if (!Section->isVirtualSection()) {
463 getContext().reportError(
464 Loc, "The usage of .zerofill is restricted to sections of "
465 "ZEROFILL type. Use .zero or .space instead.");
466 return; // Early returning here shouldn't harm. EmitZeros should work on any
467 // section.
468 }
469
470 pushSection();
471 switchSection(Section);
472
473 // The symbol may not be present, which only creates the section.
474 if (Symbol) {
475 emitValueToAlignment(ByteAlignment, 0, 1, 0);
476 emitLabel(Symbol);
477 emitZeros(Size);
478 }
479 popSection();
480}
481
482// This should always be called with the thread local bss section. Like the
483// .zerofill directive this doesn't actually switch sections on us.
484void MCMachOStreamer::emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
485 uint64_t Size, Align ByteAlignment) {
486 emitZerofill(Section, Symbol, Size, ByteAlignment);
487}
488
489void MCMachOStreamer::emitInstToData(const MCInst &Inst,
490 const MCSubtargetInfo &STI) {
491 MCDataFragment *DF = getOrCreateDataFragment();
492
495 getAssembler().getEmitter().encodeInstruction(Inst, Code, Fixups, STI);
496
497 // Add the fixups and data.
498 for (MCFixup &Fixup : Fixups) {
499 Fixup.setOffset(Fixup.getOffset() + DF->getContents().size());
500 DF->getFixups().push_back(Fixup);
501 }
502 DF->setHasInstructions(STI);
503 DF->getContents().append(Code.begin(), Code.end());
504}
505
506void MCMachOStreamer::finishImpl() {
507 emitFrames(&getAssembler().getBackend());
508
509 // We have to set the fragment atom associations so we can relax properly for
510 // Mach-O.
511
512 // First, scan the symbol table to build a lookup table from fragments to
513 // defining symbols.
515 for (const MCSymbol &Symbol : getAssembler().symbols()) {
516 auto &Sym = cast<MCSymbolMachO>(Symbol);
517 if (Sym.isSymbolLinkerVisible() && Sym.isInSection() && !Sym.isVariable() &&
518 !Sym.isAltEntry()) {
519 // An atom defining symbol should never be internal to a fragment.
520 assert(Symbol.getOffset() == 0 &&
521 "Invalid offset in atom defining symbol!");
522 DefiningSymbolMap[Symbol.getFragment()] = &Symbol;
523 }
524 }
525
526 // Set the fragment atom associations by tracking the last seen atom defining
527 // symbol.
528 for (MCSection &Sec : getAssembler()) {
529 cast<MCSectionMachO>(Sec).allocAtoms();
530 const MCSymbol *CurrentAtom = nullptr;
531 size_t I = 0;
532 for (MCFragment &Frag : Sec) {
533 if (const MCSymbol *Symbol = DefiningSymbolMap.lookup(&Frag))
534 CurrentAtom = Symbol;
535 cast<MCSectionMachO>(Sec).setAtom(I++, CurrentAtom);
536 }
537 }
538
539 finalizeCGProfile();
540
541 createAddrSigSection();
543}
544
545void MCMachOStreamer::finalizeCGProfileEntry(const MCSymbolRefExpr *&SRE) {
546 const MCSymbol *S = &SRE->getSymbol();
547 if (getAssembler().registerSymbol(*S))
548 S->setExternal(true);
549}
550
551void MCMachOStreamer::finalizeCGProfile() {
552 MCAssembler &Asm = getAssembler();
553 if (Asm.CGProfile.empty())
554 return;
555 for (MCAssembler::CGProfileEntry &E : Asm.CGProfile) {
556 finalizeCGProfileEntry(E.From);
557 finalizeCGProfileEntry(E.To);
558 }
559 // We can't write the section out until symbol indices are finalized which
560 // doesn't happen until after section layout. We need to create the section
561 // and set its size now so that it's accounted for in layout.
562 MCSection *CGProfileSection = Asm.getContext().getMachOSection(
563 "__LLVM", "__cg_profile", 0, SectionKind::getMetadata());
564 changeSection(CGProfileSection);
565 // For each entry, reserve space for 2 32-bit indices and a 64-bit count.
566 size_t SectionBytes =
567 Asm.CGProfile.size() * (2 * sizeof(uint32_t) + sizeof(uint64_t));
568 cast<MCDataFragment>(*CGProfileSection->begin())
569 .getContents()
570 .resize(SectionBytes);
571}
572
574 std::unique_ptr<MCAsmBackend> &&MAB,
575 std::unique_ptr<MCObjectWriter> &&OW,
576 std::unique_ptr<MCCodeEmitter> &&CE,
577 bool DWARFMustBeAtTheEnd,
578 bool LabelSections) {
579 MCMachOStreamer *S =
580 new MCMachOStreamer(Context, std::move(MAB), std::move(OW), std::move(CE),
581 DWARFMustBeAtTheEnd, LabelSections);
582 const Triple &Target = Context.getTargetTriple();
583 S->emitVersionForTarget(
587 return S;
588}
589
590// The AddrSig section uses a series of relocations to refer to the symbols that
591// should be considered address-significant. The only interesting content of
592// these relocations is their symbol; the type, length etc will be ignored by
593// the linker. The reason we are not referring to the symbol indices directly is
594// that those indices will be invalidated by tools that update the symbol table.
595// Symbol relocations OTOH will have their indices updated by e.g. llvm-strip.
596void MCMachOStreamer::createAddrSigSection() {
597 MCAssembler &Asm = getAssembler();
598 MCObjectWriter &writer = Asm.getWriter();
599 if (!writer.getEmitAddrsigSection())
600 return;
601 // Create the AddrSig section and first data fragment here as its layout needs
602 // to be computed immediately after in order for it to be exported correctly.
603 MCSection *AddrSigSection =
604 Asm.getContext().getObjectFileInfo()->getAddrSigSection();
605 changeSection(AddrSigSection);
606 auto *Frag = cast<MCDataFragment>(AddrSigSection->curFragList()->Head);
607 // We will generate a series of pointer-sized symbol relocations at offset
608 // 0x0. Set the section size to be large enough to contain a single pointer
609 // (instead of emitting a zero-sized section) so these relocations are
610 // technically valid, even though we don't expect these relocations to
611 // actually be applied by the linker.
612 Frag->getContents().resize(8);
613}
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
static bool canGoAfterDWARF(const MCSectionMachO &MSec)
#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:202
Context object for machine code objects.
Definition: MCContext.h:83
const MCObjectFileInfo * getObjectFileInfo() const
Definition: MCContext.h:416
const Triple & getTargetTriple() const
Definition: MCContext.h:400
Fragment for data and encoded instructions.
Definition: MCFragment.h:231
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:184
const VersionTuple & getDarwinTargetVariantSDKVersion() const
const Triple * getDarwinTargetVariantTriple() const
const VersionTuple & getSDKVersion() const
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...
This represents a section on a Mach-O system (used by Mac OS X).
StringRef getSegmentName() const
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:36
StringRef getName() const
Definition: MCSection.h:130
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:188
const MCSymbol & getSymbol() const
Definition: MCExpr.h:406
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:407
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:586
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1209
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Target - Wrapper for Target specific information.
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:1849
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
const MCSymbolRefExpr * From
Definition: MCAssembler.h:353
const MCSymbolRefExpr * To
Definition: MCAssembler.h:354