aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/PowerPC/PPCJITInfo.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-06-16 17:04:06 +0000
committerChris Lattner <sabre@nondot.org>2008-06-16 17:04:06 +0000
commitdab43b2fc2955afd32ef386e3611355e5170b411 (patch)
tree534efaada95228814631e05fe557a00d0da3e693 /lib/Target/PowerPC/PPCJITInfo.cpp
parent7894e5bbac35100047396161587a0875f93828e1 (diff)
downloadexternal_llvm-dab43b2fc2955afd32ef386e3611355e5170b411.zip
external_llvm-dab43b2fc2955afd32ef386e3611355e5170b411.tar.gz
external_llvm-dab43b2fc2955afd32ef386e3611355e5170b411.tar.bz2
Add support for icache invalidation on non-darwin ppc systems.
Patch by Gary Benson! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52332 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PowerPC/PPCJITInfo.cpp')
-rw-r--r--lib/Target/PowerPC/PPCJITInfo.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/Target/PowerPC/PPCJITInfo.cpp b/lib/Target/PowerPC/PPCJITInfo.cpp
index cbc7353..db36881 100644
--- a/lib/Target/PowerPC/PPCJITInfo.cpp
+++ b/lib/Target/PowerPC/PPCJITInfo.cpp
@@ -333,9 +333,26 @@ extern "C" void sys_icache_invalidate(const void *Addr, size_t len);
/// 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__)
+#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
}