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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 } | 142 } |
143 | 143 |
144 void ExtendCapacity(); | 144 void ExtendCapacity(); |
145 }; | 145 }; |
146 | 146 |
147 class Assembler { | 147 class Assembler { |
148 Assembler(const Assembler &) = delete; | 148 Assembler(const Assembler &) = delete; |
149 Assembler &operator=(const Assembler &) = delete; | 149 Assembler &operator=(const Assembler &) = delete; |
150 | 150 |
151 public: | 151 public: |
152 Assembler() : buffer_(*this) {} | 152 Assembler() : FunctionName(""), IsInternal(false), buffer_(*this) {} |
153 virtual ~Assembler() {} | 153 virtual ~Assembler() {} |
154 | 154 |
155 // Allocate a chunk of bytes using the per-Assembler allocator. | 155 // Allocate a chunk of bytes using the per-Assembler allocator. |
156 uintptr_t AllocateBytes(size_t bytes) { | 156 uintptr_t AllocateBytes(size_t bytes) { |
157 // For now, alignment is not related to NaCl bundle alignment, since | 157 // For now, alignment is not related to NaCl bundle alignment, since |
158 // the buffer's GetPosition is relative to the base. So NaCl bundle | 158 // the buffer's GetPosition is relative to the base. So NaCl bundle |
159 // alignment checks can be relative to that base. Later, the buffer | 159 // alignment checks can be relative to that base. Later, the buffer |
160 // will be copied out to a ".text" section (or an in memory-buffer | 160 // will be copied out to a ".text" section (or an in memory-buffer |
161 // that can be mprotect'ed with executable permission), and that | 161 // that can be mprotect'ed with executable permission), and that |
162 // second buffer should be aligned for NaCl. | 162 // second buffer should be aligned for NaCl. |
(...skipping 20 matching lines...) Expand all Loading... |
183 // Return a view of all the bytes of code for the current function. | 183 // Return a view of all the bytes of code for the current function. |
184 llvm::StringRef getBufferView() const; | 184 llvm::StringRef getBufferView() const; |
185 | 185 |
186 const FixupRefList &fixups() const { return buffer_.fixups(); } | 186 const FixupRefList &fixups() const { return buffer_.fixups(); } |
187 | 187 |
188 AssemblerFixup *createFixup(FixupKind Kind, const Constant *Value) { | 188 AssemblerFixup *createFixup(FixupKind Kind, const Constant *Value) { |
189 return buffer_.createFixup(Kind, Value); | 189 return buffer_.createFixup(Kind, Value); |
190 } | 190 } |
191 | 191 |
192 void emitIASBytes(GlobalContext *Ctx) const; | 192 void emitIASBytes(GlobalContext *Ctx) const; |
| 193 bool getInternal() const { return IsInternal; } |
| 194 void setInternal(bool Internal) { IsInternal = Internal; } |
| 195 const IceString &getFunctionName() { return FunctionName; } |
| 196 void setFunctionName(const IceString &NewName) { FunctionName = NewName; } |
193 | 197 |
194 private: | 198 private: |
195 ArenaAllocator<32 * 1024> Allocator; | 199 ArenaAllocator<32 * 1024> Allocator; |
| 200 // FunctionName and IsInternal are transferred from the original Cfg |
| 201 // object, since the Cfg object may be deleted by the time the |
| 202 // assembler buffer is emitted. |
| 203 IceString FunctionName; |
| 204 bool IsInternal; |
196 | 205 |
197 protected: | 206 protected: |
198 AssemblerBuffer buffer_; | 207 AssemblerBuffer buffer_; |
199 }; | 208 }; |
200 | 209 |
201 } // end of namespace Ice | 210 } // end of namespace Ice |
202 | 211 |
203 #endif // SUBZERO_SRC_ASSEMBLER_H_ | 212 #endif // SUBZERO_SRC_ASSEMBLER_H_ |
OLD | NEW |