Index: src/assembler.h |
diff --git a/src/assembler.h b/src/assembler.h |
index dfd8cd123bfdc09418d095c80666b1be53c322f8..84955e547843facf8b07a042dc4f3289cdadd644 100644 |
--- a/src/assembler.h |
+++ b/src/assembler.h |
@@ -115,6 +115,11 @@ public: |
const FixupRefList &fixups() const { return fixups_; } |
+ void setSize(intptr_t NewSize) { |
+ assert(NewSize <= Size()); |
+ cursor_ = contents_ + NewSize; |
+ } |
+ |
private: |
// The limit is set to kMinimumGap bytes before the end of the data area. |
// This leaves enough space for the longest possible instruction and allows |
@@ -149,7 +154,9 @@ class Assembler { |
Assembler &operator=(const Assembler &) = delete; |
public: |
- Assembler() : FunctionName(""), IsInternal(false), buffer_(*this) {} |
+ Assembler() |
+ : FunctionName(""), IsInternal(false), Preliminary(false), |
+ buffer_(*this) {} |
virtual ~Assembler() {} |
// Allocate a chunk of bytes using the per-Assembler allocator. |
@@ -170,6 +177,9 @@ public: |
// Align the tail end of the function to the required target alignment. |
virtual void alignFunction() = 0; |
+ // Add nop padding of a particular width to the current bundle. |
+ virtual void padWithNop(intptr_t Padding) = 0; |
+ |
virtual SizeT getBundleAlignLog2Bytes() const = 0; |
virtual llvm::ArrayRef<uint8_t> getNonExecBundlePadding() const = 0; |
@@ -194,6 +204,11 @@ 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(); } |
+ // Roll back to a (smaller) size. |
+ void setBufferSize(intptr_t NewSize) { buffer_.setSize(NewSize); } |
+ void setPreliminary(bool Value) { Preliminary = Value; } |
+ bool getPreliminary() const { return Preliminary; } |
private: |
ArenaAllocator<32 * 1024> Allocator; |
@@ -202,6 +217,11 @@ private: |
// assembler buffer is emitted. |
IceString FunctionName; |
bool IsInternal; |
+ // Preliminary indicates whether a preliminary pass is being made |
+ // for calculating bundle padding (Preliminary=true), versus the |
+ // final pass where all changes to label bindings, label links, and |
+ // relocation fixups are fully committed (Preliminary=false). |
+ bool Preliminary; |
protected: |
AssemblerBuffer buffer_; |