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 /// EmitNops - Flag to indicate that (optimal) NOPs should be emitted instead
231 /// of using the provided value. The exact interpretation of this flag is
232 /// target dependent.
236 MCAlignFragment(unsigned _Alignment, int64_t _Value, unsigned _ValueSize,
237 unsigned _MaxBytesToEmit, MCSectionData *SD = 0)
238 : MCFragment(FT_Align, SD), Alignment(_Alignment),
239 Value(_Value),ValueSize(_ValueSize),
240 MaxBytesToEmit(_MaxBytesToEmit), EmitNops(false) {}
245 unsigned getAlignment() const { return Alignment; }
247 int64_t getValue() const { return Value; }
249 unsigned getValueSize() const { return ValueSize; }
251 unsigned getMaxBytesToEmit() const { return MaxBytesToEmit; }
253 bool hasEmitNops() const { return EmitNops; }
254 void setEmitNops(bool Value) { EmitNops = Value; }
258 static bool classof(const MCFragment *F) {
259 return F->getKind() == MCFragment::FT_Align;
261 static bool classof(const MCAlignFragment *) { return true; }
264 class MCFillFragment : public MCFragment {
265 /// Value - Value to use for filling bytes.
268 /// ValueSize - The size (in bytes) of \arg Value to use when filling, or 0 if
269 /// this is a virtual fill fragment.
272 /// Size - The number of bytes to insert.
276 MCFillFragment(int64_t _Value, unsigned _ValueSize, uint64_t _Size,
277 MCSectionData *SD = 0)
278 : MCFragment(FT_Fill, SD),
279 Value(_Value), ValueSize(_ValueSize), Size(_Size) {
280 assert((!ValueSize || (Size % ValueSize) == 0) &&
281 "Fill size must be a multiple of the value size!");
287 int64_t getValue() const { return Value; }
289 unsigned getValueSize() const { return ValueSize; }
291 uint64_t getSize() const { return Size; }
295 static bool classof(const MCFragment *F) {
296 return F->getKind() == MCFragment::FT_Fill;
298 static bool classof(const MCFillFragment *) { return true; }
301 class MCOrgFragment : public MCFragment {
302 /// Offset - The offset this fragment should start at.
303 const MCExpr *Offset;
305 /// Value - Value to use for filling bytes.
309 MCOrgFragment(const MCExpr &_Offset, int8_t _Value, MCSectionData *SD = 0)
310 : MCFragment(FT_Org, SD),
311 Offset(&_Offset), Value(_Value) {}
316 const MCExpr &getOffset() const { return *Offset; }
318 uint8_t getValue() const { return Value; }
322 static bool classof(const MCFragment *F) {
323 return F->getKind() == MCFragment::FT_Org;
325 static bool classof(const MCOrgFragment *) { return true; }
328 class MCLEBFragment : public MCFragment {
329 /// Value - The value this fragment should contain.
332 /// IsSigned - True if this is a sleb128, false if uleb128.
335 SmallString<8> Contents;
337 MCLEBFragment(const MCExpr &Value_, bool IsSigned_, MCSectionData *SD)
338 : MCFragment(FT_LEB, SD),
339 Value(&Value_), IsSigned(IsSigned_) { Contents.push_back(0); }
344 const MCExpr &getValue() const { return *Value; }
346 bool isSigned() const { return IsSigned; }
348 SmallString<8> &getContents() { return Contents; }
349 const SmallString<8> &getContents() const { return Contents; }
353 static bool classof(const MCFragment *F) {
354 return F->getKind() == MCFragment::FT_LEB;
356 static bool classof(const MCLEBFragment *) { return true; }
359 class MCDwarfLineAddrFragment : public MCFragment {
360 /// LineDelta - the value of the difference between the two line numbers
361 /// between two .loc dwarf directives.
364 /// AddrDelta - The expression for the difference of the two symbols that
365 /// make up the address delta between two .loc dwarf directives.
366 const MCExpr *AddrDelta;
368 SmallString<8> Contents;
371 MCDwarfLineAddrFragment(int64_t _LineDelta, const MCExpr &_AddrDelta,
372 MCSectionData *SD = 0)
373 : MCFragment(FT_Dwarf, SD),
374 LineDelta(_LineDelta), AddrDelta(&_AddrDelta) { Contents.push_back(0); }
379 int64_t getLineDelta() const { return LineDelta; }
381 const MCExpr &getAddrDelta() const { return *AddrDelta; }
383 SmallString<8> &getContents() { return Contents; }
384 const SmallString<8> &getContents() const { return Contents; }
388 static bool classof(const MCFragment *F) {
389 return F->getKind() == MCFragment::FT_Dwarf;
391 static bool classof(const MCDwarfLineAddrFragment *) { return true; }
394 // FIXME: Should this be a separate class, or just merged into MCSection? Since
395 // we anticipate the fast path being through an MCAssembler, the only reason to
396 // keep it out is for API abstraction.
397 class MCSectionData : public ilist_node<MCSectionData> {
398 friend class MCAsmLayout;
400 MCSectionData(const MCSectionData&); // DO NOT IMPLEMENT
401 void operator=(const MCSectionData&); // DO NOT IMPLEMENT
404 typedef iplist<MCFragment> FragmentListType;
406 typedef FragmentListType::const_iterator const_iterator;
407 typedef FragmentListType::iterator iterator;
409 typedef FragmentListType::const_reverse_iterator const_reverse_iterator;
410 typedef FragmentListType::reverse_iterator reverse_iterator;
413 FragmentListType Fragments;
414 const MCSection *Section;
416 /// Ordinal - The section index in the assemblers section list.
419 /// LayoutOrder - The index of this section in the layout order.
420 unsigned LayoutOrder;
422 /// Alignment - The maximum alignment seen in this section.
425 /// @name Assembler Backend Data
428 // FIXME: This could all be kept private to the assembler implementation.
430 /// HasInstructions - Whether this section has had instructions emitted into
432 unsigned HasInstructions : 1;
437 // Only for use as sentinel.
439 MCSectionData(const MCSection &Section, MCAssembler *A = 0);
441 const MCSection &getSection() const { return *Section; }
443 unsigned getAlignment() const { return Alignment; }
444 void setAlignment(unsigned Value) { Alignment = Value; }
446 bool hasInstructions() const { return HasInstructions; }
447 void setHasInstructions(bool Value) { HasInstructions = Value; }
449 unsigned getOrdinal() const { return Ordinal; }
450 void setOrdinal(unsigned Value) { Ordinal = Value; }
452 unsigned getLayoutOrder() const { return LayoutOrder; }
453 void setLayoutOrder(unsigned Value) { LayoutOrder = Value; }
455 /// @name Fragment Access
458 const FragmentListType &getFragmentList() const { return Fragments; }
459 FragmentListType &getFragmentList() { return Fragments; }
461 iterator begin() { return Fragments.begin(); }
462 const_iterator begin() const { return Fragments.begin(); }
464 iterator end() { return Fragments.end(); }
465 const_iterator end() const { return Fragments.end(); }
467 reverse_iterator rbegin() { return Fragments.rbegin(); }
468 const_reverse_iterator rbegin() const { return Fragments.rbegin(); }
470 reverse_iterator rend() { return Fragments.rend(); }
471 const_reverse_iterator rend() const { return Fragments.rend(); }
473 size_t size() const { return Fragments.size(); }
475 bool empty() const { return Fragments.empty(); }
482 // FIXME: Same concerns as with SectionData.
483 class MCSymbolData : public ilist_node<MCSymbolData> {
485 const MCSymbol *Symbol;
487 /// Fragment - The fragment this symbol's value is relative to, if any.
488 MCFragment *Fragment;
490 /// Offset - The offset to apply to the fragment address to form this symbol's
494 /// IsExternal - True if this symbol is visible outside this translation
496 unsigned IsExternal : 1;
498 /// IsPrivateExtern - True if this symbol is private extern.
499 unsigned IsPrivateExtern : 1;
501 /// CommonSize - The size of the symbol, if it is 'common', or 0.
503 // FIXME: Pack this in with other fields? We could put it in offset, since a
504 // common symbol can never get a definition.
507 /// SymbolSize - An expression describing how to calculate the size of
508 /// a symbol. If a symbol has no size this field will be NULL.
509 const MCExpr *SymbolSize;
511 /// CommonAlign - The alignment of the symbol, if it is 'common'.
513 // FIXME: Pack this in with other fields?
514 unsigned CommonAlign;
516 /// Flags - The Flags field is used by object file implementations to store
517 /// additional per symbol information which is not easily classified.
520 /// Index - Index field, for use by the object file implementation.
524 // Only for use as sentinel.
526 MCSymbolData(const MCSymbol &_Symbol, MCFragment *_Fragment, uint64_t _Offset,
532 const MCSymbol &getSymbol() const { return *Symbol; }
534 MCFragment *getFragment() const { return Fragment; }
535 void setFragment(MCFragment *Value) { Fragment = Value; }
537 uint64_t getOffset() const { return Offset; }
538 void setOffset(uint64_t Value) { Offset = Value; }
541 /// @name Symbol Attributes
544 bool isExternal() const { return IsExternal; }
545 void setExternal(bool Value) { IsExternal = Value; }
547 bool isPrivateExtern() const { return IsPrivateExtern; }
548 void setPrivateExtern(bool Value) { IsPrivateExtern = Value; }
550 /// isCommon - Is this a 'common' symbol.
551 bool isCommon() const { return CommonSize != 0; }
553 /// setCommon - Mark this symbol as being 'common'.
555 /// \param Size - The size of the symbol.
556 /// \param Align - The alignment of the symbol.
557 void setCommon(uint64_t Size, unsigned Align) {
562 /// getCommonSize - Return the size of a 'common' symbol.
563 uint64_t getCommonSize() const {
564 assert(isCommon() && "Not a 'common' symbol!");
568 void setSize(const MCExpr *SS) {
572 const MCExpr *getSize() const {
577 /// getCommonAlignment - Return the alignment of a 'common' symbol.
578 unsigned getCommonAlignment() const {
579 assert(isCommon() && "Not a 'common' symbol!");
583 /// getFlags - Get the (implementation defined) symbol flags.
584 uint32_t getFlags() const { return Flags; }
586 /// setFlags - Set the (implementation defined) symbol flags.
587 void setFlags(uint32_t Value) { Flags = Value; }
589 /// modifyFlags - Modify the flags via a mask
590 void modifyFlags(uint32_t Value, uint32_t Mask) {
591 Flags = (Flags & ~Mask) | Value;
594 /// getIndex - Get the (implementation defined) index.
595 uint64_t getIndex() const { return Index; }
597 /// setIndex - Set the (implementation defined) index.
598 void setIndex(uint64_t Value) { Index = Value; }
605 // FIXME: This really doesn't belong here. See comments below.
606 struct IndirectSymbolData {
608 MCSectionData *SectionData;
612 friend class MCAsmLayout;
615 typedef iplist<MCSectionData> SectionDataListType;
616 typedef iplist<MCSymbolData> SymbolDataListType;
618 typedef SectionDataListType::const_iterator const_iterator;
619 typedef SectionDataListType::iterator iterator;
621 typedef SymbolDataListType::const_iterator const_symbol_iterator;
622 typedef SymbolDataListType::iterator symbol_iterator;
624 typedef std::vector<IndirectSymbolData>::const_iterator
625 const_indirect_symbol_iterator;
626 typedef std::vector<IndirectSymbolData>::iterator indirect_symbol_iterator;
629 MCAssembler(const MCAssembler&); // DO NOT IMPLEMENT
630 void operator=(const MCAssembler&); // DO NOT IMPLEMENT
634 TargetAsmBackend &Backend;
636 MCCodeEmitter &Emitter;
638 MCObjectWriter &Writer;
642 iplist<MCSectionData> Sections;
644 iplist<MCSymbolData> Symbols;
646 /// The map of sections to their associated assembler backend data.
648 // FIXME: Avoid this indirection?
649 DenseMap<const MCSection*, MCSectionData*> SectionMap;
651 /// The map of symbols to their associated assembler backend data.
653 // FIXME: Avoid this indirection?
654 DenseMap<const MCSymbol*, MCSymbolData*> SymbolMap;
656 std::vector<IndirectSymbolData> IndirectSymbols;
658 /// The set of function symbols for which a .thumb_func directive has
661 // FIXME: We really would like this in target specific code rather than
662 // here. Maybe when the relocation stuff moves to target specific,
663 // this can go with it? The streamer would need some target specific
665 SmallPtrSet<const MCSymbol*, 64> ThumbFuncs;
667 unsigned RelaxAll : 1;
668 unsigned SubsectionsViaSymbols : 1;
671 /// Evaluate a fixup to a relocatable expression and the value which should be
672 /// placed into the fixup.
674 /// \param Layout The layout to use for evaluation.
675 /// \param Fixup The fixup to evaluate.
676 /// \param DF The fragment the fixup is inside.
677 /// \param Target [out] On return, the relocatable expression the fixup
679 /// \param Value [out] On return, the value of the fixup as currently layed
681 /// \return Whether the fixup value was fully resolved. This is true if the
682 /// \arg Value result is fixed, otherwise the value may change due to
684 bool EvaluateFixup(const MCAsmLayout &Layout,
685 const MCFixup &Fixup, const MCFragment *DF,
686 MCValue &Target, uint64_t &Value) const;
688 /// Check whether a fixup can be satisfied, or whether it needs to be relaxed
689 /// (increased in size, in order to hold its value correctly).
690 bool FixupNeedsRelaxation(const MCFixup &Fixup, const MCFragment *DF,
691 const MCAsmLayout &Layout) const;
693 /// Check whether the given fragment needs relaxation.
694 bool FragmentNeedsRelaxation(const MCInstFragment *IF,
695 const MCAsmLayout &Layout) const;
697 /// LayoutOnce - Perform one layout iteration and return true if any offsets
699 bool LayoutOnce(MCAsmLayout &Layout);
701 bool LayoutSectionOnce(MCAsmLayout &Layout, MCSectionData &SD);
703 bool RelaxInstruction(MCAsmLayout &Layout, MCInstFragment &IF);
705 bool RelaxLEB(MCAsmLayout &Layout, MCLEBFragment &IF);
707 bool RelaxDwarfLineAddr(MCAsmLayout &Layout, MCDwarfLineAddrFragment &DF);
709 /// FinishLayout - Finalize a layout, including fragment lowering.
710 void FinishLayout(MCAsmLayout &Layout);
712 uint64_t HandleFixup(const MCAsmLayout &Layout,
713 MCFragment &F, const MCFixup &Fixup);
716 /// Compute the effective fragment size assuming it is layed out at the given
717 /// \arg SectionAddress and \arg FragmentOffset.
718 uint64_t ComputeFragmentSize(const MCAsmLayout &Layout, const MCFragment &F) const;
720 /// Find the symbol which defines the atom containing the given symbol, or
721 /// null if there is no such symbol.
722 const MCSymbolData *getAtom(const MCSymbolData *Symbol) const;
724 /// Check whether a particular symbol is visible to the linker and is required
725 /// in the symbol table, or whether it can be discarded by the assembler. This
726 /// also effects whether the assembler treats the label as potentially
727 /// defining a separate atom.
728 bool isSymbolLinkerVisible(const MCSymbol &SD) const;
730 /// Emit the section contents using the given object writer.
731 void WriteSectionData(const MCSectionData *Section,
732 const MCAsmLayout &Layout) const;
734 /// Check whether a given symbol has been flagged with .thumb_func.
735 bool isThumbFunc(const MCSymbol *Func) const {
736 return ThumbFuncs.count(Func);
739 /// Flag a function symbol as the target of a .thumb_func directive.
740 void setIsThumbFunc(const MCSymbol *Func) { ThumbFuncs.insert(Func); }
743 /// Construct a new assembler instance.
745 /// \arg OS - The stream to output to.
747 // FIXME: How are we going to parameterize this? Two obvious options are stay
748 // concrete and require clients to pass in a target like object. The other
749 // option is to make this abstract, and have targets provide concrete
750 // implementations as we do with AsmParser.
751 MCAssembler(MCContext &Context_, TargetAsmBackend &Backend_,
752 MCCodeEmitter &Emitter_, MCObjectWriter &Writer_,
756 MCContext &getContext() const { return Context; }
758 TargetAsmBackend &getBackend() const { return Backend; }
760 MCCodeEmitter &getEmitter() const { return Emitter; }
762 MCObjectWriter &getWriter() const { return Writer; }
764 /// Finish - Do final processing and write the object to the output stream.
765 /// \arg Writer is used for custom object writer (as the MCJIT does),
766 /// if not specified it is automatically created from backend.
769 // FIXME: This does not belong here.
770 bool getSubsectionsViaSymbols() const {
771 return SubsectionsViaSymbols;
773 void setSubsectionsViaSymbols(bool Value) {
774 SubsectionsViaSymbols = Value;
777 bool getRelaxAll() const { return RelaxAll; }
778 void setRelaxAll(bool Value) { RelaxAll = Value; }
780 /// @name Section List Access
783 const SectionDataListType &getSectionList() const { return Sections; }
784 SectionDataListType &getSectionList() { return Sections; }
786 iterator begin() { return Sections.begin(); }
787 const_iterator begin() const { return Sections.begin(); }
789 iterator end() { return Sections.end(); }
790 const_iterator end() const { return Sections.end(); }
792 size_t size() const { return Sections.size(); }
795 /// @name Symbol List Access
798 const SymbolDataListType &getSymbolList() const { return Symbols; }
799 SymbolDataListType &getSymbolList() { return Symbols; }
801 symbol_iterator symbol_begin() { return Symbols.begin(); }
802 const_symbol_iterator symbol_begin() const { return Symbols.begin(); }
804 symbol_iterator symbol_end() { return Symbols.end(); }
805 const_symbol_iterator symbol_end() const { return Symbols.end(); }
807 size_t symbol_size() const { return Symbols.size(); }
810 /// @name Indirect Symbol List Access
813 // FIXME: This is a total hack, this should not be here. Once things are
814 // factored so that the streamer has direct access to the .o writer, it can
816 std::vector<IndirectSymbolData> &getIndirectSymbols() {
817 return IndirectSymbols;
820 indirect_symbol_iterator indirect_symbol_begin() {
821 return IndirectSymbols.begin();
823 const_indirect_symbol_iterator indirect_symbol_begin() const {
824 return IndirectSymbols.begin();
827 indirect_symbol_iterator indirect_symbol_end() {
828 return IndirectSymbols.end();
830 const_indirect_symbol_iterator indirect_symbol_end() const {
831 return IndirectSymbols.end();
834 size_t indirect_symbol_size() const { return IndirectSymbols.size(); }
837 /// @name Backend Data Access
840 MCSectionData &getSectionData(const MCSection &Section) const {
841 MCSectionData *Entry = SectionMap.lookup(&Section);
842 assert(Entry && "Missing section data!");
846 MCSectionData &getOrCreateSectionData(const MCSection &Section,
848 MCSectionData *&Entry = SectionMap[&Section];
850 if (Created) *Created = !Entry;
852 Entry = new MCSectionData(Section, this);
857 MCSymbolData &getSymbolData(const MCSymbol &Symbol) const {
858 MCSymbolData *Entry = SymbolMap.lookup(&Symbol);
859 assert(Entry && "Missing symbol data!");
863 MCSymbolData &getOrCreateSymbolData(const MCSymbol &Symbol,
865 MCSymbolData *&Entry = SymbolMap[&Symbol];
867 if (Created) *Created = !Entry;
869 Entry = new MCSymbolData(Symbol, 0, 0, this);
879 } // end namespace llvm