summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2006-11-16 20:04:54 +0000
committerEvan Cheng <evan.cheng@apple.com>2006-11-16 20:04:54 +0000
commite03ca9b0b4adc99efdfd80d44dcb76b815340615 (patch)
tree46fc9228563af25ab283899cc3cba8387a7c437b
parent9fd73b8a7f13462d3ca4151344ba4f4751ef9deb (diff)
downloadbcm5719-llvm-e03ca9b0b4adc99efdfd80d44dcb76b815340615.tar.gz
bcm5719-llvm-e03ca9b0b4adc99efdfd80d44dcb76b815340615.zip
Allow target to specify alignment for function stub.
llvm-svn: 31788
-rw-r--r--llvm/include/llvm/CodeGen/MachineCodeEmitter.h2
-rw-r--r--llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp16
2 files changed, 12 insertions, 6 deletions
diff --git a/llvm/include/llvm/CodeGen/MachineCodeEmitter.h b/llvm/include/llvm/CodeGen/MachineCodeEmitter.h
index 758a1673098..018c5e5a3a6 100644
--- a/llvm/include/llvm/CodeGen/MachineCodeEmitter.h
+++ b/llvm/include/llvm/CodeGen/MachineCodeEmitter.h
@@ -80,7 +80,7 @@ public:
/// have constant pools, the can only use the other emitByte*/emitWord*
/// 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
/// stub.
diff --git a/llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp b/llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp
index 1c2d5d3185a..e9b630b1b73 100644
--- a/llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp
+++ b/llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp
@@ -275,7 +275,7 @@ namespace {
JITMemoryManager(bool useGOT);
~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
/// executable memory, returning a pointer to it and its actual size.
@@ -403,8 +403,11 @@ JITMemoryManager::~JITMemoryManager() {
Blocks.clear();
}
-unsigned char *JITMemoryManager::allocateStub(unsigned StubSize) {
+unsigned char *JITMemoryManager::allocateStub(unsigned StubSize,
+ unsigned Alignment) {
CurStubPtr -= StubSize;
+ CurStubPtr = (unsigned char*)(((intptr_t)CurStubPtr) &
+ ~(intptr_t)(Alignment-1));
if (CurStubPtr < StubBase) {
// FIXME: allocate a new block
std::cerr << "JIT ran out of memory for function stubs!\n";
@@ -700,7 +703,7 @@ public:
void initJumpTableInfo(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 addRelocation(const MachineRelocation &MR) {
@@ -769,6 +772,9 @@ void JITEmitter::startFunction(MachineFunction &F) {
BufferBegin = CurBufferPtr = MemMgr.startFunctionBody(ActualSize);
BufferEnd = BufferBegin+ActualSize;
+ // Ensure the constant pool/jump table info is at least 4-byte aligned.
+ emitAlignment(16);
+
emitConstantPool(F.getConstantPool());
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;
SavedBufferEnd = BufferEnd;
SavedCurBufferPtr = CurBufferPtr;
- BufferBegin = CurBufferPtr = MemMgr.allocateStub(StubSize);
+ BufferBegin = CurBufferPtr = MemMgr.allocateStub(StubSize, Alignment);
BufferEnd = BufferBegin+StubSize+1;
}
OpenPOWER on IntegriCloud