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/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/Support/Casting.h"
19 #include "llvm/MC/MCFixup.h"
20 #include "llvm/MC/MCInst.h"
21 #include "llvm/Support/DataTypes.h"
22 #include <vector> // FIXME: Shouldn't be needed.
39 class TargetAsmBackend;
41 class MCFragment : public ilist_node<MCFragment> {
42 friend class MCAsmLayout;
44 MCFragment(const MCFragment&); // DO NOT IMPLEMENT
45 void operator=(const MCFragment&); // DO NOT IMPLEMENT
62 /// Parent - The data for the section this fragment is in.
63 MCSectionData *Parent;
65 /// Atom - The atom this fragment is in, as represented by it's defining
66 /// symbol. Atom's are only used by backends which set
67 /// \see MCAsmBackend::hasReliableSymbolDifference().
70 /// @name Assembler Backend Data
73 // FIXME: This could all be kept private to the assembler implementation.
75 /// Offset - The offset of this fragment in its section. This is ~0 until
79 /// LayoutOrder - The layout order of this fragment.
85 MCFragment(FragmentType _Kind, MCSectionData *_Parent = 0);
90 virtual ~MCFragment();
92 FragmentType getKind() const { return Kind; }
94 MCSectionData *getParent() const { return Parent; }
95 void setParent(MCSectionData *Value) { Parent = Value; }
97 MCSymbolData *getAtom() const { return Atom; }
98 void setAtom(MCSymbolData *Value) { Atom = Value; }
100 unsigned getLayoutOrder() const { return LayoutOrder; }
101 void setLayoutOrder(unsigned Value) { LayoutOrder = Value; }
103 static bool classof(const MCFragment *O) { return true; }
108 class MCDataFragment : public MCFragment {
109 SmallString<32> Contents;
111 /// Fixups - The list of fixups in this fragment.
112 std::vector<MCFixup> Fixups;
115 typedef std::vector<MCFixup>::const_iterator const_fixup_iterator;
116 typedef std::vector<MCFixup>::iterator fixup_iterator;
119 MCDataFragment(MCSectionData *SD = 0) : MCFragment(FT_Data, SD) {}
124 SmallString<32> &getContents() { return Contents; }
125 const SmallString<32> &getContents() const { return Contents; }
128 /// @name Fixup Access
131 void addFixup(MCFixup Fixup) {
132 // Enforce invariant that fixups are in offset order.
133 assert((Fixups.empty() || Fixup.getOffset() > Fixups.back().getOffset()) &&
134 "Fixups must be added in order!");
135 Fixups.push_back(Fixup);
138 std::vector<MCFixup> &getFixups() { return Fixups; }
139 const std::vector<MCFixup> &getFixups() const { return Fixups; }
141 fixup_iterator fixup_begin() { return Fixups.begin(); }
142 const_fixup_iterator fixup_begin() const { return Fixups.begin(); }
144 fixup_iterator fixup_end() {return Fixups.end();}
145 const_fixup_iterator fixup_end() const {return Fixups.end();}
147 size_t fixup_size() const { return Fixups.size(); }
151 static bool classof(const MCFragment *F) {
152 return F->getKind() == MCFragment::FT_Data;
154 static bool classof(const MCDataFragment *) { return true; }
157 // FIXME: This current incarnation of MCInstFragment doesn't make much sense, as
158 // it is almost entirely a duplicate of MCDataFragment. If we decide to stick
159 // with this approach (as opposed to making MCInstFragment a very light weight
160 // object with just the MCInst and a code size, then we should just change
161 // MCDataFragment to have an optional MCInst at its end.
162 class MCInstFragment : public MCFragment {
163 /// Inst - The instruction this is a fragment for.
166 /// Code - Binary data for the currently encoded instruction.
169 /// Fixups - The list of fixups in this fragment.
170 SmallVector<MCFixup, 1> Fixups;
173 typedef SmallVectorImpl<MCFixup>::const_iterator const_fixup_iterator;
174 typedef SmallVectorImpl<MCFixup>::iterator fixup_iterator;
177 MCInstFragment(MCInst _Inst, MCSectionData *SD = 0)
178 : MCFragment(FT_Inst, SD), Inst(_Inst) {
184 SmallVectorImpl<char> &getCode() { return Code; }
185 const SmallVectorImpl<char> &getCode() const { return Code; }
187 unsigned getInstSize() const { return Code.size(); }
189 MCInst &getInst() { return Inst; }
190 const MCInst &getInst() const { return Inst; }
192 void setInst(MCInst Value) { Inst = Value; }
195 /// @name Fixup Access
198 SmallVectorImpl<MCFixup> &getFixups() { return Fixups; }
199 const SmallVectorImpl<MCFixup> &getFixups() const { return Fixups; }
201 fixup_iterator fixup_begin() { return Fixups.begin(); }
202 const_fixup_iterator fixup_begin() const { return Fixups.begin(); }
204 fixup_iterator fixup_end() {return Fixups.end();}
205 const_fixup_iterator fixup_end() const {return Fixups.end();}
207 size_t fixup_size() const { return Fixups.size(); }
211 static bool classof(const MCFragment *F) {
212 return F->getKind() == MCFragment::FT_Inst;
214 static bool classof(const MCInstFragment *) { return true; }
217 class MCAlignFragment : public MCFragment {
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 \arg 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;
262 static bool classof(const MCAlignFragment *) { return true; }
265 class MCFillFragment : public MCFragment {
266 /// Value - Value to use for filling bytes.
269 /// ValueSize - The size (in bytes) of \arg Value to use when filling, or 0 if
270 /// this is a virtual fill fragment.
273 /// Size - The number of bytes to insert.
277 MCFillFragment(int64_t _Value, unsigned _ValueSize, uint64_t _Size,
278 MCSectionData *SD = 0)
279 : MCFragment(FT_Fill, SD),
280 Value(_Value), ValueSize(_ValueSize), Size(_Size) {
281 assert((!ValueSize || (Size % ValueSize) == 0) &&
282 "Fill size must be a multiple of the value size!");
288 int64_t getValue() const { return Value; }
290 unsigned getValueSize() const { return ValueSize; }
292 uint64_t getSize() const { return Size; }
296 static bool classof(const MCFragment *F) {
297 return F->getKind() == MCFragment::FT_Fill;
299 static bool classof(const MCFillFragment *) { return true; }
302 class MCOrgFragment : public MCFragment {
303 /// Offset - The offset this fragment should start at.
304 const MCExpr *Offset;
306 /// Value - Value to use for filling bytes.
310 MCOrgFragment(const MCExpr &_Offset, int8_t _Value, MCSectionData *SD = 0)
311 : MCFragment(FT_Org, SD),
312 Offset(&_Offset), Value(_Value) {}
317 const MCExpr &getOffset() const { return *Offset; }
319 uint8_t getValue() const { return Value; }
323 static bool classof(const MCFragment *F) {
324 return F->getKind() == MCFragment::FT_Org;
326 static bool classof(const MCOrgFragment *) { return true; }
329 class MCLEBFragment : public MCFragment {
330 /// Value - The value this fragment should contain.
333 /// IsSigned - True if this is a sleb128, false if uleb128.
336 SmallString<8> Contents;
338 MCLEBFragment(const MCExpr &Value_, bool IsSigned_, MCSectionData *SD)
339 : MCFragment(FT_LEB, SD),
340 Value(&Value_), IsSigned(IsSigned_) { Contents.push_back(0); }
345 const MCExpr &getValue() const { return *Value; }
347 bool isSigned() const { return IsSigned; }
349 SmallString<8> &getContents() { return Contents; }
350 const SmallString<8> &getContents() const { return Contents; }
354 static bool classof(const MCFragment *F) {
355 return F->getKind() == MCFragment::FT_LEB;
357 static bool classof(const MCLEBFragment *) { return true; }
360 class MCDwarfLineAddrFragment : public MCFragment {
361 /// LineDelta - the value of the difference between the two line numbers
362 /// between two .loc dwarf directives.
365 /// AddrDelta - The expression for the difference of the two symbols that
366 /// make up the address delta between two .loc dwarf directives.
367 const MCExpr *AddrDelta;
369 SmallString<8> Contents;
372 MCDwarfLineAddrFragment(int64_t _LineDelta, const MCExpr &_AddrDelta,
374 : MCFragment(FT_Dwarf, SD),
375 LineDelta(_LineDelta), AddrDelta(&_AddrDelta) { Contents.push_back(0); }
380 int64_t getLineDelta() const { return LineDelta; }
382 const MCExpr &getAddrDelta() const { return *AddrDelta; }
384 SmallString<8> &getContents() { return Contents; }
385 const SmallString<8> &getContents() const { return Contents; }
389 static bool classof(const MCFragment *F) {
390 return F->getKind() == MCFragment::FT_Dwarf;
392 static bool classof(const MCDwarfLineAddrFragment *) { return true; }
395 class MCDwarfCallFrameFragment : public MCFragment {
396 /// AddrDelta - The expression for the difference of the two symbols that
397 /// make up the address delta between two .cfi_* dwarf directives.
398 const MCExpr *AddrDelta;
400 SmallString<8> Contents;
403 MCDwarfCallFrameFragment(const MCExpr &_AddrDelta, MCSectionData *SD)
404 : MCFragment(FT_DwarfFrame, SD),
405 AddrDelta(&_AddrDelta) { Contents.push_back(0); }
410 const MCExpr &getAddrDelta() const { return *AddrDelta; }
412 SmallString<8> &getContents() { return Contents; }
413 const SmallString<8> &getContents() const { return Contents; }
417 static bool classof(const MCFragment *F) {
418 return F->getKind() == MCFragment::FT_DwarfFrame;
420 static bool classof(const MCDwarfCallFrameFragment *) { return true; }
423 // FIXME: Should this be a separate class, or just merged into MCSection? Since
424 // we anticipate the fast path being through an MCAssembler, the only reason to
425 // keep it out is for API abstraction.
426 class MCSectionData : public ilist_node<MCSectionData> {
427 friend class MCAsmLayout;
429 MCSectionData(const MCSectionData&); // DO NOT IMPLEMENT
430 void operator=(const MCSectionData&); // DO NOT IMPLEMENT
433 typedef iplist<MCFragment> FragmentListType;
435 typedef FragmentListType::const_iterator const_iterator;
436 typedef FragmentListType::iterator iterator;
438 typedef FragmentListType::const_reverse_iterator const_reverse_iterator;
439 typedef FragmentListType::reverse_iterator reverse_iterator;
442 FragmentListType Fragments;
443 const MCSection *Section;
445 /// Ordinal - The section index in the assemblers section list.
448 /// LayoutOrder - The index of this section in the layout order.
449 unsigned LayoutOrder;
451 /// Alignment - The maximum alignment seen in this section.
454 /// @name Assembler Backend Data
457 // FIXME: This could all be kept private to the assembler implementation.
459 /// HasInstructions - Whether this section has had instructions emitted into
461 unsigned HasInstructions : 1;
466 // Only for use as sentinel.
468 MCSectionData(const MCSection &Section, MCAssembler *A = 0);
470 const MCSection &getSection() const { return *Section; }
472 unsigned getAlignment() const { return Alignment; }
473 void setAlignment(unsigned Value) { Alignment = Value; }
475 bool hasInstructions() const { return HasInstructions; }
476 void setHasInstructions(bool Value) { HasInstructions = Value; }
478 unsigned getOrdinal() const { return Ordinal; }
479 void setOrdinal(unsigned Value) { Ordinal = Value; }
481 unsigned getLayoutOrder() const { return LayoutOrder; }
482 void setLayoutOrder(unsigned Value) { LayoutOrder = Value; }
484 /// @name Fragment Access
487 const FragmentListType &getFragmentList() const { return Fragments; }
488 FragmentListType &getFragmentList() { return Fragments; }
490 iterator begin() { return Fragments.begin(); }
491 const_iterator begin() const { return Fragments.begin(); }
493 iterator end() { return Fragments.end(); }
494 const_iterator end() const { return Fragments.end(); }
496 reverse_iterator rbegin() { return Fragments.rbegin(); }
497 const_reverse_iterator rbegin() const { return Fragments.rbegin(); }
499 reverse_iterator rend() { return Fragments.rend(); }
500 const_reverse_iterator rend() const { return Fragments.rend(); }
502 size_t size() const { return Fragments.size(); }
504 bool empty() const { return Fragments.empty(); }
511 // FIXME: Same concerns as with SectionData.
512 class MCSymbolData : public ilist_node<MCSymbolData> {
514 const MCSymbol *Symbol;
516 /// Fragment - The fragment this symbol's value is relative to, if any.
517 MCFragment *Fragment;
519 /// Offset - The offset to apply to the fragment address to form this symbol's
523 /// IsExternal - True if this symbol is visible outside this translation
525 unsigned IsExternal : 1;
527 /// IsPrivateExtern - True if this symbol is private extern.
528 unsigned IsPrivateExtern : 1;
530 /// CommonSize - The size of the symbol, if it is 'common', or 0.
532 // FIXME: Pack this in with other fields? We could put it in offset, since a
533 // common symbol can never get a definition.
536 /// SymbolSize - An expression describing how to calculate the size of
537 /// a symbol. If a symbol has no size this field will be NULL.
538 const MCExpr *SymbolSize;
540 /// CommonAlign - The alignment of the symbol, if it is 'common'.
542 // FIXME: Pack this in with other fields?
543 unsigned CommonAlign;
545 /// Flags - The Flags field is used by object file implementations to store
546 /// additional per symbol information which is not easily classified.
549 /// Index - Index field, for use by the object file implementation.
553 // Only for use as sentinel.
555 MCSymbolData(const MCSymbol &_Symbol, MCFragment *_Fragment, uint64_t _Offset,
561 const MCSymbol &getSymbol() const { return *Symbol; }
563 MCFragment *getFragment() const { return Fragment; }
564 void setFragment(MCFragment *Value) { Fragment = Value; }
566 uint64_t getOffset() const { return Offset; }
567 void setOffset(uint64_t Value) { Offset = Value; }
570 /// @name Symbol Attributes
573 bool isExternal() const { return IsExternal; }
574 void setExternal(bool Value) { IsExternal = Value; }
576 bool isPrivateExtern() const { return IsPrivateExtern; }
577 void setPrivateExtern(bool Value) { IsPrivateExtern = Value; }
579 /// isCommon - Is this a 'common' symbol.
580 bool isCommon() const { return CommonSize != 0; }
582 /// setCommon - Mark this symbol as being 'common'.
584 /// \param Size - The size of the symbol.
585 /// \param Align - The alignment of the symbol.
586 void setCommon(uint64_t Size, unsigned Align) {
591 /// getCommonSize - Return the size of a 'common' symbol.
592 uint64_t getCommonSize() const {
593 assert(isCommon() && "Not a 'common' symbol!");
597 void setSize(const MCExpr *SS) {
601 const MCExpr *getSize() const {
606 /// getCommonAlignment - Return the alignment of a 'common' symbol.
607 unsigned getCommonAlignment() const {
608 assert(isCommon() && "Not a 'common' symbol!");
612 /// getFlags - Get the (implementation defined) symbol flags.
613 uint32_t getFlags() const { return Flags; }
615 /// setFlags - Set the (implementation defined) symbol flags.
616 void setFlags(uint32_t Value) { Flags = Value; }
618 /// modifyFlags - Modify the flags via a mask
619 void modifyFlags(uint32_t Value, uint32_t Mask) {
620 Flags = (Flags & ~Mask) | Value;
623 /// getIndex - Get the (implementation defined) index.
624 uint64_t getIndex() const { return Index; }
626 /// setIndex - Set the (implementation defined) index.
627 void setIndex(uint64_t Value) { Index = Value; }
634 // FIXME: This really doesn't belong here. See comments below.
635 struct IndirectSymbolData {
637 MCSectionData *SectionData;
641 friend class MCAsmLayout;
644 typedef iplist<MCSectionData> SectionDataListType;
645 typedef iplist<MCSymbolData> SymbolDataListType;
647 typedef SectionDataListType::const_iterator const_iterator;
648 typedef SectionDataListType::iterator iterator;
650 typedef SymbolDataListType::const_iterator const_symbol_iterator;
651 typedef SymbolDataListType::iterator symbol_iterator;
653 typedef std::vector<IndirectSymbolData>::const_iterator
654 const_indirect_symbol_iterator;
655 typedef std::vector<IndirectSymbolData>::iterator indirect_symbol_iterator;
658 MCAssembler(const MCAssembler&); // DO NOT IMPLEMENT
659 void operator=(const MCAssembler&); // DO NOT IMPLEMENT
663 TargetAsmBackend &Backend;
665 MCCodeEmitter &Emitter;
667 MCObjectWriter &Writer;
671 iplist<MCSectionData> Sections;
673 iplist<MCSymbolData> Symbols;
675 /// The map of sections to their associated assembler backend data.
677 // FIXME: Avoid this indirection?
678 DenseMap<const MCSection*, MCSectionData*> SectionMap;
680 /// The map of symbols to their associated assembler backend data.
682 // FIXME: Avoid this indirection?
683 DenseMap<const MCSymbol*, MCSymbolData*> SymbolMap;
685 std::vector<IndirectSymbolData> IndirectSymbols;
687 /// The set of function symbols for which a .thumb_func directive has
690 // FIXME: We really would like this in target specific code rather than
691 // here. Maybe when the relocation stuff moves to target specific,
692 // this can go with it? The streamer would need some target specific
694 SmallPtrSet<const MCSymbol*, 64> ThumbFuncs;
696 unsigned RelaxAll : 1;
697 unsigned NoExecStack : 1;
698 unsigned SubsectionsViaSymbols : 1;
701 /// Evaluate a fixup to a relocatable expression and the value which should be
702 /// placed into the fixup.
704 /// \param Layout The layout to use for evaluation.
705 /// \param Fixup The fixup to evaluate.
706 /// \param DF The fragment the fixup is inside.
707 /// \param Target [out] On return, the relocatable expression the fixup
709 /// \param Value [out] On return, the value of the fixup as currently laid
711 /// \return Whether the fixup value was fully resolved. This is true if the
712 /// \arg Value result is fixed, otherwise the value may change due to
714 bool EvaluateFixup(const MCAsmLayout &Layout,
715 const MCFixup &Fixup, const MCFragment *DF,
716 MCValue &Target, uint64_t &Value) const;
718 /// Check whether a fixup can be satisfied, or whether it needs to be relaxed
719 /// (increased in size, in order to hold its value correctly).
720 bool FixupNeedsRelaxation(const MCFixup &Fixup, const MCFragment *DF,
721 const MCAsmLayout &Layout) const;
723 /// Check whether the given fragment needs relaxation.
724 bool FragmentNeedsRelaxation(const MCInstFragment *IF,
725 const MCAsmLayout &Layout) const;
727 /// LayoutOnce - Perform one layout iteration and return true if any offsets
729 bool LayoutOnce(MCAsmLayout &Layout);
731 bool LayoutSectionOnce(MCAsmLayout &Layout, MCSectionData &SD);
733 bool RelaxInstruction(MCAsmLayout &Layout, MCInstFragment &IF);
735 bool RelaxLEB(MCAsmLayout &Layout, MCLEBFragment &IF);
737 bool RelaxDwarfLineAddr(MCAsmLayout &Layout, MCDwarfLineAddrFragment &DF);
738 bool RelaxDwarfCallFrameFragment(MCAsmLayout &Layout,
739 MCDwarfCallFrameFragment &DF);
741 /// FinishLayout - Finalize a layout, including fragment lowering.
742 void FinishLayout(MCAsmLayout &Layout);
744 uint64_t HandleFixup(const MCAsmLayout &Layout,
745 MCFragment &F, const MCFixup &Fixup);
748 /// Compute the effective fragment size assuming it is laid out at the given
749 /// \arg SectionAddress and \arg FragmentOffset.
750 uint64_t ComputeFragmentSize(const MCAsmLayout &Layout, const MCFragment &F) const;
752 /// Find the symbol which defines the atom containing the given symbol, or
753 /// null if there is no such symbol.
754 const MCSymbolData *getAtom(const MCSymbolData *Symbol) const;
756 /// Check whether a particular symbol is visible to the linker and is required
757 /// in the symbol table, or whether it can be discarded by the assembler. This
758 /// also effects whether the assembler treats the label as potentially
759 /// defining a separate atom.
760 bool isSymbolLinkerVisible(const MCSymbol &SD) const;
762 /// Emit the section contents using the given object writer.
763 void WriteSectionData(const MCSectionData *Section,
764 const MCAsmLayout &Layout) const;
766 /// Check whether a given symbol has been flagged with .thumb_func.
767 bool isThumbFunc(const MCSymbol *Func) const {
768 return ThumbFuncs.count(Func);
771 /// Flag a function symbol as the target of a .thumb_func directive.
772 void setIsThumbFunc(const MCSymbol *Func) { ThumbFuncs.insert(Func); }
775 /// Construct a new assembler instance.
777 /// \arg OS - The stream to output to.
779 // FIXME: How are we going to parameterize this? Two obvious options are stay
780 // concrete and require clients to pass in a target like object. The other
781 // option is to make this abstract, and have targets provide concrete
782 // implementations as we do with AsmParser.
783 MCAssembler(MCContext &Context_, TargetAsmBackend &Backend_,
784 MCCodeEmitter &Emitter_, MCObjectWriter &Writer_,
788 MCContext &getContext() const { return Context; }
790 TargetAsmBackend &getBackend() const { return Backend; }
792 MCCodeEmitter &getEmitter() const { return Emitter; }
794 MCObjectWriter &getWriter() const { return Writer; }
796 /// Finish - Do final processing and write the object to the output stream.
797 /// \arg Writer is used for custom object writer (as the MCJIT does),
798 /// if not specified it is automatically created from backend.
801 // FIXME: This does not belong here.
802 bool getSubsectionsViaSymbols() const {
803 return SubsectionsViaSymbols;
805 void setSubsectionsViaSymbols(bool Value) {
806 SubsectionsViaSymbols = Value;
809 bool getRelaxAll() const { return RelaxAll; }
810 void setRelaxAll(bool Value) { RelaxAll = Value; }
812 bool getNoExecStack() const { return NoExecStack; }
813 void setNoExecStack(bool Value) { NoExecStack = Value; }
815 /// @name Section List Access
818 const SectionDataListType &getSectionList() const { return Sections; }
819 SectionDataListType &getSectionList() { return Sections; }
821 iterator begin() { return Sections.begin(); }
822 const_iterator begin() const { return Sections.begin(); }
824 iterator end() { return Sections.end(); }
825 const_iterator end() const { return Sections.end(); }
827 size_t size() const { return Sections.size(); }
830 /// @name Symbol List Access
833 const SymbolDataListType &getSymbolList() const { return Symbols; }
834 SymbolDataListType &getSymbolList() { return Symbols; }
836 symbol_iterator symbol_begin() { return Symbols.begin(); }
837 const_symbol_iterator symbol_begin() const { return Symbols.begin(); }
839 symbol_iterator symbol_end() { return Symbols.end(); }
840 const_symbol_iterator symbol_end() const { return Symbols.end(); }
842 size_t symbol_size() const { return Symbols.size(); }
845 /// @name Indirect Symbol List Access
848 // FIXME: This is a total hack, this should not be here. Once things are
849 // factored so that the streamer has direct access to the .o writer, it can
851 std::vector<IndirectSymbolData> &getIndirectSymbols() {
852 return IndirectSymbols;
855 indirect_symbol_iterator indirect_symbol_begin() {
856 return IndirectSymbols.begin();
858 const_indirect_symbol_iterator indirect_symbol_begin() const {
859 return IndirectSymbols.begin();
862 indirect_symbol_iterator indirect_symbol_end() {
863 return IndirectSymbols.end();
865 const_indirect_symbol_iterator indirect_symbol_end() const {
866 return IndirectSymbols.end();
869 size_t indirect_symbol_size() const { return IndirectSymbols.size(); }
872 /// @name Backend Data Access
875 MCSectionData &getSectionData(const MCSection &Section) const {
876 MCSectionData *Entry = SectionMap.lookup(&Section);
877 assert(Entry && "Missing section data!");
881 MCSectionData &getOrCreateSectionData(const MCSection &Section,
883 MCSectionData *&Entry = SectionMap[&Section];
885 if (Created) *Created = !Entry;
887 Entry = new MCSectionData(Section, this);
892 MCSymbolData &getSymbolData(const MCSymbol &Symbol) const {
893 MCSymbolData *Entry = SymbolMap.lookup(&Symbol);
894 assert(Entry && "Missing symbol data!");
898 MCSymbolData &getOrCreateSymbolData(const MCSymbol &Symbol,
900 MCSymbolData *&Entry = SymbolMap[&Symbol];
902 if (Created) *Created = !Entry;
904 Entry = new MCSymbolData(Symbol, 0, 0, this);
914 } // end namespace llvm