comparison include/llvm/MC/MCLinkerOptimizationHint.h @ 95:afa8332a0e37 LLVM3.8

LLVM 3.8
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Tue, 13 Oct 2015 17:48:58 +0900
parents 60c9769439b8
children 1172e4bd9c6f
comparison
equal deleted inserted replaced
84:f3e34b893a5f 95:afa8332a0e37
101 MCLOHType Kind; 101 MCLOHType Kind;
102 102
103 /// Arguments of this directive. Order matters. 103 /// Arguments of this directive. Order matters.
104 SmallVector<MCSymbol *, 3> Args; 104 SmallVector<MCSymbol *, 3> Args;
105 105
106 /// Emit this directive in @p OutStream using the information available 106 /// Emit this directive in \p OutStream using the information available
107 /// in the given @p ObjWriter and @p Layout to get the address of the 107 /// in the given \p ObjWriter and \p Layout to get the address of the
108 /// arguments within the object file. 108 /// arguments within the object file.
109 void Emit_impl(raw_ostream &OutStream, const MachObjectWriter &ObjWriter, 109 void emit_impl(raw_ostream &OutStream, const MachObjectWriter &ObjWriter,
110 const MCAsmLayout &Layout) const; 110 const MCAsmLayout &Layout) const;
111 111
112 public: 112 public:
113 typedef SmallVectorImpl<MCSymbol *> LOHArgs; 113 typedef SmallVectorImpl<MCSymbol *> LOHArgs;
114 114
121 121
122 const LOHArgs &getArgs() const { return Args; } 122 const LOHArgs &getArgs() const { return Args; }
123 123
124 /// Emit this directive as: 124 /// Emit this directive as:
125 /// <kind, numArgs, addr1, ..., addrN> 125 /// <kind, numArgs, addr1, ..., addrN>
126 void Emit(MachObjectWriter &ObjWriter, const MCAsmLayout &Layout) const { 126 void emit(MachObjectWriter &ObjWriter, const MCAsmLayout &Layout) const {
127 raw_ostream &OutStream = ObjWriter.getStream(); 127 raw_ostream &OutStream = ObjWriter.getStream();
128 Emit_impl(OutStream, ObjWriter, Layout); 128 emit_impl(OutStream, ObjWriter, Layout);
129 } 129 }
130 130
131 /// Get the size in bytes of this directive if emitted in @p ObjWriter with 131 /// Get the size in bytes of this directive if emitted in \p ObjWriter with
132 /// the given @p Layout. 132 /// the given \p Layout.
133 uint64_t getEmitSize(const MachObjectWriter &ObjWriter, 133 uint64_t getEmitSize(const MachObjectWriter &ObjWriter,
134 const MCAsmLayout &Layout) const { 134 const MCAsmLayout &Layout) const {
135 class raw_counting_ostream : public raw_ostream { 135 class raw_counting_ostream : public raw_ostream {
136 uint64_t Count; 136 uint64_t Count;
137 137
139 139
140 uint64_t current_pos() const override { return Count; } 140 uint64_t current_pos() const override { return Count; }
141 141
142 public: 142 public:
143 raw_counting_ostream() : Count(0) {} 143 raw_counting_ostream() : Count(0) {}
144 ~raw_counting_ostream() { flush(); } 144 ~raw_counting_ostream() override { flush(); }
145 }; 145 };
146 146
147 raw_counting_ostream OutStream; 147 raw_counting_ostream OutStream;
148 Emit_impl(OutStream, ObjWriter, Layout); 148 emit_impl(OutStream, ObjWriter, Layout);
149 return OutStream.tell(); 149 return OutStream.tell();
150 } 150 }
151 }; 151 };
152 152
153 class MCLOHContainer { 153 class MCLOHContainer {
158 SmallVector<MCLOHDirective, 32> Directives; 158 SmallVector<MCLOHDirective, 32> Directives;
159 159
160 public: 160 public:
161 typedef SmallVectorImpl<MCLOHDirective> LOHDirectives; 161 typedef SmallVectorImpl<MCLOHDirective> LOHDirectives;
162 162
163 MCLOHContainer() : EmitSize(0) {}; 163 MCLOHContainer() : EmitSize(0) {}
164 164
165 /// Const accessor to the directives. 165 /// Const accessor to the directives.
166 const LOHDirectives &getDirectives() const { 166 const LOHDirectives &getDirectives() const {
167 return Directives; 167 return Directives;
168 } 168 }
169 169
170 /// Add the directive of the given kind @p Kind with the given arguments 170 /// Add the directive of the given kind \p Kind with the given arguments
171 /// @p Args to the container. 171 /// \p Args to the container.
172 void addDirective(MCLOHType Kind, const MCLOHDirective::LOHArgs &Args) { 172 void addDirective(MCLOHType Kind, const MCLOHDirective::LOHArgs &Args) {
173 Directives.push_back(MCLOHDirective(Kind, Args)); 173 Directives.push_back(MCLOHDirective(Kind, Args));
174 } 174 }
175 175
176 /// Get the size of the directives if emitted. 176 /// Get the size of the directives if emitted.
182 } 182 }
183 return EmitSize; 183 return EmitSize;
184 } 184 }
185 185
186 /// Emit all Linker Optimization Hint in one big table. 186 /// Emit all Linker Optimization Hint in one big table.
187 /// Each line of the table is emitted by LOHDirective::Emit. 187 /// Each line of the table is emitted by LOHDirective::emit.
188 void Emit(MachObjectWriter &ObjWriter, const MCAsmLayout &Layout) const { 188 void emit(MachObjectWriter &ObjWriter, const MCAsmLayout &Layout) const {
189 for (const MCLOHDirective &D : Directives) 189 for (const MCLOHDirective &D : Directives)
190 D.Emit(ObjWriter, Layout); 190 D.emit(ObjWriter, Layout);
191 } 191 }
192 192
193 void reset() { 193 void reset() {
194 Directives.clear(); 194 Directives.clear();
195 EmitSize = 0; 195 EmitSize = 0;