1//===-- ARMInstrVFP.td - VFP 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 VFP instruction set. 10// 11//===----------------------------------------------------------------------===// 12 13def SDT_CMPFP0 : SDTypeProfile<0, 1, [SDTCisFP<0>]>; 14def SDT_VMOVDRR : SDTypeProfile<1, 2, [SDTCisVT<0, f64>, SDTCisVT<1, i32>, 15 SDTCisSameAs<1, 2>]>; 16def SDT_VMOVRRD : SDTypeProfile<2, 1, [SDTCisVT<0, i32>, SDTCisSameAs<0, 1>, 17 SDTCisVT<2, f64>]>; 18 19def SDT_VMOVSR : SDTypeProfile<1, 1, [SDTCisVT<0, f32>, SDTCisVT<1, i32>]>; 20 21def arm_fmstat : SDNode<"ARMISD::FMSTAT", SDTNone, [SDNPInGlue, SDNPOutGlue]>; 22def arm_cmpfp : SDNode<"ARMISD::CMPFP", SDT_ARMCmp, [SDNPOutGlue]>; 23def arm_cmpfp0 : SDNode<"ARMISD::CMPFPw0", SDT_CMPFP0, [SDNPOutGlue]>; 24def arm_cmpfpe : SDNode<"ARMISD::CMPFPE", SDT_ARMCmp, [SDNPOutGlue]>; 25def arm_cmpfpe0: SDNode<"ARMISD::CMPFPEw0",SDT_CMPFP0, [SDNPOutGlue]>; 26def arm_fmdrr : SDNode<"ARMISD::VMOVDRR", SDT_VMOVDRR>; 27def arm_fmrrd : SDNode<"ARMISD::VMOVRRD", SDT_VMOVRRD>; 28def arm_vmovsr : SDNode<"ARMISD::VMOVSR", SDT_VMOVSR>; 29 30def SDT_VMOVhr : SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisVT<1, i32>] >; 31def SDT_VMOVrh : SDTypeProfile<1, 1, [SDTCisVT<0, i32>, SDTCisFP<1>] >; 32def arm_vmovhr : SDNode<"ARMISD::VMOVhr", SDT_VMOVhr>; 33def arm_vmovrh : SDNode<"ARMISD::VMOVrh", SDT_VMOVrh>; 34 35//===----------------------------------------------------------------------===// 36// Operand Definitions. 37// 38 39// 8-bit floating-point immediate encodings. 40def FPImmOperand : AsmOperandClass { 41 let Name = "FPImm"; 42 let ParserMethod = "parseFPImm"; 43} 44 45def vfp_f16imm : Operand<f16>, 46 PatLeaf<(f16 fpimm), [{ 47 return ARM_AM::getFP16Imm(N->getValueAPF()) != -1; 48 }], SDNodeXForm<fpimm, [{ 49 APFloat InVal = N->getValueAPF(); 50 uint32_t enc = ARM_AM::getFP16Imm(InVal); 51 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32); 52 }]>> { 53 let PrintMethod = "printFPImmOperand"; 54 let ParserMatchClass = FPImmOperand; 55} 56 57def vfp_f32f16imm_xform : SDNodeXForm<fpimm, [{ 58 APFloat InVal = N->getValueAPF(); 59 uint32_t enc = ARM_AM::getFP32FP16Imm(InVal); 60 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32); 61 }]>; 62 63def vfp_f32f16imm : PatLeaf<(f32 fpimm), [{ 64 return ARM_AM::getFP32FP16Imm(N->getValueAPF()) != -1; 65 }], vfp_f32f16imm_xform>; 66 67def vfp_f32imm_xform : SDNodeXForm<fpimm, [{ 68 APFloat InVal = N->getValueAPF(); 69 uint32_t enc = ARM_AM::getFP32Imm(InVal); 70 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32); 71 }]>; 72 73def gi_vfp_f32imm : GICustomOperandRenderer<"renderVFPF32Imm">, 74 GISDNodeXFormEquiv<vfp_f32imm_xform>; 75 76def vfp_f32imm : Operand<f32>, 77 PatLeaf<(f32 fpimm), [{ 78 return ARM_AM::getFP32Imm(N->getValueAPF()) != -1; 79 }], vfp_f32imm_xform> { 80 let PrintMethod = "printFPImmOperand"; 81 let ParserMatchClass = FPImmOperand; 82 let GISelPredicateCode = [{ 83 const auto &MO = MI.getOperand(1); 84 if (!MO.isFPImm()) 85 return false; 86 return ARM_AM::getFP32Imm(MO.getFPImm()->getValueAPF()) != -1; 87 }]; 88} 89 90def vfp_f64imm_xform : SDNodeXForm<fpimm, [{ 91 APFloat InVal = N->getValueAPF(); 92 uint32_t enc = ARM_AM::getFP64Imm(InVal); 93 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i32); 94 }]>; 95 96def gi_vfp_f64imm : GICustomOperandRenderer<"renderVFPF64Imm">, 97 GISDNodeXFormEquiv<vfp_f64imm_xform>; 98 99def vfp_f64imm : Operand<f64>, 100 PatLeaf<(f64 fpimm), [{ 101 return ARM_AM::getFP64Imm(N->getValueAPF()) != -1; 102 }], vfp_f64imm_xform> { 103 let PrintMethod = "printFPImmOperand"; 104 let ParserMatchClass = FPImmOperand; 105 let GISelPredicateCode = [{ 106 const auto &MO = MI.getOperand(1); 107 if (!MO.isFPImm()) 108 return false; 109 return ARM_AM::getFP64Imm(MO.getFPImm()->getValueAPF()) != -1; 110 }]; 111} 112 113def alignedload16 : PatFrag<(ops node:$ptr), (load node:$ptr), [{ 114 return cast<LoadSDNode>(N)->getAlignment() >= 2; 115}]>; 116 117def alignedload32 : PatFrag<(ops node:$ptr), (load node:$ptr), [{ 118 return cast<LoadSDNode>(N)->getAlignment() >= 4; 119}]>; 120 121def alignedstore16 : PatFrag<(ops node:$val, node:$ptr), 122 (store node:$val, node:$ptr), [{ 123 return cast<StoreSDNode>(N)->getAlignment() >= 2; 124}]>; 125 126def alignedstore32 : PatFrag<(ops node:$val, node:$ptr), 127 (store node:$val, node:$ptr), [{ 128 return cast<StoreSDNode>(N)->getAlignment() >= 4; 129}]>; 130 131// The VCVT to/from fixed-point instructions encode the 'fbits' operand 132// (the number of fixed bits) differently than it appears in the assembly 133// source. It's encoded as "Size - fbits" where Size is the size of the 134// fixed-point representation (32 or 16) and fbits is the value appearing 135// in the assembly source, an integer in [0,16] or (0,32], depending on size. 136def fbits32_asm_operand : AsmOperandClass { let Name = "FBits32"; } 137def fbits32 : Operand<i32> { 138 let PrintMethod = "printFBits32"; 139 let ParserMatchClass = fbits32_asm_operand; 140} 141 142def fbits16_asm_operand : AsmOperandClass { let Name = "FBits16"; } 143def fbits16 : Operand<i32> { 144 let PrintMethod = "printFBits16"; 145 let ParserMatchClass = fbits16_asm_operand; 146} 147 148//===----------------------------------------------------------------------===// 149// Load / store Instructions. 150// 151 152let canFoldAsLoad = 1, isReMaterializable = 1 in { 153 154def VLDRD : ADI5<0b1101, 0b01, (outs DPR:$Dd), (ins addrmode5:$addr), 155 IIC_fpLoad64, "vldr", "\t$Dd, $addr", 156 [(set DPR:$Dd, (f64 (alignedload32 addrmode5:$addr)))]>, 157 Requires<[HasFPRegs]>; 158 159def VLDRS : ASI5<0b1101, 0b01, (outs SPR:$Sd), (ins addrmode5:$addr), 160 IIC_fpLoad32, "vldr", "\t$Sd, $addr", 161 [(set SPR:$Sd, (alignedload32 addrmode5:$addr))]>, 162 Requires<[HasFPRegs]> { 163 // Some single precision VFP instructions may be executed on both NEON and VFP 164 // pipelines. 165 let D = VFPNeonDomain; 166} 167 168let isUnpredicable = 1 in 169def VLDRH : AHI5<0b1101, 0b01, (outs HPR:$Sd), (ins addrmode5fp16:$addr), 170 IIC_fpLoad16, "vldr", ".16\t$Sd, $addr", 171 [(set HPR:$Sd, (f16 (alignedload16 addrmode5fp16:$addr)))]>, 172 Requires<[HasFPRegs16]>; 173 174} // End of 'let canFoldAsLoad = 1, isReMaterializable = 1 in' 175 176def : Pat<(bf16 (alignedload16 addrmode5fp16:$addr)), 177 (VLDRH addrmode5fp16:$addr)> { 178 let Predicates = [HasFPRegs16]; 179} 180def : Pat<(bf16 (alignedload16 addrmode3:$addr)), 181 (COPY_TO_REGCLASS (LDRH addrmode3:$addr), HPR)> { 182 let Predicates = [HasNoFPRegs16, IsARM]; 183} 184def : Pat<(bf16 (alignedload16 t2addrmode_imm12:$addr)), 185 (COPY_TO_REGCLASS (t2LDRHi12 t2addrmode_imm12:$addr), HPR)> { 186 let Predicates = [HasNoFPRegs16, IsThumb]; 187} 188 189def VSTRD : ADI5<0b1101, 0b00, (outs), (ins DPR:$Dd, addrmode5:$addr), 190 IIC_fpStore64, "vstr", "\t$Dd, $addr", 191 [(alignedstore32 (f64 DPR:$Dd), addrmode5:$addr)]>, 192 Requires<[HasFPRegs]>; 193 194def VSTRS : ASI5<0b1101, 0b00, (outs), (ins SPR:$Sd, addrmode5:$addr), 195 IIC_fpStore32, "vstr", "\t$Sd, $addr", 196 [(alignedstore32 SPR:$Sd, addrmode5:$addr)]>, 197 Requires<[HasFPRegs]> { 198 // Some single precision VFP instructions may be executed on both NEON and VFP 199 // pipelines. 200 let D = VFPNeonDomain; 201} 202 203let isUnpredicable = 1 in 204def VSTRH : AHI5<0b1101, 0b00, (outs), (ins HPR:$Sd, addrmode5fp16:$addr), 205 IIC_fpStore16, "vstr", ".16\t$Sd, $addr", 206 [(alignedstore16 (f16 HPR:$Sd), addrmode5fp16:$addr)]>, 207 Requires<[HasFPRegs16]>; 208 209def : Pat<(alignedstore16 (bf16 HPR:$Sd), addrmode5fp16:$addr), 210 (VSTRH (bf16 HPR:$Sd), addrmode5fp16:$addr)> { 211 let Predicates = [HasFPRegs16]; 212} 213def : Pat<(alignedstore16 (bf16 HPR:$Sd), addrmode3:$addr), 214 (STRH (COPY_TO_REGCLASS $Sd, GPR), addrmode3:$addr)> { 215 let Predicates = [HasNoFPRegs16, IsARM]; 216} 217def : Pat<(alignedstore16 (bf16 HPR:$Sd), t2addrmode_imm12:$addr), 218 (t2STRHi12 (COPY_TO_REGCLASS $Sd, GPR), t2addrmode_imm12:$addr)> { 219 let Predicates = [HasNoFPRegs16, IsThumb]; 220} 221 222//===----------------------------------------------------------------------===// 223// Load / store multiple Instructions. 224// 225 226multiclass vfp_ldst_mult<string asm, bit L_bit, 227 InstrItinClass itin, InstrItinClass itin_upd> { 228 let Predicates = [HasFPRegs] in { 229 // Double Precision 230 def DIA : 231 AXDI4<(outs), (ins GPR:$Rn, pred:$p, dpr_reglist:$regs, variable_ops), 232 IndexModeNone, itin, 233 !strconcat(asm, "ia${p}\t$Rn, $regs"), "", []> { 234 let Inst{24-23} = 0b01; // Increment After 235 let Inst{21} = 0; // No writeback 236 let Inst{20} = L_bit; 237 } 238 def DIA_UPD : 239 AXDI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, dpr_reglist:$regs, 240 variable_ops), 241 IndexModeUpd, itin_upd, 242 !strconcat(asm, "ia${p}\t$Rn!, $regs"), "$Rn = $wb", []> { 243 let Inst{24-23} = 0b01; // Increment After 244 let Inst{21} = 1; // Writeback 245 let Inst{20} = L_bit; 246 } 247 def DDB_UPD : 248 AXDI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, dpr_reglist:$regs, 249 variable_ops), 250 IndexModeUpd, itin_upd, 251 !strconcat(asm, "db${p}\t$Rn!, $regs"), "$Rn = $wb", []> { 252 let Inst{24-23} = 0b10; // Decrement Before 253 let Inst{21} = 1; // Writeback 254 let Inst{20} = L_bit; 255 } 256 257 // Single Precision 258 def SIA : 259 AXSI4<(outs), (ins GPR:$Rn, pred:$p, spr_reglist:$regs, variable_ops), 260 IndexModeNone, itin, 261 !strconcat(asm, "ia${p}\t$Rn, $regs"), "", []> { 262 let Inst{24-23} = 0b01; // Increment After 263 let Inst{21} = 0; // No writeback 264 let Inst{20} = L_bit; 265 266 // Some single precision VFP instructions may be executed on both NEON and 267 // VFP pipelines. 268 let D = VFPNeonDomain; 269 } 270 def SIA_UPD : 271 AXSI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, spr_reglist:$regs, 272 variable_ops), 273 IndexModeUpd, itin_upd, 274 !strconcat(asm, "ia${p}\t$Rn!, $regs"), "$Rn = $wb", []> { 275 let Inst{24-23} = 0b01; // Increment After 276 let Inst{21} = 1; // Writeback 277 let Inst{20} = L_bit; 278 279 // Some single precision VFP instructions may be executed on both NEON and 280 // VFP pipelines. 281 let D = VFPNeonDomain; 282 } 283 def SDB_UPD : 284 AXSI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, spr_reglist:$regs, 285 variable_ops), 286 IndexModeUpd, itin_upd, 287 !strconcat(asm, "db${p}\t$Rn!, $regs"), "$Rn = $wb", []> { 288 let Inst{24-23} = 0b10; // Decrement Before 289 let Inst{21} = 1; // Writeback 290 let Inst{20} = L_bit; 291 292 // Some single precision VFP instructions may be executed on both NEON and 293 // VFP pipelines. 294 let D = VFPNeonDomain; 295 } 296 } 297} 298 299let hasSideEffects = 0 in { 300 301let mayLoad = 1, hasExtraDefRegAllocReq = 1 in 302defm VLDM : vfp_ldst_mult<"vldm", 1, IIC_fpLoad_m, IIC_fpLoad_mu>; 303 304let mayStore = 1, hasExtraSrcRegAllocReq = 1 in 305defm VSTM : vfp_ldst_mult<"vstm", 0, IIC_fpStore_m, IIC_fpStore_mu>; 306 307} // hasSideEffects 308 309def : MnemonicAlias<"vldm", "vldmia">; 310def : MnemonicAlias<"vstm", "vstmia">; 311 312 313//===----------------------------------------------------------------------===// 314// Lazy load / store multiple Instructions 315// 316def VLLDM : AXSI4<(outs), (ins GPRnopc:$Rn, pred:$p), IndexModeNone, 317 NoItinerary, "vlldm${p}\t$Rn", "", []>, 318 Requires<[HasV8MMainline, Has8MSecExt]> { 319 let Inst{24-23} = 0b00; 320 let Inst{22} = 0; 321 let Inst{21} = 1; 322 let Inst{20} = 1; 323 let Inst{15-12} = 0; 324 let Inst{7-0} = 0; 325 let mayLoad = 1; 326 let Defs = [Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, VPR, FPSCR, FPSCR_NZCV]; 327} 328 329def VLSTM : AXSI4<(outs), (ins GPRnopc:$Rn, pred:$p), IndexModeNone, 330 NoItinerary, "vlstm${p}\t$Rn", "", []>, 331 Requires<[HasV8MMainline, Has8MSecExt]> { 332 let Inst{24-23} = 0b00; 333 let Inst{22} = 0; 334 let Inst{21} = 1; 335 let Inst{20} = 0; 336 let Inst{15-12} = 0; 337 let Inst{7-0} = 0; 338 let mayStore = 1; 339} 340 341def : InstAlias<"vpush${p} $r", (VSTMDDB_UPD SP, pred:$p, dpr_reglist:$r), 0>, 342 Requires<[HasFPRegs]>; 343def : InstAlias<"vpush${p} $r", (VSTMSDB_UPD SP, pred:$p, spr_reglist:$r), 0>, 344 Requires<[HasFPRegs]>; 345def : InstAlias<"vpop${p} $r", (VLDMDIA_UPD SP, pred:$p, dpr_reglist:$r), 0>, 346 Requires<[HasFPRegs]>; 347def : InstAlias<"vpop${p} $r", (VLDMSIA_UPD SP, pred:$p, spr_reglist:$r), 0>, 348 Requires<[HasFPRegs]>; 349defm : VFPDTAnyInstAlias<"vpush${p}", "$r", 350 (VSTMSDB_UPD SP, pred:$p, spr_reglist:$r)>; 351defm : VFPDTAnyInstAlias<"vpush${p}", "$r", 352 (VSTMDDB_UPD SP, pred:$p, dpr_reglist:$r)>; 353defm : VFPDTAnyInstAlias<"vpop${p}", "$r", 354 (VLDMSIA_UPD SP, pred:$p, spr_reglist:$r)>; 355defm : VFPDTAnyInstAlias<"vpop${p}", "$r", 356 (VLDMDIA_UPD SP, pred:$p, dpr_reglist:$r)>; 357 358// FLDMX, FSTMX - Load and store multiple unknown precision registers for 359// pre-armv6 cores. 360// These instruction are deprecated so we don't want them to get selected. 361// However, there is no UAL syntax for them, so we keep them around for 362// (dis)assembly only. 363multiclass vfp_ldstx_mult<string asm, bit L_bit> { 364 let Predicates = [HasFPRegs], hasNoSchedulingInfo = 1 in { 365 // Unknown precision 366 def XIA : 367 AXXI4<(outs), (ins GPR:$Rn, pred:$p, dpr_reglist:$regs, variable_ops), 368 IndexModeNone, !strconcat(asm, "iax${p}\t$Rn, $regs"), "", []> { 369 let Inst{24-23} = 0b01; // Increment After 370 let Inst{21} = 0; // No writeback 371 let Inst{20} = L_bit; 372 } 373 def XIA_UPD : 374 AXXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, dpr_reglist:$regs, variable_ops), 375 IndexModeUpd, !strconcat(asm, "iax${p}\t$Rn!, $regs"), "$Rn = $wb", []> { 376 let Inst{24-23} = 0b01; // Increment After 377 let Inst{21} = 1; // Writeback 378 let Inst{20} = L_bit; 379 } 380 def XDB_UPD : 381 AXXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, dpr_reglist:$regs, variable_ops), 382 IndexModeUpd, !strconcat(asm, "dbx${p}\t$Rn!, $regs"), "$Rn = $wb", []> { 383 let Inst{24-23} = 0b10; // Decrement Before 384 let Inst{21} = 1; // Writeback 385 let Inst{20} = L_bit; 386 } 387 } 388} 389 390defm FLDM : vfp_ldstx_mult<"fldm", 1>; 391defm FSTM : vfp_ldstx_mult<"fstm", 0>; 392 393def : VFP2MnemonicAlias<"fldmeax", "fldmdbx">; 394def : VFP2MnemonicAlias<"fldmfdx", "fldmiax">; 395 396def : VFP2MnemonicAlias<"fstmeax", "fstmiax">; 397def : VFP2MnemonicAlias<"fstmfdx", "fstmdbx">; 398 399//===----------------------------------------------------------------------===// 400// FP Binary Operations. 401// 402 403let TwoOperandAliasConstraint = "$Dn = $Dd" in 404def VADDD : ADbI<0b11100, 0b11, 0, 0, 405 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm), 406 IIC_fpALU64, "vadd", ".f64\t$Dd, $Dn, $Dm", 407 [(set DPR:$Dd, (fadd DPR:$Dn, (f64 DPR:$Dm)))]>, 408 Sched<[WriteFPALU64]>; 409 410let TwoOperandAliasConstraint = "$Sn = $Sd" in 411def VADDS : ASbIn<0b11100, 0b11, 0, 0, 412 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm), 413 IIC_fpALU32, "vadd", ".f32\t$Sd, $Sn, $Sm", 414 [(set SPR:$Sd, (fadd SPR:$Sn, SPR:$Sm))]>, 415 Sched<[WriteFPALU32]> { 416 // Some single precision VFP instructions may be executed on both NEON and 417 // VFP pipelines on A8. 418 let D = VFPNeonA8Domain; 419} 420 421let TwoOperandAliasConstraint = "$Sn = $Sd" in 422def VADDH : AHbI<0b11100, 0b11, 0, 0, 423 (outs HPR:$Sd), (ins HPR:$Sn, HPR:$Sm), 424 IIC_fpALU16, "vadd", ".f16\t$Sd, $Sn, $Sm", 425 [(set (f16 HPR:$Sd), (fadd (f16 HPR:$Sn), (f16 HPR:$Sm)))]>, 426 Sched<[WriteFPALU32]>; 427 428let TwoOperandAliasConstraint = "$Dn = $Dd" in 429def VSUBD : ADbI<0b11100, 0b11, 1, 0, 430 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm), 431 IIC_fpALU64, "vsub", ".f64\t$Dd, $Dn, $Dm", 432 [(set DPR:$Dd, (fsub DPR:$Dn, (f64 DPR:$Dm)))]>, 433 Sched<[WriteFPALU64]>; 434 435let TwoOperandAliasConstraint = "$Sn = $Sd" in 436def VSUBS : ASbIn<0b11100, 0b11, 1, 0, 437 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm), 438 IIC_fpALU32, "vsub", ".f32\t$Sd, $Sn, $Sm", 439 [(set SPR:$Sd, (fsub SPR:$Sn, SPR:$Sm))]>, 440 Sched<[WriteFPALU32]>{ 441 // Some single precision VFP instructions may be executed on both NEON and 442 // VFP pipelines on A8. 443 let D = VFPNeonA8Domain; 444} 445 446let TwoOperandAliasConstraint = "$Sn = $Sd" in 447def VSUBH : AHbI<0b11100, 0b11, 1, 0, 448 (outs HPR:$Sd), (ins HPR:$Sn, HPR:$Sm), 449 IIC_fpALU16, "vsub", ".f16\t$Sd, $Sn, $Sm", 450 [(set (f16 HPR:$Sd), (fsub (f16 HPR:$Sn), (f16 HPR:$Sm)))]>, 451 Sched<[WriteFPALU32]>; 452 453let TwoOperandAliasConstraint = "$Dn = $Dd" in 454def VDIVD : ADbI<0b11101, 0b00, 0, 0, 455 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm), 456 IIC_fpDIV64, "vdiv", ".f64\t$Dd, $Dn, $Dm", 457 [(set DPR:$Dd, (fdiv DPR:$Dn, (f64 DPR:$Dm)))]>, 458 Sched<[WriteFPDIV64]>; 459 460let TwoOperandAliasConstraint = "$Sn = $Sd" in 461def VDIVS : ASbI<0b11101, 0b00, 0, 0, 462 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm), 463 IIC_fpDIV32, "vdiv", ".f32\t$Sd, $Sn, $Sm", 464 [(set SPR:$Sd, (fdiv SPR:$Sn, SPR:$Sm))]>, 465 Sched<[WriteFPDIV32]>; 466 467let TwoOperandAliasConstraint = "$Sn = $Sd" in 468def VDIVH : AHbI<0b11101, 0b00, 0, 0, 469 (outs HPR:$Sd), (ins HPR:$Sn, HPR:$Sm), 470 IIC_fpDIV16, "vdiv", ".f16\t$Sd, $Sn, $Sm", 471 [(set (f16 HPR:$Sd), (fdiv (f16 HPR:$Sn), (f16 HPR:$Sm)))]>, 472 Sched<[WriteFPDIV32]>; 473 474let TwoOperandAliasConstraint = "$Dn = $Dd" in 475def VMULD : ADbI<0b11100, 0b10, 0, 0, 476 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm), 477 IIC_fpMUL64, "vmul", ".f64\t$Dd, $Dn, $Dm", 478 [(set DPR:$Dd, (fmul DPR:$Dn, (f64 DPR:$Dm)))]>, 479 Sched<[WriteFPMUL64, ReadFPMUL, ReadFPMUL]>; 480 481let TwoOperandAliasConstraint = "$Sn = $Sd" in 482def VMULS : ASbIn<0b11100, 0b10, 0, 0, 483 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm), 484 IIC_fpMUL32, "vmul", ".f32\t$Sd, $Sn, $Sm", 485 [(set SPR:$Sd, (fmul SPR:$Sn, SPR:$Sm))]>, 486 Sched<[WriteFPMUL32, ReadFPMUL, ReadFPMUL]> { 487 // Some single precision VFP instructions may be executed on both NEON and 488 // VFP pipelines on A8. 489 let D = VFPNeonA8Domain; 490} 491 492let TwoOperandAliasConstraint = "$Sn = $Sd" in 493def VMULH : AHbI<0b11100, 0b10, 0, 0, 494 (outs HPR:$Sd), (ins HPR:$Sn, HPR:$Sm), 495 IIC_fpMUL16, "vmul", ".f16\t$Sd, $Sn, $Sm", 496 [(set (f16 HPR:$Sd), (fmul (f16 HPR:$Sn), (f16 HPR:$Sm)))]>, 497 Sched<[WriteFPMUL32, ReadFPMUL, ReadFPMUL]>; 498 499def VNMULD : ADbI<0b11100, 0b10, 1, 0, 500 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm), 501 IIC_fpMUL64, "vnmul", ".f64\t$Dd, $Dn, $Dm", 502 [(set DPR:$Dd, (fneg (fmul DPR:$Dn, (f64 DPR:$Dm))))]>, 503 Sched<[WriteFPMUL64, ReadFPMUL, ReadFPMUL]>; 504 505def VNMULS : ASbI<0b11100, 0b10, 1, 0, 506 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm), 507 IIC_fpMUL32, "vnmul", ".f32\t$Sd, $Sn, $Sm", 508 [(set SPR:$Sd, (fneg (fmul SPR:$Sn, SPR:$Sm)))]>, 509 Sched<[WriteFPMUL32, ReadFPMUL, ReadFPMUL]> { 510 // Some single precision VFP instructions may be executed on both NEON and 511 // VFP pipelines on A8. 512 let D = VFPNeonA8Domain; 513} 514 515def VNMULH : AHbI<0b11100, 0b10, 1, 0, 516 (outs HPR:$Sd), (ins HPR:$Sn, HPR:$Sm), 517 IIC_fpMUL16, "vnmul", ".f16\t$Sd, $Sn, $Sm", 518 [(set (f16 HPR:$Sd), (fneg (fmul (f16 HPR:$Sn), (f16 HPR:$Sm))))]>, 519 Sched<[WriteFPMUL32, ReadFPMUL, ReadFPMUL]>; 520 521multiclass vsel_inst<string op, bits<2> opc, int CC> { 522 let DecoderNamespace = "VFPV8", PostEncoderMethod = "", 523 Uses = [CPSR], AddedComplexity = 4, isUnpredicable = 1 in { 524 def H : AHbInp<0b11100, opc, 0, 525 (outs HPR:$Sd), (ins HPR:$Sn, HPR:$Sm), 526 NoItinerary, !strconcat("vsel", op, ".f16\t$Sd, $Sn, $Sm"), 527 [(set (f16 HPR:$Sd), (ARMcmov (f16 HPR:$Sm), (f16 HPR:$Sn), CC))]>, 528 Requires<[HasFullFP16]>; 529 530 def S : ASbInp<0b11100, opc, 0, 531 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm), 532 NoItinerary, !strconcat("vsel", op, ".f32\t$Sd, $Sn, $Sm"), 533 [(set SPR:$Sd, (ARMcmov SPR:$Sm, SPR:$Sn, CC))]>, 534 Requires<[HasFPARMv8]>; 535 536 def D : ADbInp<0b11100, opc, 0, 537 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm), 538 NoItinerary, !strconcat("vsel", op, ".f64\t$Dd, $Dn, $Dm"), 539 [(set DPR:$Dd, (ARMcmov (f64 DPR:$Dm), (f64 DPR:$Dn), CC))]>, 540 Requires<[HasFPARMv8, HasDPVFP]>; 541 } 542} 543 544// The CC constants here match ARMCC::CondCodes. 545defm VSELGT : vsel_inst<"gt", 0b11, 12>; 546defm VSELGE : vsel_inst<"ge", 0b10, 10>; 547defm VSELEQ : vsel_inst<"eq", 0b00, 0>; 548defm VSELVS : vsel_inst<"vs", 0b01, 6>; 549 550multiclass vmaxmin_inst<string op, bit opc, SDNode SD> { 551 let DecoderNamespace = "VFPV8", PostEncoderMethod = "", 552 isUnpredicable = 1 in { 553 def H : AHbInp<0b11101, 0b00, opc, 554 (outs HPR:$Sd), (ins HPR:$Sn, HPR:$Sm), 555 NoItinerary, !strconcat(op, ".f16\t$Sd, $Sn, $Sm"), 556 [(set (f16 HPR:$Sd), (SD (f16 HPR:$Sn), (f16 HPR:$Sm)))]>, 557 Requires<[HasFullFP16]>; 558 559 def S : ASbInp<0b11101, 0b00, opc, 560 (outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm), 561 NoItinerary, !strconcat(op, ".f32\t$Sd, $Sn, $Sm"), 562 [(set SPR:$Sd, (SD SPR:$Sn, SPR:$Sm))]>, 563 Requires<[HasFPARMv8]>; 564 565 def D : ADbInp<0b11101, 0b00, opc, 566 (outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm), 567 NoItinerary, !strconcat(op, ".f64\t$Dd, $Dn, $Dm"), 568 [(set DPR:$Dd, (f64 (SD (f64 DPR:$Dn), (f64 DPR:$Dm))))]>, 569 Requires<[HasFPARMv8, HasDPVFP]>; 570 } 571} 572 573defm VFP_VMAXNM : vmaxmin_inst<"vmaxnm", 0, fmaxnum>; 574defm VFP_VMINNM : vmaxmin_inst<"vminnm", 1, fminnum>; 575 576// Match reassociated forms only if not sign dependent rounding. 577def : Pat<(fmul (fneg DPR:$a), (f64 DPR:$b)), 578 (VNMULD DPR:$a, DPR:$b)>, 579 Requires<[NoHonorSignDependentRounding,HasDPVFP]>; 580def : Pat<(fmul (fneg SPR:$a), SPR:$b), 581 (VNMULS SPR:$a, SPR:$b)>, Requires<[NoHonorSignDependentRounding]>; 582 583// These are encoded as unary instructions. 584let Defs = [FPSCR_NZCV] in { 585def VCMPED : ADuI<0b11101, 0b11, 0b0100, 0b11, 0, 586 (outs), (ins DPR:$Dd, DPR:$Dm), 587 IIC_fpCMP64, "vcmpe", ".f64\t$Dd, $Dm", 588 [(arm_cmpfpe DPR:$Dd, (f64 DPR:$Dm))]>; 589 590def VCMPES : ASuI<0b11101, 0b11, 0b0100, 0b11, 0, 591 (outs), (ins SPR:$Sd, SPR:$Sm), 592 IIC_fpCMP32, "vcmpe", ".f32\t$Sd, $Sm", 593 [(arm_cmpfpe SPR:$Sd, SPR:$Sm)]> { 594 // Some single precision VFP instructions may be executed on both NEON and 595 // VFP pipelines on A8. 596 let D = VFPNeonA8Domain; 597} 598 599def VCMPEH : AHuI<0b11101, 0b11, 0b0100, 0b11, 0, 600 (outs), (ins HPR:$Sd, HPR:$Sm), 601 IIC_fpCMP16, "vcmpe", ".f16\t$Sd, $Sm", 602 [(arm_cmpfpe (f16 HPR:$Sd), (f16 HPR:$Sm))]>; 603 604def VCMPD : ADuI<0b11101, 0b11, 0b0100, 0b01, 0, 605 (outs), (ins DPR:$Dd, DPR:$Dm), 606 IIC_fpCMP64, "vcmp", ".f64\t$Dd, $Dm", 607 [(arm_cmpfp DPR:$Dd, (f64 DPR:$Dm))]>; 608 609def VCMPS : ASuI<0b11101, 0b11, 0b0100, 0b01, 0, 610 (outs), (ins SPR:$Sd, SPR:$Sm), 611 IIC_fpCMP32, "vcmp", ".f32\t$Sd, $Sm", 612 [(arm_cmpfp SPR:$Sd, SPR:$Sm)]> { 613 // Some single precision VFP instructions may be executed on both NEON and 614 // VFP pipelines on A8. 615 let D = VFPNeonA8Domain; 616} 617 618def VCMPH : AHuI<0b11101, 0b11, 0b0100, 0b01, 0, 619 (outs), (ins HPR:$Sd, HPR:$Sm), 620 IIC_fpCMP16, "vcmp", ".f16\t$Sd, $Sm", 621 [(arm_cmpfp (f16 HPR:$Sd), (f16 HPR:$Sm))]>; 622} // Defs = [FPSCR_NZCV] 623 624//===----------------------------------------------------------------------===// 625// FP Unary Operations. 626// 627 628def VABSD : ADuI<0b11101, 0b11, 0b0000, 0b11, 0, 629 (outs DPR:$Dd), (ins DPR:$Dm), 630 IIC_fpUNA64, "vabs", ".f64\t$Dd, $Dm", 631 [(set DPR:$Dd, (fabs (f64 DPR:$Dm)))]>; 632 633def VABSS : ASuIn<0b11101, 0b11, 0b0000, 0b11, 0, 634 (outs SPR:$Sd), (ins SPR:$Sm), 635 IIC_fpUNA32, "vabs", ".f32\t$Sd, $Sm", 636 [(set SPR:$Sd, (fabs SPR:$Sm))]> { 637 // Some single precision VFP instructions may be executed on both NEON and 638 // VFP pipelines on A8. 639 let D = VFPNeonA8Domain; 640} 641 642def VABSH : AHuI<0b11101, 0b11, 0b0000, 0b11, 0, 643 (outs HPR:$Sd), (ins HPR:$Sm), 644 IIC_fpUNA16, "vabs", ".f16\t$Sd, $Sm", 645 [(set (f16 HPR:$Sd), (fabs (f16 HPR:$Sm)))]>; 646 647let Defs = [FPSCR_NZCV] in { 648def VCMPEZD : ADuI<0b11101, 0b11, 0b0101, 0b11, 0, 649 (outs), (ins DPR:$Dd), 650 IIC_fpCMP64, "vcmpe", ".f64\t$Dd, #0", 651 [(arm_cmpfpe0 (f64 DPR:$Dd))]> { 652 let Inst{3-0} = 0b0000; 653 let Inst{5} = 0; 654} 655 656def VCMPEZS : ASuI<0b11101, 0b11, 0b0101, 0b11, 0, 657 (outs), (ins SPR:$Sd), 658 IIC_fpCMP32, "vcmpe", ".f32\t$Sd, #0", 659 [(arm_cmpfpe0 SPR:$Sd)]> { 660 let Inst{3-0} = 0b0000; 661 let Inst{5} = 0; 662 663 // Some single precision VFP instructions may be executed on both NEON and 664 // VFP pipelines on A8. 665 let D = VFPNeonA8Domain; 666} 667 668def VCMPEZH : AHuI<0b11101, 0b11, 0b0101, 0b11, 0, 669 (outs), (ins HPR:$Sd), 670 IIC_fpCMP16, "vcmpe", ".f16\t$Sd, #0", 671 [(arm_cmpfpe0 (f16 HPR:$Sd))]> { 672 let Inst{3-0} = 0b0000; 673 let Inst{5} = 0; 674} 675 676def VCMPZD : ADuI<0b11101, 0b11, 0b0101, 0b01, 0, 677 (outs), (ins DPR:$Dd), 678 IIC_fpCMP64, "vcmp", ".f64\t$Dd, #0", 679 [(arm_cmpfp0 (f64 DPR:$Dd))]> { 680 let Inst{3-0} = 0b0000; 681 let Inst{5} = 0; 682} 683 684def VCMPZS : ASuI<0b11101, 0b11, 0b0101, 0b01, 0, 685 (outs), (ins SPR:$Sd), 686 IIC_fpCMP32, "vcmp", ".f32\t$Sd, #0", 687 [(arm_cmpfp0 SPR:$Sd)]> { 688 let Inst{3-0} = 0b0000; 689 let Inst{5} = 0; 690 691 // Some single precision VFP instructions may be executed on both NEON and 692 // VFP pipelines on A8. 693 let D = VFPNeonA8Domain; 694} 695 696def VCMPZH : AHuI<0b11101, 0b11, 0b0101, 0b01, 0, 697 (outs), (ins HPR:$Sd), 698 IIC_fpCMP16, "vcmp", ".f16\t$Sd, #0", 699 [(arm_cmpfp0 (f16 HPR:$Sd))]> { 700 let Inst{3-0} = 0b0000; 701 let Inst{5} = 0; 702} 703} // Defs = [FPSCR_NZCV] 704 705def VCVTDS : ASuI<0b11101, 0b11, 0b0111, 0b11, 0, 706 (outs DPR:$Dd), (ins SPR:$Sm), 707 IIC_fpCVTDS, "vcvt", ".f64.f32\t$Dd, $Sm", 708 [(set DPR:$Dd, (fpextend SPR:$Sm))]>, 709 Sched<[WriteFPCVT]> { 710 // Instruction operands. 711 bits<5> Dd; 712 bits<5> Sm; 713 714 // Encode instruction operands. 715 let Inst{3-0} = Sm{4-1}; 716 let Inst{5} = Sm{0}; 717 let Inst{15-12} = Dd{3-0}; 718 let Inst{22} = Dd{4}; 719 720 let Predicates = [HasVFP2, HasDPVFP]; 721 let hasSideEffects = 0; 722} 723 724// Special case encoding: bits 11-8 is 0b1011. 725def VCVTSD : VFPAI<(outs SPR:$Sd), (ins DPR:$Dm), VFPUnaryFrm, 726 IIC_fpCVTSD, "vcvt", ".f32.f64\t$Sd, $Dm", 727 [(set SPR:$Sd, (fpround DPR:$Dm))]>, 728 Sched<[WriteFPCVT]> { 729 // Instruction operands. 730 bits<5> Sd; 731 bits<5> Dm; 732 733 // Encode instruction operands. 734 let Inst{3-0} = Dm{3-0}; 735 let Inst{5} = Dm{4}; 736 let Inst{15-12} = Sd{4-1}; 737 let Inst{22} = Sd{0}; 738 739 let Inst{27-23} = 0b11101; 740 let Inst{21-16} = 0b110111; 741 let Inst{11-8} = 0b1011; 742 let Inst{7-6} = 0b11; 743 let Inst{4} = 0; 744 745 let Predicates = [HasVFP2, HasDPVFP]; 746 let hasSideEffects = 0; 747} 748 749// Between half, single and double-precision. 750let hasSideEffects = 0 in 751def VCVTBHS: ASuI<0b11101, 0b11, 0b0010, 0b01, 0, (outs SPR:$Sd), (ins SPR:$Sm), 752 /* FIXME */ IIC_fpCVTSH, "vcvtb", ".f32.f16\t$Sd, $Sm", 753 [/* Intentionally left blank, see patterns below */]>, 754 Requires<[HasFP16]>, 755 Sched<[WriteFPCVT]>; 756 757def : FP16Pat<(f32 (fpextend (f16 HPR:$Sm))), 758 (VCVTBHS (COPY_TO_REGCLASS (f16 HPR:$Sm), SPR))>; 759def : FP16Pat<(f16_to_fp GPR:$a), 760 (VCVTBHS (COPY_TO_REGCLASS GPR:$a, SPR))>; 761 762let hasSideEffects = 0 in 763def VCVTBSH: ASuI<0b11101, 0b11, 0b0011, 0b01, 0, (outs SPR:$Sd), (ins SPR:$Sm), 764 /* FIXME */ IIC_fpCVTHS, "vcvtb", ".f16.f32\t$Sd, $Sm", 765 [/* Intentionally left blank, see patterns below */]>, 766 Requires<[HasFP16]>, 767 Sched<[WriteFPCVT]>; 768 769def : FP16Pat<(f16 (fpround SPR:$Sm)), 770 (COPY_TO_REGCLASS (VCVTBSH SPR:$Sm), HPR)>; 771def : FP16Pat<(fp_to_f16 SPR:$a), 772 (i32 (COPY_TO_REGCLASS (VCVTBSH SPR:$a), GPR))>; 773def : FP16Pat<(insertelt (v8f16 MQPR:$src1), (f16 (fpround (f32 SPR:$src2))), imm_even:$lane), 774 (v8f16 (INSERT_SUBREG (v8f16 MQPR:$src1), (VCVTBSH SPR:$src2), 775 (SSubReg_f16_reg imm:$lane)))>; 776def : FP16Pat<(insertelt (v4f16 DPR:$src1), (f16 (fpround (f32 SPR:$src2))), imm_even:$lane), 777 (v4f16 (INSERT_SUBREG (v4f16 DPR:$src1), (VCVTBSH SPR:$src2), 778 (SSubReg_f16_reg imm:$lane)))>; 779 780let hasSideEffects = 0 in 781def VCVTTHS: ASuI<0b11101, 0b11, 0b0010, 0b11, 0, (outs SPR:$Sd), (ins SPR:$Sm), 782 /* FIXME */ IIC_fpCVTSH, "vcvtt", ".f32.f16\t$Sd, $Sm", 783 [/* Intentionally left blank, see patterns below */]>, 784 Requires<[HasFP16]>, 785 Sched<[WriteFPCVT]>; 786 787def : FP16Pat<(f32 (fpextend (extractelt (v8f16 MQPR:$src), imm_odd:$lane))), 788 (VCVTTHS (EXTRACT_SUBREG MQPR:$src, (SSubReg_f16_reg imm_odd:$lane)))>; 789def : FP16Pat<(f32 (fpextend (extractelt (v4f16 DPR:$src), imm_odd:$lane))), 790 (VCVTTHS (EXTRACT_SUBREG 791 (v2f32 (COPY_TO_REGCLASS (v4f16 DPR:$src), DPR_VFP2)), 792 (SSubReg_f16_reg imm_odd:$lane)))>; 793 794let hasSideEffects = 0 in 795def VCVTTSH: ASuI<0b11101, 0b11, 0b0011, 0b11, 0, (outs SPR:$Sd), (ins SPR:$Sm), 796 /* FIXME */ IIC_fpCVTHS, "vcvtt", ".f16.f32\t$Sd, $Sm", 797 [/* Intentionally left blank, see patterns below */]>, 798 Requires<[HasFP16]>, 799 Sched<[WriteFPCVT]>; 800 801def : FP16Pat<(insertelt (v8f16 MQPR:$src1), (f16 (fpround (f32 SPR:$src2))), imm_odd:$lane), 802 (v8f16 (INSERT_SUBREG (v8f16 MQPR:$src1), (VCVTTSH SPR:$src2), 803 (SSubReg_f16_reg imm:$lane)))>; 804def : FP16Pat<(insertelt (v4f16 DPR:$src1), (f16 (fpround (f32 SPR:$src2))), imm_odd:$lane), 805 (v4f16 (INSERT_SUBREG (v4f16 DPR:$src1), (VCVTTSH SPR:$src2), 806 (SSubReg_f16_reg imm:$lane)))>; 807 808def VCVTBHD : ADuI<0b11101, 0b11, 0b0010, 0b01, 0, 809 (outs DPR:$Dd), (ins SPR:$Sm), 810 NoItinerary, "vcvtb", ".f64.f16\t$Dd, $Sm", 811 [/* Intentionally left blank, see patterns below */]>, 812 Requires<[HasFPARMv8, HasDPVFP]>, 813 Sched<[WriteFPCVT]> { 814 // Instruction operands. 815 bits<5> Sm; 816 817 // Encode instruction operands. 818 let Inst{3-0} = Sm{4-1}; 819 let Inst{5} = Sm{0}; 820 821 let hasSideEffects = 0; 822} 823 824def : FullFP16Pat<(f64 (fpextend (f16 HPR:$Sm))), 825 (VCVTBHD (COPY_TO_REGCLASS (f16 HPR:$Sm), SPR))>, 826 Requires<[HasFPARMv8, HasDPVFP]>; 827def : FP16Pat<(f64 (f16_to_fp GPR:$a)), 828 (VCVTBHD (COPY_TO_REGCLASS GPR:$a, SPR))>, 829 Requires<[HasFPARMv8, HasDPVFP]>; 830 831def VCVTBDH : ADuI<0b11101, 0b11, 0b0011, 0b01, 0, 832 (outs SPR:$Sd), (ins DPR:$Dm), 833 NoItinerary, "vcvtb", ".f16.f64\t$Sd, $Dm", 834 [/* Intentionally left blank, see patterns below */]>, 835 Requires<[HasFPARMv8, HasDPVFP]> { 836 // Instruction operands. 837 bits<5> Sd; 838 bits<5> Dm; 839 840 // Encode instruction operands. 841 let Inst{3-0} = Dm{3-0}; 842 let Inst{5} = Dm{4}; 843 let Inst{15-12} = Sd{4-1}; 844 let Inst{22} = Sd{0}; 845 846 let hasSideEffects = 0; 847} 848 849def : FullFP16Pat<(f16 (fpround DPR:$Dm)), 850 (COPY_TO_REGCLASS (VCVTBDH DPR:$Dm), HPR)>, 851 Requires<[HasFPARMv8, HasDPVFP]>; 852def : FP16Pat<(fp_to_f16 (f64 DPR:$a)), 853 (i32 (COPY_TO_REGCLASS (VCVTBDH DPR:$a), GPR))>, 854 Requires<[HasFPARMv8, HasDPVFP]>; 855 856def VCVTTHD : ADuI<0b11101, 0b11, 0b0010, 0b11, 0, 857 (outs DPR:$Dd), (ins SPR:$Sm), 858 NoItinerary, "vcvtt", ".f64.f16\t$Dd, $Sm", 859 []>, Requires<[HasFPARMv8, HasDPVFP]> { 860 // Instruction operands. 861 bits<5> Sm; 862 863 // Encode instruction operands. 864 let Inst{3-0} = Sm{4-1}; 865 let Inst{5} = Sm{0}; 866 867 let hasSideEffects = 0; 868} 869 870def VCVTTDH : ADuI<0b11101, 0b11, 0b0011, 0b11, 0, 871 (outs SPR:$Sd), (ins DPR:$Dm), 872 NoItinerary, "vcvtt", ".f16.f64\t$Sd, $Dm", 873 []>, Requires<[HasFPARMv8, HasDPVFP]> { 874 // Instruction operands. 875 bits<5> Sd; 876 bits<5> Dm; 877 878 // Encode instruction operands. 879 let Inst{15-12} = Sd{4-1}; 880 let Inst{22} = Sd{0}; 881 let Inst{3-0} = Dm{3-0}; 882 let Inst{5} = Dm{4}; 883 884 let hasSideEffects = 0; 885} 886 887multiclass vcvt_inst<string opc, bits<2> rm, 888 SDPatternOperator node = null_frag> { 889 let PostEncoderMethod = "", DecoderNamespace = "VFPV8", hasSideEffects = 0 in { 890 def SH : AHuInp<0b11101, 0b11, 0b1100, 0b11, 0, 891 (outs SPR:$Sd), (ins HPR:$Sm), 892 NoItinerary, !strconcat("vcvt", opc, ".s32.f16\t$Sd, $Sm"), 893 []>, 894 Requires<[HasFullFP16]> { 895 let Inst{17-16} = rm; 896 } 897 898 def UH : AHuInp<0b11101, 0b11, 0b1100, 0b01, 0, 899 (outs SPR:$Sd), (ins HPR:$Sm), 900 NoItinerary, !strconcat("vcvt", opc, ".u32.f16\t$Sd, $Sm"), 901 []>, 902 Requires<[HasFullFP16]> { 903 let Inst{17-16} = rm; 904 } 905 906 def SS : ASuInp<0b11101, 0b11, 0b1100, 0b11, 0, 907 (outs SPR:$Sd), (ins SPR:$Sm), 908 NoItinerary, !strconcat("vcvt", opc, ".s32.f32\t$Sd, $Sm"), 909 []>, 910 Requires<[HasFPARMv8]> { 911 let Inst{17-16} = rm; 912 } 913 914 def US : ASuInp<0b11101, 0b11, 0b1100, 0b01, 0, 915 (outs SPR:$Sd), (ins SPR:$Sm), 916 NoItinerary, !strconcat("vcvt", opc, ".u32.f32\t$Sd, $Sm"), 917 []>, 918 Requires<[HasFPARMv8]> { 919 let Inst{17-16} = rm; 920 } 921 922 def SD : ASuInp<0b11101, 0b11, 0b1100, 0b11, 0, 923 (outs SPR:$Sd), (ins DPR:$Dm), 924 NoItinerary, !strconcat("vcvt", opc, ".s32.f64\t$Sd, $Dm"), 925 []>, 926 Requires<[HasFPARMv8, HasDPVFP]> { 927 bits<5> Dm; 928 929 let Inst{17-16} = rm; 930 931 // Encode instruction operands. 932 let Inst{3-0} = Dm{3-0}; 933 let Inst{5} = Dm{4}; 934 let Inst{8} = 1; 935 } 936 937 def UD : ASuInp<0b11101, 0b11, 0b1100, 0b01, 0, 938 (outs SPR:$Sd), (ins DPR:$Dm), 939 NoItinerary, !strconcat("vcvt", opc, ".u32.f64\t$Sd, $Dm"), 940 []>, 941 Requires<[HasFPARMv8, HasDPVFP]> { 942 bits<5> Dm; 943 944 let Inst{17-16} = rm; 945 946 // Encode instruction operands 947 let Inst{3-0} = Dm{3-0}; 948 let Inst{5} = Dm{4}; 949 let Inst{8} = 1; 950 } 951 } 952 953 let Predicates = [HasFPARMv8] in { 954 let Predicates = [HasFullFP16] in { 955 def : Pat<(i32 (fp_to_sint (node (f16 HPR:$a)))), 956 (COPY_TO_REGCLASS 957 (!cast<Instruction>(NAME#"SH") (f16 HPR:$a)), 958 GPR)>; 959 960 def : Pat<(i32 (fp_to_uint (node (f16 HPR:$a)))), 961 (COPY_TO_REGCLASS 962 (!cast<Instruction>(NAME#"UH") (f16 HPR:$a)), 963 GPR)>; 964 } 965 def : Pat<(i32 (fp_to_sint (node SPR:$a))), 966 (COPY_TO_REGCLASS 967 (!cast<Instruction>(NAME#"SS") SPR:$a), 968 GPR)>; 969 def : Pat<(i32 (fp_to_uint (node SPR:$a))), 970 (COPY_TO_REGCLASS 971 (!cast<Instruction>(NAME#"US") SPR:$a), 972 GPR)>; 973 } 974 let Predicates = [HasFPARMv8, HasDPVFP] in { 975 def : Pat<(i32 (fp_to_sint (node (f64 DPR:$a)))), 976 (COPY_TO_REGCLASS 977 (!cast<Instruction>(NAME#"SD") DPR:$a), 978 GPR)>; 979 def : Pat<(i32 (fp_to_uint (node (f64 DPR:$a)))), 980 (COPY_TO_REGCLASS 981 (!cast<Instruction>(NAME#"UD") DPR:$a), 982 GPR)>; 983 } 984} 985 986defm VCVTA : vcvt_inst<"a", 0b00, fround>; 987defm VCVTN : vcvt_inst<"n", 0b01>; 988defm VCVTP : vcvt_inst<"p", 0b10, fceil>; 989defm VCVTM : vcvt_inst<"m", 0b11, ffloor>; 990 991def VNEGD : ADuI<0b11101, 0b11, 0b0001, 0b01, 0, 992 (outs DPR:$Dd), (ins DPR:$Dm), 993 IIC_fpUNA64, "vneg", ".f64\t$Dd, $Dm", 994 [(set DPR:$Dd, (fneg (f64 DPR:$Dm)))]>; 995 996def VNEGS : ASuIn<0b11101, 0b11, 0b0001, 0b01, 0, 997 (outs SPR:$Sd), (ins SPR:$Sm), 998 IIC_fpUNA32, "vneg", ".f32\t$Sd, $Sm", 999 [(set SPR:$Sd, (fneg SPR:$Sm))]> { 1000 // Some single precision VFP instructions may be executed on both NEON and 1001 // VFP pipelines on A8. 1002 let D = VFPNeonA8Domain; 1003} 1004 1005def VNEGH : AHuI<0b11101, 0b11, 0b0001, 0b01, 0, 1006 (outs HPR:$Sd), (ins HPR:$Sm), 1007 IIC_fpUNA16, "vneg", ".f16\t$Sd, $Sm", 1008 [(set (f16 HPR:$Sd), (fneg (f16 HPR:$Sm)))]>; 1009 1010multiclass vrint_inst_zrx<string opc, bit op, bit op2, SDPatternOperator node> { 1011 def H : AHuI<0b11101, 0b11, 0b0110, 0b11, 0, 1012 (outs HPR:$Sd), (ins HPR:$Sm), 1013 NoItinerary, !strconcat("vrint", opc), ".f16\t$Sd, $Sm", 1014 [(set (f16 HPR:$Sd), (node (f16 HPR:$Sm)))]>, 1015 Requires<[HasFullFP16]> { 1016 let Inst{7} = op2; 1017 let Inst{16} = op; 1018 } 1019 1020 def S : ASuI<0b11101, 0b11, 0b0110, 0b11, 0, 1021 (outs SPR:$Sd), (ins SPR:$Sm), 1022 NoItinerary, !strconcat("vrint", opc), ".f32\t$Sd, $Sm", 1023 [(set (f32 SPR:$Sd), (node (f32 SPR:$Sm)))]>, 1024 Requires<[HasFPARMv8]> { 1025 let Inst{7} = op2; 1026 let Inst{16} = op; 1027 } 1028 def D : ADuI<0b11101, 0b11, 0b0110, 0b11, 0, 1029 (outs DPR:$Dd), (ins DPR:$Dm), 1030 NoItinerary, !strconcat("vrint", opc), ".f64\t$Dd, $Dm", 1031 [(set (f64 DPR:$Dd), (node (f64 DPR:$Dm)))]>, 1032 Requires<[HasFPARMv8, HasDPVFP]> { 1033 let Inst{7} = op2; 1034 let Inst{16} = op; 1035 } 1036 1037 def : InstAlias<!strconcat("vrint", opc, "$p.f16.f16\t$Sd, $Sm"), 1038 (!cast<Instruction>(NAME#"H") SPR:$Sd, SPR:$Sm, pred:$p), 0>, 1039 Requires<[HasFullFP16]>; 1040 def : InstAlias<!strconcat("vrint", opc, "$p.f32.f32\t$Sd, $Sm"), 1041 (!cast<Instruction>(NAME#"S") SPR:$Sd, SPR:$Sm, pred:$p), 0>, 1042 Requires<[HasFPARMv8]>; 1043 def : InstAlias<!strconcat("vrint", opc, "$p.f64.f64\t$Dd, $Dm"), 1044 (!cast<Instruction>(NAME#"D") DPR:$Dd, DPR:$Dm, pred:$p), 0>, 1045 Requires<[HasFPARMv8,HasDPVFP]>; 1046} 1047 1048defm VRINTZ : vrint_inst_zrx<"z", 0, 1, ftrunc>; 1049defm VRINTR : vrint_inst_zrx<"r", 0, 0, fnearbyint>; 1050defm VRINTX : vrint_inst_zrx<"x", 1, 0, frint>; 1051 1052multiclass vrint_inst_anpm<string opc, bits<2> rm, 1053 SDPatternOperator node = null_frag> { 1054 let PostEncoderMethod = "", DecoderNamespace = "VFPV8", 1055 isUnpredicable = 1 in { 1056 def H : AHuInp<0b11101, 0b11, 0b1000, 0b01, 0, 1057 (outs HPR:$Sd), (ins HPR:$Sm), 1058 NoItinerary, !strconcat("vrint", opc, ".f16\t$Sd, $Sm"), 1059 [(set (f16 HPR:$Sd), (node (f16 HPR:$Sm)))]>, 1060 Requires<[HasFullFP16]> { 1061 let Inst{17-16} = rm; 1062 } 1063 def S : ASuInp<0b11101, 0b11, 0b1000, 0b01, 0, 1064 (outs SPR:$Sd), (ins SPR:$Sm), 1065 NoItinerary, !strconcat("vrint", opc, ".f32\t$Sd, $Sm"), 1066 [(set (f32 SPR:$Sd), (node (f32 SPR:$Sm)))]>, 1067 Requires<[HasFPARMv8]> { 1068 let Inst{17-16} = rm; 1069 } 1070 def D : ADuInp<0b11101, 0b11, 0b1000, 0b01, 0, 1071 (outs DPR:$Dd), (ins DPR:$Dm), 1072 NoItinerary, !strconcat("vrint", opc, ".f64\t$Dd, $Dm"), 1073 [(set (f64 DPR:$Dd), (node (f64 DPR:$Dm)))]>, 1074 Requires<[HasFPARMv8, HasDPVFP]> { 1075 let Inst{17-16} = rm; 1076 } 1077 } 1078 1079 def : InstAlias<!strconcat("vrint", opc, ".f32.f32\t$Sd, $Sm"), 1080 (!cast<Instruction>(NAME#"S") SPR:$Sd, SPR:$Sm), 0>, 1081 Requires<[HasFPARMv8]>; 1082 def : InstAlias<!strconcat("vrint", opc, ".f64.f64\t$Dd, $Dm"), 1083 (!cast<Instruction>(NAME#"D") DPR:$Dd, DPR:$Dm), 0>, 1084 Requires<[HasFPARMv8,HasDPVFP]>; 1085} 1086 1087defm VRINTA : vrint_inst_anpm<"a", 0b00, fround>; 1088defm VRINTN : vrint_inst_anpm<"n", 0b01, int_arm_neon_vrintn>; 1089defm VRINTP : vrint_inst_anpm<"p", 0b10, fceil>; 1090defm VRINTM : vrint_inst_anpm<"m", 0b11, ffloor>; 1091 1092def VSQRTD : ADuI<0b11101, 0b11, 0b0001, 0b11, 0, 1093 (outs DPR:$Dd), (ins DPR:$Dm), 1094 IIC_fpSQRT64, "vsqrt", ".f64\t$Dd, $Dm", 1095 [(set DPR:$Dd, (fsqrt (f64 DPR:$Dm)))]>, 1096 Sched<[WriteFPSQRT64]>; 1097 1098def VSQRTS : ASuI<0b11101, 0b11, 0b0001, 0b11, 0, 1099 (outs SPR:$Sd), (ins SPR:$Sm), 1100 IIC_fpSQRT32, "vsqrt", ".f32\t$Sd, $Sm", 1101 [(set SPR:$Sd, (fsqrt SPR:$Sm))]>, 1102 Sched<[WriteFPSQRT32]>; 1103 1104def VSQRTH : AHuI<0b11101, 0b11, 0b0001, 0b11, 0, 1105 (outs HPR:$Sd), (ins HPR:$Sm), 1106 IIC_fpSQRT16, "vsqrt", ".f16\t$Sd, $Sm", 1107 [(set (f16 HPR:$Sd), (fsqrt (f16 HPR:$Sm)))]>; 1108 1109let hasSideEffects = 0 in { 1110let isMoveReg = 1 in { 1111def VMOVD : ADuI<0b11101, 0b11, 0b0000, 0b01, 0, 1112 (outs DPR:$Dd), (ins DPR:$Dm), 1113 IIC_fpUNA64, "vmov", ".f64\t$Dd, $Dm", []>, 1114 Requires<[HasFPRegs64]>; 1115 1116def VMOVS : ASuI<0b11101, 0b11, 0b0000, 0b01, 0, 1117 (outs SPR:$Sd), (ins SPR:$Sm), 1118 IIC_fpUNA32, "vmov", ".f32\t$Sd, $Sm", []>, 1119 Requires<[HasFPRegs]>; 1120} // isMoveReg 1121 1122let PostEncoderMethod = "", DecoderNamespace = "VFPV8", isUnpredicable = 1 in { 1123def VMOVH : ASuInp<0b11101, 0b11, 0b0000, 0b01, 0, 1124 (outs SPR:$Sd), (ins SPR:$Sm), 1125 IIC_fpUNA16, "vmovx.f16\t$Sd, $Sm", []>, 1126 Requires<[HasFullFP16]>; 1127 1128def VINSH : ASuInp<0b11101, 0b11, 0b0000, 0b11, 0, 1129 (outs SPR:$Sd), (ins SPR:$Sda, SPR:$Sm), 1130 IIC_fpUNA16, "vins.f16\t$Sd, $Sm", []>, 1131 Requires<[HasFullFP16]> { 1132 let Constraints = "$Sd = $Sda"; 1133} 1134 1135} // PostEncoderMethod 1136} // hasSideEffects 1137 1138//===----------------------------------------------------------------------===// 1139// FP <-> GPR Copies. Int <-> FP Conversions. 1140// 1141 1142let isMoveReg = 1 in { 1143def VMOVRS : AVConv2I<0b11100001, 0b1010, 1144 (outs GPR:$Rt), (ins SPR:$Sn), 1145 IIC_fpMOVSI, "vmov", "\t$Rt, $Sn", 1146 [(set GPR:$Rt, (bitconvert SPR:$Sn))]>, 1147 Requires<[HasFPRegs]>, 1148 Sched<[WriteFPMOV]> { 1149 // Instruction operands. 1150 bits<4> Rt; 1151 bits<5> Sn; 1152 1153 // Encode instruction operands. 1154 let Inst{19-16} = Sn{4-1}; 1155 let Inst{7} = Sn{0}; 1156 let Inst{15-12} = Rt; 1157 1158 let Inst{6-5} = 0b00; 1159 let Inst{3-0} = 0b0000; 1160 1161 // Some single precision VFP instructions may be executed on both NEON and VFP 1162 // pipelines. 1163 let D = VFPNeonDomain; 1164} 1165 1166// Bitcast i32 -> f32. NEON prefers to use VMOVDRR. 1167def VMOVSR : AVConv4I<0b11100000, 0b1010, 1168 (outs SPR:$Sn), (ins GPR:$Rt), 1169 IIC_fpMOVIS, "vmov", "\t$Sn, $Rt", 1170 [(set SPR:$Sn, (bitconvert GPR:$Rt))]>, 1171 Requires<[HasFPRegs, UseVMOVSR]>, 1172 Sched<[WriteFPMOV]> { 1173 // Instruction operands. 1174 bits<5> Sn; 1175 bits<4> Rt; 1176 1177 // Encode instruction operands. 1178 let Inst{19-16} = Sn{4-1}; 1179 let Inst{7} = Sn{0}; 1180 let Inst{15-12} = Rt; 1181 1182 let Inst{6-5} = 0b00; 1183 let Inst{3-0} = 0b0000; 1184 1185 // Some single precision VFP instructions may be executed on both NEON and VFP 1186 // pipelines. 1187 let D = VFPNeonDomain; 1188} 1189} // isMoveReg 1190def : Pat<(arm_vmovsr GPR:$Rt), (VMOVSR GPR:$Rt)>, Requires<[HasVFP2, UseVMOVSR]>; 1191 1192let hasSideEffects = 0 in { 1193def VMOVRRD : AVConv3I<0b11000101, 0b1011, 1194 (outs GPR:$Rt, GPR:$Rt2), (ins DPR:$Dm), 1195 IIC_fpMOVDI, "vmov", "\t$Rt, $Rt2, $Dm", 1196 [(set GPR:$Rt, GPR:$Rt2, (arm_fmrrd DPR:$Dm))]>, 1197 Requires<[HasFPRegs]>, 1198 Sched<[WriteFPMOV]> { 1199 // Instruction operands. 1200 bits<5> Dm; 1201 bits<4> Rt; 1202 bits<4> Rt2; 1203 1204 // Encode instruction operands. 1205 let Inst{3-0} = Dm{3-0}; 1206 let Inst{5} = Dm{4}; 1207 let Inst{15-12} = Rt; 1208 let Inst{19-16} = Rt2; 1209 1210 let Inst{7-6} = 0b00; 1211 1212 // Some single precision VFP instructions may be executed on both NEON and VFP 1213 // pipelines. 1214 let D = VFPNeonDomain; 1215 1216 // This instruction is equivalent to 1217 // $Rt = EXTRACT_SUBREG $Dm, ssub_0 1218 // $Rt2 = EXTRACT_SUBREG $Dm, ssub_1 1219 let isExtractSubreg = 1; 1220} 1221 1222def VMOVRRS : AVConv3I<0b11000101, 0b1010, 1223 (outs GPR:$Rt, GPR:$Rt2), (ins SPR:$src1, SPR:$src2), 1224 IIC_fpMOVDI, "vmov", "\t$Rt, $Rt2, $src1, $src2", 1225 [/* For disassembly only; pattern left blank */]>, 1226 Requires<[HasFPRegs]>, 1227 Sched<[WriteFPMOV]> { 1228 bits<5> src1; 1229 bits<4> Rt; 1230 bits<4> Rt2; 1231 1232 // Encode instruction operands. 1233 let Inst{3-0} = src1{4-1}; 1234 let Inst{5} = src1{0}; 1235 let Inst{15-12} = Rt; 1236 let Inst{19-16} = Rt2; 1237 1238 let Inst{7-6} = 0b00; 1239 1240 // Some single precision VFP instructions may be executed on both NEON and VFP 1241 // pipelines. 1242 let D = VFPNeonDomain; 1243 let DecoderMethod = "DecodeVMOVRRS"; 1244} 1245} // hasSideEffects 1246 1247// FMDHR: GPR -> SPR 1248// FMDLR: GPR -> SPR 1249 1250def VMOVDRR : AVConv5I<0b11000100, 0b1011, 1251 (outs DPR:$Dm), (ins GPR:$Rt, GPR:$Rt2), 1252 IIC_fpMOVID, "vmov", "\t$Dm, $Rt, $Rt2", 1253 [(set DPR:$Dm, (arm_fmdrr GPR:$Rt, GPR:$Rt2))]>, 1254 Requires<[HasFPRegs]>, 1255 Sched<[WriteFPMOV]> { 1256 // Instruction operands. 1257 bits<5> Dm; 1258 bits<4> Rt; 1259 bits<4> Rt2; 1260 1261 // Encode instruction operands. 1262 let Inst{3-0} = Dm{3-0}; 1263 let Inst{5} = Dm{4}; 1264 let Inst{15-12} = Rt; 1265 let Inst{19-16} = Rt2; 1266 1267 let Inst{7-6} = 0b00; 1268 1269 // Some single precision VFP instructions may be executed on both NEON and VFP 1270 // pipelines. 1271 let D = VFPNeonDomain; 1272 1273 // This instruction is equivalent to 1274 // $Dm = REG_SEQUENCE $Rt, ssub_0, $Rt2, ssub_1 1275 let isRegSequence = 1; 1276} 1277 1278// Hoist an fabs or a fneg of a value coming from integer registers 1279// and do the fabs/fneg on the integer value. This is never a lose 1280// and could enable the conversion to float to be removed completely. 1281def : Pat<(fabs (arm_fmdrr GPR:$Rl, GPR:$Rh)), 1282 (VMOVDRR GPR:$Rl, (BFC GPR:$Rh, (i32 0x7FFFFFFF)))>, 1283 Requires<[IsARM, HasV6T2]>; 1284def : Pat<(fabs (arm_fmdrr GPR:$Rl, GPR:$Rh)), 1285 (VMOVDRR GPR:$Rl, (t2BFC GPR:$Rh, (i32 0x7FFFFFFF)))>, 1286 Requires<[IsThumb2, HasV6T2]>; 1287def : Pat<(fneg (arm_fmdrr GPR:$Rl, GPR:$Rh)), 1288 (VMOVDRR GPR:$Rl, (EORri GPR:$Rh, (i32 0x80000000)))>, 1289 Requires<[IsARM]>; 1290def : Pat<(fneg (arm_fmdrr GPR:$Rl, GPR:$Rh)), 1291 (VMOVDRR GPR:$Rl, (t2EORri GPR:$Rh, (i32 0x80000000)))>, 1292 Requires<[IsThumb2]>; 1293 1294let hasSideEffects = 0 in 1295def VMOVSRR : AVConv5I<0b11000100, 0b1010, 1296 (outs SPR:$dst1, SPR:$dst2), (ins GPR:$src1, GPR:$src2), 1297 IIC_fpMOVID, "vmov", "\t$dst1, $dst2, $src1, $src2", 1298 [/* For disassembly only; pattern left blank */]>, 1299 Requires<[HasFPRegs]>, 1300 Sched<[WriteFPMOV]> { 1301 // Instruction operands. 1302 bits<5> dst1; 1303 bits<4> src1; 1304 bits<4> src2; 1305 1306 // Encode instruction operands. 1307 let Inst{3-0} = dst1{4-1}; 1308 let Inst{5} = dst1{0}; 1309 let Inst{15-12} = src1; 1310 let Inst{19-16} = src2; 1311 1312 let Inst{7-6} = 0b00; 1313 1314 // Some single precision VFP instructions may be executed on both NEON and VFP 1315 // pipelines. 1316 let D = VFPNeonDomain; 1317 1318 let DecoderMethod = "DecodeVMOVSRR"; 1319} 1320 1321// Move H->R, clearing top 16 bits 1322def VMOVRH : AVConv2I<0b11100001, 0b1001, 1323 (outs rGPR:$Rt), (ins HPR:$Sn), 1324 IIC_fpMOVSI, "vmov", ".f16\t$Rt, $Sn", 1325 []>, 1326 Requires<[HasFPRegs16]>, 1327 Sched<[WriteFPMOV]> { 1328 // Instruction operands. 1329 bits<4> Rt; 1330 bits<5> Sn; 1331 1332 // Encode instruction operands. 1333 let Inst{19-16} = Sn{4-1}; 1334 let Inst{7} = Sn{0}; 1335 let Inst{15-12} = Rt; 1336 1337 let Inst{6-5} = 0b00; 1338 let Inst{3-0} = 0b0000; 1339 1340 let isUnpredicable = 1; 1341} 1342 1343// Move R->H, clearing top 16 bits 1344def VMOVHR : AVConv4I<0b11100000, 0b1001, 1345 (outs HPR:$Sn), (ins rGPR:$Rt), 1346 IIC_fpMOVIS, "vmov", ".f16\t$Sn, $Rt", 1347 []>, 1348 Requires<[HasFPRegs16]>, 1349 Sched<[WriteFPMOV]> { 1350 // Instruction operands. 1351 bits<5> Sn; 1352 bits<4> Rt; 1353 1354 // Encode instruction operands. 1355 let Inst{19-16} = Sn{4-1}; 1356 let Inst{7} = Sn{0}; 1357 let Inst{15-12} = Rt; 1358 1359 let Inst{6-5} = 0b00; 1360 let Inst{3-0} = 0b0000; 1361 1362 let isUnpredicable = 1; 1363} 1364 1365def : FPRegs16Pat<(arm_vmovrh (f16 HPR:$Sn)), (VMOVRH (f16 HPR:$Sn))>; 1366def : FPRegs16Pat<(arm_vmovrh (bf16 HPR:$Sn)), (VMOVRH (bf16 HPR:$Sn))>; 1367def : FPRegs16Pat<(f16 (arm_vmovhr rGPR:$Rt)), (VMOVHR rGPR:$Rt)>; 1368def : FPRegs16Pat<(bf16 (arm_vmovhr rGPR:$Rt)), (VMOVHR rGPR:$Rt)>; 1369 1370// FMRDH: SPR -> GPR 1371// FMRDL: SPR -> GPR 1372// FMRRS: SPR -> GPR 1373// FMRX: SPR system reg -> GPR 1374// FMSRR: GPR -> SPR 1375// FMXR: GPR -> VFP system reg 1376 1377 1378// Int -> FP: 1379 1380class AVConv1IDs_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, 1381 bits<4> opcod4, dag oops, dag iops, 1382 InstrItinClass itin, string opc, string asm, 1383 list<dag> pattern> 1384 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm, 1385 pattern> { 1386 // Instruction operands. 1387 bits<5> Dd; 1388 bits<5> Sm; 1389 1390 // Encode instruction operands. 1391 let Inst{3-0} = Sm{4-1}; 1392 let Inst{5} = Sm{0}; 1393 let Inst{15-12} = Dd{3-0}; 1394 let Inst{22} = Dd{4}; 1395 1396 let Predicates = [HasVFP2, HasDPVFP]; 1397 let hasSideEffects = 0; 1398} 1399 1400class AVConv1InSs_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, 1401 bits<4> opcod4, dag oops, dag iops,InstrItinClass itin, 1402 string opc, string asm, list<dag> pattern> 1403 : AVConv1In<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm, 1404 pattern> { 1405 // Instruction operands. 1406 bits<5> Sd; 1407 bits<5> Sm; 1408 1409 // Encode instruction operands. 1410 let Inst{3-0} = Sm{4-1}; 1411 let Inst{5} = Sm{0}; 1412 let Inst{15-12} = Sd{4-1}; 1413 let Inst{22} = Sd{0}; 1414 1415 let hasSideEffects = 0; 1416} 1417 1418class AVConv1IHs_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, 1419 bits<4> opcod4, dag oops, dag iops, 1420 InstrItinClass itin, string opc, string asm, 1421 list<dag> pattern> 1422 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm, 1423 pattern> { 1424 // Instruction operands. 1425 bits<5> Sd; 1426 bits<5> Sm; 1427 1428 // Encode instruction operands. 1429 let Inst{3-0} = Sm{4-1}; 1430 let Inst{5} = Sm{0}; 1431 let Inst{15-12} = Sd{4-1}; 1432 let Inst{22} = Sd{0}; 1433 1434 let Predicates = [HasFullFP16]; 1435 let hasSideEffects = 0; 1436} 1437 1438def VSITOD : AVConv1IDs_Encode<0b11101, 0b11, 0b1000, 0b1011, 1439 (outs DPR:$Dd), (ins SPR:$Sm), 1440 IIC_fpCVTID, "vcvt", ".f64.s32\t$Dd, $Sm", 1441 []>, 1442 Sched<[WriteFPCVT]> { 1443 let Inst{7} = 1; // s32 1444} 1445 1446let Predicates=[HasVFP2, HasDPVFP] in { 1447 def : VFPPat<(f64 (sint_to_fp GPR:$a)), 1448 (VSITOD (COPY_TO_REGCLASS GPR:$a, SPR))>; 1449 1450 def : VFPPat<(f64 (sint_to_fp (i32 (alignedload32 addrmode5:$a)))), 1451 (VSITOD (VLDRS addrmode5:$a))>; 1452} 1453 1454def VSITOS : AVConv1InSs_Encode<0b11101, 0b11, 0b1000, 0b1010, 1455 (outs SPR:$Sd),(ins SPR:$Sm), 1456 IIC_fpCVTIS, "vcvt", ".f32.s32\t$Sd, $Sm", 1457 []>, 1458 Sched<[WriteFPCVT]> { 1459 let Inst{7} = 1; // s32 1460 1461 // Some single precision VFP instructions may be executed on both NEON and 1462 // VFP pipelines on A8. 1463 let D = VFPNeonA8Domain; 1464} 1465 1466def : VFPNoNEONPat<(f32 (sint_to_fp GPR:$a)), 1467 (VSITOS (COPY_TO_REGCLASS GPR:$a, SPR))>; 1468 1469def : VFPNoNEONPat<(f32 (sint_to_fp (i32 (alignedload32 addrmode5:$a)))), 1470 (VSITOS (VLDRS addrmode5:$a))>; 1471 1472def VSITOH : AVConv1IHs_Encode<0b11101, 0b11, 0b1000, 0b1001, 1473 (outs HPR:$Sd), (ins SPR:$Sm), 1474 IIC_fpCVTIH, "vcvt", ".f16.s32\t$Sd, $Sm", 1475 []>, 1476 Sched<[WriteFPCVT]> { 1477 let Inst{7} = 1; // s32 1478 let isUnpredicable = 1; 1479} 1480 1481def : VFPNoNEONPat<(f16 (sint_to_fp GPR:$a)), 1482 (VSITOH (COPY_TO_REGCLASS GPR:$a, SPR))>; 1483 1484def VUITOD : AVConv1IDs_Encode<0b11101, 0b11, 0b1000, 0b1011, 1485 (outs DPR:$Dd), (ins SPR:$Sm), 1486 IIC_fpCVTID, "vcvt", ".f64.u32\t$Dd, $Sm", 1487 []>, 1488 Sched<[WriteFPCVT]> { 1489 let Inst{7} = 0; // u32 1490} 1491 1492let Predicates=[HasVFP2, HasDPVFP] in { 1493 def : VFPPat<(f64 (uint_to_fp GPR:$a)), 1494 (VUITOD (COPY_TO_REGCLASS GPR:$a, SPR))>; 1495 1496 def : VFPPat<(f64 (uint_to_fp (i32 (alignedload32 addrmode5:$a)))), 1497 (VUITOD (VLDRS addrmode5:$a))>; 1498} 1499 1500def VUITOS : AVConv1InSs_Encode<0b11101, 0b11, 0b1000, 0b1010, 1501 (outs SPR:$Sd), (ins SPR:$Sm), 1502 IIC_fpCVTIS, "vcvt", ".f32.u32\t$Sd, $Sm", 1503 []>, 1504 Sched<[WriteFPCVT]> { 1505 let Inst{7} = 0; // u32 1506 1507 // Some single precision VFP instructions may be executed on both NEON and 1508 // VFP pipelines on A8. 1509 let D = VFPNeonA8Domain; 1510} 1511 1512def : VFPNoNEONPat<(f32 (uint_to_fp GPR:$a)), 1513 (VUITOS (COPY_TO_REGCLASS GPR:$a, SPR))>; 1514 1515def : VFPNoNEONPat<(f32 (uint_to_fp (i32 (alignedload32 addrmode5:$a)))), 1516 (VUITOS (VLDRS addrmode5:$a))>; 1517 1518def VUITOH : AVConv1IHs_Encode<0b11101, 0b11, 0b1000, 0b1001, 1519 (outs HPR:$Sd), (ins SPR:$Sm), 1520 IIC_fpCVTIH, "vcvt", ".f16.u32\t$Sd, $Sm", 1521 []>, 1522 Sched<[WriteFPCVT]> { 1523 let Inst{7} = 0; // u32 1524 let isUnpredicable = 1; 1525} 1526 1527def : VFPNoNEONPat<(f16 (uint_to_fp GPR:$a)), 1528 (VUITOH (COPY_TO_REGCLASS GPR:$a, SPR))>; 1529 1530// FP -> Int: 1531 1532class AVConv1IsD_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, 1533 bits<4> opcod4, dag oops, dag iops, 1534 InstrItinClass itin, string opc, string asm, 1535 list<dag> pattern> 1536 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm, 1537 pattern> { 1538 // Instruction operands. 1539 bits<5> Sd; 1540 bits<5> Dm; 1541 1542 // Encode instruction operands. 1543 let Inst{3-0} = Dm{3-0}; 1544 let Inst{5} = Dm{4}; 1545 let Inst{15-12} = Sd{4-1}; 1546 let Inst{22} = Sd{0}; 1547 1548 let Predicates = [HasVFP2, HasDPVFP]; 1549 let hasSideEffects = 0; 1550} 1551 1552class AVConv1InsS_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, 1553 bits<4> opcod4, dag oops, dag iops, 1554 InstrItinClass itin, string opc, string asm, 1555 list<dag> pattern> 1556 : AVConv1In<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm, 1557 pattern> { 1558 // Instruction operands. 1559 bits<5> Sd; 1560 bits<5> Sm; 1561 1562 // Encode instruction operands. 1563 let Inst{3-0} = Sm{4-1}; 1564 let Inst{5} = Sm{0}; 1565 let Inst{15-12} = Sd{4-1}; 1566 let Inst{22} = Sd{0}; 1567 1568 let hasSideEffects = 0; 1569} 1570 1571class AVConv1IsH_Encode<bits<5> opcod1, bits<2> opcod2, bits<4> opcod3, 1572 bits<4> opcod4, dag oops, dag iops, 1573 InstrItinClass itin, string opc, string asm, 1574 list<dag> pattern> 1575 : AVConv1I<opcod1, opcod2, opcod3, opcod4, oops, iops, itin, opc, asm, 1576 pattern> { 1577 // Instruction operands. 1578 bits<5> Sd; 1579 bits<5> Sm; 1580 1581 // Encode instruction operands. 1582 let Inst{3-0} = Sm{4-1}; 1583 let Inst{5} = Sm{0}; 1584 let Inst{15-12} = Sd{4-1}; 1585 let Inst{22} = Sd{0}; 1586 1587 let Predicates = [HasFullFP16]; 1588 let hasSideEffects = 0; 1589} 1590 1591// Always set Z bit in the instruction, i.e. "round towards zero" variants. 1592def VTOSIZD : AVConv1IsD_Encode<0b11101, 0b11, 0b1101, 0b1011, 1593 (outs SPR:$Sd), (ins DPR:$Dm), 1594 IIC_fpCVTDI, "vcvt", ".s32.f64\t$Sd, $Dm", 1595 []>, 1596 Sched<[WriteFPCVT]> { 1597 let Inst{7} = 1; // Z bit 1598} 1599 1600let Predicates=[HasVFP2, HasDPVFP] in { 1601 def : VFPPat<(i32 (fp_to_sint (f64 DPR:$a))), 1602 (COPY_TO_REGCLASS (VTOSIZD DPR:$a), GPR)>; 1603 def : VFPPat<(i32 (fp_to_sint_sat (f64 DPR:$a), i32)), 1604 (COPY_TO_REGCLASS (VTOSIZD DPR:$a), GPR)>; 1605 1606 def : VFPPat<(alignedstore32 (i32 (fp_to_sint (f64 DPR:$a))), addrmode5:$ptr), 1607 (VSTRS (VTOSIZD DPR:$a), addrmode5:$ptr)>; 1608 def : VFPPat<(alignedstore32 (i32 (fp_to_sint_sat (f64 DPR:$a), i32)), addrmode5:$ptr), 1609 (VSTRS (VTOSIZD DPR:$a), addrmode5:$ptr)>; 1610} 1611 1612def VTOSIZS : AVConv1InsS_Encode<0b11101, 0b11, 0b1101, 0b1010, 1613 (outs SPR:$Sd), (ins SPR:$Sm), 1614 IIC_fpCVTSI, "vcvt", ".s32.f32\t$Sd, $Sm", 1615 []>, 1616 Sched<[WriteFPCVT]> { 1617 let Inst{7} = 1; // Z bit 1618 1619 // Some single precision VFP instructions may be executed on both NEON and 1620 // VFP pipelines on A8. 1621 let D = VFPNeonA8Domain; 1622} 1623 1624def : VFPNoNEONPat<(i32 (fp_to_sint SPR:$a)), 1625 (COPY_TO_REGCLASS (VTOSIZS SPR:$a), GPR)>; 1626def : VFPPat<(i32 (fp_to_sint_sat SPR:$a, i32)), 1627 (COPY_TO_REGCLASS (VTOSIZS SPR:$a), GPR)>; 1628 1629def : VFPNoNEONPat<(alignedstore32 (i32 (fp_to_sint (f32 SPR:$a))), 1630 addrmode5:$ptr), 1631 (VSTRS (VTOSIZS SPR:$a), addrmode5:$ptr)>; 1632def : VFPPat<(alignedstore32 (i32 (fp_to_sint_sat (f32 SPR:$a), i32)), 1633 addrmode5:$ptr), 1634 (VSTRS (VTOSIZS SPR:$a), addrmode5:$ptr)>; 1635 1636def VTOSIZH : AVConv1IsH_Encode<0b11101, 0b11, 0b1101, 0b1001, 1637 (outs SPR:$Sd), (ins HPR:$Sm), 1638 IIC_fpCVTHI, "vcvt", ".s32.f16\t$Sd, $Sm", 1639 []>, 1640 Sched<[WriteFPCVT]> { 1641 let Inst{7} = 1; // Z bit 1642 let isUnpredicable = 1; 1643} 1644 1645def : VFPNoNEONPat<(i32 (fp_to_sint (f16 HPR:$a))), 1646 (COPY_TO_REGCLASS (VTOSIZH (f16 HPR:$a)), GPR)>; 1647def : VFPPat<(i32 (fp_to_sint_sat (f16 HPR:$a), i32)), 1648 (COPY_TO_REGCLASS (VTOSIZH (f16 HPR:$a)), GPR)>; 1649 1650def VTOUIZD : AVConv1IsD_Encode<0b11101, 0b11, 0b1100, 0b1011, 1651 (outs SPR:$Sd), (ins DPR:$Dm), 1652 IIC_fpCVTDI, "vcvt", ".u32.f64\t$Sd, $Dm", 1653 []>, 1654 Sched<[WriteFPCVT]> { 1655 let Inst{7} = 1; // Z bit 1656} 1657 1658let Predicates=[HasVFP2, HasDPVFP] in { 1659 def : VFPPat<(i32 (fp_to_uint (f64 DPR:$a))), 1660 (COPY_TO_REGCLASS (VTOUIZD DPR:$a), GPR)>; 1661 def : VFPPat<(i32 (fp_to_uint_sat (f64 DPR:$a), i32)), 1662 (COPY_TO_REGCLASS (VTOUIZD DPR:$a), GPR)>; 1663 1664 def : VFPPat<(alignedstore32 (i32 (fp_to_uint (f64 DPR:$a))), addrmode5:$ptr), 1665 (VSTRS (VTOUIZD DPR:$a), addrmode5:$ptr)>; 1666 def : VFPPat<(alignedstore32 (i32 (fp_to_uint_sat (f64 DPR:$a), i32)), addrmode5:$ptr), 1667 (VSTRS (VTOUIZD DPR:$a), addrmode5:$ptr)>; 1668} 1669 1670def VTOUIZS : AVConv1InsS_Encode<0b11101, 0b11, 0b1100, 0b1010, 1671 (outs SPR:$Sd), (ins SPR:$Sm), 1672 IIC_fpCVTSI, "vcvt", ".u32.f32\t$Sd, $Sm", 1673 []>, 1674 Sched<[WriteFPCVT]> { 1675 let Inst{7} = 1; // Z bit 1676 1677 // Some single precision VFP instructions may be executed on both NEON and 1678 // VFP pipelines on A8. 1679 let D = VFPNeonA8Domain; 1680} 1681 1682def : VFPNoNEONPat<(i32 (fp_to_uint SPR:$a)), 1683 (COPY_TO_REGCLASS (VTOUIZS SPR:$a), GPR)>; 1684def : VFPPat<(i32 (fp_to_uint_sat SPR:$a, i32)), 1685 (COPY_TO_REGCLASS (VTOUIZS SPR:$a), GPR)>; 1686 1687def : VFPNoNEONPat<(alignedstore32 (i32 (fp_to_uint (f32 SPR:$a))), 1688 addrmode5:$ptr), 1689 (VSTRS (VTOUIZS SPR:$a), addrmode5:$ptr)>; 1690def : VFPPat<(alignedstore32 (i32 (fp_to_uint_sat (f32 SPR:$a), i32)), 1691 addrmode5:$ptr), 1692 (VSTRS (VTOUIZS SPR:$a), addrmode5:$ptr)>; 1693 1694def VTOUIZH : AVConv1IsH_Encode<0b11101, 0b11, 0b1100, 0b1001, 1695 (outs SPR:$Sd), (ins HPR:$Sm), 1696 IIC_fpCVTHI, "vcvt", ".u32.f16\t$Sd, $Sm", 1697 []>, 1698 Sched<[WriteFPCVT]> { 1699 let Inst{7} = 1; // Z bit 1700 let isUnpredicable = 1; 1701} 1702 1703def : VFPNoNEONPat<(i32 (fp_to_uint (f16 HPR:$a))), 1704 (COPY_TO_REGCLASS (VTOUIZH (f16 HPR:$a)), GPR)>; 1705def : VFPPat<(i32 (fp_to_uint_sat (f16 HPR:$a), i32)), 1706 (COPY_TO_REGCLASS (VTOUIZH (f16 HPR:$a)), GPR)>; 1707 1708// And the Z bit '0' variants, i.e. use the rounding mode specified by FPSCR. 1709let Uses = [FPSCR] in { 1710def VTOSIRD : AVConv1IsD_Encode<0b11101, 0b11, 0b1101, 0b1011, 1711 (outs SPR:$Sd), (ins DPR:$Dm), 1712 IIC_fpCVTDI, "vcvtr", ".s32.f64\t$Sd, $Dm", 1713 [(set SPR:$Sd, (int_arm_vcvtr (f64 DPR:$Dm)))]>, 1714 Sched<[WriteFPCVT]> { 1715 let Inst{7} = 0; // Z bit 1716} 1717 1718def VTOSIRS : AVConv1InsS_Encode<0b11101, 0b11, 0b1101, 0b1010, 1719 (outs SPR:$Sd), (ins SPR:$Sm), 1720 IIC_fpCVTSI, "vcvtr", ".s32.f32\t$Sd, $Sm", 1721 [(set SPR:$Sd, (int_arm_vcvtr SPR:$Sm))]>, 1722 Sched<[WriteFPCVT]> { 1723 let Inst{7} = 0; // Z bit 1724} 1725 1726def VTOSIRH : AVConv1IsH_Encode<0b11101, 0b11, 0b1101, 0b1001, 1727 (outs SPR:$Sd), (ins SPR:$Sm), 1728 IIC_fpCVTHI, "vcvtr", ".s32.f16\t$Sd, $Sm", 1729 []>, 1730 Sched<[WriteFPCVT]> { 1731 let Inst{7} = 0; // Z bit 1732 let isUnpredicable = 1; 1733} 1734 1735def VTOUIRD : AVConv1IsD_Encode<0b11101, 0b11, 0b1100, 0b1011, 1736 (outs SPR:$Sd), (ins DPR:$Dm), 1737 IIC_fpCVTDI, "vcvtr", ".u32.f64\t$Sd, $Dm", 1738 [(set SPR:$Sd, (int_arm_vcvtru(f64 DPR:$Dm)))]>, 1739 Sched<[WriteFPCVT]> { 1740 let Inst{7} = 0; // Z bit 1741} 1742 1743def VTOUIRS : AVConv1InsS_Encode<0b11101, 0b11, 0b1100, 0b1010, 1744 (outs SPR:$Sd), (ins SPR:$Sm), 1745 IIC_fpCVTSI, "vcvtr", ".u32.f32\t$Sd, $Sm", 1746 [(set SPR:$Sd, (int_arm_vcvtru SPR:$Sm))]>, 1747 Sched<[WriteFPCVT]> { 1748 let Inst{7} = 0; // Z bit 1749} 1750 1751def VTOUIRH : AVConv1IsH_Encode<0b11101, 0b11, 0b1100, 0b1001, 1752 (outs SPR:$Sd), (ins SPR:$Sm), 1753 IIC_fpCVTHI, "vcvtr", ".u32.f16\t$Sd, $Sm", 1754 []>, 1755 Sched<[WriteFPCVT]> { 1756 let Inst{7} = 0; // Z bit 1757 let isUnpredicable = 1; 1758} 1759} 1760 1761// v8.3-a Javascript Convert to Signed fixed-point 1762def VJCVT : AVConv1IsD_Encode<0b11101, 0b11, 0b1001, 0b1011, 1763 (outs SPR:$Sd), (ins DPR:$Dm), 1764 IIC_fpCVTDI, "vjcvt", ".s32.f64\t$Sd, $Dm", 1765 []>, 1766 Requires<[HasFPARMv8, HasV8_3a]> { 1767 let Inst{7} = 1; // Z bit 1768} 1769 1770// Convert between floating-point and fixed-point 1771// Data type for fixed-point naming convention: 1772// S16 (U=0, sx=0) -> SH 1773// U16 (U=1, sx=0) -> UH 1774// S32 (U=0, sx=1) -> SL 1775// U32 (U=1, sx=1) -> UL 1776 1777let Constraints = "$a = $dst" in { 1778 1779// FP to Fixed-Point: 1780 1781// Single Precision register 1782class AVConv1XInsS_Encode<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, 1783 bit op5, dag oops, dag iops, InstrItinClass itin, 1784 string opc, string asm, list<dag> pattern> 1785 : AVConv1XI<op1, op2, op3, op4, op5, oops, iops, itin, opc, asm, pattern> { 1786 bits<5> dst; 1787 // if dp_operation then UInt(D:Vd) else UInt(Vd:D); 1788 let Inst{22} = dst{0}; 1789 let Inst{15-12} = dst{4-1}; 1790 1791 let hasSideEffects = 0; 1792} 1793 1794// Double Precision register 1795class AVConv1XInsD_Encode<bits<5> op1, bits<2> op2, bits<4> op3, bits<4> op4, 1796 bit op5, dag oops, dag iops, InstrItinClass itin, 1797 string opc, string asm, list<dag> pattern> 1798 : AVConv1XI<op1, op2, op3, op4, op5, oops, iops, itin, opc, asm, pattern> { 1799 bits<5> dst; 1800 // if dp_operation then UInt(D:Vd) else UInt(Vd:D); 1801 let Inst{22} = dst{4}; 1802 let Inst{15-12} = dst{3-0}; 1803 1804 let hasSideEffects = 0; 1805 let Predicates = [HasVFP2, HasDPVFP]; 1806} 1807 1808let isUnpredicable = 1 in { 1809 1810def VTOSHH : AVConv1XInsS_Encode<0b11101, 0b11, 0b1110, 0b1001, 0, 1811 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits), 1812 IIC_fpCVTHI, "vcvt", ".s16.f16\t$dst, $a, $fbits", []>, 1813 Requires<[HasFullFP16]>, 1814 Sched<[WriteFPCVT]>; 1815 1816def VTOUHH : AVConv1XInsS_Encode<0b11101, 0b11, 0b1111, 0b1001, 0, 1817 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits), 1818 IIC_fpCVTHI, "vcvt", ".u16.f16\t$dst, $a, $fbits", []>, 1819 Requires<[HasFullFP16]>, 1820 Sched<[WriteFPCVT]>; 1821 1822def VTOSLH : AVConv1XInsS_Encode<0b11101, 0b11, 0b1110, 0b1001, 1, 1823 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits), 1824 IIC_fpCVTHI, "vcvt", ".s32.f16\t$dst, $a, $fbits", []>, 1825 Requires<[HasFullFP16]>, 1826 Sched<[WriteFPCVT]>; 1827 1828def VTOULH : AVConv1XInsS_Encode<0b11101, 0b11, 0b1111, 0b1001, 1, 1829 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits), 1830 IIC_fpCVTHI, "vcvt", ".u32.f16\t$dst, $a, $fbits", []>, 1831 Requires<[HasFullFP16]>, 1832 Sched<[WriteFPCVT]>; 1833 1834} // End of 'let isUnpredicable = 1 in' 1835 1836def VTOSHS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1110, 0b1010, 0, 1837 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits), 1838 IIC_fpCVTSI, "vcvt", ".s16.f32\t$dst, $a, $fbits", []>, 1839 Sched<[WriteFPCVT]> { 1840 // Some single precision VFP instructions may be executed on both NEON and 1841 // VFP pipelines on A8. 1842 let D = VFPNeonA8Domain; 1843} 1844 1845def VTOUHS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1111, 0b1010, 0, 1846 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits), 1847 IIC_fpCVTSI, "vcvt", ".u16.f32\t$dst, $a, $fbits", []>, 1848 Sched<[WriteFPCVT]> { 1849 // Some single precision VFP instructions may be executed on both NEON and 1850 // VFP pipelines on A8. 1851 let D = VFPNeonA8Domain; 1852} 1853 1854def VTOSLS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1110, 0b1010, 1, 1855 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits), 1856 IIC_fpCVTSI, "vcvt", ".s32.f32\t$dst, $a, $fbits", []>, 1857 Sched<[WriteFPCVT]> { 1858 // Some single precision VFP instructions may be executed on both NEON and 1859 // VFP pipelines on A8. 1860 let D = VFPNeonA8Domain; 1861} 1862 1863def VTOULS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1111, 0b1010, 1, 1864 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits), 1865 IIC_fpCVTSI, "vcvt", ".u32.f32\t$dst, $a, $fbits", []>, 1866 Sched<[WriteFPCVT]> { 1867 // Some single precision VFP instructions may be executed on both NEON and 1868 // VFP pipelines on A8. 1869 let D = VFPNeonA8Domain; 1870} 1871 1872def VTOSHD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1110, 0b1011, 0, 1873 (outs DPR:$dst), (ins DPR:$a, fbits16:$fbits), 1874 IIC_fpCVTDI, "vcvt", ".s16.f64\t$dst, $a, $fbits", []>, 1875 Sched<[WriteFPCVT]>; 1876 1877def VTOUHD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1111, 0b1011, 0, 1878 (outs DPR:$dst), (ins DPR:$a, fbits16:$fbits), 1879 IIC_fpCVTDI, "vcvt", ".u16.f64\t$dst, $a, $fbits", []>, 1880 Sched<[WriteFPCVT]>; 1881 1882def VTOSLD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1110, 0b1011, 1, 1883 (outs DPR:$dst), (ins DPR:$a, fbits32:$fbits), 1884 IIC_fpCVTDI, "vcvt", ".s32.f64\t$dst, $a, $fbits", []>, 1885 Sched<[WriteFPCVT]>; 1886 1887def VTOULD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1111, 0b1011, 1, 1888 (outs DPR:$dst), (ins DPR:$a, fbits32:$fbits), 1889 IIC_fpCVTDI, "vcvt", ".u32.f64\t$dst, $a, $fbits", []>, 1890 Sched<[WriteFPCVT]>; 1891 1892// Fixed-Point to FP: 1893 1894let isUnpredicable = 1 in { 1895 1896def VSHTOH : AVConv1XInsS_Encode<0b11101, 0b11, 0b1010, 0b1001, 0, 1897 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits), 1898 IIC_fpCVTIH, "vcvt", ".f16.s16\t$dst, $a, $fbits", []>, 1899 Requires<[HasFullFP16]>, 1900 Sched<[WriteFPCVT]>; 1901 1902def VUHTOH : AVConv1XInsS_Encode<0b11101, 0b11, 0b1011, 0b1001, 0, 1903 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits), 1904 IIC_fpCVTIH, "vcvt", ".f16.u16\t$dst, $a, $fbits", []>, 1905 Requires<[HasFullFP16]>, 1906 Sched<[WriteFPCVT]>; 1907 1908def VSLTOH : AVConv1XInsS_Encode<0b11101, 0b11, 0b1010, 0b1001, 1, 1909 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits), 1910 IIC_fpCVTIH, "vcvt", ".f16.s32\t$dst, $a, $fbits", []>, 1911 Requires<[HasFullFP16]>, 1912 Sched<[WriteFPCVT]>; 1913 1914def VULTOH : AVConv1XInsS_Encode<0b11101, 0b11, 0b1011, 0b1001, 1, 1915 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits), 1916 IIC_fpCVTIH, "vcvt", ".f16.u32\t$dst, $a, $fbits", []>, 1917 Requires<[HasFullFP16]>, 1918 Sched<[WriteFPCVT]>; 1919 1920} // End of 'let isUnpredicable = 1 in' 1921 1922def VSHTOS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1010, 0b1010, 0, 1923 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits), 1924 IIC_fpCVTIS, "vcvt", ".f32.s16\t$dst, $a, $fbits", []>, 1925 Sched<[WriteFPCVT]> { 1926 // Some single precision VFP instructions may be executed on both NEON and 1927 // VFP pipelines on A8. 1928 let D = VFPNeonA8Domain; 1929} 1930 1931def VUHTOS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1011, 0b1010, 0, 1932 (outs SPR:$dst), (ins SPR:$a, fbits16:$fbits), 1933 IIC_fpCVTIS, "vcvt", ".f32.u16\t$dst, $a, $fbits", []>, 1934 Sched<[WriteFPCVT]> { 1935 // Some single precision VFP instructions may be executed on both NEON and 1936 // VFP pipelines on A8. 1937 let D = VFPNeonA8Domain; 1938} 1939 1940def VSLTOS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1010, 0b1010, 1, 1941 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits), 1942 IIC_fpCVTIS, "vcvt", ".f32.s32\t$dst, $a, $fbits", []>, 1943 Sched<[WriteFPCVT]> { 1944 // Some single precision VFP instructions may be executed on both NEON and 1945 // VFP pipelines on A8. 1946 let D = VFPNeonA8Domain; 1947} 1948 1949def VULTOS : AVConv1XInsS_Encode<0b11101, 0b11, 0b1011, 0b1010, 1, 1950 (outs SPR:$dst), (ins SPR:$a, fbits32:$fbits), 1951 IIC_fpCVTIS, "vcvt", ".f32.u32\t$dst, $a, $fbits", []>, 1952 Sched<[WriteFPCVT]> { 1953 // Some single precision VFP instructions may be executed on both NEON and 1954 // VFP pipelines on A8. 1955 let D = VFPNeonA8Domain; 1956} 1957 1958def VSHTOD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1010, 0b1011, 0, 1959 (outs DPR:$dst), (ins DPR:$a, fbits16:$fbits), 1960 IIC_fpCVTID, "vcvt", ".f64.s16\t$dst, $a, $fbits", []>, 1961 Sched<[WriteFPCVT]>; 1962 1963def VUHTOD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1011, 0b1011, 0, 1964 (outs DPR:$dst), (ins DPR:$a, fbits16:$fbits), 1965 IIC_fpCVTID, "vcvt", ".f64.u16\t$dst, $a, $fbits", []>, 1966 Sched<[WriteFPCVT]>; 1967 1968def VSLTOD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1010, 0b1011, 1, 1969 (outs DPR:$dst), (ins DPR:$a, fbits32:$fbits), 1970 IIC_fpCVTID, "vcvt", ".f64.s32\t$dst, $a, $fbits", []>, 1971 Sched<[WriteFPCVT]>; 1972 1973def VULTOD : AVConv1XInsD_Encode<0b11101, 0b11, 0b1011, 0b1011, 1, 1974 (outs DPR:$dst), (ins DPR:$a, fbits32:$fbits), 1975 IIC_fpCVTID, "vcvt", ".f64.u32\t$dst, $a, $fbits", []>, 1976 Sched<[WriteFPCVT]>; 1977 1978} // End of 'let Constraints = "$a = $dst" in' 1979 1980// BFloat16 - Single precision, unary, predicated 1981class BF16_VCVT<string opc, bits<2> op7_6> 1982 : VFPAI<(outs SPR:$Sd), (ins SPR:$dst, SPR:$Sm), 1983 VFPUnaryFrm, NoItinerary, 1984 opc, ".bf16.f32\t$Sd, $Sm", []>, 1985 RegConstraint<"$dst = $Sd">, 1986 Requires<[HasBF16]>, 1987 Sched<[]> { 1988 bits<5> Sd; 1989 bits<5> Sm; 1990 1991 // Encode instruction operands. 1992 let Inst{3-0} = Sm{4-1}; 1993 let Inst{5} = Sm{0}; 1994 let Inst{15-12} = Sd{4-1}; 1995 let Inst{22} = Sd{0}; 1996 1997 let Inst{27-23} = 0b11101; // opcode1 1998 let Inst{21-20} = 0b11; // opcode2 1999 let Inst{19-16} = 0b0011; // opcode3 2000 let Inst{11-8} = 0b1001; 2001 let Inst{7-6} = op7_6; 2002 let Inst{4} = 0; 2003 2004 let DecoderNamespace = "VFPV8"; 2005 let hasSideEffects = 0; 2006} 2007 2008def BF16_VCVTB : BF16_VCVT<"vcvtb", 0b01>; 2009def BF16_VCVTT : BF16_VCVT<"vcvtt", 0b11>; 2010 2011//===----------------------------------------------------------------------===// 2012// FP Multiply-Accumulate Operations. 2013// 2014 2015def VMLAD : ADbI<0b11100, 0b00, 0, 0, 2016 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm), 2017 IIC_fpMAC64, "vmla", ".f64\t$Dd, $Dn, $Dm", 2018 [(set DPR:$Dd, (fadd_mlx (fmul_su DPR:$Dn, DPR:$Dm), 2019 (f64 DPR:$Ddin)))]>, 2020 RegConstraint<"$Ddin = $Dd">, 2021 Requires<[HasVFP2,HasDPVFP,UseFPVMLx]>, 2022 Sched<[WriteFPMAC64, ReadFPMAC, ReadFPMUL, ReadFPMUL]>; 2023 2024def VMLAS : ASbIn<0b11100, 0b00, 0, 0, 2025 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm), 2026 IIC_fpMAC32, "vmla", ".f32\t$Sd, $Sn, $Sm", 2027 [(set SPR:$Sd, (fadd_mlx (fmul_su SPR:$Sn, SPR:$Sm), 2028 SPR:$Sdin))]>, 2029 RegConstraint<"$Sdin = $Sd">, 2030 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>, 2031 Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]> { 2032 // Some single precision VFP instructions may be executed on both NEON and 2033 // VFP pipelines on A8. 2034 let D = VFPNeonA8Domain; 2035} 2036 2037def VMLAH : AHbI<0b11100, 0b00, 0, 0, 2038 (outs HPR:$Sd), (ins HPR:$Sdin, HPR:$Sn, HPR:$Sm), 2039 IIC_fpMAC16, "vmla", ".f16\t$Sd, $Sn, $Sm", 2040 [(set (f16 HPR:$Sd), (fadd_mlx (fmul_su (f16 HPR:$Sn), (f16 HPR:$Sm)), 2041 (f16 HPR:$Sdin)))]>, 2042 RegConstraint<"$Sdin = $Sd">, 2043 Requires<[HasFullFP16,UseFPVMLx]>; 2044 2045def : Pat<(fadd_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))), 2046 (VMLAD DPR:$dstin, DPR:$a, DPR:$b)>, 2047 Requires<[HasVFP2,HasDPVFP,UseFPVMLx]>; 2048def : Pat<(fadd_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)), 2049 (VMLAS SPR:$dstin, SPR:$a, SPR:$b)>, 2050 Requires<[HasVFP2,DontUseNEONForFP, UseFPVMLx]>; 2051def : Pat<(fadd_mlx HPR:$dstin, (fmul_su (f16 HPR:$a), HPR:$b)), 2052 (VMLAH HPR:$dstin, (f16 HPR:$a), HPR:$b)>, 2053 Requires<[HasFullFP16,DontUseNEONForFP, UseFPVMLx]>; 2054 2055 2056def VMLSD : ADbI<0b11100, 0b00, 1, 0, 2057 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm), 2058 IIC_fpMAC64, "vmls", ".f64\t$Dd, $Dn, $Dm", 2059 [(set DPR:$Dd, (fadd_mlx (fneg (fmul_su DPR:$Dn,DPR:$Dm)), 2060 (f64 DPR:$Ddin)))]>, 2061 RegConstraint<"$Ddin = $Dd">, 2062 Requires<[HasVFP2,HasDPVFP,UseFPVMLx]>, 2063 Sched<[WriteFPMAC64, ReadFPMAC, ReadFPMUL, ReadFPMUL]>; 2064 2065def VMLSS : ASbIn<0b11100, 0b00, 1, 0, 2066 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm), 2067 IIC_fpMAC32, "vmls", ".f32\t$Sd, $Sn, $Sm", 2068 [(set SPR:$Sd, (fadd_mlx (fneg (fmul_su SPR:$Sn, SPR:$Sm)), 2069 SPR:$Sdin))]>, 2070 RegConstraint<"$Sdin = $Sd">, 2071 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>, 2072 Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]> { 2073 // Some single precision VFP instructions may be executed on both NEON and 2074 // VFP pipelines on A8. 2075 let D = VFPNeonA8Domain; 2076} 2077 2078def VMLSH : AHbI<0b11100, 0b00, 1, 0, 2079 (outs HPR:$Sd), (ins HPR:$Sdin, HPR:$Sn, HPR:$Sm), 2080 IIC_fpMAC16, "vmls", ".f16\t$Sd, $Sn, $Sm", 2081 [(set (f16 HPR:$Sd), (fadd_mlx (fneg (fmul_su (f16 HPR:$Sn), (f16 HPR:$Sm))), 2082 (f16 HPR:$Sdin)))]>, 2083 RegConstraint<"$Sdin = $Sd">, 2084 Requires<[HasFullFP16,UseFPVMLx]>; 2085 2086def : Pat<(fsub_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))), 2087 (VMLSD DPR:$dstin, DPR:$a, DPR:$b)>, 2088 Requires<[HasVFP2,HasDPVFP,UseFPVMLx]>; 2089def : Pat<(fsub_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)), 2090 (VMLSS SPR:$dstin, SPR:$a, SPR:$b)>, 2091 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>; 2092def : Pat<(fsub_mlx HPR:$dstin, (fmul_su (f16 HPR:$a), HPR:$b)), 2093 (VMLSH HPR:$dstin, (f16 HPR:$a), HPR:$b)>, 2094 Requires<[HasFullFP16,DontUseNEONForFP,UseFPVMLx]>; 2095 2096def VNMLAD : ADbI<0b11100, 0b01, 1, 0, 2097 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm), 2098 IIC_fpMAC64, "vnmla", ".f64\t$Dd, $Dn, $Dm", 2099 [(set DPR:$Dd,(fsub_mlx (fneg (fmul_su DPR:$Dn,DPR:$Dm)), 2100 (f64 DPR:$Ddin)))]>, 2101 RegConstraint<"$Ddin = $Dd">, 2102 Requires<[HasVFP2,HasDPVFP,UseFPVMLx]>, 2103 Sched<[WriteFPMAC64, ReadFPMAC, ReadFPMUL, ReadFPMUL]>; 2104 2105def VNMLAS : ASbI<0b11100, 0b01, 1, 0, 2106 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm), 2107 IIC_fpMAC32, "vnmla", ".f32\t$Sd, $Sn, $Sm", 2108 [(set SPR:$Sd, (fsub_mlx (fneg (fmul_su SPR:$Sn, SPR:$Sm)), 2109 SPR:$Sdin))]>, 2110 RegConstraint<"$Sdin = $Sd">, 2111 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>, 2112 Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]> { 2113 // Some single precision VFP instructions may be executed on both NEON and 2114 // VFP pipelines on A8. 2115 let D = VFPNeonA8Domain; 2116} 2117 2118def VNMLAH : AHbI<0b11100, 0b01, 1, 0, 2119 (outs HPR:$Sd), (ins HPR:$Sdin, HPR:$Sn, HPR:$Sm), 2120 IIC_fpMAC16, "vnmla", ".f16\t$Sd, $Sn, $Sm", 2121 [(set (f16 HPR:$Sd), (fsub_mlx (fneg (fmul_su (f16 HPR:$Sn), (f16 HPR:$Sm))), 2122 (f16 HPR:$Sdin)))]>, 2123 RegConstraint<"$Sdin = $Sd">, 2124 Requires<[HasFullFP16,UseFPVMLx]>; 2125 2126// (-(a * b) - dst) -> -(dst + (a * b)) 2127def : Pat<(fsub_mlx (fneg (fmul_su DPR:$a, (f64 DPR:$b))), DPR:$dstin), 2128 (VNMLAD DPR:$dstin, DPR:$a, DPR:$b)>, 2129 Requires<[HasVFP2,HasDPVFP,UseFPVMLx]>; 2130def : Pat<(fsub_mlx (fneg (fmul_su SPR:$a, SPR:$b)), SPR:$dstin), 2131 (VNMLAS SPR:$dstin, SPR:$a, SPR:$b)>, 2132 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>; 2133def : Pat<(fsub_mlx (fneg (fmul_su (f16 HPR:$a), HPR:$b)), HPR:$dstin), 2134 (VNMLAH HPR:$dstin, (f16 HPR:$a), HPR:$b)>, 2135 Requires<[HasFullFP16,DontUseNEONForFP,UseFPVMLx]>; 2136 2137// (-dst - (a * b)) -> -(dst + (a * b)) 2138def : Pat<(fsub_mlx (fneg DPR:$dstin), (fmul_su DPR:$a, (f64 DPR:$b))), 2139 (VNMLAD DPR:$dstin, DPR:$a, DPR:$b)>, 2140 Requires<[HasVFP2,HasDPVFP,UseFPVMLx]>; 2141def : Pat<(fsub_mlx (fneg SPR:$dstin), (fmul_su SPR:$a, SPR:$b)), 2142 (VNMLAS SPR:$dstin, SPR:$a, SPR:$b)>, 2143 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>; 2144def : Pat<(fsub_mlx (fneg HPR:$dstin), (fmul_su (f16 HPR:$a), HPR:$b)), 2145 (VNMLAH HPR:$dstin, (f16 HPR:$a), HPR:$b)>, 2146 Requires<[HasFullFP16,DontUseNEONForFP,UseFPVMLx]>; 2147 2148def VNMLSD : ADbI<0b11100, 0b01, 0, 0, 2149 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm), 2150 IIC_fpMAC64, "vnmls", ".f64\t$Dd, $Dn, $Dm", 2151 [(set DPR:$Dd, (fsub_mlx (fmul_su DPR:$Dn, DPR:$Dm), 2152 (f64 DPR:$Ddin)))]>, 2153 RegConstraint<"$Ddin = $Dd">, 2154 Requires<[HasVFP2,HasDPVFP,UseFPVMLx]>, 2155 Sched<[WriteFPMAC64, ReadFPMAC, ReadFPMUL, ReadFPMUL]>; 2156 2157def VNMLSS : ASbI<0b11100, 0b01, 0, 0, 2158 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm), 2159 IIC_fpMAC32, "vnmls", ".f32\t$Sd, $Sn, $Sm", 2160 [(set SPR:$Sd, (fsub_mlx (fmul_su SPR:$Sn, SPR:$Sm), SPR:$Sdin))]>, 2161 RegConstraint<"$Sdin = $Sd">, 2162 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>, 2163 Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]> { 2164 // Some single precision VFP instructions may be executed on both NEON and 2165 // VFP pipelines on A8. 2166 let D = VFPNeonA8Domain; 2167} 2168 2169def VNMLSH : AHbI<0b11100, 0b01, 0, 0, 2170 (outs HPR:$Sd), (ins HPR:$Sdin, HPR:$Sn, HPR:$Sm), 2171 IIC_fpMAC16, "vnmls", ".f16\t$Sd, $Sn, $Sm", 2172 [(set (f16 HPR:$Sd), (fsub_mlx (fmul_su (f16 HPR:$Sn), (f16 HPR:$Sm)), (f16 HPR:$Sdin)))]>, 2173 RegConstraint<"$Sdin = $Sd">, 2174 Requires<[HasFullFP16,UseFPVMLx]>; 2175 2176def : Pat<(fsub_mlx (fmul_su DPR:$a, (f64 DPR:$b)), DPR:$dstin), 2177 (VNMLSD DPR:$dstin, DPR:$a, DPR:$b)>, 2178 Requires<[HasVFP2,HasDPVFP,UseFPVMLx]>; 2179def : Pat<(fsub_mlx (fmul_su SPR:$a, SPR:$b), SPR:$dstin), 2180 (VNMLSS SPR:$dstin, SPR:$a, SPR:$b)>, 2181 Requires<[HasVFP2,DontUseNEONForFP,UseFPVMLx]>; 2182def : Pat<(fsub_mlx (fmul_su (f16 HPR:$a), HPR:$b), HPR:$dstin), 2183 (VNMLSH HPR:$dstin, (f16 HPR:$a), HPR:$b)>, 2184 Requires<[HasFullFP16,DontUseNEONForFP,UseFPVMLx]>; 2185 2186//===----------------------------------------------------------------------===// 2187// Fused FP Multiply-Accumulate Operations. 2188// 2189def VFMAD : ADbI<0b11101, 0b10, 0, 0, 2190 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm), 2191 IIC_fpFMAC64, "vfma", ".f64\t$Dd, $Dn, $Dm", 2192 [(set DPR:$Dd, (fadd_mlx (fmul_su DPR:$Dn, DPR:$Dm), 2193 (f64 DPR:$Ddin)))]>, 2194 RegConstraint<"$Ddin = $Dd">, 2195 Requires<[HasVFP4,HasDPVFP,UseFusedMAC]>, 2196 Sched<[WriteFPMAC64, ReadFPMAC, ReadFPMUL, ReadFPMUL]>; 2197 2198def VFMAS : ASbIn<0b11101, 0b10, 0, 0, 2199 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm), 2200 IIC_fpFMAC32, "vfma", ".f32\t$Sd, $Sn, $Sm", 2201 [(set SPR:$Sd, (fadd_mlx (fmul_su SPR:$Sn, SPR:$Sm), 2202 SPR:$Sdin))]>, 2203 RegConstraint<"$Sdin = $Sd">, 2204 Requires<[HasVFP4,DontUseNEONForFP,UseFusedMAC]>, 2205 Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]> { 2206 // Some single precision VFP instructions may be executed on both NEON and 2207 // VFP pipelines. 2208} 2209 2210def VFMAH : AHbI<0b11101, 0b10, 0, 0, 2211 (outs HPR:$Sd), (ins HPR:$Sdin, HPR:$Sn, HPR:$Sm), 2212 IIC_fpFMAC16, "vfma", ".f16\t$Sd, $Sn, $Sm", 2213 [(set (f16 HPR:$Sd), (fadd_mlx (fmul_su (f16 HPR:$Sn), (f16 HPR:$Sm)), 2214 (f16 HPR:$Sdin)))]>, 2215 RegConstraint<"$Sdin = $Sd">, 2216 Requires<[HasFullFP16,UseFusedMAC]>, 2217 Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]>; 2218 2219def : Pat<(fadd_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))), 2220 (VFMAD DPR:$dstin, DPR:$a, DPR:$b)>, 2221 Requires<[HasVFP4,HasDPVFP,UseFusedMAC]>; 2222def : Pat<(fadd_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)), 2223 (VFMAS SPR:$dstin, SPR:$a, SPR:$b)>, 2224 Requires<[HasVFP4,DontUseNEONForFP,UseFusedMAC]>; 2225def : Pat<(fadd_mlx HPR:$dstin, (fmul_su (f16 HPR:$a), HPR:$b)), 2226 (VFMAH HPR:$dstin, (f16 HPR:$a), HPR:$b)>, 2227 Requires<[HasFullFP16,DontUseNEONForFP,UseFusedMAC]>; 2228 2229// Match @llvm.fma.* intrinsics 2230// (fma x, y, z) -> (vfms z, x, y) 2231def : Pat<(f64 (fma DPR:$Dn, DPR:$Dm, DPR:$Ddin)), 2232 (VFMAD DPR:$Ddin, DPR:$Dn, DPR:$Dm)>, 2233 Requires<[HasVFP4,HasDPVFP]>; 2234def : Pat<(f32 (fma SPR:$Sn, SPR:$Sm, SPR:$Sdin)), 2235 (VFMAS SPR:$Sdin, SPR:$Sn, SPR:$Sm)>, 2236 Requires<[HasVFP4]>; 2237def : Pat<(f16 (fma HPR:$Sn, HPR:$Sm, (f16 HPR:$Sdin))), 2238 (VFMAH (f16 HPR:$Sdin), (f16 HPR:$Sn), (f16 HPR:$Sm))>, 2239 Requires<[HasFullFP16]>; 2240 2241def VFMSD : ADbI<0b11101, 0b10, 1, 0, 2242 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm), 2243 IIC_fpFMAC64, "vfms", ".f64\t$Dd, $Dn, $Dm", 2244 [(set DPR:$Dd, (fadd_mlx (fneg (fmul_su DPR:$Dn,DPR:$Dm)), 2245 (f64 DPR:$Ddin)))]>, 2246 RegConstraint<"$Ddin = $Dd">, 2247 Requires<[HasVFP4,HasDPVFP,UseFusedMAC]>, 2248 Sched<[WriteFPMAC64, ReadFPMAC, ReadFPMUL, ReadFPMUL]>; 2249 2250def VFMSS : ASbIn<0b11101, 0b10, 1, 0, 2251 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm), 2252 IIC_fpFMAC32, "vfms", ".f32\t$Sd, $Sn, $Sm", 2253 [(set SPR:$Sd, (fadd_mlx (fneg (fmul_su SPR:$Sn, SPR:$Sm)), 2254 SPR:$Sdin))]>, 2255 RegConstraint<"$Sdin = $Sd">, 2256 Requires<[HasVFP4,DontUseNEONForFP,UseFusedMAC]>, 2257 Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]> { 2258 // Some single precision VFP instructions may be executed on both NEON and 2259 // VFP pipelines. 2260} 2261 2262def VFMSH : AHbI<0b11101, 0b10, 1, 0, 2263 (outs HPR:$Sd), (ins HPR:$Sdin, HPR:$Sn, HPR:$Sm), 2264 IIC_fpFMAC16, "vfms", ".f16\t$Sd, $Sn, $Sm", 2265 [(set (f16 HPR:$Sd), (fadd_mlx (fneg (fmul_su (f16 HPR:$Sn), (f16 HPR:$Sm))), 2266 (f16 HPR:$Sdin)))]>, 2267 RegConstraint<"$Sdin = $Sd">, 2268 Requires<[HasFullFP16,UseFusedMAC]>, 2269 Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]>; 2270 2271def : Pat<(fsub_mlx DPR:$dstin, (fmul_su DPR:$a, (f64 DPR:$b))), 2272 (VFMSD DPR:$dstin, DPR:$a, DPR:$b)>, 2273 Requires<[HasVFP4,HasDPVFP,UseFusedMAC]>; 2274def : Pat<(fsub_mlx SPR:$dstin, (fmul_su SPR:$a, SPR:$b)), 2275 (VFMSS SPR:$dstin, SPR:$a, SPR:$b)>, 2276 Requires<[HasVFP4,DontUseNEONForFP,UseFusedMAC]>; 2277def : Pat<(fsub_mlx HPR:$dstin, (fmul_su (f16 HPR:$a), HPR:$b)), 2278 (VFMSH HPR:$dstin, (f16 HPR:$a), HPR:$b)>, 2279 Requires<[HasFullFP16,DontUseNEONForFP,UseFusedMAC]>; 2280 2281// Match @llvm.fma.* intrinsics 2282// (fma (fneg x), y, z) -> (vfms z, x, y) 2283def : Pat<(f64 (fma (fneg DPR:$Dn), DPR:$Dm, DPR:$Ddin)), 2284 (VFMSD DPR:$Ddin, DPR:$Dn, DPR:$Dm)>, 2285 Requires<[HasVFP4,HasDPVFP]>; 2286def : Pat<(f32 (fma (fneg SPR:$Sn), SPR:$Sm, SPR:$Sdin)), 2287 (VFMSS SPR:$Sdin, SPR:$Sn, SPR:$Sm)>, 2288 Requires<[HasVFP4]>; 2289def : Pat<(f16 (fma (fneg (f16 HPR:$Sn)), (f16 HPR:$Sm), (f16 HPR:$Sdin))), 2290 (VFMSH (f16 HPR:$Sdin), (f16 HPR:$Sn), (f16 HPR:$Sm))>, 2291 Requires<[HasFullFP16]>; 2292 2293def VFNMAD : ADbI<0b11101, 0b01, 1, 0, 2294 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm), 2295 IIC_fpFMAC64, "vfnma", ".f64\t$Dd, $Dn, $Dm", 2296 [(set DPR:$Dd,(fsub_mlx (fneg (fmul_su DPR:$Dn,DPR:$Dm)), 2297 (f64 DPR:$Ddin)))]>, 2298 RegConstraint<"$Ddin = $Dd">, 2299 Requires<[HasVFP4,HasDPVFP,UseFusedMAC]>, 2300 Sched<[WriteFPMAC64, ReadFPMAC, ReadFPMUL, ReadFPMUL]>; 2301 2302def VFNMAS : ASbI<0b11101, 0b01, 1, 0, 2303 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm), 2304 IIC_fpFMAC32, "vfnma", ".f32\t$Sd, $Sn, $Sm", 2305 [(set SPR:$Sd, (fsub_mlx (fneg (fmul_su SPR:$Sn, SPR:$Sm)), 2306 SPR:$Sdin))]>, 2307 RegConstraint<"$Sdin = $Sd">, 2308 Requires<[HasVFP4,DontUseNEONForFP,UseFusedMAC]>, 2309 Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]> { 2310 // Some single precision VFP instructions may be executed on both NEON and 2311 // VFP pipelines. 2312} 2313 2314def VFNMAH : AHbI<0b11101, 0b01, 1, 0, 2315 (outs HPR:$Sd), (ins HPR:$Sdin, HPR:$Sn, HPR:$Sm), 2316 IIC_fpFMAC16, "vfnma", ".f16\t$Sd, $Sn, $Sm", 2317 [(set (f16 HPR:$Sd), (fsub_mlx (fneg (fmul_su (f16 HPR:$Sn), (f16 HPR:$Sm))), 2318 (f16 HPR:$Sdin)))]>, 2319 RegConstraint<"$Sdin = $Sd">, 2320 Requires<[HasFullFP16,UseFusedMAC]>, 2321 Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]>; 2322 2323def : Pat<(fsub_mlx (fneg (fmul_su DPR:$a, (f64 DPR:$b))), DPR:$dstin), 2324 (VFNMAD DPR:$dstin, DPR:$a, DPR:$b)>, 2325 Requires<[HasVFP4,HasDPVFP,UseFusedMAC]>; 2326def : Pat<(fsub_mlx (fneg (fmul_su SPR:$a, SPR:$b)), SPR:$dstin), 2327 (VFNMAS SPR:$dstin, SPR:$a, SPR:$b)>, 2328 Requires<[HasVFP4,DontUseNEONForFP,UseFusedMAC]>; 2329 2330// Match @llvm.fma.* intrinsics 2331// (fneg (fma x, y, z)) -> (vfnma z, x, y) 2332def : Pat<(fneg (fma (f64 DPR:$Dn), (f64 DPR:$Dm), (f64 DPR:$Ddin))), 2333 (VFNMAD DPR:$Ddin, DPR:$Dn, DPR:$Dm)>, 2334 Requires<[HasVFP4,HasDPVFP]>; 2335def : Pat<(fneg (fma (f32 SPR:$Sn), (f32 SPR:$Sm), (f32 SPR:$Sdin))), 2336 (VFNMAS SPR:$Sdin, SPR:$Sn, SPR:$Sm)>, 2337 Requires<[HasVFP4]>; 2338def : Pat<(fneg (fma (f16 HPR:$Sn), (f16 HPR:$Sm), (f16 (f16 HPR:$Sdin)))), 2339 (VFNMAH (f16 HPR:$Sdin), (f16 HPR:$Sn), (f16 HPR:$Sm))>, 2340 Requires<[HasFullFP16]>; 2341// (fma (fneg x), y, (fneg z)) -> (vfnma z, x, y) 2342def : Pat<(f64 (fma (fneg DPR:$Dn), DPR:$Dm, (fneg DPR:$Ddin))), 2343 (VFNMAD DPR:$Ddin, DPR:$Dn, DPR:$Dm)>, 2344 Requires<[HasVFP4,HasDPVFP]>; 2345def : Pat<(f32 (fma (fneg SPR:$Sn), SPR:$Sm, (fneg SPR:$Sdin))), 2346 (VFNMAS SPR:$Sdin, SPR:$Sn, SPR:$Sm)>, 2347 Requires<[HasVFP4]>; 2348def : Pat<(f16 (fma (fneg (f16 HPR:$Sn)), (f16 HPR:$Sm), (fneg (f16 HPR:$Sdin)))), 2349 (VFNMAH (f16 HPR:$Sdin), (f16 HPR:$Sn), (f16 HPR:$Sm))>, 2350 Requires<[HasFullFP16]>; 2351 2352def VFNMSD : ADbI<0b11101, 0b01, 0, 0, 2353 (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm), 2354 IIC_fpFMAC64, "vfnms", ".f64\t$Dd, $Dn, $Dm", 2355 [(set DPR:$Dd, (fsub_mlx (fmul_su DPR:$Dn, DPR:$Dm), 2356 (f64 DPR:$Ddin)))]>, 2357 RegConstraint<"$Ddin = $Dd">, 2358 Requires<[HasVFP4,HasDPVFP,UseFusedMAC]>, 2359 Sched<[WriteFPMAC64, ReadFPMAC, ReadFPMUL, ReadFPMUL]>; 2360 2361def VFNMSS : ASbI<0b11101, 0b01, 0, 0, 2362 (outs SPR:$Sd), (ins SPR:$Sdin, SPR:$Sn, SPR:$Sm), 2363 IIC_fpFMAC32, "vfnms", ".f32\t$Sd, $Sn, $Sm", 2364 [(set SPR:$Sd, (fsub_mlx (fmul_su SPR:$Sn, SPR:$Sm), SPR:$Sdin))]>, 2365 RegConstraint<"$Sdin = $Sd">, 2366 Requires<[HasVFP4,DontUseNEONForFP,UseFusedMAC]>, 2367 Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]> { 2368 // Some single precision VFP instructions may be executed on both NEON and 2369 // VFP pipelines. 2370} 2371 2372def VFNMSH : AHbI<0b11101, 0b01, 0, 0, 2373 (outs HPR:$Sd), (ins HPR:$Sdin, HPR:$Sn, HPR:$Sm), 2374 IIC_fpFMAC16, "vfnms", ".f16\t$Sd, $Sn, $Sm", 2375 [(set (f16 HPR:$Sd), (fsub_mlx (fmul_su (f16 HPR:$Sn), (f16 HPR:$Sm)), (f16 HPR:$Sdin)))]>, 2376 RegConstraint<"$Sdin = $Sd">, 2377 Requires<[HasFullFP16,UseFusedMAC]>, 2378 Sched<[WriteFPMAC32, ReadFPMAC, ReadFPMUL, ReadFPMUL]>; 2379 2380def : Pat<(fsub_mlx (fmul_su DPR:$a, (f64 DPR:$b)), DPR:$dstin), 2381 (VFNMSD DPR:$dstin, DPR:$a, DPR:$b)>, 2382 Requires<[HasVFP4,HasDPVFP,UseFusedMAC]>; 2383def : Pat<(fsub_mlx (fmul_su SPR:$a, SPR:$b), SPR:$dstin), 2384 (VFNMSS SPR:$dstin, SPR:$a, SPR:$b)>, 2385 Requires<[HasVFP4,DontUseNEONForFP,UseFusedMAC]>; 2386 2387// Match @llvm.fma.* intrinsics 2388 2389// (fma x, y, (fneg z)) -> (vfnms z, x, y)) 2390def : Pat<(f64 (fma DPR:$Dn, DPR:$Dm, (fneg DPR:$Ddin))), 2391 (VFNMSD DPR:$Ddin, DPR:$Dn, DPR:$Dm)>, 2392 Requires<[HasVFP4,HasDPVFP]>; 2393def : Pat<(f32 (fma SPR:$Sn, SPR:$Sm, (fneg SPR:$Sdin))), 2394 (VFNMSS SPR:$Sdin, SPR:$Sn, SPR:$Sm)>, 2395 Requires<[HasVFP4]>; 2396def : Pat<(f16 (fma (f16 HPR:$Sn), (f16 HPR:$Sm), (fneg (f16 HPR:$Sdin)))), 2397 (VFNMSH (f16 HPR:$Sdin), (f16 HPR:$Sn), (f16 HPR:$Sm))>, 2398 Requires<[HasFullFP16]>; 2399// (fneg (fma (fneg x), y, z)) -> (vfnms z, x, y) 2400def : Pat<(fneg (f64 (fma (fneg DPR:$Dn), DPR:$Dm, DPR:$Ddin))), 2401 (VFNMSD DPR:$Ddin, DPR:$Dn, DPR:$Dm)>, 2402 Requires<[HasVFP4,HasDPVFP]>; 2403def : Pat<(fneg (f32 (fma (fneg SPR:$Sn), SPR:$Sm, SPR:$Sdin))), 2404 (VFNMSS SPR:$Sdin, SPR:$Sn, SPR:$Sm)>, 2405 Requires<[HasVFP4]>; 2406def : Pat<(fneg (f16 (fma (fneg (f16 HPR:$Sn)), (f16 HPR:$Sm), (f16 HPR:$Sdin)))), 2407 (VFNMSH (f16 HPR:$Sdin), (f16 HPR:$Sn), (f16 HPR:$Sm))>, 2408 Requires<[HasFullFP16]>; 2409 2410//===----------------------------------------------------------------------===// 2411// FP Conditional moves. 2412// 2413 2414let hasSideEffects = 0 in { 2415def VMOVDcc : PseudoInst<(outs DPR:$Dd), (ins DPR:$Dn, DPR:$Dm, cmovpred:$p), 2416 IIC_fpUNA64, 2417 [(set (f64 DPR:$Dd), 2418 (ARMcmov DPR:$Dn, DPR:$Dm, cmovpred:$p))]>, 2419 RegConstraint<"$Dn = $Dd">, Requires<[HasFPRegs64]>; 2420 2421def VMOVScc : PseudoInst<(outs SPR:$Sd), (ins SPR:$Sn, SPR:$Sm, cmovpred:$p), 2422 IIC_fpUNA32, 2423 [(set (f32 SPR:$Sd), 2424 (ARMcmov SPR:$Sn, SPR:$Sm, cmovpred:$p))]>, 2425 RegConstraint<"$Sn = $Sd">, Requires<[HasFPRegs]>; 2426 2427def VMOVHcc : PseudoInst<(outs HPR:$Sd), (ins HPR:$Sn, HPR:$Sm, cmovpred:$p), 2428 IIC_fpUNA16, 2429 [(set (f16 HPR:$Sd), 2430 (ARMcmov (f16 HPR:$Sn), (f16 HPR:$Sm), cmovpred:$p))]>, 2431 RegConstraint<"$Sd = $Sn">, Requires<[HasFPRegs]>; 2432} // hasSideEffects 2433 2434//===----------------------------------------------------------------------===// 2435// Move from VFP System Register to ARM core register. 2436// 2437 2438class MovFromVFP<bits<4> opc19_16, dag oops, dag iops, string opc, string asm, 2439 list<dag> pattern>: 2440 VFPAI<oops, iops, VFPMiscFrm, IIC_fpSTAT, opc, asm, pattern> { 2441 2442 // Instruction operand. 2443 bits<4> Rt; 2444 2445 let Inst{27-20} = 0b11101111; 2446 let Inst{19-16} = opc19_16; 2447 let Inst{15-12} = Rt; 2448 let Inst{11-8} = 0b1010; 2449 let Inst{7} = 0; 2450 let Inst{6-5} = 0b00; 2451 let Inst{4} = 1; 2452 let Inst{3-0} = 0b0000; 2453 let Unpredictable{7-5} = 0b111; 2454 let Unpredictable{3-0} = 0b1111; 2455} 2456 2457let DecoderMethod = "DecodeForVMRSandVMSR" in { 2458 // APSR is the application level alias of CPSR. This FPSCR N, Z, C, V flags 2459 // to APSR. 2460 let Defs = [CPSR], Uses = [FPSCR_NZCV], Predicates = [HasFPRegs], 2461 Rt = 0b1111 /* apsr_nzcv */ in 2462 def FMSTAT : MovFromVFP<0b0001 /* fpscr */, (outs), (ins), 2463 "vmrs", "\tAPSR_nzcv, fpscr", [(arm_fmstat)]>; 2464 2465 // Application level FPSCR -> GPR 2466 let hasSideEffects = 1, Uses = [FPSCR], Predicates = [HasFPRegs] in 2467 def VMRS : MovFromVFP<0b0001 /* fpscr */, (outs GPRnopc:$Rt), (ins), 2468 "vmrs", "\t$Rt, fpscr", 2469 [(set GPRnopc:$Rt, (int_arm_get_fpscr))]>; 2470 2471 // System level FPEXC, FPSID -> GPR 2472 let Uses = [FPSCR] in { 2473 def VMRS_FPEXC : MovFromVFP<0b1000 /* fpexc */, (outs GPRnopc:$Rt), (ins), 2474 "vmrs", "\t$Rt, fpexc", []>; 2475 def VMRS_FPSID : MovFromVFP<0b0000 /* fpsid */, (outs GPRnopc:$Rt), (ins), 2476 "vmrs", "\t$Rt, fpsid", []>; 2477 def VMRS_MVFR0 : MovFromVFP<0b0111 /* mvfr0 */, (outs GPRnopc:$Rt), (ins), 2478 "vmrs", "\t$Rt, mvfr0", []>; 2479 def VMRS_MVFR1 : MovFromVFP<0b0110 /* mvfr1 */, (outs GPRnopc:$Rt), (ins), 2480 "vmrs", "\t$Rt, mvfr1", []>; 2481 let Predicates = [HasFPARMv8] in { 2482 def VMRS_MVFR2 : MovFromVFP<0b0101 /* mvfr2 */, (outs GPRnopc:$Rt), (ins), 2483 "vmrs", "\t$Rt, mvfr2", []>; 2484 } 2485 def VMRS_FPINST : MovFromVFP<0b1001 /* fpinst */, (outs GPRnopc:$Rt), (ins), 2486 "vmrs", "\t$Rt, fpinst", []>; 2487 def VMRS_FPINST2 : MovFromVFP<0b1010 /* fpinst2 */, (outs GPRnopc:$Rt), 2488 (ins), "vmrs", "\t$Rt, fpinst2", []>; 2489 let Predicates = [HasV8_1MMainline, HasFPRegs] in { 2490 // System level FPSCR_NZCVQC -> GPR 2491 def VMRS_FPSCR_NZCVQC 2492 : MovFromVFP<0b0010 /* fpscr_nzcvqc */, 2493 (outs GPR:$Rt), (ins cl_FPSCR_NZCV:$fpscr_in), 2494 "vmrs", "\t$Rt, fpscr_nzcvqc", []>; 2495 } 2496 } 2497 let Predicates = [HasV8_1MMainline, Has8MSecExt] in { 2498 // System level FPSCR -> GPR, with context saving for security extensions 2499 def VMRS_FPCXTNS : MovFromVFP<0b1110 /* fpcxtns */, (outs GPR:$Rt), (ins), 2500 "vmrs", "\t$Rt, fpcxtns", []>; 2501 } 2502 let Predicates = [HasV8_1MMainline, Has8MSecExt] in { 2503 // System level FPSCR -> GPR, with context saving for security extensions 2504 def VMRS_FPCXTS : MovFromVFP<0b1111 /* fpcxts */, (outs GPR:$Rt), (ins), 2505 "vmrs", "\t$Rt, fpcxts", []>; 2506 } 2507 2508 let Predicates = [HasV8_1MMainline, HasMVEInt] in { 2509 // System level VPR/P0 -> GPR 2510 let Uses = [VPR] in 2511 def VMRS_VPR : MovFromVFP<0b1100 /* vpr */, (outs GPR:$Rt), (ins), 2512 "vmrs", "\t$Rt, vpr", []>; 2513 2514 def VMRS_P0 : MovFromVFP<0b1101 /* p0 */, (outs GPR:$Rt), (ins VCCR:$cond), 2515 "vmrs", "\t$Rt, p0", []>; 2516 } 2517} 2518 2519//===----------------------------------------------------------------------===// 2520// Move from ARM core register to VFP System Register. 2521// 2522 2523class MovToVFP<bits<4> opc19_16, dag oops, dag iops, string opc, string asm, 2524 list<dag> pattern>: 2525 VFPAI<oops, iops, VFPMiscFrm, IIC_fpSTAT, opc, asm, pattern> { 2526 2527 // Instruction operand. 2528 bits<4> Rt; 2529 2530 let Inst{27-20} = 0b11101110; 2531 let Inst{19-16} = opc19_16; 2532 let Inst{15-12} = Rt; 2533 let Inst{11-8} = 0b1010; 2534 let Inst{7} = 0; 2535 let Inst{6-5} = 0b00; 2536 let Inst{4} = 1; 2537 let Inst{3-0} = 0b0000; 2538 let Predicates = [HasVFP2]; 2539 let Unpredictable{7-5} = 0b111; 2540 let Unpredictable{3-0} = 0b1111; 2541} 2542 2543let DecoderMethod = "DecodeForVMRSandVMSR" in { 2544 let Defs = [FPSCR] in { 2545 let Predicates = [HasFPRegs] in 2546 // Application level GPR -> FPSCR 2547 def VMSR : MovToVFP<0b0001 /* fpscr */, (outs), (ins GPRnopc:$Rt), 2548 "vmsr", "\tfpscr, $Rt", 2549 [(int_arm_set_fpscr GPRnopc:$Rt)]>; 2550 // System level GPR -> FPEXC 2551 def VMSR_FPEXC : MovToVFP<0b1000 /* fpexc */, (outs), (ins GPRnopc:$Rt), 2552 "vmsr", "\tfpexc, $Rt", []>; 2553 // System level GPR -> FPSID 2554 def VMSR_FPSID : MovToVFP<0b0000 /* fpsid */, (outs), (ins GPRnopc:$Rt), 2555 "vmsr", "\tfpsid, $Rt", []>; 2556 def VMSR_FPINST : MovToVFP<0b1001 /* fpinst */, (outs), (ins GPRnopc:$Rt), 2557 "vmsr", "\tfpinst, $Rt", []>; 2558 def VMSR_FPINST2 : MovToVFP<0b1010 /* fpinst2 */, (outs), (ins GPRnopc:$Rt), 2559 "vmsr", "\tfpinst2, $Rt", []>; 2560 } 2561 let Predicates = [HasV8_1MMainline, Has8MSecExt] in { 2562 // System level GPR -> FPSCR with context saving for security extensions 2563 def VMSR_FPCXTNS : MovToVFP<0b1110 /* fpcxtns */, (outs), (ins GPR:$Rt), 2564 "vmsr", "\tfpcxtns, $Rt", []>; 2565 } 2566 let Predicates = [HasV8_1MMainline, Has8MSecExt] in { 2567 // System level GPR -> FPSCR with context saving for security extensions 2568 def VMSR_FPCXTS : MovToVFP<0b1111 /* fpcxts */, (outs), (ins GPR:$Rt), 2569 "vmsr", "\tfpcxts, $Rt", []>; 2570 } 2571 let Predicates = [HasV8_1MMainline, HasFPRegs] in { 2572 // System level GPR -> FPSCR_NZCVQC 2573 def VMSR_FPSCR_NZCVQC 2574 : MovToVFP<0b0010 /* fpscr_nzcvqc */, 2575 (outs cl_FPSCR_NZCV:$fpscr_out), (ins GPR:$Rt), 2576 "vmsr", "\tfpscr_nzcvqc, $Rt", []>; 2577 } 2578 2579 let Predicates = [HasV8_1MMainline, HasMVEInt] in { 2580 // System level GPR -> VPR/P0 2581 let Defs = [VPR] in 2582 def VMSR_VPR : MovToVFP<0b1100 /* vpr */, (outs), (ins GPR:$Rt), 2583 "vmsr", "\tvpr, $Rt", []>; 2584 2585 def VMSR_P0 : MovToVFP<0b1101 /* p0 */, (outs VCCR:$cond), (ins GPR:$Rt), 2586 "vmsr", "\tp0, $Rt", []>; 2587 } 2588} 2589 2590//===----------------------------------------------------------------------===// 2591// Misc. 2592// 2593 2594// Materialize FP immediates. VFP3 only. 2595let isReMaterializable = 1 in { 2596def FCONSTD : VFPAI<(outs DPR:$Dd), (ins vfp_f64imm:$imm), 2597 VFPMiscFrm, IIC_fpUNA64, 2598 "vmov", ".f64\t$Dd, $imm", 2599 [(set DPR:$Dd, vfp_f64imm:$imm)]>, 2600 Requires<[HasVFP3,HasDPVFP]> { 2601 bits<5> Dd; 2602 bits<8> imm; 2603 2604 let Inst{27-23} = 0b11101; 2605 let Inst{22} = Dd{4}; 2606 let Inst{21-20} = 0b11; 2607 let Inst{19-16} = imm{7-4}; 2608 let Inst{15-12} = Dd{3-0}; 2609 let Inst{11-9} = 0b101; 2610 let Inst{8} = 1; // Double precision. 2611 let Inst{7-4} = 0b0000; 2612 let Inst{3-0} = imm{3-0}; 2613} 2614 2615def FCONSTS : VFPAI<(outs SPR:$Sd), (ins vfp_f32imm:$imm), 2616 VFPMiscFrm, IIC_fpUNA32, 2617 "vmov", ".f32\t$Sd, $imm", 2618 [(set SPR:$Sd, vfp_f32imm:$imm)]>, Requires<[HasVFP3]> { 2619 bits<5> Sd; 2620 bits<8> imm; 2621 2622 let Inst{27-23} = 0b11101; 2623 let Inst{22} = Sd{0}; 2624 let Inst{21-20} = 0b11; 2625 let Inst{19-16} = imm{7-4}; 2626 let Inst{15-12} = Sd{4-1}; 2627 let Inst{11-9} = 0b101; 2628 let Inst{8} = 0; // Single precision. 2629 let Inst{7-4} = 0b0000; 2630 let Inst{3-0} = imm{3-0}; 2631} 2632 2633def FCONSTH : VFPAI<(outs HPR:$Sd), (ins vfp_f16imm:$imm), 2634 VFPMiscFrm, IIC_fpUNA16, 2635 "vmov", ".f16\t$Sd, $imm", 2636 [(set (f16 HPR:$Sd), vfp_f16imm:$imm)]>, 2637 Requires<[HasFullFP16]> { 2638 bits<5> Sd; 2639 bits<8> imm; 2640 2641 let Inst{27-23} = 0b11101; 2642 let Inst{22} = Sd{0}; 2643 let Inst{21-20} = 0b11; 2644 let Inst{19-16} = imm{7-4}; 2645 let Inst{15-12} = Sd{4-1}; 2646 let Inst{11-8} = 0b1001; // Half precision 2647 let Inst{7-4} = 0b0000; 2648 let Inst{3-0} = imm{3-0}; 2649 2650 let isUnpredicable = 1; 2651} 2652} 2653 2654def : Pat<(f32 (vfp_f32f16imm:$imm)), 2655 (f32 (COPY_TO_REGCLASS (f16 (FCONSTH (vfp_f32f16imm_xform (f32 $imm)))), SPR))> { 2656 let Predicates = [HasFullFP16]; 2657} 2658 2659//===----------------------------------------------------------------------===// 2660// Assembler aliases. 2661// 2662// A few mnemonic aliases for pre-unifixed syntax. We don't guarantee to 2663// support them all, but supporting at least some of the basics is 2664// good to be friendly. 2665def : VFP2MnemonicAlias<"flds", "vldr">; 2666def : VFP2MnemonicAlias<"fldd", "vldr">; 2667def : VFP2MnemonicAlias<"fmrs", "vmov">; 2668def : VFP2MnemonicAlias<"fmsr", "vmov">; 2669def : VFP2MnemonicAlias<"fsqrts", "vsqrt">; 2670def : VFP2MnemonicAlias<"fsqrtd", "vsqrt">; 2671def : VFP2MnemonicAlias<"fadds", "vadd.f32">; 2672def : VFP2MnemonicAlias<"faddd", "vadd.f64">; 2673def : VFP2MnemonicAlias<"fmrdd", "vmov">; 2674def : VFP2MnemonicAlias<"fmrds", "vmov">; 2675def : VFP2MnemonicAlias<"fmrrd", "vmov">; 2676def : VFP2MnemonicAlias<"fmdrr", "vmov">; 2677def : VFP2MnemonicAlias<"fmuls", "vmul.f32">; 2678def : VFP2MnemonicAlias<"fmuld", "vmul.f64">; 2679def : VFP2MnemonicAlias<"fnegs", "vneg.f32">; 2680def : VFP2MnemonicAlias<"fnegd", "vneg.f64">; 2681def : VFP2MnemonicAlias<"ftosizd", "vcvt.s32.f64">; 2682def : VFP2MnemonicAlias<"ftosid", "vcvtr.s32.f64">; 2683def : VFP2MnemonicAlias<"ftosizs", "vcvt.s32.f32">; 2684def : VFP2MnemonicAlias<"ftosis", "vcvtr.s32.f32">; 2685def : VFP2MnemonicAlias<"ftouizd", "vcvt.u32.f64">; 2686def : VFP2MnemonicAlias<"ftouid", "vcvtr.u32.f64">; 2687def : VFP2MnemonicAlias<"ftouizs", "vcvt.u32.f32">; 2688def : VFP2MnemonicAlias<"ftouis", "vcvtr.u32.f32">; 2689def : VFP2MnemonicAlias<"fsitod", "vcvt.f64.s32">; 2690def : VFP2MnemonicAlias<"fsitos", "vcvt.f32.s32">; 2691def : VFP2MnemonicAlias<"fuitod", "vcvt.f64.u32">; 2692def : VFP2MnemonicAlias<"fuitos", "vcvt.f32.u32">; 2693def : VFP2MnemonicAlias<"fsts", "vstr">; 2694def : VFP2MnemonicAlias<"fstd", "vstr">; 2695def : VFP2MnemonicAlias<"fmacd", "vmla.f64">; 2696def : VFP2MnemonicAlias<"fmacs", "vmla.f32">; 2697def : VFP2MnemonicAlias<"fcpys", "vmov.f32">; 2698def : VFP2MnemonicAlias<"fcpyd", "vmov.f64">; 2699def : VFP2MnemonicAlias<"fcmps", "vcmp.f32">; 2700def : VFP2MnemonicAlias<"fcmpd", "vcmp.f64">; 2701def : VFP2MnemonicAlias<"fdivs", "vdiv.f32">; 2702def : VFP2MnemonicAlias<"fdivd", "vdiv.f64">; 2703def : VFP2MnemonicAlias<"fmrx", "vmrs">; 2704def : VFP2MnemonicAlias<"fmxr", "vmsr">; 2705 2706// Be friendly and accept the old form of zero-compare 2707def : VFP2DPInstAlias<"fcmpzd${p} $val", (VCMPZD DPR:$val, pred:$p)>; 2708def : VFP2InstAlias<"fcmpzs${p} $val", (VCMPZS SPR:$val, pred:$p)>; 2709 2710 2711def : InstAlias<"fmstat${p}", (FMSTAT pred:$p), 0>, Requires<[HasFPRegs]>; 2712def : VFP2InstAlias<"fadds${p} $Sd, $Sn, $Sm", 2713 (VADDS SPR:$Sd, SPR:$Sn, SPR:$Sm, pred:$p)>; 2714def : VFP2DPInstAlias<"faddd${p} $Dd, $Dn, $Dm", 2715 (VADDD DPR:$Dd, DPR:$Dn, DPR:$Dm, pred:$p)>; 2716def : VFP2InstAlias<"fsubs${p} $Sd, $Sn, $Sm", 2717 (VSUBS SPR:$Sd, SPR:$Sn, SPR:$Sm, pred:$p)>; 2718def : VFP2DPInstAlias<"fsubd${p} $Dd, $Dn, $Dm", 2719 (VSUBD DPR:$Dd, DPR:$Dn, DPR:$Dm, pred:$p)>; 2720 2721// No need for the size suffix on VSQRT. It's implied by the register classes. 2722def : VFP2InstAlias<"vsqrt${p} $Sd, $Sm", (VSQRTS SPR:$Sd, SPR:$Sm, pred:$p)>; 2723def : VFP2DPInstAlias<"vsqrt${p} $Dd, $Dm", (VSQRTD DPR:$Dd, DPR:$Dm, pred:$p)>; 2724 2725// VLDR/VSTR accept an optional type suffix. 2726def : VFP2InstAlias<"vldr${p}.32 $Sd, $addr", 2727 (VLDRS SPR:$Sd, addrmode5:$addr, pred:$p)>; 2728def : VFP2InstAlias<"vstr${p}.32 $Sd, $addr", 2729 (VSTRS SPR:$Sd, addrmode5:$addr, pred:$p)>; 2730def : VFP2InstAlias<"vldr${p}.64 $Dd, $addr", 2731 (VLDRD DPR:$Dd, addrmode5:$addr, pred:$p)>; 2732def : VFP2InstAlias<"vstr${p}.64 $Dd, $addr", 2733 (VSTRD DPR:$Dd, addrmode5:$addr, pred:$p)>; 2734 2735// VMOV can accept optional 32-bit or less data type suffix suffix. 2736def : VFP2InstAlias<"vmov${p}.8 $Rt, $Sn", 2737 (VMOVRS GPR:$Rt, SPR:$Sn, pred:$p)>; 2738def : VFP2InstAlias<"vmov${p}.16 $Rt, $Sn", 2739 (VMOVRS GPR:$Rt, SPR:$Sn, pred:$p)>; 2740def : VFP2InstAlias<"vmov${p}.32 $Rt, $Sn", 2741 (VMOVRS GPR:$Rt, SPR:$Sn, pred:$p)>; 2742def : VFP2InstAlias<"vmov${p}.8 $Sn, $Rt", 2743 (VMOVSR SPR:$Sn, GPR:$Rt, pred:$p)>; 2744def : VFP2InstAlias<"vmov${p}.16 $Sn, $Rt", 2745 (VMOVSR SPR:$Sn, GPR:$Rt, pred:$p)>; 2746def : VFP2InstAlias<"vmov${p}.32 $Sn, $Rt", 2747 (VMOVSR SPR:$Sn, GPR:$Rt, pred:$p)>; 2748 2749def : VFP2InstAlias<"vmov${p}.f64 $Rt, $Rt2, $Dn", 2750 (VMOVRRD GPR:$Rt, GPR:$Rt2, DPR:$Dn, pred:$p)>; 2751def : VFP2InstAlias<"vmov${p}.f64 $Dn, $Rt, $Rt2", 2752 (VMOVDRR DPR:$Dn, GPR:$Rt, GPR:$Rt2, pred:$p)>; 2753 2754// VMOVS doesn't need the .f32 to disambiguate from the NEON encoding the way 2755// VMOVD does. 2756def : VFP2InstAlias<"vmov${p} $Sd, $Sm", 2757 (VMOVS SPR:$Sd, SPR:$Sm, pred:$p)>; 2758 2759// FCONSTD/FCONSTS alias for vmov.f64/vmov.f32 2760// These aliases provide added functionality over vmov.f instructions by 2761// allowing users to write assembly containing encoded floating point constants 2762// (e.g. #0x70 vs #1.0). Without these alises there is no way for the 2763// assembler to accept encoded fp constants (but the equivalent fp-literal is 2764// accepted directly by vmovf). 2765def : VFP3InstAlias<"fconstd${p} $Dd, $val", 2766 (FCONSTD DPR:$Dd, vfp_f64imm:$val, pred:$p)>; 2767def : VFP3InstAlias<"fconsts${p} $Sd, $val", 2768 (FCONSTS SPR:$Sd, vfp_f32imm:$val, pred:$p)>; 2769 2770def VSCCLRMD : VFPXI<(outs), (ins pred:$p, fp_dreglist_with_vpr:$regs, variable_ops), 2771 AddrModeNone, 4, IndexModeNone, VFPMiscFrm, NoItinerary, 2772 "vscclrm{$p}\t$regs", "", []>, Sched<[]> { 2773 bits<13> regs; 2774 let Inst{31-23} = 0b111011001; 2775 let Inst{22} = regs{12}; 2776 let Inst{21-16} = 0b011111; 2777 let Inst{15-12} = regs{11-8}; 2778 let Inst{11-8} = 0b1011; 2779 let Inst{7-1} = regs{7-1}; 2780 let Inst{0} = 0; 2781 2782 let DecoderMethod = "DecodeVSCCLRM"; 2783 2784 list<Predicate> Predicates = [HasV8_1MMainline, Has8MSecExt]; 2785} 2786 2787def VSCCLRMS : VFPXI<(outs), (ins pred:$p, fp_sreglist_with_vpr:$regs, variable_ops), 2788 AddrModeNone, 4, IndexModeNone, VFPMiscFrm, NoItinerary, 2789 "vscclrm{$p}\t$regs", "", []>, Sched<[]> { 2790 bits<13> regs; 2791 let Inst{31-23} = 0b111011001; 2792 let Inst{22} = regs{8}; 2793 let Inst{21-16} = 0b011111; 2794 let Inst{15-12} = regs{12-9}; 2795 let Inst{11-8} = 0b1010; 2796 let Inst{7-0} = regs{7-0}; 2797 2798 let DecoderMethod = "DecodeVSCCLRM"; 2799 2800 list<Predicate> Predicates = [HasV8_1MMainline, Has8MSecExt]; 2801} 2802 2803//===----------------------------------------------------------------------===// 2804// Store VFP System Register to memory. 2805// 2806 2807class vfp_vstrldr<bit opc, bit P, bit W, bits<4> SysReg, string sysreg, 2808 dag oops, dag iops, IndexMode im, string Dest, string cstr> 2809 : VFPI<oops, iops, AddrModeT2_i7s4, 4, im, VFPLdStFrm, IIC_fpSTAT, 2810 !if(opc,"vldr","vstr"), !strconcat("\t", sysreg, ", ", Dest), cstr, []>, 2811 Sched<[]> { 2812 bits<12> addr; 2813 let Inst{27-25} = 0b110; 2814 let Inst{24} = P; 2815 let Inst{23} = addr{7}; 2816 let Inst{22} = SysReg{3}; 2817 let Inst{21} = W; 2818 let Inst{20} = opc; 2819 let Inst{19-16} = addr{11-8}; 2820 let Inst{15-13} = SysReg{2-0}; 2821 let Inst{12-7} = 0b011111; 2822 let Inst{6-0} = addr{6-0}; 2823 list<Predicate> Predicates = [HasFPRegs, HasV8_1MMainline]; 2824 let mayLoad = opc; 2825 let mayStore = !if(opc, 0b0, 0b1); 2826 let hasSideEffects = 1; 2827} 2828 2829multiclass vfp_vstrldr_sysreg<bit opc, bits<4> SysReg, string sysreg, 2830 dag oops=(outs), dag iops=(ins)> { 2831 def _off : 2832 vfp_vstrldr<opc, 1, 0, SysReg, sysreg, 2833 oops, !con(iops, (ins t2addrmode_imm7s4:$addr)), 2834 IndexModePost, "$addr", "" > { 2835 let DecoderMethod = "DecodeVSTRVLDR_SYSREG<false>"; 2836 } 2837 2838 def _pre : 2839 vfp_vstrldr<opc, 1, 1, SysReg, sysreg, 2840 !con(oops, (outs GPRnopc:$wb)), 2841 !con(iops, (ins t2addrmode_imm7s4_pre:$addr)), 2842 IndexModePre, "$addr!", "$addr.base = $wb"> { 2843 let DecoderMethod = "DecodeVSTRVLDR_SYSREG<true>"; 2844 } 2845 2846 def _post : 2847 vfp_vstrldr<opc, 0, 1, SysReg, sysreg, 2848 !con(oops, (outs GPRnopc:$wb)), 2849 !con(iops, (ins t2_addr_offset_none:$Rn, 2850 t2am_imm7s4_offset:$addr)), 2851 IndexModePost, "$Rn$addr", "$Rn.base = $wb"> { 2852 bits<4> Rn; 2853 let Inst{19-16} = Rn{3-0}; 2854 let DecoderMethod = "DecodeVSTRVLDR_SYSREG<true>"; 2855 } 2856} 2857 2858let Defs = [FPSCR] in { 2859 defm VSTR_FPSCR : vfp_vstrldr_sysreg<0b0,0b0001, "fpscr">; 2860 defm VSTR_FPSCR_NZCVQC : vfp_vstrldr_sysreg<0b0,0b0010, "fpscr_nzcvqc">; 2861 2862 let Predicates = [HasV8_1MMainline, Has8MSecExt] in { 2863 defm VSTR_FPCXTNS : vfp_vstrldr_sysreg<0b0,0b1110, "fpcxtns">; 2864 defm VSTR_FPCXTS : vfp_vstrldr_sysreg<0b0,0b1111, "fpcxts">; 2865 } 2866} 2867 2868let Predicates = [HasV8_1MMainline, HasMVEInt] in { 2869 let Uses = [VPR] in { 2870 defm VSTR_VPR : vfp_vstrldr_sysreg<0b0,0b1100, "vpr">; 2871 } 2872 defm VSTR_P0 : vfp_vstrldr_sysreg<0b0,0b1101, "p0", 2873 (outs), (ins VCCR:$P0)>; 2874 2875 let Defs = [VPR] in { 2876 defm VLDR_VPR : vfp_vstrldr_sysreg<0b1,0b1100, "vpr">; 2877 } 2878 defm VLDR_P0 : vfp_vstrldr_sysreg<0b1,0b1101, "p0", 2879 (outs VCCR:$P0), (ins)>; 2880} 2881 2882let Uses = [FPSCR] in { 2883 defm VLDR_FPSCR : vfp_vstrldr_sysreg<0b1,0b0001, "fpscr">; 2884 defm VLDR_FPSCR_NZCVQC : vfp_vstrldr_sysreg<0b1,0b0010, "fpscr_nzcvqc">; 2885 2886 let Predicates = [HasV8_1MMainline, Has8MSecExt] in { 2887 defm VLDR_FPCXTNS : vfp_vstrldr_sysreg<0b1,0b1110, "fpcxtns">; 2888 defm VLDR_FPCXTS : vfp_vstrldr_sysreg<0b1,0b1111, "fpcxts">; 2889 } 2890} 2891