| OLD | NEW |
| 1 //===- subzero/src/assembler.h - Integrated assembler -----------*- C++ -*-===// | 1 //===- subzero/src/assembler.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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 #endif // NDEBUG | 108 #endif // NDEBUG |
| 109 | 109 |
| 110 // Returns the position in the instruction stream. | 110 // Returns the position in the instruction stream. |
| 111 intptr_t GetPosition() const { return cursor_ - contents_; } | 111 intptr_t GetPosition() const { return cursor_ - contents_; } |
| 112 | 112 |
| 113 // Create and track a fixup in the current function. | 113 // Create and track a fixup in the current function. |
| 114 AssemblerFixup *createFixup(FixupKind Kind, const Constant *Value); | 114 AssemblerFixup *createFixup(FixupKind Kind, const Constant *Value); |
| 115 | 115 |
| 116 const FixupRefList &fixups() const { return fixups_; } | 116 const FixupRefList &fixups() const { return fixups_; } |
| 117 | 117 |
| 118 void setSize(intptr_t NewSize) { |
| 119 assert(NewSize < Size()); |
| 120 cursor_ = contents_ + NewSize; |
| 121 } |
| 122 |
| 118 private: | 123 private: |
| 119 // The limit is set to kMinimumGap bytes before the end of the data area. | 124 // The limit is set to kMinimumGap bytes before the end of the data area. |
| 120 // This leaves enough space for the longest possible instruction and allows | 125 // This leaves enough space for the longest possible instruction and allows |
| 121 // for a single, fast space check per instruction. | 126 // for a single, fast space check per instruction. |
| 122 static const intptr_t kMinimumGap = 32; | 127 static const intptr_t kMinimumGap = 32; |
| 123 | 128 |
| 124 uintptr_t contents_; | 129 uintptr_t contents_; |
| 125 uintptr_t cursor_; | 130 uintptr_t cursor_; |
| 126 uintptr_t limit_; | 131 uintptr_t limit_; |
| 127 Assembler &assembler_; | 132 Assembler &assembler_; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 | 192 |
| 188 AssemblerFixup *createFixup(FixupKind Kind, const Constant *Value) { | 193 AssemblerFixup *createFixup(FixupKind Kind, const Constant *Value) { |
| 189 return buffer_.createFixup(Kind, Value); | 194 return buffer_.createFixup(Kind, Value); |
| 190 } | 195 } |
| 191 | 196 |
| 192 void emitIASBytes(GlobalContext *Ctx) const; | 197 void emitIASBytes(GlobalContext *Ctx) const; |
| 193 bool getInternal() const { return IsInternal; } | 198 bool getInternal() const { return IsInternal; } |
| 194 void setInternal(bool Internal) { IsInternal = Internal; } | 199 void setInternal(bool Internal) { IsInternal = Internal; } |
| 195 const IceString &getFunctionName() { return FunctionName; } | 200 const IceString &getFunctionName() { return FunctionName; } |
| 196 void setFunctionName(const IceString &NewName) { FunctionName = NewName; } | 201 void setFunctionName(const IceString &NewName) { FunctionName = NewName; } |
| 202 intptr_t getBufferSize() const { return buffer_.Size(); } |
| 203 // Roll back to a (smaller) size. |
| 204 void setBufferSize(intptr_t NewSize) { buffer_.setSize(NewSize); } |
| 205 // Add nop padding of a particular width. |
| 206 virtual void padWithNop(intptr_t Padding) = 0; |
| 197 | 207 |
| 198 private: | 208 private: |
| 199 ArenaAllocator<32 * 1024> Allocator; | 209 ArenaAllocator<32 * 1024> Allocator; |
| 200 // FunctionName and IsInternal are transferred from the original Cfg | 210 // FunctionName and IsInternal are transferred from the original Cfg |
| 201 // object, since the Cfg object may be deleted by the time the | 211 // object, since the Cfg object may be deleted by the time the |
| 202 // assembler buffer is emitted. | 212 // assembler buffer is emitted. |
| 203 IceString FunctionName; | 213 IceString FunctionName; |
| 204 bool IsInternal; | 214 bool IsInternal; |
| 205 | 215 |
| 206 protected: | 216 protected: |
| 207 AssemblerBuffer buffer_; | 217 AssemblerBuffer buffer_; |
| 208 }; | 218 }; |
| 209 | 219 |
| 210 } // end of namespace Ice | 220 } // end of namespace Ice |
| 211 | 221 |
| 212 #endif // SUBZERO_SRC_ASSEMBLER_H_ | 222 #endif // SUBZERO_SRC_ASSEMBLER_H_ |
| OLD | NEW |