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", "@earlyclobber $RdaDest,$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 let Predicates = [HasFullFP16] in { 1886 def : Pat<(ARMinsertelt (v8i16 MQPR:$src1), 1887 (ARMvgetlaneu (v8i16 MQPR:$src2), imm_even:$extlane), 1888 imm_odd:$inslane), 1889 (COPY_TO_REGCLASS (INSERT_SUBREG (v4f32 (COPY_TO_REGCLASS MQPR:$src1, MQPR)), 1890 (VINSH (EXTRACT_SUBREG MQPR:$src1, (SSubReg_f16_reg imm_odd:$inslane)), 1891 (EXTRACT_SUBREG MQPR:$src2, (SSubReg_f16_reg imm_even:$extlane))), 1892 (SSubReg_f16_reg imm_odd:$inslane)), MQPR)>; 1893 } 1894 1895 def : Pat<(v16i8 (scalar_to_vector GPR:$src)), 1896 (MVE_VMOV_to_lane_8 (v16i8 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>; 1897 def : Pat<(v8i16 (scalar_to_vector GPR:$src)), 1898 (MVE_VMOV_to_lane_16 (v8i16 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>; 1899 def : Pat<(v4i32 (scalar_to_vector GPR:$src)), 1900 (MVE_VMOV_to_lane_32 (v4i32 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>; 1901 1902 // Floating point patterns, still enabled under HasMVEInt 1903 def : Pat<(extractelt (v4f32 MQPR:$src), imm:$lane), 1904 (COPY_TO_REGCLASS (f32 (EXTRACT_SUBREG MQPR:$src, (SSubReg_f32_reg imm:$lane))), SPR)>; 1905 def : Pat<(insertelt (v4f32 MQPR:$src1), (f32 SPR:$src2), imm:$lane), 1906 (INSERT_SUBREG (v4f32 (COPY_TO_REGCLASS MQPR:$src1, MQPR)), SPR:$src2, (SSubReg_f32_reg imm:$lane))>; 1907 1908 def : Pat<(insertelt (v8f16 MQPR:$src1), (f16 HPR:$src2), imm_even:$lane), 1909 (MVE_VMOV_to_lane_16 MQPR:$src1, (COPY_TO_REGCLASS (f16 HPR:$src2), rGPR), imm:$lane)>; 1910 let Predicates = [HasFullFP16] in { 1911 def : Pat<(insertelt (v8f16 MQPR:$src1), (f16 HPR:$src2), imm_odd:$lane), 1912 (COPY_TO_REGCLASS (INSERT_SUBREG (v4f32 (COPY_TO_REGCLASS MQPR:$src1, MQPR)), 1913 (VINSH (EXTRACT_SUBREG MQPR:$src1, (SSubReg_f16_reg imm_odd:$lane)), 1914 (COPY_TO_REGCLASS HPR:$src2, SPR)), 1915 (SSubReg_f16_reg imm_odd:$lane)), MQPR)>; 1916 } 1917 def : Pat<(extractelt (v8f16 MQPR:$src), imm_even:$lane), 1918 (EXTRACT_SUBREG MQPR:$src, (SSubReg_f16_reg imm_even:$lane))>; 1919 let Predicates = [HasFullFP16] in { 1920 def : Pat<(extractelt (v8f16 MQPR:$src), imm_odd:$lane), 1921 (COPY_TO_REGCLASS 1922 (VMOVH (EXTRACT_SUBREG MQPR:$src, (SSubReg_f16_reg imm_odd:$lane))), 1923 HPR)>; 1924 } 1925 1926 def : Pat<(v2f64 (scalar_to_vector (f64 DPR:$src))), 1927 (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), DPR:$src, dsub_0)>; 1928 def : Pat<(v4f32 (scalar_to_vector SPR:$src)), 1929 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), SPR:$src, ssub_0)>; 1930 def : Pat<(v4f32 (scalar_to_vector GPR:$src)), 1931 (MVE_VMOV_to_lane_32 (v4f32 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>; 1932 def : Pat<(v8f16 (scalar_to_vector (f16 HPR:$src))), 1933 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), (f16 HPR:$src), ssub_0)>; 1934 def : Pat<(v8f16 (scalar_to_vector GPR:$src)), 1935 (MVE_VMOV_to_lane_16 (v8f16 (IMPLICIT_DEF)), rGPR:$src, (i32 0))>; 1936} 1937 1938// end of mve_bit instructions 1939 1940// start of MVE Integer instructions 1941 1942class MVE_int<string iname, string suffix, bits<2> size, list<dag> pattern=[]> 1943 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm), NoItinerary, 1944 iname, suffix, "$Qd, $Qn, $Qm", vpred_r, "", size, pattern> { 1945 bits<4> Qd; 1946 bits<4> Qn; 1947 bits<4> Qm; 1948 1949 let Inst{22} = Qd{3}; 1950 let Inst{21-20} = size; 1951 let Inst{19-17} = Qn{2-0}; 1952 let Inst{15-13} = Qd{2-0}; 1953 let Inst{7} = Qn{3}; 1954 let Inst{6} = 0b1; 1955 let Inst{5} = Qm{3}; 1956 let Inst{3-1} = Qm{2-0}; 1957} 1958 1959class MVE_VMULt1<string iname, string suffix, bits<2> size, 1960 list<dag> pattern=[]> 1961 : MVE_int<iname, suffix, size, pattern> { 1962 1963 let Inst{28} = 0b0; 1964 let Inst{25-23} = 0b110; 1965 let Inst{16} = 0b0; 1966 let Inst{12-8} = 0b01001; 1967 let Inst{4} = 0b1; 1968 let Inst{0} = 0b0; 1969 let validForTailPredication = 1; 1970} 1971 1972multiclass MVE_VMUL_m<MVEVectorVTInfo VTI> { 1973 def "" : MVE_VMULt1<"vmul", VTI.Suffix, VTI.Size>; 1974 1975 let Predicates = [HasMVEInt] in { 1976 defm : MVE_TwoOpPattern<VTI, mul, int_arm_mve_mul_predicated, (? ), 1977 !cast<Instruction>(NAME), ARMimmOneV>; 1978 } 1979} 1980 1981defm MVE_VMULi8 : MVE_VMUL_m<MVE_v16i8>; 1982defm MVE_VMULi16 : MVE_VMUL_m<MVE_v8i16>; 1983defm MVE_VMULi32 : MVE_VMUL_m<MVE_v4i32>; 1984 1985class MVE_VQxDMULH_Base<string iname, string suffix, bits<2> size, bit rounding, 1986 list<dag> pattern=[]> 1987 : MVE_int<iname, suffix, size, pattern> { 1988 1989 let Inst{28} = rounding; 1990 let Inst{25-23} = 0b110; 1991 let Inst{16} = 0b0; 1992 let Inst{12-8} = 0b01011; 1993 let Inst{4} = 0b0; 1994 let Inst{0} = 0b0; 1995 let validForTailPredication = 1; 1996} 1997 1998def MVEvqdmulh : SDNode<"ARMISD::VQDMULH", SDTIntBinOp>; 1999 2000multiclass MVE_VQxDMULH_m<string iname, MVEVectorVTInfo VTI, 2001 SDNode Op, Intrinsic unpred_int, Intrinsic pred_int, 2002 bit rounding> { 2003 def "" : MVE_VQxDMULH_Base<iname, VTI.Suffix, VTI.Size, rounding>; 2004 defvar Inst = !cast<Instruction>(NAME); 2005 2006 let Predicates = [HasMVEInt] in { 2007 defm : MVE_TwoOpPattern<VTI, Op, pred_int, (? ), Inst>; 2008 2009 // Extra unpredicated multiply intrinsic patterns 2010 def : Pat<(VTI.Vec (unpred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn))), 2011 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>; 2012 } 2013} 2014 2015multiclass MVE_VQxDMULH<string iname, MVEVectorVTInfo VTI, bit rounding> 2016 : MVE_VQxDMULH_m<iname, VTI, !if(rounding, null_frag, 2017 MVEvqdmulh), 2018 !if(rounding, int_arm_mve_vqrdmulh, 2019 int_arm_mve_vqdmulh), 2020 !if(rounding, int_arm_mve_qrdmulh_predicated, 2021 int_arm_mve_qdmulh_predicated), 2022 rounding>; 2023 2024defm MVE_VQDMULHi8 : MVE_VQxDMULH<"vqdmulh", MVE_v16s8, 0b0>; 2025defm MVE_VQDMULHi16 : MVE_VQxDMULH<"vqdmulh", MVE_v8s16, 0b0>; 2026defm MVE_VQDMULHi32 : MVE_VQxDMULH<"vqdmulh", MVE_v4s32, 0b0>; 2027 2028defm MVE_VQRDMULHi8 : MVE_VQxDMULH<"vqrdmulh", MVE_v16s8, 0b1>; 2029defm MVE_VQRDMULHi16 : MVE_VQxDMULH<"vqrdmulh", MVE_v8s16, 0b1>; 2030defm MVE_VQRDMULHi32 : MVE_VQxDMULH<"vqrdmulh", MVE_v4s32, 0b1>; 2031 2032class MVE_VADDSUB<string iname, string suffix, bits<2> size, bit subtract, 2033 list<dag> pattern=[]> 2034 : MVE_int<iname, suffix, size, pattern> { 2035 2036 let Inst{28} = subtract; 2037 let Inst{25-23} = 0b110; 2038 let Inst{16} = 0b0; 2039 let Inst{12-8} = 0b01000; 2040 let Inst{4} = 0b0; 2041 let Inst{0} = 0b0; 2042 let validForTailPredication = 1; 2043} 2044 2045multiclass MVE_VADDSUB_m<string iname, MVEVectorVTInfo VTI, bit subtract, 2046 SDNode Op, Intrinsic PredInt> { 2047 def "" : MVE_VADDSUB<iname, VTI.Suffix, VTI.Size, subtract>; 2048 defvar Inst = !cast<Instruction>(NAME); 2049 2050 let Predicates = [HasMVEInt] in { 2051 defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? ), !cast<Instruction>(NAME), ARMimmAllZerosV>; 2052 } 2053} 2054 2055multiclass MVE_VADD<MVEVectorVTInfo VTI> 2056 : MVE_VADDSUB_m<"vadd", VTI, 0b0, add, int_arm_mve_add_predicated>; 2057multiclass MVE_VSUB<MVEVectorVTInfo VTI> 2058 : MVE_VADDSUB_m<"vsub", VTI, 0b1, sub, int_arm_mve_sub_predicated>; 2059 2060defm MVE_VADDi8 : MVE_VADD<MVE_v16i8>; 2061defm MVE_VADDi16 : MVE_VADD<MVE_v8i16>; 2062defm MVE_VADDi32 : MVE_VADD<MVE_v4i32>; 2063 2064defm MVE_VSUBi8 : MVE_VSUB<MVE_v16i8>; 2065defm MVE_VSUBi16 : MVE_VSUB<MVE_v8i16>; 2066defm MVE_VSUBi32 : MVE_VSUB<MVE_v4i32>; 2067 2068class MVE_VQADDSUB<string iname, string suffix, bit U, bit subtract, 2069 bits<2> size> 2070 : MVE_int<iname, suffix, size, []> { 2071 2072 let Inst{28} = U; 2073 let Inst{25-23} = 0b110; 2074 let Inst{16} = 0b0; 2075 let Inst{12-10} = 0b000; 2076 let Inst{9} = subtract; 2077 let Inst{8} = 0b0; 2078 let Inst{4} = 0b1; 2079 let Inst{0} = 0b0; 2080 let validForTailPredication = 1; 2081} 2082 2083class MVE_VQADD_<string suffix, bit U, bits<2> size> 2084 : MVE_VQADDSUB<"vqadd", suffix, U, 0b0, size>; 2085class MVE_VQSUB_<string suffix, bit U, bits<2> size> 2086 : MVE_VQADDSUB<"vqsub", suffix, U, 0b1, size>; 2087 2088multiclass MVE_VQADD_m<MVEVectorVTInfo VTI, 2089 SDNode Op, Intrinsic PredInt> { 2090 def "" : MVE_VQADD_<VTI.Suffix, VTI.Unsigned, VTI.Size>; 2091 defvar Inst = !cast<Instruction>(NAME); 2092 2093 let Predicates = [HasMVEInt] in { 2094 defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? (i32 VTI.Unsigned)), 2095 !cast<Instruction>(NAME)>; 2096 } 2097} 2098 2099multiclass MVE_VQADD<MVEVectorVTInfo VTI, SDNode unpred_op> 2100 : MVE_VQADD_m<VTI, unpred_op, int_arm_mve_qadd_predicated>; 2101 2102defm MVE_VQADDs8 : MVE_VQADD<MVE_v16s8, saddsat>; 2103defm MVE_VQADDs16 : MVE_VQADD<MVE_v8s16, saddsat>; 2104defm MVE_VQADDs32 : MVE_VQADD<MVE_v4s32, saddsat>; 2105defm MVE_VQADDu8 : MVE_VQADD<MVE_v16u8, uaddsat>; 2106defm MVE_VQADDu16 : MVE_VQADD<MVE_v8u16, uaddsat>; 2107defm MVE_VQADDu32 : MVE_VQADD<MVE_v4u32, uaddsat>; 2108 2109multiclass MVE_VQSUB_m<MVEVectorVTInfo VTI, 2110 SDNode Op, Intrinsic PredInt> { 2111 def "" : MVE_VQSUB_<VTI.Suffix, VTI.Unsigned, VTI.Size>; 2112 defvar Inst = !cast<Instruction>(NAME); 2113 2114 let Predicates = [HasMVEInt] in { 2115 defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? (i32 VTI.Unsigned)), 2116 !cast<Instruction>(NAME)>; 2117 } 2118} 2119 2120multiclass MVE_VQSUB<MVEVectorVTInfo VTI, SDNode unpred_op> 2121 : MVE_VQSUB_m<VTI, unpred_op, int_arm_mve_qsub_predicated>; 2122 2123defm MVE_VQSUBs8 : MVE_VQSUB<MVE_v16s8, ssubsat>; 2124defm MVE_VQSUBs16 : MVE_VQSUB<MVE_v8s16, ssubsat>; 2125defm MVE_VQSUBs32 : MVE_VQSUB<MVE_v4s32, ssubsat>; 2126defm MVE_VQSUBu8 : MVE_VQSUB<MVE_v16u8, usubsat>; 2127defm MVE_VQSUBu16 : MVE_VQSUB<MVE_v8u16, usubsat>; 2128defm MVE_VQSUBu32 : MVE_VQSUB<MVE_v4u32, usubsat>; 2129 2130class MVE_VABD_int<string suffix, bit U, bits<2> size, 2131 list<dag> pattern=[]> 2132 : MVE_int<"vabd", suffix, size, pattern> { 2133 2134 let Inst{28} = U; 2135 let Inst{25-23} = 0b110; 2136 let Inst{16} = 0b0; 2137 let Inst{12-8} = 0b00111; 2138 let Inst{4} = 0b0; 2139 let Inst{0} = 0b0; 2140 let validForTailPredication = 1; 2141} 2142 2143multiclass MVE_VABD_m<MVEVectorVTInfo VTI, SDNode Op, 2144 Intrinsic unpred_int, Intrinsic PredInt> { 2145 def "" : MVE_VABD_int<VTI.Suffix, VTI.Unsigned, VTI.Size>; 2146 defvar Inst = !cast<Instruction>(NAME); 2147 2148 let Predicates = [HasMVEInt] in { 2149 defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? (i32 VTI.Unsigned)), 2150 !cast<Instruction>(NAME)>; 2151 2152 // Unpredicated absolute difference 2153 def : Pat<(VTI.Vec (unpred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 2154 (i32 VTI.Unsigned))), 2155 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>; 2156 } 2157} 2158 2159multiclass MVE_VABD<MVEVectorVTInfo VTI, SDNode Op> 2160 : MVE_VABD_m<VTI, Op, int_arm_mve_vabd, int_arm_mve_abd_predicated>; 2161 2162defm MVE_VABDs8 : MVE_VABD<MVE_v16s8, abds>; 2163defm MVE_VABDs16 : MVE_VABD<MVE_v8s16, abds>; 2164defm MVE_VABDs32 : MVE_VABD<MVE_v4s32, abds>; 2165defm MVE_VABDu8 : MVE_VABD<MVE_v16u8, abdu>; 2166defm MVE_VABDu16 : MVE_VABD<MVE_v8u16, abdu>; 2167defm MVE_VABDu32 : MVE_VABD<MVE_v4u32, abdu>; 2168 2169class MVE_VRHADD_Base<string suffix, bit U, bits<2> size, list<dag> pattern=[]> 2170 : MVE_int<"vrhadd", suffix, size, pattern> { 2171 2172 let Inst{28} = U; 2173 let Inst{25-23} = 0b110; 2174 let Inst{16} = 0b0; 2175 let Inst{12-8} = 0b00001; 2176 let Inst{4} = 0b0; 2177 let Inst{0} = 0b0; 2178 let validForTailPredication = 1; 2179} 2180 2181def addnuw : PatFrag<(ops node:$lhs, node:$rhs), 2182 (add node:$lhs, node:$rhs), [{ 2183 return N->getFlags().hasNoUnsignedWrap(); 2184}]>; 2185 2186def addnsw : PatFrag<(ops node:$lhs, node:$rhs), 2187 (add node:$lhs, node:$rhs), [{ 2188 return N->getFlags().hasNoSignedWrap(); 2189}]>; 2190 2191def subnuw : PatFrag<(ops node:$lhs, node:$rhs), 2192 (sub node:$lhs, node:$rhs), [{ 2193 return N->getFlags().hasNoUnsignedWrap(); 2194}]>; 2195 2196def subnsw : PatFrag<(ops node:$lhs, node:$rhs), 2197 (sub node:$lhs, node:$rhs), [{ 2198 return N->getFlags().hasNoSignedWrap(); 2199}]>; 2200 2201multiclass MVE_VRHADD_m<MVEVectorVTInfo VTI, SDNode Op, 2202 SDNode unpred_op, Intrinsic PredInt> { 2203 def "" : MVE_VRHADD_Base<VTI.Suffix, VTI.Unsigned, VTI.Size>; 2204 defvar Inst = !cast<Instruction>(NAME); 2205 defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? (i32 VTI.Unsigned)), !cast<Instruction>(NAME)>; 2206 2207 let Predicates = [HasMVEInt] in { 2208 // Unpredicated rounding add-with-divide-by-two intrinsic 2209 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 2210 (i32 VTI.Unsigned))), 2211 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>; 2212 } 2213} 2214 2215multiclass MVE_VRHADD<MVEVectorVTInfo VTI, SDNode rhadd> 2216 : MVE_VRHADD_m<VTI, rhadd, int_arm_mve_vrhadd, int_arm_mve_rhadd_predicated>; 2217 2218defm MVE_VRHADDs8 : MVE_VRHADD<MVE_v16s8, avgceils>; 2219defm MVE_VRHADDs16 : MVE_VRHADD<MVE_v8s16, avgceils>; 2220defm MVE_VRHADDs32 : MVE_VRHADD<MVE_v4s32, avgceils>; 2221defm MVE_VRHADDu8 : MVE_VRHADD<MVE_v16u8, avgceilu>; 2222defm MVE_VRHADDu16 : MVE_VRHADD<MVE_v8u16, avgceilu>; 2223defm MVE_VRHADDu32 : MVE_VRHADD<MVE_v4u32, avgceilu>; 2224 2225// Rounding Halving Add perform the arithemtic operation with an extra bit of 2226// precision, before performing the shift, to void clipping errors. We're not 2227// modelling that here with these patterns, but we're using no wrap forms of 2228// add to ensure that the extra bit of information is not needed for the 2229// arithmetic or the rounding. 2230let Predicates = [HasMVEInt] in { 2231 def : Pat<(v16i8 (ARMvshrsImm (addnsw (addnsw (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn)), 2232 (v16i8 (ARMvmovImm (i32 3585)))), 2233 (i32 1))), 2234 (MVE_VRHADDs8 MQPR:$Qm, MQPR:$Qn)>; 2235 def : Pat<(v8i16 (ARMvshrsImm (addnsw (addnsw (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn)), 2236 (v8i16 (ARMvmovImm (i32 2049)))), 2237 (i32 1))), 2238 (MVE_VRHADDs16 MQPR:$Qm, MQPR:$Qn)>; 2239 def : Pat<(v4i32 (ARMvshrsImm (addnsw (addnsw (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn)), 2240 (v4i32 (ARMvmovImm (i32 1)))), 2241 (i32 1))), 2242 (MVE_VRHADDs32 MQPR:$Qm, MQPR:$Qn)>; 2243 def : Pat<(v16i8 (ARMvshruImm (addnuw (addnuw (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn)), 2244 (v16i8 (ARMvmovImm (i32 3585)))), 2245 (i32 1))), 2246 (MVE_VRHADDu8 MQPR:$Qm, MQPR:$Qn)>; 2247 def : Pat<(v8i16 (ARMvshruImm (addnuw (addnuw (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn)), 2248 (v8i16 (ARMvmovImm (i32 2049)))), 2249 (i32 1))), 2250 (MVE_VRHADDu16 MQPR:$Qm, MQPR:$Qn)>; 2251 def : Pat<(v4i32 (ARMvshruImm (addnuw (addnuw (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn)), 2252 (v4i32 (ARMvmovImm (i32 1)))), 2253 (i32 1))), 2254 (MVE_VRHADDu32 MQPR:$Qm, MQPR:$Qn)>; 2255 2256 def : Pat<(v16i8 (ARMvshrsImm (addnsw (addnsw (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn)), 2257 (v16i8 (ARMvdup (i32 1)))), 2258 (i32 1))), 2259 (MVE_VRHADDs8 MQPR:$Qm, MQPR:$Qn)>; 2260 def : Pat<(v8i16 (ARMvshrsImm (addnsw (addnsw (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn)), 2261 (v8i16 (ARMvdup (i32 1)))), 2262 (i32 1))), 2263 (MVE_VRHADDs16 MQPR:$Qm, MQPR:$Qn)>; 2264 def : Pat<(v4i32 (ARMvshrsImm (addnsw (addnsw (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn)), 2265 (v4i32 (ARMvdup (i32 1)))), 2266 (i32 1))), 2267 (MVE_VRHADDs32 MQPR:$Qm, MQPR:$Qn)>; 2268 def : Pat<(v16i8 (ARMvshruImm (addnuw (addnuw (v16i8 MQPR:$Qm), (v16i8 MQPR:$Qn)), 2269 (v16i8 (ARMvdup (i32 1)))), 2270 (i32 1))), 2271 (MVE_VRHADDu8 MQPR:$Qm, MQPR:$Qn)>; 2272 def : Pat<(v8i16 (ARMvshruImm (addnuw (addnuw (v8i16 MQPR:$Qm), (v8i16 MQPR:$Qn)), 2273 (v8i16 (ARMvdup (i32 1)))), 2274 (i32 1))), 2275 (MVE_VRHADDu16 MQPR:$Qm, MQPR:$Qn)>; 2276 def : Pat<(v4i32 (ARMvshruImm (addnuw (addnuw (v4i32 MQPR:$Qm), (v4i32 MQPR:$Qn)), 2277 (v4i32 (ARMvdup (i32 1)))), 2278 (i32 1))), 2279 (MVE_VRHADDu32 MQPR:$Qm, MQPR:$Qn)>; 2280} 2281 2282 2283class MVE_VHADDSUB<string iname, string suffix, bit U, bit subtract, 2284 bits<2> size, list<dag> pattern=[]> 2285 : MVE_int<iname, suffix, size, pattern> { 2286 2287 let Inst{28} = U; 2288 let Inst{25-23} = 0b110; 2289 let Inst{16} = 0b0; 2290 let Inst{12-10} = 0b000; 2291 let Inst{9} = subtract; 2292 let Inst{8} = 0b0; 2293 let Inst{4} = 0b0; 2294 let Inst{0} = 0b0; 2295 let validForTailPredication = 1; 2296} 2297 2298class MVE_VHADD_<string suffix, bit U, bits<2> size, 2299 list<dag> pattern=[]> 2300 : MVE_VHADDSUB<"vhadd", suffix, U, 0b0, size, pattern>; 2301class MVE_VHSUB_<string suffix, bit U, bits<2> size, 2302 list<dag> pattern=[]> 2303 : MVE_VHADDSUB<"vhsub", suffix, U, 0b1, size, pattern>; 2304 2305multiclass MVE_VHADD_m<MVEVectorVTInfo VTI, SDNode Op, 2306 SDNode unpred_op, Intrinsic PredInt, PatFrag add_op, 2307 SDNode shift_op> { 2308 def "" : MVE_VHADD_<VTI.Suffix, VTI.Unsigned, VTI.Size>; 2309 defvar Inst = !cast<Instruction>(NAME); 2310 defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? (i32 VTI.Unsigned)), !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} 2321 2322multiclass MVE_VHADD<MVEVectorVTInfo VTI, SDNode Op, PatFrag add_op, SDNode shift_op> 2323 : MVE_VHADD_m<VTI, Op, int_arm_mve_vhadd, int_arm_mve_hadd_predicated, add_op, 2324 shift_op>; 2325 2326// Halving add/sub perform the arithemtic operation with an extra bit of 2327// precision, before performing the shift, to void clipping errors. We're not 2328// modelling that here with these patterns, but we're using no wrap forms of 2329// add/sub to ensure that the extra bit of information is not needed. 2330defm MVE_VHADDs8 : MVE_VHADD<MVE_v16s8, avgfloors, addnsw, ARMvshrsImm>; 2331defm MVE_VHADDs16 : MVE_VHADD<MVE_v8s16, avgfloors, addnsw, ARMvshrsImm>; 2332defm MVE_VHADDs32 : MVE_VHADD<MVE_v4s32, avgfloors, addnsw, ARMvshrsImm>; 2333defm MVE_VHADDu8 : MVE_VHADD<MVE_v16u8, avgflooru, addnuw, ARMvshruImm>; 2334defm MVE_VHADDu16 : MVE_VHADD<MVE_v8u16, avgflooru, addnuw, ARMvshruImm>; 2335defm MVE_VHADDu32 : MVE_VHADD<MVE_v4u32, avgflooru, addnuw, ARMvshruImm>; 2336 2337multiclass MVE_VHSUB_m<MVEVectorVTInfo VTI, 2338 SDNode unpred_op, Intrinsic pred_int, PatFrag sub_op, 2339 SDNode shift_op> { 2340 def "" : MVE_VHSUB_<VTI.Suffix, VTI.Unsigned, VTI.Size>; 2341 defvar Inst = !cast<Instruction>(NAME); 2342 2343 let Predicates = [HasMVEInt] in { 2344 // Unpredicated subtract-and-divide-by-two 2345 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 2346 (i32 VTI.Unsigned))), 2347 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>; 2348 2349 def : Pat<(VTI.Vec (shift_op (sub_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)), (i32 1))), 2350 (Inst MQPR:$Qm, MQPR:$Qn)>; 2351 2352 2353 // Predicated subtract-and-divide-by-two 2354 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 2355 (i32 VTI.Unsigned), (VTI.Pred VCCR:$mask), 2356 (VTI.Vec MQPR:$inactive))), 2357 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 2358 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 2359 (VTI.Vec MQPR:$inactive)))>; 2360 } 2361} 2362 2363multiclass MVE_VHSUB<MVEVectorVTInfo VTI, PatFrag sub_op, SDNode shift_op> 2364 : MVE_VHSUB_m<VTI, int_arm_mve_vhsub, int_arm_mve_hsub_predicated, sub_op, 2365 shift_op>; 2366 2367defm MVE_VHSUBs8 : MVE_VHSUB<MVE_v16s8, subnsw, ARMvshrsImm>; 2368defm MVE_VHSUBs16 : MVE_VHSUB<MVE_v8s16, subnsw, ARMvshrsImm>; 2369defm MVE_VHSUBs32 : MVE_VHSUB<MVE_v4s32, subnsw, ARMvshrsImm>; 2370defm MVE_VHSUBu8 : MVE_VHSUB<MVE_v16u8, subnuw, ARMvshruImm>; 2371defm MVE_VHSUBu16 : MVE_VHSUB<MVE_v8u16, subnuw, ARMvshruImm>; 2372defm MVE_VHSUBu32 : MVE_VHSUB<MVE_v4u32, subnuw, ARMvshruImm>; 2373 2374class MVE_VDUP<string suffix, bit B, bit E, bits<2> vecsize, list<dag> pattern=[]> 2375 : MVE_p<(outs MQPR:$Qd), (ins rGPR:$Rt), NoItinerary, 2376 "vdup", suffix, "$Qd, $Rt", vpred_r, "", vecsize, pattern> { 2377 bits<4> Qd; 2378 bits<4> Rt; 2379 2380 let Inst{28} = 0b0; 2381 let Inst{25-23} = 0b101; 2382 let Inst{22} = B; 2383 let Inst{21-20} = 0b10; 2384 let Inst{19-17} = Qd{2-0}; 2385 let Inst{16} = 0b0; 2386 let Inst{15-12} = Rt; 2387 let Inst{11-8} = 0b1011; 2388 let Inst{7} = Qd{3}; 2389 let Inst{6} = 0b0; 2390 let Inst{5} = E; 2391 let Inst{4-0} = 0b10000; 2392 let validForTailPredication = 1; 2393} 2394 2395def MVE_VDUP32 : MVE_VDUP<"32", 0b0, 0b0, 0b10>; 2396def MVE_VDUP16 : MVE_VDUP<"16", 0b0, 0b1, 0b01>; 2397def MVE_VDUP8 : MVE_VDUP<"8", 0b1, 0b0, 0b00>; 2398 2399let Predicates = [HasMVEInt] in { 2400 def : Pat<(v16i8 (ARMvdup (i32 rGPR:$elem))), 2401 (MVE_VDUP8 rGPR:$elem)>; 2402 def : Pat<(v8i16 (ARMvdup (i32 rGPR:$elem))), 2403 (MVE_VDUP16 rGPR:$elem)>; 2404 def : Pat<(v4i32 (ARMvdup (i32 rGPR:$elem))), 2405 (MVE_VDUP32 rGPR:$elem)>; 2406 2407 def : Pat<(v8f16 (ARMvdup (i32 rGPR:$elem))), 2408 (MVE_VDUP16 rGPR:$elem)>; 2409 def : Pat<(v4f32 (ARMvdup (i32 rGPR:$elem))), 2410 (MVE_VDUP32 rGPR:$elem)>; 2411 2412 // Match a vselect with an ARMvdup as a predicated MVE_VDUP 2413 def : Pat<(v16i8 (vselect (v16i1 VCCR:$pred), 2414 (v16i8 (ARMvdup (i32 rGPR:$elem))), 2415 (v16i8 MQPR:$inactive))), 2416 (MVE_VDUP8 rGPR:$elem, ARMVCCThen, (v16i1 VCCR:$pred), zero_reg, 2417 (v16i8 MQPR:$inactive))>; 2418 def : Pat<(v8i16 (vselect (v8i1 VCCR:$pred), 2419 (v8i16 (ARMvdup (i32 rGPR:$elem))), 2420 (v8i16 MQPR:$inactive))), 2421 (MVE_VDUP16 rGPR:$elem, ARMVCCThen, (v8i1 VCCR:$pred), zero_reg, 2422 (v8i16 MQPR:$inactive))>; 2423 def : Pat<(v4i32 (vselect (v4i1 VCCR:$pred), 2424 (v4i32 (ARMvdup (i32 rGPR:$elem))), 2425 (v4i32 MQPR:$inactive))), 2426 (MVE_VDUP32 rGPR:$elem, ARMVCCThen, (v4i1 VCCR:$pred), zero_reg, 2427 (v4i32 MQPR:$inactive))>; 2428 def : Pat<(v4f32 (vselect (v4i1 VCCR:$pred), 2429 (v4f32 (ARMvdup (i32 rGPR:$elem))), 2430 (v4f32 MQPR:$inactive))), 2431 (MVE_VDUP32 rGPR:$elem, ARMVCCThen, (v4i1 VCCR:$pred), zero_reg, 2432 (v4f32 MQPR:$inactive))>; 2433 def : Pat<(v8f16 (vselect (v8i1 VCCR:$pred), 2434 (v8f16 (ARMvdup (i32 rGPR:$elem))), 2435 (v8f16 MQPR:$inactive))), 2436 (MVE_VDUP16 rGPR:$elem, ARMVCCThen, (v8i1 VCCR:$pred), zero_reg, 2437 (v8f16 MQPR:$inactive))>; 2438} 2439 2440 2441class MVEIntSingleSrc<string iname, string suffix, bits<2> size, 2442 list<dag> pattern=[]> 2443 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qm), NoItinerary, 2444 iname, suffix, "$Qd, $Qm", vpred_r, "", size, pattern> { 2445 bits<4> Qd; 2446 bits<4> Qm; 2447 2448 let Inst{22} = Qd{3}; 2449 let Inst{19-18} = size{1-0}; 2450 let Inst{15-13} = Qd{2-0}; 2451 let Inst{5} = Qm{3}; 2452 let Inst{3-1} = Qm{2-0}; 2453} 2454 2455class MVE_VCLSCLZ<string iname, string suffix, bits<2> size, 2456 bit count_zeroes, list<dag> pattern=[]> 2457 : MVEIntSingleSrc<iname, suffix, size, pattern> { 2458 2459 let Inst{28} = 0b1; 2460 let Inst{25-23} = 0b111; 2461 let Inst{21-20} = 0b11; 2462 let Inst{17-16} = 0b00; 2463 let Inst{12-8} = 0b00100; 2464 let Inst{7} = count_zeroes; 2465 let Inst{6} = 0b1; 2466 let Inst{4} = 0b0; 2467 let Inst{0} = 0b0; 2468 let validForTailPredication = 1; 2469} 2470 2471multiclass MVE_VCLSCLZ_p<string opname, bit opcode, MVEVectorVTInfo VTI, 2472 SDPatternOperator unpred_op> { 2473 def "": MVE_VCLSCLZ<"v"#opname, VTI.Suffix, VTI.Size, opcode>; 2474 2475 defvar Inst = !cast<Instruction>(NAME); 2476 defvar pred_int = !cast<Intrinsic>("int_arm_mve_"#opname#"_predicated"); 2477 2478 let Predicates = [HasMVEInt] in { 2479 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$val))), 2480 (VTI.Vec (Inst (VTI.Vec MQPR:$val)))>; 2481 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$val), (VTI.Pred VCCR:$pred), 2482 (VTI.Vec MQPR:$inactive))), 2483 (VTI.Vec (Inst (VTI.Vec MQPR:$val), ARMVCCThen, 2484 (VTI.Pred VCCR:$pred), zero_reg, (VTI.Vec MQPR:$inactive)))>; 2485 } 2486} 2487 2488defm MVE_VCLSs8 : MVE_VCLSCLZ_p<"cls", 0, MVE_v16s8, int_arm_mve_vcls>; 2489defm MVE_VCLSs16 : MVE_VCLSCLZ_p<"cls", 0, MVE_v8s16, int_arm_mve_vcls>; 2490defm MVE_VCLSs32 : MVE_VCLSCLZ_p<"cls", 0, MVE_v4s32, int_arm_mve_vcls>; 2491 2492defm MVE_VCLZs8 : MVE_VCLSCLZ_p<"clz", 1, MVE_v16i8, ctlz>; 2493defm MVE_VCLZs16 : MVE_VCLSCLZ_p<"clz", 1, MVE_v8i16, ctlz>; 2494defm MVE_VCLZs32 : MVE_VCLSCLZ_p<"clz", 1, MVE_v4i32, ctlz>; 2495 2496class MVE_VABSNEG_int<string iname, string suffix, bits<2> size, bit negate, 2497 bit saturate, list<dag> pattern=[]> 2498 : MVEIntSingleSrc<iname, suffix, size, pattern> { 2499 2500 let Inst{28} = 0b1; 2501 let Inst{25-23} = 0b111; 2502 let Inst{21-20} = 0b11; 2503 let Inst{17} = 0b0; 2504 let Inst{16} = !eq(saturate, 0); 2505 let Inst{12-11} = 0b00; 2506 let Inst{10} = saturate; 2507 let Inst{9-8} = 0b11; 2508 let Inst{7} = negate; 2509 let Inst{6} = 0b1; 2510 let Inst{4} = 0b0; 2511 let Inst{0} = 0b0; 2512 let validForTailPredication = 1; 2513} 2514 2515multiclass MVE_VABSNEG_int_m<string iname, bit negate, bit saturate, 2516 SDPatternOperator unpred_op, Intrinsic pred_int, 2517 MVEVectorVTInfo VTI> { 2518 def "" : MVE_VABSNEG_int<iname, VTI.Suffix, VTI.Size, negate, saturate>; 2519 defvar Inst = !cast<Instruction>(NAME); 2520 2521 let Predicates = [HasMVEInt] in { 2522 // VQABS and VQNEG have more difficult isel patterns defined elsewhere 2523 if !not(saturate) then { 2524 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$v))), 2525 (VTI.Vec (Inst $v))>; 2526 } 2527 2528 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$v), (VTI.Pred VCCR:$mask), 2529 (VTI.Vec MQPR:$inactive))), 2530 (VTI.Vec (Inst $v, ARMVCCThen, $mask, zero_reg, $inactive))>; 2531 } 2532} 2533 2534foreach VTI = [ MVE_v16s8, MVE_v8s16, MVE_v4s32 ] in { 2535 defm "MVE_VABS" # VTI.Suffix : MVE_VABSNEG_int_m< 2536 "vabs", 0, 0, abs, int_arm_mve_abs_predicated, VTI>; 2537 defm "MVE_VQABS" # VTI.Suffix : MVE_VABSNEG_int_m< 2538 "vqabs", 0, 1, ?, int_arm_mve_qabs_predicated, VTI>; 2539 defm "MVE_VNEG" # VTI.Suffix : MVE_VABSNEG_int_m< 2540 "vneg", 1, 0, vnegq, int_arm_mve_neg_predicated, VTI>; 2541 defm "MVE_VQNEG" # VTI.Suffix : MVE_VABSNEG_int_m< 2542 "vqneg", 1, 1, ?, int_arm_mve_qneg_predicated, VTI>; 2543} 2544 2545// int_min/int_max: vector containing INT_MIN/INT_MAX VTI.Size times 2546// zero_vec: v4i32-initialized zero vector, potentially wrapped in a bitconvert 2547multiclass vqabsneg_pattern<MVEVectorVTInfo VTI, dag int_min, dag int_max, 2548 dag zero_vec, MVE_VABSNEG_int vqabs_instruction, 2549 MVE_VABSNEG_int vqneg_instruction> { 2550 let Predicates = [HasMVEInt] in { 2551 // The below tree can be replaced by a vqabs instruction, as it represents 2552 // the following vectorized expression (r being the value in $reg): 2553 // r > 0 ? r : (r == INT_MIN ? INT_MAX : -r) 2554 def : Pat<(VTI.Vec (vselect 2555 (VTI.Pred (ARMvcmpz (VTI.Vec MQPR:$reg), ARMCCgt)), 2556 (VTI.Vec MQPR:$reg), 2557 (VTI.Vec (vselect 2558 (VTI.Pred (ARMvcmp (VTI.Vec MQPR:$reg), int_min, ARMCCeq)), 2559 int_max, 2560 (sub (VTI.Vec zero_vec), (VTI.Vec MQPR:$reg)))))), 2561 (VTI.Vec (vqabs_instruction (VTI.Vec MQPR:$reg)))>; 2562 // Similarly, this tree represents vqneg, i.e. the following vectorized expression: 2563 // r == INT_MIN ? INT_MAX : -r 2564 def : Pat<(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 (vqneg_instruction (VTI.Vec MQPR:$reg)))>; 2569 } 2570} 2571 2572defm MVE_VQABSNEG_Ps8 : vqabsneg_pattern<MVE_v16i8, 2573 (v16i8 (ARMvmovImm (i32 3712))), 2574 (v16i8 (ARMvmovImm (i32 3711))), 2575 (bitconvert (v4i32 (ARMvmovImm (i32 0)))), 2576 MVE_VQABSs8, MVE_VQNEGs8>; 2577defm MVE_VQABSNEG_Ps16 : vqabsneg_pattern<MVE_v8i16, 2578 (v8i16 (ARMvmovImm (i32 2688))), 2579 (v8i16 (ARMvmvnImm (i32 2688))), 2580 (bitconvert (v4i32 (ARMvmovImm (i32 0)))), 2581 MVE_VQABSs16, MVE_VQNEGs16>; 2582defm MVE_VQABSNEG_Ps32 : vqabsneg_pattern<MVE_v4i32, 2583 (v4i32 (ARMvmovImm (i32 1664))), 2584 (v4i32 (ARMvmvnImm (i32 1664))), 2585 (ARMvmovImm (i32 0)), 2586 MVE_VQABSs32, MVE_VQNEGs32>; 2587 2588class MVE_mod_imm<string iname, string suffix, bits<4> cmode, bit op, 2589 dag iops, bits<2> vecsize, list<dag> pattern=[]> 2590 : MVE_p<(outs MQPR:$Qd), iops, NoItinerary, iname, suffix, "$Qd, $imm", 2591 vpred_r, "", vecsize, pattern> { 2592 bits<13> imm; 2593 bits<4> Qd; 2594 2595 let Inst{28} = imm{7}; 2596 let Inst{25-23} = 0b111; 2597 let Inst{22} = Qd{3}; 2598 let Inst{21-19} = 0b000; 2599 let Inst{18-16} = imm{6-4}; 2600 let Inst{15-13} = Qd{2-0}; 2601 let Inst{12} = 0b0; 2602 let Inst{11-8} = cmode{3-0}; 2603 let Inst{7-6} = 0b01; 2604 let Inst{5} = op; 2605 let Inst{4} = 0b1; 2606 let Inst{3-0} = imm{3-0}; 2607 2608 let DecoderMethod = "DecodeMVEModImmInstruction"; 2609 let validForTailPredication = 1; 2610} 2611 2612let isReMaterializable = 1 in { 2613let isAsCheapAsAMove = 1 in { 2614def MVE_VMOVimmi8 : MVE_mod_imm<"vmov", "i8", {1,1,1,0}, 0b0, (ins nImmSplatI8:$imm), 0b00>; 2615def MVE_VMOVimmi16 : MVE_mod_imm<"vmov", "i16", {1,0,?,0}, 0b0, (ins nImmSplatI16:$imm), 0b01> { 2616 let Inst{9} = imm{9}; 2617} 2618def MVE_VMOVimmi32 : MVE_mod_imm<"vmov", "i32", {?,?,?,?}, 0b0, (ins nImmVMOVI32:$imm), 0b10> { 2619 let Inst{11-8} = imm{11-8}; 2620} 2621def MVE_VMOVimmi64 : MVE_mod_imm<"vmov", "i64", {1,1,1,0}, 0b1, (ins nImmSplatI64:$imm), 0b11>; 2622def MVE_VMOVimmf32 : MVE_mod_imm<"vmov", "f32", {1,1,1,1}, 0b0, (ins nImmVMOVF32:$imm), 0b10>; 2623} // let isAsCheapAsAMove = 1 2624 2625def MVE_VMVNimmi16 : MVE_mod_imm<"vmvn", "i16", {1,0,?,0}, 0b1, (ins nImmSplatI16:$imm), 0b01> { 2626 let Inst{9} = imm{9}; 2627} 2628def MVE_VMVNimmi32 : MVE_mod_imm<"vmvn", "i32", {?,?,?,?}, 0b1, (ins nImmVMOVI32:$imm), 0b10> { 2629 let Inst{11-8} = imm{11-8}; 2630} 2631} // let isReMaterializable = 1 2632 2633let Predicates = [HasMVEInt] in { 2634 def : Pat<(v16i8 (ARMvmovImm timm:$simm)), 2635 (v16i8 (MVE_VMOVimmi8 nImmSplatI8:$simm))>; 2636 def : Pat<(v8i16 (ARMvmovImm timm:$simm)), 2637 (v8i16 (MVE_VMOVimmi16 nImmSplatI16:$simm))>; 2638 def : Pat<(v4i32 (ARMvmovImm timm:$simm)), 2639 (v4i32 (MVE_VMOVimmi32 nImmVMOVI32:$simm))>; 2640 def : Pat<(v2i64 (ARMvmovImm timm:$simm)), 2641 (v2i64 (MVE_VMOVimmi64 nImmSplatI64:$simm))>; 2642 2643 def : Pat<(v8i16 (ARMvmvnImm timm:$simm)), 2644 (v8i16 (MVE_VMVNimmi16 nImmSplatI16:$simm))>; 2645 def : Pat<(v4i32 (ARMvmvnImm timm:$simm)), 2646 (v4i32 (MVE_VMVNimmi32 nImmVMOVI32:$simm))>; 2647 2648 def : Pat<(v4f32 (ARMvmovFPImm timm:$simm)), 2649 (v4f32 (MVE_VMOVimmf32 nImmVMOVF32:$simm))>; 2650 2651 def : Pat<(v8i16 (vselect (v8i1 VCCR:$pred), (ARMvmvnImm timm:$simm), 2652 MQPR:$inactive)), 2653 (v8i16 (MVE_VMVNimmi16 nImmSplatI16:$simm, 2654 ARMVCCThen, VCCR:$pred, zero_reg, MQPR:$inactive))>; 2655 def : Pat<(v4i32 (vselect (v4i1 VCCR:$pred), (ARMvmvnImm timm:$simm), 2656 MQPR:$inactive)), 2657 (v4i32 (MVE_VMVNimmi32 nImmSplatI32:$simm, 2658 ARMVCCThen, VCCR:$pred, zero_reg, MQPR:$inactive))>; 2659} 2660 2661class MVE_VMINMAXA<string iname, string suffix, bits<2> size, 2662 bit bit_12, list<dag> pattern=[]> 2663 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qd_src, MQPR:$Qm), 2664 NoItinerary, iname, suffix, "$Qd, $Qm", vpred_n, "$Qd = $Qd_src", 2665 size, pattern> { 2666 bits<4> Qd; 2667 bits<4> Qm; 2668 2669 let Inst{28} = 0b0; 2670 let Inst{25-23} = 0b100; 2671 let Inst{22} = Qd{3}; 2672 let Inst{21-20} = 0b11; 2673 let Inst{19-18} = size; 2674 let Inst{17-16} = 0b11; 2675 let Inst{15-13} = Qd{2-0}; 2676 let Inst{12} = bit_12; 2677 let Inst{11-6} = 0b111010; 2678 let Inst{5} = Qm{3}; 2679 let Inst{4} = 0b0; 2680 let Inst{3-1} = Qm{2-0}; 2681 let Inst{0} = 0b1; 2682 let validForTailPredication = 1; 2683} 2684 2685multiclass MVE_VMINMAXA_m<string iname, MVEVectorVTInfo VTI, 2686 SDNode unpred_op, Intrinsic pred_int, bit bit_12> { 2687 def "" : MVE_VMINMAXA<iname, VTI.Suffix, VTI.Size, bit_12>; 2688 defvar Inst = !cast<Instruction>(NAME); 2689 2690 let Predicates = [HasMVEInt] in { 2691 // Unpredicated v(min|max)a 2692 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qd), (abs (VTI.Vec MQPR:$Qm)))), 2693 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm)))>; 2694 2695 // Predicated v(min|max)a 2696 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm), 2697 (VTI.Pred VCCR:$mask))), 2698 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm), 2699 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>; 2700 } 2701} 2702 2703multiclass MVE_VMINA<MVEVectorVTInfo VTI> 2704 : MVE_VMINMAXA_m<"vmina", VTI, umin, int_arm_mve_vmina_predicated, 0b1>; 2705 2706defm MVE_VMINAs8 : MVE_VMINA<MVE_v16s8>; 2707defm MVE_VMINAs16 : MVE_VMINA<MVE_v8s16>; 2708defm MVE_VMINAs32 : MVE_VMINA<MVE_v4s32>; 2709 2710multiclass MVE_VMAXA<MVEVectorVTInfo VTI> 2711 : MVE_VMINMAXA_m<"vmaxa", VTI, umax, int_arm_mve_vmaxa_predicated, 0b0>; 2712 2713defm MVE_VMAXAs8 : MVE_VMAXA<MVE_v16s8>; 2714defm MVE_VMAXAs16 : MVE_VMAXA<MVE_v8s16>; 2715defm MVE_VMAXAs32 : MVE_VMAXA<MVE_v4s32>; 2716 2717// end of MVE Integer instructions 2718 2719// start of mve_imm_shift instructions 2720 2721def MVE_VSHLC : MVE_p<(outs rGPR:$RdmDest, MQPR:$Qd), 2722 (ins MQPR:$QdSrc, rGPR:$RdmSrc, long_shift:$imm), 2723 NoItinerary, "vshlc", "", "$QdSrc, $RdmSrc, $imm", 2724 vpred_n, "$RdmDest = $RdmSrc,$Qd = $QdSrc", 0b10> { 2725 bits<5> imm; 2726 bits<4> Qd; 2727 bits<4> RdmDest; 2728 2729 let Inst{28} = 0b0; 2730 let Inst{25-23} = 0b101; 2731 let Inst{22} = Qd{3}; 2732 let Inst{21} = 0b1; 2733 let Inst{20-16} = imm{4-0}; 2734 let Inst{15-13} = Qd{2-0}; 2735 let Inst{12-4} = 0b011111100; 2736 let Inst{3-0} = RdmDest{3-0}; 2737} 2738 2739class MVE_shift_imm<dag oops, dag iops, string iname, string suffix, 2740 string ops, vpred_ops vpred, string cstr, 2741 bits<2> vecsize, list<dag> pattern=[]> 2742 : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, vecsize, pattern> { 2743 bits<4> Qd; 2744 bits<4> Qm; 2745 2746 let Inst{22} = Qd{3}; 2747 let Inst{15-13} = Qd{2-0}; 2748 let Inst{5} = Qm{3}; 2749 let Inst{3-1} = Qm{2-0}; 2750} 2751 2752class MVE_VMOVL<string iname, string suffix, bits<2> sz, bit U, bit top, 2753 list<dag> pattern=[]> 2754 : MVE_shift_imm<(outs MQPR:$Qd), (ins MQPR:$Qm), 2755 iname, suffix, "$Qd, $Qm", vpred_r, "", 2756 sz, pattern> { 2757 let Inst{28} = U; 2758 let Inst{25-23} = 0b101; 2759 let Inst{21} = 0b1; 2760 let Inst{20-19} = sz{1-0}; 2761 let Inst{18-16} = 0b000; 2762 let Inst{12} = top; 2763 let Inst{11-6} = 0b111101; 2764 let Inst{4} = 0b0; 2765 let Inst{0} = 0b0; 2766 let doubleWidthResult = 1; 2767} 2768 2769multiclass MVE_VMOVL_m<bit top, string chr, MVEVectorVTInfo OutVTI, 2770 MVEVectorVTInfo InVTI> { 2771 def "": MVE_VMOVL<"vmovl" # chr, InVTI.Suffix, OutVTI.Size, 2772 InVTI.Unsigned, top>; 2773 defvar Inst = !cast<Instruction>(NAME); 2774 2775 def : Pat<(OutVTI.Vec (int_arm_mve_vmovl_predicated (InVTI.Vec MQPR:$src), 2776 (i32 InVTI.Unsigned), (i32 top), 2777 (OutVTI.Pred VCCR:$pred), 2778 (OutVTI.Vec MQPR:$inactive))), 2779 (OutVTI.Vec (Inst (InVTI.Vec MQPR:$src), ARMVCCThen, 2780 (OutVTI.Pred VCCR:$pred), zero_reg, 2781 (OutVTI.Vec MQPR:$inactive)))>; 2782} 2783 2784defm MVE_VMOVLs8bh : MVE_VMOVL_m<0, "b", MVE_v8s16, MVE_v16s8>; 2785defm MVE_VMOVLs8th : MVE_VMOVL_m<1, "t", MVE_v8s16, MVE_v16s8>; 2786defm MVE_VMOVLu8bh : MVE_VMOVL_m<0, "b", MVE_v8u16, MVE_v16u8>; 2787defm MVE_VMOVLu8th : MVE_VMOVL_m<1, "t", MVE_v8u16, MVE_v16u8>; 2788defm MVE_VMOVLs16bh : MVE_VMOVL_m<0, "b", MVE_v4s32, MVE_v8s16>; 2789defm MVE_VMOVLs16th : MVE_VMOVL_m<1, "t", MVE_v4s32, MVE_v8s16>; 2790defm MVE_VMOVLu16bh : MVE_VMOVL_m<0, "b", MVE_v4s32, MVE_v8u16>; 2791defm MVE_VMOVLu16th : MVE_VMOVL_m<1, "t", MVE_v4s32, MVE_v8u16>; 2792 2793let Predicates = [HasMVEInt] in { 2794 def : Pat<(sext_inreg (v4i32 MQPR:$src), v4i16), 2795 (MVE_VMOVLs16bh MQPR:$src)>; 2796 def : Pat<(sext_inreg (v8i16 MQPR:$src), v8i8), 2797 (MVE_VMOVLs8bh MQPR:$src)>; 2798 def : Pat<(sext_inreg (v4i32 MQPR:$src), v4i8), 2799 (MVE_VMOVLs16bh (MVE_VMOVLs8bh MQPR:$src))>; 2800 2801 def : Pat<(sext_inreg (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src)))), v8i8), 2802 (MVE_VMOVLs8th MQPR:$src)>; 2803 def : Pat<(sext_inreg (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src)))), v4i16), 2804 (MVE_VMOVLs16th MQPR:$src)>; 2805 2806 // zext_inreg 8 -> 16 2807 def : Pat<(ARMvbicImm (v8i16 MQPR:$src), (i32 0xAFF)), 2808 (MVE_VMOVLu8bh MQPR:$src)>; 2809 // zext_inreg 16 -> 32 2810 def : Pat<(and (v4i32 MQPR:$src), (v4i32 (ARMvmovImm (i32 0xCFF)))), 2811 (MVE_VMOVLu16bh MQPR:$src)>; 2812 // Same zext_inreg with vrevs, picking the top half 2813 def : Pat<(ARMvbicImm (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src)))), (i32 0xAFF)), 2814 (MVE_VMOVLu8th MQPR:$src)>; 2815 def : Pat<(and (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src)))), 2816 (v4i32 (ARMvmovImm (i32 0xCFF)))), 2817 (MVE_VMOVLu16th MQPR:$src)>; 2818} 2819 2820 2821class MVE_VSHLL_imm<string iname, string suffix, bit U, bit th, 2822 Operand immtype, bits<2> vecsize, list<dag> pattern=[]> 2823 : MVE_shift_imm<(outs MQPR:$Qd), (ins MQPR:$Qm, immtype:$imm), 2824 iname, suffix, "$Qd, $Qm, $imm", vpred_r, "", vecsize, pattern> { 2825 let Inst{28} = U; 2826 let Inst{25-23} = 0b101; 2827 let Inst{21} = 0b1; 2828 let Inst{12} = th; 2829 let Inst{11-6} = 0b111101; 2830 let Inst{4} = 0b0; 2831 let Inst{0} = 0b0; 2832 2833 // For the MVE_VSHLL_patterns multiclass to refer to 2834 Operand immediateType = immtype; 2835 2836 let doubleWidthResult = 1; 2837} 2838 2839// The immediate VSHLL instructions accept shift counts from 1 up to 2840// the lane width (8 or 16), but the full-width shifts have an 2841// entirely separate encoding, given below with 'lw' in the name. 2842 2843class MVE_VSHLL_imm8<string iname, string suffix, 2844 bit U, bit th, list<dag> pattern=[]> 2845 : MVE_VSHLL_imm<iname, suffix, U, th, mve_shift_imm1_7, 0b01, pattern> { 2846 bits<3> imm; 2847 let Inst{20-19} = 0b01; 2848 let Inst{18-16} = imm; 2849} 2850 2851class MVE_VSHLL_imm16<string iname, string suffix, 2852 bit U, bit th, list<dag> pattern=[]> 2853 : MVE_VSHLL_imm<iname, suffix, U, th, mve_shift_imm1_15, 0b10, pattern> { 2854 bits<4> imm; 2855 let Inst{20} = 0b1; 2856 let Inst{19-16} = imm; 2857} 2858 2859def MVE_VSHLL_imms8bh : MVE_VSHLL_imm8 <"vshllb", "s8", 0b0, 0b0>; 2860def MVE_VSHLL_imms8th : MVE_VSHLL_imm8 <"vshllt", "s8", 0b0, 0b1>; 2861def MVE_VSHLL_immu8bh : MVE_VSHLL_imm8 <"vshllb", "u8", 0b1, 0b0>; 2862def MVE_VSHLL_immu8th : MVE_VSHLL_imm8 <"vshllt", "u8", 0b1, 0b1>; 2863def MVE_VSHLL_imms16bh : MVE_VSHLL_imm16<"vshllb", "s16", 0b0, 0b0>; 2864def MVE_VSHLL_imms16th : MVE_VSHLL_imm16<"vshllt", "s16", 0b0, 0b1>; 2865def MVE_VSHLL_immu16bh : MVE_VSHLL_imm16<"vshllb", "u16", 0b1, 0b0>; 2866def MVE_VSHLL_immu16th : MVE_VSHLL_imm16<"vshllt", "u16", 0b1, 0b1>; 2867 2868class MVE_VSHLL_by_lane_width<string iname, string suffix, bits<2> size, 2869 bit U, string ops, list<dag> pattern=[]> 2870 : MVE_shift_imm<(outs MQPR:$Qd), (ins MQPR:$Qm), 2871 iname, suffix, ops, vpred_r, "", !if(size, 0b10, 0b01), pattern> { 2872 let Inst{28} = U; 2873 let Inst{25-23} = 0b100; 2874 let Inst{21-20} = 0b11; 2875 let Inst{19-18} = size{1-0}; 2876 let Inst{17-16} = 0b01; 2877 let Inst{11-6} = 0b111000; 2878 let Inst{4} = 0b0; 2879 let Inst{0} = 0b1; 2880 let doubleWidthResult = 1; 2881} 2882 2883multiclass MVE_VSHLL_lw<string iname, string suffix, bits<2> sz, bit U, 2884 string ops, list<dag> pattern=[]> { 2885 def bh : MVE_VSHLL_by_lane_width<iname#"b", suffix, sz, U, ops, pattern> { 2886 let Inst{12} = 0b0; 2887 } 2888 def th : MVE_VSHLL_by_lane_width<iname#"t", suffix, sz, U, ops, pattern> { 2889 let Inst{12} = 0b1; 2890 } 2891} 2892 2893defm MVE_VSHLL_lws8 : MVE_VSHLL_lw<"vshll", "s8", 0b00, 0b0, "$Qd, $Qm, #8">; 2894defm MVE_VSHLL_lws16 : MVE_VSHLL_lw<"vshll", "s16", 0b01, 0b0, "$Qd, $Qm, #16">; 2895defm MVE_VSHLL_lwu8 : MVE_VSHLL_lw<"vshll", "u8", 0b00, 0b1, "$Qd, $Qm, #8">; 2896defm MVE_VSHLL_lwu16 : MVE_VSHLL_lw<"vshll", "u16", 0b01, 0b1, "$Qd, $Qm, #16">; 2897 2898multiclass MVE_VSHLL_patterns<MVEVectorVTInfo VTI, int top> { 2899 defvar suffix = !strconcat(VTI.Suffix, !if(top, "th", "bh")); 2900 defvar inst_imm = !cast<MVE_VSHLL_imm>("MVE_VSHLL_imm" # suffix); 2901 defvar inst_lw = !cast<MVE_VSHLL_by_lane_width>("MVE_VSHLL_lw" # suffix); 2902 defvar unpred_int = int_arm_mve_vshll_imm; 2903 defvar pred_int = int_arm_mve_vshll_imm_predicated; 2904 defvar imm = inst_imm.immediateType; 2905 2906 def : Pat<(VTI.DblVec (unpred_int (VTI.Vec MQPR:$src), imm:$imm, 2907 (i32 VTI.Unsigned), (i32 top))), 2908 (VTI.DblVec (inst_imm (VTI.Vec MQPR:$src), imm:$imm))>; 2909 def : Pat<(VTI.DblVec (unpred_int (VTI.Vec MQPR:$src), (i32 VTI.LaneBits), 2910 (i32 VTI.Unsigned), (i32 top))), 2911 (VTI.DblVec (inst_lw (VTI.Vec MQPR:$src)))>; 2912 2913 def : Pat<(VTI.DblVec (pred_int (VTI.Vec MQPR:$src), imm:$imm, 2914 (i32 VTI.Unsigned), (i32 top), 2915 (VTI.DblPred VCCR:$mask), 2916 (VTI.DblVec MQPR:$inactive))), 2917 (VTI.DblVec (inst_imm (VTI.Vec MQPR:$src), imm:$imm, 2918 ARMVCCThen, (VTI.DblPred VCCR:$mask), zero_reg, 2919 (VTI.DblVec MQPR:$inactive)))>; 2920 def : Pat<(VTI.DblVec (pred_int (VTI.Vec MQPR:$src), (i32 VTI.LaneBits), 2921 (i32 VTI.Unsigned), (i32 top), 2922 (VTI.DblPred VCCR:$mask), 2923 (VTI.DblVec MQPR:$inactive))), 2924 (VTI.DblVec (inst_lw (VTI.Vec MQPR:$src), ARMVCCThen, 2925 (VTI.DblPred VCCR:$mask), zero_reg, 2926 (VTI.DblVec MQPR:$inactive)))>; 2927} 2928 2929foreach VTI = [MVE_v16s8, MVE_v8s16, MVE_v16u8, MVE_v8u16] in 2930 foreach top = [0, 1] in 2931 defm : MVE_VSHLL_patterns<VTI, top>; 2932 2933class MVE_shift_imm_partial<Operand imm, string iname, string suffix, bits<2> vecsize> 2934 : MVE_shift_imm<(outs MQPR:$Qd), (ins MQPR:$QdSrc, MQPR:$Qm, imm:$imm), 2935 iname, suffix, "$Qd, $Qm, $imm", vpred_n, "$Qd = $QdSrc", vecsize> { 2936 Operand immediateType = imm; 2937} 2938 2939class MVE_VxSHRN<string iname, string suffix, bit bit_12, bit bit_28, 2940 Operand imm, bits<2> vecsize> 2941 : MVE_shift_imm_partial<imm, iname, suffix, vecsize> { 2942 bits<5> imm; 2943 2944 let Inst{28} = bit_28; 2945 let Inst{25-23} = 0b101; 2946 let Inst{21} = 0b0; 2947 let Inst{20-16} = imm{4-0}; 2948 let Inst{12} = bit_12; 2949 let Inst{11-6} = 0b111111; 2950 let Inst{4} = 0b0; 2951 let Inst{0} = 0b1; 2952 let validForTailPredication = 1; 2953 let retainsPreviousHalfElement = 1; 2954} 2955 2956def MVE_VRSHRNi16bh : MVE_VxSHRN<"vrshrnb", "i16", 0b0, 0b1, shr_imm8, 0b01> { 2957 let Inst{20-19} = 0b01; 2958} 2959def MVE_VRSHRNi16th : MVE_VxSHRN<"vrshrnt", "i16", 0b1, 0b1, shr_imm8, 0b01> { 2960 let Inst{20-19} = 0b01; 2961} 2962def MVE_VRSHRNi32bh : MVE_VxSHRN<"vrshrnb", "i32", 0b0, 0b1, shr_imm16, 0b10> { 2963 let Inst{20} = 0b1; 2964} 2965def MVE_VRSHRNi32th : MVE_VxSHRN<"vrshrnt", "i32", 0b1, 0b1, shr_imm16, 0b10> { 2966 let Inst{20} = 0b1; 2967} 2968 2969def MVE_VSHRNi16bh : MVE_VxSHRN<"vshrnb", "i16", 0b0, 0b0, shr_imm8, 0b01> { 2970 let Inst{20-19} = 0b01; 2971} 2972def MVE_VSHRNi16th : MVE_VxSHRN<"vshrnt", "i16", 0b1, 0b0, shr_imm8, 0b01> { 2973 let Inst{20-19} = 0b01; 2974} 2975def MVE_VSHRNi32bh : MVE_VxSHRN<"vshrnb", "i32", 0b0, 0b0, shr_imm16, 0b10> { 2976 let Inst{20} = 0b1; 2977} 2978def MVE_VSHRNi32th : MVE_VxSHRN<"vshrnt", "i32", 0b1, 0b0, shr_imm16, 0b10> { 2979 let Inst{20} = 0b1; 2980} 2981 2982class MVE_VxQRSHRUN<string iname, string suffix, bit bit_28, bit bit_12, 2983 Operand imm, bits<2> vecsize> 2984 : MVE_shift_imm_partial<imm, iname, suffix, vecsize> { 2985 bits<5> imm; 2986 2987 let Inst{28} = bit_28; 2988 let Inst{25-23} = 0b101; 2989 let Inst{21} = 0b0; 2990 let Inst{20-16} = imm{4-0}; 2991 let Inst{12} = bit_12; 2992 let Inst{11-6} = 0b111111; 2993 let Inst{4} = 0b0; 2994 let Inst{0} = 0b0; 2995 let validForTailPredication = 1; 2996 let retainsPreviousHalfElement = 1; 2997} 2998 2999def MVE_VQRSHRUNs16bh : MVE_VxQRSHRUN< 3000 "vqrshrunb", "s16", 0b1, 0b0, shr_imm8, 0b01> { 3001 let Inst{20-19} = 0b01; 3002} 3003def MVE_VQRSHRUNs16th : MVE_VxQRSHRUN< 3004 "vqrshrunt", "s16", 0b1, 0b1, shr_imm8, 0b01> { 3005 let Inst{20-19} = 0b01; 3006} 3007def MVE_VQRSHRUNs32bh : MVE_VxQRSHRUN< 3008 "vqrshrunb", "s32", 0b1, 0b0, shr_imm16, 0b10> { 3009 let Inst{20} = 0b1; 3010} 3011def MVE_VQRSHRUNs32th : MVE_VxQRSHRUN< 3012 "vqrshrunt", "s32", 0b1, 0b1, shr_imm16, 0b10> { 3013 let Inst{20} = 0b1; 3014} 3015 3016def MVE_VQSHRUNs16bh : MVE_VxQRSHRUN< 3017 "vqshrunb", "s16", 0b0, 0b0, shr_imm8, 0b01> { 3018 let Inst{20-19} = 0b01; 3019} 3020def MVE_VQSHRUNs16th : MVE_VxQRSHRUN< 3021 "vqshrunt", "s16", 0b0, 0b1, shr_imm8, 0b01> { 3022 let Inst{20-19} = 0b01; 3023} 3024def MVE_VQSHRUNs32bh : MVE_VxQRSHRUN< 3025 "vqshrunb", "s32", 0b0, 0b0, shr_imm16, 0b10> { 3026 let Inst{20} = 0b1; 3027} 3028def MVE_VQSHRUNs32th : MVE_VxQRSHRUN< 3029 "vqshrunt", "s32", 0b0, 0b1, shr_imm16, 0b10> { 3030 let Inst{20} = 0b1; 3031} 3032 3033class MVE_VxQRSHRN<string iname, string suffix, bit bit_0, bit bit_12, 3034 Operand imm, bits<2> vecsize> 3035 : MVE_shift_imm_partial<imm, iname, suffix, vecsize> { 3036 bits<5> imm; 3037 3038 let Inst{25-23} = 0b101; 3039 let Inst{21} = 0b0; 3040 let Inst{20-16} = imm{4-0}; 3041 let Inst{12} = bit_12; 3042 let Inst{11-6} = 0b111101; 3043 let Inst{4} = 0b0; 3044 let Inst{0} = bit_0; 3045 let validForTailPredication = 1; 3046 let retainsPreviousHalfElement = 1; 3047} 3048 3049multiclass MVE_VxQRSHRN_types<string iname, bit bit_0, bit bit_12> { 3050 def s16 : MVE_VxQRSHRN<iname, "s16", bit_0, bit_12, shr_imm8, 0b01> { 3051 let Inst{28} = 0b0; 3052 let Inst{20-19} = 0b01; 3053 } 3054 def u16 : MVE_VxQRSHRN<iname, "u16", bit_0, bit_12, shr_imm8, 0b01> { 3055 let Inst{28} = 0b1; 3056 let Inst{20-19} = 0b01; 3057 } 3058 def s32 : MVE_VxQRSHRN<iname, "s32", bit_0, bit_12, shr_imm16, 0b10> { 3059 let Inst{28} = 0b0; 3060 let Inst{20} = 0b1; 3061 } 3062 def u32 : MVE_VxQRSHRN<iname, "u32", bit_0, bit_12, shr_imm16, 0b10> { 3063 let Inst{28} = 0b1; 3064 let Inst{20} = 0b1; 3065 } 3066} 3067 3068defm MVE_VQRSHRNbh : MVE_VxQRSHRN_types<"vqrshrnb", 0b1, 0b0>; 3069defm MVE_VQRSHRNth : MVE_VxQRSHRN_types<"vqrshrnt", 0b1, 0b1>; 3070defm MVE_VQSHRNbh : MVE_VxQRSHRN_types<"vqshrnb", 0b0, 0b0>; 3071defm MVE_VQSHRNth : MVE_VxQRSHRN_types<"vqshrnt", 0b0, 0b1>; 3072 3073multiclass MVE_VSHRN_patterns<MVE_shift_imm_partial inst, 3074 MVEVectorVTInfo OutVTI, MVEVectorVTInfo InVTI, 3075 bit q, bit r, bit top> { 3076 defvar inparams = (? (OutVTI.Vec MQPR:$QdSrc), (InVTI.Vec MQPR:$Qm), 3077 (inst.immediateType:$imm), (i32 q), (i32 r), 3078 (i32 OutVTI.Unsigned), (i32 InVTI.Unsigned), (i32 top)); 3079 defvar outparams = (inst (OutVTI.Vec MQPR:$QdSrc), (InVTI.Vec MQPR:$Qm), 3080 (imm:$imm)); 3081 3082 def : Pat<(OutVTI.Vec !setdagop(inparams, int_arm_mve_vshrn)), 3083 (OutVTI.Vec outparams)>; 3084 def : Pat<(OutVTI.Vec !con(inparams, (int_arm_mve_vshrn_predicated 3085 (InVTI.Pred VCCR:$pred)))), 3086 (OutVTI.Vec !con(outparams, (? ARMVCCThen, VCCR:$pred, zero_reg)))>; 3087} 3088 3089defm : MVE_VSHRN_patterns<MVE_VSHRNi16bh, MVE_v16s8, MVE_v8s16, 0,0,0>; 3090defm : MVE_VSHRN_patterns<MVE_VSHRNi16th, MVE_v16s8, MVE_v8s16, 0,0,1>; 3091defm : MVE_VSHRN_patterns<MVE_VSHRNi32bh, MVE_v8s16, MVE_v4s32, 0,0,0>; 3092defm : MVE_VSHRN_patterns<MVE_VSHRNi32th, MVE_v8s16, MVE_v4s32, 0,0,1>; 3093defm : MVE_VSHRN_patterns<MVE_VSHRNi16bh, MVE_v16u8, MVE_v8u16, 0,0,0>; 3094defm : MVE_VSHRN_patterns<MVE_VSHRNi16th, MVE_v16u8, MVE_v8u16, 0,0,1>; 3095defm : MVE_VSHRN_patterns<MVE_VSHRNi32bh, MVE_v8u16, MVE_v4u32, 0,0,0>; 3096defm : MVE_VSHRN_patterns<MVE_VSHRNi32th, MVE_v8u16, MVE_v4u32, 0,0,1>; 3097defm : MVE_VSHRN_patterns<MVE_VRSHRNi16bh, MVE_v16s8, MVE_v8s16, 0,1,0>; 3098defm : MVE_VSHRN_patterns<MVE_VRSHRNi16th, MVE_v16s8, MVE_v8s16, 0,1,1>; 3099defm : MVE_VSHRN_patterns<MVE_VRSHRNi32bh, MVE_v8s16, MVE_v4s32, 0,1,0>; 3100defm : MVE_VSHRN_patterns<MVE_VRSHRNi32th, MVE_v8s16, MVE_v4s32, 0,1,1>; 3101defm : MVE_VSHRN_patterns<MVE_VRSHRNi16bh, MVE_v16u8, MVE_v8u16, 0,1,0>; 3102defm : MVE_VSHRN_patterns<MVE_VRSHRNi16th, MVE_v16u8, MVE_v8u16, 0,1,1>; 3103defm : MVE_VSHRN_patterns<MVE_VRSHRNi32bh, MVE_v8u16, MVE_v4u32, 0,1,0>; 3104defm : MVE_VSHRN_patterns<MVE_VRSHRNi32th, MVE_v8u16, MVE_v4u32, 0,1,1>; 3105defm : MVE_VSHRN_patterns<MVE_VQSHRNbhs16, MVE_v16s8, MVE_v8s16, 1,0,0>; 3106defm : MVE_VSHRN_patterns<MVE_VQSHRNths16, MVE_v16s8, MVE_v8s16, 1,0,1>; 3107defm : MVE_VSHRN_patterns<MVE_VQSHRNbhs32, MVE_v8s16, MVE_v4s32, 1,0,0>; 3108defm : MVE_VSHRN_patterns<MVE_VQSHRNths32, MVE_v8s16, MVE_v4s32, 1,0,1>; 3109defm : MVE_VSHRN_patterns<MVE_VQSHRNbhu16, MVE_v16u8, MVE_v8u16, 1,0,0>; 3110defm : MVE_VSHRN_patterns<MVE_VQSHRNthu16, MVE_v16u8, MVE_v8u16, 1,0,1>; 3111defm : MVE_VSHRN_patterns<MVE_VQSHRNbhu32, MVE_v8u16, MVE_v4u32, 1,0,0>; 3112defm : MVE_VSHRN_patterns<MVE_VQSHRNthu32, MVE_v8u16, MVE_v4u32, 1,0,1>; 3113defm : MVE_VSHRN_patterns<MVE_VQRSHRNbhs16, MVE_v16s8, MVE_v8s16, 1,1,0>; 3114defm : MVE_VSHRN_patterns<MVE_VQRSHRNths16, MVE_v16s8, MVE_v8s16, 1,1,1>; 3115defm : MVE_VSHRN_patterns<MVE_VQRSHRNbhs32, MVE_v8s16, MVE_v4s32, 1,1,0>; 3116defm : MVE_VSHRN_patterns<MVE_VQRSHRNths32, MVE_v8s16, MVE_v4s32, 1,1,1>; 3117defm : MVE_VSHRN_patterns<MVE_VQRSHRNbhu16, MVE_v16u8, MVE_v8u16, 1,1,0>; 3118defm : MVE_VSHRN_patterns<MVE_VQRSHRNthu16, MVE_v16u8, MVE_v8u16, 1,1,1>; 3119defm : MVE_VSHRN_patterns<MVE_VQRSHRNbhu32, MVE_v8u16, MVE_v4u32, 1,1,0>; 3120defm : MVE_VSHRN_patterns<MVE_VQRSHRNthu32, MVE_v8u16, MVE_v4u32, 1,1,1>; 3121defm : MVE_VSHRN_patterns<MVE_VQSHRUNs16bh, MVE_v16u8, MVE_v8s16, 1,0,0>; 3122defm : MVE_VSHRN_patterns<MVE_VQSHRUNs16th, MVE_v16u8, MVE_v8s16, 1,0,1>; 3123defm : MVE_VSHRN_patterns<MVE_VQSHRUNs32bh, MVE_v8u16, MVE_v4s32, 1,0,0>; 3124defm : MVE_VSHRN_patterns<MVE_VQSHRUNs32th, MVE_v8u16, MVE_v4s32, 1,0,1>; 3125defm : MVE_VSHRN_patterns<MVE_VQRSHRUNs16bh, MVE_v16u8, MVE_v8s16, 1,1,0>; 3126defm : MVE_VSHRN_patterns<MVE_VQRSHRUNs16th, MVE_v16u8, MVE_v8s16, 1,1,1>; 3127defm : MVE_VSHRN_patterns<MVE_VQRSHRUNs32bh, MVE_v8u16, MVE_v4s32, 1,1,0>; 3128defm : MVE_VSHRN_patterns<MVE_VQRSHRUNs32th, MVE_v8u16, MVE_v4s32, 1,1,1>; 3129 3130// end of mve_imm_shift instructions 3131 3132// start of mve_shift instructions 3133 3134class MVE_shift_by_vec<string iname, string suffix, bit U, 3135 bits<2> size, bit bit_4, bit bit_8> 3136 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qm, MQPR:$Qn), NoItinerary, 3137 iname, suffix, "$Qd, $Qm, $Qn", vpred_r, "", size, []> { 3138 // Shift instructions which take a vector of shift counts 3139 bits<4> Qd; 3140 bits<4> Qm; 3141 bits<4> Qn; 3142 3143 let Inst{28} = U; 3144 let Inst{25-24} = 0b11; 3145 let Inst{23} = 0b0; 3146 let Inst{22} = Qd{3}; 3147 let Inst{21-20} = size; 3148 let Inst{19-17} = Qn{2-0}; 3149 let Inst{16} = 0b0; 3150 let Inst{15-13} = Qd{2-0}; 3151 let Inst{12-9} = 0b0010; 3152 let Inst{8} = bit_8; 3153 let Inst{7} = Qn{3}; 3154 let Inst{6} = 0b1; 3155 let Inst{5} = Qm{3}; 3156 let Inst{4} = bit_4; 3157 let Inst{3-1} = Qm{2-0}; 3158 let Inst{0} = 0b0; 3159 let validForTailPredication = 1; 3160} 3161 3162multiclass MVE_shift_by_vec_p<string iname, MVEVectorVTInfo VTI, bit q, bit r> { 3163 def "" : MVE_shift_by_vec<iname, VTI.Suffix, VTI.Unsigned, VTI.Size, q, r>; 3164 defvar Inst = !cast<Instruction>(NAME); 3165 3166 def : Pat<(VTI.Vec (int_arm_mve_vshl_vector 3167 (VTI.Vec MQPR:$in), (VTI.Vec MQPR:$sh), 3168 (i32 q), (i32 r), (i32 VTI.Unsigned))), 3169 (VTI.Vec (Inst (VTI.Vec MQPR:$in), (VTI.Vec MQPR:$sh)))>; 3170 3171 def : Pat<(VTI.Vec (int_arm_mve_vshl_vector_predicated 3172 (VTI.Vec MQPR:$in), (VTI.Vec MQPR:$sh), 3173 (i32 q), (i32 r), (i32 VTI.Unsigned), 3174 (VTI.Pred VCCR:$mask), (VTI.Vec MQPR:$inactive))), 3175 (VTI.Vec (Inst (VTI.Vec MQPR:$in), (VTI.Vec MQPR:$sh), 3176 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 3177 (VTI.Vec MQPR:$inactive)))>; 3178} 3179 3180multiclass mve_shift_by_vec_multi<string iname, bit bit_4, bit bit_8> { 3181 defm s8 : MVE_shift_by_vec_p<iname, MVE_v16s8, bit_4, bit_8>; 3182 defm s16 : MVE_shift_by_vec_p<iname, MVE_v8s16, bit_4, bit_8>; 3183 defm s32 : MVE_shift_by_vec_p<iname, MVE_v4s32, bit_4, bit_8>; 3184 defm u8 : MVE_shift_by_vec_p<iname, MVE_v16u8, bit_4, bit_8>; 3185 defm u16 : MVE_shift_by_vec_p<iname, MVE_v8u16, bit_4, bit_8>; 3186 defm u32 : MVE_shift_by_vec_p<iname, MVE_v4u32, bit_4, bit_8>; 3187} 3188 3189defm MVE_VSHL_by_vec : mve_shift_by_vec_multi<"vshl", 0b0, 0b0>; 3190defm MVE_VQSHL_by_vec : mve_shift_by_vec_multi<"vqshl", 0b1, 0b0>; 3191defm MVE_VQRSHL_by_vec : mve_shift_by_vec_multi<"vqrshl", 0b1, 0b1>; 3192defm MVE_VRSHL_by_vec : mve_shift_by_vec_multi<"vrshl", 0b0, 0b1>; 3193 3194let Predicates = [HasMVEInt] in { 3195 defm : MVE_TwoOpPattern<MVE_v16i8, ARMvshlu, int_arm_mve_vshl_vector_predicated, 3196 (? (i32 0), (i32 0), (i32 1)), MVE_VSHL_by_vecu8, null_frag>; 3197 defm : MVE_TwoOpPattern<MVE_v8i16, ARMvshlu, int_arm_mve_vshl_vector_predicated, 3198 (? (i32 0), (i32 0), (i32 1)), MVE_VSHL_by_vecu16, null_frag>; 3199 defm : MVE_TwoOpPattern<MVE_v4i32, ARMvshlu, int_arm_mve_vshl_vector_predicated, 3200 (? (i32 0), (i32 0), (i32 1)), MVE_VSHL_by_vecu32, null_frag>; 3201 defm : MVE_TwoOpPattern<MVE_v16i8, ARMvshls, int_arm_mve_vshl_vector_predicated, 3202 (? (i32 0), (i32 0), (i32 0)), MVE_VSHL_by_vecs8, null_frag>; 3203 defm : MVE_TwoOpPattern<MVE_v8i16, ARMvshls, int_arm_mve_vshl_vector_predicated, 3204 (? (i32 0), (i32 0), (i32 0)), MVE_VSHL_by_vecs16, null_frag>; 3205 defm : MVE_TwoOpPattern<MVE_v4i32, ARMvshls, int_arm_mve_vshl_vector_predicated, 3206 (? (i32 0), (i32 0), (i32 0)), MVE_VSHL_by_vecs32, null_frag>; 3207} 3208 3209class MVE_shift_with_imm<string iname, string suffix, dag oops, dag iops, 3210 string ops, vpred_ops vpred, string cstr, 3211 bits<2> vecsize, list<dag> pattern=[]> 3212 : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, vecsize, pattern> { 3213 bits<4> Qd; 3214 bits<4> Qm; 3215 3216 let Inst{23} = 0b1; 3217 let Inst{22} = Qd{3}; 3218 let Inst{15-13} = Qd{2-0}; 3219 let Inst{12-11} = 0b00; 3220 let Inst{7-6} = 0b01; 3221 let Inst{5} = Qm{3}; 3222 let Inst{4} = 0b1; 3223 let Inst{3-1} = Qm{2-0}; 3224 let Inst{0} = 0b0; 3225 let validForTailPredication = 1; 3226 3227 // For the MVE_shift_imm_patterns multiclass to refer to 3228 MVEVectorVTInfo VTI; 3229 Operand immediateType; 3230 Intrinsic unpred_int; 3231 Intrinsic pred_int; 3232 dag unsignedFlag = (?); 3233} 3234 3235class MVE_VSxI_imm<string iname, string suffix, bit bit_8, Operand immType, bits<2> vecsize> 3236 : MVE_shift_with_imm<iname, suffix, (outs MQPR:$Qd), 3237 (ins MQPR:$Qd_src, MQPR:$Qm, immType:$imm), 3238 "$Qd, $Qm, $imm", vpred_n, "$Qd = $Qd_src", vecsize> { 3239 bits<6> imm; 3240 let Inst{28} = 0b1; 3241 let Inst{25-24} = 0b11; 3242 let Inst{21-16} = imm; 3243 let Inst{10-9} = 0b10; 3244 let Inst{8} = bit_8; 3245 let validForTailPredication = 1; 3246 3247 Operand immediateType = immType; 3248} 3249 3250def MVE_VSRIimm8 : MVE_VSxI_imm<"vsri", "8", 0b0, shr_imm8, 0b00> { 3251 let Inst{21-19} = 0b001; 3252} 3253 3254def MVE_VSRIimm16 : MVE_VSxI_imm<"vsri", "16", 0b0, shr_imm16, 0b01> { 3255 let Inst{21-20} = 0b01; 3256} 3257 3258def MVE_VSRIimm32 : MVE_VSxI_imm<"vsri", "32", 0b0, shr_imm32, 0b10> { 3259 let Inst{21} = 0b1; 3260} 3261 3262def MVE_VSLIimm8 : MVE_VSxI_imm<"vsli", "8", 0b1, imm0_7, 0b00> { 3263 let Inst{21-19} = 0b001; 3264} 3265 3266def MVE_VSLIimm16 : MVE_VSxI_imm<"vsli", "16", 0b1, imm0_15, 0b01> { 3267 let Inst{21-20} = 0b01; 3268} 3269 3270def MVE_VSLIimm32 : MVE_VSxI_imm<"vsli", "32", 0b1,imm0_31, 0b10> { 3271 let Inst{21} = 0b1; 3272} 3273 3274multiclass MVE_VSxI_patterns<MVE_VSxI_imm inst, string name, 3275 MVEVectorVTInfo VTI> { 3276 defvar inparams = (? (VTI.Vec MQPR:$QdSrc), (VTI.Vec MQPR:$Qm), 3277 (inst.immediateType:$imm)); 3278 defvar outparams = (inst (VTI.Vec MQPR:$QdSrc), (VTI.Vec MQPR:$Qm), 3279 (inst.immediateType:$imm)); 3280 defvar unpred_int = !cast<Intrinsic>("int_arm_mve_" # name); 3281 defvar pred_int = !cast<Intrinsic>("int_arm_mve_" # name # "_predicated"); 3282 3283 def : Pat<(VTI.Vec !setdagop(inparams, unpred_int)), 3284 (VTI.Vec outparams)>; 3285 def : Pat<(VTI.Vec !con(inparams, (pred_int (VTI.Pred VCCR:$pred)))), 3286 (VTI.Vec !con(outparams, (? ARMVCCThen, VCCR:$pred, zero_reg)))>; 3287} 3288 3289defm : MVE_VSxI_patterns<MVE_VSLIimm8, "vsli", MVE_v16i8>; 3290defm : MVE_VSxI_patterns<MVE_VSLIimm16, "vsli", MVE_v8i16>; 3291defm : MVE_VSxI_patterns<MVE_VSLIimm32, "vsli", MVE_v4i32>; 3292defm : MVE_VSxI_patterns<MVE_VSRIimm8, "vsri", MVE_v16i8>; 3293defm : MVE_VSxI_patterns<MVE_VSRIimm16, "vsri", MVE_v8i16>; 3294defm : MVE_VSxI_patterns<MVE_VSRIimm32, "vsri", MVE_v4i32>; 3295 3296class MVE_VQSHL_imm<MVEVectorVTInfo VTI_, Operand immType> 3297 : MVE_shift_with_imm<"vqshl", VTI_.Suffix, (outs MQPR:$Qd), 3298 (ins MQPR:$Qm, immType:$imm), "$Qd, $Qm, $imm", 3299 vpred_r, "", VTI_.Size> { 3300 bits<6> imm; 3301 3302 let Inst{28} = VTI_.Unsigned; 3303 let Inst{25-24} = 0b11; 3304 let Inst{21-16} = imm; 3305 let Inst{10-8} = 0b111; 3306 3307 let VTI = VTI_; 3308 let immediateType = immType; 3309 let unsignedFlag = (? (i32 VTI.Unsigned)); 3310} 3311 3312let unpred_int = int_arm_mve_vqshl_imm, 3313 pred_int = int_arm_mve_vqshl_imm_predicated in { 3314 def MVE_VQSHLimms8 : MVE_VQSHL_imm<MVE_v16s8, imm0_7> { 3315 let Inst{21-19} = 0b001; 3316 } 3317 def MVE_VQSHLimmu8 : MVE_VQSHL_imm<MVE_v16u8, imm0_7> { 3318 let Inst{21-19} = 0b001; 3319 } 3320 3321 def MVE_VQSHLimms16 : MVE_VQSHL_imm<MVE_v8s16, imm0_15> { 3322 let Inst{21-20} = 0b01; 3323 } 3324 def MVE_VQSHLimmu16 : MVE_VQSHL_imm<MVE_v8u16, imm0_15> { 3325 let Inst{21-20} = 0b01; 3326 } 3327 3328 def MVE_VQSHLimms32 : MVE_VQSHL_imm<MVE_v4s32, imm0_31> { 3329 let Inst{21} = 0b1; 3330 } 3331 def MVE_VQSHLimmu32 : MVE_VQSHL_imm<MVE_v4u32, imm0_31> { 3332 let Inst{21} = 0b1; 3333 } 3334} 3335 3336class MVE_VQSHLU_imm<MVEVectorVTInfo VTI_, Operand immType> 3337 : MVE_shift_with_imm<"vqshlu", VTI_.Suffix, (outs MQPR:$Qd), 3338 (ins MQPR:$Qm, immType:$imm), "$Qd, $Qm, $imm", 3339 vpred_r, "", VTI_.Size> { 3340 bits<6> imm; 3341 3342 let Inst{28} = 0b1; 3343 let Inst{25-24} = 0b11; 3344 let Inst{21-16} = imm; 3345 let Inst{10-8} = 0b110; 3346 3347 let VTI = VTI_; 3348 let immediateType = immType; 3349} 3350 3351let unpred_int = int_arm_mve_vqshlu_imm, 3352 pred_int = int_arm_mve_vqshlu_imm_predicated in { 3353 def MVE_VQSHLU_imms8 : MVE_VQSHLU_imm<MVE_v16s8, imm0_7> { 3354 let Inst{21-19} = 0b001; 3355 } 3356 3357 def MVE_VQSHLU_imms16 : MVE_VQSHLU_imm<MVE_v8s16, imm0_15> { 3358 let Inst{21-20} = 0b01; 3359 } 3360 3361 def MVE_VQSHLU_imms32 : MVE_VQSHLU_imm<MVE_v4s32, imm0_31> { 3362 let Inst{21} = 0b1; 3363 } 3364} 3365 3366class MVE_VRSHR_imm<MVEVectorVTInfo VTI_, Operand immType> 3367 : MVE_shift_with_imm<"vrshr", VTI_.Suffix, (outs MQPR:$Qd), 3368 (ins MQPR:$Qm, immType:$imm), "$Qd, $Qm, $imm", 3369 vpred_r, "", VTI_.Size> { 3370 bits<6> imm; 3371 3372 let Inst{28} = VTI_.Unsigned; 3373 let Inst{25-24} = 0b11; 3374 let Inst{21-16} = imm; 3375 let Inst{10-8} = 0b010; 3376 3377 let VTI = VTI_; 3378 let immediateType = immType; 3379 let unsignedFlag = (? (i32 VTI.Unsigned)); 3380} 3381 3382let unpred_int = int_arm_mve_vrshr_imm, 3383 pred_int = int_arm_mve_vrshr_imm_predicated in { 3384 def MVE_VRSHR_imms8 : MVE_VRSHR_imm<MVE_v16s8, shr_imm8> { 3385 let Inst{21-19} = 0b001; 3386 } 3387 3388 def MVE_VRSHR_immu8 : MVE_VRSHR_imm<MVE_v16u8, shr_imm8> { 3389 let Inst{21-19} = 0b001; 3390 } 3391 3392 def MVE_VRSHR_imms16 : MVE_VRSHR_imm<MVE_v8s16, shr_imm16> { 3393 let Inst{21-20} = 0b01; 3394 } 3395 3396 def MVE_VRSHR_immu16 : MVE_VRSHR_imm<MVE_v8u16, shr_imm16> { 3397 let Inst{21-20} = 0b01; 3398 } 3399 3400 def MVE_VRSHR_imms32 : MVE_VRSHR_imm<MVE_v4s32, shr_imm32> { 3401 let Inst{21} = 0b1; 3402 } 3403 3404 def MVE_VRSHR_immu32 : MVE_VRSHR_imm<MVE_v4u32, shr_imm32> { 3405 let Inst{21} = 0b1; 3406 } 3407} 3408 3409multiclass MVE_shift_imm_patterns<MVE_shift_with_imm inst> { 3410 def : Pat<(inst.VTI.Vec !con((inst.unpred_int (inst.VTI.Vec MQPR:$src), 3411 inst.immediateType:$imm), 3412 inst.unsignedFlag)), 3413 (inst.VTI.Vec (inst (inst.VTI.Vec MQPR:$src), 3414 inst.immediateType:$imm))>; 3415 3416 def : Pat<(inst.VTI.Vec !con((inst.pred_int (inst.VTI.Vec MQPR:$src), 3417 inst.immediateType:$imm), 3418 inst.unsignedFlag, 3419 (? (inst.VTI.Pred VCCR:$mask), 3420 (inst.VTI.Vec MQPR:$inactive)))), 3421 (inst.VTI.Vec (inst (inst.VTI.Vec MQPR:$src), 3422 inst.immediateType:$imm, 3423 ARMVCCThen, (inst.VTI.Pred VCCR:$mask), zero_reg, 3424 (inst.VTI.Vec MQPR:$inactive)))>; 3425} 3426 3427defm : MVE_shift_imm_patterns<MVE_VQSHLimms8>; 3428defm : MVE_shift_imm_patterns<MVE_VQSHLimmu8>; 3429defm : MVE_shift_imm_patterns<MVE_VQSHLimms16>; 3430defm : MVE_shift_imm_patterns<MVE_VQSHLimmu16>; 3431defm : MVE_shift_imm_patterns<MVE_VQSHLimms32>; 3432defm : MVE_shift_imm_patterns<MVE_VQSHLimmu32>; 3433defm : MVE_shift_imm_patterns<MVE_VQSHLU_imms8>; 3434defm : MVE_shift_imm_patterns<MVE_VQSHLU_imms16>; 3435defm : MVE_shift_imm_patterns<MVE_VQSHLU_imms32>; 3436defm : MVE_shift_imm_patterns<MVE_VRSHR_imms8>; 3437defm : MVE_shift_imm_patterns<MVE_VRSHR_immu8>; 3438defm : MVE_shift_imm_patterns<MVE_VRSHR_imms16>; 3439defm : MVE_shift_imm_patterns<MVE_VRSHR_immu16>; 3440defm : MVE_shift_imm_patterns<MVE_VRSHR_imms32>; 3441defm : MVE_shift_imm_patterns<MVE_VRSHR_immu32>; 3442 3443class MVE_VSHR_imm<string suffix, dag imm, bits<2> vecsize> 3444 : MVE_shift_with_imm<"vshr", suffix, (outs MQPR:$Qd), 3445 !con((ins MQPR:$Qm), imm), "$Qd, $Qm, $imm", 3446 vpred_r, "", vecsize> { 3447 bits<6> imm; 3448 3449 let Inst{25-24} = 0b11; 3450 let Inst{21-16} = imm; 3451 let Inst{10-8} = 0b000; 3452} 3453 3454def MVE_VSHR_imms8 : MVE_VSHR_imm<"s8", (ins shr_imm8:$imm), 0b00> { 3455 let Inst{28} = 0b0; 3456 let Inst{21-19} = 0b001; 3457} 3458 3459def MVE_VSHR_immu8 : MVE_VSHR_imm<"u8", (ins shr_imm8:$imm), 0b00> { 3460 let Inst{28} = 0b1; 3461 let Inst{21-19} = 0b001; 3462} 3463 3464def MVE_VSHR_imms16 : MVE_VSHR_imm<"s16", (ins shr_imm16:$imm), 0b01> { 3465 let Inst{28} = 0b0; 3466 let Inst{21-20} = 0b01; 3467} 3468 3469def MVE_VSHR_immu16 : MVE_VSHR_imm<"u16", (ins shr_imm16:$imm), 0b01> { 3470 let Inst{28} = 0b1; 3471 let Inst{21-20} = 0b01; 3472} 3473 3474def MVE_VSHR_imms32 : MVE_VSHR_imm<"s32", (ins shr_imm32:$imm), 0b10> { 3475 let Inst{28} = 0b0; 3476 let Inst{21} = 0b1; 3477} 3478 3479def MVE_VSHR_immu32 : MVE_VSHR_imm<"u32", (ins shr_imm32:$imm), 0b10> { 3480 let Inst{28} = 0b1; 3481 let Inst{21} = 0b1; 3482} 3483 3484class MVE_VSHL_imm<string suffix, dag imm, bits<2> vecsize> 3485 : MVE_shift_with_imm<"vshl", suffix, (outs MQPR:$Qd), 3486 !con((ins MQPR:$Qm), imm), "$Qd, $Qm, $imm", 3487 vpred_r, "", vecsize> { 3488 bits<6> imm; 3489 3490 let Inst{28} = 0b0; 3491 let Inst{25-24} = 0b11; 3492 let Inst{21-16} = imm; 3493 let Inst{10-8} = 0b101; 3494} 3495 3496def MVE_VSHL_immi8 : MVE_VSHL_imm<"i8", (ins imm0_7:$imm), 0b00> { 3497 let Inst{21-19} = 0b001; 3498} 3499 3500def MVE_VSHL_immi16 : MVE_VSHL_imm<"i16", (ins imm0_15:$imm), 0b01> { 3501 let Inst{21-20} = 0b01; 3502} 3503 3504def MVE_VSHL_immi32 : MVE_VSHL_imm<"i32", (ins imm0_31:$imm), 0b10> { 3505 let Inst{21} = 0b1; 3506} 3507 3508multiclass MVE_immediate_shift_patterns_inner< 3509 MVEVectorVTInfo VTI, Operand imm_operand_type, SDNode unpred_op, 3510 Intrinsic pred_int, Instruction inst, list<int> unsignedFlag = []> { 3511 3512 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$src), imm_operand_type:$imm)), 3513 (VTI.Vec (inst (VTI.Vec MQPR:$src), imm_operand_type:$imm))>; 3514 3515 def : Pat<(VTI.Vec !con((pred_int (VTI.Vec MQPR:$src), imm_operand_type:$imm), 3516 !dag(pred_int, unsignedFlag, ?), 3517 (pred_int (VTI.Pred VCCR:$mask), 3518 (VTI.Vec MQPR:$inactive)))), 3519 (VTI.Vec (inst (VTI.Vec MQPR:$src), imm_operand_type:$imm, 3520 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 3521 (VTI.Vec MQPR:$inactive)))>; 3522} 3523 3524multiclass MVE_immediate_shift_patterns<MVEVectorVTInfo VTI, 3525 Operand imm_operand_type> { 3526 defm : MVE_immediate_shift_patterns_inner<VTI, imm_operand_type, 3527 ARMvshlImm, int_arm_mve_shl_imm_predicated, 3528 !cast<Instruction>("MVE_VSHL_immi" # VTI.BitsSuffix)>; 3529 defm : MVE_immediate_shift_patterns_inner<VTI, imm_operand_type, 3530 ARMvshruImm, int_arm_mve_shr_imm_predicated, 3531 !cast<Instruction>("MVE_VSHR_immu" # VTI.BitsSuffix), [1]>; 3532 defm : MVE_immediate_shift_patterns_inner<VTI, imm_operand_type, 3533 ARMvshrsImm, int_arm_mve_shr_imm_predicated, 3534 !cast<Instruction>("MVE_VSHR_imms" # VTI.BitsSuffix), [0]>; 3535} 3536 3537let Predicates = [HasMVEInt] in { 3538 defm : MVE_immediate_shift_patterns<MVE_v16i8, imm0_7>; 3539 defm : MVE_immediate_shift_patterns<MVE_v8i16, imm0_15>; 3540 defm : MVE_immediate_shift_patterns<MVE_v4i32, imm0_31>; 3541} 3542 3543// end of mve_shift instructions 3544 3545// start of MVE Floating Point instructions 3546 3547class MVE_float<string iname, string suffix, dag oops, dag iops, string ops, 3548 vpred_ops vpred, string cstr, bits<2> vecsize, list<dag> pattern=[]> 3549 : MVE_f<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, vecsize, pattern> { 3550 bits<4> Qm; 3551 3552 let Inst{12} = 0b0; 3553 let Inst{6} = 0b1; 3554 let Inst{5} = Qm{3}; 3555 let Inst{3-1} = Qm{2-0}; 3556 let Inst{0} = 0b0; 3557} 3558 3559class MVE_VRINT<string rmode, bits<3> op, string suffix, bits<2> size, 3560 list<dag> pattern=[]> 3561 : MVE_float<!strconcat("vrint", rmode), suffix, (outs MQPR:$Qd), 3562 (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", size, pattern> { 3563 bits<4> Qd; 3564 3565 let Inst{28} = 0b1; 3566 let Inst{25-23} = 0b111; 3567 let Inst{22} = Qd{3}; 3568 let Inst{21-20} = 0b11; 3569 let Inst{19-18} = size; 3570 let Inst{17-16} = 0b10; 3571 let Inst{15-13} = Qd{2-0}; 3572 let Inst{11-10} = 0b01; 3573 let Inst{9-7} = op{2-0}; 3574 let Inst{4} = 0b0; 3575 let validForTailPredication = 1; 3576 3577} 3578 3579multiclass MVE_VRINT_m<MVEVectorVTInfo VTI, string suffix, bits<3> opcode, 3580 SDPatternOperator unpred_op> { 3581 def "": MVE_VRINT<suffix, opcode, VTI.Suffix, VTI.Size>; 3582 defvar Inst = !cast<Instruction>(NAME); 3583 defvar pred_int = !cast<Intrinsic>("int_arm_mve_vrint"#suffix#"_predicated"); 3584 3585 let Predicates = [HasMVEFloat] in { 3586 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$val))), 3587 (VTI.Vec (Inst (VTI.Vec MQPR:$val)))>; 3588 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$val), (VTI.Pred VCCR:$pred), 3589 (VTI.Vec MQPR:$inactive))), 3590 (VTI.Vec (Inst (VTI.Vec MQPR:$val), ARMVCCThen, 3591 (VTI.Pred VCCR:$pred), zero_reg, (VTI.Vec MQPR:$inactive)))>; 3592 } 3593} 3594 3595multiclass MVE_VRINT_ops<MVEVectorVTInfo VTI> { 3596 defm N : MVE_VRINT_m<VTI, "n", 0b000, int_arm_mve_vrintn>; 3597 defm X : MVE_VRINT_m<VTI, "x", 0b001, frint>; 3598 defm A : MVE_VRINT_m<VTI, "a", 0b010, fround>; 3599 defm Z : MVE_VRINT_m<VTI, "z", 0b011, ftrunc>; 3600 defm M : MVE_VRINT_m<VTI, "m", 0b101, ffloor>; 3601 defm P : MVE_VRINT_m<VTI, "p", 0b111, fceil>; 3602} 3603 3604defm MVE_VRINTf16 : MVE_VRINT_ops<MVE_v8f16>; 3605defm MVE_VRINTf32 : MVE_VRINT_ops<MVE_v4f32>; 3606 3607class MVEFloatArithNeon<string iname, string suffix, bit size, 3608 dag oops, dag iops, string ops, 3609 vpred_ops vpred, string cstr, bits<2> vecsize, list<dag> pattern=[]> 3610 : MVE_float<iname, suffix, oops, iops, ops, vpred, cstr, vecsize, pattern> { 3611 let Inst{20} = size; 3612 let Inst{16} = 0b0; 3613} 3614 3615class MVE_VMUL_fp<string iname, string suffix, bits<2> size, list<dag> pattern=[]> 3616 : MVEFloatArithNeon<iname, suffix, size{0}, (outs MQPR:$Qd), 3617 (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm", vpred_r, "", 3618 size, pattern> { 3619 bits<4> Qd; 3620 bits<4> Qn; 3621 3622 let Inst{28} = 0b1; 3623 let Inst{25-23} = 0b110; 3624 let Inst{22} = Qd{3}; 3625 let Inst{21} = 0b0; 3626 let Inst{19-17} = Qn{2-0}; 3627 let Inst{15-13} = Qd{2-0}; 3628 let Inst{12-8} = 0b01101; 3629 let Inst{7} = Qn{3}; 3630 let Inst{4} = 0b1; 3631 let validForTailPredication = 1; 3632} 3633 3634multiclass MVE_VMULT_fp_m<string iname, MVEVectorVTInfo VTI, SDNode Op, 3635 Intrinsic PredInt, SDPatternOperator IdentityVec> { 3636 def "" : MVE_VMUL_fp<iname, VTI.Suffix, VTI.Size>; 3637 defvar Inst = !cast<Instruction>(NAME); 3638 3639 let Predicates = [HasMVEFloat] in { 3640 defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? ), !cast<Instruction>(NAME), IdentityVec>; 3641 } 3642} 3643 3644multiclass MVE_VMUL_fp_m<MVEVectorVTInfo VTI, SDPatternOperator IdentityVec> 3645 : MVE_VMULT_fp_m<"vmul", VTI, fmul, int_arm_mve_mul_predicated, IdentityVec>; 3646 3647def ARMimmOneF: PatLeaf<(bitconvert (v4f32 (ARMvmovFPImm (i32 112))))>; // 1.0 float 3648def ARMimmOneH: PatLeaf<(bitconvert (v8i16 (ARMvmovImm (i32 2620))))>; // 1.0 half 3649 3650defm MVE_VMULf32 : MVE_VMUL_fp_m<MVE_v4f32, ARMimmOneF>; 3651defm MVE_VMULf16 : MVE_VMUL_fp_m<MVE_v8f16, ARMimmOneH>; 3652 3653class MVE_VCMLA<string suffix, bits<2> size> 3654 : MVEFloatArithNeon<"vcmla", suffix, size{1}, (outs MQPR:$Qd), 3655 (ins MQPR:$Qd_src, MQPR:$Qn, MQPR:$Qm, complexrotateop:$rot), 3656 "$Qd, $Qn, $Qm, $rot", vpred_n, "$Qd = $Qd_src", size, []> { 3657 bits<4> Qd; 3658 bits<4> Qn; 3659 bits<2> rot; 3660 3661 let Inst{28} = 0b1; 3662 let Inst{25} = 0b0; 3663 let Inst{24-23} = rot; 3664 let Inst{22} = Qd{3}; 3665 let Inst{21} = 0b1; 3666 let Inst{19-17} = Qn{2-0}; 3667 let Inst{15-13} = Qd{2-0}; 3668 let Inst{12-8} = 0b01000; 3669 let Inst{7} = Qn{3}; 3670 let Inst{4} = 0b0; 3671} 3672 3673multiclass MVE_VCMLA_m<MVEVectorVTInfo VTI> { 3674 def "" : MVE_VCMLA<VTI.Suffix, VTI.Size>; 3675 defvar Inst = !cast<Instruction>(NAME); 3676 3677 let Predicates = [HasMVEFloat] in { 3678 def : Pat<(VTI.Vec (int_arm_mve_vcmlaq 3679 imm:$rot, (VTI.Vec MQPR:$Qd_src), 3680 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))), 3681 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src), 3682 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 3683 imm:$rot))>; 3684 3685 def: Pat<(VTI.Vec (fadd_contract MQPR:$Qd_src, 3686 (int_arm_mve_vcmulq imm:$rot, 3687 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm)))), 3688 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src), 3689 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 3690 imm:$rot))>; 3691 3692 def : Pat<(VTI.Vec (int_arm_mve_vcmlaq_predicated 3693 imm:$rot, (VTI.Vec MQPR:$Qd_src), 3694 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 3695 (VTI.Pred VCCR:$mask))), 3696 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src), (VTI.Vec MQPR:$Qn), 3697 (VTI.Vec MQPR:$Qm), imm:$rot, 3698 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>; 3699 } 3700} 3701 3702defm MVE_VCMLAf16 : MVE_VCMLA_m<MVE_v8f16>; 3703defm MVE_VCMLAf32 : MVE_VCMLA_m<MVE_v4f32>; 3704 3705class MVE_VADDSUBFMA_fp<string iname, string suffix, bits<2> size, bit bit_4, 3706 bit bit_8, bit bit_21, dag iops=(ins), 3707 vpred_ops vpred=vpred_r, string cstr="", 3708 list<dag> pattern=[]> 3709 : MVEFloatArithNeon<iname, suffix, size{0}, (outs MQPR:$Qd), 3710 !con(iops, (ins MQPR:$Qn, MQPR:$Qm)), "$Qd, $Qn, $Qm", 3711 vpred, cstr, size, pattern> { 3712 bits<4> Qd; 3713 bits<4> Qn; 3714 3715 let Inst{28} = 0b0; 3716 let Inst{25-23} = 0b110; 3717 let Inst{22} = Qd{3}; 3718 let Inst{21} = bit_21; 3719 let Inst{19-17} = Qn{2-0}; 3720 let Inst{15-13} = Qd{2-0}; 3721 let Inst{11-9} = 0b110; 3722 let Inst{8} = bit_8; 3723 let Inst{7} = Qn{3}; 3724 let Inst{4} = bit_4; 3725 let validForTailPredication = 1; 3726} 3727 3728multiclass MVE_VFMA_fp_multi<string iname, bit fms, MVEVectorVTInfo VTI> { 3729 def "" : MVE_VADDSUBFMA_fp<iname, VTI.Suffix, VTI.Size, 0b1, 0b0, fms, 3730 (ins MQPR:$Qd_src), vpred_n, "$Qd = $Qd_src">; 3731 defvar Inst = !cast<Instruction>(NAME); 3732 defvar pred_int = int_arm_mve_fma_predicated; 3733 defvar m1 = (VTI.Vec MQPR:$m1); 3734 defvar m2 = (VTI.Vec MQPR:$m2); 3735 defvar add = (VTI.Vec MQPR:$add); 3736 defvar pred = (VTI.Pred VCCR:$pred); 3737 3738 let Predicates = [HasMVEFloat] in { 3739 if fms then { 3740 def : Pat<(VTI.Vec (fma (fneg m1), m2, add)), 3741 (Inst $add, $m1, $m2)>; 3742 def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred), 3743 (VTI.Vec (fma (fneg m1), m2, add)), 3744 add)), 3745 (Inst $add, $m1, $m2, ARMVCCThen, $pred, zero_reg)>; 3746 def : Pat<(VTI.Vec (pred_int (fneg m1), m2, add, pred)), 3747 (Inst $add, $m1, $m2, ARMVCCThen, $pred, zero_reg)>; 3748 def : Pat<(VTI.Vec (pred_int m1, (fneg m2), add, pred)), 3749 (Inst $add, $m1, $m2, ARMVCCThen, $pred, zero_reg)>; 3750 } else { 3751 def : Pat<(VTI.Vec (fma m1, m2, add)), 3752 (Inst $add, $m1, $m2)>; 3753 def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred), 3754 (VTI.Vec (fma m1, m2, add)), 3755 add)), 3756 (Inst $add, $m1, $m2, ARMVCCThen, $pred, zero_reg)>; 3757 def : Pat<(VTI.Vec (pred_int m1, m2, add, pred)), 3758 (Inst $add, $m1, $m2, ARMVCCThen, $pred, zero_reg)>; 3759 } 3760 } 3761} 3762 3763defm MVE_VFMAf32 : MVE_VFMA_fp_multi<"vfma", 0, MVE_v4f32>; 3764defm MVE_VFMAf16 : MVE_VFMA_fp_multi<"vfma", 0, MVE_v8f16>; 3765defm MVE_VFMSf32 : MVE_VFMA_fp_multi<"vfms", 1, MVE_v4f32>; 3766defm MVE_VFMSf16 : MVE_VFMA_fp_multi<"vfms", 1, MVE_v8f16>; 3767 3768multiclass MVE_VADDSUB_fp_m<string iname, bit bit_21, MVEVectorVTInfo VTI, 3769 SDNode Op, Intrinsic PredInt, SDPatternOperator IdentityVec> { 3770 def "" : MVE_VADDSUBFMA_fp<iname, VTI.Suffix, VTI.Size, 0, 1, bit_21> { 3771 let validForTailPredication = 1; 3772 } 3773 defvar Inst = !cast<Instruction>(NAME); 3774 3775 let Predicates = [HasMVEFloat] in { 3776 defm : MVE_TwoOpPattern<VTI, Op, PredInt, (? ), !cast<Instruction>(NAME), IdentityVec>; 3777 } 3778} 3779 3780multiclass MVE_VADD_fp_m<MVEVectorVTInfo VTI, SDPatternOperator IdentityVec> 3781 : MVE_VADDSUB_fp_m<"vadd", 0, VTI, fadd, int_arm_mve_add_predicated, IdentityVec>; 3782multiclass MVE_VSUB_fp_m<MVEVectorVTInfo VTI, SDPatternOperator IdentityVec> 3783 : MVE_VADDSUB_fp_m<"vsub", 1, VTI, fsub, int_arm_mve_sub_predicated, IdentityVec>; 3784 3785def ARMimmMinusZeroF: PatLeaf<(bitconvert (v4i32 (ARMvmovImm (i32 1664))))>; // -0.0 float 3786def ARMimmMinusZeroH: PatLeaf<(bitconvert (v8i16 (ARMvmovImm (i32 2688))))>; // -0.0 half 3787 3788defm MVE_VADDf32 : MVE_VADD_fp_m<MVE_v4f32, ARMimmMinusZeroF>; 3789defm MVE_VADDf16 : MVE_VADD_fp_m<MVE_v8f16, ARMimmMinusZeroH>; 3790 3791defm MVE_VSUBf32 : MVE_VSUB_fp_m<MVE_v4f32, ARMimmAllZerosV>; 3792defm MVE_VSUBf16 : MVE_VSUB_fp_m<MVE_v8f16, ARMimmAllZerosV>; 3793 3794class MVE_VCADD<string suffix, bits<2> size, string cstr=""> 3795 : MVEFloatArithNeon<"vcadd", suffix, size{1}, (outs MQPR:$Qd), 3796 (ins MQPR:$Qn, MQPR:$Qm, complexrotateopodd:$rot), 3797 "$Qd, $Qn, $Qm, $rot", vpred_r, cstr, size, []> { 3798 bits<4> Qd; 3799 bits<4> Qn; 3800 bit rot; 3801 3802 let Inst{28} = 0b1; 3803 let Inst{25} = 0b0; 3804 let Inst{24} = rot; 3805 let Inst{23} = 0b1; 3806 let Inst{22} = Qd{3}; 3807 let Inst{21} = 0b0; 3808 let Inst{19-17} = Qn{2-0}; 3809 let Inst{15-13} = Qd{2-0}; 3810 let Inst{12-8} = 0b01000; 3811 let Inst{7} = Qn{3}; 3812 let Inst{4} = 0b0; 3813} 3814 3815multiclass MVE_VCADD_m<MVEVectorVTInfo VTI, string cstr=""> { 3816 def "" : MVE_VCADD<VTI.Suffix, VTI.Size, cstr>; 3817 defvar Inst = !cast<Instruction>(NAME); 3818 3819 let Predicates = [HasMVEFloat] in { 3820 def : Pat<(VTI.Vec (int_arm_mve_vcaddq (i32 1), 3821 imm:$rot, (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))), 3822 (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 3823 imm:$rot))>; 3824 3825 def : Pat<(VTI.Vec (int_arm_mve_vcaddq_predicated (i32 1), 3826 imm:$rot, (VTI.Vec MQPR:$inactive), 3827 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 3828 (VTI.Pred VCCR:$mask))), 3829 (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 3830 imm:$rot, ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 3831 (VTI.Vec MQPR:$inactive)))>; 3832 3833 } 3834} 3835 3836defm MVE_VCADDf16 : MVE_VCADD_m<MVE_v8f16>; 3837defm MVE_VCADDf32 : MVE_VCADD_m<MVE_v4f32, "@earlyclobber $Qd">; 3838 3839class MVE_VABD_fp<string suffix, bits<2> size> 3840 : MVE_float<"vabd", suffix, (outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm), 3841 "$Qd, $Qn, $Qm", vpred_r, "", size> { 3842 bits<4> Qd; 3843 bits<4> Qn; 3844 3845 let Inst{28} = 0b1; 3846 let Inst{25-23} = 0b110; 3847 let Inst{22} = Qd{3}; 3848 let Inst{21} = 0b1; 3849 let Inst{20} = size{0}; 3850 let Inst{19-17} = Qn{2-0}; 3851 let Inst{16} = 0b0; 3852 let Inst{15-13} = Qd{2-0}; 3853 let Inst{11-8} = 0b1101; 3854 let Inst{7} = Qn{3}; 3855 let Inst{4} = 0b0; 3856 let validForTailPredication = 1; 3857} 3858 3859multiclass MVE_VABDT_fp_m<MVEVectorVTInfo VTI, 3860 Intrinsic unpred_int, Intrinsic pred_int> { 3861 def "" : MVE_VABD_fp<VTI.Suffix, VTI.Size>; 3862 defvar Inst = !cast<Instruction>(NAME); 3863 3864 let Predicates = [HasMVEFloat] in { 3865 def : Pat<(VTI.Vec (unpred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 3866 (i32 0))), 3867 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>; 3868 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 3869 (i32 0), (VTI.Pred VCCR:$mask), 3870 (VTI.Vec MQPR:$inactive))), 3871 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 3872 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 3873 (VTI.Vec MQPR:$inactive)))>; 3874 } 3875} 3876 3877multiclass MVE_VABD_fp_m<MVEVectorVTInfo VTI> 3878 : MVE_VABDT_fp_m<VTI, int_arm_mve_vabd, int_arm_mve_abd_predicated>; 3879 3880defm MVE_VABDf32 : MVE_VABD_fp_m<MVE_v4f32>; 3881defm MVE_VABDf16 : MVE_VABD_fp_m<MVE_v8f16>; 3882 3883let Predicates = [HasMVEFloat] in { 3884 def : Pat<(v8f16 (fabs (fsub (v8f16 MQPR:$Qm), (v8f16 MQPR:$Qn)))), 3885 (MVE_VABDf16 MQPR:$Qm, MQPR:$Qn)>; 3886 def : Pat<(v4f32 (fabs (fsub (v4f32 MQPR:$Qm), (v4f32 MQPR:$Qn)))), 3887 (MVE_VABDf32 MQPR:$Qm, MQPR:$Qn)>; 3888} 3889 3890class MVE_VCVT_fix<string suffix, bit fsi, bit U, bit op, 3891 Operand imm_operand_type> 3892 : MVE_float<"vcvt", suffix, 3893 (outs MQPR:$Qd), (ins MQPR:$Qm, imm_operand_type:$imm6), 3894 "$Qd, $Qm, $imm6", vpred_r, "", !if(fsi, 0b10, 0b01), []> { 3895 bits<4> Qd; 3896 bits<6> imm6; 3897 3898 let Inst{28} = U; 3899 let Inst{25-23} = 0b111; 3900 let Inst{22} = Qd{3}; 3901 let Inst{21} = 0b1; 3902 let Inst{19-16} = imm6{3-0}; 3903 let Inst{15-13} = Qd{2-0}; 3904 let Inst{11-10} = 0b11; 3905 let Inst{9} = fsi; 3906 let Inst{8} = op; 3907 let Inst{7} = 0b0; 3908 let Inst{4} = 0b1; 3909 3910 let DecoderMethod = "DecodeMVEVCVTt1fp"; 3911 let validForTailPredication = 1; 3912} 3913 3914class MVE_VCVT_imm_asmop<int Bits> : AsmOperandClass { 3915 let PredicateMethod = "isImmediate<1," # Bits # ">"; 3916 let DiagnosticString = 3917 "MVE fixed-point immediate operand must be between 1 and " # Bits; 3918 let Name = "MVEVcvtImm" # Bits; 3919 let RenderMethod = "addImmOperands"; 3920} 3921class MVE_VCVT_imm<int Bits>: Operand<i32> { 3922 let ParserMatchClass = MVE_VCVT_imm_asmop<Bits>; 3923 let EncoderMethod = "getNEONVcvtImm32OpValue"; 3924 let DecoderMethod = "DecodeVCVTImmOperand"; 3925} 3926 3927class MVE_VCVT_fix_f32<string suffix, bit U, bit op> 3928 : MVE_VCVT_fix<suffix, 0b1, U, op, MVE_VCVT_imm<32>> { 3929 let Inst{20} = imm6{4}; 3930} 3931class MVE_VCVT_fix_f16<string suffix, bit U, bit op> 3932 : MVE_VCVT_fix<suffix, 0b0, U, op, MVE_VCVT_imm<16>> { 3933 let Inst{20} = 0b1; 3934} 3935 3936multiclass MVE_VCVT_fix_patterns<Instruction Inst, bit U, MVEVectorVTInfo DestVTI, 3937 MVEVectorVTInfo SrcVTI> { 3938 let Predicates = [HasMVEFloat] in { 3939 def : Pat<(DestVTI.Vec (int_arm_mve_vcvt_fix 3940 (i32 U), (SrcVTI.Vec MQPR:$Qm), imm:$scale)), 3941 (DestVTI.Vec (Inst (SrcVTI.Vec MQPR:$Qm), imm:$scale))>; 3942 def : Pat<(DestVTI.Vec (int_arm_mve_vcvt_fix_predicated (i32 U), 3943 (DestVTI.Vec MQPR:$inactive), 3944 (SrcVTI.Vec MQPR:$Qm), 3945 imm:$scale, 3946 (DestVTI.Pred VCCR:$mask))), 3947 (DestVTI.Vec (Inst (SrcVTI.Vec MQPR:$Qm), imm:$scale, 3948 ARMVCCThen, (DestVTI.Pred VCCR:$mask), zero_reg, 3949 (DestVTI.Vec MQPR:$inactive)))>; 3950 } 3951} 3952 3953multiclass MVE_VCVT_fix_f32_m<bit U, bit op, 3954 MVEVectorVTInfo DestVTI, MVEVectorVTInfo SrcVTI> { 3955 def "" : MVE_VCVT_fix_f32<DestVTI.Suffix#"."#SrcVTI.Suffix, U, op>; 3956 defm : MVE_VCVT_fix_patterns<!cast<Instruction>(NAME), U, DestVTI, SrcVTI>; 3957} 3958 3959multiclass MVE_VCVT_fix_f16_m<bit U, bit op, 3960 MVEVectorVTInfo DestVTI, MVEVectorVTInfo SrcVTI> { 3961 def "" : MVE_VCVT_fix_f16<DestVTI.Suffix#"."#SrcVTI.Suffix, U, op>; 3962 defm : MVE_VCVT_fix_patterns<!cast<Instruction>(NAME), U, DestVTI, SrcVTI>; 3963} 3964 3965defm MVE_VCVTf16s16_fix : MVE_VCVT_fix_f16_m<0b0, 0b0, MVE_v8f16, MVE_v8s16>; 3966defm MVE_VCVTs16f16_fix : MVE_VCVT_fix_f16_m<0b0, 0b1, MVE_v8s16, MVE_v8f16>; 3967defm MVE_VCVTf16u16_fix : MVE_VCVT_fix_f16_m<0b1, 0b0, MVE_v8f16, MVE_v8u16>; 3968defm MVE_VCVTu16f16_fix : MVE_VCVT_fix_f16_m<0b1, 0b1, MVE_v8u16, MVE_v8f16>; 3969defm MVE_VCVTf32s32_fix : MVE_VCVT_fix_f32_m<0b0, 0b0, MVE_v4f32, MVE_v4s32>; 3970defm MVE_VCVTs32f32_fix : MVE_VCVT_fix_f32_m<0b0, 0b1, MVE_v4s32, MVE_v4f32>; 3971defm MVE_VCVTf32u32_fix : MVE_VCVT_fix_f32_m<0b1, 0b0, MVE_v4f32, MVE_v4u32>; 3972defm MVE_VCVTu32f32_fix : MVE_VCVT_fix_f32_m<0b1, 0b1, MVE_v4u32, MVE_v4f32>; 3973 3974class MVE_VCVT_fp_int_anpm<string suffix, bits<2> size, bit op, string anpm, 3975 bits<2> rm, list<dag> pattern=[]> 3976 : MVE_float<!strconcat("vcvt", anpm), suffix, (outs MQPR:$Qd), 3977 (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", size, pattern> { 3978 bits<4> Qd; 3979 3980 let Inst{28} = 0b1; 3981 let Inst{25-23} = 0b111; 3982 let Inst{22} = Qd{3}; 3983 let Inst{21-20} = 0b11; 3984 let Inst{19-18} = size; 3985 let Inst{17-16} = 0b11; 3986 let Inst{15-13} = Qd{2-0}; 3987 let Inst{12-10} = 0b000; 3988 let Inst{9-8} = rm; 3989 let Inst{7} = op; 3990 let Inst{4} = 0b0; 3991 let validForTailPredication = 1; 3992} 3993 3994multiclass MVE_VCVT_fp_int_anpm_inner<MVEVectorVTInfo Int, MVEVectorVTInfo Flt, 3995 string anpm, bits<2> rm> { 3996 def "": MVE_VCVT_fp_int_anpm<Int.Suffix # "." # Flt.Suffix, Int.Size, 3997 Int.Unsigned, anpm, rm>; 3998 3999 defvar Inst = !cast<Instruction>(NAME); 4000 defvar IntrBaseName = "int_arm_mve_vcvt" # anpm; 4001 defvar UnpredIntr = !cast<Intrinsic>(IntrBaseName); 4002 defvar PredIntr = !cast<Intrinsic>(IntrBaseName # "_predicated"); 4003 4004 let Predicates = [HasMVEFloat] in { 4005 def : Pat<(Int.Vec (UnpredIntr (i32 Int.Unsigned), (Flt.Vec MQPR:$in))), 4006 (Int.Vec (Inst (Flt.Vec MQPR:$in)))>; 4007 4008 def : Pat<(Int.Vec (PredIntr (i32 Int.Unsigned), (Int.Vec MQPR:$inactive), 4009 (Flt.Vec MQPR:$in), (Flt.Pred VCCR:$pred))), 4010 (Int.Vec (Inst (Flt.Vec MQPR:$in), ARMVCCThen, 4011 (Flt.Pred VCCR:$pred), zero_reg, (Int.Vec MQPR:$inactive)))>; 4012 } 4013} 4014 4015multiclass MVE_VCVT_fp_int_anpm_outer<MVEVectorVTInfo Int, 4016 MVEVectorVTInfo Flt> { 4017 defm a : MVE_VCVT_fp_int_anpm_inner<Int, Flt, "a", 0b00>; 4018 defm n : MVE_VCVT_fp_int_anpm_inner<Int, Flt, "n", 0b01>; 4019 defm p : MVE_VCVT_fp_int_anpm_inner<Int, Flt, "p", 0b10>; 4020 defm m : MVE_VCVT_fp_int_anpm_inner<Int, Flt, "m", 0b11>; 4021} 4022 4023// This defines instructions such as MVE_VCVTu16f16a, with an explicit 4024// rounding-mode suffix on the mnemonic. The class below will define 4025// the bare MVE_VCVTu16f16 (with implied rounding toward zero). 4026defm MVE_VCVTs16f16 : MVE_VCVT_fp_int_anpm_outer<MVE_v8s16, MVE_v8f16>; 4027defm MVE_VCVTu16f16 : MVE_VCVT_fp_int_anpm_outer<MVE_v8u16, MVE_v8f16>; 4028defm MVE_VCVTs32f32 : MVE_VCVT_fp_int_anpm_outer<MVE_v4s32, MVE_v4f32>; 4029defm MVE_VCVTu32f32 : MVE_VCVT_fp_int_anpm_outer<MVE_v4u32, MVE_v4f32>; 4030 4031class MVE_VCVT_fp_int<string suffix, bits<2> size, bit toint, bit unsigned, 4032 list<dag> pattern=[]> 4033 : MVE_float<"vcvt", suffix, (outs MQPR:$Qd), 4034 (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", size, pattern> { 4035 bits<4> Qd; 4036 4037 let Inst{28} = 0b1; 4038 let Inst{25-23} = 0b111; 4039 let Inst{22} = Qd{3}; 4040 let Inst{21-20} = 0b11; 4041 let Inst{19-18} = size; 4042 let Inst{17-16} = 0b11; 4043 let Inst{15-13} = Qd{2-0}; 4044 let Inst{12-9} = 0b0011; 4045 let Inst{8} = toint; 4046 let Inst{7} = unsigned; 4047 let Inst{4} = 0b0; 4048 let validForTailPredication = 1; 4049} 4050 4051multiclass MVE_VCVT_fp_int_m<MVEVectorVTInfo Dest, MVEVectorVTInfo Src, 4052 SDNode unpred_op> { 4053 defvar Unsigned = !or(!eq(Dest.SuffixLetter,"u"), !eq(Src.SuffixLetter,"u")); 4054 defvar ToInt = !eq(Src.SuffixLetter,"f"); 4055 4056 def "" : MVE_VCVT_fp_int<Dest.Suffix # "." # Src.Suffix, Dest.Size, 4057 ToInt, Unsigned>; 4058 defvar Inst = !cast<Instruction>(NAME); 4059 4060 let Predicates = [HasMVEFloat] in { 4061 def : Pat<(Dest.Vec (unpred_op (Src.Vec MQPR:$src))), 4062 (Dest.Vec (Inst (Src.Vec MQPR:$src)))>; 4063 def : Pat<(Dest.Vec (int_arm_mve_vcvt_fp_int_predicated 4064 (Src.Vec MQPR:$src), (i32 Unsigned), 4065 (Src.Pred VCCR:$mask), (Dest.Vec MQPR:$inactive))), 4066 (Dest.Vec (Inst (Src.Vec MQPR:$src), ARMVCCThen, 4067 (Src.Pred VCCR:$mask), zero_reg, 4068 (Dest.Vec MQPR:$inactive)))>; 4069 } 4070} 4071// The unsuffixed VCVT for float->int implicitly rounds toward zero, 4072// which I reflect here in the llvm instruction names 4073defm MVE_VCVTs16f16z : MVE_VCVT_fp_int_m<MVE_v8s16, MVE_v8f16, fp_to_sint>; 4074defm MVE_VCVTu16f16z : MVE_VCVT_fp_int_m<MVE_v8u16, MVE_v8f16, fp_to_uint>; 4075defm MVE_VCVTs32f32z : MVE_VCVT_fp_int_m<MVE_v4s32, MVE_v4f32, fp_to_sint>; 4076defm MVE_VCVTu32f32z : MVE_VCVT_fp_int_m<MVE_v4u32, MVE_v4f32, fp_to_uint>; 4077// Whereas VCVT for int->float rounds to nearest 4078defm MVE_VCVTf16s16n : MVE_VCVT_fp_int_m<MVE_v8f16, MVE_v8s16, sint_to_fp>; 4079defm MVE_VCVTf16u16n : MVE_VCVT_fp_int_m<MVE_v8f16, MVE_v8u16, uint_to_fp>; 4080defm MVE_VCVTf32s32n : MVE_VCVT_fp_int_m<MVE_v4f32, MVE_v4s32, sint_to_fp>; 4081defm MVE_VCVTf32u32n : MVE_VCVT_fp_int_m<MVE_v4f32, MVE_v4u32, uint_to_fp>; 4082 4083let Predicates = [HasMVEFloat] in { 4084 def : Pat<(v4i32 (fp_to_sint_sat v4f32:$src, i32)), 4085 (MVE_VCVTs32f32z v4f32:$src)>; 4086 def : Pat<(v4i32 (fp_to_uint_sat v4f32:$src, i32)), 4087 (MVE_VCVTu32f32z v4f32:$src)>; 4088 def : Pat<(v8i16 (fp_to_sint_sat v8f16:$src, i16)), 4089 (MVE_VCVTs16f16z v8f16:$src)>; 4090 def : Pat<(v8i16 (fp_to_uint_sat v8f16:$src, i16)), 4091 (MVE_VCVTu16f16z v8f16:$src)>; 4092} 4093 4094class MVE_VABSNEG_fp<string iname, string suffix, bits<2> size, bit negate, 4095 list<dag> pattern=[]> 4096 : MVE_float<iname, suffix, (outs MQPR:$Qd), 4097 (ins MQPR:$Qm), "$Qd, $Qm", vpred_r, "", size, pattern> { 4098 bits<4> Qd; 4099 4100 let Inst{28} = 0b1; 4101 let Inst{25-23} = 0b111; 4102 let Inst{22} = Qd{3}; 4103 let Inst{21-20} = 0b11; 4104 let Inst{19-18} = size; 4105 let Inst{17-16} = 0b01; 4106 let Inst{15-13} = Qd{2-0}; 4107 let Inst{11-8} = 0b0111; 4108 let Inst{7} = negate; 4109 let Inst{4} = 0b0; 4110 let validForTailPredication = 1; 4111} 4112 4113multiclass MVE_VABSNEG_fp_m<string iname, SDNode unpred_op, Intrinsic pred_int, 4114 MVEVectorVTInfo VTI, bit opcode> { 4115 def "" : MVE_VABSNEG_fp<iname, VTI.Suffix, VTI.Size, opcode>; 4116 defvar Inst = !cast<Instruction>(NAME); 4117 4118 let Predicates = [HasMVEInt] in { 4119 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$v))), 4120 (VTI.Vec (Inst $v))>; 4121 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$v), (VTI.Pred VCCR:$mask), 4122 (VTI.Vec MQPR:$inactive))), 4123 (VTI.Vec (Inst $v, ARMVCCThen, $mask, zero_reg, $inactive))>; 4124 } 4125} 4126 4127defm MVE_VABSf16 : MVE_VABSNEG_fp_m<"vabs", fabs, int_arm_mve_abs_predicated, 4128 MVE_v8f16, 0>; 4129defm MVE_VABSf32 : MVE_VABSNEG_fp_m<"vabs", fabs, int_arm_mve_abs_predicated, 4130 MVE_v4f32, 0>; 4131defm MVE_VNEGf16 : MVE_VABSNEG_fp_m<"vneg", fneg, int_arm_mve_neg_predicated, 4132 MVE_v8f16, 1>; 4133defm MVE_VNEGf32 : MVE_VABSNEG_fp_m<"vneg", fneg, int_arm_mve_neg_predicated, 4134 MVE_v4f32, 1>; 4135 4136class MVE_VMAXMINNMA<string iname, string suffix, bits<2> size, bit bit_12, 4137 list<dag> pattern=[]> 4138 : MVE_f<(outs MQPR:$Qd), (ins MQPR:$Qd_src, MQPR:$Qm), 4139 NoItinerary, iname, suffix, "$Qd, $Qm", vpred_n, "$Qd = $Qd_src", 4140 size, pattern> { 4141 bits<4> Qd; 4142 bits<4> Qm; 4143 4144 let Inst{28} = size{0}; 4145 let Inst{25-23} = 0b100; 4146 let Inst{22} = Qd{3}; 4147 let Inst{21-16} = 0b111111; 4148 let Inst{15-13} = Qd{2-0}; 4149 let Inst{12} = bit_12; 4150 let Inst{11-6} = 0b111010; 4151 let Inst{5} = Qm{3}; 4152 let Inst{4} = 0b0; 4153 let Inst{3-1} = Qm{2-0}; 4154 let Inst{0} = 0b1; 4155 4156 let isCommutable = 1; 4157 let validForTailPredication = 1; 4158} 4159 4160multiclass MVE_VMAXMINNMA_m<string iname, MVEVectorVTInfo VTI, 4161 SDNode unpred_op, Intrinsic pred_int, 4162 bit bit_12> { 4163 def "" : MVE_VMAXMINNMA<iname, VTI.Suffix, VTI.Size, bit_12>; 4164 defvar Inst = !cast<Instruction>(NAME); 4165 4166 let Predicates = [HasMVEInt] in { 4167 // Unpredicated v(max|min)nma 4168 def : Pat<(VTI.Vec (unpred_op (fabs (VTI.Vec MQPR:$Qd)), 4169 (fabs (VTI.Vec MQPR:$Qm)))), 4170 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm)))>; 4171 4172 // Predicated v(max|min)nma 4173 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm), 4174 (VTI.Pred VCCR:$mask))), 4175 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm), 4176 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>; 4177 } 4178} 4179 4180multiclass MVE_VMAXNMA<MVEVectorVTInfo VTI, bit bit_12> 4181 : MVE_VMAXMINNMA_m<"vmaxnma", VTI, fmaxnum, int_arm_mve_vmaxnma_predicated, bit_12>; 4182 4183defm MVE_VMAXNMAf32 : MVE_VMAXNMA<MVE_v4f32, 0b0>; 4184defm MVE_VMAXNMAf16 : MVE_VMAXNMA<MVE_v8f16, 0b0>; 4185 4186multiclass MVE_VMINNMA<MVEVectorVTInfo VTI, bit bit_12> 4187 : MVE_VMAXMINNMA_m<"vminnma", VTI, fminnum, int_arm_mve_vminnma_predicated, bit_12>; 4188 4189defm MVE_VMINNMAf32 : MVE_VMINNMA<MVE_v4f32, 0b1>; 4190defm MVE_VMINNMAf16 : MVE_VMINNMA<MVE_v8f16, 0b1>; 4191 4192// end of MVE Floating Point instructions 4193 4194// start of MVE compares 4195 4196class MVE_VCMPqq<string suffix, bit bit_28, bits<2> bits_21_20, 4197 VCMPPredicateOperand predtype, bits<2> vecsize, list<dag> pattern=[]> 4198 : MVE_p<(outs VCCR:$P0), (ins MQPR:$Qn, MQPR:$Qm, predtype:$fc), 4199 NoItinerary, "vcmp", suffix, "$fc, $Qn, $Qm", vpred_n, "", vecsize, pattern> { 4200 // Base class for comparing two vector registers 4201 bits<3> fc; 4202 bits<4> Qn; 4203 bits<4> Qm; 4204 4205 let Inst{28} = bit_28; 4206 let Inst{25-22} = 0b1000; 4207 let Inst{21-20} = bits_21_20; 4208 let Inst{19-17} = Qn{2-0}; 4209 let Inst{16-13} = 0b1000; 4210 let Inst{12} = fc{2}; 4211 let Inst{11-8} = 0b1111; 4212 let Inst{7} = fc{0}; 4213 let Inst{6} = 0b0; 4214 let Inst{5} = Qm{3}; 4215 let Inst{4} = 0b0; 4216 let Inst{3-1} = Qm{2-0}; 4217 let Inst{0} = fc{1}; 4218 4219 let Constraints = ""; 4220 4221 // We need a custom decoder method for these instructions because of 4222 // the output VCCR operand, which isn't encoded in the instruction 4223 // bits anywhere (there is only one choice for it) but has to be 4224 // included in the MC operands so that codegen will be able to track 4225 // its data flow between instructions, spill/reload it when 4226 // necessary, etc. There seems to be no way to get the Tablegen 4227 // decoder to emit an operand that isn't affected by any instruction 4228 // bit. 4229 let DecoderMethod = "DecodeMVEVCMP<false," # predtype.DecoderMethod # ">"; 4230 let validForTailPredication = 1; 4231} 4232 4233class MVE_VCMPqqf<string suffix, bit size> 4234 : MVE_VCMPqq<suffix, size, 0b11, pred_basic_fp, !if(size, 0b01, 0b10)> { 4235 let Predicates = [HasMVEFloat]; 4236} 4237 4238class MVE_VCMPqqi<string suffix, bits<2> size> 4239 : MVE_VCMPqq<suffix, 0b1, size, pred_basic_i, size> { 4240 let Inst{12} = 0b0; 4241 let Inst{0} = 0b0; 4242} 4243 4244class MVE_VCMPqqu<string suffix, bits<2> size> 4245 : MVE_VCMPqq<suffix, 0b1, size, pred_basic_u, size> { 4246 let Inst{12} = 0b0; 4247 let Inst{0} = 0b1; 4248} 4249 4250class MVE_VCMPqqs<string suffix, bits<2> size> 4251 : MVE_VCMPqq<suffix, 0b1, size, pred_basic_s, size> { 4252 let Inst{12} = 0b1; 4253} 4254 4255def MVE_VCMPf32 : MVE_VCMPqqf<"f32", 0b0>; 4256def MVE_VCMPf16 : MVE_VCMPqqf<"f16", 0b1>; 4257 4258def MVE_VCMPi8 : MVE_VCMPqqi<"i8", 0b00>; 4259def MVE_VCMPi16 : MVE_VCMPqqi<"i16", 0b01>; 4260def MVE_VCMPi32 : MVE_VCMPqqi<"i32", 0b10>; 4261 4262def MVE_VCMPu8 : MVE_VCMPqqu<"u8", 0b00>; 4263def MVE_VCMPu16 : MVE_VCMPqqu<"u16", 0b01>; 4264def MVE_VCMPu32 : MVE_VCMPqqu<"u32", 0b10>; 4265 4266def MVE_VCMPs8 : MVE_VCMPqqs<"s8", 0b00>; 4267def MVE_VCMPs16 : MVE_VCMPqqs<"s16", 0b01>; 4268def MVE_VCMPs32 : MVE_VCMPqqs<"s32", 0b10>; 4269 4270class MVE_VCMPqr<string suffix, bit bit_28, bits<2> bits_21_20, 4271 VCMPPredicateOperand predtype, bits<2> vecsize, list<dag> pattern=[]> 4272 : MVE_p<(outs VCCR:$P0), (ins MQPR:$Qn, GPRwithZR:$Rm, predtype:$fc), 4273 NoItinerary, "vcmp", suffix, "$fc, $Qn, $Rm", vpred_n, "", vecsize, pattern> { 4274 // Base class for comparing a vector register with a scalar 4275 bits<3> fc; 4276 bits<4> Qn; 4277 bits<4> Rm; 4278 4279 let Inst{28} = bit_28; 4280 let Inst{25-22} = 0b1000; 4281 let Inst{21-20} = bits_21_20; 4282 let Inst{19-17} = Qn{2-0}; 4283 let Inst{16-13} = 0b1000; 4284 let Inst{12} = fc{2}; 4285 let Inst{11-8} = 0b1111; 4286 let Inst{7} = fc{0}; 4287 let Inst{6} = 0b1; 4288 let Inst{5} = fc{1}; 4289 let Inst{4} = 0b0; 4290 let Inst{3-0} = Rm{3-0}; 4291 4292 let Constraints = ""; 4293 // Custom decoder method, for the same reason as MVE_VCMPqq 4294 let DecoderMethod = "DecodeMVEVCMP<true," # predtype.DecoderMethod # ">"; 4295 let validForTailPredication = 1; 4296} 4297 4298class MVE_VCMPqrf<string suffix, bit size> 4299 : MVE_VCMPqr<suffix, size, 0b11, pred_basic_fp, !if(size, 0b01, 0b10)> { 4300 let Predicates = [HasMVEFloat]; 4301} 4302 4303class MVE_VCMPqri<string suffix, bits<2> size> 4304 : MVE_VCMPqr<suffix, 0b1, size, pred_basic_i, size> { 4305 let Inst{12} = 0b0; 4306 let Inst{5} = 0b0; 4307} 4308 4309class MVE_VCMPqru<string suffix, bits<2> size> 4310 : MVE_VCMPqr<suffix, 0b1, size, pred_basic_u, size> { 4311 let Inst{12} = 0b0; 4312 let Inst{5} = 0b1; 4313} 4314 4315class MVE_VCMPqrs<string suffix, bits<2> size> 4316 : MVE_VCMPqr<suffix, 0b1, size, pred_basic_s, size> { 4317 let Inst{12} = 0b1; 4318} 4319 4320def MVE_VCMPf32r : MVE_VCMPqrf<"f32", 0b0>; 4321def MVE_VCMPf16r : MVE_VCMPqrf<"f16", 0b1>; 4322 4323def MVE_VCMPi8r : MVE_VCMPqri<"i8", 0b00>; 4324def MVE_VCMPi16r : MVE_VCMPqri<"i16", 0b01>; 4325def MVE_VCMPi32r : MVE_VCMPqri<"i32", 0b10>; 4326 4327def MVE_VCMPu8r : MVE_VCMPqru<"u8", 0b00>; 4328def MVE_VCMPu16r : MVE_VCMPqru<"u16", 0b01>; 4329def MVE_VCMPu32r : MVE_VCMPqru<"u32", 0b10>; 4330 4331def MVE_VCMPs8r : MVE_VCMPqrs<"s8", 0b00>; 4332def MVE_VCMPs16r : MVE_VCMPqrs<"s16", 0b01>; 4333def MVE_VCMPs32r : MVE_VCMPqrs<"s32", 0b10>; 4334 4335multiclass unpred_vcmp_z<string suffix, PatLeaf fc> { 4336 def i8 : Pat<(v16i1 (ARMvcmpz (v16i8 MQPR:$v1), fc)), 4337 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), ZR, fc))>; 4338 def i16 : Pat<(v8i1 (ARMvcmpz (v8i16 MQPR:$v1), fc)), 4339 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), ZR, fc))>; 4340 def i32 : Pat<(v4i1 (ARMvcmpz (v4i32 MQPR:$v1), fc)), 4341 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), ZR, fc))>; 4342 4343 def : Pat<(v16i1 (and (v16i1 VCCR:$p1), (v16i1 (ARMvcmpz (v16i8 MQPR:$v1), fc)))), 4344 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), ZR, fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4345 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmpz (v8i16 MQPR:$v1), fc)))), 4346 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), ZR, fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4347 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmpz (v4i32 MQPR:$v1), fc)))), 4348 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), ZR, fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4349} 4350 4351multiclass unpred_vcmp_r<string suffix, PatLeaf fc> { 4352 def i8 : Pat<(v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), fc)), 4353 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8") (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), fc))>; 4354 def i16 : Pat<(v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), fc)), 4355 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16") (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), fc))>; 4356 def i32 : Pat<(v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), fc)), 4357 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32") (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), fc))>; 4358 4359 def i8r : Pat<(v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 (ARMvdup rGPR:$v2)), fc)), 4360 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), (i32 rGPR:$v2), fc))>; 4361 def i16r : Pat<(v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 (ARMvdup rGPR:$v2)), fc)), 4362 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), (i32 rGPR:$v2), fc))>; 4363 def i32r : Pat<(v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 (ARMvdup rGPR:$v2)), fc)), 4364 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), (i32 rGPR:$v2), fc))>; 4365 4366 def : Pat<(v16i1 (and (v16i1 VCCR:$p1), (v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), fc)))), 4367 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8") (v16i8 MQPR:$v1), (v16i8 MQPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4368 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), fc)))), 4369 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16") (v8i16 MQPR:$v1), (v8i16 MQPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4370 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), fc)))), 4371 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32") (v4i32 MQPR:$v1), (v4i32 MQPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4372 4373 def : Pat<(v16i1 (and (v16i1 VCCR:$p1), (v16i1 (ARMvcmp (v16i8 MQPR:$v1), (v16i8 (ARMvdup rGPR:$v2)), fc)))), 4374 (v16i1 (!cast<Instruction>("MVE_VCMP"#suffix#"8r") (v16i8 MQPR:$v1), (i32 rGPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4375 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8i16 MQPR:$v1), (v8i16 (ARMvdup rGPR:$v2)), fc)))), 4376 (v8i1 (!cast<Instruction>("MVE_VCMP"#suffix#"16r") (v8i16 MQPR:$v1), (i32 rGPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4377 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4i32 MQPR:$v1), (v4i32 (ARMvdup rGPR:$v2)), fc)))), 4378 (v4i1 (!cast<Instruction>("MVE_VCMP"#suffix#"32r") (v4i32 MQPR:$v1), (i32 rGPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4379} 4380 4381multiclass unpred_vcmpf_z<PatLeaf fc> { 4382 def f16 : Pat<(v8i1 (ARMvcmpz (v8f16 MQPR:$v1), fc)), 4383 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), ZR, fc))>; 4384 def f32 : Pat<(v4i1 (ARMvcmpz (v4f32 MQPR:$v1), fc)), 4385 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, fc))>; 4386 4387 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmpz (v8f16 MQPR:$v1), fc)))), 4388 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), ZR, fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4389 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmpz (v4f32 MQPR:$v1), fc)))), 4390 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4391} 4392 4393multiclass unpred_vcmpf_r<PatLeaf fc> { 4394 def : Pat<(v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), fc)), 4395 (v8i1 (MVE_VCMPf16 (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), fc))>; 4396 def : Pat<(v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), fc)), 4397 (v4i1 (MVE_VCMPf32 (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), fc))>; 4398 4399 def : Pat<(v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 (ARMvdup rGPR:$v2)), fc)), 4400 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), (i32 rGPR:$v2), fc))>; 4401 def : Pat<(v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 (ARMvdup rGPR:$v2)), fc)), 4402 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), (i32 rGPR:$v2), fc))>; 4403 4404 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), fc)))), 4405 (v8i1 (MVE_VCMPf16 (v8f16 MQPR:$v1), (v8f16 MQPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4406 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), fc)))), 4407 (v4i1 (MVE_VCMPf32 (v4f32 MQPR:$v1), (v4f32 MQPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4408 4409 def : Pat<(v8i1 (and (v8i1 VCCR:$p1), (v8i1 (ARMvcmp (v8f16 MQPR:$v1), (v8f16 (ARMvdup rGPR:$v2)), fc)))), 4410 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), (i32 rGPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4411 def : Pat<(v4i1 (and (v4i1 VCCR:$p1), (v4i1 (ARMvcmp (v4f32 MQPR:$v1), (v4f32 (ARMvdup rGPR:$v2)), fc)))), 4412 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), (i32 rGPR:$v2), fc, ARMVCCThen, VCCR:$p1, zero_reg))>; 4413} 4414 4415let Predicates = [HasMVEInt] in { 4416 defm MVE_VCEQZ : unpred_vcmp_z<"i", ARMCCeq>; 4417 defm MVE_VCNEZ : unpred_vcmp_z<"i", ARMCCne>; 4418 defm MVE_VCGEZ : unpred_vcmp_z<"s", ARMCCge>; 4419 defm MVE_VCLTZ : unpred_vcmp_z<"s", ARMCClt>; 4420 defm MVE_VCGTZ : unpred_vcmp_z<"s", ARMCCgt>; 4421 defm MVE_VCLEZ : unpred_vcmp_z<"s", ARMCCle>; 4422 defm MVE_VCGTUZ : unpred_vcmp_z<"u", ARMCChi>; 4423 defm MVE_VCGEUZ : unpred_vcmp_z<"u", ARMCChs>; 4424 4425 defm MVE_VCEQ : unpred_vcmp_r<"i", ARMCCeq>; 4426 defm MVE_VCNE : unpred_vcmp_r<"i", ARMCCne>; 4427 defm MVE_VCGE : unpred_vcmp_r<"s", ARMCCge>; 4428 defm MVE_VCLT : unpred_vcmp_r<"s", ARMCClt>; 4429 defm MVE_VCGT : unpred_vcmp_r<"s", ARMCCgt>; 4430 defm MVE_VCLE : unpred_vcmp_r<"s", ARMCCle>; 4431 defm MVE_VCGTU : unpred_vcmp_r<"u", ARMCChi>; 4432 defm MVE_VCGEU : unpred_vcmp_r<"u", ARMCChs>; 4433} 4434 4435let Predicates = [HasMVEFloat] in { 4436 defm MVE_VFCEQZ : unpred_vcmpf_z<ARMCCeq>; 4437 defm MVE_VFCNEZ : unpred_vcmpf_z<ARMCCne>; 4438 defm MVE_VFCGEZ : unpred_vcmpf_z<ARMCCge>; 4439 defm MVE_VFCLTZ : unpred_vcmpf_z<ARMCClt>; 4440 defm MVE_VFCGTZ : unpred_vcmpf_z<ARMCCgt>; 4441 defm MVE_VFCLEZ : unpred_vcmpf_z<ARMCCle>; 4442 4443 defm MVE_VFCEQ : unpred_vcmpf_r<ARMCCeq>; 4444 defm MVE_VFCNE : unpred_vcmpf_r<ARMCCne>; 4445 defm MVE_VFCGE : unpred_vcmpf_r<ARMCCge>; 4446 defm MVE_VFCLT : unpred_vcmpf_r<ARMCClt>; 4447 defm MVE_VFCGT : unpred_vcmpf_r<ARMCCgt>; 4448 defm MVE_VFCLE : unpred_vcmpf_r<ARMCCle>; 4449} 4450 4451 4452// Extra "worst case" and/or/xor patterns, going into and out of GRP 4453multiclass two_predops<SDPatternOperator opnode, Instruction insn> { 4454 def v16i1 : Pat<(v16i1 (opnode (v16i1 VCCR:$p1), (v16i1 VCCR:$p2))), 4455 (v16i1 (COPY_TO_REGCLASS 4456 (insn (i32 (COPY_TO_REGCLASS (v16i1 VCCR:$p1), rGPR)), 4457 (i32 (COPY_TO_REGCLASS (v16i1 VCCR:$p2), rGPR))), 4458 VCCR))>; 4459 def v8i1 : Pat<(v8i1 (opnode (v8i1 VCCR:$p1), (v8i1 VCCR:$p2))), 4460 (v8i1 (COPY_TO_REGCLASS 4461 (insn (i32 (COPY_TO_REGCLASS (v8i1 VCCR:$p1), rGPR)), 4462 (i32 (COPY_TO_REGCLASS (v8i1 VCCR:$p2), rGPR))), 4463 VCCR))>; 4464 def v4i1 : Pat<(v4i1 (opnode (v4i1 VCCR:$p1), (v4i1 VCCR:$p2))), 4465 (v4i1 (COPY_TO_REGCLASS 4466 (insn (i32 (COPY_TO_REGCLASS (v4i1 VCCR:$p1), rGPR)), 4467 (i32 (COPY_TO_REGCLASS (v4i1 VCCR:$p2), rGPR))), 4468 VCCR))>; 4469 def v2i1 : Pat<(v2i1 (opnode (v2i1 VCCR:$p1), (v2i1 VCCR:$p2))), 4470 (v2i1 (COPY_TO_REGCLASS 4471 (insn (i32 (COPY_TO_REGCLASS (v2i1 VCCR:$p1), rGPR)), 4472 (i32 (COPY_TO_REGCLASS (v2i1 VCCR:$p2), rGPR))), 4473 VCCR))>; 4474} 4475 4476let Predicates = [HasMVEInt] in { 4477 defm POR : two_predops<or, t2ORRrr>; 4478 defm PAND : two_predops<and, t2ANDrr>; 4479 defm PEOR : two_predops<xor, t2EORrr>; 4480} 4481 4482// Occasionally we need to cast between a i32 and a boolean vector, for 4483// example when moving between rGPR and VPR.P0 as part of predicate vector 4484// shuffles. We also sometimes need to cast between different predicate 4485// vector types (v4i1<>v8i1, etc.) also as part of lowering vector shuffles. 4486def predicate_cast : SDNode<"ARMISD::PREDICATE_CAST", SDTUnaryOp>; 4487 4488def load_align4 : PatFrag<(ops node:$ptr), (load node:$ptr), [{ 4489 return cast<LoadSDNode>(N)->getAlign() >= 4; 4490}]>; 4491 4492let Predicates = [HasMVEInt] in { 4493 foreach VT = [ v2i1, v4i1, v8i1, v16i1 ] in { 4494 def : Pat<(i32 (predicate_cast (VT VCCR:$src))), 4495 (i32 (COPY_TO_REGCLASS (VT VCCR:$src), VCCR))>; 4496 def : Pat<(VT (predicate_cast (i32 VCCR:$src))), 4497 (VT (COPY_TO_REGCLASS (i32 VCCR:$src), VCCR))>; 4498 4499 foreach VT2 = [ v2i1, v4i1, v8i1, v16i1 ] in 4500 def : Pat<(VT (predicate_cast (VT2 VCCR:$src))), 4501 (VT (COPY_TO_REGCLASS (VT2 VCCR:$src), VCCR))>; 4502 } 4503 4504 // If we happen to be casting from a load we can convert that straight 4505 // into a predicate load, so long as the load is of the correct type. 4506 foreach VT = [ v2i1, v4i1, v8i1, v16i1 ] in { 4507 def : Pat<(VT (predicate_cast (i32 (load_align4 taddrmode_imm7<2>:$addr)))), 4508 (VT (VLDR_P0_off taddrmode_imm7<2>:$addr))>; 4509 } 4510 4511 // Here we match the specific SDNode type 'ARMVectorRegCastImpl' 4512 // rather than the more general 'ARMVectorRegCast' which would also 4513 // match some bitconverts. If we use the latter in cases where the 4514 // input and output types are the same, the bitconvert gets elided 4515 // and we end up generating a nonsense match of nothing. 4516 4517 foreach VT = [ v16i8, v8i16, v8f16, v4i32, v4f32, v2i64, v2f64 ] in 4518 foreach VT2 = [ v16i8, v8i16, v8f16, v4i32, v4f32, v2i64, v2f64 ] in 4519 def : Pat<(VT (ARMVectorRegCastImpl (VT2 MQPR:$src))), 4520 (VT MQPR:$src)>; 4521} 4522 4523// end of MVE compares 4524 4525// start of MVE_qDest_qSrc 4526 4527class MVE_qDest_qSrc<string iname, string suffix, dag oops, dag iops, 4528 string ops, vpred_ops vpred, string cstr, 4529 bits<2> vecsize, list<dag> pattern=[]> 4530 : MVE_p<oops, iops, NoItinerary, iname, suffix, 4531 ops, vpred, cstr, vecsize, pattern> { 4532 bits<4> Qd; 4533 bits<4> Qm; 4534 4535 let Inst{25-23} = 0b100; 4536 let Inst{22} = Qd{3}; 4537 let Inst{15-13} = Qd{2-0}; 4538 let Inst{11-9} = 0b111; 4539 let Inst{6} = 0b0; 4540 let Inst{5} = Qm{3}; 4541 let Inst{4} = 0b0; 4542 let Inst{3-1} = Qm{2-0}; 4543} 4544 4545class MVE_VQxDMLxDH<string iname, bit exch, bit round, bit subtract, 4546 string suffix, bits<2> size, string cstr="", 4547 list<dag> pattern=[]> 4548 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd), 4549 (ins MQPR:$Qd_src, MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm", 4550 vpred_n, "$Qd = $Qd_src"#cstr, size, pattern> { 4551 bits<4> Qn; 4552 4553 let Inst{28} = subtract; 4554 let Inst{21-20} = size; 4555 let Inst{19-17} = Qn{2-0}; 4556 let Inst{16} = 0b0; 4557 let Inst{12} = exch; 4558 let Inst{8} = 0b0; 4559 let Inst{7} = Qn{3}; 4560 let Inst{0} = round; 4561} 4562 4563multiclass MVE_VQxDMLxDH_p<string iname, bit exch, bit round, bit subtract, 4564 MVEVectorVTInfo VTI> { 4565 def "": MVE_VQxDMLxDH<iname, exch, round, subtract, VTI.Suffix, VTI.Size, 4566 !if(!eq(VTI.LaneBits, 32), ",@earlyclobber $Qd", "")>; 4567 defvar Inst = !cast<Instruction>(NAME); 4568 defvar ConstParams = (? (i32 exch), (i32 round), (i32 subtract)); 4569 defvar unpred_intr = int_arm_mve_vqdmlad; 4570 defvar pred_intr = int_arm_mve_vqdmlad_predicated; 4571 4572 def : Pat<(VTI.Vec !con((unpred_intr (VTI.Vec MQPR:$a), (VTI.Vec MQPR:$b), 4573 (VTI.Vec MQPR:$c)), ConstParams)), 4574 (VTI.Vec (Inst (VTI.Vec MQPR:$a), (VTI.Vec MQPR:$b), 4575 (VTI.Vec MQPR:$c)))>; 4576 def : Pat<(VTI.Vec !con((pred_intr (VTI.Vec MQPR:$a), (VTI.Vec MQPR:$b), 4577 (VTI.Vec MQPR:$c)), ConstParams, 4578 (? (VTI.Pred VCCR:$pred)))), 4579 (VTI.Vec (Inst (VTI.Vec MQPR:$a), (VTI.Vec MQPR:$b), 4580 (VTI.Vec MQPR:$c), 4581 ARMVCCThen, (VTI.Pred VCCR:$pred), zero_reg))>; 4582} 4583 4584multiclass MVE_VQxDMLxDH_multi<string iname, bit exch, 4585 bit round, bit subtract> { 4586 defm s8 : MVE_VQxDMLxDH_p<iname, exch, round, subtract, MVE_v16s8>; 4587 defm s16 : MVE_VQxDMLxDH_p<iname, exch, round, subtract, MVE_v8s16>; 4588 defm s32 : MVE_VQxDMLxDH_p<iname, exch, round, subtract, MVE_v4s32>; 4589} 4590 4591defm MVE_VQDMLADH : MVE_VQxDMLxDH_multi<"vqdmladh", 0b0, 0b0, 0b0>; 4592defm MVE_VQDMLADHX : MVE_VQxDMLxDH_multi<"vqdmladhx", 0b1, 0b0, 0b0>; 4593defm MVE_VQRDMLADH : MVE_VQxDMLxDH_multi<"vqrdmladh", 0b0, 0b1, 0b0>; 4594defm MVE_VQRDMLADHX : MVE_VQxDMLxDH_multi<"vqrdmladhx", 0b1, 0b1, 0b0>; 4595defm MVE_VQDMLSDH : MVE_VQxDMLxDH_multi<"vqdmlsdh", 0b0, 0b0, 0b1>; 4596defm MVE_VQDMLSDHX : MVE_VQxDMLxDH_multi<"vqdmlsdhx", 0b1, 0b0, 0b1>; 4597defm MVE_VQRDMLSDH : MVE_VQxDMLxDH_multi<"vqrdmlsdh", 0b0, 0b1, 0b1>; 4598defm MVE_VQRDMLSDHX : MVE_VQxDMLxDH_multi<"vqrdmlsdhx", 0b1, 0b1, 0b1>; 4599 4600class MVE_VCMUL<string iname, string suffix, bits<2> size, string cstr=""> 4601 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd), 4602 (ins MQPR:$Qn, MQPR:$Qm, complexrotateop:$rot), 4603 "$Qd, $Qn, $Qm, $rot", vpred_r, cstr, size, 4604 []> { 4605 bits<4> Qn; 4606 bits<2> rot; 4607 4608 let Inst{28} = size{1}; 4609 let Inst{21-20} = 0b11; 4610 let Inst{19-17} = Qn{2-0}; 4611 let Inst{16} = 0b0; 4612 let Inst{12} = rot{1}; 4613 let Inst{8} = 0b0; 4614 let Inst{7} = Qn{3}; 4615 let Inst{0} = rot{0}; 4616 4617 let Predicates = [HasMVEFloat]; 4618} 4619 4620multiclass MVE_VCMUL_m<string iname, MVEVectorVTInfo VTI, 4621 string cstr=""> { 4622 def "" : MVE_VCMUL<iname, VTI.Suffix, VTI.Size, cstr>; 4623 defvar Inst = !cast<Instruction>(NAME); 4624 4625 let Predicates = [HasMVEFloat] in { 4626 def : Pat<(VTI.Vec (int_arm_mve_vcmulq 4627 imm:$rot, (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))), 4628 (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 4629 imm:$rot))>; 4630 4631 def : Pat<(VTI.Vec (int_arm_mve_vcmulq_predicated 4632 imm:$rot, (VTI.Vec MQPR:$inactive), 4633 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 4634 (VTI.Pred VCCR:$mask))), 4635 (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 4636 imm:$rot, ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 4637 (VTI.Vec MQPR:$inactive)))>; 4638 4639 } 4640} 4641 4642defm MVE_VCMULf16 : MVE_VCMUL_m<"vcmul", MVE_v8f16>; 4643defm MVE_VCMULf32 : MVE_VCMUL_m<"vcmul", MVE_v4f32, "@earlyclobber $Qd">; 4644 4645class MVE_VMULL<string iname, string suffix, bit bit_28, bits<2> bits_21_20, 4646 bit T, string cstr, bits<2> vecsize, list<dag> pattern=[]> 4647 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd), 4648 (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm", 4649 vpred_r, cstr, vecsize, pattern> { 4650 bits<4> Qd; 4651 bits<4> Qn; 4652 bits<4> Qm; 4653 4654 let Inst{28} = bit_28; 4655 let Inst{21-20} = bits_21_20; 4656 let Inst{19-17} = Qn{2-0}; 4657 let Inst{16} = 0b1; 4658 let Inst{12} = T; 4659 let Inst{8} = 0b0; 4660 let Inst{7} = Qn{3}; 4661 let Inst{0} = 0b0; 4662 let validForTailPredication = 1; 4663 let doubleWidthResult = 1; 4664} 4665 4666multiclass MVE_VMULL_m<MVEVectorVTInfo VTI, 4667 SDPatternOperator unpred_op, Intrinsic pred_int, 4668 bit Top, bits<2> vecsize, string cstr=""> { 4669 def "" : MVE_VMULL<"vmull" # !if(Top, "t", "b"), VTI.Suffix, VTI.Unsigned, 4670 VTI.Size, Top, cstr, vecsize>; 4671 defvar Inst = !cast<Instruction>(NAME); 4672 4673 let Predicates = [HasMVEInt] in { 4674 defvar uflag = !if(!eq(VTI.SuffixLetter, "p"), (?), (? (i32 VTI.Unsigned))); 4675 4676 // Unpredicated multiply 4677 def : Pat<(VTI.DblVec !con((unpred_op (VTI.Vec MQPR:$Qm), 4678 (VTI.Vec MQPR:$Qn)), 4679 uflag, (? (i32 Top)))), 4680 (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>; 4681 4682 // Predicated multiply 4683 def : Pat<(VTI.DblVec !con((pred_int (VTI.Vec MQPR:$Qm), 4684 (VTI.Vec MQPR:$Qn)), 4685 uflag, (? (i32 Top), (VTI.DblPred VCCR:$mask), 4686 (VTI.DblVec MQPR:$inactive)))), 4687 (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 4688 ARMVCCThen, (VTI.DblPred VCCR:$mask), zero_reg, 4689 (VTI.DblVec MQPR:$inactive)))>; 4690 } 4691} 4692 4693// For polynomial multiplies, the size bits take the unused value 0b11, and 4694// the unsigned bit switches to encoding the size. 4695 4696defm MVE_VMULLBs8 : MVE_VMULL_m<MVE_v16s8, int_arm_mve_vmull, 4697 int_arm_mve_mull_int_predicated, 0b0, 0b01>; 4698defm MVE_VMULLTs8 : MVE_VMULL_m<MVE_v16s8, int_arm_mve_vmull, 4699 int_arm_mve_mull_int_predicated, 0b1, 0b01>; 4700defm MVE_VMULLBs16 : MVE_VMULL_m<MVE_v8s16, int_arm_mve_vmull, 4701 int_arm_mve_mull_int_predicated, 0b0, 0b10>; 4702defm MVE_VMULLTs16 : MVE_VMULL_m<MVE_v8s16, int_arm_mve_vmull, 4703 int_arm_mve_mull_int_predicated, 0b1, 0b10>; 4704defm MVE_VMULLBs32 : MVE_VMULL_m<MVE_v4s32, int_arm_mve_vmull, 4705 int_arm_mve_mull_int_predicated, 0b0, 0b11, 4706 "@earlyclobber $Qd">; 4707defm MVE_VMULLTs32 : MVE_VMULL_m<MVE_v4s32, int_arm_mve_vmull, 4708 int_arm_mve_mull_int_predicated, 0b1, 0b11, 4709 "@earlyclobber $Qd">; 4710 4711defm MVE_VMULLBu8 : MVE_VMULL_m<MVE_v16u8, int_arm_mve_vmull, 4712 int_arm_mve_mull_int_predicated, 0b0, 0b01>; 4713defm MVE_VMULLTu8 : MVE_VMULL_m<MVE_v16u8, int_arm_mve_vmull, 4714 int_arm_mve_mull_int_predicated, 0b1, 0b01>; 4715defm MVE_VMULLBu16 : MVE_VMULL_m<MVE_v8u16, int_arm_mve_vmull, 4716 int_arm_mve_mull_int_predicated, 0b0, 0b10>; 4717defm MVE_VMULLTu16 : MVE_VMULL_m<MVE_v8u16, int_arm_mve_vmull, 4718 int_arm_mve_mull_int_predicated, 0b1, 0b10>; 4719defm MVE_VMULLBu32 : MVE_VMULL_m<MVE_v4u32, int_arm_mve_vmull, 4720 int_arm_mve_mull_int_predicated, 0b0, 0b11, 4721 "@earlyclobber $Qd">; 4722defm MVE_VMULLTu32 : MVE_VMULL_m<MVE_v4u32, int_arm_mve_vmull, 4723 int_arm_mve_mull_int_predicated, 0b1, 0b11, 4724 "@earlyclobber $Qd">; 4725 4726defm MVE_VMULLBp8 : MVE_VMULL_m<MVE_v16p8, int_arm_mve_vmull_poly, 4727 int_arm_mve_mull_poly_predicated, 0b0, 0b01>; 4728defm MVE_VMULLTp8 : MVE_VMULL_m<MVE_v16p8, int_arm_mve_vmull_poly, 4729 int_arm_mve_mull_poly_predicated, 0b1, 0b01>; 4730defm MVE_VMULLBp16 : MVE_VMULL_m<MVE_v8p16, int_arm_mve_vmull_poly, 4731 int_arm_mve_mull_poly_predicated, 0b0, 0b10>; 4732defm MVE_VMULLTp16 : MVE_VMULL_m<MVE_v8p16, int_arm_mve_vmull_poly, 4733 int_arm_mve_mull_poly_predicated, 0b1, 0b10>; 4734 4735let Predicates = [HasMVEInt] in { 4736 def : Pat<(v2i64 (ARMvmulls (v4i32 MQPR:$src1), (v4i32 MQPR:$src2))), 4737 (MVE_VMULLBs32 MQPR:$src1, MQPR:$src2)>; 4738 def : Pat<(v2i64 (ARMvmulls (v4i32 (ARMvrev64 (v4i32 MQPR:$src1))), 4739 (v4i32 (ARMvrev64 (v4i32 MQPR:$src2))))), 4740 (MVE_VMULLTs32 MQPR:$src1, MQPR:$src2)>; 4741 4742 def : Pat<(mul (sext_inreg (v4i32 MQPR:$src1), v4i16), 4743 (sext_inreg (v4i32 MQPR:$src2), v4i16)), 4744 (MVE_VMULLBs16 MQPR:$src1, MQPR:$src2)>; 4745 def : Pat<(mul (sext_inreg (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src1)))), v4i16), 4746 (sext_inreg (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src2)))), v4i16)), 4747 (MVE_VMULLTs16 MQPR:$src1, MQPR:$src2)>; 4748 4749 def : Pat<(mul (sext_inreg (v8i16 MQPR:$src1), v8i8), 4750 (sext_inreg (v8i16 MQPR:$src2), v8i8)), 4751 (MVE_VMULLBs8 MQPR:$src1, MQPR:$src2)>; 4752 def : Pat<(mul (sext_inreg (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src1)))), v8i8), 4753 (sext_inreg (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src2)))), v8i8)), 4754 (MVE_VMULLTs8 MQPR:$src1, MQPR:$src2)>; 4755 4756 def : Pat<(v2i64 (ARMvmullu (v4i32 MQPR:$src1), (v4i32 MQPR:$src2))), 4757 (MVE_VMULLBu32 MQPR:$src1, MQPR:$src2)>; 4758 def : Pat<(v2i64 (ARMvmullu (v4i32 (ARMvrev64 (v4i32 MQPR:$src1))), 4759 (v4i32 (ARMvrev64 (v4i32 MQPR:$src2))))), 4760 (MVE_VMULLTu32 MQPR:$src1, MQPR:$src2)>; 4761 4762 def : Pat<(mul (and (v4i32 MQPR:$src1), (v4i32 (ARMvmovImm (i32 0xCFF)))), 4763 (and (v4i32 MQPR:$src2), (v4i32 (ARMvmovImm (i32 0xCFF))))), 4764 (MVE_VMULLBu16 MQPR:$src1, MQPR:$src2)>; 4765 def : Pat<(mul (and (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src1)))), 4766 (v4i32 (ARMvmovImm (i32 0xCFF)))), 4767 (and (v4i32 (ARMVectorRegCast (ARMvrev32 (v8i16 MQPR:$src2)))), 4768 (v4i32 (ARMvmovImm (i32 0xCFF))))), 4769 (MVE_VMULLTu16 MQPR:$src1, MQPR:$src2)>; 4770 4771 def : Pat<(mul (ARMvbicImm (v8i16 MQPR:$src1), (i32 0xAFF)), 4772 (ARMvbicImm (v8i16 MQPR:$src2), (i32 0xAFF))), 4773 (MVE_VMULLBu8 MQPR:$src1, MQPR:$src2)>; 4774 def : Pat<(mul (ARMvbicImm (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src1)))), (i32 0xAFF)), 4775 (ARMvbicImm (v8i16 (ARMVectorRegCast (ARMvrev16 (v16i8 MQPR:$src2)))), (i32 0xAFF))), 4776 (MVE_VMULLTu8 MQPR:$src1, MQPR:$src2)>; 4777} 4778 4779class MVE_VxMULH<string iname, string suffix, bit U, bits<2> size, bit round, 4780 list<dag> pattern=[]> 4781 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd), 4782 (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm", 4783 vpred_r, "", size, pattern> { 4784 bits<4> Qn; 4785 4786 let Inst{28} = U; 4787 let Inst{21-20} = size; 4788 let Inst{19-17} = Qn{2-0}; 4789 let Inst{16} = 0b1; 4790 let Inst{12} = round; 4791 let Inst{8} = 0b0; 4792 let Inst{7} = Qn{3}; 4793 let Inst{0} = 0b1; 4794 let validForTailPredication = 1; 4795} 4796 4797multiclass MVE_VxMULH_m<string iname, MVEVectorVTInfo VTI, SDNode unpred_op, 4798 Intrinsic PredInt, bit round> { 4799 def "" : MVE_VxMULH<iname, VTI.Suffix, VTI.Unsigned, VTI.Size, round>; 4800 defvar Inst = !cast<Instruction>(NAME); 4801 4802 let Predicates = [HasMVEInt] in { 4803 if !eq(round, 0b0) then { 4804 defvar mulh = !if(VTI.Unsigned, mulhu, mulhs); 4805 defm : MVE_TwoOpPattern<VTI, mulh, PredInt, (? (i32 VTI.Unsigned)), 4806 !cast<Instruction>(NAME)>; 4807 } else { 4808 // Predicated multiply returning high bits 4809 def : Pat<(VTI.Vec (PredInt (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 4810 (i32 VTI.Unsigned), (VTI.Pred VCCR:$mask), 4811 (VTI.Vec MQPR:$inactive))), 4812 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 4813 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 4814 (VTI.Vec MQPR:$inactive)))>; 4815 } 4816 4817 // Unpredicated intrinsic 4818 def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 4819 (i32 VTI.Unsigned))), 4820 (VTI.Vec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>; 4821 } 4822} 4823 4824multiclass MVE_VMULT<string iname, MVEVectorVTInfo VTI, bit round> 4825 : MVE_VxMULH_m<iname, VTI, !if(round, int_arm_mve_vrmulh, int_arm_mve_vmulh), 4826 !if(round, int_arm_mve_rmulh_predicated, 4827 int_arm_mve_mulh_predicated), 4828 round>; 4829 4830defm MVE_VMULHs8 : MVE_VMULT<"vmulh", MVE_v16s8, 0b0>; 4831defm MVE_VMULHs16 : MVE_VMULT<"vmulh", MVE_v8s16, 0b0>; 4832defm MVE_VMULHs32 : MVE_VMULT<"vmulh", MVE_v4s32, 0b0>; 4833defm MVE_VMULHu8 : MVE_VMULT<"vmulh", MVE_v16u8, 0b0>; 4834defm MVE_VMULHu16 : MVE_VMULT<"vmulh", MVE_v8u16, 0b0>; 4835defm MVE_VMULHu32 : MVE_VMULT<"vmulh", MVE_v4u32, 0b0>; 4836 4837defm MVE_VRMULHs8 : MVE_VMULT<"vrmulh", MVE_v16s8, 0b1>; 4838defm MVE_VRMULHs16 : MVE_VMULT<"vrmulh", MVE_v8s16, 0b1>; 4839defm MVE_VRMULHs32 : MVE_VMULT<"vrmulh", MVE_v4s32, 0b1>; 4840defm MVE_VRMULHu8 : MVE_VMULT<"vrmulh", MVE_v16u8, 0b1>; 4841defm MVE_VRMULHu16 : MVE_VMULT<"vrmulh", MVE_v8u16, 0b1>; 4842defm MVE_VRMULHu32 : MVE_VMULT<"vrmulh", MVE_v4u32, 0b1>; 4843 4844class MVE_VxMOVxN<string iname, string suffix, bit bit_28, bit bit_17, 4845 bits<2> size, bit T, list<dag> pattern=[]> 4846 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd), 4847 (ins MQPR:$Qd_src, MQPR:$Qm), "$Qd, $Qm", 4848 vpred_n, "$Qd = $Qd_src", !if(size, 0b10, 0b01), pattern> { 4849 4850 let Inst{28} = bit_28; 4851 let Inst{21-20} = 0b11; 4852 let Inst{19-18} = size; 4853 let Inst{17} = bit_17; 4854 let Inst{16} = 0b1; 4855 let Inst{12} = T; 4856 let Inst{8} = 0b0; 4857 let Inst{7} = !not(bit_17); 4858 let Inst{0} = 0b1; 4859 let validForTailPredication = 1; 4860 let retainsPreviousHalfElement = 1; 4861} 4862 4863multiclass MVE_VxMOVxN_halves<string iname, string suffix, 4864 bit bit_28, bit bit_17, bits<2> size> { 4865 def bh : MVE_VxMOVxN<iname # "b", suffix, bit_28, bit_17, size, 0b0>; 4866 def th : MVE_VxMOVxN<iname # "t", suffix, bit_28, bit_17, size, 0b1>; 4867} 4868 4869defm MVE_VMOVNi16 : MVE_VxMOVxN_halves<"vmovn", "i16", 0b1, 0b0, 0b00>; 4870defm MVE_VMOVNi32 : MVE_VxMOVxN_halves<"vmovn", "i32", 0b1, 0b0, 0b01>; 4871defm MVE_VQMOVNs16 : MVE_VxMOVxN_halves<"vqmovn", "s16", 0b0, 0b1, 0b00>; 4872defm MVE_VQMOVNs32 : MVE_VxMOVxN_halves<"vqmovn", "s32", 0b0, 0b1, 0b01>; 4873defm MVE_VQMOVNu16 : MVE_VxMOVxN_halves<"vqmovn", "u16", 0b1, 0b1, 0b00>; 4874defm MVE_VQMOVNu32 : MVE_VxMOVxN_halves<"vqmovn", "u32", 0b1, 0b1, 0b01>; 4875defm MVE_VQMOVUNs16 : MVE_VxMOVxN_halves<"vqmovun", "s16", 0b0, 0b0, 0b00>; 4876defm MVE_VQMOVUNs32 : MVE_VxMOVxN_halves<"vqmovun", "s32", 0b0, 0b0, 0b01>; 4877 4878def MVEvmovn : SDNode<"ARMISD::VMOVN", SDTARMVEXT>; 4879 4880multiclass MVE_VMOVN_p<Instruction Inst, bit top, 4881 MVEVectorVTInfo VTI, MVEVectorVTInfo InVTI> { 4882 // Match the most obvious MVEvmovn(a,b,t), which overwrites the odd or even 4883 // lanes of a (depending on t) with the even lanes of b. 4884 def : Pat<(VTI.Vec (MVEvmovn (VTI.Vec MQPR:$Qd_src), 4885 (VTI.Vec MQPR:$Qm), (i32 top))), 4886 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src), (VTI.Vec MQPR:$Qm)))>; 4887 4888 if !not(top) then { 4889 // If we see MVEvmovn(a,ARMvrev(b),1), that wants to overwrite the odd 4890 // lanes of a with the odd lanes of b. In other words, the lanes we're 4891 // _keeping_ from a are the even ones. So we can flip it round and say that 4892 // this is the same as overwriting the even lanes of b with the even lanes 4893 // of a, i.e. it's a VMOVNB with the operands reversed. 4894 defvar vrev = !cast<SDNode>("ARMvrev" # InVTI.LaneBits); 4895 def : Pat<(VTI.Vec (MVEvmovn (VTI.Vec MQPR:$Qm), 4896 (VTI.Vec (vrev MQPR:$Qd_src)), (i32 1))), 4897 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src), (VTI.Vec MQPR:$Qm)))>; 4898 } 4899 4900 // Match the IR intrinsic for a predicated VMOVN. This regards the Qm input 4901 // as having wider lanes that we're narrowing, instead of already-narrow 4902 // lanes that we're taking every other one of. 4903 def : Pat<(VTI.Vec (int_arm_mve_vmovn_predicated (VTI.Vec MQPR:$Qd_src), 4904 (InVTI.Vec MQPR:$Qm), (i32 top), 4905 (InVTI.Pred VCCR:$pred))), 4906 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src), 4907 (InVTI.Vec MQPR:$Qm), 4908 ARMVCCThen, (InVTI.Pred VCCR:$pred), zero_reg))>; 4909} 4910 4911defm : MVE_VMOVN_p<MVE_VMOVNi32bh, 0, MVE_v8i16, MVE_v4i32>; 4912defm : MVE_VMOVN_p<MVE_VMOVNi32th, 1, MVE_v8i16, MVE_v4i32>; 4913defm : MVE_VMOVN_p<MVE_VMOVNi16bh, 0, MVE_v16i8, MVE_v8i16>; 4914defm : MVE_VMOVN_p<MVE_VMOVNi16th, 1, MVE_v16i8, MVE_v8i16>; 4915 4916multiclass MVE_VQMOVN_p<Instruction Inst, bit outU, bit inU, bit top, 4917 MVEVectorVTInfo VTI, MVEVectorVTInfo InVTI> { 4918 def : Pat<(VTI.Vec (int_arm_mve_vqmovn (VTI.Vec MQPR:$Qd_src), 4919 (InVTI.Vec MQPR:$Qm), 4920 (i32 outU), (i32 inU), (i32 top))), 4921 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src), 4922 (InVTI.Vec MQPR:$Qm)))>; 4923 4924 def : Pat<(VTI.Vec (int_arm_mve_vqmovn_predicated (VTI.Vec MQPR:$Qd_src), 4925 (InVTI.Vec MQPR:$Qm), 4926 (i32 outU), (i32 inU), (i32 top), 4927 (InVTI.Pred VCCR:$pred))), 4928 (VTI.Vec (Inst (VTI.Vec MQPR:$Qd_src), 4929 (InVTI.Vec MQPR:$Qm), 4930 ARMVCCThen, (InVTI.Pred VCCR:$pred), zero_reg))>; 4931} 4932 4933defm : MVE_VQMOVN_p<MVE_VQMOVNs32bh, 0, 0, 0, MVE_v8i16, MVE_v4i32>; 4934defm : MVE_VQMOVN_p<MVE_VQMOVNs32th, 0, 0, 1, MVE_v8i16, MVE_v4i32>; 4935defm : MVE_VQMOVN_p<MVE_VQMOVNs16bh, 0, 0, 0, MVE_v16i8, MVE_v8i16>; 4936defm : MVE_VQMOVN_p<MVE_VQMOVNs16th, 0, 0, 1, MVE_v16i8, MVE_v8i16>; 4937defm : MVE_VQMOVN_p<MVE_VQMOVNu32bh, 1, 1, 0, MVE_v8i16, MVE_v4i32>; 4938defm : MVE_VQMOVN_p<MVE_VQMOVNu32th, 1, 1, 1, MVE_v8i16, MVE_v4i32>; 4939defm : MVE_VQMOVN_p<MVE_VQMOVNu16bh, 1, 1, 0, MVE_v16i8, MVE_v8i16>; 4940defm : MVE_VQMOVN_p<MVE_VQMOVNu16th, 1, 1, 1, MVE_v16i8, MVE_v8i16>; 4941defm : MVE_VQMOVN_p<MVE_VQMOVUNs32bh, 1, 0, 0, MVE_v8i16, MVE_v4i32>; 4942defm : MVE_VQMOVN_p<MVE_VQMOVUNs32th, 1, 0, 1, MVE_v8i16, MVE_v4i32>; 4943defm : MVE_VQMOVN_p<MVE_VQMOVUNs16bh, 1, 0, 0, MVE_v16i8, MVE_v8i16>; 4944defm : MVE_VQMOVN_p<MVE_VQMOVUNs16th, 1, 0, 1, MVE_v16i8, MVE_v8i16>; 4945 4946def SDTARMVMOVNQ : SDTypeProfile<1, 3, [SDTCisVec<0>, SDTCisSameAs<0, 1>, 4947 SDTCisVec<2>, SDTCisVT<3, i32>]>; 4948def MVEvqmovns : SDNode<"ARMISD::VQMOVNs", SDTARMVMOVNQ>; 4949def MVEvqmovnu : SDNode<"ARMISD::VQMOVNu", SDTARMVMOVNQ>; 4950 4951let Predicates = [HasMVEInt] in { 4952 def : Pat<(v8i16 (MVEvqmovns (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), (i32 0))), 4953 (v8i16 (MVE_VQMOVNs32bh (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm)))>; 4954 def : Pat<(v8i16 (MVEvqmovns (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), (i32 1))), 4955 (v8i16 (MVE_VQMOVNs32th (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm)))>; 4956 def : Pat<(v16i8 (MVEvqmovns (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), (i32 0))), 4957 (v16i8 (MVE_VQMOVNs16bh (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm)))>; 4958 def : Pat<(v16i8 (MVEvqmovns (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), (i32 1))), 4959 (v16i8 (MVE_VQMOVNs16th (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm)))>; 4960 4961 def : Pat<(v8i16 (MVEvqmovnu (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), (i32 0))), 4962 (v8i16 (MVE_VQMOVNu32bh (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm)))>; 4963 def : Pat<(v8i16 (MVEvqmovnu (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), (i32 1))), 4964 (v8i16 (MVE_VQMOVNu32th (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm)))>; 4965 def : Pat<(v16i8 (MVEvqmovnu (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), (i32 0))), 4966 (v16i8 (MVE_VQMOVNu16bh (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm)))>; 4967 def : Pat<(v16i8 (MVEvqmovnu (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), (i32 1))), 4968 (v16i8 (MVE_VQMOVNu16th (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm)))>; 4969 4970 def : Pat<(v8i16 (MVEvqmovns (v8i16 MQPR:$Qd_src), (v4i32 (ARMvshrsImm (v4i32 MQPR:$Qm), imm0_31:$imm)), (i32 0))), 4971 (v8i16 (MVE_VQSHRNbhs32 (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), imm0_31:$imm))>; 4972 def : Pat<(v16i8 (MVEvqmovns (v16i8 MQPR:$Qd_src), (v8i16 (ARMvshrsImm (v8i16 MQPR:$Qm), imm0_15:$imm)), (i32 0))), 4973 (v16i8 (MVE_VQSHRNbhs16 (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), imm0_15:$imm))>; 4974 def : Pat<(v8i16 (MVEvqmovns (v8i16 MQPR:$Qd_src), (v4i32 (ARMvshrsImm (v4i32 MQPR:$Qm), imm0_31:$imm)), (i32 1))), 4975 (v8i16 (MVE_VQSHRNths32 (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), imm0_31:$imm))>; 4976 def : Pat<(v16i8 (MVEvqmovns (v16i8 MQPR:$Qd_src), (v8i16 (ARMvshrsImm (v8i16 MQPR:$Qm), imm0_15:$imm)), (i32 1))), 4977 (v16i8 (MVE_VQSHRNths16 (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), imm0_15:$imm))>; 4978 4979 def : Pat<(v8i16 (MVEvqmovnu (v8i16 MQPR:$Qd_src), (v4i32 (ARMvshruImm (v4i32 MQPR:$Qm), imm0_31:$imm)), (i32 0))), 4980 (v8i16 (MVE_VQSHRNbhu32 (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), imm0_31:$imm))>; 4981 def : Pat<(v16i8 (MVEvqmovnu (v16i8 MQPR:$Qd_src), (v8i16 (ARMvshruImm (v8i16 MQPR:$Qm), imm0_15:$imm)), (i32 0))), 4982 (v16i8 (MVE_VQSHRNbhu16 (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), imm0_15:$imm))>; 4983 def : Pat<(v8i16 (MVEvqmovnu (v8i16 MQPR:$Qd_src), (v4i32 (ARMvshruImm (v4i32 MQPR:$Qm), imm0_31:$imm)), (i32 1))), 4984 (v8i16 (MVE_VQSHRNthu32 (v8i16 MQPR:$Qd_src), (v4i32 MQPR:$Qm), imm0_31:$imm))>; 4985 def : Pat<(v16i8 (MVEvqmovnu (v16i8 MQPR:$Qd_src), (v8i16 (ARMvshruImm (v8i16 MQPR:$Qm), imm0_15:$imm)), (i32 1))), 4986 (v16i8 (MVE_VQSHRNthu16 (v16i8 MQPR:$Qd_src), (v8i16 MQPR:$Qm), imm0_15:$imm))>; 4987} 4988 4989class MVE_VCVT_ff<string iname, string suffix, bit op, bit T, 4990 dag iops_extra, vpred_ops vpred, string cstr> 4991 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd), 4992 !con(iops_extra, (ins MQPR:$Qm)), "$Qd, $Qm", 4993 vpred, cstr, 0b10, []> { 4994 let Inst{28} = op; 4995 let Inst{21-16} = 0b111111; 4996 let Inst{12} = T; 4997 let Inst{8-7} = 0b00; 4998 let Inst{0} = 0b1; 4999 5000 let Predicates = [HasMVEFloat]; 5001 let retainsPreviousHalfElement = 1; 5002} 5003 5004def SDTARMVCVTL : SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisVec<1>, 5005 SDTCisVT<2, i32>]>; 5006def MVEvcvtn : SDNode<"ARMISD::VCVTN", SDTARMVMOVNQ>; 5007def MVEvcvtl : SDNode<"ARMISD::VCVTL", SDTARMVCVTL>; 5008 5009multiclass MVE_VCVT_f2h_m<string iname, int half> { 5010 def "": MVE_VCVT_ff<iname, "f16.f32", 0b0, half, 5011 (ins MQPR:$Qd_src), vpred_n, "$Qd = $Qd_src">; 5012 defvar Inst = !cast<Instruction>(NAME); 5013 5014 let Predicates = [HasMVEFloat] in { 5015 def : Pat<(v8f16 (int_arm_mve_vcvt_narrow 5016 (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm), (i32 half))), 5017 (v8f16 (Inst (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm)))>; 5018 def : Pat<(v8f16 (int_arm_mve_vcvt_narrow_predicated 5019 (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm), (i32 half), 5020 (v4i1 VCCR:$mask))), 5021 (v8f16 (Inst (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm), 5022 ARMVCCThen, (v4i1 VCCR:$mask), zero_reg))>; 5023 5024 def : Pat<(v8f16 (MVEvcvtn (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm), (i32 half))), 5025 (v8f16 (Inst (v8f16 MQPR:$Qd_src), (v4f32 MQPR:$Qm)))>; 5026 } 5027} 5028 5029multiclass MVE_VCVT_h2f_m<string iname, int half> { 5030 def "": MVE_VCVT_ff<iname, "f32.f16", 0b1, half, (ins), vpred_r, "">; 5031 defvar Inst = !cast<Instruction>(NAME); 5032 5033 let Predicates = [HasMVEFloat] in { 5034 def : Pat<(v4f32 (int_arm_mve_vcvt_widen (v8f16 MQPR:$Qm), (i32 half))), 5035 (v4f32 (Inst (v8f16 MQPR:$Qm)))>; 5036 def : Pat<(v4f32 (int_arm_mve_vcvt_widen_predicated 5037 (v4f32 MQPR:$inactive), (v8f16 MQPR:$Qm), (i32 half), 5038 (v4i1 VCCR:$mask))), 5039 (v4f32 (Inst (v8f16 MQPR:$Qm), ARMVCCThen, 5040 (v4i1 VCCR:$mask), zero_reg, (v4f32 MQPR:$inactive)))>; 5041 5042 def : Pat<(v4f32 (MVEvcvtl (v8f16 MQPR:$Qm), (i32 half))), 5043 (v4f32 (Inst (v8f16 MQPR:$Qm)))>; 5044 } 5045} 5046 5047defm MVE_VCVTf16f32bh : MVE_VCVT_f2h_m<"vcvtb", 0b0>; 5048defm MVE_VCVTf16f32th : MVE_VCVT_f2h_m<"vcvtt", 0b1>; 5049defm MVE_VCVTf32f16bh : MVE_VCVT_h2f_m<"vcvtb", 0b0>; 5050defm MVE_VCVTf32f16th : MVE_VCVT_h2f_m<"vcvtt", 0b1>; 5051 5052class MVE_VxCADD<string iname, string suffix, bits<2> size, bit halve, 5053 string cstr=""> 5054 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd), 5055 (ins MQPR:$Qn, MQPR:$Qm, complexrotateopodd:$rot), 5056 "$Qd, $Qn, $Qm, $rot", vpred_r, cstr, size, []> { 5057 bits<4> Qn; 5058 bit rot; 5059 5060 let Inst{28} = halve; 5061 let Inst{21-20} = size; 5062 let Inst{19-17} = Qn{2-0}; 5063 let Inst{16} = 0b0; 5064 let Inst{12} = rot; 5065 let Inst{8} = 0b1; 5066 let Inst{7} = Qn{3}; 5067 let Inst{0} = 0b0; 5068} 5069 5070multiclass MVE_VxCADD_m<string iname, MVEVectorVTInfo VTI, 5071 bit halve, string cstr=""> { 5072 def "" : MVE_VxCADD<iname, VTI.Suffix, VTI.Size, halve, cstr>; 5073 defvar Inst = !cast<Instruction>(NAME); 5074 5075 let Predicates = [HasMVEInt] in { 5076 def : Pat<(VTI.Vec (int_arm_mve_vcaddq halve, 5077 imm:$rot, (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm))), 5078 (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 5079 imm:$rot))>; 5080 5081 def : Pat<(VTI.Vec (int_arm_mve_vcaddq_predicated halve, 5082 imm:$rot, (VTI.Vec MQPR:$inactive), 5083 (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 5084 (VTI.Pred VCCR:$mask))), 5085 (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (VTI.Vec MQPR:$Qm), 5086 imm:$rot, ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 5087 (VTI.Vec MQPR:$inactive)))>; 5088 5089 } 5090} 5091 5092defm MVE_VCADDi8 : MVE_VxCADD_m<"vcadd", MVE_v16i8, 0b1>; 5093defm MVE_VCADDi16 : MVE_VxCADD_m<"vcadd", MVE_v8i16, 0b1>; 5094defm MVE_VCADDi32 : MVE_VxCADD_m<"vcadd", MVE_v4i32, 0b1, "@earlyclobber $Qd">; 5095 5096defm MVE_VHCADDs8 : MVE_VxCADD_m<"vhcadd", MVE_v16s8, 0b0>; 5097defm MVE_VHCADDs16 : MVE_VxCADD_m<"vhcadd", MVE_v8s16, 0b0>; 5098defm MVE_VHCADDs32 : MVE_VxCADD_m<"vhcadd", MVE_v4s32, 0b0, "@earlyclobber $Qd">; 5099 5100class MVE_VADCSBC<string iname, bit I, bit subtract, 5101 dag carryin, list<dag> pattern=[]> 5102 : MVE_qDest_qSrc<iname, "i32", (outs MQPR:$Qd, cl_FPSCR_NZCV:$carryout), 5103 !con((ins MQPR:$Qn, MQPR:$Qm), carryin), 5104 "$Qd, $Qn, $Qm", vpred_r, "", 0b10, pattern> { 5105 bits<4> Qn; 5106 5107 let Inst{28} = subtract; 5108 let Inst{21-20} = 0b11; 5109 let Inst{19-17} = Qn{2-0}; 5110 let Inst{16} = 0b0; 5111 let Inst{12} = I; 5112 let Inst{8} = 0b1; 5113 let Inst{7} = Qn{3}; 5114 let Inst{0} = 0b0; 5115 5116 // Custom decoder method in order to add the FPSCR operand(s), which 5117 // Tablegen won't do right 5118 let DecoderMethod = "DecodeMVEVADCInstruction"; 5119} 5120 5121def MVE_VADC : MVE_VADCSBC<"vadc", 0b0, 0b0, (ins cl_FPSCR_NZCV:$carryin)>; 5122def MVE_VADCI : MVE_VADCSBC<"vadci", 0b1, 0b0, (ins)>; 5123 5124def MVE_VSBC : MVE_VADCSBC<"vsbc", 0b0, 0b1, (ins cl_FPSCR_NZCV:$carryin)>; 5125def MVE_VSBCI : MVE_VADCSBC<"vsbci", 0b1, 0b1, (ins)>; 5126 5127class MVE_VQDMULL<string iname, string suffix, bit size, bit T, 5128 string cstr="", list<dag> pattern=[]> 5129 : MVE_qDest_qSrc<iname, suffix, (outs MQPR:$Qd), 5130 (ins MQPR:$Qn, MQPR:$Qm), "$Qd, $Qn, $Qm", 5131 vpred_r, cstr, !if(size, 0b10, 0b01), pattern> { 5132 bits<4> Qn; 5133 5134 let Inst{28} = size; 5135 let Inst{21-20} = 0b11; 5136 let Inst{19-17} = Qn{2-0}; 5137 let Inst{16} = 0b0; 5138 let Inst{12} = T; 5139 let Inst{8} = 0b1; 5140 let Inst{7} = Qn{3}; 5141 let Inst{0} = 0b1; 5142 let validForTailPredication = 1; 5143 let doubleWidthResult = 1; 5144} 5145 5146multiclass MVE_VQDMULL_m<string iname, MVEVectorVTInfo VTI, bit size, bit T, 5147 string cstr> { 5148 def "" : MVE_VQDMULL<iname, VTI.Suffix, size, T, cstr>; 5149 defvar Inst = !cast<Instruction>(NAME); 5150 5151 let Predicates = [HasMVEInt] in { 5152 // Unpredicated saturating multiply 5153 def : Pat<(VTI.DblVec (int_arm_mve_vqdmull (VTI.Vec MQPR:$Qm), 5154 (VTI.Vec MQPR:$Qn), (i32 T))), 5155 (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>; 5156 // Predicated saturating multiply 5157 def : Pat<(VTI.DblVec (int_arm_mve_vqdmull_predicated 5158 (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 5159 (i32 T), (VTI.DblPred VCCR:$mask), 5160 (VTI.DblVec MQPR:$inactive))), 5161 (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn), 5162 ARMVCCThen, (VTI.DblPred VCCR:$mask), zero_reg, 5163 (VTI.DblVec MQPR:$inactive)))>; 5164 } 5165} 5166 5167multiclass MVE_VQDMULL_halves<MVEVectorVTInfo VTI, bit size, string cstr=""> { 5168 defm bh : MVE_VQDMULL_m<"vqdmullb", VTI, size, 0b0, cstr>; 5169 defm th : MVE_VQDMULL_m<"vqdmullt", VTI, size, 0b1, cstr>; 5170} 5171 5172defm MVE_VQDMULLs16 : MVE_VQDMULL_halves<MVE_v8s16, 0b0>; 5173defm MVE_VQDMULLs32 : MVE_VQDMULL_halves<MVE_v4s32, 0b1, "@earlyclobber $Qd">; 5174 5175// end of mve_qDest_qSrc 5176 5177// start of mve_qDest_rSrc 5178 5179class MVE_qr_base<dag oops, dag iops, string iname, string suffix, string ops, 5180 vpred_ops vpred, string cstr, bits<2> vecsize, list<dag> pattern=[]> 5181 : MVE_p<oops, iops, NoItinerary, iname, suffix, ops, vpred, cstr, vecsize, pattern> { 5182 bits<4> Qd; 5183 bits<4> Qn; 5184 bits<4> Rm; 5185 5186 let Inst{25-23} = 0b100; 5187 let Inst{22} = Qd{3}; 5188 let Inst{19-17} = Qn{2-0}; 5189 let Inst{15-13} = Qd{2-0}; 5190 let Inst{11-9} = 0b111; 5191 let Inst{7} = Qn{3}; 5192 let Inst{6} = 0b1; 5193 let Inst{4} = 0b0; 5194 let Inst{3-0} = Rm{3-0}; 5195} 5196 5197class MVE_qDest_rSrc<string iname, string suffix, string cstr="", bits<2> vecsize, list<dag> pattern=[]> 5198 : MVE_qr_base<(outs MQPR:$Qd), (ins MQPR:$Qn, rGPR:$Rm), 5199 iname, suffix, "$Qd, $Qn, $Rm", vpred_r, cstr, 5200 vecsize, pattern>; 5201 5202class MVE_qDestSrc_rSrc<string iname, string suffix, bits<2> vecsize, list<dag> pattern=[]> 5203 : MVE_qr_base<(outs MQPR:$Qd), (ins MQPR:$Qd_src, MQPR:$Qn, rGPR:$Rm), 5204 iname, suffix, "$Qd, $Qn, $Rm", vpred_n, "$Qd = $Qd_src", 5205 vecsize, pattern>; 5206 5207class MVE_qDest_single_rSrc<string iname, string suffix, bits<2> vecsize, list<dag> pattern=[]> 5208 : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qd_src, rGPR:$Rm), NoItinerary, iname, 5209 suffix, "$Qd, $Rm", vpred_n, "$Qd = $Qd_src", vecsize, pattern> { 5210 bits<4> Qd; 5211 bits<4> Rm; 5212 5213 let Inst{22} = Qd{3}; 5214 let Inst{15-13} = Qd{2-0}; 5215 let Inst{3-0} = Rm{3-0}; 5216} 5217 5218// Patterns for vector-scalar instructions with integer operands 5219multiclass MVE_vec_scalar_int_pat_m<Instruction inst, MVEVectorVTInfo VTI, 5220 SDPatternOperator unpred_op, 5221 SDPatternOperator pred_op, 5222 bit unpred_has_sign = 0, 5223 bit pred_has_sign = 0> { 5224 defvar UnpredSign = !if(unpred_has_sign, (? (i32 VTI.Unsigned)), (?)); 5225 defvar PredSign = !if(pred_has_sign, (? (i32 VTI.Unsigned)), (?)); 5226 5227 let Predicates = [HasMVEInt] in { 5228 // Unpredicated version 5229 def : Pat<(VTI.Vec !con((unpred_op (VTI.Vec MQPR:$Qm), 5230 (VTI.Vec (ARMvdup rGPR:$val))), 5231 UnpredSign)), 5232 (VTI.Vec (inst (VTI.Vec MQPR:$Qm), (i32 rGPR:$val)))>; 5233 // Predicated version 5234 def : Pat<(VTI.Vec !con((pred_op (VTI.Vec MQPR:$Qm), 5235 (VTI.Vec (ARMvdup rGPR:$val))), 5236 PredSign, 5237 (pred_op (VTI.Pred VCCR:$mask), 5238 (VTI.Vec MQPR:$inactive)))), 5239 (VTI.Vec (inst (VTI.Vec MQPR:$Qm), (i32 rGPR:$val), 5240 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 5241 (VTI.Vec MQPR:$inactive)))>; 5242 } 5243} 5244 5245class MVE_VADDSUB_qr<string iname, string suffix, bits<2> size, 5246 bit bit_5, bit bit_12, bit bit_16, bit bit_28> 5247 : MVE_qDest_rSrc<iname, suffix, "", size> { 5248 5249 let Inst{28} = bit_28; 5250 let Inst{21-20} = size; 5251 let Inst{16} = bit_16; 5252 let Inst{12} = bit_12; 5253 let Inst{8} = 0b1; 5254 let Inst{5} = bit_5; 5255 let validForTailPredication = 1; 5256} 5257 5258// Vector-scalar add/sub 5259multiclass MVE_VADDSUB_qr_m<string iname, MVEVectorVTInfo VTI, bit subtract, 5260 SDNode Op, Intrinsic PredInt> { 5261 def "" : MVE_VADDSUB_qr<iname, VTI.Suffix, VTI.Size, 0b0, subtract, 0b1, 0b0>; 5262 let Predicates = [HasMVEInt] in { 5263 defm : MVE_TwoOpPatternDup<VTI, Op, PredInt, (? ), !cast<Instruction>(NAME), ARMimmAllZerosV>; 5264 } 5265} 5266 5267multiclass MVE_VADD_qr_m<MVEVectorVTInfo VTI> 5268 : MVE_VADDSUB_qr_m<"vadd", VTI, 0b0, add, int_arm_mve_add_predicated>; 5269 5270multiclass MVE_VSUB_qr_m<MVEVectorVTInfo VTI> 5271 : MVE_VADDSUB_qr_m<"vsub", VTI, 0b1, sub, int_arm_mve_sub_predicated>; 5272 5273defm MVE_VADD_qr_i8 : MVE_VADD_qr_m<MVE_v16i8>; 5274defm MVE_VADD_qr_i16 : MVE_VADD_qr_m<MVE_v8i16>; 5275defm MVE_VADD_qr_i32 : MVE_VADD_qr_m<MVE_v4i32>; 5276 5277defm MVE_VSUB_qr_i8 : MVE_VSUB_qr_m<MVE_v16i8>; 5278defm MVE_VSUB_qr_i16 : MVE_VSUB_qr_m<MVE_v8i16>; 5279defm MVE_VSUB_qr_i32 : MVE_VSUB_qr_m<MVE_v4i32>; 5280 5281// Vector-scalar saturating add/sub 5282multiclass MVE_VQADDSUB_qr_m<string iname, MVEVectorVTInfo VTI, bit subtract, 5283 SDNode Op, Intrinsic PredInt> { 5284 def "" : MVE_VADDSUB_qr<iname, VTI.Suffix, VTI.Size, 0b1, subtract, 5285 0b0, VTI.Unsigned>; 5286 5287 let Predicates = [HasMVEInt] in { 5288 defm : MVE_TwoOpPatternDup<VTI, Op, PredInt, (? (i32 VTI.Unsigned)), 5289 !cast<Instruction>(NAME)>; 5290 } 5291} 5292 5293multiclass MVE_VQADD_qr_m<MVEVectorVTInfo VTI, SDNode Op> 5294 : MVE_VQADDSUB_qr_m<"vqadd", VTI, 0b0, Op, int_arm_mve_qadd_predicated>; 5295 5296multiclass MVE_VQSUB_qr_m<MVEVectorVTInfo VTI, SDNode Op> 5297 : MVE_VQADDSUB_qr_m<"vqsub", VTI, 0b1, Op, int_arm_mve_qsub_predicated>; 5298 5299defm MVE_VQADD_qr_s8 : MVE_VQADD_qr_m<MVE_v16s8, saddsat>; 5300defm MVE_VQADD_qr_s16 : MVE_VQADD_qr_m<MVE_v8s16, saddsat>; 5301defm MVE_VQADD_qr_s32 : MVE_VQADD_qr_m<MVE_v4s32, saddsat>; 5302defm MVE_VQADD_qr_u8 : MVE_VQADD_qr_m<MVE_v16u8, uaddsat>; 5303defm MVE_VQADD_qr_u16 : MVE_VQADD_qr_m<MVE_v8u16, uaddsat>; 5304defm MVE_VQADD_qr_u32 : MVE_VQADD_qr_m<MVE_v4u32, uaddsat>; 5305 5306defm MVE_VQSUB_qr_s8 : MVE_VQSUB_qr_m<MVE_v16s8, ssubsat>; 5307defm MVE_VQSUB_qr_s16 : MVE_VQSUB_qr_m<MVE_v8s16, ssubsat>; 5308defm MVE_VQSUB_qr_s32 : MVE_VQSUB_qr_m<MVE_v4s32, ssubsat>; 5309defm MVE_VQSUB_qr_u8 : MVE_VQSUB_qr_m<MVE_v16u8, usubsat>; 5310defm MVE_VQSUB_qr_u16 : MVE_VQSUB_qr_m<MVE_v8u16, usubsat>; 5311defm MVE_VQSUB_qr_u32 : MVE_VQSUB_qr_m<MVE_v4u32, usubsat>; 5312 5313class MVE_VQDMULL_qr<string iname, string suffix, bit size, 5314 bit T, string cstr="", list<dag> pattern=[]> 5315 : MVE_qDest_rSrc<iname, suffix, cstr, !if(size, 0b10, 0b01), pattern> { 5316 5317 let Inst{28} = size; 5318 let Inst{21-20} = 0b11; 5319 let Inst{16} = 0b0; 5320 let Inst{12} = T; 5321 let Inst{8} = 0b1; 5322 let Inst{5} = 0b1; 5323 let validForTailPredication = 1; 5324 let doubleWidthResult = 1; 5325} 5326 5327multiclass MVE_VQDMULL_qr_m<string iname, MVEVectorVTInfo VTI, bit size, 5328 bit T, string cstr> { 5329 def "" : MVE_VQDMULL_qr<iname, VTI.Suffix, size, T, cstr>; 5330 defvar Inst = !cast<Instruction>(NAME); 5331 5332 let Predicates = [HasMVEInt] in { 5333 // Unpredicated saturating multiply 5334 def : Pat<(VTI.DblVec (int_arm_mve_vqdmull (VTI.Vec MQPR:$Qm), 5335 (VTI.Vec (ARMvdup rGPR:$val)), 5336 (i32 T))), 5337 (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (i32 rGPR:$val)))>; 5338 // Predicated saturating multiply 5339 def : Pat<(VTI.DblVec (int_arm_mve_vqdmull_predicated 5340 (VTI.Vec MQPR:$Qm), 5341 (VTI.Vec (ARMvdup rGPR:$val)), 5342 (i32 T), 5343 (VTI.DblPred VCCR:$mask), 5344 (VTI.DblVec MQPR:$inactive))), 5345 (VTI.DblVec (Inst (VTI.Vec MQPR:$Qm), (i32 rGPR:$val), 5346 ARMVCCThen, (VTI.DblPred VCCR:$mask), zero_reg, 5347 (VTI.DblVec MQPR:$inactive)))>; 5348 } 5349} 5350 5351multiclass MVE_VQDMULL_qr_halves<MVEVectorVTInfo VTI, bit size, string cstr=""> { 5352 defm bh : MVE_VQDMULL_qr_m<"vqdmullb", VTI, size, 0b0, cstr>; 5353 defm th : MVE_VQDMULL_qr_m<"vqdmullt", VTI, size, 0b1, cstr>; 5354} 5355 5356defm MVE_VQDMULL_qr_s16 : MVE_VQDMULL_qr_halves<MVE_v8s16, 0b0>; 5357defm MVE_VQDMULL_qr_s32 : MVE_VQDMULL_qr_halves<MVE_v4s32, 0b1, "@earlyclobber $Qd">; 5358 5359class MVE_VxADDSUB_qr<string iname, string suffix, 5360 bit bit_28, bits<2> size, bit subtract, 5361 bits<2> vecsize, list<dag> pattern=[]> 5362 : MVE_qDest_rSrc<iname, suffix, "", vecsize, pattern> { 5363 5364 let Inst{28} = bit_28; 5365 let Inst{21-20} = size; 5366 let Inst{16} = 0b0; 5367 let Inst{12} = subtract; 5368 let Inst{8} = 0b1; 5369 let Inst{5} = 0b0; 5370 let validForTailPredication = 1; 5371} 5372 5373multiclass MVE_VHADDSUB_qr_m<string iname, MVEVectorVTInfo VTI, bit subtract, SDNode Op, 5374 Intrinsic unpred_int, Intrinsic pred_int, PatFrag add_op, PatFrag shift_op> { 5375 def "" : MVE_VxADDSUB_qr<iname, VTI.Suffix, VTI.Unsigned, VTI.Size, subtract, VTI.Size>; 5376 defm : MVE_TwoOpPatternDup<VTI, Op, pred_int, (? (i32 VTI.Unsigned)), !cast<Instruction>(NAME)>; 5377 defm : MVE_vec_scalar_int_pat_m<!cast<Instruction>(NAME), 5378 VTI, unpred_int, pred_int, 1, 1>; 5379 defvar Inst = !cast<Instruction>(NAME); 5380 5381 let Predicates = [HasMVEInt] in { 5382 def : Pat<(VTI.Vec (shift_op (add_op (VTI.Vec MQPR:$Qm), (VTI.Vec (ARMvdup rGPR:$Rn))), (i32 1))), 5383 (Inst MQPR:$Qm, rGPR:$Rn)>; 5384 } 5385} 5386 5387multiclass MVE_VHADD_qr_m<MVEVectorVTInfo VTI, PatFrag add_op, SDNode shift_op, SDNode Op> : 5388 MVE_VHADDSUB_qr_m<"vhadd", VTI, 0b0, Op, int_arm_mve_vhadd, 5389 int_arm_mve_hadd_predicated, add_op, shift_op>; 5390 5391multiclass MVE_VHSUB_qr_m<MVEVectorVTInfo VTI, PatFrag add_op, SDNode shift_op> : 5392 MVE_VHADDSUB_qr_m<"vhsub", VTI, 0b1, null_frag, int_arm_mve_vhsub, 5393 int_arm_mve_hsub_predicated, add_op, shift_op>; 5394 5395defm MVE_VHADD_qr_s8 : MVE_VHADD_qr_m<MVE_v16s8, addnsw, ARMvshrsImm, avgfloors>; 5396defm MVE_VHADD_qr_s16 : MVE_VHADD_qr_m<MVE_v8s16, addnsw, ARMvshrsImm, avgfloors>; 5397defm MVE_VHADD_qr_s32 : MVE_VHADD_qr_m<MVE_v4s32, addnsw, ARMvshrsImm, avgfloors>; 5398defm MVE_VHADD_qr_u8 : MVE_VHADD_qr_m<MVE_v16u8, addnuw, ARMvshruImm, avgflooru>; 5399defm MVE_VHADD_qr_u16 : MVE_VHADD_qr_m<MVE_v8u16, addnuw, ARMvshruImm, avgflooru>; 5400defm MVE_VHADD_qr_u32 : MVE_VHADD_qr_m<MVE_v4u32, addnuw, ARMvshruImm, avgflooru>; 5401 5402defm MVE_VHSUB_qr_s8 : MVE_VHSUB_qr_m<MVE_v16s8, subnsw, ARMvshrsImm>; 5403defm MVE_VHSUB_qr_s16 : MVE_VHSUB_qr_m<MVE_v8s16, subnsw, ARMvshrsImm>; 5404defm MVE_VHSUB_qr_s32 : MVE_VHSUB_qr_m<MVE_v4s32, subnsw, ARMvshrsImm>; 5405defm MVE_VHSUB_qr_u8 : MVE_VHSUB_qr_m<MVE_v16u8, subnuw, ARMvshruImm>; 5406defm MVE_VHSUB_qr_u16 : MVE_VHSUB_qr_m<MVE_v8u16, subnuw, ARMvshruImm>; 5407defm MVE_VHSUB_qr_u32 : MVE_VHSUB_qr_m<MVE_v4u32, subnuw, ARMvshruImm>; 5408 5409multiclass MVE_VADDSUB_qr_f<string iname, MVEVectorVTInfo VTI, bit subtract, 5410 SDNode Op, Intrinsic PredInt, SDPatternOperator IdentityVec> { 5411 def "" : MVE_VxADDSUB_qr<iname, VTI.Suffix, VTI.Size{0}, 0b11, subtract, VTI.Size>; 5412 defm : MVE_TwoOpPatternDup<VTI, Op, PredInt, (? ), 5413 !cast<Instruction>(NAME), IdentityVec>; 5414} 5415 5416let Predicates = [HasMVEFloat] in { 5417 defm MVE_VADD_qr_f32 : MVE_VADDSUB_qr_f<"vadd", MVE_v4f32, 0b0, fadd, 5418 int_arm_mve_add_predicated, ARMimmMinusZeroF>; 5419 defm MVE_VADD_qr_f16 : MVE_VADDSUB_qr_f<"vadd", MVE_v8f16, 0b0, fadd, 5420 int_arm_mve_add_predicated, ARMimmMinusZeroH>; 5421 5422 defm MVE_VSUB_qr_f32 : MVE_VADDSUB_qr_f<"vsub", MVE_v4f32, 0b1, fsub, 5423 int_arm_mve_sub_predicated, ARMimmAllZerosV>; 5424 defm MVE_VSUB_qr_f16 : MVE_VADDSUB_qr_f<"vsub", MVE_v8f16, 0b1, fsub, 5425 int_arm_mve_sub_predicated, ARMimmAllZerosV>; 5426} 5427 5428class MVE_VxSHL_qr<string iname, string suffix, bit U, bits<2> size, 5429 bit bit_7, bit bit_17, list<dag> pattern=[]> 5430 : MVE_qDest_single_rSrc<iname, suffix, size, pattern> { 5431 5432 let Inst{28} = U; 5433 let Inst{25-23} = 0b100; 5434 let Inst{21-20} = 0b11; 5435 let Inst{19-18} = size; 5436 let Inst{17} = bit_17; 5437 let Inst{16} = 0b1; 5438 let Inst{12-8} = 0b11110; 5439 let Inst{7} = bit_7; 5440 let Inst{6-4} = 0b110; 5441 let validForTailPredication = 1; 5442} 5443 5444multiclass MVE_VxSHL_qr_p<string iname, MVEVectorVTInfo VTI, bit q, bit r> { 5445 def "" : MVE_VxSHL_qr<iname, VTI.Suffix, VTI.Unsigned, VTI.Size, q, r>; 5446 defvar Inst = !cast<Instruction>(NAME); 5447 5448 def : Pat<(VTI.Vec (int_arm_mve_vshl_scalar 5449 (VTI.Vec MQPR:$in), (i32 rGPR:$sh), 5450 (i32 q), (i32 r), (i32 VTI.Unsigned))), 5451 (VTI.Vec (Inst (VTI.Vec MQPR:$in), (i32 rGPR:$sh)))>; 5452 5453 def : Pat<(VTI.Vec (int_arm_mve_vshl_scalar_predicated 5454 (VTI.Vec MQPR:$in), (i32 rGPR:$sh), 5455 (i32 q), (i32 r), (i32 VTI.Unsigned), 5456 (VTI.Pred VCCR:$mask))), 5457 (VTI.Vec (Inst (VTI.Vec MQPR:$in), (i32 rGPR:$sh), 5458 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg))>; 5459} 5460 5461multiclass MVE_VxSHL_qr_types<string iname, bit bit_7, bit bit_17> { 5462 defm s8 : MVE_VxSHL_qr_p<iname, MVE_v16s8, bit_7, bit_17>; 5463 defm s16 : MVE_VxSHL_qr_p<iname, MVE_v8s16, bit_7, bit_17>; 5464 defm s32 : MVE_VxSHL_qr_p<iname, MVE_v4s32, bit_7, bit_17>; 5465 defm u8 : MVE_VxSHL_qr_p<iname, MVE_v16u8, bit_7, bit_17>; 5466 defm u16 : MVE_VxSHL_qr_p<iname, MVE_v8u16, bit_7, bit_17>; 5467 defm u32 : MVE_VxSHL_qr_p<iname, MVE_v4u32, bit_7, bit_17>; 5468} 5469 5470defm MVE_VSHL_qr : MVE_VxSHL_qr_types<"vshl", 0b0, 0b0>; 5471defm MVE_VRSHL_qr : MVE_VxSHL_qr_types<"vrshl", 0b0, 0b1>; 5472defm MVE_VQSHL_qr : MVE_VxSHL_qr_types<"vqshl", 0b1, 0b0>; 5473defm MVE_VQRSHL_qr : MVE_VxSHL_qr_types<"vqrshl", 0b1, 0b1>; 5474 5475let Predicates = [HasMVEInt] in { 5476 def : Pat<(v4i32 (ARMvshlu (v4i32 MQPR:$Qm), (v4i32 (ARMvdup rGPR:$Rm)))), 5477 (v4i32 (MVE_VSHL_qru32 (v4i32 MQPR:$Qm), rGPR:$Rm))>; 5478 def : Pat<(v8i16 (ARMvshlu (v8i16 MQPR:$Qm), (v8i16 (ARMvdup rGPR:$Rm)))), 5479 (v8i16 (MVE_VSHL_qru16 (v8i16 MQPR:$Qm), rGPR:$Rm))>; 5480 def : Pat<(v16i8 (ARMvshlu (v16i8 MQPR:$Qm), (v16i8 (ARMvdup rGPR:$Rm)))), 5481 (v16i8 (MVE_VSHL_qru8 (v16i8 MQPR:$Qm), rGPR:$Rm))>; 5482 5483 def : Pat<(v4i32 (ARMvshls (v4i32 MQPR:$Qm), (v4i32 (ARMvdup rGPR:$Rm)))), 5484 (v4i32 (MVE_VSHL_qrs32 (v4i32 MQPR:$Qm), rGPR:$Rm))>; 5485 def : Pat<(v8i16 (ARMvshls (v8i16 MQPR:$Qm), (v8i16 (ARMvdup rGPR:$Rm)))), 5486 (v8i16 (MVE_VSHL_qrs16 (v8i16 MQPR:$Qm), rGPR:$Rm))>; 5487 def : Pat<(v16i8 (ARMvshls (v16i8 MQPR:$Qm), (v16i8 (ARMvdup rGPR:$Rm)))), 5488 (v16i8 (MVE_VSHL_qrs8 (v16i8 MQPR:$Qm), rGPR:$Rm))>; 5489} 5490 5491class MVE_VBRSR<string iname, string suffix, bits<2> size, list<dag> pattern=[]> 5492 : MVE_qDest_rSrc<iname, suffix, "", size, pattern> { 5493 5494 let Inst{28} = 0b1; 5495 let Inst{21-20} = size; 5496 let Inst{16} = 0b1; 5497 let Inst{12} = 0b1; 5498 let Inst{8} = 0b0; 5499 let Inst{5} = 0b1; 5500 let validForTailPredication = 1; 5501} 5502 5503def MVE_VBRSR8 : MVE_VBRSR<"vbrsr", "8", 0b00>; 5504def MVE_VBRSR16 : MVE_VBRSR<"vbrsr", "16", 0b01>; 5505def MVE_VBRSR32 : MVE_VBRSR<"vbrsr", "32", 0b10>; 5506 5507multiclass MVE_VBRSR_pat_m<MVEVectorVTInfo VTI, Instruction Inst> { 5508 // Unpredicated 5509 def : Pat<(VTI.Vec (int_arm_mve_vbrsr (VTI.Vec MQPR:$Qn), (i32 rGPR:$Rm))), 5510 (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (i32 rGPR:$Rm)))>; 5511 // Predicated 5512 def : Pat<(VTI.Vec (int_arm_mve_vbrsr_predicated 5513 (VTI.Vec MQPR:$inactive), 5514 (VTI.Vec MQPR:$Qn), (i32 rGPR:$Rm), 5515 (VTI.Pred VCCR:$mask))), 5516 (VTI.Vec (Inst (VTI.Vec MQPR:$Qn), (i32 rGPR:$Rm), 5517 ARMVCCThen, (VTI.Pred VCCR:$mask), zero_reg, 5518 (VTI.Vec MQPR:$inactive)))>; 5519} 5520 5521let Predicates = [HasMVEInt] in { 5522 def : Pat<(v16i8 ( bitreverse (v16i8 MQPR:$val1))), 5523 (v16i8 ( MVE_VBRSR8 (v16i8 MQPR:$val1), (t2MOVi (i32 8)) ))>; 5524 5525 def : Pat<(v4i32 ( bitreverse (v4i32 MQPR:$val1))), 5526 (v4i32 ( MVE_VBRSR32 (v4i32 MQPR:$val1), (t2MOVi (i32 32)) ))>; 5527 5528 def : Pat<(v8i16 ( bitreverse (v8i16 MQPR:$val1))), 5529 (v8i16 ( MVE_VBRSR16 (v8i16 MQPR:$val1), (t2MOVi (i32 16)) ))>; 5530 5531 defm : MVE_VBRSR_pat_m<MVE_v16i8, MVE_VBRSR8>; 5532 defm : MVE_VBRSR_pat_m<MVE_v8i16, MVE_VBRSR16>; 5533 defm : MVE_VBRSR_pat_m<MVE_v4i32, MVE_VBRSR32>; 5534} 5535 5536let Predicates = [HasMVEFloat] in { 5537 defm : MVE_VBRSR_pat_m<MVE_v8f16, MVE_VBRSR16>; 5538 defm : MVE_VBRSR_pat_m<MVE_v4f32, MVE_VBRSR32>; 5539} 5540 5541class MVE_VMUL_qr_int<string iname, string suffix, bits<2> size> 5542 : MVE_qDest_rSrc<iname, suffix, "", size> { 5543 5544 let Inst{28} = 0b0; 5545 let Inst{21-20} = size; 5546 let Inst{16} = 0b1; 5547 let Inst{12} = 0b1; 5548 let Inst{8} = 0b0; 5549 let Inst{5} = 0b1; 5550 let validForTailPredication = 1; 5551} 5552 5553multiclass MVE_VMUL_qr_int_m<MVEVectorVTInfo VTI> { 5554 def "" : MVE_VMUL_qr_int<"vmul", VTI.Suffix, VTI.Size>; 5555 let Predicates = [HasMVEInt] in { 5556 defm : MVE_TwoOpPatternDup<VTI, mul, int_arm_mve_mul_predicated, (? ), 5557 !cast<Instruction>(NAME), ARMimmOneV>; 5558 } 5559} 5560 5561defm MVE_VMUL_qr_i8 : MVE_VMUL_qr_int_m<MVE_v16i8>; 5562defm MVE_VMUL_qr_i16 : MVE_VMUL_qr_int_m<MVE_v8i16>; 5563defm MVE_VMUL_qr_i32 : MVE_VMUL_qr_int_m<MVE_v4i32>; 5564 5565class MVE_VxxMUL_qr<string iname, string suffix, 5566 bit bit_28, bits<2> size, bits<2> vecsize, list<dag> pattern=[]> 5567 : MVE_qDest_rSrc<iname, suffix, "", vecsize, pattern> { 5568 5569 let Inst{28} = bit_28; 5570 let Inst{21-20} = size; 5571 let Inst{16} = 0b1; 5572 let Inst{12} = 0b0; 5573 let Inst{8} = 0b0; 5574 let Inst{5} = 0b1; 5575 let validForTailPredication = 1; 5576} 5577 5578multiclass MVE_VxxMUL_qr_m<string iname, MVEVectorVTInfo VTI, bit bit_28, 5579 PatFrag Op, Intrinsic int_unpred, Intrinsic int_pred> { 5580 def "" : MVE_VxxMUL_qr<iname, VTI.Suffix, bit_28, VTI.Size, VTI.Size>; 5581 5582 let Predicates = [HasMVEInt] in { 5583 defm : MVE_TwoOpPatternDup<VTI, Op, int_pred, (? ), !cast<Instruction>(NAME)>; 5584 } 5585 defm : MVE_vec_scalar_int_pat_m<!cast<Instruction>(NAME), VTI, int_unpred, int_pred>; 5586} 5587 5588multiclass MVE_VQDMULH_qr_m<MVEVectorVTInfo VTI> : 5589 MVE_VxxMUL_qr_m<"vqdmulh", VTI, 0b0, MVEvqdmulh, 5590 int_arm_mve_vqdmulh, int_arm_mve_qdmulh_predicated>; 5591 5592multiclass MVE_VQRDMULH_qr_m<MVEVectorVTInfo VTI> : 5593 MVE_VxxMUL_qr_m<"vqrdmulh", VTI, 0b1, null_frag, 5594 int_arm_mve_vqrdmulh, int_arm_mve_qrdmulh_predicated>; 5595 5596defm MVE_VQDMULH_qr_s8 : MVE_VQDMULH_qr_m<MVE_v16s8>; 5597defm MVE_VQDMULH_qr_s16 : MVE_VQDMULH_qr_m<MVE_v8s16>; 5598defm MVE_VQDMULH_qr_s32 : MVE_VQDMULH_qr_m<MVE_v4s32>; 5599 5600defm MVE_VQRDMULH_qr_s8 : MVE_VQRDMULH_qr_m<MVE_v16s8>; 5601defm MVE_VQRDMULH_qr_s16 : MVE_VQRDMULH_qr_m<MVE_v8s16>; 5602defm MVE_VQRDMULH_qr_s32 : MVE_VQRDMULH_qr_m<MVE_v4s32>; 5603 5604multiclass MVE_VxxMUL_qr_f_m<MVEVectorVTInfo VTI, SDPatternOperator IdentityVec> { 5605 let validForTailPredication = 1 in 5606 def "" : MVE_VxxMUL_qr<"vmul", VTI.Suffix, VTI.Size{0}, 0b11, VTI.Size>; 5607 defm : MVE_TwoOpPatternDup<VTI, fmul, int_arm_mve_mul_predicated, (? ), 5608 !cast<Instruction>(NAME), IdentityVec>; 5609} 5610 5611let Predicates = [HasMVEFloat] in { 5612 defm MVE_VMUL_qr_f16 : MVE_VxxMUL_qr_f_m<MVE_v8f16, ARMimmOneH>; 5613 defm MVE_VMUL_qr_f32 : MVE_VxxMUL_qr_f_m<MVE_v4f32, ARMimmOneF>; 5614} 5615 5616class MVE_VFMAMLA_qr<string iname, string suffix, 5617 bit bit_28, bits<2> bits_21_20, bit S, 5618 bits<2> vecsize, list<dag> pattern=[]> 5619 : MVE_qDestSrc_rSrc<iname, suffix, vecsize, pattern> { 5620 5621 let Inst{28} = bit_28; 5622 let Inst{21-20} = bits_21_20; 5623 let Inst{16} = 0b1; 5624 let Inst{12} = S; 5625 let Inst{8} = 0b0; 5626 let Inst{5} = 0b0; 5627 let validForTailPredication = 1; 5628 let hasSideEffects = 0; 5629} 5630 5631multiclass MVE_VMLA_qr_multi<string iname, MVEVectorVTInfo VTI, 5632 bit scalar_addend> { 5633 def "": MVE_VFMAMLA_qr<iname, VTI.Suffix, 0b0, VTI.Size, 5634 scalar_addend, VTI.Size>; 5635 defvar Inst = !cast<Instruction>(NAME); 5636 defvar pred_int = !cast<Intrinsic>("int_arm_mve_" # iname # "_n_predicated"); 5637 defvar v1 = (VTI.Vec MQPR:$v1); 5638 defvar v2 = (VTI.Vec MQPR:$v2); 5639 defvar vs = (VTI.Vec (ARMvdup rGPR:$s)); 5640 defvar s = (i32 rGPR:$s); 5641 defvar pred = (VTI.Pred VCCR:$pred); 5642 5643 let Predicates = [HasMVEInt] in { 5644 if scalar_addend then { 5645 def : Pat<(VTI.Vec (add (mul v1, v2), vs)), 5646 (VTI.Vec (Inst v1, v2, s))>; 5647 } else { 5648 def : Pat<(VTI.Vec (add (mul v2, vs), v1)), 5649 (VTI.Vec (Inst v1, v2, s))>; 5650 } 5651 5652 def : Pat<(VTI.Vec (pred_int v1, v2, s, pred)), 5653 (VTI.Vec (Inst v1, v2, s, ARMVCCThen, pred, zero_reg))>; 5654 } 5655} 5656 5657defm MVE_VMLA_qr_i8 : MVE_VMLA_qr_multi<"vmla", MVE_v16i8, 0b0>; 5658defm MVE_VMLA_qr_i16 : MVE_VMLA_qr_multi<"vmla", MVE_v8i16, 0b0>; 5659defm MVE_VMLA_qr_i32 : MVE_VMLA_qr_multi<"vmla", MVE_v4i32, 0b0>; 5660 5661defm MVE_VMLAS_qr_i8 : MVE_VMLA_qr_multi<"vmlas", MVE_v16i8, 0b1>; 5662defm MVE_VMLAS_qr_i16 : MVE_VMLA_qr_multi<"vmlas", MVE_v8i16, 0b1>; 5663defm MVE_VMLAS_qr_i32 : MVE_VMLA_qr_multi<"vmlas", MVE_v4i32, 0b1>; 5664 5665multiclass MVE_VFMA_qr_multi<string iname, MVEVectorVTInfo VTI, 5666 bit scalar_addend> { 5667 def "": MVE_VFMAMLA_qr<iname, VTI.Suffix, VTI.Size{0}, 0b11, scalar_addend, VTI.Size>; 5668 defvar Inst = !cast<Instruction>(NAME); 5669 defvar pred_int = int_arm_mve_fma_predicated; 5670 defvar v1 = (VTI.Vec MQPR:$v1); 5671 defvar v2 = (VTI.Vec MQPR:$v2); 5672 defvar vs = (VTI.Vec (ARMvdup (i32 rGPR:$s))); 5673 defvar is = (i32 rGPR:$s); 5674 defvar pred = (VTI.Pred VCCR:$pred); 5675 5676 let Predicates = [HasMVEFloat] in { 5677 if scalar_addend then { 5678 def : Pat<(VTI.Vec (fma v1, v2, vs)), 5679 (VTI.Vec (Inst v1, v2, is))>; 5680 def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred), 5681 (VTI.Vec (fma v1, v2, vs)), 5682 v1)), 5683 (VTI.Vec (Inst v1, v2, is, ARMVCCThen, $pred, zero_reg))>; 5684 def : Pat<(VTI.Vec (pred_int v1, v2, vs, pred)), 5685 (VTI.Vec (Inst v1, v2, is, ARMVCCThen, pred, zero_reg))>; 5686 } else { 5687 def : Pat<(VTI.Vec (fma v1, vs, v2)), 5688 (VTI.Vec (Inst v2, v1, is))>; 5689 def : Pat<(VTI.Vec (fma vs, v1, v2)), 5690 (VTI.Vec (Inst v2, v1, is))>; 5691 def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred), 5692 (VTI.Vec (fma vs, v2, v1)), 5693 v1)), 5694 (VTI.Vec (Inst v1, v2, is, ARMVCCThen, $pred, zero_reg))>; 5695 def : Pat<(VTI.Vec (vselect (VTI.Pred VCCR:$pred), 5696 (VTI.Vec (fma v2, vs, v1)), 5697 v1)), 5698 (VTI.Vec (Inst v1, v2, is, ARMVCCThen, $pred, zero_reg))>; 5699 def : Pat<(VTI.Vec (pred_int v1, vs, v2, pred)), 5700 (VTI.Vec (Inst v2, v1, is, ARMVCCThen, pred, zero_reg))>; 5701 def : Pat<(VTI.Vec (pred_int vs, v1, v2, pred)), 5702 (VTI.Vec (Inst v2, v1, is, ARMVCCThen, pred, zero_reg))>; 5703 } 5704 } 5705} 5706 5707let Predicates = [HasMVEFloat] in { 5708 defm MVE_VFMA_qr_f16 : MVE_VFMA_qr_multi<"vfma", MVE_v8f16, 0>; 5709 defm MVE_VFMA_qr_f32 : MVE_VFMA_qr_multi<"vfma", MVE_v4f32, 0>; 5710 defm MVE_VFMA_qr_Sf16 : MVE_VFMA_qr_multi<"vfmas", MVE_v8f16, 1>; 5711 defm MVE_VFMA_qr_Sf32 : MVE_VFMA_qr_multi<"vfmas", MVE_v4f32, 1>; 5712} 5713 5714class MVE_VQDMLAH_qr<string iname, string suffix, bit U, bits<2> size, 5715 bit bit_5, bit bit_12, list<dag> pattern=[]> 5716 : MVE_qDestSrc_rSrc<iname, suffix, size, pattern> { 5717 5718 let Inst{28} = U; 5719 let Inst{21-20} = size; 5720 let Inst{16} = 0b0; 5721 let Inst{12} = bit_12; 5722 let Inst{8} = 0b0; 5723 let Inst{5} = bit_5; 5724} 5725 5726multiclass MVE_VQDMLAH_qr_multi<string iname, MVEVectorVTInfo VTI, 5727 bit bit_5, bit bit_12> { 5728 def "": MVE_VQDMLAH_qr<iname, VTI.Suffix, 0b0, VTI.Size, bit_5, bit_12>; 5729 defvar Inst = !cast<Instruction>(NAME); 5730 defvar unpred_int = !cast<Intrinsic>("int_arm_mve_" # iname); 5731 defvar pred_int = !cast<Intrinsic>("int_arm_mve_" # iname # "_predicated"); 5732 5733 let Predicates = [HasMVEInt] in { 5734 def : Pat<(VTI.Vec (unpred_int (VTI.Vec MQPR:$v1), (VTI.Vec MQPR:$v2), 5735 (i32 rGPR:$s))), 5736 (VTI.Vec (Inst (VTI.Vec MQPR:$v1), (VTI.Vec MQPR:$v2), 5737 (i32 rGPR:$s)))>; 5738 def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$v1), (VTI.Vec MQPR:$v2), 5739 (i32 rGPR:$s), (VTI.Pred VCCR:$pred))), 5740 (VTI.Vec (Inst (VTI.Vec MQPR:$v1), (VTI.Vec MQPR:$v2), 5741 (i32 rGPR:$s), ARMVCCThen, 5742 (VTI.Pred VCCR:$pred), zero_reg))>; 5743 } 5744} 5745 5746multiclass MVE_VQDMLAH_qr_types<string iname, bit bit_5, bit bit_12> { 5747 defm s8 : MVE_VQDMLAH_qr_multi<iname, MVE_v16s8, bit_5, bit_12>; 5748 defm s16 : MVE_VQDMLAH_qr_multi<iname, MVE_v8s16, bit_5, bit_12>; 5749 defm s32 : MVE_VQDMLAH_qr_multi<iname, MVE_v4s32, bit_5, bit_12>; 5750} 5751 5752defm MVE_VQDMLAH_qr : MVE_VQDMLAH_qr_types<"vqdmlah", 0b1, 0b0>; 5753defm MVE_VQRDMLAH_qr : MVE_VQDMLAH_qr_types<"vqrdmlah", 0b0, 0b0>; 5754defm MVE_VQDMLASH_qr : MVE_VQDMLAH_qr_types<"vqdmlash", 0b1, 0b1>; 5755defm MVE_VQRDMLASH_qr : MVE_VQDMLAH_qr_types<"vqrdmlash", 0b0, 0b1>; 5756 5757class MVE_VxDUP<string iname, string suffix, bits<2> size, bit bit_12, 5758 ValueType VT, SDPatternOperator vxdup> 5759 : MVE_p<(outs MQPR:$Qd, tGPREven:$Rn), 5760 (ins tGPREven:$Rn_src, MVE_VIDUP_imm:$imm), NoItinerary, 5761 iname, suffix, "$Qd, $Rn, $imm", vpred_r, "$Rn = $Rn_src", size, 5762 [(set (VT MQPR:$Qd), (i32 tGPREven:$Rn), 5763 (vxdup (i32 tGPREven:$Rn_src), (i32 imm:$imm)))]> { 5764 bits<4> Qd; 5765 bits<4> Rn; 5766 bits<2> imm; 5767 5768 let Inst{28} = 0b0; 5769 let Inst{25-23} = 0b100; 5770 let Inst{22} = Qd{3}; 5771 let Inst{21-20} = size; 5772 let Inst{19-17} = Rn{3-1}; 5773 let Inst{16} = 0b1; 5774 let Inst{15-13} = Qd{2-0}; 5775 let Inst{12} = bit_12; 5776 let Inst{11-8} = 0b1111; 5777 let Inst{7} = imm{1}; 5778 let Inst{6-1} = 0b110111; 5779 let Inst{0} = imm{0}; 5780 let validForTailPredication = 1; 5781 let hasSideEffects = 0; 5782} 5783 5784def MVE_VIDUPu8 : MVE_VxDUP<"vidup", "u8", 0b00, 0b0, v16i8, ARMvidup>; 5785def MVE_VIDUPu16 : MVE_VxDUP<"vidup", "u16", 0b01, 0b0, v8i16, ARMvidup>; 5786def MVE_VIDUPu32 : MVE_VxDUP<"vidup", "u32", 0b10, 0b0, v4i32, ARMvidup>; 5787 5788def MVE_VDDUPu8 : MVE_VxDUP<"vddup", "u8", 0b00, 0b1, v16i8, null_frag>; 5789def MVE_VDDUPu16 : MVE_VxDUP<"vddup", "u16", 0b01, 0b1, v8i16, null_frag>; 5790def MVE_VDDUPu32 : MVE_VxDUP<"vddup", "u32", 0b10, 0b1, v4i32, null_frag>; 5791 5792class MVE_VxWDUP<string iname, string suffix, bits<2> size, bit bit_12, 5793 list<dag> pattern=[]> 5794 : MVE_p<(outs MQPR:$Qd, tGPREven:$Rn), 5795 (ins tGPREven:$Rn_src, tGPROdd:$Rm, MVE_VIDUP_imm:$imm), NoItinerary, 5796 iname, suffix, "$Qd, $Rn, $Rm, $imm", vpred_r, "$Rn = $Rn_src", size, 5797 pattern> { 5798 bits<4> Qd; 5799 bits<4> Rm; 5800 bits<4> Rn; 5801 bits<2> imm; 5802 5803 let Inst{28} = 0b0; 5804 let Inst{25-23} = 0b100; 5805 let Inst{22} = Qd{3}; 5806 let Inst{21-20} = size; 5807 let Inst{19-17} = Rn{3-1}; 5808 let Inst{16} = 0b1; 5809 let Inst{15-13} = Qd{2-0}; 5810 let Inst{12} = bit_12; 5811 let Inst{11-8} = 0b1111; 5812 let Inst{7} = imm{1}; 5813 let Inst{6-4} = 0b110; 5814 let Inst{3-1} = Rm{3-1}; 5815 let Inst{0} = imm{0}; 5816 let validForTailPredication = 1; 5817 let hasSideEffects = 0; 5818} 5819 5820def MVE_VIWDUPu8 : MVE_VxWDUP<"viwdup", "u8", 0b00, 0b0>; 5821def MVE_VIWDUPu16 : MVE_VxWDUP<"viwdup", "u16", 0b01, 0b0>; 5822def MVE_VIWDUPu32 : MVE_VxWDUP<"viwdup", "u32", 0b10, 0b0>; 5823 5824def MVE_VDWDUPu8 : MVE_VxWDUP<"vdwdup", "u8", 0b00, 0b1>; 5825def MVE_VDWDUPu16 : MVE_VxWDUP<"vdwdup", "u16", 0b01, 0b1>; 5826def MVE_VDWDUPu32 : MVE_VxWDUP<"vdwdup", "u32", 0b10, 0b1>; 5827 5828let isReMaterializable = 1 in 5829class MVE_VCTPInst<string suffix, bits<2> size, list<dag> pattern=[]> 5830 : MVE_p<(outs VCCR:$P0), (ins rGPR:$Rn), NoItinerary, "vctp", suffix, 5831 "$Rn", vpred_n, "", size, pattern> { 5832 bits<4> Rn; 5833 5834 let Inst{28-27} = 0b10; 5835 let Inst{26-22} = 0b00000; 5836 let Inst{21-20} = size; 5837 let Inst{19-16} = Rn{3-0}; 5838 let Inst{15-11} = 0b11101; 5839 let Inst{10-0} = 0b00000000001; 5840 let Unpredictable{10-0} = 0b11111111111; 5841 5842 let Constraints = ""; 5843 let DecoderMethod = "DecodeMveVCTP"; 5844 let validForTailPredication = 1; 5845} 5846 5847multiclass MVE_VCTP<MVEVectorVTInfo VTI, Intrinsic intr> { 5848 def "": MVE_VCTPInst<VTI.BitsSuffix, VTI.Size>; 5849 defvar Inst = !cast<Instruction>(NAME); 5850 5851 let Predicates = [HasMVEInt] in { 5852 def : Pat<(intr rGPR:$Rn), 5853 (VTI.Pred (Inst rGPR:$Rn))>; 5854 def : Pat<(and (intr rGPR:$Rn), (VTI.Pred VCCR:$mask)), 5855 (VTI.Pred (Inst rGPR:$Rn, ARMVCCThen, VCCR:$mask, zero_reg))>; 5856 } 5857} 5858 5859defm MVE_VCTP8 : MVE_VCTP<MVE_v16i8, int_arm_mve_vctp8>; 5860defm MVE_VCTP16 : MVE_VCTP<MVE_v8i16, int_arm_mve_vctp16>; 5861defm MVE_VCTP32 : MVE_VCTP<MVE_v4i32, int_arm_mve_vctp32>; 5862defm MVE_VCTP64 : MVE_VCTP<MVE_v2i64, int_arm_mve_vctp64>; 5863 5864// end of mve_qDest_rSrc 5865 5866// start of coproc mov 5867 5868class MVE_VMOV_64bit<dag oops, dag iops, bit to_qreg, string ops, string cstr> 5869 : MVE_VMOV_lane_base<oops, !con(iops, (ins MVEPairVectorIndex2:$idx, 5870 MVEPairVectorIndex0:$idx2)), 5871 NoItinerary, "vmov", "", ops, cstr, []> { 5872 bits<5> Rt; 5873 bits<5> Rt2; 5874 bits<4> Qd; 5875 bit idx; 5876 bit idx2; 5877 5878 let Inst{31-23} = 0b111011000; 5879 let Inst{22} = Qd{3}; 5880 let Inst{21} = 0b0; 5881 let Inst{20} = to_qreg; 5882 let Inst{19-16} = Rt2{3-0}; 5883 let Inst{15-13} = Qd{2-0}; 5884 let Inst{12-5} = 0b01111000; 5885 let Inst{4} = idx2; 5886 let Inst{3-0} = Rt{3-0}; 5887 5888 let VecSize = 0b10; 5889 let hasSideEffects = 0; 5890} 5891 5892// The assembly syntax for these instructions mentions the vector 5893// register name twice, e.g. 5894// 5895// vmov q2[2], q2[0], r0, r1 5896// vmov r0, r1, q2[2], q2[0] 5897// 5898// which needs a bit of juggling with MC operand handling. 5899// 5900// For the move _into_ a vector register, the MC operand list also has 5901// to mention the register name twice: once as the output, and once as 5902// an extra input to represent where the unchanged half of the output 5903// register comes from (when this instruction is used in code 5904// generation). So we arrange that the first mention of the vector reg 5905// in the instruction is considered by the AsmMatcher to be the output 5906// ($Qd), and the second one is the input ($QdSrc). Binding them 5907// together with the existing 'tie' constraint is enough to enforce at 5908// register allocation time that they have to be the same register. 5909// 5910// For the move _from_ a vector register, there's no way to get round 5911// the fact that both instances of that register name have to be 5912// inputs. They have to be the same register again, but this time, we 5913// can't use a tie constraint, because that has to be between an 5914// output and an input operand. So this time, we have to arrange that 5915// the q-reg appears just once in the MC operand list, in spite of 5916// being mentioned twice in the asm syntax - which needs a custom 5917// AsmMatchConverter. 5918 5919def MVE_VMOV_q_rr : MVE_VMOV_64bit<(outs MQPR:$Qd), 5920 (ins MQPR:$QdSrc, rGPR:$Rt, rGPR:$Rt2), 5921 0b1, "$Qd$idx, $QdSrc$idx2, $Rt, $Rt2", 5922 "$Qd = $QdSrc"> { 5923 let DecoderMethod = "DecodeMVEVMOVDRegtoQ"; 5924} 5925 5926def MVE_VMOV_rr_q : MVE_VMOV_64bit<(outs rGPR:$Rt, rGPR:$Rt2), (ins MQPR:$Qd), 5927 0b0, "$Rt, $Rt2, $Qd$idx, $Qd$idx2", ""> { 5928 let DecoderMethod = "DecodeMVEVMOVQtoDReg"; 5929 let AsmMatchConverter = "cvtMVEVMOVQtoDReg"; 5930} 5931 5932let Predicates = [HasMVEInt] in { 5933 // Double lane moves. There are a number of patterns here. We know that the 5934 // insertelt's will be in descending order by index, and need to match the 5 5935 // patterns that might contain 2-0 or 3-1 pairs. These are: 5936 // 3 2 1 0 -> vmovqrr 31; vmovqrr 20 5937 // 3 2 1 -> vmovqrr 31; vmov 2 5938 // 3 1 -> vmovqrr 31 5939 // 2 1 0 -> vmovqrr 20; vmov 1 5940 // 2 0 -> vmovqrr 20 5941 // The other potential patterns will be handled by single lane inserts. 5942 def : Pat<(insertelt (insertelt (insertelt (insertelt (v4i32 MQPR:$src1), 5943 rGPR:$srcA, (i32 0)), 5944 rGPR:$srcB, (i32 1)), 5945 rGPR:$srcC, (i32 2)), 5946 rGPR:$srcD, (i32 3)), 5947 (MVE_VMOV_q_rr (MVE_VMOV_q_rr MQPR:$src1, rGPR:$srcA, rGPR:$srcC, (i32 2), (i32 0)), 5948 rGPR:$srcB, rGPR:$srcD, (i32 3), (i32 1))>; 5949 def : Pat<(insertelt (insertelt (insertelt (v4i32 MQPR:$src1), 5950 rGPR:$srcB, (i32 1)), 5951 rGPR:$srcC, (i32 2)), 5952 rGPR:$srcD, (i32 3)), 5953 (MVE_VMOV_q_rr (MVE_VMOV_to_lane_32 MQPR:$src1, rGPR:$srcC, (i32 2)), 5954 rGPR:$srcB, rGPR:$srcD, (i32 3), (i32 1))>; 5955 def : Pat<(insertelt (insertelt (v4i32 MQPR:$src1), rGPR:$srcA, (i32 1)), rGPR:$srcB, (i32 3)), 5956 (MVE_VMOV_q_rr MQPR:$src1, rGPR:$srcA, rGPR:$srcB, (i32 3), (i32 1))>; 5957 def : Pat<(insertelt (insertelt (insertelt (v4i32 MQPR:$src1), 5958 rGPR:$srcB, (i32 0)), 5959 rGPR:$srcC, (i32 1)), 5960 rGPR:$srcD, (i32 2)), 5961 (MVE_VMOV_q_rr (MVE_VMOV_to_lane_32 MQPR:$src1, rGPR:$srcC, (i32 1)), 5962 rGPR:$srcB, rGPR:$srcD, (i32 2), (i32 0))>; 5963 def : Pat<(insertelt (insertelt (v4i32 MQPR:$src1), rGPR:$srcA, (i32 0)), rGPR:$srcB, (i32 2)), 5964 (MVE_VMOV_q_rr MQPR:$src1, rGPR:$srcA, rGPR:$srcB, (i32 2), (i32 0))>; 5965} 5966 5967// end of coproc mov 5968 5969// start of MVE interleaving load/store 5970 5971// Base class for the family of interleaving/deinterleaving 5972// load/stores with names like VLD20.8 and VST43.32. 5973class MVE_vldst24_base<bit writeback, bit fourregs, bits<2> stage, bits<2> size, 5974 bit load, dag Oops, dag loadIops, dag wbIops, 5975 string iname, string ops, 5976 string cstr, list<dag> pattern=[]> 5977 : MVE_MI<Oops, !con(loadIops, wbIops), NoItinerary, iname, ops, cstr, size, pattern> { 5978 bits<4> VQd; 5979 bits<4> Rn; 5980 5981 let Inst{31-22} = 0b1111110010; 5982 let Inst{21} = writeback; 5983 let Inst{20} = load; 5984 let Inst{19-16} = Rn; 5985 let Inst{15-13} = VQd{2-0}; 5986 let Inst{12-9} = 0b1111; 5987 let Inst{8-7} = size; 5988 let Inst{6-5} = stage; 5989 let Inst{4-1} = 0b0000; 5990 let Inst{0} = fourregs; 5991 5992 let mayLoad = load; 5993 let mayStore = !eq(load,0); 5994 let hasSideEffects = 0; 5995 let validForTailPredication = load; 5996} 5997 5998// A parameter class used to encapsulate all the ways the writeback 5999// variants of VLD20 and friends differ from the non-writeback ones. 6000class MVE_vldst24_writeback<bit b, dag Oo, dag Io, 6001 string sy="", string c="", string n=""> { 6002 bit writeback = b; 6003 dag Oops = Oo; 6004 dag Iops = Io; 6005 string syntax = sy; 6006 string cstr = c; 6007 string id_suffix = n; 6008} 6009 6010// Another parameter class that encapsulates the differences between VLD2x 6011// and VLD4x. 6012class MVE_vldst24_nvecs<int n, list<int> s, bit b, RegisterOperand vl> { 6013 int nvecs = n; 6014 list<int> stages = s; 6015 bit bit0 = b; 6016 RegisterOperand VecList = vl; 6017} 6018 6019// A third parameter class that distinguishes VLDnn.8 from .16 from .32. 6020class MVE_vldst24_lanesize<int i, bits<2> b> { 6021 int lanesize = i; 6022 bits<2> sizebits = b; 6023} 6024 6025// A base class for each direction of transfer: one for load, one for 6026// store. I can't make these a fourth independent parametric tuple 6027// class, because they have to take the nvecs tuple class as a 6028// parameter, in order to find the right VecList operand type. 6029 6030class MVE_vld24_base<MVE_vldst24_nvecs n, bits<2> pat, bits<2> size, 6031 MVE_vldst24_writeback wb, string iname, 6032 list<dag> pattern=[]> 6033 : MVE_vldst24_base<wb.writeback, n.bit0, pat, size, 1, 6034 !con((outs n.VecList:$VQd), wb.Oops), 6035 (ins n.VecList:$VQdSrc), wb.Iops, 6036 iname, "$VQd, $Rn" # wb.syntax, 6037 wb.cstr # ",$VQdSrc = $VQd", pattern>; 6038 6039class MVE_vst24_base<MVE_vldst24_nvecs n, bits<2> pat, bits<2> size, 6040 MVE_vldst24_writeback wb, string iname, 6041 list<dag> pattern=[]> 6042 : MVE_vldst24_base<wb.writeback, n.bit0, pat, size, 0, 6043 wb.Oops, (ins n.VecList:$VQd), wb.Iops, 6044 iname, "$VQd, $Rn" # wb.syntax, 6045 wb.cstr, pattern>; 6046 6047// Actually define all the interleaving loads and stores, by a series 6048// of nested foreaches over number of vectors (VLD2/VLD4); stage 6049// within one of those series (VLDx0/VLDx1/VLDx2/VLDx3); size of 6050// vector lane; writeback or no writeback. 6051foreach n = [MVE_vldst24_nvecs<2, [0,1], 0, VecList2Q>, 6052 MVE_vldst24_nvecs<4, [0,1,2,3], 1, VecList4Q>] in 6053foreach stage = n.stages in 6054foreach s = [MVE_vldst24_lanesize< 8, 0b00>, 6055 MVE_vldst24_lanesize<16, 0b01>, 6056 MVE_vldst24_lanesize<32, 0b10>] in 6057foreach wb = [MVE_vldst24_writeback< 6058 1, (outs rGPR:$wb), (ins t2_nosp_addr_offset_none:$Rn), 6059 "!", "$Rn.base = $wb", "_wb">, 6060 MVE_vldst24_writeback<0, (outs), (ins t2_addr_offset_none:$Rn)>] in { 6061 6062 // For each case within all of those foreaches, define the actual 6063 // instructions. The def names are made by gluing together pieces 6064 // from all the parameter classes, and will end up being things like 6065 // MVE_VLD20_8 and MVE_VST43_16_wb. 6066 6067 def "MVE_VLD" # n.nvecs # stage # "_" # s.lanesize # wb.id_suffix 6068 : MVE_vld24_base<n, stage, s.sizebits, wb, 6069 "vld" # n.nvecs # stage # "." # s.lanesize>; 6070 6071 def "MVE_VST" # n.nvecs # stage # "_" # s.lanesize # wb.id_suffix 6072 : MVE_vst24_base<n, stage, s.sizebits, wb, 6073 "vst" # n.nvecs # stage # "." # s.lanesize>; 6074} 6075 6076def SDTARMVST2 : SDTypeProfile<1, 5, [SDTCisPtrTy<0>, SDTCisPtrTy<1>, SDTCisVT<2, i32>, SDTCisVec<3>, 6077 SDTCisSameAs<3, 4>, SDTCisVT<5, i32>]>; 6078def SDTARMVST4 : SDTypeProfile<1, 7, [SDTCisPtrTy<0>, SDTCisPtrTy<1>, SDTCisVT<2, i32>, SDTCisVec<3>, 6079 SDTCisSameAs<3, 4>, SDTCisSameAs<3, 5>, 6080 SDTCisSameAs<3, 6>, SDTCisVT<7, i32>]>; 6081def MVEVST2UPD : SDNode<"ARMISD::VST2_UPD", SDTARMVST2, [SDNPHasChain, SDNPMemOperand]>; 6082def MVEVST4UPD : SDNode<"ARMISD::VST4_UPD", SDTARMVST4, [SDNPHasChain, SDNPMemOperand]>; 6083 6084multiclass MVE_vst24_patterns<int lanesize, ValueType VT> { 6085 foreach stage = [0,1] in 6086 def : Pat<(int_arm_mve_vst2q i32:$addr, 6087 (VT MQPR:$v0), (VT MQPR:$v1), (i32 stage)), 6088 (!cast<Instruction>("MVE_VST2"#stage#"_"#lanesize) 6089 (REG_SEQUENCE MQQPR, VT:$v0, qsub_0, VT:$v1, qsub_1), 6090 t2_addr_offset_none:$addr)>; 6091 foreach stage = [0,1] in 6092 def : Pat<(i32 (MVEVST2UPD i32:$addr, (i32 32), 6093 (VT MQPR:$v0), (VT MQPR:$v1), (i32 stage))), 6094 (i32 (!cast<Instruction>("MVE_VST2"#stage#"_"#lanesize#_wb) 6095 (REG_SEQUENCE MQQPR, VT:$v0, qsub_0, VT:$v1, qsub_1), 6096 t2_addr_offset_none:$addr))>; 6097 6098 foreach stage = [0,1,2,3] in 6099 def : Pat<(int_arm_mve_vst4q i32:$addr, 6100 (VT MQPR:$v0), (VT MQPR:$v1), 6101 (VT MQPR:$v2), (VT MQPR:$v3), (i32 stage)), 6102 (!cast<Instruction>("MVE_VST4"#stage#"_"#lanesize) 6103 (REG_SEQUENCE MQQQQPR, VT:$v0, qsub_0, VT:$v1, qsub_1, 6104 VT:$v2, qsub_2, VT:$v3, qsub_3), 6105 t2_addr_offset_none:$addr)>; 6106 foreach stage = [0,1,2,3] in 6107 def : Pat<(i32 (MVEVST4UPD i32:$addr, (i32 64), 6108 (VT MQPR:$v0), (VT MQPR:$v1), 6109 (VT MQPR:$v2), (VT MQPR:$v3), (i32 stage))), 6110 (i32 (!cast<Instruction>("MVE_VST4"#stage#"_"#lanesize#_wb) 6111 (REG_SEQUENCE MQQQQPR, VT:$v0, qsub_0, VT:$v1, qsub_1, 6112 VT:$v2, qsub_2, VT:$v3, qsub_3), 6113 t2_addr_offset_none:$addr))>; 6114} 6115defm : MVE_vst24_patterns<8, v16i8>; 6116defm : MVE_vst24_patterns<16, v8i16>; 6117defm : MVE_vst24_patterns<32, v4i32>; 6118defm : MVE_vst24_patterns<16, v8f16>; 6119defm : MVE_vst24_patterns<32, v4f32>; 6120 6121// end of MVE interleaving load/store 6122 6123// start of MVE predicable load/store 6124 6125// A parameter class for the direction of transfer. 6126class MVE_ldst_direction<bit b, dag Oo, dag Io, string c=""> { 6127 bit load = b; 6128 dag Oops = Oo; 6129 dag Iops = Io; 6130 string cstr = c; 6131} 6132def MVE_ld: MVE_ldst_direction<1, (outs MQPR:$Qd), (ins), ",@earlyclobber $Qd">; 6133def MVE_st: MVE_ldst_direction<0, (outs), (ins MQPR:$Qd)>; 6134 6135// A parameter class for the size of memory access in a load. 6136class MVE_memsz<bits<2> e, int s, AddrMode m, string mn, list<string> types> { 6137 bits<2> encoding = e; // opcode bit(s) for encoding 6138 int shift = s; // shift applied to immediate load offset 6139 AddrMode AM = m; 6140 6141 // For instruction aliases: define the complete list of type 6142 // suffixes at this size, and the canonical ones for loads and 6143 // stores. 6144 string MnemonicLetter = mn; 6145 int TypeBits = !shl(8, s); 6146 string CanonLoadSuffix = ".u" # TypeBits; 6147 string CanonStoreSuffix = "." # TypeBits; 6148 list<string> suffixes = !foreach(letter, types, "." # letter # TypeBits); 6149} 6150 6151// Instances of MVE_memsz. 6152// 6153// (memD doesn't need an AddrMode, because those are only for 6154// contiguous loads, and memD is only used by gather/scatters.) 6155def MVE_memB: MVE_memsz<0b00, 0, AddrModeT2_i7, "b", ["", "u", "s"]>; 6156def MVE_memH: MVE_memsz<0b01, 1, AddrModeT2_i7s2, "h", ["", "u", "s", "f"]>; 6157def MVE_memW: MVE_memsz<0b10, 2, AddrModeT2_i7s4, "w", ["", "u", "s", "f"]>; 6158def MVE_memD: MVE_memsz<0b11, 3, ?, "d", ["", "u", "s", "f"]>; 6159 6160// This is the base class for all the MVE loads and stores other than 6161// the interleaving ones. All the non-interleaving loads/stores share 6162// the characteristic that they operate on just one vector register, 6163// so they are VPT-predicable. 6164// 6165// The predication operand is vpred_n, for both loads and stores. For 6166// store instructions, the reason is obvious: if there is no output 6167// register, there can't be a need for an input parameter giving the 6168// output register's previous value. Load instructions also don't need 6169// that input parameter, because unlike MVE data processing 6170// instructions, predicated loads are defined to set the inactive 6171// lanes of the output register to zero, instead of preserving their 6172// input values. 6173class MVE_VLDRSTR_base<MVE_ldst_direction dir, bit U, bit P, bit W, bit opc, 6174 dag oops, dag iops, string asm, string suffix, 6175 string ops, string cstr, bits<2> vecsize, list<dag> pattern=[]> 6176 : MVE_p<oops, iops, NoItinerary, asm, suffix, ops, vpred_n, cstr, vecsize, pattern> { 6177 bits<3> Qd; 6178 6179 let Inst{28} = U; 6180 let Inst{25} = 0b0; 6181 let Inst{24} = P; 6182 let Inst{22} = 0b0; 6183 let Inst{21} = W; 6184 let Inst{20} = dir.load; 6185 let Inst{15-13} = Qd{2-0}; 6186 let Inst{12} = opc; 6187 let Inst{11-9} = 0b111; 6188 6189 let mayLoad = dir.load; 6190 let mayStore = !eq(dir.load,0); 6191 let hasSideEffects = 0; 6192 let validForTailPredication = 1; 6193} 6194 6195// Contiguous load and store instructions. These come in two main 6196// categories: same-size loads/stores in which 128 bits of vector 6197// register is transferred to or from 128 bits of memory in the most 6198// obvious way, and widening loads / narrowing stores, in which the 6199// size of memory accessed is less than the size of a vector register, 6200// so the load instructions sign- or zero-extend each memory value 6201// into a wider vector lane, and the store instructions truncate 6202// correspondingly. 6203// 6204// The instruction mnemonics for these two classes look reasonably 6205// similar, but the actual encodings are different enough to need two 6206// separate base classes. 6207 6208// Contiguous, same size 6209class MVE_VLDRSTR_cs<MVE_ldst_direction dir, MVE_memsz memsz, bit P, bit W, 6210 dag oops, dag iops, string asm, string suffix, 6211 IndexMode im, string ops, string cstr> 6212 : MVE_VLDRSTR_base<dir, 0, P, W, 1, oops, iops, asm, suffix, ops, cstr, memsz.encoding> { 6213 bits<12> addr; 6214 let Inst{23} = addr{7}; 6215 let Inst{19-16} = addr{11-8}; 6216 let Inst{8-7} = memsz.encoding; 6217 let Inst{6-0} = addr{6-0}; 6218 6219 let IM = im; 6220} 6221 6222// Contiguous, widening/narrowing 6223class MVE_VLDRSTR_cw<MVE_ldst_direction dir, MVE_memsz memsz, bit U, 6224 bit P, bit W, bits<2> size, dag oops, dag iops, 6225 string asm, string suffix, IndexMode im, 6226 string ops, string cstr> 6227 : MVE_VLDRSTR_base<dir, U, P, W, 0, oops, iops, asm, suffix, ops, cstr, size> { 6228 bits<11> addr; 6229 let Inst{23} = addr{7}; 6230 let Inst{19} = memsz.encoding{0}; // enough to tell 16- from 32-bit 6231 let Inst{18-16} = addr{10-8}; 6232 let Inst{8-7} = size; 6233 let Inst{6-0} = addr{6-0}; 6234 6235 let IM = im; 6236} 6237 6238// Multiclass wrapper on each of the _cw and _cs base classes, to 6239// generate three writeback modes (none, preindex, postindex). 6240 6241multiclass MVE_VLDRSTR_cw_m<MVE_ldst_direction dir, MVE_memsz memsz, 6242 string asm, string suffix, bit U, bits<2> size> { 6243 let AM = memsz.AM in { 6244 def "" : MVE_VLDRSTR_cw< 6245 dir, memsz, U, 1, 0, size, 6246 dir.Oops, !con(dir.Iops, (ins taddrmode_imm7<memsz.shift>:$addr)), 6247 asm, suffix, IndexModeNone, "$Qd, $addr", "">; 6248 6249 def _pre : MVE_VLDRSTR_cw< 6250 dir, memsz, U, 1, 1, size, 6251 !con((outs tGPR:$wb), dir.Oops), 6252 !con(dir.Iops, (ins taddrmode_imm7<memsz.shift>:$addr)), 6253 asm, suffix, IndexModePre, "$Qd, $addr!", "$addr.base = $wb"> { 6254 let DecoderMethod = "DecodeMVE_MEM_1_pre<"#memsz.shift#">"; 6255 } 6256 6257 def _post : MVE_VLDRSTR_cw< 6258 dir, memsz, U, 0, 1, size, 6259 !con((outs tGPR:$wb), dir.Oops), 6260 !con(dir.Iops, (ins t_addr_offset_none:$Rn, 6261 t2am_imm7_offset<memsz.shift>:$addr)), 6262 asm, suffix, IndexModePost, "$Qd, $Rn$addr", "$Rn.base = $wb"> { 6263 bits<4> Rn; 6264 let Inst{18-16} = Rn{2-0}; 6265 } 6266 } 6267} 6268 6269multiclass MVE_VLDRSTR_cs_m<MVE_ldst_direction dir, MVE_memsz memsz, 6270 string asm, string suffix> { 6271 let AM = memsz.AM in { 6272 def "" : MVE_VLDRSTR_cs< 6273 dir, memsz, 1, 0, 6274 dir.Oops, !con(dir.Iops, (ins t2addrmode_imm7<memsz.shift>:$addr)), 6275 asm, suffix, IndexModeNone, "$Qd, $addr", "">; 6276 6277 def _pre : MVE_VLDRSTR_cs< 6278 dir, memsz, 1, 1, 6279 !con((outs rGPR:$wb), dir.Oops), 6280 !con(dir.Iops, (ins t2addrmode_imm7_pre<memsz.shift>:$addr)), 6281 asm, suffix, IndexModePre, "$Qd, $addr!", "$addr.base = $wb"> { 6282 let DecoderMethod = "DecodeMVE_MEM_2_pre<"#memsz.shift#">"; 6283 } 6284 6285 def _post : MVE_VLDRSTR_cs< 6286 dir, memsz, 0, 1, 6287 !con((outs rGPR:$wb), dir.Oops), 6288 !con(dir.Iops, (ins t2_nosp_addr_offset_none:$Rn, 6289 t2am_imm7_offset<memsz.shift>:$addr)), 6290 asm, suffix, IndexModePost, "$Qd, $Rn$addr", "$Rn.base = $wb"> { 6291 bits<4> Rn; 6292 let Inst{19-16} = Rn{3-0}; 6293 } 6294 } 6295} 6296 6297// Now actually declare all the contiguous load/stores, via those 6298// multiclasses. The instruction ids coming out of this are the bare 6299// names shown in the defm, with _pre or _post appended for writeback, 6300// e.g. MVE_VLDRBS16, MVE_VSTRB16_pre, MVE_VSTRHU16_post. 6301 6302defm MVE_VLDRBS16: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "s16", 0, 0b01>; 6303defm MVE_VLDRBS32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "s32", 0, 0b10>; 6304defm MVE_VLDRBU16: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "u16", 1, 0b01>; 6305defm MVE_VLDRBU32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memB, "vldrb", "u32", 1, 0b10>; 6306defm MVE_VLDRHS32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memH, "vldrh", "s32", 0, 0b10>; 6307defm MVE_VLDRHU32: MVE_VLDRSTR_cw_m<MVE_ld, MVE_memH, "vldrh", "u32", 1, 0b10>; 6308 6309defm MVE_VLDRBU8: MVE_VLDRSTR_cs_m<MVE_ld, MVE_memB, "vldrb", "u8">; 6310defm MVE_VLDRHU16: MVE_VLDRSTR_cs_m<MVE_ld, MVE_memH, "vldrh", "u16">; 6311defm MVE_VLDRWU32: MVE_VLDRSTR_cs_m<MVE_ld, MVE_memW, "vldrw", "u32">; 6312 6313defm MVE_VSTRB16: MVE_VLDRSTR_cw_m<MVE_st, MVE_memB, "vstrb", "16", 0, 0b01>; 6314defm MVE_VSTRB32: MVE_VLDRSTR_cw_m<MVE_st, MVE_memB, "vstrb", "32", 0, 0b10>; 6315defm MVE_VSTRH32: MVE_VLDRSTR_cw_m<MVE_st, MVE_memH, "vstrh", "32", 0, 0b10>; 6316 6317defm MVE_VSTRBU8 : MVE_VLDRSTR_cs_m<MVE_st, MVE_memB, "vstrb", "8">; 6318defm MVE_VSTRHU16: MVE_VLDRSTR_cs_m<MVE_st, MVE_memH, "vstrh", "16">; 6319defm MVE_VSTRWU32: MVE_VLDRSTR_cs_m<MVE_st, MVE_memW, "vstrw", "32">; 6320 6321// Gather loads / scatter stores whose address operand is of the form 6322// [Rn,Qm], i.e. a single GPR as the common base address, plus a 6323// vector of offset from it. ('Load/store this sequence of elements of 6324// the same array.') 6325// 6326// Like the contiguous family, these loads and stores can widen the 6327// loaded values / truncate the stored ones, or they can just 6328// load/store the same size of memory and vector lane. But unlike the 6329// contiguous family, there's no particular difference in encoding 6330// between those two cases. 6331// 6332// This family also comes with the option to scale the offset values 6333// in Qm by the size of the loaded memory (i.e. to treat them as array 6334// indices), or not to scale them (to treat them as plain byte offsets 6335// in memory, so that perhaps the loaded values are unaligned). The 6336// scaled instructions' address operand in assembly looks like 6337// [Rn,Qm,UXTW #2] or similar. 6338 6339// Base class. 6340class MVE_VLDRSTR_rq<MVE_ldst_direction dir, MVE_memsz memsz, bit U, 6341 bits<2> size, bit os, string asm, string suffix, int shift> 6342 : MVE_VLDRSTR_base<dir, U, 0b0, 0b0, 0, dir.Oops, 6343 !con(dir.Iops, (ins mve_addr_rq_shift<shift>:$addr)), 6344 asm, suffix, "$Qd, $addr", dir.cstr, size> { 6345 bits<7> addr; 6346 let Inst{23} = 0b1; 6347 let Inst{19-16} = addr{6-3}; 6348 let Inst{8-7} = size; 6349 let Inst{6} = memsz.encoding{1}; 6350 let Inst{5} = 0; 6351 let Inst{4} = memsz.encoding{0}; 6352 let Inst{3-1} = addr{2-0}; 6353 let Inst{0} = os; 6354} 6355 6356// Multiclass that defines the scaled and unscaled versions of an 6357// instruction, when the memory size is wider than a byte. The scaled 6358// version gets the default name like MVE_VLDRBU16_rq; the unscaled / 6359// potentially unaligned version gets a "_u" suffix, e.g. 6360// MVE_VLDRBU16_rq_u. 6361multiclass MVE_VLDRSTR_rq_w<MVE_ldst_direction dir, MVE_memsz memsz, 6362 string asm, string suffix, bit U, bits<2> size> { 6363 def _u : MVE_VLDRSTR_rq<dir, memsz, U, size, 0, asm, suffix, 0>; 6364 def "" : MVE_VLDRSTR_rq<dir, memsz, U, size, 1, asm, suffix, memsz.shift>; 6365} 6366 6367// Subclass of MVE_VLDRSTR_rq with the same API as that multiclass, 6368// for use when the memory size is one byte, so there's no 'scaled' 6369// version of the instruction at all. (This is encoded as if it were 6370// unscaled, but named in the default way with no _u suffix.) 6371class MVE_VLDRSTR_rq_b<MVE_ldst_direction dir, MVE_memsz memsz, 6372 string asm, string suffix, bit U, bits<2> size> 6373 : MVE_VLDRSTR_rq<dir, memsz, U, size, 0, asm, suffix, 0>; 6374 6375// Multiclasses wrapping that to add ISel patterns for intrinsics. 6376multiclass MVE_VLDR_rq_w<MVE_memsz memsz, list<MVEVectorVTInfo> VTIs> { 6377 defm "": MVE_VLDRSTR_rq_w<MVE_ld, memsz, "vldr" # memsz.MnemonicLetter, 6378 VTIs[0].Suffix, VTIs[0].Unsigned, VTIs[0].Size>; 6379 defvar Inst = !cast<Instruction>(NAME); 6380 defvar InstU = !cast<Instruction>(NAME # "_u"); 6381 6382 foreach VTI = VTIs in 6383 foreach UnsignedFlag = !if(!eq(VTI.Size, memsz.encoding), 6384 [0,1], [VTI.Unsigned]) in { 6385 def : Pat<(VTI.Vec (int_arm_mve_vldr_gather_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), memsz.TypeBits, 0, UnsignedFlag)), 6386 (VTI.Vec (InstU GPR:$base, MQPR:$offsets))>; 6387 def : Pat<(VTI.Vec (int_arm_mve_vldr_gather_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), memsz.TypeBits, memsz.shift, UnsignedFlag)), 6388 (VTI.Vec (Inst GPR:$base, MQPR:$offsets))>; 6389 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))), 6390 (VTI.Vec (InstU GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg))>; 6391 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))), 6392 (VTI.Vec (Inst GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg))>; 6393 } 6394} 6395multiclass MVE_VLDR_rq_b<list<MVEVectorVTInfo> VTIs> { 6396 def "": MVE_VLDRSTR_rq_b<MVE_ld, MVE_memB, "vldrb", 6397 VTIs[0].Suffix, VTIs[0].Unsigned, VTIs[0].Size>; 6398 defvar Inst = !cast<Instruction>(NAME); 6399 6400 foreach VTI = VTIs in { 6401 def : Pat<(VTI.Vec (int_arm_mve_vldr_gather_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), 8, 0, VTI.Unsigned)), 6402 (VTI.Vec (Inst GPR:$base, MQPR:$offsets))>; 6403 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))), 6404 (VTI.Vec (Inst GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg))>; 6405 } 6406} 6407multiclass MVE_VSTR_rq_w<MVE_memsz memsz, list<MVEVectorVTInfo> VTIs> { 6408 defm "": MVE_VLDRSTR_rq_w<MVE_st, memsz, "vstr" # memsz.MnemonicLetter, 6409 VTIs[0].BitsSuffix, 0, VTIs[0].Size>; 6410 defvar Inst = !cast<Instruction>(NAME); 6411 defvar InstU = !cast<Instruction>(NAME # "_u"); 6412 6413 foreach VTI = VTIs in { 6414 def : Pat<(int_arm_mve_vstr_scatter_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), (VTI.Vec MQPR:$data), memsz.TypeBits, 0), 6415 (InstU MQPR:$data, GPR:$base, MQPR:$offsets)>; 6416 def : Pat<(int_arm_mve_vstr_scatter_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), (VTI.Vec MQPR:$data), memsz.TypeBits, memsz.shift), 6417 (Inst MQPR:$data, GPR:$base, MQPR:$offsets)>; 6418 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)), 6419 (InstU MQPR:$data, GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg)>; 6420 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)), 6421 (Inst MQPR:$data, GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg)>; 6422 } 6423} 6424multiclass MVE_VSTR_rq_b<list<MVEVectorVTInfo> VTIs> { 6425 def "": MVE_VLDRSTR_rq_b<MVE_st, MVE_memB, "vstrb", 6426 VTIs[0].BitsSuffix, 0, VTIs[0].Size>; 6427 defvar Inst = !cast<Instruction>(NAME); 6428 6429 foreach VTI = VTIs in { 6430 def : Pat<(int_arm_mve_vstr_scatter_offset GPR:$base, (VTIs[0].Vec MQPR:$offsets), (VTI.Vec MQPR:$data), 8, 0), 6431 (Inst MQPR:$data, GPR:$base, MQPR:$offsets)>; 6432 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)), 6433 (Inst MQPR:$data, GPR:$base, MQPR:$offsets, ARMVCCThen, VCCR:$pred, zero_reg)>; 6434 } 6435} 6436 6437// Actually define all the loads and stores in this family. 6438 6439defm MVE_VLDRBU8_rq : MVE_VLDR_rq_b<[MVE_v16u8,MVE_v16s8]>; 6440defm MVE_VLDRBU16_rq: MVE_VLDR_rq_b<[MVE_v8u16]>; 6441defm MVE_VLDRBS16_rq: MVE_VLDR_rq_b<[MVE_v8s16]>; 6442defm MVE_VLDRBU32_rq: MVE_VLDR_rq_b<[MVE_v4u32]>; 6443defm MVE_VLDRBS32_rq: MVE_VLDR_rq_b<[MVE_v4s32]>; 6444 6445defm MVE_VLDRHU16_rq: MVE_VLDR_rq_w<MVE_memH, [MVE_v8u16,MVE_v8s16,MVE_v8f16]>; 6446defm MVE_VLDRHU32_rq: MVE_VLDR_rq_w<MVE_memH, [MVE_v4u32]>; 6447defm MVE_VLDRHS32_rq: MVE_VLDR_rq_w<MVE_memH, [MVE_v4s32]>; 6448defm MVE_VLDRWU32_rq: MVE_VLDR_rq_w<MVE_memW, [MVE_v4u32,MVE_v4s32,MVE_v4f32]>; 6449defm MVE_VLDRDU64_rq: MVE_VLDR_rq_w<MVE_memD, [MVE_v2u64,MVE_v2s64]>; 6450 6451defm MVE_VSTRB8_rq : MVE_VSTR_rq_b<[MVE_v16i8]>; 6452defm MVE_VSTRB16_rq : MVE_VSTR_rq_b<[MVE_v8i16]>; 6453defm MVE_VSTRB32_rq : MVE_VSTR_rq_b<[MVE_v4i32]>; 6454 6455defm MVE_VSTRH16_rq : MVE_VSTR_rq_w<MVE_memH, [MVE_v8i16,MVE_v8f16]>; 6456defm MVE_VSTRH32_rq : MVE_VSTR_rq_w<MVE_memH, [MVE_v4i32]>; 6457defm MVE_VSTRW32_rq : MVE_VSTR_rq_w<MVE_memW, [MVE_v4i32,MVE_v4f32]>; 6458defm MVE_VSTRD64_rq : MVE_VSTR_rq_w<MVE_memD, [MVE_v2i64]>; 6459 6460// Gather loads / scatter stores whose address operand is of the form 6461// [Qm,#imm], i.e. a vector containing a full base address for each 6462// loaded item, plus an immediate offset applied consistently to all 6463// of them. ('Load/store the same field from this vector of pointers 6464// to a structure type.') 6465// 6466// This family requires the vector lane size to be at least 32 bits 6467// (so there's room for an address in each lane at all). It has no 6468// widening/narrowing variants. But it does support preindex 6469// writeback, in which the address vector is updated to hold the 6470// addresses actually loaded from. 6471 6472// Base class. 6473class MVE_VLDRSTR_qi<MVE_ldst_direction dir, MVE_memsz memsz, bit W, dag wbops, 6474 string asm, string wbAsm, string suffix, string cstr = ""> 6475 : MVE_VLDRSTR_base<dir, 1, 1, W, 1, !con(wbops, dir.Oops), 6476 !con(dir.Iops, (ins mve_addr_q_shift<memsz.shift>:$addr)), 6477 asm, suffix, "$Qd, $addr" # wbAsm, cstr # dir.cstr, memsz.encoding> { 6478 bits<11> addr; 6479 let Inst{23} = addr{7}; 6480 let Inst{19-17} = addr{10-8}; 6481 let Inst{16} = 0; 6482 let Inst{8} = memsz.encoding{0}; // enough to distinguish 32- from 64-bit 6483 let Inst{7} = 0; 6484 let Inst{6-0} = addr{6-0}; 6485} 6486 6487// Multiclass that generates the non-writeback and writeback variants. 6488multiclass MVE_VLDRSTR_qi_m<MVE_ldst_direction dir, MVE_memsz memsz, 6489 string asm, string suffix> { 6490 def "" : MVE_VLDRSTR_qi<dir, memsz, 0, (outs), asm, "", suffix>; 6491 def _pre : MVE_VLDRSTR_qi<dir, memsz, 1, (outs MQPR:$wb), asm, "!", suffix, 6492 "$addr.base = $wb"> { 6493 let DecoderMethod="DecodeMVE_MEM_3_pre<"#memsz.shift#">"; 6494 } 6495} 6496 6497// Multiclasses wrapping that one, adding selection patterns for the 6498// non-writeback loads and all the stores. (The writeback loads must 6499// deliver multiple output values, so they have to be selected by C++ 6500// code.) 6501multiclass MVE_VLDR_qi<MVE_memsz memsz, MVEVectorVTInfo AVTI, 6502 list<MVEVectorVTInfo> DVTIs> { 6503 defm "" : MVE_VLDRSTR_qi_m<MVE_ld, memsz, "vldr" # memsz.MnemonicLetter, 6504 "u" # memsz.TypeBits>; 6505 defvar Inst = !cast<Instruction>(NAME); 6506 6507 foreach DVTI = DVTIs in { 6508 def : Pat<(DVTI.Vec (int_arm_mve_vldr_gather_base 6509 (AVTI.Vec MQPR:$addr), (i32 imm:$offset))), 6510 (DVTI.Vec (Inst (AVTI.Vec MQPR:$addr), (i32 imm:$offset)))>; 6511 def : Pat<(DVTI.Vec (int_arm_mve_vldr_gather_base_predicated 6512 (AVTI.Vec MQPR:$addr), (i32 imm:$offset), (AVTI.Pred VCCR:$pred))), 6513 (DVTI.Vec (Inst (AVTI.Vec MQPR:$addr), (i32 imm:$offset), 6514 ARMVCCThen, VCCR:$pred, zero_reg))>; 6515 } 6516} 6517multiclass MVE_VSTR_qi<MVE_memsz memsz, MVEVectorVTInfo AVTI, 6518 list<MVEVectorVTInfo> DVTIs> { 6519 defm "" : MVE_VLDRSTR_qi_m<MVE_st, memsz, "vstr" # memsz.MnemonicLetter, 6520 !cast<string>(memsz.TypeBits)>; 6521 defvar Inst = !cast<Instruction>(NAME); 6522 defvar InstPre = !cast<Instruction>(NAME # "_pre"); 6523 6524 foreach DVTI = DVTIs in { 6525 def : Pat<(int_arm_mve_vstr_scatter_base 6526 (AVTI.Vec MQPR:$addr), (i32 imm:$offset), (DVTI.Vec MQPR:$data)), 6527 (Inst (DVTI.Vec MQPR:$data), (AVTI.Vec MQPR:$addr), 6528 (i32 imm:$offset))>; 6529 def : Pat<(int_arm_mve_vstr_scatter_base_predicated 6530 (AVTI.Vec MQPR:$addr), (i32 imm:$offset), (DVTI.Vec MQPR:$data), (AVTI.Pred VCCR:$pred)), 6531 (Inst (DVTI.Vec MQPR:$data), (AVTI.Vec MQPR:$addr), 6532 (i32 imm:$offset), ARMVCCThen, VCCR:$pred, zero_reg)>; 6533 def : Pat<(AVTI.Vec (int_arm_mve_vstr_scatter_base_wb 6534 (AVTI.Vec MQPR:$addr), (i32 imm:$offset), (DVTI.Vec MQPR:$data))), 6535 (AVTI.Vec (InstPre (DVTI.Vec MQPR:$data), (AVTI.Vec MQPR:$addr), 6536 (i32 imm:$offset)))>; 6537 def : Pat<(AVTI.Vec (int_arm_mve_vstr_scatter_base_wb_predicated 6538 (AVTI.Vec MQPR:$addr), (i32 imm:$offset), (DVTI.Vec MQPR:$data), (AVTI.Pred VCCR:$pred))), 6539 (AVTI.Vec (InstPre (DVTI.Vec MQPR:$data), (AVTI.Vec MQPR:$addr), 6540 (i32 imm:$offset), ARMVCCThen, VCCR:$pred, zero_reg))>; 6541 } 6542} 6543 6544// Actual instruction definitions. 6545defm MVE_VLDRWU32_qi: MVE_VLDR_qi<MVE_memW, MVE_v4i32, [MVE_v4i32,MVE_v4f32]>; 6546defm MVE_VLDRDU64_qi: MVE_VLDR_qi<MVE_memD, MVE_v2i64, [MVE_v2i64,MVE_v2f64]>; 6547defm MVE_VSTRW32_qi: MVE_VSTR_qi<MVE_memW, MVE_v4i32, [MVE_v4i32,MVE_v4f32]>; 6548defm MVE_VSTRD64_qi: MVE_VSTR_qi<MVE_memD, MVE_v2i64, [MVE_v2i64,MVE_v2f64]>; 6549 6550// Define aliases for all the instructions where memory size and 6551// vector lane size are the same. These are mnemonic aliases, so they 6552// apply consistently across all of the above families - contiguous 6553// loads, and both the rq and qi types of gather/scatter. 6554// 6555// Rationale: As long as you're loading (for example) 16-bit memory 6556// values into 16-bit vector lanes, you can think of them as signed or 6557// unsigned integers, fp16 or just raw 16-bit blobs and it makes no 6558// difference. So we permit all of vldrh.16, vldrh.u16, vldrh.s16, 6559// vldrh.f16 and treat them all as equivalent to the canonical 6560// spelling (which happens to be .u16 for loads, and just .16 for 6561// stores). 6562 6563foreach vpt_cond = ["", "t", "e"] in 6564foreach memsz = [MVE_memB, MVE_memH, MVE_memW, MVE_memD] in 6565foreach suffix = memsz.suffixes in { 6566 // Define an alias with every suffix in the list, except for the one 6567 // used by the real Instruction record (i.e. the one that all the 6568 // rest are aliases *for*). 6569 6570 if !ne(suffix, memsz.CanonLoadSuffix) then { 6571 def : MnemonicAlias< 6572 "vldr" # memsz.MnemonicLetter # vpt_cond # suffix, 6573 "vldr" # memsz.MnemonicLetter # vpt_cond # memsz.CanonLoadSuffix>; 6574 } 6575 6576 if !ne(suffix, memsz.CanonStoreSuffix) then { 6577 def : MnemonicAlias< 6578 "vstr" # memsz.MnemonicLetter # vpt_cond # suffix, 6579 "vstr" # memsz.MnemonicLetter # vpt_cond # memsz.CanonStoreSuffix>; 6580 } 6581} 6582 6583// end of MVE predicable load/store 6584 6585class MVE_VPT<string suffix, bits<2> size, dag iops, string asm, list<dag> pattern=[]> 6586 : MVE_MI<(outs ), iops, NoItinerary, !strconcat("vpt", "${Mk}", ".", suffix), asm, "", size, pattern> { 6587 bits<3> fc; 6588 bits<4> Mk; 6589 bits<3> Qn; 6590 6591 let Inst{31-23} = 0b111111100; 6592 let Inst{22} = Mk{3}; 6593 let Inst{21-20} = size; 6594 let Inst{19-17} = Qn{2-0}; 6595 let Inst{16} = 0b1; 6596 let Inst{15-13} = Mk{2-0}; 6597 let Inst{12} = fc{2}; 6598 let Inst{11-8} = 0b1111; 6599 let Inst{7} = fc{0}; 6600 let Inst{4} = 0b0; 6601 6602 let Defs = [VPR]; 6603 let validForTailPredication=1; 6604} 6605 6606class MVE_VPTt1<string suffix, bits<2> size, dag iops> 6607 : MVE_VPT<suffix, size, iops, "$fc, $Qn, $Qm"> { 6608 bits<4> Qm; 6609 bits<4> Mk; 6610 6611 let Inst{6} = 0b0; 6612 let Inst{5} = Qm{3}; 6613 let Inst{3-1} = Qm{2-0}; 6614 let Inst{0} = fc{1}; 6615} 6616 6617class MVE_VPTt1i<string suffix, bits<2> size> 6618 : MVE_VPTt1<suffix, size, 6619 (ins vpt_mask:$Mk, MQPR:$Qn, MQPR:$Qm, pred_basic_i:$fc)> { 6620 let Inst{12} = 0b0; 6621 let Inst{0} = 0b0; 6622} 6623 6624def MVE_VPTv4i32 : MVE_VPTt1i<"i32", 0b10>; 6625def MVE_VPTv8i16 : MVE_VPTt1i<"i16", 0b01>; 6626def MVE_VPTv16i8 : MVE_VPTt1i<"i8", 0b00>; 6627 6628class MVE_VPTt1u<string suffix, bits<2> size> 6629 : MVE_VPTt1<suffix, size, 6630 (ins vpt_mask:$Mk, MQPR:$Qn, MQPR:$Qm, pred_basic_u:$fc)> { 6631 let Inst{12} = 0b0; 6632 let Inst{0} = 0b1; 6633} 6634 6635def MVE_VPTv4u32 : MVE_VPTt1u<"u32", 0b10>; 6636def MVE_VPTv8u16 : MVE_VPTt1u<"u16", 0b01>; 6637def MVE_VPTv16u8 : MVE_VPTt1u<"u8", 0b00>; 6638 6639class MVE_VPTt1s<string suffix, bits<2> size> 6640 : MVE_VPTt1<suffix, size, 6641 (ins vpt_mask:$Mk, MQPR:$Qn, MQPR:$Qm, pred_basic_s:$fc)> { 6642 let Inst{12} = 0b1; 6643} 6644 6645def MVE_VPTv4s32 : MVE_VPTt1s<"s32", 0b10>; 6646def MVE_VPTv8s16 : MVE_VPTt1s<"s16", 0b01>; 6647def MVE_VPTv16s8 : MVE_VPTt1s<"s8", 0b00>; 6648 6649class MVE_VPTt2<string suffix, bits<2> size, dag iops> 6650 : MVE_VPT<suffix, size, iops, 6651 "$fc, $Qn, $Rm"> { 6652 bits<4> Rm; 6653 bits<3> fc; 6654 bits<4> Mk; 6655 6656 let Inst{6} = 0b1; 6657 let Inst{5} = fc{1}; 6658 let Inst{3-0} = Rm{3-0}; 6659} 6660 6661class MVE_VPTt2i<string suffix, bits<2> size> 6662 : MVE_VPTt2<suffix, size, 6663 (ins vpt_mask:$Mk, MQPR:$Qn, GPRwithZR:$Rm, pred_basic_i:$fc)> { 6664 let Inst{12} = 0b0; 6665 let Inst{5} = 0b0; 6666} 6667 6668def MVE_VPTv4i32r : MVE_VPTt2i<"i32", 0b10>; 6669def MVE_VPTv8i16r : MVE_VPTt2i<"i16", 0b01>; 6670def MVE_VPTv16i8r : MVE_VPTt2i<"i8", 0b00>; 6671 6672class MVE_VPTt2u<string suffix, bits<2> size> 6673 : MVE_VPTt2<suffix, size, 6674 (ins vpt_mask:$Mk, MQPR:$Qn, GPRwithZR:$Rm, pred_basic_u:$fc)> { 6675 let Inst{12} = 0b0; 6676 let Inst{5} = 0b1; 6677} 6678 6679def MVE_VPTv4u32r : MVE_VPTt2u<"u32", 0b10>; 6680def MVE_VPTv8u16r : MVE_VPTt2u<"u16", 0b01>; 6681def MVE_VPTv16u8r : MVE_VPTt2u<"u8", 0b00>; 6682 6683class MVE_VPTt2s<string suffix, bits<2> size> 6684 : MVE_VPTt2<suffix, size, 6685 (ins vpt_mask:$Mk, MQPR:$Qn, GPRwithZR:$Rm, pred_basic_s:$fc)> { 6686 let Inst{12} = 0b1; 6687} 6688 6689def MVE_VPTv4s32r : MVE_VPTt2s<"s32", 0b10>; 6690def MVE_VPTv8s16r : MVE_VPTt2s<"s16", 0b01>; 6691def MVE_VPTv16s8r : MVE_VPTt2s<"s8", 0b00>; 6692 6693 6694class MVE_VPTf<string suffix, bit size, dag iops, string asm, list<dag> pattern=[]> 6695 : MVE_MI<(outs ), iops, NoItinerary, !strconcat("vpt", "${Mk}", ".", suffix), asm, 6696 "", !if(size, 0b01, 0b10), pattern> { 6697 bits<3> fc; 6698 bits<4> Mk; 6699 bits<3> Qn; 6700 6701 let Inst{31-29} = 0b111; 6702 let Inst{28} = size; 6703 let Inst{27-23} = 0b11100; 6704 let Inst{22} = Mk{3}; 6705 let Inst{21-20} = 0b11; 6706 let Inst{19-17} = Qn{2-0}; 6707 let Inst{16} = 0b1; 6708 let Inst{15-13} = Mk{2-0}; 6709 let Inst{12} = fc{2}; 6710 let Inst{11-8} = 0b1111; 6711 let Inst{7} = fc{0}; 6712 let Inst{4} = 0b0; 6713 6714 let Defs = [VPR]; 6715 let Predicates = [HasMVEFloat]; 6716 let validForTailPredication=1; 6717} 6718 6719class MVE_VPTft1<string suffix, bit size> 6720 : MVE_VPTf<suffix, size, (ins vpt_mask:$Mk, MQPR:$Qn, MQPR:$Qm, pred_basic_fp:$fc), 6721 "$fc, $Qn, $Qm"> { 6722 bits<3> fc; 6723 bits<4> Qm; 6724 6725 let Inst{6} = 0b0; 6726 let Inst{5} = Qm{3}; 6727 let Inst{3-1} = Qm{2-0}; 6728 let Inst{0} = fc{1}; 6729} 6730 6731def MVE_VPTv4f32 : MVE_VPTft1<"f32", 0b0>; 6732def MVE_VPTv8f16 : MVE_VPTft1<"f16", 0b1>; 6733 6734class MVE_VPTft2<string suffix, bit size> 6735 : MVE_VPTf<suffix, size, (ins vpt_mask:$Mk, MQPR:$Qn, GPRwithZR:$Rm, pred_basic_fp:$fc), 6736 "$fc, $Qn, $Rm"> { 6737 bits<3> fc; 6738 bits<4> Rm; 6739 6740 let Inst{6} = 0b1; 6741 let Inst{5} = fc{1}; 6742 let Inst{3-0} = Rm{3-0}; 6743} 6744 6745def MVE_VPTv4f32r : MVE_VPTft2<"f32", 0b0>; 6746def MVE_VPTv8f16r : MVE_VPTft2<"f16", 0b1>; 6747 6748def MVE_VPST : MVE_MI<(outs ), (ins vpt_mask:$Mk), NoItinerary, 6749 !strconcat("vpst", "${Mk}"), "", "", 0b00, []> { 6750 bits<4> Mk; 6751 6752 let Inst{31-23} = 0b111111100; 6753 let Inst{22} = Mk{3}; 6754 let Inst{21-16} = 0b110001; 6755 let Inst{15-13} = Mk{2-0}; 6756 let Inst{12-0} = 0b0111101001101; 6757 let Unpredictable{12} = 0b1; 6758 let Unpredictable{7} = 0b1; 6759 let Unpredictable{5} = 0b1; 6760 6761 let Uses = [VPR]; 6762 let validForTailPredication = 1; 6763} 6764 6765def MVE_VPSEL : MVE_p<(outs MQPR:$Qd), (ins MQPR:$Qn, MQPR:$Qm), NoItinerary, 6766 "vpsel", "", "$Qd, $Qn, $Qm", vpred_n, "", 0b00, []> { 6767 bits<4> Qn; 6768 bits<4> Qd; 6769 bits<4> Qm; 6770 6771 let Inst{28} = 0b1; 6772 let Inst{25-23} = 0b100; 6773 let Inst{22} = Qd{3}; 6774 let Inst{21-20} = 0b11; 6775 let Inst{19-17} = Qn{2-0}; 6776 let Inst{16} = 0b1; 6777 let Inst{15-13} = Qd{2-0}; 6778 let Inst{12-9} = 0b0111; 6779 let Inst{8} = 0b1; 6780 let Inst{7} = Qn{3}; 6781 let Inst{6} = 0b0; 6782 let Inst{5} = Qm{3}; 6783 let Inst{4} = 0b0; 6784 let Inst{3-1} = Qm{2-0}; 6785 let Inst{0} = 0b1; 6786} 6787 6788foreach suffix = ["s8", "s16", "s32", "u8", "u16", "u32", 6789 "i8", "i16", "i32", "f16", "f32"] in 6790def : MVEInstAlias<"vpsel${vp}." # suffix # "\t$Qd, $Qn, $Qm", 6791 (MVE_VPSEL MQPR:$Qd, MQPR:$Qn, MQPR:$Qm, vpred_n:$vp)>; 6792 6793let Predicates = [HasMVEInt] in { 6794 def : Pat<(v16i8 (vselect (v16i1 VCCR:$pred), (v16i8 MQPR:$v1), (v16i8 MQPR:$v2))), 6795 (v16i8 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>; 6796 def : Pat<(v8i16 (vselect (v8i1 VCCR:$pred), (v8i16 MQPR:$v1), (v8i16 MQPR:$v2))), 6797 (v8i16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>; 6798 def : Pat<(v4i32 (vselect (v4i1 VCCR:$pred), (v4i32 MQPR:$v1), (v4i32 MQPR:$v2))), 6799 (v4i32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>; 6800 def : Pat<(v2i64 (vselect (v2i1 VCCR:$pred), (v2i64 MQPR:$v1), (v2i64 MQPR:$v2))), 6801 (v2i64 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>; 6802 6803 def : Pat<(v8f16 (vselect (v8i1 VCCR:$pred), (v8f16 MQPR:$v1), (v8f16 MQPR:$v2))), 6804 (v8f16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>; 6805 def : Pat<(v4f32 (vselect (v4i1 VCCR:$pred), (v4f32 MQPR:$v1), (v4f32 MQPR:$v2))), 6806 (v4f32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>; 6807 def : Pat<(v2f64 (vselect (v2i1 VCCR:$pred), (v2f64 MQPR:$v1), (v2f64 MQPR:$v2))), 6808 (v2f64 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, VCCR:$pred, zero_reg))>; 6809 6810 def : Pat<(v16i8 (vselect (v16i8 MQPR:$pred), (v16i8 MQPR:$v1), (v16i8 MQPR:$v2))), 6811 (v16i8 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, 6812 (MVE_VCMPi8 (v16i8 MQPR:$pred), (MVE_VMOVimmi8 0), ARMCCne), zero_reg))>; 6813 def : Pat<(v8i16 (vselect (v8i16 MQPR:$pred), (v8i16 MQPR:$v1), (v8i16 MQPR:$v2))), 6814 (v8i16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, 6815 (MVE_VCMPi16 (v8i16 MQPR:$pred), (MVE_VMOVimmi16 0), ARMCCne), zero_reg))>; 6816 def : Pat<(v4i32 (vselect (v4i32 MQPR:$pred), (v4i32 MQPR:$v1), (v4i32 MQPR:$v2))), 6817 (v4i32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, 6818 (MVE_VCMPi32 (v4i32 MQPR:$pred), (MVE_VMOVimmi32 0), ARMCCne), zero_reg))>; 6819 6820 def : Pat<(v8f16 (vselect (v8i16 MQPR:$pred), (v8f16 MQPR:$v1), (v8f16 MQPR:$v2))), 6821 (v8f16 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, 6822 (MVE_VCMPi16 (v8i16 MQPR:$pred), (MVE_VMOVimmi16 0), ARMCCne), zero_reg))>; 6823 def : Pat<(v4f32 (vselect (v4i32 MQPR:$pred), (v4f32 MQPR:$v1), (v4f32 MQPR:$v2))), 6824 (v4f32 (MVE_VPSEL MQPR:$v1, MQPR:$v2, ARMVCCNone, 6825 (MVE_VCMPi32 (v4i32 MQPR:$pred), (MVE_VMOVimmi32 0), ARMCCne), zero_reg))>; 6826 6827 // Pred <-> Int 6828 def : Pat<(v16i8 (zext (v16i1 VCCR:$pred))), 6829 (v16i8 (MVE_VPSEL (MVE_VMOVimmi8 1), (MVE_VMOVimmi8 0), ARMVCCNone, VCCR:$pred, zero_reg))>; 6830 def : Pat<(v8i16 (zext (v8i1 VCCR:$pred))), 6831 (v8i16 (MVE_VPSEL (MVE_VMOVimmi16 1), (MVE_VMOVimmi16 0), ARMVCCNone, VCCR:$pred, zero_reg))>; 6832 def : Pat<(v4i32 (zext (v4i1 VCCR:$pred))), 6833 (v4i32 (MVE_VPSEL (MVE_VMOVimmi32 1), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>; 6834 def : Pat<(v2i64 (zext (v2i1 VCCR:$pred))), 6835 (v2i64 (MVE_VPSEL (MVE_VMOVimmi64 1), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>; 6836 6837 def : Pat<(v16i8 (sext (v16i1 VCCR:$pred))), 6838 (v16i8 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi8 0), ARMVCCNone, VCCR:$pred, zero_reg))>; 6839 def : Pat<(v8i16 (sext (v8i1 VCCR:$pred))), 6840 (v8i16 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi16 0), ARMVCCNone, VCCR:$pred, zero_reg))>; 6841 def : Pat<(v4i32 (sext (v4i1 VCCR:$pred))), 6842 (v4i32 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>; 6843 def : Pat<(v2i64 (sext (v2i1 VCCR:$pred))), 6844 (v2i64 (MVE_VPSEL (MVE_VMOVimmi8 255), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>; 6845 6846 def : Pat<(v16i8 (anyext (v16i1 VCCR:$pred))), 6847 (v16i8 (MVE_VPSEL (MVE_VMOVimmi8 1), (MVE_VMOVimmi8 0), ARMVCCNone, VCCR:$pred, zero_reg))>; 6848 def : Pat<(v8i16 (anyext (v8i1 VCCR:$pred))), 6849 (v8i16 (MVE_VPSEL (MVE_VMOVimmi16 1), (MVE_VMOVimmi16 0), ARMVCCNone, VCCR:$pred, zero_reg))>; 6850 def : Pat<(v4i32 (anyext (v4i1 VCCR:$pred))), 6851 (v4i32 (MVE_VPSEL (MVE_VMOVimmi32 1), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>; 6852 def : Pat<(v2i64 (anyext (v2i1 VCCR:$pred))), 6853 (v2i64 (MVE_VPSEL (MVE_VMOVimmi64 1), (MVE_VMOVimmi32 0), ARMVCCNone, VCCR:$pred, zero_reg))>; 6854} 6855 6856let Predicates = [HasMVEFloat] in { 6857 // Pred <-> Float 6858 // 112 is 1.0 in float 6859 def : Pat<(v4f32 (uint_to_fp (v4i1 VCCR:$pred))), 6860 (v4f32 (MVE_VPSEL (v4f32 (MVE_VMOVimmf32 112)), (v4f32 (MVE_VMOVimmi32 0)), ARMVCCNone, VCCR:$pred, zero_reg))>; 6861 // 2620 in 1.0 in half 6862 def : Pat<(v8f16 (uint_to_fp (v8i1 VCCR:$pred))), 6863 (v8f16 (MVE_VPSEL (v8f16 (MVE_VMOVimmi16 2620)), (v8f16 (MVE_VMOVimmi16 0)), ARMVCCNone, VCCR:$pred, zero_reg))>; 6864 // 240 is -1.0 in float 6865 def : Pat<(v4f32 (sint_to_fp (v4i1 VCCR:$pred))), 6866 (v4f32 (MVE_VPSEL (v4f32 (MVE_VMOVimmf32 240)), (v4f32 (MVE_VMOVimmi32 0)), ARMVCCNone, VCCR:$pred, zero_reg))>; 6867 // 2748 is -1.0 in half 6868 def : Pat<(v8f16 (sint_to_fp (v8i1 VCCR:$pred))), 6869 (v8f16 (MVE_VPSEL (v8f16 (MVE_VMOVimmi16 2748)), (v8f16 (MVE_VMOVimmi16 0)), ARMVCCNone, VCCR:$pred, zero_reg))>; 6870 6871 def : Pat<(v4i1 (fp_to_uint (v4f32 MQPR:$v1))), 6872 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, ARMCCne))>; 6873 def : Pat<(v8i1 (fp_to_uint (v8f16 MQPR:$v1))), 6874 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), ZR, ARMCCne))>; 6875 def : Pat<(v4i1 (fp_to_sint (v4f32 MQPR:$v1))), 6876 (v4i1 (MVE_VCMPf32r (v4f32 MQPR:$v1), ZR, ARMCCne))>; 6877 def : Pat<(v8i1 (fp_to_sint (v8f16 MQPR:$v1))), 6878 (v8i1 (MVE_VCMPf16r (v8f16 MQPR:$v1), ZR, ARMCCne))>; 6879} 6880 6881def MVE_VPNOT : MVE_p<(outs VCCR:$P0), (ins VCCR:$P0_in), NoItinerary, 6882 "vpnot", "", "", vpred_n, "", 0b00, []> { 6883 let Inst{31-0} = 0b11111110001100010000111101001101; 6884 let Unpredictable{19-17} = 0b111; 6885 let Unpredictable{12} = 0b1; 6886 let Unpredictable{7} = 0b1; 6887 let Unpredictable{5} = 0b1; 6888 6889 let Constraints = ""; 6890 let DecoderMethod = "DecodeMVEVPNOT"; 6891} 6892 6893let Predicates = [HasMVEInt] in { 6894 def : Pat<(v2i1 (xor (v2i1 VCCR:$pred), (v2i1 (predicate_cast (i32 65535))))), 6895 (v2i1 (MVE_VPNOT (v2i1 VCCR:$pred)))>; 6896 def : Pat<(v4i1 (xor (v4i1 VCCR:$pred), (v4i1 (predicate_cast (i32 65535))))), 6897 (v4i1 (MVE_VPNOT (v4i1 VCCR:$pred)))>; 6898 def : Pat<(v8i1 (xor (v8i1 VCCR:$pred), (v8i1 (predicate_cast (i32 65535))))), 6899 (v8i1 (MVE_VPNOT (v8i1 VCCR:$pred)))>; 6900 def : Pat<(v16i1 (xor (v16i1 VCCR:$pred), (v16i1 (predicate_cast (i32 65535))))), 6901 (v16i1 (MVE_VPNOT (v16i1 VCCR:$pred)))>; 6902} 6903 6904 6905class MVE_loltp_start<dag iops, string asm, string ops, bits<2> size> 6906 : t2LOL<(outs GPRlr:$LR), iops, asm, ops> { 6907 bits<4> Rn; 6908 let Predicates = [HasMVEInt]; 6909 let Inst{22} = 0b0; 6910 let Inst{21-20} = size; 6911 let Inst{19-16} = Rn{3-0}; 6912 let Inst{12} = 0b0; 6913} 6914 6915class MVE_DLSTP<string asm, bits<2> size> 6916 : MVE_loltp_start<(ins rGPR:$Rn), asm, "$LR, $Rn", size> { 6917 let Inst{13} = 0b1; 6918 let Inst{11-1} = 0b00000000000; 6919 let Unpredictable{10-1} = 0b1111111111; 6920} 6921 6922class MVE_WLSTP<string asm, bits<2> size> 6923 : MVE_loltp_start<(ins rGPR:$Rn, wlslabel_u11:$label), 6924 asm, "$LR, $Rn, $label", size> { 6925 bits<11> label; 6926 let Inst{13} = 0b0; 6927 let Inst{11} = label{0}; 6928 let Inst{10-1} = label{10-1}; 6929 let isBranch = 1; 6930 let isTerminator = 1; 6931} 6932 6933def SDT_MVEMEMCPYLOOPNODE 6934 : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisPtrTy<1>, SDTCisVT<2, i32>]>; 6935def MVE_MEMCPYLOOPNODE : SDNode<"ARMISD::MEMCPYLOOP", SDT_MVEMEMCPYLOOPNODE, 6936 [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>; 6937 6938let usesCustomInserter = 1, hasNoSchedulingInfo = 1, Defs = [CPSR] in { 6939 def MVE_MEMCPYLOOPINST : PseudoInst<(outs), 6940 (ins rGPR:$dst, rGPR:$src, rGPR:$sz), 6941 NoItinerary, 6942 [(MVE_MEMCPYLOOPNODE rGPR:$dst, rGPR:$src, rGPR:$sz)]>; 6943} 6944 6945def SDT_MVEMEMSETLOOPNODE 6946 : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisVT<1, v16i8>, SDTCisVT<2, i32>]>; 6947def MVE_MEMSETLOOPNODE : SDNode<"ARMISD::MEMSETLOOP", SDT_MVEMEMSETLOOPNODE, 6948 [SDNPHasChain, SDNPMayStore, SDNPMayLoad]>; 6949 6950let usesCustomInserter = 1, hasNoSchedulingInfo = 1, Defs = [CPSR] in { 6951 def MVE_MEMSETLOOPINST : PseudoInst<(outs), 6952 (ins rGPR:$dst, MQPR:$src, rGPR:$sz), 6953 NoItinerary, 6954 [(MVE_MEMSETLOOPNODE rGPR:$dst, MQPR:$src, rGPR:$sz)]>; 6955} 6956 6957def MVE_DLSTP_8 : MVE_DLSTP<"dlstp.8", 0b00>; 6958def MVE_DLSTP_16 : MVE_DLSTP<"dlstp.16", 0b01>; 6959def MVE_DLSTP_32 : MVE_DLSTP<"dlstp.32", 0b10>; 6960def MVE_DLSTP_64 : MVE_DLSTP<"dlstp.64", 0b11>; 6961 6962def MVE_WLSTP_8 : MVE_WLSTP<"wlstp.8", 0b00>; 6963def MVE_WLSTP_16 : MVE_WLSTP<"wlstp.16", 0b01>; 6964def MVE_WLSTP_32 : MVE_WLSTP<"wlstp.32", 0b10>; 6965def MVE_WLSTP_64 : MVE_WLSTP<"wlstp.64", 0b11>; 6966 6967class MVE_loltp_end<dag oops, dag iops, string asm, string ops> 6968 : t2LOL<oops, iops, asm, ops> { 6969 let Predicates = [HasMVEInt]; 6970 let Inst{22-21} = 0b00; 6971 let Inst{19-16} = 0b1111; 6972 let Inst{12} = 0b0; 6973} 6974 6975def MVE_LETP : MVE_loltp_end<(outs GPRlr:$LRout), 6976 (ins GPRlr:$LRin, lelabel_u11:$label), 6977 "letp", "$LRin, $label"> { 6978 bits<11> label; 6979 let Inst{20} = 0b1; 6980 let Inst{13} = 0b0; 6981 let Inst{11} = label{0}; 6982 let Inst{10-1} = label{10-1}; 6983 let isBranch = 1; 6984 let isTerminator = 1; 6985} 6986 6987def MVE_LCTP : MVE_loltp_end<(outs), (ins pred:$p), "lctp${p}", ""> { 6988 let Inst{20} = 0b0; 6989 let Inst{13} = 0b1; 6990 let Inst{11-1} = 0b00000000000; 6991 let Unpredictable{21-20} = 0b11; 6992 let Unpredictable{11-1} = 0b11111111111; 6993} 6994 6995 6996// Pseudo instructions for lowering MQQPR and MQQQQPR stack spills and reloads. 6997// They are equivalent to VLDMDIA/VSTMDIA with a single reg, as opposed to multiple 6998// dreg subregs. 6999 7000let Predicates = [HasMVEInt], AM = AddrMode4 in { 7001let mayStore = 1, hasSideEffects = 0 in { 7002 def MQQPRStore : t2PseudoInst<(outs), (ins MQQPR:$val, GPRnopc:$ptr), 7003 4, NoItinerary, []>; 7004 def MQQQQPRStore : t2PseudoInst<(outs), (ins MQQQQPR:$val, GPRnopc:$ptr), 7005 4, NoItinerary, []>; 7006} 7007let mayLoad = 1, hasSideEffects = 0 in { 7008 def MQQPRLoad : t2PseudoInst<(outs MQQPR:$val), (ins GPRnopc:$ptr), 7009 4, NoItinerary, []>; 7010 def MQQQQPRLoad : t2PseudoInst<(outs MQQQQPR:$val), (ins GPRnopc:$ptr), 7011 4, NoItinerary, []>; 7012} 7013} 7014 7015// Pseudo for lowering MVE Q register COPYs. These will usually get converted 7016// to a "MVE_VORR dst, src, src", but may behave differently in tail predicated 7017// loops to ensure the whole register is copied, not a subset from a 7018// tail-predicated MVE_VORR. In the event we cannot prove a MVE_VORR is valid, 7019// it will become a pair of VMOVD instructions for each half of the Q register. 7020let Predicates = [HasMVEInt], hasSideEffects = 0, isMoveReg = 1, 7021 D = MVEDomain in { 7022 def MQPRCopy : t2PseudoInst<(outs MQPR:$dst), (ins MQPR:$src), 7023 8, NoItinerary, []>; 7024} 7025 7026 7027//===----------------------------------------------------------------------===// 7028// Patterns 7029//===----------------------------------------------------------------------===// 7030 7031// PatFrags for loads and stores. Often trying to keep semi-consistent names. 7032 7033def aligned32_pre_store : PatFrag<(ops node:$val, node:$ptr, node:$offset), 7034 (pre_store node:$val, node:$ptr, node:$offset), [{ 7035 return cast<StoreSDNode>(N)->getAlign() >= 4; 7036}]>; 7037def aligned32_post_store : PatFrag<(ops node:$val, node:$ptr, node:$offset), 7038 (post_store node:$val, node:$ptr, node:$offset), [{ 7039 return cast<StoreSDNode>(N)->getAlign() >= 4; 7040}]>; 7041def aligned16_pre_store : PatFrag<(ops node:$val, node:$ptr, node:$offset), 7042 (pre_store node:$val, node:$ptr, node:$offset), [{ 7043 return cast<StoreSDNode>(N)->getAlign() >= 2; 7044}]>; 7045def aligned16_post_store : PatFrag<(ops node:$val, node:$ptr, node:$offset), 7046 (post_store node:$val, node:$ptr, node:$offset), [{ 7047 return cast<StoreSDNode>(N)->getAlign() >= 2; 7048}]>; 7049 7050 7051def aligned_maskedloadvi8 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru), 7052 (masked_ld node:$ptr, undef, node:$pred, node:$passthru), [{ 7053 auto *Ld = cast<MaskedLoadSDNode>(N); 7054 return Ld->getMemoryVT().getScalarType() == MVT::i8; 7055}]>; 7056def aligned_sextmaskedloadvi8 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru), 7057 (aligned_maskedloadvi8 node:$ptr, node:$pred, node:$passthru), [{ 7058 return cast<MaskedLoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD; 7059}]>; 7060def aligned_zextmaskedloadvi8 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru), 7061 (aligned_maskedloadvi8 node:$ptr, node:$pred, node:$passthru), [{ 7062 return cast<MaskedLoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD; 7063}]>; 7064def aligned_extmaskedloadvi8 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru), 7065 (aligned_maskedloadvi8 node:$ptr, node:$pred, node:$passthru), [{ 7066 auto *Ld = cast<MaskedLoadSDNode>(N); 7067 EVT ScalarVT = Ld->getMemoryVT().getScalarType(); 7068 return ScalarVT.isInteger() && Ld->getExtensionType() == ISD::EXTLOAD; 7069}]>; 7070def aligned_maskedloadvi16: PatFrag<(ops node:$ptr, node:$pred, node:$passthru), 7071 (masked_ld node:$ptr, undef, node:$pred, node:$passthru), [{ 7072 auto *Ld = cast<MaskedLoadSDNode>(N); 7073 EVT ScalarVT = Ld->getMemoryVT().getScalarType(); 7074 return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && Ld->getAlign() >= 2; 7075}]>; 7076def aligned_sextmaskedloadvi16 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru), 7077 (aligned_maskedloadvi16 node:$ptr, node:$pred, node:$passthru), [{ 7078 return cast<MaskedLoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD; 7079}]>; 7080def aligned_zextmaskedloadvi16 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru), 7081 (aligned_maskedloadvi16 node:$ptr, node:$pred, node:$passthru), [{ 7082 return cast<MaskedLoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD; 7083}]>; 7084def aligned_extmaskedloadvi16 : PatFrag<(ops node:$ptr, node:$pred, node:$passthru), 7085 (aligned_maskedloadvi16 node:$ptr, node:$pred, node:$passthru), [{ 7086 auto *Ld = cast<MaskedLoadSDNode>(N); 7087 EVT ScalarVT = Ld->getMemoryVT().getScalarType(); 7088 return ScalarVT.isInteger() && Ld->getExtensionType() == ISD::EXTLOAD; 7089}]>; 7090def aligned_maskedloadvi32: PatFrag<(ops node:$ptr, node:$pred, node:$passthru), 7091 (masked_ld node:$ptr, undef, node:$pred, node:$passthru), [{ 7092 auto *Ld = cast<MaskedLoadSDNode>(N); 7093 EVT ScalarVT = Ld->getMemoryVT().getScalarType(); 7094 return (ScalarVT == MVT::i32 || ScalarVT == MVT::f32) && Ld->getAlign() >= 4; 7095}]>; 7096 7097def aligned_maskedstvi8 : PatFrag<(ops node:$val, node:$ptr, node:$pred), 7098 (masked_st node:$val, node:$ptr, undef, node:$pred), [{ 7099 return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8; 7100}]>; 7101def aligned_maskedstvi16 : PatFrag<(ops node:$val, node:$ptr, node:$pred), 7102 (masked_st node:$val, node:$ptr, undef, node:$pred), [{ 7103 auto *St = cast<MaskedStoreSDNode>(N); 7104 EVT ScalarVT = St->getMemoryVT().getScalarType(); 7105 return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlign() >= 2; 7106}]>; 7107def aligned_maskedstvi32 : PatFrag<(ops node:$val, node:$ptr, node:$pred), 7108 (masked_st node:$val, node:$ptr, undef, node:$pred), [{ 7109 auto *St = cast<MaskedStoreSDNode>(N); 7110 EVT ScalarVT = St->getMemoryVT().getScalarType(); 7111 return (ScalarVT == MVT::i32 || ScalarVT == MVT::f32) && St->getAlign() >= 4; 7112}]>; 7113 7114def pre_maskedstore : PatFrag<(ops node:$val, node:$base, node:$offset, node:$mask), 7115 (masked_st node:$val, node:$base, node:$offset, node:$mask), [{ 7116 ISD::MemIndexedMode AM = cast<MaskedStoreSDNode>(N)->getAddressingMode(); 7117 return AM == ISD::PRE_INC || AM == ISD::PRE_DEC; 7118}]>; 7119def post_maskedstore : PatFrag<(ops node:$val, node:$base, node:$offset, node:$mask), 7120 (masked_st node:$val, node:$base, node:$offset, node:$mask), [{ 7121 ISD::MemIndexedMode AM = cast<MaskedStoreSDNode>(N)->getAddressingMode(); 7122 return AM == ISD::POST_INC || AM == ISD::POST_DEC; 7123}]>; 7124def aligned_pre_maskedstorevi8 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask), 7125 (pre_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{ 7126 return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8; 7127}]>; 7128def aligned_post_maskedstorevi8 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask), 7129 (post_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{ 7130 return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8; 7131}]>; 7132def aligned_pre_maskedstorevi16 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask), 7133 (pre_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{ 7134 auto *St = cast<MaskedStoreSDNode>(N); 7135 EVT ScalarVT = St->getMemoryVT().getScalarType(); 7136 return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlign() >= 2; 7137}]>; 7138def aligned_post_maskedstorevi16 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask), 7139 (post_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{ 7140 auto *St = cast<MaskedStoreSDNode>(N); 7141 EVT ScalarVT = St->getMemoryVT().getScalarType(); 7142 return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlign() >= 2; 7143}]>; 7144def aligned_pre_maskedstorevi32 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask), 7145 (pre_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{ 7146 auto *St = cast<MaskedStoreSDNode>(N); 7147 EVT ScalarVT = St->getMemoryVT().getScalarType(); 7148 return (ScalarVT == MVT::i32 || ScalarVT == MVT::f32) && St->getAlign() >= 4; 7149}]>; 7150def aligned_post_maskedstorevi32 : PatFrag<(ops node:$val, node:$ptr, node:$offset, node:$mask), 7151 (post_maskedstore node:$val, node:$ptr, node:$offset, node:$mask), [{ 7152 auto *St = cast<MaskedStoreSDNode>(N); 7153 EVT ScalarVT = St->getMemoryVT().getScalarType(); 7154 return (ScalarVT == MVT::i32 || ScalarVT == MVT::f32) && St->getAlign() >= 4; 7155}]>; 7156 7157 7158// PatFrags for "Aligned" extending / truncating 7159 7160def aligned_extloadvi8 : PatFrag<(ops node:$ptr), (extloadvi8 node:$ptr)>; 7161def aligned_sextloadvi8 : PatFrag<(ops node:$ptr), (sextloadvi8 node:$ptr)>; 7162def aligned_zextloadvi8 : PatFrag<(ops node:$ptr), (zextloadvi8 node:$ptr)>; 7163 7164def aligned_truncstvi8 : PatFrag<(ops node:$val, node:$ptr), 7165 (truncstorevi8 node:$val, node:$ptr)>; 7166def aligned_post_truncstvi8 : PatFrag<(ops node:$val, node:$base, node:$offset), 7167 (post_truncstvi8 node:$val, node:$base, node:$offset)>; 7168def aligned_pre_truncstvi8 : PatFrag<(ops node:$val, node:$base, node:$offset), 7169 (pre_truncstvi8 node:$val, node:$base, node:$offset)>; 7170 7171let MinAlignment = 2 in { 7172 def aligned_extloadvi16 : PatFrag<(ops node:$ptr), (extloadvi16 node:$ptr)>; 7173 def aligned_sextloadvi16 : PatFrag<(ops node:$ptr), (sextloadvi16 node:$ptr)>; 7174 def aligned_zextloadvi16 : PatFrag<(ops node:$ptr), (zextloadvi16 node:$ptr)>; 7175 7176 def aligned_truncstvi16 : PatFrag<(ops node:$val, node:$ptr), 7177 (truncstorevi16 node:$val, node:$ptr)>; 7178 def aligned_post_truncstvi16 : PatFrag<(ops node:$val, node:$base, node:$offset), 7179 (post_truncstvi16 node:$val, node:$base, node:$offset)>; 7180 def aligned_pre_truncstvi16 : PatFrag<(ops node:$val, node:$base, node:$offset), 7181 (pre_truncstvi16 node:$val, node:$base, node:$offset)>; 7182} 7183 7184def truncmaskedst : PatFrag<(ops node:$val, node:$base, node:$pred), 7185 (masked_st node:$val, node:$base, undef, node:$pred), [{ 7186 return cast<MaskedStoreSDNode>(N)->isTruncatingStore(); 7187}]>; 7188def aligned_truncmaskedstvi8 : PatFrag<(ops node:$val, node:$base, node:$pred), 7189 (truncmaskedst node:$val, node:$base, node:$pred), [{ 7190 return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8; 7191}]>; 7192def aligned_truncmaskedstvi16 : PatFrag<(ops node:$val, node:$base, node:$pred), 7193 (truncmaskedst node:$val, node:$base, node:$pred), [{ 7194 auto *St = cast<MaskedStoreSDNode>(N); 7195 EVT ScalarVT = St->getMemoryVT().getScalarType(); 7196 return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlign() >= 2; 7197}]>; 7198def pre_truncmaskedst : PatFrag<(ops node:$val, node:$base, node:$offset, node:$pred), 7199 (masked_st node:$val, node:$base, node:$offset, node:$pred), [{ 7200 ISD::MemIndexedMode AM = cast<MaskedStoreSDNode>(N)->getAddressingMode(); 7201 return cast<MaskedStoreSDNode>(N)->isTruncatingStore() && (AM == ISD::PRE_INC || AM == ISD::PRE_DEC); 7202}]>; 7203def aligned_pre_truncmaskedstvi8 : PatFrag<(ops node:$val, node:$base, node:$offset, node:$pred), 7204 (pre_truncmaskedst node:$val, node:$base, node:$offset, node:$pred), [{ 7205 return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8; 7206}]>; 7207def aligned_pre_truncmaskedstvi16 : PatFrag<(ops node:$val, node:$base, node:$offset, node:$pred), 7208 (pre_truncmaskedst node:$val, node:$base, node:$offset, node:$pred), [{ 7209 auto *St = cast<MaskedStoreSDNode>(N); 7210 EVT ScalarVT = St->getMemoryVT().getScalarType(); 7211 return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlign() >= 2; 7212}]>; 7213def post_truncmaskedst : PatFrag<(ops node:$val, node:$base, node:$offset, node:$postd), 7214 (masked_st node:$val, node:$base, node:$offset, node:$postd), [{ 7215 ISD::MemIndexedMode AM = cast<MaskedStoreSDNode>(N)->getAddressingMode(); 7216 return cast<MaskedStoreSDNode>(N)->isTruncatingStore() && (AM == ISD::POST_INC || AM == ISD::POST_DEC); 7217}]>; 7218def aligned_post_truncmaskedstvi8 : PatFrag<(ops node:$val, node:$base, node:$offset, node:$postd), 7219 (post_truncmaskedst node:$val, node:$base, node:$offset, node:$postd), [{ 7220 return cast<MaskedStoreSDNode>(N)->getMemoryVT().getScalarType() == MVT::i8; 7221}]>; 7222def aligned_post_truncmaskedstvi16 : PatFrag<(ops node:$val, node:$base, node:$offset, node:$postd), 7223 (post_truncmaskedst node:$val, node:$base, node:$offset, node:$postd), [{ 7224 auto *St = cast<MaskedStoreSDNode>(N); 7225 EVT ScalarVT = St->getMemoryVT().getScalarType(); 7226 return (ScalarVT == MVT::i16 || ScalarVT == MVT::f16) && St->getAlign() >= 2; 7227}]>; 7228 7229// Load/store patterns 7230 7231class MVE_vector_store_typed<ValueType Ty, Instruction RegImmInst, 7232 PatFrag StoreKind, int shift> 7233 : Pat<(StoreKind (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr), 7234 (RegImmInst (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr)>; 7235 7236class MVE_vector_maskedstore_typed<ValueType Ty, Instruction RegImmInst, 7237 PatFrag StoreKind, int shift> 7238 : Pat<(StoreKind (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr, VCCR:$pred), 7239 (RegImmInst (Ty MQPR:$val), t2addrmode_imm7<shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg)>; 7240 7241multiclass MVE_vector_store<Instruction RegImmInst, PatFrag StoreKind, 7242 int shift> { 7243 def : MVE_vector_store_typed<v16i8, RegImmInst, StoreKind, shift>; 7244 def : MVE_vector_store_typed<v8i16, RegImmInst, StoreKind, shift>; 7245 def : MVE_vector_store_typed<v8f16, RegImmInst, StoreKind, shift>; 7246 def : MVE_vector_store_typed<v4i32, RegImmInst, StoreKind, shift>; 7247 def : MVE_vector_store_typed<v4f32, RegImmInst, StoreKind, shift>; 7248 def : MVE_vector_store_typed<v2i64, RegImmInst, StoreKind, shift>; 7249 def : MVE_vector_store_typed<v2f64, RegImmInst, StoreKind, shift>; 7250} 7251 7252class MVE_vector_load_typed<ValueType Ty, Instruction RegImmInst, 7253 PatFrag LoadKind, int shift> 7254 : Pat<(Ty (LoadKind t2addrmode_imm7<shift>:$addr)), 7255 (Ty (RegImmInst t2addrmode_imm7<shift>:$addr))>; 7256 7257class MVE_vector_maskedload_typed<ValueType Ty, Instruction RegImmInst, 7258 PatFrag LoadKind, int shift> 7259 : Pat<(Ty (LoadKind t2addrmode_imm7<shift>:$addr, VCCR:$pred, (Ty (ARMvmovImm (i32 0))))), 7260 (Ty (RegImmInst t2addrmode_imm7<shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg))>; 7261 7262multiclass MVE_vector_load<Instruction RegImmInst, PatFrag LoadKind, 7263 int shift> { 7264 def : MVE_vector_load_typed<v16i8, RegImmInst, LoadKind, shift>; 7265 def : MVE_vector_load_typed<v8i16, RegImmInst, LoadKind, shift>; 7266 def : MVE_vector_load_typed<v8f16, RegImmInst, LoadKind, shift>; 7267 def : MVE_vector_load_typed<v4i32, RegImmInst, LoadKind, shift>; 7268 def : MVE_vector_load_typed<v4f32, RegImmInst, LoadKind, shift>; 7269 def : MVE_vector_load_typed<v2i64, RegImmInst, LoadKind, shift>; 7270 def : MVE_vector_load_typed<v2f64, RegImmInst, LoadKind, shift>; 7271} 7272 7273class MVE_vector_offset_store_typed<ValueType Ty, Instruction Opcode, 7274 PatFrag StoreKind, int shift> 7275 : Pat<(StoreKind (Ty MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<shift>:$addr), 7276 (Opcode MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<shift>:$addr)>; 7277 7278class MVE_vector_offset_maskedstore_typed<ValueType Ty, Instruction Opcode, 7279 PatFrag StoreKind, int shift> 7280 : Pat<(StoreKind (Ty MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<shift>:$addr, VCCR:$pred), 7281 (Opcode MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg)>; 7282 7283multiclass MVE_vector_offset_store<Instruction RegImmInst, PatFrag StoreKind, 7284 int shift> { 7285 def : MVE_vector_offset_store_typed<v16i8, RegImmInst, StoreKind, shift>; 7286 def : MVE_vector_offset_store_typed<v8i16, RegImmInst, StoreKind, shift>; 7287 def : MVE_vector_offset_store_typed<v8f16, RegImmInst, StoreKind, shift>; 7288 def : MVE_vector_offset_store_typed<v4i32, RegImmInst, StoreKind, shift>; 7289 def : MVE_vector_offset_store_typed<v4f32, RegImmInst, StoreKind, shift>; 7290 def : MVE_vector_offset_store_typed<v2i64, RegImmInst, StoreKind, shift>; 7291 def : MVE_vector_offset_store_typed<v2f64, RegImmInst, StoreKind, shift>; 7292} 7293 7294 7295let Predicates = [HasMVEInt, IsLE] in { 7296 // Stores 7297 defm : MVE_vector_store<MVE_VSTRBU8, byte_alignedstore, 0>; 7298 defm : MVE_vector_store<MVE_VSTRHU16, hword_alignedstore, 1>; 7299 defm : MVE_vector_store<MVE_VSTRWU32, alignedstore32, 2>; 7300 7301 // Loads 7302 defm : MVE_vector_load<MVE_VLDRBU8, byte_alignedload, 0>; 7303 defm : MVE_vector_load<MVE_VLDRHU16, hword_alignedload, 1>; 7304 defm : MVE_vector_load<MVE_VLDRWU32, alignedload32, 2>; 7305 7306 // Pre/post inc stores 7307 defm : MVE_vector_offset_store<MVE_VSTRBU8_pre, pre_store, 0>; 7308 defm : MVE_vector_offset_store<MVE_VSTRBU8_post, post_store, 0>; 7309 defm : MVE_vector_offset_store<MVE_VSTRHU16_pre, aligned16_pre_store, 1>; 7310 defm : MVE_vector_offset_store<MVE_VSTRHU16_post, aligned16_post_store, 1>; 7311 defm : MVE_vector_offset_store<MVE_VSTRWU32_pre, aligned32_pre_store, 2>; 7312 defm : MVE_vector_offset_store<MVE_VSTRWU32_post, aligned32_post_store, 2>; 7313} 7314 7315let Predicates = [HasMVEInt, IsBE] in { 7316 // Aligned Stores 7317 def : MVE_vector_store_typed<v16i8, MVE_VSTRBU8, store, 0>; 7318 def : MVE_vector_store_typed<v8i16, MVE_VSTRHU16, alignedstore16, 1>; 7319 def : MVE_vector_store_typed<v8f16, MVE_VSTRHU16, alignedstore16, 1>; 7320 def : MVE_vector_store_typed<v4i32, MVE_VSTRWU32, alignedstore32, 2>; 7321 def : MVE_vector_store_typed<v4f32, MVE_VSTRWU32, alignedstore32, 2>; 7322 7323 // Aligned Loads 7324 def : MVE_vector_load_typed<v16i8, MVE_VLDRBU8, load, 0>; 7325 def : MVE_vector_load_typed<v8i16, MVE_VLDRHU16, alignedload16, 1>; 7326 def : MVE_vector_load_typed<v8f16, MVE_VLDRHU16, alignedload16, 1>; 7327 def : MVE_vector_load_typed<v4i32, MVE_VLDRWU32, alignedload32, 2>; 7328 def : MVE_vector_load_typed<v4f32, MVE_VLDRWU32, alignedload32, 2>; 7329 7330 // Other unaligned loads/stores need to go though a VREV 7331 def : Pat<(v2f64 (load t2addrmode_imm7<0>:$addr)), 7332 (v2f64 (MVE_VREV64_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>; 7333 def : Pat<(v2i64 (load t2addrmode_imm7<0>:$addr)), 7334 (v2i64 (MVE_VREV64_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>; 7335 def : Pat<(v4i32 (load t2addrmode_imm7<0>:$addr)), 7336 (v4i32 (MVE_VREV32_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>; 7337 def : Pat<(v4f32 (load t2addrmode_imm7<0>:$addr)), 7338 (v4f32 (MVE_VREV32_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>; 7339 def : Pat<(v8i16 (load t2addrmode_imm7<0>:$addr)), 7340 (v8i16 (MVE_VREV16_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>; 7341 def : Pat<(v8f16 (load t2addrmode_imm7<0>:$addr)), 7342 (v8f16 (MVE_VREV16_8 (MVE_VLDRBU8 t2addrmode_imm7<0>:$addr)))>; 7343 def : Pat<(store (v2f64 MQPR:$val), t2addrmode_imm7<0>:$addr), 7344 (MVE_VSTRBU8 (MVE_VREV64_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>; 7345 def : Pat<(store (v2i64 MQPR:$val), t2addrmode_imm7<0>:$addr), 7346 (MVE_VSTRBU8 (MVE_VREV64_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>; 7347 def : Pat<(store (v4i32 MQPR:$val), t2addrmode_imm7<0>:$addr), 7348 (MVE_VSTRBU8 (MVE_VREV32_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>; 7349 def : Pat<(store (v4f32 MQPR:$val), t2addrmode_imm7<0>:$addr), 7350 (MVE_VSTRBU8 (MVE_VREV32_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>; 7351 def : Pat<(store (v8i16 MQPR:$val), t2addrmode_imm7<0>:$addr), 7352 (MVE_VSTRBU8 (MVE_VREV16_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>; 7353 def : Pat<(store (v8f16 MQPR:$val), t2addrmode_imm7<0>:$addr), 7354 (MVE_VSTRBU8 (MVE_VREV16_8 MQPR:$val), t2addrmode_imm7<0>:$addr)>; 7355 7356 // Pre/Post inc stores 7357 def : MVE_vector_offset_store_typed<v16i8, MVE_VSTRBU8_pre, pre_store, 0>; 7358 def : MVE_vector_offset_store_typed<v16i8, MVE_VSTRBU8_post, post_store, 0>; 7359 def : MVE_vector_offset_store_typed<v8i16, MVE_VSTRHU16_pre, aligned16_pre_store, 1>; 7360 def : MVE_vector_offset_store_typed<v8i16, MVE_VSTRHU16_post, aligned16_post_store, 1>; 7361 def : MVE_vector_offset_store_typed<v8f16, MVE_VSTRHU16_pre, aligned16_pre_store, 1>; 7362 def : MVE_vector_offset_store_typed<v8f16, MVE_VSTRHU16_post, aligned16_post_store, 1>; 7363 def : MVE_vector_offset_store_typed<v4i32, MVE_VSTRWU32_pre, aligned32_pre_store, 2>; 7364 def : MVE_vector_offset_store_typed<v4i32, MVE_VSTRWU32_post, aligned32_post_store, 2>; 7365 def : MVE_vector_offset_store_typed<v4f32, MVE_VSTRWU32_pre, aligned32_pre_store, 2>; 7366 def : MVE_vector_offset_store_typed<v4f32, MVE_VSTRWU32_post, aligned32_post_store, 2>; 7367} 7368 7369let Predicates = [HasMVEInt] in { 7370 // Aligned masked store, shared between LE and BE 7371 def : MVE_vector_maskedstore_typed<v16i8, MVE_VSTRBU8, aligned_maskedstvi8, 0>; 7372 def : MVE_vector_maskedstore_typed<v8i16, MVE_VSTRHU16, aligned_maskedstvi16, 1>; 7373 def : MVE_vector_maskedstore_typed<v8f16, MVE_VSTRHU16, aligned_maskedstvi16, 1>; 7374 def : MVE_vector_maskedstore_typed<v4i32, MVE_VSTRWU32, aligned_maskedstvi32, 2>; 7375 def : MVE_vector_maskedstore_typed<v4f32, MVE_VSTRWU32, aligned_maskedstvi32, 2>; 7376 7377 // Pre/Post inc masked stores 7378 def : MVE_vector_offset_maskedstore_typed<v16i8, MVE_VSTRBU8_pre, aligned_pre_maskedstorevi8, 0>; 7379 def : MVE_vector_offset_maskedstore_typed<v16i8, MVE_VSTRBU8_post, aligned_post_maskedstorevi8, 0>; 7380 def : MVE_vector_offset_maskedstore_typed<v8i16, MVE_VSTRHU16_pre, aligned_pre_maskedstorevi16, 1>; 7381 def : MVE_vector_offset_maskedstore_typed<v8i16, MVE_VSTRHU16_post, aligned_post_maskedstorevi16, 1>; 7382 def : MVE_vector_offset_maskedstore_typed<v8f16, MVE_VSTRHU16_pre, aligned_pre_maskedstorevi16, 1>; 7383 def : MVE_vector_offset_maskedstore_typed<v8f16, MVE_VSTRHU16_post, aligned_post_maskedstorevi16, 1>; 7384 def : MVE_vector_offset_maskedstore_typed<v4i32, MVE_VSTRWU32_pre, aligned_pre_maskedstorevi32, 2>; 7385 def : MVE_vector_offset_maskedstore_typed<v4i32, MVE_VSTRWU32_post, aligned_post_maskedstorevi32, 2>; 7386 def : MVE_vector_offset_maskedstore_typed<v4f32, MVE_VSTRWU32_pre, aligned_pre_maskedstorevi32, 2>; 7387 def : MVE_vector_offset_maskedstore_typed<v4f32, MVE_VSTRWU32_post, aligned_post_maskedstorevi32, 2>; 7388 7389 // Aligned masked loads 7390 def : MVE_vector_maskedload_typed<v16i8, MVE_VLDRBU8, aligned_maskedloadvi8, 0>; 7391 def : MVE_vector_maskedload_typed<v8i16, MVE_VLDRHU16, aligned_maskedloadvi16, 1>; 7392 def : MVE_vector_maskedload_typed<v8f16, MVE_VLDRHU16, aligned_maskedloadvi16, 1>; 7393 def : MVE_vector_maskedload_typed<v4i32, MVE_VLDRWU32, aligned_maskedloadvi32, 2>; 7394 def : MVE_vector_maskedload_typed<v4f32, MVE_VLDRWU32, aligned_maskedloadvi32, 2>; 7395} 7396 7397// Widening/Narrowing Loads/Stores 7398 7399multiclass MVEExtLoadStore<Instruction LoadSInst, Instruction LoadUInst, string StoreInst, 7400 string Amble, ValueType VT, int Shift> { 7401 // Trunc stores 7402 def : Pat<(!cast<PatFrag>("aligned_truncst"#Amble) (VT MQPR:$val), taddrmode_imm7<Shift>:$addr), 7403 (!cast<Instruction>(StoreInst) MQPR:$val, taddrmode_imm7<Shift>:$addr)>; 7404 def : Pat<(!cast<PatFrag>("aligned_post_truncst"#Amble) (VT MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<Shift>:$addr), 7405 (!cast<Instruction>(StoreInst#"_post") MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<Shift>:$addr)>; 7406 def : Pat<(!cast<PatFrag>("aligned_pre_truncst"#Amble) (VT MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<Shift>:$addr), 7407 (!cast<Instruction>(StoreInst#"_pre") MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<Shift>:$addr)>; 7408 7409 // Masked trunc stores 7410 def : Pat<(!cast<PatFrag>("aligned_truncmaskedst"#Amble) (VT MQPR:$val), taddrmode_imm7<Shift>:$addr, VCCR:$pred), 7411 (!cast<Instruction>(StoreInst) MQPR:$val, taddrmode_imm7<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg)>; 7412 def : Pat<(!cast<PatFrag>("aligned_post_truncmaskedst"#Amble) (VT MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<Shift>:$addr, VCCR:$pred), 7413 (!cast<Instruction>(StoreInst#"_post") MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg)>; 7414 def : Pat<(!cast<PatFrag>("aligned_pre_truncmaskedst"#Amble) (VT MQPR:$Rt), tGPR:$Rn, t2am_imm7_offset<Shift>:$addr, VCCR:$pred), 7415 (!cast<Instruction>(StoreInst#"_pre") MQPR:$Rt, tGPR:$Rn, t2am_imm7_offset<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg)>; 7416 7417 // Ext loads 7418 def : Pat<(VT (!cast<PatFrag>("aligned_extload"#Amble) taddrmode_imm7<Shift>:$addr)), 7419 (VT (LoadUInst taddrmode_imm7<Shift>:$addr))>; 7420 def : Pat<(VT (!cast<PatFrag>("aligned_sextload"#Amble) taddrmode_imm7<Shift>:$addr)), 7421 (VT (LoadSInst taddrmode_imm7<Shift>:$addr))>; 7422 def : Pat<(VT (!cast<PatFrag>("aligned_zextload"#Amble) taddrmode_imm7<Shift>:$addr)), 7423 (VT (LoadUInst taddrmode_imm7<Shift>:$addr))>; 7424 7425 // Masked ext loads 7426 def : Pat<(VT (!cast<PatFrag>("aligned_extmaskedload"#Amble) taddrmode_imm7<Shift>:$addr, VCCR:$pred, (VT (ARMvmovImm (i32 0))))), 7427 (VT (LoadUInst taddrmode_imm7<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg))>; 7428 def : Pat<(VT (!cast<PatFrag>("aligned_sextmaskedload"#Amble) taddrmode_imm7<Shift>:$addr, VCCR:$pred, (VT (ARMvmovImm (i32 0))))), 7429 (VT (LoadSInst taddrmode_imm7<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg))>; 7430 def : Pat<(VT (!cast<PatFrag>("aligned_zextmaskedload"#Amble) taddrmode_imm7<Shift>:$addr, VCCR:$pred, (VT (ARMvmovImm (i32 0))))), 7431 (VT (LoadUInst taddrmode_imm7<Shift>:$addr, ARMVCCThen, VCCR:$pred, zero_reg))>; 7432} 7433 7434let Predicates = [HasMVEInt] in { 7435 defm : MVEExtLoadStore<MVE_VLDRBS16, MVE_VLDRBU16, "MVE_VSTRB16", "vi8", v8i16, 0>; 7436 defm : MVEExtLoadStore<MVE_VLDRBS32, MVE_VLDRBU32, "MVE_VSTRB32", "vi8", v4i32, 0>; 7437 defm : MVEExtLoadStore<MVE_VLDRHS32, MVE_VLDRHU32, "MVE_VSTRH32", "vi16", v4i32, 1>; 7438} 7439 7440 7441// Bit convert patterns 7442 7443let Predicates = [HasMVEInt] in { 7444 def : Pat<(v2f64 (bitconvert (v2i64 MQPR:$src))), (v2f64 MQPR:$src)>; 7445 def : Pat<(v2i64 (bitconvert (v2f64 MQPR:$src))), (v2i64 MQPR:$src)>; 7446 7447 def : Pat<(v4i32 (bitconvert (v4f32 MQPR:$src))), (v4i32 MQPR:$src)>; 7448 def : Pat<(v4f32 (bitconvert (v4i32 MQPR:$src))), (v4f32 MQPR:$src)>; 7449 7450 def : Pat<(v8i16 (bitconvert (v8f16 MQPR:$src))), (v8i16 MQPR:$src)>; 7451 def : Pat<(v8f16 (bitconvert (v8i16 MQPR:$src))), (v8f16 MQPR:$src)>; 7452} 7453 7454let Predicates = [IsLE,HasMVEInt] in { 7455 def : Pat<(v2f64 (bitconvert (v4f32 MQPR:$src))), (v2f64 MQPR:$src)>; 7456 def : Pat<(v2f64 (bitconvert (v4i32 MQPR:$src))), (v2f64 MQPR:$src)>; 7457 def : Pat<(v2f64 (bitconvert (v8f16 MQPR:$src))), (v2f64 MQPR:$src)>; 7458 def : Pat<(v2f64 (bitconvert (v8i16 MQPR:$src))), (v2f64 MQPR:$src)>; 7459 def : Pat<(v2f64 (bitconvert (v16i8 MQPR:$src))), (v2f64 MQPR:$src)>; 7460 7461 def : Pat<(v2i64 (bitconvert (v4f32 MQPR:$src))), (v2i64 MQPR:$src)>; 7462 def : Pat<(v2i64 (bitconvert (v4i32 MQPR:$src))), (v2i64 MQPR:$src)>; 7463 def : Pat<(v2i64 (bitconvert (v8f16 MQPR:$src))), (v2i64 MQPR:$src)>; 7464 def : Pat<(v2i64 (bitconvert (v8i16 MQPR:$src))), (v2i64 MQPR:$src)>; 7465 def : Pat<(v2i64 (bitconvert (v16i8 MQPR:$src))), (v2i64 MQPR:$src)>; 7466 7467 def : Pat<(v4f32 (bitconvert (v2f64 MQPR:$src))), (v4f32 MQPR:$src)>; 7468 def : Pat<(v4f32 (bitconvert (v2i64 MQPR:$src))), (v4f32 MQPR:$src)>; 7469 def : Pat<(v4f32 (bitconvert (v8f16 MQPR:$src))), (v4f32 MQPR:$src)>; 7470 def : Pat<(v4f32 (bitconvert (v8i16 MQPR:$src))), (v4f32 MQPR:$src)>; 7471 def : Pat<(v4f32 (bitconvert (v16i8 MQPR:$src))), (v4f32 MQPR:$src)>; 7472 7473 def : Pat<(v4i32 (bitconvert (v2f64 MQPR:$src))), (v4i32 MQPR:$src)>; 7474 def : Pat<(v4i32 (bitconvert (v2i64 MQPR:$src))), (v4i32 MQPR:$src)>; 7475 def : Pat<(v4i32 (bitconvert (v8f16 MQPR:$src))), (v4i32 MQPR:$src)>; 7476 def : Pat<(v4i32 (bitconvert (v8i16 MQPR:$src))), (v4i32 MQPR:$src)>; 7477 def : Pat<(v4i32 (bitconvert (v16i8 MQPR:$src))), (v4i32 MQPR:$src)>; 7478 7479 def : Pat<(v8f16 (bitconvert (v2f64 MQPR:$src))), (v8f16 MQPR:$src)>; 7480 def : Pat<(v8f16 (bitconvert (v2i64 MQPR:$src))), (v8f16 MQPR:$src)>; 7481 def : Pat<(v8f16 (bitconvert (v4f32 MQPR:$src))), (v8f16 MQPR:$src)>; 7482 def : Pat<(v8f16 (bitconvert (v4i32 MQPR:$src))), (v8f16 MQPR:$src)>; 7483 def : Pat<(v8f16 (bitconvert (v16i8 MQPR:$src))), (v8f16 MQPR:$src)>; 7484 7485 def : Pat<(v8i16 (bitconvert (v2f64 MQPR:$src))), (v8i16 MQPR:$src)>; 7486 def : Pat<(v8i16 (bitconvert (v2i64 MQPR:$src))), (v8i16 MQPR:$src)>; 7487 def : Pat<(v8i16 (bitconvert (v4f32 MQPR:$src))), (v8i16 MQPR:$src)>; 7488 def : Pat<(v8i16 (bitconvert (v4i32 MQPR:$src))), (v8i16 MQPR:$src)>; 7489 def : Pat<(v8i16 (bitconvert (v16i8 MQPR:$src))), (v8i16 MQPR:$src)>; 7490 7491 def : Pat<(v16i8 (bitconvert (v2f64 MQPR:$src))), (v16i8 MQPR:$src)>; 7492 def : Pat<(v16i8 (bitconvert (v2i64 MQPR:$src))), (v16i8 MQPR:$src)>; 7493 def : Pat<(v16i8 (bitconvert (v4f32 MQPR:$src))), (v16i8 MQPR:$src)>; 7494 def : Pat<(v16i8 (bitconvert (v4i32 MQPR:$src))), (v16i8 MQPR:$src)>; 7495 def : Pat<(v16i8 (bitconvert (v8f16 MQPR:$src))), (v16i8 MQPR:$src)>; 7496 def : Pat<(v16i8 (bitconvert (v8i16 MQPR:$src))), (v16i8 MQPR:$src)>; 7497} 7498 7499let Predicates = [IsBE,HasMVEInt] in { 7500 def : Pat<(v2f64 (bitconvert (v4f32 MQPR:$src))), (v2f64 (MVE_VREV64_32 MQPR:$src))>; 7501 def : Pat<(v2f64 (bitconvert (v4i32 MQPR:$src))), (v2f64 (MVE_VREV64_32 MQPR:$src))>; 7502 def : Pat<(v2f64 (bitconvert (v8f16 MQPR:$src))), (v2f64 (MVE_VREV64_16 MQPR:$src))>; 7503 def : Pat<(v2f64 (bitconvert (v8i16 MQPR:$src))), (v2f64 (MVE_VREV64_16 MQPR:$src))>; 7504 def : Pat<(v2f64 (bitconvert (v16i8 MQPR:$src))), (v2f64 (MVE_VREV64_8 MQPR:$src))>; 7505 7506 def : Pat<(v2i64 (bitconvert (v4f32 MQPR:$src))), (v2i64 (MVE_VREV64_32 MQPR:$src))>; 7507 def : Pat<(v2i64 (bitconvert (v4i32 MQPR:$src))), (v2i64 (MVE_VREV64_32 MQPR:$src))>; 7508 def : Pat<(v2i64 (bitconvert (v8f16 MQPR:$src))), (v2i64 (MVE_VREV64_16 MQPR:$src))>; 7509 def : Pat<(v2i64 (bitconvert (v8i16 MQPR:$src))), (v2i64 (MVE_VREV64_16 MQPR:$src))>; 7510 def : Pat<(v2i64 (bitconvert (v16i8 MQPR:$src))), (v2i64 (MVE_VREV64_8 MQPR:$src))>; 7511 7512 def : Pat<(v4f32 (bitconvert (v2f64 MQPR:$src))), (v4f32 (MVE_VREV64_32 MQPR:$src))>; 7513 def : Pat<(v4f32 (bitconvert (v2i64 MQPR:$src))), (v4f32 (MVE_VREV64_32 MQPR:$src))>; 7514 def : Pat<(v4f32 (bitconvert (v8f16 MQPR:$src))), (v4f32 (MVE_VREV32_16 MQPR:$src))>; 7515 def : Pat<(v4f32 (bitconvert (v8i16 MQPR:$src))), (v4f32 (MVE_VREV32_16 MQPR:$src))>; 7516 def : Pat<(v4f32 (bitconvert (v16i8 MQPR:$src))), (v4f32 (MVE_VREV32_8 MQPR:$src))>; 7517 7518 def : Pat<(v4i32 (bitconvert (v2f64 MQPR:$src))), (v4i32 (MVE_VREV64_32 MQPR:$src))>; 7519 def : Pat<(v4i32 (bitconvert (v2i64 MQPR:$src))), (v4i32 (MVE_VREV64_32 MQPR:$src))>; 7520 def : Pat<(v4i32 (bitconvert (v8f16 MQPR:$src))), (v4i32 (MVE_VREV32_16 MQPR:$src))>; 7521 def : Pat<(v4i32 (bitconvert (v8i16 MQPR:$src))), (v4i32 (MVE_VREV32_16 MQPR:$src))>; 7522 def : Pat<(v4i32 (bitconvert (v16i8 MQPR:$src))), (v4i32 (MVE_VREV32_8 MQPR:$src))>; 7523 7524 def : Pat<(v8f16 (bitconvert (v2f64 MQPR:$src))), (v8f16 (MVE_VREV64_16 MQPR:$src))>; 7525 def : Pat<(v8f16 (bitconvert (v2i64 MQPR:$src))), (v8f16 (MVE_VREV64_16 MQPR:$src))>; 7526 def : Pat<(v8f16 (bitconvert (v4f32 MQPR:$src))), (v8f16 (MVE_VREV32_16 MQPR:$src))>; 7527 def : Pat<(v8f16 (bitconvert (v4i32 MQPR:$src))), (v8f16 (MVE_VREV32_16 MQPR:$src))>; 7528 def : Pat<(v8f16 (bitconvert (v16i8 MQPR:$src))), (v8f16 (MVE_VREV16_8 MQPR:$src))>; 7529 7530 def : Pat<(v8i16 (bitconvert (v2f64 MQPR:$src))), (v8i16 (MVE_VREV64_16 MQPR:$src))>; 7531 def : Pat<(v8i16 (bitconvert (v2i64 MQPR:$src))), (v8i16 (MVE_VREV64_16 MQPR:$src))>; 7532 def : Pat<(v8i16 (bitconvert (v4f32 MQPR:$src))), (v8i16 (MVE_VREV32_16 MQPR:$src))>; 7533 def : Pat<(v8i16 (bitconvert (v4i32 MQPR:$src))), (v8i16 (MVE_VREV32_16 MQPR:$src))>; 7534 def : Pat<(v8i16 (bitconvert (v16i8 MQPR:$src))), (v8i16 (MVE_VREV16_8 MQPR:$src))>; 7535 7536 def : Pat<(v16i8 (bitconvert (v2f64 MQPR:$src))), (v16i8 (MVE_VREV64_8 MQPR:$src))>; 7537 def : Pat<(v16i8 (bitconvert (v2i64 MQPR:$src))), (v16i8 (MVE_VREV64_8 MQPR:$src))>; 7538 def : Pat<(v16i8 (bitconvert (v4f32 MQPR:$src))), (v16i8 (MVE_VREV32_8 MQPR:$src))>; 7539 def : Pat<(v16i8 (bitconvert (v4i32 MQPR:$src))), (v16i8 (MVE_VREV32_8 MQPR:$src))>; 7540 def : Pat<(v16i8 (bitconvert (v8f16 MQPR:$src))), (v16i8 (MVE_VREV16_8 MQPR:$src))>; 7541 def : Pat<(v16i8 (bitconvert (v8i16 MQPR:$src))), (v16i8 (MVE_VREV16_8 MQPR:$src))>; 7542} 7543