diff options
Diffstat (limited to 'gcc/testsuite/lib/target-supports.exp')
-rw-r--r-- | gcc/testsuite/lib/target-supports.exp | 319 |
1 files changed, 276 insertions, 43 deletions
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 287e51b..7435519 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 @@ -1011,6 +1017,18 @@ proc check_effective_target_label_values {} { return 1 } + +# Return 1 if builtin_trap expands not into a call but an instruction, +# 0 otherwise. +proc check_effective_target_trap { } { + return [check_no_messages_and_pattern trap "!\\(call" rtl-expand { + void foo () + { + return __builtin_trap (); + } + } "" ] +} + # Return 1 if builtin_return_address and builtin_frame_address are # supported, 0 otherwise. @@ -1092,6 +1110,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 +1451,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 @@ -2395,7 +2440,7 @@ proc check_effective_target_riscv_v_misalign_ok { } { = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; asm ("vsetivli zero,7,e8,m1,ta,ma"); asm ("addi a7,%0,1" : : "r" (a) : "a7" ); - asm ("vle8.v v8,0(a7)" : : : "v8"); + asm ("vle16.v v8,0(a7)" : : : "v8"); return 0; } } "-march=${gcc_march}"] } { return 1 } @@ -2652,6 +2697,14 @@ proc remove_options_for_riscv_zvbb { flags } { return [add_options_for_riscv_z_ext zvbb $flags] } +proc add_options_for_riscv_zvfh { flags } { + return [add_options_for_riscv_z_ext zvfh $flags] +} + +proc remove_options_for_riscv_zvfh { flags } { + return [add_options_for_riscv_z_ext zvfh $flags] +} + # Return 1 if the target is ia32 or x86_64. proc check_effective_target_x86 { } { @@ -5767,6 +5820,13 @@ proc add_options_for_aarch64_sve { flags } { return "$flags -march=armv8.2-a+sve" } +proc add_options_for_aarch64_sme { flags } { + if { ![istarget aarch64*-*-*] || [check_effective_target_aarch64_sme] } { + return "$flags" + } + return "$flags -march=armv9-a+sme" +} + # Return 1 if this is an ARM target supporting the FP16 alternative # format. Some multilibs may be incompatible with the options needed. Also # set et_arm_fp16_alternative_flags to the best options to add. @@ -6458,6 +6518,23 @@ proc check_effective_target_aarch64_sve2_hw { } { }] } +# Return true if this is an AArch64 target that can run SVE2.1 code. + +proc check_effective_target_aarch64_sve2p1_hw { } { + if { ![istarget aarch64*-*-*] } { + return 0 + } + return [check_runtime aarch64_sve2p1_hw_available { + #pragma GCC target "+sve2p1" + int + main (void) + { + asm volatile ("dupq z0.b, z0.b[0]"); + return 0; + } + }] +} + # Return true if this is an AArch64 target that can run SVE code and # if its SVE vectors have exactly BITS bits. @@ -6489,6 +6566,22 @@ foreach N { 128 256 512 1024 2048 } { }] } +# Return true if this is an AArch64 target that can run SME code. + +proc check_effective_target_aarch64_sme_hw { } { + if { ![istarget aarch64*-*-*] } { + return 0 + } + return [check_runtime aarch64_sme_hw_available { + int + main (void) + { + asm volatile ("rdsvl x0, #1"); + return 0; + } + } [add_options_for_aarch64_sme ""]] +} + proc check_effective_target_arm_neonv2_hw { } { return [check_runtime arm_neon_hwv2_available { #include "arm_neon.h" @@ -6631,17 +6724,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 +6767,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 +6786,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 +6807,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 +6826,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 +6847,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 +6866,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 +6941,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 +6960,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 +7033,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 +7560,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 { } { @@ -9893,7 +10004,8 @@ proc check_effective_target_vect_logical_reduc { } { || [istarget amdgcn-*-*] || [check_effective_target_riscv_v] || [check_effective_target_loongarch_sx] - || [check_effective_target_x86]}] + || [check_effective_target_x86] + || [check_effective_target_s390_vx]}] } # Return 1 if the target supports the fold_extract_last optab. @@ -10145,6 +10257,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 +10295,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,15 +12503,38 @@ 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" "faminmax" + "fp" "fp8" "fp8dot2" "fp8dot4" "fp8fma" "i8mm" "ls64" "lse" "lut" + "sb" "simd" "sve-b16b16" "sve" "sve2" +} + +# We don't support SME without SVE2, so we'll use armv9 as the base +# archiecture for SME and the features that require it. +set exts_sve2 { + "sme-b16b16" "sme-f16f16" "sme-i16i64" "sme" "sme2" "sme2p1" + "ssve-fp8dot2" "ssve-fp8dot4" "ssve-fp8fma" +} + +foreach { aarch64_ext } $exts { eval [string map [list FUNC $aarch64_ext] { proc check_effective_target_aarch64_asm_FUNC_ok { } { if { [istarget aarch64*-*-*] } { @@ -12410,6 +12548,20 @@ foreach { aarch64_ext } { "fp" "simd" "crypto" "crc" "lse" "dotprod" "sve" }] } +foreach { aarch64_ext } $exts_sve2 { + eval [string map [list FUNC $aarch64_ext] { + proc check_effective_target_aarch64_asm_FUNC_ok { } { + if { [istarget aarch64*-*-*] } { + return [check_no_compiler_messages aarch64_FUNC_assembler object { + __asm__ (".arch_extension FUNC"); + } "-march=armv9-a+FUNC"] + } else { + return 0 + } + } + }] +} + proc check_effective_target_aarch64_asm_sve2p1_ok { } { if { [istarget aarch64*-*-*] } { return [check_no_compiler_messages aarch64_sve2p1_assembler object { @@ -13414,11 +13566,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 +13584,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 +13613,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 +13631,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 +14569,74 @@ 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; + } + }] +} +# +# Return 1 if the x86-64 target enables -mfentry by default, 0 +# otherwise. Cache the result. + +proc check_effective_target_fentry { } { + global tool + global GCC_UNDER_TEST + + if { ![check_effective_target_x86] } { + return 0 + } + + # Need auto-host.h to check linker support. + if { ![file exists ../../auto-host.h ] } { + return 0 + } + + return [check_cached_effective_target fentry { + # Set up and compile to see if ENABLE_X86_64_MFENTRY is + # non-zero. Include the current process ID in the file + # names to prevent conflicts with invocations for multiple + # testsuites. + + set src pie[pid].c + set obj pie[pid].o + + set f [open $src "w"] + puts $f "#include \"../../auto-host.h\"" + puts $f "#if ENABLE_X86_64_MFENTRY == 0 || !defined __x86_64__" + puts $f "# error -mfentry is not enabled by default." + puts $f "#endif" + close $f + + verbose "check_effective_target_fentry compiling testfile $src" 2 + set lines [${tool}_target_compile $src $obj object ""] + + file delete $src + file delete $obj + + if [string match "" $lines] then { + verbose "check_effective_target_fentry testfile compilation passed" 2 + return 1 + } else { + verbose "check_effective_target_fentry testfile compilation failed" 2 + return 0 + } + }] +} |