xref: /freebsd/contrib/llvm-project/llvm/lib/Target/ARM/ARMInstrNEON.td (revision 7fdf597e96a02165cfe22ff357b857d5fa15ed8a)
1//===-- ARMInstrNEON.td - NEON support for ARM -------------*- tablegen -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file describes the ARM NEON instruction set.
10//
11//===----------------------------------------------------------------------===//
12
13
14//===----------------------------------------------------------------------===//
15// NEON-specific Operands.
16//===----------------------------------------------------------------------===//
17def nModImm : Operand<i32> {
18  let PrintMethod = "printVMOVModImmOperand";
19}
20
21def nImmSplatI8AsmOperand : AsmOperandClass { let Name = "NEONi8splat"; }
22def nImmSplatI8 : Operand<i32> {
23  let PrintMethod = "printVMOVModImmOperand";
24  let ParserMatchClass = nImmSplatI8AsmOperand;
25}
26def nImmSplatI16AsmOperand : AsmOperandClass { let Name = "NEONi16splat"; }
27def nImmSplatI16 : Operand<i32> {
28  let PrintMethod = "printVMOVModImmOperand";
29  let ParserMatchClass = nImmSplatI16AsmOperand;
30}
31def nImmSplatI32AsmOperand : AsmOperandClass { let Name = "NEONi32splat"; }
32def nImmSplatI32 : Operand<i32> {
33  let PrintMethod = "printVMOVModImmOperand";
34  let ParserMatchClass = nImmSplatI32AsmOperand;
35}
36def nImmSplatNotI16AsmOperand : AsmOperandClass { let Name = "NEONi16splatNot"; }
37def nImmSplatNotI16 : Operand<i32> {
38  let ParserMatchClass = nImmSplatNotI16AsmOperand;
39}
40def nImmSplatNotI32AsmOperand : AsmOperandClass { let Name = "NEONi32splatNot"; }
41def nImmSplatNotI32 : Operand<i32> {
42  let ParserMatchClass = nImmSplatNotI32AsmOperand;
43}
44def nImmVMOVI32AsmOperand : AsmOperandClass { let Name = "NEONi32vmov"; }
45def nImmVMOVI32 : Operand<i32> {
46  let PrintMethod = "printVMOVModImmOperand";
47  let ParserMatchClass = nImmVMOVI32AsmOperand;
48}
49
50class nImmVMOVIAsmOperandReplicate<ValueType From, ValueType To>
51  : AsmOperandClass {
52  let Name = "NEONi" # To.Size # "vmovi" # From.Size # "Replicate";
53  let PredicateMethod = "isNEONmovReplicate<" # From.Size # ", " # To.Size # ">";
54  let RenderMethod = "addNEONvmovi" # From.Size # "ReplicateOperands";
55}
56
57class nImmVINVIAsmOperandReplicate<ValueType From, ValueType To>
58  : AsmOperandClass {
59  let Name = "NEONi" # To.Size # "invi" # From.Size # "Replicate";
60  let PredicateMethod = "isNEONinvReplicate<" # From.Size # ", " # To.Size # ">";
61  let RenderMethod = "addNEONinvi" # From.Size # "ReplicateOperands";
62}
63
64class nImmVMOVIReplicate<ValueType From, ValueType To> : Operand<i32> {
65  let PrintMethod = "printVMOVModImmOperand";
66  let ParserMatchClass = nImmVMOVIAsmOperandReplicate<From, To>;
67}
68
69class nImmVINVIReplicate<ValueType From, ValueType To> : Operand<i32> {
70  let PrintMethod = "printVMOVModImmOperand";
71  let ParserMatchClass = nImmVINVIAsmOperandReplicate<From, To>;
72}
73
74def nImmVMOVI32NegAsmOperand : AsmOperandClass { let Name = "NEONi32vmovNeg"; }
75def nImmVMOVI32Neg : Operand<i32> {
76  let PrintMethod = "printVMOVModImmOperand";
77  let ParserMatchClass = nImmVMOVI32NegAsmOperand;
78}
79def nImmVMOVF32 : Operand<i32> {
80  let PrintMethod = "printFPImmOperand";
81  let ParserMatchClass = FPImmOperand;
82}
83def nImmSplatI64AsmOperand : AsmOperandClass { let Name = "NEONi64splat"; }
84def nImmSplatI64 : Operand<i32> {
85  let PrintMethod = "printVMOVModImmOperand";
86  let ParserMatchClass = nImmSplatI64AsmOperand;
87}
88
89def VectorIndex8Operand  : AsmOperandClass { let Name = "VectorIndex8"; }
90def VectorIndex16Operand : AsmOperandClass { let Name = "VectorIndex16"; }
91def VectorIndex32Operand : AsmOperandClass { let Name = "VectorIndex32"; }
92def VectorIndex64Operand : AsmOperandClass { let Name = "VectorIndex64"; }
93def VectorIndex8 : Operand<i32>, ImmLeaf<i32, [{
94  return ((uint64_t)Imm) < 8;
95}]> {
96  let ParserMatchClass = VectorIndex8Operand;
97  let PrintMethod = "printVectorIndex";
98  let MIOperandInfo = (ops i32imm);
99}
100def VectorIndex16 : Operand<i32>, ImmLeaf<i32, [{
101  return ((uint64_t)Imm) < 4;
102}]> {
103  let ParserMatchClass = VectorIndex16Operand;
104  let PrintMethod = "printVectorIndex";
105  let MIOperandInfo = (ops i32imm);
106}
107def VectorIndex32 : Operand<i32>, ImmLeaf<i32, [{
108  return ((uint64_t)Imm) < 2;
109}]> {
110  let ParserMatchClass = VectorIndex32Operand;
111  let PrintMethod = "printVectorIndex";
112  let MIOperandInfo = (ops i32imm);
113}
114def VectorIndex64 : Operand<i32>, ImmLeaf<i32, [{
115  return ((uint64_t)Imm) < 1;
116}]> {
117  let ParserMatchClass = VectorIndex64Operand;
118  let PrintMethod = "printVectorIndex";
119  let MIOperandInfo = (ops i32imm);
120}
121
122// Register list of one D register.
123def VecListOneDAsmOperand : AsmOperandClass {
124  let Name = "VecListOneD";
125  let ParserMethod = "parseVectorList";
126  let RenderMethod = "addVecListOperands";
127}
128def VecListOneD : RegisterOperand<DPR, "printVectorListOne"> {
129  let ParserMatchClass = VecListOneDAsmOperand;
130}
131// Register list of two sequential D registers.
132def VecListDPairAsmOperand : AsmOperandClass {
133  let Name = "VecListDPair";
134  let ParserMethod = "parseVectorList";
135  let RenderMethod = "addVecListOperands";
136}
137def VecListDPair : RegisterOperand<DPair, "printVectorListTwo"> {
138  let ParserMatchClass = VecListDPairAsmOperand;
139}
140// Register list of three sequential D registers.
141def VecListThreeDAsmOperand : AsmOperandClass {
142  let Name = "VecListThreeD";
143  let ParserMethod = "parseVectorList";
144  let RenderMethod = "addVecListOperands";
145}
146def VecListThreeD : RegisterOperand<DPR, "printVectorListThree"> {
147  let ParserMatchClass = VecListThreeDAsmOperand;
148}
149// Register list of four sequential D registers.
150def VecListFourDAsmOperand : AsmOperandClass {
151  let Name = "VecListFourD";
152  let ParserMethod = "parseVectorList";
153  let RenderMethod = "addVecListOperands";
154}
155def VecListFourD : RegisterOperand<DPR, "printVectorListFour"> {
156  let ParserMatchClass = VecListFourDAsmOperand;
157}
158// Register list of two D registers spaced by 2 (two sequential Q registers).
159def VecListDPairSpacedAsmOperand : AsmOperandClass {
160  let Name = "VecListDPairSpaced";
161  let ParserMethod = "parseVectorList";
162  let RenderMethod = "addVecListOperands";
163}
164def VecListDPairSpaced : RegisterOperand<DPair, "printVectorListTwoSpaced"> {
165  let ParserMatchClass = VecListDPairSpacedAsmOperand;
166}
167// Register list of three D registers spaced by 2 (three Q registers).
168def VecListThreeQAsmOperand : AsmOperandClass {
169  let Name = "VecListThreeQ";
170  let ParserMethod = "parseVectorList";
171  let RenderMethod = "addVecListOperands";
172}
173def VecListThreeQ : RegisterOperand<DPR, "printVectorListThreeSpaced"> {
174  let ParserMatchClass = VecListThreeQAsmOperand;
175}
176// Register list of three D registers spaced by 2 (three Q registers).
177def VecListFourQAsmOperand : AsmOperandClass {
178  let Name = "VecListFourQ";
179  let ParserMethod = "parseVectorList";
180  let RenderMethod = "addVecListOperands";
181}
182def VecListFourQ : RegisterOperand<DPR, "printVectorListFourSpaced"> {
183  let ParserMatchClass = VecListFourQAsmOperand;
184}
185
186// Register list of one D register, with "all lanes" subscripting.
187def VecListOneDAllLanesAsmOperand : AsmOperandClass {
188  let Name = "VecListOneDAllLanes";
189  let ParserMethod = "parseVectorList";
190  let RenderMethod = "addVecListOperands";
191}
192def VecListOneDAllLanes : RegisterOperand<DPR, "printVectorListOneAllLanes"> {
193  let ParserMatchClass = VecListOneDAllLanesAsmOperand;
194}
195// Register list of two D registers, with "all lanes" subscripting.
196def VecListDPairAllLanesAsmOperand : AsmOperandClass {
197  let Name = "VecListDPairAllLanes";
198  let ParserMethod = "parseVectorList";
199  let RenderMethod = "addVecListOperands";
200}
201def VecListDPairAllLanes : RegisterOperand<DPair,
202                                           "printVectorListTwoAllLanes"> {
203  let ParserMatchClass = VecListDPairAllLanesAsmOperand;
204}
205// Register list of two D registers spaced by 2 (two sequential Q registers).
206def VecListDPairSpacedAllLanesAsmOperand : AsmOperandClass {
207  let Name = "VecListDPairSpacedAllLanes";
208  let ParserMethod = "parseVectorList";
209  let RenderMethod = "addVecListOperands";
210}
211def VecListDPairSpacedAllLanes : RegisterOperand<DPairSpc,
212                                         "printVectorListTwoSpacedAllLanes"> {
213  let ParserMatchClass = VecListDPairSpacedAllLanesAsmOperand;
214}
215// Register list of three D registers, with "all lanes" subscripting.
216def VecListThreeDAllLanesAsmOperand : AsmOperandClass {
217  let Name = "VecListThreeDAllLanes";
218  let ParserMethod = "parseVectorList";
219  let RenderMethod = "addVecListOperands";
220}
221def VecListThreeDAllLanes : RegisterOperand<DPR,
222                                            "printVectorListThreeAllLanes"> {
223  let ParserMatchClass = VecListThreeDAllLanesAsmOperand;
224}
225// Register list of three D registers spaced by 2 (three sequential Q regs).
226def VecListThreeQAllLanesAsmOperand : AsmOperandClass {
227  let Name = "VecListThreeQAllLanes";
228  let ParserMethod = "parseVectorList";
229  let RenderMethod = "addVecListOperands";
230}
231def VecListThreeQAllLanes : RegisterOperand<DPR,
232                                         "printVectorListThreeSpacedAllLanes"> {
233  let ParserMatchClass = VecListThreeQAllLanesAsmOperand;
234}
235// Register list of four D registers, with "all lanes" subscripting.
236def VecListFourDAllLanesAsmOperand : AsmOperandClass {
237  let Name = "VecListFourDAllLanes";
238  let ParserMethod = "parseVectorList";
239  let RenderMethod = "addVecListOperands";
240}
241def VecListFourDAllLanes : RegisterOperand<DPR, "printVectorListFourAllLanes"> {
242  let ParserMatchClass = VecListFourDAllLanesAsmOperand;
243}
244// Register list of four D registers spaced by 2 (four sequential Q regs).
245def VecListFourQAllLanesAsmOperand : AsmOperandClass {
246  let Name = "VecListFourQAllLanes";
247  let ParserMethod = "parseVectorList";
248  let RenderMethod = "addVecListOperands";
249}
250def VecListFourQAllLanes : RegisterOperand<DPR,
251                                         "printVectorListFourSpacedAllLanes"> {
252  let ParserMatchClass = VecListFourQAllLanesAsmOperand;
253}
254
255
256// Register list of one D register, with byte lane subscripting.
257def VecListOneDByteIndexAsmOperand : AsmOperandClass {
258  let Name = "VecListOneDByteIndexed";
259  let ParserMethod = "parseVectorList";
260  let RenderMethod = "addVecListIndexedOperands";
261}
262def VecListOneDByteIndexed : Operand<i32> {
263  let ParserMatchClass = VecListOneDByteIndexAsmOperand;
264  let MIOperandInfo = (ops DPR:$Vd, i32imm:$idx);
265}
266// ...with half-word lane subscripting.
267def VecListOneDHWordIndexAsmOperand : AsmOperandClass {
268  let Name = "VecListOneDHWordIndexed";
269  let ParserMethod = "parseVectorList";
270  let RenderMethod = "addVecListIndexedOperands";
271}
272def VecListOneDHWordIndexed : Operand<i32> {
273  let ParserMatchClass = VecListOneDHWordIndexAsmOperand;
274  let MIOperandInfo = (ops DPR:$Vd, i32imm:$idx);
275}
276// ...with word lane subscripting.
277def VecListOneDWordIndexAsmOperand : AsmOperandClass {
278  let Name = "VecListOneDWordIndexed";
279  let ParserMethod = "parseVectorList";
280  let RenderMethod = "addVecListIndexedOperands";
281}
282def VecListOneDWordIndexed : Operand<i32> {
283  let ParserMatchClass = VecListOneDWordIndexAsmOperand;
284  let MIOperandInfo = (ops DPR:$Vd, i32imm:$idx);
285}
286
287// Register list of two D registers with byte lane subscripting.
288def VecListTwoDByteIndexAsmOperand : AsmOperandClass {
289  let Name = "VecListTwoDByteIndexed";
290  let ParserMethod = "parseVectorList";
291  let RenderMethod = "addVecListIndexedOperands";
292}
293def VecListTwoDByteIndexed : Operand<i32> {
294  let ParserMatchClass = VecListTwoDByteIndexAsmOperand;
295  let MIOperandInfo = (ops DPR:$Vd, i32imm:$idx);
296}
297// ...with half-word lane subscripting.
298def VecListTwoDHWordIndexAsmOperand : AsmOperandClass {
299  let Name = "VecListTwoDHWordIndexed";
300  let ParserMethod = "parseVectorList";
301  let RenderMethod = "addVecListIndexedOperands";
302}
303def VecListTwoDHWordIndexed : Operand<i32> {
304  let ParserMatchClass = VecListTwoDHWordIndexAsmOperand;
305  let MIOperandInfo = (ops DPR:$Vd, i32imm:$idx);
306}
307// ...with word lane subscripting.
308def VecListTwoDWordIndexAsmOperand : AsmOperandClass {
309  let Name = "VecListTwoDWordIndexed";
310  let ParserMethod = "parseVectorList";
311  let RenderMethod = "addVecListIndexedOperands";
312}
313def VecListTwoDWordIndexed : Operand<i32> {
314  let ParserMatchClass = VecListTwoDWordIndexAsmOperand;
315  let MIOperandInfo = (ops DPR:$Vd, i32imm:$idx);
316}
317// Register list of two Q registers with half-word lane subscripting.
318def VecListTwoQHWordIndexAsmOperand : AsmOperandClass {
319  let Name = "VecListTwoQHWordIndexed";
320  let ParserMethod = "parseVectorList";
321  let RenderMethod = "addVecListIndexedOperands";
322}
323def VecListTwoQHWordIndexed : Operand<i32> {
324  let ParserMatchClass = VecListTwoQHWordIndexAsmOperand;
325  let MIOperandInfo = (ops DPR:$Vd, i32imm:$idx);
326}
327// ...with word lane subscripting.
328def VecListTwoQWordIndexAsmOperand : AsmOperandClass {
329  let Name = "VecListTwoQWordIndexed";
330  let ParserMethod = "parseVectorList";
331  let RenderMethod = "addVecListIndexedOperands";
332}
333def VecListTwoQWordIndexed : Operand<i32> {
334  let ParserMatchClass = VecListTwoQWordIndexAsmOperand;
335  let MIOperandInfo = (ops DPR:$Vd, i32imm:$idx);
336}
337
338
339// Register list of three D registers with byte lane subscripting.
340def VecListThreeDByteIndexAsmOperand : AsmOperandClass {
341  let Name = "VecListThreeDByteIndexed";
342  let ParserMethod = "parseVectorList";
343  let RenderMethod = "addVecListIndexedOperands";
344}
345def VecListThreeDByteIndexed : Operand<i32> {
346  let ParserMatchClass = VecListThreeDByteIndexAsmOperand;
347  let MIOperandInfo = (ops DPR:$Vd, i32imm:$idx);
348}
349// ...with half-word lane subscripting.
350def VecListThreeDHWordIndexAsmOperand : AsmOperandClass {
351  let Name = "VecListThreeDHWordIndexed";
352  let ParserMethod = "parseVectorList";
353  let RenderMethod = "addVecListIndexedOperands";
354}
355def VecListThreeDHWordIndexed : Operand<i32> {
356  let ParserMatchClass = VecListThreeDHWordIndexAsmOperand;
357  let MIOperandInfo = (ops DPR:$Vd, i32imm:$idx);
358}
359// ...with word lane subscripting.
360def VecListThreeDWordIndexAsmOperand : AsmOperandClass {
361  let Name = "VecListThreeDWordIndexed";
362  let ParserMethod = "parseVectorList";
363  let RenderMethod = "addVecListIndexedOperands";
364}
365def VecListThreeDWordIndexed : Operand<i32> {
366  let ParserMatchClass = VecListThreeDWordIndexAsmOperand;
367  let MIOperandInfo = (ops DPR:$Vd, i32imm:$idx);
368}
369// Register list of three Q registers with half-word lane subscripting.
370def VecListThreeQHWordIndexAsmOperand : AsmOperandClass {
371  let Name = "VecListThreeQHWordIndexed";
372  let ParserMethod = "parseVectorList";
373  let RenderMethod = "addVecListIndexedOperands";
374}
375def VecListThreeQHWordIndexed : Operand<i32> {
376  let ParserMatchClass = VecListThreeQHWordIndexAsmOperand;
377  let MIOperandInfo = (ops DPR:$Vd, i32imm:$idx);
378}
379// ...with word lane subscripting.
380def VecListThreeQWordIndexAsmOperand : AsmOperandClass {
381  let Name = "VecListThreeQWordIndexed";
382  let ParserMethod = "parseVectorList";
383  let RenderMethod = "addVecListIndexedOperands";
384}
385def VecListThreeQWordIndexed : Operand<i32> {
386  let ParserMatchClass = VecListThreeQWordIndexAsmOperand;
387  let MIOperandInfo = (ops DPR:$Vd, i32imm:$idx);
388}
389
390// Register list of four D registers with byte lane subscripting.
391def VecListFourDByteIndexAsmOperand : AsmOperandClass {
392  let Name = "VecListFourDByteIndexed";
393  let ParserMethod = "parseVectorList";
394  let RenderMethod = "addVecListIndexedOperands";
395}
396def VecListFourDByteIndexed : Operand<i32> {
397  let ParserMatchClass = VecListFourDByteIndexAsmOperand;
398  let MIOperandInfo = (ops DPR:$Vd, i32imm:$idx);
399}
400// ...with half-word lane subscripting.
401def VecListFourDHWordIndexAsmOperand : AsmOperandClass {
402  let Name = "VecListFourDHWordIndexed";
403  let ParserMethod = "parseVectorList";
404  let RenderMethod = "addVecListIndexedOperands";
405}
406def VecListFourDHWordIndexed : Operand<i32> {
407  let ParserMatchClass = VecListFourDHWordIndexAsmOperand;
408  let MIOperandInfo = (ops DPR:$Vd, i32imm:$idx);
409}
410// ...with word lane subscripting.
411def VecListFourDWordIndexAsmOperand : AsmOperandClass {
412  let Name = "VecListFourDWordIndexed";
413  let ParserMethod = "parseVectorList";
414  let RenderMethod = "addVecListIndexedOperands";
415}
416def VecListFourDWordIndexed : Operand<i32> {
417  let ParserMatchClass = VecListFourDWordIndexAsmOperand;
418  let MIOperandInfo = (ops DPR:$Vd, i32imm:$idx);
419}
420// Register list of four Q registers with half-word lane subscripting.
421def VecListFourQHWordIndexAsmOperand : AsmOperandClass {
422  let Name = "VecListFourQHWordIndexed";
423  let ParserMethod = "parseVectorList";
424  let RenderMethod = "addVecListIndexedOperands";
425}
426def VecListFourQHWordIndexed : Operand<i32> {
427  let ParserMatchClass = VecListFourQHWordIndexAsmOperand;
428  let MIOperandInfo = (ops DPR:$Vd, i32imm:$idx);
429}
430// ...with word lane subscripting.
431def VecListFourQWordIndexAsmOperand : AsmOperandClass {
432  let Name = "VecListFourQWordIndexed";
433  let ParserMethod = "parseVectorList";
434  let RenderMethod = "addVecListIndexedOperands";
435}
436def VecListFourQWordIndexed : Operand<i32> {
437  let ParserMatchClass = VecListFourQWordIndexAsmOperand;
438  let MIOperandInfo = (ops DPR:$Vd, i32imm:$idx);
439}
440
441def dword_alignedload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
442  return cast<LoadSDNode>(N)->getAlign() >= 8;
443}]>;
444def dword_alignedstore : PatFrag<(ops node:$val, node:$ptr),
445                                 (store node:$val, node:$ptr), [{
446  return cast<StoreSDNode>(N)->getAlign() >= 8;
447}]>;
448def word_alignedload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
449  return cast<LoadSDNode>(N)->getAlign() == 4;
450}]>;
451def word_alignedstore : PatFrag<(ops node:$val, node:$ptr),
452                                 (store node:$val, node:$ptr), [{
453  return cast<StoreSDNode>(N)->getAlign() == 4;
454}]>;
455def hword_alignedload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
456  return cast<LoadSDNode>(N)->getAlign() == 2;
457}]>;
458def hword_alignedstore : PatFrag<(ops node:$val, node:$ptr),
459                                 (store node:$val, node:$ptr), [{
460  return cast<StoreSDNode>(N)->getAlign() == 2;
461}]>;
462def byte_alignedload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
463  return cast<LoadSDNode>(N)->getAlign() == 1;
464}]>;
465def byte_alignedstore : PatFrag<(ops node:$val, node:$ptr),
466                             (store node:$val, node:$ptr), [{
467  return cast<StoreSDNode>(N)->getAlign() == 1;
468}]>;
469def non_word_alignedload : PatFrag<(ops node:$ptr), (load node:$ptr), [{
470  return cast<LoadSDNode>(N)->getAlign() < 4;
471}]>;
472def non_word_alignedstore : PatFrag<(ops node:$val, node:$ptr),
473                                    (store node:$val, node:$ptr), [{
474  return cast<StoreSDNode>(N)->getAlign() < 4;
475}]>;
476
477//===----------------------------------------------------------------------===//
478// NEON-specific DAG Nodes.
479//===----------------------------------------------------------------------===//
480
481def SDTARMVTST    : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisSameAs<1, 2>]>;
482def NEONvtst      : SDNode<"ARMISD::VTST", SDTARMVTST>;
483
484// Types for vector shift by immediates.  The "SHX" version is for long and
485// narrow operations where the source and destination vectors have different
486// types.  The "SHINS" version is for shift and insert operations.
487def SDTARMVSHXIMM    : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisInt<1>,
488                                            SDTCisVT<2, i32>]>;
489def SDTARMVSHINSIMM  : SDTypeProfile<1, 3, [SDTCisInt<0>, SDTCisSameAs<0, 1>,
490                                            SDTCisSameAs<0, 2>, SDTCisVT<3, i32>]>;
491
492def NEONvshrnImm     : SDNode<"ARMISD::VSHRNIMM", SDTARMVSHXIMM>;
493
494def NEONvrshrsImm    : SDNode<"ARMISD::VRSHRsIMM", SDTARMVSHIMM>;
495def NEONvrshruImm    : SDNode<"ARMISD::VRSHRuIMM", SDTARMVSHIMM>;
496def NEONvrshrnImm    : SDNode<"ARMISD::VRSHRNIMM", SDTARMVSHXIMM>;
497
498def NEONvqshlsImm    : SDNode<"ARMISD::VQSHLsIMM", SDTARMVSHIMM>;
499def NEONvqshluImm    : SDNode<"ARMISD::VQSHLuIMM", SDTARMVSHIMM>;
500def NEONvqshlsuImm   : SDNode<"ARMISD::VQSHLsuIMM", SDTARMVSHIMM>;
501def NEONvqshrnsImm   : SDNode<"ARMISD::VQSHRNsIMM", SDTARMVSHXIMM>;
502def NEONvqshrnuImm   : SDNode<"ARMISD::VQSHRNuIMM", SDTARMVSHXIMM>;
503def NEONvqshrnsuImm  : SDNode<"ARMISD::VQSHRNsuIMM", SDTARMVSHXIMM>;
504
505def NEONvqrshrnsImm  : SDNode<"ARMISD::VQRSHRNsIMM", SDTARMVSHXIMM>;
506def NEONvqrshrnuImm  : SDNode<"ARMISD::VQRSHRNuIMM", SDTARMVSHXIMM>;
507def NEONvqrshrnsuImm : SDNode<"ARMISD::VQRSHRNsuIMM", SDTARMVSHXIMM>;
508
509def NEONvsliImm      : SDNode<"ARMISD::VSLIIMM", SDTARMVSHINSIMM>;
510def NEONvsriImm      : SDNode<"ARMISD::VSRIIMM", SDTARMVSHINSIMM>;
511
512def NEONvbsp      : SDNode<"ARMISD::VBSP",
513                           SDTypeProfile<1, 3, [SDTCisVec<0>,
514                                                SDTCisSameAs<0, 1>,
515                                                SDTCisSameAs<0, 2>,
516                                                SDTCisSameAs<0, 3>]>>;
517
518def SDTARMVEXT    : SDTypeProfile<1, 3, [SDTCisVec<0>, SDTCisSameAs<0, 1>,
519                                         SDTCisSameAs<0, 2>, SDTCisVT<3, i32>]>;
520def NEONvext      : SDNode<"ARMISD::VEXT", SDTARMVEXT>;
521
522def SDTARMVSHUF2  : SDTypeProfile<2, 2, [SDTCisVec<0>, SDTCisSameAs<0, 1>,
523                                         SDTCisSameAs<0, 2>,
524                                         SDTCisSameAs<0, 3>]>;
525def NEONzip       : SDNode<"ARMISD::VZIP", SDTARMVSHUF2>;
526def NEONuzp       : SDNode<"ARMISD::VUZP", SDTARMVSHUF2>;
527def NEONtrn       : SDNode<"ARMISD::VTRN", SDTARMVSHUF2>;
528
529def SDTARMVTBL1   : SDTypeProfile<1, 2, [SDTCisVT<0, v8i8>, SDTCisVT<1, v8i8>,
530                                         SDTCisVT<2, v8i8>]>;
531def SDTARMVTBL2   : SDTypeProfile<1, 3, [SDTCisVT<0, v8i8>, SDTCisVT<1, v8i8>,
532                                         SDTCisVT<2, v8i8>, SDTCisVT<3, v8i8>]>;
533def NEONvtbl1     : SDNode<"ARMISD::VTBL1", SDTARMVTBL1>;
534def NEONvtbl2     : SDNode<"ARMISD::VTBL2", SDTARMVTBL2>;
535
536
537//===----------------------------------------------------------------------===//
538// NEON load / store instructions
539//===----------------------------------------------------------------------===//
540
541// Use VLDM to load a Q register as a D register pair.
542// This is a pseudo instruction that is expanded to VLDMD after reg alloc.
543def VLDMQIA
544  : PseudoVFPLdStM<(outs DPair:$dst), (ins GPR:$Rn),
545                    IIC_fpLoad_m, "",
546                   [(set DPair:$dst, (v2f64 (word_alignedload GPR:$Rn)))]>;
547
548// Use VSTM to store a Q register as a D register pair.
549// This is a pseudo instruction that is expanded to VSTMD after reg alloc.
550def VSTMQIA
551  : PseudoVFPLdStM<(outs), (ins DPair:$src, GPR:$Rn),
552                    IIC_fpStore_m, "",
553                   [(word_alignedstore (v2f64 DPair:$src), GPR:$Rn)]>;
554
555// Classes for VLD* pseudo-instructions with multi-register operands.
556// These are expanded to real instructions after register allocation.
557class VLDQPseudo<InstrItinClass itin>
558  : PseudoNLdSt<(outs QPR:$dst), (ins addrmode6:$addr), itin, "">;
559class VLDQWBPseudo<InstrItinClass itin>
560  : PseudoNLdSt<(outs QPR:$dst, GPR:$wb),
561                (ins addrmode6:$addr, am6offset:$offset), itin,
562                "$addr.addr = $wb">;
563class VLDQWBfixedPseudo<InstrItinClass itin>
564  : PseudoNLdSt<(outs QPR:$dst, GPR:$wb),
565                (ins addrmode6:$addr), itin,
566                "$addr.addr = $wb">;
567class VLDQWBregisterPseudo<InstrItinClass itin>
568  : PseudoNLdSt<(outs QPR:$dst, GPR:$wb),
569                (ins addrmode6:$addr, rGPR:$offset), itin,
570                "$addr.addr = $wb">;
571
572class VLDQQPseudo<InstrItinClass itin>
573  : PseudoNLdSt<(outs QQPR:$dst), (ins addrmode6:$addr), itin, "">;
574class VLDQQWBPseudo<InstrItinClass itin>
575  : PseudoNLdSt<(outs QQPR:$dst, GPR:$wb),
576                (ins addrmode6:$addr, am6offset:$offset), itin,
577                "$addr.addr = $wb">;
578class VLDQQWBfixedPseudo<InstrItinClass itin>
579  : PseudoNLdSt<(outs QQPR:$dst, GPR:$wb),
580                (ins addrmode6:$addr), itin,
581                "$addr.addr = $wb">;
582class VLDQQWBregisterPseudo<InstrItinClass itin>
583  : PseudoNLdSt<(outs QQPR:$dst, GPR:$wb),
584                (ins addrmode6:$addr, rGPR:$offset), itin,
585                "$addr.addr = $wb">;
586
587
588class VLDQQQQPseudo<InstrItinClass itin>
589  : PseudoNLdSt<(outs QQQQPR:$dst), (ins addrmode6:$addr, QQQQPR:$src),itin,
590                "$src = $dst">;
591class VLDQQQQWBPseudo<InstrItinClass itin>
592  : PseudoNLdSt<(outs QQQQPR:$dst, GPR:$wb),
593                (ins addrmode6:$addr, am6offset:$offset, QQQQPR:$src), itin,
594                "$addr.addr = $wb, $src = $dst">;
595
596let mayLoad = 1, hasSideEffects = 0, hasExtraDefRegAllocReq = 1 in {
597
598//   VLD1     : Vector Load (multiple single elements)
599class VLD1D<bits<4> op7_4, string Dt, Operand AddrMode>
600  : NLdSt<0,0b10,0b0111,op7_4, (outs VecListOneD:$Vd),
601          (ins AddrMode:$Rn), IIC_VLD1,
602          "vld1", Dt, "$Vd, $Rn", "", []>, Sched<[WriteVLD1]> {
603  let Rm = 0b1111;
604  let Inst{4} = Rn{4};
605  let DecoderMethod = "DecodeVLDST1Instruction";
606}
607class VLD1Q<bits<4> op7_4, string Dt, Operand AddrMode>
608  : NLdSt<0,0b10,0b1010,op7_4, (outs VecListDPair:$Vd),
609          (ins AddrMode:$Rn), IIC_VLD1x2,
610          "vld1", Dt, "$Vd, $Rn", "", []>, Sched<[WriteVLD2]> {
611  let Rm = 0b1111;
612  let Inst{5-4} = Rn{5-4};
613  let DecoderMethod = "DecodeVLDST1Instruction";
614}
615
616def  VLD1d8   : VLD1D<{0,0,0,?}, "8",  addrmode6align64>;
617def  VLD1d16  : VLD1D<{0,1,0,?}, "16", addrmode6align64>;
618def  VLD1d32  : VLD1D<{1,0,0,?}, "32", addrmode6align64>;
619def  VLD1d64  : VLD1D<{1,1,0,?}, "64", addrmode6align64>;
620
621def  VLD1q8   : VLD1Q<{0,0,?,?}, "8",  addrmode6align64or128>;
622def  VLD1q16  : VLD1Q<{0,1,?,?}, "16", addrmode6align64or128>;
623def  VLD1q32  : VLD1Q<{1,0,?,?}, "32", addrmode6align64or128>;
624def  VLD1q64  : VLD1Q<{1,1,?,?}, "64", addrmode6align64or128>;
625
626// ...with address register writeback:
627multiclass VLD1DWB<bits<4> op7_4, string Dt, Operand AddrMode> {
628  def _fixed : NLdSt<0,0b10, 0b0111,op7_4, (outs VecListOneD:$Vd, GPR:$wb),
629                     (ins AddrMode:$Rn), IIC_VLD1u,
630                     "vld1", Dt, "$Vd, $Rn!",
631                     "$Rn.addr = $wb", []>, Sched<[WriteVLD1]> {
632    let Rm = 0b1101; // NLdSt will assign to the right encoding bits.
633    let Inst{4} = Rn{4};
634    let DecoderMethod = "DecodeVLDST1Instruction";
635  }
636  def _register : NLdSt<0,0b10,0b0111,op7_4, (outs VecListOneD:$Vd, GPR:$wb),
637                        (ins AddrMode:$Rn, rGPR:$Rm), IIC_VLD1u,
638                        "vld1", Dt, "$Vd, $Rn, $Rm",
639                        "$Rn.addr = $wb", []>, Sched<[WriteVLD1]> {
640    let Inst{4} = Rn{4};
641    let DecoderMethod = "DecodeVLDST1Instruction";
642  }
643}
644multiclass VLD1QWB<bits<4> op7_4, string Dt, Operand AddrMode> {
645  def _fixed : NLdSt<0,0b10,0b1010,op7_4, (outs VecListDPair:$Vd, GPR:$wb),
646                    (ins AddrMode:$Rn), IIC_VLD1x2u,
647                     "vld1", Dt, "$Vd, $Rn!",
648                     "$Rn.addr = $wb", []>, Sched<[WriteVLD2]> {
649    let Rm = 0b1101; // NLdSt will assign to the right encoding bits.
650    let Inst{5-4} = Rn{5-4};
651    let DecoderMethod = "DecodeVLDST1Instruction";
652  }
653  def _register : NLdSt<0,0b10,0b1010,op7_4, (outs VecListDPair:$Vd, GPR:$wb),
654                        (ins AddrMode:$Rn, rGPR:$Rm), IIC_VLD1x2u,
655                        "vld1", Dt, "$Vd, $Rn, $Rm",
656                        "$Rn.addr = $wb", []>, Sched<[WriteVLD2]> {
657    let Inst{5-4} = Rn{5-4};
658    let DecoderMethod = "DecodeVLDST1Instruction";
659  }
660}
661
662defm VLD1d8wb  : VLD1DWB<{0,0,0,?}, "8",  addrmode6align64>;
663defm VLD1d16wb : VLD1DWB<{0,1,0,?}, "16", addrmode6align64>;
664defm VLD1d32wb : VLD1DWB<{1,0,0,?}, "32", addrmode6align64>;
665defm VLD1d64wb : VLD1DWB<{1,1,0,?}, "64", addrmode6align64>;
666defm VLD1q8wb  : VLD1QWB<{0,0,?,?}, "8",  addrmode6align64or128>;
667defm VLD1q16wb : VLD1QWB<{0,1,?,?}, "16", addrmode6align64or128>;
668defm VLD1q32wb : VLD1QWB<{1,0,?,?}, "32", addrmode6align64or128>;
669defm VLD1q64wb : VLD1QWB<{1,1,?,?}, "64", addrmode6align64or128>;
670
671// ...with 3 registers
672class VLD1D3<bits<4> op7_4, string Dt, Operand AddrMode>
673  : NLdSt<0,0b10,0b0110,op7_4, (outs VecListThreeD:$Vd),
674          (ins AddrMode:$Rn), IIC_VLD1x3, "vld1", Dt,
675          "$Vd, $Rn", "", []>, Sched<[WriteVLD3]> {
676  let Rm = 0b1111;
677  let Inst{4} = Rn{4};
678  let DecoderMethod = "DecodeVLDST1Instruction";
679}
680multiclass VLD1D3WB<bits<4> op7_4, string Dt, Operand AddrMode> {
681  def _fixed : NLdSt<0,0b10,0b0110, op7_4, (outs VecListThreeD:$Vd, GPR:$wb),
682                    (ins AddrMode:$Rn), IIC_VLD1x2u,
683                     "vld1", Dt, "$Vd, $Rn!",
684                     "$Rn.addr = $wb", []>, Sched<[WriteVLD3]> {
685    let Rm = 0b1101; // NLdSt will assign to the right encoding bits.
686    let Inst{4} = Rn{4};
687    let DecoderMethod = "DecodeVLDST1Instruction";
688  }
689  def _register : NLdSt<0,0b10,0b0110,op7_4, (outs VecListThreeD:$Vd, GPR:$wb),
690                        (ins AddrMode:$Rn, rGPR:$Rm), IIC_VLD1x2u,
691                        "vld1", Dt, "$Vd, $Rn, $Rm",
692                        "$Rn.addr = $wb", []>, Sched<[WriteVLD3]> {
693    let Inst{4} = Rn{4};
694    let DecoderMethod = "DecodeVLDST1Instruction";
695  }
696}
697
698def VLD1d8T      : VLD1D3<{0,0,0,?}, "8",  addrmode6align64>;
699def VLD1d16T     : VLD1D3<{0,1,0,?}, "16", addrmode6align64>;
700def VLD1d32T     : VLD1D3<{1,0,0,?}, "32", addrmode6align64>;
701def VLD1d64T     : VLD1D3<{1,1,0,?}, "64", addrmode6align64>;
702
703defm VLD1d8Twb  : VLD1D3WB<{0,0,0,?}, "8",  addrmode6align64>;
704defm VLD1d16Twb : VLD1D3WB<{0,1,0,?}, "16", addrmode6align64>;
705defm VLD1d32Twb : VLD1D3WB<{1,0,0,?}, "32", addrmode6align64>;
706defm VLD1d64Twb : VLD1D3WB<{1,1,0,?}, "64", addrmode6align64>;
707
708def VLD1d8TPseudo             : VLDQQPseudo<IIC_VLD1x3>, Sched<[WriteVLD3]>;
709def VLD1d8TPseudoWB_fixed     : VLDQQWBfixedPseudo<IIC_VLD1x3>, Sched<[WriteVLD3]>;
710def VLD1d8TPseudoWB_register  : VLDQQWBregisterPseudo<IIC_VLD1x3>, Sched<[WriteVLD3]>;
711def VLD1d16TPseudo            : VLDQQPseudo<IIC_VLD1x3>, Sched<[WriteVLD3]>;
712def VLD1d16TPseudoWB_fixed    : VLDQQWBfixedPseudo<IIC_VLD1x3>, Sched<[WriteVLD3]>;
713def VLD1d16TPseudoWB_register : VLDQQWBregisterPseudo<IIC_VLD1x3>, Sched<[WriteVLD3]>;
714def VLD1d32TPseudo            : VLDQQPseudo<IIC_VLD1x3>, Sched<[WriteVLD3]>;
715def VLD1d32TPseudoWB_fixed    : VLDQQWBfixedPseudo<IIC_VLD1x3>, Sched<[WriteVLD3]>;
716def VLD1d32TPseudoWB_register : VLDQQWBregisterPseudo<IIC_VLD1x3>, Sched<[WriteVLD3]>;
717def VLD1d64TPseudo            : VLDQQPseudo<IIC_VLD1x3>, Sched<[WriteVLD3]>;
718def VLD1d64TPseudoWB_fixed    : VLDQQWBfixedPseudo<IIC_VLD1x3>, Sched<[WriteVLD3]>;
719def VLD1d64TPseudoWB_register : VLDQQWBregisterPseudo<IIC_VLD1x3>, Sched<[WriteVLD3]>;
720
721def VLD1q8HighTPseudo      : VLDQQQQPseudo<IIC_VLD1x3>, Sched<[WriteVLD3]>;
722def VLD1q8HighTPseudo_UPD  : VLDQQQQWBPseudo<IIC_VLD1x3>, Sched<[WriteVLD3]>;
723def VLD1q8LowTPseudo_UPD   : VLDQQQQWBPseudo<IIC_VLD1x3>, Sched<[WriteVLD3]>;
724def VLD1q16HighTPseudo     : VLDQQQQPseudo<IIC_VLD1x3>, Sched<[WriteVLD3]>;
725def VLD1q16HighTPseudo_UPD : VLDQQQQWBPseudo<IIC_VLD1x3>, Sched<[WriteVLD3]>;
726def VLD1q16LowTPseudo_UPD  : VLDQQQQWBPseudo<IIC_VLD1x3>, Sched<[WriteVLD3]>;
727def VLD1q32HighTPseudo     : VLDQQQQPseudo<IIC_VLD1x3>, Sched<[WriteVLD3]>;
728def VLD1q32HighTPseudo_UPD : VLDQQQQWBPseudo<IIC_VLD1x3>, Sched<[WriteVLD3]>;
729def VLD1q32LowTPseudo_UPD  : VLDQQQQWBPseudo<IIC_VLD1x3>, Sched<[WriteVLD3]>;
730def VLD1q64HighTPseudo     : VLDQQQQPseudo<IIC_VLD1x3>, Sched<[WriteVLD3]>;
731def VLD1q64HighTPseudo_UPD : VLDQQQQWBPseudo<IIC_VLD1x3>, Sched<[WriteVLD3]>;
732def VLD1q64LowTPseudo_UPD  : VLDQQQQWBPseudo<IIC_VLD1x3>, Sched<[WriteVLD3]>;
733
734// ...with 4 registers
735class VLD1D4<bits<4> op7_4, string Dt, Operand AddrMode>
736  : NLdSt<0, 0b10, 0b0010, op7_4, (outs VecListFourD:$Vd),
737          (ins AddrMode:$Rn), IIC_VLD1x4, "vld1", Dt,
738          "$Vd, $Rn", "", []>, Sched<[WriteVLD4]> {
739  let Rm = 0b1111;
740  let Inst{5-4} = Rn{5-4};
741  let DecoderMethod = "DecodeVLDST1Instruction";
742}
743multiclass VLD1D4WB<bits<4> op7_4, string Dt, Operand AddrMode> {
744  def _fixed : NLdSt<0,0b10,0b0010, op7_4, (outs VecListFourD:$Vd, GPR:$wb),
745                    (ins AddrMode:$Rn), IIC_VLD1x2u,
746                     "vld1", Dt, "$Vd, $Rn!",
747                     "$Rn.addr = $wb", []>, Sched<[WriteVLD4]> {
748    let Rm = 0b1101; // NLdSt will assign to the right encoding bits.
749    let Inst{5-4} = Rn{5-4};
750    let DecoderMethod = "DecodeVLDST1Instruction";
751  }
752  def _register : NLdSt<0,0b10,0b0010,op7_4, (outs VecListFourD:$Vd, GPR:$wb),
753                        (ins AddrMode:$Rn, rGPR:$Rm), IIC_VLD1x2u,
754                        "vld1", Dt, "$Vd, $Rn, $Rm",
755                        "$Rn.addr = $wb", []>, Sched<[WriteVLD4]> {
756    let Inst{5-4} = Rn{5-4};
757    let DecoderMethod = "DecodeVLDST1Instruction";
758  }
759}
760
761def VLD1d8Q      : VLD1D4<{0,0,?,?}, "8",  addrmode6align64or128or256>;
762def VLD1d16Q     : VLD1D4<{0,1,?,?}, "16", addrmode6align64or128or256>;
763def VLD1d32Q     : VLD1D4<{1,0,?,?}, "32", addrmode6align64or128or256>;
764def VLD1d64Q     : VLD1D4<{1,1,?,?}, "64", addrmode6align64or128or256>;
765
766defm VLD1d8Qwb   : VLD1D4WB<{0,0,?,?}, "8",  addrmode6align64or128or256>;
767defm VLD1d16Qwb  : VLD1D4WB<{0,1,?,?}, "16", addrmode6align64or128or256>;
768defm VLD1d32Qwb  : VLD1D4WB<{1,0,?,?}, "32", addrmode6align64or128or256>;
769defm VLD1d64Qwb  : VLD1D4WB<{1,1,?,?}, "64", addrmode6align64or128or256>;
770
771def VLD1d8QPseudo             : VLDQQPseudo<IIC_VLD1x4>, Sched<[WriteVLD4]>;
772def VLD1d8QPseudoWB_fixed     : VLDQQWBfixedPseudo<IIC_VLD1x4>, Sched<[WriteVLD4]>;
773def VLD1d8QPseudoWB_register  : VLDQQWBregisterPseudo<IIC_VLD1x4>, Sched<[WriteVLD4]>;
774def VLD1d16QPseudo            : VLDQQPseudo<IIC_VLD1x4>, Sched<[WriteVLD4]>;
775def VLD1d16QPseudoWB_fixed    : VLDQQWBfixedPseudo<IIC_VLD1x4>, Sched<[WriteVLD4]>;
776def VLD1d16QPseudoWB_register : VLDQQWBregisterPseudo<IIC_VLD1x4>, Sched<[WriteVLD4]>;
777def VLD1d32QPseudo            : VLDQQPseudo<IIC_VLD1x4>, Sched<[WriteVLD4]>;
778def VLD1d32QPseudoWB_fixed    : VLDQQWBfixedPseudo<IIC_VLD1x4>, Sched<[WriteVLD4]>;
779def VLD1d32QPseudoWB_register : VLDQQWBregisterPseudo<IIC_VLD1x4>, Sched<[WriteVLD4]>;
780def VLD1d64QPseudo            : VLDQQPseudo<IIC_VLD1x4>, Sched<[WriteVLD4]>;
781def VLD1d64QPseudoWB_fixed    : VLDQQWBfixedPseudo<IIC_VLD1x4>, Sched<[WriteVLD4]>;
782def VLD1d64QPseudoWB_register : VLDQQWBregisterPseudo<IIC_VLD1x4>, Sched<[WriteVLD4]>;
783
784def VLD1q8LowQPseudo_UPD   : VLDQQQQWBPseudo<IIC_VLD1x4>, Sched<[WriteVLD4]>;
785def VLD1q8HighQPseudo      : VLDQQQQPseudo<IIC_VLD1x4>, Sched<[WriteVLD4]>;
786def VLD1q8HighQPseudo_UPD  : VLDQQQQWBPseudo<IIC_VLD1x4>, Sched<[WriteVLD4]>;
787def VLD1q16LowQPseudo_UPD  : VLDQQQQWBPseudo<IIC_VLD1x4>, Sched<[WriteVLD4]>;
788def VLD1q16HighQPseudo     : VLDQQQQPseudo<IIC_VLD1x4>, Sched<[WriteVLD4]>;
789def VLD1q16HighQPseudo_UPD : VLDQQQQWBPseudo<IIC_VLD1x4>, Sched<[WriteVLD4]>;
790def VLD1q32LowQPseudo_UPD  : VLDQQQQWBPseudo<IIC_VLD1x4>, Sched<[WriteVLD4]>;
791def VLD1q32HighQPseudo     : VLDQQQQPseudo<IIC_VLD1x4>, Sched<[WriteVLD4]>;
792def VLD1q32HighQPseudo_UPD : VLDQQQQWBPseudo<IIC_VLD1x4>, Sched<[WriteVLD4]>;
793def VLD1q64LowQPseudo_UPD  : VLDQQQQWBPseudo<IIC_VLD1x4>, Sched<[WriteVLD4]>;
794def VLD1q64HighQPseudo     : VLDQQQQPseudo<IIC_VLD1x4>, Sched<[WriteVLD4]>;
795def VLD1q64HighQPseudo_UPD : VLDQQQQWBPseudo<IIC_VLD1x4>, Sched<[WriteVLD4]>;
796
797//   VLD2     : Vector Load (multiple 2-element structures)
798class VLD2<bits<4> op11_8, bits<4> op7_4, string Dt, RegisterOperand VdTy,
799           InstrItinClass itin, Operand AddrMode>
800  : NLdSt<0, 0b10, op11_8, op7_4, (outs VdTy:$Vd),
801          (ins AddrMode:$Rn), itin,
802          "vld2", Dt, "$Vd, $Rn", "", []> {
803  let Rm = 0b1111;
804  let Inst{5-4} = Rn{5-4};
805  let DecoderMethod = "DecodeVLDST2Instruction";
806}
807
808def  VLD2d8   : VLD2<0b1000, {0,0,?,?}, "8", VecListDPair, IIC_VLD2,
809                     addrmode6align64or128>, Sched<[WriteVLD2]>;
810def  VLD2d16  : VLD2<0b1000, {0,1,?,?}, "16", VecListDPair, IIC_VLD2,
811                     addrmode6align64or128>, Sched<[WriteVLD2]>;
812def  VLD2d32  : VLD2<0b1000, {1,0,?,?}, "32", VecListDPair, IIC_VLD2,
813                     addrmode6align64or128>, Sched<[WriteVLD2]>;
814
815def  VLD2q8   : VLD2<0b0011, {0,0,?,?}, "8", VecListFourD, IIC_VLD2x2,
816                     addrmode6align64or128or256>, Sched<[WriteVLD4]>;
817def  VLD2q16  : VLD2<0b0011, {0,1,?,?}, "16", VecListFourD, IIC_VLD2x2,
818                     addrmode6align64or128or256>, Sched<[WriteVLD4]>;
819def  VLD2q32  : VLD2<0b0011, {1,0,?,?}, "32", VecListFourD, IIC_VLD2x2,
820                     addrmode6align64or128or256>, Sched<[WriteVLD4]>;
821
822def  VLD2q8Pseudo  : VLDQQPseudo<IIC_VLD2x2>, Sched<[WriteVLD4]>;
823def  VLD2q16Pseudo : VLDQQPseudo<IIC_VLD2x2>, Sched<[WriteVLD4]>;
824def  VLD2q32Pseudo : VLDQQPseudo<IIC_VLD2x2>, Sched<[WriteVLD4]>;
825
826// ...with address register writeback:
827multiclass VLD2WB<bits<4> op11_8, bits<4> op7_4, string Dt,
828                  RegisterOperand VdTy, InstrItinClass itin, Operand AddrMode> {
829  def _fixed : NLdSt<0, 0b10, op11_8, op7_4, (outs VdTy:$Vd, GPR:$wb),
830                     (ins AddrMode:$Rn), itin,
831                     "vld2", Dt, "$Vd, $Rn!",
832                     "$Rn.addr = $wb", []> {
833    let Rm = 0b1101; // NLdSt will assign to the right encoding bits.
834    let Inst{5-4} = Rn{5-4};
835    let DecoderMethod = "DecodeVLDST2Instruction";
836  }
837  def _register : NLdSt<0, 0b10, op11_8, op7_4, (outs VdTy:$Vd, GPR:$wb),
838                        (ins AddrMode:$Rn, rGPR:$Rm), itin,
839                        "vld2", Dt, "$Vd, $Rn, $Rm",
840                        "$Rn.addr = $wb", []> {
841    let Inst{5-4} = Rn{5-4};
842    let DecoderMethod = "DecodeVLDST2Instruction";
843  }
844}
845
846defm VLD2d8wb  : VLD2WB<0b1000, {0,0,?,?}, "8", VecListDPair, IIC_VLD2u,
847                        addrmode6align64or128>, Sched<[WriteVLD2]>;
848defm VLD2d16wb : VLD2WB<0b1000, {0,1,?,?}, "16", VecListDPair, IIC_VLD2u,
849                        addrmode6align64or128>, Sched<[WriteVLD2]>;
850defm VLD2d32wb : VLD2WB<0b1000, {1,0,?,?}, "32", VecListDPair, IIC_VLD2u,
851                        addrmode6align64or128>, Sched<[WriteVLD2]>;
852
853defm VLD2q8wb  : VLD2WB<0b0011, {0,0,?,?}, "8", VecListFourD, IIC_VLD2x2u,
854                        addrmode6align64or128or256>, Sched<[WriteVLD4]>;
855defm VLD2q16wb : VLD2WB<0b0011, {0,1,?,?}, "16", VecListFourD, IIC_VLD2x2u,
856                        addrmode6align64or128or256>, Sched<[WriteVLD4]>;
857defm VLD2q32wb : VLD2WB<0b0011, {1,0,?,?}, "32", VecListFourD, IIC_VLD2x2u,
858                        addrmode6align64or128or256>, Sched<[WriteVLD4]>;
859
860def VLD2q8PseudoWB_fixed     : VLDQQWBfixedPseudo<IIC_VLD2x2u>, Sched<[WriteVLD4]>;
861def VLD2q16PseudoWB_fixed    : VLDQQWBfixedPseudo<IIC_VLD2x2u>, Sched<[WriteVLD4]>;
862def VLD2q32PseudoWB_fixed    : VLDQQWBfixedPseudo<IIC_VLD2x2u>, Sched<[WriteVLD4]>;
863def VLD2q8PseudoWB_register  : VLDQQWBregisterPseudo<IIC_VLD2x2u>, Sched<[WriteVLD4]>;
864def VLD2q16PseudoWB_register : VLDQQWBregisterPseudo<IIC_VLD2x2u>, Sched<[WriteVLD4]>;
865def VLD2q32PseudoWB_register : VLDQQWBregisterPseudo<IIC_VLD2x2u>, Sched<[WriteVLD4]>;
866
867// ...with double-spaced registers
868def  VLD2b8    : VLD2<0b1001, {0,0,?,?}, "8", VecListDPairSpaced, IIC_VLD2,
869                      addrmode6align64or128>, Sched<[WriteVLD2]>;
870def  VLD2b16   : VLD2<0b1001, {0,1,?,?}, "16", VecListDPairSpaced, IIC_VLD2,
871                      addrmode6align64or128>, Sched<[WriteVLD2]>;
872def  VLD2b32   : VLD2<0b1001, {1,0,?,?}, "32", VecListDPairSpaced, IIC_VLD2,
873                      addrmode6align64or128>, Sched<[WriteVLD2]>;
874defm VLD2b8wb  : VLD2WB<0b1001, {0,0,?,?}, "8", VecListDPairSpaced, IIC_VLD2u,
875                        addrmode6align64or128>, Sched<[WriteVLD2]>;
876defm VLD2b16wb : VLD2WB<0b1001, {0,1,?,?}, "16", VecListDPairSpaced, IIC_VLD2u,
877                        addrmode6align64or128>, Sched<[WriteVLD2]>;
878defm VLD2b32wb : VLD2WB<0b1001, {1,0,?,?}, "32", VecListDPairSpaced, IIC_VLD2u,
879                        addrmode6align64or128>, Sched<[WriteVLD2]>;
880
881//   VLD3     : Vector Load (multiple 3-element structures)
882class VLD3D<bits<4> op11_8, bits<4> op7_4, string Dt>
883  : NLdSt<0, 0b10, op11_8, op7_4, (outs DPR:$Vd, DPR:$dst2, DPR:$dst3),
884          (ins addrmode6:$Rn), IIC_VLD3,
885          "vld3", Dt, "\\{$Vd, $dst2, $dst3\\}, $Rn", "", []>, Sched<[WriteVLD3]> {
886  let Rm = 0b1111;
887  let Inst{4} = Rn{4};
888  let DecoderMethod = "DecodeVLDST3Instruction";
889}
890
891def  VLD3d8   : VLD3D<0b0100, {0,0,0,?}, "8">;
892def  VLD3d16  : VLD3D<0b0100, {0,1,0,?}, "16">;
893def  VLD3d32  : VLD3D<0b0100, {1,0,0,?}, "32">;
894
895def  VLD3d8Pseudo  : VLDQQPseudo<IIC_VLD3>, Sched<[WriteVLD3]>;
896def  VLD3d16Pseudo : VLDQQPseudo<IIC_VLD3>, Sched<[WriteVLD3]>;
897def  VLD3d32Pseudo : VLDQQPseudo<IIC_VLD3>, Sched<[WriteVLD3]>;
898
899// ...with address register writeback:
900class VLD3DWB<bits<4> op11_8, bits<4> op7_4, string Dt>
901  : NLdSt<0, 0b10, op11_8, op7_4,
902          (outs DPR:$Vd, DPR:$dst2, DPR:$dst3, GPR:$wb),
903          (ins addrmode6:$Rn, am6offset:$Rm), IIC_VLD3u,
904          "vld3", Dt, "\\{$Vd, $dst2, $dst3\\}, $Rn$Rm",
905          "$Rn.addr = $wb", []>, Sched<[WriteVLD3]> {
906  let Inst{4} = Rn{4};
907  let DecoderMethod = "DecodeVLDST3Instruction";
908}
909
910def VLD3d8_UPD  : VLD3DWB<0b0100, {0,0,0,?}, "8">;
911def VLD3d16_UPD : VLD3DWB<0b0100, {0,1,0,?}, "16">;
912def VLD3d32_UPD : VLD3DWB<0b0100, {1,0,0,?}, "32">;
913
914def VLD3d8Pseudo_UPD  : VLDQQWBPseudo<IIC_VLD3u>, Sched<[WriteVLD3]>;
915def VLD3d16Pseudo_UPD : VLDQQWBPseudo<IIC_VLD3u>, Sched<[WriteVLD3]>;
916def VLD3d32Pseudo_UPD : VLDQQWBPseudo<IIC_VLD3u>, Sched<[WriteVLD3]>;
917
918// ...with double-spaced registers:
919def VLD3q8      : VLD3D<0b0101, {0,0,0,?}, "8">;
920def VLD3q16     : VLD3D<0b0101, {0,1,0,?}, "16">;
921def VLD3q32     : VLD3D<0b0101, {1,0,0,?}, "32">;
922def VLD3q8_UPD  : VLD3DWB<0b0101, {0,0,0,?}, "8">;
923def VLD3q16_UPD : VLD3DWB<0b0101, {0,1,0,?}, "16">;
924def VLD3q32_UPD : VLD3DWB<0b0101, {1,0,0,?}, "32">;
925
926def VLD3q8Pseudo_UPD  : VLDQQQQWBPseudo<IIC_VLD3u>, Sched<[WriteVLD3]>;
927def VLD3q16Pseudo_UPD : VLDQQQQWBPseudo<IIC_VLD3u>, Sched<[WriteVLD3]>;
928def VLD3q32Pseudo_UPD : VLDQQQQWBPseudo<IIC_VLD3u>, Sched<[WriteVLD3]>;
929
930// ...alternate versions to be allocated odd register numbers:
931def VLD3q8oddPseudo   : VLDQQQQPseudo<IIC_VLD3>, Sched<[WriteVLD3]>;
932def VLD3q16oddPseudo  : VLDQQQQPseudo<IIC_VLD3>, Sched<[WriteVLD3]>;
933def VLD3q32oddPseudo  : VLDQQQQPseudo<IIC_VLD3>, Sched<[WriteVLD3]>;
934
935def VLD3q8oddPseudo_UPD  : VLDQQQQWBPseudo<IIC_VLD3u>, Sched<[WriteVLD3]>;
936def VLD3q16oddPseudo_UPD : VLDQQQQWBPseudo<IIC_VLD3u>, Sched<[WriteVLD3]>;
937def VLD3q32oddPseudo_UPD : VLDQQQQWBPseudo<IIC_VLD3u>, Sched<[WriteVLD3]>;
938
939//   VLD4     : Vector Load (multiple 4-element structures)
940class VLD4D<bits<4> op11_8, bits<4> op7_4, string Dt>
941  : NLdSt<0, 0b10, op11_8, op7_4,
942          (outs DPR:$Vd, DPR:$dst2, DPR:$dst3, DPR:$dst4),
943          (ins addrmode6:$Rn), IIC_VLD4,
944          "vld4", Dt, "\\{$Vd, $dst2, $dst3, $dst4\\}, $Rn", "", []>,
945    Sched<[WriteVLD4]> {
946  let Rm = 0b1111;
947  let Inst{5-4} = Rn{5-4};
948  let DecoderMethod = "DecodeVLDST4Instruction";
949}
950
951def  VLD4d8   : VLD4D<0b0000, {0,0,?,?}, "8">;
952def  VLD4d16  : VLD4D<0b0000, {0,1,?,?}, "16">;
953def  VLD4d32  : VLD4D<0b0000, {1,0,?,?}, "32">;
954
955def  VLD4d8Pseudo  : VLDQQPseudo<IIC_VLD4>, Sched<[WriteVLD4]>;
956def  VLD4d16Pseudo : VLDQQPseudo<IIC_VLD4>, Sched<[WriteVLD4]>;
957def  VLD4d32Pseudo : VLDQQPseudo<IIC_VLD4>, Sched<[WriteVLD4]>;
958
959// ...with address register writeback:
960class VLD4DWB<bits<4> op11_8, bits<4> op7_4, string Dt>
961  : NLdSt<0, 0b10, op11_8, op7_4,
962          (outs DPR:$Vd, DPR:$dst2, DPR:$dst3, DPR:$dst4, GPR:$wb),
963          (ins addrmode6:$Rn, am6offset:$Rm), IIC_VLD4u,
964          "vld4", Dt, "\\{$Vd, $dst2, $dst3, $dst4\\}, $Rn$Rm",
965          "$Rn.addr = $wb", []>, Sched<[WriteVLD4]> {
966  let Inst{5-4} = Rn{5-4};
967  let DecoderMethod = "DecodeVLDST4Instruction";
968}
969
970def VLD4d8_UPD  : VLD4DWB<0b0000, {0,0,?,?}, "8">;
971def VLD4d16_UPD : VLD4DWB<0b0000, {0,1,?,?}, "16">;
972def VLD4d32_UPD : VLD4DWB<0b0000, {1,0,?,?}, "32">;
973
974def VLD4d8Pseudo_UPD  : VLDQQWBPseudo<IIC_VLD4u>, Sched<[WriteVLD4]>;
975def VLD4d16Pseudo_UPD : VLDQQWBPseudo<IIC_VLD4u>, Sched<[WriteVLD4]>;
976def VLD4d32Pseudo_UPD : VLDQQWBPseudo<IIC_VLD4u>, Sched<[WriteVLD4]>;
977
978// ...with double-spaced registers:
979def VLD4q8      : VLD4D<0b0001, {0,0,?,?}, "8">;
980def VLD4q16     : VLD4D<0b0001, {0,1,?,?}, "16">;
981def VLD4q32     : VLD4D<0b0001, {1,0,?,?}, "32">;
982def VLD4q8_UPD  : VLD4DWB<0b0001, {0,0,?,?}, "8">;
983def VLD4q16_UPD : VLD4DWB<0b0001, {0,1,?,?}, "16">;
984def VLD4q32_UPD : VLD4DWB<0b0001, {1,0,?,?}, "32">;
985
986def VLD4q8Pseudo_UPD  : VLDQQQQWBPseudo<IIC_VLD4u>, Sched<[WriteVLD4]>;
987def VLD4q16Pseudo_UPD : VLDQQQQWBPseudo<IIC_VLD4u>, Sched<[WriteVLD4]>;
988def VLD4q32Pseudo_UPD : VLDQQQQWBPseudo<IIC_VLD4u>, Sched<[WriteVLD4]>;
989
990// ...alternate versions to be allocated odd register numbers:
991def VLD4q8oddPseudo   : VLDQQQQPseudo<IIC_VLD4>, Sched<[WriteVLD4]>;
992def VLD4q16oddPseudo  : VLDQQQQPseudo<IIC_VLD4>, Sched<[WriteVLD4]>;
993def VLD4q32oddPseudo  : VLDQQQQPseudo<IIC_VLD4>, Sched<[WriteVLD4]>;
994
995def VLD4q8oddPseudo_UPD  : VLDQQQQWBPseudo<IIC_VLD4u>, Sched<[WriteVLD4]>;
996def VLD4q16oddPseudo_UPD : VLDQQQQWBPseudo<IIC_VLD4u>, Sched<[WriteVLD4]>;
997def VLD4q32oddPseudo_UPD : VLDQQQQWBPseudo<IIC_VLD4u>, Sched<[WriteVLD4]>;
998
999} // mayLoad = 1, hasSideEffects = 0, hasExtraDefRegAllocReq = 1
1000
1001// Classes for VLD*LN pseudo-instructions with multi-register operands.
1002// These are expanded to real instructions after register allocation.
1003class VLDQLNPseudo<InstrItinClass itin>
1004  : PseudoNLdSt<(outs QPR:$dst),
1005                (ins addrmode6:$addr, QPR:$src, nohash_imm:$lane),
1006                itin, "$src = $dst">;
1007class VLDQLNWBPseudo<InstrItinClass itin>
1008  : PseudoNLdSt<(outs QPR:$dst, GPR:$wb),
1009                (ins addrmode6:$addr, am6offset:$offset, QPR:$src,
1010                 nohash_imm:$lane), itin, "$addr.addr = $wb, $src = $dst">;
1011class VLDQQLNPseudo<InstrItinClass itin>
1012  : PseudoNLdSt<(outs QQPR:$dst),
1013                (ins addrmode6:$addr, QQPR:$src, nohash_imm:$lane),
1014                itin, "$src = $dst">;
1015class VLDQQLNWBPseudo<InstrItinClass itin>
1016  : PseudoNLdSt<(outs QQPR:$dst, GPR:$wb),
1017                (ins addrmode6:$addr, am6offset:$offset, QQPR:$src,
1018                 nohash_imm:$lane), itin, "$addr.addr = $wb, $src = $dst">;
1019class VLDQQQQLNPseudo<InstrItinClass itin>
1020  : PseudoNLdSt<(outs QQQQPR:$dst),
1021                (ins addrmode6:$addr, QQQQPR:$src, nohash_imm:$lane),
1022                itin, "$src = $dst">;
1023class VLDQQQQLNWBPseudo<InstrItinClass itin>
1024  : PseudoNLdSt<(outs QQQQPR:$dst, GPR:$wb),
1025                (ins addrmode6:$addr, am6offset:$offset, QQQQPR:$src,
1026                 nohash_imm:$lane), itin, "$addr.addr = $wb, $src = $dst">;
1027
1028//   VLD1LN   : Vector Load (single element to one lane)
1029class VLD1LN<bits<4> op11_8, bits<4> op7_4, string Dt, ValueType Ty,
1030             PatFrag LoadOp>
1031  : NLdStLn<1, 0b10, op11_8, op7_4, (outs DPR:$Vd),
1032          (ins addrmode6:$Rn, DPR:$src, nohash_imm:$lane),
1033          IIC_VLD1ln, "vld1", Dt, "\\{$Vd[$lane]\\}, $Rn",
1034          "$src = $Vd",
1035          [(set DPR:$Vd, (vector_insert (Ty DPR:$src),
1036                                         (i32 (LoadOp addrmode6:$Rn)),
1037                                         imm:$lane))]> {
1038  let Rm = 0b1111;
1039  let DecoderMethod = "DecodeVLD1LN";
1040}
1041class VLD1LN32<bits<4> op11_8, bits<4> op7_4, string Dt, ValueType Ty,
1042             PatFrag LoadOp>
1043  : NLdStLn<1, 0b10, op11_8, op7_4, (outs DPR:$Vd),
1044          (ins addrmode6oneL32:$Rn, DPR:$src, nohash_imm:$lane),
1045          IIC_VLD1ln, "vld1", Dt, "\\{$Vd[$lane]\\}, $Rn",
1046          "$src = $Vd",
1047          [(set DPR:$Vd, (vector_insert (Ty DPR:$src),
1048                                         (i32 (LoadOp addrmode6oneL32:$Rn)),
1049                                         imm:$lane))]>, Sched<[WriteVLD1]> {
1050  let Rm = 0b1111;
1051  let DecoderMethod = "DecodeVLD1LN";
1052}
1053class VLD1QLNPseudo<ValueType Ty, PatFrag LoadOp> : VLDQLNPseudo<IIC_VLD1ln>,
1054                                                    Sched<[WriteVLD1]> {
1055  let Pattern = [(set QPR:$dst, (vector_insert (Ty QPR:$src),
1056                                               (i32 (LoadOp addrmode6:$addr)),
1057                                               imm:$lane))];
1058}
1059
1060def VLD1LNd8  : VLD1LN<0b0000, {?,?,?,0}, "8", v8i8, extloadi8> {
1061  let Inst{7-5} = lane{2-0};
1062}
1063def VLD1LNd16 : VLD1LN<0b0100, {?,?,0,?}, "16", v4i16, extloadi16> {
1064  let Inst{7-6} = lane{1-0};
1065  let Inst{5-4} = Rn{5-4};
1066}
1067def VLD1LNd32 : VLD1LN32<0b1000, {?,0,?,?}, "32", v2i32, load> {
1068  let Inst{7} = lane{0};
1069  let Inst{5-4} = Rn{5-4};
1070}
1071
1072def VLD1LNq8Pseudo  : VLD1QLNPseudo<v16i8, extloadi8>;
1073def VLD1LNq16Pseudo : VLD1QLNPseudo<v8i16, extloadi16>;
1074def VLD1LNq32Pseudo : VLD1QLNPseudo<v4i32, load>;
1075
1076let Predicates = [HasNEON] in {
1077def : Pat<(vector_insert (v4f16 DPR:$src),
1078                         (f16 (load addrmode6:$addr)), imm:$lane),
1079          (VLD1LNd16 addrmode6:$addr, DPR:$src, imm:$lane)>;
1080def : Pat<(vector_insert (v8f16 QPR:$src),
1081                         (f16 (load addrmode6:$addr)), imm:$lane),
1082          (VLD1LNq16Pseudo addrmode6:$addr, QPR:$src, imm:$lane)>;
1083def : Pat<(vector_insert (v4bf16 DPR:$src),
1084                         (bf16 (load addrmode6:$addr)), imm:$lane),
1085          (VLD1LNd16 addrmode6:$addr, DPR:$src, imm:$lane)>;
1086def : Pat<(vector_insert (v8bf16 QPR:$src),
1087                         (bf16 (load addrmode6:$addr)), imm:$lane),
1088          (VLD1LNq16Pseudo addrmode6:$addr, QPR:$src, imm:$lane)>;
1089def : Pat<(vector_insert (v2f32 DPR:$src),
1090                         (f32 (load addrmode6:$addr)), imm:$lane),
1091          (VLD1LNd32 addrmode6:$addr, DPR:$src, imm:$lane)>;
1092def : Pat<(vector_insert (v4f32 QPR:$src),
1093                         (f32 (load addrmode6:$addr)), imm:$lane),
1094          (VLD1LNq32Pseudo addrmode6:$addr, QPR:$src, imm:$lane)>;
1095
1096// A 64-bit subvector insert to the first 128-bit vector position
1097// is a subregister copy that needs no instruction.
1098def : Pat<(insert_subvector undef, (v1i64 DPR:$src), (i32 0)),
1099          (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)), DPR:$src, dsub_0)>;
1100def : Pat<(insert_subvector undef, (v2i32 DPR:$src), (i32 0)),
1101          (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), DPR:$src, dsub_0)>;
1102def : Pat<(insert_subvector undef, (v2f32 DPR:$src), (i32 0)),
1103          (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), DPR:$src, dsub_0)>;
1104def : Pat<(insert_subvector undef, (v4i16 DPR:$src), (i32 0)),
1105          (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)), DPR:$src, dsub_0)>;
1106def : Pat<(insert_subvector undef, (v4f16 DPR:$src), (i32 0)),
1107          (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), DPR:$src, dsub_0)>;
1108def : Pat<(insert_subvector (v16i8 undef), (v8i8 DPR:$src), (i32 0)),
1109          (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)), DPR:$src, dsub_0)>;
1110}
1111
1112
1113let mayLoad = 1, hasSideEffects = 0, hasExtraDefRegAllocReq = 1 in {
1114
1115// ...with address register writeback:
1116class VLD1LNWB<bits<4> op11_8, bits<4> op7_4, string Dt>
1117  : NLdStLn<1, 0b10, op11_8, op7_4, (outs DPR:$Vd, GPR:$wb),
1118          (ins addrmode6:$Rn, am6offset:$Rm,
1119           DPR:$src, nohash_imm:$lane), IIC_VLD1lnu, "vld1", Dt,
1120          "\\{$Vd[$lane]\\}, $Rn$Rm",
1121          "$src = $Vd, $Rn.addr = $wb", []>, Sched<[WriteVLD1]> {
1122  let DecoderMethod = "DecodeVLD1LN";
1123}
1124
1125def VLD1LNd8_UPD  : VLD1LNWB<0b0000, {?,?,?,0}, "8"> {
1126  let Inst{7-5} = lane{2-0};
1127}
1128def VLD1LNd16_UPD : VLD1LNWB<0b0100, {?,?,0,?}, "16"> {
1129  let Inst{7-6} = lane{1-0};
1130  let Inst{4}   = Rn{4};
1131}
1132def VLD1LNd32_UPD : VLD1LNWB<0b1000, {?,0,?,?}, "32"> {
1133  let Inst{7} = lane{0};
1134  let Inst{5} = Rn{4};
1135  let Inst{4} = Rn{4};
1136}
1137
1138def VLD1LNq8Pseudo_UPD  : VLDQLNWBPseudo<IIC_VLD1lnu>, Sched<[WriteVLD1]>;
1139def VLD1LNq16Pseudo_UPD : VLDQLNWBPseudo<IIC_VLD1lnu>, Sched<[WriteVLD1]>;
1140def VLD1LNq32Pseudo_UPD : VLDQLNWBPseudo<IIC_VLD1lnu>, Sched<[WriteVLD1]>;
1141
1142//   VLD2LN   : Vector Load (single 2-element structure to one lane)
1143class VLD2LN<bits<4> op11_8, bits<4> op7_4, string Dt>
1144  : NLdStLn<1, 0b10, op11_8, op7_4, (outs DPR:$Vd, DPR:$dst2),
1145          (ins addrmode6:$Rn, DPR:$src1, DPR:$src2, nohash_imm:$lane),
1146          IIC_VLD2ln, "vld2", Dt, "\\{$Vd[$lane], $dst2[$lane]\\}, $Rn",
1147          "$src1 = $Vd, $src2 = $dst2", []>, Sched<[WriteVLD1]> {
1148  let Rm = 0b1111;
1149  let Inst{4}   = Rn{4};
1150  let DecoderMethod = "DecodeVLD2LN";
1151}
1152
1153def VLD2LNd8  : VLD2LN<0b0001, {?,?,?,?}, "8"> {
1154  let Inst{7-5} = lane{2-0};
1155}
1156def VLD2LNd16 : VLD2LN<0b0101, {?,?,0,?}, "16"> {
1157  let Inst{7-6} = lane{1-0};
1158}
1159def VLD2LNd32 : VLD2LN<0b1001, {?,0,0,?}, "32"> {
1160  let Inst{7} = lane{0};
1161}
1162
1163def VLD2LNd8Pseudo  : VLDQLNPseudo<IIC_VLD2ln>, Sched<[WriteVLD1]>;
1164def VLD2LNd16Pseudo : VLDQLNPseudo<IIC_VLD2ln>, Sched<[WriteVLD1]>;
1165def VLD2LNd32Pseudo : VLDQLNPseudo<IIC_VLD2ln>, Sched<[WriteVLD1]>;
1166
1167// ...with double-spaced registers:
1168def VLD2LNq16 : VLD2LN<0b0101, {?,?,1,?}, "16"> {
1169  let Inst{7-6} = lane{1-0};
1170}
1171def VLD2LNq32 : VLD2LN<0b1001, {?,1,0,?}, "32"> {
1172  let Inst{7} = lane{0};
1173}
1174
1175def VLD2LNq16Pseudo : VLDQQLNPseudo<IIC_VLD2ln>, Sched<[WriteVLD1]>;
1176def VLD2LNq32Pseudo : VLDQQLNPseudo<IIC_VLD2ln>, Sched<[WriteVLD1]>;
1177
1178// ...with address register writeback:
1179class VLD2LNWB<bits<4> op11_8, bits<4> op7_4, string Dt>
1180  : NLdStLn<1, 0b10, op11_8, op7_4, (outs DPR:$Vd, DPR:$dst2, GPR:$wb),
1181          (ins addrmode6:$Rn, am6offset:$Rm,
1182           DPR:$src1, DPR:$src2, nohash_imm:$lane), IIC_VLD2lnu, "vld2", Dt,
1183          "\\{$Vd[$lane], $dst2[$lane]\\}, $Rn$Rm",
1184          "$src1 = $Vd, $src2 = $dst2, $Rn.addr = $wb", []> {
1185  let Inst{4}   = Rn{4};
1186  let DecoderMethod = "DecodeVLD2LN";
1187}
1188
1189def VLD2LNd8_UPD  : VLD2LNWB<0b0001, {?,?,?,?}, "8"> {
1190  let Inst{7-5} = lane{2-0};
1191}
1192def VLD2LNd16_UPD : VLD2LNWB<0b0101, {?,?,0,?}, "16"> {
1193  let Inst{7-6} = lane{1-0};
1194}
1195def VLD2LNd32_UPD : VLD2LNWB<0b1001, {?,0,0,?}, "32"> {
1196  let Inst{7} = lane{0};
1197}
1198
1199def VLD2LNd8Pseudo_UPD  : VLDQLNWBPseudo<IIC_VLD2lnu>, Sched<[WriteVLD1]>;
1200def VLD2LNd16Pseudo_UPD : VLDQLNWBPseudo<IIC_VLD2lnu>, Sched<[WriteVLD1]>;
1201def VLD2LNd32Pseudo_UPD : VLDQLNWBPseudo<IIC_VLD2lnu>, Sched<[WriteVLD1]>;
1202
1203def VLD2LNq16_UPD : VLD2LNWB<0b0101, {?,?,1,?}, "16"> {
1204  let Inst{7-6} = lane{1-0};
1205}
1206def VLD2LNq32_UPD : VLD2LNWB<0b1001, {?,1,0,?}, "32"> {
1207  let Inst{7} = lane{0};
1208}
1209
1210def VLD2LNq16Pseudo_UPD : VLDQQLNWBPseudo<IIC_VLD2lnu>, Sched<[WriteVLD1]>;
1211def VLD2LNq32Pseudo_UPD : VLDQQLNWBPseudo<IIC_VLD2lnu>, Sched<[WriteVLD1]>;
1212
1213//   VLD3LN   : Vector Load (single 3-element structure to one lane)
1214class VLD3LN<bits<4> op11_8, bits<4> op7_4, string Dt>
1215  : NLdStLn<1, 0b10, op11_8, op7_4, (outs DPR:$Vd, DPR:$dst2, DPR:$dst3),
1216          (ins addrmode6:$Rn, DPR:$src1, DPR:$src2, DPR:$src3,
1217          nohash_imm:$lane), IIC_VLD3ln, "vld3", Dt,
1218          "\\{$Vd[$lane], $dst2[$lane], $dst3[$lane]\\}, $Rn",
1219          "$src1 = $Vd, $src2 = $dst2, $src3 = $dst3", []>, Sched<[WriteVLD2]> {
1220  let Rm = 0b1111;
1221  let DecoderMethod = "DecodeVLD3LN";
1222}
1223
1224def VLD3LNd8  : VLD3LN<0b0010, {?,?,?,0}, "8"> {
1225  let Inst{7-5} = lane{2-0};
1226}
1227def VLD3LNd16 : VLD3LN<0b0110, {?,?,0,0}, "16"> {
1228  let Inst{7-6} = lane{1-0};
1229}
1230def VLD3LNd32 : VLD3LN<0b1010, {?,0,0,0}, "32"> {
1231  let Inst{7}   = lane{0};
1232}
1233
1234def VLD3LNd8Pseudo  : VLDQQLNPseudo<IIC_VLD3ln>, Sched<[WriteVLD2]>;
1235def VLD3LNd16Pseudo : VLDQQLNPseudo<IIC_VLD3ln>, Sched<[WriteVLD2]>;
1236def VLD3LNd32Pseudo : VLDQQLNPseudo<IIC_VLD3ln>, Sched<[WriteVLD2]>;
1237
1238// ...with double-spaced registers:
1239def VLD3LNq16 : VLD3LN<0b0110, {?,?,1,0}, "16"> {
1240  let Inst{7-6} = lane{1-0};
1241}
1242def VLD3LNq32 : VLD3LN<0b1010, {?,1,0,0}, "32"> {
1243  let Inst{7}   = lane{0};
1244}
1245
1246def VLD3LNq16Pseudo : VLDQQQQLNPseudo<IIC_VLD3ln>, Sched<[WriteVLD2]>;
1247def VLD3LNq32Pseudo : VLDQQQQLNPseudo<IIC_VLD3ln>, Sched<[WriteVLD2]>;
1248
1249// ...with address register writeback:
1250class VLD3LNWB<bits<4> op11_8, bits<4> op7_4, string Dt>
1251  : NLdStLn<1, 0b10, op11_8, op7_4,
1252          (outs DPR:$Vd, DPR:$dst2, DPR:$dst3, GPR:$wb),
1253          (ins addrmode6:$Rn, am6offset:$Rm,
1254           DPR:$src1, DPR:$src2, DPR:$src3, nohash_imm:$lane),
1255          IIC_VLD3lnu, "vld3", Dt,
1256          "\\{$Vd[$lane], $dst2[$lane], $dst3[$lane]\\}, $Rn$Rm",
1257          "$src1 = $Vd, $src2 = $dst2, $src3 = $dst3, $Rn.addr = $wb",
1258          []>, Sched<[WriteVLD2]> {
1259  let DecoderMethod = "DecodeVLD3LN";
1260}
1261
1262def VLD3LNd8_UPD  : VLD3LNWB<0b0010, {?,?,?,0}, "8"> {
1263  let Inst{7-5} = lane{2-0};
1264}
1265def VLD3LNd16_UPD : VLD3LNWB<0b0110, {?,?,0,0}, "16"> {
1266  let Inst{7-6} = lane{1-0};
1267}
1268def VLD3LNd32_UPD : VLD3LNWB<0b1010, {?,0,0,0}, "32"> {
1269  let Inst{7} = lane{0};
1270}
1271
1272def VLD3LNd8Pseudo_UPD  : VLDQQLNWBPseudo<IIC_VLD3lnu>, Sched<[WriteVLD2]>;
1273def VLD3LNd16Pseudo_UPD : VLDQQLNWBPseudo<IIC_VLD3lnu>, Sched<[WriteVLD2]>;
1274def VLD3LNd32Pseudo_UPD : VLDQQLNWBPseudo<IIC_VLD3lnu>, Sched<[WriteVLD2]>;
1275
1276def VLD3LNq16_UPD : VLD3LNWB<0b0110, {?,?,1,0}, "16"> {
1277  let Inst{7-6} = lane{1-0};
1278}
1279def VLD3LNq32_UPD : VLD3LNWB<0b1010, {?,1,0,0}, "32"> {
1280  let Inst{7} = lane{0};
1281}
1282
1283def VLD3LNq16Pseudo_UPD : VLDQQQQLNWBPseudo<IIC_VLD3lnu>, Sched<[WriteVLD2]>;
1284def VLD3LNq32Pseudo_UPD : VLDQQQQLNWBPseudo<IIC_VLD3lnu>, Sched<[WriteVLD2]>;
1285
1286//   VLD4LN   : Vector Load (single 4-element structure to one lane)
1287class VLD4LN<bits<4> op11_8, bits<4> op7_4, string Dt>
1288  : NLdStLn<1, 0b10, op11_8, op7_4,
1289          (outs DPR:$Vd, DPR:$dst2, DPR:$dst3, DPR:$dst4),
1290          (ins addrmode6:$Rn, DPR:$src1, DPR:$src2, DPR:$src3, DPR:$src4,
1291          nohash_imm:$lane), IIC_VLD4ln, "vld4", Dt,
1292          "\\{$Vd[$lane], $dst2[$lane], $dst3[$lane], $dst4[$lane]\\}, $Rn",
1293          "$src1 = $Vd, $src2 = $dst2, $src3 = $dst3, $src4 = $dst4", []>,
1294    Sched<[WriteVLD2]> {
1295  let Rm = 0b1111;
1296  let Inst{4} = Rn{4};
1297  let DecoderMethod = "DecodeVLD4LN";
1298}
1299
1300def VLD4LNd8  : VLD4LN<0b0011, {?,?,?,?}, "8"> {
1301  let Inst{7-5} = lane{2-0};
1302}
1303def VLD4LNd16 : VLD4LN<0b0111, {?,?,0,?}, "16"> {
1304  let Inst{7-6} = lane{1-0};
1305}
1306def VLD4LNd32 : VLD4LN<0b1011, {?,0,?,?}, "32"> {
1307  let Inst{7} = lane{0};
1308  let Inst{5} = Rn{5};
1309}
1310
1311def VLD4LNd8Pseudo  : VLDQQLNPseudo<IIC_VLD4ln>, Sched<[WriteVLD2]>;
1312def VLD4LNd16Pseudo : VLDQQLNPseudo<IIC_VLD4ln>, Sched<[WriteVLD2]>;
1313def VLD4LNd32Pseudo : VLDQQLNPseudo<IIC_VLD4ln>, Sched<[WriteVLD2]>;
1314
1315// ...with double-spaced registers:
1316def VLD4LNq16 : VLD4LN<0b0111, {?,?,1,?}, "16"> {
1317  let Inst{7-6} = lane{1-0};
1318}
1319def VLD4LNq32 : VLD4LN<0b1011, {?,1,?,?}, "32"> {
1320  let Inst{7} = lane{0};
1321  let Inst{5} = Rn{5};
1322}
1323
1324def VLD4LNq16Pseudo : VLDQQQQLNPseudo<IIC_VLD4ln>, Sched<[WriteVLD2]>;
1325def VLD4LNq32Pseudo : VLDQQQQLNPseudo<IIC_VLD4ln>, Sched<[WriteVLD2]>;
1326
1327// ...with address register writeback:
1328class VLD4LNWB<bits<4> op11_8, bits<4> op7_4, string Dt>
1329  : NLdStLn<1, 0b10, op11_8, op7_4,
1330          (outs DPR:$Vd, DPR:$dst2, DPR:$dst3, DPR:$dst4, GPR:$wb),
1331          (ins addrmode6:$Rn, am6offset:$Rm,
1332           DPR:$src1, DPR:$src2, DPR:$src3, DPR:$src4, nohash_imm:$lane),
1333          IIC_VLD4lnu, "vld4", Dt,
1334"\\{$Vd[$lane], $dst2[$lane], $dst3[$lane], $dst4[$lane]\\}, $Rn$Rm",
1335"$src1 = $Vd, $src2 = $dst2, $src3 = $dst3, $src4 = $dst4, $Rn.addr = $wb",
1336          []> {
1337  let Inst{4}   = Rn{4};
1338  let DecoderMethod = "DecodeVLD4LN"  ;
1339}
1340
1341def VLD4LNd8_UPD  : VLD4LNWB<0b0011, {?,?,?,?}, "8"> {
1342  let Inst{7-5} = lane{2-0};
1343}
1344def VLD4LNd16_UPD : VLD4LNWB<0b0111, {?,?,0,?}, "16"> {
1345  let Inst{7-6} = lane{1-0};
1346}
1347def VLD4LNd32_UPD : VLD4LNWB<0b1011, {?,0,?,?}, "32"> {
1348  let Inst{7} = lane{0};
1349  let Inst{5} = Rn{5};
1350}
1351
1352def VLD4LNd8Pseudo_UPD  : VLDQQLNWBPseudo<IIC_VLD4lnu>, Sched<[WriteVLD2]>;
1353def VLD4LNd16Pseudo_UPD : VLDQQLNWBPseudo<IIC_VLD4lnu>, Sched<[WriteVLD2]>;
1354def VLD4LNd32Pseudo_UPD : VLDQQLNWBPseudo<IIC_VLD4lnu>, Sched<[WriteVLD2]>;
1355
1356def VLD4LNq16_UPD : VLD4LNWB<0b0111, {?,?,1,?}, "16"> {
1357  let Inst{7-6} = lane{1-0};
1358}
1359def VLD4LNq32_UPD : VLD4LNWB<0b1011, {?,1,?,?}, "32"> {
1360  let Inst{7} = lane{0};
1361  let Inst{5} = Rn{5};
1362}
1363
1364def VLD4LNq16Pseudo_UPD : VLDQQQQLNWBPseudo<IIC_VLD4lnu>, Sched<[WriteVLD2]>;
1365def VLD4LNq32Pseudo_UPD : VLDQQQQLNWBPseudo<IIC_VLD4lnu>, Sched<[WriteVLD2]>;
1366
1367} // mayLoad = 1, hasSideEffects = 0, hasExtraDefRegAllocReq = 1
1368
1369//   VLD1DUP  : Vector Load (single element to all lanes)
1370class VLD1DUP<bits<4> op7_4, string Dt, ValueType Ty, PatFrag LoadOp,
1371              Operand AddrMode>
1372  : NLdSt<1, 0b10, 0b1100, op7_4, (outs VecListOneDAllLanes:$Vd),
1373          (ins AddrMode:$Rn),
1374          IIC_VLD1dup, "vld1", Dt, "$Vd, $Rn", "",
1375          [(set VecListOneDAllLanes:$Vd,
1376                (Ty (ARMvdup (i32 (LoadOp AddrMode:$Rn)))))]>,
1377   Sched<[WriteVLD2]> {
1378  let Rm = 0b1111;
1379  let Inst{4} = Rn{4};
1380  let DecoderMethod = "DecodeVLD1DupInstruction";
1381}
1382def VLD1DUPd8  : VLD1DUP<{0,0,0,?}, "8", v8i8, extloadi8,
1383                         addrmode6dupalignNone>;
1384def VLD1DUPd16 : VLD1DUP<{0,1,0,?}, "16", v4i16, extloadi16,
1385                         addrmode6dupalign16>;
1386def VLD1DUPd32 : VLD1DUP<{1,0,0,?}, "32", v2i32, load,
1387                         addrmode6dupalign32>;
1388
1389let Predicates = [HasNEON] in {
1390def : Pat<(v2f32 (ARMvdup (f32 (load addrmode6dup:$addr)))),
1391          (VLD1DUPd32 addrmode6:$addr)>;
1392}
1393
1394class VLD1QDUP<bits<4> op7_4, string Dt, ValueType Ty, PatFrag LoadOp,
1395               Operand AddrMode>
1396  : NLdSt<1, 0b10, 0b1100, op7_4, (outs VecListDPairAllLanes:$Vd),
1397          (ins AddrMode:$Rn), IIC_VLD1dup,
1398          "vld1", Dt, "$Vd, $Rn", "",
1399          [(set VecListDPairAllLanes:$Vd,
1400                (Ty (ARMvdup (i32 (LoadOp AddrMode:$Rn)))))]> {
1401  let Rm = 0b1111;
1402  let Inst{4} = Rn{4};
1403  let DecoderMethod = "DecodeVLD1DupInstruction";
1404}
1405
1406def VLD1DUPq8  : VLD1QDUP<{0,0,1,0}, "8", v16i8, extloadi8,
1407                          addrmode6dupalignNone>;
1408def VLD1DUPq16 : VLD1QDUP<{0,1,1,?}, "16", v8i16, extloadi16,
1409                          addrmode6dupalign16>;
1410def VLD1DUPq32 : VLD1QDUP<{1,0,1,?}, "32", v4i32, load,
1411                          addrmode6dupalign32>;
1412
1413let Predicates = [HasNEON] in {
1414def : Pat<(v4f32 (ARMvdup (f32 (load addrmode6dup:$addr)))),
1415          (VLD1DUPq32 addrmode6:$addr)>;
1416}
1417
1418let mayLoad = 1, hasSideEffects = 0, hasExtraDefRegAllocReq = 1 in {
1419// ...with address register writeback:
1420multiclass VLD1DUPWB<bits<4> op7_4, string Dt, Operand AddrMode> {
1421  def _fixed : NLdSt<1, 0b10, 0b1100, op7_4,
1422                     (outs VecListOneDAllLanes:$Vd, GPR:$wb),
1423                     (ins AddrMode:$Rn), IIC_VLD1dupu,
1424                     "vld1", Dt, "$Vd, $Rn!",
1425                     "$Rn.addr = $wb", []> {
1426    let Rm = 0b1101; // NLdSt will assign to the right encoding bits.
1427    let Inst{4} = Rn{4};
1428    let DecoderMethod = "DecodeVLD1DupInstruction";
1429  }
1430  def _register : NLdSt<1, 0b10, 0b1100, op7_4,
1431                        (outs VecListOneDAllLanes:$Vd, GPR:$wb),
1432                        (ins AddrMode:$Rn, rGPR:$Rm), IIC_VLD1dupu,
1433                        "vld1", Dt, "$Vd, $Rn, $Rm",
1434                        "$Rn.addr = $wb", []> {
1435    let Inst{4} = Rn{4};
1436    let DecoderMethod = "DecodeVLD1DupInstruction";
1437  }
1438}
1439multiclass VLD1QDUPWB<bits<4> op7_4, string Dt, Operand AddrMode> {
1440  def _fixed : NLdSt<1, 0b10, 0b1100, op7_4,
1441                     (outs VecListDPairAllLanes:$Vd, GPR:$wb),
1442                     (ins AddrMode:$Rn), IIC_VLD1dupu,
1443                     "vld1", Dt, "$Vd, $Rn!",
1444                     "$Rn.addr = $wb", []>, Sched<[WriteVLD1]> {
1445    let Rm = 0b1101; // NLdSt will assign to the right encoding bits.
1446    let Inst{4} = Rn{4};
1447    let DecoderMethod = "DecodeVLD1DupInstruction";
1448  }
1449  def _register : NLdSt<1, 0b10, 0b1100, op7_4,
1450                        (outs VecListDPairAllLanes:$Vd, GPR:$wb),
1451                        (ins AddrMode:$Rn, rGPR:$Rm), IIC_VLD1dupu,
1452                        "vld1", Dt, "$Vd, $Rn, $Rm",
1453                        "$Rn.addr = $wb", []> {
1454    let Inst{4} = Rn{4};
1455    let DecoderMethod = "DecodeVLD1DupInstruction";
1456  }
1457}
1458
1459defm VLD1DUPd8wb  : VLD1DUPWB<{0,0,0,0}, "8", addrmode6dupalignNone>;
1460defm VLD1DUPd16wb : VLD1DUPWB<{0,1,0,?}, "16", addrmode6dupalign16>;
1461defm VLD1DUPd32wb : VLD1DUPWB<{1,0,0,?}, "32", addrmode6dupalign32>;
1462
1463defm VLD1DUPq8wb  : VLD1QDUPWB<{0,0,1,0}, "8", addrmode6dupalignNone>;
1464defm VLD1DUPq16wb : VLD1QDUPWB<{0,1,1,?}, "16", addrmode6dupalign16>;
1465defm VLD1DUPq32wb : VLD1QDUPWB<{1,0,1,?}, "32", addrmode6dupalign32>;
1466
1467//   VLD2DUP  : Vector Load (single 2-element structure to all lanes)
1468class VLD2DUP<bits<4> op7_4, string Dt, RegisterOperand VdTy, Operand AddrMode>
1469  : NLdSt<1, 0b10, 0b1101, op7_4, (outs VdTy:$Vd),
1470          (ins AddrMode:$Rn), IIC_VLD2dup,
1471          "vld2", Dt, "$Vd, $Rn", "", []> {
1472  let Rm = 0b1111;
1473  let Inst{4} = Rn{4};
1474  let DecoderMethod = "DecodeVLD2DupInstruction";
1475}
1476
1477def VLD2DUPd8  : VLD2DUP<{0,0,0,?}, "8",  VecListDPairAllLanes,
1478                         addrmode6dupalign16>;
1479def VLD2DUPd16 : VLD2DUP<{0,1,0,?}, "16", VecListDPairAllLanes,
1480                         addrmode6dupalign32>;
1481def VLD2DUPd32 : VLD2DUP<{1,0,0,?}, "32", VecListDPairAllLanes,
1482                         addrmode6dupalign64>;
1483
1484// HACK this one, VLD2DUPd8x2 must be changed at the same time with VLD2b8 or
1485// "vld2.8 {d0[], d2[]}, [r4:32]" will become "vld2.8 {d0, d2}, [r4:32]".
1486// ...with double-spaced registers
1487def VLD2DUPd8x2  : VLD2DUP<{0,0,1,?}, "8",  VecListDPairSpacedAllLanes,
1488                           addrmode6dupalign16>;
1489def VLD2DUPd16x2 : VLD2DUP<{0,1,1,?}, "16", VecListDPairSpacedAllLanes,
1490                           addrmode6dupalign32>;
1491def VLD2DUPd32x2 : VLD2DUP<{1,0,1,?}, "32", VecListDPairSpacedAllLanes,
1492                           addrmode6dupalign64>;
1493
1494// Duplicate of VLDQQPseudo but with a constraint variable
1495// to ensure the odd and even lanes use the same register range
1496class VLDQQPseudoInputDST<InstrItinClass itin>
1497  : PseudoNLdSt<(outs QQPR:$dst), (ins addrmode6:$addr, QQPR: $src), itin,
1498                "$src = $dst">;
1499class VLDQQWBPseudoInputDST<InstrItinClass itin>
1500  : PseudoNLdSt<(outs QQPR:$dst, GPR:$wb),
1501                (ins addrmode6:$addr, am6offset:$offset, QQPR: $src), itin,
1502                "$addr.addr = $wb, $src = $dst">;
1503class VLDQQWBfixedPseudoInputDST<InstrItinClass itin>
1504  : PseudoNLdSt<(outs QQPR:$dst, GPR:$wb),
1505                (ins addrmode6:$addr, QQPR: $src), itin,
1506                "$addr.addr = $wb, $src = $dst">;
1507
1508def VLD2DUPq8EvenPseudo  : VLDQQPseudoInputDST<IIC_VLD2dup>, Sched<[WriteVLD2]>;
1509def VLD2DUPq8OddPseudo   : VLDQQPseudoInputDST<IIC_VLD2dup>, Sched<[WriteVLD2]>;
1510def VLD2DUPq16EvenPseudo : VLDQQPseudoInputDST<IIC_VLD2dup>, Sched<[WriteVLD2]>;
1511def VLD2DUPq16OddPseudo  : VLDQQPseudoInputDST<IIC_VLD2dup>, Sched<[WriteVLD2]>;
1512def VLD2DUPq32EvenPseudo : VLDQQPseudoInputDST<IIC_VLD2dup>, Sched<[WriteVLD2]>;
1513def VLD2DUPq32OddPseudo  : VLDQQPseudoInputDST<IIC_VLD2dup>, Sched<[WriteVLD2]>;
1514
1515// ...with address register writeback:
1516multiclass VLD2DUPWB<bits<4> op7_4, string Dt, RegisterOperand VdTy,
1517                     Operand AddrMode> {
1518  def _fixed : NLdSt<1, 0b10, 0b1101, op7_4,
1519                     (outs VdTy:$Vd, GPR:$wb),
1520                     (ins AddrMode:$Rn), IIC_VLD2dupu,
1521                     "vld2", Dt, "$Vd, $Rn!",
1522                     "$Rn.addr = $wb", []>, Sched<[WriteVLD1]> {
1523    let Rm = 0b1101; // NLdSt will assign to the right encoding bits.
1524    let Inst{4} = Rn{4};
1525    let DecoderMethod = "DecodeVLD2DupInstruction";
1526  }
1527  def _register : NLdSt<1, 0b10, 0b1101, op7_4,
1528                        (outs VdTy:$Vd, GPR:$wb),
1529                        (ins AddrMode:$Rn, rGPR:$Rm), IIC_VLD2dupu,
1530                        "vld2", Dt, "$Vd, $Rn, $Rm",
1531                        "$Rn.addr = $wb", []>, Sched<[WriteVLD1]> {
1532    let Inst{4} = Rn{4};
1533    let DecoderMethod = "DecodeVLD2DupInstruction";
1534  }
1535}
1536
1537defm VLD2DUPd8wb    : VLD2DUPWB<{0,0,0,0}, "8",  VecListDPairAllLanes,
1538                                addrmode6dupalign16>;
1539defm VLD2DUPd16wb   : VLD2DUPWB<{0,1,0,?}, "16", VecListDPairAllLanes,
1540                                addrmode6dupalign32>;
1541defm VLD2DUPd32wb   : VLD2DUPWB<{1,0,0,?}, "32", VecListDPairAllLanes,
1542                                addrmode6dupalign64>;
1543
1544defm VLD2DUPd8x2wb  : VLD2DUPWB<{0,0,1,0}, "8",  VecListDPairSpacedAllLanes,
1545                                addrmode6dupalign16>;
1546defm VLD2DUPd16x2wb : VLD2DUPWB<{0,1,1,?}, "16", VecListDPairSpacedAllLanes,
1547                                addrmode6dupalign32>;
1548defm VLD2DUPd32x2wb : VLD2DUPWB<{1,0,1,?}, "32", VecListDPairSpacedAllLanes,
1549                                addrmode6dupalign64>;
1550
1551def VLD2DUPq8OddPseudoWB_fixed     : VLDQQWBfixedPseudoInputDST<IIC_VLD2dup>, Sched<[WriteVLD2]>;
1552def VLD2DUPq16OddPseudoWB_fixed    : VLDQQWBfixedPseudoInputDST<IIC_VLD2dup>, Sched<[WriteVLD2]>;
1553def VLD2DUPq32OddPseudoWB_fixed    : VLDQQWBfixedPseudoInputDST<IIC_VLD2dup>, Sched<[WriteVLD2]>;
1554def VLD2DUPq8OddPseudoWB_register  : VLDQQWBPseudoInputDST<IIC_VLD2dup>, Sched<[WriteVLD2]>;
1555def VLD2DUPq16OddPseudoWB_register : VLDQQWBPseudoInputDST<IIC_VLD2dup>, Sched<[WriteVLD2]>;
1556def VLD2DUPq32OddPseudoWB_register : VLDQQWBPseudoInputDST<IIC_VLD2dup>, Sched<[WriteVLD2]>;
1557
1558//   VLD3DUP  : Vector Load (single 3-element structure to all lanes)
1559class VLD3DUP<bits<4> op7_4, string Dt>
1560  : NLdSt<1, 0b10, 0b1110, op7_4, (outs DPR:$Vd, DPR:$dst2, DPR:$dst3),
1561          (ins addrmode6dup:$Rn), IIC_VLD3dup,
1562          "vld3", Dt, "\\{$Vd[], $dst2[], $dst3[]\\}, $Rn", "", []>,
1563    Sched<[WriteVLD2]> {
1564  let Rm = 0b1111;
1565  let Inst{4} = 0;
1566  let DecoderMethod = "DecodeVLD3DupInstruction";
1567}
1568
1569def VLD3DUPd8  : VLD3DUP<{0,0,0,?}, "8">;
1570def VLD3DUPd16 : VLD3DUP<{0,1,0,?}, "16">;
1571def VLD3DUPd32 : VLD3DUP<{1,0,0,?}, "32">;
1572
1573def VLD3DUPd8Pseudo  : VLDQQPseudo<IIC_VLD3dup>, Sched<[WriteVLD2]>;
1574def VLD3DUPd16Pseudo : VLDQQPseudo<IIC_VLD3dup>, Sched<[WriteVLD2]>;
1575def VLD3DUPd32Pseudo : VLDQQPseudo<IIC_VLD3dup>, Sched<[WriteVLD2]>;
1576
1577// ...with double-spaced registers (not used for codegen):
1578def VLD3DUPq8  : VLD3DUP<{0,0,1,?}, "8">;
1579def VLD3DUPq16 : VLD3DUP<{0,1,1,?}, "16">;
1580def VLD3DUPq32 : VLD3DUP<{1,0,1,?}, "32">;
1581
1582def VLD3DUPq8EvenPseudo  : VLDQQQQPseudo<IIC_VLD3dup>, Sched<[WriteVLD2]>;
1583def VLD3DUPq8OddPseudo   : VLDQQQQPseudo<IIC_VLD3dup>, Sched<[WriteVLD2]>;
1584def VLD3DUPq16EvenPseudo : VLDQQQQPseudo<IIC_VLD3dup>, Sched<[WriteVLD2]>;
1585def VLD3DUPq16OddPseudo  : VLDQQQQPseudo<IIC_VLD3dup>, Sched<[WriteVLD2]>;
1586def VLD3DUPq32EvenPseudo : VLDQQQQPseudo<IIC_VLD3dup>, Sched<[WriteVLD2]>;
1587def VLD3DUPq32OddPseudo  : VLDQQQQPseudo<IIC_VLD3dup>, Sched<[WriteVLD2]>;
1588
1589// ...with address register writeback:
1590class VLD3DUPWB<bits<4> op7_4, string Dt, Operand AddrMode>
1591  : NLdSt<1, 0b10, 0b1110, op7_4, (outs DPR:$Vd, DPR:$dst2, DPR:$dst3, GPR:$wb),
1592          (ins AddrMode:$Rn, am6offset:$Rm), IIC_VLD3dupu,
1593          "vld3", Dt, "\\{$Vd[], $dst2[], $dst3[]\\}, $Rn$Rm",
1594          "$Rn.addr = $wb", []>, Sched<[WriteVLD2]> {
1595  let Inst{4} = 0;
1596  let DecoderMethod = "DecodeVLD3DupInstruction";
1597}
1598
1599def VLD3DUPd8_UPD  : VLD3DUPWB<{0,0,0,0}, "8",  addrmode6dupalign64>;
1600def VLD3DUPd16_UPD : VLD3DUPWB<{0,1,0,?}, "16", addrmode6dupalign64>;
1601def VLD3DUPd32_UPD : VLD3DUPWB<{1,0,0,?}, "32", addrmode6dupalign64>;
1602
1603def VLD3DUPq8_UPD  : VLD3DUPWB<{0,0,1,0}, "8",  addrmode6dupalign64>;
1604def VLD3DUPq16_UPD : VLD3DUPWB<{0,1,1,?}, "16", addrmode6dupalign64>;
1605def VLD3DUPq32_UPD : VLD3DUPWB<{1,0,1,?}, "32", addrmode6dupalign64>;
1606
1607def VLD3DUPd8Pseudo_UPD  : VLDQQWBPseudo<IIC_VLD3dupu>, Sched<[WriteVLD2]>;
1608def VLD3DUPd16Pseudo_UPD : VLDQQWBPseudo<IIC_VLD3dupu>, Sched<[WriteVLD2]>;
1609def VLD3DUPd32Pseudo_UPD : VLDQQWBPseudo<IIC_VLD3dupu>, Sched<[WriteVLD2]>;
1610
1611def VLD3DUPq8OddPseudo_UPD  : VLDQQQQWBPseudo<IIC_VLD3dupu>, Sched<[WriteVLD2]>;
1612def VLD3DUPq16OddPseudo_UPD : VLDQQQQWBPseudo<IIC_VLD3dupu>, Sched<[WriteVLD2]>;
1613def VLD3DUPq32OddPseudo_UPD : VLDQQQQWBPseudo<IIC_VLD3dupu>, Sched<[WriteVLD2]>;
1614
1615//   VLD4DUP  : Vector Load (single 4-element structure to all lanes)
1616class VLD4DUP<bits<4> op7_4, string Dt>
1617  : NLdSt<1, 0b10, 0b1111, op7_4,
1618          (outs DPR:$Vd, DPR:$dst2, DPR:$dst3, DPR:$dst4),
1619          (ins addrmode6dup:$Rn), IIC_VLD4dup,
1620          "vld4", Dt, "\\{$Vd[], $dst2[], $dst3[], $dst4[]\\}, $Rn", "", []> {
1621  let Rm = 0b1111;
1622  let Inst{4} = Rn{4};
1623  let DecoderMethod = "DecodeVLD4DupInstruction";
1624}
1625
1626def VLD4DUPd8  : VLD4DUP<{0,0,0,?}, "8">;
1627def VLD4DUPd16 : VLD4DUP<{0,1,0,?}, "16">;
1628def VLD4DUPd32 : VLD4DUP<{1,?,0,?}, "32"> { let Inst{6} = Rn{5}; }
1629
1630def VLD4DUPd8Pseudo  : VLDQQPseudo<IIC_VLD4dup>, Sched<[WriteVLD2]>;
1631def VLD4DUPd16Pseudo : VLDQQPseudo<IIC_VLD4dup>, Sched<[WriteVLD2]>;
1632def VLD4DUPd32Pseudo : VLDQQPseudo<IIC_VLD4dup>, Sched<[WriteVLD2]>;
1633
1634// ...with double-spaced registers (not used for codegen):
1635def VLD4DUPq8  : VLD4DUP<{0,0,1,?}, "8">;
1636def VLD4DUPq16 : VLD4DUP<{0,1,1,?}, "16">;
1637def VLD4DUPq32 : VLD4DUP<{1,?,1,?}, "32"> { let Inst{6} = Rn{5}; }
1638
1639def VLD4DUPq8EvenPseudo  : VLDQQQQPseudo<IIC_VLD4dup>, Sched<[WriteVLD2]>;
1640def VLD4DUPq8OddPseudo   : VLDQQQQPseudo<IIC_VLD4dup>, Sched<[WriteVLD2]>;
1641def VLD4DUPq16EvenPseudo : VLDQQQQPseudo<IIC_VLD4dup>, Sched<[WriteVLD2]>;
1642def VLD4DUPq16OddPseudo  : VLDQQQQPseudo<IIC_VLD4dup>, Sched<[WriteVLD2]>;
1643def VLD4DUPq32EvenPseudo : VLDQQQQPseudo<IIC_VLD4dup>, Sched<[WriteVLD2]>;
1644def VLD4DUPq32OddPseudo  : VLDQQQQPseudo<IIC_VLD4dup>, Sched<[WriteVLD2]>;
1645
1646// ...with address register writeback:
1647class VLD4DUPWB<bits<4> op7_4, string Dt>
1648  : NLdSt<1, 0b10, 0b1111, op7_4,
1649          (outs DPR:$Vd, DPR:$dst2, DPR:$dst3, DPR:$dst4, GPR:$wb),
1650          (ins addrmode6dup:$Rn, am6offset:$Rm), IIC_VLD4dupu,
1651          "vld4", Dt, "\\{$Vd[], $dst2[], $dst3[], $dst4[]\\}, $Rn$Rm",
1652          "$Rn.addr = $wb", []>, Sched<[WriteVLD2]> {
1653  let Inst{4} = Rn{4};
1654  let DecoderMethod = "DecodeVLD4DupInstruction";
1655}
1656
1657def VLD4DUPd8_UPD  : VLD4DUPWB<{0,0,0,0}, "8">;
1658def VLD4DUPd16_UPD : VLD4DUPWB<{0,1,0,?}, "16">;
1659def VLD4DUPd32_UPD : VLD4DUPWB<{1,?,0,?}, "32"> { let Inst{6} = Rn{5}; }
1660
1661def VLD4DUPq8_UPD  : VLD4DUPWB<{0,0,1,0}, "8">;
1662def VLD4DUPq16_UPD : VLD4DUPWB<{0,1,1,?}, "16">;
1663def VLD4DUPq32_UPD : VLD4DUPWB<{1,?,1,?}, "32"> { let Inst{6} = Rn{5}; }
1664
1665def VLD4DUPd8Pseudo_UPD  : VLDQQWBPseudo<IIC_VLD4dupu>, Sched<[WriteVLD2]>;
1666def VLD4DUPd16Pseudo_UPD : VLDQQWBPseudo<IIC_VLD4dupu>, Sched<[WriteVLD2]>;
1667def VLD4DUPd32Pseudo_UPD : VLDQQWBPseudo<IIC_VLD4dupu>, Sched<[WriteVLD2]>;
1668
1669def VLD4DUPq8OddPseudo_UPD  : VLDQQQQWBPseudo<IIC_VLD4dupu>, Sched<[WriteVLD2]>;
1670def VLD4DUPq16OddPseudo_UPD : VLDQQQQWBPseudo<IIC_VLD4dupu>, Sched<[WriteVLD2]>;
1671def VLD4DUPq32OddPseudo_UPD : VLDQQQQWBPseudo<IIC_VLD4dupu>, Sched<[WriteVLD2]>;
1672
1673} // mayLoad = 1, hasSideEffects = 0, hasExtraDefRegAllocReq = 1
1674
1675let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
1676
1677// Classes for VST* pseudo-instructions with multi-register operands.
1678// These are expanded to real instructions after register allocation.
1679class VSTQPseudo<InstrItinClass itin>
1680  : PseudoNLdSt<(outs), (ins addrmode6:$addr, QPR:$src), itin, "">;
1681class VSTQWBPseudo<InstrItinClass itin>
1682  : PseudoNLdSt<(outs GPR:$wb),
1683                (ins addrmode6:$addr, am6offset:$offset, QPR:$src), itin,
1684                "$addr.addr = $wb">;
1685class VSTQWBfixedPseudo<InstrItinClass itin>
1686  : PseudoNLdSt<(outs GPR:$wb),
1687                (ins addrmode6:$addr, QPR:$src), itin,
1688                "$addr.addr = $wb">;
1689class VSTQWBregisterPseudo<InstrItinClass itin>
1690  : PseudoNLdSt<(outs GPR:$wb),
1691                (ins addrmode6:$addr, rGPR:$offset, QPR:$src), itin,
1692                "$addr.addr = $wb">;
1693class VSTQQPseudo<InstrItinClass itin>
1694  : PseudoNLdSt<(outs), (ins addrmode6:$addr, QQPR:$src), itin, "">;
1695class VSTQQWBPseudo<InstrItinClass itin>
1696  : PseudoNLdSt<(outs GPR:$wb),
1697                (ins addrmode6:$addr, am6offset:$offset, QQPR:$src), itin,
1698                "$addr.addr = $wb">;
1699class VSTQQWBfixedPseudo<InstrItinClass itin>
1700  : PseudoNLdSt<(outs GPR:$wb),
1701                (ins addrmode6:$addr, QQPR:$src), itin,
1702                "$addr.addr = $wb">;
1703class VSTQQWBregisterPseudo<InstrItinClass itin>
1704  : PseudoNLdSt<(outs GPR:$wb),
1705                (ins addrmode6:$addr, rGPR:$offset, QQPR:$src), itin,
1706                "$addr.addr = $wb">;
1707
1708class VSTQQQQPseudo<InstrItinClass itin>
1709  : PseudoNLdSt<(outs), (ins addrmode6:$addr, QQQQPR:$src), itin, "">;
1710class VSTQQQQWBPseudo<InstrItinClass itin>
1711  : PseudoNLdSt<(outs GPR:$wb),
1712                (ins addrmode6:$addr, am6offset:$offset, QQQQPR:$src), itin,
1713                "$addr.addr = $wb">;
1714
1715//   VST1     : Vector Store (multiple single elements)
1716class VST1D<bits<4> op7_4, string Dt, Operand AddrMode>
1717  : NLdSt<0,0b00,0b0111,op7_4, (outs), (ins AddrMode:$Rn, VecListOneD:$Vd),
1718          IIC_VST1, "vst1", Dt, "$Vd, $Rn", "", []>, Sched<[WriteVST1]> {
1719  let Rm = 0b1111;
1720  let Inst{4} = Rn{4};
1721  let DecoderMethod = "DecodeVLDST1Instruction";
1722}
1723class VST1Q<bits<4> op7_4, string Dt, Operand AddrMode>
1724  : NLdSt<0,0b00,0b1010,op7_4, (outs), (ins AddrMode:$Rn, VecListDPair:$Vd),
1725          IIC_VST1x2, "vst1", Dt, "$Vd, $Rn", "", []>, Sched<[WriteVST2]> {
1726  let Rm = 0b1111;
1727  let Inst{5-4} = Rn{5-4};
1728  let DecoderMethod = "DecodeVLDST1Instruction";
1729}
1730
1731def  VST1d8   : VST1D<{0,0,0,?}, "8",  addrmode6align64>;
1732def  VST1d16  : VST1D<{0,1,0,?}, "16", addrmode6align64>;
1733def  VST1d32  : VST1D<{1,0,0,?}, "32", addrmode6align64>;
1734def  VST1d64  : VST1D<{1,1,0,?}, "64", addrmode6align64>;
1735
1736def  VST1q8   : VST1Q<{0,0,?,?}, "8",  addrmode6align64or128>;
1737def  VST1q16  : VST1Q<{0,1,?,?}, "16", addrmode6align64or128>;
1738def  VST1q32  : VST1Q<{1,0,?,?}, "32", addrmode6align64or128>;
1739def  VST1q64  : VST1Q<{1,1,?,?}, "64", addrmode6align64or128>;
1740
1741// ...with address register writeback:
1742multiclass VST1DWB<bits<4> op7_4, string Dt, Operand AddrMode> {
1743  def _fixed : NLdSt<0,0b00, 0b0111,op7_4, (outs GPR:$wb),
1744                     (ins AddrMode:$Rn, VecListOneD:$Vd), IIC_VLD1u,
1745                     "vst1", Dt, "$Vd, $Rn!",
1746                     "$Rn.addr = $wb", []>, Sched<[WriteVST1]> {
1747    let Rm = 0b1101; // NLdSt will assign to the right encoding bits.
1748    let Inst{4} = Rn{4};
1749    let DecoderMethod = "DecodeVLDST1Instruction";
1750  }
1751  def _register : NLdSt<0,0b00,0b0111,op7_4, (outs GPR:$wb),
1752                        (ins AddrMode:$Rn, rGPR:$Rm, VecListOneD:$Vd),
1753                        IIC_VLD1u,
1754                        "vst1", Dt, "$Vd, $Rn, $Rm",
1755                        "$Rn.addr = $wb", []>, Sched<[WriteVST1]> {
1756    let Inst{4} = Rn{4};
1757    let DecoderMethod = "DecodeVLDST1Instruction";
1758  }
1759}
1760multiclass VST1QWB<bits<4> op7_4, string Dt, Operand AddrMode> {
1761  def _fixed : NLdSt<0,0b00,0b1010,op7_4, (outs GPR:$wb),
1762                    (ins AddrMode:$Rn, VecListDPair:$Vd), IIC_VLD1x2u,
1763                     "vst1", Dt, "$Vd, $Rn!",
1764                     "$Rn.addr = $wb", []>, Sched<[WriteVST2]> {
1765    let Rm = 0b1101; // NLdSt will assign to the right encoding bits.
1766    let Inst{5-4} = Rn{5-4};
1767    let DecoderMethod = "DecodeVLDST1Instruction";
1768  }
1769  def _register : NLdSt<0,0b00,0b1010,op7_4, (outs GPR:$wb),
1770                        (ins AddrMode:$Rn, rGPR:$Rm, VecListDPair:$Vd),
1771                        IIC_VLD1x2u,
1772                        "vst1", Dt, "$Vd, $Rn, $Rm",
1773                        "$Rn.addr = $wb", []>, Sched<[WriteVST2]> {
1774    let Inst{5-4} = Rn{5-4};
1775    let DecoderMethod = "DecodeVLDST1Instruction";
1776  }
1777}
1778
1779defm VST1d8wb  : VST1DWB<{0,0,0,?}, "8",  addrmode6align64>;
1780defm VST1d16wb : VST1DWB<{0,1,0,?}, "16", addrmode6align64>;
1781defm VST1d32wb : VST1DWB<{1,0,0,?}, "32", addrmode6align64>;
1782defm VST1d64wb : VST1DWB<{1,1,0,?}, "64", addrmode6align64>;
1783
1784defm VST1q8wb  : VST1QWB<{0,0,?,?}, "8",  addrmode6align64or128>;
1785defm VST1q16wb : VST1QWB<{0,1,?,?}, "16", addrmode6align64or128>;
1786defm VST1q32wb : VST1QWB<{1,0,?,?}, "32", addrmode6align64or128>;
1787defm VST1q64wb : VST1QWB<{1,1,?,?}, "64", addrmode6align64or128>;
1788
1789// ...with 3 registers
1790class VST1D3<bits<4> op7_4, string Dt, Operand AddrMode>
1791  : NLdSt<0, 0b00, 0b0110, op7_4, (outs),
1792          (ins AddrMode:$Rn, VecListThreeD:$Vd),
1793          IIC_VST1x3, "vst1", Dt, "$Vd, $Rn", "", []>, Sched<[WriteVST3]> {
1794  let Rm = 0b1111;
1795  let Inst{4} = Rn{4};
1796  let DecoderMethod = "DecodeVLDST1Instruction";
1797}
1798multiclass VST1D3WB<bits<4> op7_4, string Dt, Operand AddrMode> {
1799  def _fixed : NLdSt<0,0b00,0b0110,op7_4, (outs GPR:$wb),
1800                    (ins AddrMode:$Rn, VecListThreeD:$Vd), IIC_VLD1x3u,
1801                     "vst1", Dt, "$Vd, $Rn!",
1802                     "$Rn.addr = $wb", []>, Sched<[WriteVST3]> {
1803    let Rm = 0b1101; // NLdSt will assign to the right encoding bits.
1804    let Inst{5-4} = Rn{5-4};
1805    let DecoderMethod = "DecodeVLDST1Instruction";
1806  }
1807  def _register : NLdSt<0,0b00,0b0110,op7_4, (outs GPR:$wb),
1808                        (ins AddrMode:$Rn, rGPR:$Rm, VecListThreeD:$Vd),
1809                        IIC_VLD1x3u,
1810                        "vst1", Dt, "$Vd, $Rn, $Rm",
1811                        "$Rn.addr = $wb", []>, Sched<[WriteVST3]> {
1812    let Inst{5-4} = Rn{5-4};
1813    let DecoderMethod = "DecodeVLDST1Instruction";
1814  }
1815}
1816
1817def VST1d8T     : VST1D3<{0,0,0,?}, "8",  addrmode6align64>;
1818def VST1d16T    : VST1D3<{0,1,0,?}, "16", addrmode6align64>;
1819def VST1d32T    : VST1D3<{1,0,0,?}, "32", addrmode6align64>;
1820def VST1d64T    : VST1D3<{1,1,0,?}, "64", addrmode6align64>;
1821
1822defm VST1d8Twb  : VST1D3WB<{0,0,0,?}, "8",  addrmode6align64>;
1823defm VST1d16Twb : VST1D3WB<{0,1,0,?}, "16", addrmode6align64>;
1824defm VST1d32Twb : VST1D3WB<{1,0,0,?}, "32", addrmode6align64>;
1825defm VST1d64Twb : VST1D3WB<{1,1,0,?}, "64", addrmode6align64>;
1826
1827def VST1d8TPseudo             : VSTQQPseudo<IIC_VST1x3>, Sched<[WriteVST3]>;
1828def VST1d8TPseudoWB_fixed     : VSTQQWBfixedPseudo<IIC_VST1x3u>, Sched<[WriteVST3]>;
1829def VST1d8TPseudoWB_register  : VSTQQWBPseudo<IIC_VST1x3u>, Sched<[WriteVST3]>;
1830def VST1d16TPseudo            : VSTQQPseudo<IIC_VST1x3>, Sched<[WriteVST3]>;
1831def VST1d16TPseudoWB_fixed    : VSTQQWBfixedPseudo<IIC_VST1x3u>, Sched<[WriteVST3]>;
1832def VST1d16TPseudoWB_register : VSTQQWBPseudo<IIC_VST1x3u>, Sched<[WriteVST3]>;
1833def VST1d32TPseudo            : VSTQQPseudo<IIC_VST1x3>, Sched<[WriteVST3]>;
1834def VST1d32TPseudoWB_fixed    : VSTQQWBfixedPseudo<IIC_VST1x3u>, Sched<[WriteVST3]>;
1835def VST1d32TPseudoWB_register : VSTQQWBPseudo<IIC_VST1x3u>, Sched<[WriteVST3]>;
1836def VST1d64TPseudo            : VSTQQPseudo<IIC_VST1x3>, Sched<[WriteVST3]>;
1837def VST1d64TPseudoWB_fixed    : VSTQQWBfixedPseudo<IIC_VST1x3u>, Sched<[WriteVST3]>;
1838def VST1d64TPseudoWB_register : VSTQQWBPseudo<IIC_VST1x3u>, Sched<[WriteVST3]>;
1839
1840def VST1q8HighTPseudo     : VSTQQQQPseudo<IIC_VST1x3>, Sched<[WriteVST3]>;
1841def VST1q16HighTPseudo    : VSTQQQQPseudo<IIC_VST1x3>, Sched<[WriteVST3]>;
1842def VST1q32HighTPseudo    : VSTQQQQPseudo<IIC_VST1x3>, Sched<[WriteVST3]>;
1843def VST1q64HighTPseudo    : VSTQQQQPseudo<IIC_VST1x3>, Sched<[WriteVST3]>;
1844
1845def VST1q8HighTPseudo_UPD  : VSTQQQQWBPseudo<IIC_VST1x3>, Sched<[WriteVST3]>;
1846def VST1q16HighTPseudo_UPD : VSTQQQQWBPseudo<IIC_VST1x3>, Sched<[WriteVST3]>;
1847def VST1q32HighTPseudo_UPD : VSTQQQQWBPseudo<IIC_VST1x3>, Sched<[WriteVST3]>;
1848def VST1q64HighTPseudo_UPD : VSTQQQQWBPseudo<IIC_VST1x3>, Sched<[WriteVST3]>;
1849
1850def VST1q8LowTPseudo_UPD  : VSTQQQQWBPseudo<IIC_VST1x3>, Sched<[WriteVST3]>;
1851def VST1q16LowTPseudo_UPD : VSTQQQQWBPseudo<IIC_VST1x3>, Sched<[WriteVST3]>;
1852def VST1q32LowTPseudo_UPD : VSTQQQQWBPseudo<IIC_VST1x3>, Sched<[WriteVST3]>;
1853def VST1q64LowTPseudo_UPD : VSTQQQQWBPseudo<IIC_VST1x3>, Sched<[WriteVST3]>;
1854
1855// ...with 4 registers
1856class VST1D4<bits<4> op7_4, string Dt, Operand AddrMode>
1857  : NLdSt<0, 0b00, 0b0010, op7_4, (outs),
1858          (ins AddrMode:$Rn, VecListFourD:$Vd),
1859          IIC_VST1x4, "vst1", Dt, "$Vd, $Rn", "",
1860          []>, Sched<[WriteVST4]> {
1861  let Rm = 0b1111;
1862  let Inst{5-4} = Rn{5-4};
1863  let DecoderMethod = "DecodeVLDST1Instruction";
1864}
1865multiclass VST1D4WB<bits<4> op7_4, string Dt, Operand AddrMode> {
1866  def _fixed : NLdSt<0,0b00,0b0010,op7_4, (outs GPR:$wb),
1867                    (ins AddrMode:$Rn, VecListFourD:$Vd), IIC_VLD1x4u,
1868                     "vst1", Dt, "$Vd, $Rn!",
1869                     "$Rn.addr = $wb", []>, Sched<[WriteVST4]> {
1870    let Rm = 0b1101; // NLdSt will assign to the right encoding bits.
1871    let Inst{5-4} = Rn{5-4};
1872    let DecoderMethod = "DecodeVLDST1Instruction";
1873  }
1874  def _register : NLdSt<0,0b00,0b0010,op7_4, (outs GPR:$wb),
1875                        (ins AddrMode:$Rn, rGPR:$Rm, VecListFourD:$Vd),
1876                        IIC_VLD1x4u,
1877                        "vst1", Dt, "$Vd, $Rn, $Rm",
1878                        "$Rn.addr = $wb", []>, Sched<[WriteVST4]> {
1879    let Inst{5-4} = Rn{5-4};
1880    let DecoderMethod = "DecodeVLDST1Instruction";
1881  }
1882}
1883
1884def VST1d8Q     : VST1D4<{0,0,?,?}, "8",  addrmode6align64or128or256>;
1885def VST1d16Q    : VST1D4<{0,1,?,?}, "16", addrmode6align64or128or256>;
1886def VST1d32Q    : VST1D4<{1,0,?,?}, "32", addrmode6align64or128or256>;
1887def VST1d64Q    : VST1D4<{1,1,?,?}, "64", addrmode6align64or128or256>;
1888
1889defm VST1d8Qwb  : VST1D4WB<{0,0,?,?}, "8",  addrmode6align64or128or256>;
1890defm VST1d16Qwb : VST1D4WB<{0,1,?,?}, "16", addrmode6align64or128or256>;
1891defm VST1d32Qwb : VST1D4WB<{1,0,?,?}, "32", addrmode6align64or128or256>;
1892defm VST1d64Qwb : VST1D4WB<{1,1,?,?}, "64", addrmode6align64or128or256>;
1893
1894def VST1d8QPseudo             : VSTQQPseudo<IIC_VST1x4>, Sched<[WriteVST4]>;
1895def VST1d8QPseudoWB_fixed     : VSTQQWBfixedPseudo<IIC_VST1x4u>, Sched<[WriteVST4]>;
1896def VST1d8QPseudoWB_register  : VSTQQWBPseudo<IIC_VST1x4u>, Sched<[WriteVST4]>;
1897def VST1d16QPseudo            : VSTQQPseudo<IIC_VST1x4>, Sched<[WriteVST4]>;
1898def VST1d16QPseudoWB_fixed    : VSTQQWBfixedPseudo<IIC_VST1x4u>, Sched<[WriteVST4]>;
1899def VST1d16QPseudoWB_register : VSTQQWBPseudo<IIC_VST1x4u>, Sched<[WriteVST4]>;
1900def VST1d32QPseudo            : VSTQQPseudo<IIC_VST1x4>, Sched<[WriteVST4]>;
1901def VST1d32QPseudoWB_fixed    : VSTQQWBfixedPseudo<IIC_VST1x4u>, Sched<[WriteVST4]>;
1902def VST1d32QPseudoWB_register : VSTQQWBPseudo<IIC_VST1x4u>, Sched<[WriteVST4]>;
1903def VST1d64QPseudo            : VSTQQPseudo<IIC_VST1x4>, Sched<[WriteVST4]>;
1904def VST1d64QPseudoWB_fixed    : VSTQQWBfixedPseudo<IIC_VST1x4u>, Sched<[WriteVST4]>;
1905def VST1d64QPseudoWB_register : VSTQQWBPseudo<IIC_VST1x4u>, Sched<[WriteVST4]>;
1906
1907def VST1q8HighQPseudo     : VSTQQQQPseudo<IIC_VST1x4>, Sched<[WriteVST4]>;
1908def VST1q16HighQPseudo    : VSTQQQQPseudo<IIC_VST1x4>, Sched<[WriteVST4]>;
1909def VST1q32HighQPseudo    : VSTQQQQPseudo<IIC_VST1x4>, Sched<[WriteVST4]>;
1910def VST1q64HighQPseudo    : VSTQQQQPseudo<IIC_VST1x4>, Sched<[WriteVST4]>;
1911
1912def VST1q8HighQPseudo_UPD  : VSTQQQQWBPseudo<IIC_VST1x4>, Sched<[WriteVST4]>;
1913def VST1q16HighQPseudo_UPD : VSTQQQQWBPseudo<IIC_VST1x4>, Sched<[WriteVST4]>;
1914def VST1q32HighQPseudo_UPD : VSTQQQQWBPseudo<IIC_VST1x4>, Sched<[WriteVST4]>;
1915def VST1q64HighQPseudo_UPD : VSTQQQQWBPseudo<IIC_VST1x4>, Sched<[WriteVST4]>;
1916
1917def VST1q8LowQPseudo_UPD  : VSTQQQQWBPseudo<IIC_VST1x4>, Sched<[WriteVST4]>;
1918def VST1q16LowQPseudo_UPD : VSTQQQQWBPseudo<IIC_VST1x4>, Sched<[WriteVST4]>;
1919def VST1q32LowQPseudo_UPD : VSTQQQQWBPseudo<IIC_VST1x4>, Sched<[WriteVST4]>;
1920def VST1q64LowQPseudo_UPD : VSTQQQQWBPseudo<IIC_VST1x4>, Sched<[WriteVST4]>;
1921
1922//   VST2     : Vector Store (multiple 2-element structures)
1923class VST2<bits<4> op11_8, bits<4> op7_4, string Dt, RegisterOperand VdTy,
1924            InstrItinClass itin, Operand AddrMode>
1925  : NLdSt<0, 0b00, op11_8, op7_4, (outs), (ins AddrMode:$Rn, VdTy:$Vd),
1926          itin, "vst2", Dt, "$Vd, $Rn", "", []> {
1927  let Rm = 0b1111;
1928  let Inst{5-4} = Rn{5-4};
1929  let DecoderMethod = "DecodeVLDST2Instruction";
1930}
1931
1932def  VST2d8   : VST2<0b1000, {0,0,?,?}, "8",  VecListDPair, IIC_VST2,
1933                     addrmode6align64or128>, Sched<[WriteVST2]>;
1934def  VST2d16  : VST2<0b1000, {0,1,?,?}, "16", VecListDPair, IIC_VST2,
1935                     addrmode6align64or128>, Sched<[WriteVST2]>;
1936def  VST2d32  : VST2<0b1000, {1,0,?,?}, "32", VecListDPair, IIC_VST2,
1937                     addrmode6align64or128>, Sched<[WriteVST2]>;
1938
1939def  VST2q8   : VST2<0b0011, {0,0,?,?}, "8",  VecListFourD, IIC_VST2x2,
1940                     addrmode6align64or128or256>, Sched<[WriteVST4]>;
1941def  VST2q16  : VST2<0b0011, {0,1,?,?}, "16", VecListFourD, IIC_VST2x2,
1942                     addrmode6align64or128or256>, Sched<[WriteVST4]>;
1943def  VST2q32  : VST2<0b0011, {1,0,?,?}, "32", VecListFourD, IIC_VST2x2,
1944                     addrmode6align64or128or256>, Sched<[WriteVST4]>;
1945
1946def  VST2q8Pseudo  : VSTQQPseudo<IIC_VST2x2>, Sched<[WriteVST4]>;
1947def  VST2q16Pseudo : VSTQQPseudo<IIC_VST2x2>, Sched<[WriteVST4]>;
1948def  VST2q32Pseudo : VSTQQPseudo<IIC_VST2x2>, Sched<[WriteVST4]>;
1949
1950// ...with address register writeback:
1951multiclass VST2DWB<bits<4> op11_8, bits<4> op7_4, string Dt,
1952                   RegisterOperand VdTy, Operand AddrMode> {
1953  def _fixed : NLdSt<0, 0b00, op11_8, op7_4, (outs GPR:$wb),
1954                     (ins AddrMode:$Rn, VdTy:$Vd), IIC_VLD1u,
1955                     "vst2", Dt, "$Vd, $Rn!",
1956                     "$Rn.addr = $wb", []>, Sched<[WriteVST2]> {
1957    let Rm = 0b1101; // NLdSt will assign to the right encoding bits.
1958    let Inst{5-4} = Rn{5-4};
1959    let DecoderMethod = "DecodeVLDST2Instruction";
1960  }
1961  def _register : NLdSt<0, 0b00, op11_8, op7_4, (outs GPR:$wb),
1962                        (ins AddrMode:$Rn, rGPR:$Rm, VdTy:$Vd), IIC_VLD1u,
1963                        "vst2", Dt, "$Vd, $Rn, $Rm",
1964                        "$Rn.addr = $wb", []>, Sched<[WriteVST2]> {
1965    let Inst{5-4} = Rn{5-4};
1966    let DecoderMethod = "DecodeVLDST2Instruction";
1967  }
1968}
1969multiclass VST2QWB<bits<4> op7_4, string Dt, Operand AddrMode> {
1970  def _fixed : NLdSt<0, 0b00, 0b0011, op7_4, (outs GPR:$wb),
1971                     (ins AddrMode:$Rn, VecListFourD:$Vd), IIC_VLD1u,
1972                     "vst2", Dt, "$Vd, $Rn!",
1973                     "$Rn.addr = $wb", []>, Sched<[WriteVST4]> {
1974    let Rm = 0b1101; // NLdSt will assign to the right encoding bits.
1975    let Inst{5-4} = Rn{5-4};
1976    let DecoderMethod = "DecodeVLDST2Instruction";
1977  }
1978  def _register : NLdSt<0, 0b00, 0b0011, op7_4, (outs GPR:$wb),
1979                        (ins AddrMode:$Rn, rGPR:$Rm, VecListFourD:$Vd),
1980                        IIC_VLD1u,
1981                        "vst2", Dt, "$Vd, $Rn, $Rm",
1982                        "$Rn.addr = $wb", []>, Sched<[WriteVST4]> {
1983    let Inst{5-4} = Rn{5-4};
1984    let DecoderMethod = "DecodeVLDST2Instruction";
1985  }
1986}
1987
1988defm VST2d8wb    : VST2DWB<0b1000, {0,0,?,?}, "8",  VecListDPair,
1989                           addrmode6align64or128>;
1990defm VST2d16wb   : VST2DWB<0b1000, {0,1,?,?}, "16", VecListDPair,
1991                           addrmode6align64or128>;
1992defm VST2d32wb   : VST2DWB<0b1000, {1,0,?,?}, "32", VecListDPair,
1993                           addrmode6align64or128>;
1994
1995defm VST2q8wb    : VST2QWB<{0,0,?,?}, "8", addrmode6align64or128or256>;
1996defm VST2q16wb   : VST2QWB<{0,1,?,?}, "16", addrmode6align64or128or256>;
1997defm VST2q32wb   : VST2QWB<{1,0,?,?}, "32", addrmode6align64or128or256>;
1998
1999def VST2q8PseudoWB_fixed     : VSTQQWBfixedPseudo<IIC_VST2x2u>, Sched<[WriteVST4]>;
2000def VST2q16PseudoWB_fixed    : VSTQQWBfixedPseudo<IIC_VST2x2u>, Sched<[WriteVST4]>;
2001def VST2q32PseudoWB_fixed    : VSTQQWBfixedPseudo<IIC_VST2x2u>, Sched<[WriteVST4]>;
2002def VST2q8PseudoWB_register  : VSTQQWBregisterPseudo<IIC_VST2x2u>, Sched<[WriteVST4]>;
2003def VST2q16PseudoWB_register : VSTQQWBregisterPseudo<IIC_VST2x2u>, Sched<[WriteVST4]>;
2004def VST2q32PseudoWB_register : VSTQQWBregisterPseudo<IIC_VST2x2u>, Sched<[WriteVST4]>;
2005
2006// ...with double-spaced registers
2007def VST2b8      : VST2<0b1001, {0,0,?,?}, "8",  VecListDPairSpaced, IIC_VST2,
2008                      addrmode6align64or128>;
2009def VST2b16     : VST2<0b1001, {0,1,?,?}, "16", VecListDPairSpaced, IIC_VST2,
2010                      addrmode6align64or128>;
2011def VST2b32     : VST2<0b1001, {1,0,?,?}, "32", VecListDPairSpaced, IIC_VST2,
2012                      addrmode6align64or128>;
2013defm VST2b8wb   : VST2DWB<0b1001, {0,0,?,?}, "8",  VecListDPairSpaced,
2014                          addrmode6align64or128>;
2015defm VST2b16wb  : VST2DWB<0b1001, {0,1,?,?}, "16", VecListDPairSpaced,
2016                          addrmode6align64or128>;
2017defm VST2b32wb  : VST2DWB<0b1001, {1,0,?,?}, "32", VecListDPairSpaced,
2018                          addrmode6align64or128>;
2019
2020//   VST3     : Vector Store (multiple 3-element structures)
2021class VST3D<bits<4> op11_8, bits<4> op7_4, string Dt>
2022  : NLdSt<0, 0b00, op11_8, op7_4, (outs),
2023          (ins addrmode6:$Rn, DPR:$Vd, DPR:$src2, DPR:$src3), IIC_VST3,
2024          "vst3", Dt, "\\{$Vd, $src2, $src3\\}, $Rn", "", []>, Sched<[WriteVST3]> {
2025  let Rm = 0b1111;
2026  let Inst{4} = Rn{4};
2027  let DecoderMethod = "DecodeVLDST3Instruction";
2028}
2029
2030def  VST3d8   : VST3D<0b0100, {0,0,0,?}, "8">;
2031def  VST3d16  : VST3D<0b0100, {0,1,0,?}, "16">;
2032def  VST3d32  : VST3D<0b0100, {1,0,0,?}, "32">;
2033
2034def  VST3d8Pseudo  : VSTQQPseudo<IIC_VST3>, Sched<[WriteVST3]>;
2035def  VST3d16Pseudo : VSTQQPseudo<IIC_VST3>, Sched<[WriteVST3]>;
2036def  VST3d32Pseudo : VSTQQPseudo<IIC_VST3>, Sched<[WriteVST3]>;
2037
2038// ...with address register writeback:
2039class VST3DWB<bits<4> op11_8, bits<4> op7_4, string Dt>
2040  : NLdSt<0, 0b00, op11_8, op7_4, (outs GPR:$wb),
2041          (ins addrmode6:$Rn, am6offset:$Rm,
2042           DPR:$Vd, DPR:$src2, DPR:$src3), IIC_VST3u,
2043          "vst3", Dt, "\\{$Vd, $src2, $src3\\}, $Rn$Rm",
2044          "$Rn.addr = $wb", []>, Sched<[WriteVST3]> {
2045  let Inst{4} = Rn{4};
2046  let DecoderMethod = "DecodeVLDST3Instruction";
2047}
2048
2049def VST3d8_UPD  : VST3DWB<0b0100, {0,0,0,?}, "8">;
2050def VST3d16_UPD : VST3DWB<0b0100, {0,1,0,?}, "16">;
2051def VST3d32_UPD : VST3DWB<0b0100, {1,0,0,?}, "32">;
2052
2053def VST3d8Pseudo_UPD  : VSTQQWBPseudo<IIC_VST3u>, Sched<[WriteVST3]>;
2054def VST3d16Pseudo_UPD : VSTQQWBPseudo<IIC_VST3u>, Sched<[WriteVST3]>;
2055def VST3d32Pseudo_UPD : VSTQQWBPseudo<IIC_VST3u>, Sched<[WriteVST3]>;
2056
2057// ...with double-spaced registers:
2058def VST3q8      : VST3D<0b0101, {0,0,0,?}, "8">;
2059def VST3q16     : VST3D<0b0101, {0,1,0,?}, "16">;
2060def VST3q32     : VST3D<0b0101, {1,0,0,?}, "32">;
2061def VST3q8_UPD  : VST3DWB<0b0101, {0,0,0,?}, "8">;
2062def VST3q16_UPD : VST3DWB<0b0101, {0,1,0,?}, "16">;
2063def VST3q32_UPD : VST3DWB<0b0101, {1,0,0,?}, "32">;
2064
2065def VST3q8Pseudo_UPD  : VSTQQQQWBPseudo<IIC_VST3u>, Sched<[WriteVST3]>;
2066def VST3q16Pseudo_UPD : VSTQQQQWBPseudo<IIC_VST3u>, Sched<[WriteVST3]>;
2067def VST3q32Pseudo_UPD : VSTQQQQWBPseudo<IIC_VST3u>, Sched<[WriteVST3]>;
2068
2069// ...alternate versions to be allocated odd register numbers:
2070def VST3q8oddPseudo   : VSTQQQQPseudo<IIC_VST3>, Sched<[WriteVST3]>;
2071def VST3q16oddPseudo  : VSTQQQQPseudo<IIC_VST3>, Sched<[WriteVST3]>;
2072def VST3q32oddPseudo  : VSTQQQQPseudo<IIC_VST3>, Sched<[WriteVST3]>;
2073
2074def VST3q8oddPseudo_UPD  : VSTQQQQWBPseudo<IIC_VST3u>, Sched<[WriteVST3]>;
2075def VST3q16oddPseudo_UPD : VSTQQQQWBPseudo<IIC_VST3u>, Sched<[WriteVST3]>;
2076def VST3q32oddPseudo_UPD : VSTQQQQWBPseudo<IIC_VST3u>, Sched<[WriteVST3]>;
2077
2078//   VST4     : Vector Store (multiple 4-element structures)
2079class VST4D<bits<4> op11_8, bits<4> op7_4, string Dt>
2080  : NLdSt<0, 0b00, op11_8, op7_4, (outs),
2081          (ins addrmode6:$Rn, DPR:$Vd, DPR:$src2, DPR:$src3, DPR:$src4),
2082          IIC_VST4, "vst4", Dt, "\\{$Vd, $src2, $src3, $src4\\}, $Rn",
2083          "", []>, Sched<[WriteVST4]> {
2084  let Rm = 0b1111;
2085  let Inst{5-4} = Rn{5-4};
2086  let DecoderMethod = "DecodeVLDST4Instruction";
2087}
2088
2089def  VST4d8   : VST4D<0b0000, {0,0,?,?}, "8">;
2090def  VST4d16  : VST4D<0b0000, {0,1,?,?}, "16">;
2091def  VST4d32  : VST4D<0b0000, {1,0,?,?}, "32">;
2092
2093def  VST4d8Pseudo  : VSTQQPseudo<IIC_VST4>, Sched<[WriteVST4]>;
2094def  VST4d16Pseudo : VSTQQPseudo<IIC_VST4>, Sched<[WriteVST4]>;
2095def  VST4d32Pseudo : VSTQQPseudo<IIC_VST4>, Sched<[WriteVST4]>;
2096
2097// ...with address register writeback:
2098class VST4DWB<bits<4> op11_8, bits<4> op7_4, string Dt>
2099  : NLdSt<0, 0b00, op11_8, op7_4, (outs GPR:$wb),
2100          (ins addrmode6:$Rn, am6offset:$Rm,
2101           DPR:$Vd, DPR:$src2, DPR:$src3, DPR:$src4), IIC_VST4u,
2102           "vst4", Dt, "\\{$Vd, $src2, $src3, $src4\\}, $Rn$Rm",
2103          "$Rn.addr = $wb", []>, Sched<[WriteVST4]> {
2104  let Inst{5-4} = Rn{5-4};
2105  let DecoderMethod = "DecodeVLDST4Instruction";
2106}
2107
2108def VST4d8_UPD  : VST4DWB<0b0000, {0,0,?,?}, "8">;
2109def VST4d16_UPD : VST4DWB<0b0000, {0,1,?,?}, "16">;
2110def VST4d32_UPD : VST4DWB<0b0000, {1,0,?,?}, "32">;
2111
2112def VST4d8Pseudo_UPD  : VSTQQWBPseudo<IIC_VST4u>, Sched<[WriteVST4]>;
2113def VST4d16Pseudo_UPD : VSTQQWBPseudo<IIC_VST4u>, Sched<[WriteVST4]>;
2114def VST4d32Pseudo_UPD : VSTQQWBPseudo<IIC_VST4u>, Sched<[WriteVST4]>;
2115
2116// ...with double-spaced registers:
2117def VST4q8      : VST4D<0b0001, {0,0,?,?}, "8">;
2118def VST4q16     : VST4D<0b0001, {0,1,?,?}, "16">;
2119def VST4q32     : VST4D<0b0001, {1,0,?,?}, "32">;
2120def VST4q8_UPD  : VST4DWB<0b0001, {0,0,?,?}, "8">;
2121def VST4q16_UPD : VST4DWB<0b0001, {0,1,?,?}, "16">;
2122def VST4q32_UPD : VST4DWB<0b0001, {1,0,?,?}, "32">;
2123
2124def VST4q8Pseudo_UPD  : VSTQQQQWBPseudo<IIC_VST4u>, Sched<[WriteVST4]>;
2125def VST4q16Pseudo_UPD : VSTQQQQWBPseudo<IIC_VST4u>, Sched<[WriteVST4]>;
2126def VST4q32Pseudo_UPD : VSTQQQQWBPseudo<IIC_VST4u>, Sched<[WriteVST4]>;
2127
2128// ...alternate versions to be allocated odd register numbers:
2129def VST4q8oddPseudo   : VSTQQQQPseudo<IIC_VST4>, Sched<[WriteVST4]>;
2130def VST4q16oddPseudo  : VSTQQQQPseudo<IIC_VST4>, Sched<[WriteVST4]>;
2131def VST4q32oddPseudo  : VSTQQQQPseudo<IIC_VST4>, Sched<[WriteVST4]>;
2132
2133def VST4q8oddPseudo_UPD  : VSTQQQQWBPseudo<IIC_VST4u>, Sched<[WriteVST4]>;
2134def VST4q16oddPseudo_UPD : VSTQQQQWBPseudo<IIC_VST4u>, Sched<[WriteVST4]>;
2135def VST4q32oddPseudo_UPD : VSTQQQQWBPseudo<IIC_VST4u>, Sched<[WriteVST4]>;
2136
2137} // mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1
2138
2139// Classes for VST*LN pseudo-instructions with multi-register operands.
2140// These are expanded to real instructions after register allocation.
2141class VSTQLNPseudo<InstrItinClass itin>
2142  : PseudoNLdSt<(outs), (ins addrmode6:$addr, QPR:$src, nohash_imm:$lane),
2143                itin, "">;
2144class VSTQLNWBPseudo<InstrItinClass itin>
2145  : PseudoNLdSt<(outs GPR:$wb),
2146                (ins addrmode6:$addr, am6offset:$offset, QPR:$src,
2147                 nohash_imm:$lane), itin, "$addr.addr = $wb">;
2148class VSTQQLNPseudo<InstrItinClass itin>
2149  : PseudoNLdSt<(outs), (ins addrmode6:$addr, QQPR:$src, nohash_imm:$lane),
2150                itin, "">;
2151class VSTQQLNWBPseudo<InstrItinClass itin>
2152  : PseudoNLdSt<(outs GPR:$wb),
2153                (ins addrmode6:$addr, am6offset:$offset, QQPR:$src,
2154                 nohash_imm:$lane), itin, "$addr.addr = $wb">;
2155class VSTQQQQLNPseudo<InstrItinClass itin>
2156  : PseudoNLdSt<(outs), (ins addrmode6:$addr, QQQQPR:$src, nohash_imm:$lane),
2157                itin, "">;
2158class VSTQQQQLNWBPseudo<InstrItinClass itin>
2159  : PseudoNLdSt<(outs GPR:$wb),
2160                (ins addrmode6:$addr, am6offset:$offset, QQQQPR:$src,
2161                 nohash_imm:$lane), itin, "$addr.addr = $wb">;
2162
2163//   VST1LN   : Vector Store (single element from one lane)
2164class VST1LN<bits<4> op11_8, bits<4> op7_4, string Dt, ValueType Ty,
2165             PatFrag StoreOp, SDNode ExtractOp, Operand AddrMode>
2166  : NLdStLn<1, 0b00, op11_8, op7_4, (outs),
2167          (ins AddrMode:$Rn, DPR:$Vd, nohash_imm:$lane),
2168          IIC_VST1ln, "vst1", Dt, "\\{$Vd[$lane]\\}, $Rn", "",
2169          [(StoreOp (ExtractOp (Ty DPR:$Vd), imm:$lane), AddrMode:$Rn)]>,
2170     Sched<[WriteVST1]> {
2171  let Rm = 0b1111;
2172  let DecoderMethod = "DecodeVST1LN";
2173}
2174class VST1QLNPseudo<ValueType Ty, PatFrag StoreOp, SDNode ExtractOp>
2175  : VSTQLNPseudo<IIC_VST1ln>, Sched<[WriteVST1]> {
2176  let Pattern = [(StoreOp (ExtractOp (Ty QPR:$src), imm:$lane),
2177                          addrmode6:$addr)];
2178}
2179
2180def VST1LNd8  : VST1LN<0b0000, {?,?,?,0}, "8", v8i8, truncstorei8,
2181                       ARMvgetlaneu, addrmode6> {
2182  let Inst{7-5} = lane{2-0};
2183}
2184def VST1LNd16 : VST1LN<0b0100, {?,?,0,?}, "16", v4i16, truncstorei16,
2185                       ARMvgetlaneu, addrmode6> {
2186  let Inst{7-6} = lane{1-0};
2187  let Inst{4}   = Rn{4};
2188}
2189
2190def VST1LNd32 : VST1LN<0b1000, {?,0,?,?}, "32", v2i32, store, extractelt,
2191                       addrmode6oneL32> {
2192  let Inst{7}   = lane{0};
2193  let Inst{5-4} = Rn{5-4};
2194}
2195
2196def VST1LNq8Pseudo  : VST1QLNPseudo<v16i8, truncstorei8, ARMvgetlaneu>;
2197def VST1LNq16Pseudo : VST1QLNPseudo<v8i16, truncstorei16, ARMvgetlaneu>;
2198def VST1LNq32Pseudo : VST1QLNPseudo<v4i32, store, extractelt>;
2199
2200let Predicates = [HasNEON] in {
2201def : Pat<(store (extractelt (v2f32 DPR:$src), imm:$lane), addrmode6:$addr),
2202          (VST1LNd32 addrmode6:$addr, DPR:$src, imm:$lane)>;
2203def : Pat<(store (extractelt (v4f32 QPR:$src), imm:$lane), addrmode6:$addr),
2204          (VST1LNq32Pseudo addrmode6:$addr, QPR:$src, imm:$lane)>;
2205
2206def : Pat<(store (extractelt (v4f16 DPR:$src), imm:$lane), addrmode6:$addr),
2207          (VST1LNd16 addrmode6:$addr, DPR:$src, imm:$lane)>;
2208def : Pat<(store (extractelt (v8f16 QPR:$src), imm:$lane), addrmode6:$addr),
2209          (VST1LNq16Pseudo addrmode6:$addr, QPR:$src, imm:$lane)>;
2210}
2211
2212// ...with address register writeback:
2213class VST1LNWB<bits<4> op11_8, bits<4> op7_4, string Dt, ValueType Ty,
2214               PatFrag StoreOp, SDNode ExtractOp, Operand AdrMode>
2215  : NLdStLn<1, 0b00, op11_8, op7_4, (outs GPR:$wb),
2216          (ins AdrMode:$Rn, am6offset:$Rm,
2217           DPR:$Vd, nohash_imm:$lane), IIC_VST1lnu, "vst1", Dt,
2218          "\\{$Vd[$lane]\\}, $Rn$Rm",
2219          "$Rn.addr = $wb",
2220          [(set GPR:$wb, (StoreOp (ExtractOp (Ty DPR:$Vd), imm:$lane),
2221                                  AdrMode:$Rn, am6offset:$Rm))]>,
2222    Sched<[WriteVST1]> {
2223  let DecoderMethod = "DecodeVST1LN";
2224}
2225class VST1QLNWBPseudo<ValueType Ty, PatFrag StoreOp, SDNode ExtractOp>
2226  : VSTQLNWBPseudo<IIC_VST1lnu>, Sched<[WriteVST1]> {
2227  let Pattern = [(set GPR:$wb, (StoreOp (ExtractOp (Ty QPR:$src), imm:$lane),
2228                                        addrmode6:$addr, am6offset:$offset))];
2229}
2230
2231def VST1LNd8_UPD  : VST1LNWB<0b0000, {?,?,?,0}, "8", v8i8, post_truncsti8,
2232                             ARMvgetlaneu, addrmode6> {
2233  let Inst{7-5} = lane{2-0};
2234}
2235def VST1LNd16_UPD : VST1LNWB<0b0100, {?,?,0,?}, "16", v4i16, post_truncsti16,
2236                             ARMvgetlaneu, addrmode6> {
2237  let Inst{7-6} = lane{1-0};
2238  let Inst{4}   = Rn{4};
2239}
2240def VST1LNd32_UPD : VST1LNWB<0b1000, {?,0,?,?}, "32", v2i32, post_store,
2241                             extractelt, addrmode6oneL32> {
2242  let Inst{7}   = lane{0};
2243  let Inst{5-4} = Rn{5-4};
2244}
2245
2246def VST1LNq8Pseudo_UPD  : VST1QLNWBPseudo<v16i8, post_truncsti8, ARMvgetlaneu>;
2247def VST1LNq16Pseudo_UPD : VST1QLNWBPseudo<v8i16, post_truncsti16,ARMvgetlaneu>;
2248def VST1LNq32Pseudo_UPD : VST1QLNWBPseudo<v4i32, post_store, extractelt>;
2249
2250let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
2251
2252//   VST2LN   : Vector Store (single 2-element structure from one lane)
2253class VST2LN<bits<4> op11_8, bits<4> op7_4, string Dt>
2254  : NLdStLn<1, 0b00, op11_8, op7_4, (outs),
2255          (ins addrmode6:$Rn, DPR:$Vd, DPR:$src2, nohash_imm:$lane),
2256          IIC_VST2ln, "vst2", Dt, "\\{$Vd[$lane], $src2[$lane]\\}, $Rn",
2257          "", []>, Sched<[WriteVST1]> {
2258  let Rm = 0b1111;
2259  let Inst{4}   = Rn{4};
2260  let DecoderMethod = "DecodeVST2LN";
2261}
2262
2263def VST2LNd8  : VST2LN<0b0001, {?,?,?,?}, "8"> {
2264  let Inst{7-5} = lane{2-0};
2265}
2266def VST2LNd16 : VST2LN<0b0101, {?,?,0,?}, "16"> {
2267  let Inst{7-6} = lane{1-0};
2268}
2269def VST2LNd32 : VST2LN<0b1001, {?,0,0,?}, "32"> {
2270  let Inst{7}   = lane{0};
2271}
2272
2273def VST2LNd8Pseudo  : VSTQLNPseudo<IIC_VST2ln>, Sched<[WriteVST1]>;
2274def VST2LNd16Pseudo : VSTQLNPseudo<IIC_VST2ln>, Sched<[WriteVST1]>;
2275def VST2LNd32Pseudo : VSTQLNPseudo<IIC_VST2ln>, Sched<[WriteVST1]>;
2276
2277// ...with double-spaced registers:
2278def VST2LNq16 : VST2LN<0b0101, {?,?,1,?}, "16"> {
2279  let Inst{7-6} = lane{1-0};
2280  let Inst{4}   = Rn{4};
2281}
2282def VST2LNq32 : VST2LN<0b1001, {?,1,0,?}, "32"> {
2283  let Inst{7}   = lane{0};
2284  let Inst{4}   = Rn{4};
2285}
2286
2287def VST2LNq16Pseudo : VSTQQLNPseudo<IIC_VST2ln>, Sched<[WriteVST1]>;
2288def VST2LNq32Pseudo : VSTQQLNPseudo<IIC_VST2ln>, Sched<[WriteVST1]>;
2289
2290// ...with address register writeback:
2291class VST2LNWB<bits<4> op11_8, bits<4> op7_4, string Dt>
2292  : NLdStLn<1, 0b00, op11_8, op7_4, (outs GPR:$wb),
2293          (ins addrmode6:$Rn, am6offset:$Rm,
2294           DPR:$Vd, DPR:$src2, nohash_imm:$lane), IIC_VST2lnu, "vst2", Dt,
2295          "\\{$Vd[$lane], $src2[$lane]\\}, $Rn$Rm",
2296          "$Rn.addr = $wb", []> {
2297  let Inst{4}   = Rn{4};
2298  let DecoderMethod = "DecodeVST2LN";
2299}
2300
2301def VST2LNd8_UPD  : VST2LNWB<0b0001, {?,?,?,?}, "8"> {
2302  let Inst{7-5} = lane{2-0};
2303}
2304def VST2LNd16_UPD : VST2LNWB<0b0101, {?,?,0,?}, "16"> {
2305  let Inst{7-6} = lane{1-0};
2306}
2307def VST2LNd32_UPD : VST2LNWB<0b1001, {?,0,0,?}, "32"> {
2308  let Inst{7}   = lane{0};
2309}
2310
2311def VST2LNd8Pseudo_UPD  : VSTQLNWBPseudo<IIC_VST2lnu>, Sched<[WriteVST1]>;
2312def VST2LNd16Pseudo_UPD : VSTQLNWBPseudo<IIC_VST2lnu>, Sched<[WriteVST1]>;
2313def VST2LNd32Pseudo_UPD : VSTQLNWBPseudo<IIC_VST2lnu>, Sched<[WriteVST1]>;
2314
2315def VST2LNq16_UPD : VST2LNWB<0b0101, {?,?,1,?}, "16"> {
2316  let Inst{7-6} = lane{1-0};
2317}
2318def VST2LNq32_UPD : VST2LNWB<0b1001, {?,1,0,?}, "32"> {
2319  let Inst{7}   = lane{0};
2320}
2321
2322def VST2LNq16Pseudo_UPD : VSTQQLNWBPseudo<IIC_VST2lnu>, Sched<[WriteVST1]>;
2323def VST2LNq32Pseudo_UPD : VSTQQLNWBPseudo<IIC_VST2lnu>, Sched<[WriteVST1]>;
2324
2325//   VST3LN   : Vector Store (single 3-element structure from one lane)
2326class VST3LN<bits<4> op11_8, bits<4> op7_4, string Dt>
2327  : NLdStLn<1, 0b00, op11_8, op7_4, (outs),
2328          (ins addrmode6:$Rn, DPR:$Vd, DPR:$src2, DPR:$src3,
2329           nohash_imm:$lane), IIC_VST3ln, "vst3", Dt,
2330          "\\{$Vd[$lane], $src2[$lane], $src3[$lane]\\}, $Rn", "", []>,
2331    Sched<[WriteVST2]> {
2332  let Rm = 0b1111;
2333  let DecoderMethod = "DecodeVST3LN";
2334}
2335
2336def VST3LNd8  : VST3LN<0b0010, {?,?,?,0}, "8"> {
2337  let Inst{7-5} = lane{2-0};
2338}
2339def VST3LNd16 : VST3LN<0b0110, {?,?,0,0}, "16"> {
2340  let Inst{7-6} = lane{1-0};
2341}
2342def VST3LNd32 : VST3LN<0b1010, {?,0,0,0}, "32"> {
2343  let Inst{7}   = lane{0};
2344}
2345
2346def VST3LNd8Pseudo  : VSTQQLNPseudo<IIC_VST3ln>, Sched<[WriteVST2]>;
2347def VST3LNd16Pseudo : VSTQQLNPseudo<IIC_VST3ln>, Sched<[WriteVST2]>;
2348def VST3LNd32Pseudo : VSTQQLNPseudo<IIC_VST3ln>, Sched<[WriteVST2]>;
2349
2350// ...with double-spaced registers:
2351def VST3LNq16 : VST3LN<0b0110, {?,?,1,0}, "16"> {
2352  let Inst{7-6} = lane{1-0};
2353}
2354def VST3LNq32 : VST3LN<0b1010, {?,1,0,0}, "32"> {
2355  let Inst{7}   = lane{0};
2356}
2357
2358def VST3LNq16Pseudo : VSTQQQQLNPseudo<IIC_VST3ln>;
2359def VST3LNq32Pseudo : VSTQQQQLNPseudo<IIC_VST3ln>;
2360
2361// ...with address register writeback:
2362class VST3LNWB<bits<4> op11_8, bits<4> op7_4, string Dt>
2363  : NLdStLn<1, 0b00, op11_8, op7_4, (outs GPR:$wb),
2364          (ins addrmode6:$Rn, am6offset:$Rm,
2365           DPR:$Vd, DPR:$src2, DPR:$src3, nohash_imm:$lane),
2366          IIC_VST3lnu, "vst3", Dt,
2367          "\\{$Vd[$lane], $src2[$lane], $src3[$lane]\\}, $Rn$Rm",
2368          "$Rn.addr = $wb", []> {
2369  let DecoderMethod = "DecodeVST3LN";
2370}
2371
2372def VST3LNd8_UPD  : VST3LNWB<0b0010, {?,?,?,0}, "8"> {
2373  let Inst{7-5} = lane{2-0};
2374}
2375def VST3LNd16_UPD : VST3LNWB<0b0110, {?,?,0,0}, "16"> {
2376  let Inst{7-6} = lane{1-0};
2377}
2378def VST3LNd32_UPD : VST3LNWB<0b1010, {?,0,0,0}, "32"> {
2379  let Inst{7}   = lane{0};
2380}
2381
2382def VST3LNd8Pseudo_UPD  : VSTQQLNWBPseudo<IIC_VST3lnu>, Sched<[WriteVST2]>;
2383def VST3LNd16Pseudo_UPD : VSTQQLNWBPseudo<IIC_VST3lnu>, Sched<[WriteVST2]>;
2384def VST3LNd32Pseudo_UPD : VSTQQLNWBPseudo<IIC_VST3lnu>, Sched<[WriteVST2]>;
2385
2386def VST3LNq16_UPD : VST3LNWB<0b0110, {?,?,1,0}, "16"> {
2387  let Inst{7-6} = lane{1-0};
2388}
2389def VST3LNq32_UPD : VST3LNWB<0b1010, {?,1,0,0}, "32"> {
2390  let Inst{7}   = lane{0};
2391}
2392
2393def VST3LNq16Pseudo_UPD : VSTQQQQLNWBPseudo<IIC_VST3lnu>, Sched<[WriteVST2]>;
2394def VST3LNq32Pseudo_UPD : VSTQQQQLNWBPseudo<IIC_VST3lnu>, Sched<[WriteVST2]>;
2395
2396//   VST4LN   : Vector Store (single 4-element structure from one lane)
2397class VST4LN<bits<4> op11_8, bits<4> op7_4, string Dt>
2398  : NLdStLn<1, 0b00, op11_8, op7_4, (outs),
2399          (ins addrmode6:$Rn, DPR:$Vd, DPR:$src2, DPR:$src3, DPR:$src4,
2400           nohash_imm:$lane), IIC_VST4ln, "vst4", Dt,
2401          "\\{$Vd[$lane], $src2[$lane], $src3[$lane], $src4[$lane]\\}, $Rn",
2402          "", []>, Sched<[WriteVST2]> {
2403  let Rm = 0b1111;
2404  let Inst{4} = Rn{4};
2405  let DecoderMethod = "DecodeVST4LN";
2406}
2407
2408def VST4LNd8  : VST4LN<0b0011, {?,?,?,?}, "8"> {
2409  let Inst{7-5} = lane{2-0};
2410}
2411def VST4LNd16 : VST4LN<0b0111, {?,?,0,?}, "16"> {
2412  let Inst{7-6} = lane{1-0};
2413}
2414def VST4LNd32 : VST4LN<0b1011, {?,0,?,?}, "32"> {
2415  let Inst{7}   = lane{0};
2416  let Inst{5} = Rn{5};
2417}
2418
2419def VST4LNd8Pseudo  : VSTQQLNPseudo<IIC_VST4ln>, Sched<[WriteVST2]>;
2420def VST4LNd16Pseudo : VSTQQLNPseudo<IIC_VST4ln>, Sched<[WriteVST2]>;
2421def VST4LNd32Pseudo : VSTQQLNPseudo<IIC_VST4ln>, Sched<[WriteVST2]>;
2422
2423// ...with double-spaced registers:
2424def VST4LNq16 : VST4LN<0b0111, {?,?,1,?}, "16"> {
2425  let Inst{7-6} = lane{1-0};
2426}
2427def VST4LNq32 : VST4LN<0b1011, {?,1,?,?}, "32"> {
2428  let Inst{7}   = lane{0};
2429  let Inst{5} = Rn{5};
2430}
2431
2432def VST4LNq16Pseudo : VSTQQQQLNPseudo<IIC_VST4ln>, Sched<[WriteVST2]>;
2433def VST4LNq32Pseudo : VSTQQQQLNPseudo<IIC_VST4ln>, Sched<[WriteVST2]>;
2434
2435// ...with address register writeback:
2436class VST4LNWB<bits<4> op11_8, bits<4> op7_4, string Dt>
2437  : NLdStLn<1, 0b00, op11_8, op7_4, (outs GPR:$wb),
2438          (ins addrmode6:$Rn, am6offset:$Rm,
2439           DPR:$Vd, DPR:$src2, DPR:$src3, DPR:$src4, nohash_imm:$lane),
2440          IIC_VST4lnu, "vst4", Dt,
2441  "\\{$Vd[$lane], $src2[$lane], $src3[$lane], $src4[$lane]\\}, $Rn$Rm",
2442          "$Rn.addr = $wb", []> {
2443  let Inst{4} = Rn{4};
2444  let DecoderMethod = "DecodeVST4LN";
2445}
2446
2447def VST4LNd8_UPD  : VST4LNWB<0b0011, {?,?,?,?}, "8"> {
2448  let Inst{7-5} = lane{2-0};
2449}
2450def VST4LNd16_UPD : VST4LNWB<0b0111, {?,?,0,?}, "16"> {
2451  let Inst{7-6} = lane{1-0};
2452}
2453def VST4LNd32_UPD : VST4LNWB<0b1011, {?,0,?,?}, "32"> {
2454  let Inst{7}   = lane{0};
2455  let Inst{5} = Rn{5};
2456}
2457
2458def VST4LNd8Pseudo_UPD  : VSTQQLNWBPseudo<IIC_VST4lnu>, Sched<[WriteVST2]>;
2459def VST4LNd16Pseudo_UPD : VSTQQLNWBPseudo<IIC_VST4lnu>, Sched<[WriteVST2]>;
2460def VST4LNd32Pseudo_UPD : VSTQQLNWBPseudo<IIC_VST4lnu>, Sched<[WriteVST2]>;
2461
2462def VST4LNq16_UPD : VST4LNWB<0b0111, {?,?,1,?}, "16"> {
2463  let Inst{7-6} = lane{1-0};
2464}
2465def VST4LNq32_UPD : VST4LNWB<0b1011, {?,1,?,?}, "32"> {
2466  let Inst{7}   = lane{0};
2467  let Inst{5} = Rn{5};
2468}
2469
2470def VST4LNq16Pseudo_UPD : VSTQQQQLNWBPseudo<IIC_VST4lnu>, Sched<[WriteVST2]>;
2471def VST4LNq32Pseudo_UPD : VSTQQQQLNWBPseudo<IIC_VST4lnu>, Sched<[WriteVST2]>;
2472
2473} // mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1
2474
2475// Use vld1/vst1 for unaligned f64 load / store
2476let Predicates = [IsLE,HasNEON] in {
2477def : Pat<(f64 (hword_alignedload addrmode6:$addr)),
2478          (VLD1d16 addrmode6:$addr)>;
2479def : Pat<(hword_alignedstore (f64 DPR:$value), addrmode6:$addr),
2480          (VST1d16 addrmode6:$addr, DPR:$value)>;
2481def : Pat<(f64 (byte_alignedload addrmode6:$addr)),
2482          (VLD1d8 addrmode6:$addr)>;
2483def : Pat<(byte_alignedstore (f64 DPR:$value), addrmode6:$addr),
2484          (VST1d8 addrmode6:$addr, DPR:$value)>;
2485}
2486let Predicates = [IsBE,HasNEON] in {
2487def : Pat<(f64 (non_word_alignedload addrmode6:$addr)),
2488          (VLD1d64 addrmode6:$addr)>;
2489def : Pat<(non_word_alignedstore (f64 DPR:$value), addrmode6:$addr),
2490          (VST1d64 addrmode6:$addr, DPR:$value)>;
2491}
2492
2493// Use vld1/vst1 for Q and QQ. Also use them for unaligned v2f64
2494// load / store if it's legal.
2495let Predicates = [HasNEON] in {
2496def : Pat<(v2f64 (dword_alignedload addrmode6:$addr)),
2497          (VLD1q64 addrmode6:$addr)>;
2498def : Pat<(dword_alignedstore (v2f64 QPR:$value), addrmode6:$addr),
2499          (VST1q64 addrmode6:$addr, QPR:$value)>;
2500}
2501let Predicates = [IsLE,HasNEON] in {
2502def : Pat<(v2f64 (word_alignedload addrmode6:$addr)),
2503          (VLD1q32 addrmode6:$addr)>;
2504def : Pat<(word_alignedstore (v2f64 QPR:$value), addrmode6:$addr),
2505          (VST1q32 addrmode6:$addr, QPR:$value)>;
2506def : Pat<(v2f64 (hword_alignedload addrmode6:$addr)),
2507          (VLD1q16 addrmode6:$addr)>;
2508def : Pat<(hword_alignedstore (v2f64 QPR:$value), addrmode6:$addr),
2509          (VST1q16 addrmode6:$addr, QPR:$value)>;
2510def : Pat<(v2f64 (byte_alignedload addrmode6:$addr)),
2511          (VLD1q8 addrmode6:$addr)>;
2512def : Pat<(byte_alignedstore (v2f64 QPR:$value), addrmode6:$addr),
2513          (VST1q8 addrmode6:$addr, QPR:$value)>;
2514}
2515
2516//===----------------------------------------------------------------------===//
2517// Instruction Classes
2518//===----------------------------------------------------------------------===//
2519
2520// Basic 2-register operations: double- and quad-register.
2521class N2VD<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18,
2522           bits<2> op17_16, bits<5> op11_7, bit op4, string OpcodeStr,
2523           string Dt, ValueType ResTy, ValueType OpTy, SDNode OpNode>
2524  : N2V<op24_23, op21_20, op19_18, op17_16, op11_7, 0, op4, (outs DPR:$Vd),
2525        (ins DPR:$Vm), IIC_VUNAD, OpcodeStr, Dt,"$Vd, $Vm", "",
2526        [(set DPR:$Vd, (ResTy (OpNode (OpTy DPR:$Vm))))]>;
2527class N2VQ<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18,
2528           bits<2> op17_16, bits<5> op11_7, bit op4, string OpcodeStr,
2529           string Dt, ValueType ResTy, ValueType OpTy, SDNode OpNode>
2530  : N2V<op24_23, op21_20, op19_18, op17_16, op11_7, 1, op4, (outs QPR:$Vd),
2531        (ins QPR:$Vm), IIC_VUNAQ, OpcodeStr, Dt,"$Vd, $Vm", "",
2532        [(set QPR:$Vd, (ResTy (OpNode (OpTy QPR:$Vm))))]>;
2533
2534// Basic 2-register intrinsics, both double- and quad-register.
2535class N2VDInt<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18,
2536              bits<2> op17_16, bits<5> op11_7, bit op4,
2537              InstrItinClass itin, string OpcodeStr, string Dt,
2538              ValueType ResTy, ValueType OpTy, SDPatternOperator IntOp>
2539  : N2V<op24_23, op21_20, op19_18, op17_16, op11_7, 0, op4, (outs DPR:$Vd),
2540        (ins DPR:$Vm), itin, OpcodeStr, Dt, "$Vd, $Vm", "",
2541        [(set DPR:$Vd, (ResTy (IntOp (OpTy DPR:$Vm))))]>;
2542class N2VQInt<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18,
2543              bits<2> op17_16, bits<5> op11_7, bit op4,
2544              InstrItinClass itin, string OpcodeStr, string Dt,
2545              ValueType ResTy, ValueType OpTy, SDPatternOperator IntOp>
2546  : N2V<op24_23, op21_20, op19_18, op17_16, op11_7, 1, op4, (outs QPR:$Vd),
2547        (ins QPR:$Vm), itin, OpcodeStr, Dt, "$Vd, $Vm", "",
2548        [(set QPR:$Vd, (ResTy (IntOp (OpTy QPR:$Vm))))]>;
2549
2550// Same as above, but not predicated.
2551class N2VDIntnp<bits<2> op19_18, bits<2> op17_16, bits<3> op10_8, bit op7,
2552              InstrItinClass itin, string OpcodeStr, string Dt,
2553              ValueType ResTy, ValueType OpTy, SDPatternOperator IntOp>
2554  : N2Vnp<op19_18, op17_16, op10_8, op7, 0,  (outs DPR:$Vd), (ins DPR:$Vm),
2555          itin, OpcodeStr, Dt,
2556          [(set DPR:$Vd, (ResTy (IntOp (OpTy DPR:$Vm))))]>;
2557
2558class N2VQIntnp<bits<2> op19_18, bits<2> op17_16, bits<3> op10_8, bit op7,
2559              InstrItinClass itin, string OpcodeStr, string Dt,
2560              ValueType ResTy, ValueType OpTy, SDPatternOperator IntOp>
2561  : N2Vnp<op19_18, op17_16, op10_8, op7, 1,  (outs QPR:$Vd), (ins QPR:$Vm),
2562          itin, OpcodeStr, Dt,
2563          [(set QPR:$Vd, (ResTy (IntOp (OpTy QPR:$Vm))))]>;
2564
2565// Similar to NV2VQIntnp with some more encoding bits exposed (crypto).
2566class N2VQIntXnp<bits<2> op19_18, bits<2> op17_16, bits<3> op10_8, bit op6,
2567              bit op7, InstrItinClass itin, string OpcodeStr, string Dt,
2568              ValueType ResTy, ValueType OpTy, SDPatternOperator IntOp>
2569  : N2Vnp<op19_18, op17_16, op10_8, op7, op6,  (outs QPR:$Vd), (ins QPR:$Vm),
2570          itin, OpcodeStr, Dt,
2571          [(set QPR:$Vd, (ResTy (IntOp (OpTy QPR:$Vm))))]>;
2572
2573// Same as N2VQIntXnp but with Vd as a src register.
2574class N2VQIntX2np<bits<2> op19_18, bits<2> op17_16, bits<3> op10_8, bit op6,
2575              bit op7, InstrItinClass itin, string OpcodeStr, string Dt,
2576              ValueType ResTy, ValueType OpTy, SDPatternOperator IntOp>
2577  : N2Vnp<op19_18, op17_16, op10_8, op7, op6,
2578          (outs QPR:$Vd), (ins QPR:$src, QPR:$Vm),
2579          itin, OpcodeStr, Dt,
2580          [(set QPR:$Vd, (ResTy (IntOp (OpTy QPR:$src), (OpTy QPR:$Vm))))]> {
2581  let Constraints = "$src = $Vd";
2582}
2583
2584// Narrow 2-register operations.
2585class N2VN<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18,
2586           bits<2> op17_16, bits<5> op11_7, bit op6, bit op4,
2587           InstrItinClass itin, string OpcodeStr, string Dt,
2588           ValueType TyD, ValueType TyQ, SDNode OpNode>
2589  : N2V<op24_23, op21_20, op19_18, op17_16, op11_7, op6, op4, (outs DPR:$Vd),
2590        (ins QPR:$Vm), itin, OpcodeStr, Dt, "$Vd, $Vm", "",
2591        [(set DPR:$Vd, (TyD (OpNode (TyQ QPR:$Vm))))]>;
2592
2593// Narrow 2-register intrinsics.
2594class N2VNInt<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18,
2595              bits<2> op17_16, bits<5> op11_7, bit op6, bit op4,
2596              InstrItinClass itin, string OpcodeStr, string Dt,
2597              ValueType TyD, ValueType TyQ, SDPatternOperator IntOp>
2598  : N2V<op24_23, op21_20, op19_18, op17_16, op11_7, op6, op4, (outs DPR:$Vd),
2599        (ins QPR:$Vm), itin, OpcodeStr, Dt, "$Vd, $Vm", "",
2600        [(set DPR:$Vd, (TyD (IntOp (TyQ QPR:$Vm))))]>;
2601
2602// Long 2-register operations (currently only used for VMOVL).
2603class N2VL<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18,
2604           bits<2> op17_16, bits<5> op11_7, bit op6, bit op4,
2605           InstrItinClass itin, string OpcodeStr, string Dt,
2606           ValueType TyQ, ValueType TyD, SDNode OpNode>
2607  : N2V<op24_23, op21_20, op19_18, op17_16, op11_7, op6, op4, (outs QPR:$Vd),
2608        (ins DPR:$Vm), itin, OpcodeStr, Dt, "$Vd, $Vm", "",
2609        [(set QPR:$Vd, (TyQ (OpNode (TyD DPR:$Vm))))]>;
2610
2611// Long 2-register intrinsics.
2612class N2VLInt<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18,
2613              bits<2> op17_16, bits<5> op11_7, bit op6, bit op4,
2614              InstrItinClass itin, string OpcodeStr, string Dt,
2615              ValueType TyQ, ValueType TyD, SDPatternOperator IntOp>
2616  : N2V<op24_23, op21_20, op19_18, op17_16, op11_7, op6, op4, (outs QPR:$Vd),
2617        (ins DPR:$Vm), itin, OpcodeStr, Dt, "$Vd, $Vm", "",
2618        [(set QPR:$Vd, (TyQ (IntOp (TyD DPR:$Vm))))]>;
2619
2620// 2-register shuffles (VTRN/VZIP/VUZP), both double- and quad-register.
2621class N2VDShuffle<bits<2> op19_18, bits<5> op11_7, string OpcodeStr, string Dt>
2622  : N2V<0b11, 0b11, op19_18, 0b10, op11_7, 0, 0, (outs DPR:$Vd, DPR:$Vm),
2623        (ins DPR:$src1, DPR:$src2), IIC_VPERMD,
2624        OpcodeStr, Dt, "$Vd, $Vm",
2625        "$src1 = $Vd, $src2 = $Vm", []>;
2626class N2VQShuffle<bits<2> op19_18, bits<5> op11_7,
2627                  InstrItinClass itin, string OpcodeStr, string Dt>
2628  : N2V<0b11, 0b11, op19_18, 0b10, op11_7, 1, 0, (outs QPR:$Vd, QPR:$Vm),
2629        (ins QPR:$src1, QPR:$src2), itin, OpcodeStr, Dt, "$Vd, $Vm",
2630        "$src1 = $Vd, $src2 = $Vm", []>;
2631
2632// Basic 3-register operations: double- and quad-register.
2633class N3VD<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op4,
2634           InstrItinClass itin, string OpcodeStr, string Dt,
2635           ValueType ResTy, ValueType OpTy, SDNode OpNode, bit Commutable>
2636  : N3V<op24, op23, op21_20, op11_8, 0, op4,
2637        (outs DPR:$Vd), (ins DPR:$Vn, DPR:$Vm), N3RegFrm, itin,
2638        OpcodeStr, Dt, "$Vd, $Vn, $Vm", "",
2639        [(set DPR:$Vd, (ResTy (OpNode (OpTy DPR:$Vn), (OpTy DPR:$Vm))))]> {
2640  // All of these have a two-operand InstAlias.
2641  let TwoOperandAliasConstraint = "$Vn = $Vd";
2642  let isCommutable = Commutable;
2643}
2644// Same as N3VD but no data type.
2645class N3VDX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op4,
2646           InstrItinClass itin, string OpcodeStr,
2647           ValueType ResTy, ValueType OpTy,
2648           SDNode OpNode, bit Commutable>
2649  : N3VX<op24, op23, op21_20, op11_8, 0, op4,
2650         (outs DPR:$Vd), (ins DPR:$Vn, DPR:$Vm), N3RegFrm, itin,
2651         OpcodeStr, "$Vd, $Vn, $Vm", "",
2652         [(set DPR:$Vd, (ResTy (OpNode (OpTy DPR:$Vn), (OpTy DPR:$Vm))))]>{
2653  // All of these have a two-operand InstAlias.
2654  let TwoOperandAliasConstraint = "$Vn = $Vd";
2655  let isCommutable = Commutable;
2656}
2657
2658class N3VDSL<bits<2> op21_20, bits<4> op11_8,
2659             InstrItinClass itin, string OpcodeStr, string Dt,
2660             ValueType Ty, SDNode ShOp>
2661  : N3VLane32<0, 1, op21_20, op11_8, 1, 0,
2662        (outs DPR:$Vd), (ins DPR:$Vn, DPR_VFP2:$Vm, VectorIndex32:$lane),
2663        NVMulSLFrm, itin, OpcodeStr, Dt, "$Vd, $Vn, $Vm$lane", "",
2664        [(set (Ty DPR:$Vd),
2665              (Ty (ShOp (Ty DPR:$Vn),
2666                        (Ty (ARMvduplane (Ty DPR_VFP2:$Vm),imm:$lane)))))]> {
2667  // All of these have a two-operand InstAlias.
2668  let TwoOperandAliasConstraint = "$Vn = $Vd";
2669  let isCommutable = 0;
2670}
2671class N3VDSL16<bits<2> op21_20, bits<4> op11_8,
2672               string OpcodeStr, string Dt, ValueType Ty, SDNode ShOp>
2673  : N3VLane16<0, 1, op21_20, op11_8, 1, 0,
2674        (outs DPR:$Vd), (ins DPR:$Vn, DPR_8:$Vm, VectorIndex16:$lane),
2675        NVMulSLFrm, IIC_VMULi16D, OpcodeStr, Dt,"$Vd, $Vn, $Vm$lane","",
2676        [(set (Ty DPR:$Vd),
2677              (Ty (ShOp (Ty DPR:$Vn),
2678                        (Ty (ARMvduplane (Ty DPR_8:$Vm), imm:$lane)))))]> {
2679  // All of these have a two-operand InstAlias.
2680  let TwoOperandAliasConstraint = "$Vn = $Vd";
2681  let isCommutable = 0;
2682}
2683
2684class N3VQ<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op4,
2685           InstrItinClass itin, string OpcodeStr, string Dt,
2686           ValueType ResTy, ValueType OpTy, SDNode OpNode, bit Commutable>
2687  : N3V<op24, op23, op21_20, op11_8, 1, op4,
2688        (outs QPR:$Vd), (ins QPR:$Vn, QPR:$Vm), N3RegFrm, itin,
2689        OpcodeStr, Dt, "$Vd, $Vn, $Vm", "",
2690        [(set QPR:$Vd, (ResTy (OpNode (OpTy QPR:$Vn), (OpTy QPR:$Vm))))]> {
2691  // All of these have a two-operand InstAlias.
2692  let TwoOperandAliasConstraint = "$Vn = $Vd";
2693  let isCommutable = Commutable;
2694}
2695class N3VQX<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op4,
2696           InstrItinClass itin, string OpcodeStr,
2697           ValueType ResTy, ValueType OpTy, SDNode OpNode, bit Commutable>
2698  : N3VX<op24, op23, op21_20, op11_8, 1, op4,
2699         (outs QPR:$Vd), (ins QPR:$Vn, QPR:$Vm), N3RegFrm, itin,
2700         OpcodeStr, "$Vd, $Vn, $Vm", "",
2701         [(set QPR:$Vd, (ResTy (OpNode (OpTy QPR:$Vn), (OpTy QPR:$Vm))))]>{
2702  // All of these have a two-operand InstAlias.
2703  let TwoOperandAliasConstraint = "$Vn = $Vd";
2704  let isCommutable = Commutable;
2705}
2706class N3VQSL<bits<2> op21_20, bits<4> op11_8,
2707             InstrItinClass itin, string OpcodeStr, string Dt,
2708             ValueType ResTy, ValueType OpTy, SDNode ShOp>
2709  : N3VLane32<1, 1, op21_20, op11_8, 1, 0,
2710        (outs QPR:$Vd), (ins QPR:$Vn, DPR_VFP2:$Vm, VectorIndex32:$lane),
2711        NVMulSLFrm, itin, OpcodeStr, Dt, "$Vd, $Vn, $Vm$lane", "",
2712        [(set (ResTy QPR:$Vd),
2713              (ResTy (ShOp (ResTy QPR:$Vn),
2714                           (ResTy (ARMvduplane (OpTy DPR_VFP2:$Vm),
2715                                                imm:$lane)))))]> {
2716  // All of these have a two-operand InstAlias.
2717  let TwoOperandAliasConstraint = "$Vn = $Vd";
2718  let isCommutable = 0;
2719}
2720class N3VQSL16<bits<2> op21_20, bits<4> op11_8, string OpcodeStr, string Dt,
2721               ValueType ResTy, ValueType OpTy, SDNode ShOp>
2722  : N3VLane16<1, 1, op21_20, op11_8, 1, 0,
2723        (outs QPR:$Vd), (ins QPR:$Vn, DPR_8:$Vm, VectorIndex16:$lane),
2724        NVMulSLFrm, IIC_VMULi16Q, OpcodeStr, Dt,"$Vd, $Vn, $Vm$lane", "",
2725        [(set (ResTy QPR:$Vd),
2726              (ResTy (ShOp (ResTy QPR:$Vn),
2727                           (ResTy (ARMvduplane (OpTy DPR_8:$Vm),
2728                                                imm:$lane)))))]> {
2729  // All of these have a two-operand InstAlias.
2730  let TwoOperandAliasConstraint = "$Vn = $Vd";
2731  let isCommutable = 0;
2732}
2733
2734// Basic 3-register intrinsics, both double- and quad-register.
2735class N3VDInt<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op4,
2736              Format f, InstrItinClass itin, string OpcodeStr, string Dt,
2737              ValueType ResTy, ValueType OpTy, SDPatternOperator IntOp, bit Commutable>
2738  : N3V<op24, op23, op21_20, op11_8, 0, op4,
2739        (outs DPR:$Vd), (ins DPR:$Vn, DPR:$Vm), f, itin,
2740        OpcodeStr, Dt, "$Vd, $Vn, $Vm", "",
2741        [(set DPR:$Vd, (ResTy (IntOp (OpTy DPR:$Vn), (OpTy DPR:$Vm))))]> {
2742  // All of these have a two-operand InstAlias.
2743  let TwoOperandAliasConstraint = "$Vn = $Vd";
2744  let isCommutable = Commutable;
2745}
2746
2747class N3VDIntnp<bits<5> op27_23, bits<2> op21_20, bits<4> op11_8, bit op6,
2748                bit op4, Format f, InstrItinClass itin, string OpcodeStr,
2749                string Dt, ValueType ResTy, ValueType OpTy,
2750                SDPatternOperator IntOp, bit Commutable>
2751  : N3Vnp<op27_23, op21_20, op11_8, op6, op4,
2752          (outs DPR:$Vd), (ins DPR:$Vn, DPR:$Vm), f, itin, OpcodeStr, Dt,
2753          [(set DPR:$Vd, (ResTy (IntOp (OpTy DPR:$Vn), (OpTy DPR:$Vm))))]> {
2754  let isCommutable = Commutable;
2755}
2756
2757
2758class N3VDIntSL<bits<2> op21_20, bits<4> op11_8, InstrItinClass itin,
2759                string OpcodeStr, string Dt, ValueType Ty, SDPatternOperator IntOp>
2760  : N3VLane32<0, 1, op21_20, op11_8, 1, 0,
2761        (outs DPR:$Vd), (ins DPR:$Vn, DPR_VFP2:$Vm, VectorIndex32:$lane),
2762        NVMulSLFrm, itin, OpcodeStr, Dt, "$Vd, $Vn, $Vm$lane", "",
2763        [(set (Ty DPR:$Vd),
2764              (Ty (IntOp (Ty DPR:$Vn),
2765                         (Ty (ARMvduplane (Ty DPR_VFP2:$Vm),
2766                                           imm:$lane)))))]> {
2767  let isCommutable = 0;
2768}
2769
2770class N3VDIntSL16<bits<2> op21_20, bits<4> op11_8, InstrItinClass itin,
2771                  string OpcodeStr, string Dt, ValueType Ty, SDPatternOperator IntOp>
2772  : N3VLane16<0, 1, op21_20, op11_8, 1, 0,
2773        (outs DPR:$Vd), (ins DPR:$Vn, DPR_8:$Vm, VectorIndex16:$lane),
2774        NVMulSLFrm, itin, OpcodeStr, Dt, "$Vd, $Vn, $Vm$lane", "",
2775        [(set (Ty DPR:$Vd),
2776              (Ty (IntOp (Ty DPR:$Vn),
2777                         (Ty (ARMvduplane (Ty DPR_8:$Vm), imm:$lane)))))]> {
2778  let isCommutable = 0;
2779}
2780class N3VDIntSh<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op4,
2781              Format f, InstrItinClass itin, string OpcodeStr, string Dt,
2782              ValueType ResTy, ValueType OpTy, SDPatternOperator IntOp>
2783  : N3V<op24, op23, op21_20, op11_8, 0, op4,
2784        (outs DPR:$Vd), (ins DPR:$Vm, DPR:$Vn), f, itin,
2785        OpcodeStr, Dt, "$Vd, $Vm, $Vn", "",
2786        [(set DPR:$Vd, (ResTy (IntOp (OpTy DPR:$Vm), (OpTy DPR:$Vn))))]> {
2787  let TwoOperandAliasConstraint = "$Vm = $Vd";
2788  let isCommutable = 0;
2789}
2790
2791class N3VQInt<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op4,
2792              Format f, InstrItinClass itin, string OpcodeStr, string Dt,
2793              ValueType ResTy, ValueType OpTy, SDPatternOperator IntOp, bit Commutable>
2794  : N3V<op24, op23, op21_20, op11_8, 1, op4,
2795        (outs QPR:$Vd), (ins QPR:$Vn, QPR:$Vm), f, itin,
2796        OpcodeStr, Dt, "$Vd, $Vn, $Vm", "",
2797        [(set QPR:$Vd, (ResTy (IntOp (OpTy QPR:$Vn), (OpTy QPR:$Vm))))]> {
2798  // All of these have a two-operand InstAlias.
2799  let TwoOperandAliasConstraint = "$Vn = $Vd";
2800  let isCommutable = Commutable;
2801}
2802
2803class N3VQIntnp<bits<5> op27_23, bits<2> op21_20, bits<4> op11_8, bit op6,
2804                bit op4, Format f, InstrItinClass itin, string OpcodeStr,
2805                string Dt, ValueType ResTy, ValueType OpTy,
2806                SDPatternOperator IntOp, bit Commutable>
2807  : N3Vnp<op27_23, op21_20, op11_8, op6, op4,
2808          (outs QPR:$Vd), (ins QPR:$Vn, QPR:$Vm), f, itin, OpcodeStr, Dt,
2809          [(set QPR:$Vd, (ResTy (IntOp (OpTy QPR:$Vn), (OpTy QPR:$Vm))))]> {
2810  let isCommutable = Commutable;
2811}
2812
2813// Same as N3VQIntnp but with Vd as a src register.
2814class N3VQInt3np<bits<5> op27_23, bits<2> op21_20, bits<4> op11_8, bit op6,
2815                bit op4, Format f, InstrItinClass itin, string OpcodeStr,
2816                string Dt, ValueType ResTy, ValueType OpTy,
2817                SDPatternOperator IntOp>
2818  : N3Vnp<op27_23, op21_20, op11_8, op6, op4,
2819          (outs QPR:$Vd), (ins QPR:$src, QPR:$Vn, QPR:$Vm),
2820          f, itin, OpcodeStr, Dt,
2821          [(set QPR:$Vd, (ResTy (IntOp (OpTy QPR:$src), (OpTy QPR:$Vn),
2822                                       (OpTy QPR:$Vm))))]> {
2823  let Constraints = "$src = $Vd";
2824  let isCommutable = 0;
2825}
2826
2827class N3VQIntSL<bits<2> op21_20, bits<4> op11_8, InstrItinClass itin,
2828                string OpcodeStr, string Dt,
2829                ValueType ResTy, ValueType OpTy, SDPatternOperator IntOp>
2830  : N3VLane32<1, 1, op21_20, op11_8, 1, 0,
2831        (outs QPR:$Vd), (ins QPR:$Vn, DPR_VFP2:$Vm, VectorIndex32:$lane),
2832        NVMulSLFrm, itin, OpcodeStr, Dt, "$Vd, $Vn, $Vm$lane", "",
2833        [(set (ResTy QPR:$Vd),
2834              (ResTy (IntOp (ResTy QPR:$Vn),
2835                            (ResTy (ARMvduplane (OpTy DPR_VFP2:$Vm),
2836                                                 imm:$lane)))))]> {
2837  let isCommutable = 0;
2838}
2839class N3VQIntSL16<bits<2> op21_20, bits<4> op11_8, InstrItinClass itin,
2840                  string OpcodeStr, string Dt,
2841                  ValueType ResTy, ValueType OpTy, SDPatternOperator IntOp>
2842  : N3VLane16<1, 1, op21_20, op11_8, 1, 0,
2843        (outs QPR:$Vd), (ins QPR:$Vn, DPR_8:$Vm, VectorIndex16:$lane),
2844        NVMulSLFrm, itin, OpcodeStr, Dt, "$Vd, $Vn, $Vm$lane", "",
2845        [(set (ResTy QPR:$Vd),
2846              (ResTy (IntOp (ResTy QPR:$Vn),
2847                            (ResTy (ARMvduplane (OpTy DPR_8:$Vm),
2848                                                 imm:$lane)))))]> {
2849  let isCommutable = 0;
2850}
2851class N3VQIntSh<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op4,
2852              Format f, InstrItinClass itin, string OpcodeStr, string Dt,
2853              ValueType ResTy, ValueType OpTy, SDPatternOperator IntOp>
2854  : N3V<op24, op23, op21_20, op11_8, 1, op4,
2855        (outs QPR:$Vd), (ins QPR:$Vm, QPR:$Vn), f, itin,
2856        OpcodeStr, Dt, "$Vd, $Vm, $Vn", "",
2857        [(set QPR:$Vd, (ResTy (IntOp (OpTy QPR:$Vm), (OpTy QPR:$Vn))))]> {
2858  let TwoOperandAliasConstraint = "$Vm = $Vd";
2859  let isCommutable = 0;
2860}
2861
2862// Multiply-Add/Sub operations: double- and quad-register.
2863class N3VDMulOp<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op4,
2864                InstrItinClass itin, string OpcodeStr, string Dt,
2865                ValueType Ty, SDPatternOperator MulOp, SDPatternOperator OpNode>
2866  : N3V<op24, op23, op21_20, op11_8, 0, op4,
2867        (outs DPR:$Vd), (ins DPR:$src1, DPR:$Vn, DPR:$Vm), N3RegFrm, itin,
2868        OpcodeStr, Dt, "$Vd, $Vn, $Vm", "$src1 = $Vd",
2869        [(set DPR:$Vd, (Ty (OpNode DPR:$src1,
2870                             (Ty (MulOp DPR:$Vn, DPR:$Vm)))))]>;
2871
2872class N3VDMulOpSL<bits<2> op21_20, bits<4> op11_8, InstrItinClass itin,
2873                  string OpcodeStr, string Dt,
2874                  ValueType Ty, SDPatternOperator MulOp, SDPatternOperator ShOp>
2875  : N3VLane32<0, 1, op21_20, op11_8, 1, 0,
2876        (outs DPR:$Vd),
2877        (ins DPR:$src1, DPR:$Vn, DPR_VFP2:$Vm, VectorIndex32:$lane),
2878        NVMulSLFrm, itin,
2879        OpcodeStr, Dt, "$Vd, $Vn, $Vm$lane", "$src1 = $Vd",
2880        [(set (Ty DPR:$Vd),
2881              (Ty (ShOp (Ty DPR:$src1),
2882                        (Ty (MulOp DPR:$Vn,
2883                                   (Ty (ARMvduplane (Ty DPR_VFP2:$Vm),
2884                                                     imm:$lane)))))))]>;
2885class N3VDMulOpSL16<bits<2> op21_20, bits<4> op11_8, InstrItinClass itin,
2886                    string OpcodeStr, string Dt,
2887                    ValueType Ty, SDPatternOperator MulOp, SDPatternOperator ShOp>
2888  : N3VLane16<0, 1, op21_20, op11_8, 1, 0,
2889        (outs DPR:$Vd),
2890        (ins DPR:$src1, DPR:$Vn, DPR_8:$Vm, VectorIndex16:$lane),
2891        NVMulSLFrm, itin,
2892        OpcodeStr, Dt, "$Vd, $Vn, $Vm$lane", "$src1 = $Vd",
2893        [(set (Ty DPR:$Vd),
2894              (Ty (ShOp (Ty DPR:$src1),
2895                        (Ty (MulOp DPR:$Vn,
2896                                   (Ty (ARMvduplane (Ty DPR_8:$Vm),
2897                                                     imm:$lane)))))))]>;
2898
2899class N3VQMulOp<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op4,
2900                InstrItinClass itin, string OpcodeStr, string Dt, ValueType Ty,
2901                SDPatternOperator MulOp, SDPatternOperator OpNode>
2902  : N3V<op24, op23, op21_20, op11_8, 1, op4,
2903        (outs QPR:$Vd), (ins QPR:$src1, QPR:$Vn, QPR:$Vm), N3RegFrm, itin,
2904        OpcodeStr, Dt, "$Vd, $Vn, $Vm", "$src1 = $Vd",
2905        [(set QPR:$Vd, (Ty (OpNode QPR:$src1,
2906                             (Ty (MulOp QPR:$Vn, QPR:$Vm)))))]>;
2907class N3VQMulOpSL<bits<2> op21_20, bits<4> op11_8, InstrItinClass itin,
2908                  string OpcodeStr, string Dt, ValueType ResTy, ValueType OpTy,
2909                  SDPatternOperator MulOp, SDPatternOperator ShOp>
2910  : N3VLane32<1, 1, op21_20, op11_8, 1, 0,
2911        (outs QPR:$Vd),
2912        (ins QPR:$src1, QPR:$Vn, DPR_VFP2:$Vm, VectorIndex32:$lane),
2913        NVMulSLFrm, itin,
2914        OpcodeStr, Dt, "$Vd, $Vn, $Vm$lane", "$src1 = $Vd",
2915        [(set (ResTy QPR:$Vd),
2916              (ResTy (ShOp (ResTy QPR:$src1),
2917                           (ResTy (MulOp QPR:$Vn,
2918                                   (ResTy (ARMvduplane (OpTy DPR_VFP2:$Vm),
2919                                                        imm:$lane)))))))]>;
2920class N3VQMulOpSL16<bits<2> op21_20, bits<4> op11_8, InstrItinClass itin,
2921                    string OpcodeStr, string Dt,
2922                    ValueType ResTy, ValueType OpTy,
2923                    SDPatternOperator MulOp, SDPatternOperator ShOp>
2924  : N3VLane16<1, 1, op21_20, op11_8, 1, 0,
2925        (outs QPR:$Vd),
2926        (ins QPR:$src1, QPR:$Vn, DPR_8:$Vm, VectorIndex16:$lane),
2927        NVMulSLFrm, itin,
2928        OpcodeStr, Dt, "$Vd, $Vn, $Vm$lane", "$src1 = $Vd",
2929        [(set (ResTy QPR:$Vd),
2930              (ResTy (ShOp (ResTy QPR:$src1),
2931                           (ResTy (MulOp QPR:$Vn,
2932                                   (ResTy (ARMvduplane (OpTy DPR_8:$Vm),
2933                                                        imm:$lane)))))))]>;
2934
2935// Neon Intrinsic-Op instructions (VABA): double- and quad-register.
2936class N3VDIntOp<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op4,
2937                InstrItinClass itin, string OpcodeStr, string Dt,
2938                ValueType Ty, SDPatternOperator IntOp, SDNode OpNode>
2939  : N3V<op24, op23, op21_20, op11_8, 0, op4,
2940        (outs DPR:$Vd), (ins DPR:$src1, DPR:$Vn, DPR:$Vm), N3RegFrm, itin,
2941        OpcodeStr, Dt, "$Vd, $Vn, $Vm", "$src1 = $Vd",
2942        [(set DPR:$Vd, (Ty (OpNode DPR:$src1,
2943                             (Ty (IntOp (Ty DPR:$Vn), (Ty DPR:$Vm))))))]>;
2944class N3VQIntOp<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op4,
2945                InstrItinClass itin, string OpcodeStr, string Dt,
2946                ValueType Ty, SDPatternOperator IntOp, SDNode OpNode>
2947  : N3V<op24, op23, op21_20, op11_8, 1, op4,
2948        (outs QPR:$Vd), (ins QPR:$src1, QPR:$Vn, QPR:$Vm), N3RegFrm, itin,
2949        OpcodeStr, Dt, "$Vd, $Vn, $Vm", "$src1 = $Vd",
2950        [(set QPR:$Vd, (Ty (OpNode QPR:$src1,
2951                             (Ty (IntOp (Ty QPR:$Vn), (Ty QPR:$Vm))))))]>;
2952
2953// Neon 3-argument intrinsics, both double- and quad-register.
2954// The destination register is also used as the first source operand register.
2955class N3VDInt3<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op4,
2956               InstrItinClass itin, string OpcodeStr, string Dt,
2957               ValueType ResTy, ValueType OpTy, SDPatternOperator IntOp>
2958  : N3V<op24, op23, op21_20, op11_8, 0, op4,
2959        (outs DPR:$Vd), (ins DPR:$src1, DPR:$Vn, DPR:$Vm), N3RegFrm, itin,
2960        OpcodeStr, Dt, "$Vd, $Vn, $Vm", "$src1 = $Vd",
2961        [(set DPR:$Vd, (ResTy (IntOp (OpTy DPR:$src1),
2962                                      (OpTy DPR:$Vn), (OpTy DPR:$Vm))))]>;
2963class N3VQInt3<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op4,
2964               InstrItinClass itin, string OpcodeStr, string Dt,
2965               ValueType ResTy, ValueType OpTy, SDPatternOperator IntOp>
2966  : N3V<op24, op23, op21_20, op11_8, 1, op4,
2967        (outs QPR:$Vd), (ins QPR:$src1, QPR:$Vn, QPR:$Vm), N3RegFrm, itin,
2968        OpcodeStr, Dt, "$Vd, $Vn, $Vm", "$src1 = $Vd",
2969        [(set QPR:$Vd, (ResTy (IntOp (OpTy QPR:$src1),
2970                                      (OpTy QPR:$Vn), (OpTy QPR:$Vm))))]>;
2971
2972// Long Multiply-Add/Sub operations.
2973class N3VLMulOp<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op4,
2974                InstrItinClass itin, string OpcodeStr, string Dt,
2975                ValueType TyQ, ValueType TyD, SDNode MulOp, SDNode OpNode>
2976  : N3V<op24, op23, op21_20, op11_8, 0, op4,
2977        (outs QPR:$Vd), (ins QPR:$src1, DPR:$Vn, DPR:$Vm), N3RegFrm, itin,
2978        OpcodeStr, Dt, "$Vd, $Vn, $Vm", "$src1 = $Vd",
2979        [(set QPR:$Vd, (OpNode (TyQ QPR:$src1),
2980                                (TyQ (MulOp (TyD DPR:$Vn),
2981                                            (TyD DPR:$Vm)))))]>;
2982class N3VLMulOpSL<bit op24, bits<2> op21_20, bits<4> op11_8,
2983                  InstrItinClass itin, string OpcodeStr, string Dt,
2984                  ValueType TyQ, ValueType TyD, SDNode MulOp, SDNode OpNode>
2985  : N3VLane32<op24, 1, op21_20, op11_8, 1, 0, (outs QPR:$Vd),
2986        (ins QPR:$src1, DPR:$Vn, DPR_VFP2:$Vm, VectorIndex32:$lane),
2987        NVMulSLFrm, itin,
2988        OpcodeStr, Dt, "$Vd, $Vn, $Vm$lane", "$src1 = $Vd",
2989        [(set QPR:$Vd,
2990          (OpNode (TyQ QPR:$src1),
2991                  (TyQ (MulOp (TyD DPR:$Vn),
2992                              (TyD (ARMvduplane (TyD DPR_VFP2:$Vm),
2993                                                 imm:$lane))))))]>;
2994class N3VLMulOpSL16<bit op24, bits<2> op21_20, bits<4> op11_8,
2995                    InstrItinClass itin, string OpcodeStr, string Dt,
2996                    ValueType TyQ, ValueType TyD, SDNode MulOp, SDNode OpNode>
2997  : N3VLane16<op24, 1, op21_20, op11_8, 1, 0, (outs QPR:$Vd),
2998        (ins QPR:$src1, DPR:$Vn, DPR_8:$Vm, VectorIndex16:$lane),
2999        NVMulSLFrm, itin,
3000        OpcodeStr, Dt, "$Vd, $Vn, $Vm$lane", "$src1 = $Vd",
3001        [(set QPR:$Vd,
3002          (OpNode (TyQ QPR:$src1),
3003                  (TyQ (MulOp (TyD DPR:$Vn),
3004                              (TyD (ARMvduplane (TyD DPR_8:$Vm),
3005                                                 imm:$lane))))))]>;
3006
3007// Long Intrinsic-Op vector operations with explicit extend (VABAL).
3008class N3VLIntExtOp<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op4,
3009                   InstrItinClass itin, string OpcodeStr, string Dt,
3010                   ValueType TyQ, ValueType TyD, SDPatternOperator IntOp, SDNode ExtOp,
3011                   SDNode OpNode>
3012  : N3V<op24, op23, op21_20, op11_8, 0, op4,
3013        (outs QPR:$Vd), (ins QPR:$src1, DPR:$Vn, DPR:$Vm), N3RegFrm, itin,
3014        OpcodeStr, Dt, "$Vd, $Vn, $Vm", "$src1 = $Vd",
3015        [(set QPR:$Vd, (OpNode (TyQ QPR:$src1),
3016                                (TyQ (ExtOp (TyD (IntOp (TyD DPR:$Vn),
3017                                                        (TyD DPR:$Vm)))))))]>;
3018
3019// Neon Long 3-argument intrinsic.  The destination register is
3020// a quad-register and is also used as the first source operand register.
3021class N3VLInt3<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op4,
3022               InstrItinClass itin, string OpcodeStr, string Dt,
3023               ValueType TyQ, ValueType TyD, SDPatternOperator IntOp>
3024  : N3V<op24, op23, op21_20, op11_8, 0, op4,
3025        (outs QPR:$Vd), (ins QPR:$src1, DPR:$Vn, DPR:$Vm), N3RegFrm, itin,
3026        OpcodeStr, Dt, "$Vd, $Vn, $Vm", "$src1 = $Vd",
3027        [(set QPR:$Vd,
3028          (TyQ (IntOp (TyQ QPR:$src1), (TyD DPR:$Vn), (TyD DPR:$Vm))))]>;
3029class N3VLInt3SL<bit op24, bits<2> op21_20, bits<4> op11_8, InstrItinClass itin,
3030                 string OpcodeStr, string Dt,
3031                 ValueType ResTy, ValueType OpTy, SDPatternOperator IntOp>
3032  : N3VLane32<op24, 1, op21_20, op11_8, 1, 0,
3033        (outs QPR:$Vd),
3034        (ins QPR:$src1, DPR:$Vn, DPR_VFP2:$Vm, VectorIndex32:$lane),
3035        NVMulSLFrm, itin,
3036        OpcodeStr, Dt, "$Vd, $Vn, $Vm$lane", "$src1 = $Vd",
3037        [(set (ResTy QPR:$Vd),
3038              (ResTy (IntOp (ResTy QPR:$src1),
3039                            (OpTy DPR:$Vn),
3040                            (OpTy (ARMvduplane (OpTy DPR_VFP2:$Vm),
3041                                                imm:$lane)))))]>;
3042class N3VLInt3SL16<bit op24, bits<2> op21_20, bits<4> op11_8,
3043                   InstrItinClass itin, string OpcodeStr, string Dt,
3044                   ValueType ResTy, ValueType OpTy, SDPatternOperator IntOp>
3045  : N3VLane16<op24, 1, op21_20, op11_8, 1, 0,
3046        (outs QPR:$Vd),
3047        (ins QPR:$src1, DPR:$Vn, DPR_8:$Vm, VectorIndex16:$lane),
3048        NVMulSLFrm, itin,
3049        OpcodeStr, Dt, "$Vd, $Vn, $Vm$lane", "$src1 = $Vd",
3050        [(set (ResTy QPR:$Vd),
3051              (ResTy (IntOp (ResTy QPR:$src1),
3052                            (OpTy DPR:$Vn),
3053                            (OpTy (ARMvduplane (OpTy DPR_8:$Vm),
3054                                                imm:$lane)))))]>;
3055
3056// Narrowing 3-register intrinsics.
3057class N3VNInt<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op4,
3058              string OpcodeStr, string Dt, ValueType TyD, ValueType TyQ,
3059              SDPatternOperator IntOp, bit Commutable>
3060  : N3V<op24, op23, op21_20, op11_8, 0, op4,
3061        (outs DPR:$Vd), (ins QPR:$Vn, QPR:$Vm), N3RegFrm, IIC_VBINi4D,
3062        OpcodeStr, Dt, "$Vd, $Vn, $Vm", "",
3063        [(set DPR:$Vd, (TyD (IntOp (TyQ QPR:$Vn), (TyQ QPR:$Vm))))]> {
3064  let isCommutable = Commutable;
3065}
3066
3067// Long 3-register operations.
3068class N3VL<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op4,
3069           InstrItinClass itin, string OpcodeStr, string Dt,
3070           ValueType TyQ, ValueType TyD, SDNode OpNode, bit Commutable>
3071  : N3V<op24, op23, op21_20, op11_8, 0, op4,
3072        (outs QPR:$Vd), (ins DPR:$Vn, DPR:$Vm), N3RegFrm, itin,
3073        OpcodeStr, Dt, "$Vd, $Vn, $Vm", "",
3074        [(set QPR:$Vd, (TyQ (OpNode (TyD DPR:$Vn), (TyD DPR:$Vm))))]> {
3075  let isCommutable = Commutable;
3076}
3077
3078class N3VLSL<bit op24, bits<2> op21_20, bits<4> op11_8,
3079             InstrItinClass itin, string OpcodeStr, string Dt,
3080             ValueType TyQ, ValueType TyD, SDNode OpNode>
3081  : N3VLane32<op24, 1, op21_20, op11_8, 1, 0,
3082        (outs QPR:$Vd), (ins DPR:$Vn, DPR_VFP2:$Vm, VectorIndex32:$lane),
3083        NVMulSLFrm, itin, OpcodeStr, Dt, "$Vd, $Vn, $Vm$lane", "",
3084        [(set QPR:$Vd,
3085          (TyQ (OpNode (TyD DPR:$Vn),
3086                       (TyD (ARMvduplane (TyD DPR_VFP2:$Vm),imm:$lane)))))]>;
3087class N3VLSL16<bit op24, bits<2> op21_20, bits<4> op11_8,
3088               InstrItinClass itin, string OpcodeStr, string Dt,
3089               ValueType TyQ, ValueType TyD, SDNode OpNode>
3090  : N3VLane16<op24, 1, op21_20, op11_8, 1, 0,
3091        (outs QPR:$Vd), (ins DPR:$Vn, DPR_8:$Vm, VectorIndex16:$lane),
3092        NVMulSLFrm, itin, OpcodeStr, Dt, "$Vd, $Vn, $Vm$lane", "",
3093        [(set QPR:$Vd,
3094          (TyQ (OpNode (TyD DPR:$Vn),
3095                       (TyD (ARMvduplane (TyD DPR_8:$Vm), imm:$lane)))))]>;
3096
3097// Long 3-register operations with explicitly extended operands.
3098class N3VLExt<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op4,
3099              InstrItinClass itin, string OpcodeStr, string Dt,
3100              ValueType TyQ, ValueType TyD, SDNode OpNode, SDPatternOperator ExtOp,
3101              bit Commutable>
3102  : N3V<op24, op23, op21_20, op11_8, 0, op4,
3103        (outs QPR:$Vd), (ins DPR:$Vn, DPR:$Vm), N3RegFrm, itin,
3104        OpcodeStr, Dt, "$Vd, $Vn, $Vm", "",
3105        [(set QPR:$Vd, (OpNode (TyQ (ExtOp (TyD DPR:$Vn))),
3106                                (TyQ (ExtOp (TyD DPR:$Vm)))))]> {
3107  let isCommutable = Commutable;
3108}
3109
3110// Long 3-register intrinsics with explicit extend (VABDL).
3111class N3VLIntExt<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op4,
3112                 InstrItinClass itin, string OpcodeStr, string Dt,
3113                 ValueType TyQ, ValueType TyD, SDPatternOperator IntOp, SDNode ExtOp,
3114                 bit Commutable>
3115  : N3V<op24, op23, op21_20, op11_8, 0, op4,
3116        (outs QPR:$Vd), (ins DPR:$Vn, DPR:$Vm), N3RegFrm, itin,
3117        OpcodeStr, Dt, "$Vd, $Vn, $Vm", "",
3118        [(set QPR:$Vd, (TyQ (ExtOp (TyD (IntOp (TyD DPR:$Vn),
3119                                                (TyD DPR:$Vm))))))]> {
3120  let isCommutable = Commutable;
3121}
3122
3123// Long 3-register intrinsics.
3124class N3VLInt<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op4,
3125              InstrItinClass itin, string OpcodeStr, string Dt,
3126              ValueType TyQ, ValueType TyD, SDPatternOperator IntOp, bit Commutable>
3127  : N3V<op24, op23, op21_20, op11_8, 0, op4,
3128        (outs QPR:$Vd), (ins DPR:$Vn, DPR:$Vm), N3RegFrm, itin,
3129        OpcodeStr, Dt, "$Vd, $Vn, $Vm", "",
3130        [(set QPR:$Vd, (TyQ (IntOp (TyD DPR:$Vn), (TyD DPR:$Vm))))]> {
3131  let isCommutable = Commutable;
3132}
3133
3134// Same as above, but not predicated.
3135class N3VLIntnp<bits<5> op27_23, bits<2> op21_20, bits<4> op11_8, bit op6,
3136                bit op4, InstrItinClass itin, string OpcodeStr,
3137                string Dt, ValueType ResTy, ValueType OpTy,
3138                SDPatternOperator IntOp, bit Commutable>
3139  : N3Vnp<op27_23, op21_20, op11_8, op6, op4,
3140          (outs QPR:$Vd), (ins DPR:$Vn, DPR:$Vm), N3RegFrm, itin, OpcodeStr, Dt,
3141          [(set QPR:$Vd, (ResTy (IntOp (OpTy DPR:$Vn), (OpTy DPR:$Vm))))]> {
3142  let isCommutable = Commutable;
3143}
3144
3145
3146class N3VLIntSL<bit op24, bits<2> op21_20, bits<4> op11_8, InstrItinClass itin,
3147                string OpcodeStr, string Dt,
3148                ValueType ResTy, ValueType OpTy, SDPatternOperator IntOp>
3149  : N3VLane32<op24, 1, op21_20, op11_8, 1, 0,
3150        (outs QPR:$Vd), (ins DPR:$Vn, DPR_VFP2:$Vm, VectorIndex32:$lane),
3151        NVMulSLFrm, itin, OpcodeStr, Dt, "$Vd, $Vn, $Vm$lane", "",
3152        [(set (ResTy QPR:$Vd),
3153              (ResTy (IntOp (OpTy DPR:$Vn),
3154                            (OpTy (ARMvduplane (OpTy DPR_VFP2:$Vm),
3155                                                imm:$lane)))))]>;
3156class N3VLIntSL16<bit op24, bits<2> op21_20, bits<4> op11_8,
3157                  InstrItinClass itin, string OpcodeStr, string Dt,
3158                  ValueType ResTy, ValueType OpTy, SDPatternOperator IntOp>
3159  : N3VLane16<op24, 1, op21_20, op11_8, 1, 0,
3160        (outs QPR:$Vd), (ins DPR:$Vn, DPR_8:$Vm, VectorIndex16:$lane),
3161        NVMulSLFrm, itin, OpcodeStr, Dt, "$Vd, $Vn, $Vm$lane", "",
3162        [(set (ResTy QPR:$Vd),
3163              (ResTy (IntOp (OpTy DPR:$Vn),
3164                            (OpTy (ARMvduplane (OpTy DPR_8:$Vm),
3165                                                imm:$lane)))))]>;
3166
3167// Wide 3-register operations.
3168class N3VW<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op4,
3169           string OpcodeStr, string Dt, ValueType TyQ, ValueType TyD,
3170           SDNode OpNode, SDPatternOperator ExtOp, bit Commutable>
3171  : N3V<op24, op23, op21_20, op11_8, 0, op4,
3172        (outs QPR:$Vd), (ins QPR:$Vn, DPR:$Vm), N3RegFrm, IIC_VSUBiD,
3173        OpcodeStr, Dt, "$Vd, $Vn, $Vm", "",
3174        [(set QPR:$Vd, (OpNode (TyQ QPR:$Vn),
3175                                (TyQ (ExtOp (TyD DPR:$Vm)))))]> {
3176  // All of these have a two-operand InstAlias.
3177  let TwoOperandAliasConstraint = "$Vn = $Vd";
3178  let isCommutable = Commutable;
3179}
3180
3181// Pairwise long 2-register intrinsics, both double- and quad-register.
3182class N2VDPLInt<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18,
3183                bits<2> op17_16, bits<5> op11_7, bit op4,
3184                string OpcodeStr, string Dt,
3185                ValueType ResTy, ValueType OpTy, SDPatternOperator IntOp>
3186  : N2V<op24_23, op21_20, op19_18, op17_16, op11_7, 0, op4, (outs DPR:$Vd),
3187        (ins DPR:$Vm), IIC_VSHLiD, OpcodeStr, Dt, "$Vd, $Vm", "",
3188        [(set DPR:$Vd, (ResTy (IntOp (OpTy DPR:$Vm))))]>;
3189class N2VQPLInt<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18,
3190                bits<2> op17_16, bits<5> op11_7, bit op4,
3191                string OpcodeStr, string Dt,
3192                ValueType ResTy, ValueType OpTy, SDPatternOperator IntOp>
3193  : N2V<op24_23, op21_20, op19_18, op17_16, op11_7, 1, op4, (outs QPR:$Vd),
3194        (ins QPR:$Vm), IIC_VSHLiD, OpcodeStr, Dt, "$Vd, $Vm", "",
3195        [(set QPR:$Vd, (ResTy (IntOp (OpTy QPR:$Vm))))]>;
3196
3197// Pairwise long 2-register accumulate intrinsics,
3198// both double- and quad-register.
3199// The destination register is also used as the first source operand register.
3200class N2VDPLInt2<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18,
3201                 bits<2> op17_16, bits<5> op11_7, bit op4,
3202                 string OpcodeStr, string Dt,
3203                 ValueType ResTy, ValueType OpTy, SDPatternOperator IntOp>
3204  : N2V<op24_23, op21_20, op19_18, op17_16, op11_7, 0, op4,
3205        (outs DPR:$Vd), (ins DPR:$src1, DPR:$Vm), IIC_VPALiD,
3206        OpcodeStr, Dt, "$Vd, $Vm", "$src1 = $Vd",
3207        [(set DPR:$Vd, (ResTy (IntOp (ResTy DPR:$src1), (OpTy DPR:$Vm))))]>;
3208class N2VQPLInt2<bits<2> op24_23, bits<2> op21_20, bits<2> op19_18,
3209                 bits<2> op17_16, bits<5> op11_7, bit op4,
3210                 string OpcodeStr, string Dt,
3211                 ValueType ResTy, ValueType OpTy, SDPatternOperator IntOp>
3212  : N2V<op24_23, op21_20, op19_18, op17_16, op11_7, 1, op4,
3213        (outs QPR:$Vd), (ins QPR:$src1, QPR:$Vm), IIC_VPALiQ,
3214        OpcodeStr, Dt, "$Vd, $Vm", "$src1 = $Vd",
3215        [(set QPR:$Vd, (ResTy (IntOp (ResTy QPR:$src1), (OpTy QPR:$Vm))))]>;
3216
3217// Shift by immediate,
3218// both double- and quad-register.
3219let TwoOperandAliasConstraint = "$Vm = $Vd" in {
3220class N2VDSh<bit op24, bit op23, bits<4> op11_8, bit op7, bit op4,
3221             Format f, InstrItinClass itin, Operand ImmTy,
3222             string OpcodeStr, string Dt, ValueType Ty, SDNode OpNode>
3223  : N2VImm<op24, op23, op11_8, op7, 0, op4,
3224           (outs DPR:$Vd), (ins DPR:$Vm, ImmTy:$SIMM), f, itin,
3225           OpcodeStr, Dt, "$Vd, $Vm, $SIMM", "",
3226           [(set DPR:$Vd, (Ty (OpNode (Ty DPR:$Vm), (i32 imm:$SIMM))))]>;
3227class N2VQSh<bit op24, bit op23, bits<4> op11_8, bit op7, bit op4,
3228             Format f, InstrItinClass itin, Operand ImmTy,
3229             string OpcodeStr, string Dt, ValueType Ty, SDNode OpNode>
3230  : N2VImm<op24, op23, op11_8, op7, 1, op4,
3231           (outs QPR:$Vd), (ins QPR:$Vm, ImmTy:$SIMM), f, itin,
3232           OpcodeStr, Dt, "$Vd, $Vm, $SIMM", "",
3233           [(set QPR:$Vd, (Ty (OpNode (Ty QPR:$Vm), (i32 imm:$SIMM))))]>;
3234}
3235
3236// Long shift by immediate.
3237class N2VLSh<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
3238             string OpcodeStr, string Dt,
3239             ValueType ResTy, ValueType OpTy, Operand ImmTy,
3240             SDPatternOperator OpNode>
3241  : N2VImm<op24, op23, op11_8, op7, op6, op4,
3242           (outs QPR:$Vd), (ins DPR:$Vm, ImmTy:$SIMM), N2RegVShLFrm,
3243           IIC_VSHLiD, OpcodeStr, Dt, "$Vd, $Vm, $SIMM", "",
3244           [(set QPR:$Vd, (ResTy (OpNode (OpTy DPR:$Vm), ImmTy:$SIMM)))]>;
3245
3246// Narrow shift by immediate.
3247class N2VNSh<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6, bit op4,
3248             InstrItinClass itin, string OpcodeStr, string Dt,
3249             ValueType ResTy, ValueType OpTy, Operand ImmTy,
3250             SDPatternOperator OpNode>
3251  : N2VImm<op24, op23, op11_8, op7, op6, op4,
3252           (outs DPR:$Vd), (ins QPR:$Vm, ImmTy:$SIMM), N2RegVShRFrm, itin,
3253           OpcodeStr, Dt, "$Vd, $Vm, $SIMM", "",
3254           [(set DPR:$Vd, (ResTy (OpNode (OpTy QPR:$Vm),
3255                                          (i32 ImmTy:$SIMM))))]>;
3256
3257// Shift right by immediate and accumulate,
3258// both double- and quad-register.
3259let TwoOperandAliasConstraint = "$Vm = $Vd" in {
3260class N2VDShAdd<bit op24, bit op23, bits<4> op11_8, bit op7, bit op4,
3261                Operand ImmTy, string OpcodeStr, string Dt,
3262                ValueType Ty, SDNode ShOp>
3263  : N2VImm<op24, op23, op11_8, op7, 0, op4, (outs DPR:$Vd),
3264           (ins DPR:$src1, DPR:$Vm, ImmTy:$SIMM), N2RegVShRFrm, IIC_VPALiD,
3265           OpcodeStr, Dt, "$Vd, $Vm, $SIMM", "$src1 = $Vd",
3266           [(set DPR:$Vd, (Ty (add DPR:$src1,
3267                                (Ty (ShOp DPR:$Vm, (i32 imm:$SIMM))))))]>;
3268class N2VQShAdd<bit op24, bit op23, bits<4> op11_8, bit op7, bit op4,
3269                Operand ImmTy, string OpcodeStr, string Dt,
3270                ValueType Ty, SDNode ShOp>
3271  : N2VImm<op24, op23, op11_8, op7, 1, op4, (outs QPR:$Vd),
3272           (ins QPR:$src1, QPR:$Vm, ImmTy:$SIMM), N2RegVShRFrm, IIC_VPALiD,
3273           OpcodeStr, Dt, "$Vd, $Vm, $SIMM", "$src1 = $Vd",
3274           [(set QPR:$Vd, (Ty (add QPR:$src1,
3275                                (Ty (ShOp QPR:$Vm, (i32 imm:$SIMM))))))]>;
3276}
3277
3278// Shift by immediate and insert,
3279// both double- and quad-register.
3280let TwoOperandAliasConstraint = "$Vm = $Vd" in {
3281class N2VDShIns<bit op24, bit op23, bits<4> op11_8, bit op7, bit op4,
3282                Operand ImmTy, Format f, string OpcodeStr, string Dt,
3283                ValueType Ty,SDNode ShOp>
3284  : N2VImm<op24, op23, op11_8, op7, 0, op4, (outs DPR:$Vd),
3285           (ins DPR:$src1, DPR:$Vm, ImmTy:$SIMM), f, IIC_VSHLiD,
3286           OpcodeStr, Dt, "$Vd, $Vm, $SIMM", "$src1 = $Vd",
3287           [(set DPR:$Vd, (Ty (ShOp DPR:$src1, DPR:$Vm, (i32 imm:$SIMM))))]>;
3288class N2VQShIns<bit op24, bit op23, bits<4> op11_8, bit op7, bit op4,
3289                Operand ImmTy, Format f, string OpcodeStr, string Dt,
3290                ValueType Ty,SDNode ShOp>
3291  : N2VImm<op24, op23, op11_8, op7, 1, op4, (outs QPR:$Vd),
3292           (ins QPR:$src1, QPR:$Vm, ImmTy:$SIMM), f, IIC_VSHLiQ,
3293           OpcodeStr, Dt, "$Vd, $Vm, $SIMM", "$src1 = $Vd",
3294           [(set QPR:$Vd, (Ty (ShOp QPR:$src1, QPR:$Vm, (i32 imm:$SIMM))))]>;
3295}
3296
3297// Convert, with fractional bits immediate,
3298// both double- and quad-register.
3299class N2VCvtD<bit op24, bit op23, bits<4> op11_8, bit op7, bit op4,
3300              string OpcodeStr, string Dt, ValueType ResTy, ValueType OpTy,
3301              SDPatternOperator IntOp>
3302  : N2VImm<op24, op23, op11_8, op7, 0, op4,
3303           (outs DPR:$Vd), (ins DPR:$Vm, neon_vcvt_imm32:$SIMM), NVCVTFrm,
3304           IIC_VUNAD, OpcodeStr, Dt, "$Vd, $Vm, $SIMM", "",
3305           [(set DPR:$Vd, (ResTy (IntOp (OpTy DPR:$Vm), (i32 imm:$SIMM))))]>;
3306class N2VCvtQ<bit op24, bit op23, bits<4> op11_8, bit op7, bit op4,
3307              string OpcodeStr, string Dt, ValueType ResTy, ValueType OpTy,
3308              SDPatternOperator IntOp>
3309  : N2VImm<op24, op23, op11_8, op7, 1, op4,
3310           (outs QPR:$Vd), (ins QPR:$Vm, neon_vcvt_imm32:$SIMM), NVCVTFrm,
3311           IIC_VUNAQ, OpcodeStr, Dt, "$Vd, $Vm, $SIMM", "",
3312           [(set QPR:$Vd, (ResTy (IntOp (OpTy QPR:$Vm), (i32 imm:$SIMM))))]>;
3313
3314//===----------------------------------------------------------------------===//
3315// Multiclasses
3316//===----------------------------------------------------------------------===//
3317
3318// Abbreviations used in multiclass suffixes:
3319//   Q = quarter int (8 bit) elements
3320//   H = half int (16 bit) elements
3321//   S = single int (32 bit) elements
3322//   D = double int (64 bit) elements
3323
3324// Neon 2-register vector operations and intrinsics.
3325
3326// Neon 2-register comparisons.
3327//   source operand element sizes of 8, 16 and 32 bits:
3328multiclass N2V_QHS_cmp<bits<2> op24_23, bits<2> op21_20, bits<2> op17_16,
3329                       bits<5> op11_7, bit op4, string opc, string Dt,
3330                       string asm, PatFrag fc> {
3331  // 64-bit vector types.
3332  def v8i8  : N2V<op24_23, op21_20, 0b00, op17_16, op11_7, 0, op4,
3333                  (outs DPR:$Vd), (ins DPR:$Vm), NoItinerary,
3334                  opc, !strconcat(Dt, "8"), asm, "",
3335                  [(set DPR:$Vd, (v8i8 (ARMvcmpz (v8i8 DPR:$Vm), fc)))]>;
3336  def v4i16 : N2V<op24_23, op21_20, 0b01, op17_16, op11_7, 0, op4,
3337                  (outs DPR:$Vd), (ins DPR:$Vm), NoItinerary,
3338                  opc, !strconcat(Dt, "16"), asm, "",
3339                  [(set DPR:$Vd, (v4i16 (ARMvcmpz (v4i16 DPR:$Vm), fc)))]>;
3340  def v2i32 : N2V<op24_23, op21_20, 0b10, op17_16, op11_7, 0, op4,
3341                  (outs DPR:$Vd), (ins DPR:$Vm), NoItinerary,
3342                  opc, !strconcat(Dt, "32"), asm, "",
3343                  [(set DPR:$Vd, (v2i32 (ARMvcmpz (v2i32 DPR:$Vm), fc)))]>;
3344  def v2f32 : N2V<op24_23, op21_20, 0b10, op17_16, op11_7, 0, op4,
3345                  (outs DPR:$Vd), (ins DPR:$Vm), NoItinerary,
3346                  opc, "f32", asm, "",
3347                  [(set DPR:$Vd, (v2i32 (ARMvcmpz (v2f32 DPR:$Vm), fc)))]> {
3348    let Inst{10} = 1; // overwrite F = 1
3349  }
3350  def v4f16 : N2V<op24_23, op21_20, 0b01, op17_16, op11_7, 0, op4,
3351                  (outs DPR:$Vd), (ins DPR:$Vm), NoItinerary,
3352                  opc, "f16", asm, "",
3353                  [(set DPR:$Vd, (v4i16 (ARMvcmpz (v4f16 DPR:$Vm), fc)))]>,
3354              Requires<[HasNEON,HasFullFP16]> {
3355    let Inst{10} = 1; // overwrite F = 1
3356  }
3357
3358  // 128-bit vector types.
3359  def v16i8 : N2V<op24_23, op21_20, 0b00, op17_16, op11_7, 1, op4,
3360                  (outs QPR:$Vd), (ins QPR:$Vm), NoItinerary,
3361                  opc, !strconcat(Dt, "8"), asm, "",
3362                  [(set QPR:$Vd, (v16i8 (ARMvcmpz (v16i8 QPR:$Vm), fc)))]>;
3363  def v8i16 : N2V<op24_23, op21_20, 0b01, op17_16, op11_7, 1, op4,
3364                  (outs QPR:$Vd), (ins QPR:$Vm), NoItinerary,
3365                  opc, !strconcat(Dt, "16"), asm, "",
3366                  [(set QPR:$Vd, (v8i16 (ARMvcmpz (v8i16 QPR:$Vm), fc)))]>;
3367  def v4i32 : N2V<op24_23, op21_20, 0b10, op17_16, op11_7, 1, op4,
3368                  (outs QPR:$Vd), (ins QPR:$Vm), NoItinerary,
3369                  opc, !strconcat(Dt, "32"), asm, "",
3370                  [(set QPR:$Vd, (v4i32 (ARMvcmpz (v4i32 QPR:$Vm), fc)))]>;
3371  def v4f32 : N2V<op24_23, op21_20, 0b10, op17_16, op11_7, 1, op4,
3372                  (outs QPR:$Vd), (ins QPR:$Vm), NoItinerary,
3373                  opc, "f32", asm, "",
3374                  [(set QPR:$Vd, (v4i32 (ARMvcmpz (v4f32 QPR:$Vm), fc)))]> {
3375    let Inst{10} = 1; // overwrite F = 1
3376  }
3377  def v8f16 : N2V<op24_23, op21_20, 0b01, op17_16, op11_7, 1, op4,
3378                  (outs QPR:$Vd), (ins QPR:$Vm), NoItinerary,
3379                  opc, "f16", asm, "",
3380                  [(set QPR:$Vd, (v8i16 (ARMvcmpz (v8f16 QPR:$Vm), fc)))]>,
3381              Requires<[HasNEON,HasFullFP16]> {
3382    let Inst{10} = 1; // overwrite F = 1
3383  }
3384}
3385
3386// Neon 3-register comparisons.
3387class N3VQ_cmp<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op4,
3388               InstrItinClass itin, string OpcodeStr, string Dt,
3389               ValueType ResTy, ValueType OpTy, PatFrag fc, bit Commutable>
3390  : N3V<op24, op23, op21_20, op11_8, 1, op4,
3391        (outs QPR:$Vd), (ins QPR:$Vn, QPR:$Vm), N3RegFrm, itin,
3392        OpcodeStr, Dt, "$Vd, $Vn, $Vm", "",
3393        [(set QPR:$Vd, (ResTy (ARMvcmp (OpTy QPR:$Vn), (OpTy QPR:$Vm), fc)))]> {
3394  // All of these have a two-operand InstAlias.
3395  let TwoOperandAliasConstraint = "$Vn = $Vd";
3396  let isCommutable = Commutable;
3397}
3398
3399class N3VD_cmp<bit op24, bit op23, bits<2> op21_20, bits<4> op11_8, bit op4,
3400               InstrItinClass itin, string OpcodeStr, string Dt,
3401               ValueType ResTy, ValueType OpTy, PatFrag fc, bit Commutable>
3402  : N3V<op24, op23, op21_20, op11_8, 0, op4,
3403        (outs DPR:$Vd), (ins DPR:$Vn, DPR:$Vm), N3RegFrm, itin,
3404        OpcodeStr, Dt, "$Vd, $Vn, $Vm", "",
3405        [(set DPR:$Vd, (ResTy (ARMvcmp (OpTy DPR:$Vn), (OpTy DPR:$Vm), fc)))]> {
3406  // All of these have a two-operand InstAlias.
3407  let TwoOperandAliasConstraint = "$Vn = $Vd";
3408  let isCommutable = Commutable;
3409}
3410
3411multiclass N3V_QHS_cmp<bit op24, bit op23, bits<4> op11_8, bit op4,
3412                       InstrItinClass itinD16, InstrItinClass itinD32,
3413                       InstrItinClass itinQ16, InstrItinClass itinQ32,
3414                       string OpcodeStr, string Dt,
3415                       PatFrag fc, bit Commutable = 0> {
3416  // 64-bit vector types.
3417  def v8i8  : N3VD_cmp<op24, op23, 0b00, op11_8, op4, itinD16,
3418                       OpcodeStr, !strconcat(Dt, "8"),
3419                       v8i8, v8i8, fc, Commutable>;
3420  def v4i16 : N3VD_cmp<op24, op23, 0b01, op11_8, op4, itinD16,
3421                       OpcodeStr, !strconcat(Dt, "16"),
3422                       v4i16, v4i16, fc, Commutable>;
3423  def v2i32 : N3VD_cmp<op24, op23, 0b10, op11_8, op4, itinD32,
3424                       OpcodeStr, !strconcat(Dt, "32"),
3425                       v2i32, v2i32, fc, Commutable>;
3426
3427  // 128-bit vector types.
3428  def v16i8 : N3VQ_cmp<op24, op23, 0b00, op11_8, op4, itinQ16,
3429                       OpcodeStr, !strconcat(Dt, "8"),
3430                       v16i8, v16i8, fc, Commutable>;
3431  def v8i16 : N3VQ_cmp<op24, op23, 0b01, op11_8, op4, itinQ16,
3432                       OpcodeStr, !strconcat(Dt, "16"),
3433                       v8i16, v8i16, fc, Commutable>;
3434  def v4i32 : N3VQ_cmp<op24, op23, 0b10, op11_8, op4, itinQ32,
3435                       OpcodeStr, !strconcat(Dt, "32"),
3436                       v4i32, v4i32, fc, Commutable>;
3437}
3438
3439
3440// Neon 2-register vector intrinsics,
3441//   element sizes of 8, 16 and 32 bits:
3442multiclass N2VInt_QHS<bits<2> op24_23, bits<2> op21_20, bits<2> op17_16,
3443                      bits<5> op11_7, bit op4,
3444                      InstrItinClass itinD, InstrItinClass itinQ,
3445                      string OpcodeStr, string Dt, SDPatternOperator IntOp> {
3446  // 64-bit vector types.
3447  def v8i8  : N2VDInt<op24_23, op21_20, 0b00, op17_16, op11_7, op4,
3448                      itinD, OpcodeStr, !strconcat(Dt, "8"), v8i8, v8i8, IntOp>;
3449  def v4i16 : N2VDInt<op24_23, op21_20, 0b01, op17_16, op11_7, op4,
3450                      itinD, OpcodeStr, !strconcat(Dt, "16"),v4i16,v4i16,IntOp>;
3451  def v2i32 : N2VDInt<op24_23, op21_20, 0b10, op17_16, op11_7, op4,
3452                      itinD, OpcodeStr, !strconcat(Dt, "32"),v2i32,v2i32,IntOp>;
3453
3454  // 128-bit vector types.
3455  def v16i8 : N2VQInt<op24_23, op21_20, 0b00, op17_16, op11_7, op4,
3456                      itinQ, OpcodeStr, !strconcat(Dt, "8"), v16i8,v16i8,IntOp>;
3457  def v8i16 : N2VQInt<op24_23, op21_20, 0b01, op17_16, op11_7, op4,
3458                      itinQ, OpcodeStr, !strconcat(Dt, "16"),v8i16,v8i16,IntOp>;
3459  def v4i32 : N2VQInt<op24_23, op21_20, 0b10, op17_16, op11_7, op4,
3460                      itinQ, OpcodeStr, !strconcat(Dt, "32"),v4i32,v4i32,IntOp>;
3461}
3462
3463
3464// Neon Narrowing 2-register vector operations,
3465//   source operand element sizes of 16, 32 and 64 bits:
3466multiclass N2VN_HSD<bits<2> op24_23, bits<2> op21_20, bits<2> op17_16,
3467                    bits<5> op11_7, bit op6, bit op4,
3468                    InstrItinClass itin, string OpcodeStr, string Dt,
3469                    SDNode OpNode> {
3470  def v8i8  : N2VN<op24_23, op21_20, 0b00, op17_16, op11_7, op6, op4,
3471                   itin, OpcodeStr, !strconcat(Dt, "16"),
3472                   v8i8, v8i16, OpNode>;
3473  def v4i16 : N2VN<op24_23, op21_20, 0b01, op17_16, op11_7, op6, op4,
3474                   itin, OpcodeStr, !strconcat(Dt, "32"),
3475                   v4i16, v4i32, OpNode>;
3476  def v2i32 : N2VN<op24_23, op21_20, 0b10, op17_16, op11_7, op6, op4,
3477                   itin, OpcodeStr, !strconcat(Dt, "64"),
3478                   v2i32, v2i64, OpNode>;
3479}
3480
3481// Neon Narrowing 2-register vector intrinsics,
3482//   source operand element sizes of 16, 32 and 64 bits:
3483multiclass N2VNInt_HSD<bits<2> op24_23, bits<2> op21_20, bits<2> op17_16,
3484                       bits<5> op11_7, bit op6, bit op4,
3485                       InstrItinClass itin, string OpcodeStr, string Dt,
3486                       SDPatternOperator IntOp> {
3487  def v8i8  : N2VNInt<op24_23, op21_20, 0b00, op17_16, op11_7, op6, op4,
3488                      itin, OpcodeStr, !strconcat(Dt, "16"),
3489                      v8i8, v8i16, IntOp>;
3490  def v4i16 : N2VNInt<op24_23, op21_20, 0b01, op17_16, op11_7, op6, op4,
3491                      itin, OpcodeStr, !strconcat(Dt, "32"),
3492                      v4i16, v4i32, IntOp>;
3493  def v2i32 : N2VNInt<op24_23, op21_20, 0b10, op17_16, op11_7, op6, op4,
3494                      itin, OpcodeStr, !strconcat(Dt, "64"),
3495                      v2i32, v2i64, IntOp>;
3496}
3497
3498
3499// Neon Lengthening 2-register vector intrinsic (currently specific to VMOVL).
3500//   source operand element sizes of 16, 32 and 64 bits:
3501multiclass N2VL_QHS<bits<2> op24_23, bits<5> op11_7, bit op6, bit op4,
3502                    string OpcodeStr, string Dt, SDNode OpNode> {
3503  def v8i16 : N2VL<op24_23, 0b00, 0b10, 0b00, op11_7, op6, op4, IIC_VQUNAiD,
3504                   OpcodeStr, !strconcat(Dt, "8"), v8i16, v8i8, OpNode>;
3505  def v4i32 : N2VL<op24_23, 0b01, 0b00, 0b00, op11_7, op6, op4, IIC_VQUNAiD,
3506                   OpcodeStr, !strconcat(Dt, "16"), v4i32, v4i16, OpNode>;
3507  def v2i64 : N2VL<op24_23, 0b10, 0b00, 0b00, op11_7, op6, op4, IIC_VQUNAiD,
3508                   OpcodeStr, !strconcat(Dt, "32"), v2i64, v2i32, OpNode>;
3509}
3510
3511
3512// Neon 3-register vector operations.
3513
3514// First with only element sizes of 8, 16 and 32 bits:
3515multiclass N3V_QHS<bit op24, bit op23, bits<4> op11_8, bit op4,
3516                   InstrItinClass itinD16, InstrItinClass itinD32,
3517                   InstrItinClass itinQ16, InstrItinClass itinQ32,
3518                   string OpcodeStr, string Dt,
3519                   SDNode OpNode, bit Commutable = 0> {
3520  // 64-bit vector types.
3521  def v8i8  : N3VD<op24, op23, 0b00, op11_8, op4, itinD16,
3522                   OpcodeStr, !strconcat(Dt, "8"),
3523                   v8i8, v8i8, OpNode, Commutable>;
3524  def v4i16 : N3VD<op24, op23, 0b01, op11_8, op4, itinD16,
3525                   OpcodeStr, !strconcat(Dt, "16"),
3526                   v4i16, v4i16, OpNode, Commutable>;
3527  def v2i32 : N3VD<op24, op23, 0b10, op11_8, op4, itinD32,
3528                   OpcodeStr, !strconcat(Dt, "32"),
3529                   v2i32, v2i32, OpNode, Commutable>;
3530
3531  // 128-bit vector types.
3532  def v16i8 : N3VQ<op24, op23, 0b00, op11_8, op4, itinQ16,
3533                   OpcodeStr, !strconcat(Dt, "8"),
3534                   v16i8, v16i8, OpNode, Commutable>;
3535  def v8i16 : N3VQ<op24, op23, 0b01, op11_8, op4, itinQ16,
3536                   OpcodeStr, !strconcat(Dt, "16"),
3537                   v8i16, v8i16, OpNode, Commutable>;
3538  def v4i32 : N3VQ<op24, op23, 0b10, op11_8, op4, itinQ32,
3539                   OpcodeStr, !strconcat(Dt, "32"),
3540                   v4i32, v4i32, OpNode, Commutable>;
3541}
3542
3543multiclass N3VSL_HS<bits<4> op11_8, string OpcodeStr, SDNode ShOp> {
3544  def v4i16 : N3VDSL16<0b01, op11_8, OpcodeStr, "i16", v4i16, ShOp>;
3545  def v2i32 : N3VDSL<0b10, op11_8, IIC_VMULi32D, OpcodeStr, "i32", v2i32, ShOp>;
3546  def v8i16 : N3VQSL16<0b01, op11_8, OpcodeStr, "i16", v8i16, v4i16, ShOp>;
3547  def v4i32 : N3VQSL<0b10, op11_8, IIC_VMULi32Q, OpcodeStr, "i32",
3548                     v4i32, v2i32, ShOp>;
3549}
3550
3551// ....then also with element size 64 bits:
3552multiclass N3V_QHSD<bit op24, bit op23, bits<4> op11_8, bit op4,
3553                    InstrItinClass itinD, InstrItinClass itinQ,
3554                    string OpcodeStr, string Dt,
3555                    SDNode OpNode, bit Commutable = 0>
3556  : N3V_QHS<op24, op23, op11_8, op4, itinD, itinD, itinQ, itinQ,
3557            OpcodeStr, Dt, OpNode, Commutable> {
3558  def v1i64 : N3VD<op24, op23, 0b11, op11_8, op4, itinD,
3559                   OpcodeStr, !strconcat(Dt, "64"),
3560                   v1i64, v1i64, OpNode, Commutable>;
3561  def v2i64 : N3VQ<op24, op23, 0b11, op11_8, op4, itinQ,
3562                   OpcodeStr, !strconcat(Dt, "64"),
3563                   v2i64, v2i64, OpNode, Commutable>;
3564}
3565
3566
3567// Neon 3-register vector intrinsics.
3568
3569// First with only element sizes of 16 and 32 bits:
3570multiclass N3VInt_HS<bit op24, bit op23, bits<4> op11_8, bit op4, Format f,
3571                     InstrItinClass itinD16, InstrItinClass itinD32,
3572                     InstrItinClass itinQ16, InstrItinClass itinQ32,
3573                     string OpcodeStr, string Dt,
3574                     SDPatternOperator IntOp, bit Commutable = 0> {
3575  // 64-bit vector types.
3576  def v4i16 : N3VDInt<op24, op23, 0b01, op11_8, op4, f, itinD16,
3577                      OpcodeStr, !strconcat(Dt, "16"),
3578                      v4i16, v4i16, IntOp, Commutable>;
3579  def v2i32 : N3VDInt<op24, op23, 0b10, op11_8, op4, f, itinD32,
3580                      OpcodeStr, !strconcat(Dt, "32"),
3581                      v2i32, v2i32, IntOp, Commutable>;
3582
3583  // 128-bit vector types.
3584  def v8i16 : N3VQInt<op24, op23, 0b01, op11_8, op4, f, itinQ16,
3585                      OpcodeStr, !strconcat(Dt, "16"),
3586                      v8i16, v8i16, IntOp, Commutable>;
3587  def v4i32 : N3VQInt<op24, op23, 0b10, op11_8, op4, f, itinQ32,
3588                      OpcodeStr, !strconcat(Dt, "32"),
3589                      v4i32, v4i32, IntOp, Commutable>;
3590}
3591multiclass N3VInt_HSSh<bit op24, bit op23, bits<4> op11_8, bit op4, Format f,
3592                     InstrItinClass itinD16, InstrItinClass itinD32,
3593                     InstrItinClass itinQ16, InstrItinClass itinQ32,
3594                     string OpcodeStr, string Dt,
3595                     SDPatternOperator IntOp> {
3596  // 64-bit vector types.
3597  def v4i16 : N3VDIntSh<op24, op23, 0b01, op11_8, op4, f, itinD16,
3598                      OpcodeStr, !strconcat(Dt, "16"),
3599                      v4i16, v4i16, IntOp>;
3600  def v2i32 : N3VDIntSh<op24, op23, 0b10, op11_8, op4, f, itinD32,
3601                      OpcodeStr, !strconcat(Dt, "32"),
3602                      v2i32, v2i32, IntOp>;
3603
3604  // 128-bit vector types.
3605  def v8i16 : N3VQIntSh<op24, op23, 0b01, op11_8, op4, f, itinQ16,
3606                      OpcodeStr, !strconcat(Dt, "16"),
3607                      v8i16, v8i16, IntOp>;
3608  def v4i32 : N3VQIntSh<op24, op23, 0b10, op11_8, op4, f, itinQ32,
3609                      OpcodeStr, !strconcat(Dt, "32"),
3610                      v4i32, v4i32, IntOp>;
3611}
3612
3613multiclass N3VIntSL_HS<bits<4> op11_8,
3614                       InstrItinClass itinD16, InstrItinClass itinD32,
3615                       InstrItinClass itinQ16, InstrItinClass itinQ32,
3616                       string OpcodeStr, string Dt, SDPatternOperator IntOp> {
3617  def v4i16 : N3VDIntSL16<0b01, op11_8, itinD16,
3618                          OpcodeStr, !strconcat(Dt, "16"), v4i16, IntOp>;
3619  def v2i32 : N3VDIntSL<0b10, op11_8, itinD32,
3620                        OpcodeStr, !strconcat(Dt, "32"), v2i32, IntOp>;
3621  def v8i16 : N3VQIntSL16<0b01, op11_8, itinQ16,
3622                          OpcodeStr, !strconcat(Dt, "16"), v8i16, v4i16, IntOp>;
3623  def v4i32 : N3VQIntSL<0b10, op11_8, itinQ32,
3624                        OpcodeStr, !strconcat(Dt, "32"), v4i32, v2i32, IntOp>;
3625}
3626
3627// ....then also with element size of 8 bits:
3628multiclass N3VInt_QHS<bit op24, bit op23, bits<4> op11_8, bit op4, Format f,
3629                      InstrItinClass itinD16, InstrItinClass itinD32,
3630                      InstrItinClass itinQ16, InstrItinClass itinQ32,
3631                      string OpcodeStr, string Dt,
3632                      SDPatternOperator IntOp, bit Commutable = 0>
3633  : N3VInt_HS<op24, op23, op11_8, op4, f, itinD16, itinD32, itinQ16, itinQ32,
3634              OpcodeStr, Dt, IntOp, Commutable> {
3635  def v8i8  : N3VDInt<op24, op23, 0b00, op11_8, op4, f, itinD16,
3636                      OpcodeStr, !strconcat(Dt, "8"),
3637                      v8i8, v8i8, IntOp, Commutable>;
3638  def v16i8 : N3VQInt<op24, op23, 0b00, op11_8, op4, f, itinQ16,
3639                      OpcodeStr, !strconcat(Dt, "8"),
3640                      v16i8, v16i8, IntOp, Commutable>;
3641}
3642multiclass N3VInt_QHSSh<bit op24, bit op23, bits<4> op11_8, bit op4, Format f,
3643                      InstrItinClass itinD16, InstrItinClass itinD32,
3644                      InstrItinClass itinQ16, InstrItinClass itinQ32,
3645                      string OpcodeStr, string Dt,
3646                      SDPatternOperator IntOp>
3647  : N3VInt_HSSh<op24, op23, op11_8, op4, f, itinD16, itinD32, itinQ16, itinQ32,
3648              OpcodeStr, Dt, IntOp> {
3649  def v8i8  : N3VDIntSh<op24, op23, 0b00, op11_8, op4, f, itinD16,
3650                      OpcodeStr, !strconcat(Dt, "8"),
3651                      v8i8, v8i8, IntOp>;
3652  def v16i8 : N3VQIntSh<op24, op23, 0b00, op11_8, op4, f, itinQ16,
3653                      OpcodeStr, !strconcat(Dt, "8"),
3654                      v16i8, v16i8, IntOp>;
3655}
3656
3657
3658// ....then also with element size of 64 bits:
3659multiclass N3VInt_QHSD<bit op24, bit op23, bits<4> op11_8, bit op4, Format f,
3660                       InstrItinClass itinD16, InstrItinClass itinD32,
3661                       InstrItinClass itinQ16, InstrItinClass itinQ32,
3662                       string OpcodeStr, string Dt,
3663                       SDPatternOperator IntOp, bit Commutable = 0>
3664  : N3VInt_QHS<op24, op23, op11_8, op4, f, itinD16, itinD32, itinQ16, itinQ32,
3665               OpcodeStr, Dt, IntOp, Commutable> {
3666  def v1i64 : N3VDInt<op24, op23, 0b11, op11_8, op4, f, itinD32,
3667                      OpcodeStr, !strconcat(Dt, "64"),
3668                      v1i64, v1i64, IntOp, Commutable>;
3669  def v2i64 : N3VQInt<op24, op23, 0b11, op11_8, op4, f, itinQ32,
3670                      OpcodeStr, !strconcat(Dt, "64"),
3671                      v2i64, v2i64, IntOp, Commutable>;
3672}
3673multiclass N3VInt_QHSDSh<bit op24, bit op23, bits<4> op11_8, bit op4, Format f,
3674                       InstrItinClass itinD16, InstrItinClass itinD32,
3675                       InstrItinClass itinQ16, InstrItinClass itinQ32,
3676                       string OpcodeStr, string Dt,
3677                       SDPatternOperator IntOp>
3678  : N3VInt_QHSSh<op24, op23, op11_8, op4, f, itinD16, itinD32, itinQ16, itinQ32,
3679               OpcodeStr, Dt, IntOp> {
3680  def v1i64 : N3VDIntSh<op24, op23, 0b11, op11_8, op4, f, itinD32,
3681                      OpcodeStr, !strconcat(Dt, "64"),
3682                      v1i64, v1i64, IntOp>;
3683  def v2i64 : N3VQIntSh<op24, op23, 0b11, op11_8, op4, f, itinQ32,
3684                      OpcodeStr, !strconcat(Dt, "64"),
3685                      v2i64, v2i64, IntOp>;
3686}
3687
3688// Neon Narrowing 3-register vector intrinsics,
3689//   source operand element sizes of 16, 32 and 64 bits:
3690multiclass N3VNInt_HSD<bit op24, bit op23, bits<4> op11_8, bit op4,
3691                       string OpcodeStr, string Dt,
3692                       SDPatternOperator IntOp, bit Commutable = 0> {
3693  def v8i8  : N3VNInt<op24, op23, 0b00, op11_8, op4,
3694                      OpcodeStr, !strconcat(Dt, "16"),
3695                      v8i8, v8i16, IntOp, Commutable>;
3696  def v4i16 : N3VNInt<op24, op23, 0b01, op11_8, op4,
3697                      OpcodeStr, !strconcat(Dt, "32"),
3698                      v4i16, v4i32, IntOp, Commutable>;
3699  def v2i32 : N3VNInt<op24, op23, 0b10, op11_8, op4,
3700                      OpcodeStr, !strconcat(Dt, "64"),
3701                      v2i32, v2i64, IntOp, Commutable>;
3702}
3703
3704
3705// Neon Long 3-register vector operations.
3706
3707multiclass N3VL_QHS<bit op24, bit op23, bits<4> op11_8, bit op4,
3708                    InstrItinClass itin16, InstrItinClass itin32,
3709                    string OpcodeStr, string Dt,
3710                    SDNode OpNode, bit Commutable = 0> {
3711  def v8i16 : N3VL<op24, op23, 0b00, op11_8, op4, itin16,
3712                   OpcodeStr, !strconcat(Dt, "8"),
3713                   v8i16, v8i8, OpNode, Commutable>;
3714  def v4i32 : N3VL<op24, op23, 0b01, op11_8, op4, itin16,
3715                   OpcodeStr, !strconcat(Dt, "16"),
3716                   v4i32, v4i16, OpNode, Commutable>;
3717  def v2i64 : N3VL<op24, op23, 0b10, op11_8, op4, itin32,
3718                   OpcodeStr, !strconcat(Dt, "32"),
3719                   v2i64, v2i32, OpNode, Commutable>;
3720}
3721
3722multiclass N3VLSL_HS<bit op24, bits<4> op11_8,
3723                     InstrItinClass itin, string OpcodeStr, string Dt,
3724                     SDNode OpNode> {
3725  def v4i16 : N3VLSL16<op24, 0b01, op11_8, itin, OpcodeStr,
3726                       !strconcat(Dt, "16"), v4i32, v4i16, OpNode>;
3727  def v2i32 : N3VLSL<op24, 0b10, op11_8, itin, OpcodeStr,
3728                     !strconcat(Dt, "32"), v2i64, v2i32, OpNode>;
3729}
3730
3731multiclass N3VLExt_QHS<bit op24, bit op23, bits<4> op11_8, bit op4,
3732                       InstrItinClass itin16, InstrItinClass itin32,
3733                       string OpcodeStr, string Dt,
3734                       SDNode OpNode, SDPatternOperator ExtOp, bit Commutable = 0> {
3735  def v8i16 : N3VLExt<op24, op23, 0b00, op11_8, op4, itin16,
3736                      OpcodeStr, !strconcat(Dt, "8"),
3737                      v8i16, v8i8, OpNode, ExtOp, Commutable>;
3738  def v4i32 : N3VLExt<op24, op23, 0b01, op11_8, op4, itin16,
3739                      OpcodeStr, !strconcat(Dt, "16"),
3740                      v4i32, v4i16, OpNode, ExtOp, Commutable>;
3741  def v2i64 : N3VLExt<op24, op23, 0b10, op11_8, op4, itin32,
3742                      OpcodeStr, !strconcat(Dt, "32"),
3743                      v2i64, v2i32, OpNode, ExtOp, Commutable>;
3744}
3745
3746// Neon Long 3-register vector intrinsics.
3747
3748// First with only element sizes of 16 and 32 bits:
3749multiclass N3VLInt_HS<bit op24, bit op23, bits<4> op11_8, bit op4,
3750                      InstrItinClass itin16, InstrItinClass itin32,
3751                      string OpcodeStr, string Dt,
3752                      SDPatternOperator IntOp, bit Commutable = 0> {
3753  def v4i32 : N3VLInt<op24, op23, 0b01, op11_8, op4, itin16,
3754                      OpcodeStr, !strconcat(Dt, "16"),
3755                      v4i32, v4i16, IntOp, Commutable>;
3756  def v2i64 : N3VLInt<op24, op23, 0b10, op11_8, op4, itin32,
3757                      OpcodeStr, !strconcat(Dt, "32"),
3758                      v2i64, v2i32, IntOp, Commutable>;
3759}
3760
3761multiclass N3VLIntSL_HS<bit op24, bits<4> op11_8,
3762                        InstrItinClass itin, string OpcodeStr, string Dt,
3763                        SDPatternOperator IntOp> {
3764  def v4i16 : N3VLIntSL16<op24, 0b01, op11_8, itin,
3765                          OpcodeStr, !strconcat(Dt, "16"), v4i32, v4i16, IntOp>;
3766  def v2i32 : N3VLIntSL<op24, 0b10, op11_8, itin,
3767                        OpcodeStr, !strconcat(Dt, "32"), v2i64, v2i32, IntOp>;
3768}
3769
3770// ....then also with element size of 8 bits:
3771multiclass N3VLInt_QHS<bit op24, bit op23, bits<4> op11_8, bit op4,
3772                       InstrItinClass itin16, InstrItinClass itin32,
3773                       string OpcodeStr, string Dt,
3774                       SDPatternOperator IntOp, bit Commutable = 0>
3775  : N3VLInt_HS<op24, op23, op11_8, op4, itin16, itin32, OpcodeStr, Dt,
3776               IntOp, Commutable> {
3777  def v8i16 : N3VLInt<op24, op23, 0b00, op11_8, op4, itin16,
3778                      OpcodeStr, !strconcat(Dt, "8"),
3779                      v8i16, v8i8, IntOp, Commutable>;
3780}
3781
3782// ....with explicit extend (VABDL).
3783multiclass N3VLIntExt_QHS<bit op24, bit op23, bits<4> op11_8, bit op4,
3784                       InstrItinClass itin, string OpcodeStr, string Dt,
3785                       SDPatternOperator IntOp, SDNode ExtOp, bit Commutable = 0> {
3786  def v8i16 : N3VLIntExt<op24, op23, 0b00, op11_8, op4, itin,
3787                         OpcodeStr, !strconcat(Dt, "8"),
3788                         v8i16, v8i8, IntOp, ExtOp, Commutable>;
3789  def v4i32 : N3VLIntExt<op24, op23, 0b01, op11_8, op4, itin,
3790                         OpcodeStr, !strconcat(Dt, "16"),
3791                         v4i32, v4i16, IntOp, ExtOp, Commutable>;
3792  def v2i64 : N3VLIntExt<op24, op23, 0b10, op11_8, op4, itin,
3793                         OpcodeStr, !strconcat(Dt, "32"),
3794                         v2i64, v2i32, IntOp, ExtOp, Commutable>;
3795}
3796
3797
3798// Neon Wide 3-register vector intrinsics,
3799//   source operand element sizes of 8, 16 and 32 bits:
3800multiclass N3VW_QHS<bit op24, bit op23, bits<4> op11_8, bit op4,
3801                    string OpcodeStr, string Dt,
3802                    SDNode OpNode, SDPatternOperator ExtOp, bit Commutable = 0> {
3803  def v8i16 : N3VW<op24, op23, 0b00, op11_8, op4,
3804                   OpcodeStr, !strconcat(Dt, "8"),
3805                   v8i16, v8i8, OpNode, ExtOp, Commutable>;
3806  def v4i32 : N3VW<op24, op23, 0b01, op11_8, op4,
3807                   OpcodeStr, !strconcat(Dt, "16"),
3808                   v4i32, v4i16, OpNode, ExtOp, Commutable>;
3809  def v2i64 : N3VW<op24, op23, 0b10, op11_8, op4,
3810                   OpcodeStr, !strconcat(Dt, "32"),
3811                   v2i64, v2i32, OpNode, ExtOp, Commutable>;
3812}
3813
3814
3815// Neon Multiply-Op vector operations,
3816//   element sizes of 8, 16 and 32 bits:
3817multiclass N3VMulOp_QHS<bit op24, bit op23, bits<4> op11_8, bit op4,
3818                        InstrItinClass itinD16, InstrItinClass itinD32,
3819                        InstrItinClass itinQ16, InstrItinClass itinQ32,
3820                        string OpcodeStr, string Dt, SDNode OpNode> {
3821  // 64-bit vector types.
3822  def v8i8  : N3VDMulOp<op24, op23, 0b00, op11_8, op4, itinD16,
3823                        OpcodeStr, !strconcat(Dt, "8"), v8i8, mul, OpNode>;
3824  def v4i16 : N3VDMulOp<op24, op23, 0b01, op11_8, op4, itinD16,
3825                        OpcodeStr, !strconcat(Dt, "16"), v4i16, mul, OpNode>;
3826  def v2i32 : N3VDMulOp<op24, op23, 0b10, op11_8, op4, itinD32,
3827                        OpcodeStr, !strconcat(Dt, "32"), v2i32, mul, OpNode>;
3828
3829  // 128-bit vector types.
3830  def v16i8 : N3VQMulOp<op24, op23, 0b00, op11_8, op4, itinQ16,
3831                        OpcodeStr, !strconcat(Dt, "8"), v16i8, mul, OpNode>;
3832  def v8i16 : N3VQMulOp<op24, op23, 0b01, op11_8, op4, itinQ16,
3833                        OpcodeStr, !strconcat(Dt, "16"), v8i16, mul, OpNode>;
3834  def v4i32 : N3VQMulOp<op24, op23, 0b10, op11_8, op4, itinQ32,
3835                        OpcodeStr, !strconcat(Dt, "32"), v4i32, mul, OpNode>;
3836}
3837
3838multiclass N3VMulOpSL_HS<bits<4> op11_8,
3839                         InstrItinClass itinD16, InstrItinClass itinD32,
3840                         InstrItinClass itinQ16, InstrItinClass itinQ32,
3841                         string OpcodeStr, string Dt, SDPatternOperator ShOp> {
3842  def v4i16 : N3VDMulOpSL16<0b01, op11_8, itinD16,
3843                            OpcodeStr, !strconcat(Dt, "16"), v4i16, mul, ShOp>;
3844  def v2i32 : N3VDMulOpSL<0b10, op11_8, itinD32,
3845                          OpcodeStr, !strconcat(Dt, "32"), v2i32, mul, ShOp>;
3846  def v8i16 : N3VQMulOpSL16<0b01, op11_8, itinQ16,
3847                            OpcodeStr, !strconcat(Dt, "16"), v8i16, v4i16,
3848                            mul, ShOp>;
3849  def v4i32 : N3VQMulOpSL<0b10, op11_8, itinQ32,
3850                          OpcodeStr, !strconcat(Dt, "32"), v4i32, v2i32,
3851                          mul, ShOp>;
3852}
3853
3854// Neon Intrinsic-Op vector operations,
3855//   element sizes of 8, 16 and 32 bits:
3856multiclass N3VIntOp_QHS<bit op24, bit op23, bits<4> op11_8, bit op4,
3857                        InstrItinClass itinD, InstrItinClass itinQ,
3858                        string OpcodeStr, string Dt, SDPatternOperator IntOp,
3859                        SDNode OpNode> {
3860  // 64-bit vector types.
3861  def v8i8  : N3VDIntOp<op24, op23, 0b00, op11_8, op4, itinD,
3862                        OpcodeStr, !strconcat(Dt, "8"), v8i8, IntOp, OpNode>;
3863  def v4i16 : N3VDIntOp<op24, op23, 0b01, op11_8, op4, itinD,
3864                        OpcodeStr, !strconcat(Dt, "16"), v4i16, IntOp, OpNode>;
3865  def v2i32 : N3VDIntOp<op24, op23, 0b10, op11_8, op4, itinD,
3866                        OpcodeStr, !strconcat(Dt, "32"), v2i32, IntOp, OpNode>;
3867
3868  // 128-bit vector types.
3869  def v16i8 : N3VQIntOp<op24, op23, 0b00, op11_8, op4, itinQ,
3870                        OpcodeStr, !strconcat(Dt, "8"), v16i8, IntOp, OpNode>;
3871  def v8i16 : N3VQIntOp<op24, op23, 0b01, op11_8, op4, itinQ,
3872                        OpcodeStr, !strconcat(Dt, "16"), v8i16, IntOp, OpNode>;
3873  def v4i32 : N3VQIntOp<op24, op23, 0b10, op11_8, op4, itinQ,
3874                        OpcodeStr, !strconcat(Dt, "32"), v4i32, IntOp, OpNode>;
3875}
3876
3877// Neon 3-argument intrinsics,
3878//   element sizes of 16 and 32 bits:
3879multiclass N3VInt3_HS<bit op24, bit op23, bits<4> op11_8, bit op4,
3880                       InstrItinClass itinD16, InstrItinClass itinD32,
3881                       InstrItinClass itinQ16, InstrItinClass itinQ32,
3882                       string OpcodeStr, string Dt, SDPatternOperator IntOp> {
3883  // 64-bit vector types.
3884  def v4i16 : N3VDInt3<op24, op23, 0b01, op11_8, op4, itinD16,
3885                       OpcodeStr, !strconcat(Dt, "16"), v4i16, v4i16, IntOp>;
3886  def v2i32 : N3VDInt3<op24, op23, 0b10, op11_8, op4, itinD32,
3887                       OpcodeStr, !strconcat(Dt, "32"), v2i32, v2i32, IntOp>;
3888
3889  // 128-bit vector types.
3890  def v8i16 : N3VQInt3<op24, op23, 0b01, op11_8, op4, itinQ16,
3891                       OpcodeStr, !strconcat(Dt, "16"), v8i16, v8i16, IntOp>;
3892  def v4i32 : N3VQInt3<op24, op23, 0b10, op11_8, op4, itinQ32,
3893                       OpcodeStr, !strconcat(Dt, "32"), v4i32, v4i32, IntOp>;
3894}
3895
3896//   element sizes of 8, 16 and 32 bits:
3897multiclass N3VInt3_QHS<bit op24, bit op23, bits<4> op11_8, bit op4,
3898                       InstrItinClass itinD16, InstrItinClass itinD32,
3899                       InstrItinClass itinQ16, InstrItinClass itinQ32,
3900                       string OpcodeStr, string Dt, SDPatternOperator IntOp>
3901           :N3VInt3_HS <op24, op23, op11_8, op4, itinD16, itinD32,
3902                        itinQ16, itinQ32, OpcodeStr, Dt, IntOp>{
3903  // 64-bit vector types.
3904  def v8i8  : N3VDInt3<op24, op23, 0b00, op11_8, op4, itinD16,
3905                       OpcodeStr, !strconcat(Dt, "8"), v8i8, v8i8, IntOp>;
3906  // 128-bit vector types.
3907  def v16i8 : N3VQInt3<op24, op23, 0b00, op11_8, op4, itinQ16,
3908                       OpcodeStr, !strconcat(Dt, "8"), v16i8, v16i8, IntOp>;
3909}
3910
3911// Neon Long Multiply-Op vector operations,
3912//   element sizes of 8, 16 and 32 bits:
3913multiclass N3VLMulOp_QHS<bit op24, bit op23, bits<4> op11_8, bit op4,
3914                         InstrItinClass itin16, InstrItinClass itin32,
3915                         string OpcodeStr, string Dt, SDNode MulOp,
3916                         SDNode OpNode> {
3917  def v8i16 : N3VLMulOp<op24, op23, 0b00, op11_8, op4, itin16, OpcodeStr,
3918                        !strconcat(Dt, "8"), v8i16, v8i8, MulOp, OpNode>;
3919  def v4i32 : N3VLMulOp<op24, op23, 0b01, op11_8, op4, itin16, OpcodeStr,
3920                        !strconcat(Dt, "16"), v4i32, v4i16, MulOp, OpNode>;
3921  def v2i64 : N3VLMulOp<op24, op23, 0b10, op11_8, op4, itin32, OpcodeStr,
3922                        !strconcat(Dt, "32"), v2i64, v2i32, MulOp, OpNode>;
3923}
3924
3925multiclass N3VLMulOpSL_HS<bit op24, bits<4> op11_8, string OpcodeStr,
3926                          string Dt, SDNode MulOp, SDNode OpNode> {
3927  def v4i16 : N3VLMulOpSL16<op24, 0b01, op11_8, IIC_VMACi16D, OpcodeStr,
3928                            !strconcat(Dt,"16"), v4i32, v4i16, MulOp, OpNode>;
3929  def v2i32 : N3VLMulOpSL<op24, 0b10, op11_8, IIC_VMACi32D, OpcodeStr,
3930                          !strconcat(Dt, "32"), v2i64, v2i32, MulOp, OpNode>;
3931}
3932
3933
3934// Neon Long 3-argument intrinsics.
3935
3936// First with only element sizes of 16 and 32 bits:
3937multiclass N3VLInt3_HS<bit op24, bit op23, bits<4> op11_8, bit op4,
3938                       InstrItinClass itin16, InstrItinClass itin32,
3939                       string OpcodeStr, string Dt, SDPatternOperator IntOp> {
3940  def v4i32 : N3VLInt3<op24, op23, 0b01, op11_8, op4, itin16,
3941                       OpcodeStr, !strconcat(Dt, "16"), v4i32, v4i16, IntOp>;
3942  def v2i64 : N3VLInt3<op24, op23, 0b10, op11_8, op4, itin32,
3943                       OpcodeStr, !strconcat(Dt, "32"), v2i64, v2i32, IntOp>;
3944}
3945
3946multiclass N3VLInt3SL_HS<bit op24, bits<4> op11_8,
3947                         string OpcodeStr, string Dt, SDPatternOperator IntOp> {
3948  def v4i16 : N3VLInt3SL16<op24, 0b01, op11_8, IIC_VMACi16D,
3949                           OpcodeStr, !strconcat(Dt,"16"), v4i32, v4i16, IntOp>;
3950  def v2i32 : N3VLInt3SL<op24, 0b10, op11_8, IIC_VMACi32D,
3951                         OpcodeStr, !strconcat(Dt, "32"), v2i64, v2i32, IntOp>;
3952}
3953
3954// ....then also with element size of 8 bits:
3955multiclass N3VLInt3_QHS<bit op24, bit op23, bits<4> op11_8, bit op4,
3956                        InstrItinClass itin16, InstrItinClass itin32,
3957                        string OpcodeStr, string Dt, SDPatternOperator IntOp>
3958  : N3VLInt3_HS<op24, op23, op11_8, op4, itin16, itin32, OpcodeStr, Dt, IntOp> {
3959  def v8i16 : N3VLInt3<op24, op23, 0b00, op11_8, op4, itin16,
3960                       OpcodeStr, !strconcat(Dt, "8"), v8i16, v8i8, IntOp>;
3961}
3962
3963// ....with explicit extend (VABAL).
3964multiclass N3VLIntExtOp_QHS<bit op24, bit op23, bits<4> op11_8, bit op4,
3965                            InstrItinClass itin, string OpcodeStr, string Dt,
3966                            SDPatternOperator IntOp, SDNode ExtOp, SDNode OpNode> {
3967  def v8i16 : N3VLIntExtOp<op24, op23, 0b00, op11_8, op4, itin,
3968                           OpcodeStr, !strconcat(Dt, "8"), v8i16, v8i8,
3969                           IntOp, ExtOp, OpNode>;
3970  def v4i32 : N3VLIntExtOp<op24, op23, 0b01, op11_8, op4, itin,
3971                           OpcodeStr, !strconcat(Dt, "16"), v4i32, v4i16,
3972                           IntOp, ExtOp, OpNode>;
3973  def v2i64 : N3VLIntExtOp<op24, op23, 0b10, op11_8, op4, itin,
3974                           OpcodeStr, !strconcat(Dt, "32"), v2i64, v2i32,
3975                           IntOp, ExtOp, OpNode>;
3976}
3977
3978
3979// Neon Pairwise long 2-register intrinsics,
3980//   element sizes of 8, 16 and 32 bits:
3981multiclass N2VPLInt_QHS<bits<2> op24_23, bits<2> op21_20, bits<2> op17_16,
3982                        bits<5> op11_7, bit op4,
3983                        string OpcodeStr, string Dt, SDPatternOperator IntOp> {
3984  // 64-bit vector types.
3985  def v8i8  : N2VDPLInt<op24_23, op21_20, 0b00, op17_16, op11_7, op4,
3986                        OpcodeStr, !strconcat(Dt, "8"), v4i16, v8i8, IntOp>;
3987  def v4i16 : N2VDPLInt<op24_23, op21_20, 0b01, op17_16, op11_7, op4,
3988                        OpcodeStr, !strconcat(Dt, "16"), v2i32, v4i16, IntOp>;
3989  def v2i32 : N2VDPLInt<op24_23, op21_20, 0b10, op17_16, op11_7, op4,
3990                        OpcodeStr, !strconcat(Dt, "32"), v1i64, v2i32, IntOp>;
3991
3992  // 128-bit vector types.
3993  def v16i8 : N2VQPLInt<op24_23, op21_20, 0b00, op17_16, op11_7, op4,
3994                        OpcodeStr, !strconcat(Dt, "8"), v8i16, v16i8, IntOp>;
3995  def v8i16 : N2VQPLInt<op24_23, op21_20, 0b01, op17_16, op11_7, op4,
3996                        OpcodeStr, !strconcat(Dt, "16"), v4i32, v8i16, IntOp>;
3997  def v4i32 : N2VQPLInt<op24_23, op21_20, 0b10, op17_16, op11_7, op4,
3998                        OpcodeStr, !strconcat(Dt, "32"), v2i64, v4i32, IntOp>;
3999}
4000
4001
4002// Neon Pairwise long 2-register accumulate intrinsics,
4003//   element sizes of 8, 16 and 32 bits:
4004multiclass N2VPLInt2_QHS<bits<2> op24_23, bits<2> op21_20, bits<2> op17_16,
4005                         bits<5> op11_7, bit op4,
4006                         string OpcodeStr, string Dt, SDPatternOperator IntOp> {
4007  // 64-bit vector types.
4008  def v8i8  : N2VDPLInt2<op24_23, op21_20, 0b00, op17_16, op11_7, op4,
4009                         OpcodeStr, !strconcat(Dt, "8"), v4i16, v8i8, IntOp>;
4010  def v4i16 : N2VDPLInt2<op24_23, op21_20, 0b01, op17_16, op11_7, op4,
4011                         OpcodeStr, !strconcat(Dt, "16"), v2i32, v4i16, IntOp>;
4012  def v2i32 : N2VDPLInt2<op24_23, op21_20, 0b10, op17_16, op11_7, op4,
4013                         OpcodeStr, !strconcat(Dt, "32"), v1i64, v2i32, IntOp>;
4014
4015  // 128-bit vector types.
4016  def v16i8 : N2VQPLInt2<op24_23, op21_20, 0b00, op17_16, op11_7, op4,
4017                         OpcodeStr, !strconcat(Dt, "8"), v8i16, v16i8, IntOp>;
4018  def v8i16 : N2VQPLInt2<op24_23, op21_20, 0b01, op17_16, op11_7, op4,
4019                         OpcodeStr, !strconcat(Dt, "16"), v4i32, v8i16, IntOp>;
4020  def v4i32 : N2VQPLInt2<op24_23, op21_20, 0b10, op17_16, op11_7, op4,
4021                         OpcodeStr, !strconcat(Dt, "32"), v2i64, v4i32, IntOp>;
4022}
4023
4024
4025// Neon 2-register vector shift by immediate,
4026//   with f of either N2RegVShLFrm or N2RegVShRFrm
4027//   element sizes of 8, 16, 32 and 64 bits:
4028multiclass N2VShL_QHSD<bit op24, bit op23, bits<4> op11_8, bit op4,
4029                       InstrItinClass itin, string OpcodeStr, string Dt,
4030                       SDNode OpNode> {
4031  // 64-bit vector types.
4032  def v8i8  : N2VDSh<op24, op23, op11_8, 0, op4, N2RegVShLFrm, itin, i32imm,
4033                     OpcodeStr, !strconcat(Dt, "8"), v8i8, OpNode> {
4034    let Inst{21-19} = 0b001; // imm6 = 001xxx
4035  }
4036  def v4i16 : N2VDSh<op24, op23, op11_8, 0, op4, N2RegVShLFrm, itin, i32imm,
4037                     OpcodeStr, !strconcat(Dt, "16"), v4i16, OpNode> {
4038    let Inst{21-20} = 0b01;  // imm6 = 01xxxx
4039  }
4040  def v2i32 : N2VDSh<op24, op23, op11_8, 0, op4, N2RegVShLFrm, itin, i32imm,
4041                     OpcodeStr, !strconcat(Dt, "32"), v2i32, OpNode> {
4042    let Inst{21} = 0b1;      // imm6 = 1xxxxx
4043  }
4044  def v1i64 : N2VDSh<op24, op23, op11_8, 1, op4, N2RegVShLFrm, itin, i32imm,
4045                     OpcodeStr, !strconcat(Dt, "64"), v1i64, OpNode>;
4046                             // imm6 = xxxxxx
4047
4048  // 128-bit vector types.
4049  def v16i8 : N2VQSh<op24, op23, op11_8, 0, op4, N2RegVShLFrm, itin, i32imm,
4050                     OpcodeStr, !strconcat(Dt, "8"), v16i8, OpNode> {
4051    let Inst{21-19} = 0b001; // imm6 = 001xxx
4052  }
4053  def v8i16 : N2VQSh<op24, op23, op11_8, 0, op4, N2RegVShLFrm, itin, i32imm,
4054                     OpcodeStr, !strconcat(Dt, "16"), v8i16, OpNode> {
4055    let Inst{21-20} = 0b01;  // imm6 = 01xxxx
4056  }
4057  def v4i32 : N2VQSh<op24, op23, op11_8, 0, op4, N2RegVShLFrm, itin, i32imm,
4058                     OpcodeStr, !strconcat(Dt, "32"), v4i32, OpNode> {
4059    let Inst{21} = 0b1;      // imm6 = 1xxxxx
4060  }
4061  def v2i64 : N2VQSh<op24, op23, op11_8, 1, op4, N2RegVShLFrm, itin, i32imm,
4062                     OpcodeStr, !strconcat(Dt, "64"), v2i64, OpNode>;
4063                             // imm6 = xxxxxx
4064}
4065multiclass N2VShR_QHSD<bit op24, bit op23, bits<4> op11_8, bit op4,
4066                       InstrItinClass itin, string OpcodeStr, string Dt,
4067                       SDNode OpNode> {
4068  // 64-bit vector types.
4069  def v8i8  : N2VDSh<op24, op23, op11_8, 0, op4, N2RegVShRFrm, itin, shr_imm8,
4070                     OpcodeStr, !strconcat(Dt, "8"), v8i8, OpNode> {
4071    let Inst{21-19} = 0b001; // imm6 = 001xxx
4072  }
4073  def v4i16 : N2VDSh<op24, op23, op11_8, 0, op4, N2RegVShRFrm, itin, shr_imm16,
4074                     OpcodeStr, !strconcat(Dt, "16"), v4i16, OpNode> {
4075    let Inst{21-20} = 0b01;  // imm6 = 01xxxx
4076  }
4077  def v2i32 : N2VDSh<op24, op23, op11_8, 0, op4, N2RegVShRFrm, itin, shr_imm32,
4078                     OpcodeStr, !strconcat(Dt, "32"), v2i32, OpNode> {
4079    let Inst{21} = 0b1;      // imm6 = 1xxxxx
4080  }
4081  def v1i64 : N2VDSh<op24, op23, op11_8, 1, op4, N2RegVShRFrm, itin, shr_imm64,
4082                     OpcodeStr, !strconcat(Dt, "64"), v1i64, OpNode>;
4083                             // imm6 = xxxxxx
4084
4085  // 128-bit vector types.
4086  def v16i8 : N2VQSh<op24, op23, op11_8, 0, op4, N2RegVShRFrm, itin, shr_imm8,
4087                     OpcodeStr, !strconcat(Dt, "8"), v16i8, OpNode> {
4088    let Inst{21-19} = 0b001; // imm6 = 001xxx
4089  }
4090  def v8i16 : N2VQSh<op24, op23, op11_8, 0, op4, N2RegVShRFrm, itin, shr_imm16,
4091                     OpcodeStr, !strconcat(Dt, "16"), v8i16, OpNode> {
4092    let Inst{21-20} = 0b01;  // imm6 = 01xxxx
4093  }
4094  def v4i32 : N2VQSh<op24, op23, op11_8, 0, op4, N2RegVShRFrm, itin, shr_imm32,
4095                     OpcodeStr, !strconcat(Dt, "32"), v4i32, OpNode> {
4096    let Inst{21} = 0b1;      // imm6 = 1xxxxx
4097  }
4098  def v2i64 : N2VQSh<op24, op23, op11_8, 1, op4, N2RegVShRFrm, itin, shr_imm64,
4099                     OpcodeStr, !strconcat(Dt, "64"), v2i64, OpNode>;
4100                             // imm6 = xxxxxx
4101}
4102
4103// Neon Shift-Accumulate vector operations,
4104//   element sizes of 8, 16, 32 and 64 bits:
4105multiclass N2VShAdd_QHSD<bit op24, bit op23, bits<4> op11_8, bit op4,
4106                         string OpcodeStr, string Dt, SDNode ShOp> {
4107  // 64-bit vector types.
4108  def v8i8  : N2VDShAdd<op24, op23, op11_8, 0, op4, shr_imm8,
4109                        OpcodeStr, !strconcat(Dt, "8"), v8i8, ShOp> {
4110    let Inst{21-19} = 0b001; // imm6 = 001xxx
4111  }
4112  def v4i16 : N2VDShAdd<op24, op23, op11_8, 0, op4, shr_imm16,
4113                        OpcodeStr, !strconcat(Dt, "16"), v4i16, ShOp> {
4114    let Inst{21-20} = 0b01;  // imm6 = 01xxxx
4115  }
4116  def v2i32 : N2VDShAdd<op24, op23, op11_8, 0, op4, shr_imm32,
4117                        OpcodeStr, !strconcat(Dt, "32"), v2i32, ShOp> {
4118    let Inst{21} = 0b1;      // imm6 = 1xxxxx
4119  }
4120  def v1i64 : N2VDShAdd<op24, op23, op11_8, 1, op4, shr_imm64,
4121                        OpcodeStr, !strconcat(Dt, "64"), v1i64, ShOp>;
4122                             // imm6 = xxxxxx
4123
4124  // 128-bit vector types.
4125  def v16i8 : N2VQShAdd<op24, op23, op11_8, 0, op4, shr_imm8,
4126                        OpcodeStr, !strconcat(Dt, "8"), v16i8, ShOp> {
4127    let Inst{21-19} = 0b001; // imm6 = 001xxx
4128  }
4129  def v8i16 : N2VQShAdd<op24, op23, op11_8, 0, op4, shr_imm16,
4130                        OpcodeStr, !strconcat(Dt, "16"), v8i16, ShOp> {
4131    let Inst{21-20} = 0b01;  // imm6 = 01xxxx
4132  }
4133  def v4i32 : N2VQShAdd<op24, op23, op11_8, 0, op4, shr_imm32,
4134                        OpcodeStr, !strconcat(Dt, "32"), v4i32, ShOp> {
4135    let Inst{21} = 0b1;      // imm6 = 1xxxxx
4136  }
4137  def v2i64 : N2VQShAdd<op24, op23, op11_8, 1, op4, shr_imm64,
4138                        OpcodeStr, !strconcat(Dt, "64"), v2i64, ShOp>;
4139                             // imm6 = xxxxxx
4140}
4141
4142// Neon Shift-Insert vector operations,
4143//   with f of either N2RegVShLFrm or N2RegVShRFrm
4144//   element sizes of 8, 16, 32 and 64 bits:
4145multiclass N2VShInsL_QHSD<bit op24, bit op23, bits<4> op11_8, bit op4,
4146                          string OpcodeStr> {
4147  // 64-bit vector types.
4148  def v8i8  : N2VDShIns<op24, op23, op11_8, 0, op4, i32imm,
4149                        N2RegVShLFrm, OpcodeStr, "8", v8i8, NEONvsliImm> {
4150    let Inst{21-19} = 0b001; // imm6 = 001xxx
4151  }
4152  def v4i16 : N2VDShIns<op24, op23, op11_8, 0, op4, i32imm,
4153                        N2RegVShLFrm, OpcodeStr, "16", v4i16, NEONvsliImm> {
4154    let Inst{21-20} = 0b01;  // imm6 = 01xxxx
4155  }
4156  def v2i32 : N2VDShIns<op24, op23, op11_8, 0, op4, i32imm,
4157                        N2RegVShLFrm, OpcodeStr, "32", v2i32, NEONvsliImm> {
4158    let Inst{21} = 0b1;      // imm6 = 1xxxxx
4159  }
4160  def v1i64 : N2VDShIns<op24, op23, op11_8, 1, op4, i32imm,
4161                        N2RegVShLFrm, OpcodeStr, "64", v1i64, NEONvsliImm>;
4162                             // imm6 = xxxxxx
4163
4164  // 128-bit vector types.
4165  def v16i8 : N2VQShIns<op24, op23, op11_8, 0, op4, i32imm,
4166                        N2RegVShLFrm, OpcodeStr, "8", v16i8, NEONvsliImm> {
4167    let Inst{21-19} = 0b001; // imm6 = 001xxx
4168  }
4169  def v8i16 : N2VQShIns<op24, op23, op11_8, 0, op4, i32imm,
4170                        N2RegVShLFrm, OpcodeStr, "16", v8i16, NEONvsliImm> {
4171    let Inst{21-20} = 0b01;  // imm6 = 01xxxx
4172  }
4173  def v4i32 : N2VQShIns<op24, op23, op11_8, 0, op4, i32imm,
4174                        N2RegVShLFrm, OpcodeStr, "32", v4i32, NEONvsliImm> {
4175    let Inst{21} = 0b1;      // imm6 = 1xxxxx
4176  }
4177  def v2i64 : N2VQShIns<op24, op23, op11_8, 1, op4, i32imm,
4178                        N2RegVShLFrm, OpcodeStr, "64", v2i64, NEONvsliImm>;
4179                             // imm6 = xxxxxx
4180}
4181multiclass N2VShInsR_QHSD<bit op24, bit op23, bits<4> op11_8, bit op4,
4182                          string OpcodeStr> {
4183  // 64-bit vector types.
4184  def v8i8  : N2VDShIns<op24, op23, op11_8, 0, op4, shr_imm8,
4185                        N2RegVShRFrm, OpcodeStr, "8", v8i8, NEONvsriImm> {
4186    let Inst{21-19} = 0b001; // imm6 = 001xxx
4187  }
4188  def v4i16 : N2VDShIns<op24, op23, op11_8, 0, op4, shr_imm16,
4189                        N2RegVShRFrm, OpcodeStr, "16", v4i16, NEONvsriImm> {
4190    let Inst{21-20} = 0b01;  // imm6 = 01xxxx
4191  }
4192  def v2i32 : N2VDShIns<op24, op23, op11_8, 0, op4, shr_imm32,
4193                        N2RegVShRFrm, OpcodeStr, "32", v2i32, NEONvsriImm> {
4194    let Inst{21} = 0b1;      // imm6 = 1xxxxx
4195  }
4196  def v1i64 : N2VDShIns<op24, op23, op11_8, 1, op4, shr_imm64,
4197                        N2RegVShRFrm, OpcodeStr, "64", v1i64, NEONvsriImm>;
4198                             // imm6 = xxxxxx
4199
4200  // 128-bit vector types.
4201  def v16i8 : N2VQShIns<op24, op23, op11_8, 0, op4, shr_imm8,
4202                        N2RegVShRFrm, OpcodeStr, "8", v16i8, NEONvsriImm> {
4203    let Inst{21-19} = 0b001; // imm6 = 001xxx
4204  }
4205  def v8i16 : N2VQShIns<op24, op23, op11_8, 0, op4, shr_imm16,
4206                        N2RegVShRFrm, OpcodeStr, "16", v8i16, NEONvsriImm> {
4207    let Inst{21-20} = 0b01;  // imm6 = 01xxxx
4208  }
4209  def v4i32 : N2VQShIns<op24, op23, op11_8, 0, op4, shr_imm32,
4210                        N2RegVShRFrm, OpcodeStr, "32", v4i32, NEONvsriImm> {
4211    let Inst{21} = 0b1;      // imm6 = 1xxxxx
4212  }
4213  def v2i64 : N2VQShIns<op24, op23, op11_8, 1, op4, shr_imm64,
4214                        N2RegVShRFrm, OpcodeStr, "64", v2i64, NEONvsriImm>;
4215                             // imm6 = xxxxxx
4216}
4217
4218// Neon Shift Long operations,
4219//   element sizes of 8, 16, 32 bits:
4220multiclass N2VLSh_QHS<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6,
4221                      bit op4, string OpcodeStr, string Dt,
4222                      SDPatternOperator OpNode> {
4223  def v8i16 : N2VLSh<op24, op23, op11_8, op7, op6, op4,
4224              OpcodeStr, !strconcat(Dt, "8"), v8i16, v8i8, imm1_7, OpNode> {
4225    let Inst{21-19} = 0b001; // imm6 = 001xxx
4226  }
4227  def v4i32 : N2VLSh<op24, op23, op11_8, op7, op6, op4,
4228               OpcodeStr, !strconcat(Dt, "16"), v4i32, v4i16, imm1_15, OpNode> {
4229    let Inst{21-20} = 0b01;  // imm6 = 01xxxx
4230  }
4231  def v2i64 : N2VLSh<op24, op23, op11_8, op7, op6, op4,
4232               OpcodeStr, !strconcat(Dt, "32"), v2i64, v2i32, imm1_31, OpNode> {
4233    let Inst{21} = 0b1;      // imm6 = 1xxxxx
4234  }
4235}
4236
4237// Neon Shift Narrow operations,
4238//   element sizes of 16, 32, 64 bits:
4239multiclass N2VNSh_HSD<bit op24, bit op23, bits<4> op11_8, bit op7, bit op6,
4240                      bit op4, InstrItinClass itin, string OpcodeStr, string Dt,
4241                      SDPatternOperator OpNode> {
4242  def v8i8 : N2VNSh<op24, op23, op11_8, op7, op6, op4, itin,
4243                    OpcodeStr, !strconcat(Dt, "16"),
4244                    v8i8, v8i16, shr_imm8, OpNode> {
4245    let Inst{21-19} = 0b001; // imm6 = 001xxx
4246  }
4247  def v4i16 : N2VNSh<op24, op23, op11_8, op7, op6, op4, itin,
4248                     OpcodeStr, !strconcat(Dt, "32"),
4249                     v4i16, v4i32, shr_imm16, OpNode> {
4250    let Inst{21-20} = 0b01;  // imm6 = 01xxxx
4251  }
4252  def v2i32 : N2VNSh<op24, op23, op11_8, op7, op6, op4, itin,
4253                     OpcodeStr, !strconcat(Dt, "64"),
4254                     v2i32, v2i64, shr_imm32, OpNode> {
4255    let Inst{21} = 0b1;      // imm6 = 1xxxxx
4256  }
4257}
4258
4259//===----------------------------------------------------------------------===//
4260// Instruction Definitions.
4261//===----------------------------------------------------------------------===//
4262
4263// Vector Add Operations.
4264
4265//   VADD     : Vector Add (integer and floating-point)
4266defm VADD     : N3V_QHSD<0, 0, 0b1000, 0, IIC_VBINiD, IIC_VBINiQ, "vadd", "i",
4267                         add, 1>;
4268def  VADDfd   : N3VD<0, 0, 0b00, 0b1101, 0, IIC_VBIND, "vadd", "f32",
4269                     v2f32, v2f32, fadd, 1>;
4270def  VADDfq   : N3VQ<0, 0, 0b00, 0b1101, 0, IIC_VBINQ, "vadd", "f32",
4271                     v4f32, v4f32, fadd, 1>;
4272def  VADDhd   : N3VD<0, 0, 0b01, 0b1101, 0, IIC_VBIND, "vadd", "f16",
4273                     v4f16, v4f16, fadd, 1>,
4274                Requires<[HasNEON,HasFullFP16]>;
4275def  VADDhq   : N3VQ<0, 0, 0b01, 0b1101, 0, IIC_VBINQ, "vadd", "f16",
4276                     v8f16, v8f16, fadd, 1>,
4277                Requires<[HasNEON,HasFullFP16]>;
4278//   VADDL    : Vector Add Long (Q = D + D)
4279defm VADDLs   : N3VLExt_QHS<0,1,0b0000,0, IIC_VSHLiD, IIC_VSHLiD,
4280                            "vaddl", "s", add, sext, 1>;
4281defm VADDLu   : N3VLExt_QHS<1,1,0b0000,0, IIC_VSHLiD, IIC_VSHLiD,
4282                            "vaddl", "u", add, zanyext, 1>;
4283//   VADDW    : Vector Add Wide (Q = Q + D)
4284defm VADDWs   : N3VW_QHS<0,1,0b0001,0, "vaddw", "s", add, sext, 0>;
4285defm VADDWu   : N3VW_QHS<1,1,0b0001,0, "vaddw", "u", add, zanyext, 0>;
4286//   VHADD    : Vector Halving Add
4287defm VHADDs   : N3VInt_QHS<0, 0, 0b0000, 0, N3RegFrm,
4288                           IIC_VBINi4D, IIC_VBINi4D, IIC_VBINi4Q, IIC_VBINi4Q,
4289                           "vhadd", "s", int_arm_neon_vhadds, 1>;
4290defm VHADDu   : N3VInt_QHS<1, 0, 0b0000, 0, N3RegFrm,
4291                           IIC_VBINi4D, IIC_VBINi4D, IIC_VBINi4Q, IIC_VBINi4Q,
4292                           "vhadd", "u", int_arm_neon_vhaddu, 1>;
4293//   VRHADD   : Vector Rounding Halving Add
4294defm VRHADDs  : N3VInt_QHS<0, 0, 0b0001, 0, N3RegFrm,
4295                           IIC_VBINi4D, IIC_VBINi4D, IIC_VBINi4Q, IIC_VBINi4Q,
4296                           "vrhadd", "s", int_arm_neon_vrhadds, 1>;
4297defm VRHADDu  : N3VInt_QHS<1, 0, 0b0001, 0, N3RegFrm,
4298                           IIC_VBINi4D, IIC_VBINi4D, IIC_VBINi4Q, IIC_VBINi4Q,
4299                           "vrhadd", "u", int_arm_neon_vrhaddu, 1>;
4300//   VQADD    : Vector Saturating Add
4301defm VQADDs   : N3VInt_QHSD<0, 0, 0b0000, 1, N3RegFrm,
4302                            IIC_VBINi4D, IIC_VBINi4D, IIC_VBINi4Q, IIC_VBINi4Q,
4303                            "vqadd", "s", saddsat, 1>;
4304defm VQADDu   : N3VInt_QHSD<1, 0, 0b0000, 1, N3RegFrm,
4305                            IIC_VBINi4D, IIC_VBINi4D, IIC_VBINi4Q, IIC_VBINi4Q,
4306                            "vqadd", "u", uaddsat, 1>;
4307//   VADDHN   : Vector Add and Narrow Returning High Half (D = Q + Q)
4308defm VADDHN   : N3VNInt_HSD<0,1,0b0100,0, "vaddhn", "i", null_frag, 1>;
4309//   VRADDHN  : Vector Rounding Add and Narrow Returning High Half (D = Q + Q)
4310defm VRADDHN  : N3VNInt_HSD<1,1,0b0100,0, "vraddhn", "i",
4311                            int_arm_neon_vraddhn, 1>;
4312
4313let Predicates = [HasNEON] in {
4314def : Pat<(v8i8  (trunc (ARMvshruImm (add (v8i16 QPR:$Vn), QPR:$Vm), 8))),
4315          (VADDHNv8i8 QPR:$Vn, QPR:$Vm)>;
4316def : Pat<(v4i16 (trunc (ARMvshruImm (add (v4i32 QPR:$Vn), QPR:$Vm), 16))),
4317          (VADDHNv4i16 QPR:$Vn, QPR:$Vm)>;
4318def : Pat<(v2i32 (trunc (ARMvshruImm (add (v2i64 QPR:$Vn), QPR:$Vm), 32))),
4319          (VADDHNv2i32 QPR:$Vn, QPR:$Vm)>;
4320}
4321
4322// Vector Multiply Operations.
4323
4324//   VMUL     : Vector Multiply (integer, polynomial and floating-point)
4325defm VMUL     : N3V_QHS<0, 0, 0b1001, 1, IIC_VMULi16D, IIC_VMULi32D,
4326                        IIC_VMULi16Q, IIC_VMULi32Q, "vmul", "i", mul, 1>;
4327def  VMULpd   : N3VDInt<1, 0, 0b00, 0b1001, 1, N3RegFrm, IIC_VMULi16D, "vmul",
4328                        "p8", v8i8, v8i8, int_arm_neon_vmulp, 1>;
4329def  VMULpq   : N3VQInt<1, 0, 0b00, 0b1001, 1, N3RegFrm, IIC_VMULi16Q, "vmul",
4330                        "p8", v16i8, v16i8, int_arm_neon_vmulp, 1>;
4331def  VMULfd   : N3VD<1, 0, 0b00, 0b1101, 1, IIC_VFMULD, "vmul", "f32",
4332                     v2f32, v2f32, fmul, 1>;
4333def  VMULfq   : N3VQ<1, 0, 0b00, 0b1101, 1, IIC_VFMULQ, "vmul", "f32",
4334                     v4f32, v4f32, fmul, 1>;
4335def  VMULhd   : N3VD<1, 0, 0b01, 0b1101, 1, IIC_VFMULD, "vmul", "f16",
4336                     v4f16, v4f16, fmul, 1>,
4337                Requires<[HasNEON,HasFullFP16]>;
4338def  VMULhq   : N3VQ<1, 0, 0b01, 0b1101, 1, IIC_VFMULQ, "vmul", "f16",
4339                     v8f16, v8f16, fmul, 1>,
4340                Requires<[HasNEON,HasFullFP16]>;
4341defm VMULsl   : N3VSL_HS<0b1000, "vmul", mul>;
4342def  VMULslfd : N3VDSL<0b10, 0b1001, IIC_VBIND, "vmul", "f32", v2f32, fmul>;
4343def  VMULslfq : N3VQSL<0b10, 0b1001, IIC_VBINQ, "vmul", "f32", v4f32,
4344                       v2f32, fmul>;
4345def  VMULslhd : N3VDSL16<0b01, 0b1001, "vmul", "f16", v4f16, fmul>,
4346                Requires<[HasNEON,HasFullFP16]>;
4347def  VMULslhq : N3VQSL16<0b01, 0b1001, "vmul", "f16", v8f16,
4348                       v4f16, fmul>,
4349                Requires<[HasNEON,HasFullFP16]>;
4350
4351let Predicates = [HasNEON] in {
4352def : Pat<(v8i16 (mul (v8i16 QPR:$src1),
4353                      (v8i16 (ARMvduplane (v8i16 QPR:$src2), imm:$lane)))),
4354          (v8i16 (VMULslv8i16 (v8i16 QPR:$src1),
4355                              (v4i16 (EXTRACT_SUBREG QPR:$src2,
4356                                      (DSubReg_i16_reg imm:$lane))),
4357                              (SubReg_i16_lane imm:$lane)))>;
4358def : Pat<(v4i32 (mul (v4i32 QPR:$src1),
4359                      (v4i32 (ARMvduplane (v4i32 QPR:$src2), imm:$lane)))),
4360          (v4i32 (VMULslv4i32 (v4i32 QPR:$src1),
4361                              (v2i32 (EXTRACT_SUBREG QPR:$src2,
4362                                      (DSubReg_i32_reg imm:$lane))),
4363                              (SubReg_i32_lane imm:$lane)))>;
4364def : Pat<(v4f32 (fmul (v4f32 QPR:$src1),
4365                       (v4f32 (ARMvduplane (v4f32 QPR:$src2), imm:$lane)))),
4366          (v4f32 (VMULslfq (v4f32 QPR:$src1),
4367                           (v2f32 (EXTRACT_SUBREG QPR:$src2,
4368                                   (DSubReg_i32_reg imm:$lane))),
4369                           (SubReg_i32_lane imm:$lane)))>;
4370def : Pat<(v8f16 (fmul (v8f16 QPR:$src1),
4371                       (v8f16 (ARMvduplane (v8f16 QPR:$src2), imm:$lane)))),
4372          (v8f16 (VMULslhq(v8f16 QPR:$src1),
4373                           (v4f16 (EXTRACT_SUBREG QPR:$src2,
4374                                   (DSubReg_i16_reg imm:$lane))),
4375                           (SubReg_i16_lane imm:$lane)))>;
4376
4377def : Pat<(v2f32 (fmul DPR:$Rn, (ARMvdup (f32 SPR:$Rm)))),
4378          (VMULslfd DPR:$Rn,
4379            (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), SPR:$Rm, ssub_0),
4380            (i32 0))>;
4381def : Pat<(v4f16 (fmul DPR:$Rn, (ARMvdup (f16 HPR:$Rm)))),
4382          (VMULslhd DPR:$Rn,
4383            (INSERT_SUBREG (v4f16 (IMPLICIT_DEF)), (f16 HPR:$Rm), ssub_0),
4384            (i32 0))>;
4385def : Pat<(v4f32 (fmul QPR:$Rn, (ARMvdup (f32 SPR:$Rm)))),
4386          (VMULslfq QPR:$Rn,
4387            (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), SPR:$Rm, ssub_0),
4388            (i32 0))>;
4389def : Pat<(v8f16 (fmul QPR:$Rn, (ARMvdup (f16 HPR:$Rm)))),
4390          (VMULslhq QPR:$Rn,
4391            (INSERT_SUBREG (v4f16 (IMPLICIT_DEF)), (f16 HPR:$Rm), ssub_0),
4392            (i32 0))>;
4393}
4394
4395//   VQDMULH  : Vector Saturating Doubling Multiply Returning High Half
4396defm VQDMULH  : N3VInt_HS<0, 0, 0b1011, 0, N3RegFrm, IIC_VMULi16D, IIC_VMULi32D,
4397                          IIC_VMULi16Q, IIC_VMULi32Q,
4398                          "vqdmulh", "s", int_arm_neon_vqdmulh, 1>;
4399defm VQDMULHsl: N3VIntSL_HS<0b1100, IIC_VMULi16D, IIC_VMULi32D,
4400                            IIC_VMULi16Q, IIC_VMULi32Q,
4401                            "vqdmulh", "s",  int_arm_neon_vqdmulh>;
4402
4403let Predicates = [HasNEON] in {
4404def : Pat<(v8i16 (int_arm_neon_vqdmulh (v8i16 QPR:$src1),
4405                                       (v8i16 (ARMvduplane (v8i16 QPR:$src2),
4406                                                            imm:$lane)))),
4407          (v8i16 (VQDMULHslv8i16 (v8i16 QPR:$src1),
4408                                 (v4i16 (EXTRACT_SUBREG QPR:$src2,
4409                                         (DSubReg_i16_reg imm:$lane))),
4410                                 (SubReg_i16_lane imm:$lane)))>;
4411def : Pat<(v4i32 (int_arm_neon_vqdmulh (v4i32 QPR:$src1),
4412                                       (v4i32 (ARMvduplane (v4i32 QPR:$src2),
4413                                                            imm:$lane)))),
4414          (v4i32 (VQDMULHslv4i32 (v4i32 QPR:$src1),
4415                                 (v2i32 (EXTRACT_SUBREG QPR:$src2,
4416                                         (DSubReg_i32_reg imm:$lane))),
4417                                 (SubReg_i32_lane imm:$lane)))>;
4418}
4419
4420//   VQRDMULH : Vector Rounding Saturating Doubling Multiply Returning High Half
4421defm VQRDMULH   : N3VInt_HS<1, 0, 0b1011, 0, N3RegFrm,
4422                            IIC_VMULi16D,IIC_VMULi32D,IIC_VMULi16Q,IIC_VMULi32Q,
4423                            "vqrdmulh", "s", int_arm_neon_vqrdmulh, 1>;
4424defm VQRDMULHsl : N3VIntSL_HS<0b1101, IIC_VMULi16D, IIC_VMULi32D,
4425                              IIC_VMULi16Q, IIC_VMULi32Q,
4426                              "vqrdmulh", "s",  int_arm_neon_vqrdmulh>;
4427
4428let Predicates = [HasNEON] in {
4429def : Pat<(v8i16 (int_arm_neon_vqrdmulh (v8i16 QPR:$src1),
4430                                        (v8i16 (ARMvduplane (v8i16 QPR:$src2),
4431                                                             imm:$lane)))),
4432          (v8i16 (VQRDMULHslv8i16 (v8i16 QPR:$src1),
4433                                  (v4i16 (EXTRACT_SUBREG QPR:$src2,
4434                                          (DSubReg_i16_reg imm:$lane))),
4435                                  (SubReg_i16_lane imm:$lane)))>;
4436def : Pat<(v4i32 (int_arm_neon_vqrdmulh (v4i32 QPR:$src1),
4437                                        (v4i32 (ARMvduplane (v4i32 QPR:$src2),
4438                                                             imm:$lane)))),
4439          (v4i32 (VQRDMULHslv4i32 (v4i32 QPR:$src1),
4440                                  (v2i32 (EXTRACT_SUBREG QPR:$src2,
4441                                          (DSubReg_i32_reg imm:$lane))),
4442                                  (SubReg_i32_lane imm:$lane)))>;
4443}
4444
4445//   VMULL    : Vector Multiply Long (integer and polynomial) (Q = D * D)
4446let PostEncoderMethod = "NEONThumb2DataIPostEncoder",
4447    DecoderNamespace = "NEONData" in {
4448  defm VMULLs   : N3VL_QHS<0,1,0b1100,0, IIC_VMULi16D, IIC_VMULi32D,
4449                           "vmull", "s", ARMvmulls, 1>;
4450  defm VMULLu   : N3VL_QHS<1,1,0b1100,0, IIC_VMULi16D, IIC_VMULi32D,
4451                           "vmull", "u", ARMvmullu, 1>;
4452  def  VMULLp8   :  N3VLInt<0, 1, 0b00, 0b1110, 0, IIC_VMULi16D, "vmull", "p8",
4453                            v8i16, v8i8, int_arm_neon_vmullp, 1>;
4454  def  VMULLp64  : N3VLIntnp<0b00101, 0b10, 0b1110, 0, 0, NoItinerary,
4455                          "vmull", "p64", v2i64, v1i64, int_arm_neon_vmullp, 1>,
4456                    Requires<[HasV8, HasAES]>;
4457}
4458defm VMULLsls : N3VLSL_HS<0, 0b1010, IIC_VMULi16D, "vmull", "s", ARMvmulls>;
4459defm VMULLslu : N3VLSL_HS<1, 0b1010, IIC_VMULi16D, "vmull", "u", ARMvmullu>;
4460
4461//   VQDMULL  : Vector Saturating Doubling Multiply Long (Q = D * D)
4462defm VQDMULL  : N3VLInt_HS<0,1,0b1101,0, IIC_VMULi16D, IIC_VMULi32D,
4463                           "vqdmull", "s", int_arm_neon_vqdmull, 1>;
4464defm VQDMULLsl: N3VLIntSL_HS<0, 0b1011, IIC_VMULi16D,
4465                             "vqdmull", "s", int_arm_neon_vqdmull>;
4466
4467// Vector Multiply-Accumulate and Multiply-Subtract Operations.
4468
4469//   VMLA     : Vector Multiply Accumulate (integer and floating-point)
4470defm VMLA     : N3VMulOp_QHS<0, 0, 0b1001, 0, IIC_VMACi16D, IIC_VMACi32D,
4471                             IIC_VMACi16Q, IIC_VMACi32Q, "vmla", "i", add>;
4472def  VMLAfd   : N3VDMulOp<0, 0, 0b00, 0b1101, 1, IIC_VMACD, "vmla", "f32",
4473                          v2f32, fmul_su, fadd_mlx>,
4474                Requires<[HasNEON, UseFPVMLx]>;
4475def  VMLAfq   : N3VQMulOp<0, 0, 0b00, 0b1101, 1, IIC_VMACQ, "vmla", "f32",
4476                          v4f32, fmul_su, fadd_mlx>,
4477                Requires<[HasNEON, UseFPVMLx]>;
4478def  VMLAhd   : N3VDMulOp<0, 0, 0b01, 0b1101, 1, IIC_VMACD, "vmla", "f16",
4479                          v4f16, fmul_su, fadd_mlx>,
4480                Requires<[HasNEON, HasFullFP16, UseFPVMLx]>;
4481def  VMLAhq   : N3VQMulOp<0, 0, 0b01, 0b1101, 1, IIC_VMACQ, "vmla", "f16",
4482                          v8f16, fmul_su, fadd_mlx>,
4483                Requires<[HasNEON, HasFullFP16, UseFPVMLx]>;
4484defm VMLAsl   : N3VMulOpSL_HS<0b0000, IIC_VMACi16D, IIC_VMACi32D,
4485                              IIC_VMACi16Q, IIC_VMACi32Q, "vmla", "i", add>;
4486def  VMLAslfd : N3VDMulOpSL<0b10, 0b0001, IIC_VMACD, "vmla", "f32",
4487                            v2f32, fmul_su, fadd_mlx>,
4488                Requires<[HasNEON, UseFPVMLx]>;
4489def  VMLAslfq : N3VQMulOpSL<0b10, 0b0001, IIC_VMACQ, "vmla", "f32",
4490                            v4f32, v2f32, fmul_su, fadd_mlx>,
4491                Requires<[HasNEON, UseFPVMLx]>;
4492def  VMLAslhd : N3VDMulOpSL16<0b01, 0b0001, IIC_VMACD, "vmla", "f16",
4493                            v4f16, fmul, fadd>,
4494                Requires<[HasNEON, HasFullFP16, UseFPVMLx]>;
4495def  VMLAslhq : N3VQMulOpSL16<0b01, 0b0001, IIC_VMACQ, "vmla", "f16",
4496                            v8f16, v4f16, fmul, fadd>,
4497                Requires<[HasNEON, HasFullFP16, UseFPVMLx]>;
4498
4499let Predicates = [HasNEON] in {
4500def : Pat<(v8i16 (add (v8i16 QPR:$src1),
4501                  (mul (v8i16 QPR:$src2),
4502                       (v8i16 (ARMvduplane (v8i16 QPR:$src3), imm:$lane))))),
4503          (v8i16 (VMLAslv8i16 (v8i16 QPR:$src1), (v8i16 QPR:$src2),
4504                              (v4i16 (EXTRACT_SUBREG QPR:$src3,
4505                                      (DSubReg_i16_reg imm:$lane))),
4506                              (SubReg_i16_lane imm:$lane)))>;
4507
4508def : Pat<(v4i32 (add (v4i32 QPR:$src1),
4509                  (mul (v4i32 QPR:$src2),
4510                       (v4i32 (ARMvduplane (v4i32 QPR:$src3), imm:$lane))))),
4511          (v4i32 (VMLAslv4i32 (v4i32 QPR:$src1), (v4i32 QPR:$src2),
4512                              (v2i32 (EXTRACT_SUBREG QPR:$src3,
4513                                      (DSubReg_i32_reg imm:$lane))),
4514                              (SubReg_i32_lane imm:$lane)))>;
4515}
4516
4517def : Pat<(v4f32 (fadd_mlx (v4f32 QPR:$src1),
4518                  (fmul_su (v4f32 QPR:$src2),
4519                        (v4f32 (ARMvduplane (v4f32 QPR:$src3), imm:$lane))))),
4520          (v4f32 (VMLAslfq (v4f32 QPR:$src1),
4521                           (v4f32 QPR:$src2),
4522                           (v2f32 (EXTRACT_SUBREG QPR:$src3,
4523                                   (DSubReg_i32_reg imm:$lane))),
4524                           (SubReg_i32_lane imm:$lane)))>,
4525          Requires<[HasNEON, UseFPVMLx]>;
4526
4527//   VMLAL    : Vector Multiply Accumulate Long (Q += D * D)
4528defm VMLALs   : N3VLMulOp_QHS<0,1,0b1000,0, IIC_VMACi16D, IIC_VMACi32D,
4529                              "vmlal", "s", ARMvmulls, add>;
4530defm VMLALu   : N3VLMulOp_QHS<1,1,0b1000,0, IIC_VMACi16D, IIC_VMACi32D,
4531                              "vmlal", "u", ARMvmullu, add>;
4532
4533defm VMLALsls : N3VLMulOpSL_HS<0, 0b0010, "vmlal", "s", ARMvmulls, add>;
4534defm VMLALslu : N3VLMulOpSL_HS<1, 0b0010, "vmlal", "u", ARMvmullu, add>;
4535
4536let Predicates = [HasNEON, HasV8_1a] in {
4537  // v8.1a Neon Rounding Double Multiply-Op vector operations,
4538  // VQRDMLAH : Vector Saturating Rounding Doubling Multiply Accumulate Long
4539  //            (Q += D * D)
4540  defm VQRDMLAH : N3VInt3_HS<1, 0, 0b1011, 1, IIC_VMACi16D, IIC_VMACi32D,
4541                             IIC_VMACi16Q, IIC_VMACi32Q, "vqrdmlah", "s",
4542                             null_frag>;
4543  def : Pat<(v4i16 (int_arm_neon_vqrdmlah (v4i16 DPR:$src1), (v4i16 DPR:$Vn),
4544                                                   (v4i16 DPR:$Vm))),
4545            (v4i16 (VQRDMLAHv4i16 DPR:$src1, DPR:$Vn, DPR:$Vm))>;
4546  def : Pat<(v2i32 (int_arm_neon_vqrdmlah (v2i32 DPR:$src1), (v2i32 DPR:$Vn),
4547                                                   (v2i32 DPR:$Vm))),
4548            (v2i32 (VQRDMLAHv2i32 DPR:$src1, DPR:$Vn, DPR:$Vm))>;
4549  def : Pat<(v8i16 (int_arm_neon_vqrdmlah (v8i16 QPR:$src1), (v8i16 QPR:$Vn),
4550                                                   (v8i16 QPR:$Vm))),
4551            (v8i16 (VQRDMLAHv8i16 QPR:$src1, QPR:$Vn, QPR:$Vm))>;
4552  def : Pat<(v4i32 (int_arm_neon_vqrdmlah (v4i32 QPR:$src1), (v4i32 QPR:$Vn),
4553                                                   (v4i32 QPR:$Vm))),
4554            (v4i32 (VQRDMLAHv4i32 QPR:$src1, QPR:$Vn, QPR:$Vm))>;
4555
4556  defm VQRDMLAHsl : N3VMulOpSL_HS<0b1110, IIC_VMACi16D, IIC_VMACi32D,
4557                                  IIC_VMACi16Q, IIC_VMACi32Q, "vqrdmlah", "s",
4558                                  null_frag>;
4559  def : Pat<(v4i16 (int_arm_neon_vqrdmlah (v4i16 DPR:$src1),
4560                              (v4i16 DPR:$Vn),
4561                              (v4i16 (ARMvduplane (v4i16 DPR_8:$Vm),
4562                                                   imm:$lane)))),
4563            (v4i16 (VQRDMLAHslv4i16 DPR:$src1, DPR:$Vn, DPR_8:$Vm,
4564                                    imm:$lane))>;
4565  def : Pat<(v2i32 (int_arm_neon_vqrdmlah (v2i32 DPR:$src1),
4566                              (v2i32 DPR:$Vn),
4567                              (v2i32 (ARMvduplane (v2i32 DPR_VFP2:$Vm),
4568                                                   imm:$lane)))),
4569            (v2i32 (VQRDMLAHslv2i32 DPR:$src1, DPR:$Vn, DPR_VFP2:$Vm,
4570                                    imm:$lane))>;
4571  def : Pat<(v8i16 (int_arm_neon_vqrdmlah (v8i16 QPR:$src1),
4572                              (v8i16 QPR:$src2),
4573                              (v8i16 (ARMvduplane (v8i16 QPR:$src3),
4574                                                   imm:$lane)))),
4575            (v8i16 (VQRDMLAHslv8i16 (v8i16 QPR:$src1),
4576                                    (v8i16 QPR:$src2),
4577                                    (v4i16 (EXTRACT_SUBREG
4578                                             QPR:$src3,
4579                                             (DSubReg_i16_reg imm:$lane))),
4580                                    (SubReg_i16_lane imm:$lane)))>;
4581  def : Pat<(v4i32 (int_arm_neon_vqrdmlah (v4i32 QPR:$src1),
4582                              (v4i32 QPR:$src2),
4583                              (v4i32 (ARMvduplane (v4i32 QPR:$src3),
4584                                                   imm:$lane)))),
4585            (v4i32 (VQRDMLAHslv4i32 (v4i32 QPR:$src1),
4586                                    (v4i32 QPR:$src2),
4587                                    (v2i32 (EXTRACT_SUBREG
4588                                             QPR:$src3,
4589                                             (DSubReg_i32_reg imm:$lane))),
4590                                    (SubReg_i32_lane imm:$lane)))>;
4591
4592  //   VQRDMLSH : Vector Saturating Rounding Doubling Multiply Subtract Long
4593  //              (Q -= D * D)
4594  defm VQRDMLSH : N3VInt3_HS<1, 0, 0b1100, 1, IIC_VMACi16D, IIC_VMACi32D,
4595                             IIC_VMACi16Q, IIC_VMACi32Q, "vqrdmlsh", "s",
4596                             null_frag>;
4597  def : Pat<(v4i16 (int_arm_neon_vqrdmlsh (v4i16 DPR:$src1), (v4i16 DPR:$Vn),
4598                                                   (v4i16 DPR:$Vm))),
4599            (v4i16 (VQRDMLSHv4i16 DPR:$src1, DPR:$Vn, DPR:$Vm))>;
4600  def : Pat<(v2i32 (int_arm_neon_vqrdmlsh (v2i32 DPR:$src1), (v2i32 DPR:$Vn),
4601                                                   (v2i32 DPR:$Vm))),
4602            (v2i32 (VQRDMLSHv2i32 DPR:$src1, DPR:$Vn, DPR:$Vm))>;
4603  def : Pat<(v8i16 (int_arm_neon_vqrdmlsh (v8i16 QPR:$src1), (v8i16 QPR:$Vn),
4604                                                   (v8i16 QPR:$Vm))),
4605            (v8i16 (VQRDMLSHv8i16 QPR:$src1, QPR:$Vn, QPR:$Vm))>;
4606  def : Pat<(v4i32 (int_arm_neon_vqrdmlsh (v4i32 QPR:$src1), (v4i32 QPR:$Vn),
4607                                                   (v4i32 QPR:$Vm))),
4608            (v4i32 (VQRDMLSHv4i32 QPR:$src1, QPR:$Vn, QPR:$Vm))>;
4609
4610  defm VQRDMLSHsl : N3VMulOpSL_HS<0b1111, IIC_VMACi16D, IIC_VMACi32D,
4611                                  IIC_VMACi16Q, IIC_VMACi32Q, "vqrdmlsh", "s",
4612                                  null_frag>;
4613  def : Pat<(v4i16 (int_arm_neon_vqrdmlsh (v4i16 DPR:$src1),
4614                              (v4i16 DPR:$Vn),
4615                              (v4i16 (ARMvduplane (v4i16 DPR_8:$Vm),
4616                                                   imm:$lane)))),
4617            (v4i16 (VQRDMLSHslv4i16 DPR:$src1, DPR:$Vn, DPR_8:$Vm, imm:$lane))>;
4618  def : Pat<(v2i32 (int_arm_neon_vqrdmlsh (v2i32 DPR:$src1),
4619                              (v2i32 DPR:$Vn),
4620                              (v2i32 (ARMvduplane (v2i32 DPR_VFP2:$Vm),
4621                                                   imm:$lane)))),
4622            (v2i32 (VQRDMLSHslv2i32 DPR:$src1, DPR:$Vn, DPR_VFP2:$Vm,
4623                                    imm:$lane))>;
4624  def : Pat<(v8i16 (int_arm_neon_vqrdmlsh (v8i16 QPR:$src1),
4625                              (v8i16 QPR:$src2),
4626                              (v8i16 (ARMvduplane (v8i16 QPR:$src3),
4627                                                   imm:$lane)))),
4628            (v8i16 (VQRDMLSHslv8i16 (v8i16 QPR:$src1),
4629                                    (v8i16 QPR:$src2),
4630                                    (v4i16 (EXTRACT_SUBREG
4631                                             QPR:$src3,
4632                                             (DSubReg_i16_reg imm:$lane))),
4633                                    (SubReg_i16_lane imm:$lane)))>;
4634  def : Pat<(v4i32 (int_arm_neon_vqrdmlsh (v4i32 QPR:$src1),
4635                              (v4i32 QPR:$src2),
4636                              (v4i32 (ARMvduplane (v4i32 QPR:$src3),
4637                                                    imm:$lane)))),
4638            (v4i32 (VQRDMLSHslv4i32 (v4i32 QPR:$src1),
4639                                    (v4i32 QPR:$src2),
4640                                    (v2i32 (EXTRACT_SUBREG
4641                                             QPR:$src3,
4642                                             (DSubReg_i32_reg imm:$lane))),
4643                                    (SubReg_i32_lane imm:$lane)))>;
4644}
4645//   VQDMLAL  : Vector Saturating Doubling Multiply Accumulate Long (Q += D * D)
4646defm VQDMLAL  : N3VLInt3_HS<0, 1, 0b1001, 0, IIC_VMACi16D, IIC_VMACi32D,
4647                            "vqdmlal", "s", null_frag>;
4648defm VQDMLALsl: N3VLInt3SL_HS<0, 0b0011, "vqdmlal", "s", null_frag>;
4649
4650let Predicates = [HasNEON] in {
4651def : Pat<(v4i32 (saddsat (v4i32 QPR:$src1),
4652                     (v4i32 (int_arm_neon_vqdmull (v4i16 DPR:$Vn),
4653                                                  (v4i16 DPR:$Vm))))),
4654          (VQDMLALv4i32 QPR:$src1, DPR:$Vn, DPR:$Vm)>;
4655def : Pat<(v2i64 (saddsat (v2i64 QPR:$src1),
4656                     (v2i64 (int_arm_neon_vqdmull (v2i32 DPR:$Vn),
4657                                                  (v2i32 DPR:$Vm))))),
4658          (VQDMLALv2i64 QPR:$src1, DPR:$Vn, DPR:$Vm)>;
4659def : Pat<(v4i32 (saddsat (v4i32 QPR:$src1),
4660                     (v4i32 (int_arm_neon_vqdmull (v4i16 DPR:$Vn),
4661                                (v4i16 (ARMvduplane (v4i16 DPR_8:$Vm),
4662                                                     imm:$lane)))))),
4663          (VQDMLALslv4i16 QPR:$src1, DPR:$Vn, DPR_8:$Vm, imm:$lane)>;
4664def : Pat<(v2i64 (saddsat (v2i64 QPR:$src1),
4665                     (v2i64 (int_arm_neon_vqdmull (v2i32 DPR:$Vn),
4666                                (v2i32 (ARMvduplane (v2i32 DPR_VFP2:$Vm),
4667                                                     imm:$lane)))))),
4668          (VQDMLALslv2i32 QPR:$src1, DPR:$Vn, DPR_VFP2:$Vm, imm:$lane)>;
4669}
4670
4671//   VMLS     : Vector Multiply Subtract (integer and floating-point)
4672defm VMLS     : N3VMulOp_QHS<1, 0, 0b1001, 0, IIC_VMACi16D, IIC_VMACi32D,
4673                             IIC_VMACi16Q, IIC_VMACi32Q, "vmls", "i", sub>;
4674def  VMLSfd   : N3VDMulOp<0, 0, 0b10, 0b1101, 1, IIC_VMACD, "vmls", "f32",
4675                          v2f32, fmul_su, fsub_mlx>,
4676                Requires<[HasNEON, UseFPVMLx]>;
4677def  VMLSfq   : N3VQMulOp<0, 0, 0b10, 0b1101, 1, IIC_VMACQ, "vmls", "f32",
4678                          v4f32, fmul_su, fsub_mlx>,
4679                Requires<[HasNEON, UseFPVMLx]>;
4680def  VMLShd   : N3VDMulOp<0, 0, 0b11, 0b1101, 1, IIC_VMACD, "vmls", "f16",
4681                          v4f16, fmul, fsub>,
4682                Requires<[HasNEON, HasFullFP16, UseFPVMLx]>;
4683def  VMLShq   : N3VQMulOp<0, 0, 0b11, 0b1101, 1, IIC_VMACQ, "vmls", "f16",
4684                          v8f16, fmul, fsub>,
4685                Requires<[HasNEON, HasFullFP16, UseFPVMLx]>;
4686defm VMLSsl   : N3VMulOpSL_HS<0b0100, IIC_VMACi16D, IIC_VMACi32D,
4687                              IIC_VMACi16Q, IIC_VMACi32Q, "vmls", "i", sub>;
4688def  VMLSslfd : N3VDMulOpSL<0b10, 0b0101, IIC_VMACD, "vmls", "f32",
4689                            v2f32, fmul_su, fsub_mlx>,
4690                Requires<[HasNEON, UseFPVMLx]>;
4691def  VMLSslfq : N3VQMulOpSL<0b10, 0b0101, IIC_VMACQ, "vmls", "f32",
4692                            v4f32, v2f32, fmul_su, fsub_mlx>,
4693                Requires<[HasNEON, UseFPVMLx]>;
4694def  VMLSslhd : N3VDMulOpSL16<0b01, 0b0101, IIC_VMACD, "vmls", "f16",
4695                            v4f16, fmul, fsub>,
4696                Requires<[HasNEON, HasFullFP16, UseFPVMLx]>;
4697def  VMLSslhq : N3VQMulOpSL16<0b01, 0b0101, IIC_VMACQ, "vmls", "f16",
4698                            v8f16, v4f16, fmul, fsub>,
4699                Requires<[HasNEON, HasFullFP16, UseFPVMLx]>;
4700
4701let Predicates = [HasNEON] in {
4702def : Pat<(v8i16 (sub (v8i16 QPR:$src1),
4703                  (mul (v8i16 QPR:$src2),
4704                       (v8i16 (ARMvduplane (v8i16 QPR:$src3), imm:$lane))))),
4705          (v8i16 (VMLSslv8i16 (v8i16 QPR:$src1), (v8i16 QPR:$src2),
4706                              (v4i16 (EXTRACT_SUBREG QPR:$src3,
4707                                      (DSubReg_i16_reg imm:$lane))),
4708                              (SubReg_i16_lane imm:$lane)))>;
4709
4710def : Pat<(v4i32 (sub (v4i32 QPR:$src1),
4711                  (mul (v4i32 QPR:$src2),
4712                     (v4i32 (ARMvduplane (v4i32 QPR:$src3), imm:$lane))))),
4713          (v4i32 (VMLSslv4i32 (v4i32 QPR:$src1), (v4i32 QPR:$src2),
4714                              (v2i32 (EXTRACT_SUBREG QPR:$src3,
4715                                      (DSubReg_i32_reg imm:$lane))),
4716                              (SubReg_i32_lane imm:$lane)))>;
4717}
4718
4719def : Pat<(v4f32 (fsub_mlx (v4f32 QPR:$src1),
4720                  (fmul_su (v4f32 QPR:$src2),
4721                        (v4f32 (ARMvduplane (v4f32 QPR:$src3), imm:$lane))))),
4722          (v4f32 (VMLSslfq (v4f32 QPR:$src1), (v4f32 QPR:$src2),
4723                           (v2f32 (EXTRACT_SUBREG QPR:$src3,
4724                                   (DSubReg_i32_reg imm:$lane))),
4725                           (SubReg_i32_lane imm:$lane)))>,
4726          Requires<[HasNEON, UseFPVMLx]>;
4727
4728//   VMLSL    : Vector Multiply Subtract Long (Q -= D * D)
4729defm VMLSLs   : N3VLMulOp_QHS<0,1,0b1010,0, IIC_VMACi16D, IIC_VMACi32D,
4730                              "vmlsl", "s", ARMvmulls, sub>;
4731defm VMLSLu   : N3VLMulOp_QHS<1,1,0b1010,0, IIC_VMACi16D, IIC_VMACi32D,
4732                              "vmlsl", "u", ARMvmullu, sub>;
4733
4734defm VMLSLsls : N3VLMulOpSL_HS<0, 0b0110, "vmlsl", "s", ARMvmulls, sub>;
4735defm VMLSLslu : N3VLMulOpSL_HS<1, 0b0110, "vmlsl", "u", ARMvmullu, sub>;
4736
4737//   VQDMLSL  : Vector Saturating Doubling Multiply Subtract Long (Q -= D * D)
4738defm VQDMLSL  : N3VLInt3_HS<0, 1, 0b1011, 0, IIC_VMACi16D, IIC_VMACi32D,
4739                            "vqdmlsl", "s", null_frag>;
4740defm VQDMLSLsl: N3VLInt3SL_HS<0, 0b0111, "vqdmlsl", "s", null_frag>;
4741
4742let Predicates = [HasNEON] in {
4743def : Pat<(v4i32 (ssubsat (v4i32 QPR:$src1),
4744                     (v4i32 (int_arm_neon_vqdmull (v4i16 DPR:$Vn),
4745                                                  (v4i16 DPR:$Vm))))),
4746          (VQDMLSLv4i32 QPR:$src1, DPR:$Vn, DPR:$Vm)>;
4747def : Pat<(v2i64 (ssubsat (v2i64 QPR:$src1),
4748                     (v2i64 (int_arm_neon_vqdmull (v2i32 DPR:$Vn),
4749                                                  (v2i32 DPR:$Vm))))),
4750          (VQDMLSLv2i64 QPR:$src1, DPR:$Vn, DPR:$Vm)>;
4751def : Pat<(v4i32 (ssubsat (v4i32 QPR:$src1),
4752                     (v4i32 (int_arm_neon_vqdmull (v4i16 DPR:$Vn),
4753                                (v4i16 (ARMvduplane (v4i16 DPR_8:$Vm),
4754                                                     imm:$lane)))))),
4755          (VQDMLSLslv4i16 QPR:$src1, DPR:$Vn, DPR_8:$Vm, imm:$lane)>;
4756def : Pat<(v2i64 (ssubsat (v2i64 QPR:$src1),
4757                     (v2i64 (int_arm_neon_vqdmull (v2i32 DPR:$Vn),
4758                                (v2i32 (ARMvduplane (v2i32 DPR_VFP2:$Vm),
4759                                                     imm:$lane)))))),
4760          (VQDMLSLslv2i32 QPR:$src1, DPR:$Vn, DPR_VFP2:$Vm, imm:$lane)>;
4761}
4762
4763// Fused Vector Multiply-Accumulate and Fused Multiply-Subtract Operations.
4764def  VFMAfd   : N3VDMulOp<0, 0, 0b00, 0b1100, 1, IIC_VFMACD, "vfma", "f32",
4765                          v2f32, fmul_su, fadd_mlx>,
4766                Requires<[HasNEON,HasVFP4,UseFusedMAC]>;
4767
4768def  VFMAfq   : N3VQMulOp<0, 0, 0b00, 0b1100, 1, IIC_VFMACQ, "vfma", "f32",
4769                          v4f32, fmul_su, fadd_mlx>,
4770                Requires<[HasNEON,HasVFP4,UseFusedMAC]>;
4771def  VFMAhd   : N3VDMulOp<0, 0, 0b01, 0b1100, 1, IIC_VFMACD, "vfma", "f16",
4772                          v4f16, fmul, fadd>,
4773                Requires<[HasNEON,HasFullFP16,UseFusedMAC]>;
4774
4775def  VFMAhq   : N3VQMulOp<0, 0, 0b01, 0b1100, 1, IIC_VFMACQ, "vfma", "f16",
4776                          v8f16, fmul, fadd>,
4777                Requires<[HasNEON,HasFullFP16,UseFusedMAC]>;
4778
4779//   Fused Vector Multiply Subtract (floating-point)
4780def  VFMSfd   : N3VDMulOp<0, 0, 0b10, 0b1100, 1, IIC_VFMACD, "vfms", "f32",
4781                          v2f32, fmul_su, fsub_mlx>,
4782                Requires<[HasNEON,HasVFP4,UseFusedMAC]>;
4783def  VFMSfq   : N3VQMulOp<0, 0, 0b10, 0b1100, 1, IIC_VFMACQ, "vfms", "f32",
4784                          v4f32, fmul_su, fsub_mlx>,
4785                Requires<[HasNEON,HasVFP4,UseFusedMAC]>;
4786def  VFMShd   : N3VDMulOp<0, 0, 0b11, 0b1100, 1, IIC_VFMACD, "vfms", "f16",
4787                          v4f16, fmul, fsub>,
4788                Requires<[HasNEON,HasFullFP16,UseFusedMAC]>;
4789def  VFMShq   : N3VQMulOp<0, 0, 0b11, 0b1100, 1, IIC_VFMACQ, "vfms", "f16",
4790                          v8f16, fmul, fsub>,
4791                Requires<[HasNEON,HasFullFP16,UseFusedMAC]>;
4792
4793// Match @llvm.fma.* intrinsics
4794def : Pat<(v4f16 (fma DPR:$Vn, DPR:$Vm, DPR:$src1)),
4795          (VFMAhd DPR:$src1, DPR:$Vn, DPR:$Vm)>,
4796          Requires<[HasNEON,HasFullFP16]>;
4797def : Pat<(v8f16 (fma QPR:$Vn, QPR:$Vm, QPR:$src1)),
4798          (VFMAhq QPR:$src1, QPR:$Vn, QPR:$Vm)>,
4799          Requires<[HasNEON,HasFullFP16]>;
4800def : Pat<(v2f32 (fma DPR:$Vn, DPR:$Vm, DPR:$src1)),
4801          (VFMAfd DPR:$src1, DPR:$Vn, DPR:$Vm)>,
4802          Requires<[HasNEON,HasVFP4]>;
4803def : Pat<(v4f32 (fma QPR:$Vn, QPR:$Vm, QPR:$src1)),
4804          (VFMAfq QPR:$src1, QPR:$Vn, QPR:$Vm)>,
4805          Requires<[HasNEON,HasVFP4]>;
4806def : Pat<(v2f32 (fma (fneg DPR:$Vn), DPR:$Vm, DPR:$src1)),
4807          (VFMSfd DPR:$src1, DPR:$Vn, DPR:$Vm)>,
4808      Requires<[HasNEON,HasVFP4]>;
4809def : Pat<(v4f32 (fma (fneg QPR:$Vn), QPR:$Vm, QPR:$src1)),
4810          (VFMSfq QPR:$src1, QPR:$Vn, QPR:$Vm)>,
4811      Requires<[HasNEON,HasVFP4]>;
4812
4813// ARMv8.2a dot product instructions.
4814// We put them in the VFPV8 decoder namespace because the ARM and Thumb
4815// encodings are the same and thus no further bit twiddling is necessary
4816// in the disassembler.
4817class VDOT<bit op6, bit op4, bit op23, RegisterClass RegTy, string Asm,
4818           string AsmTy, ValueType AccumTy, ValueType InputTy,
4819           SDPatternOperator OpNode> :
4820      N3Vnp<{0b1100, op23}, 0b10, 0b1101, op6, op4, (outs RegTy:$dst),
4821            (ins RegTy:$Vd, RegTy:$Vn, RegTy:$Vm), N3RegFrm, IIC_VDOTPROD,
4822            Asm, AsmTy,
4823            [(set (AccumTy RegTy:$dst),
4824                  (OpNode (AccumTy RegTy:$Vd),
4825                          (InputTy RegTy:$Vn),
4826                          (InputTy RegTy:$Vm)))]> {
4827  let Predicates = [HasDotProd];
4828  let DecoderNamespace = "VFPV8";
4829  let Constraints = "$dst = $Vd";
4830}
4831
4832def VUDOTD : VDOT<0, 1, 0, DPR, "vudot", "u8", v2i32, v8i8,  int_arm_neon_udot>;
4833def VSDOTD : VDOT<0, 0, 0, DPR, "vsdot", "s8", v2i32, v8i8,  int_arm_neon_sdot>;
4834def VUDOTQ : VDOT<1, 1, 0, QPR, "vudot", "u8", v4i32, v16i8, int_arm_neon_udot>;
4835def VSDOTQ : VDOT<1, 0, 0, QPR, "vsdot", "s8", v4i32, v16i8, int_arm_neon_sdot>;
4836
4837// Indexed dot product instructions:
4838multiclass DOTI<string opc, string dt, bit Q, bit U, RegisterClass Ty,
4839           ValueType AccumType, ValueType InputType, SDPatternOperator OpNode,
4840           dag RHS> {
4841  def "" : N3Vnp<0b11100, 0b10, 0b1101, Q, U, (outs Ty:$dst),
4842                 (ins Ty:$Vd, Ty:$Vn, DPR_VFP2:$Vm, VectorIndex32:$lane),
4843                 N3RegFrm, IIC_VDOTPROD, opc, dt, []> {
4844    bit lane;
4845    let Inst{5} = lane;
4846    let AsmString = !strconcat(opc, ".", dt, "\t$Vd, $Vn, $Vm$lane");
4847    let Constraints = "$dst = $Vd";
4848    let Predicates = [HasDotProd];
4849    let DecoderNamespace = "VFPV8";
4850  }
4851
4852  def : Pat<
4853    (AccumType (OpNode (AccumType Ty:$Vd),
4854                       (InputType Ty:$Vn),
4855                       (InputType (bitconvert (AccumType
4856                                  (ARMvduplane (AccumType Ty:$Vm),
4857                                                 VectorIndex32:$lane)))))),
4858    (!cast<Instruction>(NAME) Ty:$Vd, Ty:$Vn, RHS, VectorIndex32:$lane)>;
4859}
4860
4861defm VUDOTDI : DOTI<"vudot", "u8", 0b0, 0b1, DPR, v2i32, v8i8,
4862                    int_arm_neon_udot, (v2i32 DPR_VFP2:$Vm)>;
4863defm VSDOTDI : DOTI<"vsdot", "s8", 0b0, 0b0, DPR, v2i32, v8i8,
4864                    int_arm_neon_sdot, (v2i32 DPR_VFP2:$Vm)>;
4865defm VUDOTQI : DOTI<"vudot", "u8", 0b1, 0b1, QPR, v4i32, v16i8,
4866                    int_arm_neon_udot, (EXTRACT_SUBREG QPR:$Vm, dsub_0)>;
4867defm VSDOTQI : DOTI<"vsdot", "s8", 0b1, 0b0, QPR, v4i32, v16i8,
4868                    int_arm_neon_sdot, (EXTRACT_SUBREG QPR:$Vm, dsub_0)>;
4869
4870// v8.6A matrix multiplication extension
4871let Predicates = [HasMatMulInt8] in {
4872  class N3VMatMul<bit B, bit U, string Asm, string AsmTy,
4873                  SDPatternOperator OpNode>
4874        : N3Vnp<{0b1100, B}, 0b10, 0b1100, 1, U, (outs QPR:$dst),
4875                (ins QPR:$Vd, QPR:$Vn, QPR:$Vm), N3RegFrm, NoItinerary,
4876                Asm, AsmTy,
4877                [(set (v4i32 QPR:$dst), (OpNode (v4i32 QPR:$Vd),
4878                                                (v16i8 QPR:$Vn),
4879                                                (v16i8 QPR:$Vm)))]> {
4880    let DecoderNamespace = "VFPV8";
4881    let Constraints = "$dst = $Vd";
4882  }
4883
4884  multiclass N3VMixedDotLane<bit Q, bit U, string Asm, string AsmTy, RegisterClass RegTy,
4885                        ValueType AccumTy, ValueType InputTy, SDPatternOperator OpNode,
4886                        dag RHS> {
4887
4888    def "" : N3Vnp<0b11101, 0b00, 0b1101, Q, U, (outs RegTy:$dst),
4889                (ins RegTy:$Vd, RegTy:$Vn, DPR_VFP2:$Vm, VectorIndex32:$lane), N3RegFrm,
4890                 NoItinerary, Asm, AsmTy, []> {
4891      bit lane;
4892      let Inst{5} = lane;
4893      let AsmString = !strconcat(Asm, ".", AsmTy, "\t$Vd, $Vn, $Vm$lane");
4894      let DecoderNamespace = "VFPV8";
4895      let Constraints = "$dst = $Vd";
4896    }
4897
4898    def : Pat<
4899      (AccumTy (OpNode (AccumTy RegTy:$Vd),
4900                       (InputTy RegTy:$Vn),
4901                       (InputTy (bitconvert (AccumTy
4902                                (ARMvduplane (AccumTy RegTy:$Vm),
4903                                              VectorIndex32:$lane)))))),
4904      (!cast<Instruction>(NAME) RegTy:$Vd, RegTy:$Vn, RHS, VectorIndex32:$lane)>;
4905
4906  }
4907
4908  multiclass SUDOTLane<bit Q, RegisterClass RegTy, ValueType AccumTy, ValueType InputTy, dag RHS>
4909        : N3VMixedDotLane<Q, 1, "vsudot", "u8", RegTy, AccumTy, InputTy, null_frag, null_frag> {
4910    def : Pat<
4911      (AccumTy (int_arm_neon_usdot (AccumTy RegTy:$Vd),
4912                                   (InputTy (bitconvert (AccumTy
4913                                            (ARMvduplane (AccumTy RegTy:$Vm),
4914                                                          VectorIndex32:$lane)))),
4915                                   (InputTy RegTy:$Vn))),
4916      (!cast<Instruction>(NAME) RegTy:$Vd, RegTy:$Vn, RHS, VectorIndex32:$lane)>;
4917  }
4918
4919  def VSMMLA  : N3VMatMul<0, 0, "vsmmla",  "s8", int_arm_neon_smmla>;
4920  def VUMMLA  : N3VMatMul<0, 1, "vummla",  "u8", int_arm_neon_ummla>;
4921  def VUSMMLA : N3VMatMul<1, 0, "vusmmla", "s8", int_arm_neon_usmmla>;
4922  def VUSDOTD : VDOT<0, 0, 1, DPR, "vusdot", "s8", v2i32, v8i8,  int_arm_neon_usdot>;
4923  def VUSDOTQ : VDOT<1, 0, 1, QPR, "vusdot", "s8", v4i32, v16i8, int_arm_neon_usdot>;
4924
4925  defm VUSDOTDI : N3VMixedDotLane<0, 0, "vusdot", "s8", DPR, v2i32, v8i8,
4926                                  int_arm_neon_usdot, (v2i32 DPR_VFP2:$Vm)>;
4927  defm VUSDOTQI : N3VMixedDotLane<1, 0, "vusdot", "s8", QPR, v4i32, v16i8,
4928                                  int_arm_neon_usdot, (EXTRACT_SUBREG QPR:$Vm, dsub_0)>;
4929  defm VSUDOTDI : SUDOTLane<0, DPR, v2i32, v8i8, (v2i32 DPR_VFP2:$Vm)>;
4930  defm VSUDOTQI : SUDOTLane<1, QPR, v4i32, v16i8, (EXTRACT_SUBREG QPR:$Vm, dsub_0)>;
4931}
4932
4933// ARMv8.3 complex operations
4934class BaseN3VCP8ComplexTied<bit op21, bit op4, bit s, bit q,
4935                            InstrItinClass itin, dag oops, dag iops,
4936                            string opc, string dt, list<dag> pattern>
4937  : N3VCP8<{?,?}, {op21,s}, q, op4, oops,
4938           iops, itin, opc, dt, "$Vd, $Vn, $Vm, $rot", "$src1 = $Vd", pattern>{
4939  bits<2> rot;
4940  let Inst{24-23} = rot;
4941}
4942
4943class BaseN3VCP8ComplexOdd<bit op23, bit op21, bit op4, bit s, bit q,
4944                           InstrItinClass itin, dag oops, dag iops, string opc,
4945                            string dt, list<dag> pattern>
4946  : N3VCP8<{?,op23}, {op21,s}, q, op4, oops,
4947           iops, itin, opc, dt, "$Vd, $Vn, $Vm, $rot", "", pattern> {
4948  bits<1> rot;
4949  let Inst{24} = rot;
4950}
4951
4952class BaseN3VCP8ComplexTiedLane32<bit op4, bit s, bit q, InstrItinClass itin,
4953                                  dag oops, dag iops, string opc, string dt,
4954                                  list<dag> pattern>
4955  : N3VLaneCP8<s, {?,?}, q, op4, oops, iops, itin, opc, dt,
4956               "$Vd, $Vn, $Vm$lane, $rot", "$src1 = $Vd", pattern> {
4957  bits<2> rot;
4958  bit lane;
4959
4960  let Inst{21-20} = rot;
4961  let Inst{5} = lane;
4962}
4963
4964class BaseN3VCP8ComplexTiedLane64<bit op4, bit s, bit q, InstrItinClass itin,
4965                            dag oops, dag iops, string opc, string dt,
4966                            list<dag> pattern>
4967  : N3VLaneCP8<s, {?,?}, q, op4, oops, iops, itin, opc, dt,
4968               "$Vd, $Vn, $Vm$lane, $rot", "$src1 = $Vd", pattern> {
4969  bits<2> rot;
4970  bit lane;
4971
4972  let Inst{21-20} = rot;
4973  let Inst{5} = Vm{4};
4974  // This is needed because the lane operand does not have any bits in the
4975  // encoding (it only has one possible value), so we need to manually set it
4976  // to it's default value.
4977  let DecoderMethod = "DecodeNEONComplexLane64Instruction";
4978}
4979
4980multiclass N3VCP8ComplexTied<bit op21, bit op4,
4981                       string OpcodeStr> {
4982  let Predicates = [HasNEON,HasV8_3a,HasFullFP16] in {
4983  def v4f16 : BaseN3VCP8ComplexTied<op21, op4, 0, 0, IIC_VMACD, (outs DPR:$Vd),
4984              (ins DPR:$src1, DPR:$Vn, DPR:$Vm, complexrotateop:$rot),
4985              OpcodeStr, "f16", []>;
4986  def v8f16 : BaseN3VCP8ComplexTied<op21, op4, 0, 1, IIC_VMACQ, (outs QPR:$Vd),
4987              (ins QPR:$src1, QPR:$Vn, QPR:$Vm, complexrotateop:$rot),
4988              OpcodeStr, "f16", []>;
4989  }
4990  let Predicates = [HasNEON,HasV8_3a] in {
4991  def v2f32 : BaseN3VCP8ComplexTied<op21, op4, 1, 0, IIC_VMACD, (outs DPR:$Vd),
4992              (ins DPR:$src1, DPR:$Vn, DPR:$Vm, complexrotateop:$rot),
4993              OpcodeStr, "f32", []>;
4994  def v4f32 : BaseN3VCP8ComplexTied<op21, op4, 1, 1, IIC_VMACQ, (outs QPR:$Vd),
4995              (ins QPR:$src1, QPR:$Vn, QPR:$Vm, complexrotateop:$rot),
4996              OpcodeStr, "f32", []>;
4997  }
4998}
4999
5000multiclass N3VCP8ComplexOdd<bit op23, bit op21, bit op4,
5001                       string OpcodeStr> {
5002  let Predicates = [HasNEON,HasV8_3a,HasFullFP16] in {
5003  def v4f16 : BaseN3VCP8ComplexOdd<op23, op21, op4, 0, 0, IIC_VMACD,
5004              (outs DPR:$Vd),
5005              (ins DPR:$Vn, DPR:$Vm, complexrotateopodd:$rot),
5006              OpcodeStr, "f16", []>;
5007  def v8f16 : BaseN3VCP8ComplexOdd<op23, op21, op4, 0, 1, IIC_VMACQ,
5008              (outs QPR:$Vd),
5009              (ins QPR:$Vn, QPR:$Vm, complexrotateopodd:$rot),
5010              OpcodeStr, "f16", []>;
5011  }
5012  let Predicates = [HasNEON,HasV8_3a] in {
5013  def v2f32 : BaseN3VCP8ComplexOdd<op23, op21, op4, 1, 0, IIC_VMACD,
5014              (outs DPR:$Vd),
5015              (ins DPR:$Vn, DPR:$Vm, complexrotateopodd:$rot),
5016              OpcodeStr, "f32", []>;
5017  def v4f32 : BaseN3VCP8ComplexOdd<op23, op21, op4, 1, 1, IIC_VMACQ,
5018              (outs QPR:$Vd),
5019              (ins QPR:$Vn, QPR:$Vm, complexrotateopodd:$rot),
5020              OpcodeStr, "f32", []>;
5021  }
5022}
5023
5024// These instructions index by pairs of lanes, so the VectorIndexes are twice
5025// as wide as the data types.
5026multiclass N3VCP8ComplexTiedLane<bit op4, string OpcodeStr> {
5027  let Predicates = [HasNEON,HasV8_3a,HasFullFP16] in {
5028  def v4f16_indexed : BaseN3VCP8ComplexTiedLane32<op4, 0, 0, IIC_VMACD,
5029                      (outs DPR:$Vd),
5030                      (ins DPR:$src1, DPR:$Vn, DPR_VFP2:$Vm,
5031                      VectorIndex32:$lane, complexrotateop:$rot),
5032                      OpcodeStr, "f16", []>;
5033  def v8f16_indexed : BaseN3VCP8ComplexTiedLane32<op4, 0, 1, IIC_VMACQ,
5034                      (outs QPR:$Vd),
5035                      (ins QPR:$src1, QPR:$Vn, DPR_VFP2:$Vm,
5036                      VectorIndex32:$lane, complexrotateop:$rot),
5037                      OpcodeStr, "f16", []>;
5038  }
5039  let Predicates = [HasNEON,HasV8_3a] in {
5040  def v2f32_indexed : BaseN3VCP8ComplexTiedLane64<op4, 1, 0, IIC_VMACD,
5041                      (outs DPR:$Vd),
5042                      (ins DPR:$src1, DPR:$Vn, DPR:$Vm, VectorIndex64:$lane,
5043                      complexrotateop:$rot),
5044                      OpcodeStr, "f32", []>;
5045  def v4f32_indexed : BaseN3VCP8ComplexTiedLane64<op4, 1, 1, IIC_VMACQ,
5046                      (outs QPR:$Vd),
5047                      (ins QPR:$src1, QPR:$Vn, DPR:$Vm, VectorIndex64:$lane,
5048                      complexrotateop:$rot),
5049                      OpcodeStr, "f32", []>;
5050  }
5051}
5052
5053defm VCMLA : N3VCP8ComplexTied<1, 0, "vcmla">;
5054defm VCADD : N3VCP8ComplexOdd<1, 0, 0, "vcadd">;
5055defm VCMLA : N3VCP8ComplexTiedLane<0, "vcmla">;
5056
5057let Predicates = [HasNEON,HasV8_3a,HasFullFP16] in {
5058  def : Pat<(v4f16 (int_arm_neon_vcadd_rot90 (v4f16 DPR:$Rn), (v4f16 DPR:$Rm))),
5059            (VCADDv4f16 (v4f16 DPR:$Rn), (v4f16 DPR:$Rm), (i32 0))>;
5060  def : Pat<(v4f16 (int_arm_neon_vcadd_rot270 (v4f16 DPR:$Rn), (v4f16 DPR:$Rm))),
5061            (VCADDv4f16 (v4f16 DPR:$Rn), (v4f16 DPR:$Rm), (i32 1))>;
5062  def : Pat<(v8f16 (int_arm_neon_vcadd_rot90 (v8f16 QPR:$Rn), (v8f16 QPR:$Rm))),
5063            (VCADDv8f16 (v8f16 QPR:$Rn), (v8f16 QPR:$Rm), (i32 0))>;
5064  def : Pat<(v8f16 (int_arm_neon_vcadd_rot270 (v8f16 QPR:$Rn), (v8f16 QPR:$Rm))),
5065            (VCADDv8f16 (v8f16 QPR:$Rn), (v8f16 QPR:$Rm), (i32 1))>;
5066}
5067let Predicates = [HasNEON,HasV8_3a] in {
5068  def : Pat<(v2f32 (int_arm_neon_vcadd_rot90 (v2f32 DPR:$Rn), (v2f32 DPR:$Rm))),
5069            (VCADDv2f32 (v2f32 DPR:$Rn), (v2f32 DPR:$Rm), (i32 0))>;
5070  def : Pat<(v2f32 (int_arm_neon_vcadd_rot270 (v2f32 DPR:$Rn), (v2f32 DPR:$Rm))),
5071            (VCADDv2f32 (v2f32 DPR:$Rn), (v2f32 DPR:$Rm), (i32 1))>;
5072  def : Pat<(v4f32 (int_arm_neon_vcadd_rot90 (v4f32 QPR:$Rn), (v4f32 QPR:$Rm))),
5073            (VCADDv4f32 (v4f32 QPR:$Rn), (v4f32 QPR:$Rm), (i32 0))>;
5074  def : Pat<(v4f32 (int_arm_neon_vcadd_rot270 (v4f32 QPR:$Rn), (v4f32 QPR:$Rm))),
5075            (VCADDv4f32 (v4f32 QPR:$Rn), (v4f32 QPR:$Rm), (i32 1))>;
5076}
5077
5078// Vector Subtract Operations.
5079
5080//   VSUB     : Vector Subtract (integer and floating-point)
5081defm VSUB     : N3V_QHSD<1, 0, 0b1000, 0, IIC_VSUBiD, IIC_VSUBiQ,
5082                         "vsub", "i", sub, 0>;
5083def  VSUBfd   : N3VD<0, 0, 0b10, 0b1101, 0, IIC_VBIND, "vsub", "f32",
5084                     v2f32, v2f32, fsub, 0>;
5085def  VSUBfq   : N3VQ<0, 0, 0b10, 0b1101, 0, IIC_VBINQ, "vsub", "f32",
5086                     v4f32, v4f32, fsub, 0>;
5087def  VSUBhd   : N3VD<0, 0, 0b11, 0b1101, 0, IIC_VBIND, "vsub", "f16",
5088                     v4f16, v4f16, fsub, 0>,
5089                Requires<[HasNEON,HasFullFP16]>;
5090def  VSUBhq   : N3VQ<0, 0, 0b11, 0b1101, 0, IIC_VBINQ, "vsub", "f16",
5091                     v8f16, v8f16, fsub, 0>,
5092                Requires<[HasNEON,HasFullFP16]>;
5093//   VSUBL    : Vector Subtract Long (Q = D - D)
5094defm VSUBLs   : N3VLExt_QHS<0,1,0b0010,0, IIC_VSHLiD, IIC_VSHLiD,
5095                            "vsubl", "s", sub, sext, 0>;
5096defm VSUBLu   : N3VLExt_QHS<1,1,0b0010,0, IIC_VSHLiD, IIC_VSHLiD,
5097                            "vsubl", "u", sub, zanyext, 0>;
5098//   VSUBW    : Vector Subtract Wide (Q = Q - D)
5099defm VSUBWs   : N3VW_QHS<0,1,0b0011,0, "vsubw", "s", sub, sext, 0>;
5100defm VSUBWu   : N3VW_QHS<1,1,0b0011,0, "vsubw", "u", sub, zanyext, 0>;
5101//   VHSUB    : Vector Halving Subtract
5102defm VHSUBs   : N3VInt_QHS<0, 0, 0b0010, 0, N3RegFrm,
5103                           IIC_VSUBi4D, IIC_VSUBi4D, IIC_VSUBi4Q, IIC_VSUBi4Q,
5104                           "vhsub", "s", int_arm_neon_vhsubs, 0>;
5105defm VHSUBu   : N3VInt_QHS<1, 0, 0b0010, 0, N3RegFrm,
5106                           IIC_VSUBi4D, IIC_VSUBi4D, IIC_VSUBi4Q, IIC_VSUBi4Q,
5107                           "vhsub", "u", int_arm_neon_vhsubu, 0>;
5108//   VQSUB    : Vector Saturing Subtract
5109defm VQSUBs   : N3VInt_QHSD<0, 0, 0b0010, 1, N3RegFrm,
5110                            IIC_VSUBi4D, IIC_VSUBi4D, IIC_VSUBi4Q, IIC_VSUBi4Q,
5111                            "vqsub", "s", ssubsat, 0>;
5112defm VQSUBu   : N3VInt_QHSD<1, 0, 0b0010, 1, N3RegFrm,
5113                            IIC_VSUBi4D, IIC_VSUBi4D, IIC_VSUBi4Q, IIC_VSUBi4Q,
5114                            "vqsub", "u", usubsat, 0>;
5115//   VSUBHN   : Vector Subtract and Narrow Returning High Half (D = Q - Q)
5116defm VSUBHN   : N3VNInt_HSD<0,1,0b0110,0, "vsubhn", "i", null_frag, 0>;
5117//   VRSUBHN  : Vector Rounding Subtract and Narrow Returning High Half (D=Q-Q)
5118defm VRSUBHN  : N3VNInt_HSD<1,1,0b0110,0, "vrsubhn", "i",
5119                            int_arm_neon_vrsubhn, 0>;
5120
5121let Predicates = [HasNEON] in {
5122def : Pat<(v8i8  (trunc (ARMvshruImm (sub (v8i16 QPR:$Vn), QPR:$Vm), 8))),
5123          (VSUBHNv8i8 QPR:$Vn, QPR:$Vm)>;
5124def : Pat<(v4i16 (trunc (ARMvshruImm (sub (v4i32 QPR:$Vn), QPR:$Vm), 16))),
5125          (VSUBHNv4i16 QPR:$Vn, QPR:$Vm)>;
5126def : Pat<(v2i32 (trunc (ARMvshruImm (sub (v2i64 QPR:$Vn), QPR:$Vm), 32))),
5127          (VSUBHNv2i32 QPR:$Vn, QPR:$Vm)>;
5128}
5129
5130// Vector Comparisons.
5131
5132//   VCEQ     : Vector Compare Equal
5133defm VCEQ     : N3V_QHS_cmp<1, 0, 0b1000, 1, IIC_VSUBi4D, IIC_VSUBi4D, IIC_VSUBi4Q,
5134                            IIC_VSUBi4Q, "vceq", "i", ARMCCeq, 1>;
5135def  VCEQfd   : N3VD_cmp<0,0,0b00,0b1110,0, IIC_VBIND, "vceq", "f32", v2i32, v2f32,
5136                         ARMCCeq, 1>;
5137def  VCEQfq   : N3VQ_cmp<0,0,0b00,0b1110,0, IIC_VBINQ, "vceq", "f32", v4i32, v4f32,
5138                         ARMCCeq, 1>;
5139def  VCEQhd   : N3VD_cmp<0,0,0b01,0b1110,0, IIC_VBIND, "vceq", "f16", v4i16, v4f16,
5140                         ARMCCeq, 1>,
5141                Requires<[HasNEON, HasFullFP16]>;
5142def  VCEQhq   : N3VQ_cmp<0,0,0b01,0b1110,0, IIC_VBINQ, "vceq", "f16", v8i16, v8f16,
5143                         ARMCCeq, 1>,
5144                Requires<[HasNEON, HasFullFP16]>;
5145
5146let TwoOperandAliasConstraint = "$Vm = $Vd" in
5147defm VCEQz    : N2V_QHS_cmp<0b11, 0b11, 0b01, 0b00010, 0, "vceq", "i",
5148                            "$Vd, $Vm, #0", ARMCCeq>;
5149
5150//   VCGE     : Vector Compare Greater Than or Equal
5151defm VCGEs    : N3V_QHS_cmp<0, 0, 0b0011, 1, IIC_VSUBi4D, IIC_VSUBi4D, IIC_VSUBi4Q,
5152                            IIC_VSUBi4Q, "vcge", "s", ARMCCge, 0>;
5153defm VCGEu    : N3V_QHS_cmp<1, 0, 0b0011, 1, IIC_VSUBi4D, IIC_VSUBi4D, IIC_VSUBi4Q,
5154                            IIC_VSUBi4Q, "vcge", "u", ARMCChs, 0>;
5155def  VCGEfd   : N3VD_cmp<1,0,0b00,0b1110,0, IIC_VBIND, "vcge", "f32", v2i32, v2f32,
5156                         ARMCCge, 0>;
5157def  VCGEfq   : N3VQ_cmp<1,0,0b00,0b1110,0, IIC_VBINQ, "vcge", "f32", v4i32, v4f32,
5158                         ARMCCge, 0>;
5159def  VCGEhd   : N3VD_cmp<1,0,0b01,0b1110,0, IIC_VBIND, "vcge", "f16", v4i16, v4f16,
5160                         ARMCCge, 0>,
5161                Requires<[HasNEON, HasFullFP16]>;
5162def  VCGEhq   : N3VQ_cmp<1,0,0b01,0b1110,0, IIC_VBINQ, "vcge", "f16", v8i16, v8f16,
5163                         ARMCCge, 0>,
5164                Requires<[HasNEON, HasFullFP16]>;
5165
5166let TwoOperandAliasConstraint = "$Vm = $Vd" in {
5167defm VCGEz    : N2V_QHS_cmp<0b11, 0b11, 0b01, 0b00001, 0, "vcge", "s",
5168                            "$Vd, $Vm, #0", ARMCCge>;
5169defm VCLEz    : N2V_QHS_cmp<0b11, 0b11, 0b01, 0b00011, 0, "vcle", "s",
5170                            "$Vd, $Vm, #0", ARMCCle>;
5171}
5172
5173//   VCGT     : Vector Compare Greater Than
5174defm VCGTs    : N3V_QHS_cmp<0, 0, 0b0011, 0, IIC_VSUBi4D, IIC_VSUBi4D, IIC_VSUBi4Q,
5175                            IIC_VSUBi4Q, "vcgt", "s", ARMCCgt, 0>;
5176defm VCGTu    : N3V_QHS_cmp<1, 0, 0b0011, 0, IIC_VSUBi4D, IIC_VSUBi4D, IIC_VSUBi4Q,
5177                            IIC_VSUBi4Q, "vcgt", "u", ARMCChi, 0>;
5178def  VCGTfd   : N3VD_cmp<1,0,0b10,0b1110,0, IIC_VBIND, "vcgt", "f32", v2i32, v2f32,
5179                         ARMCCgt, 0>;
5180def  VCGTfq   : N3VQ_cmp<1,0,0b10,0b1110,0, IIC_VBINQ, "vcgt", "f32", v4i32, v4f32,
5181                         ARMCCgt, 0>;
5182def  VCGThd   : N3VD_cmp<1,0,0b11,0b1110,0, IIC_VBIND, "vcgt", "f16", v4i16, v4f16,
5183                         ARMCCgt, 0>,
5184                Requires<[HasNEON, HasFullFP16]>;
5185def  VCGThq   : N3VQ_cmp<1,0,0b11,0b1110,0, IIC_VBINQ, "vcgt", "f16", v8i16, v8f16,
5186                         ARMCCgt, 0>,
5187                Requires<[HasNEON, HasFullFP16]>;
5188
5189let TwoOperandAliasConstraint = "$Vm = $Vd" in {
5190defm VCGTz    : N2V_QHS_cmp<0b11, 0b11, 0b01, 0b00000, 0, "vcgt", "s",
5191                            "$Vd, $Vm, #0", ARMCCgt>;
5192defm VCLTz    : N2V_QHS_cmp<0b11, 0b11, 0b01, 0b00100, 0, "vclt", "s",
5193                            "$Vd, $Vm, #0", ARMCClt>;
5194}
5195
5196//   VACGE    : Vector Absolute Compare Greater Than or Equal (aka VCAGE)
5197def  VACGEfd   : N3VDInt<1, 0, 0b00, 0b1110, 1, N3RegFrm, IIC_VBIND, "vacge",
5198                        "f32", v2i32, v2f32, int_arm_neon_vacge, 0>;
5199def  VACGEfq   : N3VQInt<1, 0, 0b00, 0b1110, 1, N3RegFrm, IIC_VBINQ, "vacge",
5200                        "f32", v4i32, v4f32, int_arm_neon_vacge, 0>;
5201def  VACGEhd   : N3VDInt<1, 0, 0b01, 0b1110, 1, N3RegFrm, IIC_VBIND, "vacge",
5202                        "f16", v4i16, v4f16, int_arm_neon_vacge, 0>,
5203                 Requires<[HasNEON, HasFullFP16]>;
5204def  VACGEhq   : N3VQInt<1, 0, 0b01, 0b1110, 1, N3RegFrm, IIC_VBINQ, "vacge",
5205                        "f16", v8i16, v8f16, int_arm_neon_vacge, 0>,
5206                 Requires<[HasNEON, HasFullFP16]>;
5207//   VACGT    : Vector Absolute Compare Greater Than (aka VCAGT)
5208def  VACGTfd   : N3VDInt<1, 0, 0b10, 0b1110, 1, N3RegFrm, IIC_VBIND, "vacgt",
5209                        "f32", v2i32, v2f32, int_arm_neon_vacgt, 0>;
5210def  VACGTfq   : N3VQInt<1, 0, 0b10, 0b1110, 1, N3RegFrm, IIC_VBINQ, "vacgt",
5211                        "f32", v4i32, v4f32, int_arm_neon_vacgt, 0>;
5212def  VACGThd   : N3VDInt<1, 0, 0b11, 0b1110, 1, N3RegFrm, IIC_VBIND, "vacgt",
5213                        "f16", v4i16, v4f16, int_arm_neon_vacgt, 0>,
5214                 Requires<[HasNEON, HasFullFP16]>;
5215def  VACGThq   : N3VQInt<1, 0, 0b11, 0b1110, 1, N3RegFrm, IIC_VBINQ, "vacgt",
5216                        "f16", v8i16, v8f16, int_arm_neon_vacgt, 0>,
5217                 Requires<[HasNEON, HasFullFP16]>;
5218//   VTST     : Vector Test Bits
5219defm VTST     : N3V_QHS<0, 0, 0b1000, 1, IIC_VBINi4D, IIC_VBINi4D, IIC_VBINi4Q,
5220                        IIC_VBINi4Q, "vtst", "", NEONvtst, 1>;
5221
5222def: NEONInstAlias<"vaclt${p}.f32 $Vd, $Vn, $Vm",
5223                   (VACGTfd DPR:$Vd, DPR:$Vm, DPR:$Vn, pred:$p)>;
5224def: NEONInstAlias<"vaclt${p}.f32 $Vd, $Vn, $Vm",
5225                   (VACGTfq QPR:$Vd, QPR:$Vm, QPR:$Vn, pred:$p)>;
5226def: NEONInstAlias<"vacle${p}.f32 $Vd, $Vn, $Vm",
5227                   (VACGEfd DPR:$Vd, DPR:$Vm, DPR:$Vn, pred:$p)>;
5228def: NEONInstAlias<"vacle${p}.f32 $Vd, $Vn, $Vm",
5229                   (VACGEfq QPR:$Vd, QPR:$Vm, QPR:$Vn, pred:$p)>;
5230let Predicates = [HasNEON, HasFullFP16] in {
5231def: NEONInstAlias<"vaclt${p}.f16 $Vd, $Vn, $Vm",
5232                   (VACGThd DPR:$Vd, DPR:$Vm, DPR:$Vn, pred:$p)>;
5233def: NEONInstAlias<"vaclt${p}.f16 $Vd, $Vn, $Vm",
5234                   (VACGThq QPR:$Vd, QPR:$Vm, QPR:$Vn, pred:$p)>;
5235def: NEONInstAlias<"vacle${p}.f16 $Vd, $Vn, $Vm",
5236                   (VACGEhd DPR:$Vd, DPR:$Vm, DPR:$Vn, pred:$p)>;
5237def: NEONInstAlias<"vacle${p}.f16 $Vd, $Vn, $Vm",
5238                   (VACGEhq QPR:$Vd, QPR:$Vm, QPR:$Vn, pred:$p)>;
5239}
5240
5241// +fp16fml Floating Point Multiplication Variants
5242let Predicates = [HasNEON, HasFP16FML], DecoderNamespace= "VFPV8" in {
5243
5244class N3VCP8F16Q1<string asm, RegisterClass Td, RegisterClass Tn,
5245                RegisterClass Tm, bits<2> op1, bits<2> op2, bit op3>
5246  : N3VCP8<op1, op2, 1, op3, (outs Td:$Vd), (ins Tn:$Vn, Tm:$Vm), NoItinerary,
5247           asm, "f16", "$Vd, $Vn, $Vm", "", []>;
5248
5249class N3VCP8F16Q0<string asm, RegisterClass Td, RegisterClass Tn,
5250                RegisterClass Tm, bits<2> op1, bits<2> op2, bit op3>
5251  : N3VCP8Q0<op1, op2, 0, op3, (outs Td:$Vd), (ins Tn:$Vn, Tm:$Vm), NoItinerary,
5252           asm, "f16", "$Vd, $Vn, $Vm", "", []>;
5253
5254// Vd, Vs, Vs[0-15], Idx[0-1]
5255class VFMD<string opc, string type, bits<2> S>
5256  : N3VLaneCP8<0, S, 0, 1, (outs DPR:$Vd),
5257               (ins SPR:$Vn, SPR_8:$Vm, VectorIndex32:$idx),
5258               IIC_VMACD, opc, type, "$Vd, $Vn, $Vm$idx", "", []> {
5259  bit idx;
5260  let Inst{3} = idx;
5261  let Inst{19-16} = Vn{4-1};
5262  let Inst{7}     = Vn{0};
5263  let Inst{5}     = Vm{0};
5264  let Inst{2-0}   = Vm{3-1};
5265}
5266
5267// Vq, Vd, Vd[0-7], Idx[0-3]
5268class VFMQ<string opc, string type, bits<2> S>
5269  : N3VLaneCP8<0, S, 1, 1, (outs QPR:$Vd),
5270               (ins DPR:$Vn, DPR_8:$Vm, VectorIndex16:$idx),
5271               IIC_VMACD, opc, type, "$Vd, $Vn, $Vm$idx", "", []> {
5272  bits<2> idx;
5273  let Inst{5} = idx{1};
5274  let Inst{3} = idx{0};
5275}
5276
5277//                                                op1   op2   op3
5278def VFMALD  : N3VCP8F16Q0<"vfmal", DPR, SPR, SPR, 0b00, 0b10, 1>;
5279def VFMSLD  : N3VCP8F16Q0<"vfmsl", DPR, SPR, SPR, 0b01, 0b10, 1>;
5280def VFMALQ  : N3VCP8F16Q1<"vfmal", QPR, DPR, DPR, 0b00, 0b10, 1>;
5281def VFMSLQ  : N3VCP8F16Q1<"vfmsl", QPR, DPR, DPR, 0b01, 0b10, 1>;
5282def VFMALDI : VFMD<"vfmal", "f16", 0b00>;
5283def VFMSLDI : VFMD<"vfmsl", "f16", 0b01>;
5284def VFMALQI : VFMQ<"vfmal", "f16", 0b00>;
5285def VFMSLQI : VFMQ<"vfmsl", "f16", 0b01>;
5286} // HasNEON, HasFP16FML
5287
5288
5289def: NEONInstAlias<"vaclt${p}.f32 $Vd, $Vm",
5290                   (VACGTfd DPR:$Vd, DPR:$Vm, DPR:$Vd, pred:$p)>;
5291def: NEONInstAlias<"vaclt${p}.f32 $Vd, $Vm",
5292                   (VACGTfq QPR:$Vd, QPR:$Vm, QPR:$Vd, pred:$p)>;
5293def: NEONInstAlias<"vacle${p}.f32 $Vd, $Vm",
5294                   (VACGEfd DPR:$Vd, DPR:$Vm, DPR:$Vd, pred:$p)>;
5295def: NEONInstAlias<"vacle${p}.f32 $Vd, $Vm",
5296                   (VACGEfq QPR:$Vd, QPR:$Vm, QPR:$Vd, pred:$p)>;
5297let Predicates = [HasNEON, HasFullFP16] in {
5298def: NEONInstAlias<"vaclt${p}.f16 $Vd, $Vm",
5299                   (VACGThd DPR:$Vd, DPR:$Vm, DPR:$Vd, pred:$p)>;
5300def: NEONInstAlias<"vaclt${p}.f16 $Vd, $Vm",
5301                   (VACGThq QPR:$Vd, QPR:$Vm, QPR:$Vd, pred:$p)>;
5302def: NEONInstAlias<"vacle${p}.f16 $Vd, $Vm",
5303                   (VACGEhd DPR:$Vd, DPR:$Vm, DPR:$Vd, pred:$p)>;
5304def: NEONInstAlias<"vacle${p}.f16 $Vd, $Vm",
5305                   (VACGEhq QPR:$Vd, QPR:$Vm, QPR:$Vd, pred:$p)>;
5306}
5307
5308// Vector Bitwise Operations.
5309
5310def vnotd : PatFrag<(ops node:$in),
5311                    (xor node:$in, ARMimmAllOnesD)>;
5312def vnotq : PatFrag<(ops node:$in),
5313                    (xor node:$in, ARMimmAllOnesV)>;
5314
5315
5316//   VAND     : Vector Bitwise AND
5317def  VANDd    : N3VDX<0, 0, 0b00, 0b0001, 1, IIC_VBINiD, "vand",
5318                      v2i32, v2i32, and, 1>;
5319def  VANDq    : N3VQX<0, 0, 0b00, 0b0001, 1, IIC_VBINiQ, "vand",
5320                      v4i32, v4i32, and, 1>;
5321
5322//   VEOR     : Vector Bitwise Exclusive OR
5323def  VEORd    : N3VDX<1, 0, 0b00, 0b0001, 1, IIC_VBINiD, "veor",
5324                      v2i32, v2i32, xor, 1>;
5325def  VEORq    : N3VQX<1, 0, 0b00, 0b0001, 1, IIC_VBINiQ, "veor",
5326                      v4i32, v4i32, xor, 1>;
5327
5328//   VORR     : Vector Bitwise OR
5329def  VORRd    : N3VDX<0, 0, 0b10, 0b0001, 1, IIC_VBINiD, "vorr",
5330                      v2i32, v2i32, or, 1>;
5331def  VORRq    : N3VQX<0, 0, 0b10, 0b0001, 1, IIC_VBINiQ, "vorr",
5332                      v4i32, v4i32, or, 1>;
5333
5334multiclass BitwisePatterns<string Name, SDPatternOperator OpNodeD,
5335                           SDPatternOperator OpNodeQ> {
5336  def : Pat<(v8i8 (OpNodeD DPR:$LHS, DPR:$RHS)),
5337            (!cast<Instruction>(Name#"d") DPR:$LHS, DPR:$RHS)>;
5338  def : Pat<(v4i16 (OpNodeD DPR:$LHS, DPR:$RHS)),
5339            (!cast<Instruction>(Name#"d") DPR:$LHS, DPR:$RHS)>;
5340  def : Pat<(v1i64 (OpNodeD DPR:$LHS, DPR:$RHS)),
5341            (!cast<Instruction>(Name#"d") DPR:$LHS, DPR:$RHS)>;
5342
5343  def : Pat<(v16i8 (OpNodeQ QPR:$LHS, QPR:$RHS)),
5344            (!cast<Instruction>(Name#"q") QPR:$LHS, QPR:$RHS)>;
5345  def : Pat<(v8i16 (OpNodeQ QPR:$LHS, QPR:$RHS)),
5346            (!cast<Instruction>(Name#"q") QPR:$LHS, QPR:$RHS)>;
5347  def : Pat<(v2i64 (OpNodeQ QPR:$LHS, QPR:$RHS)),
5348            (!cast<Instruction>(Name#"q") QPR:$LHS, QPR:$RHS)>;
5349}
5350
5351let Predicates = [HasNEON] in {
5352  defm : BitwisePatterns<"VAND", and, and>;
5353  defm : BitwisePatterns<"VORR", or, or>;
5354  defm : BitwisePatterns<"VEOR", xor, xor>;
5355}
5356
5357def VORRiv4i16 : N1ModImm<1, 0b000, {1,0,?,1}, 0, 0, 0, 1,
5358                          (outs DPR:$Vd), (ins nImmSplatI16:$SIMM, DPR:$src),
5359                          IIC_VMOVImm,
5360                          "vorr", "i16", "$Vd, $SIMM", "$src = $Vd",
5361                          [(set DPR:$Vd,
5362                            (v4i16 (ARMvorrImm DPR:$src, timm:$SIMM)))]> {
5363  let Inst{9} = SIMM{9};
5364}
5365
5366def VORRiv2i32 : N1ModImm<1, 0b000, {0,?,?,1}, 0, 0, 0, 1,
5367                          (outs DPR:$Vd), (ins nImmSplatI32:$SIMM, DPR:$src),
5368                          IIC_VMOVImm,
5369                          "vorr", "i32", "$Vd, $SIMM", "$src = $Vd",
5370                          [(set DPR:$Vd,
5371                            (v2i32 (ARMvorrImm DPR:$src, timm:$SIMM)))]> {
5372  let Inst{10-9} = SIMM{10-9};
5373}
5374
5375def VORRiv8i16 : N1ModImm<1, 0b000, {1,0,?,1}, 0, 1, 0, 1,
5376                          (outs QPR:$Vd), (ins nImmSplatI16:$SIMM, QPR:$src),
5377                          IIC_VMOVImm,
5378                          "vorr", "i16", "$Vd, $SIMM", "$src = $Vd",
5379                          [(set QPR:$Vd,
5380                            (v8i16 (ARMvorrImm QPR:$src, timm:$SIMM)))]> {
5381  let Inst{9} = SIMM{9};
5382}
5383
5384def VORRiv4i32 : N1ModImm<1, 0b000, {0,?,?,1}, 0, 1, 0, 1,
5385                          (outs QPR:$Vd), (ins nImmSplatI32:$SIMM, QPR:$src),
5386                          IIC_VMOVImm,
5387                          "vorr", "i32", "$Vd, $SIMM", "$src = $Vd",
5388                          [(set QPR:$Vd,
5389                            (v4i32 (ARMvorrImm QPR:$src, timm:$SIMM)))]> {
5390  let Inst{10-9} = SIMM{10-9};
5391}
5392
5393
5394//   VBIC     : Vector Bitwise Bit Clear (AND NOT)
5395let TwoOperandAliasConstraint = "$Vn = $Vd" in {
5396def  VBICd    : N3VX<0, 0, 0b01, 0b0001, 0, 1, (outs DPR:$Vd),
5397                     (ins DPR:$Vn, DPR:$Vm), N3RegFrm, IIC_VBINiD,
5398                     "vbic", "$Vd, $Vn, $Vm", "",
5399                     [(set DPR:$Vd, (v2i32 (and DPR:$Vn,
5400                                                 (vnotd DPR:$Vm))))]>;
5401def  VBICq    : N3VX<0, 0, 0b01, 0b0001, 1, 1, (outs QPR:$Vd),
5402                     (ins QPR:$Vn, QPR:$Vm), N3RegFrm, IIC_VBINiQ,
5403                     "vbic", "$Vd, $Vn, $Vm", "",
5404                     [(set QPR:$Vd, (v4i32 (and QPR:$Vn,
5405                                                 (vnotq QPR:$Vm))))]>;
5406}
5407
5408let Predicates = [HasNEON] in {
5409  defm : BitwisePatterns<"VBIC", BinOpFrag<(and node:$LHS, (vnotd node:$RHS))>,
5410                                 BinOpFrag<(and node:$LHS, (vnotq node:$RHS))>>;
5411}
5412
5413def VBICiv4i16 : N1ModImm<1, 0b000, {1,0,?,1}, 0, 0, 1, 1,
5414                          (outs DPR:$Vd), (ins nImmSplatI16:$SIMM, DPR:$src),
5415                          IIC_VMOVImm,
5416                          "vbic", "i16", "$Vd, $SIMM", "$src = $Vd",
5417                          [(set DPR:$Vd,
5418                            (v4i16 (ARMvbicImm DPR:$src, timm:$SIMM)))]> {
5419  let Inst{9} = SIMM{9};
5420}
5421
5422def VBICiv2i32 : N1ModImm<1, 0b000, {0,?,?,1}, 0, 0, 1, 1,
5423                          (outs DPR:$Vd), (ins nImmSplatI32:$SIMM, DPR:$src),
5424                          IIC_VMOVImm,
5425                          "vbic", "i32", "$Vd, $SIMM", "$src = $Vd",
5426                          [(set DPR:$Vd,
5427                            (v2i32 (ARMvbicImm DPR:$src, timm:$SIMM)))]> {
5428  let Inst{10-9} = SIMM{10-9};
5429}
5430
5431def VBICiv8i16 : N1ModImm<1, 0b000, {1,0,?,1}, 0, 1, 1, 1,
5432                          (outs QPR:$Vd), (ins nImmSplatI16:$SIMM, QPR:$src),
5433                          IIC_VMOVImm,
5434                          "vbic", "i16", "$Vd, $SIMM", "$src = $Vd",
5435                          [(set QPR:$Vd,
5436                            (v8i16 (ARMvbicImm QPR:$src, timm:$SIMM)))]> {
5437  let Inst{9} = SIMM{9};
5438}
5439
5440def VBICiv4i32 : N1ModImm<1, 0b000, {0,?,?,1}, 0, 1, 1, 1,
5441                          (outs QPR:$Vd), (ins nImmSplatI32:$SIMM, QPR:$src),
5442                          IIC_VMOVImm,
5443                          "vbic", "i32", "$Vd, $SIMM", "$src = $Vd",
5444                          [(set QPR:$Vd,
5445                            (v4i32 (ARMvbicImm QPR:$src, timm:$SIMM)))]> {
5446  let Inst{10-9} = SIMM{10-9};
5447}
5448
5449//   VORN     : Vector Bitwise OR NOT
5450def  VORNd    : N3VX<0, 0, 0b11, 0b0001, 0, 1, (outs DPR:$Vd),
5451                     (ins DPR:$Vn, DPR:$Vm), N3RegFrm, IIC_VBINiD,
5452                     "vorn", "$Vd, $Vn, $Vm", "",
5453                     [(set DPR:$Vd, (v2i32 (or DPR:$Vn,
5454                                                (vnotd DPR:$Vm))))]>;
5455def  VORNq    : N3VX<0, 0, 0b11, 0b0001, 1, 1, (outs QPR:$Vd),
5456                     (ins QPR:$Vn, QPR:$Vm), N3RegFrm, IIC_VBINiQ,
5457                     "vorn", "$Vd, $Vn, $Vm", "",
5458                     [(set QPR:$Vd, (v4i32 (or QPR:$Vn,
5459                                                (vnotq QPR:$Vm))))]>;
5460
5461let Predicates = [HasNEON] in {
5462  defm : BitwisePatterns<"VORN", BinOpFrag<(or node:$LHS, (vnotd node:$RHS))>,
5463                                 BinOpFrag<(or node:$LHS, (vnotq node:$RHS))>>;
5464}
5465
5466//   VMVN     : Vector Bitwise NOT (Immediate)
5467
5468let isReMaterializable = 1 in {
5469
5470def VMVNv4i16 : N1ModImm<1, 0b000, {1,0,?,0}, 0, 0, 1, 1, (outs DPR:$Vd),
5471                         (ins nImmSplatI16:$SIMM), IIC_VMOVImm,
5472                         "vmvn", "i16", "$Vd, $SIMM", "",
5473                         [(set DPR:$Vd, (v4i16 (ARMvmvnImm timm:$SIMM)))]> {
5474  let Inst{9} = SIMM{9};
5475}
5476
5477def VMVNv8i16 : N1ModImm<1, 0b000, {1,0,?,0}, 0, 1, 1, 1, (outs QPR:$Vd),
5478                         (ins nImmSplatI16:$SIMM), IIC_VMOVImm,
5479                         "vmvn", "i16", "$Vd, $SIMM", "",
5480                         [(set QPR:$Vd, (v8i16 (ARMvmvnImm timm:$SIMM)))]> {
5481  let Inst{9} = SIMM{9};
5482}
5483
5484def VMVNv2i32 : N1ModImm<1, 0b000, {?,?,?,?}, 0, 0, 1, 1, (outs DPR:$Vd),
5485                         (ins nImmVMOVI32:$SIMM), IIC_VMOVImm,
5486                         "vmvn", "i32", "$Vd, $SIMM", "",
5487                         [(set DPR:$Vd, (v2i32 (ARMvmvnImm timm:$SIMM)))]> {
5488  let Inst{11-8} = SIMM{11-8};
5489}
5490
5491def VMVNv4i32 : N1ModImm<1, 0b000, {?,?,?,?}, 0, 1, 1, 1, (outs QPR:$Vd),
5492                         (ins nImmVMOVI32:$SIMM), IIC_VMOVImm,
5493                         "vmvn", "i32", "$Vd, $SIMM", "",
5494                         [(set QPR:$Vd, (v4i32 (ARMvmvnImm timm:$SIMM)))]> {
5495  let Inst{11-8} = SIMM{11-8};
5496}
5497}
5498
5499//   VMVN     : Vector Bitwise NOT
5500def  VMVNd    : N2VX<0b11, 0b11, 0b00, 0b00, 0b01011, 0, 0,
5501                     (outs DPR:$Vd), (ins DPR:$Vm), IIC_VSUBiD,
5502                     "vmvn", "$Vd, $Vm", "",
5503                     [(set DPR:$Vd, (v2i32 (vnotd DPR:$Vm)))]>;
5504def  VMVNq    : N2VX<0b11, 0b11, 0b00, 0b00, 0b01011, 1, 0,
5505                     (outs QPR:$Vd), (ins QPR:$Vm), IIC_VSUBiD,
5506                     "vmvn", "$Vd, $Vm", "",
5507                     [(set QPR:$Vd, (v4i32 (vnotq QPR:$Vm)))]>;
5508let Predicates = [HasNEON] in {
5509def : Pat<(v1i64 (vnotd DPR:$src)),
5510          (VMVNd DPR:$src)>;
5511def : Pat<(v4i16 (vnotd DPR:$src)),
5512          (VMVNd DPR:$src)>;
5513def : Pat<(v8i8 (vnotd DPR:$src)),
5514          (VMVNd DPR:$src)>;
5515def : Pat<(v2i64 (vnotq QPR:$src)),
5516          (VMVNq QPR:$src)>;
5517def : Pat<(v8i16 (vnotq QPR:$src)),
5518          (VMVNq QPR:$src)>;
5519def : Pat<(v16i8 (vnotq QPR:$src)),
5520          (VMVNq QPR:$src)>;
5521}
5522
5523// The TwoAddress pass will not go looking for equivalent operations
5524// with different register constraints; it just inserts copies.
5525// That is why pseudo VBSP implemented. Is is expanded later into
5526// VBIT/VBIF/VBSL taking into account register constraints to avoid copies.
5527def  VBSPd
5528  : PseudoNeonI<(outs DPR:$Vd), (ins DPR:$src1, DPR:$Vn, DPR:$Vm),
5529                IIC_VBINiD, "",
5530                [(set DPR:$Vd,
5531                      (v2i32 (NEONvbsp DPR:$src1, DPR:$Vn, DPR:$Vm)))]>;
5532let Predicates = [HasNEON] in {
5533def : Pat<(v8i8 (int_arm_neon_vbsl (v8i8 DPR:$src1),
5534                                   (v8i8 DPR:$Vn), (v8i8 DPR:$Vm))),
5535          (VBSPd DPR:$src1, DPR:$Vn, DPR:$Vm)>;
5536def : Pat<(v4i16 (int_arm_neon_vbsl (v4i16 DPR:$src1),
5537                                    (v4i16 DPR:$Vn), (v4i16 DPR:$Vm))),
5538          (VBSPd DPR:$src1, DPR:$Vn, DPR:$Vm)>;
5539def : Pat<(v2i32 (int_arm_neon_vbsl (v2i32 DPR:$src1),
5540                                    (v2i32 DPR:$Vn), (v2i32 DPR:$Vm))),
5541          (VBSPd DPR:$src1, DPR:$Vn, DPR:$Vm)>;
5542def : Pat<(v2f32 (int_arm_neon_vbsl (v2f32 DPR:$src1),
5543                                    (v2f32 DPR:$Vn), (v2f32 DPR:$Vm))),
5544          (VBSPd DPR:$src1, DPR:$Vn, DPR:$Vm)>;
5545def : Pat<(v1i64 (int_arm_neon_vbsl (v1i64 DPR:$src1),
5546                                    (v1i64 DPR:$Vn), (v1i64 DPR:$Vm))),
5547          (VBSPd DPR:$src1, DPR:$Vn, DPR:$Vm)>;
5548
5549def : Pat<(v8i8 (or (and DPR:$Vn, DPR:$Vd),
5550                    (and DPR:$Vm, (vnotd DPR:$Vd)))),
5551          (VBSPd DPR:$Vd, DPR:$Vn, DPR:$Vm)>;
5552def : Pat<(v4i16 (or (and DPR:$Vn, DPR:$Vd),
5553                     (and DPR:$Vm, (vnotd DPR:$Vd)))),
5554          (VBSPd DPR:$Vd, DPR:$Vn, DPR:$Vm)>;
5555def : Pat<(v2i32 (or (and DPR:$Vn, DPR:$Vd),
5556                     (and DPR:$Vm, (vnotd DPR:$Vd)))),
5557          (VBSPd DPR:$Vd, DPR:$Vn, DPR:$Vm)>;
5558def : Pat<(v1i64 (or (and DPR:$Vn, DPR:$Vd),
5559                     (and DPR:$Vm, (vnotd DPR:$Vd)))),
5560          (VBSPd DPR:$Vd, DPR:$Vn, DPR:$Vm)>;
5561}
5562
5563def  VBSPq
5564  : PseudoNeonI<(outs QPR:$Vd), (ins QPR:$src1, QPR:$Vn, QPR:$Vm),
5565                IIC_VBINiQ, "",
5566                [(set QPR:$Vd,
5567                      (v4i32 (NEONvbsp QPR:$src1, QPR:$Vn, QPR:$Vm)))]>;
5568let Predicates = [HasNEON] in {
5569def : Pat<(v16i8 (int_arm_neon_vbsl (v16i8 QPR:$src1),
5570                                   (v16i8 QPR:$Vn), (v16i8 QPR:$Vm))),
5571          (VBSPq QPR:$src1, QPR:$Vn, QPR:$Vm)>;
5572def : Pat<(v8i16 (int_arm_neon_vbsl (v8i16 QPR:$src1),
5573                                    (v8i16 QPR:$Vn), (v8i16 QPR:$Vm))),
5574          (VBSPq QPR:$src1, QPR:$Vn, QPR:$Vm)>;
5575def : Pat<(v4i32 (int_arm_neon_vbsl (v4i32 QPR:$src1),
5576                                    (v4i32 QPR:$Vn), (v4i32 QPR:$Vm))),
5577          (VBSPq QPR:$src1, QPR:$Vn, QPR:$Vm)>;
5578def : Pat<(v4f32 (int_arm_neon_vbsl (v4f32 QPR:$src1),
5579                                    (v4f32 QPR:$Vn), (v4f32 QPR:$Vm))),
5580          (VBSPq QPR:$src1, QPR:$Vn, QPR:$Vm)>;
5581def : Pat<(v2i64 (int_arm_neon_vbsl (v2i64 QPR:$src1),
5582                                    (v2i64 QPR:$Vn), (v2i64 QPR:$Vm))),
5583          (VBSPq QPR:$src1, QPR:$Vn, QPR:$Vm)>;
5584
5585def : Pat<(v16i8 (or (and QPR:$Vn, QPR:$Vd),
5586                     (and QPR:$Vm, (vnotq QPR:$Vd)))),
5587          (VBSPq QPR:$Vd, QPR:$Vn, QPR:$Vm)>;
5588def : Pat<(v8i16 (or (and QPR:$Vn, QPR:$Vd),
5589                     (and QPR:$Vm, (vnotq QPR:$Vd)))),
5590          (VBSPq QPR:$Vd, QPR:$Vn, QPR:$Vm)>;
5591def : Pat<(v4i32 (or (and QPR:$Vn, QPR:$Vd),
5592                     (and QPR:$Vm, (vnotq QPR:$Vd)))),
5593          (VBSPq QPR:$Vd, QPR:$Vn, QPR:$Vm)>;
5594def : Pat<(v2i64 (or (and QPR:$Vn, QPR:$Vd),
5595                     (and QPR:$Vm, (vnotq QPR:$Vd)))),
5596          (VBSPq QPR:$Vd, QPR:$Vn, QPR:$Vm)>;
5597}
5598
5599//   VBSL     : Vector Bitwise Select
5600def  VBSLd    : N3VX<1, 0, 0b01, 0b0001, 0, 1, (outs DPR:$Vd),
5601                     (ins DPR:$src1, DPR:$Vn, DPR:$Vm),
5602                     N3RegFrm, IIC_VBINiD,
5603                     "vbsl", "$Vd, $Vn, $Vm", "$src1 = $Vd",
5604                     []>;
5605
5606def  VBSLq    : N3VX<1, 0, 0b01, 0b0001, 1, 1, (outs QPR:$Vd),
5607                     (ins QPR:$src1, QPR:$Vn, QPR:$Vm),
5608                     N3RegFrm, IIC_VBINiQ,
5609                     "vbsl", "$Vd, $Vn, $Vm", "$src1 = $Vd",
5610                     []>;
5611
5612//   VBIF     : Vector Bitwise Insert if False
5613//              like VBSL but with: "vbif $dst, $src3, $src1", "$src2 = $dst",
5614def  VBIFd    : N3VX<1, 0, 0b11, 0b0001, 0, 1,
5615                     (outs DPR:$Vd), (ins DPR:$src1, DPR:$Vn, DPR:$Vm),
5616                     N3RegFrm, IIC_VBINiD,
5617                     "vbif", "$Vd, $Vn, $Vm", "$src1 = $Vd",
5618                     []>;
5619def  VBIFq    : N3VX<1, 0, 0b11, 0b0001, 1, 1,
5620                     (outs QPR:$Vd), (ins QPR:$src1, QPR:$Vn, QPR:$Vm),
5621                     N3RegFrm, IIC_VBINiQ,
5622                     "vbif", "$Vd, $Vn, $Vm", "$src1 = $Vd",
5623                     []>;
5624
5625//   VBIT     : Vector Bitwise Insert if True
5626//              like VBSL but with: "vbit $dst, $src2, $src1", "$src3 = $dst",
5627def  VBITd    : N3VX<1, 0, 0b10, 0b0001, 0, 1,
5628                     (outs DPR:$Vd), (ins DPR:$src1, DPR:$Vn, DPR:$Vm),
5629                     N3RegFrm, IIC_VBINiD,
5630                     "vbit", "$Vd, $Vn, $Vm", "$src1 = $Vd",
5631                     []>;
5632def  VBITq    : N3VX<1, 0, 0b10, 0b0001, 1, 1,
5633                     (outs QPR:$Vd), (ins QPR:$src1, QPR:$Vn, QPR:$Vm),
5634                     N3RegFrm, IIC_VBINiQ,
5635                     "vbit", "$Vd, $Vn, $Vm", "$src1 = $Vd",
5636                     []>;
5637
5638// Vector Absolute Differences.
5639
5640//   VABD     : Vector Absolute Difference
5641defm VABDs    : N3VInt_QHS<0, 0, 0b0111, 0, N3RegFrm,
5642                           IIC_VSUBi4D, IIC_VSUBi4D, IIC_VSUBi4Q, IIC_VSUBi4Q,
5643                           "vabd", "s", abds, 1>;
5644defm VABDu    : N3VInt_QHS<1, 0, 0b0111, 0, N3RegFrm,
5645                           IIC_VSUBi4D, IIC_VSUBi4D, IIC_VSUBi4Q, IIC_VSUBi4Q,
5646                           "vabd", "u", abdu, 1>;
5647def  VABDfd   : N3VDInt<1, 0, 0b10, 0b1101, 0, N3RegFrm, IIC_VBIND,
5648                        "vabd", "f32", v2f32, v2f32, int_arm_neon_vabds, 1>;
5649def  VABDfq   : N3VQInt<1, 0, 0b10, 0b1101, 0, N3RegFrm, IIC_VBINQ,
5650                        "vabd", "f32", v4f32, v4f32, int_arm_neon_vabds, 1>;
5651def  VABDhd   : N3VDInt<1, 0, 0b11, 0b1101, 0, N3RegFrm, IIC_VBIND,
5652                        "vabd", "f16", v4f16, v4f16, int_arm_neon_vabds, 1>,
5653                Requires<[HasNEON, HasFullFP16]>;
5654def  VABDhq   : N3VQInt<1, 0, 0b11, 0b1101, 0, N3RegFrm, IIC_VBINQ,
5655                        "vabd", "f16", v8f16, v8f16, int_arm_neon_vabds, 1>,
5656                Requires<[HasNEON, HasFullFP16]>;
5657
5658//   VABDL    : Vector Absolute Difference Long (Q = | D - D |)
5659defm VABDLs   : N3VLIntExt_QHS<0,1,0b0111,0, IIC_VSUBi4Q,
5660                               "vabdl", "s", abds, zext, 1>;
5661defm VABDLu   : N3VLIntExt_QHS<1,1,0b0111,0, IIC_VSUBi4Q,
5662                               "vabdl", "u", abdu, zext, 1>;
5663
5664let Predicates = [HasNEON] in {
5665def : Pat<(v8i16 (zext (abdu (v8i8 DPR:$opA), (v8i8 DPR:$opB)))),
5666          (VABDLuv8i16 DPR:$opA, DPR:$opB)>;
5667def : Pat<(v4i32 (zext (abdu (v4i16 DPR:$opA), (v4i16 DPR:$opB)))),
5668          (VABDLuv4i32 DPR:$opA, DPR:$opB)>;
5669def : Pat<(v2i64 (zext (abdu (v2i32 DPR:$opA), (v2i32 DPR:$opB)))),
5670          (VABDLuv2i64 DPR:$opA, DPR:$opB)>;
5671}
5672
5673//   VABA     : Vector Absolute Difference and Accumulate
5674defm VABAs    : N3VIntOp_QHS<0,0,0b0111,1, IIC_VABAD, IIC_VABAQ,
5675                             "vaba", "s", abds, add>;
5676defm VABAu    : N3VIntOp_QHS<1,0,0b0111,1, IIC_VABAD, IIC_VABAQ,
5677                             "vaba", "u", abdu, add>;
5678
5679//   VABAL    : Vector Absolute Difference and Accumulate Long (Q += | D - D |)
5680defm VABALs   : N3VLIntExtOp_QHS<0,1,0b0101,0, IIC_VABAD,
5681                                 "vabal", "s", abds, zext, add>;
5682defm VABALu   : N3VLIntExtOp_QHS<1,1,0b0101,0, IIC_VABAD,
5683                                 "vabal", "u", abdu, zext, add>;
5684
5685// Vector Maximum and Minimum.
5686
5687//   VMAX     : Vector Maximum
5688defm VMAXs    : N3VInt_QHS<0, 0, 0b0110, 0, N3RegFrm,
5689                           IIC_VSUBi4D, IIC_VSUBi4D, IIC_VSUBi4Q, IIC_VSUBi4Q,
5690                           "vmax", "s", smax, 1>;
5691defm VMAXu    : N3VInt_QHS<1, 0, 0b0110, 0, N3RegFrm,
5692                           IIC_VSUBi4D, IIC_VSUBi4D, IIC_VSUBi4Q, IIC_VSUBi4Q,
5693                           "vmax", "u", umax, 1>;
5694def  VMAXfd   : N3VDInt<0, 0, 0b00, 0b1111, 0, N3RegFrm, IIC_VBIND,
5695                        "vmax", "f32",
5696                        v2f32, v2f32, fmaximum, 1>;
5697def  VMAXfq   : N3VQInt<0, 0, 0b00, 0b1111, 0, N3RegFrm, IIC_VBINQ,
5698                        "vmax", "f32",
5699                        v4f32, v4f32, fmaximum, 1>;
5700def  VMAXhd   : N3VDInt<0, 0, 0b01, 0b1111, 0, N3RegFrm, IIC_VBIND,
5701                        "vmax", "f16",
5702                        v4f16, v4f16, fmaximum, 1>,
5703                Requires<[HasNEON, HasFullFP16]>;
5704def  VMAXhq   : N3VQInt<0, 0, 0b01, 0b1111, 0, N3RegFrm, IIC_VBINQ,
5705                        "vmax", "f16",
5706                        v8f16, v8f16, fmaximum, 1>,
5707                Requires<[HasNEON, HasFullFP16]>;
5708
5709// VMAXNM
5710let PostEncoderMethod = "NEONThumb2V8PostEncoder", DecoderNamespace = "v8NEON" in {
5711  def NEON_VMAXNMNDf  : N3VDIntnp<0b00110, 0b00, 0b1111, 0, 1,
5712                                  N3RegFrm, NoItinerary, "vmaxnm", "f32",
5713                                  v2f32, v2f32, fmaxnum, 1>,
5714                                  Requires<[HasFPARMv8, HasNEON]>;
5715  def NEON_VMAXNMNQf  : N3VQIntnp<0b00110, 0b00, 0b1111, 1, 1,
5716                                  N3RegFrm, NoItinerary, "vmaxnm", "f32",
5717                                  v4f32, v4f32, fmaxnum, 1>,
5718                                  Requires<[HasFPARMv8, HasNEON]>;
5719  def NEON_VMAXNMNDh  : N3VDIntnp<0b00110, 0b01, 0b1111, 0, 1,
5720                                  N3RegFrm, NoItinerary, "vmaxnm", "f16",
5721                                  v4f16, v4f16, fmaxnum, 1>,
5722                                  Requires<[HasFPARMv8, HasNEON, HasFullFP16]>;
5723  def NEON_VMAXNMNQh  : N3VQIntnp<0b00110, 0b01, 0b1111, 1, 1,
5724                                  N3RegFrm, NoItinerary, "vmaxnm", "f16",
5725                                  v8f16, v8f16, fmaxnum, 1>,
5726                                  Requires<[HasFPARMv8, HasNEON, HasFullFP16]>;
5727}
5728
5729//   VMIN     : Vector Minimum
5730defm VMINs    : N3VInt_QHS<0, 0, 0b0110, 1, N3RegFrm,
5731                           IIC_VSUBi4D, IIC_VSUBi4D, IIC_VSUBi4Q, IIC_VSUBi4Q,
5732                           "vmin", "s", smin, 1>;
5733defm VMINu    : N3VInt_QHS<1, 0, 0b0110, 1, N3RegFrm,
5734                           IIC_VSUBi4D, IIC_VSUBi4D, IIC_VSUBi4Q, IIC_VSUBi4Q,
5735                           "vmin", "u", umin, 1>;
5736def  VMINfd   : N3VDInt<0, 0, 0b10, 0b1111, 0, N3RegFrm, IIC_VBIND,
5737                        "vmin", "f32",
5738                        v2f32, v2f32, fminimum, 1>;
5739def  VMINfq   : N3VQInt<0, 0, 0b10, 0b1111, 0, N3RegFrm, IIC_VBINQ,
5740                        "vmin", "f32",
5741                        v4f32, v4f32, fminimum, 1>;
5742def  VMINhd   : N3VDInt<0, 0, 0b11, 0b1111, 0, N3RegFrm, IIC_VBIND,
5743                        "vmin", "f16",
5744                        v4f16, v4f16, fminimum, 1>,
5745                Requires<[HasNEON, HasFullFP16]>;
5746def  VMINhq   : N3VQInt<0, 0, 0b11, 0b1111, 0, N3RegFrm, IIC_VBINQ,
5747                        "vmin", "f16",
5748                        v8f16, v8f16, fminimum, 1>,
5749                Requires<[HasNEON, HasFullFP16]>;
5750
5751// VMINNM
5752let PostEncoderMethod = "NEONThumb2V8PostEncoder", DecoderNamespace = "v8NEON" in {
5753  def NEON_VMINNMNDf  : N3VDIntnp<0b00110, 0b10, 0b1111, 0, 1,
5754                                  N3RegFrm, NoItinerary, "vminnm", "f32",
5755                                  v2f32, v2f32, fminnum, 1>,
5756                                  Requires<[HasFPARMv8, HasNEON]>;
5757  def NEON_VMINNMNQf  : N3VQIntnp<0b00110, 0b10, 0b1111, 1, 1,
5758                                  N3RegFrm, NoItinerary, "vminnm", "f32",
5759                                  v4f32, v4f32, fminnum, 1>,
5760                                  Requires<[HasFPARMv8, HasNEON]>;
5761  def NEON_VMINNMNDh  : N3VDIntnp<0b00110, 0b11, 0b1111, 0, 1,
5762                                  N3RegFrm, NoItinerary, "vminnm", "f16",
5763                                  v4f16, v4f16, fminnum, 1>,
5764                                  Requires<[HasFPARMv8, HasNEON, HasFullFP16]>;
5765  def NEON_VMINNMNQh  : N3VQIntnp<0b00110, 0b11, 0b1111, 1, 1,
5766                                  N3RegFrm, NoItinerary, "vminnm", "f16",
5767                                  v8f16, v8f16, fminnum, 1>,
5768                                  Requires<[HasFPARMv8, HasNEON, HasFullFP16]>;
5769}
5770
5771// Vector Pairwise Operations.
5772
5773//   VPADD    : Vector Pairwise Add
5774def  VPADDi8  : N3VDInt<0, 0, 0b00, 0b1011, 1, N3RegFrm, IIC_VSHLiD,
5775                        "vpadd", "i8",
5776                        v8i8, v8i8, int_arm_neon_vpadd, 0>;
5777def  VPADDi16 : N3VDInt<0, 0, 0b01, 0b1011, 1, N3RegFrm, IIC_VSHLiD,
5778                        "vpadd", "i16",
5779                        v4i16, v4i16, int_arm_neon_vpadd, 0>;
5780def  VPADDi32 : N3VDInt<0, 0, 0b10, 0b1011, 1, N3RegFrm, IIC_VSHLiD,
5781                        "vpadd", "i32",
5782                        v2i32, v2i32, int_arm_neon_vpadd, 0>;
5783def  VPADDf   : N3VDInt<1, 0, 0b00, 0b1101, 0, N3RegFrm,
5784                        IIC_VPBIND, "vpadd", "f32",
5785                        v2f32, v2f32, int_arm_neon_vpadd, 0>;
5786def  VPADDh   : N3VDInt<1, 0, 0b01, 0b1101, 0, N3RegFrm,
5787                        IIC_VPBIND, "vpadd", "f16",
5788                        v4f16, v4f16, int_arm_neon_vpadd, 0>,
5789                Requires<[HasNEON, HasFullFP16]>;
5790
5791//   VPADDL   : Vector Pairwise Add Long
5792defm VPADDLs  : N2VPLInt_QHS<0b11, 0b11, 0b00, 0b00100, 0, "vpaddl", "s",
5793                             int_arm_neon_vpaddls>;
5794defm VPADDLu  : N2VPLInt_QHS<0b11, 0b11, 0b00, 0b00101, 0, "vpaddl", "u",
5795                             int_arm_neon_vpaddlu>;
5796
5797//   VPADAL   : Vector Pairwise Add and Accumulate Long
5798defm VPADALs  : N2VPLInt2_QHS<0b11, 0b11, 0b00, 0b01100, 0, "vpadal", "s",
5799                              int_arm_neon_vpadals>;
5800defm VPADALu  : N2VPLInt2_QHS<0b11, 0b11, 0b00, 0b01101, 0, "vpadal", "u",
5801                              int_arm_neon_vpadalu>;
5802
5803//   VPMAX    : Vector Pairwise Maximum
5804def  VPMAXs8  : N3VDInt<0, 0, 0b00, 0b1010, 0, N3RegFrm, IIC_VSUBi4D, "vpmax",
5805                        "s8", v8i8, v8i8, int_arm_neon_vpmaxs, 0>;
5806def  VPMAXs16 : N3VDInt<0, 0, 0b01, 0b1010, 0, N3RegFrm, IIC_VSUBi4D, "vpmax",
5807                        "s16", v4i16, v4i16, int_arm_neon_vpmaxs, 0>;
5808def  VPMAXs32 : N3VDInt<0, 0, 0b10, 0b1010, 0, N3RegFrm, IIC_VSUBi4D, "vpmax",
5809                        "s32", v2i32, v2i32, int_arm_neon_vpmaxs, 0>;
5810def  VPMAXu8  : N3VDInt<1, 0, 0b00, 0b1010, 0, N3RegFrm, IIC_VSUBi4D, "vpmax",
5811                        "u8", v8i8, v8i8, int_arm_neon_vpmaxu, 0>;
5812def  VPMAXu16 : N3VDInt<1, 0, 0b01, 0b1010, 0, N3RegFrm, IIC_VSUBi4D, "vpmax",
5813                        "u16", v4i16, v4i16, int_arm_neon_vpmaxu, 0>;
5814def  VPMAXu32 : N3VDInt<1, 0, 0b10, 0b1010, 0, N3RegFrm, IIC_VSUBi4D, "vpmax",
5815                        "u32", v2i32, v2i32, int_arm_neon_vpmaxu, 0>;
5816def  VPMAXf   : N3VDInt<1, 0, 0b00, 0b1111, 0, N3RegFrm, IIC_VPBIND, "vpmax",
5817                        "f32", v2f32, v2f32, int_arm_neon_vpmaxs, 0>;
5818def  VPMAXh   : N3VDInt<1, 0, 0b01, 0b1111, 0, N3RegFrm, IIC_VPBIND, "vpmax",
5819                        "f16", v4f16, v4f16, int_arm_neon_vpmaxs, 0>,
5820                Requires<[HasNEON, HasFullFP16]>;
5821
5822//   VPMIN    : Vector Pairwise Minimum
5823def  VPMINs8  : N3VDInt<0, 0, 0b00, 0b1010, 1, N3RegFrm, IIC_VSUBi4D, "vpmin",
5824                        "s8", v8i8, v8i8, int_arm_neon_vpmins, 0>;
5825def  VPMINs16 : N3VDInt<0, 0, 0b01, 0b1010, 1, N3RegFrm, IIC_VSUBi4D, "vpmin",
5826                        "s16", v4i16, v4i16, int_arm_neon_vpmins, 0>;
5827def  VPMINs32 : N3VDInt<0, 0, 0b10, 0b1010, 1, N3RegFrm, IIC_VSUBi4D, "vpmin",
5828                        "s32", v2i32, v2i32, int_arm_neon_vpmins, 0>;
5829def  VPMINu8  : N3VDInt<1, 0, 0b00, 0b1010, 1, N3RegFrm, IIC_VSUBi4D, "vpmin",
5830                        "u8", v8i8, v8i8, int_arm_neon_vpminu, 0>;
5831def  VPMINu16 : N3VDInt<1, 0, 0b01, 0b1010, 1, N3RegFrm, IIC_VSUBi4D, "vpmin",
5832                        "u16", v4i16, v4i16, int_arm_neon_vpminu, 0>;
5833def  VPMINu32 : N3VDInt<1, 0, 0b10, 0b1010, 1, N3RegFrm, IIC_VSUBi4D, "vpmin",
5834                        "u32", v2i32, v2i32, int_arm_neon_vpminu, 0>;
5835def  VPMINf   : N3VDInt<1, 0, 0b10, 0b1111, 0, N3RegFrm, IIC_VPBIND, "vpmin",
5836                        "f32", v2f32, v2f32, int_arm_neon_vpmins, 0>;
5837def  VPMINh   : N3VDInt<1, 0, 0b11, 0b1111, 0, N3RegFrm, IIC_VPBIND, "vpmin",
5838                        "f16", v4f16, v4f16, int_arm_neon_vpmins, 0>,
5839                Requires<[HasNEON, HasFullFP16]>;
5840
5841// Vector Reciprocal and Reciprocal Square Root Estimate and Step.
5842
5843//   VRECPE   : Vector Reciprocal Estimate
5844def  VRECPEd  : N2VDInt<0b11, 0b11, 0b10, 0b11, 0b01000, 0,
5845                        IIC_VUNAD, "vrecpe", "u32",
5846                        v2i32, v2i32, int_arm_neon_vrecpe>;
5847def  VRECPEq  : N2VQInt<0b11, 0b11, 0b10, 0b11, 0b01000, 0,
5848                        IIC_VUNAQ, "vrecpe", "u32",
5849                        v4i32, v4i32, int_arm_neon_vrecpe>;
5850def  VRECPEfd : N2VDInt<0b11, 0b11, 0b10, 0b11, 0b01010, 0,
5851                        IIC_VUNAD, "vrecpe", "f32",
5852                        v2f32, v2f32, int_arm_neon_vrecpe>;
5853def  VRECPEfq : N2VQInt<0b11, 0b11, 0b10, 0b11, 0b01010, 0,
5854                        IIC_VUNAQ, "vrecpe", "f32",
5855                        v4f32, v4f32, int_arm_neon_vrecpe>;
5856def  VRECPEhd : N2VDInt<0b11, 0b11, 0b01, 0b11, 0b01010, 0,
5857                        IIC_VUNAD, "vrecpe", "f16",
5858                        v4f16, v4f16, int_arm_neon_vrecpe>,
5859                Requires<[HasNEON, HasFullFP16]>;
5860def  VRECPEhq : N2VQInt<0b11, 0b11, 0b01, 0b11, 0b01010, 0,
5861                        IIC_VUNAQ, "vrecpe", "f16",
5862                        v8f16, v8f16, int_arm_neon_vrecpe>,
5863                Requires<[HasNEON, HasFullFP16]>;
5864
5865//   VRECPS   : Vector Reciprocal Step
5866def  VRECPSfd : N3VDInt<0, 0, 0b00, 0b1111, 1, N3RegFrm,
5867                        IIC_VRECSD, "vrecps", "f32",
5868                        v2f32, v2f32, int_arm_neon_vrecps, 1>;
5869def  VRECPSfq : N3VQInt<0, 0, 0b00, 0b1111, 1, N3RegFrm,
5870                        IIC_VRECSQ, "vrecps", "f32",
5871                        v4f32, v4f32, int_arm_neon_vrecps, 1>;
5872def  VRECPShd : N3VDInt<0, 0, 0b01, 0b1111, 1, N3RegFrm,
5873                        IIC_VRECSD, "vrecps", "f16",
5874                        v4f16, v4f16, int_arm_neon_vrecps, 1>,
5875                Requires<[HasNEON, HasFullFP16]>;
5876def  VRECPShq : N3VQInt<0, 0, 0b01, 0b1111, 1, N3RegFrm,
5877                        IIC_VRECSQ, "vrecps", "f16",
5878                        v8f16, v8f16, int_arm_neon_vrecps, 1>,
5879                Requires<[HasNEON, HasFullFP16]>;
5880
5881//   VRSQRTE  : Vector Reciprocal Square Root Estimate
5882def  VRSQRTEd  : N2VDInt<0b11, 0b11, 0b10, 0b11, 0b01001, 0,
5883                         IIC_VUNAD, "vrsqrte", "u32",
5884                         v2i32, v2i32, int_arm_neon_vrsqrte>;
5885def  VRSQRTEq  : N2VQInt<0b11, 0b11, 0b10, 0b11, 0b01001, 0,
5886                         IIC_VUNAQ, "vrsqrte", "u32",
5887                         v4i32, v4i32, int_arm_neon_vrsqrte>;
5888def  VRSQRTEfd : N2VDInt<0b11, 0b11, 0b10, 0b11, 0b01011, 0,
5889                         IIC_VUNAD, "vrsqrte", "f32",
5890                         v2f32, v2f32, int_arm_neon_vrsqrte>;
5891def  VRSQRTEfq : N2VQInt<0b11, 0b11, 0b10, 0b11, 0b01011, 0,
5892                         IIC_VUNAQ, "vrsqrte", "f32",
5893                         v4f32, v4f32, int_arm_neon_vrsqrte>;
5894def  VRSQRTEhd : N2VDInt<0b11, 0b11, 0b01, 0b11, 0b01011, 0,
5895                         IIC_VUNAD, "vrsqrte", "f16",
5896                         v4f16, v4f16, int_arm_neon_vrsqrte>,
5897                Requires<[HasNEON, HasFullFP16]>;
5898def  VRSQRTEhq : N2VQInt<0b11, 0b11, 0b01, 0b11, 0b01011, 0,
5899                         IIC_VUNAQ, "vrsqrte", "f16",
5900                         v8f16, v8f16, int_arm_neon_vrsqrte>,
5901                Requires<[HasNEON, HasFullFP16]>;
5902
5903//   VRSQRTS  : Vector Reciprocal Square Root Step
5904def VRSQRTSfd : N3VDInt<0, 0, 0b10, 0b1111, 1, N3RegFrm,
5905                        IIC_VRECSD, "vrsqrts", "f32",
5906                        v2f32, v2f32, int_arm_neon_vrsqrts, 1>;
5907def VRSQRTSfq : N3VQInt<0, 0, 0b10, 0b1111, 1, N3RegFrm,
5908                        IIC_VRECSQ, "vrsqrts", "f32",
5909                        v4f32, v4f32, int_arm_neon_vrsqrts, 1>;
5910def VRSQRTShd : N3VDInt<0, 0, 0b11, 0b1111, 1, N3RegFrm,
5911                        IIC_VRECSD, "vrsqrts", "f16",
5912                        v4f16, v4f16, int_arm_neon_vrsqrts, 1>,
5913                Requires<[HasNEON, HasFullFP16]>;
5914def VRSQRTShq : N3VQInt<0, 0, 0b11, 0b1111, 1, N3RegFrm,
5915                        IIC_VRECSQ, "vrsqrts", "f16",
5916                        v8f16, v8f16, int_arm_neon_vrsqrts, 1>,
5917                Requires<[HasNEON, HasFullFP16]>;
5918
5919// Vector Shifts.
5920
5921//   VSHL     : Vector Shift
5922defm VSHLs    : N3VInt_QHSDSh<0, 0, 0b0100, 0, N3RegVShFrm,
5923                            IIC_VSHLiD, IIC_VSHLiD, IIC_VSHLiQ, IIC_VSHLiQ,
5924                            "vshl", "s", int_arm_neon_vshifts>;
5925defm VSHLu    : N3VInt_QHSDSh<1, 0, 0b0100, 0, N3RegVShFrm,
5926                            IIC_VSHLiD, IIC_VSHLiD, IIC_VSHLiQ, IIC_VSHLiQ,
5927                            "vshl", "u", int_arm_neon_vshiftu>;
5928
5929let Predicates = [HasNEON] in {
5930def : Pat<(v8i8 (ARMvshls (v8i8 DPR:$Dn), (v8i8 DPR:$Dm))),
5931          (VSHLsv8i8 DPR:$Dn, DPR:$Dm)>;
5932def : Pat<(v4i16 (ARMvshls (v4i16 DPR:$Dn), (v4i16 DPR:$Dm))),
5933          (VSHLsv4i16 DPR:$Dn, DPR:$Dm)>;
5934def : Pat<(v2i32 (ARMvshls (v2i32 DPR:$Dn), (v2i32 DPR:$Dm))),
5935          (VSHLsv2i32 DPR:$Dn, DPR:$Dm)>;
5936def : Pat<(v1i64 (ARMvshls (v1i64 DPR:$Dn), (v1i64 DPR:$Dm))),
5937          (VSHLsv1i64 DPR:$Dn, DPR:$Dm)>;
5938def : Pat<(v16i8 (ARMvshls (v16i8 QPR:$Dn), (v16i8 QPR:$Dm))),
5939          (VSHLsv16i8 QPR:$Dn, QPR:$Dm)>;
5940def : Pat<(v8i16 (ARMvshls (v8i16 QPR:$Dn), (v8i16 QPR:$Dm))),
5941          (VSHLsv8i16 QPR:$Dn, QPR:$Dm)>;
5942def : Pat<(v4i32 (ARMvshls (v4i32 QPR:$Dn), (v4i32 QPR:$Dm))),
5943          (VSHLsv4i32 QPR:$Dn, QPR:$Dm)>;
5944def : Pat<(v2i64 (ARMvshls (v2i64 QPR:$Dn), (v2i64 QPR:$Dm))),
5945          (VSHLsv2i64 QPR:$Dn, QPR:$Dm)>;
5946
5947def : Pat<(v8i8 (ARMvshlu (v8i8 DPR:$Dn), (v8i8 DPR:$Dm))),
5948          (VSHLuv8i8 DPR:$Dn, DPR:$Dm)>;
5949def : Pat<(v4i16 (ARMvshlu (v4i16 DPR:$Dn), (v4i16 DPR:$Dm))),
5950          (VSHLuv4i16 DPR:$Dn, DPR:$Dm)>;
5951def : Pat<(v2i32 (ARMvshlu (v2i32 DPR:$Dn), (v2i32 DPR:$Dm))),
5952          (VSHLuv2i32 DPR:$Dn, DPR:$Dm)>;
5953def : Pat<(v1i64 (ARMvshlu (v1i64 DPR:$Dn), (v1i64 DPR:$Dm))),
5954          (VSHLuv1i64 DPR:$Dn, DPR:$Dm)>;
5955def : Pat<(v16i8 (ARMvshlu (v16i8 QPR:$Dn), (v16i8 QPR:$Dm))),
5956          (VSHLuv16i8 QPR:$Dn, QPR:$Dm)>;
5957def : Pat<(v8i16 (ARMvshlu (v8i16 QPR:$Dn), (v8i16 QPR:$Dm))),
5958          (VSHLuv8i16 QPR:$Dn, QPR:$Dm)>;
5959def : Pat<(v4i32 (ARMvshlu (v4i32 QPR:$Dn), (v4i32 QPR:$Dm))),
5960          (VSHLuv4i32 QPR:$Dn, QPR:$Dm)>;
5961def : Pat<(v2i64 (ARMvshlu (v2i64 QPR:$Dn), (v2i64 QPR:$Dm))),
5962          (VSHLuv2i64 QPR:$Dn, QPR:$Dm)>;
5963
5964}
5965
5966//   VSHL     : Vector Shift Left (Immediate)
5967defm VSHLi    : N2VShL_QHSD<0, 1, 0b0101, 1, IIC_VSHLiD, "vshl", "i", ARMvshlImm>;
5968
5969//   VSHR     : Vector Shift Right (Immediate)
5970defm VSHRs    : N2VShR_QHSD<0, 1, 0b0000, 1, IIC_VSHLiD, "vshr", "s",
5971                            ARMvshrsImm>;
5972defm VSHRu    : N2VShR_QHSD<1, 1, 0b0000, 1, IIC_VSHLiD, "vshr", "u",
5973                            ARMvshruImm>;
5974
5975//   VSHLL    : Vector Shift Left Long
5976defm VSHLLs   : N2VLSh_QHS<0, 1, 0b1010, 0, 0, 1, "vshll", "s",
5977  PatFrag<(ops node:$LHS, node:$RHS), (ARMvshlImm (sext node:$LHS), node:$RHS)>>;
5978defm VSHLLu   : N2VLSh_QHS<1, 1, 0b1010, 0, 0, 1, "vshll", "u",
5979  PatFrag<(ops node:$LHS, node:$RHS), (ARMvshlImm (zext node:$LHS), node:$RHS)>>;
5980
5981//   VSHLL    : Vector Shift Left Long (with maximum shift count)
5982class N2VLShMax<bit op24, bit op23, bits<6> op21_16, bits<4> op11_8, bit op7,
5983                bit op6, bit op4, string OpcodeStr, string Dt, ValueType ResTy,
5984                ValueType OpTy, Operand ImmTy>
5985  : N2VLSh<op24, op23, op11_8, op7, op6, op4, OpcodeStr, Dt,
5986           ResTy, OpTy, ImmTy, null_frag> {
5987  let Inst{21-16} = op21_16;
5988  let DecoderMethod = "DecodeVSHLMaxInstruction";
5989}
5990def  VSHLLi8  : N2VLShMax<1, 1, 0b110010, 0b0011, 0, 0, 0, "vshll", "i8",
5991                          v8i16, v8i8, imm8>;
5992def  VSHLLi16 : N2VLShMax<1, 1, 0b110110, 0b0011, 0, 0, 0, "vshll", "i16",
5993                          v4i32, v4i16, imm16>;
5994def  VSHLLi32 : N2VLShMax<1, 1, 0b111010, 0b0011, 0, 0, 0, "vshll", "i32",
5995                          v2i64, v2i32, imm32>;
5996
5997let Predicates = [HasNEON] in {
5998def : Pat<(v8i16 (ARMvshlImm (zext (v8i8 DPR:$Rn)), (i32 8))),
5999          (VSHLLi8 DPR:$Rn, 8)>;
6000def : Pat<(v4i32 (ARMvshlImm (zext (v4i16 DPR:$Rn)), (i32 16))),
6001          (VSHLLi16 DPR:$Rn, 16)>;
6002def : Pat<(v2i64 (ARMvshlImm (zext (v2i32 DPR:$Rn)), (i32 32))),
6003          (VSHLLi32 DPR:$Rn, 32)>;
6004def : Pat<(v8i16 (ARMvshlImm (sext (v8i8 DPR:$Rn)), (i32 8))),
6005          (VSHLLi8 DPR:$Rn, 8)>;
6006def : Pat<(v4i32 (ARMvshlImm (sext (v4i16 DPR:$Rn)), (i32 16))),
6007          (VSHLLi16 DPR:$Rn, 16)>;
6008def : Pat<(v2i64 (ARMvshlImm (sext (v2i32 DPR:$Rn)), (i32 32))),
6009          (VSHLLi32 DPR:$Rn, 32)>;
6010def : Pat<(v8i16 (ARMvshlImm (anyext (v8i8 DPR:$Rn)), (i32 8))),
6011          (VSHLLi8 DPR:$Rn, 8)>;
6012def : Pat<(v4i32 (ARMvshlImm (anyext (v4i16 DPR:$Rn)), (i32 16))),
6013          (VSHLLi16 DPR:$Rn, 16)>;
6014def : Pat<(v2i64 (ARMvshlImm (anyext (v2i32 DPR:$Rn)), (i32 32))),
6015          (VSHLLi32 DPR:$Rn, 32)>;
6016}
6017
6018//   VSHRN    : Vector Shift Right and Narrow
6019defm VSHRN    : N2VNSh_HSD<0,1,0b1000,0,0,1, IIC_VSHLiD, "vshrn", "i",
6020                           PatFrag<(ops node:$Rn, node:$amt),
6021                                   (trunc (ARMvshrsImm node:$Rn, node:$amt))>>;
6022
6023let Predicates = [HasNEON] in {
6024def : Pat<(v8i8 (trunc (ARMvshruImm (v8i16 QPR:$Vn), shr_imm8:$amt))),
6025          (VSHRNv8i8 QPR:$Vn, shr_imm8:$amt)>;
6026def : Pat<(v4i16 (trunc (ARMvshruImm (v4i32 QPR:$Vn), shr_imm16:$amt))),
6027          (VSHRNv4i16 QPR:$Vn, shr_imm16:$amt)>;
6028def : Pat<(v2i32 (trunc (ARMvshruImm (v2i64 QPR:$Vn), shr_imm32:$amt))),
6029          (VSHRNv2i32 QPR:$Vn, shr_imm32:$amt)>;
6030}
6031
6032//   VRSHL    : Vector Rounding Shift
6033defm VRSHLs   : N3VInt_QHSDSh<0, 0, 0b0101, 0, N3RegVShFrm,
6034                            IIC_VSHLi4D, IIC_VSHLi4D, IIC_VSHLi4Q, IIC_VSHLi4Q,
6035                            "vrshl", "s", int_arm_neon_vrshifts>;
6036defm VRSHLu   : N3VInt_QHSDSh<1, 0, 0b0101, 0, N3RegVShFrm,
6037                            IIC_VSHLi4D, IIC_VSHLi4D, IIC_VSHLi4Q, IIC_VSHLi4Q,
6038                            "vrshl", "u", int_arm_neon_vrshiftu>;
6039//   VRSHR    : Vector Rounding Shift Right
6040defm VRSHRs   : N2VShR_QHSD<0,1,0b0010,1, IIC_VSHLi4D, "vrshr", "s",
6041                            NEONvrshrsImm>;
6042defm VRSHRu   : N2VShR_QHSD<1,1,0b0010,1, IIC_VSHLi4D, "vrshr", "u",
6043                            NEONvrshruImm>;
6044
6045//   VRSHRN   : Vector Rounding Shift Right and Narrow
6046defm VRSHRN   : N2VNSh_HSD<0, 1, 0b1000, 0, 1, 1, IIC_VSHLi4D, "vrshrn", "i",
6047                           NEONvrshrnImm>;
6048
6049//   VQSHL    : Vector Saturating Shift
6050defm VQSHLs   : N3VInt_QHSDSh<0, 0, 0b0100, 1, N3RegVShFrm,
6051                            IIC_VSHLi4D, IIC_VSHLi4D, IIC_VSHLi4Q, IIC_VSHLi4Q,
6052                            "vqshl", "s", int_arm_neon_vqshifts>;
6053defm VQSHLu   : N3VInt_QHSDSh<1, 0, 0b0100, 1, N3RegVShFrm,
6054                            IIC_VSHLi4D, IIC_VSHLi4D, IIC_VSHLi4Q, IIC_VSHLi4Q,
6055                            "vqshl", "u", int_arm_neon_vqshiftu>;
6056//   VQSHL    : Vector Saturating Shift Left (Immediate)
6057defm VQSHLsi  : N2VShL_QHSD<0,1,0b0111,1, IIC_VSHLi4D, "vqshl", "s",NEONvqshlsImm>;
6058defm VQSHLui  : N2VShL_QHSD<1,1,0b0111,1, IIC_VSHLi4D, "vqshl", "u",NEONvqshluImm>;
6059
6060//   VQSHLU   : Vector Saturating Shift Left (Immediate, Unsigned)
6061defm VQSHLsu  : N2VShL_QHSD<1,1,0b0110,1, IIC_VSHLi4D,"vqshlu","s",NEONvqshlsuImm>;
6062
6063//   VQSHRN   : Vector Saturating Shift Right and Narrow
6064defm VQSHRNs  : N2VNSh_HSD<0, 1, 0b1001, 0, 0, 1, IIC_VSHLi4D, "vqshrn", "s",
6065                           NEONvqshrnsImm>;
6066defm VQSHRNu  : N2VNSh_HSD<1, 1, 0b1001, 0, 0, 1, IIC_VSHLi4D, "vqshrn", "u",
6067                           NEONvqshrnuImm>;
6068
6069//   VQSHRUN  : Vector Saturating Shift Right and Narrow (Unsigned)
6070defm VQSHRUN  : N2VNSh_HSD<1, 1, 0b1000, 0, 0, 1, IIC_VSHLi4D, "vqshrun", "s",
6071                           NEONvqshrnsuImm>;
6072
6073//   VQRSHL   : Vector Saturating Rounding Shift
6074defm VQRSHLs  : N3VInt_QHSDSh<0, 0, 0b0101, 1, N3RegVShFrm,
6075                            IIC_VSHLi4D, IIC_VSHLi4D, IIC_VSHLi4Q, IIC_VSHLi4Q,
6076                            "vqrshl", "s", int_arm_neon_vqrshifts>;
6077defm VQRSHLu  : N3VInt_QHSDSh<1, 0, 0b0101, 1, N3RegVShFrm,
6078                            IIC_VSHLi4D, IIC_VSHLi4D, IIC_VSHLi4Q, IIC_VSHLi4Q,
6079                            "vqrshl", "u", int_arm_neon_vqrshiftu>;
6080
6081//   VQRSHRN  : Vector Saturating Rounding Shift Right and Narrow
6082defm VQRSHRNs : N2VNSh_HSD<0, 1, 0b1001, 0, 1, 1, IIC_VSHLi4D, "vqrshrn", "s",
6083                           NEONvqrshrnsImm>;
6084defm VQRSHRNu : N2VNSh_HSD<1, 1, 0b1001, 0, 1, 1, IIC_VSHLi4D, "vqrshrn", "u",
6085                           NEONvqrshrnuImm>;
6086
6087//   VQRSHRUN : Vector Saturating Rounding Shift Right and Narrow (Unsigned)
6088defm VQRSHRUN : N2VNSh_HSD<1, 1, 0b1000, 0, 1, 1, IIC_VSHLi4D, "vqrshrun", "s",
6089                           NEONvqrshrnsuImm>;
6090
6091//   VSRA     : Vector Shift Right and Accumulate
6092defm VSRAs    : N2VShAdd_QHSD<0, 1, 0b0001, 1, "vsra", "s", ARMvshrsImm>;
6093defm VSRAu    : N2VShAdd_QHSD<1, 1, 0b0001, 1, "vsra", "u", ARMvshruImm>;
6094//   VRSRA    : Vector Rounding Shift Right and Accumulate
6095defm VRSRAs   : N2VShAdd_QHSD<0, 1, 0b0011, 1, "vrsra", "s", NEONvrshrsImm>;
6096defm VRSRAu   : N2VShAdd_QHSD<1, 1, 0b0011, 1, "vrsra", "u", NEONvrshruImm>;
6097
6098//   VSLI     : Vector Shift Left and Insert
6099defm VSLI     : N2VShInsL_QHSD<1, 1, 0b0101, 1, "vsli">;
6100
6101//   VSRI     : Vector Shift Right and Insert
6102defm VSRI     : N2VShInsR_QHSD<1, 1, 0b0100, 1, "vsri">;
6103
6104// Vector Absolute and Saturating Absolute.
6105
6106//   VABS     : Vector Absolute Value
6107defm VABS     : N2VInt_QHS<0b11, 0b11, 0b01, 0b00110, 0,
6108                           IIC_VUNAiD, IIC_VUNAiQ, "vabs", "s", abs>;
6109def  VABSfd   : N2VD<0b11, 0b11, 0b10, 0b01, 0b01110, 0,
6110                     "vabs", "f32",
6111                     v2f32, v2f32, fabs>;
6112def  VABSfq   : N2VQ<0b11, 0b11, 0b10, 0b01, 0b01110, 0,
6113                     "vabs", "f32",
6114                      v4f32, v4f32, fabs>;
6115def  VABShd   : N2VD<0b11, 0b11, 0b01, 0b01, 0b01110, 0,
6116                     "vabs", "f16",
6117                     v4f16, v4f16, fabs>,
6118                Requires<[HasNEON, HasFullFP16]>;
6119def  VABShq   : N2VQ<0b11, 0b11, 0b01, 0b01, 0b01110, 0,
6120                     "vabs", "f16",
6121                      v8f16, v8f16, fabs>,
6122                Requires<[HasNEON, HasFullFP16]>;
6123
6124//   VQABS    : Vector Saturating Absolute Value
6125defm VQABS    : N2VInt_QHS<0b11, 0b11, 0b00, 0b01110, 0,
6126                           IIC_VQUNAiD, IIC_VQUNAiQ, "vqabs", "s",
6127                           int_arm_neon_vqabs>;
6128
6129// Vector Negate.
6130
6131def vnegd  : PatFrag<(ops node:$in),
6132                     (sub ARMimmAllZerosD, node:$in)>;
6133def vnegq  : PatFrag<(ops node:$in),
6134                     (sub ARMimmAllZerosV, node:$in)>;
6135
6136class VNEGD<bits<2> size, string OpcodeStr, string Dt, ValueType Ty>
6137  : N2V<0b11, 0b11, size, 0b01, 0b00111, 0, 0, (outs DPR:$Vd), (ins DPR:$Vm),
6138        IIC_VSHLiD, OpcodeStr, Dt, "$Vd, $Vm", "",
6139        [(set DPR:$Vd, (Ty (vnegd DPR:$Vm)))]>;
6140class VNEGQ<bits<2> size, string OpcodeStr, string Dt, ValueType Ty>
6141  : N2V<0b11, 0b11, size, 0b01, 0b00111, 1, 0, (outs QPR:$Vd), (ins QPR:$Vm),
6142        IIC_VSHLiQ, OpcodeStr, Dt, "$Vd, $Vm", "",
6143        [(set QPR:$Vd, (Ty (vnegq QPR:$Vm)))]>;
6144
6145//   VNEG     : Vector Negate (integer)
6146def  VNEGs8d  : VNEGD<0b00, "vneg", "s8", v8i8>;
6147def  VNEGs16d : VNEGD<0b01, "vneg", "s16", v4i16>;
6148def  VNEGs32d : VNEGD<0b10, "vneg", "s32", v2i32>;
6149def  VNEGs8q  : VNEGQ<0b00, "vneg", "s8", v16i8>;
6150def  VNEGs16q : VNEGQ<0b01, "vneg", "s16", v8i16>;
6151def  VNEGs32q : VNEGQ<0b10, "vneg", "s32", v4i32>;
6152
6153//   VNEG     : Vector Negate (floating-point)
6154def  VNEGfd   : N2V<0b11, 0b11, 0b10, 0b01, 0b01111, 0, 0,
6155                    (outs DPR:$Vd), (ins DPR:$Vm), IIC_VUNAD,
6156                    "vneg", "f32", "$Vd, $Vm", "",
6157                    [(set DPR:$Vd, (v2f32 (fneg DPR:$Vm)))]>;
6158def  VNEGf32q : N2V<0b11, 0b11, 0b10, 0b01, 0b01111, 1, 0,
6159                    (outs QPR:$Vd), (ins QPR:$Vm), IIC_VUNAQ,
6160                    "vneg", "f32", "$Vd, $Vm", "",
6161                    [(set QPR:$Vd, (v4f32 (fneg QPR:$Vm)))]>;
6162def  VNEGhd   : N2V<0b11, 0b11, 0b01, 0b01, 0b01111, 0, 0,
6163                    (outs DPR:$Vd), (ins DPR:$Vm), IIC_VUNAD,
6164                    "vneg", "f16", "$Vd, $Vm", "",
6165                    [(set DPR:$Vd, (v4f16 (fneg DPR:$Vm)))]>,
6166                Requires<[HasNEON, HasFullFP16]>;
6167def  VNEGhq   : N2V<0b11, 0b11, 0b01, 0b01, 0b01111, 1, 0,
6168                    (outs QPR:$Vd), (ins QPR:$Vm), IIC_VUNAQ,
6169                    "vneg", "f16", "$Vd, $Vm", "",
6170                    [(set QPR:$Vd, (v8f16 (fneg QPR:$Vm)))]>,
6171                Requires<[HasNEON, HasFullFP16]>;
6172
6173let Predicates = [HasNEON] in {
6174def : Pat<(v8i8  (vnegd  DPR:$src)), (VNEGs8d DPR:$src)>;
6175def : Pat<(v4i16 (vnegd  DPR:$src)), (VNEGs16d DPR:$src)>;
6176def : Pat<(v2i32 (vnegd  DPR:$src)), (VNEGs32d DPR:$src)>;
6177def : Pat<(v16i8 (vnegq QPR:$src)), (VNEGs8q QPR:$src)>;
6178def : Pat<(v8i16 (vnegq QPR:$src)), (VNEGs16q QPR:$src)>;
6179def : Pat<(v4i32 (vnegq QPR:$src)), (VNEGs32q QPR:$src)>;
6180}
6181
6182//   VQNEG    : Vector Saturating Negate
6183defm VQNEG    : N2VInt_QHS<0b11, 0b11, 0b00, 0b01111, 0,
6184                           IIC_VQUNAiD, IIC_VQUNAiQ, "vqneg", "s",
6185                           int_arm_neon_vqneg>;
6186
6187// Vector Bit Counting Operations.
6188
6189//   VCLS     : Vector Count Leading Sign Bits
6190defm VCLS     : N2VInt_QHS<0b11, 0b11, 0b00, 0b01000, 0,
6191                           IIC_VCNTiD, IIC_VCNTiQ, "vcls", "s",
6192                           int_arm_neon_vcls>;
6193//   VCLZ     : Vector Count Leading Zeros
6194defm VCLZ     : N2VInt_QHS<0b11, 0b11, 0b00, 0b01001, 0,
6195                           IIC_VCNTiD, IIC_VCNTiQ, "vclz", "i",
6196                           ctlz>;
6197//   VCNT     : Vector Count One Bits
6198def  VCNTd    : N2VDInt<0b11, 0b11, 0b00, 0b00, 0b01010, 0,
6199                        IIC_VCNTiD, "vcnt", "8",
6200                        v8i8, v8i8, ctpop>;
6201def  VCNTq    : N2VQInt<0b11, 0b11, 0b00, 0b00, 0b01010, 0,
6202                        IIC_VCNTiQ, "vcnt", "8",
6203                        v16i8, v16i8, ctpop>;
6204
6205// Vector Swap
6206def  VSWPd    : N2VX<0b11, 0b11, 0b00, 0b10, 0b00000, 0, 0,
6207                     (outs DPR:$Vd, DPR:$Vm), (ins DPR:$in1, DPR:$in2),
6208                     NoItinerary, "vswp", "$Vd, $Vm", "$in1 = $Vd, $in2 = $Vm",
6209                     []>;
6210def  VSWPq    : N2VX<0b11, 0b11, 0b00, 0b10, 0b00000, 1, 0,
6211                     (outs QPR:$Vd, QPR:$Vm), (ins QPR:$in1, QPR:$in2),
6212                     NoItinerary, "vswp", "$Vd, $Vm", "$in1 = $Vd, $in2 = $Vm",
6213                     []>;
6214
6215// Vector Move Operations.
6216
6217//   VMOV     : Vector Move (Register)
6218def : NEONInstAlias<"vmov${p} $Vd, $Vm",
6219                    (VORRd DPR:$Vd, DPR:$Vm, DPR:$Vm, pred:$p)>;
6220def : NEONInstAlias<"vmov${p} $Vd, $Vm",
6221                    (VORRq QPR:$Vd, QPR:$Vm, QPR:$Vm, pred:$p)>;
6222
6223//   VMOV     : Vector Move (Immediate)
6224
6225// Although VMOVs are not strictly speaking cheap, they are as expensive
6226// as their copies counterpart (VORR), so we should prefer rematerialization
6227// over splitting when it applies.
6228let isReMaterializable = 1, isAsCheapAsAMove=1 in {
6229def VMOVv8i8  : N1ModImm<1, 0b000, 0b1110, 0, 0, 0, 1, (outs DPR:$Vd),
6230                         (ins nImmSplatI8:$SIMM), IIC_VMOVImm,
6231                         "vmov", "i8", "$Vd, $SIMM", "",
6232                         [(set DPR:$Vd, (v8i8 (ARMvmovImm timm:$SIMM)))]>;
6233def VMOVv16i8 : N1ModImm<1, 0b000, 0b1110, 0, 1, 0, 1, (outs QPR:$Vd),
6234                         (ins nImmSplatI8:$SIMM), IIC_VMOVImm,
6235                         "vmov", "i8", "$Vd, $SIMM", "",
6236                         [(set QPR:$Vd, (v16i8 (ARMvmovImm timm:$SIMM)))]>;
6237
6238def VMOVv4i16 : N1ModImm<1, 0b000, {1,0,?,0}, 0, 0, 0, 1, (outs DPR:$Vd),
6239                         (ins nImmSplatI16:$SIMM), IIC_VMOVImm,
6240                         "vmov", "i16", "$Vd, $SIMM", "",
6241                         [(set DPR:$Vd, (v4i16 (ARMvmovImm timm:$SIMM)))]> {
6242  let Inst{9} = SIMM{9};
6243}
6244
6245def VMOVv8i16 : N1ModImm<1, 0b000, {1,0,?,0}, 0, 1, 0, 1, (outs QPR:$Vd),
6246                         (ins nImmSplatI16:$SIMM), IIC_VMOVImm,
6247                         "vmov", "i16", "$Vd, $SIMM", "",
6248                         [(set QPR:$Vd, (v8i16 (ARMvmovImm timm:$SIMM)))]> {
6249 let Inst{9} = SIMM{9};
6250}
6251
6252def VMOVv2i32 : N1ModImm<1, 0b000, {?,?,?,?}, 0, 0, 0, 1, (outs DPR:$Vd),
6253                         (ins nImmVMOVI32:$SIMM), IIC_VMOVImm,
6254                         "vmov", "i32", "$Vd, $SIMM", "",
6255                         [(set DPR:$Vd, (v2i32 (ARMvmovImm timm:$SIMM)))]> {
6256  let Inst{11-8} = SIMM{11-8};
6257}
6258
6259def VMOVv4i32 : N1ModImm<1, 0b000, {?,?,?,?}, 0, 1, 0, 1, (outs QPR:$Vd),
6260                         (ins nImmVMOVI32:$SIMM), IIC_VMOVImm,
6261                         "vmov", "i32", "$Vd, $SIMM", "",
6262                         [(set QPR:$Vd, (v4i32 (ARMvmovImm timm:$SIMM)))]> {
6263  let Inst{11-8} = SIMM{11-8};
6264}
6265
6266def VMOVv1i64 : N1ModImm<1, 0b000, 0b1110, 0, 0, 1, 1, (outs DPR:$Vd),
6267                         (ins nImmSplatI64:$SIMM), IIC_VMOVImm,
6268                         "vmov", "i64", "$Vd, $SIMM", "",
6269                         [(set DPR:$Vd, (v1i64 (ARMvmovImm timm:$SIMM)))]>;
6270def VMOVv2i64 : N1ModImm<1, 0b000, 0b1110, 0, 1, 1, 1, (outs QPR:$Vd),
6271                         (ins nImmSplatI64:$SIMM), IIC_VMOVImm,
6272                         "vmov", "i64", "$Vd, $SIMM", "",
6273                         [(set QPR:$Vd, (v2i64 (ARMvmovImm timm:$SIMM)))]>;
6274
6275def VMOVv2f32 : N1ModImm<1, 0b000, 0b1111, 0, 0, 0, 1, (outs DPR:$Vd),
6276                         (ins nImmVMOVF32:$SIMM), IIC_VMOVImm,
6277                         "vmov", "f32", "$Vd, $SIMM", "",
6278                         [(set DPR:$Vd, (v2f32 (ARMvmovFPImm timm:$SIMM)))]>;
6279def VMOVv4f32 : N1ModImm<1, 0b000, 0b1111, 0, 1, 0, 1, (outs QPR:$Vd),
6280                         (ins nImmVMOVF32:$SIMM), IIC_VMOVImm,
6281                         "vmov", "f32", "$Vd, $SIMM", "",
6282                         [(set QPR:$Vd, (v4f32 (ARMvmovFPImm timm:$SIMM)))]>;
6283} // isReMaterializable, isAsCheapAsAMove
6284
6285// Add support for bytes replication feature, so it could be GAS compatible.
6286multiclass NEONImmReplicateI8InstAlias<ValueType To> {
6287  // E.g. instructions below:
6288  // "vmov.i32 d0, #0xffffffff"
6289  // "vmov.i32 d0, #0xabababab"
6290  // "vmov.i16 d0, #0xabab"
6291  // are incorrect, but we could deal with such cases.
6292  // For last two instructions, for example, it should emit:
6293  // "vmov.i8 d0, #0xab"
6294  def : NEONInstAlias<"vmov${p}.i" # To.Size # " $Vd, $Vm",
6295                      (VMOVv8i8 DPR:$Vd, nImmVMOVIReplicate<i8, To>:$Vm, pred:$p)>;
6296  def : NEONInstAlias<"vmov${p}.i" # To.Size # " $Vd, $Vm",
6297                      (VMOVv16i8 QPR:$Vd, nImmVMOVIReplicate<i8, To>:$Vm, pred:$p)>;
6298  // Also add same support for VMVN instructions. So instruction:
6299  // "vmvn.i32 d0, #0xabababab"
6300  // actually means:
6301  // "vmov.i8 d0, #0x54"
6302  def : NEONInstAlias<"vmvn${p}.i" # To.Size # " $Vd, $Vm",
6303                      (VMOVv8i8 DPR:$Vd, nImmVINVIReplicate<i8, To>:$Vm, pred:$p)>;
6304  def : NEONInstAlias<"vmvn${p}.i" # To.Size # " $Vd, $Vm",
6305                      (VMOVv16i8 QPR:$Vd, nImmVINVIReplicate<i8, To>:$Vm, pred:$p)>;
6306}
6307
6308defm : NEONImmReplicateI8InstAlias<i16>;
6309defm : NEONImmReplicateI8InstAlias<i32>;
6310defm : NEONImmReplicateI8InstAlias<i64>;
6311
6312// Similar to above for types other than i8, e.g.:
6313// "vmov.i32 d0, #0xab00ab00" -> "vmov.i16 d0, #0xab00"
6314// "vmvn.i64 q0, #0xab000000ab000000" -> "vmvn.i32 q0, #0xab000000"
6315// In this case we do not canonicalize VMVN to VMOV
6316multiclass NEONImmReplicateInstAlias<ValueType From, NeonI V8, NeonI V16,
6317                                     NeonI NV8, NeonI NV16, ValueType To> {
6318  def : NEONInstAlias<"vmov${p}.i" # To.Size # " $Vd, $Vm",
6319                      (V8 DPR:$Vd, nImmVMOVIReplicate<From, To>:$Vm, pred:$p)>;
6320  def : NEONInstAlias<"vmov${p}.i" # To.Size # " $Vd, $Vm",
6321                      (V16 QPR:$Vd, nImmVMOVIReplicate<From, To>:$Vm, pred:$p)>;
6322  def : NEONInstAlias<"vmvn${p}.i" # To.Size # " $Vd, $Vm",
6323                      (NV8 DPR:$Vd, nImmVMOVIReplicate<From, To>:$Vm, pred:$p)>;
6324  def : NEONInstAlias<"vmvn${p}.i" # To.Size # " $Vd, $Vm",
6325                      (NV16 QPR:$Vd, nImmVMOVIReplicate<From, To>:$Vm, pred:$p)>;
6326}
6327
6328defm : NEONImmReplicateInstAlias<i16, VMOVv4i16, VMOVv8i16,
6329                                      VMVNv4i16, VMVNv8i16, i32>;
6330defm : NEONImmReplicateInstAlias<i16, VMOVv4i16, VMOVv8i16,
6331                                      VMVNv4i16, VMVNv8i16, i64>;
6332defm : NEONImmReplicateInstAlias<i32, VMOVv2i32, VMOVv4i32,
6333                                      VMVNv2i32, VMVNv4i32, i64>;
6334// TODO: add "VMOV <-> VMVN" conversion for cases like
6335// "vmov.i32 d0, #0xffaaffaa" -> "vmvn.i16 d0, #0x55"
6336// "vmvn.i32 d0, #0xaaffaaff" -> "vmov.i16 d0, #0xff00"
6337
6338// On some CPUs the two instructions "vmov.i32 dD, #0" and "vmov.i32 qD, #0"
6339// require zero cycles to execute so they should be used wherever possible for
6340// setting a register to zero.
6341
6342// Even without these pseudo-insts we would probably end up with the correct
6343// instruction, but we could not mark the general ones with "isAsCheapAsAMove"
6344// since they are sometimes rather expensive (in general).
6345
6346let AddedComplexity = 50, isAsCheapAsAMove = 1, isReMaterializable = 1 in {
6347  def VMOVD0 : ARMPseudoExpand<(outs DPR:$Vd), (ins), 4, IIC_VMOVImm,
6348                               [(set DPR:$Vd, (v2i32 ARMimmAllZerosD))],
6349                               (VMOVv2i32 DPR:$Vd, 0, (ops 14, zero_reg))>,
6350               Requires<[HasZCZ]>;
6351  def VMOVQ0 : ARMPseudoExpand<(outs QPR:$Vd), (ins), 4, IIC_VMOVImm,
6352                               [(set QPR:$Vd, (v4i32 ARMimmAllZerosV))],
6353                               (VMOVv4i32 QPR:$Vd, 0, (ops 14, zero_reg))>,
6354               Requires<[HasZCZ]>;
6355}
6356
6357//   VMOV     : Vector Get Lane (move scalar to ARM core register)
6358
6359def VGETLNs8  : NVGetLane<{1,1,1,0,0,1,?,1}, 0b1011, {?,?},
6360                          (outs GPR:$R), (ins DPR:$V, VectorIndex8:$lane),
6361                          IIC_VMOVSI, "vmov", "s8", "$R, $V$lane",
6362                          [(set GPR:$R, (ARMvgetlanes (v8i8 DPR:$V),
6363                                           imm:$lane))]> {
6364  let Inst{21}  = lane{2};
6365  let Inst{6-5} = lane{1-0};
6366}
6367def VGETLNs16 : NVGetLane<{1,1,1,0,0,0,?,1}, 0b1011, {?,1},
6368                          (outs GPR:$R), (ins DPR:$V, VectorIndex16:$lane),
6369                          IIC_VMOVSI, "vmov", "s16", "$R, $V$lane",
6370                          [(set GPR:$R, (ARMvgetlanes (v4i16 DPR:$V),
6371                                           imm:$lane))]> {
6372  let Inst{21} = lane{1};
6373  let Inst{6}  = lane{0};
6374}
6375def VGETLNu8  : NVGetLane<{1,1,1,0,1,1,?,1}, 0b1011, {?,?},
6376                          (outs GPR:$R), (ins DPR:$V, VectorIndex8:$lane),
6377                          IIC_VMOVSI, "vmov", "u8", "$R, $V$lane",
6378                          [(set GPR:$R, (ARMvgetlaneu (v8i8 DPR:$V),
6379                                           imm:$lane))]> {
6380  let Inst{21}  = lane{2};
6381  let Inst{6-5} = lane{1-0};
6382}
6383def VGETLNu16 : NVGetLane<{1,1,1,0,1,0,?,1}, 0b1011, {?,1},
6384                          (outs GPR:$R), (ins DPR:$V, VectorIndex16:$lane),
6385                          IIC_VMOVSI, "vmov", "u16", "$R, $V$lane",
6386                          [(set GPR:$R, (ARMvgetlaneu (v4i16 DPR:$V),
6387                                           imm:$lane))]> {
6388  let Inst{21} = lane{1};
6389  let Inst{6}  = lane{0};
6390}
6391def VGETLNi32 : NVGetLane<{1,1,1,0,0,0,?,1}, 0b1011, 0b00,
6392                          (outs GPR:$R), (ins DPR:$V, VectorIndex32:$lane),
6393                          IIC_VMOVSI, "vmov", "32", "$R, $V$lane",
6394                          [(set GPR:$R, (extractelt (v2i32 DPR:$V),
6395                                           imm:$lane))]>,
6396                Requires<[HasFPRegs, HasFastVGETLNi32]> {
6397  let Inst{21} = lane{0};
6398}
6399// VGETLNi32 is also legal as just vmov r0,d0[0] without the .32 suffix
6400def : InstAlias<"vmov${p} $R, $V$lane",
6401    (VGETLNi32 GPR:$R, DPR:$V, VectorIndex32:$lane, pred:$p), 0>,
6402    Requires<VGETLNi32.Predicates>;
6403let Predicates = [HasNEON] in {
6404// def VGETLNf32: see FMRDH and FMRDL in ARMInstrVFP.td
6405def : Pat<(ARMvgetlanes (v16i8 QPR:$src), imm:$lane),
6406          (VGETLNs8 (v8i8 (EXTRACT_SUBREG QPR:$src,
6407                           (DSubReg_i8_reg imm:$lane))),
6408                     (SubReg_i8_lane imm:$lane))>;
6409def : Pat<(ARMvgetlanes (v8i16 QPR:$src), imm:$lane),
6410          (VGETLNs16 (v4i16 (EXTRACT_SUBREG QPR:$src,
6411                             (DSubReg_i16_reg imm:$lane))),
6412                     (SubReg_i16_lane imm:$lane))>;
6413def : Pat<(ARMvgetlaneu (v16i8 QPR:$src), imm:$lane),
6414          (VGETLNu8 (v8i8 (EXTRACT_SUBREG QPR:$src,
6415                           (DSubReg_i8_reg imm:$lane))),
6416                     (SubReg_i8_lane imm:$lane))>;
6417def : Pat<(ARMvgetlaneu (v8i16 QPR:$src), imm:$lane),
6418          (VGETLNu16 (v4i16 (EXTRACT_SUBREG QPR:$src,
6419                             (DSubReg_i16_reg imm:$lane))),
6420                     (SubReg_i16_lane imm:$lane))>;
6421def : Pat<(ARMvgetlaneu (v8f16 QPR:$src), imm:$lane),
6422          (VGETLNu16 (v4f16 (EXTRACT_SUBREG QPR:$src,
6423                             (DSubReg_i16_reg imm:$lane))),
6424                     (SubReg_i16_lane imm:$lane))>;
6425def : Pat<(ARMvgetlaneu (v4f16 DPR:$src), imm:$lane),
6426          (VGETLNu16 (v4f16 DPR:$src), imm:$lane)>;
6427def : Pat<(ARMvgetlaneu (v8bf16 QPR:$src), imm:$lane),
6428          (VGETLNu16 (v4bf16 (EXTRACT_SUBREG QPR:$src,
6429                             (DSubReg_i16_reg imm:$lane))),
6430                     (SubReg_i16_lane imm:$lane))>;
6431def : Pat<(ARMvgetlaneu (v4bf16 DPR:$src), imm:$lane),
6432          (VGETLNu16 (v4bf16 DPR:$src), imm:$lane)>;
6433}
6434def : Pat<(extractelt (v4i32 QPR:$src), imm:$lane),
6435          (VGETLNi32 (v2i32 (EXTRACT_SUBREG QPR:$src,
6436                             (DSubReg_i32_reg imm:$lane))),
6437                     (SubReg_i32_lane imm:$lane))>,
6438      Requires<[HasNEON, HasFastVGETLNi32]>;
6439def : Pat<(extractelt (v2i32 DPR:$src), imm:$lane),
6440          (COPY_TO_REGCLASS
6441            (i32 (EXTRACT_SUBREG DPR:$src, (SSubReg_f32_reg imm:$lane))), GPR)>,
6442      Requires<[HasNEON, HasSlowVGETLNi32]>;
6443def : Pat<(extractelt (v4i32 QPR:$src), imm:$lane),
6444          (COPY_TO_REGCLASS
6445            (i32 (EXTRACT_SUBREG QPR:$src, (SSubReg_f32_reg imm:$lane))), GPR)>,
6446      Requires<[HasNEON, HasSlowVGETLNi32]>;
6447let Predicates = [HasNEON] in {
6448def : Pat<(extractelt (v2f32 DPR:$src1), imm:$src2),
6449          (EXTRACT_SUBREG (v2f32 (COPY_TO_REGCLASS (v2f32 DPR:$src1),DPR_VFP2)),
6450                          (SSubReg_f32_reg imm:$src2))>;
6451def : Pat<(extractelt (v4f32 QPR:$src1), imm:$src2),
6452          (EXTRACT_SUBREG (v4f32 (COPY_TO_REGCLASS (v4f32 QPR:$src1),QPR_VFP2)),
6453                          (SSubReg_f32_reg imm:$src2))>;
6454//def : Pat<(extractelt (v2i64 QPR:$src1), imm:$src2),
6455//          (EXTRACT_SUBREG QPR:$src1, (DSubReg_f64_reg imm:$src2))>;
6456def : Pat<(extractelt (v2f64 QPR:$src1), imm:$src2),
6457          (EXTRACT_SUBREG QPR:$src1, (DSubReg_f64_reg imm:$src2))>;
6458}
6459
6460multiclass ExtractEltEvenF16<ValueType VT4, ValueType VT8> {
6461  def : Pat<(extractelt (VT4 DPR:$src), imm_even:$lane),
6462              (EXTRACT_SUBREG
6463                  (v2f32 (COPY_TO_REGCLASS (VT4 DPR:$src), DPR_VFP2)),
6464                  (SSubReg_f16_reg imm_even:$lane))>;
6465  def : Pat<(extractelt (VT8 QPR:$src), imm_even:$lane),
6466              (EXTRACT_SUBREG
6467                  (v4f32 (COPY_TO_REGCLASS (VT8 QPR:$src), QPR_VFP2)),
6468                  (SSubReg_f16_reg imm_even:$lane))>;
6469}
6470
6471multiclass ExtractEltOddF16VMOVH<ValueType VT4, ValueType VT8> {
6472  def : Pat<(extractelt (VT4 DPR:$src), imm_odd:$lane),
6473            (COPY_TO_REGCLASS
6474              (VMOVH (EXTRACT_SUBREG
6475                        (v2f32 (COPY_TO_REGCLASS (VT4 DPR:$src), DPR_VFP2)),
6476                        (SSubReg_f16_reg imm_odd:$lane))),
6477              HPR)>;
6478  def : Pat<(extractelt (VT8 QPR:$src), imm_odd:$lane),
6479            (COPY_TO_REGCLASS
6480              (VMOVH (EXTRACT_SUBREG
6481                        (v4f32 (COPY_TO_REGCLASS (VT8 QPR:$src), QPR_VFP2)),
6482                        (SSubReg_f16_reg imm_odd:$lane))),
6483              HPR)>;
6484}
6485
6486let Predicates = [HasNEON] in {
6487  defm : ExtractEltEvenF16<v4f16, v8f16>;
6488  defm : ExtractEltOddF16VMOVH<v4f16, v8f16>;
6489}
6490
6491let AddedComplexity = 1, Predicates = [HasNEON, HasBF16, HasFullFP16] in {
6492  // If VMOVH (vmovx.f16) is available use it to extract BF16 from the odd lanes
6493  defm : ExtractEltOddF16VMOVH<v4bf16, v8bf16>;
6494}
6495
6496let Predicates = [HasBF16, HasNEON] in {
6497  defm : ExtractEltEvenF16<v4bf16, v8bf16>;
6498
6499  // Otherwise, if VMOVH is not available resort to extracting the odd lane
6500  // into a GPR and then moving to HPR
6501  def : Pat<(extractelt (v4bf16 DPR:$src), imm_odd:$lane),
6502            (COPY_TO_REGCLASS
6503              (VGETLNu16 (v4bf16 DPR:$src), imm:$lane),
6504              HPR)>;
6505
6506  def : Pat<(extractelt (v8bf16 QPR:$src), imm_odd:$lane),
6507            (COPY_TO_REGCLASS
6508              (VGETLNu16 (v4i16 (EXTRACT_SUBREG QPR:$src,
6509                                                (DSubReg_i16_reg imm:$lane))),
6510                         (SubReg_i16_lane imm:$lane)),
6511              HPR)>;
6512}
6513
6514//   VMOV     : Vector Set Lane (move ARM core register to scalar)
6515
6516let Constraints = "$src1 = $V" in {
6517def VSETLNi8  : NVSetLane<{1,1,1,0,0,1,?,0}, 0b1011, {?,?}, (outs DPR:$V),
6518                          (ins DPR:$src1, GPR:$R, VectorIndex8:$lane),
6519                          IIC_VMOVISL, "vmov", "8", "$V$lane, $R",
6520                          [(set DPR:$V, (vector_insert (v8i8 DPR:$src1),
6521                                           GPR:$R, imm:$lane))]> {
6522  let Inst{21}  = lane{2};
6523  let Inst{6-5} = lane{1-0};
6524}
6525def VSETLNi16 : NVSetLane<{1,1,1,0,0,0,?,0}, 0b1011, {?,1}, (outs DPR:$V),
6526                          (ins DPR:$src1, GPR:$R, VectorIndex16:$lane),
6527                          IIC_VMOVISL, "vmov", "16", "$V$lane, $R",
6528                          [(set DPR:$V, (vector_insert (v4i16 DPR:$src1),
6529                                           GPR:$R, imm:$lane))]> {
6530  let Inst{21} = lane{1};
6531  let Inst{6}  = lane{0};
6532}
6533def VSETLNi32 : NVSetLane<{1,1,1,0,0,0,?,0}, 0b1011, 0b00, (outs DPR:$V),
6534                          (ins DPR:$src1, GPR:$R, VectorIndex32:$lane),
6535                          IIC_VMOVISL, "vmov", "32", "$V$lane, $R",
6536                          [(set DPR:$V, (insertelt (v2i32 DPR:$src1),
6537                                           GPR:$R, imm:$lane))]>,
6538                Requires<[HasVFP2]> {
6539  let Inst{21} = lane{0};
6540  // This instruction is equivalent as
6541  // $V = INSERT_SUBREG $src1, $R, translateImmToSubIdx($imm)
6542  let isInsertSubreg = 1;
6543}
6544}
6545// VSETLNi32 is also legal as just vmov d0[0],r0 without the .32 suffix
6546def : InstAlias<"vmov${p} $V$lane, $R",
6547    (VSETLNi32 DPR:$V, GPR:$R, VectorIndex32:$lane, pred:$p), 0>,
6548    Requires<VSETLNi32.Predicates>;
6549
6550// TODO: for odd lanes we could optimize this a bit by using the VINS
6551// FullFP16 instruction when it is available
6552multiclass InsertEltF16<ValueType VTScalar, ValueType VT4, ValueType VT8> {
6553  def : Pat<(insertelt (VT4 DPR:$src1), (VTScalar HPR:$src2), imm:$lane),
6554            (VT4 (VSETLNi16 DPR:$src1,
6555                 (COPY_TO_REGCLASS HPR:$src2, GPR), imm:$lane))>;
6556  def : Pat<(insertelt (VT8 QPR:$src1), (VTScalar HPR:$src2), imm:$lane),
6557            (VT8 (INSERT_SUBREG QPR:$src1,
6558                    (v4i16 (VSETLNi16 (v4i16 (EXTRACT_SUBREG QPR:$src1,
6559                                        (DSubReg_i16_reg imm:$lane))),
6560                              (COPY_TO_REGCLASS HPR:$src2, GPR),
6561                              (SubReg_i16_lane imm:$lane))),
6562                    (DSubReg_i16_reg imm:$lane)))>;
6563}
6564
6565let Predicates = [HasNEON] in {
6566def : Pat<(vector_insert (v16i8 QPR:$src1), GPR:$src2, imm:$lane),
6567          (v16i8 (INSERT_SUBREG QPR:$src1,
6568                  (v8i8 (VSETLNi8 (v8i8 (EXTRACT_SUBREG QPR:$src1,
6569                                   (DSubReg_i8_reg imm:$lane))),
6570                            GPR:$src2, (SubReg_i8_lane imm:$lane))),
6571                  (DSubReg_i8_reg imm:$lane)))>;
6572def : Pat<(vector_insert (v8i16 QPR:$src1), GPR:$src2, imm:$lane),
6573          (v8i16 (INSERT_SUBREG QPR:$src1,
6574                  (v4i16 (VSETLNi16 (v4i16 (EXTRACT_SUBREG QPR:$src1,
6575                                     (DSubReg_i16_reg imm:$lane))),
6576                             GPR:$src2, (SubReg_i16_lane imm:$lane))),
6577                  (DSubReg_i16_reg imm:$lane)))>;
6578def : Pat<(insertelt (v4i32 QPR:$src1), GPR:$src2, imm:$lane),
6579          (v4i32 (INSERT_SUBREG QPR:$src1,
6580                  (v2i32 (VSETLNi32 (v2i32 (EXTRACT_SUBREG QPR:$src1,
6581                                     (DSubReg_i32_reg imm:$lane))),
6582                             GPR:$src2, (SubReg_i32_lane imm:$lane))),
6583                  (DSubReg_i32_reg imm:$lane)))>;
6584
6585def : Pat<(v2f32 (insertelt DPR:$src1, SPR:$src2, imm:$src3)),
6586          (INSERT_SUBREG (v2f32 (COPY_TO_REGCLASS DPR:$src1, DPR_VFP2)),
6587                                SPR:$src2, (SSubReg_f32_reg imm:$src3))>;
6588def : Pat<(v4f32 (insertelt QPR:$src1, SPR:$src2, imm:$src3)),
6589          (INSERT_SUBREG (v4f32 (COPY_TO_REGCLASS QPR:$src1, QPR_VFP2)),
6590                                SPR:$src2, (SSubReg_f32_reg imm:$src3))>;
6591
6592defm : InsertEltF16<f16, v4f16, v8f16>;
6593
6594def : Pat<(v2f64 (insertelt QPR:$src1, DPR:$src2, imm:$src3)),
6595          (INSERT_SUBREG QPR:$src1, DPR:$src2, (DSubReg_f64_reg imm:$src3))>;
6596
6597def : Pat<(v2f32 (scalar_to_vector SPR:$src)),
6598          (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), SPR:$src, ssub_0)>;
6599def : Pat<(v2f64 (scalar_to_vector (f64 DPR:$src))),
6600          (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), DPR:$src, dsub_0)>;
6601def : Pat<(v4f32 (scalar_to_vector SPR:$src)),
6602          (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), SPR:$src, ssub_0)>;
6603
6604def : Pat<(v4f16 (scalar_to_vector (f16 HPR:$src))),
6605          (INSERT_SUBREG (v4f16 (IMPLICIT_DEF)), HPR:$src, ssub_0)>;
6606def : Pat<(v8f16 (scalar_to_vector (f16 HPR:$src))),
6607          (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), HPR:$src, ssub_0)>;
6608
6609def : Pat<(v8i8 (scalar_to_vector GPR:$src)),
6610          (VSETLNi8  (v8i8  (IMPLICIT_DEF)), GPR:$src, (i32 0))>;
6611def : Pat<(v4i16 (scalar_to_vector GPR:$src)),
6612          (VSETLNi16 (v4i16 (IMPLICIT_DEF)), GPR:$src, (i32 0))>;
6613def : Pat<(v2i32 (scalar_to_vector GPR:$src)),
6614          (VSETLNi32 (v2i32 (IMPLICIT_DEF)), GPR:$src, (i32 0))>;
6615
6616def : Pat<(v16i8 (scalar_to_vector GPR:$src)),
6617          (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
6618                         (VSETLNi8 (v8i8 (IMPLICIT_DEF)), GPR:$src, (i32 0)),
6619                         dsub_0)>;
6620def : Pat<(v8i16 (scalar_to_vector GPR:$src)),
6621          (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)),
6622                         (VSETLNi16 (v4i16 (IMPLICIT_DEF)), GPR:$src, (i32 0)),
6623                         dsub_0)>;
6624def : Pat<(v4i32 (scalar_to_vector GPR:$src)),
6625          (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)),
6626                         (VSETLNi32 (v2i32 (IMPLICIT_DEF)), GPR:$src, (i32 0)),
6627                         dsub_0)>;
6628}
6629
6630let Predicates = [HasNEON, HasBF16] in
6631defm : InsertEltF16<bf16, v4bf16, v8bf16>;
6632
6633//   VDUP     : Vector Duplicate (from ARM core register to all elements)
6634
6635class VDUPD<bits<8> opcod1, bits<2> opcod3, string Dt, ValueType Ty>
6636  : NVDup<opcod1, 0b1011, opcod3, (outs DPR:$V), (ins GPR:$R),
6637          IIC_VMOVIS, "vdup", Dt, "$V, $R",
6638          [(set DPR:$V, (Ty (ARMvdup (i32 GPR:$R))))]>;
6639class VDUPQ<bits<8> opcod1, bits<2> opcod3, string Dt, ValueType Ty>
6640  : NVDup<opcod1, 0b1011, opcod3, (outs QPR:$V), (ins GPR:$R),
6641          IIC_VMOVIS, "vdup", Dt, "$V, $R",
6642          [(set QPR:$V, (Ty (ARMvdup (i32 GPR:$R))))]>;
6643
6644def  VDUP8d   : VDUPD<0b11101100, 0b00, "8", v8i8>;
6645def  VDUP16d  : VDUPD<0b11101000, 0b01, "16", v4i16>;
6646def  VDUP32d  : VDUPD<0b11101000, 0b00, "32", v2i32>,
6647                Requires<[HasNEON, HasFastVDUP32]>;
6648def  VDUP8q   : VDUPQ<0b11101110, 0b00, "8", v16i8>;
6649def  VDUP16q  : VDUPQ<0b11101010, 0b01, "16", v8i16>;
6650def  VDUP32q  : VDUPQ<0b11101010, 0b00, "32", v4i32>;
6651
6652// ARMvdup patterns for uarchs with fast VDUP.32.
6653def : Pat<(v2f32 (ARMvdup (f32 (bitconvert GPR:$R)))), (VDUP32d GPR:$R)>,
6654      Requires<[HasNEON,HasFastVDUP32]>;
6655def : Pat<(v4f32 (ARMvdup (f32 (bitconvert GPR:$R)))), (VDUP32q GPR:$R)>,
6656      Requires<[HasNEON]>;
6657
6658// ARMvdup patterns for uarchs with slow VDUP.32 - use VMOVDRR instead.
6659def : Pat<(v2i32 (ARMvdup (i32 GPR:$R))), (VMOVDRR GPR:$R, GPR:$R)>,
6660      Requires<[HasNEON,HasSlowVDUP32]>;
6661def : Pat<(v2f32 (ARMvdup (f32 (bitconvert GPR:$R)))), (VMOVDRR GPR:$R, GPR:$R)>,
6662      Requires<[HasNEON,HasSlowVDUP32]>;
6663
6664//   VDUP     : Vector Duplicate Lane (from scalar to all elements)
6665
6666class VDUPLND<bits<4> op19_16, string OpcodeStr, string Dt,
6667              ValueType Ty, Operand IdxTy>
6668  : NVDupLane<op19_16, 0, (outs DPR:$Vd), (ins DPR:$Vm, IdxTy:$lane),
6669              IIC_VMOVD, OpcodeStr, Dt, "$Vd, $Vm$lane",
6670              [(set DPR:$Vd, (Ty (ARMvduplane (Ty DPR:$Vm), imm:$lane)))]>;
6671
6672class VDUPLNQ<bits<4> op19_16, string OpcodeStr, string Dt,
6673              ValueType ResTy, ValueType OpTy, Operand IdxTy>
6674  : NVDupLane<op19_16, 1, (outs QPR:$Vd), (ins DPR:$Vm, IdxTy:$lane),
6675              IIC_VMOVQ, OpcodeStr, Dt, "$Vd, $Vm$lane",
6676              [(set QPR:$Vd, (ResTy (ARMvduplane (OpTy DPR:$Vm),
6677                                      VectorIndex32:$lane)))]>;
6678
6679// Inst{19-16} is partially specified depending on the element size.
6680
6681def VDUPLN8d  : VDUPLND<{?,?,?,1}, "vdup", "8", v8i8, VectorIndex8> {
6682  bits<3> lane;
6683  let Inst{19-17} = lane{2-0};
6684}
6685def VDUPLN16d : VDUPLND<{?,?,1,0}, "vdup", "16", v4i16, VectorIndex16> {
6686  bits<2> lane;
6687  let Inst{19-18} = lane{1-0};
6688}
6689def VDUPLN32d : VDUPLND<{?,1,0,0}, "vdup", "32", v2i32, VectorIndex32> {
6690  bits<1> lane;
6691  let Inst{19} = lane{0};
6692}
6693def VDUPLN8q  : VDUPLNQ<{?,?,?,1}, "vdup", "8", v16i8, v8i8, VectorIndex8> {
6694  bits<3> lane;
6695  let Inst{19-17} = lane{2-0};
6696}
6697def VDUPLN16q : VDUPLNQ<{?,?,1,0}, "vdup", "16", v8i16, v4i16, VectorIndex16> {
6698  bits<2> lane;
6699  let Inst{19-18} = lane{1-0};
6700}
6701def VDUPLN32q : VDUPLNQ<{?,1,0,0}, "vdup", "32", v4i32, v2i32, VectorIndex32> {
6702  bits<1> lane;
6703  let Inst{19} = lane{0};
6704}
6705
6706let Predicates = [HasNEON] in {
6707def : Pat<(v4f16 (ARMvduplane (v4f16 DPR:$Vm), imm:$lane)),
6708          (VDUPLN16d DPR:$Vm, imm:$lane)>;
6709
6710def : Pat<(v2f32 (ARMvduplane (v2f32 DPR:$Vm), imm:$lane)),
6711          (VDUPLN32d DPR:$Vm, imm:$lane)>;
6712
6713def : Pat<(v4f32 (ARMvduplane (v2f32 DPR:$Vm), imm:$lane)),
6714          (VDUPLN32q DPR:$Vm, imm:$lane)>;
6715
6716def : Pat<(v16i8 (ARMvduplane (v16i8 QPR:$src), imm:$lane)),
6717          (v16i8 (VDUPLN8q (v8i8 (EXTRACT_SUBREG QPR:$src,
6718                                  (DSubReg_i8_reg imm:$lane))),
6719                           (SubReg_i8_lane imm:$lane)))>;
6720def : Pat<(v8i16 (ARMvduplane (v8i16 QPR:$src), imm:$lane)),
6721          (v8i16 (VDUPLN16q (v4i16 (EXTRACT_SUBREG QPR:$src,
6722                                    (DSubReg_i16_reg imm:$lane))),
6723                            (SubReg_i16_lane imm:$lane)))>;
6724def : Pat<(v8f16 (ARMvduplane (v8f16 QPR:$src), imm:$lane)),
6725          (v8f16 (VDUPLN16q (v4f16 (EXTRACT_SUBREG QPR:$src,
6726                                    (DSubReg_i16_reg imm:$lane))),
6727                            (SubReg_i16_lane imm:$lane)))>;
6728def : Pat<(v4i32 (ARMvduplane (v4i32 QPR:$src), imm:$lane)),
6729          (v4i32 (VDUPLN32q (v2i32 (EXTRACT_SUBREG QPR:$src,
6730                                    (DSubReg_i32_reg imm:$lane))),
6731                            (SubReg_i32_lane imm:$lane)))>;
6732def : Pat<(v4f32 (ARMvduplane (v4f32 QPR:$src), imm:$lane)),
6733          (v4f32 (VDUPLN32q (v2f32 (EXTRACT_SUBREG QPR:$src,
6734                                   (DSubReg_i32_reg imm:$lane))),
6735                           (SubReg_i32_lane imm:$lane)))>;
6736
6737def : Pat<(v4f16 (ARMvdup (f16 HPR:$src))),
6738          (v4f16 (VDUPLN16d (INSERT_SUBREG (v4f16 (IMPLICIT_DEF)),
6739                             (f16 HPR:$src), ssub_0), (i32 0)))>;
6740def : Pat<(v2f32 (ARMvdup (f32 SPR:$src))),
6741          (v2f32 (VDUPLN32d (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)),
6742                             SPR:$src, ssub_0), (i32 0)))>;
6743def : Pat<(v4f32 (ARMvdup (f32 SPR:$src))),
6744          (v4f32 (VDUPLN32q (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)),
6745                             SPR:$src, ssub_0), (i32 0)))>;
6746def : Pat<(v8f16 (ARMvdup (f16 HPR:$src))),
6747          (v8f16 (VDUPLN16q (INSERT_SUBREG (v4f16 (IMPLICIT_DEF)),
6748                             (f16 HPR:$src), ssub_0), (i32 0)))>;
6749}
6750
6751let Predicates = [HasNEON, HasBF16] in {
6752def : Pat<(v4bf16 (ARMvduplane (v4bf16 DPR:$Vm), imm:$lane)),
6753          (VDUPLN16d DPR:$Vm, imm:$lane)>;
6754
6755def : Pat<(v8bf16 (ARMvduplane (v8bf16 QPR:$src), imm:$lane)),
6756          (v8bf16 (VDUPLN16q (v4bf16 (EXTRACT_SUBREG QPR:$src,
6757                                    (DSubReg_i16_reg imm:$lane))),
6758                            (SubReg_i16_lane imm:$lane)))>;
6759
6760def : Pat<(v4bf16 (ARMvdup (bf16 HPR:$src))),
6761          (v4bf16 (VDUPLN16d (INSERT_SUBREG (v4bf16 (IMPLICIT_DEF)),
6762                             (bf16 HPR:$src), ssub_0), (i32 0)))>;
6763def : Pat<(v8bf16 (ARMvdup (bf16 HPR:$src))),
6764          (v8bf16 (VDUPLN16q (INSERT_SUBREG (v4bf16 (IMPLICIT_DEF)),
6765                             (bf16 HPR:$src), ssub_0), (i32 0)))>;
6766}
6767
6768//   VMOVN    : Vector Narrowing Move
6769defm VMOVN    : N2VN_HSD<0b11,0b11,0b10,0b00100,0,0, IIC_VMOVN,
6770                         "vmovn", "i", trunc>;
6771//   VQMOVN   : Vector Saturating Narrowing Move
6772defm VQMOVNs  : N2VNInt_HSD<0b11,0b11,0b10,0b00101,0,0, IIC_VQUNAiD,
6773                            "vqmovn", "s", int_arm_neon_vqmovns>;
6774defm VQMOVNu  : N2VNInt_HSD<0b11,0b11,0b10,0b00101,1,0, IIC_VQUNAiD,
6775                            "vqmovn", "u", int_arm_neon_vqmovnu>;
6776defm VQMOVNsu : N2VNInt_HSD<0b11,0b11,0b10,0b00100,1,0, IIC_VQUNAiD,
6777                            "vqmovun", "s", int_arm_neon_vqmovnsu>;
6778//   VMOVL    : Vector Lengthening Move
6779defm VMOVLs   : N2VL_QHS<0b01,0b10100,0,1, "vmovl", "s", sext>;
6780defm VMOVLu   : N2VL_QHS<0b11,0b10100,0,1, "vmovl", "u", zext>;
6781
6782let Predicates = [HasNEON] in {
6783def : Pat<(v8i16 (anyext (v8i8 DPR:$Vm))), (VMOVLuv8i16 DPR:$Vm)>;
6784def : Pat<(v4i32 (anyext (v4i16 DPR:$Vm))), (VMOVLuv4i32 DPR:$Vm)>;
6785def : Pat<(v2i64 (anyext (v2i32 DPR:$Vm))), (VMOVLuv2i64 DPR:$Vm)>;
6786}
6787
6788// Vector Conversions.
6789
6790//   VCVT     : Vector Convert Between Floating-Point and Integers
6791def  VCVTf2sd : N2VD<0b11, 0b11, 0b10, 0b11, 0b01110, 0, "vcvt", "s32.f32",
6792                     v2i32, v2f32, fp_to_sint>;
6793def  VCVTf2ud : N2VD<0b11, 0b11, 0b10, 0b11, 0b01111, 0, "vcvt", "u32.f32",
6794                     v2i32, v2f32, fp_to_uint>;
6795def  VCVTs2fd : N2VD<0b11, 0b11, 0b10, 0b11, 0b01100, 0, "vcvt", "f32.s32",
6796                     v2f32, v2i32, sint_to_fp>;
6797def  VCVTu2fd : N2VD<0b11, 0b11, 0b10, 0b11, 0b01101, 0, "vcvt", "f32.u32",
6798                     v2f32, v2i32, uint_to_fp>;
6799
6800def  VCVTf2sq : N2VQ<0b11, 0b11, 0b10, 0b11, 0b01110, 0, "vcvt", "s32.f32",
6801                     v4i32, v4f32, fp_to_sint>;
6802def  VCVTf2uq : N2VQ<0b11, 0b11, 0b10, 0b11, 0b01111, 0, "vcvt", "u32.f32",
6803                     v4i32, v4f32, fp_to_uint>;
6804def  VCVTs2fq : N2VQ<0b11, 0b11, 0b10, 0b11, 0b01100, 0, "vcvt", "f32.s32",
6805                     v4f32, v4i32, sint_to_fp>;
6806def  VCVTu2fq : N2VQ<0b11, 0b11, 0b10, 0b11, 0b01101, 0, "vcvt", "f32.u32",
6807                     v4f32, v4i32, uint_to_fp>;
6808
6809def  VCVTh2sd : N2VD<0b11, 0b11, 0b01, 0b11, 0b01110, 0, "vcvt", "s16.f16",
6810                     v4i16, v4f16, fp_to_sint>,
6811                Requires<[HasNEON, HasFullFP16]>;
6812def  VCVTh2ud : N2VD<0b11, 0b11, 0b01, 0b11, 0b01111, 0, "vcvt", "u16.f16",
6813                     v4i16, v4f16, fp_to_uint>,
6814                Requires<[HasNEON, HasFullFP16]>;
6815def  VCVTs2hd : N2VD<0b11, 0b11, 0b01, 0b11, 0b01100, 0, "vcvt", "f16.s16",
6816                     v4f16, v4i16, sint_to_fp>,
6817                Requires<[HasNEON, HasFullFP16]>;
6818def  VCVTu2hd : N2VD<0b11, 0b11, 0b01, 0b11, 0b01101, 0, "vcvt", "f16.u16",
6819                     v4f16, v4i16, uint_to_fp>,
6820                Requires<[HasNEON, HasFullFP16]>;
6821
6822def  VCVTh2sq : N2VQ<0b11, 0b11, 0b01, 0b11, 0b01110, 0, "vcvt", "s16.f16",
6823                     v8i16, v8f16, fp_to_sint>,
6824                Requires<[HasNEON, HasFullFP16]>;
6825def  VCVTh2uq : N2VQ<0b11, 0b11, 0b01, 0b11, 0b01111, 0, "vcvt", "u16.f16",
6826                     v8i16, v8f16, fp_to_uint>,
6827                Requires<[HasNEON, HasFullFP16]>;
6828def  VCVTs2hq : N2VQ<0b11, 0b11, 0b01, 0b11, 0b01100, 0, "vcvt", "f16.s16",
6829                     v8f16, v8i16, sint_to_fp>,
6830                Requires<[HasNEON, HasFullFP16]>;
6831def  VCVTu2hq : N2VQ<0b11, 0b11, 0b01, 0b11, 0b01101, 0, "vcvt", "f16.u16",
6832                     v8f16, v8i16, uint_to_fp>,
6833                Requires<[HasNEON, HasFullFP16]>;
6834
6835// VCVT{A, N, P, M}
6836multiclass VCVT_FPI<string op, bits<3> op10_8, SDPatternOperator IntS,
6837                    SDPatternOperator IntU> {
6838  let PostEncoderMethod = "NEONThumb2V8PostEncoder", DecoderNamespace = "v8NEON" in {
6839    def SDf : N2VDIntnp<0b10, 0b11, op10_8, 0, NoItinerary, !strconcat("vcvt", op),
6840                       "s32.f32", v2i32, v2f32, IntS>, Requires<[HasV8, HasNEON]>;
6841    def SQf : N2VQIntnp<0b10, 0b11, op10_8, 0, NoItinerary, !strconcat("vcvt", op),
6842                       "s32.f32", v4i32, v4f32, IntS>, Requires<[HasV8, HasNEON]>;
6843    def UDf : N2VDIntnp<0b10, 0b11, op10_8, 1, NoItinerary, !strconcat("vcvt", op),
6844                       "u32.f32", v2i32, v2f32, IntU>, Requires<[HasV8, HasNEON]>;
6845    def UQf : N2VQIntnp<0b10, 0b11, op10_8, 1, NoItinerary, !strconcat("vcvt", op),
6846                       "u32.f32", v4i32, v4f32, IntU>, Requires<[HasV8, HasNEON]>;
6847    def SDh : N2VDIntnp<0b01, 0b11, op10_8, 0, NoItinerary, !strconcat("vcvt", op),
6848                       "s16.f16", v4i16, v4f16, IntS>,
6849              Requires<[HasV8, HasNEON, HasFullFP16]>;
6850    def SQh : N2VQIntnp<0b01, 0b11, op10_8, 0, NoItinerary, !strconcat("vcvt", op),
6851                       "s16.f16", v8i16, v8f16, IntS>,
6852              Requires<[HasV8, HasNEON, HasFullFP16]>;
6853    def UDh : N2VDIntnp<0b01, 0b11, op10_8, 1, NoItinerary, !strconcat("vcvt", op),
6854                       "u16.f16", v4i16, v4f16, IntU>,
6855              Requires<[HasV8, HasNEON, HasFullFP16]>;
6856    def UQh : N2VQIntnp<0b01, 0b11, op10_8, 1, NoItinerary, !strconcat("vcvt", op),
6857                       "u16.f16", v8i16, v8f16, IntU>,
6858              Requires<[HasV8, HasNEON, HasFullFP16]>;
6859  }
6860}
6861
6862defm VCVTAN : VCVT_FPI<"a", 0b000, int_arm_neon_vcvtas, int_arm_neon_vcvtau>;
6863defm VCVTNN : VCVT_FPI<"n", 0b001, int_arm_neon_vcvtns, int_arm_neon_vcvtnu>;
6864defm VCVTPN : VCVT_FPI<"p", 0b010, int_arm_neon_vcvtps, int_arm_neon_vcvtpu>;
6865defm VCVTMN : VCVT_FPI<"m", 0b011, int_arm_neon_vcvtms, int_arm_neon_vcvtmu>;
6866
6867//   VCVT     : Vector Convert Between Floating-Point and Fixed-Point.
6868let DecoderMethod = "DecodeVCVTD" in {
6869def VCVTf2xsd : N2VCvtD<0, 1, 0b1111, 0, 1, "vcvt", "s32.f32",
6870                        v2i32, v2f32, int_arm_neon_vcvtfp2fxs>;
6871def VCVTf2xud : N2VCvtD<1, 1, 0b1111, 0, 1, "vcvt", "u32.f32",
6872                        v2i32, v2f32, int_arm_neon_vcvtfp2fxu>;
6873def VCVTxs2fd : N2VCvtD<0, 1, 0b1110, 0, 1, "vcvt", "f32.s32",
6874                        v2f32, v2i32, int_arm_neon_vcvtfxs2fp>;
6875def VCVTxu2fd : N2VCvtD<1, 1, 0b1110, 0, 1, "vcvt", "f32.u32",
6876                        v2f32, v2i32, int_arm_neon_vcvtfxu2fp>;
6877let Predicates = [HasNEON, HasFullFP16] in {
6878def VCVTh2xsd : N2VCvtD<0, 1, 0b1101, 0, 1, "vcvt", "s16.f16",
6879                        v4i16, v4f16, int_arm_neon_vcvtfp2fxs>;
6880def VCVTh2xud : N2VCvtD<1, 1, 0b1101, 0, 1, "vcvt", "u16.f16",
6881                        v4i16, v4f16, int_arm_neon_vcvtfp2fxu>;
6882def VCVTxs2hd : N2VCvtD<0, 1, 0b1100, 0, 1, "vcvt", "f16.s16",
6883                        v4f16, v4i16, int_arm_neon_vcvtfxs2fp>;
6884def VCVTxu2hd : N2VCvtD<1, 1, 0b1100, 0, 1, "vcvt", "f16.u16",
6885                        v4f16, v4i16, int_arm_neon_vcvtfxu2fp>;
6886} // Predicates = [HasNEON, HasFullFP16]
6887}
6888
6889let DecoderMethod = "DecodeVCVTQ" in {
6890def VCVTf2xsq : N2VCvtQ<0, 1, 0b1111, 0, 1, "vcvt", "s32.f32",
6891                        v4i32, v4f32, int_arm_neon_vcvtfp2fxs>;
6892def VCVTf2xuq : N2VCvtQ<1, 1, 0b1111, 0, 1, "vcvt", "u32.f32",
6893                        v4i32, v4f32, int_arm_neon_vcvtfp2fxu>;
6894def VCVTxs2fq : N2VCvtQ<0, 1, 0b1110, 0, 1, "vcvt", "f32.s32",
6895                        v4f32, v4i32, int_arm_neon_vcvtfxs2fp>;
6896def VCVTxu2fq : N2VCvtQ<1, 1, 0b1110, 0, 1, "vcvt", "f32.u32",
6897                        v4f32, v4i32, int_arm_neon_vcvtfxu2fp>;
6898let Predicates = [HasNEON, HasFullFP16] in {
6899def VCVTh2xsq : N2VCvtQ<0, 1, 0b1101, 0, 1, "vcvt", "s16.f16",
6900                        v8i16, v8f16, int_arm_neon_vcvtfp2fxs>;
6901def VCVTh2xuq : N2VCvtQ<1, 1, 0b1101, 0, 1, "vcvt", "u16.f16",
6902                        v8i16, v8f16, int_arm_neon_vcvtfp2fxu>;
6903def VCVTxs2hq : N2VCvtQ<0, 1, 0b1100, 0, 1, "vcvt", "f16.s16",
6904                        v8f16, v8i16, int_arm_neon_vcvtfxs2fp>;
6905def VCVTxu2hq : N2VCvtQ<1, 1, 0b1100, 0, 1, "vcvt", "f16.u16",
6906                        v8f16, v8i16, int_arm_neon_vcvtfxu2fp>;
6907} // Predicates = [HasNEON, HasFullFP16]
6908}
6909
6910def : NEONInstAlias<"vcvt${p}.s32.f32 $Dd, $Dm, #0",
6911                    (VCVTf2sd DPR:$Dd, DPR:$Dm, pred:$p)>;
6912def : NEONInstAlias<"vcvt${p}.u32.f32 $Dd, $Dm, #0",
6913                    (VCVTf2ud DPR:$Dd, DPR:$Dm, pred:$p)>;
6914def : NEONInstAlias<"vcvt${p}.f32.s32 $Dd, $Dm, #0",
6915                    (VCVTs2fd DPR:$Dd, DPR:$Dm, pred:$p)>;
6916def : NEONInstAlias<"vcvt${p}.f32.u32 $Dd, $Dm, #0",
6917                    (VCVTu2fd DPR:$Dd, DPR:$Dm, pred:$p)>;
6918
6919def : NEONInstAlias<"vcvt${p}.s32.f32 $Qd, $Qm, #0",
6920                    (VCVTf2sq QPR:$Qd, QPR:$Qm, pred:$p)>;
6921def : NEONInstAlias<"vcvt${p}.u32.f32 $Qd, $Qm, #0",
6922                    (VCVTf2uq QPR:$Qd, QPR:$Qm, pred:$p)>;
6923def : NEONInstAlias<"vcvt${p}.f32.s32 $Qd, $Qm, #0",
6924                    (VCVTs2fq QPR:$Qd, QPR:$Qm, pred:$p)>;
6925def : NEONInstAlias<"vcvt${p}.f32.u32 $Qd, $Qm, #0",
6926                    (VCVTu2fq QPR:$Qd, QPR:$Qm, pred:$p)>;
6927
6928def : NEONInstAlias<"vcvt${p}.s16.f16 $Dd, $Dm, #0",
6929                    (VCVTh2sd DPR:$Dd, DPR:$Dm, pred:$p)>;
6930def : NEONInstAlias<"vcvt${p}.u16.f16 $Dd, $Dm, #0",
6931                    (VCVTh2ud DPR:$Dd, DPR:$Dm, pred:$p)>;
6932def : NEONInstAlias<"vcvt${p}.f16.s16 $Dd, $Dm, #0",
6933                    (VCVTs2hd DPR:$Dd, DPR:$Dm, pred:$p)>;
6934def : NEONInstAlias<"vcvt${p}.f16.u16 $Dd, $Dm, #0",
6935                    (VCVTu2hd DPR:$Dd, DPR:$Dm, pred:$p)>;
6936
6937def : NEONInstAlias<"vcvt${p}.s16.f16 $Qd, $Qm, #0",
6938                    (VCVTh2sq QPR:$Qd, QPR:$Qm, pred:$p)>;
6939def : NEONInstAlias<"vcvt${p}.u16.f16 $Qd, $Qm, #0",
6940                    (VCVTh2uq QPR:$Qd, QPR:$Qm, pred:$p)>;
6941def : NEONInstAlias<"vcvt${p}.f16.s16 $Qd, $Qm, #0",
6942                    (VCVTs2hq QPR:$Qd, QPR:$Qm, pred:$p)>;
6943def : NEONInstAlias<"vcvt${p}.f16.u16 $Qd, $Qm, #0",
6944                    (VCVTu2hq QPR:$Qd, QPR:$Qm, pred:$p)>;
6945
6946
6947//   VCVT     : Vector Convert Between Half-Precision and Single-Precision.
6948def  VCVTf2h  : N2VNInt<0b11, 0b11, 0b01, 0b10, 0b01100, 0, 0,
6949                        IIC_VUNAQ, "vcvt", "f16.f32",
6950                        v4i16, v4f32, int_arm_neon_vcvtfp2hf>,
6951                Requires<[HasNEON, HasFP16]>;
6952def  VCVTh2f  : N2VLInt<0b11, 0b11, 0b01, 0b10, 0b01110, 0, 0,
6953                        IIC_VUNAQ, "vcvt", "f32.f16",
6954                        v4f32, v4i16, int_arm_neon_vcvthf2fp>,
6955                Requires<[HasNEON, HasFP16]>;
6956
6957def : Pat<(v4f16 (fpround (v4f32 QPR:$src))), (VCVTf2h QPR:$src)>;
6958def : Pat<(v4f32 (fpextend (v4f16 DPR:$src))), (VCVTh2f DPR:$src)>;
6959
6960// Vector Reverse.
6961
6962//   VREV64   : Vector Reverse elements within 64-bit doublewords
6963
6964class VREV64D<bits<2> op19_18, string OpcodeStr, string Dt, ValueType Ty>
6965  : N2V<0b11, 0b11, op19_18, 0b00, 0b00000, 0, 0, (outs DPR:$Vd),
6966        (ins DPR:$Vm), IIC_VMOVD,
6967        OpcodeStr, Dt, "$Vd, $Vm", "",
6968        [(set DPR:$Vd, (Ty (ARMvrev64 (Ty DPR:$Vm))))]>;
6969class VREV64Q<bits<2> op19_18, string OpcodeStr, string Dt, ValueType Ty>
6970  : N2V<0b11, 0b11, op19_18, 0b00, 0b00000, 1, 0, (outs QPR:$Vd),
6971        (ins QPR:$Vm), IIC_VMOVQ,
6972        OpcodeStr, Dt, "$Vd, $Vm", "",
6973        [(set QPR:$Vd, (Ty (ARMvrev64 (Ty QPR:$Vm))))]>;
6974
6975def VREV64d8  : VREV64D<0b00, "vrev64", "8", v8i8>;
6976def VREV64d16 : VREV64D<0b01, "vrev64", "16", v4i16>;
6977def VREV64d32 : VREV64D<0b10, "vrev64", "32", v2i32>;
6978let Predicates = [HasNEON] in {
6979def : Pat<(v2f32 (ARMvrev64 (v2f32 DPR:$Vm))), (VREV64d32 DPR:$Vm)>;
6980}
6981
6982def VREV64q8  : VREV64Q<0b00, "vrev64", "8", v16i8>;
6983def VREV64q16 : VREV64Q<0b01, "vrev64", "16", v8i16>;
6984def VREV64q32 : VREV64Q<0b10, "vrev64", "32", v4i32>;
6985
6986let Predicates = [HasNEON] in {
6987  def : Pat<(v4f32 (ARMvrev64 (v4f32 QPR:$Vm))),
6988            (VREV64q32 QPR:$Vm)>;
6989  def : Pat<(v8f16 (ARMvrev64 (v8f16 QPR:$Vm))),
6990            (VREV64q16 QPR:$Vm)>;
6991  def : Pat<(v4f16 (ARMvrev64 (v4f16 DPR:$Vm))),
6992            (VREV64d16 DPR:$Vm)>;
6993  def : Pat<(v8bf16 (ARMvrev64 (v8bf16 QPR:$Vm))),
6994            (VREV64q16 QPR:$Vm)>;
6995  def : Pat<(v4bf16 (ARMvrev64 (v4bf16 DPR:$Vm))),
6996            (VREV64d16 DPR:$Vm)>;
6997}
6998
6999//   VREV32   : Vector Reverse elements within 32-bit words
7000
7001class VREV32D<bits<2> op19_18, string OpcodeStr, string Dt, ValueType Ty>
7002  : N2V<0b11, 0b11, op19_18, 0b00, 0b00001, 0, 0, (outs DPR:$Vd),
7003        (ins DPR:$Vm), IIC_VMOVD,
7004        OpcodeStr, Dt, "$Vd, $Vm", "",
7005        [(set DPR:$Vd, (Ty (ARMvrev32 (Ty DPR:$Vm))))]>;
7006class VREV32Q<bits<2> op19_18, string OpcodeStr, string Dt, ValueType Ty>
7007  : N2V<0b11, 0b11, op19_18, 0b00, 0b00001, 1, 0, (outs QPR:$Vd),
7008        (ins QPR:$Vm), IIC_VMOVQ,
7009        OpcodeStr, Dt, "$Vd, $Vm", "",
7010        [(set QPR:$Vd, (Ty (ARMvrev32 (Ty QPR:$Vm))))]>;
7011
7012def VREV32d8  : VREV32D<0b00, "vrev32", "8", v8i8>;
7013def VREV32d16 : VREV32D<0b01, "vrev32", "16", v4i16>;
7014
7015def VREV32q8  : VREV32Q<0b00, "vrev32", "8", v16i8>;
7016def VREV32q16 : VREV32Q<0b01, "vrev32", "16", v8i16>;
7017
7018let Predicates = [HasNEON] in {
7019  def : Pat<(v8f16 (ARMvrev32 (v8f16 QPR:$Vm))),
7020            (VREV32q16 QPR:$Vm)>;
7021  def : Pat<(v4f16 (ARMvrev32 (v4f16 DPR:$Vm))),
7022            (VREV32d16 DPR:$Vm)>;
7023  def : Pat<(v8bf16 (ARMvrev32 (v8bf16 QPR:$Vm))),
7024            (VREV32q16 QPR:$Vm)>;
7025  def : Pat<(v4bf16 (ARMvrev32 (v4bf16 DPR:$Vm))),
7026            (VREV32d16 DPR:$Vm)>;
7027}
7028
7029//   VREV16   : Vector Reverse elements within 16-bit halfwords
7030
7031class VREV16D<bits<2> op19_18, string OpcodeStr, string Dt, ValueType Ty>
7032  : N2V<0b11, 0b11, op19_18, 0b00, 0b00010, 0, 0, (outs DPR:$Vd),
7033        (ins DPR:$Vm), IIC_VMOVD,
7034        OpcodeStr, Dt, "$Vd, $Vm", "",
7035        [(set DPR:$Vd, (Ty (ARMvrev16 (Ty DPR:$Vm))))]>;
7036class VREV16Q<bits<2> op19_18, string OpcodeStr, string Dt, ValueType Ty>
7037  : N2V<0b11, 0b11, op19_18, 0b00, 0b00010, 1, 0, (outs QPR:$Vd),
7038        (ins QPR:$Vm), IIC_VMOVQ,
7039        OpcodeStr, Dt, "$Vd, $Vm", "",
7040        [(set QPR:$Vd, (Ty (ARMvrev16 (Ty QPR:$Vm))))]>;
7041
7042def VREV16d8  : VREV16D<0b00, "vrev16", "8", v8i8>;
7043def VREV16q8  : VREV16Q<0b00, "vrev16", "8", v16i8>;
7044
7045// Other Vector Shuffles.
7046
7047//  Aligned extractions: really just dropping registers
7048
7049class AlignedVEXTq<ValueType DestTy, ValueType SrcTy, SDNodeXForm LaneCVT>
7050      : Pat<(DestTy (vector_extract_subvec (SrcTy QPR:$src), (i32 imm:$start))),
7051             (EXTRACT_SUBREG (SrcTy QPR:$src), (LaneCVT imm:$start))>,
7052        Requires<[HasNEON]>;
7053
7054def : AlignedVEXTq<v8i8, v16i8, DSubReg_i8_reg>;
7055def : AlignedVEXTq<v4i16, v8i16, DSubReg_i16_reg>;
7056def : AlignedVEXTq<v2i32, v4i32, DSubReg_i32_reg>;
7057def : AlignedVEXTq<v1i64, v2i64, DSubReg_f64_reg>;
7058def : AlignedVEXTq<v2f32, v4f32, DSubReg_i32_reg>;
7059def : AlignedVEXTq<v4f16, v8f16, DSubReg_i16_reg>;
7060def : AlignedVEXTq<v4bf16, v8bf16, DSubReg_i16_reg>;
7061
7062
7063//   VEXT     : Vector Extract
7064
7065// All of these have a two-operand InstAlias.
7066let TwoOperandAliasConstraint = "$Vn = $Vd" in {
7067class VEXTd<string OpcodeStr, string Dt, ValueType Ty, Operand immTy>
7068  : N3V<0,1,0b11,{?,?,?,?},0,0, (outs DPR:$Vd),
7069        (ins DPR:$Vn, DPR:$Vm, immTy:$index), NVExtFrm,
7070        IIC_VEXTD, OpcodeStr, Dt, "$Vd, $Vn, $Vm, $index", "",
7071        [(set DPR:$Vd, (Ty (NEONvext (Ty DPR:$Vn),
7072                                     (Ty DPR:$Vm), imm:$index)))]> {
7073  bits<3> index;
7074  let Inst{11} = 0b0;
7075  let Inst{10-8} = index{2-0};
7076}
7077
7078class VEXTq<string OpcodeStr, string Dt, ValueType Ty, Operand immTy>
7079  : N3V<0,1,0b11,{?,?,?,?},1,0, (outs QPR:$Vd),
7080        (ins QPR:$Vn, QPR:$Vm, immTy:$index), NVExtFrm,
7081        IIC_VEXTQ, OpcodeStr, Dt, "$Vd, $Vn, $Vm, $index", "",
7082        [(set QPR:$Vd, (Ty (NEONvext (Ty QPR:$Vn),
7083                                     (Ty QPR:$Vm), imm:$index)))]> {
7084  bits<4> index;
7085  let Inst{11-8} = index{3-0};
7086}
7087}
7088
7089def VEXTd8  : VEXTd<"vext", "8",  v8i8, imm0_7> {
7090  let Inst{10-8} = index{2-0};
7091}
7092def VEXTd16 : VEXTd<"vext", "16", v4i16, imm0_3> {
7093  let Inst{10-9} = index{1-0};
7094  let Inst{8}    = 0b0;
7095}
7096let Predicates = [HasNEON] in {
7097def : Pat<(v4f16 (NEONvext (v4f16 DPR:$Vn), (v4f16 DPR:$Vm), (i32 imm:$index))),
7098          (VEXTd16 DPR:$Vn, DPR:$Vm, imm:$index)>;
7099def : Pat<(v4bf16 (NEONvext (v4bf16 DPR:$Vn), (v4bf16 DPR:$Vm), (i32 imm:$index))),
7100          (VEXTd16 DPR:$Vn, DPR:$Vm, imm:$index)>;
7101}
7102
7103def VEXTd32 : VEXTd<"vext", "32", v2i32, imm0_1> {
7104  let Inst{10}     = index{0};
7105  let Inst{9-8}    = 0b00;
7106}
7107let Predicates = [HasNEON] in {
7108def : Pat<(v2f32 (NEONvext (v2f32 DPR:$Vn), (v2f32 DPR:$Vm), (i32 imm:$index))),
7109          (VEXTd32 DPR:$Vn, DPR:$Vm, imm:$index)>;
7110}
7111
7112def VEXTq8  : VEXTq<"vext", "8",  v16i8, imm0_15> {
7113  let Inst{11-8} = index{3-0};
7114}
7115def VEXTq16 : VEXTq<"vext", "16", v8i16, imm0_7> {
7116  let Inst{11-9} = index{2-0};
7117  let Inst{8}    = 0b0;
7118}
7119let Predicates = [HasNEON] in {
7120def : Pat<(v8f16 (NEONvext (v8f16 QPR:$Vn), (v8f16 QPR:$Vm), (i32 imm:$index))),
7121          (VEXTq16 QPR:$Vn, QPR:$Vm, imm:$index)>;
7122def : Pat<(v8bf16 (NEONvext (v8bf16 QPR:$Vn), (v8bf16 QPR:$Vm), (i32 imm:$index))),
7123          (VEXTq16 QPR:$Vn, QPR:$Vm, imm:$index)>;
7124}
7125
7126def VEXTq32 : VEXTq<"vext", "32", v4i32, imm0_3> {
7127  let Inst{11-10} = index{1-0};
7128  let Inst{9-8}    = 0b00;
7129}
7130def VEXTq64 : VEXTq<"vext", "64", v2i64, imm0_1> {
7131  let Inst{11} = index{0};
7132  let Inst{10-8}    = 0b000;
7133}
7134let Predicates = [HasNEON] in {
7135def : Pat<(v4f32 (NEONvext (v4f32 QPR:$Vn), (v4f32 QPR:$Vm), (i32 imm:$index))),
7136          (VEXTq32 QPR:$Vn, QPR:$Vm, imm:$index)>;
7137}
7138
7139//   VTRN     : Vector Transpose
7140
7141def  VTRNd8   : N2VDShuffle<0b00, 0b00001, "vtrn", "8">;
7142def  VTRNd16  : N2VDShuffle<0b01, 0b00001, "vtrn", "16">;
7143def  VTRNd32  : N2VDShuffle<0b10, 0b00001, "vtrn", "32">;
7144
7145def  VTRNq8   : N2VQShuffle<0b00, 0b00001, IIC_VPERMQ, "vtrn", "8">;
7146def  VTRNq16  : N2VQShuffle<0b01, 0b00001, IIC_VPERMQ, "vtrn", "16">;
7147def  VTRNq32  : N2VQShuffle<0b10, 0b00001, IIC_VPERMQ, "vtrn", "32">;
7148
7149//   VUZP     : Vector Unzip (Deinterleave)
7150
7151def  VUZPd8   : N2VDShuffle<0b00, 0b00010, "vuzp", "8">;
7152def  VUZPd16  : N2VDShuffle<0b01, 0b00010, "vuzp", "16">;
7153// vuzp.32 Dd, Dm is a pseudo-instruction expanded to vtrn.32 Dd, Dm.
7154def : NEONInstAlias<"vuzp${p}.32 $Dd, $Dm",
7155                    (VTRNd32 DPR:$Dd, DPR:$Dm, pred:$p)>;
7156
7157def  VUZPq8   : N2VQShuffle<0b00, 0b00010, IIC_VPERMQ3, "vuzp", "8">;
7158def  VUZPq16  : N2VQShuffle<0b01, 0b00010, IIC_VPERMQ3, "vuzp", "16">;
7159def  VUZPq32  : N2VQShuffle<0b10, 0b00010, IIC_VPERMQ3, "vuzp", "32">;
7160
7161//   VZIP     : Vector Zip (Interleave)
7162
7163def  VZIPd8   : N2VDShuffle<0b00, 0b00011, "vzip", "8">;
7164def  VZIPd16  : N2VDShuffle<0b01, 0b00011, "vzip", "16">;
7165// vzip.32 Dd, Dm is a pseudo-instruction expanded to vtrn.32 Dd, Dm.
7166def : NEONInstAlias<"vzip${p}.32 $Dd, $Dm",
7167                    (VTRNd32 DPR:$Dd, DPR:$Dm, pred:$p)>;
7168
7169def  VZIPq8   : N2VQShuffle<0b00, 0b00011, IIC_VPERMQ3, "vzip", "8">;
7170def  VZIPq16  : N2VQShuffle<0b01, 0b00011, IIC_VPERMQ3, "vzip", "16">;
7171def  VZIPq32  : N2VQShuffle<0b10, 0b00011, IIC_VPERMQ3, "vzip", "32">;
7172
7173// Vector Table Lookup and Table Extension.
7174
7175//   VTBL     : Vector Table Lookup
7176let DecoderMethod = "DecodeTBLInstruction" in {
7177def  VTBL1
7178  : N3V<1,1,0b11,0b1000,0,0, (outs DPR:$Vd),
7179        (ins VecListOneD:$Vn, DPR:$Vm), NVTBLFrm, IIC_VTB1,
7180        "vtbl", "8", "$Vd, $Vn, $Vm", "",
7181        [(set DPR:$Vd, (v8i8 (NEONvtbl1 VecListOneD:$Vn, DPR:$Vm)))]>;
7182
7183let hasExtraSrcRegAllocReq = 1 in {
7184def  VTBL2
7185  : N3V<1,1,0b11,0b1001,0,0, (outs DPR:$Vd),
7186        (ins VecListDPair:$Vn, DPR:$Vm), NVTBLFrm, IIC_VTB2,
7187        "vtbl", "8", "$Vd, $Vn, $Vm", "", []>;
7188def  VTBL3
7189  : N3V<1,1,0b11,0b1010,0,0, (outs DPR:$Vd),
7190        (ins VecListThreeD:$Vn, DPR:$Vm), NVTBLFrm, IIC_VTB3,
7191        "vtbl", "8", "$Vd, $Vn, $Vm", "", []>;
7192def  VTBL4
7193  : N3V<1,1,0b11,0b1011,0,0, (outs DPR:$Vd),
7194        (ins VecListFourD:$Vn, DPR:$Vm),
7195        NVTBLFrm, IIC_VTB4,
7196        "vtbl", "8", "$Vd, $Vn, $Vm", "", []>;
7197} // hasExtraSrcRegAllocReq = 1
7198
7199def  VTBL3Pseudo
7200  : PseudoNeonI<(outs DPR:$dst), (ins QQPR:$tbl, DPR:$src), IIC_VTB3, "", []>;
7201def  VTBL4Pseudo
7202  : PseudoNeonI<(outs DPR:$dst), (ins QQPR:$tbl, DPR:$src), IIC_VTB4, "", []>;
7203
7204//   VTBX     : Vector Table Extension
7205def  VTBX1
7206  : N3V<1,1,0b11,0b1000,1,0, (outs DPR:$Vd),
7207        (ins DPR:$orig, VecListOneD:$Vn, DPR:$Vm), NVTBLFrm, IIC_VTBX1,
7208        "vtbx", "8", "$Vd, $Vn, $Vm", "$orig = $Vd",
7209        [(set DPR:$Vd, (v8i8 (int_arm_neon_vtbx1
7210                               DPR:$orig, VecListOneD:$Vn, DPR:$Vm)))]>;
7211let hasExtraSrcRegAllocReq = 1 in {
7212def  VTBX2
7213  : N3V<1,1,0b11,0b1001,1,0, (outs DPR:$Vd),
7214        (ins DPR:$orig, VecListDPair:$Vn, DPR:$Vm), NVTBLFrm, IIC_VTBX2,
7215        "vtbx", "8", "$Vd, $Vn, $Vm", "$orig = $Vd", []>;
7216def  VTBX3
7217  : N3V<1,1,0b11,0b1010,1,0, (outs DPR:$Vd),
7218        (ins DPR:$orig, VecListThreeD:$Vn, DPR:$Vm),
7219        NVTBLFrm, IIC_VTBX3,
7220        "vtbx", "8", "$Vd, $Vn, $Vm",
7221        "$orig = $Vd", []>;
7222def  VTBX4
7223  : N3V<1,1,0b11,0b1011,1,0, (outs DPR:$Vd),
7224        (ins DPR:$orig, VecListFourD:$Vn, DPR:$Vm), NVTBLFrm, IIC_VTBX4,
7225        "vtbx", "8", "$Vd, $Vn, $Vm",
7226        "$orig = $Vd", []>;
7227} // hasExtraSrcRegAllocReq = 1
7228
7229def  VTBX3Pseudo
7230  : PseudoNeonI<(outs DPR:$dst), (ins DPR:$orig, QQPR:$tbl, DPR:$src),
7231                IIC_VTBX3, "$orig = $dst", []>;
7232def  VTBX4Pseudo
7233  : PseudoNeonI<(outs DPR:$dst), (ins DPR:$orig, QQPR:$tbl, DPR:$src),
7234                IIC_VTBX4, "$orig = $dst", []>;
7235} // DecoderMethod = "DecodeTBLInstruction"
7236
7237let Predicates = [HasNEON] in {
7238def : Pat<(v8i8 (NEONvtbl2 v8i8:$Vn0, v8i8:$Vn1, v8i8:$Vm)),
7239          (v8i8 (VTBL2 (REG_SEQUENCE DPair, v8i8:$Vn0, dsub_0,
7240                                            v8i8:$Vn1, dsub_1),
7241                       v8i8:$Vm))>;
7242def : Pat<(v8i8 (int_arm_neon_vtbx2 v8i8:$orig, v8i8:$Vn0, v8i8:$Vn1,
7243                                    v8i8:$Vm)),
7244          (v8i8 (VTBX2 v8i8:$orig,
7245                       (REG_SEQUENCE DPair, v8i8:$Vn0, dsub_0,
7246                                            v8i8:$Vn1, dsub_1),
7247                       v8i8:$Vm))>;
7248
7249def : Pat<(v8i8 (int_arm_neon_vtbl3 v8i8:$Vn0, v8i8:$Vn1,
7250                                    v8i8:$Vn2, v8i8:$Vm)),
7251          (v8i8 (VTBL3Pseudo (REG_SEQUENCE QQPR, v8i8:$Vn0, dsub_0,
7252                                                 v8i8:$Vn1, dsub_1,
7253                                                 v8i8:$Vn2, dsub_2,
7254                                                 (v8i8 (IMPLICIT_DEF)), dsub_3),
7255                             v8i8:$Vm))>;
7256def : Pat<(v8i8 (int_arm_neon_vtbx3 v8i8:$orig, v8i8:$Vn0, v8i8:$Vn1,
7257                                    v8i8:$Vn2, v8i8:$Vm)),
7258          (v8i8 (VTBX3Pseudo v8i8:$orig,
7259                             (REG_SEQUENCE QQPR, v8i8:$Vn0, dsub_0,
7260                                                 v8i8:$Vn1, dsub_1,
7261                                                 v8i8:$Vn2, dsub_2,
7262                                                 (v8i8 (IMPLICIT_DEF)), dsub_3),
7263                             v8i8:$Vm))>;
7264
7265def : Pat<(v8i8 (int_arm_neon_vtbl4 v8i8:$Vn0, v8i8:$Vn1,
7266                                    v8i8:$Vn2, v8i8:$Vn3, v8i8:$Vm)),
7267          (v8i8 (VTBL4Pseudo (REG_SEQUENCE QQPR, v8i8:$Vn0, dsub_0,
7268                                                 v8i8:$Vn1, dsub_1,
7269                                                 v8i8:$Vn2, dsub_2,
7270                                                 v8i8:$Vn3, dsub_3),
7271                             v8i8:$Vm))>;
7272def : Pat<(v8i8 (int_arm_neon_vtbx4 v8i8:$orig, v8i8:$Vn0, v8i8:$Vn1,
7273                                    v8i8:$Vn2, v8i8:$Vn3, v8i8:$Vm)),
7274          (v8i8 (VTBX4Pseudo v8i8:$orig,
7275                             (REG_SEQUENCE QQPR, v8i8:$Vn0, dsub_0,
7276                                                 v8i8:$Vn1, dsub_1,
7277                                                 v8i8:$Vn2, dsub_2,
7278                                                 v8i8:$Vn3, dsub_3),
7279                             v8i8:$Vm))>;
7280}
7281
7282// VRINT      : Vector Rounding
7283multiclass VRINT_FPI<string op, bits<3> op9_7, SDPatternOperator Int> {
7284  let PostEncoderMethod = "NEONThumb2V8PostEncoder", DecoderNamespace = "v8NEON" in {
7285    def Df : N2VDIntnp<0b10, 0b10, 0b100, 0, NoItinerary,
7286                      !strconcat("vrint", op), "f32",
7287                      v2f32, v2f32, Int>, Requires<[HasV8, HasNEON]> {
7288      let Inst{9-7} = op9_7;
7289    }
7290    def Qf : N2VQIntnp<0b10, 0b10, 0b100, 0, NoItinerary,
7291                      !strconcat("vrint", op), "f32",
7292                      v4f32, v4f32, Int>, Requires<[HasV8, HasNEON]> {
7293      let Inst{9-7} = op9_7;
7294    }
7295    def Dh : N2VDIntnp<0b01, 0b10, 0b100, 0, NoItinerary,
7296                      !strconcat("vrint", op), "f16",
7297                      v4f16, v4f16, Int>,
7298             Requires<[HasV8, HasNEON, HasFullFP16]> {
7299      let Inst{9-7} = op9_7;
7300    }
7301    def Qh : N2VQIntnp<0b01, 0b10, 0b100, 0, NoItinerary,
7302                      !strconcat("vrint", op), "f16",
7303                      v8f16, v8f16, Int>,
7304             Requires<[HasV8, HasNEON, HasFullFP16]> {
7305      let Inst{9-7} = op9_7;
7306    }
7307  }
7308
7309  def : NEONInstAlias<!strconcat("vrint", op, ".f32.f32\t$Dd, $Dm"),
7310                  (!cast<Instruction>(NAME#"Df") DPR:$Dd, DPR:$Dm)>;
7311  def : NEONInstAlias<!strconcat("vrint", op, ".f32.f32\t$Qd, $Qm"),
7312                  (!cast<Instruction>(NAME#"Qf") QPR:$Qd, QPR:$Qm)>;
7313  let Predicates = [HasNEON, HasFullFP16] in {
7314  def : NEONInstAlias<!strconcat("vrint", op, ".f16.f16\t$Dd, $Dm"),
7315                  (!cast<Instruction>(NAME#"Dh") DPR:$Dd, DPR:$Dm)>;
7316  def : NEONInstAlias<!strconcat("vrint", op, ".f16.f16\t$Qd, $Qm"),
7317                  (!cast<Instruction>(NAME#"Qh") QPR:$Qd, QPR:$Qm)>;
7318  }
7319}
7320
7321defm VRINTNN : VRINT_FPI<"n", 0b000, int_arm_neon_vrintn>;
7322defm VRINTXN : VRINT_FPI<"x", 0b001, int_arm_neon_vrintx>;
7323defm VRINTAN : VRINT_FPI<"a", 0b010, int_arm_neon_vrinta>;
7324defm VRINTZN : VRINT_FPI<"z", 0b011, int_arm_neon_vrintz>;
7325defm VRINTMN : VRINT_FPI<"m", 0b101, int_arm_neon_vrintm>;
7326defm VRINTPN : VRINT_FPI<"p", 0b111, int_arm_neon_vrintp>;
7327
7328// Cryptography instructions
7329let PostEncoderMethod = "NEONThumb2DataIPostEncoder",
7330    DecoderNamespace = "v8Crypto", hasSideEffects = 0 in {
7331  class AES<string op, bit op7, bit op6, SDPatternOperator Int>
7332    : N2VQIntXnp<0b00, 0b00, 0b011, op6, op7, NoItinerary,
7333                 !strconcat("aes", op), "8", v16i8, v16i8, Int>;
7334  class AES2Op<string op, bit op7, bit op6, SDPatternOperator Int>
7335    : N2VQIntX2np<0b00, 0b00, 0b011, op6, op7, NoItinerary,
7336                 !strconcat("aes", op), "8", v16i8, v16i8, Int>;
7337  class N2SHA<string op, bits<2> op17_16, bits<3> op10_8, bit op7, bit op6,
7338              SDPatternOperator Int>
7339    : N2VQIntXnp<0b10, op17_16, op10_8, op6, op7, NoItinerary,
7340                 !strconcat("sha", op), "32", v4i32, v4i32, Int>;
7341  class N2SHA2Op<string op, bits<2> op17_16, bits<3> op10_8, bit op7, bit op6,
7342              SDPatternOperator Int>
7343    : N2VQIntX2np<0b10, op17_16, op10_8, op6, op7, NoItinerary,
7344                 !strconcat("sha", op), "32", v4i32, v4i32, Int>;
7345  class N3SHA3Op<string op, bits<5> op27_23, bits<2> op21_20, SDPatternOperator Int>
7346    : N3VQInt3np<op27_23, op21_20, 0b1100, 1, 0, N3RegFrm, NoItinerary,
7347                !strconcat("sha", op), "32", v4i32, v4i32, Int>;
7348}
7349
7350let Predicates = [HasV8, HasAES] in {
7351let isCommutable = 1 in {
7352def AESD : AES2Op<"d", 0, 1, int_arm_neon_aesd>;
7353def AESE : AES2Op<"e", 0, 0, int_arm_neon_aese>;
7354}
7355def AESIMC : AES<"imc", 1, 1, int_arm_neon_aesimc>;
7356def AESMC : AES<"mc", 1, 0, int_arm_neon_aesmc>;
7357}
7358
7359let Predicates = [HasV8, HasSHA2] in {
7360def SHA1H : N2SHA<"1h", 0b01, 0b010, 1, 1, null_frag>;
7361def SHA1SU1 : N2SHA2Op<"1su1", 0b10, 0b011, 1, 0, int_arm_neon_sha1su1>;
7362def SHA256SU0 : N2SHA2Op<"256su0", 0b10, 0b011, 1, 1, int_arm_neon_sha256su0>;
7363def SHA1C : N3SHA3Op<"1c", 0b00100, 0b00, null_frag>;
7364def SHA1M : N3SHA3Op<"1m", 0b00100, 0b10, null_frag>;
7365def SHA1P : N3SHA3Op<"1p", 0b00100, 0b01, null_frag>;
7366def SHA1SU0 : N3SHA3Op<"1su0", 0b00100, 0b11, int_arm_neon_sha1su0>;
7367def SHA256H : N3SHA3Op<"256h", 0b00110, 0b00, int_arm_neon_sha256h>;
7368def SHA256H2 : N3SHA3Op<"256h2", 0b00110, 0b01, int_arm_neon_sha256h2>;
7369def SHA256SU1 : N3SHA3Op<"256su1", 0b00110, 0b10, int_arm_neon_sha256su1>;
7370}
7371
7372let Predicates = [HasNEON] in {
7373def : Pat<(i32 (int_arm_neon_sha1h i32:$Rn)),
7374          (COPY_TO_REGCLASS (f32 (EXTRACT_SUBREG
7375              (SHA1H (SUBREG_TO_REG (i64 0),
7376                                    (f32 (COPY_TO_REGCLASS i32:$Rn, SPR)),
7377                                    ssub_0)),
7378              ssub_0)), GPR)>;
7379
7380def : Pat<(v4i32 (int_arm_neon_sha1c v4i32:$hash_abcd, i32:$hash_e, v4i32:$wk)),
7381          (SHA1C v4i32:$hash_abcd,
7382                 (SUBREG_TO_REG (i64 0),
7383                                (f32 (COPY_TO_REGCLASS i32:$hash_e, SPR)),
7384                                ssub_0),
7385                 v4i32:$wk)>;
7386
7387def : Pat<(v4i32 (int_arm_neon_sha1m v4i32:$hash_abcd, i32:$hash_e, v4i32:$wk)),
7388          (SHA1M v4i32:$hash_abcd,
7389                 (SUBREG_TO_REG (i64 0),
7390                                (f32 (COPY_TO_REGCLASS i32:$hash_e, SPR)),
7391                                ssub_0),
7392                 v4i32:$wk)>;
7393
7394def : Pat<(v4i32 (int_arm_neon_sha1p v4i32:$hash_abcd, i32:$hash_e, v4i32:$wk)),
7395          (SHA1P v4i32:$hash_abcd,
7396                 (SUBREG_TO_REG (i64 0),
7397                                (f32 (COPY_TO_REGCLASS i32:$hash_e, SPR)),
7398                                ssub_0),
7399                 v4i32:$wk)>;
7400}
7401
7402//===----------------------------------------------------------------------===//
7403// NEON instructions for single-precision FP math
7404//===----------------------------------------------------------------------===//
7405
7406class N2VSPat<SDNode OpNode, NeonI Inst>
7407  : NEONFPPat<(f32 (OpNode SPR:$a)),
7408              (EXTRACT_SUBREG
7409               (v2f32 (COPY_TO_REGCLASS (Inst
7410                (INSERT_SUBREG
7411                 (v2f32 (COPY_TO_REGCLASS (v2f32 (IMPLICIT_DEF)), DPR_VFP2)),
7412                 SPR:$a, ssub_0)), DPR_VFP2)), ssub_0)>;
7413
7414class N3VSPat<SDNode OpNode, NeonI Inst>
7415  : NEONFPPat<(f32 (OpNode SPR:$a, SPR:$b)),
7416              (EXTRACT_SUBREG
7417               (v2f32 (COPY_TO_REGCLASS (Inst
7418                (INSERT_SUBREG
7419                 (v2f32 (COPY_TO_REGCLASS (v2f32 (IMPLICIT_DEF)), DPR_VFP2)),
7420                 SPR:$a, ssub_0),
7421                (INSERT_SUBREG
7422                 (v2f32 (COPY_TO_REGCLASS (v2f32 (IMPLICIT_DEF)), DPR_VFP2)),
7423                 SPR:$b, ssub_0)), DPR_VFP2)), ssub_0)>;
7424
7425class N3VSPatFP16<SDNode OpNode, NeonI Inst>
7426  : NEONFPPat<(f16 (OpNode HPR:$a, HPR:$b)),
7427              (EXTRACT_SUBREG
7428               (v4f16 (COPY_TO_REGCLASS (Inst
7429                (INSERT_SUBREG
7430                 (v4f16 (COPY_TO_REGCLASS (v4f16 (IMPLICIT_DEF)), DPR_VFP2)),
7431                 HPR:$a, ssub_0),
7432                (INSERT_SUBREG
7433                 (v4f16 (COPY_TO_REGCLASS (v4f16 (IMPLICIT_DEF)), DPR_VFP2)),
7434                 HPR:$b, ssub_0)), DPR_VFP2)), ssub_0)>;
7435
7436class N3VSMulOpPat<SDNode MulNode, SDNode OpNode, NeonI Inst>
7437  : NEONFPPat<(f32 (OpNode SPR:$acc, (f32 (MulNode SPR:$a, SPR:$b)))),
7438              (EXTRACT_SUBREG
7439               (v2f32 (COPY_TO_REGCLASS (Inst
7440                (INSERT_SUBREG
7441                 (v2f32 (COPY_TO_REGCLASS (v2f32 (IMPLICIT_DEF)), DPR_VFP2)),
7442                 SPR:$acc, ssub_0),
7443                (INSERT_SUBREG
7444                 (v2f32 (COPY_TO_REGCLASS (v2f32 (IMPLICIT_DEF)), DPR_VFP2)),
7445                 SPR:$a, ssub_0),
7446                (INSERT_SUBREG
7447                 (v2f32 (COPY_TO_REGCLASS (v2f32 (IMPLICIT_DEF)), DPR_VFP2)),
7448                 SPR:$b, ssub_0)), DPR_VFP2)), ssub_0)>;
7449
7450class NVCVTIFPat<SDNode OpNode, NeonI Inst>
7451  : NEONFPPat<(f32 (OpNode GPR:$a)),
7452              (f32 (EXTRACT_SUBREG
7453                     (v2f32 (Inst
7454                       (INSERT_SUBREG
7455                         (v2f32 (IMPLICIT_DEF)),
7456                         (i32 (COPY_TO_REGCLASS GPR:$a, SPR)), ssub_0))),
7457                     ssub_0))>;
7458class NVCVTFIPat<SDNode OpNode, NeonI Inst>
7459  : NEONFPPat<(i32 (OpNode SPR:$a)),
7460              (i32 (EXTRACT_SUBREG
7461                     (v2f32 (Inst (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)),
7462                                                 SPR:$a, ssub_0))),
7463                     ssub_0))>;
7464
7465def : N3VSPat<fadd, VADDfd>;
7466def : N3VSPat<fsub, VSUBfd>;
7467def : N3VSPat<fmul, VMULfd>;
7468def : N3VSMulOpPat<fmul, fadd, VMLAfd>,
7469      Requires<[HasNEON, UseNEONForFP, UseFPVMLx]>;
7470def : N3VSMulOpPat<fmul, fsub, VMLSfd>,
7471      Requires<[HasNEON, UseNEONForFP, UseFPVMLx]>;
7472def : N3VSMulOpPat<fmul, fadd, VFMAfd>,
7473      Requires<[HasVFP4, UseNEONForFP, UseFusedMAC]>;
7474def : N3VSMulOpPat<fmul, fsub, VFMSfd>,
7475      Requires<[HasVFP4, UseNEONForFP, UseFusedMAC]>;
7476def : N2VSPat<fabs, VABSfd>;
7477def : N2VSPat<fneg, VNEGfd>;
7478def : N3VSPatFP16<fmaximum, VMAXhd>, Requires<[HasFullFP16]>;
7479def : N3VSPatFP16<fminimum, VMINhd>, Requires<[HasFullFP16]>;
7480def : N3VSPat<fmaximum, VMAXfd>, Requires<[HasNEON]>;
7481def : N3VSPat<fminimum, VMINfd>, Requires<[HasNEON]>;
7482def : NVCVTFIPat<fp_to_sint, VCVTf2sd>;
7483def : NVCVTFIPat<fp_to_uint, VCVTf2ud>;
7484def : NVCVTIFPat<sint_to_fp, VCVTs2fd>;
7485def : NVCVTIFPat<uint_to_fp, VCVTu2fd>;
7486
7487// NEON doesn't have any f64 conversions, so provide patterns to make
7488// sure the VFP conversions match when extracting from a vector.
7489def : VFPPat<(f64 (sint_to_fp (extractelt (v2i32 DPR:$src), imm:$lane))),
7490             (VSITOD (EXTRACT_SUBREG DPR:$src, (SSubReg_f32_reg imm:$lane)))>;
7491def : VFPPat<(f64 (sint_to_fp (extractelt (v4i32 QPR:$src), imm:$lane))),
7492             (VSITOD (EXTRACT_SUBREG QPR:$src, (SSubReg_f32_reg imm:$lane)))>;
7493def : VFPPat<(f64 (uint_to_fp (extractelt (v2i32 DPR:$src), imm:$lane))),
7494             (VUITOD (EXTRACT_SUBREG DPR:$src, (SSubReg_f32_reg imm:$lane)))>;
7495def : VFPPat<(f64 (uint_to_fp (extractelt (v4i32 QPR:$src), imm:$lane))),
7496             (VUITOD (EXTRACT_SUBREG QPR:$src, (SSubReg_f32_reg imm:$lane)))>;
7497
7498
7499// Prefer VMOVDRR for i32 -> f32 bitcasts, it can write all DPR registers.
7500def : Pat<(f32 (bitconvert GPR:$a)),
7501          (EXTRACT_SUBREG (VMOVDRR GPR:$a, GPR:$a), ssub_0)>,
7502        Requires<[HasNEON, DontUseVMOVSR]>;
7503def : Pat<(arm_vmovsr GPR:$a),
7504          (EXTRACT_SUBREG (VMOVDRR GPR:$a, GPR:$a), ssub_0)>,
7505        Requires<[HasNEON, DontUseVMOVSR]>;
7506
7507//===----------------------------------------------------------------------===//
7508// Non-Instruction Patterns or Endianess - Revert Patterns
7509//===----------------------------------------------------------------------===//
7510
7511// bit_convert
7512// 64 bit conversions
7513let Predicates = [HasNEON] in {
7514def : Pat<(f64   (bitconvert (v1i64 DPR:$src))), (f64   DPR:$src)>;
7515def : Pat<(v1i64 (bitconvert (f64   DPR:$src))), (v1i64 DPR:$src)>;
7516
7517def : Pat<(v2f32 (bitconvert (v2i32 DPR:$src))), (v2f32 DPR:$src)>;
7518def : Pat<(v2i32 (bitconvert (v2f32 DPR:$src))), (v2i32 DPR:$src)>;
7519
7520def : Pat<(v4i16 (bitconvert (v4f16 DPR:$src))), (v4i16  DPR:$src)>;
7521def : Pat<(v4f16 (bitconvert (v4i16 DPR:$src))), (v4f16  DPR:$src)>;
7522
7523def : Pat<(v4i16 (bitconvert (v4bf16 DPR:$src))), (v4i16  DPR:$src)>;
7524def : Pat<(v4bf16 (bitconvert (v4i16 DPR:$src))), (v4bf16  DPR:$src)>;
7525
7526// 128 bit conversions
7527def : Pat<(v2f64 (bitconvert (v2i64 QPR:$src))), (v2f64 QPR:$src)>;
7528def : Pat<(v2i64 (bitconvert (v2f64 QPR:$src))), (v2i64 QPR:$src)>;
7529
7530def : Pat<(v4i32 (bitconvert (v4f32 QPR:$src))), (v4i32 QPR:$src)>;
7531def : Pat<(v4f32 (bitconvert (v4i32 QPR:$src))), (v4f32 QPR:$src)>;
7532
7533def : Pat<(v8i16 (bitconvert (v8f16 QPR:$src))), (v8i16  QPR:$src)>;
7534def : Pat<(v8f16 (bitconvert (v8i16 QPR:$src))), (v8f16  QPR:$src)>;
7535
7536def : Pat<(v8i16 (bitconvert (v8bf16 QPR:$src))), (v8i16  QPR:$src)>;
7537def : Pat<(v8bf16 (bitconvert (v8i16 QPR:$src))), (v8bf16  QPR:$src)>;
7538}
7539
7540let Predicates = [IsLE,HasNEON] in {
7541  // 64 bit conversions
7542  def : Pat<(f64   (bitconvert (v2f32 DPR:$src))), (f64   DPR:$src)>;
7543  def : Pat<(f64   (bitconvert (v2i32 DPR:$src))), (f64   DPR:$src)>;
7544  def : Pat<(f64   (bitconvert (v4f16 DPR:$src))), (f64   DPR:$src)>;
7545  def : Pat<(f64   (bitconvert (v4bf16 DPR:$src))), (f64   DPR:$src)>;
7546  def : Pat<(f64   (bitconvert (v4i16 DPR:$src))), (f64   DPR:$src)>;
7547  def : Pat<(f64   (bitconvert (v8i8  DPR:$src))), (f64   DPR:$src)>;
7548
7549  def : Pat<(v1i64 (bitconvert (v2f32 DPR:$src))), (v1i64 DPR:$src)>;
7550  def : Pat<(v1i64 (bitconvert (v2i32 DPR:$src))), (v1i64 DPR:$src)>;
7551  def : Pat<(v1i64 (bitconvert (v4f16 DPR:$src))), (v1i64 DPR:$src)>;
7552  def : Pat<(v1i64 (bitconvert (v4bf16 DPR:$src))), (v1i64 DPR:$src)>;
7553  def : Pat<(v1i64 (bitconvert (v4i16 DPR:$src))), (v1i64 DPR:$src)>;
7554  def : Pat<(v1i64 (bitconvert (v8i8  DPR:$src))), (v1i64 DPR:$src)>;
7555
7556  def : Pat<(v2f32 (bitconvert (f64   DPR:$src))), (v2f32 DPR:$src)>;
7557  def : Pat<(v2f32 (bitconvert (v1i64 DPR:$src))), (v2f32 DPR:$src)>;
7558  def : Pat<(v2f32 (bitconvert (v4f16 DPR:$src))), (v2f32 DPR:$src)>;
7559  def : Pat<(v2f32 (bitconvert (v4bf16 DPR:$src))), (v2f32 DPR:$src)>;
7560  def : Pat<(v2f32 (bitconvert (v4i16 DPR:$src))), (v2f32 DPR:$src)>;
7561  def : Pat<(v2f32 (bitconvert (v8i8  DPR:$src))), (v2f32 DPR:$src)>;
7562
7563  def : Pat<(v2i32 (bitconvert (f64   DPR:$src))), (v2i32 DPR:$src)>;
7564  def : Pat<(v2i32 (bitconvert (v1i64 DPR:$src))), (v2i32 DPR:$src)>;
7565  def : Pat<(v2i32 (bitconvert (v4f16 DPR:$src))), (v2i32 DPR:$src)>;
7566  def : Pat<(v2i32 (bitconvert (v4bf16 DPR:$src))), (v2i32 DPR:$src)>;
7567  def : Pat<(v2i32 (bitconvert (v4i16 DPR:$src))), (v2i32 DPR:$src)>;
7568  def : Pat<(v2i32 (bitconvert (v8i8  DPR:$src))), (v2i32 DPR:$src)>;
7569
7570  def : Pat<(v4f16 (bitconvert (f64   DPR:$src))), (v4f16 DPR:$src)>;
7571  def : Pat<(v4f16 (bitconvert (v1i64 DPR:$src))), (v4f16 DPR:$src)>;
7572  def : Pat<(v4f16 (bitconvert (v2f32 DPR:$src))), (v4f16 DPR:$src)>;
7573  def : Pat<(v4f16 (bitconvert (v2i32 DPR:$src))), (v4f16 DPR:$src)>;
7574  def : Pat<(v4f16 (bitconvert (v8i8  DPR:$src))), (v4f16 DPR:$src)>;
7575
7576  def : Pat<(v4bf16 (bitconvert (f64   DPR:$src))), (v4bf16 DPR:$src)>;
7577  def : Pat<(v4bf16 (bitconvert (v1i64 DPR:$src))), (v4bf16 DPR:$src)>;
7578  def : Pat<(v4bf16 (bitconvert (v2f32 DPR:$src))), (v4bf16 DPR:$src)>;
7579  def : Pat<(v4bf16 (bitconvert (v2i32 DPR:$src))), (v4bf16 DPR:$src)>;
7580  def : Pat<(v4bf16 (bitconvert (v8i8  DPR:$src))), (v4bf16 DPR:$src)>;
7581
7582  def : Pat<(v4i16 (bitconvert (f64   DPR:$src))), (v4i16 DPR:$src)>;
7583  def : Pat<(v4i16 (bitconvert (v1i64 DPR:$src))), (v4i16 DPR:$src)>;
7584  def : Pat<(v4i16 (bitconvert (v2f32 DPR:$src))), (v4i16 DPR:$src)>;
7585  def : Pat<(v4i16 (bitconvert (v2i32 DPR:$src))), (v4i16 DPR:$src)>;
7586  def : Pat<(v4i16 (bitconvert (v8i8  DPR:$src))), (v4i16 DPR:$src)>;
7587
7588  def : Pat<(v8i8  (bitconvert (f64   DPR:$src))), (v8i8  DPR:$src)>;
7589  def : Pat<(v8i8  (bitconvert (v1i64 DPR:$src))), (v8i8  DPR:$src)>;
7590  def : Pat<(v8i8  (bitconvert (v2f32 DPR:$src))), (v8i8  DPR:$src)>;
7591  def : Pat<(v8i8  (bitconvert (v2i32 DPR:$src))), (v8i8  DPR:$src)>;
7592  def : Pat<(v8i8  (bitconvert (v4f16 DPR:$src))), (v8i8  DPR:$src)>;
7593  def : Pat<(v8i8  (bitconvert (v4bf16 DPR:$src))), (v8i8  DPR:$src)>;
7594  def : Pat<(v8i8  (bitconvert (v4i16 DPR:$src))), (v8i8  DPR:$src)>;
7595
7596  // 128 bit conversions
7597  def : Pat<(v2f64 (bitconvert (v4f32 QPR:$src))), (v2f64 QPR:$src)>;
7598  def : Pat<(v2f64 (bitconvert (v4i32 QPR:$src))), (v2f64 QPR:$src)>;
7599  def : Pat<(v2f64 (bitconvert (v8f16 QPR:$src))), (v2f64 QPR:$src)>;
7600  def : Pat<(v2f64 (bitconvert (v8bf16 QPR:$src))), (v2f64 QPR:$src)>;
7601  def : Pat<(v2f64 (bitconvert (v8i16 QPR:$src))), (v2f64 QPR:$src)>;
7602  def : Pat<(v2f64 (bitconvert (v16i8 QPR:$src))), (v2f64 QPR:$src)>;
7603
7604  def : Pat<(v2i64 (bitconvert (v4f32 QPR:$src))), (v2i64 QPR:$src)>;
7605  def : Pat<(v2i64 (bitconvert (v4i32 QPR:$src))), (v2i64 QPR:$src)>;
7606  def : Pat<(v2i64 (bitconvert (v8f16 QPR:$src))), (v2i64 QPR:$src)>;
7607  def : Pat<(v2i64 (bitconvert (v8bf16 QPR:$src))), (v2i64 QPR:$src)>;
7608  def : Pat<(v2i64 (bitconvert (v8i16 QPR:$src))), (v2i64 QPR:$src)>;
7609  def : Pat<(v2i64 (bitconvert (v16i8 QPR:$src))), (v2i64 QPR:$src)>;
7610
7611  def : Pat<(v4f32 (bitconvert (v2f64 QPR:$src))), (v4f32 QPR:$src)>;
7612  def : Pat<(v4f32 (bitconvert (v2i64 QPR:$src))), (v4f32 QPR:$src)>;
7613  def : Pat<(v4f32 (bitconvert (v8f16 QPR:$src))), (v4f32 QPR:$src)>;
7614  def : Pat<(v4f32 (bitconvert (v8bf16 QPR:$src))), (v4f32 QPR:$src)>;
7615  def : Pat<(v4f32 (bitconvert (v8i16 QPR:$src))), (v4f32 QPR:$src)>;
7616  def : Pat<(v4f32 (bitconvert (v16i8 QPR:$src))), (v4f32 QPR:$src)>;
7617
7618  def : Pat<(v4i32 (bitconvert (v2f64 QPR:$src))), (v4i32 QPR:$src)>;
7619  def : Pat<(v4i32 (bitconvert (v2i64 QPR:$src))), (v4i32 QPR:$src)>;
7620  def : Pat<(v4i32 (bitconvert (v8f16 QPR:$src))), (v4i32 QPR:$src)>;
7621  def : Pat<(v4i32 (bitconvert (v8bf16 QPR:$src))), (v4i32 QPR:$src)>;
7622  def : Pat<(v4i32 (bitconvert (v8i16 QPR:$src))), (v4i32 QPR:$src)>;
7623  def : Pat<(v4i32 (bitconvert (v16i8 QPR:$src))), (v4i32 QPR:$src)>;
7624
7625  def : Pat<(v8f16 (bitconvert (v2f64 QPR:$src))), (v8f16 QPR:$src)>;
7626  def : Pat<(v8f16 (bitconvert (v2i64 QPR:$src))), (v8f16 QPR:$src)>;
7627  def : Pat<(v8f16 (bitconvert (v4f32 QPR:$src))), (v8f16 QPR:$src)>;
7628  def : Pat<(v8f16 (bitconvert (v4i32 QPR:$src))), (v8f16 QPR:$src)>;
7629  def : Pat<(v8f16 (bitconvert (v16i8 QPR:$src))), (v8f16 QPR:$src)>;
7630
7631  def : Pat<(v8bf16 (bitconvert (v2f64 QPR:$src))), (v8bf16 QPR:$src)>;
7632  def : Pat<(v8bf16 (bitconvert (v2i64 QPR:$src))), (v8bf16 QPR:$src)>;
7633  def : Pat<(v8bf16 (bitconvert (v4f32 QPR:$src))), (v8bf16 QPR:$src)>;
7634  def : Pat<(v8bf16 (bitconvert (v4i32 QPR:$src))), (v8bf16 QPR:$src)>;
7635  def : Pat<(v8bf16 (bitconvert (v16i8 QPR:$src))), (v8bf16 QPR:$src)>;
7636
7637  def : Pat<(v8i16 (bitconvert (v2f64 QPR:$src))), (v8i16 QPR:$src)>;
7638  def : Pat<(v8i16 (bitconvert (v2i64 QPR:$src))), (v8i16 QPR:$src)>;
7639  def : Pat<(v8i16 (bitconvert (v4f32 QPR:$src))), (v8i16 QPR:$src)>;
7640  def : Pat<(v8i16 (bitconvert (v4i32 QPR:$src))), (v8i16 QPR:$src)>;
7641  def : Pat<(v8i16 (bitconvert (v16i8 QPR:$src))), (v8i16 QPR:$src)>;
7642
7643  def : Pat<(v16i8 (bitconvert (v2f64 QPR:$src))), (v16i8 QPR:$src)>;
7644  def : Pat<(v16i8 (bitconvert (v2i64 QPR:$src))), (v16i8 QPR:$src)>;
7645  def : Pat<(v16i8 (bitconvert (v4f32 QPR:$src))), (v16i8 QPR:$src)>;
7646  def : Pat<(v16i8 (bitconvert (v4i32 QPR:$src))), (v16i8 QPR:$src)>;
7647  def : Pat<(v16i8 (bitconvert (v8f16 QPR:$src))), (v16i8 QPR:$src)>;
7648  def : Pat<(v16i8 (bitconvert (v8bf16 QPR:$src))), (v16i8 QPR:$src)>;
7649  def : Pat<(v16i8 (bitconvert (v8i16 QPR:$src))), (v16i8 QPR:$src)>;
7650}
7651
7652let Predicates = [IsBE,HasNEON] in {
7653  // 64 bit conversions
7654  def : Pat<(f64   (bitconvert (v2f32 DPR:$src))), (VREV64d32 DPR:$src)>;
7655  def : Pat<(f64   (bitconvert (v2i32 DPR:$src))), (VREV64d32 DPR:$src)>;
7656  def : Pat<(f64   (bitconvert (v4f16 DPR:$src))), (VREV64d16 DPR:$src)>;
7657  def : Pat<(f64   (bitconvert (v4bf16 DPR:$src))), (VREV64d16 DPR:$src)>;
7658  def : Pat<(f64   (bitconvert (v4i16 DPR:$src))), (VREV64d16 DPR:$src)>;
7659  def : Pat<(f64   (bitconvert (v8i8  DPR:$src))), (VREV64d8  DPR:$src)>;
7660
7661  def : Pat<(v1i64 (bitconvert (v2f32 DPR:$src))), (VREV64d32 DPR:$src)>;
7662  def : Pat<(v1i64 (bitconvert (v2i32 DPR:$src))), (VREV64d32 DPR:$src)>;
7663  def : Pat<(v1i64 (bitconvert (v4f16 DPR:$src))), (VREV64d16 DPR:$src)>;
7664  def : Pat<(v1i64 (bitconvert (v4bf16 DPR:$src))), (VREV64d16 DPR:$src)>;
7665  def : Pat<(v1i64 (bitconvert (v4i16 DPR:$src))), (VREV64d16 DPR:$src)>;
7666  def : Pat<(v1i64 (bitconvert (v8i8  DPR:$src))), (VREV64d8  DPR:$src)>;
7667
7668  def : Pat<(v2f32 (bitconvert (f64   DPR:$src))), (VREV64d32 DPR:$src)>;
7669  def : Pat<(v2f32 (bitconvert (v1i64 DPR:$src))), (VREV64d32 DPR:$src)>;
7670  def : Pat<(v2f32 (bitconvert (v4f16 DPR:$src))), (VREV32d16 DPR:$src)>;
7671  def : Pat<(v2f32 (bitconvert (v4bf16 DPR:$src))), (VREV32d16 DPR:$src)>;
7672  def : Pat<(v2f32 (bitconvert (v4i16 DPR:$src))), (VREV32d16 DPR:$src)>;
7673  def : Pat<(v2f32 (bitconvert (v8i8  DPR:$src))), (VREV32d8  DPR:$src)>;
7674
7675  def : Pat<(v2i32 (bitconvert (f64   DPR:$src))), (VREV64d32 DPR:$src)>;
7676  def : Pat<(v2i32 (bitconvert (v1i64 DPR:$src))), (VREV64d32 DPR:$src)>;
7677  def : Pat<(v2i32 (bitconvert (v4f16 DPR:$src))), (VREV32d16 DPR:$src)>;
7678  def : Pat<(v2i32 (bitconvert (v4bf16 DPR:$src))), (VREV32d16 DPR:$src)>;
7679  def : Pat<(v2i32 (bitconvert (v4i16 DPR:$src))), (VREV32d16 DPR:$src)>;
7680  def : Pat<(v2i32 (bitconvert (v8i8  DPR:$src))), (VREV32d8  DPR:$src)>;
7681
7682  def : Pat<(v4f16 (bitconvert (f64   DPR:$src))), (VREV64d16 DPR:$src)>;
7683  def : Pat<(v4f16 (bitconvert (v1i64 DPR:$src))), (VREV64d16 DPR:$src)>;
7684  def : Pat<(v4f16 (bitconvert (v2f32 DPR:$src))), (VREV32d16 DPR:$src)>;
7685  def : Pat<(v4f16 (bitconvert (v2i32 DPR:$src))), (VREV32d16 DPR:$src)>;
7686  def : Pat<(v4f16 (bitconvert (v8i8  DPR:$src))), (VREV16d8  DPR:$src)>;
7687
7688  def : Pat<(v4bf16 (bitconvert (f64   DPR:$src))), (VREV64d16 DPR:$src)>;
7689  def : Pat<(v4bf16 (bitconvert (v1i64 DPR:$src))), (VREV64d16 DPR:$src)>;
7690  def : Pat<(v4bf16 (bitconvert (v2f32 DPR:$src))), (VREV32d16 DPR:$src)>;
7691  def : Pat<(v4bf16 (bitconvert (v2i32 DPR:$src))), (VREV32d16 DPR:$src)>;
7692  def : Pat<(v4bf16 (bitconvert (v8i8  DPR:$src))), (VREV16d8  DPR:$src)>;
7693
7694  def : Pat<(v4i16 (bitconvert (f64   DPR:$src))), (VREV64d16 DPR:$src)>;
7695  def : Pat<(v4i16 (bitconvert (v1i64 DPR:$src))), (VREV64d16 DPR:$src)>;
7696  def : Pat<(v4i16 (bitconvert (v2f32 DPR:$src))), (VREV32d16 DPR:$src)>;
7697  def : Pat<(v4i16 (bitconvert (v2i32 DPR:$src))), (VREV32d16 DPR:$src)>;
7698  def : Pat<(v4i16 (bitconvert (v8i8  DPR:$src))), (VREV16d8  DPR:$src)>;
7699
7700  def : Pat<(v8i8  (bitconvert (f64   DPR:$src))), (VREV64d8  DPR:$src)>;
7701  def : Pat<(v8i8  (bitconvert (v1i64 DPR:$src))), (VREV64d8  DPR:$src)>;
7702  def : Pat<(v8i8  (bitconvert (v2f32 DPR:$src))), (VREV32d8  DPR:$src)>;
7703  def : Pat<(v8i8  (bitconvert (v2i32 DPR:$src))), (VREV32d8  DPR:$src)>;
7704  def : Pat<(v8i8  (bitconvert (v4f16 DPR:$src))), (VREV16d8  DPR:$src)>;
7705  def : Pat<(v8i8  (bitconvert (v4bf16 DPR:$src))), (VREV16d8  DPR:$src)>;
7706  def : Pat<(v8i8  (bitconvert (v4i16 DPR:$src))), (VREV16d8  DPR:$src)>;
7707
7708  // 128 bit conversions
7709  def : Pat<(v2f64 (bitconvert (v4f32 QPR:$src))), (VREV64q32 QPR:$src)>;
7710  def : Pat<(v2f64 (bitconvert (v4i32 QPR:$src))), (VREV64q32 QPR:$src)>;
7711  def : Pat<(v2f64 (bitconvert (v8f16 QPR:$src))), (VREV64q16 QPR:$src)>;
7712  def : Pat<(v2f64 (bitconvert (v8bf16 QPR:$src))), (VREV64q16 QPR:$src)>;
7713  def : Pat<(v2f64 (bitconvert (v8i16 QPR:$src))), (VREV64q16 QPR:$src)>;
7714  def : Pat<(v2f64 (bitconvert (v16i8 QPR:$src))), (VREV64q8  QPR:$src)>;
7715
7716  def : Pat<(v2i64 (bitconvert (v4f32 QPR:$src))), (VREV64q32 QPR:$src)>;
7717  def : Pat<(v2i64 (bitconvert (v4i32 QPR:$src))), (VREV64q32 QPR:$src)>;
7718  def : Pat<(v2i64 (bitconvert (v8f16 QPR:$src))), (VREV64q16 QPR:$src)>;
7719  def : Pat<(v2i64 (bitconvert (v8bf16 QPR:$src))), (VREV64q16 QPR:$src)>;
7720  def : Pat<(v2i64 (bitconvert (v8i16 QPR:$src))), (VREV64q16 QPR:$src)>;
7721  def : Pat<(v2i64 (bitconvert (v16i8 QPR:$src))), (VREV64q8  QPR:$src)>;
7722
7723  def : Pat<(v4f32 (bitconvert (v2f64 QPR:$src))), (VREV64q32 QPR:$src)>;
7724  def : Pat<(v4f32 (bitconvert (v2i64 QPR:$src))), (VREV64q32 QPR:$src)>;
7725  def : Pat<(v4f32 (bitconvert (v8f16 QPR:$src))), (VREV32q16 QPR:$src)>;
7726  def : Pat<(v4f32 (bitconvert (v8bf16 QPR:$src))), (VREV32q16 QPR:$src)>;
7727  def : Pat<(v4f32 (bitconvert (v8i16 QPR:$src))), (VREV32q16 QPR:$src)>;
7728  def : Pat<(v4f32 (bitconvert (v16i8 QPR:$src))), (VREV32q8  QPR:$src)>;
7729
7730  def : Pat<(v4i32 (bitconvert (v2f64 QPR:$src))), (VREV64q32 QPR:$src)>;
7731  def : Pat<(v4i32 (bitconvert (v2i64 QPR:$src))), (VREV64q32 QPR:$src)>;
7732  def : Pat<(v4i32 (bitconvert (v8f16 QPR:$src))), (VREV32q16 QPR:$src)>;
7733  def : Pat<(v4i32 (bitconvert (v8bf16 QPR:$src))), (VREV32q16 QPR:$src)>;
7734  def : Pat<(v4i32 (bitconvert (v8i16 QPR:$src))), (VREV32q16 QPR:$src)>;
7735  def : Pat<(v4i32 (bitconvert (v16i8 QPR:$src))), (VREV32q8  QPR:$src)>;
7736
7737  def : Pat<(v8f16 (bitconvert (v2f64 QPR:$src))), (VREV64q16 QPR:$src)>;
7738  def : Pat<(v8f16 (bitconvert (v2i64 QPR:$src))), (VREV64q16 QPR:$src)>;
7739  def : Pat<(v8f16 (bitconvert (v4f32 QPR:$src))), (VREV32q16 QPR:$src)>;
7740  def : Pat<(v8f16 (bitconvert (v4i32 QPR:$src))), (VREV32q16 QPR:$src)>;
7741  def : Pat<(v8f16 (bitconvert (v16i8 QPR:$src))), (VREV16q8  QPR:$src)>;
7742
7743  def : Pat<(v8bf16 (bitconvert (v2f64 QPR:$src))), (VREV64q16 QPR:$src)>;
7744  def : Pat<(v8bf16 (bitconvert (v2i64 QPR:$src))), (VREV64q16 QPR:$src)>;
7745  def : Pat<(v8bf16 (bitconvert (v4f32 QPR:$src))), (VREV32q16 QPR:$src)>;
7746  def : Pat<(v8bf16 (bitconvert (v4i32 QPR:$src))), (VREV32q16 QPR:$src)>;
7747  def : Pat<(v8bf16 (bitconvert (v16i8 QPR:$src))), (VREV16q8  QPR:$src)>;
7748
7749  def : Pat<(v8i16 (bitconvert (v2f64 QPR:$src))), (VREV64q16 QPR:$src)>;
7750  def : Pat<(v8i16 (bitconvert (v2i64 QPR:$src))), (VREV64q16 QPR:$src)>;
7751  def : Pat<(v8i16 (bitconvert (v4f32 QPR:$src))), (VREV32q16 QPR:$src)>;
7752  def : Pat<(v8i16 (bitconvert (v4i32 QPR:$src))), (VREV32q16 QPR:$src)>;
7753  def : Pat<(v8i16 (bitconvert (v16i8 QPR:$src))), (VREV16q8  QPR:$src)>;
7754
7755  def : Pat<(v16i8 (bitconvert (v2f64 QPR:$src))), (VREV64q8  QPR:$src)>;
7756  def : Pat<(v16i8 (bitconvert (v2i64 QPR:$src))), (VREV64q8  QPR:$src)>;
7757  def : Pat<(v16i8 (bitconvert (v4f32 QPR:$src))), (VREV32q8  QPR:$src)>;
7758  def : Pat<(v16i8 (bitconvert (v4i32 QPR:$src))), (VREV32q8  QPR:$src)>;
7759  def : Pat<(v16i8 (bitconvert (v8f16 QPR:$src))), (VREV16q8  QPR:$src)>;
7760  def : Pat<(v16i8 (bitconvert (v8bf16 QPR:$src))), (VREV16q8  QPR:$src)>;
7761  def : Pat<(v16i8 (bitconvert (v8i16 QPR:$src))), (VREV16q8  QPR:$src)>;
7762}
7763
7764let Predicates = [HasNEON] in {
7765  // Here we match the specific SDNode type 'ARMVectorRegCastImpl'
7766  // rather than the more general 'ARMVectorRegCast' which would also
7767  // match some bitconverts. If we use the latter in cases where the
7768  // input and output types are the same, the bitconvert gets elided
7769  // and we end up generating a nonsense match of nothing.
7770
7771  foreach VT = [ v16i8, v8i16, v8f16, v8bf16, v4i32, v4f32, v2i64, v2f64 ] in
7772    foreach VT2 = [ v16i8, v8i16, v8f16, v8bf16, v4i32, v4f32, v2i64, v2f64 ] in
7773      def : Pat<(VT (ARMVectorRegCastImpl (VT2 QPR:$src))), (VT QPR:$src)>;
7774
7775  foreach VT = [ v8i8, v4i16, v4f16, v4bf16, v2i32, v2f32, v1i64, f64 ] in
7776    foreach VT2 = [ v8i8, v4i16, v4f16, v4bf16, v2i32, v2f32, v1i64, f64 ] in
7777      def : Pat<(VT (ARMVectorRegCastImpl (VT2 DPR:$src))), (VT DPR:$src)>;
7778}
7779
7780// Use VLD1/VST1 + VREV for non-word-aligned v2f64 load/store on Big Endian
7781let Predicates = [IsBE,HasNEON] in {
7782def : Pat<(v2f64 (byte_alignedload addrmode6:$addr)),
7783          (VREV64q8 (VLD1q8 addrmode6:$addr))>;
7784def : Pat<(byte_alignedstore (v2f64 QPR:$value), addrmode6:$addr),
7785          (VST1q8 addrmode6:$addr, (VREV64q8 QPR:$value))>;
7786def : Pat<(v2f64 (hword_alignedload addrmode6:$addr)),
7787          (VREV64q16 (VLD1q16 addrmode6:$addr))>;
7788def : Pat<(hword_alignedstore (v2f64 QPR:$value), addrmode6:$addr),
7789          (VST1q16 addrmode6:$addr, (VREV64q16 QPR:$value))>;
7790}
7791
7792// Fold extracting an element out of a v2i32 into a vfp register.
7793def : Pat<(f32 (bitconvert (i32 (extractelt (v2i32 DPR:$src), imm:$lane)))),
7794          (f32 (EXTRACT_SUBREG DPR:$src, (SSubReg_f32_reg imm:$lane)))>,
7795      Requires<[HasNEON]>;
7796
7797// Vector lengthening move with load, matching extending loads.
7798
7799// extload, zextload and sextload for a standard lengthening load. Example:
7800// Lengthen_Single<"8", "i16", "8"> =
7801//     Pat<(v8i16 (extloadvi8 addrmode6:$addr))
7802//         (VMOVLuv8i16 (VLD1d8 addrmode6:$addr,
7803//                              (f64 (IMPLICIT_DEF)), (i32 0)))>;
7804multiclass Lengthen_Single<string DestLanes, string DestTy, string SrcTy> {
7805  let AddedComplexity = 10 in {
7806  def _Any : Pat<(!cast<ValueType>("v" # DestLanes # DestTy)
7807                    (!cast<PatFrag>("extloadvi" # SrcTy) addrmode6:$addr)),
7808                  (!cast<Instruction>("VMOVLuv" # DestLanes # DestTy)
7809                    (!cast<Instruction>("VLD1d" # SrcTy) addrmode6:$addr))>,
7810             Requires<[HasNEON]>;
7811
7812  def _Z : Pat<(!cast<ValueType>("v" # DestLanes # DestTy)
7813                  (!cast<PatFrag>("zextloadvi" # SrcTy) addrmode6:$addr)),
7814                (!cast<Instruction>("VMOVLuv" # DestLanes # DestTy)
7815                    (!cast<Instruction>("VLD1d" # SrcTy) addrmode6:$addr))>,
7816           Requires<[HasNEON]>;
7817
7818  def _S : Pat<(!cast<ValueType>("v" # DestLanes # DestTy)
7819                  (!cast<PatFrag>("sextloadvi" # SrcTy) addrmode6:$addr)),
7820                (!cast<Instruction>("VMOVLsv" # DestLanes # DestTy)
7821                    (!cast<Instruction>("VLD1d" # SrcTy) addrmode6:$addr))>,
7822           Requires<[HasNEON]>;
7823  }
7824}
7825
7826// extload, zextload and sextload for a lengthening load which only uses
7827// half the lanes available. Example:
7828// Lengthen_HalfSingle<"4", "i16", "8", "i16", "i8"> =
7829//     Pat<(v4i16 (extloadvi8 addrmode6oneL32:$addr)),
7830//         (EXTRACT_SUBREG (VMOVLuv8i16 (VLD1LNd32 addrmode6oneL32:$addr,
7831//                                      (f64 (IMPLICIT_DEF)), (i32 0))),
7832//                         dsub_0)>;
7833multiclass Lengthen_HalfSingle<string DestLanes, string DestTy, string SrcTy,
7834                               string InsnLanes, string InsnTy> {
7835  def _Any : Pat<(!cast<ValueType>("v" # DestLanes # DestTy)
7836                   (!cast<PatFrag>("extloadv" # SrcTy) addrmode6oneL32:$addr)),
7837       (EXTRACT_SUBREG (!cast<Instruction>("VMOVLuv" # InsnLanes # InsnTy)
7838         (VLD1LNd32 addrmode6oneL32:$addr, (f64 (IMPLICIT_DEF)), (i32 0))),
7839         dsub_0)>,
7840             Requires<[HasNEON]>;
7841  def _Z   : Pat<(!cast<ValueType>("v" # DestLanes # DestTy)
7842                   (!cast<PatFrag>("zextloadv" # SrcTy) addrmode6oneL32:$addr)),
7843       (EXTRACT_SUBREG (!cast<Instruction>("VMOVLuv" # InsnLanes # InsnTy)
7844         (VLD1LNd32 addrmode6oneL32:$addr, (f64 (IMPLICIT_DEF)), (i32 0))),
7845         dsub_0)>,
7846             Requires<[HasNEON]>;
7847  def _S   : Pat<(!cast<ValueType>("v" # DestLanes # DestTy)
7848                   (!cast<PatFrag>("sextloadv" # SrcTy) addrmode6oneL32:$addr)),
7849       (EXTRACT_SUBREG (!cast<Instruction>("VMOVLsv" # InsnLanes # InsnTy)
7850         (VLD1LNd32 addrmode6oneL32:$addr, (f64 (IMPLICIT_DEF)), (i32 0))),
7851         dsub_0)>,
7852             Requires<[HasNEON]>;
7853}
7854
7855// The following class definition is basically a copy of the
7856// Lengthen_HalfSingle definition above, however with an additional parameter
7857// "RevLanes" to select the correct VREV32dXX instruction. This is to convert
7858// data loaded by VLD1LN into proper vector format in big endian mode.
7859multiclass Lengthen_HalfSingle_Big_Endian<string DestLanes, string DestTy, string SrcTy,
7860                               string InsnLanes, string InsnTy, string RevLanes> {
7861  def _Any : Pat<(!cast<ValueType>("v" # DestLanes # DestTy)
7862                   (!cast<PatFrag>("extloadv" # SrcTy) addrmode6oneL32:$addr)),
7863       (EXTRACT_SUBREG (!cast<Instruction>("VMOVLuv" # InsnLanes # InsnTy)
7864         (!cast<Instruction>("VREV32d" # RevLanes)
7865           (VLD1LNd32 addrmode6oneL32:$addr, (f64 (IMPLICIT_DEF)), (i32 0)))),
7866         dsub_0)>,
7867             Requires<[HasNEON]>;
7868  def _Z   : Pat<(!cast<ValueType>("v" # DestLanes # DestTy)
7869                   (!cast<PatFrag>("zextloadv" # SrcTy) addrmode6oneL32:$addr)),
7870       (EXTRACT_SUBREG (!cast<Instruction>("VMOVLuv" # InsnLanes # InsnTy)
7871         (!cast<Instruction>("VREV32d" # RevLanes)
7872           (VLD1LNd32 addrmode6oneL32:$addr, (f64 (IMPLICIT_DEF)), (i32 0)))),
7873         dsub_0)>,
7874             Requires<[HasNEON]>;
7875  def _S   : Pat<(!cast<ValueType>("v" # DestLanes # DestTy)
7876                   (!cast<PatFrag>("sextloadv" # SrcTy) addrmode6oneL32:$addr)),
7877       (EXTRACT_SUBREG (!cast<Instruction>("VMOVLsv" # InsnLanes # InsnTy)
7878         (!cast<Instruction>("VREV32d" # RevLanes)
7879           (VLD1LNd32 addrmode6oneL32:$addr, (f64 (IMPLICIT_DEF)), (i32 0)))),
7880         dsub_0)>,
7881             Requires<[HasNEON]>;
7882}
7883
7884// extload, zextload and sextload for a lengthening load followed by another
7885// lengthening load, to quadruple the initial length.
7886//
7887// Lengthen_Double<"4", "i32", "i8", "8", "i16", "4", "i32"> =
7888//     Pat<(v4i32 (extloadvi8 addrmode6oneL32:$addr))
7889//         (EXTRACT_SUBREG (VMOVLuv4i32
7890//           (EXTRACT_SUBREG (VMOVLuv8i16 (VLD1LNd32 addrmode6oneL32:$addr,
7891//                                                   (f64 (IMPLICIT_DEF)),
7892//                                                   (i32 0))),
7893//                           dsub_0)),
7894//           dsub_0)>;
7895multiclass Lengthen_Double<string DestLanes, string DestTy, string SrcTy,
7896                           string Insn1Lanes, string Insn1Ty, string Insn2Lanes,
7897                           string Insn2Ty> {
7898  def _Any : Pat<(!cast<ValueType>("v" # DestLanes # DestTy)
7899                   (!cast<PatFrag>("extloadv" # SrcTy) addrmode6oneL32:$addr)),
7900         (!cast<Instruction>("VMOVLuv" # Insn2Lanes # Insn2Ty)
7901           (EXTRACT_SUBREG (!cast<Instruction>("VMOVLuv" # Insn1Lanes # Insn1Ty)
7902             (VLD1LNd32 addrmode6oneL32:$addr, (f64 (IMPLICIT_DEF)), (i32 0))),
7903             dsub_0))>,
7904             Requires<[HasNEON]>;
7905  def _Z   : Pat<(!cast<ValueType>("v" # DestLanes # DestTy)
7906                   (!cast<PatFrag>("zextloadv" # SrcTy) addrmode6oneL32:$addr)),
7907         (!cast<Instruction>("VMOVLuv" # Insn2Lanes # Insn2Ty)
7908           (EXTRACT_SUBREG (!cast<Instruction>("VMOVLuv" # Insn1Lanes # Insn1Ty)
7909             (VLD1LNd32 addrmode6oneL32:$addr, (f64 (IMPLICIT_DEF)), (i32 0))),
7910             dsub_0))>,
7911             Requires<[HasNEON]>;
7912  def _S   : Pat<(!cast<ValueType>("v" # DestLanes # DestTy)
7913                   (!cast<PatFrag>("sextloadv" # SrcTy) addrmode6oneL32:$addr)),
7914         (!cast<Instruction>("VMOVLsv" # Insn2Lanes # Insn2Ty)
7915           (EXTRACT_SUBREG (!cast<Instruction>("VMOVLsv" # Insn1Lanes # Insn1Ty)
7916             (VLD1LNd32 addrmode6oneL32:$addr, (f64 (IMPLICIT_DEF)), (i32 0))),
7917             dsub_0))>,
7918             Requires<[HasNEON]>;
7919}
7920
7921// The following class definition is basically a copy of the
7922// Lengthen_Double definition above, however with an additional parameter
7923// "RevLanes" to select the correct VREV32dXX instruction. This is to convert
7924// data loaded by VLD1LN into proper vector format in big endian mode.
7925multiclass Lengthen_Double_Big_Endian<string DestLanes, string DestTy, string SrcTy,
7926                           string Insn1Lanes, string Insn1Ty, string Insn2Lanes,
7927                           string Insn2Ty, string RevLanes> {
7928  def _Any : Pat<(!cast<ValueType>("v" # DestLanes # DestTy)
7929                   (!cast<PatFrag>("extloadv" # SrcTy) addrmode6oneL32:$addr)),
7930         (!cast<Instruction>("VMOVLuv" # Insn2Lanes # Insn2Ty)
7931           (EXTRACT_SUBREG (!cast<Instruction>("VMOVLuv" # Insn1Lanes # Insn1Ty)
7932            (!cast<Instruction>("VREV32d" # RevLanes)
7933             (VLD1LNd32 addrmode6oneL32:$addr, (f64 (IMPLICIT_DEF)), (i32 0)))),
7934             dsub_0))>,
7935             Requires<[HasNEON]>;
7936  def _Z   : Pat<(!cast<ValueType>("v" # DestLanes # DestTy)
7937                   (!cast<PatFrag>("zextloadv" # SrcTy) addrmode6oneL32:$addr)),
7938         (!cast<Instruction>("VMOVLuv" # Insn2Lanes # Insn2Ty)
7939           (EXTRACT_SUBREG (!cast<Instruction>("VMOVLuv" # Insn1Lanes # Insn1Ty)
7940            (!cast<Instruction>("VREV32d" # RevLanes)
7941             (VLD1LNd32 addrmode6oneL32:$addr, (f64 (IMPLICIT_DEF)), (i32 0)))),
7942             dsub_0))>,
7943             Requires<[HasNEON]>;
7944  def _S   : Pat<(!cast<ValueType>("v" # DestLanes # DestTy)
7945                   (!cast<PatFrag>("sextloadv" # SrcTy) addrmode6oneL32:$addr)),
7946         (!cast<Instruction>("VMOVLsv" # Insn2Lanes # Insn2Ty)
7947           (EXTRACT_SUBREG (!cast<Instruction>("VMOVLsv" # Insn1Lanes # Insn1Ty)
7948            (!cast<Instruction>("VREV32d" # RevLanes)
7949             (VLD1LNd32 addrmode6oneL32:$addr, (f64 (IMPLICIT_DEF)), (i32 0)))),
7950             dsub_0))>,
7951             Requires<[HasNEON]>;
7952}
7953
7954// extload, zextload and sextload for a lengthening load followed by another
7955// lengthening load, to quadruple the initial length, but which ends up only
7956// requiring half the available lanes (a 64-bit outcome instead of a 128-bit).
7957//
7958// Lengthen_HalfDouble<"2", "i32", "i8", "8", "i16", "4", "i32"> =
7959// Pat<(v2i32 (extloadvi8 addrmode6:$addr))
7960//     (EXTRACT_SUBREG (VMOVLuv4i32
7961//       (EXTRACT_SUBREG (VMOVLuv8i16 (VLD1LNd16 addrmode6:$addr,
7962//                                               (f64 (IMPLICIT_DEF)), (i32 0))),
7963//                       dsub_0)),
7964//       dsub_0)>;
7965multiclass Lengthen_HalfDouble<string DestLanes, string DestTy, string SrcTy,
7966                           string Insn1Lanes, string Insn1Ty, string Insn2Lanes,
7967                           string Insn2Ty> {
7968  def _Any : Pat<(!cast<ValueType>("v" # DestLanes # DestTy)
7969                   (!cast<PatFrag>("extloadv" # SrcTy) addrmode6:$addr)),
7970         (EXTRACT_SUBREG (!cast<Instruction>("VMOVLuv" # Insn2Lanes # Insn2Ty)
7971           (EXTRACT_SUBREG (!cast<Instruction>("VMOVLuv" # Insn1Lanes # Insn1Ty)
7972             (VLD1LNd16 addrmode6:$addr, (f64 (IMPLICIT_DEF)), (i32 0))),
7973             dsub_0)),
7974          dsub_0)>,
7975             Requires<[HasNEON]>;
7976  def _Z   : Pat<(!cast<ValueType>("v" # DestLanes # DestTy)
7977                   (!cast<PatFrag>("zextloadv" # SrcTy) addrmode6:$addr)),
7978         (EXTRACT_SUBREG (!cast<Instruction>("VMOVLuv" # Insn2Lanes # Insn2Ty)
7979           (EXTRACT_SUBREG (!cast<Instruction>("VMOVLuv" # Insn1Lanes # Insn1Ty)
7980             (VLD1LNd16 addrmode6:$addr, (f64 (IMPLICIT_DEF)), (i32 0))),
7981             dsub_0)),
7982          dsub_0)>,
7983              Requires<[HasNEON]>;
7984  def _S   : Pat<(!cast<ValueType>("v" # DestLanes # DestTy)
7985                   (!cast<PatFrag>("sextloadv" # SrcTy) addrmode6:$addr)),
7986         (EXTRACT_SUBREG (!cast<Instruction>("VMOVLsv" # Insn2Lanes # Insn2Ty)
7987           (EXTRACT_SUBREG (!cast<Instruction>("VMOVLsv" # Insn1Lanes # Insn1Ty)
7988             (VLD1LNd16 addrmode6:$addr, (f64 (IMPLICIT_DEF)), (i32 0))),
7989             dsub_0)),
7990          dsub_0)>,
7991             Requires<[HasNEON]>;
7992}
7993
7994// The following class definition is basically a copy of the
7995// Lengthen_HalfDouble definition above, however with an additional VREV16d8
7996// instruction to convert data loaded by VLD1LN into proper vector format
7997// in big endian mode.
7998multiclass Lengthen_HalfDouble_Big_Endian<string DestLanes, string DestTy, string SrcTy,
7999                           string Insn1Lanes, string Insn1Ty, string Insn2Lanes,
8000                           string Insn2Ty> {
8001  def _Any : Pat<(!cast<ValueType>("v" # DestLanes # DestTy)
8002                   (!cast<PatFrag>("extloadv" # SrcTy) addrmode6:$addr)),
8003         (EXTRACT_SUBREG (!cast<Instruction>("VMOVLuv" # Insn2Lanes # Insn2Ty)
8004           (EXTRACT_SUBREG (!cast<Instruction>("VMOVLuv" # Insn1Lanes # Insn1Ty)
8005             (VREV16d8 (VLD1LNd16 addrmode6:$addr, (f64 (IMPLICIT_DEF)), (i32 0)))),
8006             dsub_0)),
8007           dsub_0)>,
8008             Requires<[HasNEON]>;
8009  def _Z   : Pat<(!cast<ValueType>("v" # DestLanes # DestTy)
8010                   (!cast<PatFrag>("zextloadv" # SrcTy) addrmode6:$addr)),
8011         (EXTRACT_SUBREG (!cast<Instruction>("VMOVLuv" # Insn2Lanes # Insn2Ty)
8012           (EXTRACT_SUBREG (!cast<Instruction>("VMOVLuv" # Insn1Lanes # Insn1Ty)
8013             (VREV16d8 (VLD1LNd16 addrmode6:$addr, (f64 (IMPLICIT_DEF)), (i32 0)))),
8014             dsub_0)),
8015           dsub_0)>,
8016             Requires<[HasNEON]>;
8017  def _S   : Pat<(!cast<ValueType>("v" # DestLanes # DestTy)
8018                   (!cast<PatFrag>("sextloadv" # SrcTy) addrmode6:$addr)),
8019         (EXTRACT_SUBREG (!cast<Instruction>("VMOVLsv" # Insn2Lanes # Insn2Ty)
8020           (EXTRACT_SUBREG (!cast<Instruction>("VMOVLsv" # Insn1Lanes # Insn1Ty)
8021             (VREV16d8 (VLD1LNd16 addrmode6:$addr, (f64 (IMPLICIT_DEF)), (i32 0)))),
8022             dsub_0)),
8023           dsub_0)>,
8024             Requires<[HasNEON]>;
8025}
8026
8027defm : Lengthen_Single<"8", "i16", "8">; // v8i8 -> v8i16
8028defm : Lengthen_Single<"4", "i32", "16">; // v4i16 -> v4i32
8029defm : Lengthen_Single<"2", "i64", "32">; // v2i32 -> v2i64
8030
8031let Predicates = [HasNEON,IsLE] in {
8032  defm : Lengthen_HalfSingle<"4", "i16", "i8", "8", "i16">; // v4i8 -> v4i16
8033  defm : Lengthen_HalfSingle<"2", "i32", "i16", "4", "i32">; // v2i16 -> v2i32
8034
8035  // Double lengthening - v4i8 -> v4i16 -> v4i32
8036  defm : Lengthen_Double<"4", "i32", "i8", "8", "i16", "4", "i32">;
8037  // v2i8 -> v2i16 -> v2i32
8038  defm : Lengthen_HalfDouble<"2", "i32", "i8", "8", "i16", "4", "i32">;
8039  // v2i16 -> v2i32 -> v2i64
8040  defm : Lengthen_Double<"2", "i64", "i16", "4", "i32", "2", "i64">;
8041}
8042
8043let Predicates = [HasNEON,IsBE] in {
8044  defm : Lengthen_HalfSingle_Big_Endian<"4", "i16", "i8", "8", "i16", "8">; // v4i8 -> v4i16
8045  defm : Lengthen_HalfSingle_Big_Endian<"2", "i32", "i16", "4", "i32", "16">; // v2i16 -> v2i32
8046
8047  // Double lengthening - v4i8 -> v4i16 -> v4i32
8048  defm : Lengthen_Double_Big_Endian<"4", "i32", "i8", "8", "i16", "4", "i32", "8">;
8049  // v2i8 -> v2i16 -> v2i32
8050  defm : Lengthen_HalfDouble_Big_Endian<"2", "i32", "i8", "8", "i16", "4", "i32">;
8051  // v2i16 -> v2i32 -> v2i64
8052  defm : Lengthen_Double_Big_Endian<"2", "i64", "i16", "4", "i32", "2", "i64", "16">;
8053}
8054
8055// Triple lengthening - v2i8 -> v2i16 -> v2i32 -> v2i64
8056let Predicates = [HasNEON,IsLE] in {
8057  def : Pat<(v2i64 (extloadvi8 addrmode6:$addr)),
8058        (VMOVLuv2i64 (EXTRACT_SUBREG (VMOVLuv4i32 (EXTRACT_SUBREG (VMOVLuv8i16
8059           (VLD1LNd16 addrmode6:$addr,
8060                      (f64 (IMPLICIT_DEF)), (i32 0))), dsub_0)), dsub_0))>;
8061  def : Pat<(v2i64 (zextloadvi8 addrmode6:$addr)),
8062        (VMOVLuv2i64 (EXTRACT_SUBREG (VMOVLuv4i32 (EXTRACT_SUBREG (VMOVLuv8i16
8063           (VLD1LNd16 addrmode6:$addr,
8064                      (f64 (IMPLICIT_DEF)), (i32 0))), dsub_0)), dsub_0))>;
8065  def : Pat<(v2i64 (sextloadvi8 addrmode6:$addr)),
8066        (VMOVLsv2i64 (EXTRACT_SUBREG (VMOVLsv4i32 (EXTRACT_SUBREG (VMOVLsv8i16
8067           (VLD1LNd16 addrmode6:$addr,
8068                      (f64 (IMPLICIT_DEF)), (i32 0))), dsub_0)), dsub_0))>;
8069}
8070// The following patterns are basically a copy of the patterns above,
8071// however with an additional VREV16d instruction to convert data
8072// loaded by VLD1LN into proper vector format in big endian mode.
8073let Predicates = [HasNEON,IsBE] in {
8074  def : Pat<(v2i64 (extloadvi8 addrmode6:$addr)),
8075        (VMOVLuv2i64 (EXTRACT_SUBREG (VMOVLuv4i32 (EXTRACT_SUBREG (VMOVLuv8i16
8076           (VREV16d8
8077             (VLD1LNd16 addrmode6:$addr,
8078                        (f64 (IMPLICIT_DEF)), (i32 0)))), dsub_0)), dsub_0))>;
8079  def : Pat<(v2i64 (zextloadvi8 addrmode6:$addr)),
8080        (VMOVLuv2i64 (EXTRACT_SUBREG (VMOVLuv4i32 (EXTRACT_SUBREG (VMOVLuv8i16
8081           (VREV16d8
8082             (VLD1LNd16 addrmode6:$addr,
8083                        (f64 (IMPLICIT_DEF)), (i32 0)))), dsub_0)), dsub_0))>;
8084  def : Pat<(v2i64 (sextloadvi8 addrmode6:$addr)),
8085        (VMOVLsv2i64 (EXTRACT_SUBREG (VMOVLsv4i32 (EXTRACT_SUBREG (VMOVLsv8i16
8086           (VREV16d8
8087             (VLD1LNd16 addrmode6:$addr,
8088                        (f64 (IMPLICIT_DEF)), (i32 0)))), dsub_0)), dsub_0))>;
8089}
8090
8091let Predicates = [HasNEON] in {
8092def : Pat<(v2i64 (concat_vectors DPR:$Dn, DPR:$Dm)),
8093          (REG_SEQUENCE QPR, DPR:$Dn, dsub_0, DPR:$Dm, dsub_1)>;
8094def : Pat<(v4i32 (concat_vectors DPR:$Dn, DPR:$Dm)),
8095          (REG_SEQUENCE QPR, DPR:$Dn, dsub_0, DPR:$Dm, dsub_1)>;
8096def : Pat<(v8i16 (concat_vectors DPR:$Dn, DPR:$Dm)),
8097          (REG_SEQUENCE QPR, DPR:$Dn, dsub_0, DPR:$Dm, dsub_1)>;
8098def : Pat<(v16i8 (concat_vectors DPR:$Dn, DPR:$Dm)),
8099          (REG_SEQUENCE QPR, DPR:$Dn, dsub_0, DPR:$Dm, dsub_1)>;
8100def : Pat<(v4f32 (concat_vectors DPR:$Dn, DPR:$Dm)),
8101          (REG_SEQUENCE QPR, DPR:$Dn, dsub_0, DPR:$Dm, dsub_1)>;
8102def : Pat<(v8f16 (concat_vectors DPR:$Dn, DPR:$Dm)),
8103          (REG_SEQUENCE QPR, DPR:$Dn, dsub_0, DPR:$Dm, dsub_1)>;
8104def : Pat<(v8bf16 (concat_vectors DPR:$Dn, DPR:$Dm)),
8105          (REG_SEQUENCE QPR, DPR:$Dn, dsub_0, DPR:$Dm, dsub_1)>;
8106}
8107
8108//===----------------------------------------------------------------------===//
8109// Assembler aliases
8110//
8111
8112def : VFP2InstAlias<"fmdhr${p} $Dd, $Rn",
8113                    (VSETLNi32 DPR:$Dd, GPR:$Rn, 1, pred:$p)>;
8114def : VFP2InstAlias<"fmdlr${p} $Dd, $Rn",
8115                    (VSETLNi32 DPR:$Dd, GPR:$Rn, 0, pred:$p)>;
8116
8117// VAND/VBIC/VEOR/VORR accept but do not require a type suffix.
8118defm : NEONDTAnyInstAlias<"vand${p}", "$Vd, $Vn, $Vm",
8119                         (VANDd DPR:$Vd, DPR:$Vn, DPR:$Vm, pred:$p)>;
8120defm : NEONDTAnyInstAlias<"vand${p}", "$Vd, $Vn, $Vm",
8121                         (VANDq QPR:$Vd, QPR:$Vn, QPR:$Vm, pred:$p)>;
8122defm : NEONDTAnyInstAlias<"vbic${p}", "$Vd, $Vn, $Vm",
8123                         (VBICd DPR:$Vd, DPR:$Vn, DPR:$Vm, pred:$p)>;
8124defm : NEONDTAnyInstAlias<"vbic${p}", "$Vd, $Vn, $Vm",
8125                         (VBICq QPR:$Vd, QPR:$Vn, QPR:$Vm, pred:$p)>;
8126defm : NEONDTAnyInstAlias<"veor${p}", "$Vd, $Vn, $Vm",
8127                         (VEORd DPR:$Vd, DPR:$Vn, DPR:$Vm, pred:$p)>;
8128defm : NEONDTAnyInstAlias<"veor${p}", "$Vd, $Vn, $Vm",
8129                         (VEORq QPR:$Vd, QPR:$Vn, QPR:$Vm, pred:$p)>;
8130defm : NEONDTAnyInstAlias<"vorr${p}", "$Vd, $Vn, $Vm",
8131                         (VORRd DPR:$Vd, DPR:$Vn, DPR:$Vm, pred:$p)>;
8132defm : NEONDTAnyInstAlias<"vorr${p}", "$Vd, $Vn, $Vm",
8133                         (VORRq QPR:$Vd, QPR:$Vn, QPR:$Vm, pred:$p)>;
8134// ... two-operand aliases
8135defm : NEONDTAnyInstAlias<"vand${p}", "$Vdn, $Vm",
8136                         (VANDd DPR:$Vdn, DPR:$Vdn, DPR:$Vm, pred:$p)>;
8137defm : NEONDTAnyInstAlias<"vand${p}", "$Vdn, $Vm",
8138                         (VANDq QPR:$Vdn, QPR:$Vdn, QPR:$Vm, pred:$p)>;
8139defm : NEONDTAnyInstAlias<"veor${p}", "$Vdn, $Vm",
8140                         (VEORd DPR:$Vdn, DPR:$Vdn, DPR:$Vm, pred:$p)>;
8141defm : NEONDTAnyInstAlias<"veor${p}", "$Vdn, $Vm",
8142                         (VEORq QPR:$Vdn, QPR:$Vdn, QPR:$Vm, pred:$p)>;
8143defm : NEONDTAnyInstAlias<"vorr${p}", "$Vdn, $Vm",
8144                         (VORRd DPR:$Vdn, DPR:$Vdn, DPR:$Vm, pred:$p)>;
8145defm : NEONDTAnyInstAlias<"vorr${p}", "$Vdn, $Vm",
8146                         (VORRq QPR:$Vdn, QPR:$Vdn, QPR:$Vm, pred:$p)>;
8147// ... immediates
8148def : NEONInstAlias<"vand${p}.i16 $Vd, $imm",
8149                    (VBICiv4i16 DPR:$Vd, nImmSplatNotI16:$imm, pred:$p)>;
8150def : NEONInstAlias<"vand${p}.i32 $Vd, $imm",
8151                    (VBICiv2i32 DPR:$Vd, nImmSplatNotI32:$imm, pred:$p)>;
8152def : NEONInstAlias<"vand${p}.i16 $Vd, $imm",
8153                    (VBICiv8i16 QPR:$Vd, nImmSplatNotI16:$imm, pred:$p)>;
8154def : NEONInstAlias<"vand${p}.i32 $Vd, $imm",
8155                    (VBICiv4i32 QPR:$Vd, nImmSplatNotI32:$imm, pred:$p)>;
8156
8157
8158// VLD1 single-lane pseudo-instructions. These need special handling for
8159// the lane index that an InstAlias can't handle, so we use these instead.
8160def VLD1LNdAsm_8 : NEONDataTypeAsmPseudoInst<"vld1${p}", ".8", "$list, $addr",
8161                 (ins VecListOneDByteIndexed:$list, addrmode6alignNone:$addr,
8162                      pred:$p)>;
8163def VLD1LNdAsm_16 : NEONDataTypeAsmPseudoInst<"vld1${p}", ".16", "$list, $addr",
8164                 (ins VecListOneDHWordIndexed:$list, addrmode6align16:$addr,
8165                      pred:$p)>;
8166def VLD1LNdAsm_32 : NEONDataTypeAsmPseudoInst<"vld1${p}", ".32", "$list, $addr",
8167                 (ins VecListOneDWordIndexed:$list, addrmode6align32:$addr,
8168                      pred:$p)>;
8169
8170def VLD1LNdWB_fixed_Asm_8 :
8171        NEONDataTypeAsmPseudoInst<"vld1${p}", ".8", "$list, $addr!",
8172                 (ins VecListOneDByteIndexed:$list, addrmode6alignNone:$addr,
8173                      pred:$p)>;
8174def VLD1LNdWB_fixed_Asm_16 :
8175        NEONDataTypeAsmPseudoInst<"vld1${p}", ".16", "$list, $addr!",
8176                 (ins VecListOneDHWordIndexed:$list, addrmode6align16:$addr,
8177                      pred:$p)>;
8178def VLD1LNdWB_fixed_Asm_32 :
8179        NEONDataTypeAsmPseudoInst<"vld1${p}", ".32", "$list, $addr!",
8180                 (ins VecListOneDWordIndexed:$list, addrmode6align32:$addr,
8181                      pred:$p)>;
8182def VLD1LNdWB_register_Asm_8 :
8183        NEONDataTypeAsmPseudoInst<"vld1${p}", ".8", "$list, $addr, $Rm",
8184                  (ins VecListOneDByteIndexed:$list, addrmode6alignNone:$addr,
8185                       rGPR:$Rm, pred:$p)>;
8186def VLD1LNdWB_register_Asm_16 :
8187        NEONDataTypeAsmPseudoInst<"vld1${p}", ".16", "$list, $addr, $Rm",
8188                  (ins VecListOneDHWordIndexed:$list, addrmode6align16:$addr,
8189                       rGPR:$Rm, pred:$p)>;
8190def VLD1LNdWB_register_Asm_32 :
8191        NEONDataTypeAsmPseudoInst<"vld1${p}", ".32", "$list, $addr, $Rm",
8192                  (ins VecListOneDWordIndexed:$list, addrmode6align32:$addr,
8193                       rGPR:$Rm, pred:$p)>;
8194
8195
8196// VST1 single-lane pseudo-instructions. These need special handling for
8197// the lane index that an InstAlias can't handle, so we use these instead.
8198def VST1LNdAsm_8 : NEONDataTypeAsmPseudoInst<"vst1${p}", ".8", "$list, $addr",
8199                 (ins VecListOneDByteIndexed:$list, addrmode6alignNone:$addr,
8200                      pred:$p)>;
8201def VST1LNdAsm_16 : NEONDataTypeAsmPseudoInst<"vst1${p}", ".16", "$list, $addr",
8202                 (ins VecListOneDHWordIndexed:$list, addrmode6align16:$addr,
8203                      pred:$p)>;
8204def VST1LNdAsm_32 : NEONDataTypeAsmPseudoInst<"vst1${p}", ".32", "$list, $addr",
8205                 (ins VecListOneDWordIndexed:$list, addrmode6align32:$addr,
8206                      pred:$p)>;
8207
8208def VST1LNdWB_fixed_Asm_8 :
8209        NEONDataTypeAsmPseudoInst<"vst1${p}", ".8", "$list, $addr!",
8210                 (ins VecListOneDByteIndexed:$list, addrmode6alignNone:$addr,
8211                      pred:$p)>;
8212def VST1LNdWB_fixed_Asm_16 :
8213        NEONDataTypeAsmPseudoInst<"vst1${p}", ".16", "$list, $addr!",
8214                 (ins VecListOneDHWordIndexed:$list, addrmode6align16:$addr,
8215                      pred:$p)>;
8216def VST1LNdWB_fixed_Asm_32 :
8217        NEONDataTypeAsmPseudoInst<"vst1${p}", ".32", "$list, $addr!",
8218                 (ins VecListOneDWordIndexed:$list, addrmode6align32:$addr,
8219                      pred:$p)>;
8220def VST1LNdWB_register_Asm_8 :
8221        NEONDataTypeAsmPseudoInst<"vst1${p}", ".8", "$list, $addr, $Rm",
8222                  (ins VecListOneDByteIndexed:$list, addrmode6alignNone:$addr,
8223                       rGPR:$Rm, pred:$p)>;
8224def VST1LNdWB_register_Asm_16 :
8225        NEONDataTypeAsmPseudoInst<"vst1${p}", ".16", "$list, $addr, $Rm",
8226                  (ins VecListOneDHWordIndexed:$list, addrmode6align16:$addr,
8227                       rGPR:$Rm, pred:$p)>;
8228def VST1LNdWB_register_Asm_32 :
8229        NEONDataTypeAsmPseudoInst<"vst1${p}", ".32", "$list, $addr, $Rm",
8230                  (ins VecListOneDWordIndexed:$list, addrmode6align32:$addr,
8231                       rGPR:$Rm, pred:$p)>;
8232
8233// VLD2 single-lane pseudo-instructions. These need special handling for
8234// the lane index that an InstAlias can't handle, so we use these instead.
8235def VLD2LNdAsm_8 : NEONDataTypeAsmPseudoInst<"vld2${p}", ".8", "$list, $addr",
8236                 (ins VecListTwoDByteIndexed:$list, addrmode6align16:$addr,
8237                  pred:$p)>;
8238def VLD2LNdAsm_16 : NEONDataTypeAsmPseudoInst<"vld2${p}", ".16", "$list, $addr",
8239                 (ins VecListTwoDHWordIndexed:$list, addrmode6align32:$addr,
8240                      pred:$p)>;
8241def VLD2LNdAsm_32 : NEONDataTypeAsmPseudoInst<"vld2${p}", ".32", "$list, $addr",
8242                 (ins VecListTwoDWordIndexed:$list, addrmode6align64:$addr, pred:$p)>;
8243def VLD2LNqAsm_16 : NEONDataTypeAsmPseudoInst<"vld2${p}", ".16", "$list, $addr",
8244                 (ins VecListTwoQHWordIndexed:$list, addrmode6align32:$addr,
8245                      pred:$p)>;
8246def VLD2LNqAsm_32 : NEONDataTypeAsmPseudoInst<"vld2${p}", ".32", "$list, $addr",
8247                 (ins VecListTwoQWordIndexed:$list, addrmode6align64:$addr,
8248                      pred:$p)>;
8249
8250def VLD2LNdWB_fixed_Asm_8 :
8251        NEONDataTypeAsmPseudoInst<"vld2${p}", ".8", "$list, $addr!",
8252                 (ins VecListTwoDByteIndexed:$list, addrmode6align16:$addr,
8253                      pred:$p)>;
8254def VLD2LNdWB_fixed_Asm_16 :
8255        NEONDataTypeAsmPseudoInst<"vld2${p}", ".16", "$list, $addr!",
8256                 (ins VecListTwoDHWordIndexed:$list, addrmode6align32:$addr,
8257                      pred:$p)>;
8258def VLD2LNdWB_fixed_Asm_32 :
8259        NEONDataTypeAsmPseudoInst<"vld2${p}", ".32", "$list, $addr!",
8260                 (ins VecListTwoDWordIndexed:$list, addrmode6align64:$addr,
8261                      pred:$p)>;
8262def VLD2LNqWB_fixed_Asm_16 :
8263        NEONDataTypeAsmPseudoInst<"vld2${p}", ".16", "$list, $addr!",
8264                 (ins VecListTwoQHWordIndexed:$list, addrmode6align32:$addr,
8265                      pred:$p)>;
8266def VLD2LNqWB_fixed_Asm_32 :
8267        NEONDataTypeAsmPseudoInst<"vld2${p}", ".32", "$list, $addr!",
8268                 (ins VecListTwoQWordIndexed:$list, addrmode6align64:$addr,
8269                      pred:$p)>;
8270def VLD2LNdWB_register_Asm_8 :
8271        NEONDataTypeAsmPseudoInst<"vld2${p}", ".8", "$list, $addr, $Rm",
8272                  (ins VecListTwoDByteIndexed:$list, addrmode6align16:$addr,
8273                       rGPR:$Rm, pred:$p)>;
8274def VLD2LNdWB_register_Asm_16 :
8275        NEONDataTypeAsmPseudoInst<"vld2${p}", ".16", "$list, $addr, $Rm",
8276                  (ins VecListTwoDHWordIndexed:$list, addrmode6align32:$addr,
8277                       rGPR:$Rm, pred:$p)>;
8278def VLD2LNdWB_register_Asm_32 :
8279        NEONDataTypeAsmPseudoInst<"vld2${p}", ".32", "$list, $addr, $Rm",
8280                  (ins VecListTwoDWordIndexed:$list, addrmode6align64:$addr,
8281                       rGPR:$Rm, pred:$p)>;
8282def VLD2LNqWB_register_Asm_16 :
8283        NEONDataTypeAsmPseudoInst<"vld2${p}", ".16", "$list, $addr, $Rm",
8284                  (ins VecListTwoQHWordIndexed:$list, addrmode6align32:$addr,
8285                       rGPR:$Rm, pred:$p)>;
8286def VLD2LNqWB_register_Asm_32 :
8287        NEONDataTypeAsmPseudoInst<"vld2${p}", ".32", "$list, $addr, $Rm",
8288                  (ins VecListTwoQWordIndexed:$list, addrmode6align64:$addr,
8289                       rGPR:$Rm, pred:$p)>;
8290
8291
8292// VST2 single-lane pseudo-instructions. These need special handling for
8293// the lane index that an InstAlias can't handle, so we use these instead.
8294def VST2LNdAsm_8 : NEONDataTypeAsmPseudoInst<"vst2${p}", ".8", "$list, $addr",
8295                 (ins VecListTwoDByteIndexed:$list, addrmode6align16:$addr,
8296                      pred:$p)>;
8297def VST2LNdAsm_16 : NEONDataTypeAsmPseudoInst<"vst2${p}", ".16", "$list, $addr",
8298                 (ins VecListTwoDHWordIndexed:$list, addrmode6align32:$addr,
8299                      pred:$p)>;
8300def VST2LNdAsm_32 : NEONDataTypeAsmPseudoInst<"vst2${p}", ".32", "$list, $addr",
8301                 (ins VecListTwoDWordIndexed:$list, addrmode6align64:$addr,
8302                      pred:$p)>;
8303def VST2LNqAsm_16 : NEONDataTypeAsmPseudoInst<"vst2${p}", ".16", "$list, $addr",
8304                 (ins VecListTwoQHWordIndexed:$list, addrmode6align32:$addr,
8305                      pred:$p)>;
8306def VST2LNqAsm_32 : NEONDataTypeAsmPseudoInst<"vst2${p}", ".32", "$list, $addr",
8307                 (ins VecListTwoQWordIndexed:$list, addrmode6align64:$addr,
8308                      pred:$p)>;
8309
8310def VST2LNdWB_fixed_Asm_8 :
8311        NEONDataTypeAsmPseudoInst<"vst2${p}", ".8", "$list, $addr!",
8312                 (ins VecListTwoDByteIndexed:$list, addrmode6align16:$addr,
8313                      pred:$p)>;
8314def VST2LNdWB_fixed_Asm_16 :
8315        NEONDataTypeAsmPseudoInst<"vst2${p}", ".16", "$list, $addr!",
8316                 (ins VecListTwoDHWordIndexed:$list, addrmode6align32:$addr,
8317                      pred:$p)>;
8318def VST2LNdWB_fixed_Asm_32 :
8319        NEONDataTypeAsmPseudoInst<"vst2${p}", ".32", "$list, $addr!",
8320                 (ins VecListTwoDWordIndexed:$list, addrmode6align64:$addr,
8321                      pred:$p)>;
8322def VST2LNqWB_fixed_Asm_16 :
8323        NEONDataTypeAsmPseudoInst<"vst2${p}", ".16", "$list, $addr!",
8324                 (ins VecListTwoQHWordIndexed:$list, addrmode6align32:$addr,
8325                      pred:$p)>;
8326def VST2LNqWB_fixed_Asm_32 :
8327        NEONDataTypeAsmPseudoInst<"vst2${p}", ".32", "$list, $addr!",
8328                 (ins VecListTwoQWordIndexed:$list, addrmode6align64:$addr,
8329                      pred:$p)>;
8330def VST2LNdWB_register_Asm_8 :
8331        NEONDataTypeAsmPseudoInst<"vst2${p}", ".8", "$list, $addr, $Rm",
8332                  (ins VecListTwoDByteIndexed:$list, addrmode6align16:$addr,
8333                       rGPR:$Rm, pred:$p)>;
8334def VST2LNdWB_register_Asm_16 :
8335        NEONDataTypeAsmPseudoInst<"vst2${p}", ".16","$list, $addr, $Rm",
8336                  (ins VecListTwoDHWordIndexed:$list, addrmode6align32:$addr,
8337                       rGPR:$Rm, pred:$p)>;
8338def VST2LNdWB_register_Asm_32 :
8339        NEONDataTypeAsmPseudoInst<"vst2${p}", ".32", "$list, $addr, $Rm",
8340                  (ins VecListTwoDWordIndexed:$list, addrmode6align64:$addr,
8341                       rGPR:$Rm, pred:$p)>;
8342def VST2LNqWB_register_Asm_16 :
8343        NEONDataTypeAsmPseudoInst<"vst2${p}", ".16","$list, $addr, $Rm",
8344                  (ins VecListTwoQHWordIndexed:$list, addrmode6align32:$addr,
8345                       rGPR:$Rm, pred:$p)>;
8346def VST2LNqWB_register_Asm_32 :
8347        NEONDataTypeAsmPseudoInst<"vst2${p}", ".32", "$list, $addr, $Rm",
8348                  (ins VecListTwoQWordIndexed:$list, addrmode6align64:$addr,
8349                       rGPR:$Rm, pred:$p)>;
8350
8351// VLD3 all-lanes pseudo-instructions. These need special handling for
8352// the lane index that an InstAlias can't handle, so we use these instead.
8353def VLD3DUPdAsm_8 : NEONDataTypeAsmPseudoInst<"vld3${p}", ".8", "$list, $addr",
8354               (ins VecListThreeDAllLanes:$list, addrmode6dupalignNone:$addr,
8355                    pred:$p)>;
8356def VLD3DUPdAsm_16: NEONDataTypeAsmPseudoInst<"vld3${p}", ".16", "$list, $addr",
8357               (ins VecListThreeDAllLanes:$list, addrmode6dupalignNone:$addr,
8358                    pred:$p)>;
8359def VLD3DUPdAsm_32: NEONDataTypeAsmPseudoInst<"vld3${p}", ".32", "$list, $addr",
8360               (ins VecListThreeDAllLanes:$list, addrmode6dupalignNone:$addr,
8361                    pred:$p)>;
8362def VLD3DUPqAsm_8 : NEONDataTypeAsmPseudoInst<"vld3${p}", ".8", "$list, $addr",
8363               (ins VecListThreeQAllLanes:$list, addrmode6dupalignNone:$addr,
8364                    pred:$p)>;
8365def VLD3DUPqAsm_16: NEONDataTypeAsmPseudoInst<"vld3${p}", ".16", "$list, $addr",
8366               (ins VecListThreeQAllLanes:$list, addrmode6dupalignNone:$addr,
8367                    pred:$p)>;
8368def VLD3DUPqAsm_32: NEONDataTypeAsmPseudoInst<"vld3${p}", ".32", "$list, $addr",
8369               (ins VecListThreeQAllLanes:$list, addrmode6dupalignNone:$addr,
8370                    pred:$p)>;
8371
8372def VLD3DUPdWB_fixed_Asm_8 :
8373        NEONDataTypeAsmPseudoInst<"vld3${p}", ".8", "$list, $addr!",
8374               (ins VecListThreeDAllLanes:$list, addrmode6dupalignNone:$addr,
8375                    pred:$p)>;
8376def VLD3DUPdWB_fixed_Asm_16 :
8377        NEONDataTypeAsmPseudoInst<"vld3${p}", ".16", "$list, $addr!",
8378               (ins VecListThreeDAllLanes:$list, addrmode6dupalignNone:$addr,
8379                    pred:$p)>;
8380def VLD3DUPdWB_fixed_Asm_32 :
8381        NEONDataTypeAsmPseudoInst<"vld3${p}", ".32", "$list, $addr!",
8382               (ins VecListThreeDAllLanes:$list, addrmode6dupalignNone:$addr,
8383                    pred:$p)>;
8384def VLD3DUPqWB_fixed_Asm_8 :
8385        NEONDataTypeAsmPseudoInst<"vld3${p}", ".8", "$list, $addr!",
8386               (ins VecListThreeQAllLanes:$list, addrmode6dupalignNone:$addr,
8387                    pred:$p)>;
8388def VLD3DUPqWB_fixed_Asm_16 :
8389        NEONDataTypeAsmPseudoInst<"vld3${p}", ".16", "$list, $addr!",
8390               (ins VecListThreeQAllLanes:$list, addrmode6dupalignNone:$addr,
8391                    pred:$p)>;
8392def VLD3DUPqWB_fixed_Asm_32 :
8393        NEONDataTypeAsmPseudoInst<"vld3${p}", ".32", "$list, $addr!",
8394               (ins VecListThreeQAllLanes:$list, addrmode6dupalignNone:$addr,
8395                    pred:$p)>;
8396def VLD3DUPdWB_register_Asm_8 :
8397        NEONDataTypeAsmPseudoInst<"vld3${p}", ".8", "$list, $addr, $Rm",
8398                  (ins VecListThreeDAllLanes:$list, addrmode6dupalignNone:$addr,
8399                       rGPR:$Rm, pred:$p)>;
8400def VLD3DUPdWB_register_Asm_16 :
8401        NEONDataTypeAsmPseudoInst<"vld3${p}", ".16", "$list, $addr, $Rm",
8402                  (ins VecListThreeDAllLanes:$list, addrmode6dupalignNone:$addr,
8403                       rGPR:$Rm, pred:$p)>;
8404def VLD3DUPdWB_register_Asm_32 :
8405        NEONDataTypeAsmPseudoInst<"vld3${p}", ".32", "$list, $addr, $Rm",
8406                  (ins VecListThreeDAllLanes:$list, addrmode6dupalignNone:$addr,
8407                       rGPR:$Rm, pred:$p)>;
8408def VLD3DUPqWB_register_Asm_8 :
8409        NEONDataTypeAsmPseudoInst<"vld3${p}", ".8", "$list, $addr, $Rm",
8410                  (ins VecListThreeQAllLanes:$list, addrmode6dupalignNone:$addr,
8411                       rGPR:$Rm, pred:$p)>;
8412def VLD3DUPqWB_register_Asm_16 :
8413        NEONDataTypeAsmPseudoInst<"vld3${p}", ".16", "$list, $addr, $Rm",
8414                  (ins VecListThreeQAllLanes:$list, addrmode6dupalignNone:$addr,
8415                       rGPR:$Rm, pred:$p)>;
8416def VLD3DUPqWB_register_Asm_32 :
8417        NEONDataTypeAsmPseudoInst<"vld3${p}", ".32", "$list, $addr, $Rm",
8418                  (ins VecListThreeQAllLanes:$list, addrmode6dupalignNone:$addr,
8419                       rGPR:$Rm, pred:$p)>;
8420
8421
8422// VLD3 single-lane pseudo-instructions. These need special handling for
8423// the lane index that an InstAlias can't handle, so we use these instead.
8424def VLD3LNdAsm_8 : NEONDataTypeAsmPseudoInst<"vld3${p}", ".8", "$list, $addr",
8425               (ins VecListThreeDByteIndexed:$list, addrmode6alignNone:$addr,
8426                    pred:$p)>;
8427def VLD3LNdAsm_16 : NEONDataTypeAsmPseudoInst<"vld3${p}", ".16", "$list, $addr",
8428               (ins VecListThreeDHWordIndexed:$list, addrmode6alignNone:$addr,
8429                    pred:$p)>;
8430def VLD3LNdAsm_32 : NEONDataTypeAsmPseudoInst<"vld3${p}", ".32", "$list, $addr",
8431               (ins VecListThreeDWordIndexed:$list, addrmode6alignNone:$addr,
8432                    pred:$p)>;
8433def VLD3LNqAsm_16 : NEONDataTypeAsmPseudoInst<"vld3${p}", ".16", "$list, $addr",
8434               (ins VecListThreeQHWordIndexed:$list, addrmode6alignNone:$addr,
8435                    pred:$p)>;
8436def VLD3LNqAsm_32 : NEONDataTypeAsmPseudoInst<"vld3${p}", ".32", "$list, $addr",
8437               (ins VecListThreeQWordIndexed:$list, addrmode6alignNone:$addr,
8438                    pred:$p)>;
8439
8440def VLD3LNdWB_fixed_Asm_8 :
8441        NEONDataTypeAsmPseudoInst<"vld3${p}", ".8", "$list, $addr!",
8442               (ins VecListThreeDByteIndexed:$list, addrmode6alignNone:$addr,
8443                    pred:$p)>;
8444def VLD3LNdWB_fixed_Asm_16 :
8445        NEONDataTypeAsmPseudoInst<"vld3${p}", ".16", "$list, $addr!",
8446               (ins VecListThreeDHWordIndexed:$list, addrmode6alignNone:$addr,
8447                    pred:$p)>;
8448def VLD3LNdWB_fixed_Asm_32 :
8449        NEONDataTypeAsmPseudoInst<"vld3${p}", ".32", "$list, $addr!",
8450               (ins VecListThreeDWordIndexed:$list, addrmode6alignNone:$addr,
8451                    pred:$p)>;
8452def VLD3LNqWB_fixed_Asm_16 :
8453        NEONDataTypeAsmPseudoInst<"vld3${p}", ".16", "$list, $addr!",
8454               (ins VecListThreeQHWordIndexed:$list, addrmode6alignNone:$addr,
8455                    pred:$p)>;
8456def VLD3LNqWB_fixed_Asm_32 :
8457        NEONDataTypeAsmPseudoInst<"vld3${p}", ".32", "$list, $addr!",
8458               (ins VecListThreeQWordIndexed:$list, addrmode6alignNone:$addr,
8459                    pred:$p)>;
8460def VLD3LNdWB_register_Asm_8 :
8461        NEONDataTypeAsmPseudoInst<"vld3${p}", ".8", "$list, $addr, $Rm",
8462                  (ins VecListThreeDByteIndexed:$list, addrmode6alignNone:$addr,
8463                       rGPR:$Rm, pred:$p)>;
8464def VLD3LNdWB_register_Asm_16 :
8465        NEONDataTypeAsmPseudoInst<"vld3${p}", ".16", "$list, $addr, $Rm",
8466                  (ins VecListThreeDHWordIndexed:$list,
8467                       addrmode6alignNone:$addr, rGPR:$Rm, pred:$p)>;
8468def VLD3LNdWB_register_Asm_32 :
8469        NEONDataTypeAsmPseudoInst<"vld3${p}", ".32", "$list, $addr, $Rm",
8470                  (ins VecListThreeDWordIndexed:$list, addrmode6alignNone:$addr,
8471                       rGPR:$Rm, pred:$p)>;
8472def VLD3LNqWB_register_Asm_16 :
8473        NEONDataTypeAsmPseudoInst<"vld3${p}", ".16", "$list, $addr, $Rm",
8474                  (ins VecListThreeQHWordIndexed:$list,
8475                       addrmode6alignNone:$addr, rGPR:$Rm, pred:$p)>;
8476def VLD3LNqWB_register_Asm_32 :
8477        NEONDataTypeAsmPseudoInst<"vld3${p}", ".32", "$list, $addr, $Rm",
8478                  (ins VecListThreeQWordIndexed:$list, addrmode6alignNone:$addr,
8479                       rGPR:$Rm, pred:$p)>;
8480
8481// VLD3 multiple structure pseudo-instructions. These need special handling for
8482// the vector operands that the normal instructions don't yet model.
8483// FIXME: Remove these when the register classes and instructions are updated.
8484def VLD3dAsm_8 : NEONDataTypeAsmPseudoInst<"vld3${p}", ".8", "$list, $addr",
8485               (ins VecListThreeD:$list, addrmode6align64:$addr, pred:$p)>;
8486def VLD3dAsm_16 : NEONDataTypeAsmPseudoInst<"vld3${p}", ".16", "$list, $addr",
8487               (ins VecListThreeD:$list, addrmode6align64:$addr, pred:$p)>;
8488def VLD3dAsm_32 : NEONDataTypeAsmPseudoInst<"vld3${p}", ".32", "$list, $addr",
8489               (ins VecListThreeD:$list, addrmode6align64:$addr, pred:$p)>;
8490def VLD3qAsm_8 : NEONDataTypeAsmPseudoInst<"vld3${p}", ".8", "$list, $addr",
8491               (ins VecListThreeQ:$list, addrmode6align64:$addr, pred:$p)>;
8492def VLD3qAsm_16 : NEONDataTypeAsmPseudoInst<"vld3${p}", ".16", "$list, $addr",
8493               (ins VecListThreeQ:$list, addrmode6align64:$addr, pred:$p)>;
8494def VLD3qAsm_32 : NEONDataTypeAsmPseudoInst<"vld3${p}", ".32", "$list, $addr",
8495               (ins VecListThreeQ:$list, addrmode6align64:$addr, pred:$p)>;
8496
8497def VLD3dWB_fixed_Asm_8 :
8498        NEONDataTypeAsmPseudoInst<"vld3${p}", ".8", "$list, $addr!",
8499               (ins VecListThreeD:$list, addrmode6align64:$addr, pred:$p)>;
8500def VLD3dWB_fixed_Asm_16 :
8501        NEONDataTypeAsmPseudoInst<"vld3${p}", ".16", "$list, $addr!",
8502               (ins VecListThreeD:$list, addrmode6align64:$addr, pred:$p)>;
8503def VLD3dWB_fixed_Asm_32 :
8504        NEONDataTypeAsmPseudoInst<"vld3${p}", ".32", "$list, $addr!",
8505               (ins VecListThreeD:$list, addrmode6align64:$addr, pred:$p)>;
8506def VLD3qWB_fixed_Asm_8 :
8507        NEONDataTypeAsmPseudoInst<"vld3${p}", ".8", "$list, $addr!",
8508               (ins VecListThreeQ:$list, addrmode6align64:$addr, pred:$p)>;
8509def VLD3qWB_fixed_Asm_16 :
8510        NEONDataTypeAsmPseudoInst<"vld3${p}", ".16", "$list, $addr!",
8511               (ins VecListThreeQ:$list, addrmode6align64:$addr, pred:$p)>;
8512def VLD3qWB_fixed_Asm_32 :
8513        NEONDataTypeAsmPseudoInst<"vld3${p}", ".32", "$list, $addr!",
8514               (ins VecListThreeQ:$list, addrmode6align64:$addr, pred:$p)>;
8515def VLD3dWB_register_Asm_8 :
8516        NEONDataTypeAsmPseudoInst<"vld3${p}", ".8", "$list, $addr, $Rm",
8517                  (ins VecListThreeD:$list, addrmode6align64:$addr,
8518                       rGPR:$Rm, pred:$p)>;
8519def VLD3dWB_register_Asm_16 :
8520        NEONDataTypeAsmPseudoInst<"vld3${p}", ".16", "$list, $addr, $Rm",
8521                  (ins VecListThreeD:$list, addrmode6align64:$addr,
8522                       rGPR:$Rm, pred:$p)>;
8523def VLD3dWB_register_Asm_32 :
8524        NEONDataTypeAsmPseudoInst<"vld3${p}", ".32", "$list, $addr, $Rm",
8525                  (ins VecListThreeD:$list, addrmode6align64:$addr,
8526                       rGPR:$Rm, pred:$p)>;
8527def VLD3qWB_register_Asm_8 :
8528        NEONDataTypeAsmPseudoInst<"vld3${p}", ".8", "$list, $addr, $Rm",
8529                  (ins VecListThreeQ:$list, addrmode6align64:$addr,
8530                       rGPR:$Rm, pred:$p)>;
8531def VLD3qWB_register_Asm_16 :
8532        NEONDataTypeAsmPseudoInst<"vld3${p}", ".16", "$list, $addr, $Rm",
8533                  (ins VecListThreeQ:$list, addrmode6align64:$addr,
8534                       rGPR:$Rm, pred:$p)>;
8535def VLD3qWB_register_Asm_32 :
8536        NEONDataTypeAsmPseudoInst<"vld3${p}", ".32", "$list, $addr, $Rm",
8537                  (ins VecListThreeQ:$list, addrmode6align64:$addr,
8538                       rGPR:$Rm, pred:$p)>;
8539
8540// VST3 single-lane pseudo-instructions. These need special handling for
8541// the lane index that an InstAlias can't handle, so we use these instead.
8542def VST3LNdAsm_8 : NEONDataTypeAsmPseudoInst<"vst3${p}", ".8", "$list, $addr",
8543               (ins VecListThreeDByteIndexed:$list, addrmode6alignNone:$addr,
8544                    pred:$p)>;
8545def VST3LNdAsm_16 : NEONDataTypeAsmPseudoInst<"vst3${p}", ".16", "$list, $addr",
8546               (ins VecListThreeDHWordIndexed:$list, addrmode6alignNone:$addr,
8547                    pred:$p)>;
8548def VST3LNdAsm_32 : NEONDataTypeAsmPseudoInst<"vst3${p}", ".32", "$list, $addr",
8549               (ins VecListThreeDWordIndexed:$list, addrmode6alignNone:$addr,
8550                    pred:$p)>;
8551def VST3LNqAsm_16 : NEONDataTypeAsmPseudoInst<"vst3${p}", ".16", "$list, $addr",
8552               (ins VecListThreeQHWordIndexed:$list, addrmode6alignNone:$addr,
8553                    pred:$p)>;
8554def VST3LNqAsm_32 : NEONDataTypeAsmPseudoInst<"vst3${p}", ".32", "$list, $addr",
8555               (ins VecListThreeQWordIndexed:$list, addrmode6alignNone:$addr,
8556                    pred:$p)>;
8557
8558def VST3LNdWB_fixed_Asm_8 :
8559        NEONDataTypeAsmPseudoInst<"vst3${p}", ".8", "$list, $addr!",
8560               (ins VecListThreeDByteIndexed:$list, addrmode6alignNone:$addr,
8561                    pred:$p)>;
8562def VST3LNdWB_fixed_Asm_16 :
8563        NEONDataTypeAsmPseudoInst<"vst3${p}", ".16", "$list, $addr!",
8564               (ins VecListThreeDHWordIndexed:$list, addrmode6alignNone:$addr,
8565                    pred:$p)>;
8566def VST3LNdWB_fixed_Asm_32 :
8567        NEONDataTypeAsmPseudoInst<"vst3${p}", ".32", "$list, $addr!",
8568               (ins VecListThreeDWordIndexed:$list, addrmode6alignNone:$addr,
8569                    pred:$p)>;
8570def VST3LNqWB_fixed_Asm_16 :
8571        NEONDataTypeAsmPseudoInst<"vst3${p}", ".16", "$list, $addr!",
8572               (ins VecListThreeQHWordIndexed:$list, addrmode6alignNone:$addr,
8573                    pred:$p)>;
8574def VST3LNqWB_fixed_Asm_32 :
8575        NEONDataTypeAsmPseudoInst<"vst3${p}", ".32", "$list, $addr!",
8576               (ins VecListThreeQWordIndexed:$list, addrmode6alignNone:$addr,
8577                    pred:$p)>;
8578def VST3LNdWB_register_Asm_8 :
8579        NEONDataTypeAsmPseudoInst<"vst3${p}", ".8", "$list, $addr, $Rm",
8580                  (ins VecListThreeDByteIndexed:$list, addrmode6alignNone:$addr,
8581                       rGPR:$Rm, pred:$p)>;
8582def VST3LNdWB_register_Asm_16 :
8583        NEONDataTypeAsmPseudoInst<"vst3${p}", ".16", "$list, $addr, $Rm",
8584                  (ins VecListThreeDHWordIndexed:$list,
8585                       addrmode6alignNone:$addr, rGPR:$Rm, pred:$p)>;
8586def VST3LNdWB_register_Asm_32 :
8587        NEONDataTypeAsmPseudoInst<"vst3${p}", ".32", "$list, $addr, $Rm",
8588                  (ins VecListThreeDWordIndexed:$list, addrmode6alignNone:$addr,
8589                       rGPR:$Rm, pred:$p)>;
8590def VST3LNqWB_register_Asm_16 :
8591        NEONDataTypeAsmPseudoInst<"vst3${p}", ".16", "$list, $addr, $Rm",
8592                  (ins VecListThreeQHWordIndexed:$list,
8593                       addrmode6alignNone:$addr, rGPR:$Rm, pred:$p)>;
8594def VST3LNqWB_register_Asm_32 :
8595        NEONDataTypeAsmPseudoInst<"vst3${p}", ".32", "$list, $addr, $Rm",
8596                  (ins VecListThreeQWordIndexed:$list, addrmode6alignNone:$addr,
8597                       rGPR:$Rm, pred:$p)>;
8598
8599
8600// VST3 multiple structure pseudo-instructions. These need special handling for
8601// the vector operands that the normal instructions don't yet model.
8602// FIXME: Remove these when the register classes and instructions are updated.
8603def VST3dAsm_8 : NEONDataTypeAsmPseudoInst<"vst3${p}", ".8", "$list, $addr",
8604               (ins VecListThreeD:$list, addrmode6align64:$addr, pred:$p)>;
8605def VST3dAsm_16 : NEONDataTypeAsmPseudoInst<"vst3${p}", ".16", "$list, $addr",
8606               (ins VecListThreeD:$list, addrmode6align64:$addr, pred:$p)>;
8607def VST3dAsm_32 : NEONDataTypeAsmPseudoInst<"vst3${p}", ".32", "$list, $addr",
8608               (ins VecListThreeD:$list, addrmode6align64:$addr, pred:$p)>;
8609def VST3qAsm_8 : NEONDataTypeAsmPseudoInst<"vst3${p}", ".8", "$list, $addr",
8610               (ins VecListThreeQ:$list, addrmode6align64:$addr, pred:$p)>;
8611def VST3qAsm_16 : NEONDataTypeAsmPseudoInst<"vst3${p}", ".16", "$list, $addr",
8612               (ins VecListThreeQ:$list, addrmode6align64:$addr, pred:$p)>;
8613def VST3qAsm_32 : NEONDataTypeAsmPseudoInst<"vst3${p}", ".32", "$list, $addr",
8614               (ins VecListThreeQ:$list, addrmode6align64:$addr, pred:$p)>;
8615
8616def VST3dWB_fixed_Asm_8 :
8617        NEONDataTypeAsmPseudoInst<"vst3${p}", ".8", "$list, $addr!",
8618               (ins VecListThreeD:$list, addrmode6align64:$addr, pred:$p)>;
8619def VST3dWB_fixed_Asm_16 :
8620        NEONDataTypeAsmPseudoInst<"vst3${p}", ".16", "$list, $addr!",
8621               (ins VecListThreeD:$list, addrmode6align64:$addr, pred:$p)>;
8622def VST3dWB_fixed_Asm_32 :
8623        NEONDataTypeAsmPseudoInst<"vst3${p}", ".32", "$list, $addr!",
8624               (ins VecListThreeD:$list, addrmode6align64:$addr, pred:$p)>;
8625def VST3qWB_fixed_Asm_8 :
8626        NEONDataTypeAsmPseudoInst<"vst3${p}", ".8", "$list, $addr!",
8627               (ins VecListThreeQ:$list, addrmode6align64:$addr, pred:$p)>;
8628def VST3qWB_fixed_Asm_16 :
8629        NEONDataTypeAsmPseudoInst<"vst3${p}", ".16", "$list, $addr!",
8630               (ins VecListThreeQ:$list, addrmode6align64:$addr, pred:$p)>;
8631def VST3qWB_fixed_Asm_32 :
8632        NEONDataTypeAsmPseudoInst<"vst3${p}", ".32", "$list, $addr!",
8633               (ins VecListThreeQ:$list, addrmode6align64:$addr, pred:$p)>;
8634def VST3dWB_register_Asm_8 :
8635        NEONDataTypeAsmPseudoInst<"vst3${p}", ".8", "$list, $addr, $Rm",
8636                  (ins VecListThreeD:$list, addrmode6align64:$addr,
8637                       rGPR:$Rm, pred:$p)>;
8638def VST3dWB_register_Asm_16 :
8639        NEONDataTypeAsmPseudoInst<"vst3${p}", ".16", "$list, $addr, $Rm",
8640                  (ins VecListThreeD:$list, addrmode6align64:$addr,
8641                       rGPR:$Rm, pred:$p)>;
8642def VST3dWB_register_Asm_32 :
8643        NEONDataTypeAsmPseudoInst<"vst3${p}", ".32", "$list, $addr, $Rm",
8644                  (ins VecListThreeD:$list, addrmode6align64:$addr,
8645                       rGPR:$Rm, pred:$p)>;
8646def VST3qWB_register_Asm_8 :
8647        NEONDataTypeAsmPseudoInst<"vst3${p}", ".8", "$list, $addr, $Rm",
8648                  (ins VecListThreeQ:$list, addrmode6align64:$addr,
8649                       rGPR:$Rm, pred:$p)>;
8650def VST3qWB_register_Asm_16 :
8651        NEONDataTypeAsmPseudoInst<"vst3${p}", ".16", "$list, $addr, $Rm",
8652                  (ins VecListThreeQ:$list, addrmode6align64:$addr,
8653                       rGPR:$Rm, pred:$p)>;
8654def VST3qWB_register_Asm_32 :
8655        NEONDataTypeAsmPseudoInst<"vst3${p}", ".32", "$list, $addr, $Rm",
8656                  (ins VecListThreeQ:$list, addrmode6align64:$addr,
8657                       rGPR:$Rm, pred:$p)>;
8658
8659// VLD4 all-lanes pseudo-instructions. These need special handling for
8660// the lane index that an InstAlias can't handle, so we use these instead.
8661def VLD4DUPdAsm_8 : NEONDataTypeAsmPseudoInst<"vld4${p}", ".8", "$list, $addr",
8662               (ins VecListFourDAllLanes:$list, addrmode6dupalign32:$addr,
8663                    pred:$p)>;
8664def VLD4DUPdAsm_16: NEONDataTypeAsmPseudoInst<"vld4${p}", ".16", "$list, $addr",
8665               (ins VecListFourDAllLanes:$list, addrmode6dupalign64:$addr,
8666                    pred:$p)>;
8667def VLD4DUPdAsm_32: NEONDataTypeAsmPseudoInst<"vld4${p}", ".32", "$list, $addr",
8668               (ins VecListFourDAllLanes:$list, addrmode6dupalign64or128:$addr,
8669                    pred:$p)>;
8670def VLD4DUPqAsm_8 : NEONDataTypeAsmPseudoInst<"vld4${p}", ".8", "$list, $addr",
8671               (ins VecListFourQAllLanes:$list, addrmode6dupalign32:$addr,
8672                    pred:$p)>;
8673def VLD4DUPqAsm_16: NEONDataTypeAsmPseudoInst<"vld4${p}", ".16", "$list, $addr",
8674               (ins VecListFourQAllLanes:$list, addrmode6dupalign64:$addr,
8675                    pred:$p)>;
8676def VLD4DUPqAsm_32: NEONDataTypeAsmPseudoInst<"vld4${p}", ".32", "$list, $addr",
8677               (ins VecListFourQAllLanes:$list, addrmode6dupalign64or128:$addr,
8678                    pred:$p)>;
8679
8680def VLD4DUPdWB_fixed_Asm_8 :
8681        NEONDataTypeAsmPseudoInst<"vld4${p}", ".8", "$list, $addr!",
8682               (ins VecListFourDAllLanes:$list, addrmode6dupalign32:$addr,
8683                    pred:$p)>;
8684def VLD4DUPdWB_fixed_Asm_16 :
8685        NEONDataTypeAsmPseudoInst<"vld4${p}", ".16", "$list, $addr!",
8686               (ins VecListFourDAllLanes:$list, addrmode6dupalign64:$addr,
8687                    pred:$p)>;
8688def VLD4DUPdWB_fixed_Asm_32 :
8689        NEONDataTypeAsmPseudoInst<"vld4${p}", ".32", "$list, $addr!",
8690               (ins VecListFourDAllLanes:$list, addrmode6dupalign64or128:$addr,
8691                    pred:$p)>;
8692def VLD4DUPqWB_fixed_Asm_8 :
8693        NEONDataTypeAsmPseudoInst<"vld4${p}", ".8", "$list, $addr!",
8694               (ins VecListFourQAllLanes:$list, addrmode6dupalign32:$addr,
8695                    pred:$p)>;
8696def VLD4DUPqWB_fixed_Asm_16 :
8697        NEONDataTypeAsmPseudoInst<"vld4${p}", ".16", "$list, $addr!",
8698               (ins VecListFourQAllLanes:$list, addrmode6dupalign64:$addr,
8699                    pred:$p)>;
8700def VLD4DUPqWB_fixed_Asm_32 :
8701        NEONDataTypeAsmPseudoInst<"vld4${p}", ".32", "$list, $addr!",
8702               (ins VecListFourQAllLanes:$list, addrmode6dupalign64or128:$addr,
8703                    pred:$p)>;
8704def VLD4DUPdWB_register_Asm_8 :
8705        NEONDataTypeAsmPseudoInst<"vld4${p}", ".8", "$list, $addr, $Rm",
8706                  (ins VecListFourDAllLanes:$list, addrmode6dupalign32:$addr,
8707                       rGPR:$Rm, pred:$p)>;
8708def VLD4DUPdWB_register_Asm_16 :
8709        NEONDataTypeAsmPseudoInst<"vld4${p}", ".16", "$list, $addr, $Rm",
8710                  (ins VecListFourDAllLanes:$list, addrmode6dupalign64:$addr,
8711                       rGPR:$Rm, pred:$p)>;
8712def VLD4DUPdWB_register_Asm_32 :
8713        NEONDataTypeAsmPseudoInst<"vld4${p}", ".32", "$list, $addr, $Rm",
8714                  (ins VecListFourDAllLanes:$list,
8715                       addrmode6dupalign64or128:$addr, rGPR:$Rm, pred:$p)>;
8716def VLD4DUPqWB_register_Asm_8 :
8717        NEONDataTypeAsmPseudoInst<"vld4${p}", ".8", "$list, $addr, $Rm",
8718                  (ins VecListFourQAllLanes:$list, addrmode6dupalign32:$addr,
8719                       rGPR:$Rm, pred:$p)>;
8720def VLD4DUPqWB_register_Asm_16 :
8721        NEONDataTypeAsmPseudoInst<"vld4${p}", ".16", "$list, $addr, $Rm",
8722                  (ins VecListFourQAllLanes:$list, addrmode6dupalign64:$addr,
8723                       rGPR:$Rm, pred:$p)>;
8724def VLD4DUPqWB_register_Asm_32 :
8725        NEONDataTypeAsmPseudoInst<"vld4${p}", ".32", "$list, $addr, $Rm",
8726                  (ins VecListFourQAllLanes:$list,
8727                       addrmode6dupalign64or128:$addr, rGPR:$Rm, pred:$p)>;
8728
8729
8730// VLD4 single-lane pseudo-instructions. These need special handling for
8731// the lane index that an InstAlias can't handle, so we use these instead.
8732def VLD4LNdAsm_8 : NEONDataTypeAsmPseudoInst<"vld4${p}", ".8", "$list, $addr",
8733               (ins VecListFourDByteIndexed:$list, addrmode6align32:$addr,
8734                    pred:$p)>;
8735def VLD4LNdAsm_16 : NEONDataTypeAsmPseudoInst<"vld4${p}", ".16", "$list, $addr",
8736               (ins VecListFourDHWordIndexed:$list, addrmode6align64:$addr,
8737                    pred:$p)>;
8738def VLD4LNdAsm_32 : NEONDataTypeAsmPseudoInst<"vld4${p}", ".32", "$list, $addr",
8739               (ins VecListFourDWordIndexed:$list, addrmode6align64or128:$addr,
8740                    pred:$p)>;
8741def VLD4LNqAsm_16 : NEONDataTypeAsmPseudoInst<"vld4${p}", ".16", "$list, $addr",
8742               (ins VecListFourQHWordIndexed:$list, addrmode6align64:$addr,
8743                    pred:$p)>;
8744def VLD4LNqAsm_32 : NEONDataTypeAsmPseudoInst<"vld4${p}", ".32", "$list, $addr",
8745               (ins VecListFourQWordIndexed:$list, addrmode6align64or128:$addr,
8746                    pred:$p)>;
8747
8748def VLD4LNdWB_fixed_Asm_8 :
8749        NEONDataTypeAsmPseudoInst<"vld4${p}", ".8", "$list, $addr!",
8750               (ins VecListFourDByteIndexed:$list, addrmode6align32:$addr,
8751                    pred:$p)>;
8752def VLD4LNdWB_fixed_Asm_16 :
8753        NEONDataTypeAsmPseudoInst<"vld4${p}", ".16", "$list, $addr!",
8754               (ins VecListFourDHWordIndexed:$list, addrmode6align64:$addr,
8755                    pred:$p)>;
8756def VLD4LNdWB_fixed_Asm_32 :
8757        NEONDataTypeAsmPseudoInst<"vld4${p}", ".32", "$list, $addr!",
8758               (ins VecListFourDWordIndexed:$list, addrmode6align64or128:$addr,
8759                    pred:$p)>;
8760def VLD4LNqWB_fixed_Asm_16 :
8761        NEONDataTypeAsmPseudoInst<"vld4${p}", ".16", "$list, $addr!",
8762               (ins VecListFourQHWordIndexed:$list, addrmode6align64:$addr,
8763                    pred:$p)>;
8764def VLD4LNqWB_fixed_Asm_32 :
8765        NEONDataTypeAsmPseudoInst<"vld4${p}", ".32", "$list, $addr!",
8766               (ins VecListFourQWordIndexed:$list, addrmode6align64or128:$addr,
8767                    pred:$p)>;
8768def VLD4LNdWB_register_Asm_8 :
8769        NEONDataTypeAsmPseudoInst<"vld4${p}", ".8", "$list, $addr, $Rm",
8770                  (ins VecListFourDByteIndexed:$list, addrmode6align32:$addr,
8771                       rGPR:$Rm, pred:$p)>;
8772def VLD4LNdWB_register_Asm_16 :
8773        NEONDataTypeAsmPseudoInst<"vld4${p}", ".16", "$list, $addr, $Rm",
8774                  (ins VecListFourDHWordIndexed:$list, addrmode6align64:$addr,
8775                       rGPR:$Rm, pred:$p)>;
8776def VLD4LNdWB_register_Asm_32 :
8777        NEONDataTypeAsmPseudoInst<"vld4${p}", ".32", "$list, $addr, $Rm",
8778                  (ins VecListFourDWordIndexed:$list,
8779                       addrmode6align64or128:$addr, rGPR:$Rm, pred:$p)>;
8780def VLD4LNqWB_register_Asm_16 :
8781        NEONDataTypeAsmPseudoInst<"vld4${p}", ".16", "$list, $addr, $Rm",
8782                  (ins VecListFourQHWordIndexed:$list, addrmode6align64:$addr,
8783                       rGPR:$Rm, pred:$p)>;
8784def VLD4LNqWB_register_Asm_32 :
8785        NEONDataTypeAsmPseudoInst<"vld4${p}", ".32", "$list, $addr, $Rm",
8786                  (ins VecListFourQWordIndexed:$list,
8787                       addrmode6align64or128:$addr, rGPR:$Rm, pred:$p)>;
8788
8789
8790
8791// VLD4 multiple structure pseudo-instructions. These need special handling for
8792// the vector operands that the normal instructions don't yet model.
8793// FIXME: Remove these when the register classes and instructions are updated.
8794def VLD4dAsm_8 : NEONDataTypeAsmPseudoInst<"vld4${p}", ".8", "$list, $addr",
8795               (ins VecListFourD:$list, addrmode6align64or128or256:$addr,
8796                pred:$p)>;
8797def VLD4dAsm_16 : NEONDataTypeAsmPseudoInst<"vld4${p}", ".16", "$list, $addr",
8798               (ins VecListFourD:$list, addrmode6align64or128or256:$addr,
8799                pred:$p)>;
8800def VLD4dAsm_32 : NEONDataTypeAsmPseudoInst<"vld4${p}", ".32", "$list, $addr",
8801               (ins VecListFourD:$list, addrmode6align64or128or256:$addr,
8802                pred:$p)>;
8803def VLD4qAsm_8 : NEONDataTypeAsmPseudoInst<"vld4${p}", ".8", "$list, $addr",
8804               (ins VecListFourQ:$list, addrmode6align64or128or256:$addr,
8805                pred:$p)>;
8806def VLD4qAsm_16 : NEONDataTypeAsmPseudoInst<"vld4${p}", ".16", "$list, $addr",
8807               (ins VecListFourQ:$list, addrmode6align64or128or256:$addr,
8808                pred:$p)>;
8809def VLD4qAsm_32 : NEONDataTypeAsmPseudoInst<"vld4${p}", ".32", "$list, $addr",
8810               (ins VecListFourQ:$list, addrmode6align64or128or256:$addr,
8811                pred:$p)>;
8812
8813def VLD4dWB_fixed_Asm_8 :
8814        NEONDataTypeAsmPseudoInst<"vld4${p}", ".8", "$list, $addr!",
8815               (ins VecListFourD:$list, addrmode6align64or128or256:$addr,
8816                pred:$p)>;
8817def VLD4dWB_fixed_Asm_16 :
8818        NEONDataTypeAsmPseudoInst<"vld4${p}", ".16", "$list, $addr!",
8819               (ins VecListFourD:$list, addrmode6align64or128or256:$addr,
8820                pred:$p)>;
8821def VLD4dWB_fixed_Asm_32 :
8822        NEONDataTypeAsmPseudoInst<"vld4${p}", ".32", "$list, $addr!",
8823               (ins VecListFourD:$list, addrmode6align64or128or256:$addr,
8824                pred:$p)>;
8825def VLD4qWB_fixed_Asm_8 :
8826        NEONDataTypeAsmPseudoInst<"vld4${p}", ".8", "$list, $addr!",
8827               (ins VecListFourQ:$list, addrmode6align64or128or256:$addr,
8828                pred:$p)>;
8829def VLD4qWB_fixed_Asm_16 :
8830        NEONDataTypeAsmPseudoInst<"vld4${p}", ".16", "$list, $addr!",
8831               (ins VecListFourQ:$list, addrmode6align64or128or256:$addr,
8832                pred:$p)>;
8833def VLD4qWB_fixed_Asm_32 :
8834        NEONDataTypeAsmPseudoInst<"vld4${p}", ".32", "$list, $addr!",
8835               (ins VecListFourQ:$list, addrmode6align64or128or256:$addr,
8836                pred:$p)>;
8837def VLD4dWB_register_Asm_8 :
8838        NEONDataTypeAsmPseudoInst<"vld4${p}", ".8", "$list, $addr, $Rm",
8839                  (ins VecListFourD:$list, addrmode6align64or128or256:$addr,
8840                       rGPR:$Rm, pred:$p)>;
8841def VLD4dWB_register_Asm_16 :
8842        NEONDataTypeAsmPseudoInst<"vld4${p}", ".16", "$list, $addr, $Rm",
8843                  (ins VecListFourD:$list, addrmode6align64or128or256:$addr,
8844                       rGPR:$Rm, pred:$p)>;
8845def VLD4dWB_register_Asm_32 :
8846        NEONDataTypeAsmPseudoInst<"vld4${p}", ".32", "$list, $addr, $Rm",
8847                  (ins VecListFourD:$list, addrmode6align64or128or256:$addr,
8848                       rGPR:$Rm, pred:$p)>;
8849def VLD4qWB_register_Asm_8 :
8850        NEONDataTypeAsmPseudoInst<"vld4${p}", ".8", "$list, $addr, $Rm",
8851                  (ins VecListFourQ:$list, addrmode6align64or128or256:$addr,
8852                       rGPR:$Rm, pred:$p)>;
8853def VLD4qWB_register_Asm_16 :
8854        NEONDataTypeAsmPseudoInst<"vld4${p}", ".16", "$list, $addr, $Rm",
8855                  (ins VecListFourQ:$list, addrmode6align64or128or256:$addr,
8856                       rGPR:$Rm, pred:$p)>;
8857def VLD4qWB_register_Asm_32 :
8858        NEONDataTypeAsmPseudoInst<"vld4${p}", ".32", "$list, $addr, $Rm",
8859                  (ins VecListFourQ:$list, addrmode6align64or128or256:$addr,
8860                       rGPR:$Rm, pred:$p)>;
8861
8862// VST4 single-lane pseudo-instructions. These need special handling for
8863// the lane index that an InstAlias can't handle, so we use these instead.
8864def VST4LNdAsm_8 : NEONDataTypeAsmPseudoInst<"vst4${p}", ".8", "$list, $addr",
8865               (ins VecListFourDByteIndexed:$list, addrmode6align32:$addr,
8866                    pred:$p)>;
8867def VST4LNdAsm_16 : NEONDataTypeAsmPseudoInst<"vst4${p}", ".16", "$list, $addr",
8868               (ins VecListFourDHWordIndexed:$list, addrmode6align64:$addr,
8869                    pred:$p)>;
8870def VST4LNdAsm_32 : NEONDataTypeAsmPseudoInst<"vst4${p}", ".32", "$list, $addr",
8871               (ins VecListFourDWordIndexed:$list, addrmode6align64or128:$addr,
8872                    pred:$p)>;
8873def VST4LNqAsm_16 : NEONDataTypeAsmPseudoInst<"vst4${p}", ".16", "$list, $addr",
8874               (ins VecListFourQHWordIndexed:$list, addrmode6align64:$addr,
8875                    pred:$p)>;
8876def VST4LNqAsm_32 : NEONDataTypeAsmPseudoInst<"vst4${p}", ".32", "$list, $addr",
8877               (ins VecListFourQWordIndexed:$list, addrmode6align64or128:$addr,
8878                    pred:$p)>;
8879
8880def VST4LNdWB_fixed_Asm_8 :
8881        NEONDataTypeAsmPseudoInst<"vst4${p}", ".8", "$list, $addr!",
8882               (ins VecListFourDByteIndexed:$list, addrmode6align32:$addr,
8883                    pred:$p)>;
8884def VST4LNdWB_fixed_Asm_16 :
8885        NEONDataTypeAsmPseudoInst<"vst4${p}", ".16", "$list, $addr!",
8886               (ins VecListFourDHWordIndexed:$list, addrmode6align64:$addr,
8887                    pred:$p)>;
8888def VST4LNdWB_fixed_Asm_32 :
8889        NEONDataTypeAsmPseudoInst<"vst4${p}", ".32", "$list, $addr!",
8890               (ins VecListFourDWordIndexed:$list, addrmode6align64or128:$addr,
8891                    pred:$p)>;
8892def VST4LNqWB_fixed_Asm_16 :
8893        NEONDataTypeAsmPseudoInst<"vst4${p}", ".16", "$list, $addr!",
8894               (ins VecListFourQHWordIndexed:$list, addrmode6align64:$addr,
8895                    pred:$p)>;
8896def VST4LNqWB_fixed_Asm_32 :
8897        NEONDataTypeAsmPseudoInst<"vst4${p}", ".32", "$list, $addr!",
8898               (ins VecListFourQWordIndexed:$list, addrmode6align64or128:$addr,
8899                    pred:$p)>;
8900def VST4LNdWB_register_Asm_8 :
8901        NEONDataTypeAsmPseudoInst<"vst4${p}", ".8", "$list, $addr, $Rm",
8902                  (ins VecListFourDByteIndexed:$list, addrmode6align32:$addr,
8903                       rGPR:$Rm, pred:$p)>;
8904def VST4LNdWB_register_Asm_16 :
8905        NEONDataTypeAsmPseudoInst<"vst4${p}", ".16", "$list, $addr, $Rm",
8906                  (ins VecListFourDHWordIndexed:$list, addrmode6align64:$addr,
8907                       rGPR:$Rm, pred:$p)>;
8908def VST4LNdWB_register_Asm_32 :
8909        NEONDataTypeAsmPseudoInst<"vst4${p}", ".32", "$list, $addr, $Rm",
8910                  (ins VecListFourDWordIndexed:$list,
8911                       addrmode6align64or128:$addr, rGPR:$Rm, pred:$p)>;
8912def VST4LNqWB_register_Asm_16 :
8913        NEONDataTypeAsmPseudoInst<"vst4${p}", ".16", "$list, $addr, $Rm",
8914                  (ins VecListFourQHWordIndexed:$list, addrmode6align64:$addr,
8915                       rGPR:$Rm, pred:$p)>;
8916def VST4LNqWB_register_Asm_32 :
8917        NEONDataTypeAsmPseudoInst<"vst4${p}", ".32", "$list, $addr, $Rm",
8918                  (ins VecListFourQWordIndexed:$list,
8919                       addrmode6align64or128:$addr, rGPR:$Rm, pred:$p)>;
8920
8921
8922// VST4 multiple structure pseudo-instructions. These need special handling for
8923// the vector operands that the normal instructions don't yet model.
8924// FIXME: Remove these when the register classes and instructions are updated.
8925def VST4dAsm_8 : NEONDataTypeAsmPseudoInst<"vst4${p}", ".8", "$list, $addr",
8926               (ins VecListFourD:$list, addrmode6align64or128or256:$addr,
8927                    pred:$p)>;
8928def VST4dAsm_16 : NEONDataTypeAsmPseudoInst<"vst4${p}", ".16", "$list, $addr",
8929               (ins VecListFourD:$list, addrmode6align64or128or256:$addr,
8930                    pred:$p)>;
8931def VST4dAsm_32 : NEONDataTypeAsmPseudoInst<"vst4${p}", ".32", "$list, $addr",
8932               (ins VecListFourD:$list, addrmode6align64or128or256:$addr,
8933                    pred:$p)>;
8934def VST4qAsm_8 : NEONDataTypeAsmPseudoInst<"vst4${p}", ".8", "$list, $addr",
8935               (ins VecListFourQ:$list, addrmode6align64or128or256:$addr,
8936                    pred:$p)>;
8937def VST4qAsm_16 : NEONDataTypeAsmPseudoInst<"vst4${p}", ".16", "$list, $addr",
8938               (ins VecListFourQ:$list, addrmode6align64or128or256:$addr,
8939                    pred:$p)>;
8940def VST4qAsm_32 : NEONDataTypeAsmPseudoInst<"vst4${p}", ".32", "$list, $addr",
8941               (ins VecListFourQ:$list, addrmode6align64or128or256:$addr,
8942                    pred:$p)>;
8943
8944def VST4dWB_fixed_Asm_8 :
8945        NEONDataTypeAsmPseudoInst<"vst4${p}", ".8", "$list, $addr!",
8946               (ins VecListFourD:$list, addrmode6align64or128or256:$addr,
8947                    pred:$p)>;
8948def VST4dWB_fixed_Asm_16 :
8949        NEONDataTypeAsmPseudoInst<"vst4${p}", ".16", "$list, $addr!",
8950               (ins VecListFourD:$list, addrmode6align64or128or256:$addr,
8951                    pred:$p)>;
8952def VST4dWB_fixed_Asm_32 :
8953        NEONDataTypeAsmPseudoInst<"vst4${p}", ".32", "$list, $addr!",
8954               (ins VecListFourD:$list, addrmode6align64or128or256:$addr,
8955                    pred:$p)>;
8956def VST4qWB_fixed_Asm_8 :
8957        NEONDataTypeAsmPseudoInst<"vst4${p}", ".8", "$list, $addr!",
8958               (ins VecListFourQ:$list, addrmode6align64or128or256:$addr,
8959                    pred:$p)>;
8960def VST4qWB_fixed_Asm_16 :
8961        NEONDataTypeAsmPseudoInst<"vst4${p}", ".16", "$list, $addr!",
8962               (ins VecListFourQ:$list, addrmode6align64or128or256:$addr,
8963                    pred:$p)>;
8964def VST4qWB_fixed_Asm_32 :
8965        NEONDataTypeAsmPseudoInst<"vst4${p}", ".32", "$list, $addr!",
8966               (ins VecListFourQ:$list, addrmode6align64or128or256:$addr,
8967                    pred:$p)>;
8968def VST4dWB_register_Asm_8 :
8969        NEONDataTypeAsmPseudoInst<"vst4${p}", ".8", "$list, $addr, $Rm",
8970                  (ins VecListFourD:$list, addrmode6align64or128or256:$addr,
8971                       rGPR:$Rm, pred:$p)>;
8972def VST4dWB_register_Asm_16 :
8973        NEONDataTypeAsmPseudoInst<"vst4${p}", ".16", "$list, $addr, $Rm",
8974                  (ins VecListFourD:$list, addrmode6align64or128or256:$addr,
8975                       rGPR:$Rm, pred:$p)>;
8976def VST4dWB_register_Asm_32 :
8977        NEONDataTypeAsmPseudoInst<"vst4${p}", ".32", "$list, $addr, $Rm",
8978                  (ins VecListFourD:$list, addrmode6align64or128or256:$addr,
8979                       rGPR:$Rm, pred:$p)>;
8980def VST4qWB_register_Asm_8 :
8981        NEONDataTypeAsmPseudoInst<"vst4${p}", ".8", "$list, $addr, $Rm",
8982                  (ins VecListFourQ:$list, addrmode6align64or128or256:$addr,
8983                       rGPR:$Rm, pred:$p)>;
8984def VST4qWB_register_Asm_16 :
8985        NEONDataTypeAsmPseudoInst<"vst4${p}", ".16", "$list, $addr, $Rm",
8986                  (ins VecListFourQ:$list, addrmode6align64or128or256:$addr,
8987                       rGPR:$Rm, pred:$p)>;
8988def VST4qWB_register_Asm_32 :
8989        NEONDataTypeAsmPseudoInst<"vst4${p}", ".32", "$list, $addr, $Rm",
8990                  (ins VecListFourQ:$list, addrmode6align64or128or256:$addr,
8991                       rGPR:$Rm, pred:$p)>;
8992
8993// VMOV/VMVN takes an optional datatype suffix
8994defm : NEONDTAnyInstAlias<"vmov${p}", "$Vd, $Vm",
8995                         (VORRd DPR:$Vd, DPR:$Vm, DPR:$Vm, pred:$p)>;
8996defm : NEONDTAnyInstAlias<"vmov${p}", "$Vd, $Vm",
8997                         (VORRq QPR:$Vd, QPR:$Vm, QPR:$Vm, pred:$p)>;
8998
8999defm : NEONDTAnyInstAlias<"vmvn${p}", "$Vd, $Vm",
9000                         (VMVNd DPR:$Vd, DPR:$Vm, pred:$p)>;
9001defm : NEONDTAnyInstAlias<"vmvn${p}", "$Vd, $Vm",
9002                         (VMVNq QPR:$Vd, QPR:$Vm, pred:$p)>;
9003
9004// VCLT (register) is an assembler alias for VCGT w/ the operands reversed.
9005// D-register versions.
9006def : NEONInstAlias<"vcle${p}.s8 $Dd, $Dn, $Dm",
9007                    (VCGEsv8i8 DPR:$Dd, DPR:$Dm, DPR:$Dn, pred:$p)>;
9008def : NEONInstAlias<"vcle${p}.s16 $Dd, $Dn, $Dm",
9009                    (VCGEsv4i16 DPR:$Dd, DPR:$Dm, DPR:$Dn, pred:$p)>;
9010def : NEONInstAlias<"vcle${p}.s32 $Dd, $Dn, $Dm",
9011                    (VCGEsv2i32 DPR:$Dd, DPR:$Dm, DPR:$Dn, pred:$p)>;
9012def : NEONInstAlias<"vcle${p}.u8 $Dd, $Dn, $Dm",
9013                    (VCGEuv8i8 DPR:$Dd, DPR:$Dm, DPR:$Dn, pred:$p)>;
9014def : NEONInstAlias<"vcle${p}.u16 $Dd, $Dn, $Dm",
9015                    (VCGEuv4i16 DPR:$Dd, DPR:$Dm, DPR:$Dn, pred:$p)>;
9016def : NEONInstAlias<"vcle${p}.u32 $Dd, $Dn, $Dm",
9017                    (VCGEuv2i32 DPR:$Dd, DPR:$Dm, DPR:$Dn, pred:$p)>;
9018def : NEONInstAlias<"vcle${p}.f32 $Dd, $Dn, $Dm",
9019                    (VCGEfd DPR:$Dd, DPR:$Dm, DPR:$Dn, pred:$p)>;
9020let Predicates = [HasNEON, HasFullFP16] in
9021def : NEONInstAlias<"vcle${p}.f16 $Dd, $Dn, $Dm",
9022                    (VCGEhd DPR:$Dd, DPR:$Dm, DPR:$Dn, pred:$p)>;
9023// Q-register versions.
9024def : NEONInstAlias<"vcle${p}.s8 $Qd, $Qn, $Qm",
9025                    (VCGEsv16i8 QPR:$Qd, QPR:$Qm, QPR:$Qn, pred:$p)>;
9026def : NEONInstAlias<"vcle${p}.s16 $Qd, $Qn, $Qm",
9027                    (VCGEsv8i16 QPR:$Qd, QPR:$Qm, QPR:$Qn, pred:$p)>;
9028def : NEONInstAlias<"vcle${p}.s32 $Qd, $Qn, $Qm",
9029                    (VCGEsv4i32 QPR:$Qd, QPR:$Qm, QPR:$Qn, pred:$p)>;
9030def : NEONInstAlias<"vcle${p}.u8 $Qd, $Qn, $Qm",
9031                    (VCGEuv16i8 QPR:$Qd, QPR:$Qm, QPR:$Qn, pred:$p)>;
9032def : NEONInstAlias<"vcle${p}.u16 $Qd, $Qn, $Qm",
9033                    (VCGEuv8i16 QPR:$Qd, QPR:$Qm, QPR:$Qn, pred:$p)>;
9034def : NEONInstAlias<"vcle${p}.u32 $Qd, $Qn, $Qm",
9035                    (VCGEuv4i32 QPR:$Qd, QPR:$Qm, QPR:$Qn, pred:$p)>;
9036def : NEONInstAlias<"vcle${p}.f32 $Qd, $Qn, $Qm",
9037                    (VCGEfq QPR:$Qd, QPR:$Qm, QPR:$Qn, pred:$p)>;
9038let Predicates = [HasNEON, HasFullFP16] in
9039def : NEONInstAlias<"vcle${p}.f16 $Qd, $Qn, $Qm",
9040                    (VCGEhq QPR:$Qd, QPR:$Qm, QPR:$Qn, pred:$p)>;
9041
9042// VCLT (register) is an assembler alias for VCGT w/ the operands reversed.
9043// D-register versions.
9044def : NEONInstAlias<"vclt${p}.s8 $Dd, $Dn, $Dm",
9045                    (VCGTsv8i8 DPR:$Dd, DPR:$Dm, DPR:$Dn, pred:$p)>;
9046def : NEONInstAlias<"vclt${p}.s16 $Dd, $Dn, $Dm",
9047                    (VCGTsv4i16 DPR:$Dd, DPR:$Dm, DPR:$Dn, pred:$p)>;
9048def : NEONInstAlias<"vclt${p}.s32 $Dd, $Dn, $Dm",
9049                    (VCGTsv2i32 DPR:$Dd, DPR:$Dm, DPR:$Dn, pred:$p)>;
9050def : NEONInstAlias<"vclt${p}.u8 $Dd, $Dn, $Dm",
9051                    (VCGTuv8i8 DPR:$Dd, DPR:$Dm, DPR:$Dn, pred:$p)>;
9052def : NEONInstAlias<"vclt${p}.u16 $Dd, $Dn, $Dm",
9053                    (VCGTuv4i16 DPR:$Dd, DPR:$Dm, DPR:$Dn, pred:$p)>;
9054def : NEONInstAlias<"vclt${p}.u32 $Dd, $Dn, $Dm",
9055                    (VCGTuv2i32 DPR:$Dd, DPR:$Dm, DPR:$Dn, pred:$p)>;
9056def : NEONInstAlias<"vclt${p}.f32 $Dd, $Dn, $Dm",
9057                    (VCGTfd DPR:$Dd, DPR:$Dm, DPR:$Dn, pred:$p)>;
9058let Predicates = [HasNEON, HasFullFP16] in
9059def : NEONInstAlias<"vclt${p}.f16 $Dd, $Dn, $Dm",
9060                    (VCGThd DPR:$Dd, DPR:$Dm, DPR:$Dn, pred:$p)>;
9061// Q-register versions.
9062def : NEONInstAlias<"vclt${p}.s8 $Qd, $Qn, $Qm",
9063                    (VCGTsv16i8 QPR:$Qd, QPR:$Qm, QPR:$Qn, pred:$p)>;
9064def : NEONInstAlias<"vclt${p}.s16 $Qd, $Qn, $Qm",
9065                    (VCGTsv8i16 QPR:$Qd, QPR:$Qm, QPR:$Qn, pred:$p)>;
9066def : NEONInstAlias<"vclt${p}.s32 $Qd, $Qn, $Qm",
9067                    (VCGTsv4i32 QPR:$Qd, QPR:$Qm, QPR:$Qn, pred:$p)>;
9068def : NEONInstAlias<"vclt${p}.u8 $Qd, $Qn, $Qm",
9069                    (VCGTuv16i8 QPR:$Qd, QPR:$Qm, QPR:$Qn, pred:$p)>;
9070def : NEONInstAlias<"vclt${p}.u16 $Qd, $Qn, $Qm",
9071                    (VCGTuv8i16 QPR:$Qd, QPR:$Qm, QPR:$Qn, pred:$p)>;
9072def : NEONInstAlias<"vclt${p}.u32 $Qd, $Qn, $Qm",
9073                    (VCGTuv4i32 QPR:$Qd, QPR:$Qm, QPR:$Qn, pred:$p)>;
9074def : NEONInstAlias<"vclt${p}.f32 $Qd, $Qn, $Qm",
9075                    (VCGTfq QPR:$Qd, QPR:$Qm, QPR:$Qn, pred:$p)>;
9076let Predicates = [HasNEON, HasFullFP16] in
9077def : NEONInstAlias<"vclt${p}.f16 $Qd, $Qn, $Qm",
9078                    (VCGThq QPR:$Qd, QPR:$Qm, QPR:$Qn, pred:$p)>;
9079
9080// VSWP allows, but does not require, a type suffix.
9081defm : NEONDTAnyInstAlias<"vswp${p}", "$Vd, $Vm",
9082                         (VSWPd DPR:$Vd, DPR:$Vm, pred:$p)>;
9083defm : NEONDTAnyInstAlias<"vswp${p}", "$Vd, $Vm",
9084                         (VSWPq QPR:$Vd, QPR:$Vm, pred:$p)>;
9085
9086// VBIF, VBIT, and VBSL allow, but do not require, a type suffix.
9087defm : NEONDTAnyInstAlias<"vbif${p}", "$Vd, $Vn, $Vm",
9088                         (VBIFd DPR:$Vd, DPR:$Vn, DPR:$Vm, pred:$p)>;
9089defm : NEONDTAnyInstAlias<"vbit${p}", "$Vd, $Vn, $Vm",
9090                         (VBITd DPR:$Vd, DPR:$Vn, DPR:$Vm, pred:$p)>;
9091defm : NEONDTAnyInstAlias<"vbsl${p}", "$Vd, $Vn, $Vm",
9092                         (VBSLd DPR:$Vd, DPR:$Vn, DPR:$Vm, pred:$p)>;
9093defm : NEONDTAnyInstAlias<"vbif${p}", "$Vd, $Vn, $Vm",
9094                         (VBIFq QPR:$Vd, QPR:$Vn, QPR:$Vm, pred:$p)>;
9095defm : NEONDTAnyInstAlias<"vbit${p}", "$Vd, $Vn, $Vm",
9096                         (VBITq QPR:$Vd, QPR:$Vn, QPR:$Vm, pred:$p)>;
9097defm : NEONDTAnyInstAlias<"vbsl${p}", "$Vd, $Vn, $Vm",
9098                         (VBSLq QPR:$Vd, QPR:$Vn, QPR:$Vm, pred:$p)>;
9099
9100// "vmov Rd, #-imm" can be handled via "vmvn".
9101def : NEONInstAlias<"vmov${p}.i32 $Vd, $imm",
9102                    (VMVNv2i32 DPR:$Vd, nImmVMOVI32Neg:$imm, pred:$p)>;
9103def : NEONInstAlias<"vmov${p}.i32 $Vd, $imm",
9104                    (VMVNv4i32 QPR:$Vd, nImmVMOVI32Neg:$imm, pred:$p)>;
9105def : NEONInstAlias<"vmvn${p}.i32 $Vd, $imm",
9106                    (VMOVv2i32 DPR:$Vd, nImmVMOVI32Neg:$imm, pred:$p)>;
9107def : NEONInstAlias<"vmvn${p}.i32 $Vd, $imm",
9108                    (VMOVv4i32 QPR:$Vd, nImmVMOVI32Neg:$imm, pred:$p)>;
9109
9110// 'gas' compatibility aliases for quad-word instructions. Strictly speaking,
9111// these should restrict to just the Q register variants, but the register
9112// classes are enough to match correctly regardless, so we keep it simple
9113// and just use MnemonicAlias.
9114def : NEONMnemonicAlias<"vbicq", "vbic">;
9115def : NEONMnemonicAlias<"vandq", "vand">;
9116def : NEONMnemonicAlias<"veorq", "veor">;
9117def : NEONMnemonicAlias<"vorrq", "vorr">;
9118
9119def : NEONMnemonicAlias<"vmovq", "vmov">;
9120def : NEONMnemonicAlias<"vmvnq", "vmvn">;
9121// Explicit versions for floating point so that the FPImm variants get
9122// handled early. The parser gets confused otherwise.
9123def : NEONMnemonicAlias<"vmovq.f32", "vmov.f32">;
9124def : NEONMnemonicAlias<"vmovq.f64", "vmov.f64">;
9125
9126def : NEONMnemonicAlias<"vaddq", "vadd">;
9127def : NEONMnemonicAlias<"vsubq", "vsub">;
9128
9129def : NEONMnemonicAlias<"vminq", "vmin">;
9130def : NEONMnemonicAlias<"vmaxq", "vmax">;
9131
9132def : NEONMnemonicAlias<"vmulq", "vmul">;
9133
9134def : NEONMnemonicAlias<"vabsq", "vabs">;
9135
9136def : NEONMnemonicAlias<"vshlq", "vshl">;
9137def : NEONMnemonicAlias<"vshrq", "vshr">;
9138
9139def : NEONMnemonicAlias<"vcvtq", "vcvt">;
9140
9141def : NEONMnemonicAlias<"vcleq", "vcle">;
9142def : NEONMnemonicAlias<"vceqq", "vceq">;
9143
9144def : NEONMnemonicAlias<"vzipq", "vzip">;
9145def : NEONMnemonicAlias<"vswpq", "vswp">;
9146
9147def : NEONMnemonicAlias<"vrecpeq.f32", "vrecpe.f32">;
9148def : NEONMnemonicAlias<"vrecpeq.u32", "vrecpe.u32">;
9149
9150
9151// Alias for loading floating point immediates that aren't representable
9152// using the vmov.f32 encoding but the bitpattern is representable using
9153// the .i32 encoding.
9154def : NEONInstAlias<"vmov${p}.f32 $Vd, $imm",
9155                     (VMOVv4i32 QPR:$Vd, nImmVMOVI32:$imm, pred:$p)>;
9156def : NEONInstAlias<"vmov${p}.f32 $Vd, $imm",
9157                     (VMOVv2i32 DPR:$Vd, nImmVMOVI32:$imm, pred:$p)>;
9158
9159// ARMv8.6a BFloat16 instructions.
9160let Predicates = [HasBF16, HasNEON] in {
9161class BF16VDOT<bits<5> op27_23, bits<2> op21_20, bit op6,
9162               dag oops, dag iops, list<dag> pattern>
9163   : N3Vnp<op27_23, op21_20, 0b1101, op6, 0, oops, iops,
9164           N3RegFrm, IIC_VDOTPROD, "", "", pattern>
9165{
9166    let DecoderNamespace = "VFPV8";
9167}
9168
9169class BF16VDOTS<bit Q, RegisterClass RegTy, string opc, ValueType AccumTy, ValueType InputTy>
9170   : BF16VDOT<0b11000, 0b00,  Q, (outs RegTy:$dst),
9171              (ins RegTy:$Vd, RegTy:$Vn, RegTy:$Vm),
9172            [(set (AccumTy RegTy:$dst),
9173                  (int_arm_neon_bfdot (AccumTy RegTy:$Vd),
9174                                      (InputTy RegTy:$Vn),
9175                                      (InputTy RegTy:$Vm)))]> {
9176  let Constraints = "$dst = $Vd";
9177  let AsmString = !strconcat(opc, ".bf16", "\t$Vd, $Vn, $Vm");
9178    let DecoderNamespace = "VFPV8";
9179}
9180
9181multiclass BF16VDOTI<bit Q, RegisterClass RegTy, string opc, ValueType AccumTy,
9182                     ValueType InputTy, dag RHS> {
9183
9184  def "" : BF16VDOT<0b11100, 0b00, Q, (outs RegTy:$dst),
9185                    (ins RegTy:$Vd, RegTy:$Vn,
9186                    DPR_VFP2:$Vm, VectorIndex32:$lane), []> {
9187    bit lane;
9188    let Inst{5} = lane;
9189    let Constraints = "$dst = $Vd";
9190    let AsmString = !strconcat(opc, ".bf16", "\t$Vd, $Vn, $Vm$lane");
9191    let DecoderNamespace = "VFPV8";
9192  }
9193
9194  def : Pat<
9195    (AccumTy (int_arm_neon_bfdot (AccumTy RegTy:$Vd),
9196                                 (InputTy RegTy:$Vn),
9197                                 (InputTy (bitconvert (AccumTy
9198                                          (ARMvduplane (AccumTy RegTy:$Vm),
9199                                                        VectorIndex32:$lane)))))),
9200    (!cast<Instruction>(NAME) RegTy:$Vd, RegTy:$Vn, RHS, VectorIndex32:$lane)>;
9201}
9202
9203def BF16VDOTS_VDOTD : BF16VDOTS<0, DPR, "vdot", v2f32, v4bf16>;
9204def BF16VDOTS_VDOTQ : BF16VDOTS<1, QPR, "vdot", v4f32, v8bf16>;
9205
9206defm BF16VDOTI_VDOTD : BF16VDOTI<0, DPR, "vdot", v2f32, v4bf16, (v2f32 DPR_VFP2:$Vm)>;
9207defm BF16VDOTI_VDOTQ : BF16VDOTI<1, QPR, "vdot", v4f32, v8bf16, (EXTRACT_SUBREG QPR:$Vm, dsub_0)>;
9208
9209class BF16MM<bit Q, RegisterClass RegTy,
9210             string opc>
9211   : N3Vnp<0b11000, 0b00, 0b1100, Q, 0,
9212           (outs RegTy:$dst), (ins RegTy:$Vd, RegTy:$Vn, RegTy:$Vm),
9213           N3RegFrm, IIC_VDOTPROD, "", "",
9214                [(set (v4f32 QPR:$dst), (int_arm_neon_bfmmla (v4f32 QPR:$Vd),
9215                                                (v8bf16 QPR:$Vn),
9216                                                (v8bf16 QPR:$Vm)))]> {
9217   let Constraints = "$dst = $Vd";
9218   let AsmString = !strconcat(opc, ".bf16", "\t$Vd, $Vn, $Vm");
9219   let DecoderNamespace = "VFPV8";
9220}
9221
9222def VMMLA : BF16MM<1, QPR, "vmmla">;
9223
9224class VBF16MALQ<bit T, string suffix, SDPatternOperator OpNode>
9225  : N3VCP8<0b00, 0b11, T, 1,
9226           (outs QPR:$dst), (ins QPR:$Vd, QPR:$Vn, QPR:$Vm),
9227           NoItinerary, "vfma" # suffix, "bf16", "$Vd, $Vn, $Vm", "",
9228                [(set (v4f32 QPR:$dst),
9229                      (OpNode (v4f32 QPR:$Vd),
9230                              (v8bf16 QPR:$Vn),
9231                              (v8bf16 QPR:$Vm)))]> {
9232  let Constraints = "$dst = $Vd";
9233  let DecoderNamespace = "VFPV8";
9234}
9235
9236def VBF16MALTQ: VBF16MALQ<1, "t", int_arm_neon_bfmlalt>;
9237def VBF16MALBQ: VBF16MALQ<0, "b", int_arm_neon_bfmlalb>;
9238
9239multiclass VBF16MALQI<bit T, string suffix, SDPatternOperator OpNode> {
9240  def "" : N3VLaneCP8<0, 0b11, T, 1, (outs QPR:$dst),
9241              (ins QPR:$Vd, QPR:$Vn, DPR_8:$Vm, VectorIndex16:$idx),
9242               IIC_VMACD, "vfma" # suffix, "bf16", "$Vd, $Vn, $Vm$idx", "", []> {
9243  bits<2> idx;
9244  let Inst{5} = idx{1};
9245  let Inst{3} = idx{0};
9246  let Constraints = "$dst = $Vd";
9247  let DecoderNamespace = "VFPV8";
9248  }
9249
9250  def : Pat<
9251    (v4f32 (OpNode (v4f32 QPR:$Vd),
9252                   (v8bf16 QPR:$Vn),
9253                   (v8bf16 (ARMvduplane (v8bf16 QPR:$Vm),
9254                            VectorIndex16:$lane)))),
9255    (!cast<Instruction>(NAME) QPR:$Vd,
9256                              QPR:$Vn,
9257                              (EXTRACT_SUBREG QPR:$Vm,
9258                                (DSubReg_i16_reg VectorIndex16:$lane)),
9259                              (SubReg_i16_lane VectorIndex16:$lane))>;
9260}
9261
9262defm VBF16MALTQI: VBF16MALQI<1, "t", int_arm_neon_bfmlalt>;
9263defm VBF16MALBQI: VBF16MALQI<0, "b", int_arm_neon_bfmlalb>;
9264
9265def BF16_VCVT :  N2V<0b11, 0b11, 0b01, 0b10, 0b01100, 1, 0,
9266                    (outs DPR:$Vd), (ins QPR:$Vm),
9267                    NoItinerary, "vcvt", "bf16.f32", "$Vd, $Vm", "", []>;
9268}
9269// End of BFloat16 instructions
9270