OSDN Git Service

2009-09-29 Harsha Jagasia <harsha.jagasia@amd.com>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.target / i386 / i386.exp
1 # Copyright (C) 1997, 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
7
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
12
13 # You should have received a copy of the GNU General Public License
14 # along with GCC; see the file COPYING3.  If not see
15 # <http://www.gnu.org/licenses/>.
16
17 # GCC testsuite that uses the `dg.exp' driver.
18
19 # Exit immediately if this isn't a x86 target.
20 if { ![istarget i?86*-*-*] && ![istarget x86_64-*-*] } then {
21   return
22 }
23
24 # Load support procs.
25 load_lib gcc-dg.exp
26
27 # Return 1 if ssse3 instructions can be compiled.
28 proc check_effective_target_ssse3 { } {
29     return [check_no_compiler_messages ssse3 object {
30         typedef long long __m128i __attribute__ ((__vector_size__ (16)));
31         typedef int __v4si __attribute__ ((__vector_size__ (16)));
32
33         __m128i _mm_abs_epi32 (__m128i __X)
34         {
35             return (__m128i) __builtin_ia32_pabsd128 ((__v4si)__X);
36         }
37     } "-O2 -mssse3" ]
38 }
39
40 # Return 1 if sse4 instructions can be compiled.
41 proc check_effective_target_sse4 { } {
42     return [check_no_compiler_messages sse4.1 object {
43         typedef long long __m128i __attribute__ ((__vector_size__ (16)));
44         typedef int __v4si __attribute__ ((__vector_size__ (16)));
45
46         __m128i _mm_mullo_epi32 (__m128i __X, __m128i __Y)
47         {
48             return (__m128i) __builtin_ia32_pmulld128 ((__v4si)__X,
49                                                        (__v4si)__Y);
50         }
51     } "-O2 -msse4.1" ]
52 }
53
54 # Return 1 if aes instructions can be compiled.
55 proc check_effective_target_aes { } {
56     return [check_no_compiler_messages aes object {
57         typedef long long __m128i __attribute__ ((__vector_size__ (16)));
58         typedef long long __v2di __attribute__ ((__vector_size__ (16)));
59
60         __m128i _mm_aesimc_si128 (__m128i __X)
61         {
62             return (__m128i) __builtin_ia32_aesimc128 ((__v2di)__X);
63         }
64     } "-O2 -maes" ]
65 }
66
67 # Return 1 if vaes instructions can be compiled.
68 proc check_effective_target_vaes { } {
69     return [check_no_compiler_messages vaes 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 -mavx" ]
78 }
79
80 # Return 1 if pclmul instructions can be compiled.
81 proc check_effective_target_pclmul { } {
82     return [check_no_compiler_messages pclmul object {
83         typedef long long __m128i __attribute__ ((__vector_size__ (16)));
84         typedef long long __v2di __attribute__ ((__vector_size__ (16)));
85
86         __m128i pclmulqdq_test (__m128i __X, __m128i __Y)
87         {
88             return (__m128i) __builtin_ia32_pclmulqdq128 ((__v2di)__X,
89                                                           (__v2di)__Y,
90                                                           1);
91         }
92     } "-O2 -mpclmul" ]
93 }
94
95 # Return 1 if vpclmul instructions can be compiled.
96 proc check_effective_target_vpclmul { } {
97     return [check_no_compiler_messages vpclmul object {
98         typedef long long __m128i __attribute__ ((__vector_size__ (16)));
99         typedef long long __v2di __attribute__ ((__vector_size__ (16)));
100
101         __m128i pclmulqdq_test (__m128i __X, __m128i __Y)
102         {
103             return (__m128i) __builtin_ia32_pclmulqdq128 ((__v2di)__X,
104                                                           (__v2di)__Y,
105                                                           1);
106         }
107     } "-O2 -mpclmul -mavx" ]
108 }
109
110 # Return 1 if sse4a instructions can be compiled.
111 proc check_effective_target_sse4a { } {
112     return [check_no_compiler_messages sse4a object {
113         typedef long long __m128i __attribute__ ((__vector_size__ (16)));
114         typedef long long __v2di __attribute__ ((__vector_size__ (16)));
115
116         __m128i _mm_insert_si64 (__m128i __X,__m128i __Y)
117         {
118             return (__m128i) __builtin_ia32_insertq ((__v2di)__X, (__v2di)__Y);
119         }
120     } "-O2 -msse4a" ]
121 }
122
123 # If a testcase doesn't have special options, use these.
124 global DEFAULT_CFLAGS
125 if ![info exists DEFAULT_CFLAGS] then {
126     set DEFAULT_CFLAGS " -ansi -pedantic-errors"
127 }
128
129 # Initialize `dg'.
130 dg-init
131
132 # Special case compilation of vect-args.c so we don't have to
133 # replicate it 10 times.
134 foreach type { "" -mmmx -m3dnow -msse -msse2 } {
135   foreach level { "" -O } {
136     set flags "$type $level"
137     verbose -log "Testing vect-args, $flags" 1
138     dg-test $srcdir/$subdir/vect-args.c $flags ""
139   }
140 }
141
142 # Everything else.
143 set tests [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]]
144 set tests [prune $tests $srcdir/$subdir/vect-args.c]
145
146 # Main loop.
147 dg-runtest $tests "" $DEFAULT_CFLAGS
148
149 # All done.
150 dg-finish