| 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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 // Compute the limit based on the data area and the capacity. See | 137 // Compute the limit based on the data area and the capacity. See |
| 138 // description of kMinimumGap for the reasoning behind the value. | 138 // description of kMinimumGap for the reasoning behind the value. |
| 139 static uintptr_t computeLimit(uintptr_t Data, intptr_t Capacity) { | 139 static uintptr_t computeLimit(uintptr_t Data, intptr_t Capacity) { |
| 140 return Data + Capacity - kMinimumGap; | 140 return Data + Capacity - kMinimumGap; |
| 141 } | 141 } |
| 142 | 142 |
| 143 void extendCapacity(); | 143 void extendCapacity(); |
| 144 }; | 144 }; |
| 145 | 145 |
| 146 class Assembler { | 146 class Assembler { |
| 147 Assembler() = delete; |
| 147 Assembler(const Assembler &) = delete; | 148 Assembler(const Assembler &) = delete; |
| 148 Assembler &operator=(const Assembler &) = delete; | 149 Assembler &operator=(const Assembler &) = delete; |
| 149 | 150 |
| 150 public: | 151 public: |
| 151 Assembler() : Allocator(), Buffer(*this) {} | 152 enum AssemblerKind { |
| 153 Asm_ARM32, |
| 154 Asm_MIPS32, |
| 155 Asm_X8632, |
| 156 Asm_X8664, |
| 157 }; |
| 158 |
| 152 virtual ~Assembler() = default; | 159 virtual ~Assembler() = default; |
| 153 | 160 |
| 154 // Allocate a chunk of bytes using the per-Assembler allocator. | 161 // Allocate a chunk of bytes using the per-Assembler allocator. |
| 155 uintptr_t allocateBytes(size_t bytes) { | 162 uintptr_t allocateBytes(size_t bytes) { |
| 156 // For now, alignment is not related to NaCl bundle alignment, since | 163 // For now, alignment is not related to NaCl bundle alignment, since |
| 157 // the buffer's GetPosition is relative to the base. So NaCl bundle | 164 // the buffer's GetPosition is relative to the base. So NaCl bundle |
| 158 // alignment checks can be relative to that base. Later, the buffer | 165 // alignment checks can be relative to that base. Later, the buffer |
| 159 // will be copied out to a ".text" section (or an in memory-buffer | 166 // will be copied out to a ".text" section (or an in memory-buffer |
| 160 // that can be mprotect'ed with executable permission), and that | 167 // that can be mprotect'ed with executable permission), and that |
| 161 // second buffer should be aligned for NaCl. | 168 // second buffer should be aligned for NaCl. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 bool getInternal() const { return IsInternal; } | 203 bool getInternal() const { return IsInternal; } |
| 197 void setInternal(bool Internal) { IsInternal = Internal; } | 204 void setInternal(bool Internal) { IsInternal = Internal; } |
| 198 const IceString &getFunctionName() { return FunctionName; } | 205 const IceString &getFunctionName() { return FunctionName; } |
| 199 void setFunctionName(const IceString &NewName) { FunctionName = NewName; } | 206 void setFunctionName(const IceString &NewName) { FunctionName = NewName; } |
| 200 intptr_t getBufferSize() const { return Buffer.size(); } | 207 intptr_t getBufferSize() const { return Buffer.size(); } |
| 201 // Roll back to a (smaller) size. | 208 // Roll back to a (smaller) size. |
| 202 void setBufferSize(intptr_t NewSize) { Buffer.setSize(NewSize); } | 209 void setBufferSize(intptr_t NewSize) { Buffer.setSize(NewSize); } |
| 203 void setPreliminary(bool Value) { Preliminary = Value; } | 210 void setPreliminary(bool Value) { Preliminary = Value; } |
| 204 bool getPreliminary() const { return Preliminary; } | 211 bool getPreliminary() const { return Preliminary; } |
| 205 | 212 |
| 213 AssemblerKind getKind() const { return Kind; } |
| 214 |
| 215 protected: |
| 216 explicit Assembler(AssemblerKind Kind) |
| 217 : Kind(Kind), Allocator(), Buffer(*this) {} |
| 218 |
| 206 private: | 219 private: |
| 220 const AssemblerKind Kind; |
| 221 |
| 207 ArenaAllocator<32 * 1024> Allocator; | 222 ArenaAllocator<32 * 1024> Allocator; |
| 208 // FunctionName and IsInternal are transferred from the original Cfg | 223 // FunctionName and IsInternal are transferred from the original Cfg |
| 209 // object, since the Cfg object may be deleted by the time the | 224 // object, since the Cfg object may be deleted by the time the |
| 210 // assembler buffer is emitted. | 225 // assembler buffer is emitted. |
| 211 IceString FunctionName = ""; | 226 IceString FunctionName = ""; |
| 212 bool IsInternal = false; | 227 bool IsInternal = false; |
| 213 // Preliminary indicates whether a preliminary pass is being made | 228 // Preliminary indicates whether a preliminary pass is being made |
| 214 // for calculating bundle padding (Preliminary=true), versus the | 229 // for calculating bundle padding (Preliminary=true), versus the |
| 215 // final pass where all changes to label bindings, label links, and | 230 // final pass where all changes to label bindings, label links, and |
| 216 // relocation fixups are fully committed (Preliminary=false). | 231 // relocation fixups are fully committed (Preliminary=false). |
| 217 bool Preliminary = false; | 232 bool Preliminary = false; |
| 218 | 233 |
| 219 protected: | 234 protected: |
| 220 // Buffer's constructor uses the Allocator, so it needs to appear after it. | 235 // Buffer's constructor uses the Allocator, so it needs to appear after it. |
| 221 // TODO(jpp): dependencies on construction order are a nice way of shooting | 236 // TODO(jpp): dependencies on construction order are a nice way of shooting |
| 222 // yourself in the foot. Fix this. | 237 // yourself in the foot. Fix this. |
| 223 AssemblerBuffer Buffer; | 238 AssemblerBuffer Buffer; |
| 224 }; | 239 }; |
| 225 | 240 |
| 226 } // end of namespace Ice | 241 } // end of namespace Ice |
| 227 | 242 |
| 228 #endif // SUBZERO_SRC_ICEASSEMBLER_H_ | 243 #endif // SUBZERO_SRC_ICEASSEMBLER_H_ |
| OLD | NEW |