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 // They are printed the same way as the imm8 version
226 let PrintMethod = "printT2AddrModeImm8OffsetOperand";
227 let ParserMatchClass =
228 !cast<AsmOperandClass>("t2am_imm7shift"#shift#"OffsetAsmOperand");
229 let EncoderMethod = "getT2ScaledImmOpValue<7,"#shift#">";
230 let DecoderMethod = "DecodeT2Imm7<"#shift#">";
233 // Operands for gather/scatter loads of the form [Rbase, Qoffsets]
234 class MemRegRQOffsetAsmOperand<int shift> : AsmOperandClass {
235 let Name = "MemRegRQS"#shift#"Offset";
236 let PredicateMethod = "isMemRegRQOffset<"#shift#">";
237 let RenderMethod = "addMemRegRQOffsetOperands";
240 def MemRegRQS0OffsetAsmOperand : MemRegRQOffsetAsmOperand<0>;
241 def MemRegRQS1OffsetAsmOperand : MemRegRQOffsetAsmOperand<1>;
242 def MemRegRQS2OffsetAsmOperand : MemRegRQOffsetAsmOperand<2>;
243 def MemRegRQS3OffsetAsmOperand : MemRegRQOffsetAsmOperand<3>;
245 // mve_addr_rq_shift := reg + vreg{ << UXTW #shift}
246 class mve_addr_rq_shift<int shift> : MemOperand {
247 let EncoderMethod = "getMveAddrModeRQOpValue";
248 let PrintMethod = "printMveAddrModeRQOperand<"#shift#">";
249 let ParserMatchClass =
250 !cast<AsmOperandClass>("MemRegRQS"#shift#"OffsetAsmOperand");
251 let DecoderMethod = "DecodeMveAddrModeRQ";
252 let MIOperandInfo = (ops GPRnopc:$base, MQPR:$offsreg);
255 class MemRegQOffsetAsmOperand<int shift> : AsmOperandClass {
256 let Name = "MemRegQS"#shift#"Offset";
257 let PredicateMethod = "isMemRegQOffset<"#shift#">";
258 let RenderMethod = "addMemImmOffsetOperands";
261 def MemRegQS2OffsetAsmOperand : MemRegQOffsetAsmOperand<2>;
262 def MemRegQS3OffsetAsmOperand : MemRegQOffsetAsmOperand<3>;
264 // mve_addr_q_shift := vreg {+ #imm7s2/4}
265 class mve_addr_q_shift<int shift> : MemOperand {
266 let EncoderMethod = "getMveAddrModeQOpValue<"#shift#">";
267 // Can be printed same way as other reg + imm operands
268 let PrintMethod = "printT2AddrModeImm8Operand<false>";
269 let ParserMatchClass =
270 !cast<AsmOperandClass>("MemRegQS"#shift#"OffsetAsmOperand");
271 let DecoderMethod = "DecodeMveAddrModeQ<"#shift#">";
272 let MIOperandInfo = (ops MQPR:$base, i32imm:$imm);
275 // --------- Start of base classes for the instructions themselves
277 class MVE_MI<dag oops, dag iops, InstrItinClass itin, string asm,
278 string ops, string cstr, list<dag> pattern>
279 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, !strconcat(asm, "\t", ops), cstr,
281 Requires<[HasMVEInt]> {
283 let DecoderNamespace = "MVE";
286 // MVE_p is used for most predicated instructions, to add the cluster
287 // of input operands that provides the VPT suffix (none, T or E) and
288 // the input predicate register.
289 class MVE_p<dag oops, dag iops, InstrItinClass itin, string iname,
290 string suffix, string ops, vpred_ops vpred, string cstr,
291 list<dag> pattern=[]>
292 : MVE_MI<oops, !con(iops, (ins vpred:$vp)), itin,
293 // If the instruction has a suffix, like vadd.f32, then the
294 // VPT predication suffix goes before the dot, so the full
295 // name has to be "vadd${vp}.f32".
296 !strconcat(iname, "${vp}",
297 !if(!eq(suffix, ""), "", !strconcat(".", suffix))),
298 ops, !strconcat(cstr, vpred.vpred_constraint), pattern> {
299 let Inst{31-29} = 0b111;
300 let Inst{27-26} = 0b11;
303 class MVE_f<dag oops, dag iops, InstrItinClass itin, string iname,
304 string suffix, string ops, vpred_ops vpred, string cstr,
305 list<dag> pattern=[]>
306 : MVE_p<oops, iops, itin, iname, suffix, ops, vpred, cstr, pattern> {
307 let Predicates = [HasMVEFloat];
310 class MVE_MI_with_pred<dag oops, dag iops, InstrItinClass itin, string asm,
311 string ops, string cstr, list<dag> pattern>
312 : Thumb2I<oops, iops, AddrModeNone, 4, itin, asm, !strconcat("\t", ops), cstr,
314 Requires<[HasV8_1MMainline, HasMVEInt]> {
316 let DecoderNamespace = "MVE";
319 class MVE_VMOV_lane_base<dag oops, dag iops, InstrItinClass itin, string asm,
320 string suffix, string ops, string cstr,
322 : Thumb2I<oops, iops, AddrModeNone, 4, itin, asm,
323 !if(!eq(suffix, ""), "", "." # suffix) # "\t" # ops,
325 Requires<[HasV8_1MMainline, HasMVEInt]> {
327 let DecoderNamespace = "MVE";
330 class MVE_ScalarShift<string iname, dag oops, dag iops, string asm, string cstr,
331 list<dag> pattern=[]>
332 : MVE_MI_with_pred<oops, iops, NoItinerary, iname, asm, cstr, pattern> {
333 let Inst{31-20} = 0b111010100101;
338 class MVE_ScalarShiftSingleReg<string iname, dag iops, string asm, string cstr,
339 list<dag> pattern=[]>
340 : MVE_ScalarShift<iname, (outs rGPR:$RdaDest), iops, asm, cstr, pattern> {
343 let Inst{19-16} = RdaDest{3-0};
346 class MVE_ScalarShiftSRegImm<string iname, bits<2> op5_4, list<dag> pattern=[]>
347 : MVE_ScalarShiftSingleReg<iname, (ins rGPR:$RdaSrc, long_shift:$imm),
348 "$RdaSrc, $imm", "$RdaDest = $RdaSrc", pattern> {
352 let Inst{14-12} = imm{4-2};
353 let Inst{11-8} = 0b1111;
354 let Inst{7-6} = imm{1-0};
355 let Inst{5-4} = op5_4{1-0};
356 let Inst{3-0} = 0b1111;
359 def MVE_SQSHL : MVE_ScalarShiftSRegImm<"sqshl", 0b11>;
360 def MVE_SRSHR : MVE_ScalarShiftSRegImm<"srshr", 0b10>;
361 def MVE_UQSHL : MVE_ScalarShiftSRegImm<"uqshl", 0b00>;
362 def MVE_URSHR : MVE_ScalarShiftSRegImm<"urshr", 0b01>;
364 class MVE_ScalarShiftSRegReg<string iname, bits<2> op5_4, list<dag> pattern=[]>
365 : MVE_ScalarShiftSingleReg<iname, (ins rGPR:$RdaSrc, rGPR:$Rm),
366 "$RdaSrc, $Rm", "$RdaDest = $RdaSrc", pattern> {
369 let Inst{15-12} = Rm{3-0};
370 let Inst{11-8} = 0b1111;
371 let Inst{7-6} = 0b00;
372 let Inst{5-4} = op5_4{1-0};
373 let Inst{3-0} = 0b1101;
376 def MVE_SQRSHR : MVE_ScalarShiftSRegReg<"sqrshr", 0b10>;
377 def MVE_UQRSHL : MVE_ScalarShiftSRegReg<"uqrshl", 0b00>;
379 class MVE_ScalarShiftDoubleReg<string iname, dag iops, string asm,
380 string cstr, list<dag> pattern=[]>
381 : MVE_ScalarShift<iname, (outs tGPREven:$RdaLo, tGPROdd:$RdaHi),
382 iops, asm, cstr, pattern> {
386 let Inst{19-17} = RdaLo{3-1};
387 let Inst{11-9} = RdaHi{3-1};
390 class MVE_ScalarShiftDRegImm<string iname, bits<2> op5_4, bit op16,
391 list<dag> pattern=[]>
392 : MVE_ScalarShiftDoubleReg<
393 iname, (ins tGPREven:$RdaLo_src, tGPROdd:$RdaHi_src, long_shift:$imm),
394 "$RdaLo, $RdaHi, $imm", "$RdaLo = $RdaLo_src,$RdaHi = $RdaHi_src",
400 let Inst{14-12} = imm{4-2};
401 let Inst{7-6} = imm{1-0};
402 let Inst{5-4} = op5_4{1-0};
403 let Inst{3-0} = 0b1111;
406 class MVE_ScalarShiftDRegRegBase<string iname, dag iops, string asm,
407 bit op5, bit op16, list<dag> pattern=[]>
408 : MVE_ScalarShiftDoubleReg<
409 iname, iops, asm, "@earlyclobber $RdaHi,@earlyclobber $RdaLo,"
410 "$RdaLo = $RdaLo_src,$RdaHi = $RdaHi_src",
415 let Inst{15-12} = Rm{3-0};
419 let Inst{3-0} = 0b1101;
421 // Custom decoder method because of the following overlapping encodings:
424 // SQRSHRL and SQRSHR
425 // UQRSHLL and UQRSHL
426 let DecoderMethod = "DecodeMVEOverlappingLongShift";
429 class MVE_ScalarShiftDRegReg<string iname, bit op5, list<dag> pattern=[]>
430 : MVE_ScalarShiftDRegRegBase<
431 iname, (ins tGPREven:$RdaLo_src, tGPROdd:$RdaHi_src, rGPR:$Rm),
432 "$RdaLo, $RdaHi, $Rm", op5, 0b0, pattern> {
437 class MVE_ScalarShiftDRegRegWithSat<string iname, bit op5, list<dag> pattern=[]>
438 : MVE_ScalarShiftDRegRegBase<
439 iname, (ins tGPREven:$RdaLo_src, tGPROdd:$RdaHi_src, rGPR:$Rm, saturateop:$sat),
440 "$RdaLo, $RdaHi, $sat, $Rm", op5, 0b1, pattern> {
446 def MVE_ASRLr : MVE_ScalarShiftDRegReg<"asrl", 0b1, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi,
447 (ARMasrl tGPREven:$RdaLo_src,
448 tGPROdd:$RdaHi_src, rGPR:$Rm))]>;
449 def MVE_ASRLi : MVE_ScalarShiftDRegImm<"asrl", 0b10, ?, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi,
450 (ARMasrl tGPREven:$RdaLo_src,
451 tGPROdd:$RdaHi_src, (i32 imm:$imm)))]>;
452 def MVE_LSLLr : MVE_ScalarShiftDRegReg<"lsll", 0b0, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi,
453 (ARMlsll tGPREven:$RdaLo_src,
454 tGPROdd:$RdaHi_src, rGPR:$Rm))]>;
455 def MVE_LSLLi : MVE_ScalarShiftDRegImm<"lsll", 0b00, ?, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi,
456 (ARMlsll tGPREven:$RdaLo_src,
457 tGPROdd:$RdaHi_src, (i32 imm:$imm)))]>;
458 def MVE_LSRL : MVE_ScalarShiftDRegImm<"lsrl", 0b01, ?, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi,
459 (ARMlsrl tGPREven:$RdaLo_src,
460 tGPROdd:$RdaHi_src, (i32 imm:$imm)))]>;
462 def MVE_SQRSHRL : MVE_ScalarShiftDRegRegWithSat<"sqrshrl", 0b1>;
463 def MVE_SQSHLL : MVE_ScalarShiftDRegImm<"sqshll", 0b11, 0b1>;
464 def MVE_SRSHRL : MVE_ScalarShiftDRegImm<"srshrl", 0b10, 0b1>;
466 def MVE_UQRSHLL : MVE_ScalarShiftDRegRegWithSat<"uqrshll", 0b0>;
467 def MVE_UQSHLL : MVE_ScalarShiftDRegImm<"uqshll", 0b00, 0b1>;
468 def MVE_URSHRL : MVE_ScalarShiftDRegImm<"urshrl", 0b01, 0b1>;
470 // start of mve_rDest instructions
472 class MVE_rDest<dag oops, dag iops, InstrItinClass itin,
473 string iname, string suffix,
474 string ops, string cstr, list<dag> pattern=[]>
475 // Always use vpred_n and not vpred_r: with the output register being
476 // a GPR and not a vector register, there can't be any question of
477 // what to put in its inactive lanes.
478 : MVE_p<oops, iops, itin, iname, suffix, ops, vpred_n, cstr, pattern> {
480 let Inst{25-23} = 0b101;
481 let Inst{11-9} = 0b111;
485 class MVE_VABAV<string suffix, bit U, bits<2> size, list<dag> pattern=[]>
486 : MVE_rDest<(outs rGPR:$Rda), (ins rGPR:$Rda_src, MQPR:$Qn, MQPR:$Qm),
487 NoItinerary, "vabav", suffix, "$Rda, $Qn, $Qm", "$Rda = $Rda_src",
495 let Inst{21-20} = size{1-0};
496 let Inst{19-17} = Qn{2-0};
498 let Inst{15-12} = Rda{3-0};
503 let Inst{3-1} = Qm{2-0};
507 def MVE_VABAVs8 : MVE_VABAV<"s8", 0b0, 0b00>;
508 def MVE_VABAVs16 : MVE_VABAV<"s16", 0b0, 0b01>;
509 def MVE_VABAVs32 : MVE_VABAV<"s32", 0b0, 0b10>;
510 def MVE_VABAVu8 : MVE_VABAV<"u8", 0b1, 0b00>;
511 def MVE_VABAVu16 : MVE_VABAV<"u16", 0b1, 0b01>;
512 def MVE_VABAVu32 : MVE_VABAV<"u32", 0b1, 0b10>;
514 class MVE_VADDV<string iname, string suffix, dag iops, string cstr,
515 bit A, bit U, bits<2> size, list<dag> pattern=[]>
516 : MVE_rDest<(outs tGPREven:$Rda), iops, NoItinerary,
517 iname, suffix, "$Rda, $Qm", cstr, pattern> {
522 let Inst{22-20} = 0b111;
523 let Inst{19-18} = size{1-0};
524 let Inst{17-16} = 0b01;
525 let Inst{15-13} = Rda{3-1};
527 let Inst{8-6} = 0b100;
529 let Inst{3-1} = Qm{2-0};
533 multiclass MVE_VADDV_A<string suffix, bit U, bits<2> size,
534 list<dag> pattern=[]> {
535 def acc : MVE_VADDV<"vaddva", suffix,
536 (ins tGPREven:$Rda_src, MQPR:$Qm), "$Rda = $Rda_src",
537 0b1, U, size, pattern>;
538 def no_acc : MVE_VADDV<"vaddv", suffix,
540 0b0, U, size, pattern>;
543 defm MVE_VADDVs8 : MVE_VADDV_A<"s8", 0b0, 0b00>;
544 defm MVE_VADDVs16 : MVE_VADDV_A<"s16", 0b0, 0b01>;
545 defm MVE_VADDVs32 : MVE_VADDV_A<"s32", 0b0, 0b10>;
546 defm MVE_VADDVu8 : MVE_VADDV_A<"u8", 0b1, 0b00>;
547 defm MVE_VADDVu16 : MVE_VADDV_A<"u16", 0b1, 0b01>;
548 defm MVE_VADDVu32 : MVE_VADDV_A<"u32", 0b1, 0b10>;
550 class MVE_VADDLV<string iname, string suffix, dag iops, string cstr,
551 bit A, bit U, list<dag> pattern=[]>
552 : MVE_rDest<(outs tGPREven:$RdaLo, tGPROdd:$RdaHi), iops, NoItinerary, iname,
553 suffix, "$RdaLo, $RdaHi, $Qm", cstr, pattern> {
559 let Inst{22-20} = RdaHi{3-1};
560 let Inst{19-18} = 0b10;
561 let Inst{17-16} = 0b01;
562 let Inst{15-13} = RdaLo{3-1};
564 let Inst{8-6} = 0b100;
566 let Inst{3-1} = Qm{2-0};
570 multiclass MVE_VADDLV_A<string suffix, bit U, list<dag> pattern=[]> {
571 def acc : MVE_VADDLV<"vaddlva", suffix,
572 (ins tGPREven:$RdaLo_src, tGPROdd:$RdaHi_src, MQPR:$Qm),
573 "$RdaLo = $RdaLo_src,$RdaHi = $RdaHi_src",
575 def no_acc : MVE_VADDLV<"vaddlv", suffix,
581 defm MVE_VADDLVs32 : MVE_VADDLV_A<"s32", 0b0>;
582 defm MVE_VADDLVu32 : MVE_VADDLV_A<"u32", 0b1>;
584 class MVE_VMINMAXNMV<string iname, string suffix, bit sz,
585 bit bit_17, bit bit_7, list<dag> pattern=[]>
586 : MVE_rDest<(outs rGPR:$RdaDest), (ins rGPR:$RdaSrc, MQPR:$Qm),
587 NoItinerary, iname, suffix, "$RdaSrc, $Qm",
588 "$RdaDest = $RdaSrc", pattern> {
593 let Inst{22-20} = 0b110;
594 let Inst{19-18} = 0b11;
595 let Inst{17} = bit_17;
597 let Inst{15-12} = RdaDest{3-0};
600 let Inst{6-5} = 0b00;
601 let Inst{3-1} = Qm{2-0};
604 let Predicates = [HasMVEFloat];
607 multiclass MVE_VMINMAXNMV_fty<string iname, bit bit_7, list<dag> pattern=[]> {
608 def f32 : MVE_VMINMAXNMV<iname, "f32", 0b0, 0b1, bit_7, pattern>;
609 def f16 : MVE_VMINMAXNMV<iname, "f16", 0b1, 0b1, bit_7, pattern>;
612 defm MVE_VMINNMV : MVE_VMINMAXNMV_fty<"vminnmv", 0b1>;
613 defm MVE_VMAXNMV : MVE_VMINMAXNMV_fty<"vmaxnmv", 0b0>;
615 multiclass MVE_VMINMAXNMAV_fty<string iname, bit bit_7, list<dag> pattern=[]> {
616 def f32 : MVE_VMINMAXNMV<iname, "f32", 0b0, 0b0, bit_7, pattern>;
617 def f16 : MVE_VMINMAXNMV<iname, "f16", 0b1, 0b0, bit_7, pattern>;
620 defm MVE_VMINNMAV : MVE_VMINMAXNMAV_fty<"vminnmav", 0b1>;
621 defm MVE_VMAXNMAV : MVE_VMINMAXNMAV_fty<"vmaxnmav", 0b0>;
623 class MVE_VMINMAXV<string iname, string suffix, bit U, bits<2> size,
624 bit bit_17, bit bit_7, list<dag> pattern=[]>
625 : MVE_rDest<(outs rGPR:$RdaDest), (ins rGPR:$RdaSrc, MQPR:$Qm), NoItinerary,
626 iname, suffix, "$RdaSrc, $Qm", "$RdaDest = $RdaSrc", pattern> {
631 let Inst{22-20} = 0b110;
632 let Inst{19-18} = size{1-0};
633 let Inst{17} = bit_17;
635 let Inst{15-12} = RdaDest{3-0};
638 let Inst{6-5} = 0b00;
639 let Inst{3-1} = Qm{2-0};
643 multiclass MVE_VMINMAXV_ty<string iname, bit bit_7, list<dag> pattern=[]> {
644 def s8 : MVE_VMINMAXV<iname, "s8", 0b0, 0b00, 0b1, bit_7>;
645 def s16 : MVE_VMINMAXV<iname, "s16", 0b0, 0b01, 0b1, bit_7>;
646 def s32 : MVE_VMINMAXV<iname, "s32", 0b0, 0b10, 0b1, bit_7>;
647 def u8 : MVE_VMINMAXV<iname, "u8", 0b1, 0b00, 0b1, bit_7>;
648 def u16 : MVE_VMINMAXV<iname, "u16", 0b1, 0b01, 0b1, bit_7>;
649 def u32 : MVE_VMINMAXV<iname, "u32", 0b1, 0b10, 0b1, bit_7>;
652 defm MVE_VMINV : MVE_VMINMAXV_ty<"vminv", 0b1>;
653 defm MVE_VMAXV : MVE_VMINMAXV_ty<"vmaxv", 0b0>;
655 multiclass MVE_VMINMAXAV_ty<string iname, bit bit_7, list<dag> pattern=[]> {
656 def s8 : MVE_VMINMAXV<iname, "s8", 0b0, 0b00, 0b0, bit_7>;
657 def s16 : MVE_VMINMAXV<iname, "s16", 0b0, 0b01, 0b0, bit_7>;
658 def s32 : MVE_VMINMAXV<iname, "s32", 0b0, 0b10, 0b0, bit_7>;
661 defm MVE_VMINAV : MVE_VMINMAXAV_ty<"vminav", 0b1>;
662 defm MVE_VMAXAV : MVE_VMINMAXAV_ty<"vmaxav", 0b0>;
664 class MVE_VMLAMLSDAV<string iname, string suffix, dag iops, string cstr,
665 bit sz, bit bit_28, bit A, bit X, bit bit_8, bit bit_0,
666 list<dag> pattern=[]>
667 : MVE_rDest<(outs tGPREven:$RdaDest), iops, NoItinerary, iname, suffix,
668 "$RdaDest, $Qn, $Qm", cstr, pattern> {
673 let Inst{28} = bit_28;
674 let Inst{22-20} = 0b111;
675 let Inst{19-17} = Qn{2-0};
677 let Inst{15-13} = RdaDest{3-1};
680 let Inst{7-6} = 0b00;
682 let Inst{3-1} = Qm{2-0};
686 multiclass MVE_VMLAMLSDAV_X<string iname, string suffix, dag iops, string cstr,
687 bit sz, bit bit_28, bit A, bit bit_8, bit bit_0,
688 list<dag> pattern=[]> {
689 def _noexch : MVE_VMLAMLSDAV<iname, suffix, iops, cstr, sz,
690 bit_28, A, 0b0, bit_8, bit_0, pattern>;
691 def _exch : MVE_VMLAMLSDAV<iname # "x", suffix, iops, cstr, sz,
692 bit_28, A, 0b1, bit_8, bit_0, pattern>;
695 multiclass MVE_VMLAMLSDAV_XA<string iname, string suffix, bit sz, bit bit_28,
696 bit bit_8, bit bit_0, list<dag> pattern=[]> {
697 defm _noacc : MVE_VMLAMLSDAV_X<iname, suffix, (ins MQPR:$Qn, MQPR:$Qm), "",
698 sz, bit_28, 0b0, bit_8, bit_0, pattern>;
699 defm _acc : MVE_VMLAMLSDAV_X<iname # "a", suffix,
700 (ins tGPREven:$RdaSrc, MQPR:$Qn, MQPR:$Qm),
701 "$RdaDest = $RdaSrc",
702 sz, bit_28, 0b1, bit_8, bit_0, pattern>;
705 multiclass MVE_VMLADAV_multi<string suffix, bit sz, bit U, bit bit_8,
706 list<dag> pattern=[]> {
707 defm "" : MVE_VMLAMLSDAV_XA<"vmladav", suffix, sz, U, bit_8, 0b0, pattern>;
710 defm MVE_VMLADAVs16 : MVE_VMLADAV_multi<"s16", 0b0, 0b0, 0b0>;
711 defm MVE_VMLADAVs32 : MVE_VMLADAV_multi<"s32", 0b1, 0b0, 0b0>;
712 defm MVE_VMLADAVu16 : MVE_VMLADAV_multi<"u16", 0b0, 0b1, 0b0>;
713 defm MVE_VMLADAVu32 : MVE_VMLADAV_multi<"u32", 0b1, 0b1, 0b0>;
715 defm MVE_VMLADAVs8 : MVE_VMLADAV_multi<"s8", 0b0, 0b0, 0b1>;
716 defm MVE_VMLADAVu8 : MVE_VMLADAV_multi<"u8", 0b0, 0b1, 0b1>;
718 // vmlav aliases vmladav
719 foreach acc = ["_acc", "_noacc"] in {
720 foreach suffix = ["s8", "s16", "s32", "u8", "u16", "u32"] in {
721 def : MVEInstAlias<!strconcat("vmlav", !if(!eq(acc, "_acc"), "a", ""),
722 "${vp}.", suffix, "\t$RdaDest, $Qn, $Qm"),
723 (!cast<Instruction>("MVE_VMLADAV"#suffix#acc#"_noexch")
724 tGPREven:$RdaDest, MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
728 multiclass MVE_VMLSDAV_multi<string suffix, bit sz, bit bit_28,
729 list<dag> pattern=[]> {
730 defm "" : MVE_VMLAMLSDAV_XA<"vmlsdav", suffix, sz, bit_28, 0b0, 0b1, pattern>;
733 defm MVE_VMLSDAVs8 : MVE_VMLSDAV_multi<"s8", 0, 0b1>;
734 defm MVE_VMLSDAVs16 : MVE_VMLSDAV_multi<"s16", 0, 0b0>;
735 defm MVE_VMLSDAVs32 : MVE_VMLSDAV_multi<"s32", 1, 0b0>;
737 // Base class for VMLALDAV and VMLSLDAV, VRMLALDAVH, VRMLSLDAVH
738 class MVE_VMLALDAVBase<string iname, string suffix, dag iops, string cstr,
739 bit sz, bit bit_28, bit A, bit X, bit bit_8, bit bit_0,
740 list<dag> pattern=[]>
741 : MVE_rDest<(outs tGPREven:$RdaLoDest, tGPROdd:$RdaHiDest), iops, NoItinerary,
742 iname, suffix, "$RdaLoDest, $RdaHiDest, $Qn, $Qm", cstr, pattern> {
748 let Inst{28} = bit_28;
749 let Inst{22-20} = RdaHiDest{3-1};
750 let Inst{19-17} = Qn{2-0};
752 let Inst{15-13} = RdaLoDest{3-1};
755 let Inst{7-6} = 0b00;
757 let Inst{3-1} = Qm{2-0};
761 multiclass MVE_VMLALDAVBase_X<string iname, string suffix, dag iops,
762 string cstr, bit sz, bit bit_28, bit A,
763 bit bit_8, bit bit_0, list<dag> pattern=[]> {
764 def _noexch : MVE_VMLALDAVBase<iname, suffix, iops, cstr, sz,
765 bit_28, A, 0b0, bit_8, bit_0, pattern>;
766 def _exch : MVE_VMLALDAVBase<iname # "x", suffix, iops, cstr, sz,
767 bit_28, A, 0b1, bit_8, bit_0, pattern>;
770 multiclass MVE_VMLALDAVBase_XA<string iname, string suffix, bit sz, bit bit_28,
771 bit bit_8, bit bit_0, list<dag> pattern=[]> {
772 defm _noacc : MVE_VMLALDAVBase_X<
773 iname, suffix, (ins MQPR:$Qn, MQPR:$Qm), "",
774 sz, bit_28, 0b0, bit_8, bit_0, pattern>;
775 defm _acc : MVE_VMLALDAVBase_X<
776 iname # "a", suffix, (ins tGPREven:$RdaLoSrc, tGPROdd:$RdaHiSrc,
778 "$RdaLoDest = $RdaLoSrc,$RdaHiDest = $RdaHiSrc",
779 sz, bit_28, 0b1, bit_8, bit_0, pattern>;
782 multiclass MVE_VRMLALDAVH_multi<string suffix, bit U, list<dag> pattern=[]> {
783 defm "" : MVE_VMLALDAVBase_XA<
784 "vrmlaldavh", suffix, 0b0, U, 0b1, 0b0, pattern>;
787 defm MVE_VRMLALDAVHs32 : MVE_VRMLALDAVH_multi<"s32", 0>;
788 defm MVE_VRMLALDAVHu32 : MVE_VRMLALDAVH_multi<"u32", 1>;
790 // vrmlalvh aliases for vrmlaldavh
791 def : MVEInstAlias<"vrmlalvh${vp}.s32\t$RdaLo, $RdaHi, $Qn, $Qm",
792 (MVE_VRMLALDAVHs32_noacc_noexch
793 tGPREven:$RdaLo, tGPROdd:$RdaHi,
794 MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
795 def : MVEInstAlias<"vrmlalvha${vp}.s32\t$RdaLo, $RdaHi, $Qn, $Qm",
796 (MVE_VRMLALDAVHs32_acc_noexch
797 tGPREven:$RdaLo, tGPROdd:$RdaHi,
798 MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
799 def : MVEInstAlias<"vrmlalvh${vp}.u32\t$RdaLo, $RdaHi, $Qn, $Qm",
800 (MVE_VRMLALDAVHu32_noacc_noexch
801 tGPREven:$RdaLo, tGPROdd:$RdaHi,
802 MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
803 def : MVEInstAlias<"vrmlalvha${vp}.u32\t$RdaLo, $RdaHi, $Qn, $Qm",
804 (MVE_VRMLALDAVHu32_acc_noexch
805 tGPREven:$RdaLo, tGPROdd:$RdaHi,
806 MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
808 multiclass MVE_VMLALDAV_multi<string suffix, bit sz, bit U,
809 list<dag> pattern=[]> {
810 defm "" : MVE_VMLALDAVBase_XA<"vmlaldav", suffix, sz, U, 0b0, 0b0, pattern>;
813 defm MVE_VMLALDAVs16 : MVE_VMLALDAV_multi<"s16", 0b0, 0b0>;
814 defm MVE_VMLALDAVs32 : MVE_VMLALDAV_multi<"s32", 0b1, 0b0>;
815 defm MVE_VMLALDAVu16 : MVE_VMLALDAV_multi<"u16", 0b0, 0b1>;
816 defm MVE_VMLALDAVu32 : MVE_VMLALDAV_multi<"u32", 0b1, 0b1>;
818 // vmlalv aliases vmlaldav
819 foreach acc = ["_acc", "_noacc"] in {
820 foreach suffix = ["s16", "s32", "u16", "u32"] in {
821 def : MVEInstAlias<!strconcat("vmlalv", !if(!eq(acc, "_acc"), "a", ""),
822 "${vp}.", suffix, "\t$RdaLoDest, $RdaHiDest, $Qn, $Qm"),
823 (!cast<Instruction>("MVE_VMLALDAV"#suffix#acc#"_noexch")
824 tGPREven:$RdaLoDest, tGPROdd:$RdaHiDest,
825 MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
829 multiclass MVE_VMLSLDAV_multi<string iname, string suffix, bit sz,
830 bit bit_28, list<dag> pattern=[]> {
831 defm "" : MVE_VMLALDAVBase_XA<iname, suffix, sz, bit_28, 0b0, 0b1, pattern>;
834 defm MVE_VMLSLDAVs16 : MVE_VMLSLDAV_multi<"vmlsldav", "s16", 0b0, 0b0>;
835 defm MVE_VMLSLDAVs32 : MVE_VMLSLDAV_multi<"vmlsldav", "s32", 0b1, 0b0>;
836 defm MVE_VRMLSLDAVHs32 : MVE_VMLSLDAV_multi<"vrmlsldavh", "s32", 0b0, 0b1>;
838 // end of mve_rDest instructions
840 // start of mve_comp instructions
842 class MVE_comp<InstrItinClass itin, string iname, string suffix,
843 string cstr, list<dag> pattern=[]>
844 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm), itin, iname, suffix,
845 "$Qd, $Qn, $Qm", vpred_r, cstr, pattern> {
850 let Inst{22} = Qd{3};
851 let Inst{19-17} = Qn{2-0};
853 let Inst{15-13} = Qd{2-0};
855 let Inst{10-9} = 0b11;
858 let Inst{3-1} = Qm{2-0};
862 class MVE_VMINMAXNM<string iname, string suffix, bit sz, bit bit_21,
863 list<dag> pattern=[]>
864 : MVE_comp<NoItinerary, iname, suffix, "", pattern> {
867 let Inst{25-24} = 0b11;
869 let Inst{21} = bit_21;
876 let Predicates = [HasMVEFloat];
879 def MVE_VMAXNMf32 : MVE_VMINMAXNM<"vmaxnm", "f32", 0b0, 0b0>;
880 def MVE_VMAXNMf16 : MVE_VMINMAXNM<"vmaxnm", "f16", 0b1, 0b0>;
882 let Predicates = [HasMVEFloat] in {
883 def : Pat<(v4f32 (fmaxnum (v4f32 MQPR:$val1), (v4f32 MQPR:$val2))),
884 (v4f32 (MVE_VMAXNMf32 (v4f32 MQPR:$val1), (v4f32 MQPR:$val2)))>;
885 def : Pat<(v8f16 (fmaxnum (v8f16 MQPR:$val1), (v8f16 MQPR:$val2))),
886 (v8f16 (MVE_VMAXNMf16 (v8f16 MQPR:$val1), (v8f16 MQPR:$val2)))>;
889 def MVE_VMINNMf32 : MVE_VMINMAXNM<"vminnm", "f32", 0b0, 0b1>;
890 def MVE_VMINNMf16 : MVE_VMINMAXNM<"vminnm", "f16", 0b1, 0b1>;
892 let Predicates = [HasMVEFloat] in {
893 def : Pat<(v4f32 (fminnum (v4f32 MQPR:$val1), (v4f32 MQPR:$val2))),
894 (v4f32 (MVE_VMINNMf32 (v4f32 MQPR:$val1), (v4f32 MQPR:$val2)))>;
895 def : Pat<(v8f16 (fminnum (v8f16 MQPR:$val1), (v8f16 MQPR:$val2))),
896 (v8f16 (MVE_VMINNMf16 (v8f16 MQPR:$val1), (v8f16 MQPR:$val2)))>;
900 class MVE_VMINMAX<string iname, string suffix, bit U, bits<2> size,
901 bit bit_4, list<dag> pattern=[]>
902 : MVE_comp<NoItinerary, iname, suffix, "", pattern> {
905 let Inst{25-24} = 0b11;
907 let Inst{21-20} = size{1-0};
914 multiclass MVE_VMINMAX_all_sizes<string iname, bit bit_4> {
915 def s8 : MVE_VMINMAX<iname, "s8", 0b0, 0b00, bit_4>;
916 def s16 : MVE_VMINMAX<iname, "s16", 0b0, 0b01, bit_4>;
917 def s32 : MVE_VMINMAX<iname, "s32", 0b0, 0b10, bit_4>;
918 def u8 : MVE_VMINMAX<iname, "u8", 0b1, 0b00, bit_4>;
919 def u16 : MVE_VMINMAX<iname, "u16", 0b1, 0b01, bit_4>;
920 def u32 : MVE_VMINMAX<iname, "u32", 0b1, 0b10, bit_4>;
923 defm MVE_VMAX : MVE_VMINMAX_all_sizes<"vmax", 0b0>;
924 defm MVE_VMIN : MVE_VMINMAX_all_sizes<"vmin", 0b1>;
926 let Predicates = [HasMVEInt] in {
927 def : Pat<(v16i8 (smin (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
928 (v16i8 (MVE_VMINs8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
929 def : Pat<(v8i16 (smin (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
930 (v8i16 (MVE_VMINs16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
931 def : Pat<(v4i32 (smin (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
932 (v4i32 (MVE_VMINs32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
934 def : Pat<(v16i8 (smax (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
935 (v16i8 (MVE_VMAXs8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
936 def : Pat<(v8i16 (smax (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
937 (v8i16 (MVE_VMAXs16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
938 def : Pat<(v4i32 (smax (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
939 (v4i32 (MVE_VMAXs32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
941 def : Pat<(v16i8 (umin (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
942 (v16i8 (MVE_VMINu8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
943 def : Pat<(v8i16 (umin (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
944 (v8i16 (MVE_VMINu16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
945 def : Pat<(v4i32 (umin (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
946 (v4i32 (MVE_VMINu32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
948 def : Pat<(v16i8 (umax (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
949 (v16i8 (MVE_VMAXu8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
950 def : Pat<(v8i16 (umax (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
951 (v8i16 (MVE_VMAXu16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
952 def : Pat<(v4i32 (umax (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
953 (v4i32 (MVE_VMAXu32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
956 // end of mve_comp instructions
958 // start of mve_bit instructions
960 class MVE_bit_arith<dag oops, dag iops, string iname, string suffix,
961 string ops, string cstr, list<dag> pattern=[]>
962 : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred_r, cstr, pattern> {
966 let Inst{22} = Qd{3};
967 let Inst{15-13} = Qd{2-0};
969 let Inst{3-1} = Qm{2-0};
972 def MVE_VBIC : MVE_bit_arith<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm),
973 "vbic", "", "$Qd, $Qn, $Qm", ""> {
977 let Inst{25-23} = 0b110;
978 let Inst{21-20} = 0b01;
979 let Inst{19-17} = Qn{2-0};
981 let Inst{12-8} = 0b00001;
988 class MVE_VREV<string iname, string suffix, bits<2> size, bits<2> bit_8_7>
989 : MVE_bit_arith<(outs MQPR:$Qd), (ins MQPR:$Qm), iname,
990 suffix, "$Qd, $Qm", ""> {
993 let Inst{25-23} = 0b111;
994 let Inst{21-20} = 0b11;
995 let Inst{19-18} = size;
996 let Inst{17-16} = 0b00;
997 let Inst{12-9} = 0b0000;
998 let Inst{8-7} = bit_8_7;
1004 def MVE_VREV64_8 : MVE_VREV<"vrev64", "8", 0b00, 0b00>;
1005 def MVE_VREV64_16 : MVE_VREV<"vrev64", "16", 0b01, 0b00>;
1006 def MVE_VREV64_32 : MVE_VREV<"vrev64", "32", 0b10, 0b00>;
1008 def MVE_VREV32_8 : MVE_VREV<"vrev32", "8", 0b00, 0b01>;
1009 def MVE_VREV32_16 : MVE_VREV<"vrev32", "16", 0b01, 0b01>;
1011 def MVE_VREV16_8 : MVE_VREV<"vrev16", "8", 0b00, 0b10>;
1013 let Predicates = [HasMVEInt] in {
1014 def : Pat<(v4i32 (ARMvrev64 (v4i32 MQPR:$src))),
1015 (v4i32 (MVE_VREV64_32 (v4i32 MQPR:$src)))>;
1016 def : Pat<(v8i16 (ARMvrev64 (v8i16 MQPR:$src))),
1017 (v8i16 (MVE_VREV64_16 (v8i16 MQPR:$src)))>;
1018 def : Pat<(v16i8 (ARMvrev64 (v16i8 MQPR:$src))),
1019 (v16i8 (MVE_VREV64_8 (v16i8 MQPR:$src)))>;
1021 def : Pat<(v8i16 (ARMvrev32 (v8i16 MQPR:$src))),
1022 (v8i16 (MVE_VREV32_16 (v8i16 MQPR:$src)))>;
1023 def : Pat<(v16i8 (ARMvrev32 (v16i8 MQPR:$src))),
1024 (v16i8 (MVE_VREV32_8 (v16i8 MQPR:$src)))>;
1026 def : Pat<(v16i8 (ARMvrev16 (v16i8 MQPR:$src))),
1027 (v16i8 (MVE_VREV16_8 (v16i8 MQPR:$src)))>;
1029 def : Pat<(v4f32 (ARMvrev64 (v4f32 MQPR:$src))),
1030 (v4f32 (MVE_VREV64_32 (v4f32 MQPR:$src)))>;
1031 def : Pat<(v8f16 (ARMvrev64 (v8f16 MQPR:$src))),
1032 (v8f16 (MVE_VREV64_16 (v8f16 MQPR:$src)))>;
1033 def : Pat<(v8f16 (ARMvrev32 (v8f16 MQPR:$src))),
1034 (v8f16 (MVE_VREV32_16 (v8f16 MQPR:$src)))>;
1037 def MVE_VMVN : MVE_bit_arith<(outs MQPR:$Qd), (ins MQPR:$Qm),
1038 "vmvn", "", "$Qd, $Qm", ""> {
1040 let Inst{25-23} = 0b111;
1041 let Inst{21-16} = 0b110000;
1042 let Inst{12-6} = 0b0010111;
1047 let Predicates = [HasMVEInt] in {
1048 def : Pat<(v16i8 (vnotq (v16i8 MQPR:$val1))),
1049 (v16i8 (MVE_VMVN (v16i8 MQPR:$val1)))>;
1050 def : Pat<(v8i16 (vnotq (v8i16 MQPR:$val1))),
1051 (v8i16 (MVE_VMVN (v8i16 MQPR:$val1)))>;
1052 def : Pat<(v4i32 (vnotq (v4i32 MQPR:$val1))),
1053 (v4i32 (MVE_VMVN (v4i32 MQPR:$val1)))>;
1054 def : Pat<(v2i64 (vnotq (v2i64 MQPR:$val1))),
1055 (v2i64 (MVE_VMVN (v2i64 MQPR:$val1)))>;
1058 class MVE_bit_ops<string iname, bits<2> bit_21_20, bit bit_28>
1059 : MVE_bit_arith<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm),
1060 iname, "", "$Qd, $Qn, $Qm", ""> {
1063 let Inst{28} = bit_28;
1064 let Inst{25-23} = 0b110;
1065 let Inst{21-20} = bit_21_20;
1066 let Inst{19-17} = Qn{2-0};
1068 let Inst{12-8} = 0b00001;
1069 let Inst{7} = Qn{3};
1075 def MVE_VEOR : MVE_bit_ops<"veor", 0b00, 0b1>;
1076 def MVE_VORN : MVE_bit_ops<"vorn", 0b11, 0b0>;
1077 def MVE_VORR : MVE_bit_ops<"vorr", 0b10, 0b0>;
1078 def MVE_VAND : MVE_bit_ops<"vand", 0b00, 0b0>;
1080 // add ignored suffixes as aliases
1082 foreach s=["s8", "s16", "s32", "u8", "u16", "u32", "i8", "i16", "i32", "f16", "f32"] in {
1083 def : MVEInstAlias<"vbic${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc",
1084 (MVE_VBIC MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>;
1085 def : MVEInstAlias<"veor${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc",
1086 (MVE_VEOR MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>;
1087 def : MVEInstAlias<"vorn${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc",
1088 (MVE_VORN MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>;
1089 def : MVEInstAlias<"vorr${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc",
1090 (MVE_VORR MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>;
1091 def : MVEInstAlias<"vand${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc",
1092 (MVE_VAND MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>;
1095 let Predicates = [HasMVEInt] in {
1096 def : Pat<(v16i8 (and (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
1097 (v16i8 (MVE_VAND (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1098 def : Pat<(v8i16 (and (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
1099 (v8i16 (MVE_VAND (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1100 def : Pat<(v4i32 (and (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
1101 (v4i32 (MVE_VAND (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
1102 def : Pat<(v2i64 (and (v2i64 MQPR:$val1), (v2i64 MQPR:$val2))),
1103 (v2i64 (MVE_VAND (v2i64 MQPR:$val1), (v2i64 MQPR:$val2)))>;
1105 def : Pat<(v16i8 (or (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
1106 (v16i8 (MVE_VORR (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1107 def : Pat<(v8i16 (or (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
1108 (v8i16 (MVE_VORR (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1109 def : Pat<(v4i32 (or (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
1110 (v4i32 (MVE_VORR (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
1111 def : Pat<(v2i64 (or (v2i64 MQPR:$val1), (v2i64 MQPR:$val2))),
1112 (v2i64 (MVE_VORR (v2i64 MQPR:$val1), (v2i64 MQPR:$val2)))>;
1114 def : Pat<(v16i8 (xor (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
1115 (v16i8 (MVE_VEOR (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1116 def : Pat<(v8i16 (xor (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
1117 (v8i16 (MVE_VEOR (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1118 def : Pat<(v4i32 (xor (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
1119 (v4i32 (MVE_VEOR (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
1120 def : Pat<(v2i64 (xor (v2i64 MQPR:$val1), (v2i64 MQPR:$val2))),
1121 (v2i64 (MVE_VEOR (v2i64 MQPR:$val1), (v2i64 MQPR:$val2)))>;
1123 def : Pat<(v16i8 (and (v16i8 MQPR:$val1), (vnotq MQPR:$val2))),
1124 (v16i8 (MVE_VBIC (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1125 def : Pat<(v8i16 (and (v8i16 MQPR:$val1), (vnotq MQPR:$val2))),
1126 (v8i16 (MVE_VBIC (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1127 def : Pat<(v4i32 (and (v4i32 MQPR:$val1), (vnotq MQPR:$val2))),
1128 (v4i32 (MVE_VBIC (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
1129 def : Pat<(v2i64 (and (v2i64 MQPR:$val1), (vnotq MQPR:$val2))),
1130 (v2i64 (MVE_VBIC (v2i64 MQPR:$val1), (v2i64 MQPR:$val2)))>;
1132 def : Pat<(v16i8 (or (v16i8 MQPR:$val1), (vnotq MQPR:$val2))),
1133 (v16i8 (MVE_VORN (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1134 def : Pat<(v8i16 (or (v8i16 MQPR:$val1), (vnotq MQPR:$val2))),
1135 (v8i16 (MVE_VORN (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1136 def : Pat<(v4i32 (or (v4i32 MQPR:$val1), (vnotq MQPR:$val2))),
1137 (v4i32 (MVE_VORN (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
1138 def : Pat<(v2i64 (or (v2i64 MQPR:$val1), (vnotq MQPR:$val2))),
1139 (v2i64 (MVE_VORN (v2i64 MQPR:$val1), (v2i64 MQPR:$val2)))>;
1142 class MVE_bit_cmode<string iname, string suffix, bits<4> cmode, dag inOps>
1143 : MVE_p<(outs MQPR:$Qd), inOps, NoItinerary,
1144 iname, suffix, "$Qd, $imm", vpred_n, "$Qd = $Qd_src"> {
1148 let Inst{28} = imm{7};
1149 let Inst{27-23} = 0b11111;
1150 let Inst{22} = Qd{3};
1151 let Inst{21-19} = 0b000;
1152 let Inst{18-16} = imm{6-4};
1153 let Inst{15-13} = Qd{2-0};
1155 let Inst{11-8} = cmode;
1156 let Inst{7-6} = 0b01;
1158 let Inst{3-0} = imm{3-0};
1161 class MVE_VORR<string suffix, bits<4> cmode, ExpandImm imm_type>
1162 : MVE_bit_cmode<"vorr", suffix, cmode, (ins MQPR:$Qd_src, imm_type:$imm)> {
1166 def MVE_VORRIZ0v4i32 : MVE_VORR<"i32", 0b0001, expzero00>;
1167 def MVE_VORRIZ0v8i16 : MVE_VORR<"i16", 0b1001, expzero00>;
1168 def MVE_VORRIZ8v4i32 : MVE_VORR<"i32", 0b0011, expzero08>;
1169 def MVE_VORRIZ8v8i16 : MVE_VORR<"i16", 0b1011, expzero08>;
1170 def MVE_VORRIZ16v4i32 : MVE_VORR<"i32", 0b0101, expzero16>;
1171 def MVE_VORRIZ24v4i32 : MVE_VORR<"i32", 0b0111, expzero24>;
1173 def MVE_VORNIZ0v4i32 : MVEAsmPseudo<"vorn${vp}.i32\t$Qd, $imm",
1174 (ins MQPR:$Qd_src, expzero00inv32:$imm, vpred_n:$vp), (outs MQPR:$Qd)>;
1175 def MVE_VORNIZ0v8i16 : MVEAsmPseudo<"vorn${vp}.i16\t$Qd, $imm",
1176 (ins MQPR:$Qd_src, expzero00inv16:$imm, vpred_n:$vp), (outs MQPR:$Qd)>;
1177 def MVE_VORNIZ8v4i32 : MVEAsmPseudo<"vorn${vp}.i32\t$Qd, $imm",
1178 (ins MQPR:$Qd_src, expzero08inv32:$imm, vpred_n:$vp), (outs MQPR:$Qd)>;
1179 def MVE_VORNIZ8v8i16 : MVEAsmPseudo<"vorn${vp}.i16\t$Qd, $imm",
1180 (ins MQPR:$Qd_src, expzero08inv16:$imm, vpred_n:$vp), (outs MQPR:$Qd)>;
1181 def MVE_VORNIZ16v4i32 : MVEAsmPseudo<"vorn${vp}.i32\t$Qd, $imm",
1182 (ins MQPR:$Qd_src, expzero16inv32:$imm, vpred_n:$vp), (outs MQPR:$Qd)>;
1183 def MVE_VORNIZ24v4i32 : MVEAsmPseudo<"vorn${vp}.i32\t$Qd, $imm",
1184 (ins MQPR:$Qd_src, expzero24inv32:$imm, vpred_n:$vp), (outs MQPR:$Qd)>;
1186 def MVE_VMOV : MVEInstAlias<"vmov${vp}\t$Qd, $Qm",
1187 (MVE_VORR MQPR:$Qd, MQPR:$Qm, MQPR:$Qm, vpred_r:$vp)>;
1189 class MVE_VBIC<string suffix, bits<4> cmode, ExpandImm imm_type>
1190 : MVE_bit_cmode<"vbic", suffix, cmode, (ins MQPR:$Qd_src, imm_type:$imm)> {
1194 def MVE_VBICIZ0v4i32 : MVE_VBIC<"i32", 0b0001, expzero00>;
1195 def MVE_VBICIZ0v8i16 : MVE_VBIC<"i16", 0b1001, expzero00>;
1196 def MVE_VBICIZ8v4i32 : MVE_VBIC<"i32", 0b0011, expzero08>;
1197 def MVE_VBICIZ8v8i16 : MVE_VBIC<"i16", 0b1011, expzero08>;
1198 def MVE_VBICIZ16v4i32 : MVE_VBIC<"i32", 0b0101, expzero16>;
1199 def MVE_VBICIZ24v4i32 : MVE_VBIC<"i32", 0b0111, expzero24>;
1201 def MVE_VANDIZ0v4i32 : MVEAsmPseudo<"vand${vp}.i32\t$Qda, $imm",
1202 (ins MQPR:$Qda_src, expzero00inv32:$imm, vpred_n:$vp), (outs MQPR:$Qda)>;
1203 def MVE_VANDIZ0v8i16 : MVEAsmPseudo<"vand${vp}.i16\t$Qda, $imm",
1204 (ins MQPR:$Qda_src, expzero00inv16:$imm, vpred_n:$vp), (outs MQPR:$Qda)>;
1205 def MVE_VANDIZ8v4i32 : MVEAsmPseudo<"vand${vp}.i32\t$Qda, $imm",
1206 (ins MQPR:$Qda_src, expzero08inv32:$imm, vpred_n:$vp), (outs MQPR:$Qda)>;
1207 def MVE_VANDIZ8v8i16 : MVEAsmPseudo<"vand${vp}.i16\t$Qda, $imm",
1208 (ins MQPR:$Qda_src, expzero08inv16:$imm, vpred_n:$vp), (outs MQPR:$Qda)>;
1209 def MVE_VANDIZ16v4i32 : MVEAsmPseudo<"vand${vp}.i32\t$Qda, $imm",
1210 (ins MQPR:$Qda_src, expzero16inv32:$imm, vpred_n:$vp), (outs MQPR:$Qda)>;
1211 def MVE_VANDIZ24v4i32 : MVEAsmPseudo<"vand${vp}.i32\t$Qda, $imm",
1212 (ins MQPR:$Qda_src, expzero24inv32:$imm, vpred_n:$vp), (outs MQPR:$Qda)>;
1214 class MVE_VMOV_lane_direction {
1221 def MVE_VMOV_from_lane : MVE_VMOV_lane_direction {
1223 let oops = (outs rGPR:$Rt);
1224 let iops = (ins MQPR:$Qd);
1225 let ops = "$Rt, $Qd$Idx";
1228 def MVE_VMOV_to_lane : MVE_VMOV_lane_direction {
1230 let oops = (outs MQPR:$Qd);
1231 let iops = (ins MQPR:$Qd_src, rGPR:$Rt);
1232 let ops = "$Qd$Idx, $Rt";
1233 let cstr = "$Qd = $Qd_src";
1236 class MVE_VMOV_lane<string suffix, bit U, dag indexop,
1237 MVE_VMOV_lane_direction dir>
1238 : MVE_VMOV_lane_base<dir.oops, !con(dir.iops, indexop), NoItinerary,
1239 "vmov", suffix, dir.ops, dir.cstr, []> {
1243 let Inst{31-24} = 0b11101110;
1245 let Inst{20} = dir.bit_20;
1246 let Inst{19-17} = Qd{2-0};
1247 let Inst{15-12} = Rt{3-0};
1248 let Inst{11-8} = 0b1011;
1249 let Inst{7} = Qd{3};
1250 let Inst{4-0} = 0b10000;
1253 class MVE_VMOV_lane_32<MVE_VMOV_lane_direction dir>
1254 : MVE_VMOV_lane<"32", 0b0, (ins MVEVectorIndex<4>:$Idx), dir> {
1257 let Inst{6-5} = 0b00;
1258 let Inst{16} = Idx{1};
1259 let Inst{21} = Idx{0};
1261 let Predicates = [HasFPRegsV8_1M];
1264 class MVE_VMOV_lane_16<string suffix, bit U, MVE_VMOV_lane_direction dir>
1265 : MVE_VMOV_lane<suffix, U, (ins MVEVectorIndex<8>:$Idx), dir> {
1269 let Inst{16} = Idx{2};
1270 let Inst{21} = Idx{1};
1271 let Inst{6} = Idx{0};
1274 class MVE_VMOV_lane_8<string suffix, bit U, MVE_VMOV_lane_direction dir>
1275 : MVE_VMOV_lane<suffix, U, (ins MVEVectorIndex<16>:$Idx), dir> {
1278 let Inst{16} = Idx{3};
1279 let Inst{21} = Idx{2};
1280 let Inst{6} = Idx{1};
1281 let Inst{5} = Idx{0};
1284 def MVE_VMOV_from_lane_32 : MVE_VMOV_lane_32< MVE_VMOV_from_lane>;
1285 def MVE_VMOV_to_lane_32 : MVE_VMOV_lane_32< MVE_VMOV_to_lane>;
1286 def MVE_VMOV_from_lane_s16 : MVE_VMOV_lane_16<"s16", 0b0, MVE_VMOV_from_lane>;
1287 def MVE_VMOV_from_lane_u16 : MVE_VMOV_lane_16<"u16", 0b1, MVE_VMOV_from_lane>;
1288 def MVE_VMOV_to_lane_16 : MVE_VMOV_lane_16< "16", 0b0, MVE_VMOV_to_lane>;
1289 def MVE_VMOV_from_lane_s8 : MVE_VMOV_lane_8 < "s8", 0b0, MVE_VMOV_from_lane>;
1290 def MVE_VMOV_from_lane_u8 : MVE_VMOV_lane_8 < "u8", 0b1, MVE_VMOV_from_lane>;
1291 def MVE_VMOV_to_lane_8 : MVE_VMOV_lane_8 < "8", 0b0, MVE_VMOV_to_lane>;
1293 let Predicates = [HasMVEInt] in {
1294 def : Pat<(extractelt (v2f64 MQPR:$src), imm:$lane),
1295 (f64 (EXTRACT_SUBREG MQPR:$src, (DSubReg_f64_reg imm:$lane)))>;
1296 def : Pat<(insertelt (v2f64 MQPR:$src1), DPR:$src2, imm:$lane),
1297 (INSERT_SUBREG (v2f64 (COPY_TO_REGCLASS MQPR:$src1, MQPR)), DPR:$src2, (DSubReg_f64_reg imm:$lane))>;
1299 def : Pat<(extractelt (v4i32 MQPR:$src), imm:$lane),
1301 (i32 (EXTRACT_SUBREG MQPR:$src, (SSubReg_f32_reg imm:$lane))), rGPR)>;
1302 def : Pat<(insertelt (v4i32 MQPR:$src1), rGPR:$src2, imm:$lane),
1303 (MVE_VMOV_to_lane_32 MQPR:$src1, rGPR:$src2, imm:$lane)>;
1305 def : Pat<(vector_insert (v16i8 MQPR:$src1), rGPR:$src2, imm:$lane),
1306 (MVE_VMOV_to_lane_8 MQPR:$src1, rGPR:$src2, imm:$lane)>;
1307 def : Pat<(vector_insert (v8i16 MQPR:$src1), rGPR:$src2, imm:$lane),
1308 (MVE_VMOV_to_lane_16 MQPR:$src1, rGPR:$src2, imm:$lane)>;
1310 def : Pat<(ARMvgetlanes (v16i8 MQPR:$src), imm:$lane),
1311 (MVE_VMOV_from_lane_s8 MQPR:$src, imm:$lane)>;
1312 def : Pat<(ARMvgetlanes (v8i16 MQPR:$src), imm:$lane),
1313 (MVE_VMOV_from_lane_s16 MQPR:$src, imm:$lane)>;
1314 def : Pat<(ARMvgetlaneu (v16i8 MQPR:$src), imm:$lane),
1315 (MVE_VMOV_from_lane_u8 MQPR:$src, imm:$lane)>;
1316 def : Pat<(ARMvgetlaneu (v8i16 MQPR:$src), imm:$lane),
1317 (MVE_VMOV_from_lane_u16 MQPR:$src, imm:$lane)>;
1319 def : Pat<(v16i8 (scalar_to_vector GPR:$src)),
1320 (MVE_VMOV_to_lane_8 (v16i8 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
1321 def : Pat<(v8i16 (scalar_to_vector GPR:$src)),
1322 (MVE_VMOV_to_lane_16 (v8i16 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
1323 def : Pat<(v4i32 (scalar_to_vector GPR:$src)),
1324 (MVE_VMOV_to_lane_32 (v4i32 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
1326 // Floating point patterns, still enabled under HasMVEInt
1327 def : Pat<(extractelt (v4f32 MQPR:$src), imm:$lane),
1328 (COPY_TO_REGCLASS (f32 (EXTRACT_SUBREG MQPR:$src, (SSubReg_f32_reg imm:$lane))), SPR)>;
1329 def : Pat<(insertelt (v4f32 MQPR:$src1), (f32 SPR:$src2), imm:$lane),
1330 (INSERT_SUBREG (v4f32 (COPY_TO_REGCLASS MQPR:$src1, MQPR)), SPR:$src2, (SSubReg_f32_reg imm:$lane))>;
1332 def : Pat<(insertelt (v8f16 MQPR:$src1), HPR:$src2, imm:$lane),
1333 (MVE_VMOV_to_lane_16 MQPR:$src1, (COPY_TO_REGCLASS HPR:$src2, rGPR), imm:$lane)>;
1334 def : Pat<(extractelt (v8f16 MQPR:$src), imm:$lane),
1335 (COPY_TO_REGCLASS (MVE_VMOV_from_lane_u16 MQPR:$src, imm:$lane), HPR)>;
1337 def : Pat<(v4f32 (scalar_to_vector SPR:$src)),
1338 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), SPR:$src, ssub_0)>;
1339 def : Pat<(v4f32 (scalar_to_vector GPR:$src)),
1340 (MVE_VMOV_to_lane_32 (v4f32 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
1341 def : Pat<(v8f16 (scalar_to_vector HPR:$src)),
1342 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), HPR:$src, ssub_0)>;
1343 def : Pat<(v8f16 (scalar_to_vector GPR:$src)),
1344 (MVE_VMOV_to_lane_16 (v8f16 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
1347 // end of mve_bit instructions
1349 // start of MVE Integer instructions
1351 class MVE_int<string iname, string suffix, bits<2> size, list<dag> pattern=[]>
1352 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm), NoItinerary,
1353 iname, suffix, "$Qd, $Qn, $Qm", vpred_r, "", pattern> {
1358 let Inst{22} = Qd{3};
1359 let Inst{21-20} = size;
1360 let Inst{19-17} = Qn{2-0};
1361 let Inst{15-13} = Qd{2-0};
1362 let Inst{7} = Qn{3};
1364 let Inst{5} = Qm{3};
1365 let Inst{3-1} = Qm{2-0};
1368 class MVE_VMULt1<string suffix, bits<2> size, list<dag> pattern=[]>
1369 : MVE_int<"vmul", suffix, size, pattern> {
1372 let Inst{25-23} = 0b110;
1374 let Inst{12-8} = 0b01001;
1379 def MVE_VMULt1i8 : MVE_VMULt1<"i8", 0b00>;
1380 def MVE_VMULt1i16 : MVE_VMULt1<"i16", 0b01>;
1381 def MVE_VMULt1i32 : MVE_VMULt1<"i32", 0b10>;
1383 let Predicates = [HasMVEInt] in {
1384 def : Pat<(v16i8 (mul (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
1385 (v16i8 (MVE_VMULt1i8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1386 def : Pat<(v8i16 (mul (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
1387 (v8i16 (MVE_VMULt1i16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1388 def : Pat<(v4i32 (mul (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
1389 (v4i32 (MVE_VMULt1i32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
1392 class MVE_VQxDMULH<string iname, string suffix, bits<2> size, bit rounding,
1393 list<dag> pattern=[]>
1394 : MVE_int<iname, suffix, size, pattern> {
1396 let Inst{28} = rounding;
1397 let Inst{25-23} = 0b110;
1399 let Inst{12-8} = 0b01011;
1404 class MVE_VQDMULH<string suffix, bits<2> size, list<dag> pattern=[]>
1405 : MVE_VQxDMULH<"vqdmulh", suffix, size, 0b0, pattern>;
1406 class MVE_VQRDMULH<string suffix, bits<2> size, list<dag> pattern=[]>
1407 : MVE_VQxDMULH<"vqrdmulh", suffix, size, 0b1, pattern>;
1409 def MVE_VQDMULHi8 : MVE_VQDMULH<"s8", 0b00>;
1410 def MVE_VQDMULHi16 : MVE_VQDMULH<"s16", 0b01>;
1411 def MVE_VQDMULHi32 : MVE_VQDMULH<"s32", 0b10>;
1413 def MVE_VQRDMULHi8 : MVE_VQRDMULH<"s8", 0b00>;
1414 def MVE_VQRDMULHi16 : MVE_VQRDMULH<"s16", 0b01>;
1415 def MVE_VQRDMULHi32 : MVE_VQRDMULH<"s32", 0b10>;
1417 class MVE_VADDSUB<string iname, string suffix, bits<2> size, bit subtract,
1418 list<dag> pattern=[]>
1419 : MVE_int<iname, suffix, size, pattern> {
1421 let Inst{28} = subtract;
1422 let Inst{25-23} = 0b110;
1424 let Inst{12-8} = 0b01000;
1429 class MVE_VADD<string suffix, bits<2> size, list<dag> pattern=[]>
1430 : MVE_VADDSUB<"vadd", suffix, size, 0b0, pattern>;
1431 class MVE_VSUB<string suffix, bits<2> size, list<dag> pattern=[]>
1432 : MVE_VADDSUB<"vsub", suffix, size, 0b1, pattern>;
1434 def MVE_VADDi8 : MVE_VADD<"i8", 0b00>;
1435 def MVE_VADDi16 : MVE_VADD<"i16", 0b01>;
1436 def MVE_VADDi32 : MVE_VADD<"i32", 0b10>;
1438 let Predicates = [HasMVEInt] in {
1439 def : Pat<(v16i8 (add (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
1440 (v16i8 (MVE_VADDi8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1441 def : Pat<(v8i16 (add (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
1442 (v8i16 (MVE_VADDi16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1443 def : Pat<(v4i32 (add (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
1444 (v4i32 (MVE_VADDi32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
1447 def MVE_VSUBi8 : MVE_VSUB<"i8", 0b00>;
1448 def MVE_VSUBi16 : MVE_VSUB<"i16", 0b01>;
1449 def MVE_VSUBi32 : MVE_VSUB<"i32", 0b10>;
1451 let Predicates = [HasMVEInt] in {
1452 def : Pat<(v16i8 (sub (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
1453 (v16i8 (MVE_VSUBi8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1454 def : Pat<(v8i16 (sub (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
1455 (v8i16 (MVE_VSUBi16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1456 def : Pat<(v4i32 (sub (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))),
1457 (v4i32 (MVE_VSUBi32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)))>;
1460 class MVE_VQADDSUB<string iname, string suffix, bit U, bit subtract,
1461 bits<2> size, list<dag> pattern=[]>
1462 : MVE_int<iname, suffix, size, pattern> {
1465 let Inst{25-23} = 0b110;
1467 let Inst{12-10} = 0b000;
1468 let Inst{9} = subtract;
1474 class MVE_VQADD<string suffix, bit U, bits<2> size, list<dag> pattern=[]>
1475 : MVE_VQADDSUB<"vqadd", suffix, U, 0b0, size, pattern>;
1476 class MVE_VQSUB<string suffix, bit U, bits<2> size, list<dag> pattern=[]>
1477 : MVE_VQADDSUB<"vqsub", suffix, U, 0b1, size, pattern>;
1479 def MVE_VQADDs8 : MVE_VQADD<"s8", 0b0, 0b00>;
1480 def MVE_VQADDs16 : MVE_VQADD<"s16", 0b0, 0b01>;
1481 def MVE_VQADDs32 : MVE_VQADD<"s32", 0b0, 0b10>;
1482 def MVE_VQADDu8 : MVE_VQADD<"u8", 0b1, 0b00>;
1483 def MVE_VQADDu16 : MVE_VQADD<"u16", 0b1, 0b01>;
1484 def MVE_VQADDu32 : MVE_VQADD<"u32", 0b1, 0b10>;
1486 def MVE_VQSUBs8 : MVE_VQSUB<"s8", 0b0, 0b00>;
1487 def MVE_VQSUBs16 : MVE_VQSUB<"s16", 0b0, 0b01>;
1488 def MVE_VQSUBs32 : MVE_VQSUB<"s32", 0b0, 0b10>;
1489 def MVE_VQSUBu8 : MVE_VQSUB<"u8", 0b1, 0b00>;
1490 def MVE_VQSUBu16 : MVE_VQSUB<"u16", 0b1, 0b01>;
1491 def MVE_VQSUBu32 : MVE_VQSUB<"u32", 0b1, 0b10>;
1493 class MVE_VABD_int<string suffix, bit U, bits<2> size, list<dag> pattern=[]>
1494 : MVE_int<"vabd", suffix, size, pattern> {
1497 let Inst{25-23} = 0b110;
1499 let Inst{12-8} = 0b00111;
1504 def MVE_VABDs8 : MVE_VABD_int<"s8", 0b0, 0b00>;
1505 def MVE_VABDs16 : MVE_VABD_int<"s16", 0b0, 0b01>;
1506 def MVE_VABDs32 : MVE_VABD_int<"s32", 0b0, 0b10>;
1507 def MVE_VABDu8 : MVE_VABD_int<"u8", 0b1, 0b00>;
1508 def MVE_VABDu16 : MVE_VABD_int<"u16", 0b1, 0b01>;
1509 def MVE_VABDu32 : MVE_VABD_int<"u32", 0b1, 0b10>;
1511 class MVE_VRHADD<string suffix, bit U, bits<2> size, list<dag> pattern=[]>
1512 : MVE_int<"vrhadd", suffix, size, pattern> {
1515 let Inst{25-23} = 0b110;
1517 let Inst{12-8} = 0b00001;
1522 def MVE_VRHADDs8 : MVE_VRHADD<"s8", 0b0, 0b00>;
1523 def MVE_VRHADDs16 : MVE_VRHADD<"s16", 0b0, 0b01>;
1524 def MVE_VRHADDs32 : MVE_VRHADD<"s32", 0b0, 0b10>;
1525 def MVE_VRHADDu8 : MVE_VRHADD<"u8", 0b1, 0b00>;
1526 def MVE_VRHADDu16 : MVE_VRHADD<"u16", 0b1, 0b01>;
1527 def MVE_VRHADDu32 : MVE_VRHADD<"u32", 0b1, 0b10>;
1529 class MVE_VHADDSUB<string iname, string suffix, bit U, bit subtract,
1530 bits<2> size, list<dag> pattern=[]>
1531 : MVE_int<iname, suffix, size, pattern> {
1534 let Inst{25-23} = 0b110;
1536 let Inst{12-10} = 0b000;
1537 let Inst{9} = subtract;
1543 class MVE_VHADD<string suffix, bit U, bits<2> size,
1544 list<dag> pattern=[]>
1545 : MVE_VHADDSUB<"vhadd", suffix, U, 0b0, size, pattern>;
1546 class MVE_VHSUB<string suffix, bit U, bits<2> size,
1547 list<dag> pattern=[]>
1548 : MVE_VHADDSUB<"vhsub", suffix, U, 0b1, size, pattern>;
1550 def MVE_VHADDs8 : MVE_VHADD<"s8", 0b0, 0b00>;
1551 def MVE_VHADDs16 : MVE_VHADD<"s16", 0b0, 0b01>;
1552 def MVE_VHADDs32 : MVE_VHADD<"s32", 0b0, 0b10>;
1553 def MVE_VHADDu8 : MVE_VHADD<"u8", 0b1, 0b00>;
1554 def MVE_VHADDu16 : MVE_VHADD<"u16", 0b1, 0b01>;
1555 def MVE_VHADDu32 : MVE_VHADD<"u32", 0b1, 0b10>;
1557 def MVE_VHSUBs8 : MVE_VHSUB<"s8", 0b0, 0b00>;
1558 def MVE_VHSUBs16 : MVE_VHSUB<"s16", 0b0, 0b01>;
1559 def MVE_VHSUBs32 : MVE_VHSUB<"s32", 0b0, 0b10>;
1560 def MVE_VHSUBu8 : MVE_VHSUB<"u8", 0b1, 0b00>;
1561 def MVE_VHSUBu16 : MVE_VHSUB<"u16", 0b1, 0b01>;
1562 def MVE_VHSUBu32 : MVE_VHSUB<"u32", 0b1, 0b10>;
1564 class MVE_VDUP<string suffix, bit B, bit E, list<dag> pattern=[]>
1565 : MVE_p<(outs MQPR:$Qd), (ins rGPR:$Rt), NoItinerary,
1566 "vdup", suffix, "$Qd, $Rt", vpred_r, "", pattern> {
1571 let Inst{25-23} = 0b101;
1573 let Inst{21-20} = 0b10;
1574 let Inst{19-17} = Qd{2-0};
1576 let Inst{15-12} = Rt;
1577 let Inst{11-8} = 0b1011;
1578 let Inst{7} = Qd{3};
1581 let Inst{4-0} = 0b10000;
1584 def MVE_VDUP32 : MVE_VDUP<"32", 0b0, 0b0>;
1585 def MVE_VDUP16 : MVE_VDUP<"16", 0b0, 0b1>;
1586 def MVE_VDUP8 : MVE_VDUP<"8", 0b1, 0b0>;
1588 let Predicates = [HasMVEInt] in {
1589 def : Pat<(v16i8 (ARMvdup (i32 rGPR:$elem))),
1590 (MVE_VDUP8 rGPR:$elem)>;
1591 def : Pat<(v8i16 (ARMvdup (i32 rGPR:$elem))),
1592 (MVE_VDUP16 rGPR:$elem)>;
1593 def : Pat<(v4i32 (ARMvdup (i32 rGPR:$elem))),
1594 (MVE_VDUP32 rGPR:$elem)>;
1596 def : Pat<(v4i32 (ARMvduplane (v4i32 MQPR:$src), imm:$lane)),
1597 (MVE_VDUP32 (MVE_VMOV_from_lane_32 MQPR:$src, imm:$lane))>;
1598 // For the 16-bit and 8-bit vduplanes we don't care about the signedness
1599 // of the lane move operation as we only want the lowest 8/16 bits anyway.
1600 def : Pat<(v8i16 (ARMvduplane (v8i16 MQPR:$src), imm:$lane)),
1601 (MVE_VDUP16 (MVE_VMOV_from_lane_u16 MQPR:$src, imm:$lane))>;
1602 def : Pat<(v16i8 (ARMvduplane (v16i8 MQPR:$src), imm:$lane)),
1603 (MVE_VDUP8 (MVE_VMOV_from_lane_u8 MQPR:$src, imm:$lane))>;
1605 def : Pat<(v4f32 (ARMvdup (f32 SPR:$elem))),
1606 (v4f32 (MVE_VDUP32 (i32 (COPY_TO_REGCLASS (f32 SPR:$elem), rGPR))))>;
1607 def : Pat<(v8f16 (ARMvdup (f16 HPR:$elem))),
1608 (v8f16 (MVE_VDUP16 (i32 (COPY_TO_REGCLASS (f16 HPR:$elem), rGPR))))>;
1610 def : Pat<(v4f32 (ARMvduplane (v4f32 MQPR:$src), imm:$lane)),
1611 (MVE_VDUP32 (MVE_VMOV_from_lane_32 MQPR:$src, imm:$lane))>;
1612 def : Pat<(v8f16 (ARMvduplane (v8f16 MQPR:$src), imm:$lane)),
1613 (MVE_VDUP16 (MVE_VMOV_from_lane_u16 MQPR:$src, imm:$lane))>;
1617 class MVEIntSingleSrc<string iname, string suffix, bits<2> size,
1618 list<dag> pattern=[]>
1619 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qm), NoItinerary,
1620 iname, suffix, "$Qd, $Qm", vpred_r, "", pattern> {
1624 let Inst{22} = Qd{3};
1625 let Inst{19-18} = size{1-0};
1626 let Inst{15-13} = Qd{2-0};
1627 let Inst{5} = Qm{3};
1628 let Inst{3-1} = Qm{2-0};
1631 class MVE_VCLSCLZ<string iname, string suffix, bits<2> size,
1632 bit count_zeroes, list<dag> pattern=[]>
1633 : MVEIntSingleSrc<iname, suffix, size, pattern> {
1636 let Inst{25-23} = 0b111;
1637 let Inst{21-20} = 0b11;
1638 let Inst{17-16} = 0b00;
1639 let Inst{12-8} = 0b00100;
1640 let Inst{7} = count_zeroes;
1646 def MVE_VCLSs8 : MVE_VCLSCLZ<"vcls", "s8", 0b00, 0b0>;
1647 def MVE_VCLSs16 : MVE_VCLSCLZ<"vcls", "s16", 0b01, 0b0>;
1648 def MVE_VCLSs32 : MVE_VCLSCLZ<"vcls", "s32", 0b10, 0b0>;
1650 def MVE_VCLZs8 : MVE_VCLSCLZ<"vclz", "i8", 0b00, 0b1>;
1651 def MVE_VCLZs16 : MVE_VCLSCLZ<"vclz", "i16", 0b01, 0b1>;
1652 def MVE_VCLZs32 : MVE_VCLSCLZ<"vclz", "i32", 0b10, 0b1>;
1654 class MVE_VABSNEG_int<string iname, string suffix, bits<2> size, bit negate,
1655 list<dag> pattern=[]>
1656 : MVEIntSingleSrc<iname, suffix, size, pattern> {
1659 let Inst{25-23} = 0b111;
1660 let Inst{21-20} = 0b11;
1661 let Inst{17-16} = 0b01;
1662 let Inst{12-8} = 0b00011;
1663 let Inst{7} = negate;
1669 def MVE_VABSs8 : MVE_VABSNEG_int<"vabs", "s8", 0b00, 0b0>;
1670 def MVE_VABSs16 : MVE_VABSNEG_int<"vabs", "s16", 0b01, 0b0>;
1671 def MVE_VABSs32 : MVE_VABSNEG_int<"vabs", "s32", 0b10, 0b0>;
1673 let Predicates = [HasMVEInt] in {
1674 def : Pat<(v16i8 (abs (v16i8 MQPR:$v))),
1675 (v16i8 (MVE_VABSs8 $v))>;
1676 def : Pat<(v8i16 (abs (v8i16 MQPR:$v))),
1677 (v8i16 (MVE_VABSs16 $v))>;
1678 def : Pat<(v4i32 (abs (v4i32 MQPR:$v))),
1679 (v4i32 (MVE_VABSs32 $v))>;
1682 def MVE_VNEGs8 : MVE_VABSNEG_int<"vneg", "s8", 0b00, 0b1>;
1683 def MVE_VNEGs16 : MVE_VABSNEG_int<"vneg", "s16", 0b01, 0b1>;
1684 def MVE_VNEGs32 : MVE_VABSNEG_int<"vneg", "s32", 0b10, 0b1>;
1686 let Predicates = [HasMVEInt] in {
1687 def : Pat<(v16i8 (vnegq (v16i8 MQPR:$v))),
1688 (v16i8 (MVE_VNEGs8 $v))>;
1689 def : Pat<(v8i16 (vnegq (v8i16 MQPR:$v))),
1690 (v8i16 (MVE_VNEGs16 $v))>;
1691 def : Pat<(v4i32 (vnegq (v4i32 MQPR:$v))),
1692 (v4i32 (MVE_VNEGs32 $v))>;
1695 class MVE_VQABSNEG<string iname, string suffix, bits<2> size,
1696 bit negate, list<dag> pattern=[]>
1697 : MVEIntSingleSrc<iname, suffix, size, pattern> {
1700 let Inst{25-23} = 0b111;
1701 let Inst{21-20} = 0b11;
1702 let Inst{17-16} = 0b00;
1703 let Inst{12-8} = 0b00111;
1704 let Inst{7} = negate;
1710 def MVE_VQABSs8 : MVE_VQABSNEG<"vqabs", "s8", 0b00, 0b0>;
1711 def MVE_VQABSs16 : MVE_VQABSNEG<"vqabs", "s16", 0b01, 0b0>;
1712 def MVE_VQABSs32 : MVE_VQABSNEG<"vqabs", "s32", 0b10, 0b0>;
1714 def MVE_VQNEGs8 : MVE_VQABSNEG<"vqneg", "s8", 0b00, 0b1>;
1715 def MVE_VQNEGs16 : MVE_VQABSNEG<"vqneg", "s16", 0b01, 0b1>;
1716 def MVE_VQNEGs32 : MVE_VQABSNEG<"vqneg", "s32", 0b10, 0b1>;
1718 class MVE_mod_imm<string iname, string suffix, bits<4> cmode, bit op,
1719 dag iops, list<dag> pattern=[]>
1720 : MVE_p<(outs MQPR:$Qd), iops, NoItinerary, iname, suffix, "$Qd, $imm",
1721 vpred_r, "", pattern> {
1725 let Inst{28} = imm{7};
1726 let Inst{25-23} = 0b111;
1727 let Inst{22} = Qd{3};
1728 let Inst{21-19} = 0b000;
1729 let Inst{18-16} = imm{6-4};
1730 let Inst{15-13} = Qd{2-0};
1732 let Inst{11-8} = cmode{3-0};
1733 let Inst{7-6} = 0b01;
1736 let Inst{3-0} = imm{3-0};
1738 let DecoderMethod = "DecodeMVEModImmInstruction";
1741 let isReMaterializable = 1 in {
1742 let isAsCheapAsAMove = 1 in {
1743 def MVE_VMOVimmi8 : MVE_mod_imm<"vmov", "i8", {1,1,1,0}, 0b0, (ins nImmSplatI8:$imm)>;
1744 def MVE_VMOVimmi16 : MVE_mod_imm<"vmov", "i16", {1,0,?,0}, 0b0, (ins nImmSplatI16:$imm)> {
1745 let Inst{9} = imm{9};
1747 def MVE_VMOVimmi32 : MVE_mod_imm<"vmov", "i32", {?,?,?,?}, 0b0, (ins nImmVMOVI32:$imm)> {
1748 let Inst{11-8} = imm{11-8};
1750 def MVE_VMOVimmi64 : MVE_mod_imm<"vmov", "i64", {1,1,1,0}, 0b1, (ins nImmSplatI64:$imm)>;
1751 def MVE_VMOVimmf32 : MVE_mod_imm<"vmov", "f32", {1,1,1,1}, 0b0, (ins nImmVMOVF32:$imm)>;
1752 } // let isAsCheapAsAMove = 1
1754 def MVE_VMVNimmi16 : MVE_mod_imm<"vmvn", "i16", {1,0,?,0}, 0b1, (ins nImmSplatI16:$imm)> {
1755 let Inst{9} = imm{9};
1757 def MVE_VMVNimmi32 : MVE_mod_imm<"vmvn", "i32", {?,?,?,?}, 0b1, (ins nImmVMOVI32:$imm)> {
1758 let Inst{11-8} = imm{11-8};
1760 } // let isReMaterializable = 1
1762 let Predicates = [HasMVEInt] in {
1763 def : Pat<(v16i8 (ARMvmovImm timm:$simm)),
1764 (v16i8 (MVE_VMOVimmi8 nImmSplatI8:$simm))>;
1765 def : Pat<(v8i16 (ARMvmovImm timm:$simm)),
1766 (v8i16 (MVE_VMOVimmi16 nImmSplatI16:$simm))>;
1767 def : Pat<(v4i32 (ARMvmovImm timm:$simm)),
1768 (v4i32 (MVE_VMOVimmi32 nImmVMOVI32:$simm))>;
1770 def : Pat<(v8i16 (ARMvmvnImm timm:$simm)),
1771 (v8i16 (MVE_VMVNimmi16 nImmSplatI16:$simm))>;
1772 def : Pat<(v4i32 (ARMvmvnImm timm:$simm)),
1773 (v4i32 (MVE_VMVNimmi32 nImmVMOVI32:$simm))>;
1775 def : Pat<(v4f32 (ARMvmovFPImm timm:$simm)),
1776 (v4f32 (MVE_VMOVimmf32 nImmVMOVF32:$simm))>;
1779 class MVE_VMINMAXA<string iname, string suffix, bits<2> size,
1780 bit bit_12, list<dag> pattern=[]>
1781 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qd_src, MQPR:$Qm),
1782 NoItinerary, iname, suffix, "$Qd, $Qm", vpred_n, "$Qd = $Qd_src",
1788 let Inst{25-23} = 0b100;
1789 let Inst{22} = Qd{3};
1790 let Inst{21-20} = 0b11;
1791 let Inst{19-18} = size;
1792 let Inst{17-16} = 0b11;
1793 let Inst{15-13} = Qd{2-0};
1794 let Inst{12} = bit_12;
1795 let Inst{11-6} = 0b111010;
1796 let Inst{5} = Qm{3};
1798 let Inst{3-1} = Qm{2-0};
1802 def MVE_VMAXAs8 : MVE_VMINMAXA<"vmaxa", "s8", 0b00, 0b0>;
1803 def MVE_VMAXAs16 : MVE_VMINMAXA<"vmaxa", "s16", 0b01, 0b0>;
1804 def MVE_VMAXAs32 : MVE_VMINMAXA<"vmaxa", "s32", 0b10, 0b0>;
1806 def MVE_VMINAs8 : MVE_VMINMAXA<"vmina", "s8", 0b00, 0b1>;
1807 def MVE_VMINAs16 : MVE_VMINMAXA<"vmina", "s16", 0b01, 0b1>;
1808 def MVE_VMINAs32 : MVE_VMINMAXA<"vmina", "s32", 0b10, 0b1>;
1810 // end of MVE Integer instructions
1812 // start of mve_imm_shift instructions
1814 def MVE_VSHLC : MVE_p<(outs rGPR:$RdmDest, MQPR:$Qd),
1815 (ins MQPR:$QdSrc, rGPR:$RdmSrc, long_shift:$imm),
1816 NoItinerary, "vshlc", "", "$QdSrc, $RdmSrc, $imm",
1817 vpred_n, "$RdmDest = $RdmSrc,$Qd = $QdSrc"> {
1823 let Inst{25-23} = 0b101;
1824 let Inst{22} = Qd{3};
1826 let Inst{20-16} = imm{4-0};
1827 let Inst{15-13} = Qd{2-0};
1828 let Inst{12-4} = 0b011111100;
1829 let Inst{3-0} = RdmDest{3-0};
1832 class MVE_shift_imm<dag oops, dag iops, string iname, string suffix,
1833 string ops, vpred_ops vpred, string cstr,
1834 list<dag> pattern=[]>
1835 : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, pattern> {
1839 let Inst{22} = Qd{3};
1840 let Inst{15-13} = Qd{2-0};
1841 let Inst{5} = Qm{3};
1842 let Inst{3-1} = Qm{2-0};
1845 class MVE_VMOVL<string iname, string suffix, bits<2> sz, bit U,
1846 list<dag> pattern=[]>
1847 : MVE_shift_imm<(outs MQPR:$Qd), (ins MQPR:$Qm),
1848 iname, suffix, "$Qd, $Qm", vpred_r, "",
1851 let Inst{25-23} = 0b101;
1853 let Inst{20-19} = sz{1-0};
1854 let Inst{18-16} = 0b000;
1855 let Inst{11-6} = 0b111101;
1860 multiclass MVE_VMOVL_shift_half<string iname, string suffix, bits<2> sz, bit U,
1861 list<dag> pattern=[]> {
1862 def bh : MVE_VMOVL<!strconcat(iname, "b"), suffix, sz, U, pattern> {
1865 def th : MVE_VMOVL<!strconcat(iname, "t"), suffix, sz, U, pattern> {
1870 defm MVE_VMOVLs8 : MVE_VMOVL_shift_half<"vmovl", "s8", 0b01, 0b0>;
1871 defm MVE_VMOVLu8 : MVE_VMOVL_shift_half<"vmovl", "u8", 0b01, 0b1>;
1872 defm MVE_VMOVLs16 : MVE_VMOVL_shift_half<"vmovl", "s16", 0b10, 0b0>;
1873 defm MVE_VMOVLu16 : MVE_VMOVL_shift_half<"vmovl", "u16", 0b10, 0b1>;
1875 let Predicates = [HasMVEInt] in {
1876 def : Pat<(sext_inreg (v4i32 MQPR:$src), v4i16),
1877 (MVE_VMOVLs16bh MQPR:$src)>;
1878 def : Pat<(sext_inreg (v8i16 MQPR:$src), v8i8),
1879 (MVE_VMOVLs8bh MQPR:$src)>;
1880 def : Pat<(sext_inreg (v4i32 MQPR:$src), v4i8),
1881 (MVE_VMOVLs16bh (MVE_VMOVLs8bh MQPR:$src))>;
1883 // zext_inreg 16 -> 32
1884 def : Pat<(and (v4i32 MQPR:$src), (v4i32 (ARMvmovImm (i32 0xCFF)))),
1885 (MVE_VMOVLu16bh MQPR:$src)>;
1886 // zext_inreg 8 -> 16
1887 def : Pat<(and (v8i16 MQPR:$src), (v8i16 (ARMvmovImm (i32 0x8FF)))),
1888 (MVE_VMOVLu8bh MQPR:$src)>;
1892 class MVE_VSHLL_imm<string iname, string suffix, bit U, bit th,
1893 dag immops, list<dag> pattern=[]>
1894 : MVE_shift_imm<(outs MQPR:$Qd), !con((ins MQPR:$Qm), immops),
1895 iname, suffix, "$Qd, $Qm, $imm", vpred_r, "", pattern> {
1897 let Inst{25-23} = 0b101;
1900 let Inst{11-6} = 0b111101;
1905 // The immediate VSHLL instructions accept shift counts from 1 up to
1906 // the lane width (8 or 16), but the full-width shifts have an
1907 // entirely separate encoding, given below with 'lw' in the name.
1909 class MVE_VSHLL_imm8<string iname, string suffix,
1910 bit U, bit th, list<dag> pattern=[]>
1911 : MVE_VSHLL_imm<iname, suffix, U, th, (ins mve_shift_imm1_7:$imm), pattern> {
1913 let Inst{20-19} = 0b01;
1914 let Inst{18-16} = imm;
1917 class MVE_VSHLL_imm16<string iname, string suffix,
1918 bit U, bit th, list<dag> pattern=[]>
1919 : MVE_VSHLL_imm<iname, suffix, U, th, (ins mve_shift_imm1_15:$imm), pattern> {
1922 let Inst{19-16} = imm;
1925 def MVE_VSHLL_imms8bh : MVE_VSHLL_imm8 <"vshllb", "s8", 0b0, 0b0>;
1926 def MVE_VSHLL_imms8th : MVE_VSHLL_imm8 <"vshllt", "s8", 0b0, 0b1>;
1927 def MVE_VSHLL_immu8bh : MVE_VSHLL_imm8 <"vshllb", "u8", 0b1, 0b0>;
1928 def MVE_VSHLL_immu8th : MVE_VSHLL_imm8 <"vshllt", "u8", 0b1, 0b1>;
1929 def MVE_VSHLL_imms16bh : MVE_VSHLL_imm16<"vshllb", "s16", 0b0, 0b0>;
1930 def MVE_VSHLL_imms16th : MVE_VSHLL_imm16<"vshllt", "s16", 0b0, 0b1>;
1931 def MVE_VSHLL_immu16bh : MVE_VSHLL_imm16<"vshllb", "u16", 0b1, 0b0>;
1932 def MVE_VSHLL_immu16th : MVE_VSHLL_imm16<"vshllt", "u16", 0b1, 0b1>;
1934 class MVE_VSHLL_by_lane_width<string iname, string suffix, bits<2> size,
1935 bit U, string ops, list<dag> pattern=[]>
1936 : MVE_shift_imm<(outs MQPR:$Qd), (ins MQPR:$Qm),
1937 iname, suffix, ops, vpred_r, "", pattern> {
1939 let Inst{25-23} = 0b100;
1940 let Inst{21-20} = 0b11;
1941 let Inst{19-18} = size{1-0};
1942 let Inst{17-16} = 0b01;
1943 let Inst{11-6} = 0b111000;
1948 multiclass MVE_VSHLL_lw<string iname, string suffix, bits<2> sz, bit U,
1949 string ops, list<dag> pattern=[]> {
1950 def bh : MVE_VSHLL_by_lane_width<iname#"b", suffix, sz, U, ops, pattern> {
1953 def th : MVE_VSHLL_by_lane_width<iname#"t", suffix, sz, U, ops, pattern> {
1958 defm MVE_VSHLL_lws8 : MVE_VSHLL_lw<"vshll", "s8", 0b00, 0b0, "$Qd, $Qm, #8">;
1959 defm MVE_VSHLL_lws16 : MVE_VSHLL_lw<"vshll", "s16", 0b01, 0b0, "$Qd, $Qm, #16">;
1960 defm MVE_VSHLL_lwu8 : MVE_VSHLL_lw<"vshll", "u8", 0b00, 0b1, "$Qd, $Qm, #8">;
1961 defm MVE_VSHLL_lwu16 : MVE_VSHLL_lw<"vshll", "u16", 0b01, 0b1, "$Qd, $Qm, #16">;
1963 class MVE_VxSHRN<string iname, string suffix, bit bit_12, bit bit_28,
1964 dag immops, list<dag> pattern=[]>
1965 : MVE_shift_imm<(outs MQPR:$Qd), !con((ins MQPR:$QdSrc, MQPR:$Qm), immops),
1966 iname, suffix, "$Qd, $Qm, $imm", vpred_n, "$Qd = $QdSrc",
1970 let Inst{28} = bit_28;
1971 let Inst{25-23} = 0b101;
1973 let Inst{20-16} = imm{4-0};
1974 let Inst{12} = bit_12;
1975 let Inst{11-6} = 0b111111;
1980 def MVE_VRSHRNi16bh : MVE_VxSHRN<
1981 "vrshrnb", "i16", 0b0, 0b1, (ins shr_imm8:$imm)> {
1982 let Inst{20-19} = 0b01;
1984 def MVE_VRSHRNi16th : MVE_VxSHRN<
1985 "vrshrnt", "i16", 0b1, 0b1,(ins shr_imm8:$imm)> {
1986 let Inst{20-19} = 0b01;
1988 def MVE_VRSHRNi32bh : MVE_VxSHRN<
1989 "vrshrnb", "i32", 0b0, 0b1, (ins shr_imm16:$imm)> {
1992 def MVE_VRSHRNi32th : MVE_VxSHRN<
1993 "vrshrnt", "i32", 0b1, 0b1, (ins shr_imm16:$imm)> {
1997 def MVE_VSHRNi16bh : MVE_VxSHRN<
1998 "vshrnb", "i16", 0b0, 0b0, (ins shr_imm8:$imm)> {
1999 let Inst{20-19} = 0b01;
2001 def MVE_VSHRNi16th : MVE_VxSHRN<
2002 "vshrnt", "i16", 0b1, 0b0, (ins shr_imm8:$imm)> {
2003 let Inst{20-19} = 0b01;
2005 def MVE_VSHRNi32bh : MVE_VxSHRN<
2006 "vshrnb", "i32", 0b0, 0b0, (ins shr_imm16:$imm)> {
2009 def MVE_VSHRNi32th : MVE_VxSHRN<
2010 "vshrnt", "i32", 0b1, 0b0, (ins shr_imm16:$imm)> {
2014 class MVE_VxQRSHRUN<string iname, string suffix, bit bit_28, bit bit_12, dag immops,
2015 list<dag> pattern=[]>
2016 : MVE_shift_imm<(outs MQPR:$Qd), !con((ins MQPR:$QdSrc, MQPR:$Qm), immops),
2017 iname, suffix, "$Qd, $Qm, $imm", vpred_n, "$Qd = $QdSrc",
2021 let Inst{28} = bit_28;
2022 let Inst{25-23} = 0b101;
2024 let Inst{20-16} = imm{4-0};
2025 let Inst{12} = bit_12;
2026 let Inst{11-6} = 0b111111;
2031 def MVE_VQRSHRUNs16bh : MVE_VxQRSHRUN<
2032 "vqrshrunb", "s16", 0b1, 0b0, (ins shr_imm8:$imm)> {
2033 let Inst{20-19} = 0b01;
2035 def MVE_VQRSHRUNs16th : MVE_VxQRSHRUN<
2036 "vqrshrunt", "s16", 0b1, 0b1, (ins shr_imm8:$imm)> {
2037 let Inst{20-19} = 0b01;
2039 def MVE_VQRSHRUNs32bh : MVE_VxQRSHRUN<
2040 "vqrshrunb", "s32", 0b1, 0b0, (ins shr_imm16:$imm)> {
2043 def MVE_VQRSHRUNs32th : MVE_VxQRSHRUN<
2044 "vqrshrunt", "s32", 0b1, 0b1, (ins shr_imm16:$imm)> {
2048 def MVE_VQSHRUNs16bh : MVE_VxQRSHRUN<
2049 "vqshrunb", "s16", 0b0, 0b0, (ins shr_imm8:$imm)> {
2050 let Inst{20-19} = 0b01;
2052 def MVE_VQSHRUNs16th : MVE_VxQRSHRUN<
2053 "vqshrunt", "s16", 0b0, 0b1, (ins shr_imm8:$imm)> {
2054 let Inst{20-19} = 0b01;
2056 def MVE_VQSHRUNs32bh : MVE_VxQRSHRUN<
2057 "vqshrunb", "s32", 0b0, 0b0, (ins shr_imm16:$imm)> {
2060 def MVE_VQSHRUNs32th : MVE_VxQRSHRUN<
2061 "vqshrunt", "s32", 0b0, 0b1, (ins shr_imm16:$imm)> {
2065 class MVE_VxQRSHRN<string iname, string suffix, bit bit_0, bit bit_12,
2066 dag immops, list<dag> pattern=[]>
2067 : MVE_shift_imm<(outs MQPR:$Qd), !con((ins MQPR:$QdSrc, MQPR:$Qm), immops),
2068 iname, suffix, "$Qd, $Qm, $imm", vpred_n, "$Qd = $QdSrc",
2072 let Inst{25-23} = 0b101;
2074 let Inst{20-16} = imm{4-0};
2075 let Inst{12} = bit_12;
2076 let Inst{11-6} = 0b111101;
2078 let Inst{0} = bit_0;
2081 multiclass MVE_VxQRSHRN_types<string iname, bit bit_0, bit bit_12> {
2082 def s16 : MVE_VxQRSHRN<iname, "s16", bit_0, bit_12, (ins shr_imm8:$imm)> {
2084 let Inst{20-19} = 0b01;
2086 def u16 : MVE_VxQRSHRN<iname, "u16", bit_0, bit_12, (ins shr_imm8:$imm)> {
2088 let Inst{20-19} = 0b01;
2090 def s32 : MVE_VxQRSHRN<iname, "s32", bit_0, bit_12, (ins shr_imm16:$imm)> {
2094 def u32 : MVE_VxQRSHRN<iname, "u32", bit_0, bit_12, (ins shr_imm16:$imm)> {
2100 defm MVE_VQRSHRNbh : MVE_VxQRSHRN_types<"vqrshrnb", 0b1, 0b0>;
2101 defm MVE_VQRSHRNth : MVE_VxQRSHRN_types<"vqrshrnt", 0b1, 0b1>;
2102 defm MVE_VQSHRNbh : MVE_VxQRSHRN_types<"vqshrnb", 0b0, 0b0>;
2103 defm MVE_VQSHRNth : MVE_VxQRSHRN_types<"vqshrnt", 0b0, 0b1>;
2105 // end of mve_imm_shift instructions
2107 // start of mve_shift instructions
2109 class MVE_shift_by_vec<string iname, string suffix, bit U,
2110 bits<2> size, bit bit_4, bit bit_8>
2111 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qm, MQPR:$Qn), NoItinerary,
2112 iname, suffix, "$Qd, $Qm, $Qn", vpred_r, "", []> {
2113 // Shift instructions which take a vector of shift counts
2119 let Inst{25-24} = 0b11;
2121 let Inst{22} = Qd{3};
2122 let Inst{21-20} = size;
2123 let Inst{19-17} = Qn{2-0};
2125 let Inst{15-13} = Qd{2-0};
2126 let Inst{12-9} = 0b0010;
2127 let Inst{8} = bit_8;
2128 let Inst{7} = Qn{3};
2130 let Inst{5} = Qm{3};
2131 let Inst{4} = bit_4;
2132 let Inst{3-1} = Qm{2-0};
2136 multiclass mve_shift_by_vec_multi<string iname, bit bit_4, bit bit_8> {
2137 def s8 : MVE_shift_by_vec<iname, "s8", 0b0, 0b00, bit_4, bit_8>;
2138 def s16 : MVE_shift_by_vec<iname, "s16", 0b0, 0b01, bit_4, bit_8>;
2139 def s32 : MVE_shift_by_vec<iname, "s32", 0b0, 0b10, bit_4, bit_8>;
2140 def u8 : MVE_shift_by_vec<iname, "u8", 0b1, 0b00, bit_4, bit_8>;
2141 def u16 : MVE_shift_by_vec<iname, "u16", 0b1, 0b01, bit_4, bit_8>;
2142 def u32 : MVE_shift_by_vec<iname, "u32", 0b1, 0b10, bit_4, bit_8>;
2145 defm MVE_VSHL_by_vec : mve_shift_by_vec_multi<"vshl", 0b0, 0b0>;
2146 defm MVE_VQSHL_by_vec : mve_shift_by_vec_multi<"vqshl", 0b1, 0b0>;
2147 defm MVE_VQRSHL_by_vec : mve_shift_by_vec_multi<"vqrshl", 0b1, 0b1>;
2148 defm MVE_VRSHL_by_vec : mve_shift_by_vec_multi<"vrshl", 0b0, 0b1>;
2150 let Predicates = [HasMVEInt] in {
2151 def : Pat<(v4i32 (ARMvshlu (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn))),
2152 (v4i32 (MVE_VSHL_by_vecu32 (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn)))>;
2153 def : Pat<(v8i16 (ARMvshlu (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn))),
2154 (v8i16 (MVE_VSHL_by_vecu16 (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn)))>;
2155 def : Pat<(v16i8 (ARMvshlu (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn))),
2156 (v16i8 (MVE_VSHL_by_vecu8 (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn)))>;
2158 def : Pat<(v4i32 (ARMvshls (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn))),
2159 (v4i32 (MVE_VSHL_by_vecs32 (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn)))>;
2160 def : Pat<(v8i16 (ARMvshls (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn))),
2161 (v8i16 (MVE_VSHL_by_vecs16 (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn)))>;
2162 def : Pat<(v16i8 (ARMvshls (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn))),
2163 (v16i8 (MVE_VSHL_by_vecs8 (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn)))>;
2166 class MVE_shift_with_imm<string iname, string suffix, dag oops, dag iops,
2167 string ops, vpred_ops vpred, string cstr,
2168 list<dag> pattern=[]>
2169 : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, pattern> {
2174 let Inst{22} = Qd{3};
2175 let Inst{15-13} = Qd{2-0};
2176 let Inst{12-11} = 0b00;
2177 let Inst{7-6} = 0b01;
2178 let Inst{5} = Qm{3};
2180 let Inst{3-1} = Qm{2-0};
2184 class MVE_VSxI_imm<string iname, string suffix, bit bit_8, dag imm>
2185 : MVE_shift_with_imm<iname, suffix, (outs MQPR:$Qd),
2186 !con((ins MQPR:$Qd_src, MQPR:$Qm), imm),
2187 "$Qd, $Qm, $imm", vpred_n, "$Qd = $Qd_src"> {
2190 let Inst{25-24} = 0b11;
2191 let Inst{21-16} = imm;
2192 let Inst{10-9} = 0b10;
2193 let Inst{8} = bit_8;
2196 def MVE_VSRIimm8 : MVE_VSxI_imm<"vsri", "8", 0b0, (ins shr_imm8:$imm)> {
2197 let Inst{21-19} = 0b001;
2200 def MVE_VSRIimm16 : MVE_VSxI_imm<"vsri", "16", 0b0, (ins shr_imm16:$imm)> {
2201 let Inst{21-20} = 0b01;
2204 def MVE_VSRIimm32 : MVE_VSxI_imm<"vsri", "32", 0b0, (ins shr_imm32:$imm)> {
2208 def MVE_VSLIimm8 : MVE_VSxI_imm<"vsli", "8", 0b1, (ins imm0_7:$imm)> {
2209 let Inst{21-19} = 0b001;
2212 def MVE_VSLIimm16 : MVE_VSxI_imm<"vsli", "16", 0b1, (ins imm0_15:$imm)> {
2213 let Inst{21-20} = 0b01;
2216 def MVE_VSLIimm32 : MVE_VSxI_imm<"vsli", "32", 0b1,(ins imm0_31:$imm)> {
2220 class MVE_VQSHL_imm<string suffix, dag imm>
2221 : MVE_shift_with_imm<"vqshl", suffix, (outs MQPR:$Qd),
2222 !con((ins MQPR:$Qm), imm), "$Qd, $Qm, $imm",
2226 let Inst{25-24} = 0b11;
2227 let Inst{21-16} = imm;
2228 let Inst{10-8} = 0b111;
2231 def MVE_VSLIimms8 : MVE_VQSHL_imm<"s8", (ins imm0_7:$imm)> {
2233 let Inst{21-19} = 0b001;
2236 def MVE_VSLIimmu8 : MVE_VQSHL_imm<"u8", (ins imm0_7:$imm)> {
2238 let Inst{21-19} = 0b001;
2241 def MVE_VSLIimms16 : MVE_VQSHL_imm<"s16", (ins imm0_15:$imm)> {
2243 let Inst{21-20} = 0b01;
2246 def MVE_VSLIimmu16 : MVE_VQSHL_imm<"u16", (ins imm0_15:$imm)> {
2248 let Inst{21-20} = 0b01;
2251 def MVE_VSLIimms32 : MVE_VQSHL_imm<"s32", (ins imm0_31:$imm)> {
2256 def MVE_VSLIimmu32 : MVE_VQSHL_imm<"u32", (ins imm0_31:$imm)> {
2261 class MVE_VQSHLU_imm<string suffix, dag imm>
2262 : MVE_shift_with_imm<"vqshlu", suffix, (outs MQPR:$Qd),
2263 !con((ins MQPR:$Qm), imm), "$Qd, $Qm, $imm",
2268 let Inst{25-24} = 0b11;
2269 let Inst{21-16} = imm;
2270 let Inst{10-8} = 0b110;
2273 def MVE_VQSHLU_imms8 : MVE_VQSHLU_imm<"s8", (ins imm0_7:$imm)> {
2274 let Inst{21-19} = 0b001;
2277 def MVE_VQSHLU_imms16 : MVE_VQSHLU_imm<"s16", (ins imm0_15:$imm)> {
2278 let Inst{21-20} = 0b01;
2281 def MVE_VQSHLU_imms32 : MVE_VQSHLU_imm<"s32", (ins imm0_31:$imm)> {
2285 class MVE_VRSHR_imm<string suffix, dag imm>
2286 : MVE_shift_with_imm<"vrshr", suffix, (outs MQPR:$Qd),
2287 !con((ins MQPR:$Qm), imm), "$Qd, $Qm, $imm",
2291 let Inst{25-24} = 0b11;
2292 let Inst{21-16} = imm;
2293 let Inst{10-8} = 0b010;
2296 def MVE_VRSHR_imms8 : MVE_VRSHR_imm<"s8", (ins shr_imm8:$imm)> {
2298 let Inst{21-19} = 0b001;
2301 def MVE_VRSHR_immu8 : MVE_VRSHR_imm<"u8", (ins shr_imm8:$imm)> {
2303 let Inst{21-19} = 0b001;
2306 def MVE_VRSHR_imms16 : MVE_VRSHR_imm<"s16", (ins shr_imm16:$imm)> {
2308 let Inst{21-20} = 0b01;
2311 def MVE_VRSHR_immu16 : MVE_VRSHR_imm<"u16", (ins shr_imm16:$imm)> {
2313 let Inst{21-20} = 0b01;
2316 def MVE_VRSHR_imms32 : MVE_VRSHR_imm<"s32", (ins shr_imm32:$imm)> {
2321 def MVE_VRSHR_immu32 : MVE_VRSHR_imm<"u32", (ins shr_imm32:$imm)> {
2326 class MVE_VSHR_imm<string suffix, dag imm>
2327 : MVE_shift_with_imm<"vshr", suffix, (outs MQPR:$Qd),
2328 !con((ins MQPR:$Qm), imm), "$Qd, $Qm, $imm",
2332 let Inst{25-24} = 0b11;
2333 let Inst{21-16} = imm;
2334 let Inst{10-8} = 0b000;
2337 def MVE_VSHR_imms8 : MVE_VSHR_imm<"s8", (ins shr_imm8:$imm)> {
2339 let Inst{21-19} = 0b001;
2342 def MVE_VSHR_immu8 : MVE_VSHR_imm<"u8", (ins shr_imm8:$imm)> {
2344 let Inst{21-19} = 0b001;
2347 def MVE_VSHR_imms16 : MVE_VSHR_imm<"s16", (ins shr_imm16:$imm)> {
2349 let Inst{21-20} = 0b01;
2352 def MVE_VSHR_immu16 : MVE_VSHR_imm<"u16", (ins shr_imm16:$imm)> {
2354 let Inst{21-20} = 0b01;
2357 def MVE_VSHR_imms32 : MVE_VSHR_imm<"s32", (ins shr_imm32:$imm)> {
2362 def MVE_VSHR_immu32 : MVE_VSHR_imm<"u32", (ins shr_imm32:$imm)> {
2367 class MVE_VSHL_imm<string suffix, dag imm>
2368 : MVE_shift_with_imm<"vshl", suffix, (outs MQPR:$Qd),
2369 !con((ins MQPR:$Qm), imm), "$Qd, $Qm, $imm",
2374 let Inst{25-24} = 0b11;
2375 let Inst{21-16} = imm;
2376 let Inst{10-8} = 0b101;
2379 def MVE_VSHL_immi8 : MVE_VSHL_imm<"i8", (ins imm0_7:$imm)> {
2380 let Inst{21-19} = 0b001;
2383 def MVE_VSHL_immi16 : MVE_VSHL_imm<"i16", (ins imm0_15:$imm)> {
2384 let Inst{21-20} = 0b01;
2387 def MVE_VSHL_immi32 : MVE_VSHL_imm<"i32", (ins imm0_31:$imm)> {
2391 let Predicates = [HasMVEInt] in {
2392 def : Pat<(v4i32 (ARMvshlImm (v4i32 MQPR:$src), imm0_31:$imm)),
2393 (v4i32 (MVE_VSHL_immi32 (v4i32 MQPR:$src), imm0_31:$imm))>;
2394 def : Pat<(v8i16 (ARMvshlImm (v8i16 MQPR:$src), imm0_15:$imm)),
2395 (v8i16 (MVE_VSHL_immi16 (v8i16 MQPR:$src), imm0_15:$imm))>;
2396 def : Pat<(v16i8 (ARMvshlImm (v16i8 MQPR:$src), imm0_7:$imm)),
2397 (v16i8 (MVE_VSHL_immi8 (v16i8 MQPR:$src), imm0_7:$imm))>;
2399 def : Pat<(v4i32 (ARMvshruImm (v4i32 MQPR:$src), imm0_31:$imm)),
2400 (v4i32 (MVE_VSHR_immu32 (v4i32 MQPR:$src), imm0_31:$imm))>;
2401 def : Pat<(v8i16 (ARMvshruImm (v8i16 MQPR:$src), imm0_15:$imm)),
2402 (v8i16 (MVE_VSHR_immu16 (v8i16 MQPR:$src), imm0_15:$imm))>;
2403 def : Pat<(v16i8 (ARMvshruImm (v16i8 MQPR:$src), imm0_7:$imm)),
2404 (v16i8 (MVE_VSHR_immu8 (v16i8 MQPR:$src), imm0_7:$imm))>;
2406 def : Pat<(v4i32 (ARMvshrsImm (v4i32 MQPR:$src), imm0_31:$imm)),
2407 (v4i32 (MVE_VSHR_imms32 (v4i32 MQPR:$src), imm0_31:$imm))>;
2408 def : Pat<(v8i16 (ARMvshrsImm (v8i16 MQPR:$src), imm0_15:$imm)),
2409 (v8i16 (MVE_VSHR_imms16 (v8i16 MQPR:$src), imm0_15:$imm))>;
2410 def : Pat<(v16i8 (ARMvshrsImm (v16i8 MQPR:$src), imm0_7:$imm)),
2411 (v16i8 (MVE_VSHR_imms8 (v16i8 MQPR:$src), imm0_7:$imm))>;
2414 // end of mve_shift instructions
2416 // start of MVE Floating Point instructions
2418 class MVE_float<string iname, string suffix, dag oops, dag iops, string ops,
2419 vpred_ops vpred, string cstr, list<dag> pattern=[]>
2420 : MVE_f<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, pattern> {
2425 let Inst{5} = Qm{3};
2426 let Inst{3-1} = Qm{2-0};
2430 class MVE_VRINT<string rmode, bits<3> op, string suffix, bits<2> size,
2431 list<dag> pattern=[]>
2432 : MVE_float<!strconcat("vrint", rmode), suffix, (outs MQPR:$Qd),
2433 (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", pattern> {
2437 let Inst{25-23} = 0b111;
2438 let Inst{22} = Qd{3};
2439 let Inst{21-20} = 0b11;
2440 let Inst{19-18} = size;
2441 let Inst{17-16} = 0b10;
2442 let Inst{15-13} = Qd{2-0};
2443 let Inst{11-10} = 0b01;
2444 let Inst{9-7} = op{2-0};
2449 multiclass MVE_VRINT_ops<string suffix, bits<2> size, list<dag> pattern=[]> {
2450 def N : MVE_VRINT<"n", 0b000, suffix, size, pattern>;
2451 def X : MVE_VRINT<"x", 0b001, suffix, size, pattern>;
2452 def A : MVE_VRINT<"a", 0b010, suffix, size, pattern>;
2453 def Z : MVE_VRINT<"z", 0b011, suffix, size, pattern>;
2454 def M : MVE_VRINT<"m", 0b101, suffix, size, pattern>;
2455 def P : MVE_VRINT<"p", 0b111, suffix, size, pattern>;
2458 defm MVE_VRINTf16 : MVE_VRINT_ops<"f16", 0b01>;
2459 defm MVE_VRINTf32 : MVE_VRINT_ops<"f32", 0b10>;
2461 let Predicates = [HasMVEFloat] in {
2462 def : Pat<(v4f32 (frint (v4f32 MQPR:$val1))),
2463 (v4f32 (MVE_VRINTf32X (v4f32 MQPR:$val1)))>;
2464 def : Pat<(v8f16 (frint (v8f16 MQPR:$val1))),
2465 (v8f16 (MVE_VRINTf16X (v8f16 MQPR:$val1)))>;
2466 def : Pat<(v4f32 (fround (v4f32 MQPR:$val1))),
2467 (v4f32 (MVE_VRINTf32A (v4f32 MQPR:$val1)))>;
2468 def : Pat<(v8f16 (fround (v8f16 MQPR:$val1))),
2469 (v8f16 (MVE_VRINTf16A (v8f16 MQPR:$val1)))>;
2470 def : Pat<(v4f32 (ftrunc (v4f32 MQPR:$val1))),
2471 (v4f32 (MVE_VRINTf32Z (v4f32 MQPR:$val1)))>;
2472 def : Pat<(v8f16 (ftrunc (v8f16 MQPR:$val1))),
2473 (v8f16 (MVE_VRINTf16Z (v8f16 MQPR:$val1)))>;
2474 def : Pat<(v4f32 (ffloor (v4f32 MQPR:$val1))),
2475 (v4f32 (MVE_VRINTf32M (v4f32 MQPR:$val1)))>;
2476 def : Pat<(v8f16 (ffloor (v8f16 MQPR:$val1))),
2477 (v8f16 (MVE_VRINTf16M (v8f16 MQPR:$val1)))>;
2478 def : Pat<(v4f32 (fceil (v4f32 MQPR:$val1))),
2479 (v4f32 (MVE_VRINTf32P (v4f32 MQPR:$val1)))>;
2480 def : Pat<(v8f16 (fceil (v8f16 MQPR:$val1))),
2481 (v8f16 (MVE_VRINTf16P (v8f16 MQPR:$val1)))>;
2484 class MVEFloatArithNeon<string iname, string suffix, bit size,
2485 dag oops, dag iops, string ops,
2486 vpred_ops vpred, string cstr, list<dag> pattern=[]>
2487 : MVE_float<iname, suffix, oops, iops, ops, vpred, cstr, pattern> {
2488 let Inst{20} = size;
2492 class MVE_VMUL_fp<string suffix, bit size, list<dag> pattern=[]>
2493 : MVEFloatArithNeon<"vmul", suffix, size, (outs MQPR:$Qd),
2494 (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm", vpred_r, "",
2500 let Inst{25-23} = 0b110;
2501 let Inst{22} = Qd{3};
2503 let Inst{19-17} = Qn{2-0};
2504 let Inst{15-13} = Qd{2-0};
2505 let Inst{12-8} = 0b01101;
2506 let Inst{7} = Qn{3};
2510 def MVE_VMULf32 : MVE_VMUL_fp<"f32", 0b0>;
2511 def MVE_VMULf16 : MVE_VMUL_fp<"f16", 0b1>;
2513 let Predicates = [HasMVEFloat] in {
2514 def : Pat<(v4f32 (fmul (v4f32 MQPR:$val1), (v4f32 MQPR:$val2))),
2515 (v4f32 (MVE_VMULf32 (v4f32 MQPR:$val1), (v4f32 MQPR:$val2)))>;
2516 def : Pat<(v8f16 (fmul (v8f16 MQPR:$val1), (v8f16 MQPR:$val2))),
2517 (v8f16 (MVE_VMULf16 (v8f16 MQPR:$val1), (v8f16 MQPR:$val2)))>;
2520 class MVE_VCMLA<string suffix, bit size, list<dag> pattern=[]>
2521 : MVEFloatArithNeon<"vcmla", suffix, size, (outs MQPR:$Qd),
2522 (ins MQPR:$Qd_src, MQPR:$Qn, MQPR:$Qm, complexrotateop:$rot),
2523 "$Qd, $Qn, $Qm, $rot", vpred_n, "$Qd = $Qd_src", pattern> {
2530 let Inst{24-23} = rot;
2531 let Inst{22} = Qd{3};
2533 let Inst{19-17} = Qn{2-0};
2534 let Inst{15-13} = Qd{2-0};
2535 let Inst{12-8} = 0b01000;
2536 let Inst{7} = Qn{3};
2540 def MVE_VCMLAf16 : MVE_VCMLA<"f16", 0b0>;
2541 def MVE_VCMLAf32 : MVE_VCMLA<"f32", 0b1>;
2543 class MVE_VADDSUBFMA_fp<string iname, string suffix, bit size, bit bit_4,
2544 bit bit_8, bit bit_21, dag iops=(ins),
2545 vpred_ops vpred=vpred_r, string cstr="",
2546 list<dag> pattern=[]>
2547 : MVEFloatArithNeon<iname, suffix, size, (outs MQPR:$Qd),
2548 !con(iops, (ins MQPR:$Qn, MQPR:$Qm)), "$Qd, $Qn, $Qm",
2549 vpred, cstr, pattern> {
2554 let Inst{25-23} = 0b110;
2555 let Inst{22} = Qd{3};
2556 let Inst{21} = bit_21;
2557 let Inst{19-17} = Qn{2-0};
2558 let Inst{15-13} = Qd{2-0};
2559 let Inst{11-9} = 0b110;
2560 let Inst{8} = bit_8;
2561 let Inst{7} = Qn{3};
2562 let Inst{4} = bit_4;
2565 def MVE_VFMAf32 : MVE_VADDSUBFMA_fp<"vfma", "f32", 0b0, 0b1, 0b0, 0b0,
2566 (ins MQPR:$Qd_src), vpred_n, "$Qd = $Qd_src">;
2567 def MVE_VFMAf16 : MVE_VADDSUBFMA_fp<"vfma", "f16", 0b1, 0b1, 0b0, 0b0,
2568 (ins MQPR:$Qd_src), vpred_n, "$Qd = $Qd_src">;
2570 def MVE_VFMSf32 : MVE_VADDSUBFMA_fp<"vfms", "f32", 0b0, 0b1, 0b0, 0b1,
2571 (ins MQPR:$Qd_src), vpred_n, "$Qd = $Qd_src">;
2572 def MVE_VFMSf16 : MVE_VADDSUBFMA_fp<"vfms", "f16", 0b1, 0b1, 0b0, 0b1,
2573 (ins MQPR:$Qd_src), vpred_n, "$Qd = $Qd_src">;
2575 def MVE_VADDf32 : MVE_VADDSUBFMA_fp<"vadd", "f32", 0b0, 0b0, 0b1, 0b0>;
2576 def MVE_VADDf16 : MVE_VADDSUBFMA_fp<"vadd", "f16", 0b1, 0b0, 0b1, 0b0>;
2578 let Predicates = [HasMVEFloat] in {
2579 def : Pat<(v4f32 (fadd (v4f32 MQPR:$val1), (v4f32 MQPR:$val2))),
2580 (v4f32 (MVE_VADDf32 (v4f32 MQPR:$val1), (v4f32 MQPR:$val2)))>;
2581 def : Pat<(v8f16 (fadd (v8f16 MQPR:$val1), (v8f16 MQPR:$val2))),
2582 (v8f16 (MVE_VADDf16 (v8f16 MQPR:$val1), (v8f16 MQPR:$val2)))>;
2585 def MVE_VSUBf32 : MVE_VADDSUBFMA_fp<"vsub", "f32", 0b0, 0b0, 0b1, 0b1>;
2586 def MVE_VSUBf16 : MVE_VADDSUBFMA_fp<"vsub", "f16", 0b1, 0b0, 0b1, 0b1>;
2588 let Predicates = [HasMVEFloat] in {
2589 def : Pat<(v4f32 (fsub (v4f32 MQPR:$val1), (v4f32 MQPR:$val2))),
2590 (v4f32 (MVE_VSUBf32 (v4f32 MQPR:$val1), (v4f32 MQPR:$val2)))>;
2591 def : Pat<(v8f16 (fsub (v8f16 MQPR:$val1), (v8f16 MQPR:$val2))),
2592 (v8f16 (MVE_VSUBf16 (v8f16 MQPR:$val1), (v8f16 MQPR:$val2)))>;
2595 class MVE_VCADD<string suffix, bit size, list<dag> pattern=[]>
2596 : MVEFloatArithNeon<"vcadd", suffix, size, (outs MQPR:$Qd),
2597 (ins MQPR:$Qn, MQPR:$Qm, complexrotateopodd:$rot),
2598 "$Qd, $Qn, $Qm, $rot", vpred_r, "", pattern> {
2607 let Inst{22} = Qd{3};
2609 let Inst{19-17} = Qn{2-0};
2610 let Inst{15-13} = Qd{2-0};
2611 let Inst{12-8} = 0b01000;
2612 let Inst{7} = Qn{3};
2616 def MVE_VCADDf16 : MVE_VCADD<"f16", 0b0>;
2617 def MVE_VCADDf32 : MVE_VCADD<"f32", 0b1>;
2619 class MVE_VABD_fp<string suffix, bit size>
2620 : MVE_float<"vabd", suffix, (outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm),
2621 "$Qd, $Qn, $Qm", vpred_r, ""> {
2626 let Inst{25-23} = 0b110;
2627 let Inst{22} = Qd{3};
2629 let Inst{20} = size;
2630 let Inst{19-17} = Qn{2-0};
2632 let Inst{15-13} = Qd{2-0};
2633 let Inst{11-8} = 0b1101;
2634 let Inst{7} = Qn{3};
2638 def MVE_VABDf32 : MVE_VABD_fp<"f32", 0b0>;
2639 def MVE_VABDf16 : MVE_VABD_fp<"f16", 0b1>;
2641 class MVE_VCVT_fix<string suffix, bit fsi, bit U, bit op,
2642 Operand imm_operand_type, list<dag> pattern=[]>
2643 : MVE_float<"vcvt", suffix,
2644 (outs MQPR:$Qd), (ins MQPR:$Qm, imm_operand_type:$imm6),
2645 "$Qd, $Qm, $imm6", vpred_r, "", pattern> {
2650 let Inst{25-23} = 0b111;
2651 let Inst{22} = Qd{3};
2653 let Inst{19-16} = imm6{3-0};
2654 let Inst{15-13} = Qd{2-0};
2655 let Inst{11-10} = 0b11;
2661 let DecoderMethod = "DecodeMVEVCVTt1fp";
2664 class MVE_VCVT_imm_asmop<int Bits> : AsmOperandClass {
2665 let PredicateMethod = "isImmediate<1," # Bits # ">";
2666 let DiagnosticString =
2667 "MVE fixed-point immediate operand must be between 1 and " # Bits;
2668 let Name = "MVEVcvtImm" # Bits;
2669 let RenderMethod = "addImmOperands";
2671 class MVE_VCVT_imm<int Bits>: Operand<i32> {
2672 let ParserMatchClass = MVE_VCVT_imm_asmop<Bits>;
2673 let EncoderMethod = "getNEONVcvtImm32OpValue";
2674 let DecoderMethod = "DecodeVCVTImmOperand";
2677 class MVE_VCVT_fix_f32<string suffix, bit U, bit op>
2678 : MVE_VCVT_fix<suffix, 0b1, U, op, MVE_VCVT_imm<32>> {
2679 let Inst{20} = imm6{4};
2681 class MVE_VCVT_fix_f16<string suffix, bit U, bit op>
2682 : MVE_VCVT_fix<suffix, 0b0, U, op, MVE_VCVT_imm<16>> {
2686 def MVE_VCVTf16s16_fix : MVE_VCVT_fix_f16<"f16.s16", 0b0, 0b0>;
2687 def MVE_VCVTs16f16_fix : MVE_VCVT_fix_f16<"s16.f16", 0b0, 0b1>;
2688 def MVE_VCVTf16u16_fix : MVE_VCVT_fix_f16<"f16.u16", 0b1, 0b0>;
2689 def MVE_VCVTu16f16_fix : MVE_VCVT_fix_f16<"u16.f16", 0b1, 0b1>;
2690 def MVE_VCVTf32s32_fix : MVE_VCVT_fix_f32<"f32.s32", 0b0, 0b0>;
2691 def MVE_VCVTs32f32_fix : MVE_VCVT_fix_f32<"s32.f32", 0b0, 0b1>;
2692 def MVE_VCVTf32u32_fix : MVE_VCVT_fix_f32<"f32.u32", 0b1, 0b0>;
2693 def MVE_VCVTu32f32_fix : MVE_VCVT_fix_f32<"u32.f32", 0b1, 0b1>;
2695 class MVE_VCVT_fp_int_anpm<string suffix, bits<2> size, bit op, string anpm,
2696 bits<2> rm, list<dag> pattern=[]>
2697 : MVE_float<!strconcat("vcvt", anpm), suffix, (outs MQPR:$Qd),
2698 (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", pattern> {
2702 let Inst{25-23} = 0b111;
2703 let Inst{22} = Qd{3};
2704 let Inst{21-20} = 0b11;
2705 let Inst{19-18} = size;
2706 let Inst{17-16} = 0b11;
2707 let Inst{15-13} = Qd{2-0};
2708 let Inst{12-10} = 0b000;
2714 multiclass MVE_VCVT_fp_int_anpm_multi<string suffix, bits<2> size, bit op,
2715 list<dag> pattern=[]> {
2716 def a : MVE_VCVT_fp_int_anpm<suffix, size, op, "a", 0b00>;
2717 def n : MVE_VCVT_fp_int_anpm<suffix, size, op, "n", 0b01>;
2718 def p : MVE_VCVT_fp_int_anpm<suffix, size, op, "p", 0b10>;
2719 def m : MVE_VCVT_fp_int_anpm<suffix, size, op, "m", 0b11>;
2722 // This defines instructions such as MVE_VCVTu16f16a, with an explicit
2723 // rounding-mode suffix on the mnemonic. The class below will define
2724 // the bare MVE_VCVTu16f16 (with implied rounding toward zero).
2725 defm MVE_VCVTs16f16 : MVE_VCVT_fp_int_anpm_multi<"s16.f16", 0b01, 0b0>;
2726 defm MVE_VCVTu16f16 : MVE_VCVT_fp_int_anpm_multi<"u16.f16", 0b01, 0b1>;
2727 defm MVE_VCVTs32f32 : MVE_VCVT_fp_int_anpm_multi<"s32.f32", 0b10, 0b0>;
2728 defm MVE_VCVTu32f32 : MVE_VCVT_fp_int_anpm_multi<"u32.f32", 0b10, 0b1>;
2730 class MVE_VCVT_fp_int<string suffix, bits<2> size, bits<2> op,
2731 list<dag> pattern=[]>
2732 : MVE_float<"vcvt", suffix, (outs MQPR:$Qd),
2733 (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", pattern> {
2737 let Inst{25-23} = 0b111;
2738 let Inst{22} = Qd{3};
2739 let Inst{21-20} = 0b11;
2740 let Inst{19-18} = size;
2741 let Inst{17-16} = 0b11;
2742 let Inst{15-13} = Qd{2-0};
2743 let Inst{12-9} = 0b0011;
2748 // The unsuffixed VCVT for float->int implicitly rounds toward zero,
2749 // which I reflect here in the llvm instruction names
2750 def MVE_VCVTs16f16z : MVE_VCVT_fp_int<"s16.f16", 0b01, 0b10>;
2751 def MVE_VCVTu16f16z : MVE_VCVT_fp_int<"u16.f16", 0b01, 0b11>;
2752 def MVE_VCVTs32f32z : MVE_VCVT_fp_int<"s32.f32", 0b10, 0b10>;
2753 def MVE_VCVTu32f32z : MVE_VCVT_fp_int<"u32.f32", 0b10, 0b11>;
2754 // Whereas VCVT for int->float rounds to nearest
2755 def MVE_VCVTf16s16n : MVE_VCVT_fp_int<"f16.s16", 0b01, 0b00>;
2756 def MVE_VCVTf16u16n : MVE_VCVT_fp_int<"f16.u16", 0b01, 0b01>;
2757 def MVE_VCVTf32s32n : MVE_VCVT_fp_int<"f32.s32", 0b10, 0b00>;
2758 def MVE_VCVTf32u32n : MVE_VCVT_fp_int<"f32.u32", 0b10, 0b01>;
2760 let Predicates = [HasMVEFloat] in {
2761 def : Pat<(v4i32 (fp_to_sint (v4f32 MQPR:$src))),
2762 (v4i32 (MVE_VCVTs32f32z (v4f32 MQPR:$src)))>;
2763 def : Pat<(v4i32 (fp_to_uint (v4f32 MQPR:$src))),
2764 (v4i32 (MVE_VCVTu32f32z (v4f32 MQPR:$src)))>;
2765 def : Pat<(v8i16 (fp_to_sint (v8f16 MQPR:$src))),
2766 (v8i16 (MVE_VCVTs16f16z (v8f16 MQPR:$src)))>;
2767 def : Pat<(v8i16 (fp_to_uint (v8f16 MQPR:$src))),
2768 (v8i16 (MVE_VCVTu16f16z (v8f16 MQPR:$src)))>;
2769 def : Pat<(v4f32 (sint_to_fp (v4i32 MQPR:$src))),
2770 (v4f32 (MVE_VCVTf32s32n (v4i32 MQPR:$src)))>;
2771 def : Pat<(v4f32 (uint_to_fp (v4i32 MQPR:$src))),
2772 (v4f32 (MVE_VCVTf32u32n (v4i32 MQPR:$src)))>;
2773 def : Pat<(v8f16 (sint_to_fp (v8i16 MQPR:$src))),
2774 (v8f16 (MVE_VCVTf16s16n (v8i16 MQPR:$src)))>;
2775 def : Pat<(v8f16 (uint_to_fp (v8i16 MQPR:$src))),
2776 (v8f16 (MVE_VCVTf16u16n (v8i16 MQPR:$src)))>;
2779 class MVE_VABSNEG_fp<string iname, string suffix, bits<2> size, bit negate,
2780 list<dag> pattern=[]>
2781 : MVE_float<iname, suffix, (outs MQPR:$Qd),
2782 (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", pattern> {
2786 let Inst{25-23} = 0b111;
2787 let Inst{22} = Qd{3};
2788 let Inst{21-20} = 0b11;
2789 let Inst{19-18} = size;
2790 let Inst{17-16} = 0b01;
2791 let Inst{15-13} = Qd{2-0};
2792 let Inst{11-8} = 0b0111;
2793 let Inst{7} = negate;
2797 def MVE_VABSf16 : MVE_VABSNEG_fp<"vabs", "f16", 0b01, 0b0>;
2798 def MVE_VABSf32 : MVE_VABSNEG_fp<"vabs", "f32", 0b10, 0b0>;
2800 let Predicates = [HasMVEFloat] in {
2801 def : Pat<(v8f16 (fabs MQPR:$src)),
2802 (MVE_VABSf16 MQPR:$src)>;
2803 def : Pat<(v4f32 (fabs MQPR:$src)),
2804 (MVE_VABSf32 MQPR:$src)>;
2807 def MVE_VNEGf16 : MVE_VABSNEG_fp<"vneg", "f16", 0b01, 0b1>;
2808 def MVE_VNEGf32 : MVE_VABSNEG_fp<"vneg", "f32", 0b10, 0b1>;
2810 let Predicates = [HasMVEFloat] in {
2811 def : Pat<(v8f16 (fneg MQPR:$src)),
2812 (MVE_VNEGf16 MQPR:$src)>;
2813 def : Pat<(v4f32 (fneg MQPR:$src)),
2814 (MVE_VNEGf32 MQPR:$src)>;
2817 class MVE_VMAXMINNMA<string iname, string suffix, bit size, bit bit_12,
2818 list<dag> pattern=[]>
2819 : MVE_f<(outs MQPR:$Qd), (ins MQPR:$Qd_src, MQPR:$Qm),
2820 NoItinerary, iname, suffix, "$Qd, $Qm", vpred_n, "$Qd = $Qd_src",
2825 let Inst{28} = size;
2826 let Inst{25-23} = 0b100;
2827 let Inst{22} = Qd{3};
2828 let Inst{21-16} = 0b111111;
2829 let Inst{15-13} = Qd{2-0};
2830 let Inst{12} = bit_12;
2831 let Inst{11-6} = 0b111010;
2832 let Inst{5} = Qm{3};
2834 let Inst{3-1} = Qm{2-0};
2838 def MVE_VMAXNMAf32 : MVE_VMAXMINNMA<"vmaxnma", "f32", 0b0, 0b0>;
2839 def MVE_VMAXNMAf16 : MVE_VMAXMINNMA<"vmaxnma", "f16", 0b1, 0b0>;
2841 def MVE_VMINNMAf32 : MVE_VMAXMINNMA<"vminnma", "f32", 0b0, 0b1>;
2842 def MVE_VMINNMAf16 : MVE_VMAXMINNMA<"vminnma", "f16", 0b1, 0b1>;
2844 // end of MVE Floating Point instructions
2846 // start of MVE compares
2848 class MVE_VCMPqq<string suffix, bit bit_28, bits<2> bits_21_20,
2849 VCMPPredicateOperand predtype, list<dag> pattern=[]>
2850 : MVE_p<(outs VCCR:$P0), (ins MQPR:$Qn, MQPR:$Qm, predtype:$fc),
2851 NoItinerary, "vcmp", suffix, "$fc, $Qn, $Qm", vpred_n, "", pattern> {
2852 // Base class for comparing two vector registers
2857 let Inst{28} = bit_28;
2858 let Inst{25-22} = 0b1000;
2859 let Inst{21-20} = bits_21_20;
2860 let Inst{19-17} = Qn{2-0};
2861 let Inst{16-13} = 0b1000;
2862 let Inst{12} = fc{2};
2863 let Inst{11-8} = 0b1111;
2864 let Inst{7} = fc{0};
2866 let Inst{5} = Qm{3};
2868 let Inst{3-1} = Qm{2-0};
2869 let Inst{0} = fc{1};
2871 let Constraints = "";
2873 // We need a custom decoder method for these instructions because of
2874 // the output VCCR operand, which isn't encoded in the instruction
2875 // bits anywhere (there is only one choice for it) but has to be
2876 // included in the MC operands so that codegen will be able to track
2877 // its data flow between instructions, spill/reload it when
2878 // necessary, etc. There seems to be no way to get the Tablegen
2879 // decoder to emit an operand that isn't affected by any instruction
2881 let DecoderMethod = "DecodeMVEVCMP<false," # predtype.DecoderMethod # ">";
2884 class MVE_VCMPqqf<string suffix, bit size>
2885 : MVE_VCMPqq<suffix, size, 0b11, pred_basic_fp> {
2886 let Predicates = [HasMVEFloat];
2889 class MVE_VCMPqqi<string suffix, bits<2> size>
2890 : MVE_VCMPqq<suffix, 0b1, size, pred_basic_i> {
2895 class MVE_VCMPqqu<string suffix, bits<2> size>
2896 : MVE_VCMPqq<suffix, 0b1, size, pred_basic_u> {
2901 class MVE_VCMPqqs<string suffix, bits<2> size>
2902 : MVE_VCMPqq<suffix, 0b1, size, pred_basic_s> {
2906 def MVE_VCMPf32 : MVE_VCMPqqf<"f32", 0b0>;
2907 def MVE_VCMPf16 : MVE_VCMPqqf<"f16", 0b1>;
2909 def MVE_VCMPi8 : MVE_VCMPqqi<"i8", 0b00>;
2910 def MVE_VCMPi16 : MVE_VCMPqqi<"i16", 0b01>;
2911 def MVE_VCMPi32 : MVE_VCMPqqi<"i32", 0b10>;
2913 def MVE_VCMPu8 : MVE_VCMPqqu<"u8", 0b00>;
2914 def MVE_VCMPu16 : MVE_VCMPqqu<"u16", 0b01>;
2915 def MVE_VCMPu32 : MVE_VCMPqqu<"u32", 0b10>;
2917 def MVE_VCMPs8 : MVE_VCMPqqs<"s8", 0b00>;
2918 def MVE_VCMPs16 : MVE_VCMPqqs<"s16", 0b01>;
2919 def MVE_VCMPs32 : MVE_VCMPqqs<"s32", 0b10>;
2921 class MVE_VCMPqr<string suffix, bit bit_28, bits<2> bits_21_20,
2922 VCMPPredicateOperand predtype, list<dag> pattern=[]>
2923 : MVE_p<(outs VCCR:$P0), (ins MQPR:$Qn, GPRwithZR:$Rm, predtype:$fc),
2924 NoItinerary, "vcmp", suffix, "$fc, $Qn, $Rm", vpred_n, "", pattern> {
2925 // Base class for comparing a vector register with a scalar
2930 let Inst{28} = bit_28;
2931 let Inst{25-22} = 0b1000;
2932 let Inst{21-20} = bits_21_20;
2933 let Inst{19-17} = Qn{2-0};
2934 let Inst{16-13} = 0b1000;
2935 let Inst{12} = fc{2};
2936 let Inst{11-8} = 0b1111;
2937 let Inst{7} = fc{0};
2939 let Inst{5} = fc{1};
2941 let Inst{3-0} = Rm{3-0};
2943 let Constraints = "";
2944 // Custom decoder method, for the same reason as MVE_VCMPqq
2945 let DecoderMethod = "DecodeMVEVCMP<true," # predtype.DecoderMethod # ">";
2948 class MVE_VCMPqrf<string suffix, bit size>
2949 : MVE_VCMPqr<suffix, size, 0b11, pred_basic_fp> {
2950 let Predicates = [HasMVEFloat];
2953 class MVE_VCMPqri<string suffix, bits<2> size>
2954 : MVE_VCMPqr<suffix, 0b1, size, pred_basic_i> {
2959 class MVE_VCMPqru<string suffix, bits<2> size>
2960 : MVE_VCMPqr<suffix, 0b1, size, pred_basic_u> {
2965 class MVE_VCMPqrs<string suffix, bits<2> size>
2966 : MVE_VCMPqr<suffix, 0b1, size, pred_basic_s> {
2970 def MVE_VCMPf32r : MVE_VCMPqrf<"f32", 0b0>;
2971 def MVE_VCMPf16r : MVE_VCMPqrf<"f16", 0b1>;
2973 def MVE_VCMPi8r : MVE_VCMPqri<"i8", 0b00>;
2974 def MVE_VCMPi16r : MVE_VCMPqri<"i16", 0b01>;
2975 def MVE_VCMPi32r : MVE_VCMPqri<"i32", 0b10>;
2977 def MVE_VCMPu8r : MVE_VCMPqru<"u8", 0b00>;
2978 def MVE_VCMPu16r : MVE_VCMPqru<"u16", 0b01>;
2979 def MVE_VCMPu32r : MVE_VCMPqru<"u32", 0b10>;
2981 def MVE_VCMPs8r : MVE_VCMPqrs<"s8", 0b00>;
2982 def MVE_VCMPs16r : MVE_VCMPqrs<"s16", 0b01>;
2983 def MVE_VCMPs32r : MVE_VCMPqrs<"s32", 0b10>;
2985 multiclass unpred_vcmp_z<SDPatternOperator opnode, string suffix, int fc> {
2986 def i8 : Pat<(v16i1 (opnode (v16i8 MQPR:$v1))),
2987 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), ZR, fc))>;
2988 def i16 : Pat<(v8i1 (opnode (v8i16 MQPR:$v1))),
2989 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), ZR, fc))>;
2990 def i32 : Pat<(v4i1 (opnode (v4i32 MQPR:$v1))),
2991 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), ZR, fc))>;
2993 def : Pat<(v16i1 (and (v16i1 VCCR:$p1), (v16i1 (opnode (v16i8 MQPR:$v1))))),
2994 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), ZR, fc, 1, VCCR:$p1))>;
2995 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (opnode (v8i16 MQPR:$v1))))),
2996 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), ZR, fc, 1, VCCR:$p1))>;
2997 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (opnode (v4i32 MQPR:$v1))))),
2998 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), ZR, fc, 1, VCCR:$p1))>;
3001 multiclass unpred_vcmp_r<SDPatternOperator opnode, string suffix, int fc> {
3002 def i8 : Pat<(v16i1 (opnode (v16i8 MQPR:$v1), (v16i8 MQPR:$v2))),
3003 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8") (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), fc))>;
3004 def i16 : Pat<(v8i1 (opnode (v8i16 MQPR:$v1), (v8i16 MQPR:$v2))),
3005 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16") (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), fc))>;
3006 def i32 : Pat<(v4i1 (opnode (v4i32 MQPR:$v1), (v4i32 MQPR:$v2))),
3007 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32") (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), fc))>;
3009 def i8r : Pat<(v16i1 (opnode (v16i8 MQPR:$v1), (v16i8 (ARMvdup GPR:$v2)))),
3010 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), (i32 GPR:$v2), fc))>;
3011 def i16r : Pat<(v8i1 (opnode (v8i16 MQPR:$v1), (v8i16 (ARMvdup GPR:$v2)))),
3012 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), (i32 GPR:$v2), fc))>;
3013 def i32r : Pat<(v4i1 (opnode (v4i32 MQPR:$v1), (v4i32 (ARMvdup GPR:$v2)))),
3014 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), (i32 GPR:$v2), fc))>;
3016 def : Pat<(v16i1 (and (v16i1 VCCR:$p1), (v16i1 (opnode (v16i8 MQPR:$v1), (v16i8 MQPR:$v2))))),
3017 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8") (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), fc, 1, VCCR:$p1))>;
3018 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (opnode (v8i16 MQPR:$v1), (v8i16 MQPR:$v2))))),
3019 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16") (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), fc, 1, VCCR:$p1))>;
3020 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (opnode (v4i32 MQPR:$v1), (v4i32 MQPR:$v2))))),
3021 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32") (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), fc, 1, VCCR:$p1))>;
3024 multiclass unpred_vcmpf_z<SDPatternOperator opnode, int fc> {
3025 def f16 : Pat<(v8i1 (opnode (v8f16 MQPR:$v1))),
3026 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), ZR, fc))>;
3027 def f32 : Pat<(v4i1 (opnode (v4f32 MQPR:$v1))),
3028 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, fc))>;
3030 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (opnode (v8f16 MQPR:$v1))))),
3031 (v8i1 (MVE_VCMPf32r (v8f16 MQPR:$v1), ZR, fc, 1, VCCR:$p1))>;
3032 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (opnode (v4f32 MQPR:$v1))))),
3033 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, fc, 1, VCCR:$p1))>;
3036 multiclass unpred_vcmpf_r<SDPatternOperator opnode, int fc> {
3037 def f16 : Pat<(v8i1 (opnode (v8f16 MQPR:$v1), (v8f16 MQPR:$v2))),
3038 (v8i1 (MVE_VCMPf16 (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), fc))>;
3039 def f32 : Pat<(v4i1 (opnode (v4f32 MQPR:$v1), (v4f32 MQPR:$v2))),
3040 (v4i1 (MVE_VCMPf32 (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), fc))>;
3042 def f16r : Pat<(v8i1 (opnode (v8f16 MQPR:$v1), (v8f16 (ARMvdup HPR:$v2)))),
3043 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), (i32 (COPY_TO_REGCLASS (f16 HPR:$v2), rGPR)), fc))>;
3044 def f32r : Pat<(v4i1 (opnode (v4f32 MQPR:$v1), (v4f32 (ARMvdup SPR:$v2)))),
3045 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), (i32 (COPY_TO_REGCLASS (f32 SPR:$v2), rGPR)), fc))>;
3047 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (opnode (v8f16 MQPR:$v1), (v8f16 MQPR:$v2))))),
3048 (v8i1 (MVE_VCMPf16 (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), fc, 1, VCCR:$p1))>;
3049 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (opnode (v4f32 MQPR:$v1), (v4f32 MQPR:$v2))))),
3050 (v4i1 (MVE_VCMPf32 (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), fc, 1, VCCR:$p1))>;
3053 let Predicates = [HasMVEInt] in {
3054 defm MVE_VCEQZ : unpred_vcmp_z<ARMvceqz, "i", 0>;
3055 defm MVE_VCNEZ : unpred_vcmp_z<ARMvcnez, "i", 1>;
3056 defm MVE_VCGEZ : unpred_vcmp_z<ARMvcgez, "s", 10>;
3057 defm MVE_VCLTZ : unpred_vcmp_z<ARMvcltz, "s", 11>;
3058 defm MVE_VCGTZ : unpred_vcmp_z<ARMvcgtz, "s", 12>;
3059 defm MVE_VCLEZ : unpred_vcmp_z<ARMvclez, "s", 13>;
3061 defm MVE_VCEQ : unpred_vcmp_r<ARMvceq, "i", 0>;
3062 defm MVE_VCNE : unpred_vcmp_r<ARMvcne, "i", 1>;
3063 defm MVE_VCGE : unpred_vcmp_r<ARMvcge, "s", 10>;
3064 defm MVE_VCLT : unpred_vcmp_r<ARMvclt, "s", 11>;
3065 defm MVE_VCGT : unpred_vcmp_r<ARMvcgt, "s", 12>;
3066 defm MVE_VCLE : unpred_vcmp_r<ARMvcle, "s", 13>;
3067 defm MVE_VCGTU : unpred_vcmp_r<ARMvcgtu, "u", 8>;
3068 defm MVE_VCGEU : unpred_vcmp_r<ARMvcgeu, "u", 2>;
3071 let Predicates = [HasMVEFloat] in {
3072 defm MVE_VFCEQZ : unpred_vcmpf_z<ARMvceqz, 0>;
3073 defm MVE_VFCNEZ : unpred_vcmpf_z<ARMvcnez, 1>;
3074 defm MVE_VFCGEZ : unpred_vcmpf_z<ARMvcgez, 10>;
3075 defm MVE_VFCLTZ : unpred_vcmpf_z<ARMvcltz, 11>;
3076 defm MVE_VFCGTZ : unpred_vcmpf_z<ARMvcgtz, 12>;
3077 defm MVE_VFCLEZ : unpred_vcmpf_z<ARMvclez, 13>;
3079 defm MVE_VFCGE : unpred_vcmpf_r<ARMvcge, 10>;
3080 defm MVE_VFCLT : unpred_vcmpf_r<ARMvclt, 11>;
3081 defm MVE_VFCGT : unpred_vcmpf_r<ARMvcgt, 12>;
3082 defm MVE_VFCLE : unpred_vcmpf_r<ARMvcle, 13>;
3083 defm MVE_VFCEQ : unpred_vcmpf_r<ARMvceq, 0>;
3084 defm MVE_VFCNE : unpred_vcmpf_r<ARMvcne, 1>;
3088 // Extra "worst case" and/or/xor partterns, going into and out of GRP
3089 multiclass two_predops<SDPatternOperator opnode, Instruction insn> {
3090 def v16i1 : Pat<(v16i1 (opnode (v16i1 VCCR:$p1), (v16i1 VCCR:$p2))),
3091 (v16i1 (COPY_TO_REGCLASS
3092 (insn (i32 (COPY_TO_REGCLASS (v16i1 VCCR:$p1), rGPR)),
3093 (i32 (COPY_TO_REGCLASS (v16i1 VCCR:$p2), rGPR))),
3095 def v8i1 : Pat<(v8i1 (opnode (v8i1 VCCR:$p1), (v8i1 VCCR:$p2))),
3096 (v8i1 (COPY_TO_REGCLASS
3097 (insn (i32 (COPY_TO_REGCLASS (v8i1 VCCR:$p1), rGPR)),
3098 (i32 (COPY_TO_REGCLASS (v8i1 VCCR:$p2), rGPR))),
3100 def v4i1 : Pat<(v4i1 (opnode (v4i1 VCCR:$p1), (v4i1 VCCR:$p2))),
3101 (v4i1 (COPY_TO_REGCLASS
3102 (insn (i32 (COPY_TO_REGCLASS (v4i1 VCCR:$p1), rGPR)),
3103 (i32 (COPY_TO_REGCLASS (v4i1 VCCR:$p2), rGPR))),
3107 let Predicates = [HasMVEInt] in {
3108 defm POR : two_predops<or, t2ORRrr>;
3109 defm PAND : two_predops<and, t2ANDrr>;
3110 defm PEOR : two_predops<xor, t2EORrr>;
3113 // Occasionally we need to cast between a i32 and a boolean vector, for
3114 // example when moving between rGPR and VPR.P0 as part of predicate vector
3115 // shuffles. We also sometimes need to cast between different predicate
3116 // vector types (v4i1<>v8i1, etc.) also as part of lowering vector shuffles.
3118 def predicate_cast : SDNode<"ARMISD::PREDICATE_CAST", SDTUnaryOp>;
3120 let Predicates = [HasMVEInt] in {
3121 foreach VT = [ v4i1, v8i1, v16i1 ] in {
3122 def : Pat<(i32 (predicate_cast (VT VCCR:$src))),
3123 (i32 (COPY_TO_REGCLASS (VT VCCR:$src), VCCR))>;
3124 def : Pat<(VT (predicate_cast (i32 VCCR:$src))),
3125 (VT (COPY_TO_REGCLASS (i32 VCCR:$src), VCCR))>;
3127 foreach VT2 = [ v4i1, v8i1, v16i1 ] in
3128 def : Pat<(VT (predicate_cast (VT2 VCCR:$src))),
3129 (VT (COPY_TO_REGCLASS (VT2 VCCR:$src), VCCR))>;
3133 // end of MVE compares
3135 // start of MVE_qDest_qSrc
3137 class MVE_qDest_qSrc<string iname, string suffix, dag oops, dag iops,
3138 string ops, vpred_ops vpred, string cstr,
3139 list<dag> pattern=[]>
3140 : MVE_p<oops, iops, NoItinerary, iname, suffix,
3141 ops, vpred, cstr, pattern> {
3145 let Inst{25-23} = 0b100;
3146 let Inst{22} = Qd{3};
3147 let Inst{15-13} = Qd{2-0};
3148 let Inst{11-9} = 0b111;
3150 let Inst{5} = Qm{3};
3152 let Inst{3-1} = Qm{2-0};
3155 class MVE_VQxDMLxDH<string iname, bit exch, bit round, bit subtract,
3156 string suffix, bits<2> size, list<dag> pattern=[]>
3157 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
3158 (ins MQPR:$Qd_src, MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm",
3159 vpred_n, "$Qd = $Qd_src", pattern> {
3162 let Inst{28} = subtract;
3163 let Inst{21-20} = size;
3164 let Inst{19-17} = Qn{2-0};
3166 let Inst{12} = exch;
3168 let Inst{7} = Qn{3};
3169 let Inst{0} = round;
3172 multiclass MVE_VQxDMLxDH_multi<string iname, bit exch,
3173 bit round, bit subtract> {
3174 def s8 : MVE_VQxDMLxDH<iname, exch, round, subtract, "s8", 0b00>;
3175 def s16 : MVE_VQxDMLxDH<iname, exch, round, subtract, "s16", 0b01>;
3176 def s32 : MVE_VQxDMLxDH<iname, exch, round, subtract, "s32", 0b10>;
3179 defm MVE_VQDMLADH : MVE_VQxDMLxDH_multi<"vqdmladh", 0b0, 0b0, 0b0>;
3180 defm MVE_VQDMLADHX : MVE_VQxDMLxDH_multi<"vqdmladhx", 0b1, 0b0, 0b0>;
3181 defm MVE_VQRDMLADH : MVE_VQxDMLxDH_multi<"vqrdmladh", 0b0, 0b1, 0b0>;
3182 defm MVE_VQRDMLADHX : MVE_VQxDMLxDH_multi<"vqrdmladhx", 0b1, 0b1, 0b0>;
3183 defm MVE_VQDMLSDH : MVE_VQxDMLxDH_multi<"vqdmlsdh", 0b0, 0b0, 0b1>;
3184 defm MVE_VQDMLSDHX : MVE_VQxDMLxDH_multi<"vqdmlsdhx", 0b1, 0b0, 0b1>;
3185 defm MVE_VQRDMLSDH : MVE_VQxDMLxDH_multi<"vqrdmlsdh", 0b0, 0b1, 0b1>;
3186 defm MVE_VQRDMLSDHX : MVE_VQxDMLxDH_multi<"vqrdmlsdhx", 0b1, 0b1, 0b1>;
3188 class MVE_VCMUL<string iname, string suffix, bit size, list<dag> pattern=[]>
3189 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
3190 (ins MQPR:$Qn, MQPR:$Qm, complexrotateop:$rot),
3191 "$Qd, $Qn, $Qm, $rot", vpred_r, "", pattern> {
3195 let Inst{28} = size;
3196 let Inst{21-20} = 0b11;
3197 let Inst{19-17} = Qn{2-0};
3199 let Inst{12} = rot{1};
3201 let Inst{7} = Qn{3};
3202 let Inst{0} = rot{0};
3204 let Predicates = [HasMVEFloat];
3207 def MVE_VCMULf16 : MVE_VCMUL<"vcmul", "f16", 0b0>;
3208 def MVE_VCMULf32 : MVE_VCMUL<"vcmul", "f32", 0b1>;
3210 class MVE_VMULL<string iname, string suffix, bit bit_28, bits<2> bits_21_20,
3211 bit T, list<dag> pattern=[]>
3212 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
3213 (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm",
3214 vpred_r, "", pattern> {
3219 let Inst{28} = bit_28;
3220 let Inst{21-20} = bits_21_20;
3221 let Inst{19-17} = Qn{2-0};
3225 let Inst{7} = Qn{3};
3229 multiclass MVE_VMULL_multi<string iname, string suffix,
3230 bit bit_28, bits<2> bits_21_20> {
3231 def bh : MVE_VMULL<iname # "b", suffix, bit_28, bits_21_20, 0b0>;
3232 def th : MVE_VMULL<iname # "t", suffix, bit_28, bits_21_20, 0b1>;
3235 // For integer multiplies, bits 21:20 encode size, and bit 28 signedness.
3236 // For polynomial multiplies, bits 21:20 take the unused value 0b11, and
3237 // bit 28 switches to encoding the size.
3239 defm MVE_VMULLs8 : MVE_VMULL_multi<"vmull", "s8", 0b0, 0b00>;
3240 defm MVE_VMULLs16 : MVE_VMULL_multi<"vmull", "s16", 0b0, 0b01>;
3241 defm MVE_VMULLs32 : MVE_VMULL_multi<"vmull", "s32", 0b0, 0b10>;
3242 defm MVE_VMULLu8 : MVE_VMULL_multi<"vmull", "u8", 0b1, 0b00>;
3243 defm MVE_VMULLu16 : MVE_VMULL_multi<"vmull", "u16", 0b1, 0b01>;
3244 defm MVE_VMULLu32 : MVE_VMULL_multi<"vmull", "u32", 0b1, 0b10>;
3245 defm MVE_VMULLp8 : MVE_VMULL_multi<"vmull", "p8", 0b0, 0b11>;
3246 defm MVE_VMULLp16 : MVE_VMULL_multi<"vmull", "p16", 0b1, 0b11>;
3248 class MVE_VxMULH<string iname, string suffix, bit U, bits<2> size,
3249 bit round, list<dag> pattern=[]>
3250 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
3251 (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm",
3252 vpred_r, "", pattern> {
3256 let Inst{21-20} = size;
3257 let Inst{19-17} = Qn{2-0};
3259 let Inst{12} = round;
3261 let Inst{7} = Qn{3};
3265 def MVE_VMULHs8 : MVE_VxMULH<"vmulh", "s8", 0b0, 0b00, 0b0>;
3266 def MVE_VMULHs16 : MVE_VxMULH<"vmulh", "s16", 0b0, 0b01, 0b0>;
3267 def MVE_VMULHs32 : MVE_VxMULH<"vmulh", "s32", 0b0, 0b10, 0b0>;
3268 def MVE_VMULHu8 : MVE_VxMULH<"vmulh", "u8", 0b1, 0b00, 0b0>;
3269 def MVE_VMULHu16 : MVE_VxMULH<"vmulh", "u16", 0b1, 0b01, 0b0>;
3270 def MVE_VMULHu32 : MVE_VxMULH<"vmulh", "u32", 0b1, 0b10, 0b0>;
3272 def MVE_VRMULHs8 : MVE_VxMULH<"vrmulh", "s8", 0b0, 0b00, 0b1>;
3273 def MVE_VRMULHs16 : MVE_VxMULH<"vrmulh", "s16", 0b0, 0b01, 0b1>;
3274 def MVE_VRMULHs32 : MVE_VxMULH<"vrmulh", "s32", 0b0, 0b10, 0b1>;
3275 def MVE_VRMULHu8 : MVE_VxMULH<"vrmulh", "u8", 0b1, 0b00, 0b1>;
3276 def MVE_VRMULHu16 : MVE_VxMULH<"vrmulh", "u16", 0b1, 0b01, 0b1>;
3277 def MVE_VRMULHu32 : MVE_VxMULH<"vrmulh", "u32", 0b1, 0b10, 0b1>;
3279 class MVE_VxMOVxN<string iname, string suffix, bit bit_28, bit bit_17,
3280 bits<2> size, bit T, list<dag> pattern=[]>
3281 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
3282 (ins MQPR:$Qd_src, MQPR:$Qm), "$Qd, $Qm",
3283 vpred_n, "$Qd = $Qd_src", pattern> {
3285 let Inst{28} = bit_28;
3286 let Inst{21-20} = 0b11;
3287 let Inst{19-18} = size;
3288 let Inst{17} = bit_17;
3292 let Inst{7} = !if(!eq(bit_17, 0), 1, 0);
3296 multiclass MVE_VxMOVxN_halves<string iname, string suffix,
3297 bit bit_28, bit bit_17, bits<2> size> {
3298 def bh : MVE_VxMOVxN<iname # "b", suffix, bit_28, bit_17, size, 0b0>;
3299 def th : MVE_VxMOVxN<iname # "t", suffix, bit_28, bit_17, size, 0b1>;
3302 defm MVE_VMOVNi16 : MVE_VxMOVxN_halves<"vmovn", "i16", 0b1, 0b0, 0b00>;
3303 defm MVE_VMOVNi32 : MVE_VxMOVxN_halves<"vmovn", "i32", 0b1, 0b0, 0b01>;
3304 defm MVE_VQMOVNs16 : MVE_VxMOVxN_halves<"vqmovn", "s16", 0b0, 0b1, 0b00>;
3305 defm MVE_VQMOVNs32 : MVE_VxMOVxN_halves<"vqmovn", "s32", 0b0, 0b1, 0b01>;
3306 defm MVE_VQMOVNu16 : MVE_VxMOVxN_halves<"vqmovn", "u16", 0b1, 0b1, 0b00>;
3307 defm MVE_VQMOVNu32 : MVE_VxMOVxN_halves<"vqmovn", "u32", 0b1, 0b1, 0b01>;
3308 defm MVE_VQMOVUNs16 : MVE_VxMOVxN_halves<"vqmovun", "s16", 0b0, 0b0, 0b00>;
3309 defm MVE_VQMOVUNs32 : MVE_VxMOVxN_halves<"vqmovun", "s32", 0b0, 0b0, 0b01>;
3311 class MVE_VCVT_ff<string iname, string suffix, bit op, bit T,
3312 list<dag> pattern=[]>
3313 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd), (ins MQPR:$Qd_src, MQPR:$Qm),
3314 "$Qd, $Qm", vpred_n, "$Qd = $Qd_src", pattern> {
3316 let Inst{21-16} = 0b111111;
3318 let Inst{8-7} = 0b00;
3321 let Predicates = [HasMVEFloat];
3324 multiclass MVE_VCVT_ff_halves<string suffix, bit op> {
3325 def bh : MVE_VCVT_ff<"vcvtb", suffix, op, 0b0>;
3326 def th : MVE_VCVT_ff<"vcvtt", suffix, op, 0b1>;
3329 defm MVE_VCVTf16f32 : MVE_VCVT_ff_halves<"f16.f32", 0b0>;
3330 defm MVE_VCVTf32f16 : MVE_VCVT_ff_halves<"f32.f16", 0b1>;
3332 class MVE_VxCADD<string iname, string suffix, bits<2> size, bit halve,
3333 list<dag> pattern=[]>
3334 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
3335 (ins MQPR:$Qn, MQPR:$Qm, complexrotateopodd:$rot),
3336 "$Qd, $Qn, $Qm, $rot", vpred_r, "",
3341 let Inst{28} = halve;
3342 let Inst{21-20} = size;
3343 let Inst{19-17} = Qn{2-0};
3347 let Inst{7} = Qn{3};
3351 def MVE_VCADDi8 : MVE_VxCADD<"vcadd", "i8", 0b00, 0b1>;
3352 def MVE_VCADDi16 : MVE_VxCADD<"vcadd", "i16", 0b01, 0b1>;
3353 def MVE_VCADDi32 : MVE_VxCADD<"vcadd", "i32", 0b10, 0b1>;
3355 def MVE_VHCADDs8 : MVE_VxCADD<"vhcadd", "s8", 0b00, 0b0>;
3356 def MVE_VHCADDs16 : MVE_VxCADD<"vhcadd", "s16", 0b01, 0b0>;
3357 def MVE_VHCADDs32 : MVE_VxCADD<"vhcadd", "s32", 0b10, 0b0>;
3359 class MVE_VADCSBC<string iname, bit I, bit subtract,
3360 dag carryin, list<dag> pattern=[]>
3361 : MVE_qDest_qSrc<iname, "i32", (outs MQPR:$Qd, cl_FPSCR_NZCV:$carryout),
3362 !con((ins MQPR:$Qn, MQPR:$Qm), carryin),
3363 "$Qd, $Qn, $Qm", vpred_r, "", pattern> {
3366 let Inst{28} = subtract;
3367 let Inst{21-20} = 0b11;
3368 let Inst{19-17} = Qn{2-0};
3372 let Inst{7} = Qn{3};
3375 // Custom decoder method in order to add the FPSCR operand(s), which
3376 // Tablegen won't do right
3377 let DecoderMethod = "DecodeMVEVADCInstruction";
3380 def MVE_VADC : MVE_VADCSBC<"vadc", 0b0, 0b0, (ins cl_FPSCR_NZCV:$carryin)>;
3381 def MVE_VADCI : MVE_VADCSBC<"vadci", 0b1, 0b0, (ins)>;
3383 def MVE_VSBC : MVE_VADCSBC<"vsbc", 0b0, 0b1, (ins cl_FPSCR_NZCV:$carryin)>;
3384 def MVE_VSBCI : MVE_VADCSBC<"vsbci", 0b1, 0b1, (ins)>;
3386 class MVE_VQDMULL<string iname, string suffix, bit size, bit T,
3387 list<dag> pattern=[]>
3388 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
3389 (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm",
3390 vpred_r, "", pattern> {
3393 let Inst{28} = size;
3394 let Inst{21-20} = 0b11;
3395 let Inst{19-17} = Qn{2-0};
3399 let Inst{7} = Qn{3};
3403 multiclass MVE_VQDMULL_halves<string suffix, bit size> {
3404 def bh : MVE_VQDMULL<"vqdmullb", suffix, size, 0b0>;
3405 def th : MVE_VQDMULL<"vqdmullt", suffix, size, 0b1>;
3408 defm MVE_VQDMULLs16 : MVE_VQDMULL_halves<"s16", 0b0>;
3409 defm MVE_VQDMULLs32 : MVE_VQDMULL_halves<"s32", 0b1>;
3411 // end of mve_qDest_qSrc
3413 // start of mve_qDest_rSrc
3415 class MVE_qr_base<dag oops, dag iops, InstrItinClass itin, string iname,
3416 string suffix, string ops, vpred_ops vpred, string cstr,
3417 list<dag> pattern=[]>
3418 : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, pattern> {
3423 let Inst{25-23} = 0b100;
3424 let Inst{22} = Qd{3};
3425 let Inst{19-17} = Qn{2-0};
3426 let Inst{15-13} = Qd{2-0};
3427 let Inst{11-9} = 0b111;
3428 let Inst{7} = Qn{3};
3431 let Inst{3-0} = Rm{3-0};
3434 class MVE_qDest_rSrc<string iname, string suffix, list<dag> pattern=[]>
3435 : MVE_qr_base<(outs MQPR:$Qd), (ins MQPR:$Qn, rGPR:$Rm),
3436 NoItinerary, iname, suffix, "$Qd, $Qn, $Rm", vpred_r, "",
3439 class MVE_qDestSrc_rSrc<string iname, string suffix, list<dag> pattern=[]>
3440 : MVE_qr_base<(outs MQPR:$Qd), (ins MQPR:$Qd_src, MQPR:$Qn, rGPR:$Rm),
3441 NoItinerary, iname, suffix, "$Qd, $Qn, $Rm", vpred_n, "$Qd = $Qd_src",
3444 class MVE_qDest_single_rSrc<string iname, string suffix, list<dag> pattern=[]>
3445 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qd_src, rGPR:$Rm), NoItinerary, iname,
3446 suffix, "$Qd, $Rm", vpred_n, "$Qd = $Qd_src", pattern> {
3450 let Inst{22} = Qd{3};
3451 let Inst{15-13} = Qd{2-0};
3452 let Inst{3-0} = Rm{3-0};
3455 class MVE_VADDSUB_qr<string iname, string suffix, bits<2> size,
3456 bit bit_5, bit bit_12, bit bit_16,
3457 bit bit_28, list<dag> pattern=[]>
3458 : MVE_qDest_rSrc<iname, suffix, pattern> {
3460 let Inst{28} = bit_28;
3461 let Inst{21-20} = size;
3462 let Inst{16} = bit_16;
3463 let Inst{12} = bit_12;
3465 let Inst{5} = bit_5;
3468 multiclass MVE_VADDSUB_qr_sizes<string iname, string suffix,
3469 bit bit_5, bit bit_12, bit bit_16,
3470 bit bit_28, list<dag> pattern=[]> {
3471 def "8" : MVE_VADDSUB_qr<iname, suffix#"8", 0b00,
3472 bit_5, bit_12, bit_16, bit_28>;
3473 def "16" : MVE_VADDSUB_qr<iname, suffix#"16", 0b01,
3474 bit_5, bit_12, bit_16, bit_28>;
3475 def "32" : MVE_VADDSUB_qr<iname, suffix#"32", 0b10,
3476 bit_5, bit_12, bit_16, bit_28>;
3479 defm MVE_VADD_qr_i : MVE_VADDSUB_qr_sizes<"vadd", "i", 0b0, 0b0, 0b1, 0b0>;
3480 defm MVE_VQADD_qr_s : MVE_VADDSUB_qr_sizes<"vqadd", "s", 0b1, 0b0, 0b0, 0b0>;
3481 defm MVE_VQADD_qr_u : MVE_VADDSUB_qr_sizes<"vqadd", "u", 0b1, 0b0, 0b0, 0b1>;
3483 defm MVE_VSUB_qr_i : MVE_VADDSUB_qr_sizes<"vsub", "i", 0b0, 0b1, 0b1, 0b0>;
3484 defm MVE_VQSUB_qr_s : MVE_VADDSUB_qr_sizes<"vqsub", "s", 0b1, 0b1, 0b0, 0b0>;
3485 defm MVE_VQSUB_qr_u : MVE_VADDSUB_qr_sizes<"vqsub", "u", 0b1, 0b1, 0b0, 0b1>;
3487 class MVE_VQDMULL_qr<string iname, string suffix, bit size,
3488 bit T, list<dag> pattern=[]>
3489 : MVE_qDest_rSrc<iname, suffix, pattern> {
3491 let Inst{28} = size;
3492 let Inst{21-20} = 0b11;
3499 multiclass MVE_VQDMULL_qr_halves<string suffix, bit size> {
3500 def bh : MVE_VQDMULL_qr<"vqdmullb", suffix, size, 0b0>;
3501 def th : MVE_VQDMULL_qr<"vqdmullt", suffix, size, 0b1>;
3504 defm MVE_VQDMULL_qr_s16 : MVE_VQDMULL_qr_halves<"s16", 0b0>;
3505 defm MVE_VQDMULL_qr_s32 : MVE_VQDMULL_qr_halves<"s32", 0b1>;
3507 class MVE_VxADDSUB_qr<string iname, string suffix,
3508 bit bit_28, bits<2> bits_21_20, bit subtract,
3509 list<dag> pattern=[]>
3510 : MVE_qDest_rSrc<iname, suffix, pattern> {
3512 let Inst{28} = bit_28;
3513 let Inst{21-20} = bits_21_20;
3515 let Inst{12} = subtract;
3520 def MVE_VHADD_qr_s8 : MVE_VxADDSUB_qr<"vhadd", "s8", 0b0, 0b00, 0b0>;
3521 def MVE_VHADD_qr_s16 : MVE_VxADDSUB_qr<"vhadd", "s16", 0b0, 0b01, 0b0>;
3522 def MVE_VHADD_qr_s32 : MVE_VxADDSUB_qr<"vhadd", "s32", 0b0, 0b10, 0b0>;
3523 def MVE_VHADD_qr_u8 : MVE_VxADDSUB_qr<"vhadd", "u8", 0b1, 0b00, 0b0>;
3524 def MVE_VHADD_qr_u16 : MVE_VxADDSUB_qr<"vhadd", "u16", 0b1, 0b01, 0b0>;
3525 def MVE_VHADD_qr_u32 : MVE_VxADDSUB_qr<"vhadd", "u32", 0b1, 0b10, 0b0>;
3527 def MVE_VHSUB_qr_s8 : MVE_VxADDSUB_qr<"vhsub", "s8", 0b0, 0b00, 0b1>;
3528 def MVE_VHSUB_qr_s16 : MVE_VxADDSUB_qr<"vhsub", "s16", 0b0, 0b01, 0b1>;
3529 def MVE_VHSUB_qr_s32 : MVE_VxADDSUB_qr<"vhsub", "s32", 0b0, 0b10, 0b1>;
3530 def MVE_VHSUB_qr_u8 : MVE_VxADDSUB_qr<"vhsub", "u8", 0b1, 0b00, 0b1>;
3531 def MVE_VHSUB_qr_u16 : MVE_VxADDSUB_qr<"vhsub", "u16", 0b1, 0b01, 0b1>;
3532 def MVE_VHSUB_qr_u32 : MVE_VxADDSUB_qr<"vhsub", "u32", 0b1, 0b10, 0b1>;
3534 let Predicates = [HasMVEFloat] in {
3535 def MVE_VADD_qr_f32 : MVE_VxADDSUB_qr<"vadd", "f32", 0b0, 0b11, 0b0>;
3536 def MVE_VADD_qr_f16 : MVE_VxADDSUB_qr<"vadd", "f16", 0b1, 0b11, 0b0>;
3538 def MVE_VSUB_qr_f32 : MVE_VxADDSUB_qr<"vsub", "f32", 0b0, 0b11, 0b1>;
3539 def MVE_VSUB_qr_f16 : MVE_VxADDSUB_qr<"vsub", "f16", 0b1, 0b11, 0b1>;
3542 class MVE_VxSHL_qr<string iname, string suffix, bit U, bits<2> size,
3543 bit bit_7, bit bit_17, list<dag> pattern=[]>
3544 : MVE_qDest_single_rSrc<iname, suffix, pattern> {
3547 let Inst{25-23} = 0b100;
3548 let Inst{21-20} = 0b11;
3549 let Inst{19-18} = size;
3550 let Inst{17} = bit_17;
3552 let Inst{12-8} = 0b11110;
3553 let Inst{7} = bit_7;
3554 let Inst{6-4} = 0b110;
3557 multiclass MVE_VxSHL_qr_types<string iname, bit bit_7, bit bit_17> {
3558 def s8 : MVE_VxSHL_qr<iname, "s8", 0b0, 0b00, bit_7, bit_17>;
3559 def s16 : MVE_VxSHL_qr<iname, "s16", 0b0, 0b01, bit_7, bit_17>;
3560 def s32 : MVE_VxSHL_qr<iname, "s32", 0b0, 0b10, bit_7, bit_17>;
3561 def u8 : MVE_VxSHL_qr<iname, "u8", 0b1, 0b00, bit_7, bit_17>;
3562 def u16 : MVE_VxSHL_qr<iname, "u16", 0b1, 0b01, bit_7, bit_17>;
3563 def u32 : MVE_VxSHL_qr<iname, "u32", 0b1, 0b10, bit_7, bit_17>;
3566 defm MVE_VSHL_qr : MVE_VxSHL_qr_types<"vshl", 0b0, 0b0>;
3567 defm MVE_VRSHL_qr : MVE_VxSHL_qr_types<"vrshl", 0b0, 0b1>;
3568 defm MVE_VQSHL_qr : MVE_VxSHL_qr_types<"vqshl", 0b1, 0b0>;
3569 defm MVE_VQRSHL_qr : MVE_VxSHL_qr_types<"vqrshl", 0b1, 0b1>;
3571 let Predicates = [HasMVEInt] in {
3572 def : Pat<(v4i32 (ARMvshlu (v4i32 MQPR:$Qm), (v4i32 (ARMvdup GPR:$Rm)))),
3573 (v4i32 (MVE_VSHL_qru32 (v4i32 MQPR:$Qm), GPR:$Rm))>;
3574 def : Pat<(v8i16 (ARMvshlu (v8i16 MQPR:$Qm), (v8i16 (ARMvdup GPR:$Rm)))),
3575 (v8i16 (MVE_VSHL_qru16 (v8i16 MQPR:$Qm), GPR:$Rm))>;
3576 def : Pat<(v16i8 (ARMvshlu (v16i8 MQPR:$Qm), (v16i8 (ARMvdup GPR:$Rm)))),
3577 (v16i8 (MVE_VSHL_qru8 (v16i8 MQPR:$Qm), GPR:$Rm))>;
3579 def : Pat<(v4i32 (ARMvshls (v4i32 MQPR:$Qm), (v4i32 (ARMvdup GPR:$Rm)))),
3580 (v4i32 (MVE_VSHL_qrs32 (v4i32 MQPR:$Qm), GPR:$Rm))>;
3581 def : Pat<(v8i16 (ARMvshls (v8i16 MQPR:$Qm), (v8i16 (ARMvdup GPR:$Rm)))),
3582 (v8i16 (MVE_VSHL_qrs16 (v8i16 MQPR:$Qm), GPR:$Rm))>;
3583 def : Pat<(v16i8 (ARMvshls (v16i8 MQPR:$Qm), (v16i8 (ARMvdup GPR:$Rm)))),
3584 (v16i8 (MVE_VSHL_qrs8 (v16i8 MQPR:$Qm), GPR:$Rm))>;
3587 class MVE_VBRSR<string iname, string suffix, bits<2> size, list<dag> pattern=[]>
3588 : MVE_qDest_rSrc<iname, suffix, pattern> {
3591 let Inst{21-20} = size;
3598 def MVE_VBRSR8 : MVE_VBRSR<"vbrsr", "8", 0b00>;
3599 def MVE_VBRSR16 : MVE_VBRSR<"vbrsr", "16", 0b01>;
3600 def MVE_VBRSR32 : MVE_VBRSR<"vbrsr", "32", 0b10>;
3602 class MVE_VMUL_qr_int<string iname, string suffix,
3603 bits<2> size, list<dag> pattern=[]>
3604 : MVE_qDest_rSrc<iname, suffix, pattern> {
3607 let Inst{21-20} = size;
3614 def MVE_VMUL_qr_i8 : MVE_VMUL_qr_int<"vmul", "i8", 0b00>;
3615 def MVE_VMUL_qr_i16 : MVE_VMUL_qr_int<"vmul", "i16", 0b01>;
3616 def MVE_VMUL_qr_i32 : MVE_VMUL_qr_int<"vmul", "i32", 0b10>;
3618 class MVE_VxxMUL_qr<string iname, string suffix,
3619 bit bit_28, bits<2> bits_21_20, list<dag> pattern=[]>
3620 : MVE_qDest_rSrc<iname, suffix, pattern> {
3622 let Inst{28} = bit_28;
3623 let Inst{21-20} = bits_21_20;
3630 def MVE_VQDMULH_qr_s8 : MVE_VxxMUL_qr<"vqdmulh", "s8", 0b0, 0b00>;
3631 def MVE_VQDMULH_qr_s16 : MVE_VxxMUL_qr<"vqdmulh", "s16", 0b0, 0b01>;
3632 def MVE_VQDMULH_qr_s32 : MVE_VxxMUL_qr<"vqdmulh", "s32", 0b0, 0b10>;
3634 def MVE_VQRDMULH_qr_s8 : MVE_VxxMUL_qr<"vqrdmulh", "s8", 0b1, 0b00>;
3635 def MVE_VQRDMULH_qr_s16 : MVE_VxxMUL_qr<"vqrdmulh", "s16", 0b1, 0b01>;
3636 def MVE_VQRDMULH_qr_s32 : MVE_VxxMUL_qr<"vqrdmulh", "s32", 0b1, 0b10>;
3638 let Predicates = [HasMVEFloat] in {
3639 def MVE_VMUL_qr_f16 : MVE_VxxMUL_qr<"vmul", "f16", 0b1, 0b11>;
3640 def MVE_VMUL_qr_f32 : MVE_VxxMUL_qr<"vmul", "f32", 0b0, 0b11>;
3643 class MVE_VFMAMLA_qr<string iname, string suffix,
3644 bit bit_28, bits<2> bits_21_20, bit S,
3645 list<dag> pattern=[]>
3646 : MVE_qDestSrc_rSrc<iname, suffix, pattern> {
3648 let Inst{28} = bit_28;
3649 let Inst{21-20} = bits_21_20;
3656 def MVE_VMLA_qr_s8 : MVE_VFMAMLA_qr<"vmla", "s8", 0b0, 0b00, 0b0>;
3657 def MVE_VMLA_qr_s16 : MVE_VFMAMLA_qr<"vmla", "s16", 0b0, 0b01, 0b0>;
3658 def MVE_VMLA_qr_s32 : MVE_VFMAMLA_qr<"vmla", "s32", 0b0, 0b10, 0b0>;
3659 def MVE_VMLA_qr_u8 : MVE_VFMAMLA_qr<"vmla", "u8", 0b1, 0b00, 0b0>;
3660 def MVE_VMLA_qr_u16 : MVE_VFMAMLA_qr<"vmla", "u16", 0b1, 0b01, 0b0>;
3661 def MVE_VMLA_qr_u32 : MVE_VFMAMLA_qr<"vmla", "u32", 0b1, 0b10, 0b0>;
3663 def MVE_VMLAS_qr_s8 : MVE_VFMAMLA_qr<"vmlas", "s8", 0b0, 0b00, 0b1>;
3664 def MVE_VMLAS_qr_s16 : MVE_VFMAMLA_qr<"vmlas", "s16", 0b0, 0b01, 0b1>;
3665 def MVE_VMLAS_qr_s32 : MVE_VFMAMLA_qr<"vmlas", "s32", 0b0, 0b10, 0b1>;
3666 def MVE_VMLAS_qr_u8 : MVE_VFMAMLA_qr<"vmlas", "u8", 0b1, 0b00, 0b1>;
3667 def MVE_VMLAS_qr_u16 : MVE_VFMAMLA_qr<"vmlas", "u16", 0b1, 0b01, 0b1>;
3668 def MVE_VMLAS_qr_u32 : MVE_VFMAMLA_qr<"vmlas", "u32", 0b1, 0b10, 0b1>;
3670 let Predicates = [HasMVEFloat] in {
3671 def MVE_VFMA_qr_f16 : MVE_VFMAMLA_qr<"vfma", "f16", 0b1, 0b11, 0b0>;
3672 def MVE_VFMA_qr_f32 : MVE_VFMAMLA_qr<"vfma", "f32", 0b0, 0b11, 0b0>;
3673 def MVE_VFMA_qr_Sf16 : MVE_VFMAMLA_qr<"vfmas", "f16", 0b1, 0b11, 0b1>;
3674 def MVE_VFMA_qr_Sf32 : MVE_VFMAMLA_qr<"vfmas", "f32", 0b0, 0b11, 0b1>;
3677 class MVE_VQDMLAH_qr<string iname, string suffix, bit U, bits<2> size,
3678 bit bit_5, bit bit_12, list<dag> pattern=[]>
3679 : MVE_qDestSrc_rSrc<iname, suffix, pattern> {
3682 let Inst{21-20} = size;
3684 let Inst{12} = bit_12;
3686 let Inst{5} = bit_5;
3689 multiclass MVE_VQDMLAH_qr_types<string iname, bit bit_5, bit bit_12> {
3690 def s8 : MVE_VQDMLAH_qr<iname, "s8", 0b0, 0b00, bit_5, bit_12>;
3691 def s16 : MVE_VQDMLAH_qr<iname, "s16", 0b0, 0b01, bit_5, bit_12>;
3692 def s32 : MVE_VQDMLAH_qr<iname, "s32", 0b0, 0b10, bit_5, bit_12>;
3695 defm MVE_VQDMLAH_qr : MVE_VQDMLAH_qr_types<"vqdmlah", 0b1, 0b0>;
3696 defm MVE_VQRDMLAH_qr : MVE_VQDMLAH_qr_types<"vqrdmlah", 0b0, 0b0>;
3697 defm MVE_VQDMLASH_qr : MVE_VQDMLAH_qr_types<"vqdmlash", 0b1, 0b1>;
3698 defm MVE_VQRDMLASH_qr : MVE_VQDMLAH_qr_types<"vqrdmlash", 0b0, 0b1>;
3700 class MVE_VxDUP<string iname, string suffix, bits<2> size, bit bit_12,
3701 list<dag> pattern=[]>
3702 : MVE_p<(outs MQPR:$Qd, tGPREven:$Rn),
3703 (ins tGPREven:$Rn_src, MVE_VIDUP_imm:$imm), NoItinerary,
3704 iname, suffix, "$Qd, $Rn, $imm", vpred_r, "$Rn = $Rn_src",
3711 let Inst{25-23} = 0b100;
3712 let Inst{22} = Qd{3};
3713 let Inst{21-20} = size;
3714 let Inst{19-17} = Rn{3-1};
3716 let Inst{15-13} = Qd{2-0};
3717 let Inst{12} = bit_12;
3718 let Inst{11-8} = 0b1111;
3719 let Inst{7} = imm{1};
3720 let Inst{6-1} = 0b110111;
3721 let Inst{0} = imm{0};
3724 def MVE_VIDUPu8 : MVE_VxDUP<"vidup", "u8", 0b00, 0b0>;
3725 def MVE_VIDUPu16 : MVE_VxDUP<"vidup", "u16", 0b01, 0b0>;
3726 def MVE_VIDUPu32 : MVE_VxDUP<"vidup", "u32", 0b10, 0b0>;
3728 def MVE_VDDUPu8 : MVE_VxDUP<"vddup", "u8", 0b00, 0b1>;
3729 def MVE_VDDUPu16 : MVE_VxDUP<"vddup", "u16", 0b01, 0b1>;
3730 def MVE_VDDUPu32 : MVE_VxDUP<"vddup", "u32", 0b10, 0b1>;
3732 class MVE_VxWDUP<string iname, string suffix, bits<2> size, bit bit_12,
3733 list<dag> pattern=[]>
3734 : MVE_p<(outs MQPR:$Qd, tGPREven:$Rn),
3735 (ins tGPREven:$Rn_src, tGPROdd:$Rm, MVE_VIDUP_imm:$imm), NoItinerary,
3736 iname, suffix, "$Qd, $Rn, $Rm, $imm", vpred_r, "$Rn = $Rn_src",
3744 let Inst{25-23} = 0b100;
3745 let Inst{22} = Qd{3};
3746 let Inst{21-20} = size;
3747 let Inst{19-17} = Rn{3-1};
3749 let Inst{15-13} = Qd{2-0};
3750 let Inst{12} = bit_12;
3751 let Inst{11-8} = 0b1111;
3752 let Inst{7} = imm{1};
3753 let Inst{6-4} = 0b110;
3754 let Inst{3-1} = Rm{3-1};
3755 let Inst{0} = imm{0};
3758 def MVE_VIWDUPu8 : MVE_VxWDUP<"viwdup", "u8", 0b00, 0b0>;
3759 def MVE_VIWDUPu16 : MVE_VxWDUP<"viwdup", "u16", 0b01, 0b0>;
3760 def MVE_VIWDUPu32 : MVE_VxWDUP<"viwdup", "u32", 0b10, 0b0>;
3762 def MVE_VDWDUPu8 : MVE_VxWDUP<"vdwdup", "u8", 0b00, 0b1>;
3763 def MVE_VDWDUPu16 : MVE_VxWDUP<"vdwdup", "u16", 0b01, 0b1>;
3764 def MVE_VDWDUPu32 : MVE_VxWDUP<"vdwdup", "u32", 0b10, 0b1>;
3766 class MVE_VCTP<string suffix, bits<2> size, list<dag> pattern=[]>
3767 : MVE_p<(outs VCCR:$P0), (ins rGPR:$Rn), NoItinerary, "vctp", suffix,
3768 "$Rn", vpred_n, "", pattern> {
3771 let Inst{28-27} = 0b10;
3772 let Inst{26-22} = 0b00000;
3773 let Inst{21-20} = size;
3774 let Inst{19-16} = Rn{3-0};
3775 let Inst{15-11} = 0b11101;
3776 let Inst{10-0} = 0b00000000001;
3777 let Unpredictable{10-0} = 0b11111111111;
3779 let Constraints = "";
3780 let DecoderMethod = "DecodeMveVCTP";
3783 def MVE_VCTP8 : MVE_VCTP<"8", 0b00>;
3784 def MVE_VCTP16 : MVE_VCTP<"16", 0b01>;
3785 def MVE_VCTP32 : MVE_VCTP<"32", 0b10>;
3786 def MVE_VCTP64 : MVE_VCTP<"64", 0b11>;
3788 // end of mve_qDest_rSrc
3790 // start of coproc mov
3792 class MVE_VMOV_64bit<dag oops, dag iops, bit to_qreg, string ops, string cstr>
3793 : MVE_VMOV_lane_base<oops, !con(iops, (ins MVEPairVectorIndex2:$idx,
3794 MVEPairVectorIndex0:$idx2)),
3795 NoItinerary, "vmov", "", ops, cstr, []> {
3802 let Inst{31-23} = 0b111011000;
3803 let Inst{22} = Qd{3};
3805 let Inst{20} = to_qreg;
3806 let Inst{19-16} = Rt2{3-0};
3807 let Inst{15-13} = Qd{2-0};
3808 let Inst{12-5} = 0b01111000;
3810 let Inst{3-0} = Rt{3-0};
3813 // The assembly syntax for these instructions mentions the vector
3814 // register name twice, e.g.
3816 // vmov q2[2], q2[0], r0, r1
3817 // vmov r0, r1, q2[2], q2[0]
3819 // which needs a bit of juggling with MC operand handling.
3821 // For the move _into_ a vector register, the MC operand list also has
3822 // to mention the register name twice: once as the output, and once as
3823 // an extra input to represent where the unchanged half of the output
3824 // register comes from (when this instruction is used in code
3825 // generation). So we arrange that the first mention of the vector reg
3826 // in the instruction is considered by the AsmMatcher to be the output
3827 // ($Qd), and the second one is the input ($QdSrc). Binding them
3828 // together with the existing 'tie' constraint is enough to enforce at
3829 // register allocation time that they have to be the same register.
3831 // For the move _from_ a vector register, there's no way to get round
3832 // the fact that both instances of that register name have to be
3833 // inputs. They have to be the same register again, but this time, we
3834 // can't use a tie constraint, because that has to be between an
3835 // output and an input operand. So this time, we have to arrange that
3836 // the q-reg appears just once in the MC operand list, in spite of
3837 // being mentioned twice in the asm syntax - which needs a custom
3838 // AsmMatchConverter.
3840 def MVE_VMOV_q_rr : MVE_VMOV_64bit<(outs MQPR:$Qd),
3841 (ins MQPR:$QdSrc, rGPR:$Rt, rGPR:$Rt2),
3842 0b1, "$Qd$idx, $QdSrc$idx2, $Rt, $Rt2",
3844 let DecoderMethod = "DecodeMVEVMOVDRegtoQ";
3847 def MVE_VMOV_rr_q : MVE_VMOV_64bit<(outs rGPR:$Rt, rGPR:$Rt2), (ins MQPR:$Qd),
3848 0b0, "$Rt, $Rt2, $Qd$idx, $Qd$idx2", ""> {
3849 let DecoderMethod = "DecodeMVEVMOVQtoDReg";
3850 let AsmMatchConverter = "cvtMVEVMOVQtoDReg";
3853 // end of coproc mov
3855 // start of MVE interleaving load/store
3857 // Base class for the family of interleaving/deinterleaving
3858 // load/stores with names like VLD20.8 and VST43.32.
3859 class MVE_vldst24_base<bit writeback, bit fourregs, bits<2> stage, bits<2> size,
3860 bit load, dag Oops, dag loadIops, dag wbIops,
3861 string iname, string ops,
3862 string cstr, list<dag> pattern=[]>
3863 : MVE_MI<Oops, !con(loadIops, wbIops), NoItinerary, iname, ops, cstr, pattern> {
3867 let Inst{31-22} = 0b1111110010;
3868 let Inst{21} = writeback;
3869 let Inst{20} = load;
3870 let Inst{19-16} = Rn;
3871 let Inst{15-13} = VQd{2-0};
3872 let Inst{12-9} = 0b1111;
3873 let Inst{8-7} = size;
3874 let Inst{6-5} = stage;
3875 let Inst{4-1} = 0b0000;
3876 let Inst{0} = fourregs;
3879 let mayStore = !eq(load,0);
3882 // A parameter class used to encapsulate all the ways the writeback
3883 // variants of VLD20 and friends differ from the non-writeback ones.
3884 class MVE_vldst24_writeback<bit b, dag Oo, dag Io,
3885 string sy="", string c="", string n=""> {
3891 string id_suffix = n;
3894 // Another parameter class that encapsulates the differences between VLD2x
3896 class MVE_vldst24_nvecs<int n, list<int> s, bit b, RegisterOperand vl> {
3898 list<int> stages = s;
3900 RegisterOperand VecList = vl;
3903 // A third parameter class that distinguishes VLDnn.8 from .16 from .32.
3904 class MVE_vldst24_lanesize<int i, bits<2> b> {
3906 bits<2> sizebits = b;
3909 // A base class for each direction of transfer: one for load, one for
3910 // store. I can't make these a fourth independent parametric tuple
3911 // class, because they have to take the nvecs tuple class as a
3912 // parameter, in order to find the right VecList operand type.
3914 class MVE_vld24_base<MVE_vldst24_nvecs n, bits<2> pat, bits<2> size,
3915 MVE_vldst24_writeback wb, string iname,
3916 list<dag> pattern=[]>
3917 : MVE_vldst24_base<wb.writeback, n.bit0, pat, size, 1,
3918 !con((outs n.VecList:$VQd), wb.Oops),
3919 (ins n.VecList:$VQdSrc), wb.Iops,
3920 iname, "$VQd, $Rn" # wb.syntax,
3921 wb.cstr # ",$VQdSrc = $VQd", pattern>;
3923 class MVE_vst24_base<MVE_vldst24_nvecs n, bits<2> pat, bits<2> size,
3924 MVE_vldst24_writeback wb, string iname,
3925 list<dag> pattern=[]>
3926 : MVE_vldst24_base<wb.writeback, n.bit0, pat, size, 0,
3927 wb.Oops, (ins n.VecList:$VQd), wb.Iops,
3928 iname, "$VQd, $Rn" # wb.syntax,
3931 // Actually define all the interleaving loads and stores, by a series
3932 // of nested foreaches over number of vectors (VLD2/VLD4); stage
3933 // within one of those series (VLDx0/VLDx1/VLDx2/VLDx3); size of
3934 // vector lane; writeback or no writeback.
3935 foreach n = [MVE_vldst24_nvecs<2, [0,1], 0, VecList2Q>,
3936 MVE_vldst24_nvecs<4, [0,1,2,3], 1, VecList4Q>] in
3937 foreach stage = n.stages in
3938 foreach s = [MVE_vldst24_lanesize< 8, 0b00>,
3939 MVE_vldst24_lanesize<16, 0b01>,
3940 MVE_vldst24_lanesize<32, 0b10>] in
3941 foreach wb = [MVE_vldst24_writeback<
3942 1, (outs rGPR:$wb), (ins t2_nosp_addr_offset_none:$Rn),
3943 "!", "$Rn.base = $wb", "_wb">,
3944 MVE_vldst24_writeback<0, (outs), (ins t2_addr_offset_none:$Rn)>] in {
3946 // For each case within all of those foreaches, define the actual
3947 // instructions. The def names are made by gluing together pieces
3948 // from all the parameter classes, and will end up being things like
3949 // MVE_VLD20_8 and MVE_VST43_16_wb.
3951 def "MVE_VLD" # n.nvecs # stage # "_" # s.lanesize # wb.id_suffix
3952 : MVE_vld24_base<n, stage, s.sizebits, wb,
3953 "vld" # n.nvecs # stage # "." # s.lanesize>;
3955 def "MVE_VST" # n.nvecs # stage # "_" # s.lanesize # wb.id_suffix
3956 : MVE_vst24_base<n, stage, s.sizebits, wb,
3957 "vst" # n.nvecs # stage # "." # s.lanesize>;
3960 // end of MVE interleaving load/store
3962 // start of MVE predicable load/store
3964 // A parameter class for the direction of transfer.
3965 class MVE_ldst_direction<bit b, dag Oo, dag Io, string c=""> {
3971 def MVE_ld: MVE_ldst_direction<1, (outs MQPR:$Qd), (ins), ",@earlyclobber $Qd">;
3972 def MVE_st: MVE_ldst_direction<0, (outs), (ins MQPR:$Qd)>;
3974 // A parameter class for the size of memory access in a load.
3975 class MVE_memsz<bits<2> e, int s, AddrMode m, string mn, list<string> types> {
3976 bits<2> encoding = e; // opcode bit(s) for encoding
3977 int shift = s; // shift applied to immediate load offset
3980 // For instruction aliases: define the complete list of type
3981 // suffixes at this size, and the canonical ones for loads and
3983 string MnemonicLetter = mn;
3984 int TypeBits = !shl(8, s);
3985 string CanonLoadSuffix = ".u" # TypeBits;
3986 string CanonStoreSuffix = "." # TypeBits;
3987 list<string> suffixes = !foreach(letter, types, "." # letter # TypeBits);
3990 // Instances of MVE_memsz.
3992 // (memD doesn't need an AddrMode, because those are only for
3993 // contiguous loads, and memD is only used by gather/scatters.)
3994 def MVE_memB: MVE_memsz<0b00, 0, AddrModeT2_i7, "b", ["", "u", "s"]>;
3995 def MVE_memH: MVE_memsz<0b01, 1, AddrModeT2_i7s2, "h", ["", "u", "s", "f"]>;
3996 def MVE_memW: MVE_memsz<0b10, 2, AddrModeT2_i7s4, "w", ["", "u", "s", "f"]>;
3997 def MVE_memD: MVE_memsz<0b11, 3, ?, "d", ["", "u", "s", "f"]>;
3999 // This is the base class for all the MVE loads and stores other than
4000 // the interleaving ones. All the non-interleaving loads/stores share
4001 // the characteristic that they operate on just one vector register,
4002 // so they are VPT-predicable.
4004 // The predication operand is vpred_n, for both loads and stores. For
4005 // store instructions, the reason is obvious: if there is no output
4006 // register, there can't be a need for an input parameter giving the
4007 // output register's previous value. Load instructions also don't need
4008 // that input parameter, because unlike MVE data processing
4009 // instructions, predicated loads are defined to set the inactive
4010 // lanes of the output register to zero, instead of preserving their
4012 class MVE_VLDRSTR_base<MVE_ldst_direction dir, bit U, bit P, bit W, bit opc,
4013 dag oops, dag iops, string asm, string suffix,
4014 string ops, string cstr, list<dag> pattern=[]>
4015 : MVE_p<oops, iops, NoItinerary, asm, suffix, ops, vpred_n, cstr, pattern> {
4023 let Inst{20} = dir.load;
4024 let Inst{15-13} = Qd{2-0};
4026 let Inst{11-9} = 0b111;
4028 let mayLoad = dir.load;
4029 let mayStore = !eq(dir.load,0);
4032 // Contiguous load and store instructions. These come in two main
4033 // categories: same-size loads/stores in which 128 bits of vector
4034 // register is transferred to or from 128 bits of memory in the most
4035 // obvious way, and widening loads / narrowing stores, in which the
4036 // size of memory accessed is less than the size of a vector register,
4037 // so the load instructions sign- or zero-extend each memory value
4038 // into a wider vector lane, and the store instructions truncate
4041 // The instruction mnemonics for these two classes look reasonably
4042 // similar, but the actual encodings are different enough to need two
4043 // separate base classes.
4045 // Contiguous, same size
4046 class MVE_VLDRSTR_cs<MVE_ldst_direction dir, MVE_memsz memsz, bit P, bit W,
4047 dag oops, dag iops, string asm, string suffix,
4048 IndexMode im, string ops, string cstr>
4049 : MVE_VLDRSTR_base<dir, 0, P, W, 1, oops, iops, asm, suffix, ops, cstr> {
4051 let Inst{23} = addr{7};
4052 let Inst{19-16} = addr{11-8};
4053 let Inst{8-7} = memsz.encoding;
4054 let Inst{6-0} = addr{6-0};
4057 // Contiguous, widening/narrowing
4058 class MVE_VLDRSTR_cw<MVE_ldst_direction dir, MVE_memsz memsz, bit U,
4059 bit P, bit W, bits<2> size, dag oops, dag iops,
4060 string asm, string suffix, IndexMode im,
4061 string ops, string cstr>
4062 : MVE_VLDRSTR_base<dir, U, P, W, 0, oops, iops, asm, suffix, ops, cstr> {
4064 let Inst{23} = addr{7};
4065 let Inst{19} = memsz.encoding{0}; // enough to tell 16- from 32-bit
4066 let Inst{18-16} = addr{10-8};
4067 let Inst{8-7} = size;
4068 let Inst{6-0} = addr{6-0};
4073 // Multiclass wrapper on each of the _cw and _cs base classes, to
4074 // generate three writeback modes (none, preindex, postindex).
4076 multiclass MVE_VLDRSTR_cw_m<MVE_ldst_direction dir, MVE_memsz memsz,
4077 string asm, string suffix, bit U, bits<2> size> {
4078 let AM = memsz.AM in {
4079 def "" : MVE_VLDRSTR_cw<
4080 dir, memsz, U, 1, 0, size,
4081 dir.Oops, !con(dir.Iops, (ins taddrmode_imm7<memsz.shift>:$addr)),
4082 asm, suffix, IndexModeNone, "$Qd, $addr", "">;
4084 def _pre : MVE_VLDRSTR_cw<
4085 dir, memsz, U, 1, 1, size,
4086 !con((outs tGPR:$wb), dir.Oops),
4087 !con(dir.Iops, (ins taddrmode_imm7<memsz.shift>:$addr)),
4088 asm, suffix, IndexModePre, "$Qd, $addr!", "$addr.base = $wb"> {
4089 let DecoderMethod = "DecodeMVE_MEM_1_pre<"#memsz.shift#">";
4092 def _post : MVE_VLDRSTR_cw<
4093 dir, memsz, U, 0, 1, size,
4094 !con((outs tGPR:$wb), dir.Oops),
4095 !con(dir.Iops, (ins t_addr_offset_none:$Rn,
4096 t2am_imm7_offset<memsz.shift>:$addr)),
4097 asm, suffix, IndexModePost, "$Qd, $Rn$addr", "$Rn.base = $wb"> {
4099 let Inst{18-16} = Rn{2-0};
4104 multiclass MVE_VLDRSTR_cs_m<MVE_ldst_direction dir, MVE_memsz memsz,
4105 string asm, string suffix> {
4106 let AM = memsz.AM in {
4107 def "" : MVE_VLDRSTR_cs<
4109 dir.Oops, !con(dir.Iops, (ins t2addrmode_imm7<memsz.shift>:$addr)),
4110 asm, suffix, IndexModeNone, "$Qd, $addr", "">;
4112 def _pre : MVE_VLDRSTR_cs<
4114 !con((outs rGPR:$wb), dir.Oops),
4115 !con(dir.Iops, (ins t2addrmode_imm7_pre<memsz.shift>:$addr)),
4116 asm, suffix, IndexModePre, "$Qd, $addr!", "$addr.base = $wb"> {
4117 let DecoderMethod = "DecodeMVE_MEM_2_pre<"#memsz.shift#">";
4120 def _post : MVE_VLDRSTR_cs<
4122 !con((outs rGPR:$wb), dir.Oops),
4123 // We need an !if here to select the base register class,
4124 // because it's legal to write back to SP in a load of this
4125 // type, but not in a store.
4126 !con(dir.Iops, (ins !if(dir.load, t2_addr_offset_none,
4127 t2_nosp_addr_offset_none):$Rn,
4128 t2am_imm7_offset<memsz.shift>:$addr)),
4129 asm, suffix, IndexModePost, "$Qd, $Rn$addr", "$Rn.base = $wb"> {
4131 let Inst{19-16} = Rn{3-0};
4136 // Now actually declare all the contiguous load/stores, via those
4137 // multiclasses. The instruction ids coming out of this are the bare
4138 // names shown in the defm, with _pre or _post appended for writeback,
4139 // e.g. MVE_VLDRBS16, MVE_VSTRB16_pre, MVE_VSTRHU16_post.
4141 defm MVE_VLDRBS16: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "s16", 0, 0b01>;
4142 defm MVE_VLDRBS32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "s32", 0, 0b10>;
4143 defm MVE_VLDRBU16: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "u16", 1, 0b01>;
4144 defm MVE_VLDRBU32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "u32", 1, 0b10>;
4145 defm MVE_VLDRHS32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memH, "vldrh", "s32", 0, 0b10>;
4146 defm MVE_VLDRHU32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memH, "vldrh", "u32", 1, 0b10>;
4148 defm MVE_VLDRBU8: MVE_VLDRSTR_cs_m<MVE_ld, MVE_memB, "vldrb", "u8">;
4149 defm MVE_VLDRHU16: MVE_VLDRSTR_cs_m<MVE_ld, MVE_memH, "vldrh", "u16">;
4150 defm MVE_VLDRWU32: MVE_VLDRSTR_cs_m<MVE_ld, MVE_memW, "vldrw", "u32">;
4152 defm MVE_VSTRB16: MVE_VLDRSTR_cw_m<MVE_st, MVE_memB, "vstrb", "16", 0, 0b01>;
4153 defm MVE_VSTRB32: MVE_VLDRSTR_cw_m<MVE_st, MVE_memB, "vstrb", "32", 0, 0b10>;
4154 defm MVE_VSTRH32: MVE_VLDRSTR_cw_m<MVE_st, MVE_memH, "vstrh", "32", 0, 0b10>;
4156 defm MVE_VSTRBU8 : MVE_VLDRSTR_cs_m<MVE_st, MVE_memB, "vstrb", "8">;
4157 defm MVE_VSTRHU16: MVE_VLDRSTR_cs_m<MVE_st, MVE_memH, "vstrh", "16">;
4158 defm MVE_VSTRWU32: MVE_VLDRSTR_cs_m<MVE_st, MVE_memW, "vstrw", "32">;
4160 // Gather loads / scatter stores whose address operand is of the form
4161 // [Rn,Qm], i.e. a single GPR as the common base address, plus a
4162 // vector of offset from it. ('Load/store this sequence of elements of
4163 // the same array.')
4165 // Like the contiguous family, these loads and stores can widen the
4166 // loaded values / truncate the stored ones, or they can just
4167 // load/store the same size of memory and vector lane. But unlike the
4168 // contiguous family, there's no particular difference in encoding
4169 // between those two cases.
4171 // This family also comes with the option to scale the offset values
4172 // in Qm by the size of the loaded memory (i.e. to treat them as array
4173 // indices), or not to scale them (to treat them as plain byte offsets
4174 // in memory, so that perhaps the loaded values are unaligned). The
4175 // scaled instructions' address operand in assembly looks like
4176 // [Rn,Qm,UXTW #2] or similar.
4179 class MVE_VLDRSTR_rq<MVE_ldst_direction dir, MVE_memsz memsz, bit U,
4180 bits<2> size, bit os, string asm, string suffix, int shift>
4181 : MVE_VLDRSTR_base<dir, U, 0b0, 0b0, 0, dir.Oops,
4182 !con(dir.Iops, (ins mve_addr_rq_shift<shift>:$addr)),
4183 asm, suffix, "$Qd, $addr", dir.cstr> {
4186 let Inst{19-16} = addr{6-3};
4187 let Inst{8-7} = size;
4188 let Inst{6} = memsz.encoding{1};
4190 let Inst{4} = memsz.encoding{0};
4191 let Inst{3-1} = addr{2-0};
4195 // Multiclass that defines the scaled and unscaled versions of an
4196 // instruction, when the memory size is wider than a byte. The scaled
4197 // version gets the default name like MVE_VLDRBU16_rq; the unscaled /
4198 // potentially unaligned version gets a "_u" suffix, e.g.
4199 // MVE_VLDRBU16_rq_u.
4200 multiclass MVE_VLDRSTR_rq_w<MVE_ldst_direction dir, MVE_memsz memsz,
4201 string asm, string suffix, bit U, bits<2> size> {
4202 def _u : MVE_VLDRSTR_rq<dir, memsz, U, size, 0, asm, suffix, 0>;
4203 def "" : MVE_VLDRSTR_rq<dir, memsz, U, size, 1, asm, suffix, memsz.shift>;
4206 // Subclass of MVE_VLDRSTR_rq with the same API as that multiclass,
4207 // for use when the memory size is one byte, so there's no 'scaled'
4208 // version of the instruction at all. (This is encoded as if it were
4209 // unscaled, but named in the default way with no _u suffix.)
4210 class MVE_VLDRSTR_rq_b<MVE_ldst_direction dir, MVE_memsz memsz,
4211 string asm, string suffix, bit U, bits<2> size>
4212 : MVE_VLDRSTR_rq<dir, memsz, U, size, 0, asm, suffix, 0>;
4214 // Actually define all the loads and stores in this family.
4216 def MVE_VLDRBU8_rq : MVE_VLDRSTR_rq_b<MVE_ld, MVE_memB, "vldrb","u8", 1,0b00>;
4217 def MVE_VLDRBU16_rq: MVE_VLDRSTR_rq_b<MVE_ld, MVE_memB, "vldrb","u16", 1,0b01>;
4218 def MVE_VLDRBS16_rq: MVE_VLDRSTR_rq_b<MVE_ld, MVE_memB, "vldrb","s16", 0,0b01>;
4219 def MVE_VLDRBU32_rq: MVE_VLDRSTR_rq_b<MVE_ld, MVE_memB, "vldrb","u32", 1,0b10>;
4220 def MVE_VLDRBS32_rq: MVE_VLDRSTR_rq_b<MVE_ld, MVE_memB, "vldrb","s32", 0,0b10>;
4222 defm MVE_VLDRHU16_rq: MVE_VLDRSTR_rq_w<MVE_ld, MVE_memH, "vldrh","u16", 1,0b01>;
4223 defm MVE_VLDRHU32_rq: MVE_VLDRSTR_rq_w<MVE_ld, MVE_memH, "vldrh","u32", 1,0b10>;
4224 defm MVE_VLDRHS32_rq: MVE_VLDRSTR_rq_w<MVE_ld, MVE_memH, "vldrh","s32", 0,0b10>;
4225 defm MVE_VLDRWU32_rq: MVE_VLDRSTR_rq_w<MVE_ld, MVE_memW, "vldrw","u32", 1,0b10>;
4226 defm MVE_VLDRDU64_rq: MVE_VLDRSTR_rq_w<MVE_ld, MVE_memD, "vldrd","u64", 1,0b11>;
4228 def MVE_VSTRB8_rq : MVE_VLDRSTR_rq_b<MVE_st, MVE_memB, "vstrb","8", 0,0b00>;
4229 def MVE_VSTRB16_rq : MVE_VLDRSTR_rq_b<MVE_st, MVE_memB, "vstrb","16", 0,0b01>;
4230 def MVE_VSTRB32_rq : MVE_VLDRSTR_rq_b<MVE_st, MVE_memB, "vstrb","32", 0,0b10>;
4232 defm MVE_VSTRH16_rq : MVE_VLDRSTR_rq_w<MVE_st, MVE_memH, "vstrh","16", 0,0b01>;
4233 defm MVE_VSTRH32_rq : MVE_VLDRSTR_rq_w<MVE_st, MVE_memH, "vstrh","32", 0,0b10>;
4234 defm MVE_VSTRW32_rq : MVE_VLDRSTR_rq_w<MVE_st, MVE_memW, "vstrw","32", 0,0b10>;
4235 defm MVE_VSTRD64_rq : MVE_VLDRSTR_rq_w<MVE_st, MVE_memD, "vstrd","64", 0,0b11>;
4237 // Gather loads / scatter stores whose address operand is of the form
4238 // [Qm,#imm], i.e. a vector containing a full base address for each
4239 // loaded item, plus an immediate offset applied consistently to all
4240 // of them. ('Load/store the same field from this vector of pointers
4241 // to a structure type.')
4243 // This family requires the vector lane size to be at least 32 bits
4244 // (so there's room for an address in each lane at all). It has no
4245 // widening/narrowing variants. But it does support preindex
4246 // writeback, in which the address vector is updated to hold the
4247 // addresses actually loaded from.
4250 class MVE_VLDRSTR_qi<MVE_ldst_direction dir, MVE_memsz memsz, bit W, dag wbops,
4251 string asm, string wbAsm, string suffix, string cstr = "">
4252 : MVE_VLDRSTR_base<dir, 1, 1, W, 1, !con(wbops, dir.Oops),
4253 !con(dir.Iops, (ins mve_addr_q_shift<memsz.shift>:$addr)),
4254 asm, suffix, "$Qd, $addr" # wbAsm, cstr # dir.cstr> {
4256 let Inst{23} = addr{7};
4257 let Inst{19-17} = addr{10-8};
4259 let Inst{8} = memsz.encoding{0}; // enough to distinguish 32- from 64-bit
4261 let Inst{6-0} = addr{6-0};
4264 // Multiclass that generates the non-writeback and writeback variants.
4265 multiclass MVE_VLDRSTR_qi_m<MVE_ldst_direction dir, MVE_memsz memsz,
4266 string asm, string suffix> {
4267 def "" : MVE_VLDRSTR_qi<dir, memsz, 0, (outs), asm, "", suffix>;
4268 def _pre : MVE_VLDRSTR_qi<dir, memsz, 1, (outs MQPR:$wb), asm, "!", suffix,
4269 "$addr.base = $wb"> {
4270 let DecoderMethod="DecodeMVE_MEM_3_pre<"#memsz.shift#">";
4274 // Actual instruction definitions.
4275 defm MVE_VLDRWU32_qi: MVE_VLDRSTR_qi_m<MVE_ld, MVE_memW, "vldrw", "u32">;
4276 defm MVE_VLDRDU64_qi: MVE_VLDRSTR_qi_m<MVE_ld, MVE_memD, "vldrd", "u64">;
4277 defm MVE_VSTRW32_qi: MVE_VLDRSTR_qi_m<MVE_st, MVE_memW, "vstrw", "32">;
4278 defm MVE_VSTRD64_qi: MVE_VLDRSTR_qi_m<MVE_st, MVE_memD, "vstrd", "64">;
4280 // Define aliases for all the instructions where memory size and
4281 // vector lane size are the same. These are mnemonic aliases, so they
4282 // apply consistently across all of the above families - contiguous
4283 // loads, and both the rq and qi types of gather/scatter.
4285 // Rationale: As long as you're loading (for example) 16-bit memory
4286 // values into 16-bit vector lanes, you can think of them as signed or
4287 // unsigned integers, fp16 or just raw 16-bit blobs and it makes no
4288 // difference. So we permit all of vldrh.16, vldrh.u16, vldrh.s16,
4289 // vldrh.f16 and treat them all as equivalent to the canonical
4290 // spelling (which happens to be .u16 for loads, and just .16 for
4293 foreach vpt_cond = ["", "t", "e"] in
4294 foreach memsz = [MVE_memB, MVE_memH, MVE_memW, MVE_memD] in
4295 foreach suffix = memsz.suffixes in {
4297 // These foreaches are conceptually ifs, implemented by iterating a
4298 // dummy variable over a list with 0 or 1 elements depending on the
4299 // condition. The idea is to iterate over _nearly_ all the suffixes
4300 // in memsz.suffixes, but omit the one we want all the others to alias.
4302 foreach _ = !if(!ne(suffix, memsz.CanonLoadSuffix), [1], []<int>) in
4303 def : MnemonicAlias<
4304 "vldr" # memsz.MnemonicLetter # vpt_cond # suffix,
4305 "vldr" # memsz.MnemonicLetter # vpt_cond # memsz.CanonLoadSuffix>;
4307 foreach _ = !if(!ne(suffix, memsz.CanonStoreSuffix), [1], []<int>) in
4308 def : MnemonicAlias<
4309 "vstr" # memsz.MnemonicLetter # vpt_cond # suffix,
4310 "vstr" # memsz.MnemonicLetter # vpt_cond # memsz.CanonStoreSuffix>;
4313 // end of MVE predicable load/store
4315 class MVE_VPT<string suffix, bits<2> size, dag iops, string asm, list<dag> pattern=[]>
4316 : MVE_MI<(outs ), iops, NoItinerary, !strconcat("vpt", "${Mk}", ".", suffix), asm, "", pattern> {
4321 let Inst{31-23} = 0b111111100;
4322 let Inst{22} = Mk{3};
4323 let Inst{21-20} = size;
4324 let Inst{19-17} = Qn{2-0};
4326 let Inst{15-13} = Mk{2-0};
4327 let Inst{12} = fc{2};
4328 let Inst{11-8} = 0b1111;
4329 let Inst{7} = fc{0};
4332 let Defs = [VPR, P0];
4335 class MVE_VPTt1<string suffix, bits<2> size, dag iops>
4336 : MVE_VPT<suffix, size, iops, "$fc, $Qn, $Qm"> {
4341 let Inst{5} = Qm{3};
4342 let Inst{3-1} = Qm{2-0};
4343 let Inst{0} = fc{1};
4346 class MVE_VPTt1i<string suffix, bits<2> size>
4347 : MVE_VPTt1<suffix, size,
4348 (ins vpt_mask:$Mk, pred_basic_i:$fc, MQPR:$Qn, MQPR:$Qm)> {
4353 def MVE_VPTv4i32 : MVE_VPTt1i<"i32", 0b10>;
4354 def MVE_VPTv8i16 : MVE_VPTt1i<"i16", 0b01>;
4355 def MVE_VPTv16i8 : MVE_VPTt1i<"i8", 0b00>;
4357 class MVE_VPTt1u<string suffix, bits<2> size>
4358 : MVE_VPTt1<suffix, size,
4359 (ins vpt_mask:$Mk, pred_basic_u:$fc, MQPR:$Qn, MQPR:$Qm)> {
4364 def MVE_VPTv4u32 : MVE_VPTt1u<"u32", 0b10>;
4365 def MVE_VPTv8u16 : MVE_VPTt1u<"u16", 0b01>;
4366 def MVE_VPTv16u8 : MVE_VPTt1u<"u8", 0b00>;
4368 class MVE_VPTt1s<string suffix, bits<2> size>
4369 : MVE_VPTt1<suffix, size,
4370 (ins vpt_mask:$Mk, pred_basic_s:$fc, MQPR:$Qn, MQPR:$Qm)> {
4374 def MVE_VPTv4s32 : MVE_VPTt1s<"s32", 0b10>;
4375 def MVE_VPTv8s16 : MVE_VPTt1s<"s16", 0b01>;
4376 def MVE_VPTv16s8 : MVE_VPTt1s<"s8", 0b00>;
4378 class MVE_VPTt2<string suffix, bits<2> size, dag iops>
4379 : MVE_VPT<suffix, size, iops,
4386 let Inst{5} = fc{1};
4387 let Inst{3-0} = Rm{3-0};
4390 class MVE_VPTt2i<string suffix, bits<2> size>
4391 : MVE_VPTt2<suffix, size,
4392 (ins vpt_mask:$Mk, pred_basic_i:$fc, MQPR:$Qn, GPRwithZR:$Rm)> {
4397 def MVE_VPTv4i32r : MVE_VPTt2i<"i32", 0b10>;
4398 def MVE_VPTv8i16r : MVE_VPTt2i<"i16", 0b01>;
4399 def MVE_VPTv16i8r : MVE_VPTt2i<"i8", 0b00>;
4401 class MVE_VPTt2u<string suffix, bits<2> size>
4402 : MVE_VPTt2<suffix, size,
4403 (ins vpt_mask:$Mk, pred_basic_u:$fc, MQPR:$Qn, GPRwithZR:$Rm)> {
4408 def MVE_VPTv4u32r : MVE_VPTt2u<"u32", 0b10>;
4409 def MVE_VPTv8u16r : MVE_VPTt2u<"u16", 0b01>;
4410 def MVE_VPTv16u8r : MVE_VPTt2u<"u8", 0b00>;
4412 class MVE_VPTt2s<string suffix, bits<2> size>
4413 : MVE_VPTt2<suffix, size,
4414 (ins vpt_mask:$Mk, pred_basic_s:$fc, MQPR:$Qn, GPRwithZR:$Rm)> {
4418 def MVE_VPTv4s32r : MVE_VPTt2s<"s32", 0b10>;
4419 def MVE_VPTv8s16r : MVE_VPTt2s<"s16", 0b01>;
4420 def MVE_VPTv16s8r : MVE_VPTt2s<"s8", 0b00>;
4423 class MVE_VPTf<string suffix, bit size, dag iops, string asm, list<dag> pattern=[]>
4424 : MVE_MI<(outs ), iops, NoItinerary, !strconcat("vpt", "${Mk}", ".", suffix), asm,
4430 let Inst{31-29} = 0b111;
4431 let Inst{28} = size;
4432 let Inst{27-23} = 0b11100;
4433 let Inst{22} = Mk{3};
4434 let Inst{21-20} = 0b11;
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};
4444 let Predicates = [HasMVEFloat];
4447 class MVE_VPTft1<string suffix, bit size>
4448 : MVE_VPTf<suffix, size, (ins vpt_mask:$Mk, pred_basic_fp:$fc, MQPR:$Qn, MQPR:$Qm),
4454 let Inst{5} = Qm{3};
4455 let Inst{3-1} = Qm{2-0};
4456 let Inst{0} = fc{1};
4459 def MVE_VPTv4f32 : MVE_VPTft1<"f32", 0b0>;
4460 def MVE_VPTv8f16 : MVE_VPTft1<"f16", 0b1>;
4462 class MVE_VPTft2<string suffix, bit size>
4463 : MVE_VPTf<suffix, size, (ins vpt_mask:$Mk, pred_basic_fp:$fc, MQPR:$Qn, GPRwithZR:$Rm),
4469 let Inst{5} = fc{1};
4470 let Inst{3-0} = Rm{3-0};
4473 def MVE_VPTv4f32r : MVE_VPTft2<"f32", 0b0>;
4474 def MVE_VPTv8f16r : MVE_VPTft2<"f16", 0b1>;
4476 def MVE_VPST : MVE_MI<(outs ), (ins vpt_mask:$Mk), NoItinerary,
4477 !strconcat("vpst", "${Mk}"), "", "", []> {
4480 let Inst{31-23} = 0b111111100;
4481 let Inst{22} = Mk{3};
4482 let Inst{21-16} = 0b110001;
4483 let Inst{15-13} = Mk{2-0};
4484 let Inst{12-0} = 0b0111101001101;
4485 let Unpredictable{12} = 0b1;
4486 let Unpredictable{7} = 0b1;
4487 let Unpredictable{5} = 0b1;
4492 def MVE_VPSEL : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm), NoItinerary,
4493 "vpsel", "", "$Qd, $Qn, $Qm", vpred_n, "", []> {
4499 let Inst{25-23} = 0b100;
4500 let Inst{22} = Qd{3};
4501 let Inst{21-20} = 0b11;
4502 let Inst{19-17} = Qn{2-0};
4504 let Inst{15-13} = Qd{2-0};
4505 let Inst{12-9} = 0b0111;
4507 let Inst{7} = Qn{3};
4509 let Inst{5} = Qm{3};
4511 let Inst{3-1} = Qm{2-0};
4515 foreach suffix = ["s8", "s16", "s32", "u8", "u16", "u32",
4516 "i8", "i16", "i32", "f16", "f32"] in
4517 def : MVEInstAlias<"vpsel${vp}." # suffix # "\t$Qd, $Qn, $Qm",
4518 (MVE_VPSEL MQPR:$Qd, MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
4520 let Predicates = [HasMVEInt] in {
4521 def : Pat<(v16i8 (vselect (v16i1 VCCR:$pred), (v16i8 MQPR:$v1), (v16i8 MQPR:$v2))),
4522 (v16i8 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0, VCCR:$pred))>;
4523 def : Pat<(v8i16 (vselect (v8i1 VCCR:$pred), (v8i16 MQPR:$v1), (v8i16 MQPR:$v2))),
4524 (v8i16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0, VCCR:$pred))>;
4525 def : Pat<(v4i32 (vselect (v4i1 VCCR:$pred), (v4i32 MQPR:$v1), (v4i32 MQPR:$v2))),
4526 (v4i32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0, VCCR:$pred))>;
4528 def : Pat<(v8f16 (vselect (v8i1 VCCR:$pred), (v8f16 MQPR:$v1), (v8f16 MQPR:$v2))),
4529 (v8f16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0, VCCR:$pred))>;
4530 def : Pat<(v4f32 (vselect (v4i1 VCCR:$pred), (v4f32 MQPR:$v1), (v4f32 MQPR:$v2))),
4531 (v4f32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0, VCCR:$pred))>;
4533 def : Pat<(v16i8 (vselect (v16i8 MQPR:$pred), (v16i8 MQPR:$v1), (v16i8 MQPR:$v2))),
4534 (v16i8 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0,
4535 (MVE_VCMPi8 (v16i8 MQPR:$pred), (MVE_VMOVimmi8 0), 1)))>;
4536 def : Pat<(v8i16 (vselect (v8i16 MQPR:$pred), (v8i16 MQPR:$v1), (v8i16 MQPR:$v2))),
4537 (v8i16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0,
4538 (MVE_VCMPi16 (v8i16 MQPR:$pred), (MVE_VMOVimmi16 0), 1)))>;
4539 def : Pat<(v4i32 (vselect (v4i32 MQPR:$pred), (v4i32 MQPR:$v1), (v4i32 MQPR:$v2))),
4540 (v4i32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0,
4541 (MVE_VCMPi32 (v4i32 MQPR:$pred), (MVE_VMOVimmi32 0), 1)))>;
4543 def : Pat<(v8f16 (vselect (v8i16 MQPR:$pred), (v8f16 MQPR:$v1), (v8f16 MQPR:$v2))),
4544 (v8f16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0,
4545 (MVE_VCMPi16 (v8i16 MQPR:$pred), (MVE_VMOVimmi16 0), 1)))>;
4546 def : Pat<(v4f32 (vselect (v4i32 MQPR:$pred), (v4f32 MQPR:$v1), (v4f32 MQPR:$v2))),
4547 (v4f32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, 0,
4548 (MVE_VCMPi32 (v4i32 MQPR:$pred), (MVE_VMOVimmi32 0), 1)))>;
4550 def : Pat<(v16i8 (zext (v16i1 VCCR:$pred))),
4551 (v16i8 (MVE_VPSEL (MVE_VMOVimmi8 1), (MVE_VMOVimmi8 0), 0, VCCR:$pred))>;
4552 def : Pat<(v8i16 (zext (v8i1 VCCR:$pred))),
4553 (v8i16 (MVE_VPSEL (MVE_VMOVimmi16 1), (MVE_VMOVimmi16 0), 0, VCCR:$pred))>;
4554 def : Pat<(v4i32 (zext (v4i1 VCCR:$pred))),
4555 (v4i32 (MVE_VPSEL (MVE_VMOVimmi32 1), (MVE_VMOVimmi32 0), 0, VCCR:$pred))>;
4557 def : Pat<(v16i8 (sext (v16i1 VCCR:$pred))),
4558 (v16i8 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi8 0), 0, VCCR:$pred))>;
4559 def : Pat<(v8i16 (sext (v8i1 VCCR:$pred))),
4560 (v8i16 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi16 0), 0, VCCR:$pred))>;
4561 def : Pat<(v4i32 (sext (v4i1 VCCR:$pred))),
4562 (v4i32 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi32 0), 0, VCCR:$pred))>;
4564 def : Pat<(v16i8 (anyext (v16i1 VCCR:$pred))),
4565 (v16i8 (MVE_VPSEL (MVE_VMOVimmi8 1), (MVE_VMOVimmi8 0), 0, VCCR:$pred))>;
4566 def : Pat<(v8i16 (anyext (v8i1 VCCR:$pred))),
4567 (v8i16 (MVE_VPSEL (MVE_VMOVimmi16 1), (MVE_VMOVimmi16 0), 0, VCCR:$pred))>;
4568 def : Pat<(v4i32 (anyext (v4i1 VCCR:$pred))),
4569 (v4i32 (MVE_VPSEL (MVE_VMOVimmi32 1), (MVE_VMOVimmi32 0), 0, VCCR:$pred))>;
4572 def MVE_VPNOT : MVE_p<(outs), (ins), NoItinerary,
4573 "vpnot", "", "", vpred_n, "", []> {
4574 let Inst{31-0} = 0b11111110001100010000111101001101;
4575 let Unpredictable{19-17} = 0b111;
4576 let Unpredictable{12} = 0b1;
4577 let Unpredictable{7} = 0b1;
4578 let Unpredictable{5} = 0b1;
4582 let Constraints = "";
4585 class MVE_loltp_start<dag iops, string asm, string ops, bits<2> size>
4586 : t2LOL<(outs GPRlr:$LR), iops, asm, ops> {
4588 let Predicates = [HasMVEInt];
4590 let Inst{21-20} = size;
4591 let Inst{19-16} = Rn{3-0};
4595 class MVE_DLSTP<string asm, bits<2> size>
4596 : MVE_loltp_start<(ins rGPR:$Rn), asm, "$LR, $Rn", size> {
4598 let Inst{11-1} = 0b00000000000;
4599 let Unpredictable{10-1} = 0b1111111111;
4602 class MVE_WLSTP<string asm, bits<2> size>
4603 : MVE_loltp_start<(ins rGPR:$Rn, wlslabel_u11:$label),
4604 asm, "$LR, $Rn, $label", size> {
4607 let Inst{11} = label{0};
4608 let Inst{10-1} = label{10-1};
4611 def MVE_DLSTP_8 : MVE_DLSTP<"dlstp.8", 0b00>;
4612 def MVE_DLSTP_16 : MVE_DLSTP<"dlstp.16", 0b01>;
4613 def MVE_DLSTP_32 : MVE_DLSTP<"dlstp.32", 0b10>;
4614 def MVE_DLSTP_64 : MVE_DLSTP<"dlstp.64", 0b11>;
4616 def MVE_WLSTP_8 : MVE_WLSTP<"wlstp.8", 0b00>;
4617 def MVE_WLSTP_16 : MVE_WLSTP<"wlstp.16", 0b01>;
4618 def MVE_WLSTP_32 : MVE_WLSTP<"wlstp.32", 0b10>;
4619 def MVE_WLSTP_64 : MVE_WLSTP<"wlstp.64", 0b11>;
4621 class MVE_loltp_end<dag oops, dag iops, string asm, string ops>
4622 : t2LOL<oops, iops, asm, ops> {
4623 let Predicates = [HasMVEInt];
4624 let Inst{22-21} = 0b00;
4625 let Inst{19-16} = 0b1111;
4629 def MVE_LETP : MVE_loltp_end<(outs GPRlr:$LRout),
4630 (ins GPRlr:$LRin, lelabel_u11:$label),
4631 "letp", "$LRin, $label"> {
4635 let Inst{11} = label{0};
4636 let Inst{10-1} = label{10-1};
4639 def MVE_LCTP : MVE_loltp_end<(outs), (ins pred:$p), "lctp${p}", ""> {
4642 let Inst{11-1} = 0b00000000000;
4643 let Unpredictable{21-20} = 0b11;
4644 let Unpredictable{11-1} = 0b11111111111;
4648 //===----------------------------------------------------------------------===//
4650 //===----------------------------------------------------------------------===//
4652 class MVE_unpred_vector_store_typed<ValueType Ty, Instruction RegImmInst,
4653 PatFrag StoreKind, int shift>
4654 : Pat<(StoreKind (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr),
4655 (RegImmInst (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr)>;
4657 multiclass MVE_unpred_vector_store<Instruction RegImmInst, PatFrag StoreKind,
4659 def : MVE_unpred_vector_store_typed<v16i8, RegImmInst, StoreKind, shift>;
4660 def : MVE_unpred_vector_store_typed<v8i16, RegImmInst, StoreKind, shift>;
4661 def : MVE_unpred_vector_store_typed<v8f16, RegImmInst, StoreKind, shift>;
4662 def : MVE_unpred_vector_store_typed<v4i32, RegImmInst, StoreKind, shift>;
4663 def : MVE_unpred_vector_store_typed<v4f32, RegImmInst, StoreKind, shift>;
4664 def : MVE_unpred_vector_store_typed<v2i64, RegImmInst, StoreKind, shift>;
4665 def : MVE_unpred_vector_store_typed<v2f64, RegImmInst, StoreKind, shift>;
4668 class MVE_unpred_vector_load_typed<ValueType Ty, Instruction RegImmInst,
4669 PatFrag LoadKind, int shift>
4670 : Pat<(Ty (LoadKind t2addrmode_imm7<shift>:$addr)),
4671 (Ty (RegImmInst t2addrmode_imm7<shift>:$addr))>;
4673 multiclass MVE_unpred_vector_load<Instruction RegImmInst, PatFrag LoadKind,
4675 def : MVE_unpred_vector_load_typed<v16i8, RegImmInst, LoadKind, shift>;
4676 def : MVE_unpred_vector_load_typed<v8i16, RegImmInst, LoadKind, shift>;
4677 def : MVE_unpred_vector_load_typed<v8f16, RegImmInst, LoadKind, shift>;
4678 def : MVE_unpred_vector_load_typed<v4i32, RegImmInst, LoadKind, shift>;
4679 def : MVE_unpred_vector_load_typed<v4f32, RegImmInst, LoadKind, shift>;
4680 def : MVE_unpred_vector_load_typed<v2i64, RegImmInst, LoadKind, shift>;
4681 def : MVE_unpred_vector_load_typed<v2f64, RegImmInst, LoadKind, shift>;
4684 let Predicates = [HasMVEInt, IsLE] in {
4685 defm : MVE_unpred_vector_store<MVE_VSTRBU8, byte_alignedstore, 0>;
4686 defm : MVE_unpred_vector_store<MVE_VSTRHU16, hword_alignedstore, 1>;
4687 defm : MVE_unpred_vector_store<MVE_VSTRWU32, alignedstore32, 2>;
4689 defm : MVE_unpred_vector_load<MVE_VLDRBU8, byte_alignedload, 0>;
4690 defm : MVE_unpred_vector_load<MVE_VLDRHU16, hword_alignedload, 1>;
4691 defm : MVE_unpred_vector_load<MVE_VLDRWU32, alignedload32, 2>;
4693 def : Pat<(v16i1 (load t2addrmode_imm7<2>:$addr)),
4694 (v16i1 (VLDR_P0_off t2addrmode_imm7<2>:$addr))>;
4695 def : Pat<(v8i1 (load t2addrmode_imm7<2>:$addr)),
4696 (v8i1 (VLDR_P0_off t2addrmode_imm7<2>:$addr))>;
4697 def : Pat<(v4i1 (load t2addrmode_imm7<2>:$addr)),
4698 (v4i1 (VLDR_P0_off t2addrmode_imm7<2>:$addr))>;
4701 let Predicates = [HasMVEInt, IsBE] in {
4702 def : MVE_unpred_vector_store_typed<v16i8, MVE_VSTRBU8, store, 0>;
4703 def : MVE_unpred_vector_store_typed<v8i16, MVE_VSTRHU16, alignedstore16, 1>;
4704 def : MVE_unpred_vector_store_typed<v8f16, MVE_VSTRHU16, alignedstore16, 1>;
4705 def : MVE_unpred_vector_store_typed<v4i32, MVE_VSTRWU32, alignedstore32, 2>;
4706 def : MVE_unpred_vector_store_typed<v4f32, MVE_VSTRWU32, alignedstore32, 2>;
4708 def : MVE_unpred_vector_load_typed<v16i8, MVE_VLDRBU8, load, 0>;
4709 def : MVE_unpred_vector_load_typed<v8i16, MVE_VLDRHU16, alignedload16, 1>;
4710 def : MVE_unpred_vector_load_typed<v8f16, MVE_VLDRHU16, alignedload16, 1>;
4711 def : MVE_unpred_vector_load_typed<v4i32, MVE_VLDRWU32, alignedload32, 2>;
4712 def : MVE_unpred_vector_load_typed<v4f32, MVE_VLDRWU32, alignedload32, 2>;
4716 // Widening/Narrowing Loads/Stores
4718 let Predicates = [HasMVEInt] in {
4719 def : Pat<(truncstorevi8 (v8i16 MQPR:$val), t2addrmode_imm7<1>:$addr),
4720 (MVE_VSTRB16 MQPR:$val, t2addrmode_imm7<1>:$addr)>;
4721 def : Pat<(truncstorevi8 (v4i32 MQPR:$val), t2addrmode_imm7<1>:$addr),
4722 (MVE_VSTRB32 MQPR:$val, t2addrmode_imm7<1>:$addr)>;
4723 def : Pat<(truncstorevi16 (v4i32 MQPR:$val), t2addrmode_imm7<2>:$addr),
4724 (MVE_VSTRH32 MQPR:$val, t2addrmode_imm7<2>:$addr)>;
4727 multiclass MVEExtLoad<string DestLanes, string DestElemBits,
4728 string SrcElemBits, string SrcElemType,
4730 def _Any : Pat<(!cast<ValueType>("v" # DestLanes # "i" # DestElemBits)
4731 (!cast<PatFrag>("extloadvi" # SrcElemBits) am:$addr)),
4732 (!cast<Instruction>("MVE_VLDR" # SrcElemType # "U" # DestElemBits)
4734 def _Z : Pat<(!cast<ValueType>("v" # DestLanes # "i" # DestElemBits)
4735 (!cast<PatFrag>("zextloadvi" # SrcElemBits) am:$addr)),
4736 (!cast<Instruction>("MVE_VLDR" # SrcElemType # "U" # DestElemBits)
4738 def _S : Pat<(!cast<ValueType>("v" # DestLanes # "i" # DestElemBits)
4739 (!cast<PatFrag>("sextloadvi" # SrcElemBits) am:$addr)),
4740 (!cast<Instruction>("MVE_VLDR" # SrcElemType # "S" # DestElemBits)
4744 let Predicates = [HasMVEInt] in {
4745 defm : MVEExtLoad<"4", "32", "8", "B", t2addrmode_imm7<1>>;
4746 defm : MVEExtLoad<"8", "16", "8", "B", t2addrmode_imm7<1>>;
4747 defm : MVEExtLoad<"4", "32", "16", "H", t2addrmode_imm7<2>>;
4751 // Bit convert patterns
4753 let Predicates = [HasMVEInt] in {
4754 def : Pat<(v2f64 (bitconvert (v2i64 QPR:$src))), (v2f64 QPR:$src)>;
4755 def : Pat<(v2i64 (bitconvert (v2f64 QPR:$src))), (v2i64 QPR:$src)>;
4757 def : Pat<(v4i32 (bitconvert (v4f32 QPR:$src))), (v4i32 QPR:$src)>;
4758 def : Pat<(v4f32 (bitconvert (v4i32 QPR:$src))), (v4f32 QPR:$src)>;
4760 def : Pat<(v8i16 (bitconvert (v8f16 QPR:$src))), (v8i16 QPR:$src)>;
4761 def : Pat<(v8f16 (bitconvert (v8i16 QPR:$src))), (v8f16 QPR:$src)>;
4764 let Predicates = [IsLE,HasMVEInt] in {
4765 def : Pat<(v2f64 (bitconvert (v4f32 QPR:$src))), (v2f64 QPR:$src)>;
4766 def : Pat<(v2f64 (bitconvert (v4i32 QPR:$src))), (v2f64 QPR:$src)>;
4767 def : Pat<(v2f64 (bitconvert (v8f16 QPR:$src))), (v2f64 QPR:$src)>;
4768 def : Pat<(v2f64 (bitconvert (v8i16 QPR:$src))), (v2f64 QPR:$src)>;
4769 def : Pat<(v2f64 (bitconvert (v16i8 QPR:$src))), (v2f64 QPR:$src)>;
4771 def : Pat<(v2i64 (bitconvert (v4f32 QPR:$src))), (v2i64 QPR:$src)>;
4772 def : Pat<(v2i64 (bitconvert (v4i32 QPR:$src))), (v2i64 QPR:$src)>;
4773 def : Pat<(v2i64 (bitconvert (v8f16 QPR:$src))), (v2i64 QPR:$src)>;
4774 def : Pat<(v2i64 (bitconvert (v8i16 QPR:$src))), (v2i64 QPR:$src)>;
4775 def : Pat<(v2i64 (bitconvert (v16i8 QPR:$src))), (v2i64 QPR:$src)>;
4777 def : Pat<(v4f32 (bitconvert (v2f64 QPR:$src))), (v4f32 QPR:$src)>;
4778 def : Pat<(v4f32 (bitconvert (v2i64 QPR:$src))), (v4f32 QPR:$src)>;
4779 def : Pat<(v4f32 (bitconvert (v8f16 QPR:$src))), (v4f32 QPR:$src)>;
4780 def : Pat<(v4f32 (bitconvert (v8i16 QPR:$src))), (v4f32 QPR:$src)>;
4781 def : Pat<(v4f32 (bitconvert (v16i8 QPR:$src))), (v4f32 QPR:$src)>;
4783 def : Pat<(v4i32 (bitconvert (v2f64 QPR:$src))), (v4i32 QPR:$src)>;
4784 def : Pat<(v4i32 (bitconvert (v2i64 QPR:$src))), (v4i32 QPR:$src)>;
4785 def : Pat<(v4i32 (bitconvert (v8f16 QPR:$src))), (v4i32 QPR:$src)>;
4786 def : Pat<(v4i32 (bitconvert (v8i16 QPR:$src))), (v4i32 QPR:$src)>;
4787 def : Pat<(v4i32 (bitconvert (v16i8 QPR:$src))), (v4i32 QPR:$src)>;
4789 def : Pat<(v8f16 (bitconvert (v2f64 QPR:$src))), (v8f16 QPR:$src)>;
4790 def : Pat<(v8f16 (bitconvert (v2i64 QPR:$src))), (v8f16 QPR:$src)>;
4791 def : Pat<(v8f16 (bitconvert (v4f32 QPR:$src))), (v8f16 QPR:$src)>;
4792 def : Pat<(v8f16 (bitconvert (v4i32 QPR:$src))), (v8f16 QPR:$src)>;
4793 def : Pat<(v8f16 (bitconvert (v16i8 QPR:$src))), (v8f16 QPR:$src)>;
4795 def : Pat<(v8i16 (bitconvert (v2f64 QPR:$src))), (v8i16 QPR:$src)>;
4796 def : Pat<(v8i16 (bitconvert (v2i64 QPR:$src))), (v8i16 QPR:$src)>;
4797 def : Pat<(v8i16 (bitconvert (v4f32 QPR:$src))), (v8i16 QPR:$src)>;
4798 def : Pat<(v8i16 (bitconvert (v4i32 QPR:$src))), (v8i16 QPR:$src)>;
4799 def : Pat<(v8i16 (bitconvert (v16i8 QPR:$src))), (v8i16 QPR:$src)>;
4801 def : Pat<(v16i8 (bitconvert (v2f64 QPR:$src))), (v16i8 QPR:$src)>;
4802 def : Pat<(v16i8 (bitconvert (v2i64 QPR:$src))), (v16i8 QPR:$src)>;
4803 def : Pat<(v16i8 (bitconvert (v4f32 QPR:$src))), (v16i8 QPR:$src)>;
4804 def : Pat<(v16i8 (bitconvert (v4i32 QPR:$src))), (v16i8 QPR:$src)>;
4805 def : Pat<(v16i8 (bitconvert (v8f16 QPR:$src))), (v16i8 QPR:$src)>;
4806 def : Pat<(v16i8 (bitconvert (v8i16 QPR:$src))), (v16i8 QPR:$src)>;