diff options
| author | Chris Lattner <sabre@nondot.org> | 2006-05-02 22:51:03 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2006-05-02 22:51:03 +0000 |
| commit | ee1a61810c6cb4c9253cb7d1d53168dc5ac1dd98 (patch) | |
| tree | 9281904cb2c60151ead3f963eb4878048321837b /llvm | |
| parent | 233391f5f5e4af46cc2b0b17c24d6ddf51e70674 (diff) | |
| download | bcm5719-llvm-ee1a61810c6cb4c9253cb7d1d53168dc5ac1dd98.tar.gz bcm5719-llvm-ee1a61810c6cb4c9253cb7d1d53168dc5ac1dd98.zip | |
Add a method for allocating space from the code buffer.
llvm-svn: 28064
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/include/llvm/CodeGen/MachineCodeEmitter.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/llvm/include/llvm/CodeGen/MachineCodeEmitter.h b/llvm/include/llvm/CodeGen/MachineCodeEmitter.h index 58e232d341a..d26d7e773f4 100644 --- a/llvm/include/llvm/CodeGen/MachineCodeEmitter.h +++ b/llvm/include/llvm/CodeGen/MachineCodeEmitter.h @@ -140,6 +140,28 @@ 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) { + 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)); + void *Result = CurBufferPtr; + + // Allocate the space. + CurBufferPtr += Size; + + // Check for buffer overflow. + if (CurBufferPtr >= BufferEnd) { + CurBufferPtr = BufferEnd; + Result = 0; + } + return Result; + } + + /// getCurrentPCValue - This returns the address that the next emitted byte /// will be output to. /// |

