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
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; }
102 static bool classof(const MCFragment *O) { return true; }
107 class MCDataFragment : public MCFragment {
108 SmallString<32> Contents;
110 /// Fixups - The list of fixups in this fragment.
111 std::vector<MCFixup> Fixups;
114 typedef std::vector<MCFixup>::const_iterator const_fixup_iterator;
115 typedef std::vector<MCFixup>::iterator fixup_iterator;
118 MCDataFragment(MCSectionData *SD = 0) : MCFragment(FT_Data, SD) {}
123 SmallString<32> &getContents() { return Contents; }
124 const SmallString<32> &getContents() const { return Contents; }
127 /// @name Fixup Access
130 void addFixup(MCFixup Fixup) {
131 // Enforce invariant that fixups are in offset order.
132 assert((Fixups.empty() || Fixup.getOffset() > Fixups.back().getOffset()) &&
133 "Fixups must be added in order!");
134 Fixups.push_back(Fixup);
137 std::vector<MCFixup> &getFixups() { return Fixups; }
138 const std::vector<MCFixup> &getFixups() const { return Fixups; }
140 fixup_iterator fixup_begin() { return Fixups.begin(); }
141 const_fixup_iterator fixup_begin() const { return Fixups.begin(); }
143 fixup_iterator fixup_end() {return Fixups.end();}
144 const_fixup_iterator fixup_end() const {return Fixups.end();}
146 size_t fixup_size() const { return Fixups.size(); }
150 static bool classof(const MCFragment *F) {
151 return F->getKind() == MCFragment::FT_Data;
153 static bool classof(const MCDataFragment *) { return true; }
156 // FIXME: This current incarnation of MCInstFragment doesn't make much sense, as
157 // it is almost entirely a duplicate of MCDataFragment. If we decide to stick
158 // with this approach (as opposed to making MCInstFragment a very light weight
159 // object with just the MCInst and a code size, then we should just change
160 // MCDataFragment to have an optional MCInst at its end.
161 class MCInstFragment : public MCFragment {
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(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(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;
213 static bool classof(const MCInstFragment *) { return true; }
216 class MCAlignFragment : public MCFragment {
217 /// Alignment - The alignment to ensure, in bytes.
220 /// Value - Value to use for filling padding bytes.
223 /// ValueSize - The size of the integer (in bytes) of \arg Value.
226 /// MaxBytesToEmit - The maximum number of bytes to emit; if the alignment
227 /// cannot be satisfied in this width then this fragment is ignored.
228 unsigned MaxBytesToEmit;
230 /// Size - The current estimate of the size.
233 /// EmitNops - Flag to indicate that (optimal) NOPs should be emitted instead
234 /// of using the provided value. The exact interpretation of this flag is
235 /// target dependent.
239 MCAlignFragment(unsigned _Alignment, int64_t _Value, unsigned _ValueSize,
240 unsigned _MaxBytesToEmit, MCSectionData *SD = 0)
241 : MCFragment(FT_Align, SD), Alignment(_Alignment),
242 Value(_Value),ValueSize(_ValueSize),
243 MaxBytesToEmit(_MaxBytesToEmit), Size(0), EmitNops(false) {}
248 unsigned getAlignment() const { return Alignment; }
250 int64_t getValue() const { return Value; }
252 unsigned getValueSize() const { return ValueSize; }
254 unsigned getSize() const { return Size; }
256 void setSize(unsigned Size_) { Size = Size_; }
258 unsigned getMaxBytesToEmit() const { return MaxBytesToEmit; }
260 bool hasEmitNops() const { return EmitNops; }
261 void setEmitNops(bool Value) { EmitNops = Value; }
265 static bool classof(const MCFragment *F) {
266 return F->getKind() == MCFragment::FT_Align;
268 static bool classof(const MCAlignFragment *) { return true; }
271 class MCFillFragment : public MCFragment {
272 /// Value - Value to use for filling bytes.
275 /// ValueSize - The size (in bytes) of \arg Value to use when filling, or 0 if
276 /// this is a virtual fill fragment.
279 /// Size - The number of bytes to insert.
283 MCFillFragment(int64_t _Value, unsigned _ValueSize, uint64_t _Size,
284 MCSectionData *SD = 0)
285 : MCFragment(FT_Fill, SD),
286 Value(_Value), ValueSize(_ValueSize), Size(_Size) {
287 assert((!ValueSize || (Size % ValueSize) == 0) &&
288 "Fill size must be a multiple of the value size!");
294 int64_t getValue() const { return Value; }
296 unsigned getValueSize() const { return ValueSize; }
298 uint64_t getSize() const { return Size; }
302 static bool classof(const MCFragment *F) {
303 return F->getKind() == MCFragment::FT_Fill;
305 static bool classof(const MCFillFragment *) { return true; }
308 class MCOrgFragment : public MCFragment {
309 /// Offset - The offset this fragment should start at.
310 const MCExpr *Offset;
312 /// Value - Value to use for filling bytes.
315 /// Size - The current estimate of the size.
319 MCOrgFragment(const MCExpr &_Offset, int8_t _Value, MCSectionData *SD = 0)
320 : MCFragment(FT_Org, SD),
321 Offset(&_Offset), Value(_Value), Size(0) {}
326 const MCExpr &getOffset() const { return *Offset; }
328 uint8_t getValue() const { return Value; }
330 unsigned getSize() const { return Size; }
332 void setSize(unsigned Size_) { Size = Size_; }
335 static bool classof(const MCFragment *F) {
336 return F->getKind() == MCFragment::FT_Org;
338 static bool classof(const MCOrgFragment *) { return true; }
341 class MCLEBFragment : public MCFragment {
342 /// Value - The value this fragment should contain.
345 /// IsSigned - True if this is a sleb128, false if uleb128.
348 SmallString<8> Contents;
350 MCLEBFragment(const MCExpr &Value_, bool IsSigned_, MCSectionData *SD)
351 : MCFragment(FT_LEB, SD),
352 Value(&Value_), IsSigned(IsSigned_) { Contents.push_back(0); }
357 const MCExpr &getValue() const { return *Value; }
359 bool isSigned() const { return IsSigned; }
361 SmallString<8> &getContents() { return Contents; }
362 const SmallString<8> &getContents() const { return Contents; }
366 static bool classof(const MCFragment *F) {
367 return F->getKind() == MCFragment::FT_LEB;
369 static bool classof(const MCLEBFragment *) { return true; }
372 class MCDwarfLineAddrFragment : public MCFragment {
373 /// LineDelta - the value of the difference between the two line numbers
374 /// between two .loc dwarf directives.
377 /// AddrDelta - The expression for the difference of the two symbols that
378 /// make up the address delta between two .loc dwarf directives.
379 const MCExpr *AddrDelta;
381 SmallString<8> Contents;
384 MCDwarfLineAddrFragment(int64_t _LineDelta, const MCExpr &_AddrDelta,
385 MCSectionData *SD = 0)
386 : MCFragment(FT_Dwarf, SD),
387 LineDelta(_LineDelta), AddrDelta(&_AddrDelta) { Contents.push_back(0); }
392 int64_t getLineDelta() const { return LineDelta; }
394 const MCExpr &getAddrDelta() const { return *AddrDelta; }
396 SmallString<8> &getContents() { return Contents; }
397 const SmallString<8> &getContents() const { return Contents; }
401 static bool classof(const MCFragment *F) {
402 return F->getKind() == MCFragment::FT_Dwarf;
404 static bool classof(const MCDwarfLineAddrFragment *) { return true; }
407 // FIXME: Should this be a separate class, or just merged into MCSection? Since
408 // we anticipate the fast path being through an MCAssembler, the only reason to
409 // keep it out is for API abstraction.
410 class MCSectionData : public ilist_node<MCSectionData> {
411 friend class MCAsmLayout;
413 MCSectionData(const MCSectionData&); // DO NOT IMPLEMENT
414 void operator=(const MCSectionData&); // DO NOT IMPLEMENT
417 typedef iplist<MCFragment> FragmentListType;
419 typedef FragmentListType::const_iterator const_iterator;
420 typedef FragmentListType::iterator iterator;
422 typedef FragmentListType::const_reverse_iterator const_reverse_iterator;
423 typedef FragmentListType::reverse_iterator reverse_iterator;
426 FragmentListType Fragments;
427 const MCSection *Section;
429 /// Ordinal - The section index in the assemblers section list.
432 /// LayoutOrder - The index of this section in the layout order.
433 unsigned LayoutOrder;
435 /// Alignment - The maximum alignment seen in this section.
438 /// @name Assembler Backend Data
441 // FIXME: This could all be kept private to the assembler implementation.
443 /// HasInstructions - Whether this section has had instructions emitted into
445 unsigned HasInstructions : 1;
450 // Only for use as sentinel.
452 MCSectionData(const MCSection &Section, MCAssembler *A = 0);
454 const MCSection &getSection() const { return *Section; }
456 unsigned getAlignment() const { return Alignment; }
457 void setAlignment(unsigned Value) { Alignment = Value; }
459 bool hasInstructions() const { return HasInstructions; }
460 void setHasInstructions(bool Value) { HasInstructions = Value; }
462 unsigned getOrdinal() const { return Ordinal; }
463 void setOrdinal(unsigned Value) { Ordinal = Value; }
465 unsigned getLayoutOrder() const { return LayoutOrder; }
466 void setLayoutOrder(unsigned Value) { LayoutOrder = Value; }
468 /// @name Fragment Access
471 const FragmentListType &getFragmentList() const { return Fragments; }
472 FragmentListType &getFragmentList() { return Fragments; }
474 iterator begin() { return Fragments.begin(); }
475 const_iterator begin() const { return Fragments.begin(); }
477 iterator end() { return Fragments.end(); }
478 const_iterator end() const { return Fragments.end(); }
480 reverse_iterator rbegin() { return Fragments.rbegin(); }
481 const_reverse_iterator rbegin() const { return Fragments.rbegin(); }
483 reverse_iterator rend() { return Fragments.rend(); }
484 const_reverse_iterator rend() const { return Fragments.rend(); }
486 size_t size() const { return Fragments.size(); }
488 bool empty() const { return Fragments.empty(); }
495 // FIXME: Same concerns as with SectionData.
496 class MCSymbolData : public ilist_node<MCSymbolData> {
498 const MCSymbol *Symbol;
500 /// Fragment - The fragment this symbol's value is relative to, if any.
501 MCFragment *Fragment;
503 /// Offset - The offset to apply to the fragment address to form this symbol's
507 /// IsExternal - True if this symbol is visible outside this translation
509 unsigned IsExternal : 1;
511 /// IsPrivateExtern - True if this symbol is private extern.
512 unsigned IsPrivateExtern : 1;
514 /// CommonSize - The size of the symbol, if it is 'common', or 0.
516 // FIXME: Pack this in with other fields? We could put it in offset, since a
517 // common symbol can never get a definition.
520 /// SymbolSize - An expression describing how to calculate the size of
521 /// a symbol. If a symbol has no size this field will be NULL.
522 const MCExpr *SymbolSize;
524 /// CommonAlign - The alignment of the symbol, if it is 'common'.
526 // FIXME: Pack this in with other fields?
527 unsigned CommonAlign;
529 /// Flags - The Flags field is used by object file implementations to store
530 /// additional per symbol information which is not easily classified.
533 /// Index - Index field, for use by the object file implementation.
537 // Only for use as sentinel.
539 MCSymbolData(const MCSymbol &_Symbol, MCFragment *_Fragment, uint64_t _Offset,
545 const MCSymbol &getSymbol() const { return *Symbol; }
547 MCFragment *getFragment() const { return Fragment; }
548 void setFragment(MCFragment *Value) { Fragment = Value; }
550 uint64_t getOffset() const { return Offset; }
551 void setOffset(uint64_t Value) { Offset = Value; }
554 /// @name Symbol Attributes
557 bool isExternal() const { return IsExternal; }
558 void setExternal(bool Value) { IsExternal = Value; }
560 bool isPrivateExtern() const { return IsPrivateExtern; }
561 void setPrivateExtern(bool Value) { IsPrivateExtern = Value; }
563 /// isCommon - Is this a 'common' symbol.
564 bool isCommon() const { return CommonSize != 0; }
566 /// setCommon - Mark this symbol as being 'common'.
568 /// \param Size - The size of the symbol.
569 /// \param Align - The alignment of the symbol.
570 void setCommon(uint64_t Size, unsigned Align) {
575 /// getCommonSize - Return the size of a 'common' symbol.
576 uint64_t getCommonSize() const {
577 assert(isCommon() && "Not a 'common' symbol!");
581 void setSize(const MCExpr *SS) {
585 const MCExpr *getSize() const {
590 /// getCommonAlignment - Return the alignment of a 'common' symbol.
591 unsigned getCommonAlignment() const {
592 assert(isCommon() && "Not a 'common' symbol!");
596 /// getFlags - Get the (implementation defined) symbol flags.
597 uint32_t getFlags() const { return Flags; }
599 /// setFlags - Set the (implementation defined) symbol flags.
600 void setFlags(uint32_t Value) { Flags = Value; }
602 /// modifyFlags - Modify the flags via a mask
603 void modifyFlags(uint32_t Value, uint32_t Mask) {
604 Flags = (Flags & ~Mask) | Value;
607 /// getIndex - Get the (implementation defined) index.
608 uint64_t getIndex() const { return Index; }
610 /// setIndex - Set the (implementation defined) index.
611 void setIndex(uint64_t Value) { Index = Value; }
618 // FIXME: This really doesn't belong here. See comments below.
619 struct IndirectSymbolData {
621 MCSectionData *SectionData;
625 friend class MCAsmLayout;
628 typedef iplist<MCSectionData> SectionDataListType;
629 typedef iplist<MCSymbolData> SymbolDataListType;
631 typedef SectionDataListType::const_iterator const_iterator;
632 typedef SectionDataListType::iterator iterator;
634 typedef SymbolDataListType::const_iterator const_symbol_iterator;
635 typedef SymbolDataListType::iterator symbol_iterator;
637 typedef std::vector<IndirectSymbolData>::const_iterator
638 const_indirect_symbol_iterator;
639 typedef std::vector<IndirectSymbolData>::iterator indirect_symbol_iterator;
642 MCAssembler(const MCAssembler&); // DO NOT IMPLEMENT
643 void operator=(const MCAssembler&); // DO NOT IMPLEMENT
647 TargetAsmBackend &Backend;
649 MCCodeEmitter &Emitter;
651 MCObjectWriter &Writer;
655 iplist<MCSectionData> Sections;
657 iplist<MCSymbolData> Symbols;
659 /// The map of sections to their associated assembler backend data.
661 // FIXME: Avoid this indirection?
662 DenseMap<const MCSection*, MCSectionData*> SectionMap;
664 /// The map of symbols to their associated assembler backend data.
666 // FIXME: Avoid this indirection?
667 DenseMap<const MCSymbol*, MCSymbolData*> SymbolMap;
669 std::vector<IndirectSymbolData> IndirectSymbols;
671 /// The set of function symbols for which a .thumb_func directive has
674 // FIXME: We really would like this in target specific code rather than
675 // here. Maybe when the relocation stuff moves to target specific,
676 // this can go with it? The streamer would need some target specific
678 SmallPtrSet<const MCSymbol*, 64> ThumbFuncs;
680 unsigned RelaxAll : 1;
681 unsigned SubsectionsViaSymbols : 1;
684 /// Evaluate a fixup to a relocatable expression and the value which should be
685 /// placed into the fixup.
687 /// \param Layout The layout to use for evaluation.
688 /// \param Fixup The fixup to evaluate.
689 /// \param DF The fragment the fixup is inside.
690 /// \param Target [out] On return, the relocatable expression the fixup
692 /// \param Value [out] On return, the value of the fixup as currently layed
694 /// \return Whether the fixup value was fully resolved. This is true if the
695 /// \arg Value result is fixed, otherwise the value may change due to
697 bool EvaluateFixup(const MCAsmLayout &Layout,
698 const MCFixup &Fixup, const MCFragment *DF,
699 MCValue &Target, uint64_t &Value) const;
701 /// Check whether a fixup can be satisfied, or whether it needs to be relaxed
702 /// (increased in size, in order to hold its value correctly).
703 bool FixupNeedsRelaxation(const MCFixup &Fixup, const MCFragment *DF,
704 const MCAsmLayout &Layout) const;
706 /// Check whether the given fragment needs relaxation.
707 bool FragmentNeedsRelaxation(const MCInstFragment *IF,
708 const MCAsmLayout &Layout) const;
710 /// LayoutOnce - Perform one layout iteration and return true if any offsets
712 bool LayoutOnce(MCAsmLayout &Layout);
714 bool RelaxInstruction(MCAsmLayout &Layout, MCInstFragment &IF);
716 bool RelaxOrg(MCAsmLayout &Layout, MCOrgFragment &OF);
718 bool RelaxLEB(MCAsmLayout &Layout, MCLEBFragment &IF);
720 bool RelaxDwarfLineAddr(MCAsmLayout &Layout, MCDwarfLineAddrFragment &DF);
722 bool RelaxAlignment(MCAsmLayout &Layout, MCAlignFragment &DF);
724 /// FinishLayout - Finalize a layout, including fragment lowering.
725 void FinishLayout(MCAsmLayout &Layout);
727 uint64_t HandleFixup(const MCAsmLayout &Layout,
728 MCFragment &F, const MCFixup &Fixup);
731 /// Compute the effective fragment size assuming it is layed out at the given
732 /// \arg SectionAddress and \arg FragmentOffset.
733 uint64_t ComputeFragmentSize(const MCFragment &F) const;
735 /// Find the symbol which defines the atom containing the given symbol, or
736 /// null if there is no such symbol.
737 const MCSymbolData *getAtom(const MCSymbolData *Symbol) const;
739 /// Check whether a particular symbol is visible to the linker and is required
740 /// in the symbol table, or whether it can be discarded by the assembler. This
741 /// also effects whether the assembler treats the label as potentially
742 /// defining a separate atom.
743 bool isSymbolLinkerVisible(const MCSymbol &SD) const;
745 /// Emit the section contents using the given object writer.
746 void WriteSectionData(const MCSectionData *Section,
747 const MCAsmLayout &Layout) const;
749 /// Check whether a given symbol has been flagged with .thumb_func.
750 bool isThumbFunc(const MCSymbol *Func) const {
751 return ThumbFuncs.count(Func);
754 /// Flag a function symbol as the target of a .thumb_func directive.
755 void setIsThumbFunc(const MCSymbol *Func) { ThumbFuncs.insert(Func); }
758 /// Construct a new assembler instance.
760 /// \arg OS - The stream to output to.
762 // FIXME: How are we going to parameterize this? Two obvious options are stay
763 // concrete and require clients to pass in a target like object. The other
764 // option is to make this abstract, and have targets provide concrete
765 // implementations as we do with AsmParser.
766 MCAssembler(MCContext &Context_, TargetAsmBackend &Backend_,
767 MCCodeEmitter &Emitter_, MCObjectWriter &Writer_,
771 MCContext &getContext() const { return Context; }
773 TargetAsmBackend &getBackend() const { return Backend; }
775 MCCodeEmitter &getEmitter() const { return Emitter; }
777 MCObjectWriter &getWriter() const { return Writer; }
779 /// Finish - Do final processing and write the object to the output stream.
780 /// \arg Writer is used for custom object writer (as the MCJIT does),
781 /// if not specified it is automatically created from backend.
784 // FIXME: This does not belong here.
785 bool getSubsectionsViaSymbols() const {
786 return SubsectionsViaSymbols;
788 void setSubsectionsViaSymbols(bool Value) {
789 SubsectionsViaSymbols = Value;
792 bool getRelaxAll() const { return RelaxAll; }
793 void setRelaxAll(bool Value) { RelaxAll = Value; }
795 /// @name Section List Access
798 const SectionDataListType &getSectionList() const { return Sections; }
799 SectionDataListType &getSectionList() { return Sections; }
801 iterator begin() { return Sections.begin(); }
802 const_iterator begin() const { return Sections.begin(); }
804 iterator end() { return Sections.end(); }
805 const_iterator end() const { return Sections.end(); }
807 size_t size() const { return Sections.size(); }
810 /// @name Symbol List Access
813 const SymbolDataListType &getSymbolList() const { return Symbols; }
814 SymbolDataListType &getSymbolList() { return Symbols; }
816 symbol_iterator symbol_begin() { return Symbols.begin(); }
817 const_symbol_iterator symbol_begin() const { return Symbols.begin(); }
819 symbol_iterator symbol_end() { return Symbols.end(); }
820 const_symbol_iterator symbol_end() const { return Symbols.end(); }
822 size_t symbol_size() const { return Symbols.size(); }
825 /// @name Indirect Symbol List Access
828 // FIXME: This is a total hack, this should not be here. Once things are
829 // factored so that the streamer has direct access to the .o writer, it can
831 std::vector<IndirectSymbolData> &getIndirectSymbols() {
832 return IndirectSymbols;
835 indirect_symbol_iterator indirect_symbol_begin() {
836 return IndirectSymbols.begin();
838 const_indirect_symbol_iterator indirect_symbol_begin() const {
839 return IndirectSymbols.begin();
842 indirect_symbol_iterator indirect_symbol_end() {
843 return IndirectSymbols.end();
845 const_indirect_symbol_iterator indirect_symbol_end() const {
846 return IndirectSymbols.end();
849 size_t indirect_symbol_size() const { return IndirectSymbols.size(); }
852 /// @name Backend Data Access
855 MCSectionData &getSectionData(const MCSection &Section) const {
856 MCSectionData *Entry = SectionMap.lookup(&Section);
857 assert(Entry && "Missing section data!");
861 MCSectionData &getOrCreateSectionData(const MCSection &Section,
863 MCSectionData *&Entry = SectionMap[&Section];
865 if (Created) *Created = !Entry;
867 Entry = new MCSectionData(Section, this);
872 MCSymbolData &getSymbolData(const MCSymbol &Symbol) const {
873 MCSymbolData *Entry = SymbolMap.lookup(&Symbol);
874 assert(Entry && "Missing symbol data!");
878 MCSymbolData &getOrCreateSymbolData(const MCSymbol &Symbol,
880 MCSymbolData *&Entry = SymbolMap[&Symbol];
882 if (Created) *Created = !Entry;
884 Entry = new MCSymbolData(Symbol, 0, 0, this);
894 } // end namespace llvm