~louis/ubuntu/trusty/clamav/lp799623_fix_logrotate

« back to all changes in this revision

Viewing changes to libclamav/c++/llvm/include/llvm/MC/MCAssembler.h

  • Committer: Bazaar Package Importer
  • Author(s): Scott Kitterman
  • Date: 2010-03-12 11:30:04 UTC
  • mfrom: (0.41.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100312113004-b0fop4bkycszdd0z
Tags: 0.96~rc1+dfsg-0ubuntu1
* New upstream RC - FFE (LP: #537636):
  - Add OfficialDatabaseOnly option to clamav-base.postinst.in
  - Add LocalSocketGroup option to clamav-base.postinst.in
  - Add LocalSocketMode option to clamav-base.postinst.in
  - Add CrossFilesystems option to clamav-base.postinst.in
  - Add ClamukoScannerCount option to clamav-base.postinst.in
  - Add BytecodeSecurity opiton to clamav-base.postinst.in
  - Add DetectionStatsHostID option to clamav-freshclam.postinst.in
  - Add Bytecode option to clamav-freshclam.postinst.in
  - Add MilterSocketGroup option to clamav-milter.postinst.in
  - Add MilterSocketMode option to clamav-milter.postinst.in
  - Add ReportHostname option to clamav-milter.postinst.in
  - Bump libclamav SO version to 6.1.0 in libclamav6.install
  - Drop clamdmon from clamav.examples (no longer shipped by upstream)
  - Drop libclamav.a from libclamav-dev.install (not built by upstream)
  - Update SO version for lintian override for libclamav6
  - Add new Bytecode Testing Tool, usr/bin/clambc, to clamav.install
  - Add build-depends on python and python-setuptools for new test suite
  - Update debian/copyright for the embedded copy of llvm (using the system
    llvm is not currently feasible)

Show diffs side-by-side

added added

removed removed

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