diff options
Diffstat (limited to 'gcc/testsuite/lib')
-rw-r--r-- | gcc/testsuite/lib/htmltest.py | 89 | ||||
-rw-r--r-- | gcc/testsuite/lib/sarif.py | 15 | ||||
-rw-r--r-- | gcc/testsuite/lib/target-supports.exp | 159 |
3 files changed, 236 insertions, 27 deletions
diff --git a/gcc/testsuite/lib/htmltest.py b/gcc/testsuite/lib/htmltest.py index b249ea6..35f524c 100644 --- a/gcc/testsuite/lib/htmltest.py +++ b/gcc/testsuite/lib/htmltest.py @@ -7,3 +7,92 @@ def html_tree_from_env(): 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/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index e0495d8..956bc0b 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 } } @@ -12378,15 +12442,32 @@ 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. -foreach { aarch64_ext } { "fp" "simd" "crypto" "crc" "lse" "dotprod" "sve" - "i8mm" "f32mm" "f64mm" "bf16" "sb" "sve2" "ls64" - "lut" "sme" "sme-i16i64" "sme2" "sve-b16b16" - "sme-b16b16" "sme-f16f16" "sme2p1" "fp8" "fp8fma" - "ssve-fp8fma" "fp8dot2" "ssve-fp8dot2" "fp8dot4" - "ssve-fp8dot4"} { +set exts { + "bf16" "cmpbr" "crc" "crypto" "dotprod" "f32mm" "f64mm" "fp" "fp8" + "fp8dot2" "fp8dot4" "fp8fma" "i8mm" "ls64" "lse" "lut" "sb" "simd" + "sme-b16b16" "sme-f16f16" "sme-i16i64" "sme" "sme2" "sme2p1" "ssve-fp8dot2" + "ssve-fp8dot4" "ssve-fp8fma" "sve-b16b16" "sve" "sve2" +} + +foreach { aarch64_ext } $exts { eval [string map [list FUNC $aarch64_ext] { proc check_effective_target_aarch64_asm_FUNC_ok { } { if { [istarget aarch64*-*-*] } { @@ -13404,11 +13485,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"} { @@ -13417,8 +13503,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; } } @@ -13446,11 +13532,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"} { @@ -13459,9 +13550,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; } } @@ -14406,3 +14497,17 @@ proc check_effective_target_xtensa_atomic { } { #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; + } + }] +} |