| 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 // Disable the actual check in non-debug mode. | 167 // Disable the actual check in non-debug mode. |
| 168 return true; | 168 return true; |
| 169 } | 169 } |
| 170 | 170 |
| 171 /// Returns the position in the instruction stream. | 171 /// Returns the position in the instruction stream. |
| 172 intptr_t getPosition() const { return Cursor - Contents; } | 172 intptr_t getPosition() const { return Cursor - Contents; } |
| 173 | 173 |
| 174 /// Create and track a fixup in the current function. | 174 /// Create and track a fixup in the current function. |
| 175 AssemblerFixup *createFixup(FixupKind Kind, const Constant *Value); | 175 AssemblerFixup *createFixup(FixupKind Kind, const Constant *Value); |
| 176 | 176 |
| 177 /// Installs a created fixup, after it has been allocated. |
| 178 void installFixup(AssemblerFixup *F); |
| 179 |
| 177 const FixupRefList &fixups() const { return Fixups; } | 180 const FixupRefList &fixups() const { return Fixups; } |
| 178 | 181 |
| 179 void setSize(intptr_t NewSize) { | 182 void setSize(intptr_t NewSize) { |
| 180 assert(NewSize <= size()); | 183 assert(NewSize <= size()); |
| 181 Cursor = Contents + NewSize; | 184 Cursor = Contents + NewSize; |
| 182 } | 185 } |
| 183 | 186 |
| 184 private: | 187 private: |
| 185 /// The limit is set to kMinimumGap bytes before the end of the data area. | 188 /// The limit is set to kMinimumGap bytes before the end of the data area. |
| 186 /// This leaves enough space for the longest possible instruction and allows | 189 /// This leaves enough space for the longest possible instruction and allows |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 virtual Label *getCfgNodeLabel(SizeT NodeNumber) = 0; | 264 virtual Label *getCfgNodeLabel(SizeT NodeNumber) = 0; |
| 262 /// Mark the current text location as the start of a CFG node (represented by | 265 /// Mark the current text location as the start of a CFG node (represented by |
| 263 /// NodeNumber). | 266 /// NodeNumber). |
| 264 virtual void bindCfgNodeLabel(SizeT NodeNumber) = 0; | 267 virtual void bindCfgNodeLabel(SizeT NodeNumber) = 0; |
| 265 | 268 |
| 266 virtual bool fixupIsPCRel(FixupKind Kind) const = 0; | 269 virtual bool fixupIsPCRel(FixupKind Kind) const = 0; |
| 267 | 270 |
| 268 // Return a view of all the bytes of code for the current function. | 271 // Return a view of all the bytes of code for the current function. |
| 269 llvm::StringRef getBufferView() const; | 272 llvm::StringRef getBufferView() const; |
| 270 | 273 |
| 274 /// Emit a fixup at the current location. |
| 275 void emitFixup(AssemblerFixup *Fixup) { Buffer.emitFixup(Fixup); } |
| 276 |
| 271 const FixupRefList &fixups() const { return Buffer.fixups(); } | 277 const FixupRefList &fixups() const { return Buffer.fixups(); } |
| 272 | 278 |
| 273 AssemblerFixup *createFixup(FixupKind Kind, const Constant *Value) { | 279 AssemblerFixup *createFixup(FixupKind Kind, const Constant *Value) { |
| 274 return Buffer.createFixup(Kind, Value); | 280 return Buffer.createFixup(Kind, Value); |
| 275 } | 281 } |
| 276 | 282 |
| 277 void emitIASBytes() const; | 283 void emitIASBytes() const; |
| 278 bool getInternal() const { return IsInternal; } | 284 bool getInternal() const { return IsInternal; } |
| 279 void setInternal(bool Internal) { IsInternal = Internal; } | 285 void setInternal(bool Internal) { IsInternal = Internal; } |
| 280 const IceString &getFunctionName() { return FunctionName; } | 286 const IceString &getFunctionName() { return FunctionName; } |
| 281 void setFunctionName(const IceString &NewName) { FunctionName = NewName; } | 287 void setFunctionName(const IceString &NewName) { FunctionName = NewName; } |
| 282 intptr_t getBufferSize() const { return Buffer.size(); } | 288 intptr_t getBufferSize() const { return Buffer.size(); } |
| 283 /// Roll back to a (smaller) size. | 289 /// Roll back to a (smaller) size. |
| 284 void setBufferSize(intptr_t NewSize) { Buffer.setSize(NewSize); } | 290 void setBufferSize(intptr_t NewSize) { Buffer.setSize(NewSize); } |
| 285 void setPreliminary(bool Value) { Preliminary = Value; } | 291 void setPreliminary(bool Value) { Preliminary = Value; } |
| 286 bool getPreliminary() const { return Preliminary; } | 292 bool getPreliminary() const { return Preliminary; } |
| 287 | 293 |
| 288 AssemblerKind getKind() const { return Kind; } | 294 AssemblerKind getKind() const { return Kind; } |
| 289 | 295 |
| 290 protected: | 296 protected: |
| 291 explicit Assembler(AssemblerKind Kind, GlobalContext *Ctx) | 297 explicit Assembler(AssemblerKind Kind, GlobalContext *Ctx) |
| 292 : Kind(Kind), Allocator(), Ctx(Ctx), Buffer(*this) {} | 298 : Kind(Kind), Allocator(), Ctx(Ctx), Buffer(*this) {} |
| 293 | 299 |
| 300 /// Installs a created fixup, after it has been allocated. |
| 301 void installFixup(AssemblerFixup *F) { Buffer.installFixup(F); } |
| 302 |
| 294 private: | 303 private: |
| 295 const AssemblerKind Kind; | 304 const AssemblerKind Kind; |
| 296 | 305 |
| 297 ArenaAllocator<32 * 1024> Allocator; | 306 ArenaAllocator<32 * 1024> Allocator; |
| 298 /// FunctionName and IsInternal are transferred from the original Cfg object, | 307 /// FunctionName and IsInternal are transferred from the original Cfg object, |
| 299 /// since the Cfg object may be deleted by the time the assembler buffer is | 308 /// since the Cfg object may be deleted by the time the assembler buffer is |
| 300 /// emitted. | 309 /// emitted. |
| 301 IceString FunctionName = ""; | 310 IceString FunctionName = ""; |
| 302 bool IsInternal = false; | 311 bool IsInternal = false; |
| 303 /// Preliminary indicates whether a preliminary pass is being made for | 312 /// Preliminary indicates whether a preliminary pass is being made for |
| 304 /// calculating bundle padding (Preliminary=true), versus the final pass where | 313 /// calculating bundle padding (Preliminary=true), versus the final pass where |
| 305 /// all changes to label bindings, label links, and relocation fixups are | 314 /// all changes to label bindings, label links, and relocation fixups are |
| 306 /// fully committed (Preliminary=false). | 315 /// fully committed (Preliminary=false). |
| 307 bool Preliminary = false; | 316 bool Preliminary = false; |
| 308 | 317 |
| 309 protected: | 318 protected: |
| 310 GlobalContext *Ctx; | 319 GlobalContext *Ctx; |
| 311 // Buffer's constructor uses the Allocator, so it needs to appear after it. | 320 // Buffer's constructor uses the Allocator, so it needs to appear after it. |
| 312 // TODO(jpp): dependencies on construction order are a nice way of shooting | 321 // TODO(jpp): dependencies on construction order are a nice way of shooting |
| 313 // yourself in the foot. Fix this. | 322 // yourself in the foot. Fix this. |
| 314 AssemblerBuffer Buffer; | 323 AssemblerBuffer Buffer; |
| 315 }; | 324 }; |
| 316 | 325 |
| 317 } // end of namespace Ice | 326 } // end of namespace Ice |
| 318 | 327 |
| 319 #endif // SUBZERO_SRC_ICEASSEMBLER_H_ | 328 #endif // SUBZERO_SRC_ICEASSEMBLER_H_ |
| OLD | NEW |