Remove refs to non-DebugLoc version of BuildMI from XCore, PIC16.
[oota-llvm.git] / lib / Target / PowerPC / PPCJITInfo.cpp
index db36881ae5391d8a81012534623da3164ab56e6b..b5de31868d74b86b5a13f5aef4af8d75a97de7ba 100644 (file)
@@ -17,9 +17,8 @@
 #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;
@@ -330,39 +329,13 @@ defined(__APPLE__)
 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)
-  
-#ifdef __APPLE__
-  sys_icache_invalidate(Addr, len);
-#elif defined(__GNUC__)
-  const size_t LineSize = 32;
-  
-  const intptr_t Mask = ~(LineSize - 1);
-  const intptr_t StartLine = ((intptr_t) Addr) & Mask;
-  const intptr_t EndLine = ((intptr_t) Addr + len + LineSize - 1) & Mask;
-
-  for (intptr_t Line = StartLine; Line < EndLine; Line += LineSize)
-      asm volatile("dcbf 0, %0" : : "r"(Line));
-  asm volatile("sync");
-
-  for (intptr_t Line = StartLine; Line < EndLine; Line += LineSize)
-      asm volatile("icbi 0, %0" : : "r"(Line));
-  asm volatile("isync");
-#endif
-  
-#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);
@@ -372,11 +345,11 @@ void *PPCJITInfo::emitFunctionStub(const Function* F, void *Fn,
     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)
@@ -400,8 +373,8 @@ void *PPCJITInfo::emitFunctionStub(const Function* F, void *Fn,
   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);
 }