Check avx2_available in check_avx2_available
[gcc.git] / gcc / testsuite / lib / target-supports.exp
index 76c393d85c91318e90d032ebdd82bb461764129d..90efaea804d34d480ad752ff07faaf85f71fd51b 100644 (file)
@@ -1,4 +1,4 @@
-#   Copyright (C) 1999-2018 Free Software Foundation, Inc.
+#   Copyright (C) 1999-2019 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
@@ -31,6 +31,7 @@
 # Assume by default that CONTENTS is C code.  
 # Otherwise, code should contain:
 # "// C++" for c++,
+# "// D" for D,
 # "! Fortran" for Fortran code,
 # "/* ObjC", for ObjC
 # "// ObjC++" for ObjC++
@@ -58,6 +59,7 @@ proc check_compile {basename type contents args} {
     switch -glob -- $contents {
        "*! Fortran*" { set src ${basename}[pid].f90 }
        "*// C++*" { set src ${basename}[pid].cc }
+       "*// D*" { set src ${basename}[pid].d }
        "*// ObjC++*" { set src ${basename}[pid].mm }
        "*/* ObjC*" { set src ${basename}[pid].m }
        "*// Go*" { set src ${basename}[pid].go }
@@ -314,6 +316,12 @@ proc check_weak_available { } {
        return 1
     }
 
+    # pdp11 doesn't support it
+
+    if { [istarget pdp11*-*-*] } {
+       return 0
+    }
+
     # ELF and ECOFF support it. a.out does with gas/gld but may also with
     # other linkers, so we should try it
 
@@ -333,6 +341,9 @@ proc check_weak_available { } {
 # return 1 if weak undefined symbols are supported.
 
 proc check_effective_target_weak_undefined { } {
+    if { [istarget hppa*-*-hpux*] } {
+       return 0
+    }
     return [check_runtime weak_undefined {
        extern void foo () __attribute__((weak));
        int main (void) { if (foo) return 1; return 0; }
@@ -651,6 +662,7 @@ proc check_profiling_available { test_what } {
        # missing other needed machinery.
        if {[istarget aarch64*-*-elf]
             || [istarget am3*-*-linux*]
+            || [istarget amdgcn-*-*]
             || [istarget arm*-*-eabi*]
             || [istarget arm*-*-elf]
             || [istarget arm*-*-symbianelf*]
@@ -776,6 +788,9 @@ proc check_effective_target_global_constructor {} {
     if { [istarget nvptx-*-*] } {
        return 0
     }
+    if { [istarget amdgcn-*-*] } {
+       return 0
+    }
     return 1
 }
 
@@ -796,6 +811,10 @@ proc check_effective_target_return_address {} {
     if { [istarget nvptx-*-*] } {
        return 0
     }
+    # It could be supported on amdgcn, but isn't yet.
+    if { [istarget amdgcn*-*-*] } {
+       return 0
+    }
     return 1
 }
 
@@ -937,9 +956,10 @@ proc check_effective_target_fgraphite {} {
 # code, 0 otherwise.
 
 proc check_effective_target_fopenacc {} {
-    # nvptx can be built with the device-side bits of openacc, but it
+    # nvptx/amdgcn can be built with the device-side bits of openacc, but it
     # does not make sense to test it as an openacc host.
     if [istarget nvptx-*-*] { return 0 }
+    if [istarget amdgcn-*-*] { return 0 }
 
     return [check_no_compiler_messages fopenacc object {
        void foo (void) { }
@@ -950,9 +970,10 @@ proc check_effective_target_fopenacc {} {
 # code, 0 otherwise.
 
 proc check_effective_target_fopenmp {} {
-    # nvptx can be built with the device-side bits of libgomp, but it
+    # nvptx/amdgcn can be built with the device-side bits of libgomp, but it
     # does not make sense to test it as an openmp host.
     if [istarget nvptx-*-*] { return 0 }
+    if [istarget amdgcn-*-*] { return 0 }
 
     return [check_no_compiler_messages fopenmp object {
        void foo (void) { }
@@ -1086,7 +1107,7 @@ proc check_effective_target_freorder {} {
     } "-freorder-blocks-and-partition"]
     && [check_no_compiler_messages fprofile_use_freorder object {
        void foo (void) { }
-    } "-fprofile-use -freorder-blocks-and-partition"] } {
+    } "-fprofile-use -freorder-blocks-and-partition -Wno-missing-profile"] } {
        return 1
     }
     return 0
@@ -1168,7 +1189,8 @@ proc check_effective_target_pie { } {
         || [istarget *-*-dragonfly*]
         || [istarget *-*-freebsd*]
         || [istarget *-*-linux*]
-        || [istarget *-*-gnu*] } {
+        || [istarget *-*-gnu*]
+        || [istarget *-*-amdhsa]} {
        return 1;
     }
     if { [istarget *-*-solaris2.1\[1-9\]*] } {
@@ -2600,9 +2622,21 @@ proc check_effective_target_ptr32plus { } {
     }]
 }
 
-# Return 1 if we support 32-bit or larger array and structure sizes
-# using default options, 0 otherwise.  Avoid false positive on
-# targets with 20 or 24 bit address spaces.
+# Return 1 if we support 16-bit or larger array and structure sizes
+# using default options, 0 otherwise.
+# This implies at least a 20-bit address space, as no targets have an address
+# space between 16 and 20 bits.
+
+proc check_effective_target_size20plus { } {
+    return [check_no_compiler_messages size20plus object {
+       char dummy[65537L];
+    }]
+}
+
+# Return 1 if we support 24-bit or larger array and structure sizes
+# using default options, 0 otherwise.
+# This implies at least a 32-bit address space, as no targets have an address
+# space between 24 and 32 bits.
 
 proc check_effective_target_size32plus { } {
     return [check_no_compiler_messages size32plus object {
@@ -2651,6 +2685,29 @@ proc check_effective_target_long_neq_int { } {
     }]
 }
 
+# Return 1 if int size is equal to float size,
+# 0 otherwise.
+
+proc check_effective_target_int_eq_float { } {
+    return [check_no_compiler_messages int_eq_float object {
+       int dummy[sizeof (int) >= sizeof (float) ? 1 : -1];
+    }]
+}
+
+# Return 1 if pointer size is equal to long size,
+# 0 otherwise.
+
+proc check_effective_target_ptr_eq_long { } {
+    # sizeof (void *) == 4 for msp430-elf -mlarge which is equal to
+    # sizeof (long). Avoid false positive.
+    if { [istarget msp430-*-*] } {
+       return 0
+    }
+    return [check_no_compiler_messages ptr_eq_long object {
+       int dummy[sizeof (void *) == sizeof (long) ? 1 : -1];
+    }]
+}
+
 # Return 1 if the target supports long double larger than double,
 # 0 otherwise.
 
@@ -3078,6 +3135,7 @@ proc check_effective_target_vect_int { } {
          [istarget i?86-*-*] || [istarget x86_64-*-*]
          || ([istarget powerpc*-*-*]
             && ![istarget powerpc-*-linux*paired*])
+        || [istarget amdgcn-*-*]
         || [istarget spu-*-*]
         || [istarget sparc*-*-*]
         || [istarget alpha*-*-*]
@@ -3102,7 +3160,8 @@ proc check_effective_target_vect_intfloat_cvt { } {
                 && ![istarget powerpc-*-linux*paired*])
             || [is-effective-target arm_neon]
             || ([istarget mips*-*-*]
-                && [et-is-effective-target mips_msa]) }}]
+                && [et-is-effective-target mips_msa])
+            || [istarget amdgcn-*-*] }}]
 }
 
 # Return 1 if the target supports signed double->int conversion
@@ -3166,7 +3225,8 @@ proc check_effective_target_vect_uintfloat_cvt { } {
             || [istarget aarch64*-*-*]
             || [is-effective-target arm_neon]
             || ([istarget mips*-*-*]
-                && [et-is-effective-target mips_msa]) }}]
+                && [et-is-effective-target mips_msa])
+            || [istarget amdgcn-*-*] }}]
 }
 
 
@@ -3180,7 +3240,8 @@ proc check_effective_target_vect_floatint_cvt { } {
                 && ![istarget powerpc-*-linux*paired*])
             || [is-effective-target arm_neon]
             || ([istarget mips*-*-*]
-                && [et-is-effective-target mips_msa]) }}]
+                && [et-is-effective-target mips_msa])
+            || [istarget amdgcn-*-*] }}]
 }
 
 # Return 1 if the target supports unsigned float->int conversion
@@ -3192,7 +3253,8 @@ proc check_effective_target_vect_floatuint_cvt { } {
              && ![istarget powerpc-*-linux*paired*])
            || [is-effective-target arm_neon]
            || ([istarget mips*-*-*]
-               && [et-is-effective-target mips_msa]) }}]
+               && [et-is-effective-target mips_msa])
+           || [istarget amdgcn-*-*] }}]
 }
 
 # Return 1 if peeling for alignment might be profitable on the target
@@ -3216,7 +3278,8 @@ proc check_effective_target_vect_simd_clones { } {
     # be able to assemble avx512f.
     return [check_cached_effective_target_indexed vect_simd_clones {
       expr { (([istarget i?86-*-*] || [istarget x86_64-*-*])
-             && [check_effective_target_avx512f]) }}]
+             && [check_effective_target_avx512f])
+            || [istarget amdgcn-*-*] }}]
 }
 
 # Return 1 if this is a AArch64 target supporting big endian
@@ -3725,6 +3788,43 @@ proc check_effective_target_arm_neon_fp16_ok { } {
                check_effective_target_arm_neon_fp16_ok_nocache]
 }
 
+# Return 1 if this is an ARM target supporting -mfpu=neon-fp16
+# and -mfloat-abi=softfp together.  Some multilibs may be
+# incompatible with these options.  Also set et_arm_neon_softfp_fp16_flags to
+# the best options to add.
+
+proc check_effective_target_arm_neon_softfp_fp16_ok_nocache { } {
+    global et_arm_neon_softfp_fp16_flags
+    global et_arm_neon_flags
+    set et_arm_neon_softfp_fp16_flags ""
+    if { [check_effective_target_arm32]
+        && [check_effective_target_arm_neon_ok] } {
+       foreach flags {"-mfpu=neon-fp16 -mfloat-abi=softfp"
+                      "-mfpu=neon-fp16 -mfloat-abi=softfp -mfp16-format=ieee"} {
+           if { [check_no_compiler_messages_nocache arm_neon_softfp_fp16_ok object {
+               #include "arm_neon.h"
+               float16x4_t
+               foo (float32x4_t arg)
+               {
+                  return vcvt_f16_f32 (arg);
+               }
+           } "$et_arm_neon_flags $flags"] } {
+               set et_arm_neon_softfp_fp16_flags [concat $et_arm_neon_flags $flags]
+               return 1
+           }
+       }
+    }
+
+    return 0
+}
+
+proc check_effective_target_arm_neon_softfp_fp16_ok { } {
+    return [check_cached_effective_target arm_neon_softfp_fp16_ok \
+               check_effective_target_arm_neon_softfp_fp16_ok_nocache]
+}
+
+
+
 proc check_effective_target_arm_neon_fp16_hw { } {
     if {! [check_effective_target_arm_neon_fp16_ok] } {
        return 0
@@ -3748,6 +3848,14 @@ proc add_options_for_arm_neon_fp16 { flags } {
     return "$flags $et_arm_neon_fp16_flags"
 }
 
+proc add_options_for_arm_neon_softfp_fp16 { flags } {
+    if { ! [check_effective_target_arm_neon_softfp_fp16_ok] } {
+       return "$flags"
+    }
+    global et_arm_neon_softfp_fp16_flags
+    return "$flags $et_arm_neon_softfp_fp16_flags"
+}
+
 # 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_neon_fp16_flags to the best options to add.
@@ -4270,6 +4378,27 @@ proc check_effective_target_arm_neonv2_hw { } {
     } [add_options_for_arm_neonv2 ""]]
 }
 
+# ID_AA64PFR1_EL1.BT using bits[3:0] == 1 implies BTI implimented.
+proc check_effective_target_aarch64_bti_hw { } {
+    if { ![istarget aarch64*-*-*] } {
+       return 0
+    }
+    return [check_runtime aarch64_bti_hw_available {
+       int
+       main (void)
+       {
+         int a;
+         asm volatile ("mrs %0, id_aa64pfr1_el1" : "=r" (a));
+         return !((a & 0xf) == 1);
+       }
+    } "-O2" ]
+}
+
+# Return 1 if GCC was configured with --enable-standard-branch-protection
+proc check_effective_target_default_branch_protection { } {
+    return [check_configured_with "enable-standard-branch-protection"]
+}
+
 # Return 1 if the target supports the ARMv8.1 Adv.SIMD extension, 0
 # otherwise.  The test is valid for AArch64 and ARM.  Record the command
 # line options needed.
@@ -4394,6 +4523,7 @@ proc check_effective_target_arm_v8_2a_dotprod_neon_ok_nocache { } {
     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_dotprod_neon_ok object {
+           #include <stdint.h>
             #if !defined (__ARM_FEATURE_DOTPROD)
             #error "__ARM_FEATURE_DOTPROD not defined"
             #endif
@@ -4440,7 +4570,7 @@ proc check_effective_target_arm_fp16fml_neon_ok_nocache { } {
                float32x2_t
                foo (float32x2_t r, float16x4_t a, float16x4_t b)
                {
-                 return vfmlal_high_u32 (r, a, b);
+                 return vfmlal_high_f16 (r, a, b);
                }
         } "$flags -march=armv8.2-a+fp16fml"] } {
             set et_arm_fp16fml_neon_flags "$flags -march=armv8.2-a+fp16fml"
@@ -4836,6 +4966,26 @@ proc check_effective_target_arm_prefer_ldrd_strd { } {
     }  "-O2 -mthumb" ]
 }
 
+# Return true if LDRD/STRD instructions are available on this target.
+proc check_effective_target_arm_ldrd_strd_ok { } {
+    if { ![check_effective_target_arm32] } {
+      return 0;
+    }
+
+    return [check_no_compiler_messages arm_ldrd_strd_ok object {
+      int main(void)
+      {
+        __UINT64_TYPE__ a = 1, b = 10;
+        __UINT64_TYPE__ *c = &b;
+        // `a` will be in a valid register since it's a DImode quantity.
+        asm ("ldrd %0, %1"
+             : "=r" (a)
+             : "m" (c));
+        return a == 10;
+      }
+    }]
+}
+
 # Return 1 if this is a PowerPC target supporting -meabi.
 
 proc check_effective_target_powerpc_eabi_ok { } {
@@ -5326,7 +5476,17 @@ proc check_effective_target_vect_shift { } {
                 && ([et-is-effective-target mips_msa]
                     || [et-is-effective-target mips_loongson_mmi]))
             || ([istarget s390*-*-*]
-                && [check_effective_target_s390_vx]) }}]
+                && [check_effective_target_s390_vx])
+            || [istarget amdgcn-*-*] }}]
+}
+
+# Return 1 if the target supports hardware vector shift by register operation.
+
+proc check_effective_target_vect_var_shift { } {
+    return [check_cached_effective_target_indexed vect_var_shift {
+      expr {(([istarget i?86-*-*] || [istarget x86_64-*-*])
+            && [check_avx2_available])
+      }}]
 }
 
 proc check_effective_target_whole_vector_shift { } {
@@ -5339,7 +5499,8 @@ proc check_effective_target_whole_vector_shift { } {
         || ([istarget mips*-*-*]
             && [et-is-effective-target mips_loongson_mmi])
         || ([istarget s390*-*-*]
-            && [check_effective_target_s390_vx]) } {
+            && [check_effective_target_s390_vx])
+        || [istarget amdgcn-*-*] } {
        set answer 1
     } else {
        set answer 0
@@ -5353,7 +5514,9 @@ proc check_effective_target_whole_vector_shift { } {
 
 proc check_effective_target_vect_bswap { } {
     return [check_cached_effective_target_indexed vect_bswap {
-      expr { [istarget aarch64*-*-*] || [is-effective-target arm_neon] }}]
+      expr { [istarget aarch64*-*-*]
+            || [is-effective-target arm_neon]
+            || [istarget amdgcn-*-*] }}]
 }
 
 # Return 1 if the target supports hardware vector shift operation for char.
@@ -5366,7 +5529,8 @@ proc check_effective_target_vect_shift_char { } {
             || ([istarget mips*-*-*]
                 && [et-is-effective-target mips_msa])
             || ([istarget s390*-*-*]
-                && [check_effective_target_s390_vx]) }}]
+                && [check_effective_target_s390_vx])
+            || [istarget amdgcn-*-*] }}]
 }
 
 # Return 1 if the target supports hardware vectors of long, 0 otherwise.
@@ -5384,7 +5548,8 @@ proc check_effective_target_vect_long { } {
         || ([istarget mips*-*-*]
              && [et-is-effective-target mips_msa])
         || ([istarget s390*-*-*]
-            && [check_effective_target_s390_vx]) } {
+            && [check_effective_target_s390_vx])
+        || [istarget amdgcn-*-*] } {
        set answer 1
     } else {
        set answer 0
@@ -5412,7 +5577,8 @@ proc check_effective_target_vect_float { } {
                 && [et-is-effective-target mips_msa])
             || [is-effective-target arm_neon]
             || ([istarget s390*-*-*]
-                && [check_effective_target_s390_vxe]) }}]
+                && [check_effective_target_s390_vxe])
+            || [istarget amdgcn-*-*] }}]
 }
 
 # Return 1 if the target supports hardware vectors of float without
@@ -5441,7 +5607,8 @@ proc check_effective_target_vect_double { } {
             || ([istarget mips*-*-*]
                 && [et-is-effective-target mips_msa])
             || ([istarget s390*-*-*]
-                && [check_effective_target_s390_vx])} }]
+                && [check_effective_target_s390_vx])
+            || [istarget amdgcn-*-*]} }]
 }
 
 # Return 1 if the target supports conditional addition, subtraction,
@@ -5516,7 +5683,8 @@ proc check_effective_target_vect_perm { } {
                 && ([et-is-effective-target mpaired_single]
                     || [et-is-effective-target mips_msa]))
             || ([istarget s390*-*-*]
-                && [check_effective_target_s390_vx]) }}]
+                && [check_effective_target_s390_vx])
+            || [istarget amdgcn-*-*] }}]
 }
 
 # Return 1 if, for some VF:
@@ -5609,7 +5777,8 @@ proc check_effective_target_vect_perm_byte { } {
             || ([istarget mips-*.*]
                 && [et-is-effective-target mips_msa])
             || ([istarget s390*-*-*]
-                && [check_effective_target_s390_vx]) }}]
+                && [check_effective_target_s390_vx])
+            || [istarget amdgcn-*-*] }}]
 }
 
 # Return 1 if the target supports SLP permutation of 3 vectors when each
@@ -5638,7 +5807,8 @@ proc check_effective_target_vect_perm_short { } {
             || ([istarget mips*-*-*]
                  && [et-is-effective-target mips_msa])
             || ([istarget s390*-*-*]
-                && [check_effective_target_s390_vx]) }}]
+                && [check_effective_target_s390_vx])
+            || [istarget amdgcn-*-*] }}]
 }
 
 # Return 1 if the target supports SLP permutation of 3 vectors when each
@@ -5656,7 +5826,8 @@ proc check_effective_target_vect_perm3_short { } {
 
 proc check_effective_target_xorsign { } {
     return [check_cached_effective_target_indexed xorsign {
-      expr { [istarget aarch64*-*-*] || [istarget arm*-*-*] }}]
+      expr { [istarget i?86-*-*] || [istarget x86_64-*-*]
+            || [istarget aarch64*-*-*] || [istarget arm*-*-*] }}]
 }
 
 # Return 1 if the target plus current options supports a vector
@@ -5729,7 +5900,8 @@ proc check_effective_target_vect_widen_mult_qi_to_hi { } {
                      && ![check_effective_target_aarch64_sve])
                  || [is-effective-target arm_neon]
                  || ([istarget s390*-*-*]
-                     && [check_effective_target_s390_vx])) }}]
+                     && [check_effective_target_s390_vx])) 
+             || [istarget amdgcn-*-*] }}]
 }
 
 # Return 1 if the target plus current options supports a vector
@@ -5753,7 +5925,8 @@ proc check_effective_target_vect_widen_mult_hi_to_si { } {
                 || [istarget i?86-*-*] || [istarget x86_64-*-*]
                 || [is-effective-target arm_neon]
                 || ([istarget s390*-*-*]
-                    && [check_effective_target_s390_vx])) }}]
+                    && [check_effective_target_s390_vx]))
+            || [istarget amdgcn-*-*] }}]
 }
 
 # Return 1 if the target plus current options supports a vector
@@ -5767,7 +5940,8 @@ proc check_effective_target_vect_widen_mult_qi_to_hi_pattern { } {
              || ([is-effective-target arm_neon]
                 && [check_effective_target_arm_little_endian])
             || ([istarget s390*-*-*]
-                && [check_effective_target_s390_vx]) }}]
+                && [check_effective_target_s390_vx])
+            || [istarget amdgcn-*-*] }}]
 }
 
 # Return 1 if the target plus current options supports a vector
@@ -5784,7 +5958,8 @@ proc check_effective_target_vect_widen_mult_hi_to_si_pattern { } {
             || ([is-effective-target arm_neon]
                 && [check_effective_target_arm_little_endian])
             || ([istarget s390*-*-*]
-                && [check_effective_target_s390_vx]) }}]
+                && [check_effective_target_s390_vx])
+            || [istarget amdgcn-*-*] }}]
 }
 
 # Return 1 if the target plus current options supports a vector
@@ -5872,7 +6047,12 @@ proc check_effective_target_vect_udot_hi { } {
 
 proc check_effective_target_vect_usad_char { } {
     return [check_cached_effective_target_indexed vect_usad_char {
-      expr { [istarget i?86-*-*] || [istarget x86_64-*-*] }}]
+      expr { [istarget i?86-*-*]
+             || [istarget x86_64-*-*]
+             || ([istarget aarch64*-*-*]
+                 && ![check_effective_target_aarch64_sve])
+             || ([istarget powerpc*-*-*]
+                 && [check_p9vector_hw_available])}}]
 }
 
 # Return 1 if the target plus current options supports both signed
@@ -6025,7 +6205,8 @@ proc check_effective_target_vect_natural_alignment { } {
     set et_vect_natural_alignment 1
     if { [check_effective_target_arm_eabi]
         || [istarget nvptx-*-*]
-        || [istarget s390*-*-*] } {
+        || [istarget s390*-*-*]
+        || [istarget amdgcn-*-*] } {
        set et_vect_natural_alignment 0
     }
     verbose "check_effective_target_vect_natural_alignment:\
@@ -6036,7 +6217,8 @@ proc check_effective_target_vect_natural_alignment { } {
 # Return true if fully-masked loops are supported.
 
 proc check_effective_target_vect_fully_masked { } {
-    return [check_effective_target_aarch64_sve]
+    return [expr { [check_effective_target_aarch64_sve]
+                  || [istarget amdgcn*-*-*] }]
 }
 
 # Return 1 if the target doesn't prefer any alignment beyond element
@@ -6088,7 +6270,8 @@ proc check_effective_target_vect_element_align { } {
     return [check_cached_effective_target_indexed vect_element_align {
       expr { ([istarget arm*-*-*]
              && ![check_effective_target_arm_vect_no_misalign])
-            || [check_effective_target_vect_hw_misalign] }}]
+            || [check_effective_target_vect_hw_misalign]
+            || [istarget amdgcn-*-*] }}]
 }
 
 # Return 1 if we expect to see unaligned accesses in at least some
@@ -6113,13 +6296,15 @@ proc check_effective_target_vect_load_lanes { } {
 # Return 1 if the target supports vector masked stores.
 
 proc check_effective_target_vect_masked_store { } {
-    return [check_effective_target_aarch64_sve]
+    return [expr { [check_effective_target_aarch64_sve]
+                  || [istarget amdgcn*-*-*] }]
 }
 
 # Return 1 if the target supports vector scatter stores.
 
 proc check_effective_target_vect_scatter_store { } {
-    return [check_effective_target_aarch64_sve]
+    return [expr { [check_effective_target_aarch64_sve]
+                  || [istarget amdgcn*-*-*] }]
 }
 
 # Return 1 if the target supports vector conditional operations, 0 otherwise.
@@ -6136,7 +6321,8 @@ proc check_effective_target_vect_condition { } {
             || ([istarget arm*-*-*]
                 && [check_effective_target_arm_neon_ok])
             || ([istarget s390*-*-*]
-                && [check_effective_target_s390_vx]) }}]
+                && [check_effective_target_s390_vx])
+            || [istarget amdgcn-*-*] }}]
 }
 
 # Return 1 if the target supports vector conditional operations where
@@ -6150,7 +6336,8 @@ proc check_effective_target_vect_cond_mixed { } {
             || ([istarget mips*-*-*]
                 && [et-is-effective-target mips_msa])
             || ([istarget s390*-*-*]
-                && [check_effective_target_s390_vx]) }}]
+                && [check_effective_target_s390_vx])
+            || [istarget amdgcn-*-*] }}]
 }
 
 # Return 1 if the target supports vector char multiplication, 0 otherwise.
@@ -6165,7 +6352,8 @@ proc check_effective_target_vect_char_mult { } {
             || ([istarget mips*-*-*]
                 && [et-is-effective-target mips_msa])
             || ([istarget s390*-*-*]
-                && [check_effective_target_s390_vx]) }}]
+                && [check_effective_target_s390_vx])
+            || [istarget amdgcn-*-*] }}]
 }
 
 # Return 1 if the target supports vector short multiplication, 0 otherwise.
@@ -6182,7 +6370,8 @@ proc check_effective_target_vect_short_mult { } {
                 && ([et-is-effective-target mips_msa]
                     || [et-is-effective-target mips_loongson_mmi]))
             || ([istarget s390*-*-*]
-                && [check_effective_target_s390_vx]) }}]
+                && [check_effective_target_s390_vx])
+            || [istarget amdgcn-*-*] }}]
 }
 
 # Return 1 if the target supports vector int multiplication, 0 otherwise.
@@ -6198,7 +6387,8 @@ proc check_effective_target_vect_int_mult { } {
                 && [et-is-effective-target mips_msa])
             || [check_effective_target_arm32]
             || ([istarget s390*-*-*]
-                && [check_effective_target_s390_vx]) }}]
+                && [check_effective_target_s390_vx])
+            || [istarget amdgcn-*-*] }}]
 }
 
 # Return 1 if the target supports 64 bit hardware vector
@@ -6273,6 +6463,9 @@ foreach N {2 3 4 8} {
                      || [istarget aarch64*-*-*]) && N >= 2 && N <= 4 } {
                    return 1
                }
+               if [check_effective_target_vect_fully_masked] {
+                   return 1
+               }
                return 0
            }]
        }
@@ -6340,7 +6533,17 @@ proc check_effective_target_sqrt_insn { } {
             || [istarget aarch64*-*-*]
             || ([istarget arm*-*-*] && [check_effective_target_arm_vfp_ok])
             || ([istarget s390*-*-*]
-                && [check_effective_target_s390_vx]) }}]
+                && [check_effective_target_s390_vx])
+            || [istarget amdgcn-*-*] }}]
+}
+
+# Return any additional options to enable square root intructions.
+
+proc add_options_for_sqrt_insn { flags } {
+    if { [istarget amdgcn*-*-*] } {
+       return "$flags -ffast-math"
+    }
+    return $flags
 }
 
 # Return 1 if the target supports vector sqrtf calls.
@@ -6359,7 +6562,8 @@ proc check_effective_target_vect_call_sqrtf { } {
 proc check_effective_target_vect_call_lrint { } {
     set et_vect_call_lrint 0
     if { (([istarget i?86-*-*] || [istarget x86_64-*-*])
-         && [check_effective_target_ilp32]) } {
+         && [check_effective_target_ilp32])
+        || [istarget amdgcn-*-*] } {
        set et_vect_call_lrint 1
     }
 
@@ -6371,21 +6575,24 @@ proc check_effective_target_vect_call_lrint { } {
 
 proc check_effective_target_vect_call_btrunc { } {
     return [check_cached_effective_target_indexed vect_call_btrunc {
-      expr { [istarget aarch64*-*-*] }}]
+      expr { [istarget aarch64*-*-*]
+            || [istarget amdgcn-*-*] }}]
 }
 
 # Return 1 if the target supports vector btruncf calls.
 
 proc check_effective_target_vect_call_btruncf { } {
     return [check_cached_effective_target_indexed vect_call_btruncf {
-      expr { [istarget aarch64*-*-*] }}]
+      expr { [istarget aarch64*-*-*]
+            || [istarget amdgcn-*-*] }}]
 }
 
 # Return 1 if the target supports vector ceil calls.
 
 proc check_effective_target_vect_call_ceil { } {
     return [check_cached_effective_target_indexed vect_call_ceil {
-      expr { [istarget aarch64*-*-*] }}]
+      expr { [istarget aarch64*-*-*]
+            || [istarget amdgcn-*-*] }}]
 }
 
 # Return 1 if the target supports vector ceilf calls.
@@ -6406,7 +6613,8 @@ proc check_effective_target_vect_call_floor { } {
 
 proc check_effective_target_vect_call_floorf { } {
     return [check_cached_effective_target_indexed vect_call_floorf {
-      expr { [istarget aarch64*-*-*] }}]
+      expr { [istarget aarch64*-*-*]
+            || [istarget amdgcn-*-*] }}]
 }
 
 # Return 1 if the target supports vector lceil calls.
@@ -6513,6 +6721,17 @@ proc check_effective_target_sync_long_long { } {
     }
 }
 
+# Return 1 if the target supports popcount on long.
+
+proc check_effective_target_popcountl { } {
+    return [check_no_messages_and_pattern popcountl "!\\(call" rtl-expand {
+       int foo (long b)
+         {
+           return __builtin_popcountl (b);
+         }
+    } "" ]
+}
+
 # Return 1 if the target supports atomic operations on "long long"
 # and can execute them.
 #
@@ -6670,6 +6889,11 @@ proc check_effective_target_newlib {} {
     }]
 }
 
+# Return true if GCC was configured with --enable-newlib-nano-formatted-io
+proc check_effective_target_newlib_nano_io { } {
+    return [check_configured_with "--enable-newlib-nano-formatted-io"]
+}
+
 # Some newlib versions don't provide a frexpl and instead depend
 # on frexp to implement long double conversions in their printf-like
 # functions.  This leads to broken results.  Detect such versions here.
@@ -7128,6 +7352,19 @@ proc check_effective_target_c99_runtime { } {
     }]
 }
 
+# Return 1 if the target provides the D runtime.
+
+proc check_effective_target_d_runtime { } {
+    return [check_no_compiler_messages d_runtime executable {
+       // D
+       module mod;
+
+       extern(C) int main() {
+           return 0;
+       }
+    }]
+}
+
 # Return 1 if  target wchar_t is at least 4 bytes.
 
 proc check_effective_target_4byte_wchar_t { } {
@@ -7163,6 +7400,19 @@ proc check_avx_available { } {
   return 0;
 }
 
+# Return true if we are compiling for AVX2 target.
+
+proc check_avx2_available { } {
+  if { [check_no_compiler_messages avx2_available assembly {
+    #ifndef __AVX2__
+    #error unsupported
+    #endif
+  } ""] } {
+    return 1;
+  }
+  return 0;
+}
+
 # Return true if we are compiling for SSSE3 target.
 
 proc check_ssse3_available { } {
@@ -7911,7 +8161,8 @@ proc check_effective_target_gld { } {
 # (LTO) support.
 
 proc check_effective_target_lto { } {
-    if { [istarget nvptx-*-*] } {
+    if { [istarget nvptx-*-*]
+        || [istarget amdgcn-*-*] } {
        return 0;
     }
     return [check_no_compiler_messages lto object {
@@ -7919,6 +8170,18 @@ proc check_effective_target_lto { } {
     } "-flto"]
 }
 
+# Return 1 if the compiler and linker support incremental link-time
+# optimization.
+
+proc check_effective_target_lto_incremental { } {
+    if ![check_effective_target_lto] {
+       return 0
+    }
+    return [check_no_compiler_messages lto_incremental executable {
+       int main () { return 0; }
+    } "-flto -r -nostdlib"]
+}
+
 # Return 1 if -mx32 -maddress-mode=short can compile, 0 otherwise.
 
 proc check_effective_target_maybe_x32 { } {
@@ -8229,6 +8492,8 @@ proc check_vect_support_and_set_flags { } {
            lappend DEFAULT_VECTCFLAGS "-march=z14" "-mzarch"
             set dg-do-what-default compile
         }
+    } elseif [istarget amdgcn-*-*] {
+        set dg-do-what-default run
     } else {
         return 0
     }
@@ -8341,6 +8606,14 @@ proc check_effective_target_avr_tiny { } {
     }
 }
 
+# Return 1 if <fenv.h> is available.
+
+proc check_effective_target_fenv {} {
+    return [check_no_compiler_messages fenv object {
+       #include <fenv.h>
+    } [add_options_for_ieee "-std=gnu99"]]
+}
+
 # Return 1 if <fenv.h> is available with all the standard IEEE
 # exceptions and floating-point exceptions are raised by arithmetic
 # operations.  (If the target requires special options for "inexact"
@@ -8378,6 +8651,16 @@ proc check_effective_target_fenv_exceptions {} {
     } [add_options_for_ieee "-std=gnu99"]]
 }
 
+# Return 1 if -fexceptions is supported.
+
+proc check_effective_target_exceptions {} {
+    if { [istarget amdgcn*-*-*] } {
+       return 0
+    }
+    return 1
+}
+
+
 proc check_effective_target_tiny {} {
     return [check_cached_effective_target tiny {
       if { [istarget aarch64*-*-*]
@@ -8392,27 +8675,6 @@ proc check_effective_target_tiny {} {
     }]
 }
 
-# Return 1 if LOGICAL_OP_NON_SHORT_CIRCUIT is set to 0 for the current target.
-
-proc check_effective_target_logical_op_short_circuit {} {
-    if { [istarget mips*-*-*]
-        || [istarget arc*-*-*]
-        || [istarget avr*-*-*]
-        || [istarget crisv32-*-*] || [istarget cris-*-*]
-        || [istarget csky*-*-*]
-        || [istarget mmix-*-*]
-        || [istarget s390*-*-*]
-        || [istarget powerpc*-*-*]
-        || [istarget nios2*-*-*]
-        || [istarget riscv*-*-*]
-        || [istarget v850*-*-*]
-        || [istarget visium-*-*]
-        || [check_effective_target_arm_cortex_m] } {
-       return 1
-    }
-    return 0
-}
-
 # Return 1 if the target supports -mbranch-cost=N option.
 
 proc check_effective_target_branch_cost {} {
@@ -8641,20 +8903,20 @@ proc check_effective_target_vect_max_reduc { } {
     return 0
 }
 
-# Return 1 if there is an nvptx offload compiler.
+# Return 1 if the compiler has been configured with hsa offloading.
 
-proc check_effective_target_offload_nvptx { } {
-    return [check_no_compiler_messages offload_nvptx object {
+proc check_effective_target_offload_hsa { } {
+    return [check_no_compiler_messages offload_hsa assembly {
        int main () {return 0;}
-    } "-foffload=nvptx-none" ]
+    } "-foffload=hsa" ]
 }
 
 # Return 1 if the compiler has been configured with hsa offloading.
 
-proc check_effective_target_offload_hsa { } {
-    return [check_no_compiler_messages offload_hsa assembly {
+proc check_effective_target_offload_gcn { } {
+    return [check_no_compiler_messages offload_gcn assembly {
        int main () {return 0;}
-    } "-foffload=hsa" ]
+    } "-foffload=amdgcn-unknown-amdhsa" ]
 }
 
 # Return 1 if the target support -fprofile-update=atomic
@@ -8953,3 +9215,117 @@ proc check_effective_target_inf { } {
         const double pinf = __builtin_inf ();
     }]
 }
+
+# Return 1 if the target supports ARMv8.3 Adv.SIMD Complex instructions
+# instructions, 0 otherwise.  The test is valid for ARM and for AArch64.
+# Record the command line options needed.
+
+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 ""
+
+    if { ![istarget arm*-*-*] && ![istarget aarch64*-*-*] } {
+        return 0;
+    }
+
+    # 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"} {
+        if { [check_no_compiler_messages_nocache \
+                  arm_v8_3a_complex_neon_ok object {
+            #if !defined (__ARM_FEATURE_COMPLEX)
+            #error "__ARM_FEATURE_COMPLEX not defined"
+            #endif
+        } "$flags -march=armv8.3-a"] } {
+            set et_arm_v8_3a_complex_neon_flags "$flags -march=armv8.3-a"
+            return 1
+        }
+    }
+
+    return 0;
+}
+
+proc check_effective_target_arm_v8_3a_complex_neon_ok { } {
+    return [check_cached_effective_target arm_v8_3a_complex_neon_ok \
+                check_effective_target_arm_v8_3a_complex_neon_ok_nocache]
+}
+
+proc add_options_for_arm_v8_3a_complex_neon { flags } {
+    if { ! [check_effective_target_arm_v8_3a_complex_neon_ok] } {
+        return "$flags"
+    }
+    global et_arm_v8_3a_complex_neon_flags
+    return "$flags $et_arm_v8_3a_complex_neon_flags"
+}
+
+# Return 1 if the target supports executing AdvSIMD instructions from ARMv8.3
+# with the complex instruction extension, 0 otherwise.  The test is valid for
+# ARM and for AArch64.
+
+proc check_effective_target_arm_v8_3a_complex_neon_hw { } {
+    if { ![check_effective_target_arm_v8_3a_complex_neon_ok] } {
+        return 0;
+    }
+    return [check_runtime arm_v8_3a_complex_neon_hw_available {
+        #include "arm_neon.h"
+        int
+        main (void)
+        {
+
+          float32x2_t results = {-4.0,5.0};
+          float32x2_t a = {1.0,3.0};
+          float32x2_t b = {2.0,5.0};
+
+          #ifdef __ARM_ARCH_ISA_A64
+          asm ("fcadd %0.2s, %1.2s, %2.2s, #90"
+               : "=w"(results)
+               : "w"(a), "w"(b)
+               : /* No clobbers.  */);
+
+          #else
+          asm ("vcadd.f32 %P0, %P1, %P2, #90"
+               : "=w"(results)
+               : "w"(a), "w"(b)
+               : /* No clobbers.  */);
+          #endif
+
+          return (results[0] == 8 && results[1] == 24) ? 1 : 0;
+        }
+    } [add_options_for_arm_v8_3a_complex_neon ""]]
+}
+
+# Return 1 if the target plus current options supports a vector
+# complex addition with rotate of half and single float modes, 0 otherwise.
+#
+# This won't change for different subtargets so cache the result.
+
+foreach N {hf sf} {
+    eval [string map [list N $N] {
+        proc check_effective_target_vect_complex_rot_N { } {
+            return [check_cached_effective_target_indexed vect_complex_rot_N {
+            expr { [istarget aarch64*-*-*]
+                    || [istarget arm*-*-*] }}]
+        }
+    }]
+}
+
+# Return 1 if the target plus current options supports a vector
+# complex addition with rotate of double float modes, 0 otherwise.
+#
+# This won't change for different subtargets so cache the result.
+
+foreach N {df} {
+    eval [string map [list N $N] {
+        proc check_effective_target_vect_complex_rot_N { } {
+            return [check_cached_effective_target_indexed vect_complex_rot_N {
+            expr { [istarget aarch64*-*-*] }}]
+        }
+    }]
+}
+
+# Return 1 if this target uses an LLVM assembler and/or linker
+proc check_effective_target_llvm_binutils { } {
+    return [check_cached_effective_target llvm_binutils {
+             expr { [istarget amdgcn*-*-*]
+                    || [check_effective_target_offload_gcn] }}]
+}