summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2008-09-02 07:49:03 +0000
committerEvan Cheng <evan.cheng@apple.com>2008-09-02 07:49:03 +0000
commit95ce1178e40d232cbf8d134030c3dcc8474c704d (patch)
tree7312f0a9200d8804496aeac872e5deeab1abee17
parent7602e11c3298ca740deb04a246c70560f1743dbd (diff)
downloadllvm-95ce1178e40d232cbf8d134030c3dcc8474c704d.tar.gz
llvm-95ce1178e40d232cbf8d134030c3dcc8474c704d.tar.bz2
llvm-95ce1178e40d232cbf8d134030c3dcc8474c704d.tar.xz
Add Mac OS X compatible JIT callback routine.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55625 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/ARM/ARMJITInfo.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/lib/Target/ARM/ARMJITInfo.cpp b/lib/Target/ARM/ARMJITInfo.cpp
index bc2bba36c8..1c23054c82 100644
--- a/lib/Target/ARM/ARMJITInfo.cpp
+++ b/lib/Target/ARM/ARMJITInfo.cpp
@@ -29,6 +29,14 @@ void ARMJITInfo::replaceMachineCodeForFunction(void *Old, void *New) {
/// compile a function lazily.
static TargetJITInfo::JITCompilerFn JITCompilerFunction;
+// Get the ASMPREFIX for the current host. This is often '_'.
+#ifndef __USER_LABEL_PREFIX__
+#define __USER_LABEL_PREFIX__
+#endif
+#define GETASMPREFIX2(X) #X
+#define GETASMPREFIX(X) GETASMPREFIX2(X)
+#define ASMPREFIX GETASMPREFIX(__USER_LABEL_PREFIX__)
+
// CompilationCallback stub - We can't use a C function with inline assembly in
// it, because we the prolog/epilog inserted by GCC won't work for us. Instead,
// write our own wrapper, which does things our way, so we have complete control
@@ -39,21 +47,37 @@ extern "C" {
asm(
".text\n"
".align 2\n"
- ".globl ARMCompilationCallback\n"
- "ARMCompilationCallback:\n"
+ ".globl " ASMPREFIX "ARMCompilationCallback\n"
+ ASMPREFIX "ARMCompilationCallback:\n"
// save main registers
+#if defined(__APPLE__)
+ "stmfd sp!, {r4, r5, r6, r7, lr}\n"
+ "mov r0, r7\n" // stub's frame
+ "stmfd sp!, {r8, r10, r11}\n"
+#else
"mov ip, sp\n"
"stmfd sp!, {fp, ip, lr, pc}\n"
"sub fp, ip, #4\n"
+#endif // __APPLE__
// arguments to Compilation Callback
// r0 - our lr (address of the call instruction in stub plus 4)
// r1 - stub's lr (address of instruction that called the stub plus 4)
+#if defined(__APPLE__)
+ "mov r0, r7\n" // stub's frame
+#else
"mov r0, fp\n" // stub's frame
+#endif // __APPLE__
"mov r1, lr\n" // stub's lr
- "bl ARMCompilationCallbackC\n"
+ "bl " ASMPREFIX "ARMCompilationCallbackC\n"
// restore main registers
- "ldmfd sp, {fp, sp, pc}\n");
-#else // Not an ARM host
+#if defined(__APPLE__)
+ "ldmfd sp!, {r8, r10, r11}\n"
+ "ldmfd sp!, {r4, r5, r6, r7, pc}\n"
+#else
+ "ldmfd sp, {fp, sp, pc}\n"
+#endif // __APPLE__
+ );
+#else // Not an ARM host
void ARMCompilationCallback() {
assert(0 && "Cannot call ARMCompilationCallback() on a non-ARM arch!\n");
abort();