1//===-- ARMInstrMVE.td - MVE support for ARM ---------------*- tablegen -*-===// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8// 9// This file describes the ARM MVE instruction set. 10// 11//===----------------------------------------------------------------------===// 12 13// VPT condition mask 14def vpt_mask : Operand<i32> { 15 let PrintMethod = "printVPTMask"; 16 let ParserMatchClass = it_mask_asmoperand; 17 let EncoderMethod = "getVPTMaskOpValue"; 18 let DecoderMethod = "DecodeVPTMaskOperand"; 19} 20 21// VPT/VCMP restricted predicate for sign invariant types 22def 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"; 29} 30 31// VPT/VCMP restricted predicate for signed types 32def 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"; 39} 40 41// VPT/VCMP restricted predicate for unsigned types 42def 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"; 49} 50 51// VPT/VCMP restricted predicate for floating point 52def 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"; 59} 60 61class VCMPPredicateOperand : Operand<i32>; 62 63def pred_basic_i : VCMPPredicateOperand { 64 let PrintMethod = "printMandatoryRestrictedPredicateOperand"; 65 let ParserMatchClass = pred_restricted_i_asmoperand; 66 let DecoderMethod = "DecodeRestrictedIPredicateOperand"; 67 let EncoderMethod = "getRestrictedCondCodeOpValue"; 68} 69 70def pred_basic_u : VCMPPredicateOperand { 71 let PrintMethod = "printMandatoryRestrictedPredicateOperand"; 72 let ParserMatchClass = pred_restricted_u_asmoperand; 73 let DecoderMethod = "DecodeRestrictedUPredicateOperand"; 74 let EncoderMethod = "getRestrictedCondCodeOpValue"; 75} 76 77def pred_basic_s : VCMPPredicateOperand { 78 let PrintMethod = "printMandatoryRestrictedPredicateOperand"; 79 let ParserMatchClass = pred_restricted_s_asmoperand; 80 let DecoderMethod = "DecodeRestrictedSPredicateOperand"; 81 let EncoderMethod = "getRestrictedCondCodeOpValue"; 82} 83 84def pred_basic_fp : VCMPPredicateOperand { 85 let PrintMethod = "printMandatoryRestrictedPredicateOperand"; 86 let ParserMatchClass = pred_restricted_fp_asmoperand; 87 let DecoderMethod = "DecodeRestrictedFPPredicateOperand"; 88 let EncoderMethod = "getRestrictedCondCodeOpValue"; 89} 90 91// Register list operands for interleaving load/stores 92def 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]"; 98} 99 100def VecList2Q : RegisterOperand<MQQPR, "printMVEVectorListTwoQ"> { 101 let ParserMatchClass = VecList2QAsmOperand; 102 let PrintMethod = "printMVEVectorList<2>"; 103} 104 105def 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]"; 111} 112 113def VecList4Q : RegisterOperand<MQQQQPR, "printMVEVectorListFourQ"> { 114 let ParserMatchClass = VecList4QAsmOperand; 115 let PrintMethod = "printMVEVectorList<4>"; 116} 117 118// taddrmode_imm7 := reg[r0-r7] +/- (imm7 << shift) 119class TMemImm7ShiftOffsetAsmOperand<int shift> : AsmOperandClass { 120 let Name = "TMemImm7Shift"#shift#"Offset"; 121 let PredicateMethod = "isMemImm7ShiftedOffset<"#shift#",ARM::tGPRRegClassID>"; 122 let RenderMethod = "addMemImmOffsetOperands"; 123} 124 125class 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); 134} 135 136// t2addrmode_imm7 := reg +/- (imm7) 137class MemImm7ShiftOffsetAsmOperand<int shift> : AsmOperandClass { 138 let Name = "MemImm7Shift"#shift#"Offset"; 139 let PredicateMethod = "isMemImm7ShiftedOffset<" # shift # 140 ",ARM::GPRnopcRegClassID>"; 141 let RenderMethod = "addMemImmOffsetOperands"; 142} 143 144def MemImm7Shift0OffsetAsmOperand : MemImm7ShiftOffsetAsmOperand<0>; 145def MemImm7Shift1OffsetAsmOperand : MemImm7ShiftOffsetAsmOperand<1>; 146def MemImm7Shift2OffsetAsmOperand : MemImm7ShiftOffsetAsmOperand<2>; 147class 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); 154} 155 156class t2addrmode_imm7<int shift> : T2AddrMode_Imm7<shift> { 157 // They are printed the same way as the imm8 version 158 let PrintMethod = "printT2AddrModeImm8Operand<false>"; 159} 160 161class MemImm7ShiftOffsetWBAsmOperand<int shift> : AsmOperandClass { 162 let Name = "MemImm7Shift"#shift#"OffsetWB"; 163 let PredicateMethod = "isMemImm7ShiftedOffset<" # shift # 164 ",ARM::rGPRRegClassID>"; 165 let RenderMethod = "addMemImmOffsetOperands"; 166} 167 168def MemImm7Shift0OffsetWBAsmOperand : MemImm7ShiftOffsetWBAsmOperand<0>; 169def MemImm7Shift1OffsetWBAsmOperand : MemImm7ShiftOffsetWBAsmOperand<1>; 170def MemImm7Shift2OffsetWBAsmOperand : MemImm7ShiftOffsetWBAsmOperand<2>; 171 172class 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); 179} 180 181class t2am_imm7shiftOffsetAsmOperand<int shift> 182 : AsmOperandClass { let Name = "Imm7Shift"#shift; } 183def t2am_imm7shift0OffsetAsmOperand : t2am_imm7shiftOffsetAsmOperand<0>; 184def t2am_imm7shift1OffsetAsmOperand : t2am_imm7shiftOffsetAsmOperand<1>; 185def t2am_imm7shift2OffsetAsmOperand : t2am_imm7shiftOffsetAsmOperand<2>; 186 187class t2am_imm7_offset<int shift> : MemOperand, 188 ComplexPattern<i32, 1, "SelectT2AddrModeImm7Offset<"#shift#">", 189 [], [SDNPWantRoot]> { 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} 197 198// Operands for gather/scatter loads of the form [Rbase, Qoffsets] 199class MemRegRQOffsetAsmOperand<int shift> : AsmOperandClass { 200 let Name = "MemRegRQS"#shift#"Offset"; 201 let PredicateMethod = "isMemRegRQOffset<"#shift#">"; 202 let RenderMethod = "addMemRegRQOffsetOperands"; 203} 204 205def MemRegRQS0OffsetAsmOperand : MemRegRQOffsetAsmOperand<0>; 206def MemRegRQS1OffsetAsmOperand : MemRegRQOffsetAsmOperand<1>; 207def MemRegRQS2OffsetAsmOperand : MemRegRQOffsetAsmOperand<2>; 208def MemRegRQS3OffsetAsmOperand : MemRegRQOffsetAsmOperand<3>; 209 210// mve_addr_rq_shift := reg + vreg{ << UXTW #shift} 211class mve_addr_rq_shift<int shift> : MemOperand { 212 let EncoderMethod = "getMveAddrModeRQOpValue"; 213 let PrintMethod = "printMveAddrModeRQOperand<"#shift#">"; 214 let ParserMatchClass = 215 !cast<AsmOperandClass>("MemRegRQS"#shift#"OffsetAsmOperand"); 216 let DecoderMethod = "DecodeMveAddrModeRQ"; 217 let MIOperandInfo = (ops GPRnopc:$base, MQPR:$offsreg); 218} 219 220class MemRegQOffsetAsmOperand<int shift> : AsmOperandClass { 221 let Name = "MemRegQS"#shift#"Offset"; 222 let PredicateMethod = "isMemRegQOffset<"#shift#">"; 223 let RenderMethod = "addMemImmOffsetOperands"; 224} 225 226def MemRegQS2OffsetAsmOperand : MemRegQOffsetAsmOperand<2>; 227def MemRegQS3OffsetAsmOperand : MemRegQOffsetAsmOperand<3>; 228 229// mve_addr_q_shift := vreg {+ #imm7s2/4} 230class mve_addr_q_shift<int shift> : MemOperand { 231 let EncoderMethod = "getMveAddrModeQOpValue<"#shift#">"; 232 // Can be printed same way as other reg + imm operands 233 let PrintMethod = "printT2AddrModeImm8Operand<false>"; 234 let ParserMatchClass = 235 !cast<AsmOperandClass>("MemRegQS"#shift#"OffsetAsmOperand"); 236 let DecoderMethod = "DecodeMveAddrModeQ<"#shift#">"; 237 let MIOperandInfo = (ops MQPR:$base, i32imm:$imm); 238} 239 240// A family of classes wrapping up information about the vector types 241// used by MVE. 242class MVEVectorVTInfo<ValueType vec, ValueType dblvec, 243 ValueType pred, ValueType dblpred, 244 bits<2> size, string suffixletter, bit unsigned> { 245 // The LLVM ValueType representing the vector, so we can use it in 246 // ISel patterns. 247 ValueType Vec = vec; 248 249 // The LLVM ValueType representing a vector with elements double the size 250 // of those in Vec, so we can use it in ISel patterns. It is up to the 251 // invoker of this class to ensure that this is a correct choice. 252 ValueType DblVec = dblvec; 253 254 // An LLVM ValueType representing a corresponding vector of 255 // predicate bits, for use in ISel patterns that handle an IR 256 // intrinsic describing the predicated form of the instruction. 257 ValueType Pred = pred; 258 259 // Same as Pred but for DblVec rather than Vec. 260 ValueType DblPred = dblpred; 261 262 // The most common representation of the vector element size in MVE 263 // instruction encodings: a 2-bit value V representing an (8<<V)-bit 264 // vector element. 265 bits<2> Size = size; 266 267 // For vectors explicitly mentioning a signedness of integers: 0 for 268 // signed and 1 for unsigned. For anything else, undefined. 269 bit Unsigned = unsigned; 270 271 // The number of bits in a vector element, in integer form. 272 int LaneBits = !shl(8, Size); 273 274 // The suffix used in assembly language on an instruction operating 275 // on this lane if it only cares about number of bits. 276 string BitsSuffix = !if(!eq(suffixletter, "p"), 277 !if(!eq(unsigned, 0b0), "8", "16"), 278 !cast<string>(LaneBits)); 279 280 // The suffix used on an instruction that mentions the whole type. 281 string Suffix = suffixletter # BitsSuffix; 282 283 // The letter part of the suffix only. 284 string SuffixLetter = suffixletter; 285} 286 287// Integer vector types that don't treat signed and unsigned differently. 288def MVE_v16i8 : MVEVectorVTInfo<v16i8, v8i16, v16i1, v8i1, 0b00, "i", ?>; 289def MVE_v8i16 : MVEVectorVTInfo<v8i16, v4i32, v8i1, v4i1, 0b01, "i", ?>; 290def MVE_v4i32 : MVEVectorVTInfo<v4i32, v2i64, v4i1, v2i1, 0b10, "i", ?>; 291def MVE_v2i64 : MVEVectorVTInfo<v2i64, ?, v2i1, ?, 0b11, "i", ?>; 292 293// Explicitly signed and unsigned integer vectors. They map to the 294// same set of LLVM ValueTypes as above, but are represented 295// differently in assembly and instruction encodings. 296def MVE_v16s8 : MVEVectorVTInfo<v16i8, v8i16, v16i1, v8i1, 0b00, "s", 0b0>; 297def MVE_v8s16 : MVEVectorVTInfo<v8i16, v4i32, v8i1, v4i1, 0b01, "s", 0b0>; 298def MVE_v4s32 : MVEVectorVTInfo<v4i32, v2i64, v4i1, v2i1, 0b10, "s", 0b0>; 299def MVE_v2s64 : MVEVectorVTInfo<v2i64, ?, v2i1, ?, 0b11, "s", 0b0>; 300def MVE_v16u8 : MVEVectorVTInfo<v16i8, v8i16, v16i1, v8i1, 0b00, "u", 0b1>; 301def MVE_v8u16 : MVEVectorVTInfo<v8i16, v4i32, v8i1, v4i1, 0b01, "u", 0b1>; 302def MVE_v4u32 : MVEVectorVTInfo<v4i32, v2i64, v4i1, v2i1, 0b10, "u", 0b1>; 303def MVE_v2u64 : MVEVectorVTInfo<v2i64, ?, v2i1, ?, 0b11, "u", 0b1>; 304 305// FP vector types. 306def MVE_v8f16 : MVEVectorVTInfo<v8f16, v4f32, v8i1, v4i1, 0b01, "f", ?>; 307def MVE_v4f32 : MVEVectorVTInfo<v4f32, v2f64, v4i1, v2i1, 0b10, "f", ?>; 308def MVE_v2f64 : MVEVectorVTInfo<v2f64, ?, v2i1, ?, 0b11, "f", ?>; 309 310// Polynomial vector types. 311def MVE_v16p8 : MVEVectorVTInfo<v16i8, v8i16, v16i1, v8i1, 0b11, "p", 0b0>; 312def MVE_v8p16 : MVEVectorVTInfo<v8i16, v4i32, v8i1, v4i1, 0b11, "p", 0b1>; 313 314multiclass MVE_TwoOpPattern<MVEVectorVTInfo VTI, SDPatternOperator Op, Intrinsic PredInt, 315 dag PredOperands, Instruction Inst, 316 SDPatternOperator IdentityVec = null_frag> { 317 // Unpredicated 318 def : Pat<(VTI.Vec (Op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn))), 319 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>; 320 321 // Predicated with select 322 if !ne(VTI.Size, 0b11) then { 323 def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$mask), 324 (VTI.Vec (Op (VTI.Vec MQPR:$Qm), 325 (VTI.Vec MQPR:$Qn))), 326 (VTI.Vec MQPR:$inactive))), 327 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 328 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 329 (VTI.Vec MQPR:$inactive)))>; 330 331 // Optionally with the select folded through the op 332 def : Pat<(VTI.Vec (Op (VTI.Vec MQPR:$Qm), 333 (VTI.Vec (vselect (VTI.Pred VCCR:$mask), 334 (VTI.Vec MQPR:$Qn), 335 (VTI.Vec IdentityVec))))), 336 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 337 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 338 (VTI.Vec MQPR:$Qm)))>; 339 } 340 341 // Predicated with intrinsic 342 def : Pat<(VTI.Vec !con((PredInt (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)), 343 PredOperands, 344 (? (VTI.Pred VCCR:$mask), (VTI.Vec MQPR:$inactive)))), 345 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 346 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 347 (VTI.Vec MQPR:$inactive)))>; 348} 349 350multiclass MVE_TwoOpPatternDup<MVEVectorVTInfo VTI, SDPatternOperator Op, Intrinsic PredInt, 351 dag PredOperands, Instruction Inst, 352 SDPatternOperator IdentityVec = null_frag> { 353 // Unpredicated 354 def : Pat<(VTI.Vec (Op (VTI.Vec MQPR:$Qm), (VTI.Vec (ARMvdup rGPR:$Rn)))), 355 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), rGPR:$Rn))>; 356 357 // Predicated with select 358 if !ne(VTI.Size, 0b11) then { 359 def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$mask), 360 (VTI.Vec (Op (VTI.Vec MQPR:$Qm), 361 (VTI.Vec (ARMvdup rGPR:$Rn)))), 362 (VTI.Vec MQPR:$inactive))), 363 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), rGPR:$Rn, 364 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 365 (VTI.Vec MQPR:$inactive)))>; 366 367 // Optionally with the select folded through the op 368 def : Pat<(VTI.Vec (Op (VTI.Vec MQPR:$Qm), 369 (VTI.Vec (vselect (VTI.Pred VCCR:$mask), 370 (ARMvdup rGPR:$Rn), 371 (VTI.Vec IdentityVec))))), 372 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), rGPR:$Rn, 373 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 374 (VTI.Vec MQPR:$Qm)))>; 375 } 376 377 // Predicated with intrinsic 378 def : Pat<(VTI.Vec !con((PredInt (VTI.Vec MQPR:$Qm), (VTI.Vec (ARMvdup rGPR:$Rn))), 379 PredOperands, 380 (? (VTI.Pred VCCR:$mask), (VTI.Vec MQPR:$inactive)))), 381 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), rGPR:$Rn, 382 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 383 (VTI.Vec MQPR:$inactive)))>; 384} 385 386// --------- Start of base classes for the instructions themselves 387 388class MVE_MI<dag oops, dag iops, InstrItinClass itin, string asm, 389 string ops, string cstr, bits<2> vecsize, list<dag> pattern> 390 : Thumb2XI<oops, iops, AddrModeNone, 4, itin, !strconcat(asm, "\t", ops), cstr, 391 pattern>, 392 Requires<[HasMVEInt]> { 393 let D = MVEDomain; 394 let DecoderNamespace = "MVE"; 395 let VecSize = vecsize; 396} 397 398// MVE_p is used for most predicated instructions, to add the cluster 399// of input operands that provides the VPT suffix (none, T or E) and 400// the input predicate register. 401class MVE_p<dag oops, dag iops, InstrItinClass itin, string iname, 402 string suffix, string ops, vpred_ops vpred, string cstr, 403 bits<2> vecsize, list<dag> pattern=[]> 404 : MVE_MI<oops, !con(iops, (ins vpred:$vp)), itin, 405 // If the instruction has a suffix, like vadd.f32, then the 406 // VPT predication suffix goes before the dot, so the full 407 // name has to be "vadd${vp}.f32". 408 !strconcat(iname, "${vp}", 409 !if(!eq(suffix, ""), "", !strconcat(".", suffix))), 410 ops, !strconcat(cstr, vpred.vpred_constraint), vecsize, pattern> { 411 let Inst{31-29} = 0b111; 412 let Inst{27-26} = 0b11; 413} 414 415class MVE_f<dag oops, dag iops, InstrItinClass itin, string iname, 416 string suffix, string ops, vpred_ops vpred, string cstr, 417 bits<2> vecsize, list<dag> pattern=[]> 418 : MVE_p<oops, iops, itin, iname, suffix, ops, vpred, cstr, vecsize, pattern> { 419 let Predicates = [HasMVEFloat]; 420} 421 422class MVE_MI_with_pred<dag oops, dag iops, InstrItinClass itin, string asm, 423 string ops, string cstr, list<dag> pattern> 424 : Thumb2I<oops, iops, AddrModeNone, 4, itin, asm, !strconcat("\t", ops), cstr, 425 pattern>, 426 Requires<[HasV8_1MMainline, HasMVEInt]> { 427 let D = MVEDomain; 428 let DecoderNamespace = "MVE"; 429} 430 431class MVE_VMOV_lane_base<dag oops, dag iops, InstrItinClass itin, string asm, 432 string suffix, string ops, string cstr, 433 list<dag> pattern> 434 : Thumb2I<oops, iops, AddrModeNone, 4, itin, asm, 435 !if(!eq(suffix, ""), "", "." # suffix) # "\t" # ops, 436 cstr, pattern>, 437 Requires<[HasV8_1MMainline, HasMVEInt]> { 438 let D = MVEDomain; 439 let DecoderNamespace = "MVE"; 440} 441 442class MVE_ScalarShift<string iname, dag oops, dag iops, string asm, string cstr, 443 list<dag> pattern=[]> 444 : MVE_MI_with_pred<oops, iops, NoItinerary, iname, asm, cstr, pattern> { 445 let Inst{31-20} = 0b111010100101; 446 let Inst{8} = 0b1; 447 let validForTailPredication=1; 448} 449 450class MVE_ScalarShiftSingleReg<string iname, dag iops, string asm, string cstr, 451 list<dag> pattern=[]> 452 : MVE_ScalarShift<iname, (outs rGPR:$RdaDest), iops, asm, cstr, pattern> { 453 bits<4> RdaDest; 454 455 let Inst{19-16} = RdaDest{3-0}; 456} 457 458class MVE_ScalarShiftSRegImm<string iname, bits<2> op5_4> 459 : MVE_ScalarShiftSingleReg<iname, (ins rGPR:$RdaSrc, long_shift:$imm), 460 "$RdaSrc, $imm", "$RdaDest = $RdaSrc", 461 [(set rGPR:$RdaDest, 462 (i32 (!cast<Intrinsic>("int_arm_mve_" # iname) 463 (i32 rGPR:$RdaSrc), (i32 imm:$imm))))]> { 464 bits<5> imm; 465 466 let Inst{15} = 0b0; 467 let Inst{14-12} = imm{4-2}; 468 let Inst{11-8} = 0b1111; 469 let Inst{7-6} = imm{1-0}; 470 let Inst{5-4} = op5_4{1-0}; 471 let Inst{3-0} = 0b1111; 472} 473 474def MVE_SQSHL : MVE_ScalarShiftSRegImm<"sqshl", 0b11>; 475def MVE_SRSHR : MVE_ScalarShiftSRegImm<"srshr", 0b10>; 476def MVE_UQSHL : MVE_ScalarShiftSRegImm<"uqshl", 0b00>; 477def MVE_URSHR : MVE_ScalarShiftSRegImm<"urshr", 0b01>; 478 479class MVE_ScalarShiftSRegReg<string iname, bits<2> op5_4> 480 : MVE_ScalarShiftSingleReg<iname, (ins rGPR:$RdaSrc, rGPR:$Rm), 481 "$RdaSrc, $Rm", "$RdaDest = $RdaSrc", 482 [(set rGPR:$RdaDest, 483 (i32 (!cast<Intrinsic>("int_arm_mve_" # iname) 484 (i32 rGPR:$RdaSrc), (i32 rGPR:$Rm))))]> { 485 bits<4> Rm; 486 487 let Inst{15-12} = Rm{3-0}; 488 let Inst{11-8} = 0b1111; 489 let Inst{7-6} = 0b00; 490 let Inst{5-4} = op5_4{1-0}; 491 let Inst{3-0} = 0b1101; 492 493 let Unpredictable{8-6} = 0b111; 494} 495 496def MVE_SQRSHR : MVE_ScalarShiftSRegReg<"sqrshr", 0b10>; 497def MVE_UQRSHL : MVE_ScalarShiftSRegReg<"uqrshl", 0b00>; 498 499class MVE_ScalarShiftDoubleReg<string iname, dag iops, string asm, 500 string cstr, list<dag> pattern=[]> 501 : MVE_ScalarShift<iname, (outs tGPREven:$RdaLo, tGPROdd:$RdaHi), 502 iops, asm, cstr, pattern> { 503 bits<4> RdaLo; 504 bits<4> RdaHi; 505 506 let Inst{19-17} = RdaLo{3-1}; 507 let Inst{11-9} = RdaHi{3-1}; 508 509 let hasSideEffects = 0; 510} 511 512class MVE_ScalarShiftDRegImm<string iname, bits<2> op5_4, bit op16, 513 list<dag> pattern=[]> 514 : MVE_ScalarShiftDoubleReg< 515 iname, (ins tGPREven:$RdaLo_src, tGPROdd:$RdaHi_src, long_shift:$imm), 516 "$RdaLo, $RdaHi, $imm", "$RdaLo = $RdaLo_src,$RdaHi = $RdaHi_src", 517 pattern> { 518 bits<5> imm; 519 520 let Inst{16} = op16; 521 let Inst{15} = 0b0; 522 let Inst{14-12} = imm{4-2}; 523 let Inst{7-6} = imm{1-0}; 524 let Inst{5-4} = op5_4{1-0}; 525 let Inst{3-0} = 0b1111; 526} 527 528class MVE_ScalarShiftDRegRegBase<string iname, dag iops, string asm, 529 bit op5, bit op16, list<dag> pattern=[]> 530 : MVE_ScalarShiftDoubleReg< 531 iname, iops, asm, "@earlyclobber $RdaHi,@earlyclobber $RdaLo," 532 "$RdaLo = $RdaLo_src,$RdaHi = $RdaHi_src", 533 pattern> { 534 bits<4> Rm; 535 536 let Inst{16} = op16; 537 let Inst{15-12} = Rm{3-0}; 538 let Inst{6} = 0b0; 539 let Inst{5} = op5; 540 let Inst{4} = 0b0; 541 let Inst{3-0} = 0b1101; 542 543 // Custom decoder method because of the following overlapping encodings: 544 // ASRL and SQRSHR 545 // LSLL and UQRSHL 546 // SQRSHRL and SQRSHR 547 // UQRSHLL and UQRSHL 548 let DecoderMethod = "DecodeMVEOverlappingLongShift"; 549} 550 551class MVE_ScalarShiftDRegReg<string iname, bit op5, list<dag> pattern=[]> 552 : MVE_ScalarShiftDRegRegBase< 553 iname, (ins tGPREven:$RdaLo_src, tGPROdd:$RdaHi_src, rGPR:$Rm), 554 "$RdaLo, $RdaHi, $Rm", op5, 0b0, pattern> { 555 556 let Inst{7} = 0b0; 557} 558 559class MVE_ScalarShiftDRegRegWithSat<string iname, bit op5, list<dag> pattern=[]> 560 : MVE_ScalarShiftDRegRegBase< 561 iname, (ins tGPREven:$RdaLo_src, tGPROdd:$RdaHi_src, rGPR:$Rm, saturateop:$sat), 562 "$RdaLo, $RdaHi, $sat, $Rm", op5, 0b1, pattern> { 563 bit sat; 564 565 let Inst{7} = sat; 566} 567 568def MVE_ASRLr : MVE_ScalarShiftDRegReg<"asrl", 0b1, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi, 569 (ARMasrl tGPREven:$RdaLo_src, 570 tGPROdd:$RdaHi_src, rGPR:$Rm))]>; 571def MVE_ASRLi : MVE_ScalarShiftDRegImm<"asrl", 0b10, ?, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi, 572 (ARMasrl tGPREven:$RdaLo_src, 573 tGPROdd:$RdaHi_src, (i32 long_shift:$imm)))]>; 574def MVE_LSLLr : MVE_ScalarShiftDRegReg<"lsll", 0b0, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi, 575 (ARMlsll tGPREven:$RdaLo_src, 576 tGPROdd:$RdaHi_src, rGPR:$Rm))]>; 577def MVE_LSLLi : MVE_ScalarShiftDRegImm<"lsll", 0b00, ?, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi, 578 (ARMlsll tGPREven:$RdaLo_src, 579 tGPROdd:$RdaHi_src, (i32 long_shift:$imm)))]>; 580def MVE_LSRL : MVE_ScalarShiftDRegImm<"lsrl", 0b01, ?, [(set tGPREven:$RdaLo, tGPROdd:$RdaHi, 581 (ARMlsrl tGPREven:$RdaLo_src, 582 tGPROdd:$RdaHi_src, (i32 long_shift:$imm)))]>; 583 584def MVE_SQRSHRL : MVE_ScalarShiftDRegRegWithSat<"sqrshrl", 0b1>; 585def MVE_SQSHLL : MVE_ScalarShiftDRegImm<"sqshll", 0b11, 0b1>; 586def MVE_SRSHRL : MVE_ScalarShiftDRegImm<"srshrl", 0b10, 0b1>; 587 588def MVE_UQRSHLL : MVE_ScalarShiftDRegRegWithSat<"uqrshll", 0b0>; 589def MVE_UQSHLL : MVE_ScalarShiftDRegImm<"uqshll", 0b00, 0b1>; 590def MVE_URSHRL : MVE_ScalarShiftDRegImm<"urshrl", 0b01, 0b1>; 591 592// start of mve_rDest instructions 593 594class MVE_rDest<dag oops, dag iops, InstrItinClass itin, 595 string iname, string suffix, 596 string ops, string cstr, bits<2> vecsize, list<dag> pattern=[]> 597// Always use vpred_n and not vpred_r: with the output register being 598// a GPR and not a vector register, there can't be any question of 599// what to put in its inactive lanes. 600 : MVE_p<oops, iops, itin, iname, suffix, ops, vpred_n, cstr, vecsize, pattern> { 601 602 let Inst{25-23} = 0b101; 603 let Inst{11-9} = 0b111; 604 let Inst{4} = 0b0; 605} 606 607class MVE_VABAV<string suffix, bit U, bits<2> size> 608 : MVE_rDest<(outs rGPR:$Rda), (ins rGPR:$Rda_src, MQPR:$Qn, MQPR:$Qm), 609 NoItinerary, "vabav", suffix, "$Rda, $Qn, $Qm", "$Rda = $Rda_src", 610 size, []> { 611 bits<4> Qm; 612 bits<4> Qn; 613 bits<4> Rda; 614 615 let Inst{28} = U; 616 let Inst{22} = 0b0; 617 let Inst{21-20} = size{1-0}; 618 let Inst{19-17} = Qn{2-0}; 619 let Inst{16} = 0b0; 620 let Inst{15-12} = Rda{3-0}; 621 let Inst{8} = 0b1; 622 let Inst{7} = Qn{3}; 623 let Inst{6} = 0b0; 624 let Inst{5} = Qm{3}; 625 let Inst{3-1} = Qm{2-0}; 626 let Inst{0} = 0b1; 627 let horizontalReduction = 1; 628} 629 630multiclass MVE_VABAV_m<MVEVectorVTInfo VTI> { 631 def "" : MVE_VABAV<VTI.Suffix, VTI.Unsigned, VTI.Size>; 632 defvar Inst = !cast<Instruction>(NAME); 633 634 let Predicates = [HasMVEInt] in { 635 def : Pat<(i32 (int_arm_mve_vabav 636 (i32 VTI.Unsigned), 637 (i32 rGPR:$Rda_src), 638 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))), 639 (i32 (Inst (i32 rGPR:$Rda_src), 640 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm)))>; 641 642 def : Pat<(i32 (int_arm_mve_vabav_predicated 643 (i32 VTI.Unsigned), 644 (i32 rGPR:$Rda_src), 645 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 646 (VTI.Pred VCCR:$mask))), 647 (i32 (Inst (i32 rGPR:$Rda_src), 648 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 649 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>; 650 } 651} 652 653defm MVE_VABAVs8 : MVE_VABAV_m<MVE_v16s8>; 654defm MVE_VABAVs16 : MVE_VABAV_m<MVE_v8s16>; 655defm MVE_VABAVs32 : MVE_VABAV_m<MVE_v4s32>; 656defm MVE_VABAVu8 : MVE_VABAV_m<MVE_v16u8>; 657defm MVE_VABAVu16 : MVE_VABAV_m<MVE_v8u16>; 658defm MVE_VABAVu32 : MVE_VABAV_m<MVE_v4u32>; 659 660class MVE_VADDV<string iname, string suffix, dag iops, string cstr, 661 bit A, bit U, bits<2> size, list<dag> pattern=[]> 662 : MVE_rDest<(outs tGPREven:$Rda), iops, NoItinerary, 663 iname, suffix, "$Rda, $Qm", cstr, size, pattern> { 664 bits<3> Qm; 665 bits<4> Rda; 666 667 let Inst{28} = U; 668 let Inst{22-20} = 0b111; 669 let Inst{19-18} = size{1-0}; 670 let Inst{17-16} = 0b01; 671 let Inst{15-13} = Rda{3-1}; 672 let Inst{12} = 0b0; 673 let Inst{8-6} = 0b100; 674 let Inst{5} = A; 675 let Inst{3-1} = Qm{2-0}; 676 let Inst{0} = 0b0; 677 let horizontalReduction = 1; 678 let validForTailPredication = 1; 679} 680 681def SDTVecReduceP : SDTypeProfile<1, 2, [ // VADDLVp 682 SDTCisInt<0>, SDTCisVec<1>, SDTCisVec<2> 683]>; 684def ARMVADDVs : SDNode<"ARMISD::VADDVs", SDTVecReduce>; 685def ARMVADDVu : SDNode<"ARMISD::VADDVu", SDTVecReduce>; 686def ARMVADDVps : SDNode<"ARMISD::VADDVps", SDTVecReduceP>; 687def ARMVADDVpu : SDNode<"ARMISD::VADDVpu", SDTVecReduceP>; 688 689multiclass MVE_VADDV_A<MVEVectorVTInfo VTI> { 690 def acc : MVE_VADDV<"vaddva", VTI.Suffix, 691 (ins tGPREven:$Rda_src, MQPR:$Qm), "$Rda = $Rda_src", 692 0b1, VTI.Unsigned, VTI.Size>; 693 def no_acc : MVE_VADDV<"vaddv", VTI.Suffix, 694 (ins MQPR:$Qm), "", 695 0b0, VTI.Unsigned, VTI.Size>; 696 697 defvar InstA = !cast<Instruction>(NAME # "acc"); 698 defvar InstN = !cast<Instruction>(NAME # "no_acc"); 699 700 let Predicates = [HasMVEInt] in { 701 if VTI.Unsigned then { 702 def : Pat<(i32 (vecreduce_add (VTI.Vec MQPR:$vec))), 703 (i32 (InstN $vec))>; 704 def : Pat<(i32 (vecreduce_add (VTI.Vec (vselect (VTI.Pred VCCR:$pred), 705 (VTI.Vec MQPR:$vec), 706 (VTI.Vec ARMimmAllZerosV))))), 707 (i32 (InstN $vec, ARMVCCThen, $pred, zero_reg))>; 708 def : Pat<(i32 (ARMVADDVu (VTI.Vec MQPR:$vec))), 709 (i32 (InstN $vec))>; 710 def : Pat<(i32 (ARMVADDVpu (VTI.Vec MQPR:$vec), (VTI.Pred VCCR:$pred))), 711 (i32 (InstN $vec, ARMVCCThen, $pred, zero_reg))>; 712 def : Pat<(i32 (add (i32 (vecreduce_add (VTI.Vec MQPR:$vec))), 713 (i32 tGPREven:$acc))), 714 (i32 (InstA $acc, $vec))>; 715 def : Pat<(i32 (add (i32 (vecreduce_add (VTI.Vec (vselect (VTI.Pred VCCR:$pred), 716 (VTI.Vec MQPR:$vec), 717 (VTI.Vec ARMimmAllZerosV))))), 718 (i32 tGPREven:$acc))), 719 (i32 (InstA $acc, $vec, ARMVCCThen, $pred, zero_reg))>; 720 def : Pat<(i32 (add (i32 (ARMVADDVu (VTI.Vec MQPR:$vec))), 721 (i32 tGPREven:$acc))), 722 (i32 (InstA $acc, $vec))>; 723 def : Pat<(i32 (add (i32 (ARMVADDVpu (VTI.Vec MQPR:$vec), (VTI.Pred VCCR:$pred))), 724 (i32 tGPREven:$acc))), 725 (i32 (InstA $acc, $vec, ARMVCCThen, $pred, zero_reg))>; 726 } else { 727 def : Pat<(i32 (ARMVADDVs (VTI.Vec MQPR:$vec))), 728 (i32 (InstN $vec))>; 729 def : Pat<(i32 (add (i32 (ARMVADDVs (VTI.Vec MQPR:$vec))), 730 (i32 tGPREven:$acc))), 731 (i32 (InstA $acc, $vec))>; 732 def : Pat<(i32 (ARMVADDVps (VTI.Vec MQPR:$vec), (VTI.Pred VCCR:$pred))), 733 (i32 (InstN $vec, ARMVCCThen, $pred, zero_reg))>; 734 def : Pat<(i32 (add (i32 (ARMVADDVps (VTI.Vec MQPR:$vec), (VTI.Pred VCCR:$pred))), 735 (i32 tGPREven:$acc))), 736 (i32 (InstA $acc, $vec, ARMVCCThen, $pred, zero_reg))>; 737 } 738 739 def : Pat<(i32 (int_arm_mve_addv_predicated (VTI.Vec MQPR:$vec), 740 (i32 VTI.Unsigned), 741 (VTI.Pred VCCR:$pred))), 742 (i32 (InstN $vec, ARMVCCThen, $pred, zero_reg))>; 743 def : Pat<(i32 (add (int_arm_mve_addv_predicated (VTI.Vec MQPR:$vec), 744 (i32 VTI.Unsigned), 745 (VTI.Pred VCCR:$pred)), 746 (i32 tGPREven:$acc))), 747 (i32 (InstA $acc, $vec, ARMVCCThen, $pred, zero_reg))>; 748 } 749} 750 751defm MVE_VADDVs8 : MVE_VADDV_A<MVE_v16s8>; 752defm MVE_VADDVs16 : MVE_VADDV_A<MVE_v8s16>; 753defm MVE_VADDVs32 : MVE_VADDV_A<MVE_v4s32>; 754defm MVE_VADDVu8 : MVE_VADDV_A<MVE_v16u8>; 755defm MVE_VADDVu16 : MVE_VADDV_A<MVE_v8u16>; 756defm MVE_VADDVu32 : MVE_VADDV_A<MVE_v4u32>; 757 758class MVE_VADDLV<string iname, string suffix, dag iops, string cstr, 759 bit A, bit U, list<dag> pattern=[]> 760 : MVE_rDest<(outs tGPREven:$RdaLo, tGPROdd:$RdaHi), iops, NoItinerary, iname, 761 suffix, "$RdaLo, $RdaHi, $Qm", cstr, 0b10, pattern> { 762 bits<3> Qm; 763 bits<4> RdaLo; 764 bits<4> RdaHi; 765 766 let Inst{28} = U; 767 let Inst{22-20} = RdaHi{3-1}; 768 let Inst{19-18} = 0b10; 769 let Inst{17-16} = 0b01; 770 let Inst{15-13} = RdaLo{3-1}; 771 let Inst{12} = 0b0; 772 let Inst{8-6} = 0b100; 773 let Inst{5} = A; 774 let Inst{3-1} = Qm{2-0}; 775 let Inst{0} = 0b0; 776 let horizontalReduction = 1; 777} 778 779def SDTVecReduceL : SDTypeProfile<2, 1, [ // VADDLV 780 SDTCisInt<0>, SDTCisInt<1>, SDTCisVec<2> 781]>; 782def SDTVecReduceLA : SDTypeProfile<2, 3, [ // VADDLVA 783 SDTCisInt<0>, SDTCisInt<1>, SDTCisInt<2>, SDTCisInt<3>, 784 SDTCisVec<4> 785]>; 786def SDTVecReduceLP : SDTypeProfile<2, 2, [ // VADDLVp 787 SDTCisInt<0>, SDTCisInt<1>, SDTCisVec<2>, SDTCisVec<2> 788]>; 789def SDTVecReduceLPA : SDTypeProfile<2, 4, [ // VADDLVAp 790 SDTCisInt<0>, SDTCisInt<1>, SDTCisInt<2>, SDTCisInt<3>, 791 SDTCisVec<4>, SDTCisVec<5> 792]>; 793 794multiclass MVE_VADDLV_A<MVEVectorVTInfo VTI> { 795 def acc : MVE_VADDLV<"vaddlva", VTI.Suffix, 796 (ins tGPREven:$RdaLo_src, tGPROdd:$RdaHi_src, MQPR:$Qm), 797 "$RdaLo = $RdaLo_src,$RdaHi = $RdaHi_src", 798 0b1, VTI.Unsigned>; 799 def no_acc : MVE_VADDLV<"vaddlv", VTI.Suffix, 800 (ins MQPR:$Qm), "", 801 0b0, VTI.Unsigned>; 802 803 defvar InstA = !cast<Instruction>(NAME # "acc"); 804 defvar InstN = !cast<Instruction>(NAME # "no_acc"); 805 806 defvar letter = VTI.SuffixLetter; 807 defvar ARMVADDLV = SDNode<"ARMISD::VADDLV" # letter, SDTVecReduceL>; 808 defvar ARMVADDLVA = SDNode<"ARMISD::VADDLVA" # letter, SDTVecReduceLA>; 809 defvar ARMVADDLVp = SDNode<"ARMISD::VADDLVp" # letter, SDTVecReduceLP>; 810 defvar ARMVADDLVAp = SDNode<"ARMISD::VADDLVAp" # letter, SDTVecReduceLPA>; 811 812 let Predicates = [HasMVEInt] in { 813 def : Pat<(ARMVADDLV (v4i32 MQPR:$vec)), 814 (InstN (v4i32 MQPR:$vec))>; 815 def : Pat<(ARMVADDLVA tGPREven:$acclo, tGPROdd:$acchi, (v4i32 MQPR:$vec)), 816 (InstA tGPREven:$acclo, tGPROdd:$acchi, (v4i32 MQPR:$vec))>; 817 def : Pat<(ARMVADDLVp (v4i32 MQPR:$vec), (VTI.Pred VCCR:$pred)), 818 (InstN (v4i32 MQPR:$vec), ARMVCCThen, (VTI.Pred VCCR:$pred), zero_reg)>; 819 def : Pat<(ARMVADDLVAp tGPREven:$acclo, tGPROdd:$acchi, (v4i32 MQPR:$vec), 820 (VTI.Pred VCCR:$pred)), 821 (InstA tGPREven:$acclo, tGPROdd:$acchi, (v4i32 MQPR:$vec), 822 ARMVCCThen, (VTI.Pred VCCR:$pred), zero_reg)>; 823 } 824} 825 826defm MVE_VADDLVs32 : MVE_VADDLV_A<MVE_v4s32>; 827defm MVE_VADDLVu32 : MVE_VADDLV_A<MVE_v4u32>; 828 829class MVE_VMINMAXNMV<string iname, string suffix, bit sz, 830 bit bit_17, bit bit_7, list<dag> pattern=[]> 831 : MVE_rDest<(outs rGPR:$RdaDest), (ins rGPR:$RdaSrc, MQPR:$Qm), 832 NoItinerary, iname, suffix, "$RdaSrc, $Qm", 833 "$RdaDest = $RdaSrc", !if(sz, 0b01, 0b10), pattern> { 834 bits<3> Qm; 835 bits<4> RdaDest; 836 837 let Inst{28} = sz; 838 let Inst{22-20} = 0b110; 839 let Inst{19-18} = 0b11; 840 let Inst{17} = bit_17; 841 let Inst{16} = 0b0; 842 let Inst{15-12} = RdaDest{3-0}; 843 let Inst{8} = 0b1; 844 let Inst{7} = bit_7; 845 let Inst{6-5} = 0b00; 846 let Inst{3-1} = Qm{2-0}; 847 let Inst{0} = 0b0; 848 let horizontalReduction = 1; 849 850 let Predicates = [HasMVEFloat]; 851 let hasSideEffects = 0; 852} 853 854multiclass MVE_VMINMAXNMV_p<string iname, bit notAbs, bit isMin, 855 MVEVectorVTInfo VTI, string intrBaseName, 856 ValueType Scalar, RegisterClass ScalarReg> { 857 def "": MVE_VMINMAXNMV<iname, VTI.Suffix, VTI.Size{0}, notAbs, isMin>; 858 defvar Inst = !cast<Instruction>(NAME); 859 defvar unpred_intr = !cast<Intrinsic>(intrBaseName); 860 defvar pred_intr = !cast<Intrinsic>(intrBaseName#"_predicated"); 861 862 let Predicates = [HasMVEFloat] in { 863 def : Pat<(Scalar (unpred_intr (Scalar ScalarReg:$prev), 864 (VTI.Vec MQPR:$vec))), 865 (COPY_TO_REGCLASS (Inst (COPY_TO_REGCLASS ScalarReg:$prev, rGPR), 866 (VTI.Vec MQPR:$vec)), 867 ScalarReg)>; 868 def : Pat<(Scalar (pred_intr (Scalar ScalarReg:$prev), 869 (VTI.Vec MQPR:$vec), 870 (VTI.Pred VCCR:$pred))), 871 (COPY_TO_REGCLASS (Inst (COPY_TO_REGCLASS ScalarReg:$prev, rGPR), 872 (VTI.Vec MQPR:$vec), 873 ARMVCCThen, (VTI.Pred VCCR:$pred), zero_reg), 874 ScalarReg)>; 875 } 876} 877 878multiclass MVE_VMINMAXNMV_fty<string iname, bit notAbs, bit isMin, 879 string intrBase> { 880 defm f32 : MVE_VMINMAXNMV_p<iname, notAbs, isMin, MVE_v4f32, intrBase, 881 f32, SPR>; 882 defm f16 : MVE_VMINMAXNMV_p<iname, notAbs, isMin, MVE_v8f16, intrBase, 883 f16, HPR>; 884} 885 886defm MVE_VMINNMV : MVE_VMINMAXNMV_fty<"vminnmv", 1, 1, "int_arm_mve_minnmv">; 887defm MVE_VMAXNMV : MVE_VMINMAXNMV_fty<"vmaxnmv", 1, 0, "int_arm_mve_maxnmv">; 888defm MVE_VMINNMAV: MVE_VMINMAXNMV_fty<"vminnmav", 0, 1, "int_arm_mve_minnmav">; 889defm MVE_VMAXNMAV: MVE_VMINMAXNMV_fty<"vmaxnmav", 0, 0, "int_arm_mve_maxnmav">; 890 891class MVE_VMINMAXV<string iname, string suffix, bit U, bits<2> size, 892 bit bit_17, bit bit_7, list<dag> pattern=[]> 893 : MVE_rDest<(outs rGPR:$RdaDest), (ins rGPR:$RdaSrc, MQPR:$Qm), NoItinerary, 894 iname, suffix, "$RdaSrc, $Qm", "$RdaDest = $RdaSrc", size, pattern> { 895 bits<3> Qm; 896 bits<4> RdaDest; 897 898 let Inst{28} = U; 899 let Inst{22-20} = 0b110; 900 let Inst{19-18} = size{1-0}; 901 let Inst{17} = bit_17; 902 let Inst{16} = 0b0; 903 let Inst{15-12} = RdaDest{3-0}; 904 let Inst{8} = 0b1; 905 let Inst{7} = bit_7; 906 let Inst{6-5} = 0b00; 907 let Inst{3-1} = Qm{2-0}; 908 let Inst{0} = 0b0; 909 let horizontalReduction = 1; 910} 911 912multiclass MVE_VMINMAXV_p<string iname, bit notAbs, bit isMin, 913 MVEVectorVTInfo VTI, string intrBaseName> { 914 def "": MVE_VMINMAXV<iname, VTI.Suffix, VTI.Unsigned, VTI.Size, 915 notAbs, isMin>; 916 defvar Inst = !cast<Instruction>(NAME); 917 defvar unpred_intr = !cast<Intrinsic>(intrBaseName); 918 defvar pred_intr = !cast<Intrinsic>(intrBaseName#"_predicated"); 919 defvar base_args = (? (i32 rGPR:$prev), (VTI.Vec MQPR:$vec)); 920 defvar args = !if(notAbs, !con(base_args, (? (i32 VTI.Unsigned))), 921 base_args); 922 923 let Predicates = [HasMVEInt] in { 924 def : Pat<(i32 !con(args, (unpred_intr))), 925 (i32 (Inst (i32 rGPR:$prev), (VTI.Vec MQPR:$vec)))>; 926 def : Pat<(i32 !con(args, (pred_intr (VTI.Pred VCCR:$pred)))), 927 (i32 (Inst (i32 rGPR:$prev), (VTI.Vec MQPR:$vec), 928 ARMVCCThen, (VTI.Pred VCCR:$pred), zero_reg))>; 929 } 930} 931 932multiclass MVE_VMINMAXV_ty<string iname, bit isMin, string intrBaseName> { 933 defm s8 : MVE_VMINMAXV_p<iname, 1, isMin, MVE_v16s8, intrBaseName>; 934 defm s16: MVE_VMINMAXV_p<iname, 1, isMin, MVE_v8s16, intrBaseName>; 935 defm s32: MVE_VMINMAXV_p<iname, 1, isMin, MVE_v4s32, intrBaseName>; 936 defm u8 : MVE_VMINMAXV_p<iname, 1, isMin, MVE_v16u8, intrBaseName>; 937 defm u16: MVE_VMINMAXV_p<iname, 1, isMin, MVE_v8u16, intrBaseName>; 938 defm u32: MVE_VMINMAXV_p<iname, 1, isMin, MVE_v4u32, intrBaseName>; 939} 940 941def SDTVecReduceR : SDTypeProfile<1, 2, [ // Reduction of an integer and vector into an integer 942 SDTCisInt<0>, SDTCisInt<1>, SDTCisVec<2> 943]>; 944def ARMVMINVu : SDNode<"ARMISD::VMINVu", SDTVecReduceR>; 945def ARMVMINVs : SDNode<"ARMISD::VMINVs", SDTVecReduceR>; 946def ARMVMAXVu : SDNode<"ARMISD::VMAXVu", SDTVecReduceR>; 947def ARMVMAXVs : SDNode<"ARMISD::VMAXVs", SDTVecReduceR>; 948 949defm MVE_VMINV : MVE_VMINMAXV_ty<"vminv", 1, "int_arm_mve_minv">; 950defm MVE_VMAXV : MVE_VMINMAXV_ty<"vmaxv", 0, "int_arm_mve_maxv">; 951 952let Predicates = [HasMVEInt] in { 953 def : Pat<(i32 (vecreduce_smax (v16i8 MQPR:$src))), 954 (i32 (MVE_VMAXVs8 (t2MVNi (i32 127)), $src))>; 955 def : Pat<(i32 (vecreduce_smax (v8i16 MQPR:$src))), 956 (i32 (MVE_VMAXVs16 (t2MOVi32imm (i32 -32768)), $src))>; 957 def : Pat<(i32 (vecreduce_smax (v4i32 MQPR:$src))), 958 (i32 (MVE_VMAXVs32 (t2MOVi (i32 -2147483648)), $src))>; 959 def : Pat<(i32 (vecreduce_umax (v16i8 MQPR:$src))), 960 (i32 (MVE_VMAXVu8 (t2MOVi (i32 0)), $src))>; 961 def : Pat<(i32 (vecreduce_umax (v8i16 MQPR:$src))), 962 (i32 (MVE_VMAXVu16 (t2MOVi (i32 0)), $src))>; 963 def : Pat<(i32 (vecreduce_umax (v4i32 MQPR:$src))), 964 (i32 (MVE_VMAXVu32 (t2MOVi (i32 0)), $src))>; 965 966 def : Pat<(i32 (vecreduce_smin (v16i8 MQPR:$src))), 967 (i32 (MVE_VMINVs8 (t2MOVi (i32 127)), $src))>; 968 def : Pat<(i32 (vecreduce_smin (v8i16 MQPR:$src))), 969 (i32 (MVE_VMINVs16 (t2MOVi16 (i32 32767)), $src))>; 970 def : Pat<(i32 (vecreduce_smin (v4i32 MQPR:$src))), 971 (i32 (MVE_VMINVs32 (t2MVNi (i32 -2147483648)), $src))>; 972 def : Pat<(i32 (vecreduce_umin (v16i8 MQPR:$src))), 973 (i32 (MVE_VMINVu8 (t2MOVi (i32 255)), $src))>; 974 def : Pat<(i32 (vecreduce_umin (v8i16 MQPR:$src))), 975 (i32 (MVE_VMINVu16 (t2MOVi16 (i32 65535)), $src))>; 976 def : Pat<(i32 (vecreduce_umin (v4i32 MQPR:$src))), 977 (i32 (MVE_VMINVu32 (t2MOVi (i32 4294967295)), $src))>; 978 979 def : Pat<(i32 (ARMVMINVu (i32 rGPR:$x), (v16i8 MQPR:$src))), 980 (i32 (MVE_VMINVu8 $x, $src))>; 981 def : Pat<(i32 (ARMVMINVu (i32 rGPR:$x), (v8i16 MQPR:$src))), 982 (i32 (MVE_VMINVu16 $x, $src))>; 983 def : Pat<(i32 (ARMVMINVu (i32 rGPR:$x), (v4i32 MQPR:$src))), 984 (i32 (MVE_VMINVu32 $x, $src))>; 985 def : Pat<(i32 (ARMVMINVs (i32 rGPR:$x), (v16i8 MQPR:$src))), 986 (i32 (MVE_VMINVs8 $x, $src))>; 987 def : Pat<(i32 (ARMVMINVs (i32 rGPR:$x), (v8i16 MQPR:$src))), 988 (i32 (MVE_VMINVs16 $x, $src))>; 989 def : Pat<(i32 (ARMVMINVs (i32 rGPR:$x), (v4i32 MQPR:$src))), 990 (i32 (MVE_VMINVs32 $x, $src))>; 991 992 def : Pat<(i32 (ARMVMAXVu (i32 rGPR:$x), (v16i8 MQPR:$src))), 993 (i32 (MVE_VMAXVu8 $x, $src))>; 994 def : Pat<(i32 (ARMVMAXVu (i32 rGPR:$x), (v8i16 MQPR:$src))), 995 (i32 (MVE_VMAXVu16 $x, $src))>; 996 def : Pat<(i32 (ARMVMAXVu (i32 rGPR:$x), (v4i32 MQPR:$src))), 997 (i32 (MVE_VMAXVu32 $x, $src))>; 998 def : Pat<(i32 (ARMVMAXVs (i32 rGPR:$x), (v16i8 MQPR:$src))), 999 (i32 (MVE_VMAXVs8 $x, $src))>; 1000 def : Pat<(i32 (ARMVMAXVs (i32 rGPR:$x), (v8i16 MQPR:$src))), 1001 (i32 (MVE_VMAXVs16 $x, $src))>; 1002 def : Pat<(i32 (ARMVMAXVs (i32 rGPR:$x), (v4i32 MQPR:$src))), 1003 (i32 (MVE_VMAXVs32 $x, $src))>; 1004 1005} 1006 1007multiclass MVE_VMINMAXAV_ty<string iname, bit isMin, string intrBaseName> { 1008 defm s8 : MVE_VMINMAXV_p<iname, 0, isMin, MVE_v16s8, intrBaseName>; 1009 defm s16: MVE_VMINMAXV_p<iname, 0, isMin, MVE_v8s16, intrBaseName>; 1010 defm s32: MVE_VMINMAXV_p<iname, 0, isMin, MVE_v4s32, intrBaseName>; 1011} 1012 1013defm MVE_VMINAV : MVE_VMINMAXAV_ty<"vminav", 1, "int_arm_mve_minav">; 1014defm MVE_VMAXAV : MVE_VMINMAXAV_ty<"vmaxav", 0, "int_arm_mve_maxav">; 1015 1016class MVE_VMLAMLSDAV<string iname, string suffix, dag iops, string cstr, 1017 bit sz, bit bit_28, bit A, bit X, bit bit_8, bit bit_0, 1018 bits<2> vecsize> 1019 : MVE_rDest<(outs tGPREven:$RdaDest), iops, NoItinerary, iname, suffix, 1020 "$RdaDest, $Qn, $Qm", cstr, vecsize, []> { 1021 bits<4> RdaDest; 1022 bits<3> Qm; 1023 bits<3> Qn; 1024 1025 let Inst{28} = bit_28; 1026 let Inst{22-20} = 0b111; 1027 let Inst{19-17} = Qn{2-0}; 1028 let Inst{16} = sz; 1029 let Inst{15-13} = RdaDest{3-1}; 1030 let Inst{12} = X; 1031 let Inst{8} = bit_8; 1032 let Inst{7-6} = 0b00; 1033 let Inst{5} = A; 1034 let Inst{3-1} = Qm{2-0}; 1035 let Inst{0} = bit_0; 1036 let horizontalReduction = 1; 1037 // Allow tail predication for non-exchanging versions. As this is also a 1038 // horizontalReduction, ARMLowOverheadLoops will also have to check that 1039 // the vector operands contain zeros in their false lanes for the instruction 1040 // to be properly valid. 1041 let validForTailPredication = !eq(X, 0); 1042} 1043 1044multiclass MVE_VMLAMLSDAV_A<string iname, string x, MVEVectorVTInfo VTI, 1045 bit sz, bit bit_28, bit X, bit bit_8, bit bit_0> { 1046 def ""#x#VTI.Suffix : MVE_VMLAMLSDAV<iname # x, VTI.Suffix, 1047 (ins MQPR:$Qn, MQPR:$Qm), "", 1048 sz, bit_28, 0b0, X, bit_8, bit_0, VTI.Size>; 1049 def "a"#x#VTI.Suffix : MVE_VMLAMLSDAV<iname # "a" # x, VTI.Suffix, 1050 (ins tGPREven:$RdaSrc, MQPR:$Qn, MQPR:$Qm), 1051 "$RdaDest = $RdaSrc", 1052 sz, bit_28, 0b1, X, bit_8, bit_0, VTI.Size>; 1053 let Predicates = [HasMVEInt] in { 1054 def : Pat<(i32 (int_arm_mve_vmldava 1055 (i32 VTI.Unsigned), 1056 (i32 bit_0) /* subtract */, 1057 (i32 X) /* exchange */, 1058 (i32 0) /* accumulator */, 1059 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))), 1060 (i32 (!cast<Instruction>(NAME # x # VTI.Suffix) 1061 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm)))>; 1062 1063 def : Pat<(i32 (int_arm_mve_vmldava_predicated 1064 (i32 VTI.Unsigned), 1065 (i32 bit_0) /* subtract */, 1066 (i32 X) /* exchange */, 1067 (i32 0) /* accumulator */, 1068 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 1069 (VTI.Pred VCCR:$mask))), 1070 (i32 (!cast<Instruction>(NAME # x # VTI.Suffix) 1071 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 1072 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>; 1073 1074 def : Pat<(i32 (int_arm_mve_vmldava 1075 (i32 VTI.Unsigned), 1076 (i32 bit_0) /* subtract */, 1077 (i32 X) /* exchange */, 1078 (i32 tGPREven:$RdaSrc), 1079 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))), 1080 (i32 (!cast<Instruction>(NAME # "a" # x # VTI.Suffix) 1081 (i32 tGPREven:$RdaSrc), 1082 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm)))>; 1083 1084 def : Pat<(i32 (int_arm_mve_vmldava_predicated 1085 (i32 VTI.Unsigned), 1086 (i32 bit_0) /* subtract */, 1087 (i32 X) /* exchange */, 1088 (i32 tGPREven:$RdaSrc), 1089 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 1090 (VTI.Pred VCCR:$mask))), 1091 (i32 (!cast<Instruction>(NAME # "a" # x # VTI.Suffix) 1092 (i32 tGPREven:$RdaSrc), 1093 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 1094 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>; 1095 } 1096} 1097 1098multiclass MVE_VMLAMLSDAV_AX<string iname, MVEVectorVTInfo VTI, bit sz, 1099 bit bit_28, bit bit_8, bit bit_0> { 1100 defm "" : MVE_VMLAMLSDAV_A<iname, "", VTI, sz, bit_28, 1101 0b0, bit_8, bit_0>; 1102 defm "" : MVE_VMLAMLSDAV_A<iname, "x", VTI, sz, bit_28, 1103 0b1, bit_8, bit_0>; 1104} 1105 1106multiclass MVE_VMLADAV_multi<MVEVectorVTInfo SVTI, MVEVectorVTInfo UVTI, 1107 bit sz, bit bit_8> { 1108 defm "" : MVE_VMLAMLSDAV_AX<"vmladav", SVTI, 1109 sz, 0b0, bit_8, 0b0>; 1110 defm "" : MVE_VMLAMLSDAV_A<"vmladav", "", UVTI, 1111 sz, 0b1, 0b0, bit_8, 0b0>; 1112} 1113 1114multiclass MVE_VMLSDAV_multi<MVEVectorVTInfo VTI, bit sz, bit bit_28> { 1115 defm "" : MVE_VMLAMLSDAV_AX<"vmlsdav", VTI, 1116 sz, bit_28, 0b0, 0b1>; 1117} 1118 1119defm MVE_VMLADAV : MVE_VMLADAV_multi<MVE_v16s8, MVE_v16u8, 0b0, 0b1>; 1120defm MVE_VMLADAV : MVE_VMLADAV_multi<MVE_v8s16, MVE_v8u16, 0b0, 0b0>; 1121defm MVE_VMLADAV : MVE_VMLADAV_multi<MVE_v4s32, MVE_v4u32, 0b1, 0b0>; 1122 1123defm MVE_VMLSDAV : MVE_VMLSDAV_multi<MVE_v16s8, 0b0, 0b1>; 1124defm MVE_VMLSDAV : MVE_VMLSDAV_multi<MVE_v8s16, 0b0, 0b0>; 1125defm MVE_VMLSDAV : MVE_VMLSDAV_multi<MVE_v4s32, 0b1, 0b0>; 1126 1127def SDTVecReduce2 : SDTypeProfile<1, 2, [ // VMLAV 1128 SDTCisInt<0>, SDTCisVec<1>, SDTCisVec<2> 1129]>; 1130def SDTVecReduce2L : SDTypeProfile<2, 2, [ // VMLALV 1131 SDTCisInt<0>, SDTCisInt<1>, SDTCisVec<2>, SDTCisVec<3> 1132]>; 1133def SDTVecReduce2LA : SDTypeProfile<2, 4, [ // VMLALVA 1134 SDTCisInt<0>, SDTCisInt<1>, SDTCisInt<2>, SDTCisInt<3>, 1135 SDTCisVec<4>, SDTCisVec<5> 1136]>; 1137def SDTVecReduce2P : SDTypeProfile<1, 3, [ // VMLAV 1138 SDTCisInt<0>, SDTCisVec<1>, SDTCisVec<2>, SDTCisVec<3> 1139]>; 1140def SDTVecReduce2LP : SDTypeProfile<2, 3, [ // VMLALV 1141 SDTCisInt<0>, SDTCisInt<1>, SDTCisVec<2>, SDTCisVec<3>, SDTCisVec<4> 1142]>; 1143def SDTVecReduce2LAP : SDTypeProfile<2, 5, [ // VMLALVA 1144 SDTCisInt<0>, SDTCisInt<1>, SDTCisInt<2>, SDTCisInt<3>, 1145 SDTCisVec<4>, SDTCisVec<5>, SDTCisVec<6> 1146]>; 1147def ARMVMLAVs : SDNode<"ARMISD::VMLAVs", SDTVecReduce2>; 1148def ARMVMLAVu : SDNode<"ARMISD::VMLAVu", SDTVecReduce2>; 1149def ARMVMLALVs : SDNode<"ARMISD::VMLALVs", SDTVecReduce2L>; 1150def ARMVMLALVu : SDNode<"ARMISD::VMLALVu", SDTVecReduce2L>; 1151def ARMVMLALVAs : SDNode<"ARMISD::VMLALVAs", SDTVecReduce2LA>; 1152def ARMVMLALVAu : SDNode<"ARMISD::VMLALVAu", SDTVecReduce2LA>; 1153def ARMVMLAVps : SDNode<"ARMISD::VMLAVps", SDTVecReduce2P>; 1154def ARMVMLAVpu : SDNode<"ARMISD::VMLAVpu", SDTVecReduce2P>; 1155def ARMVMLALVps : SDNode<"ARMISD::VMLALVps", SDTVecReduce2LP>; 1156def ARMVMLALVpu : SDNode<"ARMISD::VMLALVpu", SDTVecReduce2LP>; 1157def ARMVMLALVAps : SDNode<"ARMISD::VMLALVAps", SDTVecReduce2LAP>; 1158def ARMVMLALVApu : SDNode<"ARMISD::VMLALVApu", SDTVecReduce2LAP>; 1159 1160let Predicates = [HasMVEInt] in { 1161 def : Pat<(i32 (vecreduce_add (mul (v4i32 MQPR:$src1), (v4i32 MQPR:$src2)))), 1162 (i32 (MVE_VMLADAVu32 $src1, $src2))>; 1163 def : Pat<(i32 (vecreduce_add (mul (v8i16 MQPR:$src1), (v8i16 MQPR:$src2)))), 1164 (i32 (MVE_VMLADAVu16 $src1, $src2))>; 1165 def : Pat<(i32 (ARMVMLAVs (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))), 1166 (i32 (MVE_VMLADAVs16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>; 1167 def : Pat<(i32 (ARMVMLAVu (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))), 1168 (i32 (MVE_VMLADAVu16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>; 1169 def : Pat<(i32 (vecreduce_add (mul (v16i8 MQPR:$src1), (v16i8 MQPR:$src2)))), 1170 (i32 (MVE_VMLADAVu8 $src1, $src2))>; 1171 def : Pat<(i32 (ARMVMLAVs (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))), 1172 (i32 (MVE_VMLADAVs8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>; 1173 def : Pat<(i32 (ARMVMLAVu (v16i8 MQPR:$val1), (v16i8 MQPR:$val2))), 1174 (i32 (MVE_VMLADAVu8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>; 1175 1176 def : Pat<(i32 (add (i32 (vecreduce_add (mul (v4i32 MQPR:$src1), (v4i32 MQPR:$src2)))), 1177 (i32 tGPREven:$src3))), 1178 (i32 (MVE_VMLADAVau32 $src3, $src1, $src2))>; 1179 def : Pat<(i32 (add (i32 (vecreduce_add (mul (v8i16 MQPR:$src1), (v8i16 MQPR:$src2)))), 1180 (i32 tGPREven:$src3))), 1181 (i32 (MVE_VMLADAVau16 $src3, $src1, $src2))>; 1182 def : Pat<(i32 (add (ARMVMLAVs (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)), tGPREven:$Rd)), 1183 (i32 (MVE_VMLADAVas16 tGPREven:$Rd, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>; 1184 def : Pat<(i32 (add (ARMVMLAVu (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)), tGPREven:$Rd)), 1185 (i32 (MVE_VMLADAVau16 tGPREven:$Rd, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)))>; 1186 def : Pat<(i32 (add (i32 (vecreduce_add (mul (v16i8 MQPR:$src1), (v16i8 MQPR:$src2)))), 1187 (i32 tGPREven:$src3))), 1188 (i32 (MVE_VMLADAVau8 $src3, $src1, $src2))>; 1189 def : Pat<(i32 (add (ARMVMLAVs (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)), tGPREven:$Rd)), 1190 (i32 (MVE_VMLADAVas8 tGPREven:$Rd, (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>; 1191 def : Pat<(i32 (add (ARMVMLAVu (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)), tGPREven:$Rd)), 1192 (i32 (MVE_VMLADAVau8 tGPREven:$Rd, (v16i8 MQPR:$val1), (v16i8 MQPR:$val2)))>; 1193 1194 // Predicated 1195 def : Pat<(i32 (vecreduce_add (vselect (v4i1 VCCR:$pred), 1196 (mul (v4i32 MQPR:$src1), (v4i32 MQPR:$src2)), 1197 (v4i32 ARMimmAllZerosV)))), 1198 (i32 (MVE_VMLADAVu32 $src1, $src2, ARMVCCThen, $pred, zero_reg))>; 1199 def : Pat<(i32 (vecreduce_add (vselect (v8i1 VCCR:$pred), 1200 (mul (v8i16 MQPR:$src1), (v8i16 MQPR:$src2)), 1201 (v8i16 ARMimmAllZerosV)))), 1202 (i32 (MVE_VMLADAVu16 $src1, $src2, ARMVCCThen, $pred, zero_reg))>; 1203 def : Pat<(i32 (ARMVMLAVps (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), (v8i1 VCCR:$pred))), 1204 (i32 (MVE_VMLADAVs16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), ARMVCCThen, $pred, zero_reg))>; 1205 def : Pat<(i32 (ARMVMLAVpu (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), (v8i1 VCCR:$pred))), 1206 (i32 (MVE_VMLADAVu16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), ARMVCCThen, $pred, zero_reg))>; 1207 def : Pat<(i32 (vecreduce_add (vselect (v16i1 VCCR:$pred), 1208 (mul (v16i8 MQPR:$src1), (v16i8 MQPR:$src2)), 1209 (v16i8 ARMimmAllZerosV)))), 1210 (i32 (MVE_VMLADAVu8 $src1, $src2, ARMVCCThen, $pred, zero_reg))>; 1211 def : Pat<(i32 (ARMVMLAVps (v16i8 MQPR:$val1), (v16i8 MQPR:$val2), (v16i1 VCCR:$pred))), 1212 (i32 (MVE_VMLADAVs8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2), ARMVCCThen, $pred, zero_reg))>; 1213 def : Pat<(i32 (ARMVMLAVpu (v16i8 MQPR:$val1), (v16i8 MQPR:$val2), (v16i1 VCCR:$pred))), 1214 (i32 (MVE_VMLADAVu8 (v16i8 MQPR:$val1), (v16i8 MQPR:$val2), ARMVCCThen, $pred, zero_reg))>; 1215 1216 def : Pat<(i32 (add (i32 (vecreduce_add (vselect (v4i1 VCCR:$pred), 1217 (mul (v4i32 MQPR:$src1), (v4i32 MQPR:$src2)), 1218 (v4i32 ARMimmAllZerosV)))), 1219 (i32 tGPREven:$src3))), 1220 (i32 (MVE_VMLADAVau32 $src3, $src1, $src2, ARMVCCThen, $pred, zero_reg))>; 1221 def : Pat<(i32 (add (i32 (vecreduce_add (vselect (v8i1 VCCR:$pred), 1222 (mul (v8i16 MQPR:$src1), (v8i16 MQPR:$src2)), 1223 (v8i16 ARMimmAllZerosV)))), 1224 (i32 tGPREven:$src3))), 1225 (i32 (MVE_VMLADAVau16 $src3, $src1, $src2, ARMVCCThen, $pred, zero_reg))>; 1226 def : Pat<(i32 (add (ARMVMLAVps (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), (v8i1 VCCR:$pred)), tGPREven:$Rd)), 1227 (i32 (MVE_VMLADAVas16 tGPREven:$Rd, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), ARMVCCThen, $pred, zero_reg))>; 1228 def : Pat<(i32 (add (ARMVMLAVpu (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), (v8i1 VCCR:$pred)), tGPREven:$Rd)), 1229 (i32 (MVE_VMLADAVau16 tGPREven:$Rd, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), ARMVCCThen, $pred, zero_reg))>; 1230 def : Pat<(i32 (add (i32 (vecreduce_add (vselect (v16i1 VCCR:$pred), 1231 (mul (v16i8 MQPR:$src1), (v16i8 MQPR:$src2)), 1232 (v16i8 ARMimmAllZerosV)))), 1233 (i32 tGPREven:$src3))), 1234 (i32 (MVE_VMLADAVau8 $src3, $src1, $src2, ARMVCCThen, $pred, zero_reg))>; 1235 def : Pat<(i32 (add (ARMVMLAVps (v16i8 MQPR:$val1), (v16i8 MQPR:$val2), (v16i1 VCCR:$pred)), tGPREven:$Rd)), 1236 (i32 (MVE_VMLADAVas8 tGPREven:$Rd, (v16i8 MQPR:$val1), (v16i8 MQPR:$val2), ARMVCCThen, $pred, zero_reg))>; 1237 def : Pat<(i32 (add (ARMVMLAVpu (v16i8 MQPR:$val1), (v16i8 MQPR:$val2), (v16i1 VCCR:$pred)), tGPREven:$Rd)), 1238 (i32 (MVE_VMLADAVau8 tGPREven:$Rd, (v16i8 MQPR:$val1), (v16i8 MQPR:$val2), ARMVCCThen, $pred, zero_reg))>; 1239} 1240 1241// vmlav aliases vmladav 1242foreach acc = ["", "a"] in { 1243 foreach suffix = ["s8", "s16", "s32", "u8", "u16", "u32"] in { 1244 def : MVEInstAlias<"vmlav"#acc#"${vp}."#suffix#"\t$RdaDest, $Qn, $Qm", 1245 (!cast<Instruction>("MVE_VMLADAV"#acc#suffix) 1246 tGPREven:$RdaDest, MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>; 1247 } 1248} 1249 1250// Base class for VMLALDAV and VMLSLDAV, VRMLALDAVH, VRMLSLDAVH 1251class MVE_VMLALDAVBase<string iname, string suffix, dag iops, string cstr, 1252 bit sz, bit bit_28, bit A, bit X, bit bit_8, bit bit_0, 1253 bits<2> vecsize, list<dag> pattern=[]> 1254 : MVE_rDest<(outs tGPREven:$RdaLoDest, tGPROdd:$RdaHiDest), iops, NoItinerary, 1255 iname, suffix, "$RdaLoDest, $RdaHiDest, $Qn, $Qm", cstr, vecsize, pattern> { 1256 bits<4> RdaLoDest; 1257 bits<4> RdaHiDest; 1258 bits<3> Qm; 1259 bits<3> Qn; 1260 1261 let Inst{28} = bit_28; 1262 let Inst{22-20} = RdaHiDest{3-1}; 1263 let Inst{19-17} = Qn{2-0}; 1264 let Inst{16} = sz; 1265 let Inst{15-13} = RdaLoDest{3-1}; 1266 let Inst{12} = X; 1267 let Inst{8} = bit_8; 1268 let Inst{7-6} = 0b00; 1269 let Inst{5} = A; 1270 let Inst{3-1} = Qm{2-0}; 1271 let Inst{0} = bit_0; 1272 let horizontalReduction = 1; 1273 // Allow tail predication for non-exchanging versions. As this is also a 1274 // horizontalReduction, ARMLowOverheadLoops will also have to check that 1275 // the vector operands contain zeros in their false lanes for the instruction 1276 // to be properly valid. 1277 let validForTailPredication = !eq(X, 0); 1278 1279 let hasSideEffects = 0; 1280} 1281 1282multiclass MVE_VMLALDAVBase_A<string iname, string x, string suffix, 1283 bit sz, bit bit_28, bit X, bit bit_8, bit bit_0, 1284 bits<2> vecsize, list<dag> pattern=[]> { 1285 def ""#x#suffix : MVE_VMLALDAVBase< 1286 iname # x, suffix, (ins MQPR:$Qn, MQPR:$Qm), "", 1287 sz, bit_28, 0b0, X, bit_8, bit_0, vecsize, pattern>; 1288 def "a"#x#suffix : MVE_VMLALDAVBase< 1289 iname # "a" # x, suffix, 1290 (ins tGPREven:$RdaLoSrc, tGPROdd:$RdaHiSrc, MQPR:$Qn, MQPR:$Qm), 1291 "$RdaLoDest = $RdaLoSrc,$RdaHiDest = $RdaHiSrc", 1292 sz, bit_28, 0b1, X, bit_8, bit_0, vecsize, pattern>; 1293} 1294 1295 1296multiclass MVE_VMLALDAVBase_AX<string iname, string suffix, bit sz, bit bit_28, 1297 bit bit_8, bit bit_0, bits<2> vecsize, list<dag> pattern=[]> { 1298 defm "" : MVE_VMLALDAVBase_A<iname, "", suffix, sz, 1299 bit_28, 0b0, bit_8, bit_0, vecsize, pattern>; 1300 defm "" : MVE_VMLALDAVBase_A<iname, "x", suffix, sz, 1301 bit_28, 0b1, bit_8, bit_0, vecsize, pattern>; 1302} 1303 1304multiclass MVE_VRMLALDAVH_multi<MVEVectorVTInfo VTI, list<dag> pattern=[]> { 1305 defm "" : MVE_VMLALDAVBase_AX<"vrmlaldavh", "s"#VTI.BitsSuffix, 1306 0b0, 0b0, 0b1, 0b0, VTI.Size, pattern>; 1307 defm "" : MVE_VMLALDAVBase_A<"vrmlaldavh", "", "u"#VTI.BitsSuffix, 1308 0b0, 0b1, 0b0, 0b1, 0b0, VTI.Size, pattern>; 1309} 1310 1311defm MVE_VRMLALDAVH : MVE_VRMLALDAVH_multi<MVE_v4i32>; 1312 1313// vrmlalvh aliases for vrmlaldavh 1314def : MVEInstAlias<"vrmlalvh${vp}.s32\t$RdaLo, $RdaHi, $Qn, $Qm", 1315 (MVE_VRMLALDAVHs32 1316 tGPREven:$RdaLo, tGPROdd:$RdaHi, 1317 MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>; 1318def : MVEInstAlias<"vrmlalvha${vp}.s32\t$RdaLo, $RdaHi, $Qn, $Qm", 1319 (MVE_VRMLALDAVHas32 1320 tGPREven:$RdaLo, tGPROdd:$RdaHi, 1321 MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>; 1322def : MVEInstAlias<"vrmlalvh${vp}.u32\t$RdaLo, $RdaHi, $Qn, $Qm", 1323 (MVE_VRMLALDAVHu32 1324 tGPREven:$RdaLo, tGPROdd:$RdaHi, 1325 MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>; 1326def : MVEInstAlias<"vrmlalvha${vp}.u32\t$RdaLo, $RdaHi, $Qn, $Qm", 1327 (MVE_VRMLALDAVHau32 1328 tGPREven:$RdaLo, tGPROdd:$RdaHi, 1329 MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>; 1330 1331multiclass MVE_VMLALDAV_multi<MVEVectorVTInfo VTI, list<dag> pattern=[]> { 1332 defm "" : MVE_VMLALDAVBase_AX<"vmlaldav", "s"#VTI.BitsSuffix, 1333 VTI.Size{1}, 0b0, 0b0, 0b0, VTI.Size, pattern>; 1334 defm "" : MVE_VMLALDAVBase_A<"vmlaldav", "", "u"#VTI.BitsSuffix, 1335 VTI.Size{1}, 0b1, 0b0, 0b0, 0b0, VTI.Size, pattern>; 1336} 1337 1338defm MVE_VMLALDAV : MVE_VMLALDAV_multi<MVE_v8i16>; 1339defm MVE_VMLALDAV : MVE_VMLALDAV_multi<MVE_v4i32>; 1340 1341let Predicates = [HasMVEInt] in { 1342 def : Pat<(ARMVMLALVs (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)), 1343 (MVE_VMLALDAVs32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))>; 1344 def : Pat<(ARMVMLALVu (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)), 1345 (MVE_VMLALDAVu32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))>; 1346 def : Pat<(ARMVMLALVs (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)), 1347 (MVE_VMLALDAVs16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))>; 1348 def : Pat<(ARMVMLALVu (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)), 1349 (MVE_VMLALDAVu16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))>; 1350 1351 def : Pat<(ARMVMLALVAs tGPREven:$Rda, tGPROdd:$Rdb, (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)), 1352 (MVE_VMLALDAVas32 tGPREven:$Rda, tGPROdd:$Rdb, (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))>; 1353 def : Pat<(ARMVMLALVAu tGPREven:$Rda, tGPROdd:$Rdb, (v4i32 MQPR:$val1), (v4i32 MQPR:$val2)), 1354 (MVE_VMLALDAVau32 tGPREven:$Rda, tGPROdd:$Rdb, (v4i32 MQPR:$val1), (v4i32 MQPR:$val2))>; 1355 def : Pat<(ARMVMLALVAs tGPREven:$Rda, tGPROdd:$Rdb, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)), 1356 (MVE_VMLALDAVas16 tGPREven:$Rda, tGPROdd:$Rdb, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))>; 1357 def : Pat<(ARMVMLALVAu tGPREven:$Rda, tGPROdd:$Rdb, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2)), 1358 (MVE_VMLALDAVau16 tGPREven:$Rda, tGPROdd:$Rdb, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2))>; 1359 1360 // Predicated 1361 def : Pat<(ARMVMLALVps (v4i32 MQPR:$val1), (v4i32 MQPR:$val2), (v4i1 VCCR:$pred)), 1362 (MVE_VMLALDAVs32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2), ARMVCCThen, $pred, zero_reg)>; 1363 def : Pat<(ARMVMLALVpu (v4i32 MQPR:$val1), (v4i32 MQPR:$val2), (v4i1 VCCR:$pred)), 1364 (MVE_VMLALDAVu32 (v4i32 MQPR:$val1), (v4i32 MQPR:$val2), ARMVCCThen, $pred, zero_reg)>; 1365 def : Pat<(ARMVMLALVps (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), (v8i1 VCCR:$pred)), 1366 (MVE_VMLALDAVs16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), ARMVCCThen, $pred, zero_reg)>; 1367 def : Pat<(ARMVMLALVpu (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), (v8i1 VCCR:$pred)), 1368 (MVE_VMLALDAVu16 (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), ARMVCCThen, $pred, zero_reg)>; 1369 1370 def : Pat<(ARMVMLALVAps tGPREven:$Rda, tGPROdd:$Rdb, (v4i32 MQPR:$val1), (v4i32 MQPR:$val2), (v4i1 VCCR:$pred)), 1371 (MVE_VMLALDAVas32 tGPREven:$Rda, tGPROdd:$Rdb, (v4i32 MQPR:$val1), (v4i32 MQPR:$val2), ARMVCCThen, $pred, zero_reg)>; 1372 def : Pat<(ARMVMLALVApu tGPREven:$Rda, tGPROdd:$Rdb, (v4i32 MQPR:$val1), (v4i32 MQPR:$val2), (v4i1 VCCR:$pred)), 1373 (MVE_VMLALDAVau32 tGPREven:$Rda, tGPROdd:$Rdb, (v4i32 MQPR:$val1), (v4i32 MQPR:$val2), ARMVCCThen, $pred, zero_reg)>; 1374 def : Pat<(ARMVMLALVAps tGPREven:$Rda, tGPROdd:$Rdb, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), (v8i1 VCCR:$pred)), 1375 (MVE_VMLALDAVas16 tGPREven:$Rda, tGPROdd:$Rdb, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), ARMVCCThen, $pred, zero_reg)>; 1376 def : Pat<(ARMVMLALVApu tGPREven:$Rda, tGPROdd:$Rdb, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), (v8i1 VCCR:$pred)), 1377 (MVE_VMLALDAVau16 tGPREven:$Rda, tGPROdd:$Rdb, (v8i16 MQPR:$val1), (v8i16 MQPR:$val2), ARMVCCThen, $pred, zero_reg)>; 1378} 1379 1380// vmlalv aliases vmlaldav 1381foreach acc = ["", "a"] in { 1382 foreach suffix = ["s16", "s32", "u16", "u32"] in { 1383 def : MVEInstAlias<"vmlalv" # acc # "${vp}." # suffix # 1384 "\t$RdaLoDest, $RdaHiDest, $Qn, $Qm", 1385 (!cast<Instruction>("MVE_VMLALDAV"#acc#suffix) 1386 tGPREven:$RdaLoDest, tGPROdd:$RdaHiDest, 1387 MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>; 1388 } 1389} 1390 1391multiclass MVE_VMLSLDAV_multi<string iname, string suffix, bit sz, 1392 bit bit_28, bits<2> vecsize, list<dag> pattern=[]> { 1393 defm "" : MVE_VMLALDAVBase_AX<iname, suffix, sz, bit_28, 0b0, 0b1, vecsize, pattern>; 1394} 1395 1396defm MVE_VMLSLDAV : MVE_VMLSLDAV_multi<"vmlsldav", "s16", 0b0, 0b0, 0b01>; 1397defm MVE_VMLSLDAV : MVE_VMLSLDAV_multi<"vmlsldav", "s32", 0b1, 0b0, 0b10>; 1398defm MVE_VRMLSLDAVH : MVE_VMLSLDAV_multi<"vrmlsldavh", "s32", 0b0, 0b1, 0b10>; 1399 1400// end of mve_rDest instructions 1401 1402// start of mve_comp instructions 1403 1404class MVE_comp<InstrItinClass itin, string iname, string suffix, 1405 string cstr, bits<2> vecsize, list<dag> pattern=[]> 1406 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm), itin, iname, suffix, 1407 "$Qd, $Qn, $Qm", vpred_r, cstr, vecsize, pattern> { 1408 bits<4> Qd; 1409 bits<4> Qn; 1410 bits<4> Qm; 1411 1412 let Inst{22} = Qd{3}; 1413 let Inst{19-17} = Qn{2-0}; 1414 let Inst{16} = 0b0; 1415 let Inst{15-13} = Qd{2-0}; 1416 let Inst{12} = 0b0; 1417 let Inst{10-9} = 0b11; 1418 let Inst{7} = Qn{3}; 1419 let Inst{5} = Qm{3}; 1420 let Inst{3-1} = Qm{2-0}; 1421 let Inst{0} = 0b0; 1422} 1423 1424class MVE_VMINMAXNM<string iname, string suffix, bits<2> sz, bit bit_21, 1425 list<dag> pattern=[]> 1426 : MVE_comp<NoItinerary, iname, suffix, "", sz, pattern> { 1427 1428 let Inst{28} = 0b1; 1429 let Inst{25-24} = 0b11; 1430 let Inst{23} = 0b0; 1431 let Inst{21} = bit_21; 1432 let Inst{20} = sz{0}; 1433 let Inst{11} = 0b1; 1434 let Inst{8} = 0b1; 1435 let Inst{6} = 0b1; 1436 let Inst{4} = 0b1; 1437 1438 let Predicates = [HasMVEFloat]; 1439 let validForTailPredication = 1; 1440} 1441 1442multiclass MVE_VMINMAXNM_m<string iname, bit bit_4, MVEVectorVTInfo VTI, SDNode Op, Intrinsic PredInt> { 1443 def "" : MVE_VMINMAXNM<iname, VTI.Suffix, VTI.Size, bit_4>; 1444 1445 let Predicates = [HasMVEFloat] in { 1446 defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? (i32 0)), !cast<Instruction>(NAME)>; 1447 } 1448} 1449 1450defm MVE_VMAXNMf32 : MVE_VMINMAXNM_m<"vmaxnm", 0b0, MVE_v4f32, fmaxnum, int_arm_mve_max_predicated>; 1451defm MVE_VMAXNMf16 : MVE_VMINMAXNM_m<"vmaxnm", 0b0, MVE_v8f16, fmaxnum, int_arm_mve_max_predicated>; 1452defm MVE_VMINNMf32 : MVE_VMINMAXNM_m<"vminnm", 0b1, MVE_v4f32, fminnum, int_arm_mve_min_predicated>; 1453defm MVE_VMINNMf16 : MVE_VMINMAXNM_m<"vminnm", 0b1, MVE_v8f16, fminnum, int_arm_mve_min_predicated>; 1454 1455 1456class MVE_VMINMAX<string iname, string suffix, bit U, bits<2> size, 1457 bit bit_4, list<dag> pattern=[]> 1458 : MVE_comp<NoItinerary, iname, suffix, "", size, pattern> { 1459 1460 let Inst{28} = U; 1461 let Inst{25-24} = 0b11; 1462 let Inst{23} = 0b0; 1463 let Inst{21-20} = size{1-0}; 1464 let Inst{11} = 0b0; 1465 let Inst{8} = 0b0; 1466 let Inst{6} = 0b1; 1467 let Inst{4} = bit_4; 1468 let validForTailPredication = 1; 1469} 1470 1471multiclass MVE_VMINMAX_m<string iname, bit bit_4, MVEVectorVTInfo VTI, 1472 SDNode Op, Intrinsic PredInt> { 1473 def "" : MVE_VMINMAX<iname, VTI.Suffix, VTI.Unsigned, VTI.Size, bit_4>; 1474 1475 let Predicates = [HasMVEInt] in { 1476 defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? (i32 VTI.Unsigned)), !cast<Instruction>(NAME)>; 1477 } 1478} 1479 1480multiclass MVE_VMAX<MVEVectorVTInfo VTI> 1481 : MVE_VMINMAX_m<"vmax", 0b0, VTI, !if(VTI.Unsigned, umax, smax), int_arm_mve_max_predicated>; 1482multiclass MVE_VMIN<MVEVectorVTInfo VTI> 1483 : MVE_VMINMAX_m<"vmin", 0b1, VTI, !if(VTI.Unsigned, umin, smin), int_arm_mve_min_predicated>; 1484 1485defm MVE_VMINs8 : MVE_VMIN<MVE_v16s8>; 1486defm MVE_VMINs16 : MVE_VMIN<MVE_v8s16>; 1487defm MVE_VMINs32 : MVE_VMIN<MVE_v4s32>; 1488defm MVE_VMINu8 : MVE_VMIN<MVE_v16u8>; 1489defm MVE_VMINu16 : MVE_VMIN<MVE_v8u16>; 1490defm MVE_VMINu32 : MVE_VMIN<MVE_v4u32>; 1491 1492defm MVE_VMAXs8 : MVE_VMAX<MVE_v16s8>; 1493defm MVE_VMAXs16 : MVE_VMAX<MVE_v8s16>; 1494defm MVE_VMAXs32 : MVE_VMAX<MVE_v4s32>; 1495defm MVE_VMAXu8 : MVE_VMAX<MVE_v16u8>; 1496defm MVE_VMAXu16 : MVE_VMAX<MVE_v8u16>; 1497defm MVE_VMAXu32 : MVE_VMAX<MVE_v4u32>; 1498 1499// end of mve_comp instructions 1500 1501// start of mve_bit instructions 1502 1503class MVE_bit_arith<dag oops, dag iops, string iname, string suffix, 1504 string ops, string cstr, bits<2> vecsize, list<dag> pattern=[]> 1505 : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred_r, cstr, vecsize, pattern> { 1506 bits<4> Qd; 1507 bits<4> Qm; 1508 1509 let Inst{22} = Qd{3}; 1510 let Inst{15-13} = Qd{2-0}; 1511 let Inst{5} = Qm{3}; 1512 let Inst{3-1} = Qm{2-0}; 1513} 1514 1515def MVE_VBIC : MVE_bit_arith<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm), 1516 "vbic", "", "$Qd, $Qn, $Qm", "", 0b00> { 1517 bits<4> Qn; 1518 1519 let Inst{28} = 0b0; 1520 let Inst{25-23} = 0b110; 1521 let Inst{21-20} = 0b01; 1522 let Inst{19-17} = Qn{2-0}; 1523 let Inst{16} = 0b0; 1524 let Inst{12-8} = 0b00001; 1525 let Inst{7} = Qn{3}; 1526 let Inst{6} = 0b1; 1527 let Inst{4} = 0b1; 1528 let Inst{0} = 0b0; 1529 let validForTailPredication = 1; 1530} 1531 1532class MVE_VREV<string iname, string suffix, bits<2> size, bits<2> bit_8_7, 1533 bits<2> vecsize, string cstr=""> 1534 : MVE_bit_arith<(outs MQPR:$Qd), (ins MQPR:$Qm), iname, 1535 suffix, "$Qd, $Qm", cstr, vecsize> { 1536 1537 let Inst{28} = 0b1; 1538 let Inst{25-23} = 0b111; 1539 let Inst{21-20} = 0b11; 1540 let Inst{19-18} = size; 1541 let Inst{17-16} = 0b00; 1542 let Inst{12-9} = 0b0000; 1543 let Inst{8-7} = bit_8_7; 1544 let Inst{6} = 0b1; 1545 let Inst{4} = 0b0; 1546 let Inst{0} = 0b0; 1547} 1548 1549def MVE_VREV64_8 : MVE_VREV<"vrev64", "8", 0b00, 0b00, 0b11, "@earlyclobber $Qd">; 1550def MVE_VREV64_16 : MVE_VREV<"vrev64", "16", 0b01, 0b00, 0b11, "@earlyclobber $Qd">; 1551def MVE_VREV64_32 : MVE_VREV<"vrev64", "32", 0b10, 0b00, 0b11, "@earlyclobber $Qd">; 1552 1553def MVE_VREV32_8 : MVE_VREV<"vrev32", "8", 0b00, 0b01, 0b10>; 1554def MVE_VREV32_16 : MVE_VREV<"vrev32", "16", 0b01, 0b01, 0b10>; 1555 1556def MVE_VREV16_8 : MVE_VREV<"vrev16", "8", 0b00, 0b10, 0b01>; 1557 1558let Predicates = [HasMVEInt] in { 1559 def : Pat<(v8i16 (bswap (v8i16 MQPR:$src))), 1560 (v8i16 (MVE_VREV16_8 (v8i16 MQPR:$src)))>; 1561 def : Pat<(v4i32 (bswap (v4i32 MQPR:$src))), 1562 (v4i32 (MVE_VREV32_8 (v4i32 MQPR:$src)))>; 1563} 1564 1565multiclass MVE_VREV_basic_patterns<int revbits, list<MVEVectorVTInfo> VTIs, 1566 Instruction Inst> { 1567 defvar unpred_op = !cast<SDNode>("ARMvrev" # revbits); 1568 1569 foreach VTI = VTIs in { 1570 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$src))), 1571 (VTI.Vec (Inst (VTI.Vec MQPR:$src)))>; 1572 def : Pat<(VTI.Vec (int_arm_mve_vrev_predicated (VTI.Vec MQPR:$src), 1573 revbits, (VTI.Pred VCCR:$pred), (VTI.Vec MQPR:$inactive))), 1574 (VTI.Vec (Inst (VTI.Vec MQPR:$src), ARMVCCThen, 1575 (VTI.Pred VCCR:$pred), zero_reg, (VTI.Vec MQPR:$inactive)))>; 1576 } 1577} 1578 1579let Predicates = [HasMVEInt] in { 1580 defm: MVE_VREV_basic_patterns<64, [MVE_v4i32, MVE_v4f32], MVE_VREV64_32>; 1581 defm: MVE_VREV_basic_patterns<64, [MVE_v8i16, MVE_v8f16], MVE_VREV64_16>; 1582 defm: MVE_VREV_basic_patterns<64, [MVE_v16i8 ], MVE_VREV64_8>; 1583 1584 defm: MVE_VREV_basic_patterns<32, [MVE_v8i16, MVE_v8f16], MVE_VREV32_16>; 1585 defm: MVE_VREV_basic_patterns<32, [MVE_v16i8 ], MVE_VREV32_8>; 1586 1587 defm: MVE_VREV_basic_patterns<16, [MVE_v16i8 ], MVE_VREV16_8>; 1588} 1589 1590def MVE_VMVN : MVE_bit_arith<(outs MQPR:$Qd), (ins MQPR:$Qm), 1591 "vmvn", "", "$Qd, $Qm", "", 0b00> { 1592 let Inst{28} = 0b1; 1593 let Inst{25-23} = 0b111; 1594 let Inst{21-16} = 0b110000; 1595 let Inst{12-6} = 0b0010111; 1596 let Inst{4} = 0b0; 1597 let Inst{0} = 0b0; 1598 let validForTailPredication = 1; 1599} 1600 1601let Predicates = [HasMVEInt] in { 1602 foreach VTI = [ MVE_v16i8, MVE_v8i16, MVE_v4i32, MVE_v2i64 ] in { 1603 def : Pat<(VTI.Vec (vnotq (VTI.Vec MQPR:$val1))), 1604 (VTI.Vec (MVE_VMVN (VTI.Vec MQPR:$val1)))>; 1605 def : Pat<(VTI.Vec (int_arm_mve_mvn_predicated (VTI.Vec MQPR:$val1), 1606 (VTI.Pred VCCR:$pred), (VTI.Vec MQPR:$inactive))), 1607 (VTI.Vec (MVE_VMVN (VTI.Vec MQPR:$val1), ARMVCCThen, 1608 (VTI.Pred VCCR:$pred), zero_reg, (VTI.Vec MQPR:$inactive)))>; 1609 } 1610} 1611 1612class MVE_bit_ops<string iname, bits<2> bit_21_20, bit bit_28> 1613 : MVE_bit_arith<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm), 1614 iname, "", "$Qd, $Qn, $Qm", "", 0b00> { 1615 bits<4> Qn; 1616 1617 let Inst{28} = bit_28; 1618 let Inst{25-23} = 0b110; 1619 let Inst{21-20} = bit_21_20; 1620 let Inst{19-17} = Qn{2-0}; 1621 let Inst{16} = 0b0; 1622 let Inst{12-8} = 0b00001; 1623 let Inst{7} = Qn{3}; 1624 let Inst{6} = 0b1; 1625 let Inst{4} = 0b1; 1626 let Inst{0} = 0b0; 1627 let validForTailPredication = 1; 1628} 1629 1630def MVE_VEOR : MVE_bit_ops<"veor", 0b00, 0b1>; 1631def MVE_VORN : MVE_bit_ops<"vorn", 0b11, 0b0>; 1632def MVE_VORR : MVE_bit_ops<"vorr", 0b10, 0b0>; 1633def MVE_VAND : MVE_bit_ops<"vand", 0b00, 0b0>; 1634 1635// add ignored suffixes as aliases 1636 1637foreach s=["s8", "s16", "s32", "u8", "u16", "u32", "i8", "i16", "i32", "f16", "f32"] in { 1638 def : MVEInstAlias<"vbic${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc", 1639 (MVE_VBIC MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>; 1640 def : MVEInstAlias<"veor${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc", 1641 (MVE_VEOR MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>; 1642 def : MVEInstAlias<"vorn${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc", 1643 (MVE_VORN MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>; 1644 def : MVEInstAlias<"vorr${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc", 1645 (MVE_VORR MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>; 1646 def : MVEInstAlias<"vand${vp}." # s # "\t$QdSrc, $QnSrc, $QmSrc", 1647 (MVE_VAND MQPR:$QdSrc, MQPR:$QnSrc, MQPR:$QmSrc, vpred_r:$vp)>; 1648} 1649 1650let Predicates = [HasMVEInt] in { 1651 defm : MVE_TwoOpPattern<MVE_v16i8, and, int_arm_mve_and_predicated, (? ), MVE_VAND, ARMimmAllOnesV>; 1652 defm : MVE_TwoOpPattern<MVE_v8i16, and, int_arm_mve_and_predicated, (? ), MVE_VAND, ARMimmAllOnesV>; 1653 defm : MVE_TwoOpPattern<MVE_v4i32, and, int_arm_mve_and_predicated, (? ), MVE_VAND, ARMimmAllOnesV>; 1654 defm : MVE_TwoOpPattern<MVE_v2i64, and, int_arm_mve_and_predicated, (? ), MVE_VAND, ARMimmAllOnesV>; 1655 1656 defm : MVE_TwoOpPattern<MVE_v16i8, or, int_arm_mve_orr_predicated, (? ), MVE_VORR, ARMimmAllZerosV>; 1657 defm : MVE_TwoOpPattern<MVE_v8i16, or, int_arm_mve_orr_predicated, (? ), MVE_VORR, ARMimmAllZerosV>; 1658 defm : MVE_TwoOpPattern<MVE_v4i32, or, int_arm_mve_orr_predicated, (? ), MVE_VORR, ARMimmAllZerosV>; 1659 defm : MVE_TwoOpPattern<MVE_v2i64, or, int_arm_mve_orr_predicated, (? ), MVE_VORR, ARMimmAllZerosV>; 1660 1661 defm : MVE_TwoOpPattern<MVE_v16i8, xor, int_arm_mve_eor_predicated, (? ), MVE_VEOR, ARMimmAllZerosV>; 1662 defm : MVE_TwoOpPattern<MVE_v8i16, xor, int_arm_mve_eor_predicated, (? ), MVE_VEOR, ARMimmAllZerosV>; 1663 defm : MVE_TwoOpPattern<MVE_v4i32, xor, int_arm_mve_eor_predicated, (? ), MVE_VEOR, ARMimmAllZerosV>; 1664 defm : MVE_TwoOpPattern<MVE_v2i64, xor, int_arm_mve_eor_predicated, (? ), MVE_VEOR, ARMimmAllZerosV>; 1665 1666 defm : MVE_TwoOpPattern<MVE_v16i8, BinOpFrag<(and node:$LHS, (vnotq node:$RHS))>, 1667 int_arm_mve_bic_predicated, (? ), MVE_VBIC>; 1668 defm : MVE_TwoOpPattern<MVE_v8i16, BinOpFrag<(and node:$LHS, (vnotq node:$RHS))>, 1669 int_arm_mve_bic_predicated, (? ), MVE_VBIC>; 1670 defm : MVE_TwoOpPattern<MVE_v4i32, BinOpFrag<(and node:$LHS, (vnotq node:$RHS))>, 1671 int_arm_mve_bic_predicated, (? ), MVE_VBIC>; 1672 defm : MVE_TwoOpPattern<MVE_v2i64, BinOpFrag<(and node:$LHS, (vnotq node:$RHS))>, 1673 int_arm_mve_bic_predicated, (? ), MVE_VBIC>; 1674 1675 defm : MVE_TwoOpPattern<MVE_v16i8, BinOpFrag<(or node:$LHS, (vnotq node:$RHS))>, 1676 int_arm_mve_orn_predicated, (? ), MVE_VORN>; 1677 defm : MVE_TwoOpPattern<MVE_v8i16, BinOpFrag<(or node:$LHS, (vnotq node:$RHS))>, 1678 int_arm_mve_orn_predicated, (? ), MVE_VORN>; 1679 defm : MVE_TwoOpPattern<MVE_v4i32, BinOpFrag<(or node:$LHS, (vnotq node:$RHS))>, 1680 int_arm_mve_orn_predicated, (? ), MVE_VORN>; 1681 defm : MVE_TwoOpPattern<MVE_v2i64, BinOpFrag<(or node:$LHS, (vnotq node:$RHS))>, 1682 int_arm_mve_orn_predicated, (? ), MVE_VORN>; 1683} 1684 1685class MVE_bit_cmode<string iname, string suffix, bit halfword, dag inOps, bits<2> vecsize> 1686 : MVE_p<(outs MQPR:$Qd), inOps, NoItinerary, 1687 iname, suffix, "$Qd, $imm", vpred_n, "$Qd = $Qd_src", vecsize> { 1688 bits<12> imm; 1689 bits<4> Qd; 1690 1691 let Inst{28} = imm{7}; 1692 let Inst{27-23} = 0b11111; 1693 let Inst{22} = Qd{3}; 1694 let Inst{21-19} = 0b000; 1695 let Inst{18-16} = imm{6-4}; 1696 let Inst{15-13} = Qd{2-0}; 1697 let Inst{12} = 0b0; 1698 let Inst{11} = halfword; 1699 let Inst{10} = !if(halfword, 0, imm{10}); 1700 let Inst{9} = imm{9}; 1701 let Inst{8} = 0b1; 1702 let Inst{7-6} = 0b01; 1703 let Inst{4} = 0b1; 1704 let Inst{3-0} = imm{3-0}; 1705} 1706 1707multiclass MVE_bit_cmode_p<string iname, bit opcode, 1708 MVEVectorVTInfo VTI, Operand imm_type, SDNode op> { 1709 def "" : MVE_bit_cmode<iname, VTI.Suffix, VTI.Size{0}, 1710 (ins MQPR:$Qd_src, imm_type:$imm), VTI.Size> { 1711 let Inst{5} = opcode; 1712 let validForTailPredication = 1; 1713 } 1714 1715 defvar Inst = !cast<Instruction>(NAME); 1716 defvar UnpredPat = (VTI.Vec (op (VTI.Vec MQPR:$src), timm:$simm)); 1717 1718 let Predicates = [HasMVEInt] in { 1719 def : Pat<UnpredPat, 1720 (VTI.Vec (Inst (VTI.Vec MQPR:$src), imm_type:$simm))>; 1721 def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred), 1722 UnpredPat, (VTI.Vec MQPR:$src))), 1723 (VTI.Vec (Inst (VTI.Vec MQPR:$src), imm_type:$simm, 1724 ARMVCCThen, (VTI.Pred VCCR:$pred), zero_reg))>; 1725 } 1726} 1727 1728multiclass MVE_VORRimm<MVEVectorVTInfo VTI, Operand imm_type> { 1729 defm "": MVE_bit_cmode_p<"vorr", 0, VTI, imm_type, ARMvorrImm>; 1730} 1731multiclass MVE_VBICimm<MVEVectorVTInfo VTI, Operand imm_type> { 1732 defm "": MVE_bit_cmode_p<"vbic", 1, VTI, imm_type, ARMvbicImm>; 1733} 1734 1735defm MVE_VORRimmi16 : MVE_VORRimm<MVE_v8i16, nImmSplatI16>; 1736defm MVE_VORRimmi32 : MVE_VORRimm<MVE_v4i32, nImmSplatI32>; 1737defm MVE_VBICimmi16 : MVE_VBICimm<MVE_v8i16, nImmSplatI16>; 1738defm MVE_VBICimmi32 : MVE_VBICimm<MVE_v4i32, nImmSplatI32>; 1739 1740def MVE_VORNimmi16 : MVEInstAlias<"vorn${vp}.i16\t$Qd, $imm", 1741 (MVE_VORRimmi16 MQPR:$Qd, nImmSplatNotI16:$imm, vpred_n:$vp), 0>; 1742def MVE_VORNimmi32 : MVEInstAlias<"vorn${vp}.i32\t$Qd, $imm", 1743 (MVE_VORRimmi32 MQPR:$Qd, nImmSplatNotI32:$imm, vpred_n:$vp), 0>; 1744 1745def MVE_VANDimmi16 : MVEInstAlias<"vand${vp}.i16\t$Qd, $imm", 1746 (MVE_VBICimmi16 MQPR:$Qd, nImmSplatNotI16:$imm, vpred_n:$vp), 0>; 1747def MVE_VANDimmi32 : MVEInstAlias<"vand${vp}.i32\t$Qd, $imm", 1748 (MVE_VBICimmi32 MQPR:$Qd, nImmSplatNotI32:$imm, vpred_n:$vp), 0>; 1749 1750def MVE_VMOV : MVEInstAlias<"vmov${vp}\t$Qd, $Qm", 1751 (MVE_VORR MQPR:$Qd, MQPR:$Qm, MQPR:$Qm, vpred_r:$vp)>; 1752 1753class MVE_VMOV_lane_direction { 1754 bit bit_20; 1755 dag oops; 1756 dag iops; 1757 string ops; 1758 string cstr; 1759} 1760def MVE_VMOV_from_lane : MVE_VMOV_lane_direction { 1761 let bit_20 = 0b1; 1762 let oops = (outs rGPR:$Rt); 1763 let iops = (ins MQPR:$Qd); 1764 let ops = "$Rt, $Qd$Idx"; 1765 let cstr = ""; 1766} 1767def MVE_VMOV_to_lane : MVE_VMOV_lane_direction { 1768 let bit_20 = 0b0; 1769 let oops = (outs MQPR:$Qd); 1770 let iops = (ins MQPR:$Qd_src, rGPR:$Rt); 1771 let ops = "$Qd$Idx, $Rt"; 1772 let cstr = "$Qd = $Qd_src"; 1773} 1774 1775class MVE_VMOV_lane<string suffix, bit U, dag indexop, 1776 MVE_VMOV_lane_direction dir> 1777 : MVE_VMOV_lane_base<dir.oops, !con(dir.iops, indexop), NoItinerary, 1778 "vmov", suffix, dir.ops, dir.cstr, []> { 1779 bits<4> Qd; 1780 bits<4> Rt; 1781 1782 let Inst{31-24} = 0b11101110; 1783 let Inst{23} = U; 1784 let Inst{20} = dir.bit_20; 1785 let Inst{19-17} = Qd{2-0}; 1786 let Inst{15-12} = Rt{3-0}; 1787 let Inst{11-8} = 0b1011; 1788 let Inst{7} = Qd{3}; 1789 let Inst{4-0} = 0b10000; 1790 1791 let hasSideEffects = 0; 1792} 1793 1794class MVE_VMOV_lane_32<MVE_VMOV_lane_direction dir> 1795 : MVE_VMOV_lane<"32", 0b0, (ins MVEVectorIndex<4>:$Idx), dir> { 1796 bits<2> Idx; 1797 let Inst{22} = 0b0; 1798 let Inst{6-5} = 0b00; 1799 let Inst{16} = Idx{1}; 1800 let Inst{21} = Idx{0}; 1801 1802 let VecSize = 0b10; 1803 let Predicates = [HasFPRegsV8_1M]; 1804} 1805 1806class MVE_VMOV_lane_16<string suffix, bit U, MVE_VMOV_lane_direction dir> 1807 : MVE_VMOV_lane<suffix, U, (ins MVEVectorIndex<8>:$Idx), dir> { 1808 bits<3> Idx; 1809 let Inst{22} = 0b0; 1810 let Inst{5} = 0b1; 1811 let Inst{16} = Idx{2}; 1812 let Inst{21} = Idx{1}; 1813 let Inst{6} = Idx{0}; 1814 1815 let VecSize = 0b01; 1816} 1817 1818class MVE_VMOV_lane_8<string suffix, bit U, MVE_VMOV_lane_direction dir> 1819 : MVE_VMOV_lane<suffix, U, (ins MVEVectorIndex<16>:$Idx), dir> { 1820 bits<4> Idx; 1821 let Inst{22} = 0b1; 1822 let Inst{16} = Idx{3}; 1823 let Inst{21} = Idx{2}; 1824 let Inst{6} = Idx{1}; 1825 let Inst{5} = Idx{0}; 1826 1827 let VecSize = 0b00; 1828} 1829 1830def MVE_VMOV_from_lane_32 : MVE_VMOV_lane_32< MVE_VMOV_from_lane>; 1831def MVE_VMOV_from_lane_s16 : MVE_VMOV_lane_16<"s16", 0b0, MVE_VMOV_from_lane>; 1832def MVE_VMOV_from_lane_u16 : MVE_VMOV_lane_16<"u16", 0b1, MVE_VMOV_from_lane>; 1833def MVE_VMOV_from_lane_s8 : MVE_VMOV_lane_8 < "s8", 0b0, MVE_VMOV_from_lane>; 1834def MVE_VMOV_from_lane_u8 : MVE_VMOV_lane_8 < "u8", 0b1, MVE_VMOV_from_lane>; 1835let isInsertSubreg = 1 in 1836def MVE_VMOV_to_lane_32 : MVE_VMOV_lane_32< MVE_VMOV_to_lane>; 1837def MVE_VMOV_to_lane_16 : MVE_VMOV_lane_16< "16", 0b0, MVE_VMOV_to_lane>; 1838def MVE_VMOV_to_lane_8 : MVE_VMOV_lane_8 < "8", 0b0, MVE_VMOV_to_lane>; 1839 1840// This is the same as insertelt but allows the inserted value to be an i32 as 1841// will be used when it is the only legal type. 1842def ARMVecInsert : SDTypeProfile<1, 3, [ 1843 SDTCisVT<2, i32>, SDTCisSameAs<0, 1>, SDTCisPtrTy<3> 1844]>; 1845def ARMinsertelt : SDNode<"ISD::INSERT_VECTOR_ELT", ARMVecInsert>; 1846 1847let Predicates = [HasMVEInt] in { 1848 def : Pat<(extractelt (v2f64 MQPR:$src), imm:$lane), 1849 (f64 (EXTRACT_SUBREG MQPR:$src, (DSubReg_f64_reg imm:$lane)))>; 1850 def : Pat<(insertelt (v2f64 MQPR:$src1), DPR:$src2, imm:$lane), 1851 (INSERT_SUBREG (v2f64 (COPY_TO_REGCLASS MQPR:$src1, MQPR)), DPR:$src2, (DSubReg_f64_reg imm:$lane))>; 1852 1853 def : Pat<(extractelt (v4i32 MQPR:$src), imm:$lane), 1854 (COPY_TO_REGCLASS 1855 (i32 (EXTRACT_SUBREG MQPR:$src, (SSubReg_f32_reg imm:$lane))), rGPR)>; 1856 def : Pat<(insertelt (v4i32 MQPR:$src1), rGPR:$src2, imm:$lane), 1857 (MVE_VMOV_to_lane_32 MQPR:$src1, rGPR:$src2, imm:$lane)>; 1858 // This tries to copy from one lane to another, without going via GPR regs 1859 def : Pat<(insertelt (v4i32 MQPR:$src1), (extractelt (v4i32 MQPR:$src2), imm:$extlane), imm:$inslane), 1860 (v4i32 (COPY_TO_REGCLASS 1861 (INSERT_SUBREG (v4f32 (COPY_TO_REGCLASS (v4i32 MQPR:$src1), MQPR)), 1862 (f32 (EXTRACT_SUBREG (v4f32 (COPY_TO_REGCLASS (v4i32 MQPR:$src2), MQPR)), 1863 (SSubReg_f32_reg imm:$extlane))), 1864 (SSubReg_f32_reg imm:$inslane)), 1865 MQPR))>; 1866 1867 def : Pat<(vector_insert (v16i8 MQPR:$src1), rGPR:$src2, imm:$lane), 1868 (MVE_VMOV_to_lane_8 MQPR:$src1, rGPR:$src2, imm:$lane)>; 1869 def : Pat<(vector_insert (v8i16 MQPR:$src1), rGPR:$src2, imm:$lane), 1870 (MVE_VMOV_to_lane_16 MQPR:$src1, rGPR:$src2, imm:$lane)>; 1871 1872 def : Pat<(ARMvgetlanes (v16i8 MQPR:$src), imm:$lane), 1873 (MVE_VMOV_from_lane_s8 MQPR:$src, imm:$lane)>; 1874 def : Pat<(ARMvgetlanes (v8i16 MQPR:$src), imm:$lane), 1875 (MVE_VMOV_from_lane_s16 MQPR:$src, imm:$lane)>; 1876 def : Pat<(ARMvgetlanes (v8f16 MQPR:$src), imm:$lane), 1877 (MVE_VMOV_from_lane_s16 MQPR:$src, imm:$lane)>; 1878 def : Pat<(ARMvgetlaneu (v16i8 MQPR:$src), imm:$lane), 1879 (MVE_VMOV_from_lane_u8 MQPR:$src, imm:$lane)>; 1880 def : Pat<(ARMvgetlaneu (v8i16 MQPR:$src), imm:$lane), 1881 (MVE_VMOV_from_lane_u16 MQPR:$src, imm:$lane)>; 1882 def : Pat<(ARMvgetlaneu (v8f16 MQPR:$src), imm:$lane), 1883 (MVE_VMOV_from_lane_u16 MQPR:$src, imm:$lane)>; 1884 // For i16's inserts being extracted from low lanes, then may use VINS. 1885 def : Pat<(ARMinsertelt (v8i16 MQPR:$src1), 1886 (ARMvgetlaneu (v8i16 MQPR:$src2), imm_even:$extlane), 1887 imm_odd:$inslane), 1888 (COPY_TO_REGCLASS (INSERT_SUBREG (v4f32 (COPY_TO_REGCLASS MQPR:$src1, MQPR)), 1889 (VINSH (EXTRACT_SUBREG MQPR:$src1, (SSubReg_f16_reg imm_odd:$inslane)), 1890 (EXTRACT_SUBREG MQPR:$src2, (SSubReg_f16_reg imm_even:$extlane))), 1891 (SSubReg_f16_reg imm_odd:$inslane)), MQPR)>; 1892 1893 def : Pat<(v16i8 (scalar_to_vector GPR:$src)), 1894 (MVE_VMOV_to_lane_8 (v16i8 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>; 1895 def : Pat<(v8i16 (scalar_to_vector GPR:$src)), 1896 (MVE_VMOV_to_lane_16 (v8i16 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>; 1897 def : Pat<(v4i32 (scalar_to_vector GPR:$src)), 1898 (MVE_VMOV_to_lane_32 (v4i32 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>; 1899 1900 // Floating point patterns, still enabled under HasMVEInt 1901 def : Pat<(extractelt (v4f32 MQPR:$src), imm:$lane), 1902 (COPY_TO_REGCLASS (f32 (EXTRACT_SUBREG MQPR:$src, (SSubReg_f32_reg imm:$lane))), SPR)>; 1903 def : Pat<(insertelt (v4f32 MQPR:$src1), (f32 SPR:$src2), imm:$lane), 1904 (INSERT_SUBREG (v4f32 (COPY_TO_REGCLASS MQPR:$src1, MQPR)), SPR:$src2, (SSubReg_f32_reg imm:$lane))>; 1905 1906 def : Pat<(insertelt (v8f16 MQPR:$src1), (f16 HPR:$src2), imm_even:$lane), 1907 (MVE_VMOV_to_lane_16 MQPR:$src1, (COPY_TO_REGCLASS (f16 HPR:$src2), rGPR), imm:$lane)>; 1908 def : Pat<(insertelt (v8f16 MQPR:$src1), (f16 HPR:$src2), imm_odd:$lane), 1909 (COPY_TO_REGCLASS (INSERT_SUBREG (v4f32 (COPY_TO_REGCLASS MQPR:$src1, MQPR)), 1910 (VINSH (EXTRACT_SUBREG MQPR:$src1, (SSubReg_f16_reg imm_odd:$lane)), 1911 (COPY_TO_REGCLASS HPR:$src2, SPR)), 1912 (SSubReg_f16_reg imm_odd:$lane)), MQPR)>; 1913 def : Pat<(extractelt (v8f16 MQPR:$src), imm_even:$lane), 1914 (EXTRACT_SUBREG MQPR:$src, (SSubReg_f16_reg imm_even:$lane))>; 1915 def : Pat<(extractelt (v8f16 MQPR:$src), imm_odd:$lane), 1916 (COPY_TO_REGCLASS 1917 (VMOVH (EXTRACT_SUBREG MQPR:$src, (SSubReg_f16_reg imm_odd:$lane))), 1918 HPR)>; 1919 1920 def : Pat<(v2f64 (scalar_to_vector (f64 DPR:$src))), 1921 (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), DPR:$src, dsub_0)>; 1922 def : Pat<(v4f32 (scalar_to_vector SPR:$src)), 1923 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), SPR:$src, ssub_0)>; 1924 def : Pat<(v4f32 (scalar_to_vector GPR:$src)), 1925 (MVE_VMOV_to_lane_32 (v4f32 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>; 1926 def : Pat<(v8f16 (scalar_to_vector (f16 HPR:$src))), 1927 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), (f16 HPR:$src), ssub_0)>; 1928 def : Pat<(v8f16 (scalar_to_vector GPR:$src)), 1929 (MVE_VMOV_to_lane_16 (v8f16 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>; 1930} 1931 1932// end of mve_bit instructions 1933 1934// start of MVE Integer instructions 1935 1936class MVE_int<string iname, string suffix, bits<2> size, list<dag> pattern=[]> 1937 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm), NoItinerary, 1938 iname, suffix, "$Qd, $Qn, $Qm", vpred_r, "", size, pattern> { 1939 bits<4> Qd; 1940 bits<4> Qn; 1941 bits<4> Qm; 1942 1943 let Inst{22} = Qd{3}; 1944 let Inst{21-20} = size; 1945 let Inst{19-17} = Qn{2-0}; 1946 let Inst{15-13} = Qd{2-0}; 1947 let Inst{7} = Qn{3}; 1948 let Inst{6} = 0b1; 1949 let Inst{5} = Qm{3}; 1950 let Inst{3-1} = Qm{2-0}; 1951} 1952 1953class MVE_VMULt1<string iname, string suffix, bits<2> size, 1954 list<dag> pattern=[]> 1955 : MVE_int<iname, suffix, size, pattern> { 1956 1957 let Inst{28} = 0b0; 1958 let Inst{25-23} = 0b110; 1959 let Inst{16} = 0b0; 1960 let Inst{12-8} = 0b01001; 1961 let Inst{4} = 0b1; 1962 let Inst{0} = 0b0; 1963 let validForTailPredication = 1; 1964} 1965 1966multiclass MVE_VMUL_m<MVEVectorVTInfo VTI> { 1967 def "" : MVE_VMULt1<"vmul", VTI.Suffix, VTI.Size>; 1968 1969 let Predicates = [HasMVEInt] in { 1970 defm : MVE_TwoOpPattern<VTI, mul, int_arm_mve_mul_predicated, (? ), 1971 !cast<Instruction>(NAME), ARMimmOneV>; 1972 } 1973} 1974 1975defm MVE_VMULi8 : MVE_VMUL_m<MVE_v16i8>; 1976defm MVE_VMULi16 : MVE_VMUL_m<MVE_v8i16>; 1977defm MVE_VMULi32 : MVE_VMUL_m<MVE_v4i32>; 1978 1979class MVE_VQxDMULH_Base<string iname, string suffix, bits<2> size, bit rounding, 1980 list<dag> pattern=[]> 1981 : MVE_int<iname, suffix, size, pattern> { 1982 1983 let Inst{28} = rounding; 1984 let Inst{25-23} = 0b110; 1985 let Inst{16} = 0b0; 1986 let Inst{12-8} = 0b01011; 1987 let Inst{4} = 0b0; 1988 let Inst{0} = 0b0; 1989 let validForTailPredication = 1; 1990} 1991 1992def MVEvqdmulh : SDNode<"ARMISD::VQDMULH", SDTIntBinOp>; 1993 1994multiclass MVE_VQxDMULH_m<string iname, MVEVectorVTInfo VTI, 1995 SDNode Op, Intrinsic unpred_int, Intrinsic pred_int, 1996 bit rounding> { 1997 def "" : MVE_VQxDMULH_Base<iname, VTI.Suffix, VTI.Size, rounding>; 1998 defvar Inst = !cast<Instruction>(NAME); 1999 2000 let Predicates = [HasMVEInt] in { 2001 defm : MVE_TwoOpPattern<VTI, Op, pred_int, (? ), Inst>; 2002 2003 // Extra unpredicated multiply intrinsic patterns 2004 def : Pat<(VTI.Vec (unpred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn))), 2005 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>; 2006 } 2007} 2008 2009multiclass MVE_VQxDMULH<string iname, MVEVectorVTInfo VTI, bit rounding> 2010 : MVE_VQxDMULH_m<iname, VTI, !if(rounding, null_frag, 2011 MVEvqdmulh), 2012 !if(rounding, int_arm_mve_vqrdmulh, 2013 int_arm_mve_vqdmulh), 2014 !if(rounding, int_arm_mve_qrdmulh_predicated, 2015 int_arm_mve_qdmulh_predicated), 2016 rounding>; 2017 2018defm MVE_VQDMULHi8 : MVE_VQxDMULH<"vqdmulh", MVE_v16s8, 0b0>; 2019defm MVE_VQDMULHi16 : MVE_VQxDMULH<"vqdmulh", MVE_v8s16, 0b0>; 2020defm MVE_VQDMULHi32 : MVE_VQxDMULH<"vqdmulh", MVE_v4s32, 0b0>; 2021 2022defm MVE_VQRDMULHi8 : MVE_VQxDMULH<"vqrdmulh", MVE_v16s8, 0b1>; 2023defm MVE_VQRDMULHi16 : MVE_VQxDMULH<"vqrdmulh", MVE_v8s16, 0b1>; 2024defm MVE_VQRDMULHi32 : MVE_VQxDMULH<"vqrdmulh", MVE_v4s32, 0b1>; 2025 2026class MVE_VADDSUB<string iname, string suffix, bits<2> size, bit subtract, 2027 list<dag> pattern=[]> 2028 : MVE_int<iname, suffix, size, pattern> { 2029 2030 let Inst{28} = subtract; 2031 let Inst{25-23} = 0b110; 2032 let Inst{16} = 0b0; 2033 let Inst{12-8} = 0b01000; 2034 let Inst{4} = 0b0; 2035 let Inst{0} = 0b0; 2036 let validForTailPredication = 1; 2037} 2038 2039multiclass MVE_VADDSUB_m<string iname, MVEVectorVTInfo VTI, bit subtract, 2040 SDNode Op, Intrinsic PredInt> { 2041 def "" : MVE_VADDSUB<iname, VTI.Suffix, VTI.Size, subtract>; 2042 defvar Inst = !cast<Instruction>(NAME); 2043 2044 let Predicates = [HasMVEInt] in { 2045 defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? ), !cast<Instruction>(NAME), ARMimmAllZerosV>; 2046 } 2047} 2048 2049multiclass MVE_VADD<MVEVectorVTInfo VTI> 2050 : MVE_VADDSUB_m<"vadd", VTI, 0b0, add, int_arm_mve_add_predicated>; 2051multiclass MVE_VSUB<MVEVectorVTInfo VTI> 2052 : MVE_VADDSUB_m<"vsub", VTI, 0b1, sub, int_arm_mve_sub_predicated>; 2053 2054defm MVE_VADDi8 : MVE_VADD<MVE_v16i8>; 2055defm MVE_VADDi16 : MVE_VADD<MVE_v8i16>; 2056defm MVE_VADDi32 : MVE_VADD<MVE_v4i32>; 2057 2058defm MVE_VSUBi8 : MVE_VSUB<MVE_v16i8>; 2059defm MVE_VSUBi16 : MVE_VSUB<MVE_v8i16>; 2060defm MVE_VSUBi32 : MVE_VSUB<MVE_v4i32>; 2061 2062class MVE_VQADDSUB<string iname, string suffix, bit U, bit subtract, 2063 bits<2> size> 2064 : MVE_int<iname, suffix, size, []> { 2065 2066 let Inst{28} = U; 2067 let Inst{25-23} = 0b110; 2068 let Inst{16} = 0b0; 2069 let Inst{12-10} = 0b000; 2070 let Inst{9} = subtract; 2071 let Inst{8} = 0b0; 2072 let Inst{4} = 0b1; 2073 let Inst{0} = 0b0; 2074 let validForTailPredication = 1; 2075} 2076 2077class MVE_VQADD_<string suffix, bit U, bits<2> size> 2078 : MVE_VQADDSUB<"vqadd", suffix, U, 0b0, size>; 2079class MVE_VQSUB_<string suffix, bit U, bits<2> size> 2080 : MVE_VQADDSUB<"vqsub", suffix, U, 0b1, size>; 2081 2082multiclass MVE_VQADD_m<MVEVectorVTInfo VTI, 2083 SDNode Op, Intrinsic PredInt> { 2084 def "" : MVE_VQADD_<VTI.Suffix, VTI.Unsigned, VTI.Size>; 2085 defvar Inst = !cast<Instruction>(NAME); 2086 2087 let Predicates = [HasMVEInt] in { 2088 defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? (i32 VTI.Unsigned)), 2089 !cast<Instruction>(NAME)>; 2090 } 2091} 2092 2093multiclass MVE_VQADD<MVEVectorVTInfo VTI, SDNode unpred_op> 2094 : MVE_VQADD_m<VTI, unpred_op, int_arm_mve_qadd_predicated>; 2095 2096defm MVE_VQADDs8 : MVE_VQADD<MVE_v16s8, saddsat>; 2097defm MVE_VQADDs16 : MVE_VQADD<MVE_v8s16, saddsat>; 2098defm MVE_VQADDs32 : MVE_VQADD<MVE_v4s32, saddsat>; 2099defm MVE_VQADDu8 : MVE_VQADD<MVE_v16u8, uaddsat>; 2100defm MVE_VQADDu16 : MVE_VQADD<MVE_v8u16, uaddsat>; 2101defm MVE_VQADDu32 : MVE_VQADD<MVE_v4u32, uaddsat>; 2102 2103multiclass MVE_VQSUB_m<MVEVectorVTInfo VTI, 2104 SDNode Op, Intrinsic PredInt> { 2105 def "" : MVE_VQSUB_<VTI.Suffix, VTI.Unsigned, VTI.Size>; 2106 defvar Inst = !cast<Instruction>(NAME); 2107 2108 let Predicates = [HasMVEInt] in { 2109 defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? (i32 VTI.Unsigned)), 2110 !cast<Instruction>(NAME)>; 2111 } 2112} 2113 2114multiclass MVE_VQSUB<MVEVectorVTInfo VTI, SDNode unpred_op> 2115 : MVE_VQSUB_m<VTI, unpred_op, int_arm_mve_qsub_predicated>; 2116 2117defm MVE_VQSUBs8 : MVE_VQSUB<MVE_v16s8, ssubsat>; 2118defm MVE_VQSUBs16 : MVE_VQSUB<MVE_v8s16, ssubsat>; 2119defm MVE_VQSUBs32 : MVE_VQSUB<MVE_v4s32, ssubsat>; 2120defm MVE_VQSUBu8 : MVE_VQSUB<MVE_v16u8, usubsat>; 2121defm MVE_VQSUBu16 : MVE_VQSUB<MVE_v8u16, usubsat>; 2122defm MVE_VQSUBu32 : MVE_VQSUB<MVE_v4u32, usubsat>; 2123 2124class MVE_VABD_int<string suffix, bit U, bits<2> size, 2125 list<dag> pattern=[]> 2126 : MVE_int<"vabd", suffix, size, pattern> { 2127 2128 let Inst{28} = U; 2129 let Inst{25-23} = 0b110; 2130 let Inst{16} = 0b0; 2131 let Inst{12-8} = 0b00111; 2132 let Inst{4} = 0b0; 2133 let Inst{0} = 0b0; 2134 let validForTailPredication = 1; 2135} 2136 2137multiclass MVE_VABD_m<MVEVectorVTInfo VTI, SDNode Op, 2138 Intrinsic unpred_int, Intrinsic PredInt> { 2139 def "" : MVE_VABD_int<VTI.Suffix, VTI.Unsigned, VTI.Size>; 2140 defvar Inst = !cast<Instruction>(NAME); 2141 2142 let Predicates = [HasMVEInt] in { 2143 defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? (i32 VTI.Unsigned)), 2144 !cast<Instruction>(NAME)>; 2145 2146 // Unpredicated absolute difference 2147 def : Pat<(VTI.Vec (unpred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 2148 (i32 VTI.Unsigned))), 2149 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>; 2150 } 2151} 2152 2153multiclass MVE_VABD<MVEVectorVTInfo VTI, SDNode Op> 2154 : MVE_VABD_m<VTI, Op, int_arm_mve_vabd, int_arm_mve_abd_predicated>; 2155 2156defm MVE_VABDs8 : MVE_VABD<MVE_v16s8, abds>; 2157defm MVE_VABDs16 : MVE_VABD<MVE_v8s16, abds>; 2158defm MVE_VABDs32 : MVE_VABD<MVE_v4s32, abds>; 2159defm MVE_VABDu8 : MVE_VABD<MVE_v16u8, abdu>; 2160defm MVE_VABDu16 : MVE_VABD<MVE_v8u16, abdu>; 2161defm MVE_VABDu32 : MVE_VABD<MVE_v4u32, abdu>; 2162 2163class MVE_VRHADD_Base<string suffix, bit U, bits<2> size, list<dag> pattern=[]> 2164 : MVE_int<"vrhadd", suffix, size, pattern> { 2165 2166 let Inst{28} = U; 2167 let Inst{25-23} = 0b110; 2168 let Inst{16} = 0b0; 2169 let Inst{12-8} = 0b00001; 2170 let Inst{4} = 0b0; 2171 let Inst{0} = 0b0; 2172 let validForTailPredication = 1; 2173} 2174 2175def addnuw : PatFrag<(ops node:$lhs, node:$rhs), 2176 (add node:$lhs, node:$rhs), [{ 2177 return N->getFlags().hasNoUnsignedWrap(); 2178}]>; 2179 2180def addnsw : PatFrag<(ops node:$lhs, node:$rhs), 2181 (add node:$lhs, node:$rhs), [{ 2182 return N->getFlags().hasNoSignedWrap(); 2183}]>; 2184 2185def subnuw : PatFrag<(ops node:$lhs, node:$rhs), 2186 (sub node:$lhs, node:$rhs), [{ 2187 return N->getFlags().hasNoUnsignedWrap(); 2188}]>; 2189 2190def subnsw : PatFrag<(ops node:$lhs, node:$rhs), 2191 (sub node:$lhs, node:$rhs), [{ 2192 return N->getFlags().hasNoSignedWrap(); 2193}]>; 2194 2195multiclass MVE_VRHADD_m<MVEVectorVTInfo VTI, 2196 SDNode unpred_op, Intrinsic pred_int> { 2197 def "" : MVE_VRHADD_Base<VTI.Suffix, VTI.Unsigned, VTI.Size>; 2198 defvar Inst = !cast<Instruction>(NAME); 2199 2200 let Predicates = [HasMVEInt] in { 2201 // Unpredicated rounding add-with-divide-by-two 2202 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 2203 (i32 VTI.Unsigned))), 2204 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>; 2205 2206 // Predicated add-with-divide-by-two 2207 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 2208 (i32 VTI.Unsigned), (VTI.Pred VCCR:$mask), 2209 (VTI.Vec MQPR:$inactive))), 2210 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 2211 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 2212 (VTI.Vec MQPR:$inactive)))>; 2213 } 2214} 2215 2216multiclass MVE_VRHADD<MVEVectorVTInfo VTI> 2217 : MVE_VRHADD_m<VTI, int_arm_mve_vrhadd, int_arm_mve_rhadd_predicated>; 2218 2219defm MVE_VRHADDs8 : MVE_VRHADD<MVE_v16s8>; 2220defm MVE_VRHADDs16 : MVE_VRHADD<MVE_v8s16>; 2221defm MVE_VRHADDs32 : MVE_VRHADD<MVE_v4s32>; 2222defm MVE_VRHADDu8 : MVE_VRHADD<MVE_v16u8>; 2223defm MVE_VRHADDu16 : MVE_VRHADD<MVE_v8u16>; 2224defm MVE_VRHADDu32 : MVE_VRHADD<MVE_v4u32>; 2225 2226// Rounding Halving Add perform the arithemtic operation with an extra bit of 2227// precision, before performing the shift, to void clipping errors. We're not 2228// modelling that here with these patterns, but we're using no wrap forms of 2229// add to ensure that the extra bit of information is not needed for the 2230// arithmetic or the rounding. 2231let Predicates = [HasMVEInt] in { 2232 def : Pat<(v16i8 (ARMvshrsImm (addnsw (addnsw (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn)), 2233 (v16i8 (ARMvmovImm (i32 3585)))), 2234 (i32 1))), 2235 (MVE_VRHADDs8 MQPR:$Qm, MQPR:$Qn)>; 2236 def : Pat<(v8i16 (ARMvshrsImm (addnsw (addnsw (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn)), 2237 (v8i16 (ARMvmovImm (i32 2049)))), 2238 (i32 1))), 2239 (MVE_VRHADDs16 MQPR:$Qm, MQPR:$Qn)>; 2240 def : Pat<(v4i32 (ARMvshrsImm (addnsw (addnsw (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn)), 2241 (v4i32 (ARMvmovImm (i32 1)))), 2242 (i32 1))), 2243 (MVE_VRHADDs32 MQPR:$Qm, MQPR:$Qn)>; 2244 def : Pat<(v16i8 (ARMvshruImm (addnuw (addnuw (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn)), 2245 (v16i8 (ARMvmovImm (i32 3585)))), 2246 (i32 1))), 2247 (MVE_VRHADDu8 MQPR:$Qm, MQPR:$Qn)>; 2248 def : Pat<(v8i16 (ARMvshruImm (addnuw (addnuw (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn)), 2249 (v8i16 (ARMvmovImm (i32 2049)))), 2250 (i32 1))), 2251 (MVE_VRHADDu16 MQPR:$Qm, MQPR:$Qn)>; 2252 def : Pat<(v4i32 (ARMvshruImm (addnuw (addnuw (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn)), 2253 (v4i32 (ARMvmovImm (i32 1)))), 2254 (i32 1))), 2255 (MVE_VRHADDu32 MQPR:$Qm, MQPR:$Qn)>; 2256 2257 def : Pat<(v16i8 (ARMvshrsImm (addnsw (addnsw (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn)), 2258 (v16i8 (ARMvdup (i32 1)))), 2259 (i32 1))), 2260 (MVE_VRHADDs8 MQPR:$Qm, MQPR:$Qn)>; 2261 def : Pat<(v8i16 (ARMvshrsImm (addnsw (addnsw (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn)), 2262 (v8i16 (ARMvdup (i32 1)))), 2263 (i32 1))), 2264 (MVE_VRHADDs16 MQPR:$Qm, MQPR:$Qn)>; 2265 def : Pat<(v4i32 (ARMvshrsImm (addnsw (addnsw (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn)), 2266 (v4i32 (ARMvdup (i32 1)))), 2267 (i32 1))), 2268 (MVE_VRHADDs32 MQPR:$Qm, MQPR:$Qn)>; 2269 def : Pat<(v16i8 (ARMvshruImm (addnuw (addnuw (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn)), 2270 (v16i8 (ARMvdup (i32 1)))), 2271 (i32 1))), 2272 (MVE_VRHADDu8 MQPR:$Qm, MQPR:$Qn)>; 2273 def : Pat<(v8i16 (ARMvshruImm (addnuw (addnuw (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn)), 2274 (v8i16 (ARMvdup (i32 1)))), 2275 (i32 1))), 2276 (MVE_VRHADDu16 MQPR:$Qm, MQPR:$Qn)>; 2277 def : Pat<(v4i32 (ARMvshruImm (addnuw (addnuw (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn)), 2278 (v4i32 (ARMvdup (i32 1)))), 2279 (i32 1))), 2280 (MVE_VRHADDu32 MQPR:$Qm, MQPR:$Qn)>; 2281} 2282 2283 2284class MVE_VHADDSUB<string iname, string suffix, bit U, bit subtract, 2285 bits<2> size, list<dag> pattern=[]> 2286 : MVE_int<iname, suffix, size, pattern> { 2287 2288 let Inst{28} = U; 2289 let Inst{25-23} = 0b110; 2290 let Inst{16} = 0b0; 2291 let Inst{12-10} = 0b000; 2292 let Inst{9} = subtract; 2293 let Inst{8} = 0b0; 2294 let Inst{4} = 0b0; 2295 let Inst{0} = 0b0; 2296 let validForTailPredication = 1; 2297} 2298 2299class MVE_VHADD_<string suffix, bit U, bits<2> size, 2300 list<dag> pattern=[]> 2301 : MVE_VHADDSUB<"vhadd", suffix, U, 0b0, size, pattern>; 2302class MVE_VHSUB_<string suffix, bit U, bits<2> size, 2303 list<dag> pattern=[]> 2304 : MVE_VHADDSUB<"vhsub", suffix, U, 0b1, size, pattern>; 2305 2306multiclass MVE_VHADD_m<MVEVectorVTInfo VTI, 2307 SDNode unpred_op, Intrinsic pred_int, PatFrag add_op, 2308 SDNode shift_op> { 2309 def "" : MVE_VHADD_<VTI.Suffix, VTI.Unsigned, VTI.Size>; 2310 defvar Inst = !cast<Instruction>(NAME); 2311 2312 let Predicates = [HasMVEInt] in { 2313 // Unpredicated add-and-divide-by-two 2314 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), (i32 VTI.Unsigned))), 2315 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>; 2316 2317 def : Pat<(VTI.Vec (shift_op (add_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)), (i32 1))), 2318 (Inst MQPR:$Qm, MQPR:$Qn)>; 2319 2320 // Predicated add-and-divide-by-two 2321 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), (i32 VTI.Unsigned), 2322 (VTI.Pred VCCR:$mask), (VTI.Vec MQPR:$inactive))), 2323 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 2324 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 2325 (VTI.Vec MQPR:$inactive)))>; 2326 } 2327} 2328 2329multiclass MVE_VHADD<MVEVectorVTInfo VTI, PatFrag add_op, SDNode shift_op> 2330 : MVE_VHADD_m<VTI, int_arm_mve_vhadd, int_arm_mve_hadd_predicated, add_op, 2331 shift_op>; 2332 2333// Halving add/sub perform the arithemtic operation with an extra bit of 2334// precision, before performing the shift, to void clipping errors. We're not 2335// modelling that here with these patterns, but we're using no wrap forms of 2336// add/sub to ensure that the extra bit of information is not needed. 2337defm MVE_VHADDs8 : MVE_VHADD<MVE_v16s8, addnsw, ARMvshrsImm>; 2338defm MVE_VHADDs16 : MVE_VHADD<MVE_v8s16, addnsw, ARMvshrsImm>; 2339defm MVE_VHADDs32 : MVE_VHADD<MVE_v4s32, addnsw, ARMvshrsImm>; 2340defm MVE_VHADDu8 : MVE_VHADD<MVE_v16u8, addnuw, ARMvshruImm>; 2341defm MVE_VHADDu16 : MVE_VHADD<MVE_v8u16, addnuw, ARMvshruImm>; 2342defm MVE_VHADDu32 : MVE_VHADD<MVE_v4u32, addnuw, ARMvshruImm>; 2343 2344multiclass MVE_VHSUB_m<MVEVectorVTInfo VTI, 2345 SDNode unpred_op, Intrinsic pred_int, PatFrag sub_op, 2346 SDNode shift_op> { 2347 def "" : MVE_VHSUB_<VTI.Suffix, VTI.Unsigned, VTI.Size>; 2348 defvar Inst = !cast<Instruction>(NAME); 2349 2350 let Predicates = [HasMVEInt] in { 2351 // Unpredicated subtract-and-divide-by-two 2352 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 2353 (i32 VTI.Unsigned))), 2354 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>; 2355 2356 def : Pat<(VTI.Vec (shift_op (sub_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)), (i32 1))), 2357 (Inst MQPR:$Qm, MQPR:$Qn)>; 2358 2359 2360 // Predicated subtract-and-divide-by-two 2361 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 2362 (i32 VTI.Unsigned), (VTI.Pred VCCR:$mask), 2363 (VTI.Vec MQPR:$inactive))), 2364 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 2365 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 2366 (VTI.Vec MQPR:$inactive)))>; 2367 } 2368} 2369 2370multiclass MVE_VHSUB<MVEVectorVTInfo VTI, PatFrag sub_op, SDNode shift_op> 2371 : MVE_VHSUB_m<VTI, int_arm_mve_vhsub, int_arm_mve_hsub_predicated, sub_op, 2372 shift_op>; 2373 2374defm MVE_VHSUBs8 : MVE_VHSUB<MVE_v16s8, subnsw, ARMvshrsImm>; 2375defm MVE_VHSUBs16 : MVE_VHSUB<MVE_v8s16, subnsw, ARMvshrsImm>; 2376defm MVE_VHSUBs32 : MVE_VHSUB<MVE_v4s32, subnsw, ARMvshrsImm>; 2377defm MVE_VHSUBu8 : MVE_VHSUB<MVE_v16u8, subnuw, ARMvshruImm>; 2378defm MVE_VHSUBu16 : MVE_VHSUB<MVE_v8u16, subnuw, ARMvshruImm>; 2379defm MVE_VHSUBu32 : MVE_VHSUB<MVE_v4u32, subnuw, ARMvshruImm>; 2380 2381class MVE_VDUP<string suffix, bit B, bit E, bits<2> vecsize, list<dag> pattern=[]> 2382 : MVE_p<(outs MQPR:$Qd), (ins rGPR:$Rt), NoItinerary, 2383 "vdup", suffix, "$Qd, $Rt", vpred_r, "", vecsize, pattern> { 2384 bits<4> Qd; 2385 bits<4> Rt; 2386 2387 let Inst{28} = 0b0; 2388 let Inst{25-23} = 0b101; 2389 let Inst{22} = B; 2390 let Inst{21-20} = 0b10; 2391 let Inst{19-17} = Qd{2-0}; 2392 let Inst{16} = 0b0; 2393 let Inst{15-12} = Rt; 2394 let Inst{11-8} = 0b1011; 2395 let Inst{7} = Qd{3}; 2396 let Inst{6} = 0b0; 2397 let Inst{5} = E; 2398 let Inst{4-0} = 0b10000; 2399 let validForTailPredication = 1; 2400} 2401 2402def MVE_VDUP32 : MVE_VDUP<"32", 0b0, 0b0, 0b10>; 2403def MVE_VDUP16 : MVE_VDUP<"16", 0b0, 0b1, 0b01>; 2404def MVE_VDUP8 : MVE_VDUP<"8", 0b1, 0b0, 0b00>; 2405 2406let Predicates = [HasMVEInt] in { 2407 def : Pat<(v16i8 (ARMvdup (i32 rGPR:$elem))), 2408 (MVE_VDUP8 rGPR:$elem)>; 2409 def : Pat<(v8i16 (ARMvdup (i32 rGPR:$elem))), 2410 (MVE_VDUP16 rGPR:$elem)>; 2411 def : Pat<(v4i32 (ARMvdup (i32 rGPR:$elem))), 2412 (MVE_VDUP32 rGPR:$elem)>; 2413 2414 def : Pat<(v8f16 (ARMvdup (i32 rGPR:$elem))), 2415 (MVE_VDUP16 rGPR:$elem)>; 2416 def : Pat<(v4f32 (ARMvdup (i32 rGPR:$elem))), 2417 (MVE_VDUP32 rGPR:$elem)>; 2418 2419 // Match a vselect with an ARMvdup as a predicated MVE_VDUP 2420 def : Pat<(v16i8 (vselect (v16i1 VCCR:$pred), 2421 (v16i8 (ARMvdup (i32 rGPR:$elem))), 2422 (v16i8 MQPR:$inactive))), 2423 (MVE_VDUP8 rGPR:$elem, ARMVCCThen, (v16i1 VCCR:$pred), zero_reg, 2424 (v16i8 MQPR:$inactive))>; 2425 def : Pat<(v8i16 (vselect (v8i1 VCCR:$pred), 2426 (v8i16 (ARMvdup (i32 rGPR:$elem))), 2427 (v8i16 MQPR:$inactive))), 2428 (MVE_VDUP16 rGPR:$elem, ARMVCCThen, (v8i1 VCCR:$pred), zero_reg, 2429 (v8i16 MQPR:$inactive))>; 2430 def : Pat<(v4i32 (vselect (v4i1 VCCR:$pred), 2431 (v4i32 (ARMvdup (i32 rGPR:$elem))), 2432 (v4i32 MQPR:$inactive))), 2433 (MVE_VDUP32 rGPR:$elem, ARMVCCThen, (v4i1 VCCR:$pred), zero_reg, 2434 (v4i32 MQPR:$inactive))>; 2435 def : Pat<(v4f32 (vselect (v4i1 VCCR:$pred), 2436 (v4f32 (ARMvdup (i32 rGPR:$elem))), 2437 (v4f32 MQPR:$inactive))), 2438 (MVE_VDUP32 rGPR:$elem, ARMVCCThen, (v4i1 VCCR:$pred), zero_reg, 2439 (v4f32 MQPR:$inactive))>; 2440 def : Pat<(v8f16 (vselect (v8i1 VCCR:$pred), 2441 (v8f16 (ARMvdup (i32 rGPR:$elem))), 2442 (v8f16 MQPR:$inactive))), 2443 (MVE_VDUP16 rGPR:$elem, ARMVCCThen, (v8i1 VCCR:$pred), zero_reg, 2444 (v8f16 MQPR:$inactive))>; 2445} 2446 2447 2448class MVEIntSingleSrc<string iname, string suffix, bits<2> size, 2449 list<dag> pattern=[]> 2450 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qm), NoItinerary, 2451 iname, suffix, "$Qd, $Qm", vpred_r, "", size, pattern> { 2452 bits<4> Qd; 2453 bits<4> Qm; 2454 2455 let Inst{22} = Qd{3}; 2456 let Inst{19-18} = size{1-0}; 2457 let Inst{15-13} = Qd{2-0}; 2458 let Inst{5} = Qm{3}; 2459 let Inst{3-1} = Qm{2-0}; 2460} 2461 2462class MVE_VCLSCLZ<string iname, string suffix, bits<2> size, 2463 bit count_zeroes, list<dag> pattern=[]> 2464 : MVEIntSingleSrc<iname, suffix, size, pattern> { 2465 2466 let Inst{28} = 0b1; 2467 let Inst{25-23} = 0b111; 2468 let Inst{21-20} = 0b11; 2469 let Inst{17-16} = 0b00; 2470 let Inst{12-8} = 0b00100; 2471 let Inst{7} = count_zeroes; 2472 let Inst{6} = 0b1; 2473 let Inst{4} = 0b0; 2474 let Inst{0} = 0b0; 2475 let validForTailPredication = 1; 2476} 2477 2478multiclass MVE_VCLSCLZ_p<string opname, bit opcode, MVEVectorVTInfo VTI, 2479 SDPatternOperator unpred_op> { 2480 def "": MVE_VCLSCLZ<"v"#opname, VTI.Suffix, VTI.Size, opcode>; 2481 2482 defvar Inst = !cast<Instruction>(NAME); 2483 defvar pred_int = !cast<Intrinsic>("int_arm_mve_"#opname#"_predicated"); 2484 2485 let Predicates = [HasMVEInt] in { 2486 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$val))), 2487 (VTI.Vec (Inst (VTI.Vec MQPR:$val)))>; 2488 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$val), (VTI.Pred VCCR:$pred), 2489 (VTI.Vec MQPR:$inactive))), 2490 (VTI.Vec (Inst (VTI.Vec MQPR:$val), ARMVCCThen, 2491 (VTI.Pred VCCR:$pred), zero_reg, (VTI.Vec MQPR:$inactive)))>; 2492 } 2493} 2494 2495defm MVE_VCLSs8 : MVE_VCLSCLZ_p<"cls", 0, MVE_v16s8, int_arm_mve_vcls>; 2496defm MVE_VCLSs16 : MVE_VCLSCLZ_p<"cls", 0, MVE_v8s16, int_arm_mve_vcls>; 2497defm MVE_VCLSs32 : MVE_VCLSCLZ_p<"cls", 0, MVE_v4s32, int_arm_mve_vcls>; 2498 2499defm MVE_VCLZs8 : MVE_VCLSCLZ_p<"clz", 1, MVE_v16i8, ctlz>; 2500defm MVE_VCLZs16 : MVE_VCLSCLZ_p<"clz", 1, MVE_v8i16, ctlz>; 2501defm MVE_VCLZs32 : MVE_VCLSCLZ_p<"clz", 1, MVE_v4i32, ctlz>; 2502 2503class MVE_VABSNEG_int<string iname, string suffix, bits<2> size, bit negate, 2504 bit saturate, list<dag> pattern=[]> 2505 : MVEIntSingleSrc<iname, suffix, size, pattern> { 2506 2507 let Inst{28} = 0b1; 2508 let Inst{25-23} = 0b111; 2509 let Inst{21-20} = 0b11; 2510 let Inst{17} = 0b0; 2511 let Inst{16} = !eq(saturate, 0); 2512 let Inst{12-11} = 0b00; 2513 let Inst{10} = saturate; 2514 let Inst{9-8} = 0b11; 2515 let Inst{7} = negate; 2516 let Inst{6} = 0b1; 2517 let Inst{4} = 0b0; 2518 let Inst{0} = 0b0; 2519 let validForTailPredication = 1; 2520} 2521 2522multiclass MVE_VABSNEG_int_m<string iname, bit negate, bit saturate, 2523 SDPatternOperator unpred_op, Intrinsic pred_int, 2524 MVEVectorVTInfo VTI> { 2525 def "" : MVE_VABSNEG_int<iname, VTI.Suffix, VTI.Size, negate, saturate>; 2526 defvar Inst = !cast<Instruction>(NAME); 2527 2528 let Predicates = [HasMVEInt] in { 2529 // VQABS and VQNEG have more difficult isel patterns defined elsewhere 2530 if !not(saturate) then { 2531 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$v))), 2532 (VTI.Vec (Inst $v))>; 2533 } 2534 2535 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$v), (VTI.Pred VCCR:$mask), 2536 (VTI.Vec MQPR:$inactive))), 2537 (VTI.Vec (Inst $v, ARMVCCThen, $mask, zero_reg, $inactive))>; 2538 } 2539} 2540 2541foreach VTI = [ MVE_v16s8, MVE_v8s16, MVE_v4s32 ] in { 2542 defm "MVE_VABS" # VTI.Suffix : MVE_VABSNEG_int_m< 2543 "vabs", 0, 0, abs, int_arm_mve_abs_predicated, VTI>; 2544 defm "MVE_VQABS" # VTI.Suffix : MVE_VABSNEG_int_m< 2545 "vqabs", 0, 1, ?, int_arm_mve_qabs_predicated, VTI>; 2546 defm "MVE_VNEG" # VTI.Suffix : MVE_VABSNEG_int_m< 2547 "vneg", 1, 0, vnegq, int_arm_mve_neg_predicated, VTI>; 2548 defm "MVE_VQNEG" # VTI.Suffix : MVE_VABSNEG_int_m< 2549 "vqneg", 1, 1, ?, int_arm_mve_qneg_predicated, VTI>; 2550} 2551 2552// int_min/int_max: vector containing INT_MIN/INT_MAX VTI.Size times 2553// zero_vec: v4i32-initialized zero vector, potentially wrapped in a bitconvert 2554multiclass vqabsneg_pattern<MVEVectorVTInfo VTI, dag int_min, dag int_max, 2555 dag zero_vec, MVE_VABSNEG_int vqabs_instruction, 2556 MVE_VABSNEG_int vqneg_instruction> { 2557 let Predicates = [HasMVEInt] in { 2558 // The below tree can be replaced by a vqabs instruction, as it represents 2559 // the following vectorized expression (r being the value in $reg): 2560 // r > 0 ? r : (r == INT_MIN ? INT_MAX : -r) 2561 def : Pat<(VTI.Vec (vselect 2562 (VTI.Pred (ARMvcmpz (VTI.Vec MQPR:$reg), ARMCCgt)), 2563 (VTI.Vec MQPR:$reg), 2564 (VTI.Vec (vselect 2565 (VTI.Pred (ARMvcmp (VTI.Vec MQPR:$reg), int_min, ARMCCeq)), 2566 int_max, 2567 (sub (VTI.Vec zero_vec), (VTI.Vec MQPR:$reg)))))), 2568 (VTI.Vec (vqabs_instruction (VTI.Vec MQPR:$reg)))>; 2569 // Similarly, this tree represents vqneg, i.e. the following vectorized expression: 2570 // r == INT_MIN ? INT_MAX : -r 2571 def : Pat<(VTI.Vec (vselect 2572 (VTI.Pred (ARMvcmp (VTI.Vec MQPR:$reg), int_min, ARMCCeq)), 2573 int_max, 2574 (sub (VTI.Vec zero_vec), (VTI.Vec MQPR:$reg)))), 2575 (VTI.Vec (vqneg_instruction (VTI.Vec MQPR:$reg)))>; 2576 } 2577} 2578 2579defm MVE_VQABSNEG_Ps8 : vqabsneg_pattern<MVE_v16i8, 2580 (v16i8 (ARMvmovImm (i32 3712))), 2581 (v16i8 (ARMvmovImm (i32 3711))), 2582 (bitconvert (v4i32 (ARMvmovImm (i32 0)))), 2583 MVE_VQABSs8, MVE_VQNEGs8>; 2584defm MVE_VQABSNEG_Ps16 : vqabsneg_pattern<MVE_v8i16, 2585 (v8i16 (ARMvmovImm (i32 2688))), 2586 (v8i16 (ARMvmvnImm (i32 2688))), 2587 (bitconvert (v4i32 (ARMvmovImm (i32 0)))), 2588 MVE_VQABSs16, MVE_VQNEGs16>; 2589defm MVE_VQABSNEG_Ps32 : vqabsneg_pattern<MVE_v4i32, 2590 (v4i32 (ARMvmovImm (i32 1664))), 2591 (v4i32 (ARMvmvnImm (i32 1664))), 2592 (ARMvmovImm (i32 0)), 2593 MVE_VQABSs32, MVE_VQNEGs32>; 2594 2595class MVE_mod_imm<string iname, string suffix, bits<4> cmode, bit op, 2596 dag iops, bits<2> vecsize, list<dag> pattern=[]> 2597 : MVE_p<(outs MQPR:$Qd), iops, NoItinerary, iname, suffix, "$Qd, $imm", 2598 vpred_r, "", vecsize, pattern> { 2599 bits<13> imm; 2600 bits<4> Qd; 2601 2602 let Inst{28} = imm{7}; 2603 let Inst{25-23} = 0b111; 2604 let Inst{22} = Qd{3}; 2605 let Inst{21-19} = 0b000; 2606 let Inst{18-16} = imm{6-4}; 2607 let Inst{15-13} = Qd{2-0}; 2608 let Inst{12} = 0b0; 2609 let Inst{11-8} = cmode{3-0}; 2610 let Inst{7-6} = 0b01; 2611 let Inst{5} = op; 2612 let Inst{4} = 0b1; 2613 let Inst{3-0} = imm{3-0}; 2614 2615 let DecoderMethod = "DecodeMVEModImmInstruction"; 2616 let validForTailPredication = 1; 2617} 2618 2619let isReMaterializable = 1 in { 2620let isAsCheapAsAMove = 1 in { 2621def MVE_VMOVimmi8 : MVE_mod_imm<"vmov", "i8", {1,1,1,0}, 0b0, (ins nImmSplatI8:$imm), 0b00>; 2622def MVE_VMOVimmi16 : MVE_mod_imm<"vmov", "i16", {1,0,?,0}, 0b0, (ins nImmSplatI16:$imm), 0b01> { 2623 let Inst{9} = imm{9}; 2624} 2625def MVE_VMOVimmi32 : MVE_mod_imm<"vmov", "i32", {?,?,?,?}, 0b0, (ins nImmVMOVI32:$imm), 0b10> { 2626 let Inst{11-8} = imm{11-8}; 2627} 2628def MVE_VMOVimmi64 : MVE_mod_imm<"vmov", "i64", {1,1,1,0}, 0b1, (ins nImmSplatI64:$imm), 0b11>; 2629def MVE_VMOVimmf32 : MVE_mod_imm<"vmov", "f32", {1,1,1,1}, 0b0, (ins nImmVMOVF32:$imm), 0b10>; 2630} // let isAsCheapAsAMove = 1 2631 2632def MVE_VMVNimmi16 : MVE_mod_imm<"vmvn", "i16", {1,0,?,0}, 0b1, (ins nImmSplatI16:$imm), 0b01> { 2633 let Inst{9} = imm{9}; 2634} 2635def MVE_VMVNimmi32 : MVE_mod_imm<"vmvn", "i32", {?,?,?,?}, 0b1, (ins nImmVMOVI32:$imm), 0b10> { 2636 let Inst{11-8} = imm{11-8}; 2637} 2638} // let isReMaterializable = 1 2639 2640let Predicates = [HasMVEInt] in { 2641 def : Pat<(v16i8 (ARMvmovImm timm:$simm)), 2642 (v16i8 (MVE_VMOVimmi8 nImmSplatI8:$simm))>; 2643 def : Pat<(v8i16 (ARMvmovImm timm:$simm)), 2644 (v8i16 (MVE_VMOVimmi16 nImmSplatI16:$simm))>; 2645 def : Pat<(v4i32 (ARMvmovImm timm:$simm)), 2646 (v4i32 (MVE_VMOVimmi32 nImmVMOVI32:$simm))>; 2647 def : Pat<(v2i64 (ARMvmovImm timm:$simm)), 2648 (v2i64 (MVE_VMOVimmi64 nImmSplatI64:$simm))>; 2649 2650 def : Pat<(v8i16 (ARMvmvnImm timm:$simm)), 2651 (v8i16 (MVE_VMVNimmi16 nImmSplatI16:$simm))>; 2652 def : Pat<(v4i32 (ARMvmvnImm timm:$simm)), 2653 (v4i32 (MVE_VMVNimmi32 nImmVMOVI32:$simm))>; 2654 2655 def : Pat<(v4f32 (ARMvmovFPImm timm:$simm)), 2656 (v4f32 (MVE_VMOVimmf32 nImmVMOVF32:$simm))>; 2657 2658 def : Pat<(v8i16 (vselect (v8i1 VCCR:$pred), (ARMvmvnImm timm:$simm), 2659 MQPR:$inactive)), 2660 (v8i16 (MVE_VMVNimmi16 nImmSplatI16:$simm, 2661 ARMVCCThen, VCCR:$pred, zero_reg, MQPR:$inactive))>; 2662 def : Pat<(v4i32 (vselect (v4i1 VCCR:$pred), (ARMvmvnImm timm:$simm), 2663 MQPR:$inactive)), 2664 (v4i32 (MVE_VMVNimmi32 nImmSplatI32:$simm, 2665 ARMVCCThen, VCCR:$pred, zero_reg, MQPR:$inactive))>; 2666} 2667 2668class MVE_VMINMAXA<string iname, string suffix, bits<2> size, 2669 bit bit_12, list<dag> pattern=[]> 2670 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qd_src, MQPR:$Qm), 2671 NoItinerary, iname, suffix, "$Qd, $Qm", vpred_n, "$Qd = $Qd_src", 2672 size, pattern> { 2673 bits<4> Qd; 2674 bits<4> Qm; 2675 2676 let Inst{28} = 0b0; 2677 let Inst{25-23} = 0b100; 2678 let Inst{22} = Qd{3}; 2679 let Inst{21-20} = 0b11; 2680 let Inst{19-18} = size; 2681 let Inst{17-16} = 0b11; 2682 let Inst{15-13} = Qd{2-0}; 2683 let Inst{12} = bit_12; 2684 let Inst{11-6} = 0b111010; 2685 let Inst{5} = Qm{3}; 2686 let Inst{4} = 0b0; 2687 let Inst{3-1} = Qm{2-0}; 2688 let Inst{0} = 0b1; 2689 let validForTailPredication = 1; 2690} 2691 2692multiclass MVE_VMINMAXA_m<string iname, MVEVectorVTInfo VTI, 2693 SDNode unpred_op, Intrinsic pred_int, bit bit_12> { 2694 def "" : MVE_VMINMAXA<iname, VTI.Suffix, VTI.Size, bit_12>; 2695 defvar Inst = !cast<Instruction>(NAME); 2696 2697 let Predicates = [HasMVEInt] in { 2698 // Unpredicated v(min|max)a 2699 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qd), (abs (VTI.Vec MQPR:$Qm)))), 2700 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm)))>; 2701 2702 // Predicated v(min|max)a 2703 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm), 2704 (VTI.Pred VCCR:$mask))), 2705 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm), 2706 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>; 2707 } 2708} 2709 2710multiclass MVE_VMINA<MVEVectorVTInfo VTI> 2711 : MVE_VMINMAXA_m<"vmina", VTI, umin, int_arm_mve_vmina_predicated, 0b1>; 2712 2713defm MVE_VMINAs8 : MVE_VMINA<MVE_v16s8>; 2714defm MVE_VMINAs16 : MVE_VMINA<MVE_v8s16>; 2715defm MVE_VMINAs32 : MVE_VMINA<MVE_v4s32>; 2716 2717multiclass MVE_VMAXA<MVEVectorVTInfo VTI> 2718 : MVE_VMINMAXA_m<"vmaxa", VTI, umax, int_arm_mve_vmaxa_predicated, 0b0>; 2719 2720defm MVE_VMAXAs8 : MVE_VMAXA<MVE_v16s8>; 2721defm MVE_VMAXAs16 : MVE_VMAXA<MVE_v8s16>; 2722defm MVE_VMAXAs32 : MVE_VMAXA<MVE_v4s32>; 2723 2724// end of MVE Integer instructions 2725 2726// start of mve_imm_shift instructions 2727 2728def MVE_VSHLC : MVE_p<(outs rGPR:$RdmDest, MQPR:$Qd), 2729 (ins MQPR:$QdSrc, rGPR:$RdmSrc, long_shift:$imm), 2730 NoItinerary, "vshlc", "", "$QdSrc, $RdmSrc, $imm", 2731 vpred_n, "$RdmDest = $RdmSrc,$Qd = $QdSrc", 0b10> { 2732 bits<5> imm; 2733 bits<4> Qd; 2734 bits<4> RdmDest; 2735 2736 let Inst{28} = 0b0; 2737 let Inst{25-23} = 0b101; 2738 let Inst{22} = Qd{3}; 2739 let Inst{21} = 0b1; 2740 let Inst{20-16} = imm{4-0}; 2741 let Inst{15-13} = Qd{2-0}; 2742 let Inst{12-4} = 0b011111100; 2743 let Inst{3-0} = RdmDest{3-0}; 2744} 2745 2746class MVE_shift_imm<dag oops, dag iops, string iname, string suffix, 2747 string ops, vpred_ops vpred, string cstr, 2748 bits<2> vecsize, list<dag> pattern=[]> 2749 : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, vecsize, pattern> { 2750 bits<4> Qd; 2751 bits<4> Qm; 2752 2753 let Inst{22} = Qd{3}; 2754 let Inst{15-13} = Qd{2-0}; 2755 let Inst{5} = Qm{3}; 2756 let Inst{3-1} = Qm{2-0}; 2757} 2758 2759class MVE_VMOVL<string iname, string suffix, bits<2> sz, bit U, bit top, 2760 list<dag> pattern=[]> 2761 : MVE_shift_imm<(outs MQPR:$Qd), (ins MQPR:$Qm), 2762 iname, suffix, "$Qd, $Qm", vpred_r, "", 2763 sz, pattern> { 2764 let Inst{28} = U; 2765 let Inst{25-23} = 0b101; 2766 let Inst{21} = 0b1; 2767 let Inst{20-19} = sz{1-0}; 2768 let Inst{18-16} = 0b000; 2769 let Inst{12} = top; 2770 let Inst{11-6} = 0b111101; 2771 let Inst{4} = 0b0; 2772 let Inst{0} = 0b0; 2773 let doubleWidthResult = 1; 2774} 2775 2776multiclass MVE_VMOVL_m<bit top, string chr, MVEVectorVTInfo OutVTI, 2777 MVEVectorVTInfo InVTI> { 2778 def "": MVE_VMOVL<"vmovl" # chr, InVTI.Suffix, OutVTI.Size, 2779 InVTI.Unsigned, top>; 2780 defvar Inst = !cast<Instruction>(NAME); 2781 2782 def : Pat<(OutVTI.Vec (int_arm_mve_vmovl_predicated (InVTI.Vec MQPR:$src), 2783 (i32 InVTI.Unsigned), (i32 top), 2784 (OutVTI.Pred VCCR:$pred), 2785 (OutVTI.Vec MQPR:$inactive))), 2786 (OutVTI.Vec (Inst (InVTI.Vec MQPR:$src), ARMVCCThen, 2787 (OutVTI.Pred VCCR:$pred), zero_reg, 2788 (OutVTI.Vec MQPR:$inactive)))>; 2789} 2790 2791defm MVE_VMOVLs8bh : MVE_VMOVL_m<0, "b", MVE_v8s16, MVE_v16s8>; 2792defm MVE_VMOVLs8th : MVE_VMOVL_m<1, "t", MVE_v8s16, MVE_v16s8>; 2793defm MVE_VMOVLu8bh : MVE_VMOVL_m<0, "b", MVE_v8u16, MVE_v16u8>; 2794defm MVE_VMOVLu8th : MVE_VMOVL_m<1, "t", MVE_v8u16, MVE_v16u8>; 2795defm MVE_VMOVLs16bh : MVE_VMOVL_m<0, "b", MVE_v4s32, MVE_v8s16>; 2796defm MVE_VMOVLs16th : MVE_VMOVL_m<1, "t", MVE_v4s32, MVE_v8s16>; 2797defm MVE_VMOVLu16bh : MVE_VMOVL_m<0, "b", MVE_v4s32, MVE_v8u16>; 2798defm MVE_VMOVLu16th : MVE_VMOVL_m<1, "t", MVE_v4s32, MVE_v8u16>; 2799 2800let Predicates = [HasMVEInt] in { 2801 def : Pat<(sext_inreg (v4i32 MQPR:$src), v4i16), 2802 (MVE_VMOVLs16bh MQPR:$src)>; 2803 def : Pat<(sext_inreg (v8i16 MQPR:$src), v8i8), 2804 (MVE_VMOVLs8bh MQPR:$src)>; 2805 def : Pat<(sext_inreg (v4i32 MQPR:$src), v4i8), 2806 (MVE_VMOVLs16bh (MVE_VMOVLs8bh MQPR:$src))>; 2807 2808 def : Pat<(sext_inreg (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src)))), v8i8), 2809 (MVE_VMOVLs8th MQPR:$src)>; 2810 def : Pat<(sext_inreg (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src)))), v4i16), 2811 (MVE_VMOVLs16th MQPR:$src)>; 2812 2813 // zext_inreg 8 -> 16 2814 def : Pat<(ARMvbicImm (v8i16 MQPR:$src), (i32 0xAFF)), 2815 (MVE_VMOVLu8bh MQPR:$src)>; 2816 // zext_inreg 16 -> 32 2817 def : Pat<(and (v4i32 MQPR:$src), (v4i32 (ARMvmovImm (i32 0xCFF)))), 2818 (MVE_VMOVLu16bh MQPR:$src)>; 2819 // Same zext_inreg with vrevs, picking the top half 2820 def : Pat<(ARMvbicImm (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src)))), (i32 0xAFF)), 2821 (MVE_VMOVLu8th MQPR:$src)>; 2822 def : Pat<(and (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src)))), 2823 (v4i32 (ARMvmovImm (i32 0xCFF)))), 2824 (MVE_VMOVLu16th MQPR:$src)>; 2825} 2826 2827 2828class MVE_VSHLL_imm<string iname, string suffix, bit U, bit th, 2829 Operand immtype, bits<2> vecsize, list<dag> pattern=[]> 2830 : MVE_shift_imm<(outs MQPR:$Qd), (ins MQPR:$Qm, immtype:$imm), 2831 iname, suffix, "$Qd, $Qm, $imm", vpred_r, "", vecsize, pattern> { 2832 let Inst{28} = U; 2833 let Inst{25-23} = 0b101; 2834 let Inst{21} = 0b1; 2835 let Inst{12} = th; 2836 let Inst{11-6} = 0b111101; 2837 let Inst{4} = 0b0; 2838 let Inst{0} = 0b0; 2839 2840 // For the MVE_VSHLL_patterns multiclass to refer to 2841 Operand immediateType = immtype; 2842 2843 let doubleWidthResult = 1; 2844} 2845 2846// The immediate VSHLL instructions accept shift counts from 1 up to 2847// the lane width (8 or 16), but the full-width shifts have an 2848// entirely separate encoding, given below with 'lw' in the name. 2849 2850class MVE_VSHLL_imm8<string iname, string suffix, 2851 bit U, bit th, list<dag> pattern=[]> 2852 : MVE_VSHLL_imm<iname, suffix, U, th, mve_shift_imm1_7, 0b01, pattern> { 2853 bits<3> imm; 2854 let Inst{20-19} = 0b01; 2855 let Inst{18-16} = imm; 2856} 2857 2858class MVE_VSHLL_imm16<string iname, string suffix, 2859 bit U, bit th, list<dag> pattern=[]> 2860 : MVE_VSHLL_imm<iname, suffix, U, th, mve_shift_imm1_15, 0b10, pattern> { 2861 bits<4> imm; 2862 let Inst{20} = 0b1; 2863 let Inst{19-16} = imm; 2864} 2865 2866def MVE_VSHLL_imms8bh : MVE_VSHLL_imm8 <"vshllb", "s8", 0b0, 0b0>; 2867def MVE_VSHLL_imms8th : MVE_VSHLL_imm8 <"vshllt", "s8", 0b0, 0b1>; 2868def MVE_VSHLL_immu8bh : MVE_VSHLL_imm8 <"vshllb", "u8", 0b1, 0b0>; 2869def MVE_VSHLL_immu8th : MVE_VSHLL_imm8 <"vshllt", "u8", 0b1, 0b1>; 2870def MVE_VSHLL_imms16bh : MVE_VSHLL_imm16<"vshllb", "s16", 0b0, 0b0>; 2871def MVE_VSHLL_imms16th : MVE_VSHLL_imm16<"vshllt", "s16", 0b0, 0b1>; 2872def MVE_VSHLL_immu16bh : MVE_VSHLL_imm16<"vshllb", "u16", 0b1, 0b0>; 2873def MVE_VSHLL_immu16th : MVE_VSHLL_imm16<"vshllt", "u16", 0b1, 0b1>; 2874 2875class MVE_VSHLL_by_lane_width<string iname, string suffix, bits<2> size, 2876 bit U, string ops, list<dag> pattern=[]> 2877 : MVE_shift_imm<(outs MQPR:$Qd), (ins MQPR:$Qm), 2878 iname, suffix, ops, vpred_r, "", !if(size, 0b10, 0b01), pattern> { 2879 let Inst{28} = U; 2880 let Inst{25-23} = 0b100; 2881 let Inst{21-20} = 0b11; 2882 let Inst{19-18} = size{1-0}; 2883 let Inst{17-16} = 0b01; 2884 let Inst{11-6} = 0b111000; 2885 let Inst{4} = 0b0; 2886 let Inst{0} = 0b1; 2887 let doubleWidthResult = 1; 2888} 2889 2890multiclass MVE_VSHLL_lw<string iname, string suffix, bits<2> sz, bit U, 2891 string ops, list<dag> pattern=[]> { 2892 def bh : MVE_VSHLL_by_lane_width<iname#"b", suffix, sz, U, ops, pattern> { 2893 let Inst{12} = 0b0; 2894 } 2895 def th : MVE_VSHLL_by_lane_width<iname#"t", suffix, sz, U, ops, pattern> { 2896 let Inst{12} = 0b1; 2897 } 2898} 2899 2900defm MVE_VSHLL_lws8 : MVE_VSHLL_lw<"vshll", "s8", 0b00, 0b0, "$Qd, $Qm, #8">; 2901defm MVE_VSHLL_lws16 : MVE_VSHLL_lw<"vshll", "s16", 0b01, 0b0, "$Qd, $Qm, #16">; 2902defm MVE_VSHLL_lwu8 : MVE_VSHLL_lw<"vshll", "u8", 0b00, 0b1, "$Qd, $Qm, #8">; 2903defm MVE_VSHLL_lwu16 : MVE_VSHLL_lw<"vshll", "u16", 0b01, 0b1, "$Qd, $Qm, #16">; 2904 2905multiclass MVE_VSHLL_patterns<MVEVectorVTInfo VTI, int top> { 2906 defvar suffix = !strconcat(VTI.Suffix, !if(top, "th", "bh")); 2907 defvar inst_imm = !cast<MVE_VSHLL_imm>("MVE_VSHLL_imm" # suffix); 2908 defvar inst_lw = !cast<MVE_VSHLL_by_lane_width>("MVE_VSHLL_lw" # suffix); 2909 defvar unpred_int = int_arm_mve_vshll_imm; 2910 defvar pred_int = int_arm_mve_vshll_imm_predicated; 2911 defvar imm = inst_imm.immediateType; 2912 2913 def : Pat<(VTI.DblVec (unpred_int (VTI.Vec MQPR:$src), imm:$imm, 2914 (i32 VTI.Unsigned), (i32 top))), 2915 (VTI.DblVec (inst_imm (VTI.Vec MQPR:$src), imm:$imm))>; 2916 def : Pat<(VTI.DblVec (unpred_int (VTI.Vec MQPR:$src), (i32 VTI.LaneBits), 2917 (i32 VTI.Unsigned), (i32 top))), 2918 (VTI.DblVec (inst_lw (VTI.Vec MQPR:$src)))>; 2919 2920 def : Pat<(VTI.DblVec (pred_int (VTI.Vec MQPR:$src), imm:$imm, 2921 (i32 VTI.Unsigned), (i32 top), 2922 (VTI.DblPred VCCR:$mask), 2923 (VTI.DblVec MQPR:$inactive))), 2924 (VTI.DblVec (inst_imm (VTI.Vec MQPR:$src), imm:$imm, 2925 ARMVCCThen, (VTI.DblPred VCCR:$mask), zero_reg, 2926 (VTI.DblVec MQPR:$inactive)))>; 2927 def : Pat<(VTI.DblVec (pred_int (VTI.Vec MQPR:$src), (i32 VTI.LaneBits), 2928 (i32 VTI.Unsigned), (i32 top), 2929 (VTI.DblPred VCCR:$mask), 2930 (VTI.DblVec MQPR:$inactive))), 2931 (VTI.DblVec (inst_lw (VTI.Vec MQPR:$src), ARMVCCThen, 2932 (VTI.DblPred VCCR:$mask), zero_reg, 2933 (VTI.DblVec MQPR:$inactive)))>; 2934} 2935 2936foreach VTI = [MVE_v16s8, MVE_v8s16, MVE_v16u8, MVE_v8u16] in 2937 foreach top = [0, 1] in 2938 defm : MVE_VSHLL_patterns<VTI, top>; 2939 2940class MVE_shift_imm_partial<Operand imm, string iname, string suffix, bits<2> vecsize> 2941 : MVE_shift_imm<(outs MQPR:$Qd), (ins MQPR:$QdSrc, MQPR:$Qm, imm:$imm), 2942 iname, suffix, "$Qd, $Qm, $imm", vpred_n, "$Qd = $QdSrc", vecsize> { 2943 Operand immediateType = imm; 2944} 2945 2946class MVE_VxSHRN<string iname, string suffix, bit bit_12, bit bit_28, 2947 Operand imm, bits<2> vecsize> 2948 : MVE_shift_imm_partial<imm, iname, suffix, vecsize> { 2949 bits<5> imm; 2950 2951 let Inst{28} = bit_28; 2952 let Inst{25-23} = 0b101; 2953 let Inst{21} = 0b0; 2954 let Inst{20-16} = imm{4-0}; 2955 let Inst{12} = bit_12; 2956 let Inst{11-6} = 0b111111; 2957 let Inst{4} = 0b0; 2958 let Inst{0} = 0b1; 2959 let validForTailPredication = 1; 2960 let retainsPreviousHalfElement = 1; 2961} 2962 2963def MVE_VRSHRNi16bh : MVE_VxSHRN<"vrshrnb", "i16", 0b0, 0b1, shr_imm8, 0b01> { 2964 let Inst{20-19} = 0b01; 2965} 2966def MVE_VRSHRNi16th : MVE_VxSHRN<"vrshrnt", "i16", 0b1, 0b1, shr_imm8, 0b01> { 2967 let Inst{20-19} = 0b01; 2968} 2969def MVE_VRSHRNi32bh : MVE_VxSHRN<"vrshrnb", "i32", 0b0, 0b1, shr_imm16, 0b10> { 2970 let Inst{20} = 0b1; 2971} 2972def MVE_VRSHRNi32th : MVE_VxSHRN<"vrshrnt", "i32", 0b1, 0b1, shr_imm16, 0b10> { 2973 let Inst{20} = 0b1; 2974} 2975 2976def MVE_VSHRNi16bh : MVE_VxSHRN<"vshrnb", "i16", 0b0, 0b0, shr_imm8, 0b01> { 2977 let Inst{20-19} = 0b01; 2978} 2979def MVE_VSHRNi16th : MVE_VxSHRN<"vshrnt", "i16", 0b1, 0b0, shr_imm8, 0b01> { 2980 let Inst{20-19} = 0b01; 2981} 2982def MVE_VSHRNi32bh : MVE_VxSHRN<"vshrnb", "i32", 0b0, 0b0, shr_imm16, 0b10> { 2983 let Inst{20} = 0b1; 2984} 2985def MVE_VSHRNi32th : MVE_VxSHRN<"vshrnt", "i32", 0b1, 0b0, shr_imm16, 0b10> { 2986 let Inst{20} = 0b1; 2987} 2988 2989class MVE_VxQRSHRUN<string iname, string suffix, bit bit_28, bit bit_12, 2990 Operand imm, bits<2> vecsize> 2991 : MVE_shift_imm_partial<imm, iname, suffix, vecsize> { 2992 bits<5> imm; 2993 2994 let Inst{28} = bit_28; 2995 let Inst{25-23} = 0b101; 2996 let Inst{21} = 0b0; 2997 let Inst{20-16} = imm{4-0}; 2998 let Inst{12} = bit_12; 2999 let Inst{11-6} = 0b111111; 3000 let Inst{4} = 0b0; 3001 let Inst{0} = 0b0; 3002 let validForTailPredication = 1; 3003 let retainsPreviousHalfElement = 1; 3004} 3005 3006def MVE_VQRSHRUNs16bh : MVE_VxQRSHRUN< 3007 "vqrshrunb", "s16", 0b1, 0b0, shr_imm8, 0b01> { 3008 let Inst{20-19} = 0b01; 3009} 3010def MVE_VQRSHRUNs16th : MVE_VxQRSHRUN< 3011 "vqrshrunt", "s16", 0b1, 0b1, shr_imm8, 0b01> { 3012 let Inst{20-19} = 0b01; 3013} 3014def MVE_VQRSHRUNs32bh : MVE_VxQRSHRUN< 3015 "vqrshrunb", "s32", 0b1, 0b0, shr_imm16, 0b10> { 3016 let Inst{20} = 0b1; 3017} 3018def MVE_VQRSHRUNs32th : MVE_VxQRSHRUN< 3019 "vqrshrunt", "s32", 0b1, 0b1, shr_imm16, 0b10> { 3020 let Inst{20} = 0b1; 3021} 3022 3023def MVE_VQSHRUNs16bh : MVE_VxQRSHRUN< 3024 "vqshrunb", "s16", 0b0, 0b0, shr_imm8, 0b01> { 3025 let Inst{20-19} = 0b01; 3026} 3027def MVE_VQSHRUNs16th : MVE_VxQRSHRUN< 3028 "vqshrunt", "s16", 0b0, 0b1, shr_imm8, 0b01> { 3029 let Inst{20-19} = 0b01; 3030} 3031def MVE_VQSHRUNs32bh : MVE_VxQRSHRUN< 3032 "vqshrunb", "s32", 0b0, 0b0, shr_imm16, 0b10> { 3033 let Inst{20} = 0b1; 3034} 3035def MVE_VQSHRUNs32th : MVE_VxQRSHRUN< 3036 "vqshrunt", "s32", 0b0, 0b1, shr_imm16, 0b10> { 3037 let Inst{20} = 0b1; 3038} 3039 3040class MVE_VxQRSHRN<string iname, string suffix, bit bit_0, bit bit_12, 3041 Operand imm, bits<2> vecsize> 3042 : MVE_shift_imm_partial<imm, iname, suffix, vecsize> { 3043 bits<5> imm; 3044 3045 let Inst{25-23} = 0b101; 3046 let Inst{21} = 0b0; 3047 let Inst{20-16} = imm{4-0}; 3048 let Inst{12} = bit_12; 3049 let Inst{11-6} = 0b111101; 3050 let Inst{4} = 0b0; 3051 let Inst{0} = bit_0; 3052 let validForTailPredication = 1; 3053 let retainsPreviousHalfElement = 1; 3054} 3055 3056multiclass MVE_VxQRSHRN_types<string iname, bit bit_0, bit bit_12> { 3057 def s16 : MVE_VxQRSHRN<iname, "s16", bit_0, bit_12, shr_imm8, 0b01> { 3058 let Inst{28} = 0b0; 3059 let Inst{20-19} = 0b01; 3060 } 3061 def u16 : MVE_VxQRSHRN<iname, "u16", bit_0, bit_12, shr_imm8, 0b01> { 3062 let Inst{28} = 0b1; 3063 let Inst{20-19} = 0b01; 3064 } 3065 def s32 : MVE_VxQRSHRN<iname, "s32", bit_0, bit_12, shr_imm16, 0b10> { 3066 let Inst{28} = 0b0; 3067 let Inst{20} = 0b1; 3068 } 3069 def u32 : MVE_VxQRSHRN<iname, "u32", bit_0, bit_12, shr_imm16, 0b10> { 3070 let Inst{28} = 0b1; 3071 let Inst{20} = 0b1; 3072 } 3073} 3074 3075defm MVE_VQRSHRNbh : MVE_VxQRSHRN_types<"vqrshrnb", 0b1, 0b0>; 3076defm MVE_VQRSHRNth : MVE_VxQRSHRN_types<"vqrshrnt", 0b1, 0b1>; 3077defm MVE_VQSHRNbh : MVE_VxQRSHRN_types<"vqshrnb", 0b0, 0b0>; 3078defm MVE_VQSHRNth : MVE_VxQRSHRN_types<"vqshrnt", 0b0, 0b1>; 3079 3080multiclass MVE_VSHRN_patterns<MVE_shift_imm_partial inst, 3081 MVEVectorVTInfo OutVTI, MVEVectorVTInfo InVTI, 3082 bit q, bit r, bit top> { 3083 defvar inparams = (? (OutVTI.Vec MQPR:$QdSrc), (InVTI.Vec MQPR:$Qm), 3084 (inst.immediateType:$imm), (i32 q), (i32 r), 3085 (i32 OutVTI.Unsigned), (i32 InVTI.Unsigned), (i32 top)); 3086 defvar outparams = (inst (OutVTI.Vec MQPR:$QdSrc), (InVTI.Vec MQPR:$Qm), 3087 (imm:$imm)); 3088 3089 def : Pat<(OutVTI.Vec !setdagop(inparams, int_arm_mve_vshrn)), 3090 (OutVTI.Vec outparams)>; 3091 def : Pat<(OutVTI.Vec !con(inparams, (int_arm_mve_vshrn_predicated 3092 (InVTI.Pred VCCR:$pred)))), 3093 (OutVTI.Vec !con(outparams, (? ARMVCCThen, VCCR:$pred, zero_reg)))>; 3094} 3095 3096defm : MVE_VSHRN_patterns<MVE_VSHRNi16bh, MVE_v16s8, MVE_v8s16, 0,0,0>; 3097defm : MVE_VSHRN_patterns<MVE_VSHRNi16th, MVE_v16s8, MVE_v8s16, 0,0,1>; 3098defm : MVE_VSHRN_patterns<MVE_VSHRNi32bh, MVE_v8s16, MVE_v4s32, 0,0,0>; 3099defm : MVE_VSHRN_patterns<MVE_VSHRNi32th, MVE_v8s16, MVE_v4s32, 0,0,1>; 3100defm : MVE_VSHRN_patterns<MVE_VSHRNi16bh, MVE_v16u8, MVE_v8u16, 0,0,0>; 3101defm : MVE_VSHRN_patterns<MVE_VSHRNi16th, MVE_v16u8, MVE_v8u16, 0,0,1>; 3102defm : MVE_VSHRN_patterns<MVE_VSHRNi32bh, MVE_v8u16, MVE_v4u32, 0,0,0>; 3103defm : MVE_VSHRN_patterns<MVE_VSHRNi32th, MVE_v8u16, MVE_v4u32, 0,0,1>; 3104defm : MVE_VSHRN_patterns<MVE_VRSHRNi16bh, MVE_v16s8, MVE_v8s16, 0,1,0>; 3105defm : MVE_VSHRN_patterns<MVE_VRSHRNi16th, MVE_v16s8, MVE_v8s16, 0,1,1>; 3106defm : MVE_VSHRN_patterns<MVE_VRSHRNi32bh, MVE_v8s16, MVE_v4s32, 0,1,0>; 3107defm : MVE_VSHRN_patterns<MVE_VRSHRNi32th, MVE_v8s16, MVE_v4s32, 0,1,1>; 3108defm : MVE_VSHRN_patterns<MVE_VRSHRNi16bh, MVE_v16u8, MVE_v8u16, 0,1,0>; 3109defm : MVE_VSHRN_patterns<MVE_VRSHRNi16th, MVE_v16u8, MVE_v8u16, 0,1,1>; 3110defm : MVE_VSHRN_patterns<MVE_VRSHRNi32bh, MVE_v8u16, MVE_v4u32, 0,1,0>; 3111defm : MVE_VSHRN_patterns<MVE_VRSHRNi32th, MVE_v8u16, MVE_v4u32, 0,1,1>; 3112defm : MVE_VSHRN_patterns<MVE_VQSHRNbhs16, MVE_v16s8, MVE_v8s16, 1,0,0>; 3113defm : MVE_VSHRN_patterns<MVE_VQSHRNths16, MVE_v16s8, MVE_v8s16, 1,0,1>; 3114defm : MVE_VSHRN_patterns<MVE_VQSHRNbhs32, MVE_v8s16, MVE_v4s32, 1,0,0>; 3115defm : MVE_VSHRN_patterns<MVE_VQSHRNths32, MVE_v8s16, MVE_v4s32, 1,0,1>; 3116defm : MVE_VSHRN_patterns<MVE_VQSHRNbhu16, MVE_v16u8, MVE_v8u16, 1,0,0>; 3117defm : MVE_VSHRN_patterns<MVE_VQSHRNthu16, MVE_v16u8, MVE_v8u16, 1,0,1>; 3118defm : MVE_VSHRN_patterns<MVE_VQSHRNbhu32, MVE_v8u16, MVE_v4u32, 1,0,0>; 3119defm : MVE_VSHRN_patterns<MVE_VQSHRNthu32, MVE_v8u16, MVE_v4u32, 1,0,1>; 3120defm : MVE_VSHRN_patterns<MVE_VQRSHRNbhs16, MVE_v16s8, MVE_v8s16, 1,1,0>; 3121defm : MVE_VSHRN_patterns<MVE_VQRSHRNths16, MVE_v16s8, MVE_v8s16, 1,1,1>; 3122defm : MVE_VSHRN_patterns<MVE_VQRSHRNbhs32, MVE_v8s16, MVE_v4s32, 1,1,0>; 3123defm : MVE_VSHRN_patterns<MVE_VQRSHRNths32, MVE_v8s16, MVE_v4s32, 1,1,1>; 3124defm : MVE_VSHRN_patterns<MVE_VQRSHRNbhu16, MVE_v16u8, MVE_v8u16, 1,1,0>; 3125defm : MVE_VSHRN_patterns<MVE_VQRSHRNthu16, MVE_v16u8, MVE_v8u16, 1,1,1>; 3126defm : MVE_VSHRN_patterns<MVE_VQRSHRNbhu32, MVE_v8u16, MVE_v4u32, 1,1,0>; 3127defm : MVE_VSHRN_patterns<MVE_VQRSHRNthu32, MVE_v8u16, MVE_v4u32, 1,1,1>; 3128defm : MVE_VSHRN_patterns<MVE_VQSHRUNs16bh, MVE_v16u8, MVE_v8s16, 1,0,0>; 3129defm : MVE_VSHRN_patterns<MVE_VQSHRUNs16th, MVE_v16u8, MVE_v8s16, 1,0,1>; 3130defm : MVE_VSHRN_patterns<MVE_VQSHRUNs32bh, MVE_v8u16, MVE_v4s32, 1,0,0>; 3131defm : MVE_VSHRN_patterns<MVE_VQSHRUNs32th, MVE_v8u16, MVE_v4s32, 1,0,1>; 3132defm : MVE_VSHRN_patterns<MVE_VQRSHRUNs16bh, MVE_v16u8, MVE_v8s16, 1,1,0>; 3133defm : MVE_VSHRN_patterns<MVE_VQRSHRUNs16th, MVE_v16u8, MVE_v8s16, 1,1,1>; 3134defm : MVE_VSHRN_patterns<MVE_VQRSHRUNs32bh, MVE_v8u16, MVE_v4s32, 1,1,0>; 3135defm : MVE_VSHRN_patterns<MVE_VQRSHRUNs32th, MVE_v8u16, MVE_v4s32, 1,1,1>; 3136 3137// end of mve_imm_shift instructions 3138 3139// start of mve_shift instructions 3140 3141class MVE_shift_by_vec<string iname, string suffix, bit U, 3142 bits<2> size, bit bit_4, bit bit_8> 3143 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qm, MQPR:$Qn), NoItinerary, 3144 iname, suffix, "$Qd, $Qm, $Qn", vpred_r, "", size, []> { 3145 // Shift instructions which take a vector of shift counts 3146 bits<4> Qd; 3147 bits<4> Qm; 3148 bits<4> Qn; 3149 3150 let Inst{28} = U; 3151 let Inst{25-24} = 0b11; 3152 let Inst{23} = 0b0; 3153 let Inst{22} = Qd{3}; 3154 let Inst{21-20} = size; 3155 let Inst{19-17} = Qn{2-0}; 3156 let Inst{16} = 0b0; 3157 let Inst{15-13} = Qd{2-0}; 3158 let Inst{12-9} = 0b0010; 3159 let Inst{8} = bit_8; 3160 let Inst{7} = Qn{3}; 3161 let Inst{6} = 0b1; 3162 let Inst{5} = Qm{3}; 3163 let Inst{4} = bit_4; 3164 let Inst{3-1} = Qm{2-0}; 3165 let Inst{0} = 0b0; 3166 let validForTailPredication = 1; 3167} 3168 3169multiclass MVE_shift_by_vec_p<string iname, MVEVectorVTInfo VTI, bit q, bit r> { 3170 def "" : MVE_shift_by_vec<iname, VTI.Suffix, VTI.Unsigned, VTI.Size, q, r>; 3171 defvar Inst = !cast<Instruction>(NAME); 3172 3173 def : Pat<(VTI.Vec (int_arm_mve_vshl_vector 3174 (VTI.Vec MQPR:$in), (VTI.Vec MQPR:$sh), 3175 (i32 q), (i32 r), (i32 VTI.Unsigned))), 3176 (VTI.Vec (Inst (VTI.Vec MQPR:$in), (VTI.Vec MQPR:$sh)))>; 3177 3178 def : Pat<(VTI.Vec (int_arm_mve_vshl_vector_predicated 3179 (VTI.Vec MQPR:$in), (VTI.Vec MQPR:$sh), 3180 (i32 q), (i32 r), (i32 VTI.Unsigned), 3181 (VTI.Pred VCCR:$mask), (VTI.Vec MQPR:$inactive))), 3182 (VTI.Vec (Inst (VTI.Vec MQPR:$in), (VTI.Vec MQPR:$sh), 3183 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 3184 (VTI.Vec MQPR:$inactive)))>; 3185} 3186 3187multiclass mve_shift_by_vec_multi<string iname, bit bit_4, bit bit_8> { 3188 defm s8 : MVE_shift_by_vec_p<iname, MVE_v16s8, bit_4, bit_8>; 3189 defm s16 : MVE_shift_by_vec_p<iname, MVE_v8s16, bit_4, bit_8>; 3190 defm s32 : MVE_shift_by_vec_p<iname, MVE_v4s32, bit_4, bit_8>; 3191 defm u8 : MVE_shift_by_vec_p<iname, MVE_v16u8, bit_4, bit_8>; 3192 defm u16 : MVE_shift_by_vec_p<iname, MVE_v8u16, bit_4, bit_8>; 3193 defm u32 : MVE_shift_by_vec_p<iname, MVE_v4u32, bit_4, bit_8>; 3194} 3195 3196defm MVE_VSHL_by_vec : mve_shift_by_vec_multi<"vshl", 0b0, 0b0>; 3197defm MVE_VQSHL_by_vec : mve_shift_by_vec_multi<"vqshl", 0b1, 0b0>; 3198defm MVE_VQRSHL_by_vec : mve_shift_by_vec_multi<"vqrshl", 0b1, 0b1>; 3199defm MVE_VRSHL_by_vec : mve_shift_by_vec_multi<"vrshl", 0b0, 0b1>; 3200 3201let Predicates = [HasMVEInt] in { 3202 def : Pat<(v4i32 (ARMvshlu (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn))), 3203 (v4i32 (MVE_VSHL_by_vecu32 (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn)))>; 3204 def : Pat<(v8i16 (ARMvshlu (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn))), 3205 (v8i16 (MVE_VSHL_by_vecu16 (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn)))>; 3206 def : Pat<(v16i8 (ARMvshlu (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn))), 3207 (v16i8 (MVE_VSHL_by_vecu8 (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn)))>; 3208 3209 def : Pat<(v4i32 (ARMvshls (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn))), 3210 (v4i32 (MVE_VSHL_by_vecs32 (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn)))>; 3211 def : Pat<(v8i16 (ARMvshls (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn))), 3212 (v8i16 (MVE_VSHL_by_vecs16 (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn)))>; 3213 def : Pat<(v16i8 (ARMvshls (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn))), 3214 (v16i8 (MVE_VSHL_by_vecs8 (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn)))>; 3215} 3216 3217class MVE_shift_with_imm<string iname, string suffix, dag oops, dag iops, 3218 string ops, vpred_ops vpred, string cstr, 3219 bits<2> vecsize, list<dag> pattern=[]> 3220 : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, vecsize, pattern> { 3221 bits<4> Qd; 3222 bits<4> Qm; 3223 3224 let Inst{23} = 0b1; 3225 let Inst{22} = Qd{3}; 3226 let Inst{15-13} = Qd{2-0}; 3227 let Inst{12-11} = 0b00; 3228 let Inst{7-6} = 0b01; 3229 let Inst{5} = Qm{3}; 3230 let Inst{4} = 0b1; 3231 let Inst{3-1} = Qm{2-0}; 3232 let Inst{0} = 0b0; 3233 let validForTailPredication = 1; 3234 3235 // For the MVE_shift_imm_patterns multiclass to refer to 3236 MVEVectorVTInfo VTI; 3237 Operand immediateType; 3238 Intrinsic unpred_int; 3239 Intrinsic pred_int; 3240 dag unsignedFlag = (?); 3241} 3242 3243class MVE_VSxI_imm<string iname, string suffix, bit bit_8, Operand immType, bits<2> vecsize> 3244 : MVE_shift_with_imm<iname, suffix, (outs MQPR:$Qd), 3245 (ins MQPR:$Qd_src, MQPR:$Qm, immType:$imm), 3246 "$Qd, $Qm, $imm", vpred_n, "$Qd = $Qd_src", vecsize> { 3247 bits<6> imm; 3248 let Inst{28} = 0b1; 3249 let Inst{25-24} = 0b11; 3250 let Inst{21-16} = imm; 3251 let Inst{10-9} = 0b10; 3252 let Inst{8} = bit_8; 3253 let validForTailPredication = 1; 3254 3255 Operand immediateType = immType; 3256} 3257 3258def MVE_VSRIimm8 : MVE_VSxI_imm<"vsri", "8", 0b0, shr_imm8, 0b00> { 3259 let Inst{21-19} = 0b001; 3260} 3261 3262def MVE_VSRIimm16 : MVE_VSxI_imm<"vsri", "16", 0b0, shr_imm16, 0b01> { 3263 let Inst{21-20} = 0b01; 3264} 3265 3266def MVE_VSRIimm32 : MVE_VSxI_imm<"vsri", "32", 0b0, shr_imm32, 0b10> { 3267 let Inst{21} = 0b1; 3268} 3269 3270def MVE_VSLIimm8 : MVE_VSxI_imm<"vsli", "8", 0b1, imm0_7, 0b00> { 3271 let Inst{21-19} = 0b001; 3272} 3273 3274def MVE_VSLIimm16 : MVE_VSxI_imm<"vsli", "16", 0b1, imm0_15, 0b01> { 3275 let Inst{21-20} = 0b01; 3276} 3277 3278def MVE_VSLIimm32 : MVE_VSxI_imm<"vsli", "32", 0b1,imm0_31, 0b10> { 3279 let Inst{21} = 0b1; 3280} 3281 3282multiclass MVE_VSxI_patterns<MVE_VSxI_imm inst, string name, 3283 MVEVectorVTInfo VTI> { 3284 defvar inparams = (? (VTI.Vec MQPR:$QdSrc), (VTI.Vec MQPR:$Qm), 3285 (inst.immediateType:$imm)); 3286 defvar outparams = (inst (VTI.Vec MQPR:$QdSrc), (VTI.Vec MQPR:$Qm), 3287 (inst.immediateType:$imm)); 3288 defvar unpred_int = !cast<Intrinsic>("int_arm_mve_" # name); 3289 defvar pred_int = !cast<Intrinsic>("int_arm_mve_" # name # "_predicated"); 3290 3291 def : Pat<(VTI.Vec !setdagop(inparams, unpred_int)), 3292 (VTI.Vec outparams)>; 3293 def : Pat<(VTI.Vec !con(inparams, (pred_int (VTI.Pred VCCR:$pred)))), 3294 (VTI.Vec !con(outparams, (? ARMVCCThen, VCCR:$pred, zero_reg)))>; 3295} 3296 3297defm : MVE_VSxI_patterns<MVE_VSLIimm8, "vsli", MVE_v16i8>; 3298defm : MVE_VSxI_patterns<MVE_VSLIimm16, "vsli", MVE_v8i16>; 3299defm : MVE_VSxI_patterns<MVE_VSLIimm32, "vsli", MVE_v4i32>; 3300defm : MVE_VSxI_patterns<MVE_VSRIimm8, "vsri", MVE_v16i8>; 3301defm : MVE_VSxI_patterns<MVE_VSRIimm16, "vsri", MVE_v8i16>; 3302defm : MVE_VSxI_patterns<MVE_VSRIimm32, "vsri", MVE_v4i32>; 3303 3304class MVE_VQSHL_imm<MVEVectorVTInfo VTI_, Operand immType> 3305 : MVE_shift_with_imm<"vqshl", VTI_.Suffix, (outs MQPR:$Qd), 3306 (ins MQPR:$Qm, immType:$imm), "$Qd, $Qm, $imm", 3307 vpred_r, "", VTI_.Size> { 3308 bits<6> imm; 3309 3310 let Inst{28} = VTI_.Unsigned; 3311 let Inst{25-24} = 0b11; 3312 let Inst{21-16} = imm; 3313 let Inst{10-8} = 0b111; 3314 3315 let VTI = VTI_; 3316 let immediateType = immType; 3317 let unsignedFlag = (? (i32 VTI.Unsigned)); 3318} 3319 3320let unpred_int = int_arm_mve_vqshl_imm, 3321 pred_int = int_arm_mve_vqshl_imm_predicated in { 3322 def MVE_VQSHLimms8 : MVE_VQSHL_imm<MVE_v16s8, imm0_7> { 3323 let Inst{21-19} = 0b001; 3324 } 3325 def MVE_VQSHLimmu8 : MVE_VQSHL_imm<MVE_v16u8, imm0_7> { 3326 let Inst{21-19} = 0b001; 3327 } 3328 3329 def MVE_VQSHLimms16 : MVE_VQSHL_imm<MVE_v8s16, imm0_15> { 3330 let Inst{21-20} = 0b01; 3331 } 3332 def MVE_VQSHLimmu16 : MVE_VQSHL_imm<MVE_v8u16, imm0_15> { 3333 let Inst{21-20} = 0b01; 3334 } 3335 3336 def MVE_VQSHLimms32 : MVE_VQSHL_imm<MVE_v4s32, imm0_31> { 3337 let Inst{21} = 0b1; 3338 } 3339 def MVE_VQSHLimmu32 : MVE_VQSHL_imm<MVE_v4u32, imm0_31> { 3340 let Inst{21} = 0b1; 3341 } 3342} 3343 3344class MVE_VQSHLU_imm<MVEVectorVTInfo VTI_, Operand immType> 3345 : MVE_shift_with_imm<"vqshlu", VTI_.Suffix, (outs MQPR:$Qd), 3346 (ins MQPR:$Qm, immType:$imm), "$Qd, $Qm, $imm", 3347 vpred_r, "", VTI_.Size> { 3348 bits<6> imm; 3349 3350 let Inst{28} = 0b1; 3351 let Inst{25-24} = 0b11; 3352 let Inst{21-16} = imm; 3353 let Inst{10-8} = 0b110; 3354 3355 let VTI = VTI_; 3356 let immediateType = immType; 3357} 3358 3359let unpred_int = int_arm_mve_vqshlu_imm, 3360 pred_int = int_arm_mve_vqshlu_imm_predicated in { 3361 def MVE_VQSHLU_imms8 : MVE_VQSHLU_imm<MVE_v16s8, imm0_7> { 3362 let Inst{21-19} = 0b001; 3363 } 3364 3365 def MVE_VQSHLU_imms16 : MVE_VQSHLU_imm<MVE_v8s16, imm0_15> { 3366 let Inst{21-20} = 0b01; 3367 } 3368 3369 def MVE_VQSHLU_imms32 : MVE_VQSHLU_imm<MVE_v4s32, imm0_31> { 3370 let Inst{21} = 0b1; 3371 } 3372} 3373 3374class MVE_VRSHR_imm<MVEVectorVTInfo VTI_, Operand immType> 3375 : MVE_shift_with_imm<"vrshr", VTI_.Suffix, (outs MQPR:$Qd), 3376 (ins MQPR:$Qm, immType:$imm), "$Qd, $Qm, $imm", 3377 vpred_r, "", VTI_.Size> { 3378 bits<6> imm; 3379 3380 let Inst{28} = VTI_.Unsigned; 3381 let Inst{25-24} = 0b11; 3382 let Inst{21-16} = imm; 3383 let Inst{10-8} = 0b010; 3384 3385 let VTI = VTI_; 3386 let immediateType = immType; 3387 let unsignedFlag = (? (i32 VTI.Unsigned)); 3388} 3389 3390let unpred_int = int_arm_mve_vrshr_imm, 3391 pred_int = int_arm_mve_vrshr_imm_predicated in { 3392 def MVE_VRSHR_imms8 : MVE_VRSHR_imm<MVE_v16s8, shr_imm8> { 3393 let Inst{21-19} = 0b001; 3394 } 3395 3396 def MVE_VRSHR_immu8 : MVE_VRSHR_imm<MVE_v16u8, shr_imm8> { 3397 let Inst{21-19} = 0b001; 3398 } 3399 3400 def MVE_VRSHR_imms16 : MVE_VRSHR_imm<MVE_v8s16, shr_imm16> { 3401 let Inst{21-20} = 0b01; 3402 } 3403 3404 def MVE_VRSHR_immu16 : MVE_VRSHR_imm<MVE_v8u16, shr_imm16> { 3405 let Inst{21-20} = 0b01; 3406 } 3407 3408 def MVE_VRSHR_imms32 : MVE_VRSHR_imm<MVE_v4s32, shr_imm32> { 3409 let Inst{21} = 0b1; 3410 } 3411 3412 def MVE_VRSHR_immu32 : MVE_VRSHR_imm<MVE_v4u32, shr_imm32> { 3413 let Inst{21} = 0b1; 3414 } 3415} 3416 3417multiclass MVE_shift_imm_patterns<MVE_shift_with_imm inst> { 3418 def : Pat<(inst.VTI.Vec !con((inst.unpred_int (inst.VTI.Vec MQPR:$src), 3419 inst.immediateType:$imm), 3420 inst.unsignedFlag)), 3421 (inst.VTI.Vec (inst (inst.VTI.Vec MQPR:$src), 3422 inst.immediateType:$imm))>; 3423 3424 def : Pat<(inst.VTI.Vec !con((inst.pred_int (inst.VTI.Vec MQPR:$src), 3425 inst.immediateType:$imm), 3426 inst.unsignedFlag, 3427 (? (inst.VTI.Pred VCCR:$mask), 3428 (inst.VTI.Vec MQPR:$inactive)))), 3429 (inst.VTI.Vec (inst (inst.VTI.Vec MQPR:$src), 3430 inst.immediateType:$imm, 3431 ARMVCCThen, (inst.VTI.Pred VCCR:$mask), zero_reg, 3432 (inst.VTI.Vec MQPR:$inactive)))>; 3433} 3434 3435defm : MVE_shift_imm_patterns<MVE_VQSHLimms8>; 3436defm : MVE_shift_imm_patterns<MVE_VQSHLimmu8>; 3437defm : MVE_shift_imm_patterns<MVE_VQSHLimms16>; 3438defm : MVE_shift_imm_patterns<MVE_VQSHLimmu16>; 3439defm : MVE_shift_imm_patterns<MVE_VQSHLimms32>; 3440defm : MVE_shift_imm_patterns<MVE_VQSHLimmu32>; 3441defm : MVE_shift_imm_patterns<MVE_VQSHLU_imms8>; 3442defm : MVE_shift_imm_patterns<MVE_VQSHLU_imms16>; 3443defm : MVE_shift_imm_patterns<MVE_VQSHLU_imms32>; 3444defm : MVE_shift_imm_patterns<MVE_VRSHR_imms8>; 3445defm : MVE_shift_imm_patterns<MVE_VRSHR_immu8>; 3446defm : MVE_shift_imm_patterns<MVE_VRSHR_imms16>; 3447defm : MVE_shift_imm_patterns<MVE_VRSHR_immu16>; 3448defm : MVE_shift_imm_patterns<MVE_VRSHR_imms32>; 3449defm : MVE_shift_imm_patterns<MVE_VRSHR_immu32>; 3450 3451class MVE_VSHR_imm<string suffix, dag imm, bits<2> vecsize> 3452 : MVE_shift_with_imm<"vshr", suffix, (outs MQPR:$Qd), 3453 !con((ins MQPR:$Qm), imm), "$Qd, $Qm, $imm", 3454 vpred_r, "", vecsize> { 3455 bits<6> imm; 3456 3457 let Inst{25-24} = 0b11; 3458 let Inst{21-16} = imm; 3459 let Inst{10-8} = 0b000; 3460} 3461 3462def MVE_VSHR_imms8 : MVE_VSHR_imm<"s8", (ins shr_imm8:$imm), 0b00> { 3463 let Inst{28} = 0b0; 3464 let Inst{21-19} = 0b001; 3465} 3466 3467def MVE_VSHR_immu8 : MVE_VSHR_imm<"u8", (ins shr_imm8:$imm), 0b00> { 3468 let Inst{28} = 0b1; 3469 let Inst{21-19} = 0b001; 3470} 3471 3472def MVE_VSHR_imms16 : MVE_VSHR_imm<"s16", (ins shr_imm16:$imm), 0b01> { 3473 let Inst{28} = 0b0; 3474 let Inst{21-20} = 0b01; 3475} 3476 3477def MVE_VSHR_immu16 : MVE_VSHR_imm<"u16", (ins shr_imm16:$imm), 0b01> { 3478 let Inst{28} = 0b1; 3479 let Inst{21-20} = 0b01; 3480} 3481 3482def MVE_VSHR_imms32 : MVE_VSHR_imm<"s32", (ins shr_imm32:$imm), 0b10> { 3483 let Inst{28} = 0b0; 3484 let Inst{21} = 0b1; 3485} 3486 3487def MVE_VSHR_immu32 : MVE_VSHR_imm<"u32", (ins shr_imm32:$imm), 0b10> { 3488 let Inst{28} = 0b1; 3489 let Inst{21} = 0b1; 3490} 3491 3492class MVE_VSHL_imm<string suffix, dag imm, bits<2> vecsize> 3493 : MVE_shift_with_imm<"vshl", suffix, (outs MQPR:$Qd), 3494 !con((ins MQPR:$Qm), imm), "$Qd, $Qm, $imm", 3495 vpred_r, "", vecsize> { 3496 bits<6> imm; 3497 3498 let Inst{28} = 0b0; 3499 let Inst{25-24} = 0b11; 3500 let Inst{21-16} = imm; 3501 let Inst{10-8} = 0b101; 3502} 3503 3504def MVE_VSHL_immi8 : MVE_VSHL_imm<"i8", (ins imm0_7:$imm), 0b00> { 3505 let Inst{21-19} = 0b001; 3506} 3507 3508def MVE_VSHL_immi16 : MVE_VSHL_imm<"i16", (ins imm0_15:$imm), 0b01> { 3509 let Inst{21-20} = 0b01; 3510} 3511 3512def MVE_VSHL_immi32 : MVE_VSHL_imm<"i32", (ins imm0_31:$imm), 0b10> { 3513 let Inst{21} = 0b1; 3514} 3515 3516multiclass MVE_immediate_shift_patterns_inner< 3517 MVEVectorVTInfo VTI, Operand imm_operand_type, SDNode unpred_op, 3518 Intrinsic pred_int, Instruction inst, list<int> unsignedFlag = []> { 3519 3520 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$src), imm_operand_type:$imm)), 3521 (VTI.Vec (inst (VTI.Vec MQPR:$src), imm_operand_type:$imm))>; 3522 3523 def : Pat<(VTI.Vec !con((pred_int (VTI.Vec MQPR:$src), imm_operand_type:$imm), 3524 !dag(pred_int, unsignedFlag, ?), 3525 (pred_int (VTI.Pred VCCR:$mask), 3526 (VTI.Vec MQPR:$inactive)))), 3527 (VTI.Vec (inst (VTI.Vec MQPR:$src), imm_operand_type:$imm, 3528 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 3529 (VTI.Vec MQPR:$inactive)))>; 3530} 3531 3532multiclass MVE_immediate_shift_patterns<MVEVectorVTInfo VTI, 3533 Operand imm_operand_type> { 3534 defm : MVE_immediate_shift_patterns_inner<VTI, imm_operand_type, 3535 ARMvshlImm, int_arm_mve_shl_imm_predicated, 3536 !cast<Instruction>("MVE_VSHL_immi" # VTI.BitsSuffix)>; 3537 defm : MVE_immediate_shift_patterns_inner<VTI, imm_operand_type, 3538 ARMvshruImm, int_arm_mve_shr_imm_predicated, 3539 !cast<Instruction>("MVE_VSHR_immu" # VTI.BitsSuffix), [1]>; 3540 defm : MVE_immediate_shift_patterns_inner<VTI, imm_operand_type, 3541 ARMvshrsImm, int_arm_mve_shr_imm_predicated, 3542 !cast<Instruction>("MVE_VSHR_imms" # VTI.BitsSuffix), [0]>; 3543} 3544 3545let Predicates = [HasMVEInt] in { 3546 defm : MVE_immediate_shift_patterns<MVE_v16i8, imm0_7>; 3547 defm : MVE_immediate_shift_patterns<MVE_v8i16, imm0_15>; 3548 defm : MVE_immediate_shift_patterns<MVE_v4i32, imm0_31>; 3549} 3550 3551// end of mve_shift instructions 3552 3553// start of MVE Floating Point instructions 3554 3555class MVE_float<string iname, string suffix, dag oops, dag iops, string ops, 3556 vpred_ops vpred, string cstr, bits<2> vecsize, list<dag> pattern=[]> 3557 : MVE_f<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, vecsize, pattern> { 3558 bits<4> Qm; 3559 3560 let Inst{12} = 0b0; 3561 let Inst{6} = 0b1; 3562 let Inst{5} = Qm{3}; 3563 let Inst{3-1} = Qm{2-0}; 3564 let Inst{0} = 0b0; 3565} 3566 3567class MVE_VRINT<string rmode, bits<3> op, string suffix, bits<2> size, 3568 list<dag> pattern=[]> 3569 : MVE_float<!strconcat("vrint", rmode), suffix, (outs MQPR:$Qd), 3570 (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", size, pattern> { 3571 bits<4> Qd; 3572 3573 let Inst{28} = 0b1; 3574 let Inst{25-23} = 0b111; 3575 let Inst{22} = Qd{3}; 3576 let Inst{21-20} = 0b11; 3577 let Inst{19-18} = size; 3578 let Inst{17-16} = 0b10; 3579 let Inst{15-13} = Qd{2-0}; 3580 let Inst{11-10} = 0b01; 3581 let Inst{9-7} = op{2-0}; 3582 let Inst{4} = 0b0; 3583 let validForTailPredication = 1; 3584 3585} 3586 3587multiclass MVE_VRINT_m<MVEVectorVTInfo VTI, string suffix, bits<3> opcode, 3588 SDPatternOperator unpred_op> { 3589 def "": MVE_VRINT<suffix, opcode, VTI.Suffix, VTI.Size>; 3590 defvar Inst = !cast<Instruction>(NAME); 3591 defvar pred_int = !cast<Intrinsic>("int_arm_mve_vrint"#suffix#"_predicated"); 3592 3593 let Predicates = [HasMVEFloat] in { 3594 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$val))), 3595 (VTI.Vec (Inst (VTI.Vec MQPR:$val)))>; 3596 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$val), (VTI.Pred VCCR:$pred), 3597 (VTI.Vec MQPR:$inactive))), 3598 (VTI.Vec (Inst (VTI.Vec MQPR:$val), ARMVCCThen, 3599 (VTI.Pred VCCR:$pred), zero_reg, (VTI.Vec MQPR:$inactive)))>; 3600 } 3601} 3602 3603multiclass MVE_VRINT_ops<MVEVectorVTInfo VTI> { 3604 defm N : MVE_VRINT_m<VTI, "n", 0b000, int_arm_mve_vrintn>; 3605 defm X : MVE_VRINT_m<VTI, "x", 0b001, frint>; 3606 defm A : MVE_VRINT_m<VTI, "a", 0b010, fround>; 3607 defm Z : MVE_VRINT_m<VTI, "z", 0b011, ftrunc>; 3608 defm M : MVE_VRINT_m<VTI, "m", 0b101, ffloor>; 3609 defm P : MVE_VRINT_m<VTI, "p", 0b111, fceil>; 3610} 3611 3612defm MVE_VRINTf16 : MVE_VRINT_ops<MVE_v8f16>; 3613defm MVE_VRINTf32 : MVE_VRINT_ops<MVE_v4f32>; 3614 3615class MVEFloatArithNeon<string iname, string suffix, bit size, 3616 dag oops, dag iops, string ops, 3617 vpred_ops vpred, string cstr, bits<2> vecsize, list<dag> pattern=[]> 3618 : MVE_float<iname, suffix, oops, iops, ops, vpred, cstr, vecsize, pattern> { 3619 let Inst{20} = size; 3620 let Inst{16} = 0b0; 3621} 3622 3623class MVE_VMUL_fp<string iname, string suffix, bits<2> size, list<dag> pattern=[]> 3624 : MVEFloatArithNeon<iname, suffix, size{0}, (outs MQPR:$Qd), 3625 (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm", vpred_r, "", 3626 size, pattern> { 3627 bits<4> Qd; 3628 bits<4> Qn; 3629 3630 let Inst{28} = 0b1; 3631 let Inst{25-23} = 0b110; 3632 let Inst{22} = Qd{3}; 3633 let Inst{21} = 0b0; 3634 let Inst{19-17} = Qn{2-0}; 3635 let Inst{15-13} = Qd{2-0}; 3636 let Inst{12-8} = 0b01101; 3637 let Inst{7} = Qn{3}; 3638 let Inst{4} = 0b1; 3639 let validForTailPredication = 1; 3640} 3641 3642multiclass MVE_VMULT_fp_m<string iname, MVEVectorVTInfo VTI, SDNode Op, 3643 Intrinsic PredInt, SDPatternOperator IdentityVec> { 3644 def "" : MVE_VMUL_fp<iname, VTI.Suffix, VTI.Size>; 3645 defvar Inst = !cast<Instruction>(NAME); 3646 3647 let Predicates = [HasMVEFloat] in { 3648 defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? ), !cast<Instruction>(NAME), IdentityVec>; 3649 } 3650} 3651 3652multiclass MVE_VMUL_fp_m<MVEVectorVTInfo VTI, SDPatternOperator IdentityVec> 3653 : MVE_VMULT_fp_m<"vmul", VTI, fmul, int_arm_mve_mul_predicated, IdentityVec>; 3654 3655def ARMimmOneF: PatLeaf<(bitconvert (v4f32 (ARMvmovFPImm (i32 112))))>; // 1.0 float 3656def ARMimmOneH: PatLeaf<(bitconvert (v8i16 (ARMvmovImm (i32 2620))))>; // 1.0 half 3657 3658defm MVE_VMULf32 : MVE_VMUL_fp_m<MVE_v4f32, ARMimmOneF>; 3659defm MVE_VMULf16 : MVE_VMUL_fp_m<MVE_v8f16, ARMimmOneH>; 3660 3661class MVE_VCMLA<string suffix, bits<2> size> 3662 : MVEFloatArithNeon<"vcmla", suffix, size{1}, (outs MQPR:$Qd), 3663 (ins MQPR:$Qd_src, MQPR:$Qn, MQPR:$Qm, complexrotateop:$rot), 3664 "$Qd, $Qn, $Qm, $rot", vpred_n, "$Qd = $Qd_src", size, []> { 3665 bits<4> Qd; 3666 bits<4> Qn; 3667 bits<2> rot; 3668 3669 let Inst{28} = 0b1; 3670 let Inst{25} = 0b0; 3671 let Inst{24-23} = rot; 3672 let Inst{22} = Qd{3}; 3673 let Inst{21} = 0b1; 3674 let Inst{19-17} = Qn{2-0}; 3675 let Inst{15-13} = Qd{2-0}; 3676 let Inst{12-8} = 0b01000; 3677 let Inst{7} = Qn{3}; 3678 let Inst{4} = 0b0; 3679} 3680 3681multiclass MVE_VCMLA_m<MVEVectorVTInfo VTI> { 3682 def "" : MVE_VCMLA<VTI.Suffix, VTI.Size>; 3683 defvar Inst = !cast<Instruction>(NAME); 3684 3685 let Predicates = [HasMVEFloat] in { 3686 def : Pat<(VTI.Vec (int_arm_mve_vcmlaq 3687 imm:$rot, (VTI.Vec MQPR:$Qd_src), 3688 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))), 3689 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src), 3690 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 3691 imm:$rot))>; 3692 3693 def : Pat<(VTI.Vec (int_arm_mve_vcmlaq_predicated 3694 imm:$rot, (VTI.Vec MQPR:$Qd_src), 3695 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 3696 (VTI.Pred VCCR:$mask))), 3697 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src), (VTI.Vec MQPR:$Qn), 3698 (VTI.Vec MQPR:$Qm), imm:$rot, 3699 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>; 3700 3701 } 3702} 3703 3704defm MVE_VCMLAf16 : MVE_VCMLA_m<MVE_v8f16>; 3705defm MVE_VCMLAf32 : MVE_VCMLA_m<MVE_v4f32>; 3706 3707class MVE_VADDSUBFMA_fp<string iname, string suffix, bits<2> size, bit bit_4, 3708 bit bit_8, bit bit_21, dag iops=(ins), 3709 vpred_ops vpred=vpred_r, string cstr="", 3710 list<dag> pattern=[]> 3711 : MVEFloatArithNeon<iname, suffix, size{0}, (outs MQPR:$Qd), 3712 !con(iops, (ins MQPR:$Qn, MQPR:$Qm)), "$Qd, $Qn, $Qm", 3713 vpred, cstr, size, pattern> { 3714 bits<4> Qd; 3715 bits<4> Qn; 3716 3717 let Inst{28} = 0b0; 3718 let Inst{25-23} = 0b110; 3719 let Inst{22} = Qd{3}; 3720 let Inst{21} = bit_21; 3721 let Inst{19-17} = Qn{2-0}; 3722 let Inst{15-13} = Qd{2-0}; 3723 let Inst{11-9} = 0b110; 3724 let Inst{8} = bit_8; 3725 let Inst{7} = Qn{3}; 3726 let Inst{4} = bit_4; 3727 let validForTailPredication = 1; 3728} 3729 3730multiclass MVE_VFMA_fp_multi<string iname, bit fms, MVEVectorVTInfo VTI> { 3731 def "" : MVE_VADDSUBFMA_fp<iname, VTI.Suffix, VTI.Size, 0b1, 0b0, fms, 3732 (ins MQPR:$Qd_src), vpred_n, "$Qd = $Qd_src">; 3733 defvar Inst = !cast<Instruction>(NAME); 3734 defvar pred_int = int_arm_mve_fma_predicated; 3735 defvar m1 = (VTI.Vec MQPR:$m1); 3736 defvar m2 = (VTI.Vec MQPR:$m2); 3737 defvar add = (VTI.Vec MQPR:$add); 3738 defvar pred = (VTI.Pred VCCR:$pred); 3739 3740 let Predicates = [HasMVEFloat] in { 3741 if fms then { 3742 def : Pat<(VTI.Vec (fma (fneg m1), m2, add)), 3743 (Inst $add, $m1, $m2)>; 3744 def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred), 3745 (VTI.Vec (fma (fneg m1), m2, add)), 3746 add)), 3747 (Inst $add, $m1, $m2, ARMVCCThen, $pred, zero_reg)>; 3748 def : Pat<(VTI.Vec (pred_int (fneg m1), m2, add, pred)), 3749 (Inst $add, $m1, $m2, ARMVCCThen, $pred, zero_reg)>; 3750 def : Pat<(VTI.Vec (pred_int m1, (fneg m2), add, pred)), 3751 (Inst $add, $m1, $m2, ARMVCCThen, $pred, zero_reg)>; 3752 } else { 3753 def : Pat<(VTI.Vec (fma m1, m2, add)), 3754 (Inst $add, $m1, $m2)>; 3755 def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred), 3756 (VTI.Vec (fma m1, m2, add)), 3757 add)), 3758 (Inst $add, $m1, $m2, ARMVCCThen, $pred, zero_reg)>; 3759 def : Pat<(VTI.Vec (pred_int m1, m2, add, pred)), 3760 (Inst $add, $m1, $m2, ARMVCCThen, $pred, zero_reg)>; 3761 } 3762 } 3763} 3764 3765defm MVE_VFMAf32 : MVE_VFMA_fp_multi<"vfma", 0, MVE_v4f32>; 3766defm MVE_VFMAf16 : MVE_VFMA_fp_multi<"vfma", 0, MVE_v8f16>; 3767defm MVE_VFMSf32 : MVE_VFMA_fp_multi<"vfms", 1, MVE_v4f32>; 3768defm MVE_VFMSf16 : MVE_VFMA_fp_multi<"vfms", 1, MVE_v8f16>; 3769 3770multiclass MVE_VADDSUB_fp_m<string iname, bit bit_21, MVEVectorVTInfo VTI, 3771 SDNode Op, Intrinsic PredInt, SDPatternOperator IdentityVec> { 3772 def "" : MVE_VADDSUBFMA_fp<iname, VTI.Suffix, VTI.Size, 0, 1, bit_21> { 3773 let validForTailPredication = 1; 3774 } 3775 defvar Inst = !cast<Instruction>(NAME); 3776 3777 let Predicates = [HasMVEFloat] in { 3778 defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? ), !cast<Instruction>(NAME), IdentityVec>; 3779 } 3780} 3781 3782multiclass MVE_VADD_fp_m<MVEVectorVTInfo VTI, SDPatternOperator IdentityVec> 3783 : MVE_VADDSUB_fp_m<"vadd", 0, VTI, fadd, int_arm_mve_add_predicated, IdentityVec>; 3784multiclass MVE_VSUB_fp_m<MVEVectorVTInfo VTI, SDPatternOperator IdentityVec> 3785 : MVE_VADDSUB_fp_m<"vsub", 1, VTI, fsub, int_arm_mve_sub_predicated, IdentityVec>; 3786 3787def ARMimmMinusZeroF: PatLeaf<(bitconvert (v4i32 (ARMvmovImm (i32 1664))))>; // -0.0 float 3788def ARMimmMinusZeroH: PatLeaf<(bitconvert (v8i16 (ARMvmovImm (i32 2688))))>; // -0.0 half 3789 3790defm MVE_VADDf32 : MVE_VADD_fp_m<MVE_v4f32, ARMimmMinusZeroF>; 3791defm MVE_VADDf16 : MVE_VADD_fp_m<MVE_v8f16, ARMimmMinusZeroH>; 3792 3793defm MVE_VSUBf32 : MVE_VSUB_fp_m<MVE_v4f32, ARMimmAllZerosV>; 3794defm MVE_VSUBf16 : MVE_VSUB_fp_m<MVE_v8f16, ARMimmAllZerosV>; 3795 3796class MVE_VCADD<string suffix, bits<2> size, string cstr=""> 3797 : MVEFloatArithNeon<"vcadd", suffix, size{1}, (outs MQPR:$Qd), 3798 (ins MQPR:$Qn, MQPR:$Qm, complexrotateopodd:$rot), 3799 "$Qd, $Qn, $Qm, $rot", vpred_r, cstr, size, []> { 3800 bits<4> Qd; 3801 bits<4> Qn; 3802 bit rot; 3803 3804 let Inst{28} = 0b1; 3805 let Inst{25} = 0b0; 3806 let Inst{24} = rot; 3807 let Inst{23} = 0b1; 3808 let Inst{22} = Qd{3}; 3809 let Inst{21} = 0b0; 3810 let Inst{19-17} = Qn{2-0}; 3811 let Inst{15-13} = Qd{2-0}; 3812 let Inst{12-8} = 0b01000; 3813 let Inst{7} = Qn{3}; 3814 let Inst{4} = 0b0; 3815} 3816 3817multiclass MVE_VCADD_m<MVEVectorVTInfo VTI, string cstr=""> { 3818 def "" : MVE_VCADD<VTI.Suffix, VTI.Size, cstr>; 3819 defvar Inst = !cast<Instruction>(NAME); 3820 3821 let Predicates = [HasMVEFloat] in { 3822 def : Pat<(VTI.Vec (int_arm_mve_vcaddq (i32 1), 3823 imm:$rot, (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))), 3824 (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 3825 imm:$rot))>; 3826 3827 def : Pat<(VTI.Vec (int_arm_mve_vcaddq_predicated (i32 1), 3828 imm:$rot, (VTI.Vec MQPR:$inactive), 3829 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 3830 (VTI.Pred VCCR:$mask))), 3831 (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 3832 imm:$rot, ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 3833 (VTI.Vec MQPR:$inactive)))>; 3834 3835 } 3836} 3837 3838defm MVE_VCADDf16 : MVE_VCADD_m<MVE_v8f16>; 3839defm MVE_VCADDf32 : MVE_VCADD_m<MVE_v4f32, "@earlyclobber $Qd">; 3840 3841class MVE_VABD_fp<string suffix, bits<2> size> 3842 : MVE_float<"vabd", suffix, (outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm), 3843 "$Qd, $Qn, $Qm", vpred_r, "", size> { 3844 bits<4> Qd; 3845 bits<4> Qn; 3846 3847 let Inst{28} = 0b1; 3848 let Inst{25-23} = 0b110; 3849 let Inst{22} = Qd{3}; 3850 let Inst{21} = 0b1; 3851 let Inst{20} = size{0}; 3852 let Inst{19-17} = Qn{2-0}; 3853 let Inst{16} = 0b0; 3854 let Inst{15-13} = Qd{2-0}; 3855 let Inst{11-8} = 0b1101; 3856 let Inst{7} = Qn{3}; 3857 let Inst{4} = 0b0; 3858 let validForTailPredication = 1; 3859} 3860 3861multiclass MVE_VABDT_fp_m<MVEVectorVTInfo VTI, 3862 Intrinsic unpred_int, Intrinsic pred_int> { 3863 def "" : MVE_VABD_fp<VTI.Suffix, VTI.Size>; 3864 defvar Inst = !cast<Instruction>(NAME); 3865 3866 let Predicates = [HasMVEFloat] in { 3867 def : Pat<(VTI.Vec (unpred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 3868 (i32 0))), 3869 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>; 3870 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 3871 (i32 0), (VTI.Pred VCCR:$mask), 3872 (VTI.Vec MQPR:$inactive))), 3873 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 3874 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 3875 (VTI.Vec MQPR:$inactive)))>; 3876 } 3877} 3878 3879multiclass MVE_VABD_fp_m<MVEVectorVTInfo VTI> 3880 : MVE_VABDT_fp_m<VTI, int_arm_mve_vabd, int_arm_mve_abd_predicated>; 3881 3882defm MVE_VABDf32 : MVE_VABD_fp_m<MVE_v4f32>; 3883defm MVE_VABDf16 : MVE_VABD_fp_m<MVE_v8f16>; 3884 3885let Predicates = [HasMVEFloat] in { 3886 def : Pat<(v8f16 (fabs (fsub (v8f16 MQPR:$Qm), (v8f16 MQPR:$Qn)))), 3887 (MVE_VABDf16 MQPR:$Qm, MQPR:$Qn)>; 3888 def : Pat<(v4f32 (fabs (fsub (v4f32 MQPR:$Qm), (v4f32 MQPR:$Qn)))), 3889 (MVE_VABDf32 MQPR:$Qm, MQPR:$Qn)>; 3890} 3891 3892class MVE_VCVT_fix<string suffix, bit fsi, bit U, bit op, 3893 Operand imm_operand_type> 3894 : MVE_float<"vcvt", suffix, 3895 (outs MQPR:$Qd), (ins MQPR:$Qm, imm_operand_type:$imm6), 3896 "$Qd, $Qm, $imm6", vpred_r, "", !if(fsi, 0b10, 0b01), []> { 3897 bits<4> Qd; 3898 bits<6> imm6; 3899 3900 let Inst{28} = U; 3901 let Inst{25-23} = 0b111; 3902 let Inst{22} = Qd{3}; 3903 let Inst{21} = 0b1; 3904 let Inst{19-16} = imm6{3-0}; 3905 let Inst{15-13} = Qd{2-0}; 3906 let Inst{11-10} = 0b11; 3907 let Inst{9} = fsi; 3908 let Inst{8} = op; 3909 let Inst{7} = 0b0; 3910 let Inst{4} = 0b1; 3911 3912 let DecoderMethod = "DecodeMVEVCVTt1fp"; 3913 let validForTailPredication = 1; 3914} 3915 3916class MVE_VCVT_imm_asmop<int Bits> : AsmOperandClass { 3917 let PredicateMethod = "isImmediate<1," # Bits # ">"; 3918 let DiagnosticString = 3919 "MVE fixed-point immediate operand must be between 1 and " # Bits; 3920 let Name = "MVEVcvtImm" # Bits; 3921 let RenderMethod = "addImmOperands"; 3922} 3923class MVE_VCVT_imm<int Bits>: Operand<i32> { 3924 let ParserMatchClass = MVE_VCVT_imm_asmop<Bits>; 3925 let EncoderMethod = "getNEONVcvtImm32OpValue"; 3926 let DecoderMethod = "DecodeVCVTImmOperand"; 3927} 3928 3929class MVE_VCVT_fix_f32<string suffix, bit U, bit op> 3930 : MVE_VCVT_fix<suffix, 0b1, U, op, MVE_VCVT_imm<32>> { 3931 let Inst{20} = imm6{4}; 3932} 3933class MVE_VCVT_fix_f16<string suffix, bit U, bit op> 3934 : MVE_VCVT_fix<suffix, 0b0, U, op, MVE_VCVT_imm<16>> { 3935 let Inst{20} = 0b1; 3936} 3937 3938multiclass MVE_VCVT_fix_patterns<Instruction Inst, bit U, MVEVectorVTInfo DestVTI, 3939 MVEVectorVTInfo SrcVTI> { 3940 let Predicates = [HasMVEFloat] in { 3941 def : Pat<(DestVTI.Vec (int_arm_mve_vcvt_fix 3942 (i32 U), (SrcVTI.Vec MQPR:$Qm), imm:$scale)), 3943 (DestVTI.Vec (Inst (SrcVTI.Vec MQPR:$Qm), imm:$scale))>; 3944 def : Pat<(DestVTI.Vec (int_arm_mve_vcvt_fix_predicated (i32 U), 3945 (DestVTI.Vec MQPR:$inactive), 3946 (SrcVTI.Vec MQPR:$Qm), 3947 imm:$scale, 3948 (DestVTI.Pred VCCR:$mask))), 3949 (DestVTI.Vec (Inst (SrcVTI.Vec MQPR:$Qm), imm:$scale, 3950 ARMVCCThen, (DestVTI.Pred VCCR:$mask), zero_reg, 3951 (DestVTI.Vec MQPR:$inactive)))>; 3952 } 3953} 3954 3955multiclass MVE_VCVT_fix_f32_m<bit U, bit op, 3956 MVEVectorVTInfo DestVTI, MVEVectorVTInfo SrcVTI> { 3957 def "" : MVE_VCVT_fix_f32<DestVTI.Suffix#"."#SrcVTI.Suffix, U, op>; 3958 defm : MVE_VCVT_fix_patterns<!cast<Instruction>(NAME), U, DestVTI, SrcVTI>; 3959} 3960 3961multiclass MVE_VCVT_fix_f16_m<bit U, bit op, 3962 MVEVectorVTInfo DestVTI, MVEVectorVTInfo SrcVTI> { 3963 def "" : MVE_VCVT_fix_f16<DestVTI.Suffix#"."#SrcVTI.Suffix, U, op>; 3964 defm : MVE_VCVT_fix_patterns<!cast<Instruction>(NAME), U, DestVTI, SrcVTI>; 3965} 3966 3967defm MVE_VCVTf16s16_fix : MVE_VCVT_fix_f16_m<0b0, 0b0, MVE_v8f16, MVE_v8s16>; 3968defm MVE_VCVTs16f16_fix : MVE_VCVT_fix_f16_m<0b0, 0b1, MVE_v8s16, MVE_v8f16>; 3969defm MVE_VCVTf16u16_fix : MVE_VCVT_fix_f16_m<0b1, 0b0, MVE_v8f16, MVE_v8u16>; 3970defm MVE_VCVTu16f16_fix : MVE_VCVT_fix_f16_m<0b1, 0b1, MVE_v8u16, MVE_v8f16>; 3971defm MVE_VCVTf32s32_fix : MVE_VCVT_fix_f32_m<0b0, 0b0, MVE_v4f32, MVE_v4s32>; 3972defm MVE_VCVTs32f32_fix : MVE_VCVT_fix_f32_m<0b0, 0b1, MVE_v4s32, MVE_v4f32>; 3973defm MVE_VCVTf32u32_fix : MVE_VCVT_fix_f32_m<0b1, 0b0, MVE_v4f32, MVE_v4u32>; 3974defm MVE_VCVTu32f32_fix : MVE_VCVT_fix_f32_m<0b1, 0b1, MVE_v4u32, MVE_v4f32>; 3975 3976class MVE_VCVT_fp_int_anpm<string suffix, bits<2> size, bit op, string anpm, 3977 bits<2> rm, list<dag> pattern=[]> 3978 : MVE_float<!strconcat("vcvt", anpm), suffix, (outs MQPR:$Qd), 3979 (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", size, pattern> { 3980 bits<4> Qd; 3981 3982 let Inst{28} = 0b1; 3983 let Inst{25-23} = 0b111; 3984 let Inst{22} = Qd{3}; 3985 let Inst{21-20} = 0b11; 3986 let Inst{19-18} = size; 3987 let Inst{17-16} = 0b11; 3988 let Inst{15-13} = Qd{2-0}; 3989 let Inst{12-10} = 0b000; 3990 let Inst{9-8} = rm; 3991 let Inst{7} = op; 3992 let Inst{4} = 0b0; 3993 let validForTailPredication = 1; 3994} 3995 3996multiclass MVE_VCVT_fp_int_anpm_inner<MVEVectorVTInfo Int, MVEVectorVTInfo Flt, 3997 string anpm, bits<2> rm> { 3998 def "": MVE_VCVT_fp_int_anpm<Int.Suffix # "." # Flt.Suffix, Int.Size, 3999 Int.Unsigned, anpm, rm>; 4000 4001 defvar Inst = !cast<Instruction>(NAME); 4002 defvar IntrBaseName = "int_arm_mve_vcvt" # anpm; 4003 defvar UnpredIntr = !cast<Intrinsic>(IntrBaseName); 4004 defvar PredIntr = !cast<Intrinsic>(IntrBaseName # "_predicated"); 4005 4006 let Predicates = [HasMVEFloat] in { 4007 def : Pat<(Int.Vec (UnpredIntr (i32 Int.Unsigned), (Flt.Vec MQPR:$in))), 4008 (Int.Vec (Inst (Flt.Vec MQPR:$in)))>; 4009 4010 def : Pat<(Int.Vec (PredIntr (i32 Int.Unsigned), (Int.Vec MQPR:$inactive), 4011 (Flt.Vec MQPR:$in), (Flt.Pred VCCR:$pred))), 4012 (Int.Vec (Inst (Flt.Vec MQPR:$in), ARMVCCThen, 4013 (Flt.Pred VCCR:$pred), zero_reg, (Int.Vec MQPR:$inactive)))>; 4014 } 4015} 4016 4017multiclass MVE_VCVT_fp_int_anpm_outer<MVEVectorVTInfo Int, 4018 MVEVectorVTInfo Flt> { 4019 defm a : MVE_VCVT_fp_int_anpm_inner<Int, Flt, "a", 0b00>; 4020 defm n : MVE_VCVT_fp_int_anpm_inner<Int, Flt, "n", 0b01>; 4021 defm p : MVE_VCVT_fp_int_anpm_inner<Int, Flt, "p", 0b10>; 4022 defm m : MVE_VCVT_fp_int_anpm_inner<Int, Flt, "m", 0b11>; 4023} 4024 4025// This defines instructions such as MVE_VCVTu16f16a, with an explicit 4026// rounding-mode suffix on the mnemonic. The class below will define 4027// the bare MVE_VCVTu16f16 (with implied rounding toward zero). 4028defm MVE_VCVTs16f16 : MVE_VCVT_fp_int_anpm_outer<MVE_v8s16, MVE_v8f16>; 4029defm MVE_VCVTu16f16 : MVE_VCVT_fp_int_anpm_outer<MVE_v8u16, MVE_v8f16>; 4030defm MVE_VCVTs32f32 : MVE_VCVT_fp_int_anpm_outer<MVE_v4s32, MVE_v4f32>; 4031defm MVE_VCVTu32f32 : MVE_VCVT_fp_int_anpm_outer<MVE_v4u32, MVE_v4f32>; 4032 4033class MVE_VCVT_fp_int<string suffix, bits<2> size, bit toint, bit unsigned, 4034 list<dag> pattern=[]> 4035 : MVE_float<"vcvt", suffix, (outs MQPR:$Qd), 4036 (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", size, pattern> { 4037 bits<4> Qd; 4038 4039 let Inst{28} = 0b1; 4040 let Inst{25-23} = 0b111; 4041 let Inst{22} = Qd{3}; 4042 let Inst{21-20} = 0b11; 4043 let Inst{19-18} = size; 4044 let Inst{17-16} = 0b11; 4045 let Inst{15-13} = Qd{2-0}; 4046 let Inst{12-9} = 0b0011; 4047 let Inst{8} = toint; 4048 let Inst{7} = unsigned; 4049 let Inst{4} = 0b0; 4050 let validForTailPredication = 1; 4051} 4052 4053multiclass MVE_VCVT_fp_int_m<MVEVectorVTInfo Dest, MVEVectorVTInfo Src, 4054 SDNode unpred_op> { 4055 defvar Unsigned = !or(!eq(Dest.SuffixLetter,"u"), !eq(Src.SuffixLetter,"u")); 4056 defvar ToInt = !eq(Src.SuffixLetter,"f"); 4057 4058 def "" : MVE_VCVT_fp_int<Dest.Suffix # "." # Src.Suffix, Dest.Size, 4059 ToInt, Unsigned>; 4060 defvar Inst = !cast<Instruction>(NAME); 4061 4062 let Predicates = [HasMVEFloat] in { 4063 def : Pat<(Dest.Vec (unpred_op (Src.Vec MQPR:$src))), 4064 (Dest.Vec (Inst (Src.Vec MQPR:$src)))>; 4065 def : Pat<(Dest.Vec (int_arm_mve_vcvt_fp_int_predicated 4066 (Src.Vec MQPR:$src), (i32 Unsigned), 4067 (Src.Pred VCCR:$mask), (Dest.Vec MQPR:$inactive))), 4068 (Dest.Vec (Inst (Src.Vec MQPR:$src), ARMVCCThen, 4069 (Src.Pred VCCR:$mask), zero_reg, 4070 (Dest.Vec MQPR:$inactive)))>; 4071 } 4072} 4073// The unsuffixed VCVT for float->int implicitly rounds toward zero, 4074// which I reflect here in the llvm instruction names 4075defm MVE_VCVTs16f16z : MVE_VCVT_fp_int_m<MVE_v8s16, MVE_v8f16, fp_to_sint>; 4076defm MVE_VCVTu16f16z : MVE_VCVT_fp_int_m<MVE_v8u16, MVE_v8f16, fp_to_uint>; 4077defm MVE_VCVTs32f32z : MVE_VCVT_fp_int_m<MVE_v4s32, MVE_v4f32, fp_to_sint>; 4078defm MVE_VCVTu32f32z : MVE_VCVT_fp_int_m<MVE_v4u32, MVE_v4f32, fp_to_uint>; 4079// Whereas VCVT for int->float rounds to nearest 4080defm MVE_VCVTf16s16n : MVE_VCVT_fp_int_m<MVE_v8f16, MVE_v8s16, sint_to_fp>; 4081defm MVE_VCVTf16u16n : MVE_VCVT_fp_int_m<MVE_v8f16, MVE_v8u16, uint_to_fp>; 4082defm MVE_VCVTf32s32n : MVE_VCVT_fp_int_m<MVE_v4f32, MVE_v4s32, sint_to_fp>; 4083defm MVE_VCVTf32u32n : MVE_VCVT_fp_int_m<MVE_v4f32, MVE_v4u32, uint_to_fp>; 4084 4085let Predicates = [HasMVEFloat] in { 4086 def : Pat<(v4i32 (fp_to_sint_sat v4f32:$src, i32)), 4087 (MVE_VCVTs32f32z v4f32:$src)>; 4088 def : Pat<(v4i32 (fp_to_uint_sat v4f32:$src, i32)), 4089 (MVE_VCVTu32f32z v4f32:$src)>; 4090 def : Pat<(v8i16 (fp_to_sint_sat v8f16:$src, i16)), 4091 (MVE_VCVTs16f16z v8f16:$src)>; 4092 def : Pat<(v8i16 (fp_to_uint_sat v8f16:$src, i16)), 4093 (MVE_VCVTu16f16z v8f16:$src)>; 4094} 4095 4096class MVE_VABSNEG_fp<string iname, string suffix, bits<2> size, bit negate, 4097 list<dag> pattern=[]> 4098 : MVE_float<iname, suffix, (outs MQPR:$Qd), 4099 (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", size, pattern> { 4100 bits<4> Qd; 4101 4102 let Inst{28} = 0b1; 4103 let Inst{25-23} = 0b111; 4104 let Inst{22} = Qd{3}; 4105 let Inst{21-20} = 0b11; 4106 let Inst{19-18} = size; 4107 let Inst{17-16} = 0b01; 4108 let Inst{15-13} = Qd{2-0}; 4109 let Inst{11-8} = 0b0111; 4110 let Inst{7} = negate; 4111 let Inst{4} = 0b0; 4112 let validForTailPredication = 1; 4113} 4114 4115multiclass MVE_VABSNEG_fp_m<string iname, SDNode unpred_op, Intrinsic pred_int, 4116 MVEVectorVTInfo VTI, bit opcode> { 4117 def "" : MVE_VABSNEG_fp<iname, VTI.Suffix, VTI.Size, opcode>; 4118 defvar Inst = !cast<Instruction>(NAME); 4119 4120 let Predicates = [HasMVEInt] in { 4121 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$v))), 4122 (VTI.Vec (Inst $v))>; 4123 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$v), (VTI.Pred VCCR:$mask), 4124 (VTI.Vec MQPR:$inactive))), 4125 (VTI.Vec (Inst $v, ARMVCCThen, $mask, zero_reg, $inactive))>; 4126 } 4127} 4128 4129defm MVE_VABSf16 : MVE_VABSNEG_fp_m<"vabs", fabs, int_arm_mve_abs_predicated, 4130 MVE_v8f16, 0>; 4131defm MVE_VABSf32 : MVE_VABSNEG_fp_m<"vabs", fabs, int_arm_mve_abs_predicated, 4132 MVE_v4f32, 0>; 4133defm MVE_VNEGf16 : MVE_VABSNEG_fp_m<"vneg", fneg, int_arm_mve_neg_predicated, 4134 MVE_v8f16, 1>; 4135defm MVE_VNEGf32 : MVE_VABSNEG_fp_m<"vneg", fneg, int_arm_mve_neg_predicated, 4136 MVE_v4f32, 1>; 4137 4138class MVE_VMAXMINNMA<string iname, string suffix, bits<2> size, bit bit_12, 4139 list<dag> pattern=[]> 4140 : MVE_f<(outs MQPR:$Qd), (ins MQPR:$Qd_src, MQPR:$Qm), 4141 NoItinerary, iname, suffix, "$Qd, $Qm", vpred_n, "$Qd = $Qd_src", 4142 size, pattern> { 4143 bits<4> Qd; 4144 bits<4> Qm; 4145 4146 let Inst{28} = size{0}; 4147 let Inst{25-23} = 0b100; 4148 let Inst{22} = Qd{3}; 4149 let Inst{21-16} = 0b111111; 4150 let Inst{15-13} = Qd{2-0}; 4151 let Inst{12} = bit_12; 4152 let Inst{11-6} = 0b111010; 4153 let Inst{5} = Qm{3}; 4154 let Inst{4} = 0b0; 4155 let Inst{3-1} = Qm{2-0}; 4156 let Inst{0} = 0b1; 4157 4158 let isCommutable = 1; 4159 let validForTailPredication = 1; 4160} 4161 4162multiclass MVE_VMAXMINNMA_m<string iname, MVEVectorVTInfo VTI, 4163 SDNode unpred_op, Intrinsic pred_int, 4164 bit bit_12> { 4165 def "" : MVE_VMAXMINNMA<iname, VTI.Suffix, VTI.Size, bit_12>; 4166 defvar Inst = !cast<Instruction>(NAME); 4167 4168 let Predicates = [HasMVEInt] in { 4169 // Unpredicated v(max|min)nma 4170 def : Pat<(VTI.Vec (unpred_op (fabs (VTI.Vec MQPR:$Qd)), 4171 (fabs (VTI.Vec MQPR:$Qm)))), 4172 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm)))>; 4173 4174 // Predicated v(max|min)nma 4175 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm), 4176 (VTI.Pred VCCR:$mask))), 4177 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm), 4178 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>; 4179 } 4180} 4181 4182multiclass MVE_VMAXNMA<MVEVectorVTInfo VTI, bit bit_12> 4183 : MVE_VMAXMINNMA_m<"vmaxnma", VTI, fmaxnum, int_arm_mve_vmaxnma_predicated, bit_12>; 4184 4185defm MVE_VMAXNMAf32 : MVE_VMAXNMA<MVE_v4f32, 0b0>; 4186defm MVE_VMAXNMAf16 : MVE_VMAXNMA<MVE_v8f16, 0b0>; 4187 4188multiclass MVE_VMINNMA<MVEVectorVTInfo VTI, bit bit_12> 4189 : MVE_VMAXMINNMA_m<"vminnma", VTI, fminnum, int_arm_mve_vminnma_predicated, bit_12>; 4190 4191defm MVE_VMINNMAf32 : MVE_VMINNMA<MVE_v4f32, 0b1>; 4192defm MVE_VMINNMAf16 : MVE_VMINNMA<MVE_v8f16, 0b1>; 4193 4194// end of MVE Floating Point instructions 4195 4196// start of MVE compares 4197 4198class MVE_VCMPqq<string suffix, bit bit_28, bits<2> bits_21_20, 4199 VCMPPredicateOperand predtype, bits<2> vecsize, list<dag> pattern=[]> 4200 : MVE_p<(outs VCCR:$P0), (ins MQPR:$Qn, MQPR:$Qm, predtype:$fc), 4201 NoItinerary, "vcmp", suffix, "$fc, $Qn, $Qm", vpred_n, "", vecsize, pattern> { 4202 // Base class for comparing two vector registers 4203 bits<3> fc; 4204 bits<4> Qn; 4205 bits<4> Qm; 4206 4207 let Inst{28} = bit_28; 4208 let Inst{25-22} = 0b1000; 4209 let Inst{21-20} = bits_21_20; 4210 let Inst{19-17} = Qn{2-0}; 4211 let Inst{16-13} = 0b1000; 4212 let Inst{12} = fc{2}; 4213 let Inst{11-8} = 0b1111; 4214 let Inst{7} = fc{0}; 4215 let Inst{6} = 0b0; 4216 let Inst{5} = Qm{3}; 4217 let Inst{4} = 0b0; 4218 let Inst{3-1} = Qm{2-0}; 4219 let Inst{0} = fc{1}; 4220 4221 let Constraints = ""; 4222 4223 // We need a custom decoder method for these instructions because of 4224 // the output VCCR operand, which isn't encoded in the instruction 4225 // bits anywhere (there is only one choice for it) but has to be 4226 // included in the MC operands so that codegen will be able to track 4227 // its data flow between instructions, spill/reload it when 4228 // necessary, etc. There seems to be no way to get the Tablegen 4229 // decoder to emit an operand that isn't affected by any instruction 4230 // bit. 4231 let DecoderMethod = "DecodeMVEVCMP<false," # predtype.DecoderMethod # ">"; 4232 let validForTailPredication = 1; 4233} 4234 4235class MVE_VCMPqqf<string suffix, bit size> 4236 : MVE_VCMPqq<suffix, size, 0b11, pred_basic_fp, !if(size, 0b01, 0b10)> { 4237 let Predicates = [HasMVEFloat]; 4238} 4239 4240class MVE_VCMPqqi<string suffix, bits<2> size> 4241 : MVE_VCMPqq<suffix, 0b1, size, pred_basic_i, size> { 4242 let Inst{12} = 0b0; 4243 let Inst{0} = 0b0; 4244} 4245 4246class MVE_VCMPqqu<string suffix, bits<2> size> 4247 : MVE_VCMPqq<suffix, 0b1, size, pred_basic_u, size> { 4248 let Inst{12} = 0b0; 4249 let Inst{0} = 0b1; 4250} 4251 4252class MVE_VCMPqqs<string suffix, bits<2> size> 4253 : MVE_VCMPqq<suffix, 0b1, size, pred_basic_s, size> { 4254 let Inst{12} = 0b1; 4255} 4256 4257def MVE_VCMPf32 : MVE_VCMPqqf<"f32", 0b0>; 4258def MVE_VCMPf16 : MVE_VCMPqqf<"f16", 0b1>; 4259 4260def MVE_VCMPi8 : MVE_VCMPqqi<"i8", 0b00>; 4261def MVE_VCMPi16 : MVE_VCMPqqi<"i16", 0b01>; 4262def MVE_VCMPi32 : MVE_VCMPqqi<"i32", 0b10>; 4263 4264def MVE_VCMPu8 : MVE_VCMPqqu<"u8", 0b00>; 4265def MVE_VCMPu16 : MVE_VCMPqqu<"u16", 0b01>; 4266def MVE_VCMPu32 : MVE_VCMPqqu<"u32", 0b10>; 4267 4268def MVE_VCMPs8 : MVE_VCMPqqs<"s8", 0b00>; 4269def MVE_VCMPs16 : MVE_VCMPqqs<"s16", 0b01>; 4270def MVE_VCMPs32 : MVE_VCMPqqs<"s32", 0b10>; 4271 4272class MVE_VCMPqr<string suffix, bit bit_28, bits<2> bits_21_20, 4273 VCMPPredicateOperand predtype, bits<2> vecsize, list<dag> pattern=[]> 4274 : MVE_p<(outs VCCR:$P0), (ins MQPR:$Qn, GPRwithZR:$Rm, predtype:$fc), 4275 NoItinerary, "vcmp", suffix, "$fc, $Qn, $Rm", vpred_n, "", vecsize, pattern> { 4276 // Base class for comparing a vector register with a scalar 4277 bits<3> fc; 4278 bits<4> Qn; 4279 bits<4> Rm; 4280 4281 let Inst{28} = bit_28; 4282 let Inst{25-22} = 0b1000; 4283 let Inst{21-20} = bits_21_20; 4284 let Inst{19-17} = Qn{2-0}; 4285 let Inst{16-13} = 0b1000; 4286 let Inst{12} = fc{2}; 4287 let Inst{11-8} = 0b1111; 4288 let Inst{7} = fc{0}; 4289 let Inst{6} = 0b1; 4290 let Inst{5} = fc{1}; 4291 let Inst{4} = 0b0; 4292 let Inst{3-0} = Rm{3-0}; 4293 4294 let Constraints = ""; 4295 // Custom decoder method, for the same reason as MVE_VCMPqq 4296 let DecoderMethod = "DecodeMVEVCMP<true," # predtype.DecoderMethod # ">"; 4297 let validForTailPredication = 1; 4298} 4299 4300class MVE_VCMPqrf<string suffix, bit size> 4301 : MVE_VCMPqr<suffix, size, 0b11, pred_basic_fp, !if(size, 0b01, 0b10)> { 4302 let Predicates = [HasMVEFloat]; 4303} 4304 4305class MVE_VCMPqri<string suffix, bits<2> size> 4306 : MVE_VCMPqr<suffix, 0b1, size, pred_basic_i, size> { 4307 let Inst{12} = 0b0; 4308 let Inst{5} = 0b0; 4309} 4310 4311class MVE_VCMPqru<string suffix, bits<2> size> 4312 : MVE_VCMPqr<suffix, 0b1, size, pred_basic_u, size> { 4313 let Inst{12} = 0b0; 4314 let Inst{5} = 0b1; 4315} 4316 4317class MVE_VCMPqrs<string suffix, bits<2> size> 4318 : MVE_VCMPqr<suffix, 0b1, size, pred_basic_s, size> { 4319 let Inst{12} = 0b1; 4320} 4321 4322def MVE_VCMPf32r : MVE_VCMPqrf<"f32", 0b0>; 4323def MVE_VCMPf16r : MVE_VCMPqrf<"f16", 0b1>; 4324 4325def MVE_VCMPi8r : MVE_VCMPqri<"i8", 0b00>; 4326def MVE_VCMPi16r : MVE_VCMPqri<"i16", 0b01>; 4327def MVE_VCMPi32r : MVE_VCMPqri<"i32", 0b10>; 4328 4329def MVE_VCMPu8r : MVE_VCMPqru<"u8", 0b00>; 4330def MVE_VCMPu16r : MVE_VCMPqru<"u16", 0b01>; 4331def MVE_VCMPu32r : MVE_VCMPqru<"u32", 0b10>; 4332 4333def MVE_VCMPs8r : MVE_VCMPqrs<"s8", 0b00>; 4334def MVE_VCMPs16r : MVE_VCMPqrs<"s16", 0b01>; 4335def MVE_VCMPs32r : MVE_VCMPqrs<"s32", 0b10>; 4336 4337multiclass unpred_vcmp_z<string suffix, PatLeaf fc> { 4338 def i8 : Pat<(v16i1 (ARMvcmpz (v16i8 MQPR:$v1), fc)), 4339 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), ZR, fc))>; 4340 def i16 : Pat<(v8i1 (ARMvcmpz (v8i16 MQPR:$v1), fc)), 4341 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), ZR, fc))>; 4342 def i32 : Pat<(v4i1 (ARMvcmpz (v4i32 MQPR:$v1), fc)), 4343 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), ZR, fc))>; 4344 4345 def : Pat<(v16i1 (and (v16i1 VCCR:$p1), (v16i1 (ARMvcmpz (v16i8 MQPR:$v1), fc)))), 4346 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), ZR, fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4347 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmpz (v8i16 MQPR:$v1), fc)))), 4348 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), ZR, fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4349 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmpz (v4i32 MQPR:$v1), fc)))), 4350 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), ZR, fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4351} 4352 4353multiclass unpred_vcmp_r<string suffix, PatLeaf fc> { 4354 def i8 : Pat<(v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), fc)), 4355 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8") (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), fc))>; 4356 def i16 : Pat<(v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), fc)), 4357 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16") (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), fc))>; 4358 def i32 : Pat<(v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), fc)), 4359 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32") (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), fc))>; 4360 4361 def i8r : Pat<(v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 (ARMvdup rGPR:$v2)), fc)), 4362 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), (i32 rGPR:$v2), fc))>; 4363 def i16r : Pat<(v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 (ARMvdup rGPR:$v2)), fc)), 4364 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), (i32 rGPR:$v2), fc))>; 4365 def i32r : Pat<(v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 (ARMvdup rGPR:$v2)), fc)), 4366 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), (i32 rGPR:$v2), fc))>; 4367 4368 def : Pat<(v16i1 (and (v16i1 VCCR:$p1), (v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), fc)))), 4369 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8") (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4370 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), fc)))), 4371 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16") (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4372 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), fc)))), 4373 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32") (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4374 4375 def : Pat<(v16i1 (and (v16i1 VCCR:$p1), (v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 (ARMvdup rGPR:$v2)), fc)))), 4376 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), (i32 rGPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4377 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 (ARMvdup rGPR:$v2)), fc)))), 4378 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), (i32 rGPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4379 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 (ARMvdup rGPR:$v2)), fc)))), 4380 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), (i32 rGPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4381} 4382 4383multiclass unpred_vcmpf_z<PatLeaf fc> { 4384 def f16 : Pat<(v8i1 (ARMvcmpz (v8f16 MQPR:$v1), fc)), 4385 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), ZR, fc))>; 4386 def f32 : Pat<(v4i1 (ARMvcmpz (v4f32 MQPR:$v1), fc)), 4387 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, fc))>; 4388 4389 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmpz (v8f16 MQPR:$v1), fc)))), 4390 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), ZR, fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4391 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmpz (v4f32 MQPR:$v1), fc)))), 4392 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4393} 4394 4395multiclass unpred_vcmpf_r<PatLeaf fc> { 4396 def : Pat<(v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), fc)), 4397 (v8i1 (MVE_VCMPf16 (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), fc))>; 4398 def : Pat<(v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), fc)), 4399 (v4i1 (MVE_VCMPf32 (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), fc))>; 4400 4401 def : Pat<(v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 (ARMvdup rGPR:$v2)), fc)), 4402 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), (i32 rGPR:$v2), fc))>; 4403 def : Pat<(v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 (ARMvdup rGPR:$v2)), fc)), 4404 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), (i32 rGPR:$v2), fc))>; 4405 4406 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), fc)))), 4407 (v8i1 (MVE_VCMPf16 (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4408 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), fc)))), 4409 (v4i1 (MVE_VCMPf32 (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4410 4411 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 (ARMvdup rGPR:$v2)), fc)))), 4412 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), (i32 rGPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4413 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 (ARMvdup rGPR:$v2)), fc)))), 4414 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), (i32 rGPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4415} 4416 4417let Predicates = [HasMVEInt] in { 4418 defm MVE_VCEQZ : unpred_vcmp_z<"i", ARMCCeq>; 4419 defm MVE_VCNEZ : unpred_vcmp_z<"i", ARMCCne>; 4420 defm MVE_VCGEZ : unpred_vcmp_z<"s", ARMCCge>; 4421 defm MVE_VCLTZ : unpred_vcmp_z<"s", ARMCClt>; 4422 defm MVE_VCGTZ : unpred_vcmp_z<"s", ARMCCgt>; 4423 defm MVE_VCLEZ : unpred_vcmp_z<"s", ARMCCle>; 4424 defm MVE_VCGTUZ : unpred_vcmp_z<"u", ARMCChi>; 4425 defm MVE_VCGEUZ : unpred_vcmp_z<"u", ARMCChs>; 4426 4427 defm MVE_VCEQ : unpred_vcmp_r<"i", ARMCCeq>; 4428 defm MVE_VCNE : unpred_vcmp_r<"i", ARMCCne>; 4429 defm MVE_VCGE : unpred_vcmp_r<"s", ARMCCge>; 4430 defm MVE_VCLT : unpred_vcmp_r<"s", ARMCClt>; 4431 defm MVE_VCGT : unpred_vcmp_r<"s", ARMCCgt>; 4432 defm MVE_VCLE : unpred_vcmp_r<"s", ARMCCle>; 4433 defm MVE_VCGTU : unpred_vcmp_r<"u", ARMCChi>; 4434 defm MVE_VCGEU : unpred_vcmp_r<"u", ARMCChs>; 4435} 4436 4437let Predicates = [HasMVEFloat] in { 4438 defm MVE_VFCEQZ : unpred_vcmpf_z<ARMCCeq>; 4439 defm MVE_VFCNEZ : unpred_vcmpf_z<ARMCCne>; 4440 defm MVE_VFCGEZ : unpred_vcmpf_z<ARMCCge>; 4441 defm MVE_VFCLTZ : unpred_vcmpf_z<ARMCClt>; 4442 defm MVE_VFCGTZ : unpred_vcmpf_z<ARMCCgt>; 4443 defm MVE_VFCLEZ : unpred_vcmpf_z<ARMCCle>; 4444 4445 defm MVE_VFCEQ : unpred_vcmpf_r<ARMCCeq>; 4446 defm MVE_VFCNE : unpred_vcmpf_r<ARMCCne>; 4447 defm MVE_VFCGE : unpred_vcmpf_r<ARMCCge>; 4448 defm MVE_VFCLT : unpred_vcmpf_r<ARMCClt>; 4449 defm MVE_VFCGT : unpred_vcmpf_r<ARMCCgt>; 4450 defm MVE_VFCLE : unpred_vcmpf_r<ARMCCle>; 4451} 4452 4453 4454// Extra "worst case" and/or/xor patterns, going into and out of GRP 4455multiclass two_predops<SDPatternOperator opnode, Instruction insn> { 4456 def v16i1 : Pat<(v16i1 (opnode (v16i1 VCCR:$p1), (v16i1 VCCR:$p2))), 4457 (v16i1 (COPY_TO_REGCLASS 4458 (insn (i32 (COPY_TO_REGCLASS (v16i1 VCCR:$p1), rGPR)), 4459 (i32 (COPY_TO_REGCLASS (v16i1 VCCR:$p2), rGPR))), 4460 VCCR))>; 4461 def v8i1 : Pat<(v8i1 (opnode (v8i1 VCCR:$p1), (v8i1 VCCR:$p2))), 4462 (v8i1 (COPY_TO_REGCLASS 4463 (insn (i32 (COPY_TO_REGCLASS (v8i1 VCCR:$p1), rGPR)), 4464 (i32 (COPY_TO_REGCLASS (v8i1 VCCR:$p2), rGPR))), 4465 VCCR))>; 4466 def v4i1 : Pat<(v4i1 (opnode (v4i1 VCCR:$p1), (v4i1 VCCR:$p2))), 4467 (v4i1 (COPY_TO_REGCLASS 4468 (insn (i32 (COPY_TO_REGCLASS (v4i1 VCCR:$p1), rGPR)), 4469 (i32 (COPY_TO_REGCLASS (v4i1 VCCR:$p2), rGPR))), 4470 VCCR))>; 4471 def v2i1 : Pat<(v2i1 (opnode (v2i1 VCCR:$p1), (v2i1 VCCR:$p2))), 4472 (v2i1 (COPY_TO_REGCLASS 4473 (insn (i32 (COPY_TO_REGCLASS (v2i1 VCCR:$p1), rGPR)), 4474 (i32 (COPY_TO_REGCLASS (v2i1 VCCR:$p2), rGPR))), 4475 VCCR))>; 4476} 4477 4478let Predicates = [HasMVEInt] in { 4479 defm POR : two_predops<or, t2ORRrr>; 4480 defm PAND : two_predops<and, t2ANDrr>; 4481 defm PEOR : two_predops<xor, t2EORrr>; 4482} 4483 4484// Occasionally we need to cast between a i32 and a boolean vector, for 4485// example when moving between rGPR and VPR.P0 as part of predicate vector 4486// shuffles. We also sometimes need to cast between different predicate 4487// vector types (v4i1<>v8i1, etc.) also as part of lowering vector shuffles. 4488def predicate_cast : SDNode<"ARMISD::PREDICATE_CAST", SDTUnaryOp>; 4489 4490def load_align4 : PatFrag<(ops node:$ptr), (load node:$ptr), [{ 4491 return cast<LoadSDNode>(N)->getAlignment() >= 4; 4492}]>; 4493 4494let Predicates = [HasMVEInt] in { 4495 foreach VT = [ v2i1, v4i1, v8i1, v16i1 ] in { 4496 def : Pat<(i32 (predicate_cast (VT VCCR:$src))), 4497 (i32 (COPY_TO_REGCLASS (VT VCCR:$src), VCCR))>; 4498 def : Pat<(VT (predicate_cast (i32 VCCR:$src))), 4499 (VT (COPY_TO_REGCLASS (i32 VCCR:$src), VCCR))>; 4500 4501 foreach VT2 = [ v2i1, v4i1, v8i1, v16i1 ] in 4502 def : Pat<(VT (predicate_cast (VT2 VCCR:$src))), 4503 (VT (COPY_TO_REGCLASS (VT2 VCCR:$src), VCCR))>; 4504 } 4505 4506 // If we happen to be casting from a load we can convert that straight 4507 // into a predicate load, so long as the load is of the correct type. 4508 foreach VT = [ v2i1, v4i1, v8i1, v16i1 ] in { 4509 def : Pat<(VT (predicate_cast (i32 (load_align4 taddrmode_imm7<2>:$addr)))), 4510 (VT (VLDR_P0_off taddrmode_imm7<2>:$addr))>; 4511 } 4512 4513 // Here we match the specific SDNode type 'ARMVectorRegCastImpl' 4514 // rather than the more general 'ARMVectorRegCast' which would also 4515 // match some bitconverts. If we use the latter in cases where the 4516 // input and output types are the same, the bitconvert gets elided 4517 // and we end up generating a nonsense match of nothing. 4518 4519 foreach VT = [ v16i8, v8i16, v8f16, v4i32, v4f32, v2i64, v2f64 ] in 4520 foreach VT2 = [ v16i8, v8i16, v8f16, v4i32, v4f32, v2i64, v2f64 ] in 4521 def : Pat<(VT (ARMVectorRegCastImpl (VT2 MQPR:$src))), 4522 (VT MQPR:$src)>; 4523} 4524 4525// end of MVE compares 4526 4527// start of MVE_qDest_qSrc 4528 4529class MVE_qDest_qSrc<string iname, string suffix, dag oops, dag iops, 4530 string ops, vpred_ops vpred, string cstr, 4531 bits<2> vecsize, list<dag> pattern=[]> 4532 : MVE_p<oops, iops, NoItinerary, iname, suffix, 4533 ops, vpred, cstr, vecsize, pattern> { 4534 bits<4> Qd; 4535 bits<4> Qm; 4536 4537 let Inst{25-23} = 0b100; 4538 let Inst{22} = Qd{3}; 4539 let Inst{15-13} = Qd{2-0}; 4540 let Inst{11-9} = 0b111; 4541 let Inst{6} = 0b0; 4542 let Inst{5} = Qm{3}; 4543 let Inst{4} = 0b0; 4544 let Inst{3-1} = Qm{2-0}; 4545} 4546 4547class MVE_VQxDMLxDH<string iname, bit exch, bit round, bit subtract, 4548 string suffix, bits<2> size, string cstr="", 4549 list<dag> pattern=[]> 4550 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd), 4551 (ins MQPR:$Qd_src, MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm", 4552 vpred_n, "$Qd = $Qd_src"#cstr, size, pattern> { 4553 bits<4> Qn; 4554 4555 let Inst{28} = subtract; 4556 let Inst{21-20} = size; 4557 let Inst{19-17} = Qn{2-0}; 4558 let Inst{16} = 0b0; 4559 let Inst{12} = exch; 4560 let Inst{8} = 0b0; 4561 let Inst{7} = Qn{3}; 4562 let Inst{0} = round; 4563} 4564 4565multiclass MVE_VQxDMLxDH_p<string iname, bit exch, bit round, bit subtract, 4566 MVEVectorVTInfo VTI> { 4567 def "": MVE_VQxDMLxDH<iname, exch, round, subtract, VTI.Suffix, VTI.Size, 4568 !if(!eq(VTI.LaneBits, 32), ",@earlyclobber $Qd", "")>; 4569 defvar Inst = !cast<Instruction>(NAME); 4570 defvar ConstParams = (? (i32 exch), (i32 round), (i32 subtract)); 4571 defvar unpred_intr = int_arm_mve_vqdmlad; 4572 defvar pred_intr = int_arm_mve_vqdmlad_predicated; 4573 4574 def : Pat<(VTI.Vec !con((unpred_intr (VTI.Vec MQPR:$a), (VTI.Vec MQPR:$b), 4575 (VTI.Vec MQPR:$c)), ConstParams)), 4576 (VTI.Vec (Inst (VTI.Vec MQPR:$a), (VTI.Vec MQPR:$b), 4577 (VTI.Vec MQPR:$c)))>; 4578 def : Pat<(VTI.Vec !con((pred_intr (VTI.Vec MQPR:$a), (VTI.Vec MQPR:$b), 4579 (VTI.Vec MQPR:$c)), ConstParams, 4580 (? (VTI.Pred VCCR:$pred)))), 4581 (VTI.Vec (Inst (VTI.Vec MQPR:$a), (VTI.Vec MQPR:$b), 4582 (VTI.Vec MQPR:$c), 4583 ARMVCCThen, (VTI.Pred VCCR:$pred), zero_reg))>; 4584} 4585 4586multiclass MVE_VQxDMLxDH_multi<string iname, bit exch, 4587 bit round, bit subtract> { 4588 defm s8 : MVE_VQxDMLxDH_p<iname, exch, round, subtract, MVE_v16s8>; 4589 defm s16 : MVE_VQxDMLxDH_p<iname, exch, round, subtract, MVE_v8s16>; 4590 defm s32 : MVE_VQxDMLxDH_p<iname, exch, round, subtract, MVE_v4s32>; 4591} 4592 4593defm MVE_VQDMLADH : MVE_VQxDMLxDH_multi<"vqdmladh", 0b0, 0b0, 0b0>; 4594defm MVE_VQDMLADHX : MVE_VQxDMLxDH_multi<"vqdmladhx", 0b1, 0b0, 0b0>; 4595defm MVE_VQRDMLADH : MVE_VQxDMLxDH_multi<"vqrdmladh", 0b0, 0b1, 0b0>; 4596defm MVE_VQRDMLADHX : MVE_VQxDMLxDH_multi<"vqrdmladhx", 0b1, 0b1, 0b0>; 4597defm MVE_VQDMLSDH : MVE_VQxDMLxDH_multi<"vqdmlsdh", 0b0, 0b0, 0b1>; 4598defm MVE_VQDMLSDHX : MVE_VQxDMLxDH_multi<"vqdmlsdhx", 0b1, 0b0, 0b1>; 4599defm MVE_VQRDMLSDH : MVE_VQxDMLxDH_multi<"vqrdmlsdh", 0b0, 0b1, 0b1>; 4600defm MVE_VQRDMLSDHX : MVE_VQxDMLxDH_multi<"vqrdmlsdhx", 0b1, 0b1, 0b1>; 4601 4602class MVE_VCMUL<string iname, string suffix, bits<2> size, string cstr=""> 4603 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd), 4604 (ins MQPR:$Qn, MQPR:$Qm, complexrotateop:$rot), 4605 "$Qd, $Qn, $Qm, $rot", vpred_r, cstr, size, 4606 []> { 4607 bits<4> Qn; 4608 bits<2> rot; 4609 4610 let Inst{28} = size{1}; 4611 let Inst{21-20} = 0b11; 4612 let Inst{19-17} = Qn{2-0}; 4613 let Inst{16} = 0b0; 4614 let Inst{12} = rot{1}; 4615 let Inst{8} = 0b0; 4616 let Inst{7} = Qn{3}; 4617 let Inst{0} = rot{0}; 4618 4619 let Predicates = [HasMVEFloat]; 4620} 4621 4622multiclass MVE_VCMUL_m<string iname, MVEVectorVTInfo VTI, 4623 string cstr=""> { 4624 def "" : MVE_VCMUL<iname, VTI.Suffix, VTI.Size, cstr>; 4625 defvar Inst = !cast<Instruction>(NAME); 4626 4627 let Predicates = [HasMVEFloat] in { 4628 def : Pat<(VTI.Vec (int_arm_mve_vcmulq 4629 imm:$rot, (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))), 4630 (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 4631 imm:$rot))>; 4632 4633 def : Pat<(VTI.Vec (int_arm_mve_vcmulq_predicated 4634 imm:$rot, (VTI.Vec MQPR:$inactive), 4635 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 4636 (VTI.Pred VCCR:$mask))), 4637 (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 4638 imm:$rot, ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 4639 (VTI.Vec MQPR:$inactive)))>; 4640 4641 } 4642} 4643 4644defm MVE_VCMULf16 : MVE_VCMUL_m<"vcmul", MVE_v8f16>; 4645defm MVE_VCMULf32 : MVE_VCMUL_m<"vcmul", MVE_v4f32, "@earlyclobber $Qd">; 4646 4647class MVE_VMULL<string iname, string suffix, bit bit_28, bits<2> bits_21_20, 4648 bit T, string cstr, bits<2> vecsize, list<dag> pattern=[]> 4649 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd), 4650 (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm", 4651 vpred_r, cstr, vecsize, pattern> { 4652 bits<4> Qd; 4653 bits<4> Qn; 4654 bits<4> Qm; 4655 4656 let Inst{28} = bit_28; 4657 let Inst{21-20} = bits_21_20; 4658 let Inst{19-17} = Qn{2-0}; 4659 let Inst{16} = 0b1; 4660 let Inst{12} = T; 4661 let Inst{8} = 0b0; 4662 let Inst{7} = Qn{3}; 4663 let Inst{0} = 0b0; 4664 let validForTailPredication = 1; 4665 let doubleWidthResult = 1; 4666} 4667 4668multiclass MVE_VMULL_m<MVEVectorVTInfo VTI, 4669 SDPatternOperator unpred_op, Intrinsic pred_int, 4670 bit Top, bits<2> vecsize, string cstr=""> { 4671 def "" : MVE_VMULL<"vmull" # !if(Top, "t", "b"), VTI.Suffix, VTI.Unsigned, 4672 VTI.Size, Top, cstr, vecsize>; 4673 defvar Inst = !cast<Instruction>(NAME); 4674 4675 let Predicates = [HasMVEInt] in { 4676 defvar uflag = !if(!eq(VTI.SuffixLetter, "p"), (?), (? (i32 VTI.Unsigned))); 4677 4678 // Unpredicated multiply 4679 def : Pat<(VTI.DblVec !con((unpred_op (VTI.Vec MQPR:$Qm), 4680 (VTI.Vec MQPR:$Qn)), 4681 uflag, (? (i32 Top)))), 4682 (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>; 4683 4684 // Predicated multiply 4685 def : Pat<(VTI.DblVec !con((pred_int (VTI.Vec MQPR:$Qm), 4686 (VTI.Vec MQPR:$Qn)), 4687 uflag, (? (i32 Top), (VTI.DblPred VCCR:$mask), 4688 (VTI.DblVec MQPR:$inactive)))), 4689 (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 4690 ARMVCCThen, (VTI.DblPred VCCR:$mask), zero_reg, 4691 (VTI.DblVec MQPR:$inactive)))>; 4692 } 4693} 4694 4695// For polynomial multiplies, the size bits take the unused value 0b11, and 4696// the unsigned bit switches to encoding the size. 4697 4698defm MVE_VMULLBs8 : MVE_VMULL_m<MVE_v16s8, int_arm_mve_vmull, 4699 int_arm_mve_mull_int_predicated, 0b0, 0b01>; 4700defm MVE_VMULLTs8 : MVE_VMULL_m<MVE_v16s8, int_arm_mve_vmull, 4701 int_arm_mve_mull_int_predicated, 0b1, 0b01>; 4702defm MVE_VMULLBs16 : MVE_VMULL_m<MVE_v8s16, int_arm_mve_vmull, 4703 int_arm_mve_mull_int_predicated, 0b0, 0b10>; 4704defm MVE_VMULLTs16 : MVE_VMULL_m<MVE_v8s16, int_arm_mve_vmull, 4705 int_arm_mve_mull_int_predicated, 0b1, 0b10>; 4706defm MVE_VMULLBs32 : MVE_VMULL_m<MVE_v4s32, int_arm_mve_vmull, 4707 int_arm_mve_mull_int_predicated, 0b0, 0b11, 4708 "@earlyclobber $Qd">; 4709defm MVE_VMULLTs32 : MVE_VMULL_m<MVE_v4s32, int_arm_mve_vmull, 4710 int_arm_mve_mull_int_predicated, 0b1, 0b11, 4711 "@earlyclobber $Qd">; 4712 4713defm MVE_VMULLBu8 : MVE_VMULL_m<MVE_v16u8, int_arm_mve_vmull, 4714 int_arm_mve_mull_int_predicated, 0b0, 0b01>; 4715defm MVE_VMULLTu8 : MVE_VMULL_m<MVE_v16u8, int_arm_mve_vmull, 4716 int_arm_mve_mull_int_predicated, 0b1, 0b01>; 4717defm MVE_VMULLBu16 : MVE_VMULL_m<MVE_v8u16, int_arm_mve_vmull, 4718 int_arm_mve_mull_int_predicated, 0b0, 0b10>; 4719defm MVE_VMULLTu16 : MVE_VMULL_m<MVE_v8u16, int_arm_mve_vmull, 4720 int_arm_mve_mull_int_predicated, 0b1, 0b10>; 4721defm MVE_VMULLBu32 : MVE_VMULL_m<MVE_v4u32, int_arm_mve_vmull, 4722 int_arm_mve_mull_int_predicated, 0b0, 0b11, 4723 "@earlyclobber $Qd">; 4724defm MVE_VMULLTu32 : MVE_VMULL_m<MVE_v4u32, int_arm_mve_vmull, 4725 int_arm_mve_mull_int_predicated, 0b1, 0b11, 4726 "@earlyclobber $Qd">; 4727 4728defm MVE_VMULLBp8 : MVE_VMULL_m<MVE_v16p8, int_arm_mve_vmull_poly, 4729 int_arm_mve_mull_poly_predicated, 0b0, 0b01>; 4730defm MVE_VMULLTp8 : MVE_VMULL_m<MVE_v16p8, int_arm_mve_vmull_poly, 4731 int_arm_mve_mull_poly_predicated, 0b1, 0b01>; 4732defm MVE_VMULLBp16 : MVE_VMULL_m<MVE_v8p16, int_arm_mve_vmull_poly, 4733 int_arm_mve_mull_poly_predicated, 0b0, 0b10>; 4734defm MVE_VMULLTp16 : MVE_VMULL_m<MVE_v8p16, int_arm_mve_vmull_poly, 4735 int_arm_mve_mull_poly_predicated, 0b1, 0b10>; 4736 4737let Predicates = [HasMVEInt] in { 4738 def : Pat<(v2i64 (ARMvmulls (v4i32 MQPR:$src1), (v4i32 MQPR:$src2))), 4739 (MVE_VMULLBs32 MQPR:$src1, MQPR:$src2)>; 4740 def : Pat<(v2i64 (ARMvmulls (v4i32 (ARMvrev64 (v4i32 MQPR:$src1))), 4741 (v4i32 (ARMvrev64 (v4i32 MQPR:$src2))))), 4742 (MVE_VMULLTs32 MQPR:$src1, MQPR:$src2)>; 4743 4744 def : Pat<(mul (sext_inreg (v4i32 MQPR:$src1), v4i16), 4745 (sext_inreg (v4i32 MQPR:$src2), v4i16)), 4746 (MVE_VMULLBs16 MQPR:$src1, MQPR:$src2)>; 4747 def : Pat<(mul (sext_inreg (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src1)))), v4i16), 4748 (sext_inreg (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src2)))), v4i16)), 4749 (MVE_VMULLTs16 MQPR:$src1, MQPR:$src2)>; 4750 4751 def : Pat<(mul (sext_inreg (v8i16 MQPR:$src1), v8i8), 4752 (sext_inreg (v8i16 MQPR:$src2), v8i8)), 4753 (MVE_VMULLBs8 MQPR:$src1, MQPR:$src2)>; 4754 def : Pat<(mul (sext_inreg (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src1)))), v8i8), 4755 (sext_inreg (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src2)))), v8i8)), 4756 (MVE_VMULLTs8 MQPR:$src1, MQPR:$src2)>; 4757 4758 def : Pat<(v2i64 (ARMvmullu (v4i32 MQPR:$src1), (v4i32 MQPR:$src2))), 4759 (MVE_VMULLBu32 MQPR:$src1, MQPR:$src2)>; 4760 def : Pat<(v2i64 (ARMvmullu (v4i32 (ARMvrev64 (v4i32 MQPR:$src1))), 4761 (v4i32 (ARMvrev64 (v4i32 MQPR:$src2))))), 4762 (MVE_VMULLTu32 MQPR:$src1, MQPR:$src2)>; 4763 4764 def : Pat<(mul (and (v4i32 MQPR:$src1), (v4i32 (ARMvmovImm (i32 0xCFF)))), 4765 (and (v4i32 MQPR:$src2), (v4i32 (ARMvmovImm (i32 0xCFF))))), 4766 (MVE_VMULLBu16 MQPR:$src1, MQPR:$src2)>; 4767 def : Pat<(mul (and (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src1)))), 4768 (v4i32 (ARMvmovImm (i32 0xCFF)))), 4769 (and (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src2)))), 4770 (v4i32 (ARMvmovImm (i32 0xCFF))))), 4771 (MVE_VMULLTu16 MQPR:$src1, MQPR:$src2)>; 4772 4773 def : Pat<(mul (ARMvbicImm (v8i16 MQPR:$src1), (i32 0xAFF)), 4774 (ARMvbicImm (v8i16 MQPR:$src2), (i32 0xAFF))), 4775 (MVE_VMULLBu8 MQPR:$src1, MQPR:$src2)>; 4776 def : Pat<(mul (ARMvbicImm (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src1)))), (i32 0xAFF)), 4777 (ARMvbicImm (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src2)))), (i32 0xAFF))), 4778 (MVE_VMULLTu8 MQPR:$src1, MQPR:$src2)>; 4779} 4780 4781class MVE_VxMULH<string iname, string suffix, bit U, bits<2> size, bit round, 4782 list<dag> pattern=[]> 4783 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd), 4784 (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm", 4785 vpred_r, "", size, pattern> { 4786 bits<4> Qn; 4787 4788 let Inst{28} = U; 4789 let Inst{21-20} = size; 4790 let Inst{19-17} = Qn{2-0}; 4791 let Inst{16} = 0b1; 4792 let Inst{12} = round; 4793 let Inst{8} = 0b0; 4794 let Inst{7} = Qn{3}; 4795 let Inst{0} = 0b1; 4796 let validForTailPredication = 1; 4797} 4798 4799multiclass MVE_VxMULH_m<string iname, MVEVectorVTInfo VTI, SDNode unpred_op, 4800 Intrinsic PredInt, bit round> { 4801 def "" : MVE_VxMULH<iname, VTI.Suffix, VTI.Unsigned, VTI.Size, round>; 4802 defvar Inst = !cast<Instruction>(NAME); 4803 4804 let Predicates = [HasMVEInt] in { 4805 if !eq(round, 0b0) then { 4806 defvar mulh = !if(VTI.Unsigned, mulhu, mulhs); 4807 defm : MVE_TwoOpPattern<VTI, mulh, PredInt, (? (i32 VTI.Unsigned)), 4808 !cast<Instruction>(NAME)>; 4809 } else { 4810 // Predicated multiply returning high bits 4811 def : Pat<(VTI.Vec (PredInt (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 4812 (i32 VTI.Unsigned), (VTI.Pred VCCR:$mask), 4813 (VTI.Vec MQPR:$inactive))), 4814 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 4815 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 4816 (VTI.Vec MQPR:$inactive)))>; 4817 } 4818 4819 // Unpredicated intrinsic 4820 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 4821 (i32 VTI.Unsigned))), 4822 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>; 4823 } 4824} 4825 4826multiclass MVE_VMULT<string iname, MVEVectorVTInfo VTI, bit round> 4827 : MVE_VxMULH_m<iname, VTI, !if(round, int_arm_mve_vrmulh, int_arm_mve_vmulh), 4828 !if(round, int_arm_mve_rmulh_predicated, 4829 int_arm_mve_mulh_predicated), 4830 round>; 4831 4832defm MVE_VMULHs8 : MVE_VMULT<"vmulh", MVE_v16s8, 0b0>; 4833defm MVE_VMULHs16 : MVE_VMULT<"vmulh", MVE_v8s16, 0b0>; 4834defm MVE_VMULHs32 : MVE_VMULT<"vmulh", MVE_v4s32, 0b0>; 4835defm MVE_VMULHu8 : MVE_VMULT<"vmulh", MVE_v16u8, 0b0>; 4836defm MVE_VMULHu16 : MVE_VMULT<"vmulh", MVE_v8u16, 0b0>; 4837defm MVE_VMULHu32 : MVE_VMULT<"vmulh", MVE_v4u32, 0b0>; 4838 4839defm MVE_VRMULHs8 : MVE_VMULT<"vrmulh", MVE_v16s8, 0b1>; 4840defm MVE_VRMULHs16 : MVE_VMULT<"vrmulh", MVE_v8s16, 0b1>; 4841defm MVE_VRMULHs32 : MVE_VMULT<"vrmulh", MVE_v4s32, 0b1>; 4842defm MVE_VRMULHu8 : MVE_VMULT<"vrmulh", MVE_v16u8, 0b1>; 4843defm MVE_VRMULHu16 : MVE_VMULT<"vrmulh", MVE_v8u16, 0b1>; 4844defm MVE_VRMULHu32 : MVE_VMULT<"vrmulh", MVE_v4u32, 0b1>; 4845 4846class MVE_VxMOVxN<string iname, string suffix, bit bit_28, bit bit_17, 4847 bits<2> size, bit T, list<dag> pattern=[]> 4848 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd), 4849 (ins MQPR:$Qd_src, MQPR:$Qm), "$Qd, $Qm", 4850 vpred_n, "$Qd = $Qd_src", !if(size, 0b10, 0b01), pattern> { 4851 4852 let Inst{28} = bit_28; 4853 let Inst{21-20} = 0b11; 4854 let Inst{19-18} = size; 4855 let Inst{17} = bit_17; 4856 let Inst{16} = 0b1; 4857 let Inst{12} = T; 4858 let Inst{8} = 0b0; 4859 let Inst{7} = !not(bit_17); 4860 let Inst{0} = 0b1; 4861 let validForTailPredication = 1; 4862 let retainsPreviousHalfElement = 1; 4863} 4864 4865multiclass MVE_VxMOVxN_halves<string iname, string suffix, 4866 bit bit_28, bit bit_17, bits<2> size> { 4867 def bh : MVE_VxMOVxN<iname # "b", suffix, bit_28, bit_17, size, 0b0>; 4868 def th : MVE_VxMOVxN<iname # "t", suffix, bit_28, bit_17, size, 0b1>; 4869} 4870 4871defm MVE_VMOVNi16 : MVE_VxMOVxN_halves<"vmovn", "i16", 0b1, 0b0, 0b00>; 4872defm MVE_VMOVNi32 : MVE_VxMOVxN_halves<"vmovn", "i32", 0b1, 0b0, 0b01>; 4873defm MVE_VQMOVNs16 : MVE_VxMOVxN_halves<"vqmovn", "s16", 0b0, 0b1, 0b00>; 4874defm MVE_VQMOVNs32 : MVE_VxMOVxN_halves<"vqmovn", "s32", 0b0, 0b1, 0b01>; 4875defm MVE_VQMOVNu16 : MVE_VxMOVxN_halves<"vqmovn", "u16", 0b1, 0b1, 0b00>; 4876defm MVE_VQMOVNu32 : MVE_VxMOVxN_halves<"vqmovn", "u32", 0b1, 0b1, 0b01>; 4877defm MVE_VQMOVUNs16 : MVE_VxMOVxN_halves<"vqmovun", "s16", 0b0, 0b0, 0b00>; 4878defm MVE_VQMOVUNs32 : MVE_VxMOVxN_halves<"vqmovun", "s32", 0b0, 0b0, 0b01>; 4879 4880def MVEvmovn : SDNode<"ARMISD::VMOVN", SDTARMVEXT>; 4881 4882multiclass MVE_VMOVN_p<Instruction Inst, bit top, 4883 MVEVectorVTInfo VTI, MVEVectorVTInfo InVTI> { 4884 // Match the most obvious MVEvmovn(a,b,t), which overwrites the odd or even 4885 // lanes of a (depending on t) with the even lanes of b. 4886 def : Pat<(VTI.Vec (MVEvmovn (VTI.Vec MQPR:$Qd_src), 4887 (VTI.Vec MQPR:$Qm), (i32 top))), 4888 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src), (VTI.Vec MQPR:$Qm)))>; 4889 4890 if !not(top) then { 4891 // If we see MVEvmovn(a,ARMvrev(b),1), that wants to overwrite the odd 4892 // lanes of a with the odd lanes of b. In other words, the lanes we're 4893 // _keeping_ from a are the even ones. So we can flip it round and say that 4894 // this is the same as overwriting the even lanes of b with the even lanes 4895 // of a, i.e. it's a VMOVNB with the operands reversed. 4896 defvar vrev = !cast<SDNode>("ARMvrev" # InVTI.LaneBits); 4897 def : Pat<(VTI.Vec (MVEvmovn (VTI.Vec MQPR:$Qm), 4898 (VTI.Vec (vrev MQPR:$Qd_src)), (i32 1))), 4899 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src), (VTI.Vec MQPR:$Qm)))>; 4900 } 4901 4902 // Match the IR intrinsic for a predicated VMOVN. This regards the Qm input 4903 // as having wider lanes that we're narrowing, instead of already-narrow 4904 // lanes that we're taking every other one of. 4905 def : Pat<(VTI.Vec (int_arm_mve_vmovn_predicated (VTI.Vec MQPR:$Qd_src), 4906 (InVTI.Vec MQPR:$Qm), (i32 top), 4907 (InVTI.Pred VCCR:$pred))), 4908 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src), 4909 (InVTI.Vec MQPR:$Qm), 4910 ARMVCCThen, (InVTI.Pred VCCR:$pred), zero_reg))>; 4911} 4912 4913defm : MVE_VMOVN_p<MVE_VMOVNi32bh, 0, MVE_v8i16, MVE_v4i32>; 4914defm : MVE_VMOVN_p<MVE_VMOVNi32th, 1, MVE_v8i16, MVE_v4i32>; 4915defm : MVE_VMOVN_p<MVE_VMOVNi16bh, 0, MVE_v16i8, MVE_v8i16>; 4916defm : MVE_VMOVN_p<MVE_VMOVNi16th, 1, MVE_v16i8, MVE_v8i16>; 4917 4918multiclass MVE_VQMOVN_p<Instruction Inst, bit outU, bit inU, bit top, 4919 MVEVectorVTInfo VTI, MVEVectorVTInfo InVTI> { 4920 def : Pat<(VTI.Vec (int_arm_mve_vqmovn (VTI.Vec MQPR:$Qd_src), 4921 (InVTI.Vec MQPR:$Qm), 4922 (i32 outU), (i32 inU), (i32 top))), 4923 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src), 4924 (InVTI.Vec MQPR:$Qm)))>; 4925 4926 def : Pat<(VTI.Vec (int_arm_mve_vqmovn_predicated (VTI.Vec MQPR:$Qd_src), 4927 (InVTI.Vec MQPR:$Qm), 4928 (i32 outU), (i32 inU), (i32 top), 4929 (InVTI.Pred VCCR:$pred))), 4930 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src), 4931 (InVTI.Vec MQPR:$Qm), 4932 ARMVCCThen, (InVTI.Pred VCCR:$pred), zero_reg))>; 4933} 4934 4935defm : MVE_VQMOVN_p<MVE_VQMOVNs32bh, 0, 0, 0, MVE_v8i16, MVE_v4i32>; 4936defm : MVE_VQMOVN_p<MVE_VQMOVNs32th, 0, 0, 1, MVE_v8i16, MVE_v4i32>; 4937defm : MVE_VQMOVN_p<MVE_VQMOVNs16bh, 0, 0, 0, MVE_v16i8, MVE_v8i16>; 4938defm : MVE_VQMOVN_p<MVE_VQMOVNs16th, 0, 0, 1, MVE_v16i8, MVE_v8i16>; 4939defm : MVE_VQMOVN_p<MVE_VQMOVNu32bh, 1, 1, 0, MVE_v8i16, MVE_v4i32>; 4940defm : MVE_VQMOVN_p<MVE_VQMOVNu32th, 1, 1, 1, MVE_v8i16, MVE_v4i32>; 4941defm : MVE_VQMOVN_p<MVE_VQMOVNu16bh, 1, 1, 0, MVE_v16i8, MVE_v8i16>; 4942defm : MVE_VQMOVN_p<MVE_VQMOVNu16th, 1, 1, 1, MVE_v16i8, MVE_v8i16>; 4943defm : MVE_VQMOVN_p<MVE_VQMOVUNs32bh, 1, 0, 0, MVE_v8i16, MVE_v4i32>; 4944defm : MVE_VQMOVN_p<MVE_VQMOVUNs32th, 1, 0, 1, MVE_v8i16, MVE_v4i32>; 4945defm : MVE_VQMOVN_p<MVE_VQMOVUNs16bh, 1, 0, 0, MVE_v16i8, MVE_v8i16>; 4946defm : MVE_VQMOVN_p<MVE_VQMOVUNs16th, 1, 0, 1, MVE_v16i8, MVE_v8i16>; 4947 4948def SDTARMVMOVNQ : SDTypeProfile<1, 3, [SDTCisVec<0>, SDTCisSameAs<0, 1>, 4949 SDTCisVec<2>, SDTCisVT<3, i32>]>; 4950def MVEvqmovns : SDNode<"ARMISD::VQMOVNs", SDTARMVMOVNQ>; 4951def MVEvqmovnu : SDNode<"ARMISD::VQMOVNu", SDTARMVMOVNQ>; 4952 4953let Predicates = [HasMVEInt] in { 4954 def : Pat<(v8i16 (MVEvqmovns (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), (i32 0))), 4955 (v8i16 (MVE_VQMOVNs32bh (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm)))>; 4956 def : Pat<(v8i16 (MVEvqmovns (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), (i32 1))), 4957 (v8i16 (MVE_VQMOVNs32th (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm)))>; 4958 def : Pat<(v16i8 (MVEvqmovns (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), (i32 0))), 4959 (v16i8 (MVE_VQMOVNs16bh (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm)))>; 4960 def : Pat<(v16i8 (MVEvqmovns (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), (i32 1))), 4961 (v16i8 (MVE_VQMOVNs16th (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm)))>; 4962 4963 def : Pat<(v8i16 (MVEvqmovnu (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), (i32 0))), 4964 (v8i16 (MVE_VQMOVNu32bh (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm)))>; 4965 def : Pat<(v8i16 (MVEvqmovnu (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), (i32 1))), 4966 (v8i16 (MVE_VQMOVNu32th (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm)))>; 4967 def : Pat<(v16i8 (MVEvqmovnu (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), (i32 0))), 4968 (v16i8 (MVE_VQMOVNu16bh (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm)))>; 4969 def : Pat<(v16i8 (MVEvqmovnu (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), (i32 1))), 4970 (v16i8 (MVE_VQMOVNu16th (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm)))>; 4971 4972 def : Pat<(v8i16 (MVEvqmovns (v8i16 MQPR:$Qd_src), (v4i32 (ARMvshrsImm (v4i32 MQPR:$Qm), imm0_31:$imm)), (i32 0))), 4973 (v8i16 (MVE_VQSHRNbhs32 (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), imm0_31:$imm))>; 4974 def : Pat<(v16i8 (MVEvqmovns (v16i8 MQPR:$Qd_src), (v8i16 (ARMvshrsImm (v8i16 MQPR:$Qm), imm0_15:$imm)), (i32 0))), 4975 (v16i8 (MVE_VQSHRNbhs16 (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), imm0_15:$imm))>; 4976 def : Pat<(v8i16 (MVEvqmovns (v8i16 MQPR:$Qd_src), (v4i32 (ARMvshrsImm (v4i32 MQPR:$Qm), imm0_31:$imm)), (i32 1))), 4977 (v8i16 (MVE_VQSHRNths32 (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), imm0_31:$imm))>; 4978 def : Pat<(v16i8 (MVEvqmovns (v16i8 MQPR:$Qd_src), (v8i16 (ARMvshrsImm (v8i16 MQPR:$Qm), imm0_15:$imm)), (i32 1))), 4979 (v16i8 (MVE_VQSHRNths16 (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), imm0_15:$imm))>; 4980 4981 def : Pat<(v8i16 (MVEvqmovnu (v8i16 MQPR:$Qd_src), (v4i32 (ARMvshruImm (v4i32 MQPR:$Qm), imm0_31:$imm)), (i32 0))), 4982 (v8i16 (MVE_VQSHRNbhu32 (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), imm0_31:$imm))>; 4983 def : Pat<(v16i8 (MVEvqmovnu (v16i8 MQPR:$Qd_src), (v8i16 (ARMvshruImm (v8i16 MQPR:$Qm), imm0_15:$imm)), (i32 0))), 4984 (v16i8 (MVE_VQSHRNbhu16 (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), imm0_15:$imm))>; 4985 def : Pat<(v8i16 (MVEvqmovnu (v8i16 MQPR:$Qd_src), (v4i32 (ARMvshruImm (v4i32 MQPR:$Qm), imm0_31:$imm)), (i32 1))), 4986 (v8i16 (MVE_VQSHRNthu32 (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), imm0_31:$imm))>; 4987 def : Pat<(v16i8 (MVEvqmovnu (v16i8 MQPR:$Qd_src), (v8i16 (ARMvshruImm (v8i16 MQPR:$Qm), imm0_15:$imm)), (i32 1))), 4988 (v16i8 (MVE_VQSHRNthu16 (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), imm0_15:$imm))>; 4989} 4990 4991class MVE_VCVT_ff<string iname, string suffix, bit op, bit T, 4992 dag iops_extra, vpred_ops vpred, string cstr> 4993 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd), 4994 !con(iops_extra, (ins MQPR:$Qm)), "$Qd, $Qm", 4995 vpred, cstr, 0b10, []> { 4996 let Inst{28} = op; 4997 let Inst{21-16} = 0b111111; 4998 let Inst{12} = T; 4999 let Inst{8-7} = 0b00; 5000 let Inst{0} = 0b1; 5001 5002 let Predicates = [HasMVEFloat]; 5003 let retainsPreviousHalfElement = 1; 5004} 5005 5006def SDTARMVCVTL : SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisVec<1>, 5007 SDTCisVT<2, i32>]>; 5008def MVEvcvtn : SDNode<"ARMISD::VCVTN", SDTARMVMOVNQ>; 5009def MVEvcvtl : SDNode<"ARMISD::VCVTL", SDTARMVCVTL>; 5010 5011multiclass MVE_VCVT_f2h_m<string iname, int half> { 5012 def "": MVE_VCVT_ff<iname, "f16.f32", 0b0, half, 5013 (ins MQPR:$Qd_src), vpred_n, "$Qd = $Qd_src">; 5014 defvar Inst = !cast<Instruction>(NAME); 5015 5016 let Predicates = [HasMVEFloat] in { 5017 def : Pat<(v8f16 (int_arm_mve_vcvt_narrow 5018 (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm), (i32 half))), 5019 (v8f16 (Inst (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm)))>; 5020 def : Pat<(v8f16 (int_arm_mve_vcvt_narrow_predicated 5021 (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm), (i32 half), 5022 (v4i1 VCCR:$mask))), 5023 (v8f16 (Inst (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm), 5024 ARMVCCThen, (v4i1 VCCR:$mask), zero_reg))>; 5025 5026 def : Pat<(v8f16 (MVEvcvtn (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm), (i32 half))), 5027 (v8f16 (Inst (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm)))>; 5028 } 5029} 5030 5031multiclass MVE_VCVT_h2f_m<string iname, int half> { 5032 def "": MVE_VCVT_ff<iname, "f32.f16", 0b1, half, (ins), vpred_r, "">; 5033 defvar Inst = !cast<Instruction>(NAME); 5034 5035 let Predicates = [HasMVEFloat] in { 5036 def : Pat<(v4f32 (int_arm_mve_vcvt_widen (v8f16 MQPR:$Qm), (i32 half))), 5037 (v4f32 (Inst (v8f16 MQPR:$Qm)))>; 5038 def : Pat<(v4f32 (int_arm_mve_vcvt_widen_predicated 5039 (v4f32 MQPR:$inactive), (v8f16 MQPR:$Qm), (i32 half), 5040 (v4i1 VCCR:$mask))), 5041 (v4f32 (Inst (v8f16 MQPR:$Qm), ARMVCCThen, 5042 (v4i1 VCCR:$mask), zero_reg, (v4f32 MQPR:$inactive)))>; 5043 5044 def : Pat<(v4f32 (MVEvcvtl (v8f16 MQPR:$Qm), (i32 half))), 5045 (v4f32 (Inst (v8f16 MQPR:$Qm)))>; 5046 } 5047} 5048 5049defm MVE_VCVTf16f32bh : MVE_VCVT_f2h_m<"vcvtb", 0b0>; 5050defm MVE_VCVTf16f32th : MVE_VCVT_f2h_m<"vcvtt", 0b1>; 5051defm MVE_VCVTf32f16bh : MVE_VCVT_h2f_m<"vcvtb", 0b0>; 5052defm MVE_VCVTf32f16th : MVE_VCVT_h2f_m<"vcvtt", 0b1>; 5053 5054class MVE_VxCADD<string iname, string suffix, bits<2> size, bit halve, 5055 string cstr=""> 5056 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd), 5057 (ins MQPR:$Qn, MQPR:$Qm, complexrotateopodd:$rot), 5058 "$Qd, $Qn, $Qm, $rot", vpred_r, cstr, size, []> { 5059 bits<4> Qn; 5060 bit rot; 5061 5062 let Inst{28} = halve; 5063 let Inst{21-20} = size; 5064 let Inst{19-17} = Qn{2-0}; 5065 let Inst{16} = 0b0; 5066 let Inst{12} = rot; 5067 let Inst{8} = 0b1; 5068 let Inst{7} = Qn{3}; 5069 let Inst{0} = 0b0; 5070} 5071 5072multiclass MVE_VxCADD_m<string iname, MVEVectorVTInfo VTI, 5073 bit halve, string cstr=""> { 5074 def "" : MVE_VxCADD<iname, VTI.Suffix, VTI.Size, halve, cstr>; 5075 defvar Inst = !cast<Instruction>(NAME); 5076 5077 let Predicates = [HasMVEInt] in { 5078 def : Pat<(VTI.Vec (int_arm_mve_vcaddq halve, 5079 imm:$rot, (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))), 5080 (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 5081 imm:$rot))>; 5082 5083 def : Pat<(VTI.Vec (int_arm_mve_vcaddq_predicated halve, 5084 imm:$rot, (VTI.Vec MQPR:$inactive), 5085 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 5086 (VTI.Pred VCCR:$mask))), 5087 (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 5088 imm:$rot, ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 5089 (VTI.Vec MQPR:$inactive)))>; 5090 5091 } 5092} 5093 5094defm MVE_VCADDi8 : MVE_VxCADD_m<"vcadd", MVE_v16i8, 0b1>; 5095defm MVE_VCADDi16 : MVE_VxCADD_m<"vcadd", MVE_v8i16, 0b1>; 5096defm MVE_VCADDi32 : MVE_VxCADD_m<"vcadd", MVE_v4i32, 0b1, "@earlyclobber $Qd">; 5097 5098defm MVE_VHCADDs8 : MVE_VxCADD_m<"vhcadd", MVE_v16s8, 0b0>; 5099defm MVE_VHCADDs16 : MVE_VxCADD_m<"vhcadd", MVE_v8s16, 0b0>; 5100defm MVE_VHCADDs32 : MVE_VxCADD_m<"vhcadd", MVE_v4s32, 0b0, "@earlyclobber $Qd">; 5101 5102class MVE_VADCSBC<string iname, bit I, bit subtract, 5103 dag carryin, list<dag> pattern=[]> 5104 : MVE_qDest_qSrc<iname, "i32", (outs MQPR:$Qd, cl_FPSCR_NZCV:$carryout), 5105 !con((ins MQPR:$Qn, MQPR:$Qm), carryin), 5106 "$Qd, $Qn, $Qm", vpred_r, "", 0b10, pattern> { 5107 bits<4> Qn; 5108 5109 let Inst{28} = subtract; 5110 let Inst{21-20} = 0b11; 5111 let Inst{19-17} = Qn{2-0}; 5112 let Inst{16} = 0b0; 5113 let Inst{12} = I; 5114 let Inst{8} = 0b1; 5115 let Inst{7} = Qn{3}; 5116 let Inst{0} = 0b0; 5117 5118 // Custom decoder method in order to add the FPSCR operand(s), which 5119 // Tablegen won't do right 5120 let DecoderMethod = "DecodeMVEVADCInstruction"; 5121} 5122 5123def MVE_VADC : MVE_VADCSBC<"vadc", 0b0, 0b0, (ins cl_FPSCR_NZCV:$carryin)>; 5124def MVE_VADCI : MVE_VADCSBC<"vadci", 0b1, 0b0, (ins)>; 5125 5126def MVE_VSBC : MVE_VADCSBC<"vsbc", 0b0, 0b1, (ins cl_FPSCR_NZCV:$carryin)>; 5127def MVE_VSBCI : MVE_VADCSBC<"vsbci", 0b1, 0b1, (ins)>; 5128 5129class MVE_VQDMULL<string iname, string suffix, bit size, bit T, 5130 string cstr="", list<dag> pattern=[]> 5131 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd), 5132 (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm", 5133 vpred_r, cstr, !if(size, 0b10, 0b01), pattern> { 5134 bits<4> Qn; 5135 5136 let Inst{28} = size; 5137 let Inst{21-20} = 0b11; 5138 let Inst{19-17} = Qn{2-0}; 5139 let Inst{16} = 0b0; 5140 let Inst{12} = T; 5141 let Inst{8} = 0b1; 5142 let Inst{7} = Qn{3}; 5143 let Inst{0} = 0b1; 5144 let validForTailPredication = 1; 5145 let doubleWidthResult = 1; 5146} 5147 5148multiclass MVE_VQDMULL_m<string iname, MVEVectorVTInfo VTI, bit size, bit T, 5149 string cstr> { 5150 def "" : MVE_VQDMULL<iname, VTI.Suffix, size, T, cstr>; 5151 defvar Inst = !cast<Instruction>(NAME); 5152 5153 let Predicates = [HasMVEInt] in { 5154 // Unpredicated saturating multiply 5155 def : Pat<(VTI.DblVec (int_arm_mve_vqdmull (VTI.Vec MQPR:$Qm), 5156 (VTI.Vec MQPR:$Qn), (i32 T))), 5157 (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>; 5158 // Predicated saturating multiply 5159 def : Pat<(VTI.DblVec (int_arm_mve_vqdmull_predicated 5160 (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 5161 (i32 T), (VTI.DblPred VCCR:$mask), 5162 (VTI.DblVec MQPR:$inactive))), 5163 (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 5164 ARMVCCThen, (VTI.DblPred VCCR:$mask), zero_reg, 5165 (VTI.DblVec MQPR:$inactive)))>; 5166 } 5167} 5168 5169multiclass MVE_VQDMULL_halves<MVEVectorVTInfo VTI, bit size, string cstr=""> { 5170 defm bh : MVE_VQDMULL_m<"vqdmullb", VTI, size, 0b0, cstr>; 5171 defm th : MVE_VQDMULL_m<"vqdmullt", VTI, size, 0b1, cstr>; 5172} 5173 5174defm MVE_VQDMULLs16 : MVE_VQDMULL_halves<MVE_v8s16, 0b0>; 5175defm MVE_VQDMULLs32 : MVE_VQDMULL_halves<MVE_v4s32, 0b1, "@earlyclobber $Qd">; 5176 5177// end of mve_qDest_qSrc 5178 5179// start of mve_qDest_rSrc 5180 5181class MVE_qr_base<dag oops, dag iops, string iname, string suffix, string ops, 5182 vpred_ops vpred, string cstr, bits<2> vecsize, list<dag> pattern=[]> 5183 : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, vecsize, pattern> { 5184 bits<4> Qd; 5185 bits<4> Qn; 5186 bits<4> Rm; 5187 5188 let Inst{25-23} = 0b100; 5189 let Inst{22} = Qd{3}; 5190 let Inst{19-17} = Qn{2-0}; 5191 let Inst{15-13} = Qd{2-0}; 5192 let Inst{11-9} = 0b111; 5193 let Inst{7} = Qn{3}; 5194 let Inst{6} = 0b1; 5195 let Inst{4} = 0b0; 5196 let Inst{3-0} = Rm{3-0}; 5197} 5198 5199class MVE_qDest_rSrc<string iname, string suffix, string cstr="", bits<2> vecsize, list<dag> pattern=[]> 5200 : MVE_qr_base<(outs MQPR:$Qd), (ins MQPR:$Qn, rGPR:$Rm), 5201 iname, suffix, "$Qd, $Qn, $Rm", vpred_r, cstr, 5202 vecsize, pattern>; 5203 5204class MVE_qDestSrc_rSrc<string iname, string suffix, bits<2> vecsize, list<dag> pattern=[]> 5205 : MVE_qr_base<(outs MQPR:$Qd), (ins MQPR:$Qd_src, MQPR:$Qn, rGPR:$Rm), 5206 iname, suffix, "$Qd, $Qn, $Rm", vpred_n, "$Qd = $Qd_src", 5207 vecsize, pattern>; 5208 5209class MVE_qDest_single_rSrc<string iname, string suffix, bits<2> vecsize, list<dag> pattern=[]> 5210 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qd_src, rGPR:$Rm), NoItinerary, iname, 5211 suffix, "$Qd, $Rm", vpred_n, "$Qd = $Qd_src", vecsize, pattern> { 5212 bits<4> Qd; 5213 bits<4> Rm; 5214 5215 let Inst{22} = Qd{3}; 5216 let Inst{15-13} = Qd{2-0}; 5217 let Inst{3-0} = Rm{3-0}; 5218} 5219 5220// Patterns for vector-scalar instructions with integer operands 5221multiclass MVE_vec_scalar_int_pat_m<Instruction inst, MVEVectorVTInfo VTI, 5222 SDPatternOperator unpred_op, 5223 SDPatternOperator pred_op, 5224 bit unpred_has_sign = 0, 5225 bit pred_has_sign = 0> { 5226 defvar UnpredSign = !if(unpred_has_sign, (? (i32 VTI.Unsigned)), (?)); 5227 defvar PredSign = !if(pred_has_sign, (? (i32 VTI.Unsigned)), (?)); 5228 5229 let Predicates = [HasMVEInt] in { 5230 // Unpredicated version 5231 def : Pat<(VTI.Vec !con((unpred_op (VTI.Vec MQPR:$Qm), 5232 (VTI.Vec (ARMvdup rGPR:$val))), 5233 UnpredSign)), 5234 (VTI.Vec (inst (VTI.Vec MQPR:$Qm), (i32 rGPR:$val)))>; 5235 // Predicated version 5236 def : Pat<(VTI.Vec !con((pred_op (VTI.Vec MQPR:$Qm), 5237 (VTI.Vec (ARMvdup rGPR:$val))), 5238 PredSign, 5239 (pred_op (VTI.Pred VCCR:$mask), 5240 (VTI.Vec MQPR:$inactive)))), 5241 (VTI.Vec (inst (VTI.Vec MQPR:$Qm), (i32 rGPR:$val), 5242 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 5243 (VTI.Vec MQPR:$inactive)))>; 5244 } 5245} 5246 5247class MVE_VADDSUB_qr<string iname, string suffix, bits<2> size, 5248 bit bit_5, bit bit_12, bit bit_16, bit bit_28> 5249 : MVE_qDest_rSrc<iname, suffix, "", size> { 5250 5251 let Inst{28} = bit_28; 5252 let Inst{21-20} = size; 5253 let Inst{16} = bit_16; 5254 let Inst{12} = bit_12; 5255 let Inst{8} = 0b1; 5256 let Inst{5} = bit_5; 5257 let validForTailPredication = 1; 5258} 5259 5260// Vector-scalar add/sub 5261multiclass MVE_VADDSUB_qr_m<string iname, MVEVectorVTInfo VTI, bit subtract, 5262 SDNode Op, Intrinsic PredInt> { 5263 def "" : MVE_VADDSUB_qr<iname, VTI.Suffix, VTI.Size, 0b0, subtract, 0b1, 0b0>; 5264 let Predicates = [HasMVEInt] in { 5265 defm : MVE_TwoOpPatternDup<VTI, Op, PredInt, (? ), !cast<Instruction>(NAME), ARMimmAllZerosV>; 5266 } 5267} 5268 5269multiclass MVE_VADD_qr_m<MVEVectorVTInfo VTI> 5270 : MVE_VADDSUB_qr_m<"vadd", VTI, 0b0, add, int_arm_mve_add_predicated>; 5271 5272multiclass MVE_VSUB_qr_m<MVEVectorVTInfo VTI> 5273 : MVE_VADDSUB_qr_m<"vsub", VTI, 0b1, sub, int_arm_mve_sub_predicated>; 5274 5275defm MVE_VADD_qr_i8 : MVE_VADD_qr_m<MVE_v16i8>; 5276defm MVE_VADD_qr_i16 : MVE_VADD_qr_m<MVE_v8i16>; 5277defm MVE_VADD_qr_i32 : MVE_VADD_qr_m<MVE_v4i32>; 5278 5279defm MVE_VSUB_qr_i8 : MVE_VSUB_qr_m<MVE_v16i8>; 5280defm MVE_VSUB_qr_i16 : MVE_VSUB_qr_m<MVE_v8i16>; 5281defm MVE_VSUB_qr_i32 : MVE_VSUB_qr_m<MVE_v4i32>; 5282 5283// Vector-scalar saturating add/sub 5284multiclass MVE_VQADDSUB_qr_m<string iname, MVEVectorVTInfo VTI, bit subtract, 5285 SDNode Op, Intrinsic PredInt> { 5286 def "" : MVE_VADDSUB_qr<iname, VTI.Suffix, VTI.Size, 0b1, subtract, 5287 0b0, VTI.Unsigned>; 5288 5289 let Predicates = [HasMVEInt] in { 5290 defm : MVE_TwoOpPatternDup<VTI, Op, PredInt, (? (i32 VTI.Unsigned)), 5291 !cast<Instruction>(NAME)>; 5292 } 5293} 5294 5295multiclass MVE_VQADD_qr_m<MVEVectorVTInfo VTI, SDNode Op> 5296 : MVE_VQADDSUB_qr_m<"vqadd", VTI, 0b0, Op, int_arm_mve_qadd_predicated>; 5297 5298multiclass MVE_VQSUB_qr_m<MVEVectorVTInfo VTI, SDNode Op> 5299 : MVE_VQADDSUB_qr_m<"vqsub", VTI, 0b1, Op, int_arm_mve_qsub_predicated>; 5300 5301defm MVE_VQADD_qr_s8 : MVE_VQADD_qr_m<MVE_v16s8, saddsat>; 5302defm MVE_VQADD_qr_s16 : MVE_VQADD_qr_m<MVE_v8s16, saddsat>; 5303defm MVE_VQADD_qr_s32 : MVE_VQADD_qr_m<MVE_v4s32, saddsat>; 5304defm MVE_VQADD_qr_u8 : MVE_VQADD_qr_m<MVE_v16u8, uaddsat>; 5305defm MVE_VQADD_qr_u16 : MVE_VQADD_qr_m<MVE_v8u16, uaddsat>; 5306defm MVE_VQADD_qr_u32 : MVE_VQADD_qr_m<MVE_v4u32, uaddsat>; 5307 5308defm MVE_VQSUB_qr_s8 : MVE_VQSUB_qr_m<MVE_v16s8, ssubsat>; 5309defm MVE_VQSUB_qr_s16 : MVE_VQSUB_qr_m<MVE_v8s16, ssubsat>; 5310defm MVE_VQSUB_qr_s32 : MVE_VQSUB_qr_m<MVE_v4s32, ssubsat>; 5311defm MVE_VQSUB_qr_u8 : MVE_VQSUB_qr_m<MVE_v16u8, usubsat>; 5312defm MVE_VQSUB_qr_u16 : MVE_VQSUB_qr_m<MVE_v8u16, usubsat>; 5313defm MVE_VQSUB_qr_u32 : MVE_VQSUB_qr_m<MVE_v4u32, usubsat>; 5314 5315class MVE_VQDMULL_qr<string iname, string suffix, bit size, 5316 bit T, string cstr="", list<dag> pattern=[]> 5317 : MVE_qDest_rSrc<iname, suffix, cstr, !if(size, 0b10, 0b01), pattern> { 5318 5319 let Inst{28} = size; 5320 let Inst{21-20} = 0b11; 5321 let Inst{16} = 0b0; 5322 let Inst{12} = T; 5323 let Inst{8} = 0b1; 5324 let Inst{5} = 0b1; 5325 let validForTailPredication = 1; 5326 let doubleWidthResult = 1; 5327} 5328 5329multiclass MVE_VQDMULL_qr_m<string iname, MVEVectorVTInfo VTI, bit size, 5330 bit T, string cstr> { 5331 def "" : MVE_VQDMULL_qr<iname, VTI.Suffix, size, T, cstr>; 5332 defvar Inst = !cast<Instruction>(NAME); 5333 5334 let Predicates = [HasMVEInt] in { 5335 // Unpredicated saturating multiply 5336 def : Pat<(VTI.DblVec (int_arm_mve_vqdmull (VTI.Vec MQPR:$Qm), 5337 (VTI.Vec (ARMvdup rGPR:$val)), 5338 (i32 T))), 5339 (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (i32 rGPR:$val)))>; 5340 // Predicated saturating multiply 5341 def : Pat<(VTI.DblVec (int_arm_mve_vqdmull_predicated 5342 (VTI.Vec MQPR:$Qm), 5343 (VTI.Vec (ARMvdup rGPR:$val)), 5344 (i32 T), 5345 (VTI.DblPred VCCR:$mask), 5346 (VTI.DblVec MQPR:$inactive))), 5347 (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (i32 rGPR:$val), 5348 ARMVCCThen, (VTI.DblPred VCCR:$mask), zero_reg, 5349 (VTI.DblVec MQPR:$inactive)))>; 5350 } 5351} 5352 5353multiclass MVE_VQDMULL_qr_halves<MVEVectorVTInfo VTI, bit size, string cstr=""> { 5354 defm bh : MVE_VQDMULL_qr_m<"vqdmullb", VTI, size, 0b0, cstr>; 5355 defm th : MVE_VQDMULL_qr_m<"vqdmullt", VTI, size, 0b1, cstr>; 5356} 5357 5358defm MVE_VQDMULL_qr_s16 : MVE_VQDMULL_qr_halves<MVE_v8s16, 0b0>; 5359defm MVE_VQDMULL_qr_s32 : MVE_VQDMULL_qr_halves<MVE_v4s32, 0b1, "@earlyclobber $Qd">; 5360 5361class MVE_VxADDSUB_qr<string iname, string suffix, 5362 bit bit_28, bits<2> size, bit subtract, 5363 bits<2> vecsize, list<dag> pattern=[]> 5364 : MVE_qDest_rSrc<iname, suffix, "", vecsize, pattern> { 5365 5366 let Inst{28} = bit_28; 5367 let Inst{21-20} = size; 5368 let Inst{16} = 0b0; 5369 let Inst{12} = subtract; 5370 let Inst{8} = 0b1; 5371 let Inst{5} = 0b0; 5372 let validForTailPredication = 1; 5373} 5374 5375multiclass MVE_VHADDSUB_qr_m<string iname, MVEVectorVTInfo VTI, bit subtract, 5376 Intrinsic unpred_int, Intrinsic pred_int, PatFrag add_op, 5377 SDNode shift_op> { 5378 def "" : MVE_VxADDSUB_qr<iname, VTI.Suffix, VTI.Unsigned, VTI.Size, subtract, VTI.Size>; 5379 defm : MVE_vec_scalar_int_pat_m<!cast<Instruction>(NAME), 5380 VTI, unpred_int, pred_int, 1, 1>; 5381 defvar Inst = !cast<Instruction>(NAME); 5382 5383 let Predicates = [HasMVEInt] in { 5384 def : Pat<(VTI.Vec (shift_op (add_op (VTI.Vec MQPR:$Qm), (VTI.Vec (ARMvdup rGPR:$Rn))), (i32 1))), 5385 (Inst MQPR:$Qm, rGPR:$Rn)>; 5386 } 5387} 5388 5389multiclass MVE_VHADD_qr_m<MVEVectorVTInfo VTI, PatFrag add_op, SDNode shift_op> : 5390 MVE_VHADDSUB_qr_m<"vhadd", VTI, 0b0, int_arm_mve_vhadd, int_arm_mve_hadd_predicated, 5391 add_op, shift_op>; 5392 5393multiclass MVE_VHSUB_qr_m<MVEVectorVTInfo VTI, PatFrag add_op, SDNode shift_op> : 5394 MVE_VHADDSUB_qr_m<"vhsub", VTI, 0b1, int_arm_mve_vhsub, int_arm_mve_hsub_predicated, 5395 add_op, shift_op>; 5396 5397defm MVE_VHADD_qr_s8 : MVE_VHADD_qr_m<MVE_v16s8, addnsw, ARMvshrsImm>; 5398defm MVE_VHADD_qr_s16 : MVE_VHADD_qr_m<MVE_v8s16, addnsw, ARMvshrsImm>; 5399defm MVE_VHADD_qr_s32 : MVE_VHADD_qr_m<MVE_v4s32, addnsw, ARMvshrsImm>; 5400defm MVE_VHADD_qr_u8 : MVE_VHADD_qr_m<MVE_v16u8, addnuw, ARMvshruImm>; 5401defm MVE_VHADD_qr_u16 : MVE_VHADD_qr_m<MVE_v8u16, addnuw, ARMvshruImm>; 5402defm MVE_VHADD_qr_u32 : MVE_VHADD_qr_m<MVE_v4u32, addnuw, ARMvshruImm>; 5403 5404defm MVE_VHSUB_qr_s8 : MVE_VHSUB_qr_m<MVE_v16s8, subnsw, ARMvshrsImm>; 5405defm MVE_VHSUB_qr_s16 : MVE_VHSUB_qr_m<MVE_v8s16, subnsw, ARMvshrsImm>; 5406defm MVE_VHSUB_qr_s32 : MVE_VHSUB_qr_m<MVE_v4s32, subnsw, ARMvshrsImm>; 5407defm MVE_VHSUB_qr_u8 : MVE_VHSUB_qr_m<MVE_v16u8, subnuw, ARMvshruImm>; 5408defm MVE_VHSUB_qr_u16 : MVE_VHSUB_qr_m<MVE_v8u16, subnuw, ARMvshruImm>; 5409defm MVE_VHSUB_qr_u32 : MVE_VHSUB_qr_m<MVE_v4u32, subnuw, ARMvshruImm>; 5410 5411multiclass MVE_VADDSUB_qr_f<string iname, MVEVectorVTInfo VTI, bit subtract, 5412 SDNode Op, Intrinsic PredInt, SDPatternOperator IdentityVec> { 5413 def "" : MVE_VxADDSUB_qr<iname, VTI.Suffix, VTI.Size{0}, 0b11, subtract, VTI.Size>; 5414 defm : MVE_TwoOpPatternDup<VTI, Op, PredInt, (? ), 5415 !cast<Instruction>(NAME), IdentityVec>; 5416} 5417 5418let Predicates = [HasMVEFloat] in { 5419 defm MVE_VADD_qr_f32 : MVE_VADDSUB_qr_f<"vadd", MVE_v4f32, 0b0, fadd, 5420 int_arm_mve_add_predicated, ARMimmMinusZeroF>; 5421 defm MVE_VADD_qr_f16 : MVE_VADDSUB_qr_f<"vadd", MVE_v8f16, 0b0, fadd, 5422 int_arm_mve_add_predicated, ARMimmMinusZeroH>; 5423 5424 defm MVE_VSUB_qr_f32 : MVE_VADDSUB_qr_f<"vsub", MVE_v4f32, 0b1, fsub, 5425 int_arm_mve_sub_predicated, ARMimmAllZerosV>; 5426 defm MVE_VSUB_qr_f16 : MVE_VADDSUB_qr_f<"vsub", MVE_v8f16, 0b1, fsub, 5427 int_arm_mve_sub_predicated, ARMimmAllZerosV>; 5428} 5429 5430class MVE_VxSHL_qr<string iname, string suffix, bit U, bits<2> size, 5431 bit bit_7, bit bit_17, list<dag> pattern=[]> 5432 : MVE_qDest_single_rSrc<iname, suffix, size, pattern> { 5433 5434 let Inst{28} = U; 5435 let Inst{25-23} = 0b100; 5436 let Inst{21-20} = 0b11; 5437 let Inst{19-18} = size; 5438 let Inst{17} = bit_17; 5439 let Inst{16} = 0b1; 5440 let Inst{12-8} = 0b11110; 5441 let Inst{7} = bit_7; 5442 let Inst{6-4} = 0b110; 5443 let validForTailPredication = 1; 5444} 5445 5446multiclass MVE_VxSHL_qr_p<string iname, MVEVectorVTInfo VTI, bit q, bit r> { 5447 def "" : MVE_VxSHL_qr<iname, VTI.Suffix, VTI.Unsigned, VTI.Size, q, r>; 5448 defvar Inst = !cast<Instruction>(NAME); 5449 5450 def : Pat<(VTI.Vec (int_arm_mve_vshl_scalar 5451 (VTI.Vec MQPR:$in), (i32 rGPR:$sh), 5452 (i32 q), (i32 r), (i32 VTI.Unsigned))), 5453 (VTI.Vec (Inst (VTI.Vec MQPR:$in), (i32 rGPR:$sh)))>; 5454 5455 def : Pat<(VTI.Vec (int_arm_mve_vshl_scalar_predicated 5456 (VTI.Vec MQPR:$in), (i32 rGPR:$sh), 5457 (i32 q), (i32 r), (i32 VTI.Unsigned), 5458 (VTI.Pred VCCR:$mask))), 5459 (VTI.Vec (Inst (VTI.Vec MQPR:$in), (i32 rGPR:$sh), 5460 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>; 5461} 5462 5463multiclass MVE_VxSHL_qr_types<string iname, bit bit_7, bit bit_17> { 5464 defm s8 : MVE_VxSHL_qr_p<iname, MVE_v16s8, bit_7, bit_17>; 5465 defm s16 : MVE_VxSHL_qr_p<iname, MVE_v8s16, bit_7, bit_17>; 5466 defm s32 : MVE_VxSHL_qr_p<iname, MVE_v4s32, bit_7, bit_17>; 5467 defm u8 : MVE_VxSHL_qr_p<iname, MVE_v16u8, bit_7, bit_17>; 5468 defm u16 : MVE_VxSHL_qr_p<iname, MVE_v8u16, bit_7, bit_17>; 5469 defm u32 : MVE_VxSHL_qr_p<iname, MVE_v4u32, bit_7, bit_17>; 5470} 5471 5472defm MVE_VSHL_qr : MVE_VxSHL_qr_types<"vshl", 0b0, 0b0>; 5473defm MVE_VRSHL_qr : MVE_VxSHL_qr_types<"vrshl", 0b0, 0b1>; 5474defm MVE_VQSHL_qr : MVE_VxSHL_qr_types<"vqshl", 0b1, 0b0>; 5475defm MVE_VQRSHL_qr : MVE_VxSHL_qr_types<"vqrshl", 0b1, 0b1>; 5476 5477let Predicates = [HasMVEInt] in { 5478 def : Pat<(v4i32 (ARMvshlu (v4i32 MQPR:$Qm), (v4i32 (ARMvdup rGPR:$Rm)))), 5479 (v4i32 (MVE_VSHL_qru32 (v4i32 MQPR:$Qm), rGPR:$Rm))>; 5480 def : Pat<(v8i16 (ARMvshlu (v8i16 MQPR:$Qm), (v8i16 (ARMvdup rGPR:$Rm)))), 5481 (v8i16 (MVE_VSHL_qru16 (v8i16 MQPR:$Qm), rGPR:$Rm))>; 5482 def : Pat<(v16i8 (ARMvshlu (v16i8 MQPR:$Qm), (v16i8 (ARMvdup rGPR:$Rm)))), 5483 (v16i8 (MVE_VSHL_qru8 (v16i8 MQPR:$Qm), rGPR:$Rm))>; 5484 5485 def : Pat<(v4i32 (ARMvshls (v4i32 MQPR:$Qm), (v4i32 (ARMvdup rGPR:$Rm)))), 5486 (v4i32 (MVE_VSHL_qrs32 (v4i32 MQPR:$Qm), rGPR:$Rm))>; 5487 def : Pat<(v8i16 (ARMvshls (v8i16 MQPR:$Qm), (v8i16 (ARMvdup rGPR:$Rm)))), 5488 (v8i16 (MVE_VSHL_qrs16 (v8i16 MQPR:$Qm), rGPR:$Rm))>; 5489 def : Pat<(v16i8 (ARMvshls (v16i8 MQPR:$Qm), (v16i8 (ARMvdup rGPR:$Rm)))), 5490 (v16i8 (MVE_VSHL_qrs8 (v16i8 MQPR:$Qm), rGPR:$Rm))>; 5491} 5492 5493class MVE_VBRSR<string iname, string suffix, bits<2> size, list<dag> pattern=[]> 5494 : MVE_qDest_rSrc<iname, suffix, "", size, pattern> { 5495 5496 let Inst{28} = 0b1; 5497 let Inst{21-20} = size; 5498 let Inst{16} = 0b1; 5499 let Inst{12} = 0b1; 5500 let Inst{8} = 0b0; 5501 let Inst{5} = 0b1; 5502 let validForTailPredication = 1; 5503} 5504 5505def MVE_VBRSR8 : MVE_VBRSR<"vbrsr", "8", 0b00>; 5506def MVE_VBRSR16 : MVE_VBRSR<"vbrsr", "16", 0b01>; 5507def MVE_VBRSR32 : MVE_VBRSR<"vbrsr", "32", 0b10>; 5508 5509multiclass MVE_VBRSR_pat_m<MVEVectorVTInfo VTI, Instruction Inst> { 5510 // Unpredicated 5511 def : Pat<(VTI.Vec (int_arm_mve_vbrsr (VTI.Vec MQPR:$Qn), (i32 rGPR:$Rm))), 5512 (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (i32 rGPR:$Rm)))>; 5513 // Predicated 5514 def : Pat<(VTI.Vec (int_arm_mve_vbrsr_predicated 5515 (VTI.Vec MQPR:$inactive), 5516 (VTI.Vec MQPR:$Qn), (i32 rGPR:$Rm), 5517 (VTI.Pred VCCR:$mask))), 5518 (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (i32 rGPR:$Rm), 5519 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 5520 (VTI.Vec MQPR:$inactive)))>; 5521} 5522 5523let Predicates = [HasMVEInt] in { 5524 def : Pat<(v16i8 ( bitreverse (v16i8 MQPR:$val1))), 5525 (v16i8 ( MVE_VBRSR8 (v16i8 MQPR:$val1), (t2MOVi (i32 8)) ))>; 5526 5527 def : Pat<(v4i32 ( bitreverse (v4i32 MQPR:$val1))), 5528 (v4i32 ( MVE_VBRSR32 (v4i32 MQPR:$val1), (t2MOVi (i32 32)) ))>; 5529 5530 def : Pat<(v8i16 ( bitreverse (v8i16 MQPR:$val1))), 5531 (v8i16 ( MVE_VBRSR16 (v8i16 MQPR:$val1), (t2MOVi (i32 16)) ))>; 5532 5533 defm : MVE_VBRSR_pat_m<MVE_v16i8, MVE_VBRSR8>; 5534 defm : MVE_VBRSR_pat_m<MVE_v8i16, MVE_VBRSR16>; 5535 defm : MVE_VBRSR_pat_m<MVE_v4i32, MVE_VBRSR32>; 5536} 5537 5538let Predicates = [HasMVEFloat] in { 5539 defm : MVE_VBRSR_pat_m<MVE_v8f16, MVE_VBRSR16>; 5540 defm : MVE_VBRSR_pat_m<MVE_v4f32, MVE_VBRSR32>; 5541} 5542 5543class MVE_VMUL_qr_int<string iname, string suffix, bits<2> size> 5544 : MVE_qDest_rSrc<iname, suffix, "", size> { 5545 5546 let Inst{28} = 0b0; 5547 let Inst{21-20} = size; 5548 let Inst{16} = 0b1; 5549 let Inst{12} = 0b1; 5550 let Inst{8} = 0b0; 5551 let Inst{5} = 0b1; 5552 let validForTailPredication = 1; 5553} 5554 5555multiclass MVE_VMUL_qr_int_m<MVEVectorVTInfo VTI> { 5556 def "" : MVE_VMUL_qr_int<"vmul", VTI.Suffix, VTI.Size>; 5557 let Predicates = [HasMVEInt] in { 5558 defm : MVE_TwoOpPatternDup<VTI, mul, int_arm_mve_mul_predicated, (? ), 5559 !cast<Instruction>(NAME), ARMimmOneV>; 5560 } 5561} 5562 5563defm MVE_VMUL_qr_i8 : MVE_VMUL_qr_int_m<MVE_v16i8>; 5564defm MVE_VMUL_qr_i16 : MVE_VMUL_qr_int_m<MVE_v8i16>; 5565defm MVE_VMUL_qr_i32 : MVE_VMUL_qr_int_m<MVE_v4i32>; 5566 5567class MVE_VxxMUL_qr<string iname, string suffix, 5568 bit bit_28, bits<2> size, bits<2> vecsize, list<dag> pattern=[]> 5569 : MVE_qDest_rSrc<iname, suffix, "", vecsize, pattern> { 5570 5571 let Inst{28} = bit_28; 5572 let Inst{21-20} = size; 5573 let Inst{16} = 0b1; 5574 let Inst{12} = 0b0; 5575 let Inst{8} = 0b0; 5576 let Inst{5} = 0b1; 5577 let validForTailPredication = 1; 5578} 5579 5580multiclass MVE_VxxMUL_qr_m<string iname, MVEVectorVTInfo VTI, bit bit_28, 5581 PatFrag Op, Intrinsic int_unpred, Intrinsic int_pred> { 5582 def "" : MVE_VxxMUL_qr<iname, VTI.Suffix, bit_28, VTI.Size, VTI.Size>; 5583 5584 let Predicates = [HasMVEInt] in { 5585 defm : MVE_TwoOpPatternDup<VTI, Op, int_pred, (? ), !cast<Instruction>(NAME)>; 5586 } 5587 defm : MVE_vec_scalar_int_pat_m<!cast<Instruction>(NAME), VTI, int_unpred, int_pred>; 5588} 5589 5590multiclass MVE_VQDMULH_qr_m<MVEVectorVTInfo VTI> : 5591 MVE_VxxMUL_qr_m<"vqdmulh", VTI, 0b0, MVEvqdmulh, 5592 int_arm_mve_vqdmulh, int_arm_mve_qdmulh_predicated>; 5593 5594multiclass MVE_VQRDMULH_qr_m<MVEVectorVTInfo VTI> : 5595 MVE_VxxMUL_qr_m<"vqrdmulh", VTI, 0b1, null_frag, 5596 int_arm_mve_vqrdmulh, int_arm_mve_qrdmulh_predicated>; 5597 5598defm MVE_VQDMULH_qr_s8 : MVE_VQDMULH_qr_m<MVE_v16s8>; 5599defm MVE_VQDMULH_qr_s16 : MVE_VQDMULH_qr_m<MVE_v8s16>; 5600defm MVE_VQDMULH_qr_s32 : MVE_VQDMULH_qr_m<MVE_v4s32>; 5601 5602defm MVE_VQRDMULH_qr_s8 : MVE_VQRDMULH_qr_m<MVE_v16s8>; 5603defm MVE_VQRDMULH_qr_s16 : MVE_VQRDMULH_qr_m<MVE_v8s16>; 5604defm MVE_VQRDMULH_qr_s32 : MVE_VQRDMULH_qr_m<MVE_v4s32>; 5605 5606multiclass MVE_VxxMUL_qr_f_m<MVEVectorVTInfo VTI, SDPatternOperator IdentityVec> { 5607 let validForTailPredication = 1 in 5608 def "" : MVE_VxxMUL_qr<"vmul", VTI.Suffix, VTI.Size{0}, 0b11, VTI.Size>; 5609 defm : MVE_TwoOpPatternDup<VTI, fmul, int_arm_mve_mul_predicated, (? ), 5610 !cast<Instruction>(NAME), IdentityVec>; 5611} 5612 5613let Predicates = [HasMVEFloat] in { 5614 defm MVE_VMUL_qr_f16 : MVE_VxxMUL_qr_f_m<MVE_v8f16, ARMimmOneH>; 5615 defm MVE_VMUL_qr_f32 : MVE_VxxMUL_qr_f_m<MVE_v4f32, ARMimmOneF>; 5616} 5617 5618class MVE_VFMAMLA_qr<string iname, string suffix, 5619 bit bit_28, bits<2> bits_21_20, bit S, 5620 bits<2> vecsize, list<dag> pattern=[]> 5621 : MVE_qDestSrc_rSrc<iname, suffix, vecsize, pattern> { 5622 5623 let Inst{28} = bit_28; 5624 let Inst{21-20} = bits_21_20; 5625 let Inst{16} = 0b1; 5626 let Inst{12} = S; 5627 let Inst{8} = 0b0; 5628 let Inst{5} = 0b0; 5629 let validForTailPredication = 1; 5630 let hasSideEffects = 0; 5631} 5632 5633multiclass MVE_VMLA_qr_multi<string iname, MVEVectorVTInfo VTI, 5634 bit scalar_addend> { 5635 def "": MVE_VFMAMLA_qr<iname, VTI.Suffix, VTI.Unsigned, VTI.Size, 5636 scalar_addend, VTI.Size>; 5637 defvar Inst = !cast<Instruction>(NAME); 5638 defvar pred_int = !cast<Intrinsic>("int_arm_mve_" # iname # "_n_predicated"); 5639 defvar v1 = (VTI.Vec MQPR:$v1); 5640 defvar v2 = (VTI.Vec MQPR:$v2); 5641 defvar vs = (VTI.Vec (ARMvdup rGPR:$s)); 5642 defvar s = (i32 rGPR:$s); 5643 defvar pred = (VTI.Pred VCCR:$pred); 5644 5645 // The signed and unsigned variants of this instruction have different 5646 // encodings, but they're functionally identical. For the sake of 5647 // determinism, we generate only the unsigned variant. 5648 if VTI.Unsigned then let Predicates = [HasMVEInt] in { 5649 if scalar_addend then { 5650 def : Pat<(VTI.Vec (add (mul v1, v2), vs)), 5651 (VTI.Vec (Inst v1, v2, s))>; 5652 } else { 5653 def : Pat<(VTI.Vec (add (mul v2, vs), v1)), 5654 (VTI.Vec (Inst v1, v2, s))>; 5655 } 5656 5657 def : Pat<(VTI.Vec (pred_int v1, v2, s, pred)), 5658 (VTI.Vec (Inst v1, v2, s, ARMVCCThen, pred, zero_reg))>; 5659 } 5660} 5661 5662defm MVE_VMLA_qr_s8 : MVE_VMLA_qr_multi<"vmla", MVE_v16s8, 0b0>; 5663defm MVE_VMLA_qr_s16 : MVE_VMLA_qr_multi<"vmla", MVE_v8s16, 0b0>; 5664defm MVE_VMLA_qr_s32 : MVE_VMLA_qr_multi<"vmla", MVE_v4s32, 0b0>; 5665defm MVE_VMLA_qr_u8 : MVE_VMLA_qr_multi<"vmla", MVE_v16u8, 0b0>; 5666defm MVE_VMLA_qr_u16 : MVE_VMLA_qr_multi<"vmla", MVE_v8u16, 0b0>; 5667defm MVE_VMLA_qr_u32 : MVE_VMLA_qr_multi<"vmla", MVE_v4u32, 0b0>; 5668 5669defm MVE_VMLAS_qr_s8 : MVE_VMLA_qr_multi<"vmlas", MVE_v16s8, 0b1>; 5670defm MVE_VMLAS_qr_s16 : MVE_VMLA_qr_multi<"vmlas", MVE_v8s16, 0b1>; 5671defm MVE_VMLAS_qr_s32 : MVE_VMLA_qr_multi<"vmlas", MVE_v4s32, 0b1>; 5672defm MVE_VMLAS_qr_u8 : MVE_VMLA_qr_multi<"vmlas", MVE_v16u8, 0b1>; 5673defm MVE_VMLAS_qr_u16 : MVE_VMLA_qr_multi<"vmlas", MVE_v8u16, 0b1>; 5674defm MVE_VMLAS_qr_u32 : MVE_VMLA_qr_multi<"vmlas", MVE_v4u32, 0b1>; 5675 5676multiclass MVE_VFMA_qr_multi<string iname, MVEVectorVTInfo VTI, 5677 bit scalar_addend> { 5678 def "": MVE_VFMAMLA_qr<iname, VTI.Suffix, VTI.Size{0}, 0b11, scalar_addend, VTI.Size>; 5679 defvar Inst = !cast<Instruction>(NAME); 5680 defvar pred_int = int_arm_mve_fma_predicated; 5681 defvar v1 = (VTI.Vec MQPR:$v1); 5682 defvar v2 = (VTI.Vec MQPR:$v2); 5683 defvar vs = (VTI.Vec (ARMvdup (i32 rGPR:$s))); 5684 defvar is = (i32 rGPR:$s); 5685 defvar pred = (VTI.Pred VCCR:$pred); 5686 5687 let Predicates = [HasMVEFloat] in { 5688 if scalar_addend then { 5689 def : Pat<(VTI.Vec (fma v1, v2, vs)), 5690 (VTI.Vec (Inst v1, v2, is))>; 5691 def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred), 5692 (VTI.Vec (fma v1, v2, vs)), 5693 v1)), 5694 (VTI.Vec (Inst v1, v2, is, ARMVCCThen, $pred, zero_reg))>; 5695 def : Pat<(VTI.Vec (pred_int v1, v2, vs, pred)), 5696 (VTI.Vec (Inst v1, v2, is, ARMVCCThen, pred, zero_reg))>; 5697 } else { 5698 def : Pat<(VTI.Vec (fma v1, vs, v2)), 5699 (VTI.Vec (Inst v2, v1, is))>; 5700 def : Pat<(VTI.Vec (fma vs, v1, v2)), 5701 (VTI.Vec (Inst v2, v1, is))>; 5702 def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred), 5703 (VTI.Vec (fma vs, v2, v1)), 5704 v1)), 5705 (VTI.Vec (Inst v1, v2, is, ARMVCCThen, $pred, zero_reg))>; 5706 def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred), 5707 (VTI.Vec (fma v2, vs, v1)), 5708 v1)), 5709 (VTI.Vec (Inst v1, v2, is, ARMVCCThen, $pred, zero_reg))>; 5710 def : Pat<(VTI.Vec (pred_int v1, vs, v2, pred)), 5711 (VTI.Vec (Inst v2, v1, is, ARMVCCThen, pred, zero_reg))>; 5712 def : Pat<(VTI.Vec (pred_int vs, v1, v2, pred)), 5713 (VTI.Vec (Inst v2, v1, is, ARMVCCThen, pred, zero_reg))>; 5714 } 5715 } 5716} 5717 5718let Predicates = [HasMVEFloat] in { 5719 defm MVE_VFMA_qr_f16 : MVE_VFMA_qr_multi<"vfma", MVE_v8f16, 0>; 5720 defm MVE_VFMA_qr_f32 : MVE_VFMA_qr_multi<"vfma", MVE_v4f32, 0>; 5721 defm MVE_VFMA_qr_Sf16 : MVE_VFMA_qr_multi<"vfmas", MVE_v8f16, 1>; 5722 defm MVE_VFMA_qr_Sf32 : MVE_VFMA_qr_multi<"vfmas", MVE_v4f32, 1>; 5723} 5724 5725class MVE_VQDMLAH_qr<string iname, string suffix, bit U, bits<2> size, 5726 bit bit_5, bit bit_12, list<dag> pattern=[]> 5727 : MVE_qDestSrc_rSrc<iname, suffix, size, pattern> { 5728 5729 let Inst{28} = U; 5730 let Inst{21-20} = size; 5731 let Inst{16} = 0b0; 5732 let Inst{12} = bit_12; 5733 let Inst{8} = 0b0; 5734 let Inst{5} = bit_5; 5735} 5736 5737multiclass MVE_VQDMLAH_qr_multi<string iname, MVEVectorVTInfo VTI, 5738 bit bit_5, bit bit_12> { 5739 def "": MVE_VQDMLAH_qr<iname, VTI.Suffix, 0b0, VTI.Size, bit_5, bit_12>; 5740 defvar Inst = !cast<Instruction>(NAME); 5741 defvar unpred_int = !cast<Intrinsic>("int_arm_mve_" # iname); 5742 defvar pred_int = !cast<Intrinsic>("int_arm_mve_" # iname # "_predicated"); 5743 5744 let Predicates = [HasMVEInt] in { 5745 def : Pat<(VTI.Vec (unpred_int (VTI.Vec MQPR:$v1), (VTI.Vec MQPR:$v2), 5746 (i32 rGPR:$s))), 5747 (VTI.Vec (Inst (VTI.Vec MQPR:$v1), (VTI.Vec MQPR:$v2), 5748 (i32 rGPR:$s)))>; 5749 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$v1), (VTI.Vec MQPR:$v2), 5750 (i32 rGPR:$s), (VTI.Pred VCCR:$pred))), 5751 (VTI.Vec (Inst (VTI.Vec MQPR:$v1), (VTI.Vec MQPR:$v2), 5752 (i32 rGPR:$s), ARMVCCThen, 5753 (VTI.Pred VCCR:$pred), zero_reg))>; 5754 } 5755} 5756 5757multiclass MVE_VQDMLAH_qr_types<string iname, bit bit_5, bit bit_12> { 5758 defm s8 : MVE_VQDMLAH_qr_multi<iname, MVE_v16s8, bit_5, bit_12>; 5759 defm s16 : MVE_VQDMLAH_qr_multi<iname, MVE_v8s16, bit_5, bit_12>; 5760 defm s32 : MVE_VQDMLAH_qr_multi<iname, MVE_v4s32, bit_5, bit_12>; 5761} 5762 5763defm MVE_VQDMLAH_qr : MVE_VQDMLAH_qr_types<"vqdmlah", 0b1, 0b0>; 5764defm MVE_VQRDMLAH_qr : MVE_VQDMLAH_qr_types<"vqrdmlah", 0b0, 0b0>; 5765defm MVE_VQDMLASH_qr : MVE_VQDMLAH_qr_types<"vqdmlash", 0b1, 0b1>; 5766defm MVE_VQRDMLASH_qr : MVE_VQDMLAH_qr_types<"vqrdmlash", 0b0, 0b1>; 5767 5768class MVE_VxDUP<string iname, string suffix, bits<2> size, bit bit_12, 5769 ValueType VT, SDPatternOperator vxdup> 5770 : MVE_p<(outs MQPR:$Qd, tGPREven:$Rn), 5771 (ins tGPREven:$Rn_src, MVE_VIDUP_imm:$imm), NoItinerary, 5772 iname, suffix, "$Qd, $Rn, $imm", vpred_r, "$Rn = $Rn_src", size, 5773 [(set (VT MQPR:$Qd), (i32 tGPREven:$Rn), 5774 (vxdup (i32 tGPREven:$Rn_src), (i32 imm:$imm)))]> { 5775 bits<4> Qd; 5776 bits<4> Rn; 5777 bits<2> imm; 5778 5779 let Inst{28} = 0b0; 5780 let Inst{25-23} = 0b100; 5781 let Inst{22} = Qd{3}; 5782 let Inst{21-20} = size; 5783 let Inst{19-17} = Rn{3-1}; 5784 let Inst{16} = 0b1; 5785 let Inst{15-13} = Qd{2-0}; 5786 let Inst{12} = bit_12; 5787 let Inst{11-8} = 0b1111; 5788 let Inst{7} = imm{1}; 5789 let Inst{6-1} = 0b110111; 5790 let Inst{0} = imm{0}; 5791 let validForTailPredication = 1; 5792 let hasSideEffects = 0; 5793} 5794 5795def MVE_VIDUPu8 : MVE_VxDUP<"vidup", "u8", 0b00, 0b0, v16i8, ARMvidup>; 5796def MVE_VIDUPu16 : MVE_VxDUP<"vidup", "u16", 0b01, 0b0, v8i16, ARMvidup>; 5797def MVE_VIDUPu32 : MVE_VxDUP<"vidup", "u32", 0b10, 0b0, v4i32, ARMvidup>; 5798 5799def MVE_VDDUPu8 : MVE_VxDUP<"vddup", "u8", 0b00, 0b1, v16i8, null_frag>; 5800def MVE_VDDUPu16 : MVE_VxDUP<"vddup", "u16", 0b01, 0b1, v8i16, null_frag>; 5801def MVE_VDDUPu32 : MVE_VxDUP<"vddup", "u32", 0b10, 0b1, v4i32, null_frag>; 5802 5803class MVE_VxWDUP<string iname, string suffix, bits<2> size, bit bit_12, 5804 list<dag> pattern=[]> 5805 : MVE_p<(outs MQPR:$Qd, tGPREven:$Rn), 5806 (ins tGPREven:$Rn_src, tGPROdd:$Rm, MVE_VIDUP_imm:$imm), NoItinerary, 5807 iname, suffix, "$Qd, $Rn, $Rm, $imm", vpred_r, "$Rn = $Rn_src", size, 5808 pattern> { 5809 bits<4> Qd; 5810 bits<4> Rm; 5811 bits<4> Rn; 5812 bits<2> imm; 5813 5814 let Inst{28} = 0b0; 5815 let Inst{25-23} = 0b100; 5816 let Inst{22} = Qd{3}; 5817 let Inst{21-20} = size; 5818 let Inst{19-17} = Rn{3-1}; 5819 let Inst{16} = 0b1; 5820 let Inst{15-13} = Qd{2-0}; 5821 let Inst{12} = bit_12; 5822 let Inst{11-8} = 0b1111; 5823 let Inst{7} = imm{1}; 5824 let Inst{6-4} = 0b110; 5825 let Inst{3-1} = Rm{3-1}; 5826 let Inst{0} = imm{0}; 5827 let validForTailPredication = 1; 5828 let hasSideEffects = 0; 5829} 5830 5831def MVE_VIWDUPu8 : MVE_VxWDUP<"viwdup", "u8", 0b00, 0b0>; 5832def MVE_VIWDUPu16 : MVE_VxWDUP<"viwdup", "u16", 0b01, 0b0>; 5833def MVE_VIWDUPu32 : MVE_VxWDUP<"viwdup", "u32", 0b10, 0b0>; 5834 5835def MVE_VDWDUPu8 : MVE_VxWDUP<"vdwdup", "u8", 0b00, 0b1>; 5836def MVE_VDWDUPu16 : MVE_VxWDUP<"vdwdup", "u16", 0b01, 0b1>; 5837def MVE_VDWDUPu32 : MVE_VxWDUP<"vdwdup", "u32", 0b10, 0b1>; 5838 5839let isReMaterializable = 1 in 5840class MVE_VCTPInst<string suffix, bits<2> size, list<dag> pattern=[]> 5841 : MVE_p<(outs VCCR:$P0), (ins rGPR:$Rn), NoItinerary, "vctp", suffix, 5842 "$Rn", vpred_n, "", size, pattern> { 5843 bits<4> Rn; 5844 5845 let Inst{28-27} = 0b10; 5846 let Inst{26-22} = 0b00000; 5847 let Inst{21-20} = size; 5848 let Inst{19-16} = Rn{3-0}; 5849 let Inst{15-11} = 0b11101; 5850 let Inst{10-0} = 0b00000000001; 5851 let Unpredictable{10-0} = 0b11111111111; 5852 5853 let Constraints = ""; 5854 let DecoderMethod = "DecodeMveVCTP"; 5855 let validForTailPredication = 1; 5856} 5857 5858multiclass MVE_VCTP<MVEVectorVTInfo VTI, Intrinsic intr> { 5859 def "": MVE_VCTPInst<VTI.BitsSuffix, VTI.Size>; 5860 defvar Inst = !cast<Instruction>(NAME); 5861 5862 let Predicates = [HasMVEInt] in { 5863 def : Pat<(intr rGPR:$Rn), 5864 (VTI.Pred (Inst rGPR:$Rn))>; 5865 def : Pat<(and (intr rGPR:$Rn), (VTI.Pred VCCR:$mask)), 5866 (VTI.Pred (Inst rGPR:$Rn, ARMVCCThen, VCCR:$mask, zero_reg))>; 5867 } 5868} 5869 5870defm MVE_VCTP8 : MVE_VCTP<MVE_v16i8, int_arm_mve_vctp8>; 5871defm MVE_VCTP16 : MVE_VCTP<MVE_v8i16, int_arm_mve_vctp16>; 5872defm MVE_VCTP32 : MVE_VCTP<MVE_v4i32, int_arm_mve_vctp32>; 5873defm MVE_VCTP64 : MVE_VCTP<MVE_v2i64, int_arm_mve_vctp64>; 5874 5875// end of mve_qDest_rSrc 5876 5877// start of coproc mov 5878 5879class MVE_VMOV_64bit<dag oops, dag iops, bit to_qreg, string ops, string cstr> 5880 : MVE_VMOV_lane_base<oops, !con(iops, (ins MVEPairVectorIndex2:$idx, 5881 MVEPairVectorIndex0:$idx2)), 5882 NoItinerary, "vmov", "", ops, cstr, []> { 5883 bits<5> Rt; 5884 bits<5> Rt2; 5885 bits<4> Qd; 5886 bit idx; 5887 bit idx2; 5888 5889 let Inst{31-23} = 0b111011000; 5890 let Inst{22} = Qd{3}; 5891 let Inst{21} = 0b0; 5892 let Inst{20} = to_qreg; 5893 let Inst{19-16} = Rt2{3-0}; 5894 let Inst{15-13} = Qd{2-0}; 5895 let Inst{12-5} = 0b01111000; 5896 let Inst{4} = idx2; 5897 let Inst{3-0} = Rt{3-0}; 5898 5899 let VecSize = 0b10; 5900 let hasSideEffects = 0; 5901} 5902 5903// The assembly syntax for these instructions mentions the vector 5904// register name twice, e.g. 5905// 5906// vmov q2[2], q2[0], r0, r1 5907// vmov r0, r1, q2[2], q2[0] 5908// 5909// which needs a bit of juggling with MC operand handling. 5910// 5911// For the move _into_ a vector register, the MC operand list also has 5912// to mention the register name twice: once as the output, and once as 5913// an extra input to represent where the unchanged half of the output 5914// register comes from (when this instruction is used in code 5915// generation). So we arrange that the first mention of the vector reg 5916// in the instruction is considered by the AsmMatcher to be the output 5917// ($Qd), and the second one is the input ($QdSrc). Binding them 5918// together with the existing 'tie' constraint is enough to enforce at 5919// register allocation time that they have to be the same register. 5920// 5921// For the move _from_ a vector register, there's no way to get round 5922// the fact that both instances of that register name have to be 5923// inputs. They have to be the same register again, but this time, we 5924// can't use a tie constraint, because that has to be between an 5925// output and an input operand. So this time, we have to arrange that 5926// the q-reg appears just once in the MC operand list, in spite of 5927// being mentioned twice in the asm syntax - which needs a custom 5928// AsmMatchConverter. 5929 5930def MVE_VMOV_q_rr : MVE_VMOV_64bit<(outs MQPR:$Qd), 5931 (ins MQPR:$QdSrc, rGPR:$Rt, rGPR:$Rt2), 5932 0b1, "$Qd$idx, $QdSrc$idx2, $Rt, $Rt2", 5933 "$Qd = $QdSrc"> { 5934 let DecoderMethod = "DecodeMVEVMOVDRegtoQ"; 5935} 5936 5937def MVE_VMOV_rr_q : MVE_VMOV_64bit<(outs rGPR:$Rt, rGPR:$Rt2), (ins MQPR:$Qd), 5938 0b0, "$Rt, $Rt2, $Qd$idx, $Qd$idx2", ""> { 5939 let DecoderMethod = "DecodeMVEVMOVQtoDReg"; 5940 let AsmMatchConverter = "cvtMVEVMOVQtoDReg"; 5941} 5942 5943let Predicates = [HasMVEInt] in { 5944 // Double lane moves. There are a number of patterns here. We know that the 5945 // insertelt's will be in descending order by index, and need to match the 5 5946 // patterns that might contain 2-0 or 3-1 pairs. These are: 5947 // 3 2 1 0 -> vmovqrr 31; vmovqrr 20 5948 // 3 2 1 -> vmovqrr 31; vmov 2 5949 // 3 1 -> vmovqrr 31 5950 // 2 1 0 -> vmovqrr 20; vmov 1 5951 // 2 0 -> vmovqrr 20 5952 // The other potential patterns will be handled by single lane inserts. 5953 def : Pat<(insertelt (insertelt (insertelt (insertelt (v4i32 MQPR:$src1), 5954 rGPR:$srcA, (i32 0)), 5955 rGPR:$srcB, (i32 1)), 5956 rGPR:$srcC, (i32 2)), 5957 rGPR:$srcD, (i32 3)), 5958 (MVE_VMOV_q_rr (MVE_VMOV_q_rr MQPR:$src1, rGPR:$srcA, rGPR:$srcC, (i32 2), (i32 0)), 5959 rGPR:$srcB, rGPR:$srcD, (i32 3), (i32 1))>; 5960 def : Pat<(insertelt (insertelt (insertelt (v4i32 MQPR:$src1), 5961 rGPR:$srcB, (i32 1)), 5962 rGPR:$srcC, (i32 2)), 5963 rGPR:$srcD, (i32 3)), 5964 (MVE_VMOV_q_rr (MVE_VMOV_to_lane_32 MQPR:$src1, rGPR:$srcC, (i32 2)), 5965 rGPR:$srcB, rGPR:$srcD, (i32 3), (i32 1))>; 5966 def : Pat<(insertelt (insertelt (v4i32 MQPR:$src1), rGPR:$srcA, (i32 1)), rGPR:$srcB, (i32 3)), 5967 (MVE_VMOV_q_rr MQPR:$src1, rGPR:$srcA, rGPR:$srcB, (i32 3), (i32 1))>; 5968 def : Pat<(insertelt (insertelt (insertelt (v4i32 MQPR:$src1), 5969 rGPR:$srcB, (i32 0)), 5970 rGPR:$srcC, (i32 1)), 5971 rGPR:$srcD, (i32 2)), 5972 (MVE_VMOV_q_rr (MVE_VMOV_to_lane_32 MQPR:$src1, rGPR:$srcC, (i32 1)), 5973 rGPR:$srcB, rGPR:$srcD, (i32 2), (i32 0))>; 5974 def : Pat<(insertelt (insertelt (v4i32 MQPR:$src1), rGPR:$srcA, (i32 0)), rGPR:$srcB, (i32 2)), 5975 (MVE_VMOV_q_rr MQPR:$src1, rGPR:$srcA, rGPR:$srcB, (i32 2), (i32 0))>; 5976} 5977 5978// end of coproc mov 5979 5980// start of MVE interleaving load/store 5981 5982// Base class for the family of interleaving/deinterleaving 5983// load/stores with names like VLD20.8 and VST43.32. 5984class MVE_vldst24_base<bit writeback, bit fourregs, bits<2> stage, bits<2> size, 5985 bit load, dag Oops, dag loadIops, dag wbIops, 5986 string iname, string ops, 5987 string cstr, list<dag> pattern=[]> 5988 : MVE_MI<Oops, !con(loadIops, wbIops), NoItinerary, iname, ops, cstr, size, pattern> { 5989 bits<4> VQd; 5990 bits<4> Rn; 5991 5992 let Inst{31-22} = 0b1111110010; 5993 let Inst{21} = writeback; 5994 let Inst{20} = load; 5995 let Inst{19-16} = Rn; 5996 let Inst{15-13} = VQd{2-0}; 5997 let Inst{12-9} = 0b1111; 5998 let Inst{8-7} = size; 5999 let Inst{6-5} = stage; 6000 let Inst{4-1} = 0b0000; 6001 let Inst{0} = fourregs; 6002 6003 let mayLoad = load; 6004 let mayStore = !eq(load,0); 6005 let hasSideEffects = 0; 6006 let validForTailPredication = load; 6007} 6008 6009// A parameter class used to encapsulate all the ways the writeback 6010// variants of VLD20 and friends differ from the non-writeback ones. 6011class MVE_vldst24_writeback<bit b, dag Oo, dag Io, 6012 string sy="", string c="", string n=""> { 6013 bit writeback = b; 6014 dag Oops = Oo; 6015 dag Iops = Io; 6016 string syntax = sy; 6017 string cstr = c; 6018 string id_suffix = n; 6019} 6020 6021// Another parameter class that encapsulates the differences between VLD2x 6022// and VLD4x. 6023class MVE_vldst24_nvecs<int n, list<int> s, bit b, RegisterOperand vl> { 6024 int nvecs = n; 6025 list<int> stages = s; 6026 bit bit0 = b; 6027 RegisterOperand VecList = vl; 6028} 6029 6030// A third parameter class that distinguishes VLDnn.8 from .16 from .32. 6031class MVE_vldst24_lanesize<int i, bits<2> b> { 6032 int lanesize = i; 6033 bits<2> sizebits = b; 6034} 6035 6036// A base class for each direction of transfer: one for load, one for 6037// store. I can't make these a fourth independent parametric tuple 6038// class, because they have to take the nvecs tuple class as a 6039// parameter, in order to find the right VecList operand type. 6040 6041class MVE_vld24_base<MVE_vldst24_nvecs n, bits<2> pat, bits<2> size, 6042 MVE_vldst24_writeback wb, string iname, 6043 list<dag> pattern=[]> 6044 : MVE_vldst24_base<wb.writeback, n.bit0, pat, size, 1, 6045 !con((outs n.VecList:$VQd), wb.Oops), 6046 (ins n.VecList:$VQdSrc), wb.Iops, 6047 iname, "$VQd, $Rn" # wb.syntax, 6048 wb.cstr # ",$VQdSrc = $VQd", pattern>; 6049 6050class MVE_vst24_base<MVE_vldst24_nvecs n, bits<2> pat, bits<2> size, 6051 MVE_vldst24_writeback wb, string iname, 6052 list<dag> pattern=[]> 6053 : MVE_vldst24_base<wb.writeback, n.bit0, pat, size, 0, 6054 wb.Oops, (ins n.VecList:$VQd), wb.Iops, 6055 iname, "$VQd, $Rn" # wb.syntax, 6056 wb.cstr, pattern>; 6057 6058// Actually define all the interleaving loads and stores, by a series 6059// of nested foreaches over number of vectors (VLD2/VLD4); stage 6060// within one of those series (VLDx0/VLDx1/VLDx2/VLDx3); size of 6061// vector lane; writeback or no writeback. 6062foreach n = [MVE_vldst24_nvecs<2, [0,1], 0, VecList2Q>, 6063 MVE_vldst24_nvecs<4, [0,1,2,3], 1, VecList4Q>] in 6064foreach stage = n.stages in 6065foreach s = [MVE_vldst24_lanesize< 8, 0b00>, 6066 MVE_vldst24_lanesize<16, 0b01>, 6067 MVE_vldst24_lanesize<32, 0b10>] in 6068foreach wb = [MVE_vldst24_writeback< 6069 1, (outs rGPR:$wb), (ins t2_nosp_addr_offset_none:$Rn), 6070 "!", "$Rn.base = $wb", "_wb">, 6071 MVE_vldst24_writeback<0, (outs), (ins t2_addr_offset_none:$Rn)>] in { 6072 6073 // For each case within all of those foreaches, define the actual 6074 // instructions. The def names are made by gluing together pieces 6075 // from all the parameter classes, and will end up being things like 6076 // MVE_VLD20_8 and MVE_VST43_16_wb. 6077 6078 def "MVE_VLD" # n.nvecs # stage # "_" # s.lanesize # wb.id_suffix 6079 : MVE_vld24_base<n, stage, s.sizebits, wb, 6080 "vld" # n.nvecs # stage # "." # s.lanesize>; 6081 6082 def "MVE_VST" # n.nvecs # stage # "_" # s.lanesize # wb.id_suffix 6083 : MVE_vst24_base<n, stage, s.sizebits, wb, 6084 "vst" # n.nvecs # stage # "." # s.lanesize>; 6085} 6086 6087def SDTARMVST2 : SDTypeProfile<1, 5, [SDTCisPtrTy<0>, SDTCisPtrTy<1>, SDTCisVT<2, i32>, SDTCisVec<3>, 6088 SDTCisSameAs<3, 4>, SDTCisVT<5, i32>]>; 6089def SDTARMVST4 : SDTypeProfile<1, 7, [SDTCisPtrTy<0>, SDTCisPtrTy<1>, SDTCisVT<2, i32>, SDTCisVec<3>, 6090 SDTCisSameAs<3, 4>, SDTCisSameAs<3, 5>, 6091 SDTCisSameAs<3, 6>, SDTCisVT<7, i32>]>; 6092def MVEVST2UPD : SDNode<"ARMISD::VST2_UPD", SDTARMVST2, [SDNPHasChain, SDNPMemOperand]>; 6093def MVEVST4UPD : SDNode<"ARMISD::VST4_UPD", SDTARMVST4, [SDNPHasChain, SDNPMemOperand]>; 6094 6095multiclass MVE_vst24_patterns<int lanesize, ValueType VT> { 6096 foreach stage = [0,1] in 6097 def : Pat<(int_arm_mve_vst2q i32:$addr, 6098 (VT MQPR:$v0), (VT MQPR:$v1), (i32 stage)), 6099 (!cast<Instruction>("MVE_VST2"#stage#"_"#lanesize) 6100 (REG_SEQUENCE MQQPR, VT:$v0, qsub_0, VT:$v1, qsub_1), 6101 t2_addr_offset_none:$addr)>; 6102 foreach stage = [0,1] in 6103 def : Pat<(i32 (MVEVST2UPD i32:$addr, (i32 32), 6104 (VT MQPR:$v0), (VT MQPR:$v1), (i32 stage))), 6105 (i32 (!cast<Instruction>("MVE_VST2"#stage#"_"#lanesize#_wb) 6106 (REG_SEQUENCE MQQPR, VT:$v0, qsub_0, VT:$v1, qsub_1), 6107 t2_addr_offset_none:$addr))>; 6108 6109 foreach stage = [0,1,2,3] in 6110 def : Pat<(int_arm_mve_vst4q i32:$addr, 6111 (VT MQPR:$v0), (VT MQPR:$v1), 6112 (VT MQPR:$v2), (VT MQPR:$v3), (i32 stage)), 6113 (!cast<Instruction>("MVE_VST4"#stage#"_"#lanesize) 6114 (REG_SEQUENCE MQQQQPR, VT:$v0, qsub_0, VT:$v1, qsub_1, 6115 VT:$v2, qsub_2, VT:$v3, qsub_3), 6116 t2_addr_offset_none:$addr)>; 6117 foreach stage = [0,1,2,3] in 6118 def : Pat<(i32 (MVEVST4UPD i32:$addr, (i32 64), 6119 (VT MQPR:$v0), (VT MQPR:$v1), 6120 (VT MQPR:$v2), (VT MQPR:$v3), (i32 stage))), 6121 (i32 (!cast<Instruction>("MVE_VST4"#stage#"_"#lanesize#_wb) 6122 (REG_SEQUENCE MQQQQPR, VT:$v0, qsub_0, VT:$v1, qsub_1, 6123 VT:$v2, qsub_2, VT:$v3, qsub_3), 6124 t2_addr_offset_none:$addr))>; 6125} 6126defm : MVE_vst24_patterns<8, v16i8>; 6127defm : MVE_vst24_patterns<16, v8i16>; 6128defm : MVE_vst24_patterns<32, v4i32>; 6129defm : MVE_vst24_patterns<16, v8f16>; 6130defm : MVE_vst24_patterns<32, v4f32>; 6131 6132// end of MVE interleaving load/store 6133 6134// start of MVE predicable load/store 6135 6136// A parameter class for the direction of transfer. 6137class MVE_ldst_direction<bit b, dag Oo, dag Io, string c=""> { 6138 bit load = b; 6139 dag Oops = Oo; 6140 dag Iops = Io; 6141 string cstr = c; 6142} 6143def MVE_ld: MVE_ldst_direction<1, (outs MQPR:$Qd), (ins), ",@earlyclobber $Qd">; 6144def MVE_st: MVE_ldst_direction<0, (outs), (ins MQPR:$Qd)>; 6145 6146// A parameter class for the size of memory access in a load. 6147class MVE_memsz<bits<2> e, int s, AddrMode m, string mn, list<string> types> { 6148 bits<2> encoding = e; // opcode bit(s) for encoding 6149 int shift = s; // shift applied to immediate load offset 6150 AddrMode AM = m; 6151 6152 // For instruction aliases: define the complete list of type 6153 // suffixes at this size, and the canonical ones for loads and 6154 // stores. 6155 string MnemonicLetter = mn; 6156 int TypeBits = !shl(8, s); 6157 string CanonLoadSuffix = ".u" # TypeBits; 6158 string CanonStoreSuffix = "." # TypeBits; 6159 list<string> suffixes = !foreach(letter, types, "." # letter # TypeBits); 6160} 6161 6162// Instances of MVE_memsz. 6163// 6164// (memD doesn't need an AddrMode, because those are only for 6165// contiguous loads, and memD is only used by gather/scatters.) 6166def MVE_memB: MVE_memsz<0b00, 0, AddrModeT2_i7, "b", ["", "u", "s"]>; 6167def MVE_memH: MVE_memsz<0b01, 1, AddrModeT2_i7s2, "h", ["", "u", "s", "f"]>; 6168def MVE_memW: MVE_memsz<0b10, 2, AddrModeT2_i7s4, "w", ["", "u", "s", "f"]>; 6169def MVE_memD: MVE_memsz<0b11, 3, ?, "d", ["", "u", "s", "f"]>; 6170 6171// This is the base class for all the MVE loads and stores other than 6172// the interleaving ones. All the non-interleaving loads/stores share 6173// the characteristic that they operate on just one vector register, 6174// so they are VPT-predicable. 6175// 6176// The predication operand is vpred_n, for both loads and stores. For 6177// store instructions, the reason is obvious: if there is no output 6178// register, there can't be a need for an input parameter giving the 6179// output register's previous value. Load instructions also don't need 6180// that input parameter, because unlike MVE data processing 6181// instructions, predicated loads are defined to set the inactive 6182// lanes of the output register to zero, instead of preserving their 6183// input values. 6184class MVE_VLDRSTR_base<MVE_ldst_direction dir, bit U, bit P, bit W, bit opc, 6185 dag oops, dag iops, string asm, string suffix, 6186 string ops, string cstr, bits<2> vecsize, list<dag> pattern=[]> 6187 : MVE_p<oops, iops, NoItinerary, asm, suffix, ops, vpred_n, cstr, vecsize, pattern> { 6188 bits<3> Qd; 6189 6190 let Inst{28} = U; 6191 let Inst{25} = 0b0; 6192 let Inst{24} = P; 6193 let Inst{22} = 0b0; 6194 let Inst{21} = W; 6195 let Inst{20} = dir.load; 6196 let Inst{15-13} = Qd{2-0}; 6197 let Inst{12} = opc; 6198 let Inst{11-9} = 0b111; 6199 6200 let mayLoad = dir.load; 6201 let mayStore = !eq(dir.load,0); 6202 let hasSideEffects = 0; 6203 let validForTailPredication = 1; 6204} 6205 6206// Contiguous load and store instructions. These come in two main 6207// categories: same-size loads/stores in which 128 bits of vector 6208// register is transferred to or from 128 bits of memory in the most 6209// obvious way, and widening loads / narrowing stores, in which the 6210// size of memory accessed is less than the size of a vector register, 6211// so the load instructions sign- or zero-extend each memory value 6212// into a wider vector lane, and the store instructions truncate 6213// correspondingly. 6214// 6215// The instruction mnemonics for these two classes look reasonably 6216// similar, but the actual encodings are different enough to need two 6217// separate base classes. 6218 6219// Contiguous, same size 6220class MVE_VLDRSTR_cs<MVE_ldst_direction dir, MVE_memsz memsz, bit P, bit W, 6221 dag oops, dag iops, string asm, string suffix, 6222 IndexMode im, string ops, string cstr> 6223 : MVE_VLDRSTR_base<dir, 0, P, W, 1, oops, iops, asm, suffix, ops, cstr, memsz.encoding> { 6224 bits<12> addr; 6225 let Inst{23} = addr{7}; 6226 let Inst{19-16} = addr{11-8}; 6227 let Inst{8-7} = memsz.encoding; 6228 let Inst{6-0} = addr{6-0}; 6229 6230 let IM = im; 6231} 6232 6233// Contiguous, widening/narrowing 6234class MVE_VLDRSTR_cw<MVE_ldst_direction dir, MVE_memsz memsz, bit U, 6235 bit P, bit W, bits<2> size, dag oops, dag iops, 6236 string asm, string suffix, IndexMode im, 6237 string ops, string cstr> 6238 : MVE_VLDRSTR_base<dir, U, P, W, 0, oops, iops, asm, suffix, ops, cstr, size> { 6239 bits<11> addr; 6240 let Inst{23} = addr{7}; 6241 let Inst{19} = memsz.encoding{0}; // enough to tell 16- from 32-bit 6242 let Inst{18-16} = addr{10-8}; 6243 let Inst{8-7} = size; 6244 let Inst{6-0} = addr{6-0}; 6245 6246 let IM = im; 6247} 6248 6249// Multiclass wrapper on each of the _cw and _cs base classes, to 6250// generate three writeback modes (none, preindex, postindex). 6251 6252multiclass MVE_VLDRSTR_cw_m<MVE_ldst_direction dir, MVE_memsz memsz, 6253 string asm, string suffix, bit U, bits<2> size> { 6254 let AM = memsz.AM in { 6255 def "" : MVE_VLDRSTR_cw< 6256 dir, memsz, U, 1, 0, size, 6257 dir.Oops, !con(dir.Iops, (ins taddrmode_imm7<memsz.shift>:$addr)), 6258 asm, suffix, IndexModeNone, "$Qd, $addr", "">; 6259 6260 def _pre : MVE_VLDRSTR_cw< 6261 dir, memsz, U, 1, 1, size, 6262 !con((outs tGPR:$wb), dir.Oops), 6263 !con(dir.Iops, (ins taddrmode_imm7<memsz.shift>:$addr)), 6264 asm, suffix, IndexModePre, "$Qd, $addr!", "$addr.base = $wb"> { 6265 let DecoderMethod = "DecodeMVE_MEM_1_pre<"#memsz.shift#">"; 6266 } 6267 6268 def _post : MVE_VLDRSTR_cw< 6269 dir, memsz, U, 0, 1, size, 6270 !con((outs tGPR:$wb), dir.Oops), 6271 !con(dir.Iops, (ins t_addr_offset_none:$Rn, 6272 t2am_imm7_offset<memsz.shift>:$addr)), 6273 asm, suffix, IndexModePost, "$Qd, $Rn$addr", "$Rn.base = $wb"> { 6274 bits<4> Rn; 6275 let Inst{18-16} = Rn{2-0}; 6276 } 6277 } 6278} 6279 6280multiclass MVE_VLDRSTR_cs_m<MVE_ldst_direction dir, MVE_memsz memsz, 6281 string asm, string suffix> { 6282 let AM = memsz.AM in { 6283 def "" : MVE_VLDRSTR_cs< 6284 dir, memsz, 1, 0, 6285 dir.Oops, !con(dir.Iops, (ins t2addrmode_imm7<memsz.shift>:$addr)), 6286 asm, suffix, IndexModeNone, "$Qd, $addr", "">; 6287 6288 def _pre : MVE_VLDRSTR_cs< 6289 dir, memsz, 1, 1, 6290 !con((outs rGPR:$wb), dir.Oops), 6291 !con(dir.Iops, (ins t2addrmode_imm7_pre<memsz.shift>:$addr)), 6292 asm, suffix, IndexModePre, "$Qd, $addr!", "$addr.base = $wb"> { 6293 let DecoderMethod = "DecodeMVE_MEM_2_pre<"#memsz.shift#">"; 6294 } 6295 6296 def _post : MVE_VLDRSTR_cs< 6297 dir, memsz, 0, 1, 6298 !con((outs rGPR:$wb), dir.Oops), 6299 !con(dir.Iops, (ins t2_nosp_addr_offset_none:$Rn, 6300 t2am_imm7_offset<memsz.shift>:$addr)), 6301 asm, suffix, IndexModePost, "$Qd, $Rn$addr", "$Rn.base = $wb"> { 6302 bits<4> Rn; 6303 let Inst{19-16} = Rn{3-0}; 6304 } 6305 } 6306} 6307 6308// Now actually declare all the contiguous load/stores, via those 6309// multiclasses. The instruction ids coming out of this are the bare 6310// names shown in the defm, with _pre or _post appended for writeback, 6311// e.g. MVE_VLDRBS16, MVE_VSTRB16_pre, MVE_VSTRHU16_post. 6312 6313defm MVE_VLDRBS16: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "s16", 0, 0b01>; 6314defm MVE_VLDRBS32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "s32", 0, 0b10>; 6315defm MVE_VLDRBU16: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "u16", 1, 0b01>; 6316defm MVE_VLDRBU32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "u32", 1, 0b10>; 6317defm MVE_VLDRHS32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memH, "vldrh", "s32", 0, 0b10>; 6318defm MVE_VLDRHU32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memH, "vldrh", "u32", 1, 0b10>; 6319 6320defm MVE_VLDRBU8: MVE_VLDRSTR_cs_m<MVE_ld, MVE_memB, "vldrb", "u8">; 6321defm MVE_VLDRHU16: MVE_VLDRSTR_cs_m<MVE_ld, MVE_memH, "vldrh", "u16">; 6322defm MVE_VLDRWU32: MVE_VLDRSTR_cs_m<MVE_ld, MVE_memW, "vldrw", "u32">; 6323 6324defm MVE_VSTRB16: MVE_VLDRSTR_cw_m<MVE_st, MVE_memB, "vstrb", "16", 0, 0b01>; 6325defm MVE_VSTRB32: MVE_VLDRSTR_cw_m<MVE_st, MVE_memB, "vstrb", "32", 0, 0b10>; 6326defm MVE_VSTRH32: MVE_VLDRSTR_cw_m<MVE_st, MVE_memH, "vstrh", "32", 0, 0b10>; 6327 6328defm MVE_VSTRBU8 : MVE_VLDRSTR_cs_m<MVE_st, MVE_memB, "vstrb", "8">; 6329defm MVE_VSTRHU16: MVE_VLDRSTR_cs_m<MVE_st, MVE_memH, "vstrh", "16">; 6330defm MVE_VSTRWU32: MVE_VLDRSTR_cs_m<MVE_st, MVE_memW, "vstrw", "32">; 6331 6332// Gather loads / scatter stores whose address operand is of the form 6333// [Rn,Qm], i.e. a single GPR as the common base address, plus a 6334// vector of offset from it. ('Load/store this sequence of elements of 6335// the same array.') 6336// 6337// Like the contiguous family, these loads and stores can widen the 6338// loaded values / truncate the stored ones, or they can just 6339// load/store the same size of memory and vector lane. But unlike the 6340// contiguous family, there's no particular difference in encoding 6341// between those two cases. 6342// 6343// This family also comes with the option to scale the offset values 6344// in Qm by the size of the loaded memory (i.e. to treat them as array 6345// indices), or not to scale them (to treat them as plain byte offsets 6346// in memory, so that perhaps the loaded values are unaligned). The 6347// scaled instructions' address operand in assembly looks like 6348// [Rn,Qm,UXTW #2] or similar. 6349 6350// Base class. 6351class MVE_VLDRSTR_rq<MVE_ldst_direction dir, MVE_memsz memsz, bit U, 6352 bits<2> size, bit os, string asm, string suffix, int shift> 6353 : MVE_VLDRSTR_base<dir, U, 0b0, 0b0, 0, dir.Oops, 6354 !con(dir.Iops, (ins mve_addr_rq_shift<shift>:$addr)), 6355 asm, suffix, "$Qd, $addr", dir.cstr, size> { 6356 bits<7> addr; 6357 let Inst{23} = 0b1; 6358 let Inst{19-16} = addr{6-3}; 6359 let Inst{8-7} = size; 6360 let Inst{6} = memsz.encoding{1}; 6361 let Inst{5} = 0; 6362 let Inst{4} = memsz.encoding{0}; 6363 let Inst{3-1} = addr{2-0}; 6364 let Inst{0} = os; 6365} 6366 6367// Multiclass that defines the scaled and unscaled versions of an 6368// instruction, when the memory size is wider than a byte. The scaled 6369// version gets the default name like MVE_VLDRBU16_rq; the unscaled / 6370// potentially unaligned version gets a "_u" suffix, e.g. 6371// MVE_VLDRBU16_rq_u. 6372multiclass MVE_VLDRSTR_rq_w<MVE_ldst_direction dir, MVE_memsz memsz, 6373 string asm, string suffix, bit U, bits<2> size> { 6374 def _u : MVE_VLDRSTR_rq<dir, memsz, U, size, 0, asm, suffix, 0>; 6375 def "" : MVE_VLDRSTR_rq<dir, memsz, U, size, 1, asm, suffix, memsz.shift>; 6376} 6377 6378// Subclass of MVE_VLDRSTR_rq with the same API as that multiclass, 6379// for use when the memory size is one byte, so there's no 'scaled' 6380// version of the instruction at all. (This is encoded as if it were 6381// unscaled, but named in the default way with no _u suffix.) 6382class MVE_VLDRSTR_rq_b<MVE_ldst_direction dir, MVE_memsz memsz, 6383 string asm, string suffix, bit U, bits<2> size> 6384 : MVE_VLDRSTR_rq<dir, memsz, U, size, 0, asm, suffix, 0>; 6385 6386// Multiclasses wrapping that to add ISel patterns for intrinsics. 6387multiclass MVE_VLDR_rq_w<MVE_memsz memsz, list<MVEVectorVTInfo> VTIs> { 6388 defm "": MVE_VLDRSTR_rq_w<MVE_ld, memsz, "vldr" # memsz.MnemonicLetter, 6389 VTIs[0].Suffix, VTIs[0].Unsigned, VTIs[0].Size>; 6390 defvar Inst = !cast<Instruction>(NAME); 6391 defvar InstU = !cast<Instruction>(NAME # "_u"); 6392 6393 foreach VTI = VTIs in 6394 foreach UnsignedFlag = !if(!eq(VTI.Size, memsz.encoding), 6395 [0,1], [VTI.Unsigned]) in { 6396 def : Pat<(VTI.Vec (int_arm_mve_vldr_gather_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), memsz.TypeBits, 0, UnsignedFlag)), 6397 (VTI.Vec (InstU GPR:$base, MQPR:$offsets))>; 6398 def : Pat<(VTI.Vec (int_arm_mve_vldr_gather_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), memsz.TypeBits, memsz.shift, UnsignedFlag)), 6399 (VTI.Vec (Inst GPR:$base, MQPR:$offsets))>; 6400 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))), 6401 (VTI.Vec (InstU GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg))>; 6402 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))), 6403 (VTI.Vec (Inst GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg))>; 6404 } 6405} 6406multiclass MVE_VLDR_rq_b<list<MVEVectorVTInfo> VTIs> { 6407 def "": MVE_VLDRSTR_rq_b<MVE_ld, MVE_memB, "vldrb", 6408 VTIs[0].Suffix, VTIs[0].Unsigned, VTIs[0].Size>; 6409 defvar Inst = !cast<Instruction>(NAME); 6410 6411 foreach VTI = VTIs in { 6412 def : Pat<(VTI.Vec (int_arm_mve_vldr_gather_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), 8, 0, VTI.Unsigned)), 6413 (VTI.Vec (Inst GPR:$base, MQPR:$offsets))>; 6414 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))), 6415 (VTI.Vec (Inst GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg))>; 6416 } 6417} 6418multiclass MVE_VSTR_rq_w<MVE_memsz memsz, list<MVEVectorVTInfo> VTIs> { 6419 defm "": MVE_VLDRSTR_rq_w<MVE_st, memsz, "vstr" # memsz.MnemonicLetter, 6420 VTIs[0].BitsSuffix, 0, VTIs[0].Size>; 6421 defvar Inst = !cast<Instruction>(NAME); 6422 defvar InstU = !cast<Instruction>(NAME # "_u"); 6423 6424 foreach VTI = VTIs in { 6425 def : Pat<(int_arm_mve_vstr_scatter_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), (VTI.Vec MQPR:$data), memsz.TypeBits, 0), 6426 (InstU MQPR:$data, GPR:$base, MQPR:$offsets)>; 6427 def : Pat<(int_arm_mve_vstr_scatter_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), (VTI.Vec MQPR:$data), memsz.TypeBits, memsz.shift), 6428 (Inst MQPR:$data, GPR:$base, MQPR:$offsets)>; 6429 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)), 6430 (InstU MQPR:$data, GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg)>; 6431 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)), 6432 (Inst MQPR:$data, GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg)>; 6433 } 6434} 6435multiclass MVE_VSTR_rq_b<list<MVEVectorVTInfo> VTIs> { 6436 def "": MVE_VLDRSTR_rq_b<MVE_st, MVE_memB, "vstrb", 6437 VTIs[0].BitsSuffix, 0, VTIs[0].Size>; 6438 defvar Inst = !cast<Instruction>(NAME); 6439 6440 foreach VTI = VTIs in { 6441 def : Pat<(int_arm_mve_vstr_scatter_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), (VTI.Vec MQPR:$data), 8, 0), 6442 (Inst MQPR:$data, GPR:$base, MQPR:$offsets)>; 6443 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)), 6444 (Inst MQPR:$data, GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg)>; 6445 } 6446} 6447 6448// Actually define all the loads and stores in this family. 6449 6450defm MVE_VLDRBU8_rq : MVE_VLDR_rq_b<[MVE_v16u8,MVE_v16s8]>; 6451defm MVE_VLDRBU16_rq: MVE_VLDR_rq_b<[MVE_v8u16]>; 6452defm MVE_VLDRBS16_rq: MVE_VLDR_rq_b<[MVE_v8s16]>; 6453defm MVE_VLDRBU32_rq: MVE_VLDR_rq_b<[MVE_v4u32]>; 6454defm MVE_VLDRBS32_rq: MVE_VLDR_rq_b<[MVE_v4s32]>; 6455 6456defm MVE_VLDRHU16_rq: MVE_VLDR_rq_w<MVE_memH, [MVE_v8u16,MVE_v8s16,MVE_v8f16]>; 6457defm MVE_VLDRHU32_rq: MVE_VLDR_rq_w<MVE_memH, [MVE_v4u32]>; 6458defm MVE_VLDRHS32_rq: MVE_VLDR_rq_w<MVE_memH, [MVE_v4s32]>; 6459defm MVE_VLDRWU32_rq: MVE_VLDR_rq_w<MVE_memW, [MVE_v4u32,MVE_v4s32,MVE_v4f32]>; 6460defm MVE_VLDRDU64_rq: MVE_VLDR_rq_w<MVE_memD, [MVE_v2u64,MVE_v2s64]>; 6461 6462defm MVE_VSTRB8_rq : MVE_VSTR_rq_b<[MVE_v16i8]>; 6463defm MVE_VSTRB16_rq : MVE_VSTR_rq_b<[MVE_v8i16]>; 6464defm MVE_VSTRB32_rq : MVE_VSTR_rq_b<[MVE_v4i32]>; 6465 6466defm MVE_VSTRH16_rq : MVE_VSTR_rq_w<MVE_memH, [MVE_v8i16,MVE_v8f16]>; 6467defm MVE_VSTRH32_rq : MVE_VSTR_rq_w<MVE_memH, [MVE_v4i32]>; 6468defm MVE_VSTRW32_rq : MVE_VSTR_rq_w<MVE_memW, [MVE_v4i32,MVE_v4f32]>; 6469defm MVE_VSTRD64_rq : MVE_VSTR_rq_w<MVE_memD, [MVE_v2i64]>; 6470 6471// Gather loads / scatter stores whose address operand is of the form 6472// [Qm,#imm], i.e. a vector containing a full base address for each 6473// loaded item, plus an immediate offset applied consistently to all 6474// of them. ('Load/store the same field from this vector of pointers 6475// to a structure type.') 6476// 6477// This family requires the vector lane size to be at least 32 bits 6478// (so there's room for an address in each lane at all). It has no 6479// widening/narrowing variants. But it does support preindex 6480// writeback, in which the address vector is updated to hold the 6481// addresses actually loaded from. 6482 6483// Base class. 6484class MVE_VLDRSTR_qi<MVE_ldst_direction dir, MVE_memsz memsz, bit W, dag wbops, 6485 string asm, string wbAsm, string suffix, string cstr = ""> 6486 : MVE_VLDRSTR_base<dir, 1, 1, W, 1, !con(wbops, dir.Oops), 6487 !con(dir.Iops, (ins mve_addr_q_shift<memsz.shift>:$addr)), 6488 asm, suffix, "$Qd, $addr" # wbAsm, cstr # dir.cstr, memsz.encoding> { 6489 bits<11> addr; 6490 let Inst{23} = addr{7}; 6491 let Inst{19-17} = addr{10-8}; 6492 let Inst{16} = 0; 6493 let Inst{8} = memsz.encoding{0}; // enough to distinguish 32- from 64-bit 6494 let Inst{7} = 0; 6495 let Inst{6-0} = addr{6-0}; 6496} 6497 6498// Multiclass that generates the non-writeback and writeback variants. 6499multiclass MVE_VLDRSTR_qi_m<MVE_ldst_direction dir, MVE_memsz memsz, 6500 string asm, string suffix> { 6501 def "" : MVE_VLDRSTR_qi<dir, memsz, 0, (outs), asm, "", suffix>; 6502 def _pre : MVE_VLDRSTR_qi<dir, memsz, 1, (outs MQPR:$wb), asm, "!", suffix, 6503 "$addr.base = $wb"> { 6504 let DecoderMethod="DecodeMVE_MEM_3_pre<"#memsz.shift#">"; 6505 } 6506} 6507 6508// Multiclasses wrapping that one, adding selection patterns for the 6509// non-writeback loads and all the stores. (The writeback loads must 6510// deliver multiple output values, so they have to be selected by C++ 6511// code.) 6512multiclass MVE_VLDR_qi<MVE_memsz memsz, MVEVectorVTInfo AVTI, 6513 list<MVEVectorVTInfo> DVTIs> { 6514 defm "" : MVE_VLDRSTR_qi_m<MVE_ld, memsz, "vldr" # memsz.MnemonicLetter, 6515 "u" # memsz.TypeBits>; 6516 defvar Inst = !cast<Instruction>(NAME); 6517 6518 foreach DVTI = DVTIs in { 6519 def : Pat<(DVTI.Vec (int_arm_mve_vldr_gather_base 6520 (AVTI.Vec MQPR:$addr), (i32 imm:$offset))), 6521 (DVTI.Vec (Inst (AVTI.Vec MQPR:$addr), (i32 imm:$offset)))>; 6522 def : Pat<(DVTI.Vec (int_arm_mve_vldr_gather_base_predicated 6523 (AVTI.Vec MQPR:$addr), (i32 imm:$offset), (AVTI.Pred VCCR:$pred))), 6524 (DVTI.Vec (Inst (AVTI.Vec MQPR:$addr), (i32 imm:$offset), 6525 ARMVCCThen, VCCR:$pred, zero_reg))>; 6526 } 6527} 6528multiclass MVE_VSTR_qi<MVE_memsz memsz, MVEVectorVTInfo AVTI, 6529 list<MVEVectorVTInfo> DVTIs> { 6530 defm "" : MVE_VLDRSTR_qi_m<MVE_st, memsz, "vstr" # memsz.MnemonicLetter, 6531 !cast<string>(memsz.TypeBits)>; 6532 defvar Inst = !cast<Instruction>(NAME); 6533 defvar InstPre = !cast<Instruction>(NAME # "_pre"); 6534 6535 foreach DVTI = DVTIs in { 6536 def : Pat<(int_arm_mve_vstr_scatter_base 6537 (AVTI.Vec MQPR:$addr), (i32 imm:$offset), (DVTI.Vec MQPR:$data)), 6538 (Inst (DVTI.Vec MQPR:$data), (AVTI.Vec MQPR:$addr), 6539 (i32 imm:$offset))>; 6540 def : Pat<(int_arm_mve_vstr_scatter_base_predicated 6541 (AVTI.Vec MQPR:$addr), (i32 imm:$offset), (DVTI.Vec MQPR:$data), (AVTI.Pred VCCR:$pred)), 6542 (Inst (DVTI.Vec MQPR:$data), (AVTI.Vec MQPR:$addr), 6543 (i32 imm:$offset), ARMVCCThen, VCCR:$pred, zero_reg)>; 6544 def : Pat<(AVTI.Vec (int_arm_mve_vstr_scatter_base_wb 6545 (AVTI.Vec MQPR:$addr), (i32 imm:$offset), (DVTI.Vec MQPR:$data))), 6546 (AVTI.Vec (InstPre (DVTI.Vec MQPR:$data), (AVTI.Vec MQPR:$addr), 6547 (i32 imm:$offset)))>; 6548 def : Pat<(AVTI.Vec (int_arm_mve_vstr_scatter_base_wb_predicated 6549 (AVTI.Vec MQPR:$addr), (i32 imm:$offset), (DVTI.Vec MQPR:$data), (AVTI.Pred VCCR:$pred))), 6550 (AVTI.Vec (InstPre (DVTI.Vec MQPR:$data), (AVTI.Vec MQPR:$addr), 6551 (i32 imm:$offset), ARMVCCThen, VCCR:$pred, zero_reg))>; 6552 } 6553} 6554 6555// Actual instruction definitions. 6556defm MVE_VLDRWU32_qi: MVE_VLDR_qi<MVE_memW, MVE_v4i32, [MVE_v4i32,MVE_v4f32]>; 6557defm MVE_VLDRDU64_qi: MVE_VLDR_qi<MVE_memD, MVE_v2i64, [MVE_v2i64,MVE_v2f64]>; 6558defm MVE_VSTRW32_qi: MVE_VSTR_qi<MVE_memW, MVE_v4i32, [MVE_v4i32,MVE_v4f32]>; 6559defm MVE_VSTRD64_qi: MVE_VSTR_qi<MVE_memD, MVE_v2i64, [MVE_v2i64,MVE_v2f64]>; 6560 6561// Define aliases for all the instructions where memory size and 6562// vector lane size are the same. These are mnemonic aliases, so they 6563// apply consistently across all of the above families - contiguous 6564// loads, and both the rq and qi types of gather/scatter. 6565// 6566// Rationale: As long as you're loading (for example) 16-bit memory 6567// values into 16-bit vector lanes, you can think of them as signed or 6568// unsigned integers, fp16 or just raw 16-bit blobs and it makes no 6569// difference. So we permit all of vldrh.16, vldrh.u16, vldrh.s16, 6570// vldrh.f16 and treat them all as equivalent to the canonical 6571// spelling (which happens to be .u16 for loads, and just .16 for 6572// stores). 6573 6574foreach vpt_cond = ["", "t", "e"] in 6575foreach memsz = [MVE_memB, MVE_memH, MVE_memW, MVE_memD] in 6576foreach suffix = memsz.suffixes in { 6577 // Define an alias with every suffix in the list, except for the one 6578 // used by the real Instruction record (i.e. the one that all the 6579 // rest are aliases *for*). 6580 6581 if !ne(suffix, memsz.CanonLoadSuffix) then { 6582 def : MnemonicAlias< 6583 "vldr" # memsz.MnemonicLetter # vpt_cond # suffix, 6584 "vldr" # memsz.MnemonicLetter # vpt_cond # memsz.CanonLoadSuffix>; 6585 } 6586 6587 if !ne(suffix, memsz.CanonStoreSuffix) then { 6588 def : MnemonicAlias< 6589 "vstr" # memsz.MnemonicLetter # vpt_cond # suffix, 6590 "vstr" # memsz.MnemonicLetter # vpt_cond # memsz.CanonStoreSuffix>; 6591 } 6592} 6593 6594// end of MVE predicable load/store 6595 6596class MVE_VPT<string suffix, bits<2> size, dag iops, string asm, list<dag> pattern=[]> 6597 : MVE_MI<(outs ), iops, NoItinerary, !strconcat("vpt", "${Mk}", ".", suffix), asm, "", size, pattern> { 6598 bits<3> fc; 6599 bits<4> Mk; 6600 bits<3> Qn; 6601 6602 let Inst{31-23} = 0b111111100; 6603 let Inst{22} = Mk{3}; 6604 let Inst{21-20} = size; 6605 let Inst{19-17} = Qn{2-0}; 6606 let Inst{16} = 0b1; 6607 let Inst{15-13} = Mk{2-0}; 6608 let Inst{12} = fc{2}; 6609 let Inst{11-8} = 0b1111; 6610 let Inst{7} = fc{0}; 6611 let Inst{4} = 0b0; 6612 6613 let Defs = [VPR]; 6614 let validForTailPredication=1; 6615} 6616 6617class MVE_VPTt1<string suffix, bits<2> size, dag iops> 6618 : MVE_VPT<suffix, size, iops, "$fc, $Qn, $Qm"> { 6619 bits<4> Qm; 6620 bits<4> Mk; 6621 6622 let Inst{6} = 0b0; 6623 let Inst{5} = Qm{3}; 6624 let Inst{3-1} = Qm{2-0}; 6625 let Inst{0} = fc{1}; 6626} 6627 6628class MVE_VPTt1i<string suffix, bits<2> size> 6629 : MVE_VPTt1<suffix, size, 6630 (ins vpt_mask:$Mk, MQPR:$Qn, MQPR:$Qm, pred_basic_i:$fc)> { 6631 let Inst{12} = 0b0; 6632 let Inst{0} = 0b0; 6633} 6634 6635def MVE_VPTv4i32 : MVE_VPTt1i<"i32", 0b10>; 6636def MVE_VPTv8i16 : MVE_VPTt1i<"i16", 0b01>; 6637def MVE_VPTv16i8 : MVE_VPTt1i<"i8", 0b00>; 6638 6639class MVE_VPTt1u<string suffix, bits<2> size> 6640 : MVE_VPTt1<suffix, size, 6641 (ins vpt_mask:$Mk, MQPR:$Qn, MQPR:$Qm, pred_basic_u:$fc)> { 6642 let Inst{12} = 0b0; 6643 let Inst{0} = 0b1; 6644} 6645 6646def MVE_VPTv4u32 : MVE_VPTt1u<"u32", 0b10>; 6647def MVE_VPTv8u16 : MVE_VPTt1u<"u16", 0b01>; 6648def MVE_VPTv16u8 : MVE_VPTt1u<"u8", 0b00>; 6649 6650class MVE_VPTt1s<string suffix, bits<2> size> 6651 : MVE_VPTt1<suffix, size, 6652 (ins vpt_mask:$Mk, MQPR:$Qn, MQPR:$Qm, pred_basic_s:$fc)> { 6653 let Inst{12} = 0b1; 6654} 6655 6656def MVE_VPTv4s32 : MVE_VPTt1s<"s32", 0b10>; 6657def MVE_VPTv8s16 : MVE_VPTt1s<"s16", 0b01>; 6658def MVE_VPTv16s8 : MVE_VPTt1s<"s8", 0b00>; 6659 6660class MVE_VPTt2<string suffix, bits<2> size, dag iops> 6661 : MVE_VPT<suffix, size, iops, 6662 "$fc, $Qn, $Rm"> { 6663 bits<4> Rm; 6664 bits<3> fc; 6665 bits<4> Mk; 6666 6667 let Inst{6} = 0b1; 6668 let Inst{5} = fc{1}; 6669 let Inst{3-0} = Rm{3-0}; 6670} 6671 6672class MVE_VPTt2i<string suffix, bits<2> size> 6673 : MVE_VPTt2<suffix, size, 6674 (ins vpt_mask:$Mk, MQPR:$Qn, GPRwithZR:$Rm, pred_basic_i:$fc)> { 6675 let Inst{12} = 0b0; 6676 let Inst{5} = 0b0; 6677} 6678 6679def MVE_VPTv4i32r : MVE_VPTt2i<"i32", 0b10>; 6680def MVE_VPTv8i16r : MVE_VPTt2i<"i16", 0b01>; 6681def MVE_VPTv16i8r : MVE_VPTt2i<"i8", 0b00>; 6682 6683class MVE_VPTt2u<string suffix, bits<2> size> 6684 : MVE_VPTt2<suffix, size, 6685 (ins vpt_mask:$Mk, MQPR:$Qn, GPRwithZR:$Rm, pred_basic_u:$fc)> { 6686 let Inst{12} = 0b0; 6687 let Inst{5} = 0b1; 6688} 6689 6690def MVE_VPTv4u32r : MVE_VPTt2u<"u32", 0b10>; 6691def MVE_VPTv8u16r : MVE_VPTt2u<"u16", 0b01>; 6692def MVE_VPTv16u8r : MVE_VPTt2u<"u8", 0b00>; 6693 6694class MVE_VPTt2s<string suffix, bits<2> size> 6695 : MVE_VPTt2<suffix, size, 6696 (ins vpt_mask:$Mk, MQPR:$Qn, GPRwithZR:$Rm, pred_basic_s:$fc)> { 6697 let Inst{12} = 0b1; 6698} 6699 6700def MVE_VPTv4s32r : MVE_VPTt2s<"s32", 0b10>; 6701def MVE_VPTv8s16r : MVE_VPTt2s<"s16", 0b01>; 6702def MVE_VPTv16s8r : MVE_VPTt2s<"s8", 0b00>; 6703 6704 6705class MVE_VPTf<string suffix, bit size, dag iops, string asm, list<dag> pattern=[]> 6706 : MVE_MI<(outs ), iops, NoItinerary, !strconcat("vpt", "${Mk}", ".", suffix), asm, 6707 "", !if(size, 0b01, 0b10), pattern> { 6708 bits<3> fc; 6709 bits<4> Mk; 6710 bits<3> Qn; 6711 6712 let Inst{31-29} = 0b111; 6713 let Inst{28} = size; 6714 let Inst{27-23} = 0b11100; 6715 let Inst{22} = Mk{3}; 6716 let Inst{21-20} = 0b11; 6717 let Inst{19-17} = Qn{2-0}; 6718 let Inst{16} = 0b1; 6719 let Inst{15-13} = Mk{2-0}; 6720 let Inst{12} = fc{2}; 6721 let Inst{11-8} = 0b1111; 6722 let Inst{7} = fc{0}; 6723 let Inst{4} = 0b0; 6724 6725 let Defs = [VPR]; 6726 let Predicates = [HasMVEFloat]; 6727 let validForTailPredication=1; 6728} 6729 6730class MVE_VPTft1<string suffix, bit size> 6731 : MVE_VPTf<suffix, size, (ins vpt_mask:$Mk, MQPR:$Qn, MQPR:$Qm, pred_basic_fp:$fc), 6732 "$fc, $Qn, $Qm"> { 6733 bits<3> fc; 6734 bits<4> Qm; 6735 6736 let Inst{6} = 0b0; 6737 let Inst{5} = Qm{3}; 6738 let Inst{3-1} = Qm{2-0}; 6739 let Inst{0} = fc{1}; 6740} 6741 6742def MVE_VPTv4f32 : MVE_VPTft1<"f32", 0b0>; 6743def MVE_VPTv8f16 : MVE_VPTft1<"f16", 0b1>; 6744 6745class MVE_VPTft2<string suffix, bit size> 6746 : MVE_VPTf<suffix, size, (ins vpt_mask:$Mk, MQPR:$Qn, GPRwithZR:$Rm, pred_basic_fp:$fc), 6747 "$fc, $Qn, $Rm"> { 6748 bits<3> fc; 6749 bits<4> Rm; 6750 6751 let Inst{6} = 0b1; 6752 let Inst{5} = fc{1}; 6753 let Inst{3-0} = Rm{3-0}; 6754} 6755 6756def MVE_VPTv4f32r : MVE_VPTft2<"f32", 0b0>; 6757def MVE_VPTv8f16r : MVE_VPTft2<"f16", 0b1>; 6758 6759def MVE_VPST : MVE_MI<(outs ), (ins vpt_mask:$Mk), NoItinerary, 6760 !strconcat("vpst", "${Mk}"), "", "", 0b00, []> { 6761 bits<4> Mk; 6762 6763 let Inst{31-23} = 0b111111100; 6764 let Inst{22} = Mk{3}; 6765 let Inst{21-16} = 0b110001; 6766 let Inst{15-13} = Mk{2-0}; 6767 let Inst{12-0} = 0b0111101001101; 6768 let Unpredictable{12} = 0b1; 6769 let Unpredictable{7} = 0b1; 6770 let Unpredictable{5} = 0b1; 6771 6772 let Uses = [VPR]; 6773 let validForTailPredication = 1; 6774} 6775 6776def MVE_VPSEL : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm), NoItinerary, 6777 "vpsel", "", "$Qd, $Qn, $Qm", vpred_n, "", 0b00, []> { 6778 bits<4> Qn; 6779 bits<4> Qd; 6780 bits<4> Qm; 6781 6782 let Inst{28} = 0b1; 6783 let Inst{25-23} = 0b100; 6784 let Inst{22} = Qd{3}; 6785 let Inst{21-20} = 0b11; 6786 let Inst{19-17} = Qn{2-0}; 6787 let Inst{16} = 0b1; 6788 let Inst{15-13} = Qd{2-0}; 6789 let Inst{12-9} = 0b0111; 6790 let Inst{8} = 0b1; 6791 let Inst{7} = Qn{3}; 6792 let Inst{6} = 0b0; 6793 let Inst{5} = Qm{3}; 6794 let Inst{4} = 0b0; 6795 let Inst{3-1} = Qm{2-0}; 6796 let Inst{0} = 0b1; 6797} 6798 6799foreach suffix = ["s8", "s16", "s32", "u8", "u16", "u32", 6800 "i8", "i16", "i32", "f16", "f32"] in 6801def : MVEInstAlias<"vpsel${vp}." # suffix # "\t$Qd, $Qn, $Qm", 6802 (MVE_VPSEL MQPR:$Qd, MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>; 6803 6804let Predicates = [HasMVEInt] in { 6805 def : Pat<(v16i8 (vselect (v16i1 VCCR:$pred), (v16i8 MQPR:$v1), (v16i8 MQPR:$v2))), 6806 (v16i8 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>; 6807 def : Pat<(v8i16 (vselect (v8i1 VCCR:$pred), (v8i16 MQPR:$v1), (v8i16 MQPR:$v2))), 6808 (v8i16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>; 6809 def : Pat<(v4i32 (vselect (v4i1 VCCR:$pred), (v4i32 MQPR:$v1), (v4i32 MQPR:$v2))), 6810 (v4i32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>; 6811 def : Pat<(v2i64 (vselect (v2i1 VCCR:$pred), (v2i64 MQPR:$v1), (v2i64 MQPR:$v2))), 6812 (v2i64 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>; 6813 6814 def : Pat<(v8f16 (vselect (v8i1 VCCR:$pred), (v8f16 MQPR:$v1), (v8f16 MQPR:$v2))), 6815 (v8f16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>; 6816 def : Pat<(v4f32 (vselect (v4i1 VCCR:$pred), (v4f32 MQPR:$v1), (v4f32 MQPR:$v2))), 6817 (v4f32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>; 6818 def : Pat<(v2f64 (vselect (v2i1 VCCR:$pred), (v2f64 MQPR:$v1), (v2f64 MQPR:$v2))), 6819 (v2f64 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>; 6820 6821 def : Pat<(v16i8 (vselect (v16i8 MQPR:$pred), (v16i8 MQPR:$v1), (v16i8 MQPR:$v2))), 6822 (v16i8 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, 6823 (MVE_VCMPi8 (v16i8 MQPR:$pred), (MVE_VMOVimmi8 0), ARMCCne), zero_reg))>; 6824 def : Pat<(v8i16 (vselect (v8i16 MQPR:$pred), (v8i16 MQPR:$v1), (v8i16 MQPR:$v2))), 6825 (v8i16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, 6826 (MVE_VCMPi16 (v8i16 MQPR:$pred), (MVE_VMOVimmi16 0), ARMCCne), zero_reg))>; 6827 def : Pat<(v4i32 (vselect (v4i32 MQPR:$pred), (v4i32 MQPR:$v1), (v4i32 MQPR:$v2))), 6828 (v4i32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, 6829 (MVE_VCMPi32 (v4i32 MQPR:$pred), (MVE_VMOVimmi32 0), ARMCCne), zero_reg))>; 6830 6831 def : Pat<(v8f16 (vselect (v8i16 MQPR:$pred), (v8f16 MQPR:$v1), (v8f16 MQPR:$v2))), 6832 (v8f16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, 6833 (MVE_VCMPi16 (v8i16 MQPR:$pred), (MVE_VMOVimmi16 0), ARMCCne), zero_reg))>; 6834 def : Pat<(v4f32 (vselect (v4i32 MQPR:$pred), (v4f32 MQPR:$v1), (v4f32 MQPR:$v2))), 6835 (v4f32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, 6836 (MVE_VCMPi32 (v4i32 MQPR:$pred), (MVE_VMOVimmi32 0), ARMCCne), zero_reg))>; 6837 6838 // Pred <-> Int 6839 def : Pat<(v16i8 (zext (v16i1 VCCR:$pred))), 6840 (v16i8 (MVE_VPSEL (MVE_VMOVimmi8 1), (MVE_VMOVimmi8 0), ARMVCCNone, VCCR:$pred, zero_reg))>; 6841 def : Pat<(v8i16 (zext (v8i1 VCCR:$pred))), 6842 (v8i16 (MVE_VPSEL (MVE_VMOVimmi16 1), (MVE_VMOVimmi16 0), ARMVCCNone, VCCR:$pred, zero_reg))>; 6843 def : Pat<(v4i32 (zext (v4i1 VCCR:$pred))), 6844 (v4i32 (MVE_VPSEL (MVE_VMOVimmi32 1), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>; 6845 def : Pat<(v2i64 (zext (v2i1 VCCR:$pred))), 6846 (v2i64 (MVE_VPSEL (MVE_VMOVimmi64 1), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>; 6847 6848 def : Pat<(v16i8 (sext (v16i1 VCCR:$pred))), 6849 (v16i8 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi8 0), ARMVCCNone, VCCR:$pred, zero_reg))>; 6850 def : Pat<(v8i16 (sext (v8i1 VCCR:$pred))), 6851 (v8i16 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi16 0), ARMVCCNone, VCCR:$pred, zero_reg))>; 6852 def : Pat<(v4i32 (sext (v4i1 VCCR:$pred))), 6853 (v4i32 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>; 6854 def : Pat<(v2i64 (sext (v2i1 VCCR:$pred))), 6855 (v2i64 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>; 6856 6857 def : Pat<(v16i8 (anyext (v16i1 VCCR:$pred))), 6858 (v16i8 (MVE_VPSEL (MVE_VMOVimmi8 1), (MVE_VMOVimmi8 0), ARMVCCNone, VCCR:$pred, zero_reg))>; 6859 def : Pat<(v8i16 (anyext (v8i1 VCCR:$pred))), 6860 (v8i16 (MVE_VPSEL (MVE_VMOVimmi16 1), (MVE_VMOVimmi16 0), ARMVCCNone, VCCR:$pred, zero_reg))>; 6861 def : Pat<(v4i32 (anyext (v4i1 VCCR:$pred))), 6862 (v4i32 (MVE_VPSEL (MVE_VMOVimmi32 1), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>; 6863 def : Pat<(v2i64 (anyext (v2i1 VCCR:$pred))), 6864 (v2i64 (MVE_VPSEL (MVE_VMOVimmi64 1), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>; 6865} 6866 6867let Predicates = [HasMVEFloat] in { 6868 // Pred <-> Float 6869 // 112 is 1.0 in float 6870 def : Pat<(v4f32 (uint_to_fp (v4i1 VCCR:$pred))), 6871 (v4f32 (MVE_VPSEL (v4f32 (MVE_VMOVimmf32 112)), (v4f32 (MVE_VMOVimmi32 0)), ARMVCCNone, VCCR:$pred, zero_reg))>; 6872 // 2620 in 1.0 in half 6873 def : Pat<(v8f16 (uint_to_fp (v8i1 VCCR:$pred))), 6874 (v8f16 (MVE_VPSEL (v8f16 (MVE_VMOVimmi16 2620)), (v8f16 (MVE_VMOVimmi16 0)), ARMVCCNone, VCCR:$pred, zero_reg))>; 6875 // 240 is -1.0 in float 6876 def : Pat<(v4f32 (sint_to_fp (v4i1 VCCR:$pred))), 6877 (v4f32 (MVE_VPSEL (v4f32 (MVE_VMOVimmf32 240)), (v4f32 (MVE_VMOVimmi32 0)), ARMVCCNone, VCCR:$pred, zero_reg))>; 6878 // 2748 is -1.0 in half 6879 def : Pat<(v8f16 (sint_to_fp (v8i1 VCCR:$pred))), 6880 (v8f16 (MVE_VPSEL (v8f16 (MVE_VMOVimmi16 2748)), (v8f16 (MVE_VMOVimmi16 0)), ARMVCCNone, VCCR:$pred, zero_reg))>; 6881 6882 def : Pat<(v4i1 (fp_to_uint (v4f32 MQPR:$v1))), 6883 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, ARMCCne))>; 6884 def : Pat<(v8i1 (fp_to_uint (v8f16 MQPR:$v1))), 6885 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), ZR, ARMCCne))>; 6886 def : Pat<(v4i1 (fp_to_sint (v4f32 MQPR:$v1))), 6887 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, ARMCCne))>; 6888 def : Pat<(v8i1 (fp_to_sint (v8f16 MQPR:$v1))), 6889 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), ZR, ARMCCne))>; 6890} 6891 6892def MVE_VPNOT : MVE_p<(outs VCCR:$P0), (ins VCCR:$P0_in), NoItinerary, 6893 "vpnot", "", "", vpred_n, "", 0b00, []> { 6894 let Inst{31-0} = 0b11111110001100010000111101001101; 6895 let Unpredictable{19-17} = 0b111; 6896 let Unpredictable{12} = 0b1; 6897 let Unpredictable{7} = 0b1; 6898 let Unpredictable{5} = 0b1; 6899 6900 let Constraints = ""; 6901 let DecoderMethod = "DecodeMVEVPNOT"; 6902} 6903 6904let Predicates = [HasMVEInt] in { 6905 def : Pat<(v2i1 (xor (v2i1 VCCR:$pred), (v2i1 (predicate_cast (i32 65535))))), 6906 (v2i1 (MVE_VPNOT (v2i1 VCCR:$pred)))>; 6907 def : Pat<(v4i1 (xor (v4i1 VCCR:$pred), (v4i1 (predicate_cast (i32 65535))))), 6908 (v4i1 (MVE_VPNOT (v4i1 VCCR:$pred)))>; 6909 def : Pat<(v8i1 (xor (v8i1 VCCR:$pred), (v8i1 (predicate_cast (i32 65535))))), 6910 (v8i1 (MVE_VPNOT (v8i1 VCCR:$pred)))>; 6911 def : Pat<(v16i1 (xor (v16i1 VCCR:$pred), (v16i1 (predicate_cast (i32 65535))))), 6912 (v16i1 (MVE_VPNOT (v16i1 VCCR:$pred)))>; 6913} 6914 6915 6916class MVE_loltp_start<dag iops, string asm, string ops, bits<2> size> 6917 : t2LOL<(outs GPRlr:$LR), iops, asm, ops> { 6918 bits<4> Rn; 6919 let Predicates = [HasMVEInt]; 6920 let Inst{22} = 0b0; 6921 let Inst{21-20} = size; 6922 let Inst{19-16} = Rn{3-0}; 6923 let Inst{12} = 0b0; 6924} 6925 6926class MVE_DLSTP<string asm, bits<2> size> 6927 : MVE_loltp_start<(ins rGPR:$Rn), asm, "$LR, $Rn", size> { 6928 let Inst{13} = 0b1; 6929 let Inst{11-1} = 0b00000000000; 6930 let Unpredictable{10-1} = 0b1111111111; 6931} 6932 6933class MVE_WLSTP<string asm, bits<2> size> 6934 : MVE_loltp_start<(ins rGPR:$Rn, wlslabel_u11:$label), 6935 asm, "$LR, $Rn, $label", size> { 6936 bits<11> label; 6937 let Inst{13} = 0b0; 6938 let Inst{11} = label{0}; 6939 let Inst{10-1} = label{10-1}; 6940 let isBranch = 1; 6941 let isTerminator = 1; 6942} 6943 6944def SDT_MVEMEMCPYLOOPNODE 6945 : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisPtrTy<1>, SDTCisVT<2, i32>]>; 6946def MVE_MEMCPYLOOPNODE : SDNode<"ARMISD::MEMCPYLOOP", SDT_MVEMEMCPYLOOPNODE, 6947 [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>; 6948 6949let usesCustomInserter = 1, hasNoSchedulingInfo = 1, Defs = [CPSR] in { 6950 def MVE_MEMCPYLOOPINST : PseudoInst<(outs), 6951 (ins rGPR:$dst, rGPR:$src, rGPR:$sz), 6952 NoItinerary, 6953 [(MVE_MEMCPYLOOPNODE rGPR:$dst, rGPR:$src, rGPR:$sz)]>; 6954} 6955 6956def SDT_MVEMEMSETLOOPNODE 6957 : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisVT<1, v16i8>, SDTCisVT<2, i32>]>; 6958def MVE_MEMSETLOOPNODE : SDNode<"ARMISD::MEMSETLOOP", SDT_MVEMEMSETLOOPNODE, 6959 [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>; 6960 6961let usesCustomInserter = 1, hasNoSchedulingInfo = 1, Defs = [CPSR] in { 6962 def MVE_MEMSETLOOPINST : PseudoInst<(outs), 6963 (ins rGPR:$dst, MQPR:$src, rGPR:$sz), 6964 NoItinerary, 6965 [(MVE_MEMSETLOOPNODE rGPR:$dst, MQPR:$src, rGPR:$sz)]>; 6966} 6967 6968def MVE_DLSTP_8 : MVE_DLSTP<"dlstp.8", 0b00>; 6969def MVE_DLSTP_16 : MVE_DLSTP<"dlstp.16", 0b01>; 6970def MVE_DLSTP_32 : MVE_DLSTP<"dlstp.32", 0b10>; 6971def MVE_DLSTP_64 : MVE_DLSTP<"dlstp.64", 0b11>; 6972 6973def MVE_WLSTP_8 : MVE_WLSTP<"wlstp.8", 0b00>; 6974def MVE_WLSTP_16 : MVE_WLSTP<"wlstp.16", 0b01>; 6975def MVE_WLSTP_32 : MVE_WLSTP<"wlstp.32", 0b10>; 6976def MVE_WLSTP_64 : MVE_WLSTP<"wlstp.64", 0b11>; 6977 6978class MVE_loltp_end<dag oops, dag iops, string asm, string ops> 6979 : t2LOL<oops, iops, asm, ops> { 6980 let Predicates = [HasMVEInt]; 6981 let Inst{22-21} = 0b00; 6982 let Inst{19-16} = 0b1111; 6983 let Inst{12} = 0b0; 6984} 6985 6986def MVE_LETP : MVE_loltp_end<(outs GPRlr:$LRout), 6987 (ins GPRlr:$LRin, lelabel_u11:$label), 6988 "letp", "$LRin, $label"> { 6989 bits<11> label; 6990 let Inst{20} = 0b1; 6991 let Inst{13} = 0b0; 6992 let Inst{11} = label{0}; 6993 let Inst{10-1} = label{10-1}; 6994 let isBranch = 1; 6995 let isTerminator = 1; 6996} 6997 6998def MVE_LCTP : MVE_loltp_end<(outs), (ins pred:$p), "lctp${p}", ""> { 6999 let Inst{20} = 0b0; 7000 let Inst{13} = 0b1; 7001 let Inst{11-1} = 0b00000000000; 7002 let Unpredictable{21-20} = 0b11; 7003 let Unpredictable{11-1} = 0b11111111111; 7004} 7005 7006 7007// Pseudo instructions for lowering MQQPR and MQQQQPR stack spills and reloads. 7008// They are equivalent to VLDMDIA/VSTMDIA with a single reg, as opposed to multiple 7009// dreg subregs. 7010 7011let Predicates = [HasMVEInt], AM = AddrMode4 in { 7012let mayStore = 1, hasSideEffects = 0 in { 7013 def MQQPRStore : t2PseudoInst<(outs), (ins MQQPR:$val, GPRnopc:$ptr), 7014 4, NoItinerary, []>; 7015 def MQQQQPRStore : t2PseudoInst<(outs), (ins MQQQQPR:$val, GPRnopc:$ptr), 7016 4, NoItinerary, []>; 7017} 7018let mayLoad = 1, hasSideEffects = 0 in { 7019 def MQQPRLoad : t2PseudoInst<(outs MQQPR:$val), (ins GPRnopc:$ptr), 7020 4, NoItinerary, []>; 7021 def MQQQQPRLoad : t2PseudoInst<(outs MQQQQPR:$val), (ins GPRnopc:$ptr), 7022 4, NoItinerary, []>; 7023} 7024} 7025 7026// Pseudo for lowering MVE Q register COPYs. These will usually get converted 7027// to a "MVE_VORR dst, src, src", but may behave differently in tail predicated 7028// loops to ensure the whole register is copied, not a subset from a 7029// tail-predicated MVE_VORR. In the event we cannot prove a MVE_VORR is valid, 7030// it will become a pair of VMOVD instructions for each half of the Q register. 7031let Predicates = [HasMVEInt], hasSideEffects = 0, isMoveReg = 1, 7032 D = MVEDomain in { 7033 def MQPRCopy : t2PseudoInst<(outs MQPR:$dst), (ins MQPR:$src), 7034 8, NoItinerary, []>; 7035} 7036 7037 7038//===----------------------------------------------------------------------===// 7039// Patterns 7040//===----------------------------------------------------------------------===// 7041 7042// PatFrags for loads and stores. Often trying to keep semi-consistent names. 7043 7044def aligned32_pre_store : PatFrag<(ops node:$val, node:$ptr, node:$offset), 7045 (pre_store node:$val, node:$ptr, node:$offset), [{ 7046 return cast<StoreSDNode>(N)->getAlignment() >= 4; 7047}]>; 7048def aligned32_post_store : PatFrag<(ops node:$val, node:$ptr, node:$offset), 7049 (post_store node:$val, node:$ptr, node:$offset), [{ 7050 return cast<StoreSDNode>(N)->getAlignment() >= 4; 7051}]>; 7052def aligned16_pre_store : PatFrag<(ops node:$val, node:$ptr, node:$offset), 7053 (pre_store node:$val, node:$ptr, node:$offset), [{ 7054 return cast<StoreSDNode>(N)->getAlignment() >= 2; 7055}]>; 7056def aligned16_post_store : PatFrag<(ops node:$val, node:$ptr, node:$offset), 7057 (post_store node:$val, node:$ptr, node:$offset), [{ 7058 return cast<StoreSDNode>(N)->getAlignment() >= 2; 7059}]>; 7060 7061 7062def aligned_maskedloadvi8 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru), 7063 (masked_ld node:$ptr, undef, node:$pred, node:$passthru), [{ 7064 auto *Ld = cast<MaskedLoadSDNode>(N); 7065 return Ld->getMemoryVT().getScalarType() == MVT::i8; 7066}]>; 7067def aligned_sextmaskedloadvi8 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru), 7068 (aligned_maskedloadvi8 node:$ptr, node:$pred, node:$passthru), [{ 7069 return cast<MaskedLoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD; 7070}]>; 7071def aligned_zextmaskedloadvi8 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru), 7072 (aligned_maskedloadvi8 node:$ptr, node:$pred, node:$passthru), [{ 7073 return cast<MaskedLoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD; 7074}]>; 7075def aligned_extmaskedloadvi8 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru), 7076 (aligned_maskedloadvi8 node:$ptr, node:$pred, node:$passthru), [{ 7077 auto *Ld = cast<MaskedLoadSDNode>(N); 7078 EVT ScalarVT = Ld->getMemoryVT().getScalarType(); 7079 return ScalarVT.isInteger() && Ld->getExtensionType() == ISD::EXTLOAD; 7080}]>; 7081def aligned_maskedloadvi16: PatFrag<(ops node:$ptr, node:$pred, node:$passthru), 7082 (masked_ld node:$ptr, undef, node:$pred, node:$passthru), [{ 7083 auto *Ld = cast<MaskedLoadSDNode>(N); 7084 EVT ScalarVT = Ld->getMemoryVT().getScalarType(); 7085 return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && Ld->getAlignment() >= 2; 7086}]>; 7087def aligned_sextmaskedloadvi16 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru), 7088 (aligned_maskedloadvi16 node:$ptr, node:$pred, node:$passthru), [{ 7089 return cast<MaskedLoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD; 7090}]>; 7091def aligned_zextmaskedloadvi16 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru), 7092 (aligned_maskedloadvi16 node:$ptr, node:$pred, node:$passthru), [{ 7093 return cast<MaskedLoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD; 7094}]>; 7095def aligned_extmaskedloadvi16 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru), 7096 (aligned_maskedloadvi16 node:$ptr, node:$pred, node:$passthru), [{ 7097 auto *Ld = cast<MaskedLoadSDNode>(N); 7098 EVT ScalarVT = Ld->getMemoryVT().getScalarType(); 7099 return ScalarVT.isInteger() && Ld->getExtensionType() == ISD::EXTLOAD; 7100}]>; 7101def aligned_maskedloadvi32: PatFrag<(ops node:$ptr, node:$pred, node:$passthru), 7102 (masked_ld node:$ptr, undef, node:$pred, node:$passthru), [{ 7103 auto *Ld = cast<MaskedLoadSDNode>(N); 7104 EVT ScalarVT = Ld->getMemoryVT().getScalarType(); 7105 return (ScalarVT == MVT::i32 || ScalarVT == MVT::f32) && Ld->getAlignment() >= 4; 7106}]>; 7107 7108def aligned_maskedstvi8 : PatFrag<(ops node:$val, node:$ptr, node:$pred), 7109 (masked_st node:$val, node:$ptr, undef, node:$pred), [{ 7110 return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8; 7111}]>; 7112def aligned_maskedstvi16 : PatFrag<(ops node:$val, node:$ptr, node:$pred), 7113 (masked_st node:$val, node:$ptr, undef, node:$pred), [{ 7114 auto *St = cast<MaskedStoreSDNode>(N); 7115 EVT ScalarVT = St->getMemoryVT().getScalarType(); 7116 return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlignment() >= 2; 7117}]>; 7118def aligned_maskedstvi32 : PatFrag<(ops node:$val, node:$ptr, node:$pred), 7119 (masked_st node:$val, node:$ptr, undef, node:$pred), [{ 7120 auto *St = cast<MaskedStoreSDNode>(N); 7121 EVT ScalarVT = St->getMemoryVT().getScalarType(); 7122 return (ScalarVT == MVT::i32 || ScalarVT == MVT::f32) && St->getAlignment() >= 4; 7123}]>; 7124 7125def pre_maskedstore : PatFrag<(ops node:$val, node:$base, node:$offset, node:$mask), 7126 (masked_st node:$val, node:$base, node:$offset, node:$mask), [{ 7127 ISD::MemIndexedMode AM = cast<MaskedStoreSDNode>(N)->getAddressingMode(); 7128 return AM == ISD::PRE_INC || AM == ISD::PRE_DEC; 7129}]>; 7130def post_maskedstore : PatFrag<(ops node:$val, node:$base, node:$offset, node:$mask), 7131 (masked_st node:$val, node:$base, node:$offset, node:$mask), [{ 7132 ISD::MemIndexedMode AM = cast<MaskedStoreSDNode>(N)->getAddressingMode(); 7133 return AM == ISD::POST_INC || AM == ISD::POST_DEC; 7134}]>; 7135def aligned_pre_maskedstorevi8 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask), 7136 (pre_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{ 7137 return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8; 7138}]>; 7139def aligned_post_maskedstorevi8 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask), 7140 (post_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{ 7141 return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8; 7142}]>; 7143def aligned_pre_maskedstorevi16 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask), 7144 (pre_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{ 7145 auto *St = cast<MaskedStoreSDNode>(N); 7146 EVT ScalarVT = St->getMemoryVT().getScalarType(); 7147 return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlignment() >= 2; 7148}]>; 7149def aligned_post_maskedstorevi16 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask), 7150 (post_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{ 7151 auto *St = cast<MaskedStoreSDNode>(N); 7152 EVT ScalarVT = St->getMemoryVT().getScalarType(); 7153 return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlignment() >= 2; 7154}]>; 7155def aligned_pre_maskedstorevi32 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask), 7156 (pre_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{ 7157 auto *St = cast<MaskedStoreSDNode>(N); 7158 EVT ScalarVT = St->getMemoryVT().getScalarType(); 7159 return (ScalarVT == MVT::i32 || ScalarVT == MVT::f32) && St->getAlignment() >= 4; 7160}]>; 7161def aligned_post_maskedstorevi32 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask), 7162 (post_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{ 7163 auto *St = cast<MaskedStoreSDNode>(N); 7164 EVT ScalarVT = St->getMemoryVT().getScalarType(); 7165 return (ScalarVT == MVT::i32 || ScalarVT == MVT::f32) && St->getAlignment() >= 4; 7166}]>; 7167 7168 7169// PatFrags for "Aligned" extending / truncating 7170 7171def aligned_extloadvi8 : PatFrag<(ops node:$ptr), (extloadvi8 node:$ptr)>; 7172def aligned_sextloadvi8 : PatFrag<(ops node:$ptr), (sextloadvi8 node:$ptr)>; 7173def aligned_zextloadvi8 : PatFrag<(ops node:$ptr), (zextloadvi8 node:$ptr)>; 7174 7175def aligned_truncstvi8 : PatFrag<(ops node:$val, node:$ptr), 7176 (truncstorevi8 node:$val, node:$ptr)>; 7177def aligned_post_truncstvi8 : PatFrag<(ops node:$val, node:$base, node:$offset), 7178 (post_truncstvi8 node:$val, node:$base, node:$offset)>; 7179def aligned_pre_truncstvi8 : PatFrag<(ops node:$val, node:$base, node:$offset), 7180 (pre_truncstvi8 node:$val, node:$base, node:$offset)>; 7181 7182let MinAlignment = 2 in { 7183 def aligned_extloadvi16 : PatFrag<(ops node:$ptr), (extloadvi16 node:$ptr)>; 7184 def aligned_sextloadvi16 : PatFrag<(ops node:$ptr), (sextloadvi16 node:$ptr)>; 7185 def aligned_zextloadvi16 : PatFrag<(ops node:$ptr), (zextloadvi16 node:$ptr)>; 7186 7187 def aligned_truncstvi16 : PatFrag<(ops node:$val, node:$ptr), 7188 (truncstorevi16 node:$val, node:$ptr)>; 7189 def aligned_post_truncstvi16 : PatFrag<(ops node:$val, node:$base, node:$offset), 7190 (post_truncstvi16 node:$val, node:$base, node:$offset)>; 7191 def aligned_pre_truncstvi16 : PatFrag<(ops node:$val, node:$base, node:$offset), 7192 (pre_truncstvi16 node:$val, node:$base, node:$offset)>; 7193} 7194 7195def truncmaskedst : PatFrag<(ops node:$val, node:$base, node:$pred), 7196 (masked_st node:$val, node:$base, undef, node:$pred), [{ 7197 return cast<MaskedStoreSDNode>(N)->isTruncatingStore(); 7198}]>; 7199def aligned_truncmaskedstvi8 : PatFrag<(ops node:$val, node:$base, node:$pred), 7200 (truncmaskedst node:$val, node:$base, node:$pred), [{ 7201 return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8; 7202}]>; 7203def aligned_truncmaskedstvi16 : PatFrag<(ops node:$val, node:$base, node:$pred), 7204 (truncmaskedst node:$val, node:$base, node:$pred), [{ 7205 auto *St = cast<MaskedStoreSDNode>(N); 7206 EVT ScalarVT = St->getMemoryVT().getScalarType(); 7207 return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlignment() >= 2; 7208}]>; 7209def pre_truncmaskedst : PatFrag<(ops node:$val, node:$base, node:$offset, node:$pred), 7210 (masked_st node:$val, node:$base, node:$offset, node:$pred), [{ 7211 ISD::MemIndexedMode AM = cast<MaskedStoreSDNode>(N)->getAddressingMode(); 7212 return cast<MaskedStoreSDNode>(N)->isTruncatingStore() && (AM == ISD::PRE_INC || AM == ISD::PRE_DEC); 7213}]>; 7214def aligned_pre_truncmaskedstvi8 : PatFrag<(ops node:$val, node:$base, node:$offset, node:$pred), 7215 (pre_truncmaskedst node:$val, node:$base, node:$offset, node:$pred), [{ 7216 return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8; 7217}]>; 7218def aligned_pre_truncmaskedstvi16 : PatFrag<(ops node:$val, node:$base, node:$offset, node:$pred), 7219 (pre_truncmaskedst node:$val, node:$base, node:$offset, node:$pred), [{ 7220 auto *St = cast<MaskedStoreSDNode>(N); 7221 EVT ScalarVT = St->getMemoryVT().getScalarType(); 7222 return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlignment() >= 2; 7223}]>; 7224def post_truncmaskedst : PatFrag<(ops node:$val, node:$base, node:$offset, node:$postd), 7225 (masked_st node:$val, node:$base, node:$offset, node:$postd), [{ 7226 ISD::MemIndexedMode AM = cast<MaskedStoreSDNode>(N)->getAddressingMode(); 7227 return cast<MaskedStoreSDNode>(N)->isTruncatingStore() && (AM == ISD::POST_INC || AM == ISD::POST_DEC); 7228}]>; 7229def aligned_post_truncmaskedstvi8 : PatFrag<(ops node:$val, node:$base, node:$offset, node:$postd), 7230 (post_truncmaskedst node:$val, node:$base, node:$offset, node:$postd), [{ 7231 return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8; 7232}]>; 7233def aligned_post_truncmaskedstvi16 : PatFrag<(ops node:$val, node:$base, node:$offset, node:$postd), 7234 (post_truncmaskedst node:$val, node:$base, node:$offset, node:$postd), [{ 7235 auto *St = cast<MaskedStoreSDNode>(N); 7236 EVT ScalarVT = St->getMemoryVT().getScalarType(); 7237 return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlignment() >= 2; 7238}]>; 7239 7240// Load/store patterns 7241 7242class MVE_vector_store_typed<ValueType Ty, Instruction RegImmInst, 7243 PatFrag StoreKind, int shift> 7244 : Pat<(StoreKind (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr), 7245 (RegImmInst (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr)>; 7246 7247class MVE_vector_maskedstore_typed<ValueType Ty, Instruction RegImmInst, 7248 PatFrag StoreKind, int shift> 7249 : Pat<(StoreKind (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr, VCCR:$pred), 7250 (RegImmInst (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg)>; 7251 7252multiclass MVE_vector_store<Instruction RegImmInst, PatFrag StoreKind, 7253 int shift> { 7254 def : MVE_vector_store_typed<v16i8, RegImmInst, StoreKind, shift>; 7255 def : MVE_vector_store_typed<v8i16, RegImmInst, StoreKind, shift>; 7256 def : MVE_vector_store_typed<v8f16, RegImmInst, StoreKind, shift>; 7257 def : MVE_vector_store_typed<v4i32, RegImmInst, StoreKind, shift>; 7258 def : MVE_vector_store_typed<v4f32, RegImmInst, StoreKind, shift>; 7259 def : MVE_vector_store_typed<v2i64, RegImmInst, StoreKind, shift>; 7260 def : MVE_vector_store_typed<v2f64, RegImmInst, StoreKind, shift>; 7261} 7262 7263class MVE_vector_load_typed<ValueType Ty, Instruction RegImmInst, 7264 PatFrag LoadKind, int shift> 7265 : Pat<(Ty (LoadKind t2addrmode_imm7<shift>:$addr)), 7266 (Ty (RegImmInst t2addrmode_imm7<shift>:$addr))>; 7267 7268class MVE_vector_maskedload_typed<ValueType Ty, Instruction RegImmInst, 7269 PatFrag LoadKind, int shift> 7270 : Pat<(Ty (LoadKind t2addrmode_imm7<shift>:$addr, VCCR:$pred, (Ty (ARMvmovImm (i32 0))))), 7271 (Ty (RegImmInst t2addrmode_imm7<shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg))>; 7272 7273multiclass MVE_vector_load<Instruction RegImmInst, PatFrag LoadKind, 7274 int shift> { 7275 def : MVE_vector_load_typed<v16i8, RegImmInst, LoadKind, shift>; 7276 def : MVE_vector_load_typed<v8i16, RegImmInst, LoadKind, shift>; 7277 def : MVE_vector_load_typed<v8f16, RegImmInst, LoadKind, shift>; 7278 def : MVE_vector_load_typed<v4i32, RegImmInst, LoadKind, shift>; 7279 def : MVE_vector_load_typed<v4f32, RegImmInst, LoadKind, shift>; 7280 def : MVE_vector_load_typed<v2i64, RegImmInst, LoadKind, shift>; 7281 def : MVE_vector_load_typed<v2f64, RegImmInst, LoadKind, shift>; 7282} 7283 7284class MVE_vector_offset_store_typed<ValueType Ty, Instruction Opcode, 7285 PatFrag StoreKind, int shift> 7286 : Pat<(StoreKind (Ty MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<shift>:$addr), 7287 (Opcode MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<shift>:$addr)>; 7288 7289class MVE_vector_offset_maskedstore_typed<ValueType Ty, Instruction Opcode, 7290 PatFrag StoreKind, int shift> 7291 : Pat<(StoreKind (Ty MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<shift>:$addr, VCCR:$pred), 7292 (Opcode MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg)>; 7293 7294multiclass MVE_vector_offset_store<Instruction RegImmInst, PatFrag StoreKind, 7295 int shift> { 7296 def : MVE_vector_offset_store_typed<v16i8, RegImmInst, StoreKind, shift>; 7297 def : MVE_vector_offset_store_typed<v8i16, RegImmInst, StoreKind, shift>; 7298 def : MVE_vector_offset_store_typed<v8f16, RegImmInst, StoreKind, shift>; 7299 def : MVE_vector_offset_store_typed<v4i32, RegImmInst, StoreKind, shift>; 7300 def : MVE_vector_offset_store_typed<v4f32, RegImmInst, StoreKind, shift>; 7301 def : MVE_vector_offset_store_typed<v2i64, RegImmInst, StoreKind, shift>; 7302 def : MVE_vector_offset_store_typed<v2f64, RegImmInst, StoreKind, shift>; 7303} 7304 7305 7306let Predicates = [HasMVEInt, IsLE] in { 7307 // Stores 7308 defm : MVE_vector_store<MVE_VSTRBU8, byte_alignedstore, 0>; 7309 defm : MVE_vector_store<MVE_VSTRHU16, hword_alignedstore, 1>; 7310 defm : MVE_vector_store<MVE_VSTRWU32, alignedstore32, 2>; 7311 7312 // Loads 7313 defm : MVE_vector_load<MVE_VLDRBU8, byte_alignedload, 0>; 7314 defm : MVE_vector_load<MVE_VLDRHU16, hword_alignedload, 1>; 7315 defm : MVE_vector_load<MVE_VLDRWU32, alignedload32, 2>; 7316 7317 // Pre/post inc stores 7318 defm : MVE_vector_offset_store<MVE_VSTRBU8_pre, pre_store, 0>; 7319 defm : MVE_vector_offset_store<MVE_VSTRBU8_post, post_store, 0>; 7320 defm : MVE_vector_offset_store<MVE_VSTRHU16_pre, aligned16_pre_store, 1>; 7321 defm : MVE_vector_offset_store<MVE_VSTRHU16_post, aligned16_post_store, 1>; 7322 defm : MVE_vector_offset_store<MVE_VSTRWU32_pre, aligned32_pre_store, 2>; 7323 defm : MVE_vector_offset_store<MVE_VSTRWU32_post, aligned32_post_store, 2>; 7324} 7325 7326let Predicates = [HasMVEInt, IsBE] in { 7327 // Aligned Stores 7328 def : MVE_vector_store_typed<v16i8, MVE_VSTRBU8, store, 0>; 7329 def : MVE_vector_store_typed<v8i16, MVE_VSTRHU16, alignedstore16, 1>; 7330 def : MVE_vector_store_typed<v8f16, MVE_VSTRHU16, alignedstore16, 1>; 7331 def : MVE_vector_store_typed<v4i32, MVE_VSTRWU32, alignedstore32, 2>; 7332 def : MVE_vector_store_typed<v4f32, MVE_VSTRWU32, alignedstore32, 2>; 7333 7334 // Aligned Loads 7335 def : MVE_vector_load_typed<v16i8, MVE_VLDRBU8, load, 0>; 7336 def : MVE_vector_load_typed<v8i16, MVE_VLDRHU16, alignedload16, 1>; 7337 def : MVE_vector_load_typed<v8f16, MVE_VLDRHU16, alignedload16, 1>; 7338 def : MVE_vector_load_typed<v4i32, MVE_VLDRWU32, alignedload32, 2>; 7339 def : MVE_vector_load_typed<v4f32, MVE_VLDRWU32, alignedload32, 2>; 7340 7341 // Other unaligned loads/stores need to go though a VREV 7342 def : Pat<(v2f64 (load t2addrmode_imm7<0>:$addr)), 7343 (v2f64 (MVE_VREV64_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>; 7344 def : Pat<(v2i64 (load t2addrmode_imm7<0>:$addr)), 7345 (v2i64 (MVE_VREV64_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>; 7346 def : Pat<(v4i32 (load t2addrmode_imm7<0>:$addr)), 7347 (v4i32 (MVE_VREV32_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>; 7348 def : Pat<(v4f32 (load t2addrmode_imm7<0>:$addr)), 7349 (v4f32 (MVE_VREV32_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>; 7350 def : Pat<(v8i16 (load t2addrmode_imm7<0>:$addr)), 7351 (v8i16 (MVE_VREV16_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>; 7352 def : Pat<(v8f16 (load t2addrmode_imm7<0>:$addr)), 7353 (v8f16 (MVE_VREV16_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>; 7354 def : Pat<(store (v2f64 MQPR:$val), t2addrmode_imm7<0>:$addr), 7355 (MVE_VSTRBU8 (MVE_VREV64_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>; 7356 def : Pat<(store (v2i64 MQPR:$val), t2addrmode_imm7<0>:$addr), 7357 (MVE_VSTRBU8 (MVE_VREV64_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>; 7358 def : Pat<(store (v4i32 MQPR:$val), t2addrmode_imm7<0>:$addr), 7359 (MVE_VSTRBU8 (MVE_VREV32_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>; 7360 def : Pat<(store (v4f32 MQPR:$val), t2addrmode_imm7<0>:$addr), 7361 (MVE_VSTRBU8 (MVE_VREV32_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>; 7362 def : Pat<(store (v8i16 MQPR:$val), t2addrmode_imm7<0>:$addr), 7363 (MVE_VSTRBU8 (MVE_VREV16_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>; 7364 def : Pat<(store (v8f16 MQPR:$val), t2addrmode_imm7<0>:$addr), 7365 (MVE_VSTRBU8 (MVE_VREV16_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>; 7366 7367 // Pre/Post inc stores 7368 def : MVE_vector_offset_store_typed<v16i8, MVE_VSTRBU8_pre, pre_store, 0>; 7369 def : MVE_vector_offset_store_typed<v16i8, MVE_VSTRBU8_post, post_store, 0>; 7370 def : MVE_vector_offset_store_typed<v8i16, MVE_VSTRHU16_pre, aligned16_pre_store, 1>; 7371 def : MVE_vector_offset_store_typed<v8i16, MVE_VSTRHU16_post, aligned16_post_store, 1>; 7372 def : MVE_vector_offset_store_typed<v8f16, MVE_VSTRHU16_pre, aligned16_pre_store, 1>; 7373 def : MVE_vector_offset_store_typed<v8f16, MVE_VSTRHU16_post, aligned16_post_store, 1>; 7374 def : MVE_vector_offset_store_typed<v4i32, MVE_VSTRWU32_pre, aligned32_pre_store, 2>; 7375 def : MVE_vector_offset_store_typed<v4i32, MVE_VSTRWU32_post, aligned32_post_store, 2>; 7376 def : MVE_vector_offset_store_typed<v4f32, MVE_VSTRWU32_pre, aligned32_pre_store, 2>; 7377 def : MVE_vector_offset_store_typed<v4f32, MVE_VSTRWU32_post, aligned32_post_store, 2>; 7378} 7379 7380let Predicates = [HasMVEInt] in { 7381 // Aligned masked store, shared between LE and BE 7382 def : MVE_vector_maskedstore_typed<v16i8, MVE_VSTRBU8, aligned_maskedstvi8, 0>; 7383 def : MVE_vector_maskedstore_typed<v8i16, MVE_VSTRHU16, aligned_maskedstvi16, 1>; 7384 def : MVE_vector_maskedstore_typed<v8f16, MVE_VSTRHU16, aligned_maskedstvi16, 1>; 7385 def : MVE_vector_maskedstore_typed<v4i32, MVE_VSTRWU32, aligned_maskedstvi32, 2>; 7386 def : MVE_vector_maskedstore_typed<v4f32, MVE_VSTRWU32, aligned_maskedstvi32, 2>; 7387 7388 // Pre/Post inc masked stores 7389 def : MVE_vector_offset_maskedstore_typed<v16i8, MVE_VSTRBU8_pre, aligned_pre_maskedstorevi8, 0>; 7390 def : MVE_vector_offset_maskedstore_typed<v16i8, MVE_VSTRBU8_post, aligned_post_maskedstorevi8, 0>; 7391 def : MVE_vector_offset_maskedstore_typed<v8i16, MVE_VSTRHU16_pre, aligned_pre_maskedstorevi16, 1>; 7392 def : MVE_vector_offset_maskedstore_typed<v8i16, MVE_VSTRHU16_post, aligned_post_maskedstorevi16, 1>; 7393 def : MVE_vector_offset_maskedstore_typed<v8f16, MVE_VSTRHU16_pre, aligned_pre_maskedstorevi16, 1>; 7394 def : MVE_vector_offset_maskedstore_typed<v8f16, MVE_VSTRHU16_post, aligned_post_maskedstorevi16, 1>; 7395 def : MVE_vector_offset_maskedstore_typed<v4i32, MVE_VSTRWU32_pre, aligned_pre_maskedstorevi32, 2>; 7396 def : MVE_vector_offset_maskedstore_typed<v4i32, MVE_VSTRWU32_post, aligned_post_maskedstorevi32, 2>; 7397 def : MVE_vector_offset_maskedstore_typed<v4f32, MVE_VSTRWU32_pre, aligned_pre_maskedstorevi32, 2>; 7398 def : MVE_vector_offset_maskedstore_typed<v4f32, MVE_VSTRWU32_post, aligned_post_maskedstorevi32, 2>; 7399 7400 // Aligned masked loads 7401 def : MVE_vector_maskedload_typed<v16i8, MVE_VLDRBU8, aligned_maskedloadvi8, 0>; 7402 def : MVE_vector_maskedload_typed<v8i16, MVE_VLDRHU16, aligned_maskedloadvi16, 1>; 7403 def : MVE_vector_maskedload_typed<v8f16, MVE_VLDRHU16, aligned_maskedloadvi16, 1>; 7404 def : MVE_vector_maskedload_typed<v4i32, MVE_VLDRWU32, aligned_maskedloadvi32, 2>; 7405 def : MVE_vector_maskedload_typed<v4f32, MVE_VLDRWU32, aligned_maskedloadvi32, 2>; 7406} 7407 7408// Widening/Narrowing Loads/Stores 7409 7410multiclass MVEExtLoadStore<Instruction LoadSInst, Instruction LoadUInst, string StoreInst, 7411 string Amble, ValueType VT, int Shift> { 7412 // Trunc stores 7413 def : Pat<(!cast<PatFrag>("aligned_truncst"#Amble) (VT MQPR:$val), taddrmode_imm7<Shift>:$addr), 7414 (!cast<Instruction>(StoreInst) MQPR:$val, taddrmode_imm7<Shift>:$addr)>; 7415 def : Pat<(!cast<PatFrag>("aligned_post_truncst"#Amble) (VT MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<Shift>:$addr), 7416 (!cast<Instruction>(StoreInst#"_post") MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<Shift>:$addr)>; 7417 def : Pat<(!cast<PatFrag>("aligned_pre_truncst"#Amble) (VT MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<Shift>:$addr), 7418 (!cast<Instruction>(StoreInst#"_pre") MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<Shift>:$addr)>; 7419 7420 // Masked trunc stores 7421 def : Pat<(!cast<PatFrag>("aligned_truncmaskedst"#Amble) (VT MQPR:$val), taddrmode_imm7<Shift>:$addr, VCCR:$pred), 7422 (!cast<Instruction>(StoreInst) MQPR:$val, taddrmode_imm7<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg)>; 7423 def : Pat<(!cast<PatFrag>("aligned_post_truncmaskedst"#Amble) (VT MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<Shift>:$addr, VCCR:$pred), 7424 (!cast<Instruction>(StoreInst#"_post") MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg)>; 7425 def : Pat<(!cast<PatFrag>("aligned_pre_truncmaskedst"#Amble) (VT MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<Shift>:$addr, VCCR:$pred), 7426 (!cast<Instruction>(StoreInst#"_pre") MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg)>; 7427 7428 // Ext loads 7429 def : Pat<(VT (!cast<PatFrag>("aligned_extload"#Amble) taddrmode_imm7<Shift>:$addr)), 7430 (VT (LoadUInst taddrmode_imm7<Shift>:$addr))>; 7431 def : Pat<(VT (!cast<PatFrag>("aligned_sextload"#Amble) taddrmode_imm7<Shift>:$addr)), 7432 (VT (LoadSInst taddrmode_imm7<Shift>:$addr))>; 7433 def : Pat<(VT (!cast<PatFrag>("aligned_zextload"#Amble) taddrmode_imm7<Shift>:$addr)), 7434 (VT (LoadUInst taddrmode_imm7<Shift>:$addr))>; 7435 7436 // Masked ext loads 7437 def : Pat<(VT (!cast<PatFrag>("aligned_extmaskedload"#Amble) taddrmode_imm7<Shift>:$addr, VCCR:$pred, (VT (ARMvmovImm (i32 0))))), 7438 (VT (LoadUInst taddrmode_imm7<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg))>; 7439 def : Pat<(VT (!cast<PatFrag>("aligned_sextmaskedload"#Amble) taddrmode_imm7<Shift>:$addr, VCCR:$pred, (VT (ARMvmovImm (i32 0))))), 7440 (VT (LoadSInst taddrmode_imm7<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg))>; 7441 def : Pat<(VT (!cast<PatFrag>("aligned_zextmaskedload"#Amble) taddrmode_imm7<Shift>:$addr, VCCR:$pred, (VT (ARMvmovImm (i32 0))))), 7442 (VT (LoadUInst taddrmode_imm7<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg))>; 7443} 7444 7445let Predicates = [HasMVEInt] in { 7446 defm : MVEExtLoadStore<MVE_VLDRBS16, MVE_VLDRBU16, "MVE_VSTRB16", "vi8", v8i16, 0>; 7447 defm : MVEExtLoadStore<MVE_VLDRBS32, MVE_VLDRBU32, "MVE_VSTRB32", "vi8", v4i32, 0>; 7448 defm : MVEExtLoadStore<MVE_VLDRHS32, MVE_VLDRHU32, "MVE_VSTRH32", "vi16", v4i32, 1>; 7449} 7450 7451 7452// Bit convert patterns 7453 7454let Predicates = [HasMVEInt] in { 7455 def : Pat<(v2f64 (bitconvert (v2i64 MQPR:$src))), (v2f64 MQPR:$src)>; 7456 def : Pat<(v2i64 (bitconvert (v2f64 MQPR:$src))), (v2i64 MQPR:$src)>; 7457 7458 def : Pat<(v4i32 (bitconvert (v4f32 MQPR:$src))), (v4i32 MQPR:$src)>; 7459 def : Pat<(v4f32 (bitconvert (v4i32 MQPR:$src))), (v4f32 MQPR:$src)>; 7460 7461 def : Pat<(v8i16 (bitconvert (v8f16 MQPR:$src))), (v8i16 MQPR:$src)>; 7462 def : Pat<(v8f16 (bitconvert (v8i16 MQPR:$src))), (v8f16 MQPR:$src)>; 7463} 7464 7465let Predicates = [IsLE,HasMVEInt] in { 7466 def : Pat<(v2f64 (bitconvert (v4f32 MQPR:$src))), (v2f64 MQPR:$src)>; 7467 def : Pat<(v2f64 (bitconvert (v4i32 MQPR:$src))), (v2f64 MQPR:$src)>; 7468 def : Pat<(v2f64 (bitconvert (v8f16 MQPR:$src))), (v2f64 MQPR:$src)>; 7469 def : Pat<(v2f64 (bitconvert (v8i16 MQPR:$src))), (v2f64 MQPR:$src)>; 7470 def : Pat<(v2f64 (bitconvert (v16i8 MQPR:$src))), (v2f64 MQPR:$src)>; 7471 7472 def : Pat<(v2i64 (bitconvert (v4f32 MQPR:$src))), (v2i64 MQPR:$src)>; 7473 def : Pat<(v2i64 (bitconvert (v4i32 MQPR:$src))), (v2i64 MQPR:$src)>; 7474 def : Pat<(v2i64 (bitconvert (v8f16 MQPR:$src))), (v2i64 MQPR:$src)>; 7475 def : Pat<(v2i64 (bitconvert (v8i16 MQPR:$src))), (v2i64 MQPR:$src)>; 7476 def : Pat<(v2i64 (bitconvert (v16i8 MQPR:$src))), (v2i64 MQPR:$src)>; 7477 7478 def : Pat<(v4f32 (bitconvert (v2f64 MQPR:$src))), (v4f32 MQPR:$src)>; 7479 def : Pat<(v4f32 (bitconvert (v2i64 MQPR:$src))), (v4f32 MQPR:$src)>; 7480 def : Pat<(v4f32 (bitconvert (v8f16 MQPR:$src))), (v4f32 MQPR:$src)>; 7481 def : Pat<(v4f32 (bitconvert (v8i16 MQPR:$src))), (v4f32 MQPR:$src)>; 7482 def : Pat<(v4f32 (bitconvert (v16i8 MQPR:$src))), (v4f32 MQPR:$src)>; 7483 7484 def : Pat<(v4i32 (bitconvert (v2f64 MQPR:$src))), (v4i32 MQPR:$src)>; 7485 def : Pat<(v4i32 (bitconvert (v2i64 MQPR:$src))), (v4i32 MQPR:$src)>; 7486 def : Pat<(v4i32 (bitconvert (v8f16 MQPR:$src))), (v4i32 MQPR:$src)>; 7487 def : Pat<(v4i32 (bitconvert (v8i16 MQPR:$src))), (v4i32 MQPR:$src)>; 7488 def : Pat<(v4i32 (bitconvert (v16i8 MQPR:$src))), (v4i32 MQPR:$src)>; 7489 7490 def : Pat<(v8f16 (bitconvert (v2f64 MQPR:$src))), (v8f16 MQPR:$src)>; 7491 def : Pat<(v8f16 (bitconvert (v2i64 MQPR:$src))), (v8f16 MQPR:$src)>; 7492 def : Pat<(v8f16 (bitconvert (v4f32 MQPR:$src))), (v8f16 MQPR:$src)>; 7493 def : Pat<(v8f16 (bitconvert (v4i32 MQPR:$src))), (v8f16 MQPR:$src)>; 7494 def : Pat<(v8f16 (bitconvert (v16i8 MQPR:$src))), (v8f16 MQPR:$src)>; 7495 7496 def : Pat<(v8i16 (bitconvert (v2f64 MQPR:$src))), (v8i16 MQPR:$src)>; 7497 def : Pat<(v8i16 (bitconvert (v2i64 MQPR:$src))), (v8i16 MQPR:$src)>; 7498 def : Pat<(v8i16 (bitconvert (v4f32 MQPR:$src))), (v8i16 MQPR:$src)>; 7499 def : Pat<(v8i16 (bitconvert (v4i32 MQPR:$src))), (v8i16 MQPR:$src)>; 7500 def : Pat<(v8i16 (bitconvert (v16i8 MQPR:$src))), (v8i16 MQPR:$src)>; 7501 7502 def : Pat<(v16i8 (bitconvert (v2f64 MQPR:$src))), (v16i8 MQPR:$src)>; 7503 def : Pat<(v16i8 (bitconvert (v2i64 MQPR:$src))), (v16i8 MQPR:$src)>; 7504 def : Pat<(v16i8 (bitconvert (v4f32 MQPR:$src))), (v16i8 MQPR:$src)>; 7505 def : Pat<(v16i8 (bitconvert (v4i32 MQPR:$src))), (v16i8 MQPR:$src)>; 7506 def : Pat<(v16i8 (bitconvert (v8f16 MQPR:$src))), (v16i8 MQPR:$src)>; 7507 def : Pat<(v16i8 (bitconvert (v8i16 MQPR:$src))), (v16i8 MQPR:$src)>; 7508} 7509 7510let Predicates = [IsBE,HasMVEInt] in { 7511 def : Pat<(v2f64 (bitconvert (v4f32 MQPR:$src))), (v2f64 (MVE_VREV64_32 MQPR:$src))>; 7512 def : Pat<(v2f64 (bitconvert (v4i32 MQPR:$src))), (v2f64 (MVE_VREV64_32 MQPR:$src))>; 7513 def : Pat<(v2f64 (bitconvert (v8f16 MQPR:$src))), (v2f64 (MVE_VREV64_16 MQPR:$src))>; 7514 def : Pat<(v2f64 (bitconvert (v8i16 MQPR:$src))), (v2f64 (MVE_VREV64_16 MQPR:$src))>; 7515 def : Pat<(v2f64 (bitconvert (v16i8 MQPR:$src))), (v2f64 (MVE_VREV64_8 MQPR:$src))>; 7516 7517 def : Pat<(v2i64 (bitconvert (v4f32 MQPR:$src))), (v2i64 (MVE_VREV64_32 MQPR:$src))>; 7518 def : Pat<(v2i64 (bitconvert (v4i32 MQPR:$src))), (v2i64 (MVE_VREV64_32 MQPR:$src))>; 7519 def : Pat<(v2i64 (bitconvert (v8f16 MQPR:$src))), (v2i64 (MVE_VREV64_16 MQPR:$src))>; 7520 def : Pat<(v2i64 (bitconvert (v8i16 MQPR:$src))), (v2i64 (MVE_VREV64_16 MQPR:$src))>; 7521 def : Pat<(v2i64 (bitconvert (v16i8 MQPR:$src))), (v2i64 (MVE_VREV64_8 MQPR:$src))>; 7522 7523 def : Pat<(v4f32 (bitconvert (v2f64 MQPR:$src))), (v4f32 (MVE_VREV64_32 MQPR:$src))>; 7524 def : Pat<(v4f32 (bitconvert (v2i64 MQPR:$src))), (v4f32 (MVE_VREV64_32 MQPR:$src))>; 7525 def : Pat<(v4f32 (bitconvert (v8f16 MQPR:$src))), (v4f32 (MVE_VREV32_16 MQPR:$src))>; 7526 def : Pat<(v4f32 (bitconvert (v8i16 MQPR:$src))), (v4f32 (MVE_VREV32_16 MQPR:$src))>; 7527 def : Pat<(v4f32 (bitconvert (v16i8 MQPR:$src))), (v4f32 (MVE_VREV32_8 MQPR:$src))>; 7528 7529 def : Pat<(v4i32 (bitconvert (v2f64 MQPR:$src))), (v4i32 (MVE_VREV64_32 MQPR:$src))>; 7530 def : Pat<(v4i32 (bitconvert (v2i64 MQPR:$src))), (v4i32 (MVE_VREV64_32 MQPR:$src))>; 7531 def : Pat<(v4i32 (bitconvert (v8f16 MQPR:$src))), (v4i32 (MVE_VREV32_16 MQPR:$src))>; 7532 def : Pat<(v4i32 (bitconvert (v8i16 MQPR:$src))), (v4i32 (MVE_VREV32_16 MQPR:$src))>; 7533 def : Pat<(v4i32 (bitconvert (v16i8 MQPR:$src))), (v4i32 (MVE_VREV32_8 MQPR:$src))>; 7534 7535 def : Pat<(v8f16 (bitconvert (v2f64 MQPR:$src))), (v8f16 (MVE_VREV64_16 MQPR:$src))>; 7536 def : Pat<(v8f16 (bitconvert (v2i64 MQPR:$src))), (v8f16 (MVE_VREV64_16 MQPR:$src))>; 7537 def : Pat<(v8f16 (bitconvert (v4f32 MQPR:$src))), (v8f16 (MVE_VREV32_16 MQPR:$src))>; 7538 def : Pat<(v8f16 (bitconvert (v4i32 MQPR:$src))), (v8f16 (MVE_VREV32_16 MQPR:$src))>; 7539 def : Pat<(v8f16 (bitconvert (v16i8 MQPR:$src))), (v8f16 (MVE_VREV16_8 MQPR:$src))>; 7540 7541 def : Pat<(v8i16 (bitconvert (v2f64 MQPR:$src))), (v8i16 (MVE_VREV64_16 MQPR:$src))>; 7542 def : Pat<(v8i16 (bitconvert (v2i64 MQPR:$src))), (v8i16 (MVE_VREV64_16 MQPR:$src))>; 7543 def : Pat<(v8i16 (bitconvert (v4f32 MQPR:$src))), (v8i16 (MVE_VREV32_16 MQPR:$src))>; 7544 def : Pat<(v8i16 (bitconvert (v4i32 MQPR:$src))), (v8i16 (MVE_VREV32_16 MQPR:$src))>; 7545 def : Pat<(v8i16 (bitconvert (v16i8 MQPR:$src))), (v8i16 (MVE_VREV16_8 MQPR:$src))>; 7546 7547 def : Pat<(v16i8 (bitconvert (v2f64 MQPR:$src))), (v16i8 (MVE_VREV64_8 MQPR:$src))>; 7548 def : Pat<(v16i8 (bitconvert (v2i64 MQPR:$src))), (v16i8 (MVE_VREV64_8 MQPR:$src))>; 7549 def : Pat<(v16i8 (bitconvert (v4f32 MQPR:$src))), (v16i8 (MVE_VREV32_8 MQPR:$src))>; 7550 def : Pat<(v16i8 (bitconvert (v4i32 MQPR:$src))), (v16i8 (MVE_VREV32_8 MQPR:$src))>; 7551 def : Pat<(v16i8 (bitconvert (v8f16 MQPR:$src))), (v16i8 (MVE_VREV16_8 MQPR:$src))>; 7552 def : Pat<(v16i8 (bitconvert (v8i16 MQPR:$src))), (v16i8 (MVE_VREV16_8 MQPR:$src))>; 7553} 7554