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_no_compiler_messages ms_hook_prologue object {
31 void __attribute__ ((__ms_hook_prologue__)) foo ();
39 # Return 1 if 3dnow instructions can be compiled.
40 proc check_effective_target_3dnow { } {
41 return [check_no_compiler_messages 3dnow object {
42 typedef int __m64 __attribute__ ((__vector_size__ (8)));
43 typedef float __v2sf __attribute__ ((__vector_size__ (8)));
45 __m64 _m_pfadd (__m64 __A, __m64 __B)
47 return (__m64) __builtin_ia32_pfadd ((__v2sf)__A, (__v2sf)__B);
52 # Return 1 if sse3 instructions can be compiled.
53 proc check_effective_target_sse3 { } {
54 return [check_no_compiler_messages sse3 object {
55 typedef double __m128d __attribute__ ((__vector_size__ (16)));
56 typedef double __v2df __attribute__ ((__vector_size__ (16)));
58 __m128d _mm_addsub_pd (__m128d __X, __m128d __Y)
60 return (__m128d) __builtin_ia32_addsubpd ((__v2df)__X, (__v2df)__Y);
65 # Return 1 if ssse3 instructions can be compiled.
66 proc check_effective_target_ssse3 { } {
67 return [check_no_compiler_messages ssse3 object {
68 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
69 typedef int __v4si __attribute__ ((__vector_size__ (16)));
71 __m128i _mm_abs_epi32 (__m128i __X)
73 return (__m128i) __builtin_ia32_pabsd128 ((__v4si)__X);
78 # Return 1 if sse4 instructions can be compiled.
79 proc check_effective_target_sse4 { } {
80 return [check_no_compiler_messages sse4.1 object {
81 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
82 typedef int __v4si __attribute__ ((__vector_size__ (16)));
84 __m128i _mm_mullo_epi32 (__m128i __X, __m128i __Y)
86 return (__m128i) __builtin_ia32_pmulld128 ((__v4si)__X,
92 # Return 1 if aes instructions can be compiled.
93 proc check_effective_target_aes { } {
94 return [check_no_compiler_messages aes object {
95 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
96 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
98 __m128i _mm_aesimc_si128 (__m128i __X)
100 return (__m128i) __builtin_ia32_aesimc128 ((__v2di)__X);
105 # Return 1 if vaes instructions can be compiled.
106 proc check_effective_target_vaes { } {
107 return [check_no_compiler_messages vaes object {
108 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
109 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
111 __m128i _mm_aesimc_si128 (__m128i __X)
113 return (__m128i) __builtin_ia32_aesimc128 ((__v2di)__X);
115 } "-O2 -maes -mavx" ]
118 # Return 1 if pclmul instructions can be compiled.
119 proc check_effective_target_pclmul { } {
120 return [check_no_compiler_messages pclmul object {
121 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
122 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
124 __m128i pclmulqdq_test (__m128i __X, __m128i __Y)
126 return (__m128i) __builtin_ia32_pclmulqdq128 ((__v2di)__X,
133 # Return 1 if vpclmul instructions can be compiled.
134 proc check_effective_target_vpclmul { } {
135 return [check_no_compiler_messages vpclmul object {
136 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
137 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
139 __m128i pclmulqdq_test (__m128i __X, __m128i __Y)
141 return (__m128i) __builtin_ia32_pclmulqdq128 ((__v2di)__X,
145 } "-O2 -mpclmul -mavx" ]
148 # Return 1 if sse4a instructions can be compiled.
149 proc check_effective_target_sse4a { } {
150 return [check_no_compiler_messages sse4a object {
151 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
152 typedef long long __v2di __attribute__ ((__vector_size__ (16)));
154 __m128i _mm_insert_si64 (__m128i __X,__m128i __Y)
156 return (__m128i) __builtin_ia32_insertq ((__v2di)__X, (__v2di)__Y);
161 # Return 1 if fma4 instructions can be compiled.
162 proc check_effective_target_fma4 { } {
163 return [check_no_compiler_messages fma4 object {
164 typedef float __m128 __attribute__ ((__vector_size__ (16)));
165 typedef float __v4sf __attribute__ ((__vector_size__ (16)));
166 __m128 _mm_macc_ps(__m128 __A, __m128 __B, __m128 __C)
168 return (__m128) __builtin_ia32_vfmaddps ((__v4sf)__A,
175 # Return 1 if xop instructions can be compiled.
176 proc check_effective_target_xop { } {
177 return [check_no_compiler_messages xop object {
178 typedef long long __m128i __attribute__ ((__vector_size__ (16)));
179 typedef short __v8hi __attribute__ ((__vector_size__ (16)));
180 __m128i _mm_maccs_epi16(__m128i __A, __m128i __B, __m128i __C)
182 return (__m128i) __builtin_ia32_vpmacssww ((__v8hi)__A,
189 # Return 1 if lzcnt instruction can be compiled.
190 proc check_effective_target_lzcnt { } {
191 return [check_no_compiler_messages lzcnt object {
192 unsigned short _lzcnt (unsigned short __X)
194 return __builtin_clzs (__X);
199 # Return 1 if bmi instructions can be compiled.
200 proc check_effective_target_bmi { } {
201 return [check_no_compiler_messages bmi object {
202 unsigned int __bextr_u32 (unsigned int __X, unsigned int __Y)
204 return __builtin_ia32_bextr_u32 (__X, __Y);
209 # If the linker used understands -M <mapfile>, pass it to clear hardware
210 # capabilities set by the Sun assembler.
211 set clearcap_ldflags "-Wl,-M,$srcdir/$subdir/clearcap.map"
213 if [check_no_compiler_messages mapfile executable {
214 int main (void) { return 0; }
215 } $clearcap_ldflags ] {
217 if { [info procs gcc_target_compile] != [list] \
218 && [info procs saved_gcc_target_compile] == [list] } {
219 rename gcc_target_compile saved_gcc_target_compile
221 proc gcc_target_compile { source dest type options } {
222 global clearcap_ldflags
223 # Always pass -Wl,-M,<mapfile>, but don't let it show up in gcc.sum.
224 lappend options "additional_flags=$clearcap_ldflags"
226 return [saved_gcc_target_compile $source $dest $type $options]
231 # If a testcase doesn't have special options, use these.
232 global DEFAULT_CFLAGS
233 if ![info exists DEFAULT_CFLAGS] then {
234 set DEFAULT_CFLAGS " -ansi -pedantic-errors"
240 # Special case compilation of vect-args.c so we don't have to
241 # replicate it 10 times.
242 foreach type { "" -mmmx -m3dnow -msse -msse2 } {
243 foreach level { "" -O } {
244 set flags "$type $level"
245 verbose -log "Testing vect-args, $flags" 1
246 dg-test $srcdir/$subdir/vect-args.c $flags ""
251 set tests [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]]
252 set tests [prune $tests $srcdir/$subdir/vect-args.c]
255 dg-runtest $tests "" $DEFAULT_CFLAGS