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/SmallString.h"
15 #include "llvm/ADT/ilist.h"
16 #include "llvm/ADT/ilist_node.h"
17 #include "llvm/Support/Casting.h"
18 #include "llvm/MC/MCFixup.h"
19 #include "llvm/MC/MCInst.h"
20 #include "llvm/Support/DataTypes.h"
21 #include <vector> // FIXME: Shouldn't be needed.
38 class TargetAsmBackend;
40 class MCFragment : public ilist_node<MCFragment> {
41 friend class MCAsmLayout;
43 MCFragment(const MCFragment&); // DO NOT IMPLEMENT
44 void operator=(const MCFragment&); // DO NOT IMPLEMENT
60 /// Parent - The data for the section this fragment is in.
61 MCSectionData *Parent;
63 /// Atom - The atom this fragment is in, as represented by it's defining
64 /// symbol. Atom's are only used by backends which set
65 /// \see MCAsmBackend::hasReliableSymbolDifference().
68 /// @name Assembler Backend Data
71 // FIXME: This could all be kept private to the assembler implementation.
73 /// Offset - The offset of this fragment in its section. This is ~0 until
77 /// EffectiveSize - The compute size of this section. This is ~0 until
79 uint64_t EffectiveSize;
81 /// LayoutOrder - The layout order of this fragment.
87 MCFragment(FragmentType _Kind, MCSectionData *_Parent = 0);
92 virtual ~MCFragment();
94 FragmentType getKind() const { return Kind; }
96 MCSectionData *getParent() const { return Parent; }
97 void setParent(MCSectionData *Value) { Parent = Value; }
99 MCSymbolData *getAtom() const { return Atom; }
100 void setAtom(MCSymbolData *Value) { Atom = Value; }
102 unsigned getLayoutOrder() const { return LayoutOrder; }
103 void setLayoutOrder(unsigned Value) { LayoutOrder = Value; }
105 static bool classof(const MCFragment *O) { return true; }
110 class MCDataFragment : public MCFragment {
111 SmallString<32> Contents;
113 /// Fixups - The list of fixups in this fragment.
114 std::vector<MCFixup> Fixups;
117 typedef std::vector<MCFixup>::const_iterator const_fixup_iterator;
118 typedef std::vector<MCFixup>::iterator fixup_iterator;
121 MCDataFragment(MCSectionData *SD = 0) : MCFragment(FT_Data, SD) {}
126 SmallString<32> &getContents() { return Contents; }
127 const SmallString<32> &getContents() const { return Contents; }
130 /// @name Fixup Access
133 void addFixup(MCFixup Fixup) {
134 // Enforce invariant that fixups are in offset order.
135 assert((Fixups.empty() || Fixup.getOffset() > Fixups.back().getOffset()) &&
136 "Fixups must be added in order!");
137 Fixups.push_back(Fixup);
140 std::vector<MCFixup> &getFixups() { return Fixups; }
141 const std::vector<MCFixup> &getFixups() const { return Fixups; }
143 fixup_iterator fixup_begin() { return Fixups.begin(); }
144 const_fixup_iterator fixup_begin() const { return Fixups.begin(); }
146 fixup_iterator fixup_end() {return Fixups.end();}
147 const_fixup_iterator fixup_end() const {return Fixups.end();}
149 size_t fixup_size() const { return Fixups.size(); }
153 static bool classof(const MCFragment *F) {
154 return F->getKind() == MCFragment::FT_Data;
156 static bool classof(const MCDataFragment *) { return true; }
159 // FIXME: This current incarnation of MCInstFragment doesn't make much sense, as
160 // it is almost entirely a duplicate of MCDataFragment. If we decide to stick
161 // with this approach (as opposed to making MCInstFragment a very light weight
162 // object with just the MCInst and a code size, then we should just change
163 // MCDataFragment to have an optional MCInst at its end.
164 class MCInstFragment : public MCFragment {
165 /// Inst - The instruction this is a fragment for.
168 /// Code - Binary data for the currently encoded instruction.
171 /// Fixups - The list of fixups in this fragment.
172 SmallVector<MCFixup, 1> Fixups;
175 typedef SmallVectorImpl<MCFixup>::const_iterator const_fixup_iterator;
176 typedef SmallVectorImpl<MCFixup>::iterator fixup_iterator;
179 MCInstFragment(MCInst _Inst, MCSectionData *SD = 0)
180 : MCFragment(FT_Inst, SD), Inst(_Inst) {
186 SmallVectorImpl<char> &getCode() { return Code; }
187 const SmallVectorImpl<char> &getCode() const { return Code; }
189 unsigned getInstSize() const { return Code.size(); }
191 MCInst &getInst() { return Inst; }
192 const MCInst &getInst() const { return Inst; }
194 void setInst(MCInst Value) { Inst = Value; }
197 /// @name Fixup Access
200 SmallVectorImpl<MCFixup> &getFixups() { return Fixups; }
201 const SmallVectorImpl<MCFixup> &getFixups() const { return Fixups; }
203 fixup_iterator fixup_begin() { return Fixups.begin(); }
204 const_fixup_iterator fixup_begin() const { return Fixups.begin(); }
206 fixup_iterator fixup_end() {return Fixups.end();}
207 const_fixup_iterator fixup_end() const {return Fixups.end();}
209 size_t fixup_size() const { return Fixups.size(); }
213 static bool classof(const MCFragment *F) {
214 return F->getKind() == MCFragment::FT_Inst;
216 static bool classof(const MCInstFragment *) { return true; }
219 class MCAlignFragment : public MCFragment {
220 /// Alignment - The alignment to ensure, in bytes.
223 /// Value - Value to use for filling padding bytes.
226 /// ValueSize - The size of the integer (in bytes) of \arg Value.
229 /// MaxBytesToEmit - The maximum number of bytes to emit; if the alignment
230 /// cannot be satisfied in this width then this fragment is ignored.
231 unsigned MaxBytesToEmit;
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), EmitNops(false) {}
248 unsigned getAlignment() const { return Alignment; }
250 int64_t getValue() const { return Value; }
252 unsigned getValueSize() const { return ValueSize; }
254 unsigned getMaxBytesToEmit() const { return MaxBytesToEmit; }
256 bool hasEmitNops() const { return EmitNops; }
257 void setEmitNops(bool Value) { EmitNops = Value; }
261 static bool classof(const MCFragment *F) {
262 return F->getKind() == MCFragment::FT_Align;
264 static bool classof(const MCAlignFragment *) { return true; }
267 class MCFillFragment : public MCFragment {
268 /// Value - Value to use for filling bytes.
271 /// ValueSize - The size (in bytes) of \arg Value to use when filling, or 0 if
272 /// this is a virtual fill fragment.
275 /// Size - The number of bytes to insert.
279 MCFillFragment(int64_t _Value, unsigned _ValueSize, uint64_t _Size,
280 MCSectionData *SD = 0)
281 : MCFragment(FT_Fill, SD),
282 Value(_Value), ValueSize(_ValueSize), Size(_Size) {
283 assert((!ValueSize || (Size % ValueSize) == 0) &&
284 "Fill size must be a multiple of the value size!");
290 int64_t getValue() const { return Value; }
292 unsigned getValueSize() const { return ValueSize; }
294 uint64_t getSize() const { return Size; }
298 static bool classof(const MCFragment *F) {
299 return F->getKind() == MCFragment::FT_Fill;
301 static bool classof(const MCFillFragment *) { return true; }
304 class MCOrgFragment : public MCFragment {
305 /// Offset - The offset this fragment should start at.
306 const MCExpr *Offset;
308 /// Value - Value to use for filling bytes.
311 /// Size - The current estimate of the size.
315 MCOrgFragment(const MCExpr &_Offset, int8_t _Value, MCSectionData *SD = 0)
316 : MCFragment(FT_Org, SD),
317 Offset(&_Offset), Value(_Value), Size(0) {}
322 const MCExpr &getOffset() const { return *Offset; }
324 uint8_t getValue() const { return Value; }
326 unsigned getSize() const { return Size; }
328 void setSize(unsigned Size_) { Size = Size_; }
331 static bool classof(const MCFragment *F) {
332 return F->getKind() == MCFragment::FT_Org;
334 static bool classof(const MCOrgFragment *) { return true; }
337 class MCLEBFragment : public MCFragment {
338 /// Value - The value this fragment should contain.
341 /// IsSigned - True if this is a sleb128, false if uleb128.
344 SmallString<8> Contents;
346 MCLEBFragment(const MCExpr &Value_, bool IsSigned_, MCSectionData *SD)
347 : MCFragment(FT_LEB, SD),
348 Value(&Value_), IsSigned(IsSigned_) { Contents.push_back(0); }
353 const MCExpr &getValue() const { return *Value; }
355 bool isSigned() const { return IsSigned; }
357 SmallString<8> &getContents() { return Contents; }
358 const SmallString<8> &getContents() const { return Contents; }
362 static bool classof(const MCFragment *F) {
363 return F->getKind() == MCFragment::FT_LEB;
365 static bool classof(const MCLEBFragment *) { return true; }
368 class MCDwarfLineAddrFragment : public MCFragment {
369 /// LineDelta - the value of the difference between the two line numbers
370 /// between two .loc dwarf directives.
373 /// AddrDelta - The expression for the difference of the two symbols that
374 /// make up the address delta between two .loc dwarf directives.
375 const MCExpr *AddrDelta;
377 SmallString<8> Contents;
380 MCDwarfLineAddrFragment(int64_t _LineDelta, const MCExpr &_AddrDelta,
381 MCSectionData *SD = 0)
382 : MCFragment(FT_Dwarf, SD),
383 LineDelta(_LineDelta), AddrDelta(&_AddrDelta) { Contents.push_back(0); }
388 int64_t getLineDelta() const { return LineDelta; }
390 const MCExpr &getAddrDelta() const { return *AddrDelta; }
392 SmallString<8> &getContents() { return Contents; }
393 const SmallString<8> &getContents() const { return Contents; }
397 static bool classof(const MCFragment *F) {
398 return F->getKind() == MCFragment::FT_Dwarf;
400 static bool classof(const MCDwarfLineAddrFragment *) { return true; }
403 // FIXME: Should this be a separate class, or just merged into MCSection? Since
404 // we anticipate the fast path being through an MCAssembler, the only reason to
405 // keep it out is for API abstraction.
406 class MCSectionData : public ilist_node<MCSectionData> {
407 friend class MCAsmLayout;
409 MCSectionData(const MCSectionData&); // DO NOT IMPLEMENT
410 void operator=(const MCSectionData&); // DO NOT IMPLEMENT
413 typedef iplist<MCFragment> FragmentListType;
415 typedef FragmentListType::const_iterator const_iterator;
416 typedef FragmentListType::iterator iterator;
418 typedef FragmentListType::const_reverse_iterator const_reverse_iterator;
419 typedef FragmentListType::reverse_iterator reverse_iterator;
422 FragmentListType Fragments;
423 const MCSection *Section;
425 /// Ordinal - The section index in the assemblers section list.
428 /// LayoutOrder - The index of this section in the layout order.
429 unsigned LayoutOrder;
431 /// Alignment - The maximum alignment seen in this section.
434 /// @name Assembler Backend Data
437 // FIXME: This could all be kept private to the assembler implementation.
439 /// HasInstructions - Whether this section has had instructions emitted into
441 unsigned HasInstructions : 1;
446 // Only for use as sentinel.
448 MCSectionData(const MCSection &Section, MCAssembler *A = 0);
450 const MCSection &getSection() const { return *Section; }
452 unsigned getAlignment() const { return Alignment; }
453 void setAlignment(unsigned Value) { Alignment = Value; }
455 bool hasInstructions() const { return HasInstructions; }
456 void setHasInstructions(bool Value) { HasInstructions = Value; }
458 unsigned getOrdinal() const { return Ordinal; }
459 void setOrdinal(unsigned Value) { Ordinal = Value; }
461 unsigned getLayoutOrder() const { return LayoutOrder; }
462 void setLayoutOrder(unsigned Value) { LayoutOrder = Value; }
464 /// @name Fragment Access
467 const FragmentListType &getFragmentList() const { return Fragments; }
468 FragmentListType &getFragmentList() { return Fragments; }
470 iterator begin() { return Fragments.begin(); }
471 const_iterator begin() const { return Fragments.begin(); }
473 iterator end() { return Fragments.end(); }
474 const_iterator end() const { return Fragments.end(); }
476 reverse_iterator rbegin() { return Fragments.rbegin(); }
477 const_reverse_iterator rbegin() const { return Fragments.rbegin(); }
479 reverse_iterator rend() { return Fragments.rend(); }
480 const_reverse_iterator rend() const { return Fragments.rend(); }
482 size_t size() const { return Fragments.size(); }
484 bool empty() const { return Fragments.empty(); }
491 // FIXME: Same concerns as with SectionData.
492 class MCSymbolData : public ilist_node<MCSymbolData> {
494 const MCSymbol *Symbol;
496 /// Fragment - The fragment this symbol's value is relative to, if any.
497 MCFragment *Fragment;
499 /// Offset - The offset to apply to the fragment address to form this symbol's
503 /// IsExternal - True if this symbol is visible outside this translation
505 unsigned IsExternal : 1;
507 /// IsPrivateExtern - True if this symbol is private extern.
508 unsigned IsPrivateExtern : 1;
510 /// CommonSize - The size of the symbol, if it is 'common', or 0.
512 // FIXME: Pack this in with other fields? We could put it in offset, since a
513 // common symbol can never get a definition.
516 /// SymbolSize - An expression describing how to calculate the size of
517 /// a symbol. If a symbol has no size this field will be NULL.
518 const MCExpr *SymbolSize;
520 /// CommonAlign - The alignment of the symbol, if it is 'common'.
522 // FIXME: Pack this in with other fields?
523 unsigned CommonAlign;
525 /// Flags - The Flags field is used by object file implementations to store
526 /// additional per symbol information which is not easily classified.
529 /// Index - Index field, for use by the object file implementation.
533 // Only for use as sentinel.
535 MCSymbolData(const MCSymbol &_Symbol, MCFragment *_Fragment, uint64_t _Offset,
541 const MCSymbol &getSymbol() const { return *Symbol; }
543 MCFragment *getFragment() const { return Fragment; }
544 void setFragment(MCFragment *Value) { Fragment = Value; }
546 uint64_t getOffset() const { return Offset; }
547 void setOffset(uint64_t Value) { Offset = Value; }
550 /// @name Symbol Attributes
553 bool isExternal() const { return IsExternal; }
554 void setExternal(bool Value) { IsExternal = Value; }
556 bool isPrivateExtern() const { return IsPrivateExtern; }
557 void setPrivateExtern(bool Value) { IsPrivateExtern = Value; }
559 /// isCommon - Is this a 'common' symbol.
560 bool isCommon() const { return CommonSize != 0; }
562 /// setCommon - Mark this symbol as being 'common'.
564 /// \param Size - The size of the symbol.
565 /// \param Align - The alignment of the symbol.
566 void setCommon(uint64_t Size, unsigned Align) {
571 /// getCommonSize - Return the size of a 'common' symbol.
572 uint64_t getCommonSize() const {
573 assert(isCommon() && "Not a 'common' symbol!");
577 void setSize(const MCExpr *SS) {
581 const MCExpr *getSize() const {
586 /// getCommonAlignment - Return the alignment of a 'common' symbol.
587 unsigned getCommonAlignment() const {
588 assert(isCommon() && "Not a 'common' symbol!");
592 /// getFlags - Get the (implementation defined) symbol flags.
593 uint32_t getFlags() const { return Flags; }
595 /// setFlags - Set the (implementation defined) symbol flags.
596 void setFlags(uint32_t Value) { Flags = Value; }
598 /// modifyFlags - Modify the flags via a mask
599 void modifyFlags(uint32_t Value, uint32_t Mask) {
600 Flags = (Flags & ~Mask) | Value;
603 /// getIndex - Get the (implementation defined) index.
604 uint64_t getIndex() const { return Index; }
606 /// setIndex - Set the (implementation defined) index.
607 void setIndex(uint64_t Value) { Index = Value; }
614 // FIXME: This really doesn't belong here. See comments below.
615 struct IndirectSymbolData {
617 MCSectionData *SectionData;
621 friend class MCAsmLayout;
624 typedef iplist<MCSectionData> SectionDataListType;
625 typedef iplist<MCSymbolData> SymbolDataListType;
627 typedef SectionDataListType::const_iterator const_iterator;
628 typedef SectionDataListType::iterator iterator;
630 typedef SymbolDataListType::const_iterator const_symbol_iterator;
631 typedef SymbolDataListType::iterator symbol_iterator;
633 typedef std::vector<IndirectSymbolData>::const_iterator
634 const_indirect_symbol_iterator;
635 typedef std::vector<IndirectSymbolData>::iterator indirect_symbol_iterator;
638 MCAssembler(const MCAssembler&); // DO NOT IMPLEMENT
639 void operator=(const MCAssembler&); // DO NOT IMPLEMENT
643 TargetAsmBackend &Backend;
645 MCCodeEmitter &Emitter;
649 iplist<MCSectionData> Sections;
651 iplist<MCSymbolData> Symbols;
653 /// The map of sections to their associated assembler backend data.
655 // FIXME: Avoid this indirection?
656 DenseMap<const MCSection*, MCSectionData*> SectionMap;
658 /// The map of symbols to their associated assembler backend data.
660 // FIXME: Avoid this indirection?
661 DenseMap<const MCSymbol*, MCSymbolData*> SymbolMap;
663 std::vector<IndirectSymbolData> IndirectSymbols;
665 unsigned RelaxAll : 1;
666 unsigned SubsectionsViaSymbols : 1;
669 /// Evaluate a fixup to a relocatable expression and the value which should be
670 /// placed into the fixup.
672 /// \param Layout The layout to use for evaluation.
673 /// \param Fixup The fixup to evaluate.
674 /// \param DF The fragment the fixup is inside.
675 /// \param Target [out] On return, the relocatable expression the fixup
677 /// \param Value [out] On return, the value of the fixup as currently layed
679 /// \return Whether the fixup value was fully resolved. This is true if the
680 /// \arg Value result is fixed, otherwise the value may change due to
682 bool EvaluateFixup(const MCObjectWriter &Writer, const MCAsmLayout &Layout,
683 const MCFixup &Fixup, const MCFragment *DF,
684 MCValue &Target, uint64_t &Value) const;
686 /// Check whether a fixup can be satisfied, or whether it needs to be relaxed
687 /// (increased in size, in order to hold its value correctly).
688 bool FixupNeedsRelaxation(const MCObjectWriter &Writer,
689 const MCFixup &Fixup, const MCFragment *DF,
690 const MCAsmLayout &Layout) const;
692 /// Check whether the given fragment needs relaxation.
693 bool FragmentNeedsRelaxation(const MCObjectWriter &Writer,
694 const MCInstFragment *IF,
695 const MCAsmLayout &Layout) const;
697 /// Compute the effective fragment size assuming it is layed out at the given
698 /// \arg SectionAddress and \arg FragmentOffset.
699 uint64_t ComputeFragmentSize(const MCFragment &F,
700 uint64_t FragmentOffset) const;
702 /// LayoutOnce - Perform one layout iteration and return true if any offsets
704 bool LayoutOnce(const MCObjectWriter &Writer, MCAsmLayout &Layout);
706 bool RelaxInstruction(const MCObjectWriter &Writer, MCAsmLayout &Layout,
709 bool RelaxOrg(const MCObjectWriter &Writer, MCAsmLayout &Layout,
712 bool RelaxLEB(const MCObjectWriter &Writer, MCAsmLayout &Layout,
715 bool RelaxDwarfLineAddr(const MCObjectWriter &Writer, MCAsmLayout &Layout,
716 MCDwarfLineAddrFragment &DF);
718 /// FinishLayout - Finalize a layout, including fragment lowering.
719 void FinishLayout(MCAsmLayout &Layout);
721 uint64_t HandleFixup(MCObjectWriter &Writer, const MCAsmLayout &Layout,
722 MCFragment &F, const MCFixup &Fixup);
725 /// Find the symbol which defines the atom containing the given symbol, or
726 /// null if there is no such symbol.
727 const MCSymbolData *getAtom(const MCSymbolData *Symbol) const;
729 /// Check whether a particular symbol is visible to the linker and is required
730 /// in the symbol table, or whether it can be discarded by the assembler. This
731 /// also effects whether the assembler treats the label as potentially
732 /// defining a separate atom.
733 bool isSymbolLinkerVisible(const MCSymbol &SD) const;
735 /// Emit the section contents using the given object writer.
737 // FIXME: Should MCAssembler always have a reference to the object writer?
738 void WriteSectionData(const MCSectionData *Section, const MCAsmLayout &Layout,
739 MCObjectWriter *OW) const;
742 /// Construct a new assembler instance.
744 /// \arg OS - The stream to output to.
746 // FIXME: How are we going to parameterize this? Two obvious options are stay
747 // concrete and require clients to pass in a target like object. The other
748 // option is to make this abstract, and have targets provide concrete
749 // implementations as we do with AsmParser.
750 MCAssembler(MCContext &_Context, TargetAsmBackend &_Backend,
751 MCCodeEmitter &_Emitter, raw_ostream &OS);
754 MCContext &getContext() const { return Context; }
756 TargetAsmBackend &getBackend() const { return Backend; }
758 MCCodeEmitter &getEmitter() const { return Emitter; }
760 /// Finish - Do final processing and write the object to the output stream.
761 /// \arg Writer is used for custom object writer (as the MCJIT does),
762 /// if not specified it is automatically created from backend.
763 void Finish(MCObjectWriter *Writer = 0);
765 // FIXME: This does not belong here.
766 bool getSubsectionsViaSymbols() const {
767 return SubsectionsViaSymbols;
769 void setSubsectionsViaSymbols(bool Value) {
770 SubsectionsViaSymbols = Value;
773 bool getRelaxAll() const { return RelaxAll; }
774 void setRelaxAll(bool Value) { RelaxAll = Value; }
776 /// @name Section List Access
779 const SectionDataListType &getSectionList() const { return Sections; }
780 SectionDataListType &getSectionList() { return Sections; }
782 iterator begin() { return Sections.begin(); }
783 const_iterator begin() const { return Sections.begin(); }
785 iterator end() { return Sections.end(); }
786 const_iterator end() const { return Sections.end(); }
788 size_t size() const { return Sections.size(); }
791 /// @name Symbol List Access
794 const SymbolDataListType &getSymbolList() const { return Symbols; }
795 SymbolDataListType &getSymbolList() { return Symbols; }
797 symbol_iterator symbol_begin() { return Symbols.begin(); }
798 const_symbol_iterator symbol_begin() const { return Symbols.begin(); }
800 symbol_iterator symbol_end() { return Symbols.end(); }
801 const_symbol_iterator symbol_end() const { return Symbols.end(); }
803 size_t symbol_size() const { return Symbols.size(); }
806 /// @name Indirect Symbol List Access
809 // FIXME: This is a total hack, this should not be here. Once things are
810 // factored so that the streamer has direct access to the .o writer, it can
812 std::vector<IndirectSymbolData> &getIndirectSymbols() {
813 return IndirectSymbols;
816 indirect_symbol_iterator indirect_symbol_begin() {
817 return IndirectSymbols.begin();
819 const_indirect_symbol_iterator indirect_symbol_begin() const {
820 return IndirectSymbols.begin();
823 indirect_symbol_iterator indirect_symbol_end() {
824 return IndirectSymbols.end();
826 const_indirect_symbol_iterator indirect_symbol_end() const {
827 return IndirectSymbols.end();
830 size_t indirect_symbol_size() const { return IndirectSymbols.size(); }
833 /// @name Backend Data Access
836 MCSectionData &getSectionData(const MCSection &Section) const {
837 MCSectionData *Entry = SectionMap.lookup(&Section);
838 assert(Entry && "Missing section data!");
842 MCSectionData &getOrCreateSectionData(const MCSection &Section,
844 MCSectionData *&Entry = SectionMap[&Section];
846 if (Created) *Created = !Entry;
848 Entry = new MCSectionData(Section, this);
853 MCSymbolData &getSymbolData(const MCSymbol &Symbol) const {
854 MCSymbolData *Entry = SymbolMap.lookup(&Symbol);
855 assert(Entry && "Missing symbol data!");
859 MCSymbolData &getOrCreateSymbolData(const MCSymbol &Symbol,
861 MCSymbolData *&Entry = SymbolMap[&Symbol];
863 if (Created) *Created = !Entry;
865 Entry = new MCSymbolData(Symbol, 0, 0, this);
875 } // end namespace llvm