[2/2] RISC-V: Require a extension for testcases with atomic insns
Checks
Commit Message
Add testsuite infrastructure for the A extension and use it to require the A
extension for dg-do run and add the add extension for non-A dg-do compile.
gcc/testsuite/ChangeLog:
* gcc.target/riscv/amo-table-a-6-amo-add-1.c: Add A extension to
dg-options for dg-do compile.
* gcc.target/riscv/amo-table-a-6-amo-add-2.c: Ditto.
* gcc.target/riscv/amo-table-a-6-amo-add-3.c: Ditto.
* gcc.target/riscv/amo-table-a-6-amo-add-4.c: Ditto.
* gcc.target/riscv/amo-table-a-6-amo-add-5.c: Ditto.
* gcc.target/riscv/amo-table-a-6-compare-exchange-1.c: Ditto.
* gcc.target/riscv/amo-table-a-6-compare-exchange-2.c: Ditto.
* gcc.target/riscv/amo-table-a-6-compare-exchange-3.c: Ditto.
* gcc.target/riscv/amo-table-a-6-compare-exchange-4.c: Ditto.
* gcc.target/riscv/amo-table-a-6-compare-exchange-5.c: Ditto.
* gcc.target/riscv/amo-table-a-6-compare-exchange-6.c: Ditto.
* gcc.target/riscv/amo-table-a-6-compare-exchange-7.c: Ditto.
* gcc.target/riscv/amo-table-a-6-subword-amo-add-1.c: Ditto.
* gcc.target/riscv/amo-table-a-6-subword-amo-add-2.c: Ditto.
* gcc.target/riscv/amo-table-a-6-subword-amo-add-3.c: Ditto.
* gcc.target/riscv/amo-table-a-6-subword-amo-add-4.c: Ditto.
* gcc.target/riscv/amo-table-a-6-subword-amo-add-5.c: Ditto.
* gcc.target/riscv/inline-atomics-2.c: Ditto.
* gcc.target/riscv/inline-atomics-3.c: Require A extension for dg-do
run.
* gcc.target/riscv/inline-atomics-4.c: Ditto.
* gcc.target/riscv/inline-atomics-5.c: Ditto.
* gcc.target/riscv/inline-atomics-6.c: Ditto.
* gcc.target/riscv/inline-atomics-7.c: Ditto.
* gcc.target/riscv/inline-atomics-8.c: Ditto.
* lib/target-supports.exp: Add testing infrastructure to require the A
extension or add it to an existing -march.
Signed-off-by: Patrick O'Neill <patrick@rivosinc.com>
---
This patch relies on the previous one in the series. If applied seperately,
amo-table-a-6-store-compat-3.c and amo-table-a-6-load-3.c must be updated to
require the A extension as those testcases check for the optimized fences.
---
.../riscv/amo-table-a-6-amo-add-1.c | 1 +
.../riscv/amo-table-a-6-amo-add-2.c | 1 +
.../riscv/amo-table-a-6-amo-add-3.c | 1 +
.../riscv/amo-table-a-6-amo-add-4.c | 1 +
.../riscv/amo-table-a-6-amo-add-5.c | 1 +
.../riscv/amo-table-a-6-compare-exchange-1.c | 1 +
.../riscv/amo-table-a-6-compare-exchange-2.c | 1 +
.../riscv/amo-table-a-6-compare-exchange-3.c | 1 +
.../riscv/amo-table-a-6-compare-exchange-4.c | 1 +
.../riscv/amo-table-a-6-compare-exchange-5.c | 1 +
.../riscv/amo-table-a-6-compare-exchange-6.c | 1 +
.../riscv/amo-table-a-6-compare-exchange-7.c | 1 +
.../riscv/amo-table-a-6-subword-amo-add-1.c | 1 +
.../riscv/amo-table-a-6-subword-amo-add-2.c | 1 +
.../riscv/amo-table-a-6-subword-amo-add-3.c | 1 +
.../riscv/amo-table-a-6-subword-amo-add-4.c | 1 +
.../riscv/amo-table-a-6-subword-amo-add-5.c | 1 +
.../gcc.target/riscv/inline-atomics-2.c | 3 ++-
.../gcc.target/riscv/inline-atomics-3.c | 2 +-
.../gcc.target/riscv/inline-atomics-4.c | 2 +-
.../gcc.target/riscv/inline-atomics-5.c | 2 +-
.../gcc.target/riscv/inline-atomics-6.c | 2 +-
.../gcc.target/riscv/inline-atomics-7.c | 2 +-
.../gcc.target/riscv/inline-atomics-8.c | 2 +-
gcc/testsuite/lib/target-supports.exp | 23 +++++++++++++++++++
25 files changed, 48 insertions(+), 7 deletions(-)
--
2.34.1
Comments
On 10/30/23 18:49, Patrick O'Neill wrote:
> Add testsuite infrastructure for the A extension and use it to require the A
> extension for dg-do run and add the add extension for non-A dg-do compile.
>
> gcc/testsuite/ChangeLog:
>
> * gcc.target/riscv/amo-table-a-6-amo-add-1.c: Add A extension to
> dg-options for dg-do compile.
> * gcc.target/riscv/amo-table-a-6-amo-add-2.c: Ditto.
> * gcc.target/riscv/amo-table-a-6-amo-add-3.c: Ditto.
> * gcc.target/riscv/amo-table-a-6-amo-add-4.c: Ditto.
> * gcc.target/riscv/amo-table-a-6-amo-add-5.c: Ditto.
> * gcc.target/riscv/amo-table-a-6-compare-exchange-1.c: Ditto.
> * gcc.target/riscv/amo-table-a-6-compare-exchange-2.c: Ditto.
> * gcc.target/riscv/amo-table-a-6-compare-exchange-3.c: Ditto.
> * gcc.target/riscv/amo-table-a-6-compare-exchange-4.c: Ditto.
> * gcc.target/riscv/amo-table-a-6-compare-exchange-5.c: Ditto.
> * gcc.target/riscv/amo-table-a-6-compare-exchange-6.c: Ditto.
> * gcc.target/riscv/amo-table-a-6-compare-exchange-7.c: Ditto.
> * gcc.target/riscv/amo-table-a-6-subword-amo-add-1.c: Ditto.
> * gcc.target/riscv/amo-table-a-6-subword-amo-add-2.c: Ditto.
> * gcc.target/riscv/amo-table-a-6-subword-amo-add-3.c: Ditto.
> * gcc.target/riscv/amo-table-a-6-subword-amo-add-4.c: Ditto.
> * gcc.target/riscv/amo-table-a-6-subword-amo-add-5.c: Ditto.
> * gcc.target/riscv/inline-atomics-2.c: Ditto.
> * gcc.target/riscv/inline-atomics-3.c: Require A extension for dg-do
> run.
> * gcc.target/riscv/inline-atomics-4.c: Ditto.
> * gcc.target/riscv/inline-atomics-5.c: Ditto.
> * gcc.target/riscv/inline-atomics-6.c: Ditto.
> * gcc.target/riscv/inline-atomics-7.c: Ditto.
> * gcc.target/riscv/inline-atomics-8.c: Ditto.
> * lib/target-supports.exp: Add testing infrastructure to require the A
> extension or add it to an existing -march.
OK
jeff
On 10/31/23 06:07, Jeff Law wrote:
>
>
> On 10/30/23 18:49, Patrick O'Neill wrote:
>> Add testsuite infrastructure for the A extension and use it to
>> require the A
>> extension for dg-do run and add the add extension for non-A dg-do
>> compile.
>>
>> gcc/testsuite/ChangeLog:
>>
>> * gcc.target/riscv/amo-table-a-6-amo-add-1.c: Add A
>> extension to
>> dg-options for dg-do compile.
>> * gcc.target/riscv/amo-table-a-6-amo-add-2.c: Ditto.
>> * gcc.target/riscv/amo-table-a-6-amo-add-3.c: Ditto.
>> * gcc.target/riscv/amo-table-a-6-amo-add-4.c: Ditto.
>> * gcc.target/riscv/amo-table-a-6-amo-add-5.c: Ditto.
>> * gcc.target/riscv/amo-table-a-6-compare-exchange-1.c: Ditto.
>> * gcc.target/riscv/amo-table-a-6-compare-exchange-2.c: Ditto.
>> * gcc.target/riscv/amo-table-a-6-compare-exchange-3.c: Ditto.
>> * gcc.target/riscv/amo-table-a-6-compare-exchange-4.c: Ditto.
>> * gcc.target/riscv/amo-table-a-6-compare-exchange-5.c: Ditto.
>> * gcc.target/riscv/amo-table-a-6-compare-exchange-6.c: Ditto.
>> * gcc.target/riscv/amo-table-a-6-compare-exchange-7.c: Ditto.
>> * gcc.target/riscv/amo-table-a-6-subword-amo-add-1.c: Ditto.
>> * gcc.target/riscv/amo-table-a-6-subword-amo-add-2.c: Ditto.
>> * gcc.target/riscv/amo-table-a-6-subword-amo-add-3.c: Ditto.
>> * gcc.target/riscv/amo-table-a-6-subword-amo-add-4.c: Ditto.
>> * gcc.target/riscv/amo-table-a-6-subword-amo-add-5.c: Ditto.
>> * gcc.target/riscv/inline-atomics-2.c: Ditto.
>> * gcc.target/riscv/inline-atomics-3.c: Require A extension
>> for dg-do
>> run.
>> * gcc.target/riscv/inline-atomics-4.c: Ditto.
>> * gcc.target/riscv/inline-atomics-5.c: Ditto.
>> * gcc.target/riscv/inline-atomics-6.c: Ditto.
>> * gcc.target/riscv/inline-atomics-7.c: Ditto.
>> * gcc.target/riscv/inline-atomics-8.c: Ditto.
>> * lib/target-supports.exp: Add testing infrastructure to
>> require the A
>> extension or add it to an existing -march.
> OK
> jeff
Committed
Patrick
@@ -1,6 +1,7 @@
/* { dg-do compile } */
/* Verify that atomic op mappings match Table A.6's recommended mapping. */
/* { dg-options "-O3" } */
+/* { dg-add-options riscv_a } */
/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
/* { dg-final { check-function-bodies "**" "" } } */
@@ -1,6 +1,7 @@
/* { dg-do compile } */
/* Verify that atomic op mappings match Table A.6's recommended mapping. */
/* { dg-options "-O3" } */
+/* { dg-add-options riscv_a } */
/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
/* { dg-final { check-function-bodies "**" "" } } */
@@ -1,6 +1,7 @@
/* { dg-do compile } */
/* Verify that atomic op mappings match Table A.6's recommended mapping. */
/* { dg-options "-O3" } */
+/* { dg-add-options riscv_a } */
/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
/* { dg-final { check-function-bodies "**" "" } } */
@@ -1,6 +1,7 @@
/* { dg-do compile } */
/* Verify that atomic op mappings match Table A.6's recommended mapping. */
/* { dg-options "-O3" } */
+/* { dg-add-options riscv_a } */
/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
/* { dg-final { check-function-bodies "**" "" } } */
@@ -1,6 +1,7 @@
/* { dg-do compile } */
/* Verify that atomic op mappings match Table A.6's recommended mapping. */
/* { dg-options "-O3" } */
+/* { dg-add-options riscv_a } */
/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */
/* { dg-final { check-function-bodies "**" "" } } */
@@ -1,5 +1,6 @@
/* { dg-do compile } */
/* Verify that compare exchange mappings match Table A.6's recommended mapping. */
+/* { dg-add-options riscv_a } */
/* { dg-final { scan-assembler-times "lr.w\t" 1 } } */
/* { dg-final { scan-assembler-times "sc.w\t" 1 } } */
@@ -1,5 +1,6 @@
/* { dg-do compile } */
/* Verify that compare exchange mappings match Table A.6's recommended mapping. */
+/* { dg-add-options riscv_a } */
/* { dg-final { scan-assembler-times "lr.w.aq\t" 1 } } */
/* { dg-final { scan-assembler-times "sc.w\t" 1 } } */
@@ -1,5 +1,6 @@
/* { dg-do compile } */
/* Verify that compare exchange mappings match Table A.6's recommended mapping. */
+/* { dg-add-options riscv_a } */
/* { dg-final { scan-assembler-times "lr.w.aq\t" 1 } } */
/* { dg-final { scan-assembler-times "sc.w\t" 1 } } */
@@ -1,5 +1,6 @@
/* { dg-do compile } */
/* Verify that compare exchange mappings match Table A.6's recommended mapping. */
+/* { dg-add-options riscv_a } */
/* { dg-final { scan-assembler-times "lr.w\t" 1 } } */
/* { dg-final { scan-assembler-times "sc.w.rl\t" 1 } } */
@@ -1,5 +1,6 @@
/* { dg-do compile } */
/* Verify that compare exchange mappings match Table A.6's recommended mapping. */
+/* { dg-add-options riscv_a } */
/* { dg-final { scan-assembler-times "lr.w.aqrl\t" 1 } } */
/* { dg-final { scan-assembler-times "sc.w.rl\t" 1 } } */
@@ -1,5 +1,6 @@
/* { dg-do compile } */
/* Verify that compare exchange mappings match Table A.6's recommended mapping. */
+/* { dg-add-options riscv_a } */
/* Mixed mappings need to be unioned. */
/* { dg-final { scan-assembler-times "lr.w.aq\t" 1 } } */
/* { dg-final { scan-assembler-times "sc.w.rl\t" 1 } } */
@@ -1,5 +1,6 @@
/* { dg-do compile } */
/* Verify that compare exchange mappings match Table A.6's recommended mapping. */
+/* { dg-add-options riscv_a } */
/* { dg-final { scan-assembler-times "lr.w.aqrl\t" 1 } } */
/* { dg-final { scan-assembler-times "sc.w.rl\t" 1 } } */
@@ -1,5 +1,6 @@
/* { dg-do compile } */
/* Verify that subword atomic op mappings match Table A.6's recommended mapping. */
+/* { dg-add-options riscv_a } */
/* { dg-final { scan-assembler-times "lr.w\t" 1 } } */
/* { dg-final { scan-assembler-times "sc.w\t" 1 } } */
@@ -1,5 +1,6 @@
/* { dg-do compile } */
/* Verify that subword atomic op mappings match Table A.6's recommended mapping. */
+/* { dg-add-options riscv_a } */
/* { dg-final { scan-assembler-times "lr.w.aq\t" 1 } } */
/* { dg-final { scan-assembler-times "sc.w\t" 1 } } */
@@ -1,5 +1,6 @@
/* { dg-do compile } */
/* Verify that subword atomic op mappings match Table A.6's recommended mapping. */
+/* { dg-add-options riscv_a } */
/* { dg-final { scan-assembler-times "lr.w\t" 1 } } */
/* { dg-final { scan-assembler-times "sc.w.rl\t" 1 } } */
@@ -1,5 +1,6 @@
/* { dg-do compile } */
/* Verify that subword atomic op mappings match Table A.6's recommended mapping. */
+/* { dg-add-options riscv_a } */
/* { dg-final { scan-assembler-times "lr.w.aq\t" 1 } } */
/* { dg-final { scan-assembler-times "sc.w.rl\t" 1 } } */
@@ -1,5 +1,6 @@
/* { dg-do compile } */
/* Verify that subword atomic op mappings match Table A.6's recommended mapping. */
+/* { dg-add-options riscv_a } */
/* { dg-final { scan-assembler-times "lr.w.aqrl\t" 1 } } */
/* { dg-final { scan-assembler-times "sc.w.rl\t" 1 } } */
@@ -1,9 +1,10 @@
/* { dg-do compile } */
/* Verify that subword atomics do not generate calls. */
/* { dg-options "-minline-atomics" } */
+/* { dg-add-options riscv_a } */
/* { dg-message "note: '__sync_fetch_and_nand' changed semantics in GCC 4.4" "fetch_and_nand" { target *-*-* } 0 } */
/* { dg-final { scan-assembler-not "\tcall\t__sync_fetch_and_add_1" } } */
/* { dg-final { scan-assembler-not "\tcall\t__sync_fetch_and_nand_1" } } */
/* { dg-final { scan-assembler-not "\tcall\t__sync_bool_compare_and_swap_1" } } */
-#include "inline-atomics-1.c"
\ No newline at end of file
+#include "inline-atomics-1.c"
@@ -2,7 +2,7 @@
/* Duplicate logic as libatomic/testsuite/libatomic.c/atomic-op-1.c */
/* Test __atomic routines for existence and proper execution on 1 byte
values with each valid memory model. */
-/* { dg-do run } */
+/* { dg-do run { target { riscv_a } } } */
/* { dg-options "-minline-atomics -Wno-address-of-packed-member" } */
/* Test the execution of the __atomic_*OP builtin routines for a char. */
@@ -2,7 +2,7 @@
/* Duplicate logic as libatomic/testsuite/libatomic.c/atomic-op-2.c */
/* Test __atomic routines for existence and proper execution on 2 byte
values with each valid memory model. */
-/* { dg-do run } */
+/* { dg-do run { target { riscv_a } } } */
/* { dg-options "-minline-atomics -Wno-address-of-packed-member" } */
/* Test the execution of the __atomic_*OP builtin routines for a short. */
@@ -1,7 +1,7 @@
/* Test __atomic routines for existence and proper execution on 1 byte
values with each valid memory model. */
/* Duplicate logic as libatomic/testsuite/libatomic.c/atomic-compare-exchange-1.c */
-/* { dg-do run } */
+/* { dg-do run { target { riscv_a } } } */
/* { dg-options "-minline-atomics" } */
/* Test the execution of the __atomic_compare_exchange_n builtin for a char. */
@@ -1,7 +1,7 @@
/* Test __atomic routines for existence and proper execution on 2 byte
values with each valid memory model. */
/* Duplicate logic as libatomic/testsuite/libatomic.c/atomic-compare-exchange-2.c */
-/* { dg-do run } */
+/* { dg-do run { target { riscv_a } } } */
/* { dg-options "-minline-atomics" } */
/* Test the execution of the __atomic_compare_exchange_n builtin for a short. */
@@ -1,7 +1,7 @@
/* Test __atomic routines for existence and proper execution on 1 byte
values with each valid memory model. */
/* Duplicate logic as libatomic/testsuite/libatomic.c/atomic-exchange-1.c */
-/* { dg-do run } */
+/* { dg-do run { target { riscv_a } } } */
/* { dg-options "-minline-atomics" } */
/* Test the execution of the __atomic_exchange_n builtin for a char. */
@@ -1,7 +1,7 @@
/* Test __atomic routines for existence and proper execution on 2 byte
values with each valid memory model. */
/* Duplicate logic as libatomic/testsuite/libatomic.c/atomic-exchange-2.c */
-/* { dg-do run } */
+/* { dg-do run { target { riscv_a } } } */
/* { dg-options "-minline-atomics" } */
/* Test the execution of the __atomic_X builtin for a short. */
@@ -1903,6 +1903,17 @@ proc check_effective_target_rv_float_abi_soft { } {
}]
}
+# Return 1 if the target arch supports the atomic extension, 0 otherwise.
+# Cache the result.
+
+proc check_effective_target_riscv_a { } {
+ return [check_no_compiler_messages riscv_ext_a assembly {
+ #ifndef __riscv_a
+ #error "Not __riscv_a"
+ #endif
+ }]
+}
+
# Return 1 if the target arch supports the double precision floating point
# extension, 0 otherwise. Cache the result.
@@ -2018,6 +2029,18 @@ proc riscv_get_arch { } {
return "$gcc_march"
}
+proc add_options_for_riscv_a { flags } {
+ if { [lsearch $flags -march=*] >= 0 } {
+ # If there are multiple -march flags, we have to adjust all of them.
+ set expanded_flags [regsub -all -- {((?:^|[[:space:]])-march=rv[[:digit:]]*)g+} $flags \\1imafd ]
+ return [regsub -all -- {((?:^|[[:space:]])-march=rv[[:digit:]]*[b-eg-rt-wy]*)a*} $expanded_flags \\1a ]
+ }
+ if { [check_effective_target_riscv_a] } {
+ return "$flags"
+ }
+ return "$flags -march=[regsub {(rv[[:digit:]]*[b-eg-rt-wy]*)a*} [riscv_get_arch] &a]"
+}
+
proc add_options_for_riscv_d { flags } {
if { [lsearch $flags -march=*] >= 0 } {
# If there are multiple -march flags, we have to adjust all of them.