| 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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() {} |
| 210 ~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; |
| 228 |
| 227 private: | 229 private: |
| 228 llvm::BumpPtrAllocator Allocator; | 230 llvm::BumpPtrAllocator Allocator; |
| 229 }; | 231 }; |
| 230 | 232 |
| 231 } // end of namespace Ice | 233 } // end of namespace Ice |
| 232 | 234 |
| 233 #endif // SUBZERO_SRC_ASSEMBLER_H_ | 235 #endif // SUBZERO_SRC_ASSEMBLER_H_ |
| OLD | NEW |