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 let ParserMatchClass = TMemImm7ShiftOffsetAsmOperand<shift>;
165 // They are printed the same way as the T2 imm8 version
166 let PrintMethod = "printT2AddrModeImm8Operand<false>";
167 // This can also be the same as the T2 version.
168 let EncoderMethod = "getT2AddrModeImmOpValue<7,"#shift#">";
169 let DecoderMethod = "DecodeTAddrModeImm7<"#shift#">";
170 let MIOperandInfo = (ops tGPR:$base, i32imm:$offsimm);
173 // t2addrmode_imm7 := reg +/- (imm7)
174 class MemImm7ShiftOffsetAsmOperand<int shift> : AsmOperandClass {
175 let Name = "MemImm7Shift"#shift#"Offset";
176 let PredicateMethod = "isMemImm7ShiftedOffset<" # shift #
177 ",ARM::GPRnopcRegClassID>";
178 let RenderMethod = "addMemImmOffsetOperands";
181 def MemImm7Shift0OffsetAsmOperand : MemImm7ShiftOffsetAsmOperand<0>;
182 def MemImm7Shift1OffsetAsmOperand : MemImm7ShiftOffsetAsmOperand<1>;
183 def MemImm7Shift2OffsetAsmOperand : MemImm7ShiftOffsetAsmOperand<2>;
184 class T2AddrMode_Imm7<int shift> : MemOperand,
185 ComplexPattern<i32, 2, "SelectT2AddrModeImm7<"#shift#">", []> {
186 let EncoderMethod = "getT2AddrModeImmOpValue<7,"#shift#">";
187 let DecoderMethod = "DecodeT2AddrModeImm7<"#shift#", 0>";
188 let ParserMatchClass =
189 !cast<AsmOperandClass>("MemImm7Shift"#shift#"OffsetAsmOperand");
190 let MIOperandInfo = (ops GPRnopc:$base, i32imm:$offsimm);
193 class t2addrmode_imm7<int shift> : T2AddrMode_Imm7<shift> {
194 // They are printed the same way as the imm8 version
195 let PrintMethod = "printT2AddrModeImm8Operand<false>";
198 class MemImm7ShiftOffsetWBAsmOperand<int shift> : AsmOperandClass {
199 let Name = "MemImm7Shift"#shift#"OffsetWB";
200 let PredicateMethod = "isMemImm7ShiftedOffset<" # shift #
201 ",ARM::rGPRRegClassID>";
202 let RenderMethod = "addMemImmOffsetOperands";
205 def MemImm7Shift0OffsetWBAsmOperand : MemImm7ShiftOffsetWBAsmOperand<0>;
206 def MemImm7Shift1OffsetWBAsmOperand : MemImm7ShiftOffsetWBAsmOperand<1>;
207 def MemImm7Shift2OffsetWBAsmOperand : MemImm7ShiftOffsetWBAsmOperand<2>;
209 class t2addrmode_imm7_pre<int shift> : T2AddrMode_Imm7<shift> {
210 // They are printed the same way as the imm8 version
211 let PrintMethod = "printT2AddrModeImm8Operand<true>";
212 let ParserMatchClass =
213 !cast<AsmOperandClass>("MemImm7Shift"#shift#"OffsetWBAsmOperand");
214 let DecoderMethod = "DecodeT2AddrModeImm7<"#shift#", 1>";
215 let MIOperandInfo = (ops rGPR:$base, i32imm:$offsim);
218 class t2am_imm7shiftOffsetAsmOperand<int shift>
219 : AsmOperandClass { let Name = "Imm7Shift"#shift; }
220 def t2am_imm7shift0OffsetAsmOperand : t2am_imm7shiftOffsetAsmOperand<0>;
221 def t2am_imm7shift1OffsetAsmOperand : t2am_imm7shiftOffsetAsmOperand<1>;
222 def t2am_imm7shift2OffsetAsmOperand : t2am_imm7shiftOffsetAsmOperand<2>;
224 class t2am_imm7_offset<int shift> : MemOperand,
225 ComplexPattern<i32, 1, "SelectT2AddrModeImm7Offset<"#shift#">",
226 [], [SDNPWantRoot]> {
227 // They are printed the same way as the imm8 version
228 let PrintMethod = "printT2AddrModeImm8OffsetOperand";
229 let ParserMatchClass =
230 !cast<AsmOperandClass>("t2am_imm7shift"#shift#"OffsetAsmOperand");
231 let EncoderMethod = "getT2ScaledImmOpValue<7,"#shift#">";
232 let DecoderMethod = "DecodeT2Imm7<"#shift#">";
235 // Operands for gather/scatter loads of the form [Rbase, Qoffsets]
236 class MemRegRQOffsetAsmOperand<int shift> : AsmOperandClass {
237 let Name = "MemRegRQS"#shift#"Offset";
238 let PredicateMethod = "isMemRegRQOffset<"#shift#">";
239 let RenderMethod = "addMemRegRQOffsetOperands";
242 def MemRegRQS0OffsetAsmOperand : MemRegRQOffsetAsmOperand<0>;
243 def MemRegRQS1OffsetAsmOperand : MemRegRQOffsetAsmOperand<1>;
244 def MemRegRQS2OffsetAsmOperand : MemRegRQOffsetAsmOperand<2>;
245 def MemRegRQS3OffsetAsmOperand : MemRegRQOffsetAsmOperand<3>;
247 // mve_addr_rq_shift := reg + vreg{ << UXTW #shift}
248 class mve_addr_rq_shift<int shift> : MemOperand {
249 let EncoderMethod = "getMveAddrModeRQOpValue";
250 let PrintMethod = "printMveAddrModeRQOperand<"#shift#">";
251 let ParserMatchClass =
252 !cast<AsmOperandClass>("MemRegRQS"#shift#"OffsetAsmOperand");
253 let DecoderMethod = "DecodeMveAddrModeRQ";
254 let MIOperandInfo = (ops GPRnopc:$base, MQPR:$offsreg);
257 class MemRegQOffsetAsmOperand<int shift> : AsmOperandClass {
258 let Name = "MemRegQS"#shift#"Offset";
259 let PredicateMethod = "isMemRegQOffset<"#shift#">";
260 let RenderMethod = "addMemImmOffsetOperands";
263 def MemRegQS2OffsetAsmOperand : MemRegQOffsetAsmOperand<2>;
264 def MemRegQS3OffsetAsmOperand : MemRegQOffsetAsmOperand<3>;
266 // mve_addr_q_shift := vreg {+ #imm7s2/4}
267 class mve_addr_q_shift<int shift> : MemOperand {
268 let EncoderMethod = "getMveAddrModeQOpValue<"#shift#">";
269 // Can be printed same way as other reg + imm operands
270 let PrintMethod = "printT2AddrModeImm8Operand<false>";
271 let ParserMatchClass =
272 !cast<AsmOperandClass>("MemRegQS"#shift#"OffsetAsmOperand");
273 let DecoderMethod = "DecodeMveAddrModeQ<"#shift#">";
274 let MIOperandInfo = (ops MQPR:$base, i32imm:$imm);
277 // --------- Start of base classes for the instructions themselves
279 class MVE_MI<dag oops, dag iops, InstrItinClass itin, string asm,
280 string ops, string cstr, list<dag> pattern>
281 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, !strconcat(asm, "\t", ops), cstr,
283 Requires<[HasMVEInt]> {
285 let DecoderNamespace = "MVE";
288 // MVE_p is used for most predicated instructions, to add the cluster
289 // of input operands that provides the VPT suffix (none, T or E) and
290 // the input predicate register.
291 class MVE_p<dag oops, dag iops, InstrItinClass itin, string iname,
292 string suffix, string ops, vpred_ops vpred, string cstr,
293 list<dag> pattern=[]>
294 : MVE_MI<oops, !con(iops, (ins vpred:$vp)), itin,
295 // If the instruction has a suffix, like vadd.f32, then the
296 // VPT predication suffix goes before the dot, so the full
297 // name has to be "vadd${vp}.f32".
298 !strconcat(iname, "${vp}",
299 !if(!eq(suffix, ""), "", !strconcat(".", suffix))),
300 ops, !strconcat(cstr, vpred.vpred_constraint), pattern> {
301 let Inst{31-29} = 0b111;
302 let Inst{27-26} = 0b11;
305 class MVE_f<dag oops, dag iops, InstrItinClass itin, string iname,
306 string suffix, string ops, vpred_ops vpred, string cstr,
307 list<dag> pattern=[]>
308 : MVE_p<oops, iops, itin, iname, suffix, ops, vpred, cstr, pattern> {
309 let Predicates = [HasMVEFloat];
312 class MVE_MI_with_pred<dag oops, dag iops, InstrItinClass itin, string asm,
313 string ops, string cstr, list<dag> pattern>
314 : Thumb2I<oops, iops, AddrModeNone, 4, itin, asm, !strconcat("\t", ops), cstr,
316 Requires<[HasV8_1MMainline, HasMVEInt]> {
318 let DecoderNamespace = "MVE";
321 class MVE_VMOV_lane_base<dag oops, dag iops, InstrItinClass itin, string asm,
322 string suffix, string ops, string cstr,
324 : Thumb2I<oops, iops, AddrModeNone, 4, itin, asm,
325 !if(!eq(suffix, ""), "", "." # suffix) # "\t" # ops,
327 Requires<[HasV8_1MMainline, HasMVEInt]> {
329 let DecoderNamespace = "MVE";
332 class MVE_ScalarShift<string iname, dag oops, dag iops, string asm, string cstr,
333 list<dag> pattern=[]>
334 : MVE_MI_with_pred<oops, iops, NoItinerary, iname, asm, cstr, pattern> {
335 let Inst{31-20} = 0b111010100101;
340 class MVE_ScalarShiftSingleReg<string iname, dag iops, string asm, string cstr,
341 list<dag> pattern=[]>
342 : MVE_ScalarShift<iname, (outs rGPR:$RdaDest), iops, asm, cstr, pattern> {
345 let Inst{19-16} = RdaDest{3-0};
348 class MVE_ScalarShiftSRegImm<string iname, bits<2> op5_4, list<dag> pattern=[]>
349 : MVE_ScalarShiftSingleReg<iname, (ins rGPR:$RdaSrc, long_shift:$imm),
350 "$RdaSrc, $imm", "$RdaDest = $RdaSrc", pattern> {
354 let Inst{14-12} = imm{4-2};
355 let Inst{11-8} = 0b1111;
356 let Inst{7-6} = imm{1-0};
357 let Inst{5-4} = op5_4{1-0};
358 let Inst{3-0} = 0b1111;
361 def MVE_SQSHL : MVE_ScalarShiftSRegImm<"sqshl", 0b11>;
362 def MVE_SRSHR : MVE_ScalarShiftSRegImm<"srshr", 0b10>;
363 def MVE_UQSHL : MVE_ScalarShiftSRegImm<"uqshl", 0b00>;
364 def MVE_URSHR : MVE_ScalarShiftSRegImm<"urshr", 0b01>;
366 class MVE_ScalarShiftSRegReg<string iname, bits<2> op5_4, list<dag> pattern=[]>
367 : MVE_ScalarShiftSingleReg<iname, (ins rGPR:$RdaSrc, rGPR:$Rm),
368 "$RdaSrc, $Rm", "$RdaDest = $RdaSrc", pattern> {
371 let Inst{15-12} = Rm{3-0};
372 let Inst{11-8} = 0b1111;
373 let Inst{7-6} = 0b00;
374 let Inst{5-4} = op5_4{1-0};
375 let Inst{3-0} = 0b1101;
378 def MVE_SQRSHR : MVE_ScalarShiftSRegReg<"sqrshr", 0b10>;
379 def MVE_UQRSHL : MVE_ScalarShiftSRegReg<"uqrshl", 0b00>;
381 class MVE_ScalarShiftDoubleReg<string iname, dag iops, string asm,
382 string cstr, list<dag> pattern=[]>
383 : MVE_ScalarShift<iname, (outs tGPREven:$RdaLo, tGPROdd:$RdaHi),
384 iops, asm, cstr, pattern> {
388 let Inst{19-17} = RdaLo{3-1};
389 let Inst{11-9} = RdaHi{3-1};
392 class MVE_ScalarShiftDRegImm<string iname, bits<2> op5_4, bit op16,
393 list<dag> pattern=[]>
394 : MVE_ScalarShiftDoubleReg<
395 iname, (ins tGPREven:$RdaLo_src, tGPROdd:$RdaHi_src, long_shift:$imm),
396 "$RdaLo, $RdaHi, $imm", "$RdaLo = $RdaLo_src,$RdaHi = $RdaHi_src",
402 let Inst{14-12} = imm{4-2};
403 let Inst{7-6} = imm{1-0};
404 let Inst{5-4} = op5_4{1-0};
405 let Inst{3-0} = 0b1111;
408 class MVE_ScalarShiftDRegRegBase<string iname, dag iops, string asm,
409 bit op5, bit op16, list<dag> pattern=[]>
410 : MVE_ScalarShiftDoubleReg<
411 iname, iops, asm, "@earlyclobber $RdaHi,@earlyclobber $RdaLo,"
412 "$RdaLo = $RdaLo_src,$RdaHi = $RdaHi_src",
417 let Inst{15-12} = Rm{3-0};
421 let Inst{3-0} = 0b1101;
423 // Custom decoder method because of the following overlapping encodings:
426 // SQRSHRL and SQRSHR
427 // UQRSHLL and UQRSHL
428 let DecoderMethod = "DecodeMVEOverlappingLongShift";
431 class MVE_ScalarShiftDRegReg<string iname, bit op5, list<dag> pattern=[]>
432 : MVE_ScalarShiftDRegRegBase<
433 iname, (ins tGPREven:$RdaLo_src, tGPROdd:$RdaHi_src, rGPR:$Rm),
434 "$RdaLo, $RdaHi, $Rm", op5, 0b0, pattern> {
439 class MVE_ScalarShiftDRegRegWithSat<string iname, bit op5, list<dag> pattern=[]>
440 : MVE_ScalarShiftDRegRegBase<
441 iname, (ins tGPREven:$RdaLo_src, tGPROdd:$RdaHi_src, rGPR:$Rm, saturateop:$sat),
442 "$RdaLo, $RdaHi, $sat, $Rm", op5, 0b1, pattern> {
448 def MVE_ASRLr : MVE_ScalarShiftDRegReg<"asrl", 0b1, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi,
449 (ARMasrl tGPREven:$RdaLo_src,
450 tGPROdd:$RdaHi_src, rGPR:$Rm))]>;
451 def MVE_ASRLi : MVE_ScalarShiftDRegImm<"asrl", 0b10, ?, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi,
452 (ARMasrl tGPREven:$RdaLo_src,
453 tGPROdd:$RdaHi_src, (i32 imm:$imm)))]>;
454 def MVE_LSLLr : MVE_ScalarShiftDRegReg<"lsll", 0b0, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi,
455 (ARMlsll tGPREven:$RdaLo_src,
456 tGPROdd:$RdaHi_src, rGPR:$Rm))]>;
457 def MVE_LSLLi : MVE_ScalarShiftDRegImm<"lsll", 0b00, ?, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi,
458 (ARMlsll tGPREven:$RdaLo_src,
459 tGPROdd:$RdaHi_src, (i32 imm:$imm)))]>;
460 def MVE_LSRL : MVE_ScalarShiftDRegImm<"lsrl", 0b01, ?, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi,
461 (ARMlsrl tGPREven:$RdaLo_src,
462 tGPROdd:$RdaHi_src, (i32 imm:$imm)))]>;
464 def MVE_SQRSHRL : MVE_ScalarShiftDRegRegWithSat<"sqrshrl", 0b1>;
465 def MVE_SQSHLL : MVE_ScalarShiftDRegImm<"sqshll", 0b11, 0b1>;
466 def MVE_SRSHRL : MVE_ScalarShiftDRegImm<"srshrl", 0b10, 0b1>;
468 def MVE_UQRSHLL : MVE_ScalarShiftDRegRegWithSat<"uqrshll", 0b0>;
469 def MVE_UQSHLL : MVE_ScalarShiftDRegImm<"uqshll", 0b00, 0b1>;
470 def MVE_URSHRL : MVE_ScalarShiftDRegImm<"urshrl", 0b01, 0b1>;
472 // start of mve_rDest instructions
474 class MVE_rDest<dag oops, dag iops, InstrItinClass itin,
475 string iname, string suffix,
476 string ops, string cstr, list<dag> pattern=[]>
477 // Always use vpred_n and not vpred_r: with the output register being
478 // a GPR and not a vector register, there can't be any question of
479 // what to put in its inactive lanes.
480 : MVE_p<oops, iops, itin, iname, suffix, ops, vpred_n, cstr, pattern> {
482 let Inst{25-23} = 0b101;
483 let Inst{11-9} = 0b111;
487 class MVE_VABAV<string suffix, bit U, bits<2> size, list<dag> pattern=[]>
488 : MVE_rDest<(outs rGPR:$Rda), (ins rGPR:$Rda_src, MQPR:$Qn, MQPR:$Qm),
489 NoItinerary, "vabav", suffix, "$Rda, $Qn, $Qm", "$Rda = $Rda_src",
497 let Inst{21-20} = size{1-0};
498 let Inst{19-17} = Qn{2-0};
500 let Inst{15-12} = Rda{3-0};
505 let Inst{3-1} = Qm{2-0};
509 def MVE_VABAVs8 : MVE_VABAV<"s8", 0b0, 0b00>;
510 def MVE_VABAVs16 : MVE_VABAV<"s16", 0b0, 0b01>;
511 def MVE_VABAVs32 : MVE_VABAV<"s32", 0b0, 0b10>;
512 def MVE_VABAVu8 : MVE_VABAV<"u8", 0b1, 0b00>;
513 def MVE_VABAVu16 : MVE_VABAV<"u16", 0b1, 0b01>;
514 def MVE_VABAVu32 : MVE_VABAV<"u32", 0b1, 0b10>;
516 class MVE_VADDV<string iname, string suffix, dag iops, string cstr,
517 bit A, bit U, bits<2> size, list<dag> pattern=[]>
518 : MVE_rDest<(outs tGPREven:$Rda), iops, NoItinerary,
519 iname, suffix, "$Rda, $Qm", cstr, pattern> {
524 let Inst{22-20} = 0b111;
525 let Inst{19-18} = size{1-0};
526 let Inst{17-16} = 0b01;
527 let Inst{15-13} = Rda{3-1};
529 let Inst{8-6} = 0b100;
531 let Inst{3-1} = Qm{2-0};
535 multiclass MVE_VADDV_A<string suffix, bit U, bits<2> size,
536 list<dag> pattern=[]> {
537 def acc : MVE_VADDV<"vaddva", suffix,
538 (ins tGPREven:$Rda_src, MQPR:$Qm), "$Rda = $Rda_src",
539 0b1, U, size, pattern>;
540 def no_acc : MVE_VADDV<"vaddv", suffix,
542 0b0, U, size, pattern>;
545 defm MVE_VADDVs8 : MVE_VADDV_A<"s8", 0b0, 0b00>;
546 defm MVE_VADDVs16 : MVE_VADDV_A<"s16", 0b0, 0b01>;
547 defm MVE_VADDVs32 : MVE_VADDV_A<"s32", 0b0, 0b10>;
548 defm MVE_VADDVu8 : MVE_VADDV_A<"u8", 0b1, 0b00>;
549 defm MVE_VADDVu16 : MVE_VADDV_A<"u16", 0b1, 0b01>;
550 defm MVE_VADDVu32 : MVE_VADDV_A<"u32", 0b1, 0b10>;
552 let Predicates = [HasMVEInt] in {
553 def : Pat<(i32 (vecreduce_add (v4i32 MQPR:$src))), (i32 (MVE_VADDVu32no_acc $src))>;
554 def : Pat<(i32 (vecreduce_add (v8i16 MQPR:$src))), (i32 (MVE_VADDVu16no_acc $src))>;
555 def : Pat<(i32 (vecreduce_add (v16i8 MQPR:$src))), (i32 (MVE_VADDVu8no_acc $src))>;
556 def : Pat<(i32 (add (i32 (vecreduce_add (v4i32 MQPR:$src1))), (i32 tGPR:$src2))),
557 (i32 (MVE_VADDVu32acc $src2, $src1))>;
558 def : Pat<(i32 (add (i32 (vecreduce_add (v8i16 MQPR:$src1))), (i32 tGPR:$src2))),
559 (i32 (MVE_VADDVu16acc $src2, $src1))>;
560 def : Pat<(i32 (add (i32 (vecreduce_add (v16i8 MQPR:$src1))), (i32 tGPR:$src2))),
561 (i32 (MVE_VADDVu8acc $src2, $src1))>;
565 class MVE_VADDLV<string iname, string suffix, dag iops, string cstr,
566 bit A, bit U, list<dag> pattern=[]>
567 : MVE_rDest<(outs tGPREven:$RdaLo, tGPROdd:$RdaHi), iops, NoItinerary, iname,
568 suffix, "$RdaLo, $RdaHi, $Qm", cstr, pattern> {
574 let Inst{22-20} = RdaHi{3-1};
575 let Inst{19-18} = 0b10;
576 let Inst{17-16} = 0b01;
577 let Inst{15-13} = RdaLo{3-1};
579 let Inst{8-6} = 0b100;
581 let Inst{3-1} = Qm{2-0};
585 multiclass MVE_VADDLV_A<string suffix, bit U, list<dag> pattern=[]> {
586 def acc : MVE_VADDLV<"vaddlva", suffix,
587 (ins tGPREven:$RdaLo_src, tGPROdd:$RdaHi_src, MQPR:$Qm),
588 "$RdaLo = $RdaLo_src,$RdaHi = $RdaHi_src",
590 def no_acc : MVE_VADDLV<"vaddlv", suffix,
596 defm MVE_VADDLVs32 : MVE_VADDLV_A<"s32", 0b0>;
597 defm MVE_VADDLVu32 : MVE_VADDLV_A<"u32", 0b1>;
599 class MVE_VMINMAXNMV<string iname, string suffix, bit sz,
600 bit bit_17, bit bit_7, list<dag> pattern=[]>
601 : MVE_rDest<(outs rGPR:$RdaDest), (ins rGPR:$RdaSrc, MQPR:$Qm),
602 NoItinerary, iname, suffix, "$RdaSrc, $Qm",
603 "$RdaDest = $RdaSrc", pattern> {
608 let Inst{22-20} = 0b110;
609 let Inst{19-18} = 0b11;
610 let Inst{17} = bit_17;
612 let Inst{15-12} = RdaDest{3-0};
615 let Inst{6-5} = 0b00;
616 let Inst{3-1} = Qm{2-0};
619 let Predicates = [HasMVEFloat];
622 multiclass MVE_VMINMAXNMV_fty<string iname, bit bit_7, list<dag> pattern=[]> {
623 def f32 : MVE_VMINMAXNMV<iname, "f32", 0b0, 0b1, bit_7, pattern>;
624 def f16 : MVE_VMINMAXNMV<iname, "f16", 0b1, 0b1, bit_7, pattern>;
627 defm MVE_VMINNMV : MVE_VMINMAXNMV_fty<"vminnmv", 0b1>;
628 defm MVE_VMAXNMV : MVE_VMINMAXNMV_fty<"vmaxnmv", 0b0>;
630 multiclass MVE_VMINMAXNMAV_fty<string iname, bit bit_7, list<dag> pattern=[]> {
631 def f32 : MVE_VMINMAXNMV<iname, "f32", 0b0, 0b0, bit_7, pattern>;
632 def f16 : MVE_VMINMAXNMV<iname, "f16", 0b1, 0b0, bit_7, pattern>;
635 defm MVE_VMINNMAV : MVE_VMINMAXNMAV_fty<"vminnmav", 0b1>;
636 defm MVE_VMAXNMAV : MVE_VMINMAXNMAV_fty<"vmaxnmav", 0b0>;
638 class MVE_VMINMAXV<string iname, string suffix, bit U, bits<2> size,
639 bit bit_17, bit bit_7, list<dag> pattern=[]>
640 : MVE_rDest<(outs rGPR:$RdaDest), (ins rGPR:$RdaSrc, MQPR:$Qm), NoItinerary,
641 iname, suffix, "$RdaSrc, $Qm", "$RdaDest = $RdaSrc", pattern> {
646 let Inst{22-20} = 0b110;
647 let Inst{19-18} = size{1-0};
648 let Inst{17} = bit_17;
650 let Inst{15-12} = RdaDest{3-0};
653 let Inst{6-5} = 0b00;
654 let Inst{3-1} = Qm{2-0};
658 multiclass MVE_VMINMAXV_ty<string iname, bit bit_7, list<dag> pattern=[]> {
659 def s8 : MVE_VMINMAXV<iname, "s8", 0b0, 0b00, 0b1, bit_7>;
660 def s16 : MVE_VMINMAXV<iname, "s16", 0b0, 0b01, 0b1, bit_7>;
661 def s32 : MVE_VMINMAXV<iname, "s32", 0b0, 0b10, 0b1, bit_7>;
662 def u8 : MVE_VMINMAXV<iname, "u8", 0b1, 0b00, 0b1, bit_7>;
663 def u16 : MVE_VMINMAXV<iname, "u16", 0b1, 0b01, 0b1, bit_7>;
664 def u32 : MVE_VMINMAXV<iname, "u32", 0b1, 0b10, 0b1, bit_7>;
667 defm MVE_VMINV : MVE_VMINMAXV_ty<"vminv", 0b1>;
668 defm MVE_VMAXV : MVE_VMINMAXV_ty<"vmaxv", 0b0>;
670 multiclass MVE_VMINMAXAV_ty<string iname, bit bit_7, list<dag> pattern=[]> {
671 def s8 : MVE_VMINMAXV<iname, "s8", 0b0, 0b00, 0b0, bit_7>;
672 def s16 : MVE_VMINMAXV<iname, "s16", 0b0, 0b01, 0b0, bit_7>;
673 def s32 : MVE_VMINMAXV<iname, "s32", 0b0, 0b10, 0b0, bit_7>;
676 defm MVE_VMINAV : MVE_VMINMAXAV_ty<"vminav", 0b1>;
677 defm MVE_VMAXAV : MVE_VMINMAXAV_ty<"vmaxav", 0b0>;
679 class MVE_VMLAMLSDAV<string iname, string suffix, dag iops, string cstr,
680 bit sz, bit bit_28, bit A, bit X, bit bit_8, bit bit_0,
681 list<dag> pattern=[]>
682 : MVE_rDest<(outs tGPREven:$RdaDest), iops, NoItinerary, iname, suffix,
683 "$RdaDest, $Qn, $Qm", cstr, pattern> {
688 let Inst{28} = bit_28;
689 let Inst{22-20} = 0b111;
690 let Inst{19-17} = Qn{2-0};
692 let Inst{15-13} = RdaDest{3-1};
695 let Inst{7-6} = 0b00;
697 let Inst{3-1} = Qm{2-0};
701 multiclass MVE_VMLAMLSDAV_X<string iname, string suffix, dag iops, string cstr,
702 bit sz, bit bit_28, bit A, bit bit_8, bit bit_0,
703 list<dag> pattern=[]> {
704 def _noexch : MVE_VMLAMLSDAV<iname, suffix, iops, cstr, sz,
705 bit_28, A, 0b0, bit_8, bit_0, pattern>;
706 def _exch : MVE_VMLAMLSDAV<iname # "x", suffix, iops, cstr, sz,
707 bit_28, A, 0b1, bit_8, bit_0, pattern>;
710 multiclass MVE_VMLAMLSDAV_XA<string iname, string suffix, bit sz, bit bit_28,
711 bit bit_8, bit bit_0, list<dag> pattern=[]> {
712 defm _noacc : MVE_VMLAMLSDAV_X<iname, suffix, (ins MQPR:$Qn, MQPR:$Qm), "",
713 sz, bit_28, 0b0, bit_8, bit_0, pattern>;
714 defm _acc : MVE_VMLAMLSDAV_X<iname # "a", suffix,
715 (ins tGPREven:$RdaSrc, MQPR:$Qn, MQPR:$Qm),
716 "$RdaDest = $RdaSrc",
717 sz, bit_28, 0b1, bit_8, bit_0, pattern>;
720 multiclass MVE_VMLADAV_multi<string suffix, bit sz, bit U, bit bit_8,
721 list<dag> pattern=[]> {
722 defm "" : MVE_VMLAMLSDAV_XA<"vmladav", suffix, sz, U, bit_8, 0b0, pattern>;
725 defm MVE_VMLADAVs16 : MVE_VMLADAV_multi<"s16", 0b0, 0b0, 0b0>;
726 defm MVE_VMLADAVs32 : MVE_VMLADAV_multi<"s32", 0b1, 0b0, 0b0>;
727 defm MVE_VMLADAVu16 : MVE_VMLADAV_multi<"u16", 0b0, 0b1, 0b0>;
728 defm MVE_VMLADAVu32 : MVE_VMLADAV_multi<"u32", 0b1, 0b1, 0b0>;
730 defm MVE_VMLADAVs8 : MVE_VMLADAV_multi<"s8", 0b0, 0b0, 0b1>;
731 defm MVE_VMLADAVu8 : MVE_VMLADAV_multi<"u8", 0b0, 0b1, 0b1>;
733 // vmlav aliases vmladav
734 foreach acc = ["_acc", "_noacc"] in {
735 foreach suffix = ["s8", "s16", "s32", "u8", "u16", "u32"] in {
736 def : MVEInstAlias<!strconcat("vmlav", !if(!eq(acc, "_acc"), "a", ""),
737 "${vp}.", suffix, "\t$RdaDest, $Qn, $Qm"),
738 (!cast<Instruction>("MVE_VMLADAV"#suffix#acc#"_noexch")
739 tGPREven:$RdaDest, MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
743 multiclass MVE_VMLSDAV_multi<string suffix, bit sz, bit bit_28,
744 list<dag> pattern=[]> {
745 defm "" : MVE_VMLAMLSDAV_XA<"vmlsdav", suffix, sz, bit_28, 0b0, 0b1, pattern>;
748 defm MVE_VMLSDAVs8 : MVE_VMLSDAV_multi<"s8", 0, 0b1>;
749 defm MVE_VMLSDAVs16 : MVE_VMLSDAV_multi<"s16", 0, 0b0>;
750 defm MVE_VMLSDAVs32 : MVE_VMLSDAV_multi<"s32", 1, 0b0>;
752 // Base class for VMLALDAV and VMLSLDAV, VRMLALDAVH, VRMLSLDAVH
753 class MVE_VMLALDAVBase<string iname, string suffix, dag iops, string cstr,
754 bit sz, bit bit_28, bit A, bit X, bit bit_8, bit bit_0,
755 list<dag> pattern=[]>
756 : MVE_rDest<(outs tGPREven:$RdaLoDest, tGPROdd:$RdaHiDest), iops, NoItinerary,
757 iname, suffix, "$RdaLoDest, $RdaHiDest, $Qn, $Qm", cstr, pattern> {
763 let Inst{28} = bit_28;
764 let Inst{22-20} = RdaHiDest{3-1};
765 let Inst{19-17} = Qn{2-0};
767 let Inst{15-13} = RdaLoDest{3-1};
770 let Inst{7-6} = 0b00;
772 let Inst{3-1} = Qm{2-0};
776 multiclass MVE_VMLALDAVBase_X<string iname, string suffix, dag iops,
777 string cstr, bit sz, bit bit_28, bit A,
778 bit bit_8, bit bit_0, list<dag> pattern=[]> {
779 def _noexch : MVE_VMLALDAVBase<iname, suffix, iops, cstr, sz,
780 bit_28, A, 0b0, bit_8, bit_0, pattern>;
781 def _exch : MVE_VMLALDAVBase<iname # "x", suffix, iops, cstr, sz,
782 bit_28, A, 0b1, bit_8, bit_0, pattern>;
785 multiclass MVE_VMLALDAVBase_XA<string iname, string suffix, bit sz, bit bit_28,
786 bit bit_8, bit bit_0, list<dag> pattern=[]> {
787 defm _noacc : MVE_VMLALDAVBase_X<
788 iname, suffix, (ins MQPR:$Qn, MQPR:$Qm), "",
789 sz, bit_28, 0b0, bit_8, bit_0, pattern>;
790 defm _acc : MVE_VMLALDAVBase_X<
791 iname # "a", suffix, (ins tGPREven:$RdaLoSrc, tGPROdd:$RdaHiSrc,
793 "$RdaLoDest = $RdaLoSrc,$RdaHiDest = $RdaHiSrc",
794 sz, bit_28, 0b1, bit_8, bit_0, pattern>;
797 multiclass MVE_VRMLALDAVH_multi<string suffix, bit U, list<dag> pattern=[]> {
798 defm "" : MVE_VMLALDAVBase_XA<
799 "vrmlaldavh", suffix, 0b0, U, 0b1, 0b0, pattern>;
802 defm MVE_VRMLALDAVHs32 : MVE_VRMLALDAVH_multi<"s32", 0>;
803 defm MVE_VRMLALDAVHu32 : MVE_VRMLALDAVH_multi<"u32", 1>;
805 // vrmlalvh aliases for vrmlaldavh
806 def : MVEInstAlias<"vrmlalvh${vp}.s32\t$RdaLo, $RdaHi, $Qn, $Qm",
807 (MVE_VRMLALDAVHs32_noacc_noexch
808 tGPREven:$RdaLo, tGPROdd:$RdaHi,
809 MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
810 def : MVEInstAlias<"vrmlalvha${vp}.s32\t$RdaLo, $RdaHi, $Qn, $Qm",
811 (MVE_VRMLALDAVHs32_acc_noexch
812 tGPREven:$RdaLo, tGPROdd:$RdaHi,
813 MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
814 def : MVEInstAlias<"vrmlalvh${vp}.u32\t$RdaLo, $RdaHi, $Qn, $Qm",
815 (MVE_VRMLALDAVHu32_noacc_noexch
816 tGPREven:$RdaLo, tGPROdd:$RdaHi,
817 MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
818 def : MVEInstAlias<"vrmlalvha${vp}.u32\t$RdaLo, $RdaHi, $Qn, $Qm",
819 (MVE_VRMLALDAVHu32_acc_noexch
820 tGPREven:$RdaLo, tGPROdd:$RdaHi,
821 MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
823 multiclass MVE_VMLALDAV_multi<string suffix, bit sz, bit U,
824 list<dag> pattern=[]> {
825 defm "" : MVE_VMLALDAVBase_XA<"vmlaldav", suffix, sz, U, 0b0, 0b0, pattern>;
828 defm MVE_VMLALDAVs16 : MVE_VMLALDAV_multi<"s16", 0b0, 0b0>;
829 defm MVE_VMLALDAVs32 : MVE_VMLALDAV_multi<"s32", 0b1, 0b0>;
830 defm MVE_VMLALDAVu16 : MVE_VMLALDAV_multi<"u16", 0b0, 0b1>;
831 defm MVE_VMLALDAVu32 : MVE_VMLALDAV_multi<"u32", 0b1, 0b1>;
833 // vmlalv aliases vmlaldav
834 foreach acc = ["_acc", "_noacc"] in {
835 foreach suffix = ["s16", "s32", "u16", "u32"] in {
836 def : MVEInstAlias<!strconcat("vmlalv", !if(!eq(acc, "_acc"), "a", ""),
837 "${vp}.", suffix, "\t$RdaLoDest, $RdaHiDest, $Qn, $Qm"),
838 (!cast<Instruction>("MVE_VMLALDAV"#suffix#acc#"_noexch")
839 tGPREven:$RdaLoDest, tGPROdd:$RdaHiDest,
840 MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
844 multiclass MVE_VMLSLDAV_multi<string iname, string suffix, bit sz,
845 bit bit_28, list<dag> pattern=[]> {
846 defm "" : MVE_VMLALDAVBase_XA<iname, suffix, sz, bit_28, 0b0, 0b1, pattern>;
849 defm MVE_VMLSLDAVs16 : MVE_VMLSLDAV_multi<"vmlsldav", "s16", 0b0, 0b0>;
850 defm MVE_VMLSLDAVs32 : MVE_VMLSLDAV_multi<"vmlsldav", "s32", 0b1, 0b0>;
851 defm MVE_VRMLSLDAVHs32 : MVE_VMLSLDAV_multi<"vrmlsldavh", "s32", 0b0, 0b1>;
853 // end of mve_rDest instructions
855 // start of mve_comp instructions
857 class MVE_comp<InstrItinClass itin, string iname, string suffix,
858 string cstr, list<dag> pattern=[]>
859 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm), itin, iname, suffix,
860 "$Qd, $Qn, $Qm", vpred_r, cstr, pattern> {
865 let Inst{22} = Qd{3};
866 let Inst{19-17} = Qn{2-0};
868 let Inst{15-13} = Qd{2-0};
870 let Inst{10-9} = 0b11;
873 let Inst{3-1} = Qm{2-0};
877 class MVE_VMINMAXNM<string iname, string suffix, bit sz, bit bit_21,
878 list<dag> pattern=[]>
879 : MVE_comp<NoItinerary, iname, suffix, "", pattern> {
882 let Inst{25-24} = 0b11;
884 let Inst{21} = bit_21;
891 let Predicates = [HasMVEFloat];
894 def MVE_VMAXNMf32 : MVE_VMINMAXNM<"vmaxnm", "f32", 0b0, 0b0>;
895 def MVE_VMAXNMf16 : MVE_VMINMAXNM<"vmaxnm", "f16", 0b1, 0b0>;
897 let Predicates = [HasMVEFloat] in {
898 def : Pat<(v4f32 (fmaxnum (v4f32 MQPR:$val1), (v4f32 MQPR:$val2))),
899 (v4f32 (MVE_VMAXNMf32 (v4f32 MQPR:$val1), (v4f32 MQPR:$val2)))>;
900 def : Pat<(v8f16 (fmaxnum (v8f16 MQPR:$val1), (v8f16 MQPR:$val2))),
901 (v8f16 (MVE_VMAXNMf16 (v8f16 MQPR:$val1), (v8f16 MQPR:$val2)))>;
904 def MVE_VMINNMf32 : MVE_VMINMAXNM<"vminnm", "f32", 0b0, 0b1>;
905 def MVE_VMINNMf16 : MVE_VMINMAXNM<"vminnm", "f16", 0b1, 0b1>;
907 let Predicates = [HasMVEFloat] in {
908 def : Pat<(v4f32 (fminnum (v4f32 MQPR:$val1), (v4f32 MQPR:$val2))),
909 (v4f32 (MVE_VMINNMf32 (v4f32 MQPR:$val1), (v4f32 MQPR:$val2)))>;
910 def : Pat<(v8f16 (fminnum (v8f16 MQPR:$val1), (v8f16 MQPR:$val2))),
911 (v8f16 (MVE_VMINNMf16 (v8f16 MQPR:$val1), (v8f16 MQPR:$val2)))>;
915 class MVE_VMINMAX<string iname, string suffix, bit U, bits<2> size,
916 bit bit_4, list<dag> pattern=[]>
917 : MVE_comp<NoItinerary, iname, suffix, "", pattern> {
920 let Inst{25-24} = 0b11;
922 let Inst{21-20} = size{1-0};
929 multiclass MVE_VMINMAX_all_sizes<string iname, bit bit_4> {
930 def s8 : MVE_VMINMAX<iname, "s8", 0b0, 0b00, bit_4>;
931 def s16 : MVE_VMINMAX<iname, "s16", 0b0, 0b01, bit_4>;
932 def s32 : MVE_VMINMAX<iname, "s32", 0b0, 0b10, bit_4>;
933 def u8 : MVE_VMINMAX<iname, "u8", 0b1, 0b00, bit_4>;
934 def u16 : MVE_VMINMAX<iname, "u16", 0b1, 0b01, bit_4>;
935 def u32 : MVE_VMINMAX<iname, "u32", 0b1, 0b10, bit_4>;
938 defm MVE_VMAX : MVE_VMINMAX_all_sizes<"vmax", 0b0>;
939 defm MVE_VMIN : MVE_VMINMAX_all_sizes<"vmin", 0b1>;
941 let Predicates = [HasMVEInt] in {
942 def : Pat<(v16i8 (smin (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
943 (v16i8 (MVE_VMINs8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
944 def : Pat<(v8i16 (smin (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
945 (v8i16 (MVE_VMINs16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
946 def : Pat<(v4i32 (smin (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
947 (v4i32 (MVE_VMINs32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
949 def : Pat<(v16i8 (smax (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
950 (v16i8 (MVE_VMAXs8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
951 def : Pat<(v8i16 (smax (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
952 (v8i16 (MVE_VMAXs16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
953 def : Pat<(v4i32 (smax (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
954 (v4i32 (MVE_VMAXs32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
956 def : Pat<(v16i8 (umin (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
957 (v16i8 (MVE_VMINu8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
958 def : Pat<(v8i16 (umin (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
959 (v8i16 (MVE_VMINu16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
960 def : Pat<(v4i32 (umin (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
961 (v4i32 (MVE_VMINu32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
963 def : Pat<(v16i8 (umax (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
964 (v16i8 (MVE_VMAXu8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
965 def : Pat<(v8i16 (umax (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
966 (v8i16 (MVE_VMAXu16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
967 def : Pat<(v4i32 (umax (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
968 (v4i32 (MVE_VMAXu32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
971 // end of mve_comp instructions
973 // start of mve_bit instructions
975 class MVE_bit_arith<dag oops, dag iops, string iname, string suffix,
976 string ops, string cstr, list<dag> pattern=[]>
977 : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred_r, cstr, pattern> {
981 let Inst{22} = Qd{3};
982 let Inst{15-13} = Qd{2-0};
984 let Inst{3-1} = Qm{2-0};
987 def MVE_VBIC : MVE_bit_arith<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm),
988 "vbic", "", "$Qd, $Qn, $Qm", ""> {
992 let Inst{25-23} = 0b110;
993 let Inst{21-20} = 0b01;
994 let Inst{19-17} = Qn{2-0};
996 let Inst{12-8} = 0b00001;
1003 class MVE_VREV<string iname, string suffix, bits<2> size, bits<2> bit_8_7, string cstr="">
1004 : MVE_bit_arith<(outs MQPR:$Qd), (ins MQPR:$Qm), iname,
1005 suffix, "$Qd, $Qm", cstr> {
1008 let Inst{25-23} = 0b111;
1009 let Inst{21-20} = 0b11;
1010 let Inst{19-18} = size;
1011 let Inst{17-16} = 0b00;
1012 let Inst{12-9} = 0b0000;
1013 let Inst{8-7} = bit_8_7;
1019 def MVE_VREV64_8 : MVE_VREV<"vrev64", "8", 0b00, 0b00, "@earlyclobber $Qd">;
1020 def MVE_VREV64_16 : MVE_VREV<"vrev64", "16", 0b01, 0b00, "@earlyclobber $Qd">;
1021 def MVE_VREV64_32 : MVE_VREV<"vrev64", "32", 0b10, 0b00, "@earlyclobber $Qd">;
1023 def MVE_VREV32_8 : MVE_VREV<"vrev32", "8", 0b00, 0b01>;
1024 def MVE_VREV32_16 : MVE_VREV<"vrev32", "16", 0b01, 0b01>;
1026 def MVE_VREV16_8 : MVE_VREV<"vrev16", "8", 0b00, 0b10>;
1028 let Predicates = [HasMVEInt] in {
1029 def : Pat<(v4i32 (ARMvrev64 (v4i32 MQPR:$src))),
1030 (v4i32 (MVE_VREV64_32 (v4i32 MQPR:$src)))>;
1031 def : Pat<(v8i16 (ARMvrev64 (v8i16 MQPR:$src))),
1032 (v8i16 (MVE_VREV64_16 (v8i16 MQPR:$src)))>;
1033 def : Pat<(v16i8 (ARMvrev64 (v16i8 MQPR:$src))),
1034 (v16i8 (MVE_VREV64_8 (v16i8 MQPR:$src)))>;
1036 def : Pat<(v8i16 (ARMvrev32 (v8i16 MQPR:$src))),
1037 (v8i16 (MVE_VREV32_16 (v8i16 MQPR:$src)))>;
1038 def : Pat<(v16i8 (ARMvrev32 (v16i8 MQPR:$src))),
1039 (v16i8 (MVE_VREV32_8 (v16i8 MQPR:$src)))>;
1041 def : Pat<(v16i8 (ARMvrev16 (v16i8 MQPR:$src))),
1042 (v16i8 (MVE_VREV16_8 (v16i8 MQPR:$src)))>;
1044 def : Pat<(v4f32 (ARMvrev64 (v4f32 MQPR:$src))),
1045 (v4f32 (MVE_VREV64_32 (v4f32 MQPR:$src)))>;
1046 def : Pat<(v8f16 (ARMvrev64 (v8f16 MQPR:$src))),
1047 (v8f16 (MVE_VREV64_16 (v8f16 MQPR:$src)))>;
1048 def : Pat<(v8f16 (ARMvrev32 (v8f16 MQPR:$src))),
1049 (v8f16 (MVE_VREV32_16 (v8f16 MQPR:$src)))>;
1052 def MVE_VMVN : MVE_bit_arith<(outs MQPR:$Qd), (ins MQPR:$Qm),
1053 "vmvn", "", "$Qd, $Qm", ""> {
1055 let Inst{25-23} = 0b111;
1056 let Inst{21-16} = 0b110000;
1057 let Inst{12-6} = 0b0010111;
1062 let Predicates = [HasMVEInt] in {
1063 def : Pat<(v16i8 (vnotq (v16i8 MQPR:$val1))),
1064 (v16i8 (MVE_VMVN (v16i8 MQPR:$val1)))>;
1065 def : Pat<(v8i16 (vnotq (v8i16 MQPR:$val1))),
1066 (v8i16 (MVE_VMVN (v8i16 MQPR:$val1)))>;
1067 def : Pat<(v4i32 (vnotq (v4i32 MQPR:$val1))),
1068 (v4i32 (MVE_VMVN (v4i32 MQPR:$val1)))>;
1069 def : Pat<(v2i64 (vnotq (v2i64 MQPR:$val1))),
1070 (v2i64 (MVE_VMVN (v2i64 MQPR:$val1)))>;
1073 class MVE_bit_ops<string iname, bits<2> bit_21_20, bit bit_28>
1074 : MVE_bit_arith<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm),
1075 iname, "", "$Qd, $Qn, $Qm", ""> {
1078 let Inst{28} = bit_28;
1079 let Inst{25-23} = 0b110;
1080 let Inst{21-20} = bit_21_20;
1081 let Inst{19-17} = Qn{2-0};
1083 let Inst{12-8} = 0b00001;
1084 let Inst{7} = Qn{3};
1090 def MVE_VEOR : MVE_bit_ops<"veor", 0b00, 0b1>;
1091 def MVE_VORN : MVE_bit_ops<"vorn", 0b11, 0b0>;
1092 def MVE_VORR : MVE_bit_ops<"vorr", 0b10, 0b0>;
1093 def MVE_VAND : MVE_bit_ops<"vand", 0b00, 0b0>;
1095 // add ignored suffixes as aliases
1097 foreach s=["s8", "s16", "s32", "u8", "u16", "u32", "i8", "i16", "i32", "f16", "f32"] in {
1098 def : MVEInstAlias<"vbic${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc",
1099 (MVE_VBIC MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>;
1100 def : MVEInstAlias<"veor${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc",
1101 (MVE_VEOR MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>;
1102 def : MVEInstAlias<"vorn${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc",
1103 (MVE_VORN MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>;
1104 def : MVEInstAlias<"vorr${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc",
1105 (MVE_VORR MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>;
1106 def : MVEInstAlias<"vand${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc",
1107 (MVE_VAND MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>;
1110 let Predicates = [HasMVEInt] in {
1111 def : Pat<(v16i8 (and (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
1112 (v16i8 (MVE_VAND (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1113 def : Pat<(v8i16 (and (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
1114 (v8i16 (MVE_VAND (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1115 def : Pat<(v4i32 (and (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
1116 (v4i32 (MVE_VAND (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
1117 def : Pat<(v2i64 (and (v2i64 MQPR:$val1), (v2i64 MQPR:$val2))),
1118 (v2i64 (MVE_VAND (v2i64 MQPR:$val1), (v2i64 MQPR:$val2)))>;
1120 def : Pat<(v16i8 (or (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
1121 (v16i8 (MVE_VORR (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1122 def : Pat<(v8i16 (or (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
1123 (v8i16 (MVE_VORR (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1124 def : Pat<(v4i32 (or (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
1125 (v4i32 (MVE_VORR (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
1126 def : Pat<(v2i64 (or (v2i64 MQPR:$val1), (v2i64 MQPR:$val2))),
1127 (v2i64 (MVE_VORR (v2i64 MQPR:$val1), (v2i64 MQPR:$val2)))>;
1129 def : Pat<(v16i8 (xor (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
1130 (v16i8 (MVE_VEOR (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1131 def : Pat<(v8i16 (xor (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
1132 (v8i16 (MVE_VEOR (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1133 def : Pat<(v4i32 (xor (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
1134 (v4i32 (MVE_VEOR (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
1135 def : Pat<(v2i64 (xor (v2i64 MQPR:$val1), (v2i64 MQPR:$val2))),
1136 (v2i64 (MVE_VEOR (v2i64 MQPR:$val1), (v2i64 MQPR:$val2)))>;
1138 def : Pat<(v16i8 (and (v16i8 MQPR:$val1), (vnotq MQPR:$val2))),
1139 (v16i8 (MVE_VBIC (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1140 def : Pat<(v8i16 (and (v8i16 MQPR:$val1), (vnotq MQPR:$val2))),
1141 (v8i16 (MVE_VBIC (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1142 def : Pat<(v4i32 (and (v4i32 MQPR:$val1), (vnotq MQPR:$val2))),
1143 (v4i32 (MVE_VBIC (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
1144 def : Pat<(v2i64 (and (v2i64 MQPR:$val1), (vnotq MQPR:$val2))),
1145 (v2i64 (MVE_VBIC (v2i64 MQPR:$val1), (v2i64 MQPR:$val2)))>;
1147 def : Pat<(v16i8 (or (v16i8 MQPR:$val1), (vnotq MQPR:$val2))),
1148 (v16i8 (MVE_VORN (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1149 def : Pat<(v8i16 (or (v8i16 MQPR:$val1), (vnotq MQPR:$val2))),
1150 (v8i16 (MVE_VORN (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1151 def : Pat<(v4i32 (or (v4i32 MQPR:$val1), (vnotq MQPR:$val2))),
1152 (v4i32 (MVE_VORN (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
1153 def : Pat<(v2i64 (or (v2i64 MQPR:$val1), (vnotq MQPR:$val2))),
1154 (v2i64 (MVE_VORN (v2i64 MQPR:$val1), (v2i64 MQPR:$val2)))>;
1157 class MVE_bit_cmode<string iname, string suffix, bits<4> cmode, dag inOps>
1158 : MVE_p<(outs MQPR:$Qd), inOps, NoItinerary,
1159 iname, suffix, "$Qd, $imm", vpred_n, "$Qd = $Qd_src"> {
1163 let Inst{28} = imm{7};
1164 let Inst{27-23} = 0b11111;
1165 let Inst{22} = Qd{3};
1166 let Inst{21-19} = 0b000;
1167 let Inst{18-16} = imm{6-4};
1168 let Inst{15-13} = Qd{2-0};
1170 let Inst{11-8} = cmode;
1171 let Inst{7-6} = 0b01;
1173 let Inst{3-0} = imm{3-0};
1176 class MVE_VORR<string suffix, bits<4> cmode, ExpandImm imm_type>
1177 : MVE_bit_cmode<"vorr", suffix, cmode, (ins MQPR:$Qd_src, imm_type:$imm)> {
1181 def MVE_VORRIZ0v4i32 : MVE_VORR<"i32", 0b0001, expzero00>;
1182 def MVE_VORRIZ0v8i16 : MVE_VORR<"i16", 0b1001, expzero00>;
1183 def MVE_VORRIZ8v4i32 : MVE_VORR<"i32", 0b0011, expzero08>;
1184 def MVE_VORRIZ8v8i16 : MVE_VORR<"i16", 0b1011, expzero08>;
1185 def MVE_VORRIZ16v4i32 : MVE_VORR<"i32", 0b0101, expzero16>;
1186 def MVE_VORRIZ24v4i32 : MVE_VORR<"i32", 0b0111, expzero24>;
1188 def MVE_VORNIZ0v4i32 : MVEAsmPseudo<"vorn${vp}.i32\t$Qd, $imm",
1189 (ins MQPR:$Qd_src, expzero00inv32:$imm, vpred_n:$vp), (outs MQPR:$Qd)>;
1190 def MVE_VORNIZ0v8i16 : MVEAsmPseudo<"vorn${vp}.i16\t$Qd, $imm",
1191 (ins MQPR:$Qd_src, expzero00inv16:$imm, vpred_n:$vp), (outs MQPR:$Qd)>;
1192 def MVE_VORNIZ8v4i32 : MVEAsmPseudo<"vorn${vp}.i32\t$Qd, $imm",
1193 (ins MQPR:$Qd_src, expzero08inv32:$imm, vpred_n:$vp), (outs MQPR:$Qd)>;
1194 def MVE_VORNIZ8v8i16 : MVEAsmPseudo<"vorn${vp}.i16\t$Qd, $imm",
1195 (ins MQPR:$Qd_src, expzero08inv16:$imm, vpred_n:$vp), (outs MQPR:$Qd)>;
1196 def MVE_VORNIZ16v4i32 : MVEAsmPseudo<"vorn${vp}.i32\t$Qd, $imm",
1197 (ins MQPR:$Qd_src, expzero16inv32:$imm, vpred_n:$vp), (outs MQPR:$Qd)>;
1198 def MVE_VORNIZ24v4i32 : MVEAsmPseudo<"vorn${vp}.i32\t$Qd, $imm",
1199 (ins MQPR:$Qd_src, expzero24inv32:$imm, vpred_n:$vp), (outs MQPR:$Qd)>;
1201 def MVE_VMOV : MVEInstAlias<"vmov${vp}\t$Qd, $Qm",
1202 (MVE_VORR MQPR:$Qd, MQPR:$Qm, MQPR:$Qm, vpred_r:$vp)>;
1204 class MVE_VBIC<string suffix, bits<4> cmode, ExpandImm imm_type>
1205 : MVE_bit_cmode<"vbic", suffix, cmode, (ins MQPR:$Qd_src, imm_type:$imm)> {
1209 def MVE_VBICIZ0v4i32 : MVE_VBIC<"i32", 0b0001, expzero00>;
1210 def MVE_VBICIZ0v8i16 : MVE_VBIC<"i16", 0b1001, expzero00>;
1211 def MVE_VBICIZ8v4i32 : MVE_VBIC<"i32", 0b0011, expzero08>;
1212 def MVE_VBICIZ8v8i16 : MVE_VBIC<"i16", 0b1011, expzero08>;
1213 def MVE_VBICIZ16v4i32 : MVE_VBIC<"i32", 0b0101, expzero16>;
1214 def MVE_VBICIZ24v4i32 : MVE_VBIC<"i32", 0b0111, expzero24>;
1216 def MVE_VANDIZ0v4i32 : MVEAsmPseudo<"vand${vp}.i32\t$Qda, $imm",
1217 (ins MQPR:$Qda_src, expzero00inv32:$imm, vpred_n:$vp), (outs MQPR:$Qda)>;
1218 def MVE_VANDIZ0v8i16 : MVEAsmPseudo<"vand${vp}.i16\t$Qda, $imm",
1219 (ins MQPR:$Qda_src, expzero00inv16:$imm, vpred_n:$vp), (outs MQPR:$Qda)>;
1220 def MVE_VANDIZ8v4i32 : MVEAsmPseudo<"vand${vp}.i32\t$Qda, $imm",
1221 (ins MQPR:$Qda_src, expzero08inv32:$imm, vpred_n:$vp), (outs MQPR:$Qda)>;
1222 def MVE_VANDIZ8v8i16 : MVEAsmPseudo<"vand${vp}.i16\t$Qda, $imm",
1223 (ins MQPR:$Qda_src, expzero08inv16:$imm, vpred_n:$vp), (outs MQPR:$Qda)>;
1224 def MVE_VANDIZ16v4i32 : MVEAsmPseudo<"vand${vp}.i32\t$Qda, $imm",
1225 (ins MQPR:$Qda_src, expzero16inv32:$imm, vpred_n:$vp), (outs MQPR:$Qda)>;
1226 def MVE_VANDIZ24v4i32 : MVEAsmPseudo<"vand${vp}.i32\t$Qda, $imm",
1227 (ins MQPR:$Qda_src, expzero24inv32:$imm, vpred_n:$vp), (outs MQPR:$Qda)>;
1229 class MVE_VMOV_lane_direction {
1236 def MVE_VMOV_from_lane : MVE_VMOV_lane_direction {
1238 let oops = (outs rGPR:$Rt);
1239 let iops = (ins MQPR:$Qd);
1240 let ops = "$Rt, $Qd$Idx";
1243 def MVE_VMOV_to_lane : MVE_VMOV_lane_direction {
1245 let oops = (outs MQPR:$Qd);
1246 let iops = (ins MQPR:$Qd_src, rGPR:$Rt);
1247 let ops = "$Qd$Idx, $Rt";
1248 let cstr = "$Qd = $Qd_src";
1251 class MVE_VMOV_lane<string suffix, bit U, dag indexop,
1252 MVE_VMOV_lane_direction dir>
1253 : MVE_VMOV_lane_base<dir.oops, !con(dir.iops, indexop), NoItinerary,
1254 "vmov", suffix, dir.ops, dir.cstr, []> {
1258 let Inst{31-24} = 0b11101110;
1260 let Inst{20} = dir.bit_20;
1261 let Inst{19-17} = Qd{2-0};
1262 let Inst{15-12} = Rt{3-0};
1263 let Inst{11-8} = 0b1011;
1264 let Inst{7} = Qd{3};
1265 let Inst{4-0} = 0b10000;
1268 class MVE_VMOV_lane_32<MVE_VMOV_lane_direction dir>
1269 : MVE_VMOV_lane<"32", 0b0, (ins MVEVectorIndex<4>:$Idx), dir> {
1272 let Inst{6-5} = 0b00;
1273 let Inst{16} = Idx{1};
1274 let Inst{21} = Idx{0};
1276 let Predicates = [HasFPRegsV8_1M];
1279 class MVE_VMOV_lane_16<string suffix, bit U, MVE_VMOV_lane_direction dir>
1280 : MVE_VMOV_lane<suffix, U, (ins MVEVectorIndex<8>:$Idx), dir> {
1284 let Inst{16} = Idx{2};
1285 let Inst{21} = Idx{1};
1286 let Inst{6} = Idx{0};
1289 class MVE_VMOV_lane_8<string suffix, bit U, MVE_VMOV_lane_direction dir>
1290 : MVE_VMOV_lane<suffix, U, (ins MVEVectorIndex<16>:$Idx), dir> {
1293 let Inst{16} = Idx{3};
1294 let Inst{21} = Idx{2};
1295 let Inst{6} = Idx{1};
1296 let Inst{5} = Idx{0};
1299 def MVE_VMOV_from_lane_32 : MVE_VMOV_lane_32< MVE_VMOV_from_lane>;
1300 def MVE_VMOV_to_lane_32 : MVE_VMOV_lane_32< MVE_VMOV_to_lane>;
1301 def MVE_VMOV_from_lane_s16 : MVE_VMOV_lane_16<"s16", 0b0, MVE_VMOV_from_lane>;
1302 def MVE_VMOV_from_lane_u16 : MVE_VMOV_lane_16<"u16", 0b1, MVE_VMOV_from_lane>;
1303 def MVE_VMOV_to_lane_16 : MVE_VMOV_lane_16< "16", 0b0, MVE_VMOV_to_lane>;
1304 def MVE_VMOV_from_lane_s8 : MVE_VMOV_lane_8 < "s8", 0b0, MVE_VMOV_from_lane>;
1305 def MVE_VMOV_from_lane_u8 : MVE_VMOV_lane_8 < "u8", 0b1, MVE_VMOV_from_lane>;
1306 def MVE_VMOV_to_lane_8 : MVE_VMOV_lane_8 < "8", 0b0, MVE_VMOV_to_lane>;
1308 let Predicates = [HasMVEInt] in {
1309 def : Pat<(extractelt (v2f64 MQPR:$src), imm:$lane),
1310 (f64 (EXTRACT_SUBREG MQPR:$src, (DSubReg_f64_reg imm:$lane)))>;
1311 def : Pat<(insertelt (v2f64 MQPR:$src1), DPR:$src2, imm:$lane),
1312 (INSERT_SUBREG (v2f64 (COPY_TO_REGCLASS MQPR:$src1, MQPR)), DPR:$src2, (DSubReg_f64_reg imm:$lane))>;
1314 def : Pat<(extractelt (v4i32 MQPR:$src), imm:$lane),
1316 (i32 (EXTRACT_SUBREG MQPR:$src, (SSubReg_f32_reg imm:$lane))), rGPR)>;
1317 def : Pat<(insertelt (v4i32 MQPR:$src1), rGPR:$src2, imm:$lane),
1318 (MVE_VMOV_to_lane_32 MQPR:$src1, rGPR:$src2, imm:$lane)>;
1320 def : Pat<(vector_insert (v16i8 MQPR:$src1), rGPR:$src2, imm:$lane),
1321 (MVE_VMOV_to_lane_8 MQPR:$src1, rGPR:$src2, imm:$lane)>;
1322 def : Pat<(vector_insert (v8i16 MQPR:$src1), rGPR:$src2, imm:$lane),
1323 (MVE_VMOV_to_lane_16 MQPR:$src1, rGPR:$src2, imm:$lane)>;
1325 def : Pat<(ARMvgetlanes (v16i8 MQPR:$src), imm:$lane),
1326 (MVE_VMOV_from_lane_s8 MQPR:$src, imm:$lane)>;
1327 def : Pat<(ARMvgetlanes (v8i16 MQPR:$src), imm:$lane),
1328 (MVE_VMOV_from_lane_s16 MQPR:$src, imm:$lane)>;
1329 def : Pat<(ARMvgetlaneu (v16i8 MQPR:$src), imm:$lane),
1330 (MVE_VMOV_from_lane_u8 MQPR:$src, imm:$lane)>;
1331 def : Pat<(ARMvgetlaneu (v8i16 MQPR:$src), imm:$lane),
1332 (MVE_VMOV_from_lane_u16 MQPR:$src, imm:$lane)>;
1334 def : Pat<(v16i8 (scalar_to_vector GPR:$src)),
1335 (MVE_VMOV_to_lane_8 (v16i8 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
1336 def : Pat<(v8i16 (scalar_to_vector GPR:$src)),
1337 (MVE_VMOV_to_lane_16 (v8i16 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
1338 def : Pat<(v4i32 (scalar_to_vector GPR:$src)),
1339 (MVE_VMOV_to_lane_32 (v4i32 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
1341 // Floating point patterns, still enabled under HasMVEInt
1342 def : Pat<(extractelt (v4f32 MQPR:$src), imm:$lane),
1343 (COPY_TO_REGCLASS (f32 (EXTRACT_SUBREG MQPR:$src, (SSubReg_f32_reg imm:$lane))), SPR)>;
1344 def : Pat<(insertelt (v4f32 MQPR:$src1), (f32 SPR:$src2), imm:$lane),
1345 (INSERT_SUBREG (v4f32 (COPY_TO_REGCLASS MQPR:$src1, MQPR)), SPR:$src2, (SSubReg_f32_reg imm:$lane))>;
1347 def : Pat<(insertelt (v8f16 MQPR:$src1), HPR:$src2, imm:$lane),
1348 (MVE_VMOV_to_lane_16 MQPR:$src1, (COPY_TO_REGCLASS HPR:$src2, rGPR), imm:$lane)>;
1349 def : Pat<(extractelt (v8f16 MQPR:$src), imm:$lane),
1350 (COPY_TO_REGCLASS (MVE_VMOV_from_lane_u16 MQPR:$src, imm:$lane), HPR)>;
1352 def : Pat<(v4f32 (scalar_to_vector SPR:$src)),
1353 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), SPR:$src, ssub_0)>;
1354 def : Pat<(v4f32 (scalar_to_vector GPR:$src)),
1355 (MVE_VMOV_to_lane_32 (v4f32 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
1356 def : Pat<(v8f16 (scalar_to_vector HPR:$src)),
1357 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), HPR:$src, ssub_0)>;
1358 def : Pat<(v8f16 (scalar_to_vector GPR:$src)),
1359 (MVE_VMOV_to_lane_16 (v8f16 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
1362 // end of mve_bit instructions
1364 // start of MVE Integer instructions
1366 class MVE_int<string iname, string suffix, bits<2> size, list<dag> pattern=[]>
1367 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm), NoItinerary,
1368 iname, suffix, "$Qd, $Qn, $Qm", vpred_r, "", pattern> {
1373 let Inst{22} = Qd{3};
1374 let Inst{21-20} = size;
1375 let Inst{19-17} = Qn{2-0};
1376 let Inst{15-13} = Qd{2-0};
1377 let Inst{7} = Qn{3};
1379 let Inst{5} = Qm{3};
1380 let Inst{3-1} = Qm{2-0};
1383 class MVE_VMULt1<string suffix, bits<2> size, list<dag> pattern=[]>
1384 : MVE_int<"vmul", suffix, size, pattern> {
1387 let Inst{25-23} = 0b110;
1389 let Inst{12-8} = 0b01001;
1394 def MVE_VMULt1i8 : MVE_VMULt1<"i8", 0b00>;
1395 def MVE_VMULt1i16 : MVE_VMULt1<"i16", 0b01>;
1396 def MVE_VMULt1i32 : MVE_VMULt1<"i32", 0b10>;
1398 let Predicates = [HasMVEInt] in {
1399 def : Pat<(v16i8 (mul (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
1400 (v16i8 (MVE_VMULt1i8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1401 def : Pat<(v8i16 (mul (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
1402 (v8i16 (MVE_VMULt1i16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1403 def : Pat<(v4i32 (mul (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
1404 (v4i32 (MVE_VMULt1i32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
1407 class MVE_VQxDMULH<string iname, string suffix, bits<2> size, bit rounding,
1408 list<dag> pattern=[]>
1409 : MVE_int<iname, suffix, size, pattern> {
1411 let Inst{28} = rounding;
1412 let Inst{25-23} = 0b110;
1414 let Inst{12-8} = 0b01011;
1419 class MVE_VQDMULH<string suffix, bits<2> size, list<dag> pattern=[]>
1420 : MVE_VQxDMULH<"vqdmulh", suffix, size, 0b0, pattern>;
1421 class MVE_VQRDMULH<string suffix, bits<2> size, list<dag> pattern=[]>
1422 : MVE_VQxDMULH<"vqrdmulh", suffix, size, 0b1, pattern>;
1424 def MVE_VQDMULHi8 : MVE_VQDMULH<"s8", 0b00>;
1425 def MVE_VQDMULHi16 : MVE_VQDMULH<"s16", 0b01>;
1426 def MVE_VQDMULHi32 : MVE_VQDMULH<"s32", 0b10>;
1428 def MVE_VQRDMULHi8 : MVE_VQRDMULH<"s8", 0b00>;
1429 def MVE_VQRDMULHi16 : MVE_VQRDMULH<"s16", 0b01>;
1430 def MVE_VQRDMULHi32 : MVE_VQRDMULH<"s32", 0b10>;
1432 class MVE_VADDSUB<string iname, string suffix, bits<2> size, bit subtract,
1433 list<dag> pattern=[]>
1434 : MVE_int<iname, suffix, size, pattern> {
1436 let Inst{28} = subtract;
1437 let Inst{25-23} = 0b110;
1439 let Inst{12-8} = 0b01000;
1444 class MVE_VADD<string suffix, bits<2> size, list<dag> pattern=[]>
1445 : MVE_VADDSUB<"vadd", suffix, size, 0b0, pattern>;
1446 class MVE_VSUB<string suffix, bits<2> size, list<dag> pattern=[]>
1447 : MVE_VADDSUB<"vsub", suffix, size, 0b1, pattern>;
1449 def MVE_VADDi8 : MVE_VADD<"i8", 0b00>;
1450 def MVE_VADDi16 : MVE_VADD<"i16", 0b01>;
1451 def MVE_VADDi32 : MVE_VADD<"i32", 0b10>;
1453 let Predicates = [HasMVEInt] in {
1454 def : Pat<(v16i8 (add (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
1455 (v16i8 (MVE_VADDi8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1456 def : Pat<(v8i16 (add (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
1457 (v8i16 (MVE_VADDi16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1458 def : Pat<(v4i32 (add (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
1459 (v4i32 (MVE_VADDi32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
1462 def MVE_VSUBi8 : MVE_VSUB<"i8", 0b00>;
1463 def MVE_VSUBi16 : MVE_VSUB<"i16", 0b01>;
1464 def MVE_VSUBi32 : MVE_VSUB<"i32", 0b10>;
1466 let Predicates = [HasMVEInt] in {
1467 def : Pat<(v16i8 (sub (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
1468 (v16i8 (MVE_VSUBi8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1469 def : Pat<(v8i16 (sub (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
1470 (v8i16 (MVE_VSUBi16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1471 def : Pat<(v4i32 (sub (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
1472 (v4i32 (MVE_VSUBi32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
1475 class MVE_VQADDSUB<string iname, string suffix, bit U, bit subtract,
1476 bits<2> size, list<dag> pattern=[]>
1477 : MVE_int<iname, suffix, size, pattern> {
1480 let Inst{25-23} = 0b110;
1482 let Inst{12-10} = 0b000;
1483 let Inst{9} = subtract;
1489 class MVE_VQADD<string suffix, bit U, bits<2> size, list<dag> pattern=[]>
1490 : MVE_VQADDSUB<"vqadd", suffix, U, 0b0, size, pattern>;
1491 class MVE_VQSUB<string suffix, bit U, bits<2> size, list<dag> pattern=[]>
1492 : MVE_VQADDSUB<"vqsub", suffix, U, 0b1, size, pattern>;
1494 def MVE_VQADDs8 : MVE_VQADD<"s8", 0b0, 0b00>;
1495 def MVE_VQADDs16 : MVE_VQADD<"s16", 0b0, 0b01>;
1496 def MVE_VQADDs32 : MVE_VQADD<"s32", 0b0, 0b10>;
1497 def MVE_VQADDu8 : MVE_VQADD<"u8", 0b1, 0b00>;
1498 def MVE_VQADDu16 : MVE_VQADD<"u16", 0b1, 0b01>;
1499 def MVE_VQADDu32 : MVE_VQADD<"u32", 0b1, 0b10>;
1501 def MVE_VQSUBs8 : MVE_VQSUB<"s8", 0b0, 0b00>;
1502 def MVE_VQSUBs16 : MVE_VQSUB<"s16", 0b0, 0b01>;
1503 def MVE_VQSUBs32 : MVE_VQSUB<"s32", 0b0, 0b10>;
1504 def MVE_VQSUBu8 : MVE_VQSUB<"u8", 0b1, 0b00>;
1505 def MVE_VQSUBu16 : MVE_VQSUB<"u16", 0b1, 0b01>;
1506 def MVE_VQSUBu32 : MVE_VQSUB<"u32", 0b1, 0b10>;
1508 class MVE_VABD_int<string suffix, bit U, bits<2> size, list<dag> pattern=[]>
1509 : MVE_int<"vabd", suffix, size, pattern> {
1512 let Inst{25-23} = 0b110;
1514 let Inst{12-8} = 0b00111;
1519 def MVE_VABDs8 : MVE_VABD_int<"s8", 0b0, 0b00>;
1520 def MVE_VABDs16 : MVE_VABD_int<"s16", 0b0, 0b01>;
1521 def MVE_VABDs32 : MVE_VABD_int<"s32", 0b0, 0b10>;
1522 def MVE_VABDu8 : MVE_VABD_int<"u8", 0b1, 0b00>;
1523 def MVE_VABDu16 : MVE_VABD_int<"u16", 0b1, 0b01>;
1524 def MVE_VABDu32 : MVE_VABD_int<"u32", 0b1, 0b10>;
1526 class MVE_VRHADD<string suffix, bit U, bits<2> size, list<dag> pattern=[]>
1527 : MVE_int<"vrhadd", suffix, size, pattern> {
1530 let Inst{25-23} = 0b110;
1532 let Inst{12-8} = 0b00001;
1537 def MVE_VRHADDs8 : MVE_VRHADD<"s8", 0b0, 0b00>;
1538 def MVE_VRHADDs16 : MVE_VRHADD<"s16", 0b0, 0b01>;
1539 def MVE_VRHADDs32 : MVE_VRHADD<"s32", 0b0, 0b10>;
1540 def MVE_VRHADDu8 : MVE_VRHADD<"u8", 0b1, 0b00>;
1541 def MVE_VRHADDu16 : MVE_VRHADD<"u16", 0b1, 0b01>;
1542 def MVE_VRHADDu32 : MVE_VRHADD<"u32", 0b1, 0b10>;
1544 class MVE_VHADDSUB<string iname, string suffix, bit U, bit subtract,
1545 bits<2> size, list<dag> pattern=[]>
1546 : MVE_int<iname, suffix, size, pattern> {
1549 let Inst{25-23} = 0b110;
1551 let Inst{12-10} = 0b000;
1552 let Inst{9} = subtract;
1558 class MVE_VHADD<string suffix, bit U, bits<2> size,
1559 list<dag> pattern=[]>
1560 : MVE_VHADDSUB<"vhadd", suffix, U, 0b0, size, pattern>;
1561 class MVE_VHSUB<string suffix, bit U, bits<2> size,
1562 list<dag> pattern=[]>
1563 : MVE_VHADDSUB<"vhsub", suffix, U, 0b1, size, pattern>;
1565 def MVE_VHADDs8 : MVE_VHADD<"s8", 0b0, 0b00>;
1566 def MVE_VHADDs16 : MVE_VHADD<"s16", 0b0, 0b01>;
1567 def MVE_VHADDs32 : MVE_VHADD<"s32", 0b0, 0b10>;
1568 def MVE_VHADDu8 : MVE_VHADD<"u8", 0b1, 0b00>;
1569 def MVE_VHADDu16 : MVE_VHADD<"u16", 0b1, 0b01>;
1570 def MVE_VHADDu32 : MVE_VHADD<"u32", 0b1, 0b10>;
1572 def MVE_VHSUBs8 : MVE_VHSUB<"s8", 0b0, 0b00>;
1573 def MVE_VHSUBs16 : MVE_VHSUB<"s16", 0b0, 0b01>;
1574 def MVE_VHSUBs32 : MVE_VHSUB<"s32", 0b0, 0b10>;
1575 def MVE_VHSUBu8 : MVE_VHSUB<"u8", 0b1, 0b00>;
1576 def MVE_VHSUBu16 : MVE_VHSUB<"u16", 0b1, 0b01>;
1577 def MVE_VHSUBu32 : MVE_VHSUB<"u32", 0b1, 0b10>;
1579 let Predicates = [HasMVEInt] in {
1580 def : Pat<(v16i8 (ARMvshrsImm
1581 (v16i8 (add (v16i8 MQPR:$v1), (v16i8 MQPR:$v2))), 1)),
1583 (v16i8 MQPR:$v1), (v16i8 MQPR:$v2)))>;
1584 def : Pat<(v8i16 (ARMvshrsImm
1585 (v8i16 (add (v8i16 MQPR:$v1), (v8i16 MQPR:$v2))), 1)),
1586 (v8i16 (MVE_VHADDs16
1587 (v8i16 MQPR:$v1), (v8i16 MQPR:$v2)))>;
1588 def : Pat<(v4i32 (ARMvshrsImm
1589 (v4i32 (add (v4i32 MQPR:$v1), (v4i32 MQPR:$v2))), 1)),
1590 (v4i32 (MVE_VHADDs32
1591 (v4i32 MQPR:$v1), (v4i32 MQPR:$v2)))>;
1593 def : Pat<(v16i8 (ARMvshruImm
1594 (v16i8 (add (v16i8 MQPR:$v1), (v16i8 MQPR:$v2))), 1)),
1596 (v16i8 MQPR:$v1), (v16i8 MQPR:$v2)))>;
1597 def : Pat<(v8i16 (ARMvshruImm
1598 (v8i16 (add (v8i16 MQPR:$v1), (v8i16 MQPR:$v2))), 1)),
1599 (v8i16 (MVE_VHADDu16
1600 (v8i16 MQPR:$v1), (v8i16 MQPR:$v2)))>;
1601 def : Pat<(v4i32 (ARMvshruImm
1602 (v4i32 (add (v4i32 MQPR:$v1), (v4i32 MQPR:$v2))), 1)),
1603 (v4i32 (MVE_VHADDu32
1604 (v4i32 MQPR:$v1), (v4i32 MQPR:$v2)))>;
1606 def : Pat<(v16i8 (ARMvshrsImm
1607 (v16i8 (sub (v16i8 MQPR:$v1), (v16i8 MQPR:$v2))), 1)),
1609 (v16i8 MQPR:$v1), (v16i8 MQPR:$v2)))>;
1610 def : Pat<(v8i16 (ARMvshrsImm
1611 (v8i16 (sub (v8i16 MQPR:$v1), (v8i16 MQPR:$v2))), 1)),
1612 (v8i16 (MVE_VHSUBs16
1613 (v8i16 MQPR:$v1), (v8i16 MQPR:$v2)))>;
1614 def : Pat<(v4i32 (ARMvshrsImm
1615 (v4i32 (sub (v4i32 MQPR:$v1), (v4i32 MQPR:$v2))), 1)),
1616 (v4i32 (MVE_VHSUBs32
1617 (v4i32 MQPR:$v1), (v4i32 MQPR:$v2)))>;
1619 def : Pat<(v16i8 (ARMvshruImm
1620 (v16i8 (sub (v16i8 MQPR:$v1), (v16i8 MQPR:$v2))), 1)),
1622 (v16i8 MQPR:$v1), (v16i8 MQPR:$v2)))>;
1623 def : Pat<(v8i16 (ARMvshruImm
1624 (v8i16 (sub (v8i16 MQPR:$v1), (v8i16 MQPR:$v2))), 1)),
1625 (v8i16 (MVE_VHSUBu16
1626 (v8i16 MQPR:$v1), (v8i16 MQPR:$v2)))>;
1627 def : Pat<(v4i32 (ARMvshruImm
1628 (v4i32 (sub (v4i32 MQPR:$v1), (v4i32 MQPR:$v2))), 1)),
1629 (v4i32 (MVE_VHSUBu32
1630 (v4i32 MQPR:$v1), (v4i32 MQPR:$v2)))>;
1633 class MVE_VDUP<string suffix, bit B, bit E, list<dag> pattern=[]>
1634 : MVE_p<(outs MQPR:$Qd), (ins rGPR:$Rt), NoItinerary,
1635 "vdup", suffix, "$Qd, $Rt", vpred_r, "", pattern> {
1640 let Inst{25-23} = 0b101;
1642 let Inst{21-20} = 0b10;
1643 let Inst{19-17} = Qd{2-0};
1645 let Inst{15-12} = Rt;
1646 let Inst{11-8} = 0b1011;
1647 let Inst{7} = Qd{3};
1650 let Inst{4-0} = 0b10000;
1653 def MVE_VDUP32 : MVE_VDUP<"32", 0b0, 0b0>;
1654 def MVE_VDUP16 : MVE_VDUP<"16", 0b0, 0b1>;
1655 def MVE_VDUP8 : MVE_VDUP<"8", 0b1, 0b0>;
1657 let Predicates = [HasMVEInt] in {
1658 def : Pat<(v16i8 (ARMvdup (i32 rGPR:$elem))),
1659 (MVE_VDUP8 rGPR:$elem)>;
1660 def : Pat<(v8i16 (ARMvdup (i32 rGPR:$elem))),
1661 (MVE_VDUP16 rGPR:$elem)>;
1662 def : Pat<(v4i32 (ARMvdup (i32 rGPR:$elem))),
1663 (MVE_VDUP32 rGPR:$elem)>;
1665 def : Pat<(v4i32 (ARMvduplane (v4i32 MQPR:$src), imm:$lane)),
1666 (MVE_VDUP32 (MVE_VMOV_from_lane_32 MQPR:$src, imm:$lane))>;
1667 // For the 16-bit and 8-bit vduplanes we don't care about the signedness
1668 // of the lane move operation as we only want the lowest 8/16 bits anyway.
1669 def : Pat<(v8i16 (ARMvduplane (v8i16 MQPR:$src), imm:$lane)),
1670 (MVE_VDUP16 (MVE_VMOV_from_lane_u16 MQPR:$src, imm:$lane))>;
1671 def : Pat<(v16i8 (ARMvduplane (v16i8 MQPR:$src), imm:$lane)),
1672 (MVE_VDUP8 (MVE_VMOV_from_lane_u8 MQPR:$src, imm:$lane))>;
1674 def : Pat<(v4f32 (ARMvdup (f32 SPR:$elem))),
1675 (v4f32 (MVE_VDUP32 (i32 (COPY_TO_REGCLASS (f32 SPR:$elem), rGPR))))>;
1676 def : Pat<(v8f16 (ARMvdup (f16 HPR:$elem))),
1677 (v8f16 (MVE_VDUP16 (i32 (COPY_TO_REGCLASS (f16 HPR:$elem), rGPR))))>;
1679 def : Pat<(v4f32 (ARMvduplane (v4f32 MQPR:$src), imm:$lane)),
1680 (MVE_VDUP32 (MVE_VMOV_from_lane_32 MQPR:$src, imm:$lane))>;
1681 def : Pat<(v8f16 (ARMvduplane (v8f16 MQPR:$src), imm:$lane)),
1682 (MVE_VDUP16 (MVE_VMOV_from_lane_u16 MQPR:$src, imm:$lane))>;
1686 class MVEIntSingleSrc<string iname, string suffix, bits<2> size,
1687 list<dag> pattern=[]>
1688 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qm), NoItinerary,
1689 iname, suffix, "$Qd, $Qm", vpred_r, "", pattern> {
1693 let Inst{22} = Qd{3};
1694 let Inst{19-18} = size{1-0};
1695 let Inst{15-13} = Qd{2-0};
1696 let Inst{5} = Qm{3};
1697 let Inst{3-1} = Qm{2-0};
1700 class MVE_VCLSCLZ<string iname, string suffix, bits<2> size,
1701 bit count_zeroes, list<dag> pattern=[]>
1702 : MVEIntSingleSrc<iname, suffix, size, pattern> {
1705 let Inst{25-23} = 0b111;
1706 let Inst{21-20} = 0b11;
1707 let Inst{17-16} = 0b00;
1708 let Inst{12-8} = 0b00100;
1709 let Inst{7} = count_zeroes;
1715 def MVE_VCLSs8 : MVE_VCLSCLZ<"vcls", "s8", 0b00, 0b0>;
1716 def MVE_VCLSs16 : MVE_VCLSCLZ<"vcls", "s16", 0b01, 0b0>;
1717 def MVE_VCLSs32 : MVE_VCLSCLZ<"vcls", "s32", 0b10, 0b0>;
1719 def MVE_VCLZs8 : MVE_VCLSCLZ<"vclz", "i8", 0b00, 0b1>;
1720 def MVE_VCLZs16 : MVE_VCLSCLZ<"vclz", "i16", 0b01, 0b1>;
1721 def MVE_VCLZs32 : MVE_VCLSCLZ<"vclz", "i32", 0b10, 0b1>;
1723 class MVE_VABSNEG_int<string iname, string suffix, bits<2> size, bit negate,
1724 list<dag> pattern=[]>
1725 : MVEIntSingleSrc<iname, suffix, size, pattern> {
1728 let Inst{25-23} = 0b111;
1729 let Inst{21-20} = 0b11;
1730 let Inst{17-16} = 0b01;
1731 let Inst{12-8} = 0b00011;
1732 let Inst{7} = negate;
1738 def MVE_VABSs8 : MVE_VABSNEG_int<"vabs", "s8", 0b00, 0b0>;
1739 def MVE_VABSs16 : MVE_VABSNEG_int<"vabs", "s16", 0b01, 0b0>;
1740 def MVE_VABSs32 : MVE_VABSNEG_int<"vabs", "s32", 0b10, 0b0>;
1742 let Predicates = [HasMVEInt] in {
1743 def : Pat<(v16i8 (abs (v16i8 MQPR:$v))),
1744 (v16i8 (MVE_VABSs8 $v))>;
1745 def : Pat<(v8i16 (abs (v8i16 MQPR:$v))),
1746 (v8i16 (MVE_VABSs16 $v))>;
1747 def : Pat<(v4i32 (abs (v4i32 MQPR:$v))),
1748 (v4i32 (MVE_VABSs32 $v))>;
1751 def MVE_VNEGs8 : MVE_VABSNEG_int<"vneg", "s8", 0b00, 0b1>;
1752 def MVE_VNEGs16 : MVE_VABSNEG_int<"vneg", "s16", 0b01, 0b1>;
1753 def MVE_VNEGs32 : MVE_VABSNEG_int<"vneg", "s32", 0b10, 0b1>;
1755 let Predicates = [HasMVEInt] in {
1756 def : Pat<(v16i8 (vnegq (v16i8 MQPR:$v))),
1757 (v16i8 (MVE_VNEGs8 $v))>;
1758 def : Pat<(v8i16 (vnegq (v8i16 MQPR:$v))),
1759 (v8i16 (MVE_VNEGs16 $v))>;
1760 def : Pat<(v4i32 (vnegq (v4i32 MQPR:$v))),
1761 (v4i32 (MVE_VNEGs32 $v))>;
1764 class MVE_VQABSNEG<string iname, string suffix, bits<2> size,
1765 bit negate, list<dag> pattern=[]>
1766 : MVEIntSingleSrc<iname, suffix, size, pattern> {
1769 let Inst{25-23} = 0b111;
1770 let Inst{21-20} = 0b11;
1771 let Inst{17-16} = 0b00;
1772 let Inst{12-8} = 0b00111;
1773 let Inst{7} = negate;
1779 def MVE_VQABSs8 : MVE_VQABSNEG<"vqabs", "s8", 0b00, 0b0>;
1780 def MVE_VQABSs16 : MVE_VQABSNEG<"vqabs", "s16", 0b01, 0b0>;
1781 def MVE_VQABSs32 : MVE_VQABSNEG<"vqabs", "s32", 0b10, 0b0>;
1783 def MVE_VQNEGs8 : MVE_VQABSNEG<"vqneg", "s8", 0b00, 0b1>;
1784 def MVE_VQNEGs16 : MVE_VQABSNEG<"vqneg", "s16", 0b01, 0b1>;
1785 def MVE_VQNEGs32 : MVE_VQABSNEG<"vqneg", "s32", 0b10, 0b1>;
1787 class MVE_mod_imm<string iname, string suffix, bits<4> cmode, bit op,
1788 dag iops, list<dag> pattern=[]>
1789 : MVE_p<(outs MQPR:$Qd), iops, NoItinerary, iname, suffix, "$Qd, $imm",
1790 vpred_r, "", pattern> {
1794 let Inst{28} = imm{7};
1795 let Inst{25-23} = 0b111;
1796 let Inst{22} = Qd{3};
1797 let Inst{21-19} = 0b000;
1798 let Inst{18-16} = imm{6-4};
1799 let Inst{15-13} = Qd{2-0};
1801 let Inst{11-8} = cmode{3-0};
1802 let Inst{7-6} = 0b01;
1805 let Inst{3-0} = imm{3-0};
1807 let DecoderMethod = "DecodeMVEModImmInstruction";
1810 let isReMaterializable = 1 in {
1811 let isAsCheapAsAMove = 1 in {
1812 def MVE_VMOVimmi8 : MVE_mod_imm<"vmov", "i8", {1,1,1,0}, 0b0, (ins nImmSplatI8:$imm)>;
1813 def MVE_VMOVimmi16 : MVE_mod_imm<"vmov", "i16", {1,0,?,0}, 0b0, (ins nImmSplatI16:$imm)> {
1814 let Inst{9} = imm{9};
1816 def MVE_VMOVimmi32 : MVE_mod_imm<"vmov", "i32", {?,?,?,?}, 0b0, (ins nImmVMOVI32:$imm)> {
1817 let Inst{11-8} = imm{11-8};
1819 def MVE_VMOVimmi64 : MVE_mod_imm<"vmov", "i64", {1,1,1,0}, 0b1, (ins nImmSplatI64:$imm)>;
1820 def MVE_VMOVimmf32 : MVE_mod_imm<"vmov", "f32", {1,1,1,1}, 0b0, (ins nImmVMOVF32:$imm)>;
1821 } // let isAsCheapAsAMove = 1
1823 def MVE_VMVNimmi16 : MVE_mod_imm<"vmvn", "i16", {1,0,?,0}, 0b1, (ins nImmSplatI16:$imm)> {
1824 let Inst{9} = imm{9};
1826 def MVE_VMVNimmi32 : MVE_mod_imm<"vmvn", "i32", {?,?,?,?}, 0b1, (ins nImmVMOVI32:$imm)> {
1827 let Inst{11-8} = imm{11-8};
1829 } // let isReMaterializable = 1
1831 let Predicates = [HasMVEInt] in {
1832 def : Pat<(v16i8 (ARMvmovImm timm:$simm)),
1833 (v16i8 (MVE_VMOVimmi8 nImmSplatI8:$simm))>;
1834 def : Pat<(v8i16 (ARMvmovImm timm:$simm)),
1835 (v8i16 (MVE_VMOVimmi16 nImmSplatI16:$simm))>;
1836 def : Pat<(v4i32 (ARMvmovImm timm:$simm)),
1837 (v4i32 (MVE_VMOVimmi32 nImmVMOVI32:$simm))>;
1839 def : Pat<(v8i16 (ARMvmvnImm timm:$simm)),
1840 (v8i16 (MVE_VMVNimmi16 nImmSplatI16:$simm))>;
1841 def : Pat<(v4i32 (ARMvmvnImm timm:$simm)),
1842 (v4i32 (MVE_VMVNimmi32 nImmVMOVI32:$simm))>;
1844 def : Pat<(v4f32 (ARMvmovFPImm timm:$simm)),
1845 (v4f32 (MVE_VMOVimmf32 nImmVMOVF32:$simm))>;
1848 class MVE_VMINMAXA<string iname, string suffix, bits<2> size,
1849 bit bit_12, list<dag> pattern=[]>
1850 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qd_src, MQPR:$Qm),
1851 NoItinerary, iname, suffix, "$Qd, $Qm", vpred_n, "$Qd = $Qd_src",
1857 let Inst{25-23} = 0b100;
1858 let Inst{22} = Qd{3};
1859 let Inst{21-20} = 0b11;
1860 let Inst{19-18} = size;
1861 let Inst{17-16} = 0b11;
1862 let Inst{15-13} = Qd{2-0};
1863 let Inst{12} = bit_12;
1864 let Inst{11-6} = 0b111010;
1865 let Inst{5} = Qm{3};
1867 let Inst{3-1} = Qm{2-0};
1871 def MVE_VMAXAs8 : MVE_VMINMAXA<"vmaxa", "s8", 0b00, 0b0>;
1872 def MVE_VMAXAs16 : MVE_VMINMAXA<"vmaxa", "s16", 0b01, 0b0>;
1873 def MVE_VMAXAs32 : MVE_VMINMAXA<"vmaxa", "s32", 0b10, 0b0>;
1875 def MVE_VMINAs8 : MVE_VMINMAXA<"vmina", "s8", 0b00, 0b1>;
1876 def MVE_VMINAs16 : MVE_VMINMAXA<"vmina", "s16", 0b01, 0b1>;
1877 def MVE_VMINAs32 : MVE_VMINMAXA<"vmina", "s32", 0b10, 0b1>;
1879 // end of MVE Integer instructions
1881 // start of mve_imm_shift instructions
1883 def MVE_VSHLC : MVE_p<(outs rGPR:$RdmDest, MQPR:$Qd),
1884 (ins MQPR:$QdSrc, rGPR:$RdmSrc, long_shift:$imm),
1885 NoItinerary, "vshlc", "", "$QdSrc, $RdmSrc, $imm",
1886 vpred_n, "$RdmDest = $RdmSrc,$Qd = $QdSrc"> {
1892 let Inst{25-23} = 0b101;
1893 let Inst{22} = Qd{3};
1895 let Inst{20-16} = imm{4-0};
1896 let Inst{15-13} = Qd{2-0};
1897 let Inst{12-4} = 0b011111100;
1898 let Inst{3-0} = RdmDest{3-0};
1901 class MVE_shift_imm<dag oops, dag iops, string iname, string suffix,
1902 string ops, vpred_ops vpred, string cstr,
1903 list<dag> pattern=[]>
1904 : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, pattern> {
1908 let Inst{22} = Qd{3};
1909 let Inst{15-13} = Qd{2-0};
1910 let Inst{5} = Qm{3};
1911 let Inst{3-1} = Qm{2-0};
1914 class MVE_VMOVL<string iname, string suffix, bits<2> sz, bit U,
1915 list<dag> pattern=[]>
1916 : MVE_shift_imm<(outs MQPR:$Qd), (ins MQPR:$Qm),
1917 iname, suffix, "$Qd, $Qm", vpred_r, "",
1920 let Inst{25-23} = 0b101;
1922 let Inst{20-19} = sz{1-0};
1923 let Inst{18-16} = 0b000;
1924 let Inst{11-6} = 0b111101;
1929 multiclass MVE_VMOVL_shift_half<string iname, string suffix, bits<2> sz, bit U,
1930 list<dag> pattern=[]> {
1931 def bh : MVE_VMOVL<!strconcat(iname, "b"), suffix, sz, U, pattern> {
1934 def th : MVE_VMOVL<!strconcat(iname, "t"), suffix, sz, U, pattern> {
1939 defm MVE_VMOVLs8 : MVE_VMOVL_shift_half<"vmovl", "s8", 0b01, 0b0>;
1940 defm MVE_VMOVLu8 : MVE_VMOVL_shift_half<"vmovl", "u8", 0b01, 0b1>;
1941 defm MVE_VMOVLs16 : MVE_VMOVL_shift_half<"vmovl", "s16", 0b10, 0b0>;
1942 defm MVE_VMOVLu16 : MVE_VMOVL_shift_half<"vmovl", "u16", 0b10, 0b1>;
1944 let Predicates = [HasMVEInt] in {
1945 def : Pat<(sext_inreg (v4i32 MQPR:$src), v4i16),
1946 (MVE_VMOVLs16bh MQPR:$src)>;
1947 def : Pat<(sext_inreg (v8i16 MQPR:$src), v8i8),
1948 (MVE_VMOVLs8bh MQPR:$src)>;
1949 def : Pat<(sext_inreg (v4i32 MQPR:$src), v4i8),
1950 (MVE_VMOVLs16bh (MVE_VMOVLs8bh MQPR:$src))>;
1952 // zext_inreg 16 -> 32
1953 def : Pat<(and (v4i32 MQPR:$src), (v4i32 (ARMvmovImm (i32 0xCFF)))),
1954 (MVE_VMOVLu16bh MQPR:$src)>;
1955 // zext_inreg 8 -> 16
1956 def : Pat<(and (v8i16 MQPR:$src), (v8i16 (ARMvmovImm (i32 0x8FF)))),
1957 (MVE_VMOVLu8bh MQPR:$src)>;
1961 class MVE_VSHLL_imm<string iname, string suffix, bit U, bit th,
1962 dag immops, list<dag> pattern=[]>
1963 : MVE_shift_imm<(outs MQPR:$Qd), !con((ins MQPR:$Qm), immops),
1964 iname, suffix, "$Qd, $Qm, $imm", vpred_r, "", pattern> {
1966 let Inst{25-23} = 0b101;
1969 let Inst{11-6} = 0b111101;
1974 // The immediate VSHLL instructions accept shift counts from 1 up to
1975 // the lane width (8 or 16), but the full-width shifts have an
1976 // entirely separate encoding, given below with 'lw' in the name.
1978 class MVE_VSHLL_imm8<string iname, string suffix,
1979 bit U, bit th, list<dag> pattern=[]>
1980 : MVE_VSHLL_imm<iname, suffix, U, th, (ins mve_shift_imm1_7:$imm), pattern> {
1982 let Inst{20-19} = 0b01;
1983 let Inst{18-16} = imm;
1986 class MVE_VSHLL_imm16<string iname, string suffix,
1987 bit U, bit th, list<dag> pattern=[]>
1988 : MVE_VSHLL_imm<iname, suffix, U, th, (ins mve_shift_imm1_15:$imm), pattern> {
1991 let Inst{19-16} = imm;
1994 def MVE_VSHLL_imms8bh : MVE_VSHLL_imm8 <"vshllb", "s8", 0b0, 0b0>;
1995 def MVE_VSHLL_imms8th : MVE_VSHLL_imm8 <"vshllt", "s8", 0b0, 0b1>;
1996 def MVE_VSHLL_immu8bh : MVE_VSHLL_imm8 <"vshllb", "u8", 0b1, 0b0>;
1997 def MVE_VSHLL_immu8th : MVE_VSHLL_imm8 <"vshllt", "u8", 0b1, 0b1>;
1998 def MVE_VSHLL_imms16bh : MVE_VSHLL_imm16<"vshllb", "s16", 0b0, 0b0>;
1999 def MVE_VSHLL_imms16th : MVE_VSHLL_imm16<"vshllt", "s16", 0b0, 0b1>;
2000 def MVE_VSHLL_immu16bh : MVE_VSHLL_imm16<"vshllb", "u16", 0b1, 0b0>;
2001 def MVE_VSHLL_immu16th : MVE_VSHLL_imm16<"vshllt", "u16", 0b1, 0b1>;
2003 class MVE_VSHLL_by_lane_width<string iname, string suffix, bits<2> size,
2004 bit U, string ops, list<dag> pattern=[]>
2005 : MVE_shift_imm<(outs MQPR:$Qd), (ins MQPR:$Qm),
2006 iname, suffix, ops, vpred_r, "", pattern> {
2008 let Inst{25-23} = 0b100;
2009 let Inst{21-20} = 0b11;
2010 let Inst{19-18} = size{1-0};
2011 let Inst{17-16} = 0b01;
2012 let Inst{11-6} = 0b111000;
2017 multiclass MVE_VSHLL_lw<string iname, string suffix, bits<2> sz, bit U,
2018 string ops, list<dag> pattern=[]> {
2019 def bh : MVE_VSHLL_by_lane_width<iname#"b", suffix, sz, U, ops, pattern> {
2022 def th : MVE_VSHLL_by_lane_width<iname#"t", suffix, sz, U, ops, pattern> {
2027 defm MVE_VSHLL_lws8 : MVE_VSHLL_lw<"vshll", "s8", 0b00, 0b0, "$Qd, $Qm, #8">;
2028 defm MVE_VSHLL_lws16 : MVE_VSHLL_lw<"vshll", "s16", 0b01, 0b0, "$Qd, $Qm, #16">;
2029 defm MVE_VSHLL_lwu8 : MVE_VSHLL_lw<"vshll", "u8", 0b00, 0b1, "$Qd, $Qm, #8">;
2030 defm MVE_VSHLL_lwu16 : MVE_VSHLL_lw<"vshll", "u16", 0b01, 0b1, "$Qd, $Qm, #16">;
2032 class MVE_VxSHRN<string iname, string suffix, bit bit_12, bit bit_28,
2033 dag immops, list<dag> pattern=[]>
2034 : MVE_shift_imm<(outs MQPR:$Qd), !con((ins MQPR:$QdSrc, MQPR:$Qm), immops),
2035 iname, suffix, "$Qd, $Qm, $imm", vpred_n, "$Qd = $QdSrc",
2039 let Inst{28} = bit_28;
2040 let Inst{25-23} = 0b101;
2042 let Inst{20-16} = imm{4-0};
2043 let Inst{12} = bit_12;
2044 let Inst{11-6} = 0b111111;
2049 def MVE_VRSHRNi16bh : MVE_VxSHRN<
2050 "vrshrnb", "i16", 0b0, 0b1, (ins shr_imm8:$imm)> {
2051 let Inst{20-19} = 0b01;
2053 def MVE_VRSHRNi16th : MVE_VxSHRN<
2054 "vrshrnt", "i16", 0b1, 0b1,(ins shr_imm8:$imm)> {
2055 let Inst{20-19} = 0b01;
2057 def MVE_VRSHRNi32bh : MVE_VxSHRN<
2058 "vrshrnb", "i32", 0b0, 0b1, (ins shr_imm16:$imm)> {
2061 def MVE_VRSHRNi32th : MVE_VxSHRN<
2062 "vrshrnt", "i32", 0b1, 0b1, (ins shr_imm16:$imm)> {
2066 def MVE_VSHRNi16bh : MVE_VxSHRN<
2067 "vshrnb", "i16", 0b0, 0b0, (ins shr_imm8:$imm)> {
2068 let Inst{20-19} = 0b01;
2070 def MVE_VSHRNi16th : MVE_VxSHRN<
2071 "vshrnt", "i16", 0b1, 0b0, (ins shr_imm8:$imm)> {
2072 let Inst{20-19} = 0b01;
2074 def MVE_VSHRNi32bh : MVE_VxSHRN<
2075 "vshrnb", "i32", 0b0, 0b0, (ins shr_imm16:$imm)> {
2078 def MVE_VSHRNi32th : MVE_VxSHRN<
2079 "vshrnt", "i32", 0b1, 0b0, (ins shr_imm16:$imm)> {
2083 class MVE_VxQRSHRUN<string iname, string suffix, bit bit_28, bit bit_12, dag immops,
2084 list<dag> pattern=[]>
2085 : MVE_shift_imm<(outs MQPR:$Qd), !con((ins MQPR:$QdSrc, MQPR:$Qm), immops),
2086 iname, suffix, "$Qd, $Qm, $imm", vpred_n, "$Qd = $QdSrc",
2090 let Inst{28} = bit_28;
2091 let Inst{25-23} = 0b101;
2093 let Inst{20-16} = imm{4-0};
2094 let Inst{12} = bit_12;
2095 let Inst{11-6} = 0b111111;
2100 def MVE_VQRSHRUNs16bh : MVE_VxQRSHRUN<
2101 "vqrshrunb", "s16", 0b1, 0b0, (ins shr_imm8:$imm)> {
2102 let Inst{20-19} = 0b01;
2104 def MVE_VQRSHRUNs16th : MVE_VxQRSHRUN<
2105 "vqrshrunt", "s16", 0b1, 0b1, (ins shr_imm8:$imm)> {
2106 let Inst{20-19} = 0b01;
2108 def MVE_VQRSHRUNs32bh : MVE_VxQRSHRUN<
2109 "vqrshrunb", "s32", 0b1, 0b0, (ins shr_imm16:$imm)> {
2112 def MVE_VQRSHRUNs32th : MVE_VxQRSHRUN<
2113 "vqrshrunt", "s32", 0b1, 0b1, (ins shr_imm16:$imm)> {
2117 def MVE_VQSHRUNs16bh : MVE_VxQRSHRUN<
2118 "vqshrunb", "s16", 0b0, 0b0, (ins shr_imm8:$imm)> {
2119 let Inst{20-19} = 0b01;
2121 def MVE_VQSHRUNs16th : MVE_VxQRSHRUN<
2122 "vqshrunt", "s16", 0b0, 0b1, (ins shr_imm8:$imm)> {
2123 let Inst{20-19} = 0b01;
2125 def MVE_VQSHRUNs32bh : MVE_VxQRSHRUN<
2126 "vqshrunb", "s32", 0b0, 0b0, (ins shr_imm16:$imm)> {
2129 def MVE_VQSHRUNs32th : MVE_VxQRSHRUN<
2130 "vqshrunt", "s32", 0b0, 0b1, (ins shr_imm16:$imm)> {
2134 class MVE_VxQRSHRN<string iname, string suffix, bit bit_0, bit bit_12,
2135 dag immops, list<dag> pattern=[]>
2136 : MVE_shift_imm<(outs MQPR:$Qd), !con((ins MQPR:$QdSrc, MQPR:$Qm), immops),
2137 iname, suffix, "$Qd, $Qm, $imm", vpred_n, "$Qd = $QdSrc",
2141 let Inst{25-23} = 0b101;
2143 let Inst{20-16} = imm{4-0};
2144 let Inst{12} = bit_12;
2145 let Inst{11-6} = 0b111101;
2147 let Inst{0} = bit_0;
2150 multiclass MVE_VxQRSHRN_types<string iname, bit bit_0, bit bit_12> {
2151 def s16 : MVE_VxQRSHRN<iname, "s16", bit_0, bit_12, (ins shr_imm8:$imm)> {
2153 let Inst{20-19} = 0b01;
2155 def u16 : MVE_VxQRSHRN<iname, "u16", bit_0, bit_12, (ins shr_imm8:$imm)> {
2157 let Inst{20-19} = 0b01;
2159 def s32 : MVE_VxQRSHRN<iname, "s32", bit_0, bit_12, (ins shr_imm16:$imm)> {
2163 def u32 : MVE_VxQRSHRN<iname, "u32", bit_0, bit_12, (ins shr_imm16:$imm)> {
2169 defm MVE_VQRSHRNbh : MVE_VxQRSHRN_types<"vqrshrnb", 0b1, 0b0>;
2170 defm MVE_VQRSHRNth : MVE_VxQRSHRN_types<"vqrshrnt", 0b1, 0b1>;
2171 defm MVE_VQSHRNbh : MVE_VxQRSHRN_types<"vqshrnb", 0b0, 0b0>;
2172 defm MVE_VQSHRNth : MVE_VxQRSHRN_types<"vqshrnt", 0b0, 0b1>;
2174 // end of mve_imm_shift instructions
2176 // start of mve_shift instructions
2178 class MVE_shift_by_vec<string iname, string suffix, bit U,
2179 bits<2> size, bit bit_4, bit bit_8>
2180 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qm, MQPR:$Qn), NoItinerary,
2181 iname, suffix, "$Qd, $Qm, $Qn", vpred_r, "", []> {
2182 // Shift instructions which take a vector of shift counts
2188 let Inst{25-24} = 0b11;
2190 let Inst{22} = Qd{3};
2191 let Inst{21-20} = size;
2192 let Inst{19-17} = Qn{2-0};
2194 let Inst{15-13} = Qd{2-0};
2195 let Inst{12-9} = 0b0010;
2196 let Inst{8} = bit_8;
2197 let Inst{7} = Qn{3};
2199 let Inst{5} = Qm{3};
2200 let Inst{4} = bit_4;
2201 let Inst{3-1} = Qm{2-0};
2205 multiclass mve_shift_by_vec_multi<string iname, bit bit_4, bit bit_8> {
2206 def s8 : MVE_shift_by_vec<iname, "s8", 0b0, 0b00, bit_4, bit_8>;
2207 def s16 : MVE_shift_by_vec<iname, "s16", 0b0, 0b01, bit_4, bit_8>;
2208 def s32 : MVE_shift_by_vec<iname, "s32", 0b0, 0b10, bit_4, bit_8>;
2209 def u8 : MVE_shift_by_vec<iname, "u8", 0b1, 0b00, bit_4, bit_8>;
2210 def u16 : MVE_shift_by_vec<iname, "u16", 0b1, 0b01, bit_4, bit_8>;
2211 def u32 : MVE_shift_by_vec<iname, "u32", 0b1, 0b10, bit_4, bit_8>;
2214 defm MVE_VSHL_by_vec : mve_shift_by_vec_multi<"vshl", 0b0, 0b0>;
2215 defm MVE_VQSHL_by_vec : mve_shift_by_vec_multi<"vqshl", 0b1, 0b0>;
2216 defm MVE_VQRSHL_by_vec : mve_shift_by_vec_multi<"vqrshl", 0b1, 0b1>;
2217 defm MVE_VRSHL_by_vec : mve_shift_by_vec_multi<"vrshl", 0b0, 0b1>;
2219 let Predicates = [HasMVEInt] in {
2220 def : Pat<(v4i32 (ARMvshlu (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn))),
2221 (v4i32 (MVE_VSHL_by_vecu32 (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn)))>;
2222 def : Pat<(v8i16 (ARMvshlu (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn))),
2223 (v8i16 (MVE_VSHL_by_vecu16 (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn)))>;
2224 def : Pat<(v16i8 (ARMvshlu (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn))),
2225 (v16i8 (MVE_VSHL_by_vecu8 (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn)))>;
2227 def : Pat<(v4i32 (ARMvshls (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn))),
2228 (v4i32 (MVE_VSHL_by_vecs32 (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn)))>;
2229 def : Pat<(v8i16 (ARMvshls (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn))),
2230 (v8i16 (MVE_VSHL_by_vecs16 (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn)))>;
2231 def : Pat<(v16i8 (ARMvshls (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn))),
2232 (v16i8 (MVE_VSHL_by_vecs8 (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn)))>;
2235 class MVE_shift_with_imm<string iname, string suffix, dag oops, dag iops,
2236 string ops, vpred_ops vpred, string cstr,
2237 list<dag> pattern=[]>
2238 : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, pattern> {
2243 let Inst{22} = Qd{3};
2244 let Inst{15-13} = Qd{2-0};
2245 let Inst{12-11} = 0b00;
2246 let Inst{7-6} = 0b01;
2247 let Inst{5} = Qm{3};
2249 let Inst{3-1} = Qm{2-0};
2253 class MVE_VSxI_imm<string iname, string suffix, bit bit_8, dag imm>
2254 : MVE_shift_with_imm<iname, suffix, (outs MQPR:$Qd),
2255 !con((ins MQPR:$Qd_src, MQPR:$Qm), imm),
2256 "$Qd, $Qm, $imm", vpred_n, "$Qd = $Qd_src"> {
2259 let Inst{25-24} = 0b11;
2260 let Inst{21-16} = imm;
2261 let Inst{10-9} = 0b10;
2262 let Inst{8} = bit_8;
2265 def MVE_VSRIimm8 : MVE_VSxI_imm<"vsri", "8", 0b0, (ins shr_imm8:$imm)> {
2266 let Inst{21-19} = 0b001;
2269 def MVE_VSRIimm16 : MVE_VSxI_imm<"vsri", "16", 0b0, (ins shr_imm16:$imm)> {
2270 let Inst{21-20} = 0b01;
2273 def MVE_VSRIimm32 : MVE_VSxI_imm<"vsri", "32", 0b0, (ins shr_imm32:$imm)> {
2277 def MVE_VSLIimm8 : MVE_VSxI_imm<"vsli", "8", 0b1, (ins imm0_7:$imm)> {
2278 let Inst{21-19} = 0b001;
2281 def MVE_VSLIimm16 : MVE_VSxI_imm<"vsli", "16", 0b1, (ins imm0_15:$imm)> {
2282 let Inst{21-20} = 0b01;
2285 def MVE_VSLIimm32 : MVE_VSxI_imm<"vsli", "32", 0b1,(ins imm0_31:$imm)> {
2289 class MVE_VQSHL_imm<string suffix, dag imm>
2290 : MVE_shift_with_imm<"vqshl", suffix, (outs MQPR:$Qd),
2291 !con((ins MQPR:$Qm), imm), "$Qd, $Qm, $imm",
2295 let Inst{25-24} = 0b11;
2296 let Inst{21-16} = imm;
2297 let Inst{10-8} = 0b111;
2300 def MVE_VSLIimms8 : MVE_VQSHL_imm<"s8", (ins imm0_7:$imm)> {
2302 let Inst{21-19} = 0b001;
2305 def MVE_VSLIimmu8 : MVE_VQSHL_imm<"u8", (ins imm0_7:$imm)> {
2307 let Inst{21-19} = 0b001;
2310 def MVE_VSLIimms16 : MVE_VQSHL_imm<"s16", (ins imm0_15:$imm)> {
2312 let Inst{21-20} = 0b01;
2315 def MVE_VSLIimmu16 : MVE_VQSHL_imm<"u16", (ins imm0_15:$imm)> {
2317 let Inst{21-20} = 0b01;
2320 def MVE_VSLIimms32 : MVE_VQSHL_imm<"s32", (ins imm0_31:$imm)> {
2325 def MVE_VSLIimmu32 : MVE_VQSHL_imm<"u32", (ins imm0_31:$imm)> {
2330 class MVE_VQSHLU_imm<string suffix, dag imm>
2331 : MVE_shift_with_imm<"vqshlu", suffix, (outs MQPR:$Qd),
2332 !con((ins MQPR:$Qm), imm), "$Qd, $Qm, $imm",
2337 let Inst{25-24} = 0b11;
2338 let Inst{21-16} = imm;
2339 let Inst{10-8} = 0b110;
2342 def MVE_VQSHLU_imms8 : MVE_VQSHLU_imm<"s8", (ins imm0_7:$imm)> {
2343 let Inst{21-19} = 0b001;
2346 def MVE_VQSHLU_imms16 : MVE_VQSHLU_imm<"s16", (ins imm0_15:$imm)> {
2347 let Inst{21-20} = 0b01;
2350 def MVE_VQSHLU_imms32 : MVE_VQSHLU_imm<"s32", (ins imm0_31:$imm)> {
2354 class MVE_VRSHR_imm<string suffix, dag imm>
2355 : MVE_shift_with_imm<"vrshr", suffix, (outs MQPR:$Qd),
2356 !con((ins MQPR:$Qm), imm), "$Qd, $Qm, $imm",
2360 let Inst{25-24} = 0b11;
2361 let Inst{21-16} = imm;
2362 let Inst{10-8} = 0b010;
2365 def MVE_VRSHR_imms8 : MVE_VRSHR_imm<"s8", (ins shr_imm8:$imm)> {
2367 let Inst{21-19} = 0b001;
2370 def MVE_VRSHR_immu8 : MVE_VRSHR_imm<"u8", (ins shr_imm8:$imm)> {
2372 let Inst{21-19} = 0b001;
2375 def MVE_VRSHR_imms16 : MVE_VRSHR_imm<"s16", (ins shr_imm16:$imm)> {
2377 let Inst{21-20} = 0b01;
2380 def MVE_VRSHR_immu16 : MVE_VRSHR_imm<"u16", (ins shr_imm16:$imm)> {
2382 let Inst{21-20} = 0b01;
2385 def MVE_VRSHR_imms32 : MVE_VRSHR_imm<"s32", (ins shr_imm32:$imm)> {
2390 def MVE_VRSHR_immu32 : MVE_VRSHR_imm<"u32", (ins shr_imm32:$imm)> {
2395 class MVE_VSHR_imm<string suffix, dag imm>
2396 : MVE_shift_with_imm<"vshr", suffix, (outs MQPR:$Qd),
2397 !con((ins MQPR:$Qm), imm), "$Qd, $Qm, $imm",
2401 let Inst{25-24} = 0b11;
2402 let Inst{21-16} = imm;
2403 let Inst{10-8} = 0b000;
2406 def MVE_VSHR_imms8 : MVE_VSHR_imm<"s8", (ins shr_imm8:$imm)> {
2408 let Inst{21-19} = 0b001;
2411 def MVE_VSHR_immu8 : MVE_VSHR_imm<"u8", (ins shr_imm8:$imm)> {
2413 let Inst{21-19} = 0b001;
2416 def MVE_VSHR_imms16 : MVE_VSHR_imm<"s16", (ins shr_imm16:$imm)> {
2418 let Inst{21-20} = 0b01;
2421 def MVE_VSHR_immu16 : MVE_VSHR_imm<"u16", (ins shr_imm16:$imm)> {
2423 let Inst{21-20} = 0b01;
2426 def MVE_VSHR_imms32 : MVE_VSHR_imm<"s32", (ins shr_imm32:$imm)> {
2431 def MVE_VSHR_immu32 : MVE_VSHR_imm<"u32", (ins shr_imm32:$imm)> {
2436 class MVE_VSHL_imm<string suffix, dag imm>
2437 : MVE_shift_with_imm<"vshl", suffix, (outs MQPR:$Qd),
2438 !con((ins MQPR:$Qm), imm), "$Qd, $Qm, $imm",
2443 let Inst{25-24} = 0b11;
2444 let Inst{21-16} = imm;
2445 let Inst{10-8} = 0b101;
2448 def MVE_VSHL_immi8 : MVE_VSHL_imm<"i8", (ins imm0_7:$imm)> {
2449 let Inst{21-19} = 0b001;
2452 def MVE_VSHL_immi16 : MVE_VSHL_imm<"i16", (ins imm0_15:$imm)> {
2453 let Inst{21-20} = 0b01;
2456 def MVE_VSHL_immi32 : MVE_VSHL_imm<"i32", (ins imm0_31:$imm)> {
2460 let Predicates = [HasMVEInt] in {
2461 def : Pat<(v4i32 (ARMvshlImm (v4i32 MQPR:$src), imm0_31:$imm)),
2462 (v4i32 (MVE_VSHL_immi32 (v4i32 MQPR:$src), imm0_31:$imm))>;
2463 def : Pat<(v8i16 (ARMvshlImm (v8i16 MQPR:$src), imm0_15:$imm)),
2464 (v8i16 (MVE_VSHL_immi16 (v8i16 MQPR:$src), imm0_15:$imm))>;
2465 def : Pat<(v16i8 (ARMvshlImm (v16i8 MQPR:$src), imm0_7:$imm)),
2466 (v16i8 (MVE_VSHL_immi8 (v16i8 MQPR:$src), imm0_7:$imm))>;
2468 def : Pat<(v4i32 (ARMvshruImm (v4i32 MQPR:$src), imm0_31:$imm)),
2469 (v4i32 (MVE_VSHR_immu32 (v4i32 MQPR:$src), imm0_31:$imm))>;
2470 def : Pat<(v8i16 (ARMvshruImm (v8i16 MQPR:$src), imm0_15:$imm)),
2471 (v8i16 (MVE_VSHR_immu16 (v8i16 MQPR:$src), imm0_15:$imm))>;
2472 def : Pat<(v16i8 (ARMvshruImm (v16i8 MQPR:$src), imm0_7:$imm)),
2473 (v16i8 (MVE_VSHR_immu8 (v16i8 MQPR:$src), imm0_7:$imm))>;
2475 def : Pat<(v4i32 (ARMvshrsImm (v4i32 MQPR:$src), imm0_31:$imm)),
2476 (v4i32 (MVE_VSHR_imms32 (v4i32 MQPR:$src), imm0_31:$imm))>;
2477 def : Pat<(v8i16 (ARMvshrsImm (v8i16 MQPR:$src), imm0_15:$imm)),
2478 (v8i16 (MVE_VSHR_imms16 (v8i16 MQPR:$src), imm0_15:$imm))>;
2479 def : Pat<(v16i8 (ARMvshrsImm (v16i8 MQPR:$src), imm0_7:$imm)),
2480 (v16i8 (MVE_VSHR_imms8 (v16i8 MQPR:$src), imm0_7:$imm))>;
2483 // end of mve_shift instructions
2485 // start of MVE Floating Point instructions
2487 class MVE_float<string iname, string suffix, dag oops, dag iops, string ops,
2488 vpred_ops vpred, string cstr, list<dag> pattern=[]>
2489 : MVE_f<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, pattern> {
2494 let Inst{5} = Qm{3};
2495 let Inst{3-1} = Qm{2-0};
2499 class MVE_VRINT<string rmode, bits<3> op, string suffix, bits<2> size,
2500 list<dag> pattern=[]>
2501 : MVE_float<!strconcat("vrint", rmode), suffix, (outs MQPR:$Qd),
2502 (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", pattern> {
2506 let Inst{25-23} = 0b111;
2507 let Inst{22} = Qd{3};
2508 let Inst{21-20} = 0b11;
2509 let Inst{19-18} = size;
2510 let Inst{17-16} = 0b10;
2511 let Inst{15-13} = Qd{2-0};
2512 let Inst{11-10} = 0b01;
2513 let Inst{9-7} = op{2-0};
2518 multiclass MVE_VRINT_ops<string suffix, bits<2> size, list<dag> pattern=[]> {
2519 def N : MVE_VRINT<"n", 0b000, suffix, size, pattern>;
2520 def X : MVE_VRINT<"x", 0b001, suffix, size, pattern>;
2521 def A : MVE_VRINT<"a", 0b010, suffix, size, pattern>;
2522 def Z : MVE_VRINT<"z", 0b011, suffix, size, pattern>;
2523 def M : MVE_VRINT<"m", 0b101, suffix, size, pattern>;
2524 def P : MVE_VRINT<"p", 0b111, suffix, size, pattern>;
2527 defm MVE_VRINTf16 : MVE_VRINT_ops<"f16", 0b01>;
2528 defm MVE_VRINTf32 : MVE_VRINT_ops<"f32", 0b10>;
2530 let Predicates = [HasMVEFloat] in {
2531 def : Pat<(v4f32 (frint (v4f32 MQPR:$val1))),
2532 (v4f32 (MVE_VRINTf32X (v4f32 MQPR:$val1)))>;
2533 def : Pat<(v8f16 (frint (v8f16 MQPR:$val1))),
2534 (v8f16 (MVE_VRINTf16X (v8f16 MQPR:$val1)))>;
2535 def : Pat<(v4f32 (fround (v4f32 MQPR:$val1))),
2536 (v4f32 (MVE_VRINTf32A (v4f32 MQPR:$val1)))>;
2537 def : Pat<(v8f16 (fround (v8f16 MQPR:$val1))),
2538 (v8f16 (MVE_VRINTf16A (v8f16 MQPR:$val1)))>;
2539 def : Pat<(v4f32 (ftrunc (v4f32 MQPR:$val1))),
2540 (v4f32 (MVE_VRINTf32Z (v4f32 MQPR:$val1)))>;
2541 def : Pat<(v8f16 (ftrunc (v8f16 MQPR:$val1))),
2542 (v8f16 (MVE_VRINTf16Z (v8f16 MQPR:$val1)))>;
2543 def : Pat<(v4f32 (ffloor (v4f32 MQPR:$val1))),
2544 (v4f32 (MVE_VRINTf32M (v4f32 MQPR:$val1)))>;
2545 def : Pat<(v8f16 (ffloor (v8f16 MQPR:$val1))),
2546 (v8f16 (MVE_VRINTf16M (v8f16 MQPR:$val1)))>;
2547 def : Pat<(v4f32 (fceil (v4f32 MQPR:$val1))),
2548 (v4f32 (MVE_VRINTf32P (v4f32 MQPR:$val1)))>;
2549 def : Pat<(v8f16 (fceil (v8f16 MQPR:$val1))),
2550 (v8f16 (MVE_VRINTf16P (v8f16 MQPR:$val1)))>;
2553 class MVEFloatArithNeon<string iname, string suffix, bit size,
2554 dag oops, dag iops, string ops,
2555 vpred_ops vpred, string cstr, list<dag> pattern=[]>
2556 : MVE_float<iname, suffix, oops, iops, ops, vpred, cstr, pattern> {
2557 let Inst{20} = size;
2561 class MVE_VMUL_fp<string suffix, bit size, list<dag> pattern=[]>
2562 : MVEFloatArithNeon<"vmul", suffix, size, (outs MQPR:$Qd),
2563 (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm", vpred_r, "",
2569 let Inst{25-23} = 0b110;
2570 let Inst{22} = Qd{3};
2572 let Inst{19-17} = Qn{2-0};
2573 let Inst{15-13} = Qd{2-0};
2574 let Inst{12-8} = 0b01101;
2575 let Inst{7} = Qn{3};
2579 def MVE_VMULf32 : MVE_VMUL_fp<"f32", 0b0>;
2580 def MVE_VMULf16 : MVE_VMUL_fp<"f16", 0b1>;
2582 let Predicates = [HasMVEFloat] in {
2583 def : Pat<(v4f32 (fmul (v4f32 MQPR:$val1), (v4f32 MQPR:$val2))),
2584 (v4f32 (MVE_VMULf32 (v4f32 MQPR:$val1), (v4f32 MQPR:$val2)))>;
2585 def : Pat<(v8f16 (fmul (v8f16 MQPR:$val1), (v8f16 MQPR:$val2))),
2586 (v8f16 (MVE_VMULf16 (v8f16 MQPR:$val1), (v8f16 MQPR:$val2)))>;
2589 class MVE_VCMLA<string suffix, bit size, list<dag> pattern=[]>
2590 : MVEFloatArithNeon<"vcmla", suffix, size, (outs MQPR:$Qd),
2591 (ins MQPR:$Qd_src, MQPR:$Qn, MQPR:$Qm, complexrotateop:$rot),
2592 "$Qd, $Qn, $Qm, $rot", vpred_n, "$Qd = $Qd_src", pattern> {
2599 let Inst{24-23} = rot;
2600 let Inst{22} = Qd{3};
2602 let Inst{19-17} = Qn{2-0};
2603 let Inst{15-13} = Qd{2-0};
2604 let Inst{12-8} = 0b01000;
2605 let Inst{7} = Qn{3};
2609 def MVE_VCMLAf16 : MVE_VCMLA<"f16", 0b0>;
2610 def MVE_VCMLAf32 : MVE_VCMLA<"f32", 0b1>;
2612 class MVE_VADDSUBFMA_fp<string iname, string suffix, bit size, bit bit_4,
2613 bit bit_8, bit bit_21, dag iops=(ins),
2614 vpred_ops vpred=vpred_r, string cstr="",
2615 list<dag> pattern=[]>
2616 : MVEFloatArithNeon<iname, suffix, size, (outs MQPR:$Qd),
2617 !con(iops, (ins MQPR:$Qn, MQPR:$Qm)), "$Qd, $Qn, $Qm",
2618 vpred, cstr, pattern> {
2623 let Inst{25-23} = 0b110;
2624 let Inst{22} = Qd{3};
2625 let Inst{21} = bit_21;
2626 let Inst{19-17} = Qn{2-0};
2627 let Inst{15-13} = Qd{2-0};
2628 let Inst{11-9} = 0b110;
2629 let Inst{8} = bit_8;
2630 let Inst{7} = Qn{3};
2631 let Inst{4} = bit_4;
2634 def MVE_VFMAf32 : MVE_VADDSUBFMA_fp<"vfma", "f32", 0b0, 0b1, 0b0, 0b0,
2635 (ins MQPR:$Qd_src), vpred_n, "$Qd = $Qd_src">;
2636 def MVE_VFMAf16 : MVE_VADDSUBFMA_fp<"vfma", "f16", 0b1, 0b1, 0b0, 0b0,
2637 (ins MQPR:$Qd_src), vpred_n, "$Qd = $Qd_src">;
2639 def MVE_VFMSf32 : MVE_VADDSUBFMA_fp<"vfms", "f32", 0b0, 0b1, 0b0, 0b1,
2640 (ins MQPR:$Qd_src), vpred_n, "$Qd = $Qd_src">;
2641 def MVE_VFMSf16 : MVE_VADDSUBFMA_fp<"vfms", "f16", 0b1, 0b1, 0b0, 0b1,
2642 (ins MQPR:$Qd_src), vpred_n, "$Qd = $Qd_src">;
2644 let Predicates = [HasMVEFloat, UseFusedMAC] in {
2645 def : Pat<(v8f16 (fadd (v8f16 MQPR:$src1),
2646 (fmul (v8f16 MQPR:$src2),
2647 (v8f16 MQPR:$src3)))),
2648 (v8f16 (MVE_VFMAf16 $src1, $src2, $src3))>;
2649 def : Pat<(v4f32 (fadd (v4f32 MQPR:$src1),
2650 (fmul (v4f32 MQPR:$src2),
2651 (v4f32 MQPR:$src3)))),
2652 (v4f32 (MVE_VFMAf32 $src1, $src2, $src3))>;
2654 def : Pat<(v8f16 (fsub (v8f16 MQPR:$src1),
2655 (fmul (v8f16 MQPR:$src2),
2656 (v8f16 MQPR:$src3)))),
2657 (v8f16 (MVE_VFMSf16 $src1, $src2, $src3))>;
2658 def : Pat<(v4f32 (fsub (v4f32 MQPR:$src1),
2659 (fmul (v4f32 MQPR:$src2),
2660 (v4f32 MQPR:$src3)))),
2661 (v4f32 (MVE_VFMSf32 $src1, $src2, $src3))>;
2664 let Predicates = [HasMVEFloat] in {
2665 def : Pat<(v8f16 (fma (v8f16 MQPR:$src1), (v8f16 MQPR:$src2), (v8f16 MQPR:$src3))),
2666 (v8f16 (MVE_VFMAf16 $src3, $src1, $src2))>;
2667 def : Pat<(v4f32 (fma (v4f32 MQPR:$src1), (v4f32 MQPR:$src2), (v4f32 MQPR:$src3))),
2668 (v4f32 (MVE_VFMAf32 $src3, $src1, $src2))>;
2672 def MVE_VADDf32 : MVE_VADDSUBFMA_fp<"vadd", "f32", 0b0, 0b0, 0b1, 0b0>;
2673 def MVE_VADDf16 : MVE_VADDSUBFMA_fp<"vadd", "f16", 0b1, 0b0, 0b1, 0b0>;
2675 let Predicates = [HasMVEFloat] in {
2676 def : Pat<(v4f32 (fadd (v4f32 MQPR:$val1), (v4f32 MQPR:$val2))),
2677 (v4f32 (MVE_VADDf32 (v4f32 MQPR:$val1), (v4f32 MQPR:$val2)))>;
2678 def : Pat<(v8f16 (fadd (v8f16 MQPR:$val1), (v8f16 MQPR:$val2))),
2679 (v8f16 (MVE_VADDf16 (v8f16 MQPR:$val1), (v8f16 MQPR:$val2)))>;
2682 def MVE_VSUBf32 : MVE_VADDSUBFMA_fp<"vsub", "f32", 0b0, 0b0, 0b1, 0b1>;
2683 def MVE_VSUBf16 : MVE_VADDSUBFMA_fp<"vsub", "f16", 0b1, 0b0, 0b1, 0b1>;
2685 let Predicates = [HasMVEFloat] in {
2686 def : Pat<(v4f32 (fsub (v4f32 MQPR:$val1), (v4f32 MQPR:$val2))),
2687 (v4f32 (MVE_VSUBf32 (v4f32 MQPR:$val1), (v4f32 MQPR:$val2)))>;
2688 def : Pat<(v8f16 (fsub (v8f16 MQPR:$val1), (v8f16 MQPR:$val2))),
2689 (v8f16 (MVE_VSUBf16 (v8f16 MQPR:$val1), (v8f16 MQPR:$val2)))>;
2692 class MVE_VCADD<string suffix, bit size, list<dag> pattern=[]>
2693 : MVEFloatArithNeon<"vcadd", suffix, size, (outs MQPR:$Qd),
2694 (ins MQPR:$Qn, MQPR:$Qm, complexrotateopodd:$rot),
2695 "$Qd, $Qn, $Qm, $rot", vpred_r, "", pattern> {
2704 let Inst{22} = Qd{3};
2706 let Inst{19-17} = Qn{2-0};
2707 let Inst{15-13} = Qd{2-0};
2708 let Inst{12-8} = 0b01000;
2709 let Inst{7} = Qn{3};
2713 def MVE_VCADDf16 : MVE_VCADD<"f16", 0b0>;
2714 def MVE_VCADDf32 : MVE_VCADD<"f32", 0b1>;
2716 class MVE_VABD_fp<string suffix, bit size>
2717 : MVE_float<"vabd", suffix, (outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm),
2718 "$Qd, $Qn, $Qm", vpred_r, ""> {
2723 let Inst{25-23} = 0b110;
2724 let Inst{22} = Qd{3};
2726 let Inst{20} = size;
2727 let Inst{19-17} = Qn{2-0};
2729 let Inst{15-13} = Qd{2-0};
2730 let Inst{11-8} = 0b1101;
2731 let Inst{7} = Qn{3};
2735 def MVE_VABDf32 : MVE_VABD_fp<"f32", 0b0>;
2736 def MVE_VABDf16 : MVE_VABD_fp<"f16", 0b1>;
2738 class MVE_VCVT_fix<string suffix, bit fsi, bit U, bit op,
2739 Operand imm_operand_type, list<dag> pattern=[]>
2740 : MVE_float<"vcvt", suffix,
2741 (outs MQPR:$Qd), (ins MQPR:$Qm, imm_operand_type:$imm6),
2742 "$Qd, $Qm, $imm6", vpred_r, "", pattern> {
2747 let Inst{25-23} = 0b111;
2748 let Inst{22} = Qd{3};
2750 let Inst{19-16} = imm6{3-0};
2751 let Inst{15-13} = Qd{2-0};
2752 let Inst{11-10} = 0b11;
2758 let DecoderMethod = "DecodeMVEVCVTt1fp";
2761 class MVE_VCVT_imm_asmop<int Bits> : AsmOperandClass {
2762 let PredicateMethod = "isImmediate<1," # Bits # ">";
2763 let DiagnosticString =
2764 "MVE fixed-point immediate operand must be between 1 and " # Bits;
2765 let Name = "MVEVcvtImm" # Bits;
2766 let RenderMethod = "addImmOperands";
2768 class MVE_VCVT_imm<int Bits>: Operand<i32> {
2769 let ParserMatchClass = MVE_VCVT_imm_asmop<Bits>;
2770 let EncoderMethod = "getNEONVcvtImm32OpValue";
2771 let DecoderMethod = "DecodeVCVTImmOperand";
2774 class MVE_VCVT_fix_f32<string suffix, bit U, bit op>
2775 : MVE_VCVT_fix<suffix, 0b1, U, op, MVE_VCVT_imm<32>> {
2776 let Inst{20} = imm6{4};
2778 class MVE_VCVT_fix_f16<string suffix, bit U, bit op>
2779 : MVE_VCVT_fix<suffix, 0b0, U, op, MVE_VCVT_imm<16>> {
2783 def MVE_VCVTf16s16_fix : MVE_VCVT_fix_f16<"f16.s16", 0b0, 0b0>;
2784 def MVE_VCVTs16f16_fix : MVE_VCVT_fix_f16<"s16.f16", 0b0, 0b1>;
2785 def MVE_VCVTf16u16_fix : MVE_VCVT_fix_f16<"f16.u16", 0b1, 0b0>;
2786 def MVE_VCVTu16f16_fix : MVE_VCVT_fix_f16<"u16.f16", 0b1, 0b1>;
2787 def MVE_VCVTf32s32_fix : MVE_VCVT_fix_f32<"f32.s32", 0b0, 0b0>;
2788 def MVE_VCVTs32f32_fix : MVE_VCVT_fix_f32<"s32.f32", 0b0, 0b1>;
2789 def MVE_VCVTf32u32_fix : MVE_VCVT_fix_f32<"f32.u32", 0b1, 0b0>;
2790 def MVE_VCVTu32f32_fix : MVE_VCVT_fix_f32<"u32.f32", 0b1, 0b1>;
2792 class MVE_VCVT_fp_int_anpm<string suffix, bits<2> size, bit op, string anpm,
2793 bits<2> rm, list<dag> pattern=[]>
2794 : MVE_float<!strconcat("vcvt", anpm), suffix, (outs MQPR:$Qd),
2795 (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", pattern> {
2799 let Inst{25-23} = 0b111;
2800 let Inst{22} = Qd{3};
2801 let Inst{21-20} = 0b11;
2802 let Inst{19-18} = size;
2803 let Inst{17-16} = 0b11;
2804 let Inst{15-13} = Qd{2-0};
2805 let Inst{12-10} = 0b000;
2811 multiclass MVE_VCVT_fp_int_anpm_multi<string suffix, bits<2> size, bit op,
2812 list<dag> pattern=[]> {
2813 def a : MVE_VCVT_fp_int_anpm<suffix, size, op, "a", 0b00>;
2814 def n : MVE_VCVT_fp_int_anpm<suffix, size, op, "n", 0b01>;
2815 def p : MVE_VCVT_fp_int_anpm<suffix, size, op, "p", 0b10>;
2816 def m : MVE_VCVT_fp_int_anpm<suffix, size, op, "m", 0b11>;
2819 // This defines instructions such as MVE_VCVTu16f16a, with an explicit
2820 // rounding-mode suffix on the mnemonic. The class below will define
2821 // the bare MVE_VCVTu16f16 (with implied rounding toward zero).
2822 defm MVE_VCVTs16f16 : MVE_VCVT_fp_int_anpm_multi<"s16.f16", 0b01, 0b0>;
2823 defm MVE_VCVTu16f16 : MVE_VCVT_fp_int_anpm_multi<"u16.f16", 0b01, 0b1>;
2824 defm MVE_VCVTs32f32 : MVE_VCVT_fp_int_anpm_multi<"s32.f32", 0b10, 0b0>;
2825 defm MVE_VCVTu32f32 : MVE_VCVT_fp_int_anpm_multi<"u32.f32", 0b10, 0b1>;
2827 class MVE_VCVT_fp_int<string suffix, bits<2> size, bits<2> op,
2828 list<dag> pattern=[]>
2829 : MVE_float<"vcvt", suffix, (outs MQPR:$Qd),
2830 (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", pattern> {
2834 let Inst{25-23} = 0b111;
2835 let Inst{22} = Qd{3};
2836 let Inst{21-20} = 0b11;
2837 let Inst{19-18} = size;
2838 let Inst{17-16} = 0b11;
2839 let Inst{15-13} = Qd{2-0};
2840 let Inst{12-9} = 0b0011;
2845 // The unsuffixed VCVT for float->int implicitly rounds toward zero,
2846 // which I reflect here in the llvm instruction names
2847 def MVE_VCVTs16f16z : MVE_VCVT_fp_int<"s16.f16", 0b01, 0b10>;
2848 def MVE_VCVTu16f16z : MVE_VCVT_fp_int<"u16.f16", 0b01, 0b11>;
2849 def MVE_VCVTs32f32z : MVE_VCVT_fp_int<"s32.f32", 0b10, 0b10>;
2850 def MVE_VCVTu32f32z : MVE_VCVT_fp_int<"u32.f32", 0b10, 0b11>;
2851 // Whereas VCVT for int->float rounds to nearest
2852 def MVE_VCVTf16s16n : MVE_VCVT_fp_int<"f16.s16", 0b01, 0b00>;
2853 def MVE_VCVTf16u16n : MVE_VCVT_fp_int<"f16.u16", 0b01, 0b01>;
2854 def MVE_VCVTf32s32n : MVE_VCVT_fp_int<"f32.s32", 0b10, 0b00>;
2855 def MVE_VCVTf32u32n : MVE_VCVT_fp_int<"f32.u32", 0b10, 0b01>;
2857 let Predicates = [HasMVEFloat] in {
2858 def : Pat<(v4i32 (fp_to_sint (v4f32 MQPR:$src))),
2859 (v4i32 (MVE_VCVTs32f32z (v4f32 MQPR:$src)))>;
2860 def : Pat<(v4i32 (fp_to_uint (v4f32 MQPR:$src))),
2861 (v4i32 (MVE_VCVTu32f32z (v4f32 MQPR:$src)))>;
2862 def : Pat<(v8i16 (fp_to_sint (v8f16 MQPR:$src))),
2863 (v8i16 (MVE_VCVTs16f16z (v8f16 MQPR:$src)))>;
2864 def : Pat<(v8i16 (fp_to_uint (v8f16 MQPR:$src))),
2865 (v8i16 (MVE_VCVTu16f16z (v8f16 MQPR:$src)))>;
2866 def : Pat<(v4f32 (sint_to_fp (v4i32 MQPR:$src))),
2867 (v4f32 (MVE_VCVTf32s32n (v4i32 MQPR:$src)))>;
2868 def : Pat<(v4f32 (uint_to_fp (v4i32 MQPR:$src))),
2869 (v4f32 (MVE_VCVTf32u32n (v4i32 MQPR:$src)))>;
2870 def : Pat<(v8f16 (sint_to_fp (v8i16 MQPR:$src))),
2871 (v8f16 (MVE_VCVTf16s16n (v8i16 MQPR:$src)))>;
2872 def : Pat<(v8f16 (uint_to_fp (v8i16 MQPR:$src))),
2873 (v8f16 (MVE_VCVTf16u16n (v8i16 MQPR:$src)))>;
2876 class MVE_VABSNEG_fp<string iname, string suffix, bits<2> size, bit negate,
2877 list<dag> pattern=[]>
2878 : MVE_float<iname, suffix, (outs MQPR:$Qd),
2879 (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", pattern> {
2883 let Inst{25-23} = 0b111;
2884 let Inst{22} = Qd{3};
2885 let Inst{21-20} = 0b11;
2886 let Inst{19-18} = size;
2887 let Inst{17-16} = 0b01;
2888 let Inst{15-13} = Qd{2-0};
2889 let Inst{11-8} = 0b0111;
2890 let Inst{7} = negate;
2894 def MVE_VABSf16 : MVE_VABSNEG_fp<"vabs", "f16", 0b01, 0b0>;
2895 def MVE_VABSf32 : MVE_VABSNEG_fp<"vabs", "f32", 0b10, 0b0>;
2897 let Predicates = [HasMVEFloat] in {
2898 def : Pat<(v8f16 (fabs MQPR:$src)),
2899 (MVE_VABSf16 MQPR:$src)>;
2900 def : Pat<(v4f32 (fabs MQPR:$src)),
2901 (MVE_VABSf32 MQPR:$src)>;
2904 def MVE_VNEGf16 : MVE_VABSNEG_fp<"vneg", "f16", 0b01, 0b1>;
2905 def MVE_VNEGf32 : MVE_VABSNEG_fp<"vneg", "f32", 0b10, 0b1>;
2907 let Predicates = [HasMVEFloat] in {
2908 def : Pat<(v8f16 (fneg MQPR:$src)),
2909 (MVE_VNEGf16 MQPR:$src)>;
2910 def : Pat<(v4f32 (fneg MQPR:$src)),
2911 (MVE_VNEGf32 MQPR:$src)>;
2914 class MVE_VMAXMINNMA<string iname, string suffix, bit size, bit bit_12,
2915 list<dag> pattern=[]>
2916 : MVE_f<(outs MQPR:$Qd), (ins MQPR:$Qd_src, MQPR:$Qm),
2917 NoItinerary, iname, suffix, "$Qd, $Qm", vpred_n, "$Qd = $Qd_src",
2922 let Inst{28} = size;
2923 let Inst{25-23} = 0b100;
2924 let Inst{22} = Qd{3};
2925 let Inst{21-16} = 0b111111;
2926 let Inst{15-13} = Qd{2-0};
2927 let Inst{12} = bit_12;
2928 let Inst{11-6} = 0b111010;
2929 let Inst{5} = Qm{3};
2931 let Inst{3-1} = Qm{2-0};
2935 def MVE_VMAXNMAf32 : MVE_VMAXMINNMA<"vmaxnma", "f32", 0b0, 0b0>;
2936 def MVE_VMAXNMAf16 : MVE_VMAXMINNMA<"vmaxnma", "f16", 0b1, 0b0>;
2938 def MVE_VMINNMAf32 : MVE_VMAXMINNMA<"vminnma", "f32", 0b0, 0b1>;
2939 def MVE_VMINNMAf16 : MVE_VMAXMINNMA<"vminnma", "f16", 0b1, 0b1>;
2941 // end of MVE Floating Point instructions
2943 // start of MVE compares
2945 class MVE_VCMPqq<string suffix, bit bit_28, bits<2> bits_21_20,
2946 VCMPPredicateOperand predtype, list<dag> pattern=[]>
2947 : MVE_p<(outs VCCR:$P0), (ins MQPR:$Qn, MQPR:$Qm, predtype:$fc),
2948 NoItinerary, "vcmp", suffix, "$fc, $Qn, $Qm", vpred_n, "", pattern> {
2949 // Base class for comparing two vector registers
2954 let Inst{28} = bit_28;
2955 let Inst{25-22} = 0b1000;
2956 let Inst{21-20} = bits_21_20;
2957 let Inst{19-17} = Qn{2-0};
2958 let Inst{16-13} = 0b1000;
2959 let Inst{12} = fc{2};
2960 let Inst{11-8} = 0b1111;
2961 let Inst{7} = fc{0};
2963 let Inst{5} = Qm{3};
2965 let Inst{3-1} = Qm{2-0};
2966 let Inst{0} = fc{1};
2968 let Constraints = "";
2970 // We need a custom decoder method for these instructions because of
2971 // the output VCCR operand, which isn't encoded in the instruction
2972 // bits anywhere (there is only one choice for it) but has to be
2973 // included in the MC operands so that codegen will be able to track
2974 // its data flow between instructions, spill/reload it when
2975 // necessary, etc. There seems to be no way to get the Tablegen
2976 // decoder to emit an operand that isn't affected by any instruction
2978 let DecoderMethod = "DecodeMVEVCMP<false," # predtype.DecoderMethod # ">";
2981 class MVE_VCMPqqf<string suffix, bit size>
2982 : MVE_VCMPqq<suffix, size, 0b11, pred_basic_fp> {
2983 let Predicates = [HasMVEFloat];
2986 class MVE_VCMPqqi<string suffix, bits<2> size>
2987 : MVE_VCMPqq<suffix, 0b1, size, pred_basic_i> {
2992 class MVE_VCMPqqu<string suffix, bits<2> size>
2993 : MVE_VCMPqq<suffix, 0b1, size, pred_basic_u> {
2998 class MVE_VCMPqqs<string suffix, bits<2> size>
2999 : MVE_VCMPqq<suffix, 0b1, size, pred_basic_s> {
3003 def MVE_VCMPf32 : MVE_VCMPqqf<"f32", 0b0>;
3004 def MVE_VCMPf16 : MVE_VCMPqqf<"f16", 0b1>;
3006 def MVE_VCMPi8 : MVE_VCMPqqi<"i8", 0b00>;
3007 def MVE_VCMPi16 : MVE_VCMPqqi<"i16", 0b01>;
3008 def MVE_VCMPi32 : MVE_VCMPqqi<"i32", 0b10>;
3010 def MVE_VCMPu8 : MVE_VCMPqqu<"u8", 0b00>;
3011 def MVE_VCMPu16 : MVE_VCMPqqu<"u16", 0b01>;
3012 def MVE_VCMPu32 : MVE_VCMPqqu<"u32", 0b10>;
3014 def MVE_VCMPs8 : MVE_VCMPqqs<"s8", 0b00>;
3015 def MVE_VCMPs16 : MVE_VCMPqqs<"s16", 0b01>;
3016 def MVE_VCMPs32 : MVE_VCMPqqs<"s32", 0b10>;
3018 class MVE_VCMPqr<string suffix, bit bit_28, bits<2> bits_21_20,
3019 VCMPPredicateOperand predtype, list<dag> pattern=[]>
3020 : MVE_p<(outs VCCR:$P0), (ins MQPR:$Qn, GPRwithZR:$Rm, predtype:$fc),
3021 NoItinerary, "vcmp", suffix, "$fc, $Qn, $Rm", vpred_n, "", pattern> {
3022 // Base class for comparing a vector register with a scalar
3027 let Inst{28} = bit_28;
3028 let Inst{25-22} = 0b1000;
3029 let Inst{21-20} = bits_21_20;
3030 let Inst{19-17} = Qn{2-0};
3031 let Inst{16-13} = 0b1000;
3032 let Inst{12} = fc{2};
3033 let Inst{11-8} = 0b1111;
3034 let Inst{7} = fc{0};
3036 let Inst{5} = fc{1};
3038 let Inst{3-0} = Rm{3-0};
3040 let Constraints = "";
3041 // Custom decoder method, for the same reason as MVE_VCMPqq
3042 let DecoderMethod = "DecodeMVEVCMP<true," # predtype.DecoderMethod # ">";
3045 class MVE_VCMPqrf<string suffix, bit size>
3046 : MVE_VCMPqr<suffix, size, 0b11, pred_basic_fp> {
3047 let Predicates = [HasMVEFloat];
3050 class MVE_VCMPqri<string suffix, bits<2> size>
3051 : MVE_VCMPqr<suffix, 0b1, size, pred_basic_i> {
3056 class MVE_VCMPqru<string suffix, bits<2> size>
3057 : MVE_VCMPqr<suffix, 0b1, size, pred_basic_u> {
3062 class MVE_VCMPqrs<string suffix, bits<2> size>
3063 : MVE_VCMPqr<suffix, 0b1, size, pred_basic_s> {
3067 def MVE_VCMPf32r : MVE_VCMPqrf<"f32", 0b0>;
3068 def MVE_VCMPf16r : MVE_VCMPqrf<"f16", 0b1>;
3070 def MVE_VCMPi8r : MVE_VCMPqri<"i8", 0b00>;
3071 def MVE_VCMPi16r : MVE_VCMPqri<"i16", 0b01>;
3072 def MVE_VCMPi32r : MVE_VCMPqri<"i32", 0b10>;
3074 def MVE_VCMPu8r : MVE_VCMPqru<"u8", 0b00>;
3075 def MVE_VCMPu16r : MVE_VCMPqru<"u16", 0b01>;
3076 def MVE_VCMPu32r : MVE_VCMPqru<"u32", 0b10>;
3078 def MVE_VCMPs8r : MVE_VCMPqrs<"s8", 0b00>;
3079 def MVE_VCMPs16r : MVE_VCMPqrs<"s16", 0b01>;
3080 def MVE_VCMPs32r : MVE_VCMPqrs<"s32", 0b10>;
3082 multiclass unpred_vcmp_z<string suffix, int fc> {
3083 def i8 : Pat<(v16i1 (ARMvcmpz (v16i8 MQPR:$v1), (i32 fc))),
3084 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), ZR, fc))>;
3085 def i16 : Pat<(v8i1 (ARMvcmpz (v8i16 MQPR:$v1), (i32 fc))),
3086 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), ZR, fc))>;
3087 def i32 : Pat<(v4i1 (ARMvcmpz (v4i32 MQPR:$v1), (i32 fc))),
3088 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), ZR, fc))>;
3090 def : Pat<(v16i1 (and (v16i1 VCCR:$p1), (v16i1 (ARMvcmpz (v16i8 MQPR:$v1), (i32 fc))))),
3091 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), ZR, fc, 1, VCCR:$p1))>;
3092 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmpz (v8i16 MQPR:$v1), (i32 fc))))),
3093 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), ZR, fc, 1, VCCR:$p1))>;
3094 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmpz (v4i32 MQPR:$v1), (i32 fc))))),
3095 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), ZR, fc, 1, VCCR:$p1))>;
3098 multiclass unpred_vcmp_r<string suffix, int fc> {
3099 def i8 : Pat<(v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), (i32 fc))),
3100 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8") (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), fc))>;
3101 def i16 : Pat<(v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), (i32 fc))),
3102 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16") (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), fc))>;
3103 def i32 : Pat<(v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), (i32 fc))),
3104 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32") (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), fc))>;
3106 def i8r : Pat<(v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 (ARMvdup GPR:$v2)), (i32 fc))),
3107 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), (i32 GPR:$v2), fc))>;
3108 def i16r : Pat<(v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 (ARMvdup GPR:$v2)), (i32 fc))),
3109 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), (i32 GPR:$v2), fc))>;
3110 def i32r : Pat<(v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 (ARMvdup GPR:$v2)), (i32 fc))),
3111 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), (i32 GPR:$v2), fc))>;
3113 def : Pat<(v16i1 (and (v16i1 VCCR:$p1), (v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), (i32 fc))))),
3114 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8") (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), fc, 1, VCCR:$p1))>;
3115 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), (i32 fc))))),
3116 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16") (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), fc, 1, VCCR:$p1))>;
3117 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), (i32 fc))))),
3118 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32") (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), fc, 1, VCCR:$p1))>;
3120 def : Pat<(v16i1 (and (v16i1 VCCR:$p1), (v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 (ARMvdup GPR:$v2)), (i32 fc))))),
3121 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), (i32 GPR:$v2), fc, 1, VCCR:$p1))>;
3122 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 (ARMvdup GPR:$v2)), (i32 fc))))),
3123 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), (i32 GPR:$v2), fc, 1, VCCR:$p1))>;
3124 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 (ARMvdup GPR:$v2)), (i32 fc))))),
3125 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), (i32 GPR:$v2), fc, 1, VCCR:$p1))>;
3128 multiclass unpred_vcmpf_z<int fc> {
3129 def f16 : Pat<(v8i1 (ARMvcmpz (v8f16 MQPR:$v1), (i32 fc))),
3130 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), ZR, fc))>;
3131 def f32 : Pat<(v4i1 (ARMvcmpz (v4f32 MQPR:$v1), (i32 fc))),
3132 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, fc))>;
3134 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmpz (v8f16 MQPR:$v1), (i32 fc))))),
3135 (v8i1 (MVE_VCMPf32r (v8f16 MQPR:$v1), ZR, fc, 1, VCCR:$p1))>;
3136 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmpz (v4f32 MQPR:$v1), (i32 fc))))),
3137 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, fc, 1, VCCR:$p1))>;
3140 multiclass unpred_vcmpf_r<int fc> {
3141 def f16 : Pat<(v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), (i32 fc))),
3142 (v8i1 (MVE_VCMPf16 (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), fc))>;
3143 def f32 : Pat<(v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), (i32 fc))),
3144 (v4i1 (MVE_VCMPf32 (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), fc))>;
3146 def f16r : Pat<(v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 (ARMvdup HPR:$v2)), (i32 fc))),
3147 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), (i32 (COPY_TO_REGCLASS (f16 HPR:$v2), rGPR)), fc))>;
3148 def f32r : Pat<(v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 (ARMvdup SPR:$v2)), (i32 fc))),
3149 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), (i32 (COPY_TO_REGCLASS (f32 SPR:$v2), rGPR)), fc))>;
3151 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), (i32 fc))))),
3152 (v8i1 (MVE_VCMPf16 (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), fc, 1, VCCR:$p1))>;
3153 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), (i32 fc))))),
3154 (v4i1 (MVE_VCMPf32 (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), fc, 1, VCCR:$p1))>;
3156 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 (ARMvdup HPR:$v2)), (i32 fc))))),
3157 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), (i32 (COPY_TO_REGCLASS (f16 HPR:$v2), rGPR)), fc, 1, VCCR:$p1))>;
3158 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 (ARMvdup SPR:$v2)), (i32 fc))))),
3159 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), (i32 (COPY_TO_REGCLASS (f32 SPR:$v2), rGPR)), fc, 1, VCCR:$p1))>;
3162 let Predicates = [HasMVEInt] in {
3163 defm MVE_VCEQZ : unpred_vcmp_z<"i", 0>;
3164 defm MVE_VCNEZ : unpred_vcmp_z<"i", 1>;
3165 defm MVE_VCGEZ : unpred_vcmp_z<"s", 10>;
3166 defm MVE_VCLTZ : unpred_vcmp_z<"s", 11>;
3167 defm MVE_VCGTZ : unpred_vcmp_z<"s", 12>;
3168 defm MVE_VCLEZ : unpred_vcmp_z<"s", 13>;
3169 defm MVE_VCGTUZ : unpred_vcmp_z<"u", 8>;
3170 defm MVE_VCGEUZ : unpred_vcmp_z<"u", 2>;
3172 defm MVE_VCEQ : unpred_vcmp_r<"i", 0>;
3173 defm MVE_VCNE : unpred_vcmp_r<"i", 1>;
3174 defm MVE_VCGE : unpred_vcmp_r<"s", 10>;
3175 defm MVE_VCLT : unpred_vcmp_r<"s", 11>;
3176 defm MVE_VCGT : unpred_vcmp_r<"s", 12>;
3177 defm MVE_VCLE : unpred_vcmp_r<"s", 13>;
3178 defm MVE_VCGTU : unpred_vcmp_r<"u", 8>;
3179 defm MVE_VCGEU : unpred_vcmp_r<"u", 2>;
3182 let Predicates = [HasMVEFloat] in {
3183 defm MVE_VFCEQZ : unpred_vcmpf_z<0>;
3184 defm MVE_VFCNEZ : unpred_vcmpf_z<1>;
3185 defm MVE_VFCGEZ : unpred_vcmpf_z<10>;
3186 defm MVE_VFCLTZ : unpred_vcmpf_z<11>;
3187 defm MVE_VFCGTZ : unpred_vcmpf_z<12>;
3188 defm MVE_VFCLEZ : unpred_vcmpf_z<13>;
3190 defm MVE_VFCEQ : unpred_vcmpf_r<0>;
3191 defm MVE_VFCNE : unpred_vcmpf_r<1>;
3192 defm MVE_VFCGE : unpred_vcmpf_r<10>;
3193 defm MVE_VFCLT : unpred_vcmpf_r<11>;
3194 defm MVE_VFCGT : unpred_vcmpf_r<12>;
3195 defm MVE_VFCLE : unpred_vcmpf_r<13>;
3199 // Extra "worst case" and/or/xor partterns, going into and out of GRP
3200 multiclass two_predops<SDPatternOperator opnode, Instruction insn> {
3201 def v16i1 : Pat<(v16i1 (opnode (v16i1 VCCR:$p1), (v16i1 VCCR:$p2))),
3202 (v16i1 (COPY_TO_REGCLASS
3203 (insn (i32 (COPY_TO_REGCLASS (v16i1 VCCR:$p1), rGPR)),
3204 (i32 (COPY_TO_REGCLASS (v16i1 VCCR:$p2), rGPR))),
3206 def v8i1 : Pat<(v8i1 (opnode (v8i1 VCCR:$p1), (v8i1 VCCR:$p2))),
3207 (v8i1 (COPY_TO_REGCLASS
3208 (insn (i32 (COPY_TO_REGCLASS (v8i1 VCCR:$p1), rGPR)),
3209 (i32 (COPY_TO_REGCLASS (v8i1 VCCR:$p2), rGPR))),
3211 def v4i1 : Pat<(v4i1 (opnode (v4i1 VCCR:$p1), (v4i1 VCCR:$p2))),
3212 (v4i1 (COPY_TO_REGCLASS
3213 (insn (i32 (COPY_TO_REGCLASS (v4i1 VCCR:$p1), rGPR)),
3214 (i32 (COPY_TO_REGCLASS (v4i1 VCCR:$p2), rGPR))),
3218 let Predicates = [HasMVEInt] in {
3219 defm POR : two_predops<or, t2ORRrr>;
3220 defm PAND : two_predops<and, t2ANDrr>;
3221 defm PEOR : two_predops<xor, t2EORrr>;
3224 // Occasionally we need to cast between a i32 and a boolean vector, for
3225 // example when moving between rGPR and VPR.P0 as part of predicate vector
3226 // shuffles. We also sometimes need to cast between different predicate
3227 // vector types (v4i1<>v8i1, etc.) also as part of lowering vector shuffles.
3229 def predicate_cast : SDNode<"ARMISD::PREDICATE_CAST", SDTUnaryOp>;
3231 let Predicates = [HasMVEInt] in {
3232 foreach VT = [ v4i1, v8i1, v16i1 ] in {
3233 def : Pat<(i32 (predicate_cast (VT VCCR:$src))),
3234 (i32 (COPY_TO_REGCLASS (VT VCCR:$src), VCCR))>;
3235 def : Pat<(VT (predicate_cast (i32 VCCR:$src))),
3236 (VT (COPY_TO_REGCLASS (i32 VCCR:$src), VCCR))>;
3238 foreach VT2 = [ v4i1, v8i1, v16i1 ] in
3239 def : Pat<(VT (predicate_cast (VT2 VCCR:$src))),
3240 (VT (COPY_TO_REGCLASS (VT2 VCCR:$src), VCCR))>;
3244 // end of MVE compares
3246 // start of MVE_qDest_qSrc
3248 class MVE_qDest_qSrc<string iname, string suffix, dag oops, dag iops,
3249 string ops, vpred_ops vpred, string cstr,
3250 list<dag> pattern=[]>
3251 : MVE_p<oops, iops, NoItinerary, iname, suffix,
3252 ops, vpred, cstr, pattern> {
3256 let Inst{25-23} = 0b100;
3257 let Inst{22} = Qd{3};
3258 let Inst{15-13} = Qd{2-0};
3259 let Inst{11-9} = 0b111;
3261 let Inst{5} = Qm{3};
3263 let Inst{3-1} = Qm{2-0};
3266 class MVE_VQxDMLxDH<string iname, bit exch, bit round, bit subtract,
3267 string suffix, bits<2> size, list<dag> pattern=[]>
3268 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
3269 (ins MQPR:$Qd_src, MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm",
3270 vpred_n, "$Qd = $Qd_src", pattern> {
3273 let Inst{28} = subtract;
3274 let Inst{21-20} = size;
3275 let Inst{19-17} = Qn{2-0};
3277 let Inst{12} = exch;
3279 let Inst{7} = Qn{3};
3280 let Inst{0} = round;
3283 multiclass MVE_VQxDMLxDH_multi<string iname, bit exch,
3284 bit round, bit subtract> {
3285 def s8 : MVE_VQxDMLxDH<iname, exch, round, subtract, "s8", 0b00>;
3286 def s16 : MVE_VQxDMLxDH<iname, exch, round, subtract, "s16", 0b01>;
3287 def s32 : MVE_VQxDMLxDH<iname, exch, round, subtract, "s32", 0b10>;
3290 defm MVE_VQDMLADH : MVE_VQxDMLxDH_multi<"vqdmladh", 0b0, 0b0, 0b0>;
3291 defm MVE_VQDMLADHX : MVE_VQxDMLxDH_multi<"vqdmladhx", 0b1, 0b0, 0b0>;
3292 defm MVE_VQRDMLADH : MVE_VQxDMLxDH_multi<"vqrdmladh", 0b0, 0b1, 0b0>;
3293 defm MVE_VQRDMLADHX : MVE_VQxDMLxDH_multi<"vqrdmladhx", 0b1, 0b1, 0b0>;
3294 defm MVE_VQDMLSDH : MVE_VQxDMLxDH_multi<"vqdmlsdh", 0b0, 0b0, 0b1>;
3295 defm MVE_VQDMLSDHX : MVE_VQxDMLxDH_multi<"vqdmlsdhx", 0b1, 0b0, 0b1>;
3296 defm MVE_VQRDMLSDH : MVE_VQxDMLxDH_multi<"vqrdmlsdh", 0b0, 0b1, 0b1>;
3297 defm MVE_VQRDMLSDHX : MVE_VQxDMLxDH_multi<"vqrdmlsdhx", 0b1, 0b1, 0b1>;
3299 class MVE_VCMUL<string iname, string suffix, bit size, list<dag> pattern=[]>
3300 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
3301 (ins MQPR:$Qn, MQPR:$Qm, complexrotateop:$rot),
3302 "$Qd, $Qn, $Qm, $rot", vpred_r, "", pattern> {
3306 let Inst{28} = size;
3307 let Inst{21-20} = 0b11;
3308 let Inst{19-17} = Qn{2-0};
3310 let Inst{12} = rot{1};
3312 let Inst{7} = Qn{3};
3313 let Inst{0} = rot{0};
3315 let Predicates = [HasMVEFloat];
3318 def MVE_VCMULf16 : MVE_VCMUL<"vcmul", "f16", 0b0>;
3319 def MVE_VCMULf32 : MVE_VCMUL<"vcmul", "f32", 0b1>;
3321 class MVE_VMULL<string iname, string suffix, bit bit_28, bits<2> bits_21_20,
3322 bit T, list<dag> pattern=[]>
3323 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
3324 (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm",
3325 vpred_r, "", pattern> {
3330 let Inst{28} = bit_28;
3331 let Inst{21-20} = bits_21_20;
3332 let Inst{19-17} = Qn{2-0};
3336 let Inst{7} = Qn{3};
3340 multiclass MVE_VMULL_multi<string iname, string suffix,
3341 bit bit_28, bits<2> bits_21_20> {
3342 def bh : MVE_VMULL<iname # "b", suffix, bit_28, bits_21_20, 0b0>;
3343 def th : MVE_VMULL<iname # "t", suffix, bit_28, bits_21_20, 0b1>;
3346 // For integer multiplies, bits 21:20 encode size, and bit 28 signedness.
3347 // For polynomial multiplies, bits 21:20 take the unused value 0b11, and
3348 // bit 28 switches to encoding the size.
3350 defm MVE_VMULLs8 : MVE_VMULL_multi<"vmull", "s8", 0b0, 0b00>;
3351 defm MVE_VMULLs16 : MVE_VMULL_multi<"vmull", "s16", 0b0, 0b01>;
3352 defm MVE_VMULLs32 : MVE_VMULL_multi<"vmull", "s32", 0b0, 0b10>;
3353 defm MVE_VMULLu8 : MVE_VMULL_multi<"vmull", "u8", 0b1, 0b00>;
3354 defm MVE_VMULLu16 : MVE_VMULL_multi<"vmull", "u16", 0b1, 0b01>;
3355 defm MVE_VMULLu32 : MVE_VMULL_multi<"vmull", "u32", 0b1, 0b10>;
3356 defm MVE_VMULLp8 : MVE_VMULL_multi<"vmull", "p8", 0b0, 0b11>;
3357 defm MVE_VMULLp16 : MVE_VMULL_multi<"vmull", "p16", 0b1, 0b11>;
3359 class MVE_VxMULH<string iname, string suffix, bit U, bits<2> size,
3360 bit round, list<dag> pattern=[]>
3361 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
3362 (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm",
3363 vpred_r, "", pattern> {
3367 let Inst{21-20} = size;
3368 let Inst{19-17} = Qn{2-0};
3370 let Inst{12} = round;
3372 let Inst{7} = Qn{3};
3376 def MVE_VMULHs8 : MVE_VxMULH<"vmulh", "s8", 0b0, 0b00, 0b0>;
3377 def MVE_VMULHs16 : MVE_VxMULH<"vmulh", "s16", 0b0, 0b01, 0b0>;
3378 def MVE_VMULHs32 : MVE_VxMULH<"vmulh", "s32", 0b0, 0b10, 0b0>;
3379 def MVE_VMULHu8 : MVE_VxMULH<"vmulh", "u8", 0b1, 0b00, 0b0>;
3380 def MVE_VMULHu16 : MVE_VxMULH<"vmulh", "u16", 0b1, 0b01, 0b0>;
3381 def MVE_VMULHu32 : MVE_VxMULH<"vmulh", "u32", 0b1, 0b10, 0b0>;
3383 def MVE_VRMULHs8 : MVE_VxMULH<"vrmulh", "s8", 0b0, 0b00, 0b1>;
3384 def MVE_VRMULHs16 : MVE_VxMULH<"vrmulh", "s16", 0b0, 0b01, 0b1>;
3385 def MVE_VRMULHs32 : MVE_VxMULH<"vrmulh", "s32", 0b0, 0b10, 0b1>;
3386 def MVE_VRMULHu8 : MVE_VxMULH<"vrmulh", "u8", 0b1, 0b00, 0b1>;
3387 def MVE_VRMULHu16 : MVE_VxMULH<"vrmulh", "u16", 0b1, 0b01, 0b1>;
3388 def MVE_VRMULHu32 : MVE_VxMULH<"vrmulh", "u32", 0b1, 0b10, 0b1>;
3390 class MVE_VxMOVxN<string iname, string suffix, bit bit_28, bit bit_17,
3391 bits<2> size, bit T, list<dag> pattern=[]>
3392 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
3393 (ins MQPR:$Qd_src, MQPR:$Qm), "$Qd, $Qm",
3394 vpred_n, "$Qd = $Qd_src", pattern> {
3396 let Inst{28} = bit_28;
3397 let Inst{21-20} = 0b11;
3398 let Inst{19-18} = size;
3399 let Inst{17} = bit_17;
3403 let Inst{7} = !if(!eq(bit_17, 0), 1, 0);
3407 multiclass MVE_VxMOVxN_halves<string iname, string suffix,
3408 bit bit_28, bit bit_17, bits<2> size> {
3409 def bh : MVE_VxMOVxN<iname # "b", suffix, bit_28, bit_17, size, 0b0>;
3410 def th : MVE_VxMOVxN<iname # "t", suffix, bit_28, bit_17, size, 0b1>;
3413 defm MVE_VMOVNi16 : MVE_VxMOVxN_halves<"vmovn", "i16", 0b1, 0b0, 0b00>;
3414 defm MVE_VMOVNi32 : MVE_VxMOVxN_halves<"vmovn", "i32", 0b1, 0b0, 0b01>;
3415 defm MVE_VQMOVNs16 : MVE_VxMOVxN_halves<"vqmovn", "s16", 0b0, 0b1, 0b00>;
3416 defm MVE_VQMOVNs32 : MVE_VxMOVxN_halves<"vqmovn", "s32", 0b0, 0b1, 0b01>;
3417 defm MVE_VQMOVNu16 : MVE_VxMOVxN_halves<"vqmovn", "u16", 0b1, 0b1, 0b00>;
3418 defm MVE_VQMOVNu32 : MVE_VxMOVxN_halves<"vqmovn", "u32", 0b1, 0b1, 0b01>;
3419 defm MVE_VQMOVUNs16 : MVE_VxMOVxN_halves<"vqmovun", "s16", 0b0, 0b0, 0b00>;
3420 defm MVE_VQMOVUNs32 : MVE_VxMOVxN_halves<"vqmovun", "s32", 0b0, 0b0, 0b01>;
3422 class MVE_VCVT_ff<string iname, string suffix, bit op, bit T,
3423 list<dag> pattern=[]>
3424 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd), (ins MQPR:$Qd_src, MQPR:$Qm),
3425 "$Qd, $Qm", vpred_n, "$Qd = $Qd_src", pattern> {
3427 let Inst{21-16} = 0b111111;
3429 let Inst{8-7} = 0b00;
3432 let Predicates = [HasMVEFloat];
3435 multiclass MVE_VCVT_ff_halves<string suffix, bit op> {
3436 def bh : MVE_VCVT_ff<"vcvtb", suffix, op, 0b0>;
3437 def th : MVE_VCVT_ff<"vcvtt", suffix, op, 0b1>;
3440 defm MVE_VCVTf16f32 : MVE_VCVT_ff_halves<"f16.f32", 0b0>;
3441 defm MVE_VCVTf32f16 : MVE_VCVT_ff_halves<"f32.f16", 0b1>;
3443 class MVE_VxCADD<string iname, string suffix, bits<2> size, bit halve,
3444 list<dag> pattern=[]>
3445 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
3446 (ins MQPR:$Qn, MQPR:$Qm, complexrotateopodd:$rot),
3447 "$Qd, $Qn, $Qm, $rot", vpred_r, "",
3452 let Inst{28} = halve;
3453 let Inst{21-20} = size;
3454 let Inst{19-17} = Qn{2-0};
3458 let Inst{7} = Qn{3};
3462 def MVE_VCADDi8 : MVE_VxCADD<"vcadd", "i8", 0b00, 0b1>;
3463 def MVE_VCADDi16 : MVE_VxCADD<"vcadd", "i16", 0b01, 0b1>;
3464 def MVE_VCADDi32 : MVE_VxCADD<"vcadd", "i32", 0b10, 0b1>;
3466 def MVE_VHCADDs8 : MVE_VxCADD<"vhcadd", "s8", 0b00, 0b0>;
3467 def MVE_VHCADDs16 : MVE_VxCADD<"vhcadd", "s16", 0b01, 0b0>;
3468 def MVE_VHCADDs32 : MVE_VxCADD<"vhcadd", "s32", 0b10, 0b0>;
3470 class MVE_VADCSBC<string iname, bit I, bit subtract,
3471 dag carryin, list<dag> pattern=[]>
3472 : MVE_qDest_qSrc<iname, "i32", (outs MQPR:$Qd, cl_FPSCR_NZCV:$carryout),
3473 !con((ins MQPR:$Qn, MQPR:$Qm), carryin),
3474 "$Qd, $Qn, $Qm", vpred_r, "", pattern> {
3477 let Inst{28} = subtract;
3478 let Inst{21-20} = 0b11;
3479 let Inst{19-17} = Qn{2-0};
3483 let Inst{7} = Qn{3};
3486 // Custom decoder method in order to add the FPSCR operand(s), which
3487 // Tablegen won't do right
3488 let DecoderMethod = "DecodeMVEVADCInstruction";
3491 def MVE_VADC : MVE_VADCSBC<"vadc", 0b0, 0b0, (ins cl_FPSCR_NZCV:$carryin)>;
3492 def MVE_VADCI : MVE_VADCSBC<"vadci", 0b1, 0b0, (ins)>;
3494 def MVE_VSBC : MVE_VADCSBC<"vsbc", 0b0, 0b1, (ins cl_FPSCR_NZCV:$carryin)>;
3495 def MVE_VSBCI : MVE_VADCSBC<"vsbci", 0b1, 0b1, (ins)>;
3497 class MVE_VQDMULL<string iname, string suffix, bit size, bit T,
3498 list<dag> pattern=[]>
3499 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
3500 (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm",
3501 vpred_r, "", pattern> {
3504 let Inst{28} = size;
3505 let Inst{21-20} = 0b11;
3506 let Inst{19-17} = Qn{2-0};
3510 let Inst{7} = Qn{3};
3514 multiclass MVE_VQDMULL_halves<string suffix, bit size> {
3515 def bh : MVE_VQDMULL<"vqdmullb", suffix, size, 0b0>;
3516 def th : MVE_VQDMULL<"vqdmullt", suffix, size, 0b1>;
3519 defm MVE_VQDMULLs16 : MVE_VQDMULL_halves<"s16", 0b0>;
3520 defm MVE_VQDMULLs32 : MVE_VQDMULL_halves<"s32", 0b1>;
3522 // end of mve_qDest_qSrc
3524 // start of mve_qDest_rSrc
3526 class MVE_qr_base<dag oops, dag iops, InstrItinClass itin, string iname,
3527 string suffix, string ops, vpred_ops vpred, string cstr,
3528 list<dag> pattern=[]>
3529 : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, pattern> {
3534 let Inst{25-23} = 0b100;
3535 let Inst{22} = Qd{3};
3536 let Inst{19-17} = Qn{2-0};
3537 let Inst{15-13} = Qd{2-0};
3538 let Inst{11-9} = 0b111;
3539 let Inst{7} = Qn{3};
3542 let Inst{3-0} = Rm{3-0};
3545 class MVE_qDest_rSrc<string iname, string suffix, list<dag> pattern=[]>
3546 : MVE_qr_base<(outs MQPR:$Qd), (ins MQPR:$Qn, rGPR:$Rm),
3547 NoItinerary, iname, suffix, "$Qd, $Qn, $Rm", vpred_r, "",
3550 class MVE_qDestSrc_rSrc<string iname, string suffix, list<dag> pattern=[]>
3551 : MVE_qr_base<(outs MQPR:$Qd), (ins MQPR:$Qd_src, MQPR:$Qn, rGPR:$Rm),
3552 NoItinerary, iname, suffix, "$Qd, $Qn, $Rm", vpred_n, "$Qd = $Qd_src",
3555 class MVE_qDest_single_rSrc<string iname, string suffix, list<dag> pattern=[]>
3556 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qd_src, rGPR:$Rm), NoItinerary, iname,
3557 suffix, "$Qd, $Rm", vpred_n, "$Qd = $Qd_src", pattern> {
3561 let Inst{22} = Qd{3};
3562 let Inst{15-13} = Qd{2-0};
3563 let Inst{3-0} = Rm{3-0};
3566 class MVE_VADDSUB_qr<string iname, string suffix, bits<2> size,
3567 bit bit_5, bit bit_12, bit bit_16,
3568 bit bit_28, list<dag> pattern=[]>
3569 : MVE_qDest_rSrc<iname, suffix, pattern> {
3571 let Inst{28} = bit_28;
3572 let Inst{21-20} = size;
3573 let Inst{16} = bit_16;
3574 let Inst{12} = bit_12;
3576 let Inst{5} = bit_5;
3579 multiclass MVE_VADDSUB_qr_sizes<string iname, string suffix,
3580 bit bit_5, bit bit_12, bit bit_16,
3581 bit bit_28, list<dag> pattern=[]> {
3582 def "8" : MVE_VADDSUB_qr<iname, suffix#"8", 0b00,
3583 bit_5, bit_12, bit_16, bit_28>;
3584 def "16" : MVE_VADDSUB_qr<iname, suffix#"16", 0b01,
3585 bit_5, bit_12, bit_16, bit_28>;
3586 def "32" : MVE_VADDSUB_qr<iname, suffix#"32", 0b10,
3587 bit_5, bit_12, bit_16, bit_28>;
3590 defm MVE_VADD_qr_i : MVE_VADDSUB_qr_sizes<"vadd", "i", 0b0, 0b0, 0b1, 0b0>;
3591 defm MVE_VQADD_qr_s : MVE_VADDSUB_qr_sizes<"vqadd", "s", 0b1, 0b0, 0b0, 0b0>;
3592 defm MVE_VQADD_qr_u : MVE_VADDSUB_qr_sizes<"vqadd", "u", 0b1, 0b0, 0b0, 0b1>;
3594 defm MVE_VSUB_qr_i : MVE_VADDSUB_qr_sizes<"vsub", "i", 0b0, 0b1, 0b1, 0b0>;
3595 defm MVE_VQSUB_qr_s : MVE_VADDSUB_qr_sizes<"vqsub", "s", 0b1, 0b1, 0b0, 0b0>;
3596 defm MVE_VQSUB_qr_u : MVE_VADDSUB_qr_sizes<"vqsub", "u", 0b1, 0b1, 0b0, 0b1>;
3598 class MVE_VQDMULL_qr<string iname, string suffix, bit size,
3599 bit T, list<dag> pattern=[]>
3600 : MVE_qDest_rSrc<iname, suffix, pattern> {
3602 let Inst{28} = size;
3603 let Inst{21-20} = 0b11;
3610 multiclass MVE_VQDMULL_qr_halves<string suffix, bit size> {
3611 def bh : MVE_VQDMULL_qr<"vqdmullb", suffix, size, 0b0>;
3612 def th : MVE_VQDMULL_qr<"vqdmullt", suffix, size, 0b1>;
3615 defm MVE_VQDMULL_qr_s16 : MVE_VQDMULL_qr_halves<"s16", 0b0>;
3616 defm MVE_VQDMULL_qr_s32 : MVE_VQDMULL_qr_halves<"s32", 0b1>;
3618 class MVE_VxADDSUB_qr<string iname, string suffix,
3619 bit bit_28, bits<2> bits_21_20, bit subtract,
3620 list<dag> pattern=[]>
3621 : MVE_qDest_rSrc<iname, suffix, pattern> {
3623 let Inst{28} = bit_28;
3624 let Inst{21-20} = bits_21_20;
3626 let Inst{12} = subtract;
3631 def MVE_VHADD_qr_s8 : MVE_VxADDSUB_qr<"vhadd", "s8", 0b0, 0b00, 0b0>;
3632 def MVE_VHADD_qr_s16 : MVE_VxADDSUB_qr<"vhadd", "s16", 0b0, 0b01, 0b0>;
3633 def MVE_VHADD_qr_s32 : MVE_VxADDSUB_qr<"vhadd", "s32", 0b0, 0b10, 0b0>;
3634 def MVE_VHADD_qr_u8 : MVE_VxADDSUB_qr<"vhadd", "u8", 0b1, 0b00, 0b0>;
3635 def MVE_VHADD_qr_u16 : MVE_VxADDSUB_qr<"vhadd", "u16", 0b1, 0b01, 0b0>;
3636 def MVE_VHADD_qr_u32 : MVE_VxADDSUB_qr<"vhadd", "u32", 0b1, 0b10, 0b0>;
3638 def MVE_VHSUB_qr_s8 : MVE_VxADDSUB_qr<"vhsub", "s8", 0b0, 0b00, 0b1>;
3639 def MVE_VHSUB_qr_s16 : MVE_VxADDSUB_qr<"vhsub", "s16", 0b0, 0b01, 0b1>;
3640 def MVE_VHSUB_qr_s32 : MVE_VxADDSUB_qr<"vhsub", "s32", 0b0, 0b10, 0b1>;
3641 def MVE_VHSUB_qr_u8 : MVE_VxADDSUB_qr<"vhsub", "u8", 0b1, 0b00, 0b1>;
3642 def MVE_VHSUB_qr_u16 : MVE_VxADDSUB_qr<"vhsub", "u16", 0b1, 0b01, 0b1>;
3643 def MVE_VHSUB_qr_u32 : MVE_VxADDSUB_qr<"vhsub", "u32", 0b1, 0b10, 0b1>;
3645 let Predicates = [HasMVEFloat] in {
3646 def MVE_VADD_qr_f32 : MVE_VxADDSUB_qr<"vadd", "f32", 0b0, 0b11, 0b0>;
3647 def MVE_VADD_qr_f16 : MVE_VxADDSUB_qr<"vadd", "f16", 0b1, 0b11, 0b0>;
3649 def MVE_VSUB_qr_f32 : MVE_VxADDSUB_qr<"vsub", "f32", 0b0, 0b11, 0b1>;
3650 def MVE_VSUB_qr_f16 : MVE_VxADDSUB_qr<"vsub", "f16", 0b1, 0b11, 0b1>;
3653 class MVE_VxSHL_qr<string iname, string suffix, bit U, bits<2> size,
3654 bit bit_7, bit bit_17, list<dag> pattern=[]>
3655 : MVE_qDest_single_rSrc<iname, suffix, pattern> {
3658 let Inst{25-23} = 0b100;
3659 let Inst{21-20} = 0b11;
3660 let Inst{19-18} = size;
3661 let Inst{17} = bit_17;
3663 let Inst{12-8} = 0b11110;
3664 let Inst{7} = bit_7;
3665 let Inst{6-4} = 0b110;
3668 multiclass MVE_VxSHL_qr_types<string iname, bit bit_7, bit bit_17> {
3669 def s8 : MVE_VxSHL_qr<iname, "s8", 0b0, 0b00, bit_7, bit_17>;
3670 def s16 : MVE_VxSHL_qr<iname, "s16", 0b0, 0b01, bit_7, bit_17>;
3671 def s32 : MVE_VxSHL_qr<iname, "s32", 0b0, 0b10, bit_7, bit_17>;
3672 def u8 : MVE_VxSHL_qr<iname, "u8", 0b1, 0b00, bit_7, bit_17>;
3673 def u16 : MVE_VxSHL_qr<iname, "u16", 0b1, 0b01, bit_7, bit_17>;
3674 def u32 : MVE_VxSHL_qr<iname, "u32", 0b1, 0b10, bit_7, bit_17>;
3677 defm MVE_VSHL_qr : MVE_VxSHL_qr_types<"vshl", 0b0, 0b0>;
3678 defm MVE_VRSHL_qr : MVE_VxSHL_qr_types<"vrshl", 0b0, 0b1>;
3679 defm MVE_VQSHL_qr : MVE_VxSHL_qr_types<"vqshl", 0b1, 0b0>;
3680 defm MVE_VQRSHL_qr : MVE_VxSHL_qr_types<"vqrshl", 0b1, 0b1>;
3682 let Predicates = [HasMVEInt] in {
3683 def : Pat<(v4i32 (ARMvshlu (v4i32 MQPR:$Qm), (v4i32 (ARMvdup GPR:$Rm)))),
3684 (v4i32 (MVE_VSHL_qru32 (v4i32 MQPR:$Qm), GPR:$Rm))>;
3685 def : Pat<(v8i16 (ARMvshlu (v8i16 MQPR:$Qm), (v8i16 (ARMvdup GPR:$Rm)))),
3686 (v8i16 (MVE_VSHL_qru16 (v8i16 MQPR:$Qm), GPR:$Rm))>;
3687 def : Pat<(v16i8 (ARMvshlu (v16i8 MQPR:$Qm), (v16i8 (ARMvdup GPR:$Rm)))),
3688 (v16i8 (MVE_VSHL_qru8 (v16i8 MQPR:$Qm), GPR:$Rm))>;
3690 def : Pat<(v4i32 (ARMvshls (v4i32 MQPR:$Qm), (v4i32 (ARMvdup GPR:$Rm)))),
3691 (v4i32 (MVE_VSHL_qrs32 (v4i32 MQPR:$Qm), GPR:$Rm))>;
3692 def : Pat<(v8i16 (ARMvshls (v8i16 MQPR:$Qm), (v8i16 (ARMvdup GPR:$Rm)))),
3693 (v8i16 (MVE_VSHL_qrs16 (v8i16 MQPR:$Qm), GPR:$Rm))>;
3694 def : Pat<(v16i8 (ARMvshls (v16i8 MQPR:$Qm), (v16i8 (ARMvdup GPR:$Rm)))),
3695 (v16i8 (MVE_VSHL_qrs8 (v16i8 MQPR:$Qm), GPR:$Rm))>;
3698 class MVE_VBRSR<string iname, string suffix, bits<2> size, list<dag> pattern=[]>
3699 : MVE_qDest_rSrc<iname, suffix, pattern> {
3702 let Inst{21-20} = size;
3709 def MVE_VBRSR8 : MVE_VBRSR<"vbrsr", "8", 0b00>;
3710 def MVE_VBRSR16 : MVE_VBRSR<"vbrsr", "16", 0b01>;
3711 def MVE_VBRSR32 : MVE_VBRSR<"vbrsr", "32", 0b10>;
3713 class MVE_VMUL_qr_int<string iname, string suffix,
3714 bits<2> size, list<dag> pattern=[]>
3715 : MVE_qDest_rSrc<iname, suffix, pattern> {
3718 let Inst{21-20} = size;
3725 def MVE_VMUL_qr_i8 : MVE_VMUL_qr_int<"vmul", "i8", 0b00>;
3726 def MVE_VMUL_qr_i16 : MVE_VMUL_qr_int<"vmul", "i16", 0b01>;
3727 def MVE_VMUL_qr_i32 : MVE_VMUL_qr_int<"vmul", "i32", 0b10>;
3729 class MVE_VxxMUL_qr<string iname, string suffix,
3730 bit bit_28, bits<2> bits_21_20, list<dag> pattern=[]>
3731 : MVE_qDest_rSrc<iname, suffix, pattern> {
3733 let Inst{28} = bit_28;
3734 let Inst{21-20} = bits_21_20;
3741 def MVE_VQDMULH_qr_s8 : MVE_VxxMUL_qr<"vqdmulh", "s8", 0b0, 0b00>;
3742 def MVE_VQDMULH_qr_s16 : MVE_VxxMUL_qr<"vqdmulh", "s16", 0b0, 0b01>;
3743 def MVE_VQDMULH_qr_s32 : MVE_VxxMUL_qr<"vqdmulh", "s32", 0b0, 0b10>;
3745 def MVE_VQRDMULH_qr_s8 : MVE_VxxMUL_qr<"vqrdmulh", "s8", 0b1, 0b00>;
3746 def MVE_VQRDMULH_qr_s16 : MVE_VxxMUL_qr<"vqrdmulh", "s16", 0b1, 0b01>;
3747 def MVE_VQRDMULH_qr_s32 : MVE_VxxMUL_qr<"vqrdmulh", "s32", 0b1, 0b10>;
3749 let Predicates = [HasMVEFloat] in {
3750 def MVE_VMUL_qr_f16 : MVE_VxxMUL_qr<"vmul", "f16", 0b1, 0b11>;
3751 def MVE_VMUL_qr_f32 : MVE_VxxMUL_qr<"vmul", "f32", 0b0, 0b11>;
3754 class MVE_VFMAMLA_qr<string iname, string suffix,
3755 bit bit_28, bits<2> bits_21_20, bit S,
3756 list<dag> pattern=[]>
3757 : MVE_qDestSrc_rSrc<iname, suffix, pattern> {
3759 let Inst{28} = bit_28;
3760 let Inst{21-20} = bits_21_20;
3767 def MVE_VMLA_qr_s8 : MVE_VFMAMLA_qr<"vmla", "s8", 0b0, 0b00, 0b0>;
3768 def MVE_VMLA_qr_s16 : MVE_VFMAMLA_qr<"vmla", "s16", 0b0, 0b01, 0b0>;
3769 def MVE_VMLA_qr_s32 : MVE_VFMAMLA_qr<"vmla", "s32", 0b0, 0b10, 0b0>;
3770 def MVE_VMLA_qr_u8 : MVE_VFMAMLA_qr<"vmla", "u8", 0b1, 0b00, 0b0>;
3771 def MVE_VMLA_qr_u16 : MVE_VFMAMLA_qr<"vmla", "u16", 0b1, 0b01, 0b0>;
3772 def MVE_VMLA_qr_u32 : MVE_VFMAMLA_qr<"vmla", "u32", 0b1, 0b10, 0b0>;
3774 def MVE_VMLAS_qr_s8 : MVE_VFMAMLA_qr<"vmlas", "s8", 0b0, 0b00, 0b1>;
3775 def MVE_VMLAS_qr_s16 : MVE_VFMAMLA_qr<"vmlas", "s16", 0b0, 0b01, 0b1>;
3776 def MVE_VMLAS_qr_s32 : MVE_VFMAMLA_qr<"vmlas", "s32", 0b0, 0b10, 0b1>;
3777 def MVE_VMLAS_qr_u8 : MVE_VFMAMLA_qr<"vmlas", "u8", 0b1, 0b00, 0b1>;
3778 def MVE_VMLAS_qr_u16 : MVE_VFMAMLA_qr<"vmlas", "u16", 0b1, 0b01, 0b1>;
3779 def MVE_VMLAS_qr_u32 : MVE_VFMAMLA_qr<"vmlas", "u32", 0b1, 0b10, 0b1>;
3781 let Predicates = [HasMVEFloat] in {
3782 def MVE_VFMA_qr_f16 : MVE_VFMAMLA_qr<"vfma", "f16", 0b1, 0b11, 0b0>;
3783 def MVE_VFMA_qr_f32 : MVE_VFMAMLA_qr<"vfma", "f32", 0b0, 0b11, 0b0>;
3784 def MVE_VFMA_qr_Sf16 : MVE_VFMAMLA_qr<"vfmas", "f16", 0b1, 0b11, 0b1>;
3785 def MVE_VFMA_qr_Sf32 : MVE_VFMAMLA_qr<"vfmas", "f32", 0b0, 0b11, 0b1>;
3788 class MVE_VQDMLAH_qr<string iname, string suffix, bit U, bits<2> size,
3789 bit bit_5, bit bit_12, list<dag> pattern=[]>
3790 : MVE_qDestSrc_rSrc<iname, suffix, pattern> {
3793 let Inst{21-20} = size;
3795 let Inst{12} = bit_12;
3797 let Inst{5} = bit_5;
3800 multiclass MVE_VQDMLAH_qr_types<string iname, bit bit_5, bit bit_12> {
3801 def s8 : MVE_VQDMLAH_qr<iname, "s8", 0b0, 0b00, bit_5, bit_12>;
3802 def s16 : MVE_VQDMLAH_qr<iname, "s16", 0b0, 0b01, bit_5, bit_12>;
3803 def s32 : MVE_VQDMLAH_qr<iname, "s32", 0b0, 0b10, bit_5, bit_12>;
3806 defm MVE_VQDMLAH_qr : MVE_VQDMLAH_qr_types<"vqdmlah", 0b1, 0b0>;
3807 defm MVE_VQRDMLAH_qr : MVE_VQDMLAH_qr_types<"vqrdmlah", 0b0, 0b0>;
3808 defm MVE_VQDMLASH_qr : MVE_VQDMLAH_qr_types<"vqdmlash", 0b1, 0b1>;
3809 defm MVE_VQRDMLASH_qr : MVE_VQDMLAH_qr_types<"vqrdmlash", 0b0, 0b1>;
3811 class MVE_VxDUP<string iname, string suffix, bits<2> size, bit bit_12,
3812 list<dag> pattern=[]>
3813 : MVE_p<(outs MQPR:$Qd, tGPREven:$Rn),
3814 (ins tGPREven:$Rn_src, MVE_VIDUP_imm:$imm), NoItinerary,
3815 iname, suffix, "$Qd, $Rn, $imm", vpred_r, "$Rn = $Rn_src",
3822 let Inst{25-23} = 0b100;
3823 let Inst{22} = Qd{3};
3824 let Inst{21-20} = size;
3825 let Inst{19-17} = Rn{3-1};
3827 let Inst{15-13} = Qd{2-0};
3828 let Inst{12} = bit_12;
3829 let Inst{11-8} = 0b1111;
3830 let Inst{7} = imm{1};
3831 let Inst{6-1} = 0b110111;
3832 let Inst{0} = imm{0};
3835 def MVE_VIDUPu8 : MVE_VxDUP<"vidup", "u8", 0b00, 0b0>;
3836 def MVE_VIDUPu16 : MVE_VxDUP<"vidup", "u16", 0b01, 0b0>;
3837 def MVE_VIDUPu32 : MVE_VxDUP<"vidup", "u32", 0b10, 0b0>;
3839 def MVE_VDDUPu8 : MVE_VxDUP<"vddup", "u8", 0b00, 0b1>;
3840 def MVE_VDDUPu16 : MVE_VxDUP<"vddup", "u16", 0b01, 0b1>;
3841 def MVE_VDDUPu32 : MVE_VxDUP<"vddup", "u32", 0b10, 0b1>;
3843 class MVE_VxWDUP<string iname, string suffix, bits<2> size, bit bit_12,
3844 list<dag> pattern=[]>
3845 : MVE_p<(outs MQPR:$Qd, tGPREven:$Rn),
3846 (ins tGPREven:$Rn_src, tGPROdd:$Rm, MVE_VIDUP_imm:$imm), NoItinerary,
3847 iname, suffix, "$Qd, $Rn, $Rm, $imm", vpred_r, "$Rn = $Rn_src",
3855 let Inst{25-23} = 0b100;
3856 let Inst{22} = Qd{3};
3857 let Inst{21-20} = size;
3858 let Inst{19-17} = Rn{3-1};
3860 let Inst{15-13} = Qd{2-0};
3861 let Inst{12} = bit_12;
3862 let Inst{11-8} = 0b1111;
3863 let Inst{7} = imm{1};
3864 let Inst{6-4} = 0b110;
3865 let Inst{3-1} = Rm{3-1};
3866 let Inst{0} = imm{0};
3869 def MVE_VIWDUPu8 : MVE_VxWDUP<"viwdup", "u8", 0b00, 0b0>;
3870 def MVE_VIWDUPu16 : MVE_VxWDUP<"viwdup", "u16", 0b01, 0b0>;
3871 def MVE_VIWDUPu32 : MVE_VxWDUP<"viwdup", "u32", 0b10, 0b0>;
3873 def MVE_VDWDUPu8 : MVE_VxWDUP<"vdwdup", "u8", 0b00, 0b1>;
3874 def MVE_VDWDUPu16 : MVE_VxWDUP<"vdwdup", "u16", 0b01, 0b1>;
3875 def MVE_VDWDUPu32 : MVE_VxWDUP<"vdwdup", "u32", 0b10, 0b1>;
3877 class MVE_VCTP<string suffix, bits<2> size, list<dag> pattern=[]>
3878 : MVE_p<(outs VCCR:$P0), (ins rGPR:$Rn), NoItinerary, "vctp", suffix,
3879 "$Rn", vpred_n, "", pattern> {
3882 let Inst{28-27} = 0b10;
3883 let Inst{26-22} = 0b00000;
3884 let Inst{21-20} = size;
3885 let Inst{19-16} = Rn{3-0};
3886 let Inst{15-11} = 0b11101;
3887 let Inst{10-0} = 0b00000000001;
3888 let Unpredictable{10-0} = 0b11111111111;
3890 let Constraints = "";
3891 let DecoderMethod = "DecodeMveVCTP";
3894 def MVE_VCTP8 : MVE_VCTP<"8", 0b00>;
3895 def MVE_VCTP16 : MVE_VCTP<"16", 0b01>;
3896 def MVE_VCTP32 : MVE_VCTP<"32", 0b10>;
3897 def MVE_VCTP64 : MVE_VCTP<"64", 0b11>;
3899 // end of mve_qDest_rSrc
3901 // start of coproc mov
3903 class MVE_VMOV_64bit<dag oops, dag iops, bit to_qreg, string ops, string cstr>
3904 : MVE_VMOV_lane_base<oops, !con(iops, (ins MVEPairVectorIndex2:$idx,
3905 MVEPairVectorIndex0:$idx2)),
3906 NoItinerary, "vmov", "", ops, cstr, []> {
3913 let Inst{31-23} = 0b111011000;
3914 let Inst{22} = Qd{3};
3916 let Inst{20} = to_qreg;
3917 let Inst{19-16} = Rt2{3-0};
3918 let Inst{15-13} = Qd{2-0};
3919 let Inst{12-5} = 0b01111000;
3921 let Inst{3-0} = Rt{3-0};
3924 // The assembly syntax for these instructions mentions the vector
3925 // register name twice, e.g.
3927 // vmov q2[2], q2[0], r0, r1
3928 // vmov r0, r1, q2[2], q2[0]
3930 // which needs a bit of juggling with MC operand handling.
3932 // For the move _into_ a vector register, the MC operand list also has
3933 // to mention the register name twice: once as the output, and once as
3934 // an extra input to represent where the unchanged half of the output
3935 // register comes from (when this instruction is used in code
3936 // generation). So we arrange that the first mention of the vector reg
3937 // in the instruction is considered by the AsmMatcher to be the output
3938 // ($Qd), and the second one is the input ($QdSrc). Binding them
3939 // together with the existing 'tie' constraint is enough to enforce at
3940 // register allocation time that they have to be the same register.
3942 // For the move _from_ a vector register, there's no way to get round
3943 // the fact that both instances of that register name have to be
3944 // inputs. They have to be the same register again, but this time, we
3945 // can't use a tie constraint, because that has to be between an
3946 // output and an input operand. So this time, we have to arrange that
3947 // the q-reg appears just once in the MC operand list, in spite of
3948 // being mentioned twice in the asm syntax - which needs a custom
3949 // AsmMatchConverter.
3951 def MVE_VMOV_q_rr : MVE_VMOV_64bit<(outs MQPR:$Qd),
3952 (ins MQPR:$QdSrc, rGPR:$Rt, rGPR:$Rt2),
3953 0b1, "$Qd$idx, $QdSrc$idx2, $Rt, $Rt2",
3955 let DecoderMethod = "DecodeMVEVMOVDRegtoQ";
3958 def MVE_VMOV_rr_q : MVE_VMOV_64bit<(outs rGPR:$Rt, rGPR:$Rt2), (ins MQPR:$Qd),
3959 0b0, "$Rt, $Rt2, $Qd$idx, $Qd$idx2", ""> {
3960 let DecoderMethod = "DecodeMVEVMOVQtoDReg";
3961 let AsmMatchConverter = "cvtMVEVMOVQtoDReg";
3964 // end of coproc mov
3966 // start of MVE interleaving load/store
3968 // Base class for the family of interleaving/deinterleaving
3969 // load/stores with names like VLD20.8 and VST43.32.
3970 class MVE_vldst24_base<bit writeback, bit fourregs, bits<2> stage, bits<2> size,
3971 bit load, dag Oops, dag loadIops, dag wbIops,
3972 string iname, string ops,
3973 string cstr, list<dag> pattern=[]>
3974 : MVE_MI<Oops, !con(loadIops, wbIops), NoItinerary, iname, ops, cstr, pattern> {
3978 let Inst{31-22} = 0b1111110010;
3979 let Inst{21} = writeback;
3980 let Inst{20} = load;
3981 let Inst{19-16} = Rn;
3982 let Inst{15-13} = VQd{2-0};
3983 let Inst{12-9} = 0b1111;
3984 let Inst{8-7} = size;
3985 let Inst{6-5} = stage;
3986 let Inst{4-1} = 0b0000;
3987 let Inst{0} = fourregs;
3990 let mayStore = !eq(load,0);
3993 // A parameter class used to encapsulate all the ways the writeback
3994 // variants of VLD20 and friends differ from the non-writeback ones.
3995 class MVE_vldst24_writeback<bit b, dag Oo, dag Io,
3996 string sy="", string c="", string n=""> {
4002 string id_suffix = n;
4005 // Another parameter class that encapsulates the differences between VLD2x
4007 class MVE_vldst24_nvecs<int n, list<int> s, bit b, RegisterOperand vl> {
4009 list<int> stages = s;
4011 RegisterOperand VecList = vl;
4014 // A third parameter class that distinguishes VLDnn.8 from .16 from .32.
4015 class MVE_vldst24_lanesize<int i, bits<2> b> {
4017 bits<2> sizebits = b;
4020 // A base class for each direction of transfer: one for load, one for
4021 // store. I can't make these a fourth independent parametric tuple
4022 // class, because they have to take the nvecs tuple class as a
4023 // parameter, in order to find the right VecList operand type.
4025 class MVE_vld24_base<MVE_vldst24_nvecs n, bits<2> pat, bits<2> size,
4026 MVE_vldst24_writeback wb, string iname,
4027 list<dag> pattern=[]>
4028 : MVE_vldst24_base<wb.writeback, n.bit0, pat, size, 1,
4029 !con((outs n.VecList:$VQd), wb.Oops),
4030 (ins n.VecList:$VQdSrc), wb.Iops,
4031 iname, "$VQd, $Rn" # wb.syntax,
4032 wb.cstr # ",$VQdSrc = $VQd", pattern>;
4034 class MVE_vst24_base<MVE_vldst24_nvecs n, bits<2> pat, bits<2> size,
4035 MVE_vldst24_writeback wb, string iname,
4036 list<dag> pattern=[]>
4037 : MVE_vldst24_base<wb.writeback, n.bit0, pat, size, 0,
4038 wb.Oops, (ins n.VecList:$VQd), wb.Iops,
4039 iname, "$VQd, $Rn" # wb.syntax,
4042 // Actually define all the interleaving loads and stores, by a series
4043 // of nested foreaches over number of vectors (VLD2/VLD4); stage
4044 // within one of those series (VLDx0/VLDx1/VLDx2/VLDx3); size of
4045 // vector lane; writeback or no writeback.
4046 foreach n = [MVE_vldst24_nvecs<2, [0,1], 0, VecList2Q>,
4047 MVE_vldst24_nvecs<4, [0,1,2,3], 1, VecList4Q>] in
4048 foreach stage = n.stages in
4049 foreach s = [MVE_vldst24_lanesize< 8, 0b00>,
4050 MVE_vldst24_lanesize<16, 0b01>,
4051 MVE_vldst24_lanesize<32, 0b10>] in
4052 foreach wb = [MVE_vldst24_writeback<
4053 1, (outs rGPR:$wb), (ins t2_nosp_addr_offset_none:$Rn),
4054 "!", "$Rn.base = $wb", "_wb">,
4055 MVE_vldst24_writeback<0, (outs), (ins t2_addr_offset_none:$Rn)>] in {
4057 // For each case within all of those foreaches, define the actual
4058 // instructions. The def names are made by gluing together pieces
4059 // from all the parameter classes, and will end up being things like
4060 // MVE_VLD20_8 and MVE_VST43_16_wb.
4062 def "MVE_VLD" # n.nvecs # stage # "_" # s.lanesize # wb.id_suffix
4063 : MVE_vld24_base<n, stage, s.sizebits, wb,
4064 "vld" # n.nvecs # stage # "." # s.lanesize>;
4066 def "MVE_VST" # n.nvecs # stage # "_" # s.lanesize # wb.id_suffix
4067 : MVE_vst24_base<n, stage, s.sizebits, wb,
4068 "vst" # n.nvecs # stage # "." # s.lanesize>;
4071 // end of MVE interleaving load/store
4073 // start of MVE predicable load/store
4075 // A parameter class for the direction of transfer.
4076 class MVE_ldst_direction<bit b, dag Oo, dag Io, string c=""> {
4082 def MVE_ld: MVE_ldst_direction<1, (outs MQPR:$Qd), (ins), ",@earlyclobber $Qd">;
4083 def MVE_st: MVE_ldst_direction<0, (outs), (ins MQPR:$Qd)>;
4085 // A parameter class for the size of memory access in a load.
4086 class MVE_memsz<bits<2> e, int s, AddrMode m, string mn, list<string> types> {
4087 bits<2> encoding = e; // opcode bit(s) for encoding
4088 int shift = s; // shift applied to immediate load offset
4091 // For instruction aliases: define the complete list of type
4092 // suffixes at this size, and the canonical ones for loads and
4094 string MnemonicLetter = mn;
4095 int TypeBits = !shl(8, s);
4096 string CanonLoadSuffix = ".u" # TypeBits;
4097 string CanonStoreSuffix = "." # TypeBits;
4098 list<string> suffixes = !foreach(letter, types, "." # letter # TypeBits);
4101 // Instances of MVE_memsz.
4103 // (memD doesn't need an AddrMode, because those are only for
4104 // contiguous loads, and memD is only used by gather/scatters.)
4105 def MVE_memB: MVE_memsz<0b00, 0, AddrModeT2_i7, "b", ["", "u", "s"]>;
4106 def MVE_memH: MVE_memsz<0b01, 1, AddrModeT2_i7s2, "h", ["", "u", "s", "f"]>;
4107 def MVE_memW: MVE_memsz<0b10, 2, AddrModeT2_i7s4, "w", ["", "u", "s", "f"]>;
4108 def MVE_memD: MVE_memsz<0b11, 3, ?, "d", ["", "u", "s", "f"]>;
4110 // This is the base class for all the MVE loads and stores other than
4111 // the interleaving ones. All the non-interleaving loads/stores share
4112 // the characteristic that they operate on just one vector register,
4113 // so they are VPT-predicable.
4115 // The predication operand is vpred_n, for both loads and stores. For
4116 // store instructions, the reason is obvious: if there is no output
4117 // register, there can't be a need for an input parameter giving the
4118 // output register's previous value. Load instructions also don't need
4119 // that input parameter, because unlike MVE data processing
4120 // instructions, predicated loads are defined to set the inactive
4121 // lanes of the output register to zero, instead of preserving their
4123 class MVE_VLDRSTR_base<MVE_ldst_direction dir, bit U, bit P, bit W, bit opc,
4124 dag oops, dag iops, string asm, string suffix,
4125 string ops, string cstr, list<dag> pattern=[]>
4126 : MVE_p<oops, iops, NoItinerary, asm, suffix, ops, vpred_n, cstr, pattern> {
4134 let Inst{20} = dir.load;
4135 let Inst{15-13} = Qd{2-0};
4137 let Inst{11-9} = 0b111;
4139 let mayLoad = dir.load;
4140 let mayStore = !eq(dir.load,0);
4143 // Contiguous load and store instructions. These come in two main
4144 // categories: same-size loads/stores in which 128 bits of vector
4145 // register is transferred to or from 128 bits of memory in the most
4146 // obvious way, and widening loads / narrowing stores, in which the
4147 // size of memory accessed is less than the size of a vector register,
4148 // so the load instructions sign- or zero-extend each memory value
4149 // into a wider vector lane, and the store instructions truncate
4152 // The instruction mnemonics for these two classes look reasonably
4153 // similar, but the actual encodings are different enough to need two
4154 // separate base classes.
4156 // Contiguous, same size
4157 class MVE_VLDRSTR_cs<MVE_ldst_direction dir, MVE_memsz memsz, bit P, bit W,
4158 dag oops, dag iops, string asm, string suffix,
4159 IndexMode im, string ops, string cstr>
4160 : MVE_VLDRSTR_base<dir, 0, P, W, 1, oops, iops, asm, suffix, ops, cstr> {
4162 let Inst{23} = addr{7};
4163 let Inst{19-16} = addr{11-8};
4164 let Inst{8-7} = memsz.encoding;
4165 let Inst{6-0} = addr{6-0};
4168 // Contiguous, widening/narrowing
4169 class MVE_VLDRSTR_cw<MVE_ldst_direction dir, MVE_memsz memsz, bit U,
4170 bit P, bit W, bits<2> size, dag oops, dag iops,
4171 string asm, string suffix, IndexMode im,
4172 string ops, string cstr>
4173 : MVE_VLDRSTR_base<dir, U, P, W, 0, oops, iops, asm, suffix, ops, cstr> {
4175 let Inst{23} = addr{7};
4176 let Inst{19} = memsz.encoding{0}; // enough to tell 16- from 32-bit
4177 let Inst{18-16} = addr{10-8};
4178 let Inst{8-7} = size;
4179 let Inst{6-0} = addr{6-0};
4184 // Multiclass wrapper on each of the _cw and _cs base classes, to
4185 // generate three writeback modes (none, preindex, postindex).
4187 multiclass MVE_VLDRSTR_cw_m<MVE_ldst_direction dir, MVE_memsz memsz,
4188 string asm, string suffix, bit U, bits<2> size> {
4189 let AM = memsz.AM in {
4190 def "" : MVE_VLDRSTR_cw<
4191 dir, memsz, U, 1, 0, size,
4192 dir.Oops, !con(dir.Iops, (ins taddrmode_imm7<memsz.shift>:$addr)),
4193 asm, suffix, IndexModeNone, "$Qd, $addr", "">;
4195 def _pre : MVE_VLDRSTR_cw<
4196 dir, memsz, U, 1, 1, size,
4197 !con((outs tGPR:$wb), dir.Oops),
4198 !con(dir.Iops, (ins taddrmode_imm7<memsz.shift>:$addr)),
4199 asm, suffix, IndexModePre, "$Qd, $addr!", "$addr.base = $wb"> {
4200 let DecoderMethod = "DecodeMVE_MEM_1_pre<"#memsz.shift#">";
4203 def _post : MVE_VLDRSTR_cw<
4204 dir, memsz, U, 0, 1, size,
4205 !con((outs tGPR:$wb), dir.Oops),
4206 !con(dir.Iops, (ins t_addr_offset_none:$Rn,
4207 t2am_imm7_offset<memsz.shift>:$addr)),
4208 asm, suffix, IndexModePost, "$Qd, $Rn$addr", "$Rn.base = $wb"> {
4210 let Inst{18-16} = Rn{2-0};
4215 multiclass MVE_VLDRSTR_cs_m<MVE_ldst_direction dir, MVE_memsz memsz,
4216 string asm, string suffix> {
4217 let AM = memsz.AM in {
4218 def "" : MVE_VLDRSTR_cs<
4220 dir.Oops, !con(dir.Iops, (ins t2addrmode_imm7<memsz.shift>:$addr)),
4221 asm, suffix, IndexModeNone, "$Qd, $addr", "">;
4223 def _pre : MVE_VLDRSTR_cs<
4225 !con((outs rGPR:$wb), dir.Oops),
4226 !con(dir.Iops, (ins t2addrmode_imm7_pre<memsz.shift>:$addr)),
4227 asm, suffix, IndexModePre, "$Qd, $addr!", "$addr.base = $wb"> {
4228 let DecoderMethod = "DecodeMVE_MEM_2_pre<"#memsz.shift#">";
4231 def _post : MVE_VLDRSTR_cs<
4233 !con((outs rGPR:$wb), dir.Oops),
4234 // We need an !if here to select the base register class,
4235 // because it's legal to write back to SP in a load of this
4236 // type, but not in a store.
4237 !con(dir.Iops, (ins !if(dir.load, t2_addr_offset_none,
4238 t2_nosp_addr_offset_none):$Rn,
4239 t2am_imm7_offset<memsz.shift>:$addr)),
4240 asm, suffix, IndexModePost, "$Qd, $Rn$addr", "$Rn.base = $wb"> {
4242 let Inst{19-16} = Rn{3-0};
4247 // Now actually declare all the contiguous load/stores, via those
4248 // multiclasses. The instruction ids coming out of this are the bare
4249 // names shown in the defm, with _pre or _post appended for writeback,
4250 // e.g. MVE_VLDRBS16, MVE_VSTRB16_pre, MVE_VSTRHU16_post.
4252 defm MVE_VLDRBS16: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "s16", 0, 0b01>;
4253 defm MVE_VLDRBS32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "s32", 0, 0b10>;
4254 defm MVE_VLDRBU16: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "u16", 1, 0b01>;
4255 defm MVE_VLDRBU32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "u32", 1, 0b10>;
4256 defm MVE_VLDRHS32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memH, "vldrh", "s32", 0, 0b10>;
4257 defm MVE_VLDRHU32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memH, "vldrh", "u32", 1, 0b10>;
4259 defm MVE_VLDRBU8: MVE_VLDRSTR_cs_m<MVE_ld, MVE_memB, "vldrb", "u8">;
4260 defm MVE_VLDRHU16: MVE_VLDRSTR_cs_m<MVE_ld, MVE_memH, "vldrh", "u16">;
4261 defm MVE_VLDRWU32: MVE_VLDRSTR_cs_m<MVE_ld, MVE_memW, "vldrw", "u32">;
4263 defm MVE_VSTRB16: MVE_VLDRSTR_cw_m<MVE_st, MVE_memB, "vstrb", "16", 0, 0b01>;
4264 defm MVE_VSTRB32: MVE_VLDRSTR_cw_m<MVE_st, MVE_memB, "vstrb", "32", 0, 0b10>;
4265 defm MVE_VSTRH32: MVE_VLDRSTR_cw_m<MVE_st, MVE_memH, "vstrh", "32", 0, 0b10>;
4267 defm MVE_VSTRBU8 : MVE_VLDRSTR_cs_m<MVE_st, MVE_memB, "vstrb", "8">;
4268 defm MVE_VSTRHU16: MVE_VLDRSTR_cs_m<MVE_st, MVE_memH, "vstrh", "16">;
4269 defm MVE_VSTRWU32: MVE_VLDRSTR_cs_m<MVE_st, MVE_memW, "vstrw", "32">;
4271 // Gather loads / scatter stores whose address operand is of the form
4272 // [Rn,Qm], i.e. a single GPR as the common base address, plus a
4273 // vector of offset from it. ('Load/store this sequence of elements of
4274 // the same array.')
4276 // Like the contiguous family, these loads and stores can widen the
4277 // loaded values / truncate the stored ones, or they can just
4278 // load/store the same size of memory and vector lane. But unlike the
4279 // contiguous family, there's no particular difference in encoding
4280 // between those two cases.
4282 // This family also comes with the option to scale the offset values
4283 // in Qm by the size of the loaded memory (i.e. to treat them as array
4284 // indices), or not to scale them (to treat them as plain byte offsets
4285 // in memory, so that perhaps the loaded values are unaligned). The
4286 // scaled instructions' address operand in assembly looks like
4287 // [Rn,Qm,UXTW #2] or similar.
4290 class MVE_VLDRSTR_rq<MVE_ldst_direction dir, MVE_memsz memsz, bit U,
4291 bits<2> size, bit os, string asm, string suffix, int shift>
4292 : MVE_VLDRSTR_base<dir, U, 0b0, 0b0, 0, dir.Oops,
4293 !con(dir.Iops, (ins mve_addr_rq_shift<shift>:$addr)),
4294 asm, suffix, "$Qd, $addr", dir.cstr> {
4297 let Inst{19-16} = addr{6-3};
4298 let Inst{8-7} = size;
4299 let Inst{6} = memsz.encoding{1};
4301 let Inst{4} = memsz.encoding{0};
4302 let Inst{3-1} = addr{2-0};
4306 // Multiclass that defines the scaled and unscaled versions of an
4307 // instruction, when the memory size is wider than a byte. The scaled
4308 // version gets the default name like MVE_VLDRBU16_rq; the unscaled /
4309 // potentially unaligned version gets a "_u" suffix, e.g.
4310 // MVE_VLDRBU16_rq_u.
4311 multiclass MVE_VLDRSTR_rq_w<MVE_ldst_direction dir, MVE_memsz memsz,
4312 string asm, string suffix, bit U, bits<2> size> {
4313 def _u : MVE_VLDRSTR_rq<dir, memsz, U, size, 0, asm, suffix, 0>;
4314 def "" : MVE_VLDRSTR_rq<dir, memsz, U, size, 1, asm, suffix, memsz.shift>;
4317 // Subclass of MVE_VLDRSTR_rq with the same API as that multiclass,
4318 // for use when the memory size is one byte, so there's no 'scaled'
4319 // version of the instruction at all. (This is encoded as if it were
4320 // unscaled, but named in the default way with no _u suffix.)
4321 class MVE_VLDRSTR_rq_b<MVE_ldst_direction dir, MVE_memsz memsz,
4322 string asm, string suffix, bit U, bits<2> size>
4323 : MVE_VLDRSTR_rq<dir, memsz, U, size, 0, asm, suffix, 0>;
4325 // Actually define all the loads and stores in this family.
4327 def MVE_VLDRBU8_rq : MVE_VLDRSTR_rq_b<MVE_ld, MVE_memB, "vldrb","u8", 1,0b00>;
4328 def MVE_VLDRBU16_rq: MVE_VLDRSTR_rq_b<MVE_ld, MVE_memB, "vldrb","u16", 1,0b01>;
4329 def MVE_VLDRBS16_rq: MVE_VLDRSTR_rq_b<MVE_ld, MVE_memB, "vldrb","s16", 0,0b01>;
4330 def MVE_VLDRBU32_rq: MVE_VLDRSTR_rq_b<MVE_ld, MVE_memB, "vldrb","u32", 1,0b10>;
4331 def MVE_VLDRBS32_rq: MVE_VLDRSTR_rq_b<MVE_ld, MVE_memB, "vldrb","s32", 0,0b10>;
4333 defm MVE_VLDRHU16_rq: MVE_VLDRSTR_rq_w<MVE_ld, MVE_memH, "vldrh","u16", 1,0b01>;
4334 defm MVE_VLDRHU32_rq: MVE_VLDRSTR_rq_w<MVE_ld, MVE_memH, "vldrh","u32", 1,0b10>;
4335 defm MVE_VLDRHS32_rq: MVE_VLDRSTR_rq_w<MVE_ld, MVE_memH, "vldrh","s32", 0,0b10>;
4336 defm MVE_VLDRWU32_rq: MVE_VLDRSTR_rq_w<MVE_ld, MVE_memW, "vldrw","u32", 1,0b10>;
4337 defm MVE_VLDRDU64_rq: MVE_VLDRSTR_rq_w<MVE_ld, MVE_memD, "vldrd","u64", 1,0b11>;
4339 def MVE_VSTRB8_rq : MVE_VLDRSTR_rq_b<MVE_st, MVE_memB, "vstrb","8", 0,0b00>;
4340 def MVE_VSTRB16_rq : MVE_VLDRSTR_rq_b<MVE_st, MVE_memB, "vstrb","16", 0,0b01>;
4341 def MVE_VSTRB32_rq : MVE_VLDRSTR_rq_b<MVE_st, MVE_memB, "vstrb","32", 0,0b10>;
4343 defm MVE_VSTRH16_rq : MVE_VLDRSTR_rq_w<MVE_st, MVE_memH, "vstrh","16", 0,0b01>;
4344 defm MVE_VSTRH32_rq : MVE_VLDRSTR_rq_w<MVE_st, MVE_memH, "vstrh","32", 0,0b10>;
4345 defm MVE_VSTRW32_rq : MVE_VLDRSTR_rq_w<MVE_st, MVE_memW, "vstrw","32", 0,0b10>;
4346 defm MVE_VSTRD64_rq : MVE_VLDRSTR_rq_w<MVE_st, MVE_memD, "vstrd","64", 0,0b11>;
4348 // Gather loads / scatter stores whose address operand is of the form
4349 // [Qm,#imm], i.e. a vector containing a full base address for each
4350 // loaded item, plus an immediate offset applied consistently to all
4351 // of them. ('Load/store the same field from this vector of pointers
4352 // to a structure type.')
4354 // This family requires the vector lane size to be at least 32 bits
4355 // (so there's room for an address in each lane at all). It has no
4356 // widening/narrowing variants. But it does support preindex
4357 // writeback, in which the address vector is updated to hold the
4358 // addresses actually loaded from.
4361 class MVE_VLDRSTR_qi<MVE_ldst_direction dir, MVE_memsz memsz, bit W, dag wbops,
4362 string asm, string wbAsm, string suffix, string cstr = "">
4363 : MVE_VLDRSTR_base<dir, 1, 1, W, 1, !con(wbops, dir.Oops),
4364 !con(dir.Iops, (ins mve_addr_q_shift<memsz.shift>:$addr)),
4365 asm, suffix, "$Qd, $addr" # wbAsm, cstr # dir.cstr> {
4367 let Inst{23} = addr{7};
4368 let Inst{19-17} = addr{10-8};
4370 let Inst{8} = memsz.encoding{0}; // enough to distinguish 32- from 64-bit
4372 let Inst{6-0} = addr{6-0};
4375 // Multiclass that generates the non-writeback and writeback variants.
4376 multiclass MVE_VLDRSTR_qi_m<MVE_ldst_direction dir, MVE_memsz memsz,
4377 string asm, string suffix> {
4378 def "" : MVE_VLDRSTR_qi<dir, memsz, 0, (outs), asm, "", suffix>;
4379 def _pre : MVE_VLDRSTR_qi<dir, memsz, 1, (outs MQPR:$wb), asm, "!", suffix,
4380 "$addr.base = $wb"> {
4381 let DecoderMethod="DecodeMVE_MEM_3_pre<"#memsz.shift#">";
4385 // Actual instruction definitions.
4386 defm MVE_VLDRWU32_qi: MVE_VLDRSTR_qi_m<MVE_ld, MVE_memW, "vldrw", "u32">;
4387 defm MVE_VLDRDU64_qi: MVE_VLDRSTR_qi_m<MVE_ld, MVE_memD, "vldrd", "u64">;
4388 defm MVE_VSTRW32_qi: MVE_VLDRSTR_qi_m<MVE_st, MVE_memW, "vstrw", "32">;
4389 defm MVE_VSTRD64_qi: MVE_VLDRSTR_qi_m<MVE_st, MVE_memD, "vstrd", "64">;
4391 // Define aliases for all the instructions where memory size and
4392 // vector lane size are the same. These are mnemonic aliases, so they
4393 // apply consistently across all of the above families - contiguous
4394 // loads, and both the rq and qi types of gather/scatter.
4396 // Rationale: As long as you're loading (for example) 16-bit memory
4397 // values into 16-bit vector lanes, you can think of them as signed or
4398 // unsigned integers, fp16 or just raw 16-bit blobs and it makes no
4399 // difference. So we permit all of vldrh.16, vldrh.u16, vldrh.s16,
4400 // vldrh.f16 and treat them all as equivalent to the canonical
4401 // spelling (which happens to be .u16 for loads, and just .16 for
4404 foreach vpt_cond = ["", "t", "e"] in
4405 foreach memsz = [MVE_memB, MVE_memH, MVE_memW, MVE_memD] in
4406 foreach suffix = memsz.suffixes in {
4408 // These foreaches are conceptually ifs, implemented by iterating a
4409 // dummy variable over a list with 0 or 1 elements depending on the
4410 // condition. The idea is to iterate over _nearly_ all the suffixes
4411 // in memsz.suffixes, but omit the one we want all the others to alias.
4413 foreach _ = !if(!ne(suffix, memsz.CanonLoadSuffix), [1], []<int>) in
4414 def : MnemonicAlias<
4415 "vldr" # memsz.MnemonicLetter # vpt_cond # suffix,
4416 "vldr" # memsz.MnemonicLetter # vpt_cond # memsz.CanonLoadSuffix>;
4418 foreach _ = !if(!ne(suffix, memsz.CanonStoreSuffix), [1], []<int>) in
4419 def : MnemonicAlias<
4420 "vstr" # memsz.MnemonicLetter # vpt_cond # suffix,
4421 "vstr" # memsz.MnemonicLetter # vpt_cond # memsz.CanonStoreSuffix>;
4424 // end of MVE predicable load/store
4426 class MVE_VPT<string suffix, bits<2> size, dag iops, string asm, list<dag> pattern=[]>
4427 : MVE_MI<(outs ), iops, NoItinerary, !strconcat("vpt", "${Mk}", ".", suffix), asm, "", pattern> {
4432 let Inst{31-23} = 0b111111100;
4433 let Inst{22} = Mk{3};
4434 let Inst{21-20} = size;
4435 let Inst{19-17} = Qn{2-0};
4437 let Inst{15-13} = Mk{2-0};
4438 let Inst{12} = fc{2};
4439 let Inst{11-8} = 0b1111;
4440 let Inst{7} = fc{0};
4443 let Defs = [VPR, P0];
4446 class MVE_VPTt1<string suffix, bits<2> size, dag iops>
4447 : MVE_VPT<suffix, size, iops, "$fc, $Qn, $Qm"> {
4452 let Inst{5} = Qm{3};
4453 let Inst{3-1} = Qm{2-0};
4454 let Inst{0} = fc{1};
4457 class MVE_VPTt1i<string suffix, bits<2> size>
4458 : MVE_VPTt1<suffix, size,
4459 (ins vpt_mask:$Mk, pred_basic_i:$fc, MQPR:$Qn, MQPR:$Qm)> {
4464 def MVE_VPTv4i32 : MVE_VPTt1i<"i32", 0b10>;
4465 def MVE_VPTv8i16 : MVE_VPTt1i<"i16", 0b01>;
4466 def MVE_VPTv16i8 : MVE_VPTt1i<"i8", 0b00>;
4468 class MVE_VPTt1u<string suffix, bits<2> size>
4469 : MVE_VPTt1<suffix, size,
4470 (ins vpt_mask:$Mk, pred_basic_u:$fc, MQPR:$Qn, MQPR:$Qm)> {
4475 def MVE_VPTv4u32 : MVE_VPTt1u<"u32", 0b10>;
4476 def MVE_VPTv8u16 : MVE_VPTt1u<"u16", 0b01>;
4477 def MVE_VPTv16u8 : MVE_VPTt1u<"u8", 0b00>;
4479 class MVE_VPTt1s<string suffix, bits<2> size>
4480 : MVE_VPTt1<suffix, size,
4481 (ins vpt_mask:$Mk, pred_basic_s:$fc, MQPR:$Qn, MQPR:$Qm)> {
4485 def MVE_VPTv4s32 : MVE_VPTt1s<"s32", 0b10>;
4486 def MVE_VPTv8s16 : MVE_VPTt1s<"s16", 0b01>;
4487 def MVE_VPTv16s8 : MVE_VPTt1s<"s8", 0b00>;
4489 class MVE_VPTt2<string suffix, bits<2> size, dag iops>
4490 : MVE_VPT<suffix, size, iops,
4497 let Inst{5} = fc{1};
4498 let Inst{3-0} = Rm{3-0};
4501 class MVE_VPTt2i<string suffix, bits<2> size>
4502 : MVE_VPTt2<suffix, size,
4503 (ins vpt_mask:$Mk, pred_basic_i:$fc, MQPR:$Qn, GPRwithZR:$Rm)> {
4508 def MVE_VPTv4i32r : MVE_VPTt2i<"i32", 0b10>;
4509 def MVE_VPTv8i16r : MVE_VPTt2i<"i16", 0b01>;
4510 def MVE_VPTv16i8r : MVE_VPTt2i<"i8", 0b00>;
4512 class MVE_VPTt2u<string suffix, bits<2> size>
4513 : MVE_VPTt2<suffix, size,
4514 (ins vpt_mask:$Mk, pred_basic_u:$fc, MQPR:$Qn, GPRwithZR:$Rm)> {
4519 def MVE_VPTv4u32r : MVE_VPTt2u<"u32", 0b10>;
4520 def MVE_VPTv8u16r : MVE_VPTt2u<"u16", 0b01>;
4521 def MVE_VPTv16u8r : MVE_VPTt2u<"u8", 0b00>;
4523 class MVE_VPTt2s<string suffix, bits<2> size>
4524 : MVE_VPTt2<suffix, size,
4525 (ins vpt_mask:$Mk, pred_basic_s:$fc, MQPR:$Qn, GPRwithZR:$Rm)> {
4529 def MVE_VPTv4s32r : MVE_VPTt2s<"s32", 0b10>;
4530 def MVE_VPTv8s16r : MVE_VPTt2s<"s16", 0b01>;
4531 def MVE_VPTv16s8r : MVE_VPTt2s<"s8", 0b00>;
4534 class MVE_VPTf<string suffix, bit size, dag iops, string asm, list<dag> pattern=[]>
4535 : MVE_MI<(outs ), iops, NoItinerary, !strconcat("vpt", "${Mk}", ".", suffix), asm,
4541 let Inst{31-29} = 0b111;
4542 let Inst{28} = size;
4543 let Inst{27-23} = 0b11100;
4544 let Inst{22} = Mk{3};
4545 let Inst{21-20} = 0b11;
4546 let Inst{19-17} = Qn{2-0};
4548 let Inst{15-13} = Mk{2-0};
4549 let Inst{12} = fc{2};
4550 let Inst{11-8} = 0b1111;
4551 let Inst{7} = fc{0};
4555 let Predicates = [HasMVEFloat];
4558 class MVE_VPTft1<string suffix, bit size>
4559 : MVE_VPTf<suffix, size, (ins vpt_mask:$Mk, pred_basic_fp:$fc, MQPR:$Qn, MQPR:$Qm),
4565 let Inst{5} = Qm{3};
4566 let Inst{3-1} = Qm{2-0};
4567 let Inst{0} = fc{1};
4570 def MVE_VPTv4f32 : MVE_VPTft1<"f32", 0b0>;
4571 def MVE_VPTv8f16 : MVE_VPTft1<"f16", 0b1>;
4573 class MVE_VPTft2<string suffix, bit size>
4574 : MVE_VPTf<suffix, size, (ins vpt_mask:$Mk, pred_basic_fp:$fc, MQPR:$Qn, GPRwithZR:$Rm),
4580 let Inst{5} = fc{1};
4581 let Inst{3-0} = Rm{3-0};
4584 def MVE_VPTv4f32r : MVE_VPTft2<"f32", 0b0>;
4585 def MVE_VPTv8f16r : MVE_VPTft2<"f16", 0b1>;
4587 def MVE_VPST : MVE_MI<(outs ), (ins vpt_mask:$Mk), NoItinerary,
4588 !strconcat("vpst", "${Mk}"), "", "", []> {
4591 let Inst{31-23} = 0b111111100;
4592 let Inst{22} = Mk{3};
4593 let Inst{21-16} = 0b110001;
4594 let Inst{15-13} = Mk{2-0};
4595 let Inst{12-0} = 0b0111101001101;
4596 let Unpredictable{12} = 0b1;
4597 let Unpredictable{7} = 0b1;
4598 let Unpredictable{5} = 0b1;
4603 def MVE_VPSEL : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm), NoItinerary,
4604 "vpsel", "", "$Qd, $Qn, $Qm", vpred_n, "", []> {
4610 let Inst{25-23} = 0b100;
4611 let Inst{22} = Qd{3};
4612 let Inst{21-20} = 0b11;
4613 let Inst{19-17} = Qn{2-0};
4615 let Inst{15-13} = Qd{2-0};
4616 let Inst{12-9} = 0b0111;
4618 let Inst{7} = Qn{3};
4620 let Inst{5} = Qm{3};
4622 let Inst{3-1} = Qm{2-0};
4626 foreach suffix = ["s8", "s16", "s32", "u8", "u16", "u32",
4627 "i8", "i16", "i32", "f16", "f32"] in
4628 def : MVEInstAlias<"vpsel${vp}." # suffix # "\t$Qd, $Qn, $Qm",
4629 (MVE_VPSEL MQPR:$Qd, MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
4631 let Predicates = [HasMVEInt] in {
4632 def : Pat<(v16i8 (vselect (v16i1 VCCR:$pred), (v16i8 MQPR:$v1), (v16i8 MQPR:$v2))),
4633 (v16i8 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0, VCCR:$pred))>;
4634 def : Pat<(v8i16 (vselect (v8i1 VCCR:$pred), (v8i16 MQPR:$v1), (v8i16 MQPR:$v2))),
4635 (v8i16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0, VCCR:$pred))>;
4636 def : Pat<(v4i32 (vselect (v4i1 VCCR:$pred), (v4i32 MQPR:$v1), (v4i32 MQPR:$v2))),
4637 (v4i32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0, VCCR:$pred))>;
4639 def : Pat<(v8f16 (vselect (v8i1 VCCR:$pred), (v8f16 MQPR:$v1), (v8f16 MQPR:$v2))),
4640 (v8f16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0, VCCR:$pred))>;
4641 def : Pat<(v4f32 (vselect (v4i1 VCCR:$pred), (v4f32 MQPR:$v1), (v4f32 MQPR:$v2))),
4642 (v4f32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0, VCCR:$pred))>;
4644 def : Pat<(v16i8 (vselect (v16i8 MQPR:$pred), (v16i8 MQPR:$v1), (v16i8 MQPR:$v2))),
4645 (v16i8 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0,
4646 (MVE_VCMPi8 (v16i8 MQPR:$pred), (MVE_VMOVimmi8 0), 1)))>;
4647 def : Pat<(v8i16 (vselect (v8i16 MQPR:$pred), (v8i16 MQPR:$v1), (v8i16 MQPR:$v2))),
4648 (v8i16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0,
4649 (MVE_VCMPi16 (v8i16 MQPR:$pred), (MVE_VMOVimmi16 0), 1)))>;
4650 def : Pat<(v4i32 (vselect (v4i32 MQPR:$pred), (v4i32 MQPR:$v1), (v4i32 MQPR:$v2))),
4651 (v4i32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0,
4652 (MVE_VCMPi32 (v4i32 MQPR:$pred), (MVE_VMOVimmi32 0), 1)))>;
4654 def : Pat<(v8f16 (vselect (v8i16 MQPR:$pred), (v8f16 MQPR:$v1), (v8f16 MQPR:$v2))),
4655 (v8f16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0,
4656 (MVE_VCMPi16 (v8i16 MQPR:$pred), (MVE_VMOVimmi16 0), 1)))>;
4657 def : Pat<(v4f32 (vselect (v4i32 MQPR:$pred), (v4f32 MQPR:$v1), (v4f32 MQPR:$v2))),
4658 (v4f32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0,
4659 (MVE_VCMPi32 (v4i32 MQPR:$pred), (MVE_VMOVimmi32 0), 1)))>;
4662 def : Pat<(v16i8 (zext (v16i1 VCCR:$pred))),
4663 (v16i8 (MVE_VPSEL (MVE_VMOVimmi8 1), (MVE_VMOVimmi8 0), 0, VCCR:$pred))>;
4664 def : Pat<(v8i16 (zext (v8i1 VCCR:$pred))),
4665 (v8i16 (MVE_VPSEL (MVE_VMOVimmi16 1), (MVE_VMOVimmi16 0), 0, VCCR:$pred))>;
4666 def : Pat<(v4i32 (zext (v4i1 VCCR:$pred))),
4667 (v4i32 (MVE_VPSEL (MVE_VMOVimmi32 1), (MVE_VMOVimmi32 0), 0, VCCR:$pred))>;
4669 def : Pat<(v16i8 (sext (v16i1 VCCR:$pred))),
4670 (v16i8 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi8 0), 0, VCCR:$pred))>;
4671 def : Pat<(v8i16 (sext (v8i1 VCCR:$pred))),
4672 (v8i16 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi16 0), 0, VCCR:$pred))>;
4673 def : Pat<(v4i32 (sext (v4i1 VCCR:$pred))),
4674 (v4i32 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi32 0), 0, VCCR:$pred))>;
4676 def : Pat<(v16i8 (anyext (v16i1 VCCR:$pred))),
4677 (v16i8 (MVE_VPSEL (MVE_VMOVimmi8 1), (MVE_VMOVimmi8 0), 0, VCCR:$pred))>;
4678 def : Pat<(v8i16 (anyext (v8i1 VCCR:$pred))),
4679 (v8i16 (MVE_VPSEL (MVE_VMOVimmi16 1), (MVE_VMOVimmi16 0), 0, VCCR:$pred))>;
4680 def : Pat<(v4i32 (anyext (v4i1 VCCR:$pred))),
4681 (v4i32 (MVE_VPSEL (MVE_VMOVimmi32 1), (MVE_VMOVimmi32 0), 0, VCCR:$pred))>;
4683 def : Pat<(v16i1 (trunc (v16i8 MQPR:$v1))),
4684 (v16i1 (MVE_VCMPi32r (v16i8 MQPR:$v1), ZR, 1))>;
4685 def : Pat<(v8i1 (trunc (v8i16 MQPR:$v1))),
4686 (v8i1 (MVE_VCMPi32r (v8i16 MQPR:$v1), ZR, 1))>;
4687 def : Pat<(v4i1 (trunc (v4i32 MQPR:$v1))),
4688 (v4i1 (MVE_VCMPi32r (v4i32 MQPR:$v1), ZR, 1))>;
4691 let Predicates = [HasMVEFloat] in {
4693 // 112 is 1.0 in float
4694 def : Pat<(v4f32 (uint_to_fp (v4i1 VCCR:$pred))),
4695 (v4f32 (MVE_VPSEL (v4f32 (MVE_VMOVimmf32 112)), (v4f32 (MVE_VMOVimmi32 0)), 0, VCCR:$pred))>;
4696 // 2620 in 1.0 in half
4697 def : Pat<(v8f16 (uint_to_fp (v8i1 VCCR:$pred))),
4698 (v8f16 (MVE_VPSEL (v8f16 (MVE_VMOVimmi16 2620)), (v8f16 (MVE_VMOVimmi16 0)), 0, VCCR:$pred))>;
4699 // 240 is -1.0 in float
4700 def : Pat<(v4f32 (sint_to_fp (v4i1 VCCR:$pred))),
4701 (v4f32 (MVE_VPSEL (v4f32 (MVE_VMOVimmf32 240)), (v4f32 (MVE_VMOVimmi32 0)), 0, VCCR:$pred))>;
4702 // 2748 is -1.0 in half
4703 def : Pat<(v8f16 (sint_to_fp (v8i1 VCCR:$pred))),
4704 (v8f16 (MVE_VPSEL (v8f16 (MVE_VMOVimmi16 2748)), (v8f16 (MVE_VMOVimmi16 0)), 0, VCCR:$pred))>;
4706 def : Pat<(v4i1 (fp_to_uint (v4f32 MQPR:$v1))),
4707 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, 1))>;
4708 def : Pat<(v8i1 (fp_to_uint (v8f16 MQPR:$v1))),
4709 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), ZR, 1))>;
4710 def : Pat<(v4i1 (fp_to_sint (v4f32 MQPR:$v1))),
4711 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, 1))>;
4712 def : Pat<(v8i1 (fp_to_sint (v8f16 MQPR:$v1))),
4713 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), ZR, 1))>;
4716 def MVE_VPNOT : MVE_p<(outs VCCR:$P0), (ins VCCR:$P0_in), NoItinerary,
4717 "vpnot", "", "", vpred_n, "", []> {
4718 let Inst{31-0} = 0b11111110001100010000111101001101;
4719 let Unpredictable{19-17} = 0b111;
4720 let Unpredictable{12} = 0b1;
4721 let Unpredictable{7} = 0b1;
4722 let Unpredictable{5} = 0b1;
4724 let Constraints = "";
4725 let DecoderMethod = "DecodeMVEVPNOT";
4728 let Predicates = [HasMVEInt] in {
4729 def : Pat<(v4i1 (xor (v4i1 VCCR:$pred), (v4i1 (predicate_cast (i32 65535))))),
4730 (v4i1 (MVE_VPNOT (v4i1 VCCR:$pred)))>;
4731 def : Pat<(v8i1 (xor (v8i1 VCCR:$pred), (v8i1 (predicate_cast (i32 65535))))),
4732 (v8i1 (MVE_VPNOT (v8i1 VCCR:$pred)))>;
4733 def : Pat<(v16i1 (xor (v16i1 VCCR:$pred), (v16i1 (predicate_cast (i32 65535))))),
4734 (v16i1 (MVE_VPNOT (v16i1 VCCR:$pred)))>;
4738 class MVE_loltp_start<dag iops, string asm, string ops, bits<2> size>
4739 : t2LOL<(outs GPRlr:$LR), iops, asm, ops> {
4741 let Predicates = [HasMVEInt];
4743 let Inst{21-20} = size;
4744 let Inst{19-16} = Rn{3-0};
4748 class MVE_DLSTP<string asm, bits<2> size>
4749 : MVE_loltp_start<(ins rGPR:$Rn), asm, "$LR, $Rn", size> {
4751 let Inst{11-1} = 0b00000000000;
4752 let Unpredictable{10-1} = 0b1111111111;
4755 class MVE_WLSTP<string asm, bits<2> size>
4756 : MVE_loltp_start<(ins rGPR:$Rn, wlslabel_u11:$label),
4757 asm, "$LR, $Rn, $label", size> {
4760 let Inst{11} = label{0};
4761 let Inst{10-1} = label{10-1};
4764 def MVE_DLSTP_8 : MVE_DLSTP<"dlstp.8", 0b00>;
4765 def MVE_DLSTP_16 : MVE_DLSTP<"dlstp.16", 0b01>;
4766 def MVE_DLSTP_32 : MVE_DLSTP<"dlstp.32", 0b10>;
4767 def MVE_DLSTP_64 : MVE_DLSTP<"dlstp.64", 0b11>;
4769 def MVE_WLSTP_8 : MVE_WLSTP<"wlstp.8", 0b00>;
4770 def MVE_WLSTP_16 : MVE_WLSTP<"wlstp.16", 0b01>;
4771 def MVE_WLSTP_32 : MVE_WLSTP<"wlstp.32", 0b10>;
4772 def MVE_WLSTP_64 : MVE_WLSTP<"wlstp.64", 0b11>;
4774 class MVE_loltp_end<dag oops, dag iops, string asm, string ops>
4775 : t2LOL<oops, iops, asm, ops> {
4776 let Predicates = [HasMVEInt];
4777 let Inst{22-21} = 0b00;
4778 let Inst{19-16} = 0b1111;
4782 def MVE_LETP : MVE_loltp_end<(outs GPRlr:$LRout),
4783 (ins GPRlr:$LRin, lelabel_u11:$label),
4784 "letp", "$LRin, $label"> {
4788 let Inst{11} = label{0};
4789 let Inst{10-1} = label{10-1};
4792 def MVE_LCTP : MVE_loltp_end<(outs), (ins pred:$p), "lctp${p}", ""> {
4795 let Inst{11-1} = 0b00000000000;
4796 let Unpredictable{21-20} = 0b11;
4797 let Unpredictable{11-1} = 0b11111111111;
4801 //===----------------------------------------------------------------------===//
4803 //===----------------------------------------------------------------------===//
4805 class MVE_vector_store_typed<ValueType Ty, Instruction RegImmInst,
4806 PatFrag StoreKind, int shift>
4807 : Pat<(StoreKind (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr),
4808 (RegImmInst (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr)>;
4810 multiclass MVE_vector_store<Instruction RegImmInst, PatFrag StoreKind,
4812 def : MVE_vector_store_typed<v16i8, RegImmInst, StoreKind, shift>;
4813 def : MVE_vector_store_typed<v8i16, RegImmInst, StoreKind, shift>;
4814 def : MVE_vector_store_typed<v8f16, RegImmInst, StoreKind, shift>;
4815 def : MVE_vector_store_typed<v4i32, RegImmInst, StoreKind, shift>;
4816 def : MVE_vector_store_typed<v4f32, RegImmInst, StoreKind, shift>;
4817 def : MVE_vector_store_typed<v2i64, RegImmInst, StoreKind, shift>;
4818 def : MVE_vector_store_typed<v2f64, RegImmInst, StoreKind, shift>;
4821 class MVE_vector_load_typed<ValueType Ty, Instruction RegImmInst,
4822 PatFrag LoadKind, int shift>
4823 : Pat<(Ty (LoadKind t2addrmode_imm7<shift>:$addr)),
4824 (Ty (RegImmInst t2addrmode_imm7<shift>:$addr))>;
4826 multiclass MVE_vector_load<Instruction RegImmInst, PatFrag LoadKind,
4828 def : MVE_vector_load_typed<v16i8, RegImmInst, LoadKind, shift>;
4829 def : MVE_vector_load_typed<v8i16, RegImmInst, LoadKind, shift>;
4830 def : MVE_vector_load_typed<v8f16, RegImmInst, LoadKind, shift>;
4831 def : MVE_vector_load_typed<v4i32, RegImmInst, LoadKind, shift>;
4832 def : MVE_vector_load_typed<v4f32, RegImmInst, LoadKind, shift>;
4833 def : MVE_vector_load_typed<v2i64, RegImmInst, LoadKind, shift>;
4834 def : MVE_vector_load_typed<v2f64, RegImmInst, LoadKind, shift>;
4837 class MVE_vector_offset_store_typed<ValueType Ty, Instruction Opcode,
4838 PatFrag StoreKind, int shift>
4839 : Pat<(StoreKind (Ty MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<shift>:$addr),
4840 (Opcode MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<shift>:$addr)>;
4842 multiclass MVE_vector_offset_store<Instruction RegImmInst, PatFrag StoreKind,
4844 def : MVE_vector_offset_store_typed<v16i8, RegImmInst, StoreKind, shift>;
4845 def : MVE_vector_offset_store_typed<v8i16, RegImmInst, StoreKind, shift>;
4846 def : MVE_vector_offset_store_typed<v8f16, RegImmInst, StoreKind, shift>;
4847 def : MVE_vector_offset_store_typed<v4i32, RegImmInst, StoreKind, shift>;
4848 def : MVE_vector_offset_store_typed<v4f32, RegImmInst, StoreKind, shift>;
4849 def : MVE_vector_offset_store_typed<v2i64, RegImmInst, StoreKind, shift>;
4850 def : MVE_vector_offset_store_typed<v2f64, RegImmInst, StoreKind, shift>;
4853 def aligned32_pre_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
4854 (pre_store node:$val, node:$ptr, node:$offset), [{
4855 return cast<StoreSDNode>(N)->getAlignment() >= 4;
4857 def aligned32_post_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
4858 (post_store node:$val, node:$ptr, node:$offset), [{
4859 return cast<StoreSDNode>(N)->getAlignment() >= 4;
4861 def aligned16_pre_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
4862 (pre_store node:$val, node:$ptr, node:$offset), [{
4863 return cast<StoreSDNode>(N)->getAlignment() >= 2;
4865 def aligned16_post_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
4866 (post_store node:$val, node:$ptr, node:$offset), [{
4867 return cast<StoreSDNode>(N)->getAlignment() >= 2;
4870 let Predicates = [HasMVEInt, IsLE] in {
4872 defm : MVE_vector_store<MVE_VSTRBU8, byte_alignedstore, 0>;
4873 defm : MVE_vector_store<MVE_VSTRHU16, hword_alignedstore, 1>;
4874 defm : MVE_vector_store<MVE_VSTRWU32, alignedstore32, 2>;
4877 defm : MVE_vector_load<MVE_VLDRBU8, byte_alignedload, 0>;
4878 defm : MVE_vector_load<MVE_VLDRHU16, hword_alignedload, 1>;
4879 defm : MVE_vector_load<MVE_VLDRWU32, alignedload32, 2>;
4881 // Pre/post inc stores
4882 defm : MVE_vector_offset_store<MVE_VSTRBU8_pre, pre_store, 0>;
4883 defm : MVE_vector_offset_store<MVE_VSTRBU8_post, post_store, 0>;
4884 defm : MVE_vector_offset_store<MVE_VSTRHU16_pre, aligned16_pre_store, 1>;
4885 defm : MVE_vector_offset_store<MVE_VSTRHU16_post, aligned16_post_store, 1>;
4886 defm : MVE_vector_offset_store<MVE_VSTRWU32_pre, aligned32_pre_store, 2>;
4887 defm : MVE_vector_offset_store<MVE_VSTRWU32_post, aligned32_post_store, 2>;
4890 let Predicates = [HasMVEInt, IsBE] in {
4892 def : MVE_vector_store_typed<v16i8, MVE_VSTRBU8, store, 0>;
4893 def : MVE_vector_store_typed<v8i16, MVE_VSTRHU16, alignedstore16, 1>;
4894 def : MVE_vector_store_typed<v8f16, MVE_VSTRHU16, alignedstore16, 1>;
4895 def : MVE_vector_store_typed<v4i32, MVE_VSTRWU32, alignedstore32, 2>;
4896 def : MVE_vector_store_typed<v4f32, MVE_VSTRWU32, alignedstore32, 2>;
4899 def : MVE_vector_load_typed<v16i8, MVE_VLDRBU8, load, 0>;
4900 def : MVE_vector_load_typed<v8i16, MVE_VLDRHU16, alignedload16, 1>;
4901 def : MVE_vector_load_typed<v8f16, MVE_VLDRHU16, alignedload16, 1>;
4902 def : MVE_vector_load_typed<v4i32, MVE_VLDRWU32, alignedload32, 2>;
4903 def : MVE_vector_load_typed<v4f32, MVE_VLDRWU32, alignedload32, 2>;
4905 // Other unaligned loads/stores need to go though a VREV
4906 def : Pat<(v2f64 (load t2addrmode_imm7<0>:$addr)),
4907 (v2f64 (MVE_VREV64_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
4908 def : Pat<(v2i64 (load t2addrmode_imm7<0>:$addr)),
4909 (v2i64 (MVE_VREV64_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
4910 def : Pat<(v4i32 (load t2addrmode_imm7<0>:$addr)),
4911 (v4i32 (MVE_VREV32_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
4912 def : Pat<(v4f32 (load t2addrmode_imm7<0>:$addr)),
4913 (v4f32 (MVE_VREV32_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
4914 def : Pat<(v8i16 (load t2addrmode_imm7<0>:$addr)),
4915 (v8i16 (MVE_VREV16_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
4916 def : Pat<(v8f16 (load t2addrmode_imm7<0>:$addr)),
4917 (v8f16 (MVE_VREV16_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
4918 def : Pat<(store (v2f64 MQPR:$val), t2addrmode_imm7<0>:$addr),
4919 (MVE_VSTRBU8 (MVE_VREV64_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
4920 def : Pat<(store (v2i64 MQPR:$val), t2addrmode_imm7<0>:$addr),
4921 (MVE_VSTRBU8 (MVE_VREV64_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
4922 def : Pat<(store (v4i32 MQPR:$val), t2addrmode_imm7<0>:$addr),
4923 (MVE_VSTRBU8 (MVE_VREV32_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
4924 def : Pat<(store (v4f32 MQPR:$val), t2addrmode_imm7<0>:$addr),
4925 (MVE_VSTRBU8 (MVE_VREV32_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
4926 def : Pat<(store (v8i16 MQPR:$val), t2addrmode_imm7<0>:$addr),
4927 (MVE_VSTRBU8 (MVE_VREV16_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
4928 def : Pat<(store (v8f16 MQPR:$val), t2addrmode_imm7<0>:$addr),
4929 (MVE_VSTRBU8 (MVE_VREV16_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
4931 // Pre/Post inc stores
4932 def : MVE_vector_offset_store_typed<v16i8, MVE_VSTRBU8_pre, pre_store, 0>;
4933 def : MVE_vector_offset_store_typed<v16i8, MVE_VSTRBU8_post, post_store, 0>;
4934 def : MVE_vector_offset_store_typed<v8i16, MVE_VSTRHU16_pre, aligned16_pre_store, 1>;
4935 def : MVE_vector_offset_store_typed<v8i16, MVE_VSTRHU16_post, aligned16_post_store, 1>;
4936 def : MVE_vector_offset_store_typed<v8f16, MVE_VSTRHU16_pre, aligned16_pre_store, 1>;
4937 def : MVE_vector_offset_store_typed<v8f16, MVE_VSTRHU16_post, aligned16_post_store, 1>;
4938 def : MVE_vector_offset_store_typed<v4i32, MVE_VSTRWU32_pre, aligned32_pre_store, 2>;
4939 def : MVE_vector_offset_store_typed<v4i32, MVE_VSTRWU32_post, aligned32_post_store, 2>;
4940 def : MVE_vector_offset_store_typed<v4f32, MVE_VSTRWU32_pre, aligned32_pre_store, 2>;
4941 def : MVE_vector_offset_store_typed<v4f32, MVE_VSTRWU32_post, aligned32_post_store, 2>;
4944 let Predicates = [HasMVEInt] in {
4946 def : Pat<(v16i1 (load t2addrmode_imm7<2>:$addr)),
4947 (v16i1 (VLDR_P0_off t2addrmode_imm7<2>:$addr))>;
4948 def : Pat<(v8i1 (load t2addrmode_imm7<2>:$addr)),
4949 (v8i1 (VLDR_P0_off t2addrmode_imm7<2>:$addr))>;
4950 def : Pat<(v4i1 (load t2addrmode_imm7<2>:$addr)),
4951 (v4i1 (VLDR_P0_off t2addrmode_imm7<2>:$addr))>;
4954 def : Pat<(store (v4i1 VCCR:$val), t2addrmode_imm7<2>:$addr),
4955 (VSTR_P0_off VCCR:$val, t2addrmode_imm7<2>:$addr)>;
4956 def : Pat<(store (v8i1 VCCR:$val), t2addrmode_imm7<2>:$addr),
4957 (VSTR_P0_off VCCR:$val, t2addrmode_imm7<2>:$addr)>;
4958 def : Pat<(store (v16i1 VCCR:$val), t2addrmode_imm7<2>:$addr),
4959 (VSTR_P0_off VCCR:$val, t2addrmode_imm7<2>:$addr)>;
4963 // Widening/Narrowing Loads/Stores
4965 let MinAlignment = 2 in {
4966 def truncstorevi16_align2 : PatFrag<(ops node:$val, node:$ptr),
4967 (truncstorevi16 node:$val, node:$ptr)>;
4968 def post_truncstvi16_align2 : PatFrag<(ops node:$val, node:$base, node:$offset),
4969 (post_truncstvi16 node:$val, node:$base, node:$offset)>;
4970 def pre_truncstvi16_align2 : PatFrag<(ops node:$val, node:$base, node:$offset),
4971 (pre_truncstvi16 node:$val, node:$base, node:$offset)>;
4974 let Predicates = [HasMVEInt] in {
4975 def : Pat<(truncstorevi8 (v8i16 MQPR:$val), t2addrmode_imm7<0>:$addr),
4976 (MVE_VSTRB16 MQPR:$val, t2addrmode_imm7<0>:$addr)>;
4977 def : Pat<(truncstorevi8 (v4i32 MQPR:$val), t2addrmode_imm7<0>:$addr),
4978 (MVE_VSTRB32 MQPR:$val, t2addrmode_imm7<0>:$addr)>;
4979 def : Pat<(truncstorevi16_align2 (v4i32 MQPR:$val), t2addrmode_imm7<1>:$addr),
4980 (MVE_VSTRH32 MQPR:$val, t2addrmode_imm7<1>:$addr)>;
4982 def : Pat<(post_truncstvi8 (v8i16 MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<0>:$addr),
4983 (MVE_VSTRB16_post MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<0>:$addr)>;
4984 def : Pat<(post_truncstvi8 (v4i32 MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<0>:$addr),
4985 (MVE_VSTRB32_post MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<0>:$addr)>;
4986 def : Pat<(post_truncstvi16_align2 (v4i32 MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<1>:$addr),
4987 (MVE_VSTRH32_post MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<1>:$addr)>;
4989 def : Pat<(pre_truncstvi8 (v8i16 MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<0>:$addr),
4990 (MVE_VSTRB16_pre MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<0>:$addr)>;
4991 def : Pat<(pre_truncstvi8 (v4i32 MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<0>:$addr),
4992 (MVE_VSTRB32_pre MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<0>:$addr)>;
4993 def : Pat<(pre_truncstvi16_align2 (v4i32 MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<1>:$addr),
4994 (MVE_VSTRH32_pre MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<1>:$addr)>;
4998 let MinAlignment = 2 in {
4999 def extloadvi16_align2 : PatFrag<(ops node:$ptr), (extloadvi16 node:$ptr)>;
5000 def sextloadvi16_align2 : PatFrag<(ops node:$ptr), (sextloadvi16 node:$ptr)>;
5001 def zextloadvi16_align2 : PatFrag<(ops node:$ptr), (zextloadvi16 node:$ptr)>;
5004 multiclass MVEExtLoad<string DestLanes, string DestElemBits,
5005 string SrcElemBits, string SrcElemType,
5006 string Align, Operand am> {
5007 def _Any : Pat<(!cast<ValueType>("v" # DestLanes # "i" # DestElemBits)
5008 (!cast<PatFrag>("extloadvi" # SrcElemBits # Align) am:$addr)),
5009 (!cast<Instruction>("MVE_VLDR" # SrcElemType # "U" # DestElemBits)
5011 def _Z : Pat<(!cast<ValueType>("v" # DestLanes # "i" # DestElemBits)
5012 (!cast<PatFrag>("zextloadvi" # SrcElemBits # Align) am:$addr)),
5013 (!cast<Instruction>("MVE_VLDR" # SrcElemType # "U" # DestElemBits)
5015 def _S : Pat<(!cast<ValueType>("v" # DestLanes # "i" # DestElemBits)
5016 (!cast<PatFrag>("sextloadvi" # SrcElemBits # Align) am:$addr)),
5017 (!cast<Instruction>("MVE_VLDR" # SrcElemType # "S" # DestElemBits)
5021 let Predicates = [HasMVEInt] in {
5022 defm : MVEExtLoad<"4", "32", "8", "B", "", t2addrmode_imm7<0>>;
5023 defm : MVEExtLoad<"8", "16", "8", "B", "", t2addrmode_imm7<0>>;
5024 defm : MVEExtLoad<"4", "32", "16", "H", "_align2", t2addrmode_imm7<1>>;
5028 // Bit convert patterns
5030 let Predicates = [HasMVEInt] in {
5031 def : Pat<(v2f64 (bitconvert (v2i64 QPR:$src))), (v2f64 QPR:$src)>;
5032 def : Pat<(v2i64 (bitconvert (v2f64 QPR:$src))), (v2i64 QPR:$src)>;
5034 def : Pat<(v4i32 (bitconvert (v4f32 QPR:$src))), (v4i32 QPR:$src)>;
5035 def : Pat<(v4f32 (bitconvert (v4i32 QPR:$src))), (v4f32 QPR:$src)>;
5037 def : Pat<(v8i16 (bitconvert (v8f16 QPR:$src))), (v8i16 QPR:$src)>;
5038 def : Pat<(v8f16 (bitconvert (v8i16 QPR:$src))), (v8f16 QPR:$src)>;
5041 let Predicates = [IsLE,HasMVEInt] in {
5042 def : Pat<(v2f64 (bitconvert (v4f32 QPR:$src))), (v2f64 QPR:$src)>;
5043 def : Pat<(v2f64 (bitconvert (v4i32 QPR:$src))), (v2f64 QPR:$src)>;
5044 def : Pat<(v2f64 (bitconvert (v8f16 QPR:$src))), (v2f64 QPR:$src)>;
5045 def : Pat<(v2f64 (bitconvert (v8i16 QPR:$src))), (v2f64 QPR:$src)>;
5046 def : Pat<(v2f64 (bitconvert (v16i8 QPR:$src))), (v2f64 QPR:$src)>;
5048 def : Pat<(v2i64 (bitconvert (v4f32 QPR:$src))), (v2i64 QPR:$src)>;
5049 def : Pat<(v2i64 (bitconvert (v4i32 QPR:$src))), (v2i64 QPR:$src)>;
5050 def : Pat<(v2i64 (bitconvert (v8f16 QPR:$src))), (v2i64 QPR:$src)>;
5051 def : Pat<(v2i64 (bitconvert (v8i16 QPR:$src))), (v2i64 QPR:$src)>;
5052 def : Pat<(v2i64 (bitconvert (v16i8 QPR:$src))), (v2i64 QPR:$src)>;
5054 def : Pat<(v4f32 (bitconvert (v2f64 QPR:$src))), (v4f32 QPR:$src)>;
5055 def : Pat<(v4f32 (bitconvert (v2i64 QPR:$src))), (v4f32 QPR:$src)>;
5056 def : Pat<(v4f32 (bitconvert (v8f16 QPR:$src))), (v4f32 QPR:$src)>;
5057 def : Pat<(v4f32 (bitconvert (v8i16 QPR:$src))), (v4f32 QPR:$src)>;
5058 def : Pat<(v4f32 (bitconvert (v16i8 QPR:$src))), (v4f32 QPR:$src)>;
5060 def : Pat<(v4i32 (bitconvert (v2f64 QPR:$src))), (v4i32 QPR:$src)>;
5061 def : Pat<(v4i32 (bitconvert (v2i64 QPR:$src))), (v4i32 QPR:$src)>;
5062 def : Pat<(v4i32 (bitconvert (v8f16 QPR:$src))), (v4i32 QPR:$src)>;
5063 def : Pat<(v4i32 (bitconvert (v8i16 QPR:$src))), (v4i32 QPR:$src)>;
5064 def : Pat<(v4i32 (bitconvert (v16i8 QPR:$src))), (v4i32 QPR:$src)>;
5066 def : Pat<(v8f16 (bitconvert (v2f64 QPR:$src))), (v8f16 QPR:$src)>;
5067 def : Pat<(v8f16 (bitconvert (v2i64 QPR:$src))), (v8f16 QPR:$src)>;
5068 def : Pat<(v8f16 (bitconvert (v4f32 QPR:$src))), (v8f16 QPR:$src)>;
5069 def : Pat<(v8f16 (bitconvert (v4i32 QPR:$src))), (v8f16 QPR:$src)>;
5070 def : Pat<(v8f16 (bitconvert (v16i8 QPR:$src))), (v8f16 QPR:$src)>;
5072 def : Pat<(v8i16 (bitconvert (v2f64 QPR:$src))), (v8i16 QPR:$src)>;
5073 def : Pat<(v8i16 (bitconvert (v2i64 QPR:$src))), (v8i16 QPR:$src)>;
5074 def : Pat<(v8i16 (bitconvert (v4f32 QPR:$src))), (v8i16 QPR:$src)>;
5075 def : Pat<(v8i16 (bitconvert (v4i32 QPR:$src))), (v8i16 QPR:$src)>;
5076 def : Pat<(v8i16 (bitconvert (v16i8 QPR:$src))), (v8i16 QPR:$src)>;
5078 def : Pat<(v16i8 (bitconvert (v2f64 QPR:$src))), (v16i8 QPR:$src)>;
5079 def : Pat<(v16i8 (bitconvert (v2i64 QPR:$src))), (v16i8 QPR:$src)>;
5080 def : Pat<(v16i8 (bitconvert (v4f32 QPR:$src))), (v16i8 QPR:$src)>;
5081 def : Pat<(v16i8 (bitconvert (v4i32 QPR:$src))), (v16i8 QPR:$src)>;
5082 def : Pat<(v16i8 (bitconvert (v8f16 QPR:$src))), (v16i8 QPR:$src)>;
5083 def : Pat<(v16i8 (bitconvert (v8i16 QPR:$src))), (v16i8 QPR:$src)>;
5086 let Predicates = [IsBE,HasMVEInt] in {
5087 def : Pat<(v2f64 (bitconvert (v4f32 QPR:$src))), (v2f64 (MVE_VREV64_32 QPR:$src))>;
5088 def : Pat<(v2f64 (bitconvert (v4i32 QPR:$src))), (v2f64 (MVE_VREV64_32 QPR:$src))>;
5089 def : Pat<(v2f64 (bitconvert (v8f16 QPR:$src))), (v2f64 (MVE_VREV64_16 QPR:$src))>;
5090 def : Pat<(v2f64 (bitconvert (v8i16 QPR:$src))), (v2f64 (MVE_VREV64_16 QPR:$src))>;
5091 def : Pat<(v2f64 (bitconvert (v16i8 QPR:$src))), (v2f64 (MVE_VREV64_8 QPR:$src))>;
5093 def : Pat<(v2i64 (bitconvert (v4f32 QPR:$src))), (v2i64 (MVE_VREV64_32 QPR:$src))>;
5094 def : Pat<(v2i64 (bitconvert (v4i32 QPR:$src))), (v2i64 (MVE_VREV64_32 QPR:$src))>;
5095 def : Pat<(v2i64 (bitconvert (v8f16 QPR:$src))), (v2i64 (MVE_VREV64_16 QPR:$src))>;
5096 def : Pat<(v2i64 (bitconvert (v8i16 QPR:$src))), (v2i64 (MVE_VREV64_16 QPR:$src))>;
5097 def : Pat<(v2i64 (bitconvert (v16i8 QPR:$src))), (v2i64 (MVE_VREV64_8 QPR:$src))>;
5099 def : Pat<(v4f32 (bitconvert (v2f64 QPR:$src))), (v4f32 (MVE_VREV64_32 QPR:$src))>;
5100 def : Pat<(v4f32 (bitconvert (v2i64 QPR:$src))), (v4f32 (MVE_VREV64_32 QPR:$src))>;
5101 def : Pat<(v4f32 (bitconvert (v8f16 QPR:$src))), (v4f32 (MVE_VREV32_16 QPR:$src))>;
5102 def : Pat<(v4f32 (bitconvert (v8i16 QPR:$src))), (v4f32 (MVE_VREV32_16 QPR:$src))>;
5103 def : Pat<(v4f32 (bitconvert (v16i8 QPR:$src))), (v4f32 (MVE_VREV32_8 QPR:$src))>;
5105 def : Pat<(v4i32 (bitconvert (v2f64 QPR:$src))), (v4i32 (MVE_VREV64_32 QPR:$src))>;
5106 def : Pat<(v4i32 (bitconvert (v2i64 QPR:$src))), (v4i32 (MVE_VREV64_32 QPR:$src))>;
5107 def : Pat<(v4i32 (bitconvert (v8f16 QPR:$src))), (v4i32 (MVE_VREV32_16 QPR:$src))>;
5108 def : Pat<(v4i32 (bitconvert (v8i16 QPR:$src))), (v4i32 (MVE_VREV32_16 QPR:$src))>;
5109 def : Pat<(v4i32 (bitconvert (v16i8 QPR:$src))), (v4i32 (MVE_VREV32_8 QPR:$src))>;
5111 def : Pat<(v8f16 (bitconvert (v2f64 QPR:$src))), (v8f16 (MVE_VREV64_16 QPR:$src))>;
5112 def : Pat<(v8f16 (bitconvert (v2i64 QPR:$src))), (v8f16 (MVE_VREV64_16 QPR:$src))>;
5113 def : Pat<(v8f16 (bitconvert (v4f32 QPR:$src))), (v8f16 (MVE_VREV32_16 QPR:$src))>;
5114 def : Pat<(v8f16 (bitconvert (v4i32 QPR:$src))), (v8f16 (MVE_VREV32_16 QPR:$src))>;
5115 def : Pat<(v8f16 (bitconvert (v16i8 QPR:$src))), (v8f16 (MVE_VREV16_8 QPR:$src))>;
5117 def : Pat<(v8i16 (bitconvert (v2f64 QPR:$src))), (v8i16 (MVE_VREV64_16 QPR:$src))>;
5118 def : Pat<(v8i16 (bitconvert (v2i64 QPR:$src))), (v8i16 (MVE_VREV64_16 QPR:$src))>;
5119 def : Pat<(v8i16 (bitconvert (v4f32 QPR:$src))), (v8i16 (MVE_VREV32_16 QPR:$src))>;
5120 def : Pat<(v8i16 (bitconvert (v4i32 QPR:$src))), (v8i16 (MVE_VREV32_16 QPR:$src))>;
5121 def : Pat<(v8i16 (bitconvert (v16i8 QPR:$src))), (v8i16 (MVE_VREV16_8 QPR:$src))>;
5123 def : Pat<(v16i8 (bitconvert (v2f64 QPR:$src))), (v16i8 (MVE_VREV64_8 QPR:$src))>;
5124 def : Pat<(v16i8 (bitconvert (v2i64 QPR:$src))), (v16i8 (MVE_VREV64_8 QPR:$src))>;
5125 def : Pat<(v16i8 (bitconvert (v4f32 QPR:$src))), (v16i8 (MVE_VREV32_8 QPR:$src))>;
5126 def : Pat<(v16i8 (bitconvert (v4i32 QPR:$src))), (v16i8 (MVE_VREV32_8 QPR:$src))>;
5127 def : Pat<(v16i8 (bitconvert (v8f16 QPR:$src))), (v16i8 (MVE_VREV16_8 QPR:$src))>;
5128 def : Pat<(v16i8 (bitconvert (v8i16 QPR:$src))), (v16i8 (MVE_VREV16_8 QPR:$src))>;