mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-10-20 09:24:58 +00:00
Allow target to specify alignment for function stub.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31788 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ce9a576f29
commit
9a1e9b9140
@ -80,7 +80,7 @@ public:
|
|||||||
/// have constant pools, the can only use the other emitByte*/emitWord*
|
/// have constant pools, the can only use the other emitByte*/emitWord*
|
||||||
/// methods.
|
/// methods.
|
||||||
///
|
///
|
||||||
virtual void startFunctionStub(unsigned StubSize) = 0;
|
virtual void startFunctionStub(unsigned StubSize, unsigned Alignment = 1) = 0;
|
||||||
|
|
||||||
/// finishFunctionStub - This callback is invoked to terminate a function
|
/// finishFunctionStub - This callback is invoked to terminate a function
|
||||||
/// stub.
|
/// stub.
|
||||||
|
@ -275,7 +275,7 @@ namespace {
|
|||||||
JITMemoryManager(bool useGOT);
|
JITMemoryManager(bool useGOT);
|
||||||
~JITMemoryManager();
|
~JITMemoryManager();
|
||||||
|
|
||||||
inline unsigned char *allocateStub(unsigned StubSize);
|
inline unsigned char *allocateStub(unsigned StubSize, unsigned Alignment);
|
||||||
|
|
||||||
/// startFunctionBody - When a function starts, allocate a block of free
|
/// startFunctionBody - When a function starts, allocate a block of free
|
||||||
/// executable memory, returning a pointer to it and its actual size.
|
/// executable memory, returning a pointer to it and its actual size.
|
||||||
@ -403,8 +403,11 @@ JITMemoryManager::~JITMemoryManager() {
|
|||||||
Blocks.clear();
|
Blocks.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char *JITMemoryManager::allocateStub(unsigned StubSize) {
|
unsigned char *JITMemoryManager::allocateStub(unsigned StubSize,
|
||||||
|
unsigned Alignment) {
|
||||||
CurStubPtr -= StubSize;
|
CurStubPtr -= StubSize;
|
||||||
|
CurStubPtr = (unsigned char*)(((intptr_t)CurStubPtr) &
|
||||||
|
~(intptr_t)(Alignment-1));
|
||||||
if (CurStubPtr < StubBase) {
|
if (CurStubPtr < StubBase) {
|
||||||
// FIXME: allocate a new block
|
// FIXME: allocate a new block
|
||||||
std::cerr << "JIT ran out of memory for function stubs!\n";
|
std::cerr << "JIT ran out of memory for function stubs!\n";
|
||||||
@ -700,7 +703,7 @@ public:
|
|||||||
void initJumpTableInfo(MachineJumpTableInfo *MJTI);
|
void initJumpTableInfo(MachineJumpTableInfo *MJTI);
|
||||||
void emitJumpTableInfo(MachineJumpTableInfo *MJTI);
|
void emitJumpTableInfo(MachineJumpTableInfo *MJTI);
|
||||||
|
|
||||||
virtual void startFunctionStub(unsigned StubSize);
|
virtual void startFunctionStub(unsigned StubSize, unsigned Alignment = 1);
|
||||||
virtual void* finishFunctionStub(const Function *F);
|
virtual void* finishFunctionStub(const Function *F);
|
||||||
|
|
||||||
virtual void addRelocation(const MachineRelocation &MR) {
|
virtual void addRelocation(const MachineRelocation &MR) {
|
||||||
@ -769,6 +772,9 @@ void JITEmitter::startFunction(MachineFunction &F) {
|
|||||||
BufferBegin = CurBufferPtr = MemMgr.startFunctionBody(ActualSize);
|
BufferBegin = CurBufferPtr = MemMgr.startFunctionBody(ActualSize);
|
||||||
BufferEnd = BufferBegin+ActualSize;
|
BufferEnd = BufferBegin+ActualSize;
|
||||||
|
|
||||||
|
// Ensure the constant pool/jump table info is at least 4-byte aligned.
|
||||||
|
emitAlignment(16);
|
||||||
|
|
||||||
emitConstantPool(F.getConstantPool());
|
emitConstantPool(F.getConstantPool());
|
||||||
initJumpTableInfo(F.getJumpTableInfo());
|
initJumpTableInfo(F.getJumpTableInfo());
|
||||||
|
|
||||||
@ -928,12 +934,12 @@ void JITEmitter::emitJumpTableInfo(MachineJumpTableInfo *MJTI) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void JITEmitter::startFunctionStub(unsigned StubSize) {
|
void JITEmitter::startFunctionStub(unsigned StubSize, unsigned Alignment) {
|
||||||
SavedBufferBegin = BufferBegin;
|
SavedBufferBegin = BufferBegin;
|
||||||
SavedBufferEnd = BufferEnd;
|
SavedBufferEnd = BufferEnd;
|
||||||
SavedCurBufferPtr = CurBufferPtr;
|
SavedCurBufferPtr = CurBufferPtr;
|
||||||
|
|
||||||
BufferBegin = CurBufferPtr = MemMgr.allocateStub(StubSize);
|
BufferBegin = CurBufferPtr = MemMgr.allocateStub(StubSize, Alignment);
|
||||||
BufferEnd = BufferBegin+StubSize+1;
|
BufferEnd = BufferBegin+StubSize+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user