MC/Mach-O: Factor out ExecutePostLayoutBinding, to separate the post-layout changes...
[oota-llvm.git] / include / llvm / MC / MCAssembler.h
1 //===- MCAssembler.h - Object File Generation -------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_MC_MCASSEMBLER_H
11 #define LLVM_MC_MCASSEMBLER_H
12
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/System/DataTypes.h"
20 #include <vector> // FIXME: Shouldn't be needed.
21
22 namespace llvm {
23 class raw_ostream;
24 class MCAsmLayout;
25 class MCAssembler;
26 class MCContext;
27 class MCExpr;
28 class MCFragment;
29 class MCSection;
30 class MCSectionData;
31 class MCSymbol;
32 class MCValue;
33 class TargetAsmBackend;
34
35 /// MCAsmFixup - Represent a fixed size region of bytes inside some fragment
36 /// which needs to be rewritten. This region will either be rewritten by the
37 /// assembler or cause a relocation entry to be generated.
38 struct MCAsmFixup {
39   /// Offset - The offset inside the fragment which needs to be rewritten.
40   uint64_t Offset;
41
42   /// Value - The expression to eventually write into the fragment.
43   const MCExpr *Value;
44
45   /// Kind - The fixup kind.
46   MCFixupKind Kind;
47
48   /// FixedValue - The value to replace the fix up by.
49   //
50   // FIXME: This should not be here.
51   uint64_t FixedValue;
52
53 public:
54   MCAsmFixup(uint64_t _Offset, const MCExpr &_Value, MCFixupKind _Kind)
55     : Offset(_Offset), Value(&_Value), Kind(_Kind), FixedValue(0) {}
56 };
57
58 class MCFragment : public ilist_node<MCFragment> {
59   MCFragment(const MCFragment&);     // DO NOT IMPLEMENT
60   void operator=(const MCFragment&); // DO NOT IMPLEMENT
61
62 public:
63   enum FragmentType {
64     FT_Data,
65     FT_Align,
66     FT_Fill,
67     FT_Org,
68     FT_ZeroFill
69   };
70
71 private:
72   FragmentType Kind;
73
74   /// Parent - The data for the section this fragment is in.
75   MCSectionData *Parent;
76
77   /// @name Assembler Backend Data
78   /// @{
79   //
80   // FIXME: This could all be kept private to the assembler implementation.
81
82   /// Offset - The offset of this fragment in its section. This is ~0 until
83   /// initialized.
84   uint64_t Offset;
85
86   /// FileSize - The file size of this section. This is ~0 until initialized.
87   uint64_t FileSize;
88
89   /// @}
90
91 protected:
92   MCFragment(FragmentType _Kind, MCSectionData *_Parent = 0);
93
94 public:
95   // Only for sentinel.
96   MCFragment();
97   virtual ~MCFragment();
98
99   FragmentType getKind() const { return Kind; }
100
101   MCSectionData *getParent() const { return Parent; }
102   void setParent(MCSectionData *Value) { Parent = Value; }
103
104   // FIXME: This should be abstract, fix sentinel.
105   virtual uint64_t getMaxFileSize() const {
106     assert(0 && "Invalid getMaxFileSize call!");
107     return 0;
108   }
109
110   /// @name Assembler Backend Support
111   /// @{
112   //
113   // FIXME: This could all be kept private to the assembler implementation.
114
115   uint64_t getAddress() const;
116
117   uint64_t getFileSize() const {
118     assert(FileSize != ~UINT64_C(0) && "File size not set!");
119     return FileSize;
120   }
121   void setFileSize(uint64_t Value) {
122     assert(Value <= getMaxFileSize() && "Invalid file size!");
123     FileSize = Value;
124   }
125
126   uint64_t getOffset() const {
127     assert(Offset != ~UINT64_C(0) && "File offset not set!");
128     return Offset;
129   }
130   void setOffset(uint64_t Value) { Offset = Value; }
131
132   /// @}
133
134   static bool classof(const MCFragment *O) { return true; }
135
136   virtual void dump();
137 };
138
139 class MCDataFragment : public MCFragment {
140   SmallString<32> Contents;
141
142   /// Fixups - The list of fixups in this fragment.
143   std::vector<MCAsmFixup> Fixups;
144
145 public:
146   typedef std::vector<MCAsmFixup>::const_iterator const_fixup_iterator;
147   typedef std::vector<MCAsmFixup>::iterator fixup_iterator;
148
149 public:
150   MCDataFragment(MCSectionData *SD = 0) : MCFragment(FT_Data, SD) {}
151
152   /// @name Accessors
153   /// @{
154
155   uint64_t getMaxFileSize() const {
156     return Contents.size();
157   }
158
159   SmallString<32> &getContents() { return Contents; }
160   const SmallString<32> &getContents() const { return Contents; }
161
162   /// @}
163
164   /// @name Fixup Access
165   /// @{
166
167   void addFixup(MCAsmFixup Fixup) {
168     // Enforce invariant that fixups are in offset order.
169     assert((Fixups.empty() || Fixup.Offset > Fixups.back().Offset) &&
170            "Fixups must be added in order!");
171     Fixups.push_back(Fixup);
172   }
173
174   std::vector<MCAsmFixup> &getFixups() { return Fixups; }
175   const std::vector<MCAsmFixup> &getFixups() const { return Fixups; }
176
177   fixup_iterator fixup_begin() { return Fixups.begin(); }
178   const_fixup_iterator fixup_begin() const { return Fixups.begin(); }
179
180   fixup_iterator fixup_end() {return Fixups.end();}
181   const_fixup_iterator fixup_end() const {return Fixups.end();}
182
183   size_t fixup_size() const { return Fixups.size(); }
184
185   /// @}
186
187   static bool classof(const MCFragment *F) {
188     return F->getKind() == MCFragment::FT_Data;
189   }
190   static bool classof(const MCDataFragment *) { return true; }
191
192   virtual void dump();
193 };
194
195 class MCAlignFragment : public MCFragment {
196   /// Alignment - The alignment to ensure, in bytes.
197   unsigned Alignment;
198
199   /// Value - Value to use for filling padding bytes.
200   int64_t Value;
201
202   /// ValueSize - The size of the integer (in bytes) of \arg Value.
203   unsigned ValueSize;
204
205   /// MaxBytesToEmit - The maximum number of bytes to emit; if the alignment
206   /// cannot be satisfied in this width then this fragment is ignored.
207   unsigned MaxBytesToEmit;
208
209   /// EmitNops - true when aligning code and optimal nops to be used for
210   /// filling.
211   bool EmitNops;
212
213 public:
214   MCAlignFragment(unsigned _Alignment, int64_t _Value, unsigned _ValueSize,
215                   unsigned _MaxBytesToEmit, bool _EmitNops,
216                   MCSectionData *SD = 0)
217     : MCFragment(FT_Align, SD), Alignment(_Alignment),
218       Value(_Value),ValueSize(_ValueSize),
219       MaxBytesToEmit(_MaxBytesToEmit), EmitNops(_EmitNops) {}
220
221   /// @name Accessors
222   /// @{
223
224   uint64_t getMaxFileSize() const {
225     return std::max(Alignment - 1, MaxBytesToEmit);
226   }
227
228   unsigned getAlignment() const { return Alignment; }
229
230   int64_t getValue() const { return Value; }
231
232   unsigned getValueSize() const { return ValueSize; }
233
234   unsigned getMaxBytesToEmit() const { return MaxBytesToEmit; }
235
236   unsigned getEmitNops() const { return EmitNops; }
237
238   /// @}
239
240   static bool classof(const MCFragment *F) {
241     return F->getKind() == MCFragment::FT_Align;
242   }
243   static bool classof(const MCAlignFragment *) { return true; }
244
245   virtual void dump();
246 };
247
248 class MCFillFragment : public MCFragment {
249   /// Value - Value to use for filling bytes.
250   int64_t Value;
251
252   /// ValueSize - The size (in bytes) of \arg Value to use when filling.
253   unsigned ValueSize;
254
255   /// Count - The number of copies of \arg Value to insert.
256   uint64_t Count;
257
258 public:
259   MCFillFragment(int64_t _Value, unsigned _ValueSize, uint64_t _Count,
260                  MCSectionData *SD = 0)
261     : MCFragment(FT_Fill, SD),
262       Value(_Value), ValueSize(_ValueSize), Count(_Count) {}
263
264   /// @name Accessors
265   /// @{
266
267   uint64_t getMaxFileSize() const {
268     return ValueSize * Count;
269   }
270
271   int64_t getValue() const { return Value; }
272
273   unsigned getValueSize() const { return ValueSize; }
274
275   uint64_t getCount() const { return Count; }
276
277   /// @}
278
279   static bool classof(const MCFragment *F) {
280     return F->getKind() == MCFragment::FT_Fill;
281   }
282   static bool classof(const MCFillFragment *) { return true; }
283
284   virtual void dump();
285 };
286
287 class MCOrgFragment : public MCFragment {
288   /// Offset - The offset this fragment should start at.
289   const MCExpr *Offset;
290
291   /// Value - Value to use for filling bytes.
292   int8_t Value;
293
294 public:
295   MCOrgFragment(const MCExpr &_Offset, int8_t _Value, MCSectionData *SD = 0)
296     : MCFragment(FT_Org, SD),
297       Offset(&_Offset), Value(_Value) {}
298
299   /// @name Accessors
300   /// @{
301
302   uint64_t getMaxFileSize() const {
303     // FIXME: This doesn't make much sense.
304     return ~UINT64_C(0);
305   }
306
307   const MCExpr &getOffset() const { return *Offset; }
308
309   uint8_t getValue() const { return Value; }
310
311   /// @}
312
313   static bool classof(const MCFragment *F) {
314     return F->getKind() == MCFragment::FT_Org;
315   }
316   static bool classof(const MCOrgFragment *) { return true; }
317
318   virtual void dump();
319 };
320
321 /// MCZeroFillFragment - Represent data which has a fixed size and alignment,
322 /// but requires no physical space in the object file.
323 class MCZeroFillFragment : public MCFragment {
324   /// Size - The size of this fragment.
325   uint64_t Size;
326
327   /// Alignment - The alignment for this fragment.
328   unsigned Alignment;
329
330 public:
331   MCZeroFillFragment(uint64_t _Size, unsigned _Alignment, MCSectionData *SD = 0)
332     : MCFragment(FT_ZeroFill, SD),
333       Size(_Size), Alignment(_Alignment) {}
334
335   /// @name Accessors
336   /// @{
337
338   uint64_t getMaxFileSize() const {
339     // FIXME: This also doesn't make much sense, this method is misnamed.
340     return ~UINT64_C(0);
341   }
342
343   uint64_t getSize() const { return Size; }
344
345   unsigned getAlignment() const { return Alignment; }
346
347   /// @}
348
349   static bool classof(const MCFragment *F) {
350     return F->getKind() == MCFragment::FT_ZeroFill;
351   }
352   static bool classof(const MCZeroFillFragment *) { return true; }
353
354   virtual void dump();
355 };
356
357 // FIXME: Should this be a separate class, or just merged into MCSection? Since
358 // we anticipate the fast path being through an MCAssembler, the only reason to
359 // keep it out is for API abstraction.
360 class MCSectionData : public ilist_node<MCSectionData> {
361   MCSectionData(const MCSectionData&);  // DO NOT IMPLEMENT
362   void operator=(const MCSectionData&); // DO NOT IMPLEMENT
363
364 public:
365   typedef iplist<MCFragment> FragmentListType;
366
367   typedef FragmentListType::const_iterator const_iterator;
368   typedef FragmentListType::iterator iterator;
369
370   typedef FragmentListType::const_reverse_iterator const_reverse_iterator;
371   typedef FragmentListType::reverse_iterator reverse_iterator;
372
373 private:
374   iplist<MCFragment> Fragments;
375   const MCSection *Section;
376
377   /// Alignment - The maximum alignment seen in this section.
378   unsigned Alignment;
379
380   /// @name Assembler Backend Data
381   /// @{
382   //
383   // FIXME: This could all be kept private to the assembler implementation.
384
385   /// Address - The computed address of this section. This is ~0 until
386   /// initialized.
387   uint64_t Address;
388
389   /// Size - The content size of this section. This is ~0 until initialized.
390   uint64_t Size;
391
392   /// FileSize - The size of this section in the object file. This is ~0 until
393   /// initialized.
394   uint64_t FileSize;
395
396   /// HasInstructions - Whether this section has had instructions emitted into
397   /// it.
398   unsigned HasInstructions : 1;
399
400   /// @}
401
402 public:
403   // Only for use as sentinel.
404   MCSectionData();
405   MCSectionData(const MCSection &Section, MCAssembler *A = 0);
406
407   const MCSection &getSection() const { return *Section; }
408
409   unsigned getAlignment() const { return Alignment; }
410   void setAlignment(unsigned Value) { Alignment = Value; }
411
412   /// @name Fragment Access
413   /// @{
414
415   const FragmentListType &getFragmentList() const { return Fragments; }
416   FragmentListType &getFragmentList() { return Fragments; }
417
418   iterator begin() { return Fragments.begin(); }
419   const_iterator begin() const { return Fragments.begin(); }
420
421   iterator end() { return Fragments.end(); }
422   const_iterator end() const { return Fragments.end(); }
423
424   reverse_iterator rbegin() { return Fragments.rbegin(); }
425   const_reverse_iterator rbegin() const { return Fragments.rbegin(); }
426
427   reverse_iterator rend() { return Fragments.rend(); }
428   const_reverse_iterator rend() const { return Fragments.rend(); }
429
430   size_t size() const { return Fragments.size(); }
431
432   bool empty() const { return Fragments.empty(); }
433
434   /// @}
435   /// @name Assembler Backend Support
436   /// @{
437   //
438   // FIXME: This could all be kept private to the assembler implementation.
439
440   uint64_t getAddress() const {
441     assert(Address != ~UINT64_C(0) && "Address not set!");
442     return Address;
443   }
444   void setAddress(uint64_t Value) { Address = Value; }
445
446   uint64_t getSize() const {
447     assert(Size != ~UINT64_C(0) && "File size not set!");
448     return Size;
449   }
450   void setSize(uint64_t Value) { Size = Value; }
451
452   uint64_t getFileSize() const {
453     assert(FileSize != ~UINT64_C(0) && "File size not set!");
454     return FileSize;
455   }
456   void setFileSize(uint64_t Value) { FileSize = Value; }
457
458   bool hasInstructions() const { return HasInstructions; }
459   void setHasInstructions(bool Value) { HasInstructions = Value; }
460
461   /// @}
462
463   void dump();
464 };
465
466 // FIXME: Same concerns as with SectionData.
467 class MCSymbolData : public ilist_node<MCSymbolData> {
468 public:
469   const MCSymbol *Symbol;
470
471   /// Fragment - The fragment this symbol's value is relative to, if any.
472   MCFragment *Fragment;
473
474   /// Offset - The offset to apply to the fragment address to form this symbol's
475   /// value.
476   uint64_t Offset;
477
478   /// IsExternal - True if this symbol is visible outside this translation
479   /// unit.
480   unsigned IsExternal : 1;
481
482   /// IsPrivateExtern - True if this symbol is private extern.
483   unsigned IsPrivateExtern : 1;
484
485   /// CommonSize - The size of the symbol, if it is 'common', or 0.
486   //
487   // FIXME: Pack this in with other fields? We could put it in offset, since a
488   // common symbol can never get a definition.
489   uint64_t CommonSize;
490
491   /// CommonAlign - The alignment of the symbol, if it is 'common'.
492   //
493   // FIXME: Pack this in with other fields?
494   unsigned CommonAlign;
495
496   /// Flags - The Flags field is used by object file implementations to store
497   /// additional per symbol information which is not easily classified.
498   uint32_t Flags;
499
500   /// Index - Index field, for use by the object file implementation.
501   uint64_t Index;
502
503 public:
504   // Only for use as sentinel.
505   MCSymbolData();
506   MCSymbolData(const MCSymbol &_Symbol, MCFragment *_Fragment, uint64_t _Offset,
507                MCAssembler *A = 0);
508
509   /// @name Accessors
510   /// @{
511
512   const MCSymbol &getSymbol() const { return *Symbol; }
513
514   MCFragment *getFragment() const { return Fragment; }
515   void setFragment(MCFragment *Value) { Fragment = Value; }
516
517   uint64_t getOffset() const { return Offset; }
518   void setOffset(uint64_t Value) { Offset = Value; }
519
520   uint64_t getAddress() const {
521     assert(getFragment() && "Invalid getAddress() on undefined symbol!");
522     return getFragment()->getAddress() + getOffset();
523   }
524
525   /// @}
526   /// @name Symbol Attributes
527   /// @{
528
529   bool isExternal() const { return IsExternal; }
530   void setExternal(bool Value) { IsExternal = Value; }
531
532   bool isPrivateExtern() const { return IsPrivateExtern; }
533   void setPrivateExtern(bool Value) { IsPrivateExtern = Value; }
534
535   /// isCommon - Is this a 'common' symbol.
536   bool isCommon() const { return CommonSize != 0; }
537
538   /// setCommon - Mark this symbol as being 'common'.
539   ///
540   /// \param Size - The size of the symbol.
541   /// \param Align - The alignment of the symbol.
542   void setCommon(uint64_t Size, unsigned Align) {
543     CommonSize = Size;
544     CommonAlign = Align;
545   }
546
547   /// getCommonSize - Return the size of a 'common' symbol.
548   uint64_t getCommonSize() const {
549     assert(isCommon() && "Not a 'common' symbol!");
550     return CommonSize;
551   }
552
553   /// getCommonAlignment - Return the alignment of a 'common' symbol.
554   unsigned getCommonAlignment() const {
555     assert(isCommon() && "Not a 'common' symbol!");
556     return CommonAlign;
557   }
558
559   /// getFlags - Get the (implementation defined) symbol flags.
560   uint32_t getFlags() const { return Flags; }
561
562   /// setFlags - Set the (implementation defined) symbol flags.
563   void setFlags(uint32_t Value) { Flags = Value; }
564
565   /// getIndex - Get the (implementation defined) index.
566   uint64_t getIndex() const { return Index; }
567
568   /// setIndex - Set the (implementation defined) index.
569   void setIndex(uint64_t Value) { Index = Value; }
570
571   /// @}
572
573   void dump();
574 };
575
576 // FIXME: This really doesn't belong here. See comments below.
577 struct IndirectSymbolData {
578   MCSymbol *Symbol;
579   MCSectionData *SectionData;
580 };
581
582 class MCAssembler {
583 public:
584   typedef iplist<MCSectionData> SectionDataListType;
585   typedef iplist<MCSymbolData> SymbolDataListType;
586
587   typedef SectionDataListType::const_iterator const_iterator;
588   typedef SectionDataListType::iterator iterator;
589
590   typedef SymbolDataListType::const_iterator const_symbol_iterator;
591   typedef SymbolDataListType::iterator symbol_iterator;
592
593   typedef std::vector<IndirectSymbolData>::const_iterator
594     const_indirect_symbol_iterator;
595   typedef std::vector<IndirectSymbolData>::iterator indirect_symbol_iterator;
596
597 private:
598   MCAssembler(const MCAssembler&);    // DO NOT IMPLEMENT
599   void operator=(const MCAssembler&); // DO NOT IMPLEMENT
600
601   MCContext &Context;
602
603   TargetAsmBackend &Backend;
604
605   raw_ostream &OS;
606
607   iplist<MCSectionData> Sections;
608
609   iplist<MCSymbolData> Symbols;
610
611   /// The map of sections to their associated assembler backend data.
612   //
613   // FIXME: Avoid this indirection?
614   DenseMap<const MCSection*, MCSectionData*> SectionMap;
615
616   /// The map of symbols to their associated assembler backend data.
617   //
618   // FIXME: Avoid this indirection?
619   DenseMap<const MCSymbol*, MCSymbolData*> SymbolMap;
620
621   std::vector<IndirectSymbolData> IndirectSymbols;
622
623   unsigned SubsectionsViaSymbols : 1;
624
625 private:
626   /// Check whether a fixup can be satisfied, or whether it needs to be relaxed
627   /// (increased in size, in order to hold its value correctly).
628   bool FixupNeedsRelaxation(MCAsmFixup &Fixup, MCDataFragment *DF);
629
630   /// LayoutSection - Assign offsets and sizes to the fragments in the section
631   /// \arg SD, and update the section size. The section file offset should
632   /// already have been computed.
633   void LayoutSection(MCSectionData &SD);
634
635   /// LayoutOnce - Perform one layout iteration and return true if any offsets
636   /// were adjusted.
637   bool LayoutOnce();
638
639   // FIXME: Make protected once we factor out object writer classes.
640 public:
641   /// Find the symbol which defines the atom containing given address, inside
642   /// the given section, or null if there is no such symbol.
643   //
644   // FIXME: Eliminate this, it is very slow.
645   const MCSymbolData *getAtomForAddress(const MCSectionData *Section,
646                                         uint64_t Address) const;
647
648   /// Find the symbol which defines the atom containing the given symbol, or
649   /// null if there is no such symbol.
650   //
651   // FIXME: Eliminate this, it is very slow.
652   const MCSymbolData *getAtom(const MCSymbolData *Symbol) const;
653
654   /// Check whether a particular symbol is visible to the linker and is required
655   /// in the symbol table, or whether it can be discarded by the assembler. This
656   /// also effects whether the assembler treats the label as potentially
657   /// defining a separate atom.
658   bool isSymbolLinkerVisible(const MCSymbolData *SD) const;
659
660   /// Evaluate a fixup to a relocatable expression and the value which should be
661   /// placed into the fixup.
662   ///
663   /// \param Layout The layout to use for evaluation.
664   /// \param Fixup The fixup to evaluate.
665   /// \param DF The fragment the fixup is inside.
666   /// \param Target [out] On return, the relocatable expression the fixup
667   /// evaluates to.
668   /// \param Value [out] On return, the value of the fixup as currently layed
669   /// out.
670   /// \return Whether the fixup value was fully resolved. This is true if the
671   /// \arg Value result is fixed, otherwise the value may change due to
672   /// relocation.
673   bool EvaluateFixup(const MCAsmLayout &Layout,
674                      MCAsmFixup &Fixup, MCDataFragment *DF,
675                      MCValue &Target, uint64_t &Value) const;
676
677 public:
678   /// Construct a new assembler instance.
679   ///
680   /// \arg OS - The stream to output to.
681   //
682   // FIXME: How are we going to parameterize this? Two obvious options are stay
683   // concrete and require clients to pass in a target like object. The other
684   // option is to make this abstract, and have targets provide concrete
685   // implementations as we do with AsmParser.
686   MCAssembler(MCContext &_Context, TargetAsmBackend &_Backend, raw_ostream &OS);
687   ~MCAssembler();
688
689   MCContext &getContext() const { return Context; }
690
691   TargetAsmBackend &getBackend() const { return Backend; }
692
693   /// Finish - Do final processing and write the object to the output stream.
694   void Finish();
695
696   // FIXME: This does not belong here.
697   bool getSubsectionsViaSymbols() const {
698     return SubsectionsViaSymbols;
699   }
700   void setSubsectionsViaSymbols(bool Value) {
701     SubsectionsViaSymbols = Value;
702   }
703
704   /// @name Section List Access
705   /// @{
706
707   const SectionDataListType &getSectionList() const { return Sections; }
708   SectionDataListType &getSectionList() { return Sections; }
709
710   iterator begin() { return Sections.begin(); }
711   const_iterator begin() const { return Sections.begin(); }
712
713   iterator end() { return Sections.end(); }
714   const_iterator end() const { return Sections.end(); }
715
716   size_t size() const { return Sections.size(); }
717
718   /// @}
719   /// @name Symbol List Access
720   /// @{
721
722   const SymbolDataListType &getSymbolList() const { return Symbols; }
723   SymbolDataListType &getSymbolList() { return Symbols; }
724
725   symbol_iterator symbol_begin() { return Symbols.begin(); }
726   const_symbol_iterator symbol_begin() const { return Symbols.begin(); }
727
728   symbol_iterator symbol_end() { return Symbols.end(); }
729   const_symbol_iterator symbol_end() const { return Symbols.end(); }
730
731   size_t symbol_size() const { return Symbols.size(); }
732
733   /// @}
734   /// @name Indirect Symbol List Access
735   /// @{
736
737   // FIXME: This is a total hack, this should not be here. Once things are
738   // factored so that the streamer has direct access to the .o writer, it can
739   // disappear.
740   std::vector<IndirectSymbolData> &getIndirectSymbols() {
741     return IndirectSymbols;
742   }
743
744   indirect_symbol_iterator indirect_symbol_begin() {
745     return IndirectSymbols.begin();
746   }
747   const_indirect_symbol_iterator indirect_symbol_begin() const {
748     return IndirectSymbols.begin();
749   }
750
751   indirect_symbol_iterator indirect_symbol_end() {
752     return IndirectSymbols.end();
753   }
754   const_indirect_symbol_iterator indirect_symbol_end() const {
755     return IndirectSymbols.end();
756   }
757
758   size_t indirect_symbol_size() const { return IndirectSymbols.size(); }
759
760   /// @}
761   /// @name Backend Data Access
762   /// @{
763
764   MCSectionData &getSectionData(const MCSection &Section) const {
765     MCSectionData *Entry = SectionMap.lookup(&Section);
766     assert(Entry && "Missing section data!");
767     return *Entry;
768   }
769
770   MCSectionData &getOrCreateSectionData(const MCSection &Section,
771                                         bool *Created = 0) {
772     MCSectionData *&Entry = SectionMap[&Section];
773
774     if (Created) *Created = !Entry;
775     if (!Entry)
776       Entry = new MCSectionData(Section, this);
777
778     return *Entry;
779   }
780
781   MCSymbolData &getSymbolData(const MCSymbol &Symbol) const {
782     MCSymbolData *Entry = SymbolMap.lookup(&Symbol);
783     assert(Entry && "Missing symbol data!");
784     return *Entry;
785   }
786
787   MCSymbolData &getOrCreateSymbolData(const MCSymbol &Symbol,
788                                       bool *Created = 0) {
789     MCSymbolData *&Entry = SymbolMap[&Symbol];
790
791     if (Created) *Created = !Entry;
792     if (!Entry)
793       Entry = new MCSymbolData(Symbol, 0, 0, this);
794
795     return *Entry;
796   }
797
798   /// @}
799
800   void dump();
801 };
802
803 } // end namespace llvm
804
805 #endif