# Load support procs.
load_lib gcc-dg.exp
-# If a testcase doesn't have special options, use these.
-global DEFAULT_CFLAGS
-if ![info exists DEFAULT_CFLAGS] then {
- set DEFAULT_CFLAGS " -ansi -pedantic-errors"
-}
-
# Initialize `dg'.
dg-init
-# Force SVE if we're not testing it already.
if { [check_effective_target_aarch64_sve] } {
set sve_flags ""
} else {
set sve_flags "-march=armv8.2-a+sve"
}
-# Turn off any codegen tweaks by default that may affect expected assembly.
-# Tests relying on those should turn them on explicitly.
-set sve_flags "$sve_flags -moverride=tune=none"
-
# Most of the code-quality tests are written for LP64. Just do the
# correctness tests for ILP32.
if { [check_effective_target_ilp32] } {
set pattern "*"
}
-# Main loop.
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/$pattern.\[cCS\]]] \
- $sve_flags $DEFAULT_CFLAGS
+aarch64-with-arch-dg-options $sve_flags {
+ # Main loop.
+ dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/$pattern.\[cCS\]]] \
+ "" $sve_flags
+}
# All done.
dg-finish
# Load support procs.
load_lib gcc-dg.exp
-# If a testcase doesn't have special options, use these.
-global DEFAULT_CFLAGS
-if ![info exists DEFAULT_CFLAGS] then {
- set DEFAULT_CFLAGS " -ansi -pedantic-errors"
-}
-
# Initialize `dg'.
dg-init
set sve2_flags "-march=armv8.5-a+sve2"
}
-# Main loop.
-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \
- $sve2_flags $DEFAULT_CFLAGS
+aarch64-with-arch-dg-options $sve2_flags {
+ # Main loop.
+ dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \
+ "" $sve2_flags
+}
# All done.
dg-finish
pass "$testcase dg-check-dot $dotfile"
}
+
+# Used by aarch64-with-arch-dg-options to intercept dg-options and make
+# the changes required. See there for details.
+proc aarch64-arch-dg-options { args } {
+ upvar dg-do-what do_what
+ global aarch64_default_testing_arch
+
+ set add_arch 1
+ set add_tune 1
+ set checks_output [string equal [lindex $do_what 0] "compile"]
+ set options [lindex $args 1]
+
+ foreach option [split $options] {
+ switch -glob -- $option {
+ -march=* { set add_arch 0 }
+ -mcpu=* { set add_arch 0; set add_tune 0 }
+ -mtune=* { set add_tune 0 }
+ -moverride=* { set add_tune 0 }
+ -save-temps { set checks_output 1 }
+ --save-temps { set checks_output 1 }
+ -fdump* { set checks_output 1 }
+ }
+ }
+
+ if { $add_arch && ![string equal $aarch64_default_testing_arch ""] } {
+ # Force SVE if we're not testing it already.
+ append options " $aarch64_default_testing_arch"
+ }
+
+ if { $add_tune && $checks_output } {
+ # Turn off any default tuning and codegen tweaks.
+ append options " -mtune=generic -moverride=tune=none"
+ }
+
+ uplevel 1 aarch64-old-dg-options [lreplace $args 1 1 $options]
+}
+
+# Run Tcl code CODE with dg-options modified to work better for some
+# AArch64 tests. In particular:
+#
+# - If the dg-options do not specify an -march or -mcpu option,
+# use the architecture options in ARCH (which might be empty).
+#
+# - If the dg-options do not specify an -mcpu, -mtune or -moverride option,
+# and if the test appears to be checking assembly or dump output,
+# force the test to use generic tuning.
+#
+# The idea is to handle toolchains that are configured with a default
+# CPU or architecture that's different from the norm.
+proc aarch64-with-arch-dg-options { arch code } {
+ global aarch64_default_testing_arch
+
+ set aarch64_default_testing_arch $arch
+
+ rename dg-options aarch64-old-dg-options
+ rename aarch64-arch-dg-options dg-options
+
+ uplevel 1 $code
+
+ rename dg-options aarch64-arch-dg-options
+ rename aarch64-old-dg-options dg-options
+}