LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MCAssembler.h
Go to the documentation of this file.
1 //===- MCAssembler.h - Object File Generation -------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_MC_MCASSEMBLER_H
11 #define LLVM_MC_MCASSEMBLER_H
12 
13 #include "llvm/ADT/DenseMap.h"
14 #include "llvm/ADT/SmallPtrSet.h"
15 #include "llvm/ADT/SmallString.h"
16 #include "llvm/ADT/ilist.h"
17 #include "llvm/ADT/ilist_node.h"
18 #include "llvm/MC/MCFixup.h"
19 #include "llvm/MC/MCInst.h"
20 #include "llvm/Support/Casting.h"
21 #include "llvm/Support/DataTypes.h"
22 #include <algorithm>
23 #include <vector> // FIXME: Shouldn't be needed.
24 
25 namespace llvm {
26 class raw_ostream;
27 class MCAsmLayout;
28 class MCAssembler;
29 class MCContext;
30 class MCCodeEmitter;
31 class MCExpr;
32 class MCFragment;
33 class MCObjectWriter;
34 class MCSection;
35 class MCSectionData;
36 class MCSymbol;
37 class MCSymbolData;
38 class MCValue;
39 class MCAsmBackend;
40 
41 class MCFragment : public ilist_node<MCFragment> {
42  friend class MCAsmLayout;
43 
45  void operator=(const MCFragment&) LLVM_DELETED_FUNCTION;
46 
47 public:
48  enum FragmentType {
58  };
59 
60 private:
62 
63  /// Parent - The data for the section this fragment is in.
64  MCSectionData *Parent;
65 
66  /// Atom - The atom this fragment is in, as represented by it's defining
67  /// symbol. Atom's are only used by backends which set
68  /// \see MCAsmBackend::hasReliableSymbolDifference().
69  MCSymbolData *Atom;
70 
71  /// @name Assembler Backend Data
72  /// @{
73  //
74  // FIXME: This could all be kept private to the assembler implementation.
75 
76  /// Offset - The offset of this fragment in its section. This is ~0 until
77  /// initialized.
78  uint64_t Offset;
79 
80  /// LayoutOrder - The layout order of this fragment.
81  unsigned LayoutOrder;
82 
83  /// @}
84 
85 protected:
86  MCFragment(FragmentType _Kind, MCSectionData *_Parent = 0);
87 
88 public:
89  // Only for sentinel.
90  MCFragment();
91  virtual ~MCFragment();
92 
93  FragmentType getKind() const { return Kind; }
94 
95  MCSectionData *getParent() const { return Parent; }
96  void setParent(MCSectionData *Value) { Parent = Value; }
97 
98  MCSymbolData *getAtom() const { return Atom; }
99  void setAtom(MCSymbolData *Value) { Atom = Value; }
100 
101  unsigned getLayoutOrder() const { return LayoutOrder; }
102  void setLayoutOrder(unsigned Value) { LayoutOrder = Value; }
103 
104  /// \brief Does this fragment have instructions emitted into it? By default
105  /// this is false, but specific fragment types may set it to true.
106  virtual bool hasInstructions() const { return false; }
107 
108  /// \brief Should this fragment be placed at the end of an aligned bundle?
109  virtual bool alignToBundleEnd() const { return false; }
110  virtual void setAlignToBundleEnd(bool V) { }
111 
112  /// \brief Get the padding size that must be inserted before this fragment.
113  /// Used for bundling. By default, no padding is inserted.
114  /// Note that padding size is restricted to 8 bits. This is an optimization
115  /// to reduce the amount of space used for each fragment. In practice, larger
116  /// padding should never be required.
117  virtual uint8_t getBundlePadding() const {
118  return 0;
119  }
120 
121  /// \brief Set the padding size for this fragment. By default it's a no-op,
122  /// and only some fragments have a meaningful implementation.
123  virtual void setBundlePadding(uint8_t N) {
124  }
125 
126  void dump();
127 };
128 
129 /// Interface implemented by fragments that contain encoded instructions and/or
130 /// data.
131 ///
133  virtual void anchor();
134 
135  uint8_t BundlePadding;
136 public:
138  : MCFragment(FType, SD), BundlePadding(0)
139  {
140  }
141  virtual ~MCEncodedFragment();
142 
143  virtual SmallVectorImpl<char> &getContents() = 0;
144  virtual const SmallVectorImpl<char> &getContents() const = 0;
145 
146  virtual uint8_t getBundlePadding() const {
147  return BundlePadding;
148  }
149 
150  virtual void setBundlePadding(uint8_t N) {
151  BundlePadding = N;
152  }
153 
154  static bool classof(const MCFragment *F) {
155  MCFragment::FragmentType Kind = F->getKind();
156  switch (Kind) {
157  default:
158  return false;
161  case MCFragment::FT_Data:
162  return true;
163  }
164  }
165 };
166 
167 /// Interface implemented by fragments that contain encoded instructions and/or
168 /// data and also have fixups registered.
169 ///
171  virtual void anchor();
172 
173 public:
175  MCSectionData *SD = 0)
176  : MCEncodedFragment(FType, SD)
177  {
178  }
179 
181 
184 
185  virtual SmallVectorImpl<MCFixup> &getFixups() = 0;
186  virtual const SmallVectorImpl<MCFixup> &getFixups() const = 0;
187 
188  virtual fixup_iterator fixup_begin() = 0;
189  virtual const_fixup_iterator fixup_begin() const = 0;
190  virtual fixup_iterator fixup_end() = 0;
191  virtual const_fixup_iterator fixup_end() const = 0;
192 
193  static bool classof(const MCFragment *F) {
194  MCFragment::FragmentType Kind = F->getKind();
195  return Kind == MCFragment::FT_Relaxable || Kind == MCFragment::FT_Data;
196  }
197 };
198 
199 /// Fragment for data and encoded instructions.
200 ///
202  virtual void anchor();
203 
204  /// \brief Does this fragment contain encoded instructions anywhere in it?
205  bool HasInstructions;
206 
207  /// \brief Should this fragment be aligned to the end of a bundle?
208  bool AlignToBundleEnd;
209 
210  SmallVector<char, 32> Contents;
211 
212  /// Fixups - The list of fixups in this fragment.
214 public:
217  HasInstructions(false), AlignToBundleEnd(false)
218  {
219  }
220 
221  virtual SmallVectorImpl<char> &getContents() { return Contents; }
222  virtual const SmallVectorImpl<char> &getContents() const { return Contents; }
223 
225  return Fixups;
226  }
227 
229  return Fixups;
230  }
231 
232  virtual bool hasInstructions() const { return HasInstructions; }
233  virtual void setHasInstructions(bool V) { HasInstructions = V; }
234 
235  virtual bool alignToBundleEnd() const { return AlignToBundleEnd; }
236  virtual void setAlignToBundleEnd(bool V) { AlignToBundleEnd = V; }
237 
238  fixup_iterator fixup_begin() { return Fixups.begin(); }
239  const_fixup_iterator fixup_begin() const { return Fixups.begin(); }
240 
241  fixup_iterator fixup_end() {return Fixups.end();}
242  const_fixup_iterator fixup_end() const {return Fixups.end();}
243 
244  static bool classof(const MCFragment *F) {
245  return F->getKind() == MCFragment::FT_Data;
246  }
247 };
248 
249 /// This is a compact (memory-size-wise) fragment for holding an encoded
250 /// instruction (non-relaxable) that has no fixups registered. When applicable,
251 /// it can be used instead of MCDataFragment and lead to lower memory
252 /// consumption.
253 ///
255  virtual void anchor();
256 
257  /// \brief Should this fragment be aligned to the end of a bundle?
258  bool AlignToBundleEnd;
259 
260  SmallVector<char, 4> Contents;
261 public:
263  : MCEncodedFragment(FT_CompactEncodedInst, SD), AlignToBundleEnd(false)
264  {
265  }
266 
267  virtual bool hasInstructions() const {
268  return true;
269  }
270 
271  virtual SmallVectorImpl<char> &getContents() { return Contents; }
272  virtual const SmallVectorImpl<char> &getContents() const { return Contents; }
273 
274  virtual bool alignToBundleEnd() const { return AlignToBundleEnd; }
275  virtual void setAlignToBundleEnd(bool V) { AlignToBundleEnd = V; }
276 
277  static bool classof(const MCFragment *F) {
279  }
280 };
281 
282 /// A relaxable fragment holds on to its MCInst, since it may need to be
283 /// relaxed during the assembler layout and relaxation stage.
284 ///
286  virtual void anchor();
287 
288  /// Inst - The instruction this is a fragment for.
289  MCInst Inst;
290 
291  /// Contents - Binary data for the currently encoded instruction.
292  SmallVector<char, 8> Contents;
293 
294  /// Fixups - The list of fixups in this fragment.
296 
297 public:
298  MCRelaxableFragment(const MCInst &_Inst, MCSectionData *SD = 0)
299  : MCEncodedFragmentWithFixups(FT_Relaxable, SD), Inst(_Inst) {
300  }
301 
302  virtual SmallVectorImpl<char> &getContents() { return Contents; }
303  virtual const SmallVectorImpl<char> &getContents() const { return Contents; }
304 
305  const MCInst &getInst() const { return Inst; }
306  void setInst(const MCInst& Value) { Inst = Value; }
307 
309  return Fixups;
310  }
311 
313  return Fixups;
314  }
315 
316  virtual bool hasInstructions() const { return true; }
317 
318  fixup_iterator fixup_begin() { return Fixups.begin(); }
319  const_fixup_iterator fixup_begin() const { return Fixups.begin(); }
320 
321  fixup_iterator fixup_end() {return Fixups.end();}
322  const_fixup_iterator fixup_end() const {return Fixups.end();}
323 
324  static bool classof(const MCFragment *F) {
325  return F->getKind() == MCFragment::FT_Relaxable;
326  }
327 };
328 
329 class MCAlignFragment : public MCFragment {
330  virtual void anchor();
331 
332  /// Alignment - The alignment to ensure, in bytes.
333  unsigned Alignment;
334 
335  /// Value - Value to use for filling padding bytes.
336  int64_t Value;
337 
338  /// ValueSize - The size of the integer (in bytes) of \p Value.
339  unsigned ValueSize;
340 
341  /// MaxBytesToEmit - The maximum number of bytes to emit; if the alignment
342  /// cannot be satisfied in this width then this fragment is ignored.
343  unsigned MaxBytesToEmit;
344 
345  /// EmitNops - Flag to indicate that (optimal) NOPs should be emitted instead
346  /// of using the provided value. The exact interpretation of this flag is
347  /// target dependent.
348  bool EmitNops : 1;
349 
350 public:
351  MCAlignFragment(unsigned _Alignment, int64_t _Value, unsigned _ValueSize,
352  unsigned _MaxBytesToEmit, MCSectionData *SD = 0)
353  : MCFragment(FT_Align, SD), Alignment(_Alignment),
354  Value(_Value),ValueSize(_ValueSize),
355  MaxBytesToEmit(_MaxBytesToEmit), EmitNops(false) {}
356 
357  /// @name Accessors
358  /// @{
359 
360  unsigned getAlignment() const { return Alignment; }
361 
362  int64_t getValue() const { return Value; }
363 
364  unsigned getValueSize() const { return ValueSize; }
365 
366  unsigned getMaxBytesToEmit() const { return MaxBytesToEmit; }
367 
368  bool hasEmitNops() const { return EmitNops; }
369  void setEmitNops(bool Value) { EmitNops = Value; }
370 
371  /// @}
372 
373  static bool classof(const MCFragment *F) {
374  return F->getKind() == MCFragment::FT_Align;
375  }
376 };
377 
378 class MCFillFragment : public MCFragment {
379  virtual void anchor();
380 
381  /// Value - Value to use for filling bytes.
382  int64_t Value;
383 
384  /// ValueSize - The size (in bytes) of \p Value to use when filling, or 0 if
385  /// this is a virtual fill fragment.
386  unsigned ValueSize;
387 
388  /// Size - The number of bytes to insert.
389  uint64_t Size;
390 
391 public:
392  MCFillFragment(int64_t _Value, unsigned _ValueSize, uint64_t _Size,
393  MCSectionData *SD = 0)
394  : MCFragment(FT_Fill, SD),
395  Value(_Value), ValueSize(_ValueSize), Size(_Size) {
396  assert((!ValueSize || (Size % ValueSize) == 0) &&
397  "Fill size must be a multiple of the value size!");
398  }
399 
400  /// @name Accessors
401  /// @{
402 
403  int64_t getValue() const { return Value; }
404 
405  unsigned getValueSize() const { return ValueSize; }
406 
407  uint64_t getSize() const { return Size; }
408 
409  /// @}
410 
411  static bool classof(const MCFragment *F) {
412  return F->getKind() == MCFragment::FT_Fill;
413  }
414 };
415 
416 class MCOrgFragment : public MCFragment {
417  virtual void anchor();
418 
419  /// Offset - The offset this fragment should start at.
420  const MCExpr *Offset;
421 
422  /// Value - Value to use for filling bytes.
423  int8_t Value;
424 
425 public:
426  MCOrgFragment(const MCExpr &_Offset, int8_t _Value, MCSectionData *SD = 0)
427  : MCFragment(FT_Org, SD),
428  Offset(&_Offset), Value(_Value) {}
429 
430  /// @name Accessors
431  /// @{
432 
433  const MCExpr &getOffset() const { return *Offset; }
434 
435  uint8_t getValue() const { return Value; }
436 
437  /// @}
438 
439  static bool classof(const MCFragment *F) {
440  return F->getKind() == MCFragment::FT_Org;
441  }
442 };
443 
444 class MCLEBFragment : public MCFragment {
445  virtual void anchor();
446 
447  /// Value - The value this fragment should contain.
448  const MCExpr *Value;
449 
450  /// IsSigned - True if this is a sleb128, false if uleb128.
451  bool IsSigned;
452 
453  SmallString<8> Contents;
454 public:
455  MCLEBFragment(const MCExpr &Value_, bool IsSigned_, MCSectionData *SD = 0)
456  : MCFragment(FT_LEB, SD),
457  Value(&Value_), IsSigned(IsSigned_) { Contents.push_back(0); }
458 
459  /// @name Accessors
460  /// @{
461 
462  const MCExpr &getValue() const { return *Value; }
463 
464  bool isSigned() const { return IsSigned; }
465 
466  SmallString<8> &getContents() { return Contents; }
467  const SmallString<8> &getContents() const { return Contents; }
468 
469  /// @}
470 
471  static bool classof(const MCFragment *F) {
472  return F->getKind() == MCFragment::FT_LEB;
473  }
474 };
475 
477  virtual void anchor();
478 
479  /// LineDelta - the value of the difference between the two line numbers
480  /// between two .loc dwarf directives.
481  int64_t LineDelta;
482 
483  /// AddrDelta - The expression for the difference of the two symbols that
484  /// make up the address delta between two .loc dwarf directives.
485  const MCExpr *AddrDelta;
486 
487  SmallString<8> Contents;
488 
489 public:
490  MCDwarfLineAddrFragment(int64_t _LineDelta, const MCExpr &_AddrDelta,
491  MCSectionData *SD = 0)
492  : MCFragment(FT_Dwarf, SD),
493  LineDelta(_LineDelta), AddrDelta(&_AddrDelta) { Contents.push_back(0); }
494 
495  /// @name Accessors
496  /// @{
497 
498  int64_t getLineDelta() const { return LineDelta; }
499 
500  const MCExpr &getAddrDelta() const { return *AddrDelta; }
501 
502  SmallString<8> &getContents() { return Contents; }
503  const SmallString<8> &getContents() const { return Contents; }
504 
505  /// @}
506 
507  static bool classof(const MCFragment *F) {
508  return F->getKind() == MCFragment::FT_Dwarf;
509  }
510 };
511 
513  virtual void anchor();
514 
515  /// AddrDelta - The expression for the difference of the two symbols that
516  /// make up the address delta between two .cfi_* dwarf directives.
517  const MCExpr *AddrDelta;
518 
519  SmallString<8> Contents;
520 
521 public:
522  MCDwarfCallFrameFragment(const MCExpr &_AddrDelta, MCSectionData *SD = 0)
523  : MCFragment(FT_DwarfFrame, SD),
524  AddrDelta(&_AddrDelta) { Contents.push_back(0); }
525 
526  /// @name Accessors
527  /// @{
528 
529  const MCExpr &getAddrDelta() const { return *AddrDelta; }
530 
531  SmallString<8> &getContents() { return Contents; }
532  const SmallString<8> &getContents() const { return Contents; }
533 
534  /// @}
535 
536  static bool classof(const MCFragment *F) {
537  return F->getKind() == MCFragment::FT_DwarfFrame;
538  }
539 };
540 
541 // FIXME: Should this be a separate class, or just merged into MCSection? Since
542 // we anticipate the fast path being through an MCAssembler, the only reason to
543 // keep it out is for API abstraction.
544 class MCSectionData : public ilist_node<MCSectionData> {
545  friend class MCAsmLayout;
546 
548  void operator=(const MCSectionData&) LLVM_DELETED_FUNCTION;
549 
550 public:
552 
553  typedef FragmentListType::const_iterator const_iterator;
554  typedef FragmentListType::iterator iterator;
555 
557  typedef FragmentListType::reverse_iterator reverse_iterator;
558 
559  /// \brief Express the state of bundle locked groups while emitting code.
564  };
565 private:
566  FragmentListType Fragments;
567  const MCSection *Section;
568 
569  /// Ordinal - The section index in the assemblers section list.
570  unsigned Ordinal;
571 
572  /// LayoutOrder - The index of this section in the layout order.
573  unsigned LayoutOrder;
574 
575  /// Alignment - The maximum alignment seen in this section.
576  unsigned Alignment;
577 
578  /// \brief Keeping track of bundle-locked state.
579  BundleLockStateType BundleLockState;
580 
581  /// \brief We've seen a bundle_lock directive but not its first instruction
582  /// yet.
583  bool BundleGroupBeforeFirstInst;
584 
585  /// @name Assembler Backend Data
586  /// @{
587  //
588  // FIXME: This could all be kept private to the assembler implementation.
589 
590  /// HasInstructions - Whether this section has had instructions emitted into
591  /// it.
592  unsigned HasInstructions : 1;
593 
594  /// Mapping from subsection number to insertion point for subsection numbers
595  /// below that number.
596  SmallVector<std::pair<unsigned, MCFragment *>, 1> SubsectionFragmentMap;
597 
598  /// @}
599 
600 public:
601  // Only for use as sentinel.
602  MCSectionData();
604 
605  const MCSection &getSection() const { return *Section; }
606 
607  unsigned getAlignment() const { return Alignment; }
608  void setAlignment(unsigned Value) { Alignment = Value; }
609 
610  bool hasInstructions() const { return HasInstructions; }
611  void setHasInstructions(bool Value) { HasInstructions = Value; }
612 
613  unsigned getOrdinal() const { return Ordinal; }
614  void setOrdinal(unsigned Value) { Ordinal = Value; }
615 
616  unsigned getLayoutOrder() const { return LayoutOrder; }
617  void setLayoutOrder(unsigned Value) { LayoutOrder = Value; }
618 
619  /// @name Fragment Access
620  /// @{
621 
622  const FragmentListType &getFragmentList() const { return Fragments; }
623  FragmentListType &getFragmentList() { return Fragments; }
624 
625  iterator begin() { return Fragments.begin(); }
626  const_iterator begin() const { return Fragments.begin(); }
627 
628  iterator end() { return Fragments.end(); }
629  const_iterator end() const { return Fragments.end(); }
630 
631  reverse_iterator rbegin() { return Fragments.rbegin(); }
632  const_reverse_iterator rbegin() const { return Fragments.rbegin(); }
633 
634  reverse_iterator rend() { return Fragments.rend(); }
635  const_reverse_iterator rend() const { return Fragments.rend(); }
636 
637  size_t size() const { return Fragments.size(); }
638 
639  bool empty() const { return Fragments.empty(); }
640 
641  iterator getSubsectionInsertionPoint(unsigned Subsection);
642 
643  bool isBundleLocked() const {
644  return BundleLockState != NotBundleLocked;
645  }
646 
648  return BundleLockState;
649  }
650 
652  BundleLockState = NewState;
653  }
654 
656  return BundleGroupBeforeFirstInst;
657  }
658 
659  void setBundleGroupBeforeFirstInst(bool IsFirst) {
660  BundleGroupBeforeFirstInst = IsFirst;
661  }
662 
663  void dump();
664 
665  /// @}
666 };
667 
668 // FIXME: Same concerns as with SectionData.
669 class MCSymbolData : public ilist_node<MCSymbolData> {
670 public:
671  const MCSymbol *Symbol;
672 
673  /// Fragment - The fragment this symbol's value is relative to, if any.
675 
676  /// Offset - The offset to apply to the fragment address to form this symbol's
677  /// value.
678  uint64_t Offset;
679 
680  /// IsExternal - True if this symbol is visible outside this translation
681  /// unit.
682  unsigned IsExternal : 1;
683 
684  /// IsPrivateExtern - True if this symbol is private extern.
685  unsigned IsPrivateExtern : 1;
686 
687  /// CommonSize - The size of the symbol, if it is 'common', or 0.
688  //
689  // FIXME: Pack this in with other fields? We could put it in offset, since a
690  // common symbol can never get a definition.
691  uint64_t CommonSize;
692 
693  /// SymbolSize - An expression describing how to calculate the size of
694  /// a symbol. If a symbol has no size this field will be NULL.
696 
697  /// CommonAlign - The alignment of the symbol, if it is 'common'.
698  //
699  // FIXME: Pack this in with other fields?
700  unsigned CommonAlign;
701 
702  /// Flags - The Flags field is used by object file implementations to store
703  /// additional per symbol information which is not easily classified.
704  uint32_t Flags;
705 
706  /// Index - Index field, for use by the object file implementation.
707  uint64_t Index;
708 
709 public:
710  // Only for use as sentinel.
711  MCSymbolData();
712  MCSymbolData(const MCSymbol &_Symbol, MCFragment *_Fragment, uint64_t _Offset,
713  MCAssembler *A = 0);
714 
715  /// @name Accessors
716  /// @{
717 
718  const MCSymbol &getSymbol() const { return *Symbol; }
719 
720  MCFragment *getFragment() const { return Fragment; }
721  void setFragment(MCFragment *Value) { Fragment = Value; }
722 
723  uint64_t getOffset() const { return Offset; }
724  void setOffset(uint64_t Value) { Offset = Value; }
725 
726  /// @}
727  /// @name Symbol Attributes
728  /// @{
729 
730  bool isExternal() const { return IsExternal; }
731  void setExternal(bool Value) { IsExternal = Value; }
732 
733  bool isPrivateExtern() const { return IsPrivateExtern; }
734  void setPrivateExtern(bool Value) { IsPrivateExtern = Value; }
735 
736  /// isCommon - Is this a 'common' symbol.
737  bool isCommon() const { return CommonSize != 0; }
738 
739  /// setCommon - Mark this symbol as being 'common'.
740  ///
741  /// \param Size - The size of the symbol.
742  /// \param Align - The alignment of the symbol.
743  void setCommon(uint64_t Size, unsigned Align) {
744  CommonSize = Size;
745  CommonAlign = Align;
746  }
747 
748  /// getCommonSize - Return the size of a 'common' symbol.
749  uint64_t getCommonSize() const {
750  assert(isCommon() && "Not a 'common' symbol!");
751  return CommonSize;
752  }
753 
754  void setSize(const MCExpr *SS) {
755  SymbolSize = SS;
756  }
757 
758  const MCExpr *getSize() const {
759  return SymbolSize;
760  }
761 
762 
763  /// getCommonAlignment - Return the alignment of a 'common' symbol.
764  unsigned getCommonAlignment() const {
765  assert(isCommon() && "Not a 'common' symbol!");
766  return CommonAlign;
767  }
768 
769  /// getFlags - Get the (implementation defined) symbol flags.
770  uint32_t getFlags() const { return Flags; }
771 
772  /// setFlags - Set the (implementation defined) symbol flags.
773  void setFlags(uint32_t Value) { Flags = Value; }
774 
775  /// modifyFlags - Modify the flags via a mask
776  void modifyFlags(uint32_t Value, uint32_t Mask) {
777  Flags = (Flags & ~Mask) | Value;
778  }
779 
780  /// getIndex - Get the (implementation defined) index.
781  uint64_t getIndex() const { return Index; }
782 
783  /// setIndex - Set the (implementation defined) index.
784  void setIndex(uint64_t Value) { Index = Value; }
785 
786  /// @}
787 
788  void dump();
789 };
790 
791 // FIXME: This really doesn't belong here. See comments below.
795 };
796 
797 // FIXME: Ditto this. Purely so the Streamer and the ObjectWriter can talk
798 // to one another.
800  // This enum should be kept in sync w/ the mach-o definition in
801  // llvm/Object/MachOFormat.h.
805 };
806 
807 class MCAssembler {
808  friend class MCAsmLayout;
809 
810 public:
813 
816 
819 
820  typedef std::vector<std::string> FileNameVectorType;
821  typedef FileNameVectorType::const_iterator const_file_name_iterator;
822 
823  typedef std::vector<IndirectSymbolData>::const_iterator
825  typedef std::vector<IndirectSymbolData>::iterator indirect_symbol_iterator;
826 
827  typedef std::vector<DataRegionData>::const_iterator
829  typedef std::vector<DataRegionData>::iterator data_region_iterator;
830 
831 private:
833  void operator=(const MCAssembler&) LLVM_DELETED_FUNCTION;
834 
835  MCContext &Context;
836 
837  MCAsmBackend &Backend;
838 
839  MCCodeEmitter &Emitter;
840 
841  MCObjectWriter &Writer;
842 
843  raw_ostream &OS;
844 
845  iplist<MCSectionData> Sections;
846 
847  iplist<MCSymbolData> Symbols;
848 
849  /// The map of sections to their associated assembler backend data.
850  //
851  // FIXME: Avoid this indirection?
852  DenseMap<const MCSection*, MCSectionData*> SectionMap;
853 
854  /// The map of symbols to their associated assembler backend data.
855  //
856  // FIXME: Avoid this indirection?
857  DenseMap<const MCSymbol*, MCSymbolData*> SymbolMap;
858 
859  std::vector<IndirectSymbolData> IndirectSymbols;
860 
861  std::vector<DataRegionData> DataRegions;
862 
863  /// The list of linker options to propagate into the object file.
864  std::vector<std::vector<std::string> > LinkerOptions;
865 
866  /// List of declared file names
867  FileNameVectorType FileNames;
868 
869  /// The set of function symbols for which a .thumb_func directive has
870  /// been seen.
871  //
872  // FIXME: We really would like this in target specific code rather than
873  // here. Maybe when the relocation stuff moves to target specific,
874  // this can go with it? The streamer would need some target specific
875  // refactoring too.
876  SmallPtrSet<const MCSymbol*, 64> ThumbFuncs;
877 
878  /// \brief The bundle alignment size currently set in the assembler.
879  ///
880  /// By default it's 0, which means bundling is disabled.
881  unsigned BundleAlignSize;
882 
883  unsigned RelaxAll : 1;
884  unsigned NoExecStack : 1;
885  unsigned SubsectionsViaSymbols : 1;
886 
887  /// ELF specific e_header flags
888  // It would be good if there were an MCELFAssembler class to hold this.
889  // ELF header flags are used both by the integrated and standalone assemblers.
890  // Access to the flags is necessary in cases where assembler directives affect
891  // which flags to be set.
892  unsigned ELFHeaderEFlags;
893 private:
894  /// Evaluate a fixup to a relocatable expression and the value which should be
895  /// placed into the fixup.
896  ///
897  /// \param Layout The layout to use for evaluation.
898  /// \param Fixup The fixup to evaluate.
899  /// \param DF The fragment the fixup is inside.
900  /// \param Target [out] On return, the relocatable expression the fixup
901  /// evaluates to.
902  /// \param Value [out] On return, the value of the fixup as currently laid
903  /// out.
904  /// \return Whether the fixup value was fully resolved. This is true if the
905  /// \p Value result is fixed, otherwise the value may change due to
906  /// relocation.
907  bool evaluateFixup(const MCAsmLayout &Layout,
908  const MCFixup &Fixup, const MCFragment *DF,
909  MCValue &Target, uint64_t &Value) const;
910 
911  /// Check whether a fixup can be satisfied, or whether it needs to be relaxed
912  /// (increased in size, in order to hold its value correctly).
913  bool fixupNeedsRelaxation(const MCFixup &Fixup, const MCRelaxableFragment *DF,
914  const MCAsmLayout &Layout) const;
915 
916  /// Check whether the given fragment needs relaxation.
917  bool fragmentNeedsRelaxation(const MCRelaxableFragment *IF,
918  const MCAsmLayout &Layout) const;
919 
920  /// \brief Perform one layout iteration and return true if any offsets
921  /// were adjusted.
922  bool layoutOnce(MCAsmLayout &Layout);
923 
924  /// \brief Perform one layout iteration of the given section and return true
925  /// if any offsets were adjusted.
926  bool layoutSectionOnce(MCAsmLayout &Layout, MCSectionData &SD);
927 
928  bool relaxInstruction(MCAsmLayout &Layout, MCRelaxableFragment &IF);
929 
930  bool relaxLEB(MCAsmLayout &Layout, MCLEBFragment &IF);
931 
932  bool relaxDwarfLineAddr(MCAsmLayout &Layout, MCDwarfLineAddrFragment &DF);
933  bool relaxDwarfCallFrameFragment(MCAsmLayout &Layout,
935 
936  /// finishLayout - Finalize a layout, including fragment lowering.
937  void finishLayout(MCAsmLayout &Layout);
938 
939  uint64_t handleFixup(const MCAsmLayout &Layout,
940  MCFragment &F, const MCFixup &Fixup);
941 
942 public:
943  /// Compute the effective fragment size assuming it is laid out at the given
944  /// \p SectionAddress and \p FragmentOffset.
945  uint64_t computeFragmentSize(const MCAsmLayout &Layout,
946  const MCFragment &F) const;
947 
948  /// Find the symbol which defines the atom containing the given symbol, or
949  /// null if there is no such symbol.
950  const MCSymbolData *getAtom(const MCSymbolData *Symbol) const;
951 
952  /// Check whether a particular symbol is visible to the linker and is required
953  /// in the symbol table, or whether it can be discarded by the assembler. This
954  /// also effects whether the assembler treats the label as potentially
955  /// defining a separate atom.
956  bool isSymbolLinkerVisible(const MCSymbol &SD) const;
957 
958  /// Emit the section contents using the given object writer.
960  const MCAsmLayout &Layout) const;
961 
962  /// Check whether a given symbol has been flagged with .thumb_func.
963  bool isThumbFunc(const MCSymbol *Func) const {
964  return ThumbFuncs.count(Func);
965  }
966 
967  /// Flag a function symbol as the target of a .thumb_func directive.
968  void setIsThumbFunc(const MCSymbol *Func) { ThumbFuncs.insert(Func); }
969 
970  /// ELF e_header flags
971  unsigned getELFHeaderEFlags() const {return ELFHeaderEFlags;}
972  void setELFHeaderEFlags(unsigned Flags) { ELFHeaderEFlags = Flags;}
973 
974 public:
975  /// Construct a new assembler instance.
976  ///
977  /// \param OS The stream to output to.
978  //
979  // FIXME: How are we going to parameterize this? Two obvious options are stay
980  // concrete and require clients to pass in a target like object. The other
981  // option is to make this abstract, and have targets provide concrete
982  // implementations as we do with AsmParser.
983  MCAssembler(MCContext &Context_, MCAsmBackend &Backend_,
984  MCCodeEmitter &Emitter_, MCObjectWriter &Writer_,
985  raw_ostream &OS);
986  ~MCAssembler();
987 
988  /// Reuse an assembler instance
989  ///
990  void reset();
991 
992  MCContext &getContext() const { return Context; }
993 
994  MCAsmBackend &getBackend() const { return Backend; }
995 
996  MCCodeEmitter &getEmitter() const { return Emitter; }
997 
998  MCObjectWriter &getWriter() const { return Writer; }
999 
1000  /// Finish - Do final processing and write the object to the output stream.
1001  /// \p Writer is used for custom object writer (as the MCJIT does),
1002  /// if not specified it is automatically created from backend.
1003  void Finish();
1004 
1005  // FIXME: This does not belong here.
1007  return SubsectionsViaSymbols;
1008  }
1010  SubsectionsViaSymbols = Value;
1011  }
1012 
1013  bool getRelaxAll() const { return RelaxAll; }
1014  void setRelaxAll(bool Value) { RelaxAll = Value; }
1015 
1016  bool getNoExecStack() const { return NoExecStack; }
1017  void setNoExecStack(bool Value) { NoExecStack = Value; }
1018 
1019  bool isBundlingEnabled() const {
1020  return BundleAlignSize != 0;
1021  }
1022 
1023  unsigned getBundleAlignSize() const {
1024  return BundleAlignSize;
1025  }
1026 
1027  void setBundleAlignSize(unsigned Size) {
1028  assert((Size == 0 || !(Size & (Size - 1))) &&
1029  "Expect a power-of-two bundle align size");
1030  BundleAlignSize = Size;
1031  }
1032 
1033  /// @name Section List Access
1034  /// @{
1035 
1036  const SectionDataListType &getSectionList() const { return Sections; }
1037  SectionDataListType &getSectionList() { return Sections; }
1038 
1039  iterator begin() { return Sections.begin(); }
1040  const_iterator begin() const { return Sections.begin(); }
1041 
1042  iterator end() { return Sections.end(); }
1043  const_iterator end() const { return Sections.end(); }
1044 
1045  size_t size() const { return Sections.size(); }
1046 
1047  /// @}
1048  /// @name Symbol List Access
1049  /// @{
1050 
1051  const SymbolDataListType &getSymbolList() const { return Symbols; }
1052  SymbolDataListType &getSymbolList() { return Symbols; }
1053 
1054  symbol_iterator symbol_begin() { return Symbols.begin(); }
1055  const_symbol_iterator symbol_begin() const { return Symbols.begin(); }
1056 
1057  symbol_iterator symbol_end() { return Symbols.end(); }
1058  const_symbol_iterator symbol_end() const { return Symbols.end(); }
1059 
1060  size_t symbol_size() const { return Symbols.size(); }
1061 
1062  /// @}
1063  /// @name Indirect Symbol List Access
1064  /// @{
1065 
1066  // FIXME: This is a total hack, this should not be here. Once things are
1067  // factored so that the streamer has direct access to the .o writer, it can
1068  // disappear.
1069  std::vector<IndirectSymbolData> &getIndirectSymbols() {
1070  return IndirectSymbols;
1071  }
1072 
1074  return IndirectSymbols.begin();
1075  }
1077  return IndirectSymbols.begin();
1078  }
1079 
1081  return IndirectSymbols.end();
1082  }
1084  return IndirectSymbols.end();
1085  }
1086 
1087  size_t indirect_symbol_size() const { return IndirectSymbols.size(); }
1088 
1089  /// @}
1090  /// @name Linker Option List Access
1091  /// @{
1092 
1093  std::vector<std::vector<std::string> > &getLinkerOptions() {
1094  return LinkerOptions;
1095  }
1096 
1097  /// @}
1098  /// @name Data Region List Access
1099  /// @{
1100 
1101  // FIXME: This is a total hack, this should not be here. Once things are
1102  // factored so that the streamer has direct access to the .o writer, it can
1103  // disappear.
1104  std::vector<DataRegionData> &getDataRegions() {
1105  return DataRegions;
1106  }
1107 
1109  return DataRegions.begin();
1110  }
1112  return DataRegions.begin();
1113  }
1114 
1116  return DataRegions.end();
1117  }
1119  return DataRegions.end();
1120  }
1121 
1122  size_t data_region_size() const { return DataRegions.size(); }
1123 
1124  /// @}
1125  /// @name Backend Data Access
1126  /// @{
1127 
1129  MCSectionData *Entry = SectionMap.lookup(&Section);
1130  assert(Entry && "Missing section data!");
1131  return *Entry;
1132  }
1133 
1135  bool *Created = 0) {
1136  MCSectionData *&Entry = SectionMap[&Section];
1137 
1138  if (Created) *Created = !Entry;
1139  if (!Entry)
1140  Entry = new MCSectionData(Section, this);
1141 
1142  return *Entry;
1143  }
1144 
1146  MCSymbolData *Entry = SymbolMap.lookup(&Symbol);
1147  assert(Entry && "Missing symbol data!");
1148  return *Entry;
1149  }
1150 
1152  bool *Created = 0) {
1153  MCSymbolData *&Entry = SymbolMap[&Symbol];
1154 
1155  if (Created) *Created = !Entry;
1156  if (!Entry)
1157  Entry = new MCSymbolData(Symbol, 0, 0, this);
1158 
1159  return *Entry;
1160  }
1161 
1163  return FileNames.begin();
1164  }
1165 
1167  return FileNames.end();
1168  }
1169 
1170  void addFileName(StringRef FileName) {
1171  if (std::find(file_names_begin(), file_names_end(), FileName) ==
1172  file_names_end())
1173  FileNames.push_back(FileName);
1174  }
1175 
1176  /// @}
1177 
1178  void dump();
1179 };
1180 
1181 } // end namespace llvm
1182 
1183 #endif
void setParent(MCSectionData *Value)
Definition: MCAssembler.h:96
void setIsThumbFunc(const MCSymbol *Func)
Flag a function symbol as the target of a .thumb_func directive.
Definition: MCAssembler.h:968
size_t indirect_symbol_size() const
Definition: MCAssembler.h:1087
void setELFHeaderEFlags(unsigned Flags)
Definition: MCAssembler.h:972
void push_back(const T &Elt)
Definition: SmallVector.h:236
void setExternal(bool Value)
Definition: MCAssembler.h:731
fixup_iterator fixup_end()
Definition: MCAssembler.h:321
static bool classof(const MCFragment *F)
Definition: MCAssembler.h:471
unsigned getValueSize() const
Definition: MCAssembler.h:364
std::vector< DataRegionData >::iterator data_region_iterator
Definition: MCAssembler.h:829
void setFlags(uint32_t Value)
setFlags - Set the (implementation defined) symbol flags.
Definition: MCAssembler.h:773
bool isBundleLocked() const
Definition: MCAssembler.h:643
virtual bool alignToBundleEnd() const
Should this fragment be placed at the end of an aligned bundle?
Definition: MCAssembler.h:274
const_reverse_iterator rbegin() const
Definition: MCAssembler.h:632
FragmentListType::const_reverse_iterator const_reverse_iterator
Definition: MCAssembler.h:556
bool empty() const
Definition: MCAssembler.h:639
const MCExpr * getSize() const
Definition: MCAssembler.h:758
static bool classof(const MCFragment *F)
Definition: MCAssembler.h:411
void setBundleLockState(BundleLockStateType NewState)
Definition: MCAssembler.h:651
unsigned getAlignment() const
Definition: MCAssembler.h:360
iterator begin()
Definition: MCAssembler.h:1039
reverse_iterator rend()
Definition: ilist.h:379
const MCExpr & getAddrDelta() const
Definition: MCAssembler.h:529
MCFillFragment(int64_t _Value, unsigned _ValueSize, uint64_t _Size, MCSectionData *SD=0)
Definition: MCAssembler.h:392
SmallVectorImpl< MCFixup >::iterator fixup_iterator
Definition: MCAssembler.h:183
unsigned getBundleAlignSize() const
Definition: MCAssembler.h:1023
bool getNoExecStack() const
Definition: MCAssembler.h:1016
virtual const SmallVectorImpl< char > & getContents() const
Definition: MCAssembler.h:303
MCDataFragment(MCSectionData *SD=0)
Definition: MCAssembler.h:215
SmallVectorImpl< MCFixup >::const_iterator const_fixup_iterator
Definition: MCAssembler.h:182
MCDwarfLineAddrFragment(int64_t _LineDelta, const MCExpr &_AddrDelta, MCSectionData *SD=0)
Definition: MCAssembler.h:490
MCCodeEmitter & getEmitter() const
Definition: MCAssembler.h:996
SymbolDataListType::const_iterator const_symbol_iterator
Definition: MCAssembler.h:817
F(f)
virtual SmallVectorImpl< char > & getContents()
Definition: MCAssembler.h:221
bool isSigned() const
Definition: MCAssembler.h:464
void setBundleGroupBeforeFirstInst(bool IsFirst)
Definition: MCAssembler.h:659
iterator begin()
Definition: ilist.h:359
SymbolDataListType & getSymbolList()
Definition: MCAssembler.h:1052
std::vector< IndirectSymbolData > & getIndirectSymbols()
Definition: MCAssembler.h:1069
bool hasInstructions() const
Definition: MCAssembler.h:610
unsigned getELFHeaderEFlags() const
ELF e_header flags.
Definition: MCAssembler.h:971
MCContext & getContext() const
Definition: MCAssembler.h:992
virtual bool alignToBundleEnd() const
Should this fragment be placed at the end of an aligned bundle?
Definition: MCAssembler.h:109
const MCSymbol & getSymbol() const
Definition: MCAssembler.h:718
uint64_t getSize() const
Definition: MCAssembler.h:407
const FragmentListType & getFragmentList() const
Definition: MCAssembler.h:622
const MCExpr & getOffset() const
Definition: MCAssembler.h:433
BundleLockStateType getBundleLockState() const
Definition: MCAssembler.h:647
symbol_iterator symbol_begin()
Definition: MCAssembler.h:1054
const MCInst & getInst() const
Definition: MCAssembler.h:305
MCAlignFragment(unsigned _Alignment, int64_t _Value, unsigned _ValueSize, unsigned _MaxBytesToEmit, MCSectionData *SD=0)
Definition: MCAssembler.h:351
reverse_iterator rbegin()
Definition: ilist.h:377
MCLEBFragment(const MCExpr &Value_, bool IsSigned_, MCSectionData *SD=0)
Definition: MCAssembler.h:455
virtual const SmallVectorImpl< char > & getContents() const
Definition: MCAssembler.h:272
const_iterator begin() const
Definition: MCAssembler.h:626
enum llvm::DataRegionData::KindTy Kind
SmallVectorImpl< MCFixup > & getFixups()
Definition: MCAssembler.h:224
virtual SmallVectorImpl< char > & getContents()=0
uint64_t getIndex() const
getIndex - Get the (implementation defined) index.
Definition: MCAssembler.h:781
virtual uint8_t getBundlePadding() const
Get the padding size that must be inserted before this fragment. Used for bundling. By default, no padding is inserted. Note that padding size is restricted to 8 bits. This is an optimization to reduce the amount of space used for each fragment. In practice, larger padding should never be required.
Definition: MCAssembler.h:117
iplist< MCFragment > FragmentListType
Definition: MCAssembler.h:551
MCEncodedFragmentWithFixups(MCFragment::FragmentType FType, MCSectionData *SD=0)
Definition: MCAssembler.h:174
const MCSymbolData * getAtom(const MCSymbolData *Symbol) const
std::vector< DataRegionData >::const_iterator const_data_region_iterator
Definition: MCAssembler.h:828
virtual bool hasInstructions() const
Does this fragment have instructions emitted into it? By default this is false, but specific fragment...
Definition: MCAssembler.h:106
void setEmitNops(bool Value)
Definition: MCAssembler.h:369
virtual fixup_iterator fixup_end()=0
unsigned IsPrivateExtern
IsPrivateExtern - True if this symbol is private extern.
Definition: MCAssembler.h:685
void setRelaxAll(bool Value)
Definition: MCAssembler.h:1014
virtual void setAlignToBundleEnd(bool V)
Definition: MCAssembler.h:110
virtual bool hasInstructions() const
Does this fragment have instructions emitted into it? By default this is false, but specific fragment...
Definition: MCAssembler.h:232
virtual bool hasInstructions() const
Does this fragment have instructions emitted into it? By default this is false, but specific fragment...
Definition: MCAssembler.h:267
unsigned getMaxBytesToEmit() const
Definition: MCAssembler.h:366
SectionDataListType::const_iterator const_iterator
Definition: MCAssembler.h:814
virtual fixup_iterator fixup_begin()=0
uint64_t getCommonSize() const
getCommonSize - Return the size of a 'common' symbol.
Definition: MCAssembler.h:749
MCSectionData & getSectionData(const MCSection &Section) const
Definition: MCAssembler.h:1128
const SymbolDataListType & getSymbolList() const
Definition: MCAssembler.h:1051
BundleLockStateType
Express the state of bundle locked groups while emitting code.
Definition: MCAssembler.h:560
#define false
Definition: ConvertUTF.c:64
void setSubsectionsViaSymbols(bool Value)
Definition: MCAssembler.h:1009
int64_t getLineDelta() const
Definition: MCAssembler.h:498
MCRelaxableFragment(const MCInst &_Inst, MCSectionData *SD=0)
Definition: MCAssembler.h:298
reverse_iterator rbegin()
Definition: MCAssembler.h:631
bool count(PtrType Ptr) const
count - Return true if the specified pointer is in the set.
Definition: SmallPtrSet.h:264
MCObjectWriter & getWriter() const
Definition: MCAssembler.h:998
bool isExternal() const
Definition: MCAssembler.h:730
static bool classof(const MCFragment *F)
Definition: MCAssembler.h:507
static bool classof(const MCFragment *F)
Definition: MCAssembler.h:154
iplist< MCSymbolData > SymbolDataListType
Definition: MCAssembler.h:812
MCFragment * getFragment() const
Definition: MCAssembler.h:720
void setBundleAlignSize(unsigned Size)
Definition: MCAssembler.h:1027
std::vector< IndirectSymbolData >::const_iterator const_indirect_symbol_iterator
Definition: MCAssembler.h:824
const MCSection & getSection() const
Definition: MCAssembler.h:605
const MCExpr & getAddrDelta() const
Definition: MCAssembler.h:500
const SmallVectorImpl< MCFixup > & getFixups() const
Definition: MCAssembler.h:228
void setAtom(MCSymbolData *Value)
Definition: MCAssembler.h:99
unsigned getOrdinal() const
Definition: MCAssembler.h:613
virtual void setBundlePadding(uint8_t N)
Set the padding size for this fragment. By default it's a no-op, and only some fragments have a meani...
Definition: MCAssembler.h:123
const_data_region_iterator data_region_begin() const
Definition: MCAssembler.h:1111
static bool classof(const MCFragment *F)
Definition: MCAssembler.h:439
virtual void setBundlePadding(uint8_t N)
Set the padding size for this fragment. By default it's a no-op, and only some fragments have a meani...
Definition: MCAssembler.h:150
MCSectionData * getParent() const
Definition: MCAssembler.h:95
void setPrivateExtern(bool Value)
Definition: MCAssembler.h:734
bool hasEmitNops() const
Definition: MCAssembler.h:368
MCOrgFragment(const MCExpr &_Offset, int8_t _Value, MCSectionData *SD=0)
Definition: MCAssembler.h:426
SectionDataListType & getSectionList()
Definition: MCAssembler.h:1037
const_symbol_iterator symbol_end() const
Definition: MCAssembler.h:1058
unsigned getLayoutOrder() const
Definition: MCAssembler.h:616
size_type LLVM_ATTRIBUTE_UNUSED_RESULT size() const
Definition: ilist.h:539
void setNoExecStack(bool Value)
Definition: MCAssembler.h:1017
void setLayoutOrder(unsigned Value)
Definition: MCAssembler.h:617
uint64_t computeFragmentSize(const MCAsmLayout &Layout, const MCFragment &F) const
static bool classof(const MCFragment *F)
Definition: MCAssembler.h:324
uint32_t getFlags() const
getFlags - Get the (implementation defined) symbol flags.
Definition: MCAssembler.h:770
const_iterator end() const
Definition: MCAssembler.h:1043
void setCommon(uint64_t Size, unsigned Align)
Definition: MCAssembler.h:743
FragmentType getKind() const
Definition: MCAssembler.h:93
MCCodeEmitter - Generic instruction encoding interface.
Definition: MCCodeEmitter.h:22
bool getRelaxAll() const
Definition: MCAssembler.h:1013
MCSymbolData * getAtom() const
Definition: MCAssembler.h:98
virtual void setHasInstructions(bool V)
Definition: MCAssembler.h:233
virtual void setAlignToBundleEnd(bool V)
Definition: MCAssembler.h:275
MCDwarfCallFrameFragment(const MCExpr &_AddrDelta, MCSectionData *SD=0)
Definition: MCAssembler.h:522
const SmallVectorImpl< MCFixup > & getFixups() const
Definition: MCAssembler.h:312
void setOrdinal(unsigned Value)
Definition: MCAssembler.h:614
uint64_t getOffset() const
Definition: MCAssembler.h:723
virtual SmallVectorImpl< char > & getContents()
Definition: MCAssembler.h:271
void setIndex(uint64_t Value)
setIndex - Set the (implementation defined) index.
Definition: MCAssembler.h:784
size_t size() const
Definition: MCAssembler.h:1045
const_symbol_iterator symbol_begin() const
Definition: MCAssembler.h:1055
FragmentListType & getFragmentList()
Definition: MCAssembler.h:623
FileNameVectorType::const_iterator const_file_name_iterator
Definition: MCAssembler.h:821
size_t symbol_size() const
Definition: MCAssembler.h:1060
MCFragment * Fragment
Fragment - The fragment this symbol's value is relative to, if any.
Definition: MCAssembler.h:674
virtual const SmallVectorImpl< char > & getContents() const
Definition: MCAssembler.h:222
iplist< MCSectionData > SectionDataListType
Definition: MCAssembler.h:811
data_region_iterator data_region_begin()
Definition: MCAssembler.h:1108
static bool classof(const MCFragment *F)
Definition: MCAssembler.h:373
const SmallString< 8 > & getContents() const
Definition: MCAssembler.h:467
MCSymbolData & getOrCreateSymbolData(const MCSymbol &Symbol, bool *Created=0)
Definition: MCAssembler.h:1151
const_indirect_symbol_iterator indirect_symbol_end() const
Definition: MCAssembler.h:1083
MCEncodedFragment(MCFragment::FragmentType FType, MCSectionData *SD=0)
Definition: MCAssembler.h:137
bool isSymbolLinkerVisible(const MCSymbol &SD) const
const_fixup_iterator fixup_end() const
Definition: MCAssembler.h:322
MCSymbolData & getSymbolData(const MCSymbol &Symbol) const
Definition: MCAssembler.h:1145
virtual SmallVectorImpl< char > & getContents()
Definition: MCAssembler.h:302
std::vector< std::vector< std::string > > & getLinkerOptions()
Definition: MCAssembler.h:1093
virtual void setAlignToBundleEnd(bool V)
Definition: MCAssembler.h:236
const_fixup_iterator fixup_begin() const
Definition: MCAssembler.h:239
void setOffset(uint64_t Value)
Definition: MCAssembler.h:724
indirect_symbol_iterator indirect_symbol_begin()
Definition: MCAssembler.h:1073
std::vector< std::string > FileNameVectorType
Definition: MCAssembler.h:820
unsigned getCommonAlignment() const
getCommonAlignment - Return the alignment of a 'common' symbol.
Definition: MCAssembler.h:764
const_iterator end() const
Definition: MCAssembler.h:629
uint64_t Index
Index - Index field, for use by the object file implementation.
Definition: MCAssembler.h:707
bool isBundlingEnabled() const
Definition: MCAssembler.h:1019
unsigned getAlignment() const
Definition: MCAssembler.h:607
bool isCommon() const
isCommon - Is this a 'common' symbol.
Definition: MCAssembler.h:737
const_file_name_iterator file_names_begin() const
Definition: MCAssembler.h:1162
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
Definition: ilist.h:385
reverse_iterator rend()
Definition: MCAssembler.h:634
void addFileName(StringRef FileName)
Definition: MCAssembler.h:1170
virtual bool alignToBundleEnd() const
Should this fragment be placed at the end of an aligned bundle?
Definition: MCAssembler.h:235
const SmallString< 8 > & getContents() const
Definition: MCAssembler.h:503
void setHasInstructions(bool Value)
Definition: MCAssembler.h:611
#define LLVM_DELETED_FUNCTION
Definition: Compiler.h:137
const MCExpr * SymbolSize
Definition: MCAssembler.h:695
unsigned CommonAlign
CommonAlign - The alignment of the symbol, if it is 'common'.
Definition: MCAssembler.h:700
virtual bool hasInstructions() const
Does this fragment have instructions emitted into it? By default this is false, but specific fragment...
Definition: MCAssembler.h:316
const_file_name_iterator file_names_end() const
Definition: MCAssembler.h:1166
SmallString< 8 > & getContents()
Definition: MCAssembler.h:531
static cl::opt< AlignMode > Align(cl::desc("Load/store alignment support"), cl::Hidden, cl::init(DefaultAlign), cl::values(clEnumValN(DefaultAlign,"arm-default-align","Generate unaligned accesses only on hardware/OS ""combinations that are known to support them"), clEnumValN(StrictAlign,"arm-strict-align","Disallow all unaligned memory accesses"), clEnumValN(NoStrictAlign,"arm-no-strict-align","Allow unaligned memory accesses"), clEnumValEnd))
int64_t getValue() const
Definition: MCAssembler.h:362
void setSize(const MCExpr *SS)
Definition: MCAssembler.h:754
const SectionDataListType & getSectionList() const
Definition: MCAssembler.h:1036
FragmentListType::reverse_iterator reverse_iterator
Definition: MCAssembler.h:557
MCSectionData * SectionData
Definition: MCAssembler.h:794
static bool classof(const MCFragment *F)
Definition: MCAssembler.h:277
bool getSubsectionsViaSymbols() const
Definition: MCAssembler.h:1006
uint64_t CommonSize
CommonSize - The size of the symbol, if it is 'common', or 0.
Definition: MCAssembler.h:691
MCSectionData & getOrCreateSectionData(const MCSection &Section, bool *Created=0)
Definition: MCAssembler.h:1134
static bool classof(const MCFragment *F)
Definition: MCAssembler.h:536
MCAsmBackend & getBackend() const
Definition: MCAssembler.h:994
const SmallString< 8 > & getContents() const
Definition: MCAssembler.h:532
size_t size() const
Definition: MCAssembler.h:637
void setFragment(MCFragment *Value)
Definition: MCAssembler.h:721
#define N
const_reverse_iterator rend() const
Definition: MCAssembler.h:635
fixup_iterator fixup_end()
Definition: MCAssembler.h:241
void setAlignment(unsigned Value)
Definition: MCAssembler.h:608
SmallString< 8 > & getContents()
Definition: MCAssembler.h:466
fixup_iterator fixup_begin()
Definition: MCAssembler.h:318
SectionDataListType::iterator iterator
Definition: MCAssembler.h:815
unsigned getValueSize() const
Definition: MCAssembler.h:405
static bool classof(const MCFragment *F)
Definition: MCAssembler.h:193
data_region_iterator data_region_end()
Definition: MCAssembler.h:1115
const_fixup_iterator fixup_begin() const
Definition: MCAssembler.h:319
void setLayoutOrder(unsigned Value)
Definition: MCAssembler.h:102
const_iterator begin() const
Definition: MCAssembler.h:1040
fixup_iterator fixup_begin()
Definition: MCAssembler.h:238
const_data_region_iterator data_region_end() const
Definition: MCAssembler.h:1118
iterator end()
Definition: ilist.h:367
LLVM Value Representation.
Definition: Value.h:66
MCAsmBackend - Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:34
bool isPrivateExtern() const
Definition: MCAssembler.h:733
indirect_symbol_iterator indirect_symbol_end()
Definition: MCAssembler.h:1080
cl::opt< bool > RelaxAll("mc-relax-all", cl::desc("When used with filetype=obj, ""relax all fixups in the emitted object file"))
void writeSectionData(const MCSectionData *Section, const MCAsmLayout &Layout) const
Emit the section contents using the given object writer.
const MCExpr & getValue() const
Definition: MCAssembler.h:462
virtual SmallVectorImpl< MCFixup > & getFixups()=0
unsigned getLayoutOrder() const
Definition: MCAssembler.h:101
static bool classof(const MCFragment *F)
Definition: MCAssembler.h:244
const_indirect_symbol_iterator indirect_symbol_begin() const
Definition: MCAssembler.h:1076
uint8_t getValue() const
Definition: MCAssembler.h:435
std::vector< DataRegionData > & getDataRegions()
Definition: MCAssembler.h:1104
int64_t getValue() const
Definition: MCAssembler.h:403
virtual ~MCFragment()
SmallString< 8 > & getContents()
Definition: MCAssembler.h:502
std::vector< IndirectSymbolData >::iterator indirect_symbol_iterator
Definition: MCAssembler.h:825
const MCSymbol * Symbol
Definition: MCAssembler.h:671
bool isThumbFunc(const MCSymbol *Func) const
Check whether a given symbol has been flagged with .thumb_func.
Definition: MCAssembler.h:963
MCCompactEncodedInstFragment(MCSectionData *SD=0)
Definition: MCAssembler.h:262
SymbolDataListType::iterator symbol_iterator
Definition: MCAssembler.h:818
iterator getSubsectionInsertionPoint(unsigned Subsection)
void setInst(const MCInst &Value)
Definition: MCAssembler.h:306
FragmentListType::iterator iterator
Definition: MCAssembler.h:554
virtual uint8_t getBundlePadding() const
Get the padding size that must be inserted before this fragment. Used for bundling. By default, no padding is inserted. Note that padding size is restricted to 8 bits. This is an optimization to reduce the amount of space used for each fragment. In practice, larger padding should never be required.
Definition: MCAssembler.h:146
SmallVectorImpl< MCFixup > & getFixups()
Definition: MCAssembler.h:308
size_t data_region_size() const
Definition: MCAssembler.h:1122
const_fixup_iterator fixup_end() const
Definition: MCAssembler.h:242
void modifyFlags(uint32_t Value, uint32_t Mask)
modifyFlags - Modify the flags via a mask
Definition: MCAssembler.h:776
bool isBundleGroupBeforeFirstInst() const
Definition: MCAssembler.h:655
symbol_iterator symbol_end()
Definition: MCAssembler.h:1057