[1/7] RISC-V: Use .insn directive form for orc.b

Message ID 20240422074403.2399529-2-christoph.muellner@vrull.eu
State Superseded
Delegated to: Carlos O'Donell
Headers
Series Add ifunc support for existing Zbb optimizations |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Testing passed

Commit Message

Christoph Müllner April 22, 2024, 7:43 a.m. UTC
  The orc.b instruction is part of the Zbb extension, which was ratified in 2021.
GAS releases older than that won't know of the instruction.
Newer GAS releases accepted orc.b only if Zbb is enabled in the -march string.

This patch changes the inline asm for orc.b to the '.insn' directive form,
which allows (future changes) to build orc.b-optimized routines by defining
the Zbb feature test macro (__riscv_zbb).  Building optimized routines
this way is compatible with releases of GAS with and without Zbb support.

Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
---
 sysdeps/riscv/string-fza.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Patch

diff --git a/sysdeps/riscv/string-fza.h b/sysdeps/riscv/string-fza.h
index ee5c31317f..47b1fd152f 100644
--- a/sysdeps/riscv/string-fza.h
+++ b/sysdeps/riscv/string-fza.h
@@ -36,7 +36,8 @@  find_zero_all (op_t x)
   asm ("th.tstnbz %0, %1" : "=r" (r) : "r" (x));
   return r;
 #else
-  asm ("orc.b %0, %1" : "=r" (r) : "r" (x));
+  /* orc.b using the .insn directive (supported by older Binutils releases).  */
+  asm (".insn i 0x13, 0x5, %0, %1, 0x287" : "=r" (r) : "r" (x));
   return ~r;
 #endif
 }