LLVM  14.0.0git
ARMELFStreamer.cpp
Go to the documentation of this file.
1 //===- lib/MC/ARMELFStreamer.cpp - ELF Object Output for ARM --------------===//
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 ARM ELF .o object files. Different
10 // from generic ELF streamer in emitting mapping symbols ($a, $t and $d) to
11 // delimit regions of data and code.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "ARMRegisterInfo.h"
16 #include "ARMUnwindOpAsm.h"
17 #include "llvm/ADT/DenseMap.h"
18 #include "llvm/ADT/SmallString.h"
19 #include "llvm/ADT/SmallVector.h"
20 #include "llvm/ADT/StringRef.h"
21 #include "llvm/ADT/Triple.h"
22 #include "llvm/ADT/Twine.h"
23 #include "llvm/BinaryFormat/ELF.h"
24 #include "llvm/MC/MCAsmBackend.h"
25 #include "llvm/MC/MCAsmInfo.h"
26 #include "llvm/MC/MCAssembler.h"
27 #include "llvm/MC/MCCodeEmitter.h"
28 #include "llvm/MC/MCContext.h"
29 #include "llvm/MC/MCELFStreamer.h"
30 #include "llvm/MC/MCExpr.h"
31 #include "llvm/MC/MCFixup.h"
32 #include "llvm/MC/MCFragment.h"
33 #include "llvm/MC/MCInst.h"
34 #include "llvm/MC/MCInstPrinter.h"
35 #include "llvm/MC/MCObjectWriter.h"
36 #include "llvm/MC/MCRegisterInfo.h"
37 #include "llvm/MC/MCSection.h"
38 #include "llvm/MC/MCSectionELF.h"
39 #include "llvm/MC/MCStreamer.h"
41 #include "llvm/MC/MCSymbol.h"
42 #include "llvm/MC/MCSymbolELF.h"
43 #include "llvm/MC/SectionKind.h"
45 #include "llvm/Support/ARMEHABI.h"
46 #include "llvm/Support/Casting.h"
51 #include <algorithm>
52 #include <cassert>
53 #include <climits>
54 #include <cstddef>
55 #include <cstdint>
56 #include <string>
57 
58 using namespace llvm;
59 
60 static std::string GetAEABIUnwindPersonalityName(unsigned Index) {
62  "Invalid personality index");
63  return (Twine("__aeabi_unwind_cpp_pr") + Twine(Index)).str();
64 }
65 
66 namespace {
67 
68 class ARMELFStreamer;
69 
70 class ARMTargetAsmStreamer : public ARMTargetStreamer {
72  MCInstPrinter &InstPrinter;
73  bool IsVerboseAsm;
74 
75  void emitFnStart() override;
76  void emitFnEnd() override;
77  void emitCantUnwind() override;
78  void emitPersonality(const MCSymbol *Personality) override;
79  void emitPersonalityIndex(unsigned Index) override;
80  void emitHandlerData() override;
81  void emitSetFP(unsigned FpReg, unsigned SpReg, int64_t Offset = 0) override;
82  void emitMovSP(unsigned Reg, int64_t Offset = 0) override;
83  void emitPad(int64_t Offset) override;
84  void emitRegSave(const SmallVectorImpl<unsigned> &RegList,
85  bool isVector) override;
86  void emitUnwindRaw(int64_t Offset,
87  const SmallVectorImpl<uint8_t> &Opcodes) override;
88 
89  void switchVendor(StringRef Vendor) override;
90  void emitAttribute(unsigned Attribute, unsigned Value) override;
91  void emitTextAttribute(unsigned Attribute, StringRef String) override;
92  void emitIntTextAttribute(unsigned Attribute, unsigned IntValue,
93  StringRef StringValue) override;
94  void emitArch(ARM::ArchKind Arch) override;
95  void emitArchExtension(uint64_t ArchExt) override;
96  void emitObjectArch(ARM::ArchKind Arch) override;
97  void emitFPU(unsigned FPU) override;
98  void emitInst(uint32_t Inst, char Suffix = '\0') override;
99  void finishAttributeSection() override;
100 
101  void AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE) override;
102  void emitThumbSet(MCSymbol *Symbol, const MCExpr *Value) override;
103 
104 public:
105  ARMTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS,
106  MCInstPrinter &InstPrinter, bool VerboseAsm);
107 };
108 
109 ARMTargetAsmStreamer::ARMTargetAsmStreamer(MCStreamer &S,
111  MCInstPrinter &InstPrinter,
112  bool VerboseAsm)
113  : ARMTargetStreamer(S), OS(OS), InstPrinter(InstPrinter),
114  IsVerboseAsm(VerboseAsm) {}
115 
116 void ARMTargetAsmStreamer::emitFnStart() { OS << "\t.fnstart\n"; }
117 void ARMTargetAsmStreamer::emitFnEnd() { OS << "\t.fnend\n"; }
118 void ARMTargetAsmStreamer::emitCantUnwind() { OS << "\t.cantunwind\n"; }
119 
120 void ARMTargetAsmStreamer::emitPersonality(const MCSymbol *Personality) {
121  OS << "\t.personality " << Personality->getName() << '\n';
122 }
123 
124 void ARMTargetAsmStreamer::emitPersonalityIndex(unsigned Index) {
125  OS << "\t.personalityindex " << Index << '\n';
126 }
127 
128 void ARMTargetAsmStreamer::emitHandlerData() { OS << "\t.handlerdata\n"; }
129 
130 void ARMTargetAsmStreamer::emitSetFP(unsigned FpReg, unsigned SpReg,
131  int64_t Offset) {
132  OS << "\t.setfp\t";
133  InstPrinter.printRegName(OS, FpReg);
134  OS << ", ";
135  InstPrinter.printRegName(OS, SpReg);
136  if (Offset)
137  OS << ", #" << Offset;
138  OS << '\n';
139 }
140 
141 void ARMTargetAsmStreamer::emitMovSP(unsigned Reg, int64_t Offset) {
142  assert((Reg != ARM::SP && Reg != ARM::PC) &&
143  "the operand of .movsp cannot be either sp or pc");
144 
145  OS << "\t.movsp\t";
146  InstPrinter.printRegName(OS, Reg);
147  if (Offset)
148  OS << ", #" << Offset;
149  OS << '\n';
150 }
151 
152 void ARMTargetAsmStreamer::emitPad(int64_t Offset) {
153  OS << "\t.pad\t#" << Offset << '\n';
154 }
155 
156 void ARMTargetAsmStreamer::emitRegSave(const SmallVectorImpl<unsigned> &RegList,
157  bool isVector) {
158  assert(RegList.size() && "RegList should not be empty");
159  if (isVector)
160  OS << "\t.vsave\t{";
161  else
162  OS << "\t.save\t{";
163 
164  InstPrinter.printRegName(OS, RegList[0]);
165 
166  for (unsigned i = 1, e = RegList.size(); i != e; ++i) {
167  OS << ", ";
168  InstPrinter.printRegName(OS, RegList[i]);
169  }
170 
171  OS << "}\n";
172 }
173 
174 void ARMTargetAsmStreamer::switchVendor(StringRef Vendor) {}
175 
176 void ARMTargetAsmStreamer::emitAttribute(unsigned Attribute, unsigned Value) {
177  OS << "\t.eabi_attribute\t" << Attribute << ", " << Twine(Value);
178  if (IsVerboseAsm) {
181  if (!Name.empty())
182  OS << "\t@ " << Name;
183  }
184  OS << "\n";
185 }
186 
187 void ARMTargetAsmStreamer::emitTextAttribute(unsigned Attribute,
188  StringRef String) {
189  switch (Attribute) {
191  OS << "\t.cpu\t" << String.lower();
192  break;
193  default:
194  OS << "\t.eabi_attribute\t" << Attribute << ", \"" << String << "\"";
195  if (IsVerboseAsm) {
198  if (!Name.empty())
199  OS << "\t@ " << Name;
200  }
201  break;
202  }
203  OS << "\n";
204 }
205 
206 void ARMTargetAsmStreamer::emitIntTextAttribute(unsigned Attribute,
207  unsigned IntValue,
208  StringRef StringValue) {
209  switch (Attribute) {
210  default: llvm_unreachable("unsupported multi-value attribute in asm mode");
212  OS << "\t.eabi_attribute\t" << Attribute << ", " << IntValue;
213  if (!StringValue.empty())
214  OS << ", \"" << StringValue << "\"";
215  if (IsVerboseAsm)
216  OS << "\t@ "
219  break;
220  }
221  OS << "\n";
222 }
223 
224 void ARMTargetAsmStreamer::emitArch(ARM::ArchKind Arch) {
225  OS << "\t.arch\t" << ARM::getArchName(Arch) << "\n";
226 }
227 
228 void ARMTargetAsmStreamer::emitArchExtension(uint64_t ArchExt) {
229  OS << "\t.arch_extension\t" << ARM::getArchExtName(ArchExt) << "\n";
230 }
231 
232 void ARMTargetAsmStreamer::emitObjectArch(ARM::ArchKind Arch) {
233  OS << "\t.object_arch\t" << ARM::getArchName(Arch) << '\n';
234 }
235 
236 void ARMTargetAsmStreamer::emitFPU(unsigned FPU) {
237  OS << "\t.fpu\t" << ARM::getFPUName(FPU) << "\n";
238 }
239 
240 void ARMTargetAsmStreamer::finishAttributeSection() {}
241 
242 void
243 ARMTargetAsmStreamer::AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *S) {
244  OS << "\t.tlsdescseq\t" << S->getSymbol().getName() << "\n";
245 }
246 
247 void ARMTargetAsmStreamer::emitThumbSet(MCSymbol *Symbol, const MCExpr *Value) {
248  const MCAsmInfo *MAI = Streamer.getContext().getAsmInfo();
249 
250  OS << "\t.thumb_set\t";
251  Symbol->print(OS, MAI);
252  OS << ", ";
253  Value->print(OS, MAI);
254  OS << '\n';
255 }
256 
257 void ARMTargetAsmStreamer::emitInst(uint32_t Inst, char Suffix) {
258  OS << "\t.inst";
259  if (Suffix)
260  OS << "." << Suffix;
261  OS << "\t0x" << Twine::utohexstr(Inst) << "\n";
262 }
263 
264 void ARMTargetAsmStreamer::emitUnwindRaw(int64_t Offset,
265  const SmallVectorImpl<uint8_t> &Opcodes) {
266  OS << "\t.unwind_raw " << Offset;
267  for (SmallVectorImpl<uint8_t>::const_iterator OCI = Opcodes.begin(),
268  OCE = Opcodes.end();
269  OCI != OCE; ++OCI)
270  OS << ", 0x" << Twine::utohexstr(*OCI);
271  OS << '\n';
272 }
273 
274 class ARMTargetELFStreamer : public ARMTargetStreamer {
275 private:
276  StringRef CurrentVendor;
277  unsigned FPU = ARM::FK_INVALID;
278  ARM::ArchKind Arch = ARM::ArchKind::INVALID;
279  ARM::ArchKind EmittedArch = ARM::ArchKind::INVALID;
280 
281  MCSection *AttributeSection = nullptr;
282 
283  void emitArchDefaultAttributes();
284  void emitFPUDefaultAttributes();
285 
286  ARMELFStreamer &getStreamer();
287 
288  void emitFnStart() override;
289  void emitFnEnd() override;
290  void emitCantUnwind() override;
291  void emitPersonality(const MCSymbol *Personality) override;
292  void emitPersonalityIndex(unsigned Index) override;
293  void emitHandlerData() override;
294  void emitSetFP(unsigned FpReg, unsigned SpReg, int64_t Offset = 0) override;
295  void emitMovSP(unsigned Reg, int64_t Offset = 0) override;
296  void emitPad(int64_t Offset) override;
297  void emitRegSave(const SmallVectorImpl<unsigned> &RegList,
298  bool isVector) override;
299  void emitUnwindRaw(int64_t Offset,
300  const SmallVectorImpl<uint8_t> &Opcodes) override;
301 
302  void switchVendor(StringRef Vendor) override;
303  void emitAttribute(unsigned Attribute, unsigned Value) override;
304  void emitTextAttribute(unsigned Attribute, StringRef String) override;
305  void emitIntTextAttribute(unsigned Attribute, unsigned IntValue,
306  StringRef StringValue) override;
307  void emitArch(ARM::ArchKind Arch) override;
308  void emitObjectArch(ARM::ArchKind Arch) override;
309  void emitFPU(unsigned FPU) override;
310  void emitInst(uint32_t Inst, char Suffix = '\0') override;
311  void finishAttributeSection() override;
312  void emitLabel(MCSymbol *Symbol) override;
313 
314  void AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE) override;
315  void emitThumbSet(MCSymbol *Symbol, const MCExpr *Value) override;
316 
317  // Reset state between object emissions
318  void reset() override;
319 
320 public:
321  ARMTargetELFStreamer(MCStreamer &S)
322  : ARMTargetStreamer(S), CurrentVendor("aeabi") {}
323 };
324 
325 /// Extend the generic ELFStreamer class so that it can emit mapping symbols at
326 /// the appropriate points in the object files. These symbols are defined in the
327 /// ARM ELF ABI: infocenter.arm.com/help/topic/com.arm.../IHI0044D_aaelf.pdf.
328 ///
329 /// In brief: $a, $t or $d should be emitted at the start of each contiguous
330 /// region of ARM code, Thumb code or data in a section. In practice, this
331 /// emission does not rely on explicit assembler directives but on inherent
332 /// properties of the directives doing the emission (e.g. ".byte" is data, "add
333 /// r0, r0, r0" an instruction).
334 ///
335 /// As a result this system is orthogonal to the DataRegion infrastructure used
336 /// by MachO. Beware!
337 class ARMELFStreamer : public MCELFStreamer {
338 public:
339  friend class ARMTargetELFStreamer;
340 
341  ARMELFStreamer(MCContext &Context, std::unique_ptr<MCAsmBackend> TAB,
342  std::unique_ptr<MCObjectWriter> OW,
343  std::unique_ptr<MCCodeEmitter> Emitter, bool IsThumb,
344  bool IsAndroid)
345  : MCELFStreamer(Context, std::move(TAB), std::move(OW),
346  std::move(Emitter)),
347  IsThumb(IsThumb), IsAndroid(IsAndroid) {
348  EHReset();
349  }
350 
351  ~ARMELFStreamer() override = default;
352 
353  void finishImpl() override;
354 
355  // ARM exception handling directives
356  void emitFnStart();
357  void emitFnEnd();
358  void emitCantUnwind();
359  void emitPersonality(const MCSymbol *Per);
360  void emitPersonalityIndex(unsigned index);
361  void emitHandlerData();
362  void emitSetFP(unsigned NewFpReg, unsigned NewSpReg, int64_t Offset = 0);
363  void emitMovSP(unsigned Reg, int64_t Offset = 0);
364  void emitPad(int64_t Offset);
365  void emitRegSave(const SmallVectorImpl<unsigned> &RegList, bool isVector);
366  void emitUnwindRaw(int64_t Offset, const SmallVectorImpl<uint8_t> &Opcodes);
367  void emitFill(const MCExpr &NumBytes, uint64_t FillValue,
368  SMLoc Loc) override {
369  emitDataMappingSymbol();
370  MCObjectStreamer::emitFill(NumBytes, FillValue, Loc);
371  }
372 
373  void changeSection(MCSection *Section, const MCExpr *Subsection) override {
374  LastMappingSymbols[getCurrentSection().first] = std::move(LastEMSInfo);
376  auto LastMappingSymbol = LastMappingSymbols.find(Section);
377  if (LastMappingSymbol != LastMappingSymbols.end()) {
378  LastEMSInfo = std::move(LastMappingSymbol->second);
379  return;
380  }
381  LastEMSInfo.reset(new ElfMappingSymbolInfo(SMLoc(), nullptr, 0));
382  }
383 
384  /// This function is the one used to emit instruction data into the ELF
385  /// streamer. We override it to add the appropriate mapping symbol if
386  /// necessary.
387  void emitInstruction(const MCInst &Inst,
388  const MCSubtargetInfo &STI) override {
389  if (IsThumb)
390  EmitThumbMappingSymbol();
391  else
392  EmitARMMappingSymbol();
393 
395  }
396 
397  void emitInst(uint32_t Inst, char Suffix) {
398  unsigned Size;
399  char Buffer[4];
400  const bool LittleEndian = getContext().getAsmInfo()->isLittleEndian();
401 
402  switch (Suffix) {
403  case '\0':
404  Size = 4;
405 
406  assert(!IsThumb);
407  EmitARMMappingSymbol();
408  for (unsigned II = 0, IE = Size; II != IE; II++) {
409  const unsigned I = LittleEndian ? (Size - II - 1) : II;
410  Buffer[Size - II - 1] = uint8_t(Inst >> I * CHAR_BIT);
411  }
412 
413  break;
414  case 'n':
415  case 'w':
416  Size = (Suffix == 'n' ? 2 : 4);
417 
418  assert(IsThumb);
419  EmitThumbMappingSymbol();
420  // Thumb wide instructions are emitted as a pair of 16-bit words of the
421  // appropriate endianness.
422  for (unsigned II = 0, IE = Size; II != IE; II = II + 2) {
423  const unsigned I0 = LittleEndian ? II + 0 : II + 1;
424  const unsigned I1 = LittleEndian ? II + 1 : II + 0;
425  Buffer[Size - II - 2] = uint8_t(Inst >> I0 * CHAR_BIT);
426  Buffer[Size - II - 1] = uint8_t(Inst >> I1 * CHAR_BIT);
427  }
428 
429  break;
430  default:
431  llvm_unreachable("Invalid Suffix");
432  }
433 
435  }
436 
437  /// This is one of the functions used to emit data into an ELF section, so the
438  /// ARM streamer overrides it to add the appropriate mapping symbol ($d) if
439  /// necessary.
440  void emitBytes(StringRef Data) override {
441  emitDataMappingSymbol();
443  }
444 
445  void FlushPendingMappingSymbol() {
446  if (!LastEMSInfo->hasInfo())
447  return;
448  ElfMappingSymbolInfo *EMS = LastEMSInfo.get();
449  EmitMappingSymbol("$d", EMS->Loc, EMS->F, EMS->Offset);
450  EMS->resetInfo();
451  }
452 
453  /// This is one of the functions used to emit data into an ELF section, so the
454  /// ARM streamer overrides it to add the appropriate mapping symbol ($d) if
455  /// necessary.
456  void emitValueImpl(const MCExpr *Value, unsigned Size, SMLoc Loc) override {
457  if (const MCSymbolRefExpr *SRE = dyn_cast_or_null<MCSymbolRefExpr>(Value)) {
458  if (SRE->getKind() == MCSymbolRefExpr::VK_ARM_SBREL && !(Size == 4)) {
459  getContext().reportError(Loc, "relocated expression must be 32-bit");
460  return;
461  }
463  }
464 
465  emitDataMappingSymbol();
467  }
468 
469  void emitAssemblerFlag(MCAssemblerFlag Flag) override {
471 
472  switch (Flag) {
473  case MCAF_SyntaxUnified:
474  return; // no-op here.
475  case MCAF_Code16:
476  IsThumb = true;
477  return; // Change to Thumb mode
478  case MCAF_Code32:
479  IsThumb = false;
480  return; // Change to ARM mode
481  case MCAF_Code64:
482  return;
484  return;
485  }
486  }
487 
488  /// If a label is defined before the .type directive sets the label's type
489  /// then the label can't be recorded as thumb function when the label is
490  /// defined. We override emitSymbolAttribute() which is called as part of the
491  /// parsing of .type so that if the symbol has already been defined we can
492  /// record the label as Thumb. FIXME: there is a corner case where the state
493  /// is changed in between the label definition and the .type directive, this
494  /// is not expected to occur in practice and handling it would require the
495  /// backend to track IsThumb for every label.
498 
499  if (!IsThumb)
500  return Val;
501 
502  unsigned Type = cast<MCSymbolELF>(Symbol)->getType();
503  if ((Type == ELF::STT_FUNC || Type == ELF::STT_GNU_IFUNC) &&
504  Symbol->isDefined())
506 
507  return Val;
508  };
509 
510 private:
511  enum ElfMappingSymbol {
512  EMS_None,
513  EMS_ARM,
514  EMS_Thumb,
515  EMS_Data
516  };
517 
518  struct ElfMappingSymbolInfo {
519  explicit ElfMappingSymbolInfo(SMLoc Loc, MCFragment *F, uint64_t O)
520  : Loc(Loc), F(F), Offset(O), State(EMS_None) {}
521  void resetInfo() {
522  F = nullptr;
523  Offset = 0;
524  }
525  bool hasInfo() { return F != nullptr; }
526  SMLoc Loc;
527  MCFragment *F;
529  ElfMappingSymbol State;
530  };
531 
532  void emitDataMappingSymbol() {
533  if (LastEMSInfo->State == EMS_Data)
534  return;
535  else if (LastEMSInfo->State == EMS_None) {
536  // This is a tentative symbol, it won't really be emitted until it's
537  // actually needed.
538  ElfMappingSymbolInfo *EMS = LastEMSInfo.get();
539  auto *DF = dyn_cast_or_null<MCDataFragment>(getCurrentFragment());
540  if (!DF)
541  return;
542  EMS->Loc = SMLoc();
543  EMS->F = getCurrentFragment();
544  EMS->Offset = DF->getContents().size();
545  LastEMSInfo->State = EMS_Data;
546  return;
547  }
548  EmitMappingSymbol("$d");
549  LastEMSInfo->State = EMS_Data;
550  }
551 
552  void EmitThumbMappingSymbol() {
553  if (LastEMSInfo->State == EMS_Thumb)
554  return;
555  FlushPendingMappingSymbol();
556  EmitMappingSymbol("$t");
557  LastEMSInfo->State = EMS_Thumb;
558  }
559 
560  void EmitARMMappingSymbol() {
561  if (LastEMSInfo->State == EMS_ARM)
562  return;
563  FlushPendingMappingSymbol();
564  EmitMappingSymbol("$a");
565  LastEMSInfo->State = EMS_ARM;
566  }
567 
568  void EmitMappingSymbol(StringRef Name) {
569  auto *Symbol = cast<MCSymbolELF>(getContext().getOrCreateSymbol(
570  Name + "." + Twine(MappingSymbolCounter++)));
571  emitLabel(Symbol);
572 
573  Symbol->setType(ELF::STT_NOTYPE);
574  Symbol->setBinding(ELF::STB_LOCAL);
575  }
576 
577  void EmitMappingSymbol(StringRef Name, SMLoc Loc, MCFragment *F,
578  uint64_t Offset) {
579  auto *Symbol = cast<MCSymbolELF>(getContext().getOrCreateSymbol(
580  Name + "." + Twine(MappingSymbolCounter++)));
581  emitLabelAtPos(Symbol, Loc, F, Offset);
582  Symbol->setType(ELF::STT_NOTYPE);
583  Symbol->setBinding(ELF::STB_LOCAL);
584  }
585 
586  void emitThumbFunc(MCSymbol *Func) override {
589  }
590 
591  // Helper functions for ARM exception handling directives
592  void EHReset();
593 
594  // Reset state between object emissions
595  void reset() override;
596 
597  void EmitPersonalityFixup(StringRef Name);
598  void FlushPendingOffset();
599  void FlushUnwindOpcodes(bool NoHandlerData);
600 
601  void SwitchToEHSection(StringRef Prefix, unsigned Type, unsigned Flags,
602  SectionKind Kind, const MCSymbol &Fn);
603  void SwitchToExTabSection(const MCSymbol &FnStart);
604  void SwitchToExIdxSection(const MCSymbol &FnStart);
605 
606  void EmitFixup(const MCExpr *Expr, MCFixupKind Kind);
607 
608  bool IsThumb;
609  bool IsAndroid;
610  int64_t MappingSymbolCounter = 0;
611 
613  LastMappingSymbols;
614 
615  std::unique_ptr<ElfMappingSymbolInfo> LastEMSInfo;
616 
617  // ARM Exception Handling Frame Information
618  MCSymbol *ExTab;
619  MCSymbol *FnStart;
620  const MCSymbol *Personality;
621  unsigned PersonalityIndex;
622  unsigned FPReg; // Frame pointer register
623  int64_t FPOffset; // Offset: (final frame pointer) - (initial $sp)
624  int64_t SPOffset; // Offset: (final $sp) - (initial $sp)
625  int64_t PendingOffset; // Offset: (final $sp) - (emitted $sp)
626  bool UsedFP;
627  bool CantUnwind;
628  SmallVector<uint8_t, 64> Opcodes;
629  UnwindOpcodeAssembler UnwindOpAsm;
630 };
631 
632 } // end anonymous namespace
633 
634 ARMELFStreamer &ARMTargetELFStreamer::getStreamer() {
635  return static_cast<ARMELFStreamer &>(Streamer);
636 }
637 
638 void ARMTargetELFStreamer::emitFnStart() { getStreamer().emitFnStart(); }
639 void ARMTargetELFStreamer::emitFnEnd() { getStreamer().emitFnEnd(); }
640 void ARMTargetELFStreamer::emitCantUnwind() { getStreamer().emitCantUnwind(); }
641 
642 void ARMTargetELFStreamer::emitPersonality(const MCSymbol *Personality) {
643  getStreamer().emitPersonality(Personality);
644 }
645 
646 void ARMTargetELFStreamer::emitPersonalityIndex(unsigned Index) {
647  getStreamer().emitPersonalityIndex(Index);
648 }
649 
650 void ARMTargetELFStreamer::emitHandlerData() {
651  getStreamer().emitHandlerData();
652 }
653 
654 void ARMTargetELFStreamer::emitSetFP(unsigned FpReg, unsigned SpReg,
655  int64_t Offset) {
656  getStreamer().emitSetFP(FpReg, SpReg, Offset);
657 }
658 
659 void ARMTargetELFStreamer::emitMovSP(unsigned Reg, int64_t Offset) {
660  getStreamer().emitMovSP(Reg, Offset);
661 }
662 
663 void ARMTargetELFStreamer::emitPad(int64_t Offset) {
664  getStreamer().emitPad(Offset);
665 }
666 
667 void ARMTargetELFStreamer::emitRegSave(const SmallVectorImpl<unsigned> &RegList,
668  bool isVector) {
669  getStreamer().emitRegSave(RegList, isVector);
670 }
671 
672 void ARMTargetELFStreamer::emitUnwindRaw(int64_t Offset,
673  const SmallVectorImpl<uint8_t> &Opcodes) {
674  getStreamer().emitUnwindRaw(Offset, Opcodes);
675 }
676 
677 void ARMTargetELFStreamer::switchVendor(StringRef Vendor) {
678  assert(!Vendor.empty() && "Vendor cannot be empty.");
679 
680  if (CurrentVendor == Vendor)
681  return;
682 
683  if (!CurrentVendor.empty())
684  finishAttributeSection();
685 
686  assert(getStreamer().Contents.empty() &&
687  ".ARM.attributes should be flushed before changing vendor");
688  CurrentVendor = Vendor;
689 
690 }
691 
692 void ARMTargetELFStreamer::emitAttribute(unsigned Attribute, unsigned Value) {
693  getStreamer().setAttributeItem(Attribute, Value,
694  /* OverwriteExisting= */ true);
695 }
696 
697 void ARMTargetELFStreamer::emitTextAttribute(unsigned Attribute,
698  StringRef Value) {
699  getStreamer().setAttributeItem(Attribute, Value,
700  /* OverwriteExisting= */ true);
701 }
702 
703 void ARMTargetELFStreamer::emitIntTextAttribute(unsigned Attribute,
704  unsigned IntValue,
705  StringRef StringValue) {
706  getStreamer().setAttributeItems(Attribute, IntValue, StringValue,
707  /* OverwriteExisting= */ true);
708 }
709 
710 void ARMTargetELFStreamer::emitArch(ARM::ArchKind Value) {
711  Arch = Value;
712 }
713 
714 void ARMTargetELFStreamer::emitObjectArch(ARM::ArchKind Value) {
715  EmittedArch = Value;
716 }
717 
718 void ARMTargetELFStreamer::emitArchDefaultAttributes() {
719  using namespace ARMBuildAttrs;
720  ARMELFStreamer &S = getStreamer();
721 
722  S.setAttributeItem(CPU_name, ARM::getCPUAttr(Arch), false);
723 
724  if (EmittedArch == ARM::ArchKind::INVALID)
725  S.setAttributeItem(CPU_arch, ARM::getArchAttr(Arch), false);
726  else
727  S.setAttributeItem(CPU_arch, ARM::getArchAttr(EmittedArch), false);
728 
729  switch (Arch) {
730  case ARM::ArchKind::ARMV2:
731  case ARM::ArchKind::ARMV2A:
732  case ARM::ArchKind::ARMV3:
733  case ARM::ArchKind::ARMV3M:
734  case ARM::ArchKind::ARMV4:
735  S.setAttributeItem(ARM_ISA_use, Allowed, false);
736  break;
737 
738  case ARM::ArchKind::ARMV4T:
739  case ARM::ArchKind::ARMV5T:
740  case ARM::ArchKind::XSCALE:
741  case ARM::ArchKind::ARMV5TE:
742  case ARM::ArchKind::ARMV6:
743  S.setAttributeItem(ARM_ISA_use, Allowed, false);
744  S.setAttributeItem(THUMB_ISA_use, Allowed, false);
745  break;
746 
747  case ARM::ArchKind::ARMV6T2:
748  S.setAttributeItem(ARM_ISA_use, Allowed, false);
749  S.setAttributeItem(THUMB_ISA_use, AllowThumb32, false);
750  break;
751 
752  case ARM::ArchKind::ARMV6K:
753  case ARM::ArchKind::ARMV6KZ:
754  S.setAttributeItem(ARM_ISA_use, Allowed, false);
755  S.setAttributeItem(THUMB_ISA_use, Allowed, false);
756  S.setAttributeItem(Virtualization_use, AllowTZ, false);
757  break;
758 
759  case ARM::ArchKind::ARMV6M:
760  S.setAttributeItem(THUMB_ISA_use, Allowed, false);
761  break;
762 
763  case ARM::ArchKind::ARMV7A:
764  S.setAttributeItem(CPU_arch_profile, ApplicationProfile, false);
765  S.setAttributeItem(ARM_ISA_use, Allowed, false);
766  S.setAttributeItem(THUMB_ISA_use, AllowThumb32, false);
767  break;
768 
769  case ARM::ArchKind::ARMV7R:
770  S.setAttributeItem(CPU_arch_profile, RealTimeProfile, false);
771  S.setAttributeItem(ARM_ISA_use, Allowed, false);
772  S.setAttributeItem(THUMB_ISA_use, AllowThumb32, false);
773  break;
774 
775  case ARM::ArchKind::ARMV7EM:
776  case ARM::ArchKind::ARMV7M:
777  S.setAttributeItem(CPU_arch_profile, MicroControllerProfile, false);
778  S.setAttributeItem(THUMB_ISA_use, AllowThumb32, false);
779  break;
780 
781  case ARM::ArchKind::ARMV8A:
782  case ARM::ArchKind::ARMV8_1A:
783  case ARM::ArchKind::ARMV8_2A:
784  case ARM::ArchKind::ARMV8_3A:
785  case ARM::ArchKind::ARMV8_4A:
786  case ARM::ArchKind::ARMV8_5A:
787  case ARM::ArchKind::ARMV8_6A:
788  case ARM::ArchKind::ARMV9A:
789  case ARM::ArchKind::ARMV9_1A:
790  case ARM::ArchKind::ARMV9_2A:
791  S.setAttributeItem(CPU_arch_profile, ApplicationProfile, false);
792  S.setAttributeItem(ARM_ISA_use, Allowed, false);
793  S.setAttributeItem(THUMB_ISA_use, AllowThumb32, false);
794  S.setAttributeItem(MPextension_use, Allowed, false);
795  S.setAttributeItem(Virtualization_use, AllowTZVirtualization, false);
796  break;
797 
798  case ARM::ArchKind::ARMV8MBaseline:
799  case ARM::ArchKind::ARMV8MMainline:
800  S.setAttributeItem(THUMB_ISA_use, AllowThumbDerived, false);
801  S.setAttributeItem(CPU_arch_profile, MicroControllerProfile, false);
802  break;
803 
804  case ARM::ArchKind::IWMMXT:
805  S.setAttributeItem(ARM_ISA_use, Allowed, false);
806  S.setAttributeItem(THUMB_ISA_use, Allowed, false);
807  S.setAttributeItem(WMMX_arch, AllowWMMXv1, false);
808  break;
809 
810  case ARM::ArchKind::IWMMXT2:
811  S.setAttributeItem(ARM_ISA_use, Allowed, false);
812  S.setAttributeItem(THUMB_ISA_use, Allowed, false);
813  S.setAttributeItem(WMMX_arch, AllowWMMXv2, false);
814  break;
815 
816  default:
817  report_fatal_error("Unknown Arch: " + Twine(ARM::getArchName(Arch)));
818  break;
819  }
820 }
821 
822 void ARMTargetELFStreamer::emitFPU(unsigned Value) {
823  FPU = Value;
824 }
825 
826 void ARMTargetELFStreamer::emitFPUDefaultAttributes() {
827  ARMELFStreamer &S = getStreamer();
828 
829  switch (FPU) {
830  case ARM::FK_VFP:
831  case ARM::FK_VFPV2:
833  /* OverwriteExisting= */ false);
834  break;
835 
836  case ARM::FK_VFPV3:
838  /* OverwriteExisting= */ false);
839  break;
840 
841  case ARM::FK_VFPV3_FP16:
843  /* OverwriteExisting= */ false);
845  /* OverwriteExisting= */ false);
846  break;
847 
848  case ARM::FK_VFPV3_D16:
850  /* OverwriteExisting= */ false);
851  break;
852 
853  case ARM::FK_VFPV3_D16_FP16:
855  /* OverwriteExisting= */ false);
857  /* OverwriteExisting= */ false);
858  break;
859 
860  case ARM::FK_VFPV3XD:
862  /* OverwriteExisting= */ false);
863  break;
864  case ARM::FK_VFPV3XD_FP16:
866  /* OverwriteExisting= */ false);
868  /* OverwriteExisting= */ false);
869  break;
870 
871  case ARM::FK_VFPV4:
873  /* OverwriteExisting= */ false);
874  break;
875 
876  // ABI_HardFP_use is handled in ARMAsmPrinter, so _SP_D16 is treated the same
877  // as _D16 here.
878  case ARM::FK_FPV4_SP_D16:
879  case ARM::FK_VFPV4_D16:
881  /* OverwriteExisting= */ false);
882  break;
883 
884  case ARM::FK_FP_ARMV8:
886  /* OverwriteExisting= */ false);
887  break;
888 
889  // FPV5_D16 is identical to FP_ARMV8 except for the number of D registers, so
890  // uses the FP_ARMV8_D16 build attribute.
891  case ARM::FK_FPV5_SP_D16:
892  case ARM::FK_FPV5_D16:
894  /* OverwriteExisting= */ false);
895  break;
896 
897  case ARM::FK_NEON:
899  /* OverwriteExisting= */ false);
900  S.setAttributeItem(ARMBuildAttrs::Advanced_SIMD_arch,
902  /* OverwriteExisting= */ false);
903  break;
904 
905  case ARM::FK_NEON_FP16:
907  /* OverwriteExisting= */ false);
908  S.setAttributeItem(ARMBuildAttrs::Advanced_SIMD_arch,
910  /* OverwriteExisting= */ false);
912  /* OverwriteExisting= */ false);
913  break;
914 
915  case ARM::FK_NEON_VFPV4:
917  /* OverwriteExisting= */ false);
918  S.setAttributeItem(ARMBuildAttrs::Advanced_SIMD_arch,
920  /* OverwriteExisting= */ false);
921  break;
922 
923  case ARM::FK_NEON_FP_ARMV8:
924  case ARM::FK_CRYPTO_NEON_FP_ARMV8:
926  /* OverwriteExisting= */ false);
927  // 'Advanced_SIMD_arch' must be emitted not here, but within
928  // ARMAsmPrinter::emitAttributes(), depending on hasV8Ops() and hasV8_1a()
929  break;
930 
931  case ARM::FK_SOFTVFP:
932  case ARM::FK_NONE:
933  break;
934 
935  default:
936  report_fatal_error("Unknown FPU: " + Twine(FPU));
937  break;
938  }
939 }
940 
941 void ARMTargetELFStreamer::finishAttributeSection() {
942  ARMELFStreamer &S = getStreamer();
943 
944  if (FPU != ARM::FK_INVALID)
945  emitFPUDefaultAttributes();
946 
947  if (Arch != ARM::ArchKind::INVALID)
948  emitArchDefaultAttributes();
949 
950  if (S.Contents.empty())
951  return;
952 
953  auto LessTag = [](const MCELFStreamer::AttributeItem &LHS,
954  const MCELFStreamer::AttributeItem &RHS) -> bool {
955  // The conformance tag must be emitted first when serialised into an
956  // object file. Specifically, the addenda to the ARM ABI states that
957  // (2.3.7.4):
958  //
959  // "To simplify recognition by consumers in the common case of claiming
960  // conformity for the whole file, this tag should be emitted first in a
961  // file-scope sub-subsection of the first public subsection of the
962  // attributes section."
963  //
964  // So it is special-cased in this comparison predicate when the
965  // attributes are sorted in finishAttributeSection().
966  return (RHS.Tag != ARMBuildAttrs::conformance) &&
967  ((LHS.Tag == ARMBuildAttrs::conformance) || (LHS.Tag < RHS.Tag));
968  };
969  llvm::sort(S.Contents, LessTag);
970 
971  S.emitAttributesSection(CurrentVendor, ".ARM.attributes",
972  ELF::SHT_ARM_ATTRIBUTES, AttributeSection);
973 
974  FPU = ARM::FK_INVALID;
975 }
976 
977 void ARMTargetELFStreamer::emitLabel(MCSymbol *Symbol) {
978  ARMELFStreamer &Streamer = getStreamer();
979  if (!Streamer.IsThumb)
980  return;
981 
982  Streamer.getAssembler().registerSymbol(*Symbol);
983  unsigned Type = cast<MCSymbolELF>(Symbol)->getType();
985  Streamer.emitThumbFunc(Symbol);
986 }
987 
988 void
989 ARMTargetELFStreamer::AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *S) {
990  getStreamer().EmitFixup(S, FK_Data_4);
991 }
992 
993 void ARMTargetELFStreamer::emitThumbSet(MCSymbol *Symbol, const MCExpr *Value) {
994  if (const MCSymbolRefExpr *SRE = dyn_cast<MCSymbolRefExpr>(Value)) {
995  const MCSymbol &Sym = SRE->getSymbol();
996  if (!Sym.isDefined()) {
997  getStreamer().emitAssignment(Symbol, Value);
998  return;
999  }
1000  }
1001 
1002  getStreamer().emitThumbFunc(Symbol);
1003  getStreamer().emitAssignment(Symbol, Value);
1004 }
1005 
1006 void ARMTargetELFStreamer::emitInst(uint32_t Inst, char Suffix) {
1007  getStreamer().emitInst(Inst, Suffix);
1008 }
1009 
1010 void ARMTargetELFStreamer::reset() { AttributeSection = nullptr; }
1011 
1012 void ARMELFStreamer::finishImpl() {
1013  MCTargetStreamer &TS = *getTargetStreamer();
1014  ARMTargetStreamer &ATS = static_cast<ARMTargetStreamer &>(TS);
1015  ATS.finishAttributeSection();
1016 
1017  MCELFStreamer::finishImpl();
1018 }
1019 
1020 void ARMELFStreamer::reset() {
1021  MCTargetStreamer &TS = *getTargetStreamer();
1022  ARMTargetStreamer &ATS = static_cast<ARMTargetStreamer &>(TS);
1023  ATS.reset();
1024  MappingSymbolCounter = 0;
1025  MCELFStreamer::reset();
1026  LastMappingSymbols.clear();
1027  LastEMSInfo.reset();
1028  // MCELFStreamer clear's the assembler's e_flags. However, for
1029  // arm we manually set the ABI version on streamer creation, so
1030  // do the same here
1031  getAssembler().setELFHeaderEFlags(ELF::EF_ARM_EABI_VER5);
1032 }
1033 
1034 inline void ARMELFStreamer::SwitchToEHSection(StringRef Prefix,
1035  unsigned Type,
1036  unsigned Flags,
1037  SectionKind Kind,
1038  const MCSymbol &Fn) {
1039  const MCSectionELF &FnSection =
1040  static_cast<const MCSectionELF &>(Fn.getSection());
1041 
1042  // Create the name for new section
1043  StringRef FnSecName(FnSection.getName());
1044  SmallString<128> EHSecName(Prefix);
1045  if (FnSecName != ".text") {
1046  EHSecName += FnSecName;
1047  }
1048 
1049  // Get .ARM.extab or .ARM.exidx section
1050  const MCSymbolELF *Group = FnSection.getGroup();
1051  if (Group)
1052  Flags |= ELF::SHF_GROUP;
1053  MCSectionELF *EHSection = getContext().getELFSection(
1054  EHSecName, Type, Flags, 0, Group, /*IsComdat=*/true,
1055  FnSection.getUniqueID(),
1056  static_cast<const MCSymbolELF *>(FnSection.getBeginSymbol()));
1057 
1058  assert(EHSection && "Failed to get the required EH section");
1059 
1060  // Switch to .ARM.extab or .ARM.exidx section
1061  SwitchSection(EHSection);
1062  emitValueToAlignment(4, 0, 1, 0);
1063 }
1064 
1065 inline void ARMELFStreamer::SwitchToExTabSection(const MCSymbol &FnStart) {
1066  SwitchToEHSection(".ARM.extab", ELF::SHT_PROGBITS, ELF::SHF_ALLOC,
1067  SectionKind::getData(), FnStart);
1068 }
1069 
1070 inline void ARMELFStreamer::SwitchToExIdxSection(const MCSymbol &FnStart) {
1071  SwitchToEHSection(".ARM.exidx", ELF::SHT_ARM_EXIDX,
1073  SectionKind::getData(), FnStart);
1074 }
1075 
1076 void ARMELFStreamer::EmitFixup(const MCExpr *Expr, MCFixupKind Kind) {
1077  MCDataFragment *Frag = getOrCreateDataFragment();
1078  Frag->getFixups().push_back(MCFixup::create(Frag->getContents().size(), Expr,
1079  Kind));
1080 }
1081 
1082 void ARMELFStreamer::EHReset() {
1083  ExTab = nullptr;
1084  FnStart = nullptr;
1085  Personality = nullptr;
1086  PersonalityIndex = ARM::EHABI::NUM_PERSONALITY_INDEX;
1087  FPReg = ARM::SP;
1088  FPOffset = 0;
1089  SPOffset = 0;
1090  PendingOffset = 0;
1091  UsedFP = false;
1092  CantUnwind = false;
1093 
1094  Opcodes.clear();
1095  UnwindOpAsm.Reset();
1096 }
1097 
1098 void ARMELFStreamer::emitFnStart() {
1099  assert(FnStart == nullptr);
1100  FnStart = getContext().createTempSymbol();
1101  emitLabel(FnStart);
1102 }
1103 
1104 void ARMELFStreamer::emitFnEnd() {
1105  assert(FnStart && ".fnstart must precedes .fnend");
1106 
1107  // Emit unwind opcodes if there is no .handlerdata directive
1108  if (!ExTab && !CantUnwind)
1109  FlushUnwindOpcodes(true);
1110 
1111  // Emit the exception index table entry
1112  SwitchToExIdxSection(*FnStart);
1113 
1114  // The EHABI requires a dependency preserving R_ARM_NONE relocation to the
1115  // personality routine to protect it from an arbitrary platform's static
1116  // linker garbage collection. We disable this for Android where the unwinder
1117  // is either dynamically linked or directly references the personality
1118  // routine.
1119  if (PersonalityIndex < ARM::EHABI::NUM_PERSONALITY_INDEX && !IsAndroid)
1120  EmitPersonalityFixup(GetAEABIUnwindPersonalityName(PersonalityIndex));
1121 
1122  const MCSymbolRefExpr *FnStartRef =
1123  MCSymbolRefExpr::create(FnStart,
1124  MCSymbolRefExpr::VK_ARM_PREL31,
1125  getContext());
1126 
1127  emitValue(FnStartRef, 4);
1128 
1129  if (CantUnwind) {
1130  emitInt32(ARM::EHABI::EXIDX_CANTUNWIND);
1131  } else if (ExTab) {
1132  // Emit a reference to the unwind opcodes in the ".ARM.extab" section.
1133  const MCSymbolRefExpr *ExTabEntryRef =
1134  MCSymbolRefExpr::create(ExTab,
1135  MCSymbolRefExpr::VK_ARM_PREL31,
1136  getContext());
1137  emitValue(ExTabEntryRef, 4);
1138  } else {
1139  // For the __aeabi_unwind_cpp_pr0, we have to emit the unwind opcodes in
1140  // the second word of exception index table entry. The size of the unwind
1141  // opcodes should always be 4 bytes.
1142  assert(PersonalityIndex == ARM::EHABI::AEABI_UNWIND_CPP_PR0 &&
1143  "Compact model must use __aeabi_unwind_cpp_pr0 as personality");
1144  assert(Opcodes.size() == 4u &&
1145  "Unwind opcode size for __aeabi_unwind_cpp_pr0 must be equal to 4");
1146  uint64_t Intval = Opcodes[0] |
1147  Opcodes[1] << 8 |
1148  Opcodes[2] << 16 |
1149  Opcodes[3] << 24;
1150  emitIntValue(Intval, Opcodes.size());
1151  }
1152 
1153  // Switch to the section containing FnStart
1154  SwitchSection(&FnStart->getSection());
1155 
1156  // Clean exception handling frame information
1157  EHReset();
1158 }
1159 
1160 void ARMELFStreamer::emitCantUnwind() { CantUnwind = true; }
1161 
1162 // Add the R_ARM_NONE fixup at the same position
1163 void ARMELFStreamer::EmitPersonalityFixup(StringRef Name) {
1164  const MCSymbol *PersonalitySym = getContext().getOrCreateSymbol(Name);
1165 
1166  const MCSymbolRefExpr *PersonalityRef = MCSymbolRefExpr::create(
1167  PersonalitySym, MCSymbolRefExpr::VK_ARM_NONE, getContext());
1168 
1169  visitUsedExpr(*PersonalityRef);
1170  MCDataFragment *DF = getOrCreateDataFragment();
1171  DF->getFixups().push_back(MCFixup::create(DF->getContents().size(),
1172  PersonalityRef,
1173  MCFixup::getKindForSize(4, false)));
1174 }
1175 
1176 void ARMELFStreamer::FlushPendingOffset() {
1177  if (PendingOffset != 0) {
1178  UnwindOpAsm.EmitSPOffset(-PendingOffset);
1179  PendingOffset = 0;
1180  }
1181 }
1182 
1183 void ARMELFStreamer::FlushUnwindOpcodes(bool NoHandlerData) {
1184  // Emit the unwind opcode to restore $sp.
1185  if (UsedFP) {
1186  const MCRegisterInfo *MRI = getContext().getRegisterInfo();
1187  int64_t LastRegSaveSPOffset = SPOffset - PendingOffset;
1188  UnwindOpAsm.EmitSPOffset(LastRegSaveSPOffset - FPOffset);
1189  UnwindOpAsm.EmitSetSP(MRI->getEncodingValue(FPReg));
1190  } else {
1191  FlushPendingOffset();
1192  }
1193 
1194  // Finalize the unwind opcode sequence
1195  UnwindOpAsm.Finalize(PersonalityIndex, Opcodes);
1196 
1197  // For compact model 0, we have to emit the unwind opcodes in the .ARM.exidx
1198  // section. Thus, we don't have to create an entry in the .ARM.extab
1199  // section.
1200  if (NoHandlerData && PersonalityIndex == ARM::EHABI::AEABI_UNWIND_CPP_PR0)
1201  return;
1202 
1203  // Switch to .ARM.extab section.
1204  SwitchToExTabSection(*FnStart);
1205 
1206  // Create .ARM.extab label for offset in .ARM.exidx
1207  assert(!ExTab);
1208  ExTab = getContext().createTempSymbol();
1209  emitLabel(ExTab);
1210 
1211  // Emit personality
1212  if (Personality) {
1213  const MCSymbolRefExpr *PersonalityRef =
1214  MCSymbolRefExpr::create(Personality,
1215  MCSymbolRefExpr::VK_ARM_PREL31,
1216  getContext());
1217 
1218  emitValue(PersonalityRef, 4);
1219  }
1220 
1221  // Emit unwind opcodes
1222  assert((Opcodes.size() % 4) == 0 &&
1223  "Unwind opcode size for __aeabi_cpp_unwind_pr0 must be multiple of 4");
1224  for (unsigned I = 0; I != Opcodes.size(); I += 4) {
1225  uint64_t Intval = Opcodes[I] |
1226  Opcodes[I + 1] << 8 |
1227  Opcodes[I + 2] << 16 |
1228  Opcodes[I + 3] << 24;
1229  emitInt32(Intval);
1230  }
1231 
1232  // According to ARM EHABI section 9.2, if the __aeabi_unwind_cpp_pr1() or
1233  // __aeabi_unwind_cpp_pr2() is used, then the handler data must be emitted
1234  // after the unwind opcodes. The handler data consists of several 32-bit
1235  // words, and should be terminated by zero.
1236  //
1237  // In case that the .handlerdata directive is not specified by the
1238  // programmer, we should emit zero to terminate the handler data.
1239  if (NoHandlerData && !Personality)
1240  emitInt32(0);
1241 }
1242 
1243 void ARMELFStreamer::emitHandlerData() { FlushUnwindOpcodes(false); }
1244 
1245 void ARMELFStreamer::emitPersonality(const MCSymbol *Per) {
1246  Personality = Per;
1247  UnwindOpAsm.setPersonality(Per);
1248 }
1249 
1250 void ARMELFStreamer::emitPersonalityIndex(unsigned Index) {
1251  assert(Index < ARM::EHABI::NUM_PERSONALITY_INDEX && "invalid index");
1252  PersonalityIndex = Index;
1253 }
1254 
1255 void ARMELFStreamer::emitSetFP(unsigned NewFPReg, unsigned NewSPReg,
1256  int64_t Offset) {
1257  assert((NewSPReg == ARM::SP || NewSPReg == FPReg) &&
1258  "the operand of .setfp directive should be either $sp or $fp");
1259 
1260  UsedFP = true;
1261  FPReg = NewFPReg;
1262 
1263  if (NewSPReg == ARM::SP)
1264  FPOffset = SPOffset + Offset;
1265  else
1266  FPOffset += Offset;
1267 }
1268 
1269 void ARMELFStreamer::emitMovSP(unsigned Reg, int64_t Offset) {
1270  assert((Reg != ARM::SP && Reg != ARM::PC) &&
1271  "the operand of .movsp cannot be either sp or pc");
1272  assert(FPReg == ARM::SP && "current FP must be SP");
1273 
1274  FlushPendingOffset();
1275 
1276  FPReg = Reg;
1277  FPOffset = SPOffset + Offset;
1278 
1279  const MCRegisterInfo *MRI = getContext().getRegisterInfo();
1280  UnwindOpAsm.EmitSetSP(MRI->getEncodingValue(FPReg));
1281 }
1282 
1283 void ARMELFStreamer::emitPad(int64_t Offset) {
1284  // Track the change of the $sp offset
1285  SPOffset -= Offset;
1286 
1287  // To squash multiple .pad directives, we should delay the unwind opcode
1288  // until the .save, .vsave, .handlerdata, or .fnend directives.
1289  PendingOffset -= Offset;
1290 }
1291 
1292 void ARMELFStreamer::emitRegSave(const SmallVectorImpl<unsigned> &RegList,
1293  bool IsVector) {
1294  // Collect the registers in the register list
1295  unsigned Count = 0;
1296  uint32_t Mask = 0;
1297  const MCRegisterInfo *MRI = getContext().getRegisterInfo();
1298  for (size_t i = 0; i < RegList.size(); ++i) {
1299  unsigned Reg = MRI->getEncodingValue(RegList[i]);
1300  assert(Reg < (IsVector ? 32U : 16U) && "Register out of range");
1301  unsigned Bit = (1u << Reg);
1302  if ((Mask & Bit) == 0) {
1303  Mask |= Bit;
1304  ++Count;
1305  }
1306  }
1307 
1308  // Track the change the $sp offset: For the .save directive, the
1309  // corresponding push instruction will decrease the $sp by (4 * Count).
1310  // For the .vsave directive, the corresponding vpush instruction will
1311  // decrease $sp by (8 * Count).
1312  SPOffset -= Count * (IsVector ? 8 : 4);
1313 
1314  // Emit the opcode
1315  FlushPendingOffset();
1316  if (IsVector)
1317  UnwindOpAsm.EmitVFPRegSave(Mask);
1318  else
1319  UnwindOpAsm.EmitRegSave(Mask);
1320 }
1321 
1322 void ARMELFStreamer::emitUnwindRaw(int64_t Offset,
1323  const SmallVectorImpl<uint8_t> &Opcodes) {
1324  FlushPendingOffset();
1325  SPOffset = SPOffset - Offset;
1326  UnwindOpAsm.EmitRaw(Opcodes);
1327 }
1328 
1329 namespace llvm {
1330 
1333  MCInstPrinter *InstPrint,
1334  bool isVerboseAsm) {
1335  return new ARMTargetAsmStreamer(S, OS, *InstPrint, isVerboseAsm);
1336 }
1337 
1339  return new ARMTargetStreamer(S);
1340 }
1341 
1343  const MCSubtargetInfo &STI) {
1344  const Triple &TT = STI.getTargetTriple();
1345  if (TT.isOSBinFormatELF())
1346  return new ARMTargetELFStreamer(S);
1347  return new ARMTargetStreamer(S);
1348 }
1349 
1351  std::unique_ptr<MCAsmBackend> TAB,
1352  std::unique_ptr<MCObjectWriter> OW,
1353  std::unique_ptr<MCCodeEmitter> Emitter,
1354  bool RelaxAll, bool IsThumb,
1355  bool IsAndroid) {
1356  ARMELFStreamer *S =
1357  new ARMELFStreamer(Context, std::move(TAB), std::move(OW),
1358  std::move(Emitter), IsThumb, IsAndroid);
1359  // FIXME: This should eventually end up somewhere else where more
1360  // intelligent flag decisions can be made. For now we are just maintaining
1361  // the status quo for ARM and setting EF_ARM_EABI_VER5 as the default.
1362  S->getAssembler().setELFHeaderEFlags(ELF::EF_ARM_EABI_VER5);
1363 
1364  if (RelaxAll)
1365  S->getAssembler().setRelaxAll(true);
1366  return S;
1367 }
1368 
1369 } // end namespace llvm
llvm::Check::Size
@ Size
Definition: FileCheck.h:73
llvm::ELF::SHF_GROUP
@ SHF_GROUP
Definition: ELF.h:1016
llvm::MCTargetStreamer::getStreamer
MCStreamer & getStreamer()
Definition: MCStreamer.h:99
i
i
Definition: README.txt:29
llvm::ARMTargetStreamer::emitCantUnwind
virtual void emitCantUnwind()
Definition: ARMTargetStreamer.cpp:92
llvm::ELF::EF_ARM_EABI_VER5
@ EF_ARM_EABI_VER5
Definition: ELF.h:442
llvm::MCSectionELF::getUniqueID
unsigned getUniqueID() const
Definition: MCSectionELF.h:89
llvm::ARMBuildAttrs::ARM_ISA_use
@ ARM_ISA_use
Definition: ARMBuildAttributes.h:41
llvm::ARMBuildAttrs::AllowThumbDerived
@ AllowThumbDerived
Definition: ARMBuildAttributes.h:127
ARMEHABI.h
llvm::ARMBuildAttrs::WMMX_arch
@ WMMX_arch
Definition: ARMBuildAttributes.h:44
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
Reg
unsigned Reg
Definition: MachineSink.cpp:1566
llvm::MCTargetStreamer::emitLabel
virtual void emitLabel(MCSymbol *Symbol)
Definition: MCStreamer.cpp:52
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
llvm::StringRef::empty
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:153
llvm::ARMTargetStreamer::emitFnEnd
virtual void emitFnEnd()
Definition: ARMTargetStreamer.cpp:91
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::ARMBuildAttrs::Advanced_SIMD_arch
@ Advanced_SIMD_arch
Definition: ARMBuildAttributes.h:45
llvm::cl::Prefix
@ Prefix
Definition: CommandLine.h:164
llvm::MCContext
Context object for machine code objects.
Definition: MCContext.h:72
llvm::Attribute
Definition: Attributes.h:52
llvm::ARMTargetStreamer
Definition: MCStreamer.h:133
StringRef.h
llvm::UnwindOpcodeAssembler
Definition: ARMUnwindOpAsm.h:25
llvm::ARMTargetStreamer::emitPersonality
virtual void emitPersonality(const MCSymbol *Personality)
Definition: ARMTargetStreamer.cpp:93
MCCodeEmitter.h
llvm::MCAsmInfo
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
llvm::createARMObjectTargetStreamer
MCTargetStreamer * createARMObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
Definition: ARMELFStreamer.cpp:1342
MCSectionELF.h
llvm::MCSection::getBeginSymbol
MCSymbol * getBeginSymbol()
Definition: MCSection.h:127
llvm::ARMBuildAttrs::ApplicationProfile
@ ApplicationProfile
Definition: ARMBuildAttributes.h:112
llvm::SmallVector
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1168
llvm::ARMBuildAttrs::CPU_arch_profile
@ CPU_arch_profile
Definition: ARMBuildAttributes.h:40
llvm::createARMNullTargetStreamer
MCTargetStreamer * createARMNullTargetStreamer(MCStreamer &S)
Definition: ARMELFStreamer.cpp:1338
llvm::MCELFStreamer::changeSection
void changeSection(MCSection *Section, const MCExpr *Subsection) override
Update streamer for a new active section.
Definition: MCELFStreamer.cpp:147
llvm::ARMBuildAttrs::AllowTZVirtualization
@ AllowTZVirtualization
Definition: ARMBuildAttributes.h:240
ErrorHandling.h
MCFragment.h
llvm::ARMBuildAttrs::AllowFPv3A
@ AllowFPv3A
Definition: ARMBuildAttributes.h:131
llvm::ARMBuildAttrs::AllowFPv3B
@ AllowFPv3B
Definition: ARMBuildAttributes.h:132
llvm::MCAssembler::setIsThumbFunc
void setIsThumbFunc(const MCSymbol *Func)
Flag a function symbol as the target of a .thumb_func directive.
Definition: MCAssembler.h:259
llvm::ARMBuildAttrs::AllowNeon2
@ AllowNeon2
Definition: ARMBuildAttributes.h:145
llvm::MCSectionELF::getGroup
const MCSymbolELF * getGroup() const
Definition: MCSectionELF.h:78
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
MCAssembler.h
llvm::AArch64::getCPUAttr
StringRef getCPUAttr(ArchKind AK)
Definition: AArch64TargetParser.cpp:155
llvm::ARMBuildAttrs::MPextension_use
@ MPextension_use
Definition: ARMBuildAttributes.h:69
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
DenseMap.h
llvm::MCSymbol::isDefined
bool isDefined() const
isDefined - Check if this symbol is defined (i.e., it has an address).
Definition: MCSymbol.h:243
Offset
uint64_t Offset
Definition: ELFObjHandler.cpp:81
llvm::AArch64::getArchExtName
StringRef getArchExtName(unsigned ArchExtKind)
Definition: AArch64TargetParser.cpp:167
llvm::MCStreamer::getCurrentSection
MCSectionSubPair getCurrentSection() const
Return the current section that the streamer is emitting code to.
Definition: MCStreamer.h:371
llvm::MCInst
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
llvm::ARMBuildAttrs::AllowFPARMv8A
@ AllowFPARMv8A
Definition: ARMBuildAttributes.h:135
llvm::MCEncodedFragmentWithFixups::getFixups
SmallVectorImpl< MCFixup > & getFixups()
Definition: MCFragment.h:223
llvm::AArch64::getArchAttr
unsigned getArchAttr(ArchKind AK)
Definition: AArch64TargetParser.cpp:163
llvm::MCSectionELF
This represents a section on linux, lots of unix variants and some bare metal systems.
Definition: MCSectionELF.h:28
TargetParser.h
llvm::MCAssemblerFlag
MCAssemblerFlag
Definition: MCDirectives.h:50
llvm::ARMTargetStreamer::reset
virtual void reset()
Reset any state between object emissions, i.e.
Definition: ARMTargetStreamer.cpp:51
llvm::MCELFStreamer::reset
void reset() override
state management
Definition: MCELFStreamer.h:33
llvm::BitmaskEnumDetail::Mask
std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
Definition: BitmaskEnum.h:80
llvm::Data
@ Data
Definition: SIMachineScheduler.h:55
llvm::ARMTargetStreamer::emitPad
virtual void emitPad(int64_t Offset)
Definition: ARMTargetStreamer.cpp:99
MCELFStreamer.h
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::MCSymbolAttr
MCSymbolAttr
Definition: MCDirectives.h:18
llvm::ARM::EHABI::EXIDX_CANTUNWIND
@ EXIDX_CANTUNWIND
Special entry for the function never unwind.
Definition: ARMEHABI.h:35
llvm::ARMBuildAttrs::conformance
@ conformance
Definition: ARMBuildAttributes.h:74
llvm::MCSymbolELF
Definition: MCSymbolELF.h:14
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::ARMBuildAttrs::Section
@ Section
Legacy Tags.
Definition: ARMBuildAttributes.h:78
llvm::MCFragment
Definition: MCFragment.h:31
FormattedStream.h
llvm::MCStreamer
Streaming machine code generation interface.
Definition: MCStreamer.h:199
llvm::FK_Data_4
@ FK_Data_4
A four-byte fixup.
Definition: MCFixup.h:25
llvm::ARMTargetStreamer::emitRegSave
virtual void emitRegSave(const SmallVectorImpl< unsigned > &RegList, bool isVector)
Definition: ARMTargetStreamer.cpp:100
llvm::ARMBuildAttrs::compatibility
@ compatibility
Definition: ARMBuildAttributes.h:65
ELF.h
llvm::MCELFStreamer
Definition: MCELFStreamer.h:24
llvm::MCSymbol::getSection
MCSection & getSection() const
Get the section associated with a defined, non-absolute symbol.
Definition: MCSymbol.h:262
llvm::ARMTargetStreamer::AnnotateTLSDescriptorSequence
virtual void AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *SRE)
Definition: ARMTargetStreamer.cpp:118
MCAsmBackend.h
llvm::SMLoc
Represents a location in source code.
Definition: SMLoc.h:23
ARMUnwindOpAsm.h
llvm::ARMTargetStreamer::emitInst
virtual void emitInst(uint32_t Inst, char Suffix='\0')
Definition: ARMTargetStreamer.cpp:53
SmallString.h
llvm::ARMBuildAttrs::AllowFPv2
@ AllowFPv2
Definition: ARMBuildAttributes.h:130
Twine.h
llvm::MCSubtargetInfo::getTargetTriple
const Triple & getTargetTriple() const
Definition: MCSubtargetInfo.h:107
MCSymbolELF.h
MCContext.h
llvm::MCObjectStreamer::emitInstruction
void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) override
Emit the given Instruction into the current section.
Definition: MCObjectStreamer.cpp:362
MCSymbol.h
llvm::ARMBuildAttrs::FP_arch
@ FP_arch
Definition: ARMBuildAttributes.h:43
llvm::MCAF_Code16
@ MCAF_Code16
.code16 (X86) / .code 16 (ARM)
Definition: MCDirectives.h:53
llvm::ARMTargetStreamer::emitArch
virtual void emitArch(ARM::ArchKind Arch)
Definition: ARMTargetStreamer.cpp:112
MCInst.h
MCSubtargetInfo.h
llvm::MCID::Flag
Flag
These should be considered private to the implementation of the MCInstrDesc class.
Definition: MCInstrDesc.h:146
llvm::ARMBuildAttrs::RealTimeProfile
@ RealTimeProfile
Definition: ARMBuildAttributes.h:113
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:140
llvm::MCTargetStreamer
Target specific streamer interface.
Definition: MCStreamer.h:91
llvm::MCSymbol::getName
StringRef getName() const
getName - Get the symbol name.
Definition: MCSymbol.h:198
llvm::MCELFStreamer::emitLabelAtPos
void emitLabelAtPos(MCSymbol *Symbol, SMLoc Loc, MCFragment *F, uint64_t Offset) override
Definition: MCELFStreamer.cpp:110
llvm::MCObjectStreamer::getCurrentFragment
MCFragment * getCurrentFragment() const
Definition: MCObjectStreamer.cpp:179
llvm::lltok::Kind
Kind
Definition: LLToken.h:18
MCInstPrinter.h
DF
static RegisterPass< DebugifyFunctionPass > DF("debugify-function", "Attach debug info to a function")
llvm::SmallString< 128 >
llvm::ELF::STT_FUNC
@ STT_FUNC
Definition: ELF.h:1158
llvm::ELF::STB_LOCAL
@ STB_LOCAL
Definition: ELF.h:1144
llvm::ARM_PROC::IE
@ IE
Definition: ARMBaseInfo.h:27
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:719
llvm::ARMTargetStreamer::emitSetFP
virtual void emitSetFP(unsigned FpReg, unsigned SpReg, int64_t Offset=0)
Definition: ARMTargetStreamer.cpp:96
llvm::MCELFStreamer::finishImpl
void finishImpl() override
Streamer specific finalization.
Definition: MCELFStreamer.cpp:701
llvm::ARMBuildAttrs::getARMAttributeTags
const TagNameMap & getARMAttributeTags()
Definition: ARMBuildAttrs.cpp:67
llvm::RISCVFenceField::O
@ O
Definition: RISCVBaseInfo.h:197
llvm::ARMBuildAttrs::THUMB_ISA_use
@ THUMB_ISA_use
Definition: ARMBuildAttributes.h:42
llvm::ARMTargetStreamer::emitObjectArch
virtual void emitObjectArch(ARM::ArchKind Arch)
Definition: ARMTargetStreamer.cpp:114
llvm::ARMBuildAttrs::AllowFPARMv8B
@ AllowFPARMv8B
Definition: ARMBuildAttributes.h:136
llvm::MCAF_SubsectionsViaSymbols
@ MCAF_SubsectionsViaSymbols
.subsections_via_symbols (MachO)
Definition: MCDirectives.h:52
Index
uint32_t Index
Definition: ELFObjHandler.cpp:84
index
splat index
Definition: README_ALTIVEC.txt:181
uint64_t
llvm::ELF::SHT_ARM_ATTRIBUTES
@ SHT_ARM_ATTRIBUTES
Definition: ELF.h:967
llvm::MCContext::getAsmInfo
const MCAsmInfo * getAsmInfo() const
Definition: MCContext.h:423
llvm::MCInstPrinter
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:43
llvm::ELF::SHT_PROGBITS
@ SHT_PROGBITS
Definition: ELF.h:916
llvm::createARMTargetAsmStreamer
MCTargetStreamer * createARMTargetAsmStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint, bool isVerboseAsm)
Definition: ARMELFStreamer.cpp:1331
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::ELF::SHF_ALLOC
@ SHF_ALLOC
Definition: ELF.h:994
llvm::numbers::e
constexpr double e
Definition: MathExtras.h:57
llvm::DenseMap
Definition: DenseMap.h:714
llvm::ARMTargetStreamer::emitHandlerData
virtual void emitHandlerData()
Definition: ARMTargetStreamer.cpp:95
llvm::ELF::SHT_ARM_EXIDX
@ SHT_ARM_EXIDX
Definition: ELF.h:963
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::AArch64::getArchName
StringRef getArchName(ArchKind AK)
Definition: AArch64TargetParser.cpp:151
MCRegisterInfo.h
llvm::Value::print
void print(raw_ostream &O, bool IsForDebug=false) const
Implement operator<< on Value.
Definition: AsmWriter.cpp:4593
llvm::formatted_raw_ostream
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
Definition: FormattedStream.h:30
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::ARMBuildAttrs::MicroControllerProfile
@ MicroControllerProfile
Definition: ARMBuildAttributes.h:114
llvm::MCContext::reportError
void reportError(SMLoc L, const Twine &Msg)
Definition: MCContext.cpp:963
llvm::ARMTargetStreamer::switchVendor
virtual void switchVendor(StringRef Vendor)
Definition: ARMTargetStreamer.cpp:105
llvm::ARM::EHABI::AEABI_UNWIND_CPP_PR0
@ AEABI_UNWIND_CPP_PR0
Definition: ARMEHABI.h:123
llvm::ARMTargetStreamer::emitThumbSet
virtual void emitThumbSet(MCSymbol *Symbol, const MCExpr *Value)
Definition: ARMTargetStreamer.cpp:119
llvm::ARMTargetStreamer::emitIntTextAttribute
virtual void emitIntTextAttribute(unsigned Attribute, unsigned IntValue, StringRef StringValue="")
Definition: ARMTargetStreamer.cpp:109
llvm::MCSymbolRefExpr
Represent a reference to a symbol from inside an expression.
Definition: MCExpr.h:192
MCSection.h
llvm::FK_NONE
@ FK_NONE
A no-op fixup.
Definition: MCFixup.h:22
Triple.h
llvm::createARMELFStreamer
MCELFStreamer * createARMELFStreamer(MCContext &Context, std::unique_ptr< MCAsmBackend > TAB, std::unique_ptr< MCObjectWriter > OW, std::unique_ptr< MCCodeEmitter > Emitter, bool RelaxAll, bool IsThumb, bool IsAndroid)
Definition: ARMELFStreamer.cpp:1350
llvm::ARMBuildAttrs::AllowThumb32
@ AllowThumb32
Definition: ARMBuildAttributes.h:126
llvm::MCObjectStreamer::getAssembler
MCAssembler & getAssembler()
Definition: MCObjectStreamer.h:112
llvm::ARMBuildAttrs::AllowWMMXv1
@ AllowWMMXv1
Definition: ARMBuildAttributes.h:140
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:357
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:203
MCAsmInfo.h
llvm::ARMTargetStreamer::emitPersonalityIndex
virtual void emitPersonalityIndex(unsigned Index)
Definition: ARMTargetStreamer.cpp:94
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::ARMBuildAttrs::AllowTZ
@ AllowTZ
Definition: ARMBuildAttributes.h:238
GetAEABIUnwindPersonalityName
static std::string GetAEABIUnwindPersonalityName(unsigned Index)
Definition: ARMELFStreamer.cpp:60
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:134
uint32_t
MCFixup.h
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::MCRegisterInfo
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Definition: MCRegisterInfo.h:135
MRI
unsigned const MachineRegisterInfo * MRI
Definition: AArch64AdvSIMDScalarPass.cpp:105
llvm::MCObjectStreamer::emitFill
void emitFill(const MCExpr &NumBytes, uint64_t FillValue, SMLoc Loc=SMLoc()) override
Emit Size bytes worth of the value specified by FillValue.
Definition: MCObjectStreamer.cpp:799
llvm::MCELFStreamer::AttributeItem
ELF object attributes section emission support.
Definition: MCELFStreamer.h:84
llvm::MCSection::getName
StringRef getName() const
Definition: MCSection.h:122
llvm::MCAF_Code32
@ MCAF_Code32
.code32 (X86) / .code 32 (ARM)
Definition: MCDirectives.h:54
llvm::MCAF_Code64
@ MCAF_Code64
.code64 (X86)
Definition: MCDirectives.h:55
MCObjectWriter.h
llvm::Twine
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:83
ARMRegisterInfo.h
llvm::MCAF_SyntaxUnified
@ MCAF_SyntaxUnified
.syntax (ARM/ELF)
Definition: MCDirectives.h:51
llvm::ARMBuildAttrs::Virtualization_use
@ Virtualization_use
Definition: ARMBuildAttributes.h:75
llvm::SectionKind
SectionKind - This is a simple POD value that classifies the properties of a section.
Definition: SectionKind.h:22
llvm::ARMTargetStreamer::emitTextAttribute
virtual void emitTextAttribute(unsigned Attribute, StringRef String)
Definition: ARMTargetStreamer.cpp:107
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::ARM::ArchKind
ArchKind
Definition: ARMTargetParser.h:104
std
Definition: BitVector.h:838
llvm::ARMTargetStreamer::emitUnwindRaw
virtual void emitUnwindRaw(int64_t StackOffset, const SmallVectorImpl< uint8_t > &Opcodes)
Definition: ARMTargetStreamer.cpp:102
llvm::ARMTargetStreamer::emitMovSP
virtual void emitMovSP(unsigned Reg, int64_t Offset=0)
Definition: ARMTargetStreamer.cpp:98
Casting.h
llvm::MCELFStreamer::emitSymbolAttribute
bool emitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) override
Add the given Attribute to Symbol.
Definition: MCELFStreamer.cpp:193
llvm::sort
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1492
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::RISCV::FK_INVALID
@ FK_INVALID
Definition: TargetParser.h:158
llvm::ARMBuildAttrs::AllowFPv4B
@ AllowFPv4B
Definition: ARMBuildAttributes.h:134
llvm::ARMTargetStreamer::emitAttribute
virtual void emitAttribute(unsigned Attribute, unsigned Value)
Definition: ARMTargetStreamer.cpp:106
llvm::MCAsmInfo::isLittleEndian
bool isLittleEndian() const
True if the target is little endian.
Definition: MCAsmInfo.h:545
llvm::ARMBuildAttrs::CPU_arch
@ CPU_arch
Definition: ARMBuildAttributes.h:39
llvm::ARMBuildAttrs::Allowed
@ Allowed
Definition: ARMBuildAttributes.h:121
llvm::SmallVectorImpl::clear
void clear()
Definition: SmallVector.h:585
SectionKind.h
ARMBuildAttributes.h
llvm::MCSA_ELF_TypeFunction
@ MCSA_ELF_TypeFunction
.type _foo, STT_FUNC # aka @function
Definition: MCDirectives.h:23
llvm::ARMBuildAttrs::Symbol
@ Symbol
Definition: ARMBuildAttributes.h:79
llvm::ARMTargetStreamer::emitFnStart
virtual void emitFnStart()
Definition: ARMTargetStreamer.cpp:90
llvm::ARM::getFPUName
StringRef getFPUName(unsigned FPUKind)
Definition: ARMTargetParser.cpp:361
llvm::ARMBuildAttrs::AllowHPFP
@ AllowHPFP
Definition: ARMBuildAttributes.h:218
llvm::MCFixupKind
MCFixupKind
Extensible enumeration to represent the type of a fixup.
Definition: MCFixup.h:21
llvm::MCObjectStreamer::emitBytes
void emitBytes(StringRef Data) override
Emit the bytes in Data into the output.
Definition: MCObjectStreamer.cpp:590
llvm::LegalityPredicates::isVector
LegalityPredicate isVector(unsigned TypeIdx)
True iff the specified type index is a vector.
Definition: LegalityPredicates.cpp:73
llvm::MCStreamer::getContext
MCContext & getContext() const
Definition: MCStreamer.h:280
SmallVector.h
MCStreamer.h
llvm::ARMBuildAttrs::FP_HP_extension
@ FP_HP_extension
Definition: ARMBuildAttributes.h:67
llvm::MCELFStreamer::AttributeItem::Tag
unsigned Tag
Definition: MCELFStreamer.h:94
llvm::tgtok::Bit
@ Bit
Definition: TGLexer.h:50
llvm::ARMBuildAttrs::AllowNeon
@ AllowNeon
Definition: ARMBuildAttributes.h:144
llvm::SmallVectorImpl< unsigned >
llvm::ARMBuildAttrs::CPU_name
@ CPU_name
Definition: ARMBuildAttributes.h:38
llvm::ELF::SHF_LINK_ORDER
@ SHF_LINK_ORDER
Definition: ELF.h:1009
llvm::ELF::STT_GNU_IFUNC
@ STT_GNU_IFUNC
Definition: ELF.h:1163
llvm::ARMTargetStreamer::finishAttributeSection
virtual void finishAttributeSection()
Definition: ARMTargetStreamer.cpp:116
llvm::pdb::String
@ String
Definition: PDBTypes.h:407
raw_ostream.h
llvm::ELF::STT_NOTYPE
@ STT_NOTYPE
Definition: ELF.h:1156
llvm::ARM::EHABI::NUM_PERSONALITY_INDEX
@ NUM_PERSONALITY_INDEX
Definition: ARMEHABI.h:127
llvm::MCDataFragment
Fragment for data and encoded instructions.
Definition: MCFragment.h:242
MCExpr.h
llvm::MCSubtargetInfo
Generic base class for all target subtargets.
Definition: MCSubtargetInfo.h:75
llvm::ARMTargetStreamer::emitFPU
virtual void emitFPU(unsigned FPU)
Definition: ARMTargetStreamer.cpp:115
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::MCExpr
Base class for the full range of assembler expressions which are needed for parsing.
Definition: MCExpr.h:35
llvm::ARMBuildAttrs::AllowWMMXv2
@ AllowWMMXv2
Definition: ARMBuildAttributes.h:141
llvm::MCEncodedFragmentWithContents::getContents
SmallVectorImpl< char > & getContents()
Definition: MCFragment.h:197
llvm::ELFAttrs::attrTypeAsString
StringRef attrTypeAsString(unsigned attr, TagNameMap tagNameMap, bool hasTagPrefix=true)
Definition: ELFAttributes.cpp:14
llvm::ARMBuildAttrs::AllowFPv4A
@ AllowFPv4A
Definition: ARMBuildAttributes.h:133