Update copyright years.
[gcc.git] / gcc / testsuite / lib / target-supports.exp
index 95360089b89d5fef2997dc6dbe7f47a6864143ea..e335913e914c222c6050aa32b1d74f8c3a4784b2 100644 (file)
@@ -1,4 +1,4 @@
-#   Copyright (C) 1999-2014 Free Software Foundation, Inc.
+#   Copyright (C) 1999-2015 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
@@ -436,6 +436,7 @@ proc check_effective_target_trampolines { } {
     }
     if { [istarget avr-*-*]
         || [istarget msp430-*-*]
+        || [istarget nvptx-*-*]
         || [istarget hppa2.0w-hp-hpux11.23]
         || [istarget hppa64-hp-hpux11.23] } {
        return 0;
@@ -509,7 +510,7 @@ proc check_profiling_available { test_what } {
     if {![info exists profiling_available_saved]} {
        # Some targets don't have any implementation of __bb_init_func or are
        # missing other needed machinery.
-       if {    [istarget aarch64*-*-elf]
+       if {[istarget aarch64*-*-elf]
             || [istarget am3*-*-linux*]
             || [istarget arm*-*-eabi*]
             || [istarget arm*-*-elf]
@@ -532,7 +533,7 @@ proc check_profiling_available { test_what } {
             || [istarget msp430-*-*]
             || [istarget nds32*-*-elf]
             || [istarget nios2-*-elf]
-            || [istarget picochip-*-*]
+            || [istarget nvptx-*-*]
             || [istarget powerpc-*-eabi*]
             || [istarget powerpc-*-elf]
             || [istarget rx-*-*]       
@@ -554,11 +555,7 @@ proc check_profiling_available { test_what } {
 # in Section 4 of C99 standard. Effectively, it is a target which supports no
 # extra headers or libraries other than what is considered essential.
 proc check_effective_target_freestanding { } {
-    if { [istarget picochip-*-*] } then {
-        return 1
-    } else {
-        return 0
-    }
+       return 0
 }
 
 # Return 1 if target has packed layout of structure members by
@@ -593,17 +590,78 @@ proc add_options_for_tls { flags } {
     # libthread, so always pass -pthread for native TLS. Same for AIX.
     # Need to duplicate native TLS check from
     # check_effective_target_tls_native to avoid recursion.
-    if { ([istarget *-*-solaris2.9*] || [istarget powerpc-ibm-aix*]) &&
+    if { ([istarget powerpc-ibm-aix*]) &&
         [check_no_messages_and_pattern tls_native "!emutls" assembly {
             __thread int i;
             int f (void) { return i; }
             void g (int j) { i = j; }
         }] } {
-       return "$flags -pthread"
+       return "-pthread [g++_link_flags [get_multilibs "-pthread"] ] $flags "
     }
     return $flags
 }
 
+# Return 1 if indirect jumps are supported, 0 otherwise.
+
+proc check_effective_target_indirect_jumps {} {
+    if { [istarget nvptx-*-*] } {
+       return 0
+    }
+    return 1
+}
+
+# Return 1 if nonlocal goto is supported, 0 otherwise.
+
+proc check_effective_target_nonlocal_goto {} {
+    if { [istarget nvptx-*-*] } {
+       return 0
+    }
+    return 1
+}
+
+# Return 1 if taking label values is supported, 0 otherwise.
+
+proc check_effective_target_label_values {} {
+    if { [istarget nvptx-*-*] } {
+       return 0
+    }
+    return [check_no_compiler_messages label_values assembly {
+       #ifdef NO_LABEL_VALUES
+       #error NO
+       #endif
+    }]
+}
+
+# Return 1 if builtin_return_address and builtin_frame_address are
+# supported, 0 otherwise.
+
+proc check_effective_target_return_address {} {
+    if { [istarget nvptx-*-*] } {
+       return 0
+    }
+    return 1
+}
+
+# Return 1 if the assembler does not verify function types against
+# calls, 0 otherwise.  Such verification will typically show up problems
+# with K&R C function declarations.
+
+proc check_effective_target_untyped_assembly {} {
+    if { [istarget nvptx-*-*] } {
+       return 0
+    }
+    return 1
+}
+
+# Return 1 if alloca is supported, 0 otherwise.
+
+proc check_effective_target_alloca {} {
+    if { [istarget nvptx-*-*] } {
+       return 0
+    }
+    return 1
+}
+
 # Return 1 if thread local storage (TLS) is supported, 0 otherwise.
 
 proc check_effective_target_tls {} {
@@ -706,8 +764,8 @@ proc check_effective_target_scheduling {} {
 # Return 1 if trapping arithmetic is available, 0 otherwise.
 
 proc check_effective_target_trapping {} {
-    return [check_no_compiler_messages scheduling object {
-        add (int a, int b) { return a + b; }
+    return [check_no_compiler_messages trapping object {
+        int add (int a, int b) { return a + b; }
     } "-ftrapv"]
 }
 
@@ -746,7 +804,14 @@ proc check_effective_target_mmap {} {
 
 # Return 1 if the target supports dlopen, 0 otherwise.
 proc check_effective_target_dlopen {} {
-    return [check_function_available "dlopen"]
+    return [check_no_compiler_messages dlopen executable {
+       #include <dlfcn.h>
+       int main(void) { dlopen ("dummy.so", RTLD_NOW); }
+    } [add_options_for_dlopen ""]]
+}
+
+proc add_options_for_dlopen { flags } {
+    return "$flags -ldl"
 }
 
 # Return 1 if the target supports clone, 0 otherwise.
@@ -838,6 +903,19 @@ proc check_effective_target_fpic { } {
     return 0
 }
 
+# Return 1 if -shared is supported, as in no warnings or errors
+# emitted, 0 otherwise.
+
+proc check_effective_target_shared { } {
+    # Note that M68K has a multilib that supports -fpic but not
+    # -fPIC, so we need to check both.  We test with a program that
+    # requires GOT references.
+    return [check_no_compiler_messages shared executable {
+       extern int foo (void); extern int bar;
+       int baz (void) { return foo () + bar; }
+    } "-shared -fpic"]
+}
+
 # Return 1 if -pie, -fpie and -fPIE are supported, 0 otherwise.
 
 proc check_effective_target_pie { } {
@@ -863,7 +941,7 @@ proc check_effective_target_hard_float { } {
     if { [istarget mips*-*-*] } {
        return [check_no_compiler_messages hard_float assembly {
                #if (defined __mips_soft_float || defined __mips16)
-               #error FOO
+               #error __mips_soft_float || __mips16
                #endif
        }]
     }
@@ -875,7 +953,7 @@ proc check_effective_target_hard_float { } {
        return 0
        # return [check_no_compiler_messages hard_float assembly {
                #if defined __RX_64_BIT_DOUBLES__
-               #error FOO
+               #error __RX_64_BIT_DOUBLES__
                #endif
        # }]
     }
@@ -891,7 +969,7 @@ proc check_effective_target_hard_float { } {
 proc check_effective_target_mips64 { } {
     return [check_no_compiler_messages mips64 assembly {
        #ifndef __mips64
-       #error FOO
+       #error !__mips64
        #endif
     }]
 }
@@ -902,7 +980,7 @@ proc check_effective_target_mips64 { } {
 proc check_effective_target_nomips16 { } {
     return [check_no_compiler_messages nomips16 object {
        #ifndef __mips
-       #error FOO
+       #error !__mips
        #else
        /* A cheap way of testing for -mflip-mips16.  */
        void foo (void) { asm ("addiu $20,$20,1"); }
@@ -925,12 +1003,12 @@ proc add_options_for_mips16_attribute { flags } {
 proc check_effective_target_mips16_attribute { } {
     return [check_no_compiler_messages mips16_attribute assembly {
        #ifdef PIC
-       #error FOO
+       #error PIC
        #endif
        #if defined __mips_hard_float \
            && (!defined _ABIO32 || _MIPS_SIM != _ABIO32) \
            && (!defined _ABIO64 || _MIPS_SIM != _ABIO64)
-       #error FOO
+       #error __mips_hard_float && (!_ABIO32 || !_ABIO64)
        #endif
     } [add_options_for_mips16_attribute ""]]
 }
@@ -959,7 +1037,7 @@ proc check_effective_target_mips_llsc { } {
     # Otherwise assume LL/SC support for everything but MIPS I.
     return [check_no_compiler_messages mips_llsc assembly {
        #if __mips == 1
-       #error FOO
+       #error __mips == 1
        #endif
     }]
 }
@@ -973,7 +1051,7 @@ proc check_effective_target_mips_rel { } {
     return [check_no_compiler_messages mips_rel object {
        #if (defined _ABIN32 && _MIPS_SIM == _ABIN32) \
            || (defined _ABI64 && _MIPS_SIM == _ABI64)
-       #error FOO
+       #error _ABIN32 && (_ABIN32 || _ABI64)
        #endif
     }]
 }
@@ -986,7 +1064,7 @@ proc check_effective_target_mips_eabi { } {
     }
     return [check_no_compiler_messages mips_eabi object {
        #ifndef __mips_eabi
-       #error FOO
+       #error !__mips_eabi
        #endif
     }]
 }
@@ -996,7 +1074,7 @@ proc check_effective_target_mips_eabi { } {
 proc check_effective_target_nonpic { } {
     return [check_no_compiler_messages nonpic assembly {
        #if __PIC__
-       #error FOO
+       #error __PIC__
        #endif
     }]
 }
@@ -1038,9 +1116,13 @@ proc check_iconv_available { test_what } {
 # Return true if Cilk Library is supported on the target.
 proc check_libcilkrts_available { } {
   return [ check_no_compiler_messages_nocache libcilkrts_available executable {
+       #ifdef __cplusplus
+       extern "C" 
+       #endif
+          int __cilkrts_set_param (const char *, const char *);
            int main (void) { 
-               __cilkrts_set_param ("nworkers", "0");  
-               return 0
+               int x = __cilkrts_set_param ("nworkers", "0");
+               return x
            }
        } "-fcilkplus -lcilkrts" ]
 }
@@ -1099,6 +1181,20 @@ proc check_effective_target_fortran_real_16 { } {
 }
 
 
+# Return 1 if the target supports Fortran's IEEE modules,
+# 0 otherwise.
+#
+# When the target name changes, replace the cached result.
+
+proc check_effective_target_fortran_ieee { flags } {
+    return [check_no_compiler_messages fortran_ieee executable {
+       ! Fortran
+       use, intrinsic :: ieee_features
+       end
+    } $flags ]
+}
+
+
 # Return 1 if the target supports SQRT for the largest floating-point
 # type. (Some targets lack the libm support for this FP type.)
 # On most targets, this check effectively checks either whether sqrtl is
@@ -1597,7 +1693,7 @@ proc check_effective_target_broken_cplxf_arg { } {
 proc check_effective_target_ti_c67x { } {
     return [check_no_compiler_messages ti_c67x assembly {
        #if !defined(_TMS320C6700)
-       #error FOO
+       #error !_TMS320C6700
        #endif
     }]
 }
@@ -1606,7 +1702,7 @@ proc check_effective_target_ti_c67x { } {
 proc check_effective_target_ti_c64xp { } {
     return [check_no_compiler_messages ti_c64xp assembly {
        #if !defined(_TMS320C6400_PLUS)
-       #error FOO
+       #error !_TMS320C6400_PLUS
        #endif
     }]
 }
@@ -1701,8 +1797,8 @@ proc check_effective_target_objc2 { } {
        #ifdef __OBJC2__
        int dummy[1];
        #else
-       #error
-       #endif 
+       #error !__OBJC2__
+       #endif
     }]
 }
 
@@ -1711,8 +1807,8 @@ proc check_effective_target_next_runtime { } {
        #ifdef __NEXT_RUNTIME__
        int dummy[1];
        #else
-       #error
-       #endif 
+       #error !__NEXT_RUNTIME__
+       #endif
     }]
 }
 
@@ -1784,11 +1880,12 @@ proc check_effective_target_ptr32plus { } {
 }
 
 # Return 1 if we support 32-bit or larger array and structure sizes
-# using default options, 0 otherwise.
+# using default options, 0 otherwise.  Avoid false positive on
+# targets with 20 or 24 bit address spaces.
 
 proc check_effective_target_size32plus { } {
     return [check_no_compiler_messages size32plus object {
-       char dummy[65537];
+       char dummy[16777217L];
     }]
 }
 
@@ -1851,6 +1948,15 @@ proc check_effective_target_large_double { } {
     }]
 }
 
+# Return 1 if the target supports long double of 128 bits,
+# 0 otherwise.
+
+proc check_effective_target_longdouble128 { } {
+    return [check_no_compiler_messages longdouble128 object {
+       int dummy[sizeof(long double) == 16 ? 1 : -1];
+    }]
+}
+
 # Return 1 if the target supports double of 64 bits,
 # 0 otherwise.
 
@@ -1945,14 +2051,41 @@ proc check_effective_target_dfprt { } {
     }]
 }
 
+# Return 1 if the target supports executing DFP hardware instructions,
+# 0 otherwise.  Cache the result.
+
+proc check_dfp_hw_available { } {
+    return [check_cached_effective_target dfp_hw_available {
+       # For now, disable on Darwin
+       if { [istarget powerpc-*-eabi] || [istarget powerpc*-*-eabispe] || [istarget *-*-darwin*]} {
+           expr 0
+       } else {
+           check_runtime_nocache dfp_hw_available {
+               volatile _Decimal64 r;
+               volatile _Decimal64 a = 4.0DD;
+               volatile _Decimal64 b = 2.0DD;
+               int main()
+               {
+                 asm volatile ("dadd %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
+                 asm volatile ("dsub %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
+                 asm volatile ("dmul %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
+                 asm volatile ("ddiv %0,%1,%2" : "=d" (r) : "d" (a), "d" (b));
+                 return 0;
+               }
+           } "-mcpu=power6 -mhard-float"
+       }
+    }]
+}
+
 # Return 1 if the target supports compiling and assembling UCN, 0 otherwise.
 
 proc check_effective_target_ucn_nocache { } {
     # -std=c99 is only valid for C
     if [check_effective_target_c] {
        set ucnopts "-std=c99"
+    } else {
+       set ucnopts ""
     }
-    append ucnopts " -fextended-identifiers"
     verbose "check_effective_target_ucn_nocache: compiling source" 2
     set ret [check_no_compiler_messages_nocache ucn object {
        int \u00C0;
@@ -2028,11 +2161,10 @@ proc check_effective_target_vect_int { } {
        verbose "check_effective_target_vect_int: using cached result" 2
     } else {
        set et_vect_int_saved 0
-       if { [istarget i?86-*-*]
+       if { [istarget i?86-*-*] || [istarget x86_64-*-*]
              || ([istarget powerpc*-*-*]
                   && ![istarget powerpc-*-linux*paired*])
              || [istarget spu-*-*]
-             || [istarget x86_64-*-*]
              || [istarget sparc*-*-*]
              || [istarget alpha*-*-*]
              || [istarget ia64-*-*] 
@@ -2058,10 +2190,9 @@ proc check_effective_target_vect_intfloat_cvt { } {
         verbose "check_effective_target_vect_intfloat_cvt: using cached result" 2
     } else {
         set et_vect_intfloat_cvt_saved 0
-        if { [istarget i?86-*-*]
+        if { [istarget i?86-*-*] || [istarget x86_64-*-*]
               || ([istarget powerpc*-*-*]
                    && ![istarget powerpc-*-linux*paired*])
-              || [istarget x86_64-*-*] 
               || ([istarget arm*-*-*]
                   && [check_effective_target_arm_neon_ok])} {
            set et_vect_intfloat_cvt_saved 1
@@ -2096,10 +2227,9 @@ proc check_effective_target_vect_uintfloat_cvt { } {
         verbose "check_effective_target_vect_uintfloat_cvt: using cached result" 2
     } else {
         set et_vect_uintfloat_cvt_saved 0
-        if { [istarget i?86-*-*]
+        if { [istarget i?86-*-*] || [istarget x86_64-*-*]
              || ([istarget powerpc*-*-*]
                  && ![istarget powerpc-*-linux*paired*])
-             || [istarget x86_64-*-*] 
              || [istarget aarch64*-*-*]
              || ([istarget arm*-*-*]
                  && [check_effective_target_arm_neon_ok])} {
@@ -2122,10 +2252,9 @@ proc check_effective_target_vect_floatint_cvt { } {
         verbose "check_effective_target_vect_floatint_cvt: using cached result" 2
     } else {
         set et_vect_floatint_cvt_saved 0
-        if { [istarget i?86-*-*]
+        if { [istarget i?86-*-*] || [istarget x86_64-*-*]
               || ([istarget powerpc*-*-*]
                    && ![istarget powerpc-*-linux*paired*])
-              || [istarget x86_64-*-*]
               || ([istarget arm*-*-*]
                   && [check_effective_target_arm_neon_ok])} {
            set et_vect_floatint_cvt_saved 1
@@ -2188,7 +2317,7 @@ proc check_effective_target_vect_simd_clones { } {
 proc check_effective_target_aarch64_big_endian { } {
     return [check_no_compiler_messages aarch64_big_endian assembly {
        #if !defined(__aarch64__) || !defined(__AARCH64EB__)
-       #error FOO
+       #error !__aarch64__ || !__AARCH64EB__
        #endif
     }]
 }
@@ -2202,20 +2331,20 @@ proc check_effective_target_aarch64_little_endian { } {
     }]
 }
 
-# Return 1 is this is an arm target using 32-bit instructions
+# Return 1 if this is an arm target using 32-bit instructions
 proc check_effective_target_arm32 { } {
     return [check_no_compiler_messages arm32 assembly {
        #if !defined(__arm__) || (defined(__thumb__) && !defined(__thumb2__))
-       #error FOO
+       #error !__arm || __thumb__ && !__thumb2__
        #endif
     }]
 }
 
-# Return 1 is this is an arm target not using Thumb
+# Return 1 if this is an arm target not using Thumb
 proc check_effective_target_arm_nothumb { } {
     return [check_no_compiler_messages arm_nothumb assembly {
-       #if (defined(__thumb__) || defined(__thumb2__))
-       #error FOO
+       #if !defined(__arm__) || (defined(__thumb__) || defined(__thumb2__))
+       #error !__arm__ || __thumb || __thumb2__
        #endif
     }]
 }
@@ -2224,7 +2353,7 @@ proc check_effective_target_arm_nothumb { } {
 proc check_effective_target_arm_little_endian { } {
     return [check_no_compiler_messages arm_little_endian assembly {
        #if !defined(__arm__) || !defined(__ARMEL__)
-       #error FOO
+       #error !__arm__ || !__ARMEL__
        #endif
     }]
 }
@@ -2233,9 +2362,9 @@ proc check_effective_target_arm_little_endian { } {
 proc check_effective_target_arm_vect_no_misalign { } {
     return [check_no_compiler_messages arm_vect_no_misalign assembly {
        #if !defined(__arm__) \
-           || (defined(__ARMEL__) \
-               && (!defined(__thumb__) || defined(__thumb2__)))
-       #error FOO
+           || (defined(__ARM_FEATURE_UNALIGNED) \
+               && defined(__ARMEL__))
+       #error !__arm__ || (__ARMEL__ && __ARM_FEATURE_UNALIGNED)
        #endif
     }]
 }
@@ -2255,6 +2384,19 @@ proc check_effective_target_arm_vfp_ok { } {
     }
 }
 
+# Return 1 if this is an ARM target supporting -mfpu=vfp3
+# -mfloat-abi=softfp.
+
+proc check_effective_target_arm_vfp3_ok { } {
+    if { [check_effective_target_arm32] } {
+       return [check_no_compiler_messages arm_vfp3_ok object {
+           int dummy;
+       } "-mfpu=vfp3 -mfloat-abi=softfp"]
+    } else {
+       return 0
+    }
+}
+
 # Return 1 if this is an ARM target supporting -mfpu=fp-armv8
 # -mfloat-abi=softfp.
 proc check_effective_target_arm_v8_vfp_ok {} {
@@ -2311,19 +2453,37 @@ proc check_effective_target_arm_unaligned { } {
 }
 
 # Return 1 if this is an ARM target supporting -mfpu=crypto-neon-fp-armv8
-# -mfloat-abi=softfp.
-proc check_effective_target_arm_crypto_ok {} {
+# -mfloat-abi=softfp or equivalent options.  Some multilibs may be
+# incompatible with these options.  Also set et_arm_crypto_flags to the
+# best options to add.
+
+proc check_effective_target_arm_crypto_ok_nocache { } {
+    global et_arm_crypto_flags
+    set et_arm_crypto_flags ""
     if { [check_effective_target_arm32] } {
-       return [check_no_compiler_messages arm_crypto_ok object {
-         int foo (void)
-         {
-            __asm__ volatile ("aese.8 q0, q0");
-            return 0;
-         }
-       } "-mfpu=crypto-neon-fp-armv8 -mfloat-abi=softfp"]
-    } else {
-       return 0
+       foreach flags {"" "-mfloat-abi=softfp" "-mfpu=crypto-neon-fp-armv8" "-mfpu=crypto-neon-fp-armv8 -mfloat-abi=softfp"} {
+           if { [check_no_compiler_messages_nocache arm_crypto_ok object {
+               #include "arm_neon.h"
+               uint8x16_t
+               foo (uint8x16_t a, uint8x16_t b)
+               {
+                 return vaeseq_u8 (a, b);
+               }
+           } "$flags"] } {
+               set et_arm_crypto_flags $flags
+               return 1
+           }
+       }
     }
+
+    return 0
+}
+
+# Return 1 if this is an ARM target supporting -mfpu=crypto-neon-fp-armv8
+
+proc check_effective_target_arm_crypto_ok { } {
+    return [check_cached_effective_target arm_crypto_ok \
+               check_effective_target_arm_crypto_ok_nocache]
 }
 
 # Add options for crypto extensions.
@@ -2331,7 +2491,8 @@ proc add_options_for_arm_crypto { flags } {
     if { ! [check_effective_target_arm_crypto_ok] } {
         return "$flags"
     }
-    return "$flags -mfpu=crypto-neon-fp-armv8 -mfloat-abi=softfp"
+    global et_arm_crypto_flags
+    return "$flags $et_arm_crypto_flags"
 }
 
 # Add the options needed for NEON.  We need either -mfloat-abi=softfp
@@ -2383,6 +2544,14 @@ proc add_options_for_arm_neonv2 { flags } {
     return "$flags $et_arm_neonv2_flags"
 }
 
+# Add the options needed for vfp3.
+proc add_options_for_arm_vfp3 { flags } {
+    if { ! [check_effective_target_arm_vfp3_ok] } {
+        return "$flags"
+    }
+    return "$flags -mfpu=vfp3 -mfloat-abi=softfp"
+}
+
 # Return 1 if this is an ARM target supporting -mfpu=neon
 # -mfloat-abi=softfp or equivalent options.  Some multilibs may be
 # incompatible with these options.  Also set et_arm_neon_flags to the
@@ -2478,13 +2647,16 @@ proc check_effective_target_arm_v8_neon_ok_nocache { } {
     if { [check_effective_target_arm32] } {
        foreach flags {"" "-mfloat-abi=softfp" "-mfpu=neon-fp-armv8" "-mfpu=neon-fp-armv8 -mfloat-abi=softfp"} {
            if { [check_no_compiler_messages_nocache arm_v8_neon_ok object {
+               #if __ARM_ARCH < 8
+               #error not armv8 or later
+               #endif
                #include "arm_neon.h"
                void
                foo ()
                {
                  __asm__ volatile ("vrintn.f32 q0, q0");
                }
-           } "$flags"] } {
+           } "$flags -march=armv8-a"] } {
                set et_arm_v8_neon_flags $flags
                return 1
            }
@@ -2607,6 +2779,7 @@ foreach { armfunc armflag armdef } { v4 "-march=armv4 -marm" __ARM_ARCH_4__
                                     v6z "-march=armv6z" __ARM_ARCH_6Z__
                                     v6m "-march=armv6-m -mthumb" __ARM_ARCH_6M__
                                     v7a "-march=armv7-a" __ARM_ARCH_7A__
+                                    v7ve "-march=armv7ve" __ARM_ARCH_7A__
                                     v7r "-march=armv7-r" __ARM_ARCH_7R__
                                     v7m "-march=armv7-m -mthumb" __ARM_ARCH_7M__
                                     v7em "-march=armv7e-m -mthumb" __ARM_ARCH_7EM__
@@ -2619,7 +2792,7 @@ foreach { armfunc armflag armdef } { v4 "-march=armv4 -marm" __ARM_ARCH_4__
            }
            return [check_no_compiler_messages arm_arch_FUNC_ok assembly {
                #if !defined (DEF)
-               #error FOO
+               #error !DEF
                #endif
            } "FLAG" ]
        }
@@ -2646,7 +2819,7 @@ foreach { armfunc armflag armdef } { v4 "-march=armv4 -marm" __ARM_ARCH_4__
 proc check_effective_target_arm_arm_ok { } {
     return [check_no_compiler_messages arm_arm_ok assembly {
        #if !defined (__arm__) || defined (__thumb__) || defined (__thumb2__)
-       #error FOO
+       #error !__arm__ || __thumb__ || __thumb2__
        #endif
     } "-marm"]
 }
@@ -2658,8 +2831,9 @@ proc check_effective_target_arm_arm_ok { } {
 proc check_effective_target_arm_thumb1_ok { } {
     return [check_no_compiler_messages arm_thumb1_ok assembly {
        #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
-       #error FOO
+       #error !__arm__ || !__thumb__ || __thumb2__
        #endif
+       int foo (int i) { return i; }
     } "-mthumb"]
 }
 
@@ -2669,8 +2843,9 @@ proc check_effective_target_arm_thumb1_ok { } {
 proc check_effective_target_arm_thumb2_ok { } {
     return [check_no_compiler_messages arm_thumb2_ok assembly {
        #if !defined(__thumb2__)
-       #error FOO
+       #error !__thumb2__
        #endif
+       int foo (int i) { return i; }
     } "-mthumb"]
 }
 
@@ -2680,7 +2855,7 @@ proc check_effective_target_arm_thumb2_ok { } {
 proc check_effective_target_arm_thumb1 { } {
     return [check_no_compiler_messages arm_thumb1 assembly {
        #if !defined(__arm__) || !defined(__thumb__) || defined(__thumb2__)
-       #error not thumb1
+       #error !__arm__ || !__thumb__ || __thumb2__
        #endif
        int i;
     } ""]
@@ -2692,7 +2867,7 @@ proc check_effective_target_arm_thumb1 { } {
 proc check_effective_target_arm_thumb2 { } {
     return [check_no_compiler_messages arm_thumb2 assembly {
        #if !defined(__thumb2__)
-       #error FOO
+       #error !__thumb2__
        #endif
        int i;
     } ""]
@@ -2712,11 +2887,14 @@ proc check_effective_target_arm_cond_exec { } {
 # Return 1 if this is an ARM cortex-M profile cpu
 
 proc check_effective_target_arm_cortex_m { } {
+    if { ![istarget arm*-*-*] } {
+       return 0
+    }
     return [check_no_compiler_messages arm_cortex_m assembly {
        #if !defined(__ARM_ARCH_7M__) \
             && !defined (__ARM_ARCH_7EM__) \
             && !defined (__ARM_ARCH_6M__)
-       #error FOO
+       #error !__ARM_ARCH_7M__ && !__ARM_ARCH_7EM__ && !__ARM_ARCH_6M__
        #endif
        int i;
     } "-mthumb"]
@@ -2812,7 +2990,7 @@ proc check_effective_target_arm_neonv2 { } {
 proc check_effective_target_mips_loongson { } {
     return [check_no_compiler_messages loongson assembly {
        #if !defined(__mips_loongson_vector_rev)
-       #error FOO
+       #error !__mips_loongson_vector_rev
        #endif
     }]
 }
@@ -3205,8 +3383,7 @@ proc check_effective_target_vect_shift { } {
        if { ([istarget powerpc*-*-*]
              && ![istarget powerpc-*-linux*paired*])
             || [istarget ia64-*-*]
-            || [istarget i?86-*-*]
-            || [istarget x86_64-*-*]
+            || [istarget i?86-*-*] || [istarget x86_64-*-*]
             || [istarget aarch64*-*-*]
             || [check_effective_target_arm32]
             || ([istarget mips*-*-*]
@@ -3219,6 +3396,44 @@ proc check_effective_target_vect_shift { } {
     return $et_vect_shift_saved
 }
 
+proc check_effective_target_whole_vector_shift { } {
+    if { [istarget i?86-*-*] || [istarget x86_64-*-*]
+        || [istarget ia64-*-*]
+        || [istarget aarch64*-*-*]
+        || ([check_effective_target_arm32]
+            && [check_effective_target_arm_little_endian])
+        || ([istarget mips*-*-*]
+            && [check_effective_target_mips_loongson]) } {
+       set answer 1
+    } else {
+       set answer 0
+    }
+
+    verbose "check_effective_target_vect_long: returning $answer" 2
+    return $answer
+}
+
+# Return 1 if the target supports vector bswap operations.
+
+proc check_effective_target_vect_bswap { } {
+    global et_vect_bswap_saved
+
+    if [info exists et_vect_bswap_saved] {
+       verbose "check_effective_target_vect_bswap: using cached result" 2
+    } else {
+       set et_vect_bswap_saved 0
+       if { [istarget aarch64*-*-*]
+             || ([istarget arm*-*-*]
+                && [check_effective_target_arm_neon])
+          } {
+          set et_vect_bswap_saved 1
+       }
+    }
+
+    verbose "check_effective_target_vect_bswap: returning $et_vect_bswap_saved" 2
+    return $et_vect_bswap_saved
+}
+
 # Return 1 if the target supports hardware vector shift operation for char.
 
 proc check_effective_target_vect_shift_char { } {
@@ -3244,11 +3459,10 @@ proc check_effective_target_vect_shift_char { } {
 # This can change for different subtargets so do not cache the result.
 
 proc check_effective_target_vect_long { } {
-    if { [istarget i?86-*-*]
+    if { [istarget i?86-*-*] || [istarget x86_64-*-*]
         || (([istarget powerpc*-*-*] 
               && ![istarget powerpc-*-linux*paired*]) 
               && [check_effective_target_ilp32])
-        || [istarget x86_64-*-*]
         || [check_effective_target_arm32]
         || ([istarget sparc*-*-*] && [check_effective_target_ilp32]) } {
        set answer 1
@@ -3271,12 +3485,11 @@ proc check_effective_target_vect_float { } {
        verbose "check_effective_target_vect_float: using cached result" 2
     } else {
        set et_vect_float_saved 0
-       if { [istarget i?86-*-*]
+       if { [istarget i?86-*-*] || [istarget x86_64-*-*]
              || [istarget powerpc*-*-*]
              || [istarget spu-*-*]
              || [istarget mips-sde-elf]
              || [istarget mipsisa64*-*-*]
-             || [istarget x86_64-*-*]
              || [istarget ia64-*-*]
              || [istarget aarch64*-*-*]
              || [check_effective_target_arm32] } {
@@ -3299,9 +3512,8 @@ proc check_effective_target_vect_double { } {
        verbose "check_effective_target_vect_double: using cached result" 2
     } else {
        set et_vect_double_saved 0
-       if { [istarget i?86-*-*]
-             || [istarget aarch64*-*-*]
-             || [istarget x86_64-*-*] } {
+       if { [istarget i?86-*-*] || [istarget x86_64-*-*]
+            || [istarget aarch64*-*-*] } {
           if { [check_no_compiler_messages vect_double assembly {
                 #ifdef __tune_atom__
                 # error No double vectorizer support.
@@ -3331,8 +3543,7 @@ proc check_effective_target_vect_long_long { } {
         verbose "check_effective_target_vect_long_long: using cached result" 2
     } else {
         set et_vect_long_long_saved 0
-        if { [istarget i?86-*-*]
-              || [istarget x86_64-*-*] } {
+        if { [istarget i?86-*-*] || [istarget x86_64-*-*] } {
            set et_vect_long_long_saved 1
         }
     }
@@ -3420,8 +3631,7 @@ proc check_effective_target_vect_perm { } {
             || [istarget aarch64*-*-*]
             || [istarget powerpc*-*-*]
              || [istarget spu-*-*]
-            || [istarget i?86-*-*]
-            || [istarget x86_64-*-*]
+            || [istarget i?86-*-*] || [istarget x86_64-*-*]
             || ([istarget mips*-*-*]
                 && [check_effective_target_mpaired_single]) } {
             set et_vect_perm_saved 1
@@ -3445,7 +3655,8 @@ proc check_effective_target_vect_perm_byte { } {
         set et_vect_perm_byte_saved 0
         if { ([is-effective-target arm_neon_ok]
              && [is-effective-target arm_little_endian])
-            || [istarget aarch64*-*-*]
+            || ([istarget aarch64*-*-*]
+                && [is-effective-target aarch64_little_endian])
             || [istarget powerpc*-*-*]
              || [istarget spu-*-*] } {
             set et_vect_perm_byte_saved 1
@@ -3469,7 +3680,8 @@ proc check_effective_target_vect_perm_short { } {
         set et_vect_perm_short_saved 0
         if { ([is-effective-target arm_neon_ok]
              && [is-effective-target arm_little_endian])
-            || [istarget aarch64*-*-*]
+            || ([istarget aarch64*-*-*]
+                && [is-effective-target aarch64_little_endian])
             || [istarget powerpc*-*-*]
              || [istarget spu-*-*] } {
             set et_vect_perm_short_saved 1
@@ -3623,8 +3835,7 @@ proc check_effective_target_vect_widen_mult_hi_to_si { } {
              || [istarget spu-*-*]
              || [istarget ia64-*-*]
              || [istarget aarch64*-*-*]
-             || [istarget i?86-*-*]
-             || [istarget x86_64-*-*]
+             || [istarget i?86-*-*] || [istarget x86_64-*-*]
               || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
             set et_vect_widen_mult_hi_to_si_saved 1
         }
@@ -3671,8 +3882,7 @@ proc check_effective_target_vect_widen_mult_hi_to_si_pattern { } {
         if { [istarget powerpc*-*-*]
               || [istarget spu-*-*]
               || [istarget ia64-*-*]
-              || [istarget i?86-*-*]
-              || [istarget x86_64-*-*]
+              || [istarget i?86-*-*] || [istarget x86_64-*-*]
               || ([istarget arm*-*-*]
                  && [check_effective_target_arm_neon_ok]
                  && [check_effective_target_arm_little_endian]) } {
@@ -3683,6 +3893,27 @@ proc check_effective_target_vect_widen_mult_hi_to_si_pattern { } {
     return $et_vect_widen_mult_hi_to_si_pattern_saved
 }
 
+# Return 1 if the target plus current options supports a vector
+# widening multiplication of *int* args into *long* result, 0 otherwise.
+#
+# This won't change for different subtargets so cache the result.
+
+proc check_effective_target_vect_widen_mult_si_to_di_pattern { } {
+    global et_vect_widen_mult_si_to_di_pattern
+
+    if [info exists et_vect_widen_mult_si_to_di_pattern_saved] {
+        verbose "check_effective_target_vect_widen_mult_si_to_di_pattern: using cached result" 2
+    } else {
+       set et_vect_widen_mult_si_to_di_pattern_saved 0
+        if {[istarget ia64-*-*]
+           || [istarget i?86-*-*] || [istarget x86_64-*-*] } {
+            set et_vect_widen_mult_si_to_di_pattern_saved 1
+        }
+    }
+    verbose "check_effective_target_vect_widen_mult_si_to_di_pattern: returning $et_vect_widen_mult_si_to_di_pattern_saved" 2
+    return $et_vect_widen_mult_si_to_di_pattern_saved
+}
+
 # Return 1 if the target plus current options supports a vector
 # widening shift, 0 otherwise.
 #
@@ -3758,8 +3989,7 @@ proc check_effective_target_vect_sdot_hi { } {
         set et_vect_sdot_hi_saved 0
         if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
             || [istarget ia64-*-*]
-            || [istarget i?86-*-*]
-             || [istarget x86_64-*-*] } {
+            || [istarget i?86-*-*] || [istarget x86_64-*-*] } {
             set et_vect_sdot_hi_saved 1
         }
     }
@@ -3787,6 +4017,25 @@ proc check_effective_target_vect_udot_hi { } {
     return $et_vect_udot_hi_saved
 }
 
+# Return 1 if the target plus current options supports a vector
+# sad operation of unsigned chars, 0 otherwise.
+#
+# This won't change for different subtargets so cache the result.
+
+proc check_effective_target_vect_usad_char { } {
+    global et_vect_usad_char
+
+    if [info exists et_vect_usad_char_saved] {
+        verbose "check_effective_target_vect_usad_char: using cached result" 2
+    } else {
+        set et_vect_usad_char_saved 0
+        if { ([istarget i?86-*-*] || [istarget x86_64-*-*]) } {
+            set et_vect_usad_char_saved 1
+        }
+    }
+    verbose "check_effective_target_vect_usad_char: returning $et_vect_usad_char_saved" 2
+    return $et_vect_usad_char_saved
+}
 
 # Return 1 if the target plus current options supports a vector
 # demotion (packing) of shorts (to chars) and ints (to shorts) 
@@ -3802,8 +4051,7 @@ proc check_effective_target_vect_pack_trunc { } {
     } else {
         set et_vect_pack_trunc_saved 0
         if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
-             || [istarget i?86-*-*]
-             || [istarget x86_64-*-*]
+             || [istarget i?86-*-*] || [istarget x86_64-*-*]
              || [istarget aarch64*-*-*]
              || [istarget spu-*-*]
              || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]
@@ -3828,8 +4076,7 @@ proc check_effective_target_vect_unpack { } {
     } else {
         set et_vect_unpack_saved 0
         if { ([istarget powerpc*-*-*] && ![istarget powerpc-*paired*])
-             || [istarget i?86-*-*]
-             || [istarget x86_64-*-*] 
+             || [istarget i?86-*-*] || [istarget x86_64-*-*] 
              || [istarget spu-*-*]
              || [istarget ia64-*-*]
              || [istarget aarch64*-*-*]
@@ -3896,9 +4143,8 @@ proc check_effective_target_vect_hw_misalign { } {
         verbose "check_effective_target_vect_hw_misalign: using cached result" 2
     } else {
         set et_vect_hw_misalign_saved 0
-       if { ([istarget x86_64-*-*] 
-           || [istarget aarch64*-*-*]
-            || [istarget i?86-*-*]) } {
+       if { [istarget i?86-*-*] || [istarget x86_64-*-*]
+           || [istarget aarch64*-*-*] } {
           set et_vect_hw_misalign_saved 1
        }
     }
@@ -3988,7 +4234,8 @@ proc check_effective_target_vect_natural_alignment { } {
         verbose "check_effective_target_vect_natural_alignment: using cached result" 2
     } else {
         set et_vect_natural_alignment_saved 1
-        if { [check_effective_target_arm_eabi] } {
+        if { [check_effective_target_arm_eabi]
+            || [istarget nvptx-*-*] } {
             set et_vect_natural_alignment_saved 0
         }
     }
@@ -4070,9 +4317,8 @@ proc check_effective_target_vect_condition { } {
        if { [istarget aarch64*-*-*]
             || [istarget powerpc*-*-*]
             || [istarget ia64-*-*]
-            || [istarget i?86-*-*]
+            || [istarget i?86-*-*] || [istarget x86_64-*-*]
             || [istarget spu-*-*]
-            || [istarget x86_64-*-*]
             || ([istarget arm*-*-*] && [check_effective_target_arm_neon_ok]) } {
           set et_vect_cond_saved 1
        }
@@ -4092,8 +4338,7 @@ proc check_effective_target_vect_cond_mixed { } {
        verbose "check_effective_target_vect_cond_mixed: using cached result" 2
     } else {
        set et_vect_cond_mixed_saved 0
-       if { [istarget i?86-*-*]
-            || [istarget x86_64-*-*]
+       if { [istarget i?86-*-*] || [istarget x86_64-*-*]
             || [istarget powerpc*-*-*] } {
           set et_vect_cond_mixed_saved 1
        }
@@ -4114,8 +4359,7 @@ proc check_effective_target_vect_char_mult { } {
        set et_vect_char_mult_saved 0
        if { [istarget aarch64*-*-*]
             || [istarget ia64-*-*]
-            || [istarget i?86-*-*]
-            || [istarget x86_64-*-*]
+            || [istarget i?86-*-*] || [istarget x86_64-*-*]
             || [check_effective_target_arm32] } {
           set et_vect_char_mult_saved 1
        }
@@ -4136,8 +4380,7 @@ proc check_effective_target_vect_short_mult { } {
        set et_vect_short_mult_saved 0
        if { [istarget ia64-*-*]
             || [istarget spu-*-*]
-            || [istarget i?86-*-*]
-            || [istarget x86_64-*-*]
+            || [istarget i?86-*-*] || [istarget x86_64-*-*]
             || [istarget powerpc*-*-*]
             || [istarget aarch64*-*-*]
             || [check_effective_target_arm32]
@@ -4162,8 +4405,7 @@ proc check_effective_target_vect_int_mult { } {
        set et_vect_int_mult_saved 0
        if { ([istarget powerpc*-*-*] && ![istarget powerpc-*-linux*paired*])
             || [istarget spu-*-*]
-            || [istarget i?86-*-*]
-            || [istarget x86_64-*-*]
+            || [istarget i?86-*-*] || [istarget x86_64-*-*]
             || [istarget ia64-*-*]
             || [istarget aarch64*-*-*]
             || [check_effective_target_arm32] } {
@@ -4187,8 +4429,7 @@ proc check_effective_target_vect_extract_even_odd { } {
        if { [istarget aarch64*-*-*]
             || [istarget powerpc*-*-*]
             || [is-effective-target arm_neon_ok]
-             || [istarget i?86-*-*]
-             || [istarget x86_64-*-*]
+             || [istarget i?86-*-*] || [istarget x86_64-*-*]
              || [istarget ia64-*-*]
              || [istarget spu-*-*]
             || ([istarget mips*-*-*]
@@ -4213,8 +4454,7 @@ proc check_effective_target_vect_interleave { } {
        if { [istarget aarch64*-*-*]
             || [istarget powerpc*-*-*]
             || [is-effective-target arm_neon_ok]
-             || [istarget i?86-*-*]
-             || [istarget x86_64-*-*]
+             || [istarget i?86-*-*] || [istarget x86_64-*-*]
              || [istarget ia64-*-*]
              || [istarget spu-*-*]
             || ([istarget mips*-*-*]
@@ -4303,8 +4543,7 @@ proc check_effective_target_vect_call_copysignf { } {
        verbose "check_effective_target_vect_call_copysignf: using cached result" 2
     } else {
        set et_vect_call_copysignf_saved 0
-       if { [istarget i?86-*-*]
-            || [istarget x86_64-*-*]
+       if { [istarget i?86-*-*] || [istarget x86_64-*-*]
             || [istarget powerpc*-*-*] } {
           set et_vect_call_copysignf_saved 1
        }
@@ -4324,8 +4563,7 @@ proc check_effective_target_vect_call_sqrtf { } {
     } else {
        set et_vect_call_sqrtf_saved 0
        if { [istarget aarch64*-*-*]
-            || [istarget i?86-*-*]
-            || [istarget x86_64-*-*]
+            || [istarget i?86-*-*] || [istarget x86_64-*-*]
             || ([istarget powerpc*-*-*] && [check_vsx_hw_available]) } {
            set et_vect_call_sqrtf_saved 1
        }
@@ -4339,7 +4577,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] } {
+    if { ([istarget i?86-*-*] || [istarget x86_64-*-*])
+        && [check_effective_target_ilp32] } {
        set et_vect_call_lrint 1
     }
 
@@ -4621,8 +4860,7 @@ proc check_effective_target_sync_int_128_runtime { } {
 # Note: 32bit x86 targets require -march=pentium in dg-options.
 
 proc check_effective_target_sync_long_long { } {
-    if { [istarget x86_64-*-*]
-        || [istarget i?86-*-*])
+    if { [istarget x86_64-*-*] || [istarget i?86-*-*])
         || [istarget aarch64*-*-*]
         || [istarget arm*-*-*]
         || [istarget alpha*-*-*]
@@ -4639,8 +4877,7 @@ proc check_effective_target_sync_long_long { } {
 # Note: 32bit x86 targets require -march=pentium in dg-options.
 
 proc check_effective_target_sync_long_long_runtime { } {
-    if { [istarget x86_64-*-*]
-        || [istarget i?86-*-*] } {
+    if { [istarget x86_64-*-*] || [istarget i?86-*-*] } {
        return [check_cached_effective_target sync_long_long_available {
            check_runtime_nocache sync_long_long_available {
                #include "cpuid.h"
@@ -4684,6 +4921,97 @@ proc check_effective_target_sync_long_long_runtime { } {
     }
 }
 
+# Return 1 if the target supports byte swap instructions.
+
+proc check_effective_target_bswap { } {
+    global et_bswap_saved
+
+    if [info exists et_bswap_saved] {
+        verbose "check_effective_target_bswap: using cached result" 2
+    } else {
+       set et_bswap_saved 0
+       if { [istarget aarch64*-*-*]
+            || [istarget alpha*-*-*]
+            || [istarget i?86-*-*] || [istarget x86_64-*-*]
+            || [istarget m68k-*-*]
+            || [istarget powerpc*-*-*]
+            || [istarget rs6000-*-*]
+            || [istarget s390*-*-*] } {
+           set et_bswap_saved 1
+       } else {
+           if { [istarget arm*-*-*]
+                && [check_no_compiler_messages_nocache arm_v6_or_later object {
+                    #if __ARM_ARCH < 6
+                    #error not armv6 or later
+                    #endif
+                    int i;
+                } ""] } {
+               set et_bswap_saved 1
+           }
+       }
+    }
+
+    verbose "check_effective_target_bswap: returning $et_bswap_saved" 2
+    return $et_bswap_saved
+}
+
+# Return 1 if the target supports 16-bit byte swap instructions.
+
+proc check_effective_target_bswap16 { } {
+    global et_bswap16_saved
+
+    if [info exists et_bswap16_saved] {
+       verbose "check_effective_target_bswap16: using cached result" 2
+    } else {
+       set et_bswap16_saved 0
+       if { [is-effective-target bswap]
+            && ![istarget alpha*-*-*]
+            && !([istarget i?86-*-*] || [istarget x86_64-*-*]) } {
+          set et_bswap16_saved 1
+       }
+    }
+
+    verbose "check_effective_target_bswap16: returning $et_bswap16_saved" 2
+    return $et_bswap16_saved
+}
+
+# Return 1 if the target supports 32-bit byte swap instructions.
+
+proc check_effective_target_bswap32 { } {
+    global et_bswap32_saved
+
+    if [info exists et_bswap32_saved] {
+       verbose "check_effective_target_bswap32: using cached result" 2
+    } else {
+       set et_bswap32_saved 0
+       if { [is-effective-target bswap] } {
+          set et_bswap32_saved 1
+       }
+    }
+
+    verbose "check_effective_target_bswap32: returning $et_bswap32_saved" 2
+    return $et_bswap32_saved
+}
+
+# Return 1 if the target supports 64-bit byte swap instructions.
+
+proc check_effective_target_bswap64 { } {
+    global et_bswap64_saved
+
+    if [info exists et_bswap64_saved] {
+        verbose "check_effective_target_bswap64: using cached result" 2
+    } else {
+       set et_bswap64_saved 0
+       if { [is-effective-target bswap]
+            && [is-effective-target lp64] } {
+          set et_bswap64_saved 1
+       }
+    }
+
+    verbose "check_effective_target_bswap64: returning $et_bswap64_saved" 2
+    return $et_bswap64_saved
+}
+
 # Return 1 if the target supports atomic operations on "int" and "long".
 
 proc check_effective_target_sync_int_long { } {
@@ -4696,8 +5024,7 @@ proc check_effective_target_sync_int_long { } {
 # This is intentionally powerpc but not rs6000, rs6000 doesn't have the
 # load-reserved/store-conditional instructions.
         if { [istarget ia64-*-*]
-            || [istarget i?86-*-*]
-            || [istarget x86_64-*-*]
+            || [istarget i?86-*-*] || [istarget x86_64-*-*]
             || [istarget aarch64*-*-*]
             || [istarget alpha*-*-*] 
             || [istarget arm*-*-linux-*] 
@@ -4729,8 +5056,7 @@ proc check_effective_target_sync_char_short { } {
 # load-reserved/store-conditional instructions.
         if { [istarget aarch64*-*-*]
             || [istarget ia64-*-*]
-            || [istarget i?86-*-*]
-            || [istarget x86_64-*-*]
+            || [istarget i?86-*-*] || [istarget x86_64-*-*]
             || [istarget alpha*-*-*] 
             || [istarget arm*-*-linux-*] 
             || [istarget hppa*-*linux*]
@@ -4752,7 +5078,7 @@ proc check_effective_target_sync_char_short { } {
 proc check_effective_target_coldfire_fpu { } {
     return [check_no_compiler_messages coldfire_fpu assembly {
        #ifndef __mcffpu__
-       #error FOO
+       #error !__mcffpu__
        #endif
     }]
 }
@@ -4763,7 +5089,7 @@ proc check_effective_target_uclibc {} {
     return [check_no_compiler_messages uclibc object {
        #include <features.h>
        #if !defined (__UCLIBC__)
-       #error FOO
+       #error !__UCLIBC__
        #endif
     }]
 }
@@ -4799,6 +5125,30 @@ proc check_effective_target_non_bionic {} {
     }]
 }
 
+# Return true if this target has error.h header.
+
+proc check_effective_target_error_h {} {
+    return [check_no_compiler_messages error_h object {
+ #include <error.h>
+    }]
+}
+
+# Return true if this target has tgmath.h header.
+
+proc check_effective_target_tgmath_h {} {
+    return [check_no_compiler_messages tgmath_h object {
+ #include <tgmath.h>
+    }]
+}
+
+# Return true if target's libc supports complex functions.
+
+proc check_effective_target_libc_has_complex_functions {} {
+    return [check_no_compiler_messages libc_has_complex_functions object {
+ #include <complex.h>
+    }]
+}
+
 # Return 1 if
 #   (a) an error of a few ULP is expected in string to floating-point
 #       conversion functions; and
@@ -4842,6 +5192,7 @@ proc is-effective-target { arg } {
          "vsx_hw"         { set selected [check_vsx_hw_available] }
          "p8vector_hw"    { set selected [check_p8vector_hw_available] }
          "ppc_recip_hw"   { set selected [check_ppc_recip_hw_available] }
+         "dfp_hw"         { set selected [check_dfp_hw_available] }
          "named_sections" { set selected [check_named_sections_available] }
          "gc_sections"    { set selected [check_gc_sections_available] }
          "cxa_atexit"     { set selected [check_cxa_atexit_available] }
@@ -4864,6 +5215,7 @@ proc is-effective-target-keyword { arg } {
          "vsx_hw"         { return 1 }
          "p8vector_hw"    { return 1 }
          "ppc_recip_hw"   { return 1 }
+         "dfp_hw"         { return 1 }
          "named_sections" { return 1 }
          "gc_sections"    { return 1 }
          "cxa_atexit"     { return 1 }
@@ -5012,6 +5364,7 @@ proc check_effective_target_fd_truncate { } {
        #include <unistd.h>
        #include <stdio.h>
        #include <stdlib.h>
+       #include <string.h>
        int main ()
        {
          FILE *f = fopen ("tst.tmp", "wb");
@@ -5074,25 +5427,35 @@ proc add_options_for_ieee { flags } {
     return $flags
 }
 
+if {![info exists flags_to_postpone]} {
+    set flags_to_postpone ""
+}
+
 # Add to FLAGS the flags needed to enable functions to bind locally
 # when using pic/PIC passes in the testsuite.
-
 proc add_options_for_bind_pic_locally { flags } {
+    global flags_to_postpone
+
+    # Instead of returning 'flags' with the -fPIE or -fpie appended, we save it
+    # in 'flags_to_postpone' and append it later in gcc_target_compile procedure in
+    # order to make sure that the multilib_flags doesn't override this.
+
     if {[check_no_compiler_messages using_pic2 assembly {
         #if __PIC__ != 2
-        #error FOO
+        #error __PIC__ != 2
         #endif
     }]} {
-       return "$flags -fPIE"
+        set flags_to_postpone "-fPIE"
+        return $flags
     }
     if {[check_no_compiler_messages using_pic1 assembly {
         #if __PIC__ != 1
-        #error FOO
+        #error __PIC__ != 1
         #endif
     }]} {
-       return "$flags -fpie"
+        set flags_to_postpone "-fpie"
+        return $flags
     }
-
     return $flags
 }
 
@@ -5117,7 +5480,7 @@ proc check_effective_target_c99_runtime { } {
        close $file
        append contents {
            #ifndef HAVE_C99_RUNTIME
-           #error FOO
+           #error !HAVE_C99_RUNTIME
            #endif
        }
        check_no_compiler_messages_nocache c99_runtime assembly \
@@ -5163,7 +5526,11 @@ proc check_avx_available { } {
 # Return true if 32- and 16-bytes vectors are available.
 
 proc check_effective_target_vect_sizes_32B_16B { } {
-  return [check_avx_available];
+  if { [check_avx_available] && ![check_prefer_avx128] } {
+     return 1;
+  } else {
+    return 0;
+  }
 }
 
 # Return true if 128-bits vectors are preferred even if 256-bits vectors
@@ -5196,6 +5563,9 @@ proc check_effective_target_avx512f { } {
 # Return 1 if avx instructions can be compiled.
 
 proc check_effective_target_avx { } {
+    if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
+       return 0
+    }
     return [check_no_compiler_messages avx object {
        void _mm256_zeroall (void)
        {
@@ -5359,6 +5729,9 @@ proc check_effective_target_gld { } {
 
 proc check_effective_target_lto { } {
     global ENABLE_LTO
+    if { [istarget nvptx-*-*] } {
+       return 0;
+    }
     return [info exists ENABLE_LTO]
 }
 
@@ -5408,29 +5781,64 @@ proc check_effective_target_c++ { } {
  return 0
 }
 
-# Check which language standard is active by checking for the presence of
-# one of the C++11 -std flags.  This assumes that the default for the
-# compiler is C++98, and that there will never be multiple -std= arguments
-# on the command line.
-proc check_effective_target_c++11 { } {
+# Check whether the current active language standard supports the features
+# of C++11/C++14 by checking for the presence of one of the -std
+# flags.  This assumes that the default for the compiler is C++98, and that
+# there will never be multiple -std= arguments on the command line.
+proc check_effective_target_c++11_only { } {
     if ![check_effective_target_c++] {
        return 0
     }
     return [check-flags { { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 } }]
 }
+proc check_effective_target_c++11 { } {
+    if [check_effective_target_c++11_only] {
+       return 1
+    }
+    return [check_effective_target_c++14]
+}
+proc check_effective_target_c++11_down { } {
+    if ![check_effective_target_c++] {
+       return 0
+    }
+    return ![check_effective_target_c++14]
+}
 
-proc check_effective_target_c++1y { } {
+proc check_effective_target_c++14_only { } {
     if ![check_effective_target_c++] {
        return 0
     }
-    return [check-flags { { } { } { -std=c++1y -std=gnu++1y } }]
+    return [check-flags { { } { } { -std=c++14 -std=gnu++14 -std=c++14 -std=gnu++14 } }]
 }
 
-proc check_effective_target_c++98 { } {
+proc check_effective_target_c++14 { } {
+    if [check_effective_target_c++14_only] {
+       return 1
+    }
+    return [check_effective_target_c++1z]
+}
+proc check_effective_target_c++14_down { } {
     if ![check_effective_target_c++] {
        return 0
     }
-    return [check-flags { { } { } { } { -std=c++0x -std=gnu++0x -std=c++11 -std=gnu++11 -std=c++1y -std=gnu++1y } }]
+    return ![check_effective_target_c++1z]
+}
+
+proc check_effective_target_c++98_only { } {
+    if ![check_effective_target_c++] {
+       return 0
+    }
+    return ![check_effective_target_c++11]
+}
+
+proc check_effective_target_c++1z_only { } {
+    if ![check_effective_target_c++] {
+       return 0
+    }
+    return [check-flags { { } { } { -std=c++1z -std=gnu++1z } }]
+}
+proc check_effective_target_c++1z { } {
+    return [check_effective_target_c++1z_only]
 }
 
 # Return 1 if expensive testcases should be run.
@@ -5448,6 +5856,12 @@ proc check_effective_target_mempcpy {} {
     return [check_function_available "mempcpy"]
 }
 
+# Returns 1 if "stpcpy" is available on the target system.
+
+proc check_effective_target_stpcpy {} {
+    return [check_function_available "stpcpy"]
+}
+
 # Check whether the vectorizer tests are supported by the target and
 # append additional target-dependent compile flags to DEFAULT_VECTCFLAGS.
 # Set dg-do-what-default to either compile or run, depending on target
@@ -5546,6 +5960,8 @@ proc check_vect_support_and_set_flags { } {
     return 1
 }
 
+# Return 1 if the target does *not* require strict alignment.
+
 proc check_effective_target_non_strict_align {} {
     return [check_no_compiler_messages non_strict_align assembly {
        char *y;
@@ -5639,5 +6055,103 @@ proc check_effective_target_fenv_exceptions {} {
          else
            abort ();
        }
-    } "-std=gnu99"]
+    } [add_options_for_ieee "-std=gnu99"]]
+}
+
+proc check_effective_target_tiny {} {
+    global et_target_tiny_saved
+
+    if [info exists et_target_tine_saved] {
+      verbose "check_effective_target_tiny: using cached result" 2
+    } else {
+       set et_target_tiny_saved 0
+       if { [istarget aarch64*-*-*]
+             && [check_effective_target_aarch64_tiny] } {
+         set et_target_tiny_saved 1
+       }
+    }
+
+    return $et_target_tiny_saved
+}
+
+# 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 mmix-*-*]
+        || [istarget s390*-*-*]
+        || [istarget powerpc*-*-*]
+        || [istarget nios2*-*-*]
+        || [check_effective_target_arm_cortex_m] } {
+       return 1
+    }
+    return 0
+}
+
+# Record that dg-final test TEST requires convential compilation.
+
+proc force_conventional_output_for { test } {
+    if { [info proc $test] == "" } {
+       perror "$test does not exist"
+       exit 1
+    }
+    proc ${test}_required_options {} {
+       global gcc_force_conventional_output
+       return $gcc_force_conventional_output
+    }
+}
+
+# Return 1 if the x86-64 target supports PIE with copy reloc, 0
+# otherwise.  Cache the result.
+
+proc check_effective_target_pie_copyreloc { } {
+    global pie_copyreloc_available_saved
+    global tool
+    global GCC_UNDER_TEST
+
+    if { !([istarget x86_64-*-*] || [istarget i?86-*-*]) } {
+       return 0
+    }
+
+    # Need auto-host.h to check linker support.
+    if { ![file exists ../../auto-host.h ] } {
+       return 0
+    }
+
+    if [info exists pie_copyreloc_available_saved] {
+       verbose "check_effective_target_pie_copyreloc returning saved $pie_copyreloc_available_saved" 2
+    } else {
+       # Set up and compile to see if linker supports PIE with copy
+       # reloc.  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 HAVE_LD_PIE_COPYRELOC == 0"
+       puts $f "# error Linker does not support PIE with copy reloc."
+       puts $f "#endif"
+       close $f
+
+       verbose "check_effective_target_pie_copyreloc 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_pie_copyreloc testfile compilation passed" 2
+           set pie_copyreloc_available_saved 1
+       } else {
+           verbose "check_effective_target_pie_copyreloc testfile compilation failed" 2
+           set pie_copyreloc_available_saved 0
+       }
+    }
+
+    return $pie_copyreloc_available_saved
 }