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 //===----------------------------------------------------------------------===//
14 def vpt_mask : Operand<i32> {
15 let PrintMethod = "printVPTMask";
16 let ParserMatchClass = it_mask_asmoperand;
17 let EncoderMethod = "getVPTMaskOpValue";
18 let DecoderMethod = "DecodeVPTMaskOperand";
21 // VPT/VCMP restricted predicate for sign invariant types
22 def pred_restricted_i_asmoperand : AsmOperandClass {
23 let Name = "CondCodeRestrictedI";
24 let RenderMethod = "addITCondCodeOperands";
25 let PredicateMethod = "isITCondCodeRestrictedI";
26 let ParserMethod = "parseITCondCode";
27 let DiagnosticString = "condition code for sign-independent integer "#
28 "comparison must be EQ or NE";
31 // VPT/VCMP restricted predicate for signed types
32 def pred_restricted_s_asmoperand : AsmOperandClass {
33 let Name = "CondCodeRestrictedS";
34 let RenderMethod = "addITCondCodeOperands";
35 let PredicateMethod = "isITCondCodeRestrictedS";
36 let ParserMethod = "parseITCondCode";
37 let DiagnosticString = "condition code for signed integer "#
38 "comparison must be EQ, NE, LT, GT, LE or GE";
41 // VPT/VCMP restricted predicate for unsigned types
42 def pred_restricted_u_asmoperand : AsmOperandClass {
43 let Name = "CondCodeRestrictedU";
44 let RenderMethod = "addITCondCodeOperands";
45 let PredicateMethod = "isITCondCodeRestrictedU";
46 let ParserMethod = "parseITCondCode";
47 let DiagnosticString = "condition code for unsigned integer "#
48 "comparison must be EQ, NE, HS or HI";
51 // VPT/VCMP restricted predicate for floating point
52 def pred_restricted_fp_asmoperand : AsmOperandClass {
53 let Name = "CondCodeRestrictedFP";
54 let RenderMethod = "addITCondCodeOperands";
55 let PredicateMethod = "isITCondCodeRestrictedFP";
56 let ParserMethod = "parseITCondCode";
57 let DiagnosticString = "condition code for floating-point "#
58 "comparison must be EQ, NE, LT, GT, LE or GE";
61 class VCMPPredicateOperand : Operand<i32>;
63 def pred_basic_i : VCMPPredicateOperand {
64 let PrintMethod = "printMandatoryRestrictedPredicateOperand";
65 let ParserMatchClass = pred_restricted_i_asmoperand;
66 let DecoderMethod = "DecodeRestrictedIPredicateOperand";
67 let EncoderMethod = "getRestrictedCondCodeOpValue";
70 def pred_basic_u : VCMPPredicateOperand {
71 let PrintMethod = "printMandatoryRestrictedPredicateOperand";
72 let ParserMatchClass = pred_restricted_u_asmoperand;
73 let DecoderMethod = "DecodeRestrictedUPredicateOperand";
74 let EncoderMethod = "getRestrictedCondCodeOpValue";
77 def pred_basic_s : VCMPPredicateOperand {
78 let PrintMethod = "printMandatoryRestrictedPredicateOperand";
79 let ParserMatchClass = pred_restricted_s_asmoperand;
80 let DecoderMethod = "DecodeRestrictedSPredicateOperand";
81 let EncoderMethod = "getRestrictedCondCodeOpValue";
84 def pred_basic_fp : VCMPPredicateOperand {
85 let PrintMethod = "printMandatoryRestrictedPredicateOperand";
86 let ParserMatchClass = pred_restricted_fp_asmoperand;
87 let DecoderMethod = "DecodeRestrictedFPPredicateOperand";
88 let EncoderMethod = "getRestrictedCondCodeOpValue";
91 // Register list operands for interleaving load/stores
92 def VecList2QAsmOperand : AsmOperandClass {
93 let Name = "VecListTwoMQ";
94 let ParserMethod = "parseVectorList";
95 let RenderMethod = "addMVEVecListOperands";
96 let DiagnosticString = "operand must be a list of two consecutive "#
97 "q-registers in range [q0,q7]";
100 def VecList2Q : RegisterOperand<MQQPR, "printMVEVectorListTwoQ"> {
101 let ParserMatchClass = VecList2QAsmOperand;
102 let PrintMethod = "printMVEVectorList<2>";
105 def VecList4QAsmOperand : AsmOperandClass {
106 let Name = "VecListFourMQ";
107 let ParserMethod = "parseVectorList";
108 let RenderMethod = "addMVEVecListOperands";
109 let DiagnosticString = "operand must be a list of four consecutive "#
110 "q-registers in range [q0,q7]";
113 def VecList4Q : RegisterOperand<MQQQQPR, "printMVEVectorListFourQ"> {
114 let ParserMatchClass = VecList4QAsmOperand;
115 let PrintMethod = "printMVEVectorList<4>";
118 // taddrmode_imm7 := reg[r0-r7] +/- (imm7 << shift)
119 class TMemImm7ShiftOffsetAsmOperand<int shift> : AsmOperandClass {
120 let Name = "TMemImm7Shift"#shift#"Offset";
121 let PredicateMethod = "isMemImm7ShiftedOffset<"#shift#",ARM::tGPRRegClassID>";
122 let RenderMethod = "addMemImmOffsetOperands";
125 class taddrmode_imm7<int shift> : MemOperand,
126 ComplexPattern<i32, 2, "SelectTAddrModeImm7<"#shift#">", []> {
127 let ParserMatchClass = TMemImm7ShiftOffsetAsmOperand<shift>;
128 // They are printed the same way as the T2 imm8 version
129 let PrintMethod = "printT2AddrModeImm8Operand<false>";
130 // This can also be the same as the T2 version.
131 let EncoderMethod = "getT2AddrModeImmOpValue<7,"#shift#">";
132 let DecoderMethod = "DecodeTAddrModeImm7<"#shift#">";
133 let MIOperandInfo = (ops tGPR:$base, i32imm:$offsimm);
136 // t2addrmode_imm7 := reg +/- (imm7)
137 class MemImm7ShiftOffsetAsmOperand<int shift> : AsmOperandClass {
138 let Name = "MemImm7Shift"#shift#"Offset";
139 let PredicateMethod = "isMemImm7ShiftedOffset<" # shift #
140 ",ARM::GPRnopcRegClassID>";
141 let RenderMethod = "addMemImmOffsetOperands";
144 def MemImm7Shift0OffsetAsmOperand : MemImm7ShiftOffsetAsmOperand<0>;
145 def MemImm7Shift1OffsetAsmOperand : MemImm7ShiftOffsetAsmOperand<1>;
146 def MemImm7Shift2OffsetAsmOperand : MemImm7ShiftOffsetAsmOperand<2>;
147 class T2AddrMode_Imm7<int shift> : MemOperand,
148 ComplexPattern<i32, 2, "SelectT2AddrModeImm7<"#shift#">", []> {
149 let EncoderMethod = "getT2AddrModeImmOpValue<7,"#shift#">";
150 let DecoderMethod = "DecodeT2AddrModeImm7<"#shift#", 0>";
151 let ParserMatchClass =
152 !cast<AsmOperandClass>("MemImm7Shift"#shift#"OffsetAsmOperand");
153 let MIOperandInfo = (ops GPRnopc:$base, i32imm:$offsimm);
156 class t2addrmode_imm7<int shift> : T2AddrMode_Imm7<shift> {
157 // They are printed the same way as the imm8 version
158 let PrintMethod = "printT2AddrModeImm8Operand<false>";
161 class MemImm7ShiftOffsetWBAsmOperand<int shift> : AsmOperandClass {
162 let Name = "MemImm7Shift"#shift#"OffsetWB";
163 let PredicateMethod = "isMemImm7ShiftedOffset<" # shift #
164 ",ARM::rGPRRegClassID>";
165 let RenderMethod = "addMemImmOffsetOperands";
168 def MemImm7Shift0OffsetWBAsmOperand : MemImm7ShiftOffsetWBAsmOperand<0>;
169 def MemImm7Shift1OffsetWBAsmOperand : MemImm7ShiftOffsetWBAsmOperand<1>;
170 def MemImm7Shift2OffsetWBAsmOperand : MemImm7ShiftOffsetWBAsmOperand<2>;
172 class t2addrmode_imm7_pre<int shift> : T2AddrMode_Imm7<shift> {
173 // They are printed the same way as the imm8 version
174 let PrintMethod = "printT2AddrModeImm8Operand<true>";
175 let ParserMatchClass =
176 !cast<AsmOperandClass>("MemImm7Shift"#shift#"OffsetWBAsmOperand");
177 let DecoderMethod = "DecodeT2AddrModeImm7<"#shift#", 1>";
178 let MIOperandInfo = (ops rGPR:$base, i32imm:$offsim);
181 class t2am_imm7shiftOffsetAsmOperand<int shift>
182 : AsmOperandClass { let Name = "Imm7Shift"#shift; }
183 def t2am_imm7shift0OffsetAsmOperand : t2am_imm7shiftOffsetAsmOperand<0>;
184 def t2am_imm7shift1OffsetAsmOperand : t2am_imm7shiftOffsetAsmOperand<1>;
185 def t2am_imm7shift2OffsetAsmOperand : t2am_imm7shiftOffsetAsmOperand<2>;
187 class t2am_imm7_offset<int shift>
189 ComplexPattern<i32, 1, "SelectT2AddrModeImm7Offset<"#shift#">"> {
190 // They are printed the same way as the imm8 version
191 let PrintMethod = "printT2AddrModeImm8OffsetOperand";
192 let ParserMatchClass =
193 !cast<AsmOperandClass>("t2am_imm7shift"#shift#"OffsetAsmOperand");
194 let EncoderMethod = "getT2ScaledImmOpValue<7,"#shift#">";
195 let DecoderMethod = "DecodeT2Imm7<"#shift#">";
196 let WantsRoot = true;
199 // Operands for gather/scatter loads of the form [Rbase, Qoffsets]
200 class MemRegRQOffsetAsmOperand<int shift> : AsmOperandClass {
201 let Name = "MemRegRQS"#shift#"Offset";
202 let PredicateMethod = "isMemRegRQOffset<"#shift#">";
203 let RenderMethod = "addMemRegRQOffsetOperands";
206 def MemRegRQS0OffsetAsmOperand : MemRegRQOffsetAsmOperand<0>;
207 def MemRegRQS1OffsetAsmOperand : MemRegRQOffsetAsmOperand<1>;
208 def MemRegRQS2OffsetAsmOperand : MemRegRQOffsetAsmOperand<2>;
209 def MemRegRQS3OffsetAsmOperand : MemRegRQOffsetAsmOperand<3>;
211 // mve_addr_rq_shift := reg + vreg{ << UXTW #shift}
212 class mve_addr_rq_shift<int shift> : MemOperand {
213 let EncoderMethod = "getMveAddrModeRQOpValue";
214 let PrintMethod = "printMveAddrModeRQOperand<"#shift#">";
215 let ParserMatchClass =
216 !cast<AsmOperandClass>("MemRegRQS"#shift#"OffsetAsmOperand");
217 let DecoderMethod = "DecodeMveAddrModeRQ";
218 let MIOperandInfo = (ops GPRnopc:$base, MQPR:$offsreg);
221 class MemRegQOffsetAsmOperand<int shift> : AsmOperandClass {
222 let Name = "MemRegQS"#shift#"Offset";
223 let PredicateMethod = "isMemRegQOffset<"#shift#">";
224 let RenderMethod = "addMemImmOffsetOperands";
227 def MemRegQS2OffsetAsmOperand : MemRegQOffsetAsmOperand<2>;
228 def MemRegQS3OffsetAsmOperand : MemRegQOffsetAsmOperand<3>;
230 // mve_addr_q_shift := vreg {+ #imm7s2/4}
231 class mve_addr_q_shift<int shift> : MemOperand {
232 let EncoderMethod = "getMveAddrModeQOpValue<"#shift#">";
233 // Can be printed same way as other reg + imm operands
234 let PrintMethod = "printT2AddrModeImm8Operand<false>";
235 let ParserMatchClass =
236 !cast<AsmOperandClass>("MemRegQS"#shift#"OffsetAsmOperand");
237 let DecoderMethod = "DecodeMveAddrModeQ<"#shift#">";
238 let MIOperandInfo = (ops MQPR:$base, i32imm:$imm);
241 // A family of classes wrapping up information about the vector types
243 class MVEVectorVTInfo<ValueType vec, ValueType dblvec,
244 ValueType pred, ValueType dblpred,
245 bits<2> size, string suffixletter, bit unsigned> {
246 // The LLVM ValueType representing the vector, so we can use it in
250 // The LLVM ValueType representing a vector with elements double the size
251 // of those in Vec, so we can use it in ISel patterns. It is up to the
252 // invoker of this class to ensure that this is a correct choice.
253 ValueType DblVec = dblvec;
255 // An LLVM ValueType representing a corresponding vector of
256 // predicate bits, for use in ISel patterns that handle an IR
257 // intrinsic describing the predicated form of the instruction.
258 ValueType Pred = pred;
260 // Same as Pred but for DblVec rather than Vec.
261 ValueType DblPred = dblpred;
263 // The most common representation of the vector element size in MVE
264 // instruction encodings: a 2-bit value V representing an (8<<V)-bit
268 // For vectors explicitly mentioning a signedness of integers: 0 for
269 // signed and 1 for unsigned. For anything else, undefined.
270 bit Unsigned = unsigned;
272 // The number of bits in a vector element, in integer form.
273 int LaneBits = !shl(8, Size);
275 // The suffix used in assembly language on an instruction operating
276 // on this lane if it only cares about number of bits.
277 string BitsSuffix = !if(!eq(suffixletter, "p"),
278 !if(!eq(unsigned, 0b0), "8", "16"),
279 !cast<string>(LaneBits));
281 // The suffix used on an instruction that mentions the whole type.
282 string Suffix = suffixletter # BitsSuffix;
284 // The letter part of the suffix only.
285 string SuffixLetter = suffixletter;
288 // Integer vector types that don't treat signed and unsigned differently.
289 def MVE_v16i8 : MVEVectorVTInfo<v16i8, v8i16, v16i1, v8i1, 0b00, "i", ?>;
290 def MVE_v8i16 : MVEVectorVTInfo<v8i16, v4i32, v8i1, v4i1, 0b01, "i", ?>;
291 def MVE_v4i32 : MVEVectorVTInfo<v4i32, v2i64, v4i1, v2i1, 0b10, "i", ?>;
292 def MVE_v2i64 : MVEVectorVTInfo<v2i64, ?, v2i1, ?, 0b11, "i", ?>;
294 // Explicitly signed and unsigned integer vectors. They map to the
295 // same set of LLVM ValueTypes as above, but are represented
296 // differently in assembly and instruction encodings.
297 def MVE_v16s8 : MVEVectorVTInfo<v16i8, v8i16, v16i1, v8i1, 0b00, "s", 0b0>;
298 def MVE_v8s16 : MVEVectorVTInfo<v8i16, v4i32, v8i1, v4i1, 0b01, "s", 0b0>;
299 def MVE_v4s32 : MVEVectorVTInfo<v4i32, v2i64, v4i1, v2i1, 0b10, "s", 0b0>;
300 def MVE_v2s64 : MVEVectorVTInfo<v2i64, ?, v2i1, ?, 0b11, "s", 0b0>;
301 def MVE_v16u8 : MVEVectorVTInfo<v16i8, v8i16, v16i1, v8i1, 0b00, "u", 0b1>;
302 def MVE_v8u16 : MVEVectorVTInfo<v8i16, v4i32, v8i1, v4i1, 0b01, "u", 0b1>;
303 def MVE_v4u32 : MVEVectorVTInfo<v4i32, v2i64, v4i1, v2i1, 0b10, "u", 0b1>;
304 def MVE_v2u64 : MVEVectorVTInfo<v2i64, ?, v2i1, ?, 0b11, "u", 0b1>;
307 def MVE_v8f16 : MVEVectorVTInfo<v8f16, v4f32, v8i1, v4i1, 0b01, "f", ?>;
308 def MVE_v4f32 : MVEVectorVTInfo<v4f32, v2f64, v4i1, v2i1, 0b10, "f", ?>;
309 def MVE_v2f64 : MVEVectorVTInfo<v2f64, ?, v2i1, ?, 0b11, "f", ?>;
311 // Polynomial vector types.
312 def MVE_v16p8 : MVEVectorVTInfo<v16i8, v8i16, v16i1, v8i1, 0b11, "p", 0b0>;
313 def MVE_v8p16 : MVEVectorVTInfo<v8i16, v4i32, v8i1, v4i1, 0b11, "p", 0b1>;
315 multiclass MVE_TwoOpPattern<MVEVectorVTInfo VTI, SDPatternOperator Op, Intrinsic PredInt,
316 dag PredOperands, Instruction Inst,
317 SDPatternOperator IdentityVec = null_frag> {
319 def : Pat<(VTI.Vec (Op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn))),
320 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
322 // Predicated with select
323 if !ne(VTI.Size, 0b11) then {
324 def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$mask),
325 (VTI.Vec (Op (VTI.Vec MQPR:$Qm),
326 (VTI.Vec MQPR:$Qn))),
327 (VTI.Vec MQPR:$inactive))),
328 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
329 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
330 (VTI.Vec MQPR:$inactive)))>;
332 // Optionally with the select folded through the op
333 def : Pat<(VTI.Vec (Op (VTI.Vec MQPR:$Qm),
334 (VTI.Vec (vselect (VTI.Pred VCCR:$mask),
336 (VTI.Vec IdentityVec))))),
337 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
338 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
339 (VTI.Vec MQPR:$Qm)))>;
342 // Predicated with intrinsic
343 def : Pat<(VTI.Vec !con((PredInt (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)),
345 (? (VTI.Pred VCCR:$mask), (VTI.Vec MQPR:$inactive)))),
346 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
347 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
348 (VTI.Vec MQPR:$inactive)))>;
351 multiclass MVE_TwoOpPatternDup<MVEVectorVTInfo VTI, SDPatternOperator Op, Intrinsic PredInt,
352 dag PredOperands, Instruction Inst,
353 SDPatternOperator IdentityVec = null_frag> {
355 def : Pat<(VTI.Vec (Op (VTI.Vec MQPR:$Qm), (VTI.Vec (ARMvdup rGPR:$Rn)))),
356 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), rGPR:$Rn))>;
358 // Predicated with select
359 if !ne(VTI.Size, 0b11) then {
360 def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$mask),
361 (VTI.Vec (Op (VTI.Vec MQPR:$Qm),
362 (VTI.Vec (ARMvdup rGPR:$Rn)))),
363 (VTI.Vec MQPR:$inactive))),
364 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), rGPR:$Rn,
365 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
366 (VTI.Vec MQPR:$inactive)))>;
368 // Optionally with the select folded through the op
369 def : Pat<(VTI.Vec (Op (VTI.Vec MQPR:$Qm),
370 (VTI.Vec (vselect (VTI.Pred VCCR:$mask),
372 (VTI.Vec IdentityVec))))),
373 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), rGPR:$Rn,
374 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
375 (VTI.Vec MQPR:$Qm)))>;
378 // Predicated with intrinsic
379 def : Pat<(VTI.Vec !con((PredInt (VTI.Vec MQPR:$Qm), (VTI.Vec (ARMvdup rGPR:$Rn))),
381 (? (VTI.Pred VCCR:$mask), (VTI.Vec MQPR:$inactive)))),
382 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), rGPR:$Rn,
383 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
384 (VTI.Vec MQPR:$inactive)))>;
387 // --------- Start of base classes for the instructions themselves
389 class MVE_MI<dag oops, dag iops, InstrItinClass itin, string asm,
390 string ops, string cstr, bits<2> vecsize, list<dag> pattern>
391 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, !strconcat(asm, "\t", ops), cstr,
393 Requires<[HasMVEInt]> {
395 let DecoderNamespace = "MVE";
396 let VecSize = vecsize;
399 // MVE_p is used for most predicated instructions, to add the cluster
400 // of input operands that provides the VPT suffix (none, T or E) and
401 // the input predicate register.
402 class MVE_p<dag oops, dag iops, InstrItinClass itin, string iname,
403 string suffix, string ops, vpred_ops vpred, string cstr,
404 bits<2> vecsize, list<dag> pattern=[]>
405 : MVE_MI<oops, !con(iops, (ins vpred:$vp)), itin,
406 // If the instruction has a suffix, like vadd.f32, then the
407 // VPT predication suffix goes before the dot, so the full
408 // name has to be "vadd${vp}.f32".
409 !strconcat(iname, "${vp}",
410 !if(!eq(suffix, ""), "", !strconcat(".", suffix))),
411 ops, !strconcat(cstr, vpred.vpred_constraint), vecsize, pattern> {
412 let Inst{31-29} = 0b111;
413 let Inst{27-26} = 0b11;
416 class MVE_f<dag oops, dag iops, InstrItinClass itin, string iname,
417 string suffix, string ops, vpred_ops vpred, string cstr,
418 bits<2> vecsize, list<dag> pattern=[]>
419 : MVE_p<oops, iops, itin, iname, suffix, ops, vpred, cstr, vecsize, pattern> {
420 let Predicates = [HasMVEFloat];
423 class MVE_MI_with_pred<dag oops, dag iops, InstrItinClass itin, string asm,
424 string ops, string cstr, list<dag> pattern>
425 : Thumb2I<oops, iops, AddrModeNone, 4, itin, asm, !strconcat("\t", ops), cstr,
427 Requires<[HasV8_1MMainline, HasMVEInt]> {
429 let DecoderNamespace = "MVE";
432 class MVE_VMOV_lane_base<dag oops, dag iops, InstrItinClass itin, string asm,
433 string suffix, string ops, string cstr,
435 : Thumb2I<oops, iops, AddrModeNone, 4, itin, asm,
436 !if(!eq(suffix, ""), "", "." # suffix) # "\t" # ops,
438 Requires<[HasV8_1MMainline, HasMVEInt]> {
440 let DecoderNamespace = "MVE";
443 class MVE_ScalarShift<string iname, dag oops, dag iops, string asm, string cstr,
444 list<dag> pattern=[]>
445 : MVE_MI_with_pred<oops, iops, NoItinerary, iname, asm, cstr, pattern> {
446 let Inst{31-20} = 0b111010100101;
448 let validForTailPredication=1;
451 class MVE_ScalarShiftSingleReg<string iname, dag iops, string asm, string cstr,
452 list<dag> pattern=[]>
453 : MVE_ScalarShift<iname, (outs rGPR:$RdaDest), iops, asm, cstr, pattern> {
456 let Inst{19-16} = RdaDest{3-0};
459 class MVE_ScalarShiftSRegImm<string iname, bits<2> op5_4>
460 : MVE_ScalarShiftSingleReg<iname, (ins rGPR:$RdaSrc, long_shift:$imm),
461 "$RdaSrc, $imm", "$RdaDest = $RdaSrc",
463 (i32 (!cast<Intrinsic>("int_arm_mve_" # iname)
464 (i32 rGPR:$RdaSrc), (i32 imm:$imm))))]> {
468 let Inst{14-12} = imm{4-2};
469 let Inst{11-8} = 0b1111;
470 let Inst{7-6} = imm{1-0};
471 let Inst{5-4} = op5_4{1-0};
472 let Inst{3-0} = 0b1111;
475 def MVE_SQSHL : MVE_ScalarShiftSRegImm<"sqshl", 0b11>;
476 def MVE_SRSHR : MVE_ScalarShiftSRegImm<"srshr", 0b10>;
477 def MVE_UQSHL : MVE_ScalarShiftSRegImm<"uqshl", 0b00>;
478 def MVE_URSHR : MVE_ScalarShiftSRegImm<"urshr", 0b01>;
480 class MVE_ScalarShiftSRegReg<string iname, bits<2> op5_4>
481 : MVE_ScalarShiftSingleReg<iname, (ins rGPR:$RdaSrc, rGPR:$Rm),
482 "$RdaSrc, $Rm", "@earlyclobber $RdaDest,$RdaDest = $RdaSrc",
484 (i32 (!cast<Intrinsic>("int_arm_mve_" # iname)
485 (i32 rGPR:$RdaSrc), (i32 rGPR:$Rm))))]> {
488 let Inst{15-12} = Rm{3-0};
489 let Inst{11-8} = 0b1111;
490 let Inst{7-6} = 0b00;
491 let Inst{5-4} = op5_4{1-0};
492 let Inst{3-0} = 0b1101;
494 let Unpredictable{8-6} = 0b111;
497 def MVE_SQRSHR : MVE_ScalarShiftSRegReg<"sqrshr", 0b10>;
498 def MVE_UQRSHL : MVE_ScalarShiftSRegReg<"uqrshl", 0b00>;
500 class MVE_ScalarShiftDoubleReg<string iname, dag iops, string asm,
501 string cstr, list<dag> pattern=[]>
502 : MVE_ScalarShift<iname, (outs tGPREven:$RdaLo, tGPROdd:$RdaHi),
503 iops, asm, cstr, pattern> {
507 let Inst{19-17} = RdaLo{3-1};
508 let Inst{11-9} = RdaHi{3-1};
510 let hasSideEffects = 0;
513 class MVE_ScalarShiftDRegImm<string iname, bits<2> op5_4, bit op16,
514 list<dag> pattern=[]>
515 : MVE_ScalarShiftDoubleReg<
516 iname, (ins tGPREven:$RdaLo_src, tGPROdd:$RdaHi_src, long_shift:$imm),
517 "$RdaLo, $RdaHi, $imm", "$RdaLo = $RdaLo_src,$RdaHi = $RdaHi_src",
523 let Inst{14-12} = imm{4-2};
524 let Inst{7-6} = imm{1-0};
525 let Inst{5-4} = op5_4{1-0};
526 let Inst{3-0} = 0b1111;
529 class MVE_ScalarShiftDRegRegBase<string iname, dag iops, string asm,
530 bit op5, bit op16, list<dag> pattern=[]>
531 : MVE_ScalarShiftDoubleReg<
532 iname, iops, asm, "@earlyclobber $RdaHi,@earlyclobber $RdaLo,"
533 "$RdaLo = $RdaLo_src,$RdaHi = $RdaHi_src",
538 let Inst{15-12} = Rm{3-0};
542 let Inst{3-0} = 0b1101;
544 // Custom decoder method because of the following overlapping encodings:
547 // SQRSHRL and SQRSHR
548 // UQRSHLL and UQRSHL
549 let DecoderMethod = "DecodeMVEOverlappingLongShift";
552 class MVE_ScalarShiftDRegReg<string iname, bit op5, list<dag> pattern=[]>
553 : MVE_ScalarShiftDRegRegBase<
554 iname, (ins tGPREven:$RdaLo_src, tGPROdd:$RdaHi_src, rGPR:$Rm),
555 "$RdaLo, $RdaHi, $Rm", op5, 0b0, pattern> {
560 class MVE_ScalarShiftDRegRegWithSat<string iname, bit op5, list<dag> pattern=[]>
561 : MVE_ScalarShiftDRegRegBase<
562 iname, (ins tGPREven:$RdaLo_src, tGPROdd:$RdaHi_src, rGPR:$Rm, saturateop:$sat),
563 "$RdaLo, $RdaHi, $sat, $Rm", op5, 0b1, pattern> {
569 def MVE_ASRLr : MVE_ScalarShiftDRegReg<"asrl", 0b1, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi,
570 (ARMasrl tGPREven:$RdaLo_src,
571 tGPROdd:$RdaHi_src, rGPR:$Rm))]>;
572 def MVE_ASRLi : MVE_ScalarShiftDRegImm<"asrl", 0b10, ?, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi,
573 (ARMasrl tGPREven:$RdaLo_src,
574 tGPROdd:$RdaHi_src, (i32 long_shift:$imm)))]>;
575 def MVE_LSLLr : MVE_ScalarShiftDRegReg<"lsll", 0b0, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi,
576 (ARMlsll tGPREven:$RdaLo_src,
577 tGPROdd:$RdaHi_src, rGPR:$Rm))]>;
578 def MVE_LSLLi : MVE_ScalarShiftDRegImm<"lsll", 0b00, ?, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi,
579 (ARMlsll tGPREven:$RdaLo_src,
580 tGPROdd:$RdaHi_src, (i32 long_shift:$imm)))]>;
581 def MVE_LSRL : MVE_ScalarShiftDRegImm<"lsrl", 0b01, ?, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi,
582 (ARMlsrl tGPREven:$RdaLo_src,
583 tGPROdd:$RdaHi_src, (i32 long_shift:$imm)))]>;
585 def MVE_SQRSHRL : MVE_ScalarShiftDRegRegWithSat<"sqrshrl", 0b1>;
586 def MVE_SQSHLL : MVE_ScalarShiftDRegImm<"sqshll", 0b11, 0b1>;
587 def MVE_SRSHRL : MVE_ScalarShiftDRegImm<"srshrl", 0b10, 0b1>;
589 def MVE_UQRSHLL : MVE_ScalarShiftDRegRegWithSat<"uqrshll", 0b0>;
590 def MVE_UQSHLL : MVE_ScalarShiftDRegImm<"uqshll", 0b00, 0b1>;
591 def MVE_URSHRL : MVE_ScalarShiftDRegImm<"urshrl", 0b01, 0b1>;
593 // start of mve_rDest instructions
595 class MVE_rDest<dag oops, dag iops, InstrItinClass itin,
596 string iname, string suffix,
597 string ops, string cstr, bits<2> vecsize, list<dag> pattern=[]>
598 // Always use vpred_n and not vpred_r: with the output register being
599 // a GPR and not a vector register, there can't be any question of
600 // what to put in its inactive lanes.
601 : MVE_p<oops, iops, itin, iname, suffix, ops, vpred_n, cstr, vecsize, pattern> {
603 let Inst{25-23} = 0b101;
604 let Inst{11-9} = 0b111;
608 class MVE_VABAV<string suffix, bit U, bits<2> size>
609 : MVE_rDest<(outs rGPR:$Rda), (ins rGPR:$Rda_src, MQPR:$Qn, MQPR:$Qm),
610 NoItinerary, "vabav", suffix, "$Rda, $Qn, $Qm", "$Rda = $Rda_src",
618 let Inst{21-20} = size{1-0};
619 let Inst{19-17} = Qn{2-0};
621 let Inst{15-12} = Rda{3-0};
626 let Inst{3-1} = Qm{2-0};
628 let horizontalReduction = 1;
631 multiclass MVE_VABAV_m<MVEVectorVTInfo VTI> {
632 def "" : MVE_VABAV<VTI.Suffix, VTI.Unsigned, VTI.Size>;
633 defvar Inst = !cast<Instruction>(NAME);
635 let Predicates = [HasMVEInt] in {
636 def : Pat<(i32 (int_arm_mve_vabav
639 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))),
640 (i32 (Inst (i32 rGPR:$Rda_src),
641 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm)))>;
643 def : Pat<(i32 (int_arm_mve_vabav_predicated
646 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
647 (VTI.Pred VCCR:$mask))),
648 (i32 (Inst (i32 rGPR:$Rda_src),
649 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
650 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>;
654 defm MVE_VABAVs8 : MVE_VABAV_m<MVE_v16s8>;
655 defm MVE_VABAVs16 : MVE_VABAV_m<MVE_v8s16>;
656 defm MVE_VABAVs32 : MVE_VABAV_m<MVE_v4s32>;
657 defm MVE_VABAVu8 : MVE_VABAV_m<MVE_v16u8>;
658 defm MVE_VABAVu16 : MVE_VABAV_m<MVE_v8u16>;
659 defm MVE_VABAVu32 : MVE_VABAV_m<MVE_v4u32>;
661 class MVE_VADDV<string iname, string suffix, dag iops, string cstr,
662 bit A, bit U, bits<2> size, list<dag> pattern=[]>
663 : MVE_rDest<(outs tGPREven:$Rda), iops, NoItinerary,
664 iname, suffix, "$Rda, $Qm", cstr, size, pattern> {
669 let Inst{22-20} = 0b111;
670 let Inst{19-18} = size{1-0};
671 let Inst{17-16} = 0b01;
672 let Inst{15-13} = Rda{3-1};
674 let Inst{8-6} = 0b100;
676 let Inst{3-1} = Qm{2-0};
678 let horizontalReduction = 1;
679 let validForTailPredication = 1;
682 def SDTVecReduceP : SDTypeProfile<1, 2, [ // VADDLVp
683 SDTCisInt<0>, SDTCisVec<1>, SDTCisVec<2>
685 def ARMVADDVs : SDNode<"ARMISD::VADDVs", SDTVecReduce>;
686 def ARMVADDVu : SDNode<"ARMISD::VADDVu", SDTVecReduce>;
687 def ARMVADDVps : SDNode<"ARMISD::VADDVps", SDTVecReduceP>;
688 def ARMVADDVpu : SDNode<"ARMISD::VADDVpu", SDTVecReduceP>;
690 multiclass MVE_VADDV_A<MVEVectorVTInfo VTI> {
691 def acc : MVE_VADDV<"vaddva", VTI.Suffix,
692 (ins tGPREven:$Rda_src, MQPR:$Qm), "$Rda = $Rda_src",
693 0b1, VTI.Unsigned, VTI.Size>;
694 def no_acc : MVE_VADDV<"vaddv", VTI.Suffix,
696 0b0, VTI.Unsigned, VTI.Size>;
698 defvar InstA = !cast<Instruction>(NAME # "acc");
699 defvar InstN = !cast<Instruction>(NAME # "no_acc");
701 let Predicates = [HasMVEInt] in {
702 if VTI.Unsigned then {
703 def : Pat<(i32 (vecreduce_add (VTI.Vec MQPR:$vec))),
705 def : Pat<(i32 (vecreduce_add (VTI.Vec (vselect (VTI.Pred VCCR:$pred),
707 (VTI.Vec ARMimmAllZerosV))))),
708 (i32 (InstN $vec, ARMVCCThen, $pred, zero_reg))>;
709 def : Pat<(i32 (ARMVADDVu (VTI.Vec MQPR:$vec))),
711 def : Pat<(i32 (ARMVADDVpu (VTI.Vec MQPR:$vec), (VTI.Pred VCCR:$pred))),
712 (i32 (InstN $vec, ARMVCCThen, $pred, zero_reg))>;
713 def : Pat<(i32 (add (i32 (vecreduce_add (VTI.Vec MQPR:$vec))),
714 (i32 tGPREven:$acc))),
715 (i32 (InstA $acc, $vec))>;
716 def : Pat<(i32 (add (i32 (vecreduce_add (VTI.Vec (vselect (VTI.Pred VCCR:$pred),
718 (VTI.Vec ARMimmAllZerosV))))),
719 (i32 tGPREven:$acc))),
720 (i32 (InstA $acc, $vec, ARMVCCThen, $pred, zero_reg))>;
721 def : Pat<(i32 (add (i32 (ARMVADDVu (VTI.Vec MQPR:$vec))),
722 (i32 tGPREven:$acc))),
723 (i32 (InstA $acc, $vec))>;
724 def : Pat<(i32 (add (i32 (ARMVADDVpu (VTI.Vec MQPR:$vec), (VTI.Pred VCCR:$pred))),
725 (i32 tGPREven:$acc))),
726 (i32 (InstA $acc, $vec, ARMVCCThen, $pred, zero_reg))>;
728 def : Pat<(i32 (ARMVADDVs (VTI.Vec MQPR:$vec))),
730 def : Pat<(i32 (add (i32 (ARMVADDVs (VTI.Vec MQPR:$vec))),
731 (i32 tGPREven:$acc))),
732 (i32 (InstA $acc, $vec))>;
733 def : Pat<(i32 (ARMVADDVps (VTI.Vec MQPR:$vec), (VTI.Pred VCCR:$pred))),
734 (i32 (InstN $vec, ARMVCCThen, $pred, zero_reg))>;
735 def : Pat<(i32 (add (i32 (ARMVADDVps (VTI.Vec MQPR:$vec), (VTI.Pred VCCR:$pred))),
736 (i32 tGPREven:$acc))),
737 (i32 (InstA $acc, $vec, ARMVCCThen, $pred, zero_reg))>;
740 def : Pat<(i32 (int_arm_mve_addv_predicated (VTI.Vec MQPR:$vec),
742 (VTI.Pred VCCR:$pred))),
743 (i32 (InstN $vec, ARMVCCThen, $pred, zero_reg))>;
744 def : Pat<(i32 (add (int_arm_mve_addv_predicated (VTI.Vec MQPR:$vec),
746 (VTI.Pred VCCR:$pred)),
747 (i32 tGPREven:$acc))),
748 (i32 (InstA $acc, $vec, ARMVCCThen, $pred, zero_reg))>;
752 defm MVE_VADDVs8 : MVE_VADDV_A<MVE_v16s8>;
753 defm MVE_VADDVs16 : MVE_VADDV_A<MVE_v8s16>;
754 defm MVE_VADDVs32 : MVE_VADDV_A<MVE_v4s32>;
755 defm MVE_VADDVu8 : MVE_VADDV_A<MVE_v16u8>;
756 defm MVE_VADDVu16 : MVE_VADDV_A<MVE_v8u16>;
757 defm MVE_VADDVu32 : MVE_VADDV_A<MVE_v4u32>;
759 class MVE_VADDLV<string iname, string suffix, dag iops, string cstr,
760 bit A, bit U, list<dag> pattern=[]>
761 : MVE_rDest<(outs tGPREven:$RdaLo, tGPROdd:$RdaHi), iops, NoItinerary, iname,
762 suffix, "$RdaLo, $RdaHi, $Qm", cstr, 0b10, pattern> {
768 let Inst{22-20} = RdaHi{3-1};
769 let Inst{19-18} = 0b10;
770 let Inst{17-16} = 0b01;
771 let Inst{15-13} = RdaLo{3-1};
773 let Inst{8-6} = 0b100;
775 let Inst{3-1} = Qm{2-0};
777 let horizontalReduction = 1;
780 def SDTVecReduceL : SDTypeProfile<2, 1, [ // VADDLV
781 SDTCisInt<0>, SDTCisInt<1>, SDTCisVec<2>
783 def SDTVecReduceLA : SDTypeProfile<2, 3, [ // VADDLVA
784 SDTCisInt<0>, SDTCisInt<1>, SDTCisInt<2>, SDTCisInt<3>,
787 def SDTVecReduceLP : SDTypeProfile<2, 2, [ // VADDLVp
788 SDTCisInt<0>, SDTCisInt<1>, SDTCisVec<2>, SDTCisVec<2>
790 def SDTVecReduceLPA : SDTypeProfile<2, 4, [ // VADDLVAp
791 SDTCisInt<0>, SDTCisInt<1>, SDTCisInt<2>, SDTCisInt<3>,
792 SDTCisVec<4>, SDTCisVec<5>
795 multiclass MVE_VADDLV_A<MVEVectorVTInfo VTI> {
796 def acc : MVE_VADDLV<"vaddlva", VTI.Suffix,
797 (ins tGPREven:$RdaLo_src, tGPROdd:$RdaHi_src, MQPR:$Qm),
798 "$RdaLo = $RdaLo_src,$RdaHi = $RdaHi_src",
800 def no_acc : MVE_VADDLV<"vaddlv", VTI.Suffix,
804 defvar InstA = !cast<Instruction>(NAME # "acc");
805 defvar InstN = !cast<Instruction>(NAME # "no_acc");
807 defvar letter = VTI.SuffixLetter;
808 defvar ARMVADDLV = SDNode<"ARMISD::VADDLV" # letter, SDTVecReduceL>;
809 defvar ARMVADDLVA = SDNode<"ARMISD::VADDLVA" # letter, SDTVecReduceLA>;
810 defvar ARMVADDLVp = SDNode<"ARMISD::VADDLVp" # letter, SDTVecReduceLP>;
811 defvar ARMVADDLVAp = SDNode<"ARMISD::VADDLVAp" # letter, SDTVecReduceLPA>;
813 let Predicates = [HasMVEInt] in {
814 def : Pat<(ARMVADDLV (v4i32 MQPR:$vec)),
815 (InstN (v4i32 MQPR:$vec))>;
816 def : Pat<(ARMVADDLVA tGPREven:$acclo, tGPROdd:$acchi, (v4i32 MQPR:$vec)),
817 (InstA tGPREven:$acclo, tGPROdd:$acchi, (v4i32 MQPR:$vec))>;
818 def : Pat<(ARMVADDLVp (v4i32 MQPR:$vec), (VTI.Pred VCCR:$pred)),
819 (InstN (v4i32 MQPR:$vec), ARMVCCThen, (VTI.Pred VCCR:$pred), zero_reg)>;
820 def : Pat<(ARMVADDLVAp tGPREven:$acclo, tGPROdd:$acchi, (v4i32 MQPR:$vec),
821 (VTI.Pred VCCR:$pred)),
822 (InstA tGPREven:$acclo, tGPROdd:$acchi, (v4i32 MQPR:$vec),
823 ARMVCCThen, (VTI.Pred VCCR:$pred), zero_reg)>;
827 defm MVE_VADDLVs32 : MVE_VADDLV_A<MVE_v4s32>;
828 defm MVE_VADDLVu32 : MVE_VADDLV_A<MVE_v4u32>;
830 class MVE_VMINMAXNMV<string iname, string suffix, bit sz,
831 bit bit_17, bit bit_7, list<dag> pattern=[]>
832 : MVE_rDest<(outs rGPR:$RdaDest), (ins rGPR:$RdaSrc, MQPR:$Qm),
833 NoItinerary, iname, suffix, "$RdaSrc, $Qm",
834 "$RdaDest = $RdaSrc", !if(sz, 0b01, 0b10), pattern> {
839 let Inst{22-20} = 0b110;
840 let Inst{19-18} = 0b11;
841 let Inst{17} = bit_17;
843 let Inst{15-12} = RdaDest{3-0};
846 let Inst{6-5} = 0b00;
847 let Inst{3-1} = Qm{2-0};
849 let horizontalReduction = 1;
851 let Predicates = [HasMVEFloat];
852 let hasSideEffects = 0;
855 multiclass MVE_VMINMAXNMV_p<string iname, bit notAbs, bit isMin,
856 MVEVectorVTInfo VTI, string intrBaseName,
857 ValueType Scalar, RegisterClass ScalarReg> {
858 def "": MVE_VMINMAXNMV<iname, VTI.Suffix, VTI.Size{0}, notAbs, isMin>;
859 defvar Inst = !cast<Instruction>(NAME);
860 defvar unpred_intr = !cast<Intrinsic>(intrBaseName);
861 defvar pred_intr = !cast<Intrinsic>(intrBaseName#"_predicated");
863 let Predicates = [HasMVEFloat] in {
864 def : Pat<(Scalar (unpred_intr (Scalar ScalarReg:$prev),
865 (VTI.Vec MQPR:$vec))),
866 (COPY_TO_REGCLASS (Inst (COPY_TO_REGCLASS ScalarReg:$prev, rGPR),
867 (VTI.Vec MQPR:$vec)),
869 def : Pat<(Scalar (pred_intr (Scalar ScalarReg:$prev),
871 (VTI.Pred VCCR:$pred))),
872 (COPY_TO_REGCLASS (Inst (COPY_TO_REGCLASS ScalarReg:$prev, rGPR),
874 ARMVCCThen, (VTI.Pred VCCR:$pred), zero_reg),
879 multiclass MVE_VMINMAXNMV_fty<string iname, bit notAbs, bit isMin,
881 defm f32 : MVE_VMINMAXNMV_p<iname, notAbs, isMin, MVE_v4f32, intrBase,
883 defm f16 : MVE_VMINMAXNMV_p<iname, notAbs, isMin, MVE_v8f16, intrBase,
887 defm MVE_VMINNMV : MVE_VMINMAXNMV_fty<"vminnmv", 1, 1, "int_arm_mve_minnmv">;
888 defm MVE_VMAXNMV : MVE_VMINMAXNMV_fty<"vmaxnmv", 1, 0, "int_arm_mve_maxnmv">;
889 defm MVE_VMINNMAV: MVE_VMINMAXNMV_fty<"vminnmav", 0, 1, "int_arm_mve_minnmav">;
890 defm MVE_VMAXNMAV: MVE_VMINMAXNMV_fty<"vmaxnmav", 0, 0, "int_arm_mve_maxnmav">;
892 class MVE_VMINMAXV<string iname, string suffix, bit U, bits<2> size,
893 bit bit_17, bit bit_7, list<dag> pattern=[]>
894 : MVE_rDest<(outs rGPR:$RdaDest), (ins rGPR:$RdaSrc, MQPR:$Qm), NoItinerary,
895 iname, suffix, "$RdaSrc, $Qm", "$RdaDest = $RdaSrc", size, pattern> {
900 let Inst{22-20} = 0b110;
901 let Inst{19-18} = size{1-0};
902 let Inst{17} = bit_17;
904 let Inst{15-12} = RdaDest{3-0};
907 let Inst{6-5} = 0b00;
908 let Inst{3-1} = Qm{2-0};
910 let horizontalReduction = 1;
913 multiclass MVE_VMINMAXV_p<string iname, bit notAbs, bit isMin,
914 MVEVectorVTInfo VTI, string intrBaseName> {
915 def "": MVE_VMINMAXV<iname, VTI.Suffix, VTI.Unsigned, VTI.Size,
917 defvar Inst = !cast<Instruction>(NAME);
918 defvar unpred_intr = !cast<Intrinsic>(intrBaseName);
919 defvar pred_intr = !cast<Intrinsic>(intrBaseName#"_predicated");
920 defvar base_args = (? (i32 rGPR:$prev), (VTI.Vec MQPR:$vec));
921 defvar args = !if(notAbs, !con(base_args, (? (i32 VTI.Unsigned))),
924 let Predicates = [HasMVEInt] in {
925 def : Pat<(i32 !con(args, (unpred_intr))),
926 (i32 (Inst (i32 rGPR:$prev), (VTI.Vec MQPR:$vec)))>;
927 def : Pat<(i32 !con(args, (pred_intr (VTI.Pred VCCR:$pred)))),
928 (i32 (Inst (i32 rGPR:$prev), (VTI.Vec MQPR:$vec),
929 ARMVCCThen, (VTI.Pred VCCR:$pred), zero_reg))>;
933 multiclass MVE_VMINMAXV_ty<string iname, bit isMin, string intrBaseName> {
934 defm s8 : MVE_VMINMAXV_p<iname, 1, isMin, MVE_v16s8, intrBaseName>;
935 defm s16: MVE_VMINMAXV_p<iname, 1, isMin, MVE_v8s16, intrBaseName>;
936 defm s32: MVE_VMINMAXV_p<iname, 1, isMin, MVE_v4s32, intrBaseName>;
937 defm u8 : MVE_VMINMAXV_p<iname, 1, isMin, MVE_v16u8, intrBaseName>;
938 defm u16: MVE_VMINMAXV_p<iname, 1, isMin, MVE_v8u16, intrBaseName>;
939 defm u32: MVE_VMINMAXV_p<iname, 1, isMin, MVE_v4u32, intrBaseName>;
942 def SDTVecReduceR : SDTypeProfile<1, 2, [ // Reduction of an integer and vector into an integer
943 SDTCisInt<0>, SDTCisInt<1>, SDTCisVec<2>
945 def ARMVMINVu : SDNode<"ARMISD::VMINVu", SDTVecReduceR>;
946 def ARMVMINVs : SDNode<"ARMISD::VMINVs", SDTVecReduceR>;
947 def ARMVMAXVu : SDNode<"ARMISD::VMAXVu", SDTVecReduceR>;
948 def ARMVMAXVs : SDNode<"ARMISD::VMAXVs", SDTVecReduceR>;
950 defm MVE_VMINV : MVE_VMINMAXV_ty<"vminv", 1, "int_arm_mve_minv">;
951 defm MVE_VMAXV : MVE_VMINMAXV_ty<"vmaxv", 0, "int_arm_mve_maxv">;
953 let Predicates = [HasMVEInt] in {
954 def : Pat<(i32 (vecreduce_smax (v16i8 MQPR:$src))),
955 (i32 (MVE_VMAXVs8 (t2MVNi (i32 127)), $src))>;
956 def : Pat<(i32 (vecreduce_smax (v8i16 MQPR:$src))),
957 (i32 (MVE_VMAXVs16 (t2MOVi32imm (i32 -32768)), $src))>;
958 def : Pat<(i32 (vecreduce_smax (v4i32 MQPR:$src))),
959 (i32 (MVE_VMAXVs32 (t2MOVi (i32 -2147483648)), $src))>;
960 def : Pat<(i32 (vecreduce_umax (v16i8 MQPR:$src))),
961 (i32 (MVE_VMAXVu8 (t2MOVi (i32 0)), $src))>;
962 def : Pat<(i32 (vecreduce_umax (v8i16 MQPR:$src))),
963 (i32 (MVE_VMAXVu16 (t2MOVi (i32 0)), $src))>;
964 def : Pat<(i32 (vecreduce_umax (v4i32 MQPR:$src))),
965 (i32 (MVE_VMAXVu32 (t2MOVi (i32 0)), $src))>;
967 def : Pat<(i32 (vecreduce_smin (v16i8 MQPR:$src))),
968 (i32 (MVE_VMINVs8 (t2MOVi (i32 127)), $src))>;
969 def : Pat<(i32 (vecreduce_smin (v8i16 MQPR:$src))),
970 (i32 (MVE_VMINVs16 (t2MOVi16 (i32 32767)), $src))>;
971 def : Pat<(i32 (vecreduce_smin (v4i32 MQPR:$src))),
972 (i32 (MVE_VMINVs32 (t2MVNi (i32 -2147483648)), $src))>;
973 def : Pat<(i32 (vecreduce_umin (v16i8 MQPR:$src))),
974 (i32 (MVE_VMINVu8 (t2MOVi (i32 255)), $src))>;
975 def : Pat<(i32 (vecreduce_umin (v8i16 MQPR:$src))),
976 (i32 (MVE_VMINVu16 (t2MOVi16 (i32 65535)), $src))>;
977 def : Pat<(i32 (vecreduce_umin (v4i32 MQPR:$src))),
978 (i32 (MVE_VMINVu32 (t2MOVi (i32 4294967295)), $src))>;
980 def : Pat<(i32 (ARMVMINVu (i32 rGPR:$x), (v16i8 MQPR:$src))),
981 (i32 (MVE_VMINVu8 $x, $src))>;
982 def : Pat<(i32 (ARMVMINVu (i32 rGPR:$x), (v8i16 MQPR:$src))),
983 (i32 (MVE_VMINVu16 $x, $src))>;
984 def : Pat<(i32 (ARMVMINVu (i32 rGPR:$x), (v4i32 MQPR:$src))),
985 (i32 (MVE_VMINVu32 $x, $src))>;
986 def : Pat<(i32 (ARMVMINVs (i32 rGPR:$x), (v16i8 MQPR:$src))),
987 (i32 (MVE_VMINVs8 $x, $src))>;
988 def : Pat<(i32 (ARMVMINVs (i32 rGPR:$x), (v8i16 MQPR:$src))),
989 (i32 (MVE_VMINVs16 $x, $src))>;
990 def : Pat<(i32 (ARMVMINVs (i32 rGPR:$x), (v4i32 MQPR:$src))),
991 (i32 (MVE_VMINVs32 $x, $src))>;
993 def : Pat<(i32 (ARMVMAXVu (i32 rGPR:$x), (v16i8 MQPR:$src))),
994 (i32 (MVE_VMAXVu8 $x, $src))>;
995 def : Pat<(i32 (ARMVMAXVu (i32 rGPR:$x), (v8i16 MQPR:$src))),
996 (i32 (MVE_VMAXVu16 $x, $src))>;
997 def : Pat<(i32 (ARMVMAXVu (i32 rGPR:$x), (v4i32 MQPR:$src))),
998 (i32 (MVE_VMAXVu32 $x, $src))>;
999 def : Pat<(i32 (ARMVMAXVs (i32 rGPR:$x), (v16i8 MQPR:$src))),
1000 (i32 (MVE_VMAXVs8 $x, $src))>;
1001 def : Pat<(i32 (ARMVMAXVs (i32 rGPR:$x), (v8i16 MQPR:$src))),
1002 (i32 (MVE_VMAXVs16 $x, $src))>;
1003 def : Pat<(i32 (ARMVMAXVs (i32 rGPR:$x), (v4i32 MQPR:$src))),
1004 (i32 (MVE_VMAXVs32 $x, $src))>;
1008 multiclass MVE_VMINMAXAV_ty<string iname, bit isMin, string intrBaseName> {
1009 defm s8 : MVE_VMINMAXV_p<iname, 0, isMin, MVE_v16s8, intrBaseName>;
1010 defm s16: MVE_VMINMAXV_p<iname, 0, isMin, MVE_v8s16, intrBaseName>;
1011 defm s32: MVE_VMINMAXV_p<iname, 0, isMin, MVE_v4s32, intrBaseName>;
1014 defm MVE_VMINAV : MVE_VMINMAXAV_ty<"vminav", 1, "int_arm_mve_minav">;
1015 defm MVE_VMAXAV : MVE_VMINMAXAV_ty<"vmaxav", 0, "int_arm_mve_maxav">;
1017 class MVE_VMLAMLSDAV<string iname, string suffix, dag iops, string cstr,
1018 bit sz, bit bit_28, bit A, bit X, bit bit_8, bit bit_0,
1020 : MVE_rDest<(outs tGPREven:$RdaDest), iops, NoItinerary, iname, suffix,
1021 "$RdaDest, $Qn, $Qm", cstr, vecsize, []> {
1026 let Inst{28} = bit_28;
1027 let Inst{22-20} = 0b111;
1028 let Inst{19-17} = Qn{2-0};
1030 let Inst{15-13} = RdaDest{3-1};
1032 let Inst{8} = bit_8;
1033 let Inst{7-6} = 0b00;
1035 let Inst{3-1} = Qm{2-0};
1036 let Inst{0} = bit_0;
1037 let horizontalReduction = 1;
1038 // Allow tail predication for non-exchanging versions. As this is also a
1039 // horizontalReduction, ARMLowOverheadLoops will also have to check that
1040 // the vector operands contain zeros in their false lanes for the instruction
1041 // to be properly valid.
1042 let validForTailPredication = !eq(X, 0);
1045 multiclass MVE_VMLAMLSDAV_A<string iname, string x, MVEVectorVTInfo VTI,
1046 bit sz, bit bit_28, bit X, bit bit_8, bit bit_0> {
1047 def ""#x#VTI.Suffix : MVE_VMLAMLSDAV<iname # x, VTI.Suffix,
1048 (ins MQPR:$Qn, MQPR:$Qm), "",
1049 sz, bit_28, 0b0, X, bit_8, bit_0, VTI.Size>;
1050 def "a"#x#VTI.Suffix : MVE_VMLAMLSDAV<iname # "a" # x, VTI.Suffix,
1051 (ins tGPREven:$RdaSrc, MQPR:$Qn, MQPR:$Qm),
1052 "$RdaDest = $RdaSrc",
1053 sz, bit_28, 0b1, X, bit_8, bit_0, VTI.Size>;
1054 let Predicates = [HasMVEInt] in {
1055 def : Pat<(i32 (int_arm_mve_vmldava
1057 (i32 bit_0) /* subtract */,
1058 (i32 X) /* exchange */,
1059 (i32 0) /* accumulator */,
1060 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))),
1061 (i32 (!cast<Instruction>(NAME # x # VTI.Suffix)
1062 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm)))>;
1064 def : Pat<(i32 (int_arm_mve_vmldava_predicated
1066 (i32 bit_0) /* subtract */,
1067 (i32 X) /* exchange */,
1068 (i32 0) /* accumulator */,
1069 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
1070 (VTI.Pred VCCR:$mask))),
1071 (i32 (!cast<Instruction>(NAME # x # VTI.Suffix)
1072 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
1073 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>;
1075 def : Pat<(i32 (int_arm_mve_vmldava
1077 (i32 bit_0) /* subtract */,
1078 (i32 X) /* exchange */,
1079 (i32 tGPREven:$RdaSrc),
1080 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))),
1081 (i32 (!cast<Instruction>(NAME # "a" # x # VTI.Suffix)
1082 (i32 tGPREven:$RdaSrc),
1083 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm)))>;
1085 def : Pat<(i32 (int_arm_mve_vmldava_predicated
1087 (i32 bit_0) /* subtract */,
1088 (i32 X) /* exchange */,
1089 (i32 tGPREven:$RdaSrc),
1090 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
1091 (VTI.Pred VCCR:$mask))),
1092 (i32 (!cast<Instruction>(NAME # "a" # x # VTI.Suffix)
1093 (i32 tGPREven:$RdaSrc),
1094 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
1095 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>;
1099 multiclass MVE_VMLAMLSDAV_AX<string iname, MVEVectorVTInfo VTI, bit sz,
1100 bit bit_28, bit bit_8, bit bit_0> {
1101 defm "" : MVE_VMLAMLSDAV_A<iname, "", VTI, sz, bit_28,
1103 defm "" : MVE_VMLAMLSDAV_A<iname, "x", VTI, sz, bit_28,
1107 multiclass MVE_VMLADAV_multi<MVEVectorVTInfo SVTI, MVEVectorVTInfo UVTI,
1108 bit sz, bit bit_8> {
1109 defm "" : MVE_VMLAMLSDAV_AX<"vmladav", SVTI,
1110 sz, 0b0, bit_8, 0b0>;
1111 defm "" : MVE_VMLAMLSDAV_A<"vmladav", "", UVTI,
1112 sz, 0b1, 0b0, bit_8, 0b0>;
1115 multiclass MVE_VMLSDAV_multi<MVEVectorVTInfo VTI, bit sz, bit bit_28> {
1116 defm "" : MVE_VMLAMLSDAV_AX<"vmlsdav", VTI,
1117 sz, bit_28, 0b0, 0b1>;
1120 defm MVE_VMLADAV : MVE_VMLADAV_multi<MVE_v16s8, MVE_v16u8, 0b0, 0b1>;
1121 defm MVE_VMLADAV : MVE_VMLADAV_multi<MVE_v8s16, MVE_v8u16, 0b0, 0b0>;
1122 defm MVE_VMLADAV : MVE_VMLADAV_multi<MVE_v4s32, MVE_v4u32, 0b1, 0b0>;
1124 defm MVE_VMLSDAV : MVE_VMLSDAV_multi<MVE_v16s8, 0b0, 0b1>;
1125 defm MVE_VMLSDAV : MVE_VMLSDAV_multi<MVE_v8s16, 0b0, 0b0>;
1126 defm MVE_VMLSDAV : MVE_VMLSDAV_multi<MVE_v4s32, 0b1, 0b0>;
1128 def SDTVecReduce2 : SDTypeProfile<1, 2, [ // VMLAV
1129 SDTCisInt<0>, SDTCisVec<1>, SDTCisVec<2>
1131 def SDTVecReduce2L : SDTypeProfile<2, 2, [ // VMLALV
1132 SDTCisInt<0>, SDTCisInt<1>, SDTCisVec<2>, SDTCisVec<3>
1134 def SDTVecReduce2LA : SDTypeProfile<2, 4, [ // VMLALVA
1135 SDTCisInt<0>, SDTCisInt<1>, SDTCisInt<2>, SDTCisInt<3>,
1136 SDTCisVec<4>, SDTCisVec<5>
1138 def SDTVecReduce2P : SDTypeProfile<1, 3, [ // VMLAV
1139 SDTCisInt<0>, SDTCisVec<1>, SDTCisVec<2>, SDTCisVec<3>
1141 def SDTVecReduce2LP : SDTypeProfile<2, 3, [ // VMLALV
1142 SDTCisInt<0>, SDTCisInt<1>, SDTCisVec<2>, SDTCisVec<3>, SDTCisVec<4>
1144 def SDTVecReduce2LAP : SDTypeProfile<2, 5, [ // VMLALVA
1145 SDTCisInt<0>, SDTCisInt<1>, SDTCisInt<2>, SDTCisInt<3>,
1146 SDTCisVec<4>, SDTCisVec<5>, SDTCisVec<6>
1148 def ARMVMLAVs : SDNode<"ARMISD::VMLAVs", SDTVecReduce2>;
1149 def ARMVMLAVu : SDNode<"ARMISD::VMLAVu", SDTVecReduce2>;
1150 def ARMVMLALVs : SDNode<"ARMISD::VMLALVs", SDTVecReduce2L>;
1151 def ARMVMLALVu : SDNode<"ARMISD::VMLALVu", SDTVecReduce2L>;
1152 def ARMVMLALVAs : SDNode<"ARMISD::VMLALVAs", SDTVecReduce2LA>;
1153 def ARMVMLALVAu : SDNode<"ARMISD::VMLALVAu", SDTVecReduce2LA>;
1154 def ARMVMLAVps : SDNode<"ARMISD::VMLAVps", SDTVecReduce2P>;
1155 def ARMVMLAVpu : SDNode<"ARMISD::VMLAVpu", SDTVecReduce2P>;
1156 def ARMVMLALVps : SDNode<"ARMISD::VMLALVps", SDTVecReduce2LP>;
1157 def ARMVMLALVpu : SDNode<"ARMISD::VMLALVpu", SDTVecReduce2LP>;
1158 def ARMVMLALVAps : SDNode<"ARMISD::VMLALVAps", SDTVecReduce2LAP>;
1159 def ARMVMLALVApu : SDNode<"ARMISD::VMLALVApu", SDTVecReduce2LAP>;
1161 let Predicates = [HasMVEInt] in {
1162 def : Pat<(i32 (vecreduce_add (mul (v4i32 MQPR:$src1), (v4i32 MQPR:$src2)))),
1163 (i32 (MVE_VMLADAVu32 $src1, $src2))>;
1164 def : Pat<(i32 (vecreduce_add (mul (v8i16 MQPR:$src1), (v8i16 MQPR:$src2)))),
1165 (i32 (MVE_VMLADAVu16 $src1, $src2))>;
1166 def : Pat<(i32 (ARMVMLAVs (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
1167 (i32 (MVE_VMLADAVs16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1168 def : Pat<(i32 (ARMVMLAVu (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))),
1169 (i32 (MVE_VMLADAVu16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1170 def : Pat<(i32 (vecreduce_add (mul (v16i8 MQPR:$src1), (v16i8 MQPR:$src2)))),
1171 (i32 (MVE_VMLADAVu8 $src1, $src2))>;
1172 def : Pat<(i32 (ARMVMLAVs (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
1173 (i32 (MVE_VMLADAVs8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1174 def : Pat<(i32 (ARMVMLAVu (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))),
1175 (i32 (MVE_VMLADAVu8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1177 def : Pat<(i32 (add (i32 (vecreduce_add (mul (v4i32 MQPR:$src1), (v4i32 MQPR:$src2)))),
1178 (i32 tGPREven:$src3))),
1179 (i32 (MVE_VMLADAVau32 $src3, $src1, $src2))>;
1180 def : Pat<(i32 (add (i32 (vecreduce_add (mul (v8i16 MQPR:$src1), (v8i16 MQPR:$src2)))),
1181 (i32 tGPREven:$src3))),
1182 (i32 (MVE_VMLADAVau16 $src3, $src1, $src2))>;
1183 def : Pat<(i32 (add (ARMVMLAVs (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)), tGPREven:$Rd)),
1184 (i32 (MVE_VMLADAVas16 tGPREven:$Rd, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1185 def : Pat<(i32 (add (ARMVMLAVu (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)), tGPREven:$Rd)),
1186 (i32 (MVE_VMLADAVau16 tGPREven:$Rd, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>;
1187 def : Pat<(i32 (add (i32 (vecreduce_add (mul (v16i8 MQPR:$src1), (v16i8 MQPR:$src2)))),
1188 (i32 tGPREven:$src3))),
1189 (i32 (MVE_VMLADAVau8 $src3, $src1, $src2))>;
1190 def : Pat<(i32 (add (ARMVMLAVs (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)), tGPREven:$Rd)),
1191 (i32 (MVE_VMLADAVas8 tGPREven:$Rd, (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1192 def : Pat<(i32 (add (ARMVMLAVu (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)), tGPREven:$Rd)),
1193 (i32 (MVE_VMLADAVau8 tGPREven:$Rd, (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>;
1196 def : Pat<(i32 (vecreduce_add (vselect (v4i1 VCCR:$pred),
1197 (mul (v4i32 MQPR:$src1), (v4i32 MQPR:$src2)),
1198 (v4i32 ARMimmAllZerosV)))),
1199 (i32 (MVE_VMLADAVu32 $src1, $src2, ARMVCCThen, $pred, zero_reg))>;
1200 def : Pat<(i32 (vecreduce_add (vselect (v8i1 VCCR:$pred),
1201 (mul (v8i16 MQPR:$src1), (v8i16 MQPR:$src2)),
1202 (v8i16 ARMimmAllZerosV)))),
1203 (i32 (MVE_VMLADAVu16 $src1, $src2, ARMVCCThen, $pred, zero_reg))>;
1204 def : Pat<(i32 (ARMVMLAVps (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), (v8i1 VCCR:$pred))),
1205 (i32 (MVE_VMLADAVs16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), ARMVCCThen, $pred, zero_reg))>;
1206 def : Pat<(i32 (ARMVMLAVpu (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), (v8i1 VCCR:$pred))),
1207 (i32 (MVE_VMLADAVu16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), ARMVCCThen, $pred, zero_reg))>;
1208 def : Pat<(i32 (vecreduce_add (vselect (v16i1 VCCR:$pred),
1209 (mul (v16i8 MQPR:$src1), (v16i8 MQPR:$src2)),
1210 (v16i8 ARMimmAllZerosV)))),
1211 (i32 (MVE_VMLADAVu8 $src1, $src2, ARMVCCThen, $pred, zero_reg))>;
1212 def : Pat<(i32 (ARMVMLAVps (v16i8 MQPR:$val1), (v16i8 MQPR:$val2), (v16i1 VCCR:$pred))),
1213 (i32 (MVE_VMLADAVs8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2), ARMVCCThen, $pred, zero_reg))>;
1214 def : Pat<(i32 (ARMVMLAVpu (v16i8 MQPR:$val1), (v16i8 MQPR:$val2), (v16i1 VCCR:$pred))),
1215 (i32 (MVE_VMLADAVu8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2), ARMVCCThen, $pred, zero_reg))>;
1217 def : Pat<(i32 (add (i32 (vecreduce_add (vselect (v4i1 VCCR:$pred),
1218 (mul (v4i32 MQPR:$src1), (v4i32 MQPR:$src2)),
1219 (v4i32 ARMimmAllZerosV)))),
1220 (i32 tGPREven:$src3))),
1221 (i32 (MVE_VMLADAVau32 $src3, $src1, $src2, ARMVCCThen, $pred, zero_reg))>;
1222 def : Pat<(i32 (add (i32 (vecreduce_add (vselect (v8i1 VCCR:$pred),
1223 (mul (v8i16 MQPR:$src1), (v8i16 MQPR:$src2)),
1224 (v8i16 ARMimmAllZerosV)))),
1225 (i32 tGPREven:$src3))),
1226 (i32 (MVE_VMLADAVau16 $src3, $src1, $src2, ARMVCCThen, $pred, zero_reg))>;
1227 def : Pat<(i32 (add (ARMVMLAVps (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), (v8i1 VCCR:$pred)), tGPREven:$Rd)),
1228 (i32 (MVE_VMLADAVas16 tGPREven:$Rd, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), ARMVCCThen, $pred, zero_reg))>;
1229 def : Pat<(i32 (add (ARMVMLAVpu (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), (v8i1 VCCR:$pred)), tGPREven:$Rd)),
1230 (i32 (MVE_VMLADAVau16 tGPREven:$Rd, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), ARMVCCThen, $pred, zero_reg))>;
1231 def : Pat<(i32 (add (i32 (vecreduce_add (vselect (v16i1 VCCR:$pred),
1232 (mul (v16i8 MQPR:$src1), (v16i8 MQPR:$src2)),
1233 (v16i8 ARMimmAllZerosV)))),
1234 (i32 tGPREven:$src3))),
1235 (i32 (MVE_VMLADAVau8 $src3, $src1, $src2, ARMVCCThen, $pred, zero_reg))>;
1236 def : Pat<(i32 (add (ARMVMLAVps (v16i8 MQPR:$val1), (v16i8 MQPR:$val2), (v16i1 VCCR:$pred)), tGPREven:$Rd)),
1237 (i32 (MVE_VMLADAVas8 tGPREven:$Rd, (v16i8 MQPR:$val1), (v16i8 MQPR:$val2), ARMVCCThen, $pred, zero_reg))>;
1238 def : Pat<(i32 (add (ARMVMLAVpu (v16i8 MQPR:$val1), (v16i8 MQPR:$val2), (v16i1 VCCR:$pred)), tGPREven:$Rd)),
1239 (i32 (MVE_VMLADAVau8 tGPREven:$Rd, (v16i8 MQPR:$val1), (v16i8 MQPR:$val2), ARMVCCThen, $pred, zero_reg))>;
1242 // vmlav aliases vmladav
1243 foreach acc = ["", "a"] in {
1244 foreach suffix = ["s8", "s16", "s32", "u8", "u16", "u32"] in {
1245 def : MVEInstAlias<"vmlav"#acc#"${vp}."#suffix#"\t$RdaDest, $Qn, $Qm",
1246 (!cast<Instruction>("MVE_VMLADAV"#acc#suffix)
1247 tGPREven:$RdaDest, MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
1251 // Base class for VMLALDAV and VMLSLDAV, VRMLALDAVH, VRMLSLDAVH
1252 class MVE_VMLALDAVBase<string iname, string suffix, dag iops, string cstr,
1253 bit sz, bit bit_28, bit A, bit X, bit bit_8, bit bit_0,
1254 bits<2> vecsize, list<dag> pattern=[]>
1255 : MVE_rDest<(outs tGPREven:$RdaLoDest, tGPROdd:$RdaHiDest), iops, NoItinerary,
1256 iname, suffix, "$RdaLoDest, $RdaHiDest, $Qn, $Qm", cstr, vecsize, pattern> {
1262 let Inst{28} = bit_28;
1263 let Inst{22-20} = RdaHiDest{3-1};
1264 let Inst{19-17} = Qn{2-0};
1266 let Inst{15-13} = RdaLoDest{3-1};
1268 let Inst{8} = bit_8;
1269 let Inst{7-6} = 0b00;
1271 let Inst{3-1} = Qm{2-0};
1272 let Inst{0} = bit_0;
1273 let horizontalReduction = 1;
1274 // Allow tail predication for non-exchanging versions. As this is also a
1275 // horizontalReduction, ARMLowOverheadLoops will also have to check that
1276 // the vector operands contain zeros in their false lanes for the instruction
1277 // to be properly valid.
1278 let validForTailPredication = !eq(X, 0);
1280 let hasSideEffects = 0;
1283 multiclass MVE_VMLALDAVBase_A<string iname, string x, string suffix,
1284 bit sz, bit bit_28, bit X, bit bit_8, bit bit_0,
1285 bits<2> vecsize, list<dag> pattern=[]> {
1286 def ""#x#suffix : MVE_VMLALDAVBase<
1287 iname # x, suffix, (ins MQPR:$Qn, MQPR:$Qm), "",
1288 sz, bit_28, 0b0, X, bit_8, bit_0, vecsize, pattern>;
1289 def "a"#x#suffix : MVE_VMLALDAVBase<
1290 iname # "a" # x, suffix,
1291 (ins tGPREven:$RdaLoSrc, tGPROdd:$RdaHiSrc, MQPR:$Qn, MQPR:$Qm),
1292 "$RdaLoDest = $RdaLoSrc,$RdaHiDest = $RdaHiSrc",
1293 sz, bit_28, 0b1, X, bit_8, bit_0, vecsize, pattern>;
1297 multiclass MVE_VMLALDAVBase_AX<string iname, string suffix, bit sz, bit bit_28,
1298 bit bit_8, bit bit_0, bits<2> vecsize, list<dag> pattern=[]> {
1299 defm "" : MVE_VMLALDAVBase_A<iname, "", suffix, sz,
1300 bit_28, 0b0, bit_8, bit_0, vecsize, pattern>;
1301 defm "" : MVE_VMLALDAVBase_A<iname, "x", suffix, sz,
1302 bit_28, 0b1, bit_8, bit_0, vecsize, pattern>;
1305 multiclass MVE_VRMLALDAVH_multi<MVEVectorVTInfo VTI, list<dag> pattern=[]> {
1306 defm "" : MVE_VMLALDAVBase_AX<"vrmlaldavh", "s"#VTI.BitsSuffix,
1307 0b0, 0b0, 0b1, 0b0, VTI.Size, pattern>;
1308 defm "" : MVE_VMLALDAVBase_A<"vrmlaldavh", "", "u"#VTI.BitsSuffix,
1309 0b0, 0b1, 0b0, 0b1, 0b0, VTI.Size, pattern>;
1312 defm MVE_VRMLALDAVH : MVE_VRMLALDAVH_multi<MVE_v4i32>;
1314 // vrmlalvh aliases for vrmlaldavh
1315 def : MVEInstAlias<"vrmlalvh${vp}.s32\t$RdaLo, $RdaHi, $Qn, $Qm",
1317 tGPREven:$RdaLo, tGPROdd:$RdaHi,
1318 MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
1319 def : MVEInstAlias<"vrmlalvha${vp}.s32\t$RdaLo, $RdaHi, $Qn, $Qm",
1321 tGPREven:$RdaLo, tGPROdd:$RdaHi,
1322 MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
1323 def : MVEInstAlias<"vrmlalvh${vp}.u32\t$RdaLo, $RdaHi, $Qn, $Qm",
1325 tGPREven:$RdaLo, tGPROdd:$RdaHi,
1326 MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
1327 def : MVEInstAlias<"vrmlalvha${vp}.u32\t$RdaLo, $RdaHi, $Qn, $Qm",
1329 tGPREven:$RdaLo, tGPROdd:$RdaHi,
1330 MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
1332 multiclass MVE_VMLALDAV_multi<MVEVectorVTInfo VTI, list<dag> pattern=[]> {
1333 defm "" : MVE_VMLALDAVBase_AX<"vmlaldav", "s"#VTI.BitsSuffix,
1334 VTI.Size{1}, 0b0, 0b0, 0b0, VTI.Size, pattern>;
1335 defm "" : MVE_VMLALDAVBase_A<"vmlaldav", "", "u"#VTI.BitsSuffix,
1336 VTI.Size{1}, 0b1, 0b0, 0b0, 0b0, VTI.Size, pattern>;
1339 defm MVE_VMLALDAV : MVE_VMLALDAV_multi<MVE_v8i16>;
1340 defm MVE_VMLALDAV : MVE_VMLALDAV_multi<MVE_v4i32>;
1342 let Predicates = [HasMVEInt] in {
1343 def : Pat<(ARMVMLALVs (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)),
1344 (MVE_VMLALDAVs32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))>;
1345 def : Pat<(ARMVMLALVu (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)),
1346 (MVE_VMLALDAVu32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))>;
1347 def : Pat<(ARMVMLALVs (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)),
1348 (MVE_VMLALDAVs16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))>;
1349 def : Pat<(ARMVMLALVu (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)),
1350 (MVE_VMLALDAVu16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))>;
1352 def : Pat<(ARMVMLALVAs tGPREven:$Rda, tGPROdd:$Rdb, (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)),
1353 (MVE_VMLALDAVas32 tGPREven:$Rda, tGPROdd:$Rdb, (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))>;
1354 def : Pat<(ARMVMLALVAu tGPREven:$Rda, tGPROdd:$Rdb, (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)),
1355 (MVE_VMLALDAVau32 tGPREven:$Rda, tGPROdd:$Rdb, (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))>;
1356 def : Pat<(ARMVMLALVAs tGPREven:$Rda, tGPROdd:$Rdb, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)),
1357 (MVE_VMLALDAVas16 tGPREven:$Rda, tGPROdd:$Rdb, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))>;
1358 def : Pat<(ARMVMLALVAu tGPREven:$Rda, tGPROdd:$Rdb, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)),
1359 (MVE_VMLALDAVau16 tGPREven:$Rda, tGPROdd:$Rdb, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))>;
1362 def : Pat<(ARMVMLALVps (v4i32 MQPR:$val1), (v4i32 MQPR:$val2), (v4i1 VCCR:$pred)),
1363 (MVE_VMLALDAVs32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2), ARMVCCThen, $pred, zero_reg)>;
1364 def : Pat<(ARMVMLALVpu (v4i32 MQPR:$val1), (v4i32 MQPR:$val2), (v4i1 VCCR:$pred)),
1365 (MVE_VMLALDAVu32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2), ARMVCCThen, $pred, zero_reg)>;
1366 def : Pat<(ARMVMLALVps (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), (v8i1 VCCR:$pred)),
1367 (MVE_VMLALDAVs16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), ARMVCCThen, $pred, zero_reg)>;
1368 def : Pat<(ARMVMLALVpu (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), (v8i1 VCCR:$pred)),
1369 (MVE_VMLALDAVu16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), ARMVCCThen, $pred, zero_reg)>;
1371 def : Pat<(ARMVMLALVAps tGPREven:$Rda, tGPROdd:$Rdb, (v4i32 MQPR:$val1), (v4i32 MQPR:$val2), (v4i1 VCCR:$pred)),
1372 (MVE_VMLALDAVas32 tGPREven:$Rda, tGPROdd:$Rdb, (v4i32 MQPR:$val1), (v4i32 MQPR:$val2), ARMVCCThen, $pred, zero_reg)>;
1373 def : Pat<(ARMVMLALVApu tGPREven:$Rda, tGPROdd:$Rdb, (v4i32 MQPR:$val1), (v4i32 MQPR:$val2), (v4i1 VCCR:$pred)),
1374 (MVE_VMLALDAVau32 tGPREven:$Rda, tGPROdd:$Rdb, (v4i32 MQPR:$val1), (v4i32 MQPR:$val2), ARMVCCThen, $pred, zero_reg)>;
1375 def : Pat<(ARMVMLALVAps tGPREven:$Rda, tGPROdd:$Rdb, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), (v8i1 VCCR:$pred)),
1376 (MVE_VMLALDAVas16 tGPREven:$Rda, tGPROdd:$Rdb, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), ARMVCCThen, $pred, zero_reg)>;
1377 def : Pat<(ARMVMLALVApu tGPREven:$Rda, tGPROdd:$Rdb, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), (v8i1 VCCR:$pred)),
1378 (MVE_VMLALDAVau16 tGPREven:$Rda, tGPROdd:$Rdb, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), ARMVCCThen, $pred, zero_reg)>;
1381 // vmlalv aliases vmlaldav
1382 foreach acc = ["", "a"] in {
1383 foreach suffix = ["s16", "s32", "u16", "u32"] in {
1384 def : MVEInstAlias<"vmlalv" # acc # "${vp}." # suffix #
1385 "\t$RdaLoDest, $RdaHiDest, $Qn, $Qm",
1386 (!cast<Instruction>("MVE_VMLALDAV"#acc#suffix)
1387 tGPREven:$RdaLoDest, tGPROdd:$RdaHiDest,
1388 MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
1392 multiclass MVE_VMLSLDAV_multi<string iname, string suffix, bit sz,
1393 bit bit_28, bits<2> vecsize, list<dag> pattern=[]> {
1394 defm "" : MVE_VMLALDAVBase_AX<iname, suffix, sz, bit_28, 0b0, 0b1, vecsize, pattern>;
1397 defm MVE_VMLSLDAV : MVE_VMLSLDAV_multi<"vmlsldav", "s16", 0b0, 0b0, 0b01>;
1398 defm MVE_VMLSLDAV : MVE_VMLSLDAV_multi<"vmlsldav", "s32", 0b1, 0b0, 0b10>;
1399 defm MVE_VRMLSLDAVH : MVE_VMLSLDAV_multi<"vrmlsldavh", "s32", 0b0, 0b1, 0b10>;
1401 // end of mve_rDest instructions
1403 // start of mve_comp instructions
1405 class MVE_comp<InstrItinClass itin, string iname, string suffix,
1406 string cstr, bits<2> vecsize, list<dag> pattern=[]>
1407 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm), itin, iname, suffix,
1408 "$Qd, $Qn, $Qm", vpred_r, cstr, vecsize, pattern> {
1413 let Inst{22} = Qd{3};
1414 let Inst{19-17} = Qn{2-0};
1416 let Inst{15-13} = Qd{2-0};
1418 let Inst{10-9} = 0b11;
1419 let Inst{7} = Qn{3};
1420 let Inst{5} = Qm{3};
1421 let Inst{3-1} = Qm{2-0};
1425 class MVE_VMINMAXNM<string iname, string suffix, bits<2> sz, bit bit_21,
1426 list<dag> pattern=[]>
1427 : MVE_comp<NoItinerary, iname, suffix, "", sz, pattern> {
1430 let Inst{25-24} = 0b11;
1432 let Inst{21} = bit_21;
1433 let Inst{20} = sz{0};
1439 let Predicates = [HasMVEFloat];
1440 let validForTailPredication = 1;
1443 multiclass MVE_VMINMAXNM_m<string iname, bit bit_4, MVEVectorVTInfo VTI, SDNode Op, Intrinsic PredInt> {
1444 def "" : MVE_VMINMAXNM<iname, VTI.Suffix, VTI.Size, bit_4>;
1446 let Predicates = [HasMVEFloat] in {
1447 defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? (i32 0)), !cast<Instruction>(NAME)>;
1451 defm MVE_VMAXNMf32 : MVE_VMINMAXNM_m<"vmaxnm", 0b0, MVE_v4f32, fmaxnum, int_arm_mve_max_predicated>;
1452 defm MVE_VMAXNMf16 : MVE_VMINMAXNM_m<"vmaxnm", 0b0, MVE_v8f16, fmaxnum, int_arm_mve_max_predicated>;
1453 defm MVE_VMINNMf32 : MVE_VMINMAXNM_m<"vminnm", 0b1, MVE_v4f32, fminnum, int_arm_mve_min_predicated>;
1454 defm MVE_VMINNMf16 : MVE_VMINMAXNM_m<"vminnm", 0b1, MVE_v8f16, fminnum, int_arm_mve_min_predicated>;
1457 class MVE_VMINMAX<string iname, string suffix, bit U, bits<2> size,
1458 bit bit_4, list<dag> pattern=[]>
1459 : MVE_comp<NoItinerary, iname, suffix, "", size, pattern> {
1462 let Inst{25-24} = 0b11;
1464 let Inst{21-20} = size{1-0};
1468 let Inst{4} = bit_4;
1469 let validForTailPredication = 1;
1472 multiclass MVE_VMINMAX_m<string iname, bit bit_4, MVEVectorVTInfo VTI,
1473 SDNode Op, Intrinsic PredInt> {
1474 def "" : MVE_VMINMAX<iname, VTI.Suffix, VTI.Unsigned, VTI.Size, bit_4>;
1476 let Predicates = [HasMVEInt] in {
1477 defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? (i32 VTI.Unsigned)), !cast<Instruction>(NAME)>;
1481 multiclass MVE_VMAX<MVEVectorVTInfo VTI>
1482 : MVE_VMINMAX_m<"vmax", 0b0, VTI, !if(VTI.Unsigned, umax, smax), int_arm_mve_max_predicated>;
1483 multiclass MVE_VMIN<MVEVectorVTInfo VTI>
1484 : MVE_VMINMAX_m<"vmin", 0b1, VTI, !if(VTI.Unsigned, umin, smin), int_arm_mve_min_predicated>;
1486 defm MVE_VMINs8 : MVE_VMIN<MVE_v16s8>;
1487 defm MVE_VMINs16 : MVE_VMIN<MVE_v8s16>;
1488 defm MVE_VMINs32 : MVE_VMIN<MVE_v4s32>;
1489 defm MVE_VMINu8 : MVE_VMIN<MVE_v16u8>;
1490 defm MVE_VMINu16 : MVE_VMIN<MVE_v8u16>;
1491 defm MVE_VMINu32 : MVE_VMIN<MVE_v4u32>;
1493 defm MVE_VMAXs8 : MVE_VMAX<MVE_v16s8>;
1494 defm MVE_VMAXs16 : MVE_VMAX<MVE_v8s16>;
1495 defm MVE_VMAXs32 : MVE_VMAX<MVE_v4s32>;
1496 defm MVE_VMAXu8 : MVE_VMAX<MVE_v16u8>;
1497 defm MVE_VMAXu16 : MVE_VMAX<MVE_v8u16>;
1498 defm MVE_VMAXu32 : MVE_VMAX<MVE_v4u32>;
1500 // end of mve_comp instructions
1502 // start of mve_bit instructions
1504 class MVE_bit_arith<dag oops, dag iops, string iname, string suffix,
1505 string ops, string cstr, bits<2> vecsize, list<dag> pattern=[]>
1506 : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred_r, cstr, vecsize, pattern> {
1510 let Inst{22} = Qd{3};
1511 let Inst{15-13} = Qd{2-0};
1512 let Inst{5} = Qm{3};
1513 let Inst{3-1} = Qm{2-0};
1516 def MVE_VBIC : MVE_bit_arith<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm),
1517 "vbic", "", "$Qd, $Qn, $Qm", "", 0b00> {
1521 let Inst{25-23} = 0b110;
1522 let Inst{21-20} = 0b01;
1523 let Inst{19-17} = Qn{2-0};
1525 let Inst{12-8} = 0b00001;
1526 let Inst{7} = Qn{3};
1530 let validForTailPredication = 1;
1533 class MVE_VREV<string iname, string suffix, bits<2> size, bits<2> bit_8_7,
1534 bits<2> vecsize, string cstr="">
1535 : MVE_bit_arith<(outs MQPR:$Qd), (ins MQPR:$Qm), iname,
1536 suffix, "$Qd, $Qm", cstr, vecsize> {
1539 let Inst{25-23} = 0b111;
1540 let Inst{21-20} = 0b11;
1541 let Inst{19-18} = size;
1542 let Inst{17-16} = 0b00;
1543 let Inst{12-9} = 0b0000;
1544 let Inst{8-7} = bit_8_7;
1550 def MVE_VREV64_8 : MVE_VREV<"vrev64", "8", 0b00, 0b00, 0b11, "@earlyclobber $Qd">;
1551 def MVE_VREV64_16 : MVE_VREV<"vrev64", "16", 0b01, 0b00, 0b11, "@earlyclobber $Qd">;
1552 def MVE_VREV64_32 : MVE_VREV<"vrev64", "32", 0b10, 0b00, 0b11, "@earlyclobber $Qd">;
1554 def MVE_VREV32_8 : MVE_VREV<"vrev32", "8", 0b00, 0b01, 0b10>;
1555 def MVE_VREV32_16 : MVE_VREV<"vrev32", "16", 0b01, 0b01, 0b10>;
1557 def MVE_VREV16_8 : MVE_VREV<"vrev16", "8", 0b00, 0b10, 0b01>;
1559 let Predicates = [HasMVEInt] in {
1560 def : Pat<(v8i16 (bswap (v8i16 MQPR:$src))),
1561 (v8i16 (MVE_VREV16_8 (v8i16 MQPR:$src)))>;
1562 def : Pat<(v4i32 (bswap (v4i32 MQPR:$src))),
1563 (v4i32 (MVE_VREV32_8 (v4i32 MQPR:$src)))>;
1566 multiclass MVE_VREV_basic_patterns<int revbits, list<MVEVectorVTInfo> VTIs,
1568 defvar unpred_op = !cast<SDNode>("ARMvrev" # revbits);
1570 foreach VTI = VTIs in {
1571 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$src))),
1572 (VTI.Vec (Inst (VTI.Vec MQPR:$src)))>;
1573 def : Pat<(VTI.Vec (int_arm_mve_vrev_predicated (VTI.Vec MQPR:$src),
1574 revbits, (VTI.Pred VCCR:$pred), (VTI.Vec MQPR:$inactive))),
1575 (VTI.Vec (Inst (VTI.Vec MQPR:$src), ARMVCCThen,
1576 (VTI.Pred VCCR:$pred), zero_reg, (VTI.Vec MQPR:$inactive)))>;
1580 let Predicates = [HasMVEInt] in {
1581 defm: MVE_VREV_basic_patterns<64, [MVE_v4i32, MVE_v4f32], MVE_VREV64_32>;
1582 defm: MVE_VREV_basic_patterns<64, [MVE_v8i16, MVE_v8f16], MVE_VREV64_16>;
1583 defm: MVE_VREV_basic_patterns<64, [MVE_v16i8 ], MVE_VREV64_8>;
1585 defm: MVE_VREV_basic_patterns<32, [MVE_v8i16, MVE_v8f16], MVE_VREV32_16>;
1586 defm: MVE_VREV_basic_patterns<32, [MVE_v16i8 ], MVE_VREV32_8>;
1588 defm: MVE_VREV_basic_patterns<16, [MVE_v16i8 ], MVE_VREV16_8>;
1591 def MVE_VMVN : MVE_bit_arith<(outs MQPR:$Qd), (ins MQPR:$Qm),
1592 "vmvn", "", "$Qd, $Qm", "", 0b00> {
1594 let Inst{25-23} = 0b111;
1595 let Inst{21-16} = 0b110000;
1596 let Inst{12-6} = 0b0010111;
1599 let validForTailPredication = 1;
1602 let Predicates = [HasMVEInt] in {
1603 foreach VTI = [ MVE_v16i8, MVE_v8i16, MVE_v4i32, MVE_v2i64 ] in {
1604 def : Pat<(VTI.Vec (vnotq (VTI.Vec MQPR:$val1))),
1605 (VTI.Vec (MVE_VMVN (VTI.Vec MQPR:$val1)))>;
1606 def : Pat<(VTI.Vec (int_arm_mve_mvn_predicated (VTI.Vec MQPR:$val1),
1607 (VTI.Pred VCCR:$pred), (VTI.Vec MQPR:$inactive))),
1608 (VTI.Vec (MVE_VMVN (VTI.Vec MQPR:$val1), ARMVCCThen,
1609 (VTI.Pred VCCR:$pred), zero_reg, (VTI.Vec MQPR:$inactive)))>;
1613 class MVE_bit_ops<string iname, bits<2> bit_21_20, bit bit_28>
1614 : MVE_bit_arith<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm),
1615 iname, "", "$Qd, $Qn, $Qm", "", 0b00> {
1618 let Inst{28} = bit_28;
1619 let Inst{25-23} = 0b110;
1620 let Inst{21-20} = bit_21_20;
1621 let Inst{19-17} = Qn{2-0};
1623 let Inst{12-8} = 0b00001;
1624 let Inst{7} = Qn{3};
1628 let validForTailPredication = 1;
1631 def MVE_VEOR : MVE_bit_ops<"veor", 0b00, 0b1>;
1632 def MVE_VORN : MVE_bit_ops<"vorn", 0b11, 0b0>;
1633 def MVE_VORR : MVE_bit_ops<"vorr", 0b10, 0b0>;
1634 def MVE_VAND : MVE_bit_ops<"vand", 0b00, 0b0>;
1636 // add ignored suffixes as aliases
1638 foreach s=["s8", "s16", "s32", "u8", "u16", "u32", "i8", "i16", "i32", "f16", "f32"] in {
1639 def : MVEInstAlias<"vbic${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc",
1640 (MVE_VBIC MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>;
1641 def : MVEInstAlias<"veor${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc",
1642 (MVE_VEOR MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>;
1643 def : MVEInstAlias<"vorn${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc",
1644 (MVE_VORN MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>;
1645 def : MVEInstAlias<"vorr${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc",
1646 (MVE_VORR MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>;
1647 def : MVEInstAlias<"vand${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc",
1648 (MVE_VAND MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>;
1651 let Predicates = [HasMVEInt] in {
1652 defm : MVE_TwoOpPattern<MVE_v16i8, and, int_arm_mve_and_predicated, (? ), MVE_VAND, ARMimmAllOnesV>;
1653 defm : MVE_TwoOpPattern<MVE_v8i16, and, int_arm_mve_and_predicated, (? ), MVE_VAND, ARMimmAllOnesV>;
1654 defm : MVE_TwoOpPattern<MVE_v4i32, and, int_arm_mve_and_predicated, (? ), MVE_VAND, ARMimmAllOnesV>;
1655 defm : MVE_TwoOpPattern<MVE_v2i64, and, int_arm_mve_and_predicated, (? ), MVE_VAND, ARMimmAllOnesV>;
1657 defm : MVE_TwoOpPattern<MVE_v16i8, or, int_arm_mve_orr_predicated, (? ), MVE_VORR, ARMimmAllZerosV>;
1658 defm : MVE_TwoOpPattern<MVE_v8i16, or, int_arm_mve_orr_predicated, (? ), MVE_VORR, ARMimmAllZerosV>;
1659 defm : MVE_TwoOpPattern<MVE_v4i32, or, int_arm_mve_orr_predicated, (? ), MVE_VORR, ARMimmAllZerosV>;
1660 defm : MVE_TwoOpPattern<MVE_v2i64, or, int_arm_mve_orr_predicated, (? ), MVE_VORR, ARMimmAllZerosV>;
1662 defm : MVE_TwoOpPattern<MVE_v16i8, xor, int_arm_mve_eor_predicated, (? ), MVE_VEOR, ARMimmAllZerosV>;
1663 defm : MVE_TwoOpPattern<MVE_v8i16, xor, int_arm_mve_eor_predicated, (? ), MVE_VEOR, ARMimmAllZerosV>;
1664 defm : MVE_TwoOpPattern<MVE_v4i32, xor, int_arm_mve_eor_predicated, (? ), MVE_VEOR, ARMimmAllZerosV>;
1665 defm : MVE_TwoOpPattern<MVE_v2i64, xor, int_arm_mve_eor_predicated, (? ), MVE_VEOR, ARMimmAllZerosV>;
1667 defm : MVE_TwoOpPattern<MVE_v16i8, BinOpFrag<(and node:$LHS, (vnotq node:$RHS))>,
1668 int_arm_mve_bic_predicated, (? ), MVE_VBIC>;
1669 defm : MVE_TwoOpPattern<MVE_v8i16, BinOpFrag<(and node:$LHS, (vnotq node:$RHS))>,
1670 int_arm_mve_bic_predicated, (? ), MVE_VBIC>;
1671 defm : MVE_TwoOpPattern<MVE_v4i32, BinOpFrag<(and node:$LHS, (vnotq node:$RHS))>,
1672 int_arm_mve_bic_predicated, (? ), MVE_VBIC>;
1673 defm : MVE_TwoOpPattern<MVE_v2i64, BinOpFrag<(and node:$LHS, (vnotq node:$RHS))>,
1674 int_arm_mve_bic_predicated, (? ), MVE_VBIC>;
1676 defm : MVE_TwoOpPattern<MVE_v16i8, BinOpFrag<(or node:$LHS, (vnotq node:$RHS))>,
1677 int_arm_mve_orn_predicated, (? ), MVE_VORN>;
1678 defm : MVE_TwoOpPattern<MVE_v8i16, BinOpFrag<(or node:$LHS, (vnotq node:$RHS))>,
1679 int_arm_mve_orn_predicated, (? ), MVE_VORN>;
1680 defm : MVE_TwoOpPattern<MVE_v4i32, BinOpFrag<(or node:$LHS, (vnotq node:$RHS))>,
1681 int_arm_mve_orn_predicated, (? ), MVE_VORN>;
1682 defm : MVE_TwoOpPattern<MVE_v2i64, BinOpFrag<(or node:$LHS, (vnotq node:$RHS))>,
1683 int_arm_mve_orn_predicated, (? ), MVE_VORN>;
1686 class MVE_bit_cmode<string iname, string suffix, bit halfword, dag inOps, bits<2> vecsize>
1687 : MVE_p<(outs MQPR:$Qd), inOps, NoItinerary,
1688 iname, suffix, "$Qd, $imm", vpred_n, "$Qd = $Qd_src", vecsize> {
1692 let Inst{28} = imm{7};
1693 let Inst{27-23} = 0b11111;
1694 let Inst{22} = Qd{3};
1695 let Inst{21-19} = 0b000;
1696 let Inst{18-16} = imm{6-4};
1697 let Inst{15-13} = Qd{2-0};
1699 let Inst{11} = halfword;
1700 let Inst{10} = !if(halfword, 0, imm{10});
1701 let Inst{9} = imm{9};
1703 let Inst{7-6} = 0b01;
1705 let Inst{3-0} = imm{3-0};
1708 multiclass MVE_bit_cmode_p<string iname, bit opcode,
1709 MVEVectorVTInfo VTI, Operand imm_type, SDNode op> {
1710 def "" : MVE_bit_cmode<iname, VTI.Suffix, VTI.Size{0},
1711 (ins MQPR:$Qd_src, imm_type:$imm), VTI.Size> {
1712 let Inst{5} = opcode;
1713 let validForTailPredication = 1;
1716 defvar Inst = !cast<Instruction>(NAME);
1717 defvar UnpredPat = (VTI.Vec (op (VTI.Vec MQPR:$src), timm:$simm));
1719 let Predicates = [HasMVEInt] in {
1720 def : Pat<UnpredPat,
1721 (VTI.Vec (Inst (VTI.Vec MQPR:$src), imm_type:$simm))>;
1722 def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred),
1723 UnpredPat, (VTI.Vec MQPR:$src))),
1724 (VTI.Vec (Inst (VTI.Vec MQPR:$src), imm_type:$simm,
1725 ARMVCCThen, (VTI.Pred VCCR:$pred), zero_reg))>;
1729 multiclass MVE_VORRimm<MVEVectorVTInfo VTI, Operand imm_type> {
1730 defm "": MVE_bit_cmode_p<"vorr", 0, VTI, imm_type, ARMvorrImm>;
1732 multiclass MVE_VBICimm<MVEVectorVTInfo VTI, Operand imm_type> {
1733 defm "": MVE_bit_cmode_p<"vbic", 1, VTI, imm_type, ARMvbicImm>;
1736 defm MVE_VORRimmi16 : MVE_VORRimm<MVE_v8i16, nImmSplatI16>;
1737 defm MVE_VORRimmi32 : MVE_VORRimm<MVE_v4i32, nImmSplatI32>;
1738 defm MVE_VBICimmi16 : MVE_VBICimm<MVE_v8i16, nImmSplatI16>;
1739 defm MVE_VBICimmi32 : MVE_VBICimm<MVE_v4i32, nImmSplatI32>;
1741 def MVE_VORNimmi16 : MVEInstAlias<"vorn${vp}.i16\t$Qd, $imm",
1742 (MVE_VORRimmi16 MQPR:$Qd, nImmSplatNotI16:$imm, vpred_n:$vp), 0>;
1743 def MVE_VORNimmi32 : MVEInstAlias<"vorn${vp}.i32\t$Qd, $imm",
1744 (MVE_VORRimmi32 MQPR:$Qd, nImmSplatNotI32:$imm, vpred_n:$vp), 0>;
1746 def MVE_VANDimmi16 : MVEInstAlias<"vand${vp}.i16\t$Qd, $imm",
1747 (MVE_VBICimmi16 MQPR:$Qd, nImmSplatNotI16:$imm, vpred_n:$vp), 0>;
1748 def MVE_VANDimmi32 : MVEInstAlias<"vand${vp}.i32\t$Qd, $imm",
1749 (MVE_VBICimmi32 MQPR:$Qd, nImmSplatNotI32:$imm, vpred_n:$vp), 0>;
1751 def MVE_VMOV : MVEInstAlias<"vmov${vp}\t$Qd, $Qm",
1752 (MVE_VORR MQPR:$Qd, MQPR:$Qm, MQPR:$Qm, vpred_r:$vp)>;
1754 class MVE_VMOV_lane_direction {
1761 def MVE_VMOV_from_lane : MVE_VMOV_lane_direction {
1763 let oops = (outs rGPR:$Rt);
1764 let iops = (ins MQPR:$Qd);
1765 let ops = "$Rt, $Qd$Idx";
1768 def MVE_VMOV_to_lane : MVE_VMOV_lane_direction {
1770 let oops = (outs MQPR:$Qd);
1771 let iops = (ins MQPR:$Qd_src, rGPR:$Rt);
1772 let ops = "$Qd$Idx, $Rt";
1773 let cstr = "$Qd = $Qd_src";
1776 class MVE_VMOV_lane<string suffix, bit U, dag indexop,
1777 MVE_VMOV_lane_direction dir>
1778 : MVE_VMOV_lane_base<dir.oops, !con(dir.iops, indexop), NoItinerary,
1779 "vmov", suffix, dir.ops, dir.cstr, []> {
1783 let Inst{31-24} = 0b11101110;
1785 let Inst{20} = dir.bit_20;
1786 let Inst{19-17} = Qd{2-0};
1787 let Inst{15-12} = Rt{3-0};
1788 let Inst{11-8} = 0b1011;
1789 let Inst{7} = Qd{3};
1790 let Inst{4-0} = 0b10000;
1792 let hasSideEffects = 0;
1795 class MVE_VMOV_lane_32<MVE_VMOV_lane_direction dir>
1796 : MVE_VMOV_lane<"32", 0b0, (ins MVEVectorIndex<4>:$Idx), dir> {
1799 let Inst{6-5} = 0b00;
1800 let Inst{16} = Idx{1};
1801 let Inst{21} = Idx{0};
1804 let Predicates = [HasFPRegsV8_1M];
1807 class MVE_VMOV_lane_16<string suffix, bit U, MVE_VMOV_lane_direction dir>
1808 : MVE_VMOV_lane<suffix, U, (ins MVEVectorIndex<8>:$Idx), dir> {
1812 let Inst{16} = Idx{2};
1813 let Inst{21} = Idx{1};
1814 let Inst{6} = Idx{0};
1819 class MVE_VMOV_lane_8<string suffix, bit U, MVE_VMOV_lane_direction dir>
1820 : MVE_VMOV_lane<suffix, U, (ins MVEVectorIndex<16>:$Idx), dir> {
1823 let Inst{16} = Idx{3};
1824 let Inst{21} = Idx{2};
1825 let Inst{6} = Idx{1};
1826 let Inst{5} = Idx{0};
1831 def MVE_VMOV_from_lane_32 : MVE_VMOV_lane_32< MVE_VMOV_from_lane>;
1832 def MVE_VMOV_from_lane_s16 : MVE_VMOV_lane_16<"s16", 0b0, MVE_VMOV_from_lane>;
1833 def MVE_VMOV_from_lane_u16 : MVE_VMOV_lane_16<"u16", 0b1, MVE_VMOV_from_lane>;
1834 def MVE_VMOV_from_lane_s8 : MVE_VMOV_lane_8 < "s8", 0b0, MVE_VMOV_from_lane>;
1835 def MVE_VMOV_from_lane_u8 : MVE_VMOV_lane_8 < "u8", 0b1, MVE_VMOV_from_lane>;
1836 let isInsertSubreg = 1 in
1837 def MVE_VMOV_to_lane_32 : MVE_VMOV_lane_32< MVE_VMOV_to_lane>;
1838 def MVE_VMOV_to_lane_16 : MVE_VMOV_lane_16< "16", 0b0, MVE_VMOV_to_lane>;
1839 def MVE_VMOV_to_lane_8 : MVE_VMOV_lane_8 < "8", 0b0, MVE_VMOV_to_lane>;
1841 // This is the same as insertelt but allows the inserted value to be an i32 as
1842 // will be used when it is the only legal type.
1843 def ARMVecInsert : SDTypeProfile<1, 3, [
1844 SDTCisVT<2, i32>, SDTCisSameAs<0, 1>, SDTCisPtrTy<3>
1846 def ARMinsertelt : SDNode<"ISD::INSERT_VECTOR_ELT", ARMVecInsert>;
1848 let Predicates = [HasMVEInt] in {
1849 def : Pat<(extractelt (v2f64 MQPR:$src), imm:$lane),
1850 (f64 (EXTRACT_SUBREG MQPR:$src, (DSubReg_f64_reg imm:$lane)))>;
1851 def : Pat<(insertelt (v2f64 MQPR:$src1), DPR:$src2, imm:$lane),
1852 (INSERT_SUBREG (v2f64 (COPY_TO_REGCLASS MQPR:$src1, MQPR)), DPR:$src2, (DSubReg_f64_reg imm:$lane))>;
1854 def : Pat<(extractelt (v4i32 MQPR:$src), imm:$lane),
1856 (i32 (EXTRACT_SUBREG MQPR:$src, (SSubReg_f32_reg imm:$lane))), rGPR)>;
1857 def : Pat<(insertelt (v4i32 MQPR:$src1), rGPR:$src2, imm:$lane),
1858 (MVE_VMOV_to_lane_32 MQPR:$src1, rGPR:$src2, imm:$lane)>;
1859 // This tries to copy from one lane to another, without going via GPR regs
1860 def : Pat<(insertelt (v4i32 MQPR:$src1), (extractelt (v4i32 MQPR:$src2), imm:$extlane), imm:$inslane),
1861 (v4i32 (COPY_TO_REGCLASS
1862 (INSERT_SUBREG (v4f32 (COPY_TO_REGCLASS (v4i32 MQPR:$src1), MQPR)),
1863 (f32 (EXTRACT_SUBREG (v4f32 (COPY_TO_REGCLASS (v4i32 MQPR:$src2), MQPR)),
1864 (SSubReg_f32_reg imm:$extlane))),
1865 (SSubReg_f32_reg imm:$inslane)),
1868 def : Pat<(vector_insert (v16i8 MQPR:$src1), rGPR:$src2, imm:$lane),
1869 (MVE_VMOV_to_lane_8 MQPR:$src1, rGPR:$src2, imm:$lane)>;
1870 def : Pat<(vector_insert (v8i16 MQPR:$src1), rGPR:$src2, imm:$lane),
1871 (MVE_VMOV_to_lane_16 MQPR:$src1, rGPR:$src2, imm:$lane)>;
1873 def : Pat<(ARMvgetlanes (v16i8 MQPR:$src), imm:$lane),
1874 (MVE_VMOV_from_lane_s8 MQPR:$src, imm:$lane)>;
1875 def : Pat<(ARMvgetlanes (v8i16 MQPR:$src), imm:$lane),
1876 (MVE_VMOV_from_lane_s16 MQPR:$src, imm:$lane)>;
1877 def : Pat<(ARMvgetlanes (v8f16 MQPR:$src), imm:$lane),
1878 (MVE_VMOV_from_lane_s16 MQPR:$src, imm:$lane)>;
1879 def : Pat<(ARMvgetlaneu (v16i8 MQPR:$src), imm:$lane),
1880 (MVE_VMOV_from_lane_u8 MQPR:$src, imm:$lane)>;
1881 def : Pat<(ARMvgetlaneu (v8i16 MQPR:$src), imm:$lane),
1882 (MVE_VMOV_from_lane_u16 MQPR:$src, imm:$lane)>;
1883 def : Pat<(ARMvgetlaneu (v8f16 MQPR:$src), imm:$lane),
1884 (MVE_VMOV_from_lane_u16 MQPR:$src, imm:$lane)>;
1885 // For i16's inserts being extracted from low lanes, then may use VINS.
1886 let Predicates = [HasFullFP16] in {
1887 def : Pat<(ARMinsertelt (v8i16 MQPR:$src1),
1888 (ARMvgetlaneu (v8i16 MQPR:$src2), imm_even:$extlane),
1890 (COPY_TO_REGCLASS (INSERT_SUBREG (v4f32 (COPY_TO_REGCLASS MQPR:$src1, MQPR)),
1891 (VINSH (EXTRACT_SUBREG MQPR:$src1, (SSubReg_f16_reg imm_odd:$inslane)),
1892 (EXTRACT_SUBREG MQPR:$src2, (SSubReg_f16_reg imm_even:$extlane))),
1893 (SSubReg_f16_reg imm_odd:$inslane)), MQPR)>;
1896 def : Pat<(v16i8 (scalar_to_vector GPR:$src)),
1897 (MVE_VMOV_to_lane_8 (v16i8 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
1898 def : Pat<(v8i16 (scalar_to_vector GPR:$src)),
1899 (MVE_VMOV_to_lane_16 (v8i16 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
1900 def : Pat<(v4i32 (scalar_to_vector GPR:$src)),
1901 (MVE_VMOV_to_lane_32 (v4i32 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
1903 // Floating point patterns, still enabled under HasMVEInt
1904 def : Pat<(extractelt (v4f32 MQPR:$src), imm:$lane),
1905 (COPY_TO_REGCLASS (f32 (EXTRACT_SUBREG MQPR:$src, (SSubReg_f32_reg imm:$lane))), SPR)>;
1906 def : Pat<(insertelt (v4f32 MQPR:$src1), (f32 SPR:$src2), imm:$lane),
1907 (INSERT_SUBREG (v4f32 (COPY_TO_REGCLASS MQPR:$src1, MQPR)), SPR:$src2, (SSubReg_f32_reg imm:$lane))>;
1909 def : Pat<(insertelt (v8f16 MQPR:$src1), (f16 HPR:$src2), imm_even:$lane),
1910 (MVE_VMOV_to_lane_16 MQPR:$src1, (COPY_TO_REGCLASS (f16 HPR:$src2), rGPR), imm:$lane)>;
1911 let Predicates = [HasFullFP16] in {
1912 def : Pat<(insertelt (v8f16 MQPR:$src1), (f16 HPR:$src2), imm_odd:$lane),
1913 (COPY_TO_REGCLASS (INSERT_SUBREG (v4f32 (COPY_TO_REGCLASS MQPR:$src1, MQPR)),
1914 (VINSH (EXTRACT_SUBREG MQPR:$src1, (SSubReg_f16_reg imm_odd:$lane)),
1915 (COPY_TO_REGCLASS HPR:$src2, SPR)),
1916 (SSubReg_f16_reg imm_odd:$lane)), MQPR)>;
1918 def : Pat<(extractelt (v8f16 MQPR:$src), imm_even:$lane),
1919 (EXTRACT_SUBREG MQPR:$src, (SSubReg_f16_reg imm_even:$lane))>;
1920 let Predicates = [HasFullFP16] in {
1921 def : Pat<(extractelt (v8f16 MQPR:$src), imm_odd:$lane),
1923 (VMOVH (EXTRACT_SUBREG MQPR:$src, (SSubReg_f16_reg imm_odd:$lane))),
1927 def : Pat<(v2f64 (scalar_to_vector (f64 DPR:$src))),
1928 (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), DPR:$src, dsub_0)>;
1929 def : Pat<(v4f32 (scalar_to_vector SPR:$src)),
1930 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), SPR:$src, ssub_0)>;
1931 def : Pat<(v4f32 (scalar_to_vector GPR:$src)),
1932 (MVE_VMOV_to_lane_32 (v4f32 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
1933 def : Pat<(v8f16 (scalar_to_vector (f16 HPR:$src))),
1934 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), (f16 HPR:$src), ssub_0)>;
1935 def : Pat<(v8f16 (scalar_to_vector GPR:$src)),
1936 (MVE_VMOV_to_lane_16 (v8f16 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>;
1939 // end of mve_bit instructions
1941 // start of MVE Integer instructions
1943 class MVE_int<string iname, string suffix, bits<2> size, list<dag> pattern=[]>
1944 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm), NoItinerary,
1945 iname, suffix, "$Qd, $Qn, $Qm", vpred_r, "", size, pattern> {
1950 let Inst{22} = Qd{3};
1951 let Inst{21-20} = size;
1952 let Inst{19-17} = Qn{2-0};
1953 let Inst{15-13} = Qd{2-0};
1954 let Inst{7} = Qn{3};
1956 let Inst{5} = Qm{3};
1957 let Inst{3-1} = Qm{2-0};
1960 class MVE_VMULt1<string iname, string suffix, bits<2> size,
1961 list<dag> pattern=[]>
1962 : MVE_int<iname, suffix, size, pattern> {
1965 let Inst{25-23} = 0b110;
1967 let Inst{12-8} = 0b01001;
1970 let validForTailPredication = 1;
1973 multiclass MVE_VMUL_m<MVEVectorVTInfo VTI> {
1974 def "" : MVE_VMULt1<"vmul", VTI.Suffix, VTI.Size>;
1976 let Predicates = [HasMVEInt] in {
1977 defm : MVE_TwoOpPattern<VTI, mul, int_arm_mve_mul_predicated, (? ),
1978 !cast<Instruction>(NAME), ARMimmOneV>;
1982 defm MVE_VMULi8 : MVE_VMUL_m<MVE_v16i8>;
1983 defm MVE_VMULi16 : MVE_VMUL_m<MVE_v8i16>;
1984 defm MVE_VMULi32 : MVE_VMUL_m<MVE_v4i32>;
1986 class MVE_VQxDMULH_Base<string iname, string suffix, bits<2> size, bit rounding,
1987 list<dag> pattern=[]>
1988 : MVE_int<iname, suffix, size, pattern> {
1990 let Inst{28} = rounding;
1991 let Inst{25-23} = 0b110;
1993 let Inst{12-8} = 0b01011;
1996 let validForTailPredication = 1;
1999 def MVEvqdmulh : SDNode<"ARMISD::VQDMULH", SDTIntBinOp>;
2001 multiclass MVE_VQxDMULH_m<string iname, MVEVectorVTInfo VTI,
2002 SDPatternOperator Op, Intrinsic unpred_int, Intrinsic pred_int,
2004 def "" : MVE_VQxDMULH_Base<iname, VTI.Suffix, VTI.Size, rounding>;
2005 defvar Inst = !cast<Instruction>(NAME);
2007 let Predicates = [HasMVEInt] in {
2008 defm : MVE_TwoOpPattern<VTI, Op, pred_int, (? ), Inst>;
2010 // Extra unpredicated multiply intrinsic patterns
2011 def : Pat<(VTI.Vec (unpred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn))),
2012 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
2016 multiclass MVE_VQxDMULH<string iname, MVEVectorVTInfo VTI, bit rounding>
2017 : MVE_VQxDMULH_m<iname, VTI, !if(rounding, null_frag,
2019 !if(rounding, int_arm_mve_vqrdmulh,
2020 int_arm_mve_vqdmulh),
2021 !if(rounding, int_arm_mve_qrdmulh_predicated,
2022 int_arm_mve_qdmulh_predicated),
2025 defm MVE_VQDMULHi8 : MVE_VQxDMULH<"vqdmulh", MVE_v16s8, 0b0>;
2026 defm MVE_VQDMULHi16 : MVE_VQxDMULH<"vqdmulh", MVE_v8s16, 0b0>;
2027 defm MVE_VQDMULHi32 : MVE_VQxDMULH<"vqdmulh", MVE_v4s32, 0b0>;
2029 defm MVE_VQRDMULHi8 : MVE_VQxDMULH<"vqrdmulh", MVE_v16s8, 0b1>;
2030 defm MVE_VQRDMULHi16 : MVE_VQxDMULH<"vqrdmulh", MVE_v8s16, 0b1>;
2031 defm MVE_VQRDMULHi32 : MVE_VQxDMULH<"vqrdmulh", MVE_v4s32, 0b1>;
2033 class MVE_VADDSUB<string iname, string suffix, bits<2> size, bit subtract,
2034 list<dag> pattern=[]>
2035 : MVE_int<iname, suffix, size, pattern> {
2037 let Inst{28} = subtract;
2038 let Inst{25-23} = 0b110;
2040 let Inst{12-8} = 0b01000;
2043 let validForTailPredication = 1;
2046 multiclass MVE_VADDSUB_m<string iname, MVEVectorVTInfo VTI, bit subtract,
2047 SDNode Op, Intrinsic PredInt> {
2048 def "" : MVE_VADDSUB<iname, VTI.Suffix, VTI.Size, subtract>;
2049 defvar Inst = !cast<Instruction>(NAME);
2051 let Predicates = [HasMVEInt] in {
2052 defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? ), !cast<Instruction>(NAME), ARMimmAllZerosV>;
2056 multiclass MVE_VADD<MVEVectorVTInfo VTI>
2057 : MVE_VADDSUB_m<"vadd", VTI, 0b0, add, int_arm_mve_add_predicated>;
2058 multiclass MVE_VSUB<MVEVectorVTInfo VTI>
2059 : MVE_VADDSUB_m<"vsub", VTI, 0b1, sub, int_arm_mve_sub_predicated>;
2061 defm MVE_VADDi8 : MVE_VADD<MVE_v16i8>;
2062 defm MVE_VADDi16 : MVE_VADD<MVE_v8i16>;
2063 defm MVE_VADDi32 : MVE_VADD<MVE_v4i32>;
2065 defm MVE_VSUBi8 : MVE_VSUB<MVE_v16i8>;
2066 defm MVE_VSUBi16 : MVE_VSUB<MVE_v8i16>;
2067 defm MVE_VSUBi32 : MVE_VSUB<MVE_v4i32>;
2069 class MVE_VQADDSUB<string iname, string suffix, bit U, bit subtract,
2071 : MVE_int<iname, suffix, size, []> {
2074 let Inst{25-23} = 0b110;
2076 let Inst{12-10} = 0b000;
2077 let Inst{9} = subtract;
2081 let validForTailPredication = 1;
2084 class MVE_VQADD_<string suffix, bit U, bits<2> size>
2085 : MVE_VQADDSUB<"vqadd", suffix, U, 0b0, size>;
2086 class MVE_VQSUB_<string suffix, bit U, bits<2> size>
2087 : MVE_VQADDSUB<"vqsub", suffix, U, 0b1, size>;
2089 multiclass MVE_VQADD_m<MVEVectorVTInfo VTI,
2090 SDNode Op, Intrinsic PredInt> {
2091 def "" : MVE_VQADD_<VTI.Suffix, VTI.Unsigned, VTI.Size>;
2092 defvar Inst = !cast<Instruction>(NAME);
2094 let Predicates = [HasMVEInt] in {
2095 defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? (i32 VTI.Unsigned)),
2096 !cast<Instruction>(NAME)>;
2100 multiclass MVE_VQADD<MVEVectorVTInfo VTI, SDNode unpred_op>
2101 : MVE_VQADD_m<VTI, unpred_op, int_arm_mve_qadd_predicated>;
2103 defm MVE_VQADDs8 : MVE_VQADD<MVE_v16s8, saddsat>;
2104 defm MVE_VQADDs16 : MVE_VQADD<MVE_v8s16, saddsat>;
2105 defm MVE_VQADDs32 : MVE_VQADD<MVE_v4s32, saddsat>;
2106 defm MVE_VQADDu8 : MVE_VQADD<MVE_v16u8, uaddsat>;
2107 defm MVE_VQADDu16 : MVE_VQADD<MVE_v8u16, uaddsat>;
2108 defm MVE_VQADDu32 : MVE_VQADD<MVE_v4u32, uaddsat>;
2110 multiclass MVE_VQSUB_m<MVEVectorVTInfo VTI,
2111 SDNode Op, Intrinsic PredInt> {
2112 def "" : MVE_VQSUB_<VTI.Suffix, VTI.Unsigned, VTI.Size>;
2113 defvar Inst = !cast<Instruction>(NAME);
2115 let Predicates = [HasMVEInt] in {
2116 defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? (i32 VTI.Unsigned)),
2117 !cast<Instruction>(NAME)>;
2121 multiclass MVE_VQSUB<MVEVectorVTInfo VTI, SDNode unpred_op>
2122 : MVE_VQSUB_m<VTI, unpred_op, int_arm_mve_qsub_predicated>;
2124 defm MVE_VQSUBs8 : MVE_VQSUB<MVE_v16s8, ssubsat>;
2125 defm MVE_VQSUBs16 : MVE_VQSUB<MVE_v8s16, ssubsat>;
2126 defm MVE_VQSUBs32 : MVE_VQSUB<MVE_v4s32, ssubsat>;
2127 defm MVE_VQSUBu8 : MVE_VQSUB<MVE_v16u8, usubsat>;
2128 defm MVE_VQSUBu16 : MVE_VQSUB<MVE_v8u16, usubsat>;
2129 defm MVE_VQSUBu32 : MVE_VQSUB<MVE_v4u32, usubsat>;
2131 class MVE_VABD_int<string suffix, bit U, bits<2> size,
2132 list<dag> pattern=[]>
2133 : MVE_int<"vabd", suffix, size, pattern> {
2136 let Inst{25-23} = 0b110;
2138 let Inst{12-8} = 0b00111;
2141 let validForTailPredication = 1;
2144 multiclass MVE_VABD_m<MVEVectorVTInfo VTI, SDNode Op,
2145 Intrinsic unpred_int, Intrinsic PredInt> {
2146 def "" : MVE_VABD_int<VTI.Suffix, VTI.Unsigned, VTI.Size>;
2147 defvar Inst = !cast<Instruction>(NAME);
2149 let Predicates = [HasMVEInt] in {
2150 defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? (i32 VTI.Unsigned)),
2151 !cast<Instruction>(NAME)>;
2153 // Unpredicated absolute difference
2154 def : Pat<(VTI.Vec (unpred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
2155 (i32 VTI.Unsigned))),
2156 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
2160 multiclass MVE_VABD<MVEVectorVTInfo VTI, SDNode Op>
2161 : MVE_VABD_m<VTI, Op, int_arm_mve_vabd, int_arm_mve_abd_predicated>;
2163 defm MVE_VABDs8 : MVE_VABD<MVE_v16s8, abds>;
2164 defm MVE_VABDs16 : MVE_VABD<MVE_v8s16, abds>;
2165 defm MVE_VABDs32 : MVE_VABD<MVE_v4s32, abds>;
2166 defm MVE_VABDu8 : MVE_VABD<MVE_v16u8, abdu>;
2167 defm MVE_VABDu16 : MVE_VABD<MVE_v8u16, abdu>;
2168 defm MVE_VABDu32 : MVE_VABD<MVE_v4u32, abdu>;
2170 class MVE_VRHADD_Base<string suffix, bit U, bits<2> size, list<dag> pattern=[]>
2171 : MVE_int<"vrhadd", suffix, size, pattern> {
2174 let Inst{25-23} = 0b110;
2176 let Inst{12-8} = 0b00001;
2179 let validForTailPredication = 1;
2182 def addnuw : PatFrag<(ops node:$lhs, node:$rhs),
2183 (add node:$lhs, node:$rhs), [{
2184 return N->getFlags().hasNoUnsignedWrap();
2187 def addnsw : PatFrag<(ops node:$lhs, node:$rhs),
2188 (add node:$lhs, node:$rhs), [{
2189 return N->getFlags().hasNoSignedWrap();
2192 def subnuw : PatFrag<(ops node:$lhs, node:$rhs),
2193 (sub node:$lhs, node:$rhs), [{
2194 return N->getFlags().hasNoUnsignedWrap();
2197 def subnsw : PatFrag<(ops node:$lhs, node:$rhs),
2198 (sub node:$lhs, node:$rhs), [{
2199 return N->getFlags().hasNoSignedWrap();
2202 multiclass MVE_VRHADD_m<MVEVectorVTInfo VTI, SDNode Op,
2203 SDPatternOperator unpred_op, Intrinsic PredInt> {
2204 def "" : MVE_VRHADD_Base<VTI.Suffix, VTI.Unsigned, VTI.Size>;
2205 defvar Inst = !cast<Instruction>(NAME);
2206 defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? (i32 VTI.Unsigned)), !cast<Instruction>(NAME)>;
2208 let Predicates = [HasMVEInt] in {
2209 // Unpredicated rounding add-with-divide-by-two intrinsic
2210 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
2211 (i32 VTI.Unsigned))),
2212 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
2216 multiclass MVE_VRHADD<MVEVectorVTInfo VTI, SDNode rhadd>
2217 : MVE_VRHADD_m<VTI, rhadd, int_arm_mve_vrhadd, int_arm_mve_rhadd_predicated>;
2219 defm MVE_VRHADDs8 : MVE_VRHADD<MVE_v16s8, avgceils>;
2220 defm MVE_VRHADDs16 : MVE_VRHADD<MVE_v8s16, avgceils>;
2221 defm MVE_VRHADDs32 : MVE_VRHADD<MVE_v4s32, avgceils>;
2222 defm MVE_VRHADDu8 : MVE_VRHADD<MVE_v16u8, avgceilu>;
2223 defm MVE_VRHADDu16 : MVE_VRHADD<MVE_v8u16, avgceilu>;
2224 defm MVE_VRHADDu32 : MVE_VRHADD<MVE_v4u32, avgceilu>;
2226 class MVE_VHADDSUB<string iname, string suffix, bit U, bit subtract,
2227 bits<2> size, list<dag> pattern=[]>
2228 : MVE_int<iname, suffix, size, pattern> {
2231 let Inst{25-23} = 0b110;
2233 let Inst{12-10} = 0b000;
2234 let Inst{9} = subtract;
2238 let validForTailPredication = 1;
2241 class MVE_VHADD_<string suffix, bit U, bits<2> size,
2242 list<dag> pattern=[]>
2243 : MVE_VHADDSUB<"vhadd", suffix, U, 0b0, size, pattern>;
2244 class MVE_VHSUB_<string suffix, bit U, bits<2> size,
2245 list<dag> pattern=[]>
2246 : MVE_VHADDSUB<"vhsub", suffix, U, 0b1, size, pattern>;
2248 multiclass MVE_VHADD_m<MVEVectorVTInfo VTI, SDNode Op,
2249 SDPatternOperator unpred_op, Intrinsic PredInt> {
2250 def "" : MVE_VHADD_<VTI.Suffix, VTI.Unsigned, VTI.Size>;
2251 defvar Inst = !cast<Instruction>(NAME);
2252 defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? (i32 VTI.Unsigned)), !cast<Instruction>(NAME)>;
2254 let Predicates = [HasMVEInt] in {
2255 // Unpredicated add-and-divide-by-two
2256 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), (i32 VTI.Unsigned))),
2257 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
2261 multiclass MVE_VHADD<MVEVectorVTInfo VTI, SDNode Op>
2262 : MVE_VHADD_m<VTI, Op, int_arm_mve_vhadd, int_arm_mve_hadd_predicated>;
2264 defm MVE_VHADDs8 : MVE_VHADD<MVE_v16s8, avgfloors>;
2265 defm MVE_VHADDs16 : MVE_VHADD<MVE_v8s16, avgfloors>;
2266 defm MVE_VHADDs32 : MVE_VHADD<MVE_v4s32, avgfloors>;
2267 defm MVE_VHADDu8 : MVE_VHADD<MVE_v16u8, avgflooru>;
2268 defm MVE_VHADDu16 : MVE_VHADD<MVE_v8u16, avgflooru>;
2269 defm MVE_VHADDu32 : MVE_VHADD<MVE_v4u32, avgflooru>;
2271 multiclass MVE_VHSUB_m<MVEVectorVTInfo VTI,
2272 SDPatternOperator unpred_op, Intrinsic pred_int, PatFrag sub_op,
2274 def "" : MVE_VHSUB_<VTI.Suffix, VTI.Unsigned, VTI.Size>;
2275 defvar Inst = !cast<Instruction>(NAME);
2277 let Predicates = [HasMVEInt] in {
2278 // Unpredicated subtract-and-divide-by-two
2279 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
2280 (i32 VTI.Unsigned))),
2281 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
2283 def : Pat<(VTI.Vec (shift_op (sub_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)), (i32 1))),
2284 (Inst MQPR:$Qm, MQPR:$Qn)>;
2287 // Predicated subtract-and-divide-by-two
2288 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
2289 (i32 VTI.Unsigned), (VTI.Pred VCCR:$mask),
2290 (VTI.Vec MQPR:$inactive))),
2291 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
2292 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
2293 (VTI.Vec MQPR:$inactive)))>;
2297 multiclass MVE_VHSUB<MVEVectorVTInfo VTI, PatFrag sub_op, SDNode shift_op>
2298 : MVE_VHSUB_m<VTI, int_arm_mve_vhsub, int_arm_mve_hsub_predicated, sub_op,
2301 defm MVE_VHSUBs8 : MVE_VHSUB<MVE_v16s8, subnsw, ARMvshrsImm>;
2302 defm MVE_VHSUBs16 : MVE_VHSUB<MVE_v8s16, subnsw, ARMvshrsImm>;
2303 defm MVE_VHSUBs32 : MVE_VHSUB<MVE_v4s32, subnsw, ARMvshrsImm>;
2304 defm MVE_VHSUBu8 : MVE_VHSUB<MVE_v16u8, subnuw, ARMvshruImm>;
2305 defm MVE_VHSUBu16 : MVE_VHSUB<MVE_v8u16, subnuw, ARMvshruImm>;
2306 defm MVE_VHSUBu32 : MVE_VHSUB<MVE_v4u32, subnuw, ARMvshruImm>;
2308 class MVE_VDUP<string suffix, bit B, bit E, bits<2> vecsize, list<dag> pattern=[]>
2309 : MVE_p<(outs MQPR:$Qd), (ins rGPR:$Rt), NoItinerary,
2310 "vdup", suffix, "$Qd, $Rt", vpred_r, "", vecsize, pattern> {
2315 let Inst{25-23} = 0b101;
2317 let Inst{21-20} = 0b10;
2318 let Inst{19-17} = Qd{2-0};
2320 let Inst{15-12} = Rt;
2321 let Inst{11-8} = 0b1011;
2322 let Inst{7} = Qd{3};
2325 let Inst{4-0} = 0b10000;
2326 let validForTailPredication = 1;
2329 def MVE_VDUP32 : MVE_VDUP<"32", 0b0, 0b0, 0b10>;
2330 def MVE_VDUP16 : MVE_VDUP<"16", 0b0, 0b1, 0b01>;
2331 def MVE_VDUP8 : MVE_VDUP<"8", 0b1, 0b0, 0b00>;
2333 let Predicates = [HasMVEInt] in {
2334 def : Pat<(v16i8 (ARMvdup (i32 rGPR:$elem))),
2335 (MVE_VDUP8 rGPR:$elem)>;
2336 def : Pat<(v8i16 (ARMvdup (i32 rGPR:$elem))),
2337 (MVE_VDUP16 rGPR:$elem)>;
2338 def : Pat<(v4i32 (ARMvdup (i32 rGPR:$elem))),
2339 (MVE_VDUP32 rGPR:$elem)>;
2341 def : Pat<(v8f16 (ARMvdup (i32 rGPR:$elem))),
2342 (MVE_VDUP16 rGPR:$elem)>;
2343 def : Pat<(v4f32 (ARMvdup (i32 rGPR:$elem))),
2344 (MVE_VDUP32 rGPR:$elem)>;
2346 // Match a vselect with an ARMvdup as a predicated MVE_VDUP
2347 def : Pat<(v16i8 (vselect (v16i1 VCCR:$pred),
2348 (v16i8 (ARMvdup (i32 rGPR:$elem))),
2349 (v16i8 MQPR:$inactive))),
2350 (MVE_VDUP8 rGPR:$elem, ARMVCCThen, (v16i1 VCCR:$pred), zero_reg,
2351 (v16i8 MQPR:$inactive))>;
2352 def : Pat<(v8i16 (vselect (v8i1 VCCR:$pred),
2353 (v8i16 (ARMvdup (i32 rGPR:$elem))),
2354 (v8i16 MQPR:$inactive))),
2355 (MVE_VDUP16 rGPR:$elem, ARMVCCThen, (v8i1 VCCR:$pred), zero_reg,
2356 (v8i16 MQPR:$inactive))>;
2357 def : Pat<(v4i32 (vselect (v4i1 VCCR:$pred),
2358 (v4i32 (ARMvdup (i32 rGPR:$elem))),
2359 (v4i32 MQPR:$inactive))),
2360 (MVE_VDUP32 rGPR:$elem, ARMVCCThen, (v4i1 VCCR:$pred), zero_reg,
2361 (v4i32 MQPR:$inactive))>;
2362 def : Pat<(v4f32 (vselect (v4i1 VCCR:$pred),
2363 (v4f32 (ARMvdup (i32 rGPR:$elem))),
2364 (v4f32 MQPR:$inactive))),
2365 (MVE_VDUP32 rGPR:$elem, ARMVCCThen, (v4i1 VCCR:$pred), zero_reg,
2366 (v4f32 MQPR:$inactive))>;
2367 def : Pat<(v8f16 (vselect (v8i1 VCCR:$pred),
2368 (v8f16 (ARMvdup (i32 rGPR:$elem))),
2369 (v8f16 MQPR:$inactive))),
2370 (MVE_VDUP16 rGPR:$elem, ARMVCCThen, (v8i1 VCCR:$pred), zero_reg,
2371 (v8f16 MQPR:$inactive))>;
2375 class MVEIntSingleSrc<string iname, string suffix, bits<2> size,
2376 list<dag> pattern=[]>
2377 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qm), NoItinerary,
2378 iname, suffix, "$Qd, $Qm", vpred_r, "", size, pattern> {
2382 let Inst{22} = Qd{3};
2383 let Inst{19-18} = size{1-0};
2384 let Inst{15-13} = Qd{2-0};
2385 let Inst{5} = Qm{3};
2386 let Inst{3-1} = Qm{2-0};
2389 class MVE_VCLSCLZ<string iname, string suffix, bits<2> size,
2390 bit count_zeroes, list<dag> pattern=[]>
2391 : MVEIntSingleSrc<iname, suffix, size, pattern> {
2394 let Inst{25-23} = 0b111;
2395 let Inst{21-20} = 0b11;
2396 let Inst{17-16} = 0b00;
2397 let Inst{12-8} = 0b00100;
2398 let Inst{7} = count_zeroes;
2402 let validForTailPredication = 1;
2405 multiclass MVE_VCLSCLZ_p<string opname, bit opcode, MVEVectorVTInfo VTI,
2406 SDPatternOperator unpred_op> {
2407 def "": MVE_VCLSCLZ<"v"#opname, VTI.Suffix, VTI.Size, opcode>;
2409 defvar Inst = !cast<Instruction>(NAME);
2410 defvar pred_int = !cast<Intrinsic>("int_arm_mve_"#opname#"_predicated");
2412 let Predicates = [HasMVEInt] in {
2413 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$val))),
2414 (VTI.Vec (Inst (VTI.Vec MQPR:$val)))>;
2415 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$val), (VTI.Pred VCCR:$pred),
2416 (VTI.Vec MQPR:$inactive))),
2417 (VTI.Vec (Inst (VTI.Vec MQPR:$val), ARMVCCThen,
2418 (VTI.Pred VCCR:$pred), zero_reg, (VTI.Vec MQPR:$inactive)))>;
2422 defm MVE_VCLSs8 : MVE_VCLSCLZ_p<"cls", 0, MVE_v16s8, int_arm_mve_vcls>;
2423 defm MVE_VCLSs16 : MVE_VCLSCLZ_p<"cls", 0, MVE_v8s16, int_arm_mve_vcls>;
2424 defm MVE_VCLSs32 : MVE_VCLSCLZ_p<"cls", 0, MVE_v4s32, int_arm_mve_vcls>;
2426 defm MVE_VCLZs8 : MVE_VCLSCLZ_p<"clz", 1, MVE_v16i8, ctlz>;
2427 defm MVE_VCLZs16 : MVE_VCLSCLZ_p<"clz", 1, MVE_v8i16, ctlz>;
2428 defm MVE_VCLZs32 : MVE_VCLSCLZ_p<"clz", 1, MVE_v4i32, ctlz>;
2430 class MVE_VABSNEG_int<string iname, string suffix, bits<2> size, bit negate,
2431 bit saturate, list<dag> pattern=[]>
2432 : MVEIntSingleSrc<iname, suffix, size, pattern> {
2435 let Inst{25-23} = 0b111;
2436 let Inst{21-20} = 0b11;
2438 let Inst{16} = !eq(saturate, 0);
2439 let Inst{12-11} = 0b00;
2440 let Inst{10} = saturate;
2441 let Inst{9-8} = 0b11;
2442 let Inst{7} = negate;
2446 let validForTailPredication = 1;
2449 multiclass MVE_VABSNEG_int_m<string iname, bit negate, bit saturate,
2450 SDPatternOperator unpred_op, Intrinsic pred_int,
2451 MVEVectorVTInfo VTI> {
2452 def "" : MVE_VABSNEG_int<iname, VTI.Suffix, VTI.Size, negate, saturate>;
2453 defvar Inst = !cast<Instruction>(NAME);
2455 let Predicates = [HasMVEInt] in {
2456 // VQABS and VQNEG have more difficult isel patterns defined elsewhere
2457 if !not(saturate) then {
2458 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$v))),
2459 (VTI.Vec (Inst $v))>;
2462 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$v), (VTI.Pred VCCR:$mask),
2463 (VTI.Vec MQPR:$inactive))),
2464 (VTI.Vec (Inst $v, ARMVCCThen, $mask, zero_reg, $inactive))>;
2468 foreach VTI = [ MVE_v16s8, MVE_v8s16, MVE_v4s32 ] in {
2469 defm "MVE_VABS" # VTI.Suffix : MVE_VABSNEG_int_m<
2470 "vabs", 0, 0, abs, int_arm_mve_abs_predicated, VTI>;
2471 defm "MVE_VQABS" # VTI.Suffix : MVE_VABSNEG_int_m<
2472 "vqabs", 0, 1, ?, int_arm_mve_qabs_predicated, VTI>;
2473 defm "MVE_VNEG" # VTI.Suffix : MVE_VABSNEG_int_m<
2474 "vneg", 1, 0, vnegq, int_arm_mve_neg_predicated, VTI>;
2475 defm "MVE_VQNEG" # VTI.Suffix : MVE_VABSNEG_int_m<
2476 "vqneg", 1, 1, ?, int_arm_mve_qneg_predicated, VTI>;
2479 // int_min/int_max: vector containing INT_MIN/INT_MAX VTI.Size times
2480 // zero_vec: v4i32-initialized zero vector, potentially wrapped in a bitconvert
2481 multiclass vqabsneg_pattern<MVEVectorVTInfo VTI, dag int_min, dag int_max,
2482 dag zero_vec, MVE_VABSNEG_int vqabs_instruction,
2483 MVE_VABSNEG_int vqneg_instruction> {
2484 let Predicates = [HasMVEInt] in {
2485 // The below tree can be replaced by a vqabs instruction, as it represents
2486 // the following vectorized expression (r being the value in $reg):
2487 // r > 0 ? r : (r == INT_MIN ? INT_MAX : -r)
2488 def : Pat<(VTI.Vec (vselect
2489 (VTI.Pred (ARMvcmpz (VTI.Vec MQPR:$reg), ARMCCgt)),
2490 (VTI.Vec MQPR:$reg),
2492 (VTI.Pred (ARMvcmp (VTI.Vec MQPR:$reg), int_min, ARMCCeq)),
2494 (sub (VTI.Vec zero_vec), (VTI.Vec MQPR:$reg)))))),
2495 (VTI.Vec (vqabs_instruction (VTI.Vec MQPR:$reg)))>;
2496 // Similarly, this tree represents vqneg, i.e. the following vectorized expression:
2497 // r == INT_MIN ? INT_MAX : -r
2498 def : Pat<(VTI.Vec (vselect
2499 (VTI.Pred (ARMvcmp (VTI.Vec MQPR:$reg), int_min, ARMCCeq)),
2501 (sub (VTI.Vec zero_vec), (VTI.Vec MQPR:$reg)))),
2502 (VTI.Vec (vqneg_instruction (VTI.Vec MQPR:$reg)))>;
2506 defm MVE_VQABSNEG_Ps8 : vqabsneg_pattern<MVE_v16i8,
2507 (v16i8 (ARMvmovImm (i32 3712))),
2508 (v16i8 (ARMvmovImm (i32 3711))),
2509 (bitconvert (v4i32 (ARMvmovImm (i32 0)))),
2510 MVE_VQABSs8, MVE_VQNEGs8>;
2511 defm MVE_VQABSNEG_Ps16 : vqabsneg_pattern<MVE_v8i16,
2512 (v8i16 (ARMvmovImm (i32 2688))),
2513 (v8i16 (ARMvmvnImm (i32 2688))),
2514 (bitconvert (v4i32 (ARMvmovImm (i32 0)))),
2515 MVE_VQABSs16, MVE_VQNEGs16>;
2516 defm MVE_VQABSNEG_Ps32 : vqabsneg_pattern<MVE_v4i32,
2517 (v4i32 (ARMvmovImm (i32 1664))),
2518 (v4i32 (ARMvmvnImm (i32 1664))),
2519 (ARMvmovImm (i32 0)),
2520 MVE_VQABSs32, MVE_VQNEGs32>;
2522 class MVE_mod_imm<string iname, string suffix, bits<4> cmode, bit op,
2523 dag iops, bits<2> vecsize, list<dag> pattern=[]>
2524 : MVE_p<(outs MQPR:$Qd), iops, NoItinerary, iname, suffix, "$Qd, $imm",
2525 vpred_r, "", vecsize, pattern> {
2529 let Inst{28} = imm{7};
2530 let Inst{25-23} = 0b111;
2531 let Inst{22} = Qd{3};
2532 let Inst{21-19} = 0b000;
2533 let Inst{18-16} = imm{6-4};
2534 let Inst{15-13} = Qd{2-0};
2536 let Inst{11-8} = cmode{3-0};
2537 let Inst{7-6} = 0b01;
2540 let Inst{3-0} = imm{3-0};
2542 let DecoderMethod = "DecodeMVEModImmInstruction";
2543 let validForTailPredication = 1;
2546 let isReMaterializable = 1 in {
2547 let isAsCheapAsAMove = 1 in {
2548 def MVE_VMOVimmi8 : MVE_mod_imm<"vmov", "i8", {1,1,1,0}, 0b0, (ins nImmSplatI8:$imm), 0b00>;
2549 def MVE_VMOVimmi16 : MVE_mod_imm<"vmov", "i16", {1,0,?,0}, 0b0, (ins nImmSplatI16:$imm), 0b01> {
2550 let Inst{9} = imm{9};
2552 def MVE_VMOVimmi32 : MVE_mod_imm<"vmov", "i32", {?,?,?,?}, 0b0, (ins nImmVMOVI32:$imm), 0b10> {
2553 let Inst{11-8} = imm{11-8};
2555 def MVE_VMOVimmi64 : MVE_mod_imm<"vmov", "i64", {1,1,1,0}, 0b1, (ins nImmSplatI64:$imm), 0b11>;
2556 def MVE_VMOVimmf32 : MVE_mod_imm<"vmov", "f32", {1,1,1,1}, 0b0, (ins nImmVMOVF32:$imm), 0b10>;
2557 } // let isAsCheapAsAMove = 1
2559 def MVE_VMVNimmi16 : MVE_mod_imm<"vmvn", "i16", {1,0,?,0}, 0b1, (ins nImmSplatI16:$imm), 0b01> {
2560 let Inst{9} = imm{9};
2562 def MVE_VMVNimmi32 : MVE_mod_imm<"vmvn", "i32", {?,?,?,?}, 0b1, (ins nImmVMOVI32:$imm), 0b10> {
2563 let Inst{11-8} = imm{11-8};
2565 } // let isReMaterializable = 1
2567 let Predicates = [HasMVEInt] in {
2568 def : Pat<(v16i8 (ARMvmovImm timm:$simm)),
2569 (v16i8 (MVE_VMOVimmi8 nImmSplatI8:$simm))>;
2570 def : Pat<(v8i16 (ARMvmovImm timm:$simm)),
2571 (v8i16 (MVE_VMOVimmi16 nImmSplatI16:$simm))>;
2572 def : Pat<(v4i32 (ARMvmovImm timm:$simm)),
2573 (v4i32 (MVE_VMOVimmi32 nImmVMOVI32:$simm))>;
2574 def : Pat<(v2i64 (ARMvmovImm timm:$simm)),
2575 (v2i64 (MVE_VMOVimmi64 nImmSplatI64:$simm))>;
2577 def : Pat<(v8i16 (ARMvmvnImm timm:$simm)),
2578 (v8i16 (MVE_VMVNimmi16 nImmSplatI16:$simm))>;
2579 def : Pat<(v4i32 (ARMvmvnImm timm:$simm)),
2580 (v4i32 (MVE_VMVNimmi32 nImmVMOVI32:$simm))>;
2582 def : Pat<(v4f32 (ARMvmovFPImm timm:$simm)),
2583 (v4f32 (MVE_VMOVimmf32 nImmVMOVF32:$simm))>;
2585 def : Pat<(v8i16 (vselect (v8i1 VCCR:$pred), (ARMvmvnImm timm:$simm),
2587 (v8i16 (MVE_VMVNimmi16 nImmSplatI16:$simm,
2588 ARMVCCThen, VCCR:$pred, zero_reg, MQPR:$inactive))>;
2589 def : Pat<(v4i32 (vselect (v4i1 VCCR:$pred), (ARMvmvnImm timm:$simm),
2591 (v4i32 (MVE_VMVNimmi32 nImmSplatI32:$simm,
2592 ARMVCCThen, VCCR:$pred, zero_reg, MQPR:$inactive))>;
2595 class MVE_VMINMAXA<string iname, string suffix, bits<2> size,
2596 bit bit_12, list<dag> pattern=[]>
2597 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qd_src, MQPR:$Qm),
2598 NoItinerary, iname, suffix, "$Qd, $Qm", vpred_n, "$Qd = $Qd_src",
2604 let Inst{25-23} = 0b100;
2605 let Inst{22} = Qd{3};
2606 let Inst{21-20} = 0b11;
2607 let Inst{19-18} = size;
2608 let Inst{17-16} = 0b11;
2609 let Inst{15-13} = Qd{2-0};
2610 let Inst{12} = bit_12;
2611 let Inst{11-6} = 0b111010;
2612 let Inst{5} = Qm{3};
2614 let Inst{3-1} = Qm{2-0};
2616 let validForTailPredication = 1;
2619 multiclass MVE_VMINMAXA_m<string iname, MVEVectorVTInfo VTI,
2620 SDNode unpred_op, Intrinsic pred_int, bit bit_12> {
2621 def "" : MVE_VMINMAXA<iname, VTI.Suffix, VTI.Size, bit_12>;
2622 defvar Inst = !cast<Instruction>(NAME);
2624 let Predicates = [HasMVEInt] in {
2625 // Unpredicated v(min|max)a
2626 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qd), (abs (VTI.Vec MQPR:$Qm)))),
2627 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm)))>;
2629 // Predicated v(min|max)a
2630 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm),
2631 (VTI.Pred VCCR:$mask))),
2632 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm),
2633 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>;
2637 multiclass MVE_VMINA<MVEVectorVTInfo VTI>
2638 : MVE_VMINMAXA_m<"vmina", VTI, umin, int_arm_mve_vmina_predicated, 0b1>;
2640 defm MVE_VMINAs8 : MVE_VMINA<MVE_v16s8>;
2641 defm MVE_VMINAs16 : MVE_VMINA<MVE_v8s16>;
2642 defm MVE_VMINAs32 : MVE_VMINA<MVE_v4s32>;
2644 multiclass MVE_VMAXA<MVEVectorVTInfo VTI>
2645 : MVE_VMINMAXA_m<"vmaxa", VTI, umax, int_arm_mve_vmaxa_predicated, 0b0>;
2647 defm MVE_VMAXAs8 : MVE_VMAXA<MVE_v16s8>;
2648 defm MVE_VMAXAs16 : MVE_VMAXA<MVE_v8s16>;
2649 defm MVE_VMAXAs32 : MVE_VMAXA<MVE_v4s32>;
2651 // end of MVE Integer instructions
2653 // start of mve_imm_shift instructions
2655 def MVE_VSHLC : MVE_p<(outs rGPR:$RdmDest, MQPR:$Qd),
2656 (ins MQPR:$QdSrc, rGPR:$RdmSrc, long_shift:$imm),
2657 NoItinerary, "vshlc", "", "$QdSrc, $RdmSrc, $imm",
2658 vpred_n, "$RdmDest = $RdmSrc,$Qd = $QdSrc", 0b10> {
2664 let Inst{25-23} = 0b101;
2665 let Inst{22} = Qd{3};
2667 let Inst{20-16} = imm{4-0};
2668 let Inst{15-13} = Qd{2-0};
2669 let Inst{12-4} = 0b011111100;
2670 let Inst{3-0} = RdmDest{3-0};
2673 class MVE_shift_imm<dag oops, dag iops, string iname, string suffix,
2674 string ops, vpred_ops vpred, string cstr,
2675 bits<2> vecsize, list<dag> pattern=[]>
2676 : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, vecsize, pattern> {
2680 let Inst{22} = Qd{3};
2681 let Inst{15-13} = Qd{2-0};
2682 let Inst{5} = Qm{3};
2683 let Inst{3-1} = Qm{2-0};
2686 class MVE_VMOVL<string iname, string suffix, bits<2> sz, bit U, bit top,
2687 list<dag> pattern=[]>
2688 : MVE_shift_imm<(outs MQPR:$Qd), (ins MQPR:$Qm),
2689 iname, suffix, "$Qd, $Qm", vpred_r, "",
2692 let Inst{25-23} = 0b101;
2694 let Inst{20-19} = sz{1-0};
2695 let Inst{18-16} = 0b000;
2697 let Inst{11-6} = 0b111101;
2700 let doubleWidthResult = 1;
2703 multiclass MVE_VMOVL_m<bit top, string chr, MVEVectorVTInfo OutVTI,
2704 MVEVectorVTInfo InVTI> {
2705 def "": MVE_VMOVL<"vmovl" # chr, InVTI.Suffix, OutVTI.Size,
2706 InVTI.Unsigned, top>;
2707 defvar Inst = !cast<Instruction>(NAME);
2709 def : Pat<(OutVTI.Vec (int_arm_mve_vmovl_predicated (InVTI.Vec MQPR:$src),
2710 (i32 InVTI.Unsigned), (i32 top),
2711 (OutVTI.Pred VCCR:$pred),
2712 (OutVTI.Vec MQPR:$inactive))),
2713 (OutVTI.Vec (Inst (InVTI.Vec MQPR:$src), ARMVCCThen,
2714 (OutVTI.Pred VCCR:$pred), zero_reg,
2715 (OutVTI.Vec MQPR:$inactive)))>;
2718 defm MVE_VMOVLs8bh : MVE_VMOVL_m<0, "b", MVE_v8s16, MVE_v16s8>;
2719 defm MVE_VMOVLs8th : MVE_VMOVL_m<1, "t", MVE_v8s16, MVE_v16s8>;
2720 defm MVE_VMOVLu8bh : MVE_VMOVL_m<0, "b", MVE_v8u16, MVE_v16u8>;
2721 defm MVE_VMOVLu8th : MVE_VMOVL_m<1, "t", MVE_v8u16, MVE_v16u8>;
2722 defm MVE_VMOVLs16bh : MVE_VMOVL_m<0, "b", MVE_v4s32, MVE_v8s16>;
2723 defm MVE_VMOVLs16th : MVE_VMOVL_m<1, "t", MVE_v4s32, MVE_v8s16>;
2724 defm MVE_VMOVLu16bh : MVE_VMOVL_m<0, "b", MVE_v4s32, MVE_v8u16>;
2725 defm MVE_VMOVLu16th : MVE_VMOVL_m<1, "t", MVE_v4s32, MVE_v8u16>;
2727 let Predicates = [HasMVEInt] in {
2728 def : Pat<(sext_inreg (v4i32 MQPR:$src), v4i16),
2729 (MVE_VMOVLs16bh MQPR:$src)>;
2730 def : Pat<(sext_inreg (v8i16 MQPR:$src), v8i8),
2731 (MVE_VMOVLs8bh MQPR:$src)>;
2732 def : Pat<(sext_inreg (v4i32 MQPR:$src), v4i8),
2733 (MVE_VMOVLs16bh (MVE_VMOVLs8bh MQPR:$src))>;
2735 def : Pat<(sext_inreg (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src)))), v8i8),
2736 (MVE_VMOVLs8th MQPR:$src)>;
2737 def : Pat<(sext_inreg (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src)))), v4i16),
2738 (MVE_VMOVLs16th MQPR:$src)>;
2740 // zext_inreg 8 -> 16
2741 def : Pat<(ARMvbicImm (v8i16 MQPR:$src), (i32 0xAFF)),
2742 (MVE_VMOVLu8bh MQPR:$src)>;
2743 // zext_inreg 16 -> 32
2744 def : Pat<(and (v4i32 MQPR:$src), (v4i32 (ARMvmovImm (i32 0xCFF)))),
2745 (MVE_VMOVLu16bh MQPR:$src)>;
2746 // Same zext_inreg with vrevs, picking the top half
2747 def : Pat<(ARMvbicImm (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src)))), (i32 0xAFF)),
2748 (MVE_VMOVLu8th MQPR:$src)>;
2749 def : Pat<(and (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src)))),
2750 (v4i32 (ARMvmovImm (i32 0xCFF)))),
2751 (MVE_VMOVLu16th MQPR:$src)>;
2755 class MVE_VSHLL_imm<string iname, string suffix, bit U, bit th,
2756 Operand immtype, bits<2> vecsize, list<dag> pattern=[]>
2757 : MVE_shift_imm<(outs MQPR:$Qd), (ins MQPR:$Qm, immtype:$imm),
2758 iname, suffix, "$Qd, $Qm, $imm", vpred_r, "", vecsize, pattern> {
2760 let Inst{25-23} = 0b101;
2763 let Inst{11-6} = 0b111101;
2767 // For the MVE_VSHLL_patterns multiclass to refer to
2768 Operand immediateType = immtype;
2770 let doubleWidthResult = 1;
2773 // The immediate VSHLL instructions accept shift counts from 1 up to
2774 // the lane width (8 or 16), but the full-width shifts have an
2775 // entirely separate encoding, given below with 'lw' in the name.
2777 class MVE_VSHLL_imm8<string iname, string suffix,
2778 bit U, bit th, list<dag> pattern=[]>
2779 : MVE_VSHLL_imm<iname, suffix, U, th, mve_shift_imm1_7, 0b01, pattern> {
2781 let Inst{20-19} = 0b01;
2782 let Inst{18-16} = imm;
2785 class MVE_VSHLL_imm16<string iname, string suffix,
2786 bit U, bit th, list<dag> pattern=[]>
2787 : MVE_VSHLL_imm<iname, suffix, U, th, mve_shift_imm1_15, 0b10, pattern> {
2790 let Inst{19-16} = imm;
2793 def MVE_VSHLL_imms8bh : MVE_VSHLL_imm8 <"vshllb", "s8", 0b0, 0b0>;
2794 def MVE_VSHLL_imms8th : MVE_VSHLL_imm8 <"vshllt", "s8", 0b0, 0b1>;
2795 def MVE_VSHLL_immu8bh : MVE_VSHLL_imm8 <"vshllb", "u8", 0b1, 0b0>;
2796 def MVE_VSHLL_immu8th : MVE_VSHLL_imm8 <"vshllt", "u8", 0b1, 0b1>;
2797 def MVE_VSHLL_imms16bh : MVE_VSHLL_imm16<"vshllb", "s16", 0b0, 0b0>;
2798 def MVE_VSHLL_imms16th : MVE_VSHLL_imm16<"vshllt", "s16", 0b0, 0b1>;
2799 def MVE_VSHLL_immu16bh : MVE_VSHLL_imm16<"vshllb", "u16", 0b1, 0b0>;
2800 def MVE_VSHLL_immu16th : MVE_VSHLL_imm16<"vshllt", "u16", 0b1, 0b1>;
2802 class MVE_VSHLL_by_lane_width<string iname, string suffix, bits<2> size,
2803 bit U, string ops, list<dag> pattern=[]>
2804 : MVE_shift_imm<(outs MQPR:$Qd), (ins MQPR:$Qm),
2805 iname, suffix, ops, vpred_r, "", !if(size, 0b10, 0b01), pattern> {
2807 let Inst{25-23} = 0b100;
2808 let Inst{21-20} = 0b11;
2809 let Inst{19-18} = size{1-0};
2810 let Inst{17-16} = 0b01;
2811 let Inst{11-6} = 0b111000;
2814 let doubleWidthResult = 1;
2817 multiclass MVE_VSHLL_lw<string iname, string suffix, bits<2> sz, bit U,
2818 string ops, list<dag> pattern=[]> {
2819 def bh : MVE_VSHLL_by_lane_width<iname#"b", suffix, sz, U, ops, pattern> {
2822 def th : MVE_VSHLL_by_lane_width<iname#"t", suffix, sz, U, ops, pattern> {
2827 defm MVE_VSHLL_lws8 : MVE_VSHLL_lw<"vshll", "s8", 0b00, 0b0, "$Qd, $Qm, #8">;
2828 defm MVE_VSHLL_lws16 : MVE_VSHLL_lw<"vshll", "s16", 0b01, 0b0, "$Qd, $Qm, #16">;
2829 defm MVE_VSHLL_lwu8 : MVE_VSHLL_lw<"vshll", "u8", 0b00, 0b1, "$Qd, $Qm, #8">;
2830 defm MVE_VSHLL_lwu16 : MVE_VSHLL_lw<"vshll", "u16", 0b01, 0b1, "$Qd, $Qm, #16">;
2832 multiclass MVE_VSHLL_patterns<MVEVectorVTInfo VTI, int top> {
2833 defvar suffix = !strconcat(VTI.Suffix, !if(top, "th", "bh"));
2834 defvar inst_imm = !cast<MVE_VSHLL_imm>("MVE_VSHLL_imm" # suffix);
2835 defvar inst_lw = !cast<MVE_VSHLL_by_lane_width>("MVE_VSHLL_lw" # suffix);
2836 defvar unpred_int = int_arm_mve_vshll_imm;
2837 defvar pred_int = int_arm_mve_vshll_imm_predicated;
2838 defvar imm = inst_imm.immediateType;
2840 def : Pat<(VTI.DblVec (unpred_int (VTI.Vec MQPR:$src), imm:$imm,
2841 (i32 VTI.Unsigned), (i32 top))),
2842 (VTI.DblVec (inst_imm (VTI.Vec MQPR:$src), imm:$imm))>;
2843 def : Pat<(VTI.DblVec (unpred_int (VTI.Vec MQPR:$src), (i32 VTI.LaneBits),
2844 (i32 VTI.Unsigned), (i32 top))),
2845 (VTI.DblVec (inst_lw (VTI.Vec MQPR:$src)))>;
2847 def : Pat<(VTI.DblVec (pred_int (VTI.Vec MQPR:$src), imm:$imm,
2848 (i32 VTI.Unsigned), (i32 top),
2849 (VTI.DblPred VCCR:$mask),
2850 (VTI.DblVec MQPR:$inactive))),
2851 (VTI.DblVec (inst_imm (VTI.Vec MQPR:$src), imm:$imm,
2852 ARMVCCThen, (VTI.DblPred VCCR:$mask), zero_reg,
2853 (VTI.DblVec MQPR:$inactive)))>;
2854 def : Pat<(VTI.DblVec (pred_int (VTI.Vec MQPR:$src), (i32 VTI.LaneBits),
2855 (i32 VTI.Unsigned), (i32 top),
2856 (VTI.DblPred VCCR:$mask),
2857 (VTI.DblVec MQPR:$inactive))),
2858 (VTI.DblVec (inst_lw (VTI.Vec MQPR:$src), ARMVCCThen,
2859 (VTI.DblPred VCCR:$mask), zero_reg,
2860 (VTI.DblVec MQPR:$inactive)))>;
2863 foreach VTI = [MVE_v16s8, MVE_v8s16, MVE_v16u8, MVE_v8u16] in
2864 foreach top = [0, 1] in
2865 defm : MVE_VSHLL_patterns<VTI, top>;
2867 class MVE_shift_imm_partial<Operand imm, string iname, string suffix, bits<2> vecsize>
2868 : MVE_shift_imm<(outs MQPR:$Qd), (ins MQPR:$QdSrc, MQPR:$Qm, imm:$imm),
2869 iname, suffix, "$Qd, $Qm, $imm", vpred_n, "$Qd = $QdSrc", vecsize> {
2870 Operand immediateType = imm;
2873 class MVE_VxSHRN<string iname, string suffix, bit bit_12, bit bit_28,
2874 Operand imm, bits<2> vecsize>
2875 : MVE_shift_imm_partial<imm, iname, suffix, vecsize> {
2878 let Inst{28} = bit_28;
2879 let Inst{25-23} = 0b101;
2881 let Inst{20-16} = imm{4-0};
2882 let Inst{12} = bit_12;
2883 let Inst{11-6} = 0b111111;
2886 let validForTailPredication = 1;
2887 let retainsPreviousHalfElement = 1;
2890 def MVE_VRSHRNi16bh : MVE_VxSHRN<"vrshrnb", "i16", 0b0, 0b1, shr_imm8, 0b01> {
2891 let Inst{20-19} = 0b01;
2893 def MVE_VRSHRNi16th : MVE_VxSHRN<"vrshrnt", "i16", 0b1, 0b1, shr_imm8, 0b01> {
2894 let Inst{20-19} = 0b01;
2896 def MVE_VRSHRNi32bh : MVE_VxSHRN<"vrshrnb", "i32", 0b0, 0b1, shr_imm16, 0b10> {
2899 def MVE_VRSHRNi32th : MVE_VxSHRN<"vrshrnt", "i32", 0b1, 0b1, shr_imm16, 0b10> {
2903 def MVE_VSHRNi16bh : MVE_VxSHRN<"vshrnb", "i16", 0b0, 0b0, shr_imm8, 0b01> {
2904 let Inst{20-19} = 0b01;
2906 def MVE_VSHRNi16th : MVE_VxSHRN<"vshrnt", "i16", 0b1, 0b0, shr_imm8, 0b01> {
2907 let Inst{20-19} = 0b01;
2909 def MVE_VSHRNi32bh : MVE_VxSHRN<"vshrnb", "i32", 0b0, 0b0, shr_imm16, 0b10> {
2912 def MVE_VSHRNi32th : MVE_VxSHRN<"vshrnt", "i32", 0b1, 0b0, shr_imm16, 0b10> {
2916 class MVE_VxQRSHRUN<string iname, string suffix, bit bit_28, bit bit_12,
2917 Operand imm, bits<2> vecsize>
2918 : MVE_shift_imm_partial<imm, iname, suffix, vecsize> {
2921 let Inst{28} = bit_28;
2922 let Inst{25-23} = 0b101;
2924 let Inst{20-16} = imm{4-0};
2925 let Inst{12} = bit_12;
2926 let Inst{11-6} = 0b111111;
2929 let validForTailPredication = 1;
2930 let retainsPreviousHalfElement = 1;
2933 def MVE_VQRSHRUNs16bh : MVE_VxQRSHRUN<
2934 "vqrshrunb", "s16", 0b1, 0b0, shr_imm8, 0b01> {
2935 let Inst{20-19} = 0b01;
2937 def MVE_VQRSHRUNs16th : MVE_VxQRSHRUN<
2938 "vqrshrunt", "s16", 0b1, 0b1, shr_imm8, 0b01> {
2939 let Inst{20-19} = 0b01;
2941 def MVE_VQRSHRUNs32bh : MVE_VxQRSHRUN<
2942 "vqrshrunb", "s32", 0b1, 0b0, shr_imm16, 0b10> {
2945 def MVE_VQRSHRUNs32th : MVE_VxQRSHRUN<
2946 "vqrshrunt", "s32", 0b1, 0b1, shr_imm16, 0b10> {
2950 def MVE_VQSHRUNs16bh : MVE_VxQRSHRUN<
2951 "vqshrunb", "s16", 0b0, 0b0, shr_imm8, 0b01> {
2952 let Inst{20-19} = 0b01;
2954 def MVE_VQSHRUNs16th : MVE_VxQRSHRUN<
2955 "vqshrunt", "s16", 0b0, 0b1, shr_imm8, 0b01> {
2956 let Inst{20-19} = 0b01;
2958 def MVE_VQSHRUNs32bh : MVE_VxQRSHRUN<
2959 "vqshrunb", "s32", 0b0, 0b0, shr_imm16, 0b10> {
2962 def MVE_VQSHRUNs32th : MVE_VxQRSHRUN<
2963 "vqshrunt", "s32", 0b0, 0b1, shr_imm16, 0b10> {
2967 class MVE_VxQRSHRN<string iname, string suffix, bit bit_0, bit bit_12,
2968 Operand imm, bits<2> vecsize>
2969 : MVE_shift_imm_partial<imm, iname, suffix, vecsize> {
2972 let Inst{25-23} = 0b101;
2974 let Inst{20-16} = imm{4-0};
2975 let Inst{12} = bit_12;
2976 let Inst{11-6} = 0b111101;
2978 let Inst{0} = bit_0;
2979 let validForTailPredication = 1;
2980 let retainsPreviousHalfElement = 1;
2983 multiclass MVE_VxQRSHRN_types<string iname, bit bit_0, bit bit_12> {
2984 def s16 : MVE_VxQRSHRN<iname, "s16", bit_0, bit_12, shr_imm8, 0b01> {
2986 let Inst{20-19} = 0b01;
2988 def u16 : MVE_VxQRSHRN<iname, "u16", bit_0, bit_12, shr_imm8, 0b01> {
2990 let Inst{20-19} = 0b01;
2992 def s32 : MVE_VxQRSHRN<iname, "s32", bit_0, bit_12, shr_imm16, 0b10> {
2996 def u32 : MVE_VxQRSHRN<iname, "u32", bit_0, bit_12, shr_imm16, 0b10> {
3002 defm MVE_VQRSHRNbh : MVE_VxQRSHRN_types<"vqrshrnb", 0b1, 0b0>;
3003 defm MVE_VQRSHRNth : MVE_VxQRSHRN_types<"vqrshrnt", 0b1, 0b1>;
3004 defm MVE_VQSHRNbh : MVE_VxQRSHRN_types<"vqshrnb", 0b0, 0b0>;
3005 defm MVE_VQSHRNth : MVE_VxQRSHRN_types<"vqshrnt", 0b0, 0b1>;
3007 multiclass MVE_VSHRN_patterns<MVE_shift_imm_partial inst,
3008 MVEVectorVTInfo OutVTI, MVEVectorVTInfo InVTI,
3009 bit q, bit r, bit top> {
3010 defvar inparams = (? (OutVTI.Vec MQPR:$QdSrc), (InVTI.Vec MQPR:$Qm),
3011 (inst.immediateType:$imm), (i32 q), (i32 r),
3012 (i32 OutVTI.Unsigned), (i32 InVTI.Unsigned), (i32 top));
3013 defvar outparams = (inst (OutVTI.Vec MQPR:$QdSrc), (InVTI.Vec MQPR:$Qm),
3016 def : Pat<(OutVTI.Vec !setdagop(inparams, int_arm_mve_vshrn)),
3017 (OutVTI.Vec outparams)>;
3018 def : Pat<(OutVTI.Vec !con(inparams, (int_arm_mve_vshrn_predicated
3019 (InVTI.Pred VCCR:$pred)))),
3020 (OutVTI.Vec !con(outparams, (? ARMVCCThen, VCCR:$pred, zero_reg)))>;
3023 defm : MVE_VSHRN_patterns<MVE_VSHRNi16bh, MVE_v16s8, MVE_v8s16, 0,0,0>;
3024 defm : MVE_VSHRN_patterns<MVE_VSHRNi16th, MVE_v16s8, MVE_v8s16, 0,0,1>;
3025 defm : MVE_VSHRN_patterns<MVE_VSHRNi32bh, MVE_v8s16, MVE_v4s32, 0,0,0>;
3026 defm : MVE_VSHRN_patterns<MVE_VSHRNi32th, MVE_v8s16, MVE_v4s32, 0,0,1>;
3027 defm : MVE_VSHRN_patterns<MVE_VSHRNi16bh, MVE_v16u8, MVE_v8u16, 0,0,0>;
3028 defm : MVE_VSHRN_patterns<MVE_VSHRNi16th, MVE_v16u8, MVE_v8u16, 0,0,1>;
3029 defm : MVE_VSHRN_patterns<MVE_VSHRNi32bh, MVE_v8u16, MVE_v4u32, 0,0,0>;
3030 defm : MVE_VSHRN_patterns<MVE_VSHRNi32th, MVE_v8u16, MVE_v4u32, 0,0,1>;
3031 defm : MVE_VSHRN_patterns<MVE_VRSHRNi16bh, MVE_v16s8, MVE_v8s16, 0,1,0>;
3032 defm : MVE_VSHRN_patterns<MVE_VRSHRNi16th, MVE_v16s8, MVE_v8s16, 0,1,1>;
3033 defm : MVE_VSHRN_patterns<MVE_VRSHRNi32bh, MVE_v8s16, MVE_v4s32, 0,1,0>;
3034 defm : MVE_VSHRN_patterns<MVE_VRSHRNi32th, MVE_v8s16, MVE_v4s32, 0,1,1>;
3035 defm : MVE_VSHRN_patterns<MVE_VRSHRNi16bh, MVE_v16u8, MVE_v8u16, 0,1,0>;
3036 defm : MVE_VSHRN_patterns<MVE_VRSHRNi16th, MVE_v16u8, MVE_v8u16, 0,1,1>;
3037 defm : MVE_VSHRN_patterns<MVE_VRSHRNi32bh, MVE_v8u16, MVE_v4u32, 0,1,0>;
3038 defm : MVE_VSHRN_patterns<MVE_VRSHRNi32th, MVE_v8u16, MVE_v4u32, 0,1,1>;
3039 defm : MVE_VSHRN_patterns<MVE_VQSHRNbhs16, MVE_v16s8, MVE_v8s16, 1,0,0>;
3040 defm : MVE_VSHRN_patterns<MVE_VQSHRNths16, MVE_v16s8, MVE_v8s16, 1,0,1>;
3041 defm : MVE_VSHRN_patterns<MVE_VQSHRNbhs32, MVE_v8s16, MVE_v4s32, 1,0,0>;
3042 defm : MVE_VSHRN_patterns<MVE_VQSHRNths32, MVE_v8s16, MVE_v4s32, 1,0,1>;
3043 defm : MVE_VSHRN_patterns<MVE_VQSHRNbhu16, MVE_v16u8, MVE_v8u16, 1,0,0>;
3044 defm : MVE_VSHRN_patterns<MVE_VQSHRNthu16, MVE_v16u8, MVE_v8u16, 1,0,1>;
3045 defm : MVE_VSHRN_patterns<MVE_VQSHRNbhu32, MVE_v8u16, MVE_v4u32, 1,0,0>;
3046 defm : MVE_VSHRN_patterns<MVE_VQSHRNthu32, MVE_v8u16, MVE_v4u32, 1,0,1>;
3047 defm : MVE_VSHRN_patterns<MVE_VQRSHRNbhs16, MVE_v16s8, MVE_v8s16, 1,1,0>;
3048 defm : MVE_VSHRN_patterns<MVE_VQRSHRNths16, MVE_v16s8, MVE_v8s16, 1,1,1>;
3049 defm : MVE_VSHRN_patterns<MVE_VQRSHRNbhs32, MVE_v8s16, MVE_v4s32, 1,1,0>;
3050 defm : MVE_VSHRN_patterns<MVE_VQRSHRNths32, MVE_v8s16, MVE_v4s32, 1,1,1>;
3051 defm : MVE_VSHRN_patterns<MVE_VQRSHRNbhu16, MVE_v16u8, MVE_v8u16, 1,1,0>;
3052 defm : MVE_VSHRN_patterns<MVE_VQRSHRNthu16, MVE_v16u8, MVE_v8u16, 1,1,1>;
3053 defm : MVE_VSHRN_patterns<MVE_VQRSHRNbhu32, MVE_v8u16, MVE_v4u32, 1,1,0>;
3054 defm : MVE_VSHRN_patterns<MVE_VQRSHRNthu32, MVE_v8u16, MVE_v4u32, 1,1,1>;
3055 defm : MVE_VSHRN_patterns<MVE_VQSHRUNs16bh, MVE_v16u8, MVE_v8s16, 1,0,0>;
3056 defm : MVE_VSHRN_patterns<MVE_VQSHRUNs16th, MVE_v16u8, MVE_v8s16, 1,0,1>;
3057 defm : MVE_VSHRN_patterns<MVE_VQSHRUNs32bh, MVE_v8u16, MVE_v4s32, 1,0,0>;
3058 defm : MVE_VSHRN_patterns<MVE_VQSHRUNs32th, MVE_v8u16, MVE_v4s32, 1,0,1>;
3059 defm : MVE_VSHRN_patterns<MVE_VQRSHRUNs16bh, MVE_v16u8, MVE_v8s16, 1,1,0>;
3060 defm : MVE_VSHRN_patterns<MVE_VQRSHRUNs16th, MVE_v16u8, MVE_v8s16, 1,1,1>;
3061 defm : MVE_VSHRN_patterns<MVE_VQRSHRUNs32bh, MVE_v8u16, MVE_v4s32, 1,1,0>;
3062 defm : MVE_VSHRN_patterns<MVE_VQRSHRUNs32th, MVE_v8u16, MVE_v4s32, 1,1,1>;
3064 // end of mve_imm_shift instructions
3066 // start of mve_shift instructions
3068 class MVE_shift_by_vec<string iname, string suffix, bit U,
3069 bits<2> size, bit bit_4, bit bit_8>
3070 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qm, MQPR:$Qn), NoItinerary,
3071 iname, suffix, "$Qd, $Qm, $Qn", vpred_r, "", size, []> {
3072 // Shift instructions which take a vector of shift counts
3078 let Inst{25-24} = 0b11;
3080 let Inst{22} = Qd{3};
3081 let Inst{21-20} = size;
3082 let Inst{19-17} = Qn{2-0};
3084 let Inst{15-13} = Qd{2-0};
3085 let Inst{12-9} = 0b0010;
3086 let Inst{8} = bit_8;
3087 let Inst{7} = Qn{3};
3089 let Inst{5} = Qm{3};
3090 let Inst{4} = bit_4;
3091 let Inst{3-1} = Qm{2-0};
3093 let validForTailPredication = 1;
3096 multiclass MVE_shift_by_vec_p<string iname, MVEVectorVTInfo VTI, bit q, bit r> {
3097 def "" : MVE_shift_by_vec<iname, VTI.Suffix, VTI.Unsigned, VTI.Size, q, r>;
3098 defvar Inst = !cast<Instruction>(NAME);
3100 def : Pat<(VTI.Vec (int_arm_mve_vshl_vector
3101 (VTI.Vec MQPR:$in), (VTI.Vec MQPR:$sh),
3102 (i32 q), (i32 r), (i32 VTI.Unsigned))),
3103 (VTI.Vec (Inst (VTI.Vec MQPR:$in), (VTI.Vec MQPR:$sh)))>;
3105 def : Pat<(VTI.Vec (int_arm_mve_vshl_vector_predicated
3106 (VTI.Vec MQPR:$in), (VTI.Vec MQPR:$sh),
3107 (i32 q), (i32 r), (i32 VTI.Unsigned),
3108 (VTI.Pred VCCR:$mask), (VTI.Vec MQPR:$inactive))),
3109 (VTI.Vec (Inst (VTI.Vec MQPR:$in), (VTI.Vec MQPR:$sh),
3110 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
3111 (VTI.Vec MQPR:$inactive)))>;
3114 multiclass mve_shift_by_vec_multi<string iname, bit bit_4, bit bit_8> {
3115 defm s8 : MVE_shift_by_vec_p<iname, MVE_v16s8, bit_4, bit_8>;
3116 defm s16 : MVE_shift_by_vec_p<iname, MVE_v8s16, bit_4, bit_8>;
3117 defm s32 : MVE_shift_by_vec_p<iname, MVE_v4s32, bit_4, bit_8>;
3118 defm u8 : MVE_shift_by_vec_p<iname, MVE_v16u8, bit_4, bit_8>;
3119 defm u16 : MVE_shift_by_vec_p<iname, MVE_v8u16, bit_4, bit_8>;
3120 defm u32 : MVE_shift_by_vec_p<iname, MVE_v4u32, bit_4, bit_8>;
3123 defm MVE_VSHL_by_vec : mve_shift_by_vec_multi<"vshl", 0b0, 0b0>;
3124 defm MVE_VQSHL_by_vec : mve_shift_by_vec_multi<"vqshl", 0b1, 0b0>;
3125 defm MVE_VQRSHL_by_vec : mve_shift_by_vec_multi<"vqrshl", 0b1, 0b1>;
3126 defm MVE_VRSHL_by_vec : mve_shift_by_vec_multi<"vrshl", 0b0, 0b1>;
3128 let Predicates = [HasMVEInt] in {
3129 defm : MVE_TwoOpPattern<MVE_v16i8, ARMvshlu, int_arm_mve_vshl_vector_predicated,
3130 (? (i32 0), (i32 0), (i32 1)), MVE_VSHL_by_vecu8, null_frag>;
3131 defm : MVE_TwoOpPattern<MVE_v8i16, ARMvshlu, int_arm_mve_vshl_vector_predicated,
3132 (? (i32 0), (i32 0), (i32 1)), MVE_VSHL_by_vecu16, null_frag>;
3133 defm : MVE_TwoOpPattern<MVE_v4i32, ARMvshlu, int_arm_mve_vshl_vector_predicated,
3134 (? (i32 0), (i32 0), (i32 1)), MVE_VSHL_by_vecu32, null_frag>;
3135 defm : MVE_TwoOpPattern<MVE_v16i8, ARMvshls, int_arm_mve_vshl_vector_predicated,
3136 (? (i32 0), (i32 0), (i32 0)), MVE_VSHL_by_vecs8, null_frag>;
3137 defm : MVE_TwoOpPattern<MVE_v8i16, ARMvshls, int_arm_mve_vshl_vector_predicated,
3138 (? (i32 0), (i32 0), (i32 0)), MVE_VSHL_by_vecs16, null_frag>;
3139 defm : MVE_TwoOpPattern<MVE_v4i32, ARMvshls, int_arm_mve_vshl_vector_predicated,
3140 (? (i32 0), (i32 0), (i32 0)), MVE_VSHL_by_vecs32, null_frag>;
3143 class MVE_shift_with_imm<string iname, string suffix, dag oops, dag iops,
3144 string ops, vpred_ops vpred, string cstr,
3145 bits<2> vecsize, list<dag> pattern=[]>
3146 : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, vecsize, pattern> {
3151 let Inst{22} = Qd{3};
3152 let Inst{15-13} = Qd{2-0};
3153 let Inst{12-11} = 0b00;
3154 let Inst{7-6} = 0b01;
3155 let Inst{5} = Qm{3};
3157 let Inst{3-1} = Qm{2-0};
3159 let validForTailPredication = 1;
3161 // For the MVE_shift_imm_patterns multiclass to refer to
3162 MVEVectorVTInfo VTI;
3163 Operand immediateType;
3164 Intrinsic unpred_int;
3166 dag unsignedFlag = (?);
3169 class MVE_VSxI_imm<string iname, string suffix, bit bit_8, Operand immType, bits<2> vecsize>
3170 : MVE_shift_with_imm<iname, suffix, (outs MQPR:$Qd),
3171 (ins MQPR:$Qd_src, MQPR:$Qm, immType:$imm),
3172 "$Qd, $Qm, $imm", vpred_n, "$Qd = $Qd_src", vecsize> {
3175 let Inst{25-24} = 0b11;
3176 let Inst{21-16} = imm;
3177 let Inst{10-9} = 0b10;
3178 let Inst{8} = bit_8;
3179 let validForTailPredication = 1;
3181 Operand immediateType = immType;
3184 def MVE_VSRIimm8 : MVE_VSxI_imm<"vsri", "8", 0b0, shr_imm8, 0b00> {
3185 let Inst{21-19} = 0b001;
3188 def MVE_VSRIimm16 : MVE_VSxI_imm<"vsri", "16", 0b0, shr_imm16, 0b01> {
3189 let Inst{21-20} = 0b01;
3192 def MVE_VSRIimm32 : MVE_VSxI_imm<"vsri", "32", 0b0, shr_imm32, 0b10> {
3196 def MVE_VSLIimm8 : MVE_VSxI_imm<"vsli", "8", 0b1, imm0_7, 0b00> {
3197 let Inst{21-19} = 0b001;
3200 def MVE_VSLIimm16 : MVE_VSxI_imm<"vsli", "16", 0b1, imm0_15, 0b01> {
3201 let Inst{21-20} = 0b01;
3204 def MVE_VSLIimm32 : MVE_VSxI_imm<"vsli", "32", 0b1,imm0_31, 0b10> {
3208 multiclass MVE_VSxI_patterns<MVE_VSxI_imm inst, string name,
3209 MVEVectorVTInfo VTI> {
3210 defvar inparams = (? (VTI.Vec MQPR:$QdSrc), (VTI.Vec MQPR:$Qm),
3211 (inst.immediateType:$imm));
3212 defvar outparams = (inst (VTI.Vec MQPR:$QdSrc), (VTI.Vec MQPR:$Qm),
3213 (inst.immediateType:$imm));
3214 defvar unpred_int = !cast<Intrinsic>("int_arm_mve_" # name);
3215 defvar pred_int = !cast<Intrinsic>("int_arm_mve_" # name # "_predicated");
3217 def : Pat<(VTI.Vec !setdagop(inparams, unpred_int)),
3218 (VTI.Vec outparams)>;
3219 def : Pat<(VTI.Vec !con(inparams, (pred_int (VTI.Pred VCCR:$pred)))),
3220 (VTI.Vec !con(outparams, (? ARMVCCThen, VCCR:$pred, zero_reg)))>;
3223 defm : MVE_VSxI_patterns<MVE_VSLIimm8, "vsli", MVE_v16i8>;
3224 defm : MVE_VSxI_patterns<MVE_VSLIimm16, "vsli", MVE_v8i16>;
3225 defm : MVE_VSxI_patterns<MVE_VSLIimm32, "vsli", MVE_v4i32>;
3226 defm : MVE_VSxI_patterns<MVE_VSRIimm8, "vsri", MVE_v16i8>;
3227 defm : MVE_VSxI_patterns<MVE_VSRIimm16, "vsri", MVE_v8i16>;
3228 defm : MVE_VSxI_patterns<MVE_VSRIimm32, "vsri", MVE_v4i32>;
3230 class MVE_VQSHL_imm<MVEVectorVTInfo VTI_, Operand immType>
3231 : MVE_shift_with_imm<"vqshl", VTI_.Suffix, (outs MQPR:$Qd),
3232 (ins MQPR:$Qm, immType:$imm), "$Qd, $Qm, $imm",
3233 vpred_r, "", VTI_.Size> {
3236 let Inst{28} = VTI_.Unsigned;
3237 let Inst{25-24} = 0b11;
3238 let Inst{21-16} = imm;
3239 let Inst{10-8} = 0b111;
3242 let immediateType = immType;
3243 let unsignedFlag = (? (i32 VTI.Unsigned));
3246 let unpred_int = int_arm_mve_vqshl_imm,
3247 pred_int = int_arm_mve_vqshl_imm_predicated in {
3248 def MVE_VQSHLimms8 : MVE_VQSHL_imm<MVE_v16s8, imm0_7> {
3249 let Inst{21-19} = 0b001;
3251 def MVE_VQSHLimmu8 : MVE_VQSHL_imm<MVE_v16u8, imm0_7> {
3252 let Inst{21-19} = 0b001;
3255 def MVE_VQSHLimms16 : MVE_VQSHL_imm<MVE_v8s16, imm0_15> {
3256 let Inst{21-20} = 0b01;
3258 def MVE_VQSHLimmu16 : MVE_VQSHL_imm<MVE_v8u16, imm0_15> {
3259 let Inst{21-20} = 0b01;
3262 def MVE_VQSHLimms32 : MVE_VQSHL_imm<MVE_v4s32, imm0_31> {
3265 def MVE_VQSHLimmu32 : MVE_VQSHL_imm<MVE_v4u32, imm0_31> {
3270 class MVE_VQSHLU_imm<MVEVectorVTInfo VTI_, Operand immType>
3271 : MVE_shift_with_imm<"vqshlu", VTI_.Suffix, (outs MQPR:$Qd),
3272 (ins MQPR:$Qm, immType:$imm), "$Qd, $Qm, $imm",
3273 vpred_r, "", VTI_.Size> {
3277 let Inst{25-24} = 0b11;
3278 let Inst{21-16} = imm;
3279 let Inst{10-8} = 0b110;
3282 let immediateType = immType;
3285 let unpred_int = int_arm_mve_vqshlu_imm,
3286 pred_int = int_arm_mve_vqshlu_imm_predicated in {
3287 def MVE_VQSHLU_imms8 : MVE_VQSHLU_imm<MVE_v16s8, imm0_7> {
3288 let Inst{21-19} = 0b001;
3291 def MVE_VQSHLU_imms16 : MVE_VQSHLU_imm<MVE_v8s16, imm0_15> {
3292 let Inst{21-20} = 0b01;
3295 def MVE_VQSHLU_imms32 : MVE_VQSHLU_imm<MVE_v4s32, imm0_31> {
3300 class MVE_VRSHR_imm<MVEVectorVTInfo VTI_, Operand immType>
3301 : MVE_shift_with_imm<"vrshr", VTI_.Suffix, (outs MQPR:$Qd),
3302 (ins MQPR:$Qm, immType:$imm), "$Qd, $Qm, $imm",
3303 vpred_r, "", VTI_.Size> {
3306 let Inst{28} = VTI_.Unsigned;
3307 let Inst{25-24} = 0b11;
3308 let Inst{21-16} = imm;
3309 let Inst{10-8} = 0b010;
3312 let immediateType = immType;
3313 let unsignedFlag = (? (i32 VTI.Unsigned));
3316 let unpred_int = int_arm_mve_vrshr_imm,
3317 pred_int = int_arm_mve_vrshr_imm_predicated in {
3318 def MVE_VRSHR_imms8 : MVE_VRSHR_imm<MVE_v16s8, shr_imm8> {
3319 let Inst{21-19} = 0b001;
3322 def MVE_VRSHR_immu8 : MVE_VRSHR_imm<MVE_v16u8, shr_imm8> {
3323 let Inst{21-19} = 0b001;
3326 def MVE_VRSHR_imms16 : MVE_VRSHR_imm<MVE_v8s16, shr_imm16> {
3327 let Inst{21-20} = 0b01;
3330 def MVE_VRSHR_immu16 : MVE_VRSHR_imm<MVE_v8u16, shr_imm16> {
3331 let Inst{21-20} = 0b01;
3334 def MVE_VRSHR_imms32 : MVE_VRSHR_imm<MVE_v4s32, shr_imm32> {
3338 def MVE_VRSHR_immu32 : MVE_VRSHR_imm<MVE_v4u32, shr_imm32> {
3343 multiclass MVE_shift_imm_patterns<MVE_shift_with_imm inst> {
3344 def : Pat<(inst.VTI.Vec !con((inst.unpred_int (inst.VTI.Vec MQPR:$src),
3345 inst.immediateType:$imm),
3346 inst.unsignedFlag)),
3347 (inst.VTI.Vec (inst (inst.VTI.Vec MQPR:$src),
3348 inst.immediateType:$imm))>;
3350 def : Pat<(inst.VTI.Vec !con((inst.pred_int (inst.VTI.Vec MQPR:$src),
3351 inst.immediateType:$imm),
3353 (? (inst.VTI.Pred VCCR:$mask),
3354 (inst.VTI.Vec MQPR:$inactive)))),
3355 (inst.VTI.Vec (inst (inst.VTI.Vec MQPR:$src),
3356 inst.immediateType:$imm,
3357 ARMVCCThen, (inst.VTI.Pred VCCR:$mask), zero_reg,
3358 (inst.VTI.Vec MQPR:$inactive)))>;
3361 defm : MVE_shift_imm_patterns<MVE_VQSHLimms8>;
3362 defm : MVE_shift_imm_patterns<MVE_VQSHLimmu8>;
3363 defm : MVE_shift_imm_patterns<MVE_VQSHLimms16>;
3364 defm : MVE_shift_imm_patterns<MVE_VQSHLimmu16>;
3365 defm : MVE_shift_imm_patterns<MVE_VQSHLimms32>;
3366 defm : MVE_shift_imm_patterns<MVE_VQSHLimmu32>;
3367 defm : MVE_shift_imm_patterns<MVE_VQSHLU_imms8>;
3368 defm : MVE_shift_imm_patterns<MVE_VQSHLU_imms16>;
3369 defm : MVE_shift_imm_patterns<MVE_VQSHLU_imms32>;
3370 defm : MVE_shift_imm_patterns<MVE_VRSHR_imms8>;
3371 defm : MVE_shift_imm_patterns<MVE_VRSHR_immu8>;
3372 defm : MVE_shift_imm_patterns<MVE_VRSHR_imms16>;
3373 defm : MVE_shift_imm_patterns<MVE_VRSHR_immu16>;
3374 defm : MVE_shift_imm_patterns<MVE_VRSHR_imms32>;
3375 defm : MVE_shift_imm_patterns<MVE_VRSHR_immu32>;
3377 class MVE_VSHR_imm<string suffix, dag imm, bits<2> vecsize>
3378 : MVE_shift_with_imm<"vshr", suffix, (outs MQPR:$Qd),
3379 !con((ins MQPR:$Qm), imm), "$Qd, $Qm, $imm",
3380 vpred_r, "", vecsize> {
3383 let Inst{25-24} = 0b11;
3384 let Inst{21-16} = imm;
3385 let Inst{10-8} = 0b000;
3388 def MVE_VSHR_imms8 : MVE_VSHR_imm<"s8", (ins shr_imm8:$imm), 0b00> {
3390 let Inst{21-19} = 0b001;
3393 def MVE_VSHR_immu8 : MVE_VSHR_imm<"u8", (ins shr_imm8:$imm), 0b00> {
3395 let Inst{21-19} = 0b001;
3398 def MVE_VSHR_imms16 : MVE_VSHR_imm<"s16", (ins shr_imm16:$imm), 0b01> {
3400 let Inst{21-20} = 0b01;
3403 def MVE_VSHR_immu16 : MVE_VSHR_imm<"u16", (ins shr_imm16:$imm), 0b01> {
3405 let Inst{21-20} = 0b01;
3408 def MVE_VSHR_imms32 : MVE_VSHR_imm<"s32", (ins shr_imm32:$imm), 0b10> {
3413 def MVE_VSHR_immu32 : MVE_VSHR_imm<"u32", (ins shr_imm32:$imm), 0b10> {
3418 class MVE_VSHL_imm<string suffix, dag imm, bits<2> vecsize>
3419 : MVE_shift_with_imm<"vshl", suffix, (outs MQPR:$Qd),
3420 !con((ins MQPR:$Qm), imm), "$Qd, $Qm, $imm",
3421 vpred_r, "", vecsize> {
3425 let Inst{25-24} = 0b11;
3426 let Inst{21-16} = imm;
3427 let Inst{10-8} = 0b101;
3430 def MVE_VSHL_immi8 : MVE_VSHL_imm<"i8", (ins imm0_7:$imm), 0b00> {
3431 let Inst{21-19} = 0b001;
3434 def MVE_VSHL_immi16 : MVE_VSHL_imm<"i16", (ins imm0_15:$imm), 0b01> {
3435 let Inst{21-20} = 0b01;
3438 def MVE_VSHL_immi32 : MVE_VSHL_imm<"i32", (ins imm0_31:$imm), 0b10> {
3442 multiclass MVE_immediate_shift_patterns_inner<
3443 MVEVectorVTInfo VTI, Operand imm_operand_type, SDNode unpred_op,
3444 Intrinsic pred_int, Instruction inst, list<int> unsignedFlag = []> {
3446 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$src), imm_operand_type:$imm)),
3447 (VTI.Vec (inst (VTI.Vec MQPR:$src), imm_operand_type:$imm))>;
3449 def : Pat<(VTI.Vec !con((pred_int (VTI.Vec MQPR:$src), imm_operand_type:$imm),
3450 !dag(pred_int, unsignedFlag, ?),
3451 (pred_int (VTI.Pred VCCR:$mask),
3452 (VTI.Vec MQPR:$inactive)))),
3453 (VTI.Vec (inst (VTI.Vec MQPR:$src), imm_operand_type:$imm,
3454 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
3455 (VTI.Vec MQPR:$inactive)))>;
3458 multiclass MVE_immediate_shift_patterns<MVEVectorVTInfo VTI,
3459 Operand imm_operand_type> {
3460 defm : MVE_immediate_shift_patterns_inner<VTI, imm_operand_type,
3461 ARMvshlImm, int_arm_mve_shl_imm_predicated,
3462 !cast<Instruction>("MVE_VSHL_immi" # VTI.BitsSuffix)>;
3463 defm : MVE_immediate_shift_patterns_inner<VTI, imm_operand_type,
3464 ARMvshruImm, int_arm_mve_shr_imm_predicated,
3465 !cast<Instruction>("MVE_VSHR_immu" # VTI.BitsSuffix), [1]>;
3466 defm : MVE_immediate_shift_patterns_inner<VTI, imm_operand_type,
3467 ARMvshrsImm, int_arm_mve_shr_imm_predicated,
3468 !cast<Instruction>("MVE_VSHR_imms" # VTI.BitsSuffix), [0]>;
3471 let Predicates = [HasMVEInt] in {
3472 defm : MVE_immediate_shift_patterns<MVE_v16i8, imm0_7>;
3473 defm : MVE_immediate_shift_patterns<MVE_v8i16, imm0_15>;
3474 defm : MVE_immediate_shift_patterns<MVE_v4i32, imm0_31>;
3477 // end of mve_shift instructions
3479 // start of MVE Floating Point instructions
3481 class MVE_float<string iname, string suffix, dag oops, dag iops, string ops,
3482 vpred_ops vpred, string cstr, bits<2> vecsize, list<dag> pattern=[]>
3483 : MVE_f<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, vecsize, pattern> {
3488 let Inst{5} = Qm{3};
3489 let Inst{3-1} = Qm{2-0};
3493 class MVE_VRINT<string rmode, bits<3> op, string suffix, bits<2> size,
3494 list<dag> pattern=[]>
3495 : MVE_float<!strconcat("vrint", rmode), suffix, (outs MQPR:$Qd),
3496 (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", size, pattern> {
3500 let Inst{25-23} = 0b111;
3501 let Inst{22} = Qd{3};
3502 let Inst{21-20} = 0b11;
3503 let Inst{19-18} = size;
3504 let Inst{17-16} = 0b10;
3505 let Inst{15-13} = Qd{2-0};
3506 let Inst{11-10} = 0b01;
3507 let Inst{9-7} = op{2-0};
3509 let validForTailPredication = 1;
3513 multiclass MVE_VRINT_m<MVEVectorVTInfo VTI, string suffix, bits<3> opcode,
3514 SDPatternOperator unpred_op> {
3515 def "": MVE_VRINT<suffix, opcode, VTI.Suffix, VTI.Size>;
3516 defvar Inst = !cast<Instruction>(NAME);
3517 defvar pred_int = !cast<Intrinsic>("int_arm_mve_vrint"#suffix#"_predicated");
3519 let Predicates = [HasMVEFloat] in {
3520 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$val))),
3521 (VTI.Vec (Inst (VTI.Vec MQPR:$val)))>;
3522 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$val), (VTI.Pred VCCR:$pred),
3523 (VTI.Vec MQPR:$inactive))),
3524 (VTI.Vec (Inst (VTI.Vec MQPR:$val), ARMVCCThen,
3525 (VTI.Pred VCCR:$pred), zero_reg, (VTI.Vec MQPR:$inactive)))>;
3529 multiclass MVE_VRINT_ops<MVEVectorVTInfo VTI> {
3530 defm N : MVE_VRINT_m<VTI, "n", 0b000, int_arm_mve_vrintn>;
3531 defm X : MVE_VRINT_m<VTI, "x", 0b001, frint>;
3532 defm A : MVE_VRINT_m<VTI, "a", 0b010, fround>;
3533 defm Z : MVE_VRINT_m<VTI, "z", 0b011, ftrunc>;
3534 defm M : MVE_VRINT_m<VTI, "m", 0b101, ffloor>;
3535 defm P : MVE_VRINT_m<VTI, "p", 0b111, fceil>;
3538 defm MVE_VRINTf16 : MVE_VRINT_ops<MVE_v8f16>;
3539 defm MVE_VRINTf32 : MVE_VRINT_ops<MVE_v4f32>;
3541 class MVEFloatArithNeon<string iname, string suffix, bit size,
3542 dag oops, dag iops, string ops,
3543 vpred_ops vpred, string cstr, bits<2> vecsize, list<dag> pattern=[]>
3544 : MVE_float<iname, suffix, oops, iops, ops, vpred, cstr, vecsize, pattern> {
3545 let Inst{20} = size;
3549 class MVE_VMUL_fp<string iname, string suffix, bits<2> size, list<dag> pattern=[]>
3550 : MVEFloatArithNeon<iname, suffix, size{0}, (outs MQPR:$Qd),
3551 (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm", vpred_r, "",
3557 let Inst{25-23} = 0b110;
3558 let Inst{22} = Qd{3};
3560 let Inst{19-17} = Qn{2-0};
3561 let Inst{15-13} = Qd{2-0};
3562 let Inst{12-8} = 0b01101;
3563 let Inst{7} = Qn{3};
3565 let validForTailPredication = 1;
3568 multiclass MVE_VMULT_fp_m<string iname, MVEVectorVTInfo VTI, SDNode Op,
3569 Intrinsic PredInt, SDPatternOperator IdentityVec> {
3570 def "" : MVE_VMUL_fp<iname, VTI.Suffix, VTI.Size>;
3571 defvar Inst = !cast<Instruction>(NAME);
3573 let Predicates = [HasMVEFloat] in {
3574 defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? ), !cast<Instruction>(NAME), IdentityVec>;
3578 multiclass MVE_VMUL_fp_m<MVEVectorVTInfo VTI, SDPatternOperator IdentityVec>
3579 : MVE_VMULT_fp_m<"vmul", VTI, fmul, int_arm_mve_mul_predicated, IdentityVec>;
3581 def ARMimmOneF: PatLeaf<(bitconvert (v4f32 (ARMvmovFPImm (i32 112))))>; // 1.0 float
3582 def ARMimmOneH: PatLeaf<(bitconvert (v8i16 (ARMvmovImm (i32 2620))))>; // 1.0 half
3584 defm MVE_VMULf32 : MVE_VMUL_fp_m<MVE_v4f32, ARMimmOneF>;
3585 defm MVE_VMULf16 : MVE_VMUL_fp_m<MVE_v8f16, ARMimmOneH>;
3587 class MVE_VCMLA<string suffix, bits<2> size, string cstr>
3588 : MVEFloatArithNeon<"vcmla", suffix, size{1}, (outs MQPR:$Qd),
3589 (ins MQPR:$Qd_src, MQPR:$Qn, MQPR:$Qm, complexrotateop:$rot),
3590 "$Qd, $Qn, $Qm, $rot", vpred_n, "$Qd = $Qd_src"#cstr, size, []> {
3597 let Inst{24-23} = rot;
3598 let Inst{22} = Qd{3};
3600 let Inst{19-17} = Qn{2-0};
3601 let Inst{15-13} = Qd{2-0};
3602 let Inst{12-8} = 0b01000;
3603 let Inst{7} = Qn{3};
3607 multiclass MVE_VCMLA_m<MVEVectorVTInfo VTI, string cstr=""> {
3608 def "" : MVE_VCMLA<VTI.Suffix, VTI.Size, cstr>;
3609 defvar Inst = !cast<Instruction>(NAME);
3611 let Predicates = [HasMVEFloat] in {
3612 def : Pat<(VTI.Vec (int_arm_mve_vcmlaq
3613 imm:$rot, (VTI.Vec MQPR:$Qd_src),
3614 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))),
3615 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src),
3616 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
3619 def: Pat<(VTI.Vec (fadd_contract MQPR:$Qd_src,
3620 (int_arm_mve_vcmulq imm:$rot,
3621 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm)))),
3622 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src),
3623 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
3626 def : Pat<(VTI.Vec (int_arm_mve_vcmlaq_predicated
3627 imm:$rot, (VTI.Vec MQPR:$Qd_src),
3628 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
3629 (VTI.Pred VCCR:$mask))),
3630 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src), (VTI.Vec MQPR:$Qn),
3631 (VTI.Vec MQPR:$Qm), imm:$rot,
3632 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>;
3636 defm MVE_VCMLAf16 : MVE_VCMLA_m<MVE_v8f16>;
3637 defm MVE_VCMLAf32 : MVE_VCMLA_m<MVE_v4f32, ",@earlyclobber $Qd">;
3639 class MVE_VADDSUBFMA_fp<string iname, string suffix, bits<2> size, bit bit_4,
3640 bit bit_8, bit bit_21, dag iops=(ins),
3641 vpred_ops vpred=vpred_r, string cstr="",
3642 list<dag> pattern=[]>
3643 : MVEFloatArithNeon<iname, suffix, size{0}, (outs MQPR:$Qd),
3644 !con(iops, (ins MQPR:$Qn, MQPR:$Qm)), "$Qd, $Qn, $Qm",
3645 vpred, cstr, size, pattern> {
3650 let Inst{25-23} = 0b110;
3651 let Inst{22} = Qd{3};
3652 let Inst{21} = bit_21;
3653 let Inst{19-17} = Qn{2-0};
3654 let Inst{15-13} = Qd{2-0};
3655 let Inst{11-9} = 0b110;
3656 let Inst{8} = bit_8;
3657 let Inst{7} = Qn{3};
3658 let Inst{4} = bit_4;
3659 let validForTailPredication = 1;
3662 multiclass MVE_VFMA_fp_multi<string iname, bit fms, MVEVectorVTInfo VTI> {
3663 def "" : MVE_VADDSUBFMA_fp<iname, VTI.Suffix, VTI.Size, 0b1, 0b0, fms,
3664 (ins MQPR:$Qd_src), vpred_n, "$Qd = $Qd_src">;
3665 defvar Inst = !cast<Instruction>(NAME);
3666 defvar pred_int = int_arm_mve_fma_predicated;
3667 defvar m1 = (VTI.Vec MQPR:$m1);
3668 defvar m2 = (VTI.Vec MQPR:$m2);
3669 defvar add = (VTI.Vec MQPR:$add);
3670 defvar pred = (VTI.Pred VCCR:$pred);
3672 let Predicates = [HasMVEFloat] in {
3674 def : Pat<(VTI.Vec (fma (fneg m1), m2, add)),
3675 (Inst $add, $m1, $m2)>;
3676 def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred),
3677 (VTI.Vec (fma (fneg m1), m2, add)),
3679 (Inst $add, $m1, $m2, ARMVCCThen, $pred, zero_reg)>;
3680 def : Pat<(VTI.Vec (pred_int (fneg m1), m2, add, pred)),
3681 (Inst $add, $m1, $m2, ARMVCCThen, $pred, zero_reg)>;
3682 def : Pat<(VTI.Vec (pred_int m1, (fneg m2), add, pred)),
3683 (Inst $add, $m1, $m2, ARMVCCThen, $pred, zero_reg)>;
3685 def : Pat<(VTI.Vec (fma m1, m2, add)),
3686 (Inst $add, $m1, $m2)>;
3687 def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred),
3688 (VTI.Vec (fma m1, m2, add)),
3690 (Inst $add, $m1, $m2, ARMVCCThen, $pred, zero_reg)>;
3691 def : Pat<(VTI.Vec (pred_int m1, m2, add, pred)),
3692 (Inst $add, $m1, $m2, ARMVCCThen, $pred, zero_reg)>;
3697 defm MVE_VFMAf32 : MVE_VFMA_fp_multi<"vfma", 0, MVE_v4f32>;
3698 defm MVE_VFMAf16 : MVE_VFMA_fp_multi<"vfma", 0, MVE_v8f16>;
3699 defm MVE_VFMSf32 : MVE_VFMA_fp_multi<"vfms", 1, MVE_v4f32>;
3700 defm MVE_VFMSf16 : MVE_VFMA_fp_multi<"vfms", 1, MVE_v8f16>;
3702 multiclass MVE_VADDSUB_fp_m<string iname, bit bit_21, MVEVectorVTInfo VTI,
3703 SDNode Op, Intrinsic PredInt, SDPatternOperator IdentityVec> {
3704 def "" : MVE_VADDSUBFMA_fp<iname, VTI.Suffix, VTI.Size, 0, 1, bit_21> {
3705 let validForTailPredication = 1;
3707 defvar Inst = !cast<Instruction>(NAME);
3709 let Predicates = [HasMVEFloat] in {
3710 defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? ), !cast<Instruction>(NAME), IdentityVec>;
3714 multiclass MVE_VADD_fp_m<MVEVectorVTInfo VTI, SDPatternOperator IdentityVec>
3715 : MVE_VADDSUB_fp_m<"vadd", 0, VTI, fadd, int_arm_mve_add_predicated, IdentityVec>;
3716 multiclass MVE_VSUB_fp_m<MVEVectorVTInfo VTI, SDPatternOperator IdentityVec>
3717 : MVE_VADDSUB_fp_m<"vsub", 1, VTI, fsub, int_arm_mve_sub_predicated, IdentityVec>;
3719 def ARMimmMinusZeroF: PatLeaf<(bitconvert (v4i32 (ARMvmovImm (i32 1664))))>; // -0.0 float
3720 def ARMimmMinusZeroH: PatLeaf<(bitconvert (v8i16 (ARMvmovImm (i32 2688))))>; // -0.0 half
3722 defm MVE_VADDf32 : MVE_VADD_fp_m<MVE_v4f32, ARMimmMinusZeroF>;
3723 defm MVE_VADDf16 : MVE_VADD_fp_m<MVE_v8f16, ARMimmMinusZeroH>;
3725 defm MVE_VSUBf32 : MVE_VSUB_fp_m<MVE_v4f32, ARMimmAllZerosV>;
3726 defm MVE_VSUBf16 : MVE_VSUB_fp_m<MVE_v8f16, ARMimmAllZerosV>;
3728 class MVE_VCADD<string suffix, bits<2> size, string cstr="">
3729 : MVEFloatArithNeon<"vcadd", suffix, size{1}, (outs MQPR:$Qd),
3730 (ins MQPR:$Qn, MQPR:$Qm, complexrotateopodd:$rot),
3731 "$Qd, $Qn, $Qm, $rot", vpred_r, cstr, size, []> {
3740 let Inst{22} = Qd{3};
3742 let Inst{19-17} = Qn{2-0};
3743 let Inst{15-13} = Qd{2-0};
3744 let Inst{12-8} = 0b01000;
3745 let Inst{7} = Qn{3};
3749 multiclass MVE_VCADD_m<MVEVectorVTInfo VTI, string cstr=""> {
3750 def "" : MVE_VCADD<VTI.Suffix, VTI.Size, cstr>;
3751 defvar Inst = !cast<Instruction>(NAME);
3753 let Predicates = [HasMVEFloat] in {
3754 def : Pat<(VTI.Vec (int_arm_mve_vcaddq (i32 1),
3755 imm:$rot, (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))),
3756 (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
3759 def : Pat<(VTI.Vec (int_arm_mve_vcaddq_predicated (i32 1),
3760 imm:$rot, (VTI.Vec MQPR:$inactive),
3761 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
3762 (VTI.Pred VCCR:$mask))),
3763 (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
3764 imm:$rot, ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
3765 (VTI.Vec MQPR:$inactive)))>;
3770 defm MVE_VCADDf16 : MVE_VCADD_m<MVE_v8f16>;
3771 defm MVE_VCADDf32 : MVE_VCADD_m<MVE_v4f32, "@earlyclobber $Qd">;
3773 class MVE_VABD_fp<string suffix, bits<2> size>
3774 : MVE_float<"vabd", suffix, (outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm),
3775 "$Qd, $Qn, $Qm", vpred_r, "", size> {
3780 let Inst{25-23} = 0b110;
3781 let Inst{22} = Qd{3};
3783 let Inst{20} = size{0};
3784 let Inst{19-17} = Qn{2-0};
3786 let Inst{15-13} = Qd{2-0};
3787 let Inst{11-8} = 0b1101;
3788 let Inst{7} = Qn{3};
3790 let validForTailPredication = 1;
3793 multiclass MVE_VABDT_fp_m<MVEVectorVTInfo VTI,
3794 Intrinsic unpred_int, Intrinsic pred_int> {
3795 def "" : MVE_VABD_fp<VTI.Suffix, VTI.Size>;
3796 defvar Inst = !cast<Instruction>(NAME);
3798 let Predicates = [HasMVEFloat] in {
3799 def : Pat<(VTI.Vec (unpred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
3801 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
3802 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
3803 (i32 0), (VTI.Pred VCCR:$mask),
3804 (VTI.Vec MQPR:$inactive))),
3805 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
3806 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
3807 (VTI.Vec MQPR:$inactive)))>;
3811 multiclass MVE_VABD_fp_m<MVEVectorVTInfo VTI>
3812 : MVE_VABDT_fp_m<VTI, int_arm_mve_vabd, int_arm_mve_abd_predicated>;
3814 defm MVE_VABDf32 : MVE_VABD_fp_m<MVE_v4f32>;
3815 defm MVE_VABDf16 : MVE_VABD_fp_m<MVE_v8f16>;
3817 let Predicates = [HasMVEFloat] in {
3818 def : Pat<(v8f16 (fabs (fsub (v8f16 MQPR:$Qm), (v8f16 MQPR:$Qn)))),
3819 (MVE_VABDf16 MQPR:$Qm, MQPR:$Qn)>;
3820 def : Pat<(v4f32 (fabs (fsub (v4f32 MQPR:$Qm), (v4f32 MQPR:$Qn)))),
3821 (MVE_VABDf32 MQPR:$Qm, MQPR:$Qn)>;
3824 class MVE_VCVT_fix<string suffix, bit fsi, bit U, bit op,
3825 Operand imm_operand_type>
3826 : MVE_float<"vcvt", suffix,
3827 (outs MQPR:$Qd), (ins MQPR:$Qm, imm_operand_type:$imm6),
3828 "$Qd, $Qm, $imm6", vpred_r, "", !if(fsi, 0b10, 0b01), []> {
3833 let Inst{25-23} = 0b111;
3834 let Inst{22} = Qd{3};
3836 let Inst{19-16} = imm6{3-0};
3837 let Inst{15-13} = Qd{2-0};
3838 let Inst{11-10} = 0b11;
3844 let DecoderMethod = "DecodeMVEVCVTt1fp";
3845 let validForTailPredication = 1;
3848 class MVE_VCVT_imm_asmop<int Bits> : AsmOperandClass {
3849 let PredicateMethod = "isImmediate<1," # Bits # ">";
3850 let DiagnosticString =
3851 "MVE fixed-point immediate operand must be between 1 and " # Bits;
3852 let Name = "MVEVcvtImm" # Bits;
3853 let RenderMethod = "addImmOperands";
3855 class MVE_VCVT_imm<int Bits>: Operand<i32> {
3856 let ParserMatchClass = MVE_VCVT_imm_asmop<Bits>;
3857 let EncoderMethod = "getNEONVcvtImm32OpValue";
3858 let DecoderMethod = "DecodeVCVTImmOperand";
3861 class MVE_VCVT_fix_f32<string suffix, bit U, bit op>
3862 : MVE_VCVT_fix<suffix, 0b1, U, op, MVE_VCVT_imm<32>> {
3863 let Inst{20} = imm6{4};
3865 class MVE_VCVT_fix_f16<string suffix, bit U, bit op>
3866 : MVE_VCVT_fix<suffix, 0b0, U, op, MVE_VCVT_imm<16>> {
3870 multiclass MVE_VCVT_fix_patterns<Instruction Inst, bit U, MVEVectorVTInfo DestVTI,
3871 MVEVectorVTInfo SrcVTI> {
3872 let Predicates = [HasMVEFloat] in {
3873 def : Pat<(DestVTI.Vec (int_arm_mve_vcvt_fix
3874 (i32 U), (SrcVTI.Vec MQPR:$Qm), imm:$scale)),
3875 (DestVTI.Vec (Inst (SrcVTI.Vec MQPR:$Qm), imm:$scale))>;
3876 def : Pat<(DestVTI.Vec (int_arm_mve_vcvt_fix_predicated (i32 U),
3877 (DestVTI.Vec MQPR:$inactive),
3878 (SrcVTI.Vec MQPR:$Qm),
3880 (DestVTI.Pred VCCR:$mask))),
3881 (DestVTI.Vec (Inst (SrcVTI.Vec MQPR:$Qm), imm:$scale,
3882 ARMVCCThen, (DestVTI.Pred VCCR:$mask), zero_reg,
3883 (DestVTI.Vec MQPR:$inactive)))>;
3887 multiclass MVE_VCVT_fix_f32_m<bit U, bit op,
3888 MVEVectorVTInfo DestVTI, MVEVectorVTInfo SrcVTI> {
3889 def "" : MVE_VCVT_fix_f32<DestVTI.Suffix#"."#SrcVTI.Suffix, U, op>;
3890 defm : MVE_VCVT_fix_patterns<!cast<Instruction>(NAME), U, DestVTI, SrcVTI>;
3893 multiclass MVE_VCVT_fix_f16_m<bit U, bit op,
3894 MVEVectorVTInfo DestVTI, MVEVectorVTInfo SrcVTI> {
3895 def "" : MVE_VCVT_fix_f16<DestVTI.Suffix#"."#SrcVTI.Suffix, U, op>;
3896 defm : MVE_VCVT_fix_patterns<!cast<Instruction>(NAME), U, DestVTI, SrcVTI>;
3899 defm MVE_VCVTf16s16_fix : MVE_VCVT_fix_f16_m<0b0, 0b0, MVE_v8f16, MVE_v8s16>;
3900 defm MVE_VCVTs16f16_fix : MVE_VCVT_fix_f16_m<0b0, 0b1, MVE_v8s16, MVE_v8f16>;
3901 defm MVE_VCVTf16u16_fix : MVE_VCVT_fix_f16_m<0b1, 0b0, MVE_v8f16, MVE_v8u16>;
3902 defm MVE_VCVTu16f16_fix : MVE_VCVT_fix_f16_m<0b1, 0b1, MVE_v8u16, MVE_v8f16>;
3903 defm MVE_VCVTf32s32_fix : MVE_VCVT_fix_f32_m<0b0, 0b0, MVE_v4f32, MVE_v4s32>;
3904 defm MVE_VCVTs32f32_fix : MVE_VCVT_fix_f32_m<0b0, 0b1, MVE_v4s32, MVE_v4f32>;
3905 defm MVE_VCVTf32u32_fix : MVE_VCVT_fix_f32_m<0b1, 0b0, MVE_v4f32, MVE_v4u32>;
3906 defm MVE_VCVTu32f32_fix : MVE_VCVT_fix_f32_m<0b1, 0b1, MVE_v4u32, MVE_v4f32>;
3908 class MVE_VCVT_fp_int_anpm<string suffix, bits<2> size, bit op, string anpm,
3909 bits<2> rm, list<dag> pattern=[]>
3910 : MVE_float<!strconcat("vcvt", anpm), suffix, (outs MQPR:$Qd),
3911 (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", size, pattern> {
3915 let Inst{25-23} = 0b111;
3916 let Inst{22} = Qd{3};
3917 let Inst{21-20} = 0b11;
3918 let Inst{19-18} = size;
3919 let Inst{17-16} = 0b11;
3920 let Inst{15-13} = Qd{2-0};
3921 let Inst{12-10} = 0b000;
3925 let validForTailPredication = 1;
3928 multiclass MVE_VCVT_fp_int_anpm_inner<MVEVectorVTInfo Int, MVEVectorVTInfo Flt,
3929 string anpm, bits<2> rm> {
3930 def "": MVE_VCVT_fp_int_anpm<Int.Suffix # "." # Flt.Suffix, Int.Size,
3931 Int.Unsigned, anpm, rm>;
3933 defvar Inst = !cast<Instruction>(NAME);
3934 defvar IntrBaseName = "int_arm_mve_vcvt" # anpm;
3935 defvar UnpredIntr = !cast<Intrinsic>(IntrBaseName);
3936 defvar PredIntr = !cast<Intrinsic>(IntrBaseName # "_predicated");
3938 let Predicates = [HasMVEFloat] in {
3939 def : Pat<(Int.Vec (UnpredIntr (i32 Int.Unsigned), (Flt.Vec MQPR:$in))),
3940 (Int.Vec (Inst (Flt.Vec MQPR:$in)))>;
3942 def : Pat<(Int.Vec (PredIntr (i32 Int.Unsigned), (Int.Vec MQPR:$inactive),
3943 (Flt.Vec MQPR:$in), (Flt.Pred VCCR:$pred))),
3944 (Int.Vec (Inst (Flt.Vec MQPR:$in), ARMVCCThen,
3945 (Flt.Pred VCCR:$pred), zero_reg, (Int.Vec MQPR:$inactive)))>;
3949 multiclass MVE_VCVT_fp_int_anpm_outer<MVEVectorVTInfo Int,
3950 MVEVectorVTInfo Flt> {
3951 defm a : MVE_VCVT_fp_int_anpm_inner<Int, Flt, "a", 0b00>;
3952 defm n : MVE_VCVT_fp_int_anpm_inner<Int, Flt, "n", 0b01>;
3953 defm p : MVE_VCVT_fp_int_anpm_inner<Int, Flt, "p", 0b10>;
3954 defm m : MVE_VCVT_fp_int_anpm_inner<Int, Flt, "m", 0b11>;
3957 // This defines instructions such as MVE_VCVTu16f16a, with an explicit
3958 // rounding-mode suffix on the mnemonic. The class below will define
3959 // the bare MVE_VCVTu16f16 (with implied rounding toward zero).
3960 defm MVE_VCVTs16f16 : MVE_VCVT_fp_int_anpm_outer<MVE_v8s16, MVE_v8f16>;
3961 defm MVE_VCVTu16f16 : MVE_VCVT_fp_int_anpm_outer<MVE_v8u16, MVE_v8f16>;
3962 defm MVE_VCVTs32f32 : MVE_VCVT_fp_int_anpm_outer<MVE_v4s32, MVE_v4f32>;
3963 defm MVE_VCVTu32f32 : MVE_VCVT_fp_int_anpm_outer<MVE_v4u32, MVE_v4f32>;
3965 class MVE_VCVT_fp_int<string suffix, bits<2> size, bit toint, bit unsigned,
3966 list<dag> pattern=[]>
3967 : MVE_float<"vcvt", suffix, (outs MQPR:$Qd),
3968 (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", size, pattern> {
3972 let Inst{25-23} = 0b111;
3973 let Inst{22} = Qd{3};
3974 let Inst{21-20} = 0b11;
3975 let Inst{19-18} = size;
3976 let Inst{17-16} = 0b11;
3977 let Inst{15-13} = Qd{2-0};
3978 let Inst{12-9} = 0b0011;
3979 let Inst{8} = toint;
3980 let Inst{7} = unsigned;
3982 let validForTailPredication = 1;
3985 multiclass MVE_VCVT_fp_int_m<MVEVectorVTInfo Dest, MVEVectorVTInfo Src,
3987 defvar Unsigned = !or(!eq(Dest.SuffixLetter,"u"), !eq(Src.SuffixLetter,"u"));
3988 defvar ToInt = !eq(Src.SuffixLetter,"f");
3990 def "" : MVE_VCVT_fp_int<Dest.Suffix # "." # Src.Suffix, Dest.Size,
3992 defvar Inst = !cast<Instruction>(NAME);
3994 let Predicates = [HasMVEFloat] in {
3995 def : Pat<(Dest.Vec (unpred_op (Src.Vec MQPR:$src))),
3996 (Dest.Vec (Inst (Src.Vec MQPR:$src)))>;
3997 def : Pat<(Dest.Vec (int_arm_mve_vcvt_fp_int_predicated
3998 (Src.Vec MQPR:$src), (i32 Unsigned),
3999 (Src.Pred VCCR:$mask), (Dest.Vec MQPR:$inactive))),
4000 (Dest.Vec (Inst (Src.Vec MQPR:$src), ARMVCCThen,
4001 (Src.Pred VCCR:$mask), zero_reg,
4002 (Dest.Vec MQPR:$inactive)))>;
4005 // The unsuffixed VCVT for float->int implicitly rounds toward zero,
4006 // which I reflect here in the llvm instruction names
4007 defm MVE_VCVTs16f16z : MVE_VCVT_fp_int_m<MVE_v8s16, MVE_v8f16, fp_to_sint>;
4008 defm MVE_VCVTu16f16z : MVE_VCVT_fp_int_m<MVE_v8u16, MVE_v8f16, fp_to_uint>;
4009 defm MVE_VCVTs32f32z : MVE_VCVT_fp_int_m<MVE_v4s32, MVE_v4f32, fp_to_sint>;
4010 defm MVE_VCVTu32f32z : MVE_VCVT_fp_int_m<MVE_v4u32, MVE_v4f32, fp_to_uint>;
4011 // Whereas VCVT for int->float rounds to nearest
4012 defm MVE_VCVTf16s16n : MVE_VCVT_fp_int_m<MVE_v8f16, MVE_v8s16, sint_to_fp>;
4013 defm MVE_VCVTf16u16n : MVE_VCVT_fp_int_m<MVE_v8f16, MVE_v8u16, uint_to_fp>;
4014 defm MVE_VCVTf32s32n : MVE_VCVT_fp_int_m<MVE_v4f32, MVE_v4s32, sint_to_fp>;
4015 defm MVE_VCVTf32u32n : MVE_VCVT_fp_int_m<MVE_v4f32, MVE_v4u32, uint_to_fp>;
4017 let Predicates = [HasMVEFloat] in {
4018 def : Pat<(v4i32 (fp_to_sint_sat v4f32:$src, i32)),
4019 (MVE_VCVTs32f32z v4f32:$src)>;
4020 def : Pat<(v4i32 (fp_to_uint_sat v4f32:$src, i32)),
4021 (MVE_VCVTu32f32z v4f32:$src)>;
4022 def : Pat<(v8i16 (fp_to_sint_sat v8f16:$src, i16)),
4023 (MVE_VCVTs16f16z v8f16:$src)>;
4024 def : Pat<(v8i16 (fp_to_uint_sat v8f16:$src, i16)),
4025 (MVE_VCVTu16f16z v8f16:$src)>;
4028 class MVE_VABSNEG_fp<string iname, string suffix, bits<2> size, bit negate,
4029 list<dag> pattern=[]>
4030 : MVE_float<iname, suffix, (outs MQPR:$Qd),
4031 (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", size, pattern> {
4035 let Inst{25-23} = 0b111;
4036 let Inst{22} = Qd{3};
4037 let Inst{21-20} = 0b11;
4038 let Inst{19-18} = size;
4039 let Inst{17-16} = 0b01;
4040 let Inst{15-13} = Qd{2-0};
4041 let Inst{11-8} = 0b0111;
4042 let Inst{7} = negate;
4044 let validForTailPredication = 1;
4047 multiclass MVE_VABSNEG_fp_m<string iname, SDNode unpred_op, Intrinsic pred_int,
4048 MVEVectorVTInfo VTI, bit opcode> {
4049 def "" : MVE_VABSNEG_fp<iname, VTI.Suffix, VTI.Size, opcode>;
4050 defvar Inst = !cast<Instruction>(NAME);
4052 let Predicates = [HasMVEInt] in {
4053 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$v))),
4054 (VTI.Vec (Inst $v))>;
4055 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$v), (VTI.Pred VCCR:$mask),
4056 (VTI.Vec MQPR:$inactive))),
4057 (VTI.Vec (Inst $v, ARMVCCThen, $mask, zero_reg, $inactive))>;
4061 defm MVE_VABSf16 : MVE_VABSNEG_fp_m<"vabs", fabs, int_arm_mve_abs_predicated,
4063 defm MVE_VABSf32 : MVE_VABSNEG_fp_m<"vabs", fabs, int_arm_mve_abs_predicated,
4065 defm MVE_VNEGf16 : MVE_VABSNEG_fp_m<"vneg", fneg, int_arm_mve_neg_predicated,
4067 defm MVE_VNEGf32 : MVE_VABSNEG_fp_m<"vneg", fneg, int_arm_mve_neg_predicated,
4070 class MVE_VMAXMINNMA<string iname, string suffix, bits<2> size, bit bit_12,
4071 list<dag> pattern=[]>
4072 : MVE_f<(outs MQPR:$Qd), (ins MQPR:$Qd_src, MQPR:$Qm),
4073 NoItinerary, iname, suffix, "$Qd, $Qm", vpred_n, "$Qd = $Qd_src",
4078 let Inst{28} = size{0};
4079 let Inst{25-23} = 0b100;
4080 let Inst{22} = Qd{3};
4081 let Inst{21-16} = 0b111111;
4082 let Inst{15-13} = Qd{2-0};
4083 let Inst{12} = bit_12;
4084 let Inst{11-6} = 0b111010;
4085 let Inst{5} = Qm{3};
4087 let Inst{3-1} = Qm{2-0};
4090 let isCommutable = 1;
4091 let validForTailPredication = 1;
4094 multiclass MVE_VMAXMINNMA_m<string iname, MVEVectorVTInfo VTI,
4095 SDNode unpred_op, Intrinsic pred_int,
4097 def "" : MVE_VMAXMINNMA<iname, VTI.Suffix, VTI.Size, bit_12>;
4098 defvar Inst = !cast<Instruction>(NAME);
4100 let Predicates = [HasMVEInt] in {
4101 // Unpredicated v(max|min)nma
4102 def : Pat<(VTI.Vec (unpred_op (fabs (VTI.Vec MQPR:$Qd)),
4103 (fabs (VTI.Vec MQPR:$Qm)))),
4104 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm)))>;
4106 // Predicated v(max|min)nma
4107 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm),
4108 (VTI.Pred VCCR:$mask))),
4109 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm),
4110 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>;
4114 multiclass MVE_VMAXNMA<MVEVectorVTInfo VTI, bit bit_12>
4115 : MVE_VMAXMINNMA_m<"vmaxnma", VTI, fmaxnum, int_arm_mve_vmaxnma_predicated, bit_12>;
4117 defm MVE_VMAXNMAf32 : MVE_VMAXNMA<MVE_v4f32, 0b0>;
4118 defm MVE_VMAXNMAf16 : MVE_VMAXNMA<MVE_v8f16, 0b0>;
4120 multiclass MVE_VMINNMA<MVEVectorVTInfo VTI, bit bit_12>
4121 : MVE_VMAXMINNMA_m<"vminnma", VTI, fminnum, int_arm_mve_vminnma_predicated, bit_12>;
4123 defm MVE_VMINNMAf32 : MVE_VMINNMA<MVE_v4f32, 0b1>;
4124 defm MVE_VMINNMAf16 : MVE_VMINNMA<MVE_v8f16, 0b1>;
4126 // end of MVE Floating Point instructions
4128 // start of MVE compares
4130 class MVE_VCMPqq<string suffix, bit bit_28, bits<2> bits_21_20,
4131 VCMPPredicateOperand predtype, bits<2> vecsize, list<dag> pattern=[]>
4132 : MVE_p<(outs VCCR:$P0), (ins MQPR:$Qn, MQPR:$Qm, predtype:$fc),
4133 NoItinerary, "vcmp", suffix, "$fc, $Qn, $Qm", vpred_n, "", vecsize, pattern> {
4134 // Base class for comparing two vector registers
4139 let Inst{28} = bit_28;
4140 let Inst{25-22} = 0b1000;
4141 let Inst{21-20} = bits_21_20;
4142 let Inst{19-17} = Qn{2-0};
4143 let Inst{16-13} = 0b1000;
4144 let Inst{12} = fc{2};
4145 let Inst{11-8} = 0b1111;
4146 let Inst{7} = fc{0};
4148 let Inst{5} = Qm{3};
4150 let Inst{3-1} = Qm{2-0};
4151 let Inst{0} = fc{1};
4153 let Constraints = "";
4155 // We need a custom decoder method for these instructions because of
4156 // the output VCCR operand, which isn't encoded in the instruction
4157 // bits anywhere (there is only one choice for it) but has to be
4158 // included in the MC operands so that codegen will be able to track
4159 // its data flow between instructions, spill/reload it when
4160 // necessary, etc. There seems to be no way to get the Tablegen
4161 // decoder to emit an operand that isn't affected by any instruction
4163 let DecoderMethod = "DecodeMVEVCMP<false," # predtype.DecoderMethod # ">";
4164 let validForTailPredication = 1;
4167 class MVE_VCMPqqf<string suffix, bit size>
4168 : MVE_VCMPqq<suffix, size, 0b11, pred_basic_fp, !if(size, 0b01, 0b10)> {
4169 let Predicates = [HasMVEFloat];
4172 class MVE_VCMPqqi<string suffix, bits<2> size>
4173 : MVE_VCMPqq<suffix, 0b1, size, pred_basic_i, size> {
4178 class MVE_VCMPqqu<string suffix, bits<2> size>
4179 : MVE_VCMPqq<suffix, 0b1, size, pred_basic_u, size> {
4184 class MVE_VCMPqqs<string suffix, bits<2> size>
4185 : MVE_VCMPqq<suffix, 0b1, size, pred_basic_s, size> {
4189 def MVE_VCMPf32 : MVE_VCMPqqf<"f32", 0b0>;
4190 def MVE_VCMPf16 : MVE_VCMPqqf<"f16", 0b1>;
4192 def MVE_VCMPi8 : MVE_VCMPqqi<"i8", 0b00>;
4193 def MVE_VCMPi16 : MVE_VCMPqqi<"i16", 0b01>;
4194 def MVE_VCMPi32 : MVE_VCMPqqi<"i32", 0b10>;
4196 def MVE_VCMPu8 : MVE_VCMPqqu<"u8", 0b00>;
4197 def MVE_VCMPu16 : MVE_VCMPqqu<"u16", 0b01>;
4198 def MVE_VCMPu32 : MVE_VCMPqqu<"u32", 0b10>;
4200 def MVE_VCMPs8 : MVE_VCMPqqs<"s8", 0b00>;
4201 def MVE_VCMPs16 : MVE_VCMPqqs<"s16", 0b01>;
4202 def MVE_VCMPs32 : MVE_VCMPqqs<"s32", 0b10>;
4204 class MVE_VCMPqr<string suffix, bit bit_28, bits<2> bits_21_20,
4205 VCMPPredicateOperand predtype, bits<2> vecsize, list<dag> pattern=[]>
4206 : MVE_p<(outs VCCR:$P0), (ins MQPR:$Qn, GPRwithZR:$Rm, predtype:$fc),
4207 NoItinerary, "vcmp", suffix, "$fc, $Qn, $Rm", vpred_n, "", vecsize, pattern> {
4208 // Base class for comparing a vector register with a scalar
4213 let Inst{28} = bit_28;
4214 let Inst{25-22} = 0b1000;
4215 let Inst{21-20} = bits_21_20;
4216 let Inst{19-17} = Qn{2-0};
4217 let Inst{16-13} = 0b1000;
4218 let Inst{12} = fc{2};
4219 let Inst{11-8} = 0b1111;
4220 let Inst{7} = fc{0};
4222 let Inst{5} = fc{1};
4224 let Inst{3-0} = Rm{3-0};
4226 let Constraints = "";
4227 // Custom decoder method, for the same reason as MVE_VCMPqq
4228 let DecoderMethod = "DecodeMVEVCMP<true," # predtype.DecoderMethod # ">";
4229 let validForTailPredication = 1;
4232 class MVE_VCMPqrf<string suffix, bit size>
4233 : MVE_VCMPqr<suffix, size, 0b11, pred_basic_fp, !if(size, 0b01, 0b10)> {
4234 let Predicates = [HasMVEFloat];
4237 class MVE_VCMPqri<string suffix, bits<2> size>
4238 : MVE_VCMPqr<suffix, 0b1, size, pred_basic_i, size> {
4243 class MVE_VCMPqru<string suffix, bits<2> size>
4244 : MVE_VCMPqr<suffix, 0b1, size, pred_basic_u, size> {
4249 class MVE_VCMPqrs<string suffix, bits<2> size>
4250 : MVE_VCMPqr<suffix, 0b1, size, pred_basic_s, size> {
4254 def MVE_VCMPf32r : MVE_VCMPqrf<"f32", 0b0>;
4255 def MVE_VCMPf16r : MVE_VCMPqrf<"f16", 0b1>;
4257 def MVE_VCMPi8r : MVE_VCMPqri<"i8", 0b00>;
4258 def MVE_VCMPi16r : MVE_VCMPqri<"i16", 0b01>;
4259 def MVE_VCMPi32r : MVE_VCMPqri<"i32", 0b10>;
4261 def MVE_VCMPu8r : MVE_VCMPqru<"u8", 0b00>;
4262 def MVE_VCMPu16r : MVE_VCMPqru<"u16", 0b01>;
4263 def MVE_VCMPu32r : MVE_VCMPqru<"u32", 0b10>;
4265 def MVE_VCMPs8r : MVE_VCMPqrs<"s8", 0b00>;
4266 def MVE_VCMPs16r : MVE_VCMPqrs<"s16", 0b01>;
4267 def MVE_VCMPs32r : MVE_VCMPqrs<"s32", 0b10>;
4269 multiclass unpred_vcmp_z<string suffix, PatLeaf fc> {
4270 def i8 : Pat<(v16i1 (ARMvcmpz (v16i8 MQPR:$v1), fc)),
4271 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), ZR, fc))>;
4272 def i16 : Pat<(v8i1 (ARMvcmpz (v8i16 MQPR:$v1), fc)),
4273 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), ZR, fc))>;
4274 def i32 : Pat<(v4i1 (ARMvcmpz (v4i32 MQPR:$v1), fc)),
4275 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), ZR, fc))>;
4277 def : Pat<(v16i1 (and (v16i1 VCCR:$p1), (v16i1 (ARMvcmpz (v16i8 MQPR:$v1), fc)))),
4278 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), ZR, fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
4279 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmpz (v8i16 MQPR:$v1), fc)))),
4280 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), ZR, fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
4281 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmpz (v4i32 MQPR:$v1), fc)))),
4282 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), ZR, fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
4285 multiclass unpred_vcmp_r<string suffix, PatLeaf fc> {
4286 def i8 : Pat<(v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), fc)),
4287 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8") (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), fc))>;
4288 def i16 : Pat<(v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), fc)),
4289 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16") (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), fc))>;
4290 def i32 : Pat<(v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), fc)),
4291 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32") (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), fc))>;
4293 def i8r : Pat<(v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 (ARMvdup rGPR:$v2)), fc)),
4294 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), (i32 rGPR:$v2), fc))>;
4295 def i16r : Pat<(v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 (ARMvdup rGPR:$v2)), fc)),
4296 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), (i32 rGPR:$v2), fc))>;
4297 def i32r : Pat<(v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 (ARMvdup rGPR:$v2)), fc)),
4298 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), (i32 rGPR:$v2), fc))>;
4300 def : Pat<(v16i1 (and (v16i1 VCCR:$p1), (v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), fc)))),
4301 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8") (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
4302 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), fc)))),
4303 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16") (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
4304 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), fc)))),
4305 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32") (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
4307 def : Pat<(v16i1 (and (v16i1 VCCR:$p1), (v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 (ARMvdup rGPR:$v2)), fc)))),
4308 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), (i32 rGPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
4309 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 (ARMvdup rGPR:$v2)), fc)))),
4310 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), (i32 rGPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
4311 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 (ARMvdup rGPR:$v2)), fc)))),
4312 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), (i32 rGPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
4315 multiclass unpred_vcmpf_z<PatLeaf fc> {
4316 def f16 : Pat<(v8i1 (ARMvcmpz (v8f16 MQPR:$v1), fc)),
4317 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), ZR, fc))>;
4318 def f32 : Pat<(v4i1 (ARMvcmpz (v4f32 MQPR:$v1), fc)),
4319 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, fc))>;
4321 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmpz (v8f16 MQPR:$v1), fc)))),
4322 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), ZR, fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
4323 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmpz (v4f32 MQPR:$v1), fc)))),
4324 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
4327 multiclass unpred_vcmpf_r<PatLeaf fc> {
4328 def : Pat<(v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), fc)),
4329 (v8i1 (MVE_VCMPf16 (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), fc))>;
4330 def : Pat<(v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), fc)),
4331 (v4i1 (MVE_VCMPf32 (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), fc))>;
4333 def : Pat<(v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 (ARMvdup rGPR:$v2)), fc)),
4334 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), (i32 rGPR:$v2), fc))>;
4335 def : Pat<(v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 (ARMvdup rGPR:$v2)), fc)),
4336 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), (i32 rGPR:$v2), fc))>;
4338 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), fc)))),
4339 (v8i1 (MVE_VCMPf16 (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
4340 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), fc)))),
4341 (v4i1 (MVE_VCMPf32 (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
4343 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 (ARMvdup rGPR:$v2)), fc)))),
4344 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), (i32 rGPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
4345 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 (ARMvdup rGPR:$v2)), fc)))),
4346 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), (i32 rGPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>;
4349 let Predicates = [HasMVEInt] in {
4350 defm MVE_VCEQZ : unpred_vcmp_z<"i", ARMCCeq>;
4351 defm MVE_VCNEZ : unpred_vcmp_z<"i", ARMCCne>;
4352 defm MVE_VCGEZ : unpred_vcmp_z<"s", ARMCCge>;
4353 defm MVE_VCLTZ : unpred_vcmp_z<"s", ARMCClt>;
4354 defm MVE_VCGTZ : unpred_vcmp_z<"s", ARMCCgt>;
4355 defm MVE_VCLEZ : unpred_vcmp_z<"s", ARMCCle>;
4356 defm MVE_VCGTUZ : unpred_vcmp_z<"u", ARMCChi>;
4357 defm MVE_VCGEUZ : unpred_vcmp_z<"u", ARMCChs>;
4359 defm MVE_VCEQ : unpred_vcmp_r<"i", ARMCCeq>;
4360 defm MVE_VCNE : unpred_vcmp_r<"i", ARMCCne>;
4361 defm MVE_VCGE : unpred_vcmp_r<"s", ARMCCge>;
4362 defm MVE_VCLT : unpred_vcmp_r<"s", ARMCClt>;
4363 defm MVE_VCGT : unpred_vcmp_r<"s", ARMCCgt>;
4364 defm MVE_VCLE : unpred_vcmp_r<"s", ARMCCle>;
4365 defm MVE_VCGTU : unpred_vcmp_r<"u", ARMCChi>;
4366 defm MVE_VCGEU : unpred_vcmp_r<"u", ARMCChs>;
4369 let Predicates = [HasMVEFloat] in {
4370 defm MVE_VFCEQZ : unpred_vcmpf_z<ARMCCeq>;
4371 defm MVE_VFCNEZ : unpred_vcmpf_z<ARMCCne>;
4372 defm MVE_VFCGEZ : unpred_vcmpf_z<ARMCCge>;
4373 defm MVE_VFCLTZ : unpred_vcmpf_z<ARMCClt>;
4374 defm MVE_VFCGTZ : unpred_vcmpf_z<ARMCCgt>;
4375 defm MVE_VFCLEZ : unpred_vcmpf_z<ARMCCle>;
4377 defm MVE_VFCEQ : unpred_vcmpf_r<ARMCCeq>;
4378 defm MVE_VFCNE : unpred_vcmpf_r<ARMCCne>;
4379 defm MVE_VFCGE : unpred_vcmpf_r<ARMCCge>;
4380 defm MVE_VFCLT : unpred_vcmpf_r<ARMCClt>;
4381 defm MVE_VFCGT : unpred_vcmpf_r<ARMCCgt>;
4382 defm MVE_VFCLE : unpred_vcmpf_r<ARMCCle>;
4386 // Extra "worst case" and/or/xor patterns, going into and out of GRP
4387 multiclass two_predops<SDPatternOperator opnode, Instruction insn> {
4388 def v16i1 : Pat<(v16i1 (opnode (v16i1 VCCR:$p1), (v16i1 VCCR:$p2))),
4389 (v16i1 (COPY_TO_REGCLASS
4390 (insn (i32 (COPY_TO_REGCLASS (v16i1 VCCR:$p1), rGPR)),
4391 (i32 (COPY_TO_REGCLASS (v16i1 VCCR:$p2), rGPR))),
4393 def v8i1 : Pat<(v8i1 (opnode (v8i1 VCCR:$p1), (v8i1 VCCR:$p2))),
4394 (v8i1 (COPY_TO_REGCLASS
4395 (insn (i32 (COPY_TO_REGCLASS (v8i1 VCCR:$p1), rGPR)),
4396 (i32 (COPY_TO_REGCLASS (v8i1 VCCR:$p2), rGPR))),
4398 def v4i1 : Pat<(v4i1 (opnode (v4i1 VCCR:$p1), (v4i1 VCCR:$p2))),
4399 (v4i1 (COPY_TO_REGCLASS
4400 (insn (i32 (COPY_TO_REGCLASS (v4i1 VCCR:$p1), rGPR)),
4401 (i32 (COPY_TO_REGCLASS (v4i1 VCCR:$p2), rGPR))),
4403 def v2i1 : Pat<(v2i1 (opnode (v2i1 VCCR:$p1), (v2i1 VCCR:$p2))),
4404 (v2i1 (COPY_TO_REGCLASS
4405 (insn (i32 (COPY_TO_REGCLASS (v2i1 VCCR:$p1), rGPR)),
4406 (i32 (COPY_TO_REGCLASS (v2i1 VCCR:$p2), rGPR))),
4410 let Predicates = [HasMVEInt] in {
4411 defm POR : two_predops<or, t2ORRrr>;
4412 defm PAND : two_predops<and, t2ANDrr>;
4413 defm PEOR : two_predops<xor, t2EORrr>;
4416 // Occasionally we need to cast between a i32 and a boolean vector, for
4417 // example when moving between rGPR and VPR.P0 as part of predicate vector
4418 // shuffles. We also sometimes need to cast between different predicate
4419 // vector types (v4i1<>v8i1, etc.) also as part of lowering vector shuffles.
4420 def predicate_cast : SDNode<"ARMISD::PREDICATE_CAST", SDTUnaryOp>;
4422 def load_align4 : PatFrag<(ops node:$ptr), (load node:$ptr), [{
4423 return cast<LoadSDNode>(N)->getAlign() >= 4;
4426 let Predicates = [HasMVEInt] in {
4427 foreach VT = [ v2i1, v4i1, v8i1, v16i1 ] in {
4428 def : Pat<(i32 (predicate_cast (VT VCCR:$src))),
4429 (i32 (COPY_TO_REGCLASS (VT VCCR:$src), VCCR))>;
4430 def : Pat<(VT (predicate_cast (i32 VCCR:$src))),
4431 (VT (COPY_TO_REGCLASS (i32 VCCR:$src), VCCR))>;
4433 foreach VT2 = [ v2i1, v4i1, v8i1, v16i1 ] in
4434 def : Pat<(VT (predicate_cast (VT2 VCCR:$src))),
4435 (VT (COPY_TO_REGCLASS (VT2 VCCR:$src), VCCR))>;
4438 // If we happen to be casting from a load we can convert that straight
4439 // into a predicate load, so long as the load is of the correct type.
4440 foreach VT = [ v2i1, v4i1, v8i1, v16i1 ] in {
4441 def : Pat<(VT (predicate_cast (i32 (load_align4 taddrmode_imm7<2>:$addr)))),
4442 (VT (VLDR_P0_off taddrmode_imm7<2>:$addr))>;
4445 // Here we match the specific SDNode type 'ARMVectorRegCastImpl'
4446 // rather than the more general 'ARMVectorRegCast' which would also
4447 // match some bitconverts. If we use the latter in cases where the
4448 // input and output types are the same, the bitconvert gets elided
4449 // and we end up generating a nonsense match of nothing.
4451 foreach VT = [ v16i8, v8i16, v8f16, v4i32, v4f32, v2i64, v2f64 ] in
4452 foreach VT2 = [ v16i8, v8i16, v8f16, v4i32, v4f32, v2i64, v2f64 ] in
4453 def : Pat<(VT (ARMVectorRegCastImpl (VT2 MQPR:$src))),
4457 // end of MVE compares
4459 // start of MVE_qDest_qSrc
4461 class MVE_qDest_qSrc<string iname, string suffix, dag oops, dag iops,
4462 string ops, vpred_ops vpred, string cstr,
4463 bits<2> vecsize, list<dag> pattern=[]>
4464 : MVE_p<oops, iops, NoItinerary, iname, suffix,
4465 ops, vpred, cstr, vecsize, pattern> {
4469 let Inst{25-23} = 0b100;
4470 let Inst{22} = Qd{3};
4471 let Inst{15-13} = Qd{2-0};
4472 let Inst{11-9} = 0b111;
4474 let Inst{5} = Qm{3};
4476 let Inst{3-1} = Qm{2-0};
4479 class MVE_VQxDMLxDH<string iname, bit exch, bit round, bit subtract,
4480 string suffix, bits<2> size, string cstr="",
4481 list<dag> pattern=[]>
4482 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
4483 (ins MQPR:$Qd_src, MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm",
4484 vpred_n, "$Qd = $Qd_src"#cstr, size, pattern> {
4487 let Inst{28} = subtract;
4488 let Inst{21-20} = size;
4489 let Inst{19-17} = Qn{2-0};
4491 let Inst{12} = exch;
4493 let Inst{7} = Qn{3};
4494 let Inst{0} = round;
4497 multiclass MVE_VQxDMLxDH_p<string iname, bit exch, bit round, bit subtract,
4498 MVEVectorVTInfo VTI> {
4499 def "": MVE_VQxDMLxDH<iname, exch, round, subtract, VTI.Suffix, VTI.Size,
4500 !if(!eq(VTI.LaneBits, 32), ",@earlyclobber $Qd", "")>;
4501 defvar Inst = !cast<Instruction>(NAME);
4502 defvar ConstParams = (? (i32 exch), (i32 round), (i32 subtract));
4503 defvar unpred_intr = int_arm_mve_vqdmlad;
4504 defvar pred_intr = int_arm_mve_vqdmlad_predicated;
4506 def : Pat<(VTI.Vec !con((unpred_intr (VTI.Vec MQPR:$a), (VTI.Vec MQPR:$b),
4507 (VTI.Vec MQPR:$c)), ConstParams)),
4508 (VTI.Vec (Inst (VTI.Vec MQPR:$a), (VTI.Vec MQPR:$b),
4509 (VTI.Vec MQPR:$c)))>;
4510 def : Pat<(VTI.Vec !con((pred_intr (VTI.Vec MQPR:$a), (VTI.Vec MQPR:$b),
4511 (VTI.Vec MQPR:$c)), ConstParams,
4512 (? (VTI.Pred VCCR:$pred)))),
4513 (VTI.Vec (Inst (VTI.Vec MQPR:$a), (VTI.Vec MQPR:$b),
4515 ARMVCCThen, (VTI.Pred VCCR:$pred), zero_reg))>;
4518 multiclass MVE_VQxDMLxDH_multi<string iname, bit exch,
4519 bit round, bit subtract> {
4520 defm s8 : MVE_VQxDMLxDH_p<iname, exch, round, subtract, MVE_v16s8>;
4521 defm s16 : MVE_VQxDMLxDH_p<iname, exch, round, subtract, MVE_v8s16>;
4522 defm s32 : MVE_VQxDMLxDH_p<iname, exch, round, subtract, MVE_v4s32>;
4525 defm MVE_VQDMLADH : MVE_VQxDMLxDH_multi<"vqdmladh", 0b0, 0b0, 0b0>;
4526 defm MVE_VQDMLADHX : MVE_VQxDMLxDH_multi<"vqdmladhx", 0b1, 0b0, 0b0>;
4527 defm MVE_VQRDMLADH : MVE_VQxDMLxDH_multi<"vqrdmladh", 0b0, 0b1, 0b0>;
4528 defm MVE_VQRDMLADHX : MVE_VQxDMLxDH_multi<"vqrdmladhx", 0b1, 0b1, 0b0>;
4529 defm MVE_VQDMLSDH : MVE_VQxDMLxDH_multi<"vqdmlsdh", 0b0, 0b0, 0b1>;
4530 defm MVE_VQDMLSDHX : MVE_VQxDMLxDH_multi<"vqdmlsdhx", 0b1, 0b0, 0b1>;
4531 defm MVE_VQRDMLSDH : MVE_VQxDMLxDH_multi<"vqrdmlsdh", 0b0, 0b1, 0b1>;
4532 defm MVE_VQRDMLSDHX : MVE_VQxDMLxDH_multi<"vqrdmlsdhx", 0b1, 0b1, 0b1>;
4534 class MVE_VCMUL<string iname, string suffix, bits<2> size, string cstr="">
4535 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
4536 (ins MQPR:$Qn, MQPR:$Qm, complexrotateop:$rot),
4537 "$Qd, $Qn, $Qm, $rot", vpred_r, cstr, size,
4542 let Inst{28} = size{1};
4543 let Inst{21-20} = 0b11;
4544 let Inst{19-17} = Qn{2-0};
4546 let Inst{12} = rot{1};
4548 let Inst{7} = Qn{3};
4549 let Inst{0} = rot{0};
4551 let Predicates = [HasMVEFloat];
4554 multiclass MVE_VCMUL_m<string iname, MVEVectorVTInfo VTI,
4556 def "" : MVE_VCMUL<iname, VTI.Suffix, VTI.Size, cstr>;
4557 defvar Inst = !cast<Instruction>(NAME);
4559 let Predicates = [HasMVEFloat] in {
4560 def : Pat<(VTI.Vec (int_arm_mve_vcmulq
4561 imm:$rot, (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))),
4562 (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
4565 def : Pat<(VTI.Vec (int_arm_mve_vcmulq_predicated
4566 imm:$rot, (VTI.Vec MQPR:$inactive),
4567 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
4568 (VTI.Pred VCCR:$mask))),
4569 (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
4570 imm:$rot, ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
4571 (VTI.Vec MQPR:$inactive)))>;
4576 defm MVE_VCMULf16 : MVE_VCMUL_m<"vcmul", MVE_v8f16>;
4577 defm MVE_VCMULf32 : MVE_VCMUL_m<"vcmul", MVE_v4f32, "@earlyclobber $Qd">;
4579 class MVE_VMULL<string iname, string suffix, bit bit_28, bits<2> bits_21_20,
4580 bit T, string cstr, bits<2> vecsize, list<dag> pattern=[]>
4581 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
4582 (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm",
4583 vpred_r, cstr, vecsize, pattern> {
4588 let Inst{28} = bit_28;
4589 let Inst{21-20} = bits_21_20;
4590 let Inst{19-17} = Qn{2-0};
4594 let Inst{7} = Qn{3};
4596 let validForTailPredication = 1;
4597 let doubleWidthResult = 1;
4600 multiclass MVE_VMULL_m<MVEVectorVTInfo VTI,
4601 SDPatternOperator unpred_op, Intrinsic pred_int,
4602 bit Top, bits<2> vecsize, string cstr=""> {
4603 def "" : MVE_VMULL<"vmull" # !if(Top, "t", "b"), VTI.Suffix, VTI.Unsigned,
4604 VTI.Size, Top, cstr, vecsize>;
4605 defvar Inst = !cast<Instruction>(NAME);
4607 let Predicates = [HasMVEInt] in {
4608 defvar uflag = !if(!eq(VTI.SuffixLetter, "p"), (?), (? (i32 VTI.Unsigned)));
4610 // Unpredicated multiply
4611 def : Pat<(VTI.DblVec !con((unpred_op (VTI.Vec MQPR:$Qm),
4612 (VTI.Vec MQPR:$Qn)),
4613 uflag, (? (i32 Top)))),
4614 (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
4616 // Predicated multiply
4617 def : Pat<(VTI.DblVec !con((pred_int (VTI.Vec MQPR:$Qm),
4618 (VTI.Vec MQPR:$Qn)),
4619 uflag, (? (i32 Top), (VTI.DblPred VCCR:$mask),
4620 (VTI.DblVec MQPR:$inactive)))),
4621 (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
4622 ARMVCCThen, (VTI.DblPred VCCR:$mask), zero_reg,
4623 (VTI.DblVec MQPR:$inactive)))>;
4627 // For polynomial multiplies, the size bits take the unused value 0b11, and
4628 // the unsigned bit switches to encoding the size.
4630 defm MVE_VMULLBs8 : MVE_VMULL_m<MVE_v16s8, int_arm_mve_vmull,
4631 int_arm_mve_mull_int_predicated, 0b0, 0b01>;
4632 defm MVE_VMULLTs8 : MVE_VMULL_m<MVE_v16s8, int_arm_mve_vmull,
4633 int_arm_mve_mull_int_predicated, 0b1, 0b01>;
4634 defm MVE_VMULLBs16 : MVE_VMULL_m<MVE_v8s16, int_arm_mve_vmull,
4635 int_arm_mve_mull_int_predicated, 0b0, 0b10>;
4636 defm MVE_VMULLTs16 : MVE_VMULL_m<MVE_v8s16, int_arm_mve_vmull,
4637 int_arm_mve_mull_int_predicated, 0b1, 0b10>;
4638 defm MVE_VMULLBs32 : MVE_VMULL_m<MVE_v4s32, int_arm_mve_vmull,
4639 int_arm_mve_mull_int_predicated, 0b0, 0b11,
4640 "@earlyclobber $Qd">;
4641 defm MVE_VMULLTs32 : MVE_VMULL_m<MVE_v4s32, int_arm_mve_vmull,
4642 int_arm_mve_mull_int_predicated, 0b1, 0b11,
4643 "@earlyclobber $Qd">;
4645 defm MVE_VMULLBu8 : MVE_VMULL_m<MVE_v16u8, int_arm_mve_vmull,
4646 int_arm_mve_mull_int_predicated, 0b0, 0b01>;
4647 defm MVE_VMULLTu8 : MVE_VMULL_m<MVE_v16u8, int_arm_mve_vmull,
4648 int_arm_mve_mull_int_predicated, 0b1, 0b01>;
4649 defm MVE_VMULLBu16 : MVE_VMULL_m<MVE_v8u16, int_arm_mve_vmull,
4650 int_arm_mve_mull_int_predicated, 0b0, 0b10>;
4651 defm MVE_VMULLTu16 : MVE_VMULL_m<MVE_v8u16, int_arm_mve_vmull,
4652 int_arm_mve_mull_int_predicated, 0b1, 0b10>;
4653 defm MVE_VMULLBu32 : MVE_VMULL_m<MVE_v4u32, int_arm_mve_vmull,
4654 int_arm_mve_mull_int_predicated, 0b0, 0b11,
4655 "@earlyclobber $Qd">;
4656 defm MVE_VMULLTu32 : MVE_VMULL_m<MVE_v4u32, int_arm_mve_vmull,
4657 int_arm_mve_mull_int_predicated, 0b1, 0b11,
4658 "@earlyclobber $Qd">;
4660 defm MVE_VMULLBp8 : MVE_VMULL_m<MVE_v16p8, int_arm_mve_vmull_poly,
4661 int_arm_mve_mull_poly_predicated, 0b0, 0b01>;
4662 defm MVE_VMULLTp8 : MVE_VMULL_m<MVE_v16p8, int_arm_mve_vmull_poly,
4663 int_arm_mve_mull_poly_predicated, 0b1, 0b01>;
4664 defm MVE_VMULLBp16 : MVE_VMULL_m<MVE_v8p16, int_arm_mve_vmull_poly,
4665 int_arm_mve_mull_poly_predicated, 0b0, 0b10>;
4666 defm MVE_VMULLTp16 : MVE_VMULL_m<MVE_v8p16, int_arm_mve_vmull_poly,
4667 int_arm_mve_mull_poly_predicated, 0b1, 0b10>;
4669 let Predicates = [HasMVEInt] in {
4670 def : Pat<(v2i64 (ARMvmulls (v4i32 MQPR:$src1), (v4i32 MQPR:$src2))),
4671 (MVE_VMULLBs32 MQPR:$src1, MQPR:$src2)>;
4672 def : Pat<(v2i64 (ARMvmulls (v4i32 (ARMvrev64 (v4i32 MQPR:$src1))),
4673 (v4i32 (ARMvrev64 (v4i32 MQPR:$src2))))),
4674 (MVE_VMULLTs32 MQPR:$src1, MQPR:$src2)>;
4676 def : Pat<(mul (sext_inreg (v4i32 MQPR:$src1), v4i16),
4677 (sext_inreg (v4i32 MQPR:$src2), v4i16)),
4678 (MVE_VMULLBs16 MQPR:$src1, MQPR:$src2)>;
4679 def : Pat<(mul (sext_inreg (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src1)))), v4i16),
4680 (sext_inreg (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src2)))), v4i16)),
4681 (MVE_VMULLTs16 MQPR:$src1, MQPR:$src2)>;
4683 def : Pat<(mul (sext_inreg (v8i16 MQPR:$src1), v8i8),
4684 (sext_inreg (v8i16 MQPR:$src2), v8i8)),
4685 (MVE_VMULLBs8 MQPR:$src1, MQPR:$src2)>;
4686 def : Pat<(mul (sext_inreg (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src1)))), v8i8),
4687 (sext_inreg (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src2)))), v8i8)),
4688 (MVE_VMULLTs8 MQPR:$src1, MQPR:$src2)>;
4690 def : Pat<(v2i64 (ARMvmullu (v4i32 MQPR:$src1), (v4i32 MQPR:$src2))),
4691 (MVE_VMULLBu32 MQPR:$src1, MQPR:$src2)>;
4692 def : Pat<(v2i64 (ARMvmullu (v4i32 (ARMvrev64 (v4i32 MQPR:$src1))),
4693 (v4i32 (ARMvrev64 (v4i32 MQPR:$src2))))),
4694 (MVE_VMULLTu32 MQPR:$src1, MQPR:$src2)>;
4696 def : Pat<(mul (and (v4i32 MQPR:$src1), (v4i32 (ARMvmovImm (i32 0xCFF)))),
4697 (and (v4i32 MQPR:$src2), (v4i32 (ARMvmovImm (i32 0xCFF))))),
4698 (MVE_VMULLBu16 MQPR:$src1, MQPR:$src2)>;
4699 def : Pat<(mul (and (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src1)))),
4700 (v4i32 (ARMvmovImm (i32 0xCFF)))),
4701 (and (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src2)))),
4702 (v4i32 (ARMvmovImm (i32 0xCFF))))),
4703 (MVE_VMULLTu16 MQPR:$src1, MQPR:$src2)>;
4705 def : Pat<(mul (ARMvbicImm (v8i16 MQPR:$src1), (i32 0xAFF)),
4706 (ARMvbicImm (v8i16 MQPR:$src2), (i32 0xAFF))),
4707 (MVE_VMULLBu8 MQPR:$src1, MQPR:$src2)>;
4708 def : Pat<(mul (ARMvbicImm (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src1)))), (i32 0xAFF)),
4709 (ARMvbicImm (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src2)))), (i32 0xAFF))),
4710 (MVE_VMULLTu8 MQPR:$src1, MQPR:$src2)>;
4713 class MVE_VxMULH<string iname, string suffix, bit U, bits<2> size, bit round,
4714 list<dag> pattern=[]>
4715 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
4716 (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm",
4717 vpred_r, "", size, pattern> {
4721 let Inst{21-20} = size;
4722 let Inst{19-17} = Qn{2-0};
4724 let Inst{12} = round;
4726 let Inst{7} = Qn{3};
4728 let validForTailPredication = 1;
4731 multiclass MVE_VxMULH_m<string iname, MVEVectorVTInfo VTI, SDPatternOperator unpred_op,
4732 Intrinsic PredInt, bit round> {
4733 def "" : MVE_VxMULH<iname, VTI.Suffix, VTI.Unsigned, VTI.Size, round>;
4734 defvar Inst = !cast<Instruction>(NAME);
4736 let Predicates = [HasMVEInt] in {
4737 if !eq(round, 0b0) then {
4738 defvar mulh = !if(VTI.Unsigned, mulhu, mulhs);
4739 defm : MVE_TwoOpPattern<VTI, mulh, PredInt, (? (i32 VTI.Unsigned)),
4740 !cast<Instruction>(NAME)>;
4742 // Predicated multiply returning high bits
4743 def : Pat<(VTI.Vec (PredInt (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
4744 (i32 VTI.Unsigned), (VTI.Pred VCCR:$mask),
4745 (VTI.Vec MQPR:$inactive))),
4746 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
4747 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
4748 (VTI.Vec MQPR:$inactive)))>;
4751 // Unpredicated intrinsic
4752 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
4753 (i32 VTI.Unsigned))),
4754 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
4758 multiclass MVE_VMULT<string iname, MVEVectorVTInfo VTI, bit round>
4759 : MVE_VxMULH_m<iname, VTI, !if(round, int_arm_mve_vrmulh, int_arm_mve_vmulh),
4760 !if(round, int_arm_mve_rmulh_predicated,
4761 int_arm_mve_mulh_predicated),
4764 defm MVE_VMULHs8 : MVE_VMULT<"vmulh", MVE_v16s8, 0b0>;
4765 defm MVE_VMULHs16 : MVE_VMULT<"vmulh", MVE_v8s16, 0b0>;
4766 defm MVE_VMULHs32 : MVE_VMULT<"vmulh", MVE_v4s32, 0b0>;
4767 defm MVE_VMULHu8 : MVE_VMULT<"vmulh", MVE_v16u8, 0b0>;
4768 defm MVE_VMULHu16 : MVE_VMULT<"vmulh", MVE_v8u16, 0b0>;
4769 defm MVE_VMULHu32 : MVE_VMULT<"vmulh", MVE_v4u32, 0b0>;
4771 defm MVE_VRMULHs8 : MVE_VMULT<"vrmulh", MVE_v16s8, 0b1>;
4772 defm MVE_VRMULHs16 : MVE_VMULT<"vrmulh", MVE_v8s16, 0b1>;
4773 defm MVE_VRMULHs32 : MVE_VMULT<"vrmulh", MVE_v4s32, 0b1>;
4774 defm MVE_VRMULHu8 : MVE_VMULT<"vrmulh", MVE_v16u8, 0b1>;
4775 defm MVE_VRMULHu16 : MVE_VMULT<"vrmulh", MVE_v8u16, 0b1>;
4776 defm MVE_VRMULHu32 : MVE_VMULT<"vrmulh", MVE_v4u32, 0b1>;
4778 class MVE_VxMOVxN<string iname, string suffix, bit bit_28, bit bit_17,
4779 bits<2> size, bit T, list<dag> pattern=[]>
4780 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
4781 (ins MQPR:$Qd_src, MQPR:$Qm), "$Qd, $Qm",
4782 vpred_n, "$Qd = $Qd_src", !if(size, 0b10, 0b01), pattern> {
4784 let Inst{28} = bit_28;
4785 let Inst{21-20} = 0b11;
4786 let Inst{19-18} = size;
4787 let Inst{17} = bit_17;
4791 let Inst{7} = !not(bit_17);
4793 let validForTailPredication = 1;
4794 let retainsPreviousHalfElement = 1;
4797 multiclass MVE_VxMOVxN_halves<string iname, string suffix,
4798 bit bit_28, bit bit_17, bits<2> size> {
4799 def bh : MVE_VxMOVxN<iname # "b", suffix, bit_28, bit_17, size, 0b0>;
4800 def th : MVE_VxMOVxN<iname # "t", suffix, bit_28, bit_17, size, 0b1>;
4803 defm MVE_VMOVNi16 : MVE_VxMOVxN_halves<"vmovn", "i16", 0b1, 0b0, 0b00>;
4804 defm MVE_VMOVNi32 : MVE_VxMOVxN_halves<"vmovn", "i32", 0b1, 0b0, 0b01>;
4805 defm MVE_VQMOVNs16 : MVE_VxMOVxN_halves<"vqmovn", "s16", 0b0, 0b1, 0b00>;
4806 defm MVE_VQMOVNs32 : MVE_VxMOVxN_halves<"vqmovn", "s32", 0b0, 0b1, 0b01>;
4807 defm MVE_VQMOVNu16 : MVE_VxMOVxN_halves<"vqmovn", "u16", 0b1, 0b1, 0b00>;
4808 defm MVE_VQMOVNu32 : MVE_VxMOVxN_halves<"vqmovn", "u32", 0b1, 0b1, 0b01>;
4809 defm MVE_VQMOVUNs16 : MVE_VxMOVxN_halves<"vqmovun", "s16", 0b0, 0b0, 0b00>;
4810 defm MVE_VQMOVUNs32 : MVE_VxMOVxN_halves<"vqmovun", "s32", 0b0, 0b0, 0b01>;
4812 def MVEvmovn : SDNode<"ARMISD::VMOVN", SDTARMVEXT>;
4814 multiclass MVE_VMOVN_p<Instruction Inst, bit top,
4815 MVEVectorVTInfo VTI, MVEVectorVTInfo InVTI> {
4816 // Match the most obvious MVEvmovn(a,b,t), which overwrites the odd or even
4817 // lanes of a (depending on t) with the even lanes of b.
4818 def : Pat<(VTI.Vec (MVEvmovn (VTI.Vec MQPR:$Qd_src),
4819 (VTI.Vec MQPR:$Qm), (i32 top))),
4820 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src), (VTI.Vec MQPR:$Qm)))>;
4823 // If we see MVEvmovn(a,ARMvrev(b),1), that wants to overwrite the odd
4824 // lanes of a with the odd lanes of b. In other words, the lanes we're
4825 // _keeping_ from a are the even ones. So we can flip it round and say that
4826 // this is the same as overwriting the even lanes of b with the even lanes
4827 // of a, i.e. it's a VMOVNB with the operands reversed.
4828 defvar vrev = !cast<SDNode>("ARMvrev" # InVTI.LaneBits);
4829 def : Pat<(VTI.Vec (MVEvmovn (VTI.Vec MQPR:$Qm),
4830 (VTI.Vec (vrev MQPR:$Qd_src)), (i32 1))),
4831 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src), (VTI.Vec MQPR:$Qm)))>;
4834 // Match the IR intrinsic for a predicated VMOVN. This regards the Qm input
4835 // as having wider lanes that we're narrowing, instead of already-narrow
4836 // lanes that we're taking every other one of.
4837 def : Pat<(VTI.Vec (int_arm_mve_vmovn_predicated (VTI.Vec MQPR:$Qd_src),
4838 (InVTI.Vec MQPR:$Qm), (i32 top),
4839 (InVTI.Pred VCCR:$pred))),
4840 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src),
4841 (InVTI.Vec MQPR:$Qm),
4842 ARMVCCThen, (InVTI.Pred VCCR:$pred), zero_reg))>;
4845 defm : MVE_VMOVN_p<MVE_VMOVNi32bh, 0, MVE_v8i16, MVE_v4i32>;
4846 defm : MVE_VMOVN_p<MVE_VMOVNi32th, 1, MVE_v8i16, MVE_v4i32>;
4847 defm : MVE_VMOVN_p<MVE_VMOVNi16bh, 0, MVE_v16i8, MVE_v8i16>;
4848 defm : MVE_VMOVN_p<MVE_VMOVNi16th, 1, MVE_v16i8, MVE_v8i16>;
4850 multiclass MVE_VQMOVN_p<Instruction Inst, bit outU, bit inU, bit top,
4851 MVEVectorVTInfo VTI, MVEVectorVTInfo InVTI> {
4852 def : Pat<(VTI.Vec (int_arm_mve_vqmovn (VTI.Vec MQPR:$Qd_src),
4853 (InVTI.Vec MQPR:$Qm),
4854 (i32 outU), (i32 inU), (i32 top))),
4855 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src),
4856 (InVTI.Vec MQPR:$Qm)))>;
4858 def : Pat<(VTI.Vec (int_arm_mve_vqmovn_predicated (VTI.Vec MQPR:$Qd_src),
4859 (InVTI.Vec MQPR:$Qm),
4860 (i32 outU), (i32 inU), (i32 top),
4861 (InVTI.Pred VCCR:$pred))),
4862 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src),
4863 (InVTI.Vec MQPR:$Qm),
4864 ARMVCCThen, (InVTI.Pred VCCR:$pred), zero_reg))>;
4867 defm : MVE_VQMOVN_p<MVE_VQMOVNs32bh, 0, 0, 0, MVE_v8i16, MVE_v4i32>;
4868 defm : MVE_VQMOVN_p<MVE_VQMOVNs32th, 0, 0, 1, MVE_v8i16, MVE_v4i32>;
4869 defm : MVE_VQMOVN_p<MVE_VQMOVNs16bh, 0, 0, 0, MVE_v16i8, MVE_v8i16>;
4870 defm : MVE_VQMOVN_p<MVE_VQMOVNs16th, 0, 0, 1, MVE_v16i8, MVE_v8i16>;
4871 defm : MVE_VQMOVN_p<MVE_VQMOVNu32bh, 1, 1, 0, MVE_v8i16, MVE_v4i32>;
4872 defm : MVE_VQMOVN_p<MVE_VQMOVNu32th, 1, 1, 1, MVE_v8i16, MVE_v4i32>;
4873 defm : MVE_VQMOVN_p<MVE_VQMOVNu16bh, 1, 1, 0, MVE_v16i8, MVE_v8i16>;
4874 defm : MVE_VQMOVN_p<MVE_VQMOVNu16th, 1, 1, 1, MVE_v16i8, MVE_v8i16>;
4875 defm : MVE_VQMOVN_p<MVE_VQMOVUNs32bh, 1, 0, 0, MVE_v8i16, MVE_v4i32>;
4876 defm : MVE_VQMOVN_p<MVE_VQMOVUNs32th, 1, 0, 1, MVE_v8i16, MVE_v4i32>;
4877 defm : MVE_VQMOVN_p<MVE_VQMOVUNs16bh, 1, 0, 0, MVE_v16i8, MVE_v8i16>;
4878 defm : MVE_VQMOVN_p<MVE_VQMOVUNs16th, 1, 0, 1, MVE_v16i8, MVE_v8i16>;
4880 def SDTARMVMOVNQ : SDTypeProfile<1, 3, [SDTCisVec<0>, SDTCisSameAs<0, 1>,
4881 SDTCisVec<2>, SDTCisVT<3, i32>]>;
4882 def MVEvqmovns : SDNode<"ARMISD::VQMOVNs", SDTARMVMOVNQ>;
4883 def MVEvqmovnu : SDNode<"ARMISD::VQMOVNu", SDTARMVMOVNQ>;
4885 let Predicates = [HasMVEInt] in {
4886 def : Pat<(v8i16 (MVEvqmovns (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), (i32 0))),
4887 (v8i16 (MVE_VQMOVNs32bh (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm)))>;
4888 def : Pat<(v8i16 (MVEvqmovns (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), (i32 1))),
4889 (v8i16 (MVE_VQMOVNs32th (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm)))>;
4890 def : Pat<(v16i8 (MVEvqmovns (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), (i32 0))),
4891 (v16i8 (MVE_VQMOVNs16bh (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm)))>;
4892 def : Pat<(v16i8 (MVEvqmovns (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), (i32 1))),
4893 (v16i8 (MVE_VQMOVNs16th (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm)))>;
4895 def : Pat<(v8i16 (MVEvqmovnu (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), (i32 0))),
4896 (v8i16 (MVE_VQMOVNu32bh (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm)))>;
4897 def : Pat<(v8i16 (MVEvqmovnu (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), (i32 1))),
4898 (v8i16 (MVE_VQMOVNu32th (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm)))>;
4899 def : Pat<(v16i8 (MVEvqmovnu (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), (i32 0))),
4900 (v16i8 (MVE_VQMOVNu16bh (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm)))>;
4901 def : Pat<(v16i8 (MVEvqmovnu (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), (i32 1))),
4902 (v16i8 (MVE_VQMOVNu16th (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm)))>;
4904 def : Pat<(v8i16 (MVEvqmovns (v8i16 MQPR:$Qd_src), (v4i32 (ARMvshrsImm (v4i32 MQPR:$Qm), imm0_31:$imm)), (i32 0))),
4905 (v8i16 (MVE_VQSHRNbhs32 (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), imm0_31:$imm))>;
4906 def : Pat<(v16i8 (MVEvqmovns (v16i8 MQPR:$Qd_src), (v8i16 (ARMvshrsImm (v8i16 MQPR:$Qm), imm0_15:$imm)), (i32 0))),
4907 (v16i8 (MVE_VQSHRNbhs16 (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), imm0_15:$imm))>;
4908 def : Pat<(v8i16 (MVEvqmovns (v8i16 MQPR:$Qd_src), (v4i32 (ARMvshrsImm (v4i32 MQPR:$Qm), imm0_31:$imm)), (i32 1))),
4909 (v8i16 (MVE_VQSHRNths32 (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), imm0_31:$imm))>;
4910 def : Pat<(v16i8 (MVEvqmovns (v16i8 MQPR:$Qd_src), (v8i16 (ARMvshrsImm (v8i16 MQPR:$Qm), imm0_15:$imm)), (i32 1))),
4911 (v16i8 (MVE_VQSHRNths16 (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), imm0_15:$imm))>;
4913 def : Pat<(v8i16 (MVEvqmovnu (v8i16 MQPR:$Qd_src), (v4i32 (ARMvshruImm (v4i32 MQPR:$Qm), imm0_31:$imm)), (i32 0))),
4914 (v8i16 (MVE_VQSHRNbhu32 (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), imm0_31:$imm))>;
4915 def : Pat<(v16i8 (MVEvqmovnu (v16i8 MQPR:$Qd_src), (v8i16 (ARMvshruImm (v8i16 MQPR:$Qm), imm0_15:$imm)), (i32 0))),
4916 (v16i8 (MVE_VQSHRNbhu16 (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), imm0_15:$imm))>;
4917 def : Pat<(v8i16 (MVEvqmovnu (v8i16 MQPR:$Qd_src), (v4i32 (ARMvshruImm (v4i32 MQPR:$Qm), imm0_31:$imm)), (i32 1))),
4918 (v8i16 (MVE_VQSHRNthu32 (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), imm0_31:$imm))>;
4919 def : Pat<(v16i8 (MVEvqmovnu (v16i8 MQPR:$Qd_src), (v8i16 (ARMvshruImm (v8i16 MQPR:$Qm), imm0_15:$imm)), (i32 1))),
4920 (v16i8 (MVE_VQSHRNthu16 (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), imm0_15:$imm))>;
4923 class MVE_VCVT_ff<string iname, string suffix, bit op, bit T,
4924 dag iops_extra, vpred_ops vpred, string cstr>
4925 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
4926 !con(iops_extra, (ins MQPR:$Qm)), "$Qd, $Qm",
4927 vpred, cstr, 0b10, []> {
4929 let Inst{21-16} = 0b111111;
4931 let Inst{8-7} = 0b00;
4934 let Predicates = [HasMVEFloat];
4935 let retainsPreviousHalfElement = 1;
4938 def SDTARMVCVTL : SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisVec<1>,
4940 def MVEvcvtn : SDNode<"ARMISD::VCVTN", SDTARMVMOVNQ>;
4941 def MVEvcvtl : SDNode<"ARMISD::VCVTL", SDTARMVCVTL>;
4943 multiclass MVE_VCVT_f2h_m<string iname, int half> {
4944 def "": MVE_VCVT_ff<iname, "f16.f32", 0b0, half,
4945 (ins MQPR:$Qd_src), vpred_n, "$Qd = $Qd_src">;
4946 defvar Inst = !cast<Instruction>(NAME);
4948 let Predicates = [HasMVEFloat] in {
4949 def : Pat<(v8f16 (int_arm_mve_vcvt_narrow
4950 (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm), (i32 half))),
4951 (v8f16 (Inst (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm)))>;
4952 def : Pat<(v8f16 (int_arm_mve_vcvt_narrow_predicated
4953 (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm), (i32 half),
4954 (v4i1 VCCR:$mask))),
4955 (v8f16 (Inst (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm),
4956 ARMVCCThen, (v4i1 VCCR:$mask), zero_reg))>;
4958 def : Pat<(v8f16 (MVEvcvtn (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm), (i32 half))),
4959 (v8f16 (Inst (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm)))>;
4963 multiclass MVE_VCVT_h2f_m<string iname, int half> {
4964 def "": MVE_VCVT_ff<iname, "f32.f16", 0b1, half, (ins), vpred_r, "">;
4965 defvar Inst = !cast<Instruction>(NAME);
4967 let Predicates = [HasMVEFloat] in {
4968 def : Pat<(v4f32 (int_arm_mve_vcvt_widen (v8f16 MQPR:$Qm), (i32 half))),
4969 (v4f32 (Inst (v8f16 MQPR:$Qm)))>;
4970 def : Pat<(v4f32 (int_arm_mve_vcvt_widen_predicated
4971 (v4f32 MQPR:$inactive), (v8f16 MQPR:$Qm), (i32 half),
4972 (v4i1 VCCR:$mask))),
4973 (v4f32 (Inst (v8f16 MQPR:$Qm), ARMVCCThen,
4974 (v4i1 VCCR:$mask), zero_reg, (v4f32 MQPR:$inactive)))>;
4976 def : Pat<(v4f32 (MVEvcvtl (v8f16 MQPR:$Qm), (i32 half))),
4977 (v4f32 (Inst (v8f16 MQPR:$Qm)))>;
4981 defm MVE_VCVTf16f32bh : MVE_VCVT_f2h_m<"vcvtb", 0b0>;
4982 defm MVE_VCVTf16f32th : MVE_VCVT_f2h_m<"vcvtt", 0b1>;
4983 defm MVE_VCVTf32f16bh : MVE_VCVT_h2f_m<"vcvtb", 0b0>;
4984 defm MVE_VCVTf32f16th : MVE_VCVT_h2f_m<"vcvtt", 0b1>;
4986 class MVE_VxCADD<string iname, string suffix, bits<2> size, bit halve,
4988 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
4989 (ins MQPR:$Qn, MQPR:$Qm, complexrotateopodd:$rot),
4990 "$Qd, $Qn, $Qm, $rot", vpred_r, cstr, size, []> {
4994 let Inst{28} = halve;
4995 let Inst{21-20} = size;
4996 let Inst{19-17} = Qn{2-0};
5000 let Inst{7} = Qn{3};
5004 multiclass MVE_VxCADD_m<string iname, MVEVectorVTInfo VTI,
5005 bit halve, string cstr=""> {
5006 def "" : MVE_VxCADD<iname, VTI.Suffix, VTI.Size, halve, cstr>;
5007 defvar Inst = !cast<Instruction>(NAME);
5009 let Predicates = [HasMVEInt] in {
5010 def : Pat<(VTI.Vec (int_arm_mve_vcaddq halve,
5011 imm:$rot, (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))),
5012 (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
5015 def : Pat<(VTI.Vec (int_arm_mve_vcaddq_predicated halve,
5016 imm:$rot, (VTI.Vec MQPR:$inactive),
5017 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
5018 (VTI.Pred VCCR:$mask))),
5019 (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm),
5020 imm:$rot, ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
5021 (VTI.Vec MQPR:$inactive)))>;
5026 defm MVE_VCADDi8 : MVE_VxCADD_m<"vcadd", MVE_v16i8, 0b1>;
5027 defm MVE_VCADDi16 : MVE_VxCADD_m<"vcadd", MVE_v8i16, 0b1>;
5028 defm MVE_VCADDi32 : MVE_VxCADD_m<"vcadd", MVE_v4i32, 0b1, "@earlyclobber $Qd">;
5030 defm MVE_VHCADDs8 : MVE_VxCADD_m<"vhcadd", MVE_v16s8, 0b0>;
5031 defm MVE_VHCADDs16 : MVE_VxCADD_m<"vhcadd", MVE_v8s16, 0b0>;
5032 defm MVE_VHCADDs32 : MVE_VxCADD_m<"vhcadd", MVE_v4s32, 0b0, "@earlyclobber $Qd">;
5034 class MVE_VADCSBC<string iname, bit I, bit subtract,
5035 dag carryin, list<dag> pattern=[]>
5036 : MVE_qDest_qSrc<iname, "i32", (outs MQPR:$Qd, cl_FPSCR_NZCV:$carryout),
5037 !con((ins MQPR:$Qn, MQPR:$Qm), carryin),
5038 "$Qd, $Qn, $Qm", vpred_r, "", 0b10, pattern> {
5041 let Inst{28} = subtract;
5042 let Inst{21-20} = 0b11;
5043 let Inst{19-17} = Qn{2-0};
5047 let Inst{7} = Qn{3};
5050 // Custom decoder method in order to add the FPSCR operand(s), which
5051 // Tablegen won't do right
5052 let DecoderMethod = "DecodeMVEVADCInstruction";
5055 def MVE_VADC : MVE_VADCSBC<"vadc", 0b0, 0b0, (ins cl_FPSCR_NZCV:$carryin)>;
5056 def MVE_VADCI : MVE_VADCSBC<"vadci", 0b1, 0b0, (ins)>;
5058 def MVE_VSBC : MVE_VADCSBC<"vsbc", 0b0, 0b1, (ins cl_FPSCR_NZCV:$carryin)>;
5059 def MVE_VSBCI : MVE_VADCSBC<"vsbci", 0b1, 0b1, (ins)>;
5061 class MVE_VQDMULL<string iname, string suffix, bit size, bit T,
5062 string cstr="", list<dag> pattern=[]>
5063 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd),
5064 (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm",
5065 vpred_r, cstr, !if(size, 0b10, 0b01), pattern> {
5068 let Inst{28} = size;
5069 let Inst{21-20} = 0b11;
5070 let Inst{19-17} = Qn{2-0};
5074 let Inst{7} = Qn{3};
5076 let validForTailPredication = 1;
5077 let doubleWidthResult = 1;
5080 multiclass MVE_VQDMULL_m<string iname, MVEVectorVTInfo VTI, bit size, bit T,
5082 def "" : MVE_VQDMULL<iname, VTI.Suffix, size, T, cstr>;
5083 defvar Inst = !cast<Instruction>(NAME);
5085 let Predicates = [HasMVEInt] in {
5086 // Unpredicated saturating multiply
5087 def : Pat<(VTI.DblVec (int_arm_mve_vqdmull (VTI.Vec MQPR:$Qm),
5088 (VTI.Vec MQPR:$Qn), (i32 T))),
5089 (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
5090 // Predicated saturating multiply
5091 def : Pat<(VTI.DblVec (int_arm_mve_vqdmull_predicated
5092 (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
5093 (i32 T), (VTI.DblPred VCCR:$mask),
5094 (VTI.DblVec MQPR:$inactive))),
5095 (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
5096 ARMVCCThen, (VTI.DblPred VCCR:$mask), zero_reg,
5097 (VTI.DblVec MQPR:$inactive)))>;
5101 multiclass MVE_VQDMULL_halves<MVEVectorVTInfo VTI, bit size, string cstr=""> {
5102 defm bh : MVE_VQDMULL_m<"vqdmullb", VTI, size, 0b0, cstr>;
5103 defm th : MVE_VQDMULL_m<"vqdmullt", VTI, size, 0b1, cstr>;
5106 defm MVE_VQDMULLs16 : MVE_VQDMULL_halves<MVE_v8s16, 0b0>;
5107 defm MVE_VQDMULLs32 : MVE_VQDMULL_halves<MVE_v4s32, 0b1, "@earlyclobber $Qd">;
5109 // end of mve_qDest_qSrc
5111 // start of mve_qDest_rSrc
5113 class MVE_qr_base<dag oops, dag iops, string iname, string suffix, string ops,
5114 vpred_ops vpred, string cstr, bits<2> vecsize, list<dag> pattern=[]>
5115 : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, vecsize, pattern> {
5120 let Inst{25-23} = 0b100;
5121 let Inst{22} = Qd{3};
5122 let Inst{19-17} = Qn{2-0};
5123 let Inst{15-13} = Qd{2-0};
5124 let Inst{11-9} = 0b111;
5125 let Inst{7} = Qn{3};
5128 let Inst{3-0} = Rm{3-0};
5131 class MVE_qDest_rSrc<string iname, string suffix, string cstr="", bits<2> vecsize, list<dag> pattern=[]>
5132 : MVE_qr_base<(outs MQPR:$Qd), (ins MQPR:$Qn, rGPR:$Rm),
5133 iname, suffix, "$Qd, $Qn, $Rm", vpred_r, cstr,
5136 class MVE_qDestSrc_rSrc<string iname, string suffix, bits<2> vecsize, list<dag> pattern=[]>
5137 : MVE_qr_base<(outs MQPR:$Qd), (ins MQPR:$Qd_src, MQPR:$Qn, rGPR:$Rm),
5138 iname, suffix, "$Qd, $Qn, $Rm", vpred_n, "$Qd = $Qd_src",
5141 class MVE_qDest_single_rSrc<string iname, string suffix, bits<2> vecsize, list<dag> pattern=[]>
5142 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qd_src, rGPR:$Rm), NoItinerary, iname,
5143 suffix, "$Qd, $Rm", vpred_n, "$Qd = $Qd_src", vecsize, pattern> {
5147 let Inst{22} = Qd{3};
5148 let Inst{15-13} = Qd{2-0};
5149 let Inst{3-0} = Rm{3-0};
5152 // Patterns for vector-scalar instructions with integer operands
5153 multiclass MVE_vec_scalar_int_pat_m<Instruction inst, MVEVectorVTInfo VTI,
5154 SDPatternOperator unpred_op,
5155 SDPatternOperator pred_op,
5156 bit unpred_has_sign = 0,
5157 bit pred_has_sign = 0> {
5158 defvar UnpredSign = !if(unpred_has_sign, (? (i32 VTI.Unsigned)), (?));
5159 defvar PredSign = !if(pred_has_sign, (? (i32 VTI.Unsigned)), (?));
5161 let Predicates = [HasMVEInt] in {
5162 // Unpredicated version
5163 def : Pat<(VTI.Vec !con((unpred_op (VTI.Vec MQPR:$Qm),
5164 (VTI.Vec (ARMvdup rGPR:$val))),
5166 (VTI.Vec (inst (VTI.Vec MQPR:$Qm), (i32 rGPR:$val)))>;
5167 // Predicated version
5168 def : Pat<(VTI.Vec !con((pred_op (VTI.Vec MQPR:$Qm),
5169 (VTI.Vec (ARMvdup rGPR:$val))),
5171 (pred_op (VTI.Pred VCCR:$mask),
5172 (VTI.Vec MQPR:$inactive)))),
5173 (VTI.Vec (inst (VTI.Vec MQPR:$Qm), (i32 rGPR:$val),
5174 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
5175 (VTI.Vec MQPR:$inactive)))>;
5179 class MVE_VADDSUB_qr<string iname, string suffix, bits<2> size,
5180 bit bit_5, bit bit_12, bit bit_16, bit bit_28>
5181 : MVE_qDest_rSrc<iname, suffix, "", size> {
5183 let Inst{28} = bit_28;
5184 let Inst{21-20} = size;
5185 let Inst{16} = bit_16;
5186 let Inst{12} = bit_12;
5188 let Inst{5} = bit_5;
5189 let validForTailPredication = 1;
5192 // Vector-scalar add/sub
5193 multiclass MVE_VADDSUB_qr_m<string iname, MVEVectorVTInfo VTI, bit subtract,
5194 SDNode Op, Intrinsic PredInt> {
5195 def "" : MVE_VADDSUB_qr<iname, VTI.Suffix, VTI.Size, 0b0, subtract, 0b1, 0b0>;
5196 let Predicates = [HasMVEInt] in {
5197 defm : MVE_TwoOpPatternDup<VTI, Op, PredInt, (? ), !cast<Instruction>(NAME), ARMimmAllZerosV>;
5201 multiclass MVE_VADD_qr_m<MVEVectorVTInfo VTI>
5202 : MVE_VADDSUB_qr_m<"vadd", VTI, 0b0, add, int_arm_mve_add_predicated>;
5204 multiclass MVE_VSUB_qr_m<MVEVectorVTInfo VTI>
5205 : MVE_VADDSUB_qr_m<"vsub", VTI, 0b1, sub, int_arm_mve_sub_predicated>;
5207 defm MVE_VADD_qr_i8 : MVE_VADD_qr_m<MVE_v16i8>;
5208 defm MVE_VADD_qr_i16 : MVE_VADD_qr_m<MVE_v8i16>;
5209 defm MVE_VADD_qr_i32 : MVE_VADD_qr_m<MVE_v4i32>;
5211 defm MVE_VSUB_qr_i8 : MVE_VSUB_qr_m<MVE_v16i8>;
5212 defm MVE_VSUB_qr_i16 : MVE_VSUB_qr_m<MVE_v8i16>;
5213 defm MVE_VSUB_qr_i32 : MVE_VSUB_qr_m<MVE_v4i32>;
5215 // Vector-scalar saturating add/sub
5216 multiclass MVE_VQADDSUB_qr_m<string iname, MVEVectorVTInfo VTI, bit subtract,
5217 SDNode Op, Intrinsic PredInt> {
5218 def "" : MVE_VADDSUB_qr<iname, VTI.Suffix, VTI.Size, 0b1, subtract,
5221 let Predicates = [HasMVEInt] in {
5222 defm : MVE_TwoOpPatternDup<VTI, Op, PredInt, (? (i32 VTI.Unsigned)),
5223 !cast<Instruction>(NAME)>;
5227 multiclass MVE_VQADD_qr_m<MVEVectorVTInfo VTI, SDNode Op>
5228 : MVE_VQADDSUB_qr_m<"vqadd", VTI, 0b0, Op, int_arm_mve_qadd_predicated>;
5230 multiclass MVE_VQSUB_qr_m<MVEVectorVTInfo VTI, SDNode Op>
5231 : MVE_VQADDSUB_qr_m<"vqsub", VTI, 0b1, Op, int_arm_mve_qsub_predicated>;
5233 defm MVE_VQADD_qr_s8 : MVE_VQADD_qr_m<MVE_v16s8, saddsat>;
5234 defm MVE_VQADD_qr_s16 : MVE_VQADD_qr_m<MVE_v8s16, saddsat>;
5235 defm MVE_VQADD_qr_s32 : MVE_VQADD_qr_m<MVE_v4s32, saddsat>;
5236 defm MVE_VQADD_qr_u8 : MVE_VQADD_qr_m<MVE_v16u8, uaddsat>;
5237 defm MVE_VQADD_qr_u16 : MVE_VQADD_qr_m<MVE_v8u16, uaddsat>;
5238 defm MVE_VQADD_qr_u32 : MVE_VQADD_qr_m<MVE_v4u32, uaddsat>;
5240 defm MVE_VQSUB_qr_s8 : MVE_VQSUB_qr_m<MVE_v16s8, ssubsat>;
5241 defm MVE_VQSUB_qr_s16 : MVE_VQSUB_qr_m<MVE_v8s16, ssubsat>;
5242 defm MVE_VQSUB_qr_s32 : MVE_VQSUB_qr_m<MVE_v4s32, ssubsat>;
5243 defm MVE_VQSUB_qr_u8 : MVE_VQSUB_qr_m<MVE_v16u8, usubsat>;
5244 defm MVE_VQSUB_qr_u16 : MVE_VQSUB_qr_m<MVE_v8u16, usubsat>;
5245 defm MVE_VQSUB_qr_u32 : MVE_VQSUB_qr_m<MVE_v4u32, usubsat>;
5247 class MVE_VQDMULL_qr<string iname, string suffix, bit size,
5248 bit T, string cstr="", list<dag> pattern=[]>
5249 : MVE_qDest_rSrc<iname, suffix, cstr, !if(size, 0b10, 0b01), pattern> {
5251 let Inst{28} = size;
5252 let Inst{21-20} = 0b11;
5257 let validForTailPredication = 1;
5258 let doubleWidthResult = 1;
5261 multiclass MVE_VQDMULL_qr_m<string iname, MVEVectorVTInfo VTI, bit size,
5262 bit T, string cstr> {
5263 def "" : MVE_VQDMULL_qr<iname, VTI.Suffix, size, T, cstr>;
5264 defvar Inst = !cast<Instruction>(NAME);
5266 let Predicates = [HasMVEInt] in {
5267 // Unpredicated saturating multiply
5268 def : Pat<(VTI.DblVec (int_arm_mve_vqdmull (VTI.Vec MQPR:$Qm),
5269 (VTI.Vec (ARMvdup rGPR:$val)),
5271 (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (i32 rGPR:$val)))>;
5272 // Predicated saturating multiply
5273 def : Pat<(VTI.DblVec (int_arm_mve_vqdmull_predicated
5275 (VTI.Vec (ARMvdup rGPR:$val)),
5277 (VTI.DblPred VCCR:$mask),
5278 (VTI.DblVec MQPR:$inactive))),
5279 (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (i32 rGPR:$val),
5280 ARMVCCThen, (VTI.DblPred VCCR:$mask), zero_reg,
5281 (VTI.DblVec MQPR:$inactive)))>;
5285 multiclass MVE_VQDMULL_qr_halves<MVEVectorVTInfo VTI, bit size, string cstr=""> {
5286 defm bh : MVE_VQDMULL_qr_m<"vqdmullb", VTI, size, 0b0, cstr>;
5287 defm th : MVE_VQDMULL_qr_m<"vqdmullt", VTI, size, 0b1, cstr>;
5290 defm MVE_VQDMULL_qr_s16 : MVE_VQDMULL_qr_halves<MVE_v8s16, 0b0>;
5291 defm MVE_VQDMULL_qr_s32 : MVE_VQDMULL_qr_halves<MVE_v4s32, 0b1, "@earlyclobber $Qd">;
5293 class MVE_VxADDSUB_qr<string iname, string suffix,
5294 bit bit_28, bits<2> size, bit subtract,
5295 bits<2> vecsize, list<dag> pattern=[]>
5296 : MVE_qDest_rSrc<iname, suffix, "", vecsize, pattern> {
5298 let Inst{28} = bit_28;
5299 let Inst{21-20} = size;
5301 let Inst{12} = subtract;
5304 let validForTailPredication = 1;
5307 multiclass MVE_VHADDSUB_qr_m<string iname, MVEVectorVTInfo VTI, bit subtract, SDPatternOperator Op,
5308 Intrinsic unpred_int, Intrinsic pred_int, PatFrag add_op, SDNode shift_op> {
5309 def "" : MVE_VxADDSUB_qr<iname, VTI.Suffix, VTI.Unsigned, VTI.Size, subtract, VTI.Size>;
5310 defm : MVE_TwoOpPatternDup<VTI, Op, pred_int, (? (i32 VTI.Unsigned)), !cast<Instruction>(NAME)>;
5311 defm : MVE_vec_scalar_int_pat_m<!cast<Instruction>(NAME),
5312 VTI, unpred_int, pred_int, 1, 1>;
5313 defvar Inst = !cast<Instruction>(NAME);
5315 let Predicates = [HasMVEInt] in {
5316 def : Pat<(VTI.Vec (shift_op (add_op (VTI.Vec MQPR:$Qm), (VTI.Vec (ARMvdup rGPR:$Rn))), (i32 1))),
5317 (Inst MQPR:$Qm, rGPR:$Rn)>;
5321 multiclass MVE_VHADD_qr_m<MVEVectorVTInfo VTI, PatFrag add_op, SDNode shift_op, SDNode Op> :
5322 MVE_VHADDSUB_qr_m<"vhadd", VTI, 0b0, Op, int_arm_mve_vhadd,
5323 int_arm_mve_hadd_predicated, add_op, shift_op>;
5325 multiclass MVE_VHSUB_qr_m<MVEVectorVTInfo VTI, PatFrag add_op, SDNode shift_op> :
5326 MVE_VHADDSUB_qr_m<"vhsub", VTI, 0b1, null_frag, int_arm_mve_vhsub,
5327 int_arm_mve_hsub_predicated, add_op, shift_op>;
5329 defm MVE_VHADD_qr_s8 : MVE_VHADD_qr_m<MVE_v16s8, addnsw, ARMvshrsImm, avgfloors>;
5330 defm MVE_VHADD_qr_s16 : MVE_VHADD_qr_m<MVE_v8s16, addnsw, ARMvshrsImm, avgfloors>;
5331 defm MVE_VHADD_qr_s32 : MVE_VHADD_qr_m<MVE_v4s32, addnsw, ARMvshrsImm, avgfloors>;
5332 defm MVE_VHADD_qr_u8 : MVE_VHADD_qr_m<MVE_v16u8, addnuw, ARMvshruImm, avgflooru>;
5333 defm MVE_VHADD_qr_u16 : MVE_VHADD_qr_m<MVE_v8u16, addnuw, ARMvshruImm, avgflooru>;
5334 defm MVE_VHADD_qr_u32 : MVE_VHADD_qr_m<MVE_v4u32, addnuw, ARMvshruImm, avgflooru>;
5336 defm MVE_VHSUB_qr_s8 : MVE_VHSUB_qr_m<MVE_v16s8, subnsw, ARMvshrsImm>;
5337 defm MVE_VHSUB_qr_s16 : MVE_VHSUB_qr_m<MVE_v8s16, subnsw, ARMvshrsImm>;
5338 defm MVE_VHSUB_qr_s32 : MVE_VHSUB_qr_m<MVE_v4s32, subnsw, ARMvshrsImm>;
5339 defm MVE_VHSUB_qr_u8 : MVE_VHSUB_qr_m<MVE_v16u8, subnuw, ARMvshruImm>;
5340 defm MVE_VHSUB_qr_u16 : MVE_VHSUB_qr_m<MVE_v8u16, subnuw, ARMvshruImm>;
5341 defm MVE_VHSUB_qr_u32 : MVE_VHSUB_qr_m<MVE_v4u32, subnuw, ARMvshruImm>;
5343 multiclass MVE_VADDSUB_qr_f<string iname, MVEVectorVTInfo VTI, bit subtract,
5344 SDNode Op, Intrinsic PredInt, SDPatternOperator IdentityVec> {
5345 def "" : MVE_VxADDSUB_qr<iname, VTI.Suffix, VTI.Size{0}, 0b11, subtract, VTI.Size>;
5346 defm : MVE_TwoOpPatternDup<VTI, Op, PredInt, (? ),
5347 !cast<Instruction>(NAME), IdentityVec>;
5350 let Predicates = [HasMVEFloat] in {
5351 defm MVE_VADD_qr_f32 : MVE_VADDSUB_qr_f<"vadd", MVE_v4f32, 0b0, fadd,
5352 int_arm_mve_add_predicated, ARMimmMinusZeroF>;
5353 defm MVE_VADD_qr_f16 : MVE_VADDSUB_qr_f<"vadd", MVE_v8f16, 0b0, fadd,
5354 int_arm_mve_add_predicated, ARMimmMinusZeroH>;
5356 defm MVE_VSUB_qr_f32 : MVE_VADDSUB_qr_f<"vsub", MVE_v4f32, 0b1, fsub,
5357 int_arm_mve_sub_predicated, ARMimmAllZerosV>;
5358 defm MVE_VSUB_qr_f16 : MVE_VADDSUB_qr_f<"vsub", MVE_v8f16, 0b1, fsub,
5359 int_arm_mve_sub_predicated, ARMimmAllZerosV>;
5362 class MVE_VxSHL_qr<string iname, string suffix, bit U, bits<2> size,
5363 bit bit_7, bit bit_17, list<dag> pattern=[]>
5364 : MVE_qDest_single_rSrc<iname, suffix, size, pattern> {
5367 let Inst{25-23} = 0b100;
5368 let Inst{21-20} = 0b11;
5369 let Inst{19-18} = size;
5370 let Inst{17} = bit_17;
5372 let Inst{12-8} = 0b11110;
5373 let Inst{7} = bit_7;
5374 let Inst{6-4} = 0b110;
5375 let validForTailPredication = 1;
5378 multiclass MVE_VxSHL_qr_p<string iname, MVEVectorVTInfo VTI, bit q, bit r> {
5379 def "" : MVE_VxSHL_qr<iname, VTI.Suffix, VTI.Unsigned, VTI.Size, q, r>;
5380 defvar Inst = !cast<Instruction>(NAME);
5382 def : Pat<(VTI.Vec (int_arm_mve_vshl_scalar
5383 (VTI.Vec MQPR:$in), (i32 rGPR:$sh),
5384 (i32 q), (i32 r), (i32 VTI.Unsigned))),
5385 (VTI.Vec (Inst (VTI.Vec MQPR:$in), (i32 rGPR:$sh)))>;
5387 def : Pat<(VTI.Vec (int_arm_mve_vshl_scalar_predicated
5388 (VTI.Vec MQPR:$in), (i32 rGPR:$sh),
5389 (i32 q), (i32 r), (i32 VTI.Unsigned),
5390 (VTI.Pred VCCR:$mask))),
5391 (VTI.Vec (Inst (VTI.Vec MQPR:$in), (i32 rGPR:$sh),
5392 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>;
5395 multiclass MVE_VxSHL_qr_types<string iname, bit bit_7, bit bit_17> {
5396 defm s8 : MVE_VxSHL_qr_p<iname, MVE_v16s8, bit_7, bit_17>;
5397 defm s16 : MVE_VxSHL_qr_p<iname, MVE_v8s16, bit_7, bit_17>;
5398 defm s32 : MVE_VxSHL_qr_p<iname, MVE_v4s32, bit_7, bit_17>;
5399 defm u8 : MVE_VxSHL_qr_p<iname, MVE_v16u8, bit_7, bit_17>;
5400 defm u16 : MVE_VxSHL_qr_p<iname, MVE_v8u16, bit_7, bit_17>;
5401 defm u32 : MVE_VxSHL_qr_p<iname, MVE_v4u32, bit_7, bit_17>;
5404 defm MVE_VSHL_qr : MVE_VxSHL_qr_types<"vshl", 0b0, 0b0>;
5405 defm MVE_VRSHL_qr : MVE_VxSHL_qr_types<"vrshl", 0b0, 0b1>;
5406 defm MVE_VQSHL_qr : MVE_VxSHL_qr_types<"vqshl", 0b1, 0b0>;
5407 defm MVE_VQRSHL_qr : MVE_VxSHL_qr_types<"vqrshl", 0b1, 0b1>;
5409 let Predicates = [HasMVEInt] in {
5410 def : Pat<(v4i32 (ARMvshlu (v4i32 MQPR:$Qm), (v4i32 (ARMvdup rGPR:$Rm)))),
5411 (v4i32 (MVE_VSHL_qru32 (v4i32 MQPR:$Qm), rGPR:$Rm))>;
5412 def : Pat<(v8i16 (ARMvshlu (v8i16 MQPR:$Qm), (v8i16 (ARMvdup rGPR:$Rm)))),
5413 (v8i16 (MVE_VSHL_qru16 (v8i16 MQPR:$Qm), rGPR:$Rm))>;
5414 def : Pat<(v16i8 (ARMvshlu (v16i8 MQPR:$Qm), (v16i8 (ARMvdup rGPR:$Rm)))),
5415 (v16i8 (MVE_VSHL_qru8 (v16i8 MQPR:$Qm), rGPR:$Rm))>;
5417 def : Pat<(v4i32 (ARMvshls (v4i32 MQPR:$Qm), (v4i32 (ARMvdup rGPR:$Rm)))),
5418 (v4i32 (MVE_VSHL_qrs32 (v4i32 MQPR:$Qm), rGPR:$Rm))>;
5419 def : Pat<(v8i16 (ARMvshls (v8i16 MQPR:$Qm), (v8i16 (ARMvdup rGPR:$Rm)))),
5420 (v8i16 (MVE_VSHL_qrs16 (v8i16 MQPR:$Qm), rGPR:$Rm))>;
5421 def : Pat<(v16i8 (ARMvshls (v16i8 MQPR:$Qm), (v16i8 (ARMvdup rGPR:$Rm)))),
5422 (v16i8 (MVE_VSHL_qrs8 (v16i8 MQPR:$Qm), rGPR:$Rm))>;
5425 class MVE_VBRSR<string iname, string suffix, bits<2> size, list<dag> pattern=[]>
5426 : MVE_qDest_rSrc<iname, suffix, "", size, pattern> {
5429 let Inst{21-20} = size;
5434 let validForTailPredication = 1;
5437 def MVE_VBRSR8 : MVE_VBRSR<"vbrsr", "8", 0b00>;
5438 def MVE_VBRSR16 : MVE_VBRSR<"vbrsr", "16", 0b01>;
5439 def MVE_VBRSR32 : MVE_VBRSR<"vbrsr", "32", 0b10>;
5441 multiclass MVE_VBRSR_pat_m<MVEVectorVTInfo VTI, Instruction Inst> {
5443 def : Pat<(VTI.Vec (int_arm_mve_vbrsr (VTI.Vec MQPR:$Qn), (i32 rGPR:$Rm))),
5444 (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (i32 rGPR:$Rm)))>;
5446 def : Pat<(VTI.Vec (int_arm_mve_vbrsr_predicated
5447 (VTI.Vec MQPR:$inactive),
5448 (VTI.Vec MQPR:$Qn), (i32 rGPR:$Rm),
5449 (VTI.Pred VCCR:$mask))),
5450 (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (i32 rGPR:$Rm),
5451 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg,
5452 (VTI.Vec MQPR:$inactive)))>;
5455 let Predicates = [HasMVEInt] in {
5456 def : Pat<(v16i8 ( bitreverse (v16i8 MQPR:$val1))),
5457 (v16i8 ( MVE_VBRSR8 (v16i8 MQPR:$val1), (t2MOVi (i32 8)) ))>;
5459 def : Pat<(v4i32 ( bitreverse (v4i32 MQPR:$val1))),
5460 (v4i32 ( MVE_VBRSR32 (v4i32 MQPR:$val1), (t2MOVi (i32 32)) ))>;
5462 def : Pat<(v8i16 ( bitreverse (v8i16 MQPR:$val1))),
5463 (v8i16 ( MVE_VBRSR16 (v8i16 MQPR:$val1), (t2MOVi (i32 16)) ))>;
5465 defm : MVE_VBRSR_pat_m<MVE_v16i8, MVE_VBRSR8>;
5466 defm : MVE_VBRSR_pat_m<MVE_v8i16, MVE_VBRSR16>;
5467 defm : MVE_VBRSR_pat_m<MVE_v4i32, MVE_VBRSR32>;
5470 let Predicates = [HasMVEFloat] in {
5471 defm : MVE_VBRSR_pat_m<MVE_v8f16, MVE_VBRSR16>;
5472 defm : MVE_VBRSR_pat_m<MVE_v4f32, MVE_VBRSR32>;
5475 class MVE_VMUL_qr_int<string iname, string suffix, bits<2> size>
5476 : MVE_qDest_rSrc<iname, suffix, "", size> {
5479 let Inst{21-20} = size;
5484 let validForTailPredication = 1;
5487 multiclass MVE_VMUL_qr_int_m<MVEVectorVTInfo VTI> {
5488 def "" : MVE_VMUL_qr_int<"vmul", VTI.Suffix, VTI.Size>;
5489 let Predicates = [HasMVEInt] in {
5490 defm : MVE_TwoOpPatternDup<VTI, mul, int_arm_mve_mul_predicated, (? ),
5491 !cast<Instruction>(NAME), ARMimmOneV>;
5495 defm MVE_VMUL_qr_i8 : MVE_VMUL_qr_int_m<MVE_v16i8>;
5496 defm MVE_VMUL_qr_i16 : MVE_VMUL_qr_int_m<MVE_v8i16>;
5497 defm MVE_VMUL_qr_i32 : MVE_VMUL_qr_int_m<MVE_v4i32>;
5499 class MVE_VxxMUL_qr<string iname, string suffix,
5500 bit bit_28, bits<2> size, bits<2> vecsize, list<dag> pattern=[]>
5501 : MVE_qDest_rSrc<iname, suffix, "", vecsize, pattern> {
5503 let Inst{28} = bit_28;
5504 let Inst{21-20} = size;
5509 let validForTailPredication = 1;
5512 multiclass MVE_VxxMUL_qr_m<string iname, MVEVectorVTInfo VTI, bit bit_28,
5513 SDPatternOperator Op, Intrinsic int_unpred, Intrinsic int_pred> {
5514 def "" : MVE_VxxMUL_qr<iname, VTI.Suffix, bit_28, VTI.Size, VTI.Size>;
5516 let Predicates = [HasMVEInt] in {
5517 defm : MVE_TwoOpPatternDup<VTI, Op, int_pred, (? ), !cast<Instruction>(NAME)>;
5519 defm : MVE_vec_scalar_int_pat_m<!cast<Instruction>(NAME), VTI, int_unpred, int_pred>;
5522 multiclass MVE_VQDMULH_qr_m<MVEVectorVTInfo VTI> :
5523 MVE_VxxMUL_qr_m<"vqdmulh", VTI, 0b0, MVEvqdmulh,
5524 int_arm_mve_vqdmulh, int_arm_mve_qdmulh_predicated>;
5526 multiclass MVE_VQRDMULH_qr_m<MVEVectorVTInfo VTI> :
5527 MVE_VxxMUL_qr_m<"vqrdmulh", VTI, 0b1, null_frag,
5528 int_arm_mve_vqrdmulh, int_arm_mve_qrdmulh_predicated>;
5530 defm MVE_VQDMULH_qr_s8 : MVE_VQDMULH_qr_m<MVE_v16s8>;
5531 defm MVE_VQDMULH_qr_s16 : MVE_VQDMULH_qr_m<MVE_v8s16>;
5532 defm MVE_VQDMULH_qr_s32 : MVE_VQDMULH_qr_m<MVE_v4s32>;
5534 defm MVE_VQRDMULH_qr_s8 : MVE_VQRDMULH_qr_m<MVE_v16s8>;
5535 defm MVE_VQRDMULH_qr_s16 : MVE_VQRDMULH_qr_m<MVE_v8s16>;
5536 defm MVE_VQRDMULH_qr_s32 : MVE_VQRDMULH_qr_m<MVE_v4s32>;
5538 multiclass MVE_VxxMUL_qr_f_m<MVEVectorVTInfo VTI, SDPatternOperator IdentityVec> {
5539 let validForTailPredication = 1 in
5540 def "" : MVE_VxxMUL_qr<"vmul", VTI.Suffix, VTI.Size{0}, 0b11, VTI.Size>;
5541 defm : MVE_TwoOpPatternDup<VTI, fmul, int_arm_mve_mul_predicated, (? ),
5542 !cast<Instruction>(NAME), IdentityVec>;
5545 let Predicates = [HasMVEFloat] in {
5546 defm MVE_VMUL_qr_f16 : MVE_VxxMUL_qr_f_m<MVE_v8f16, ARMimmOneH>;
5547 defm MVE_VMUL_qr_f32 : MVE_VxxMUL_qr_f_m<MVE_v4f32, ARMimmOneF>;
5550 class MVE_VFMAMLA_qr<string iname, string suffix,
5551 bit bit_28, bits<2> bits_21_20, bit S,
5552 bits<2> vecsize, list<dag> pattern=[]>
5553 : MVE_qDestSrc_rSrc<iname, suffix, vecsize, pattern> {
5555 let Inst{28} = bit_28;
5556 let Inst{21-20} = bits_21_20;
5561 let validForTailPredication = 1;
5562 let hasSideEffects = 0;
5565 multiclass MVE_VMLA_qr_multi<string iname, MVEVectorVTInfo VTI,
5566 bit scalar_addend> {
5567 def "": MVE_VFMAMLA_qr<iname, VTI.Suffix, 0b0, VTI.Size,
5568 scalar_addend, VTI.Size>;
5569 defvar Inst = !cast<Instruction>(NAME);
5570 defvar pred_int = !cast<Intrinsic>("int_arm_mve_" # iname # "_n_predicated");
5571 defvar v1 = (VTI.Vec MQPR:$v1);
5572 defvar v2 = (VTI.Vec MQPR:$v2);
5573 defvar vs = (VTI.Vec (ARMvdup rGPR:$s));
5574 defvar s = (i32 rGPR:$s);
5575 defvar pred = (VTI.Pred VCCR:$pred);
5577 let Predicates = [HasMVEInt] in {
5578 if scalar_addend then {
5579 def : Pat<(VTI.Vec (add (mul v1, v2), vs)),
5580 (VTI.Vec (Inst v1, v2, s))>;
5582 def : Pat<(VTI.Vec (add (mul v2, vs), v1)),
5583 (VTI.Vec (Inst v1, v2, s))>;
5586 def : Pat<(VTI.Vec (pred_int v1, v2, s, pred)),
5587 (VTI.Vec (Inst v1, v2, s, ARMVCCThen, pred, zero_reg))>;
5591 defm MVE_VMLA_qr_i8 : MVE_VMLA_qr_multi<"vmla", MVE_v16i8, 0b0>;
5592 defm MVE_VMLA_qr_i16 : MVE_VMLA_qr_multi<"vmla", MVE_v8i16, 0b0>;
5593 defm MVE_VMLA_qr_i32 : MVE_VMLA_qr_multi<"vmla", MVE_v4i32, 0b0>;
5595 defm MVE_VMLAS_qr_i8 : MVE_VMLA_qr_multi<"vmlas", MVE_v16i8, 0b1>;
5596 defm MVE_VMLAS_qr_i16 : MVE_VMLA_qr_multi<"vmlas", MVE_v8i16, 0b1>;
5597 defm MVE_VMLAS_qr_i32 : MVE_VMLA_qr_multi<"vmlas", MVE_v4i32, 0b1>;
5599 multiclass MVE_VFMA_qr_multi<string iname, MVEVectorVTInfo VTI,
5600 bit scalar_addend> {
5601 def "": MVE_VFMAMLA_qr<iname, VTI.Suffix, VTI.Size{0}, 0b11, scalar_addend, VTI.Size>;
5602 defvar Inst = !cast<Instruction>(NAME);
5603 defvar pred_int = int_arm_mve_fma_predicated;
5604 defvar v1 = (VTI.Vec MQPR:$v1);
5605 defvar v2 = (VTI.Vec MQPR:$v2);
5606 defvar vs = (VTI.Vec (ARMvdup (i32 rGPR:$s)));
5607 defvar is = (i32 rGPR:$s);
5608 defvar pred = (VTI.Pred VCCR:$pred);
5610 let Predicates = [HasMVEFloat] in {
5611 if scalar_addend then {
5612 def : Pat<(VTI.Vec (fma v1, v2, vs)),
5613 (VTI.Vec (Inst v1, v2, is))>;
5614 def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred),
5615 (VTI.Vec (fma v1, v2, vs)),
5617 (VTI.Vec (Inst v1, v2, is, ARMVCCThen, $pred, zero_reg))>;
5619 def : Pat<(VTI.Vec (fma v1, vs, v2)),
5620 (VTI.Vec (Inst v2, v1, is))>;
5621 def : Pat<(VTI.Vec (fma vs, v1, v2)),
5622 (VTI.Vec (Inst v2, v1, is))>;
5623 def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred),
5624 (VTI.Vec (fma vs, v2, v1)),
5626 (VTI.Vec (Inst v1, v2, is, ARMVCCThen, $pred, zero_reg))>;
5627 def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred),
5628 (VTI.Vec (fma v2, vs, v1)),
5630 (VTI.Vec (Inst v1, v2, is, ARMVCCThen, $pred, zero_reg))>;
5631 def : Pat<(VTI.Vec (pred_int v1, vs, v2, pred)),
5632 (VTI.Vec (Inst v2, v1, is, ARMVCCThen, pred, zero_reg))>;
5633 def : Pat<(VTI.Vec (pred_int vs, v1, v2, pred)),
5634 (VTI.Vec (Inst v2, v1, is, ARMVCCThen, pred, zero_reg))>;
5639 let Predicates = [HasMVEFloat] in {
5640 defm MVE_VFMA_qr_f16 : MVE_VFMA_qr_multi<"vfma", MVE_v8f16, 0>;
5641 defm MVE_VFMA_qr_f32 : MVE_VFMA_qr_multi<"vfma", MVE_v4f32, 0>;
5642 defm MVE_VFMA_qr_Sf16 : MVE_VFMA_qr_multi<"vfmas", MVE_v8f16, 1>;
5643 defm MVE_VFMA_qr_Sf32 : MVE_VFMA_qr_multi<"vfmas", MVE_v4f32, 1>;
5646 class MVE_VQDMLAH_qr<string iname, string suffix, bit U, bits<2> size,
5647 bit bit_5, bit bit_12, list<dag> pattern=[]>
5648 : MVE_qDestSrc_rSrc<iname, suffix, size, pattern> {
5651 let Inst{21-20} = size;
5653 let Inst{12} = bit_12;
5655 let Inst{5} = bit_5;
5658 multiclass MVE_VQDMLAH_qr_multi<string iname, MVEVectorVTInfo VTI,
5659 bit bit_5, bit bit_12> {
5660 def "": MVE_VQDMLAH_qr<iname, VTI.Suffix, 0b0, VTI.Size, bit_5, bit_12>;
5661 defvar Inst = !cast<Instruction>(NAME);
5662 defvar unpred_int = !cast<Intrinsic>("int_arm_mve_" # iname);
5663 defvar pred_int = !cast<Intrinsic>("int_arm_mve_" # iname # "_predicated");
5665 let Predicates = [HasMVEInt] in {
5666 def : Pat<(VTI.Vec (unpred_int (VTI.Vec MQPR:$v1), (VTI.Vec MQPR:$v2),
5668 (VTI.Vec (Inst (VTI.Vec MQPR:$v1), (VTI.Vec MQPR:$v2),
5670 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$v1), (VTI.Vec MQPR:$v2),
5671 (i32 rGPR:$s), (VTI.Pred VCCR:$pred))),
5672 (VTI.Vec (Inst (VTI.Vec MQPR:$v1), (VTI.Vec MQPR:$v2),
5673 (i32 rGPR:$s), ARMVCCThen,
5674 (VTI.Pred VCCR:$pred), zero_reg))>;
5678 multiclass MVE_VQDMLAH_qr_types<string iname, bit bit_5, bit bit_12> {
5679 defm s8 : MVE_VQDMLAH_qr_multi<iname, MVE_v16s8, bit_5, bit_12>;
5680 defm s16 : MVE_VQDMLAH_qr_multi<iname, MVE_v8s16, bit_5, bit_12>;
5681 defm s32 : MVE_VQDMLAH_qr_multi<iname, MVE_v4s32, bit_5, bit_12>;
5684 defm MVE_VQDMLAH_qr : MVE_VQDMLAH_qr_types<"vqdmlah", 0b1, 0b0>;
5685 defm MVE_VQRDMLAH_qr : MVE_VQDMLAH_qr_types<"vqrdmlah", 0b0, 0b0>;
5686 defm MVE_VQDMLASH_qr : MVE_VQDMLAH_qr_types<"vqdmlash", 0b1, 0b1>;
5687 defm MVE_VQRDMLASH_qr : MVE_VQDMLAH_qr_types<"vqrdmlash", 0b0, 0b1>;
5689 class MVE_VxDUP<string iname, string suffix, bits<2> size, bit bit_12,
5690 ValueType VT, SDPatternOperator vxdup>
5691 : MVE_p<(outs MQPR:$Qd, tGPREven:$Rn),
5692 (ins tGPREven:$Rn_src, MVE_VIDUP_imm:$imm), NoItinerary,
5693 iname, suffix, "$Qd, $Rn, $imm", vpred_r, "$Rn = $Rn_src", size,
5694 [(set (VT MQPR:$Qd), (i32 tGPREven:$Rn),
5695 (vxdup (i32 tGPREven:$Rn_src), (i32 imm:$imm)))]> {
5701 let Inst{25-23} = 0b100;
5702 let Inst{22} = Qd{3};
5703 let Inst{21-20} = size;
5704 let Inst{19-17} = Rn{3-1};
5706 let Inst{15-13} = Qd{2-0};
5707 let Inst{12} = bit_12;
5708 let Inst{11-8} = 0b1111;
5709 let Inst{7} = imm{1};
5710 let Inst{6-1} = 0b110111;
5711 let Inst{0} = imm{0};
5712 let validForTailPredication = 1;
5713 let hasSideEffects = 0;
5716 def MVE_VIDUPu8 : MVE_VxDUP<"vidup", "u8", 0b00, 0b0, v16i8, ARMvidup>;
5717 def MVE_VIDUPu16 : MVE_VxDUP<"vidup", "u16", 0b01, 0b0, v8i16, ARMvidup>;
5718 def MVE_VIDUPu32 : MVE_VxDUP<"vidup", "u32", 0b10, 0b0, v4i32, ARMvidup>;
5720 def MVE_VDDUPu8 : MVE_VxDUP<"vddup", "u8", 0b00, 0b1, v16i8, null_frag>;
5721 def MVE_VDDUPu16 : MVE_VxDUP<"vddup", "u16", 0b01, 0b1, v8i16, null_frag>;
5722 def MVE_VDDUPu32 : MVE_VxDUP<"vddup", "u32", 0b10, 0b1, v4i32, null_frag>;
5724 class MVE_VxWDUP<string iname, string suffix, bits<2> size, bit bit_12,
5725 list<dag> pattern=[]>
5726 : MVE_p<(outs MQPR:$Qd, tGPREven:$Rn),
5727 (ins tGPREven:$Rn_src, tGPROdd:$Rm, MVE_VIDUP_imm:$imm), NoItinerary,
5728 iname, suffix, "$Qd, $Rn, $Rm, $imm", vpred_r, "$Rn = $Rn_src", size,
5736 let Inst{25-23} = 0b100;
5737 let Inst{22} = Qd{3};
5738 let Inst{21-20} = size;
5739 let Inst{19-17} = Rn{3-1};
5741 let Inst{15-13} = Qd{2-0};
5742 let Inst{12} = bit_12;
5743 let Inst{11-8} = 0b1111;
5744 let Inst{7} = imm{1};
5745 let Inst{6-4} = 0b110;
5746 let Inst{3-1} = Rm{3-1};
5747 let Inst{0} = imm{0};
5748 let validForTailPredication = 1;
5749 let hasSideEffects = 0;
5752 def MVE_VIWDUPu8 : MVE_VxWDUP<"viwdup", "u8", 0b00, 0b0>;
5753 def MVE_VIWDUPu16 : MVE_VxWDUP<"viwdup", "u16", 0b01, 0b0>;
5754 def MVE_VIWDUPu32 : MVE_VxWDUP<"viwdup", "u32", 0b10, 0b0>;
5756 def MVE_VDWDUPu8 : MVE_VxWDUP<"vdwdup", "u8", 0b00, 0b1>;
5757 def MVE_VDWDUPu16 : MVE_VxWDUP<"vdwdup", "u16", 0b01, 0b1>;
5758 def MVE_VDWDUPu32 : MVE_VxWDUP<"vdwdup", "u32", 0b10, 0b1>;
5760 let isReMaterializable = 1 in
5761 class MVE_VCTPInst<string suffix, bits<2> size, list<dag> pattern=[]>
5762 : MVE_p<(outs VCCR:$P0), (ins rGPR:$Rn), NoItinerary, "vctp", suffix,
5763 "$Rn", vpred_n, "", size, pattern> {
5766 let Inst{28-27} = 0b10;
5767 let Inst{26-22} = 0b00000;
5768 let Inst{21-20} = size;
5769 let Inst{19-16} = Rn{3-0};
5770 let Inst{15-11} = 0b11101;
5771 let Inst{10-0} = 0b00000000001;
5772 let Unpredictable{10-0} = 0b11111111111;
5774 let Constraints = "";
5775 let DecoderMethod = "DecodeMveVCTP";
5776 let validForTailPredication = 1;
5779 multiclass MVE_VCTP<MVEVectorVTInfo VTI, Intrinsic intr> {
5780 def "": MVE_VCTPInst<VTI.BitsSuffix, VTI.Size>;
5781 defvar Inst = !cast<Instruction>(NAME);
5783 let Predicates = [HasMVEInt] in {
5784 def : Pat<(intr rGPR:$Rn),
5785 (VTI.Pred (Inst rGPR:$Rn))>;
5786 def : Pat<(and (intr rGPR:$Rn), (VTI.Pred VCCR:$mask)),
5787 (VTI.Pred (Inst rGPR:$Rn, ARMVCCThen, VCCR:$mask, zero_reg))>;
5791 defm MVE_VCTP8 : MVE_VCTP<MVE_v16i8, int_arm_mve_vctp8>;
5792 defm MVE_VCTP16 : MVE_VCTP<MVE_v8i16, int_arm_mve_vctp16>;
5793 defm MVE_VCTP32 : MVE_VCTP<MVE_v4i32, int_arm_mve_vctp32>;
5794 defm MVE_VCTP64 : MVE_VCTP<MVE_v2i64, int_arm_mve_vctp64>;
5796 // end of mve_qDest_rSrc
5798 // start of coproc mov
5800 class MVE_VMOV_64bit<dag oops, dag iops, bit to_qreg, string ops, string cstr>
5801 : MVE_VMOV_lane_base<oops, !con(iops, (ins MVEPairVectorIndex2:$idx,
5802 MVEPairVectorIndex0:$idx2)),
5803 NoItinerary, "vmov", "", ops, cstr, []> {
5810 let Inst{31-23} = 0b111011000;
5811 let Inst{22} = Qd{3};
5813 let Inst{20} = to_qreg;
5814 let Inst{19-16} = Rt2{3-0};
5815 let Inst{15-13} = Qd{2-0};
5816 let Inst{12-5} = 0b01111000;
5818 let Inst{3-0} = Rt{3-0};
5821 let hasSideEffects = 0;
5824 // The assembly syntax for these instructions mentions the vector
5825 // register name twice, e.g.
5827 // vmov q2[2], q2[0], r0, r1
5828 // vmov r0, r1, q2[2], q2[0]
5830 // which needs a bit of juggling with MC operand handling.
5832 // For the move _into_ a vector register, the MC operand list also has
5833 // to mention the register name twice: once as the output, and once as
5834 // an extra input to represent where the unchanged half of the output
5835 // register comes from (when this instruction is used in code
5836 // generation). So we arrange that the first mention of the vector reg
5837 // in the instruction is considered by the AsmMatcher to be the output
5838 // ($Qd), and the second one is the input ($QdSrc). Binding them
5839 // together with the existing 'tie' constraint is enough to enforce at
5840 // register allocation time that they have to be the same register.
5842 // For the move _from_ a vector register, there's no way to get round
5843 // the fact that both instances of that register name have to be
5844 // inputs. They have to be the same register again, but this time, we
5845 // can't use a tie constraint, because that has to be between an
5846 // output and an input operand. So this time, we have to arrange that
5847 // the q-reg appears just once in the MC operand list, in spite of
5848 // being mentioned twice in the asm syntax - which needs a custom
5849 // AsmMatchConverter.
5851 def MVE_VMOV_q_rr : MVE_VMOV_64bit<(outs MQPR:$Qd),
5852 (ins MQPR:$QdSrc, rGPR:$Rt, rGPR:$Rt2),
5853 0b1, "$Qd$idx, $QdSrc$idx2, $Rt, $Rt2",
5855 let DecoderMethod = "DecodeMVEVMOVDRegtoQ";
5858 def MVE_VMOV_rr_q : MVE_VMOV_64bit<(outs rGPR:$Rt, rGPR:$Rt2), (ins MQPR:$Qd),
5859 0b0, "$Rt, $Rt2, $Qd$idx, $Qd$idx2", ""> {
5860 let DecoderMethod = "DecodeMVEVMOVQtoDReg";
5861 let AsmMatchConverter = "cvtMVEVMOVQtoDReg";
5864 let Predicates = [HasMVEInt] in {
5865 // Double lane moves. There are a number of patterns here. We know that the
5866 // insertelt's will be in descending order by index, and need to match the 5
5867 // patterns that might contain 2-0 or 3-1 pairs. These are:
5868 // 3 2 1 0 -> vmovqrr 31; vmovqrr 20
5869 // 3 2 1 -> vmovqrr 31; vmov 2
5870 // 3 1 -> vmovqrr 31
5871 // 2 1 0 -> vmovqrr 20; vmov 1
5872 // 2 0 -> vmovqrr 20
5873 // The other potential patterns will be handled by single lane inserts.
5874 def : Pat<(insertelt (insertelt (insertelt (insertelt (v4i32 MQPR:$src1),
5875 rGPR:$srcA, (i32 0)),
5876 rGPR:$srcB, (i32 1)),
5877 rGPR:$srcC, (i32 2)),
5878 rGPR:$srcD, (i32 3)),
5879 (MVE_VMOV_q_rr (MVE_VMOV_q_rr MQPR:$src1, rGPR:$srcA, rGPR:$srcC, (i32 2), (i32 0)),
5880 rGPR:$srcB, rGPR:$srcD, (i32 3), (i32 1))>;
5881 def : Pat<(insertelt (insertelt (insertelt (v4i32 MQPR:$src1),
5882 rGPR:$srcB, (i32 1)),
5883 rGPR:$srcC, (i32 2)),
5884 rGPR:$srcD, (i32 3)),
5885 (MVE_VMOV_q_rr (MVE_VMOV_to_lane_32 MQPR:$src1, rGPR:$srcC, (i32 2)),
5886 rGPR:$srcB, rGPR:$srcD, (i32 3), (i32 1))>;
5887 def : Pat<(insertelt (insertelt (v4i32 MQPR:$src1), rGPR:$srcA, (i32 1)), rGPR:$srcB, (i32 3)),
5888 (MVE_VMOV_q_rr MQPR:$src1, rGPR:$srcA, rGPR:$srcB, (i32 3), (i32 1))>;
5889 def : Pat<(insertelt (insertelt (insertelt (v4i32 MQPR:$src1),
5890 rGPR:$srcB, (i32 0)),
5891 rGPR:$srcC, (i32 1)),
5892 rGPR:$srcD, (i32 2)),
5893 (MVE_VMOV_q_rr (MVE_VMOV_to_lane_32 MQPR:$src1, rGPR:$srcC, (i32 1)),
5894 rGPR:$srcB, rGPR:$srcD, (i32 2), (i32 0))>;
5895 def : Pat<(insertelt (insertelt (v4i32 MQPR:$src1), rGPR:$srcA, (i32 0)), rGPR:$srcB, (i32 2)),
5896 (MVE_VMOV_q_rr MQPR:$src1, rGPR:$srcA, rGPR:$srcB, (i32 2), (i32 0))>;
5899 // end of coproc mov
5901 // start of MVE interleaving load/store
5903 // Base class for the family of interleaving/deinterleaving
5904 // load/stores with names like VLD20.8 and VST43.32.
5905 class MVE_vldst24_base<bit writeback, bit fourregs, bits<2> stage, bits<2> size,
5906 bit load, dag Oops, dag loadIops, dag wbIops,
5907 string iname, string ops,
5908 string cstr, list<dag> pattern=[]>
5909 : MVE_MI<Oops, !con(loadIops, wbIops), NoItinerary, iname, ops, cstr, size, pattern> {
5913 let Inst{31-22} = 0b1111110010;
5914 let Inst{21} = writeback;
5915 let Inst{20} = load;
5916 let Inst{19-16} = Rn;
5917 let Inst{15-13} = VQd{2-0};
5918 let Inst{12-9} = 0b1111;
5919 let Inst{8-7} = size;
5920 let Inst{6-5} = stage;
5921 let Inst{4-1} = 0b0000;
5922 let Inst{0} = fourregs;
5925 let mayStore = !eq(load,0);
5926 let hasSideEffects = 0;
5927 let validForTailPredication = load;
5930 // A parameter class used to encapsulate all the ways the writeback
5931 // variants of VLD20 and friends differ from the non-writeback ones.
5932 class MVE_vldst24_writeback<bit b, dag Oo, dag Io,
5933 string sy="", string c="", string n=""> {
5939 string id_suffix = n;
5942 // Another parameter class that encapsulates the differences between VLD2x
5944 class MVE_vldst24_nvecs<int n, list<int> s, bit b, RegisterOperand vl> {
5946 list<int> stages = s;
5948 RegisterOperand VecList = vl;
5951 // A third parameter class that distinguishes VLDnn.8 from .16 from .32.
5952 class MVE_vldst24_lanesize<int i, bits<2> b> {
5954 bits<2> sizebits = b;
5957 // A base class for each direction of transfer: one for load, one for
5958 // store. I can't make these a fourth independent parametric tuple
5959 // class, because they have to take the nvecs tuple class as a
5960 // parameter, in order to find the right VecList operand type.
5962 class MVE_vld24_base<MVE_vldst24_nvecs n, bits<2> pat, bits<2> size,
5963 MVE_vldst24_writeback wb, string iname,
5964 list<dag> pattern=[]>
5965 : MVE_vldst24_base<wb.writeback, n.bit0, pat, size, 1,
5966 !con((outs n.VecList:$VQd), wb.Oops),
5967 (ins n.VecList:$VQdSrc), wb.Iops,
5968 iname, "$VQd, $Rn" # wb.syntax,
5969 wb.cstr # ",$VQdSrc = $VQd", pattern>;
5971 class MVE_vst24_base<MVE_vldst24_nvecs n, bits<2> pat, bits<2> size,
5972 MVE_vldst24_writeback wb, string iname,
5973 list<dag> pattern=[]>
5974 : MVE_vldst24_base<wb.writeback, n.bit0, pat, size, 0,
5975 wb.Oops, (ins n.VecList:$VQd), wb.Iops,
5976 iname, "$VQd, $Rn" # wb.syntax,
5979 // Actually define all the interleaving loads and stores, by a series
5980 // of nested foreaches over number of vectors (VLD2/VLD4); stage
5981 // within one of those series (VLDx0/VLDx1/VLDx2/VLDx3); size of
5982 // vector lane; writeback or no writeback.
5983 foreach n = [MVE_vldst24_nvecs<2, [0,1], 0, VecList2Q>,
5984 MVE_vldst24_nvecs<4, [0,1,2,3], 1, VecList4Q>] in
5985 foreach stage = n.stages in
5986 foreach s = [MVE_vldst24_lanesize< 8, 0b00>,
5987 MVE_vldst24_lanesize<16, 0b01>,
5988 MVE_vldst24_lanesize<32, 0b10>] in
5989 foreach wb = [MVE_vldst24_writeback<
5990 1, (outs rGPR:$wb), (ins t2_nosp_addr_offset_none:$Rn),
5991 "!", "$Rn.base = $wb", "_wb">,
5992 MVE_vldst24_writeback<0, (outs), (ins t2_addr_offset_none:$Rn)>] in {
5994 // For each case within all of those foreaches, define the actual
5995 // instructions. The def names are made by gluing together pieces
5996 // from all the parameter classes, and will end up being things like
5997 // MVE_VLD20_8 and MVE_VST43_16_wb.
5999 def "MVE_VLD" # n.nvecs # stage # "_" # s.lanesize # wb.id_suffix
6000 : MVE_vld24_base<n, stage, s.sizebits, wb,
6001 "vld" # n.nvecs # stage # "." # s.lanesize>;
6003 def "MVE_VST" # n.nvecs # stage # "_" # s.lanesize # wb.id_suffix
6004 : MVE_vst24_base<n, stage, s.sizebits, wb,
6005 "vst" # n.nvecs # stage # "." # s.lanesize>;
6008 def SDTARMVST2 : SDTypeProfile<1, 5, [SDTCisPtrTy<0>, SDTCisPtrTy<1>, SDTCisVT<2, i32>, SDTCisVec<3>,
6009 SDTCisSameAs<3, 4>, SDTCisVT<5, i32>]>;
6010 def SDTARMVST4 : SDTypeProfile<1, 7, [SDTCisPtrTy<0>, SDTCisPtrTy<1>, SDTCisVT<2, i32>, SDTCisVec<3>,
6011 SDTCisSameAs<3, 4>, SDTCisSameAs<3, 5>,
6012 SDTCisSameAs<3, 6>, SDTCisVT<7, i32>]>;
6013 def MVEVST2UPD : SDNode<"ARMISD::VST2_UPD", SDTARMVST2, [SDNPHasChain, SDNPMemOperand]>;
6014 def MVEVST4UPD : SDNode<"ARMISD::VST4_UPD", SDTARMVST4, [SDNPHasChain, SDNPMemOperand]>;
6016 multiclass MVE_vst24_patterns<int lanesize, ValueType VT> {
6017 foreach stage = [0,1] in
6018 def : Pat<(int_arm_mve_vst2q i32:$addr,
6019 (VT MQPR:$v0), (VT MQPR:$v1), (i32 stage)),
6020 (!cast<Instruction>("MVE_VST2"#stage#"_"#lanesize)
6021 (REG_SEQUENCE MQQPR, VT:$v0, qsub_0, VT:$v1, qsub_1),
6022 t2_addr_offset_none:$addr)>;
6023 foreach stage = [0,1] in
6024 def : Pat<(i32 (MVEVST2UPD i32:$addr, (i32 32),
6025 (VT MQPR:$v0), (VT MQPR:$v1), (i32 stage))),
6026 (i32 (!cast<Instruction>("MVE_VST2"#stage#"_"#lanesize#_wb)
6027 (REG_SEQUENCE MQQPR, VT:$v0, qsub_0, VT:$v1, qsub_1),
6028 t2_addr_offset_none:$addr))>;
6030 foreach stage = [0,1,2,3] in
6031 def : Pat<(int_arm_mve_vst4q i32:$addr,
6032 (VT MQPR:$v0), (VT MQPR:$v1),
6033 (VT MQPR:$v2), (VT MQPR:$v3), (i32 stage)),
6034 (!cast<Instruction>("MVE_VST4"#stage#"_"#lanesize)
6035 (REG_SEQUENCE MQQQQPR, VT:$v0, qsub_0, VT:$v1, qsub_1,
6036 VT:$v2, qsub_2, VT:$v3, qsub_3),
6037 t2_addr_offset_none:$addr)>;
6038 foreach stage = [0,1,2,3] in
6039 def : Pat<(i32 (MVEVST4UPD i32:$addr, (i32 64),
6040 (VT MQPR:$v0), (VT MQPR:$v1),
6041 (VT MQPR:$v2), (VT MQPR:$v3), (i32 stage))),
6042 (i32 (!cast<Instruction>("MVE_VST4"#stage#"_"#lanesize#_wb)
6043 (REG_SEQUENCE MQQQQPR, VT:$v0, qsub_0, VT:$v1, qsub_1,
6044 VT:$v2, qsub_2, VT:$v3, qsub_3),
6045 t2_addr_offset_none:$addr))>;
6047 defm : MVE_vst24_patterns<8, v16i8>;
6048 defm : MVE_vst24_patterns<16, v8i16>;
6049 defm : MVE_vst24_patterns<32, v4i32>;
6050 defm : MVE_vst24_patterns<16, v8f16>;
6051 defm : MVE_vst24_patterns<32, v4f32>;
6053 // end of MVE interleaving load/store
6055 // start of MVE predicable load/store
6057 // A parameter class for the direction of transfer.
6058 class MVE_ldst_direction<bit b, dag Oo, dag Io, string c=""> {
6064 def MVE_ld: MVE_ldst_direction<1, (outs MQPR:$Qd), (ins), ",@earlyclobber $Qd">;
6065 def MVE_st: MVE_ldst_direction<0, (outs), (ins MQPR:$Qd)>;
6067 // A parameter class for the size of memory access in a load.
6068 class MVE_memsz<bits<2> e, int s, AddrMode m, string mn, list<string> types> {
6069 bits<2> encoding = e; // opcode bit(s) for encoding
6070 int shift = s; // shift applied to immediate load offset
6073 // For instruction aliases: define the complete list of type
6074 // suffixes at this size, and the canonical ones for loads and
6076 string MnemonicLetter = mn;
6077 int TypeBits = !shl(8, s);
6078 string CanonLoadSuffix = ".u" # TypeBits;
6079 string CanonStoreSuffix = "." # TypeBits;
6080 list<string> suffixes = !foreach(letter, types, "." # letter # TypeBits);
6083 // Instances of MVE_memsz.
6085 // (memD doesn't need an AddrMode, because those are only for
6086 // contiguous loads, and memD is only used by gather/scatters.)
6087 def MVE_memB: MVE_memsz<0b00, 0, AddrModeT2_i7, "b", ["", "u", "s"]>;
6088 def MVE_memH: MVE_memsz<0b01, 1, AddrModeT2_i7s2, "h", ["", "u", "s", "f"]>;
6089 def MVE_memW: MVE_memsz<0b10, 2, AddrModeT2_i7s4, "w", ["", "u", "s", "f"]>;
6090 def MVE_memD: MVE_memsz<0b11, 3, ?, "d", ["", "u", "s", "f"]>;
6092 // This is the base class for all the MVE loads and stores other than
6093 // the interleaving ones. All the non-interleaving loads/stores share
6094 // the characteristic that they operate on just one vector register,
6095 // so they are VPT-predicable.
6097 // The predication operand is vpred_n, for both loads and stores. For
6098 // store instructions, the reason is obvious: if there is no output
6099 // register, there can't be a need for an input parameter giving the
6100 // output register's previous value. Load instructions also don't need
6101 // that input parameter, because unlike MVE data processing
6102 // instructions, predicated loads are defined to set the inactive
6103 // lanes of the output register to zero, instead of preserving their
6105 class MVE_VLDRSTR_base<MVE_ldst_direction dir, bit U, bit P, bit W, bit opc,
6106 dag oops, dag iops, string asm, string suffix,
6107 string ops, string cstr, bits<2> vecsize, list<dag> pattern=[]>
6108 : MVE_p<oops, iops, NoItinerary, asm, suffix, ops, vpred_n, cstr, vecsize, pattern> {
6116 let Inst{20} = dir.load;
6117 let Inst{15-13} = Qd{2-0};
6119 let Inst{11-9} = 0b111;
6121 let mayLoad = dir.load;
6122 let mayStore = !eq(dir.load,0);
6123 let hasSideEffects = 0;
6124 let validForTailPredication = 1;
6127 // Contiguous load and store instructions. These come in two main
6128 // categories: same-size loads/stores in which 128 bits of vector
6129 // register is transferred to or from 128 bits of memory in the most
6130 // obvious way, and widening loads / narrowing stores, in which the
6131 // size of memory accessed is less than the size of a vector register,
6132 // so the load instructions sign- or zero-extend each memory value
6133 // into a wider vector lane, and the store instructions truncate
6136 // The instruction mnemonics for these two classes look reasonably
6137 // similar, but the actual encodings are different enough to need two
6138 // separate base classes.
6140 // Contiguous, same size
6141 class MVE_VLDRSTR_cs<MVE_ldst_direction dir, MVE_memsz memsz, bit P, bit W,
6142 dag oops, dag iops, string asm, string suffix,
6143 IndexMode im, string ops, string cstr>
6144 : MVE_VLDRSTR_base<dir, 0, P, W, 1, oops, iops, asm, suffix, ops, cstr, memsz.encoding> {
6146 let Inst{23} = addr{7};
6147 let Inst{19-16} = addr{11-8};
6148 let Inst{8-7} = memsz.encoding;
6149 let Inst{6-0} = addr{6-0};
6154 // Contiguous, widening/narrowing
6155 class MVE_VLDRSTR_cw<MVE_ldst_direction dir, MVE_memsz memsz, bit U,
6156 bit P, bit W, bits<2> size, dag oops, dag iops,
6157 string asm, string suffix, IndexMode im,
6158 string ops, string cstr>
6159 : MVE_VLDRSTR_base<dir, U, P, W, 0, oops, iops, asm, suffix, ops, cstr, size> {
6161 let Inst{23} = addr{7};
6162 let Inst{19} = memsz.encoding{0}; // enough to tell 16- from 32-bit
6163 let Inst{18-16} = addr{10-8};
6164 let Inst{8-7} = size;
6165 let Inst{6-0} = addr{6-0};
6170 // Multiclass wrapper on each of the _cw and _cs base classes, to
6171 // generate three writeback modes (none, preindex, postindex).
6173 multiclass MVE_VLDRSTR_cw_m<MVE_ldst_direction dir, MVE_memsz memsz,
6174 string asm, string suffix, bit U, bits<2> size> {
6175 let AM = memsz.AM in {
6176 def "" : MVE_VLDRSTR_cw<
6177 dir, memsz, U, 1, 0, size,
6178 dir.Oops, !con(dir.Iops, (ins taddrmode_imm7<memsz.shift>:$addr)),
6179 asm, suffix, IndexModeNone, "$Qd, $addr", "">;
6181 def _pre : MVE_VLDRSTR_cw<
6182 dir, memsz, U, 1, 1, size,
6183 !con((outs tGPR:$wb), dir.Oops),
6184 !con(dir.Iops, (ins taddrmode_imm7<memsz.shift>:$addr)),
6185 asm, suffix, IndexModePre, "$Qd, $addr!", "$addr.base = $wb"> {
6186 let DecoderMethod = "DecodeMVE_MEM_1_pre<"#memsz.shift#">";
6189 def _post : MVE_VLDRSTR_cw<
6190 dir, memsz, U, 0, 1, size,
6191 !con((outs tGPR:$wb), dir.Oops),
6192 !con(dir.Iops, (ins t_addr_offset_none:$Rn,
6193 t2am_imm7_offset<memsz.shift>:$addr)),
6194 asm, suffix, IndexModePost, "$Qd, $Rn$addr", "$Rn.base = $wb"> {
6196 let Inst{18-16} = Rn{2-0};
6201 multiclass MVE_VLDRSTR_cs_m<MVE_ldst_direction dir, MVE_memsz memsz,
6202 string asm, string suffix> {
6203 let AM = memsz.AM in {
6204 def "" : MVE_VLDRSTR_cs<
6206 dir.Oops, !con(dir.Iops, (ins t2addrmode_imm7<memsz.shift>:$addr)),
6207 asm, suffix, IndexModeNone, "$Qd, $addr", "">;
6209 def _pre : MVE_VLDRSTR_cs<
6211 !con((outs rGPR:$wb), dir.Oops),
6212 !con(dir.Iops, (ins t2addrmode_imm7_pre<memsz.shift>:$addr)),
6213 asm, suffix, IndexModePre, "$Qd, $addr!", "$addr.base = $wb"> {
6214 let DecoderMethod = "DecodeMVE_MEM_2_pre<"#memsz.shift#">";
6217 def _post : MVE_VLDRSTR_cs<
6219 !con((outs rGPR:$wb), dir.Oops),
6220 !con(dir.Iops, (ins t2_nosp_addr_offset_none:$Rn,
6221 t2am_imm7_offset<memsz.shift>:$addr)),
6222 asm, suffix, IndexModePost, "$Qd, $Rn$addr", "$Rn.base = $wb"> {
6224 let Inst{19-16} = Rn{3-0};
6229 // Now actually declare all the contiguous load/stores, via those
6230 // multiclasses. The instruction ids coming out of this are the bare
6231 // names shown in the defm, with _pre or _post appended for writeback,
6232 // e.g. MVE_VLDRBS16, MVE_VSTRB16_pre, MVE_VSTRHU16_post.
6234 defm MVE_VLDRBS16: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "s16", 0, 0b01>;
6235 defm MVE_VLDRBS32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "s32", 0, 0b10>;
6236 defm MVE_VLDRBU16: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "u16", 1, 0b01>;
6237 defm MVE_VLDRBU32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "u32", 1, 0b10>;
6238 defm MVE_VLDRHS32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memH, "vldrh", "s32", 0, 0b10>;
6239 defm MVE_VLDRHU32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memH, "vldrh", "u32", 1, 0b10>;
6241 defm MVE_VLDRBU8: MVE_VLDRSTR_cs_m<MVE_ld, MVE_memB, "vldrb", "u8">;
6242 defm MVE_VLDRHU16: MVE_VLDRSTR_cs_m<MVE_ld, MVE_memH, "vldrh", "u16">;
6243 defm MVE_VLDRWU32: MVE_VLDRSTR_cs_m<MVE_ld, MVE_memW, "vldrw", "u32">;
6245 defm MVE_VSTRB16: MVE_VLDRSTR_cw_m<MVE_st, MVE_memB, "vstrb", "16", 0, 0b01>;
6246 defm MVE_VSTRB32: MVE_VLDRSTR_cw_m<MVE_st, MVE_memB, "vstrb", "32", 0, 0b10>;
6247 defm MVE_VSTRH32: MVE_VLDRSTR_cw_m<MVE_st, MVE_memH, "vstrh", "32", 0, 0b10>;
6249 defm MVE_VSTRBU8 : MVE_VLDRSTR_cs_m<MVE_st, MVE_memB, "vstrb", "8">;
6250 defm MVE_VSTRHU16: MVE_VLDRSTR_cs_m<MVE_st, MVE_memH, "vstrh", "16">;
6251 defm MVE_VSTRWU32: MVE_VLDRSTR_cs_m<MVE_st, MVE_memW, "vstrw", "32">;
6253 // Gather loads / scatter stores whose address operand is of the form
6254 // [Rn,Qm], i.e. a single GPR as the common base address, plus a
6255 // vector of offset from it. ('Load/store this sequence of elements of
6256 // the same array.')
6258 // Like the contiguous family, these loads and stores can widen the
6259 // loaded values / truncate the stored ones, or they can just
6260 // load/store the same size of memory and vector lane. But unlike the
6261 // contiguous family, there's no particular difference in encoding
6262 // between those two cases.
6264 // This family also comes with the option to scale the offset values
6265 // in Qm by the size of the loaded memory (i.e. to treat them as array
6266 // indices), or not to scale them (to treat them as plain byte offsets
6267 // in memory, so that perhaps the loaded values are unaligned). The
6268 // scaled instructions' address operand in assembly looks like
6269 // [Rn,Qm,UXTW #2] or similar.
6272 class MVE_VLDRSTR_rq<MVE_ldst_direction dir, MVE_memsz memsz, bit U,
6273 bits<2> size, bit os, string asm, string suffix, int shift>
6274 : MVE_VLDRSTR_base<dir, U, 0b0, 0b0, 0, dir.Oops,
6275 !con(dir.Iops, (ins mve_addr_rq_shift<shift>:$addr)),
6276 asm, suffix, "$Qd, $addr", dir.cstr, size> {
6279 let Inst{19-16} = addr{6-3};
6280 let Inst{8-7} = size;
6281 let Inst{6} = memsz.encoding{1};
6283 let Inst{4} = memsz.encoding{0};
6284 let Inst{3-1} = addr{2-0};
6288 // Multiclass that defines the scaled and unscaled versions of an
6289 // instruction, when the memory size is wider than a byte. The scaled
6290 // version gets the default name like MVE_VLDRBU16_rq; the unscaled /
6291 // potentially unaligned version gets a "_u" suffix, e.g.
6292 // MVE_VLDRBU16_rq_u.
6293 multiclass MVE_VLDRSTR_rq_w<MVE_ldst_direction dir, MVE_memsz memsz,
6294 string asm, string suffix, bit U, bits<2> size> {
6295 def _u : MVE_VLDRSTR_rq<dir, memsz, U, size, 0, asm, suffix, 0>;
6296 def "" : MVE_VLDRSTR_rq<dir, memsz, U, size, 1, asm, suffix, memsz.shift>;
6299 // Subclass of MVE_VLDRSTR_rq with the same API as that multiclass,
6300 // for use when the memory size is one byte, so there's no 'scaled'
6301 // version of the instruction at all. (This is encoded as if it were
6302 // unscaled, but named in the default way with no _u suffix.)
6303 class MVE_VLDRSTR_rq_b<MVE_ldst_direction dir, MVE_memsz memsz,
6304 string asm, string suffix, bit U, bits<2> size>
6305 : MVE_VLDRSTR_rq<dir, memsz, U, size, 0, asm, suffix, 0>;
6307 // Multiclasses wrapping that to add ISel patterns for intrinsics.
6308 multiclass MVE_VLDR_rq_w<MVE_memsz memsz, list<MVEVectorVTInfo> VTIs> {
6309 defm "": MVE_VLDRSTR_rq_w<MVE_ld, memsz, "vldr" # memsz.MnemonicLetter,
6310 VTIs[0].Suffix, VTIs[0].Unsigned, VTIs[0].Size>;
6311 defvar Inst = !cast<Instruction>(NAME);
6312 defvar InstU = !cast<Instruction>(NAME # "_u");
6314 foreach VTI = VTIs in
6315 foreach UnsignedFlag = !if(!eq(VTI.Size, memsz.encoding),
6316 [0,1], [VTI.Unsigned]) in {
6317 def : Pat<(VTI.Vec (int_arm_mve_vldr_gather_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), memsz.TypeBits, 0, UnsignedFlag)),
6318 (VTI.Vec (InstU GPR:$base, MQPR:$offsets))>;
6319 def : Pat<(VTI.Vec (int_arm_mve_vldr_gather_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), memsz.TypeBits, memsz.shift, UnsignedFlag)),
6320 (VTI.Vec (Inst GPR:$base, MQPR:$offsets))>;
6321 def : Pat<(VTI.Vec (int_arm_mve_vldr_gather_offset_predicated GPR:$base, (VTIs[0].Vec MQPR:$offsets), memsz.TypeBits, 0, UnsignedFlag, (VTI.Pred VCCR:$pred))),
6322 (VTI.Vec (InstU GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg))>;
6323 def : Pat<(VTI.Vec (int_arm_mve_vldr_gather_offset_predicated GPR:$base, (VTIs[0].Vec MQPR:$offsets), memsz.TypeBits, memsz.shift, UnsignedFlag, (VTI.Pred VCCR:$pred))),
6324 (VTI.Vec (Inst GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg))>;
6327 multiclass MVE_VLDR_rq_b<list<MVEVectorVTInfo> VTIs> {
6328 def "": MVE_VLDRSTR_rq_b<MVE_ld, MVE_memB, "vldrb",
6329 VTIs[0].Suffix, VTIs[0].Unsigned, VTIs[0].Size>;
6330 defvar Inst = !cast<Instruction>(NAME);
6332 foreach VTI = VTIs in {
6333 def : Pat<(VTI.Vec (int_arm_mve_vldr_gather_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), 8, 0, VTI.Unsigned)),
6334 (VTI.Vec (Inst GPR:$base, MQPR:$offsets))>;
6335 def : Pat<(VTI.Vec (int_arm_mve_vldr_gather_offset_predicated GPR:$base, (VTIs[0].Vec MQPR:$offsets), 8, 0, VTI.Unsigned, (VTI.Pred VCCR:$pred))),
6336 (VTI.Vec (Inst GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg))>;
6339 multiclass MVE_VSTR_rq_w<MVE_memsz memsz, list<MVEVectorVTInfo> VTIs> {
6340 defm "": MVE_VLDRSTR_rq_w<MVE_st, memsz, "vstr" # memsz.MnemonicLetter,
6341 VTIs[0].BitsSuffix, 0, VTIs[0].Size>;
6342 defvar Inst = !cast<Instruction>(NAME);
6343 defvar InstU = !cast<Instruction>(NAME # "_u");
6345 foreach VTI = VTIs in {
6346 def : Pat<(int_arm_mve_vstr_scatter_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), (VTI.Vec MQPR:$data), memsz.TypeBits, 0),
6347 (InstU MQPR:$data, GPR:$base, MQPR:$offsets)>;
6348 def : Pat<(int_arm_mve_vstr_scatter_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), (VTI.Vec MQPR:$data), memsz.TypeBits, memsz.shift),
6349 (Inst MQPR:$data, GPR:$base, MQPR:$offsets)>;
6350 def : Pat<(int_arm_mve_vstr_scatter_offset_predicated GPR:$base, (VTIs[0].Vec MQPR:$offsets), (VTI.Vec MQPR:$data), memsz.TypeBits, 0, (VTI.Pred VCCR:$pred)),
6351 (InstU MQPR:$data, GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg)>;
6352 def : Pat<(int_arm_mve_vstr_scatter_offset_predicated GPR:$base, (VTIs[0].Vec MQPR:$offsets), (VTI.Vec MQPR:$data), memsz.TypeBits, memsz.shift, (VTI.Pred VCCR:$pred)),
6353 (Inst MQPR:$data, GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg)>;
6356 multiclass MVE_VSTR_rq_b<list<MVEVectorVTInfo> VTIs> {
6357 def "": MVE_VLDRSTR_rq_b<MVE_st, MVE_memB, "vstrb",
6358 VTIs[0].BitsSuffix, 0, VTIs[0].Size>;
6359 defvar Inst = !cast<Instruction>(NAME);
6361 foreach VTI = VTIs in {
6362 def : Pat<(int_arm_mve_vstr_scatter_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), (VTI.Vec MQPR:$data), 8, 0),
6363 (Inst MQPR:$data, GPR:$base, MQPR:$offsets)>;
6364 def : Pat<(int_arm_mve_vstr_scatter_offset_predicated GPR:$base, (VTIs[0].Vec MQPR:$offsets), (VTI.Vec MQPR:$data), 8, 0, (VTI.Pred VCCR:$pred)),
6365 (Inst MQPR:$data, GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg)>;
6369 // Actually define all the loads and stores in this family.
6371 defm MVE_VLDRBU8_rq : MVE_VLDR_rq_b<[MVE_v16u8,MVE_v16s8]>;
6372 defm MVE_VLDRBU16_rq: MVE_VLDR_rq_b<[MVE_v8u16]>;
6373 defm MVE_VLDRBS16_rq: MVE_VLDR_rq_b<[MVE_v8s16]>;
6374 defm MVE_VLDRBU32_rq: MVE_VLDR_rq_b<[MVE_v4u32]>;
6375 defm MVE_VLDRBS32_rq: MVE_VLDR_rq_b<[MVE_v4s32]>;
6377 defm MVE_VLDRHU16_rq: MVE_VLDR_rq_w<MVE_memH, [MVE_v8u16,MVE_v8s16,MVE_v8f16]>;
6378 defm MVE_VLDRHU32_rq: MVE_VLDR_rq_w<MVE_memH, [MVE_v4u32]>;
6379 defm MVE_VLDRHS32_rq: MVE_VLDR_rq_w<MVE_memH, [MVE_v4s32]>;
6380 defm MVE_VLDRWU32_rq: MVE_VLDR_rq_w<MVE_memW, [MVE_v4u32,MVE_v4s32,MVE_v4f32]>;
6381 defm MVE_VLDRDU64_rq: MVE_VLDR_rq_w<MVE_memD, [MVE_v2u64,MVE_v2s64]>;
6383 defm MVE_VSTRB8_rq : MVE_VSTR_rq_b<[MVE_v16i8]>;
6384 defm MVE_VSTRB16_rq : MVE_VSTR_rq_b<[MVE_v8i16]>;
6385 defm MVE_VSTRB32_rq : MVE_VSTR_rq_b<[MVE_v4i32]>;
6387 defm MVE_VSTRH16_rq : MVE_VSTR_rq_w<MVE_memH, [MVE_v8i16,MVE_v8f16]>;
6388 defm MVE_VSTRH32_rq : MVE_VSTR_rq_w<MVE_memH, [MVE_v4i32]>;
6389 defm MVE_VSTRW32_rq : MVE_VSTR_rq_w<MVE_memW, [MVE_v4i32,MVE_v4f32]>;
6390 defm MVE_VSTRD64_rq : MVE_VSTR_rq_w<MVE_memD, [MVE_v2i64]>;
6392 // Gather loads / scatter stores whose address operand is of the form
6393 // [Qm,#imm], i.e. a vector containing a full base address for each
6394 // loaded item, plus an immediate offset applied consistently to all
6395 // of them. ('Load/store the same field from this vector of pointers
6396 // to a structure type.')
6398 // This family requires the vector lane size to be at least 32 bits
6399 // (so there's room for an address in each lane at all). It has no
6400 // widening/narrowing variants. But it does support preindex
6401 // writeback, in which the address vector is updated to hold the
6402 // addresses actually loaded from.
6405 class MVE_VLDRSTR_qi<MVE_ldst_direction dir, MVE_memsz memsz, bit W, dag wbops,
6406 string asm, string wbAsm, string suffix, string cstr = "">
6407 : MVE_VLDRSTR_base<dir, 1, 1, W, 1, !con(wbops, dir.Oops),
6408 !con(dir.Iops, (ins mve_addr_q_shift<memsz.shift>:$addr)),
6409 asm, suffix, "$Qd, $addr" # wbAsm, cstr # dir.cstr, memsz.encoding> {
6411 let Inst{23} = addr{7};
6412 let Inst{19-17} = addr{10-8};
6414 let Inst{8} = memsz.encoding{0}; // enough to distinguish 32- from 64-bit
6416 let Inst{6-0} = addr{6-0};
6419 // Multiclass that generates the non-writeback and writeback variants.
6420 multiclass MVE_VLDRSTR_qi_m<MVE_ldst_direction dir, MVE_memsz memsz,
6421 string asm, string suffix> {
6422 def "" : MVE_VLDRSTR_qi<dir, memsz, 0, (outs), asm, "", suffix>;
6423 def _pre : MVE_VLDRSTR_qi<dir, memsz, 1, (outs MQPR:$wb), asm, "!", suffix,
6424 "$addr.base = $wb"> {
6425 let DecoderMethod="DecodeMVE_MEM_3_pre<"#memsz.shift#">";
6429 // Multiclasses wrapping that one, adding selection patterns for the
6430 // non-writeback loads and all the stores. (The writeback loads must
6431 // deliver multiple output values, so they have to be selected by C++
6433 multiclass MVE_VLDR_qi<MVE_memsz memsz, MVEVectorVTInfo AVTI,
6434 list<MVEVectorVTInfo> DVTIs> {
6435 defm "" : MVE_VLDRSTR_qi_m<MVE_ld, memsz, "vldr" # memsz.MnemonicLetter,
6436 "u" # memsz.TypeBits>;
6437 defvar Inst = !cast<Instruction>(NAME);
6439 foreach DVTI = DVTIs in {
6440 def : Pat<(DVTI.Vec (int_arm_mve_vldr_gather_base
6441 (AVTI.Vec MQPR:$addr), (i32 imm:$offset))),
6442 (DVTI.Vec (Inst (AVTI.Vec MQPR:$addr), (i32 imm:$offset)))>;
6443 def : Pat<(DVTI.Vec (int_arm_mve_vldr_gather_base_predicated
6444 (AVTI.Vec MQPR:$addr), (i32 imm:$offset), (AVTI.Pred VCCR:$pred))),
6445 (DVTI.Vec (Inst (AVTI.Vec MQPR:$addr), (i32 imm:$offset),
6446 ARMVCCThen, VCCR:$pred, zero_reg))>;
6449 multiclass MVE_VSTR_qi<MVE_memsz memsz, MVEVectorVTInfo AVTI,
6450 list<MVEVectorVTInfo> DVTIs> {
6451 defm "" : MVE_VLDRSTR_qi_m<MVE_st, memsz, "vstr" # memsz.MnemonicLetter,
6452 !cast<string>(memsz.TypeBits)>;
6453 defvar Inst = !cast<Instruction>(NAME);
6454 defvar InstPre = !cast<Instruction>(NAME # "_pre");
6456 foreach DVTI = DVTIs in {
6457 def : Pat<(int_arm_mve_vstr_scatter_base
6458 (AVTI.Vec MQPR:$addr), (i32 imm:$offset), (DVTI.Vec MQPR:$data)),
6459 (Inst (DVTI.Vec MQPR:$data), (AVTI.Vec MQPR:$addr),
6460 (i32 imm:$offset))>;
6461 def : Pat<(int_arm_mve_vstr_scatter_base_predicated
6462 (AVTI.Vec MQPR:$addr), (i32 imm:$offset), (DVTI.Vec MQPR:$data), (AVTI.Pred VCCR:$pred)),
6463 (Inst (DVTI.Vec MQPR:$data), (AVTI.Vec MQPR:$addr),
6464 (i32 imm:$offset), ARMVCCThen, VCCR:$pred, zero_reg)>;
6465 def : Pat<(AVTI.Vec (int_arm_mve_vstr_scatter_base_wb
6466 (AVTI.Vec MQPR:$addr), (i32 imm:$offset), (DVTI.Vec MQPR:$data))),
6467 (AVTI.Vec (InstPre (DVTI.Vec MQPR:$data), (AVTI.Vec MQPR:$addr),
6468 (i32 imm:$offset)))>;
6469 def : Pat<(AVTI.Vec (int_arm_mve_vstr_scatter_base_wb_predicated
6470 (AVTI.Vec MQPR:$addr), (i32 imm:$offset), (DVTI.Vec MQPR:$data), (AVTI.Pred VCCR:$pred))),
6471 (AVTI.Vec (InstPre (DVTI.Vec MQPR:$data), (AVTI.Vec MQPR:$addr),
6472 (i32 imm:$offset), ARMVCCThen, VCCR:$pred, zero_reg))>;
6476 // Actual instruction definitions.
6477 defm MVE_VLDRWU32_qi: MVE_VLDR_qi<MVE_memW, MVE_v4i32, [MVE_v4i32,MVE_v4f32]>;
6478 defm MVE_VLDRDU64_qi: MVE_VLDR_qi<MVE_memD, MVE_v2i64, [MVE_v2i64,MVE_v2f64]>;
6479 defm MVE_VSTRW32_qi: MVE_VSTR_qi<MVE_memW, MVE_v4i32, [MVE_v4i32,MVE_v4f32]>;
6480 defm MVE_VSTRD64_qi: MVE_VSTR_qi<MVE_memD, MVE_v2i64, [MVE_v2i64,MVE_v2f64]>;
6482 // Define aliases for all the instructions where memory size and
6483 // vector lane size are the same. These are mnemonic aliases, so they
6484 // apply consistently across all of the above families - contiguous
6485 // loads, and both the rq and qi types of gather/scatter.
6487 // Rationale: As long as you're loading (for example) 16-bit memory
6488 // values into 16-bit vector lanes, you can think of them as signed or
6489 // unsigned integers, fp16 or just raw 16-bit blobs and it makes no
6490 // difference. So we permit all of vldrh.16, vldrh.u16, vldrh.s16,
6491 // vldrh.f16 and treat them all as equivalent to the canonical
6492 // spelling (which happens to be .u16 for loads, and just .16 for
6495 foreach vpt_cond = ["", "t", "e"] in
6496 foreach memsz = [MVE_memB, MVE_memH, MVE_memW, MVE_memD] in
6497 foreach suffix = memsz.suffixes in {
6498 // Define an alias with every suffix in the list, except for the one
6499 // used by the real Instruction record (i.e. the one that all the
6500 // rest are aliases *for*).
6502 if !ne(suffix, memsz.CanonLoadSuffix) then {
6503 def : MnemonicAlias<
6504 "vldr" # memsz.MnemonicLetter # vpt_cond # suffix,
6505 "vldr" # memsz.MnemonicLetter # vpt_cond # memsz.CanonLoadSuffix>;
6508 if !ne(suffix, memsz.CanonStoreSuffix) then {
6509 def : MnemonicAlias<
6510 "vstr" # memsz.MnemonicLetter # vpt_cond # suffix,
6511 "vstr" # memsz.MnemonicLetter # vpt_cond # memsz.CanonStoreSuffix>;
6515 // end of MVE predicable load/store
6517 class MVE_VPT<string suffix, bits<2> size, dag iops, string asm, list<dag> pattern=[]>
6518 : MVE_MI<(outs ), iops, NoItinerary, !strconcat("vpt", "${Mk}", ".", suffix), asm, "", size, pattern> {
6523 let Inst{31-23} = 0b111111100;
6524 let Inst{22} = Mk{3};
6525 let Inst{21-20} = size;
6526 let Inst{19-17} = Qn{2-0};
6528 let Inst{15-13} = Mk{2-0};
6529 let Inst{12} = fc{2};
6530 let Inst{11-8} = 0b1111;
6531 let Inst{7} = fc{0};
6535 let validForTailPredication=1;
6538 class MVE_VPTt1<string suffix, bits<2> size, dag iops>
6539 : MVE_VPT<suffix, size, iops, "$fc, $Qn, $Qm"> {
6544 let Inst{5} = Qm{3};
6545 let Inst{3-1} = Qm{2-0};
6546 let Inst{0} = fc{1};
6549 class MVE_VPTt1i<string suffix, bits<2> size>
6550 : MVE_VPTt1<suffix, size,
6551 (ins vpt_mask:$Mk, MQPR:$Qn, MQPR:$Qm, pred_basic_i:$fc)> {
6556 def MVE_VPTv4i32 : MVE_VPTt1i<"i32", 0b10>;
6557 def MVE_VPTv8i16 : MVE_VPTt1i<"i16", 0b01>;
6558 def MVE_VPTv16i8 : MVE_VPTt1i<"i8", 0b00>;
6560 class MVE_VPTt1u<string suffix, bits<2> size>
6561 : MVE_VPTt1<suffix, size,
6562 (ins vpt_mask:$Mk, MQPR:$Qn, MQPR:$Qm, pred_basic_u:$fc)> {
6567 def MVE_VPTv4u32 : MVE_VPTt1u<"u32", 0b10>;
6568 def MVE_VPTv8u16 : MVE_VPTt1u<"u16", 0b01>;
6569 def MVE_VPTv16u8 : MVE_VPTt1u<"u8", 0b00>;
6571 class MVE_VPTt1s<string suffix, bits<2> size>
6572 : MVE_VPTt1<suffix, size,
6573 (ins vpt_mask:$Mk, MQPR:$Qn, MQPR:$Qm, pred_basic_s:$fc)> {
6577 def MVE_VPTv4s32 : MVE_VPTt1s<"s32", 0b10>;
6578 def MVE_VPTv8s16 : MVE_VPTt1s<"s16", 0b01>;
6579 def MVE_VPTv16s8 : MVE_VPTt1s<"s8", 0b00>;
6581 class MVE_VPTt2<string suffix, bits<2> size, dag iops>
6582 : MVE_VPT<suffix, size, iops,
6589 let Inst{5} = fc{1};
6590 let Inst{3-0} = Rm{3-0};
6593 class MVE_VPTt2i<string suffix, bits<2> size>
6594 : MVE_VPTt2<suffix, size,
6595 (ins vpt_mask:$Mk, MQPR:$Qn, GPRwithZR:$Rm, pred_basic_i:$fc)> {
6600 def MVE_VPTv4i32r : MVE_VPTt2i<"i32", 0b10>;
6601 def MVE_VPTv8i16r : MVE_VPTt2i<"i16", 0b01>;
6602 def MVE_VPTv16i8r : MVE_VPTt2i<"i8", 0b00>;
6604 class MVE_VPTt2u<string suffix, bits<2> size>
6605 : MVE_VPTt2<suffix, size,
6606 (ins vpt_mask:$Mk, MQPR:$Qn, GPRwithZR:$Rm, pred_basic_u:$fc)> {
6611 def MVE_VPTv4u32r : MVE_VPTt2u<"u32", 0b10>;
6612 def MVE_VPTv8u16r : MVE_VPTt2u<"u16", 0b01>;
6613 def MVE_VPTv16u8r : MVE_VPTt2u<"u8", 0b00>;
6615 class MVE_VPTt2s<string suffix, bits<2> size>
6616 : MVE_VPTt2<suffix, size,
6617 (ins vpt_mask:$Mk, MQPR:$Qn, GPRwithZR:$Rm, pred_basic_s:$fc)> {
6621 def MVE_VPTv4s32r : MVE_VPTt2s<"s32", 0b10>;
6622 def MVE_VPTv8s16r : MVE_VPTt2s<"s16", 0b01>;
6623 def MVE_VPTv16s8r : MVE_VPTt2s<"s8", 0b00>;
6626 class MVE_VPTf<string suffix, bit size, dag iops, string asm, list<dag> pattern=[]>
6627 : MVE_MI<(outs ), iops, NoItinerary, !strconcat("vpt", "${Mk}", ".", suffix), asm,
6628 "", !if(size, 0b01, 0b10), pattern> {
6633 let Inst{31-29} = 0b111;
6634 let Inst{28} = size;
6635 let Inst{27-23} = 0b11100;
6636 let Inst{22} = Mk{3};
6637 let Inst{21-20} = 0b11;
6638 let Inst{19-17} = Qn{2-0};
6640 let Inst{15-13} = Mk{2-0};
6641 let Inst{12} = fc{2};
6642 let Inst{11-8} = 0b1111;
6643 let Inst{7} = fc{0};
6647 let Predicates = [HasMVEFloat];
6648 let validForTailPredication=1;
6651 class MVE_VPTft1<string suffix, bit size>
6652 : MVE_VPTf<suffix, size, (ins vpt_mask:$Mk, MQPR:$Qn, MQPR:$Qm, pred_basic_fp:$fc),
6658 let Inst{5} = Qm{3};
6659 let Inst{3-1} = Qm{2-0};
6660 let Inst{0} = fc{1};
6663 def MVE_VPTv4f32 : MVE_VPTft1<"f32", 0b0>;
6664 def MVE_VPTv8f16 : MVE_VPTft1<"f16", 0b1>;
6666 class MVE_VPTft2<string suffix, bit size>
6667 : MVE_VPTf<suffix, size, (ins vpt_mask:$Mk, MQPR:$Qn, GPRwithZR:$Rm, pred_basic_fp:$fc),
6673 let Inst{5} = fc{1};
6674 let Inst{3-0} = Rm{3-0};
6677 def MVE_VPTv4f32r : MVE_VPTft2<"f32", 0b0>;
6678 def MVE_VPTv8f16r : MVE_VPTft2<"f16", 0b1>;
6680 def MVE_VPST : MVE_MI<(outs ), (ins vpt_mask:$Mk), NoItinerary,
6681 !strconcat("vpst", "${Mk}"), "", "", 0b00, []> {
6684 let Inst{31-23} = 0b111111100;
6685 let Inst{22} = Mk{3};
6686 let Inst{21-16} = 0b110001;
6687 let Inst{15-13} = Mk{2-0};
6688 let Inst{12-0} = 0b0111101001101;
6689 let Unpredictable{12} = 0b1;
6690 let Unpredictable{7} = 0b1;
6691 let Unpredictable{5} = 0b1;
6694 let validForTailPredication = 1;
6697 def MVE_VPSEL : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm), NoItinerary,
6698 "vpsel", "", "$Qd, $Qn, $Qm", vpred_n, "", 0b00, []> {
6704 let Inst{25-23} = 0b100;
6705 let Inst{22} = Qd{3};
6706 let Inst{21-20} = 0b11;
6707 let Inst{19-17} = Qn{2-0};
6709 let Inst{15-13} = Qd{2-0};
6710 let Inst{12-9} = 0b0111;
6712 let Inst{7} = Qn{3};
6714 let Inst{5} = Qm{3};
6716 let Inst{3-1} = Qm{2-0};
6720 foreach suffix = ["s8", "s16", "s32", "u8", "u16", "u32",
6721 "i8", "i16", "i32", "f16", "f32"] in
6722 def : MVEInstAlias<"vpsel${vp}." # suffix # "\t$Qd, $Qn, $Qm",
6723 (MVE_VPSEL MQPR:$Qd, MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>;
6725 let Predicates = [HasMVEInt] in {
6726 def : Pat<(v16i8 (vselect (v16i1 VCCR:$pred), (v16i8 MQPR:$v1), (v16i8 MQPR:$v2))),
6727 (v16i8 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>;
6728 def : Pat<(v8i16 (vselect (v8i1 VCCR:$pred), (v8i16 MQPR:$v1), (v8i16 MQPR:$v2))),
6729 (v8i16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>;
6730 def : Pat<(v4i32 (vselect (v4i1 VCCR:$pred), (v4i32 MQPR:$v1), (v4i32 MQPR:$v2))),
6731 (v4i32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>;
6732 def : Pat<(v2i64 (vselect (v2i1 VCCR:$pred), (v2i64 MQPR:$v1), (v2i64 MQPR:$v2))),
6733 (v2i64 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>;
6735 def : Pat<(v8f16 (vselect (v8i1 VCCR:$pred), (v8f16 MQPR:$v1), (v8f16 MQPR:$v2))),
6736 (v8f16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>;
6737 def : Pat<(v4f32 (vselect (v4i1 VCCR:$pred), (v4f32 MQPR:$v1), (v4f32 MQPR:$v2))),
6738 (v4f32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>;
6739 def : Pat<(v2f64 (vselect (v2i1 VCCR:$pred), (v2f64 MQPR:$v1), (v2f64 MQPR:$v2))),
6740 (v2f64 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>;
6742 def : Pat<(v16i8 (vselect (v16i8 MQPR:$pred), (v16i8 MQPR:$v1), (v16i8 MQPR:$v2))),
6743 (v16i8 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone,
6744 (MVE_VCMPi8 (v16i8 MQPR:$pred), (MVE_VMOVimmi8 0), ARMCCne), zero_reg))>;
6745 def : Pat<(v8i16 (vselect (v8i16 MQPR:$pred), (v8i16 MQPR:$v1), (v8i16 MQPR:$v2))),
6746 (v8i16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone,
6747 (MVE_VCMPi16 (v8i16 MQPR:$pred), (MVE_VMOVimmi16 0), ARMCCne), zero_reg))>;
6748 def : Pat<(v4i32 (vselect (v4i32 MQPR:$pred), (v4i32 MQPR:$v1), (v4i32 MQPR:$v2))),
6749 (v4i32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone,
6750 (MVE_VCMPi32 (v4i32 MQPR:$pred), (MVE_VMOVimmi32 0), ARMCCne), zero_reg))>;
6752 def : Pat<(v8f16 (vselect (v8i16 MQPR:$pred), (v8f16 MQPR:$v1), (v8f16 MQPR:$v2))),
6753 (v8f16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone,
6754 (MVE_VCMPi16 (v8i16 MQPR:$pred), (MVE_VMOVimmi16 0), ARMCCne), zero_reg))>;
6755 def : Pat<(v4f32 (vselect (v4i32 MQPR:$pred), (v4f32 MQPR:$v1), (v4f32 MQPR:$v2))),
6756 (v4f32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone,
6757 (MVE_VCMPi32 (v4i32 MQPR:$pred), (MVE_VMOVimmi32 0), ARMCCne), zero_reg))>;
6760 def : Pat<(v16i8 (zext (v16i1 VCCR:$pred))),
6761 (v16i8 (MVE_VPSEL (MVE_VMOVimmi8 1), (MVE_VMOVimmi8 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
6762 def : Pat<(v8i16 (zext (v8i1 VCCR:$pred))),
6763 (v8i16 (MVE_VPSEL (MVE_VMOVimmi16 1), (MVE_VMOVimmi16 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
6764 def : Pat<(v4i32 (zext (v4i1 VCCR:$pred))),
6765 (v4i32 (MVE_VPSEL (MVE_VMOVimmi32 1), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
6766 def : Pat<(v2i64 (zext (v2i1 VCCR:$pred))),
6767 (v2i64 (MVE_VPSEL (MVE_VMOVimmi64 1), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
6769 def : Pat<(v16i8 (sext (v16i1 VCCR:$pred))),
6770 (v16i8 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi8 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
6771 def : Pat<(v8i16 (sext (v8i1 VCCR:$pred))),
6772 (v8i16 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi16 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
6773 def : Pat<(v4i32 (sext (v4i1 VCCR:$pred))),
6774 (v4i32 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
6775 def : Pat<(v2i64 (sext (v2i1 VCCR:$pred))),
6776 (v2i64 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
6778 def : Pat<(v16i8 (anyext (v16i1 VCCR:$pred))),
6779 (v16i8 (MVE_VPSEL (MVE_VMOVimmi8 1), (MVE_VMOVimmi8 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
6780 def : Pat<(v8i16 (anyext (v8i1 VCCR:$pred))),
6781 (v8i16 (MVE_VPSEL (MVE_VMOVimmi16 1), (MVE_VMOVimmi16 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
6782 def : Pat<(v4i32 (anyext (v4i1 VCCR:$pred))),
6783 (v4i32 (MVE_VPSEL (MVE_VMOVimmi32 1), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
6784 def : Pat<(v2i64 (anyext (v2i1 VCCR:$pred))),
6785 (v2i64 (MVE_VPSEL (MVE_VMOVimmi64 1), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>;
6788 let Predicates = [HasMVEFloat] in {
6790 // 112 is 1.0 in float
6791 def : Pat<(v4f32 (uint_to_fp (v4i1 VCCR:$pred))),
6792 (v4f32 (MVE_VPSEL (v4f32 (MVE_VMOVimmf32 112)), (v4f32 (MVE_VMOVimmi32 0)), ARMVCCNone, VCCR:$pred, zero_reg))>;
6793 // 2620 in 1.0 in half
6794 def : Pat<(v8f16 (uint_to_fp (v8i1 VCCR:$pred))),
6795 (v8f16 (MVE_VPSEL (v8f16 (MVE_VMOVimmi16 2620)), (v8f16 (MVE_VMOVimmi16 0)), ARMVCCNone, VCCR:$pred, zero_reg))>;
6796 // 240 is -1.0 in float
6797 def : Pat<(v4f32 (sint_to_fp (v4i1 VCCR:$pred))),
6798 (v4f32 (MVE_VPSEL (v4f32 (MVE_VMOVimmf32 240)), (v4f32 (MVE_VMOVimmi32 0)), ARMVCCNone, VCCR:$pred, zero_reg))>;
6799 // 2748 is -1.0 in half
6800 def : Pat<(v8f16 (sint_to_fp (v8i1 VCCR:$pred))),
6801 (v8f16 (MVE_VPSEL (v8f16 (MVE_VMOVimmi16 2748)), (v8f16 (MVE_VMOVimmi16 0)), ARMVCCNone, VCCR:$pred, zero_reg))>;
6803 def : Pat<(v4i1 (fp_to_uint (v4f32 MQPR:$v1))),
6804 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, ARMCCne))>;
6805 def : Pat<(v8i1 (fp_to_uint (v8f16 MQPR:$v1))),
6806 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), ZR, ARMCCne))>;
6807 def : Pat<(v4i1 (fp_to_sint (v4f32 MQPR:$v1))),
6808 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, ARMCCne))>;
6809 def : Pat<(v8i1 (fp_to_sint (v8f16 MQPR:$v1))),
6810 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), ZR, ARMCCne))>;
6813 def MVE_VPNOT : MVE_p<(outs VCCR:$P0), (ins VCCR:$P0_in), NoItinerary,
6814 "vpnot", "", "", vpred_n, "", 0b00, []> {
6815 let Inst{31-0} = 0b11111110001100010000111101001101;
6816 let Unpredictable{19-17} = 0b111;
6817 let Unpredictable{12} = 0b1;
6818 let Unpredictable{7} = 0b1;
6819 let Unpredictable{5} = 0b1;
6821 let Constraints = "";
6822 let DecoderMethod = "DecodeMVEVPNOT";
6825 let Predicates = [HasMVEInt] in {
6826 def : Pat<(v2i1 (xor (v2i1 VCCR:$pred), (v2i1 (predicate_cast (i32 65535))))),
6827 (v2i1 (MVE_VPNOT (v2i1 VCCR:$pred)))>;
6828 def : Pat<(v4i1 (xor (v4i1 VCCR:$pred), (v4i1 (predicate_cast (i32 65535))))),
6829 (v4i1 (MVE_VPNOT (v4i1 VCCR:$pred)))>;
6830 def : Pat<(v8i1 (xor (v8i1 VCCR:$pred), (v8i1 (predicate_cast (i32 65535))))),
6831 (v8i1 (MVE_VPNOT (v8i1 VCCR:$pred)))>;
6832 def : Pat<(v16i1 (xor (v16i1 VCCR:$pred), (v16i1 (predicate_cast (i32 65535))))),
6833 (v16i1 (MVE_VPNOT (v16i1 VCCR:$pred)))>;
6837 class MVE_loltp_start<dag iops, string asm, string ops, bits<2> size>
6838 : t2LOL<(outs GPRlr:$LR), iops, asm, ops> {
6840 let Predicates = [HasMVEInt];
6842 let Inst{21-20} = size;
6843 let Inst{19-16} = Rn{3-0};
6847 class MVE_DLSTP<string asm, bits<2> size>
6848 : MVE_loltp_start<(ins rGPR:$Rn), asm, "$LR, $Rn", size> {
6850 let Inst{11-1} = 0b00000000000;
6851 let Unpredictable{10-1} = 0b1111111111;
6854 class MVE_WLSTP<string asm, bits<2> size>
6855 : MVE_loltp_start<(ins rGPR:$Rn, wlslabel_u11:$label),
6856 asm, "$LR, $Rn, $label", size> {
6859 let Inst{11} = label{0};
6860 let Inst{10-1} = label{10-1};
6862 let isTerminator = 1;
6865 def SDT_MVEMEMCPYLOOPNODE
6866 : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisPtrTy<1>, SDTCisVT<2, i32>]>;
6867 def MVE_MEMCPYLOOPNODE : SDNode<"ARMISD::MEMCPYLOOP", SDT_MVEMEMCPYLOOPNODE,
6868 [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>;
6870 let usesCustomInserter = 1, hasNoSchedulingInfo = 1, Defs = [CPSR] in {
6871 def MVE_MEMCPYLOOPINST : PseudoInst<(outs),
6872 (ins rGPR:$dst, rGPR:$src, rGPR:$sz),
6874 [(MVE_MEMCPYLOOPNODE rGPR:$dst, rGPR:$src, rGPR:$sz)]>;
6877 def SDT_MVEMEMSETLOOPNODE
6878 : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisVT<1, v16i8>, SDTCisVT<2, i32>]>;
6879 def MVE_MEMSETLOOPNODE : SDNode<"ARMISD::MEMSETLOOP", SDT_MVEMEMSETLOOPNODE,
6880 [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>;
6882 let usesCustomInserter = 1, hasNoSchedulingInfo = 1, Defs = [CPSR] in {
6883 def MVE_MEMSETLOOPINST : PseudoInst<(outs),
6884 (ins rGPR:$dst, MQPR:$src, rGPR:$sz),
6886 [(MVE_MEMSETLOOPNODE rGPR:$dst, MQPR:$src, rGPR:$sz)]>;
6889 def MVE_DLSTP_8 : MVE_DLSTP<"dlstp.8", 0b00>;
6890 def MVE_DLSTP_16 : MVE_DLSTP<"dlstp.16", 0b01>;
6891 def MVE_DLSTP_32 : MVE_DLSTP<"dlstp.32", 0b10>;
6892 def MVE_DLSTP_64 : MVE_DLSTP<"dlstp.64", 0b11>;
6894 def MVE_WLSTP_8 : MVE_WLSTP<"wlstp.8", 0b00>;
6895 def MVE_WLSTP_16 : MVE_WLSTP<"wlstp.16", 0b01>;
6896 def MVE_WLSTP_32 : MVE_WLSTP<"wlstp.32", 0b10>;
6897 def MVE_WLSTP_64 : MVE_WLSTP<"wlstp.64", 0b11>;
6899 class MVE_loltp_end<dag oops, dag iops, string asm, string ops>
6900 : t2LOL<oops, iops, asm, ops> {
6901 let Predicates = [HasMVEInt];
6902 let Inst{22-21} = 0b00;
6903 let Inst{19-16} = 0b1111;
6907 def MVE_LETP : MVE_loltp_end<(outs GPRlr:$LRout),
6908 (ins GPRlr:$LRin, lelabel_u11:$label),
6909 "letp", "$LRin, $label"> {
6913 let Inst{11} = label{0};
6914 let Inst{10-1} = label{10-1};
6916 let isTerminator = 1;
6919 def MVE_LCTP : MVE_loltp_end<(outs), (ins pred:$p), "lctp${p}", ""> {
6922 let Inst{11-1} = 0b00000000000;
6923 let Unpredictable{21-20} = 0b11;
6924 let Unpredictable{11-1} = 0b11111111111;
6928 // Pseudo instructions for lowering MQQPR and MQQQQPR stack spills and reloads.
6929 // They are equivalent to VLDMDIA/VSTMDIA with a single reg, as opposed to multiple
6932 let Predicates = [HasMVEInt], AM = AddrMode4 in {
6933 let mayStore = 1, hasSideEffects = 0 in {
6934 def MQQPRStore : t2PseudoInst<(outs), (ins MQQPR:$val, GPRnopc:$ptr),
6935 4, NoItinerary, []>;
6936 def MQQQQPRStore : t2PseudoInst<(outs), (ins MQQQQPR:$val, GPRnopc:$ptr),
6937 4, NoItinerary, []>;
6939 let mayLoad = 1, hasSideEffects = 0 in {
6940 def MQQPRLoad : t2PseudoInst<(outs MQQPR:$val), (ins GPRnopc:$ptr),
6941 4, NoItinerary, []>;
6942 def MQQQQPRLoad : t2PseudoInst<(outs MQQQQPR:$val), (ins GPRnopc:$ptr),
6943 4, NoItinerary, []>;
6947 // Pseudo for lowering MVE Q register COPYs. These will usually get converted
6948 // to a "MVE_VORR dst, src, src", but may behave differently in tail predicated
6949 // loops to ensure the whole register is copied, not a subset from a
6950 // tail-predicated MVE_VORR. In the event we cannot prove a MVE_VORR is valid,
6951 // it will become a pair of VMOVD instructions for each half of the Q register.
6952 let Predicates = [HasMVEInt], hasSideEffects = 0, isMoveReg = 1,
6954 def MQPRCopy : t2PseudoInst<(outs MQPR:$dst), (ins MQPR:$src),
6955 8, NoItinerary, []>;
6959 //===----------------------------------------------------------------------===//
6961 //===----------------------------------------------------------------------===//
6963 // PatFrags for loads and stores. Often trying to keep semi-consistent names.
6965 def aligned32_pre_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
6966 (pre_store node:$val, node:$ptr, node:$offset), [{
6967 return cast<StoreSDNode>(N)->getAlign() >= 4;
6969 def aligned32_post_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
6970 (post_store node:$val, node:$ptr, node:$offset), [{
6971 return cast<StoreSDNode>(N)->getAlign() >= 4;
6973 def aligned16_pre_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
6974 (pre_store node:$val, node:$ptr, node:$offset), [{
6975 return cast<StoreSDNode>(N)->getAlign() >= 2;
6977 def aligned16_post_store : PatFrag<(ops node:$val, node:$ptr, node:$offset),
6978 (post_store node:$val, node:$ptr, node:$offset), [{
6979 return cast<StoreSDNode>(N)->getAlign() >= 2;
6983 def aligned_maskedloadvi8 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
6984 (masked_ld node:$ptr, undef, node:$pred, node:$passthru), [{
6985 auto *Ld = cast<MaskedLoadSDNode>(N);
6986 return Ld->getMemoryVT().getScalarType() == MVT::i8;
6988 def aligned_sextmaskedloadvi8 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
6989 (aligned_maskedloadvi8 node:$ptr, node:$pred, node:$passthru), [{
6990 return cast<MaskedLoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
6992 def aligned_zextmaskedloadvi8 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
6993 (aligned_maskedloadvi8 node:$ptr, node:$pred, node:$passthru), [{
6994 return cast<MaskedLoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
6996 def aligned_extmaskedloadvi8 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
6997 (aligned_maskedloadvi8 node:$ptr, node:$pred, node:$passthru), [{
6998 auto *Ld = cast<MaskedLoadSDNode>(N);
6999 EVT ScalarVT = Ld->getMemoryVT().getScalarType();
7000 return ScalarVT.isInteger() && Ld->getExtensionType() == ISD::EXTLOAD;
7002 def aligned_maskedloadvi16: PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
7003 (masked_ld node:$ptr, undef, node:$pred, node:$passthru), [{
7004 auto *Ld = cast<MaskedLoadSDNode>(N);
7005 EVT ScalarVT = Ld->getMemoryVT().getScalarType();
7006 return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && Ld->getAlign() >= 2;
7008 def aligned_sextmaskedloadvi16 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
7009 (aligned_maskedloadvi16 node:$ptr, node:$pred, node:$passthru), [{
7010 return cast<MaskedLoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD;
7012 def aligned_zextmaskedloadvi16 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
7013 (aligned_maskedloadvi16 node:$ptr, node:$pred, node:$passthru), [{
7014 return cast<MaskedLoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD;
7016 def aligned_extmaskedloadvi16 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
7017 (aligned_maskedloadvi16 node:$ptr, node:$pred, node:$passthru), [{
7018 auto *Ld = cast<MaskedLoadSDNode>(N);
7019 EVT ScalarVT = Ld->getMemoryVT().getScalarType();
7020 return ScalarVT.isInteger() && Ld->getExtensionType() == ISD::EXTLOAD;
7022 def aligned_maskedloadvi32: PatFrag<(ops node:$ptr, node:$pred, node:$passthru),
7023 (masked_ld node:$ptr, undef, node:$pred, node:$passthru), [{
7024 auto *Ld = cast<MaskedLoadSDNode>(N);
7025 EVT ScalarVT = Ld->getMemoryVT().getScalarType();
7026 return (ScalarVT == MVT::i32 || ScalarVT == MVT::f32) && Ld->getAlign() >= 4;
7029 def aligned_maskedstvi8 : PatFrag<(ops node:$val, node:$ptr, node:$pred),
7030 (masked_st node:$val, node:$ptr, undef, node:$pred), [{
7031 return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8;
7033 def aligned_maskedstvi16 : PatFrag<(ops node:$val, node:$ptr, node:$pred),
7034 (masked_st node:$val, node:$ptr, undef, node:$pred), [{
7035 auto *St = cast<MaskedStoreSDNode>(N);
7036 EVT ScalarVT = St->getMemoryVT().getScalarType();
7037 return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlign() >= 2;
7039 def aligned_maskedstvi32 : PatFrag<(ops node:$val, node:$ptr, node:$pred),
7040 (masked_st node:$val, node:$ptr, undef, node:$pred), [{
7041 auto *St = cast<MaskedStoreSDNode>(N);
7042 EVT ScalarVT = St->getMemoryVT().getScalarType();
7043 return (ScalarVT == MVT::i32 || ScalarVT == MVT::f32) && St->getAlign() >= 4;
7046 def pre_maskedstore : PatFrag<(ops node:$val, node:$base, node:$offset, node:$mask),
7047 (masked_st node:$val, node:$base, node:$offset, node:$mask), [{
7048 ISD::MemIndexedMode AM = cast<MaskedStoreSDNode>(N)->getAddressingMode();
7049 return AM == ISD::PRE_INC || AM == ISD::PRE_DEC;
7051 def post_maskedstore : PatFrag<(ops node:$val, node:$base, node:$offset, node:$mask),
7052 (masked_st node:$val, node:$base, node:$offset, node:$mask), [{
7053 ISD::MemIndexedMode AM = cast<MaskedStoreSDNode>(N)->getAddressingMode();
7054 return AM == ISD::POST_INC || AM == ISD::POST_DEC;
7056 def aligned_pre_maskedstorevi8 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask),
7057 (pre_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{
7058 return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8;
7060 def aligned_post_maskedstorevi8 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask),
7061 (post_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{
7062 return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8;
7064 def aligned_pre_maskedstorevi16 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask),
7065 (pre_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{
7066 auto *St = cast<MaskedStoreSDNode>(N);
7067 EVT ScalarVT = St->getMemoryVT().getScalarType();
7068 return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlign() >= 2;
7070 def aligned_post_maskedstorevi16 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask),
7071 (post_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{
7072 auto *St = cast<MaskedStoreSDNode>(N);
7073 EVT ScalarVT = St->getMemoryVT().getScalarType();
7074 return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlign() >= 2;
7076 def aligned_pre_maskedstorevi32 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask),
7077 (pre_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{
7078 auto *St = cast<MaskedStoreSDNode>(N);
7079 EVT ScalarVT = St->getMemoryVT().getScalarType();
7080 return (ScalarVT == MVT::i32 || ScalarVT == MVT::f32) && St->getAlign() >= 4;
7082 def aligned_post_maskedstorevi32 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask),
7083 (post_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{
7084 auto *St = cast<MaskedStoreSDNode>(N);
7085 EVT ScalarVT = St->getMemoryVT().getScalarType();
7086 return (ScalarVT == MVT::i32 || ScalarVT == MVT::f32) && St->getAlign() >= 4;
7090 // PatFrags for "Aligned" extending / truncating
7092 def aligned_extloadvi8 : PatFrag<(ops node:$ptr), (extloadvi8 node:$ptr)>;
7093 def aligned_sextloadvi8 : PatFrag<(ops node:$ptr), (sextloadvi8 node:$ptr)>;
7094 def aligned_zextloadvi8 : PatFrag<(ops node:$ptr), (zextloadvi8 node:$ptr)>;
7096 def aligned_truncstvi8 : PatFrag<(ops node:$val, node:$ptr),
7097 (truncstorevi8 node:$val, node:$ptr)>;
7098 def aligned_post_truncstvi8 : PatFrag<(ops node:$val, node:$base, node:$offset),
7099 (post_truncstvi8 node:$val, node:$base, node:$offset)>;
7100 def aligned_pre_truncstvi8 : PatFrag<(ops node:$val, node:$base, node:$offset),
7101 (pre_truncstvi8 node:$val, node:$base, node:$offset)>;
7103 let MinAlignment = 2 in {
7104 def aligned_extloadvi16 : PatFrag<(ops node:$ptr), (extloadvi16 node:$ptr)>;
7105 def aligned_sextloadvi16 : PatFrag<(ops node:$ptr), (sextloadvi16 node:$ptr)>;
7106 def aligned_zextloadvi16 : PatFrag<(ops node:$ptr), (zextloadvi16 node:$ptr)>;
7108 def aligned_truncstvi16 : PatFrag<(ops node:$val, node:$ptr),
7109 (truncstorevi16 node:$val, node:$ptr)>;
7110 def aligned_post_truncstvi16 : PatFrag<(ops node:$val, node:$base, node:$offset),
7111 (post_truncstvi16 node:$val, node:$base, node:$offset)>;
7112 def aligned_pre_truncstvi16 : PatFrag<(ops node:$val, node:$base, node:$offset),
7113 (pre_truncstvi16 node:$val, node:$base, node:$offset)>;
7116 def truncmaskedst : PatFrag<(ops node:$val, node:$base, node:$pred),
7117 (masked_st node:$val, node:$base, undef, node:$pred), [{
7118 return cast<MaskedStoreSDNode>(N)->isTruncatingStore();
7120 def aligned_truncmaskedstvi8 : PatFrag<(ops node:$val, node:$base, node:$pred),
7121 (truncmaskedst node:$val, node:$base, node:$pred), [{
7122 return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8;
7124 def aligned_truncmaskedstvi16 : PatFrag<(ops node:$val, node:$base, node:$pred),
7125 (truncmaskedst node:$val, node:$base, node:$pred), [{
7126 auto *St = cast<MaskedStoreSDNode>(N);
7127 EVT ScalarVT = St->getMemoryVT().getScalarType();
7128 return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlign() >= 2;
7130 def pre_truncmaskedst : PatFrag<(ops node:$val, node:$base, node:$offset, node:$pred),
7131 (masked_st node:$val, node:$base, node:$offset, node:$pred), [{
7132 ISD::MemIndexedMode AM = cast<MaskedStoreSDNode>(N)->getAddressingMode();
7133 return cast<MaskedStoreSDNode>(N)->isTruncatingStore() && (AM == ISD::PRE_INC || AM == ISD::PRE_DEC);
7135 def aligned_pre_truncmaskedstvi8 : PatFrag<(ops node:$val, node:$base, node:$offset, node:$pred),
7136 (pre_truncmaskedst node:$val, node:$base, node:$offset, node:$pred), [{
7137 return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8;
7139 def aligned_pre_truncmaskedstvi16 : PatFrag<(ops node:$val, node:$base, node:$offset, node:$pred),
7140 (pre_truncmaskedst node:$val, node:$base, node:$offset, node:$pred), [{
7141 auto *St = cast<MaskedStoreSDNode>(N);
7142 EVT ScalarVT = St->getMemoryVT().getScalarType();
7143 return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlign() >= 2;
7145 def post_truncmaskedst : PatFrag<(ops node:$val, node:$base, node:$offset, node:$postd),
7146 (masked_st node:$val, node:$base, node:$offset, node:$postd), [{
7147 ISD::MemIndexedMode AM = cast<MaskedStoreSDNode>(N)->getAddressingMode();
7148 return cast<MaskedStoreSDNode>(N)->isTruncatingStore() && (AM == ISD::POST_INC || AM == ISD::POST_DEC);
7150 def aligned_post_truncmaskedstvi8 : PatFrag<(ops node:$val, node:$base, node:$offset, node:$postd),
7151 (post_truncmaskedst node:$val, node:$base, node:$offset, node:$postd), [{
7152 return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8;
7154 def aligned_post_truncmaskedstvi16 : PatFrag<(ops node:$val, node:$base, node:$offset, node:$postd),
7155 (post_truncmaskedst node:$val, node:$base, node:$offset, node:$postd), [{
7156 auto *St = cast<MaskedStoreSDNode>(N);
7157 EVT ScalarVT = St->getMemoryVT().getScalarType();
7158 return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlign() >= 2;
7161 // Load/store patterns
7163 class MVE_vector_store_typed<ValueType Ty, Instruction RegImmInst,
7164 PatFrag StoreKind, int shift>
7165 : Pat<(StoreKind (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr),
7166 (RegImmInst (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr)>;
7168 class MVE_vector_maskedstore_typed<ValueType Ty, Instruction RegImmInst,
7169 PatFrag StoreKind, int shift>
7170 : Pat<(StoreKind (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr, VCCR:$pred),
7171 (RegImmInst (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg)>;
7173 multiclass MVE_vector_store<Instruction RegImmInst, PatFrag StoreKind,
7175 def : MVE_vector_store_typed<v16i8, RegImmInst, StoreKind, shift>;
7176 def : MVE_vector_store_typed<v8i16, RegImmInst, StoreKind, shift>;
7177 def : MVE_vector_store_typed<v8f16, RegImmInst, StoreKind, shift>;
7178 def : MVE_vector_store_typed<v4i32, RegImmInst, StoreKind, shift>;
7179 def : MVE_vector_store_typed<v4f32, RegImmInst, StoreKind, shift>;
7180 def : MVE_vector_store_typed<v2i64, RegImmInst, StoreKind, shift>;
7181 def : MVE_vector_store_typed<v2f64, RegImmInst, StoreKind, shift>;
7184 class MVE_vector_load_typed<ValueType Ty, Instruction RegImmInst,
7185 PatFrag LoadKind, int shift>
7186 : Pat<(Ty (LoadKind t2addrmode_imm7<shift>:$addr)),
7187 (Ty (RegImmInst t2addrmode_imm7<shift>:$addr))>;
7189 class MVE_vector_maskedload_typed<ValueType Ty, Instruction RegImmInst,
7190 PatFrag LoadKind, int shift>
7191 : Pat<(Ty (LoadKind t2addrmode_imm7<shift>:$addr, VCCR:$pred, (Ty (ARMvmovImm (i32 0))))),
7192 (Ty (RegImmInst t2addrmode_imm7<shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg))>;
7194 multiclass MVE_vector_load<Instruction RegImmInst, PatFrag LoadKind,
7196 def : MVE_vector_load_typed<v16i8, RegImmInst, LoadKind, shift>;
7197 def : MVE_vector_load_typed<v8i16, RegImmInst, LoadKind, shift>;
7198 def : MVE_vector_load_typed<v8f16, RegImmInst, LoadKind, shift>;
7199 def : MVE_vector_load_typed<v4i32, RegImmInst, LoadKind, shift>;
7200 def : MVE_vector_load_typed<v4f32, RegImmInst, LoadKind, shift>;
7201 def : MVE_vector_load_typed<v2i64, RegImmInst, LoadKind, shift>;
7202 def : MVE_vector_load_typed<v2f64, RegImmInst, LoadKind, shift>;
7205 class MVE_vector_offset_store_typed<ValueType Ty, Instruction Opcode,
7206 PatFrag StoreKind, int shift>
7207 : Pat<(StoreKind (Ty MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<shift>:$addr),
7208 (Opcode MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<shift>:$addr)>;
7210 class MVE_vector_offset_maskedstore_typed<ValueType Ty, Instruction Opcode,
7211 PatFrag StoreKind, int shift>
7212 : Pat<(StoreKind (Ty MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<shift>:$addr, VCCR:$pred),
7213 (Opcode MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg)>;
7215 multiclass MVE_vector_offset_store<Instruction RegImmInst, PatFrag StoreKind,
7217 def : MVE_vector_offset_store_typed<v16i8, RegImmInst, StoreKind, shift>;
7218 def : MVE_vector_offset_store_typed<v8i16, RegImmInst, StoreKind, shift>;
7219 def : MVE_vector_offset_store_typed<v8f16, RegImmInst, StoreKind, shift>;
7220 def : MVE_vector_offset_store_typed<v4i32, RegImmInst, StoreKind, shift>;
7221 def : MVE_vector_offset_store_typed<v4f32, RegImmInst, StoreKind, shift>;
7222 def : MVE_vector_offset_store_typed<v2i64, RegImmInst, StoreKind, shift>;
7223 def : MVE_vector_offset_store_typed<v2f64, RegImmInst, StoreKind, shift>;
7227 let Predicates = [HasMVEInt, IsLE] in {
7229 defm : MVE_vector_store<MVE_VSTRBU8, byte_alignedstore, 0>;
7230 defm : MVE_vector_store<MVE_VSTRHU16, hword_alignedstore, 1>;
7231 defm : MVE_vector_store<MVE_VSTRWU32, alignedstore32, 2>;
7234 defm : MVE_vector_load<MVE_VLDRBU8, byte_alignedload, 0>;
7235 defm : MVE_vector_load<MVE_VLDRHU16, hword_alignedload, 1>;
7236 defm : MVE_vector_load<MVE_VLDRWU32, alignedload32, 2>;
7238 // Pre/post inc stores
7239 defm : MVE_vector_offset_store<MVE_VSTRBU8_pre, pre_store, 0>;
7240 defm : MVE_vector_offset_store<MVE_VSTRBU8_post, post_store, 0>;
7241 defm : MVE_vector_offset_store<MVE_VSTRHU16_pre, aligned16_pre_store, 1>;
7242 defm : MVE_vector_offset_store<MVE_VSTRHU16_post, aligned16_post_store, 1>;
7243 defm : MVE_vector_offset_store<MVE_VSTRWU32_pre, aligned32_pre_store, 2>;
7244 defm : MVE_vector_offset_store<MVE_VSTRWU32_post, aligned32_post_store, 2>;
7247 let Predicates = [HasMVEInt, IsBE] in {
7249 def : MVE_vector_store_typed<v16i8, MVE_VSTRBU8, store, 0>;
7250 def : MVE_vector_store_typed<v8i16, MVE_VSTRHU16, alignedstore16, 1>;
7251 def : MVE_vector_store_typed<v8f16, MVE_VSTRHU16, alignedstore16, 1>;
7252 def : MVE_vector_store_typed<v4i32, MVE_VSTRWU32, alignedstore32, 2>;
7253 def : MVE_vector_store_typed<v4f32, MVE_VSTRWU32, alignedstore32, 2>;
7256 def : MVE_vector_load_typed<v16i8, MVE_VLDRBU8, load, 0>;
7257 def : MVE_vector_load_typed<v8i16, MVE_VLDRHU16, alignedload16, 1>;
7258 def : MVE_vector_load_typed<v8f16, MVE_VLDRHU16, alignedload16, 1>;
7259 def : MVE_vector_load_typed<v4i32, MVE_VLDRWU32, alignedload32, 2>;
7260 def : MVE_vector_load_typed<v4f32, MVE_VLDRWU32, alignedload32, 2>;
7262 // Other unaligned loads/stores need to go though a VREV
7263 def : Pat<(v2f64 (load t2addrmode_imm7<0>:$addr)),
7264 (v2f64 (MVE_VREV64_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
7265 def : Pat<(v2i64 (load t2addrmode_imm7<0>:$addr)),
7266 (v2i64 (MVE_VREV64_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
7267 def : Pat<(v4i32 (load t2addrmode_imm7<0>:$addr)),
7268 (v4i32 (MVE_VREV32_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
7269 def : Pat<(v4f32 (load t2addrmode_imm7<0>:$addr)),
7270 (v4f32 (MVE_VREV32_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
7271 def : Pat<(v8i16 (load t2addrmode_imm7<0>:$addr)),
7272 (v8i16 (MVE_VREV16_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
7273 def : Pat<(v8f16 (load t2addrmode_imm7<0>:$addr)),
7274 (v8f16 (MVE_VREV16_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>;
7275 def : Pat<(store (v2f64 MQPR:$val), t2addrmode_imm7<0>:$addr),
7276 (MVE_VSTRBU8 (MVE_VREV64_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
7277 def : Pat<(store (v2i64 MQPR:$val), t2addrmode_imm7<0>:$addr),
7278 (MVE_VSTRBU8 (MVE_VREV64_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
7279 def : Pat<(store (v4i32 MQPR:$val), t2addrmode_imm7<0>:$addr),
7280 (MVE_VSTRBU8 (MVE_VREV32_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
7281 def : Pat<(store (v4f32 MQPR:$val), t2addrmode_imm7<0>:$addr),
7282 (MVE_VSTRBU8 (MVE_VREV32_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
7283 def : Pat<(store (v8i16 MQPR:$val), t2addrmode_imm7<0>:$addr),
7284 (MVE_VSTRBU8 (MVE_VREV16_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
7285 def : Pat<(store (v8f16 MQPR:$val), t2addrmode_imm7<0>:$addr),
7286 (MVE_VSTRBU8 (MVE_VREV16_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>;
7288 // Pre/Post inc stores
7289 def : MVE_vector_offset_store_typed<v16i8, MVE_VSTRBU8_pre, pre_store, 0>;
7290 def : MVE_vector_offset_store_typed<v16i8, MVE_VSTRBU8_post, post_store, 0>;
7291 def : MVE_vector_offset_store_typed<v8i16, MVE_VSTRHU16_pre, aligned16_pre_store, 1>;
7292 def : MVE_vector_offset_store_typed<v8i16, MVE_VSTRHU16_post, aligned16_post_store, 1>;
7293 def : MVE_vector_offset_store_typed<v8f16, MVE_VSTRHU16_pre, aligned16_pre_store, 1>;
7294 def : MVE_vector_offset_store_typed<v8f16, MVE_VSTRHU16_post, aligned16_post_store, 1>;
7295 def : MVE_vector_offset_store_typed<v4i32, MVE_VSTRWU32_pre, aligned32_pre_store, 2>;
7296 def : MVE_vector_offset_store_typed<v4i32, MVE_VSTRWU32_post, aligned32_post_store, 2>;
7297 def : MVE_vector_offset_store_typed<v4f32, MVE_VSTRWU32_pre, aligned32_pre_store, 2>;
7298 def : MVE_vector_offset_store_typed<v4f32, MVE_VSTRWU32_post, aligned32_post_store, 2>;
7301 let Predicates = [HasMVEInt] in {
7302 // Aligned masked store, shared between LE and BE
7303 def : MVE_vector_maskedstore_typed<v16i8, MVE_VSTRBU8, aligned_maskedstvi8, 0>;
7304 def : MVE_vector_maskedstore_typed<v8i16, MVE_VSTRHU16, aligned_maskedstvi16, 1>;
7305 def : MVE_vector_maskedstore_typed<v8f16, MVE_VSTRHU16, aligned_maskedstvi16, 1>;
7306 def : MVE_vector_maskedstore_typed<v4i32, MVE_VSTRWU32, aligned_maskedstvi32, 2>;
7307 def : MVE_vector_maskedstore_typed<v4f32, MVE_VSTRWU32, aligned_maskedstvi32, 2>;
7309 // Pre/Post inc masked stores
7310 def : MVE_vector_offset_maskedstore_typed<v16i8, MVE_VSTRBU8_pre, aligned_pre_maskedstorevi8, 0>;
7311 def : MVE_vector_offset_maskedstore_typed<v16i8, MVE_VSTRBU8_post, aligned_post_maskedstorevi8, 0>;
7312 def : MVE_vector_offset_maskedstore_typed<v8i16, MVE_VSTRHU16_pre, aligned_pre_maskedstorevi16, 1>;
7313 def : MVE_vector_offset_maskedstore_typed<v8i16, MVE_VSTRHU16_post, aligned_post_maskedstorevi16, 1>;
7314 def : MVE_vector_offset_maskedstore_typed<v8f16, MVE_VSTRHU16_pre, aligned_pre_maskedstorevi16, 1>;
7315 def : MVE_vector_offset_maskedstore_typed<v8f16, MVE_VSTRHU16_post, aligned_post_maskedstorevi16, 1>;
7316 def : MVE_vector_offset_maskedstore_typed<v4i32, MVE_VSTRWU32_pre, aligned_pre_maskedstorevi32, 2>;
7317 def : MVE_vector_offset_maskedstore_typed<v4i32, MVE_VSTRWU32_post, aligned_post_maskedstorevi32, 2>;
7318 def : MVE_vector_offset_maskedstore_typed<v4f32, MVE_VSTRWU32_pre, aligned_pre_maskedstorevi32, 2>;
7319 def : MVE_vector_offset_maskedstore_typed<v4f32, MVE_VSTRWU32_post, aligned_post_maskedstorevi32, 2>;
7321 // Aligned masked loads
7322 def : MVE_vector_maskedload_typed<v16i8, MVE_VLDRBU8, aligned_maskedloadvi8, 0>;
7323 def : MVE_vector_maskedload_typed<v8i16, MVE_VLDRHU16, aligned_maskedloadvi16, 1>;
7324 def : MVE_vector_maskedload_typed<v8f16, MVE_VLDRHU16, aligned_maskedloadvi16, 1>;
7325 def : MVE_vector_maskedload_typed<v4i32, MVE_VLDRWU32, aligned_maskedloadvi32, 2>;
7326 def : MVE_vector_maskedload_typed<v4f32, MVE_VLDRWU32, aligned_maskedloadvi32, 2>;
7329 // Widening/Narrowing Loads/Stores
7331 multiclass MVEExtLoadStore<Instruction LoadSInst, Instruction LoadUInst, string StoreInst,
7332 string Amble, ValueType VT, int Shift> {
7334 def : Pat<(!cast<PatFrag>("aligned_truncst"#Amble) (VT MQPR:$val), taddrmode_imm7<Shift>:$addr),
7335 (!cast<Instruction>(StoreInst) MQPR:$val, taddrmode_imm7<Shift>:$addr)>;
7336 def : Pat<(!cast<PatFrag>("aligned_post_truncst"#Amble) (VT MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<Shift>:$addr),
7337 (!cast<Instruction>(StoreInst#"_post") MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<Shift>:$addr)>;
7338 def : Pat<(!cast<PatFrag>("aligned_pre_truncst"#Amble) (VT MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<Shift>:$addr),
7339 (!cast<Instruction>(StoreInst#"_pre") MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<Shift>:$addr)>;
7341 // Masked trunc stores
7342 def : Pat<(!cast<PatFrag>("aligned_truncmaskedst"#Amble) (VT MQPR:$val), taddrmode_imm7<Shift>:$addr, VCCR:$pred),
7343 (!cast<Instruction>(StoreInst) MQPR:$val, taddrmode_imm7<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg)>;
7344 def : Pat<(!cast<PatFrag>("aligned_post_truncmaskedst"#Amble) (VT MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<Shift>:$addr, VCCR:$pred),
7345 (!cast<Instruction>(StoreInst#"_post") MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg)>;
7346 def : Pat<(!cast<PatFrag>("aligned_pre_truncmaskedst"#Amble) (VT MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<Shift>:$addr, VCCR:$pred),
7347 (!cast<Instruction>(StoreInst#"_pre") MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg)>;
7350 def : Pat<(VT (!cast<PatFrag>("aligned_extload"#Amble) taddrmode_imm7<Shift>:$addr)),
7351 (VT (LoadUInst taddrmode_imm7<Shift>:$addr))>;
7352 def : Pat<(VT (!cast<PatFrag>("aligned_sextload"#Amble) taddrmode_imm7<Shift>:$addr)),
7353 (VT (LoadSInst taddrmode_imm7<Shift>:$addr))>;
7354 def : Pat<(VT (!cast<PatFrag>("aligned_zextload"#Amble) taddrmode_imm7<Shift>:$addr)),
7355 (VT (LoadUInst taddrmode_imm7<Shift>:$addr))>;
7358 def : Pat<(VT (!cast<PatFrag>("aligned_extmaskedload"#Amble) taddrmode_imm7<Shift>:$addr, VCCR:$pred, (VT (ARMvmovImm (i32 0))))),
7359 (VT (LoadUInst taddrmode_imm7<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg))>;
7360 def : Pat<(VT (!cast<PatFrag>("aligned_sextmaskedload"#Amble) taddrmode_imm7<Shift>:$addr, VCCR:$pred, (VT (ARMvmovImm (i32 0))))),
7361 (VT (LoadSInst taddrmode_imm7<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg))>;
7362 def : Pat<(VT (!cast<PatFrag>("aligned_zextmaskedload"#Amble) taddrmode_imm7<Shift>:$addr, VCCR:$pred, (VT (ARMvmovImm (i32 0))))),
7363 (VT (LoadUInst taddrmode_imm7<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg))>;
7366 let Predicates = [HasMVEInt] in {
7367 defm : MVEExtLoadStore<MVE_VLDRBS16, MVE_VLDRBU16, "MVE_VSTRB16", "vi8", v8i16, 0>;
7368 defm : MVEExtLoadStore<MVE_VLDRBS32, MVE_VLDRBU32, "MVE_VSTRB32", "vi8", v4i32, 0>;
7369 defm : MVEExtLoadStore<MVE_VLDRHS32, MVE_VLDRHU32, "MVE_VSTRH32", "vi16", v4i32, 1>;
7373 // Bit convert patterns
7375 let Predicates = [HasMVEInt] in {
7376 def : Pat<(v2f64 (bitconvert (v2i64 MQPR:$src))), (v2f64 MQPR:$src)>;
7377 def : Pat<(v2i64 (bitconvert (v2f64 MQPR:$src))), (v2i64 MQPR:$src)>;
7379 def : Pat<(v4i32 (bitconvert (v4f32 MQPR:$src))), (v4i32 MQPR:$src)>;
7380 def : Pat<(v4f32 (bitconvert (v4i32 MQPR:$src))), (v4f32 MQPR:$src)>;
7382 def : Pat<(v8i16 (bitconvert (v8f16 MQPR:$src))), (v8i16 MQPR:$src)>;
7383 def : Pat<(v8f16 (bitconvert (v8i16 MQPR:$src))), (v8f16 MQPR:$src)>;
7386 let Predicates = [IsLE,HasMVEInt] in {
7387 def : Pat<(v2f64 (bitconvert (v4f32 MQPR:$src))), (v2f64 MQPR:$src)>;
7388 def : Pat<(v2f64 (bitconvert (v4i32 MQPR:$src))), (v2f64 MQPR:$src)>;
7389 def : Pat<(v2f64 (bitconvert (v8f16 MQPR:$src))), (v2f64 MQPR:$src)>;
7390 def : Pat<(v2f64 (bitconvert (v8i16 MQPR:$src))), (v2f64 MQPR:$src)>;
7391 def : Pat<(v2f64 (bitconvert (v16i8 MQPR:$src))), (v2f64 MQPR:$src)>;
7393 def : Pat<(v2i64 (bitconvert (v4f32 MQPR:$src))), (v2i64 MQPR:$src)>;
7394 def : Pat<(v2i64 (bitconvert (v4i32 MQPR:$src))), (v2i64 MQPR:$src)>;
7395 def : Pat<(v2i64 (bitconvert (v8f16 MQPR:$src))), (v2i64 MQPR:$src)>;
7396 def : Pat<(v2i64 (bitconvert (v8i16 MQPR:$src))), (v2i64 MQPR:$src)>;
7397 def : Pat<(v2i64 (bitconvert (v16i8 MQPR:$src))), (v2i64 MQPR:$src)>;
7399 def : Pat<(v4f32 (bitconvert (v2f64 MQPR:$src))), (v4f32 MQPR:$src)>;
7400 def : Pat<(v4f32 (bitconvert (v2i64 MQPR:$src))), (v4f32 MQPR:$src)>;
7401 def : Pat<(v4f32 (bitconvert (v8f16 MQPR:$src))), (v4f32 MQPR:$src)>;
7402 def : Pat<(v4f32 (bitconvert (v8i16 MQPR:$src))), (v4f32 MQPR:$src)>;
7403 def : Pat<(v4f32 (bitconvert (v16i8 MQPR:$src))), (v4f32 MQPR:$src)>;
7405 def : Pat<(v4i32 (bitconvert (v2f64 MQPR:$src))), (v4i32 MQPR:$src)>;
7406 def : Pat<(v4i32 (bitconvert (v2i64 MQPR:$src))), (v4i32 MQPR:$src)>;
7407 def : Pat<(v4i32 (bitconvert (v8f16 MQPR:$src))), (v4i32 MQPR:$src)>;
7408 def : Pat<(v4i32 (bitconvert (v8i16 MQPR:$src))), (v4i32 MQPR:$src)>;
7409 def : Pat<(v4i32 (bitconvert (v16i8 MQPR:$src))), (v4i32 MQPR:$src)>;
7411 def : Pat<(v8f16 (bitconvert (v2f64 MQPR:$src))), (v8f16 MQPR:$src)>;
7412 def : Pat<(v8f16 (bitconvert (v2i64 MQPR:$src))), (v8f16 MQPR:$src)>;
7413 def : Pat<(v8f16 (bitconvert (v4f32 MQPR:$src))), (v8f16 MQPR:$src)>;
7414 def : Pat<(v8f16 (bitconvert (v4i32 MQPR:$src))), (v8f16 MQPR:$src)>;
7415 def : Pat<(v8f16 (bitconvert (v16i8 MQPR:$src))), (v8f16 MQPR:$src)>;
7417 def : Pat<(v8i16 (bitconvert (v2f64 MQPR:$src))), (v8i16 MQPR:$src)>;
7418 def : Pat<(v8i16 (bitconvert (v2i64 MQPR:$src))), (v8i16 MQPR:$src)>;
7419 def : Pat<(v8i16 (bitconvert (v4f32 MQPR:$src))), (v8i16 MQPR:$src)>;
7420 def : Pat<(v8i16 (bitconvert (v4i32 MQPR:$src))), (v8i16 MQPR:$src)>;
7421 def : Pat<(v8i16 (bitconvert (v16i8 MQPR:$src))), (v8i16 MQPR:$src)>;
7423 def : Pat<(v16i8 (bitconvert (v2f64 MQPR:$src))), (v16i8 MQPR:$src)>;
7424 def : Pat<(v16i8 (bitconvert (v2i64 MQPR:$src))), (v16i8 MQPR:$src)>;
7425 def : Pat<(v16i8 (bitconvert (v4f32 MQPR:$src))), (v16i8 MQPR:$src)>;
7426 def : Pat<(v16i8 (bitconvert (v4i32 MQPR:$src))), (v16i8 MQPR:$src)>;
7427 def : Pat<(v16i8 (bitconvert (v8f16 MQPR:$src))), (v16i8 MQPR:$src)>;
7428 def : Pat<(v16i8 (bitconvert (v8i16 MQPR:$src))), (v16i8 MQPR:$src)>;
7431 let Predicates = [IsBE,HasMVEInt] in {
7432 def : Pat<(v2f64 (bitconvert (v4f32 MQPR:$src))), (v2f64 (MVE_VREV64_32 MQPR:$src))>;
7433 def : Pat<(v2f64 (bitconvert (v4i32 MQPR:$src))), (v2f64 (MVE_VREV64_32 MQPR:$src))>;
7434 def : Pat<(v2f64 (bitconvert (v8f16 MQPR:$src))), (v2f64 (MVE_VREV64_16 MQPR:$src))>;
7435 def : Pat<(v2f64 (bitconvert (v8i16 MQPR:$src))), (v2f64 (MVE_VREV64_16 MQPR:$src))>;
7436 def : Pat<(v2f64 (bitconvert (v16i8 MQPR:$src))), (v2f64 (MVE_VREV64_8 MQPR:$src))>;
7438 def : Pat<(v2i64 (bitconvert (v4f32 MQPR:$src))), (v2i64 (MVE_VREV64_32 MQPR:$src))>;
7439 def : Pat<(v2i64 (bitconvert (v4i32 MQPR:$src))), (v2i64 (MVE_VREV64_32 MQPR:$src))>;
7440 def : Pat<(v2i64 (bitconvert (v8f16 MQPR:$src))), (v2i64 (MVE_VREV64_16 MQPR:$src))>;
7441 def : Pat<(v2i64 (bitconvert (v8i16 MQPR:$src))), (v2i64 (MVE_VREV64_16 MQPR:$src))>;
7442 def : Pat<(v2i64 (bitconvert (v16i8 MQPR:$src))), (v2i64 (MVE_VREV64_8 MQPR:$src))>;
7444 def : Pat<(v4f32 (bitconvert (v2f64 MQPR:$src))), (v4f32 (MVE_VREV64_32 MQPR:$src))>;
7445 def : Pat<(v4f32 (bitconvert (v2i64 MQPR:$src))), (v4f32 (MVE_VREV64_32 MQPR:$src))>;
7446 def : Pat<(v4f32 (bitconvert (v8f16 MQPR:$src))), (v4f32 (MVE_VREV32_16 MQPR:$src))>;
7447 def : Pat<(v4f32 (bitconvert (v8i16 MQPR:$src))), (v4f32 (MVE_VREV32_16 MQPR:$src))>;
7448 def : Pat<(v4f32 (bitconvert (v16i8 MQPR:$src))), (v4f32 (MVE_VREV32_8 MQPR:$src))>;
7450 def : Pat<(v4i32 (bitconvert (v2f64 MQPR:$src))), (v4i32 (MVE_VREV64_32 MQPR:$src))>;
7451 def : Pat<(v4i32 (bitconvert (v2i64 MQPR:$src))), (v4i32 (MVE_VREV64_32 MQPR:$src))>;
7452 def : Pat<(v4i32 (bitconvert (v8f16 MQPR:$src))), (v4i32 (MVE_VREV32_16 MQPR:$src))>;
7453 def : Pat<(v4i32 (bitconvert (v8i16 MQPR:$src))), (v4i32 (MVE_VREV32_16 MQPR:$src))>;
7454 def : Pat<(v4i32 (bitconvert (v16i8 MQPR:$src))), (v4i32 (MVE_VREV32_8 MQPR:$src))>;
7456 def : Pat<(v8f16 (bitconvert (v2f64 MQPR:$src))), (v8f16 (MVE_VREV64_16 MQPR:$src))>;
7457 def : Pat<(v8f16 (bitconvert (v2i64 MQPR:$src))), (v8f16 (MVE_VREV64_16 MQPR:$src))>;
7458 def : Pat<(v8f16 (bitconvert (v4f32 MQPR:$src))), (v8f16 (MVE_VREV32_16 MQPR:$src))>;
7459 def : Pat<(v8f16 (bitconvert (v4i32 MQPR:$src))), (v8f16 (MVE_VREV32_16 MQPR:$src))>;
7460 def : Pat<(v8f16 (bitconvert (v16i8 MQPR:$src))), (v8f16 (MVE_VREV16_8 MQPR:$src))>;
7462 def : Pat<(v8i16 (bitconvert (v2f64 MQPR:$src))), (v8i16 (MVE_VREV64_16 MQPR:$src))>;
7463 def : Pat<(v8i16 (bitconvert (v2i64 MQPR:$src))), (v8i16 (MVE_VREV64_16 MQPR:$src))>;
7464 def : Pat<(v8i16 (bitconvert (v4f32 MQPR:$src))), (v8i16 (MVE_VREV32_16 MQPR:$src))>;
7465 def : Pat<(v8i16 (bitconvert (v4i32 MQPR:$src))), (v8i16 (MVE_VREV32_16 MQPR:$src))>;
7466 def : Pat<(v8i16 (bitconvert (v16i8 MQPR:$src))), (v8i16 (MVE_VREV16_8 MQPR:$src))>;
7468 def : Pat<(v16i8 (bitconvert (v2f64 MQPR:$src))), (v16i8 (MVE_VREV64_8 MQPR:$src))>;
7469 def : Pat<(v16i8 (bitconvert (v2i64 MQPR:$src))), (v16i8 (MVE_VREV64_8 MQPR:$src))>;
7470 def : Pat<(v16i8 (bitconvert (v4f32 MQPR:$src))), (v16i8 (MVE_VREV32_8 MQPR:$src))>;
7471 def : Pat<(v16i8 (bitconvert (v4i32 MQPR:$src))), (v16i8 (MVE_VREV32_8 MQPR:$src))>;
7472 def : Pat<(v16i8 (bitconvert (v8f16 MQPR:$src))), (v16i8 (MVE_VREV16_8 MQPR:$src))>;
7473 def : Pat<(v16i8 (bitconvert (v8i16 MQPR:$src))), (v16i8 (MVE_VREV16_8 MQPR:$src))>;