Changes in directory llvm/include/llvm/CodeGen:
MachineCodeEmitter.h updated: 1.35 -> 1.36 --- Log message: Add a method for allocating space from the code buffer. --- Diffs of the changes: (+22 -0) MachineCodeEmitter.h | 22 ++++++++++++++++++++++ 1 files changed, 22 insertions(+) Index: llvm/include/llvm/CodeGen/MachineCodeEmitter.h diff -u llvm/include/llvm/CodeGen/MachineCodeEmitter.h:1.35 llvm/include/llvm/CodeGen/MachineCodeEmitter.h:1.36 --- llvm/include/llvm/CodeGen/MachineCodeEmitter.h:1.35 Tue May 2 16:57:51 2006 +++ llvm/include/llvm/CodeGen/MachineCodeEmitter.h Tue May 2 17:51:03 2006 @@ -140,6 +140,28 @@ } } + /// 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. /// _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits