System: Add SwapByteOrder and update Support/MathExtras.h to use it.
[oota-llvm.git] / include / llvm / IntrinsicsX86.td
1 //===- IntrinsicsX86.td - Defines X86 intrinsics -----------*- tablegen -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines all of the X86-specific intrinsics.
11 //
12 //===----------------------------------------------------------------------===//
13
14 //===----------------------------------------------------------------------===//
15 // Interrupt traps
16 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
17   def int_x86_int : Intrinsic<[], [llvm_i8_ty]>;
18 }
19
20 //===----------------------------------------------------------------------===//
21 // SSE1
22
23 // Arithmetic ops
24 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
25   def int_x86_sse_add_ss : GCCBuiltin<"__builtin_ia32_addss">,
26               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
27                          llvm_v4f32_ty], [IntrNoMem]>;
28   def int_x86_sse_sub_ss : GCCBuiltin<"__builtin_ia32_subss">,
29               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
30                          llvm_v4f32_ty], [IntrNoMem]>;
31   def int_x86_sse_mul_ss : GCCBuiltin<"__builtin_ia32_mulss">,
32               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
33                          llvm_v4f32_ty], [IntrNoMem]>;
34   def int_x86_sse_div_ss : GCCBuiltin<"__builtin_ia32_divss">,
35               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
36                          llvm_v4f32_ty], [IntrNoMem]>;
37   def int_x86_sse_sqrt_ss : GCCBuiltin<"__builtin_ia32_sqrtss">,
38               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty],
39                         [IntrNoMem]>;
40   def int_x86_sse_sqrt_ps : GCCBuiltin<"__builtin_ia32_sqrtps">,
41               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty],
42                         [IntrNoMem]>;
43   def int_x86_sse_rcp_ss : GCCBuiltin<"__builtin_ia32_rcpss">,
44               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty],
45                         [IntrNoMem]>;
46   def int_x86_sse_rcp_ps : GCCBuiltin<"__builtin_ia32_rcpps">,
47               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty],
48                         [IntrNoMem]>;
49   def int_x86_sse_rsqrt_ss : GCCBuiltin<"__builtin_ia32_rsqrtss">,
50               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty],
51                         [IntrNoMem]>;
52   def int_x86_sse_rsqrt_ps : GCCBuiltin<"__builtin_ia32_rsqrtps">,
53               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty],
54                         [IntrNoMem]>;
55   def int_x86_sse_min_ss : GCCBuiltin<"__builtin_ia32_minss">,
56               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
57                          llvm_v4f32_ty], [IntrNoMem]>;
58   def int_x86_sse_min_ps : GCCBuiltin<"__builtin_ia32_minps">,
59               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
60                          llvm_v4f32_ty], [IntrNoMem]>;
61   def int_x86_sse_max_ss : GCCBuiltin<"__builtin_ia32_maxss">,
62               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
63                          llvm_v4f32_ty], [IntrNoMem]>;
64   def int_x86_sse_max_ps : GCCBuiltin<"__builtin_ia32_maxps">,
65               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
66                          llvm_v4f32_ty], [IntrNoMem]>;
67 }
68
69 // Comparison ops
70 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
71   def int_x86_sse_cmp_ss :
72               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
73                          llvm_v4f32_ty, llvm_i8_ty], [IntrNoMem]>;
74   def int_x86_sse_cmp_ps :
75               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
76                          llvm_v4f32_ty, llvm_i8_ty], [IntrNoMem]>;
77   def int_x86_sse_comieq_ss : GCCBuiltin<"__builtin_ia32_comieq">,
78               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
79                          llvm_v4f32_ty], [IntrNoMem]>;
80   def int_x86_sse_comilt_ss : GCCBuiltin<"__builtin_ia32_comilt">,
81               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
82                          llvm_v4f32_ty], [IntrNoMem]>;
83   def int_x86_sse_comile_ss : GCCBuiltin<"__builtin_ia32_comile">,
84               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
85                          llvm_v4f32_ty], [IntrNoMem]>;
86   def int_x86_sse_comigt_ss : GCCBuiltin<"__builtin_ia32_comigt">,
87               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
88                          llvm_v4f32_ty], [IntrNoMem]>;
89   def int_x86_sse_comige_ss : GCCBuiltin<"__builtin_ia32_comige">,
90               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
91                          llvm_v4f32_ty], [IntrNoMem]>;
92   def int_x86_sse_comineq_ss : GCCBuiltin<"__builtin_ia32_comineq">,
93               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
94                          llvm_v4f32_ty], [IntrNoMem]>;
95   def int_x86_sse_ucomieq_ss : GCCBuiltin<"__builtin_ia32_ucomieq">,
96               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
97                          llvm_v4f32_ty], [IntrNoMem]>;
98   def int_x86_sse_ucomilt_ss : GCCBuiltin<"__builtin_ia32_ucomilt">,
99               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
100                          llvm_v4f32_ty], [IntrNoMem]>;
101   def int_x86_sse_ucomile_ss : GCCBuiltin<"__builtin_ia32_ucomile">,
102               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
103                          llvm_v4f32_ty], [IntrNoMem]>;
104   def int_x86_sse_ucomigt_ss : GCCBuiltin<"__builtin_ia32_ucomigt">,
105               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
106                          llvm_v4f32_ty], [IntrNoMem]>;
107   def int_x86_sse_ucomige_ss : GCCBuiltin<"__builtin_ia32_ucomige">,
108               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
109                          llvm_v4f32_ty], [IntrNoMem]>;
110   def int_x86_sse_ucomineq_ss : GCCBuiltin<"__builtin_ia32_ucomineq">,
111               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
112                          llvm_v4f32_ty], [IntrNoMem]>;
113 }
114
115
116 // Conversion ops
117 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
118   def int_x86_sse_cvtss2si : GCCBuiltin<"__builtin_ia32_cvtss2si">,
119               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
120   def int_x86_sse_cvtss2si64 : GCCBuiltin<"__builtin_ia32_cvtss2si64">,
121               Intrinsic<[llvm_i64_ty], [llvm_v4f32_ty], [IntrNoMem]>;
122   def int_x86_sse_cvttss2si : GCCBuiltin<"__builtin_ia32_cvttss2si">,
123               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
124   def int_x86_sse_cvttss2si64 : GCCBuiltin<"__builtin_ia32_cvttss2si64">,
125               Intrinsic<[llvm_i64_ty], [llvm_v4f32_ty], [IntrNoMem]>;
126   def int_x86_sse_cvtsi2ss : GCCBuiltin<"__builtin_ia32_cvtsi2ss">,
127               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
128                          llvm_i32_ty], [IntrNoMem]>;
129   def int_x86_sse_cvtsi642ss : GCCBuiltin<"__builtin_ia32_cvtsi642ss">,
130               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
131                          llvm_i64_ty], [IntrNoMem]>;
132   def int_x86_sse_cvtps2pi : GCCBuiltin<"__builtin_ia32_cvtps2pi">,
133               Intrinsic<[llvm_x86mmx_ty], [llvm_v4f32_ty], [IntrNoMem]>;
134   def int_x86_sse_cvttps2pi: GCCBuiltin<"__builtin_ia32_cvttps2pi">,
135               Intrinsic<[llvm_x86mmx_ty], [llvm_v4f32_ty], [IntrNoMem]>;
136   def int_x86_sse_cvtpi2ps : GCCBuiltin<"__builtin_ia32_cvtpi2ps">,
137               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
138                          llvm_x86mmx_ty], [IntrNoMem]>;
139 }
140
141 // SIMD load ops
142 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
143   def int_x86_sse_loadu_ps : GCCBuiltin<"__builtin_ia32_loadups">,
144               Intrinsic<[llvm_v4f32_ty], [llvm_ptr_ty], [IntrReadMem]>;
145 }
146
147 // SIMD store ops
148 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
149   def int_x86_sse_storeu_ps : GCCBuiltin<"__builtin_ia32_storeups">,
150               Intrinsic<[], [llvm_ptr_ty,
151                          llvm_v4f32_ty], []>;
152 }
153
154 // Cacheability support ops
155 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
156   def int_x86_sse_movnt_ps : GCCBuiltin<"__builtin_ia32_movntps">,
157               Intrinsic<[], [llvm_ptr_ty,
158                          llvm_v4f32_ty], []>;
159   def int_x86_sse_sfence : GCCBuiltin<"__builtin_ia32_sfence">,
160               Intrinsic<[], [], []>;
161 }
162
163 // Control register.
164 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
165   def int_x86_sse_stmxcsr :
166               Intrinsic<[], [llvm_ptr_ty], []>;
167   def int_x86_sse_ldmxcsr :
168               Intrinsic<[], [llvm_ptr_ty], []>;
169 }
170
171 // Misc.
172 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
173   def int_x86_sse_movmsk_ps : GCCBuiltin<"__builtin_ia32_movmskps">,
174               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
175 }
176
177 //===----------------------------------------------------------------------===//
178 // SSE2
179
180 // FP arithmetic ops
181 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
182   def int_x86_sse2_add_sd : GCCBuiltin<"__builtin_ia32_addsd">,
183               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
184                          llvm_v2f64_ty], [IntrNoMem]>;
185   def int_x86_sse2_sub_sd : GCCBuiltin<"__builtin_ia32_subsd">,
186               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
187                          llvm_v2f64_ty], [IntrNoMem]>;
188   def int_x86_sse2_mul_sd : GCCBuiltin<"__builtin_ia32_mulsd">,
189               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
190                          llvm_v2f64_ty], [IntrNoMem]>;
191   def int_x86_sse2_div_sd : GCCBuiltin<"__builtin_ia32_divsd">,
192               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
193                          llvm_v2f64_ty], [IntrNoMem]>;
194   def int_x86_sse2_sqrt_sd : GCCBuiltin<"__builtin_ia32_sqrtsd">,
195               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty],
196                         [IntrNoMem]>;
197   def int_x86_sse2_sqrt_pd : GCCBuiltin<"__builtin_ia32_sqrtpd">,
198               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty],
199                         [IntrNoMem]>;
200   def int_x86_sse2_min_sd : GCCBuiltin<"__builtin_ia32_minsd">,
201               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
202                          llvm_v2f64_ty], [IntrNoMem]>;
203   def int_x86_sse2_min_pd : GCCBuiltin<"__builtin_ia32_minpd">,
204               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
205                          llvm_v2f64_ty], [IntrNoMem]>;
206   def int_x86_sse2_max_sd : GCCBuiltin<"__builtin_ia32_maxsd">,
207               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
208                          llvm_v2f64_ty], [IntrNoMem]>;
209   def int_x86_sse2_max_pd : GCCBuiltin<"__builtin_ia32_maxpd">,
210               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
211                          llvm_v2f64_ty], [IntrNoMem]>;
212 }
213
214 // FP comparison ops
215 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
216   def int_x86_sse2_cmp_sd :
217               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
218                          llvm_v2f64_ty, llvm_i8_ty], [IntrNoMem]>;
219   def int_x86_sse2_cmp_pd :
220               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
221                          llvm_v2f64_ty, llvm_i8_ty], [IntrNoMem]>;
222   def int_x86_sse2_comieq_sd : GCCBuiltin<"__builtin_ia32_comisdeq">,
223               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
224                          llvm_v2f64_ty], [IntrNoMem]>;
225   def int_x86_sse2_comilt_sd : GCCBuiltin<"__builtin_ia32_comisdlt">,
226               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
227                          llvm_v2f64_ty], [IntrNoMem]>;
228   def int_x86_sse2_comile_sd : GCCBuiltin<"__builtin_ia32_comisdle">,
229               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
230                          llvm_v2f64_ty], [IntrNoMem]>;
231   def int_x86_sse2_comigt_sd : GCCBuiltin<"__builtin_ia32_comisdgt">,
232               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
233                          llvm_v2f64_ty], [IntrNoMem]>;
234   def int_x86_sse2_comige_sd : GCCBuiltin<"__builtin_ia32_comisdge">,
235               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
236                          llvm_v2f64_ty], [IntrNoMem]>;
237   def int_x86_sse2_comineq_sd : GCCBuiltin<"__builtin_ia32_comisdneq">,
238               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
239                          llvm_v2f64_ty], [IntrNoMem]>;
240   def int_x86_sse2_ucomieq_sd : GCCBuiltin<"__builtin_ia32_ucomisdeq">,
241               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
242                          llvm_v2f64_ty], [IntrNoMem]>;
243   def int_x86_sse2_ucomilt_sd : GCCBuiltin<"__builtin_ia32_ucomisdlt">,
244               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
245                          llvm_v2f64_ty], [IntrNoMem]>;
246   def int_x86_sse2_ucomile_sd : GCCBuiltin<"__builtin_ia32_ucomisdle">,
247               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
248                          llvm_v2f64_ty], [IntrNoMem]>;
249   def int_x86_sse2_ucomigt_sd : GCCBuiltin<"__builtin_ia32_ucomisdgt">,
250               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
251                          llvm_v2f64_ty], [IntrNoMem]>;
252   def int_x86_sse2_ucomige_sd : GCCBuiltin<"__builtin_ia32_ucomisdge">,
253               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
254                          llvm_v2f64_ty], [IntrNoMem]>;
255   def int_x86_sse2_ucomineq_sd : GCCBuiltin<"__builtin_ia32_ucomisdneq">,
256               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
257                          llvm_v2f64_ty], [IntrNoMem]>;
258 }
259
260 // Integer arithmetic ops.
261 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
262   def int_x86_sse2_padds_b : GCCBuiltin<"__builtin_ia32_paddsb128">,
263               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
264                          llvm_v16i8_ty], [IntrNoMem, Commutative]>;
265   def int_x86_sse2_padds_w : GCCBuiltin<"__builtin_ia32_paddsw128">,
266               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
267                          llvm_v8i16_ty], [IntrNoMem, Commutative]>;
268   def int_x86_sse2_paddus_b : GCCBuiltin<"__builtin_ia32_paddusb128">,
269               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
270                          llvm_v16i8_ty], [IntrNoMem, Commutative]>;
271   def int_x86_sse2_paddus_w : GCCBuiltin<"__builtin_ia32_paddusw128">,
272               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
273                          llvm_v8i16_ty], [IntrNoMem, Commutative]>;
274   def int_x86_sse2_psubs_b : GCCBuiltin<"__builtin_ia32_psubsb128">,
275               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
276                          llvm_v16i8_ty], [IntrNoMem]>;
277   def int_x86_sse2_psubs_w : GCCBuiltin<"__builtin_ia32_psubsw128">,
278               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
279                          llvm_v8i16_ty], [IntrNoMem]>;
280   def int_x86_sse2_psubus_b : GCCBuiltin<"__builtin_ia32_psubusb128">,
281               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
282                          llvm_v16i8_ty], [IntrNoMem]>;
283   def int_x86_sse2_psubus_w : GCCBuiltin<"__builtin_ia32_psubusw128">,
284               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
285                          llvm_v8i16_ty], [IntrNoMem]>;
286   def int_x86_sse2_pmulhu_w : GCCBuiltin<"__builtin_ia32_pmulhuw128">,
287               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
288                          llvm_v8i16_ty], [IntrNoMem, Commutative]>;
289   def int_x86_sse2_pmulh_w : GCCBuiltin<"__builtin_ia32_pmulhw128">,
290               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
291                          llvm_v8i16_ty], [IntrNoMem, Commutative]>;
292   def int_x86_sse2_pmulu_dq : GCCBuiltin<"__builtin_ia32_pmuludq128">,
293               Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty,
294                          llvm_v4i32_ty], [IntrNoMem, Commutative]>;
295   def int_x86_sse2_pmadd_wd : GCCBuiltin<"__builtin_ia32_pmaddwd128">,
296               Intrinsic<[llvm_v4i32_ty], [llvm_v8i16_ty,
297                          llvm_v8i16_ty], [IntrNoMem, Commutative]>;
298   def int_x86_sse2_pavg_b : GCCBuiltin<"__builtin_ia32_pavgb128">,
299               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
300                          llvm_v16i8_ty], [IntrNoMem, Commutative]>;
301   def int_x86_sse2_pavg_w : GCCBuiltin<"__builtin_ia32_pavgw128">,
302               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
303                          llvm_v8i16_ty], [IntrNoMem, Commutative]>;
304   def int_x86_sse2_pmaxu_b : GCCBuiltin<"__builtin_ia32_pmaxub128">,
305               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
306                          llvm_v16i8_ty], [IntrNoMem, Commutative]>;
307   def int_x86_sse2_pmaxs_w : GCCBuiltin<"__builtin_ia32_pmaxsw128">,
308               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
309                          llvm_v8i16_ty], [IntrNoMem, Commutative]>;
310   def int_x86_sse2_pminu_b : GCCBuiltin<"__builtin_ia32_pminub128">,
311               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
312                          llvm_v16i8_ty], [IntrNoMem, Commutative]>;
313   def int_x86_sse2_pmins_w : GCCBuiltin<"__builtin_ia32_pminsw128">,
314               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
315                          llvm_v8i16_ty], [IntrNoMem, Commutative]>;
316   def int_x86_sse2_psad_bw : GCCBuiltin<"__builtin_ia32_psadbw128">,
317               Intrinsic<[llvm_v2i64_ty], [llvm_v16i8_ty,
318                          llvm_v16i8_ty], [IntrNoMem, Commutative]>;
319 }
320
321 // Integer shift ops.
322 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
323   def int_x86_sse2_psll_w : GCCBuiltin<"__builtin_ia32_psllw128">,
324               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
325                          llvm_v8i16_ty], [IntrNoMem]>;
326   def int_x86_sse2_psll_d : GCCBuiltin<"__builtin_ia32_pslld128">,
327               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
328                          llvm_v4i32_ty], [IntrNoMem]>;
329   def int_x86_sse2_psll_q : GCCBuiltin<"__builtin_ia32_psllq128">,
330               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
331                          llvm_v2i64_ty], [IntrNoMem]>;
332   def int_x86_sse2_psrl_w : GCCBuiltin<"__builtin_ia32_psrlw128">,
333               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
334                          llvm_v8i16_ty], [IntrNoMem]>;
335   def int_x86_sse2_psrl_d : GCCBuiltin<"__builtin_ia32_psrld128">,
336               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
337                          llvm_v4i32_ty], [IntrNoMem]>;
338   def int_x86_sse2_psrl_q : GCCBuiltin<"__builtin_ia32_psrlq128">,
339               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
340                          llvm_v2i64_ty], [IntrNoMem]>;
341   def int_x86_sse2_psra_w : GCCBuiltin<"__builtin_ia32_psraw128">,
342               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
343                          llvm_v8i16_ty], [IntrNoMem]>;
344   def int_x86_sse2_psra_d : GCCBuiltin<"__builtin_ia32_psrad128">,
345               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
346                          llvm_v4i32_ty], [IntrNoMem]>;
347
348   def int_x86_sse2_pslli_w : GCCBuiltin<"__builtin_ia32_psllwi128">,
349               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
350                          llvm_i32_ty], [IntrNoMem]>;
351   def int_x86_sse2_pslli_d : GCCBuiltin<"__builtin_ia32_pslldi128">,
352               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
353                          llvm_i32_ty], [IntrNoMem]>;
354   def int_x86_sse2_pslli_q : GCCBuiltin<"__builtin_ia32_psllqi128">,
355               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
356                          llvm_i32_ty], [IntrNoMem]>;
357   def int_x86_sse2_psrli_w : GCCBuiltin<"__builtin_ia32_psrlwi128">,
358               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
359                          llvm_i32_ty], [IntrNoMem]>;
360   def int_x86_sse2_psrli_d : GCCBuiltin<"__builtin_ia32_psrldi128">,
361               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
362                          llvm_i32_ty], [IntrNoMem]>;
363   def int_x86_sse2_psrli_q : GCCBuiltin<"__builtin_ia32_psrlqi128">,
364               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
365                          llvm_i32_ty], [IntrNoMem]>;
366   def int_x86_sse2_psrai_w : GCCBuiltin<"__builtin_ia32_psrawi128">,
367               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
368                          llvm_i32_ty], [IntrNoMem]>;
369   def int_x86_sse2_psrai_d : GCCBuiltin<"__builtin_ia32_psradi128">,
370               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
371                          llvm_i32_ty], [IntrNoMem]>;
372
373   def int_x86_sse2_psll_dq : GCCBuiltin<"__builtin_ia32_pslldqi128">,
374               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
375                          llvm_i32_ty], [IntrNoMem]>;
376   def int_x86_sse2_psrl_dq : GCCBuiltin<"__builtin_ia32_psrldqi128">,
377               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
378                          llvm_i32_ty], [IntrNoMem]>;
379   def int_x86_sse2_psll_dq_bs : GCCBuiltin<"__builtin_ia32_pslldqi128_byteshift">,
380               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
381                          llvm_i32_ty], [IntrNoMem]>;
382   def int_x86_sse2_psrl_dq_bs : GCCBuiltin<"__builtin_ia32_psrldqi128_byteshift">,
383               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
384                          llvm_i32_ty], [IntrNoMem]>;
385 }
386
387 // Integer comparison ops
388 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
389   def int_x86_sse2_pcmpeq_b : GCCBuiltin<"__builtin_ia32_pcmpeqb128">,
390               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
391                          llvm_v16i8_ty], [IntrNoMem]>;
392   def int_x86_sse2_pcmpeq_w : GCCBuiltin<"__builtin_ia32_pcmpeqw128">,
393               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
394                          llvm_v8i16_ty], [IntrNoMem]>;
395   def int_x86_sse2_pcmpeq_d : GCCBuiltin<"__builtin_ia32_pcmpeqd128">,
396               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
397                          llvm_v4i32_ty], [IntrNoMem]>;
398   def int_x86_sse2_pcmpgt_b : GCCBuiltin<"__builtin_ia32_pcmpgtb128">,
399               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
400                          llvm_v16i8_ty], [IntrNoMem]>;
401   def int_x86_sse2_pcmpgt_w : GCCBuiltin<"__builtin_ia32_pcmpgtw128">,
402               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
403                          llvm_v8i16_ty], [IntrNoMem]>;
404   def int_x86_sse2_pcmpgt_d : GCCBuiltin<"__builtin_ia32_pcmpgtd128">,
405               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
406                          llvm_v4i32_ty], [IntrNoMem]>;
407 }
408
409 // Conversion ops
410 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
411   def int_x86_sse2_cvtdq2pd : GCCBuiltin<"__builtin_ia32_cvtdq2pd">,
412               Intrinsic<[llvm_v2f64_ty], [llvm_v4i32_ty], [IntrNoMem]>;
413   def int_x86_sse2_cvtdq2ps : GCCBuiltin<"__builtin_ia32_cvtdq2ps">,
414               Intrinsic<[llvm_v4f32_ty], [llvm_v4i32_ty], [IntrNoMem]>;
415   def int_x86_sse2_cvtpd2dq : GCCBuiltin<"__builtin_ia32_cvtpd2dq">,
416               Intrinsic<[llvm_v4i32_ty], [llvm_v2f64_ty], [IntrNoMem]>;
417   def int_x86_sse2_cvttpd2dq : GCCBuiltin<"__builtin_ia32_cvttpd2dq">,
418               Intrinsic<[llvm_v4i32_ty], [llvm_v2f64_ty], [IntrNoMem]>;
419   def int_x86_sse2_cvtpd2ps : GCCBuiltin<"__builtin_ia32_cvtpd2ps">,
420               Intrinsic<[llvm_v4f32_ty], [llvm_v2f64_ty], [IntrNoMem]>;
421   def int_x86_sse2_cvtps2dq : GCCBuiltin<"__builtin_ia32_cvtps2dq">,
422               Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
423   def int_x86_sse2_cvttps2dq : GCCBuiltin<"__builtin_ia32_cvttps2dq">,
424               Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
425   def int_x86_sse2_cvtps2pd : GCCBuiltin<"__builtin_ia32_cvtps2pd">,
426               Intrinsic<[llvm_v2f64_ty], [llvm_v4f32_ty], [IntrNoMem]>;
427   def int_x86_sse2_cvtsd2si : GCCBuiltin<"__builtin_ia32_cvtsd2si">,
428               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty], [IntrNoMem]>;
429   def int_x86_sse2_cvtsd2si64 : GCCBuiltin<"__builtin_ia32_cvtsd2si64">,
430               Intrinsic<[llvm_i64_ty], [llvm_v2f64_ty], [IntrNoMem]>;
431   def int_x86_sse2_cvttsd2si : GCCBuiltin<"__builtin_ia32_cvttsd2si">,
432               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty], [IntrNoMem]>;
433   def int_x86_sse2_cvttsd2si64 : GCCBuiltin<"__builtin_ia32_cvttsd2si64">,
434               Intrinsic<[llvm_i64_ty], [llvm_v2f64_ty], [IntrNoMem]>;
435   def int_x86_sse2_cvtsi2sd : GCCBuiltin<"__builtin_ia32_cvtsi2sd">,
436               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
437                          llvm_i32_ty], [IntrNoMem]>;
438   def int_x86_sse2_cvtsi642sd : GCCBuiltin<"__builtin_ia32_cvtsi642sd">,
439               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
440                          llvm_i64_ty], [IntrNoMem]>;
441   def int_x86_sse2_cvtsd2ss : GCCBuiltin<"__builtin_ia32_cvtsd2ss">,
442               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
443                          llvm_v2f64_ty], [IntrNoMem]>;
444   def int_x86_sse2_cvtss2sd : GCCBuiltin<"__builtin_ia32_cvtss2sd">,
445               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
446                          llvm_v4f32_ty], [IntrNoMem]>;
447   def int_x86_sse_cvtpd2pi : GCCBuiltin<"__builtin_ia32_cvtpd2pi">,
448               Intrinsic<[llvm_x86mmx_ty], [llvm_v2f64_ty], [IntrNoMem]>;
449   def int_x86_sse_cvttpd2pi: GCCBuiltin<"__builtin_ia32_cvttpd2pi">,
450               Intrinsic<[llvm_x86mmx_ty], [llvm_v2f64_ty], [IntrNoMem]>;
451   def int_x86_sse_cvtpi2pd : GCCBuiltin<"__builtin_ia32_cvtpi2pd">,
452               Intrinsic<[llvm_v2f64_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
453 }
454
455 // SIMD load ops
456 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
457   def int_x86_sse2_loadu_pd : GCCBuiltin<"__builtin_ia32_loadupd">,
458               Intrinsic<[llvm_v2f64_ty], [llvm_ptr_ty], [IntrReadMem]>;
459   def int_x86_sse2_loadu_dq : GCCBuiltin<"__builtin_ia32_loaddqu">,
460               Intrinsic<[llvm_v16i8_ty], [llvm_ptr_ty], [IntrReadMem]>;
461 }
462
463 // SIMD store ops
464 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
465   def int_x86_sse2_storeu_pd : GCCBuiltin<"__builtin_ia32_storeupd">,
466               Intrinsic<[], [llvm_ptr_ty,
467                          llvm_v2f64_ty], []>;
468   def int_x86_sse2_storeu_dq : GCCBuiltin<"__builtin_ia32_storedqu">,
469               Intrinsic<[], [llvm_ptr_ty,
470                          llvm_v16i8_ty], []>;
471   def int_x86_sse2_storel_dq : GCCBuiltin<"__builtin_ia32_storelv4si">,
472               Intrinsic<[], [llvm_ptr_ty,
473                          llvm_v4i32_ty], []>;
474 }
475
476 // Cacheability support ops
477 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
478   def int_x86_sse2_movnt_dq : GCCBuiltin<"__builtin_ia32_movntdq">,
479               Intrinsic<[], [llvm_ptr_ty,
480                          llvm_v2i64_ty], []>;
481   def int_x86_sse2_movnt_pd : GCCBuiltin<"__builtin_ia32_movntpd">,
482               Intrinsic<[], [llvm_ptr_ty,
483                          llvm_v2f64_ty], []>;
484   def int_x86_sse2_movnt_i : GCCBuiltin<"__builtin_ia32_movnti">,
485               Intrinsic<[], [llvm_ptr_ty,
486                          llvm_i32_ty], []>;
487 }
488
489 // Misc.
490 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
491   def int_x86_sse2_packsswb_128 : GCCBuiltin<"__builtin_ia32_packsswb128">,
492               Intrinsic<[llvm_v16i8_ty], [llvm_v8i16_ty,
493                          llvm_v8i16_ty], [IntrNoMem]>;
494   def int_x86_sse2_packssdw_128 : GCCBuiltin<"__builtin_ia32_packssdw128">,
495               Intrinsic<[llvm_v8i16_ty], [llvm_v4i32_ty,
496                          llvm_v4i32_ty], [IntrNoMem]>;
497   def int_x86_sse2_packuswb_128 : GCCBuiltin<"__builtin_ia32_packuswb128">,
498               Intrinsic<[llvm_v16i8_ty], [llvm_v8i16_ty,
499                          llvm_v8i16_ty], [IntrNoMem]>;
500   def int_x86_sse2_movmsk_pd : GCCBuiltin<"__builtin_ia32_movmskpd">,
501               Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty], [IntrNoMem]>;
502   def int_x86_sse2_pmovmskb_128 : GCCBuiltin<"__builtin_ia32_pmovmskb128">,
503               Intrinsic<[llvm_i32_ty], [llvm_v16i8_ty], [IntrNoMem]>;
504   def int_x86_sse2_maskmov_dqu : GCCBuiltin<"__builtin_ia32_maskmovdqu">,
505               Intrinsic<[], [llvm_v16i8_ty,
506                          llvm_v16i8_ty, llvm_ptr_ty], []>;
507   def int_x86_sse2_clflush : GCCBuiltin<"__builtin_ia32_clflush">,
508               Intrinsic<[], [llvm_ptr_ty], []>;
509   def int_x86_sse2_lfence : GCCBuiltin<"__builtin_ia32_lfence">,
510               Intrinsic<[], [], []>;
511   def int_x86_sse2_mfence : GCCBuiltin<"__builtin_ia32_mfence">,
512               Intrinsic<[], [], []>;
513 }
514
515 //===----------------------------------------------------------------------===//
516 // SSE3
517
518 // Addition / subtraction ops.
519 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
520   def int_x86_sse3_addsub_ps : GCCBuiltin<"__builtin_ia32_addsubps">,
521               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
522                          llvm_v4f32_ty], [IntrNoMem]>;
523   def int_x86_sse3_addsub_pd : GCCBuiltin<"__builtin_ia32_addsubpd">,
524               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
525                          llvm_v2f64_ty], [IntrNoMem]>;
526 }
527
528 // Horizontal ops.
529 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
530   def int_x86_sse3_hadd_ps : GCCBuiltin<"__builtin_ia32_haddps">,
531               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
532                          llvm_v4f32_ty], [IntrNoMem]>;
533   def int_x86_sse3_hadd_pd : GCCBuiltin<"__builtin_ia32_haddpd">,
534               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
535                          llvm_v2f64_ty], [IntrNoMem]>;
536   def int_x86_sse3_hsub_ps : GCCBuiltin<"__builtin_ia32_hsubps">,
537               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
538                          llvm_v4f32_ty], [IntrNoMem]>;
539   def int_x86_sse3_hsub_pd : GCCBuiltin<"__builtin_ia32_hsubpd">,
540               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
541                          llvm_v2f64_ty], [IntrNoMem]>;
542 }
543
544 // Specialized unaligned load.
545 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
546   def int_x86_sse3_ldu_dq : GCCBuiltin<"__builtin_ia32_lddqu">,
547               Intrinsic<[llvm_v16i8_ty], [llvm_ptr_ty], [IntrReadMem]>;
548 }
549
550 // Thread synchronization ops.
551 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
552   def int_x86_sse3_monitor : GCCBuiltin<"__builtin_ia32_monitor">,
553               Intrinsic<[], [llvm_ptr_ty,
554                          llvm_i32_ty, llvm_i32_ty], []>;
555   def int_x86_sse3_mwait : GCCBuiltin<"__builtin_ia32_mwait">,
556               Intrinsic<[], [llvm_i32_ty,
557                          llvm_i32_ty], []>;
558 }
559
560 //===----------------------------------------------------------------------===//
561 // SSSE3
562
563 // Horizontal arithmetic ops
564 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
565   def int_x86_ssse3_phadd_w         : GCCBuiltin<"__builtin_ia32_phaddw">,
566               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
567                          llvm_x86mmx_ty], [IntrNoMem]>;
568   def int_x86_ssse3_phadd_w_128     : GCCBuiltin<"__builtin_ia32_phaddw128">,
569               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
570                          llvm_v8i16_ty], [IntrNoMem]>;
571
572   def int_x86_ssse3_phadd_d         : GCCBuiltin<"__builtin_ia32_phaddd">,
573               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
574                          llvm_x86mmx_ty], [IntrNoMem]>;
575   def int_x86_ssse3_phadd_d_128     : GCCBuiltin<"__builtin_ia32_phaddd128">,
576               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
577                          llvm_v4i32_ty], [IntrNoMem]>;
578
579   def int_x86_ssse3_phadd_sw        : GCCBuiltin<"__builtin_ia32_phaddsw">,
580               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
581                          llvm_x86mmx_ty], [IntrNoMem]>;
582   def int_x86_ssse3_phadd_sw_128    : GCCBuiltin<"__builtin_ia32_phaddsw128">,
583               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
584                          llvm_v4i32_ty], [IntrNoMem]>;
585
586   def int_x86_ssse3_phsub_w         : GCCBuiltin<"__builtin_ia32_phsubw">,
587               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
588                          llvm_x86mmx_ty], [IntrNoMem]>;
589   def int_x86_ssse3_phsub_w_128     : GCCBuiltin<"__builtin_ia32_phsubw128">,
590               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
591                          llvm_v8i16_ty], [IntrNoMem]>;
592
593   def int_x86_ssse3_phsub_d         : GCCBuiltin<"__builtin_ia32_phsubd">,
594               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
595                          llvm_x86mmx_ty], [IntrNoMem]>;
596   def int_x86_ssse3_phsub_d_128     : GCCBuiltin<"__builtin_ia32_phsubd128">,
597               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
598                          llvm_v4i32_ty], [IntrNoMem]>;
599
600   def int_x86_ssse3_phsub_sw        : GCCBuiltin<"__builtin_ia32_phsubsw">,
601               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
602                          llvm_x86mmx_ty], [IntrNoMem]>;
603   def int_x86_ssse3_phsub_sw_128    : GCCBuiltin<"__builtin_ia32_phsubsw128">,
604               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
605                          llvm_v8i16_ty], [IntrNoMem]>;
606
607   def int_x86_ssse3_pmadd_ub_sw     : GCCBuiltin<"__builtin_ia32_pmaddubsw">,
608               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
609                          llvm_x86mmx_ty], [IntrNoMem]>;
610   def int_x86_ssse3_pmadd_ub_sw_128 : GCCBuiltin<"__builtin_ia32_pmaddubsw128">,
611               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
612                          llvm_v8i16_ty], [IntrNoMem]>;
613 }
614
615 // Packed multiply high with round and scale
616 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
617   def int_x86_ssse3_pmul_hr_sw      : GCCBuiltin<"__builtin_ia32_pmulhrsw">,
618               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
619                          llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
620   def int_x86_ssse3_pmul_hr_sw_128  : GCCBuiltin<"__builtin_ia32_pmulhrsw128">,
621               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
622                          llvm_v8i16_ty], [IntrNoMem, Commutative]>;
623 }
624
625 // Shuffle ops
626 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
627   def int_x86_ssse3_pshuf_b         : GCCBuiltin<"__builtin_ia32_pshufb">,
628               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
629                          llvm_x86mmx_ty], [IntrNoMem]>;
630   def int_x86_ssse3_pshuf_b_128     : GCCBuiltin<"__builtin_ia32_pshufb128">,
631               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
632                          llvm_v16i8_ty], [IntrNoMem]>;
633   def int_x86_sse_pshuf_w           : GCCBuiltin<"__builtin_ia32_pshufw">,
634               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_i8_ty],
635                          [IntrNoMem]>;
636 }
637
638 // Sign ops
639 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
640   def int_x86_ssse3_psign_b         : GCCBuiltin<"__builtin_ia32_psignb">,
641               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
642                          llvm_x86mmx_ty], [IntrNoMem]>;
643   def int_x86_ssse3_psign_b_128     : GCCBuiltin<"__builtin_ia32_psignb128">,
644               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
645                          llvm_v16i8_ty], [IntrNoMem]>;
646
647   def int_x86_ssse3_psign_w         : GCCBuiltin<"__builtin_ia32_psignw">,
648               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
649                          llvm_x86mmx_ty], [IntrNoMem]>;
650   def int_x86_ssse3_psign_w_128     : GCCBuiltin<"__builtin_ia32_psignw128">,
651               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
652                          llvm_v8i16_ty], [IntrNoMem]>;
653
654   def int_x86_ssse3_psign_d         : GCCBuiltin<"__builtin_ia32_psignd">,
655               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
656                          llvm_x86mmx_ty], [IntrNoMem]>;
657   def int_x86_ssse3_psign_d_128     : GCCBuiltin<"__builtin_ia32_psignd128">,
658               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
659                          llvm_v4i32_ty], [IntrNoMem]>;
660 }
661
662 // Absolute value ops
663 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
664   def int_x86_ssse3_pabs_b     : GCCBuiltin<"__builtin_ia32_pabsb">,
665               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
666   def int_x86_ssse3_pabs_b_128 : GCCBuiltin<"__builtin_ia32_pabsb128">,
667               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty], [IntrNoMem]>;
668
669   def int_x86_ssse3_pabs_w     : GCCBuiltin<"__builtin_ia32_pabsw">,
670               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
671   def int_x86_ssse3_pabs_w_128 : GCCBuiltin<"__builtin_ia32_pabsw128">,
672               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty], [IntrNoMem]>;
673
674   def int_x86_ssse3_pabs_d     : GCCBuiltin<"__builtin_ia32_pabsd">,
675               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
676   def int_x86_ssse3_pabs_d_128 : GCCBuiltin<"__builtin_ia32_pabsd128">,
677               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty], [IntrNoMem]>;
678 }
679
680 //===----------------------------------------------------------------------===//
681 // SSE4.1
682
683 // FP rounding ops
684 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
685   def int_x86_sse41_round_ss        : GCCBuiltin<"__builtin_ia32_roundss">,
686               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty,
687                          llvm_i32_ty], [IntrNoMem]>;
688   def int_x86_sse41_round_ps        : GCCBuiltin<"__builtin_ia32_roundps">,
689               Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
690                          llvm_i32_ty], [IntrNoMem]>;
691   def int_x86_sse41_round_sd        : GCCBuiltin<"__builtin_ia32_roundsd">,
692               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty,
693                          llvm_i32_ty], [IntrNoMem]>;
694   def int_x86_sse41_round_pd        : GCCBuiltin<"__builtin_ia32_roundpd">,
695               Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
696                          llvm_i32_ty], [IntrNoMem]>;
697 }
698
699 // Vector sign and zero extend
700 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
701   def int_x86_sse41_pmovsxbd        : GCCBuiltin<"__builtin_ia32_pmovsxbd128">,
702               Intrinsic<[llvm_v4i32_ty], [llvm_v16i8_ty],
703                         [IntrNoMem]>;
704   def int_x86_sse41_pmovsxbq        : GCCBuiltin<"__builtin_ia32_pmovsxbq128">,
705               Intrinsic<[llvm_v2i64_ty], [llvm_v16i8_ty],
706                         [IntrNoMem]>;
707   def int_x86_sse41_pmovsxbw        : GCCBuiltin<"__builtin_ia32_pmovsxbw128">,
708               Intrinsic<[llvm_v8i16_ty], [llvm_v16i8_ty],
709                         [IntrNoMem]>;
710   def int_x86_sse41_pmovsxdq        : GCCBuiltin<"__builtin_ia32_pmovsxdq128">,
711               Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty],
712                         [IntrNoMem]>;
713   def int_x86_sse41_pmovsxwd        : GCCBuiltin<"__builtin_ia32_pmovsxwd128">,
714               Intrinsic<[llvm_v4i32_ty], [llvm_v8i16_ty],
715                         [IntrNoMem]>;
716   def int_x86_sse41_pmovsxwq        : GCCBuiltin<"__builtin_ia32_pmovsxwq128">,
717               Intrinsic<[llvm_v2i64_ty], [llvm_v8i16_ty],
718                         [IntrNoMem]>;
719   def int_x86_sse41_pmovzxbd        : GCCBuiltin<"__builtin_ia32_pmovzxbd128">,
720               Intrinsic<[llvm_v4i32_ty], [llvm_v16i8_ty],
721                         [IntrNoMem]>;
722   def int_x86_sse41_pmovzxbq        : GCCBuiltin<"__builtin_ia32_pmovzxbq128">,
723               Intrinsic<[llvm_v2i64_ty], [llvm_v16i8_ty],
724                         [IntrNoMem]>;
725   def int_x86_sse41_pmovzxbw        : GCCBuiltin<"__builtin_ia32_pmovzxbw128">,
726               Intrinsic<[llvm_v8i16_ty], [llvm_v16i8_ty],
727                         [IntrNoMem]>;
728   def int_x86_sse41_pmovzxdq        : GCCBuiltin<"__builtin_ia32_pmovzxdq128">,
729               Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty],
730                         [IntrNoMem]>;
731   def int_x86_sse41_pmovzxwd        : GCCBuiltin<"__builtin_ia32_pmovzxwd128">,
732               Intrinsic<[llvm_v4i32_ty], [llvm_v8i16_ty],
733                         [IntrNoMem]>;
734   def int_x86_sse41_pmovzxwq        : GCCBuiltin<"__builtin_ia32_pmovzxwq128">,
735               Intrinsic<[llvm_v2i64_ty], [llvm_v8i16_ty],
736                         [IntrNoMem]>;
737 }
738
739 // Vector min element
740 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
741   def int_x86_sse41_phminposuw     : GCCBuiltin<"__builtin_ia32_phminposuw128">,
742               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty],
743                         [IntrNoMem]>;
744 }
745
746 // Vector compare, min, max
747 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
748   def int_x86_sse41_pcmpeqq         : GCCBuiltin<"__builtin_ia32_pcmpeqq">,
749               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
750                         [IntrNoMem, Commutative]>;
751   def int_x86_sse42_pcmpgtq         : GCCBuiltin<"__builtin_ia32_pcmpgtq">,
752               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
753                         [IntrNoMem]>;
754   def int_x86_sse41_pmaxsb          : GCCBuiltin<"__builtin_ia32_pmaxsb128">,
755               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty],
756                         [IntrNoMem, Commutative]>;
757   def int_x86_sse41_pmaxsd          : GCCBuiltin<"__builtin_ia32_pmaxsd128">,
758               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
759                         [IntrNoMem, Commutative]>;
760   def int_x86_sse41_pmaxud          : GCCBuiltin<"__builtin_ia32_pmaxud128">,
761               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
762                         [IntrNoMem, Commutative]>;
763   def int_x86_sse41_pmaxuw          : GCCBuiltin<"__builtin_ia32_pmaxuw128">,
764               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty],
765                         [IntrNoMem, Commutative]>;
766   def int_x86_sse41_pminsb          : GCCBuiltin<"__builtin_ia32_pminsb128">,
767               Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty],
768                         [IntrNoMem, Commutative]>;
769   def int_x86_sse41_pminsd          : GCCBuiltin<"__builtin_ia32_pminsd128">,
770               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
771                         [IntrNoMem, Commutative]>;
772   def int_x86_sse41_pminud          : GCCBuiltin<"__builtin_ia32_pminud128">,
773               Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
774                         [IntrNoMem, Commutative]>;
775   def int_x86_sse41_pminuw          : GCCBuiltin<"__builtin_ia32_pminuw128">,
776               Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty],
777                         [IntrNoMem, Commutative]>;
778 }
779
780 // Advanced Encryption Standard (AES) Instructions
781 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
782   def int_x86_aesni_aesimc          : GCCBuiltin<"__builtin_ia32_aesimc128">,
783               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty],
784                         [IntrNoMem]>;
785   def int_x86_aesni_aesenc          : GCCBuiltin<"__builtin_ia32_aesenc128">,
786               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
787                         [IntrNoMem]>;
788   def int_x86_aesni_aesenclast : GCCBuiltin<"__builtin_ia32_aesenclast128">,
789               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
790                         [IntrNoMem]>;
791   def int_x86_aesni_aesdec          : GCCBuiltin<"__builtin_ia32_aesdec128">,
792               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
793                         [IntrNoMem]>;
794   def int_x86_aesni_aesdeclast : GCCBuiltin<"__builtin_ia32_aesdeclast128">,
795               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
796                         [IntrNoMem]>;
797   def int_x86_aesni_aeskeygenassist :
798               GCCBuiltin<"__builtin_ia32_aeskeygenassist128">,
799               Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i8_ty],
800                         [IntrNoMem]>;
801 }
802
803 // Vector pack
804 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
805   def int_x86_sse41_packusdw        : GCCBuiltin<"__builtin_ia32_packusdw128">,
806               Intrinsic<[llvm_v8i16_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
807                         [IntrNoMem]>;
808 }
809
810 // Vector multiply
811 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
812   def int_x86_sse41_pmuldq          : GCCBuiltin<"__builtin_ia32_pmuldq128">,
813               Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
814                         [IntrNoMem, Commutative]>;
815 }
816
817 // Vector extract
818 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
819   def int_x86_sse41_pextrb         :
820               Intrinsic<[llvm_i32_ty], [llvm_v16i8_ty, llvm_i32_ty],
821                         [IntrNoMem]>;
822   def int_x86_sse41_pextrd         :
823               Intrinsic<[llvm_i32_ty], [llvm_v4i32_ty, llvm_i32_ty],
824                         [IntrNoMem]>;
825   def int_x86_sse41_pextrq         :
826               Intrinsic<[llvm_i64_ty], [llvm_v2i64_ty, llvm_i32_ty],
827                         [IntrNoMem]>;
828   def int_x86_sse41_extractps      : GCCBuiltin<"__builtin_ia32_extractps128">,
829               Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty, llvm_i32_ty],
830                         [IntrNoMem]>;
831 }
832
833 // Vector insert
834 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
835   def int_x86_sse41_insertps       : GCCBuiltin<"__builtin_ia32_insertps128">,
836           Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty,llvm_i32_ty],
837                     [IntrNoMem]>;
838 }
839
840 // Vector blend
841 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
842   def int_x86_sse41_pblendvb         : GCCBuiltin<"__builtin_ia32_pblendvb128">,
843         Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty,llvm_v16i8_ty],
844                   [IntrNoMem]>;
845   def int_x86_sse41_pblendw          : GCCBuiltin<"__builtin_ia32_pblendw128">,
846         Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_i32_ty],
847                   [IntrNoMem]>;
848   def int_x86_sse41_blendpd          : GCCBuiltin<"__builtin_ia32_blendpd">,
849         Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty, llvm_i32_ty],
850                   [IntrNoMem]>;
851   def int_x86_sse41_blendps          : GCCBuiltin<"__builtin_ia32_blendps">,
852         Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty, llvm_i32_ty],
853                   [IntrNoMem]>;
854   def int_x86_sse41_blendvpd         : GCCBuiltin<"__builtin_ia32_blendvpd">,
855         Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty,llvm_v2f64_ty],
856                   [IntrNoMem]>;
857   def int_x86_sse41_blendvps         : GCCBuiltin<"__builtin_ia32_blendvps">,
858         Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty,llvm_v4f32_ty],
859                   [IntrNoMem]>;
860 }
861
862 // Vector dot product
863 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
864   def int_x86_sse41_dppd            : GCCBuiltin<"__builtin_ia32_dppd">,
865           Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty,llvm_i32_ty],
866                     [IntrNoMem, Commutative]>;
867   def int_x86_sse41_dpps            : GCCBuiltin<"__builtin_ia32_dpps">,
868           Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty,llvm_i32_ty],
869                     [IntrNoMem, Commutative]>;
870 }
871
872 // Vector sum of absolute differences
873 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
874   def int_x86_sse41_mpsadbw         : GCCBuiltin<"__builtin_ia32_mpsadbw128">,
875           Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty,llvm_i32_ty],
876                     [IntrNoMem, Commutative]>;
877 }
878
879 // Cacheability support ops
880 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
881   def int_x86_sse41_movntdqa        : GCCBuiltin<"__builtin_ia32_movntdqa">,
882           Intrinsic<[llvm_v2i64_ty], [llvm_ptr_ty], [IntrReadMem]>;
883 }
884
885 // Test instruction with bitwise comparison.
886 let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.".
887   def int_x86_sse41_ptestz          : GCCBuiltin<"__builtin_ia32_ptestz128">,
888           Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty],
889                     [IntrNoMem]>;
890   def int_x86_sse41_ptestc          : GCCBuiltin<"__builtin_ia32_ptestc128">,
891           Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty],
892                     [IntrNoMem]>;
893   def int_x86_sse41_ptestnzc        : GCCBuiltin<"__builtin_ia32_ptestnzc128">,
894           Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty],
895                     [IntrNoMem]>;
896 }
897
898 //===----------------------------------------------------------------------===//
899 // SSE4.2
900
901 // Miscellaneous
902 // CRC Instruction
903 let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.".
904   def int_x86_sse42_crc32_8         : GCCBuiltin<"__builtin_ia32_crc32qi">,
905           Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i8_ty],
906                     [IntrNoMem]>;
907   def int_x86_sse42_crc32_16         : GCCBuiltin<"__builtin_ia32_crc32hi">,
908           Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i16_ty],
909                     [IntrNoMem]>;
910   def int_x86_sse42_crc32_32         : GCCBuiltin<"__builtin_ia32_crc32si">,
911           Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty],
912                     [IntrNoMem]>;
913   def int_x86_sse42_crc64_8         :
914           Intrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i8_ty],
915                     [IntrNoMem]>;
916   def int_x86_sse42_crc64_64         : GCCBuiltin<"__builtin_ia32_crc32di">,
917           Intrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty],
918                     [IntrNoMem]>;
919 }
920
921 // String/text processing ops.
922 let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.".
923   def int_x86_sse42_pcmpistrm128  : GCCBuiltin<"__builtin_ia32_pcmpistrm128">,
924           Intrinsic<[llvm_v16i8_ty],
925                     [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
926                     [IntrNoMem]>;
927   def int_x86_sse42_pcmpistri128  : GCCBuiltin<"__builtin_ia32_pcmpistri128">,
928           Intrinsic<[llvm_i32_ty],
929                     [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
930                     [IntrNoMem]>;
931   def int_x86_sse42_pcmpistria128 : GCCBuiltin<"__builtin_ia32_pcmpistria128">,
932           Intrinsic<[llvm_i32_ty],
933                     [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
934                     [IntrNoMem]>;
935   def int_x86_sse42_pcmpistric128 : GCCBuiltin<"__builtin_ia32_pcmpistric128">,
936           Intrinsic<[llvm_i32_ty],
937                     [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
938                     [IntrNoMem]>;
939   def int_x86_sse42_pcmpistrio128 : GCCBuiltin<"__builtin_ia32_pcmpistrio128">,
940           Intrinsic<[llvm_i32_ty],
941                     [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
942                     [IntrNoMem]>;
943   def int_x86_sse42_pcmpistris128 : GCCBuiltin<"__builtin_ia32_pcmpistris128">,
944           Intrinsic<[llvm_i32_ty],
945                     [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
946                     [IntrNoMem]>;
947   def int_x86_sse42_pcmpistriz128 : GCCBuiltin<"__builtin_ia32_pcmpistriz128">,
948           Intrinsic<[llvm_i32_ty],
949                     [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
950                     [IntrNoMem]>;
951   def int_x86_sse42_pcmpestrm128  : GCCBuiltin<"__builtin_ia32_pcmpestrm128">,
952           Intrinsic<[llvm_v16i8_ty],
953                     [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
954                      llvm_i8_ty],
955                     [IntrNoMem]>;
956   def int_x86_sse42_pcmpestri128  : GCCBuiltin<"__builtin_ia32_pcmpestri128">,
957           Intrinsic<[llvm_i32_ty],
958                     [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
959                      llvm_i8_ty],
960                     [IntrNoMem]>;
961   def int_x86_sse42_pcmpestria128 : GCCBuiltin<"__builtin_ia32_pcmpestria128">,
962           Intrinsic<[llvm_i32_ty],
963                     [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
964                      llvm_i8_ty],
965                     [IntrNoMem]>;
966   def int_x86_sse42_pcmpestric128 : GCCBuiltin<"__builtin_ia32_pcmpestric128">,
967           Intrinsic<[llvm_i32_ty],
968                     [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
969                      llvm_i8_ty],
970                     [IntrNoMem]>;
971   def int_x86_sse42_pcmpestrio128 : GCCBuiltin<"__builtin_ia32_pcmpestrio128">,
972           Intrinsic<[llvm_i32_ty],
973                     [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
974                      llvm_i8_ty],
975                     [IntrNoMem]>;
976   def int_x86_sse42_pcmpestris128 : GCCBuiltin<"__builtin_ia32_pcmpestris128">,
977           Intrinsic<[llvm_i32_ty],
978                     [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
979                      llvm_i8_ty],
980                     [IntrNoMem]>;
981   def int_x86_sse42_pcmpestriz128 : GCCBuiltin<"__builtin_ia32_pcmpestriz128">,
982           Intrinsic<[llvm_i32_ty],
983                     [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
984                      llvm_i8_ty],
985                     [IntrNoMem]>;
986 }
987
988 //===----------------------------------------------------------------------===//
989 // AVX
990
991 // Arithmetic ops
992 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
993   def int_x86_avx_addsub_pd_256 : GCCBuiltin<"__builtin_ia32_addsubpd256">,
994         Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
995                   llvm_v4f64_ty], [IntrNoMem]>;
996   def int_x86_avx_addsub_ps_256 : GCCBuiltin<"__builtin_ia32_addsubps256">,
997         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
998                   llvm_v8f32_ty], [IntrNoMem]>;
999   def int_x86_avx_max_pd_256 : GCCBuiltin<"__builtin_ia32_maxpd256">,
1000         Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1001                   llvm_v4f64_ty], [IntrNoMem]>;
1002   def int_x86_avx_max_ps_256 : GCCBuiltin<"__builtin_ia32_maxps256">,
1003         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1004                   llvm_v8f32_ty], [IntrNoMem]>;
1005   def int_x86_avx_min_pd_256 : GCCBuiltin<"__builtin_ia32_minpd256">,
1006         Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1007                   llvm_v4f64_ty], [IntrNoMem]>;
1008   def int_x86_avx_min_ps_256 : GCCBuiltin<"__builtin_ia32_minps256">,
1009         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1010                   llvm_v8f32_ty], [IntrNoMem]>;
1011
1012   def int_x86_avx_sqrt_pd_256 : GCCBuiltin<"__builtin_ia32_sqrtpd256">,
1013         Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty], [IntrNoMem]>;
1014   def int_x86_avx_sqrt_ps_256 : GCCBuiltin<"__builtin_ia32_sqrtps256">,
1015         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
1016
1017   def int_x86_avx_rsqrt_ps_256 : GCCBuiltin<"__builtin_ia32_rsqrtps256">,
1018         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
1019
1020   def int_x86_avx_rcp_ps_256 : GCCBuiltin<"__builtin_ia32_rcpps256">,
1021         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
1022
1023   def int_x86_avx_round_pd_256 : GCCBuiltin<"__builtin_ia32_roundpd256">,
1024         Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1025                   llvm_i32_ty], [IntrNoMem]>;
1026   def int_x86_avx_round_ps_256 : GCCBuiltin<"__builtin_ia32_roundps256">,
1027         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1028                   llvm_i32_ty], [IntrNoMem]>;
1029 }
1030
1031 // Horizontal ops
1032 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1033   def int_x86_avx_hadd_pd_256 : GCCBuiltin<"__builtin_ia32_haddpd256">,
1034         Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1035                   llvm_v4f64_ty], [IntrNoMem]>;
1036   def int_x86_avx_hsub_ps_256 : GCCBuiltin<"__builtin_ia32_hsubps256">,
1037         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1038                   llvm_v8f32_ty], [IntrNoMem]>;
1039   def int_x86_avx_hsub_pd_256 : GCCBuiltin<"__builtin_ia32_hsubpd256">,
1040         Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1041                   llvm_v4f64_ty], [IntrNoMem]>;
1042   def int_x86_avx_hadd_ps_256 : GCCBuiltin<"__builtin_ia32_haddps256">,
1043         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1044                   llvm_v8f32_ty], [IntrNoMem]>;
1045 }
1046
1047 // Vector permutation
1048 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1049   def int_x86_avx_vpermilvar_pd : GCCBuiltin<"__builtin_ia32_vpermilvarpd">,
1050         Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
1051                   llvm_v2i64_ty], [IntrNoMem]>;
1052   def int_x86_avx_vpermilvar_ps : GCCBuiltin<"__builtin_ia32_vpermilvarps">,
1053         Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
1054                   llvm_v4i32_ty], [IntrNoMem]>;
1055
1056   def int_x86_avx_vpermilvar_pd_256 :
1057         GCCBuiltin<"__builtin_ia32_vpermilvarpd256">,
1058         Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, llvm_v4i64_ty], [IntrNoMem]>;
1059   def int_x86_avx_vpermilvar_ps_256 :
1060         GCCBuiltin<"__builtin_ia32_vpermilvarps256">,
1061         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, llvm_v8i32_ty], [IntrNoMem]>;
1062
1063   def int_x86_avx_vperm2f128_pd_256 :
1064         GCCBuiltin<"__builtin_ia32_vperm2f128_pd256">,
1065         Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1066                   llvm_v4f64_ty, llvm_i8_ty], [IntrNoMem]>;
1067   def int_x86_avx_vperm2f128_ps_256 :
1068         GCCBuiltin<"__builtin_ia32_vperm2f128_ps256">,
1069         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1070                   llvm_v8f32_ty, llvm_i8_ty], [IntrNoMem]>;
1071   def int_x86_avx_vperm2f128_si_256 :
1072         GCCBuiltin<"__builtin_ia32_vperm2f128_si256">,
1073         Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1074                   llvm_v8i32_ty, llvm_i8_ty], [IntrNoMem]>;
1075
1076   def int_x86_avx_vpermil_pd : GCCBuiltin<"__builtin_ia32_vpermilpd">,
1077         Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
1078                   llvm_i8_ty], [IntrNoMem]>;
1079   def int_x86_avx_vpermil_ps : GCCBuiltin<"__builtin_ia32_vpermilps">,
1080         Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
1081                   llvm_i8_ty], [IntrNoMem]>;
1082
1083   def int_x86_avx_vpermil_pd_256 : GCCBuiltin<"__builtin_ia32_vpermilpd256">,
1084         Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1085                   llvm_i8_ty], [IntrNoMem]>;
1086   def int_x86_avx_vpermil_ps_256 : GCCBuiltin<"__builtin_ia32_vpermilps256">,
1087         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1088                   llvm_i8_ty], [IntrNoMem]>;
1089 }
1090
1091 // Vector blend
1092 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1093   def int_x86_avx_blend_pd_256 : GCCBuiltin<"__builtin_ia32_blendpd256">,
1094         Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1095                   llvm_v4f64_ty, llvm_i32_ty], [IntrNoMem]>;
1096   def int_x86_avx_blend_ps_256 : GCCBuiltin<"__builtin_ia32_blendps256">,
1097         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1098                   llvm_v8f32_ty, llvm_i32_ty], [IntrNoMem]>;
1099   def int_x86_avx_blendv_pd_256 : GCCBuiltin<"__builtin_ia32_blendvpd256">,
1100         Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1101                   llvm_v4f64_ty, llvm_v4f64_ty], [IntrNoMem]>;
1102   def int_x86_avx_blendv_ps_256 : GCCBuiltin<"__builtin_ia32_blendvps256">,
1103         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1104                   llvm_v8f32_ty, llvm_v8f32_ty], [IntrNoMem]>;
1105 }
1106
1107 // Vector dot product
1108 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1109   def int_x86_avx_dp_ps_256 : GCCBuiltin<"__builtin_ia32_dpps256">,
1110         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1111                   llvm_v8f32_ty, llvm_i32_ty], [IntrNoMem]>;
1112 }
1113
1114 // Vector compare
1115 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1116   def int_x86_avx_cmp_pd_256 : GCCBuiltin<"__builtin_ia32_cmppd256">,
1117         Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1118                   llvm_v4f64_ty, llvm_i8_ty], [IntrNoMem]>;
1119   def int_x86_avx_cmp_ps_256 : GCCBuiltin<"__builtin_ia32_cmpps256">,
1120         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1121                   llvm_v8f32_ty, llvm_i8_ty], [IntrNoMem]>;
1122 }
1123
1124 // Vector extract and insert
1125 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1126   def int_x86_avx_vextractf128_pd_256 :
1127         GCCBuiltin<"__builtin_ia32_vextractf128_pd256">,
1128         Intrinsic<[llvm_v2f64_ty], [llvm_v4f64_ty, llvm_i8_ty], [IntrNoMem]>;
1129   def int_x86_avx_vextractf128_ps_256 :
1130         GCCBuiltin<"__builtin_ia32_vextractf128_ps256">,
1131         Intrinsic<[llvm_v4f32_ty], [llvm_v8f32_ty, llvm_i8_ty], [IntrNoMem]>;
1132   def int_x86_avx_vextractf128_si_256 :
1133         GCCBuiltin<"__builtin_ia32_vextractf128_si256">,
1134         Intrinsic<[llvm_v4i32_ty], [llvm_v8i32_ty, llvm_i8_ty], [IntrNoMem]>;
1135
1136   def int_x86_avx_vinsertf128_pd_256 :
1137         GCCBuiltin<"__builtin_ia32_vinsertf128_pd256">,
1138         Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1139                   llvm_v2f64_ty, llvm_i8_ty], [IntrNoMem]>;
1140   def int_x86_avx_vinsertf128_ps_256 :
1141         GCCBuiltin<"__builtin_ia32_vinsertf128_ps256">,
1142         Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1143                   llvm_v4f32_ty, llvm_i8_ty], [IntrNoMem]>;
1144   def int_x86_avx_vinsertf128_si_256 :
1145         GCCBuiltin<"__builtin_ia32_vinsertf128_si256">,
1146         Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1147                   llvm_v4i32_ty, llvm_i8_ty], [IntrNoMem]>;
1148 }
1149
1150 // Vector convert
1151 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1152   def int_x86_avx_cvtdq2_pd_256 : GCCBuiltin<"__builtin_ia32_cvtdq2pd256">,
1153         Intrinsic<[llvm_v4f64_ty], [llvm_v4i32_ty], [IntrNoMem]>;
1154   def int_x86_avx_cvtdq2_ps_256 : GCCBuiltin<"__builtin_ia32_cvtdq2ps256">,
1155         Intrinsic<[llvm_v8f32_ty], [llvm_v8i32_ty], [IntrNoMem]>;
1156   def int_x86_avx_cvt_pd2_ps_256 : GCCBuiltin<"__builtin_ia32_cvtpd2ps256">,
1157         Intrinsic<[llvm_v4f32_ty], [llvm_v4f64_ty], [IntrNoMem]>;
1158   def int_x86_avx_cvt_ps2dq_256 : GCCBuiltin<"__builtin_ia32_cvtps2dq256">,
1159         Intrinsic<[llvm_v8i32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
1160   def int_x86_avx_cvt_ps2_pd_256 : GCCBuiltin<"__builtin_ia32_cvtps2pd256">,
1161         Intrinsic<[llvm_v4f64_ty], [llvm_v4f32_ty], [IntrNoMem]>;
1162   def int_x86_avx_cvtt_pd2dq_256 : GCCBuiltin<"__builtin_ia32_cvttpd2dq256">,
1163         Intrinsic<[llvm_v4i32_ty], [llvm_v4f64_ty], [IntrNoMem]>;
1164   def int_x86_avx_cvt_pd2dq_256 : GCCBuiltin<"__builtin_ia32_cvtpd2dq256">,
1165         Intrinsic<[llvm_v4i32_ty], [llvm_v4f64_ty], [IntrNoMem]>;
1166   def int_x86_avx_cvtt_ps2dq_256 : GCCBuiltin<"__builtin_ia32_cvttps2dq256">,
1167         Intrinsic<[llvm_v8i32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
1168 }
1169
1170 // Vector bit test
1171 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1172   def int_x86_avx_vtestz_pd : GCCBuiltin<"__builtin_ia32_vtestzpd">,
1173         Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
1174                   llvm_v2f64_ty], [IntrNoMem]>;
1175   def int_x86_avx_vtestc_pd : GCCBuiltin<"__builtin_ia32_vtestcpd">,
1176         Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
1177                   llvm_v2f64_ty], [IntrNoMem]>;
1178   def int_x86_avx_vtestnzc_pd : GCCBuiltin<"__builtin_ia32_vtestnzcpd">,
1179         Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
1180                   llvm_v2f64_ty], [IntrNoMem]>;
1181   def int_x86_avx_vtestz_ps : GCCBuiltin<"__builtin_ia32_vtestzps">,
1182         Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
1183                   llvm_v4f32_ty], [IntrNoMem]>;
1184   def int_x86_avx_vtestc_ps : GCCBuiltin<"__builtin_ia32_vtestcps">,
1185         Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
1186                   llvm_v4f32_ty], [IntrNoMem]>;
1187   def int_x86_avx_vtestnzc_ps : GCCBuiltin<"__builtin_ia32_vtestnzcps">,
1188         Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
1189                   llvm_v4f32_ty], [IntrNoMem]>;
1190   def int_x86_avx_vtestz_pd_256 : GCCBuiltin<"__builtin_ia32_vtestzpd256">,
1191         Intrinsic<[llvm_i32_ty], [llvm_v4f64_ty,
1192                   llvm_v4f64_ty], [IntrNoMem]>;
1193   def int_x86_avx_vtestc_pd_256 : GCCBuiltin<"__builtin_ia32_vtestcpd256">,
1194         Intrinsic<[llvm_i32_ty], [llvm_v4f64_ty,
1195                   llvm_v4f64_ty], [IntrNoMem]>;
1196   def int_x86_avx_vtestnzc_pd_256 : GCCBuiltin<"__builtin_ia32_vtestnzcpd256">,
1197         Intrinsic<[llvm_i32_ty], [llvm_v4f64_ty,
1198                   llvm_v4f64_ty], [IntrNoMem]>;
1199   def int_x86_avx_vtestz_ps_256 : GCCBuiltin<"__builtin_ia32_vtestzps256">,
1200         Intrinsic<[llvm_i32_ty], [llvm_v8f32_ty,
1201                   llvm_v8f32_ty], [IntrNoMem]>;
1202   def int_x86_avx_vtestc_ps_256 : GCCBuiltin<"__builtin_ia32_vtestcps256">,
1203         Intrinsic<[llvm_i32_ty], [llvm_v8f32_ty,
1204                   llvm_v8f32_ty], [IntrNoMem]>;
1205   def int_x86_avx_vtestnzc_ps_256 : GCCBuiltin<"__builtin_ia32_vtestnzcps256">,
1206         Intrinsic<[llvm_i32_ty], [llvm_v8f32_ty,
1207                   llvm_v8f32_ty], [IntrNoMem]>;
1208   def int_x86_avx_ptestz_256 : GCCBuiltin<"__builtin_ia32_ptestz256">,
1209         Intrinsic<[llvm_i32_ty], [llvm_v4i64_ty,
1210                   llvm_v4i64_ty], [IntrNoMem]>;
1211   def int_x86_avx_ptestc_256 : GCCBuiltin<"__builtin_ia32_ptestc256">,
1212         Intrinsic<[llvm_i32_ty], [llvm_v4i64_ty,
1213                   llvm_v4i64_ty], [IntrNoMem]>;
1214   def int_x86_avx_ptestnzc_256 : GCCBuiltin<"__builtin_ia32_ptestnzc256">,
1215         Intrinsic<[llvm_i32_ty], [llvm_v4i64_ty,
1216                   llvm_v4i64_ty], [IntrNoMem]>;
1217 }
1218
1219 // Vector extract sign mask
1220 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1221   def int_x86_avx_movmsk_pd_256 : GCCBuiltin<"__builtin_ia32_movmskpd256">,
1222         Intrinsic<[llvm_i32_ty], [llvm_v4f64_ty], [IntrNoMem]>;
1223   def int_x86_avx_movmsk_ps_256 : GCCBuiltin<"__builtin_ia32_movmskps256">,
1224         Intrinsic<[llvm_i32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
1225 }
1226
1227 // Vector zero
1228 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1229   def int_x86_avx_vzeroall : GCCBuiltin<"__builtin_ia32_vzeroall">,
1230         Intrinsic<[], [], []>;
1231   def int_x86_avx_vzeroupper : GCCBuiltin<"__builtin_ia32_vzeroupper">,
1232         Intrinsic<[], [], []>;
1233 }
1234
1235 // Vector load with broadcast
1236 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1237   def int_x86_avx_vbroadcastss :
1238         GCCBuiltin<"__builtin_ia32_vbroadcastss">,
1239         Intrinsic<[llvm_v4f32_ty], [llvm_ptr_ty], [IntrReadMem]>;
1240   def int_x86_avx_vbroadcast_sd_256 :
1241         GCCBuiltin<"__builtin_ia32_vbroadcastsd256">,
1242         Intrinsic<[llvm_v4f64_ty], [llvm_ptr_ty], [IntrReadMem]>;
1243   def int_x86_avx_vbroadcastss_256 :
1244         GCCBuiltin<"__builtin_ia32_vbroadcastss256">,
1245         Intrinsic<[llvm_v8f32_ty], [llvm_ptr_ty], [IntrReadMem]>;
1246   def int_x86_avx_vbroadcastf128_pd_256 :
1247         GCCBuiltin<"__builtin_ia32_vbroadcastf128_pd256">,
1248         Intrinsic<[llvm_v4f64_ty], [llvm_ptr_ty], [IntrReadMem]>;
1249   def int_x86_avx_vbroadcastf128_ps_256 :
1250         GCCBuiltin<"__builtin_ia32_vbroadcastf128_ps256">,
1251         Intrinsic<[llvm_v8f32_ty], [llvm_ptr_ty], [IntrReadMem]>;
1252 }
1253
1254 // SIMD load ops
1255 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1256   def int_x86_avx_loadu_pd_256 : GCCBuiltin<"__builtin_ia32_loadupd256">,
1257         Intrinsic<[llvm_v4f64_ty], [llvm_ptr_ty], [IntrReadMem]>;
1258   def int_x86_avx_loadu_ps_256 : GCCBuiltin<"__builtin_ia32_loadups256">,
1259         Intrinsic<[llvm_v8f32_ty], [llvm_ptr_ty], [IntrReadMem]>;
1260   def int_x86_avx_loadu_dq_256 : GCCBuiltin<"__builtin_ia32_loaddqu256">,
1261         Intrinsic<[llvm_v32i8_ty], [llvm_ptr_ty], [IntrReadMem]>;
1262   def int_x86_avx_ldu_dq_256 : GCCBuiltin<"__builtin_ia32_lddqu256">,
1263         Intrinsic<[llvm_v32i8_ty], [llvm_ptr_ty], [IntrReadMem]>;
1264 }
1265
1266 // SIMD store ops
1267 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1268   def int_x86_avx_storeu_pd_256 : GCCBuiltin<"__builtin_ia32_storeupd256">,
1269         Intrinsic<[], [llvm_ptr_ty, llvm_v4f64_ty], []>;
1270   def int_x86_avx_storeu_ps_256 : GCCBuiltin<"__builtin_ia32_storeups256">,
1271         Intrinsic<[], [llvm_ptr_ty, llvm_v8f32_ty], []>;
1272   def int_x86_avx_storeu_dq_256 : GCCBuiltin<"__builtin_ia32_storedqu256">,
1273         Intrinsic<[], [llvm_ptr_ty, llvm_v32i8_ty], []>;
1274 }
1275
1276 // Cacheability support ops
1277 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1278   def int_x86_avx_movnt_dq_256 : GCCBuiltin<"__builtin_ia32_movntdq256">,
1279         Intrinsic<[], [llvm_ptr_ty, llvm_v4i64_ty], []>;
1280   def int_x86_avx_movnt_pd_256 : GCCBuiltin<"__builtin_ia32_movntpd256">,
1281         Intrinsic<[], [llvm_ptr_ty, llvm_v4f64_ty], []>;
1282   def int_x86_avx_movnt_ps_256 : GCCBuiltin<"__builtin_ia32_movntps256">,
1283         Intrinsic<[], [llvm_ptr_ty, llvm_v8f32_ty], []>;
1284 }
1285
1286 // Conditional load ops
1287 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1288   def int_x86_avx_maskload_pd : GCCBuiltin<"__builtin_ia32_maskloadpd">,
1289         Intrinsic<[llvm_v2f64_ty], [llvm_ptr_ty, llvm_v2f64_ty], [IntrReadMem]>;
1290   def int_x86_avx_maskload_ps : GCCBuiltin<"__builtin_ia32_maskloadps">,
1291         Intrinsic<[llvm_v4f32_ty], [llvm_ptr_ty, llvm_v4f32_ty], [IntrReadMem]>;
1292   def int_x86_avx_maskload_pd_256 : GCCBuiltin<"__builtin_ia32_maskloadpd256">,
1293         Intrinsic<[llvm_v4f64_ty], [llvm_ptr_ty, llvm_v4f64_ty], [IntrReadMem]>;
1294   def int_x86_avx_maskload_ps_256 : GCCBuiltin<"__builtin_ia32_maskloadps256">,
1295         Intrinsic<[llvm_v8f32_ty], [llvm_ptr_ty, llvm_v8f32_ty], [IntrReadMem]>;
1296 }
1297
1298 // Conditional store ops
1299 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1300   def int_x86_avx_maskstore_pd : GCCBuiltin<"__builtin_ia32_maskstorepd">,
1301         Intrinsic<[], [llvm_ptr_ty,
1302                   llvm_v2f64_ty, llvm_v2f64_ty], []>;
1303   def int_x86_avx_maskstore_ps : GCCBuiltin<"__builtin_ia32_maskstoreps">,
1304         Intrinsic<[], [llvm_ptr_ty,
1305                   llvm_v4f32_ty, llvm_v4f32_ty], []>;
1306   def int_x86_avx_maskstore_pd_256 :
1307         GCCBuiltin<"__builtin_ia32_maskstorepd256">,
1308         Intrinsic<[], [llvm_ptr_ty,
1309                   llvm_v4f64_ty, llvm_v4f64_ty], []>;
1310   def int_x86_avx_maskstore_ps_256 :
1311         GCCBuiltin<"__builtin_ia32_maskstoreps256">,
1312         Intrinsic<[], [llvm_ptr_ty,
1313                   llvm_v8f32_ty, llvm_v8f32_ty], []>;
1314 }
1315
1316 //===----------------------------------------------------------------------===//
1317 // MMX
1318
1319 // Empty MMX state op.
1320 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1321   def int_x86_mmx_emms  : GCCBuiltin<"__builtin_ia32_emms">,
1322               Intrinsic<[], [], []>;
1323   def int_x86_mmx_femms : GCCBuiltin<"__builtin_ia32_femms">,
1324               Intrinsic<[], [], []>;
1325 }
1326
1327 // Integer arithmetic ops.
1328 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1329   // Addition
1330   def int_x86_mmx_padd_b : GCCBuiltin<"__builtin_ia32_paddb">,
1331               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
1332                         [IntrNoMem]>;
1333   def int_x86_mmx_padd_w : GCCBuiltin<"__builtin_ia32_paddw">,
1334               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
1335                         [IntrNoMem]>;
1336   def int_x86_mmx_padd_d : GCCBuiltin<"__builtin_ia32_paddd">,
1337               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
1338                         [IntrNoMem]>;
1339   def int_x86_mmx_padd_q : GCCBuiltin<"__builtin_ia32_paddq">,
1340               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
1341                         [IntrNoMem]>;
1342
1343   def int_x86_mmx_padds_b : GCCBuiltin<"__builtin_ia32_paddsb">,
1344               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1345                          llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
1346   def int_x86_mmx_padds_w : GCCBuiltin<"__builtin_ia32_paddsw">,
1347               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1348                          llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
1349
1350   def int_x86_mmx_paddus_b : GCCBuiltin<"__builtin_ia32_paddusb">,
1351               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1352                          llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
1353   def int_x86_mmx_paddus_w : GCCBuiltin<"__builtin_ia32_paddusw">,
1354               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1355                          llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
1356
1357   // Subtraction
1358   def int_x86_mmx_psub_b : GCCBuiltin<"__builtin_ia32_psubb">,
1359               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
1360                         [IntrNoMem]>;
1361   def int_x86_mmx_psub_w : GCCBuiltin<"__builtin_ia32_psubw">,
1362               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
1363                         [IntrNoMem]>;
1364   def int_x86_mmx_psub_d : GCCBuiltin<"__builtin_ia32_psubd">,
1365               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
1366                         [IntrNoMem]>;
1367   def int_x86_mmx_psub_q : GCCBuiltin<"__builtin_ia32_psubq">,
1368               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
1369                         [IntrNoMem]>;
1370
1371   def int_x86_mmx_psubs_b : GCCBuiltin<"__builtin_ia32_psubsb">,
1372               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1373                          llvm_x86mmx_ty], [IntrNoMem]>;
1374   def int_x86_mmx_psubs_w : GCCBuiltin<"__builtin_ia32_psubsw">,
1375               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1376                          llvm_x86mmx_ty], [IntrNoMem]>;
1377
1378   def int_x86_mmx_psubus_b : GCCBuiltin<"__builtin_ia32_psubusb">,
1379               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1380                          llvm_x86mmx_ty], [IntrNoMem]>;
1381   def int_x86_mmx_psubus_w : GCCBuiltin<"__builtin_ia32_psubusw">,
1382               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1383                          llvm_x86mmx_ty], [IntrNoMem]>;
1384
1385   // Multiplication
1386   def int_x86_mmx_pmulh_w : GCCBuiltin<"__builtin_ia32_pmulhw">,
1387               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1388                          llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
1389   def int_x86_mmx_pmull_w : GCCBuiltin<"__builtin_ia32_pmullw">,
1390               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1391                          llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
1392   def int_x86_mmx_pmulhu_w : GCCBuiltin<"__builtin_ia32_pmulhuw">,
1393               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1394                          llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
1395   def int_x86_mmx_pmulu_dq : GCCBuiltin<"__builtin_ia32_pmuludq">,
1396               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1397                          llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
1398   def int_x86_mmx_pmadd_wd : GCCBuiltin<"__builtin_ia32_pmaddwd">,
1399               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1400                          llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
1401
1402   // Bitwise operations
1403   def int_x86_mmx_pand : GCCBuiltin<"__builtin_ia32_pand">,
1404               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
1405                         [IntrNoMem]>;
1406   def int_x86_mmx_pandn : GCCBuiltin<"__builtin_ia32_pandn">,
1407               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
1408                         [IntrNoMem]>;
1409   def int_x86_mmx_por : GCCBuiltin<"__builtin_ia32_por">,
1410               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
1411                         [IntrNoMem]>;
1412   def int_x86_mmx_pxor : GCCBuiltin<"__builtin_ia32_pxor">,
1413               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
1414                         [IntrNoMem]>;
1415
1416   // Averages
1417   def int_x86_mmx_pavg_b : GCCBuiltin<"__builtin_ia32_pavgb">,
1418               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1419                          llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
1420   def int_x86_mmx_pavg_w : GCCBuiltin<"__builtin_ia32_pavgw">,
1421               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1422                          llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
1423
1424   // Maximum
1425   def int_x86_mmx_pmaxu_b : GCCBuiltin<"__builtin_ia32_pmaxub">,
1426               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1427                          llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
1428   def int_x86_mmx_pmaxs_w : GCCBuiltin<"__builtin_ia32_pmaxsw">,
1429               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1430                          llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
1431
1432   // Minimum
1433   def int_x86_mmx_pminu_b : GCCBuiltin<"__builtin_ia32_pminub">,
1434               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1435                          llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
1436   def int_x86_mmx_pmins_w : GCCBuiltin<"__builtin_ia32_pminsw">,
1437               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1438                          llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
1439
1440   // Packed sum of absolute differences
1441   def int_x86_mmx_psad_bw : GCCBuiltin<"__builtin_ia32_psadbw">,
1442               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1443                          llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
1444 }
1445
1446 // Integer shift ops.
1447 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1448   // Shift left logical
1449   def int_x86_mmx_psll_w : GCCBuiltin<"__builtin_ia32_psllw">,
1450               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1451                          llvm_x86mmx_ty], [IntrNoMem]>;
1452   def int_x86_mmx_psll_d : GCCBuiltin<"__builtin_ia32_pslld">,
1453               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1454                          llvm_x86mmx_ty], [IntrNoMem]>;
1455   def int_x86_mmx_psll_q : GCCBuiltin<"__builtin_ia32_psllq">,
1456               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1457                          llvm_x86mmx_ty], [IntrNoMem]>;
1458
1459   def int_x86_mmx_psrl_w : GCCBuiltin<"__builtin_ia32_psrlw">,
1460               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1461                          llvm_x86mmx_ty], [IntrNoMem]>;
1462   def int_x86_mmx_psrl_d : GCCBuiltin<"__builtin_ia32_psrld">,
1463               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1464                          llvm_x86mmx_ty], [IntrNoMem]>;
1465   def int_x86_mmx_psrl_q : GCCBuiltin<"__builtin_ia32_psrlq">,
1466               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1467                          llvm_x86mmx_ty], [IntrNoMem]>;
1468
1469   def int_x86_mmx_psra_w : GCCBuiltin<"__builtin_ia32_psraw">,
1470               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1471                          llvm_x86mmx_ty], [IntrNoMem]>;
1472   def int_x86_mmx_psra_d : GCCBuiltin<"__builtin_ia32_psrad">,
1473               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1474                          llvm_x86mmx_ty], [IntrNoMem]>;
1475
1476   def int_x86_mmx_pslli_w : GCCBuiltin<"__builtin_ia32_psllwi">,
1477               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1478                          llvm_i32_ty], [IntrNoMem]>;
1479   def int_x86_mmx_pslli_d : GCCBuiltin<"__builtin_ia32_pslldi">,
1480               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1481                          llvm_i32_ty], [IntrNoMem]>;
1482   def int_x86_mmx_pslli_q : GCCBuiltin<"__builtin_ia32_psllqi">,
1483               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1484                          llvm_i32_ty], [IntrNoMem]>;
1485
1486   def int_x86_mmx_psrli_w : GCCBuiltin<"__builtin_ia32_psrlwi">,
1487               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1488                          llvm_i32_ty], [IntrNoMem]>;
1489   def int_x86_mmx_psrli_d : GCCBuiltin<"__builtin_ia32_psrldi">,
1490               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1491                          llvm_i32_ty], [IntrNoMem]>;
1492   def int_x86_mmx_psrli_q : GCCBuiltin<"__builtin_ia32_psrlqi">,
1493               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1494                          llvm_i32_ty], [IntrNoMem]>;
1495
1496   def int_x86_mmx_psrai_w : GCCBuiltin<"__builtin_ia32_psrawi">,
1497               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1498                          llvm_i32_ty], [IntrNoMem]>;
1499   def int_x86_mmx_psrai_d : GCCBuiltin<"__builtin_ia32_psradi">,
1500               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1501                          llvm_i32_ty], [IntrNoMem]>;
1502 }
1503
1504 // Pack ops.
1505 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1506   def int_x86_mmx_packsswb : GCCBuiltin<"__builtin_ia32_packsswb">,
1507               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1508                          llvm_x86mmx_ty], [IntrNoMem]>;
1509   def int_x86_mmx_packssdw : GCCBuiltin<"__builtin_ia32_packssdw">,
1510               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1511                          llvm_x86mmx_ty], [IntrNoMem]>;
1512   def int_x86_mmx_packuswb : GCCBuiltin<"__builtin_ia32_packuswb">,
1513               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1514                          llvm_x86mmx_ty], [IntrNoMem]>;
1515 }
1516
1517 // Unpacking ops.
1518 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1519   def int_x86_mmx_punpckhbw : GCCBuiltin<"__builtin_ia32_punpckhbw">,
1520               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
1521                         [IntrNoMem]>;
1522   def int_x86_mmx_punpckhwd : GCCBuiltin<"__builtin_ia32_punpckhwd">,
1523               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
1524                         [IntrNoMem]>;
1525   def int_x86_mmx_punpckhdq : GCCBuiltin<"__builtin_ia32_punpckhdq">,
1526               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
1527                         [IntrNoMem]>;
1528   def int_x86_mmx_punpcklbw : GCCBuiltin<"__builtin_ia32_punpcklbw">,
1529               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
1530                         [IntrNoMem]>;
1531   def int_x86_mmx_punpcklwd : GCCBuiltin<"__builtin_ia32_punpcklwd">,
1532               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
1533                         [IntrNoMem]>;
1534   def int_x86_mmx_punpckldq : GCCBuiltin<"__builtin_ia32_punpckldq">,
1535               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
1536                         [IntrNoMem]>;
1537 }
1538
1539 // Integer comparison ops
1540 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1541   def int_x86_mmx_pcmpeq_b : GCCBuiltin<"__builtin_ia32_pcmpeqb">,
1542               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1543                          llvm_x86mmx_ty], [IntrNoMem]>;
1544   def int_x86_mmx_pcmpeq_w : GCCBuiltin<"__builtin_ia32_pcmpeqw">,
1545               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1546                          llvm_x86mmx_ty], [IntrNoMem]>;
1547   def int_x86_mmx_pcmpeq_d : GCCBuiltin<"__builtin_ia32_pcmpeqd">,
1548               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1549                          llvm_x86mmx_ty], [IntrNoMem]>;
1550
1551   def int_x86_mmx_pcmpgt_b : GCCBuiltin<"__builtin_ia32_pcmpgtb">,
1552               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1553                          llvm_x86mmx_ty], [IntrNoMem]>;
1554   def int_x86_mmx_pcmpgt_w : GCCBuiltin<"__builtin_ia32_pcmpgtw">,
1555               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1556                          llvm_x86mmx_ty], [IntrNoMem]>;
1557   def int_x86_mmx_pcmpgt_d : GCCBuiltin<"__builtin_ia32_pcmpgtd">,
1558               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
1559                          llvm_x86mmx_ty], [IntrNoMem]>;
1560 }
1561
1562 // Misc.
1563 let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1564   def int_x86_mmx_maskmovq : GCCBuiltin<"__builtin_ia32_maskmovq">,
1565               Intrinsic<[], [llvm_x86mmx_ty, llvm_x86mmx_ty, llvm_ptr_ty], []>;
1566
1567   def int_x86_mmx_pmovmskb : GCCBuiltin<"__builtin_ia32_pmovmskb">,
1568               Intrinsic<[llvm_i32_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
1569
1570   def int_x86_mmx_movnt_dq : GCCBuiltin<"__builtin_ia32_movntq">,
1571               Intrinsic<[], [llvm_ptrx86mmx_ty, llvm_x86mmx_ty], []>;
1572
1573   def int_x86_mmx_palignr_b : GCCBuiltin<"__builtin_ia32_palignr">,
1574               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, 
1575                         llvm_x86mmx_ty, llvm_i8_ty], [IntrNoMem]>;
1576
1577   def int_x86_mmx_pextr_w : GCCBuiltin<"__builtin_ia32_vec_ext_v4hi">,
1578               Intrinsic<[llvm_i32_ty], [llvm_x86mmx_ty, llvm_i32_ty], 
1579                         [IntrNoMem]>;
1580
1581   def int_x86_mmx_pinsr_w : GCCBuiltin<"__builtin_ia32_vec_set_v4hi">,
1582               Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, 
1583                         llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
1584 }