LLVM  4.0.0
MCMachOStreamer.cpp
Go to the documentation of this file.
1 //===-- MCMachOStreamer.cpp - MachO Streamer ------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "llvm/MC/MCStreamer.h"
11 #include "llvm/ADT/DenseMap.h"
12 #include "llvm/ADT/SmallVector.h"
13 #include "llvm/MC/MCAsmBackend.h"
14 #include "llvm/MC/MCAssembler.h"
15 #include "llvm/MC/MCCodeEmitter.h"
16 #include "llvm/MC/MCContext.h"
17 #include "llvm/MC/MCDwarf.h"
18 #include "llvm/MC/MCExpr.h"
19 #include "llvm/MC/MCInst.h"
23 #include "llvm/MC/MCSection.h"
24 #include "llvm/MC/MCSectionMachO.h"
25 #include "llvm/MC/MCSymbolMachO.h"
26 #include "llvm/MC/MCValue.h"
27 #include "llvm/Support/Dwarf.h"
31 
32 using namespace llvm;
33 
34 namespace {
35 
36 class MCMachOStreamer : public MCObjectStreamer {
37 private:
38  /// LabelSections - true if each section change should emit a linker local
39  /// label for use in relocations for assembler local references. Obviates the
40  /// need for local relocations. False by default.
41  bool LabelSections;
42 
43  bool DWARFMustBeAtTheEnd;
44  bool CreatedADWARFSection;
45 
46  /// HasSectionLabel - map of which sections have already had a non-local
47  /// label emitted to them. Used so we don't emit extraneous linker local
48  /// labels in the middle of the section.
49  DenseMap<const MCSection*, bool> HasSectionLabel;
50 
51  void EmitInstToData(const MCInst &Inst, const MCSubtargetInfo &STI) override;
52 
53  void EmitDataRegion(DataRegionData::KindTy Kind);
54  void EmitDataRegionEnd();
55 
56 public:
57  MCMachOStreamer(MCContext &Context, MCAsmBackend &MAB, raw_pwrite_stream &OS,
58  MCCodeEmitter *Emitter, bool DWARFMustBeAtTheEnd, bool label)
59  : MCObjectStreamer(Context, MAB, OS, Emitter), LabelSections(label),
60  DWARFMustBeAtTheEnd(DWARFMustBeAtTheEnd), CreatedADWARFSection(false) {}
61 
62  /// state management
63  void reset() override {
64  CreatedADWARFSection = false;
65  HasSectionLabel.clear();
67  }
68 
69  /// @name MCStreamer Interface
70  /// @{
71 
72  void ChangeSection(MCSection *Sect, const MCExpr *Subsect) override;
73  void EmitLabel(MCSymbol *Symbol) override;
74  void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) override;
75  void EmitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol) override;
76  void EmitAssemblerFlag(MCAssemblerFlag Flag) override;
77  void EmitLinkerOptions(ArrayRef<std::string> Options) override;
78  void EmitDataRegion(MCDataRegionType Kind) override;
79  void EmitVersionMin(MCVersionMinType Kind, unsigned Major,
80  unsigned Minor, unsigned Update) override;
81  void EmitThumbFunc(MCSymbol *Func) override;
82  bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override;
83  void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override;
84  void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
85  unsigned ByteAlignment) override;
86  void BeginCOFFSymbolDef(const MCSymbol *Symbol) override {
87  llvm_unreachable("macho doesn't support this directive");
88  }
89  void EmitCOFFSymbolStorageClass(int StorageClass) override {
90  llvm_unreachable("macho doesn't support this directive");
91  }
92  void EmitCOFFSymbolType(int Type) override {
93  llvm_unreachable("macho doesn't support this directive");
94  }
95  void EndCOFFSymbolDef() override {
96  llvm_unreachable("macho doesn't support this directive");
97  }
98  void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
99  unsigned ByteAlignment) override;
100  void EmitZerofill(MCSection *Section, MCSymbol *Symbol = nullptr,
101  uint64_t Size = 0, unsigned ByteAlignment = 0) override;
102  void EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size,
103  unsigned ByteAlignment = 0) override;
104 
105  void EmitFileDirective(StringRef Filename) override {
106  // FIXME: Just ignore the .file; it isn't important enough to fail the
107  // entire assembly.
108 
109  // report_fatal_error("unsupported directive: '.file'");
110  }
111 
112  void EmitIdent(StringRef IdentString) override {
113  llvm_unreachable("macho doesn't support this directive");
114  }
115 
116  void EmitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args) override {
117  getAssembler().getLOHContainer().addDirective(Kind, Args);
118  }
119 
120  void FinishImpl() override;
121 };
122 
123 } // end anonymous namespace.
124 
125 static bool canGoAfterDWARF(const MCSectionMachO &MSec) {
126  // These sections are created by the assembler itself after the end of
127  // the .s file.
128  StringRef SegName = MSec.getSegmentName();
129  StringRef SecName = MSec.getSectionName();
130 
131  if (SegName == "__LD" && SecName == "__compact_unwind")
132  return true;
133 
134  if (SegName == "__IMPORT") {
135  if (SecName == "__jump_table")
136  return true;
137 
138  if (SecName == "__pointers")
139  return true;
140  }
141 
142  if (SegName == "__TEXT" && SecName == "__eh_frame")
143  return true;
144 
145  if (SegName == "__DATA" && (SecName == "__nl_symbol_ptr" ||
146  SecName == "__thread_ptr"))
147  return true;
148 
149  return false;
150 }
151 
152 void MCMachOStreamer::ChangeSection(MCSection *Section,
153  const MCExpr *Subsection) {
154  // Change the section normally.
155  bool Created = MCObjectStreamer::changeSectionImpl(Section, Subsection);
156  const MCSectionMachO &MSec = *cast<MCSectionMachO>(Section);
157  StringRef SegName = MSec.getSegmentName();
158  if (SegName == "__DWARF")
159  CreatedADWARFSection = true;
160  else if (Created && DWARFMustBeAtTheEnd && !canGoAfterDWARF(MSec))
161  assert(!CreatedADWARFSection && "Creating regular section after DWARF");
162 
163  // Output a linker-local symbol so we don't need section-relative local
164  // relocations. The linker hates us when we do that.
165  if (LabelSections && !HasSectionLabel[Section] &&
166  !Section->getBeginSymbol()) {
167  MCSymbol *Label = getContext().createLinkerPrivateTempSymbol();
168  Section->setBeginSymbol(Label);
169  HasSectionLabel[Section] = true;
170  }
171 }
172 
173 void MCMachOStreamer::EmitEHSymAttributes(const MCSymbol *Symbol,
174  MCSymbol *EHSymbol) {
175  getAssembler().registerSymbol(*Symbol);
176  if (Symbol->isExternal())
177  EmitSymbolAttribute(EHSymbol, MCSA_Global);
178  if (cast<MCSymbolMachO>(Symbol)->isWeakDefinition())
179  EmitSymbolAttribute(EHSymbol, MCSA_WeakDefinition);
180  if (Symbol->isPrivateExtern())
181  EmitSymbolAttribute(EHSymbol, MCSA_PrivateExtern);
182 }
183 
184 void MCMachOStreamer::EmitLabel(MCSymbol *Symbol) {
185  assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
186 
187  // We have to create a new fragment if this is an atom defining symbol,
188  // fragments cannot span atoms.
189  if (getAssembler().isSymbolLinkerVisible(*Symbol))
190  insert(new MCDataFragment());
191 
193 
194  // This causes the reference type flag to be cleared. Darwin 'as' was "trying"
195  // to clear the weak reference and weak definition bits too, but the
196  // implementation was buggy. For now we just try to match 'as', for
197  // diffability.
198  //
199  // FIXME: Cleanup this code, these bits should be emitted based on semantic
200  // properties, not on the order of definition, etc.
201  cast<MCSymbolMachO>(Symbol)->clearReferenceType();
202 }
203 
204 void MCMachOStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
205  MCValue Res;
206 
207  if (Value->evaluateAsRelocatable(Res, nullptr, nullptr)) {
208  if (const MCSymbolRefExpr *SymAExpr = Res.getSymA()) {
209  const MCSymbol &SymA = SymAExpr->getSymbol();
210  if (!Res.getSymB() && (SymA.getName() == "" || Res.getConstant() != 0))
211  cast<MCSymbolMachO>(Symbol)->setAltEntry();
212  }
213  }
214  MCObjectStreamer::EmitAssignment(Symbol, Value);
215 }
216 
217 void MCMachOStreamer::EmitDataRegion(DataRegionData::KindTy Kind) {
218  // Create a temporary label to mark the start of the data region.
219  MCSymbol *Start = getContext().createTempSymbol();
220  EmitLabel(Start);
221  // Record the region for the object writer to use.
222  DataRegionData Data = { Kind, Start, nullptr };
223  std::vector<DataRegionData> &Regions = getAssembler().getDataRegions();
224  Regions.push_back(Data);
225 }
226 
227 void MCMachOStreamer::EmitDataRegionEnd() {
228  std::vector<DataRegionData> &Regions = getAssembler().getDataRegions();
229  assert(!Regions.empty() && "Mismatched .end_data_region!");
230  DataRegionData &Data = Regions.back();
231  assert(!Data.End && "Mismatched .end_data_region!");
232  // Create a temporary label to mark the end of the data region.
233  Data.End = getContext().createTempSymbol();
234  EmitLabel(Data.End);
235 }
236 
237 void MCMachOStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
238  // Let the target do whatever target specific stuff it needs to do.
239  getAssembler().getBackend().handleAssemblerFlag(Flag);
240  // Do any generic stuff we need to do.
241  switch (Flag) {
242  case MCAF_SyntaxUnified: return; // no-op here.
243  case MCAF_Code16: return; // Change parsing mode; no-op here.
244  case MCAF_Code32: return; // Change parsing mode; no-op here.
245  case MCAF_Code64: return; // Change parsing mode; no-op here.
247  getAssembler().setSubsectionsViaSymbols(true);
248  return;
249  }
250 }
251 
252 void MCMachOStreamer::EmitLinkerOptions(ArrayRef<std::string> Options) {
253  getAssembler().getLinkerOptions().push_back(Options);
254 }
255 
256 void MCMachOStreamer::EmitDataRegion(MCDataRegionType Kind) {
257  switch (Kind) {
258  case MCDR_DataRegion:
259  EmitDataRegion(DataRegionData::Data);
260  return;
261  case MCDR_DataRegionJT8:
262  EmitDataRegion(DataRegionData::JumpTable8);
263  return;
264  case MCDR_DataRegionJT16:
265  EmitDataRegion(DataRegionData::JumpTable16);
266  return;
267  case MCDR_DataRegionJT32:
268  EmitDataRegion(DataRegionData::JumpTable32);
269  return;
270  case MCDR_DataRegionEnd:
271  EmitDataRegionEnd();
272  return;
273  }
274 }
275 
276 void MCMachOStreamer::EmitVersionMin(MCVersionMinType Kind, unsigned Major,
277  unsigned Minor, unsigned Update) {
278  getAssembler().setVersionMinInfo(Kind, Major, Minor, Update);
279 }
280 
281 void MCMachOStreamer::EmitThumbFunc(MCSymbol *Symbol) {
282  // Remember that the function is a thumb function. Fixup and relocation
283  // values will need adjusted.
284  getAssembler().setIsThumbFunc(Symbol);
285  cast<MCSymbolMachO>(Symbol)->setThumbFunc();
286 }
287 
288 bool MCMachOStreamer::EmitSymbolAttribute(MCSymbol *Sym,
290  MCSymbolMachO *Symbol = cast<MCSymbolMachO>(Sym);
291 
292  // Indirect symbols are handled differently, to match how 'as' handles
293  // them. This makes writing matching .o files easier.
294  if (Attribute == MCSA_IndirectSymbol) {
295  // Note that we intentionally cannot use the symbol data here; this is
296  // important for matching the string table that 'as' generates.
297  IndirectSymbolData ISD;
298  ISD.Symbol = Symbol;
299  ISD.Section = getCurrentSectionOnly();
300  getAssembler().getIndirectSymbols().push_back(ISD);
301  return true;
302  }
303 
304  // Adding a symbol attribute always introduces the symbol, note that an
305  // important side effect of calling registerSymbol here is to register
306  // the symbol with the assembler.
307  getAssembler().registerSymbol(*Symbol);
308 
309  // The implementation of symbol attributes is designed to match 'as', but it
310  // leaves much to desired. It doesn't really make sense to arbitrarily add and
311  // remove flags, but 'as' allows this (in particular, see .desc).
312  //
313  // In the future it might be worth trying to make these operations more well
314  // defined.
315  switch (Attribute) {
316  case MCSA_Invalid:
319  case MCSA_ELF_TypeObject:
320  case MCSA_ELF_TypeTLS:
321  case MCSA_ELF_TypeCommon:
322  case MCSA_ELF_TypeNoType:
324  case MCSA_Hidden:
325  case MCSA_IndirectSymbol:
326  case MCSA_Internal:
327  case MCSA_Protected:
328  case MCSA_Weak:
329  case MCSA_Local:
330  return false;
331 
332  case MCSA_Global:
333  Symbol->setExternal(true);
334  // This effectively clears the undefined lazy bit, in Darwin 'as', although
335  // it isn't very consistent because it implements this as part of symbol
336  // lookup.
337  //
338  // FIXME: Cleanup this code, these bits should be emitted based on semantic
339  // properties, not on the order of definition, etc.
340  Symbol->setReferenceTypeUndefinedLazy(false);
341  break;
342 
343  case MCSA_LazyReference:
344  // FIXME: This requires -dynamic.
345  Symbol->setNoDeadStrip();
346  if (Symbol->isUndefined())
347  Symbol->setReferenceTypeUndefinedLazy(true);
348  break;
349 
350  // Since .reference sets the no dead strip bit, it is equivalent to
351  // .no_dead_strip in practice.
352  case MCSA_Reference:
353  case MCSA_NoDeadStrip:
354  Symbol->setNoDeadStrip();
355  break;
356 
357  case MCSA_SymbolResolver:
358  Symbol->setSymbolResolver();
359  break;
360 
361  case MCSA_AltEntry:
362  Symbol->setAltEntry();
363  break;
364 
365  case MCSA_PrivateExtern:
366  Symbol->setExternal(true);
367  Symbol->setPrivateExtern(true);
368  break;
369 
370  case MCSA_WeakReference:
371  // FIXME: This requires -dynamic.
372  if (Symbol->isUndefined())
373  Symbol->setWeakReference();
374  break;
375 
376  case MCSA_WeakDefinition:
377  // FIXME: 'as' enforces that this is defined and global. The manual claims
378  // it has to be in a coalesced section, but this isn't enforced.
379  Symbol->setWeakDefinition();
380  break;
381 
383  Symbol->setWeakDefinition();
384  Symbol->setWeakReference();
385  break;
386  }
387 
388  return true;
389 }
390 
391 void MCMachOStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
392  // Encode the 'desc' value into the lowest implementation defined bits.
393  getAssembler().registerSymbol(*Symbol);
394  cast<MCSymbolMachO>(Symbol)->setDesc(DescValue);
395 }
396 
397 void MCMachOStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
398  unsigned ByteAlignment) {
399  // FIXME: Darwin 'as' does appear to allow redef of a .comm by itself.
400  assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
401 
402  getAssembler().registerSymbol(*Symbol);
403  Symbol->setExternal(true);
404  Symbol->setCommon(Size, ByteAlignment);
405 }
406 
407 void MCMachOStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
408  unsigned ByteAlignment) {
409  // '.lcomm' is equivalent to '.zerofill'.
410  return EmitZerofill(getContext().getObjectFileInfo()->getDataBSSSection(),
411  Symbol, Size, ByteAlignment);
412 }
413 
414 void MCMachOStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol,
415  uint64_t Size, unsigned ByteAlignment) {
416  getAssembler().registerSection(*Section);
417 
418  // The symbol may not be present, which only creates the section.
419  if (!Symbol)
420  return;
421 
422  // On darwin all virtual sections have zerofill type.
423  assert(Section->isVirtualSection() && "Section does not have zerofill type!");
424 
425  assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
426 
427  getAssembler().registerSymbol(*Symbol);
428 
429  // Emit an align fragment if necessary.
430  if (ByteAlignment != 1)
431  new MCAlignFragment(ByteAlignment, 0, 0, ByteAlignment, Section);
432 
433  MCFragment *F = new MCFillFragment(0, Size, Section);
434  Symbol->setFragment(F);
435 
436  // Update the maximum alignment on the zero fill section if necessary.
437  if (ByteAlignment > Section->getAlignment())
438  Section->setAlignment(ByteAlignment);
439 }
440 
441 // This should always be called with the thread local bss section. Like the
442 // .zerofill directive this doesn't actually switch sections on us.
443 void MCMachOStreamer::EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
444  uint64_t Size, unsigned ByteAlignment) {
445  EmitZerofill(Section, Symbol, Size, ByteAlignment);
446 }
447 
448 void MCMachOStreamer::EmitInstToData(const MCInst &Inst,
449  const MCSubtargetInfo &STI) {
450  MCDataFragment *DF = getOrCreateDataFragment();
451 
454  raw_svector_ostream VecOS(Code);
455  getAssembler().getEmitter().encodeInstruction(Inst, VecOS, Fixups, STI);
456 
457  // Add the fixups and data.
458  for (MCFixup &Fixup : Fixups) {
459  Fixup.setOffset(Fixup.getOffset() + DF->getContents().size());
460  DF->getFixups().push_back(Fixup);
461  }
462  DF->getContents().append(Code.begin(), Code.end());
463 }
464 
465 void MCMachOStreamer::FinishImpl() {
466  EmitFrames(&getAssembler().getBackend());
467 
468  // We have to set the fragment atom associations so we can relax properly for
469  // Mach-O.
470 
471  // First, scan the symbol table to build a lookup table from fragments to
472  // defining symbols.
474  for (const MCSymbol &Symbol : getAssembler().symbols()) {
475  if (getAssembler().isSymbolLinkerVisible(Symbol) && Symbol.isInSection() &&
476  !Symbol.isVariable()) {
477  // An atom defining symbol should never be internal to a fragment.
478  assert(Symbol.getOffset() == 0 &&
479  "Invalid offset in atom defining symbol!");
480  DefiningSymbolMap[Symbol.getFragment()] = &Symbol;
481  }
482  }
483 
484  // Set the fragment atom associations by tracking the last seen atom defining
485  // symbol.
486  for (MCSection &Sec : getAssembler()) {
487  const MCSymbol *CurrentAtom = nullptr;
488  for (MCFragment &Frag : Sec) {
489  if (const MCSymbol *Symbol = DefiningSymbolMap.lookup(&Frag))
490  CurrentAtom = Symbol;
491  Frag.setAtom(CurrentAtom);
492  }
493  }
494 
496 }
497 
500  bool RelaxAll, bool DWARFMustBeAtTheEnd,
501  bool LabelSections) {
502  MCMachOStreamer *S = new MCMachOStreamer(Context, MAB, OS, CE,
503  DWARFMustBeAtTheEnd, LabelSections);
504  const Triple &TT = Context.getObjectFileInfo()->getTargetTriple();
505  if (TT.isOSDarwin()) {
506  unsigned Major, Minor, Update;
507  TT.getOSVersion(Major, Minor, Update);
508  // If there is a version specified, Major will be non-zero.
509  if (Major) {
510  MCVersionMinType VersionType;
511  if (TT.isWatchOS())
512  VersionType = MCVM_WatchOSVersionMin;
513  else if (TT.isTvOS())
514  VersionType = MCVM_TvOSVersionMin;
515  else if (TT.isMacOSX())
516  VersionType = MCVM_OSXVersionMin;
517  else {
518  assert(TT.isiOS() && "Must only be iOS platform left");
519  VersionType = MCVM_IOSVersionMin;
520  }
521  S->EmitVersionMin(VersionType, Major, Minor, Update);
522  }
523  }
524  if (RelaxAll)
525  S->getAssembler().setRelaxAll(true);
526  return S;
527 }
Instances of this class represent a uniqued identifier for a section in the current translation unit...
Definition: MCSection.h:40
void setPrivateExtern(bool Value)
Definition: MCSymbol.h:390
bool changeSectionImpl(MCSection *Section, const MCExpr *Subsection)
This represents a section on a Mach-O system (used by Mac OS X).
LLVMContext & Context
ValueT lookup(const KeyT &Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Definition: DenseMap.h:162
void EmitLabel(MCSymbol *Symbol) override
Emit a label for Symbol into the current section.
.type _foo, STT_OBJECT # aka
Definition: MCDirectives.h:25
This represents an "assembler immediate".
Definition: MCValue.h:40
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:39
Not a valid directive.
Definition: MCDirectives.h:20
.watchos_version_min
Definition: MCDirectives.h:68
.ios_version_min
Definition: MCDirectives.h:65
void setAlignment(unsigned Value)
Definition: MCSection.h:118
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:490
.macosx_version_min
Definition: MCDirectives.h:66
MCDataRegionType
Definition: MCDirectives.h:56
bool isExternal() const
Definition: MCSymbol.h:386
.type _foo, STT_NOTYPE # aka
Definition: MCDirectives.h:28
unsigned getAlignment() const
Definition: MCSection.h:117
COFF::SymbolStorageClass StorageClass
Definition: COFFYAML.cpp:296
Encode information on a single operation to perform on a byte sequence (e.g., an encoded instruction)...
Definition: MCFixup.h:66
bool isMacOSX() const
isMacOSX - Is this a Mac OS X triple.
Definition: Triple.h:427
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:32
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:34
.data_region jt16
Definition: MCDirectives.h:59
Represent a reference to a symbol from inside an expression.
Definition: MCExpr.h:161
void setCommon(uint64_t Size, unsigned Align)
Mark this symbol as being 'common'.
Definition: MCSymbol.h:338
.local (ELF)
Definition: MCDirectives.h:35
.no_dead_strip (MachO)
Definition: MCDirectives.h:36
Context object for machine code objects.
Definition: MCContext.h:51
void setWeakReference() const
Definition: MCSymbolMachO.h:75
#define F(x, y, z)
Definition: MD5.cpp:51
.code16 (X86) / .code 16 (ARM)
Definition: MCDirectives.h:51
Streaming object file generation interface.
StringRef getSectionName() const
.type _foo, STT_GNU_IFUNC
Definition: MCDirectives.h:24
Function Alias Analysis false
.alt_entry (MachO)
Definition: MCDirectives.h:38
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:33
.protected (ELF)
Definition: MCDirectives.h:40
void setWeakDefinition() const
Definition: MCSymbolMachO.h:82
void setExternal(bool Value) const
Definition: MCSymbol.h:387
.lazy_reference (MachO)
Definition: MCDirectives.h:34
bool isTvOS() const
Is this an Apple tvOS triple.
Definition: Triple.h:441
const Triple & getTargetTriple() const
SmallVectorImpl< char > & getContents()
Definition: MCFragment.h:175
.reference (MachO)
Definition: MCDirectives.h:41
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:150
Flag
These should be considered private to the implementation of the MCInstrDesc class.
Definition: MCInstrDesc.h:121
void setFragment(MCFragment *F) const
Mark the symbol as defined in the fragment F.
Definition: MCSymbol.h:270
bool isiOS() const
Is this an iOS triple.
Definition: Triple.h:436
.hidden (ELF)
Definition: MCDirectives.h:31
.data_region jt32
Definition: MCDirectives.h:60
Streaming machine code generation interface.
Definition: MCStreamer.h:161
.weak_def_can_be_hidden (MachO)
Definition: MCDirectives.h:45
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
.tvos_version_min
Definition: MCDirectives.h:67
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
Definition: SmallVector.h:115
MCCodeEmitter - Generic instruction encoding interface.
Definition: MCCodeEmitter.h:23
SmallVectorImpl< MCFixup > & getFixups()
Definition: MCFragment.h:200
bool isWatchOS() const
Is this an Apple watchOS triple.
Definition: Triple.h:446
MCLOHType
Linker Optimization Hint Type.
.subsections_via_symbols (MachO)
Definition: MCDirectives.h:50
void setReferenceTypeUndefinedLazy(bool Value) const
Definition: MCSymbolMachO.h:54
.weak_reference (MachO)
Definition: MCDirectives.h:44
bool isInSection(bool SetUsed=true) const
isInSection - Check if this symbol is defined in some section (i.e., it is defined but not absolute)...
Definition: MCSymbol.h:251
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
Definition: SmallVector.h:392
const MCSymbolRefExpr * getSymB() const
Definition: MCValue.h:48
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
static bool canGoAfterDWARF(const MCSectionMachO &MSec)
PowerPC TLS Dynamic Call Fixup
bool isOSDarwin() const
isOSDarwin - Is this a "Darwin" OS (OS X, iOS, or watchOS).
Definition: Triple.h:455
void setSymbolResolver() const
Definition: MCSymbolMachO.h:89
const MCSymbolRefExpr * getSymA() const
Definition: MCValue.h:47
virtual bool isVirtualSection() const =0
Check whether this section is "virtual", that is has no actual object file contents.
void getOSVersion(unsigned &Major, unsigned &Minor, unsigned &Micro) const
getOSVersion - Parse the version number from the OS name component of the triple, if present...
Definition: Triple.cpp:974
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:843
.indirect_symbol (MachO)
Definition: MCDirectives.h:32
.type _foo, STT_TLS # aka
Definition: MCDirectives.h:26
MCSymbol * getBeginSymbol()
Definition: MCSection.h:106
MCSymbolAttr
Definition: MCDirectives.h:19
void setNoDeadStrip() const
Definition: MCSymbolMachO.h:68
bool evaluateAsRelocatable(MCValue &Res, const MCAsmLayout *Layout, const MCFixup *Fixup) const
Try to evaluate the expression to a relocatable value, i.e.
Definition: MCExpr.cpp:581
.syntax (ARM/ELF)
Definition: MCDirectives.h:49
void setAltEntry() const
Definition: MCSymbolMachO.h:93
.internal (ELF)
Definition: MCDirectives.h:33
StringRef getSegmentName() const
.code32 (X86) / .code 32 (ARM)
Definition: MCDirectives.h:52
.type _foo, STT_COMMON # aka
Definition: MCDirectives.h:27
.code64 (X86)
Definition: MCDirectives.h:53
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
Definition: SmallVector.h:119
.symbol_resolver (MachO)
Definition: MCDirectives.h:37
StringRef getName() const
getName - Get the symbol name.
Definition: MCSymbol.h:199
.type _foo,
Definition: MCDirectives.h:30
void FinishImpl() override
Streamer specific finalization.
uint64_t getOffset() const
Definition: MCSymbol.h:314
MCAssemblerFlag
Definition: MCDirectives.h:48
.type _foo, STT_FUNC # aka
Definition: MCDirectives.h:23
void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) override
Emit an assignment of Value to Symbol.
void reset() override
state management
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
Definition: SmallVector.h:135
MCSubtargetInfo - Generic base class for all target subtargets.
.weak_definition (MachO)
Definition: MCDirectives.h:43
bool isVariable() const
isVariable - Check if this is a variable symbol.
Definition: MCSymbol.h:289
MCFragment * getFragment(bool SetUsed=true) const
Definition: MCSymbol.h:377
An abstract base class for streams implementations that also support a pwrite operation.
Definition: raw_ostream.h:333
const unsigned Kind
Fragment for data and encoded instructions.
Definition: MCFragment.h:218
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
.private_extern (MachO)
Definition: MCDirectives.h:39
int64_t getConstant() const
Definition: MCValue.h:46
.data_region jt8
Definition: MCDirectives.h:58
bool isPrivateExtern() const
Definition: MCSymbol.h:389
cl::opt< bool > RelaxAll("mc-relax-all", cl::desc("When used with filetype=obj, ""relax all fixups in the emitted object file"))
MCStreamer * createMachOStreamer(MCContext &Ctx, MCAsmBackend &TAB, raw_pwrite_stream &OS, MCCodeEmitter *CE, bool RelaxAll, bool DWARFMustBeAtTheEnd, bool LabelSections=false)
MCVersionMinType
Definition: MCDirectives.h:64
LLVM Value Representation.
Definition: Value.h:71
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:36
const MCObjectFileInfo * getObjectFileInfo() const
Definition: MCContext.h:247
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
.end_data_region
Definition: MCDirectives.h:61
bool isUndefined(bool SetUsed=true) const
isUndefined - Check if this symbol undefined (i.e., implicitly defined).
Definition: MCSymbol.h:256
void setBeginSymbol(MCSymbol *Sym)
Definition: MCSection.h:110