-@c Copyright (C) 2002-2025 Free Software Foundation, Inc.
+cc Copyright (C) 2002-2025 Free Software Foundation, Inc.
@c This is part of the GCC manual.
@c For copying conditions, see the file gcc.texi.
@item riscv_a
Test target architecture has support for the A extension.
+@item riscv_b_ok
+Test target architecture can execute code with B extension enabled.
+
+@item riscv_v_ok
+Test target architecture can execute code with V extension enabled.
+
@item riscv_zaamo
Test target architecture has support for the zaamo extension.
-/* { dg-do run } */
-/* { dg-require-effective-target rv64 } */
+/* { dg-do run { target { rv64 && riscv_b_ok } } } */
/* { dg-options "-march=rv64gc_zbb -mabi=lp64d -fno-ext-dce" } */
extern void abort (void);
-/* { dg-do run { target { riscv64*-*-* } } } */
+/* { dg-do run { target { rv64 && riscv_b_ok } } } */
/* { dg-options "-march=rv64gc_zba_zbb -mabi=lp64d" } */
#define myconst 0x4fffaffb0fffefffUL;
-/* { dg-do run { target { rv64 } } } */
+/* { dg-do run { target { rv64 && riscv_b_ok } } } */
/* { dg-additional-options "-march=rv64gcb -std=gnu23" } */
__attribute__ ((noipa)) _Bool
-/* { dg-do run { target { rv64 } } } */
+/* { dg-do run { target { rv64 && riscv_b_ok } } } */
/* { dg-options "-march=rv64gc_zba -mabi=lp64d -O2" } */
struct {
}
+# Return 1 if we can execute code when using dg-add-options riscv_b
+
+proc check_effective_target_riscv_b_ok { } {
+ # If the target already supports zbb without any added options,
+ # we may assume we can execute just fine.
+ # Technically we should really check for zba/zbs too, but I haven't
+ # seen a design that implements a subset of zba/zbb/zbs yet.
+ if { [check_effective_target_riscv_zbb] } {
+ return 1
+ }
+
+ # check if we can execute bitmanip insns with the given hardware or
+ # simulator
+ set gcc_march [regsub {[[:alnum:]]*} [riscv_get_arch] &b]
+ if { [check_runtime ${gcc_march}_exec {
+ int main() { asm("sh2add t0, a0, a1"); return 0; } } "-march=${gcc_march}"] } {
+ return 1
+ }
+
+ # Possible future extensions: If the target is a simulator, dg-add-options
+ # might change its config to make it allow vector insns, or we might use
+ # options to set special elf flags / sections to effect that.
+
+ return 0
+}
+
# Return 1 if we can execute code when using dg-add-options riscv_v
proc check_effective_target_riscv_v_ok { } {