1 //===- MCAssembler.h - Object File Generation -------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_MC_MCASSEMBLER_H
11 #define LLVM_MC_MCASSEMBLER_H
13 #include "llvm/MC/MCFixup.h"
14 #include "llvm/MC/MCInst.h"
15 #include "llvm/ADT/DenseMap.h"
16 #include "llvm/ADT/SmallPtrSet.h"
17 #include "llvm/ADT/SmallString.h"
18 #include "llvm/ADT/ilist.h"
19 #include "llvm/ADT/ilist_node.h"
20 #include "llvm/Support/Casting.h"
21 #include "llvm/Support/DataTypes.h"
22 #include <vector> // FIXME: Shouldn't be needed.
40 class MCFragment : public ilist_node<MCFragment> {
41 friend class MCAsmLayout;
43 MCFragment(const MCFragment&) LLVM_DELETED_FUNCTION;
44 void operator=(const MCFragment&) LLVM_DELETED_FUNCTION;
61 /// Parent - The data for the section this fragment is in.
62 MCSectionData *Parent;
64 /// Atom - The atom this fragment is in, as represented by it's defining
65 /// symbol. Atom's are only used by backends which set
66 /// \see MCAsmBackend::hasReliableSymbolDifference().
69 /// @name Assembler Backend Data
72 // FIXME: This could all be kept private to the assembler implementation.
74 /// Offset - The offset of this fragment in its section. This is ~0 until
78 /// LayoutOrder - The layout order of this fragment.
84 MCFragment(FragmentType _Kind, MCSectionData *_Parent = 0);
89 virtual ~MCFragment();
91 FragmentType getKind() const { return Kind; }
93 MCSectionData *getParent() const { return Parent; }
94 void setParent(MCSectionData *Value) { Parent = Value; }
96 MCSymbolData *getAtom() const { return Atom; }
97 void setAtom(MCSymbolData *Value) { Atom = Value; }
99 unsigned getLayoutOrder() const { return LayoutOrder; }
100 void setLayoutOrder(unsigned Value) { LayoutOrder = Value; }
105 class MCDataFragment : public MCFragment {
106 virtual void anchor();
107 SmallString<32> Contents;
109 /// Fixups - The list of fixups in this fragment.
110 std::vector<MCFixup> Fixups;
113 typedef std::vector<MCFixup>::const_iterator const_fixup_iterator;
114 typedef std::vector<MCFixup>::iterator fixup_iterator;
117 MCDataFragment(MCSectionData *SD = 0) : MCFragment(FT_Data, SD) {}
122 SmallString<32> &getContents() { return Contents; }
123 const SmallString<32> &getContents() const { return Contents; }
126 /// @name Fixup Access
129 void addFixup(MCFixup Fixup) {
130 // Enforce invariant that fixups are in offset order.
131 assert((Fixups.empty() || Fixup.getOffset() >= Fixups.back().getOffset()) &&
132 "Fixups must be added in order!");
133 Fixups.push_back(Fixup);
136 std::vector<MCFixup> &getFixups() { return Fixups; }
137 const std::vector<MCFixup> &getFixups() const { return Fixups; }
139 fixup_iterator fixup_begin() { return Fixups.begin(); }
140 const_fixup_iterator fixup_begin() const { return Fixups.begin(); }
142 fixup_iterator fixup_end() {return Fixups.end();}
143 const_fixup_iterator fixup_end() const {return Fixups.end();}
145 size_t fixup_size() const { return Fixups.size(); }
149 static bool classof(const MCFragment *F) {
150 return F->getKind() == MCFragment::FT_Data;
154 // FIXME: This current incarnation of MCInstFragment doesn't make much sense, as
155 // it is almost entirely a duplicate of MCDataFragment. If we decide to stick
156 // with this approach (as opposed to making MCInstFragment a very light weight
157 // object with just the MCInst and a code size, then we should just change
158 // MCDataFragment to have an optional MCInst at its end.
159 class MCInstFragment : public MCFragment {
160 virtual void anchor();
162 /// Inst - The instruction this is a fragment for.
165 /// Code - Binary data for the currently encoded instruction.
168 /// Fixups - The list of fixups in this fragment.
169 SmallVector<MCFixup, 1> Fixups;
172 typedef SmallVectorImpl<MCFixup>::const_iterator const_fixup_iterator;
173 typedef SmallVectorImpl<MCFixup>::iterator fixup_iterator;
176 MCInstFragment(const MCInst &_Inst, MCSectionData *SD = 0)
177 : MCFragment(FT_Inst, SD), Inst(_Inst) {
183 SmallVectorImpl<char> &getCode() { return Code; }
184 const SmallVectorImpl<char> &getCode() const { return Code; }
186 unsigned getInstSize() const { return Code.size(); }
188 MCInst &getInst() { return Inst; }
189 const MCInst &getInst() const { return Inst; }
191 void setInst(const MCInst& Value) { Inst = Value; }
194 /// @name Fixup Access
197 SmallVectorImpl<MCFixup> &getFixups() { return Fixups; }
198 const SmallVectorImpl<MCFixup> &getFixups() const { return Fixups; }
200 fixup_iterator fixup_begin() { return Fixups.begin(); }
201 const_fixup_iterator fixup_begin() const { return Fixups.begin(); }
203 fixup_iterator fixup_end() {return Fixups.end();}
204 const_fixup_iterator fixup_end() const {return Fixups.end();}
206 size_t fixup_size() const { return Fixups.size(); }
210 static bool classof(const MCFragment *F) {
211 return F->getKind() == MCFragment::FT_Inst;
215 class MCAlignFragment : public MCFragment {
216 virtual void anchor();
218 /// Alignment - The alignment to ensure, in bytes.
221 /// Value - Value to use for filling padding bytes.
224 /// ValueSize - The size of the integer (in bytes) of \p Value.
227 /// MaxBytesToEmit - The maximum number of bytes to emit; if the alignment
228 /// cannot be satisfied in this width then this fragment is ignored.
229 unsigned MaxBytesToEmit;
231 /// EmitNops - Flag to indicate that (optimal) NOPs should be emitted instead
232 /// of using the provided value. The exact interpretation of this flag is
233 /// target dependent.
237 MCAlignFragment(unsigned _Alignment, int64_t _Value, unsigned _ValueSize,
238 unsigned _MaxBytesToEmit, MCSectionData *SD = 0)
239 : MCFragment(FT_Align, SD), Alignment(_Alignment),
240 Value(_Value),ValueSize(_ValueSize),
241 MaxBytesToEmit(_MaxBytesToEmit), EmitNops(false) {}
246 unsigned getAlignment() const { return Alignment; }
248 int64_t getValue() const { return Value; }
250 unsigned getValueSize() const { return ValueSize; }
252 unsigned getMaxBytesToEmit() const { return MaxBytesToEmit; }
254 bool hasEmitNops() const { return EmitNops; }
255 void setEmitNops(bool Value) { EmitNops = Value; }
259 static bool classof(const MCFragment *F) {
260 return F->getKind() == MCFragment::FT_Align;
264 class MCFillFragment : public MCFragment {
265 virtual void anchor();
267 /// Value - Value to use for filling bytes.
270 /// ValueSize - The size (in bytes) of \p Value to use when filling, or 0 if
271 /// this is a virtual fill fragment.
274 /// Size - The number of bytes to insert.
278 MCFillFragment(int64_t _Value, unsigned _ValueSize, uint64_t _Size,
279 MCSectionData *SD = 0)
280 : MCFragment(FT_Fill, SD),
281 Value(_Value), ValueSize(_ValueSize), Size(_Size) {
282 assert((!ValueSize || (Size % ValueSize) == 0) &&
283 "Fill size must be a multiple of the value size!");
289 int64_t getValue() const { return Value; }
291 unsigned getValueSize() const { return ValueSize; }
293 uint64_t getSize() const { return Size; }
297 static bool classof(const MCFragment *F) {
298 return F->getKind() == MCFragment::FT_Fill;
302 class MCOrgFragment : public MCFragment {
303 virtual void anchor();
305 /// Offset - The offset this fragment should start at.
306 const MCExpr *Offset;
308 /// Value - Value to use for filling bytes.
312 MCOrgFragment(const MCExpr &_Offset, int8_t _Value, MCSectionData *SD = 0)
313 : MCFragment(FT_Org, SD),
314 Offset(&_Offset), Value(_Value) {}
319 const MCExpr &getOffset() const { return *Offset; }
321 uint8_t getValue() const { return Value; }
325 static bool classof(const MCFragment *F) {
326 return F->getKind() == MCFragment::FT_Org;
330 class MCLEBFragment : public MCFragment {
331 virtual void anchor();
333 /// Value - The value this fragment should contain.
336 /// IsSigned - True if this is a sleb128, false if uleb128.
339 SmallString<8> Contents;
341 MCLEBFragment(const MCExpr &Value_, bool IsSigned_, MCSectionData *SD)
342 : MCFragment(FT_LEB, SD),
343 Value(&Value_), IsSigned(IsSigned_) { Contents.push_back(0); }
348 const MCExpr &getValue() const { return *Value; }
350 bool isSigned() const { return IsSigned; }
352 SmallString<8> &getContents() { return Contents; }
353 const SmallString<8> &getContents() const { return Contents; }
357 static bool classof(const MCFragment *F) {
358 return F->getKind() == MCFragment::FT_LEB;
362 class MCDwarfLineAddrFragment : public MCFragment {
363 virtual void anchor();
365 /// LineDelta - the value of the difference between the two line numbers
366 /// between two .loc dwarf directives.
369 /// AddrDelta - The expression for the difference of the two symbols that
370 /// make up the address delta between two .loc dwarf directives.
371 const MCExpr *AddrDelta;
373 SmallString<8> Contents;
376 MCDwarfLineAddrFragment(int64_t _LineDelta, const MCExpr &_AddrDelta,
378 : MCFragment(FT_Dwarf, SD),
379 LineDelta(_LineDelta), AddrDelta(&_AddrDelta) { Contents.push_back(0); }
384 int64_t getLineDelta() const { return LineDelta; }
386 const MCExpr &getAddrDelta() const { return *AddrDelta; }
388 SmallString<8> &getContents() { return Contents; }
389 const SmallString<8> &getContents() const { return Contents; }
393 static bool classof(const MCFragment *F) {
394 return F->getKind() == MCFragment::FT_Dwarf;
398 class MCDwarfCallFrameFragment : public MCFragment {
399 virtual void anchor();
401 /// AddrDelta - The expression for the difference of the two symbols that
402 /// make up the address delta between two .cfi_* dwarf directives.
403 const MCExpr *AddrDelta;
405 SmallString<8> Contents;
408 MCDwarfCallFrameFragment(const MCExpr &_AddrDelta, MCSectionData *SD)
409 : MCFragment(FT_DwarfFrame, SD),
410 AddrDelta(&_AddrDelta) { Contents.push_back(0); }
415 const MCExpr &getAddrDelta() const { return *AddrDelta; }
417 SmallString<8> &getContents() { return Contents; }
418 const SmallString<8> &getContents() const { return Contents; }
422 static bool classof(const MCFragment *F) {
423 return F->getKind() == MCFragment::FT_DwarfFrame;
427 // FIXME: Should this be a separate class, or just merged into MCSection? Since
428 // we anticipate the fast path being through an MCAssembler, the only reason to
429 // keep it out is for API abstraction.
430 class MCSectionData : public ilist_node<MCSectionData> {
431 friend class MCAsmLayout;
433 MCSectionData(const MCSectionData&) LLVM_DELETED_FUNCTION;
434 void operator=(const MCSectionData&) LLVM_DELETED_FUNCTION;
437 typedef iplist<MCFragment> FragmentListType;
439 typedef FragmentListType::const_iterator const_iterator;
440 typedef FragmentListType::iterator iterator;
442 typedef FragmentListType::const_reverse_iterator const_reverse_iterator;
443 typedef FragmentListType::reverse_iterator reverse_iterator;
446 FragmentListType Fragments;
447 const MCSection *Section;
449 /// Ordinal - The section index in the assemblers section list.
452 /// LayoutOrder - The index of this section in the layout order.
453 unsigned LayoutOrder;
455 /// Alignment - The maximum alignment seen in this section.
458 /// @name Assembler Backend Data
461 // FIXME: This could all be kept private to the assembler implementation.
463 /// HasInstructions - Whether this section has had instructions emitted into
465 unsigned HasInstructions : 1;
470 // Only for use as sentinel.
472 MCSectionData(const MCSection &Section, MCAssembler *A = 0);
474 const MCSection &getSection() const { return *Section; }
476 unsigned getAlignment() const { return Alignment; }
477 void setAlignment(unsigned Value) { Alignment = Value; }
479 bool hasInstructions() const { return HasInstructions; }
480 void setHasInstructions(bool Value) { HasInstructions = Value; }
482 unsigned getOrdinal() const { return Ordinal; }
483 void setOrdinal(unsigned Value) { Ordinal = Value; }
485 unsigned getLayoutOrder() const { return LayoutOrder; }
486 void setLayoutOrder(unsigned Value) { LayoutOrder = Value; }
488 /// @name Fragment Access
491 const FragmentListType &getFragmentList() const { return Fragments; }
492 FragmentListType &getFragmentList() { return Fragments; }
494 iterator begin() { return Fragments.begin(); }
495 const_iterator begin() const { return Fragments.begin(); }
497 iterator end() { return Fragments.end(); }
498 const_iterator end() const { return Fragments.end(); }
500 reverse_iterator rbegin() { return Fragments.rbegin(); }
501 const_reverse_iterator rbegin() const { return Fragments.rbegin(); }
503 reverse_iterator rend() { return Fragments.rend(); }
504 const_reverse_iterator rend() const { return Fragments.rend(); }
506 size_t size() const { return Fragments.size(); }
508 bool empty() const { return Fragments.empty(); }
515 // FIXME: Same concerns as with SectionData.
516 class MCSymbolData : public ilist_node<MCSymbolData> {
518 const MCSymbol *Symbol;
520 /// Fragment - The fragment this symbol's value is relative to, if any.
521 MCFragment *Fragment;
523 /// Offset - The offset to apply to the fragment address to form this symbol's
527 /// IsExternal - True if this symbol is visible outside this translation
529 unsigned IsExternal : 1;
531 /// IsPrivateExtern - True if this symbol is private extern.
532 unsigned IsPrivateExtern : 1;
534 /// CommonSize - The size of the symbol, if it is 'common', or 0.
536 // FIXME: Pack this in with other fields? We could put it in offset, since a
537 // common symbol can never get a definition.
540 /// SymbolSize - An expression describing how to calculate the size of
541 /// a symbol. If a symbol has no size this field will be NULL.
542 const MCExpr *SymbolSize;
544 /// CommonAlign - The alignment of the symbol, if it is 'common'.
546 // FIXME: Pack this in with other fields?
547 unsigned CommonAlign;
549 /// Flags - The Flags field is used by object file implementations to store
550 /// additional per symbol information which is not easily classified.
553 /// Index - Index field, for use by the object file implementation.
557 // Only for use as sentinel.
559 MCSymbolData(const MCSymbol &_Symbol, MCFragment *_Fragment, uint64_t _Offset,
565 const MCSymbol &getSymbol() const { return *Symbol; }
567 MCFragment *getFragment() const { return Fragment; }
568 void setFragment(MCFragment *Value) { Fragment = Value; }
570 uint64_t getOffset() const { return Offset; }
571 void setOffset(uint64_t Value) { Offset = Value; }
574 /// @name Symbol Attributes
577 bool isExternal() const { return IsExternal; }
578 void setExternal(bool Value) { IsExternal = Value; }
580 bool isPrivateExtern() const { return IsPrivateExtern; }
581 void setPrivateExtern(bool Value) { IsPrivateExtern = Value; }
583 /// isCommon - Is this a 'common' symbol.
584 bool isCommon() const { return CommonSize != 0; }
586 /// setCommon - Mark this symbol as being 'common'.
588 /// \param Size - The size of the symbol.
589 /// \param Align - The alignment of the symbol.
590 void setCommon(uint64_t Size, unsigned Align) {
595 /// getCommonSize - Return the size of a 'common' symbol.
596 uint64_t getCommonSize() const {
597 assert(isCommon() && "Not a 'common' symbol!");
601 void setSize(const MCExpr *SS) {
605 const MCExpr *getSize() const {
610 /// getCommonAlignment - Return the alignment of a 'common' symbol.
611 unsigned getCommonAlignment() const {
612 assert(isCommon() && "Not a 'common' symbol!");
616 /// getFlags - Get the (implementation defined) symbol flags.
617 uint32_t getFlags() const { return Flags; }
619 /// setFlags - Set the (implementation defined) symbol flags.
620 void setFlags(uint32_t Value) { Flags = Value; }
622 /// modifyFlags - Modify the flags via a mask
623 void modifyFlags(uint32_t Value, uint32_t Mask) {
624 Flags = (Flags & ~Mask) | Value;
627 /// getIndex - Get the (implementation defined) index.
628 uint64_t getIndex() const { return Index; }
630 /// setIndex - Set the (implementation defined) index.
631 void setIndex(uint64_t Value) { Index = Value; }
638 // FIXME: This really doesn't belong here. See comments below.
639 struct IndirectSymbolData {
641 MCSectionData *SectionData;
644 // FIXME: Ditto this. Purely so the Streamer and the ObjectWriter can talk
646 struct DataRegionData {
647 // This enum should be kept in sync w/ the mach-o definition in
648 // llvm/Object/MachOFormat.h.
649 enum KindTy { Data = 1, JumpTable8, JumpTable16, JumpTable32 } Kind;
655 friend class MCAsmLayout;
658 typedef iplist<MCSectionData> SectionDataListType;
659 typedef iplist<MCSymbolData> SymbolDataListType;
661 typedef SectionDataListType::const_iterator const_iterator;
662 typedef SectionDataListType::iterator iterator;
664 typedef SymbolDataListType::const_iterator const_symbol_iterator;
665 typedef SymbolDataListType::iterator symbol_iterator;
667 typedef std::vector<IndirectSymbolData>::const_iterator
668 const_indirect_symbol_iterator;
669 typedef std::vector<IndirectSymbolData>::iterator indirect_symbol_iterator;
671 typedef std::vector<DataRegionData>::const_iterator
672 const_data_region_iterator;
673 typedef std::vector<DataRegionData>::iterator data_region_iterator;
676 MCAssembler(const MCAssembler&) LLVM_DELETED_FUNCTION;
677 void operator=(const MCAssembler&) LLVM_DELETED_FUNCTION;
681 MCAsmBackend &Backend;
683 MCCodeEmitter &Emitter;
685 MCObjectWriter &Writer;
689 iplist<MCSectionData> Sections;
691 iplist<MCSymbolData> Symbols;
693 /// The map of sections to their associated assembler backend data.
695 // FIXME: Avoid this indirection?
696 DenseMap<const MCSection*, MCSectionData*> SectionMap;
698 /// The map of symbols to their associated assembler backend data.
700 // FIXME: Avoid this indirection?
701 DenseMap<const MCSymbol*, MCSymbolData*> SymbolMap;
703 std::vector<IndirectSymbolData> IndirectSymbols;
705 std::vector<DataRegionData> DataRegions;
706 /// The set of function symbols for which a .thumb_func directive has
709 // FIXME: We really would like this in target specific code rather than
710 // here. Maybe when the relocation stuff moves to target specific,
711 // this can go with it? The streamer would need some target specific
713 SmallPtrSet<const MCSymbol*, 64> ThumbFuncs;
715 unsigned RelaxAll : 1;
716 unsigned NoExecStack : 1;
717 unsigned SubsectionsViaSymbols : 1;
720 /// Evaluate a fixup to a relocatable expression and the value which should be
721 /// placed into the fixup.
723 /// \param Layout The layout to use for evaluation.
724 /// \param Fixup The fixup to evaluate.
725 /// \param DF The fragment the fixup is inside.
726 /// \param Target [out] On return, the relocatable expression the fixup
728 /// \param Value [out] On return, the value of the fixup as currently laid
730 /// \return Whether the fixup value was fully resolved. This is true if the
731 /// \p Value result is fixed, otherwise the value may change due to
733 bool evaluateFixup(const MCAsmLayout &Layout,
734 const MCFixup &Fixup, const MCFragment *DF,
735 MCValue &Target, uint64_t &Value) const;
737 /// Check whether a fixup can be satisfied, or whether it needs to be relaxed
738 /// (increased in size, in order to hold its value correctly).
739 bool fixupNeedsRelaxation(const MCFixup &Fixup, const MCInstFragment *DF,
740 const MCAsmLayout &Layout) const;
742 /// Check whether the given fragment needs relaxation.
743 bool fragmentNeedsRelaxation(const MCInstFragment *IF,
744 const MCAsmLayout &Layout) const;
746 /// layoutOnce - Perform one layout iteration and return true if any offsets
748 bool layoutOnce(MCAsmLayout &Layout);
750 bool layoutSectionOnce(MCAsmLayout &Layout, MCSectionData &SD);
752 bool relaxInstruction(MCAsmLayout &Layout, MCInstFragment &IF);
754 bool relaxLEB(MCAsmLayout &Layout, MCLEBFragment &IF);
756 bool relaxDwarfLineAddr(MCAsmLayout &Layout, MCDwarfLineAddrFragment &DF);
757 bool relaxDwarfCallFrameFragment(MCAsmLayout &Layout,
758 MCDwarfCallFrameFragment &DF);
760 /// finishLayout - Finalize a layout, including fragment lowering.
761 void finishLayout(MCAsmLayout &Layout);
763 uint64_t handleFixup(const MCAsmLayout &Layout,
764 MCFragment &F, const MCFixup &Fixup);
767 /// Compute the effective fragment size assuming it is laid out at the given
768 /// \p SectionAddress and \p FragmentOffset.
769 uint64_t computeFragmentSize(const MCAsmLayout &Layout,
770 const MCFragment &F) const;
772 /// Find the symbol which defines the atom containing the given symbol, or
773 /// null if there is no such symbol.
774 const MCSymbolData *getAtom(const MCSymbolData *Symbol) const;
776 /// Check whether a particular symbol is visible to the linker and is required
777 /// in the symbol table, or whether it can be discarded by the assembler. This
778 /// also effects whether the assembler treats the label as potentially
779 /// defining a separate atom.
780 bool isSymbolLinkerVisible(const MCSymbol &SD) const;
782 /// Emit the section contents using the given object writer.
783 void writeSectionData(const MCSectionData *Section,
784 const MCAsmLayout &Layout) const;
786 /// Check whether a given symbol has been flagged with .thumb_func.
787 bool isThumbFunc(const MCSymbol *Func) const {
788 return ThumbFuncs.count(Func);
791 /// Flag a function symbol as the target of a .thumb_func directive.
792 void setIsThumbFunc(const MCSymbol *Func) { ThumbFuncs.insert(Func); }
795 /// Construct a new assembler instance.
797 /// \param OS The stream to output to.
799 // FIXME: How are we going to parameterize this? Two obvious options are stay
800 // concrete and require clients to pass in a target like object. The other
801 // option is to make this abstract, and have targets provide concrete
802 // implementations as we do with AsmParser.
803 MCAssembler(MCContext &Context_, MCAsmBackend &Backend_,
804 MCCodeEmitter &Emitter_, MCObjectWriter &Writer_,
808 MCContext &getContext() const { return Context; }
810 MCAsmBackend &getBackend() const { return Backend; }
812 MCCodeEmitter &getEmitter() const { return Emitter; }
814 MCObjectWriter &getWriter() const { return Writer; }
816 /// Finish - Do final processing and write the object to the output stream.
817 /// \p Writer is used for custom object writer (as the MCJIT does),
818 /// if not specified it is automatically created from backend.
821 // FIXME: This does not belong here.
822 bool getSubsectionsViaSymbols() const {
823 return SubsectionsViaSymbols;
825 void setSubsectionsViaSymbols(bool Value) {
826 SubsectionsViaSymbols = Value;
829 bool getRelaxAll() const { return RelaxAll; }
830 void setRelaxAll(bool Value) { RelaxAll = Value; }
832 bool getNoExecStack() const { return NoExecStack; }
833 void setNoExecStack(bool Value) { NoExecStack = Value; }
835 /// @name Section List Access
838 const SectionDataListType &getSectionList() const { return Sections; }
839 SectionDataListType &getSectionList() { return Sections; }
841 iterator begin() { return Sections.begin(); }
842 const_iterator begin() const { return Sections.begin(); }
844 iterator end() { return Sections.end(); }
845 const_iterator end() const { return Sections.end(); }
847 size_t size() const { return Sections.size(); }
850 /// @name Symbol List Access
853 const SymbolDataListType &getSymbolList() const { return Symbols; }
854 SymbolDataListType &getSymbolList() { return Symbols; }
856 symbol_iterator symbol_begin() { return Symbols.begin(); }
857 const_symbol_iterator symbol_begin() const { return Symbols.begin(); }
859 symbol_iterator symbol_end() { return Symbols.end(); }
860 const_symbol_iterator symbol_end() const { return Symbols.end(); }
862 size_t symbol_size() const { return Symbols.size(); }
865 /// @name Indirect Symbol List Access
868 // FIXME: This is a total hack, this should not be here. Once things are
869 // factored so that the streamer has direct access to the .o writer, it can
871 std::vector<IndirectSymbolData> &getIndirectSymbols() {
872 return IndirectSymbols;
875 indirect_symbol_iterator indirect_symbol_begin() {
876 return IndirectSymbols.begin();
878 const_indirect_symbol_iterator indirect_symbol_begin() const {
879 return IndirectSymbols.begin();
882 indirect_symbol_iterator indirect_symbol_end() {
883 return IndirectSymbols.end();
885 const_indirect_symbol_iterator indirect_symbol_end() const {
886 return IndirectSymbols.end();
889 size_t indirect_symbol_size() const { return IndirectSymbols.size(); }
892 /// @name Data Region List Access
895 // FIXME: This is a total hack, this should not be here. Once things are
896 // factored so that the streamer has direct access to the .o writer, it can
898 std::vector<DataRegionData> &getDataRegions() {
902 data_region_iterator data_region_begin() {
903 return DataRegions.begin();
905 const_data_region_iterator data_region_begin() const {
906 return DataRegions.begin();
909 data_region_iterator data_region_end() {
910 return DataRegions.end();
912 const_data_region_iterator data_region_end() const {
913 return DataRegions.end();
916 size_t data_region_size() const { return DataRegions.size(); }
919 /// @name Backend Data Access
922 MCSectionData &getSectionData(const MCSection &Section) const {
923 MCSectionData *Entry = SectionMap.lookup(&Section);
924 assert(Entry && "Missing section data!");
928 MCSectionData &getOrCreateSectionData(const MCSection &Section,
930 MCSectionData *&Entry = SectionMap[&Section];
932 if (Created) *Created = !Entry;
934 Entry = new MCSectionData(Section, this);
939 MCSymbolData &getSymbolData(const MCSymbol &Symbol) const {
940 MCSymbolData *Entry = SymbolMap.lookup(&Symbol);
941 assert(Entry && "Missing symbol data!");
945 MCSymbolData &getOrCreateSymbolData(const MCSymbol &Symbol,
947 MCSymbolData *&Entry = SymbolMap[&Symbol];
949 if (Created) *Created = !Entry;
951 Entry = new MCSymbolData(Symbol, 0, 0, this);
961 } // end namespace llvm