[PATCH] D64496: [compiler-rt][builtins] Provide __clear_cache for SPARC

Rainer Orth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 23 09:34:16 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL366822: [compiler-rt][builtins] Provide __clear_cache for SPARC (authored by ro, committed by ).
Herald added a subscriber: delcypher.

Changed prior to commit:
  https://reviews.llvm.org/D64496?vs=208959&id=211319#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64496/new/

https://reviews.llvm.org/D64496

Files:
  compiler-rt/trunk/lib/builtins/clear_cache.c


Index: compiler-rt/trunk/lib/builtins/clear_cache.c
===================================================================
--- compiler-rt/trunk/lib/builtins/clear_cache.c
+++ compiler-rt/trunk/lib/builtins/clear_cache.c
@@ -173,6 +173,16 @@
   for (uintptr_t line = start_line; line < end_line; line += line_size)
     __asm__ volatile("icbi 0, %0" : : "r"(line));
   __asm__ volatile("isync");
+#elif defined(__sparc__)
+  const size_t dword_size = 8;
+  const size_t len = (uintptr_t)end - (uintptr_t)start;
+
+  const uintptr_t mask = ~(dword_size - 1);
+  const uintptr_t start_dword = ((uintptr_t)start) & mask;
+  const uintptr_t end_dword = ((uintptr_t)start + len + dword_size - 1) & mask;
+
+  for (uintptr_t dword = start_dword; dword < end_dword; dword += dword_size)
+    __asm__ volatile("flush %0" : : "r"(dword));
 #else
 #if __APPLE__
   // On Darwin, sys_icache_invalidate() provides this functionality


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64496.211319.patch
Type: text/x-patch
Size: 918 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190723/31671bbb/attachment.bin>


More information about the llvm-commits mailing list