| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 /// hold the emitted instruction. Usage: | 69 /// hold the emitted instruction. Usage: |
| 70 /// | 70 /// |
| 71 /// AssemblerBuffer buffer; | 71 /// AssemblerBuffer buffer; |
| 72 /// AssemblerBuffer::EnsureCapacity ensured(&buffer); | 72 /// AssemblerBuffer::EnsureCapacity ensured(&buffer); |
| 73 /// ... emit bytes for single instruction ... | 73 /// ... emit bytes for single instruction ... |
| 74 class EnsureCapacity { | 74 class EnsureCapacity { |
| 75 EnsureCapacity(const EnsureCapacity &) = delete; | 75 EnsureCapacity(const EnsureCapacity &) = delete; |
| 76 EnsureCapacity &operator=(const EnsureCapacity &) = delete; | 76 EnsureCapacity &operator=(const EnsureCapacity &) = delete; |
| 77 | 77 |
| 78 public: | 78 public: |
| 79 explicit EnsureCapacity(AssemblerBuffer *Buffer) : Buffer(Buffer) { | 79 explicit EnsureCapacity(AssemblerBuffer *MyBuffer) : Buffer(MyBuffer) { |
| 80 if (Buffer->cursor() >= Buffer->limit()) | 80 if (Buffer->cursor() >= Buffer->limit()) |
| 81 Buffer->extendCapacity(); | 81 Buffer->extendCapacity(); |
| 82 if (BuildDefs::asserts()) | 82 if (BuildDefs::asserts()) |
| 83 validate(Buffer); | 83 validate(Buffer); |
| 84 } | 84 } |
| 85 ~EnsureCapacity(); | 85 ~EnsureCapacity(); |
| 86 | 86 |
| 87 private: | 87 private: |
| 88 AssemblerBuffer *Buffer; | 88 AssemblerBuffer *Buffer; |
| 89 intptr_t Gap = 0; | 89 intptr_t Gap = 0; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 /// (represented by NodeNumber). | 188 /// (represented by NodeNumber). |
| 189 virtual void bindCfgNodeLabel(SizeT NodeNumber) = 0; | 189 virtual void bindCfgNodeLabel(SizeT NodeNumber) = 0; |
| 190 | 190 |
| 191 virtual bool fixupIsPCRel(FixupKind Kind) const = 0; | 191 virtual bool fixupIsPCRel(FixupKind Kind) const = 0; |
| 192 | 192 |
| 193 // Return a view of all the bytes of code for the current function. | 193 // Return a view of all the bytes of code for the current function. |
| 194 llvm::StringRef getBufferView() const; | 194 llvm::StringRef getBufferView() const; |
| 195 | 195 |
| 196 const FixupRefList &fixups() const { return Buffer.fixups(); } | 196 const FixupRefList &fixups() const { return Buffer.fixups(); } |
| 197 | 197 |
| 198 AssemblerFixup *createFixup(FixupKind Kind, const Constant *Value) { | 198 AssemblerFixup *createFixup(FixupKind FKind, const Constant *Value) { |
| 199 return Buffer.createFixup(Kind, Value); | 199 return Buffer.createFixup(FKind, Value); |
| 200 } | 200 } |
| 201 | 201 |
| 202 void emitIASBytes(GlobalContext *Ctx) const; | 202 void emitIASBytes(GlobalContext *Ctx) const; |
| 203 bool getInternal() const { return IsInternal; } | 203 bool getInternal() const { return IsInternal; } |
| 204 void setInternal(bool Internal) { IsInternal = Internal; } | 204 void setInternal(bool Internal) { IsInternal = Internal; } |
| 205 const IceString &getFunctionName() { return FunctionName; } | 205 const IceString &getFunctionName() { return FunctionName; } |
| 206 void setFunctionName(const IceString &NewName) { FunctionName = NewName; } | 206 void setFunctionName(const IceString &NewName) { FunctionName = NewName; } |
| 207 intptr_t getBufferSize() const { return Buffer.size(); } | 207 intptr_t getBufferSize() const { return Buffer.size(); } |
| 208 /// Roll back to a (smaller) size. | 208 /// Roll back to a (smaller) size. |
| 209 void setBufferSize(intptr_t NewSize) { Buffer.setSize(NewSize); } | 209 void setBufferSize(intptr_t NewSize) { Buffer.setSize(NewSize); } |
| 210 void setPreliminary(bool Value) { Preliminary = Value; } | 210 void setPreliminary(bool Value) { Preliminary = Value; } |
| 211 bool getPreliminary() const { return Preliminary; } | 211 bool getPreliminary() const { return Preliminary; } |
| 212 | 212 |
| 213 AssemblerKind getKind() const { return Kind; } | 213 AssemblerKind getKind() const { return Kind; } |
| 214 | 214 |
| 215 protected: | 215 protected: |
| 216 explicit Assembler(AssemblerKind Kind) | 216 explicit Assembler(AssemblerKind MyKind) |
| 217 : Kind(Kind), Allocator(), Buffer(*this) {} | 217 : Kind(MyKind), Allocator(), Buffer(*this) {} |
| 218 | 218 |
| 219 private: | 219 private: |
| 220 const AssemblerKind Kind; | 220 const AssemblerKind Kind; |
| 221 | 221 |
| 222 ArenaAllocator<32 * 1024> Allocator; | 222 ArenaAllocator<32 * 1024> Allocator; |
| 223 /// FunctionName and IsInternal are transferred from the original Cfg | 223 /// FunctionName and IsInternal are transferred from the original Cfg |
| 224 /// object, since the Cfg object may be deleted by the time the | 224 /// object, since the Cfg object may be deleted by the time the |
| 225 /// assembler buffer is emitted. | 225 /// assembler buffer is emitted. |
| 226 IceString FunctionName = ""; | 226 IceString FunctionName = ""; |
| 227 bool IsInternal = false; | 227 bool IsInternal = false; |
| 228 /// Preliminary indicates whether a preliminary pass is being made | 228 /// Preliminary indicates whether a preliminary pass is being made |
| 229 /// for calculating bundle padding (Preliminary=true), versus the | 229 /// for calculating bundle padding (Preliminary=true), versus the |
| 230 /// final pass where all changes to label bindings, label links, and | 230 /// final pass where all changes to label bindings, label links, and |
| 231 /// relocation fixups are fully committed (Preliminary=false). | 231 /// relocation fixups are fully committed (Preliminary=false). |
| 232 bool Preliminary = false; | 232 bool Preliminary = false; |
| 233 | 233 |
| 234 protected: | 234 protected: |
| 235 // Buffer's constructor uses the Allocator, so it needs to appear after it. | 235 // Buffer's constructor uses the Allocator, so it needs to appear after it. |
| 236 // TODO(jpp): dependencies on construction order are a nice way of shooting | 236 // TODO(jpp): dependencies on construction order are a nice way of shooting |
| 237 // yourself in the foot. Fix this. | 237 // yourself in the foot. Fix this. |
| 238 AssemblerBuffer Buffer; | 238 AssemblerBuffer Buffer; |
| 239 }; | 239 }; |
| 240 | 240 |
| 241 } // end of namespace Ice | 241 } // end of namespace Ice |
| 242 | 242 |
| 243 #endif // SUBZERO_SRC_ICEASSEMBLER_H_ | 243 #endif // SUBZERO_SRC_ICEASSEMBLER_H_ |
| OLD | NEW |