| Index: src/IceAssembler.h
|
| diff --git a/src/assembler.h b/src/IceAssembler.h
|
| similarity index 68%
|
| rename from src/assembler.h
|
| rename to src/IceAssembler.h
|
| index cf65d948dd1aa2aa72bfa9bb013b88c6645fa24b..131b62a0bb9677faf5751a87f474c0c256ad0550 100644
|
| --- a/src/assembler.h
|
| +++ b/src/IceAssembler.h
|
| @@ -1,4 +1,4 @@
|
| -//===- subzero/src/assembler.h - Integrated assembler -----------*- C++ -*-===//
|
| +//===- subzero/src/IceAssembler.h - Integrated assembler --------*- C++ -*-===//
|
| // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE file.
|
| @@ -20,8 +20,8 @@
|
| //
|
| //===----------------------------------------------------------------------===//
|
|
|
| -#ifndef SUBZERO_SRC_ASSEMBLER_H
|
| -#define SUBZERO_SRC_ASSEMBLER_H
|
| +#ifndef SUBZERO_SRC_ICEASSEMBLER_H
|
| +#define SUBZERO_SRC_ICEASSEMBLER_H
|
|
|
| #include "IceDefs.h"
|
| #include "IceFixups.h"
|
| @@ -38,30 +38,30 @@ public:
|
| ~AssemblerBuffer();
|
|
|
| // Basic support for emitting, loading, and storing.
|
| - template <typename T> void Emit(T value) {
|
| - assert(HasEnsuredCapacity());
|
| - *reinterpret_cast<T *>(cursor_) = value;
|
| - cursor_ += sizeof(T);
|
| + template <typename T> void emit(T Value) {
|
| + assert(hasEnsuredCapacity());
|
| + *reinterpret_cast<T *>(Cursor) = Value;
|
| + Cursor += sizeof(T);
|
| }
|
|
|
| - template <typename T> T Load(intptr_t position) const {
|
| - assert(position >= 0 &&
|
| - position <= (Size() - static_cast<intptr_t>(sizeof(T))));
|
| - return *reinterpret_cast<T *>(contents_ + position);
|
| + template <typename T> T load(intptr_t Position) const {
|
| + assert(Position >= 0 &&
|
| + Position <= (size() - static_cast<intptr_t>(sizeof(T))));
|
| + return *reinterpret_cast<T *>(Contents + Position);
|
| }
|
|
|
| - template <typename T> void Store(intptr_t position, T value) {
|
| - assert(position >= 0 &&
|
| - position <= (Size() - static_cast<intptr_t>(sizeof(T))));
|
| - *reinterpret_cast<T *>(contents_ + position) = value;
|
| + template <typename T> void store(intptr_t Position, T Value) {
|
| + assert(Position >= 0 &&
|
| + Position <= (size() - static_cast<intptr_t>(sizeof(T))));
|
| + *reinterpret_cast<T *>(Contents + Position) = Value;
|
| }
|
|
|
| // Emit a fixup at the current location.
|
| - void EmitFixup(AssemblerFixup *fixup) { fixup->set_position(Size()); }
|
| + void emitFixup(AssemblerFixup *Fixup) { Fixup->set_position(size()); }
|
|
|
| // Get the size of the emitted code.
|
| - intptr_t Size() const { return cursor_ - contents_; }
|
| - uintptr_t contents() const { return contents_; }
|
| + intptr_t size() const { return Cursor - Contents; }
|
| + uintptr_t contents() const { return Contents; }
|
|
|
| // To emit an instruction to the assembler buffer, the EnsureCapacity helper
|
| // must be used to guarantee that the underlying data area is big enough to
|
| @@ -77,47 +77,47 @@ public:
|
| EnsureCapacity &operator=(const EnsureCapacity &) = delete;
|
|
|
| public:
|
| - explicit EnsureCapacity(AssemblerBuffer *buffer);
|
| + explicit EnsureCapacity(AssemblerBuffer *Buffer);
|
| ~EnsureCapacity();
|
|
|
| private:
|
| - AssemblerBuffer *buffer_;
|
| - intptr_t gap_;
|
| + AssemblerBuffer *Buffer;
|
| + intptr_t Gap;
|
|
|
| - intptr_t ComputeGap() { return buffer_->Capacity() - buffer_->Size(); }
|
| + intptr_t computeGap() { return Buffer->capacity() - Buffer->size(); }
|
| };
|
|
|
| - bool has_ensured_capacity_;
|
| - bool HasEnsuredCapacity() const { return has_ensured_capacity_; }
|
| + bool HasEnsuredCapacity;
|
| + bool hasEnsuredCapacity() const { return HasEnsuredCapacity; }
|
| #else // NDEBUG
|
| class EnsureCapacity {
|
| EnsureCapacity(const EnsureCapacity &) = delete;
|
| EnsureCapacity &operator=(const EnsureCapacity &) = delete;
|
|
|
| public:
|
| - explicit EnsureCapacity(AssemblerBuffer *buffer) {
|
| - if (buffer->cursor() >= buffer->limit())
|
| - buffer->ExtendCapacity();
|
| + explicit EnsureCapacity(AssemblerBuffer *Buffer) {
|
| + if (Buffer->cursor() >= buffer->limit())
|
| + buffer->extendCapacity();
|
| }
|
| };
|
|
|
| // When building the C++ tests, assertion code is enabled. To allow
|
| // asserting that the user of the assembler buffer has ensured the
|
| // capacity needed for emitting, we add a dummy method in non-debug mode.
|
| - bool HasEnsuredCapacity() const { return true; }
|
| + bool hasEnsuredCapacity() const { return true; }
|
| #endif // NDEBUG
|
|
|
| // Returns the position in the instruction stream.
|
| - intptr_t GetPosition() const { return cursor_ - contents_; }
|
| + intptr_t getPosition() const { return Cursor - Contents; }
|
|
|
| // Create and track a fixup in the current function.
|
| AssemblerFixup *createFixup(FixupKind Kind, const Constant *Value);
|
|
|
| - const FixupRefList &fixups() const { return fixups_; }
|
| + const FixupRefList &fixups() const { return Fixups; }
|
|
|
| void setSize(intptr_t NewSize) {
|
| - assert(NewSize <= Size());
|
| - cursor_ = contents_ + NewSize;
|
| + assert(NewSize <= size());
|
| + Cursor = Contents + NewSize;
|
| }
|
|
|
| private:
|
| @@ -126,27 +126,28 @@ private:
|
| // for a single, fast space check per instruction.
|
| static const intptr_t kMinimumGap = 32;
|
|
|
| - uintptr_t contents_;
|
| - uintptr_t cursor_;
|
| - uintptr_t limit_;
|
| - Assembler &assembler_;
|
| + uintptr_t Contents;
|
| + uintptr_t Cursor;
|
| + uintptr_t Limit;
|
| + // The member variable is named Assemblr to avoid hiding the class Assembler.
|
| + Assembler &Assemblr;
|
| // List of pool-allocated fixups relative to the current function.
|
| - FixupRefList fixups_;
|
| + FixupRefList Fixups;
|
|
|
| - uintptr_t cursor() const { return cursor_; }
|
| - uintptr_t limit() const { return limit_; }
|
| - intptr_t Capacity() const {
|
| - assert(limit_ >= contents_);
|
| - return (limit_ - contents_) + kMinimumGap;
|
| + uintptr_t cursor() const { return Cursor; }
|
| + uintptr_t limit() const { return Limit; }
|
| + intptr_t capacity() const {
|
| + assert(Limit >= Contents);
|
| + return (Limit - Contents) + kMinimumGap;
|
| }
|
|
|
| // Compute the limit based on the data area and the capacity. See
|
| // description of kMinimumGap for the reasoning behind the value.
|
| - static uintptr_t ComputeLimit(uintptr_t data, intptr_t capacity) {
|
| - return data + capacity - kMinimumGap;
|
| + static uintptr_t computeLimit(uintptr_t Data, intptr_t Capacity) {
|
| + return Data + Capacity - kMinimumGap;
|
| }
|
|
|
| - void ExtendCapacity();
|
| + void extendCapacity();
|
| };
|
|
|
| class Assembler {
|
| @@ -155,12 +156,12 @@ class Assembler {
|
|
|
| public:
|
| Assembler()
|
| - : FunctionName(""), IsInternal(false), Preliminary(false),
|
| - buffer_(*this) {}
|
| - virtual ~Assembler() {}
|
| + : Buffer(*this), FunctionName(""), IsInternal(false),
|
| + Preliminary(false) {}
|
| + virtual ~Assembler() = default;
|
|
|
| // Allocate a chunk of bytes using the per-Assembler allocator.
|
| - uintptr_t AllocateBytes(size_t bytes) {
|
| + uintptr_t allocateBytes(size_t bytes) {
|
| // For now, alignment is not related to NaCl bundle alignment, since
|
| // the buffer's GetPosition is relative to the base. So NaCl bundle
|
| // alignment checks can be relative to that base. Later, the buffer
|
| @@ -172,7 +173,7 @@ public:
|
| }
|
|
|
| // Allocate data of type T using the per-Assembler allocator.
|
| - template <typename T> T *Allocate() { return Allocator.Allocate<T>(); }
|
| + template <typename T> T *allocate() { return Allocator.Allocate<T>(); }
|
|
|
| // Align the tail end of the function to the required target alignment.
|
| virtual void alignFunction() = 0;
|
| @@ -187,17 +188,17 @@ public:
|
|
|
| // Mark the current text location as the start of a CFG node
|
| // (represented by NodeNumber).
|
| - virtual void BindCfgNodeLabel(SizeT NodeNumber) = 0;
|
| + virtual void bindCfgNodeLabel(SizeT NodeNumber) = 0;
|
|
|
| virtual bool fixupIsPCRel(FixupKind Kind) const = 0;
|
|
|
| // Return a view of all the bytes of code for the current function.
|
| llvm::StringRef getBufferView() const;
|
|
|
| - const FixupRefList &fixups() const { return buffer_.fixups(); }
|
| + const FixupRefList &fixups() const { return Buffer.fixups(); }
|
|
|
| AssemblerFixup *createFixup(FixupKind Kind, const Constant *Value) {
|
| - return buffer_.createFixup(Kind, Value);
|
| + return Buffer.createFixup(Kind, Value);
|
| }
|
|
|
| void emitIASBytes(GlobalContext *Ctx) const;
|
| @@ -205,12 +206,15 @@ public:
|
| void setInternal(bool Internal) { IsInternal = Internal; }
|
| const IceString &getFunctionName() { return FunctionName; }
|
| void setFunctionName(const IceString &NewName) { FunctionName = NewName; }
|
| - intptr_t getBufferSize() const { return buffer_.Size(); }
|
| + intptr_t getBufferSize() const { return Buffer.size(); }
|
| // Roll back to a (smaller) size.
|
| - void setBufferSize(intptr_t NewSize) { buffer_.setSize(NewSize); }
|
| + void setBufferSize(intptr_t NewSize) { Buffer.setSize(NewSize); }
|
| void setPreliminary(bool Value) { Preliminary = Value; }
|
| bool getPreliminary() const { return Preliminary; }
|
|
|
| +protected:
|
| + AssemblerBuffer Buffer;
|
| +
|
| private:
|
| ArenaAllocator<32 * 1024> Allocator;
|
| // FunctionName and IsInternal are transferred from the original Cfg
|
| @@ -223,11 +227,8 @@ private:
|
| // final pass where all changes to label bindings, label links, and
|
| // relocation fixups are fully committed (Preliminary=false).
|
| bool Preliminary;
|
| -
|
| -protected:
|
| - AssemblerBuffer buffer_;
|
| };
|
|
|
| } // end of namespace Ice
|
|
|
| -#endif // SUBZERO_SRC_ASSEMBLER_H_
|
| +#endif // SUBZERO_SRC_ICEASSEMBLER_H_
|
|
|