• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//===-- PPCInstrAltivec.td - The PowerPC Altivec Extension -*- 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 describes the Altivec extension to the PowerPC instruction set.
11//
12//===----------------------------------------------------------------------===//
13
14//===----------------------------------------------------------------------===//
15// Altivec transformation functions and pattern fragments.
16//
17
18// Since we canonicalize buildvectors to v16i8, all vnots "-1" operands will be
19// of that type.
20def vnot_ppc : PatFrag<(ops node:$in),
21                       (xor node:$in, (bitconvert (v16i8 immAllOnesV)))>;
22
23def vpkuhum_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
24                              (vector_shuffle node:$lhs, node:$rhs), [{
25  return PPC::isVPKUHUMShuffleMask(cast<ShuffleVectorSDNode>(N), false);
26}]>;
27def vpkuwum_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
28                              (vector_shuffle node:$lhs, node:$rhs), [{
29  return PPC::isVPKUWUMShuffleMask(cast<ShuffleVectorSDNode>(N), false);
30}]>;
31def vpkuhum_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
32                                    (vector_shuffle node:$lhs, node:$rhs), [{
33  return PPC::isVPKUHUMShuffleMask(cast<ShuffleVectorSDNode>(N), true);
34}]>;
35def vpkuwum_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
36                                    (vector_shuffle node:$lhs, node:$rhs), [{
37  return PPC::isVPKUWUMShuffleMask(cast<ShuffleVectorSDNode>(N), true);
38}]>;
39
40
41def vmrglb_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
42                             (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
43  return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 1, false);
44}]>;
45def vmrglh_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
46                             (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
47  return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 2, false);
48}]>;
49def vmrglw_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
50                             (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
51  return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 4, false);
52}]>;
53def vmrghb_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
54                             (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
55  return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 1, false);
56}]>;
57def vmrghh_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
58                             (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
59  return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 2, false);
60}]>;
61def vmrghw_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
62                             (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
63  return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 4, false);
64}]>;
65
66
67def vmrglb_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
68                               (vector_shuffle (v16i8 node:$lhs), node:$rhs), [{
69  return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 1, true);
70}]>;
71def vmrglh_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
72                                   (vector_shuffle node:$lhs, node:$rhs), [{
73  return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 2, true);
74}]>;
75def vmrglw_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
76                                   (vector_shuffle node:$lhs, node:$rhs), [{
77  return PPC::isVMRGLShuffleMask(cast<ShuffleVectorSDNode>(N), 4, true);
78}]>;
79def vmrghb_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
80                                   (vector_shuffle node:$lhs, node:$rhs), [{
81  return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 1, true);
82}]>;
83def vmrghh_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
84                                   (vector_shuffle node:$lhs, node:$rhs), [{
85  return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 2, true);
86}]>;
87def vmrghw_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
88                                   (vector_shuffle node:$lhs, node:$rhs), [{
89  return PPC::isVMRGHShuffleMask(cast<ShuffleVectorSDNode>(N), 4, true);
90}]>;
91
92
93def VSLDOI_get_imm : SDNodeXForm<vector_shuffle, [{
94  return getI32Imm(PPC::isVSLDOIShuffleMask(N, false));
95}]>;
96def vsldoi_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
97                             (vector_shuffle node:$lhs, node:$rhs), [{
98  return PPC::isVSLDOIShuffleMask(N, false) != -1;
99}], VSLDOI_get_imm>;
100
101
102/// VSLDOI_unary* - These are used to match vsldoi(X,X), which is turned into
103/// vector_shuffle(X,undef,mask) by the dag combiner.
104def VSLDOI_unary_get_imm : SDNodeXForm<vector_shuffle, [{
105  return getI32Imm(PPC::isVSLDOIShuffleMask(N, true));
106}]>;
107def vsldoi_unary_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
108                                   (vector_shuffle node:$lhs, node:$rhs), [{
109  return PPC::isVSLDOIShuffleMask(N, true) != -1;
110}], VSLDOI_unary_get_imm>;
111
112
113// VSPLT*_get_imm xform function: convert vector_shuffle mask to VSPLT* imm.
114def VSPLTB_get_imm : SDNodeXForm<vector_shuffle, [{
115  return getI32Imm(PPC::getVSPLTImmediate(N, 1));
116}]>;
117def vspltb_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
118                             (vector_shuffle node:$lhs, node:$rhs), [{
119  return PPC::isSplatShuffleMask(cast<ShuffleVectorSDNode>(N), 1);
120}], VSPLTB_get_imm>;
121def VSPLTH_get_imm : SDNodeXForm<vector_shuffle, [{
122  return getI32Imm(PPC::getVSPLTImmediate(N, 2));
123}]>;
124def vsplth_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
125                             (vector_shuffle node:$lhs, node:$rhs), [{
126  return PPC::isSplatShuffleMask(cast<ShuffleVectorSDNode>(N), 2);
127}], VSPLTH_get_imm>;
128def VSPLTW_get_imm : SDNodeXForm<vector_shuffle, [{
129  return getI32Imm(PPC::getVSPLTImmediate(N, 4));
130}]>;
131def vspltw_shuffle : PatFrag<(ops node:$lhs, node:$rhs),
132                             (vector_shuffle node:$lhs, node:$rhs), [{
133  return PPC::isSplatShuffleMask(cast<ShuffleVectorSDNode>(N), 4);
134}], VSPLTW_get_imm>;
135
136
137// VSPLTISB_get_imm xform function: convert build_vector to VSPLTISB imm.
138def VSPLTISB_get_imm : SDNodeXForm<build_vector, [{
139  return PPC::get_VSPLTI_elt(N, 1, *CurDAG);
140}]>;
141def vecspltisb : PatLeaf<(build_vector), [{
142  return PPC::get_VSPLTI_elt(N, 1, *CurDAG).getNode() != 0;
143}], VSPLTISB_get_imm>;
144
145// VSPLTISH_get_imm xform function: convert build_vector to VSPLTISH imm.
146def VSPLTISH_get_imm : SDNodeXForm<build_vector, [{
147  return PPC::get_VSPLTI_elt(N, 2, *CurDAG);
148}]>;
149def vecspltish : PatLeaf<(build_vector), [{
150  return PPC::get_VSPLTI_elt(N, 2, *CurDAG).getNode() != 0;
151}], VSPLTISH_get_imm>;
152
153// VSPLTISW_get_imm xform function: convert build_vector to VSPLTISW imm.
154def VSPLTISW_get_imm : SDNodeXForm<build_vector, [{
155  return PPC::get_VSPLTI_elt(N, 4, *CurDAG);
156}]>;
157def vecspltisw : PatLeaf<(build_vector), [{
158  return PPC::get_VSPLTI_elt(N, 4, *CurDAG).getNode() != 0;
159}], VSPLTISW_get_imm>;
160
161//===----------------------------------------------------------------------===//
162// Helpers for defining instructions that directly correspond to intrinsics.
163
164// VA1a_Int_Ty - A VAForm_1a intrinsic definition of specific type.
165class VA1a_Int_Ty<bits<6> xo, string opc, Intrinsic IntID, ValueType Ty>
166  : VAForm_1a<xo, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB, vrrc:$vC),
167              !strconcat(opc, " $vD, $vA, $vB, $vC"), VecFP,
168                       [(set Ty:$vD, (IntID Ty:$vA, Ty:$vB, Ty:$vC))]>;
169
170// VA1a_Int_Ty2 - A VAForm_1a intrinsic definition where the type of the
171// inputs doesn't match the type of the output.
172class VA1a_Int_Ty2<bits<6> xo, string opc, Intrinsic IntID, ValueType OutTy,
173                   ValueType InTy>
174  : VAForm_1a<xo, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB, vrrc:$vC),
175              !strconcat(opc, " $vD, $vA, $vB, $vC"), VecFP,
176                       [(set OutTy:$vD, (IntID InTy:$vA, InTy:$vB, InTy:$vC))]>;
177
178// VA1a_Int_Ty3 - A VAForm_1a intrinsic definition where there are two
179// input types and an output type.
180class VA1a_Int_Ty3<bits<6> xo, string opc, Intrinsic IntID, ValueType OutTy,
181                   ValueType In1Ty, ValueType In2Ty>
182  : VAForm_1a<xo, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB, vrrc:$vC),
183              !strconcat(opc, " $vD, $vA, $vB, $vC"), VecFP,
184                       [(set OutTy:$vD,
185                         (IntID In1Ty:$vA, In1Ty:$vB, In2Ty:$vC))]>;
186
187// VX1_Int_Ty - A VXForm_1 intrinsic definition of specific type.
188class VX1_Int_Ty<bits<11> xo, string opc, Intrinsic IntID, ValueType Ty>
189  : VXForm_1<xo, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
190             !strconcat(opc, " $vD, $vA, $vB"), VecFP,
191             [(set Ty:$vD, (IntID Ty:$vA, Ty:$vB))]>;
192
193// VX1_Int_Ty2 - A VXForm_1 intrinsic definition where the type of the
194// inputs doesn't match the type of the output.
195class VX1_Int_Ty2<bits<11> xo, string opc, Intrinsic IntID, ValueType OutTy,
196                  ValueType InTy>
197  : VXForm_1<xo, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
198             !strconcat(opc, " $vD, $vA, $vB"), VecFP,
199             [(set OutTy:$vD, (IntID InTy:$vA, InTy:$vB))]>;
200
201// VX1_Int_Ty3 - A VXForm_1 intrinsic definition where there are two
202// input types and an output type.
203class VX1_Int_Ty3<bits<11> xo, string opc, Intrinsic IntID, ValueType OutTy,
204                  ValueType In1Ty, ValueType In2Ty>
205  : VXForm_1<xo, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
206             !strconcat(opc, " $vD, $vA, $vB"), VecFP,
207             [(set OutTy:$vD, (IntID In1Ty:$vA, In2Ty:$vB))]>;
208
209// VX2_Int_SP - A VXForm_2 intrinsic definition of vector single-precision type.
210class VX2_Int_SP<bits<11> xo, string opc, Intrinsic IntID>
211  : VXForm_2<xo, (outs vrrc:$vD), (ins vrrc:$vB),
212             !strconcat(opc, " $vD, $vB"), VecFP,
213             [(set v4f32:$vD, (IntID v4f32:$vB))]>;
214
215// VX2_Int_Ty2 - A VXForm_2 intrinsic definition where the type of the
216// inputs doesn't match the type of the output.
217class VX2_Int_Ty2<bits<11> xo, string opc, Intrinsic IntID, ValueType OutTy,
218                  ValueType InTy>
219  : VXForm_2<xo, (outs vrrc:$vD), (ins vrrc:$vB),
220             !strconcat(opc, " $vD, $vB"), VecFP,
221             [(set OutTy:$vD, (IntID InTy:$vB))]>;
222
223//===----------------------------------------------------------------------===//
224// Instruction Definitions.
225
226def HasAltivec : Predicate<"PPCSubTarget.hasAltivec()">;
227let Predicates = [HasAltivec] in {
228
229let isCodeGenOnly = 1 in {
230def DSS      : DSS_Form<822, (outs),
231                        (ins u5imm:$ZERO0, u5imm:$STRM,u5imm:$ZERO1,u5imm:$ZERO2),
232                        "dss $STRM", LdStLoad /*FIXME*/, []>;
233def DSSALL   : DSS_Form<822, (outs),
234                        (ins u5imm:$ONE, u5imm:$ZERO0,u5imm:$ZERO1,u5imm:$ZERO2),
235                        "dssall", LdStLoad /*FIXME*/, []>;
236def DST      : DSS_Form<342, (outs),
237                        (ins u5imm:$ZERO, u5imm:$STRM, gprc:$rA, gprc:$rB),
238                        "dst $rA, $rB, $STRM", LdStLoad /*FIXME*/, []>;
239def DSTT     : DSS_Form<342, (outs),
240                        (ins u5imm:$ONE, u5imm:$STRM, gprc:$rA, gprc:$rB),
241                        "dstt $rA, $rB, $STRM", LdStLoad /*FIXME*/, []>;
242def DSTST    : DSS_Form<374, (outs),
243                        (ins u5imm:$ZERO, u5imm:$STRM, gprc:$rA, gprc:$rB),
244                        "dstst $rA, $rB, $STRM", LdStLoad /*FIXME*/, []>;
245def DSTSTT   : DSS_Form<374, (outs),
246                        (ins u5imm:$ONE, u5imm:$STRM, gprc:$rA, gprc:$rB),
247                        "dststt $rA, $rB, $STRM", LdStLoad /*FIXME*/, []>;
248
249def DST64    : DSS_Form<342, (outs),
250                        (ins u5imm:$ZERO, u5imm:$STRM, g8rc:$rA, gprc:$rB),
251                        "dst $rA, $rB, $STRM", LdStLoad /*FIXME*/, []>;
252def DSTT64   : DSS_Form<342, (outs),
253                        (ins u5imm:$ONE, u5imm:$STRM, g8rc:$rA, gprc:$rB),
254                        "dstt $rA, $rB, $STRM", LdStLoad /*FIXME*/, []>;
255def DSTST64  : DSS_Form<374, (outs),
256                        (ins u5imm:$ZERO, u5imm:$STRM, g8rc:$rA, gprc:$rB),
257                        "dstst $rA, $rB, $STRM", LdStLoad /*FIXME*/, []>;
258def DSTSTT64 : DSS_Form<374, (outs),
259                        (ins u5imm:$ONE, u5imm:$STRM, g8rc:$rA, gprc:$rB),
260                        "dststt $rA, $rB, $STRM", LdStLoad /*FIXME*/, []>;
261}
262
263def MFVSCR : VXForm_4<1540, (outs vrrc:$vD), (ins),
264                      "mfvscr $vD", LdStStore,
265                      [(set v8i16:$vD, (int_ppc_altivec_mfvscr))]>;
266def MTVSCR : VXForm_5<1604, (outs), (ins vrrc:$vB),
267                      "mtvscr $vB", LdStLoad,
268                      [(int_ppc_altivec_mtvscr v4i32:$vB)]>;
269
270let canFoldAsLoad = 1, PPC970_Unit = 2 in {  // Loads.
271def LVEBX: XForm_1<31,   7, (outs vrrc:$vD), (ins memrr:$src),
272                   "lvebx $vD, $src", LdStLoad,
273                   [(set v16i8:$vD, (int_ppc_altivec_lvebx xoaddr:$src))]>;
274def LVEHX: XForm_1<31,  39, (outs vrrc:$vD), (ins memrr:$src),
275                   "lvehx $vD, $src", LdStLoad,
276                   [(set v8i16:$vD, (int_ppc_altivec_lvehx xoaddr:$src))]>;
277def LVEWX: XForm_1<31,  71, (outs vrrc:$vD), (ins memrr:$src),
278                   "lvewx $vD, $src", LdStLoad,
279                   [(set v4i32:$vD, (int_ppc_altivec_lvewx xoaddr:$src))]>;
280def LVX  : XForm_1<31, 103, (outs vrrc:$vD), (ins memrr:$src),
281                   "lvx $vD, $src", LdStLoad,
282                   [(set v4i32:$vD, (int_ppc_altivec_lvx xoaddr:$src))]>;
283def LVXL : XForm_1<31, 359, (outs vrrc:$vD), (ins memrr:$src),
284                   "lvxl $vD, $src", LdStLoad,
285                   [(set v4i32:$vD, (int_ppc_altivec_lvxl xoaddr:$src))]>;
286}
287
288def LVSL : XForm_1<31,   6, (outs vrrc:$vD), (ins memrr:$src),
289                   "lvsl $vD, $src", LdStLoad,
290                   [(set v16i8:$vD, (int_ppc_altivec_lvsl xoaddr:$src))]>,
291                   PPC970_Unit_LSU;
292def LVSR : XForm_1<31,  38, (outs vrrc:$vD), (ins memrr:$src),
293                   "lvsr $vD, $src", LdStLoad,
294                   [(set v16i8:$vD, (int_ppc_altivec_lvsr xoaddr:$src))]>,
295                   PPC970_Unit_LSU;
296
297let PPC970_Unit = 2 in {   // Stores.
298def STVEBX: XForm_8<31, 135, (outs), (ins vrrc:$rS, memrr:$dst),
299                   "stvebx $rS, $dst", LdStStore,
300                   [(int_ppc_altivec_stvebx v16i8:$rS, xoaddr:$dst)]>;
301def STVEHX: XForm_8<31, 167, (outs), (ins vrrc:$rS, memrr:$dst),
302                   "stvehx $rS, $dst", LdStStore,
303                   [(int_ppc_altivec_stvehx v8i16:$rS, xoaddr:$dst)]>;
304def STVEWX: XForm_8<31, 199, (outs), (ins vrrc:$rS, memrr:$dst),
305                   "stvewx $rS, $dst", LdStStore,
306                   [(int_ppc_altivec_stvewx v4i32:$rS, xoaddr:$dst)]>;
307def STVX  : XForm_8<31, 231, (outs), (ins vrrc:$rS, memrr:$dst),
308                   "stvx $rS, $dst", LdStStore,
309                   [(int_ppc_altivec_stvx v4i32:$rS, xoaddr:$dst)]>;
310def STVXL : XForm_8<31, 487, (outs), (ins vrrc:$rS, memrr:$dst),
311                   "stvxl $rS, $dst", LdStStore,
312                   [(int_ppc_altivec_stvxl v4i32:$rS, xoaddr:$dst)]>;
313}
314
315let PPC970_Unit = 5 in {  // VALU Operations.
316// VA-Form instructions.  3-input AltiVec ops.
317def VMADDFP : VAForm_1<46, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vC, vrrc:$vB),
318                       "vmaddfp $vD, $vA, $vC, $vB", VecFP,
319                       [(set v4f32:$vD,
320                        (fma v4f32:$vA, v4f32:$vC, v4f32:$vB))]>;
321
322// FIXME: The fma+fneg pattern won't match because fneg is not legal.
323def VNMSUBFP: VAForm_1<47, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vC, vrrc:$vB),
324                       "vnmsubfp $vD, $vA, $vC, $vB", VecFP,
325                       [(set v4f32:$vD, (fneg (fma v4f32:$vA, v4f32:$vC,
326                                                  (fneg v4f32:$vB))))]>;
327
328def VMHADDSHS  : VA1a_Int_Ty<32, "vmhaddshs", int_ppc_altivec_vmhaddshs, v8i16>;
329def VMHRADDSHS : VA1a_Int_Ty<33, "vmhraddshs", int_ppc_altivec_vmhraddshs,
330                             v8i16>;
331def VMLADDUHM  : VA1a_Int_Ty<34, "vmladduhm", int_ppc_altivec_vmladduhm, v8i16>;
332
333def VPERM      : VA1a_Int_Ty3<43, "vperm", int_ppc_altivec_vperm,
334                              v4i32, v4i32, v16i8>;
335def VSEL       : VA1a_Int_Ty<42, "vsel",  int_ppc_altivec_vsel, v4i32>;
336
337// Shuffles.
338def VSLDOI  : VAForm_2<44, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB, u5imm:$SH),
339                       "vsldoi $vD, $vA, $vB, $SH", VecFP,
340                       [(set v16i8:$vD,
341                         (vsldoi_shuffle:$SH v16i8:$vA, v16i8:$vB))]>;
342
343// VX-Form instructions.  AltiVec arithmetic ops.
344def VADDFP : VXForm_1<10, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
345                      "vaddfp $vD, $vA, $vB", VecFP,
346                      [(set v4f32:$vD, (fadd v4f32:$vA, v4f32:$vB))]>;
347
348def VADDUBM : VXForm_1<0, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
349                      "vaddubm $vD, $vA, $vB", VecGeneral,
350                      [(set v16i8:$vD, (add v16i8:$vA, v16i8:$vB))]>;
351def VADDUHM : VXForm_1<64, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
352                      "vadduhm $vD, $vA, $vB", VecGeneral,
353                      [(set v8i16:$vD, (add v8i16:$vA, v8i16:$vB))]>;
354def VADDUWM : VXForm_1<128, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
355                      "vadduwm $vD, $vA, $vB", VecGeneral,
356                      [(set v4i32:$vD, (add v4i32:$vA, v4i32:$vB))]>;
357
358def VADDCUW : VX1_Int_Ty<384, "vaddcuw", int_ppc_altivec_vaddcuw, v4i32>;
359def VADDSBS : VX1_Int_Ty<768, "vaddsbs", int_ppc_altivec_vaddsbs, v16i8>;
360def VADDSHS : VX1_Int_Ty<832, "vaddshs", int_ppc_altivec_vaddshs, v8i16>;
361def VADDSWS : VX1_Int_Ty<896, "vaddsws", int_ppc_altivec_vaddsws, v4i32>;
362def VADDUBS : VX1_Int_Ty<512, "vaddubs", int_ppc_altivec_vaddubs, v16i8>;
363def VADDUHS : VX1_Int_Ty<576, "vadduhs", int_ppc_altivec_vadduhs, v8i16>;
364def VADDUWS : VX1_Int_Ty<640, "vadduws", int_ppc_altivec_vadduws, v4i32>;
365
366
367def VAND : VXForm_1<1028, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
368                    "vand $vD, $vA, $vB", VecFP,
369                    [(set v4i32:$vD, (and v4i32:$vA, v4i32:$vB))]>;
370def VANDC : VXForm_1<1092, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
371                     "vandc $vD, $vA, $vB", VecFP,
372                     [(set v4i32:$vD, (and v4i32:$vA,
373                                           (vnot_ppc v4i32:$vB)))]>;
374
375def VCFSX  : VXForm_1<842, (outs vrrc:$vD), (ins u5imm:$UIMM, vrrc:$vB),
376                      "vcfsx $vD, $vB, $UIMM", VecFP,
377                      [(set v4f32:$vD,
378                             (int_ppc_altivec_vcfsx v4i32:$vB, imm:$UIMM))]>;
379def VCFUX  : VXForm_1<778, (outs vrrc:$vD), (ins u5imm:$UIMM, vrrc:$vB),
380                      "vcfux $vD, $vB, $UIMM", VecFP,
381                      [(set v4f32:$vD,
382                             (int_ppc_altivec_vcfux v4i32:$vB, imm:$UIMM))]>;
383def VCTSXS : VXForm_1<970, (outs vrrc:$vD), (ins u5imm:$UIMM, vrrc:$vB),
384                      "vctsxs $vD, $vB, $UIMM", VecFP,
385                      [(set v4i32:$vD,
386                             (int_ppc_altivec_vctsxs v4f32:$vB, imm:$UIMM))]>;
387def VCTUXS : VXForm_1<906, (outs vrrc:$vD), (ins u5imm:$UIMM, vrrc:$vB),
388                      "vctuxs $vD, $vB, $UIMM", VecFP,
389                      [(set v4i32:$vD,
390                             (int_ppc_altivec_vctuxs v4f32:$vB, imm:$UIMM))]>;
391
392// Defines with the UIM field set to 0 for floating-point
393// to integer (fp_to_sint/fp_to_uint) conversions and integer
394// to floating-point (sint_to_fp/uint_to_fp) conversions.
395let isCodeGenOnly = 1, VA = 0 in {
396def VCFSX_0 : VXForm_1<842, (outs vrrc:$vD), (ins vrrc:$vB),
397                       "vcfsx $vD, $vB, 0", VecFP,
398                       [(set v4f32:$vD,
399                             (int_ppc_altivec_vcfsx v4i32:$vB, 0))]>;
400def VCTUXS_0 : VXForm_1<906, (outs vrrc:$vD), (ins vrrc:$vB),
401                        "vctuxs $vD, $vB, 0", VecFP,
402                        [(set v4i32:$vD,
403                               (int_ppc_altivec_vctuxs v4f32:$vB, 0))]>;
404def VCFUX_0 : VXForm_1<778, (outs vrrc:$vD), (ins vrrc:$vB),
405                       "vcfux $vD, $vB, 0", VecFP,
406                       [(set v4f32:$vD,
407                               (int_ppc_altivec_vcfux v4i32:$vB, 0))]>;
408def VCTSXS_0 : VXForm_1<970, (outs vrrc:$vD), (ins vrrc:$vB),
409                      "vctsxs $vD, $vB, 0", VecFP,
410                      [(set v4i32:$vD,
411                             (int_ppc_altivec_vctsxs v4f32:$vB, 0))]>;
412}
413def VEXPTEFP : VX2_Int_SP<394, "vexptefp", int_ppc_altivec_vexptefp>;
414def VLOGEFP  : VX2_Int_SP<458, "vlogefp",  int_ppc_altivec_vlogefp>;
415
416def VAVGSB : VX1_Int_Ty<1282, "vavgsb", int_ppc_altivec_vavgsb, v16i8>;
417def VAVGSH : VX1_Int_Ty<1346, "vavgsh", int_ppc_altivec_vavgsh, v8i16>;
418def VAVGSW : VX1_Int_Ty<1410, "vavgsw", int_ppc_altivec_vavgsw, v4i32>;
419def VAVGUB : VX1_Int_Ty<1026, "vavgub", int_ppc_altivec_vavgub, v16i8>;
420def VAVGUH : VX1_Int_Ty<1090, "vavguh", int_ppc_altivec_vavguh, v8i16>;
421def VAVGUW : VX1_Int_Ty<1154, "vavguw", int_ppc_altivec_vavguw, v4i32>;
422
423def VMAXFP : VX1_Int_Ty<1034, "vmaxfp", int_ppc_altivec_vmaxfp, v4f32>;
424def VMAXSB : VX1_Int_Ty< 258, "vmaxsb", int_ppc_altivec_vmaxsb, v16i8>;
425def VMAXSH : VX1_Int_Ty< 322, "vmaxsh", int_ppc_altivec_vmaxsh, v8i16>;
426def VMAXSW : VX1_Int_Ty< 386, "vmaxsw", int_ppc_altivec_vmaxsw, v4i32>;
427def VMAXUB : VX1_Int_Ty<   2, "vmaxub", int_ppc_altivec_vmaxub, v16i8>;
428def VMAXUH : VX1_Int_Ty<  66, "vmaxuh", int_ppc_altivec_vmaxuh, v8i16>;
429def VMAXUW : VX1_Int_Ty< 130, "vmaxuw", int_ppc_altivec_vmaxuw, v4i32>;
430def VMINFP : VX1_Int_Ty<1098, "vminfp", int_ppc_altivec_vminfp, v4f32>;
431def VMINSB : VX1_Int_Ty< 770, "vminsb", int_ppc_altivec_vminsb, v16i8>;
432def VMINSH : VX1_Int_Ty< 834, "vminsh", int_ppc_altivec_vminsh, v8i16>;
433def VMINSW : VX1_Int_Ty< 898, "vminsw", int_ppc_altivec_vminsw, v4i32>;
434def VMINUB : VX1_Int_Ty< 514, "vminub", int_ppc_altivec_vminub, v16i8>;
435def VMINUH : VX1_Int_Ty< 578, "vminuh", int_ppc_altivec_vminuh, v8i16>;
436def VMINUW : VX1_Int_Ty< 642, "vminuw", int_ppc_altivec_vminuw, v4i32>;
437
438def VMRGHB : VXForm_1< 12, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
439                      "vmrghb $vD, $vA, $vB", VecFP,
440                      [(set v16i8:$vD, (vmrghb_shuffle v16i8:$vA, v16i8:$vB))]>;
441def VMRGHH : VXForm_1< 76, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
442                      "vmrghh $vD, $vA, $vB", VecFP,
443                      [(set v16i8:$vD, (vmrghh_shuffle v16i8:$vA, v16i8:$vB))]>;
444def VMRGHW : VXForm_1<140, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
445                      "vmrghw $vD, $vA, $vB", VecFP,
446                      [(set v16i8:$vD, (vmrghw_shuffle v16i8:$vA, v16i8:$vB))]>;
447def VMRGLB : VXForm_1<268, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
448                      "vmrglb $vD, $vA, $vB", VecFP,
449                      [(set v16i8:$vD, (vmrglb_shuffle v16i8:$vA, v16i8:$vB))]>;
450def VMRGLH : VXForm_1<332, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
451                      "vmrglh $vD, $vA, $vB", VecFP,
452                      [(set v16i8:$vD, (vmrglh_shuffle v16i8:$vA, v16i8:$vB))]>;
453def VMRGLW : VXForm_1<396, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
454                      "vmrglw $vD, $vA, $vB", VecFP,
455                      [(set v16i8:$vD, (vmrglw_shuffle v16i8:$vA, v16i8:$vB))]>;
456
457def VMSUMMBM : VA1a_Int_Ty3<37, "vmsummbm", int_ppc_altivec_vmsummbm,
458                            v4i32, v16i8, v4i32>;
459def VMSUMSHM : VA1a_Int_Ty3<40, "vmsumshm", int_ppc_altivec_vmsumshm,
460                            v4i32, v8i16, v4i32>;
461def VMSUMSHS : VA1a_Int_Ty3<41, "vmsumshs", int_ppc_altivec_vmsumshs,
462                            v4i32, v8i16, v4i32>;
463def VMSUMUBM : VA1a_Int_Ty3<36, "vmsumubm", int_ppc_altivec_vmsumubm,
464                            v4i32, v16i8, v4i32>;
465def VMSUMUHM : VA1a_Int_Ty3<38, "vmsumuhm", int_ppc_altivec_vmsumuhm,
466                            v4i32, v8i16, v4i32>;
467def VMSUMUHS : VA1a_Int_Ty3<39, "vmsumuhs", int_ppc_altivec_vmsumuhs,
468                            v4i32, v8i16, v4i32>;
469
470def VMULESB : VX1_Int_Ty2<776, "vmulesb", int_ppc_altivec_vmulesb,
471                          v8i16, v16i8>;
472def VMULESH : VX1_Int_Ty2<840, "vmulesh", int_ppc_altivec_vmulesh,
473                          v4i32, v8i16>;
474def VMULEUB : VX1_Int_Ty2<520, "vmuleub", int_ppc_altivec_vmuleub,
475                          v8i16, v16i8>;
476def VMULEUH : VX1_Int_Ty2<584, "vmuleuh", int_ppc_altivec_vmuleuh,
477                          v4i32, v8i16>;
478def VMULOSB : VX1_Int_Ty2<264, "vmulosb", int_ppc_altivec_vmulosb,
479                          v8i16, v16i8>;
480def VMULOSH : VX1_Int_Ty2<328, "vmulosh", int_ppc_altivec_vmulosh,
481                          v4i32, v8i16>;
482def VMULOUB : VX1_Int_Ty2<  8, "vmuloub", int_ppc_altivec_vmuloub,
483                          v8i16, v16i8>;
484def VMULOUH : VX1_Int_Ty2< 72, "vmulouh", int_ppc_altivec_vmulouh,
485                          v4i32, v8i16>;
486
487def VREFP     : VX2_Int_SP<266, "vrefp",     int_ppc_altivec_vrefp>;
488def VRFIM     : VX2_Int_SP<714, "vrfim",     int_ppc_altivec_vrfim>;
489def VRFIN     : VX2_Int_SP<522, "vrfin",     int_ppc_altivec_vrfin>;
490def VRFIP     : VX2_Int_SP<650, "vrfip",     int_ppc_altivec_vrfip>;
491def VRFIZ     : VX2_Int_SP<586, "vrfiz",     int_ppc_altivec_vrfiz>;
492def VRSQRTEFP : VX2_Int_SP<330, "vrsqrtefp", int_ppc_altivec_vrsqrtefp>;
493
494def VSUBCUW : VX1_Int_Ty<1408, "vsubcuw", int_ppc_altivec_vsubcuw, v4i32>;
495
496def VSUBFP  : VXForm_1<74, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
497                      "vsubfp $vD, $vA, $vB", VecGeneral,
498                      [(set v4f32:$vD, (fsub v4f32:$vA, v4f32:$vB))]>;
499def VSUBUBM : VXForm_1<1024, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
500                      "vsububm $vD, $vA, $vB", VecGeneral,
501                      [(set v16i8:$vD, (sub v16i8:$vA, v16i8:$vB))]>;
502def VSUBUHM : VXForm_1<1088, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
503                      "vsubuhm $vD, $vA, $vB", VecGeneral,
504                      [(set v8i16:$vD, (sub v8i16:$vA, v8i16:$vB))]>;
505def VSUBUWM : VXForm_1<1152, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
506                      "vsubuwm $vD, $vA, $vB", VecGeneral,
507                      [(set v4i32:$vD, (sub v4i32:$vA, v4i32:$vB))]>;
508
509def VSUBSBS : VX1_Int_Ty<1792, "vsubsbs" , int_ppc_altivec_vsubsbs, v16i8>;
510def VSUBSHS : VX1_Int_Ty<1856, "vsubshs" , int_ppc_altivec_vsubshs, v8i16>;
511def VSUBSWS : VX1_Int_Ty<1920, "vsubsws" , int_ppc_altivec_vsubsws, v4i32>;
512def VSUBUBS : VX1_Int_Ty<1536, "vsububs" , int_ppc_altivec_vsububs, v16i8>;
513def VSUBUHS : VX1_Int_Ty<1600, "vsubuhs" , int_ppc_altivec_vsubuhs, v8i16>;
514def VSUBUWS : VX1_Int_Ty<1664, "vsubuws" , int_ppc_altivec_vsubuws, v4i32>;
515
516def VSUMSWS : VX1_Int_Ty<1928, "vsumsws" , int_ppc_altivec_vsumsws, v4i32>;
517def VSUM2SWS: VX1_Int_Ty<1672, "vsum2sws", int_ppc_altivec_vsum2sws, v4i32>;
518
519def VSUM4SBS: VX1_Int_Ty3<1800, "vsum4sbs", int_ppc_altivec_vsum4sbs,
520                          v4i32, v16i8, v4i32>;
521def VSUM4SHS: VX1_Int_Ty3<1608, "vsum4shs", int_ppc_altivec_vsum4shs,
522                          v4i32, v8i16, v4i32>;
523def VSUM4UBS: VX1_Int_Ty3<1544, "vsum4ubs", int_ppc_altivec_vsum4ubs,
524                          v4i32, v16i8, v4i32>;
525
526def VNOR : VXForm_1<1284, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
527                    "vnor $vD, $vA, $vB", VecFP,
528                    [(set v4i32:$vD, (vnot_ppc (or v4i32:$vA,
529                                                   v4i32:$vB)))]>;
530def VOR : VXForm_1<1156, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
531                      "vor $vD, $vA, $vB", VecFP,
532                      [(set v4i32:$vD, (or v4i32:$vA, v4i32:$vB))]>;
533def VXOR : VXForm_1<1220, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
534                      "vxor $vD, $vA, $vB", VecFP,
535                      [(set v4i32:$vD, (xor v4i32:$vA, v4i32:$vB))]>;
536
537def VRLB   : VX1_Int_Ty<   4, "vrlb", int_ppc_altivec_vrlb, v16i8>;
538def VRLH   : VX1_Int_Ty<  68, "vrlh", int_ppc_altivec_vrlh, v8i16>;
539def VRLW   : VX1_Int_Ty< 132, "vrlw", int_ppc_altivec_vrlw, v4i32>;
540
541def VSL    : VX1_Int_Ty< 452, "vsl" , int_ppc_altivec_vsl,  v4i32 >;
542def VSLO   : VX1_Int_Ty<1036, "vslo", int_ppc_altivec_vslo, v4i32>;
543
544def VSLB   : VX1_Int_Ty< 260, "vslb", int_ppc_altivec_vslb, v16i8>;
545def VSLH   : VX1_Int_Ty< 324, "vslh", int_ppc_altivec_vslh, v8i16>;
546def VSLW   : VX1_Int_Ty< 388, "vslw", int_ppc_altivec_vslw, v4i32>;
547
548def VSPLTB : VXForm_1<524, (outs vrrc:$vD), (ins u5imm:$UIMM, vrrc:$vB),
549                      "vspltb $vD, $vB, $UIMM", VecPerm,
550                      [(set v16i8:$vD,
551                        (vspltb_shuffle:$UIMM v16i8:$vB, (undef)))]>;
552def VSPLTH : VXForm_1<588, (outs vrrc:$vD), (ins u5imm:$UIMM, vrrc:$vB),
553                      "vsplth $vD, $vB, $UIMM", VecPerm,
554                      [(set v16i8:$vD,
555                        (vsplth_shuffle:$UIMM v16i8:$vB, (undef)))]>;
556def VSPLTW : VXForm_1<652, (outs vrrc:$vD), (ins u5imm:$UIMM, vrrc:$vB),
557                      "vspltw $vD, $vB, $UIMM", VecPerm,
558                      [(set v16i8:$vD,
559                        (vspltw_shuffle:$UIMM v16i8:$vB, (undef)))]>;
560
561def VSR    : VX1_Int_Ty< 708, "vsr"  , int_ppc_altivec_vsr,  v4i32>;
562def VSRO   : VX1_Int_Ty<1100, "vsro" , int_ppc_altivec_vsro, v4i32>;
563
564def VSRAB  : VX1_Int_Ty< 772, "vsrab", int_ppc_altivec_vsrab, v16i8>;
565def VSRAH  : VX1_Int_Ty< 836, "vsrah", int_ppc_altivec_vsrah, v8i16>;
566def VSRAW  : VX1_Int_Ty< 900, "vsraw", int_ppc_altivec_vsraw, v4i32>;
567def VSRB   : VX1_Int_Ty< 516, "vsrb" , int_ppc_altivec_vsrb , v16i8>;
568def VSRH   : VX1_Int_Ty< 580, "vsrh" , int_ppc_altivec_vsrh , v8i16>;
569def VSRW   : VX1_Int_Ty< 644, "vsrw" , int_ppc_altivec_vsrw , v4i32>;
570
571
572def VSPLTISB : VXForm_3<780, (outs vrrc:$vD), (ins s5imm:$SIMM),
573                       "vspltisb $vD, $SIMM", VecPerm,
574                       [(set v16i8:$vD, (v16i8 vecspltisb:$SIMM))]>;
575def VSPLTISH : VXForm_3<844, (outs vrrc:$vD), (ins s5imm:$SIMM),
576                       "vspltish $vD, $SIMM", VecPerm,
577                       [(set v8i16:$vD, (v8i16 vecspltish:$SIMM))]>;
578def VSPLTISW : VXForm_3<908, (outs vrrc:$vD), (ins s5imm:$SIMM),
579                       "vspltisw $vD, $SIMM", VecPerm,
580                       [(set v4i32:$vD, (v4i32 vecspltisw:$SIMM))]>;
581
582// Vector Pack.
583def VPKPX   : VX1_Int_Ty2<782, "vpkpx", int_ppc_altivec_vpkpx,
584                          v8i16, v4i32>;
585def VPKSHSS : VX1_Int_Ty2<398, "vpkshss", int_ppc_altivec_vpkshss,
586                          v16i8, v8i16>;
587def VPKSHUS : VX1_Int_Ty2<270, "vpkshus", int_ppc_altivec_vpkshus,
588                          v16i8, v8i16>;
589def VPKSWSS : VX1_Int_Ty2<462, "vpkswss", int_ppc_altivec_vpkswss,
590                          v16i8, v4i32>;
591def VPKSWUS : VX1_Int_Ty2<334, "vpkswus", int_ppc_altivec_vpkswus,
592                          v8i16, v4i32>;
593def VPKUHUM : VXForm_1<14, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
594                       "vpkuhum $vD, $vA, $vB", VecFP,
595                       [(set v16i8:$vD,
596                         (vpkuhum_shuffle v16i8:$vA, v16i8:$vB))]>;
597def VPKUHUS : VX1_Int_Ty2<142, "vpkuhus", int_ppc_altivec_vpkuhus,
598                          v16i8, v8i16>;
599def VPKUWUM : VXForm_1<78, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),
600                       "vpkuwum $vD, $vA, $vB", VecFP,
601                       [(set v16i8:$vD,
602                         (vpkuwum_shuffle v16i8:$vA, v16i8:$vB))]>;
603def VPKUWUS : VX1_Int_Ty2<206, "vpkuwus", int_ppc_altivec_vpkuwus,
604                          v8i16, v4i32>;
605
606// Vector Unpack.
607def VUPKHPX : VX2_Int_Ty2<846, "vupkhpx", int_ppc_altivec_vupkhpx,
608                          v4i32, v8i16>;
609def VUPKHSB : VX2_Int_Ty2<526, "vupkhsb", int_ppc_altivec_vupkhsb,
610                          v8i16, v16i8>;
611def VUPKHSH : VX2_Int_Ty2<590, "vupkhsh", int_ppc_altivec_vupkhsh,
612                          v4i32, v8i16>;
613def VUPKLPX : VX2_Int_Ty2<974, "vupklpx", int_ppc_altivec_vupklpx,
614                          v4i32, v8i16>;
615def VUPKLSB : VX2_Int_Ty2<654, "vupklsb", int_ppc_altivec_vupklsb,
616                          v8i16, v16i8>;
617def VUPKLSH : VX2_Int_Ty2<718, "vupklsh", int_ppc_altivec_vupklsh,
618                          v4i32, v8i16>;
619
620
621// Altivec Comparisons.
622
623class VCMP<bits<10> xo, string asmstr, ValueType Ty>
624  : VXRForm_1<xo, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),asmstr,VecFPCompare,
625              [(set Ty:$vD, (Ty (PPCvcmp Ty:$vA, Ty:$vB, xo)))]>;
626class VCMPo<bits<10> xo, string asmstr, ValueType Ty>
627  : VXRForm_1<xo, (outs vrrc:$vD), (ins vrrc:$vA, vrrc:$vB),asmstr,VecFPCompare,
628              [(set Ty:$vD, (Ty (PPCvcmp_o Ty:$vA, Ty:$vB, xo)))]> {
629  let Defs = [CR6];
630  let RC = 1;
631}
632
633// f32 element comparisons.0
634def VCMPBFP   : VCMP <966, "vcmpbfp $vD, $vA, $vB"  , v4f32>;
635def VCMPBFPo  : VCMPo<966, "vcmpbfp. $vD, $vA, $vB" , v4f32>;
636def VCMPEQFP  : VCMP <198, "vcmpeqfp $vD, $vA, $vB" , v4f32>;
637def VCMPEQFPo : VCMPo<198, "vcmpeqfp. $vD, $vA, $vB", v4f32>;
638def VCMPGEFP  : VCMP <454, "vcmpgefp $vD, $vA, $vB" , v4f32>;
639def VCMPGEFPo : VCMPo<454, "vcmpgefp. $vD, $vA, $vB", v4f32>;
640def VCMPGTFP  : VCMP <710, "vcmpgtfp $vD, $vA, $vB" , v4f32>;
641def VCMPGTFPo : VCMPo<710, "vcmpgtfp. $vD, $vA, $vB", v4f32>;
642
643// i8 element comparisons.
644def VCMPEQUB  : VCMP <  6, "vcmpequb $vD, $vA, $vB" , v16i8>;
645def VCMPEQUBo : VCMPo<  6, "vcmpequb. $vD, $vA, $vB", v16i8>;
646def VCMPGTSB  : VCMP <774, "vcmpgtsb $vD, $vA, $vB" , v16i8>;
647def VCMPGTSBo : VCMPo<774, "vcmpgtsb. $vD, $vA, $vB", v16i8>;
648def VCMPGTUB  : VCMP <518, "vcmpgtub $vD, $vA, $vB" , v16i8>;
649def VCMPGTUBo : VCMPo<518, "vcmpgtub. $vD, $vA, $vB", v16i8>;
650
651// i16 element comparisons.
652def VCMPEQUH  : VCMP < 70, "vcmpequh $vD, $vA, $vB" , v8i16>;
653def VCMPEQUHo : VCMPo< 70, "vcmpequh. $vD, $vA, $vB", v8i16>;
654def VCMPGTSH  : VCMP <838, "vcmpgtsh $vD, $vA, $vB" , v8i16>;
655def VCMPGTSHo : VCMPo<838, "vcmpgtsh. $vD, $vA, $vB", v8i16>;
656def VCMPGTUH  : VCMP <582, "vcmpgtuh $vD, $vA, $vB" , v8i16>;
657def VCMPGTUHo : VCMPo<582, "vcmpgtuh. $vD, $vA, $vB", v8i16>;
658
659// i32 element comparisons.
660def VCMPEQUW  : VCMP <134, "vcmpequw $vD, $vA, $vB" , v4i32>;
661def VCMPEQUWo : VCMPo<134, "vcmpequw. $vD, $vA, $vB", v4i32>;
662def VCMPGTSW  : VCMP <902, "vcmpgtsw $vD, $vA, $vB" , v4i32>;
663def VCMPGTSWo : VCMPo<902, "vcmpgtsw. $vD, $vA, $vB", v4i32>;
664def VCMPGTUW  : VCMP <646, "vcmpgtuw $vD, $vA, $vB" , v4i32>;
665def VCMPGTUWo : VCMPo<646, "vcmpgtuw. $vD, $vA, $vB", v4i32>;
666
667let isCodeGenOnly = 1 in {
668def V_SET0B : VXForm_setzero<1220, (outs vrrc:$vD), (ins),
669                      "vxor $vD, $vD, $vD", VecFP,
670                      [(set v16i8:$vD, (v16i8 immAllZerosV))]>;
671def V_SET0H : VXForm_setzero<1220, (outs vrrc:$vD), (ins),
672                      "vxor $vD, $vD, $vD", VecFP,
673                      [(set v8i16:$vD, (v8i16 immAllZerosV))]>;
674def V_SET0  : VXForm_setzero<1220, (outs vrrc:$vD), (ins),
675                      "vxor $vD, $vD, $vD", VecFP,
676                      [(set v4i32:$vD, (v4i32 immAllZerosV))]>;
677
678let IMM=-1 in {
679def V_SETALLONESB : VXForm_3<908, (outs vrrc:$vD), (ins),
680                      "vspltisw $vD, -1", VecFP,
681                      [(set v16i8:$vD, (v16i8 immAllOnesV))]>;
682def V_SETALLONESH : VXForm_3<908, (outs vrrc:$vD), (ins),
683                      "vspltisw $vD, -1", VecFP,
684                      [(set v8i16:$vD, (v8i16 immAllOnesV))]>;
685def V_SETALLONES  : VXForm_3<908, (outs vrrc:$vD), (ins),
686                      "vspltisw $vD, -1", VecFP,
687                      [(set v4i32:$vD, (v4i32 immAllOnesV))]>;
688}
689}
690} // VALU Operations.
691
692//===----------------------------------------------------------------------===//
693// Additional Altivec Patterns
694//
695
696// DS* intrinsics
697def : Pat<(int_ppc_altivec_dssall), (DSSALL 1, 0, 0, 0)>;
698def : Pat<(int_ppc_altivec_dss imm:$STRM), (DSS 0, imm:$STRM, 0, 0)>;
699
700//  * 32-bit
701def : Pat<(int_ppc_altivec_dst i32:$rA, i32:$rB, imm:$STRM),
702          (DST 0, imm:$STRM, $rA, $rB)>;
703def : Pat<(int_ppc_altivec_dstt i32:$rA, i32:$rB, imm:$STRM),
704          (DSTT 1, imm:$STRM, $rA, $rB)>;
705def : Pat<(int_ppc_altivec_dstst i32:$rA, i32:$rB, imm:$STRM),
706          (DSTST 0, imm:$STRM, $rA, $rB)>;
707def : Pat<(int_ppc_altivec_dststt i32:$rA, i32:$rB, imm:$STRM),
708          (DSTSTT 1, imm:$STRM, $rA, $rB)>;
709
710//  * 64-bit
711def : Pat<(int_ppc_altivec_dst i64:$rA, i32:$rB, imm:$STRM),
712          (DST64 0, imm:$STRM, $rA, $rB)>;
713def : Pat<(int_ppc_altivec_dstt i64:$rA, i32:$rB, imm:$STRM),
714          (DSTT64 1, imm:$STRM, $rA, $rB)>;
715def : Pat<(int_ppc_altivec_dstst i64:$rA, i32:$rB, imm:$STRM),
716          (DSTST64 0, imm:$STRM, $rA, $rB)>;
717def : Pat<(int_ppc_altivec_dststt i64:$rA, i32:$rB, imm:$STRM),
718          (DSTSTT64 1, imm:$STRM, $rA, $rB)>;
719
720// Loads.
721def : Pat<(v4i32 (load xoaddr:$src)), (LVX xoaddr:$src)>;
722
723// Stores.
724def : Pat<(store v4i32:$rS, xoaddr:$dst),
725          (STVX $rS, xoaddr:$dst)>;
726
727// Bit conversions.
728def : Pat<(v16i8 (bitconvert (v8i16 VRRC:$src))), (v16i8 VRRC:$src)>;
729def : Pat<(v16i8 (bitconvert (v4i32 VRRC:$src))), (v16i8 VRRC:$src)>;
730def : Pat<(v16i8 (bitconvert (v4f32 VRRC:$src))), (v16i8 VRRC:$src)>;
731
732def : Pat<(v8i16 (bitconvert (v16i8 VRRC:$src))), (v8i16 VRRC:$src)>;
733def : Pat<(v8i16 (bitconvert (v4i32 VRRC:$src))), (v8i16 VRRC:$src)>;
734def : Pat<(v8i16 (bitconvert (v4f32 VRRC:$src))), (v8i16 VRRC:$src)>;
735
736def : Pat<(v4i32 (bitconvert (v16i8 VRRC:$src))), (v4i32 VRRC:$src)>;
737def : Pat<(v4i32 (bitconvert (v8i16 VRRC:$src))), (v4i32 VRRC:$src)>;
738def : Pat<(v4i32 (bitconvert (v4f32 VRRC:$src))), (v4i32 VRRC:$src)>;
739
740def : Pat<(v4f32 (bitconvert (v16i8 VRRC:$src))), (v4f32 VRRC:$src)>;
741def : Pat<(v4f32 (bitconvert (v8i16 VRRC:$src))), (v4f32 VRRC:$src)>;
742def : Pat<(v4f32 (bitconvert (v4i32 VRRC:$src))), (v4f32 VRRC:$src)>;
743
744// Shuffles.
745
746// Match vsldoi(x,x), vpkuwum(x,x), vpkuhum(x,x)
747def:Pat<(vsldoi_unary_shuffle:$in v16i8:$vA, undef),
748        (VSLDOI $vA, $vA, (VSLDOI_unary_get_imm $in))>;
749def:Pat<(vpkuwum_unary_shuffle v16i8:$vA, undef),
750        (VPKUWUM $vA, $vA)>;
751def:Pat<(vpkuhum_unary_shuffle v16i8:$vA, undef),
752        (VPKUHUM $vA, $vA)>;
753
754// Match vmrg*(x,x)
755def:Pat<(vmrglb_unary_shuffle v16i8:$vA, undef),
756        (VMRGLB $vA, $vA)>;
757def:Pat<(vmrglh_unary_shuffle v16i8:$vA, undef),
758        (VMRGLH $vA, $vA)>;
759def:Pat<(vmrglw_unary_shuffle v16i8:$vA, undef),
760        (VMRGLW $vA, $vA)>;
761def:Pat<(vmrghb_unary_shuffle v16i8:$vA, undef),
762        (VMRGHB $vA, $vA)>;
763def:Pat<(vmrghh_unary_shuffle v16i8:$vA, undef),
764        (VMRGHH $vA, $vA)>;
765def:Pat<(vmrghw_unary_shuffle v16i8:$vA, undef),
766        (VMRGHW $vA, $vA)>;
767
768// Logical Operations
769def : Pat<(vnot_ppc v4i32:$vA), (VNOR $vA, $vA)>;
770
771def : Pat<(vnot_ppc (or v4i32:$A, v4i32:$B)),
772          (VNOR $A, $B)>;
773def : Pat<(and v4i32:$A, (vnot_ppc v4i32:$B)),
774          (VANDC $A, $B)>;
775
776def : Pat<(fmul v4f32:$vA, v4f32:$vB),
777          (VMADDFP $vA, $vB,
778             (v4i32 (VSLW (V_SETALLONES), (V_SETALLONES))))>;
779
780// Fused multiply add and multiply sub for packed float.  These are represented
781// separately from the real instructions above, for operations that must have
782// the additional precision, such as Newton-Rhapson (used by divide, sqrt)
783def : Pat<(PPCvmaddfp v4f32:$A, v4f32:$B, v4f32:$C),
784          (VMADDFP $A, $B, $C)>;
785def : Pat<(PPCvnmsubfp v4f32:$A, v4f32:$B, v4f32:$C),
786          (VNMSUBFP $A, $B, $C)>;
787
788def : Pat<(int_ppc_altivec_vmaddfp v4f32:$A, v4f32:$B, v4f32:$C),
789          (VMADDFP $A, $B, $C)>;
790def : Pat<(int_ppc_altivec_vnmsubfp v4f32:$A, v4f32:$B, v4f32:$C),
791          (VNMSUBFP $A, $B, $C)>;
792
793def : Pat<(PPCvperm v16i8:$vA, v16i8:$vB, v16i8:$vC),
794          (VPERM $vA, $vB, $vC)>;
795
796def : Pat<(PPCfre v4f32:$A), (VREFP $A)>;
797def : Pat<(PPCfrsqrte v4f32:$A), (VRSQRTEFP $A)>;
798
799// Vector shifts
800def : Pat<(v16i8 (shl v16i8:$vA, v16i8:$vB)),
801          (v16i8 (VSLB $vA, $vB))>;
802def : Pat<(v8i16 (shl v8i16:$vA, v8i16:$vB)),
803          (v8i16 (VSLH $vA, $vB))>;
804def : Pat<(v4i32 (shl v4i32:$vA, v4i32:$vB)),
805          (v4i32 (VSLW $vA, $vB))>;
806
807def : Pat<(v16i8 (srl v16i8:$vA, v16i8:$vB)),
808          (v16i8 (VSRB $vA, $vB))>;
809def : Pat<(v8i16 (srl v8i16:$vA, v8i16:$vB)),
810          (v8i16 (VSRH $vA, $vB))>;
811def : Pat<(v4i32 (srl v4i32:$vA, v4i32:$vB)),
812          (v4i32 (VSRW $vA, $vB))>;
813
814def : Pat<(v16i8 (sra v16i8:$vA, v16i8:$vB)),
815          (v16i8 (VSRAB $vA, $vB))>;
816def : Pat<(v8i16 (sra v8i16:$vA, v8i16:$vB)),
817          (v8i16 (VSRAH $vA, $vB))>;
818def : Pat<(v4i32 (sra v4i32:$vA, v4i32:$vB)),
819          (v4i32 (VSRAW $vA, $vB))>;
820
821// Float to integer and integer to float conversions
822def : Pat<(v4i32 (fp_to_sint v4f32:$vA)),
823           (VCTSXS_0 $vA)>;
824def : Pat<(v4i32 (fp_to_uint v4f32:$vA)),
825           (VCTUXS_0 $vA)>;
826def : Pat<(v4f32 (sint_to_fp v4i32:$vA)),
827           (VCFSX_0 $vA)>;
828def : Pat<(v4f32 (uint_to_fp v4i32:$vA)),
829           (VCFUX_0 $vA)>;
830
831// Floating-point rounding
832def : Pat<(v4f32 (ffloor v4f32:$vA)),
833          (VRFIM $vA)>;
834def : Pat<(v4f32 (fceil v4f32:$vA)),
835          (VRFIP $vA)>;
836def : Pat<(v4f32 (ftrunc v4f32:$vA)),
837          (VRFIZ $vA)>;
838def : Pat<(v4f32 (fnearbyint v4f32:$vA)),
839          (VRFIN $vA)>;
840
841} // end HasAltivec
842
843