1 //===-- ARMInstrMVE.td - MVE support for ARM ---------------*- tablegen -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // This file describes the ARM MVE instruction set.
11 //===----------------------------------------------------------------------===//
13 class ExpandImmAsmOp<string shift> : AsmOperandClass {
14 let Name = !strconcat("ExpandImm", shift);
15 let PredicateMethod = !strconcat("isExpImm<", shift, ">");
16 let RenderMethod = "addImmOperands";
18 class InvertedExpandImmAsmOp<string shift, string size> : AsmOperandClass {
19 let Name = !strconcat("InvertedExpandImm", shift, "_", size);
20 let PredicateMethod = !strconcat("isInvertedExpImm<", shift, ",", size, ">");
21 let RenderMethod = "addImmOperands";
24 class ExpandImm<string shift> : Operand<i32> {
25 let ParserMatchClass = ExpandImmAsmOp<shift>;
26 let EncoderMethod = !strconcat("getExpandedImmOpValue<",shift,",false>");
27 let DecoderMethod = !strconcat("DecodeExpandedImmOperand<",shift,">");
28 let PrintMethod = "printExpandedImmOperand";
30 class InvertedExpandImm<string shift, string size> : Operand<i32> {
31 let ParserMatchClass = InvertedExpandImmAsmOp<shift, size>;
32 let EncoderMethod = !strconcat("getExpandedImmOpValue<",shift,",true>");
33 let PrintMethod = "printExpandedImmOperand";
34 // No decoder method needed, because this operand type is only used
35 // by aliases (VAND and VORN)
38 def expzero00 : ExpandImm<"0">;
39 def expzero08 : ExpandImm<"8">;
40 def expzero16 : ExpandImm<"16">;
41 def expzero24 : ExpandImm<"24">;
43 def expzero00inv16 : InvertedExpandImm<"0", "16">;
44 def expzero08inv16 : InvertedExpandImm<"8", "16">;
46 def expzero00inv32 : InvertedExpandImm<"0", "32">;
47 def expzero08inv32 : InvertedExpandImm<"8", "32">;
48 def expzero16inv32 : InvertedExpandImm<"16", "32">;
49 def expzero24inv32 : InvertedExpandImm<"24", "32">;
52 def vpt_mask : Operand<i32> {
53 let PrintMethod = "printVPTMask";
54 let ParserMatchClass = it_mask_asmoperand;
55 let EncoderMethod = "getVPTMaskOpValue";
56 let DecoderMethod = "DecodeVPTMaskOperand";
59 // VPT/VCMP restricted predicate for sign invariant types
60 def pred_restricted_i_asmoperand : AsmOperandClass {
61 let Name = "CondCodeRestrictedI";
62 let RenderMethod = "addITCondCodeOperands";
63 let PredicateMethod = "isITCondCodeRestrictedI";
64 let ParserMethod = "parseITCondCode";
65 let DiagnosticString = "condition code for sign-independent integer "#
66 "comparison must be EQ or NE";
69 // VPT/VCMP restricted predicate for signed types
70 def pred_restricted_s_asmoperand : AsmOperandClass {
71 let Name = "CondCodeRestrictedS";
72 let RenderMethod = "addITCondCodeOperands";
73 let PredicateMethod = "isITCondCodeRestrictedS";
74 let ParserMethod = "parseITCondCode";
75 let DiagnosticString = "condition code for signed integer "#
76 "comparison must be EQ, NE, LT, GT, LE or GE";
79 // VPT/VCMP restricted predicate for unsigned types
80 def pred_restricted_u_asmoperand : AsmOperandClass {
81 let Name = "CondCodeRestrictedU";
82 let RenderMethod = "addITCondCodeOperands";
83 let PredicateMethod = "isITCondCodeRestrictedU";
84 let ParserMethod = "parseITCondCode";
85 let DiagnosticString = "condition code for unsigned integer "#
86 "comparison must be EQ, NE, HS or HI";
89 // VPT/VCMP restricted predicate for floating point
90 def pred_restricted_fp_asmoperand : AsmOperandClass {
91 let Name = "CondCodeRestrictedFP";
92 let RenderMethod = "addITCondCodeOperands";
93 let PredicateMethod = "isITCondCodeRestrictedFP";
94 let ParserMethod = "parseITCondCode";
95 let DiagnosticString = "condition code for floating-point "#
96 "comparison must be EQ, NE, LT, GT, LE or GE";
99 class VCMPPredicateOperand : Operand<i32>;
101 def pred_basic_i : VCMPPredicateOperand {
102 let PrintMethod = "printMandatoryRestrictedPredicateOperand";
103 let ParserMatchClass = pred_restricted_i_asmoperand;
104 let DecoderMethod = "DecodeRestrictedIPredicateOperand";
105 let EncoderMethod = "getRestrictedCondCodeOpValue";
108 def pred_basic_u : VCMPPredicateOperand {
109 let PrintMethod = "printMandatoryRestrictedPredicateOperand";
110 let ParserMatchClass = pred_restricted_u_asmoperand;
111 let DecoderMethod = "DecodeRestrictedUPredicateOperand";
112 let EncoderMethod = "getRestrictedCondCodeOpValue";
115 def pred_basic_s : VCMPPredicateOperand {
116 let PrintMethod = "printMandatoryRestrictedPredicateOperand";
117 let ParserMatchClass = pred_restricted_s_asmoperand;
118 let DecoderMethod = "DecodeRestrictedSPredicateOperand";
119 let EncoderMethod = "getRestrictedCondCodeOpValue";
122 def pred_basic_fp : VCMPPredicateOperand {
123 let PrintMethod = "printMandatoryRestrictedPredicateOperand";
124 let ParserMatchClass = pred_restricted_fp_asmoperand;
125 let DecoderMethod = "DecodeRestrictedFPPredicateOperand";
126 let EncoderMethod = "getRestrictedCondCodeOpValue";
129 // Register list operands for interleaving load/stores
130 def VecList2QAsmOperand : AsmOperandClass {
131 let Name = "VecListTwoMQ";
132 let ParserMethod = "parseVectorList";
133 let RenderMethod = "addMVEVecListOperands";
134 let DiagnosticString = "operand must be a list of two consecutive "#
135 "q-registers in range [q0,q7]";
138 def VecList2Q : RegisterOperand<QQPR, "printMVEVectorListTwoQ"> {
139 let ParserMatchClass = VecList2QAsmOperand;
140 let PrintMethod = "printMVEVectorList<2>";
143 def VecList4QAsmOperand : AsmOperandClass {
144 let Name = "VecListFourMQ";
145 let ParserMethod = "parseVectorList";
146 let RenderMethod = "addMVEVecListOperands";
147 let DiagnosticString = "operand must be a list of four consecutive "#
148 "q-registers in range [q0,q7]";
151 def VecList4Q : RegisterOperand<QQQQPR, "printMVEVectorListFourQ"> {
152 let ParserMatchClass = VecList4QAsmOperand;
153 let PrintMethod = "printMVEVectorList<4>";
156 // taddrmode_imm7 := reg[r0-r7] +/- (imm7 << shift)
157 class TMemImm7ShiftOffsetAsmOperand<int shift> : AsmOperandClass {
158 let Name = "TMemImm7Shift"#shift#"Offset";
159 let PredicateMethod = "isMemImm7ShiftedOffset<"#shift#",ARM::tGPRRegClassID>";
160 let RenderMethod = "addMemImmOffsetOperands";
163 class taddrmode_imm7<int shift> : MemOperand,
164 ComplexPattern<i32, 2, "SelectTAddrModeImm7<"#shift#">", []> {
165 let ParserMatchClass = TMemImm7ShiftOffsetAsmOperand<shift>;
166 // They are printed the same way as the T2 imm8 version
167 let PrintMethod = "printT2AddrModeImm8Operand<false>";
168 // This can also be the same as the T2 version.
169 let EncoderMethod = "getT2AddrModeImmOpValue<7,"#shift#">";
170 let DecoderMethod = "DecodeTAddrModeImm7<"#shift#">";
171 let MIOperandInfo = (ops tGPR:$base, i32imm:$offsimm);
174 // t2addrmode_imm7 := reg +/- (imm7)
175 class MemImm7ShiftOffsetAsmOperand<int shift> : AsmOperandClass {
176 let Name = "MemImm7Shift"#shift#"Offset";
177 let PredicateMethod = "isMemImm7ShiftedOffset<" # shift #
178 ",ARM::GPRnopcRegClassID>";
179 let RenderMethod = "addMemImmOffsetOperands";
182 def MemImm7Shift0OffsetAsmOperand : MemImm7ShiftOffsetAsmOperand<0>;
183 def MemImm7Shift1OffsetAsmOperand : MemImm7ShiftOffsetAsmOperand<1>;
184 def MemImm7Shift2OffsetAsmOperand : MemImm7ShiftOffsetAsmOperand<2>;
185 class T2AddrMode_Imm7<int shift> : MemOperand,
186 ComplexPattern<i32, 2, "SelectT2AddrModeImm7<"#shift#">", []> {
187 let EncoderMethod = "getT2AddrModeImmOpValue<7,"#shift#">";
188 let DecoderMethod = "DecodeT2AddrModeImm7<"#shift#", 0>";
189 let ParserMatchClass =
190 !cast<AsmOperandClass>("MemImm7Shift"#shift#"OffsetAsmOperand");
191 let MIOperandInfo = (ops GPRnopc:$base, i32imm:$offsimm);
194 class t2addrmode_imm7<int shift> : T2AddrMode_Imm7<shift> {
195 // They are printed the same way as the imm8 version
196 let PrintMethod = "printT2AddrModeImm8Operand<false>";
199 class MemImm7ShiftOffsetWBAsmOperand<int shift> : AsmOperandClass {
200 let Name = "MemImm7Shift"#shift#"OffsetWB";
201 let PredicateMethod = "isMemImm7ShiftedOffset<" # shift #
202 ",ARM::rGPRRegClassID>";
203 let RenderMethod = "addMemImmOffsetOperands";
206 def MemImm7Shift0OffsetWBAsmOperand : MemImm7ShiftOffsetWBAsmOperand<0>;
207 def MemImm7Shift1OffsetWBAsmOperand : MemImm7ShiftOffsetWBAsmOperand<1>;
208 def MemImm7Shift2OffsetWBAsmOperand : MemImm7ShiftOffsetWBAsmOperand<2>;
210 class t2addrmode_imm7_pre<int shift> : T2AddrMode_Imm7<shift> {
211 // They are printed the same way as the imm8 version
212 let PrintMethod = "printT2AddrModeImm8Operand<true>";
213 let ParserMatchClass =
214 !cast<AsmOperandClass>("MemImm7Shift"#shift#"OffsetWBAsmOperand");
215 let DecoderMethod = "DecodeT2AddrModeImm7<"#shift#", 1>";
216 let MIOperandInfo = (ops rGPR:$base, i32imm:$offsim);
219 class t2am_imm7shiftOffsetAsmOperand<int shift>
220 : AsmOperandClass { let Name = "Imm7Shift"#shift; }
221 def t2am_imm7shift0OffsetAsmOperand : t2am_imm7shiftOffsetAsmOperand<0>;
222 def t2am_imm7shift1OffsetAsmOperand : t2am_imm7shiftOffsetAsmOperand<1>;
223 def t2am_imm7shift2OffsetAsmOperand : t2am_imm7shiftOffsetAsmOperand<2>;
225 class t2am_imm7_offset<int shift> : MemOperand,
226 ComplexPattern<i32, 1, "SelectT2AddrModeImm7Offset<"#shift#">",
227 [], [SDNPWantRoot]> {
228 // They are printed the same way as the imm8 version
229 let PrintMethod = "printT2AddrModeImm8OffsetOperand";
230 let ParserMatchClass =
231 !cast<AsmOperandClass>("t2am_imm7shift"#shift#"OffsetAsmOperand");
232 let EncoderMethod = "getT2ScaledImmOpValue<7,"#shift#">";
233 let DecoderMethod = "DecodeT2Imm7<"#shift#">";
236 // Operands for gather/scatter loads of the form [Rbase, Qoffsets]
237 class MemRegRQOffsetAsmOperand<int shift> : AsmOperandClass {
238 let Name = "MemRegRQS"#shift#"Offset";
239 let PredicateMethod = "isMemRegRQOffset<"#shift#">";
240 let RenderMethod = "addMemRegRQOffsetOperands";
243 def MemRegRQS0OffsetAsmOperand : MemRegRQOffsetAsmOperand<0>;
244 def MemRegRQS1OffsetAsmOperand : MemRegRQOffsetAsmOperand<1>;
245 def MemRegRQS2OffsetAsmOperand : MemRegRQOffsetAsmOperand<2>;
246 def MemRegRQS3OffsetAsmOperand : MemRegRQOffsetAsmOperand<3>;
248 // mve_addr_rq_shift := reg + vreg{ << UXTW #shift}
249 class mve_addr_rq_shift<int shift> : MemOperand {
250 let EncoderMethod = "getMveAddrModeRQOpValue";
251 let PrintMethod = "printMveAddrModeRQOperand<"#shift#">";
252 let ParserMatchClass =
253 !cast<AsmOperandClass>("MemRegRQS"#shift#"OffsetAsmOperand");
254 let DecoderMethod = "DecodeMveAddrModeRQ";
255 let MIOperandInfo = (ops GPRnopc:$base, MQPR:$offsreg);
258 class MemRegQOffsetAsmOperand<int shift> : AsmOperandClass {
259 let Name = "MemRegQS"#shift#"Offset";
260 let PredicateMethod = "isMemRegQOffset<"#shift#">";
261 let RenderMethod = "addMemImmOffsetOperands";
264 def MemRegQS2OffsetAsmOperand : MemRegQOffsetAsmOperand<2>;
265 def MemRegQS3OffsetAsmOperand : MemRegQOffsetAsmOperand<3>;
267 // mve_addr_q_shift := vreg {+ #imm7s2/4}
268 class mve_addr_q_shift<int shift> : MemOperand {
269 let EncoderMethod = "getMveAddrModeQOpValue<"#shift#">";
270 // Can be printed same way as other reg + imm operands
271 let PrintMethod = "printT2AddrModeImm8Operand<false>";
272 let ParserMatchClass =
273 !cast<AsmOperandClass>("MemRegQS"#shift#"OffsetAsmOperand");
274 let DecoderMethod = "DecodeMveAddrModeQ<"#shift#">";
275 let MIOperandInfo = (ops MQPR:$base, i32imm:$imm);
278 // --------- Start of base classes for the instructions themselves
280 class MVE_MI<dag oops, dag iops, InstrItinClass itin, string asm,
281 string ops, string cstr, list<dag> pattern>
282 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, !strconcat(asm, "\t", ops), cstr,
284 Requires<[HasMVEInt]> {
286 let DecoderNamespace = "MVE";
289 // MVE_p is used for most predicated instructions, to add the cluster
290 // of input operands that provides the VPT suffix (none, T or E) and
291 // the input predicate register.
292 class MVE_p<dag oops, dag iops, InstrItinClass itin, string iname,
293 string suffix, string ops, vpred_ops vpred, string cstr,
294 list<dag> pattern=[]>
295 : MVE_MI<oops, !con(iops, (ins vpred:$vp)), itin,
296 // If the instruction has a suffix, like vadd.f32, then the
297 // VPT predication suffix goes before the dot, so the full
298 // name has to be "vadd${vp}.f32".
299 !strconcat(iname, "${vp}",
300 !if(!eq(suffix, ""), "", !strconcat(".", suffix))),
301 ops, !strconcat(cstr, vpred.vpred_constraint), pattern> {
302 let Inst{31-29} = 0b111;
303 let Inst{27-26} = 0b11;
306 class MVE_f<dag oops, dag iops, InstrItinClass itin, string iname,
307 string suffix, string ops, vpred_ops vpred, string cstr,
308 list<dag> pattern=[]>
309 : MVE_p<oops, iops, itin, iname, suffix, ops, vpred, cstr, pattern> {
310 let Predicates = [HasMVEFloat];
313 class MVE_MI_with_pred<dag oops, dag iops, InstrItinClass itin, string asm,
314 string ops, string cstr, list<dag> pattern>
315 : Thumb2I<oops, iops, AddrModeNone, 4, itin, asm, !strconcat("\t", ops), cstr,
317 Requires<[HasV8_1MMainline, HasMVEInt]> {
319 let DecoderNamespace = "MVE";
322 class MVE_VMOV_lane_base<dag oops, dag iops, InstrItinClass itin, string asm,
323 string suffix, string ops, string cstr,
325 : Thumb2I<oops, iops, AddrModeNone, 4, itin, asm,
326 !if(!eq(suffix, ""), "", "." # suffix) # "\t" # ops,
328 Requires<[HasV8_1MMainline, HasMVEInt]> {
330 let DecoderNamespace = "MVE";
333 class MVE_ScalarShift<string iname, dag oops, dag iops, string asm, string cstr,
334 list<dag> pattern=[]>
335 : MVE_MI_with_pred<oops, iops, NoItinerary, iname, asm, cstr, pattern> {
336 let Inst{31-20} = 0b111010100101;
341 class MVE_ScalarShiftSingleReg<string iname, dag iops, string asm, string cstr,
342 list<dag> pattern=[]>
343 : MVE_ScalarShift<iname, (outs rGPR:$RdaDest), iops, asm, cstr, pattern> {
346 let Inst{19-16} = RdaDest{3-0};
349 class MVE_ScalarShiftSRegImm<string iname, bits<2> op5_4, list<dag> pattern=[]>
350 : MVE_ScalarShiftSingleReg<iname, (ins rGPR:$RdaSrc, long_shift:$imm),
351 "$RdaSrc, $imm", "$RdaDest = $RdaSrc", pattern> {
355 let Inst{14-12} = imm{4-2};
356 let Inst{11-8} = 0b1111;
357 let Inst{7-6} = imm{1-0};
358 let Inst{5-4} = op5_4{1-0};
359 let Inst{3-0} = 0b1111;
362 def MVE_SQSHL : MVE_ScalarShiftSRegImm<"sqshl", 0b11>;
363 def MVE_SRSHR : MVE_ScalarShiftSRegImm<"srshr", 0b10>;
364 def MVE_UQSHL : MVE_ScalarShiftSRegImm<"uqshl", 0b00>;
365 def MVE_URSHR : MVE_ScalarShiftSRegImm<"urshr", 0b01>;
367 class MVE_ScalarShiftSRegReg<string iname, bits<2> op5_4, list<dag> pattern=[]>
368 : MVE_ScalarShiftSingleReg<iname, (ins rGPR:$RdaSrc, rGPR:$Rm),
369 "$RdaSrc, $Rm", "$RdaDest = $RdaSrc", pattern> {
372 let Inst{15-12} = Rm{3-0};
373 let Inst{11-8} = 0b1111;
374 let Inst{7-6} = 0b00;
375 let Inst{5-4} = op5_4{1-0};
376 let Inst{3-0} = 0b1101;
378 let Unpredictable{8-6} = 0b111;
381 def MVE_SQRSHR : MVE_ScalarShiftSRegReg<"sqrshr", 0b10>;
382 def MVE_UQRSHL : MVE_ScalarShiftSRegReg<"uqrshl", 0b00>;
384 class MVE_ScalarShiftDoubleReg<string iname, dag iops, string asm,
385 string cstr, list<dag> pattern=[]>
386 : MVE_ScalarShift<iname, (outs tGPREven:$RdaLo, tGPROdd:$RdaHi),
387 iops, asm, cstr, pattern> {
391 let Inst{19-17} = RdaLo{3-1};
392 let Inst{11-9} = RdaHi{3-1};
395 class MVE_ScalarShiftDRegImm<string iname, bits<2> op5_4, bit op16,
396 list<dag> pattern=[]>
397 : MVE_ScalarShiftDoubleReg<
398 iname, (ins tGPREven:$RdaLo_src, tGPROdd:$RdaHi_src, long_shift:$imm),
399 "$RdaLo, $RdaHi, $imm", "$RdaLo = $RdaLo_src,$RdaHi = $RdaHi_src",
405 let Inst{14-12} = imm{4-2};
406 let Inst{7-6} = imm{1-0};
407 let Inst{5-4} = op5_4{1-0};
408 let Inst{3-0} = 0b1111;
411 class MVE_ScalarShiftDRegRegBase<string iname, dag iops, string asm,
412 bit op5, bit op16, list<dag> pattern=[]>
413 : MVE_ScalarShiftDoubleReg<
414 iname, iops, asm, "@earlyclobber $RdaHi,@earlyclobber $RdaLo,"
415 "$RdaLo = $RdaLo_src,$RdaHi = $RdaHi_src",
420 let Inst{15-12} = Rm{3-0};
424 let Inst{3-0} = 0b1101;
426 // Custom decoder method because of the following overlapping encodings:
429 // SQRSHRL and SQRSHR
430 // UQRSHLL and UQRSHL
431 let DecoderMethod = "DecodeMVEOverlappingLongShift";
434 class MVE_ScalarShiftDRegReg<string iname, bit op5, list<dag> pattern=[]>
435 : MVE_ScalarShiftDRegRegBase<
436 iname, (ins tGPREven:$RdaLo_src, tGPROdd:$RdaHi_src, rGPR:$Rm),
437 "$RdaLo, $RdaHi, $Rm", op5, 0b0, pattern> {
442 class MVE_ScalarShiftDRegRegWithSat<string iname, bit op5, list<dag> pattern=[]>
443 : MVE_ScalarShiftDRegRegBase<
444 iname, (ins tGPREven:$RdaLo_src, tGPROdd:$RdaHi_src, rGPR:$Rm, saturateop:$sat),
445 "$RdaLo, $RdaHi, $sat, $Rm", op5, 0b1, pattern> {
451 def MVE_ASRLr : MVE_ScalarShiftDRegReg<"asrl", 0b1, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi,
452 (ARMasrl tGPREven:$RdaLo_src,
453 tGPROdd:$RdaHi_src, rGPR:$Rm))]>;
454 def MVE_ASRLi : MVE_ScalarShiftDRegImm<"asrl", 0b10, ?, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi,
455 (ARMasrl tGPREven:$RdaLo_src,
456 tGPROdd:$RdaHi_src, (i32 long_shift:$imm)))]>;
457 def MVE_LSLLr : MVE_ScalarShiftDRegReg<"lsll", 0b0, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi,
458 (ARMlsll tGPREven:$RdaLo_src,
459 tGPROdd:$RdaHi_src, rGPR:$Rm))]>;
460 def MVE_LSLLi : MVE_ScalarShiftDRegImm<"lsll", 0b00, ?, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi,
461 (ARMlsll tGPREven:$RdaLo_src,
462 tGPROdd:$RdaHi_src, (i32 long_shift:$imm)))]>;
463 def MVE_LSRL : MVE_ScalarShiftDRegImm<"lsrl", 0b01, ?, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi,
464 (ARMlsrl tGPREven:$RdaLo_src,
465 tGPROdd:$RdaHi_src, (i32 long_shift:$imm)))]>;
467 def MVE_SQRSHRL : MVE_ScalarShiftDRegRegWithSat<"sqrshrl", 0b1>;
468 def MVE_SQSHLL : MVE_ScalarShiftDRegImm<"sqshll", 0b11, 0b1>;
469 def MVE_SRSHRL : MVE_ScalarShiftDRegImm<"srshrl", 0b10, 0b1>;
471 def MVE_UQRSHLL : MVE_ScalarShiftDRegRegWithSat<"uqrshll", 0b0>;
472 def MVE_UQSHLL : MVE_ScalarShiftDRegImm<"uqshll", 0b00, 0b1>;
473 def MVE_URSHRL : MVE_ScalarShiftDRegImm<"urshrl", 0b01, 0b1>;
475 // start of mve_rDest instructions
477 class MVE_rDest<dag oops, dag iops, InstrItinClass itin,
478 string iname, string suffix,
479 string ops, string cstr, list<dag> pattern=[]>
480 // Always use vpred_n and not vpred_r: with the output register being
481 // a GPR and not a vector register, there can't be any question of
482 // what to put in its inactive lanes.
483 : MVE_p<oops, iops, itin, iname, suffix, ops, vpred_n, cstr, pattern> {
485 let Inst{25-23} = 0b101;
486 let Inst{11-9} = 0b111;
490 class MVE_VABAV<string suffix, bit U, bits<2> size, list<dag> pattern=[]>
491 : MVE_rDest<(outs rGPR:$Rda), (ins rGPR:$Rda_src, MQPR:$Qn, MQPR:$Qm),
492 NoItinerary, "vabav", suffix, "$Rda, $Qn, $Qm", "$Rda = $Rda_src",
500 let Inst{21-20} = size{1-0};
501 let Inst{19-17} = Qn{2-0};
503 let Inst{15-12} = Rda{3-0};
508 let Inst{3-1} = Qm{2-0};
512 def MVE_VABAVs8 : MVE_VABAV<"s8", 0b0, 0b00>;
513 def MVE_VABAVs16 : MVE_VABAV<"s16", 0b0, 0b01>;
514 def MVE_VABAVs32 : MVE_VABAV<"s32", 0b0, 0b10>;
515 def MVE_VABAVu8 : MVE_VABAV<"u8", 0b1, 0b00>;
516 def MVE_VABAVu16 : MVE_VABAV<"u16", 0b1, 0b01>;
517 def MVE_VABAVu32 : MVE_VABAV<"u32", 0b1, 0b10>;
519 class MVE_VADDV<string iname, string suffix, dag iops, string cstr,
520 bit A, bit U, bits<2> size, list<dag> pattern=[]>
521 : MVE_rDest<(outs tGPREven:$Rda), iops, NoItinerary,
522 iname, suffix, "$Rda, $Qm", cstr, pattern> {
527 let Inst{22-20} = 0b111;
528 let Inst{19-18} = size{1-0};
529 let Inst{17-16} = 0b01;
530 let Inst{15-13} = Rda{3-1};
532 let Inst{8-6} = 0b100;
534 let Inst{3-1} = Qm{2-0};
538 multiclass MVE_VADDV_A<string suffix, bit U, bits<2> size,
539 list<dag> pattern=[]> {
540 def acc : MVE_VADDV<"vaddva", suffix,
541 (ins tGPREven:$Rda_src, MQPR:$Qm), "$Rda = $Rda_src",
542 0b1, U, size, pattern>;
543 def no_acc : MVE_VADDV<"vaddv", suffix,
545 0b0, U, size, pattern>;
548 defm MVE_VADDVs8 : MVE_VADDV_A<"s8", 0b0, 0b00>;
549 defm MVE_VADDVs16 : MVE_VADDV_A<"s16", 0b0, 0b01>;
550 defm MVE_VADDVs32 : MVE_VADDV_A<"s32", 0b0, 0b10>;
551 defm MVE_VADDVu8 : MVE_VADDV_A<"u8", 0b1, 0b00>;
552 defm MVE_VADDVu16 : MVE_VADDV_A<"u16", 0b1, 0b01>;
553 defm MVE_VADDVu32 : MVE_VADDV_A<"u32", 0b1, 0b10>;
555 let Predicates = [HasMVEInt] in {
556 def : Pat<(i32 (vecreduce_add (v4i32 MQPR:$src))), (i32 (MVE_VADDVu32no_acc $src))>;
557 def : Pat<(i32 (vecreduce_add (v8i16 MQPR:$src))), (i32 (MVE_VADDVu16no_acc $src))>;
558 def : Pat<(i32 (vecreduce_add (v16i8 MQPR:$src))), (i32 (MVE_VADDVu8no_acc $src))>;
559 def : Pat<(i32 (add (i32 (vecreduce_add (v4i32 MQPR:$src1))), (i32 tGPR:$src2))),
560 (i32 (MVE_VADDVu32acc $src2, $src1))>;
561 def : Pat<(i32 (add (i32 (vecreduce_add (v8i16 MQPR:$src1))), (i32 tGPR:$src2))),
562 (i32 (MVE_VADDVu16acc $src2, $src1))>;
563 def : Pat<(i32 (add (i32 (vecreduce_add (v16i8 MQPR:$src1))), (i32 tGPR:$src2))),
564 (i32 (MVE_VADDVu8acc $src2, $src1))>;
568 class MVE_VADDLV<string iname, string suffix, dag iops, string cstr,
569 bit A, bit U, list<dag> pattern=[]>
570 : MVE_rDest<(outs tGPREven:$RdaLo, tGPROdd:$RdaHi), iops, NoItinerary, iname,
571 suffix, "$RdaLo, $RdaHi, $Qm", cstr, pattern> {
577 let Inst{22-20} = RdaHi{3-1};
578 let Inst{19-18} = 0b10;
579 let Inst{17-16} = 0b01;
580 let Inst{15-13} = RdaLo{3-1};
582 let Inst{8-6} = 0b100;
584 let Inst{3-1} = Qm{2-0};
588 multiclass MVE_VADDLV_A<string suffix, bit U, list<dag> pattern=[]> {
589 def acc : MVE_VADDLV<"vaddlva", suffix,
590 (ins tGPREven:$RdaLo_src, tGPROdd:$RdaHi_src, MQPR:$Qm),
591 "$RdaLo = $RdaLo_src,$RdaHi = $RdaHi_src",
593 def no_acc : MVE_VADDLV<"vaddlv", suffix,
599 defm MVE_VADDLVs32 : MVE_VADDLV_A<"s32", 0b0>;
600 defm MVE_VADDLVu32 : MVE_VADDLV_A<"u32", 0b1>;
602 class MVE_VMINMAXNMV<string iname, string suffix, bit sz,
603 bit bit_17, bit bit_7, list<dag> pattern=[]>
604 : MVE_rDest<(outs rGPR:$RdaDest), (ins rGPR:$RdaSrc, MQPR:$Qm),
605 NoItinerary, iname, suffix, "$RdaSrc, $Qm",
606 "$RdaDest = $RdaSrc", pattern> {
611 let Inst{22-20} = 0b110;
612 let Inst{19-18} = 0b11;
613 let Inst{17} = bit_17;
615 let Inst{15-12} = RdaDest{3-0};
618 let Inst{6-5} = 0b00;
619 let Inst{3-1} = Qm{2-0};
622 let Predicates = [HasMVEFloat];
625 multiclass MVE_VMINMAXNMV_fty<string iname, bit bit_7, list<dag> pattern=[]> {
626 def f32 : MVE_VMINMAXNMV<iname, "f32", 0b0, 0b1, bit_7, pattern>;
627 def f16 : MVE_VMINMAXNMV<iname, "f16", 0b1, 0b1, bit_7, pattern>;
630 defm MVE_VMINNMV : MVE_VMINMAXNMV_fty<"vminnmv", 0b1>;
631 defm MVE_VMAXNMV : MVE_VMINMAXNMV_fty<"vmaxnmv", 0b0>;
633 multiclass MVE_VMINMAXNMAV_fty<string iname, bit bit_7, list<dag> pattern=[]> {
634 def f32 : MVE_VMINMAXNMV<iname, "f32", 0b0, 0b0, bit_7, pattern>;
635 def f16 : MVE_VMINMAXNMV<iname, "f16", 0b1, 0b0, bit_7, pattern>;
638 defm MVE_VMINNMAV : MVE_VMINMAXNMAV_fty<"vminnmav", 0b1>;
639 defm MVE_VMAXNMAV : MVE_VMINMAXNMAV_fty<"vmaxnmav", 0b0>;
641 class MVE_VMINMAXV<string iname, string suffix, bit U, bits<2> size,
642 bit bit_17, bit bit_7, list<dag> pattern=[]>
643 : MVE_rDest<(outs rGPR:$RdaDest), (ins rGPR:$RdaSrc, MQPR:$Qm), NoItinerary,
644 iname, suffix, "$RdaSrc, $Qm", "$RdaDest = $RdaSrc", pattern> {
649 let Inst{22-20} = 0b110;
650 let Inst{19-18} = size{1-0};
651 let Inst{17} = bit_17;
653 let Inst{15-12} = RdaDest{3-0};
656 let Inst{6-5} = 0b00;
657 let Inst{3-1} = Qm{2-0};
661 multiclass MVE_VMINMAXV_ty<string iname, bit bit_7, list<dag> pattern=[]> {
662 def s8 : MVE_VMINMAXV<iname, "s8", 0b0, 0b00, 0b1, bit_7>;
663 def s16 : MVE_VMINMAXV<iname, "s16", 0b0, 0b01, 0b1, bit_7>;
664 def s32 : MVE_VMINMAXV<iname, "s32", 0b0, 0b10, 0b1, bit_7>;
665 def u8 : MVE_VMINMAXV<iname, "u8", 0b1, 0b00, 0b1, bit_7>;
666 def u16 : MVE_VMINMAXV<iname, "u16", 0b1, 0b01, 0b1, bit_7>;
667 def u32 : MVE_VMINMAXV<iname, "u32", 0b1, 0b10, 0b1, bit_7>;
670 defm MVE_VMINV : MVE_VMINMAXV_ty<"vminv", 0b1>;
671 defm MVE_VMAXV : MVE_VMINMAXV_ty<"vmaxv", 0b0>;
673 let Predicates = [HasMVEInt] in {
674 def : Pat<(i32 (vecreduce_smax (v16i8 MQPR:$src))),
675 (i32 (MVE_VMAXVs8 (t2MVNi (i32 127)), $src))>;
676 def : Pat<(i32 (vecreduce_smax (v8i16 MQPR:$src))),
677 (i32 (MVE_VMAXVs16 (t2MOVi32imm (i32 -32768)), $src))>;
678 def : Pat<(i32 (vecreduce_smax (v4i32 MQPR:$src))),
679 (i32 (MVE_VMAXVs32 (t2MOVi (i32 -2147483648)), $src))>;
680 def : Pat<(i32 (vecreduce_umax (v16i8 MQPR:$src))),
681 (i32 (MVE_VMAXVu8 (t2MOVi (i32 0)), $src))>;
682 def : Pat<(i32 (vecreduce_umax (v8i16 MQPR:$src))),
683 (i32 (MVE_VMAXVu16 (t2MOVi (i32 0)), $src))>;
684 def : Pat<(i32 (vecreduce_umax (v4i32 MQPR:$src))),
685 (i32 (MVE_VMAXVu32 (t2MOVi (i32 0)), $src))>;
687 def : Pat<(i32 (vecreduce_smin (v16i8 MQPR:$src))),
688 (i32 (MVE_VMINVs8 (t2MOVi (i32 127)), $src))>;
689 def : Pat<(i32 (vecreduce_smin (v8i16 MQPR:$src))),
690 (i32 (MVE_VMINVs16 (t2MOVi16 (i32 32767)), $src))>;
691 def : Pat<(i32 (vecreduce_smin (v4i32 MQPR:$src))),
692 (i32 (MVE_VMINVs32 (t2MVNi (i32 -2147483648)), $src))>;
693 def : Pat<(i32 (vecreduce_umin (v16i8 MQPR:$src))),
694 (i32 (MVE_VMINVu8 (t2MOVi (i32 255)), $src))>;
695 def : Pat<(i32 (vecreduce_umin (v8i16 MQPR:$src))),
696 (i32 (MVE_VMINVu16 (t2MOVi16 (i32 65535)), $src))>;
697 def : Pat<(i32 (vecreduce_umin (v4i32 MQPR:$src))),
698 (i32 (MVE_VMINVu32 (t2MOVi (i32 4294967295)), $src))>;
702 multiclass MVE_VMINMAXAV_ty<string iname, bit bit_7, list<dag> pattern=[]> {
703 def s8 : MVE_VMINMAXV<iname, "s8", 0b0, 0b00, 0b0, bit_7>;
704 def s16 : MVE_VMINMAXV<iname, "s16", 0b0, 0b01, 0b0, bit_7>;
705 def s32 : MVE_VMINMAXV<iname, "s32", 0b0, 0b10, 0b0, bit_7>;
708 defm MVE_VMINAV : MVE_VMINMAXAV_ty<"vminav", 0b1>;
709 defm MVE_VMAXAV : MVE_VMINMAXAV_ty<"vmaxav", 0b0>;
711 class MVE_VMLAMLSDAV<string iname, string suffix, dag iops, string cstr,
712 bit sz, bit bit_28, bit A, bit X, bit bit_8, bit bit_0,
713 list<dag> pattern=[]>
714 : MVE_rDest<(outs tGPREven:$RdaDest), iops, NoItinerary, iname, suffix,
715 "$RdaDest, $Qn, $Qm", cstr, pattern> {
720 let Inst{28} = bit_28;
721 let Inst{22-20} = 0b111;
722 let Inst{19-17} = Qn{2-0};
724 let Inst{15-13} = RdaDest{3-1};
727 let Inst{7-6} = 0b00;
729 let Inst{3-1} = Qm{2-0};
733 multiclass MVE_VMLAMLSDAV_A<string iname, string x, string suffix,
734 bit sz, bit bit_28, bit X, bit bit_8, bit bit_0,
735 list<dag> pattern=[]> {
736 def ""#x#suffix : MVE_VMLAMLSDAV<iname # x, suffix,
737 (ins MQPR:$Qn, MQPR:$Qm), "",
738 sz, bit_28, 0b0, X, bit_8, bit_0, pattern>;
739 def "a"#x#suffix : MVE_VMLAMLSDAV<iname # "a" # x, suffix,
740 (ins tGPREven:$RdaSrc, MQPR:$Qn, MQPR:$Qm),
741 "$RdaDest = $RdaSrc",
742 sz, bit_28, 0b1, X, bit_8, bit_0, pattern>;
745 multiclass MVE_VMLAMLSDAV_AX<string iname, string suffix, bit sz, bit bit_28,
746 bit bit_8, bit bit_0, list<dag> pattern=[]> {
747 defm "" : MVE_VMLAMLSDAV_A<iname, "", suffix, sz, bit_28,
748 0b0, bit_8, bit_0, pattern>;
749 defm "" : MVE_VMLAMLSDAV_A<iname, "x", suffix, sz, bit_28,
750 0b1, bit_8, bit_0, pattern>;
753 multiclass MVE_VMLADAV_multi<string suffix, bit sz, bit bit_8,
754 list<dag> pattern=[]> {
755 defm "" : MVE_VMLAMLSDAV_AX<"vmladav", "s"#suffix,
756 sz, 0b0, bit_8, 0b0, pattern>;
757 defm "" : MVE_VMLAMLSDAV_A<"vmladav", "", "u"#suffix,
758 sz, 0b1, 0b0, bit_8, 0b0, pattern>;
761 multiclass MVE_VMLSDAV_multi<string suffix, bit sz, bit bit_28,
762 list<dag> pattern=[]> {
763 defm "" : MVE_VMLAMLSDAV_AX<"vmlsdav", "s"#suffix,
764 sz, bit_28, 0b0, 0b1, pattern>;
767 defm MVE_VMLADAV : MVE_VMLADAV_multi< "8", 0b0, 0b1>;
768 defm MVE_VMLADAV : MVE_VMLADAV_multi<"16", 0b0, 0b0>;
769 defm MVE_VMLADAV : MVE_VMLADAV_multi<"32", 0b1, 0b0>;
771 defm MVE_VMLSDAV : MVE_VMLSDAV_multi< "8", 0b0, 0b1>;
772 defm MVE_VMLSDAV : MVE_VMLSDAV_multi<"16", 0b0, 0b0>;
773 defm MVE_VMLSDAV : MVE_VMLSDAV_multi<"32", 0b1, 0b0>;
775 // vmlav aliases vmladav
776 foreach acc = ["", "a"] in {
777 foreach suffix = ["s8", "s16", "s32", "u8", "u16", "u32"] in {
778 def : MVEInstAlias<"vmlav"#acc#"${vp}."#suffix#"\t$RdaDest, $Qn, $Qm",
779 (!cast<Instruction>("MVE_VMLADAV"#acc#suffix)
780 tGPREven:$RdaDest, MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
784 // Base class for VMLALDAV and VMLSLDAV, VRMLALDAVH, VRMLSLDAVH
785 class MVE_VMLALDAVBase<string iname, string suffix, dag iops, string cstr,
786 bit sz, bit bit_28, bit A, bit X, bit bit_8, bit bit_0,
787 list<dag> pattern=[]>
788 : MVE_rDest<(outs tGPREven:$RdaLoDest, tGPROdd:$RdaHiDest), iops, NoItinerary,
789 iname, suffix, "$RdaLoDest, $RdaHiDest, $Qn, $Qm", cstr, pattern> {
795 let Inst{28} = bit_28;
796 let Inst{22-20} = RdaHiDest{3-1};
797 let Inst{19-17} = Qn{2-0};
799 let Inst{15-13} = RdaLoDest{3-1};
802 let Inst{7-6} = 0b00;
804 let Inst{3-1} = Qm{2-0};
808 multiclass MVE_VMLALDAVBase_A<string iname, string x, string suffix,
809 bit sz, bit bit_28, bit X, bit bit_8, bit bit_0,
810 list<dag> pattern=[]> {
811 def ""#x#suffix : MVE_VMLALDAVBase<
812 iname # x, suffix, (ins MQPR:$Qn, MQPR:$Qm), "",
813 sz, bit_28, 0b0, X, bit_8, bit_0, pattern>;
814 def "a"#x#suffix : MVE_VMLALDAVBase<
815 iname # "a" # x, suffix,
816 (ins tGPREven:$RdaLoSrc, tGPROdd:$RdaHiSrc, MQPR:$Qn, MQPR:$Qm),
817 "$RdaLoDest = $RdaLoSrc,$RdaHiDest = $RdaHiSrc",
818 sz, bit_28, 0b1, X, bit_8, bit_0, pattern>;
822 multiclass MVE_VMLALDAVBase_AX<string iname, string suffix, bit sz, bit bit_28,
823 bit bit_8, bit bit_0, list<dag> pattern=[]> {
824 defm "" : MVE_VMLALDAVBase_A<iname, "", suffix, sz,
825 bit_28, 0b0, bit_8, bit_0, pattern>;
826 defm "" : MVE_VMLALDAVBase_A<iname, "x", suffix, sz,
827 bit_28, 0b1, bit_8, bit_0, pattern>;
830 multiclass MVE_VRMLALDAVH_multi<string suffix, list<dag> pattern=[]> {
831 defm "" : MVE_VMLALDAVBase_AX<"vrmlaldavh", "s"#suffix,
832 0b0, 0b0, 0b1, 0b0, pattern>;
833 defm "" : MVE_VMLALDAVBase_A<"vrmlaldavh", "", "u"#suffix,
834 0b0, 0b1, 0b0, 0b1, 0b0, pattern>;
837 defm MVE_VRMLALDAVH : MVE_VRMLALDAVH_multi<"32">;
839 // vrmlalvh aliases for vrmlaldavh
840 def : MVEInstAlias<"vrmlalvh${vp}.s32\t$RdaLo, $RdaHi, $Qn, $Qm",
842 tGPREven:$RdaLo, tGPROdd:$RdaHi,
843 MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
844 def : MVEInstAlias<"vrmlalvha${vp}.s32\t$RdaLo, $RdaHi, $Qn, $Qm",
846 tGPREven:$RdaLo, tGPROdd:$RdaHi,
847 MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
848 def : MVEInstAlias<"vrmlalvh${vp}.u32\t$RdaLo, $RdaHi, $Qn, $Qm",
850 tGPREven:$RdaLo, tGPROdd:$RdaHi,
851 MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
852 def : MVEInstAlias<"vrmlalvha${vp}.u32\t$RdaLo, $RdaHi, $Qn, $Qm",
854 tGPREven:$RdaLo, tGPROdd:$RdaHi,
855 MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
857 multiclass MVE_VMLALDAV_multi<string suffix, bit sz, list<dag> pattern=[]> {
858 defm "" : MVE_VMLALDAVBase_AX<"vmlaldav", "s"#suffix, sz, 0b0, 0b0, 0b0, pattern>;
859 defm "" : MVE_VMLALDAVBase_A<"vmlaldav", "", "u"#suffix,
860 sz, 0b1, 0b0, 0b0, 0b0, pattern>;
863 defm MVE_VMLALDAV : MVE_VMLALDAV_multi<"16", 0b0>;
864 defm MVE_VMLALDAV : MVE_VMLALDAV_multi<"32", 0b1>;
866 // vmlalv aliases vmlaldav
867 foreach acc = ["", "a"] in {
868 foreach suffix = ["s16", "s32", "u16", "u32"] in {
869 def : MVEInstAlias<"vmlalv" # acc # "${vp}." # suffix #
870 "\t$RdaLoDest, $RdaHiDest, $Qn, $Qm",
871 (!cast<Instruction>("MVE_VMLALDAV"#acc#suffix)
872 tGPREven:$RdaLoDest, tGPROdd:$RdaHiDest,
873 MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
877 multiclass MVE_VMLSLDAV_multi<string iname, string suffix, bit sz,
878 bit bit_28, list<dag> pattern=[]> {
879 defm "" : MVE_VMLALDAVBase_AX<iname, suffix, sz, bit_28, 0b0, 0b1, pattern>;
882 defm MVE_VMLSLDAV : MVE_VMLSLDAV_multi<"vmlsldav", "s16", 0b0, 0b0>;
883 defm MVE_VMLSLDAV : MVE_VMLSLDAV_multi<"vmlsldav", "s32", 0b1, 0b0>;
884 defm MVE_VRMLSLDAVH : MVE_VMLSLDAV_multi<"vrmlsldavh", "s32", 0b0, 0b1>;
886 // end of mve_rDest instructions
888 // start of mve_comp instructions
890 class MVE_comp<InstrItinClass itin, string iname, string suffix,
891 string cstr, list<dag> pattern=[]>
892 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm), itin, iname, suffix,
893 "$Qd, $Qn, $Qm", vpred_r, cstr, pattern> {
898 let Inst{22} = Qd{3};
899 let Inst{19-17} = Qn{2-0};
901 let Inst{15-13} = Qd{2-0};
903 let Inst{10-9} = 0b11;
906 let Inst{3-1} = Qm{2-0};
910 class MVE_VMINMAXNM<string iname, string suffix, bit sz, bit bit_21,
911 list<dag> pattern=[]>
912 : MVE_comp<NoItinerary, iname, suffix, "", pattern> {
915 let Inst{25-24} = 0b11;
917 let Inst{21} = bit_21;
924 let Predicates = [HasMVEFloat];
927 def MVE_VMAXNMf32 : MVE_VMINMAXNM<"vmaxnm", "f32", 0b0, 0b0>;
928 def MVE_VMAXNMf16 : MVE_VMINMAXNM<"vmaxnm", "f16", 0b1, 0b0>;
930 let Predicates = [HasMVEFloat] in {
931 def : Pat<(v4f32 (fmaxnum (v4f32 MQPR:$val1), (v4f32 MQPR:$val2))),
932 (v4f32 (MVE_VMAXNMf32 (v4f32 MQPR:$val1), (v4f32 MQPR:$val2)))>;
933 def : Pat<(v8f16 (fmaxnum (v8f16 MQPR:$val1), (v8f16 MQPR:$val2))),
934 (v8f16 (MVE_VMAXNMf16 (v8f16 MQPR:$val1), (v8f16 MQPR:$val2)))>;
937 def MVE_VMINNMf32 : MVE_VMINMAXNM<"vminnm", "f32", 0b0, 0b1>;
938 def MVE_VMINNMf16 : MVE_VMINMAXNM<"vminnm", "f16", 0b1, 0b1>;
940 let Predicates = [HasMVEFloat] in {
941 def : Pat<(v4f32 (fminnum (v4f32 MQPR:$val1), (v4f32 MQPR:$val2))),
942 (v4f32 (MVE_VMINNMf32 (v4f32 MQPR:$val1), (v4f32 MQPR:$val2)))>;
943 def : Pat<(v8f16 (fminnum (v8f16 MQPR:$val1), (v8f16 MQPR:$val2))),
944 (v8f16 (MVE_VMINNMf16 (v8f16 MQPR:$val1), (v8f16 MQPR:$val2)))>;
948 class MVE_VMINMAX<string iname, string suffix, bit U, bits<2> size,
949 bit bit_4, list<dag> pattern=[]>
950 : MVE_comp<NoItinerary, iname, suffix, "", pattern> {
953 let Inst{25-24} = 0b11;
955 let Inst{21-20} = size{1-0};
962 multiclass MVE_VMINMAX_all_sizes<string iname, bit bit_4> {
963 def s8 : MVE_VMINMAX<iname, "s8", 0b0, 0b00, bit_4>;
964 def s16 : MVE_VMINMAX<iname, "s16", 0b0, 0b01, bit_4>;
965 def s32 : MVE_VMINMAX<iname, "s32", 0b0, 0b10, bit_4>;
966 def u8 : MVE_VMINMAX<iname, "u8", 0b1, 0b00, bit_4>;
967 def u16 : MVE_VMINMAX<iname, "u16", 0b1, 0b01, bit_4>;
968 def u32 : MVE_VMINMAX<iname, "u32", 0b1, 0b10, bit_4>;
971 defm MVE_VMAX : MVE_VMINMAX_all_sizes<"vmax", 0b0>;
972 defm MVE_VMIN : MVE_VMINMAX_all_sizes<"vmin", 0b1>;
974 let Predicates = [HasMVEInt] in {
975 def : Pat<(v16i8 (smin (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
976 (v16i8 (MVE_VMINs8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
977 def : Pat<(v8i16 (smin (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
978 (v8i16 (MVE_VMINs16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
979 def : Pat<(v4i32 (smin (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
980 (v4i32 (MVE_VMINs32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
982 def : Pat<(v16i8 (smax (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
983 (v16i8 (MVE_VMAXs8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
984 def : Pat<(v8i16 (smax (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
985 (v8i16 (MVE_VMAXs16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
986 def : Pat<(v4i32 (smax (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
987 (v4i32 (MVE_VMAXs32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
989 def : Pat<(v16i8 (umin (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
990 (v16i8 (MVE_VMINu8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
991 def : Pat<(v8i16 (umin (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
992 (v8i16 (MVE_VMINu16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
993 def : Pat<(v4i32 (umin (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
994 (v4i32 (MVE_VMINu32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
996 def : Pat<(v16i8 (umax (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
997 (v16i8 (MVE_VMAXu8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
998 def : Pat<(v8i16 (umax (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
999 (v8i16 (MVE_VMAXu16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1000 def : Pat<(v4i32 (umax (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
1001 (v4i32 (MVE_VMAXu32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
1004 // end of mve_comp instructions
1006 // start of mve_bit instructions
1008 class MVE_bit_arith<dag oops, dag iops, string iname, string suffix,
1009 string ops, string cstr, list<dag> pattern=[]>
1010 : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred_r, cstr, pattern> {
1014 let Inst{22} = Qd{3};
1015 let Inst{15-13} = Qd{2-0};
1016 let Inst{5} = Qm{3};
1017 let Inst{3-1} = Qm{2-0};
1020 def MVE_VBIC : MVE_bit_arith<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm),
1021 "vbic", "", "$Qd, $Qn, $Qm", ""> {
1025 let Inst{25-23} = 0b110;
1026 let Inst{21-20} = 0b01;
1027 let Inst{19-17} = Qn{2-0};
1029 let Inst{12-8} = 0b00001;
1030 let Inst{7} = Qn{3};
1034 let validForTailPredication = 1;
1037 class MVE_VREV<string iname, string suffix, bits<2> size, bits<2> bit_8_7, string cstr="">
1038 : MVE_bit_arith<(outs MQPR:$Qd), (ins MQPR:$Qm), iname,
1039 suffix, "$Qd, $Qm", cstr> {
1042 let Inst{25-23} = 0b111;
1043 let Inst{21-20} = 0b11;
1044 let Inst{19-18} = size;
1045 let Inst{17-16} = 0b00;
1046 let Inst{12-9} = 0b0000;
1047 let Inst{8-7} = bit_8_7;
1053 def MVE_VREV64_8 : MVE_VREV<"vrev64", "8", 0b00, 0b00, "@earlyclobber $Qd">;
1054 def MVE_VREV64_16 : MVE_VREV<"vrev64", "16", 0b01, 0b00, "@earlyclobber $Qd">;
1055 def MVE_VREV64_32 : MVE_VREV<"vrev64", "32", 0b10, 0b00, "@earlyclobber $Qd">;
1057 def MVE_VREV32_8 : MVE_VREV<"vrev32", "8", 0b00, 0b01>;
1058 def MVE_VREV32_16 : MVE_VREV<"vrev32", "16", 0b01, 0b01>;
1060 def MVE_VREV16_8 : MVE_VREV<"vrev16", "8", 0b00, 0b10>;
1062 let Predicates = [HasMVEInt] in {
1063 def : Pat<(v8i16 (bswap (v8i16 MQPR:$src))),
1064 (v8i16 (MVE_VREV16_8 (v8i16 MQPR:$src)))>;
1065 def : Pat<(v4i32 (bswap (v4i32 MQPR:$src))),
1066 (v4i32 (MVE_VREV32_8 (v4i32 MQPR:$src)))>;
1069 let Predicates = [HasMVEInt] in {
1070 def : Pat<(v4i32 (ARMvrev64 (v4i32 MQPR:$src))),
1071 (v4i32 (MVE_VREV64_32 (v4i32 MQPR:$src)))>;
1072 def : Pat<(v8i16 (ARMvrev64 (v8i16 MQPR:$src))),
1073 (v8i16 (MVE_VREV64_16 (v8i16 MQPR:$src)))>;
1074 def : Pat<(v16i8 (ARMvrev64 (v16i8 MQPR:$src))),
1075 (v16i8 (MVE_VREV64_8 (v16i8 MQPR:$src)))>;
1077 def : Pat<(v8i16 (ARMvrev32 (v8i16 MQPR:$src))),
1078 (v8i16 (MVE_VREV32_16 (v8i16 MQPR:$src)))>;
1079 def : Pat<(v16i8 (ARMvrev32 (v16i8 MQPR:$src))),
1080 (v16i8 (MVE_VREV32_8 (v16i8 MQPR:$src)))>;
1082 def : Pat<(v16i8 (ARMvrev16 (v16i8 MQPR:$src))),
1083 (v16i8 (MVE_VREV16_8 (v16i8 MQPR:$src)))>;
1085 def : Pat<(v4f32 (ARMvrev64 (v4f32 MQPR:$src))),
1086 (v4f32 (MVE_VREV64_32 (v4f32 MQPR:$src)))>;
1087 def : Pat<(v8f16 (ARMvrev64 (v8f16 MQPR:$src))),
1088 (v8f16 (MVE_VREV64_16 (v8f16 MQPR:$src)))>;
1089 def : Pat<(v8f16 (ARMvrev32 (v8f16 MQPR:$src))),
1090 (v8f16 (MVE_VREV32_16 (v8f16 MQPR:$src)))>;
1093 def MVE_VMVN : MVE_bit_arith<(outs MQPR:$Qd), (ins MQPR:$Qm),
1094 "vmvn", "", "$Qd, $Qm", ""> {
1096 let Inst{25-23} = 0b111;
1097 let Inst{21-16} = 0b110000;
1098 let Inst{12-6} = 0b0010111;
1101 let validForTailPredication = 1;
1104 let Predicates = [HasMVEInt] in {
1105 def : Pat<(v16i8 (vnotq (v16i8 MQPR:$val1))),
1106 (v16i8 (MVE_VMVN (v16i8 MQPR:$val1)))>;
1107 def : Pat<(v8i16 (vnotq (v8i16 MQPR:$val1))),
1108 (v8i16 (MVE_VMVN (v8i16 MQPR:$val1)))>;
1109 def : Pat<(v4i32 (vnotq (v4i32 MQPR:$val1))),
1110 (v4i32 (MVE_VMVN (v4i32 MQPR:$val1)))>;
1111 def : Pat<(v2i64 (vnotq (v2i64 MQPR:$val1))),
1112 (v2i64 (MVE_VMVN (v2i64 MQPR:$val1)))>;
1115 class MVE_bit_ops<string iname, bits<2> bit_21_20, bit bit_28>
1116 : MVE_bit_arith<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm),
1117 iname, "", "$Qd, $Qn, $Qm", ""> {
1120 let Inst{28} = bit_28;
1121 let Inst{25-23} = 0b110;
1122 let Inst{21-20} = bit_21_20;
1123 let Inst{19-17} = Qn{2-0};
1125 let Inst{12-8} = 0b00001;
1126 let Inst{7} = Qn{3};
1130 let validForTailPredication = 1;
1133 def MVE_VEOR : MVE_bit_ops<"veor", 0b00, 0b1>;
1134 def MVE_VORN : MVE_bit_ops<"vorn", 0b11, 0b0>;
1135 def MVE_VORR : MVE_bit_ops<"vorr", 0b10, 0b0>;
1136 def MVE_VAND : MVE_bit_ops<"vand", 0b00, 0b0>;
1138 // add ignored suffixes as aliases
1140 foreach s=["s8", "s16", "s32", "u8", "u16", "u32", "i8", "i16", "i32", "f16", "f32"] in {
1141 def : MVEInstAlias<"vbic${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc",
1142 (MVE_VBIC MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>;
1143 def : MVEInstAlias<"veor${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc",
1144 (MVE_VEOR MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>;
1145 def : MVEInstAlias<"vorn${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc",
1146 (MVE_VORN MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>;
1147 def : MVEInstAlias<"vorr${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc",
1148 (MVE_VORR MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>;
1149 def : MVEInstAlias<"vand${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc",
1150 (MVE_VAND MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>;
1153 let Predicates = [HasMVEInt] in {
1154 def : Pat<(v16i8 (and (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
1155 (v16i8 (MVE_VAND (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1156 def : Pat<(v8i16 (and (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
1157 (v8i16 (MVE_VAND (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1158 def : Pat<(v4i32 (and (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
1159 (v4i32 (MVE_VAND (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
1160 def : Pat<(v2i64 (and (v2i64 MQPR:$val1), (v2i64 MQPR:$val2))),
1161 (v2i64 (MVE_VAND (v2i64 MQPR:$val1), (v2i64 MQPR:$val2)))>;
1163 def : Pat<(v16i8 (or (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
1164 (v16i8 (MVE_VORR (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1165 def : Pat<(v8i16 (or (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
1166 (v8i16 (MVE_VORR (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1167 def : Pat<(v4i32 (or (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
1168 (v4i32 (MVE_VORR (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
1169 def : Pat<(v2i64 (or (v2i64 MQPR:$val1), (v2i64 MQPR:$val2))),
1170 (v2i64 (MVE_VORR (v2i64 MQPR:$val1), (v2i64 MQPR:$val2)))>;
1172 def : Pat<(v16i8 (xor (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
1173 (v16i8 (MVE_VEOR (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1174 def : Pat<(v8i16 (xor (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
1175 (v8i16 (MVE_VEOR (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1176 def : Pat<(v4i32 (xor (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
1177 (v4i32 (MVE_VEOR (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
1178 def : Pat<(v2i64 (xor (v2i64 MQPR:$val1), (v2i64 MQPR:$val2))),
1179 (v2i64 (MVE_VEOR (v2i64 MQPR:$val1), (v2i64 MQPR:$val2)))>;
1181 def : Pat<(v16i8 (and (v16i8 MQPR:$val1), (vnotq MQPR:$val2))),
1182 (v16i8 (MVE_VBIC (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1183 def : Pat<(v8i16 (and (v8i16 MQPR:$val1), (vnotq MQPR:$val2))),
1184 (v8i16 (MVE_VBIC (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1185 def : Pat<(v4i32 (and (v4i32 MQPR:$val1), (vnotq MQPR:$val2))),
1186 (v4i32 (MVE_VBIC (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
1187 def : Pat<(v2i64 (and (v2i64 MQPR:$val1), (vnotq MQPR:$val2))),
1188 (v2i64 (MVE_VBIC (v2i64 MQPR:$val1), (v2i64 MQPR:$val2)))>;
1190 def : Pat<(v16i8 (or (v16i8 MQPR:$val1), (vnotq MQPR:$val2))),
1191 (v16i8 (MVE_VORN (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1192 def : Pat<(v8i16 (or (v8i16 MQPR:$val1), (vnotq MQPR:$val2))),
1193 (v8i16 (MVE_VORN (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1194 def : Pat<(v4i32 (or (v4i32 MQPR:$val1), (vnotq MQPR:$val2))),
1195 (v4i32 (MVE_VORN (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
1196 def : Pat<(v2i64 (or (v2i64 MQPR:$val1), (vnotq MQPR:$val2))),
1197 (v2i64 (MVE_VORN (v2i64 MQPR:$val1), (v2i64 MQPR:$val2)))>;
1200 class MVE_bit_cmode<string iname, string suffix, bits<4> cmode, dag inOps>
1201 : MVE_p<(outs MQPR:$Qd), inOps, NoItinerary,
1202 iname, suffix, "$Qd, $imm", vpred_n, "$Qd = $Qd_src"> {
1206 let Inst{28} = imm{7};
1207 let Inst{27-23} = 0b11111;
1208 let Inst{22} = Qd{3};
1209 let Inst{21-19} = 0b000;
1210 let Inst{18-16} = imm{6-4};
1211 let Inst{15-13} = Qd{2-0};
1213 let Inst{11-8} = cmode;
1214 let Inst{7-6} = 0b01;
1216 let Inst{3-0} = imm{3-0};
1219 class MVE_VORR<string suffix, bits<4> cmode, ExpandImm imm_type>
1220 : MVE_bit_cmode<"vorr", suffix, cmode, (ins MQPR:$Qd_src, imm_type:$imm)> {
1222 let validForTailPredication = 1;
1225 def MVE_VORRIZ0v4i32 : MVE_VORR<"i32", 0b0001, expzero00>;
1226 def MVE_VORRIZ0v8i16 : MVE_VORR<"i16", 0b1001, expzero00>;
1227 def MVE_VORRIZ8v4i32 : MVE_VORR<"i32", 0b0011, expzero08>;
1228 def MVE_VORRIZ8v8i16 : MVE_VORR<"i16", 0b1011, expzero08>;
1229 def MVE_VORRIZ16v4i32 : MVE_VORR<"i32", 0b0101, expzero16>;
1230 def MVE_VORRIZ24v4i32 : MVE_VORR<"i32", 0b0111, expzero24>;
1232 def MVE_VORNIZ0v4i32 : MVEAsmPseudo<"vorn${vp}.i32\t$Qd, $imm",
1233 (ins MQPR:$Qd_src, expzero00inv32:$imm, vpred_n:$vp), (outs MQPR:$Qd)>;
1234 def MVE_VORNIZ0v8i16 : MVEAsmPseudo<"vorn${vp}.i16\t$Qd, $imm",
1235 (ins MQPR:$Qd_src, expzero00inv16:$imm, vpred_n:$vp), (outs MQPR:$Qd)>;
1236 def MVE_VORNIZ8v4i32 : MVEAsmPseudo<"vorn${vp}.i32\t$Qd, $imm",
1237 (ins MQPR:$Qd_src, expzero08inv32:$imm, vpred_n:$vp), (outs MQPR:$Qd)>;
1238 def MVE_VORNIZ8v8i16 : MVEAsmPseudo<"vorn${vp}.i16\t$Qd, $imm",
1239 (ins MQPR:$Qd_src, expzero08inv16:$imm, vpred_n:$vp), (outs MQPR:$Qd)>;
1240 def MVE_VORNIZ16v4i32 : MVEAsmPseudo<"vorn${vp}.i32\t$Qd, $imm",
1241 (ins MQPR:$Qd_src, expzero16inv32:$imm, vpred_n:$vp), (outs MQPR:$Qd)>;
1242 def MVE_VORNIZ24v4i32 : MVEAsmPseudo<"vorn${vp}.i32\t$Qd, $imm",
1243 (ins MQPR:$Qd_src, expzero24inv32:$imm, vpred_n:$vp), (outs MQPR:$Qd)>;
1245 def MVE_VMOV : MVEInstAlias<"vmov${vp}\t$Qd, $Qm",
1246 (MVE_VORR MQPR:$Qd, MQPR:$Qm, MQPR:$Qm, vpred_r:$vp)>;
1248 class MVE_VBIC<string suffix, bits<4> cmode, ExpandImm imm_type>
1249 : MVE_bit_cmode<"vbic", suffix, cmode, (ins MQPR:$Qd_src, imm_type:$imm)> {
1251 let validForTailPredication = 1;
1254 def MVE_VBICIZ0v4i32 : MVE_VBIC<"i32", 0b0001, expzero00>;
1255 def MVE_VBICIZ0v8i16 : MVE_VBIC<"i16", 0b1001, expzero00>;
1256 def MVE_VBICIZ8v4i32 : MVE_VBIC<"i32", 0b0011, expzero08>;
1257 def MVE_VBICIZ8v8i16 : MVE_VBIC<"i16", 0b1011, expzero08>;
1258 def MVE_VBICIZ16v4i32 : MVE_VBIC<"i32", 0b0101, expzero16>;
1259 def MVE_VBICIZ24v4i32 : MVE_VBIC<"i32", 0b0111, expzero24>;
1261 def MVE_VANDIZ0v4i32 : MVEAsmPseudo<"vand${vp}.i32\t$Qda, $imm",
1262 (ins MQPR:$Qda_src, expzero00inv32:$imm, vpred_n:$vp), (outs MQPR:$Qda)>;
1263 def MVE_VANDIZ0v8i16 : MVEAsmPseudo<"vand${vp}.i16\t$Qda, $imm",
1264 (ins MQPR:$Qda_src, expzero00inv16:$imm, vpred_n:$vp), (outs MQPR:$Qda)>;
1265 def MVE_VANDIZ8v4i32 : MVEAsmPseudo<"vand${vp}.i32\t$Qda, $imm",
1266 (ins MQPR:$Qda_src, expzero08inv32:$imm, vpred_n:$vp), (outs MQPR:$Qda)>;
1267 def MVE_VANDIZ8v8i16 : MVEAsmPseudo<"vand${vp}.i16\t$Qda, $imm",
1268 (ins MQPR:$Qda_src, expzero08inv16:$imm, vpred_n:$vp), (outs MQPR:$Qda)>;
1269 def MVE_VANDIZ16v4i32 : MVEAsmPseudo<"vand${vp}.i32\t$Qda, $imm",
1270 (ins MQPR:$Qda_src, expzero16inv32:$imm, vpred_n:$vp), (outs MQPR:$Qda)>;
1271 def MVE_VANDIZ24v4i32 : MVEAsmPseudo<"vand${vp}.i32\t$Qda, $imm",
1272 (ins MQPR:$Qda_src, expzero24inv32:$imm, vpred_n:$vp), (outs MQPR:$Qda)>;
1274 class MVE_VMOV_lane_direction {
1281 def MVE_VMOV_from_lane : MVE_VMOV_lane_direction {
1283 let oops = (outs rGPR:$Rt);
1284 let iops = (ins MQPR:$Qd);
1285 let ops = "$Rt, $Qd$Idx";
1288 def MVE_VMOV_to_lane : MVE_VMOV_lane_direction {
1290 let oops = (outs MQPR:$Qd);
1291 let iops = (ins MQPR:$Qd_src, rGPR:$Rt);
1292 let ops = "$Qd$Idx, $Rt";
1293 let cstr = "$Qd = $Qd_src";
1296 class MVE_VMOV_lane<string suffix, bit U, dag indexop,
1297 MVE_VMOV_lane_direction dir>
1298 : MVE_VMOV_lane_base<dir.oops, !con(dir.iops, indexop), NoItinerary,
1299 "vmov", suffix, dir.ops, dir.cstr, []> {
1303 let Inst{31-24} = 0b11101110;
1305 let Inst{20} = dir.bit_20;
1306 let Inst{19-17} = Qd{2-0};
1307 let Inst{15-12} = Rt{3-0};
1308 let Inst{11-8} = 0b1011;
1309 let Inst{7} = Qd{3};
1310 let Inst{4-0} = 0b10000;
1313 class MVE_VMOV_lane_32<MVE_VMOV_lane_direction dir>
1314 : MVE_VMOV_lane<"32", 0b0, (ins MVEVectorIndex<4>:$Idx), dir> {
1317 let Inst{6-5} = 0b00;
1318 let Inst{16} = Idx{1};
1319 let Inst{21} = Idx{0};
1321 let Predicates = [HasFPRegsV8_1M];
1324 class MVE_VMOV_lane_16<string suffix, bit U, MVE_VMOV_lane_direction dir>
1325 : MVE_VMOV_lane<suffix, U, (ins MVEVectorIndex<8>:$Idx), dir> {
1329 let Inst{16} = Idx{2};
1330 let Inst{21} = Idx{1};
1331 let Inst{6} = Idx{0};
1334 class MVE_VMOV_lane_8<string suffix, bit U, MVE_VMOV_lane_direction dir>
1335 : MVE_VMOV_lane<suffix, U, (ins MVEVectorIndex<16>:$Idx), dir> {
1338 let Inst{16} = Idx{3};
1339 let Inst{21} = Idx{2};
1340 let Inst{6} = Idx{1};
1341 let Inst{5} = Idx{0};
1344 def MVE_VMOV_from_lane_32 : MVE_VMOV_lane_32< MVE_VMOV_from_lane>;
1345 def MVE_VMOV_to_lane_32 : MVE_VMOV_lane_32< MVE_VMOV_to_lane>;
1346 def MVE_VMOV_from_lane_s16 : MVE_VMOV_lane_16<"s16", 0b0, MVE_VMOV_from_lane>;
1347 def MVE_VMOV_from_lane_u16 : MVE_VMOV_lane_16<"u16", 0b1, MVE_VMOV_from_lane>;
1348 def MVE_VMOV_to_lane_16 : MVE_VMOV_lane_16< "16", 0b0, MVE_VMOV_to_lane>;
1349 def MVE_VMOV_from_lane_s8 : MVE_VMOV_lane_8 < "s8", 0b0, MVE_VMOV_from_lane>;
1350 def MVE_VMOV_from_lane_u8 : MVE_VMOV_lane_8 < "u8", 0b1, MVE_VMOV_from_lane>;
1351 def MVE_VMOV_to_lane_8 : MVE_VMOV_lane_8 < "8", 0b0, MVE_VMOV_to_lane>;
1353 let Predicates = [HasMVEInt] in {
1354 def : Pat<(extractelt (v2f64 MQPR:$src), imm:$lane),
1355 (f64 (EXTRACT_SUBREG MQPR:$src, (DSubReg_f64_reg imm:$lane)))>;
1356 def : Pat<(insertelt (v2f64 MQPR:$src1), DPR:$src2, imm:$lane),
1357 (INSERT_SUBREG (v2f64 (COPY_TO_REGCLASS MQPR:$src1, MQPR)), DPR:$src2, (DSubReg_f64_reg imm:$lane))>;
1359 def : Pat<(extractelt (v4i32 MQPR:$src), imm:$lane),
1361 (i32 (EXTRACT_SUBREG MQPR:$src, (SSubReg_f32_reg imm:$lane))), rGPR)>;
1362 def : Pat<(insertelt (v4i32 MQPR:$src1), rGPR:$src2, imm:$lane),
1363 (MVE_VMOV_to_lane_32 MQPR:$src1, rGPR:$src2, imm:$lane)>;
1365 def : Pat<(vector_insert (v16i8 MQPR:$src1), rGPR:$src2, imm:$lane),
1366 (MVE_VMOV_to_lane_8 MQPR:$src1, rGPR:$src2, imm:$lane)>;
1367 def : Pat<(vector_insert (v8i16 MQPR:$src1), rGPR:$src2, imm:$lane),
1368 (MVE_VMOV_to_lane_16 MQPR:$src1, rGPR:$src2, imm:$lane)>;
1370 def : Pat<(ARMvgetlanes (v16i8 MQPR:$src), imm:$lane),
1371 (MVE_VMOV_from_lane_s8 MQPR:$src, imm:$lane)>;
1372 def : Pat<(ARMvgetlanes (v8i16 MQPR:$src), imm:$lane),
1373 (MVE_VMOV_from_lane_s16 MQPR:$src, imm:$lane)>;
1374 def : Pat<(ARMvgetlaneu (v16i8 MQPR:$src), imm:$lane),
1375 (MVE_VMOV_from_lane_u8 MQPR:$src, imm:$lane)>;
1376 def : Pat<(ARMvgetlaneu (v8i16 MQPR:$src), imm:$lane),
1377 (MVE_VMOV_from_lane_u16 MQPR:$src, imm:$lane)>;
1379 def : Pat<(v16i8 (scalar_to_vector GPR:$src)),
1380 (MVE_VMOV_to_lane_8 (v16i8 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
1381 def : Pat<(v8i16 (scalar_to_vector GPR:$src)),
1382 (MVE_VMOV_to_lane_16 (v8i16 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
1383 def : Pat<(v4i32 (scalar_to_vector GPR:$src)),
1384 (MVE_VMOV_to_lane_32 (v4i32 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
1386 // Floating point patterns, still enabled under HasMVEInt
1387 def : Pat<(extractelt (v4f32 MQPR:$src), imm:$lane),
1388 (COPY_TO_REGCLASS (f32 (EXTRACT_SUBREG MQPR:$src, (SSubReg_f32_reg imm:$lane))), SPR)>;
1389 def : Pat<(insertelt (v4f32 MQPR:$src1), (f32 SPR:$src2), imm:$lane),
1390 (INSERT_SUBREG (v4f32 (COPY_TO_REGCLASS MQPR:$src1, MQPR)), SPR:$src2, (SSubReg_f32_reg imm:$lane))>;
1392 def : Pat<(insertelt (v8f16 MQPR:$src1), HPR:$src2, imm:$lane),
1393 (MVE_VMOV_to_lane_16 MQPR:$src1, (COPY_TO_REGCLASS HPR:$src2, rGPR), imm:$lane)>;
1394 def : Pat<(extractelt (v8f16 MQPR:$src), imm_even:$lane),
1395 (EXTRACT_SUBREG MQPR:$src, (SSubReg_f16_reg imm_even:$lane))>;
1396 def : Pat<(extractelt (v8f16 MQPR:$src), imm_odd:$lane),
1398 (VMOVH (EXTRACT_SUBREG MQPR:$src, (SSubReg_f16_reg imm_odd:$lane))),
1401 def : Pat<(v4f32 (scalar_to_vector SPR:$src)),
1402 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), SPR:$src, ssub_0)>;
1403 def : Pat<(v4f32 (scalar_to_vector GPR:$src)),
1404 (MVE_VMOV_to_lane_32 (v4f32 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
1405 def : Pat<(v8f16 (scalar_to_vector HPR:$src)),
1406 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), HPR:$src, ssub_0)>;
1407 def : Pat<(v8f16 (scalar_to_vector GPR:$src)),
1408 (MVE_VMOV_to_lane_16 (v8f16 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
1411 // end of mve_bit instructions
1413 // start of MVE Integer instructions
1415 class MVE_int<string iname, string suffix, bits<2> size, list<dag> pattern=[]>
1416 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm), NoItinerary,
1417 iname, suffix, "$Qd, $Qn, $Qm", vpred_r, "", pattern> {
1422 let Inst{22} = Qd{3};
1423 let Inst{21-20} = size;
1424 let Inst{19-17} = Qn{2-0};
1425 let Inst{15-13} = Qd{2-0};
1426 let Inst{7} = Qn{3};
1428 let Inst{5} = Qm{3};
1429 let Inst{3-1} = Qm{2-0};
1432 class MVE_VMULt1<string suffix, bits<2> size, list<dag> pattern=[]>
1433 : MVE_int<"vmul", suffix, size, pattern> {
1436 let Inst{25-23} = 0b110;
1438 let Inst{12-8} = 0b01001;
1443 def MVE_VMULt1i8 : MVE_VMULt1<"i8", 0b00>;
1444 def MVE_VMULt1i16 : MVE_VMULt1<"i16", 0b01>;
1445 def MVE_VMULt1i32 : MVE_VMULt1<"i32", 0b10>;
1447 let Predicates = [HasMVEInt] in {
1448 def : Pat<(v16i8 (mul (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
1449 (v16i8 (MVE_VMULt1i8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1450 def : Pat<(v8i16 (mul (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
1451 (v8i16 (MVE_VMULt1i16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1452 def : Pat<(v4i32 (mul (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
1453 (v4i32 (MVE_VMULt1i32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
1456 class MVE_VQxDMULH<string iname, string suffix, bits<2> size, bit rounding,
1457 list<dag> pattern=[]>
1458 : MVE_int<iname, suffix, size, pattern> {
1460 let Inst{28} = rounding;
1461 let Inst{25-23} = 0b110;
1463 let Inst{12-8} = 0b01011;
1468 class MVE_VQDMULH<string suffix, bits<2> size, list<dag> pattern=[]>
1469 : MVE_VQxDMULH<"vqdmulh", suffix, size, 0b0, pattern>;
1470 class MVE_VQRDMULH<string suffix, bits<2> size, list<dag> pattern=[]>
1471 : MVE_VQxDMULH<"vqrdmulh", suffix, size, 0b1, pattern>;
1473 def MVE_VQDMULHi8 : MVE_VQDMULH<"s8", 0b00>;
1474 def MVE_VQDMULHi16 : MVE_VQDMULH<"s16", 0b01>;
1475 def MVE_VQDMULHi32 : MVE_VQDMULH<"s32", 0b10>;
1477 def MVE_VQRDMULHi8 : MVE_VQRDMULH<"s8", 0b00>;
1478 def MVE_VQRDMULHi16 : MVE_VQRDMULH<"s16", 0b01>;
1479 def MVE_VQRDMULHi32 : MVE_VQRDMULH<"s32", 0b10>;
1481 class MVE_VADDSUB<string iname, string suffix, bits<2> size, bit subtract,
1482 list<dag> pattern=[]>
1483 : MVE_int<iname, suffix, size, pattern> {
1485 let Inst{28} = subtract;
1486 let Inst{25-23} = 0b110;
1488 let Inst{12-8} = 0b01000;
1491 let validForTailPredication = 1;
1494 class MVE_VADD<string suffix, bits<2> size, list<dag> pattern=[]>
1495 : MVE_VADDSUB<"vadd", suffix, size, 0b0, pattern>;
1496 class MVE_VSUB<string suffix, bits<2> size, list<dag> pattern=[]>
1497 : MVE_VADDSUB<"vsub", suffix, size, 0b1, pattern>;
1499 def MVE_VADDi8 : MVE_VADD<"i8", 0b00>;
1500 def MVE_VADDi16 : MVE_VADD<"i16", 0b01>;
1501 def MVE_VADDi32 : MVE_VADD<"i32", 0b10>;
1503 let Predicates = [HasMVEInt] in {
1504 def : Pat<(v16i8 (add (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
1505 (v16i8 (MVE_VADDi8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1506 def : Pat<(v8i16 (add (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
1507 (v8i16 (MVE_VADDi16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1508 def : Pat<(v4i32 (add (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
1509 (v4i32 (MVE_VADDi32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
1512 def MVE_VSUBi8 : MVE_VSUB<"i8", 0b00>;
1513 def MVE_VSUBi16 : MVE_VSUB<"i16", 0b01>;
1514 def MVE_VSUBi32 : MVE_VSUB<"i32", 0b10>;
1516 let Predicates = [HasMVEInt] in {
1517 def : Pat<(v16i8 (sub (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
1518 (v16i8 (MVE_VSUBi8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1519 def : Pat<(v8i16 (sub (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
1520 (v8i16 (MVE_VSUBi16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1521 def : Pat<(v4i32 (sub (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
1522 (v4i32 (MVE_VSUBi32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
1525 class MVE_VQADDSUB<string iname, string suffix, bit U, bit subtract,
1526 bits<2> size, ValueType vt>
1527 : MVE_int<iname, suffix, size, []> {
1530 let Inst{25-23} = 0b110;
1532 let Inst{12-10} = 0b000;
1533 let Inst{9} = subtract;
1537 let validForTailPredication = 1;
1542 class MVE_VQADD<string suffix, bit U, bits<2> size, ValueType VT>
1543 : MVE_VQADDSUB<"vqadd", suffix, U, 0b0, size, VT>;
1544 class MVE_VQSUB<string suffix, bit U, bits<2> size, ValueType VT>
1545 : MVE_VQADDSUB<"vqsub", suffix, U, 0b1, size, VT>;
1547 def MVE_VQADDs8 : MVE_VQADD<"s8", 0b0, 0b00, v16i8>;
1548 def MVE_VQADDs16 : MVE_VQADD<"s16", 0b0, 0b01, v8i16>;
1549 def MVE_VQADDs32 : MVE_VQADD<"s32", 0b0, 0b10, v4i32>;
1550 def MVE_VQADDu8 : MVE_VQADD<"u8", 0b1, 0b00, v16i8>;
1551 def MVE_VQADDu16 : MVE_VQADD<"u16", 0b1, 0b01, v8i16>;
1552 def MVE_VQADDu32 : MVE_VQADD<"u32", 0b1, 0b10, v4i32>;
1554 def MVE_VQSUBs8 : MVE_VQSUB<"s8", 0b0, 0b00, v16i8>;
1555 def MVE_VQSUBs16 : MVE_VQSUB<"s16", 0b0, 0b01, v8i16>;
1556 def MVE_VQSUBs32 : MVE_VQSUB<"s32", 0b0, 0b10, v4i32>;
1557 def MVE_VQSUBu8 : MVE_VQSUB<"u8", 0b1, 0b00, v16i8>;
1558 def MVE_VQSUBu16 : MVE_VQSUB<"u16", 0b1, 0b01, v8i16>;
1559 def MVE_VQSUBu32 : MVE_VQSUB<"u32", 0b1, 0b10, v4i32>;
1561 let Predicates = [HasMVEInt] in {
1562 foreach instr = [MVE_VQADDu8, MVE_VQADDu16, MVE_VQADDu32] in
1563 foreach VT = [instr.VT] in
1564 def : Pat<(VT (uaddsat (VT MQPR:$Qm), (VT MQPR:$Qn))),
1565 (VT (instr (VT MQPR:$Qm), (VT MQPR:$Qn)))>;
1566 foreach instr = [MVE_VQADDs8, MVE_VQADDs16, MVE_VQADDs32] in
1567 foreach VT = [instr.VT] in
1568 def : Pat<(VT (saddsat (VT MQPR:$Qm), (VT MQPR:$Qn))),
1569 (VT (instr (VT MQPR:$Qm), (VT MQPR:$Qn)))>;
1570 foreach instr = [MVE_VQSUBu8, MVE_VQSUBu16, MVE_VQSUBu32] in
1571 foreach VT = [instr.VT] in
1572 def : Pat<(VT (usubsat (VT MQPR:$Qm), (VT MQPR:$Qn))),
1573 (VT (instr (VT MQPR:$Qm), (VT MQPR:$Qn)))>;
1574 foreach instr = [MVE_VQSUBs8, MVE_VQSUBs16, MVE_VQSUBs32] in
1575 foreach VT = [instr.VT] in
1576 def : Pat<(VT (ssubsat (VT MQPR:$Qm), (VT MQPR:$Qn))),
1577 (VT (instr (VT MQPR:$Qm), (VT MQPR:$Qn)))>;
1581 class MVE_VABD_int<string suffix, bit U, bits<2> size, list<dag> pattern=[]>
1582 : MVE_int<"vabd", suffix, size, pattern> {
1585 let Inst{25-23} = 0b110;
1587 let Inst{12-8} = 0b00111;
1590 let validForTailPredication = 1;
1593 def MVE_VABDs8 : MVE_VABD_int<"s8", 0b0, 0b00>;
1594 def MVE_VABDs16 : MVE_VABD_int<"s16", 0b0, 0b01>;
1595 def MVE_VABDs32 : MVE_VABD_int<"s32", 0b0, 0b10>;
1596 def MVE_VABDu8 : MVE_VABD_int<"u8", 0b1, 0b00>;
1597 def MVE_VABDu16 : MVE_VABD_int<"u16", 0b1, 0b01>;
1598 def MVE_VABDu32 : MVE_VABD_int<"u32", 0b1, 0b10>;
1600 class MVE_VRHADD<string suffix, bit U, bits<2> size, list<dag> pattern=[]>
1601 : MVE_int<"vrhadd", suffix, size, pattern> {
1604 let Inst{25-23} = 0b110;
1606 let Inst{12-8} = 0b00001;
1609 let validForTailPredication = 1;
1612 def MVE_VRHADDs8 : MVE_VRHADD<"s8", 0b0, 0b00>;
1613 def MVE_VRHADDs16 : MVE_VRHADD<"s16", 0b0, 0b01>;
1614 def MVE_VRHADDs32 : MVE_VRHADD<"s32", 0b0, 0b10>;
1615 def MVE_VRHADDu8 : MVE_VRHADD<"u8", 0b1, 0b00>;
1616 def MVE_VRHADDu16 : MVE_VRHADD<"u16", 0b1, 0b01>;
1617 def MVE_VRHADDu32 : MVE_VRHADD<"u32", 0b1, 0b10>;
1619 class MVE_VHADDSUB<string iname, string suffix, bit U, bit subtract,
1620 bits<2> size, list<dag> pattern=[]>
1621 : MVE_int<iname, suffix, size, pattern> {
1624 let Inst{25-23} = 0b110;
1626 let Inst{12-10} = 0b000;
1627 let Inst{9} = subtract;
1631 let validForTailPredication = 1;
1634 class MVE_VHADD<string suffix, bit U, bits<2> size,
1635 list<dag> pattern=[]>
1636 : MVE_VHADDSUB<"vhadd", suffix, U, 0b0, size, pattern>;
1637 class MVE_VHSUB<string suffix, bit U, bits<2> size,
1638 list<dag> pattern=[]>
1639 : MVE_VHADDSUB<"vhsub", suffix, U, 0b1, size, pattern>;
1641 def MVE_VHADDs8 : MVE_VHADD<"s8", 0b0, 0b00>;
1642 def MVE_VHADDs16 : MVE_VHADD<"s16", 0b0, 0b01>;
1643 def MVE_VHADDs32 : MVE_VHADD<"s32", 0b0, 0b10>;
1644 def MVE_VHADDu8 : MVE_VHADD<"u8", 0b1, 0b00>;
1645 def MVE_VHADDu16 : MVE_VHADD<"u16", 0b1, 0b01>;
1646 def MVE_VHADDu32 : MVE_VHADD<"u32", 0b1, 0b10>;
1648 def MVE_VHSUBs8 : MVE_VHSUB<"s8", 0b0, 0b00>;
1649 def MVE_VHSUBs16 : MVE_VHSUB<"s16", 0b0, 0b01>;
1650 def MVE_VHSUBs32 : MVE_VHSUB<"s32", 0b0, 0b10>;
1651 def MVE_VHSUBu8 : MVE_VHSUB<"u8", 0b1, 0b00>;
1652 def MVE_VHSUBu16 : MVE_VHSUB<"u16", 0b1, 0b01>;
1653 def MVE_VHSUBu32 : MVE_VHSUB<"u32", 0b1, 0b10>;
1655 let Predicates = [HasMVEInt] in {
1656 def : Pat<(v16i8 (ARMvshrsImm
1657 (v16i8 (add (v16i8 MQPR:$v1), (v16i8 MQPR:$v2))), 1)),
1659 (v16i8 MQPR:$v1), (v16i8 MQPR:$v2)))>;
1660 def : Pat<(v8i16 (ARMvshrsImm
1661 (v8i16 (add (v8i16 MQPR:$v1), (v8i16 MQPR:$v2))), 1)),
1662 (v8i16 (MVE_VHADDs16
1663 (v8i16 MQPR:$v1), (v8i16 MQPR:$v2)))>;
1664 def : Pat<(v4i32 (ARMvshrsImm
1665 (v4i32 (add (v4i32 MQPR:$v1), (v4i32 MQPR:$v2))), 1)),
1666 (v4i32 (MVE_VHADDs32
1667 (v4i32 MQPR:$v1), (v4i32 MQPR:$v2)))>;
1669 def : Pat<(v16i8 (ARMvshruImm
1670 (v16i8 (add (v16i8 MQPR:$v1), (v16i8 MQPR:$v2))), 1)),
1672 (v16i8 MQPR:$v1), (v16i8 MQPR:$v2)))>;
1673 def : Pat<(v8i16 (ARMvshruImm
1674 (v8i16 (add (v8i16 MQPR:$v1), (v8i16 MQPR:$v2))), 1)),
1675 (v8i16 (MVE_VHADDu16
1676 (v8i16 MQPR:$v1), (v8i16 MQPR:$v2)))>;
1677 def : Pat<(v4i32 (ARMvshruImm
1678 (v4i32 (add (v4i32 MQPR:$v1), (v4i32 MQPR:$v2))), 1)),
1679 (v4i32 (MVE_VHADDu32
1680 (v4i32 MQPR:$v1), (v4i32 MQPR:$v2)))>;
1682 def : Pat<(v16i8 (ARMvshrsImm
1683 (v16i8 (sub (v16i8 MQPR:$v1), (v16i8 MQPR:$v2))), 1)),
1685 (v16i8 MQPR:$v1), (v16i8 MQPR:$v2)))>;
1686 def : Pat<(v8i16 (ARMvshrsImm
1687 (v8i16 (sub (v8i16 MQPR:$v1), (v8i16 MQPR:$v2))), 1)),
1688 (v8i16 (MVE_VHSUBs16
1689 (v8i16 MQPR:$v1), (v8i16 MQPR:$v2)))>;
1690 def : Pat<(v4i32 (ARMvshrsImm
1691 (v4i32 (sub (v4i32 MQPR:$v1), (v4i32 MQPR:$v2))), 1)),
1692 (v4i32 (MVE_VHSUBs32
1693 (v4i32 MQPR:$v1), (v4i32 MQPR:$v2)))>;
1695 def : Pat<(v16i8 (ARMvshruImm
1696 (v16i8 (sub (v16i8 MQPR:$v1), (v16i8 MQPR:$v2))), 1)),
1698 (v16i8 MQPR:$v1), (v16i8 MQPR:$v2)))>;
1699 def : Pat<(v8i16 (ARMvshruImm
1700 (v8i16 (sub (v8i16 MQPR:$v1), (v8i16 MQPR:$v2))), 1)),
1701 (v8i16 (MVE_VHSUBu16
1702 (v8i16 MQPR:$v1), (v8i16 MQPR:$v2)))>;
1703 def : Pat<(v4i32 (ARMvshruImm
1704 (v4i32 (sub (v4i32 MQPR:$v1), (v4i32 MQPR:$v2))), 1)),
1705 (v4i32 (MVE_VHSUBu32
1706 (v4i32 MQPR:$v1), (v4i32 MQPR:$v2)))>;
1709 class MVE_VDUP<string suffix, bit B, bit E, list<dag> pattern=[]>
1710 : MVE_p<(outs MQPR:$Qd), (ins rGPR:$Rt), NoItinerary,
1711 "vdup", suffix, "$Qd, $Rt", vpred_r, "", pattern> {
1716 let Inst{25-23} = 0b101;
1718 let Inst{21-20} = 0b10;
1719 let Inst{19-17} = Qd{2-0};
1721 let Inst{15-12} = Rt;
1722 let Inst{11-8} = 0b1011;
1723 let Inst{7} = Qd{3};
1726 let Inst{4-0} = 0b10000;
1727 let validForTailPredication = 1;
1730 def MVE_VDUP32 : MVE_VDUP<"32", 0b0, 0b0>;
1731 def MVE_VDUP16 : MVE_VDUP<"16", 0b0, 0b1>;
1732 def MVE_VDUP8 : MVE_VDUP<"8", 0b1, 0b0>;
1734 let Predicates = [HasMVEInt] in {
1735 def : Pat<(v16i8 (ARMvdup (i32 rGPR:$elem))),
1736 (MVE_VDUP8 rGPR:$elem)>;
1737 def : Pat<(v8i16 (ARMvdup (i32 rGPR:$elem))),
1738 (MVE_VDUP16 rGPR:$elem)>;
1739 def : Pat<(v4i32 (ARMvdup (i32 rGPR:$elem))),
1740 (MVE_VDUP32 rGPR:$elem)>;
1742 def : Pat<(v4i32 (ARMvduplane (v4i32 MQPR:$src), imm:$lane)),
1743 (MVE_VDUP32 (MVE_VMOV_from_lane_32 MQPR:$src, imm:$lane))>;
1744 // For the 16-bit and 8-bit vduplanes we don't care about the signedness
1745 // of the lane move operation as we only want the lowest 8/16 bits anyway.
1746 def : Pat<(v8i16 (ARMvduplane (v8i16 MQPR:$src), imm:$lane)),
1747 (MVE_VDUP16 (MVE_VMOV_from_lane_u16 MQPR:$src, imm:$lane))>;
1748 def : Pat<(v16i8 (ARMvduplane (v16i8 MQPR:$src), imm:$lane)),
1749 (MVE_VDUP8 (MVE_VMOV_from_lane_u8 MQPR:$src, imm:$lane))>;
1751 def : Pat<(v4f32 (ARMvdup (f32 SPR:$elem))),
1752 (v4f32 (MVE_VDUP32 (i32 (COPY_TO_REGCLASS (f32 SPR:$elem), rGPR))))>;
1753 def : Pat<(v8f16 (ARMvdup (f16 HPR:$elem))),
1754 (v8f16 (MVE_VDUP16 (i32 (COPY_TO_REGCLASS (f16 HPR:$elem), rGPR))))>;
1756 def : Pat<(v4f32 (ARMvduplane (v4f32 MQPR:$src), imm:$lane)),
1757 (MVE_VDUP32 (MVE_VMOV_from_lane_32 MQPR:$src, imm:$lane))>;
1758 def : Pat<(v8f16 (ARMvduplane (v8f16 MQPR:$src), imm:$lane)),
1759 (MVE_VDUP16 (MVE_VMOV_from_lane_u16 MQPR:$src, imm:$lane))>;
1763 class MVEIntSingleSrc<string iname, string suffix, bits<2> size,
1764 list<dag> pattern=[]>
1765 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qm), NoItinerary,
1766 iname, suffix, "$Qd, $Qm", vpred_r, "", pattern> {
1770 let Inst{22} = Qd{3};
1771 let Inst{19-18} = size{1-0};
1772 let Inst{15-13} = Qd{2-0};
1773 let Inst{5} = Qm{3};
1774 let Inst{3-1} = Qm{2-0};
1777 class MVE_VCLSCLZ<string iname, string suffix, bits<2> size,
1778 bit count_zeroes, list<dag> pattern=[]>
1779 : MVEIntSingleSrc<iname, suffix, size, pattern> {
1782 let Inst{25-23} = 0b111;
1783 let Inst{21-20} = 0b11;
1784 let Inst{17-16} = 0b00;
1785 let Inst{12-8} = 0b00100;
1786 let Inst{7} = count_zeroes;
1790 let validForTailPredication = 1;
1793 def MVE_VCLSs8 : MVE_VCLSCLZ<"vcls", "s8", 0b00, 0b0>;
1794 def MVE_VCLSs16 : MVE_VCLSCLZ<"vcls", "s16", 0b01, 0b0>;
1795 def MVE_VCLSs32 : MVE_VCLSCLZ<"vcls", "s32", 0b10, 0b0>;
1797 def MVE_VCLZs8 : MVE_VCLSCLZ<"vclz", "i8", 0b00, 0b1>;
1798 def MVE_VCLZs16 : MVE_VCLSCLZ<"vclz", "i16", 0b01, 0b1>;
1799 def MVE_VCLZs32 : MVE_VCLSCLZ<"vclz", "i32", 0b10, 0b1>;
1801 let Predicates = [HasMVEInt] in {
1802 def : Pat<(v16i8 ( ctlz (v16i8 MQPR:$val1))),
1803 (v16i8 ( MVE_VCLZs8 (v16i8 MQPR:$val1)))>;
1804 def : Pat<(v4i32 ( ctlz (v4i32 MQPR:$val1))),
1805 (v4i32 ( MVE_VCLZs32 (v4i32 MQPR:$val1)))>;
1806 def : Pat<(v8i16 ( ctlz (v8i16 MQPR:$val1))),
1807 (v8i16 ( MVE_VCLZs16 (v8i16 MQPR:$val1)))>;
1810 class MVE_VABSNEG_int<string iname, string suffix, bits<2> size, bit negate,
1811 list<dag> pattern=[]>
1812 : MVEIntSingleSrc<iname, suffix, size, pattern> {
1815 let Inst{25-23} = 0b111;
1816 let Inst{21-20} = 0b11;
1817 let Inst{17-16} = 0b01;
1818 let Inst{12-8} = 0b00011;
1819 let Inst{7} = negate;
1823 let validForTailPredication = 1;
1826 def MVE_VABSs8 : MVE_VABSNEG_int<"vabs", "s8", 0b00, 0b0>;
1827 def MVE_VABSs16 : MVE_VABSNEG_int<"vabs", "s16", 0b01, 0b0>;
1828 def MVE_VABSs32 : MVE_VABSNEG_int<"vabs", "s32", 0b10, 0b0>;
1830 let Predicates = [HasMVEInt] in {
1831 def : Pat<(v16i8 (abs (v16i8 MQPR:$v))),
1832 (v16i8 (MVE_VABSs8 $v))>;
1833 def : Pat<(v8i16 (abs (v8i16 MQPR:$v))),
1834 (v8i16 (MVE_VABSs16 $v))>;
1835 def : Pat<(v4i32 (abs (v4i32 MQPR:$v))),
1836 (v4i32 (MVE_VABSs32 $v))>;
1839 def MVE_VNEGs8 : MVE_VABSNEG_int<"vneg", "s8", 0b00, 0b1>;
1840 def MVE_VNEGs16 : MVE_VABSNEG_int<"vneg", "s16", 0b01, 0b1>;
1841 def MVE_VNEGs32 : MVE_VABSNEG_int<"vneg", "s32", 0b10, 0b1>;
1843 let Predicates = [HasMVEInt] in {
1844 def : Pat<(v16i8 (vnegq (v16i8 MQPR:$v))),
1845 (v16i8 (MVE_VNEGs8 $v))>;
1846 def : Pat<(v8i16 (vnegq (v8i16 MQPR:$v))),
1847 (v8i16 (MVE_VNEGs16 $v))>;
1848 def : Pat<(v4i32 (vnegq (v4i32 MQPR:$v))),
1849 (v4i32 (MVE_VNEGs32 $v))>;
1852 class MVE_VQABSNEG<string iname, string suffix, bits<2> size,
1853 bit negate, list<dag> pattern=[]>
1854 : MVEIntSingleSrc<iname, suffix, size, pattern> {
1857 let Inst{25-23} = 0b111;
1858 let Inst{21-20} = 0b11;
1859 let Inst{17-16} = 0b00;
1860 let Inst{12-8} = 0b00111;
1861 let Inst{7} = negate;
1865 let validForTailPredication = 1;
1868 def MVE_VQABSs8 : MVE_VQABSNEG<"vqabs", "s8", 0b00, 0b0>;
1869 def MVE_VQABSs16 : MVE_VQABSNEG<"vqabs", "s16", 0b01, 0b0>;
1870 def MVE_VQABSs32 : MVE_VQABSNEG<"vqabs", "s32", 0b10, 0b0>;
1872 def MVE_VQNEGs8 : MVE_VQABSNEG<"vqneg", "s8", 0b00, 0b1>;
1873 def MVE_VQNEGs16 : MVE_VQABSNEG<"vqneg", "s16", 0b01, 0b1>;
1874 def MVE_VQNEGs32 : MVE_VQABSNEG<"vqneg", "s32", 0b10, 0b1>;
1876 class MVE_mod_imm<string iname, string suffix, bits<4> cmode, bit op,
1877 dag iops, list<dag> pattern=[]>
1878 : MVE_p<(outs MQPR:$Qd), iops, NoItinerary, iname, suffix, "$Qd, $imm",
1879 vpred_r, "", pattern> {
1883 let Inst{28} = imm{7};
1884 let Inst{25-23} = 0b111;
1885 let Inst{22} = Qd{3};
1886 let Inst{21-19} = 0b000;
1887 let Inst{18-16} = imm{6-4};
1888 let Inst{15-13} = Qd{2-0};
1890 let Inst{11-8} = cmode{3-0};
1891 let Inst{7-6} = 0b01;
1894 let Inst{3-0} = imm{3-0};
1896 let DecoderMethod = "DecodeMVEModImmInstruction";
1897 let validForTailPredication = 1;
1900 let isReMaterializable = 1 in {
1901 let isAsCheapAsAMove = 1 in {
1902 def MVE_VMOVimmi8 : MVE_mod_imm<"vmov", "i8", {1,1,1,0}, 0b0, (ins nImmSplatI8:$imm)>;
1903 def MVE_VMOVimmi16 : MVE_mod_imm<"vmov", "i16", {1,0,?,0}, 0b0, (ins nImmSplatI16:$imm)> {
1904 let Inst{9} = imm{9};
1906 def MVE_VMOVimmi32 : MVE_mod_imm<"vmov", "i32", {?,?,?,?}, 0b0, (ins nImmVMOVI32:$imm)> {
1907 let Inst{11-8} = imm{11-8};
1909 def MVE_VMOVimmi64 : MVE_mod_imm<"vmov", "i64", {1,1,1,0}, 0b1, (ins nImmSplatI64:$imm)>;
1910 def MVE_VMOVimmf32 : MVE_mod_imm<"vmov", "f32", {1,1,1,1}, 0b0, (ins nImmVMOVF32:$imm)>;
1911 } // let isAsCheapAsAMove = 1
1913 def MVE_VMVNimmi16 : MVE_mod_imm<"vmvn", "i16", {1,0,?,0}, 0b1, (ins nImmSplatI16:$imm)> {
1914 let Inst{9} = imm{9};
1916 def MVE_VMVNimmi32 : MVE_mod_imm<"vmvn", "i32", {?,?,?,?}, 0b1, (ins nImmVMOVI32:$imm)> {
1917 let Inst{11-8} = imm{11-8};
1919 } // let isReMaterializable = 1
1921 let Predicates = [HasMVEInt] in {
1922 def : Pat<(v16i8 (ARMvmovImm timm:$simm)),
1923 (v16i8 (MVE_VMOVimmi8 nImmSplatI8:$simm))>;
1924 def : Pat<(v8i16 (ARMvmovImm timm:$simm)),
1925 (v8i16 (MVE_VMOVimmi16 nImmSplatI16:$simm))>;
1926 def : Pat<(v4i32 (ARMvmovImm timm:$simm)),
1927 (v4i32 (MVE_VMOVimmi32 nImmVMOVI32:$simm))>;
1929 def : Pat<(v8i16 (ARMvmvnImm timm:$simm)),
1930 (v8i16 (MVE_VMVNimmi16 nImmSplatI16:$simm))>;
1931 def : Pat<(v4i32 (ARMvmvnImm timm:$simm)),
1932 (v4i32 (MVE_VMVNimmi32 nImmVMOVI32:$simm))>;
1934 def : Pat<(v4f32 (ARMvmovFPImm timm:$simm)),
1935 (v4f32 (MVE_VMOVimmf32 nImmVMOVF32:$simm))>;
1938 class MVE_VMINMAXA<string iname, string suffix, bits<2> size,
1939 bit bit_12, list<dag> pattern=[]>
1940 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qd_src, MQPR:$Qm),
1941 NoItinerary, iname, suffix, "$Qd, $Qm", vpred_n, "$Qd = $Qd_src",
1947 let Inst{25-23} = 0b100;
1948 let Inst{22} = Qd{3};
1949 let Inst{21-20} = 0b11;
1950 let Inst{19-18} = size;
1951 let Inst{17-16} = 0b11;
1952 let Inst{15-13} = Qd{2-0};
1953 let Inst{12} = bit_12;
1954 let Inst{11-6} = 0b111010;
1955 let Inst{5} = Qm{3};
1957 let Inst{3-1} = Qm{2-0};
1961 def MVE_VMAXAs8 : MVE_VMINMAXA<"vmaxa", "s8", 0b00, 0b0>;
1962 def MVE_VMAXAs16 : MVE_VMINMAXA<"vmaxa", "s16", 0b01, 0b0>;
1963 def MVE_VMAXAs32 : MVE_VMINMAXA<"vmaxa", "s32", 0b10, 0b0>;
1965 def MVE_VMINAs8 : MVE_VMINMAXA<"vmina", "s8", 0b00, 0b1>;
1966 def MVE_VMINAs16 : MVE_VMINMAXA<"vmina", "s16", 0b01, 0b1>;
1967 def MVE_VMINAs32 : MVE_VMINMAXA<"vmina", "s32", 0b10, 0b1>;
1969 // end of MVE Integer instructions
1971 // start of mve_imm_shift instructions
1973 def MVE_VSHLC : MVE_p<(outs rGPR:$RdmDest, MQPR:$Qd),
1974 (ins MQPR:$QdSrc, rGPR:$RdmSrc, long_shift:$imm),
1975 NoItinerary, "vshlc", "", "$QdSrc, $RdmSrc, $imm",
1976 vpred_n, "$RdmDest = $RdmSrc,$Qd = $QdSrc"> {
1982 let Inst{25-23} = 0b101;
1983 let Inst{22} = Qd{3};
1985 let Inst{20-16} = imm{4-0};
1986 let Inst{15-13} = Qd{2-0};
1987 let Inst{12-4} = 0b011111100;
1988 let Inst{3-0} = RdmDest{3-0};
1991 class MVE_shift_imm<dag oops, dag iops, string iname, string suffix,
1992 string ops, vpred_ops vpred, string cstr,
1993 list<dag> pattern=[]>
1994 : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, pattern> {
1998 let Inst{22} = Qd{3};
1999 let Inst{15-13} = Qd{2-0};
2000 let Inst{5} = Qm{3};
2001 let Inst{3-1} = Qm{2-0};
2004 class MVE_VMOVL<string iname, string suffix, bits<2> sz, bit U,
2005 list<dag> pattern=[]>
2006 : MVE_shift_imm<(outs MQPR:$Qd), (ins MQPR:$Qm),
2007 iname, suffix, "$Qd, $Qm", vpred_r, "",
2010 let Inst{25-23} = 0b101;
2012 let Inst{20-19} = sz{1-0};
2013 let Inst{18-16} = 0b000;
2014 let Inst{11-6} = 0b111101;
2019 multiclass MVE_VMOVL_shift_half<string iname, string suffix, bits<2> sz, bit U,
2020 list<dag> pattern=[]> {
2021 def bh : MVE_VMOVL<!strconcat(iname, "b"), suffix, sz, U, pattern> {
2024 def th : MVE_VMOVL<!strconcat(iname, "t"), suffix, sz, U, pattern> {
2029 defm MVE_VMOVLs8 : MVE_VMOVL_shift_half<"vmovl", "s8", 0b01, 0b0>;
2030 defm MVE_VMOVLu8 : MVE_VMOVL_shift_half<"vmovl", "u8", 0b01, 0b1>;
2031 defm MVE_VMOVLs16 : MVE_VMOVL_shift_half<"vmovl", "s16", 0b10, 0b0>;
2032 defm MVE_VMOVLu16 : MVE_VMOVL_shift_half<"vmovl", "u16", 0b10, 0b1>;
2034 let Predicates = [HasMVEInt] in {
2035 def : Pat<(sext_inreg (v4i32 MQPR:$src), v4i16),
2036 (MVE_VMOVLs16bh MQPR:$src)>;
2037 def : Pat<(sext_inreg (v8i16 MQPR:$src), v8i8),
2038 (MVE_VMOVLs8bh MQPR:$src)>;
2039 def : Pat<(sext_inreg (v4i32 MQPR:$src), v4i8),
2040 (MVE_VMOVLs16bh (MVE_VMOVLs8bh MQPR:$src))>;
2042 // zext_inreg 16 -> 32
2043 def : Pat<(and (v4i32 MQPR:$src), (v4i32 (ARMvmovImm (i32 0xCFF)))),
2044 (MVE_VMOVLu16bh MQPR:$src)>;
2045 // zext_inreg 8 -> 16
2046 def : Pat<(and (v8i16 MQPR:$src), (v8i16 (ARMvmovImm (i32 0x8FF)))),
2047 (MVE_VMOVLu8bh MQPR:$src)>;
2051 class MVE_VSHLL_imm<string iname, string suffix, bit U, bit th,
2052 dag immops, list<dag> pattern=[]>
2053 : MVE_shift_imm<(outs MQPR:$Qd), !con((ins MQPR:$Qm), immops),
2054 iname, suffix, "$Qd, $Qm, $imm", vpred_r, "", pattern> {
2056 let Inst{25-23} = 0b101;
2059 let Inst{11-6} = 0b111101;
2064 // The immediate VSHLL instructions accept shift counts from 1 up to
2065 // the lane width (8 or 16), but the full-width shifts have an
2066 // entirely separate encoding, given below with 'lw' in the name.
2068 class MVE_VSHLL_imm8<string iname, string suffix,
2069 bit U, bit th, list<dag> pattern=[]>
2070 : MVE_VSHLL_imm<iname, suffix, U, th, (ins mve_shift_imm1_7:$imm), pattern> {
2072 let Inst{20-19} = 0b01;
2073 let Inst{18-16} = imm;
2076 class MVE_VSHLL_imm16<string iname, string suffix,
2077 bit U, bit th, list<dag> pattern=[]>
2078 : MVE_VSHLL_imm<iname, suffix, U, th, (ins mve_shift_imm1_15:$imm), pattern> {
2081 let Inst{19-16} = imm;
2084 def MVE_VSHLL_imms8bh : MVE_VSHLL_imm8 <"vshllb", "s8", 0b0, 0b0>;
2085 def MVE_VSHLL_imms8th : MVE_VSHLL_imm8 <"vshllt", "s8", 0b0, 0b1>;
2086 def MVE_VSHLL_immu8bh : MVE_VSHLL_imm8 <"vshllb", "u8", 0b1, 0b0>;
2087 def MVE_VSHLL_immu8th : MVE_VSHLL_imm8 <"vshllt", "u8", 0b1, 0b1>;
2088 def MVE_VSHLL_imms16bh : MVE_VSHLL_imm16<"vshllb", "s16", 0b0, 0b0>;
2089 def MVE_VSHLL_imms16th : MVE_VSHLL_imm16<"vshllt", "s16", 0b0, 0b1>;
2090 def MVE_VSHLL_immu16bh : MVE_VSHLL_imm16<"vshllb", "u16", 0b1, 0b0>;
2091 def MVE_VSHLL_immu16th : MVE_VSHLL_imm16<"vshllt", "u16", 0b1, 0b1>;
2093 class MVE_VSHLL_by_lane_width<string iname, string suffix, bits<2> size,
2094 bit U, string ops, list<dag> pattern=[]>
2095 : MVE_shift_imm<(outs MQPR:$Qd), (ins MQPR:$Qm),
2096 iname, suffix, ops, vpred_r, "", pattern> {
2098 let Inst{25-23} = 0b100;
2099 let Inst{21-20} = 0b11;
2100 let Inst{19-18} = size{1-0};
2101 let Inst{17-16} = 0b01;
2102 let Inst{11-6} = 0b111000;
2107 multiclass MVE_VSHLL_lw<string iname, string suffix, bits<2> sz, bit U,
2108 string ops, list<dag> pattern=[]> {
2109 def bh : MVE_VSHLL_by_lane_width<iname#"b", suffix, sz, U, ops, pattern> {
2112 def th : MVE_VSHLL_by_lane_width<iname#"t", suffix, sz, U, ops, pattern> {
2117 defm MVE_VSHLL_lws8 : MVE_VSHLL_lw<"vshll", "s8", 0b00, 0b0, "$Qd, $Qm, #8">;
2118 defm MVE_VSHLL_lws16 : MVE_VSHLL_lw<"vshll", "s16", 0b01, 0b0, "$Qd, $Qm, #16">;
2119 defm MVE_VSHLL_lwu8 : MVE_VSHLL_lw<"vshll", "u8", 0b00, 0b1, "$Qd, $Qm, #8">;
2120 defm MVE_VSHLL_lwu16 : MVE_VSHLL_lw<"vshll", "u16", 0b01, 0b1, "$Qd, $Qm, #16">;
2122 class MVE_VxSHRN<string iname, string suffix, bit bit_12, bit bit_28,
2123 dag immops, list<dag> pattern=[]>
2124 : MVE_shift_imm<(outs MQPR:$Qd), !con((ins MQPR:$QdSrc, MQPR:$Qm), immops),
2125 iname, suffix, "$Qd, $Qm, $imm", vpred_n, "$Qd = $QdSrc",
2129 let Inst{28} = bit_28;
2130 let Inst{25-23} = 0b101;
2132 let Inst{20-16} = imm{4-0};
2133 let Inst{12} = bit_12;
2134 let Inst{11-6} = 0b111111;
2139 def MVE_VRSHRNi16bh : MVE_VxSHRN<
2140 "vrshrnb", "i16", 0b0, 0b1, (ins shr_imm8:$imm)> {
2141 let Inst{20-19} = 0b01;
2143 def MVE_VRSHRNi16th : MVE_VxSHRN<
2144 "vrshrnt", "i16", 0b1, 0b1,(ins shr_imm8:$imm)> {
2145 let Inst{20-19} = 0b01;
2147 def MVE_VRSHRNi32bh : MVE_VxSHRN<
2148 "vrshrnb", "i32", 0b0, 0b1, (ins shr_imm16:$imm)> {
2151 def MVE_VRSHRNi32th : MVE_VxSHRN<
2152 "vrshrnt", "i32", 0b1, 0b1, (ins shr_imm16:$imm)> {
2156 def MVE_VSHRNi16bh : MVE_VxSHRN<
2157 "vshrnb", "i16", 0b0, 0b0, (ins shr_imm8:$imm)> {
2158 let Inst{20-19} = 0b01;
2160 def MVE_VSHRNi16th : MVE_VxSHRN<
2161 "vshrnt", "i16", 0b1, 0b0, (ins shr_imm8:$imm)> {
2162 let Inst{20-19} = 0b01;
2164 def MVE_VSHRNi32bh : MVE_VxSHRN<
2165 "vshrnb", "i32", 0b0, 0b0, (ins shr_imm16:$imm)> {
2168 def MVE_VSHRNi32th : MVE_VxSHRN<
2169 "vshrnt", "i32", 0b1, 0b0, (ins shr_imm16:$imm)> {
2173 class MVE_VxQRSHRUN<string iname, string suffix, bit bit_28, bit bit_12, dag immops,
2174 list<dag> pattern=[]>
2175 : MVE_shift_imm<(outs MQPR:$Qd), !con((ins MQPR:$QdSrc, MQPR:$Qm), immops),
2176 iname, suffix, "$Qd, $Qm, $imm", vpred_n, "$Qd = $QdSrc",
2180 let Inst{28} = bit_28;
2181 let Inst{25-23} = 0b101;
2183 let Inst{20-16} = imm{4-0};
2184 let Inst{12} = bit_12;
2185 let Inst{11-6} = 0b111111;
2190 def MVE_VQRSHRUNs16bh : MVE_VxQRSHRUN<
2191 "vqrshrunb", "s16", 0b1, 0b0, (ins shr_imm8:$imm)> {
2192 let Inst{20-19} = 0b01;
2194 def MVE_VQRSHRUNs16th : MVE_VxQRSHRUN<
2195 "vqrshrunt", "s16", 0b1, 0b1, (ins shr_imm8:$imm)> {
2196 let Inst{20-19} = 0b01;
2198 def MVE_VQRSHRUNs32bh : MVE_VxQRSHRUN<
2199 "vqrshrunb", "s32", 0b1, 0b0, (ins shr_imm16:$imm)> {
2202 def MVE_VQRSHRUNs32th : MVE_VxQRSHRUN<
2203 "vqrshrunt", "s32", 0b1, 0b1, (ins shr_imm16:$imm)> {
2207 def MVE_VQSHRUNs16bh : MVE_VxQRSHRUN<
2208 "vqshrunb", "s16", 0b0, 0b0, (ins shr_imm8:$imm)> {
2209 let Inst{20-19} = 0b01;
2211 def MVE_VQSHRUNs16th : MVE_VxQRSHRUN<
2212 "vqshrunt", "s16", 0b0, 0b1, (ins shr_imm8:$imm)> {
2213 let Inst{20-19} = 0b01;
2215 def MVE_VQSHRUNs32bh : MVE_VxQRSHRUN<
2216 "vqshrunb", "s32", 0b0, 0b0, (ins shr_imm16:$imm)> {
2219 def MVE_VQSHRUNs32th : MVE_VxQRSHRUN<
2220 "vqshrunt", "s32", 0b0, 0b1, (ins shr_imm16:$imm)> {
2224 class MVE_VxQRSHRN<string iname, string suffix, bit bit_0, bit bit_12,
2225 dag immops, list<dag> pattern=[]>
2226 : MVE_shift_imm<(outs MQPR:$Qd), !con((ins MQPR:$QdSrc, MQPR:$Qm), immops),
2227 iname, suffix, "$Qd, $Qm, $imm", vpred_n, "$Qd = $QdSrc",
2231 let Inst{25-23} = 0b101;
2233 let Inst{20-16} = imm{4-0};
2234 let Inst{12} = bit_12;
2235 let Inst{11-6} = 0b111101;
2237 let Inst{0} = bit_0;
2240 multiclass MVE_VxQRSHRN_types<string iname, bit bit_0, bit bit_12> {
2241 def s16 : MVE_VxQRSHRN<iname, "s16", bit_0, bit_12, (ins shr_imm8:$imm)> {
2243 let Inst{20-19} = 0b01;
2245 def u16 : MVE_VxQRSHRN<iname, "u16", bit_0, bit_12, (ins shr_imm8:$imm)> {
2247 let Inst{20-19} = 0b01;
2249 def s32 : MVE_VxQRSHRN<iname, "s32", bit_0, bit_12, (ins shr_imm16:$imm)> {
2253 def u32 : MVE_VxQRSHRN<iname, "u32", bit_0, bit_12, (ins shr_imm16:$imm)> {
2259 defm MVE_VQRSHRNbh : MVE_VxQRSHRN_types<"vqrshrnb", 0b1, 0b0>;
2260 defm MVE_VQRSHRNth : MVE_VxQRSHRN_types<"vqrshrnt", 0b1, 0b1>;
2261 defm MVE_VQSHRNbh : MVE_VxQRSHRN_types<"vqshrnb", 0b0, 0b0>;
2262 defm MVE_VQSHRNth : MVE_VxQRSHRN_types<"vqshrnt", 0b0, 0b1>;
2264 // end of mve_imm_shift instructions
2266 // start of mve_shift instructions
2268 class MVE_shift_by_vec<string iname, string suffix, bit U,
2269 bits<2> size, bit bit_4, bit bit_8>
2270 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qm, MQPR:$Qn), NoItinerary,
2271 iname, suffix, "$Qd, $Qm, $Qn", vpred_r, "", []> {
2272 // Shift instructions which take a vector of shift counts
2278 let Inst{25-24} = 0b11;
2280 let Inst{22} = Qd{3};
2281 let Inst{21-20} = size;
2282 let Inst{19-17} = Qn{2-0};
2284 let Inst{15-13} = Qd{2-0};
2285 let Inst{12-9} = 0b0010;
2286 let Inst{8} = bit_8;
2287 let Inst{7} = Qn{3};
2289 let Inst{5} = Qm{3};
2290 let Inst{4} = bit_4;
2291 let Inst{3-1} = Qm{2-0};
2293 let validForTailPredication = 1;
2296 multiclass mve_shift_by_vec_multi<string iname, bit bit_4, bit bit_8> {
2297 def s8 : MVE_shift_by_vec<iname, "s8", 0b0, 0b00, bit_4, bit_8>;
2298 def s16 : MVE_shift_by_vec<iname, "s16", 0b0, 0b01, bit_4, bit_8>;
2299 def s32 : MVE_shift_by_vec<iname, "s32", 0b0, 0b10, bit_4, bit_8>;
2300 def u8 : MVE_shift_by_vec<iname, "u8", 0b1, 0b00, bit_4, bit_8>;
2301 def u16 : MVE_shift_by_vec<iname, "u16", 0b1, 0b01, bit_4, bit_8>;
2302 def u32 : MVE_shift_by_vec<iname, "u32", 0b1, 0b10, bit_4, bit_8>;
2305 defm MVE_VSHL_by_vec : mve_shift_by_vec_multi<"vshl", 0b0, 0b0>;
2306 defm MVE_VQSHL_by_vec : mve_shift_by_vec_multi<"vqshl", 0b1, 0b0>;
2307 defm MVE_VQRSHL_by_vec : mve_shift_by_vec_multi<"vqrshl", 0b1, 0b1>;
2308 defm MVE_VRSHL_by_vec : mve_shift_by_vec_multi<"vrshl", 0b0, 0b1>;
2310 let Predicates = [HasMVEInt] in {
2311 def : Pat<(v4i32 (ARMvshlu (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn))),
2312 (v4i32 (MVE_VSHL_by_vecu32 (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn)))>;
2313 def : Pat<(v8i16 (ARMvshlu (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn))),
2314 (v8i16 (MVE_VSHL_by_vecu16 (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn)))>;
2315 def : Pat<(v16i8 (ARMvshlu (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn))),
2316 (v16i8 (MVE_VSHL_by_vecu8 (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn)))>;
2318 def : Pat<(v4i32 (ARMvshls (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn))),
2319 (v4i32 (MVE_VSHL_by_vecs32 (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn)))>;
2320 def : Pat<(v8i16 (ARMvshls (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn))),
2321 (v8i16 (MVE_VSHL_by_vecs16 (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn)))>;
2322 def : Pat<(v16i8 (ARMvshls (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn))),
2323 (v16i8 (MVE_VSHL_by_vecs8 (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn)))>;
2326 class MVE_shift_with_imm<string iname, string suffix, dag oops, dag iops,
2327 string ops, vpred_ops vpred, string cstr,
2328 list<dag> pattern=[]>
2329 : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, pattern> {
2334 let Inst{22} = Qd{3};
2335 let Inst{15-13} = Qd{2-0};
2336 let Inst{12-11} = 0b00;
2337 let Inst{7-6} = 0b01;
2338 let Inst{5} = Qm{3};
2340 let Inst{3-1} = Qm{2-0};
2342 let validForTailPredication = 1;
2345 class MVE_VSxI_imm<string iname, string suffix, bit bit_8, dag imm>
2346 : MVE_shift_with_imm<iname, suffix, (outs MQPR:$Qd),
2347 !con((ins MQPR:$Qd_src, MQPR:$Qm), imm),
2348 "$Qd, $Qm, $imm", vpred_n, "$Qd = $Qd_src"> {
2351 let Inst{25-24} = 0b11;
2352 let Inst{21-16} = imm;
2353 let Inst{10-9} = 0b10;
2354 let Inst{8} = bit_8;
2355 let validForTailPredication = 1;
2358 def MVE_VSRIimm8 : MVE_VSxI_imm<"vsri", "8", 0b0, (ins shr_imm8:$imm)> {
2359 let Inst{21-19} = 0b001;
2362 def MVE_VSRIimm16 : MVE_VSxI_imm<"vsri", "16", 0b0, (ins shr_imm16:$imm)> {
2363 let Inst{21-20} = 0b01;
2366 def MVE_VSRIimm32 : MVE_VSxI_imm<"vsri", "32", 0b0, (ins shr_imm32:$imm)> {
2370 def MVE_VSLIimm8 : MVE_VSxI_imm<"vsli", "8", 0b1, (ins imm0_7:$imm)> {
2371 let Inst{21-19} = 0b001;
2374 def MVE_VSLIimm16 : MVE_VSxI_imm<"vsli", "16", 0b1, (ins imm0_15:$imm)> {
2375 let Inst{21-20} = 0b01;
2378 def MVE_VSLIimm32 : MVE_VSxI_imm<"vsli", "32", 0b1,(ins imm0_31:$imm)> {
2382 class MVE_VQSHL_imm<string suffix, dag imm>
2383 : MVE_shift_with_imm<"vqshl", suffix, (outs MQPR:$Qd),
2384 !con((ins MQPR:$Qm), imm), "$Qd, $Qm, $imm",
2388 let Inst{25-24} = 0b11;
2389 let Inst{21-16} = imm;
2390 let Inst{10-8} = 0b111;
2393 def MVE_VSLIimms8 : MVE_VQSHL_imm<"s8", (ins imm0_7:$imm)> {
2395 let Inst{21-19} = 0b001;
2398 def MVE_VSLIimmu8 : MVE_VQSHL_imm<"u8", (ins imm0_7:$imm)> {
2400 let Inst{21-19} = 0b001;
2403 def MVE_VSLIimms16 : MVE_VQSHL_imm<"s16", (ins imm0_15:$imm)> {
2405 let Inst{21-20} = 0b01;
2408 def MVE_VSLIimmu16 : MVE_VQSHL_imm<"u16", (ins imm0_15:$imm)> {
2410 let Inst{21-20} = 0b01;
2413 def MVE_VSLIimms32 : MVE_VQSHL_imm<"s32", (ins imm0_31:$imm)> {
2418 def MVE_VSLIimmu32 : MVE_VQSHL_imm<"u32", (ins imm0_31:$imm)> {
2423 class MVE_VQSHLU_imm<string suffix, dag imm>
2424 : MVE_shift_with_imm<"vqshlu", suffix, (outs MQPR:$Qd),
2425 !con((ins MQPR:$Qm), imm), "$Qd, $Qm, $imm",
2430 let Inst{25-24} = 0b11;
2431 let Inst{21-16} = imm;
2432 let Inst{10-8} = 0b110;
2435 def MVE_VQSHLU_imms8 : MVE_VQSHLU_imm<"s8", (ins imm0_7:$imm)> {
2436 let Inst{21-19} = 0b001;
2439 def MVE_VQSHLU_imms16 : MVE_VQSHLU_imm<"s16", (ins imm0_15:$imm)> {
2440 let Inst{21-20} = 0b01;
2443 def MVE_VQSHLU_imms32 : MVE_VQSHLU_imm<"s32", (ins imm0_31:$imm)> {
2447 class MVE_VRSHR_imm<string suffix, dag imm>
2448 : MVE_shift_with_imm<"vrshr", suffix, (outs MQPR:$Qd),
2449 !con((ins MQPR:$Qm), imm), "$Qd, $Qm, $imm",
2453 let Inst{25-24} = 0b11;
2454 let Inst{21-16} = imm;
2455 let Inst{10-8} = 0b010;
2458 def MVE_VRSHR_imms8 : MVE_VRSHR_imm<"s8", (ins shr_imm8:$imm)> {
2460 let Inst{21-19} = 0b001;
2463 def MVE_VRSHR_immu8 : MVE_VRSHR_imm<"u8", (ins shr_imm8:$imm)> {
2465 let Inst{21-19} = 0b001;
2468 def MVE_VRSHR_imms16 : MVE_VRSHR_imm<"s16", (ins shr_imm16:$imm)> {
2470 let Inst{21-20} = 0b01;
2473 def MVE_VRSHR_immu16 : MVE_VRSHR_imm<"u16", (ins shr_imm16:$imm)> {
2475 let Inst{21-20} = 0b01;
2478 def MVE_VRSHR_imms32 : MVE_VRSHR_imm<"s32", (ins shr_imm32:$imm)> {
2483 def MVE_VRSHR_immu32 : MVE_VRSHR_imm<"u32", (ins shr_imm32:$imm)> {
2488 class MVE_VSHR_imm<string suffix, dag imm>
2489 : MVE_shift_with_imm<"vshr", suffix, (outs MQPR:$Qd),
2490 !con((ins MQPR:$Qm), imm), "$Qd, $Qm, $imm",
2494 let Inst{25-24} = 0b11;
2495 let Inst{21-16} = imm;
2496 let Inst{10-8} = 0b000;
2499 def MVE_VSHR_imms8 : MVE_VSHR_imm<"s8", (ins shr_imm8:$imm)> {
2501 let Inst{21-19} = 0b001;
2504 def MVE_VSHR_immu8 : MVE_VSHR_imm<"u8", (ins shr_imm8:$imm)> {
2506 let Inst{21-19} = 0b001;
2509 def MVE_VSHR_imms16 : MVE_VSHR_imm<"s16", (ins shr_imm16:$imm)> {
2511 let Inst{21-20} = 0b01;
2514 def MVE_VSHR_immu16 : MVE_VSHR_imm<"u16", (ins shr_imm16:$imm)> {
2516 let Inst{21-20} = 0b01;
2519 def MVE_VSHR_imms32 : MVE_VSHR_imm<"s32", (ins shr_imm32:$imm)> {
2524 def MVE_VSHR_immu32 : MVE_VSHR_imm<"u32", (ins shr_imm32:$imm)> {
2529 class MVE_VSHL_imm<string suffix, dag imm>
2530 : MVE_shift_with_imm<"vshl", suffix, (outs MQPR:$Qd),
2531 !con((ins MQPR:$Qm), imm), "$Qd, $Qm, $imm",
2536 let Inst{25-24} = 0b11;
2537 let Inst{21-16} = imm;
2538 let Inst{10-8} = 0b101;
2541 def MVE_VSHL_immi8 : MVE_VSHL_imm<"i8", (ins imm0_7:$imm)> {
2542 let Inst{21-19} = 0b001;
2545 def MVE_VSHL_immi16 : MVE_VSHL_imm<"i16", (ins imm0_15:$imm)> {
2546 let Inst{21-20} = 0b01;
2549 def MVE_VSHL_immi32 : MVE_VSHL_imm<"i32", (ins imm0_31:$imm)> {
2553 let Predicates = [HasMVEInt] in {
2554 def : Pat<(v4i32 (ARMvshlImm (v4i32 MQPR:$src), imm0_31:$imm)),
2555 (v4i32 (MVE_VSHL_immi32 (v4i32 MQPR:$src), imm0_31:$imm))>;
2556 def : Pat<(v8i16 (ARMvshlImm (v8i16 MQPR:$src), imm0_15:$imm)),
2557 (v8i16 (MVE_VSHL_immi16 (v8i16 MQPR:$src), imm0_15:$imm))>;
2558 def : Pat<(v16i8 (ARMvshlImm (v16i8 MQPR:$src), imm0_7:$imm)),
2559 (v16i8 (MVE_VSHL_immi8 (v16i8 MQPR:$src), imm0_7:$imm))>;
2561 def : Pat<(v4i32 (ARMvshruImm (v4i32 MQPR:$src), imm0_31:$imm)),
2562 (v4i32 (MVE_VSHR_immu32 (v4i32 MQPR:$src), imm0_31:$imm))>;
2563 def : Pat<(v8i16 (ARMvshruImm (v8i16 MQPR:$src), imm0_15:$imm)),
2564 (v8i16 (MVE_VSHR_immu16 (v8i16 MQPR:$src), imm0_15:$imm))>;
2565 def : Pat<(v16i8 (ARMvshruImm (v16i8 MQPR:$src), imm0_7:$imm)),
2566 (v16i8 (MVE_VSHR_immu8 (v16i8 MQPR:$src), imm0_7:$imm))>;
2568 def : Pat<(v4i32 (ARMvshrsImm (v4i32 MQPR:$src), imm0_31:$imm)),
2569 (v4i32 (MVE_VSHR_imms32 (v4i32 MQPR:$src), imm0_31:$imm))>;
2570 def : Pat<(v8i16 (ARMvshrsImm (v8i16 MQPR:$src), imm0_15:$imm)),
2571 (v8i16 (MVE_VSHR_imms16 (v8i16 MQPR:$src), imm0_15:$imm))>;
2572 def : Pat<(v16i8 (ARMvshrsImm (v16i8 MQPR:$src), imm0_7:$imm)),
2573 (v16i8 (MVE_VSHR_imms8 (v16i8 MQPR:$src), imm0_7:$imm))>;
2576 // end of mve_shift instructions
2578 // start of MVE Floating Point instructions
2580 class MVE_float<string iname, string suffix, dag oops, dag iops, string ops,
2581 vpred_ops vpred, string cstr, list<dag> pattern=[]>
2582 : MVE_f<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, pattern> {
2587 let Inst{5} = Qm{3};
2588 let Inst{3-1} = Qm{2-0};
2592 class MVE_VRINT<string rmode, bits<3> op, string suffix, bits<2> size,
2593 list<dag> pattern=[]>
2594 : MVE_float<!strconcat("vrint", rmode), suffix, (outs MQPR:$Qd),
2595 (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", pattern> {
2599 let Inst{25-23} = 0b111;
2600 let Inst{22} = Qd{3};
2601 let Inst{21-20} = 0b11;
2602 let Inst{19-18} = size;
2603 let Inst{17-16} = 0b10;
2604 let Inst{15-13} = Qd{2-0};
2605 let Inst{11-10} = 0b01;
2606 let Inst{9-7} = op{2-0};
2608 let validForTailPredication = 1;
2612 multiclass MVE_VRINT_ops<string suffix, bits<2> size, list<dag> pattern=[]> {
2613 def N : MVE_VRINT<"n", 0b000, suffix, size, pattern>;
2614 def X : MVE_VRINT<"x", 0b001, suffix, size, pattern>;
2615 def A : MVE_VRINT<"a", 0b010, suffix, size, pattern>;
2616 def Z : MVE_VRINT<"z", 0b011, suffix, size, pattern>;
2617 def M : MVE_VRINT<"m", 0b101, suffix, size, pattern>;
2618 def P : MVE_VRINT<"p", 0b111, suffix, size, pattern>;
2621 defm MVE_VRINTf16 : MVE_VRINT_ops<"f16", 0b01>;
2622 defm MVE_VRINTf32 : MVE_VRINT_ops<"f32", 0b10>;
2624 let Predicates = [HasMVEFloat] in {
2625 def : Pat<(v4f32 (frint (v4f32 MQPR:$val1))),
2626 (v4f32 (MVE_VRINTf32X (v4f32 MQPR:$val1)))>;
2627 def : Pat<(v8f16 (frint (v8f16 MQPR:$val1))),
2628 (v8f16 (MVE_VRINTf16X (v8f16 MQPR:$val1)))>;
2629 def : Pat<(v4f32 (fround (v4f32 MQPR:$val1))),
2630 (v4f32 (MVE_VRINTf32A (v4f32 MQPR:$val1)))>;
2631 def : Pat<(v8f16 (fround (v8f16 MQPR:$val1))),
2632 (v8f16 (MVE_VRINTf16A (v8f16 MQPR:$val1)))>;
2633 def : Pat<(v4f32 (ftrunc (v4f32 MQPR:$val1))),
2634 (v4f32 (MVE_VRINTf32Z (v4f32 MQPR:$val1)))>;
2635 def : Pat<(v8f16 (ftrunc (v8f16 MQPR:$val1))),
2636 (v8f16 (MVE_VRINTf16Z (v8f16 MQPR:$val1)))>;
2637 def : Pat<(v4f32 (ffloor (v4f32 MQPR:$val1))),
2638 (v4f32 (MVE_VRINTf32M (v4f32 MQPR:$val1)))>;
2639 def : Pat<(v8f16 (ffloor (v8f16 MQPR:$val1))),
2640 (v8f16 (MVE_VRINTf16M (v8f16 MQPR:$val1)))>;
2641 def : Pat<(v4f32 (fceil (v4f32 MQPR:$val1))),
2642 (v4f32 (MVE_VRINTf32P (v4f32 MQPR:$val1)))>;
2643 def : Pat<(v8f16 (fceil (v8f16 MQPR:$val1))),
2644 (v8f16 (MVE_VRINTf16P (v8f16 MQPR:$val1)))>;
2647 class MVEFloatArithNeon<string iname, string suffix, bit size,
2648 dag oops, dag iops, string ops,
2649 vpred_ops vpred, string cstr, list<dag> pattern=[]>
2650 : MVE_float<iname, suffix, oops, iops, ops, vpred, cstr, pattern> {
2651 let Inst{20} = size;
2655 class MVE_VMUL_fp<string suffix, bit size, list<dag> pattern=[]>
2656 : MVEFloatArithNeon<"vmul", suffix, size, (outs MQPR:$Qd),
2657 (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm", vpred_r, "",
2663 let Inst{25-23} = 0b110;
2664 let Inst{22} = Qd{3};
2666 let Inst{19-17} = Qn{2-0};
2667 let Inst{15-13} = Qd{2-0};
2668 let Inst{12-8} = 0b01101;
2669 let Inst{7} = Qn{3};
2671 let validForTailPredication = 1;
2674 def MVE_VMULf32 : MVE_VMUL_fp<"f32", 0b0>;
2675 def MVE_VMULf16 : MVE_VMUL_fp<"f16", 0b1>;
2677 let Predicates = [HasMVEFloat] in {
2678 def : Pat<(v4f32 (fmul (v4f32 MQPR:$val1), (v4f32 MQPR:$val2))),
2679 (v4f32 (MVE_VMULf32 (v4f32 MQPR:$val1), (v4f32 MQPR:$val2)))>;
2680 def : Pat<(v8f16 (fmul (v8f16 MQPR:$val1), (v8f16 MQPR:$val2))),
2681 (v8f16 (MVE_VMULf16 (v8f16 MQPR:$val1), (v8f16 MQPR:$val2)))>;
2684 class MVE_VCMLA<string suffix, bit size, list<dag> pattern=[]>
2685 : MVEFloatArithNeon<"vcmla", suffix, size, (outs MQPR:$Qd),
2686 (ins MQPR:$Qd_src, MQPR:$Qn, MQPR:$Qm, complexrotateop:$rot),
2687 "$Qd, $Qn, $Qm, $rot", vpred_n, "$Qd = $Qd_src", pattern> {
2694 let Inst{24-23} = rot;
2695 let Inst{22} = Qd{3};
2697 let Inst{19-17} = Qn{2-0};
2698 let Inst{15-13} = Qd{2-0};
2699 let Inst{12-8} = 0b01000;
2700 let Inst{7} = Qn{3};
2704 def MVE_VCMLAf16 : MVE_VCMLA<"f16", 0b0>;
2705 def MVE_VCMLAf32 : MVE_VCMLA<"f32", 0b1>;
2707 class MVE_VADDSUBFMA_fp<string iname, string suffix, bit size, bit bit_4,
2708 bit bit_8, bit bit_21, dag iops=(ins),
2709 vpred_ops vpred=vpred_r, string cstr="",
2710 list<dag> pattern=[]>
2711 : MVEFloatArithNeon<iname, suffix, size, (outs MQPR:$Qd),
2712 !con(iops, (ins MQPR:$Qn, MQPR:$Qm)), "$Qd, $Qn, $Qm",
2713 vpred, cstr, pattern> {
2718 let Inst{25-23} = 0b110;
2719 let Inst{22} = Qd{3};
2720 let Inst{21} = bit_21;
2721 let Inst{19-17} = Qn{2-0};
2722 let Inst{15-13} = Qd{2-0};
2723 let Inst{11-9} = 0b110;
2724 let Inst{8} = bit_8;
2725 let Inst{7} = Qn{3};
2726 let Inst{4} = bit_4;
2729 def MVE_VFMAf32 : MVE_VADDSUBFMA_fp<"vfma", "f32", 0b0, 0b1, 0b0, 0b0,
2730 (ins MQPR:$Qd_src), vpred_n, "$Qd = $Qd_src">;
2731 def MVE_VFMAf16 : MVE_VADDSUBFMA_fp<"vfma", "f16", 0b1, 0b1, 0b0, 0b0,
2732 (ins MQPR:$Qd_src), vpred_n, "$Qd = $Qd_src">;
2734 def MVE_VFMSf32 : MVE_VADDSUBFMA_fp<"vfms", "f32", 0b0, 0b1, 0b0, 0b1,
2735 (ins MQPR:$Qd_src), vpred_n, "$Qd = $Qd_src">;
2736 def MVE_VFMSf16 : MVE_VADDSUBFMA_fp<"vfms", "f16", 0b1, 0b1, 0b0, 0b1,
2737 (ins MQPR:$Qd_src), vpred_n, "$Qd = $Qd_src">;
2739 let Predicates = [HasMVEFloat, UseFusedMAC] in {
2740 def : Pat<(v8f16 (fadd (v8f16 MQPR:$src1),
2741 (fmul (v8f16 MQPR:$src2),
2742 (v8f16 MQPR:$src3)))),
2743 (v8f16 (MVE_VFMAf16 $src1, $src2, $src3))>;
2744 def : Pat<(v4f32 (fadd (v4f32 MQPR:$src1),
2745 (fmul (v4f32 MQPR:$src2),
2746 (v4f32 MQPR:$src3)))),
2747 (v4f32 (MVE_VFMAf32 $src1, $src2, $src3))>;
2749 def : Pat<(v8f16 (fsub (v8f16 MQPR:$src1),
2750 (fmul (v8f16 MQPR:$src2),
2751 (v8f16 MQPR:$src3)))),
2752 (v8f16 (MVE_VFMSf16 $src1, $src2, $src3))>;
2753 def : Pat<(v4f32 (fsub (v4f32 MQPR:$src1),
2754 (fmul (v4f32 MQPR:$src2),
2755 (v4f32 MQPR:$src3)))),
2756 (v4f32 (MVE_VFMSf32 $src1, $src2, $src3))>;
2759 let Predicates = [HasMVEFloat] in {
2760 def : Pat<(v8f16 (fma (v8f16 MQPR:$src1), (v8f16 MQPR:$src2), (v8f16 MQPR:$src3))),
2761 (v8f16 (MVE_VFMAf16 $src3, $src1, $src2))>;
2762 def : Pat<(v4f32 (fma (v4f32 MQPR:$src1), (v4f32 MQPR:$src2), (v4f32 MQPR:$src3))),
2763 (v4f32 (MVE_VFMAf32 $src3, $src1, $src2))>;
2767 let validForTailPredication = 1 in {
2768 def MVE_VADDf32 : MVE_VADDSUBFMA_fp<"vadd", "f32", 0b0, 0b0, 0b1, 0b0>;
2769 def MVE_VADDf16 : MVE_VADDSUBFMA_fp<"vadd", "f16", 0b1, 0b0, 0b1, 0b0>;
2772 let Predicates = [HasMVEFloat] in {
2773 def : Pat<(v4f32 (fadd (v4f32 MQPR:$val1), (v4f32 MQPR:$val2))),
2774 (v4f32 (MVE_VADDf32 (v4f32 MQPR:$val1), (v4f32 MQPR:$val2)))>;
2775 def : Pat<(v8f16 (fadd (v8f16 MQPR:$val1), (v8f16 MQPR:$val2))),
2776 (v8f16 (MVE_VADDf16 (v8f16 MQPR:$val1), (v8f16 MQPR:$val2)))>;
2780 let validForTailPredication = 1 in {
2781 def MVE_VSUBf32 : MVE_VADDSUBFMA_fp<"vsub", "f32", 0b0, 0b0, 0b1, 0b1>;
2782 def MVE_VSUBf16 : MVE_VADDSUBFMA_fp<"vsub", "f16", 0b1, 0b0, 0b1, 0b1>;
2785 let Predicates = [HasMVEFloat] in {
2786 def : Pat<(v4f32 (fsub (v4f32 MQPR:$val1), (v4f32 MQPR:$val2))),
2787 (v4f32 (MVE_VSUBf32 (v4f32 MQPR:$val1), (v4f32 MQPR:$val2)))>;
2788 def : Pat<(v8f16 (fsub (v8f16 MQPR:$val1), (v8f16 MQPR:$val2))),
2789 (v8f16 (MVE_VSUBf16 (v8f16 MQPR:$val1), (v8f16 MQPR:$val2)))>;
2792 class MVE_VCADD<string suffix, bit size, string cstr="", list<dag> pattern=[]>
2793 : MVEFloatArithNeon<"vcadd", suffix, size, (outs MQPR:$Qd),
2794 (ins MQPR:$Qn, MQPR:$Qm, complexrotateopodd:$rot),
2795 "$Qd, $Qn, $Qm, $rot", vpred_r, cstr, pattern> {
2804 let Inst{22} = Qd{3};
2806 let Inst{19-17} = Qn{2-0};
2807 let Inst{15-13} = Qd{2-0};
2808 let Inst{12-8} = 0b01000;
2809 let Inst{7} = Qn{3};
2813 def MVE_VCADDf16 : MVE_VCADD<"f16", 0b0>;
2814 def MVE_VCADDf32 : MVE_VCADD<"f32", 0b1, "@earlyclobber $Qd">;
2816 class MVE_VABD_fp<string suffix, bit size>
2817 : MVE_float<"vabd", suffix, (outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm),
2818 "$Qd, $Qn, $Qm", vpred_r, ""> {
2823 let Inst{25-23} = 0b110;
2824 let Inst{22} = Qd{3};
2826 let Inst{20} = size;
2827 let Inst{19-17} = Qn{2-0};
2829 let Inst{15-13} = Qd{2-0};
2830 let Inst{11-8} = 0b1101;
2831 let Inst{7} = Qn{3};
2833 let validForTailPredication = 1;
2836 def MVE_VABDf32 : MVE_VABD_fp<"f32", 0b0>;
2837 def MVE_VABDf16 : MVE_VABD_fp<"f16", 0b1>;
2839 class MVE_VCVT_fix<string suffix, bit fsi, bit U, bit op,
2840 Operand imm_operand_type, list<dag> pattern=[]>
2841 : MVE_float<"vcvt", suffix,
2842 (outs MQPR:$Qd), (ins MQPR:$Qm, imm_operand_type:$imm6),
2843 "$Qd, $Qm, $imm6", vpred_r, "", pattern> {
2848 let Inst{25-23} = 0b111;
2849 let Inst{22} = Qd{3};
2851 let Inst{19-16} = imm6{3-0};
2852 let Inst{15-13} = Qd{2-0};
2853 let Inst{11-10} = 0b11;
2859 let DecoderMethod = "DecodeMVEVCVTt1fp";
2860 let validForTailPredication = 1;
2863 class MVE_VCVT_imm_asmop<int Bits> : AsmOperandClass {
2864 let PredicateMethod = "isImmediate<1," # Bits # ">";
2865 let DiagnosticString =
2866 "MVE fixed-point immediate operand must be between 1 and " # Bits;
2867 let Name = "MVEVcvtImm" # Bits;
2868 let RenderMethod = "addImmOperands";
2870 class MVE_VCVT_imm<int Bits>: Operand<i32> {
2871 let ParserMatchClass = MVE_VCVT_imm_asmop<Bits>;
2872 let EncoderMethod = "getNEONVcvtImm32OpValue";
2873 let DecoderMethod = "DecodeVCVTImmOperand";
2876 class MVE_VCVT_fix_f32<string suffix, bit U, bit op>
2877 : MVE_VCVT_fix<suffix, 0b1, U, op, MVE_VCVT_imm<32>> {
2878 let Inst{20} = imm6{4};
2880 class MVE_VCVT_fix_f16<string suffix, bit U, bit op>
2881 : MVE_VCVT_fix<suffix, 0b0, U, op, MVE_VCVT_imm<16>> {
2885 def MVE_VCVTf16s16_fix : MVE_VCVT_fix_f16<"f16.s16", 0b0, 0b0>;
2886 def MVE_VCVTs16f16_fix : MVE_VCVT_fix_f16<"s16.f16", 0b0, 0b1>;
2887 def MVE_VCVTf16u16_fix : MVE_VCVT_fix_f16<"f16.u16", 0b1, 0b0>;
2888 def MVE_VCVTu16f16_fix : MVE_VCVT_fix_f16<"u16.f16", 0b1, 0b1>;
2889 def MVE_VCVTf32s32_fix : MVE_VCVT_fix_f32<"f32.s32", 0b0, 0b0>;
2890 def MVE_VCVTs32f32_fix : MVE_VCVT_fix_f32<"s32.f32", 0b0, 0b1>;
2891 def MVE_VCVTf32u32_fix : MVE_VCVT_fix_f32<"f32.u32", 0b1, 0b0>;
2892 def MVE_VCVTu32f32_fix : MVE_VCVT_fix_f32<"u32.f32", 0b1, 0b1>;
2894 class MVE_VCVT_fp_int_anpm<string suffix, bits<2> size, bit op, string anpm,
2895 bits<2> rm, list<dag> pattern=[]>
2896 : MVE_float<!strconcat("vcvt", anpm), suffix, (outs MQPR:$Qd),
2897 (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", pattern> {
2901 let Inst{25-23} = 0b111;
2902 let Inst{22} = Qd{3};
2903 let Inst{21-20} = 0b11;
2904 let Inst{19-18} = size;
2905 let Inst{17-16} = 0b11;
2906 let Inst{15-13} = Qd{2-0};
2907 let Inst{12-10} = 0b000;
2911 let validForTailPredication = 1;
2914 multiclass MVE_VCVT_fp_int_anpm_multi<string suffix, bits<2> size, bit op,
2915 list<dag> pattern=[]> {
2916 def a : MVE_VCVT_fp_int_anpm<suffix, size, op, "a", 0b00>;
2917 def n : MVE_VCVT_fp_int_anpm<suffix, size, op, "n", 0b01>;
2918 def p : MVE_VCVT_fp_int_anpm<suffix, size, op, "p", 0b10>;
2919 def m : MVE_VCVT_fp_int_anpm<suffix, size, op, "m", 0b11>;
2922 // This defines instructions such as MVE_VCVTu16f16a, with an explicit
2923 // rounding-mode suffix on the mnemonic. The class below will define
2924 // the bare MVE_VCVTu16f16 (with implied rounding toward zero).
2925 defm MVE_VCVTs16f16 : MVE_VCVT_fp_int_anpm_multi<"s16.f16", 0b01, 0b0>;
2926 defm MVE_VCVTu16f16 : MVE_VCVT_fp_int_anpm_multi<"u16.f16", 0b01, 0b1>;
2927 defm MVE_VCVTs32f32 : MVE_VCVT_fp_int_anpm_multi<"s32.f32", 0b10, 0b0>;
2928 defm MVE_VCVTu32f32 : MVE_VCVT_fp_int_anpm_multi<"u32.f32", 0b10, 0b1>;
2930 class MVE_VCVT_fp_int<string suffix, bits<2> size, bits<2> op,
2931 list<dag> pattern=[]>
2932 : MVE_float<"vcvt", suffix, (outs MQPR:$Qd),
2933 (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", pattern> {
2937 let Inst{25-23} = 0b111;
2938 let Inst{22} = Qd{3};
2939 let Inst{21-20} = 0b11;
2940 let Inst{19-18} = size;
2941 let Inst{17-16} = 0b11;
2942 let Inst{15-13} = Qd{2-0};
2943 let Inst{12-9} = 0b0011;
2946 let validForTailPredication = 1;
2949 // The unsuffixed VCVT for float->int implicitly rounds toward zero,
2950 // which I reflect here in the llvm instruction names
2951 def MVE_VCVTs16f16z : MVE_VCVT_fp_int<"s16.f16", 0b01, 0b10>;
2952 def MVE_VCVTu16f16z : MVE_VCVT_fp_int<"u16.f16", 0b01, 0b11>;
2953 def MVE_VCVTs32f32z : MVE_VCVT_fp_int<"s32.f32", 0b10, 0b10>;
2954 def MVE_VCVTu32f32z : MVE_VCVT_fp_int<"u32.f32", 0b10, 0b11>;
2955 // Whereas VCVT for int->float rounds to nearest
2956 def MVE_VCVTf16s16n : MVE_VCVT_fp_int<"f16.s16", 0b01, 0b00>;
2957 def MVE_VCVTf16u16n : MVE_VCVT_fp_int<"f16.u16", 0b01, 0b01>;
2958 def MVE_VCVTf32s32n : MVE_VCVT_fp_int<"f32.s32", 0b10, 0b00>;
2959 def MVE_VCVTf32u32n : MVE_VCVT_fp_int<"f32.u32", 0b10, 0b01>;
2961 let Predicates = [HasMVEFloat] in {
2962 def : Pat<(v4i32 (fp_to_sint (v4f32 MQPR:$src))),
2963 (v4i32 (MVE_VCVTs32f32z (v4f32 MQPR:$src)))>;
2964 def : Pat<(v4i32 (fp_to_uint (v4f32 MQPR:$src))),
2965 (v4i32 (MVE_VCVTu32f32z (v4f32 MQPR:$src)))>;
2966 def : Pat<(v8i16 (fp_to_sint (v8f16 MQPR:$src))),
2967 (v8i16 (MVE_VCVTs16f16z (v8f16 MQPR:$src)))>;
2968 def : Pat<(v8i16 (fp_to_uint (v8f16 MQPR:$src))),
2969 (v8i16 (MVE_VCVTu16f16z (v8f16 MQPR:$src)))>;
2970 def : Pat<(v4f32 (sint_to_fp (v4i32 MQPR:$src))),
2971 (v4f32 (MVE_VCVTf32s32n (v4i32 MQPR:$src)))>;
2972 def : Pat<(v4f32 (uint_to_fp (v4i32 MQPR:$src))),
2973 (v4f32 (MVE_VCVTf32u32n (v4i32 MQPR:$src)))>;
2974 def : Pat<(v8f16 (sint_to_fp (v8i16 MQPR:$src))),
2975 (v8f16 (MVE_VCVTf16s16n (v8i16 MQPR:$src)))>;
2976 def : Pat<(v8f16 (uint_to_fp (v8i16 MQPR:$src))),
2977 (v8f16 (MVE_VCVTf16u16n (v8i16 MQPR:$src)))>;
2980 class MVE_VABSNEG_fp<string iname, string suffix, bits<2> size, bit negate,
2981 list<dag> pattern=[]>
2982 : MVE_float<iname, suffix, (outs MQPR:$Qd),
2983 (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", pattern> {
2987 let Inst{25-23} = 0b111;
2988 let Inst{22} = Qd{3};
2989 let Inst{21-20} = 0b11;
2990 let Inst{19-18} = size;
2991 let Inst{17-16} = 0b01;
2992 let Inst{15-13} = Qd{2-0};
2993 let Inst{11-8} = 0b0111;
2994 let Inst{7} = negate;
2996 let validForTailPredication = 1;
2999 def MVE_VABSf16 : MVE_VABSNEG_fp<"vabs", "f16", 0b01, 0b0>;
3000 def MVE_VABSf32 : MVE_VABSNEG_fp<"vabs", "f32", 0b10, 0b0>;
3002 let Predicates = [HasMVEFloat] in {
3003 def : Pat<(v8f16 (fabs MQPR:$src)),
3004 (MVE_VABSf16 MQPR:$src)>;
3005 def : Pat<(v4f32 (fabs MQPR:$src)),
3006 (MVE_VABSf32 MQPR:$src)>;
3009 def MVE_VNEGf16 : MVE_VABSNEG_fp<"vneg", "f16", 0b01, 0b1>;
3010 def MVE_VNEGf32 : MVE_VABSNEG_fp<"vneg", "f32", 0b10, 0b1>;
3012 let Predicates = [HasMVEFloat] in {
3013 def : Pat<(v8f16 (fneg MQPR:$src)),
3014 (MVE_VNEGf16 MQPR:$src)>;
3015 def : Pat<(v4f32 (fneg MQPR:$src)),
3016 (MVE_VNEGf32 MQPR:$src)>;
3019 class MVE_VMAXMINNMA<string iname, string suffix, bit size, bit bit_12,
3020 list<dag> pattern=[]>
3021 : MVE_f<(outs MQPR:$Qd), (ins MQPR:$Qd_src, MQPR:$Qm),
3022 NoItinerary, iname, suffix, "$Qd, $Qm", vpred_n, "$Qd = $Qd_src",
3027 let Inst{28} = size;
3028 let Inst{25-23} = 0b100;
3029 let Inst{22} = Qd{3};
3030 let Inst{21-16} = 0b111111;
3031 let Inst{15-13} = Qd{2-0};
3032 let Inst{12} = bit_12;
3033 let Inst{11-6} = 0b111010;
3034 let Inst{5} = Qm{3};
3036 let Inst{3-1} = Qm{2-0};
3040 def MVE_VMAXNMAf32 : MVE_VMAXMINNMA<"vmaxnma", "f32", 0b0, 0b0>;
3041 def MVE_VMAXNMAf16 : MVE_VMAXMINNMA<"vmaxnma", "f16", 0b1, 0b0>;
3043 def MVE_VMINNMAf32 : MVE_VMAXMINNMA<"vminnma", "f32", 0b0, 0b1>;
3044 def MVE_VMINNMAf16 : MVE_VMAXMINNMA<"vminnma", "f16", 0b1, 0b1>;
3046 // end of MVE Floating Point instructions
3048 // start of MVE compares
3050 class MVE_VCMPqq<string suffix, bit bit_28, bits<2> bits_21_20,
3051 VCMPPredicateOperand predtype, list<dag> pattern=[]>
3052 : MVE_p<(outs VCCR:$P0), (ins MQPR:$Qn, MQPR:$Qm, predtype:$fc),
3053 NoItinerary, "vcmp", suffix, "$fc, $Qn, $Qm", vpred_n, "", pattern> {
3054 // Base class for comparing two vector registers
3059 let Inst{28} = bit_28;
3060 let Inst{25-22} = 0b1000;
3061 let Inst{21-20} = bits_21_20;
3062 let Inst{19-17} = Qn{2-0};
3063 let Inst{16-13} = 0b1000;
3064 let Inst{12} = fc{2};
3065 let Inst{11-8} = 0b1111;
3066 let Inst{7} = fc{0};
3068 let Inst{5} = Qm{3};
3070 let Inst{3-1} = Qm{2-0};
3071 let Inst{0} = fc{1};
3073 let Constraints = "";
3075 // We need a custom decoder method for these instructions because of
3076 // the output VCCR operand, which isn't encoded in the instruction
3077 // bits anywhere (there is only one choice for it) but has to be
3078 // included in the MC operands so that codegen will be able to track
3079 // its data flow between instructions, spill/reload it when
3080 // necessary, etc. There seems to be no way to get the Tablegen
3081 // decoder to emit an operand that isn't affected by any instruction
3083 let DecoderMethod = "DecodeMVEVCMP<false," # predtype.DecoderMethod # ">";
3084 let validForTailPredication = 1;
3087 class MVE_VCMPqqf<string suffix, bit size>
3088 : MVE_VCMPqq<suffix, size, 0b11, pred_basic_fp> {
3089 let Predicates = [HasMVEFloat];
3092 class MVE_VCMPqqi<string suffix, bits<2> size>
3093 : MVE_VCMPqq<suffix, 0b1, size, pred_basic_i> {
3098 class MVE_VCMPqqu<string suffix, bits<2> size>
3099 : MVE_VCMPqq<suffix, 0b1, size, pred_basic_u> {
3104 class MVE_VCMPqqs<string suffix, bits<2> size>
3105 : MVE_VCMPqq<suffix, 0b1, size, pred_basic_s> {
3109 def MVE_VCMPf32 : MVE_VCMPqqf<"f32", 0b0>;
3110 def MVE_VCMPf16 : MVE_VCMPqqf<"f16", 0b1>;
3112 def MVE_VCMPi8 : MVE_VCMPqqi<"i8", 0b00>;
3113 def MVE_VCMPi16 : MVE_VCMPqqi<"i16", 0b01>;
3114 def MVE_VCMPi32 : MVE_VCMPqqi<"i32", 0b10>;
3116 def MVE_VCMPu8 : MVE_VCMPqqu<"u8", 0b00>;
3117 def MVE_VCMPu16 : MVE_VCMPqqu<"u16", 0b01>;
3118 def MVE_VCMPu32 : MVE_VCMPqqu<"u32", 0b10>;
3120 def MVE_VCMPs8 : MVE_VCMPqqs<"s8", 0b00>;
3121 def MVE_VCMPs16 : MVE_VCMPqqs<"s16", 0b01>;
3122 def MVE_VCMPs32 : MVE_VCMPqqs<"s32", 0b10>;
3124 class MVE_VCMPqr<string suffix, bit bit_28, bits<2> bits_21_20,
3125 VCMPPredicateOperand predtype, list<dag> pattern=[]>
3126 : MVE_p<(outs VCCR:$P0), (ins MQPR:$Qn, GPRwithZR:$Rm, predtype:$fc),
3127 NoItinerary, "vcmp", suffix, "$fc, $Qn, $Rm", vpred_n, "", pattern> {
3128 // Base class for comparing a vector register with a scalar
3133 let Inst{28} = bit_28;
3134 let Inst{25-22} = 0b1000;
3135 let Inst{21-20} = bits_21_20;
3136 let Inst{19-17} = Qn{2-0};
3137 let Inst{16-13} = 0b1000;
3138 let Inst{12} = fc{2};
3139 let Inst{11-8} = 0b1111;
3140 let Inst{7} = fc{0};
3142 let Inst{5} = fc{1};
3144 let Inst{3-0} = Rm{3-0};
3146 let Constraints = "";
3147 // Custom decoder method, for the same reason as MVE_VCMPqq
3148 let DecoderMethod = "DecodeMVEVCMP<true," # predtype.DecoderMethod # ">";
3149 let validForTailPredication = 1;
3152 class MVE_VCMPqrf<string suffix, bit size>
3153 : MVE_VCMPqr<suffix, size, 0b11, pred_basic_fp> {
3154 let Predicates = [HasMVEFloat];
3157 class MVE_VCMPqri<string suffix, bits<2> size>
3158 : MVE_VCMPqr<suffix, 0b1, size, pred_basic_i> {
3163 class MVE_VCMPqru<string suffix, bits<2> size>
3164 : MVE_VCMPqr<suffix, 0b1, size, pred_basic_u> {
3169 class MVE_VCMPqrs<string suffix, bits<2> size>
3170 : MVE_VCMPqr<suffix, 0b1, size, pred_basic_s> {
3174 def MVE_VCMPf32r : MVE_VCMPqrf<"f32", 0b0>;
3175 def MVE_VCMPf16r : MVE_VCMPqrf<"f16", 0b1>;
3177 def MVE_VCMPi8r : MVE_VCMPqri<"i8", 0b00>;
3178 def MVE_VCMPi16r : MVE_VCMPqri<"i16", 0b01>;
3179 def MVE_VCMPi32r : MVE_VCMPqri<"i32", 0b10>;
3181 def MVE_VCMPu8r : MVE_VCMPqru<"u8", 0b00>;
3182 def MVE_VCMPu16r : MVE_VCMPqru<"u16", 0b01>;
3183 def MVE_VCMPu32r : MVE_VCMPqru<"u32", 0b10>;
3185 def MVE_VCMPs8r : MVE_VCMPqrs<"s8", 0b00>;
3186 def MVE_VCMPs16r : MVE_VCMPqrs<"s16", 0b01>;
3187 def MVE_VCMPs32r : MVE_VCMPqrs<"s32", 0b10>;
3189 multiclass unpred_vcmp_z<string suffix, int fc> {
3190 def i8 : Pat<(v16i1 (ARMvcmpz (v16i8 MQPR:$v1), (i32 fc))),
3191 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), ZR, fc))>;
3192 def i16 : Pat<(v8i1 (ARMvcmpz (v8i16 MQPR:$v1), (i32 fc))),
3193 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), ZR, fc))>;
3194 def i32 : Pat<(v4i1 (ARMvcmpz (v4i32 MQPR:$v1), (i32 fc))),
3195 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), ZR, fc))>;
3197 def : Pat<(v16i1 (and (v16i1 VCCR:$p1), (v16i1 (ARMvcmpz (v16i8 MQPR:$v1), (i32 fc))))),
3198 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), ZR, fc, 1, VCCR:$p1))>;
3199 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmpz (v8i16 MQPR:$v1), (i32 fc))))),
3200 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), ZR, fc, 1, VCCR:$p1))>;
3201 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmpz (v4i32 MQPR:$v1), (i32 fc))))),
3202 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), ZR, fc, 1, VCCR:$p1))>;
3205 multiclass unpred_vcmp_r<string suffix, int fc> {
3206 def i8 : Pat<(v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), (i32 fc))),
3207 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8") (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), fc))>;
3208 def i16 : Pat<(v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), (i32 fc))),
3209 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16") (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), fc))>;
3210 def i32 : Pat<(v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), (i32 fc))),
3211 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32") (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), fc))>;
3213 def i8r : Pat<(v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 (ARMvdup GPR:$v2)), (i32 fc))),
3214 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), (i32 GPR:$v2), fc))>;
3215 def i16r : Pat<(v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 (ARMvdup GPR:$v2)), (i32 fc))),
3216 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), (i32 GPR:$v2), fc))>;
3217 def i32r : Pat<(v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 (ARMvdup GPR:$v2)), (i32 fc))),
3218 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), (i32 GPR:$v2), fc))>;
3220 def : Pat<(v16i1 (and (v16i1 VCCR:$p1), (v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), (i32 fc))))),
3221 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8") (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), fc, 1, VCCR:$p1))>;
3222 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), (i32 fc))))),
3223 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16") (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), fc, 1, VCCR:$p1))>;
3224 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), (i32 fc))))),
3225 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32") (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), fc, 1, VCCR:$p1))>;
3227 def : Pat<(v16i1 (and (v16i1 VCCR:$p1), (v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 (ARMvdup GPR:$v2)), (i32 fc))))),
3228 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), (i32 GPR:$v2), fc, 1, VCCR:$p1))>;
3229 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 (ARMvdup GPR:$v2)), (i32 fc))))),
3230 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), (i32 GPR:$v2), fc, 1, VCCR:$p1))>;
3231 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 (ARMvdup GPR:$v2)), (i32 fc))))),
3232 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), (i32 GPR:$v2), fc, 1, VCCR:$p1))>;
3235 multiclass unpred_vcmpf_z<int fc> {
3236 def f16 : Pat<(v8i1 (ARMvcmpz (v8f16 MQPR:$v1), (i32 fc))),
3237 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), ZR, fc))>;
3238 def f32 : Pat<(v4i1 (ARMvcmpz (v4f32 MQPR:$v1), (i32 fc))),
3239 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, fc))>;
3241 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmpz (v8f16 MQPR:$v1), (i32 fc))))),
3242 (v8i1 (MVE_VCMPf32r (v8f16 MQPR:$v1), ZR, fc, 1, VCCR:$p1))>;
3243 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmpz (v4f32 MQPR:$v1), (i32 fc))))),
3244 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, fc, 1, VCCR:$p1))>;
3247 multiclass unpred_vcmpf_r<int fc> {
3248 def f16 : Pat<(v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), (i32 fc))),
3249 (v8i1 (MVE_VCMPf16 (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), fc))>;
3250 def f32 : Pat<(v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), (i32 fc))),
3251 (v4i1 (MVE_VCMPf32 (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), fc))>;
3253 def f16r : Pat<(v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 (ARMvdup HPR:$v2)), (i32 fc))),
3254 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), (i32 (COPY_TO_REGCLASS (f16 HPR:$v2), rGPR)), fc))>;
3255 def f32r : Pat<(v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 (ARMvdup SPR:$v2)), (i32 fc))),
3256 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), (i32 (COPY_TO_REGCLASS (f32 SPR:$v2), rGPR)), fc))>;
3258 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), (i32 fc))))),
3259 (v8i1 (MVE_VCMPf16 (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), fc, 1, VCCR:$p1))>;
3260 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), (i32 fc))))),
3261 (v4i1 (MVE_VCMPf32 (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), fc, 1, VCCR:$p1))>;
3263 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 (ARMvdup HPR:$v2)), (i32 fc))))),
3264 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), (i32 (COPY_TO_REGCLASS (f16 HPR:$v2), rGPR)), fc, 1, VCCR:$p1))>;
3265 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 (ARMvdup SPR:$v2)), (i32 fc))))),
3266 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), (i32 (COPY_TO_REGCLASS (f32 SPR:$v2), rGPR)), fc, 1, VCCR:$p1))>;
3269 let Predicates = [HasMVEInt] in {
3270 defm MVE_VCEQZ : unpred_vcmp_z<"i", 0>;
3271 defm MVE_VCNEZ : unpred_vcmp_z<"i", 1>;
3272 defm MVE_VCGEZ : unpred_vcmp_z<"s", 10>;
3273 defm MVE_VCLTZ : unpred_vcmp_z<"s", 11>;
3274 defm MVE_VCGTZ : unpred_vcmp_z<"s", 12>;
3275 defm MVE_VCLEZ : unpred_vcmp_z<"s", 13>;
3276 defm MVE_VCGTUZ : unpred_vcmp_z<"u", 8>;
3277 defm MVE_VCGEUZ : unpred_vcmp_z<"u", 2>;
3279 defm MVE_VCEQ : unpred_vcmp_r<"i", 0>;
3280 defm MVE_VCNE : unpred_vcmp_r<"i", 1>;
3281 defm MVE_VCGE : unpred_vcmp_r<"s", 10>;
3282 defm MVE_VCLT : unpred_vcmp_r<"s", 11>;
3283 defm MVE_VCGT : unpred_vcmp_r<"s", 12>;
3284 defm MVE_VCLE : unpred_vcmp_r<"s", 13>;
3285 defm MVE_VCGTU : unpred_vcmp_r<"u", 8>;
3286 defm MVE_VCGEU : unpred_vcmp_r<"u", 2>;
3289 let Predicates = [HasMVEFloat] in {
3290 defm MVE_VFCEQZ : unpred_vcmpf_z<0>;
3291 defm MVE_VFCNEZ : unpred_vcmpf_z<1>;
3292 defm MVE_VFCGEZ : unpred_vcmpf_z<10>;
3293 defm MVE_VFCLTZ : unpred_vcmpf_z<11>;
3294 defm MVE_VFCGTZ : unpred_vcmpf_z<12>;
3295 defm MVE_VFCLEZ : unpred_vcmpf_z<13>;
3297 defm MVE_VFCEQ : unpred_vcmpf_r<0>;
3298 defm MVE_VFCNE : unpred_vcmpf_r<1>;
3299 defm MVE_VFCGE : unpred_vcmpf_r<10>;
3300 defm MVE_VFCLT : unpred_vcmpf_r<11>;
3301 defm MVE_VFCGT : unpred_vcmpf_r<12>;
3302 defm MVE_VFCLE : unpred_vcmpf_r<13>;
3306 // Extra "worst case" and/or/xor partterns, going into and out of GRP
3307 multiclass two_predops<SDPatternOperator opnode, Instruction insn> {
3308 def v16i1 : Pat<(v16i1 (opnode (v16i1 VCCR:$p1), (v16i1 VCCR:$p2))),
3309 (v16i1 (COPY_TO_REGCLASS
3310 (insn (i32 (COPY_TO_REGCLASS (v16i1 VCCR:$p1), rGPR)),
3311 (i32 (COPY_TO_REGCLASS (v16i1 VCCR:$p2), rGPR))),
3313 def v8i1 : Pat<(v8i1 (opnode (v8i1 VCCR:$p1), (v8i1 VCCR:$p2))),
3314 (v8i1 (COPY_TO_REGCLASS
3315 (insn (i32 (COPY_TO_REGCLASS (v8i1 VCCR:$p1), rGPR)),
3316 (i32 (COPY_TO_REGCLASS (v8i1 VCCR:$p2), rGPR))),
3318 def v4i1 : Pat<(v4i1 (opnode (v4i1 VCCR:$p1), (v4i1 VCCR:$p2))),
3319 (v4i1 (COPY_TO_REGCLASS
3320 (insn (i32 (COPY_TO_REGCLASS (v4i1 VCCR:$p1), rGPR)),
3321 (i32 (COPY_TO_REGCLASS (v4i1 VCCR:$p2), rGPR))),
3325 let Predicates = [HasMVEInt] in {
3326 defm POR : two_predops<or, t2ORRrr>;
3327 defm PAND : two_predops<and, t2ANDrr>;
3328 defm PEOR : two_predops<xor, t2EORrr>;
3331 // Occasionally we need to cast between a i32 and a boolean vector, for
3332 // example when moving between rGPR and VPR.P0 as part of predicate vector
3333 // shuffles. We also sometimes need to cast between different predicate
3334 // vector types (v4i1<>v8i1, etc.) also as part of lowering vector shuffles.
3336 def predicate_cast : SDNode<"ARMISD::PREDICATE_CAST", SDTUnaryOp>;
3338 let Predicates = [HasMVEInt] in {
3339 foreach VT = [ v4i1, v8i1, v16i1 ] in {
3340 def : Pat<(i32 (predicate_cast (VT VCCR:$src))),
3341 (i32 (COPY_TO_REGCLASS (VT VCCR:$src), VCCR))>;
3342 def : Pat<(VT (predicate_cast (i32 VCCR:$src))),
3343 (VT (COPY_TO_REGCLASS (i32 VCCR:$src), VCCR))>;
3345 foreach VT2 = [ v4i1, v8i1, v16i1 ] in
3346 def : Pat<(VT (predicate_cast (VT2 VCCR:$src))),
3347 (VT (COPY_TO_REGCLASS (VT2 VCCR:$src), VCCR))>;
3351 // end of MVE compares
3353 // start of MVE_qDest_qSrc
3355 class MVE_qDest_qSrc<string iname, string suffix, dag oops, dag iops,
3356 string ops, vpred_ops vpred, string cstr,
3357 list<dag> pattern=[]>
3358 : MVE_p<oops, iops, NoItinerary, iname, suffix,
3359 ops, vpred, cstr, pattern> {
3363 let Inst{25-23} = 0b100;
3364 let Inst{22} = Qd{3};
3365 let Inst{15-13} = Qd{2-0};
3366 let Inst{11-9} = 0b111;
3368 let Inst{5} = Qm{3};
3370 let Inst{3-1} = Qm{2-0};
3373 class MVE_VQxDMLxDH<string iname, bit exch, bit round, bit subtract,
3374 string suffix, bits<2> size, string cstr="", list<dag> pattern=[]>
3375 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
3376 (ins MQPR:$Qd_src, MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm",
3377 vpred_n, "$Qd = $Qd_src"#cstr, pattern> {
3380 let Inst{28} = subtract;
3381 let Inst{21-20} = size;
3382 let Inst{19-17} = Qn{2-0};
3384 let Inst{12} = exch;
3386 let Inst{7} = Qn{3};
3387 let Inst{0} = round;
3390 multiclass MVE_VQxDMLxDH_multi<string iname, bit exch,
3391 bit round, bit subtract> {
3392 def s8 : MVE_VQxDMLxDH<iname, exch, round, subtract, "s8", 0b00>;
3393 def s16 : MVE_VQxDMLxDH<iname, exch, round, subtract, "s16", 0b01>;
3394 def s32 : MVE_VQxDMLxDH<iname, exch, round, subtract, "s32", 0b10, ",@earlyclobber $Qd">;
3397 defm MVE_VQDMLADH : MVE_VQxDMLxDH_multi<"vqdmladh", 0b0, 0b0, 0b0>;
3398 defm MVE_VQDMLADHX : MVE_VQxDMLxDH_multi<"vqdmladhx", 0b1, 0b0, 0b0>;
3399 defm MVE_VQRDMLADH : MVE_VQxDMLxDH_multi<"vqrdmladh", 0b0, 0b1, 0b0>;
3400 defm MVE_VQRDMLADHX : MVE_VQxDMLxDH_multi<"vqrdmladhx", 0b1, 0b1, 0b0>;
3401 defm MVE_VQDMLSDH : MVE_VQxDMLxDH_multi<"vqdmlsdh", 0b0, 0b0, 0b1>;
3402 defm MVE_VQDMLSDHX : MVE_VQxDMLxDH_multi<"vqdmlsdhx", 0b1, 0b0, 0b1>;
3403 defm MVE_VQRDMLSDH : MVE_VQxDMLxDH_multi<"vqrdmlsdh", 0b0, 0b1, 0b1>;
3404 defm MVE_VQRDMLSDHX : MVE_VQxDMLxDH_multi<"vqrdmlsdhx", 0b1, 0b1, 0b1>;
3406 class MVE_VCMUL<string iname, string suffix, bit size, string cstr="", list<dag> pattern=[]>
3407 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
3408 (ins MQPR:$Qn, MQPR:$Qm, complexrotateop:$rot),
3409 "$Qd, $Qn, $Qm, $rot", vpred_r, cstr, pattern> {
3413 let Inst{28} = size;
3414 let Inst{21-20} = 0b11;
3415 let Inst{19-17} = Qn{2-0};
3417 let Inst{12} = rot{1};
3419 let Inst{7} = Qn{3};
3420 let Inst{0} = rot{0};
3422 let Predicates = [HasMVEFloat];
3425 def MVE_VCMULf16 : MVE_VCMUL<"vcmul", "f16", 0b0>;
3426 def MVE_VCMULf32 : MVE_VCMUL<"vcmul", "f32", 0b1, "@earlyclobber $Qd">;
3428 class MVE_VMULL<string iname, string suffix, bit bit_28, bits<2> bits_21_20,
3429 bit T, string cstr, list<dag> pattern=[]>
3430 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
3431 (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm",
3432 vpred_r, cstr, pattern> {
3437 let Inst{28} = bit_28;
3438 let Inst{21-20} = bits_21_20;
3439 let Inst{19-17} = Qn{2-0};
3443 let Inst{7} = Qn{3};
3447 multiclass MVE_VMULL_multi<string iname, string suffix,
3448 bit bit_28, bits<2> bits_21_20, string cstr=""> {
3449 def bh : MVE_VMULL<iname # "b", suffix, bit_28, bits_21_20, 0b0, cstr>;
3450 def th : MVE_VMULL<iname # "t", suffix, bit_28, bits_21_20, 0b1, cstr>;
3453 // For integer multiplies, bits 21:20 encode size, and bit 28 signedness.
3454 // For polynomial multiplies, bits 21:20 take the unused value 0b11, and
3455 // bit 28 switches to encoding the size.
3457 defm MVE_VMULLs8 : MVE_VMULL_multi<"vmull", "s8", 0b0, 0b00>;
3458 defm MVE_VMULLs16 : MVE_VMULL_multi<"vmull", "s16", 0b0, 0b01>;
3459 defm MVE_VMULLs32 : MVE_VMULL_multi<"vmull", "s32", 0b0, 0b10, "@earlyclobber $Qd">;
3460 defm MVE_VMULLu8 : MVE_VMULL_multi<"vmull", "u8", 0b1, 0b00>;
3461 defm MVE_VMULLu16 : MVE_VMULL_multi<"vmull", "u16", 0b1, 0b01>;
3462 defm MVE_VMULLu32 : MVE_VMULL_multi<"vmull", "u32", 0b1, 0b10, "@earlyclobber $Qd">;
3463 defm MVE_VMULLp8 : MVE_VMULL_multi<"vmull", "p8", 0b0, 0b11>;
3464 defm MVE_VMULLp16 : MVE_VMULL_multi<"vmull", "p16", 0b1, 0b11>;
3466 class MVE_VxMULH<string iname, string suffix, bit U, bits<2> size,
3467 bit round, list<dag> pattern=[]>
3468 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
3469 (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm",
3470 vpred_r, "", pattern> {
3474 let Inst{21-20} = size;
3475 let Inst{19-17} = Qn{2-0};
3477 let Inst{12} = round;
3479 let Inst{7} = Qn{3};
3483 def MVE_VMULHs8 : MVE_VxMULH<"vmulh", "s8", 0b0, 0b00, 0b0>;
3484 def MVE_VMULHs16 : MVE_VxMULH<"vmulh", "s16", 0b0, 0b01, 0b0>;
3485 def MVE_VMULHs32 : MVE_VxMULH<"vmulh", "s32", 0b0, 0b10, 0b0>;
3486 def MVE_VMULHu8 : MVE_VxMULH<"vmulh", "u8", 0b1, 0b00, 0b0>;
3487 def MVE_VMULHu16 : MVE_VxMULH<"vmulh", "u16", 0b1, 0b01, 0b0>;
3488 def MVE_VMULHu32 : MVE_VxMULH<"vmulh", "u32", 0b1, 0b10, 0b0>;
3490 def MVE_VRMULHs8 : MVE_VxMULH<"vrmulh", "s8", 0b0, 0b00, 0b1>;
3491 def MVE_VRMULHs16 : MVE_VxMULH<"vrmulh", "s16", 0b0, 0b01, 0b1>;
3492 def MVE_VRMULHs32 : MVE_VxMULH<"vrmulh", "s32", 0b0, 0b10, 0b1>;
3493 def MVE_VRMULHu8 : MVE_VxMULH<"vrmulh", "u8", 0b1, 0b00, 0b1>;
3494 def MVE_VRMULHu16 : MVE_VxMULH<"vrmulh", "u16", 0b1, 0b01, 0b1>;
3495 def MVE_VRMULHu32 : MVE_VxMULH<"vrmulh", "u32", 0b1, 0b10, 0b1>;
3497 class MVE_VxMOVxN<string iname, string suffix, bit bit_28, bit bit_17,
3498 bits<2> size, bit T, list<dag> pattern=[]>
3499 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
3500 (ins MQPR:$Qd_src, MQPR:$Qm), "$Qd, $Qm",
3501 vpred_n, "$Qd = $Qd_src", pattern> {
3503 let Inst{28} = bit_28;
3504 let Inst{21-20} = 0b11;
3505 let Inst{19-18} = size;
3506 let Inst{17} = bit_17;
3510 let Inst{7} = !if(!eq(bit_17, 0), 1, 0);
3514 multiclass MVE_VxMOVxN_halves<string iname, string suffix,
3515 bit bit_28, bit bit_17, bits<2> size> {
3516 def bh : MVE_VxMOVxN<iname # "b", suffix, bit_28, bit_17, size, 0b0>;
3517 def th : MVE_VxMOVxN<iname # "t", suffix, bit_28, bit_17, size, 0b1>;
3520 defm MVE_VMOVNi16 : MVE_VxMOVxN_halves<"vmovn", "i16", 0b1, 0b0, 0b00>;
3521 defm MVE_VMOVNi32 : MVE_VxMOVxN_halves<"vmovn", "i32", 0b1, 0b0, 0b01>;
3522 defm MVE_VQMOVNs16 : MVE_VxMOVxN_halves<"vqmovn", "s16", 0b0, 0b1, 0b00>;
3523 defm MVE_VQMOVNs32 : MVE_VxMOVxN_halves<"vqmovn", "s32", 0b0, 0b1, 0b01>;
3524 defm MVE_VQMOVNu16 : MVE_VxMOVxN_halves<"vqmovn", "u16", 0b1, 0b1, 0b00>;
3525 defm MVE_VQMOVNu32 : MVE_VxMOVxN_halves<"vqmovn", "u32", 0b1, 0b1, 0b01>;
3526 defm MVE_VQMOVUNs16 : MVE_VxMOVxN_halves<"vqmovun", "s16", 0b0, 0b0, 0b00>;
3527 defm MVE_VQMOVUNs32 : MVE_VxMOVxN_halves<"vqmovun", "s32", 0b0, 0b0, 0b01>;
3529 def MVEvmovn : SDNode<"ARMISD::VMOVN", SDTARMVEXT>;
3530 let Predicates = [HasMVEInt] in {
3531 def : Pat<(v8i16 (MVEvmovn (v8i16 MQPR:$Qd_src), (v8i16 MQPR:$Qm), (i32 0))),
3532 (v8i16 (MVE_VMOVNi32bh (v8i16 MQPR:$Qd_src), (v8i16 MQPR:$Qm)))>;
3533 def : Pat<(v8i16 (MVEvmovn (v8i16 MQPR:$Qd_src), (v8i16 MQPR:$Qm), (i32 1))),
3534 (v8i16 (MVE_VMOVNi32th (v8i16 MQPR:$Qd_src), (v8i16 MQPR:$Qm)))>;
3535 def : Pat<(v16i8 (MVEvmovn (v16i8 MQPR:$Qd_src), (v16i8 MQPR:$Qm), (i32 0))),
3536 (v16i8 (MVE_VMOVNi16bh (v16i8 MQPR:$Qd_src), (v16i8 MQPR:$Qm)))>;
3537 def : Pat<(v16i8 (MVEvmovn (v16i8 MQPR:$Qd_src), (v16i8 MQPR:$Qm), (i32 1))),
3538 (v16i8 (MVE_VMOVNi16th (v16i8 MQPR:$Qd_src), (v16i8 MQPR:$Qm)))>;
3541 class MVE_VCVT_ff<string iname, string suffix, bit op, bit T,
3542 list<dag> pattern=[]>
3543 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd), (ins MQPR:$Qd_src, MQPR:$Qm),
3544 "$Qd, $Qm", vpred_n, "$Qd = $Qd_src", pattern> {
3546 let Inst{21-16} = 0b111111;
3548 let Inst{8-7} = 0b00;
3551 let Predicates = [HasMVEFloat];
3554 multiclass MVE_VCVT_ff_halves<string suffix, bit op> {
3555 def bh : MVE_VCVT_ff<"vcvtb", suffix, op, 0b0>;
3556 def th : MVE_VCVT_ff<"vcvtt", suffix, op, 0b1>;
3559 defm MVE_VCVTf16f32 : MVE_VCVT_ff_halves<"f16.f32", 0b0>;
3560 defm MVE_VCVTf32f16 : MVE_VCVT_ff_halves<"f32.f16", 0b1>;
3562 class MVE_VxCADD<string iname, string suffix, bits<2> size, bit halve,
3563 string cstr="", list<dag> pattern=[]>
3564 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
3565 (ins MQPR:$Qn, MQPR:$Qm, complexrotateopodd:$rot),
3566 "$Qd, $Qn, $Qm, $rot", vpred_r, cstr, pattern> {
3570 let Inst{28} = halve;
3571 let Inst{21-20} = size;
3572 let Inst{19-17} = Qn{2-0};
3576 let Inst{7} = Qn{3};
3580 def MVE_VCADDi8 : MVE_VxCADD<"vcadd", "i8", 0b00, 0b1>;
3581 def MVE_VCADDi16 : MVE_VxCADD<"vcadd", "i16", 0b01, 0b1>;
3582 def MVE_VCADDi32 : MVE_VxCADD<"vcadd", "i32", 0b10, 0b1, "@earlyclobber $Qd">;
3584 def MVE_VHCADDs8 : MVE_VxCADD<"vhcadd", "s8", 0b00, 0b0>;
3585 def MVE_VHCADDs16 : MVE_VxCADD<"vhcadd", "s16", 0b01, 0b0>;
3586 def MVE_VHCADDs32 : MVE_VxCADD<"vhcadd", "s32", 0b10, 0b0, "@earlyclobber $Qd">;
3588 class MVE_VADCSBC<string iname, bit I, bit subtract,
3589 dag carryin, list<dag> pattern=[]>
3590 : MVE_qDest_qSrc<iname, "i32", (outs MQPR:$Qd, cl_FPSCR_NZCV:$carryout),
3591 !con((ins MQPR:$Qn, MQPR:$Qm), carryin),
3592 "$Qd, $Qn, $Qm", vpred_r, "", pattern> {
3595 let Inst{28} = subtract;
3596 let Inst{21-20} = 0b11;
3597 let Inst{19-17} = Qn{2-0};
3601 let Inst{7} = Qn{3};
3604 // Custom decoder method in order to add the FPSCR operand(s), which
3605 // Tablegen won't do right
3606 let DecoderMethod = "DecodeMVEVADCInstruction";
3609 def MVE_VADC : MVE_VADCSBC<"vadc", 0b0, 0b0, (ins cl_FPSCR_NZCV:$carryin)>;
3610 def MVE_VADCI : MVE_VADCSBC<"vadci", 0b1, 0b0, (ins)>;
3612 def MVE_VSBC : MVE_VADCSBC<"vsbc", 0b0, 0b1, (ins cl_FPSCR_NZCV:$carryin)>;
3613 def MVE_VSBCI : MVE_VADCSBC<"vsbci", 0b1, 0b1, (ins)>;
3615 class MVE_VQDMULL<string iname, string suffix, bit size, bit T,
3616 string cstr="", list<dag> pattern=[]>
3617 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
3618 (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm",
3619 vpred_r, cstr, pattern> {
3622 let Inst{28} = size;
3623 let Inst{21-20} = 0b11;
3624 let Inst{19-17} = Qn{2-0};
3628 let Inst{7} = Qn{3};
3632 multiclass MVE_VQDMULL_halves<string suffix, bit size, string cstr=""> {
3633 def bh : MVE_VQDMULL<"vqdmullb", suffix, size, 0b0, cstr>;
3634 def th : MVE_VQDMULL<"vqdmullt", suffix, size, 0b1, cstr>;
3637 defm MVE_VQDMULLs16 : MVE_VQDMULL_halves<"s16", 0b0>;
3638 defm MVE_VQDMULLs32 : MVE_VQDMULL_halves<"s32", 0b1, "@earlyclobber $Qd">;
3640 // end of mve_qDest_qSrc
3642 // start of mve_qDest_rSrc
3644 class MVE_qr_base<dag oops, dag iops, InstrItinClass itin, string iname,
3645 string suffix, string ops, vpred_ops vpred, string cstr,
3646 list<dag> pattern=[]>
3647 : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, pattern> {
3652 let Inst{25-23} = 0b100;
3653 let Inst{22} = Qd{3};
3654 let Inst{19-17} = Qn{2-0};
3655 let Inst{15-13} = Qd{2-0};
3656 let Inst{11-9} = 0b111;
3657 let Inst{7} = Qn{3};
3660 let Inst{3-0} = Rm{3-0};
3663 class MVE_qDest_rSrc<string iname, string suffix, string cstr="", list<dag> pattern=[]>
3664 : MVE_qr_base<(outs MQPR:$Qd), (ins MQPR:$Qn, rGPR:$Rm),
3665 NoItinerary, iname, suffix, "$Qd, $Qn, $Rm", vpred_r, cstr,
3668 class MVE_qDestSrc_rSrc<string iname, string suffix, list<dag> pattern=[]>
3669 : MVE_qr_base<(outs MQPR:$Qd), (ins MQPR:$Qd_src, MQPR:$Qn, rGPR:$Rm),
3670 NoItinerary, iname, suffix, "$Qd, $Qn, $Rm", vpred_n, "$Qd = $Qd_src",
3673 class MVE_qDest_single_rSrc<string iname, string suffix, list<dag> pattern=[]>
3674 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qd_src, rGPR:$Rm), NoItinerary, iname,
3675 suffix, "$Qd, $Rm", vpred_n, "$Qd = $Qd_src", pattern> {
3679 let Inst{22} = Qd{3};
3680 let Inst{15-13} = Qd{2-0};
3681 let Inst{3-0} = Rm{3-0};
3684 class MVE_VADDSUB_qr<string iname, string suffix, bits<2> size,
3685 bit bit_5, bit bit_12, bit bit_16,
3686 bit bit_28, list<dag> pattern=[]>
3687 : MVE_qDest_rSrc<iname, suffix, "", pattern> {
3689 let Inst{28} = bit_28;
3690 let Inst{21-20} = size;
3691 let Inst{16} = bit_16;
3692 let Inst{12} = bit_12;
3694 let Inst{5} = bit_5;
3695 let validForTailPredication = 1;
3698 multiclass MVE_VADDSUB_qr_sizes<string iname, string suffix,
3699 bit bit_5, bit bit_12, bit bit_16,
3700 bit bit_28, list<dag> pattern=[]> {
3701 def "8" : MVE_VADDSUB_qr<iname, suffix#"8", 0b00,
3702 bit_5, bit_12, bit_16, bit_28>;
3703 def "16" : MVE_VADDSUB_qr<iname, suffix#"16", 0b01,
3704 bit_5, bit_12, bit_16, bit_28>;
3705 def "32" : MVE_VADDSUB_qr<iname, suffix#"32", 0b10,
3706 bit_5, bit_12, bit_16, bit_28>;
3709 defm MVE_VADD_qr_i : MVE_VADDSUB_qr_sizes<"vadd", "i", 0b0, 0b0, 0b1, 0b0>;
3710 defm MVE_VQADD_qr_s : MVE_VADDSUB_qr_sizes<"vqadd", "s", 0b1, 0b0, 0b0, 0b0>;
3711 defm MVE_VQADD_qr_u : MVE_VADDSUB_qr_sizes<"vqadd", "u", 0b1, 0b0, 0b0, 0b1>;
3713 defm MVE_VSUB_qr_i : MVE_VADDSUB_qr_sizes<"vsub", "i", 0b0, 0b1, 0b1, 0b0>;
3714 defm MVE_VQSUB_qr_s : MVE_VADDSUB_qr_sizes<"vqsub", "s", 0b1, 0b1, 0b0, 0b0>;
3715 defm MVE_VQSUB_qr_u : MVE_VADDSUB_qr_sizes<"vqsub", "u", 0b1, 0b1, 0b0, 0b1>;
3717 let Predicates = [HasMVEInt] in {
3718 def : Pat<(v16i8 (add (v16i8 MQPR:$val1), (v16i8 (ARMvdup GPR:$val2)))),
3719 (v16i8 (MVE_VADD_qr_i8 (v16i8 MQPR:$val1), (i32 GPR:$val2)))>;
3720 def : Pat<(v8i16 (add (v8i16 MQPR:$val1), (v8i16 (ARMvdup GPR:$val2)))),
3721 (v8i16 (MVE_VADD_qr_i16 (v8i16 MQPR:$val1), (i32 GPR:$val2)))>;
3722 def : Pat<(v4i32 (add (v4i32 MQPR:$val1), (v4i32 (ARMvdup GPR:$val2)))),
3723 (v4i32 (MVE_VADD_qr_i32 (v4i32 MQPR:$val1), (i32 GPR:$val2)))>;
3726 let Predicates = [HasMVEInt] in {
3727 def : Pat<(v16i8 (sub (v16i8 MQPR:$val1), (v16i8 (ARMvdup GPR:$val2)))),
3728 (v16i8 (MVE_VSUB_qr_i8 (v16i8 MQPR:$val1), (i32 GPR:$val2)))>;
3729 def : Pat<(v8i16 (sub (v8i16 MQPR:$val1), (v8i16 (ARMvdup GPR:$val2)))),
3730 (v8i16 (MVE_VSUB_qr_i16 (v8i16 MQPR:$val1), (i32 GPR:$val2)))>;
3731 def : Pat<(v4i32 (sub (v4i32 MQPR:$val1), (v4i32 (ARMvdup GPR:$val2)))),
3732 (v4i32 (MVE_VSUB_qr_i32 (v4i32 MQPR:$val1), (i32 GPR:$val2)))>;
3735 class MVE_VQDMULL_qr<string iname, string suffix, bit size,
3736 bit T, string cstr="", list<dag> pattern=[]>
3737 : MVE_qDest_rSrc<iname, suffix, cstr, pattern> {
3739 let Inst{28} = size;
3740 let Inst{21-20} = 0b11;
3747 multiclass MVE_VQDMULL_qr_halves<string suffix, bit size, string cstr=""> {
3748 def bh : MVE_VQDMULL_qr<"vqdmullb", suffix, size, 0b0, cstr>;
3749 def th : MVE_VQDMULL_qr<"vqdmullt", suffix, size, 0b1, cstr>;
3752 defm MVE_VQDMULL_qr_s16 : MVE_VQDMULL_qr_halves<"s16", 0b0>;
3753 defm MVE_VQDMULL_qr_s32 : MVE_VQDMULL_qr_halves<"s32", 0b1, "@earlyclobber $Qd">;
3755 class MVE_VxADDSUB_qr<string iname, string suffix,
3756 bit bit_28, bits<2> bits_21_20, bit subtract,
3757 list<dag> pattern=[]>
3758 : MVE_qDest_rSrc<iname, suffix, "", pattern> {
3760 let Inst{28} = bit_28;
3761 let Inst{21-20} = bits_21_20;
3763 let Inst{12} = subtract;
3766 let validForTailPredication = 1;
3769 def MVE_VHADD_qr_s8 : MVE_VxADDSUB_qr<"vhadd", "s8", 0b0, 0b00, 0b0>;
3770 def MVE_VHADD_qr_s16 : MVE_VxADDSUB_qr<"vhadd", "s16", 0b0, 0b01, 0b0>;
3771 def MVE_VHADD_qr_s32 : MVE_VxADDSUB_qr<"vhadd", "s32", 0b0, 0b10, 0b0>;
3772 def MVE_VHADD_qr_u8 : MVE_VxADDSUB_qr<"vhadd", "u8", 0b1, 0b00, 0b0>;
3773 def MVE_VHADD_qr_u16 : MVE_VxADDSUB_qr<"vhadd", "u16", 0b1, 0b01, 0b0>;
3774 def MVE_VHADD_qr_u32 : MVE_VxADDSUB_qr<"vhadd", "u32", 0b1, 0b10, 0b0>;
3776 def MVE_VHSUB_qr_s8 : MVE_VxADDSUB_qr<"vhsub", "s8", 0b0, 0b00, 0b1>;
3777 def MVE_VHSUB_qr_s16 : MVE_VxADDSUB_qr<"vhsub", "s16", 0b0, 0b01, 0b1>;
3778 def MVE_VHSUB_qr_s32 : MVE_VxADDSUB_qr<"vhsub", "s32", 0b0, 0b10, 0b1>;
3779 def MVE_VHSUB_qr_u8 : MVE_VxADDSUB_qr<"vhsub", "u8", 0b1, 0b00, 0b1>;
3780 def MVE_VHSUB_qr_u16 : MVE_VxADDSUB_qr<"vhsub", "u16", 0b1, 0b01, 0b1>;
3781 def MVE_VHSUB_qr_u32 : MVE_VxADDSUB_qr<"vhsub", "u32", 0b1, 0b10, 0b1>;
3783 let Predicates = [HasMVEFloat] in {
3784 def MVE_VADD_qr_f32 : MVE_VxADDSUB_qr<"vadd", "f32", 0b0, 0b11, 0b0>;
3785 def MVE_VADD_qr_f16 : MVE_VxADDSUB_qr<"vadd", "f16", 0b1, 0b11, 0b0>;
3787 def MVE_VSUB_qr_f32 : MVE_VxADDSUB_qr<"vsub", "f32", 0b0, 0b11, 0b1>;
3788 def MVE_VSUB_qr_f16 : MVE_VxADDSUB_qr<"vsub", "f16", 0b1, 0b11, 0b1>;
3791 class MVE_VxSHL_qr<string iname, string suffix, bit U, bits<2> size,
3792 bit bit_7, bit bit_17, list<dag> pattern=[]>
3793 : MVE_qDest_single_rSrc<iname, suffix, pattern> {
3796 let Inst{25-23} = 0b100;
3797 let Inst{21-20} = 0b11;
3798 let Inst{19-18} = size;
3799 let Inst{17} = bit_17;
3801 let Inst{12-8} = 0b11110;
3802 let Inst{7} = bit_7;
3803 let Inst{6-4} = 0b110;
3804 let validForTailPredication = 1;
3807 multiclass MVE_VxSHL_qr_types<string iname, bit bit_7, bit bit_17> {
3808 def s8 : MVE_VxSHL_qr<iname, "s8", 0b0, 0b00, bit_7, bit_17>;
3809 def s16 : MVE_VxSHL_qr<iname, "s16", 0b0, 0b01, bit_7, bit_17>;
3810 def s32 : MVE_VxSHL_qr<iname, "s32", 0b0, 0b10, bit_7, bit_17>;
3811 def u8 : MVE_VxSHL_qr<iname, "u8", 0b1, 0b00, bit_7, bit_17>;
3812 def u16 : MVE_VxSHL_qr<iname, "u16", 0b1, 0b01, bit_7, bit_17>;
3813 def u32 : MVE_VxSHL_qr<iname, "u32", 0b1, 0b10, bit_7, bit_17>;
3816 defm MVE_VSHL_qr : MVE_VxSHL_qr_types<"vshl", 0b0, 0b0>;
3817 defm MVE_VRSHL_qr : MVE_VxSHL_qr_types<"vrshl", 0b0, 0b1>;
3818 defm MVE_VQSHL_qr : MVE_VxSHL_qr_types<"vqshl", 0b1, 0b0>;
3819 defm MVE_VQRSHL_qr : MVE_VxSHL_qr_types<"vqrshl", 0b1, 0b1>;
3821 let Predicates = [HasMVEInt] in {
3822 def : Pat<(v4i32 (ARMvshlu (v4i32 MQPR:$Qm), (v4i32 (ARMvdup GPR:$Rm)))),
3823 (v4i32 (MVE_VSHL_qru32 (v4i32 MQPR:$Qm), GPR:$Rm))>;
3824 def : Pat<(v8i16 (ARMvshlu (v8i16 MQPR:$Qm), (v8i16 (ARMvdup GPR:$Rm)))),
3825 (v8i16 (MVE_VSHL_qru16 (v8i16 MQPR:$Qm), GPR:$Rm))>;
3826 def : Pat<(v16i8 (ARMvshlu (v16i8 MQPR:$Qm), (v16i8 (ARMvdup GPR:$Rm)))),
3827 (v16i8 (MVE_VSHL_qru8 (v16i8 MQPR:$Qm), GPR:$Rm))>;
3829 def : Pat<(v4i32 (ARMvshls (v4i32 MQPR:$Qm), (v4i32 (ARMvdup GPR:$Rm)))),
3830 (v4i32 (MVE_VSHL_qrs32 (v4i32 MQPR:$Qm), GPR:$Rm))>;
3831 def : Pat<(v8i16 (ARMvshls (v8i16 MQPR:$Qm), (v8i16 (ARMvdup GPR:$Rm)))),
3832 (v8i16 (MVE_VSHL_qrs16 (v8i16 MQPR:$Qm), GPR:$Rm))>;
3833 def : Pat<(v16i8 (ARMvshls (v16i8 MQPR:$Qm), (v16i8 (ARMvdup GPR:$Rm)))),
3834 (v16i8 (MVE_VSHL_qrs8 (v16i8 MQPR:$Qm), GPR:$Rm))>;
3837 class MVE_VBRSR<string iname, string suffix, bits<2> size, list<dag> pattern=[]>
3838 : MVE_qDest_rSrc<iname, suffix, "", pattern> {
3841 let Inst{21-20} = size;
3846 let validForTailPredication = 1;
3849 def MVE_VBRSR8 : MVE_VBRSR<"vbrsr", "8", 0b00>;
3850 def MVE_VBRSR16 : MVE_VBRSR<"vbrsr", "16", 0b01>;
3851 def MVE_VBRSR32 : MVE_VBRSR<"vbrsr", "32", 0b10>;
3853 let Predicates = [HasMVEInt] in {
3854 def : Pat<(v16i8 ( bitreverse (v16i8 MQPR:$val1))),
3855 (v16i8 ( MVE_VBRSR8 (v16i8 MQPR:$val1), (t2MOVi (i32 8)) ))>;
3857 def : Pat<(v4i32 ( bitreverse (v4i32 MQPR:$val1))),
3858 (v4i32 ( MVE_VBRSR32 (v4i32 MQPR:$val1), (t2MOVi (i32 32)) ))>;
3860 def : Pat<(v8i16 ( bitreverse (v8i16 MQPR:$val1))),
3861 (v8i16 ( MVE_VBRSR16 (v8i16 MQPR:$val1), (t2MOVi (i32 16)) ))>;
3864 class MVE_VMUL_qr_int<string iname, string suffix,
3865 bits<2> size, list<dag> pattern=[]>
3866 : MVE_qDest_rSrc<iname, suffix, "", pattern> {
3869 let Inst{21-20} = size;
3874 let validForTailPredication = 1;
3877 def MVE_VMUL_qr_i8 : MVE_VMUL_qr_int<"vmul", "i8", 0b00>;
3878 def MVE_VMUL_qr_i16 : MVE_VMUL_qr_int<"vmul", "i16", 0b01>;
3879 def MVE_VMUL_qr_i32 : MVE_VMUL_qr_int<"vmul", "i32", 0b10>;
3881 let Predicates = [HasMVEInt] in {
3882 def : Pat<(v16i8 (mul (v16i8 MQPR:$val1), (v16i8 (ARMvdup GPR:$val2)))),
3883 (v16i8 (MVE_VMUL_qr_i8 (v16i8 MQPR:$val1), (i32 GPR:$val2)))>;
3884 def : Pat<(v8i16 (mul (v8i16 MQPR:$val1), (v8i16 (ARMvdup GPR:$val2)))),
3885 (v8i16 (MVE_VMUL_qr_i16 (v8i16 MQPR:$val1), (i32 GPR:$val2)))>;
3886 def : Pat<(v4i32 (mul (v4i32 MQPR:$val1), (v4i32 (ARMvdup GPR:$val2)))),
3887 (v4i32 (MVE_VMUL_qr_i32 (v4i32 MQPR:$val1), (i32 GPR:$val2)))>;
3890 class MVE_VxxMUL_qr<string iname, string suffix,
3891 bit bit_28, bits<2> bits_21_20, list<dag> pattern=[]>
3892 : MVE_qDest_rSrc<iname, suffix, "", pattern> {
3894 let Inst{28} = bit_28;
3895 let Inst{21-20} = bits_21_20;
3902 def MVE_VQDMULH_qr_s8 : MVE_VxxMUL_qr<"vqdmulh", "s8", 0b0, 0b00>;
3903 def MVE_VQDMULH_qr_s16 : MVE_VxxMUL_qr<"vqdmulh", "s16", 0b0, 0b01>;
3904 def MVE_VQDMULH_qr_s32 : MVE_VxxMUL_qr<"vqdmulh", "s32", 0b0, 0b10>;
3906 def MVE_VQRDMULH_qr_s8 : MVE_VxxMUL_qr<"vqrdmulh", "s8", 0b1, 0b00>;
3907 def MVE_VQRDMULH_qr_s16 : MVE_VxxMUL_qr<"vqrdmulh", "s16", 0b1, 0b01>;
3908 def MVE_VQRDMULH_qr_s32 : MVE_VxxMUL_qr<"vqrdmulh", "s32", 0b1, 0b10>;
3910 let Predicates = [HasMVEFloat], validForTailPredication = 1 in {
3911 def MVE_VMUL_qr_f16 : MVE_VxxMUL_qr<"vmul", "f16", 0b1, 0b11>;
3912 def MVE_VMUL_qr_f32 : MVE_VxxMUL_qr<"vmul", "f32", 0b0, 0b11>;
3915 class MVE_VFMAMLA_qr<string iname, string suffix,
3916 bit bit_28, bits<2> bits_21_20, bit S,
3917 list<dag> pattern=[]>
3918 : MVE_qDestSrc_rSrc<iname, suffix, pattern> {
3920 let Inst{28} = bit_28;
3921 let Inst{21-20} = bits_21_20;
3926 let validForTailPredication = 1;
3929 def MVE_VMLA_qr_s8 : MVE_VFMAMLA_qr<"vmla", "s8", 0b0, 0b00, 0b0>;
3930 def MVE_VMLA_qr_s16 : MVE_VFMAMLA_qr<"vmla", "s16", 0b0, 0b01, 0b0>;
3931 def MVE_VMLA_qr_s32 : MVE_VFMAMLA_qr<"vmla", "s32", 0b0, 0b10, 0b0>;
3932 def MVE_VMLA_qr_u8 : MVE_VFMAMLA_qr<"vmla", "u8", 0b1, 0b00, 0b0>;
3933 def MVE_VMLA_qr_u16 : MVE_VFMAMLA_qr<"vmla", "u16", 0b1, 0b01, 0b0>;
3934 def MVE_VMLA_qr_u32 : MVE_VFMAMLA_qr<"vmla", "u32", 0b1, 0b10, 0b0>;
3936 def MVE_VMLAS_qr_s8 : MVE_VFMAMLA_qr<"vmlas", "s8", 0b0, 0b00, 0b1>;
3937 def MVE_VMLAS_qr_s16 : MVE_VFMAMLA_qr<"vmlas", "s16", 0b0, 0b01, 0b1>;
3938 def MVE_VMLAS_qr_s32 : MVE_VFMAMLA_qr<"vmlas", "s32", 0b0, 0b10, 0b1>;
3939 def MVE_VMLAS_qr_u8 : MVE_VFMAMLA_qr<"vmlas", "u8", 0b1, 0b00, 0b1>;
3940 def MVE_VMLAS_qr_u16 : MVE_VFMAMLA_qr<"vmlas", "u16", 0b1, 0b01, 0b1>;
3941 def MVE_VMLAS_qr_u32 : MVE_VFMAMLA_qr<"vmlas", "u32", 0b1, 0b10, 0b1>;
3943 let Predicates = [HasMVEInt] in {
3944 def : Pat<(v4i32 (add (v4i32 MQPR:$src1),
3945 (v4i32 (mul (v4i32 MQPR:$src2),
3946 (v4i32 (ARMvdup (i32 rGPR:$x))))))),
3947 (v4i32 (MVE_VMLA_qr_u32 $src1, $src2, $x))>;
3948 def : Pat<(v8i16 (add (v8i16 MQPR:$src1),
3949 (v8i16 (mul (v8i16 MQPR:$src2),
3950 (v8i16 (ARMvdup (i32 rGPR:$x))))))),
3951 (v8i16 (MVE_VMLA_qr_u16 $src1, $src2, $x))>;
3952 def : Pat<(v16i8 (add (v16i8 MQPR:$src1),
3953 (v16i8 (mul (v16i8 MQPR:$src2),
3954 (v16i8 (ARMvdup (i32 rGPR:$x))))))),
3955 (v16i8 (MVE_VMLA_qr_u8 $src1, $src2, $x))>;
3958 let Predicates = [HasMVEFloat] in {
3959 def MVE_VFMA_qr_f16 : MVE_VFMAMLA_qr<"vfma", "f16", 0b1, 0b11, 0b0>;
3960 def MVE_VFMA_qr_f32 : MVE_VFMAMLA_qr<"vfma", "f32", 0b0, 0b11, 0b0>;
3961 def MVE_VFMA_qr_Sf16 : MVE_VFMAMLA_qr<"vfmas", "f16", 0b1, 0b11, 0b1>;
3962 def MVE_VFMA_qr_Sf32 : MVE_VFMAMLA_qr<"vfmas", "f32", 0b0, 0b11, 0b1>;
3965 class MVE_VQDMLAH_qr<string iname, string suffix, bit U, bits<2> size,
3966 bit bit_5, bit bit_12, list<dag> pattern=[]>
3967 : MVE_qDestSrc_rSrc<iname, suffix, pattern> {
3970 let Inst{21-20} = size;
3972 let Inst{12} = bit_12;
3974 let Inst{5} = bit_5;
3977 multiclass MVE_VQDMLAH_qr_types<string iname, bit bit_5, bit bit_12> {
3978 def s8 : MVE_VQDMLAH_qr<iname, "s8", 0b0, 0b00, bit_5, bit_12>;
3979 def s16 : MVE_VQDMLAH_qr<iname, "s16", 0b0, 0b01, bit_5, bit_12>;
3980 def s32 : MVE_VQDMLAH_qr<iname, "s32", 0b0, 0b10, bit_5, bit_12>;
3983 defm MVE_VQDMLAH_qr : MVE_VQDMLAH_qr_types<"vqdmlah", 0b1, 0b0>;
3984 defm MVE_VQRDMLAH_qr : MVE_VQDMLAH_qr_types<"vqrdmlah", 0b0, 0b0>;
3985 defm MVE_VQDMLASH_qr : MVE_VQDMLAH_qr_types<"vqdmlash", 0b1, 0b1>;
3986 defm MVE_VQRDMLASH_qr : MVE_VQDMLAH_qr_types<"vqrdmlash", 0b0, 0b1>;
3988 class MVE_VxDUP<string iname, string suffix, bits<2> size, bit bit_12,
3989 list<dag> pattern=[]>
3990 : MVE_p<(outs MQPR:$Qd, tGPREven:$Rn),
3991 (ins tGPREven:$Rn_src, MVE_VIDUP_imm:$imm), NoItinerary,
3992 iname, suffix, "$Qd, $Rn, $imm", vpred_r, "$Rn = $Rn_src",
3999 let Inst{25-23} = 0b100;
4000 let Inst{22} = Qd{3};
4001 let Inst{21-20} = size;
4002 let Inst{19-17} = Rn{3-1};
4004 let Inst{15-13} = Qd{2-0};
4005 let Inst{12} = bit_12;
4006 let Inst{11-8} = 0b1111;
4007 let Inst{7} = imm{1};
4008 let Inst{6-1} = 0b110111;
4009 let Inst{0} = imm{0};
4010 let validForTailPredication = 1;
4013 def MVE_VIDUPu8 : MVE_VxDUP<"vidup", "u8", 0b00, 0b0>;
4014 def MVE_VIDUPu16 : MVE_VxDUP<"vidup", "u16", 0b01, 0b0>;
4015 def MVE_VIDUPu32 : MVE_VxDUP<"vidup", "u32", 0b10, 0b0>;
4017 def MVE_VDDUPu8 : MVE_VxDUP<"vddup", "u8", 0b00, 0b1>;
4018 def MVE_VDDUPu16 : MVE_VxDUP<"vddup", "u16", 0b01, 0b1>;
4019 def MVE_VDDUPu32 : MVE_VxDUP<"vddup", "u32", 0b10, 0b1>;
4021 class MVE_VxWDUP<string iname, string suffix, bits<2> size, bit bit_12,
4022 list<dag> pattern=[]>
4023 : MVE_p<(outs MQPR:$Qd, tGPREven:$Rn),
4024 (ins tGPREven:$Rn_src, tGPROdd:$Rm, MVE_VIDUP_imm:$imm), NoItinerary,
4025 iname, suffix, "$Qd, $Rn, $Rm, $imm", vpred_r, "$Rn = $Rn_src",
4033 let Inst{25-23} = 0b100;
4034 let Inst{22} = Qd{3};
4035 let Inst{21-20} = size;
4036 let Inst{19-17} = Rn{3-1};
4038 let Inst{15-13} = Qd{2-0};
4039 let Inst{12} = bit_12;
4040 let Inst{11-8} = 0b1111;
4041 let Inst{7} = imm{1};
4042 let Inst{6-4} = 0b110;
4043 let Inst{3-1} = Rm{3-1};
4044 let Inst{0} = imm{0};
4045 let validForTailPredication = 1;
4048 def MVE_VIWDUPu8 : MVE_VxWDUP<"viwdup", "u8", 0b00, 0b0>;
4049 def MVE_VIWDUPu16 : MVE_VxWDUP<"viwdup", "u16", 0b01, 0b0>;
4050 def MVE_VIWDUPu32 : MVE_VxWDUP<"viwdup", "u32", 0b10, 0b0>;
4052 def MVE_VDWDUPu8 : MVE_VxWDUP<"vdwdup", "u8", 0b00, 0b1>;
4053 def MVE_VDWDUPu16 : MVE_VxWDUP<"vdwdup", "u16", 0b01, 0b1>;
4054 def MVE_VDWDUPu32 : MVE_VxWDUP<"vdwdup", "u32", 0b10, 0b1>;
4056 let hasSideEffects = 1 in
4057 class MVE_VCTP<string suffix, bits<2> size, list<dag> pattern=[]>
4058 : MVE_p<(outs VCCR:$P0), (ins rGPR:$Rn), NoItinerary, "vctp", suffix,
4059 "$Rn", vpred_n, "", pattern> {
4062 let Inst{28-27} = 0b10;
4063 let Inst{26-22} = 0b00000;
4064 let Inst{21-20} = size;
4065 let Inst{19-16} = Rn{3-0};
4066 let Inst{15-11} = 0b11101;
4067 let Inst{10-0} = 0b00000000001;
4068 let Unpredictable{10-0} = 0b11111111111;
4070 let Constraints = "";
4071 let DecoderMethod = "DecodeMveVCTP";
4072 let validForTailPredication = 1;
4075 def MVE_VCTP8 : MVE_VCTP<"8", 0b00>;
4076 def MVE_VCTP16 : MVE_VCTP<"16", 0b01>;
4077 def MVE_VCTP32 : MVE_VCTP<"32", 0b10>;
4078 def MVE_VCTP64 : MVE_VCTP<"64", 0b11>;
4080 let Predicates = [HasMVEInt] in {
4081 def : Pat<(int_arm_vctp8 rGPR:$Rn),
4082 (v16i1 (MVE_VCTP8 rGPR:$Rn))>;
4083 def : Pat<(int_arm_vctp16 rGPR:$Rn),
4084 (v8i1 (MVE_VCTP16 rGPR:$Rn))>;
4085 def : Pat<(int_arm_vctp32 rGPR:$Rn),
4086 (v4i1 (MVE_VCTP32 rGPR:$Rn))>;
4089 // end of mve_qDest_rSrc
4091 // start of coproc mov
4093 class MVE_VMOV_64bit<dag oops, dag iops, bit to_qreg, string ops, string cstr>
4094 : MVE_VMOV_lane_base<oops, !con(iops, (ins MVEPairVectorIndex2:$idx,
4095 MVEPairVectorIndex0:$idx2)),
4096 NoItinerary, "vmov", "", ops, cstr, []> {
4103 let Inst{31-23} = 0b111011000;
4104 let Inst{22} = Qd{3};
4106 let Inst{20} = to_qreg;
4107 let Inst{19-16} = Rt2{3-0};
4108 let Inst{15-13} = Qd{2-0};
4109 let Inst{12-5} = 0b01111000;
4111 let Inst{3-0} = Rt{3-0};
4114 // The assembly syntax for these instructions mentions the vector
4115 // register name twice, e.g.
4117 // vmov q2[2], q2[0], r0, r1
4118 // vmov r0, r1, q2[2], q2[0]
4120 // which needs a bit of juggling with MC operand handling.
4122 // For the move _into_ a vector register, the MC operand list also has
4123 // to mention the register name twice: once as the output, and once as
4124 // an extra input to represent where the unchanged half of the output
4125 // register comes from (when this instruction is used in code
4126 // generation). So we arrange that the first mention of the vector reg
4127 // in the instruction is considered by the AsmMatcher to be the output
4128 // ($Qd), and the second one is the input ($QdSrc). Binding them
4129 // together with the existing 'tie' constraint is enough to enforce at
4130 // register allocation time that they have to be the same register.
4132 // For the move _from_ a vector register, there's no way to get round
4133 // the fact that both instances of that register name have to be
4134 // inputs. They have to be the same register again, but this time, we
4135 // can't use a tie constraint, because that has to be between an
4136 // output and an input operand. So this time, we have to arrange that
4137 // the q-reg appears just once in the MC operand list, in spite of
4138 // being mentioned twice in the asm syntax - which needs a custom
4139 // AsmMatchConverter.
4141 def MVE_VMOV_q_rr : MVE_VMOV_64bit<(outs MQPR:$Qd),
4142 (ins MQPR:$QdSrc, rGPR:$Rt, rGPR:$Rt2),
4143 0b1, "$Qd$idx, $QdSrc$idx2, $Rt, $Rt2",
4145 let DecoderMethod = "DecodeMVEVMOVDRegtoQ";
4148 def MVE_VMOV_rr_q : MVE_VMOV_64bit<(outs rGPR:$Rt, rGPR:$Rt2), (ins MQPR:$Qd),
4149 0b0, "$Rt, $Rt2, $Qd$idx, $Qd$idx2", ""> {
4150 let DecoderMethod = "DecodeMVEVMOVQtoDReg";
4151 let AsmMatchConverter = "cvtMVEVMOVQtoDReg";
4154 // end of coproc mov
4156 // start of MVE interleaving load/store
4158 // Base class for the family of interleaving/deinterleaving
4159 // load/stores with names like VLD20.8 and VST43.32.
4160 class MVE_vldst24_base<bit writeback, bit fourregs, bits<2> stage, bits<2> size,
4161 bit load, dag Oops, dag loadIops, dag wbIops,
4162 string iname, string ops,
4163 string cstr, list<dag> pattern=[]>
4164 : MVE_MI<Oops, !con(loadIops, wbIops), NoItinerary, iname, ops, cstr, pattern> {
4168 let Inst{31-22} = 0b1111110010;
4169 let Inst{21} = writeback;
4170 let Inst{20} = load;
4171 let Inst{19-16} = Rn;
4172 let Inst{15-13} = VQd{2-0};
4173 let Inst{12-9} = 0b1111;
4174 let Inst{8-7} = size;
4175 let Inst{6-5} = stage;
4176 let Inst{4-1} = 0b0000;
4177 let Inst{0} = fourregs;
4180 let mayStore = !eq(load,0);
4183 // A parameter class used to encapsulate all the ways the writeback
4184 // variants of VLD20 and friends differ from the non-writeback ones.
4185 class MVE_vldst24_writeback<bit b, dag Oo, dag Io,
4186 string sy="", string c="", string n=""> {
4192 string id_suffix = n;
4195 // Another parameter class that encapsulates the differences between VLD2x
4197 class MVE_vldst24_nvecs<int n, list<int> s, bit b, RegisterOperand vl> {
4199 list<int> stages = s;
4201 RegisterOperand VecList = vl;
4204 // A third parameter class that distinguishes VLDnn.8 from .16 from .32.
4205 class MVE_vldst24_lanesize<int i, bits<2> b> {
4207 bits<2> sizebits = b;
4210 // A base class for each direction of transfer: one for load, one for
4211 // store. I can't make these a fourth independent parametric tuple
4212 // class, because they have to take the nvecs tuple class as a
4213 // parameter, in order to find the right VecList operand type.
4215 class MVE_vld24_base<MVE_vldst24_nvecs n, bits<2> pat, bits<2> size,
4216 MVE_vldst24_writeback wb, string iname,
4217 list<dag> pattern=[]>
4218 : MVE_vldst24_base<wb.writeback, n.bit0, pat, size, 1,
4219 !con((outs n.VecList:$VQd), wb.Oops),
4220 (ins n.VecList:$VQdSrc), wb.Iops,
4221 iname, "$VQd, $Rn" # wb.syntax,
4222 wb.cstr # ",$VQdSrc = $VQd", pattern>;
4224 class MVE_vst24_base<MVE_vldst24_nvecs n, bits<2> pat, bits<2> size,
4225 MVE_vldst24_writeback wb, string iname,
4226 list<dag> pattern=[]>
4227 : MVE_vldst24_base<wb.writeback, n.bit0, pat, size, 0,
4228 wb.Oops, (ins n.VecList:$VQd), wb.Iops,
4229 iname, "$VQd, $Rn" # wb.syntax,
4232 // Actually define all the interleaving loads and stores, by a series
4233 // of nested foreaches over number of vectors (VLD2/VLD4); stage
4234 // within one of those series (VLDx0/VLDx1/VLDx2/VLDx3); size of
4235 // vector lane; writeback or no writeback.
4236 foreach n = [MVE_vldst24_nvecs<2, [0,1], 0, VecList2Q>,
4237 MVE_vldst24_nvecs<4, [0,1,2,3], 1, VecList4Q>] in
4238 foreach stage = n.stages in
4239 foreach s = [MVE_vldst24_lanesize< 8, 0b00>,
4240 MVE_vldst24_lanesize<16, 0b01>,
4241 MVE_vldst24_lanesize<32, 0b10>] in
4242 foreach wb = [MVE_vldst24_writeback<
4243 1, (outs rGPR:$wb), (ins t2_nosp_addr_offset_none:$Rn),
4244 "!", "$Rn.base = $wb", "_wb">,
4245 MVE_vldst24_writeback<0, (outs), (ins t2_addr_offset_none:$Rn)>] in {
4247 // For each case within all of those foreaches, define the actual
4248 // instructions. The def names are made by gluing together pieces
4249 // from all the parameter classes, and will end up being things like
4250 // MVE_VLD20_8 and MVE_VST43_16_wb.
4252 def "MVE_VLD" # n.nvecs # stage # "_" # s.lanesize # wb.id_suffix
4253 : MVE_vld24_base<n, stage, s.sizebits, wb,
4254 "vld" # n.nvecs # stage # "." # s.lanesize>;
4256 def "MVE_VST" # n.nvecs # stage # "_" # s.lanesize # wb.id_suffix
4257 : MVE_vst24_base<n, stage, s.sizebits, wb,
4258 "vst" # n.nvecs # stage # "." # s.lanesize>;
4261 // end of MVE interleaving load/store
4263 // start of MVE predicable load/store
4265 // A parameter class for the direction of transfer.
4266 class MVE_ldst_direction<bit b, dag Oo, dag Io, string c=""> {
4272 def MVE_ld: MVE_ldst_direction<1, (outs MQPR:$Qd), (ins), ",@earlyclobber $Qd">;
4273 def MVE_st: MVE_ldst_direction<0, (outs), (ins MQPR:$Qd)>;
4275 // A parameter class for the size of memory access in a load.
4276 class MVE_memsz<bits<2> e, int s, AddrMode m, string mn, list<string> types> {
4277 bits<2> encoding = e; // opcode bit(s) for encoding
4278 int shift = s; // shift applied to immediate load offset
4281 // For instruction aliases: define the complete list of type
4282 // suffixes at this size, and the canonical ones for loads and
4284 string MnemonicLetter = mn;
4285 int TypeBits = !shl(8, s);
4286 string CanonLoadSuffix = ".u" # TypeBits;
4287 string CanonStoreSuffix = "." # TypeBits;
4288 list<string> suffixes = !foreach(letter, types, "." # letter # TypeBits);
4291 // Instances of MVE_memsz.
4293 // (memD doesn't need an AddrMode, because those are only for
4294 // contiguous loads, and memD is only used by gather/scatters.)
4295 def MVE_memB: MVE_memsz<0b00, 0, AddrModeT2_i7, "b", ["", "u", "s"]>;
4296 def MVE_memH: MVE_memsz<0b01, 1, AddrModeT2_i7s2, "h", ["", "u", "s", "f"]>;
4297 def MVE_memW: MVE_memsz<0b10, 2, AddrModeT2_i7s4, "w", ["", "u", "s", "f"]>;
4298 def MVE_memD: MVE_memsz<0b11, 3, ?, "d", ["", "u", "s", "f"]>;
4300 // This is the base class for all the MVE loads and stores other than
4301 // the interleaving ones. All the non-interleaving loads/stores share
4302 // the characteristic that they operate on just one vector register,
4303 // so they are VPT-predicable.
4305 // The predication operand is vpred_n, for both loads and stores. For
4306 // store instructions, the reason is obvious: if there is no output
4307 // register, there can't be a need for an input parameter giving the
4308 // output register's previous value. Load instructions also don't need
4309 // that input parameter, because unlike MVE data processing
4310 // instructions, predicated loads are defined to set the inactive
4311 // lanes of the output register to zero, instead of preserving their
4313 class MVE_VLDRSTR_base<MVE_ldst_direction dir, bit U, bit P, bit W, bit opc,
4314 dag oops, dag iops, string asm, string suffix,
4315 string ops, string cstr, list<dag> pattern=[]>
4316 : MVE_p<oops, iops, NoItinerary, asm, suffix, ops, vpred_n, cstr, pattern> {
4324 let Inst{20} = dir.load;
4325 let Inst{15-13} = Qd{2-0};
4327 let Inst{11-9} = 0b111;
4329 let mayLoad = dir.load;
4330 let mayStore = !eq(dir.load,0);
4331 let validForTailPredication = 1;
4334 // Contiguous load and store instructions. These come in two main
4335 // categories: same-size loads/stores in which 128 bits of vector
4336 // register is transferred to or from 128 bits of memory in the most
4337 // obvious way, and widening loads / narrowing stores, in which the
4338 // size of memory accessed is less than the size of a vector register,
4339 // so the load instructions sign- or zero-extend each memory value
4340 // into a wider vector lane, and the store instructions truncate
4343 // The instruction mnemonics for these two classes look reasonably
4344 // similar, but the actual encodings are different enough to need two
4345 // separate base classes.
4347 // Contiguous, same size
4348 class MVE_VLDRSTR_cs<MVE_ldst_direction dir, MVE_memsz memsz, bit P, bit W,
4349 dag oops, dag iops, string asm, string suffix,
4350 IndexMode im, string ops, string cstr>
4351 : MVE_VLDRSTR_base<dir, 0, P, W, 1, oops, iops, asm, suffix, ops, cstr> {
4353 let Inst{23} = addr{7};
4354 let Inst{19-16} = addr{11-8};
4355 let Inst{8-7} = memsz.encoding;
4356 let Inst{6-0} = addr{6-0};
4359 // Contiguous, widening/narrowing
4360 class MVE_VLDRSTR_cw<MVE_ldst_direction dir, MVE_memsz memsz, bit U,
4361 bit P, bit W, bits<2> size, dag oops, dag iops,
4362 string asm, string suffix, IndexMode im,
4363 string ops, string cstr>
4364 : MVE_VLDRSTR_base<dir, U, P, W, 0, oops, iops, asm, suffix, ops, cstr> {
4366 let Inst{23} = addr{7};
4367 let Inst{19} = memsz.encoding{0}; // enough to tell 16- from 32-bit
4368 let Inst{18-16} = addr{10-8};
4369 let Inst{8-7} = size;
4370 let Inst{6-0} = addr{6-0};
4375 // Multiclass wrapper on each of the _cw and _cs base classes, to
4376 // generate three writeback modes (none, preindex, postindex).
4378 multiclass MVE_VLDRSTR_cw_m<MVE_ldst_direction dir, MVE_memsz memsz,
4379 string asm, string suffix, bit U, bits<2> size> {
4380 let AM = memsz.AM in {
4381 def "" : MVE_VLDRSTR_cw<
4382 dir, memsz, U, 1, 0, size,
4383 dir.Oops, !con(dir.Iops, (ins taddrmode_imm7<memsz.shift>:$addr)),
4384 asm, suffix, IndexModeNone, "$Qd, $addr", "">;
4386 def _pre : MVE_VLDRSTR_cw<
4387 dir, memsz, U, 1, 1, size,
4388 !con((outs tGPR:$wb), dir.Oops),
4389 !con(dir.Iops, (ins taddrmode_imm7<memsz.shift>:$addr)),
4390 asm, suffix, IndexModePre, "$Qd, $addr!", "$addr.base = $wb"> {
4391 let DecoderMethod = "DecodeMVE_MEM_1_pre<"#memsz.shift#">";
4394 def _post : MVE_VLDRSTR_cw<
4395 dir, memsz, U, 0, 1, size,
4396 !con((outs tGPR:$wb), dir.Oops),
4397 !con(dir.Iops, (ins t_addr_offset_none:$Rn,
4398 t2am_imm7_offset<memsz.shift>:$addr)),
4399 asm, suffix, IndexModePost, "$Qd, $Rn$addr", "$Rn.base = $wb"> {
4401 let Inst{18-16} = Rn{2-0};
4406 multiclass MVE_VLDRSTR_cs_m<MVE_ldst_direction dir, MVE_memsz memsz,
4407 string asm, string suffix> {
4408 let AM = memsz.AM in {
4409 def "" : MVE_VLDRSTR_cs<
4411 dir.Oops, !con(dir.Iops, (ins t2addrmode_imm7<memsz.shift>:$addr)),
4412 asm, suffix, IndexModeNone, "$Qd, $addr", "">;
4414 def _pre : MVE_VLDRSTR_cs<
4416 !con((outs rGPR:$wb), dir.Oops),
4417 !con(dir.Iops, (ins t2addrmode_imm7_pre<memsz.shift>:$addr)),
4418 asm, suffix, IndexModePre, "$Qd, $addr!", "$addr.base = $wb"> {
4419 let DecoderMethod = "DecodeMVE_MEM_2_pre<"#memsz.shift#">";
4422 def _post : MVE_VLDRSTR_cs<
4424 !con((outs rGPR:$wb), dir.Oops),
4425 // We need an !if here to select the base register class,
4426 // because it's legal to write back to SP in a load of this
4427 // type, but not in a store.
4428 !con(dir.Iops, (ins !if(dir.load, t2_addr_offset_none,
4429 t2_nosp_addr_offset_none):$Rn,
4430 t2am_imm7_offset<memsz.shift>:$addr)),
4431 asm, suffix, IndexModePost, "$Qd, $Rn$addr", "$Rn.base = $wb"> {
4433 let Inst{19-16} = Rn{3-0};
4438 // Now actually declare all the contiguous load/stores, via those
4439 // multiclasses. The instruction ids coming out of this are the bare
4440 // names shown in the defm, with _pre or _post appended for writeback,
4441 // e.g. MVE_VLDRBS16, MVE_VSTRB16_pre, MVE_VSTRHU16_post.
4443 defm MVE_VLDRBS16: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "s16", 0, 0b01>;
4444 defm MVE_VLDRBS32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "s32", 0, 0b10>;
4445 defm MVE_VLDRBU16: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "u16", 1, 0b01>;
4446 defm MVE_VLDRBU32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "u32", 1, 0b10>;
4447 defm MVE_VLDRHS32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memH, "vldrh", "s32", 0, 0b10>;
4448 defm MVE_VLDRHU32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memH, "vldrh", "u32", 1, 0b10>;
4450 defm MVE_VLDRBU8: MVE_VLDRSTR_cs_m<MVE_ld, MVE_memB, "vldrb", "u8">;
4451 defm MVE_VLDRHU16: MVE_VLDRSTR_cs_m<MVE_ld, MVE_memH, "vldrh", "u16">;
4452 defm MVE_VLDRWU32: MVE_VLDRSTR_cs_m<MVE_ld, MVE_memW, "vldrw", "u32">;
4454 defm MVE_VSTRB16: MVE_VLDRSTR_cw_m<MVE_st, MVE_memB, "vstrb", "16", 0, 0b01>;
4455 defm MVE_VSTRB32: MVE_VLDRSTR_cw_m<MVE_st, MVE_memB, "vstrb", "32", 0, 0b10>;
4456 defm MVE_VSTRH32: MVE_VLDRSTR_cw_m<MVE_st, MVE_memH, "vstrh", "32", 0, 0b10>;
4458 defm MVE_VSTRBU8 : MVE_VLDRSTR_cs_m<MVE_st, MVE_memB, "vstrb", "8">;
4459 defm MVE_VSTRHU16: MVE_VLDRSTR_cs_m<MVE_st, MVE_memH, "vstrh", "16">;
4460 defm MVE_VSTRWU32: MVE_VLDRSTR_cs_m<MVE_st, MVE_memW, "vstrw", "32">;
4462 // Gather loads / scatter stores whose address operand is of the form
4463 // [Rn,Qm], i.e. a single GPR as the common base address, plus a
4464 // vector of offset from it. ('Load/store this sequence of elements of
4465 // the same array.')
4467 // Like the contiguous family, these loads and stores can widen the
4468 // loaded values / truncate the stored ones, or they can just
4469 // load/store the same size of memory and vector lane. But unlike the
4470 // contiguous family, there's no particular difference in encoding
4471 // between those two cases.
4473 // This family also comes with the option to scale the offset values
4474 // in Qm by the size of the loaded memory (i.e. to treat them as array
4475 // indices), or not to scale them (to treat them as plain byte offsets
4476 // in memory, so that perhaps the loaded values are unaligned). The
4477 // scaled instructions' address operand in assembly looks like
4478 // [Rn,Qm,UXTW #2] or similar.
4481 class MVE_VLDRSTR_rq<MVE_ldst_direction dir, MVE_memsz memsz, bit U,
4482 bits<2> size, bit os, string asm, string suffix, int shift>
4483 : MVE_VLDRSTR_base<dir, U, 0b0, 0b0, 0, dir.Oops,
4484 !con(dir.Iops, (ins mve_addr_rq_shift<shift>:$addr)),
4485 asm, suffix, "$Qd, $addr", dir.cstr> {
4488 let Inst{19-16} = addr{6-3};
4489 let Inst{8-7} = size;
4490 let Inst{6} = memsz.encoding{1};
4492 let Inst{4} = memsz.encoding{0};
4493 let Inst{3-1} = addr{2-0};
4497 // Multiclass that defines the scaled and unscaled versions of an
4498 // instruction, when the memory size is wider than a byte. The scaled
4499 // version gets the default name like MVE_VLDRBU16_rq; the unscaled /
4500 // potentially unaligned version gets a "_u" suffix, e.g.
4501 // MVE_VLDRBU16_rq_u.
4502 multiclass MVE_VLDRSTR_rq_w<MVE_ldst_direction dir, MVE_memsz memsz,
4503 string asm, string suffix, bit U, bits<2> size> {
4504 def _u : MVE_VLDRSTR_rq<dir, memsz, U, size, 0, asm, suffix, 0>;
4505 def "" : MVE_VLDRSTR_rq<dir, memsz, U, size, 1, asm, suffix, memsz.shift>;
4508 // Subclass of MVE_VLDRSTR_rq with the same API as that multiclass,
4509 // for use when the memory size is one byte, so there's no 'scaled'
4510 // version of the instruction at all. (This is encoded as if it were
4511 // unscaled, but named in the default way with no _u suffix.)
4512 class MVE_VLDRSTR_rq_b<MVE_ldst_direction dir, MVE_memsz memsz,
4513 string asm, string suffix, bit U, bits<2> size>
4514 : MVE_VLDRSTR_rq<dir, memsz, U, size, 0, asm, suffix, 0>;
4516 // Actually define all the loads and stores in this family.
4518 def MVE_VLDRBU8_rq : MVE_VLDRSTR_rq_b<MVE_ld, MVE_memB, "vldrb","u8", 1,0b00>;
4519 def MVE_VLDRBU16_rq: MVE_VLDRSTR_rq_b<MVE_ld, MVE_memB, "vldrb","u16", 1,0b01>;
4520 def MVE_VLDRBS16_rq: MVE_VLDRSTR_rq_b<MVE_ld, MVE_memB, "vldrb","s16", 0,0b01>;
4521 def MVE_VLDRBU32_rq: MVE_VLDRSTR_rq_b<MVE_ld, MVE_memB, "vldrb","u32", 1,0b10>;
4522 def MVE_VLDRBS32_rq: MVE_VLDRSTR_rq_b<MVE_ld, MVE_memB, "vldrb","s32", 0,0b10>;
4524 defm MVE_VLDRHU16_rq: MVE_VLDRSTR_rq_w<MVE_ld, MVE_memH, "vldrh","u16", 1,0b01>;
4525 defm MVE_VLDRHU32_rq: MVE_VLDRSTR_rq_w<MVE_ld, MVE_memH, "vldrh","u32", 1,0b10>;
4526 defm MVE_VLDRHS32_rq: MVE_VLDRSTR_rq_w<MVE_ld, MVE_memH, "vldrh","s32", 0,0b10>;
4527 defm MVE_VLDRWU32_rq: MVE_VLDRSTR_rq_w<MVE_ld, MVE_memW, "vldrw","u32", 1,0b10>;
4528 defm MVE_VLDRDU64_rq: MVE_VLDRSTR_rq_w<MVE_ld, MVE_memD, "vldrd","u64", 1,0b11>;
4530 def MVE_VSTRB8_rq : MVE_VLDRSTR_rq_b<MVE_st, MVE_memB, "vstrb","8", 0,0b00>;
4531 def MVE_VSTRB16_rq : MVE_VLDRSTR_rq_b<MVE_st, MVE_memB, "vstrb","16", 0,0b01>;
4532 def MVE_VSTRB32_rq : MVE_VLDRSTR_rq_b<MVE_st, MVE_memB, "vstrb","32", 0,0b10>;
4534 defm MVE_VSTRH16_rq : MVE_VLDRSTR_rq_w<MVE_st, MVE_memH, "vstrh","16", 0,0b01>;
4535 defm MVE_VSTRH32_rq : MVE_VLDRSTR_rq_w<MVE_st, MVE_memH, "vstrh","32", 0,0b10>;
4536 defm MVE_VSTRW32_rq : MVE_VLDRSTR_rq_w<MVE_st, MVE_memW, "vstrw","32", 0,0b10>;
4537 defm MVE_VSTRD64_rq : MVE_VLDRSTR_rq_w<MVE_st, MVE_memD, "vstrd","64", 0,0b11>;
4539 // Gather loads / scatter stores whose address operand is of the form
4540 // [Qm,#imm], i.e. a vector containing a full base address for each
4541 // loaded item, plus an immediate offset applied consistently to all
4542 // of them. ('Load/store the same field from this vector of pointers
4543 // to a structure type.')
4545 // This family requires the vector lane size to be at least 32 bits
4546 // (so there's room for an address in each lane at all). It has no
4547 // widening/narrowing variants. But it does support preindex
4548 // writeback, in which the address vector is updated to hold the
4549 // addresses actually loaded from.
4552 class MVE_VLDRSTR_qi<MVE_ldst_direction dir, MVE_memsz memsz, bit W, dag wbops,
4553 string asm, string wbAsm, string suffix, string cstr = "">
4554 : MVE_VLDRSTR_base<dir, 1, 1, W, 1, !con(wbops, dir.Oops),
4555 !con(dir.Iops, (ins mve_addr_q_shift<memsz.shift>:$addr)),
4556 asm, suffix, "$Qd, $addr" # wbAsm, cstr # dir.cstr> {
4558 let Inst{23} = addr{7};
4559 let Inst{19-17} = addr{10-8};
4561 let Inst{8} = memsz.encoding{0}; // enough to distinguish 32- from 64-bit
4563 let Inst{6-0} = addr{6-0};
4566 // Multiclass that generates the non-writeback and writeback variants.
4567 multiclass MVE_VLDRSTR_qi_m<MVE_ldst_direction dir, MVE_memsz memsz,
4568 string asm, string suffix> {
4569 def "" : MVE_VLDRSTR_qi<dir, memsz, 0, (outs), asm, "", suffix>;
4570 def _pre : MVE_VLDRSTR_qi<dir, memsz, 1, (outs MQPR:$wb), asm, "!", suffix,
4571 "$addr.base = $wb"> {
4572 let DecoderMethod="DecodeMVE_MEM_3_pre<"#memsz.shift#">";
4576 // Actual instruction definitions.
4577 defm MVE_VLDRWU32_qi: MVE_VLDRSTR_qi_m<MVE_ld, MVE_memW, "vldrw", "u32">;
4578 defm MVE_VLDRDU64_qi: MVE_VLDRSTR_qi_m<MVE_ld, MVE_memD, "vldrd", "u64">;
4579 defm MVE_VSTRW32_qi: MVE_VLDRSTR_qi_m<MVE_st, MVE_memW, "vstrw", "32">;
4580 defm MVE_VSTRD64_qi: MVE_VLDRSTR_qi_m<MVE_st, MVE_memD, "vstrd", "64">;
4582 // Define aliases for all the instructions where memory size and
4583 // vector lane size are the same. These are mnemonic aliases, so they
4584 // apply consistently across all of the above families - contiguous
4585 // loads, and both the rq and qi types of gather/scatter.
4587 // Rationale: As long as you're loading (for example) 16-bit memory
4588 // values into 16-bit vector lanes, you can think of them as signed or
4589 // unsigned integers, fp16 or just raw 16-bit blobs and it makes no
4590 // difference. So we permit all of vldrh.16, vldrh.u16, vldrh.s16,
4591 // vldrh.f16 and treat them all as equivalent to the canonical
4592 // spelling (which happens to be .u16 for loads, and just .16 for
4595 foreach vpt_cond = ["", "t", "e"] in
4596 foreach memsz = [MVE_memB, MVE_memH, MVE_memW, MVE_memD] in
4597 foreach suffix = memsz.suffixes in {
4599 // These foreaches are conceptually ifs, implemented by iterating a
4600 // dummy variable over a list with 0 or 1 elements depending on the
4601 // condition. The idea is to iterate over _nearly_ all the suffixes
4602 // in memsz.suffixes, but omit the one we want all the others to alias.
4604 foreach _ = !if(!ne(suffix, memsz.CanonLoadSuffix), [1], []<int>) in
4605 def : MnemonicAlias<
4606 "vldr" # memsz.MnemonicLetter # vpt_cond # suffix,
4607 "vldr" # memsz.MnemonicLetter # vpt_cond # memsz.CanonLoadSuffix>;
4609 foreach _ = !if(!ne(suffix, memsz.CanonStoreSuffix), [1], []<int>) in
4610 def : MnemonicAlias<
4611 "vstr" # memsz.MnemonicLetter # vpt_cond # suffix,
4612 "vstr" # memsz.MnemonicLetter # vpt_cond # memsz.CanonStoreSuffix>;
4615 // end of MVE predicable load/store
4617 class MVE_VPT<string suffix, bits<2> size, dag iops, string asm, list<dag> pattern=[]>
4618 : MVE_MI<(outs ), iops, NoItinerary, !strconcat("vpt", "${Mk}", ".", suffix), asm, "", pattern> {
4623 let Inst{31-23} = 0b111111100;
4624 let Inst{22} = Mk{3};
4625 let Inst{21-20} = size;
4626 let Inst{19-17} = Qn{2-0};
4628 let Inst{15-13} = Mk{2-0};
4629 let Inst{12} = fc{2};
4630 let Inst{11-8} = 0b1111;
4631 let Inst{7} = fc{0};
4635 let validForTailPredication = 1;
4638 class MVE_VPTt1<string suffix, bits<2> size, dag iops>
4639 : MVE_VPT<suffix, size, iops, "$fc, $Qn, $Qm"> {
4644 let Inst{5} = Qm{3};
4645 let Inst{3-1} = Qm{2-0};
4646 let Inst{0} = fc{1};
4647 let validForTailPredication = 1;
4650 class MVE_VPTt1i<string suffix, bits<2> size>
4651 : MVE_VPTt1<suffix, size,
4652 (ins vpt_mask:$Mk, MQPR:$Qn, MQPR:$Qm, pred_basic_i:$fc)> {
4657 def MVE_VPTv4i32 : MVE_VPTt1i<"i32", 0b10>;
4658 def MVE_VPTv8i16 : MVE_VPTt1i<"i16", 0b01>;
4659 def MVE_VPTv16i8 : MVE_VPTt1i<"i8", 0b00>;
4661 class MVE_VPTt1u<string suffix, bits<2> size>
4662 : MVE_VPTt1<suffix, size,
4663 (ins vpt_mask:$Mk, MQPR:$Qn, MQPR:$Qm, pred_basic_u:$fc)> {
4668 def MVE_VPTv4u32 : MVE_VPTt1u<"u32", 0b10>;
4669 def MVE_VPTv8u16 : MVE_VPTt1u<"u16", 0b01>;
4670 def MVE_VPTv16u8 : MVE_VPTt1u<"u8", 0b00>;
4672 class MVE_VPTt1s<string suffix, bits<2> size>
4673 : MVE_VPTt1<suffix, size,
4674 (ins vpt_mask:$Mk, MQPR:$Qn, MQPR:$Qm, pred_basic_s:$fc)> {
4678 def MVE_VPTv4s32 : MVE_VPTt1s<"s32", 0b10>;
4679 def MVE_VPTv8s16 : MVE_VPTt1s<"s16", 0b01>;
4680 def MVE_VPTv16s8 : MVE_VPTt1s<"s8", 0b00>;
4682 class MVE_VPTt2<string suffix, bits<2> size, dag iops>
4683 : MVE_VPT<suffix, size, iops,
4690 let Inst{5} = fc{1};
4691 let Inst{3-0} = Rm{3-0};
4694 class MVE_VPTt2i<string suffix, bits<2> size>
4695 : MVE_VPTt2<suffix, size,
4696 (ins vpt_mask:$Mk, MQPR:$Qn, GPRwithZR:$Rm, pred_basic_i:$fc)> {
4701 def MVE_VPTv4i32r : MVE_VPTt2i<"i32", 0b10>;
4702 def MVE_VPTv8i16r : MVE_VPTt2i<"i16", 0b01>;
4703 def MVE_VPTv16i8r : MVE_VPTt2i<"i8", 0b00>;
4705 class MVE_VPTt2u<string suffix, bits<2> size>
4706 : MVE_VPTt2<suffix, size,
4707 (ins vpt_mask:$Mk, MQPR:$Qn, GPRwithZR:$Rm, pred_basic_u:$fc)> {
4712 def MVE_VPTv4u32r : MVE_VPTt2u<"u32", 0b10>;
4713 def MVE_VPTv8u16r : MVE_VPTt2u<"u16", 0b01>;
4714 def MVE_VPTv16u8r : MVE_VPTt2u<"u8", 0b00>;
4716 class MVE_VPTt2s<string suffix, bits<2> size>
4717 : MVE_VPTt2<suffix, size,
4718 (ins vpt_mask:$Mk, MQPR:$Qn, GPRwithZR:$Rm, pred_basic_s:$fc)> {
4722 def MVE_VPTv4s32r : MVE_VPTt2s<"s32", 0b10>;
4723 def MVE_VPTv8s16r : MVE_VPTt2s<"s16", 0b01>;
4724 def MVE_VPTv16s8r : MVE_VPTt2s<"s8", 0b00>;
4727 class MVE_VPTf<string suffix, bit size, dag iops, string asm, list<dag> pattern=[]>
4728 : MVE_MI<(outs ), iops, NoItinerary, !strconcat("vpt", "${Mk}", ".", suffix), asm,
4734 let Inst{31-29} = 0b111;
4735 let Inst{28} = size;
4736 let Inst{27-23} = 0b11100;
4737 let Inst{22} = Mk{3};
4738 let Inst{21-20} = 0b11;
4739 let Inst{19-17} = Qn{2-0};
4741 let Inst{15-13} = Mk{2-0};
4742 let Inst{12} = fc{2};
4743 let Inst{11-8} = 0b1111;
4744 let Inst{7} = fc{0};
4748 let Predicates = [HasMVEFloat];
4749 let validForTailPredication = 1;
4752 class MVE_VPTft1<string suffix, bit size>
4753 : MVE_VPTf<suffix, size, (ins vpt_mask:$Mk, MQPR:$Qn, MQPR:$Qm, pred_basic_fp:$fc),
4759 let Inst{5} = Qm{3};
4760 let Inst{3-1} = Qm{2-0};
4761 let Inst{0} = fc{1};
4764 def MVE_VPTv4f32 : MVE_VPTft1<"f32", 0b0>;
4765 def MVE_VPTv8f16 : MVE_VPTft1<"f16", 0b1>;
4767 class MVE_VPTft2<string suffix, bit size>
4768 : MVE_VPTf<suffix, size, (ins vpt_mask:$Mk, MQPR:$Qn, GPRwithZR:$Rm, pred_basic_fp:$fc),
4774 let Inst{5} = fc{1};
4775 let Inst{3-0} = Rm{3-0};
4778 def MVE_VPTv4f32r : MVE_VPTft2<"f32", 0b0>;
4779 def MVE_VPTv8f16r : MVE_VPTft2<"f16", 0b1>;
4781 def MVE_VPST : MVE_MI<(outs ), (ins vpt_mask:$Mk), NoItinerary,
4782 !strconcat("vpst", "${Mk}"), "", "", []> {
4785 let Inst{31-23} = 0b111111100;
4786 let Inst{22} = Mk{3};
4787 let Inst{21-16} = 0b110001;
4788 let Inst{15-13} = Mk{2-0};
4789 let Inst{12-0} = 0b0111101001101;
4790 let Unpredictable{12} = 0b1;
4791 let Unpredictable{7} = 0b1;
4792 let Unpredictable{5} = 0b1;
4795 let validForTailPredication = 1;
4798 def MVE_VPSEL : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm), NoItinerary,
4799 "vpsel", "", "$Qd, $Qn, $Qm", vpred_n, "", []> {
4805 let Inst{25-23} = 0b100;
4806 let Inst{22} = Qd{3};
4807 let Inst{21-20} = 0b11;
4808 let Inst{19-17} = Qn{2-0};
4810 let Inst{15-13} = Qd{2-0};
4811 let Inst{12-9} = 0b0111;
4813 let Inst{7} = Qn{3};
4815 let Inst{5} = Qm{3};
4817 let Inst{3-1} = Qm{2-0};
4819 let validForTailPredication = 1;
4822 foreach suffix = ["s8", "s16", "s32", "u8", "u16", "u32",
4823 "i8", "i16", "i32", "f16", "f32"] in
4824 def : MVEInstAlias<"vpsel${vp}." # suffix # "\t$Qd, $Qn, $Qm",
4825 (MVE_VPSEL MQPR:$Qd, MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
4827 let Predicates = [HasMVEInt] in {
4828 def : Pat<(v16i8 (vselect (v16i1 VCCR:$pred), (v16i8 MQPR:$v1), (v16i8 MQPR:$v2))),
4829 (v16i8 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0, VCCR:$pred))>;
4830 def : Pat<(v8i16 (vselect (v8i1 VCCR:$pred), (v8i16 MQPR:$v1), (v8i16 MQPR:$v2))),
4831 (v8i16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0, VCCR:$pred))>;
4832 def : Pat<(v4i32 (vselect (v4i1 VCCR:$pred), (v4i32 MQPR:$v1), (v4i32 MQPR:$v2))),
4833 (v4i32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0, VCCR:$pred))>;
4835 def : Pat<(v8f16 (vselect (v8i1 VCCR:$pred), (v8f16 MQPR:$v1), (v8f16 MQPR:$v2))),
4836 (v8f16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0, VCCR:$pred))>;
4837 def : Pat<(v4f32 (vselect (v4i1 VCCR:$pred), (v4f32 MQPR:$v1), (v4f32 MQPR:$v2))),
4838 (v4f32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0, VCCR:$pred))>;
4840 def : Pat<(v16i8 (vselect (v16i8 MQPR:$pred), (v16i8 MQPR:$v1), (v16i8 MQPR:$v2))),
4841 (v16i8 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0,
4842 (MVE_VCMPi8 (v16i8 MQPR:$pred), (MVE_VMOVimmi8 0), 1)))>;
4843 def : Pat<(v8i16 (vselect (v8i16 MQPR:$pred), (v8i16 MQPR:$v1), (v8i16 MQPR:$v2))),
4844 (v8i16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0,
4845 (MVE_VCMPi16 (v8i16 MQPR:$pred), (MVE_VMOVimmi16 0), 1)))>;
4846 def : Pat<(v4i32 (vselect (v4i32 MQPR:$pred), (v4i32 MQPR:$v1), (v4i32 MQPR:$v2))),
4847 (v4i32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0,
4848 (MVE_VCMPi32 (v4i32 MQPR:$pred), (MVE_VMOVimmi32 0), 1)))>;
4850 def : Pat<(v8f16 (vselect (v8i16 MQPR:$pred), (v8f16 MQPR:$v1), (v8f16 MQPR:$v2))),
4851 (v8f16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0,
4852 (MVE_VCMPi16 (v8i16 MQPR:$pred), (MVE_VMOVimmi16 0), 1)))>;
4853 def : Pat<(v4f32 (vselect (v4i32 MQPR:$pred), (v4f32 MQPR:$v1), (v4f32 MQPR:$v2))),
4854 (v4f32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0,
4855 (MVE_VCMPi32 (v4i32 MQPR:$pred), (MVE_VMOVimmi32 0), 1)))>;
4858 def : Pat<(v16i8 (zext (v16i1 VCCR:$pred))),
4859 (v16i8 (MVE_VPSEL (MVE_VMOVimmi8 1), (MVE_VMOVimmi8 0), 0, VCCR:$pred))>;
4860 def : Pat<(v8i16 (zext (v8i1 VCCR:$pred))),
4861 (v8i16 (MVE_VPSEL (MVE_VMOVimmi16 1), (MVE_VMOVimmi16 0), 0, VCCR:$pred))>;
4862 def : Pat<(v4i32 (zext (v4i1 VCCR:$pred))),
4863 (v4i32 (MVE_VPSEL (MVE_VMOVimmi32 1), (MVE_VMOVimmi32 0), 0, VCCR:$pred))>;
4865 def : Pat<(v16i8 (sext (v16i1 VCCR:$pred))),
4866 (v16i8 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi8 0), 0, VCCR:$pred))>;
4867 def : Pat<(v8i16 (sext (v8i1 VCCR:$pred))),
4868 (v8i16 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi16 0), 0, VCCR:$pred))>;
4869 def : Pat<(v4i32 (sext (v4i1 VCCR:$pred))),
4870 (v4i32 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi32 0), 0, VCCR:$pred))>;
4872 def : Pat<(v16i8 (anyext (v16i1 VCCR:$pred))),
4873 (v16i8 (MVE_VPSEL (MVE_VMOVimmi8 1), (MVE_VMOVimmi8 0), 0, VCCR:$pred))>;
4874 def : Pat<(v8i16 (anyext (v8i1 VCCR:$pred))),
4875 (v8i16 (MVE_VPSEL (MVE_VMOVimmi16 1), (MVE_VMOVimmi16 0), 0, VCCR:$pred))>;
4876 def : Pat<(v4i32 (anyext (v4i1 VCCR:$pred))),
4877 (v4i32 (MVE_VPSEL (MVE_VMOVimmi32 1), (MVE_VMOVimmi32 0), 0, VCCR:$pred))>;
4879 def : Pat<(v16i1 (trunc (v16i8 MQPR:$v1))),
4880 (v16i1 (MVE_VCMPi32r (v16i8 MQPR:$v1), ZR, 1))>;
4881 def : Pat<(v8i1 (trunc (v8i16 MQPR:$v1))),
4882 (v8i1 (MVE_VCMPi32r (v8i16 MQPR:$v1), ZR, 1))>;
4883 def : Pat<(v4i1 (trunc (v4i32 MQPR:$v1))),
4884 (v4i1 (MVE_VCMPi32r (v4i32 MQPR:$v1), ZR, 1))>;
4887 let Predicates = [HasMVEFloat] in {
4889 // 112 is 1.0 in float
4890 def : Pat<(v4f32 (uint_to_fp (v4i1 VCCR:$pred))),
4891 (v4f32 (MVE_VPSEL (v4f32 (MVE_VMOVimmf32 112)), (v4f32 (MVE_VMOVimmi32 0)), 0, VCCR:$pred))>;
4892 // 2620 in 1.0 in half
4893 def : Pat<(v8f16 (uint_to_fp (v8i1 VCCR:$pred))),
4894 (v8f16 (MVE_VPSEL (v8f16 (MVE_VMOVimmi16 2620)), (v8f16 (MVE_VMOVimmi16 0)), 0, VCCR:$pred))>;
4895 // 240 is -1.0 in float
4896 def : Pat<(v4f32 (sint_to_fp (v4i1 VCCR:$pred))),
4897 (v4f32 (MVE_VPSEL (v4f32 (MVE_VMOVimmf32 240)), (v4f32 (MVE_VMOVimmi32 0)), 0, VCCR:$pred))>;
4898 // 2748 is -1.0 in half
4899 def : Pat<(v8f16 (sint_to_fp (v8i1 VCCR:$pred))),
4900 (v8f16 (MVE_VPSEL (v8f16 (MVE_VMOVimmi16 2748)), (v8f16 (MVE_VMOVimmi16 0)), 0, VCCR:$pred))>;
4902 def : Pat<(v4i1 (fp_to_uint (v4f32 MQPR:$v1))),
4903 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, 1))>;
4904 def : Pat<(v8i1 (fp_to_uint (v8f16 MQPR:$v1))),
4905 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), ZR, 1))>;
4906 def : Pat<(v4i1 (fp_to_sint (v4f32 MQPR:$v1))),
4907 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, 1))>;
4908 def : Pat<(v8i1 (fp_to_sint (v8f16 MQPR:$v1))),
4909 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), ZR, 1))>;
4912 def MVE_VPNOT : MVE_p<(outs VCCR:$P0), (ins VCCR:$P0_in), NoItinerary,
4913 "vpnot", "", "", vpred_n, "", []> {
4914 let Inst{31-0} = 0b11111110001100010000111101001101;
4915 let Unpredictable{19-17} = 0b111;
4916 let Unpredictable{12} = 0b1;
4917 let Unpredictable{7} = 0b1;
4918 let Unpredictable{5} = 0b1;
4920 let Constraints = "";
4921 let DecoderMethod = "DecodeMVEVPNOT";
4924 let Predicates = [HasMVEInt] in {
4925 def : Pat<(v4i1 (xor (v4i1 VCCR:$pred), (v4i1 (predicate_cast (i32 65535))))),
4926 (v4i1 (MVE_VPNOT (v4i1 VCCR:$pred)))>;
4927 def : Pat<(v8i1 (xor (v8i1 VCCR:$pred), (v8i1 (predicate_cast (i32 65535))))),
4928 (v8i1 (MVE_VPNOT (v8i1 VCCR:$pred)))>;
4929 def : Pat<(v16i1 (xor (v16i1 VCCR:$pred), (v16i1 (predicate_cast (i32 65535))))),
4930 (v16i1 (MVE_VPNOT (v16i1 VCCR:$pred)))>;
4934 class MVE_loltp_start<dag iops, string asm, string ops, bits<2> size>
4935 : t2LOL<(outs GPRlr:$LR), iops, asm, ops> {
4937 let Predicates = [HasMVEInt];
4939 let Inst{21-20} = size;
4940 let Inst{19-16} = Rn{3-0};
4944 class MVE_DLSTP<string asm, bits<2> size>
4945 : MVE_loltp_start<(ins rGPR:$Rn), asm, "$LR, $Rn", size> {
4947 let Inst{11-1} = 0b00000000000;
4948 let Unpredictable{10-1} = 0b1111111111;
4951 class MVE_WLSTP<string asm, bits<2> size>
4952 : MVE_loltp_start<(ins rGPR:$Rn, wlslabel_u11:$label),
4953 asm, "$LR, $Rn, $label", size> {
4956 let Inst{11} = label{0};
4957 let Inst{10-1} = label{10-1};
4960 def MVE_DLSTP_8 : MVE_DLSTP<"dlstp.8", 0b00>;
4961 def MVE_DLSTP_16 : MVE_DLSTP<"dlstp.16", 0b01>;
4962 def MVE_DLSTP_32 : MVE_DLSTP<"dlstp.32", 0b10>;
4963 def MVE_DLSTP_64 : MVE_DLSTP<"dlstp.64", 0b11>;
4965 def MVE_WLSTP_8 : MVE_WLSTP<"wlstp.8", 0b00>;
4966 def MVE_WLSTP_16 : MVE_WLSTP<"wlstp.16", 0b01>;
4967 def MVE_WLSTP_32 : MVE_WLSTP<"wlstp.32", 0b10>;
4968 def MVE_WLSTP_64 : MVE_WLSTP<"wlstp.64", 0b11>;
4970 class MVE_loltp_end<dag oops, dag iops, string asm, string ops>
4971 : t2LOL<oops, iops, asm, ops> {
4972 let Predicates = [HasMVEInt];
4973 let Inst{22-21} = 0b00;
4974 let Inst{19-16} = 0b1111;
4978 def MVE_LETP : MVE_loltp_end<(outs GPRlr:$LRout),
4979 (ins GPRlr:$LRin, lelabel_u11:$label),
4980 "letp", "$LRin, $label"> {
4984 let Inst{11} = label{0};
4985 let Inst{10-1} = label{10-1};
4988 def MVE_LCTP : MVE_loltp_end<(outs), (ins pred:$p), "lctp${p}", ""> {
4991 let Inst{11-1} = 0b00000000000;
4992 let Unpredictable{21-20} = 0b11;
4993 let Unpredictable{11-1} = 0b11111111111;
4997 //===----------------------------------------------------------------------===//
4999 //===----------------------------------------------------------------------===//
5001 class MVE_vector_store_typed<ValueType Ty, Instruction RegImmInst,
5002 PatFrag StoreKind, int shift>
5003 : Pat<(StoreKind (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr),
5004 (RegImmInst (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr)>;
5005 class MVE_vector_maskedstore_typed<ValueType Ty, Instruction RegImmInst,
5006 PatFrag StoreKind, int shift>
5007 : Pat<(StoreKind (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr, VCCR:$pred),
5008 (RegImmInst (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr, (i32 1), VCCR:$pred)>;
5010 multiclass MVE_vector_store<Instruction RegImmInst, PatFrag StoreKind,
5012 def : MVE_vector_store_typed<v16i8, RegImmInst, StoreKind, shift>;
5013 def : MVE_vector_store_typed<v8i16, RegImmInst, StoreKind, shift>;
5014 def : MVE_vector_store_typed<v8f16, RegImmInst, StoreKind, shift>;
5015 def : MVE_vector_store_typed<v4i32, RegImmInst, StoreKind, shift>;
5016 def : MVE_vector_store_typed<v4f32, RegImmInst, StoreKind, shift>;
5017 def : MVE_vector_store_typed<v2i64, RegImmInst, StoreKind, shift>;
5018 def : MVE_vector_store_typed<v2f64, RegImmInst, StoreKind, shift>;
5021 class MVE_vector_load_typed<ValueType Ty, Instruction RegImmInst,
5022 PatFrag LoadKind, int shift>
5023 : Pat<(Ty (LoadKind t2addrmode_imm7<shift>:$addr)),
5024 (Ty (RegImmInst t2addrmode_imm7<shift>:$addr))>;
5025 class MVE_vector_maskedload_typed<ValueType Ty, Instruction RegImmInst,
5026 PatFrag LoadKind, int shift>
5027 : Pat<(Ty (LoadKind t2addrmode_imm7<shift>:$addr, VCCR:$pred, (Ty NEONimmAllZerosV))),
5028 (Ty (RegImmInst t2addrmode_imm7<shift>:$addr, (i32 1), VCCR:$pred))>;
5030 multiclass MVE_vector_load<Instruction RegImmInst, PatFrag LoadKind,
5032 def : MVE_vector_load_typed<v16i8, RegImmInst, LoadKind, shift>;
5033 def : MVE_vector_load_typed<v8i16, RegImmInst, LoadKind, shift>;
5034 def : MVE_vector_load_typed<v8f16, RegImmInst, LoadKind, shift>;
5035 def : MVE_vector_load_typed<v4i32, RegImmInst, LoadKind, shift>;
5036 def : MVE_vector_load_typed<v4f32, RegImmInst, LoadKind, shift>;
5037 def : MVE_vector_load_typed<v2i64, RegImmInst, LoadKind, shift>;
5038 def : MVE_vector_load_typed<v2f64, RegImmInst, LoadKind, shift>;
5041 class MVE_vector_offset_store_typed<ValueType Ty, Instruction Opcode,
5042 PatFrag StoreKind, int shift>
5043 : Pat<(StoreKind (Ty MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<shift>:$addr),
5044 (Opcode MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<shift>:$addr)>;
5046 multiclass MVE_vector_offset_store<Instruction RegImmInst, PatFrag StoreKind,
5048 def : MVE_vector_offset_store_typed<v16i8, RegImmInst, StoreKind, shift>;
5049 def : MVE_vector_offset_store_typed<v8i16, RegImmInst, StoreKind, shift>;
5050 def : MVE_vector_offset_store_typed<v8f16, RegImmInst, StoreKind, shift>;
5051 def : MVE_vector_offset_store_typed<v4i32, RegImmInst, StoreKind, shift>;
5052 def : MVE_vector_offset_store_typed<v4f32, RegImmInst, StoreKind, shift>;
5053 def : MVE_vector_offset_store_typed<v2i64, RegImmInst, StoreKind, shift>;
5054 def : MVE_vector_offset_store_typed<v2f64, RegImmInst, StoreKind, shift>;
5057 def aligned32_pre_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
5058 (pre_store node:$val, node:$ptr, node:$offset), [{
5059 return cast<StoreSDNode>(N)->getAlignment() >= 4;
5061 def aligned32_post_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
5062 (post_store node:$val, node:$ptr, node:$offset), [{
5063 return cast<StoreSDNode>(N)->getAlignment() >= 4;
5065 def aligned16_pre_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
5066 (pre_store node:$val, node:$ptr, node:$offset), [{
5067 return cast<StoreSDNode>(N)->getAlignment() >= 2;
5069 def aligned16_post_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
5070 (post_store node:$val, node:$ptr, node:$offset), [{
5071 return cast<StoreSDNode>(N)->getAlignment() >= 2;
5075 def maskedload8 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
5076 (masked_ld node:$ptr, node:$pred, node:$passthru), [{
5077 auto *Ld = cast<MaskedLoadSDNode>(N);
5078 return Ld->getMemoryVT().getScalarType() == MVT::i8;
5080 def sextmaskedload8 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
5081 (maskedload8 node:$ptr, node:$pred, node:$passthru), [{
5082 return cast<MaskedLoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
5084 def zextmaskedload8 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
5085 (maskedload8 node:$ptr, node:$pred, node:$passthru), [{
5086 return cast<MaskedLoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
5088 def extmaskedload8 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
5089 (maskedload8 node:$ptr, node:$pred, node:$passthru), [{
5090 auto *Ld = cast<MaskedLoadSDNode>(N);
5091 EVT ScalarVT = Ld->getMemoryVT().getScalarType();
5092 return ScalarVT.isInteger() && Ld->getExtensionType() == ISD::EXTLOAD;
5094 def alignedmaskedload16: PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
5095 (masked_ld node:$ptr, node:$pred, node:$passthru), [{
5096 auto *Ld = cast<MaskedLoadSDNode>(N);
5097 EVT ScalarVT = Ld->getMemoryVT().getScalarType();
5098 return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && Ld->getAlignment() >= 2;
5100 def sextmaskedload16 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
5101 (alignedmaskedload16 node:$ptr, node:$pred, node:$passthru), [{
5102 return cast<MaskedLoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
5104 def zextmaskedload16 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
5105 (alignedmaskedload16 node:$ptr, node:$pred, node:$passthru), [{
5106 return cast<MaskedLoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
5108 def extmaskedload16 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
5109 (alignedmaskedload16 node:$ptr, node:$pred, node:$passthru), [{
5110 auto *Ld = cast<MaskedLoadSDNode>(N);
5111 EVT ScalarVT = Ld->getMemoryVT().getScalarType();
5112 return ScalarVT.isInteger() && Ld->getExtensionType() == ISD::EXTLOAD;
5114 def alignedmaskedload32: PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
5115 (masked_ld node:$ptr, node:$pred, node:$passthru), [{
5116 auto *Ld = cast<MaskedLoadSDNode>(N);
5117 EVT ScalarVT = Ld->getMemoryVT().getScalarType();
5118 return (ScalarVT == MVT::i32 || ScalarVT == MVT::f32) && Ld->getAlignment() >= 4;
5121 def maskedstore8 : PatFrag<(ops node:$val, node:$ptr, node:$pred),
5122 (masked_st node:$val, node:$ptr, node:$pred), [{
5123 return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8;
5125 def truncatingmaskedstore8 : PatFrag<(ops node:$val, node:$ptr, node:$pred),
5126 (maskedstore8 node:$val, node:$ptr, node:$pred), [{
5127 return cast<MaskedStoreSDNode>(N)->isTruncatingStore();
5129 def maskedstore16 : PatFrag<(ops node:$val, node:$ptr, node:$pred),
5130 (masked_st node:$val, node:$ptr, node:$pred), [{
5131 auto *St = cast<MaskedStoreSDNode>(N);
5132 EVT ScalarVT = St->getMemoryVT().getScalarType();
5133 return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlignment() >= 2;
5136 def truncatingmaskedstore16 : PatFrag<(ops node:$val, node:$ptr, node:$pred),
5137 (maskedstore16 node:$val, node:$ptr, node:$pred), [{
5138 return cast<MaskedStoreSDNode>(N)->isTruncatingStore();
5140 def maskedstore32 : PatFrag<(ops node:$val, node:$ptr, node:$pred),
5141 (masked_st node:$val, node:$ptr, node:$pred), [{
5142 auto *St = cast<MaskedStoreSDNode>(N);
5143 EVT ScalarVT = St->getMemoryVT().getScalarType();
5144 return (ScalarVT == MVT::i32 || ScalarVT == MVT::f32) && St->getAlignment() >= 4;
5147 let Predicates = [HasMVEInt, IsLE] in {
5149 defm : MVE_vector_store<MVE_VSTRBU8, byte_alignedstore, 0>;
5150 defm : MVE_vector_store<MVE_VSTRHU16, hword_alignedstore, 1>;
5151 defm : MVE_vector_store<MVE_VSTRWU32, alignedstore32, 2>;
5154 defm : MVE_vector_load<MVE_VLDRBU8, byte_alignedload, 0>;
5155 defm : MVE_vector_load<MVE_VLDRHU16, hword_alignedload, 1>;
5156 defm : MVE_vector_load<MVE_VLDRWU32, alignedload32, 2>;
5158 // Pre/post inc stores
5159 defm : MVE_vector_offset_store<MVE_VSTRBU8_pre, pre_store, 0>;
5160 defm : MVE_vector_offset_store<MVE_VSTRBU8_post, post_store, 0>;
5161 defm : MVE_vector_offset_store<MVE_VSTRHU16_pre, aligned16_pre_store, 1>;
5162 defm : MVE_vector_offset_store<MVE_VSTRHU16_post, aligned16_post_store, 1>;
5163 defm : MVE_vector_offset_store<MVE_VSTRWU32_pre, aligned32_pre_store, 2>;
5164 defm : MVE_vector_offset_store<MVE_VSTRWU32_post, aligned32_post_store, 2>;
5167 let Predicates = [HasMVEInt, IsBE] in {
5169 def : MVE_vector_store_typed<v16i8, MVE_VSTRBU8, store, 0>;
5170 def : MVE_vector_store_typed<v8i16, MVE_VSTRHU16, alignedstore16, 1>;
5171 def : MVE_vector_store_typed<v8f16, MVE_VSTRHU16, alignedstore16, 1>;
5172 def : MVE_vector_store_typed<v4i32, MVE_VSTRWU32, alignedstore32, 2>;
5173 def : MVE_vector_store_typed<v4f32, MVE_VSTRWU32, alignedstore32, 2>;
5176 def : MVE_vector_load_typed<v16i8, MVE_VLDRBU8, load, 0>;
5177 def : MVE_vector_load_typed<v8i16, MVE_VLDRHU16, alignedload16, 1>;
5178 def : MVE_vector_load_typed<v8f16, MVE_VLDRHU16, alignedload16, 1>;
5179 def : MVE_vector_load_typed<v4i32, MVE_VLDRWU32, alignedload32, 2>;
5180 def : MVE_vector_load_typed<v4f32, MVE_VLDRWU32, alignedload32, 2>;
5182 // Other unaligned loads/stores need to go though a VREV
5183 def : Pat<(v2f64 (load t2addrmode_imm7<0>:$addr)),
5184 (v2f64 (MVE_VREV64_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
5185 def : Pat<(v2i64 (load t2addrmode_imm7<0>:$addr)),
5186 (v2i64 (MVE_VREV64_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
5187 def : Pat<(v4i32 (load t2addrmode_imm7<0>:$addr)),
5188 (v4i32 (MVE_VREV32_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
5189 def : Pat<(v4f32 (load t2addrmode_imm7<0>:$addr)),
5190 (v4f32 (MVE_VREV32_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
5191 def : Pat<(v8i16 (load t2addrmode_imm7<0>:$addr)),
5192 (v8i16 (MVE_VREV16_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
5193 def : Pat<(v8f16 (load t2addrmode_imm7<0>:$addr)),
5194 (v8f16 (MVE_VREV16_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
5195 def : Pat<(store (v2f64 MQPR:$val), t2addrmode_imm7<0>:$addr),
5196 (MVE_VSTRBU8 (MVE_VREV64_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
5197 def : Pat<(store (v2i64 MQPR:$val), t2addrmode_imm7<0>:$addr),
5198 (MVE_VSTRBU8 (MVE_VREV64_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
5199 def : Pat<(store (v4i32 MQPR:$val), t2addrmode_imm7<0>:$addr),
5200 (MVE_VSTRBU8 (MVE_VREV32_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
5201 def : Pat<(store (v4f32 MQPR:$val), t2addrmode_imm7<0>:$addr),
5202 (MVE_VSTRBU8 (MVE_VREV32_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
5203 def : Pat<(store (v8i16 MQPR:$val), t2addrmode_imm7<0>:$addr),
5204 (MVE_VSTRBU8 (MVE_VREV16_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
5205 def : Pat<(store (v8f16 MQPR:$val), t2addrmode_imm7<0>:$addr),
5206 (MVE_VSTRBU8 (MVE_VREV16_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
5208 // Pre/Post inc stores
5209 def : MVE_vector_offset_store_typed<v16i8, MVE_VSTRBU8_pre, pre_store, 0>;
5210 def : MVE_vector_offset_store_typed<v16i8, MVE_VSTRBU8_post, post_store, 0>;
5211 def : MVE_vector_offset_store_typed<v8i16, MVE_VSTRHU16_pre, aligned16_pre_store, 1>;
5212 def : MVE_vector_offset_store_typed<v8i16, MVE_VSTRHU16_post, aligned16_post_store, 1>;
5213 def : MVE_vector_offset_store_typed<v8f16, MVE_VSTRHU16_pre, aligned16_pre_store, 1>;
5214 def : MVE_vector_offset_store_typed<v8f16, MVE_VSTRHU16_post, aligned16_post_store, 1>;
5215 def : MVE_vector_offset_store_typed<v4i32, MVE_VSTRWU32_pre, aligned32_pre_store, 2>;
5216 def : MVE_vector_offset_store_typed<v4i32, MVE_VSTRWU32_post, aligned32_post_store, 2>;
5217 def : MVE_vector_offset_store_typed<v4f32, MVE_VSTRWU32_pre, aligned32_pre_store, 2>;
5218 def : MVE_vector_offset_store_typed<v4f32, MVE_VSTRWU32_post, aligned32_post_store, 2>;
5221 let Predicates = [HasMVEInt] in {
5222 // Aligned masked store, shared between LE and BE
5223 def : MVE_vector_maskedstore_typed<v16i8, MVE_VSTRBU8, maskedstore8, 0>;
5224 def : MVE_vector_maskedstore_typed<v8i16, MVE_VSTRHU16, maskedstore16, 1>;
5225 def : MVE_vector_maskedstore_typed<v8f16, MVE_VSTRHU16, maskedstore16, 1>;
5226 def : MVE_vector_maskedstore_typed<v4i32, MVE_VSTRWU32, maskedstore32, 2>;
5227 def : MVE_vector_maskedstore_typed<v4f32, MVE_VSTRWU32, maskedstore32, 2>;
5228 // Truncating stores
5229 def : Pat<(truncatingmaskedstore8 (v8i16 MQPR:$val), t2addrmode_imm7<0>:$addr, VCCR:$pred),
5230 (MVE_VSTRB16 MQPR:$val, t2addrmode_imm7<0>:$addr, (i32 1), VCCR:$pred)>;
5231 def : Pat<(truncatingmaskedstore8 (v4i32 MQPR:$val), t2addrmode_imm7<0>:$addr, VCCR:$pred),
5232 (MVE_VSTRB32 MQPR:$val, t2addrmode_imm7<0>:$addr, (i32 1), VCCR:$pred)>;
5233 def : Pat<(truncatingmaskedstore16 (v4i32 MQPR:$val), t2addrmode_imm7<1>:$addr, VCCR:$pred),
5234 (MVE_VSTRH32 MQPR:$val, t2addrmode_imm7<1>:$addr, (i32 1), VCCR:$pred)>;
5235 // Aligned masked loads
5236 def : MVE_vector_maskedload_typed<v16i8, MVE_VLDRBU8, maskedload8, 0>;
5237 def : MVE_vector_maskedload_typed<v8i16, MVE_VLDRHU16, alignedmaskedload16, 1>;
5238 def : MVE_vector_maskedload_typed<v8f16, MVE_VLDRHU16, alignedmaskedload16, 1>;
5239 def : MVE_vector_maskedload_typed<v4i32, MVE_VLDRWU32, alignedmaskedload32, 2>;
5240 def : MVE_vector_maskedload_typed<v4f32, MVE_VLDRWU32, alignedmaskedload32, 2>;
5241 // Extending masked loads.
5242 def : Pat<(v8i16 (sextmaskedload8 t2addrmode_imm7<0>:$addr, VCCR:$pred,
5243 (v8i16 NEONimmAllZerosV))),
5244 (v8i16 (MVE_VLDRBS16 t2addrmode_imm7<0>:$addr, (i32 1), VCCR:$pred))>;
5245 def : Pat<(v4i32 (sextmaskedload8 t2addrmode_imm7<0>:$addr, VCCR:$pred,
5246 (v4i32 NEONimmAllZerosV))),
5247 (v4i32 (MVE_VLDRBS32 t2addrmode_imm7<0>:$addr, (i32 1), VCCR:$pred))>;
5248 def : Pat<(v8i16 (zextmaskedload8 t2addrmode_imm7<0>:$addr, VCCR:$pred,
5249 (v8i16 NEONimmAllZerosV))),
5250 (v8i16 (MVE_VLDRBU16 t2addrmode_imm7<0>:$addr, (i32 1), VCCR:$pred))>;
5251 def : Pat<(v4i32 (zextmaskedload8 t2addrmode_imm7<0>:$addr, VCCR:$pred,
5252 (v4i32 NEONimmAllZerosV))),
5253 (v4i32 (MVE_VLDRBU32 t2addrmode_imm7<0>:$addr, (i32 1), VCCR:$pred))>;
5254 def : Pat<(v8i16 (extmaskedload8 t2addrmode_imm7<0>:$addr, VCCR:$pred,
5255 (v8i16 NEONimmAllZerosV))),
5256 (v8i16 (MVE_VLDRBU16 t2addrmode_imm7<0>:$addr, (i32 1), VCCR:$pred))>;
5257 def : Pat<(v4i32 (extmaskedload8 t2addrmode_imm7<0>:$addr, VCCR:$pred,
5258 (v4i32 NEONimmAllZerosV))),
5259 (v4i32 (MVE_VLDRBU32 t2addrmode_imm7<0>:$addr, (i32 1), VCCR:$pred))>;
5260 def : Pat<(v4i32 (sextmaskedload16 t2addrmode_imm7<1>:$addr, VCCR:$pred,
5261 (v4i32 NEONimmAllZerosV))),
5262 (v4i32 (MVE_VLDRHS32 t2addrmode_imm7<1>:$addr, (i32 1), VCCR:$pred))>;
5263 def : Pat<(v4i32 (zextmaskedload16 t2addrmode_imm7<1>:$addr, VCCR:$pred,
5264 (v4i32 NEONimmAllZerosV))),
5265 (v4i32 (MVE_VLDRHU32 t2addrmode_imm7<1>:$addr, (i32 1), VCCR:$pred))>;
5266 def : Pat<(v4i32 (extmaskedload16 t2addrmode_imm7<1>:$addr, VCCR:$pred,
5267 (v4i32 NEONimmAllZerosV))),
5268 (v4i32 (MVE_VLDRHU32 t2addrmode_imm7<1>:$addr, (i32 1), VCCR:$pred))>;
5271 // Widening/Narrowing Loads/Stores
5273 let MinAlignment = 2 in {
5274 def truncstorevi16_align2 : PatFrag<(ops node:$val, node:$ptr),
5275 (truncstorevi16 node:$val, node:$ptr)>;
5276 def post_truncstvi16_align2 : PatFrag<(ops node:$val, node:$base, node:$offset),
5277 (post_truncstvi16 node:$val, node:$base, node:$offset)>;
5278 def pre_truncstvi16_align2 : PatFrag<(ops node:$val, node:$base, node:$offset),
5279 (pre_truncstvi16 node:$val, node:$base, node:$offset)>;
5282 let Predicates = [HasMVEInt] in {
5283 def : Pat<(truncstorevi8 (v8i16 MQPR:$val), taddrmode_imm7<0>:$addr),
5284 (MVE_VSTRB16 MQPR:$val, taddrmode_imm7<0>:$addr)>;
5285 def : Pat<(truncstorevi8 (v4i32 MQPR:$val), taddrmode_imm7<0>:$addr),
5286 (MVE_VSTRB32 MQPR:$val, taddrmode_imm7<0>:$addr)>;
5287 def : Pat<(truncstorevi16_align2 (v4i32 MQPR:$val), taddrmode_imm7<1>:$addr),
5288 (MVE_VSTRH32 MQPR:$val, taddrmode_imm7<1>:$addr)>;
5290 def : Pat<(post_truncstvi8 (v8i16 MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<0>:$addr),
5291 (MVE_VSTRB16_post MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<0>:$addr)>;
5292 def : Pat<(post_truncstvi8 (v4i32 MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<0>:$addr),
5293 (MVE_VSTRB32_post MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<0>:$addr)>;
5294 def : Pat<(post_truncstvi16_align2 (v4i32 MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<1>:$addr),
5295 (MVE_VSTRH32_post MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<1>:$addr)>;
5297 def : Pat<(pre_truncstvi8 (v8i16 MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<0>:$addr),
5298 (MVE_VSTRB16_pre MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<0>:$addr)>;
5299 def : Pat<(pre_truncstvi8 (v4i32 MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<0>:$addr),
5300 (MVE_VSTRB32_pre MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<0>:$addr)>;
5301 def : Pat<(pre_truncstvi16_align2 (v4i32 MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<1>:$addr),
5302 (MVE_VSTRH32_pre MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<1>:$addr)>;
5306 let MinAlignment = 2 in {
5307 def extloadvi16_align2 : PatFrag<(ops node:$ptr), (extloadvi16 node:$ptr)>;
5308 def sextloadvi16_align2 : PatFrag<(ops node:$ptr), (sextloadvi16 node:$ptr)>;
5309 def zextloadvi16_align2 : PatFrag<(ops node:$ptr), (zextloadvi16 node:$ptr)>;
5312 multiclass MVEExtLoad<string DestLanes, string DestElemBits,
5313 string SrcElemBits, string SrcElemType,
5314 string Align, Operand am> {
5315 def _Any : Pat<(!cast<ValueType>("v" # DestLanes # "i" # DestElemBits)
5316 (!cast<PatFrag>("extloadvi" # SrcElemBits # Align) am:$addr)),
5317 (!cast<Instruction>("MVE_VLDR" # SrcElemType # "U" # DestElemBits)
5319 def _Z : Pat<(!cast<ValueType>("v" # DestLanes # "i" # DestElemBits)
5320 (!cast<PatFrag>("zextloadvi" # SrcElemBits # Align) am:$addr)),
5321 (!cast<Instruction>("MVE_VLDR" # SrcElemType # "U" # DestElemBits)
5323 def _S : Pat<(!cast<ValueType>("v" # DestLanes # "i" # DestElemBits)
5324 (!cast<PatFrag>("sextloadvi" # SrcElemBits # Align) am:$addr)),
5325 (!cast<Instruction>("MVE_VLDR" # SrcElemType # "S" # DestElemBits)
5329 let Predicates = [HasMVEInt] in {
5330 defm : MVEExtLoad<"4", "32", "8", "B", "", taddrmode_imm7<0>>;
5331 defm : MVEExtLoad<"8", "16", "8", "B", "", taddrmode_imm7<0>>;
5332 defm : MVEExtLoad<"4", "32", "16", "H", "_align2", taddrmode_imm7<1>>;
5336 // Bit convert patterns
5338 let Predicates = [HasMVEInt] in {
5339 def : Pat<(v2f64 (bitconvert (v2i64 MQPR:$src))), (v2f64 MQPR:$src)>;
5340 def : Pat<(v2i64 (bitconvert (v2f64 MQPR:$src))), (v2i64 MQPR:$src)>;
5342 def : Pat<(v4i32 (bitconvert (v4f32 MQPR:$src))), (v4i32 MQPR:$src)>;
5343 def : Pat<(v4f32 (bitconvert (v4i32 MQPR:$src))), (v4f32 MQPR:$src)>;
5345 def : Pat<(v8i16 (bitconvert (v8f16 MQPR:$src))), (v8i16 MQPR:$src)>;
5346 def : Pat<(v8f16 (bitconvert (v8i16 MQPR:$src))), (v8f16 MQPR:$src)>;
5349 let Predicates = [IsLE,HasMVEInt] in {
5350 def : Pat<(v2f64 (bitconvert (v4f32 MQPR:$src))), (v2f64 MQPR:$src)>;
5351 def : Pat<(v2f64 (bitconvert (v4i32 MQPR:$src))), (v2f64 MQPR:$src)>;
5352 def : Pat<(v2f64 (bitconvert (v8f16 MQPR:$src))), (v2f64 MQPR:$src)>;
5353 def : Pat<(v2f64 (bitconvert (v8i16 MQPR:$src))), (v2f64 MQPR:$src)>;
5354 def : Pat<(v2f64 (bitconvert (v16i8 MQPR:$src))), (v2f64 MQPR:$src)>;
5356 def : Pat<(v2i64 (bitconvert (v4f32 MQPR:$src))), (v2i64 MQPR:$src)>;
5357 def : Pat<(v2i64 (bitconvert (v4i32 MQPR:$src))), (v2i64 MQPR:$src)>;
5358 def : Pat<(v2i64 (bitconvert (v8f16 MQPR:$src))), (v2i64 MQPR:$src)>;
5359 def : Pat<(v2i64 (bitconvert (v8i16 MQPR:$src))), (v2i64 MQPR:$src)>;
5360 def : Pat<(v2i64 (bitconvert (v16i8 MQPR:$src))), (v2i64 MQPR:$src)>;
5362 def : Pat<(v4f32 (bitconvert (v2f64 MQPR:$src))), (v4f32 MQPR:$src)>;
5363 def : Pat<(v4f32 (bitconvert (v2i64 MQPR:$src))), (v4f32 MQPR:$src)>;
5364 def : Pat<(v4f32 (bitconvert (v8f16 MQPR:$src))), (v4f32 MQPR:$src)>;
5365 def : Pat<(v4f32 (bitconvert (v8i16 MQPR:$src))), (v4f32 MQPR:$src)>;
5366 def : Pat<(v4f32 (bitconvert (v16i8 MQPR:$src))), (v4f32 MQPR:$src)>;
5368 def : Pat<(v4i32 (bitconvert (v2f64 MQPR:$src))), (v4i32 MQPR:$src)>;
5369 def : Pat<(v4i32 (bitconvert (v2i64 MQPR:$src))), (v4i32 MQPR:$src)>;
5370 def : Pat<(v4i32 (bitconvert (v8f16 MQPR:$src))), (v4i32 MQPR:$src)>;
5371 def : Pat<(v4i32 (bitconvert (v8i16 MQPR:$src))), (v4i32 MQPR:$src)>;
5372 def : Pat<(v4i32 (bitconvert (v16i8 MQPR:$src))), (v4i32 MQPR:$src)>;
5374 def : Pat<(v8f16 (bitconvert (v2f64 MQPR:$src))), (v8f16 MQPR:$src)>;
5375 def : Pat<(v8f16 (bitconvert (v2i64 MQPR:$src))), (v8f16 MQPR:$src)>;
5376 def : Pat<(v8f16 (bitconvert (v4f32 MQPR:$src))), (v8f16 MQPR:$src)>;
5377 def : Pat<(v8f16 (bitconvert (v4i32 MQPR:$src))), (v8f16 MQPR:$src)>;
5378 def : Pat<(v8f16 (bitconvert (v16i8 MQPR:$src))), (v8f16 MQPR:$src)>;
5380 def : Pat<(v8i16 (bitconvert (v2f64 MQPR:$src))), (v8i16 MQPR:$src)>;
5381 def : Pat<(v8i16 (bitconvert (v2i64 MQPR:$src))), (v8i16 MQPR:$src)>;
5382 def : Pat<(v8i16 (bitconvert (v4f32 MQPR:$src))), (v8i16 MQPR:$src)>;
5383 def : Pat<(v8i16 (bitconvert (v4i32 MQPR:$src))), (v8i16 MQPR:$src)>;
5384 def : Pat<(v8i16 (bitconvert (v16i8 MQPR:$src))), (v8i16 MQPR:$src)>;
5386 def : Pat<(v16i8 (bitconvert (v2f64 MQPR:$src))), (v16i8 MQPR:$src)>;
5387 def : Pat<(v16i8 (bitconvert (v2i64 MQPR:$src))), (v16i8 MQPR:$src)>;
5388 def : Pat<(v16i8 (bitconvert (v4f32 MQPR:$src))), (v16i8 MQPR:$src)>;
5389 def : Pat<(v16i8 (bitconvert (v4i32 MQPR:$src))), (v16i8 MQPR:$src)>;
5390 def : Pat<(v16i8 (bitconvert (v8f16 MQPR:$src))), (v16i8 MQPR:$src)>;
5391 def : Pat<(v16i8 (bitconvert (v8i16 MQPR:$src))), (v16i8 MQPR:$src)>;
5394 let Predicates = [IsBE,HasMVEInt] in {
5395 def : Pat<(v2f64 (bitconvert (v4f32 MQPR:$src))), (v2f64 (MVE_VREV64_32 MQPR:$src))>;
5396 def : Pat<(v2f64 (bitconvert (v4i32 MQPR:$src))), (v2f64 (MVE_VREV64_32 MQPR:$src))>;
5397 def : Pat<(v2f64 (bitconvert (v8f16 MQPR:$src))), (v2f64 (MVE_VREV64_16 MQPR:$src))>;
5398 def : Pat<(v2f64 (bitconvert (v8i16 MQPR:$src))), (v2f64 (MVE_VREV64_16 MQPR:$src))>;
5399 def : Pat<(v2f64 (bitconvert (v16i8 MQPR:$src))), (v2f64 (MVE_VREV64_8 MQPR:$src))>;
5401 def : Pat<(v2i64 (bitconvert (v4f32 MQPR:$src))), (v2i64 (MVE_VREV64_32 MQPR:$src))>;
5402 def : Pat<(v2i64 (bitconvert (v4i32 MQPR:$src))), (v2i64 (MVE_VREV64_32 MQPR:$src))>;
5403 def : Pat<(v2i64 (bitconvert (v8f16 MQPR:$src))), (v2i64 (MVE_VREV64_16 MQPR:$src))>;
5404 def : Pat<(v2i64 (bitconvert (v8i16 MQPR:$src))), (v2i64 (MVE_VREV64_16 MQPR:$src))>;
5405 def : Pat<(v2i64 (bitconvert (v16i8 MQPR:$src))), (v2i64 (MVE_VREV64_8 MQPR:$src))>;
5407 def : Pat<(v4f32 (bitconvert (v2f64 MQPR:$src))), (v4f32 (MVE_VREV64_32 MQPR:$src))>;
5408 def : Pat<(v4f32 (bitconvert (v2i64 MQPR:$src))), (v4f32 (MVE_VREV64_32 MQPR:$src))>;
5409 def : Pat<(v4f32 (bitconvert (v8f16 MQPR:$src))), (v4f32 (MVE_VREV32_16 MQPR:$src))>;
5410 def : Pat<(v4f32 (bitconvert (v8i16 MQPR:$src))), (v4f32 (MVE_VREV32_16 MQPR:$src))>;
5411 def : Pat<(v4f32 (bitconvert (v16i8 MQPR:$src))), (v4f32 (MVE_VREV32_8 MQPR:$src))>;
5413 def : Pat<(v4i32 (bitconvert (v2f64 MQPR:$src))), (v4i32 (MVE_VREV64_32 MQPR:$src))>;
5414 def : Pat<(v4i32 (bitconvert (v2i64 MQPR:$src))), (v4i32 (MVE_VREV64_32 MQPR:$src))>;
5415 def : Pat<(v4i32 (bitconvert (v8f16 MQPR:$src))), (v4i32 (MVE_VREV32_16 MQPR:$src))>;
5416 def : Pat<(v4i32 (bitconvert (v8i16 MQPR:$src))), (v4i32 (MVE_VREV32_16 MQPR:$src))>;
5417 def : Pat<(v4i32 (bitconvert (v16i8 MQPR:$src))), (v4i32 (MVE_VREV32_8 MQPR:$src))>;
5419 def : Pat<(v8f16 (bitconvert (v2f64 MQPR:$src))), (v8f16 (MVE_VREV64_16 MQPR:$src))>;
5420 def : Pat<(v8f16 (bitconvert (v2i64 MQPR:$src))), (v8f16 (MVE_VREV64_16 MQPR:$src))>;
5421 def : Pat<(v8f16 (bitconvert (v4f32 MQPR:$src))), (v8f16 (MVE_VREV32_16 MQPR:$src))>;
5422 def : Pat<(v8f16 (bitconvert (v4i32 MQPR:$src))), (v8f16 (MVE_VREV32_16 MQPR:$src))>;
5423 def : Pat<(v8f16 (bitconvert (v16i8 MQPR:$src))), (v8f16 (MVE_VREV16_8 MQPR:$src))>;
5425 def : Pat<(v8i16 (bitconvert (v2f64 MQPR:$src))), (v8i16 (MVE_VREV64_16 MQPR:$src))>;
5426 def : Pat<(v8i16 (bitconvert (v2i64 MQPR:$src))), (v8i16 (MVE_VREV64_16 MQPR:$src))>;
5427 def : Pat<(v8i16 (bitconvert (v4f32 MQPR:$src))), (v8i16 (MVE_VREV32_16 MQPR:$src))>;
5428 def : Pat<(v8i16 (bitconvert (v4i32 MQPR:$src))), (v8i16 (MVE_VREV32_16 MQPR:$src))>;
5429 def : Pat<(v8i16 (bitconvert (v16i8 MQPR:$src))), (v8i16 (MVE_VREV16_8 MQPR:$src))>;
5431 def : Pat<(v16i8 (bitconvert (v2f64 MQPR:$src))), (v16i8 (MVE_VREV64_8 MQPR:$src))>;
5432 def : Pat<(v16i8 (bitconvert (v2i64 MQPR:$src))), (v16i8 (MVE_VREV64_8 MQPR:$src))>;
5433 def : Pat<(v16i8 (bitconvert (v4f32 MQPR:$src))), (v16i8 (MVE_VREV32_8 MQPR:$src))>;
5434 def : Pat<(v16i8 (bitconvert (v4i32 MQPR:$src))), (v16i8 (MVE_VREV32_8 MQPR:$src))>;
5435 def : Pat<(v16i8 (bitconvert (v8f16 MQPR:$src))), (v16i8 (MVE_VREV16_8 MQPR:$src))>;
5436 def : Pat<(v16i8 (bitconvert (v8i16 MQPR:$src))), (v16i8 (MVE_VREV16_8 MQPR:$src))>;