Fix build on platforms where stdint.h is not implicitly included in the standard...
[llvm/avr.git] / include / llvm / MC / MCAssembler.h
blobb2a24159a75b7c5a031296cf2bc9522e08cd5591
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 //===----------------------------------------------------------------------===//
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"
17 namespace llvm {
18 class raw_ostream;
19 class MCAssembler;
20 class MCSection;
21 class MCSectionData;
23 class MCFragment : public ilist_node<MCFragment> {
24 MCFragment(const MCFragment&); // DO NOT IMPLEMENT
25 void operator=(const MCFragment&); // DO NOT IMPLEMENT
27 public:
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
38 public:
39 typedef iplist<MCFragment> FragmentListType;
41 private:
42 iplist<MCFragment> Fragments;
43 const MCSection &Section;
45 /// Alignment - The maximum alignment seen in this section.
46 unsigned Alignment;
48 /// @name Assembler Backend Data
49 /// @{
51 // FIXME: This could all be kept private to the assembler implementation.
53 /// FileOffset - The offset of this section in the object file.
54 uint64_t FileOffset;
56 /// FileSize - The size of this section in the object file.
57 uint64_t FileSize;
59 /// @}
61 public:
62 // Only for use as sentinel.
63 MCSectionData();
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
75 /// @{
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;
86 /// @}
89 class MCAssembler {
90 public:
91 typedef iplist<MCSectionData> SectionDataListType;
93 typedef SectionDataListType::const_iterator const_iterator;
94 typedef SectionDataListType::iterator iterator;
96 private:
97 MCAssembler(const MCAssembler&); // DO NOT IMPLEMENT
98 void operator=(const MCAssembler&); // DO NOT IMPLEMENT
100 raw_ostream &OS;
102 iplist<MCSectionData> Sections;
104 public:
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);
114 ~MCAssembler();
116 /// Finish - Do final processing and write the object to the output stream.
117 void Finish();
119 /// @name Section List Access
120 /// @{
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(); }
133 /// @}
136 } // end namespace llvm
138 #endif