OSDN Git Service

85c6e042dc65e6b69555fad398db45e1c3d3a9a1
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.target / i386 / i386.exp
1 # Copyright (C) 1997, 2004, 2007, 2008, 2009, 2010
2 # Free Software Foundation, Inc.
3
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.
8
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.
13
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/>.
17
18 # GCC testsuite that uses the `dg.exp' driver.
19
20 # Exit immediately if this isn't a x86 target.
21 if { ![istarget i?86*-*-*] && ![istarget x86_64-*-*] } then {
22   return
23 }
24
25 # Load support procs.
26 load_lib gcc-dg.exp
27
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 ();
33          } ""] } {
34         return 1
35     } else {
36         return 0
37     }
38 }
39
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)));
45
46         __m128i _mm_abs_epi32 (__m128i __X)
47         {
48             return (__m128i) __builtin_ia32_pabsd128 ((__v4si)__X);
49         }
50     } "-O2 -mssse3" ]
51 }
52
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)));
58
59         __m128i _mm_mullo_epi32 (__m128i __X, __m128i __Y)
60         {
61             return (__m128i) __builtin_ia32_pmulld128 ((__v4si)__X,
62                                                        (__v4si)__Y);
63         }
64     } "-O2 -msse4.1" ]
65 }
66
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)));
72
73         __m128i _mm_aesimc_si128 (__m128i __X)
74         {
75             return (__m128i) __builtin_ia32_aesimc128 ((__v2di)__X);
76         }
77     } "-O2 -maes" ]
78 }
79
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)));
85
86         __m128i _mm_aesimc_si128 (__m128i __X)
87         {
88             return (__m128i) __builtin_ia32_aesimc128 ((__v2di)__X);
89         }
90     } "-O2 -maes -mavx" ]
91 }
92
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)));
98
99         __m128i pclmulqdq_test (__m128i __X, __m128i __Y)
100         {
101             return (__m128i) __builtin_ia32_pclmulqdq128 ((__v2di)__X,
102                                                           (__v2di)__Y,
103                                                           1);
104         }
105     } "-O2 -mpclmul" ]
106 }
107
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)));
113
114         __m128i pclmulqdq_test (__m128i __X, __m128i __Y)
115         {
116             return (__m128i) __builtin_ia32_pclmulqdq128 ((__v2di)__X,
117                                                           (__v2di)__Y,
118                                                           1);
119         }
120     } "-O2 -mpclmul -mavx" ]
121 }
122
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)));
128
129         __m128i _mm_insert_si64 (__m128i __X,__m128i __Y)
130         {
131             return (__m128i) __builtin_ia32_insertq ((__v2di)__X, (__v2di)__Y);
132         }
133     } "-O2 -msse4a" ]
134 }
135
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)
142         {
143             return (__m128) __builtin_ia32_vfmaddps ((__v4sf)__A,
144                                                      (__v4sf)__B,
145                                                      (__v4sf)__C);
146         }
147     } "-O2 -mfma4" ]
148 }
149
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)
156         {
157             return (__m128i) __builtin_ia32_vpmacssww ((__v8hi)__A,
158                                                        (__v8hi)__B,
159                                                        (__v8hi)__C);
160         }
161     } "-O2 -mxop" ]
162 }
163
164 # If the linker used understands -M <mapfile>, pass it to clear hardware
165 # capabilities set by the Sun assembler.
166 set FLAGS ""
167 set clearcap_ldflags "-Wl,-M,$srcdir/$subdir/clearcap.map"
168
169 if [check_no_compiler_messages mapfile executable {
170         int main (void) { return 0; }
171   } $clearcap_ldflags ] {
172   set FLAGS $clearcap_ldflags
173 }
174
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"
179 }
180
181 # Initialize `dg'.
182 dg-init
183
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 ""
191   }
192 }
193
194 # Everything else.
195 set tests [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]]
196 set tests [prune $tests $srcdir/$subdir/vect-args.c]
197
198 # Main loop.
199 dg-runtest $tests $FLAGS $DEFAULT_CFLAGS
200
201 # All done.
202 dg-finish