]> Savannah Git Hosting - gnulib.git/commitdiff
jit/cache: Fix for hppa CPUs.
authorBruno Haible <bruno@clisp.org>
Tue, 9 Jan 2024 21:12:11 +0000 (22:12 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 18 Jan 2024 08:29:19 +0000 (09:29 +0100)
* lib/jit/cache.h (clear_cache): On hppa CPUs, use the 'fdc' and 'fic'
instructions.

ChangeLog
lib/jit/cache.h

index 64f6803206e51c44926bcb53fcfeecbbab159fae..746b428d0d0eecb741a52bb92a348668e13aeffd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2024-01-09  Bruno Haible  <bruno@clisp.org>
 
+       jit/cache: Fix for hppa CPUs.
+       * lib/jit/cache.h (clear_cache): On hppa CPUs, use the 'fdc' and 'fic'
+       instructions.
+
        jit/cache tests: Avoid test failure on OpenBSD.
        * tests/jit/test-cache.c (return1_code, return2_code): New constants.
        (main): On OpenBSD, use return1_code and return2_code instead of
index 5bcc22cdc95bccc790d988b51bf6e545f2bad742..2a3469e0c4f5558eaf5146a7da3dd6c621487394 100644 (file)
@@ -99,6 +99,30 @@ clear_cache (void *start, void *end)
       addr += 8;
     }
   while (addr < end_addr);
+#elif (defined __GNUC__ || defined __clang__) && defined __hppa
+  /* Use inline assembly.  */
+  /* The PA-RISC 1.1 Architecture and Instruction Set Reference Manual says:
+     "A cache line can be 16, 32, or 64 bytes in length."  */
+  /* XXX Is this good enough, or do we need the space register business
+     like in gcc/gcc/config/pa/pa.md and libffcall/trampoline/cache-hppa.c?  */
+  intptr_t cache_line_size = 16;
+  uintptr_t addr = (uintptr_t) start & ~cache_line_size;
+  uintptr_t end_addr = (uintptr_t) end;
+  do
+    {
+      asm volatile ("fdc 0(0,%0)"
+             "\n\t" "sync"
+             "\n\t" "fic 0(0,%0)"
+             "\n\t" "sync" : : "r" (addr));
+      addr += cache_line_size;
+    }
+  while (addr < end_addr);
+  asm volatile ("nop"
+         "\n\t" "nop"
+         "\n\t" "nop"
+         "\n\t" "nop"
+         "\n\t" "nop"
+         "\n\t" "nop");
 #elif (defined __GNUC__ || defined __clang__) && defined __m68k__ && defined __linux__
   /* Use inline assembly to call the 'cacheflush' system call.
      sys_cacheflush (addr, scope, cache, len)