LLVM  16.0.0git
MCELFStreamer.cpp
Go to the documentation of this file.
1 //===- lib/MC/MCELFStreamer.cpp - ELF Object Output -----------------------===//
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 // This file assembles .s files and emits ELF .o object files.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "llvm/MC/MCELFStreamer.h"
14 #include "llvm/ADT/SmallString.h"
15 #include "llvm/ADT/SmallVector.h"
16 #include "llvm/BinaryFormat/ELF.h"
17 #include "llvm/MC/MCAsmBackend.h"
18 #include "llvm/MC/MCAsmInfo.h"
19 #include "llvm/MC/MCAssembler.h"
20 #include "llvm/MC/MCCodeEmitter.h"
21 #include "llvm/MC/MCContext.h"
22 #include "llvm/MC/MCExpr.h"
23 #include "llvm/MC/MCFixup.h"
24 #include "llvm/MC/MCFragment.h"
26 #include "llvm/MC/MCObjectWriter.h"
27 #include "llvm/MC/MCSection.h"
28 #include "llvm/MC/MCSectionELF.h"
29 #include "llvm/MC/MCStreamer.h"
30 #include "llvm/MC/MCSymbol.h"
31 #include "llvm/MC/MCSymbolELF.h"
32 #include "llvm/MC/TargetRegistry.h"
33 #include "llvm/Support/Casting.h"
35 #include "llvm/Support/LEB128.h"
37 #include <cassert>
38 #include <cstdint>
39 
40 using namespace llvm;
41 
43  std::unique_ptr<MCAsmBackend> TAB,
44  std::unique_ptr<MCObjectWriter> OW,
45  std::unique_ptr<MCCodeEmitter> Emitter)
46  : MCObjectStreamer(Context, std::move(TAB), std::move(OW),
47  std::move(Emitter)) {}
48 
49 bool MCELFStreamer::isBundleLocked() const {
51 }
52 
53 void MCELFStreamer::mergeFragment(MCDataFragment *DF,
54  MCDataFragment *EF) {
55  MCAssembler &Assembler = getAssembler();
56 
57  if (Assembler.isBundlingEnabled() && Assembler.getRelaxAll()) {
58  uint64_t FSize = EF->getContents().size();
59 
60  if (FSize > Assembler.getBundleAlignSize())
61  report_fatal_error("Fragment can't be larger than a bundle size");
62 
63  uint64_t RequiredBundlePadding = computeBundlePadding(
64  Assembler, EF, DF->getContents().size(), FSize);
65 
66  if (RequiredBundlePadding > UINT8_MAX)
67  report_fatal_error("Padding cannot exceed 255 bytes");
68 
69  if (RequiredBundlePadding > 0) {
70  SmallString<256> Code;
71  raw_svector_ostream VecOS(Code);
72  EF->setBundlePadding(static_cast<uint8_t>(RequiredBundlePadding));
73  Assembler.writeFragmentPadding(VecOS, *EF, FSize);
74 
75  DF->getContents().append(Code.begin(), Code.end());
76  }
77  }
78 
79  flushPendingLabels(DF, DF->getContents().size());
80 
81  for (unsigned i = 0, e = EF->getFixups().size(); i != e; ++i) {
82  EF->getFixups()[i].setOffset(EF->getFixups()[i].getOffset() +
83  DF->getContents().size());
84  DF->getFixups().push_back(EF->getFixups()[i]);
85  }
86  if (DF->getSubtargetInfo() == nullptr && EF->getSubtargetInfo())
87  DF->setHasInstructions(*EF->getSubtargetInfo());
88  DF->getContents().append(EF->getContents().begin(), EF->getContents().end());
89 }
90 
91 void MCELFStreamer::initSections(bool NoExecStack, const MCSubtargetInfo &STI) {
92  MCContext &Ctx = getContext();
95 
96  if (NoExecStack)
98 }
99 
101  auto *Symbol = cast<MCSymbolELF>(S);
103 
104  const MCSectionELF &Section =
105  static_cast<const MCSectionELF &>(*getCurrentSectionOnly());
106  if (Section.getFlags() & ELF::SHF_TLS)
107  Symbol->setType(ELF::STT_TLS);
108 }
109 
111  uint64_t Offset) {
112  auto *Symbol = cast<MCSymbolELF>(S);
114 
115  const MCSectionELF &Section =
116  static_cast<const MCSectionELF &>(*getCurrentSectionOnly());
117  if (Section.getFlags() & ELF::SHF_TLS)
118  Symbol->setType(ELF::STT_TLS);
119 }
120 
122  // Let the target do whatever target specific stuff it needs to do.
124  // Do any generic stuff we need to do.
125  switch (Flag) {
126  case MCAF_SyntaxUnified: return; // no-op here.
127  case MCAF_Code16: return; // Change parsing mode; no-op here.
128  case MCAF_Code32: return; // Change parsing mode; no-op here.
129  case MCAF_Code64: return; // Change parsing mode; no-op here.
132  return;
133  }
134 
135  llvm_unreachable("invalid assembler flag!");
136 }
137 
138 // If bundle alignment is used and there are any instructions in the section, it
139 // needs to be aligned to at least the bundle size.
140 static void setSectionAlignmentForBundling(const MCAssembler &Assembler,
141  MCSection *Section) {
142  if (Section && Assembler.isBundlingEnabled() && Section->hasInstructions() &&
143  Section->getAlignment() < Assembler.getBundleAlignSize())
144  Section->setAlignment(Align(Assembler.getBundleAlignSize()));
145 }
146 
148  const MCExpr *Subsection) {
149  MCSection *CurSection = getCurrentSectionOnly();
150  if (CurSection && isBundleLocked())
151  report_fatal_error("Unterminated .bundle_lock when changing a section");
152 
154  // Ensure the previous section gets aligned if necessary.
155  setSectionAlignmentForBundling(Asm, CurSection);
156  auto *SectionELF = static_cast<const MCSectionELF *>(Section);
157  const MCSymbol *Grp = SectionELF->getGroup();
158  if (Grp)
159  Asm.registerSymbol(*Grp);
160  if (SectionELF->getFlags() & ELF::SHF_GNU_RETAIN)
161  Asm.getWriter().markGnuAbi();
162 
163  changeSectionImpl(Section, Subsection);
164  Asm.registerSymbol(*Section->getBeginSymbol());
165 }
166 
171  Alias->setVariableValue(Value);
172 }
173 
174 // When GNU as encounters more than one .type declaration for an object it seems
175 // to use a mechanism similar to the one below to decide which type is actually
176 // used in the object file. The greater of T1 and T2 is selected based on the
177 // following ordering:
178 // STT_NOTYPE < STT_OBJECT < STT_FUNC < STT_GNU_IFUNC < STT_TLS < anything else
179 // If neither T1 < T2 nor T2 < T1 according to this ordering, use T2 (the user
180 // provided type).
181 static unsigned CombineSymbolTypes(unsigned T1, unsigned T2) {
184  if (T1 == Type)
185  return T2;
186  if (T2 == Type)
187  return T1;
188  }
189 
190  return T2;
191 }
192 
194  auto *Symbol = cast<MCSymbolELF>(S);
195 
196  // Adding a symbol attribute always introduces the symbol, note that an
197  // important side effect of calling registerSymbol here is to register
198  // the symbol with the assembler.
200 
201  // The implementation of symbol attributes is designed to match 'as', but it
202  // leaves much to desired. It doesn't really make sense to arbitrarily add and
203  // remove flags, but 'as' allows this (in particular, see .desc).
204  //
205  // In the future it might be worth trying to make these operations more well
206  // defined.
207  switch (Attribute) {
208  case MCSA_Cold:
209  case MCSA_Extern:
210  case MCSA_LazyReference:
211  case MCSA_Reference:
212  case MCSA_SymbolResolver:
213  case MCSA_PrivateExtern:
214  case MCSA_WeakDefinition:
216  case MCSA_Invalid:
217  case MCSA_IndirectSymbol:
218  case MCSA_Exported:
219  return false;
220 
221  case MCSA_NoDeadStrip:
222  // Ignore for now.
223  break;
224 
226  Symbol->setType(CombineSymbolTypes(Symbol->getType(), ELF::STT_OBJECT));
227  Symbol->setBinding(ELF::STB_GNU_UNIQUE);
229  break;
230 
231  case MCSA_Global:
232  // For `.weak x; .global x`, GNU as sets the binding to STB_WEAK while we
233  // traditionally set the binding to STB_GLOBAL. This is error-prone, so we
234  // error on such cases. Note, we also disallow changed binding from .local.
235  if (Symbol->isBindingSet() && Symbol->getBinding() != ELF::STB_GLOBAL)
237  Symbol->getName() +
238  " changed binding to STB_GLOBAL");
239  Symbol->setBinding(ELF::STB_GLOBAL);
240  break;
241 
242  case MCSA_WeakReference:
243  case MCSA_Weak:
244  // For `.global x; .weak x`, both MC and GNU as set the binding to STB_WEAK.
245  // We emit a warning for now but may switch to an error in the future.
246  if (Symbol->isBindingSet() && Symbol->getBinding() != ELF::STB_WEAK)
248  getStartTokLoc(), Symbol->getName() + " changed binding to STB_WEAK");
249  Symbol->setBinding(ELF::STB_WEAK);
250  break;
251 
252  case MCSA_Local:
253  if (Symbol->isBindingSet() && Symbol->getBinding() != ELF::STB_LOCAL)
255  Symbol->getName() +
256  " changed binding to STB_LOCAL");
257  Symbol->setBinding(ELF::STB_LOCAL);
258  break;
259 
261  Symbol->setType(CombineSymbolTypes(Symbol->getType(), ELF::STT_FUNC));
262  break;
263 
265  Symbol->setType(CombineSymbolTypes(Symbol->getType(), ELF::STT_GNU_IFUNC));
267  break;
268 
269  case MCSA_ELF_TypeObject:
270  Symbol->setType(CombineSymbolTypes(Symbol->getType(), ELF::STT_OBJECT));
271  break;
272 
273  case MCSA_ELF_TypeTLS:
274  Symbol->setType(CombineSymbolTypes(Symbol->getType(), ELF::STT_TLS));
275  break;
276 
277  case MCSA_ELF_TypeCommon:
278  // TODO: Emit these as a common symbol.
279  Symbol->setType(CombineSymbolTypes(Symbol->getType(), ELF::STT_OBJECT));
280  break;
281 
282  case MCSA_ELF_TypeNoType:
283  Symbol->setType(CombineSymbolTypes(Symbol->getType(), ELF::STT_NOTYPE));
284  break;
285 
286  case MCSA_Protected:
287  Symbol->setVisibility(ELF::STV_PROTECTED);
288  break;
289 
290  case MCSA_Hidden:
291  Symbol->setVisibility(ELF::STV_HIDDEN);
292  break;
293 
294  case MCSA_Internal:
295  Symbol->setVisibility(ELF::STV_INTERNAL);
296  break;
297 
298  case MCSA_AltEntry:
299  llvm_unreachable("ELF doesn't support the .alt_entry attribute");
300 
301  case MCSA_LGlobal:
302  llvm_unreachable("ELF doesn't support the .lglobl attribute");
303  }
304 
305  return true;
306 }
307 
309  unsigned ByteAlignment) {
310  auto *Symbol = cast<MCSymbolELF>(S);
312 
313  if (!Symbol->isBindingSet())
314  Symbol->setBinding(ELF::STB_GLOBAL);
315 
316  Symbol->setType(ELF::STT_OBJECT);
317 
318  if (Symbol->getBinding() == ELF::STB_LOCAL) {
322  switchSection(&Section);
323 
325  emitLabel(Symbol);
326  emitZeros(Size);
327 
328  switchSection(P.first, P.second);
329  } else {
330  if(Symbol->declareCommon(Size, ByteAlignment))
331  report_fatal_error(Twine("Symbol: ") + Symbol->getName() +
332  " redeclared as different type");
333  }
334 
335  cast<MCSymbolELF>(Symbol)
336  ->setSize(MCConstantExpr::create(Size, getContext()));
337 }
338 
340  cast<MCSymbolELF>(Symbol)->setSize(Value);
341 }
342 
344  StringRef Name,
345  bool KeepOriginalSym) {
347  getStartTokLoc(), OriginalSym, Name, KeepOriginalSym});
348 }
349 
351  unsigned ByteAlignment) {
352  auto *Symbol = cast<MCSymbolELF>(S);
353  // FIXME: Should this be caught and done earlier?
355  Symbol->setBinding(ELF::STB_LOCAL);
357 }
358 
359 void MCELFStreamer::emitValueImpl(const MCExpr *Value, unsigned Size,
360  SMLoc Loc) {
361  if (isBundleLocked())
362  report_fatal_error("Emitting values inside a locked bundle is forbidden");
363  fixSymbolsInTLSFixups(Value);
365 }
366 
368  int64_t Value,
369  unsigned ValueSize,
370  unsigned MaxBytesToEmit) {
371  if (isBundleLocked())
372  report_fatal_error("Emitting values inside a locked bundle is forbidden");
374  ValueSize, MaxBytesToEmit);
375 }
376 
378  const MCSymbolRefExpr *To,
379  uint64_t Count) {
380  getAssembler().CGProfile.push_back({From, To, Count});
381 }
382 
386  pushSection();
387  switchSection(Comment);
388  if (!SeenIdent) {
389  emitInt8(0);
390  SeenIdent = true;
391  }
392  emitBytes(IdentString);
393  emitInt8(0);
394  popSection();
395 }
396 
397 void MCELFStreamer::fixSymbolsInTLSFixups(const MCExpr *expr) {
398  switch (expr->getKind()) {
399  case MCExpr::Target:
400  cast<MCTargetExpr>(expr)->fixELFSymbolsInTLSFixups(getAssembler());
401  break;
402  case MCExpr::Constant:
403  break;
404 
405  case MCExpr::Binary: {
406  const MCBinaryExpr *be = cast<MCBinaryExpr>(expr);
407  fixSymbolsInTLSFixups(be->getLHS());
408  fixSymbolsInTLSFixups(be->getRHS());
409  break;
410  }
411 
412  case MCExpr::SymbolRef: {
413  const MCSymbolRefExpr &symRef = *cast<MCSymbolRefExpr>(expr);
414  switch (symRef.getKind()) {
415  default:
416  return;
471  break;
472  }
474  cast<MCSymbolELF>(symRef.getSymbol()).setType(ELF::STT_TLS);
475  break;
476  }
477 
478  case MCExpr::Unary:
479  fixSymbolsInTLSFixups(cast<MCUnaryExpr>(expr)->getSubExpr());
480  break;
481  }
482 }
483 
484 void MCELFStreamer::finalizeCGProfileEntry(const MCSymbolRefExpr *&SRE,
485  uint64_t Offset) {
486  const MCSymbol *S = &SRE->getSymbol();
487  if (S->isTemporary()) {
488  if (!S->isInSection()) {
490  SRE->getLoc(), Twine("Reference to undefined temporary symbol ") +
491  "`" + S->getName() + "`");
492  return;
493  }
494  S = S->getSection().getBeginSymbol();
495  S->setUsedInReloc();
497  SRE->getLoc());
498  }
499  const MCConstantExpr *MCOffset = MCConstantExpr::create(Offset, getContext());
501  if (Optional<std::pair<bool, std::string>> Err =
503  *MCOffset, "BFD_RELOC_NONE", SRE, SRE->getLoc(),
504  *getContext().getSubtargetInfo()))
505  report_fatal_error("Relocation for CG Profile could not be created: " +
506  Twine(Err->second));
507 }
508 
509 void MCELFStreamer::finalizeCGProfile() {
511  if (Asm.CGProfile.empty())
512  return;
514  ".llvm.call-graph-profile", ELF::SHT_LLVM_CALL_GRAPH_PROFILE,
515  ELF::SHF_EXCLUDE, /*sizeof(Elf_CGProfile_Impl<>)=*/8);
516  pushSection();
517  switchSection(CGProfile);
518  uint64_t Offset = 0;
519  for (MCAssembler::CGProfileEntry &E : Asm.CGProfile) {
520  finalizeCGProfileEntry(E.From, Offset);
521  finalizeCGProfileEntry(E.To, Offset);
522  emitIntValue(E.Count, sizeof(uint64_t));
523  Offset += sizeof(uint64_t);
524  }
525  popSection();
526 }
527 
528 void MCELFStreamer::emitInstToFragment(const MCInst &Inst,
529  const MCSubtargetInfo &STI) {
530  this->MCObjectStreamer::emitInstToFragment(Inst, STI);
531  MCRelaxableFragment &F = *cast<MCRelaxableFragment>(getCurrentFragment());
532 
533  for (auto &Fixup : F.getFixups())
534  fixSymbolsInTLSFixups(Fixup.getValue());
535 }
536 
537 // A fragment can only have one Subtarget, and when bundling is enabled we
538 // sometimes need to use the same fragment. We give an error if there
539 // are conflicting Subtargets.
540 static void CheckBundleSubtargets(const MCSubtargetInfo *OldSTI,
541  const MCSubtargetInfo *NewSTI) {
542  if (OldSTI && NewSTI && OldSTI != NewSTI)
543  report_fatal_error("A Bundle can only have one Subtarget.");
544 }
545 
546 void MCELFStreamer::emitInstToData(const MCInst &Inst,
547  const MCSubtargetInfo &STI) {
548  MCAssembler &Assembler = getAssembler();
551  raw_svector_ostream VecOS(Code);
552  Assembler.getEmitter().encodeInstruction(Inst, VecOS, Fixups, STI);
553 
554  for (auto &Fixup : Fixups)
555  fixSymbolsInTLSFixups(Fixup.getValue());
556 
557  // There are several possibilities here:
558  //
559  // If bundling is disabled, append the encoded instruction to the current data
560  // fragment (or create a new such fragment if the current fragment is not a
561  // data fragment, or the Subtarget has changed).
562  //
563  // If bundling is enabled:
564  // - If we're not in a bundle-locked group, emit the instruction into a
565  // fragment of its own. If there are no fixups registered for the
566  // instruction, emit a MCCompactEncodedInstFragment. Otherwise, emit a
567  // MCDataFragment.
568  // - If we're in a bundle-locked group, append the instruction to the current
569  // data fragment because we want all the instructions in a group to get into
570  // the same fragment. Be careful not to do that for the first instruction in
571  // the group, though.
573 
574  if (Assembler.isBundlingEnabled()) {
576  if (Assembler.getRelaxAll() && isBundleLocked()) {
577  // If the -mc-relax-all flag is used and we are bundle-locked, we re-use
578  // the current bundle group.
579  DF = BundleGroups.back();
580  CheckBundleSubtargets(DF->getSubtargetInfo(), &STI);
581  }
582  else if (Assembler.getRelaxAll() && !isBundleLocked())
583  // When not in a bundle-locked group and the -mc-relax-all flag is used,
584  // we create a new temporary fragment which will be later merged into
585  // the current fragment.
586  DF = new MCDataFragment();
587  else if (isBundleLocked() && !Sec.isBundleGroupBeforeFirstInst()) {
588  // If we are bundle-locked, we re-use the current fragment.
589  // The bundle-locking directive ensures this is a new data fragment.
590  DF = cast<MCDataFragment>(getCurrentFragment());
591  CheckBundleSubtargets(DF->getSubtargetInfo(), &STI);
592  }
593  else if (!isBundleLocked() && Fixups.size() == 0) {
594  // Optimize memory usage by emitting the instruction to a
595  // MCCompactEncodedInstFragment when not in a bundle-locked group and
596  // there are no fixups registered.
598  insert(CEIF);
599  CEIF->getContents().append(Code.begin(), Code.end());
600  CEIF->setHasInstructions(STI);
601  return;
602  } else {
603  DF = new MCDataFragment();
604  insert(DF);
605  }
607  // If this fragment is for a group marked "align_to_end", set a flag
608  // in the fragment. This can happen after the fragment has already been
609  // created if there are nested bundle_align groups and an inner one
610  // is the one marked align_to_end.
611  DF->setAlignToBundleEnd(true);
612  }
613 
614  // We're now emitting an instruction in a bundle group, so this flag has
615  // to be turned off.
617  } else {
618  DF = getOrCreateDataFragment(&STI);
619  }
620 
621  // Add the fixups and data.
622  for (auto &Fixup : Fixups) {
623  Fixup.setOffset(Fixup.getOffset() + DF->getContents().size());
624  DF->getFixups().push_back(Fixup);
625  }
626 
627  DF->setHasInstructions(STI);
628  DF->getContents().append(Code.begin(), Code.end());
629 
630  if (Assembler.isBundlingEnabled() && Assembler.getRelaxAll()) {
631  if (!isBundleLocked()) {
632  mergeFragment(getOrCreateDataFragment(&STI), DF);
633  delete DF;
634  }
635  }
636 }
637 
638 void MCELFStreamer::emitBundleAlignMode(unsigned AlignPow2) {
639  assert(AlignPow2 <= 30 && "Invalid bundle alignment");
640  MCAssembler &Assembler = getAssembler();
641  if (AlignPow2 > 0 && (Assembler.getBundleAlignSize() == 0 ||
642  Assembler.getBundleAlignSize() == 1U << AlignPow2))
643  Assembler.setBundleAlignSize(1U << AlignPow2);
644  else
645  report_fatal_error(".bundle_align_mode cannot be changed once set");
646 }
647 
648 void MCELFStreamer::emitBundleLock(bool AlignToEnd) {
650 
651  if (!getAssembler().isBundlingEnabled())
652  report_fatal_error(".bundle_lock forbidden when bundling is disabled");
653 
654  if (!isBundleLocked())
656 
657  if (getAssembler().getRelaxAll() && !isBundleLocked()) {
658  // TODO: drop the lock state and set directly in the fragment
660  BundleGroups.push_back(DF);
661  }
662 
665 }
666 
669 
670  if (!getAssembler().isBundlingEnabled())
671  report_fatal_error(".bundle_unlock forbidden when bundling is disabled");
672  else if (!isBundleLocked())
673  report_fatal_error(".bundle_unlock without matching lock");
674  else if (Sec.isBundleGroupBeforeFirstInst())
675  report_fatal_error("Empty bundle-locked group is forbidden");
676 
677  // When the -mc-relax-all flag is used, we emit instructions to fragments
678  // stored on a stack. When the bundle unlock is emitted, we pop a fragment
679  // from the stack a merge it to the one below.
680  if (getAssembler().getRelaxAll()) {
681  assert(!BundleGroups.empty() && "There are no bundle groups");
682  MCDataFragment *DF = BundleGroups.back();
683 
684  // FIXME: Use BundleGroups to track the lock state instead.
686 
687  // FIXME: Use more separate fragments for nested groups.
688  if (!isBundleLocked()) {
689  mergeFragment(getOrCreateDataFragment(DF->getSubtargetInfo()), DF);
690  BundleGroups.pop_back();
691  delete DF;
692  }
693 
696  } else
698 }
699 
701  // Emit the .gnu attributes section if any attributes have been added.
702  if (!GNUAttributes.empty()) {
703  MCSection *DummyAttributeSection = nullptr;
704  createAttributesSection("gnu", ".gnu.attributes", ELF::SHT_GNU_ATTRIBUTES,
705  DummyAttributeSection, GNUAttributes);
706  }
707 
708  // Ensure the last section gets aligned if necessary.
709  MCSection *CurSection = getCurrentSectionOnly();
711 
712  finalizeCGProfile();
713  emitFrames(nullptr);
714 
716 }
717 
719  llvm_unreachable("Generic ELF doesn't support this directive");
720 }
721 
722 void MCELFStreamer::emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
723  llvm_unreachable("ELF doesn't support this directive");
724 }
725 
727  uint64_t Size, unsigned ByteAlignment,
728  SMLoc Loc) {
729  llvm_unreachable("ELF doesn't support this directive");
730 }
731 
733  uint64_t Size, unsigned ByteAlignment) {
734  llvm_unreachable("ELF doesn't support this directive");
735 }
736 
738  bool OverwriteExisting) {
739  // Look for existing attribute item
740  if (AttributeItem *Item = getAttributeItem(Attribute)) {
741  if (!OverwriteExisting)
742  return;
743  Item->Type = AttributeItem::NumericAttribute;
744  Item->IntValue = Value;
745  return;
746  }
747 
748  // Create new attribute item
750  std::string(StringRef(""))};
751  Contents.push_back(Item);
752 }
753 
755  bool OverwriteExisting) {
756  // Look for existing attribute item
757  if (AttributeItem *Item = getAttributeItem(Attribute)) {
758  if (!OverwriteExisting)
759  return;
760  Item->Type = AttributeItem::TextAttribute;
761  Item->StringValue = std::string(Value);
762  return;
763  }
764 
765  // Create new attribute item
767  std::string(Value)};
768  Contents.push_back(Item);
769 }
770 
771 void MCELFStreamer::setAttributeItems(unsigned Attribute, unsigned IntValue,
772  StringRef StringValue,
773  bool OverwriteExisting) {
774  // Look for existing attribute item
775  if (AttributeItem *Item = getAttributeItem(Attribute)) {
776  if (!OverwriteExisting)
777  return;
779  Item->IntValue = IntValue;
780  Item->StringValue = std::string(StringValue);
781  return;
782  }
783 
784  // Create new attribute item
786  IntValue, std::string(StringValue)};
787  Contents.push_back(Item);
788 }
789 
791 MCELFStreamer::getAttributeItem(unsigned Attribute) {
792  for (size_t I = 0; I < Contents.size(); ++I)
793  if (Contents[I].Tag == Attribute)
794  return &Contents[I];
795  return nullptr;
796 }
797 
798 size_t
799 MCELFStreamer::calculateContentSize(SmallVector<AttributeItem, 64> &AttrsVec) {
800  size_t Result = 0;
801  for (size_t I = 0; I < AttrsVec.size(); ++I) {
802  AttributeItem Item = AttrsVec[I];
803  switch (Item.Type) {
805  break;
807  Result += getULEB128Size(Item.Tag);
808  Result += getULEB128Size(Item.IntValue);
809  break;
811  Result += getULEB128Size(Item.Tag);
812  Result += Item.StringValue.size() + 1; // string + '\0'
813  break;
815  Result += getULEB128Size(Item.Tag);
816  Result += getULEB128Size(Item.IntValue);
817  Result += Item.StringValue.size() + 1; // string + '\0';
818  break;
819  }
820  }
821  return Result;
822 }
823 
824 void MCELFStreamer::createAttributesSection(
825  StringRef Vendor, const Twine &Section, unsigned Type,
826  MCSection *&AttributeSection, SmallVector<AttributeItem, 64> &AttrsVec) {
827  // <format-version>
828  // [ <section-length> "vendor-name"
829  // [ <file-tag> <size> <attribute>*
830  // | <section-tag> <size> <section-number>* 0 <attribute>*
831  // | <symbol-tag> <size> <symbol-number>* 0 <attribute>*
832  // ]+
833  // ]*
834 
835  // Switch section to AttributeSection or get/create the section.
836  if (AttributeSection) {
837  switchSection(AttributeSection);
838  } else {
839  AttributeSection = getContext().getELFSection(Section, Type, 0);
840  switchSection(AttributeSection);
841 
842  // Format version
843  emitInt8(0x41);
844  }
845 
846  // Vendor size + Vendor name + '\0'
847  const size_t VendorHeaderSize = 4 + Vendor.size() + 1;
848 
849  // Tag + Tag Size
850  const size_t TagHeaderSize = 1 + 4;
851 
852  const size_t ContentsSize = calculateContentSize(AttrsVec);
853 
854  emitInt32(VendorHeaderSize + TagHeaderSize + ContentsSize);
855  emitBytes(Vendor);
856  emitInt8(0); // '\0'
857 
859  emitInt32(TagHeaderSize + ContentsSize);
860 
861  // Size should have been accounted for already, now
862  // emit each field as its type (ULEB or String)
863  for (size_t I = 0; I < AttrsVec.size(); ++I) {
864  AttributeItem Item = AttrsVec[I];
865  emitULEB128IntValue(Item.Tag);
866  switch (Item.Type) {
867  default:
868  llvm_unreachable("Invalid attribute type");
870  emitULEB128IntValue(Item.IntValue);
871  break;
873  emitBytes(Item.StringValue);
874  emitInt8(0); // '\0'
875  break;
877  emitULEB128IntValue(Item.IntValue);
878  emitBytes(Item.StringValue);
879  emitInt8(0); // '\0'
880  break;
881  }
882  }
883 
884  AttrsVec.clear();
885 }
886 
888  std::unique_ptr<MCAsmBackend> &&MAB,
889  std::unique_ptr<MCObjectWriter> &&OW,
890  std::unique_ptr<MCCodeEmitter> &&CE,
891  bool RelaxAll) {
892  MCELFStreamer *S =
893  new MCELFStreamer(Context, std::move(MAB), std::move(OW), std::move(CE));
894  if (RelaxAll)
895  S->getAssembler().setRelaxAll(true);
896  return S;
897 }
llvm::MCObjectStreamer::emitRelocDirective
Optional< std::pair< bool, std::string > > emitRelocDirective(const MCExpr &Offset, StringRef Name, const MCExpr *Expr, SMLoc Loc, const MCSubtargetInfo &STI) override
Record a relocation described by the .reloc directive.
Definition: MCObjectStreamer.cpp:795
llvm::MCAssembler::getBackend
MCAsmBackend & getBackend() const
Definition: MCAssembler.h:329
llvm::MCSection::isBundleLocked
bool isBundleLocked() const
Definition: MCSection.h:151
llvm::MCSymbolRefExpr::getKind
VariantKind getKind() const
Definition: MCExpr.h:401
i
i
Definition: README.txt:29
llvm::ELF::STT_TLS
@ STT_TLS
Definition: ELF.h:1231
llvm::MCObjectWriter::markGnuAbi
virtual void markGnuAbi()
ELF only. Mark that we have seen GNU ABI usage (e.g. SHF_GNU_RETAIN).
Definition: MCObjectWriter.h:93
llvm::MCContext::getObjectFileInfo
const MCObjectFileInfo * getObjectFileInfo() const
Definition: MCContext.h:451
llvm::MCStreamer::visitUsedExpr
void visitUsedExpr(const MCExpr &Expr)
Definition: MCStreamer.cpp:1070
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::ELF::STB_GLOBAL
@ STB_GLOBAL
Definition: ELF.h:1214
llvm::MCRelaxableFragment
A relaxable fragment holds on to its MCInst, since it may need to be relaxed during the assembler lay...
Definition: MCFragment.h:270
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
llvm::MCObjectFileInfo::getTextSectionAlignment
virtual unsigned getTextSectionAlignment() const
Definition: MCObjectFileInfo.h:267
llvm::MCEncodedFragment::setHasInstructions
void setHasInstructions(const MCSubtargetInfo &STI)
Record that the fragment contains instructions with the MCSubtargetInfo in effect when the instructio...
Definition: MCFragment.h:176
llvm::MCObjectStreamer::emitLabel
void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override
Emit a label for Symbol into the current section.
Definition: MCObjectStreamer.cpp:286
llvm::MCAssembler::Symvers
std::vector< Symver > Symvers
Definition: MCAssembler.h:235
llvm::MCELFStreamer::emitLabel
void emitLabel(MCSymbol *Symbol, SMLoc Loc=SMLoc()) override
Emit a label for Symbol into the current section.
Definition: MCELFStreamer.cpp:100
llvm::MCSymbolRefExpr::VK_PPC_TPREL_HA
@ VK_PPC_TPREL_HA
Definition: MCExpr.h:270
llvm::MCAssembler::registerSymbol
void registerSymbol(const MCSymbol &Symbol, bool *Created=nullptr)
Definition: MCAssembler.cpp:467
llvm::MCSection::setBundleLockState
void setBundleLockState(BundleLockStateType NewState)
Definition: MCSection.cpp:39
llvm::MCObjectStreamer::emitValueToAlignment
void emitValueToAlignment(unsigned ByteAlignment, int64_t Value=0, unsigned ValueSize=1, unsigned MaxBytesToEmit=0) override
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
Definition: MCObjectStreamer.cpp:644
llvm::MCSymbolRefExpr::VK_PPC_DTPREL_HIGHER
@ VK_PPC_DTPREL_HIGHER
Definition: MCExpr.h:282
llvm::MCSymbolRefExpr::VK_PPC_DTPREL_HIGHEST
@ VK_PPC_DTPREL_HIGHEST
Definition: MCExpr.h:284
llvm::MCSymbolRefExpr::VK_PPC_TLSGD
@ VK_PPC_TLSGD
Definition: MCExpr.h:299
llvm::MCSymbolRefExpr::VK_INDNTPOFF
@ VK_INDNTPOFF
Definition: MCExpr.h:205
llvm::MCContext
Context object for machine code objects.
Definition: MCContext.h:76
llvm::Attribute
Definition: Attributes.h:65
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::MCSA_ELF_TypeObject
@ MCSA_ELF_TypeObject
.type _foo, STT_OBJECT # aka @object
Definition: MCDirectives.h:25
MCCodeEmitter.h
llvm::MCSA_Invalid
@ MCSA_Invalid
Not a valid directive.
Definition: MCDirectives.h:19
llvm::MCELFStreamer::emitZerofill
void emitZerofill(MCSection *Section, MCSymbol *Symbol=nullptr, uint64_t Size=0, unsigned ByteAlignment=0, SMLoc L=SMLoc()) override
Emit the zerofill section and an optional symbol.
Definition: MCELFStreamer.cpp:726
llvm::MCConstantExpr::create
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Definition: MCExpr.cpp:194
llvm::MCSymbolRefExpr::VK_PPC_GOT_TPREL_HI
@ VK_PPC_GOT_TPREL_HI
Definition: MCExpr.h:288
MCSectionELF.h
llvm::MCStreamer::emitInt8
void emitInt8(uint64_t Value)
Definition: MCStreamer.h:736
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1182
llvm::tgtok::Code
@ Code
Definition: TGLexer.h:50
llvm::MCELFStreamer::changeSection
void changeSection(MCSection *Section, const MCExpr *Subsection) override
Update streamer for a new active section.
Definition: MCELFStreamer.cpp:147
llvm::MCAsmBackend::handleAssemblerFlag
virtual void handleAssemblerFlag(MCAssemblerFlag Flag)
Handle any target-specific assembler flags. By default, do nothing.
Definition: MCAsmBackend.h:211
ErrorHandling.h
MCFragment.h
MCAssembler.h
llvm::MCELFStreamer::MCELFStreamer
MCELFStreamer(MCContext &Context, std::unique_ptr< MCAsmBackend > TAB, std::unique_ptr< MCObjectWriter > OW, std::unique_ptr< MCCodeEmitter > Emitter)
Definition: MCELFStreamer.cpp:42
llvm::MCSymbolRefExpr::VK_PPC_GOT_TLSGD_HI
@ VK_PPC_GOT_TLSGD_HI
Definition: MCExpr.h:297
llvm::ELF::SHT_NOBITS
@ SHT_NOBITS
Definition: ELF.h:983
llvm::MCELFStreamer::AttributeItem::TextAttribute
@ TextAttribute
Definition: MCELFStreamer.h:98
llvm::ELF::STT_NOTYPE
@ STT_NOTYPE
Definition: ELF.h:1225
MCObjectFileInfo.h
llvm::MCObjectStreamer::emitLabelAtPos
virtual void emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, MCFragment *F, uint64_t Offset)
Definition: MCObjectStreamer.cpp:322
llvm::MCSymbolRefExpr::VK_PPC_DTPREL_HI
@ VK_PPC_DTPREL_HI
Definition: MCExpr.h:278
llvm::MCSection::getBundleLockState
BundleLockStateType getBundleLockState() const
Definition: MCSection.h:149
llvm::getULEB128Size
unsigned getULEB128Size(uint64_t Value)
Utility function to get the size of the ULEB128-encoded value.
Definition: LEB128.cpp:19
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::MCELFStreamer::emitTBSSSymbol
void emitTBSSSymbol(MCSection *Section, MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment=0) override
Emit a thread local bss (.tbss) symbol.
Definition: MCELFStreamer.cpp:732
llvm::MCStreamer::popSection
bool popSection()
Restore the current and previous section from the section stack.
Definition: MCStreamer.h:420
llvm::MCStreamer::emitInt32
void emitInt32(uint64_t Value)
Definition: MCStreamer.h:738
llvm::ELF::SHF_MERGE
@ SHF_MERGE
Definition: ELF.h:1066
T1
#define T1
Definition: Mips16ISelLowering.cpp:340
llvm::Optional
Definition: APInt.h:33
llvm::ELF::SHT_PROGBITS
@ SHT_PROGBITS
Definition: ELF.h:976
llvm::MCSA_ELF_TypeNoType
@ MCSA_ELF_TypeNoType
.type _foo, STT_NOTYPE # aka @notype
Definition: MCDirectives.h:28
llvm::ELF::SHF_TLS
@ SHF_TLS
Definition: ELF.h:1085
llvm::MCStreamer::getCurrentSection
MCSectionSubPair getCurrentSection() const
Return the current section that the streamer is emitting code to.
Definition: MCStreamer.h:384
llvm::MCSymbolRefExpr::VK_PPC_GOT_TLSGD_LO
@ VK_PPC_GOT_TLSGD_LO
Definition: MCExpr.h:296
llvm::MCSymbolRefExpr::VK_PPC_DTPREL_HIGHESTA
@ VK_PPC_DTPREL_HIGHESTA
Definition: MCExpr.h:285
llvm::MCInst
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
llvm::MCEncodedFragmentWithFixups::getFixups
SmallVectorImpl< MCFixup > & getFixups()
Definition: MCFragment.h:222
llvm::MCSectionELF
This represents a section on linux, lots of unix variants and some bare metal systems.
Definition: MCSectionELF.h:26
llvm::MCAssemblerFlag
MCAssemblerFlag
Definition: MCDirectives.h:51
llvm::MCSymbol::setVariableValue
void setVariableValue(const MCExpr *Value)
Definition: MCSymbol.cpp:47
llvm::MCSection::setBundleGroupBeforeFirstInst
void setBundleGroupBeforeFirstInst(bool IsFirst)
Definition: MCSection.h:156
llvm::dwarf::Tag
Tag
Definition: Dwarf.h:105
llvm::MCBinaryExpr
Binary assembler expressions.
Definition: MCExpr.h:481
llvm::ELF::STV_HIDDEN
@ STV_HIDDEN
Definition: ELF.h:1245
MCELFStreamer.h
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::MCSymbolAttr
MCSymbolAttr
Definition: MCDirectives.h:18
llvm::ELF::STT_FUNC
@ STT_FUNC
Definition: ELF.h:1227
llvm::MCSA_Cold
@ MCSA_Cold
.cold (MachO)
Definition: MCDirectives.h:22
llvm::MCSA_Local
@ MCSA_Local
.local (ELF)
Definition: MCDirectives.h:38
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::MCSymbolRefExpr::VK_PPC_TPREL_HIGHA
@ VK_PPC_TPREL_HIGHA
Definition: MCExpr.h:272
llvm::MCSA_NoDeadStrip
@ MCSA_NoDeadStrip
.no_dead_strip (MachO)
Definition: MCDirectives.h:39
llvm::MCSymbolRefExpr::VK_PPC_TLS
@ VK_PPC_TLS
Definition: MCExpr.h:294
llvm::MCFragment
Definition: MCFragment.h:30
llvm::MCStreamer
Streaming machine code generation interface.
Definition: MCStreamer.h:212
llvm::ELF::STV_PROTECTED
@ STV_PROTECTED
Definition: ELF.h:1246
llvm::MCSymbolRefExpr::VK_NTPOFF
@ VK_NTPOFF
Definition: MCExpr.h:206
llvm::MCSymbolRefExpr::VK_PPC_GOT_TLSGD_PCREL
@ VK_PPC_GOT_TLSGD_PCREL
Definition: MCExpr.h:307
llvm::MCSymbolRefExpr::VK_PPC_GOT_DTPREL_LO
@ VK_PPC_GOT_DTPREL_LO
Definition: MCExpr.h:291
ELF.h
llvm::MCELFStreamer
Definition: MCELFStreamer.h:31
MCAsmBackend.h
llvm::SMLoc
Represents a location in source code.
Definition: SMLoc.h:23
llvm::ELF::STB_GNU_UNIQUE
@ STB_GNU_UNIQUE
Definition: ELF.h:1216
SmallString.h
llvm::MCSymbolRefExpr::VK_PPC_TPREL_HIGHEST
@ VK_PPC_TPREL_HIGHEST
Definition: MCExpr.h:275
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
llvm::MCAssembler::getContext
MCContext & getContext() const
Definition: MCAssembler.h:321
llvm::MCExpr::Target
@ Target
Target specific expression.
Definition: MCExpr.h:42
llvm::MCSA_Extern
@ MCSA_Extern
.extern (XCOFF)
Definition: MCDirectives.h:32
llvm::MCSA_AltEntry
@ MCSA_AltEntry
.alt_entry (MachO)
Definition: MCDirectives.h:41
llvm::MCObjectStreamer::emitValueImpl
void emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc()) override
Emit the expression Value into the output as a native integer of the given Size bytes.
Definition: MCObjectStreamer.cpp:244
MCSymbolELF.h
llvm::MCSA_Protected
@ MCSA_Protected
.protected (ELF)
Definition: MCDirectives.h:43
MCContext.h
llvm::MCSymbolRefExpr::VK_GOTNTPOFF
@ VK_GOTNTPOFF
Definition: MCExpr.h:207
llvm::MCStreamer::switchSection
virtual void switchSection(MCSection *Section, const MCExpr *Subsection=nullptr)
Set the current section where code is being emitted to Section.
Definition: MCStreamer.cpp:1225
llvm::MCSymbolRefExpr::VK_DTPREL
@ VK_DTPREL
Definition: MCExpr.h:358
MCSymbol.h
llvm::MCSA_LazyReference
@ MCSA_LazyReference
.lazy_reference (MachO)
Definition: MCDirectives.h:37
llvm::ms_demangle::QualifierMangleMode::Result
@ Result
llvm::MCELFStreamer::emitCGProfileEntry
void emitCGProfileEntry(const MCSymbolRefExpr *From, const MCSymbolRefExpr *To, uint64_t Count) override
Definition: MCELFStreamer.cpp:377
llvm::MCSA_LGlobal
@ MCSA_LGlobal
.lglobl (XCOFF)
Definition: MCDirectives.h:31
llvm::MCContext::getELFSection
MCSectionELF * getELFSection(const Twine &Section, unsigned Type, unsigned Flags)
Definition: MCContext.h:564
llvm::MCSymbolRefExpr::VK_TLSLDM
@ VK_TLSLDM
Definition: MCExpr.h:211
llvm::MCAF_Code16
@ MCAF_Code16
.code16 (X86) / .code 16 (ARM)
Definition: MCDirectives.h:54
llvm::MCObjectStreamer
Streaming object file generation interface.
Definition: MCObjectStreamer.h:42
llvm::MCSA_ELF_TypeIndFunction
@ MCSA_ELF_TypeIndFunction
.type _foo, STT_GNU_IFUNC
Definition: MCDirectives.h:24
llvm::AArch64::Fixups
Fixups
Definition: AArch64FixupKinds.h:17
llvm::MCSA_Reference
@ MCSA_Reference
.reference (MachO)
Definition: MCDirectives.h:44
llvm::MCELFStreamer::emitBundleLock
void emitBundleLock(bool AlignToEnd) override
The following instructions are a bundle-locked group.
Definition: MCELFStreamer.cpp:648
llvm::MCID::Flag
Flag
These should be considered private to the implementation of the MCInstrDesc class.
Definition: MCInstrDesc.h:147
be
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can be
Definition: README.txt:14
llvm::report_fatal_error
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:145
llvm::MCSymbolRefExpr::getSymbol
const MCSymbol & getSymbol() const
Definition: MCExpr.h:399
llvm::MCSymbolRefExpr::VK_PPC_DTPREL_HIGHERA
@ VK_PPC_DTPREL_HIGHERA
Definition: MCExpr.h:283
llvm::MCSymbolRefExpr::VK_PPC_GOT_DTPREL_HA
@ VK_PPC_GOT_DTPREL_HA
Definition: MCExpr.h:293
llvm::MCELFStreamer::emitWeakReference
void emitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) override
Emit an weak reference from Alias to Symbol.
Definition: MCELFStreamer.cpp:167
llvm::MCSA_Hidden
@ MCSA_Hidden
.hidden (ELF)
Definition: MCDirectives.h:33
llvm::MCSymbolRefExpr::VK_TLSLD
@ VK_TLSLD
Definition: MCExpr.h:210
llvm::SmallVectorImpl::append
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
Definition: SmallVector.h:670
llvm::MCELFStreamer::emitCommonSymbol
void emitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override
Emit a common symbol.
Definition: MCELFStreamer.cpp:308
llvm::MCSA_ELF_TypeGnuUniqueObject
@ MCSA_ELF_TypeGnuUniqueObject
Definition: MCDirectives.h:29
llvm::ELF::SHF_EXCLUDE
@ SHF_EXCLUDE
Definition: ELF.h:1094
llvm::MCELFStreamer::Contents
SmallVector< AttributeItem, 64 > Contents
Definition: MCELFStreamer.h:107
Align
uint64_t Align
Definition: ELFObjHandler.cpp:81
llvm::MCELFStreamer::emitLabelAtPos
void emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, MCFragment *F, uint64_t Offset) override
Definition: MCELFStreamer.cpp:110
llvm::MCExpr::getKind
ExprKind getKind() const
Definition: MCExpr.h:81
llvm::MCObjectStreamer::getCurrentFragment
MCFragment * getCurrentFragment() const
Definition: MCObjectStreamer.cpp:201
llvm::MCSymbolRefExpr::VK_PPC_TPREL_HI
@ VK_PPC_TPREL_HI
Definition: MCExpr.h:269
llvm::MCAssembler::setBundleAlignSize
void setBundleAlignSize(unsigned Size)
Definition: MCAssembler.h:364
llvm::MCStreamer::getCurrentSectionOnly
MCSection * getCurrentSectionOnly() const
Definition: MCStreamer.h:389
llvm::MCObjectFileInfo::getTextSection
MCSection * getTextSection() const
Definition: MCObjectFileInfo.h:268
llvm::MCExpr::Binary
@ Binary
Binary expressions.
Definition: MCExpr.h:38
DF
static RegisterPass< DebugifyFunctionPass > DF("debugify-function", "Attach debug info to a function")
llvm::SmallString< 256 >
llvm::MCSA_Exported
@ MCSA_Exported
.globl _foo, exported (XCOFF)
Definition: MCDirectives.h:34
llvm::MCSymbolRefExpr::VK_PPC_GOT_TPREL_PCREL
@ VK_PPC_GOT_TPREL_PCREL
Definition: MCExpr.h:309
llvm::MCELFStreamer::emitValueToAlignment
void emitValueToAlignment(unsigned, int64_t, unsigned, unsigned) override
Emit some number of copies of Value until the byte alignment ByteAlignment is reached.
Definition: MCELFStreamer.cpp:367
llvm::MCConstantExpr
Definition: MCExpr.h:144
llvm::MCELFStreamer::emitThumbFunc
void emitThumbFunc(MCSymbol *Func) override
Note in the output that the specified Func is a Thumb mode function (ARM target only).
Definition: MCELFStreamer.cpp:718
llvm::MCSymbolRefExpr::VK_PPC_GOT_DTPREL_HI
@ VK_PPC_GOT_DTPREL_HI
Definition: MCExpr.h:292
llvm::MCSA_WeakDefAutoPrivate
@ MCSA_WeakDefAutoPrivate
.weak_def_can_be_hidden (MachO)
Definition: MCDirectives.h:48
llvm::ELF::STT_GNU_IFUNC
@ STT_GNU_IFUNC
Definition: ELF.h:1232
llvm::MCELFStreamer::finishImpl
void finishImpl() override
Streamer specific finalization.
Definition: MCELFStreamer.cpp:700
llvm::MCSection::BundleLockedAlignToEnd
@ BundleLockedAlignToEnd
Definition: MCSection.h:58
llvm::MCELFStreamer::emitELFSymverDirective
void emitELFSymverDirective(const MCSymbol *OriginalSym, StringRef Name, bool KeepOriginalSym) override
Emit an ELF .symver directive.
Definition: MCELFStreamer.cpp:343
llvm::MCSymbolRefExpr::VK_PPC_TLSLD
@ VK_PPC_TLSLD
Definition: MCExpr.h:311
llvm::MCAssembler
Definition: MCAssembler.h:73
llvm::MCAssembler::getEmitter
MCCodeEmitter & getEmitter() const
Definition: MCAssembler.h:331
llvm::AMDGPU::Hwreg::Offset
Offset
Definition: SIDefines.h:416
llvm::MCAF_SubsectionsViaSymbols
@ MCAF_SubsectionsViaSymbols
.subsections_via_symbols (MachO)
Definition: MCDirectives.h:53
llvm::MCELFStreamer::emitLocalCommonSymbol
void emitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment) override
Emit a local common (.lcomm) symbol.
Definition: MCELFStreamer.cpp:350
uint64_t
llvm::MCCompactEncodedInstFragment
This is a compact (memory-size-wise) fragment for holding an encoded instruction (non-relaxable) that...
Definition: MCFragment.h:256
llvm::MCContext::getAsmInfo
const MCAsmInfo * getAsmInfo() const
Definition: MCContext.h:447
llvm::ELF::SHF_STRINGS
@ SHF_STRINGS
Definition: ELF.h:1069
llvm::MCSymbolRefExpr::VK_PPC_TLS_PCREL
@ VK_PPC_TLS_PCREL
Definition: MCExpr.h:310
llvm::MCSA_WeakReference
@ MCSA_WeakReference
.weak_reference (MachO)
Definition: MCDirectives.h:47
LEB128.h
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::MCELFStreamer::emitIdent
void emitIdent(StringRef IdentString) override
Emit the "identifiers" directive.
Definition: MCELFStreamer.cpp:383
llvm::numbers::e
constexpr double e
Definition: MathExtras.h:54
llvm::MCELFStreamer::emitSymbolDesc
void emitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) override
Set the DescValue for the Symbol.
Definition: MCELFStreamer.cpp:722
llvm::MCEncodedFragment::setBundlePadding
void setBundlePadding(uint8_t N)
Set the padding size for this fragment.
Definition: MCFragment.h:168
llvm::MCSymbolRefExpr::VK_TLSDESC
@ VK_TLSDESC
Definition: MCExpr.h:215
llvm::MCAssembler::getBundleAlignSize
unsigned getBundleAlignSize() const
Definition: MCAssembler.h:362
I
#define I(x, y, z)
Definition: MD5.cpp:58
llvm::MCSymbolRefExpr::VK_PPC_GOT_TLSGD
@ VK_PPC_GOT_TLSGD
Definition: MCExpr.h:295
llvm::MCSymbolRefExpr::VK_PPC_GOT_TPREL
@ VK_PPC_GOT_TPREL
Definition: MCExpr.h:286
llvm::MCStreamer::getStartTokLoc
SMLoc getStartTokLoc() const
Definition: MCStreamer.h:285
llvm::ELF::SHF_ALLOC
@ SHF_ALLOC
Definition: ELF.h:1060
llvm::MCSymbolRefExpr::VK_PPC_TPREL_HIGH
@ VK_PPC_TPREL_HIGH
Definition: MCExpr.h:271
llvm::MCObjectStreamer::insert
void insert(MCFragment *F)
Definition: MCObjectStreamer.h:94
llvm::MCStreamer::pushSection
void pushSection()
Save the current and previous section on the section stack.
Definition: MCStreamer.h:411
llvm::ELF::SHT_LLVM_CALL_GRAPH_PROFILE
@ SHT_LLVM_CALL_GRAPH_PROFILE
Definition: ELF.h:1012
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::move
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:1666
llvm::MCSymbolRefExpr::VK_TLSCALL
@ VK_TLSCALL
Definition: MCExpr.h:214
llvm::MCStreamer::emitIntValue
virtual void emitIntValue(uint64_t Value, unsigned Size)
Special case of EmitValue that avoids the client having to pass in a MCExpr for constant integers.
Definition: MCStreamer.cpp:134
llvm::MCContext::reportError
void reportError(SMLoc L, const Twine &Msg)
Definition: MCContext.cpp:1024
llvm::MCAssembler::getRelaxAll
bool getRelaxAll() const
Definition: MCAssembler.h:357
llvm::MCSymbolRefExpr::VK_PPC_TPREL_LO
@ VK_PPC_TPREL_LO
Definition: MCExpr.h:268
llvm::MCSymbolRefExpr::VK_PPC_GOT_DTPREL
@ VK_PPC_GOT_DTPREL
Definition: MCExpr.h:290
llvm::MCSymbolRefExpr
Represent a reference to a symbol from inside an expression.
Definition: MCExpr.h:192
llvm::MCSymbolRefExpr::VK_TPOFF
@ VK_TPOFF
Definition: MCExpr.h:212
MCSection.h
llvm::MCSymbolRefExpr::VK_PPC_DTPREL_LO
@ VK_PPC_DTPREL_LO
Definition: MCExpr.h:277
llvm::MCObjectStreamer::getAssembler
MCAssembler & getAssembler()
Definition: MCObjectStreamer.h:128
llvm::MCELFStreamer::setAttributeItem
void setAttributeItem(unsigned Attribute, unsigned Value, bool OverwriteExisting)
Definition: MCELFStreamer.cpp:737
llvm::MCELFStreamer::emitValueImpl
void emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc=SMLoc()) override
Emit the expression Value into the output as a native integer of the given Size bytes.
Definition: MCELFStreamer.cpp:359
llvm::MCObjectStreamer::getOrCreateDataFragment
MCDataFragment * getOrCreateDataFragment(const MCSubtargetInfo *STI=nullptr)
Get a data fragment to write into, creating a new one if the current fragment is not a data fragment.
Definition: MCObjectStreamer.cpp:225
MCAsmInfo.h
Fixup
PowerPC TLS Dynamic Call Fixup
Definition: PPCTLSDynamicCall.cpp:215
llvm::MCObjectStreamer::changeSectionImpl
bool changeSectionImpl(MCSection *Section, const MCExpr *Subsection)
Definition: MCObjectStreamer.cpp:368
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
llvm::MCAssembler::Symver
Definition: MCAssembler.h:228
llvm::MCELFStreamer::setAttributeItems
void setAttributeItems(unsigned Attribute, unsigned IntValue, StringRef StringValue, bool OverwriteExisting)
Definition: MCELFStreamer.cpp:771
MCFixup.h
llvm::ELF::SHT_GNU_ATTRIBUTES
@ SHT_GNU_ATTRIBUTES
Definition: ELF.h:1018
llvm::MCSection
Instances of this class represent a uniqued identifier for a section in the current translation unit.
Definition: MCSection.h:39
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::MCSymbolRefExpr::VK_PPC_GOT_TLSLD_LO
@ VK_PPC_GOT_TLSLD_LO
Definition: MCExpr.h:303
llvm::MCSA_ELF_TypeTLS
@ MCSA_ELF_TypeTLS
.type _foo, STT_TLS # aka @tls_object
Definition: MCDirectives.h:26
llvm::MCObjectStreamer::emitInstToFragment
virtual void emitInstToFragment(const MCInst &Inst, const MCSubtargetInfo &)
Emit an instruction to a special fragment, because this instruction can change its size during relaxa...
Definition: MCObjectStreamer.cpp:461
llvm::MCELFStreamer::AttributeItem::HiddenAttribute
@ HiddenAttribute
Definition: MCELFStreamer.h:96
llvm::MCSA_IndirectSymbol
@ MCSA_IndirectSymbol
.indirect_symbol (MachO)
Definition: MCDirectives.h:35
CombineSymbolTypes
static unsigned CombineSymbolTypes(unsigned T1, unsigned T2)
Definition: MCELFStreamer.cpp:181
llvm::MCSymbolRefExpr::VK_WEAKREF
@ VK_WEAKREF
Definition: MCExpr.h:225
llvm::MCSymbolRefExpr::VK_PPC_TPREL_HIGHER
@ VK_PPC_TPREL_HIGHER
Definition: MCExpr.h:273
llvm::MCSA_Internal
@ MCSA_Internal
.internal (ELF)
Definition: MCDirectives.h:36
llvm::MCELFStreamer::AttributeItem
ELF object attributes section emission support.
Definition: MCELFStreamer.h:91
llvm::MCSymbolRefExpr::VK_PPC_TPREL_HIGHESTA
@ VK_PPC_TPREL_HIGHESTA
Definition: MCExpr.h:276
llvm::MCAF_Code32
@ MCAF_Code32
.code32 (X86) / .code 32 (ARM)
Definition: MCDirectives.h:55
llvm::MCSA_ELF_TypeCommon
@ MCSA_ELF_TypeCommon
.type _foo, STT_COMMON # aka @common
Definition: MCDirectives.h:27
llvm::MCSection::BundleLocked
@ BundleLocked
Definition: MCSection.h:57
llvm::MCSymbolRefExpr::VK_PPC_GOT_TPREL_LO
@ VK_PPC_GOT_TPREL_LO
Definition: MCExpr.h:287
llvm::createELFStreamer
MCStreamer * createELFStreamer(MCContext &Ctx, std::unique_ptr< MCAsmBackend > &&TAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&CE, bool RelaxAll)
Definition: MCELFStreamer.cpp:887
llvm::StringRef::size
constexpr size_t size() const
size - Get the string size.
Definition: StringRef.h:137
llvm::MCSection::isBundleGroupBeforeFirstInst
bool isBundleGroupBeforeFirstInst() const
Definition: MCSection.h:153
llvm::MCSymbolRefExpr::VK_PPC_GOT_TLSLD_HI
@ VK_PPC_GOT_TLSLD_HI
Definition: MCExpr.h:304
llvm::MCAF_Code64
@ MCAF_Code64
.code64 (X86)
Definition: MCDirectives.h:56
llvm::MCSymbolRefExpr::VK_PPC_GOT_TLSGD_HA
@ VK_PPC_GOT_TLSGD_HA
Definition: MCExpr.h:298
MCObjectWriter.h
llvm::MCSymbolRefExpr::VK_TPREL
@ VK_TPREL
Definition: MCExpr.h:357
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
llvm::MCELFStreamer::emitBundleAlignMode
void emitBundleAlignMode(unsigned AlignPow2) override
Set the bundle alignment mode from now on in the section.
Definition: MCELFStreamer.cpp:638
llvm::MCSymbolRefExpr::VK_PPC_DTPREL_HIGH
@ VK_PPC_DTPREL_HIGH
Definition: MCExpr.h:280
llvm::MCSymbolRefExpr::VK_PPC_TPREL_HIGHERA
@ VK_PPC_TPREL_HIGHERA
Definition: MCExpr.h:274
llvm::MCAF_SyntaxUnified
@ MCAF_SyntaxUnified
.syntax (ARM/ELF)
Definition: MCDirectives.h:52
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:50
std
Definition: BitVector.h:851
llvm::MCSA_SymbolResolver
@ MCSA_SymbolResolver
.symbol_resolver (MachO)
Definition: MCDirectives.h:40
llvm::MCEncodedFragment::getSubtargetInfo
const MCSubtargetInfo * getSubtargetInfo() const
Retrieve the MCSubTargetInfo in effect when the instruction was encoded.
Definition: MCFragment.h:172
Casting.h
llvm::MCELFStreamer::emitSymbolAttribute
bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override
Add the given Attribute to Symbol.
Definition: MCELFStreamer.cpp:193
llvm::ELF::SHF_WRITE
@ SHF_WRITE
Definition: ELF.h:1057
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.h:27
llvm::MCELFStreamer::emitAssemblerFlag
void emitAssemblerFlag(MCAssemblerFlag Flag) override
Note in the output the specified Flag.
Definition: MCELFStreamer.cpp:121
llvm::MCSection::NotBundleLocked
@ NotBundleLocked
Definition: MCSection.h:56
llvm::MCSymbolRefExpr::VK_TLSGD
@ VK_TLSGD
Definition: MCExpr.h:209
llvm::MCSymbolRefExpr::create
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
Definition: MCExpr.h:386
llvm::SmallVectorImpl::clear
void clear()
Definition: SmallVector.h:597
llvm::MCELFStreamer::AttributeItem::NumericAndTextAttributes
@ NumericAndTextAttributes
Definition: MCELFStreamer.h:99
llvm::MCSA_Global
@ MCSA_Global
.type _foo, @gnu_unique_object
Definition: MCDirectives.h:30
llvm::MCSA_WeakDefinition
@ MCSA_WeakDefinition
.weak_definition (MachO)
Definition: MCDirectives.h:46
llvm::LCOMM::ByteAlignment
@ ByteAlignment
Definition: MCAsmInfo.h:50
llvm::MCSymbolRefExpr::VK_PPC_GOT_TPREL_HA
@ VK_PPC_GOT_TPREL_HA
Definition: MCExpr.h:289
llvm::MCSA_ELF_TypeFunction
@ MCSA_ELF_TypeFunction
.type _foo, STT_FUNC # aka @function
Definition: MCDirectives.h:23
llvm::ARMBuildAttrs::Symbol
@ Symbol
Definition: ARMBuildAttributes.h:83
llvm::computeBundlePadding
uint64_t computeBundlePadding(const MCAssembler &Assembler, const MCEncodedFragment *F, uint64_t FOffset, uint64_t FSize)
Compute the amount of padding required before the fragment F to obey bundling restrictions,...
Definition: MCFragment.cpp:213
llvm::MCSA_Weak
@ MCSA_Weak
.weak
Definition: MCDirectives.h:45
llvm::MCEncodedFragment::setAlignToBundleEnd
void setAlignToBundleEnd(bool V)
Definition: MCFragment.h:157
llvm::MCObjectStreamer::emitBytes
void emitBytes(StringRef Data) override
Emit the bytes in Data into the output.
Definition: MCObjectStreamer.cpp:637
llvm::MCObjectStreamer::flushPendingLabels
void flushPendingLabels()
Create a data fragment for any pending labels across all Sections and Subsections.
Definition: MCObjectStreamer.cpp:91
llvm::MCSymbolRefExpr::VK_PPC_DTPREL_HA
@ VK_PPC_DTPREL_HA
Definition: MCExpr.h:279
llvm::MCSymbolRefExpr::VK_PPC_GOT_TLSLD
@ VK_PPC_GOT_TLSLD
Definition: MCExpr.h:302
llvm::ELF::STV_INTERNAL
@ STV_INTERNAL
Definition: ELF.h:1244
llvm::MCStreamer::emitULEB128IntValue
void emitULEB128IntValue(uint64_t Value, unsigned PadTo=0)
Special case of EmitULEB128Value that avoids the client having to pass in a MCExpr for constant integ...
Definition: MCStreamer.cpp:162
llvm::MCStreamer::getContext
MCContext & getContext() const
Definition: MCStreamer.h:293
SmallVector.h
llvm::MCExpr::SymbolRef
@ SymbolRef
References to labels and assigned expressions.
Definition: MCExpr.h:40
llvm::MCExpr::Unary
@ Unary
Unary expressions.
Definition: MCExpr.h:41
llvm::MCELFStreamer::emitELFSize
void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override
Emit an ELF .size directive.
Definition: MCELFStreamer.cpp:339
MCStreamer.h
llvm::MCELFStreamer::emitBundleUnlock
void emitBundleUnlock() override
Ends a bundle-locked group.
Definition: MCELFStreamer.cpp:667
llvm::MCSectionSubPair
std::pair< MCSection *, const MCExpr * > MCSectionSubPair
Definition: MCStreamer.h:66
llvm::MCAsmInfo::getNonexecutableStackSection
virtual MCSection * getNonexecutableStackSection(MCContext &Ctx) const
Targets can implement this method to specify a section to switch to if the translation unit doesn't h...
Definition: MCAsmInfo.h:581
llvm::ELF::STB_WEAK
@ STB_WEAK
Definition: ELF.h:1215
llvm::MCExpr::Constant
@ Constant
Constant expressions.
Definition: MCExpr.h:39
llvm::MCELFStreamer::initSections
void initSections(bool NoExecStack, const MCSubtargetInfo &STI) override
Create the default sections and set the initial one.
Definition: MCELFStreamer.cpp:91
llvm::MCAssembler::setSubsectionsViaSymbols
void setSubsectionsViaSymbols(bool Value)
Definition: MCAssembler.h:348
llvm::ELF::STB_LOCAL
@ STB_LOCAL
Definition: ELF.h:1213
llvm::raw_svector_ostream
A raw_ostream that writes to an SmallVector or SmallString.
Definition: raw_ostream.h:658
llvm::MCSymbolRefExpr::VK_PPC_GOT_TLSLD_HA
@ VK_PPC_GOT_TLSLD_HA
Definition: MCExpr.h:305
llvm::MCSA_PrivateExtern
@ MCSA_PrivateExtern
.private_extern (MachO)
Definition: MCDirectives.h:42
llvm::MCAssembler::writeFragmentPadding
void writeFragmentPadding(raw_ostream &OS, const MCEncodedFragment &F, uint64_t FSize) const
Write the necessary bundle padding to OS.
Definition: MCAssembler.cpp:477
llvm::HexStyle::Asm
@ Asm
0ffh
Definition: MCInstPrinter.h:34
llvm::MCSymbolRefExpr::VK_None
@ VK_None
Definition: MCExpr.h:195
llvm::mc::getRelaxAll
bool getRelaxAll()
From
BlockVerifier::State From
Definition: BlockVerifier.cpp:55
llvm::ELF::SHF_GNU_RETAIN
@ SHF_GNU_RETAIN
Definition: ELF.h:1091
llvm::MCSymbolRefExpr::VK_PPC_DTPREL_HIGHA
@ VK_PPC_DTPREL_HIGHA
Definition: MCExpr.h:281
llvm::MCObjectStreamer::finishImpl
void finishImpl() override
Streamer specific finalization.
Definition: MCObjectStreamer.cpp:919
llvm::MCObjectStreamer::emitFrames
void emitFrames(MCAsmBackend *MAB)
Definition: MCObjectStreamer.cpp:190
llvm::ARMBuildAttrs::File
@ File
Definition: ARMBuildAttributes.h:36
raw_ostream.h
llvm::MCObjectStreamer::emitCodeAlignment
void emitCodeAlignment(unsigned ByteAlignment, const MCSubtargetInfo *STI, unsigned MaxBytesToEmit=0) override
Emit nops until the byte alignment ByteAlignment is reached.
Definition: MCObjectStreamer.cpp:659
llvm::MCDataFragment
Fragment for data and encoded instructions.
Definition: MCFragment.h:241
TargetRegistry.h
llvm::MCAssembler::isBundlingEnabled
bool isBundlingEnabled() const
Definition: MCAssembler.h:360
MCExpr.h
llvm::MCSubtargetInfo
Generic base class for all target subtargets.
Definition: MCSubtargetInfo.h:76
llvm::ELF::STT_OBJECT
@ STT_OBJECT
Definition: ELF.h:1226
CheckBundleSubtargets
static void CheckBundleSubtargets(const MCSubtargetInfo *OldSTI, const MCSubtargetInfo *NewSTI)
Definition: MCELFStreamer.cpp:540
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::MCELFStreamer::AttributeItem::NumericAttribute
@ NumericAttribute
Definition: MCELFStreamer.h:97
llvm::MCExpr
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
llvm::MCSymbolRefExpr::VK_GOTTPOFF
@ VK_GOTTPOFF
Definition: MCExpr.h:204
setSectionAlignmentForBundling
static void setSectionAlignmentForBundling(const MCAssembler &Assembler, MCSection *Section)
Definition: MCELFStreamer.cpp:140
llvm::MCSymbolRefExpr::VK_PPC_DTPMOD
@ VK_PPC_DTPMOD
Definition: MCExpr.h:267
llvm::MCAssembler::CGProfileEntry
Definition: MCAssembler.h:465
llvm::MCEncodedFragmentWithContents::getContents
SmallVectorImpl< char > & getContents()
Definition: MCFragment.h:196
llvm::MCExpr::getLoc
SMLoc getLoc() const
Definition: MCExpr.h:82
llvm::MCContext::reportWarning
void reportWarning(SMLoc L, const Twine &Msg)
Definition: MCContext.cpp:1031
llvm::MCCodeEmitter::encodeInstruction
virtual void encodeInstruction(const MCInst &Inst, raw_ostream &OS, SmallVectorImpl< MCFixup > &Fixups, const MCSubtargetInfo &STI) const =0
EncodeInstruction - Encode the given Inst to bytes on the output stream OS.
llvm::MCSymbolRefExpr::VK_DTPOFF
@ VK_DTPOFF
Definition: MCExpr.h:213
llvm::MCStreamer::emitZeros
void emitZeros(uint64_t NumBytes)
Emit NumBytes worth of zeros.
Definition: MCStreamer.cpp:227
llvm::MCAssembler::getWriter
MCObjectWriter & getWriter() const
Definition: MCAssembler.h:333
llvm::MCAssembler::CGProfile
std::vector< CGProfileEntry > CGProfile
Definition: MCAssembler.h:470