Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(566)

Side by Side Diff: src/IceAssembler.h

Issue 1418523002: Add hybrid assembler concept to ARM assembler. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix nits. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/IceAssembler.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceAssembler.h - Integrated assembler --------*- C++ -*-===// 1 //===- subzero/src/IceAssembler.h - Integrated assembler --------*- C++ -*-===//
2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
3 // for details. All rights reserved. Use of this source code is governed by a 3 // for details. All rights reserved. Use of this source code is governed by a
4 // BSD-style license that can be found in the LICENSE file. 4 // BSD-style license that can be found in the LICENSE file.
5 // 5 //
6 // Modified by the Subzero authors. 6 // Modified by the Subzero authors.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // The Subzero Code Generator 10 // The Subzero Code Generator
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 // Disable the actual check in non-debug mode. 167 // Disable the actual check in non-debug mode.
168 return true; 168 return true;
169 } 169 }
170 170
171 /// Returns the position in the instruction stream. 171 /// Returns the position in the instruction stream.
172 intptr_t getPosition() const { return Cursor - Contents; } 172 intptr_t getPosition() const { return Cursor - Contents; }
173 173
174 /// Create and track a fixup in the current function. 174 /// Create and track a fixup in the current function.
175 AssemblerFixup *createFixup(FixupKind Kind, const Constant *Value); 175 AssemblerFixup *createFixup(FixupKind Kind, const Constant *Value);
176 176
177 /// Create and track a textual fixup in the current function.
178 AssemblerTextFixup *createTextFixup(const std::string &Text,
179 size_t BytesUsed);
180
181 /// Mark that an attempt was made to emit, but failed. Hence, in order to
182 /// continue, one must emit a text fixup.
183 void setNeedsTextFixup() { TextFixupNeeded = true; }
184
185 /// Returns true if last emit failed and needs a text fixup.
186 bool needsTextFixup() const { return TextFixupNeeded; }
187
188 /// Installs a created fixup, after it has been allocated.
189 void installFixup(AssemblerFixup *F);
190
177 const FixupRefList &fixups() const { return Fixups; } 191 const FixupRefList &fixups() const { return Fixups; }
178 192
179 void setSize(intptr_t NewSize) { 193 void setSize(intptr_t NewSize) {
180 assert(NewSize <= size()); 194 assert(NewSize <= size());
181 Cursor = Contents + NewSize; 195 Cursor = Contents + NewSize;
182 } 196 }
183 197
184 private: 198 private:
185 /// The limit is set to kMinimumGap bytes before the end of the data area. 199 /// The limit is set to kMinimumGap bytes before the end of the data area.
186 /// This leaves enough space for the longest possible instruction and allows 200 /// This leaves enough space for the longest possible instruction and allows
187 /// for a single, fast space check per instruction. 201 /// for a single, fast space check per instruction.
188 static constexpr intptr_t kMinimumGap = 32; 202 static constexpr intptr_t kMinimumGap = 32;
189 203
190 uintptr_t Contents; 204 uintptr_t Contents;
191 uintptr_t Cursor; 205 uintptr_t Cursor;
192 uintptr_t Limit; 206 uintptr_t Limit;
193 // The member variable is named Assemblr to avoid hiding the class Assembler. 207 // The member variable is named Assemblr to avoid hiding the class Assembler.
194 Assembler &Assemblr; 208 Assembler &Assemblr;
195 /// List of pool-allocated fixups relative to the current function. 209 /// List of pool-allocated fixups relative to the current function.
196 FixupRefList Fixups; 210 FixupRefList Fixups;
211 // True if a textual fixup is needed, because the assembler was unable to
212 // emit the last request.
213 bool TextFixupNeeded;
197 214
198 uintptr_t cursor() const { return Cursor; } 215 uintptr_t cursor() const { return Cursor; }
199 uintptr_t limit() const { return Limit; } 216 uintptr_t limit() const { return Limit; }
200 intptr_t capacity() const { 217 intptr_t capacity() const {
201 assert(Limit >= Contents); 218 assert(Limit >= Contents);
202 return (Limit - Contents) + kMinimumGap; 219 return (Limit - Contents) + kMinimumGap;
203 } 220 }
204 221
205 /// Compute the limit based on the data area and the capacity. See description 222 /// Compute the limit based on the data area and the capacity. See description
206 /// of kMinimumGap for the reasoning behind the value. 223 /// of kMinimumGap for the reasoning behind the value.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 virtual Label *getCfgNodeLabel(SizeT NodeNumber) = 0; 278 virtual Label *getCfgNodeLabel(SizeT NodeNumber) = 0;
262 /// Mark the current text location as the start of a CFG node (represented by 279 /// Mark the current text location as the start of a CFG node (represented by
263 /// NodeNumber). 280 /// NodeNumber).
264 virtual void bindCfgNodeLabel(SizeT NodeNumber) = 0; 281 virtual void bindCfgNodeLabel(SizeT NodeNumber) = 0;
265 282
266 virtual bool fixupIsPCRel(FixupKind Kind) const = 0; 283 virtual bool fixupIsPCRel(FixupKind Kind) const = 0;
267 284
268 // Return a view of all the bytes of code for the current function. 285 // Return a view of all the bytes of code for the current function.
269 llvm::StringRef getBufferView() const; 286 llvm::StringRef getBufferView() const;
270 287
288 /// Emit a fixup at the current location.
289 void emitFixup(AssemblerFixup *Fixup) { Buffer.emitFixup(Fixup); }
290
271 const FixupRefList &fixups() const { return Buffer.fixups(); } 291 const FixupRefList &fixups() const { return Buffer.fixups(); }
272 292
273 AssemblerFixup *createFixup(FixupKind Kind, const Constant *Value) { 293 AssemblerFixup *createFixup(FixupKind Kind, const Constant *Value) {
274 return Buffer.createFixup(Kind, Value); 294 return Buffer.createFixup(Kind, Value);
275 } 295 }
276 296
297 AssemblerTextFixup *createTextFixup(const std::string &Text,
298 size_t BytesUsed) {
299 return Buffer.createTextFixup(Text, BytesUsed);
300 }
301
302 void setNeedsTextFixup() { Buffer.setNeedsTextFixup(); }
303
304 bool needsTextFixup() const { return Buffer.needsTextFixup(); }
305
277 void emitIASBytes() const; 306 void emitIASBytes() const;
278 bool getInternal() const { return IsInternal; } 307 bool getInternal() const { return IsInternal; }
279 void setInternal(bool Internal) { IsInternal = Internal; } 308 void setInternal(bool Internal) { IsInternal = Internal; }
280 const IceString &getFunctionName() { return FunctionName; } 309 const IceString &getFunctionName() { return FunctionName; }
281 void setFunctionName(const IceString &NewName) { FunctionName = NewName; } 310 void setFunctionName(const IceString &NewName) { FunctionName = NewName; }
282 intptr_t getBufferSize() const { return Buffer.size(); } 311 intptr_t getBufferSize() const { return Buffer.size(); }
283 /// Roll back to a (smaller) size. 312 /// Roll back to a (smaller) size.
284 void setBufferSize(intptr_t NewSize) { Buffer.setSize(NewSize); } 313 void setBufferSize(intptr_t NewSize) { Buffer.setSize(NewSize); }
285 void setPreliminary(bool Value) { Preliminary = Value; } 314 void setPreliminary(bool Value) { Preliminary = Value; }
286 bool getPreliminary() const { return Preliminary; } 315 bool getPreliminary() const { return Preliminary; }
(...skipping 12 matching lines...) Expand all
299 /// since the Cfg object may be deleted by the time the assembler buffer is 328 /// since the Cfg object may be deleted by the time the assembler buffer is
300 /// emitted. 329 /// emitted.
301 IceString FunctionName = ""; 330 IceString FunctionName = "";
302 bool IsInternal = false; 331 bool IsInternal = false;
303 /// Preliminary indicates whether a preliminary pass is being made for 332 /// Preliminary indicates whether a preliminary pass is being made for
304 /// calculating bundle padding (Preliminary=true), versus the final pass where 333 /// calculating bundle padding (Preliminary=true), versus the final pass where
305 /// all changes to label bindings, label links, and relocation fixups are 334 /// all changes to label bindings, label links, and relocation fixups are
306 /// fully committed (Preliminary=false). 335 /// fully committed (Preliminary=false).
307 bool Preliminary = false; 336 bool Preliminary = false;
308 337
338 /// Installs a created fixup, after it has been allocated.
339 void installFixup(AssemblerFixup *F) { Buffer.installFixup(F); }
340
309 protected: 341 protected:
310 GlobalContext *Ctx; 342 GlobalContext *Ctx;
311 // Buffer's constructor uses the Allocator, so it needs to appear after it. 343 // Buffer's constructor uses the Allocator, so it needs to appear after it.
312 // TODO(jpp): dependencies on construction order are a nice way of shooting 344 // TODO(jpp): dependencies on construction order are a nice way of shooting
313 // yourself in the foot. Fix this. 345 // yourself in the foot. Fix this.
314 AssemblerBuffer Buffer; 346 AssemblerBuffer Buffer;
315 }; 347 };
316 348
317 } // end of namespace Ice 349 } // end of namespace Ice
318 350
319 #endif // SUBZERO_SRC_ICEASSEMBLER_H_ 351 #endif // SUBZERO_SRC_ICEASSEMBLER_H_
OLDNEW
« no previous file with comments | « no previous file | src/IceAssembler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698