Skip to content

Commit

Permalink
Add a new emitAlignment method
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28072 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
lattner committed May 3, 2006
1 parent e6fdcbf commit 3db9e30
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions include/llvm/CodeGen/MachineCodeEmitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,22 @@ class MachineCodeEmitter {
}
}

/// allocateSpace - Allocate a block of space in the current output buffer,
/// returning null (and setting conditions to indicate buffer overflow) on
/// failure. Alignment is the alignment in bytes of the buffer desired.
void *allocateSpace(intptr_t Size, unsigned Alignment) {
/// emitAlignment - Move the CurBufferPtr pointer up the the specified
/// alignment (saturated to BufferEnd of course).
void emitAlignment(unsigned Alignment) {
if (Alignment == 0) Alignment = 1;
// Move the current buffer ptr up to the specified alignment.
CurBufferPtr =
(unsigned char*)(((intptr_t)CurBufferPtr+Alignment-1) & ~(Alignment-1));
if (CurBufferPtr > BufferEnd)
CurBufferPtr = BufferEnd;
}

/// allocateSpace - Allocate a block of space in the current output buffer,
/// returning null (and setting conditions to indicate buffer overflow) on
/// failure. Alignment is the alignment in bytes of the buffer desired.
void *allocateSpace(intptr_t Size, unsigned Alignment) {
emitAlignment(Alignment);
void *Result = CurBufferPtr;

// Allocate the space.
Expand Down

0 comments on commit 3db9e30

Please sign in to comment.