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/ilist.h"
14 #include "llvm/ADT/ilist_node.h"
15 #include "llvm/Support/DataTypes.h"
23 class MCFragment
: public ilist_node
<MCFragment
> {
24 MCFragment(const MCFragment
&); // DO NOT IMPLEMENT
25 void operator=(const MCFragment
&); // DO NOT IMPLEMENT
28 MCFragment(MCSectionData
*SD
= 0);
31 // FIXME: Should this be a separate class, or just merged into MCSection? Since
32 // we anticipate the fast path being through an MCAssembler, the only reason to
33 // keep it out is for API abstraction.
34 class MCSectionData
: public ilist_node
<MCSectionData
> {
35 MCSectionData(const MCSectionData
&); // DO NOT IMPLEMENT
36 void operator=(const MCSectionData
&); // DO NOT IMPLEMENT
39 typedef iplist
<MCFragment
> FragmentListType
;
42 iplist
<MCFragment
> Fragments
;
43 const MCSection
&Section
;
45 /// Alignment - The maximum alignment seen in this section.
48 /// @name Assembler Backend Data
51 // FIXME: This could all be kept private to the assembler implementation.
53 /// FileOffset - The offset of this section in the object file.
56 /// FileSize - The size of this section in the object file.
62 // Only for use as sentinel.
64 MCSectionData(const MCSection
&Section
, MCAssembler
*A
= 0);
66 const FragmentListType
&getFragmentList() const { return Fragments
; }
67 FragmentListType
&getFragmentList() { return Fragments
; }
69 const MCSection
&getSection() const { return Section
; }
71 unsigned getAlignment() const { return Alignment
; }
72 void setAlignment(unsigned Value
) { Alignment
= Value
; }
74 /// @name Assembler Backend Support
77 // FIXME: This could all be kept private to the assembler implementation.
79 unsigned getFileSize() const { return FileSize
; }
81 uint64_t getFileOffset() const { return FileOffset
; }
82 void setFileOffset(uint64_t Value
) { FileOffset
= Value
; }
84 void WriteFileData(raw_ostream
&OS
) const;
91 typedef iplist
<MCSectionData
> SectionDataListType
;
93 typedef SectionDataListType::const_iterator const_iterator
;
94 typedef SectionDataListType::iterator iterator
;
97 MCAssembler(const MCAssembler
&); // DO NOT IMPLEMENT
98 void operator=(const MCAssembler
&); // DO NOT IMPLEMENT
102 iplist
<MCSectionData
> Sections
;
105 /// Construct a new assembler instance.
107 /// \arg OS - The stream to output to.
109 // FIXME: How are we going to parameterize this? Two obvious options are stay
110 // concrete and require clients to pass in a target like object. The other
111 // option is to make this abstract, and have targets provide concrete
112 // implementations as we do with AsmParser.
113 MCAssembler(raw_ostream
&OS
);
116 /// Finish - Do final processing and write the object to the output stream.
119 /// @name Section List Access
122 const SectionDataListType
&getSectionList() const { return Sections
; }
123 SectionDataListType
&getSectionList() { return Sections
; }
125 iterator
begin() { return Sections
.begin(); }
126 const_iterator
begin() const { return Sections
.begin(); }
128 iterator
end() { return Sections
.end(); }
129 const_iterator
end() const { return Sections
.end(); }
131 size_t size() const { return Sections
.size(); }
136 } // end namespace llvm