| OLD | NEW |
| 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 | 230 |
| 231 void extendCapacity(); | 231 void extendCapacity(); |
| 232 }; | 232 }; |
| 233 | 233 |
| 234 class Assembler { | 234 class Assembler { |
| 235 Assembler() = delete; | 235 Assembler() = delete; |
| 236 Assembler(const Assembler &) = delete; | 236 Assembler(const Assembler &) = delete; |
| 237 Assembler &operator=(const Assembler &) = delete; | 237 Assembler &operator=(const Assembler &) = delete; |
| 238 | 238 |
| 239 public: | 239 public: |
| 240 using InternalRelocationList = | |
| 241 std::vector<std::pair<const IceString, const SizeT>>; | |
| 242 | |
| 243 enum AssemblerKind { | 240 enum AssemblerKind { |
| 244 Asm_ARM32, | 241 Asm_ARM32, |
| 245 Asm_MIPS32, | 242 Asm_MIPS32, |
| 246 Asm_X8632, | 243 Asm_X8632, |
| 247 Asm_X8664, | 244 Asm_X8664, |
| 248 }; | 245 }; |
| 249 | 246 |
| 250 virtual ~Assembler() = default; | 247 virtual ~Assembler() = default; |
| 251 | 248 |
| 252 /// Allocate a chunk of bytes using the per-Assembler allocator. | 249 /// Allocate a chunk of bytes using the per-Assembler allocator. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 const IceString &getFunctionName() { return FunctionName; } | 316 const IceString &getFunctionName() { return FunctionName; } |
| 320 void setFunctionName(const IceString &NewName) { FunctionName = NewName; } | 317 void setFunctionName(const IceString &NewName) { FunctionName = NewName; } |
| 321 intptr_t getBufferSize() const { return Buffer.size(); } | 318 intptr_t getBufferSize() const { return Buffer.size(); } |
| 322 /// Roll back to a (smaller) size. | 319 /// Roll back to a (smaller) size. |
| 323 void setBufferSize(intptr_t NewSize) { Buffer.setSize(NewSize); } | 320 void setBufferSize(intptr_t NewSize) { Buffer.setSize(NewSize); } |
| 324 void setPreliminary(bool Value) { Preliminary = Value; } | 321 void setPreliminary(bool Value) { Preliminary = Value; } |
| 325 bool getPreliminary() const { return Preliminary; } | 322 bool getPreliminary() const { return Preliminary; } |
| 326 | 323 |
| 327 AssemblerKind getKind() const { return Kind; } | 324 AssemblerKind getKind() const { return Kind; } |
| 328 | 325 |
| 329 void addRelocationAtCurrentPosition(const IceString &RelocName) { | |
| 330 if (!getPreliminary()) { | |
| 331 InternalRelocs.emplace_back(RelocName, getBufferSize()); | |
| 332 } | |
| 333 } | |
| 334 | |
| 335 const InternalRelocationList &getInternalRelocations() const { | |
| 336 return InternalRelocs; | |
| 337 } | |
| 338 | |
| 339 protected: | 326 protected: |
| 340 explicit Assembler(AssemblerKind Kind) | 327 explicit Assembler(AssemblerKind Kind) |
| 341 : Kind(Kind), Allocator(), Buffer(*this) {} | 328 : Kind(Kind), Allocator(), Buffer(*this) {} |
| 342 | 329 |
| 343 private: | 330 private: |
| 344 const AssemblerKind Kind; | 331 const AssemblerKind Kind; |
| 345 InternalRelocationList InternalRelocs; | |
| 346 | 332 |
| 347 ArenaAllocator<32 * 1024> Allocator; | 333 ArenaAllocator<32 * 1024> Allocator; |
| 348 /// FunctionName and IsInternal are transferred from the original Cfg object, | 334 /// FunctionName and IsInternal are transferred from the original Cfg object, |
| 349 /// since the Cfg object may be deleted by the time the assembler buffer is | 335 /// since the Cfg object may be deleted by the time the assembler buffer is |
| 350 /// emitted. | 336 /// emitted. |
| 351 IceString FunctionName = ""; | 337 IceString FunctionName = ""; |
| 352 bool IsInternal = false; | 338 bool IsInternal = false; |
| 353 /// Preliminary indicates whether a preliminary pass is being made for | 339 /// Preliminary indicates whether a preliminary pass is being made for |
| 354 /// calculating bundle padding (Preliminary=true), versus the final pass where | 340 /// calculating bundle padding (Preliminary=true), versus the final pass where |
| 355 /// all changes to label bindings, label links, and relocation fixups are | 341 /// all changes to label bindings, label links, and relocation fixups are |
| 356 /// fully committed (Preliminary=false). | 342 /// fully committed (Preliminary=false). |
| 357 bool Preliminary = false; | 343 bool Preliminary = false; |
| 358 | 344 |
| 359 /// Installs a created fixup, after it has been allocated. | 345 /// Installs a created fixup, after it has been allocated. |
| 360 void installFixup(AssemblerFixup *F) { Buffer.installFixup(F); } | 346 void installFixup(AssemblerFixup *F) { Buffer.installFixup(F); } |
| 361 | 347 |
| 362 protected: | 348 protected: |
| 363 // Buffer's constructor uses the Allocator, so it needs to appear after it. | 349 // Buffer's constructor uses the Allocator, so it needs to appear after it. |
| 364 // TODO(jpp): dependencies on construction order are a nice way of shooting | 350 // TODO(jpp): dependencies on construction order are a nice way of shooting |
| 365 // yourself in the foot. Fix this. | 351 // yourself in the foot. Fix this. |
| 366 AssemblerBuffer Buffer; | 352 AssemblerBuffer Buffer; |
| 367 }; | 353 }; |
| 368 | 354 |
| 369 } // end of namespace Ice | 355 } // end of namespace Ice |
| 370 | 356 |
| 371 #endif // SUBZERO_SRC_ICEASSEMBLER_H_ | 357 #endif // SUBZERO_SRC_ICEASSEMBLER_H_ |
| OLD | NEW |