diff options
| author | Sterling Augustine <saugustine@google.com> | 2017-07-28 19:49:22 +0000 |
|---|---|---|
| committer | Sterling Augustine <saugustine@google.com> | 2017-07-28 19:49:22 +0000 |
| commit | dd9173420f06d4ce3cf4f92c13da1cdba48d33c7 (patch) | |
| tree | 6c3eeecee4de79e8a174ab5a4c067858f4d8d970 /compiler-rt/lib/builtins/clear_cache.c | |
| parent | 9be82c31691cb4d062bb0f56724fb1e064000fc0 (diff) | |
| download | bcm5719-llvm-dd9173420f06d4ce3cf4f92c13da1cdba48d33c7.tar.gz bcm5719-llvm-dd9173420f06d4ce3cf4f92c13da1cdba48d33c7.zip | |
Add clear_cache implementation for ppc64. Fix buffer to meet ppc64 alignment.
llvm-svn: 309423
Diffstat (limited to 'compiler-rt/lib/builtins/clear_cache.c')
| -rw-r--r-- | compiler-rt/lib/builtins/clear_cache.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/compiler-rt/lib/builtins/clear_cache.c b/compiler-rt/lib/builtins/clear_cache.c index af4ca619ad1..3c6570db6d5 100644 --- a/compiler-rt/lib/builtins/clear_cache.c +++ b/compiler-rt/lib/builtins/clear_cache.c @@ -165,6 +165,21 @@ void __clear_cache(void *start, void *end) { for (addr = xstart; addr < xend; addr += icache_line_size) __asm __volatile("ic ivau, %0" :: "r"(addr)); __asm __volatile("isb sy"); +#elif defined (__powerpc64__) && defined(__LITTLE_ENDIAN__) + const size_t line_size = 32; + const size_t len = (uintptr_t)end - (uintptr_t)start; + + const uintptr_t mask = ~(line_size - 1); + const uintptr_t start_line = ((uintptr_t)start) & mask; + const uintptr_t end_line = ((uintptr_t)start + len + line_size - 1) & mask; + + for (uintptr_t line = start_line; line < end_line; line += line_size) + __asm__ volatile("dcbf 0, %0" : : "r"(line)); + __asm__ volatile("sync"); + + for (uintptr_t line = start_line; line < end_line; line += line_size) + __asm__ volatile("icbi 0, %0" : : "r"(line)); + __asm__ volatile("isync"); #else #if __APPLE__ /* On Darwin, sys_icache_invalidate() provides this functionality */ @@ -174,4 +189,3 @@ void __clear_cache(void *start, void *end) { #endif #endif } - |

