/* { 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 "**" "" } } */
/* { 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 "**" "" } } */
/* { 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 "**" "" } } */
/* { 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 "**" "" } } */
/* { 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 "**" "" } } */
/* { 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 } } */
/* { 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 } } */
/* { 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 } } */
/* { 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 } } */
/* { 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 } } */
/* { 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 } } */
/* { 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 } } */
/* { 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 } } */
/* { 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 } } */
/* { 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 } } */
/* { 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 } } */
/* { 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 } } */
/* { 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"
/* 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. */
/* 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. */
/* 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. */
/* 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. */
/* 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. */
/* 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. */
}]
}
+# 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.
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.