Add a new emitAlignment method

llvm-svn: 28072
This commit is contained in:
Chris Lattner 2006-05-03 01:01:51 +00:00
parent 77fe5b4459
commit 7150a7038a
1 changed files with 12 additions and 4 deletions

View File

@ -130,14 +130,22 @@ public:
}
}
/// 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.