#include "PPCTargetMachine.h"
#include "llvm/Function.h"
#include "llvm/CodeGen/MachineCodeEmitter.h"
-#include "llvm/Config/alloca.h"
+#include "llvm/System/Memory.h"
#include "llvm/Support/Debug.h"
-#include <set>
using namespace llvm;
static TargetJITInfo::JITCompilerFn JITCompilerFunction;
extern "C" void PPC64CompilationCallback();
#if (defined(__POWERPC__) || defined (__ppc__) || defined(_POWER)) && \
- !defined(__ppc64__)
+ !(defined(__ppc64__) || defined(__FreeBSD__))
// 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
);
#elif defined(__PPC__) && !defined(__ppc64__)
-// Linux/PPC support
+// Linux & FreeBSD / PPC 32 support
// 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,
extern "C" void sys_icache_invalidate(const void *Addr, size_t len);
#endif
-/// SyncICache - On PPC, the JIT emitted code must be explicitly refetched to
-/// ensure correct execution.
-static void SyncICache(const void *Addr, size_t len) {
-#if (defined(__POWERPC__) || defined (__ppc__) || defined(_POWER)) && \
-defined(__APPLE__)
- sys_icache_invalidate(Addr, len);
-#endif
-}
-
void *PPCJITInfo::emitFunctionStub(const Function* F, void *Fn,
MachineCodeEmitter &MCE) {
// If this is just a call to an external function, emit a branch instead of a
// call. The code is the same except for one bit of the last instruction.
if (Fn != (void*)(intptr_t)PPC32CompilationCallback &&
Fn != (void*)(intptr_t)PPC64CompilationCallback) {
- MCE.startFunctionStub(F, 7*4);
+ MCE.startGVStub(F, 7*4);
intptr_t Addr = (intptr_t)MCE.getCurrentPCValue();
MCE.emitWordBE(0);
MCE.emitWordBE(0);
MCE.emitWordBE(0);
MCE.emitWordBE(0);
EmitBranchToAt(Addr, (intptr_t)Fn, false, is64Bit);
- SyncICache((void*)Addr, 7*4);
- return MCE.finishFunctionStub(F);
+ sys::Memory::InvalidateInstructionCache((void*)Addr, 7*4);
+ return MCE.finishGVStub(F);
}
- MCE.startFunctionStub(F, 10*4);
+ MCE.startGVStub(F, 10*4);
intptr_t Addr = (intptr_t)MCE.getCurrentPCValue();
if (is64Bit) {
MCE.emitWordBE(0xf821ffb1); // stdu r1,-80(r1)
MCE.emitWordBE(0);
MCE.emitWordBE(0);
EmitBranchToAt(BranchAddr, (intptr_t)Fn, true, is64Bit);
- SyncICache((void*)Addr, 10*4);
- return MCE.finishFunctionStub(F);
+ sys::Memory::InvalidateInstructionCache((void*)Addr, 10*4);
+ return MCE.finishGVStub(F);
}