• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
16let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
17  def int_x86_int : Intrinsic<[], [llvm_i8_ty]>;
18}
19
20//===----------------------------------------------------------------------===//
21// 3DNow!
22
23let TargetPrefix = "x86" in {
24  def int_x86_3dnow_pavgusb : GCCBuiltin<"__builtin_ia32_pavgusb">,
25              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
26                        [IntrNoMem]>;
27  def int_x86_3dnow_pf2id : GCCBuiltin<"__builtin_ia32_pf2id">,
28              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
29  def int_x86_3dnow_pfacc : GCCBuiltin<"__builtin_ia32_pfacc">,
30              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
31                        [IntrNoMem]>;
32  def int_x86_3dnow_pfadd : GCCBuiltin<"__builtin_ia32_pfadd">,
33              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
34                        [IntrNoMem]>;
35  def int_x86_3dnow_pfcmpeq : GCCBuiltin<"__builtin_ia32_pfcmpeq">,
36              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
37                        [IntrNoMem]>;
38  def int_x86_3dnow_pfcmpge : GCCBuiltin<"__builtin_ia32_pfcmpge">,
39              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
40                        [IntrNoMem]>;
41  def int_x86_3dnow_pfcmpgt : GCCBuiltin<"__builtin_ia32_pfcmpgt">,
42              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
43                        [IntrNoMem]>;
44  def int_x86_3dnow_pfmax : GCCBuiltin<"__builtin_ia32_pfmax">,
45              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
46                        [IntrNoMem]>;
47  def int_x86_3dnow_pfmin : GCCBuiltin<"__builtin_ia32_pfmin">,
48              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
49                        [IntrNoMem]>;
50  def int_x86_3dnow_pfmul : GCCBuiltin<"__builtin_ia32_pfmul">,
51              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
52                        [IntrNoMem]>;
53  def int_x86_3dnow_pfrcp : GCCBuiltin<"__builtin_ia32_pfrcp">,
54              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
55  def int_x86_3dnow_pfrcpit1 : GCCBuiltin<"__builtin_ia32_pfrcpit1">,
56              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
57                        [IntrNoMem]>;
58  def int_x86_3dnow_pfrcpit2 : GCCBuiltin<"__builtin_ia32_pfrcpit2">,
59              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
60                        [IntrNoMem]>;
61  def int_x86_3dnow_pfrsqrt : GCCBuiltin<"__builtin_ia32_pfrsqrt">,
62              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
63  def int_x86_3dnow_pfrsqit1 : GCCBuiltin<"__builtin_ia32_pfrsqit1">,
64              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
65                        [IntrNoMem]>;
66  def int_x86_3dnow_pfsub : GCCBuiltin<"__builtin_ia32_pfsub">,
67              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
68                        [IntrNoMem]>;
69  def int_x86_3dnow_pfsubr : GCCBuiltin<"__builtin_ia32_pfsubr">,
70              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
71                        [IntrNoMem]>;
72  def int_x86_3dnow_pi2fd : GCCBuiltin<"__builtin_ia32_pi2fd">,
73              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
74  def int_x86_3dnow_pmulhrw : GCCBuiltin<"__builtin_ia32_pmulhrw">,
75              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
76                        [IntrNoMem]>;
77}
78
79//===----------------------------------------------------------------------===//
80// 3DNow! extensions
81
82let TargetPrefix = "x86" in {
83  def int_x86_3dnowa_pf2iw : GCCBuiltin<"__builtin_ia32_pf2iw">,
84              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
85  def int_x86_3dnowa_pfnacc : GCCBuiltin<"__builtin_ia32_pfnacc">,
86              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
87                        [IntrNoMem]>;
88  def int_x86_3dnowa_pfpnacc : GCCBuiltin<"__builtin_ia32_pfpnacc">,
89              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
90                        [IntrNoMem]>;
91  def int_x86_3dnowa_pi2fw : GCCBuiltin<"__builtin_ia32_pi2fw">,
92              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
93  def int_x86_3dnowa_pswapd :
94              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
95}
96
97//===----------------------------------------------------------------------===//
98// SSE1
99
100// Arithmetic ops
101let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
102  def int_x86_sse_add_ss : GCCBuiltin<"__builtin_ia32_addss">,
103              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
104                         llvm_v4f32_ty], [IntrNoMem]>;
105  def int_x86_sse_sub_ss : GCCBuiltin<"__builtin_ia32_subss">,
106              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
107                         llvm_v4f32_ty], [IntrNoMem]>;
108  def int_x86_sse_mul_ss : GCCBuiltin<"__builtin_ia32_mulss">,
109              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
110                         llvm_v4f32_ty], [IntrNoMem]>;
111  def int_x86_sse_div_ss : GCCBuiltin<"__builtin_ia32_divss">,
112              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
113                         llvm_v4f32_ty], [IntrNoMem]>;
114  def int_x86_sse_sqrt_ss : GCCBuiltin<"__builtin_ia32_sqrtss">,
115              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty],
116                        [IntrNoMem]>;
117  def int_x86_sse_sqrt_ps : GCCBuiltin<"__builtin_ia32_sqrtps">,
118              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty],
119                        [IntrNoMem]>;
120  def int_x86_sse_rcp_ss : GCCBuiltin<"__builtin_ia32_rcpss">,
121              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty],
122                        [IntrNoMem]>;
123  def int_x86_sse_rcp_ps : GCCBuiltin<"__builtin_ia32_rcpps">,
124              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty],
125                        [IntrNoMem]>;
126  def int_x86_sse_rsqrt_ss : GCCBuiltin<"__builtin_ia32_rsqrtss">,
127              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty],
128                        [IntrNoMem]>;
129  def int_x86_sse_rsqrt_ps : GCCBuiltin<"__builtin_ia32_rsqrtps">,
130              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty],
131                        [IntrNoMem]>;
132  def int_x86_sse_min_ss : GCCBuiltin<"__builtin_ia32_minss">,
133              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
134                         llvm_v4f32_ty], [IntrNoMem]>;
135  def int_x86_sse_min_ps : GCCBuiltin<"__builtin_ia32_minps">,
136              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
137                         llvm_v4f32_ty], [IntrNoMem]>;
138  def int_x86_sse_max_ss : GCCBuiltin<"__builtin_ia32_maxss">,
139              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
140                         llvm_v4f32_ty], [IntrNoMem]>;
141  def int_x86_sse_max_ps : GCCBuiltin<"__builtin_ia32_maxps">,
142              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
143                         llvm_v4f32_ty], [IntrNoMem]>;
144}
145
146// Comparison ops
147let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
148  def int_x86_sse_cmp_ss : GCCBuiltin<"__builtin_ia32_cmpss">,
149              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
150                         llvm_v4f32_ty, llvm_i8_ty], [IntrNoMem]>;
151  def int_x86_sse_cmp_ps : GCCBuiltin<"__builtin_ia32_cmpps">,
152              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
153                         llvm_v4f32_ty, llvm_i8_ty], [IntrNoMem]>;
154  def int_x86_sse_comieq_ss : GCCBuiltin<"__builtin_ia32_comieq">,
155              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
156                         llvm_v4f32_ty], [IntrNoMem]>;
157  def int_x86_sse_comilt_ss : GCCBuiltin<"__builtin_ia32_comilt">,
158              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
159                         llvm_v4f32_ty], [IntrNoMem]>;
160  def int_x86_sse_comile_ss : GCCBuiltin<"__builtin_ia32_comile">,
161              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
162                         llvm_v4f32_ty], [IntrNoMem]>;
163  def int_x86_sse_comigt_ss : GCCBuiltin<"__builtin_ia32_comigt">,
164              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
165                         llvm_v4f32_ty], [IntrNoMem]>;
166  def int_x86_sse_comige_ss : GCCBuiltin<"__builtin_ia32_comige">,
167              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
168                         llvm_v4f32_ty], [IntrNoMem]>;
169  def int_x86_sse_comineq_ss : GCCBuiltin<"__builtin_ia32_comineq">,
170              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
171                         llvm_v4f32_ty], [IntrNoMem]>;
172  def int_x86_sse_ucomieq_ss : GCCBuiltin<"__builtin_ia32_ucomieq">,
173              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
174                         llvm_v4f32_ty], [IntrNoMem]>;
175  def int_x86_sse_ucomilt_ss : GCCBuiltin<"__builtin_ia32_ucomilt">,
176              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
177                         llvm_v4f32_ty], [IntrNoMem]>;
178  def int_x86_sse_ucomile_ss : GCCBuiltin<"__builtin_ia32_ucomile">,
179              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
180                         llvm_v4f32_ty], [IntrNoMem]>;
181  def int_x86_sse_ucomigt_ss : GCCBuiltin<"__builtin_ia32_ucomigt">,
182              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
183                         llvm_v4f32_ty], [IntrNoMem]>;
184  def int_x86_sse_ucomige_ss : GCCBuiltin<"__builtin_ia32_ucomige">,
185              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
186                         llvm_v4f32_ty], [IntrNoMem]>;
187  def int_x86_sse_ucomineq_ss : GCCBuiltin<"__builtin_ia32_ucomineq">,
188              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
189                         llvm_v4f32_ty], [IntrNoMem]>;
190}
191
192
193// Conversion ops
194let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
195  def int_x86_sse_cvtss2si : GCCBuiltin<"__builtin_ia32_cvtss2si">,
196              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
197  def int_x86_sse_cvtss2si64 : GCCBuiltin<"__builtin_ia32_cvtss2si64">,
198              Intrinsic<[llvm_i64_ty], [llvm_v4f32_ty], [IntrNoMem]>;
199  def int_x86_sse_cvttss2si : GCCBuiltin<"__builtin_ia32_cvttss2si">,
200              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
201  def int_x86_sse_cvttss2si64 : GCCBuiltin<"__builtin_ia32_cvttss2si64">,
202              Intrinsic<[llvm_i64_ty], [llvm_v4f32_ty], [IntrNoMem]>;
203  def int_x86_sse_cvtsi2ss : GCCBuiltin<"__builtin_ia32_cvtsi2ss">,
204              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
205                         llvm_i32_ty], [IntrNoMem]>;
206  def int_x86_sse_cvtsi642ss : GCCBuiltin<"__builtin_ia32_cvtsi642ss">,
207              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
208                         llvm_i64_ty], [IntrNoMem]>;
209  def int_x86_sse_cvtps2pi : GCCBuiltin<"__builtin_ia32_cvtps2pi">,
210              Intrinsic<[llvm_x86mmx_ty], [llvm_v4f32_ty], [IntrNoMem]>;
211  def int_x86_sse_cvttps2pi: GCCBuiltin<"__builtin_ia32_cvttps2pi">,
212              Intrinsic<[llvm_x86mmx_ty], [llvm_v4f32_ty], [IntrNoMem]>;
213  def int_x86_sse_cvtpi2ps : GCCBuiltin<"__builtin_ia32_cvtpi2ps">,
214              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
215                         llvm_x86mmx_ty], [IntrNoMem]>;
216}
217
218// SIMD store ops
219let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
220  def int_x86_sse_storeu_ps : GCCBuiltin<"__builtin_ia32_storeups">,
221              Intrinsic<[], [llvm_ptr_ty,
222                         llvm_v4f32_ty], [IntrReadWriteArgMem]>;
223}
224
225// Cacheability support ops
226let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
227  def int_x86_sse_sfence : GCCBuiltin<"__builtin_ia32_sfence">,
228              Intrinsic<[], [], []>;
229}
230
231// Control register.
232let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
233  def int_x86_sse_stmxcsr :
234              Intrinsic<[], [llvm_ptr_ty], []>;
235  def int_x86_sse_ldmxcsr :
236              Intrinsic<[], [llvm_ptr_ty], []>;
237}
238
239// Misc.
240let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
241  def int_x86_sse_movmsk_ps : GCCBuiltin<"__builtin_ia32_movmskps">,
242              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
243}
244
245//===----------------------------------------------------------------------===//
246// SSE2
247
248// FP arithmetic ops
249let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
250  def int_x86_sse2_add_sd : GCCBuiltin<"__builtin_ia32_addsd">,
251              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
252                         llvm_v2f64_ty], [IntrNoMem]>;
253  def int_x86_sse2_sub_sd : GCCBuiltin<"__builtin_ia32_subsd">,
254              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
255                         llvm_v2f64_ty], [IntrNoMem]>;
256  def int_x86_sse2_mul_sd : GCCBuiltin<"__builtin_ia32_mulsd">,
257              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
258                         llvm_v2f64_ty], [IntrNoMem]>;
259  def int_x86_sse2_div_sd : GCCBuiltin<"__builtin_ia32_divsd">,
260              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
261                         llvm_v2f64_ty], [IntrNoMem]>;
262  def int_x86_sse2_sqrt_sd : GCCBuiltin<"__builtin_ia32_sqrtsd">,
263              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty],
264                        [IntrNoMem]>;
265  def int_x86_sse2_sqrt_pd : GCCBuiltin<"__builtin_ia32_sqrtpd">,
266              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty],
267                        [IntrNoMem]>;
268  def int_x86_sse2_min_sd : GCCBuiltin<"__builtin_ia32_minsd">,
269              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
270                         llvm_v2f64_ty], [IntrNoMem]>;
271  def int_x86_sse2_min_pd : GCCBuiltin<"__builtin_ia32_minpd">,
272              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
273                         llvm_v2f64_ty], [IntrNoMem]>;
274  def int_x86_sse2_max_sd : GCCBuiltin<"__builtin_ia32_maxsd">,
275              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
276                         llvm_v2f64_ty], [IntrNoMem]>;
277  def int_x86_sse2_max_pd : GCCBuiltin<"__builtin_ia32_maxpd">,
278              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
279                         llvm_v2f64_ty], [IntrNoMem]>;
280}
281
282// FP comparison ops
283let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
284  def int_x86_sse2_cmp_sd : GCCBuiltin<"__builtin_ia32_cmpsd">,
285              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
286                         llvm_v2f64_ty, llvm_i8_ty], [IntrNoMem]>;
287  def int_x86_sse2_cmp_pd : GCCBuiltin<"__builtin_ia32_cmppd">,
288              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
289                         llvm_v2f64_ty, llvm_i8_ty], [IntrNoMem]>;
290  def int_x86_sse2_comieq_sd : GCCBuiltin<"__builtin_ia32_comisdeq">,
291              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
292                         llvm_v2f64_ty], [IntrNoMem]>;
293  def int_x86_sse2_comilt_sd : GCCBuiltin<"__builtin_ia32_comisdlt">,
294              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
295                         llvm_v2f64_ty], [IntrNoMem]>;
296  def int_x86_sse2_comile_sd : GCCBuiltin<"__builtin_ia32_comisdle">,
297              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
298                         llvm_v2f64_ty], [IntrNoMem]>;
299  def int_x86_sse2_comigt_sd : GCCBuiltin<"__builtin_ia32_comisdgt">,
300              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
301                         llvm_v2f64_ty], [IntrNoMem]>;
302  def int_x86_sse2_comige_sd : GCCBuiltin<"__builtin_ia32_comisdge">,
303              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
304                         llvm_v2f64_ty], [IntrNoMem]>;
305  def int_x86_sse2_comineq_sd : GCCBuiltin<"__builtin_ia32_comisdneq">,
306              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
307                         llvm_v2f64_ty], [IntrNoMem]>;
308  def int_x86_sse2_ucomieq_sd : GCCBuiltin<"__builtin_ia32_ucomisdeq">,
309              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
310                         llvm_v2f64_ty], [IntrNoMem]>;
311  def int_x86_sse2_ucomilt_sd : GCCBuiltin<"__builtin_ia32_ucomisdlt">,
312              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
313                         llvm_v2f64_ty], [IntrNoMem]>;
314  def int_x86_sse2_ucomile_sd : GCCBuiltin<"__builtin_ia32_ucomisdle">,
315              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
316                         llvm_v2f64_ty], [IntrNoMem]>;
317  def int_x86_sse2_ucomigt_sd : GCCBuiltin<"__builtin_ia32_ucomisdgt">,
318              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
319                         llvm_v2f64_ty], [IntrNoMem]>;
320  def int_x86_sse2_ucomige_sd : GCCBuiltin<"__builtin_ia32_ucomisdge">,
321              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
322                         llvm_v2f64_ty], [IntrNoMem]>;
323  def int_x86_sse2_ucomineq_sd : GCCBuiltin<"__builtin_ia32_ucomisdneq">,
324              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
325                         llvm_v2f64_ty], [IntrNoMem]>;
326}
327
328// Integer arithmetic ops.
329let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
330  def int_x86_sse2_padds_b : GCCBuiltin<"__builtin_ia32_paddsb128">,
331              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
332                         llvm_v16i8_ty], [IntrNoMem, Commutative]>;
333  def int_x86_sse2_padds_w : GCCBuiltin<"__builtin_ia32_paddsw128">,
334              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
335                         llvm_v8i16_ty], [IntrNoMem, Commutative]>;
336  def int_x86_sse2_paddus_b : GCCBuiltin<"__builtin_ia32_paddusb128">,
337              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
338                         llvm_v16i8_ty], [IntrNoMem, Commutative]>;
339  def int_x86_sse2_paddus_w : GCCBuiltin<"__builtin_ia32_paddusw128">,
340              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
341                         llvm_v8i16_ty], [IntrNoMem, Commutative]>;
342  def int_x86_sse2_psubs_b : GCCBuiltin<"__builtin_ia32_psubsb128">,
343              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
344                         llvm_v16i8_ty], [IntrNoMem]>;
345  def int_x86_sse2_psubs_w : GCCBuiltin<"__builtin_ia32_psubsw128">,
346              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
347                         llvm_v8i16_ty], [IntrNoMem]>;
348  def int_x86_sse2_psubus_b : GCCBuiltin<"__builtin_ia32_psubusb128">,
349              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
350                         llvm_v16i8_ty], [IntrNoMem]>;
351  def int_x86_sse2_psubus_w : GCCBuiltin<"__builtin_ia32_psubusw128">,
352              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
353                         llvm_v8i16_ty], [IntrNoMem]>;
354  def int_x86_sse2_pmulhu_w : GCCBuiltin<"__builtin_ia32_pmulhuw128">,
355              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
356                         llvm_v8i16_ty], [IntrNoMem, Commutative]>;
357  def int_x86_sse2_pmulh_w : GCCBuiltin<"__builtin_ia32_pmulhw128">,
358              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
359                         llvm_v8i16_ty], [IntrNoMem, Commutative]>;
360  def int_x86_sse2_pmulu_dq : GCCBuiltin<"__builtin_ia32_pmuludq128">,
361              Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty,
362                         llvm_v4i32_ty], [IntrNoMem, Commutative]>;
363  def int_x86_sse2_pmadd_wd : GCCBuiltin<"__builtin_ia32_pmaddwd128">,
364              Intrinsic<[llvm_v4i32_ty], [llvm_v8i16_ty,
365                         llvm_v8i16_ty], [IntrNoMem, Commutative]>;
366  def int_x86_sse2_pavg_b : GCCBuiltin<"__builtin_ia32_pavgb128">,
367              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
368                         llvm_v16i8_ty], [IntrNoMem, Commutative]>;
369  def int_x86_sse2_pavg_w : GCCBuiltin<"__builtin_ia32_pavgw128">,
370              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
371                         llvm_v8i16_ty], [IntrNoMem, Commutative]>;
372  def int_x86_sse2_pmaxu_b : GCCBuiltin<"__builtin_ia32_pmaxub128">,
373              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
374                         llvm_v16i8_ty], [IntrNoMem, Commutative]>;
375  def int_x86_sse2_pmaxs_w : GCCBuiltin<"__builtin_ia32_pmaxsw128">,
376              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
377                         llvm_v8i16_ty], [IntrNoMem, Commutative]>;
378  def int_x86_sse2_pminu_b : GCCBuiltin<"__builtin_ia32_pminub128">,
379              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
380                         llvm_v16i8_ty], [IntrNoMem, Commutative]>;
381  def int_x86_sse2_pmins_w : GCCBuiltin<"__builtin_ia32_pminsw128">,
382              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
383                         llvm_v8i16_ty], [IntrNoMem, Commutative]>;
384  def int_x86_sse2_psad_bw : GCCBuiltin<"__builtin_ia32_psadbw128">,
385              Intrinsic<[llvm_v2i64_ty], [llvm_v16i8_ty,
386                         llvm_v16i8_ty], [IntrNoMem, Commutative]>;
387}
388
389// Integer shift ops.
390let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
391  def int_x86_sse2_psll_w : GCCBuiltin<"__builtin_ia32_psllw128">,
392              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
393                         llvm_v8i16_ty], [IntrNoMem]>;
394  def int_x86_sse2_psll_d : GCCBuiltin<"__builtin_ia32_pslld128">,
395              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
396                         llvm_v4i32_ty], [IntrNoMem]>;
397  def int_x86_sse2_psll_q : GCCBuiltin<"__builtin_ia32_psllq128">,
398              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
399                         llvm_v2i64_ty], [IntrNoMem]>;
400  def int_x86_sse2_psrl_w : GCCBuiltin<"__builtin_ia32_psrlw128">,
401              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
402                         llvm_v8i16_ty], [IntrNoMem]>;
403  def int_x86_sse2_psrl_d : GCCBuiltin<"__builtin_ia32_psrld128">,
404              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
405                         llvm_v4i32_ty], [IntrNoMem]>;
406  def int_x86_sse2_psrl_q : GCCBuiltin<"__builtin_ia32_psrlq128">,
407              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
408                         llvm_v2i64_ty], [IntrNoMem]>;
409  def int_x86_sse2_psra_w : GCCBuiltin<"__builtin_ia32_psraw128">,
410              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
411                         llvm_v8i16_ty], [IntrNoMem]>;
412  def int_x86_sse2_psra_d : GCCBuiltin<"__builtin_ia32_psrad128">,
413              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
414                         llvm_v4i32_ty], [IntrNoMem]>;
415
416  def int_x86_sse2_pslli_w : GCCBuiltin<"__builtin_ia32_psllwi128">,
417              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
418                         llvm_i32_ty], [IntrNoMem]>;
419  def int_x86_sse2_pslli_d : GCCBuiltin<"__builtin_ia32_pslldi128">,
420              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
421                         llvm_i32_ty], [IntrNoMem]>;
422  def int_x86_sse2_pslli_q : GCCBuiltin<"__builtin_ia32_psllqi128">,
423              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
424                         llvm_i32_ty], [IntrNoMem]>;
425  def int_x86_sse2_psrli_w : GCCBuiltin<"__builtin_ia32_psrlwi128">,
426              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
427                         llvm_i32_ty], [IntrNoMem]>;
428  def int_x86_sse2_psrli_d : GCCBuiltin<"__builtin_ia32_psrldi128">,
429              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
430                         llvm_i32_ty], [IntrNoMem]>;
431  def int_x86_sse2_psrli_q : GCCBuiltin<"__builtin_ia32_psrlqi128">,
432              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
433                         llvm_i32_ty], [IntrNoMem]>;
434  def int_x86_sse2_psrai_w : GCCBuiltin<"__builtin_ia32_psrawi128">,
435              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
436                         llvm_i32_ty], [IntrNoMem]>;
437  def int_x86_sse2_psrai_d : GCCBuiltin<"__builtin_ia32_psradi128">,
438              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
439                         llvm_i32_ty], [IntrNoMem]>;
440
441  def int_x86_sse2_psll_dq : GCCBuiltin<"__builtin_ia32_pslldqi128">,
442              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
443                         llvm_i32_ty], [IntrNoMem]>;
444  def int_x86_sse2_psrl_dq : GCCBuiltin<"__builtin_ia32_psrldqi128">,
445              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
446                         llvm_i32_ty], [IntrNoMem]>;
447  def int_x86_sse2_psll_dq_bs : GCCBuiltin<"__builtin_ia32_pslldqi128_byteshift">,
448              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
449                         llvm_i32_ty], [IntrNoMem]>;
450  def int_x86_sse2_psrl_dq_bs : GCCBuiltin<"__builtin_ia32_psrldqi128_byteshift">,
451              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty,
452                         llvm_i32_ty], [IntrNoMem]>;
453}
454
455// Conversion ops
456let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
457  def int_x86_sse2_cvtdq2pd : GCCBuiltin<"__builtin_ia32_cvtdq2pd">,
458              Intrinsic<[llvm_v2f64_ty], [llvm_v4i32_ty], [IntrNoMem]>;
459  def int_x86_sse2_cvtdq2ps : GCCBuiltin<"__builtin_ia32_cvtdq2ps">,
460              Intrinsic<[llvm_v4f32_ty], [llvm_v4i32_ty], [IntrNoMem]>;
461  def int_x86_sse2_cvtpd2dq : GCCBuiltin<"__builtin_ia32_cvtpd2dq">,
462              Intrinsic<[llvm_v4i32_ty], [llvm_v2f64_ty], [IntrNoMem]>;
463  def int_x86_sse2_cvttpd2dq : GCCBuiltin<"__builtin_ia32_cvttpd2dq">,
464              Intrinsic<[llvm_v4i32_ty], [llvm_v2f64_ty], [IntrNoMem]>;
465  def int_x86_sse2_cvtpd2ps : GCCBuiltin<"__builtin_ia32_cvtpd2ps">,
466              Intrinsic<[llvm_v4f32_ty], [llvm_v2f64_ty], [IntrNoMem]>;
467  def int_x86_sse2_cvtps2dq : GCCBuiltin<"__builtin_ia32_cvtps2dq">,
468              Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
469  def int_x86_sse2_cvttps2dq : GCCBuiltin<"__builtin_ia32_cvttps2dq">,
470              Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
471  def int_x86_sse2_cvtps2pd : GCCBuiltin<"__builtin_ia32_cvtps2pd">,
472              Intrinsic<[llvm_v2f64_ty], [llvm_v4f32_ty], [IntrNoMem]>;
473  def int_x86_sse2_cvtsd2si : GCCBuiltin<"__builtin_ia32_cvtsd2si">,
474              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty], [IntrNoMem]>;
475  def int_x86_sse2_cvtsd2si64 : GCCBuiltin<"__builtin_ia32_cvtsd2si64">,
476              Intrinsic<[llvm_i64_ty], [llvm_v2f64_ty], [IntrNoMem]>;
477  def int_x86_sse2_cvttsd2si : GCCBuiltin<"__builtin_ia32_cvttsd2si">,
478              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty], [IntrNoMem]>;
479  def int_x86_sse2_cvttsd2si64 : GCCBuiltin<"__builtin_ia32_cvttsd2si64">,
480              Intrinsic<[llvm_i64_ty], [llvm_v2f64_ty], [IntrNoMem]>;
481  def int_x86_sse2_cvtsi2sd : GCCBuiltin<"__builtin_ia32_cvtsi2sd">,
482              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
483                         llvm_i32_ty], [IntrNoMem]>;
484  def int_x86_sse2_cvtsi642sd : GCCBuiltin<"__builtin_ia32_cvtsi642sd">,
485              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
486                         llvm_i64_ty], [IntrNoMem]>;
487  def int_x86_sse2_cvtsd2ss : GCCBuiltin<"__builtin_ia32_cvtsd2ss">,
488              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
489                         llvm_v2f64_ty], [IntrNoMem]>;
490  def int_x86_sse2_cvtss2sd : GCCBuiltin<"__builtin_ia32_cvtss2sd">,
491              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
492                         llvm_v4f32_ty], [IntrNoMem]>;
493  def int_x86_sse_cvtpd2pi : GCCBuiltin<"__builtin_ia32_cvtpd2pi">,
494              Intrinsic<[llvm_x86mmx_ty], [llvm_v2f64_ty], [IntrNoMem]>;
495  def int_x86_sse_cvttpd2pi: GCCBuiltin<"__builtin_ia32_cvttpd2pi">,
496              Intrinsic<[llvm_x86mmx_ty], [llvm_v2f64_ty], [IntrNoMem]>;
497  def int_x86_sse_cvtpi2pd : GCCBuiltin<"__builtin_ia32_cvtpi2pd">,
498              Intrinsic<[llvm_v2f64_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
499}
500
501// SIMD store ops
502let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
503  def int_x86_sse2_storeu_pd : GCCBuiltin<"__builtin_ia32_storeupd">,
504              Intrinsic<[], [llvm_ptr_ty,
505                         llvm_v2f64_ty], [IntrReadWriteArgMem]>;
506  def int_x86_sse2_storeu_dq : GCCBuiltin<"__builtin_ia32_storedqu">,
507              Intrinsic<[], [llvm_ptr_ty,
508                         llvm_v16i8_ty], [IntrReadWriteArgMem]>;
509  def int_x86_sse2_storel_dq : GCCBuiltin<"__builtin_ia32_storelv4si">,
510              Intrinsic<[], [llvm_ptr_ty,
511                         llvm_v4i32_ty], [IntrReadWriteArgMem]>;
512}
513
514// Misc.
515let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
516  def int_x86_sse2_packsswb_128 : GCCBuiltin<"__builtin_ia32_packsswb128">,
517              Intrinsic<[llvm_v16i8_ty], [llvm_v8i16_ty,
518                         llvm_v8i16_ty], [IntrNoMem]>;
519  def int_x86_sse2_packssdw_128 : GCCBuiltin<"__builtin_ia32_packssdw128">,
520              Intrinsic<[llvm_v8i16_ty], [llvm_v4i32_ty,
521                         llvm_v4i32_ty], [IntrNoMem]>;
522  def int_x86_sse2_packuswb_128 : GCCBuiltin<"__builtin_ia32_packuswb128">,
523              Intrinsic<[llvm_v16i8_ty], [llvm_v8i16_ty,
524                         llvm_v8i16_ty], [IntrNoMem]>;
525  def int_x86_sse2_movmsk_pd : GCCBuiltin<"__builtin_ia32_movmskpd">,
526              Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty], [IntrNoMem]>;
527  def int_x86_sse2_pmovmskb_128 : GCCBuiltin<"__builtin_ia32_pmovmskb128">,
528              Intrinsic<[llvm_i32_ty], [llvm_v16i8_ty], [IntrNoMem]>;
529  def int_x86_sse2_maskmov_dqu : GCCBuiltin<"__builtin_ia32_maskmovdqu">,
530              Intrinsic<[], [llvm_v16i8_ty,
531                         llvm_v16i8_ty, llvm_ptr_ty], []>;
532  def int_x86_sse2_clflush : GCCBuiltin<"__builtin_ia32_clflush">,
533              Intrinsic<[], [llvm_ptr_ty], []>;
534  def int_x86_sse2_lfence : GCCBuiltin<"__builtin_ia32_lfence">,
535              Intrinsic<[], [], []>;
536  def int_x86_sse2_mfence : GCCBuiltin<"__builtin_ia32_mfence">,
537              Intrinsic<[], [], []>;
538}
539
540//===----------------------------------------------------------------------===//
541// SSE3
542
543// Addition / subtraction ops.
544let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
545  def int_x86_sse3_addsub_ps : GCCBuiltin<"__builtin_ia32_addsubps">,
546              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
547                         llvm_v4f32_ty], [IntrNoMem]>;
548  def int_x86_sse3_addsub_pd : GCCBuiltin<"__builtin_ia32_addsubpd">,
549              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
550                         llvm_v2f64_ty], [IntrNoMem]>;
551}
552
553// Horizontal ops.
554let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
555  def int_x86_sse3_hadd_ps : GCCBuiltin<"__builtin_ia32_haddps">,
556              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
557                         llvm_v4f32_ty], [IntrNoMem]>;
558  def int_x86_sse3_hadd_pd : GCCBuiltin<"__builtin_ia32_haddpd">,
559              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
560                         llvm_v2f64_ty], [IntrNoMem]>;
561  def int_x86_sse3_hsub_ps : GCCBuiltin<"__builtin_ia32_hsubps">,
562              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
563                         llvm_v4f32_ty], [IntrNoMem]>;
564  def int_x86_sse3_hsub_pd : GCCBuiltin<"__builtin_ia32_hsubpd">,
565              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
566                         llvm_v2f64_ty], [IntrNoMem]>;
567}
568
569// Specialized unaligned load.
570let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
571  def int_x86_sse3_ldu_dq : GCCBuiltin<"__builtin_ia32_lddqu">,
572              Intrinsic<[llvm_v16i8_ty], [llvm_ptr_ty], [IntrReadMem]>;
573}
574
575// Thread synchronization ops.
576let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
577  def int_x86_sse3_monitor : GCCBuiltin<"__builtin_ia32_monitor">,
578              Intrinsic<[], [llvm_ptr_ty,
579                         llvm_i32_ty, llvm_i32_ty], []>;
580  def int_x86_sse3_mwait : GCCBuiltin<"__builtin_ia32_mwait">,
581              Intrinsic<[], [llvm_i32_ty,
582                         llvm_i32_ty], []>;
583}
584
585//===----------------------------------------------------------------------===//
586// SSSE3
587
588// Horizontal arithmetic ops
589let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
590  def int_x86_ssse3_phadd_w         : GCCBuiltin<"__builtin_ia32_phaddw">,
591              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
592                         llvm_x86mmx_ty], [IntrNoMem]>;
593  def int_x86_ssse3_phadd_w_128     : GCCBuiltin<"__builtin_ia32_phaddw128">,
594              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
595                         llvm_v8i16_ty], [IntrNoMem]>;
596
597  def int_x86_ssse3_phadd_d         : GCCBuiltin<"__builtin_ia32_phaddd">,
598              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
599                         llvm_x86mmx_ty], [IntrNoMem]>;
600  def int_x86_ssse3_phadd_d_128     : GCCBuiltin<"__builtin_ia32_phaddd128">,
601              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
602                         llvm_v4i32_ty], [IntrNoMem]>;
603
604  def int_x86_ssse3_phadd_sw        : GCCBuiltin<"__builtin_ia32_phaddsw">,
605              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
606                         llvm_x86mmx_ty], [IntrNoMem]>;
607  def int_x86_ssse3_phadd_sw_128    : GCCBuiltin<"__builtin_ia32_phaddsw128">,
608              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
609                         llvm_v8i16_ty], [IntrNoMem]>;
610
611  def int_x86_ssse3_phsub_w         : GCCBuiltin<"__builtin_ia32_phsubw">,
612              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
613                         llvm_x86mmx_ty], [IntrNoMem]>;
614  def int_x86_ssse3_phsub_w_128     : GCCBuiltin<"__builtin_ia32_phsubw128">,
615              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
616                         llvm_v8i16_ty], [IntrNoMem]>;
617
618  def int_x86_ssse3_phsub_d         : GCCBuiltin<"__builtin_ia32_phsubd">,
619              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
620                         llvm_x86mmx_ty], [IntrNoMem]>;
621  def int_x86_ssse3_phsub_d_128     : GCCBuiltin<"__builtin_ia32_phsubd128">,
622              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
623                         llvm_v4i32_ty], [IntrNoMem]>;
624
625  def int_x86_ssse3_phsub_sw        : GCCBuiltin<"__builtin_ia32_phsubsw">,
626              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
627                         llvm_x86mmx_ty], [IntrNoMem]>;
628  def int_x86_ssse3_phsub_sw_128    : GCCBuiltin<"__builtin_ia32_phsubsw128">,
629              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
630                         llvm_v8i16_ty], [IntrNoMem]>;
631
632  def int_x86_ssse3_pmadd_ub_sw     : GCCBuiltin<"__builtin_ia32_pmaddubsw">,
633              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
634                         llvm_x86mmx_ty], [IntrNoMem]>;
635  def int_x86_ssse3_pmadd_ub_sw_128 : GCCBuiltin<"__builtin_ia32_pmaddubsw128">,
636              Intrinsic<[llvm_v8i16_ty], [llvm_v16i8_ty,
637                         llvm_v16i8_ty], [IntrNoMem]>;
638}
639
640// Packed multiply high with round and scale
641let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
642  def int_x86_ssse3_pmul_hr_sw      : GCCBuiltin<"__builtin_ia32_pmulhrsw">,
643              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
644                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
645  def int_x86_ssse3_pmul_hr_sw_128  : GCCBuiltin<"__builtin_ia32_pmulhrsw128">,
646              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
647                         llvm_v8i16_ty], [IntrNoMem, Commutative]>;
648}
649
650// Shuffle ops
651let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
652  def int_x86_ssse3_pshuf_b         : GCCBuiltin<"__builtin_ia32_pshufb">,
653              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
654                         llvm_x86mmx_ty], [IntrNoMem]>;
655  def int_x86_ssse3_pshuf_b_128     : GCCBuiltin<"__builtin_ia32_pshufb128">,
656              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
657                         llvm_v16i8_ty], [IntrNoMem]>;
658  def int_x86_sse_pshuf_w           : GCCBuiltin<"__builtin_ia32_pshufw">,
659              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_i8_ty],
660                         [IntrNoMem]>;
661}
662
663// Sign ops
664let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
665  def int_x86_ssse3_psign_b         : GCCBuiltin<"__builtin_ia32_psignb">,
666              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
667                         llvm_x86mmx_ty], [IntrNoMem]>;
668  def int_x86_ssse3_psign_b_128     : GCCBuiltin<"__builtin_ia32_psignb128">,
669              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty,
670                         llvm_v16i8_ty], [IntrNoMem]>;
671
672  def int_x86_ssse3_psign_w         : GCCBuiltin<"__builtin_ia32_psignw">,
673              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
674                         llvm_x86mmx_ty], [IntrNoMem]>;
675  def int_x86_ssse3_psign_w_128     : GCCBuiltin<"__builtin_ia32_psignw128">,
676              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty,
677                         llvm_v8i16_ty], [IntrNoMem]>;
678
679  def int_x86_ssse3_psign_d         : GCCBuiltin<"__builtin_ia32_psignd">,
680              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
681                         llvm_x86mmx_ty], [IntrNoMem]>;
682  def int_x86_ssse3_psign_d_128     : GCCBuiltin<"__builtin_ia32_psignd128">,
683              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty,
684                         llvm_v4i32_ty], [IntrNoMem]>;
685}
686
687// Absolute value ops
688let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
689  def int_x86_ssse3_pabs_b     : GCCBuiltin<"__builtin_ia32_pabsb">,
690              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
691  def int_x86_ssse3_pabs_b_128 : GCCBuiltin<"__builtin_ia32_pabsb128">,
692              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty], [IntrNoMem]>;
693
694  def int_x86_ssse3_pabs_w     : GCCBuiltin<"__builtin_ia32_pabsw">,
695              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
696  def int_x86_ssse3_pabs_w_128 : GCCBuiltin<"__builtin_ia32_pabsw128">,
697              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty], [IntrNoMem]>;
698
699  def int_x86_ssse3_pabs_d     : GCCBuiltin<"__builtin_ia32_pabsd">,
700              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
701  def int_x86_ssse3_pabs_d_128 : GCCBuiltin<"__builtin_ia32_pabsd128">,
702              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty], [IntrNoMem]>;
703}
704
705//===----------------------------------------------------------------------===//
706// SSE4.1
707
708// FP rounding ops
709let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
710  def int_x86_sse41_round_ss        : GCCBuiltin<"__builtin_ia32_roundss">,
711              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty,
712                         llvm_i32_ty], [IntrNoMem]>;
713  def int_x86_sse41_round_ps        : GCCBuiltin<"__builtin_ia32_roundps">,
714              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
715                         llvm_i32_ty], [IntrNoMem]>;
716  def int_x86_sse41_round_sd        : GCCBuiltin<"__builtin_ia32_roundsd">,
717              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty,
718                         llvm_i32_ty], [IntrNoMem]>;
719  def int_x86_sse41_round_pd        : GCCBuiltin<"__builtin_ia32_roundpd">,
720              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
721                         llvm_i32_ty], [IntrNoMem]>;
722}
723
724// Vector sign and zero extend
725let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
726  def int_x86_sse41_pmovsxbd        : GCCBuiltin<"__builtin_ia32_pmovsxbd128">,
727              Intrinsic<[llvm_v4i32_ty], [llvm_v16i8_ty],
728                        [IntrNoMem]>;
729  def int_x86_sse41_pmovsxbq        : GCCBuiltin<"__builtin_ia32_pmovsxbq128">,
730              Intrinsic<[llvm_v2i64_ty], [llvm_v16i8_ty],
731                        [IntrNoMem]>;
732  def int_x86_sse41_pmovsxbw        : GCCBuiltin<"__builtin_ia32_pmovsxbw128">,
733              Intrinsic<[llvm_v8i16_ty], [llvm_v16i8_ty],
734                        [IntrNoMem]>;
735  def int_x86_sse41_pmovsxdq        : GCCBuiltin<"__builtin_ia32_pmovsxdq128">,
736              Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty],
737                        [IntrNoMem]>;
738  def int_x86_sse41_pmovsxwd        : GCCBuiltin<"__builtin_ia32_pmovsxwd128">,
739              Intrinsic<[llvm_v4i32_ty], [llvm_v8i16_ty],
740                        [IntrNoMem]>;
741  def int_x86_sse41_pmovsxwq        : GCCBuiltin<"__builtin_ia32_pmovsxwq128">,
742              Intrinsic<[llvm_v2i64_ty], [llvm_v8i16_ty],
743                        [IntrNoMem]>;
744  def int_x86_sse41_pmovzxbd        : GCCBuiltin<"__builtin_ia32_pmovzxbd128">,
745              Intrinsic<[llvm_v4i32_ty], [llvm_v16i8_ty],
746                        [IntrNoMem]>;
747  def int_x86_sse41_pmovzxbq        : GCCBuiltin<"__builtin_ia32_pmovzxbq128">,
748              Intrinsic<[llvm_v2i64_ty], [llvm_v16i8_ty],
749                        [IntrNoMem]>;
750  def int_x86_sse41_pmovzxbw        : GCCBuiltin<"__builtin_ia32_pmovzxbw128">,
751              Intrinsic<[llvm_v8i16_ty], [llvm_v16i8_ty],
752                        [IntrNoMem]>;
753  def int_x86_sse41_pmovzxdq        : GCCBuiltin<"__builtin_ia32_pmovzxdq128">,
754              Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty],
755                        [IntrNoMem]>;
756  def int_x86_sse41_pmovzxwd        : GCCBuiltin<"__builtin_ia32_pmovzxwd128">,
757              Intrinsic<[llvm_v4i32_ty], [llvm_v8i16_ty],
758                        [IntrNoMem]>;
759  def int_x86_sse41_pmovzxwq        : GCCBuiltin<"__builtin_ia32_pmovzxwq128">,
760              Intrinsic<[llvm_v2i64_ty], [llvm_v8i16_ty],
761                        [IntrNoMem]>;
762}
763
764// Vector min element
765let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
766  def int_x86_sse41_phminposuw     : GCCBuiltin<"__builtin_ia32_phminposuw128">,
767              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty],
768                        [IntrNoMem]>;
769}
770
771// Vector compare, min, max
772let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
773  def int_x86_sse41_pmaxsb          : GCCBuiltin<"__builtin_ia32_pmaxsb128">,
774              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty],
775                        [IntrNoMem, Commutative]>;
776  def int_x86_sse41_pmaxsd          : GCCBuiltin<"__builtin_ia32_pmaxsd128">,
777              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
778                        [IntrNoMem, Commutative]>;
779  def int_x86_sse41_pmaxud          : GCCBuiltin<"__builtin_ia32_pmaxud128">,
780              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
781                        [IntrNoMem, Commutative]>;
782  def int_x86_sse41_pmaxuw          : GCCBuiltin<"__builtin_ia32_pmaxuw128">,
783              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty],
784                        [IntrNoMem, Commutative]>;
785  def int_x86_sse41_pminsb          : GCCBuiltin<"__builtin_ia32_pminsb128">,
786              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty],
787                        [IntrNoMem, Commutative]>;
788  def int_x86_sse41_pminsd          : GCCBuiltin<"__builtin_ia32_pminsd128">,
789              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
790                        [IntrNoMem, Commutative]>;
791  def int_x86_sse41_pminud          : GCCBuiltin<"__builtin_ia32_pminud128">,
792              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
793                        [IntrNoMem, Commutative]>;
794  def int_x86_sse41_pminuw          : GCCBuiltin<"__builtin_ia32_pminuw128">,
795              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty],
796                        [IntrNoMem, Commutative]>;
797}
798
799// Advanced Encryption Standard (AES) Instructions
800let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
801  def int_x86_aesni_aesimc          : GCCBuiltin<"__builtin_ia32_aesimc128">,
802              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty],
803                        [IntrNoMem]>;
804  def int_x86_aesni_aesenc          : GCCBuiltin<"__builtin_ia32_aesenc128">,
805              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
806                        [IntrNoMem]>;
807  def int_x86_aesni_aesenclast : GCCBuiltin<"__builtin_ia32_aesenclast128">,
808              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
809                        [IntrNoMem]>;
810  def int_x86_aesni_aesdec          : GCCBuiltin<"__builtin_ia32_aesdec128">,
811              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
812                        [IntrNoMem]>;
813  def int_x86_aesni_aesdeclast : GCCBuiltin<"__builtin_ia32_aesdeclast128">,
814              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
815                        [IntrNoMem]>;
816  def int_x86_aesni_aeskeygenassist :
817              GCCBuiltin<"__builtin_ia32_aeskeygenassist128">,
818              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i8_ty],
819                        [IntrNoMem]>;
820}
821
822// PCLMUL instruction
823let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.".
824  def int_x86_pclmulqdq : GCCBuiltin<"__builtin_ia32_pclmulqdq128">,
825          Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty, llvm_i8_ty],
826                    [IntrNoMem]>;
827}
828
829// Vector pack
830let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
831  def int_x86_sse41_packusdw        : GCCBuiltin<"__builtin_ia32_packusdw128">,
832              Intrinsic<[llvm_v8i16_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
833                        [IntrNoMem]>;
834}
835
836// Vector multiply
837let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
838  def int_x86_sse41_pmuldq          : GCCBuiltin<"__builtin_ia32_pmuldq128">,
839              Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
840                        [IntrNoMem, Commutative]>;
841}
842
843// Vector extract
844let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
845  def int_x86_sse41_pextrb         :
846              Intrinsic<[llvm_i32_ty], [llvm_v16i8_ty, llvm_i32_ty],
847                        [IntrNoMem]>;
848  def int_x86_sse41_pextrd         :
849              Intrinsic<[llvm_i32_ty], [llvm_v4i32_ty, llvm_i32_ty],
850                        [IntrNoMem]>;
851  def int_x86_sse41_pextrq         :
852              Intrinsic<[llvm_i64_ty], [llvm_v2i64_ty, llvm_i32_ty],
853                        [IntrNoMem]>;
854  def int_x86_sse41_extractps      : GCCBuiltin<"__builtin_ia32_extractps128">,
855              Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty, llvm_i32_ty],
856                        [IntrNoMem]>;
857}
858
859// Vector insert
860let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
861  def int_x86_sse41_insertps       : GCCBuiltin<"__builtin_ia32_insertps128">,
862          Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty,llvm_i32_ty],
863                    [IntrNoMem]>;
864}
865
866// Vector blend
867let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
868  def int_x86_sse41_pblendvb         : GCCBuiltin<"__builtin_ia32_pblendvb128">,
869        Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty,llvm_v16i8_ty],
870                  [IntrNoMem]>;
871  def int_x86_sse41_pblendw          : GCCBuiltin<"__builtin_ia32_pblendw128">,
872        Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_i32_ty],
873                  [IntrNoMem]>;
874  def int_x86_sse41_blendpd          : GCCBuiltin<"__builtin_ia32_blendpd">,
875        Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty, llvm_i32_ty],
876                  [IntrNoMem]>;
877  def int_x86_sse41_blendps          : GCCBuiltin<"__builtin_ia32_blendps">,
878        Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty, llvm_i32_ty],
879                  [IntrNoMem]>;
880  def int_x86_sse41_blendvpd         : GCCBuiltin<"__builtin_ia32_blendvpd">,
881        Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty,llvm_v2f64_ty],
882                  [IntrNoMem]>;
883  def int_x86_sse41_blendvps         : GCCBuiltin<"__builtin_ia32_blendvps">,
884        Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty,llvm_v4f32_ty],
885                  [IntrNoMem]>;
886}
887
888// Vector dot product
889let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
890  def int_x86_sse41_dppd            : GCCBuiltin<"__builtin_ia32_dppd">,
891          Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty,llvm_i32_ty],
892                    [IntrNoMem, Commutative]>;
893  def int_x86_sse41_dpps            : GCCBuiltin<"__builtin_ia32_dpps">,
894          Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty,llvm_i32_ty],
895                    [IntrNoMem, Commutative]>;
896}
897
898// Vector sum of absolute differences
899let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
900  def int_x86_sse41_mpsadbw         : GCCBuiltin<"__builtin_ia32_mpsadbw128">,
901          Intrinsic<[llvm_v8i16_ty], [llvm_v16i8_ty, llvm_v16i8_ty,llvm_i32_ty],
902                    [IntrNoMem, Commutative]>;
903}
904
905// Cacheability support ops
906let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
907  def int_x86_sse41_movntdqa        : GCCBuiltin<"__builtin_ia32_movntdqa">,
908          Intrinsic<[llvm_v2i64_ty], [llvm_ptr_ty], [IntrReadMem]>;
909}
910
911// Test instruction with bitwise comparison.
912let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.".
913  def int_x86_sse41_ptestz          : GCCBuiltin<"__builtin_ia32_ptestz128">,
914          Intrinsic<[llvm_i32_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
915                    [IntrNoMem]>;
916  def int_x86_sse41_ptestc          : GCCBuiltin<"__builtin_ia32_ptestc128">,
917          Intrinsic<[llvm_i32_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
918                    [IntrNoMem]>;
919  def int_x86_sse41_ptestnzc        : GCCBuiltin<"__builtin_ia32_ptestnzc128">,
920          Intrinsic<[llvm_i32_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
921                    [IntrNoMem]>;
922}
923
924//===----------------------------------------------------------------------===//
925// SSE4.2
926
927// Miscellaneous
928// CRC Instruction
929let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.".
930  def int_x86_sse42_crc32_32_8       : GCCBuiltin<"__builtin_ia32_crc32qi">,
931          Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i8_ty],
932                    [IntrNoMem]>;
933  def int_x86_sse42_crc32_32_16      : GCCBuiltin<"__builtin_ia32_crc32hi">,
934          Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i16_ty],
935                    [IntrNoMem]>;
936  def int_x86_sse42_crc32_32_32      : GCCBuiltin<"__builtin_ia32_crc32si">,
937          Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty],
938                    [IntrNoMem]>;
939  def int_x86_sse42_crc32_64_8       :
940          Intrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i8_ty],
941                    [IntrNoMem]>;
942  def int_x86_sse42_crc32_64_64      : GCCBuiltin<"__builtin_ia32_crc32di">,
943          Intrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty],
944                    [IntrNoMem]>;
945}
946
947// String/text processing ops.
948let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.".
949  def int_x86_sse42_pcmpistrm128  : GCCBuiltin<"__builtin_ia32_pcmpistrm128">,
950    Intrinsic<[llvm_v16i8_ty],
951        [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
952        [IntrNoMem]>;
953  def int_x86_sse42_pcmpistri128  : GCCBuiltin<"__builtin_ia32_pcmpistri128">,
954    Intrinsic<[llvm_i32_ty],
955        [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
956        [IntrNoMem]>;
957  def int_x86_sse42_pcmpistria128 : GCCBuiltin<"__builtin_ia32_pcmpistria128">,
958    Intrinsic<[llvm_i32_ty],
959        [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
960        [IntrNoMem]>;
961  def int_x86_sse42_pcmpistric128 : GCCBuiltin<"__builtin_ia32_pcmpistric128">,
962    Intrinsic<[llvm_i32_ty],
963        [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
964        [IntrNoMem]>;
965  def int_x86_sse42_pcmpistrio128 : GCCBuiltin<"__builtin_ia32_pcmpistrio128">,
966    Intrinsic<[llvm_i32_ty],
967        [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
968        [IntrNoMem]>;
969  def int_x86_sse42_pcmpistris128 : GCCBuiltin<"__builtin_ia32_pcmpistris128">,
970    Intrinsic<[llvm_i32_ty],
971        [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
972        [IntrNoMem]>;
973  def int_x86_sse42_pcmpistriz128 : GCCBuiltin<"__builtin_ia32_pcmpistriz128">,
974    Intrinsic<[llvm_i32_ty],
975        [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i8_ty],
976        [IntrNoMem]>;
977  def int_x86_sse42_pcmpestrm128  : GCCBuiltin<"__builtin_ia32_pcmpestrm128">,
978    Intrinsic<[llvm_v16i8_ty],
979        [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
980         llvm_i8_ty],
981        [IntrNoMem]>;
982  def int_x86_sse42_pcmpestri128  : GCCBuiltin<"__builtin_ia32_pcmpestri128">,
983    Intrinsic<[llvm_i32_ty],
984        [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
985         llvm_i8_ty],
986        [IntrNoMem]>;
987  def int_x86_sse42_pcmpestria128 : GCCBuiltin<"__builtin_ia32_pcmpestria128">,
988    Intrinsic<[llvm_i32_ty],
989        [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
990         llvm_i8_ty],
991        [IntrNoMem]>;
992  def int_x86_sse42_pcmpestric128 : GCCBuiltin<"__builtin_ia32_pcmpestric128">,
993    Intrinsic<[llvm_i32_ty],
994        [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
995         llvm_i8_ty],
996        [IntrNoMem]>;
997  def int_x86_sse42_pcmpestrio128 : GCCBuiltin<"__builtin_ia32_pcmpestrio128">,
998    Intrinsic<[llvm_i32_ty],
999        [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
1000         llvm_i8_ty],
1001        [IntrNoMem]>;
1002  def int_x86_sse42_pcmpestris128 : GCCBuiltin<"__builtin_ia32_pcmpestris128">,
1003    Intrinsic<[llvm_i32_ty],
1004        [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
1005         llvm_i8_ty],
1006        [IntrNoMem]>;
1007  def int_x86_sse42_pcmpestriz128 : GCCBuiltin<"__builtin_ia32_pcmpestriz128">,
1008    Intrinsic<[llvm_i32_ty],
1009        [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty, llvm_i32_ty,
1010         llvm_i8_ty],
1011        [IntrNoMem]>;
1012}
1013
1014//===----------------------------------------------------------------------===//
1015// SSE4A
1016
1017let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1018  def int_x86_sse4a_extrqi : GCCBuiltin<"__builtin_ia32_extrqi">,
1019    Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i8_ty, llvm_i8_ty],
1020              [IntrNoMem]>;
1021  def int_x86_sse4a_extrq  : GCCBuiltin<"__builtin_ia32_extrq">,
1022    Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v16i8_ty], [IntrNoMem]>;
1023
1024  def int_x86_sse4a_insertqi : GCCBuiltin<"__builtin_ia32_insertqi">,
1025    Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty,
1026                                llvm_i8_ty, llvm_i8_ty], [IntrNoMem]>;
1027  def int_x86_sse4a_insertq  : GCCBuiltin<"__builtin_ia32_insertq">,
1028    Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>;
1029
1030  def int_x86_sse4a_movnt_ss : GCCBuiltin<"__builtin_ia32_movntss">,
1031    Intrinsic<[], [llvm_ptr_ty, llvm_v4f32_ty], []>;
1032  def int_x86_sse4a_movnt_sd : GCCBuiltin<"__builtin_ia32_movntsd">,
1033    Intrinsic<[], [llvm_ptr_ty, llvm_v2f64_ty], []>;
1034}
1035
1036//===----------------------------------------------------------------------===//
1037// AVX
1038
1039// Arithmetic ops
1040let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1041  def int_x86_avx_addsub_pd_256 : GCCBuiltin<"__builtin_ia32_addsubpd256">,
1042        Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1043                  llvm_v4f64_ty], [IntrNoMem]>;
1044  def int_x86_avx_addsub_ps_256 : GCCBuiltin<"__builtin_ia32_addsubps256">,
1045        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1046                  llvm_v8f32_ty], [IntrNoMem]>;
1047  def int_x86_avx_max_pd_256 : GCCBuiltin<"__builtin_ia32_maxpd256">,
1048        Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1049                  llvm_v4f64_ty], [IntrNoMem]>;
1050  def int_x86_avx_max_ps_256 : GCCBuiltin<"__builtin_ia32_maxps256">,
1051        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1052                  llvm_v8f32_ty], [IntrNoMem]>;
1053  def int_x86_avx_min_pd_256 : GCCBuiltin<"__builtin_ia32_minpd256">,
1054        Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1055                  llvm_v4f64_ty], [IntrNoMem]>;
1056  def int_x86_avx_min_ps_256 : GCCBuiltin<"__builtin_ia32_minps256">,
1057        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1058                  llvm_v8f32_ty], [IntrNoMem]>;
1059
1060  def int_x86_avx_sqrt_pd_256 : GCCBuiltin<"__builtin_ia32_sqrtpd256">,
1061        Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty], [IntrNoMem]>;
1062  def int_x86_avx_sqrt_ps_256 : GCCBuiltin<"__builtin_ia32_sqrtps256">,
1063        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
1064
1065  def int_x86_avx_rsqrt_ps_256 : GCCBuiltin<"__builtin_ia32_rsqrtps256">,
1066        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
1067
1068  def int_x86_avx_rcp_ps_256 : GCCBuiltin<"__builtin_ia32_rcpps256">,
1069        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
1070
1071  def int_x86_avx_round_pd_256 : GCCBuiltin<"__builtin_ia32_roundpd256">,
1072        Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1073                  llvm_i32_ty], [IntrNoMem]>;
1074  def int_x86_avx_round_ps_256 : GCCBuiltin<"__builtin_ia32_roundps256">,
1075        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1076                  llvm_i32_ty], [IntrNoMem]>;
1077}
1078
1079// Horizontal ops
1080let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1081  def int_x86_avx_hadd_pd_256 : GCCBuiltin<"__builtin_ia32_haddpd256">,
1082        Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1083                  llvm_v4f64_ty], [IntrNoMem]>;
1084  def int_x86_avx_hsub_ps_256 : GCCBuiltin<"__builtin_ia32_hsubps256">,
1085        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1086                  llvm_v8f32_ty], [IntrNoMem]>;
1087  def int_x86_avx_hsub_pd_256 : GCCBuiltin<"__builtin_ia32_hsubpd256">,
1088        Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1089                  llvm_v4f64_ty], [IntrNoMem]>;
1090  def int_x86_avx_hadd_ps_256 : GCCBuiltin<"__builtin_ia32_haddps256">,
1091        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1092                  llvm_v8f32_ty], [IntrNoMem]>;
1093}
1094
1095// Vector permutation
1096let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1097  def int_x86_avx_vpermilvar_pd : GCCBuiltin<"__builtin_ia32_vpermilvarpd">,
1098        Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty,
1099                  llvm_v2i64_ty], [IntrNoMem]>;
1100  def int_x86_avx_vpermilvar_ps : GCCBuiltin<"__builtin_ia32_vpermilvarps">,
1101        Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty,
1102                  llvm_v4i32_ty], [IntrNoMem]>;
1103
1104  def int_x86_avx_vpermilvar_pd_256 :
1105        GCCBuiltin<"__builtin_ia32_vpermilvarpd256">,
1106        Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, llvm_v4i64_ty], [IntrNoMem]>;
1107  def int_x86_avx_vpermilvar_ps_256 :
1108        GCCBuiltin<"__builtin_ia32_vpermilvarps256">,
1109        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, llvm_v8i32_ty], [IntrNoMem]>;
1110
1111  def int_x86_avx_vperm2f128_pd_256 :
1112        GCCBuiltin<"__builtin_ia32_vperm2f128_pd256">,
1113        Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1114                  llvm_v4f64_ty, llvm_i8_ty], [IntrNoMem]>;
1115  def int_x86_avx_vperm2f128_ps_256 :
1116        GCCBuiltin<"__builtin_ia32_vperm2f128_ps256">,
1117        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1118                  llvm_v8f32_ty, llvm_i8_ty], [IntrNoMem]>;
1119  def int_x86_avx_vperm2f128_si_256 :
1120        GCCBuiltin<"__builtin_ia32_vperm2f128_si256">,
1121        Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1122                  llvm_v8i32_ty, llvm_i8_ty], [IntrNoMem]>;
1123}
1124
1125// Vector blend
1126let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1127  def int_x86_avx_blend_pd_256 : GCCBuiltin<"__builtin_ia32_blendpd256">,
1128        Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1129                  llvm_v4f64_ty, llvm_i32_ty], [IntrNoMem]>;
1130  def int_x86_avx_blend_ps_256 : GCCBuiltin<"__builtin_ia32_blendps256">,
1131        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1132                  llvm_v8f32_ty, llvm_i32_ty], [IntrNoMem]>;
1133  def int_x86_avx_blendv_pd_256 : GCCBuiltin<"__builtin_ia32_blendvpd256">,
1134        Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1135                  llvm_v4f64_ty, llvm_v4f64_ty], [IntrNoMem]>;
1136  def int_x86_avx_blendv_ps_256 : GCCBuiltin<"__builtin_ia32_blendvps256">,
1137        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1138                  llvm_v8f32_ty, llvm_v8f32_ty], [IntrNoMem]>;
1139}
1140
1141// Vector dot product
1142let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1143  def int_x86_avx_dp_ps_256 : GCCBuiltin<"__builtin_ia32_dpps256">,
1144        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1145                  llvm_v8f32_ty, llvm_i32_ty], [IntrNoMem]>;
1146}
1147
1148// Vector compare
1149let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1150  def int_x86_avx_cmp_pd_256 : GCCBuiltin<"__builtin_ia32_cmppd256">,
1151        Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1152                  llvm_v4f64_ty, llvm_i8_ty], [IntrNoMem]>;
1153  def int_x86_avx_cmp_ps_256 : GCCBuiltin<"__builtin_ia32_cmpps256">,
1154        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1155                  llvm_v8f32_ty, llvm_i8_ty], [IntrNoMem]>;
1156}
1157
1158// Vector extract and insert
1159let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1160  def int_x86_avx_vextractf128_pd_256 :
1161        GCCBuiltin<"__builtin_ia32_vextractf128_pd256">,
1162        Intrinsic<[llvm_v2f64_ty], [llvm_v4f64_ty, llvm_i8_ty], [IntrNoMem]>;
1163  def int_x86_avx_vextractf128_ps_256 :
1164        GCCBuiltin<"__builtin_ia32_vextractf128_ps256">,
1165        Intrinsic<[llvm_v4f32_ty], [llvm_v8f32_ty, llvm_i8_ty], [IntrNoMem]>;
1166  def int_x86_avx_vextractf128_si_256 :
1167        GCCBuiltin<"__builtin_ia32_vextractf128_si256">,
1168        Intrinsic<[llvm_v4i32_ty], [llvm_v8i32_ty, llvm_i8_ty], [IntrNoMem]>;
1169
1170  def int_x86_avx_vinsertf128_pd_256 :
1171        GCCBuiltin<"__builtin_ia32_vinsertf128_pd256">,
1172        Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty,
1173                  llvm_v2f64_ty, llvm_i8_ty], [IntrNoMem]>;
1174  def int_x86_avx_vinsertf128_ps_256 :
1175        GCCBuiltin<"__builtin_ia32_vinsertf128_ps256">,
1176        Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty,
1177                  llvm_v4f32_ty, llvm_i8_ty], [IntrNoMem]>;
1178  def int_x86_avx_vinsertf128_si_256 :
1179        GCCBuiltin<"__builtin_ia32_vinsertf128_si256">,
1180        Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1181                  llvm_v4i32_ty, llvm_i8_ty], [IntrNoMem]>;
1182}
1183
1184// Vector convert
1185let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1186  def int_x86_avx_cvtdq2_pd_256 : GCCBuiltin<"__builtin_ia32_cvtdq2pd256">,
1187        Intrinsic<[llvm_v4f64_ty], [llvm_v4i32_ty], [IntrNoMem]>;
1188  def int_x86_avx_cvtdq2_ps_256 : GCCBuiltin<"__builtin_ia32_cvtdq2ps256">,
1189        Intrinsic<[llvm_v8f32_ty], [llvm_v8i32_ty], [IntrNoMem]>;
1190  def int_x86_avx_cvt_pd2_ps_256 : GCCBuiltin<"__builtin_ia32_cvtpd2ps256">,
1191        Intrinsic<[llvm_v4f32_ty], [llvm_v4f64_ty], [IntrNoMem]>;
1192  def int_x86_avx_cvt_ps2dq_256 : GCCBuiltin<"__builtin_ia32_cvtps2dq256">,
1193        Intrinsic<[llvm_v8i32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
1194  def int_x86_avx_cvt_ps2_pd_256 : GCCBuiltin<"__builtin_ia32_cvtps2pd256">,
1195        Intrinsic<[llvm_v4f64_ty], [llvm_v4f32_ty], [IntrNoMem]>;
1196  def int_x86_avx_cvtt_pd2dq_256 : GCCBuiltin<"__builtin_ia32_cvttpd2dq256">,
1197        Intrinsic<[llvm_v4i32_ty], [llvm_v4f64_ty], [IntrNoMem]>;
1198  def int_x86_avx_cvt_pd2dq_256 : GCCBuiltin<"__builtin_ia32_cvtpd2dq256">,
1199        Intrinsic<[llvm_v4i32_ty], [llvm_v4f64_ty], [IntrNoMem]>;
1200  def int_x86_avx_cvtt_ps2dq_256 : GCCBuiltin<"__builtin_ia32_cvttps2dq256">,
1201        Intrinsic<[llvm_v8i32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
1202}
1203
1204// Vector bit test
1205let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1206  def int_x86_avx_vtestz_pd : GCCBuiltin<"__builtin_ia32_vtestzpd">,
1207        Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
1208                  llvm_v2f64_ty], [IntrNoMem]>;
1209  def int_x86_avx_vtestc_pd : GCCBuiltin<"__builtin_ia32_vtestcpd">,
1210        Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
1211                  llvm_v2f64_ty], [IntrNoMem]>;
1212  def int_x86_avx_vtestnzc_pd : GCCBuiltin<"__builtin_ia32_vtestnzcpd">,
1213        Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty,
1214                  llvm_v2f64_ty], [IntrNoMem]>;
1215  def int_x86_avx_vtestz_ps : GCCBuiltin<"__builtin_ia32_vtestzps">,
1216        Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
1217                  llvm_v4f32_ty], [IntrNoMem]>;
1218  def int_x86_avx_vtestc_ps : GCCBuiltin<"__builtin_ia32_vtestcps">,
1219        Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
1220                  llvm_v4f32_ty], [IntrNoMem]>;
1221  def int_x86_avx_vtestnzc_ps : GCCBuiltin<"__builtin_ia32_vtestnzcps">,
1222        Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty,
1223                  llvm_v4f32_ty], [IntrNoMem]>;
1224  def int_x86_avx_vtestz_pd_256 : GCCBuiltin<"__builtin_ia32_vtestzpd256">,
1225        Intrinsic<[llvm_i32_ty], [llvm_v4f64_ty,
1226                  llvm_v4f64_ty], [IntrNoMem]>;
1227  def int_x86_avx_vtestc_pd_256 : GCCBuiltin<"__builtin_ia32_vtestcpd256">,
1228        Intrinsic<[llvm_i32_ty], [llvm_v4f64_ty,
1229                  llvm_v4f64_ty], [IntrNoMem]>;
1230  def int_x86_avx_vtestnzc_pd_256 : GCCBuiltin<"__builtin_ia32_vtestnzcpd256">,
1231        Intrinsic<[llvm_i32_ty], [llvm_v4f64_ty,
1232                  llvm_v4f64_ty], [IntrNoMem]>;
1233  def int_x86_avx_vtestz_ps_256 : GCCBuiltin<"__builtin_ia32_vtestzps256">,
1234        Intrinsic<[llvm_i32_ty], [llvm_v8f32_ty,
1235                  llvm_v8f32_ty], [IntrNoMem]>;
1236  def int_x86_avx_vtestc_ps_256 : GCCBuiltin<"__builtin_ia32_vtestcps256">,
1237        Intrinsic<[llvm_i32_ty], [llvm_v8f32_ty,
1238                  llvm_v8f32_ty], [IntrNoMem]>;
1239  def int_x86_avx_vtestnzc_ps_256 : GCCBuiltin<"__builtin_ia32_vtestnzcps256">,
1240        Intrinsic<[llvm_i32_ty], [llvm_v8f32_ty,
1241                  llvm_v8f32_ty], [IntrNoMem]>;
1242  def int_x86_avx_ptestz_256 : GCCBuiltin<"__builtin_ia32_ptestz256">,
1243        Intrinsic<[llvm_i32_ty], [llvm_v4i64_ty,
1244                  llvm_v4i64_ty], [IntrNoMem]>;
1245  def int_x86_avx_ptestc_256 : GCCBuiltin<"__builtin_ia32_ptestc256">,
1246        Intrinsic<[llvm_i32_ty], [llvm_v4i64_ty,
1247                  llvm_v4i64_ty], [IntrNoMem]>;
1248  def int_x86_avx_ptestnzc_256 : GCCBuiltin<"__builtin_ia32_ptestnzc256">,
1249        Intrinsic<[llvm_i32_ty], [llvm_v4i64_ty,
1250                  llvm_v4i64_ty], [IntrNoMem]>;
1251}
1252
1253// Vector extract sign mask
1254let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1255  def int_x86_avx_movmsk_pd_256 : GCCBuiltin<"__builtin_ia32_movmskpd256">,
1256        Intrinsic<[llvm_i32_ty], [llvm_v4f64_ty], [IntrNoMem]>;
1257  def int_x86_avx_movmsk_ps_256 : GCCBuiltin<"__builtin_ia32_movmskps256">,
1258        Intrinsic<[llvm_i32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
1259}
1260
1261// Vector zero
1262let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1263  def int_x86_avx_vzeroall : GCCBuiltin<"__builtin_ia32_vzeroall">,
1264        Intrinsic<[], [], []>;
1265  def int_x86_avx_vzeroupper : GCCBuiltin<"__builtin_ia32_vzeroupper">,
1266        Intrinsic<[], [], []>;
1267}
1268
1269// Vector load with broadcast
1270let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1271  def int_x86_avx_vbroadcast_ss :
1272        GCCBuiltin<"__builtin_ia32_vbroadcastss">,
1273        Intrinsic<[llvm_v4f32_ty], [llvm_ptr_ty], [IntrReadArgMem]>;
1274  def int_x86_avx_vbroadcast_sd_256 :
1275        GCCBuiltin<"__builtin_ia32_vbroadcastsd256">,
1276        Intrinsic<[llvm_v4f64_ty], [llvm_ptr_ty], [IntrReadArgMem]>;
1277  def int_x86_avx_vbroadcast_ss_256 :
1278        GCCBuiltin<"__builtin_ia32_vbroadcastss256">,
1279        Intrinsic<[llvm_v8f32_ty], [llvm_ptr_ty], [IntrReadArgMem]>;
1280  def int_x86_avx_vbroadcastf128_pd_256 :
1281        GCCBuiltin<"__builtin_ia32_vbroadcastf128_pd256">,
1282        Intrinsic<[llvm_v4f64_ty], [llvm_ptr_ty], [IntrReadArgMem]>;
1283  def int_x86_avx_vbroadcastf128_ps_256 :
1284        GCCBuiltin<"__builtin_ia32_vbroadcastf128_ps256">,
1285        Intrinsic<[llvm_v8f32_ty], [llvm_ptr_ty], [IntrReadArgMem]>;
1286}
1287
1288// SIMD load ops
1289let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1290  def int_x86_avx_ldu_dq_256 : GCCBuiltin<"__builtin_ia32_lddqu256">,
1291        Intrinsic<[llvm_v32i8_ty], [llvm_ptr_ty], [IntrReadMem]>;
1292}
1293
1294// SIMD store ops
1295let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1296  def int_x86_avx_storeu_pd_256 : GCCBuiltin<"__builtin_ia32_storeupd256">,
1297        Intrinsic<[], [llvm_ptr_ty, llvm_v4f64_ty], [IntrReadWriteArgMem]>;
1298  def int_x86_avx_storeu_ps_256 : GCCBuiltin<"__builtin_ia32_storeups256">,
1299        Intrinsic<[], [llvm_ptr_ty, llvm_v8f32_ty], [IntrReadWriteArgMem]>;
1300  def int_x86_avx_storeu_dq_256 : GCCBuiltin<"__builtin_ia32_storedqu256">,
1301        Intrinsic<[], [llvm_ptr_ty, llvm_v32i8_ty], [IntrReadWriteArgMem]>;
1302}
1303
1304// Conditional load ops
1305let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1306  def int_x86_avx_maskload_pd : GCCBuiltin<"__builtin_ia32_maskloadpd">,
1307        Intrinsic<[llvm_v2f64_ty], [llvm_ptr_ty, llvm_v2f64_ty],
1308                  [IntrReadArgMem]>;
1309  def int_x86_avx_maskload_ps : GCCBuiltin<"__builtin_ia32_maskloadps">,
1310        Intrinsic<[llvm_v4f32_ty], [llvm_ptr_ty, llvm_v4f32_ty],
1311                  [IntrReadArgMem]>;
1312  def int_x86_avx_maskload_pd_256 : GCCBuiltin<"__builtin_ia32_maskloadpd256">,
1313        Intrinsic<[llvm_v4f64_ty], [llvm_ptr_ty, llvm_v4f64_ty],
1314                  [IntrReadArgMem]>;
1315  def int_x86_avx_maskload_ps_256 : GCCBuiltin<"__builtin_ia32_maskloadps256">,
1316        Intrinsic<[llvm_v8f32_ty], [llvm_ptr_ty, llvm_v8f32_ty],
1317                  [IntrReadArgMem]>;
1318}
1319
1320// Conditional store ops
1321let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1322  def int_x86_avx_maskstore_pd : GCCBuiltin<"__builtin_ia32_maskstorepd">,
1323        Intrinsic<[], [llvm_ptr_ty,
1324                  llvm_v2f64_ty, llvm_v2f64_ty], [IntrReadWriteArgMem]>;
1325  def int_x86_avx_maskstore_ps : GCCBuiltin<"__builtin_ia32_maskstoreps">,
1326        Intrinsic<[], [llvm_ptr_ty,
1327                  llvm_v4f32_ty, llvm_v4f32_ty], [IntrReadWriteArgMem]>;
1328  def int_x86_avx_maskstore_pd_256 :
1329        GCCBuiltin<"__builtin_ia32_maskstorepd256">,
1330        Intrinsic<[], [llvm_ptr_ty,
1331                  llvm_v4f64_ty, llvm_v4f64_ty], [IntrReadWriteArgMem]>;
1332  def int_x86_avx_maskstore_ps_256 :
1333        GCCBuiltin<"__builtin_ia32_maskstoreps256">,
1334        Intrinsic<[], [llvm_ptr_ty,
1335                  llvm_v8f32_ty, llvm_v8f32_ty], [IntrReadWriteArgMem]>;
1336}
1337
1338//===----------------------------------------------------------------------===//
1339// AVX2
1340
1341// Integer arithmetic ops.
1342let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1343  def int_x86_avx2_padds_b : GCCBuiltin<"__builtin_ia32_paddsb256">,
1344              Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1345                         llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1346  def int_x86_avx2_padds_w : GCCBuiltin<"__builtin_ia32_paddsw256">,
1347              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1348                         llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1349  def int_x86_avx2_paddus_b : GCCBuiltin<"__builtin_ia32_paddusb256">,
1350              Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1351                         llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1352  def int_x86_avx2_paddus_w : GCCBuiltin<"__builtin_ia32_paddusw256">,
1353              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1354                         llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1355  def int_x86_avx2_psubs_b : GCCBuiltin<"__builtin_ia32_psubsb256">,
1356              Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1357                         llvm_v32i8_ty], [IntrNoMem]>;
1358  def int_x86_avx2_psubs_w : GCCBuiltin<"__builtin_ia32_psubsw256">,
1359              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1360                         llvm_v16i16_ty], [IntrNoMem]>;
1361  def int_x86_avx2_psubus_b : GCCBuiltin<"__builtin_ia32_psubusb256">,
1362              Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1363                         llvm_v32i8_ty], [IntrNoMem]>;
1364  def int_x86_avx2_psubus_w : GCCBuiltin<"__builtin_ia32_psubusw256">,
1365              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1366                         llvm_v16i16_ty], [IntrNoMem]>;
1367  def int_x86_avx2_pmulhu_w : GCCBuiltin<"__builtin_ia32_pmulhuw256">,
1368              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1369                         llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1370  def int_x86_avx2_pmulh_w : GCCBuiltin<"__builtin_ia32_pmulhw256">,
1371              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1372                         llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1373  def int_x86_avx2_pmulu_dq : GCCBuiltin<"__builtin_ia32_pmuludq256">,
1374              Intrinsic<[llvm_v4i64_ty], [llvm_v8i32_ty,
1375                         llvm_v8i32_ty], [IntrNoMem, Commutative]>;
1376  def int_x86_avx2_pmul_dq : GCCBuiltin<"__builtin_ia32_pmuldq256">,
1377              Intrinsic<[llvm_v4i64_ty], [llvm_v8i32_ty,
1378                         llvm_v8i32_ty], [IntrNoMem, Commutative]>;
1379  def int_x86_avx2_pmadd_wd : GCCBuiltin<"__builtin_ia32_pmaddwd256">,
1380              Intrinsic<[llvm_v8i32_ty], [llvm_v16i16_ty,
1381                         llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1382  def int_x86_avx2_pavg_b : GCCBuiltin<"__builtin_ia32_pavgb256">,
1383              Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1384                         llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1385  def int_x86_avx2_pavg_w : GCCBuiltin<"__builtin_ia32_pavgw256">,
1386              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1387                         llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1388  def int_x86_avx2_psad_bw : GCCBuiltin<"__builtin_ia32_psadbw256">,
1389              Intrinsic<[llvm_v4i64_ty], [llvm_v32i8_ty,
1390                         llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1391}
1392
1393// Vector min, max
1394let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1395  def int_x86_avx2_pmaxu_b : GCCBuiltin<"__builtin_ia32_pmaxub256">,
1396              Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1397                         llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1398  def int_x86_avx2_pmaxu_w : GCCBuiltin<"__builtin_ia32_pmaxuw256">,
1399              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1400                         llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1401  def int_x86_avx2_pmaxu_d : GCCBuiltin<"__builtin_ia32_pmaxud256">,
1402              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1403                         llvm_v8i32_ty], [IntrNoMem, Commutative]>;
1404  def int_x86_avx2_pmaxs_b : GCCBuiltin<"__builtin_ia32_pmaxsb256">,
1405              Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1406                         llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1407  def int_x86_avx2_pmaxs_w : GCCBuiltin<"__builtin_ia32_pmaxsw256">,
1408              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1409                         llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1410  def int_x86_avx2_pmaxs_d : GCCBuiltin<"__builtin_ia32_pmaxsd256">,
1411              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1412                         llvm_v8i32_ty], [IntrNoMem, Commutative]>;
1413  def int_x86_avx2_pminu_b : GCCBuiltin<"__builtin_ia32_pminub256">,
1414              Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1415                         llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1416  def int_x86_avx2_pminu_w : GCCBuiltin<"__builtin_ia32_pminuw256">,
1417              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1418                         llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1419  def int_x86_avx2_pminu_d : GCCBuiltin<"__builtin_ia32_pminud256">,
1420              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1421                         llvm_v8i32_ty], [IntrNoMem, Commutative]>;
1422  def int_x86_avx2_pmins_b : GCCBuiltin<"__builtin_ia32_pminsb256">,
1423              Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1424                         llvm_v32i8_ty], [IntrNoMem, Commutative]>;
1425  def int_x86_avx2_pmins_w : GCCBuiltin<"__builtin_ia32_pminsw256">,
1426              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1427                         llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1428  def int_x86_avx2_pmins_d : GCCBuiltin<"__builtin_ia32_pminsd256">,
1429              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1430                         llvm_v8i32_ty], [IntrNoMem, Commutative]>;
1431}
1432
1433// Integer shift ops.
1434let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1435  def int_x86_avx2_psll_w : GCCBuiltin<"__builtin_ia32_psllw256">,
1436              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1437                         llvm_v8i16_ty], [IntrNoMem]>;
1438  def int_x86_avx2_psll_d : GCCBuiltin<"__builtin_ia32_pslld256">,
1439              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1440                         llvm_v4i32_ty], [IntrNoMem]>;
1441  def int_x86_avx2_psll_q : GCCBuiltin<"__builtin_ia32_psllq256">,
1442              Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,
1443                         llvm_v2i64_ty], [IntrNoMem]>;
1444  def int_x86_avx2_psrl_w : GCCBuiltin<"__builtin_ia32_psrlw256">,
1445              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1446                         llvm_v8i16_ty], [IntrNoMem]>;
1447  def int_x86_avx2_psrl_d : GCCBuiltin<"__builtin_ia32_psrld256">,
1448              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1449                         llvm_v4i32_ty], [IntrNoMem]>;
1450  def int_x86_avx2_psrl_q : GCCBuiltin<"__builtin_ia32_psrlq256">,
1451              Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,
1452                         llvm_v2i64_ty], [IntrNoMem]>;
1453  def int_x86_avx2_psra_w : GCCBuiltin<"__builtin_ia32_psraw256">,
1454              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1455                         llvm_v8i16_ty], [IntrNoMem]>;
1456  def int_x86_avx2_psra_d : GCCBuiltin<"__builtin_ia32_psrad256">,
1457              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1458                         llvm_v4i32_ty], [IntrNoMem]>;
1459
1460  def int_x86_avx2_pslli_w : GCCBuiltin<"__builtin_ia32_psllwi256">,
1461              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1462                         llvm_i32_ty], [IntrNoMem]>;
1463  def int_x86_avx2_pslli_d : GCCBuiltin<"__builtin_ia32_pslldi256">,
1464              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1465                         llvm_i32_ty], [IntrNoMem]>;
1466  def int_x86_avx2_pslli_q : GCCBuiltin<"__builtin_ia32_psllqi256">,
1467              Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,
1468                         llvm_i32_ty], [IntrNoMem]>;
1469  def int_x86_avx2_psrli_w : GCCBuiltin<"__builtin_ia32_psrlwi256">,
1470              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1471                         llvm_i32_ty], [IntrNoMem]>;
1472  def int_x86_avx2_psrli_d : GCCBuiltin<"__builtin_ia32_psrldi256">,
1473              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1474                         llvm_i32_ty], [IntrNoMem]>;
1475  def int_x86_avx2_psrli_q : GCCBuiltin<"__builtin_ia32_psrlqi256">,
1476              Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,
1477                         llvm_i32_ty], [IntrNoMem]>;
1478  def int_x86_avx2_psrai_w : GCCBuiltin<"__builtin_ia32_psrawi256">,
1479              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1480                         llvm_i32_ty], [IntrNoMem]>;
1481  def int_x86_avx2_psrai_d : GCCBuiltin<"__builtin_ia32_psradi256">,
1482              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1483                         llvm_i32_ty], [IntrNoMem]>;
1484
1485  def int_x86_avx2_psll_dq : GCCBuiltin<"__builtin_ia32_pslldqi256">,
1486              Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,
1487                         llvm_i32_ty], [IntrNoMem]>;
1488  def int_x86_avx2_psrl_dq : GCCBuiltin<"__builtin_ia32_psrldqi256">,
1489              Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,
1490                         llvm_i32_ty], [IntrNoMem]>;
1491  def int_x86_avx2_psll_dq_bs : GCCBuiltin<"__builtin_ia32_pslldqi256_byteshift">,
1492              Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,
1493                         llvm_i32_ty], [IntrNoMem]>;
1494  def int_x86_avx2_psrl_dq_bs : GCCBuiltin<"__builtin_ia32_psrldqi256_byteshift">,
1495              Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,
1496                         llvm_i32_ty], [IntrNoMem]>;
1497}
1498
1499// Pack ops.
1500let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1501  def int_x86_avx2_packsswb : GCCBuiltin<"__builtin_ia32_packsswb256">,
1502              Intrinsic<[llvm_v32i8_ty], [llvm_v16i16_ty,
1503                         llvm_v16i16_ty], [IntrNoMem]>;
1504  def int_x86_avx2_packssdw : GCCBuiltin<"__builtin_ia32_packssdw256">,
1505              Intrinsic<[llvm_v16i16_ty], [llvm_v8i32_ty,
1506                         llvm_v8i32_ty], [IntrNoMem]>;
1507  def int_x86_avx2_packuswb : GCCBuiltin<"__builtin_ia32_packuswb256">,
1508              Intrinsic<[llvm_v32i8_ty], [llvm_v16i16_ty,
1509                         llvm_v16i16_ty], [IntrNoMem]>;
1510  def int_x86_avx2_packusdw : GCCBuiltin<"__builtin_ia32_packusdw256">,
1511              Intrinsic<[llvm_v16i16_ty], [llvm_v8i32_ty,
1512                         llvm_v8i32_ty], [IntrNoMem]>;
1513}
1514
1515// Absolute value ops
1516let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1517  def int_x86_avx2_pabs_b : GCCBuiltin<"__builtin_ia32_pabsb256">,
1518              Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty], [IntrNoMem]>;
1519  def int_x86_avx2_pabs_w : GCCBuiltin<"__builtin_ia32_pabsw256">,
1520              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty], [IntrNoMem]>;
1521  def int_x86_avx2_pabs_d : GCCBuiltin<"__builtin_ia32_pabsd256">,
1522              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty], [IntrNoMem]>;
1523}
1524
1525// Horizontal arithmetic ops
1526let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1527  def int_x86_avx2_phadd_w : GCCBuiltin<"__builtin_ia32_phaddw256">,
1528              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1529                         llvm_v16i16_ty], [IntrNoMem]>;
1530  def int_x86_avx2_phadd_d : GCCBuiltin<"__builtin_ia32_phaddd256">,
1531              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1532                         llvm_v8i32_ty], [IntrNoMem]>;
1533  def int_x86_avx2_phadd_sw : GCCBuiltin<"__builtin_ia32_phaddsw256">,
1534              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1535                         llvm_v16i16_ty], [IntrNoMem]>;
1536  def int_x86_avx2_phsub_w : GCCBuiltin<"__builtin_ia32_phsubw256">,
1537              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1538                         llvm_v16i16_ty], [IntrNoMem]>;
1539  def int_x86_avx2_phsub_d : GCCBuiltin<"__builtin_ia32_phsubd256">,
1540              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1541                         llvm_v8i32_ty], [IntrNoMem]>;
1542  def int_x86_avx2_phsub_sw : GCCBuiltin<"__builtin_ia32_phsubsw256">,
1543              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1544                         llvm_v16i16_ty], [IntrNoMem]>;
1545  def int_x86_avx2_pmadd_ub_sw : GCCBuiltin<"__builtin_ia32_pmaddubsw256">,
1546              Intrinsic<[llvm_v16i16_ty], [llvm_v32i8_ty,
1547                         llvm_v32i8_ty], [IntrNoMem]>;
1548}
1549
1550// Sign ops
1551let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1552  def int_x86_avx2_psign_b : GCCBuiltin<"__builtin_ia32_psignb256">,
1553              Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1554                         llvm_v32i8_ty], [IntrNoMem]>;
1555  def int_x86_avx2_psign_w : GCCBuiltin<"__builtin_ia32_psignw256">,
1556              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1557                         llvm_v16i16_ty], [IntrNoMem]>;
1558  def int_x86_avx2_psign_d : GCCBuiltin<"__builtin_ia32_psignd256">,
1559              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty,
1560                         llvm_v8i32_ty], [IntrNoMem]>;
1561}
1562
1563// Packed multiply high with round and scale
1564let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1565  def int_x86_avx2_pmul_hr_sw : GCCBuiltin<"__builtin_ia32_pmulhrsw256">,
1566              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty,
1567                         llvm_v16i16_ty], [IntrNoMem, Commutative]>;
1568}
1569
1570// Vector sign and zero extend
1571let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1572  def int_x86_avx2_pmovsxbd : GCCBuiltin<"__builtin_ia32_pmovsxbd256">,
1573              Intrinsic<[llvm_v8i32_ty], [llvm_v16i8_ty],
1574                        [IntrNoMem]>;
1575  def int_x86_avx2_pmovsxbq : GCCBuiltin<"__builtin_ia32_pmovsxbq256">,
1576              Intrinsic<[llvm_v4i64_ty], [llvm_v16i8_ty],
1577                        [IntrNoMem]>;
1578  def int_x86_avx2_pmovsxbw : GCCBuiltin<"__builtin_ia32_pmovsxbw256">,
1579              Intrinsic<[llvm_v16i16_ty], [llvm_v16i8_ty],
1580                        [IntrNoMem]>;
1581  def int_x86_avx2_pmovsxdq : GCCBuiltin<"__builtin_ia32_pmovsxdq256">,
1582              Intrinsic<[llvm_v4i64_ty], [llvm_v4i32_ty],
1583                        [IntrNoMem]>;
1584  def int_x86_avx2_pmovsxwd : GCCBuiltin<"__builtin_ia32_pmovsxwd256">,
1585              Intrinsic<[llvm_v8i32_ty], [llvm_v8i16_ty],
1586                        [IntrNoMem]>;
1587  def int_x86_avx2_pmovsxwq : GCCBuiltin<"__builtin_ia32_pmovsxwq256">,
1588              Intrinsic<[llvm_v4i64_ty], [llvm_v8i16_ty],
1589                        [IntrNoMem]>;
1590  def int_x86_avx2_pmovzxbd : GCCBuiltin<"__builtin_ia32_pmovzxbd256">,
1591              Intrinsic<[llvm_v8i32_ty], [llvm_v16i8_ty],
1592                        [IntrNoMem]>;
1593  def int_x86_avx2_pmovzxbq : GCCBuiltin<"__builtin_ia32_pmovzxbq256">,
1594              Intrinsic<[llvm_v4i64_ty], [llvm_v16i8_ty],
1595                        [IntrNoMem]>;
1596  def int_x86_avx2_pmovzxbw : GCCBuiltin<"__builtin_ia32_pmovzxbw256">,
1597              Intrinsic<[llvm_v16i16_ty], [llvm_v16i8_ty],
1598                        [IntrNoMem]>;
1599  def int_x86_avx2_pmovzxdq : GCCBuiltin<"__builtin_ia32_pmovzxdq256">,
1600              Intrinsic<[llvm_v4i64_ty], [llvm_v4i32_ty],
1601                        [IntrNoMem]>;
1602  def int_x86_avx2_pmovzxwd : GCCBuiltin<"__builtin_ia32_pmovzxwd256">,
1603              Intrinsic<[llvm_v8i32_ty], [llvm_v8i16_ty],
1604                        [IntrNoMem]>;
1605  def int_x86_avx2_pmovzxwq : GCCBuiltin<"__builtin_ia32_pmovzxwq256">,
1606              Intrinsic<[llvm_v4i64_ty], [llvm_v8i16_ty],
1607                        [IntrNoMem]>;
1608}
1609
1610// Vector blend
1611let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1612  def int_x86_avx2_pblendvb : GCCBuiltin<"__builtin_ia32_pblendvb256">,
1613              Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty, llvm_v32i8_ty,
1614                         llvm_v32i8_ty], [IntrNoMem]>;
1615  def int_x86_avx2_pblendw : GCCBuiltin<"__builtin_ia32_pblendw256">,
1616              Intrinsic<[llvm_v16i16_ty], [llvm_v16i16_ty, llvm_v16i16_ty,
1617                         llvm_i32_ty], [IntrNoMem]>;
1618  def int_x86_avx2_pblendd_128 : GCCBuiltin<"__builtin_ia32_pblendd128">,
1619              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty,
1620                         llvm_i32_ty], [IntrNoMem]>;
1621  def int_x86_avx2_pblendd_256 : GCCBuiltin<"__builtin_ia32_pblendd256">,
1622              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty,
1623                         llvm_i32_ty], [IntrNoMem]>;
1624}
1625
1626// Vector load with broadcast
1627let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1628  def int_x86_avx2_vbroadcast_ss_ps :
1629              GCCBuiltin<"__builtin_ia32_vbroadcastss_ps">,
1630              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
1631  def int_x86_avx2_vbroadcast_sd_pd_256 :
1632              GCCBuiltin<"__builtin_ia32_vbroadcastsd_pd256">,
1633              Intrinsic<[llvm_v4f64_ty], [llvm_v2f64_ty], [IntrNoMem]>;
1634  def int_x86_avx2_vbroadcast_ss_ps_256 :
1635              GCCBuiltin<"__builtin_ia32_vbroadcastss_ps256">,
1636              Intrinsic<[llvm_v8f32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
1637  def int_x86_avx2_vbroadcasti128 :
1638              GCCBuiltin<"__builtin_ia32_vbroadcastsi256">,
1639              Intrinsic<[llvm_v4i64_ty], [llvm_ptr_ty], [IntrReadArgMem]>;
1640  def int_x86_avx2_pbroadcastb_128 :
1641              GCCBuiltin<"__builtin_ia32_pbroadcastb128">,
1642              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty], [IntrNoMem]>;
1643  def int_x86_avx2_pbroadcastb_256 :
1644              GCCBuiltin<"__builtin_ia32_pbroadcastb256">,
1645              Intrinsic<[llvm_v32i8_ty], [llvm_v16i8_ty], [IntrNoMem]>;
1646  def int_x86_avx2_pbroadcastw_128 :
1647              GCCBuiltin<"__builtin_ia32_pbroadcastw128">,
1648              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty], [IntrNoMem]>;
1649  def int_x86_avx2_pbroadcastw_256 :
1650              GCCBuiltin<"__builtin_ia32_pbroadcastw256">,
1651              Intrinsic<[llvm_v16i16_ty], [llvm_v8i16_ty], [IntrNoMem]>;
1652  def int_x86_avx2_pbroadcastd_128 :
1653              GCCBuiltin<"__builtin_ia32_pbroadcastd128">,
1654              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty], [IntrNoMem]>;
1655  def int_x86_avx2_pbroadcastd_256 :
1656              GCCBuiltin<"__builtin_ia32_pbroadcastd256">,
1657              Intrinsic<[llvm_v8i32_ty], [llvm_v4i32_ty], [IntrNoMem]>;
1658  def int_x86_avx2_pbroadcastq_128 :
1659              GCCBuiltin<"__builtin_ia32_pbroadcastq128">,
1660              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty], [IntrNoMem]>;
1661  def int_x86_avx2_pbroadcastq_256 :
1662              GCCBuiltin<"__builtin_ia32_pbroadcastq256">,
1663              Intrinsic<[llvm_v4i64_ty], [llvm_v2i64_ty], [IntrNoMem]>;
1664}
1665
1666// Vector permutation
1667let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1668  def int_x86_avx2_permd : GCCBuiltin<"__builtin_ia32_permvarsi256">,
1669              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty],
1670                        [IntrNoMem]>;
1671  def int_x86_avx2_permps : GCCBuiltin<"__builtin_ia32_permvarsf256">,
1672              Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, llvm_v8f32_ty],
1673                        [IntrNoMem]>;
1674  def int_x86_avx2_vperm2i128 : GCCBuiltin<"__builtin_ia32_permti256">,
1675              Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,
1676                         llvm_v4i64_ty, llvm_i8_ty], [IntrNoMem]>;
1677}
1678
1679// Vector extract and insert
1680let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1681  def int_x86_avx2_vextracti128 : GCCBuiltin<"__builtin_ia32_extract128i256">,
1682              Intrinsic<[llvm_v2i64_ty], [llvm_v4i64_ty,
1683                         llvm_i8_ty], [IntrNoMem]>;
1684  def int_x86_avx2_vinserti128 : GCCBuiltin<"__builtin_ia32_insert128i256">,
1685              Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty,
1686                         llvm_v2i64_ty, llvm_i8_ty], [IntrNoMem]>;
1687}
1688
1689// Conditional load ops
1690let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1691  def int_x86_avx2_maskload_d : GCCBuiltin<"__builtin_ia32_maskloadd">,
1692        Intrinsic<[llvm_v4i32_ty], [llvm_ptr_ty, llvm_v4i32_ty],
1693                  [IntrReadArgMem]>;
1694  def int_x86_avx2_maskload_q : GCCBuiltin<"__builtin_ia32_maskloadq">,
1695        Intrinsic<[llvm_v2i64_ty], [llvm_ptr_ty, llvm_v2i64_ty],
1696                  [IntrReadArgMem]>;
1697  def int_x86_avx2_maskload_d_256 : GCCBuiltin<"__builtin_ia32_maskloadd256">,
1698        Intrinsic<[llvm_v8i32_ty], [llvm_ptr_ty, llvm_v8i32_ty],
1699                  [IntrReadArgMem]>;
1700  def int_x86_avx2_maskload_q_256 : GCCBuiltin<"__builtin_ia32_maskloadq256">,
1701        Intrinsic<[llvm_v4i64_ty], [llvm_ptr_ty, llvm_v4i64_ty],
1702                  [IntrReadArgMem]>;
1703}
1704
1705// Conditional store ops
1706let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1707  def int_x86_avx2_maskstore_d : GCCBuiltin<"__builtin_ia32_maskstored">,
1708        Intrinsic<[], [llvm_ptr_ty, llvm_v4i32_ty, llvm_v4i32_ty],
1709                  [IntrReadWriteArgMem]>;
1710  def int_x86_avx2_maskstore_q : GCCBuiltin<"__builtin_ia32_maskstoreq">,
1711        Intrinsic<[], [llvm_ptr_ty, llvm_v2i64_ty, llvm_v2i64_ty],
1712                  [IntrReadWriteArgMem]>;
1713  def int_x86_avx2_maskstore_d_256 :
1714        GCCBuiltin<"__builtin_ia32_maskstored256">,
1715        Intrinsic<[], [llvm_ptr_ty, llvm_v8i32_ty, llvm_v8i32_ty],
1716                  [IntrReadWriteArgMem]>;
1717  def int_x86_avx2_maskstore_q_256 :
1718        GCCBuiltin<"__builtin_ia32_maskstoreq256">,
1719        Intrinsic<[], [llvm_ptr_ty, llvm_v4i64_ty, llvm_v4i64_ty],
1720                  [IntrReadWriteArgMem]>;
1721}
1722
1723// Variable bit shift ops
1724let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1725  def int_x86_avx2_psllv_d : GCCBuiltin<"__builtin_ia32_psllv4si">,
1726              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
1727                        [IntrNoMem]>;
1728  def int_x86_avx2_psllv_d_256 : GCCBuiltin<"__builtin_ia32_psllv8si">,
1729              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty],
1730                        [IntrNoMem]>;
1731  def int_x86_avx2_psllv_q : GCCBuiltin<"__builtin_ia32_psllv2di">,
1732              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
1733                        [IntrNoMem]>;
1734  def int_x86_avx2_psllv_q_256 : GCCBuiltin<"__builtin_ia32_psllv4di">,
1735              Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, llvm_v4i64_ty],
1736                        [IntrNoMem]>;
1737
1738  def int_x86_avx2_psrlv_d : GCCBuiltin<"__builtin_ia32_psrlv4si">,
1739              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
1740                        [IntrNoMem]>;
1741  def int_x86_avx2_psrlv_d_256 : GCCBuiltin<"__builtin_ia32_psrlv8si">,
1742              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty],
1743                        [IntrNoMem]>;
1744  def int_x86_avx2_psrlv_q : GCCBuiltin<"__builtin_ia32_psrlv2di">,
1745              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
1746                        [IntrNoMem]>;
1747  def int_x86_avx2_psrlv_q_256 : GCCBuiltin<"__builtin_ia32_psrlv4di">,
1748              Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, llvm_v4i64_ty],
1749                        [IntrNoMem]>;
1750
1751  def int_x86_avx2_psrav_d : GCCBuiltin<"__builtin_ia32_psrav4si">,
1752              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
1753                        [IntrNoMem]>;
1754  def int_x86_avx2_psrav_d_256 : GCCBuiltin<"__builtin_ia32_psrav8si">,
1755              Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty],
1756                        [IntrNoMem]>;
1757}
1758
1759// Gather ops
1760let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1761  def int_x86_avx2_gather_d_pd : GCCBuiltin<"__builtin_ia32_gatherd_pd">,
1762      Intrinsic<[llvm_v2f64_ty],
1763        [llvm_v2f64_ty, llvm_ptr_ty, llvm_v4i32_ty, llvm_v2f64_ty, llvm_i8_ty],
1764        [IntrReadMem]>;
1765  def int_x86_avx2_gather_d_pd_256 : GCCBuiltin<"__builtin_ia32_gatherd_pd256">,
1766      Intrinsic<[llvm_v4f64_ty],
1767        [llvm_v4f64_ty, llvm_ptr_ty, llvm_v4i32_ty, llvm_v4f64_ty, llvm_i8_ty],
1768        [IntrReadMem]>;
1769  def int_x86_avx2_gather_q_pd : GCCBuiltin<"__builtin_ia32_gatherq_pd">,
1770      Intrinsic<[llvm_v2f64_ty],
1771        [llvm_v2f64_ty, llvm_ptr_ty, llvm_v2i64_ty, llvm_v2f64_ty, llvm_i8_ty],
1772        [IntrReadMem]>;
1773  def int_x86_avx2_gather_q_pd_256 : GCCBuiltin<"__builtin_ia32_gatherq_pd256">,
1774      Intrinsic<[llvm_v4f64_ty],
1775        [llvm_v4f64_ty, llvm_ptr_ty, llvm_v4i64_ty, llvm_v4f64_ty, llvm_i8_ty],
1776        [IntrReadMem]>;
1777  def int_x86_avx2_gather_d_ps : GCCBuiltin<"__builtin_ia32_gatherd_ps">,
1778      Intrinsic<[llvm_v4f32_ty],
1779        [llvm_v4f32_ty, llvm_ptr_ty, llvm_v4i32_ty, llvm_v4f32_ty, llvm_i8_ty],
1780        [IntrReadMem]>;
1781  def int_x86_avx2_gather_d_ps_256 : GCCBuiltin<"__builtin_ia32_gatherd_ps256">,
1782      Intrinsic<[llvm_v8f32_ty],
1783        [llvm_v8f32_ty, llvm_ptr_ty, llvm_v8i32_ty, llvm_v8f32_ty, llvm_i8_ty],
1784        [IntrReadMem]>;
1785  def int_x86_avx2_gather_q_ps : GCCBuiltin<"__builtin_ia32_gatherq_ps">,
1786      Intrinsic<[llvm_v4f32_ty],
1787        [llvm_v4f32_ty, llvm_ptr_ty, llvm_v2i64_ty, llvm_v4f32_ty, llvm_i8_ty],
1788        [IntrReadMem]>;
1789  def int_x86_avx2_gather_q_ps_256 : GCCBuiltin<"__builtin_ia32_gatherq_ps256">,
1790      Intrinsic<[llvm_v4f32_ty],
1791        [llvm_v4f32_ty, llvm_ptr_ty, llvm_v4i64_ty, llvm_v4f32_ty, llvm_i8_ty],
1792        [IntrReadMem]>;
1793
1794  def int_x86_avx2_gather_d_q : GCCBuiltin<"__builtin_ia32_gatherd_q">,
1795      Intrinsic<[llvm_v2i64_ty],
1796        [llvm_v2i64_ty, llvm_ptr_ty, llvm_v4i32_ty, llvm_v2i64_ty, llvm_i8_ty],
1797        [IntrReadMem]>;
1798  def int_x86_avx2_gather_d_q_256 : GCCBuiltin<"__builtin_ia32_gatherd_q256">,
1799      Intrinsic<[llvm_v4i64_ty],
1800        [llvm_v4i64_ty, llvm_ptr_ty, llvm_v4i32_ty, llvm_v4i64_ty, llvm_i8_ty],
1801        [IntrReadMem]>;
1802  def int_x86_avx2_gather_q_q : GCCBuiltin<"__builtin_ia32_gatherq_q">,
1803      Intrinsic<[llvm_v2i64_ty],
1804        [llvm_v2i64_ty, llvm_ptr_ty, llvm_v2i64_ty, llvm_v2i64_ty, llvm_i8_ty],
1805        [IntrReadMem]>;
1806  def int_x86_avx2_gather_q_q_256 : GCCBuiltin<"__builtin_ia32_gatherq_q256">,
1807      Intrinsic<[llvm_v4i64_ty],
1808        [llvm_v4i64_ty, llvm_ptr_ty, llvm_v4i64_ty, llvm_v4i64_ty, llvm_i8_ty],
1809        [IntrReadMem]>;
1810  def int_x86_avx2_gather_d_d : GCCBuiltin<"__builtin_ia32_gatherd_d">,
1811      Intrinsic<[llvm_v4i32_ty],
1812        [llvm_v4i32_ty, llvm_ptr_ty, llvm_v4i32_ty, llvm_v4i32_ty, llvm_i8_ty],
1813        [IntrReadMem]>;
1814  def int_x86_avx2_gather_d_d_256 : GCCBuiltin<"__builtin_ia32_gatherd_d256">,
1815      Intrinsic<[llvm_v8i32_ty],
1816        [llvm_v8i32_ty, llvm_ptr_ty, llvm_v8i32_ty, llvm_v8i32_ty, llvm_i8_ty],
1817        [IntrReadMem]>;
1818  def int_x86_avx2_gather_q_d : GCCBuiltin<"__builtin_ia32_gatherq_d">,
1819      Intrinsic<[llvm_v4i32_ty],
1820        [llvm_v4i32_ty, llvm_ptr_ty, llvm_v2i64_ty, llvm_v4i32_ty, llvm_i8_ty],
1821        [IntrReadMem]>;
1822  def int_x86_avx2_gather_q_d_256 : GCCBuiltin<"__builtin_ia32_gatherq_d256">,
1823      Intrinsic<[llvm_v4i32_ty],
1824        [llvm_v4i32_ty, llvm_ptr_ty, llvm_v4i64_ty, llvm_v4i32_ty, llvm_i8_ty],
1825        [IntrReadMem]>;
1826}
1827
1828// Misc.
1829let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1830  def int_x86_avx2_pmovmskb : GCCBuiltin<"__builtin_ia32_pmovmskb256">,
1831              Intrinsic<[llvm_i32_ty], [llvm_v32i8_ty], [IntrNoMem]>;
1832  def int_x86_avx2_pshuf_b : GCCBuiltin<"__builtin_ia32_pshufb256">,
1833              Intrinsic<[llvm_v32i8_ty], [llvm_v32i8_ty,
1834                         llvm_v32i8_ty], [IntrNoMem]>;
1835  def int_x86_avx2_mpsadbw : GCCBuiltin<"__builtin_ia32_mpsadbw256">,
1836              Intrinsic<[llvm_v16i16_ty], [llvm_v32i8_ty, llvm_v32i8_ty,
1837                         llvm_i32_ty], [IntrNoMem, Commutative]>;
1838  def int_x86_avx2_movntdqa : GCCBuiltin<"__builtin_ia32_movntdqa256">,
1839              Intrinsic<[llvm_v4i64_ty], [llvm_ptr_ty], [IntrReadMem]>;
1840}
1841
1842//===----------------------------------------------------------------------===//
1843// FMA3 and FMA4
1844
1845let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
1846  def int_x86_fma_vfmadd_ss : GCCBuiltin<"__builtin_ia32_vfmaddss">,
1847              Intrinsic<[llvm_v4f32_ty],
1848                        [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
1849                        [IntrNoMem]>;
1850  def int_x86_fma_vfmadd_sd : GCCBuiltin<"__builtin_ia32_vfmaddsd">,
1851              Intrinsic<[llvm_v2f64_ty],
1852                        [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
1853                        [IntrNoMem]>;
1854  def int_x86_fma_vfmadd_ps : GCCBuiltin<"__builtin_ia32_vfmaddps">,
1855              Intrinsic<[llvm_v4f32_ty],
1856                        [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
1857                        [IntrNoMem]>;
1858  def int_x86_fma_vfmadd_pd : GCCBuiltin<"__builtin_ia32_vfmaddpd">,
1859              Intrinsic<[llvm_v2f64_ty],
1860                        [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
1861                        [IntrNoMem]>;
1862  def int_x86_fma_vfmadd_ps_256 : GCCBuiltin<"__builtin_ia32_vfmaddps256">,
1863              Intrinsic<[llvm_v8f32_ty],
1864                        [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty],
1865                        [IntrNoMem]>;
1866  def int_x86_fma_vfmadd_pd_256 : GCCBuiltin<"__builtin_ia32_vfmaddpd256">,
1867              Intrinsic<[llvm_v4f64_ty],
1868                        [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty],
1869                        [IntrNoMem]>;
1870  def int_x86_fma_vfmsub_ss : GCCBuiltin<"__builtin_ia32_vfmsubss">,
1871              Intrinsic<[llvm_v4f32_ty],
1872                        [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
1873                        [IntrNoMem]>;
1874  def int_x86_fma_vfmsub_sd : GCCBuiltin<"__builtin_ia32_vfmsubsd">,
1875              Intrinsic<[llvm_v2f64_ty],
1876                        [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
1877                        [IntrNoMem]>;
1878  def int_x86_fma_vfmsub_ps : GCCBuiltin<"__builtin_ia32_vfmsubps">,
1879              Intrinsic<[llvm_v4f32_ty],
1880                        [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
1881                        [IntrNoMem]>;
1882  def int_x86_fma_vfmsub_pd : GCCBuiltin<"__builtin_ia32_vfmsubpd">,
1883              Intrinsic<[llvm_v2f64_ty],
1884                        [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
1885                        [IntrNoMem]>;
1886  def int_x86_fma_vfmsub_ps_256 : GCCBuiltin<"__builtin_ia32_vfmsubps256">,
1887              Intrinsic<[llvm_v8f32_ty],
1888                        [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty],
1889                        [IntrNoMem]>;
1890  def int_x86_fma_vfmsub_pd_256 : GCCBuiltin<"__builtin_ia32_vfmsubpd256">,
1891              Intrinsic<[llvm_v4f64_ty],
1892                        [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty],
1893                        [IntrNoMem]>;
1894  def int_x86_fma_vfnmadd_ss : GCCBuiltin<"__builtin_ia32_vfnmaddss">,
1895              Intrinsic<[llvm_v4f32_ty],
1896                        [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
1897                        [IntrNoMem]>;
1898  def int_x86_fma_vfnmadd_sd : GCCBuiltin<"__builtin_ia32_vfnmaddsd">,
1899              Intrinsic<[llvm_v2f64_ty],
1900                        [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
1901                        [IntrNoMem]>;
1902  def int_x86_fma_vfnmadd_ps : GCCBuiltin<"__builtin_ia32_vfnmaddps">,
1903              Intrinsic<[llvm_v4f32_ty],
1904                        [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
1905                        [IntrNoMem]>;
1906  def int_x86_fma_vfnmadd_pd : GCCBuiltin<"__builtin_ia32_vfnmaddpd">,
1907              Intrinsic<[llvm_v2f64_ty],
1908                        [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
1909                        [IntrNoMem]>;
1910  def int_x86_fma_vfnmadd_ps_256 : GCCBuiltin<"__builtin_ia32_vfnmaddps256">,
1911              Intrinsic<[llvm_v8f32_ty],
1912                        [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty],
1913                        [IntrNoMem]>;
1914  def int_x86_fma_vfnmadd_pd_256 : GCCBuiltin<"__builtin_ia32_vfnmaddpd256">,
1915              Intrinsic<[llvm_v4f64_ty],
1916                        [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty],
1917                        [IntrNoMem]>;
1918  def int_x86_fma_vfnmsub_ss : GCCBuiltin<"__builtin_ia32_vfnmsubss">,
1919              Intrinsic<[llvm_v4f32_ty],
1920                        [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
1921                        [IntrNoMem]>;
1922  def int_x86_fma_vfnmsub_sd : GCCBuiltin<"__builtin_ia32_vfnmsubsd">,
1923              Intrinsic<[llvm_v2f64_ty],
1924                        [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
1925                        [IntrNoMem]>;
1926  def int_x86_fma_vfnmsub_ps : GCCBuiltin<"__builtin_ia32_vfnmsubps">,
1927              Intrinsic<[llvm_v4f32_ty],
1928                        [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
1929                        [IntrNoMem]>;
1930  def int_x86_fma_vfnmsub_pd : GCCBuiltin<"__builtin_ia32_vfnmsubpd">,
1931              Intrinsic<[llvm_v2f64_ty],
1932                        [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
1933                        [IntrNoMem]>;
1934  def int_x86_fma_vfnmsub_ps_256 : GCCBuiltin<"__builtin_ia32_vfnmsubps256">,
1935              Intrinsic<[llvm_v8f32_ty],
1936                        [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty],
1937                        [IntrNoMem]>;
1938  def int_x86_fma_vfnmsub_pd_256 : GCCBuiltin<"__builtin_ia32_vfnmsubpd256">,
1939              Intrinsic<[llvm_v4f64_ty],
1940                        [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty],
1941                        [IntrNoMem]>;
1942  def int_x86_fma_vfmaddsub_ps : GCCBuiltin<"__builtin_ia32_vfmaddsubps">,
1943              Intrinsic<[llvm_v4f32_ty],
1944                        [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
1945                        [IntrNoMem]>;
1946  def int_x86_fma_vfmaddsub_pd : GCCBuiltin<"__builtin_ia32_vfmaddsubpd">,
1947              Intrinsic<[llvm_v2f64_ty],
1948                        [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
1949                        [IntrNoMem]>;
1950  def int_x86_fma_vfmaddsub_ps_256 :
1951               GCCBuiltin<"__builtin_ia32_vfmaddsubps256">,
1952              Intrinsic<[llvm_v8f32_ty],
1953                        [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty],
1954                        [IntrNoMem]>;
1955  def int_x86_fma_vfmaddsub_pd_256 :
1956              GCCBuiltin<"__builtin_ia32_vfmaddsubpd256">,
1957              Intrinsic<[llvm_v4f64_ty],
1958                        [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty],
1959                        [IntrNoMem]>;
1960  def int_x86_fma_vfmsubadd_ps : GCCBuiltin<"__builtin_ia32_vfmsubaddps">,
1961              Intrinsic<[llvm_v4f32_ty],
1962                        [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty],
1963                        [IntrNoMem]>;
1964  def int_x86_fma_vfmsubadd_pd : GCCBuiltin<"__builtin_ia32_vfmsubaddpd">,
1965              Intrinsic<[llvm_v2f64_ty],
1966                        [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty],
1967                        [IntrNoMem]>;
1968  def int_x86_fma_vfmsubadd_ps_256 :
1969              GCCBuiltin<"__builtin_ia32_vfmsubaddps256">,
1970              Intrinsic<[llvm_v8f32_ty],
1971                        [llvm_v8f32_ty, llvm_v8f32_ty, llvm_v8f32_ty],
1972                        [IntrNoMem]>;
1973  def int_x86_fma_vfmsubadd_pd_256 :
1974              GCCBuiltin<"__builtin_ia32_vfmsubaddpd256">,
1975              Intrinsic<[llvm_v4f64_ty],
1976                        [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty],
1977                        [IntrNoMem]>;
1978}
1979
1980//===----------------------------------------------------------------------===//
1981// XOP
1982
1983  def int_x86_xop_vpermil2pd : GCCBuiltin<"__builtin_ia32_vpermil2pd">,
1984              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty,
1985                                          llvm_v2f64_ty, llvm_i8_ty],
1986                        [IntrNoMem]>;
1987
1988  def int_x86_xop_vpermil2pd_256 :
1989              GCCBuiltin<"__builtin_ia32_vpermil2pd256">,
1990              Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, llvm_v4f64_ty,
1991                                          llvm_v4f64_ty, llvm_i8_ty],
1992                        [IntrNoMem]>;
1993
1994  def int_x86_xop_vpermil2ps : GCCBuiltin<"__builtin_ia32_vpermil2ps">,
1995              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty,
1996                                          llvm_v4f32_ty, llvm_i8_ty],
1997                        [IntrNoMem]>;
1998  def int_x86_xop_vpermil2ps_256 :
1999              GCCBuiltin<"__builtin_ia32_vpermil2ps256">,
2000              Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, llvm_v8f32_ty,
2001                                          llvm_v8f32_ty, llvm_i8_ty],
2002                        [IntrNoMem]>;
2003
2004  def int_x86_xop_vfrcz_pd : GCCBuiltin<"__builtin_ia32_vfrczpd">,
2005              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty], [IntrNoMem]>;
2006  def int_x86_xop_vfrcz_ps : GCCBuiltin<"__builtin_ia32_vfrczps">,
2007              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
2008  def int_x86_xop_vfrcz_sd : GCCBuiltin<"__builtin_ia32_vfrczsd">,
2009              Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty], [IntrNoMem]>;
2010  def int_x86_xop_vfrcz_ss : GCCBuiltin<"__builtin_ia32_vfrczss">,
2011              Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], [IntrNoMem]>;
2012  def int_x86_xop_vfrcz_pd_256 : GCCBuiltin<"__builtin_ia32_vfrczpd256">,
2013              Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty], [IntrNoMem]>;
2014  def int_x86_xop_vfrcz_ps_256 : GCCBuiltin<"__builtin_ia32_vfrczps256">,
2015              Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty], [IntrNoMem]>;
2016
2017  def int_x86_xop_vpcmov :
2018              GCCBuiltin<"__builtin_ia32_vpcmov">,
2019              Intrinsic<[llvm_v2i64_ty],
2020                        [llvm_v2i64_ty, llvm_v2i64_ty, llvm_v2i64_ty],
2021                        [IntrNoMem]>;
2022  def int_x86_xop_vpcmov_256 :
2023              GCCBuiltin<"__builtin_ia32_vpcmov_256">,
2024              Intrinsic<[llvm_v4i64_ty],
2025                        [llvm_v4i64_ty, llvm_v4i64_ty, llvm_v4i64_ty],
2026                        [IntrNoMem]>;
2027
2028  def int_x86_xop_vpcomb : GCCBuiltin<"__builtin_ia32_vpcomb">,
2029              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty,
2030                         llvm_i8_ty], [IntrNoMem]>;
2031  def int_x86_xop_vpcomw : GCCBuiltin<"__builtin_ia32_vpcomw">,
2032              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty,
2033                         llvm_i8_ty], [IntrNoMem]>;
2034  def int_x86_xop_vpcomd : GCCBuiltin<"__builtin_ia32_vpcomd">,
2035              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty,
2036                         llvm_i8_ty], [IntrNoMem]>;
2037  def int_x86_xop_vpcomq : GCCBuiltin<"__builtin_ia32_vpcomq">,
2038              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty,
2039                         llvm_i8_ty], [IntrNoMem]>;
2040  def int_x86_xop_vpcomub : GCCBuiltin<"__builtin_ia32_vpcomub">,
2041              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty,
2042                         llvm_i8_ty], [IntrNoMem]>;
2043  def int_x86_xop_vpcomuw : GCCBuiltin<"__builtin_ia32_vpcomuw">,
2044              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty,
2045                         llvm_i8_ty], [IntrNoMem]>;
2046  def int_x86_xop_vpcomud : GCCBuiltin<"__builtin_ia32_vpcomud">,
2047              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty,
2048                         llvm_i8_ty], [IntrNoMem]>;
2049  def int_x86_xop_vpcomuq : GCCBuiltin<"__builtin_ia32_vpcomuq">,
2050              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty,
2051                         llvm_i8_ty], [IntrNoMem]>;
2052
2053  def int_x86_xop_vphaddbd :
2054              GCCBuiltin<"__builtin_ia32_vphaddbd">,
2055              Intrinsic<[llvm_v4i32_ty], [llvm_v16i8_ty], [IntrNoMem]>;
2056  def int_x86_xop_vphaddbq :
2057              GCCBuiltin<"__builtin_ia32_vphaddbq">,
2058              Intrinsic<[llvm_v2i64_ty], [llvm_v16i8_ty], [IntrNoMem]>;
2059  def int_x86_xop_vphaddbw :
2060              GCCBuiltin<"__builtin_ia32_vphaddbw">,
2061              Intrinsic<[llvm_v8i16_ty], [llvm_v16i8_ty], [IntrNoMem]>;
2062  def int_x86_xop_vphadddq :
2063              GCCBuiltin<"__builtin_ia32_vphadddq">,
2064              Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty], [IntrNoMem]>;
2065  def int_x86_xop_vphaddubd :
2066              GCCBuiltin<"__builtin_ia32_vphaddubd">,
2067              Intrinsic<[llvm_v4i32_ty], [llvm_v16i8_ty], [IntrNoMem]>;
2068  def int_x86_xop_vphaddubq :
2069              GCCBuiltin<"__builtin_ia32_vphaddubq">,
2070              Intrinsic<[llvm_v2i64_ty], [llvm_v16i8_ty], [IntrNoMem]>;
2071  def int_x86_xop_vphaddubw :
2072              GCCBuiltin<"__builtin_ia32_vphaddubw">,
2073              Intrinsic<[llvm_v8i16_ty], [llvm_v16i8_ty], [IntrNoMem]>;
2074  def int_x86_xop_vphaddudq :
2075              GCCBuiltin<"__builtin_ia32_vphaddudq">,
2076              Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty], [IntrNoMem]>;
2077  def int_x86_xop_vphadduwd :
2078              GCCBuiltin<"__builtin_ia32_vphadduwd">,
2079              Intrinsic<[llvm_v4i32_ty], [llvm_v8i16_ty], [IntrNoMem]>;
2080  def int_x86_xop_vphadduwq :
2081              GCCBuiltin<"__builtin_ia32_vphadduwq">,
2082              Intrinsic<[llvm_v2i64_ty], [llvm_v8i16_ty], [IntrNoMem]>;
2083  def int_x86_xop_vphaddwd :
2084              GCCBuiltin<"__builtin_ia32_vphaddwd">,
2085              Intrinsic<[llvm_v4i32_ty], [llvm_v8i16_ty], [IntrNoMem]>;
2086  def int_x86_xop_vphaddwq :
2087              GCCBuiltin<"__builtin_ia32_vphaddwq">,
2088              Intrinsic<[llvm_v2i64_ty], [llvm_v8i16_ty], [IntrNoMem]>;
2089  def int_x86_xop_vphsubbw :
2090              GCCBuiltin<"__builtin_ia32_vphsubbw">,
2091              Intrinsic<[llvm_v8i16_ty], [llvm_v16i8_ty], [IntrNoMem]>;
2092  def int_x86_xop_vphsubdq :
2093              GCCBuiltin<"__builtin_ia32_vphsubdq">,
2094              Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty], [IntrNoMem]>;
2095  def int_x86_xop_vphsubwd :
2096              GCCBuiltin<"__builtin_ia32_vphsubwd">,
2097              Intrinsic<[llvm_v4i32_ty], [llvm_v8i16_ty], [IntrNoMem]>;
2098  def int_x86_xop_vpmacsdd :
2099              GCCBuiltin<"__builtin_ia32_vpmacsdd">,
2100              Intrinsic<[llvm_v4i32_ty],
2101                        [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty],
2102                        [IntrNoMem]>;
2103  def int_x86_xop_vpmacsdqh :
2104              GCCBuiltin<"__builtin_ia32_vpmacsdqh">,
2105              Intrinsic<[llvm_v2i64_ty],
2106                        [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v2i64_ty],
2107                        [IntrNoMem]>;
2108  def int_x86_xop_vpmacsdql :
2109              GCCBuiltin<"__builtin_ia32_vpmacsdql">,
2110              Intrinsic<[llvm_v2i64_ty],
2111                        [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v2i64_ty],
2112                        [IntrNoMem]>;
2113  def int_x86_xop_vpmacssdd :
2114              GCCBuiltin<"__builtin_ia32_vpmacssdd">,
2115              Intrinsic<[llvm_v4i32_ty],
2116                        [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty],
2117                        [IntrNoMem]>;
2118  def int_x86_xop_vpmacssdqh :
2119              GCCBuiltin<"__builtin_ia32_vpmacssdqh">,
2120              Intrinsic<[llvm_v2i64_ty],
2121                        [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v2i64_ty],
2122                        [IntrNoMem]>;
2123  def int_x86_xop_vpmacssdql :
2124              GCCBuiltin<"__builtin_ia32_vpmacssdql">,
2125              Intrinsic<[llvm_v2i64_ty],
2126                        [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v2i64_ty],
2127                        [IntrNoMem]>;
2128  def int_x86_xop_vpmacsswd :
2129              GCCBuiltin<"__builtin_ia32_vpmacsswd">,
2130              Intrinsic<[llvm_v4i32_ty],
2131                        [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v4i32_ty],
2132                        [IntrNoMem]>;
2133  def int_x86_xop_vpmacssww :
2134              GCCBuiltin<"__builtin_ia32_vpmacssww">,
2135              Intrinsic<[llvm_v8i16_ty],
2136                        [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty],
2137                        [IntrNoMem]>;
2138  def int_x86_xop_vpmacswd :
2139              GCCBuiltin<"__builtin_ia32_vpmacswd">,
2140              Intrinsic<[llvm_v4i32_ty],
2141                        [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v4i32_ty],
2142                        [IntrNoMem]>;
2143  def int_x86_xop_vpmacsww :
2144              GCCBuiltin<"__builtin_ia32_vpmacsww">,
2145              Intrinsic<[llvm_v8i16_ty],
2146                        [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty],
2147                        [IntrNoMem]>;
2148  def int_x86_xop_vpmadcsswd :
2149              GCCBuiltin<"__builtin_ia32_vpmadcsswd">,
2150              Intrinsic<[llvm_v4i32_ty],
2151                        [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v4i32_ty],
2152                        [IntrNoMem]>;
2153  def int_x86_xop_vpmadcswd :
2154              GCCBuiltin<"__builtin_ia32_vpmadcswd">,
2155              Intrinsic<[llvm_v4i32_ty],
2156                        [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v4i32_ty],
2157                        [IntrNoMem]>;
2158  def int_x86_xop_vpperm :
2159              GCCBuiltin<"__builtin_ia32_vpperm">,
2160              Intrinsic<[llvm_v16i8_ty],
2161                        [llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty],
2162                        [IntrNoMem]>;
2163
2164  def int_x86_xop_vprotb : GCCBuiltin<"__builtin_ia32_vprotb">,
2165              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty],
2166                        [IntrNoMem]>;
2167  def int_x86_xop_vprotd : GCCBuiltin<"__builtin_ia32_vprotd">,
2168              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
2169                        [IntrNoMem]>;
2170  def int_x86_xop_vprotq : GCCBuiltin<"__builtin_ia32_vprotq">,
2171              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
2172                        [IntrNoMem]>;
2173  def int_x86_xop_vprotw : GCCBuiltin<"__builtin_ia32_vprotw">,
2174              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty],
2175                        [IntrNoMem]>;
2176  def int_x86_xop_vprotbi : GCCBuiltin<"__builtin_ia32_vprotbi">,
2177              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i8_ty],
2178                        [IntrNoMem]>;
2179  def int_x86_xop_vprotdi : GCCBuiltin<"__builtin_ia32_vprotdi">,
2180              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i8_ty],
2181                        [IntrNoMem]>;
2182  def int_x86_xop_vprotqi : GCCBuiltin<"__builtin_ia32_vprotqi">,
2183              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i8_ty],
2184                        [IntrNoMem]>;
2185  def int_x86_xop_vprotwi : GCCBuiltin<"__builtin_ia32_vprotwi">,
2186              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i8_ty],
2187                        [IntrNoMem]>;
2188
2189  def int_x86_xop_vpshab :
2190              GCCBuiltin<"__builtin_ia32_vpshab">,
2191              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty],
2192                        [IntrNoMem]>;
2193  def int_x86_xop_vpshad :
2194              GCCBuiltin<"__builtin_ia32_vpshad">,
2195              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
2196                        [IntrNoMem]>;
2197  def int_x86_xop_vpshaq :
2198              GCCBuiltin<"__builtin_ia32_vpshaq">,
2199              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
2200                        [IntrNoMem]>;
2201  def int_x86_xop_vpshaw :
2202              GCCBuiltin<"__builtin_ia32_vpshaw">,
2203              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty],
2204                        [IntrNoMem]>;
2205  def int_x86_xop_vpshlb :
2206              GCCBuiltin<"__builtin_ia32_vpshlb">,
2207              Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty],
2208                        [IntrNoMem]>;
2209  def int_x86_xop_vpshld :
2210              GCCBuiltin<"__builtin_ia32_vpshld">,
2211              Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty],
2212                        [IntrNoMem]>;
2213  def int_x86_xop_vpshlq :
2214              GCCBuiltin<"__builtin_ia32_vpshlq">,
2215              Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty],
2216                        [IntrNoMem]>;
2217  def int_x86_xop_vpshlw :
2218              GCCBuiltin<"__builtin_ia32_vpshlw">,
2219              Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty],
2220                        [IntrNoMem]>;
2221
2222//===----------------------------------------------------------------------===//
2223// MMX
2224
2225// Empty MMX state op.
2226let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2227  def int_x86_mmx_emms  : GCCBuiltin<"__builtin_ia32_emms">,
2228              Intrinsic<[], [], []>;
2229  def int_x86_mmx_femms : GCCBuiltin<"__builtin_ia32_femms">,
2230              Intrinsic<[], [], []>;
2231}
2232
2233// Integer arithmetic ops.
2234let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2235  // Addition
2236  def int_x86_mmx_padd_b : GCCBuiltin<"__builtin_ia32_paddb">,
2237              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2238                        [IntrNoMem]>;
2239  def int_x86_mmx_padd_w : GCCBuiltin<"__builtin_ia32_paddw">,
2240              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2241                        [IntrNoMem]>;
2242  def int_x86_mmx_padd_d : GCCBuiltin<"__builtin_ia32_paddd">,
2243              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2244                        [IntrNoMem]>;
2245  def int_x86_mmx_padd_q : GCCBuiltin<"__builtin_ia32_paddq">,
2246              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2247                        [IntrNoMem]>;
2248
2249  def int_x86_mmx_padds_b : GCCBuiltin<"__builtin_ia32_paddsb">,
2250              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2251                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2252  def int_x86_mmx_padds_w : GCCBuiltin<"__builtin_ia32_paddsw">,
2253              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2254                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2255
2256  def int_x86_mmx_paddus_b : GCCBuiltin<"__builtin_ia32_paddusb">,
2257              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2258                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2259  def int_x86_mmx_paddus_w : GCCBuiltin<"__builtin_ia32_paddusw">,
2260              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2261                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2262
2263  // Subtraction
2264  def int_x86_mmx_psub_b : GCCBuiltin<"__builtin_ia32_psubb">,
2265              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2266                        [IntrNoMem]>;
2267  def int_x86_mmx_psub_w : GCCBuiltin<"__builtin_ia32_psubw">,
2268              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2269                        [IntrNoMem]>;
2270  def int_x86_mmx_psub_d : GCCBuiltin<"__builtin_ia32_psubd">,
2271              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2272                        [IntrNoMem]>;
2273  def int_x86_mmx_psub_q : GCCBuiltin<"__builtin_ia32_psubq">,
2274              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2275                        [IntrNoMem]>;
2276
2277  def int_x86_mmx_psubs_b : GCCBuiltin<"__builtin_ia32_psubsb">,
2278              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2279                         llvm_x86mmx_ty], [IntrNoMem]>;
2280  def int_x86_mmx_psubs_w : GCCBuiltin<"__builtin_ia32_psubsw">,
2281              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2282                         llvm_x86mmx_ty], [IntrNoMem]>;
2283
2284  def int_x86_mmx_psubus_b : GCCBuiltin<"__builtin_ia32_psubusb">,
2285              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2286                         llvm_x86mmx_ty], [IntrNoMem]>;
2287  def int_x86_mmx_psubus_w : GCCBuiltin<"__builtin_ia32_psubusw">,
2288              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2289                         llvm_x86mmx_ty], [IntrNoMem]>;
2290
2291  // Multiplication
2292  def int_x86_mmx_pmulh_w : GCCBuiltin<"__builtin_ia32_pmulhw">,
2293              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2294                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2295  def int_x86_mmx_pmull_w : GCCBuiltin<"__builtin_ia32_pmullw">,
2296              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2297                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2298  def int_x86_mmx_pmulhu_w : GCCBuiltin<"__builtin_ia32_pmulhuw">,
2299              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2300                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2301  def int_x86_mmx_pmulu_dq : GCCBuiltin<"__builtin_ia32_pmuludq">,
2302              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2303                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2304  def int_x86_mmx_pmadd_wd : GCCBuiltin<"__builtin_ia32_pmaddwd">,
2305              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2306                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2307
2308  // Bitwise operations
2309  def int_x86_mmx_pand : GCCBuiltin<"__builtin_ia32_pand">,
2310              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2311                        [IntrNoMem]>;
2312  def int_x86_mmx_pandn : GCCBuiltin<"__builtin_ia32_pandn">,
2313              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2314                        [IntrNoMem]>;
2315  def int_x86_mmx_por : GCCBuiltin<"__builtin_ia32_por">,
2316              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2317                        [IntrNoMem]>;
2318  def int_x86_mmx_pxor : GCCBuiltin<"__builtin_ia32_pxor">,
2319              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2320                        [IntrNoMem]>;
2321
2322  // Averages
2323  def int_x86_mmx_pavg_b : GCCBuiltin<"__builtin_ia32_pavgb">,
2324              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2325                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2326  def int_x86_mmx_pavg_w : GCCBuiltin<"__builtin_ia32_pavgw">,
2327              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2328                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2329
2330  // Maximum
2331  def int_x86_mmx_pmaxu_b : GCCBuiltin<"__builtin_ia32_pmaxub">,
2332              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2333                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2334  def int_x86_mmx_pmaxs_w : GCCBuiltin<"__builtin_ia32_pmaxsw">,
2335              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2336                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2337
2338  // Minimum
2339  def int_x86_mmx_pminu_b : GCCBuiltin<"__builtin_ia32_pminub">,
2340              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2341                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2342  def int_x86_mmx_pmins_w : GCCBuiltin<"__builtin_ia32_pminsw">,
2343              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2344                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2345
2346  // Packed sum of absolute differences
2347  def int_x86_mmx_psad_bw : GCCBuiltin<"__builtin_ia32_psadbw">,
2348              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2349                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2350}
2351
2352// Integer shift ops.
2353let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2354  // Shift left logical
2355  def int_x86_mmx_psll_w : GCCBuiltin<"__builtin_ia32_psllw">,
2356              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2357                         llvm_x86mmx_ty], [IntrNoMem]>;
2358  def int_x86_mmx_psll_d : GCCBuiltin<"__builtin_ia32_pslld">,
2359              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2360                         llvm_x86mmx_ty], [IntrNoMem]>;
2361  def int_x86_mmx_psll_q : GCCBuiltin<"__builtin_ia32_psllq">,
2362              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2363                         llvm_x86mmx_ty], [IntrNoMem]>;
2364
2365  def int_x86_mmx_psrl_w : GCCBuiltin<"__builtin_ia32_psrlw">,
2366              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2367                         llvm_x86mmx_ty], [IntrNoMem]>;
2368  def int_x86_mmx_psrl_d : GCCBuiltin<"__builtin_ia32_psrld">,
2369              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2370                         llvm_x86mmx_ty], [IntrNoMem]>;
2371  def int_x86_mmx_psrl_q : GCCBuiltin<"__builtin_ia32_psrlq">,
2372              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2373                         llvm_x86mmx_ty], [IntrNoMem]>;
2374
2375  def int_x86_mmx_psra_w : GCCBuiltin<"__builtin_ia32_psraw">,
2376              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2377                         llvm_x86mmx_ty], [IntrNoMem]>;
2378  def int_x86_mmx_psra_d : GCCBuiltin<"__builtin_ia32_psrad">,
2379              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2380                         llvm_x86mmx_ty], [IntrNoMem]>;
2381
2382  def int_x86_mmx_pslli_w : GCCBuiltin<"__builtin_ia32_psllwi">,
2383              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2384                         llvm_i32_ty], [IntrNoMem]>;
2385  def int_x86_mmx_pslli_d : GCCBuiltin<"__builtin_ia32_pslldi">,
2386              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2387                         llvm_i32_ty], [IntrNoMem]>;
2388  def int_x86_mmx_pslli_q : GCCBuiltin<"__builtin_ia32_psllqi">,
2389              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2390                         llvm_i32_ty], [IntrNoMem]>;
2391
2392  def int_x86_mmx_psrli_w : GCCBuiltin<"__builtin_ia32_psrlwi">,
2393              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2394                         llvm_i32_ty], [IntrNoMem]>;
2395  def int_x86_mmx_psrli_d : GCCBuiltin<"__builtin_ia32_psrldi">,
2396              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2397                         llvm_i32_ty], [IntrNoMem]>;
2398  def int_x86_mmx_psrli_q : GCCBuiltin<"__builtin_ia32_psrlqi">,
2399              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2400                         llvm_i32_ty], [IntrNoMem]>;
2401
2402  def int_x86_mmx_psrai_w : GCCBuiltin<"__builtin_ia32_psrawi">,
2403              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2404                         llvm_i32_ty], [IntrNoMem]>;
2405  def int_x86_mmx_psrai_d : GCCBuiltin<"__builtin_ia32_psradi">,
2406              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2407                         llvm_i32_ty], [IntrNoMem]>;
2408}
2409
2410// Pack ops.
2411let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2412  def int_x86_mmx_packsswb : GCCBuiltin<"__builtin_ia32_packsswb">,
2413              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2414                         llvm_x86mmx_ty], [IntrNoMem]>;
2415  def int_x86_mmx_packssdw : GCCBuiltin<"__builtin_ia32_packssdw">,
2416              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2417                         llvm_x86mmx_ty], [IntrNoMem]>;
2418  def int_x86_mmx_packuswb : GCCBuiltin<"__builtin_ia32_packuswb">,
2419              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2420                         llvm_x86mmx_ty], [IntrNoMem]>;
2421}
2422
2423// Unpacking ops.
2424let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2425  def int_x86_mmx_punpckhbw : GCCBuiltin<"__builtin_ia32_punpckhbw">,
2426              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2427                        [IntrNoMem]>;
2428  def int_x86_mmx_punpckhwd : GCCBuiltin<"__builtin_ia32_punpckhwd">,
2429              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2430                        [IntrNoMem]>;
2431  def int_x86_mmx_punpckhdq : GCCBuiltin<"__builtin_ia32_punpckhdq">,
2432              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2433                        [IntrNoMem]>;
2434  def int_x86_mmx_punpcklbw : GCCBuiltin<"__builtin_ia32_punpcklbw">,
2435              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2436                        [IntrNoMem]>;
2437  def int_x86_mmx_punpcklwd : GCCBuiltin<"__builtin_ia32_punpcklwd">,
2438              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2439                        [IntrNoMem]>;
2440  def int_x86_mmx_punpckldq : GCCBuiltin<"__builtin_ia32_punpckldq">,
2441              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty, llvm_x86mmx_ty],
2442                        [IntrNoMem]>;
2443}
2444
2445// Integer comparison ops
2446let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2447  def int_x86_mmx_pcmpeq_b : GCCBuiltin<"__builtin_ia32_pcmpeqb">,
2448              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2449                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2450  def int_x86_mmx_pcmpeq_w : GCCBuiltin<"__builtin_ia32_pcmpeqw">,
2451              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2452                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2453  def int_x86_mmx_pcmpeq_d : GCCBuiltin<"__builtin_ia32_pcmpeqd">,
2454              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2455                         llvm_x86mmx_ty], [IntrNoMem, Commutative]>;
2456
2457  def int_x86_mmx_pcmpgt_b : GCCBuiltin<"__builtin_ia32_pcmpgtb">,
2458              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2459                         llvm_x86mmx_ty], [IntrNoMem]>;
2460  def int_x86_mmx_pcmpgt_w : GCCBuiltin<"__builtin_ia32_pcmpgtw">,
2461              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2462                         llvm_x86mmx_ty], [IntrNoMem]>;
2463  def int_x86_mmx_pcmpgt_d : GCCBuiltin<"__builtin_ia32_pcmpgtd">,
2464              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2465                         llvm_x86mmx_ty], [IntrNoMem]>;
2466}
2467
2468// Misc.
2469let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2470  def int_x86_mmx_maskmovq : GCCBuiltin<"__builtin_ia32_maskmovq">,
2471              Intrinsic<[], [llvm_x86mmx_ty, llvm_x86mmx_ty, llvm_ptr_ty], []>;
2472
2473  def int_x86_mmx_pmovmskb : GCCBuiltin<"__builtin_ia32_pmovmskb">,
2474              Intrinsic<[llvm_i32_ty], [llvm_x86mmx_ty], [IntrNoMem]>;
2475
2476  def int_x86_mmx_movnt_dq : GCCBuiltin<"__builtin_ia32_movntq">,
2477              Intrinsic<[], [llvm_ptrx86mmx_ty, llvm_x86mmx_ty], []>;
2478
2479  def int_x86_mmx_palignr_b : GCCBuiltin<"__builtin_ia32_palignr">,
2480              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2481                        llvm_x86mmx_ty, llvm_i8_ty], [IntrNoMem]>;
2482
2483  def int_x86_mmx_pextr_w : GCCBuiltin<"__builtin_ia32_vec_ext_v4hi">,
2484              Intrinsic<[llvm_i32_ty], [llvm_x86mmx_ty, llvm_i32_ty],
2485                        [IntrNoMem]>;
2486
2487  def int_x86_mmx_pinsr_w : GCCBuiltin<"__builtin_ia32_vec_set_v4hi">,
2488              Intrinsic<[llvm_x86mmx_ty], [llvm_x86mmx_ty,
2489                        llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
2490}
2491
2492//===----------------------------------------------------------------------===//
2493// BMI
2494
2495let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2496  def int_x86_bmi_bextr_32 : GCCBuiltin<"__builtin_ia32_bextr_u32">,
2497              Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
2498  def int_x86_bmi_bextr_64 : GCCBuiltin<"__builtin_ia32_bextr_u64">,
2499              Intrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty], [IntrNoMem]>;
2500  def int_x86_bmi_bzhi_32 : GCCBuiltin<"__builtin_ia32_bzhi_si">,
2501              Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
2502  def int_x86_bmi_bzhi_64 : GCCBuiltin<"__builtin_ia32_bzhi_di">,
2503              Intrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty], [IntrNoMem]>;
2504  def int_x86_bmi_pdep_32 : GCCBuiltin<"__builtin_ia32_pdep_si">,
2505              Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
2506  def int_x86_bmi_pdep_64 : GCCBuiltin<"__builtin_ia32_pdep_di">,
2507              Intrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty], [IntrNoMem]>;
2508  def int_x86_bmi_pext_32 : GCCBuiltin<"__builtin_ia32_pext_si">,
2509              Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>;
2510  def int_x86_bmi_pext_64 : GCCBuiltin<"__builtin_ia32_pext_di">,
2511              Intrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty], [IntrNoMem]>;
2512}
2513
2514//===----------------------------------------------------------------------===//
2515// FS/GS Base
2516
2517let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2518  def int_x86_rdfsbase_32 : GCCBuiltin<"__builtin_ia32_rdfsbase32">,
2519              Intrinsic<[llvm_i32_ty], []>;
2520  def int_x86_rdgsbase_32 : GCCBuiltin<"__builtin_ia32_rdgsbase32">,
2521              Intrinsic<[llvm_i32_ty], []>;
2522  def int_x86_rdfsbase_64 : GCCBuiltin<"__builtin_ia32_rdfsbase64">,
2523              Intrinsic<[llvm_i64_ty], []>;
2524  def int_x86_rdgsbase_64 : GCCBuiltin<"__builtin_ia32_rdgsbase64">,
2525              Intrinsic<[llvm_i64_ty], []>;
2526  def int_x86_wrfsbase_32 : GCCBuiltin<"__builtin_ia32_wrfsbase32">,
2527              Intrinsic<[], [llvm_i32_ty]>;
2528  def int_x86_wrgsbase_32 : GCCBuiltin<"__builtin_ia32_wrgsbase32">,
2529              Intrinsic<[], [llvm_i32_ty]>;
2530  def int_x86_wrfsbase_64 : GCCBuiltin<"__builtin_ia32_wrfsbase64">,
2531              Intrinsic<[], [llvm_i64_ty]>;
2532  def int_x86_wrgsbase_64 : GCCBuiltin<"__builtin_ia32_wrgsbase64">,
2533              Intrinsic<[], [llvm_i64_ty]>;
2534}
2535
2536//===----------------------------------------------------------------------===//
2537// Half float conversion
2538
2539let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2540  def int_x86_vcvtph2ps_128 : GCCBuiltin<"__builtin_ia32_vcvtph2ps">,
2541              Intrinsic<[llvm_v4f32_ty], [llvm_v8i16_ty], [IntrNoMem]>;
2542  def int_x86_vcvtph2ps_256 : GCCBuiltin<"__builtin_ia32_vcvtph2ps256">,
2543              Intrinsic<[llvm_v8f32_ty], [llvm_v8i16_ty], [IntrNoMem]>;
2544  def int_x86_vcvtps2ph_128 : GCCBuiltin<"__builtin_ia32_vcvtps2ph">,
2545              Intrinsic<[llvm_v8i16_ty], [llvm_v4f32_ty, llvm_i32_ty],
2546                        [IntrNoMem]>;
2547  def int_x86_vcvtps2ph_256 : GCCBuiltin<"__builtin_ia32_vcvtps2ph256">,
2548              Intrinsic<[llvm_v8i16_ty], [llvm_v8f32_ty, llvm_i32_ty],
2549                        [IntrNoMem]>;
2550}
2551
2552//===----------------------------------------------------------------------===//
2553// RDRAND intrinsics - Return a random value and whether it is valid.
2554// RDSEED intrinsics - Return a NIST SP800-90B & C compliant random value and
2555// whether it is valid.
2556
2557let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2558  // These are declared side-effecting so they don't get eliminated by CSE or
2559  // LICM.
2560  def int_x86_rdrand_16 : Intrinsic<[llvm_i16_ty, llvm_i32_ty], [], []>;
2561  def int_x86_rdrand_32 : Intrinsic<[llvm_i32_ty, llvm_i32_ty], [], []>;
2562  def int_x86_rdrand_64 : Intrinsic<[llvm_i64_ty, llvm_i32_ty], [], []>;
2563  def int_x86_rdseed_16 : Intrinsic<[llvm_i16_ty, llvm_i32_ty], [], []>;
2564  def int_x86_rdseed_32 : Intrinsic<[llvm_i32_ty, llvm_i32_ty], [], []>;
2565  def int_x86_rdseed_64 : Intrinsic<[llvm_i64_ty, llvm_i32_ty], [], []>;
2566}
2567
2568//===----------------------------------------------------------------------===//
2569// RTM intrinsics. Transactional Memory support.
2570
2571let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2572  def int_x86_xbegin : GCCBuiltin<"__builtin_ia32_xbegin">,
2573              Intrinsic<[llvm_i32_ty], [], []>;
2574  def int_x86_xend : GCCBuiltin<"__builtin_ia32_xend">,
2575              Intrinsic<[], [], []>;
2576  def int_x86_xabort : GCCBuiltin<"__builtin_ia32_xabort">,
2577              Intrinsic<[], [llvm_i8_ty], [IntrNoReturn]>;
2578  def int_x86_xtest : GCCBuiltin<"__builtin_ia32_xtest">,
2579              Intrinsic<[llvm_i32_ty], [], []>;
2580}
2581// AVX-512
2582
2583let TargetPrefix = "x86" in {  // All intrinsics start with "llvm.x86.".
2584  // Mask instructions
2585  // 16-bit mask
2586  def int_x86_kadd_v16i1 : GCCBuiltin<"__builtin_ia32_kaddw">,
2587              Intrinsic<[llvm_v16i1_ty], [llvm_v16i1_ty, llvm_v16i1_ty],
2588                         [IntrNoMem]>;
2589  def int_x86_kand_v16i1 : GCCBuiltin<"__builtin_ia32_kandw">,
2590              Intrinsic<[llvm_v16i1_ty], [llvm_v16i1_ty, llvm_v16i1_ty],
2591                         [IntrNoMem]>;
2592  def int_x86_kandn_v16i1 : GCCBuiltin<"__builtin_ia32_kandnw">,
2593              Intrinsic<[llvm_v16i1_ty], [llvm_v16i1_ty, llvm_v16i1_ty],
2594                         [IntrNoMem]>;
2595  def int_x86_knot_v16i1 : GCCBuiltin<"__builtin_ia32_knotw">,
2596              Intrinsic<[llvm_v16i1_ty], [llvm_v16i1_ty], [IntrNoMem]>;
2597  def int_x86_kor_v16i1 : GCCBuiltin<"__builtin_ia32_korw">,
2598              Intrinsic<[llvm_v16i1_ty], [llvm_v16i1_ty, llvm_v16i1_ty],
2599                         [IntrNoMem]>;
2600  def int_x86_kxor_v16i1 : GCCBuiltin<"__builtin_ia32_kxorw">,
2601              Intrinsic<[llvm_v16i1_ty], [llvm_v16i1_ty, llvm_v16i1_ty],
2602                         [IntrNoMem]>;
2603  def int_x86_kxnor_v16i1 : GCCBuiltin<"__builtin_ia32_kxnorw">,
2604              Intrinsic<[llvm_v16i1_ty], [llvm_v16i1_ty, llvm_v16i1_ty],
2605                         [IntrNoMem]>;
2606  def int_x86_mask2int_v16i1 : GCCBuiltin<"__builtin_ia32_mask2intw">,
2607              Intrinsic<[llvm_i32_ty], [llvm_v16i1_ty], [IntrNoMem]>;
2608  def int_x86_int2mask_v16i1 : GCCBuiltin<"__builtin_ia32_int2maskw">,
2609              Intrinsic<[llvm_v16i1_ty], [llvm_i32_ty], [IntrNoMem]>;
2610  def int_x86_kunpck_v16i1 : GCCBuiltin<"__builtin_ia32_kunpckbw">,
2611              Intrinsic<[llvm_v16i1_ty], [llvm_v8i1_ty, llvm_v8i1_ty],
2612                         [IntrNoMem]>;
2613  def int_x86_avx512_kortestz : GCCBuiltin<"__builtin_ia32_kortestz">,
2614              Intrinsic<[llvm_i32_ty], [llvm_i16_ty, llvm_i16_ty],
2615                        [IntrNoMem]>;
2616  def int_x86_avx512_kortestc : GCCBuiltin<"__builtin_ia32_kortestc">,
2617              Intrinsic<[llvm_i32_ty], [llvm_i16_ty, llvm_i16_ty],
2618                        [IntrNoMem]>;
2619}
2620