aboutsummaryrefslogtreecommitdiff
path: root/include/llvm/CodeGen/MachineCodeEmitter.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-05-03 01:01:51 +0000
committerChris Lattner <sabre@nondot.org>2006-05-03 01:01:51 +0000
commit3db9e30c09404d5562001ff88c8a222edd9a5efe (patch)
treedda8896692bce06f85a8d19f85ee46a0c2114825 /include/llvm/CodeGen/MachineCodeEmitter.h
parente6fdcbfc47e32c0f8a2ed9df350ac0c871c575f7 (diff)
Add a new emitAlignment method
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28072 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen/MachineCodeEmitter.h')
-rw-r--r--include/llvm/CodeGen/MachineCodeEmitter.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/include/llvm/CodeGen/MachineCodeEmitter.h b/include/llvm/CodeGen/MachineCodeEmitter.h
index f05375fc5f..43b14ca38f 100644
--- a/include/llvm/CodeGen/MachineCodeEmitter.h
+++ b/include/llvm/CodeGen/MachineCodeEmitter.h
@@ -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.