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 39 matching lines...) Loading... |
50 return *reinterpret_cast<T *>(contents_ + position); | 50 return *reinterpret_cast<T *>(contents_ + position); |
51 } | 51 } |
52 | 52 |
53 template <typename T> void Store(intptr_t position, T value) { | 53 template <typename T> void Store(intptr_t position, T value) { |
54 assert(position >= 0 && | 54 assert(position >= 0 && |
55 position <= (Size() - static_cast<intptr_t>(sizeof(T)))); | 55 position <= (Size() - static_cast<intptr_t>(sizeof(T)))); |
56 *reinterpret_cast<T *>(contents_ + position) = value; | 56 *reinterpret_cast<T *>(contents_ + position) = value; |
57 } | 57 } |
58 | 58 |
59 // Emit a fixup at the current location. | 59 // Emit a fixup at the current location. |
60 void EmitFixup(AssemblerFixup *fixup) { | 60 void EmitFixup(AssemblerFixup *fixup) { fixup->set_position(Size()); } |
61 fixup->set_position(Size()); | |
62 } | |
63 | 61 |
64 // Get the size of the emitted code. | 62 // Get the size of the emitted code. |
65 intptr_t Size() const { return cursor_ - contents_; } | 63 intptr_t Size() const { return cursor_ - contents_; } |
66 uintptr_t contents() const { return contents_; } | 64 uintptr_t contents() const { return contents_; } |
67 | 65 |
68 // To emit an instruction to the assembler buffer, the EnsureCapacity helper | 66 // To emit an instruction to the assembler buffer, the EnsureCapacity helper |
69 // must be used to guarantee that the underlying data area is big enough to | 67 // must be used to guarantee that the underlying data area is big enough to |
70 // hold the emitted instruction. Usage: | 68 // hold the emitted instruction. Usage: |
71 // | 69 // |
72 // AssemblerBuffer buffer; | 70 // AssemblerBuffer buffer; |
(...skipping 123 matching lines...) Loading... |
196 private: | 194 private: |
197 ArenaAllocator<32 * 1024> Allocator; | 195 ArenaAllocator<32 * 1024> Allocator; |
198 | 196 |
199 protected: | 197 protected: |
200 AssemblerBuffer buffer_; | 198 AssemblerBuffer buffer_; |
201 }; | 199 }; |
202 | 200 |
203 } // end of namespace Ice | 201 } // end of namespace Ice |
204 | 202 |
205 #endif // SUBZERO_SRC_ASSEMBLER_H_ | 203 #endif // SUBZERO_SRC_ASSEMBLER_H_ |
OLD | NEW |