1 # Copyright (C) 1997, 2004, 2007, 2008, 2009, 2010
2 # Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with GCC; see the file COPYING3. If not see
16 # <http://www.gnu.org/licenses/>.
18 # GCC testsuite that uses the `dg.exp' driver.
20 # Exit immediately if this isn't a x86 target.
21 if { ![istarget i?86*-*-*] && ![istarget x86_64-*-*] } then {
28 # Return 1 if attribute ms_hook_prologue is supported.
29 proc check_effective_target_ms_hook_prologue { } {
30 if { [check_effective_target_ilp32]
31 && [check_no_compiler_messages ms_hook_prologue object {
32 void __attribute__ ((__ms_hook_prologue__)) foo ();
40 # Return 1 if ssse3 instructions can be compiled.
41 proc check_effective_target_ssse3 { } {
42 return [check_no_compiler_messages ssse3 object {
43 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
44 typedef int __v4si __attribute__ ((__vector_size__ (16)));
46 __m128i _mm_abs_epi32 (__m128i __X)
48 return (__m128i) __builtin_ia32_pabsd128 ((__v4si)__X);
53 # Return 1 if sse4 instructions can be compiled.
54 proc check_effective_target_sse4 { } {
55 return [check_no_compiler_messages sse4.1 object {
56 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
57 typedef int __v4si __attribute__ ((__vector_size__ (16)));
59 __m128i _mm_mullo_epi32 (__m128i __X, __m128i __Y)
61 return (__m128i) __builtin_ia32_pmulld128 ((__v4si)__X,
67 # Return 1 if aes instructions can be compiled.
68 proc check_effective_target_aes { } {
69 return [check_no_compiler_messages aes object {
70 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
71 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
73 __m128i _mm_aesimc_si128 (__m128i __X)
75 return (__m128i) __builtin_ia32_aesimc128 ((__v2di)__X);
80 # Return 1 if vaes instructions can be compiled.
81 proc check_effective_target_vaes { } {
82 return [check_no_compiler_messages vaes object {
83 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
84 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
86 __m128i _mm_aesimc_si128 (__m128i __X)
88 return (__m128i) __builtin_ia32_aesimc128 ((__v2di)__X);
93 # Return 1 if pclmul instructions can be compiled.
94 proc check_effective_target_pclmul { } {
95 return [check_no_compiler_messages pclmul object {
96 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
97 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
99 __m128i pclmulqdq_test (__m128i __X, __m128i __Y)
101 return (__m128i) __builtin_ia32_pclmulqdq128 ((__v2di)__X,
108 # Return 1 if vpclmul instructions can be compiled.
109 proc check_effective_target_vpclmul { } {
110 return [check_no_compiler_messages vpclmul object {
111 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
112 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
114 __m128i pclmulqdq_test (__m128i __X, __m128i __Y)
116 return (__m128i) __builtin_ia32_pclmulqdq128 ((__v2di)__X,
120 } "-O2 -mpclmul -mavx" ]
123 # Return 1 if sse4a instructions can be compiled.
124 proc check_effective_target_sse4a { } {
125 return [check_no_compiler_messages sse4a object {
126 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
127 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
129 __m128i _mm_insert_si64 (__m128i __X,__m128i __Y)
131 return (__m128i) __builtin_ia32_insertq ((__v2di)__X, (__v2di)__Y);
136 # Return 1 if fma4 instructions can be compiled.
137 proc check_effective_target_fma4 { } {
138 return [check_no_compiler_messages fma4 object {
139 typedef float __m128 __attribute__ ((__vector_size__ (16)));
140 typedef float __v4sf __attribute__ ((__vector_size__ (16)));
141 __m128 _mm_macc_ps(__m128 __A, __m128 __B, __m128 __C)
143 return (__m128) __builtin_ia32_vfmaddps ((__v4sf)__A,
150 # Return 1 if xop instructions can be compiled.
151 proc check_effective_target_xop { } {
152 return [check_no_compiler_messages xop object {
153 typedef long long __m128i __attribute__ ((__vector_size__ (16), __may_alias__));
154 typedef short __v8hi __attribute__ ((__vector_size__ (16)));
155 __m128i _mm_maccs_epi16(__m128i __A, __m128i __B, __m128i __C)
157 return (__m128i) __builtin_ia32_vpmacssww ((__v8hi)__A,
164 # If the linker used understands -M <mapfile>, pass it to clear hardware
165 # capabilities set by the Sun assembler.
167 set clearcap_ldflags "-Wl,-M,$srcdir/$subdir/clearcap.map"
169 if [check_no_compiler_messages mapfile executable {
170 int main (void) { return 0; }
171 } $clearcap_ldflags ] {
172 set FLAGS $clearcap_ldflags
175 # If a testcase doesn't have special options, use these.
176 global DEFAULT_CFLAGS
177 if ![info exists DEFAULT_CFLAGS] then {
178 set DEFAULT_CFLAGS " -ansi -pedantic-errors"
184 # Special case compilation of vect-args.c so we don't have to
185 # replicate it 10 times.
186 foreach type { "" -mmmx -m3dnow -msse -msse2 } {
187 foreach level { "" -O } {
188 set flags "$type $level"
189 verbose -log "Testing vect-args, $flags" 1
190 dg-test $srcdir/$subdir/vect-args.c $flags ""
195 set tests [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]]
196 set tests [prune $tests $srcdir/$subdir/vect-args.c]
199 dg-runtest $tests $FLAGS $DEFAULT_CFLAGS