aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/lib
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/lib')
-rw-r--r--gcc/testsuite/lib/g++-dg.exp130
-rw-r--r--gcc/testsuite/lib/gcc-dg.exp1
-rw-r--r--gcc/testsuite/lib/gm2-dg.exp37
-rw-r--r--gcc/testsuite/lib/htmltest.py98
-rw-r--r--gcc/testsuite/lib/sarif.py15
-rw-r--r--gcc/testsuite/lib/scanhtml.exp90
-rw-r--r--gcc/testsuite/lib/target-supports.exp172
7 files changed, 451 insertions, 92 deletions
diff --git a/gcc/testsuite/lib/g++-dg.exp b/gcc/testsuite/lib/g++-dg.exp
index 26bda65..042a917 100644
--- a/gcc/testsuite/lib/g++-dg.exp
+++ b/gcc/testsuite/lib/g++-dg.exp
@@ -27,6 +27,79 @@ proc g++-dg-prune { system text } {
return [gcc-dg-prune $system $text]
}
+# Return a list of -std flags to use for TEST.
+proc g++-std-flags { test } {
+ # If the testcase specifies a standard, use that one.
+ # If not, run it under several standards, allowing GNU extensions
+ # if there's a dg-options line.
+ if ![search_for $test "-std=*++"] {
+ if [search_for $test "dg-options"] {
+ set std_prefix "-std=gnu++"
+ } else {
+ set std_prefix "-std=c++"
+ }
+
+ set low 0
+ # Some directories expect certain minimums.
+ if { [string match "*/coroutines/*" $test] } { set low 20 }
+ if { [string match "*/modules/*" $test] } { set low 17 }
+
+ # See g++.exp for the initial value of this list.
+ global gpp_std_list
+ if { [llength $gpp_std_list] > 0 } {
+ set std_list {}
+ foreach ver $gpp_std_list {
+ set cmpver $ver
+ if { $ver == 98 } { set cmpver 03 }
+ if { $ver ni $std_list
+ && $cmpver >= $low } {
+ lappend std_list $ver
+ }
+ }
+ } else {
+ # If the test mentions specific C++ versions, test those.
+ set lines [get_matching_lines $test {\{ dg* c++[0-9][0-9]}]
+ set std_list {}
+ foreach line $lines {
+ regexp {c\+\+([0-9][0-9])} $line -> ver
+ lappend std_list $ver
+
+ if { $ver == 98 } {
+ # Leave low alone.
+ } elseif { [regexp {dg-do|dg-require-effective-target} $line] } {
+ set low $ver
+ }
+ }
+ #verbose "low: $low" 1
+
+ set std_list [lsort -unique $std_list]
+
+ # If fewer than 3 specific versions are mentioned, add more.
+ # The order of this list is significant: first $cxx_default,
+ # then the oldest and newest, then others in rough order of
+ # importance based on test coverage and usage.
+ foreach ver { 17 98 26 11 20 14 23 } {
+ set cmpver $ver
+ if { $ver == 98 } { set cmpver 03 }
+ if { [llength $std_list] < 3
+ && $ver ni $std_list
+ && $cmpver >= $low } {
+ lappend std_list $ver
+ }
+ }
+ verbose "std_list: $std_list" 1
+ }
+ set option_list { }
+ foreach x $std_list {
+ if { $x eq "impcx" } then { set x "26 -fimplicit-constexpr" }
+ lappend option_list "${std_prefix}$x"
+ }
+ } else {
+ set option_list { "" }
+ }
+ return $option_list
+}
+
# Modified dg-runtest that runs tests in multiple standard modes,
# unless they specifically specify one standard.
proc g++-dg-runtest { testcases flags default-extra-flags } {
@@ -38,62 +111,7 @@ proc g++-dg-runtest { testcases flags default-extra-flags } {
continue
}
- # If the testcase specifies a standard, use that one.
- # If not, run it under several standards, allowing GNU extensions
- # if there's a dg-options line.
- if ![search_for $test "-std=*++"] {
- if [search_for $test "dg-options"] {
- set std_prefix "-std=gnu++"
- } else {
- set std_prefix "-std=c++"
- }
-
- # See g++.exp for the initial value of this list.
- global gpp_std_list
- if { [llength $gpp_std_list] > 0 } {
- set std_list $gpp_std_list
- } else {
- # If the test mentions specific C++ versions, test those.
- set lines [get_matching_lines $test {\{ dg* c++[0-9][0-9]}]
- set std_list {}
- set low 0
- foreach line $lines {
- regexp {c\+\+([0-9][0-9])} $line -> ver
- lappend std_list $ver
-
- if { $ver == 98 } {
- # Leave low alone.
- } elseif { [regexp {dg-do|dg-require-effective-target} $line] } {
- set low $ver
- }
- }
- #verbose "low: $low" 1
-
- set std_list [lsort -unique $std_list]
-
- # If fewer than 3 specific versions are mentioned, add more.
- # The order of this list is significant: first $cxx_default,
- # then the oldest and newest, then others in rough order of
- # importance based on test coverage and usage.
- foreach ver { 17 98 26 11 20 14 23 } {
- set cmpver $ver
- if { $ver == 98 } { set cmpver 03 }
- if { [llength $std_list] < 3
- && $ver ni $std_list
- && $cmpver > $low } {
- lappend std_list $ver
- }
- }
- verbose "std_list: $std_list" 1
- }
- set option_list { }
- foreach x $std_list {
- if { $x eq "impcx" } then { set x "26 -fimplicit-constexpr" }
- lappend option_list "${std_prefix}$x"
- }
- } else {
- set option_list { "" }
- }
+ set option_list [g++-std-flags $test]
set nshort [file tail [file dirname $test]]/[file tail $test]
diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 6dd8fa3..312c4b8 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -26,6 +26,7 @@ load_lib scanipa.exp
load_lib scanwpaipa.exp
load_lib scanlang.exp
load_lib scansarif.exp
+load_lib scanhtml.exp
load_lib timeout.exp
load_lib timeout-dg.exp
load_lib prune.exp
diff --git a/gcc/testsuite/lib/gm2-dg.exp b/gcc/testsuite/lib/gm2-dg.exp
index eaed554..5a36507 100644
--- a/gcc/testsuite/lib/gm2-dg.exp
+++ b/gcc/testsuite/lib/gm2-dg.exp
@@ -65,7 +65,7 @@ proc gm2-dg-runtest { testcases flags default-extra-flags } {
if [expr [search_for $test "dg-do run"]] {
set option_list $TORTURE_OPTIONS
} else {
- set option_list [list { -O } ]
+ set option_list [list { -O -O2 } ]
}
set nshort [file tail [file dirname $test]]/[file tail $test]
@@ -77,3 +77,38 @@ proc gm2-dg-runtest { testcases flags default-extra-flags } {
}
}
+
+# Check if frontend has been configured with option.
+# This checks a configure build option was used and not
+# the availability of a compiler command line option.
+
+proc gm2-dg-frontend-configure-check { option } {
+ global GCC_UNDER_TEST
+
+ # ignore any arguments after the command
+ set compiler [lindex $GCC_UNDER_TEST 0]
+
+ if ![is_remote host] {
+ set compiler_name [which $compiler]
+ } else {
+ set compiler_name $compiler
+ }
+
+ # verify that the compiler exists
+ if { $compiler_name != 0 } then {
+ set tmp [remote_exec host "$compiler -v"]
+ set status [lindex $tmp 0]
+ set output [lindex $tmp 1]
+ regexp "Configured with.*\[\n\r\]" $output config
+ set option "*${option}*"
+ if { [string match $option $config] } {
+ return 1
+ } else {
+ return 0
+ }
+ } else {
+ # compiler does not exist (this should have already been detected)
+ warning "$compiler does not exist"
+ return 0
+ }
+}
diff --git a/gcc/testsuite/lib/htmltest.py b/gcc/testsuite/lib/htmltest.py
new file mode 100644
index 0000000..35f524c
--- /dev/null
+++ b/gcc/testsuite/lib/htmltest.py
@@ -0,0 +1,98 @@
+import os
+import xml.etree.ElementTree as ET
+
+def html_tree_from_env():
+ # return parsed HTML content as an ET from an HTML_PATH file
+ html_filename = os.environ['HTML_PATH']
+ html_filename += '.html'
+ print('html_filename: %r' % html_filename)
+ return ET.parse(html_filename)
+
+XHTML = 'http://www.w3.org/1999/xhtml'
+SVG = 'http://www.w3.org/2000/svg'
+ns = {'xhtml': XHTML,
+ 'svg' : SVG}
+
+def make_tag(local_name):
+ return f'{{{XHTML}}}' + local_name
+
+def assert_tag(element, expected):
+ assert element.tag == make_tag(expected)
+
+def assert_class(element, expected):
+ assert element.attrib['class'] == expected
+
+def assert_quoted_line(tr, expected_line_num, expected_src):
+ """Verify that tr is a line of quoted source."""
+ tds = tr.findall('xhtml:td', ns)
+ assert len(tds) == 3
+ assert_class(tds[0], 'linenum')
+ assert tds[0].text == expected_line_num
+ assert_class(tds[1], 'left-margin')
+ assert tds[1].text == ' '
+ assert_class(tds[2], 'source')
+ assert tds[2].text == expected_src
+
+def assert_annotation_line(tr, expected_src,
+ expected_line_num=' ',
+ expected_left_margin=' '):
+ """Verify that tr is an annotation line."""
+ tds = tr.findall('xhtml:td', ns)
+ assert len(tds) == 3
+ assert_class(tds[0], 'linenum')
+ assert tds[0].text == expected_line_num
+ assert_class(tds[1], 'left-margin')
+ assert tds[1].text == expected_left_margin
+ assert_class(tds[2], 'annotation')
+ assert tds[2].text == expected_src
+
+def assert_frame(frame, expected_fnname):
+ """
+ Assert that frame is of class 'stack-frame'
+ and has a child showing the expected fnname.
+ """
+ assert_class(frame, 'stack-frame')
+ funcname = frame[0]
+ assert_class(funcname, 'frame-funcname')
+ span = funcname[0]
+ assert_tag(span, 'span')
+ assert span.text == expected_fnname
+
+def assert_event_range_with_margin(element):
+ """
+ Verify that "element" is an event-range-with-margin
+ """
+ assert_tag(element, 'table')
+ assert_class(element, 'event-range-with-margin')
+ tr = element.find('xhtml:tr', ns)
+ assert tr is not None
+ td = tr.find('xhtml:td', ns)
+ assert_class(td, 'event-range')
+
+ events_hdr = td.find('xhtml:div', ns)
+ assert_class(events_hdr, 'events-hdr')
+
+ #...etc
+
+def get_diag_by_index(html_tree, index):
+ root = html_tree.getroot ()
+ assert root.tag == make_tag('html')
+
+ body = root.find('xhtml:body', ns)
+ assert body is not None
+
+ diag_list = body.find('xhtml:div', ns)
+ assert diag_list is not None
+ assert_class(diag_list, 'gcc-diagnostic-list')
+
+ diag = diag_list.find(f"xhtml:div[@id='gcc-diag-{index}']", ns)
+ return diag
+
+def get_message_within_diag(diag_element):
+ msg = diag_element.find("xhtml:div[@class='gcc-message']", ns)
+ return msg
+
+def get_locus_within_diag(diag_element):
+ src = diag_element.find('xhtml:table', ns)
+ assert_class(src, 'locus')
+ return src
diff --git a/gcc/testsuite/lib/sarif.py b/gcc/testsuite/lib/sarif.py
index 7daf35b..384de2f 100644
--- a/gcc/testsuite/lib/sarif.py
+++ b/gcc/testsuite/lib/sarif.py
@@ -1,5 +1,6 @@
import json
import os
+import xml.etree.ElementTree as ET
def sarif_from_env():
# return parsed JSON content a SARIF_PATH file
@@ -21,3 +22,17 @@ def get_location_snippet_text(location):
def get_location_relationships(location):
return location['relationships']
+
+def get_result_by_index(sarif, idx):
+ runs = sarif['runs']
+ run = runs[0]
+ results = run['results']
+ return results[idx]
+
+def get_xml_state(events, event_idx):
+ xml_src = events[event_idx]['properties']['gcc/diagnostic_event/xml_state']
+ if 0:
+ print(xml_src)
+ xml = ET.fromstring(xml_src)
+ assert xml.tag == 'state-diagram'
+ return xml
diff --git a/gcc/testsuite/lib/scanhtml.exp b/gcc/testsuite/lib/scanhtml.exp
new file mode 100644
index 0000000..6d8f398
--- /dev/null
+++ b/gcc/testsuite/lib/scanhtml.exp
@@ -0,0 +1,90 @@
+# Copyright (C) 2000-2025 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3. If not see
+# <http://www.gnu.org/licenses/>.
+
+# Various utilities for scanning HTML output, used by gcc-dg.exp and
+# g++-dg.exp.
+#
+# This is largely borrowed from scansarif.exp.
+
+proc html-pytest-format-line { args } {
+ global subdir
+
+ set testcase [lindex $args 0]
+ set pytest_script [lindex $args 1]
+ set output_line [lindex $args 2]
+
+ set index [string first "::" $output_line]
+ set test_output [string range $output_line [expr $index + 2] [string length $output_line]]
+
+ return "$subdir/$testcase ${pytest_script}::${test_output}"
+}
+
+# Call by dg-final to run a pytest Python script.
+# We pass filename of a test via HTML_PATH environment variable.
+
+proc run-html-pytest { args } {
+ global srcdir subdir
+ # Extract the test file name from the arguments.
+ set testcase [lindex $args 0]
+
+ verbose "Running HTML $testcase in $srcdir/$subdir" 2
+ set testcase [remote_download host $testcase]
+
+ set pytest_script [lindex $args 1]
+ if { ![check_effective_target_pytest3] } {
+ unsupported "$pytest_script pytest python3 is missing"
+ return
+ }
+
+ setenv HTML_PATH $testcase
+ set libdir "${srcdir}/lib"
+
+ # Set/prepend libdir to PYTHONPATH
+ if [info exists ::env(PYTHONPATH)] {
+ set old_PYTHONPATH $::env(PYTHONPATH)
+ setenv PYTHONPATH "${libdir}:${old_PYTHONPATH}"
+ } else {
+ setenv PYTHONPATH "${libdir}"
+ }
+
+ verbose "PYTHONPATH=[getenv PYTHONPATH]" 2
+
+ spawn -noecho python3 -m pytest --color=no -rap -s --tb=no $srcdir/$subdir/$pytest_script
+
+ if [info exists old_PYTHONPATH] {
+ setenv PYTHONPATH ${old_PYTHONPATH}
+ }
+
+ set prefix "\[^\r\n\]*"
+ expect {
+ -re "FAILED($prefix)\[^\r\n\]+\r\n" {
+ set output [html-pytest-format-line $testcase $pytest_script $expect_out(1,string)]
+ fail $output
+ exp_continue
+ }
+ -re "ERROR($prefix)\[^\r\n\]+\r\n" {
+ set output [html-pytest-format-line $testcase $pytest_script $expect_out(1,string)]
+ fail $output
+ exp_continue
+ }
+ -re "PASSED($prefix)\[^\r\n\]+\r\n" {
+ set output [html-pytest-format-line $testcase $pytest_script $expect_out(1,string)]
+ pass $output
+ exp_continue
+ }
+ }
+}
+
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 287e51b..25ceeea 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -759,7 +759,13 @@ proc check_effective_target_keeps_null_pointer_checks { } {
# this allows parallelism of 16 and higher of parallel gcc-auto-profile
proc profopt-perf-wrapper { } {
global srcdir
- return "$srcdir/../config/i386/gcc-auto-profile --all -m8 "
+ if { [check_effective_target_x86] } {
+ return "$srcdir/../config/i386/gcc-auto-profile -m8"
+ }
+ if { [istarget aarch64*-*-*] } {
+ return "$srcdir/../config/aarch64/gcc-auto-profile -m8"
+ }
+ return ""
}
# Return true if profiling is supported on the target.
@@ -778,8 +784,7 @@ proc check_profiling_available { test_what } {
}
if { $test_what == "-fauto-profile" } {
- if { !([check_effective_target_x86] && [istarget *-*-linux*]) } {
- verbose "autofdo only supported on linux"
+ if { !([check_effective_target_autofdo]) } {
return 0
}
# not cross compiling?
@@ -787,13 +792,14 @@ proc check_profiling_available { test_what } {
verbose "autofdo not supported for non native builds"
return 0
}
- set event [profopt-perf-wrapper]
- if {$event == "" } {
+ set wrapper [profopt-perf-wrapper]
+ if {$wrapper == "" } {
verbose "autofdo not supported"
return 0
}
+ puts $wrapper
global srcdir
- set status [remote_exec host "$srcdir/../config/i386/gcc-auto-profile" "-m8 true -v >/dev/null"]
+ set status [remote_exec host "$wrapper true -v >/dev/null"]
if { [lindex $status 0] != 0 } {
verbose "autofdo not supported because perf does not work"
return 0
@@ -1092,6 +1098,16 @@ proc check_effective_target_tls {} {
}]
}
+# Return 1 if we can link using TLS, 0 otherwise.
+
+proc check_effective_target_tls_link {} {
+ return [check_no_compiler_messages tls_link executable {
+ __thread int i;
+ int main (void) { return i; }
+ void g (int j) { i = j; }
+ }]
+}
+
# Return 1 if *native* thread local storage (TLS) is supported, 0 otherwise.
proc check_effective_target_tls_native {} {
@@ -1423,6 +1439,23 @@ proc check_effective_target_fpic { } {
return 0
}
+# Check if target supports autofdo.
+
+proc check_effective_target_autofdo { } {
+ if { !([istarget *-*-linux*]) } {
+ verbose "autofdo only supported on linux"
+ return 0
+ }
+ if { [check_effective_target_x86] } {
+ return 1
+ }
+ if { [istarget aarch64*-*-*] } {
+ return 1
+ }
+ return 0
+}
+
+
# On AArch64, if -fpic is not supported, then we will fall back to -fPIC
# silently. So, we can't rely on above "check_effective_target_fpic" as it
# assumes compiler will give warning if -fpic not supported. Here we check
@@ -6631,17 +6664,23 @@ proc add_options_for_arm_v8_1m_mve_fp { flags } {
proc check_effective_target_arm_v8_1a_neon_ok_nocache { } {
global et_arm_v8_1a_neon_flags
set et_arm_v8_1a_neon_flags ""
+ set cpu_unset ""
if { ![istarget arm*-*-*] && ![istarget aarch64*-*-*] } {
return 0;
}
+ if { [istarget arm*-*-*] } {
+ set cpu_unset "-mcpu=unset"
+ }
+
# Iterate through sets of options to find the compiler flags that
# need to be added to the -march option. Start with the empty set
# since AArch64 only needs the -march setting.
foreach flags {"" "-mfpu=neon-fp-armv8" "-mfloat-abi=softfp" \
"-mfpu=neon-fp-armv8 -mfloat-abi=softfp"} {
- foreach arches { "-mcpu=unset -march=armv8-a+rdma" "-mcpu=unset -march=armv8.1-a" } {
+ foreach arches [list "$cpu_unset -march=armv8-a+rdma" \
+ "$cpu_unset -march=armv8.1-a" ] {
if { [check_no_compiler_messages_nocache arm_v8_1a_neon_ok object {
#if !defined (__ARM_FEATURE_QRDMX)
#error "__ARM_FEATURE_QRDMX not defined"
@@ -6668,11 +6707,16 @@ proc check_effective_target_arm_v8_1a_neon_ok { } {
proc check_effective_target_arm_v8_2a_fp16_scalar_ok_nocache { } {
global et_arm_v8_2a_fp16_scalar_flags
set et_arm_v8_2a_fp16_scalar_flags ""
+ set cpu_unset ""
if { ![istarget arm*-*-*] && ![istarget aarch64*-*-*] } {
return 0;
}
+ if { [istarget arm*-*-*] } {
+ set cpu_unset "-mcpu=unset"
+ }
+
# Iterate through sets of options to find the compiler flags that
# need to be added to the -march option.
foreach flags {"" "-mfpu=fp-armv8" "-mfloat-abi=softfp" \
@@ -6682,8 +6726,8 @@ proc check_effective_target_arm_v8_2a_fp16_scalar_ok_nocache { } {
#if !defined (__ARM_FEATURE_FP16_SCALAR_ARITHMETIC)
#error "__ARM_FEATURE_FP16_SCALAR_ARITHMETIC not defined"
#endif
- } "$flags -mcpu=unset -march=armv8.2-a+fp16"] } {
- set et_arm_v8_2a_fp16_scalar_flags "$flags -mcpu=unset -march=armv8.2-a+fp16"
+ } "$flags $cpu_unset -march=armv8.2-a+fp16"] } {
+ set et_arm_v8_2a_fp16_scalar_flags "$flags $cpu_unset -march=armv8.2-a+fp16"
return 1
}
}
@@ -6703,11 +6747,16 @@ proc check_effective_target_arm_v8_2a_fp16_scalar_ok { } {
proc check_effective_target_arm_v8_2a_fp16_neon_ok_nocache { } {
global et_arm_v8_2a_fp16_neon_flags
set et_arm_v8_2a_fp16_neon_flags ""
+ set cpu_unset ""
if { ![istarget arm*-*-*] && ![istarget aarch64*-*-*] } {
return 0;
}
+ if { [istarget arm*-*-*] } {
+ set cpu_unset "-mcpu=unset"
+ }
+
# Iterate through sets of options to find the compiler flags that
# need to be added to the -march option.
foreach flags {"" "-mfpu=neon-fp-armv8" "-mfloat-abi=softfp" \
@@ -6717,8 +6766,8 @@ proc check_effective_target_arm_v8_2a_fp16_neon_ok_nocache { } {
#if !defined (__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)
#error "__ARM_FEATURE_FP16_VECTOR_ARITHMETIC not defined"
#endif
- } "$flags -mcpu=unset -march=armv8.2-a+fp16"] } {
- set et_arm_v8_2a_fp16_neon_flags "$flags -mcpu=unset -march=armv8.2-a+fp16"
+ } "$flags $cpu_unset -march=armv8.2-a+fp16"] } {
+ set et_arm_v8_2a_fp16_neon_flags "$flags $cpu_unset -march=armv8.2-a+fp16"
return 1
}
}
@@ -6738,11 +6787,16 @@ proc check_effective_target_arm_v8_2a_fp16_neon_ok { } {
proc check_effective_target_arm_v8_2a_dotprod_neon_ok_nocache { } {
global et_arm_v8_2a_dotprod_neon_flags
set et_arm_v8_2a_dotprod_neon_flags ""
+ set cpu_unset ""
if { ![istarget arm*-*-*] && ![istarget aarch64*-*-*] } {
return 0;
}
+ if { [istarget arm*-*-*] } {
+ set cpu_unset "-mcpu=unset"
+ }
+
# Iterate through sets of options to find the compiler flags that
# need to be added to the -march option.
foreach flags {"" "-mfloat-abi=softfp -mfpu=neon-fp-armv8" "-mfloat-abi=hard -mfpu=neon-fp-armv8"} {
@@ -6752,8 +6806,8 @@ proc check_effective_target_arm_v8_2a_dotprod_neon_ok_nocache { } {
#if !defined (__ARM_FEATURE_DOTPROD)
#error "__ARM_FEATURE_DOTPROD not defined"
#endif
- } "$flags -mcpu=unset -march=armv8.2-a+dotprod"] } {
- set et_arm_v8_2a_dotprod_neon_flags "$flags -mcpu=unset -march=armv8.2-a+dotprod"
+ } "$flags $cpu_unset -march=armv8.2-a+dotprod"] } {
+ set et_arm_v8_2a_dotprod_neon_flags "$flags $cpu_unset -march=armv8.2-a+dotprod"
return 1
}
}
@@ -6827,11 +6881,16 @@ proc add_options_for_arm_v8_2a_dotprod_neon { flags } {
proc check_effective_target_arm_v8_2a_i8mm_ok_nocache { } {
global et_arm_v8_2a_i8mm_flags
set et_arm_v8_2a_i8mm_flags ""
+ set cpu_unset ""
if { ![istarget arm*-*-*] && ![istarget aarch64*-*-*] } {
return 0;
}
+ if { [istarget arm*-*-*] } {
+ set cpu_unset "-mcpu=unset"
+ }
+
# Iterate through sets of options to find the compiler flags that
# need to be added to the -march option.
foreach flags {"" "-mfloat-abi=softfp -mfpu=neon-fp-armv8" "-mfloat-abi=hard -mfpu=neon-fp-armv8" } {
@@ -6841,8 +6900,8 @@ proc check_effective_target_arm_v8_2a_i8mm_ok_nocache { } {
#if !defined (__ARM_FEATURE_MATMUL_INT8)
#error "__ARM_FEATURE_MATMUL_INT8 not defined"
#endif
- } "$flags -mcpu=unset -march=armv8.2-a+i8mm"] } {
- set et_arm_v8_2a_i8mm_flags "$flags -mcpu=unset -march=armv8.2-a+i8mm"
+ } "$flags $cpu_unset -march=armv8.2-a+i8mm"] } {
+ set et_arm_v8_2a_i8mm_flags "$flags $cpu_unset -march=armv8.2-a+i8mm"
return 1
}
}
@@ -6914,19 +6973,24 @@ proc add_options_for_arm_fp16fml_neon { flags } {
proc check_effective_target_arm_v8_2a_bf16_neon_ok_nocache { } {
global et_arm_v8_2a_bf16_neon_flags
set et_arm_v8_2a_bf16_neon_flags ""
+ set cpu_unset ""
if { ![istarget arm*-*-*] && ![istarget aarch64*-*-*] } {
return 0;
}
+ if { [istarget arm*-*-*] } {
+ set cpu_unset "-mcpu=unset"
+ }
+
foreach flags {"" "-mfloat-abi=softfp -mfpu=neon-fp-armv8" "-mfloat-abi=hard -mfpu=neon-fp-armv8" } {
if { [check_no_compiler_messages_nocache arm_v8_2a_bf16_neon_ok object {
#include <arm_neon.h>
#if !defined (__ARM_FEATURE_BF16_VECTOR_ARITHMETIC)
#error "__ARM_FEATURE_BF16_VECTOR_ARITHMETIC not defined"
#endif
- } "$flags -mcpu=unset -march=armv8.2-a+bf16"] } {
- set et_arm_v8_2a_bf16_neon_flags "$flags -mcpu=unset -march=armv8.2-a+bf16"
+ } "$flags $cpu_unset -march=armv8.2-a+bf16"] } {
+ set et_arm_v8_2a_bf16_neon_flags "$flags $cpu_unset -march=armv8.2-a+bf16"
return 1
}
}
@@ -7436,19 +7500,6 @@ proc check_effective_target_arm_softfloat { } {
}]
}
-# Return 1 if this is an ARM target supporting -mcpu=iwmmxt.
-# Some multilibs may be incompatible with this option.
-
-proc check_effective_target_arm_iwmmxt_ok { } {
- if { [check_effective_target_arm32] } {
- return [check_no_compiler_messages arm_iwmmxt_ok object {
- int dummy;
- } "-mcpu=iwmmxt"]
- } else {
- return 0
- }
-}
-
# Return true if LDRD/STRD instructions are prefered over LDM/STM instructions
# for an ARM target.
proc check_effective_target_arm_prefer_ldrd_strd { } {
@@ -10145,6 +10196,7 @@ proc check_effective_target_sync_int_long { } {
|| ([istarget arc*-*-*] && [check_effective_target_arc_atomic])
|| [check_effective_target_mips_llsc]
|| [istarget nvptx*-*-*]
+ || ([istarget xtensa*-*-*] && [check_effective_target_xtensa_atomic])
}}]
}
@@ -10182,7 +10234,9 @@ proc check_effective_target_sync_char_short { } {
|| ([istarget riscv*-*-*]
&& ([check_effective_target_riscv_zalrsc]
|| [check_effective_target_riscv_zabha]))
- || [check_effective_target_mips_llsc] }}]
+ || [check_effective_target_mips_llsc]
+ || ([istarget xtensa*-*-*] && [check_effective_target_xtensa_atomic])
+ }}]
}
# Return 1 if thread_fence does not rely on __sync_synchronize
@@ -12388,6 +12442,21 @@ proc check_effective_target_aarch64_tiny { } {
}
}
+# Return 1 if Gas supports AEABI build attributes on AArch64 target
+proc check_effective_target_aarch64_gas_has_build_attributes { } {
+ if { ![istarget aarch64*-*-*] } {
+ return 0
+ }
+
+ return [check_no_compiler_messages aarch64_gas_has_build_attributes object {
+ /* Assembly */
+ .aeabi_subsection aeabi_feature_and_bits, optional, ULEB128
+ .aeabi_attribute Tag_Feature_BTI, 1
+ .aeabi_attribute Tag_Feature_PAC, 1
+ .aeabi_attribute Tag_Feature_GCS, 1
+ }]
+}
+
# Create functions to check that the AArch64 assembler supports the
# various architecture extensions via the .arch_extension pseudo-op.
@@ -13414,11 +13483,16 @@ proc check_effective_target_inff { } {
proc check_effective_target_arm_v8_3a_complex_neon_ok_nocache { } {
global et_arm_v8_3a_complex_neon_flags
set et_arm_v8_3a_complex_neon_flags ""
+ set cpu_unset ""
if { ![istarget arm*-*-*] && ![istarget aarch64*-*-*] } {
return 0;
}
+ if { [istarget arm*-*-*] } {
+ set cpu_unset "-mcpu=unset"
+ }
+
# Iterate through sets of options to find the compiler flags that
# need to be added to the -march option.
foreach flags {"" "-mfloat-abi=softfp -mfpu=auto" "-mfloat-abi=hard -mfpu=auto"} {
@@ -13427,8 +13501,8 @@ proc check_effective_target_arm_v8_3a_complex_neon_ok_nocache { } {
#if !defined (__ARM_FEATURE_COMPLEX)
#error "__ARM_FEATURE_COMPLEX not defined"
#endif
- } "$flags -mcpu=unset -march=armv8.3-a"] } {
- set et_arm_v8_3a_complex_neon_flags "$flags -mcpu=unset -march=armv8.3-a"
+ } "$flags $cpu_unset -march=armv8.3-a"] } {
+ set et_arm_v8_3a_complex_neon_flags "$flags $cpu_unset -march=armv8.3-a"
return 1;
}
}
@@ -13456,11 +13530,16 @@ proc add_options_for_arm_v8_3a_complex_neon { flags } {
proc check_effective_target_arm_v8_3a_fp16_complex_neon_ok_nocache { } {
global et_arm_v8_3a_fp16_complex_neon_flags
set et_arm_v8_3a_fp16_complex_neon_flags ""
+ set cpu_unset ""
if { ![istarget arm*-*-*] && ![istarget aarch64*-*-*] } {
return 0;
}
+ if { [istarget arm*-*-*] } {
+ set cpu_unset "-mcpu=unset"
+ }
+
# Iterate through sets of options to find the compiler flags that
# need to be added to the -march option.
foreach flags {"" "-mfloat-abi=softfp -mfpu=auto" "-mfloat-abi=hard -mfpu=auto"} {
@@ -13469,9 +13548,9 @@ proc check_effective_target_arm_v8_3a_fp16_complex_neon_ok_nocache { } {
#if !defined (__ARM_FEATURE_COMPLEX)
#error "__ARM_FEATURE_COMPLEX not defined"
#endif
- } "$flags -mcpu=unset -march=armv8.3-a+fp16"] } {
+ } "$flags $cpu_unset -march=armv8.3-a+fp16"] } {
set et_arm_v8_3a_fp16_complex_neon_flags \
- "$flags -mcpu=unset -march=armv8.3-a+fp16"
+ "$flags $cpu_unset -march=armv8.3-a+fp16"
return 1;
}
}
@@ -14407,3 +14486,26 @@ proc check_effective_target_speculation_barrier_defined { } {
}
}]
}
+
+# Return 1 if this is a compiler supporting Xtensa atomic operations
+proc check_effective_target_xtensa_atomic { } {
+ return [check_no_compiler_messages xtensa_atomic assembly {
+ #if __XCHAL_HAVE_S32C1I != 1 && __XCHAL_HAVE_EXCLUSIVE != 1
+ #error FOO
+ #endif
+ }]
+}
+
+# Return 1 if pi-based trigonometry function is foldable
+# We should remove this after bumping the minimum mpfr version to 4.2.0.
+proc check_effective_target_foldable_pi_based_trigonometry { } {
+ return [check_runtime foldable_pi_based_trigonometry {
+ int
+ main ()
+ {
+ if (!__builtin_constant_p (__builtin_acospi (0.5)))
+ __builtin_abort ();
+ return 0;
+ }
+ }]
+}