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 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 void ExtendCapacity(); | 199 void ExtendCapacity(); |
200 | 200 |
201 friend class AssemblerFixup; | 201 friend class AssemblerFixup; |
202 }; | 202 }; |
203 | 203 |
204 class Assembler { | 204 class Assembler { |
205 Assembler(const Assembler &) = delete; | 205 Assembler(const Assembler &) = delete; |
206 Assembler &operator=(const Assembler &) = delete; | 206 Assembler &operator=(const Assembler &) = delete; |
207 | 207 |
208 public: | 208 public: |
209 Assembler() {} | 209 Assembler() : buffer_(*this) {} |
210 virtual ~Assembler() {} | 210 virtual ~Assembler() {} |
211 | 211 |
212 // Allocate a chunk of bytes using the per-Assembler allocator. | 212 // Allocate a chunk of bytes using the per-Assembler allocator. |
213 uintptr_t AllocateBytes(size_t bytes) { | 213 uintptr_t AllocateBytes(size_t bytes) { |
214 // For now, alignment is not related to NaCl bundle alignment, since | 214 // For now, alignment is not related to NaCl bundle alignment, since |
215 // the buffer's GetPosition is relative to the base. So NaCl bundle | 215 // the buffer's GetPosition is relative to the base. So NaCl bundle |
216 // alignment checks can be relative to that base. Later, the buffer | 216 // alignment checks can be relative to that base. Later, the buffer |
217 // will be copied out to a ".text" section (or an in memory-buffer | 217 // will be copied out to a ".text" section (or an in memory-buffer |
218 // that can be mprotect'ed with executable permission), and that | 218 // that can be mprotect'ed with executable permission), and that |
219 // second buffer should be aligned for NaCl. | 219 // second buffer should be aligned for NaCl. |
220 const size_t Alignment = 16; | 220 const size_t Alignment = 16; |
221 return reinterpret_cast<uintptr_t>(Allocator.Allocate(bytes, Alignment)); | 221 return reinterpret_cast<uintptr_t>(Allocator.Allocate(bytes, Alignment)); |
222 } | 222 } |
223 | 223 |
224 // Allocate data of type T using the per-Assembler allocator. | 224 // Allocate data of type T using the per-Assembler allocator. |
225 template <typename T> T *Allocate() { return Allocator.Allocate<T>(); } | 225 template <typename T> T *Allocate() { return Allocator.Allocate<T>(); } |
226 | 226 |
227 virtual void BindCfgNodeLabel(SizeT NodeNumber) = 0; | 227 virtual void BindCfgNodeLabel(SizeT NodeNumber) = 0; |
228 | 228 |
| 229 void emitIASBytes(GlobalContext *Ctx) const; |
| 230 |
229 private: | 231 private: |
230 llvm::BumpPtrAllocator Allocator; | 232 llvm::BumpPtrAllocator Allocator; |
| 233 |
| 234 protected: |
| 235 AssemblerBuffer buffer_; |
231 }; | 236 }; |
232 | 237 |
233 } // end of namespace Ice | 238 } // end of namespace Ice |
234 | 239 |
235 #endif // SUBZERO_SRC_ASSEMBLER_H_ | 240 #endif // SUBZERO_SRC_ASSEMBLER_H_ |
OLD | NEW |