| 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 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 #ifndef SUBZERO_SRC_ICEASSEMBLER_H | 26 #ifndef SUBZERO_SRC_ICEASSEMBLER_H |
| 27 #define SUBZERO_SRC_ICEASSEMBLER_H | 27 #define SUBZERO_SRC_ICEASSEMBLER_H |
| 28 | 28 |
| 29 #include "IceDefs.h" | 29 #include "IceDefs.h" |
| 30 #include "IceFixups.h" | 30 #include "IceFixups.h" |
| 31 #include "IceUtils.h" | 31 #include "IceUtils.h" |
| 32 | 32 |
| 33 namespace Ice { | 33 namespace Ice { |
| 34 | 34 |
| 35 class Assembler; |
| 36 |
| 35 /// A Label can be in one of three states: | 37 /// A Label can be in one of three states: |
| 36 /// - Unused. | 38 /// - Unused. |
| 37 /// - Linked, unplaced and tracking the position of branches to the label. | 39 /// - Linked, unplaced and tracking the position of branches to the label. |
| 38 /// - Bound, placed and tracking its position. | 40 /// - Bound, placed and tracking its position. |
| 39 class Label { | 41 class Label { |
| 40 Label(const Label &) = delete; | 42 Label(const Label &) = delete; |
| 41 Label &operator=(const Label &) = delete; | 43 Label &operator=(const Label &) = delete; |
| 42 | 44 |
| 43 public: | 45 public: |
| 44 Label() = default; | 46 Label() = default; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 75 bool isLinked() const { return Position > 0; } | 77 bool isLinked() const { return Position > 0; } |
| 76 | 78 |
| 77 virtual bool isUnused() const { return Position == 0; } | 79 virtual bool isUnused() const { return Position == 0; } |
| 78 | 80 |
| 79 void bindTo(intptr_t position) { | 81 void bindTo(intptr_t position) { |
| 80 assert(!isBound()); | 82 assert(!isBound()); |
| 81 Position = -position - kWordSize; | 83 Position = -position - kWordSize; |
| 82 assert(isBound()); | 84 assert(isBound()); |
| 83 } | 85 } |
| 84 | 86 |
| 85 void linkTo(intptr_t position) { | 87 void linkTo(const Assembler &Asm, intptr_t position); |
| 86 assert(!isBound()); | |
| 87 Position = position + kWordSize; | |
| 88 assert(isLinked()); | |
| 89 } | |
| 90 | 88 |
| 91 protected: | 89 protected: |
| 92 intptr_t Position = 0; | 90 intptr_t Position = 0; |
| 93 | 91 |
| 94 // TODO(jvoung): why are labels offset by this? | 92 // TODO(jvoung): why are labels offset by this? |
| 95 static constexpr uint32_t kWordSize = sizeof(uint32_t); | 93 static constexpr uint32_t kWordSize = sizeof(uint32_t); |
| 96 }; | 94 }; |
| 97 | 95 |
| 98 /// Assembler buffers are used to emit binary code. They grow on demand. | 96 /// Assembler buffers are used to emit binary code. They grow on demand. |
| 99 class AssemblerBuffer { | 97 class AssemblerBuffer { |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 protected: | 348 protected: |
| 351 // 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. |
| 352 // 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 |
| 353 // yourself in the foot. Fix this. | 351 // yourself in the foot. Fix this. |
| 354 AssemblerBuffer Buffer; | 352 AssemblerBuffer Buffer; |
| 355 }; | 353 }; |
| 356 | 354 |
| 357 } // end of namespace Ice | 355 } // end of namespace Ice |
| 358 | 356 |
| 359 #endif // SUBZERO_SRC_ICEASSEMBLER_H_ | 357 #endif // SUBZERO_SRC_ICEASSEMBLER_H_ |
| OLD | NEW |