aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2008-11-14 02:33:17 +0000
committerEvan Cheng <evan.cheng@apple.com>2008-11-14 02:33:17 +0000
commitc663beecdb6d87409ac4891c1a8febdf12013ad2 (patch)
treed88b28ddbe2823b667b814a155573647b5c8d409
parent59d5f1d13babee143957686003db06f605d05ba2 (diff)
ARM / Mac OS X also wants to invalidate icache after jitting.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59291 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/System/Memory.cpp42
1 files changed, 22 insertions, 20 deletions
diff --git a/lib/System/Memory.cpp b/lib/System/Memory.cpp
index 3660bcb1a4..375c73cf02 100644
--- a/lib/System/Memory.cpp
+++ b/lib/System/Memory.cpp
@@ -35,26 +35,28 @@ extern "C" void sys_icache_invalidate(const void *Addr, size_t len);
void llvm::sys::Memory::InvalidateInstructionCache(const void *Addr,
size_t Len) {
-// icache invalidation for PPC.
+// icache invalidation for PPC and ARM.
+#if defined(__APPLE__)
#if (defined(__POWERPC__) || defined (__ppc__) || \
- defined(_POWER) || defined(_ARCH_PPC))
- #if defined(__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 // end PPC
+ defined(_POWER) || defined(_ARCH_PPC)) || defined(__arm__)
+ sys_icache_invalidate(Addr, Len);
+#endif
+#else
+#if (defined(__POWERPC__) || defined (__ppc__) || \
+ defined(_POWER) || defined(_ARCH_PPC)) && 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 // end apple
}