diff options
author | Chris Lattner <sabre@nondot.org> | 2005-05-19 06:49:17 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-05-19 06:49:17 +0000 |
commit | 1030f72f8aea31fad9ebc22c471d2708c36d5bf6 (patch) | |
tree | 665ff86c3a41c60a02613c2c8c231db19c8976bb /lib/Target/X86/X86JITInfo.cpp | |
parent | 16cb6f82eb78a2140fe1cf1e432288fc98cb4ee7 (diff) | |
download | external_llvm-1030f72f8aea31fad9ebc22c471d2708c36d5bf6.zip external_llvm-1030f72f8aea31fad9ebc22c471d2708c36d5bf6.tar.gz external_llvm-1030f72f8aea31fad9ebc22c471d2708c36d5bf6.tar.bz2 |
Fastcc passes arguments in EAX and EDX, make sure the JIT doesn't clobber them
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22137 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/X86JITInfo.cpp')
-rw-r--r-- | lib/Target/X86/X86JITInfo.cpp | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/lib/Target/X86/X86JITInfo.cpp b/lib/Target/X86/X86JITInfo.cpp index ec8b63a..77200d0 100644 --- a/lib/Target/X86/X86JITInfo.cpp +++ b/lib/Target/X86/X86JITInfo.cpp @@ -36,19 +36,52 @@ void X86JITInfo::replaceMachineCodeForFunction(void *Old, void *New) { /// compile a function lazily. static TargetJITInfo::JITCompilerFn JITCompilerFunction; -/// CompilationCallback - This is the target-specific function invoked by the +// Provide a wrapper for X86CompilationCallback2 that saves non-traditional +// callee saved registers, for the fastcc calling convention. +extern "C" void X86CompilationCallback(void); + +#if defined(__i386__) || defined(i386) +#ifndef _MSC_VER +asm( + ".text\n" + ".align 8\n" + ".globl X86CompilationCallback\n" +"X86CompilationCallback:\n" + "pushl %ebp\n" + "movl %esp, %ebp\n" // Standard prologue + "pushl %eax\n" + "pushl %edx\n" // save EAX/EDX + "call X86CompilationCallback2\n" + "popl %edx\n" + "popl %eax\n" + "popl %ebp\n" + "ret\n"); +#else +// FIXME: implement this for VC++ +#endif + +#else +// Not an i386 host +void X86CompilationCallback() { + assert(0 && "This is not a X86, you can't execute this!"); + abort(); +} +#endif + +/// X86CompilationCallback - This is the target-specific function invoked by the /// function stub when we did not know the real target of a call. This function /// must locate the start of the stub or call site and pass it into the JIT /// compiler function. -static void CompilationCallback() { +extern "C" void X86CompilationCallback2() { #ifdef _MSC_VER + // FIXME: This needs to go up one more level! unsigned *StackPtr, RetAddr; __asm mov StackPtr, ebp; __asm mov eax, DWORD PTR [ebp + 4]; __asm mov RetAddr, eax; #else - unsigned *StackPtr = (unsigned*)__builtin_frame_address(0); - unsigned RetAddr = (unsigned)(intptr_t)__builtin_return_address(0); + unsigned *StackPtr = (unsigned*)__builtin_frame_address(1); + unsigned RetAddr = (unsigned)(intptr_t)__builtin_return_address(1); // NOTE: __builtin_frame_address doesn't work if frame pointer elimination has // been performed. Having a variable sized alloca disables frame pointer @@ -100,11 +133,11 @@ static void CompilationCallback() { TargetJITInfo::LazyResolverFn X86JITInfo::getLazyResolverFunction(JITCompilerFn F) { JITCompilerFunction = F; - return CompilationCallback; + return X86CompilationCallback; } void *X86JITInfo::emitFunctionStub(void *Fn, MachineCodeEmitter &MCE) { - if (Fn != CompilationCallback) { + if (Fn != X86CompilationCallback) { MCE.startFunctionStub(5); MCE.emitByte(0xE9); MCE.emitWord((intptr_t)Fn-MCE.getCurrentPCValue()-4); |