1 //=- AArch64InstrInfo.td - Describe the AArch64 Instructions -*- tablegen -*-=//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // AArch64 Instruction definitions.
11 //===----------------------------------------------------------------------===//
13 //===----------------------------------------------------------------------===//
14 // ARM Instruction Predicate Definitions.
16 def HasV8_1a : Predicate<"Subtarget->hasV8_1aOps()">,
17 AssemblerPredicate<"HasV8_1aOps", "armv8.1a">;
18 def HasV8_2a : Predicate<"Subtarget->hasV8_2aOps()">,
19 AssemblerPredicate<"HasV8_2aOps", "armv8.2a">;
20 def HasV8_3a : Predicate<"Subtarget->hasV8_3aOps()">,
21 AssemblerPredicate<"HasV8_3aOps", "armv8.3a">;
22 def HasV8_4a : Predicate<"Subtarget->hasV8_4aOps()">,
23 AssemblerPredicate<"HasV8_4aOps", "armv8.4a">;
24 def HasV8_5a : Predicate<"Subtarget->hasV8_5aOps()">,
25 AssemblerPredicate<"HasV8_5aOps", "armv8.5a">;
26 def HasVH : Predicate<"Subtarget->hasVH()">,
27 AssemblerPredicate<"FeatureVH", "vh">;
29 def HasLOR : Predicate<"Subtarget->hasLOR()">,
30 AssemblerPredicate<"FeatureLOR", "lor">;
32 def HasPA : Predicate<"Subtarget->hasPA()">,
33 AssemblerPredicate<"FeaturePA", "pa">;
35 def HasJS : Predicate<"Subtarget->hasJS()">,
36 AssemblerPredicate<"FeatureJS", "jsconv">;
38 def HasCCIDX : Predicate<"Subtarget->hasCCIDX()">,
39 AssemblerPredicate<"FeatureCCIDX", "ccidx">;
41 def HasComplxNum : Predicate<"Subtarget->hasComplxNum()">,
42 AssemblerPredicate<"FeatureComplxNum", "complxnum">;
44 def HasNV : Predicate<"Subtarget->hasNV()">,
45 AssemblerPredicate<"FeatureNV", "nv">;
47 def HasRASv8_4 : Predicate<"Subtarget->hasRASv8_4()">,
48 AssemblerPredicate<"FeatureRASv8_4", "rasv8_4">;
50 def HasMPAM : Predicate<"Subtarget->hasMPAM()">,
51 AssemblerPredicate<"FeatureMPAM", "mpam">;
53 def HasDIT : Predicate<"Subtarget->hasDIT()">,
54 AssemblerPredicate<"FeatureDIT", "dit">;
56 def HasTRACEV8_4 : Predicate<"Subtarget->hasTRACEV8_4()">,
57 AssemblerPredicate<"FeatureTRACEV8_4", "tracev8.4">;
59 def HasAM : Predicate<"Subtarget->hasAM()">,
60 AssemblerPredicate<"FeatureAM", "am">;
62 def HasSEL2 : Predicate<"Subtarget->hasSEL2()">,
63 AssemblerPredicate<"FeatureSEL2", "sel2">;
65 def HasTLB_RMI : Predicate<"Subtarget->hasTLB_RMI()">,
66 AssemblerPredicate<"FeatureTLB_RMI", "tlb-rmi">;
68 def HasFMI : Predicate<"Subtarget->hasFMI()">,
69 AssemblerPredicate<"FeatureFMI", "fmi">;
71 def HasRCPC_IMMO : Predicate<"Subtarget->hasRCPCImm()">,
72 AssemblerPredicate<"FeatureRCPC_IMMO", "rcpc-immo">;
74 def HasFPARMv8 : Predicate<"Subtarget->hasFPARMv8()">,
75 AssemblerPredicate<"FeatureFPARMv8", "fp-armv8">;
76 def HasNEON : Predicate<"Subtarget->hasNEON()">,
77 AssemblerPredicate<"FeatureNEON", "neon">;
78 def HasCrypto : Predicate<"Subtarget->hasCrypto()">,
79 AssemblerPredicate<"FeatureCrypto", "crypto">;
80 def HasSM4 : Predicate<"Subtarget->hasSM4()">,
81 AssemblerPredicate<"FeatureSM4", "sm4">;
82 def HasSHA3 : Predicate<"Subtarget->hasSHA3()">,
83 AssemblerPredicate<"FeatureSHA3", "sha3">;
84 def HasSHA2 : Predicate<"Subtarget->hasSHA2()">,
85 AssemblerPredicate<"FeatureSHA2", "sha2">;
86 def HasAES : Predicate<"Subtarget->hasAES()">,
87 AssemblerPredicate<"FeatureAES", "aes">;
88 def HasDotProd : Predicate<"Subtarget->hasDotProd()">,
89 AssemblerPredicate<"FeatureDotProd", "dotprod">;
90 def HasCRC : Predicate<"Subtarget->hasCRC()">,
91 AssemblerPredicate<"FeatureCRC", "crc">;
92 def HasLSE : Predicate<"Subtarget->hasLSE()">,
93 AssemblerPredicate<"FeatureLSE", "lse">;
94 def HasRAS : Predicate<"Subtarget->hasRAS()">,
95 AssemblerPredicate<"FeatureRAS", "ras">;
96 def HasRDM : Predicate<"Subtarget->hasRDM()">,
97 AssemblerPredicate<"FeatureRDM", "rdm">;
98 def HasPerfMon : Predicate<"Subtarget->hasPerfMon()">;
99 def HasFullFP16 : Predicate<"Subtarget->hasFullFP16()">,
100 AssemblerPredicate<"FeatureFullFP16", "fullfp16">;
101 def HasFP16FML : Predicate<"Subtarget->hasFP16FML()">,
102 AssemblerPredicate<"FeatureFP16FML", "fp16fml">;
103 def HasSPE : Predicate<"Subtarget->hasSPE()">,
104 AssemblerPredicate<"FeatureSPE", "spe">;
105 def HasFuseAES : Predicate<"Subtarget->hasFuseAES()">,
106 AssemblerPredicate<"FeatureFuseAES",
108 def HasSVE : Predicate<"Subtarget->hasSVE()">,
109 AssemblerPredicate<"FeatureSVE", "sve">;
110 def HasSVE2 : Predicate<"Subtarget->hasSVE2()">,
111 AssemblerPredicate<"FeatureSVE2", "sve2">;
112 def HasSVE2AES : Predicate<"Subtarget->hasSVE2AES()">,
113 AssemblerPredicate<"FeatureSVE2AES", "sve2-aes">;
114 def HasSVE2SM4 : Predicate<"Subtarget->hasSVE2SM4()">,
115 AssemblerPredicate<"FeatureSVE2SM4", "sve2-sm4">;
116 def HasSVE2SHA3 : Predicate<"Subtarget->hasSVE2SHA3()">,
117 AssemblerPredicate<"FeatureSVE2SHA3", "sve2-sha3">;
118 def HasSVE2BitPerm : Predicate<"Subtarget->hasSVE2BitPerm()">,
119 AssemblerPredicate<"FeatureSVE2BitPerm", "sve2-bitperm">;
120 def HasRCPC : Predicate<"Subtarget->hasRCPC()">,
121 AssemblerPredicate<"FeatureRCPC", "rcpc">;
122 def HasAltNZCV : Predicate<"Subtarget->hasAlternativeNZCV()">,
123 AssemblerPredicate<"FeatureAltFPCmp", "altnzcv">;
124 def HasFRInt3264 : Predicate<"Subtarget->hasFRInt3264()">,
125 AssemblerPredicate<"FeatureFRInt3264", "frint3264">;
126 def HasSB : Predicate<"Subtarget->hasSB()">,
127 AssemblerPredicate<"FeatureSB", "sb">;
128 def HasPredRes : Predicate<"Subtarget->hasPredRes()">,
129 AssemblerPredicate<"FeaturePredRes", "predres">;
130 def HasCCDP : Predicate<"Subtarget->hasCCDP()">,
131 AssemblerPredicate<"FeatureCacheDeepPersist", "ccdp">;
132 def HasBTI : Predicate<"Subtarget->hasBTI()">,
133 AssemblerPredicate<"FeatureBranchTargetId", "bti">;
134 def HasMTE : Predicate<"Subtarget->hasMTE()">,
135 AssemblerPredicate<"FeatureMTE", "mte">;
136 def HasETE : Predicate<"Subtarget->hasETE()">,
137 AssemblerPredicate<"FeatureETE", "ete">;
138 def HasTRBE : Predicate<"Subtarget->hasTRBE()">,
139 AssemblerPredicate<"FeatureTRBE", "trbe">;
140 def IsLE : Predicate<"Subtarget->isLittleEndian()">;
141 def IsBE : Predicate<"!Subtarget->isLittleEndian()">;
142 def IsWindows : Predicate<"Subtarget->isTargetWindows()">;
143 def UseAlternateSExtLoadCVTF32
144 : Predicate<"Subtarget->useAlternateSExtLoadCVTF32Pattern()">;
146 def UseNegativeImmediates
147 : Predicate<"false">, AssemblerPredicate<"!FeatureNoNegativeImmediates",
148 "NegativeImmediates">;
150 def AArch64LocalRecover : SDNode<"ISD::LOCAL_RECOVER",
151 SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>,
155 //===----------------------------------------------------------------------===//
156 // AArch64-specific DAG Nodes.
159 // SDTBinaryArithWithFlagsOut - RES1, FLAGS = op LHS, RHS
160 def SDTBinaryArithWithFlagsOut : SDTypeProfile<2, 2,
163 SDTCisInt<0>, SDTCisVT<1, i32>]>;
165 // SDTBinaryArithWithFlagsIn - RES1, FLAGS = op LHS, RHS, FLAGS
166 def SDTBinaryArithWithFlagsIn : SDTypeProfile<1, 3,
172 // SDTBinaryArithWithFlagsInOut - RES1, FLAGS = op LHS, RHS, FLAGS
173 def SDTBinaryArithWithFlagsInOut : SDTypeProfile<2, 3,
180 def SDT_AArch64Brcond : SDTypeProfile<0, 3,
181 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i32>,
183 def SDT_AArch64cbz : SDTypeProfile<0, 2, [SDTCisInt<0>, SDTCisVT<1, OtherVT>]>;
184 def SDT_AArch64tbz : SDTypeProfile<0, 3, [SDTCisInt<0>, SDTCisInt<1>,
185 SDTCisVT<2, OtherVT>]>;
188 def SDT_AArch64CSel : SDTypeProfile<1, 4,
193 def SDT_AArch64CCMP : SDTypeProfile<1, 5,
200 def SDT_AArch64FCCMP : SDTypeProfile<1, 5,
207 def SDT_AArch64FCmp : SDTypeProfile<0, 2,
209 SDTCisSameAs<0, 1>]>;
210 def SDT_AArch64Dup : SDTypeProfile<1, 1, [SDTCisVec<0>]>;
211 def SDT_AArch64DupLane : SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisInt<2>]>;
212 def SDT_AArch64Zip : SDTypeProfile<1, 2, [SDTCisVec<0>,
214 SDTCisSameAs<0, 2>]>;
215 def SDT_AArch64MOVIedit : SDTypeProfile<1, 1, [SDTCisInt<1>]>;
216 def SDT_AArch64MOVIshift : SDTypeProfile<1, 2, [SDTCisInt<1>, SDTCisInt<2>]>;
217 def SDT_AArch64vecimm : SDTypeProfile<1, 3, [SDTCisVec<0>, SDTCisSameAs<0,1>,
218 SDTCisInt<2>, SDTCisInt<3>]>;
219 def SDT_AArch64UnaryVec: SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisSameAs<0,1>]>;
220 def SDT_AArch64ExtVec: SDTypeProfile<1, 3, [SDTCisVec<0>, SDTCisSameAs<0,1>,
221 SDTCisSameAs<0,2>, SDTCisInt<3>]>;
222 def SDT_AArch64vshift : SDTypeProfile<1, 2, [SDTCisSameAs<0,1>, SDTCisInt<2>]>;
224 def SDT_AArch64unvec : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisSameAs<0,1>]>;
225 def SDT_AArch64fcmpz : SDTypeProfile<1, 1, []>;
226 def SDT_AArch64fcmp : SDTypeProfile<1, 2, [SDTCisSameAs<1,2>]>;
227 def SDT_AArch64binvec : SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisSameAs<0,1>,
229 def SDT_AArch64trivec : SDTypeProfile<1, 3, [SDTCisVec<0>, SDTCisSameAs<0,1>,
232 def SDT_AArch64TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>]>;
233 def SDT_AArch64PREFETCH : SDTypeProfile<0, 2, [SDTCisVT<0, i32>, SDTCisPtrTy<1>]>;
235 def SDT_AArch64ITOF : SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisSameAs<0,1>]>;
237 def SDT_AArch64TLSDescCall : SDTypeProfile<0, -2, [SDTCisPtrTy<0>,
240 // Generates the general dynamic sequences, i.e.
241 // adrp x0, :tlsdesc:var
242 // ldr x1, [x0, #:tlsdesc_lo12:var]
243 // add x0, x0, #:tlsdesc_lo12:var
247 // (the TPIDR_EL0 offset is put directly in X0, hence no "result" here)
248 // number of operands (the variable)
249 def SDT_AArch64TLSDescCallSeq : SDTypeProfile<0,1,
252 def SDT_AArch64WrapperLarge : SDTypeProfile<1, 4,
253 [SDTCisVT<0, i64>, SDTCisVT<1, i32>,
254 SDTCisSameAs<1, 2>, SDTCisSameAs<1, 3>,
255 SDTCisSameAs<1, 4>]>;
259 def AArch64adrp : SDNode<"AArch64ISD::ADRP", SDTIntUnaryOp, []>;
260 def AArch64adr : SDNode<"AArch64ISD::ADR", SDTIntUnaryOp, []>;
261 def AArch64addlow : SDNode<"AArch64ISD::ADDlow", SDTIntBinOp, []>;
262 def AArch64LOADgot : SDNode<"AArch64ISD::LOADgot", SDTIntUnaryOp>;
263 def AArch64callseq_start : SDNode<"ISD::CALLSEQ_START",
264 SDCallSeqStart<[ SDTCisVT<0, i32>,
266 [SDNPHasChain, SDNPOutGlue]>;
267 def AArch64callseq_end : SDNode<"ISD::CALLSEQ_END",
268 SDCallSeqEnd<[ SDTCisVT<0, i32>,
270 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
271 def AArch64call : SDNode<"AArch64ISD::CALL",
272 SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>,
273 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
275 def AArch64brcond : SDNode<"AArch64ISD::BRCOND", SDT_AArch64Brcond,
277 def AArch64cbz : SDNode<"AArch64ISD::CBZ", SDT_AArch64cbz,
279 def AArch64cbnz : SDNode<"AArch64ISD::CBNZ", SDT_AArch64cbz,
281 def AArch64tbz : SDNode<"AArch64ISD::TBZ", SDT_AArch64tbz,
283 def AArch64tbnz : SDNode<"AArch64ISD::TBNZ", SDT_AArch64tbz,
287 def AArch64csel : SDNode<"AArch64ISD::CSEL", SDT_AArch64CSel>;
288 def AArch64csinv : SDNode<"AArch64ISD::CSINV", SDT_AArch64CSel>;
289 def AArch64csneg : SDNode<"AArch64ISD::CSNEG", SDT_AArch64CSel>;
290 def AArch64csinc : SDNode<"AArch64ISD::CSINC", SDT_AArch64CSel>;
291 def AArch64retflag : SDNode<"AArch64ISD::RET_FLAG", SDTNone,
292 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
293 def AArch64adc : SDNode<"AArch64ISD::ADC", SDTBinaryArithWithFlagsIn >;
294 def AArch64sbc : SDNode<"AArch64ISD::SBC", SDTBinaryArithWithFlagsIn>;
295 def AArch64add_flag : SDNode<"AArch64ISD::ADDS", SDTBinaryArithWithFlagsOut,
297 def AArch64sub_flag : SDNode<"AArch64ISD::SUBS", SDTBinaryArithWithFlagsOut>;
298 def AArch64and_flag : SDNode<"AArch64ISD::ANDS", SDTBinaryArithWithFlagsOut,
300 def AArch64adc_flag : SDNode<"AArch64ISD::ADCS", SDTBinaryArithWithFlagsInOut>;
301 def AArch64sbc_flag : SDNode<"AArch64ISD::SBCS", SDTBinaryArithWithFlagsInOut>;
303 def AArch64ccmp : SDNode<"AArch64ISD::CCMP", SDT_AArch64CCMP>;
304 def AArch64ccmn : SDNode<"AArch64ISD::CCMN", SDT_AArch64CCMP>;
305 def AArch64fccmp : SDNode<"AArch64ISD::FCCMP", SDT_AArch64FCCMP>;
307 def AArch64threadpointer : SDNode<"AArch64ISD::THREAD_POINTER", SDTPtrLeaf>;
309 def AArch64fcmp : SDNode<"AArch64ISD::FCMP", SDT_AArch64FCmp>;
311 def AArch64dup : SDNode<"AArch64ISD::DUP", SDT_AArch64Dup>;
312 def AArch64duplane8 : SDNode<"AArch64ISD::DUPLANE8", SDT_AArch64DupLane>;
313 def AArch64duplane16 : SDNode<"AArch64ISD::DUPLANE16", SDT_AArch64DupLane>;
314 def AArch64duplane32 : SDNode<"AArch64ISD::DUPLANE32", SDT_AArch64DupLane>;
315 def AArch64duplane64 : SDNode<"AArch64ISD::DUPLANE64", SDT_AArch64DupLane>;
317 def AArch64zip1 : SDNode<"AArch64ISD::ZIP1", SDT_AArch64Zip>;
318 def AArch64zip2 : SDNode<"AArch64ISD::ZIP2", SDT_AArch64Zip>;
319 def AArch64uzp1 : SDNode<"AArch64ISD::UZP1", SDT_AArch64Zip>;
320 def AArch64uzp2 : SDNode<"AArch64ISD::UZP2", SDT_AArch64Zip>;
321 def AArch64trn1 : SDNode<"AArch64ISD::TRN1", SDT_AArch64Zip>;
322 def AArch64trn2 : SDNode<"AArch64ISD::TRN2", SDT_AArch64Zip>;
324 def AArch64movi_edit : SDNode<"AArch64ISD::MOVIedit", SDT_AArch64MOVIedit>;
325 def AArch64movi_shift : SDNode<"AArch64ISD::MOVIshift", SDT_AArch64MOVIshift>;
326 def AArch64movi_msl : SDNode<"AArch64ISD::MOVImsl", SDT_AArch64MOVIshift>;
327 def AArch64mvni_shift : SDNode<"AArch64ISD::MVNIshift", SDT_AArch64MOVIshift>;
328 def AArch64mvni_msl : SDNode<"AArch64ISD::MVNImsl", SDT_AArch64MOVIshift>;
329 def AArch64movi : SDNode<"AArch64ISD::MOVI", SDT_AArch64MOVIedit>;
330 def AArch64fmov : SDNode<"AArch64ISD::FMOV", SDT_AArch64MOVIedit>;
332 def AArch64rev16 : SDNode<"AArch64ISD::REV16", SDT_AArch64UnaryVec>;
333 def AArch64rev32 : SDNode<"AArch64ISD::REV32", SDT_AArch64UnaryVec>;
334 def AArch64rev64 : SDNode<"AArch64ISD::REV64", SDT_AArch64UnaryVec>;
335 def AArch64ext : SDNode<"AArch64ISD::EXT", SDT_AArch64ExtVec>;
337 def AArch64vashr : SDNode<"AArch64ISD::VASHR", SDT_AArch64vshift>;
338 def AArch64vlshr : SDNode<"AArch64ISD::VLSHR", SDT_AArch64vshift>;
339 def AArch64vshl : SDNode<"AArch64ISD::VSHL", SDT_AArch64vshift>;
340 def AArch64sqshli : SDNode<"AArch64ISD::SQSHL_I", SDT_AArch64vshift>;
341 def AArch64uqshli : SDNode<"AArch64ISD::UQSHL_I", SDT_AArch64vshift>;
342 def AArch64sqshlui : SDNode<"AArch64ISD::SQSHLU_I", SDT_AArch64vshift>;
343 def AArch64srshri : SDNode<"AArch64ISD::SRSHR_I", SDT_AArch64vshift>;
344 def AArch64urshri : SDNode<"AArch64ISD::URSHR_I", SDT_AArch64vshift>;
346 def AArch64not: SDNode<"AArch64ISD::NOT", SDT_AArch64unvec>;
347 def AArch64bit: SDNode<"AArch64ISD::BIT", SDT_AArch64trivec>;
348 def AArch64bsl: SDNode<"AArch64ISD::BSL", SDT_AArch64trivec>;
350 def AArch64cmeq: SDNode<"AArch64ISD::CMEQ", SDT_AArch64binvec>;
351 def AArch64cmge: SDNode<"AArch64ISD::CMGE", SDT_AArch64binvec>;
352 def AArch64cmgt: SDNode<"AArch64ISD::CMGT", SDT_AArch64binvec>;
353 def AArch64cmhi: SDNode<"AArch64ISD::CMHI", SDT_AArch64binvec>;
354 def AArch64cmhs: SDNode<"AArch64ISD::CMHS", SDT_AArch64binvec>;
356 def AArch64fcmeq: SDNode<"AArch64ISD::FCMEQ", SDT_AArch64fcmp>;
357 def AArch64fcmge: SDNode<"AArch64ISD::FCMGE", SDT_AArch64fcmp>;
358 def AArch64fcmgt: SDNode<"AArch64ISD::FCMGT", SDT_AArch64fcmp>;
360 def AArch64cmeqz: SDNode<"AArch64ISD::CMEQz", SDT_AArch64unvec>;
361 def AArch64cmgez: SDNode<"AArch64ISD::CMGEz", SDT_AArch64unvec>;
362 def AArch64cmgtz: SDNode<"AArch64ISD::CMGTz", SDT_AArch64unvec>;
363 def AArch64cmlez: SDNode<"AArch64ISD::CMLEz", SDT_AArch64unvec>;
364 def AArch64cmltz: SDNode<"AArch64ISD::CMLTz", SDT_AArch64unvec>;
365 def AArch64cmtst : PatFrag<(ops node:$LHS, node:$RHS),
366 (AArch64not (AArch64cmeqz (and node:$LHS, node:$RHS)))>;
368 def AArch64fcmeqz: SDNode<"AArch64ISD::FCMEQz", SDT_AArch64fcmpz>;
369 def AArch64fcmgez: SDNode<"AArch64ISD::FCMGEz", SDT_AArch64fcmpz>;
370 def AArch64fcmgtz: SDNode<"AArch64ISD::FCMGTz", SDT_AArch64fcmpz>;
371 def AArch64fcmlez: SDNode<"AArch64ISD::FCMLEz", SDT_AArch64fcmpz>;
372 def AArch64fcmltz: SDNode<"AArch64ISD::FCMLTz", SDT_AArch64fcmpz>;
374 def AArch64bici: SDNode<"AArch64ISD::BICi", SDT_AArch64vecimm>;
375 def AArch64orri: SDNode<"AArch64ISD::ORRi", SDT_AArch64vecimm>;
377 def AArch64neg : SDNode<"AArch64ISD::NEG", SDT_AArch64unvec>;
379 def AArch64tcret: SDNode<"AArch64ISD::TC_RETURN", SDT_AArch64TCRET,
380 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
382 def AArch64Prefetch : SDNode<"AArch64ISD::PREFETCH", SDT_AArch64PREFETCH,
383 [SDNPHasChain, SDNPSideEffect]>;
385 def AArch64sitof: SDNode<"AArch64ISD::SITOF", SDT_AArch64ITOF>;
386 def AArch64uitof: SDNode<"AArch64ISD::UITOF", SDT_AArch64ITOF>;
388 def AArch64tlsdesc_callseq : SDNode<"AArch64ISD::TLSDESC_CALLSEQ",
389 SDT_AArch64TLSDescCallSeq,
390 [SDNPInGlue, SDNPOutGlue, SDNPHasChain,
394 def AArch64WrapperLarge : SDNode<"AArch64ISD::WrapperLarge",
395 SDT_AArch64WrapperLarge>;
397 def AArch64NvCast : SDNode<"AArch64ISD::NVCAST", SDTUnaryOp>;
399 def SDT_AArch64mull : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisInt<1>,
400 SDTCisSameAs<1, 2>]>;
401 def AArch64smull : SDNode<"AArch64ISD::SMULL", SDT_AArch64mull>;
402 def AArch64umull : SDNode<"AArch64ISD::UMULL", SDT_AArch64mull>;
404 def AArch64frecpe : SDNode<"AArch64ISD::FRECPE", SDTFPUnaryOp>;
405 def AArch64frecps : SDNode<"AArch64ISD::FRECPS", SDTFPBinOp>;
406 def AArch64frsqrte : SDNode<"AArch64ISD::FRSQRTE", SDTFPUnaryOp>;
407 def AArch64frsqrts : SDNode<"AArch64ISD::FRSQRTS", SDTFPBinOp>;
409 def AArch64saddv : SDNode<"AArch64ISD::SADDV", SDT_AArch64UnaryVec>;
410 def AArch64uaddv : SDNode<"AArch64ISD::UADDV", SDT_AArch64UnaryVec>;
411 def AArch64sminv : SDNode<"AArch64ISD::SMINV", SDT_AArch64UnaryVec>;
412 def AArch64uminv : SDNode<"AArch64ISD::UMINV", SDT_AArch64UnaryVec>;
413 def AArch64smaxv : SDNode<"AArch64ISD::SMAXV", SDT_AArch64UnaryVec>;
414 def AArch64umaxv : SDNode<"AArch64ISD::UMAXV", SDT_AArch64UnaryVec>;
416 def SDT_AArch64SETTAG : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisPtrTy<1>]>;
417 def AArch64stg : SDNode<"AArch64ISD::STG", SDT_AArch64SETTAG, [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
418 def AArch64stzg : SDNode<"AArch64ISD::STZG", SDT_AArch64SETTAG, [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
419 def AArch64st2g : SDNode<"AArch64ISD::ST2G", SDT_AArch64SETTAG, [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
420 def AArch64stz2g : SDNode<"AArch64ISD::STZ2G", SDT_AArch64SETTAG, [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
422 //===----------------------------------------------------------------------===//
424 //===----------------------------------------------------------------------===//
426 // AArch64 Instruction Predicate Definitions.
427 // We could compute these on a per-module basis but doing so requires accessing
428 // the Function object through the <Target>Subtarget and objections were raised
429 // to that (see post-commit review comments for r301750).
430 let RecomputePerFunction = 1 in {
431 def ForCodeSize : Predicate<"MF->getFunction().hasOptSize()">;
432 def NotForCodeSize : Predicate<"!MF->getFunction().hasOptSize()">;
433 // Avoid generating STRQro if it is slow, unless we're optimizing for code size.
434 def UseSTRQro : Predicate<"!Subtarget->isSTRQroSlow() || MF->getFunction().hasOptSize()">;
436 def UseBTI : Predicate<[{ MF->getFunction().hasFnAttribute("branch-target-enforcement") }]>;
437 def NotUseBTI : Predicate<[{ !MF->getFunction().hasFnAttribute("branch-target-enforcement") }]>;
440 include "AArch64InstrFormats.td"
441 include "SVEInstrFormats.td"
443 //===----------------------------------------------------------------------===//
445 //===----------------------------------------------------------------------===//
446 // Miscellaneous instructions.
447 //===----------------------------------------------------------------------===//
449 let Defs = [SP], Uses = [SP], hasSideEffects = 1, isCodeGenOnly = 1 in {
450 // We set Sched to empty list because we expect these instructions to simply get
451 // removed in most cases.
452 def ADJCALLSTACKDOWN : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
453 [(AArch64callseq_start timm:$amt1, timm:$amt2)]>,
455 def ADJCALLSTACKUP : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
456 [(AArch64callseq_end timm:$amt1, timm:$amt2)]>,
458 } // Defs = [SP], Uses = [SP], hasSideEffects = 1, isCodeGenOnly = 1
460 let isReMaterializable = 1, isCodeGenOnly = 1 in {
461 // FIXME: The following pseudo instructions are only needed because remat
462 // cannot handle multiple instructions. When that changes, they can be
463 // removed, along with the AArch64Wrapper node.
465 let AddedComplexity = 10 in
466 def LOADgot : Pseudo<(outs GPR64:$dst), (ins i64imm:$addr),
467 [(set GPR64:$dst, (AArch64LOADgot tglobaladdr:$addr))]>,
470 // The MOVaddr instruction should match only when the add is not folded
471 // into a load or store address.
473 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
474 [(set GPR64:$dst, (AArch64addlow (AArch64adrp tglobaladdr:$hi),
475 tglobaladdr:$low))]>,
476 Sched<[WriteAdrAdr]>;
478 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
479 [(set GPR64:$dst, (AArch64addlow (AArch64adrp tjumptable:$hi),
481 Sched<[WriteAdrAdr]>;
483 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
484 [(set GPR64:$dst, (AArch64addlow (AArch64adrp tconstpool:$hi),
486 Sched<[WriteAdrAdr]>;
488 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
489 [(set GPR64:$dst, (AArch64addlow (AArch64adrp tblockaddress:$hi),
490 tblockaddress:$low))]>,
491 Sched<[WriteAdrAdr]>;
493 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
494 [(set GPR64:$dst, (AArch64addlow (AArch64adrp tglobaltlsaddr:$hi),
495 tglobaltlsaddr:$low))]>,
496 Sched<[WriteAdrAdr]>;
498 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
499 [(set GPR64:$dst, (AArch64addlow (AArch64adrp texternalsym:$hi),
500 texternalsym:$low))]>,
501 Sched<[WriteAdrAdr]>;
502 // Normally AArch64addlow either gets folded into a following ldr/str,
503 // or together with an adrp into MOVaddr above. For cases with TLS, it
504 // might appear without either of them, so allow lowering it into a plain
507 : Pseudo<(outs GPR64:$dst), (ins GPR64:$src, i64imm:$low),
508 [(set GPR64:$dst, (AArch64addlow GPR64:$src,
509 tglobaltlsaddr:$low))]>,
512 } // isReMaterializable, isCodeGenOnly
514 def : Pat<(AArch64LOADgot tglobaltlsaddr:$addr),
515 (LOADgot tglobaltlsaddr:$addr)>;
517 def : Pat<(AArch64LOADgot texternalsym:$addr),
518 (LOADgot texternalsym:$addr)>;
520 def : Pat<(AArch64LOADgot tconstpool:$addr),
521 (LOADgot tconstpool:$addr)>;
523 // 32-bit jump table destination is actually only 2 instructions since we can
524 // use the table itself as a PC-relative base. But optimization occurs after
525 // branch relaxation so be pessimistic.
526 let Size = 12, Constraints = "@earlyclobber $dst,@earlyclobber $scratch" in {
527 def JumpTableDest32 : Pseudo<(outs GPR64:$dst, GPR64sp:$scratch),
528 (ins GPR64:$table, GPR64:$entry, i32imm:$jti), []>,
530 def JumpTableDest16 : Pseudo<(outs GPR64:$dst, GPR64sp:$scratch),
531 (ins GPR64:$table, GPR64:$entry, i32imm:$jti), []>,
533 def JumpTableDest8 : Pseudo<(outs GPR64:$dst, GPR64sp:$scratch),
534 (ins GPR64:$table, GPR64:$entry, i32imm:$jti), []>,
538 // Space-consuming pseudo to aid testing of placement and reachability
539 // algorithms. Immediate operand is the number of bytes this "instruction"
540 // occupies; register operands can be used to enforce dependency and constrain
542 let hasSideEffects = 1, mayLoad = 1, mayStore = 1 in
543 def SPACE : Pseudo<(outs GPR64:$Rd), (ins i32imm:$size, GPR64:$Rn),
544 [(set GPR64:$Rd, (int_aarch64_space imm:$size, GPR64:$Rn))]>,
547 let hasSideEffects = 1, isCodeGenOnly = 1 in {
548 def SpeculationSafeValueX
549 : Pseudo<(outs GPR64:$dst), (ins GPR64:$src), []>, Sched<[]>;
550 def SpeculationSafeValueW
551 : Pseudo<(outs GPR32:$dst), (ins GPR32:$src), []>, Sched<[]>;
555 //===----------------------------------------------------------------------===//
556 // System instructions.
557 //===----------------------------------------------------------------------===//
559 def HINT : HintI<"hint">;
560 def : InstAlias<"nop", (HINT 0b000)>;
561 def : InstAlias<"yield",(HINT 0b001)>;
562 def : InstAlias<"wfe", (HINT 0b010)>;
563 def : InstAlias<"wfi", (HINT 0b011)>;
564 def : InstAlias<"sev", (HINT 0b100)>;
565 def : InstAlias<"sevl", (HINT 0b101)>;
566 def : InstAlias<"esb", (HINT 0b10000)>, Requires<[HasRAS]>;
567 def : InstAlias<"csdb", (HINT 20)>;
568 def : InstAlias<"bti", (HINT 32)>, Requires<[HasBTI]>;
569 def : InstAlias<"bti $op", (HINT btihint_op:$op)>, Requires<[HasBTI]>;
571 // v8.2a Statistical Profiling extension
572 def : InstAlias<"psb $op", (HINT psbhint_op:$op)>, Requires<[HasSPE]>;
574 // As far as LLVM is concerned this writes to the system's exclusive monitors.
575 let mayLoad = 1, mayStore = 1 in
576 def CLREX : CRmSystemI<imm0_15, 0b010, "clrex">;
578 // NOTE: ideally, this would have mayStore = 0, mayLoad = 0, but we cannot
579 // model patterns with sufficiently fine granularity.
580 let mayLoad = ?, mayStore = ? in {
581 def DMB : CRmSystemI<barrier_op, 0b101, "dmb",
582 [(int_aarch64_dmb (i32 imm32_0_15:$CRm))]>;
584 def DSB : CRmSystemI<barrier_op, 0b100, "dsb",
585 [(int_aarch64_dsb (i32 imm32_0_15:$CRm))]>;
587 def ISB : CRmSystemI<barrier_op, 0b110, "isb",
588 [(int_aarch64_isb (i32 imm32_0_15:$CRm))]>;
590 def TSB : CRmSystemI<barrier_op, 0b010, "tsb", []> {
593 let Predicates = [HasTRACEV8_4];
597 // ARMv8.2-A Dot Product
598 let Predicates = [HasDotProd] in {
599 defm SDOT : SIMDThreeSameVectorDot<0, "sdot", int_aarch64_neon_sdot>;
600 defm UDOT : SIMDThreeSameVectorDot<1, "udot", int_aarch64_neon_udot>;
601 defm SDOTlane : SIMDThreeSameVectorDotIndex<0, "sdot", int_aarch64_neon_sdot>;
602 defm UDOTlane : SIMDThreeSameVectorDotIndex<1, "udot", int_aarch64_neon_udot>;
605 // ARMv8.2-A FP16 Fused Multiply-Add Long
606 let Predicates = [HasNEON, HasFP16FML] in {
607 defm FMLAL : SIMDThreeSameVectorFML<0, 1, 0b001, "fmlal", int_aarch64_neon_fmlal>;
608 defm FMLSL : SIMDThreeSameVectorFML<0, 1, 0b101, "fmlsl", int_aarch64_neon_fmlsl>;
609 defm FMLAL2 : SIMDThreeSameVectorFML<1, 0, 0b001, "fmlal2", int_aarch64_neon_fmlal2>;
610 defm FMLSL2 : SIMDThreeSameVectorFML<1, 0, 0b101, "fmlsl2", int_aarch64_neon_fmlsl2>;
611 defm FMLALlane : SIMDThreeSameVectorFMLIndex<0, 0b0000, "fmlal", int_aarch64_neon_fmlal>;
612 defm FMLSLlane : SIMDThreeSameVectorFMLIndex<0, 0b0100, "fmlsl", int_aarch64_neon_fmlsl>;
613 defm FMLAL2lane : SIMDThreeSameVectorFMLIndex<1, 0b1000, "fmlal2", int_aarch64_neon_fmlal2>;
614 defm FMLSL2lane : SIMDThreeSameVectorFMLIndex<1, 0b1100, "fmlsl2", int_aarch64_neon_fmlsl2>;
617 // Armv8.2-A Crypto extensions
618 let Predicates = [HasSHA3] in {
619 def SHA512H : CryptoRRRTied<0b0, 0b00, "sha512h">;
620 def SHA512H2 : CryptoRRRTied<0b0, 0b01, "sha512h2">;
621 def SHA512SU0 : CryptoRRTied_2D<0b0, 0b00, "sha512su0">;
622 def SHA512SU1 : CryptoRRRTied_2D<0b0, 0b10, "sha512su1">;
623 def RAX1 : CryptoRRR_2D<0b0,0b11, "rax1">;
624 def EOR3 : CryptoRRRR_16B<0b00, "eor3">;
625 def BCAX : CryptoRRRR_16B<0b01, "bcax">;
626 def XAR : CryptoRRRi6<"xar">;
629 let Predicates = [HasSM4] in {
630 def SM3TT1A : CryptoRRRi2Tied<0b0, 0b00, "sm3tt1a">;
631 def SM3TT1B : CryptoRRRi2Tied<0b0, 0b01, "sm3tt1b">;
632 def SM3TT2A : CryptoRRRi2Tied<0b0, 0b10, "sm3tt2a">;
633 def SM3TT2B : CryptoRRRi2Tied<0b0, 0b11, "sm3tt2b">;
634 def SM3SS1 : CryptoRRRR_4S<0b10, "sm3ss1">;
635 def SM3PARTW1 : CryptoRRRTied_4S<0b1, 0b00, "sm3partw1">;
636 def SM3PARTW2 : CryptoRRRTied_4S<0b1, 0b01, "sm3partw2">;
637 def SM4ENCKEY : CryptoRRR_4S<0b1, 0b10, "sm4ekey">;
638 def SM4E : CryptoRRTied_4S<0b0, 0b01, "sm4e">;
641 let Predicates = [HasRCPC] in {
642 // v8.3 Release Consistent Processor Consistent support, optional in v8.2.
643 def LDAPRB : RCPCLoad<0b00, "ldaprb", GPR32>;
644 def LDAPRH : RCPCLoad<0b01, "ldaprh", GPR32>;
645 def LDAPRW : RCPCLoad<0b10, "ldapr", GPR32>;
646 def LDAPRX : RCPCLoad<0b11, "ldapr", GPR64>;
649 // v8.3a complex add and multiply-accumulate. No predicate here, that is done
650 // inside the multiclass as the FP16 versions need different predicates.
651 defm FCMLA : SIMDThreeSameVectorTiedComplexHSD<1, 0b110, complexrotateop,
653 defm FCADD : SIMDThreeSameVectorComplexHSD<1, 0b111, complexrotateopodd,
655 defm FCMLA : SIMDIndexedTiedComplexHSD<1, 0, 1, complexrotateop, "fcmla",
658 // v8.3a Pointer Authentication
659 // These instructions inhabit part of the hint space and so can be used for
661 let Uses = [LR], Defs = [LR] in {
662 def PACIAZ : SystemNoOperands<0b000, "paciaz">;
663 def PACIBZ : SystemNoOperands<0b010, "pacibz">;
664 def AUTIAZ : SystemNoOperands<0b100, "autiaz">;
665 def AUTIBZ : SystemNoOperands<0b110, "autibz">;
667 let Uses = [LR, SP], Defs = [LR] in {
668 def PACIASP : SystemNoOperands<0b001, "paciasp">;
669 def PACIBSP : SystemNoOperands<0b011, "pacibsp">;
670 def AUTIASP : SystemNoOperands<0b101, "autiasp">;
671 def AUTIBSP : SystemNoOperands<0b111, "autibsp">;
673 let Uses = [X16, X17], Defs = [X17], CRm = 0b0001 in {
674 def PACIA1716 : SystemNoOperands<0b000, "pacia1716">;
675 def PACIB1716 : SystemNoOperands<0b010, "pacib1716">;
676 def AUTIA1716 : SystemNoOperands<0b100, "autia1716">;
677 def AUTIB1716 : SystemNoOperands<0b110, "autib1716">;
680 let Uses = [LR], Defs = [LR], CRm = 0b0000 in {
681 def XPACLRI : SystemNoOperands<0b111, "xpaclri">;
684 // These pointer authentication isntructions require armv8.3a
685 let Predicates = [HasPA] in {
686 multiclass SignAuth<bits<3> prefix, bits<3> prefix_z, string asm> {
687 def IA : SignAuthOneData<prefix, 0b00, !strconcat(asm, "ia")>;
688 def IB : SignAuthOneData<prefix, 0b01, !strconcat(asm, "ib")>;
689 def DA : SignAuthOneData<prefix, 0b10, !strconcat(asm, "da")>;
690 def DB : SignAuthOneData<prefix, 0b11, !strconcat(asm, "db")>;
691 def IZA : SignAuthZero<prefix_z, 0b00, !strconcat(asm, "iza")>;
692 def DZA : SignAuthZero<prefix_z, 0b10, !strconcat(asm, "dza")>;
693 def IZB : SignAuthZero<prefix_z, 0b01, !strconcat(asm, "izb")>;
694 def DZB : SignAuthZero<prefix_z, 0b11, !strconcat(asm, "dzb")>;
697 defm PAC : SignAuth<0b000, 0b010, "pac">;
698 defm AUT : SignAuth<0b001, 0b011, "aut">;
700 def XPACI : SignAuthZero<0b100, 0b00, "xpaci">;
701 def XPACD : SignAuthZero<0b100, 0b01, "xpacd">;
702 def PACGA : SignAuthTwoOperand<0b1100, "pacga", null_frag>;
704 // Combined Instructions
705 def BRAA : AuthBranchTwoOperands<0, 0, "braa">;
706 def BRAB : AuthBranchTwoOperands<0, 1, "brab">;
707 def BLRAA : AuthBranchTwoOperands<1, 0, "blraa">;
708 def BLRAB : AuthBranchTwoOperands<1, 1, "blrab">;
710 def BRAAZ : AuthOneOperand<0b000, 0, "braaz">;
711 def BRABZ : AuthOneOperand<0b000, 1, "brabz">;
712 def BLRAAZ : AuthOneOperand<0b001, 0, "blraaz">;
713 def BLRABZ : AuthOneOperand<0b001, 1, "blrabz">;
715 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
716 def RETAA : AuthReturn<0b010, 0, "retaa">;
717 def RETAB : AuthReturn<0b010, 1, "retab">;
718 def ERETAA : AuthReturn<0b100, 0, "eretaa">;
719 def ERETAB : AuthReturn<0b100, 1, "eretab">;
722 defm LDRAA : AuthLoad<0, "ldraa", simm10Scaled>;
723 defm LDRAB : AuthLoad<1, "ldrab", simm10Scaled>;
727 // v8.3a floating point conversion for javascript
728 let Predicates = [HasJS, HasFPARMv8] in
729 def FJCVTZS : BaseFPToIntegerUnscaled<0b01, 0b11, 0b110, FPR64, GPR32,
732 (int_aarch64_fjcvtzs FPR64:$Rn))]> {
734 } // HasJS, HasFPARMv8
736 // v8.4 Flag manipulation instructions
737 let Predicates = [HasFMI] in {
738 def CFINV : SimpleSystemI<0, (ins), "cfinv", "">, Sched<[WriteSys]> {
739 let Inst{20-5} = 0b0000001000000000;
741 def SETF8 : BaseFlagManipulation<0, 0, (ins GPR32:$Rn), "setf8", "{\t$Rn}">;
742 def SETF16 : BaseFlagManipulation<0, 1, (ins GPR32:$Rn), "setf16", "{\t$Rn}">;
743 def RMIF : FlagRotate<(ins GPR64:$Rn, uimm6:$imm, imm0_15:$mask), "rmif",
744 "{\t$Rn, $imm, $mask}">;
747 // v8.5 flag manipulation instructions
748 let Predicates = [HasAltNZCV], Uses = [NZCV], Defs = [NZCV] in {
750 def XAFLAG : PstateWriteSimple<(ins), "xaflag", "">, Sched<[WriteSys]> {
751 let Inst{18-16} = 0b000;
752 let Inst{11-8} = 0b0000;
753 let Unpredictable{11-8} = 0b1111;
754 let Inst{7-5} = 0b001;
757 def AXFLAG : PstateWriteSimple<(ins), "axflag", "">, Sched<[WriteSys]> {
758 let Inst{18-16} = 0b000;
759 let Inst{11-8} = 0b0000;
760 let Unpredictable{11-8} = 0b1111;
761 let Inst{7-5} = 0b010;
766 // Armv8.5-A speculation barrier
767 def SB : SimpleSystemI<0, (ins), "sb", "">, Sched<[]> {
768 let Inst{20-5} = 0b0001100110000111;
769 let Unpredictable{11-8} = 0b1111;
770 let Predicates = [HasSB];
771 let hasSideEffects = 1;
774 def : InstAlias<"clrex", (CLREX 0xf)>;
775 def : InstAlias<"isb", (ISB 0xf)>;
776 def : InstAlias<"ssbb", (DSB 0)>;
777 def : InstAlias<"pssbb", (DSB 4)>;
781 def MSRpstateImm1 : MSRpstateImm0_1;
782 def MSRpstateImm4 : MSRpstateImm0_15;
784 // The thread pointer (on Linux, at least, where this has been implemented) is
786 def MOVbaseTLS : Pseudo<(outs GPR64:$dst), (ins),
787 [(set GPR64:$dst, AArch64threadpointer)]>, Sched<[WriteSys]>;
789 let Uses = [ X9 ], Defs = [ X16, X17, LR, NZCV ] in {
790 def HWASAN_CHECK_MEMACCESS : Pseudo<
791 (outs), (ins GPR64noip:$ptr, i32imm:$accessinfo),
792 [(int_hwasan_check_memaccess X9, GPR64noip:$ptr, (i32 imm:$accessinfo))]>,
796 // The cycle counter PMC register is PMCCNTR_EL0.
797 let Predicates = [HasPerfMon] in
798 def : Pat<(readcyclecounter), (MRS 0xdce8)>;
801 def : Pat<(i64 (int_aarch64_get_fpcr)), (MRS 0xda20)>;
803 // Generic system instructions
804 def SYSxt : SystemXtI<0, "sys">;
805 def SYSLxt : SystemLXtI<1, "sysl">;
807 def : InstAlias<"sys $op1, $Cn, $Cm, $op2",
808 (SYSxt imm0_7:$op1, sys_cr_op:$Cn,
809 sys_cr_op:$Cm, imm0_7:$op2, XZR)>;
811 //===----------------------------------------------------------------------===//
812 // Move immediate instructions.
813 //===----------------------------------------------------------------------===//
815 defm MOVK : InsertImmediate<0b11, "movk">;
816 defm MOVN : MoveImmediate<0b00, "movn">;
818 let PostEncoderMethod = "fixMOVZ" in
819 defm MOVZ : MoveImmediate<0b10, "movz">;
821 // First group of aliases covers an implicit "lsl #0".
822 def : InstAlias<"movk $dst, $imm", (MOVKWi GPR32:$dst, imm0_65535:$imm, 0), 0>;
823 def : InstAlias<"movk $dst, $imm", (MOVKXi GPR64:$dst, imm0_65535:$imm, 0), 0>;
824 def : InstAlias<"movn $dst, $imm", (MOVNWi GPR32:$dst, imm0_65535:$imm, 0)>;
825 def : InstAlias<"movn $dst, $imm", (MOVNXi GPR64:$dst, imm0_65535:$imm, 0)>;
826 def : InstAlias<"movz $dst, $imm", (MOVZWi GPR32:$dst, imm0_65535:$imm, 0)>;
827 def : InstAlias<"movz $dst, $imm", (MOVZXi GPR64:$dst, imm0_65535:$imm, 0)>;
829 // Next, we have various ELF relocations with the ":XYZ_g0:sym" syntax.
830 def : InstAlias<"movz $Rd, $sym", (MOVZXi GPR64:$Rd, movw_symbol_g3:$sym, 48)>;
831 def : InstAlias<"movz $Rd, $sym", (MOVZXi GPR64:$Rd, movw_symbol_g2:$sym, 32)>;
832 def : InstAlias<"movz $Rd, $sym", (MOVZXi GPR64:$Rd, movw_symbol_g1:$sym, 16)>;
833 def : InstAlias<"movz $Rd, $sym", (MOVZXi GPR64:$Rd, movw_symbol_g0:$sym, 0)>;
835 def : InstAlias<"movn $Rd, $sym", (MOVNXi GPR64:$Rd, movw_symbol_g3:$sym, 48)>;
836 def : InstAlias<"movn $Rd, $sym", (MOVNXi GPR64:$Rd, movw_symbol_g2:$sym, 32)>;
837 def : InstAlias<"movn $Rd, $sym", (MOVNXi GPR64:$Rd, movw_symbol_g1:$sym, 16)>;
838 def : InstAlias<"movn $Rd, $sym", (MOVNXi GPR64:$Rd, movw_symbol_g0:$sym, 0)>;
840 def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movw_symbol_g3:$sym, 48), 0>;
841 def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movw_symbol_g2:$sym, 32), 0>;
842 def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movw_symbol_g1:$sym, 16), 0>;
843 def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movw_symbol_g0:$sym, 0), 0>;
845 def : InstAlias<"movz $Rd, $sym", (MOVZWi GPR32:$Rd, movw_symbol_g1:$sym, 16)>;
846 def : InstAlias<"movz $Rd, $sym", (MOVZWi GPR32:$Rd, movw_symbol_g0:$sym, 0)>;
848 def : InstAlias<"movn $Rd, $sym", (MOVNWi GPR32:$Rd, movw_symbol_g1:$sym, 16)>;
849 def : InstAlias<"movn $Rd, $sym", (MOVNWi GPR32:$Rd, movw_symbol_g0:$sym, 0)>;
851 def : InstAlias<"movk $Rd, $sym", (MOVKWi GPR32:$Rd, movw_symbol_g1:$sym, 16), 0>;
852 def : InstAlias<"movk $Rd, $sym", (MOVKWi GPR32:$Rd, movw_symbol_g0:$sym, 0), 0>;
854 // Final group of aliases covers true "mov $Rd, $imm" cases.
855 multiclass movw_mov_alias<string basename,Instruction INST, RegisterClass GPR,
856 int width, int shift> {
857 def _asmoperand : AsmOperandClass {
858 let Name = basename # width # "_lsl" # shift # "MovAlias";
859 let PredicateMethod = "is" # basename # "MovAlias<" # width # ", "
861 let RenderMethod = "add" # basename # "MovAliasOperands<" # shift # ">";
864 def _movimm : Operand<i32> {
865 let ParserMatchClass = !cast<AsmOperandClass>(NAME # "_asmoperand");
868 def : InstAlias<"mov $Rd, $imm",
869 (INST GPR:$Rd, !cast<Operand>(NAME # "_movimm"):$imm, shift)>;
872 defm : movw_mov_alias<"MOVZ", MOVZWi, GPR32, 32, 0>;
873 defm : movw_mov_alias<"MOVZ", MOVZWi, GPR32, 32, 16>;
875 defm : movw_mov_alias<"MOVZ", MOVZXi, GPR64, 64, 0>;
876 defm : movw_mov_alias<"MOVZ", MOVZXi, GPR64, 64, 16>;
877 defm : movw_mov_alias<"MOVZ", MOVZXi, GPR64, 64, 32>;
878 defm : movw_mov_alias<"MOVZ", MOVZXi, GPR64, 64, 48>;
880 defm : movw_mov_alias<"MOVN", MOVNWi, GPR32, 32, 0>;
881 defm : movw_mov_alias<"MOVN", MOVNWi, GPR32, 32, 16>;
883 defm : movw_mov_alias<"MOVN", MOVNXi, GPR64, 64, 0>;
884 defm : movw_mov_alias<"MOVN", MOVNXi, GPR64, 64, 16>;
885 defm : movw_mov_alias<"MOVN", MOVNXi, GPR64, 64, 32>;
886 defm : movw_mov_alias<"MOVN", MOVNXi, GPR64, 64, 48>;
888 let isReMaterializable = 1, isCodeGenOnly = 1, isMoveImm = 1,
889 isAsCheapAsAMove = 1 in {
890 // FIXME: The following pseudo instructions are only needed because remat
891 // cannot handle multiple instructions. When that changes, we can select
892 // directly to the real instructions and get rid of these pseudos.
895 : Pseudo<(outs GPR32:$dst), (ins i32imm:$src),
896 [(set GPR32:$dst, imm:$src)]>,
899 : Pseudo<(outs GPR64:$dst), (ins i64imm:$src),
900 [(set GPR64:$dst, imm:$src)]>,
902 } // isReMaterializable, isCodeGenOnly
904 // If possible, we want to use MOVi32imm even for 64-bit moves. This gives the
905 // eventual expansion code fewer bits to worry about getting right. Marshalling
906 // the types is a little tricky though:
907 def i64imm_32bit : ImmLeaf<i64, [{
908 return (Imm & 0xffffffffULL) == static_cast<uint64_t>(Imm);
911 def s64imm_32bit : ImmLeaf<i64, [{
912 int64_t Imm64 = static_cast<int64_t>(Imm);
913 return Imm64 >= std::numeric_limits<int32_t>::min() &&
914 Imm64 <= std::numeric_limits<int32_t>::max();
917 def trunc_imm : SDNodeXForm<imm, [{
918 return CurDAG->getTargetConstant(N->getZExtValue(), SDLoc(N), MVT::i32);
921 def gi_trunc_imm : GICustomOperandRenderer<"renderTruncImm">,
922 GISDNodeXFormEquiv<trunc_imm>;
924 def : Pat<(i64 i64imm_32bit:$src),
925 (SUBREG_TO_REG (i64 0), (MOVi32imm (trunc_imm imm:$src)), sub_32)>;
927 // Materialize FP constants via MOVi32imm/MOVi64imm (MachO large code model).
928 def bitcast_fpimm_to_i32 : SDNodeXForm<fpimm, [{
929 return CurDAG->getTargetConstant(
930 N->getValueAPF().bitcastToAPInt().getZExtValue(), SDLoc(N), MVT::i32);
933 def bitcast_fpimm_to_i64 : SDNodeXForm<fpimm, [{
934 return CurDAG->getTargetConstant(
935 N->getValueAPF().bitcastToAPInt().getZExtValue(), SDLoc(N), MVT::i64);
939 def : Pat<(f32 fpimm:$in),
940 (COPY_TO_REGCLASS (MOVi32imm (bitcast_fpimm_to_i32 f32:$in)), FPR32)>;
941 def : Pat<(f64 fpimm:$in),
942 (COPY_TO_REGCLASS (MOVi64imm (bitcast_fpimm_to_i64 f64:$in)), FPR64)>;
945 // Deal with the various forms of (ELF) large addressing with MOVZ/MOVK
947 def : Pat<(AArch64WrapperLarge tglobaladdr:$g3, tglobaladdr:$g2,
948 tglobaladdr:$g1, tglobaladdr:$g0),
949 (MOVKXi (MOVKXi (MOVKXi (MOVZXi tglobaladdr:$g0, 0),
950 tglobaladdr:$g1, 16),
951 tglobaladdr:$g2, 32),
952 tglobaladdr:$g3, 48)>;
954 def : Pat<(AArch64WrapperLarge tblockaddress:$g3, tblockaddress:$g2,
955 tblockaddress:$g1, tblockaddress:$g0),
956 (MOVKXi (MOVKXi (MOVKXi (MOVZXi tblockaddress:$g0, 0),
957 tblockaddress:$g1, 16),
958 tblockaddress:$g2, 32),
959 tblockaddress:$g3, 48)>;
961 def : Pat<(AArch64WrapperLarge tconstpool:$g3, tconstpool:$g2,
962 tconstpool:$g1, tconstpool:$g0),
963 (MOVKXi (MOVKXi (MOVKXi (MOVZXi tconstpool:$g0, 0),
966 tconstpool:$g3, 48)>;
968 def : Pat<(AArch64WrapperLarge tjumptable:$g3, tjumptable:$g2,
969 tjumptable:$g1, tjumptable:$g0),
970 (MOVKXi (MOVKXi (MOVKXi (MOVZXi tjumptable:$g0, 0),
973 tjumptable:$g3, 48)>;
976 //===----------------------------------------------------------------------===//
977 // Arithmetic instructions.
978 //===----------------------------------------------------------------------===//
980 // Add/subtract with carry.
981 defm ADC : AddSubCarry<0, "adc", "adcs", AArch64adc, AArch64adc_flag>;
982 defm SBC : AddSubCarry<1, "sbc", "sbcs", AArch64sbc, AArch64sbc_flag>;
984 def : InstAlias<"ngc $dst, $src", (SBCWr GPR32:$dst, WZR, GPR32:$src)>;
985 def : InstAlias<"ngc $dst, $src", (SBCXr GPR64:$dst, XZR, GPR64:$src)>;
986 def : InstAlias<"ngcs $dst, $src", (SBCSWr GPR32:$dst, WZR, GPR32:$src)>;
987 def : InstAlias<"ngcs $dst, $src", (SBCSXr GPR64:$dst, XZR, GPR64:$src)>;
990 defm ADD : AddSub<0, "add", "sub", add>;
991 defm SUB : AddSub<1, "sub", "add">;
993 def : InstAlias<"mov $dst, $src",
994 (ADDWri GPR32sponly:$dst, GPR32sp:$src, 0, 0)>;
995 def : InstAlias<"mov $dst, $src",
996 (ADDWri GPR32sp:$dst, GPR32sponly:$src, 0, 0)>;
997 def : InstAlias<"mov $dst, $src",
998 (ADDXri GPR64sponly:$dst, GPR64sp:$src, 0, 0)>;
999 def : InstAlias<"mov $dst, $src",
1000 (ADDXri GPR64sp:$dst, GPR64sponly:$src, 0, 0)>;
1002 defm ADDS : AddSubS<0, "adds", AArch64add_flag, "cmn", "subs", "cmp">;
1003 defm SUBS : AddSubS<1, "subs", AArch64sub_flag, "cmp", "adds", "cmn">;
1005 // Use SUBS instead of SUB to enable CSE between SUBS and SUB.
1006 def : Pat<(sub GPR32sp:$Rn, addsub_shifted_imm32:$imm),
1007 (SUBSWri GPR32sp:$Rn, addsub_shifted_imm32:$imm)>;
1008 def : Pat<(sub GPR64sp:$Rn, addsub_shifted_imm64:$imm),
1009 (SUBSXri GPR64sp:$Rn, addsub_shifted_imm64:$imm)>;
1010 def : Pat<(sub GPR32:$Rn, GPR32:$Rm),
1011 (SUBSWrr GPR32:$Rn, GPR32:$Rm)>;
1012 def : Pat<(sub GPR64:$Rn, GPR64:$Rm),
1013 (SUBSXrr GPR64:$Rn, GPR64:$Rm)>;
1014 def : Pat<(sub GPR32:$Rn, arith_shifted_reg32:$Rm),
1015 (SUBSWrs GPR32:$Rn, arith_shifted_reg32:$Rm)>;
1016 def : Pat<(sub GPR64:$Rn, arith_shifted_reg64:$Rm),
1017 (SUBSXrs GPR64:$Rn, arith_shifted_reg64:$Rm)>;
1018 let AddedComplexity = 1 in {
1019 def : Pat<(sub GPR32sp:$R2, arith_extended_reg32<i32>:$R3),
1020 (SUBSWrx GPR32sp:$R2, arith_extended_reg32<i32>:$R3)>;
1021 def : Pat<(sub GPR64sp:$R2, arith_extended_reg32to64<i64>:$R3),
1022 (SUBSXrx GPR64sp:$R2, arith_extended_reg32to64<i64>:$R3)>;
1025 // Because of the immediate format for add/sub-imm instructions, the
1026 // expression (add x, -1) must be transformed to (SUB{W,X}ri x, 1).
1027 // These patterns capture that transformation.
1028 let AddedComplexity = 1 in {
1029 def : Pat<(add GPR32:$Rn, neg_addsub_shifted_imm32:$imm),
1030 (SUBSWri GPR32:$Rn, neg_addsub_shifted_imm32:$imm)>;
1031 def : Pat<(add GPR64:$Rn, neg_addsub_shifted_imm64:$imm),
1032 (SUBSXri GPR64:$Rn, neg_addsub_shifted_imm64:$imm)>;
1033 def : Pat<(sub GPR32:$Rn, neg_addsub_shifted_imm32:$imm),
1034 (ADDWri GPR32:$Rn, neg_addsub_shifted_imm32:$imm)>;
1035 def : Pat<(sub GPR64:$Rn, neg_addsub_shifted_imm64:$imm),
1036 (ADDXri GPR64:$Rn, neg_addsub_shifted_imm64:$imm)>;
1039 // Because of the immediate format for add/sub-imm instructions, the
1040 // expression (add x, -1) must be transformed to (SUB{W,X}ri x, 1).
1041 // These patterns capture that transformation.
1042 let AddedComplexity = 1 in {
1043 def : Pat<(AArch64add_flag GPR32:$Rn, neg_addsub_shifted_imm32:$imm),
1044 (SUBSWri GPR32:$Rn, neg_addsub_shifted_imm32:$imm)>;
1045 def : Pat<(AArch64add_flag GPR64:$Rn, neg_addsub_shifted_imm64:$imm),
1046 (SUBSXri GPR64:$Rn, neg_addsub_shifted_imm64:$imm)>;
1047 def : Pat<(AArch64sub_flag GPR32:$Rn, neg_addsub_shifted_imm32:$imm),
1048 (ADDSWri GPR32:$Rn, neg_addsub_shifted_imm32:$imm)>;
1049 def : Pat<(AArch64sub_flag GPR64:$Rn, neg_addsub_shifted_imm64:$imm),
1050 (ADDSXri GPR64:$Rn, neg_addsub_shifted_imm64:$imm)>;
1053 def : InstAlias<"neg $dst, $src", (SUBWrs GPR32:$dst, WZR, GPR32:$src, 0), 3>;
1054 def : InstAlias<"neg $dst, $src", (SUBXrs GPR64:$dst, XZR, GPR64:$src, 0), 3>;
1055 def : InstAlias<"neg $dst, $src$shift",
1056 (SUBWrs GPR32:$dst, WZR, GPR32:$src, arith_shift32:$shift), 2>;
1057 def : InstAlias<"neg $dst, $src$shift",
1058 (SUBXrs GPR64:$dst, XZR, GPR64:$src, arith_shift64:$shift), 2>;
1060 def : InstAlias<"negs $dst, $src", (SUBSWrs GPR32:$dst, WZR, GPR32:$src, 0), 3>;
1061 def : InstAlias<"negs $dst, $src", (SUBSXrs GPR64:$dst, XZR, GPR64:$src, 0), 3>;
1062 def : InstAlias<"negs $dst, $src$shift",
1063 (SUBSWrs GPR32:$dst, WZR, GPR32:$src, arith_shift32:$shift), 2>;
1064 def : InstAlias<"negs $dst, $src$shift",
1065 (SUBSXrs GPR64:$dst, XZR, GPR64:$src, arith_shift64:$shift), 2>;
1068 // Unsigned/Signed divide
1069 defm UDIV : Div<0, "udiv", udiv>;
1070 defm SDIV : Div<1, "sdiv", sdiv>;
1072 def : Pat<(int_aarch64_udiv GPR32:$Rn, GPR32:$Rm), (UDIVWr GPR32:$Rn, GPR32:$Rm)>;
1073 def : Pat<(int_aarch64_udiv GPR64:$Rn, GPR64:$Rm), (UDIVXr GPR64:$Rn, GPR64:$Rm)>;
1074 def : Pat<(int_aarch64_sdiv GPR32:$Rn, GPR32:$Rm), (SDIVWr GPR32:$Rn, GPR32:$Rm)>;
1075 def : Pat<(int_aarch64_sdiv GPR64:$Rn, GPR64:$Rm), (SDIVXr GPR64:$Rn, GPR64:$Rm)>;
1078 defm ASRV : Shift<0b10, "asr", sra>;
1079 defm LSLV : Shift<0b00, "lsl", shl>;
1080 defm LSRV : Shift<0b01, "lsr", srl>;
1081 defm RORV : Shift<0b11, "ror", rotr>;
1083 def : ShiftAlias<"asrv", ASRVWr, GPR32>;
1084 def : ShiftAlias<"asrv", ASRVXr, GPR64>;
1085 def : ShiftAlias<"lslv", LSLVWr, GPR32>;
1086 def : ShiftAlias<"lslv", LSLVXr, GPR64>;
1087 def : ShiftAlias<"lsrv", LSRVWr, GPR32>;
1088 def : ShiftAlias<"lsrv", LSRVXr, GPR64>;
1089 def : ShiftAlias<"rorv", RORVWr, GPR32>;
1090 def : ShiftAlias<"rorv", RORVXr, GPR64>;
1093 let AddedComplexity = 5 in {
1094 defm MADD : MulAccum<0, "madd", add>;
1095 defm MSUB : MulAccum<1, "msub", sub>;
1097 def : Pat<(i32 (mul GPR32:$Rn, GPR32:$Rm)),
1098 (MADDWrrr GPR32:$Rn, GPR32:$Rm, WZR)>;
1099 def : Pat<(i64 (mul GPR64:$Rn, GPR64:$Rm)),
1100 (MADDXrrr GPR64:$Rn, GPR64:$Rm, XZR)>;
1102 def : Pat<(i32 (ineg (mul GPR32:$Rn, GPR32:$Rm))),
1103 (MSUBWrrr GPR32:$Rn, GPR32:$Rm, WZR)>;
1104 def : Pat<(i64 (ineg (mul GPR64:$Rn, GPR64:$Rm))),
1105 (MSUBXrrr GPR64:$Rn, GPR64:$Rm, XZR)>;
1106 def : Pat<(i32 (mul (ineg GPR32:$Rn), GPR32:$Rm)),
1107 (MSUBWrrr GPR32:$Rn, GPR32:$Rm, WZR)>;
1108 def : Pat<(i64 (mul (ineg GPR64:$Rn), GPR64:$Rm)),
1109 (MSUBXrrr GPR64:$Rn, GPR64:$Rm, XZR)>;
1110 } // AddedComplexity = 5
1112 let AddedComplexity = 5 in {
1113 def SMADDLrrr : WideMulAccum<0, 0b001, "smaddl", add, sext>;
1114 def SMSUBLrrr : WideMulAccum<1, 0b001, "smsubl", sub, sext>;
1115 def UMADDLrrr : WideMulAccum<0, 0b101, "umaddl", add, zext>;
1116 def UMSUBLrrr : WideMulAccum<1, 0b101, "umsubl", sub, zext>;
1118 def : Pat<(i64 (mul (sext GPR32:$Rn), (sext GPR32:$Rm))),
1119 (SMADDLrrr GPR32:$Rn, GPR32:$Rm, XZR)>;
1120 def : Pat<(i64 (mul (zext GPR32:$Rn), (zext GPR32:$Rm))),
1121 (UMADDLrrr GPR32:$Rn, GPR32:$Rm, XZR)>;
1123 def : Pat<(i64 (ineg (mul (sext GPR32:$Rn), (sext GPR32:$Rm)))),
1124 (SMSUBLrrr GPR32:$Rn, GPR32:$Rm, XZR)>;
1125 def : Pat<(i64 (ineg (mul (zext GPR32:$Rn), (zext GPR32:$Rm)))),
1126 (UMSUBLrrr GPR32:$Rn, GPR32:$Rm, XZR)>;
1128 def : Pat<(i64 (mul (sext GPR32:$Rn), (s64imm_32bit:$C))),
1129 (SMADDLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1130 def : Pat<(i64 (mul (zext GPR32:$Rn), (i64imm_32bit:$C))),
1131 (UMADDLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1132 def : Pat<(i64 (mul (sext_inreg GPR64:$Rn, i32), (s64imm_32bit:$C))),
1133 (SMADDLrrr (i32 (EXTRACT_SUBREG GPR64:$Rn, sub_32)),
1134 (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1136 def : Pat<(i64 (ineg (mul (sext GPR32:$Rn), (s64imm_32bit:$C)))),
1137 (SMSUBLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1138 def : Pat<(i64 (ineg (mul (zext GPR32:$Rn), (i64imm_32bit:$C)))),
1139 (UMSUBLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1140 def : Pat<(i64 (ineg (mul (sext_inreg GPR64:$Rn, i32), (s64imm_32bit:$C)))),
1141 (SMSUBLrrr (i32 (EXTRACT_SUBREG GPR64:$Rn, sub_32)),
1142 (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1144 def : Pat<(i64 (add (mul (sext GPR32:$Rn), (s64imm_32bit:$C)), GPR64:$Ra)),
1145 (SMADDLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1146 def : Pat<(i64 (add (mul (zext GPR32:$Rn), (i64imm_32bit:$C)), GPR64:$Ra)),
1147 (UMADDLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1148 def : Pat<(i64 (add (mul (sext_inreg GPR64:$Rn, i32), (s64imm_32bit:$C)),
1150 (SMADDLrrr (i32 (EXTRACT_SUBREG GPR64:$Rn, sub_32)),
1151 (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1153 def : Pat<(i64 (sub GPR64:$Ra, (mul (sext GPR32:$Rn), (s64imm_32bit:$C)))),
1154 (SMSUBLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1155 def : Pat<(i64 (sub GPR64:$Ra, (mul (zext GPR32:$Rn), (i64imm_32bit:$C)))),
1156 (UMSUBLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1157 def : Pat<(i64 (sub GPR64:$Ra, (mul (sext_inreg GPR64:$Rn, i32),
1158 (s64imm_32bit:$C)))),
1159 (SMSUBLrrr (i32 (EXTRACT_SUBREG GPR64:$Rn, sub_32)),
1160 (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1161 } // AddedComplexity = 5
1163 def : MulAccumWAlias<"mul", MADDWrrr>;
1164 def : MulAccumXAlias<"mul", MADDXrrr>;
1165 def : MulAccumWAlias<"mneg", MSUBWrrr>;
1166 def : MulAccumXAlias<"mneg", MSUBXrrr>;
1167 def : WideMulAccumAlias<"smull", SMADDLrrr>;
1168 def : WideMulAccumAlias<"smnegl", SMSUBLrrr>;
1169 def : WideMulAccumAlias<"umull", UMADDLrrr>;
1170 def : WideMulAccumAlias<"umnegl", UMSUBLrrr>;
1173 def SMULHrr : MulHi<0b010, "smulh", mulhs>;
1174 def UMULHrr : MulHi<0b110, "umulh", mulhu>;
1177 def CRC32Brr : BaseCRC32<0, 0b00, 0, GPR32, int_aarch64_crc32b, "crc32b">;
1178 def CRC32Hrr : BaseCRC32<0, 0b01, 0, GPR32, int_aarch64_crc32h, "crc32h">;
1179 def CRC32Wrr : BaseCRC32<0, 0b10, 0, GPR32, int_aarch64_crc32w, "crc32w">;
1180 def CRC32Xrr : BaseCRC32<1, 0b11, 0, GPR64, int_aarch64_crc32x, "crc32x">;
1182 def CRC32CBrr : BaseCRC32<0, 0b00, 1, GPR32, int_aarch64_crc32cb, "crc32cb">;
1183 def CRC32CHrr : BaseCRC32<0, 0b01, 1, GPR32, int_aarch64_crc32ch, "crc32ch">;
1184 def CRC32CWrr : BaseCRC32<0, 0b10, 1, GPR32, int_aarch64_crc32cw, "crc32cw">;
1185 def CRC32CXrr : BaseCRC32<1, 0b11, 1, GPR64, int_aarch64_crc32cx, "crc32cx">;
1188 defm CAS : CompareAndSwap<0, 0, "">;
1189 defm CASA : CompareAndSwap<1, 0, "a">;
1190 defm CASL : CompareAndSwap<0, 1, "l">;
1191 defm CASAL : CompareAndSwap<1, 1, "al">;
1194 defm CASP : CompareAndSwapPair<0, 0, "">;
1195 defm CASPA : CompareAndSwapPair<1, 0, "a">;
1196 defm CASPL : CompareAndSwapPair<0, 1, "l">;
1197 defm CASPAL : CompareAndSwapPair<1, 1, "al">;
1200 defm SWP : Swap<0, 0, "">;
1201 defm SWPA : Swap<1, 0, "a">;
1202 defm SWPL : Swap<0, 1, "l">;
1203 defm SWPAL : Swap<1, 1, "al">;
1205 // v8.1 atomic LD<OP>(register). Performs load and then ST<OP>(register)
1206 defm LDADD : LDOPregister<0b000, "add", 0, 0, "">;
1207 defm LDADDA : LDOPregister<0b000, "add", 1, 0, "a">;
1208 defm LDADDL : LDOPregister<0b000, "add", 0, 1, "l">;
1209 defm LDADDAL : LDOPregister<0b000, "add", 1, 1, "al">;
1211 defm LDCLR : LDOPregister<0b001, "clr", 0, 0, "">;
1212 defm LDCLRA : LDOPregister<0b001, "clr", 1, 0, "a">;
1213 defm LDCLRL : LDOPregister<0b001, "clr", 0, 1, "l">;
1214 defm LDCLRAL : LDOPregister<0b001, "clr", 1, 1, "al">;
1216 defm LDEOR : LDOPregister<0b010, "eor", 0, 0, "">;
1217 defm LDEORA : LDOPregister<0b010, "eor", 1, 0, "a">;
1218 defm LDEORL : LDOPregister<0b010, "eor", 0, 1, "l">;
1219 defm LDEORAL : LDOPregister<0b010, "eor", 1, 1, "al">;
1221 defm LDSET : LDOPregister<0b011, "set", 0, 0, "">;
1222 defm LDSETA : LDOPregister<0b011, "set", 1, 0, "a">;
1223 defm LDSETL : LDOPregister<0b011, "set", 0, 1, "l">;
1224 defm LDSETAL : LDOPregister<0b011, "set", 1, 1, "al">;
1226 defm LDSMAX : LDOPregister<0b100, "smax", 0, 0, "">;
1227 defm LDSMAXA : LDOPregister<0b100, "smax", 1, 0, "a">;
1228 defm LDSMAXL : LDOPregister<0b100, "smax", 0, 1, "l">;
1229 defm LDSMAXAL : LDOPregister<0b100, "smax", 1, 1, "al">;
1231 defm LDSMIN : LDOPregister<0b101, "smin", 0, 0, "">;
1232 defm LDSMINA : LDOPregister<0b101, "smin", 1, 0, "a">;
1233 defm LDSMINL : LDOPregister<0b101, "smin", 0, 1, "l">;
1234 defm LDSMINAL : LDOPregister<0b101, "smin", 1, 1, "al">;
1236 defm LDUMAX : LDOPregister<0b110, "umax", 0, 0, "">;
1237 defm LDUMAXA : LDOPregister<0b110, "umax", 1, 0, "a">;
1238 defm LDUMAXL : LDOPregister<0b110, "umax", 0, 1, "l">;
1239 defm LDUMAXAL : LDOPregister<0b110, "umax", 1, 1, "al">;
1241 defm LDUMIN : LDOPregister<0b111, "umin", 0, 0, "">;
1242 defm LDUMINA : LDOPregister<0b111, "umin", 1, 0, "a">;
1243 defm LDUMINL : LDOPregister<0b111, "umin", 0, 1, "l">;
1244 defm LDUMINAL : LDOPregister<0b111, "umin", 1, 1, "al">;
1246 // v8.1 atomic ST<OP>(register) as aliases to "LD<OP>(register) when Rt=xZR"
1247 defm : STOPregister<"stadd","LDADD">; // STADDx
1248 defm : STOPregister<"stclr","LDCLR">; // STCLRx
1249 defm : STOPregister<"steor","LDEOR">; // STEORx
1250 defm : STOPregister<"stset","LDSET">; // STSETx
1251 defm : STOPregister<"stsmax","LDSMAX">;// STSMAXx
1252 defm : STOPregister<"stsmin","LDSMIN">;// STSMINx
1253 defm : STOPregister<"stumax","LDUMAX">;// STUMAXx
1254 defm : STOPregister<"stumin","LDUMIN">;// STUMINx
1256 // v8.5 Memory Tagging Extension
1257 let Predicates = [HasMTE] in {
1259 def IRG : BaseTwoOperand<0b0100, GPR64sp, "irg", int_aarch64_irg, GPR64sp, GPR64>,
1263 def GMI : BaseTwoOperand<0b0101, GPR64, "gmi", int_aarch64_gmi, GPR64sp>, Sched<[]>{
1265 let isNotDuplicable = 1;
1267 def ADDG : AddSubG<0, "addg", null_frag>;
1268 def SUBG : AddSubG<1, "subg", null_frag>;
1270 def : InstAlias<"irg $dst, $src", (IRG GPR64sp:$dst, GPR64sp:$src, XZR), 1>;
1272 def SUBP : SUBP<0, "subp", int_aarch64_subp>, Sched<[]>;
1273 def SUBPS : SUBP<1, "subps", null_frag>, Sched<[]>{
1277 def : InstAlias<"cmpp $lhs, $rhs", (SUBPS XZR, GPR64sp:$lhs, GPR64sp:$rhs), 0>;
1279 def LDG : MemTagLoad<"ldg", "\t$Rt, [$Rn, $offset]">;
1281 def : Pat<(int_aarch64_addg (am_indexedu6s128 GPR64sp:$Rn, uimm6s16:$imm6), imm0_15:$imm4),
1282 (ADDG GPR64sp:$Rn, imm0_63:$imm6, imm0_15:$imm4)>;
1283 def : Pat<(int_aarch64_ldg GPR64:$Rt, (am_indexeds9s128 GPR64sp:$Rn, simm9s16:$offset)),
1284 (LDG GPR64:$Rt, GPR64sp:$Rn, simm9s16:$offset)>;
1286 def : InstAlias<"ldg $Rt, [$Rn]", (LDG GPR64:$Rt, GPR64sp:$Rn, 0), 1>;
1288 def LDGM : MemTagVector<1, "ldgm", "\t$Rt, [$Rn]",
1289 (outs GPR64:$Rt), (ins GPR64sp:$Rn)>;
1290 def STGM : MemTagVector<0, "stgm", "\t$Rt, [$Rn]",
1291 (outs), (ins GPR64:$Rt, GPR64sp:$Rn)>;
1292 def STZGM : MemTagVector<0, "stzgm", "\t$Rt, [$Rn]",
1293 (outs), (ins GPR64:$Rt, GPR64sp:$Rn)> {
1297 defm STG : MemTagStore<0b00, "stg">;
1298 defm STZG : MemTagStore<0b01, "stzg">;
1299 defm ST2G : MemTagStore<0b10, "st2g">;
1300 defm STZ2G : MemTagStore<0b11, "stz2g">;
1302 def : Pat<(AArch64stg GPR64sp:$Rn, (am_indexeds9s128 GPR64sp:$Rm, simm9s16:$imm)),
1303 (STGOffset $Rn, $Rm, $imm)>;
1304 def : Pat<(AArch64stzg GPR64sp:$Rn, (am_indexeds9s128 GPR64sp:$Rm, simm9s16:$imm)),
1305 (STZGOffset $Rn, $Rm, $imm)>;
1306 def : Pat<(AArch64st2g GPR64sp:$Rn, (am_indexeds9s128 GPR64sp:$Rm, simm9s16:$imm)),
1307 (ST2GOffset $Rn, $Rm, $imm)>;
1308 def : Pat<(AArch64stz2g GPR64sp:$Rn, (am_indexeds9s128 GPR64sp:$Rm, simm9s16:$imm)),
1309 (STZ2GOffset $Rn, $Rm, $imm)>;
1311 defm STGP : StorePairOffset <0b01, 0, GPR64z, simm7s16, "stgp">;
1312 def STGPpre : StorePairPreIdx <0b01, 0, GPR64z, simm7s16, "stgp">;
1313 def STGPpost : StorePairPostIdx<0b01, 0, GPR64z, simm7s16, "stgp">;
1315 def : Pat<(int_aarch64_stg GPR64:$Rt, (am_indexeds9s128 GPR64sp:$Rn, simm9s16:$offset)),
1316 (STGOffset GPR64:$Rt, GPR64sp:$Rn, simm9s16:$offset)>;
1318 def : Pat<(int_aarch64_stgp (am_indexed7s128 GPR64sp:$Rn, simm7s16:$imm), GPR64:$Rt, GPR64:$Rt2),
1319 (STGPi $Rt, $Rt2, $Rn, $imm)>;
1322 : Pseudo<(outs GPR64sp:$Rd), (ins GPR64sp:$Rsp, GPR64:$Rm), []>,
1325 : Pseudo<(outs GPR64sp:$Rd), (ins GPR64sp:$Rn, uimm6s16:$imm6, GPR64sp:$Rm, imm0_15:$imm4), []>,
1328 // Explicit SP in the first operand prevents ShrinkWrap optimization
1329 // from leaving this instruction out of the stack frame. When IRGstack
1330 // is transformed into IRG, this operand is replaced with the actual
1331 // register / expression for the tagged base pointer of the current function.
1332 def : Pat<(int_aarch64_irg_sp i64:$Rm), (IRGstack SP, i64:$Rm)>;
1334 // Large STG to be expanded into a loop. $Rm is the size, $Rn is start address.
1335 // $Rn_wback is one past the end of the range.
1336 let isCodeGenOnly=1, mayStore=1 in {
1338 : Pseudo<(outs GPR64common:$Rm_wback, GPR64sp:$Rn_wback), (ins GPR64common:$Rm, GPR64sp:$Rn),
1339 [], "$Rn = $Rn_wback,@earlyclobber $Rn_wback,$Rm = $Rm_wback,@earlyclobber $Rm_wback" >,
1340 Sched<[WriteAdr, WriteST]>;
1343 : Pseudo<(outs GPR64common:$Rm_wback, GPR64sp:$Rn_wback), (ins GPR64common:$Rm, GPR64sp:$Rn),
1344 [], "$Rn = $Rn_wback,@earlyclobber $Rn_wback,$Rm = $Rm_wback,@earlyclobber $Rm_wback" >,
1345 Sched<[WriteAdr, WriteST]>;
1348 } // Predicates = [HasMTE]
1350 //===----------------------------------------------------------------------===//
1351 // Logical instructions.
1352 //===----------------------------------------------------------------------===//
1355 defm ANDS : LogicalImmS<0b11, "ands", AArch64and_flag, "bics">;
1356 defm AND : LogicalImm<0b00, "and", and, "bic">;
1357 defm EOR : LogicalImm<0b10, "eor", xor, "eon">;
1358 defm ORR : LogicalImm<0b01, "orr", or, "orn">;
1360 // FIXME: these aliases *are* canonical sometimes (when movz can't be
1361 // used). Actually, it seems to be working right now, but putting logical_immXX
1362 // here is a bit dodgy on the AsmParser side too.
1363 def : InstAlias<"mov $dst, $imm", (ORRWri GPR32sp:$dst, WZR,
1364 logical_imm32:$imm), 0>;
1365 def : InstAlias<"mov $dst, $imm", (ORRXri GPR64sp:$dst, XZR,
1366 logical_imm64:$imm), 0>;
1370 defm ANDS : LogicalRegS<0b11, 0, "ands", AArch64and_flag>;
1371 defm BICS : LogicalRegS<0b11, 1, "bics",
1372 BinOpFrag<(AArch64and_flag node:$LHS, (not node:$RHS))>>;
1373 defm AND : LogicalReg<0b00, 0, "and", and>;
1374 defm BIC : LogicalReg<0b00, 1, "bic",
1375 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
1376 defm EON : LogicalReg<0b10, 1, "eon",
1377 BinOpFrag<(not (xor node:$LHS, node:$RHS))>>;
1378 defm EOR : LogicalReg<0b10, 0, "eor", xor>;
1379 defm ORN : LogicalReg<0b01, 1, "orn",
1380 BinOpFrag<(or node:$LHS, (not node:$RHS))>>;
1381 defm ORR : LogicalReg<0b01, 0, "orr", or>;
1383 def : InstAlias<"mov $dst, $src", (ORRWrs GPR32:$dst, WZR, GPR32:$src, 0), 2>;
1384 def : InstAlias<"mov $dst, $src", (ORRXrs GPR64:$dst, XZR, GPR64:$src, 0), 2>;
1386 def : InstAlias<"mvn $Wd, $Wm", (ORNWrs GPR32:$Wd, WZR, GPR32:$Wm, 0), 3>;
1387 def : InstAlias<"mvn $Xd, $Xm", (ORNXrs GPR64:$Xd, XZR, GPR64:$Xm, 0), 3>;
1389 def : InstAlias<"mvn $Wd, $Wm$sh",
1390 (ORNWrs GPR32:$Wd, WZR, GPR32:$Wm, logical_shift32:$sh), 2>;
1391 def : InstAlias<"mvn $Xd, $Xm$sh",
1392 (ORNXrs GPR64:$Xd, XZR, GPR64:$Xm, logical_shift64:$sh), 2>;
1394 def : InstAlias<"tst $src1, $src2",
1395 (ANDSWri WZR, GPR32:$src1, logical_imm32:$src2), 2>;
1396 def : InstAlias<"tst $src1, $src2",
1397 (ANDSXri XZR, GPR64:$src1, logical_imm64:$src2), 2>;
1399 def : InstAlias<"tst $src1, $src2",
1400 (ANDSWrs WZR, GPR32:$src1, GPR32:$src2, 0), 3>;
1401 def : InstAlias<"tst $src1, $src2",
1402 (ANDSXrs XZR, GPR64:$src1, GPR64:$src2, 0), 3>;
1404 def : InstAlias<"tst $src1, $src2$sh",
1405 (ANDSWrs WZR, GPR32:$src1, GPR32:$src2, logical_shift32:$sh), 2>;
1406 def : InstAlias<"tst $src1, $src2$sh",
1407 (ANDSXrs XZR, GPR64:$src1, GPR64:$src2, logical_shift64:$sh), 2>;
1410 def : Pat<(not GPR32:$Wm), (ORNWrr WZR, GPR32:$Wm)>;
1411 def : Pat<(not GPR64:$Xm), (ORNXrr XZR, GPR64:$Xm)>;
1414 //===----------------------------------------------------------------------===//
1415 // One operand data processing instructions.
1416 //===----------------------------------------------------------------------===//
1418 defm CLS : OneOperandData<0b101, "cls">;
1419 defm CLZ : OneOperandData<0b100, "clz", ctlz>;
1420 defm RBIT : OneOperandData<0b000, "rbit", bitreverse>;
1422 def REV16Wr : OneWRegData<0b001, "rev16",
1423 UnOpFrag<(rotr (bswap node:$LHS), (i64 16))>>;
1424 def REV16Xr : OneXRegData<0b001, "rev16", null_frag>;
1426 def : Pat<(cttz GPR32:$Rn),
1427 (CLZWr (RBITWr GPR32:$Rn))>;
1428 def : Pat<(cttz GPR64:$Rn),
1429 (CLZXr (RBITXr GPR64:$Rn))>;
1430 def : Pat<(ctlz (or (shl (xor (sra GPR32:$Rn, (i64 31)), GPR32:$Rn), (i64 1)),
1433 def : Pat<(ctlz (or (shl (xor (sra GPR64:$Rn, (i64 63)), GPR64:$Rn), (i64 1)),
1437 // Unlike the other one operand instructions, the instructions with the "rev"
1438 // mnemonic do *not* just different in the size bit, but actually use different
1439 // opcode bits for the different sizes.
1440 def REVWr : OneWRegData<0b010, "rev", bswap>;
1441 def REVXr : OneXRegData<0b011, "rev", bswap>;
1442 def REV32Xr : OneXRegData<0b010, "rev32",
1443 UnOpFrag<(rotr (bswap node:$LHS), (i64 32))>>;
1445 def : InstAlias<"rev64 $Rd, $Rn", (REVXr GPR64:$Rd, GPR64:$Rn), 0>;
1447 // The bswap commutes with the rotr so we want a pattern for both possible
1449 def : Pat<(bswap (rotr GPR32:$Rn, (i64 16))), (REV16Wr GPR32:$Rn)>;
1450 def : Pat<(bswap (rotr GPR64:$Rn, (i64 32))), (REV32Xr GPR64:$Rn)>;
1452 //===----------------------------------------------------------------------===//
1453 // Bitfield immediate extraction instruction.
1454 //===----------------------------------------------------------------------===//
1455 let hasSideEffects = 0 in
1456 defm EXTR : ExtractImm<"extr">;
1457 def : InstAlias<"ror $dst, $src, $shift",
1458 (EXTRWrri GPR32:$dst, GPR32:$src, GPR32:$src, imm0_31:$shift)>;
1459 def : InstAlias<"ror $dst, $src, $shift",
1460 (EXTRXrri GPR64:$dst, GPR64:$src, GPR64:$src, imm0_63:$shift)>;
1462 def : Pat<(rotr GPR32:$Rn, (i64 imm0_31:$imm)),
1463 (EXTRWrri GPR32:$Rn, GPR32:$Rn, imm0_31:$imm)>;
1464 def : Pat<(rotr GPR64:$Rn, (i64 imm0_63:$imm)),
1465 (EXTRXrri GPR64:$Rn, GPR64:$Rn, imm0_63:$imm)>;
1467 //===----------------------------------------------------------------------===//
1468 // Other bitfield immediate instructions.
1469 //===----------------------------------------------------------------------===//
1470 let hasSideEffects = 0 in {
1471 defm BFM : BitfieldImmWith2RegArgs<0b01, "bfm">;
1472 defm SBFM : BitfieldImm<0b00, "sbfm">;
1473 defm UBFM : BitfieldImm<0b10, "ubfm">;
1476 def i32shift_a : Operand<i64>, SDNodeXForm<imm, [{
1477 uint64_t enc = (32 - N->getZExtValue()) & 0x1f;
1478 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1481 def i32shift_b : Operand<i64>, SDNodeXForm<imm, [{
1482 uint64_t enc = 31 - N->getZExtValue();
1483 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1486 // min(7, 31 - shift_amt)
1487 def i32shift_sext_i8 : Operand<i64>, SDNodeXForm<imm, [{
1488 uint64_t enc = 31 - N->getZExtValue();
1489 enc = enc > 7 ? 7 : enc;
1490 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1493 // min(15, 31 - shift_amt)
1494 def i32shift_sext_i16 : Operand<i64>, SDNodeXForm<imm, [{
1495 uint64_t enc = 31 - N->getZExtValue();
1496 enc = enc > 15 ? 15 : enc;
1497 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1500 def i64shift_a : Operand<i64>, SDNodeXForm<imm, [{
1501 uint64_t enc = (64 - N->getZExtValue()) & 0x3f;
1502 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1505 def i64shift_b : Operand<i64>, SDNodeXForm<imm, [{
1506 uint64_t enc = 63 - N->getZExtValue();
1507 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1510 // min(7, 63 - shift_amt)
1511 def i64shift_sext_i8 : Operand<i64>, SDNodeXForm<imm, [{
1512 uint64_t enc = 63 - N->getZExtValue();
1513 enc = enc > 7 ? 7 : enc;
1514 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1517 // min(15, 63 - shift_amt)
1518 def i64shift_sext_i16 : Operand<i64>, SDNodeXForm<imm, [{
1519 uint64_t enc = 63 - N->getZExtValue();
1520 enc = enc > 15 ? 15 : enc;
1521 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1524 // min(31, 63 - shift_amt)
1525 def i64shift_sext_i32 : Operand<i64>, SDNodeXForm<imm, [{
1526 uint64_t enc = 63 - N->getZExtValue();
1527 enc = enc > 31 ? 31 : enc;
1528 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1531 def : Pat<(shl GPR32:$Rn, (i64 imm0_31:$imm)),
1532 (UBFMWri GPR32:$Rn, (i64 (i32shift_a imm0_31:$imm)),
1533 (i64 (i32shift_b imm0_31:$imm)))>;
1534 def : Pat<(shl GPR64:$Rn, (i64 imm0_63:$imm)),
1535 (UBFMXri GPR64:$Rn, (i64 (i64shift_a imm0_63:$imm)),
1536 (i64 (i64shift_b imm0_63:$imm)))>;
1538 let AddedComplexity = 10 in {
1539 def : Pat<(sra GPR32:$Rn, (i64 imm0_31:$imm)),
1540 (SBFMWri GPR32:$Rn, imm0_31:$imm, 31)>;
1541 def : Pat<(sra GPR64:$Rn, (i64 imm0_63:$imm)),
1542 (SBFMXri GPR64:$Rn, imm0_63:$imm, 63)>;
1545 def : InstAlias<"asr $dst, $src, $shift",
1546 (SBFMWri GPR32:$dst, GPR32:$src, imm0_31:$shift, 31)>;
1547 def : InstAlias<"asr $dst, $src, $shift",
1548 (SBFMXri GPR64:$dst, GPR64:$src, imm0_63:$shift, 63)>;
1549 def : InstAlias<"sxtb $dst, $src", (SBFMWri GPR32:$dst, GPR32:$src, 0, 7)>;
1550 def : InstAlias<"sxtb $dst, $src", (SBFMXri GPR64:$dst, GPR64:$src, 0, 7)>;
1551 def : InstAlias<"sxth $dst, $src", (SBFMWri GPR32:$dst, GPR32:$src, 0, 15)>;
1552 def : InstAlias<"sxth $dst, $src", (SBFMXri GPR64:$dst, GPR64:$src, 0, 15)>;
1553 def : InstAlias<"sxtw $dst, $src", (SBFMXri GPR64:$dst, GPR64:$src, 0, 31)>;
1555 def : Pat<(srl GPR32:$Rn, (i64 imm0_31:$imm)),
1556 (UBFMWri GPR32:$Rn, imm0_31:$imm, 31)>;
1557 def : Pat<(srl GPR64:$Rn, (i64 imm0_63:$imm)),
1558 (UBFMXri GPR64:$Rn, imm0_63:$imm, 63)>;
1560 def : InstAlias<"lsr $dst, $src, $shift",
1561 (UBFMWri GPR32:$dst, GPR32:$src, imm0_31:$shift, 31)>;
1562 def : InstAlias<"lsr $dst, $src, $shift",
1563 (UBFMXri GPR64:$dst, GPR64:$src, imm0_63:$shift, 63)>;
1564 def : InstAlias<"uxtb $dst, $src", (UBFMWri GPR32:$dst, GPR32:$src, 0, 7)>;
1565 def : InstAlias<"uxtb $dst, $src", (UBFMXri GPR64:$dst, GPR64:$src, 0, 7)>;
1566 def : InstAlias<"uxth $dst, $src", (UBFMWri GPR32:$dst, GPR32:$src, 0, 15)>;
1567 def : InstAlias<"uxth $dst, $src", (UBFMXri GPR64:$dst, GPR64:$src, 0, 15)>;
1568 def : InstAlias<"uxtw $dst, $src", (UBFMXri GPR64:$dst, GPR64:$src, 0, 31)>;
1570 //===----------------------------------------------------------------------===//
1571 // Conditional comparison instructions.
1572 //===----------------------------------------------------------------------===//
1573 defm CCMN : CondComparison<0, "ccmn", AArch64ccmn>;
1574 defm CCMP : CondComparison<1, "ccmp", AArch64ccmp>;
1576 //===----------------------------------------------------------------------===//
1577 // Conditional select instructions.
1578 //===----------------------------------------------------------------------===//
1579 defm CSEL : CondSelect<0, 0b00, "csel">;
1581 def inc : PatFrag<(ops node:$in), (add node:$in, 1)>;
1582 defm CSINC : CondSelectOp<0, 0b01, "csinc", inc>;
1583 defm CSINV : CondSelectOp<1, 0b00, "csinv", not>;
1584 defm CSNEG : CondSelectOp<1, 0b01, "csneg", ineg>;
1586 def : Pat<(AArch64csinv GPR32:$tval, GPR32:$fval, (i32 imm:$cc), NZCV),
1587 (CSINVWr GPR32:$tval, GPR32:$fval, (i32 imm:$cc))>;
1588 def : Pat<(AArch64csinv GPR64:$tval, GPR64:$fval, (i32 imm:$cc), NZCV),
1589 (CSINVXr GPR64:$tval, GPR64:$fval, (i32 imm:$cc))>;
1590 def : Pat<(AArch64csneg GPR32:$tval, GPR32:$fval, (i32 imm:$cc), NZCV),
1591 (CSNEGWr GPR32:$tval, GPR32:$fval, (i32 imm:$cc))>;
1592 def : Pat<(AArch64csneg GPR64:$tval, GPR64:$fval, (i32 imm:$cc), NZCV),
1593 (CSNEGXr GPR64:$tval, GPR64:$fval, (i32 imm:$cc))>;
1594 def : Pat<(AArch64csinc GPR32:$tval, GPR32:$fval, (i32 imm:$cc), NZCV),
1595 (CSINCWr GPR32:$tval, GPR32:$fval, (i32 imm:$cc))>;
1596 def : Pat<(AArch64csinc GPR64:$tval, GPR64:$fval, (i32 imm:$cc), NZCV),
1597 (CSINCXr GPR64:$tval, GPR64:$fval, (i32 imm:$cc))>;
1599 def : Pat<(AArch64csel (i32 0), (i32 1), (i32 imm:$cc), NZCV),
1600 (CSINCWr WZR, WZR, (i32 imm:$cc))>;
1601 def : Pat<(AArch64csel (i64 0), (i64 1), (i32 imm:$cc), NZCV),
1602 (CSINCXr XZR, XZR, (i32 imm:$cc))>;
1603 def : Pat<(AArch64csel GPR32:$tval, (i32 1), (i32 imm:$cc), NZCV),
1604 (CSINCWr GPR32:$tval, WZR, (i32 imm:$cc))>;
1605 def : Pat<(AArch64csel GPR64:$tval, (i64 1), (i32 imm:$cc), NZCV),
1606 (CSINCXr GPR64:$tval, XZR, (i32 imm:$cc))>;
1607 def : Pat<(AArch64csel (i32 1), GPR32:$fval, (i32 imm:$cc), NZCV),
1608 (CSINCWr GPR32:$fval, WZR, (i32 (inv_cond_XFORM imm:$cc)))>;
1609 def : Pat<(AArch64csel (i64 1), GPR64:$fval, (i32 imm:$cc), NZCV),
1610 (CSINCXr GPR64:$fval, XZR, (i32 (inv_cond_XFORM imm:$cc)))>;
1611 def : Pat<(AArch64csel (i32 0), (i32 -1), (i32 imm:$cc), NZCV),
1612 (CSINVWr WZR, WZR, (i32 imm:$cc))>;
1613 def : Pat<(AArch64csel (i64 0), (i64 -1), (i32 imm:$cc), NZCV),
1614 (CSINVXr XZR, XZR, (i32 imm:$cc))>;
1615 def : Pat<(AArch64csel GPR32:$tval, (i32 -1), (i32 imm:$cc), NZCV),
1616 (CSINVWr GPR32:$tval, WZR, (i32 imm:$cc))>;
1617 def : Pat<(AArch64csel GPR64:$tval, (i64 -1), (i32 imm:$cc), NZCV),
1618 (CSINVXr GPR64:$tval, XZR, (i32 imm:$cc))>;
1619 def : Pat<(AArch64csel (i32 -1), GPR32:$fval, (i32 imm:$cc), NZCV),
1620 (CSINVWr GPR32:$fval, WZR, (i32 (inv_cond_XFORM imm:$cc)))>;
1621 def : Pat<(AArch64csel (i64 -1), GPR64:$fval, (i32 imm:$cc), NZCV),
1622 (CSINVXr GPR64:$fval, XZR, (i32 (inv_cond_XFORM imm:$cc)))>;
1624 // The inverse of the condition code from the alias instruction is what is used
1625 // in the aliased instruction. The parser all ready inverts the condition code
1626 // for these aliases.
1627 def : InstAlias<"cset $dst, $cc",
1628 (CSINCWr GPR32:$dst, WZR, WZR, inv_ccode:$cc)>;
1629 def : InstAlias<"cset $dst, $cc",
1630 (CSINCXr GPR64:$dst, XZR, XZR, inv_ccode:$cc)>;
1632 def : InstAlias<"csetm $dst, $cc",
1633 (CSINVWr GPR32:$dst, WZR, WZR, inv_ccode:$cc)>;
1634 def : InstAlias<"csetm $dst, $cc",
1635 (CSINVXr GPR64:$dst, XZR, XZR, inv_ccode:$cc)>;
1637 def : InstAlias<"cinc $dst, $src, $cc",
1638 (CSINCWr GPR32:$dst, GPR32:$src, GPR32:$src, inv_ccode:$cc)>;
1639 def : InstAlias<"cinc $dst, $src, $cc",
1640 (CSINCXr GPR64:$dst, GPR64:$src, GPR64:$src, inv_ccode:$cc)>;
1642 def : InstAlias<"cinv $dst, $src, $cc",
1643 (CSINVWr GPR32:$dst, GPR32:$src, GPR32:$src, inv_ccode:$cc)>;
1644 def : InstAlias<"cinv $dst, $src, $cc",
1645 (CSINVXr GPR64:$dst, GPR64:$src, GPR64:$src, inv_ccode:$cc)>;
1647 def : InstAlias<"cneg $dst, $src, $cc",
1648 (CSNEGWr GPR32:$dst, GPR32:$src, GPR32:$src, inv_ccode:$cc)>;
1649 def : InstAlias<"cneg $dst, $src, $cc",
1650 (CSNEGXr GPR64:$dst, GPR64:$src, GPR64:$src, inv_ccode:$cc)>;
1652 //===----------------------------------------------------------------------===//
1653 // PC-relative instructions.
1654 //===----------------------------------------------------------------------===//
1655 let isReMaterializable = 1 in {
1656 let hasSideEffects = 0, mayStore = 0, mayLoad = 0 in {
1657 def ADR : ADRI<0, "adr", adrlabel,
1658 [(set GPR64:$Xd, (AArch64adr tglobaladdr:$label))]>;
1659 } // hasSideEffects = 0
1661 def ADRP : ADRI<1, "adrp", adrplabel,
1662 [(set GPR64:$Xd, (AArch64adrp tglobaladdr:$label))]>;
1663 } // isReMaterializable = 1
1665 // page address of a constant pool entry, block address
1666 def : Pat<(AArch64adr tconstpool:$cp), (ADR tconstpool:$cp)>;
1667 def : Pat<(AArch64adr tblockaddress:$cp), (ADR tblockaddress:$cp)>;
1668 def : Pat<(AArch64adr texternalsym:$sym), (ADR texternalsym:$sym)>;
1669 def : Pat<(AArch64adr tjumptable:$sym), (ADR tjumptable:$sym)>;
1670 def : Pat<(AArch64adrp tconstpool:$cp), (ADRP tconstpool:$cp)>;
1671 def : Pat<(AArch64adrp tblockaddress:$cp), (ADRP tblockaddress:$cp)>;
1672 def : Pat<(AArch64adrp texternalsym:$sym), (ADRP texternalsym:$sym)>;
1674 //===----------------------------------------------------------------------===//
1675 // Unconditional branch (register) instructions.
1676 //===----------------------------------------------------------------------===//
1678 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
1679 def RET : BranchReg<0b0010, "ret", []>;
1680 def DRPS : SpecialReturn<0b0101, "drps">;
1681 def ERET : SpecialReturn<0b0100, "eret">;
1682 } // isReturn = 1, isTerminator = 1, isBarrier = 1
1684 // Default to the LR register.
1685 def : InstAlias<"ret", (RET LR)>;
1687 let isCall = 1, Defs = [LR], Uses = [SP] in {
1688 def BLR : BranchReg<0b0001, "blr", [(AArch64call GPR64:$Rn)]>;
1691 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
1692 def BR : BranchReg<0b0000, "br", [(brind GPR64:$Rn)]>;
1693 } // isBranch, isTerminator, isBarrier, isIndirectBranch
1695 // Create a separate pseudo-instruction for codegen to use so that we don't
1696 // flag lr as used in every function. It'll be restored before the RET by the
1697 // epilogue if it's legitimately used.
1698 def RET_ReallyLR : Pseudo<(outs), (ins), [(AArch64retflag)]>,
1699 Sched<[WriteBrReg]> {
1700 let isTerminator = 1;
1705 // This is a directive-like pseudo-instruction. The purpose is to insert an
1706 // R_AARCH64_TLSDESC_CALL relocation at the offset of the following instruction
1707 // (which in the usual case is a BLR).
1708 let hasSideEffects = 1 in
1709 def TLSDESCCALL : Pseudo<(outs), (ins i64imm:$sym), []>, Sched<[]> {
1710 let AsmString = ".tlsdesccall $sym";
1713 // Pseudo instruction to tell the streamer to emit a 'B' character into the
1714 // augmentation string.
1715 def EMITBKEY : Pseudo<(outs), (ins), []>, Sched<[]> {}
1717 // FIXME: maybe the scratch register used shouldn't be fixed to X1?
1718 // FIXME: can "hasSideEffects be dropped?
1719 let isCall = 1, Defs = [LR, X0, X1], hasSideEffects = 1,
1720 isCodeGenOnly = 1 in
1722 : Pseudo<(outs), (ins i64imm:$sym),
1723 [(AArch64tlsdesc_callseq tglobaltlsaddr:$sym)]>,
1724 Sched<[WriteI, WriteLD, WriteI, WriteBrReg]>;
1725 def : Pat<(AArch64tlsdesc_callseq texternalsym:$sym),
1726 (TLSDESC_CALLSEQ texternalsym:$sym)>;
1728 //===----------------------------------------------------------------------===//
1729 // Conditional branch (immediate) instruction.
1730 //===----------------------------------------------------------------------===//
1731 def Bcc : BranchCond;
1733 //===----------------------------------------------------------------------===//
1734 // Compare-and-branch instructions.
1735 //===----------------------------------------------------------------------===//
1736 defm CBZ : CmpBranch<0, "cbz", AArch64cbz>;
1737 defm CBNZ : CmpBranch<1, "cbnz", AArch64cbnz>;
1739 //===----------------------------------------------------------------------===//
1740 // Test-bit-and-branch instructions.
1741 //===----------------------------------------------------------------------===//
1742 defm TBZ : TestBranch<0, "tbz", AArch64tbz>;
1743 defm TBNZ : TestBranch<1, "tbnz", AArch64tbnz>;
1745 //===----------------------------------------------------------------------===//
1746 // Unconditional branch (immediate) instructions.
1747 //===----------------------------------------------------------------------===//
1748 let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
1749 def B : BranchImm<0, "b", [(br bb:$addr)]>;
1750 } // isBranch, isTerminator, isBarrier
1752 let isCall = 1, Defs = [LR], Uses = [SP] in {
1753 def BL : CallImm<1, "bl", [(AArch64call tglobaladdr:$addr)]>;
1755 def : Pat<(AArch64call texternalsym:$func), (BL texternalsym:$func)>;
1757 //===----------------------------------------------------------------------===//
1758 // Exception generation instructions.
1759 //===----------------------------------------------------------------------===//
1761 def BRK : ExceptionGeneration<0b001, 0b00, "brk">;
1763 def DCPS1 : ExceptionGeneration<0b101, 0b01, "dcps1">;
1764 def DCPS2 : ExceptionGeneration<0b101, 0b10, "dcps2">;
1765 def DCPS3 : ExceptionGeneration<0b101, 0b11, "dcps3">;
1766 def HLT : ExceptionGeneration<0b010, 0b00, "hlt">;
1767 def HVC : ExceptionGeneration<0b000, 0b10, "hvc">;
1768 def SMC : ExceptionGeneration<0b000, 0b11, "smc">;
1769 def SVC : ExceptionGeneration<0b000, 0b01, "svc">;
1771 // DCPSn defaults to an immediate operand of zero if unspecified.
1772 def : InstAlias<"dcps1", (DCPS1 0)>;
1773 def : InstAlias<"dcps2", (DCPS2 0)>;
1774 def : InstAlias<"dcps3", (DCPS3 0)>;
1776 def UDF : UDFType<0, "udf">;
1778 //===----------------------------------------------------------------------===//
1779 // Load instructions.
1780 //===----------------------------------------------------------------------===//
1782 // Pair (indexed, offset)
1783 defm LDPW : LoadPairOffset<0b00, 0, GPR32z, simm7s4, "ldp">;
1784 defm LDPX : LoadPairOffset<0b10, 0, GPR64z, simm7s8, "ldp">;
1785 defm LDPS : LoadPairOffset<0b00, 1, FPR32Op, simm7s4, "ldp">;
1786 defm LDPD : LoadPairOffset<0b01, 1, FPR64Op, simm7s8, "ldp">;
1787 defm LDPQ : LoadPairOffset<0b10, 1, FPR128Op, simm7s16, "ldp">;
1789 defm LDPSW : LoadPairOffset<0b01, 0, GPR64z, simm7s4, "ldpsw">;
1791 // Pair (pre-indexed)
1792 def LDPWpre : LoadPairPreIdx<0b00, 0, GPR32z, simm7s4, "ldp">;
1793 def LDPXpre : LoadPairPreIdx<0b10, 0, GPR64z, simm7s8, "ldp">;
1794 def LDPSpre : LoadPairPreIdx<0b00, 1, FPR32Op, simm7s4, "ldp">;
1795 def LDPDpre : LoadPairPreIdx<0b01, 1, FPR64Op, simm7s8, "ldp">;
1796 def LDPQpre : LoadPairPreIdx<0b10, 1, FPR128Op, simm7s16, "ldp">;
1798 def LDPSWpre : LoadPairPreIdx<0b01, 0, GPR64z, simm7s4, "ldpsw">;
1800 // Pair (post-indexed)
1801 def LDPWpost : LoadPairPostIdx<0b00, 0, GPR32z, simm7s4, "ldp">;
1802 def LDPXpost : LoadPairPostIdx<0b10, 0, GPR64z, simm7s8, "ldp">;
1803 def LDPSpost : LoadPairPostIdx<0b00, 1, FPR32Op, simm7s4, "ldp">;
1804 def LDPDpost : LoadPairPostIdx<0b01, 1, FPR64Op, simm7s8, "ldp">;
1805 def LDPQpost : LoadPairPostIdx<0b10, 1, FPR128Op, simm7s16, "ldp">;
1807 def LDPSWpost : LoadPairPostIdx<0b01, 0, GPR64z, simm7s4, "ldpsw">;
1810 // Pair (no allocate)
1811 defm LDNPW : LoadPairNoAlloc<0b00, 0, GPR32z, simm7s4, "ldnp">;
1812 defm LDNPX : LoadPairNoAlloc<0b10, 0, GPR64z, simm7s8, "ldnp">;
1813 defm LDNPS : LoadPairNoAlloc<0b00, 1, FPR32Op, simm7s4, "ldnp">;
1814 defm LDNPD : LoadPairNoAlloc<0b01, 1, FPR64Op, simm7s8, "ldnp">;
1815 defm LDNPQ : LoadPairNoAlloc<0b10, 1, FPR128Op, simm7s16, "ldnp">;
1818 // (register offset)
1822 defm LDRBB : Load8RO<0b00, 0, 0b01, GPR32, "ldrb", i32, zextloadi8>;
1823 defm LDRHH : Load16RO<0b01, 0, 0b01, GPR32, "ldrh", i32, zextloadi16>;
1824 defm LDRW : Load32RO<0b10, 0, 0b01, GPR32, "ldr", i32, load>;
1825 defm LDRX : Load64RO<0b11, 0, 0b01, GPR64, "ldr", i64, load>;
1828 defm LDRB : Load8RO<0b00, 1, 0b01, FPR8Op, "ldr", untyped, load>;
1829 defm LDRH : Load16RO<0b01, 1, 0b01, FPR16Op, "ldr", f16, load>;
1830 defm LDRS : Load32RO<0b10, 1, 0b01, FPR32Op, "ldr", f32, load>;
1831 defm LDRD : Load64RO<0b11, 1, 0b01, FPR64Op, "ldr", f64, load>;
1832 defm LDRQ : Load128RO<0b00, 1, 0b11, FPR128Op, "ldr", f128, load>;
1834 // Load sign-extended half-word
1835 defm LDRSHW : Load16RO<0b01, 0, 0b11, GPR32, "ldrsh", i32, sextloadi16>;
1836 defm LDRSHX : Load16RO<0b01, 0, 0b10, GPR64, "ldrsh", i64, sextloadi16>;
1838 // Load sign-extended byte
1839 defm LDRSBW : Load8RO<0b00, 0, 0b11, GPR32, "ldrsb", i32, sextloadi8>;
1840 defm LDRSBX : Load8RO<0b00, 0, 0b10, GPR64, "ldrsb", i64, sextloadi8>;
1842 // Load sign-extended word
1843 defm LDRSW : Load32RO<0b10, 0, 0b10, GPR64, "ldrsw", i64, sextloadi32>;
1846 defm PRFM : PrefetchRO<0b11, 0, 0b10, "prfm">;
1848 // For regular load, we do not have any alignment requirement.
1849 // Thus, it is safe to directly map the vector loads with interesting
1850 // addressing modes.
1851 // FIXME: We could do the same for bitconvert to floating point vectors.
1852 multiclass ScalToVecROLoadPat<ROAddrMode ro, SDPatternOperator loadop,
1853 ValueType ScalTy, ValueType VecTy,
1854 Instruction LOADW, Instruction LOADX,
1856 def : Pat<(VecTy (scalar_to_vector (ScalTy
1857 (loadop (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$offset))))),
1858 (INSERT_SUBREG (VecTy (IMPLICIT_DEF)),
1859 (LOADW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$offset),
1862 def : Pat<(VecTy (scalar_to_vector (ScalTy
1863 (loadop (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$offset))))),
1864 (INSERT_SUBREG (VecTy (IMPLICIT_DEF)),
1865 (LOADX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$offset),
1869 let AddedComplexity = 10 in {
1870 defm : ScalToVecROLoadPat<ro8, extloadi8, i32, v8i8, LDRBroW, LDRBroX, bsub>;
1871 defm : ScalToVecROLoadPat<ro8, extloadi8, i32, v16i8, LDRBroW, LDRBroX, bsub>;
1873 defm : ScalToVecROLoadPat<ro16, extloadi16, i32, v4i16, LDRHroW, LDRHroX, hsub>;
1874 defm : ScalToVecROLoadPat<ro16, extloadi16, i32, v8i16, LDRHroW, LDRHroX, hsub>;
1876 defm : ScalToVecROLoadPat<ro16, load, i32, v4f16, LDRHroW, LDRHroX, hsub>;
1877 defm : ScalToVecROLoadPat<ro16, load, i32, v8f16, LDRHroW, LDRHroX, hsub>;
1879 defm : ScalToVecROLoadPat<ro32, load, i32, v2i32, LDRSroW, LDRSroX, ssub>;
1880 defm : ScalToVecROLoadPat<ro32, load, i32, v4i32, LDRSroW, LDRSroX, ssub>;
1882 defm : ScalToVecROLoadPat<ro32, load, f32, v2f32, LDRSroW, LDRSroX, ssub>;
1883 defm : ScalToVecROLoadPat<ro32, load, f32, v4f32, LDRSroW, LDRSroX, ssub>;
1885 defm : ScalToVecROLoadPat<ro64, load, i64, v2i64, LDRDroW, LDRDroX, dsub>;
1887 defm : ScalToVecROLoadPat<ro64, load, f64, v2f64, LDRDroW, LDRDroX, dsub>;
1890 def : Pat <(v1i64 (scalar_to_vector (i64
1891 (load (ro_Windexed64 GPR64sp:$Rn, GPR32:$Rm,
1892 ro_Wextend64:$extend))))),
1893 (LDRDroW GPR64sp:$Rn, GPR32:$Rm, ro_Wextend64:$extend)>;
1895 def : Pat <(v1i64 (scalar_to_vector (i64
1896 (load (ro_Xindexed64 GPR64sp:$Rn, GPR64:$Rm,
1897 ro_Xextend64:$extend))))),
1898 (LDRDroX GPR64sp:$Rn, GPR64:$Rm, ro_Xextend64:$extend)>;
1901 // Match all load 64 bits width whose type is compatible with FPR64
1902 multiclass VecROLoadPat<ROAddrMode ro, ValueType VecTy,
1903 Instruction LOADW, Instruction LOADX> {
1905 def : Pat<(VecTy (load (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend))),
1906 (LOADW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
1908 def : Pat<(VecTy (load (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend))),
1909 (LOADX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
1912 let AddedComplexity = 10 in {
1913 let Predicates = [IsLE] in {
1914 // We must do vector loads with LD1 in big-endian.
1915 defm : VecROLoadPat<ro64, v2i32, LDRDroW, LDRDroX>;
1916 defm : VecROLoadPat<ro64, v2f32, LDRDroW, LDRDroX>;
1917 defm : VecROLoadPat<ro64, v8i8, LDRDroW, LDRDroX>;
1918 defm : VecROLoadPat<ro64, v4i16, LDRDroW, LDRDroX>;
1919 defm : VecROLoadPat<ro64, v4f16, LDRDroW, LDRDroX>;
1922 defm : VecROLoadPat<ro64, v1i64, LDRDroW, LDRDroX>;
1923 defm : VecROLoadPat<ro64, v1f64, LDRDroW, LDRDroX>;
1925 // Match all load 128 bits width whose type is compatible with FPR128
1926 let Predicates = [IsLE] in {
1927 // We must do vector loads with LD1 in big-endian.
1928 defm : VecROLoadPat<ro128, v2i64, LDRQroW, LDRQroX>;
1929 defm : VecROLoadPat<ro128, v2f64, LDRQroW, LDRQroX>;
1930 defm : VecROLoadPat<ro128, v4i32, LDRQroW, LDRQroX>;
1931 defm : VecROLoadPat<ro128, v4f32, LDRQroW, LDRQroX>;
1932 defm : VecROLoadPat<ro128, v8i16, LDRQroW, LDRQroX>;
1933 defm : VecROLoadPat<ro128, v8f16, LDRQroW, LDRQroX>;
1934 defm : VecROLoadPat<ro128, v16i8, LDRQroW, LDRQroX>;
1936 } // AddedComplexity = 10
1939 multiclass ExtLoadTo64ROPat<ROAddrMode ro, SDPatternOperator loadop,
1940 Instruction INSTW, Instruction INSTX> {
1941 def : Pat<(i64 (loadop (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend))),
1942 (SUBREG_TO_REG (i64 0),
1943 (INSTW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend),
1946 def : Pat<(i64 (loadop (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend))),
1947 (SUBREG_TO_REG (i64 0),
1948 (INSTX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend),
1952 let AddedComplexity = 10 in {
1953 defm : ExtLoadTo64ROPat<ro8, zextloadi8, LDRBBroW, LDRBBroX>;
1954 defm : ExtLoadTo64ROPat<ro16, zextloadi16, LDRHHroW, LDRHHroX>;
1955 defm : ExtLoadTo64ROPat<ro32, zextloadi32, LDRWroW, LDRWroX>;
1957 // zextloadi1 -> zextloadi8
1958 defm : ExtLoadTo64ROPat<ro8, zextloadi1, LDRBBroW, LDRBBroX>;
1960 // extload -> zextload
1961 defm : ExtLoadTo64ROPat<ro8, extloadi8, LDRBBroW, LDRBBroX>;
1962 defm : ExtLoadTo64ROPat<ro16, extloadi16, LDRHHroW, LDRHHroX>;
1963 defm : ExtLoadTo64ROPat<ro32, extloadi32, LDRWroW, LDRWroX>;
1965 // extloadi1 -> zextloadi8
1966 defm : ExtLoadTo64ROPat<ro8, extloadi1, LDRBBroW, LDRBBroX>;
1971 multiclass ExtLoadTo32ROPat<ROAddrMode ro, SDPatternOperator loadop,
1972 Instruction INSTW, Instruction INSTX> {
1973 def : Pat<(i32 (loadop (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend))),
1974 (INSTW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
1976 def : Pat<(i32 (loadop (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend))),
1977 (INSTX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
1981 let AddedComplexity = 10 in {
1982 // extload -> zextload
1983 defm : ExtLoadTo32ROPat<ro8, extloadi8, LDRBBroW, LDRBBroX>;
1984 defm : ExtLoadTo32ROPat<ro16, extloadi16, LDRHHroW, LDRHHroX>;
1985 defm : ExtLoadTo32ROPat<ro32, extloadi32, LDRWroW, LDRWroX>;
1987 // zextloadi1 -> zextloadi8
1988 defm : ExtLoadTo32ROPat<ro8, zextloadi1, LDRBBroW, LDRBBroX>;
1992 // (unsigned immediate)
1994 defm LDRX : LoadUI<0b11, 0, 0b01, GPR64z, uimm12s8, "ldr",
1996 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)))]>;
1997 defm LDRW : LoadUI<0b10, 0, 0b01, GPR32z, uimm12s4, "ldr",
1999 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset)))]>;
2000 defm LDRB : LoadUI<0b00, 1, 0b01, FPR8Op, uimm12s1, "ldr",
2002 (load (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset)))]>;
2003 defm LDRH : LoadUI<0b01, 1, 0b01, FPR16Op, uimm12s2, "ldr",
2004 [(set (f16 FPR16Op:$Rt),
2005 (load (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset)))]>;
2006 defm LDRS : LoadUI<0b10, 1, 0b01, FPR32Op, uimm12s4, "ldr",
2007 [(set (f32 FPR32Op:$Rt),
2008 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset)))]>;
2009 defm LDRD : LoadUI<0b11, 1, 0b01, FPR64Op, uimm12s8, "ldr",
2010 [(set (f64 FPR64Op:$Rt),
2011 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)))]>;
2012 defm LDRQ : LoadUI<0b00, 1, 0b11, FPR128Op, uimm12s16, "ldr",
2013 [(set (f128 FPR128Op:$Rt),
2014 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)))]>;
2016 // For regular load, we do not have any alignment requirement.
2017 // Thus, it is safe to directly map the vector loads with interesting
2018 // addressing modes.
2019 // FIXME: We could do the same for bitconvert to floating point vectors.
2020 def : Pat <(v8i8 (scalar_to_vector (i32
2021 (extloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))))),
2022 (INSERT_SUBREG (v8i8 (IMPLICIT_DEF)),
2023 (LDRBui GPR64sp:$Rn, uimm12s1:$offset), bsub)>;
2024 def : Pat <(v16i8 (scalar_to_vector (i32
2025 (extloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))))),
2026 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
2027 (LDRBui GPR64sp:$Rn, uimm12s1:$offset), bsub)>;
2028 def : Pat <(v4i16 (scalar_to_vector (i32
2029 (extloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))))),
2030 (INSERT_SUBREG (v4i16 (IMPLICIT_DEF)),
2031 (LDRHui GPR64sp:$Rn, uimm12s2:$offset), hsub)>;
2032 def : Pat <(v8i16 (scalar_to_vector (i32
2033 (extloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))))),
2034 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)),
2035 (LDRHui GPR64sp:$Rn, uimm12s2:$offset), hsub)>;
2036 def : Pat <(v2i32 (scalar_to_vector (i32
2037 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))))),
2038 (INSERT_SUBREG (v2i32 (IMPLICIT_DEF)),
2039 (LDRSui GPR64sp:$Rn, uimm12s4:$offset), ssub)>;
2040 def : Pat <(v4i32 (scalar_to_vector (i32
2041 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))))),
2042 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)),
2043 (LDRSui GPR64sp:$Rn, uimm12s4:$offset), ssub)>;
2044 def : Pat <(v1i64 (scalar_to_vector (i64
2045 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))))),
2046 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2047 def : Pat <(v2i64 (scalar_to_vector (i64
2048 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))))),
2049 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)),
2050 (LDRDui GPR64sp:$Rn, uimm12s8:$offset), dsub)>;
2052 // Match all load 64 bits width whose type is compatible with FPR64
2053 let Predicates = [IsLE] in {
2054 // We must use LD1 to perform vector loads in big-endian.
2055 def : Pat<(v2f32 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2056 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2057 def : Pat<(v8i8 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2058 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2059 def : Pat<(v4i16 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2060 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2061 def : Pat<(v2i32 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2062 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2063 def : Pat<(v4f16 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2064 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2066 def : Pat<(v1f64 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2067 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2068 def : Pat<(v1i64 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2069 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2071 // Match all load 128 bits width whose type is compatible with FPR128
2072 let Predicates = [IsLE] in {
2073 // We must use LD1 to perform vector loads in big-endian.
2074 def : Pat<(v4f32 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2075 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2076 def : Pat<(v2f64 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2077 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2078 def : Pat<(v16i8 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2079 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2080 def : Pat<(v8i16 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2081 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2082 def : Pat<(v4i32 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2083 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2084 def : Pat<(v2i64 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2085 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2086 def : Pat<(v8f16 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2087 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2089 def : Pat<(f128 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2090 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2092 defm LDRHH : LoadUI<0b01, 0, 0b01, GPR32, uimm12s2, "ldrh",
2094 (zextloadi16 (am_indexed16 GPR64sp:$Rn,
2095 uimm12s2:$offset)))]>;
2096 defm LDRBB : LoadUI<0b00, 0, 0b01, GPR32, uimm12s1, "ldrb",
2098 (zextloadi8 (am_indexed8 GPR64sp:$Rn,
2099 uimm12s1:$offset)))]>;
2101 def : Pat<(i64 (zextloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2102 (SUBREG_TO_REG (i64 0), (LDRBBui GPR64sp:$Rn, uimm12s1:$offset), sub_32)>;
2103 def : Pat<(i64 (zextloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))),
2104 (SUBREG_TO_REG (i64 0), (LDRHHui GPR64sp:$Rn, uimm12s2:$offset), sub_32)>;
2106 // zextloadi1 -> zextloadi8
2107 def : Pat<(i32 (zextloadi1 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2108 (LDRBBui GPR64sp:$Rn, uimm12s1:$offset)>;
2109 def : Pat<(i64 (zextloadi1 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2110 (SUBREG_TO_REG (i64 0), (LDRBBui GPR64sp:$Rn, uimm12s1:$offset), sub_32)>;
2112 // extload -> zextload
2113 def : Pat<(i32 (extloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))),
2114 (LDRHHui GPR64sp:$Rn, uimm12s2:$offset)>;
2115 def : Pat<(i32 (extloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2116 (LDRBBui GPR64sp:$Rn, uimm12s1:$offset)>;
2117 def : Pat<(i32 (extloadi1 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2118 (LDRBBui GPR64sp:$Rn, uimm12s1:$offset)>;
2119 def : Pat<(i64 (extloadi32 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))),
2120 (SUBREG_TO_REG (i64 0), (LDRWui GPR64sp:$Rn, uimm12s4:$offset), sub_32)>;
2121 def : Pat<(i64 (extloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))),
2122 (SUBREG_TO_REG (i64 0), (LDRHHui GPR64sp:$Rn, uimm12s2:$offset), sub_32)>;
2123 def : Pat<(i64 (extloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2124 (SUBREG_TO_REG (i64 0), (LDRBBui GPR64sp:$Rn, uimm12s1:$offset), sub_32)>;
2125 def : Pat<(i64 (extloadi1 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2126 (SUBREG_TO_REG (i64 0), (LDRBBui GPR64sp:$Rn, uimm12s1:$offset), sub_32)>;
2128 // load sign-extended half-word
2129 defm LDRSHW : LoadUI<0b01, 0, 0b11, GPR32, uimm12s2, "ldrsh",
2131 (sextloadi16 (am_indexed16 GPR64sp:$Rn,
2132 uimm12s2:$offset)))]>;
2133 defm LDRSHX : LoadUI<0b01, 0, 0b10, GPR64, uimm12s2, "ldrsh",
2135 (sextloadi16 (am_indexed16 GPR64sp:$Rn,
2136 uimm12s2:$offset)))]>;
2138 // load sign-extended byte
2139 defm LDRSBW : LoadUI<0b00, 0, 0b11, GPR32, uimm12s1, "ldrsb",
2141 (sextloadi8 (am_indexed8 GPR64sp:$Rn,
2142 uimm12s1:$offset)))]>;
2143 defm LDRSBX : LoadUI<0b00, 0, 0b10, GPR64, uimm12s1, "ldrsb",
2145 (sextloadi8 (am_indexed8 GPR64sp:$Rn,
2146 uimm12s1:$offset)))]>;
2148 // load sign-extended word
2149 defm LDRSW : LoadUI<0b10, 0, 0b10, GPR64, uimm12s4, "ldrsw",
2151 (sextloadi32 (am_indexed32 GPR64sp:$Rn,
2152 uimm12s4:$offset)))]>;
2154 // load zero-extended word
2155 def : Pat<(i64 (zextloadi32 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))),
2156 (SUBREG_TO_REG (i64 0), (LDRWui GPR64sp:$Rn, uimm12s4:$offset), sub_32)>;
2159 def PRFMui : PrefetchUI<0b11, 0, 0b10, "prfm",
2160 [(AArch64Prefetch imm:$Rt,
2161 (am_indexed64 GPR64sp:$Rn,
2162 uimm12s8:$offset))]>;
2164 def : InstAlias<"prfm $Rt, [$Rn]", (PRFMui prfop:$Rt, GPR64sp:$Rn, 0)>;
2169 def alignedglobal : PatLeaf<(iPTR iPTR:$label), [{
2170 if (auto *G = dyn_cast<GlobalAddressSDNode>(N)) {
2171 const DataLayout &DL = MF->getDataLayout();
2172 unsigned Align = G->getGlobal()->getPointerAlignment(DL);
2173 return Align >= 4 && G->getOffset() % 4 == 0;
2175 if (auto *C = dyn_cast<ConstantPoolSDNode>(N))
2176 return C->getAlignment() >= 4 && C->getOffset() % 4 == 0;
2180 def LDRWl : LoadLiteral<0b00, 0, GPR32z, "ldr",
2181 [(set GPR32z:$Rt, (load (AArch64adr alignedglobal:$label)))]>;
2182 def LDRXl : LoadLiteral<0b01, 0, GPR64z, "ldr",
2183 [(set GPR64z:$Rt, (load (AArch64adr alignedglobal:$label)))]>;
2184 def LDRSl : LoadLiteral<0b00, 1, FPR32Op, "ldr",
2185 [(set (f32 FPR32Op:$Rt), (load (AArch64adr alignedglobal:$label)))]>;
2186 def LDRDl : LoadLiteral<0b01, 1, FPR64Op, "ldr",
2187 [(set (f64 FPR64Op:$Rt), (load (AArch64adr alignedglobal:$label)))]>;
2188 def LDRQl : LoadLiteral<0b10, 1, FPR128Op, "ldr",
2189 [(set (f128 FPR128Op:$Rt), (load (AArch64adr alignedglobal:$label)))]>;
2191 // load sign-extended word
2192 def LDRSWl : LoadLiteral<0b10, 0, GPR64z, "ldrsw",
2193 [(set GPR64z:$Rt, (sextloadi32 (AArch64adr alignedglobal:$label)))]>;
2195 let AddedComplexity = 20 in {
2196 def : Pat<(i64 (zextloadi32 (AArch64adr alignedglobal:$label))),
2197 (SUBREG_TO_REG (i64 0), (LDRWl $label), sub_32)>;
2201 def PRFMl : PrefetchLiteral<0b11, 0, "prfm", []>;
2202 // [(AArch64Prefetch imm:$Rt, tglobaladdr:$label)]>;
2205 // (unscaled immediate)
2206 defm LDURX : LoadUnscaled<0b11, 0, 0b01, GPR64z, "ldur",
2208 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset)))]>;
2209 defm LDURW : LoadUnscaled<0b10, 0, 0b01, GPR32z, "ldur",
2211 (load (am_unscaled32 GPR64sp:$Rn, simm9:$offset)))]>;
2212 defm LDURB : LoadUnscaled<0b00, 1, 0b01, FPR8Op, "ldur",
2214 (load (am_unscaled8 GPR64sp:$Rn, simm9:$offset)))]>;
2215 defm LDURH : LoadUnscaled<0b01, 1, 0b01, FPR16Op, "ldur",
2217 (load (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
2218 defm LDURS : LoadUnscaled<0b10, 1, 0b01, FPR32Op, "ldur",
2219 [(set (f32 FPR32Op:$Rt),
2220 (load (am_unscaled32 GPR64sp:$Rn, simm9:$offset)))]>;
2221 defm LDURD : LoadUnscaled<0b11, 1, 0b01, FPR64Op, "ldur",
2222 [(set (f64 FPR64Op:$Rt),
2223 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset)))]>;
2224 defm LDURQ : LoadUnscaled<0b00, 1, 0b11, FPR128Op, "ldur",
2225 [(set (f128 FPR128Op:$Rt),
2226 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset)))]>;
2229 : LoadUnscaled<0b01, 0, 0b01, GPR32, "ldurh",
2231 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
2233 : LoadUnscaled<0b00, 0, 0b01, GPR32, "ldurb",
2235 (zextloadi8 (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
2237 // Match all load 64 bits width whose type is compatible with FPR64
2238 let Predicates = [IsLE] in {
2239 def : Pat<(v2f32 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2240 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2241 def : Pat<(v2i32 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2242 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2243 def : Pat<(v4i16 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2244 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2245 def : Pat<(v8i8 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2246 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2247 def : Pat<(v4f16 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2248 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2250 def : Pat<(v1f64 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2251 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2252 def : Pat<(v1i64 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2253 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2255 // Match all load 128 bits width whose type is compatible with FPR128
2256 let Predicates = [IsLE] in {
2257 def : Pat<(v2f64 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2258 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2259 def : Pat<(v2i64 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2260 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2261 def : Pat<(v4f32 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2262 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2263 def : Pat<(v4i32 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2264 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2265 def : Pat<(v8i16 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2266 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2267 def : Pat<(v16i8 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2268 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2269 def : Pat<(v8f16 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2270 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2274 def : Pat<(i32 (extloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
2275 (LDURHHi GPR64sp:$Rn, simm9:$offset)>;
2276 def : Pat<(i32 (extloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2277 (LDURBBi GPR64sp:$Rn, simm9:$offset)>;
2278 def : Pat<(i32 (extloadi1 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2279 (LDURBBi GPR64sp:$Rn, simm9:$offset)>;
2280 def : Pat<(i64 (extloadi32 (am_unscaled32 GPR64sp:$Rn, simm9:$offset))),
2281 (SUBREG_TO_REG (i64 0), (LDURWi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2282 def : Pat<(i64 (extloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
2283 (SUBREG_TO_REG (i64 0), (LDURHHi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2284 def : Pat<(i64 (extloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2285 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2286 def : Pat<(i64 (extloadi1 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2287 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2289 def : Pat<(i32 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
2290 (LDURHHi GPR64sp:$Rn, simm9:$offset)>;
2291 def : Pat<(i32 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2292 (LDURBBi GPR64sp:$Rn, simm9:$offset)>;
2293 def : Pat<(i32 (zextloadi1 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2294 (LDURBBi GPR64sp:$Rn, simm9:$offset)>;
2295 def : Pat<(i64 (zextloadi32 (am_unscaled32 GPR64sp:$Rn, simm9:$offset))),
2296 (SUBREG_TO_REG (i64 0), (LDURWi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2297 def : Pat<(i64 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
2298 (SUBREG_TO_REG (i64 0), (LDURHHi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2299 def : Pat<(i64 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2300 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2301 def : Pat<(i64 (zextloadi1 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2302 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2306 // LDR mnemonics fall back to LDUR for negative or unaligned offsets.
2308 // Define new assembler match classes as we want to only match these when
2309 // the don't otherwise match the scaled addressing mode for LDR/STR. Don't
2310 // associate a DiagnosticType either, as we want the diagnostic for the
2311 // canonical form (the scaled operand) to take precedence.
2312 class SImm9OffsetOperand<int Width> : AsmOperandClass {
2313 let Name = "SImm9OffsetFB" # Width;
2314 let PredicateMethod = "isSImm9OffsetFB<" # Width # ">";
2315 let RenderMethod = "addImmOperands";
2318 def SImm9OffsetFB8Operand : SImm9OffsetOperand<8>;
2319 def SImm9OffsetFB16Operand : SImm9OffsetOperand<16>;
2320 def SImm9OffsetFB32Operand : SImm9OffsetOperand<32>;
2321 def SImm9OffsetFB64Operand : SImm9OffsetOperand<64>;
2322 def SImm9OffsetFB128Operand : SImm9OffsetOperand<128>;
2324 def simm9_offset_fb8 : Operand<i64> {
2325 let ParserMatchClass = SImm9OffsetFB8Operand;
2327 def simm9_offset_fb16 : Operand<i64> {
2328 let ParserMatchClass = SImm9OffsetFB16Operand;
2330 def simm9_offset_fb32 : Operand<i64> {
2331 let ParserMatchClass = SImm9OffsetFB32Operand;
2333 def simm9_offset_fb64 : Operand<i64> {
2334 let ParserMatchClass = SImm9OffsetFB64Operand;
2336 def simm9_offset_fb128 : Operand<i64> {
2337 let ParserMatchClass = SImm9OffsetFB128Operand;
2340 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2341 (LDURXi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb64:$offset), 0>;
2342 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2343 (LDURWi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
2344 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2345 (LDURBi FPR8Op:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2346 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2347 (LDURHi FPR16Op:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2348 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2349 (LDURSi FPR32Op:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
2350 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2351 (LDURDi FPR64Op:$Rt, GPR64sp:$Rn, simm9_offset_fb64:$offset), 0>;
2352 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2353 (LDURQi FPR128Op:$Rt, GPR64sp:$Rn, simm9_offset_fb128:$offset), 0>;
2356 def : Pat<(i64 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2357 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2358 def : Pat<(i64 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
2359 (SUBREG_TO_REG (i64 0), (LDURHHi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2361 // load sign-extended half-word
2363 : LoadUnscaled<0b01, 0, 0b11, GPR32, "ldursh",
2365 (sextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
2367 : LoadUnscaled<0b01, 0, 0b10, GPR64, "ldursh",
2369 (sextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
2371 // load sign-extended byte
2373 : LoadUnscaled<0b00, 0, 0b11, GPR32, "ldursb",
2375 (sextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset)))]>;
2377 : LoadUnscaled<0b00, 0, 0b10, GPR64, "ldursb",
2379 (sextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset)))]>;
2381 // load sign-extended word
2383 : LoadUnscaled<0b10, 0, 0b10, GPR64, "ldursw",
2385 (sextloadi32 (am_unscaled32 GPR64sp:$Rn, simm9:$offset)))]>;
2387 // zero and sign extending aliases from generic LDR* mnemonics to LDUR*.
2388 def : InstAlias<"ldrb $Rt, [$Rn, $offset]",
2389 (LDURBBi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2390 def : InstAlias<"ldrh $Rt, [$Rn, $offset]",
2391 (LDURHHi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2392 def : InstAlias<"ldrsb $Rt, [$Rn, $offset]",
2393 (LDURSBWi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2394 def : InstAlias<"ldrsb $Rt, [$Rn, $offset]",
2395 (LDURSBXi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2396 def : InstAlias<"ldrsh $Rt, [$Rn, $offset]",
2397 (LDURSHWi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2398 def : InstAlias<"ldrsh $Rt, [$Rn, $offset]",
2399 (LDURSHXi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2400 def : InstAlias<"ldrsw $Rt, [$Rn, $offset]",
2401 (LDURSWi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
2404 defm PRFUM : PrefetchUnscaled<0b11, 0, 0b10, "prfum",
2405 [(AArch64Prefetch imm:$Rt,
2406 (am_unscaled64 GPR64sp:$Rn, simm9:$offset))]>;
2409 // (unscaled immediate, unprivileged)
2410 defm LDTRX : LoadUnprivileged<0b11, 0, 0b01, GPR64, "ldtr">;
2411 defm LDTRW : LoadUnprivileged<0b10, 0, 0b01, GPR32, "ldtr">;
2413 defm LDTRH : LoadUnprivileged<0b01, 0, 0b01, GPR32, "ldtrh">;
2414 defm LDTRB : LoadUnprivileged<0b00, 0, 0b01, GPR32, "ldtrb">;
2416 // load sign-extended half-word
2417 defm LDTRSHW : LoadUnprivileged<0b01, 0, 0b11, GPR32, "ldtrsh">;
2418 defm LDTRSHX : LoadUnprivileged<0b01, 0, 0b10, GPR64, "ldtrsh">;
2420 // load sign-extended byte
2421 defm LDTRSBW : LoadUnprivileged<0b00, 0, 0b11, GPR32, "ldtrsb">;
2422 defm LDTRSBX : LoadUnprivileged<0b00, 0, 0b10, GPR64, "ldtrsb">;
2424 // load sign-extended word
2425 defm LDTRSW : LoadUnprivileged<0b10, 0, 0b10, GPR64, "ldtrsw">;
2428 // (immediate pre-indexed)
2429 def LDRWpre : LoadPreIdx<0b10, 0, 0b01, GPR32z, "ldr">;
2430 def LDRXpre : LoadPreIdx<0b11, 0, 0b01, GPR64z, "ldr">;
2431 def LDRBpre : LoadPreIdx<0b00, 1, 0b01, FPR8Op, "ldr">;
2432 def LDRHpre : LoadPreIdx<0b01, 1, 0b01, FPR16Op, "ldr">;
2433 def LDRSpre : LoadPreIdx<0b10, 1, 0b01, FPR32Op, "ldr">;
2434 def LDRDpre : LoadPreIdx<0b11, 1, 0b01, FPR64Op, "ldr">;
2435 def LDRQpre : LoadPreIdx<0b00, 1, 0b11, FPR128Op, "ldr">;
2437 // load sign-extended half-word
2438 def LDRSHWpre : LoadPreIdx<0b01, 0, 0b11, GPR32z, "ldrsh">;
2439 def LDRSHXpre : LoadPreIdx<0b01, 0, 0b10, GPR64z, "ldrsh">;
2441 // load sign-extended byte
2442 def LDRSBWpre : LoadPreIdx<0b00, 0, 0b11, GPR32z, "ldrsb">;
2443 def LDRSBXpre : LoadPreIdx<0b00, 0, 0b10, GPR64z, "ldrsb">;
2445 // load zero-extended byte
2446 def LDRBBpre : LoadPreIdx<0b00, 0, 0b01, GPR32z, "ldrb">;
2447 def LDRHHpre : LoadPreIdx<0b01, 0, 0b01, GPR32z, "ldrh">;
2449 // load sign-extended word
2450 def LDRSWpre : LoadPreIdx<0b10, 0, 0b10, GPR64z, "ldrsw">;
2453 // (immediate post-indexed)
2454 def LDRWpost : LoadPostIdx<0b10, 0, 0b01, GPR32z, "ldr">;
2455 def LDRXpost : LoadPostIdx<0b11, 0, 0b01, GPR64z, "ldr">;
2456 def LDRBpost : LoadPostIdx<0b00, 1, 0b01, FPR8Op, "ldr">;
2457 def LDRHpost : LoadPostIdx<0b01, 1, 0b01, FPR16Op, "ldr">;
2458 def LDRSpost : LoadPostIdx<0b10, 1, 0b01, FPR32Op, "ldr">;
2459 def LDRDpost : LoadPostIdx<0b11, 1, 0b01, FPR64Op, "ldr">;
2460 def LDRQpost : LoadPostIdx<0b00, 1, 0b11, FPR128Op, "ldr">;
2462 // load sign-extended half-word
2463 def LDRSHWpost : LoadPostIdx<0b01, 0, 0b11, GPR32z, "ldrsh">;
2464 def LDRSHXpost : LoadPostIdx<0b01, 0, 0b10, GPR64z, "ldrsh">;
2466 // load sign-extended byte
2467 def LDRSBWpost : LoadPostIdx<0b00, 0, 0b11, GPR32z, "ldrsb">;
2468 def LDRSBXpost : LoadPostIdx<0b00, 0, 0b10, GPR64z, "ldrsb">;
2470 // load zero-extended byte
2471 def LDRBBpost : LoadPostIdx<0b00, 0, 0b01, GPR32z, "ldrb">;
2472 def LDRHHpost : LoadPostIdx<0b01, 0, 0b01, GPR32z, "ldrh">;
2474 // load sign-extended word
2475 def LDRSWpost : LoadPostIdx<0b10, 0, 0b10, GPR64z, "ldrsw">;
2477 //===----------------------------------------------------------------------===//
2478 // Store instructions.
2479 //===----------------------------------------------------------------------===//
2481 // Pair (indexed, offset)
2482 // FIXME: Use dedicated range-checked addressing mode operand here.
2483 defm STPW : StorePairOffset<0b00, 0, GPR32z, simm7s4, "stp">;
2484 defm STPX : StorePairOffset<0b10, 0, GPR64z, simm7s8, "stp">;
2485 defm STPS : StorePairOffset<0b00, 1, FPR32Op, simm7s4, "stp">;
2486 defm STPD : StorePairOffset<0b01, 1, FPR64Op, simm7s8, "stp">;
2487 defm STPQ : StorePairOffset<0b10, 1, FPR128Op, simm7s16, "stp">;
2489 // Pair (pre-indexed)
2490 def STPWpre : StorePairPreIdx<0b00, 0, GPR32z, simm7s4, "stp">;
2491 def STPXpre : StorePairPreIdx<0b10, 0, GPR64z, simm7s8, "stp">;
2492 def STPSpre : StorePairPreIdx<0b00, 1, FPR32Op, simm7s4, "stp">;
2493 def STPDpre : StorePairPreIdx<0b01, 1, FPR64Op, simm7s8, "stp">;
2494 def STPQpre : StorePairPreIdx<0b10, 1, FPR128Op, simm7s16, "stp">;
2496 // Pair (pre-indexed)
2497 def STPWpost : StorePairPostIdx<0b00, 0, GPR32z, simm7s4, "stp">;
2498 def STPXpost : StorePairPostIdx<0b10, 0, GPR64z, simm7s8, "stp">;
2499 def STPSpost : StorePairPostIdx<0b00, 1, FPR32Op, simm7s4, "stp">;
2500 def STPDpost : StorePairPostIdx<0b01, 1, FPR64Op, simm7s8, "stp">;
2501 def STPQpost : StorePairPostIdx<0b10, 1, FPR128Op, simm7s16, "stp">;
2503 // Pair (no allocate)
2504 defm STNPW : StorePairNoAlloc<0b00, 0, GPR32z, simm7s4, "stnp">;
2505 defm STNPX : StorePairNoAlloc<0b10, 0, GPR64z, simm7s8, "stnp">;
2506 defm STNPS : StorePairNoAlloc<0b00, 1, FPR32Op, simm7s4, "stnp">;
2507 defm STNPD : StorePairNoAlloc<0b01, 1, FPR64Op, simm7s8, "stnp">;
2508 defm STNPQ : StorePairNoAlloc<0b10, 1, FPR128Op, simm7s16, "stnp">;
2511 // (Register offset)
2514 defm STRBB : Store8RO< 0b00, 0, 0b00, GPR32, "strb", i32, truncstorei8>;
2515 defm STRHH : Store16RO<0b01, 0, 0b00, GPR32, "strh", i32, truncstorei16>;
2516 defm STRW : Store32RO<0b10, 0, 0b00, GPR32, "str", i32, store>;
2517 defm STRX : Store64RO<0b11, 0, 0b00, GPR64, "str", i64, store>;
2521 defm STRB : Store8RO< 0b00, 1, 0b00, FPR8Op, "str", untyped, store>;
2522 defm STRH : Store16RO<0b01, 1, 0b00, FPR16Op, "str", f16, store>;
2523 defm STRS : Store32RO<0b10, 1, 0b00, FPR32Op, "str", f32, store>;
2524 defm STRD : Store64RO<0b11, 1, 0b00, FPR64Op, "str", f64, store>;
2525 defm STRQ : Store128RO<0b00, 1, 0b10, FPR128Op, "str", f128, store>;
2527 let Predicates = [UseSTRQro], AddedComplexity = 10 in {
2528 def : Pat<(store (f128 FPR128:$Rt),
2529 (ro_Windexed128 GPR64sp:$Rn, GPR32:$Rm,
2530 ro_Wextend128:$extend)),
2531 (STRQroW FPR128:$Rt, GPR64sp:$Rn, GPR32:$Rm, ro_Wextend128:$extend)>;
2532 def : Pat<(store (f128 FPR128:$Rt),
2533 (ro_Xindexed128 GPR64sp:$Rn, GPR64:$Rm,
2534 ro_Xextend128:$extend)),
2535 (STRQroX FPR128:$Rt, GPR64sp:$Rn, GPR64:$Rm, ro_Wextend128:$extend)>;
2538 multiclass TruncStoreFrom64ROPat<ROAddrMode ro, SDPatternOperator storeop,
2539 Instruction STRW, Instruction STRX> {
2541 def : Pat<(storeop GPR64:$Rt,
2542 (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)),
2543 (STRW (EXTRACT_SUBREG GPR64:$Rt, sub_32),
2544 GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
2546 def : Pat<(storeop GPR64:$Rt,
2547 (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)),
2548 (STRX (EXTRACT_SUBREG GPR64:$Rt, sub_32),
2549 GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
2552 let AddedComplexity = 10 in {
2554 defm : TruncStoreFrom64ROPat<ro8, truncstorei8, STRBBroW, STRBBroX>;
2555 defm : TruncStoreFrom64ROPat<ro16, truncstorei16, STRHHroW, STRHHroX>;
2556 defm : TruncStoreFrom64ROPat<ro32, truncstorei32, STRWroW, STRWroX>;
2559 multiclass VecROStorePat<ROAddrMode ro, ValueType VecTy, RegisterClass FPR,
2560 Instruction STRW, Instruction STRX> {
2561 def : Pat<(store (VecTy FPR:$Rt),
2562 (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)),
2563 (STRW FPR:$Rt, GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
2565 def : Pat<(store (VecTy FPR:$Rt),
2566 (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)),
2567 (STRX FPR:$Rt, GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
2570 let AddedComplexity = 10 in {
2571 // Match all store 64 bits width whose type is compatible with FPR64
2572 let Predicates = [IsLE] in {
2573 // We must use ST1 to store vectors in big-endian.
2574 defm : VecROStorePat<ro64, v2i32, FPR64, STRDroW, STRDroX>;
2575 defm : VecROStorePat<ro64, v2f32, FPR64, STRDroW, STRDroX>;
2576 defm : VecROStorePat<ro64, v4i16, FPR64, STRDroW, STRDroX>;
2577 defm : VecROStorePat<ro64, v8i8, FPR64, STRDroW, STRDroX>;
2578 defm : VecROStorePat<ro64, v4f16, FPR64, STRDroW, STRDroX>;
2581 defm : VecROStorePat<ro64, v1i64, FPR64, STRDroW, STRDroX>;
2582 defm : VecROStorePat<ro64, v1f64, FPR64, STRDroW, STRDroX>;
2584 // Match all store 128 bits width whose type is compatible with FPR128
2585 let Predicates = [IsLE, UseSTRQro] in {
2586 // We must use ST1 to store vectors in big-endian.
2587 defm : VecROStorePat<ro128, v2i64, FPR128, STRQroW, STRQroX>;
2588 defm : VecROStorePat<ro128, v2f64, FPR128, STRQroW, STRQroX>;
2589 defm : VecROStorePat<ro128, v4i32, FPR128, STRQroW, STRQroX>;
2590 defm : VecROStorePat<ro128, v4f32, FPR128, STRQroW, STRQroX>;
2591 defm : VecROStorePat<ro128, v8i16, FPR128, STRQroW, STRQroX>;
2592 defm : VecROStorePat<ro128, v16i8, FPR128, STRQroW, STRQroX>;
2593 defm : VecROStorePat<ro128, v8f16, FPR128, STRQroW, STRQroX>;
2595 } // AddedComplexity = 10
2597 // Match stores from lane 0 to the appropriate subreg's store.
2598 multiclass VecROStoreLane0Pat<ROAddrMode ro, SDPatternOperator storeop,
2599 ValueType VecTy, ValueType STy,
2600 SubRegIndex SubRegIdx,
2601 Instruction STRW, Instruction STRX> {
2603 def : Pat<(storeop (STy (vector_extract (VecTy VecListOne128:$Vt), 0)),
2604 (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)),
2605 (STRW (EXTRACT_SUBREG VecListOne128:$Vt, SubRegIdx),
2606 GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
2608 def : Pat<(storeop (STy (vector_extract (VecTy VecListOne128:$Vt), 0)),
2609 (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)),
2610 (STRX (EXTRACT_SUBREG VecListOne128:$Vt, SubRegIdx),
2611 GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
2614 let AddedComplexity = 19 in {
2615 defm : VecROStoreLane0Pat<ro16, truncstorei16, v8i16, i32, hsub, STRHroW, STRHroX>;
2616 defm : VecROStoreLane0Pat<ro16, store, v8f16, f16, hsub, STRHroW, STRHroX>;
2617 defm : VecROStoreLane0Pat<ro32, store, v4i32, i32, ssub, STRSroW, STRSroX>;
2618 defm : VecROStoreLane0Pat<ro32, store, v4f32, f32, ssub, STRSroW, STRSroX>;
2619 defm : VecROStoreLane0Pat<ro64, store, v2i64, i64, dsub, STRDroW, STRDroX>;
2620 defm : VecROStoreLane0Pat<ro64, store, v2f64, f64, dsub, STRDroW, STRDroX>;
2624 // (unsigned immediate)
2625 defm STRX : StoreUIz<0b11, 0, 0b00, GPR64z, uimm12s8, "str",
2627 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))]>;
2628 defm STRW : StoreUIz<0b10, 0, 0b00, GPR32z, uimm12s4, "str",
2630 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))]>;
2631 defm STRB : StoreUI<0b00, 1, 0b00, FPR8Op, uimm12s1, "str",
2633 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))]>;
2634 defm STRH : StoreUI<0b01, 1, 0b00, FPR16Op, uimm12s2, "str",
2635 [(store (f16 FPR16Op:$Rt),
2636 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))]>;
2637 defm STRS : StoreUI<0b10, 1, 0b00, FPR32Op, uimm12s4, "str",
2638 [(store (f32 FPR32Op:$Rt),
2639 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))]>;
2640 defm STRD : StoreUI<0b11, 1, 0b00, FPR64Op, uimm12s8, "str",
2641 [(store (f64 FPR64Op:$Rt),
2642 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))]>;
2643 defm STRQ : StoreUI<0b00, 1, 0b10, FPR128Op, uimm12s16, "str", []>;
2645 defm STRHH : StoreUIz<0b01, 0, 0b00, GPR32z, uimm12s2, "strh",
2646 [(truncstorei16 GPR32z:$Rt,
2647 (am_indexed16 GPR64sp:$Rn,
2648 uimm12s2:$offset))]>;
2649 defm STRBB : StoreUIz<0b00, 0, 0b00, GPR32z, uimm12s1, "strb",
2650 [(truncstorei8 GPR32z:$Rt,
2651 (am_indexed8 GPR64sp:$Rn,
2652 uimm12s1:$offset))]>;
2654 let AddedComplexity = 10 in {
2656 // Match all store 64 bits width whose type is compatible with FPR64
2657 def : Pat<(store (v1i64 FPR64:$Rt),
2658 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2659 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2660 def : Pat<(store (v1f64 FPR64:$Rt),
2661 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2662 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2664 let Predicates = [IsLE] in {
2665 // We must use ST1 to store vectors in big-endian.
2666 def : Pat<(store (v2f32 FPR64:$Rt),
2667 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2668 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2669 def : Pat<(store (v8i8 FPR64:$Rt),
2670 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2671 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2672 def : Pat<(store (v4i16 FPR64:$Rt),
2673 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2674 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2675 def : Pat<(store (v2i32 FPR64:$Rt),
2676 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2677 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2678 def : Pat<(store (v4f16 FPR64:$Rt),
2679 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2680 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2683 // Match all store 128 bits width whose type is compatible with FPR128
2684 def : Pat<(store (f128 FPR128:$Rt),
2685 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2686 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2688 let Predicates = [IsLE] in {
2689 // We must use ST1 to store vectors in big-endian.
2690 def : Pat<(store (v4f32 FPR128:$Rt),
2691 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2692 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2693 def : Pat<(store (v2f64 FPR128:$Rt),
2694 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2695 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2696 def : Pat<(store (v16i8 FPR128:$Rt),
2697 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2698 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2699 def : Pat<(store (v8i16 FPR128:$Rt),
2700 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2701 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2702 def : Pat<(store (v4i32 FPR128:$Rt),
2703 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2704 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2705 def : Pat<(store (v2i64 FPR128:$Rt),
2706 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2707 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2708 def : Pat<(store (v8f16 FPR128:$Rt),
2709 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2710 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2714 def : Pat<(truncstorei32 GPR64:$Rt,
2715 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset)),
2716 (STRWui (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, uimm12s4:$offset)>;
2717 def : Pat<(truncstorei16 GPR64:$Rt,
2718 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset)),
2719 (STRHHui (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, uimm12s2:$offset)>;
2720 def : Pat<(truncstorei8 GPR64:$Rt, (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset)),
2721 (STRBBui (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, uimm12s1:$offset)>;
2723 } // AddedComplexity = 10
2725 // Match stores from lane 0 to the appropriate subreg's store.
2726 multiclass VecStoreLane0Pat<Operand UIAddrMode, SDPatternOperator storeop,
2727 ValueType VTy, ValueType STy,
2728 SubRegIndex SubRegIdx, Operand IndexType,
2730 def : Pat<(storeop (STy (vector_extract (VTy VecListOne128:$Vt), 0)),
2731 (UIAddrMode GPR64sp:$Rn, IndexType:$offset)),
2732 (STR (EXTRACT_SUBREG VecListOne128:$Vt, SubRegIdx),
2733 GPR64sp:$Rn, IndexType:$offset)>;
2736 let AddedComplexity = 19 in {
2737 defm : VecStoreLane0Pat<am_indexed16, truncstorei16, v8i16, i32, hsub, uimm12s2, STRHui>;
2738 defm : VecStoreLane0Pat<am_indexed16, store, v8f16, f16, hsub, uimm12s2, STRHui>;
2739 defm : VecStoreLane0Pat<am_indexed32, store, v4i32, i32, ssub, uimm12s4, STRSui>;
2740 defm : VecStoreLane0Pat<am_indexed32, store, v4f32, f32, ssub, uimm12s4, STRSui>;
2741 defm : VecStoreLane0Pat<am_indexed64, store, v2i64, i64, dsub, uimm12s8, STRDui>;
2742 defm : VecStoreLane0Pat<am_indexed64, store, v2f64, f64, dsub, uimm12s8, STRDui>;
2746 // (unscaled immediate)
2747 defm STURX : StoreUnscaled<0b11, 0, 0b00, GPR64z, "stur",
2749 (am_unscaled64 GPR64sp:$Rn, simm9:$offset))]>;
2750 defm STURW : StoreUnscaled<0b10, 0, 0b00, GPR32z, "stur",
2752 (am_unscaled32 GPR64sp:$Rn, simm9:$offset))]>;
2753 defm STURB : StoreUnscaled<0b00, 1, 0b00, FPR8Op, "stur",
2755 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))]>;
2756 defm STURH : StoreUnscaled<0b01, 1, 0b00, FPR16Op, "stur",
2757 [(store (f16 FPR16Op:$Rt),
2758 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))]>;
2759 defm STURS : StoreUnscaled<0b10, 1, 0b00, FPR32Op, "stur",
2760 [(store (f32 FPR32Op:$Rt),
2761 (am_unscaled32 GPR64sp:$Rn, simm9:$offset))]>;
2762 defm STURD : StoreUnscaled<0b11, 1, 0b00, FPR64Op, "stur",
2763 [(store (f64 FPR64Op:$Rt),
2764 (am_unscaled64 GPR64sp:$Rn, simm9:$offset))]>;
2765 defm STURQ : StoreUnscaled<0b00, 1, 0b10, FPR128Op, "stur",
2766 [(store (f128 FPR128Op:$Rt),
2767 (am_unscaled128 GPR64sp:$Rn, simm9:$offset))]>;
2768 defm STURHH : StoreUnscaled<0b01, 0, 0b00, GPR32z, "sturh",
2769 [(truncstorei16 GPR32z:$Rt,
2770 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))]>;
2771 defm STURBB : StoreUnscaled<0b00, 0, 0b00, GPR32z, "sturb",
2772 [(truncstorei8 GPR32z:$Rt,
2773 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))]>;
2775 // Armv8.4 Weaker Release Consistency enhancements
2776 // LDAPR & STLR with Immediate Offset instructions
2777 let Predicates = [HasRCPC_IMMO] in {
2778 defm STLURB : BaseStoreUnscaleV84<"stlurb", 0b00, 0b00, GPR32>;
2779 defm STLURH : BaseStoreUnscaleV84<"stlurh", 0b01, 0b00, GPR32>;
2780 defm STLURW : BaseStoreUnscaleV84<"stlur", 0b10, 0b00, GPR32>;
2781 defm STLURX : BaseStoreUnscaleV84<"stlur", 0b11, 0b00, GPR64>;
2782 defm LDAPURB : BaseLoadUnscaleV84<"ldapurb", 0b00, 0b01, GPR32>;
2783 defm LDAPURSBW : BaseLoadUnscaleV84<"ldapursb", 0b00, 0b11, GPR32>;
2784 defm LDAPURSBX : BaseLoadUnscaleV84<"ldapursb", 0b00, 0b10, GPR64>;
2785 defm LDAPURH : BaseLoadUnscaleV84<"ldapurh", 0b01, 0b01, GPR32>;
2786 defm LDAPURSHW : BaseLoadUnscaleV84<"ldapursh", 0b01, 0b11, GPR32>;
2787 defm LDAPURSHX : BaseLoadUnscaleV84<"ldapursh", 0b01, 0b10, GPR64>;
2788 defm LDAPUR : BaseLoadUnscaleV84<"ldapur", 0b10, 0b01, GPR32>;
2789 defm LDAPURSW : BaseLoadUnscaleV84<"ldapursw", 0b10, 0b10, GPR64>;
2790 defm LDAPURX : BaseLoadUnscaleV84<"ldapur", 0b11, 0b01, GPR64>;
2793 // Match all store 64 bits width whose type is compatible with FPR64
2794 def : Pat<(store (v1f64 FPR64:$Rt), (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2795 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2796 def : Pat<(store (v1i64 FPR64:$Rt), (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2797 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2799 let AddedComplexity = 10 in {
2801 let Predicates = [IsLE] in {
2802 // We must use ST1 to store vectors in big-endian.
2803 def : Pat<(store (v2f32 FPR64:$Rt),
2804 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2805 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2806 def : Pat<(store (v8i8 FPR64:$Rt),
2807 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2808 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2809 def : Pat<(store (v4i16 FPR64:$Rt),
2810 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2811 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2812 def : Pat<(store (v2i32 FPR64:$Rt),
2813 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2814 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2815 def : Pat<(store (v4f16 FPR64:$Rt),
2816 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2817 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2820 // Match all store 128 bits width whose type is compatible with FPR128
2821 def : Pat<(store (f128 FPR128:$Rt), (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2822 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2824 let Predicates = [IsLE] in {
2825 // We must use ST1 to store vectors in big-endian.
2826 def : Pat<(store (v4f32 FPR128:$Rt),
2827 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2828 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2829 def : Pat<(store (v2f64 FPR128:$Rt),
2830 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2831 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2832 def : Pat<(store (v16i8 FPR128:$Rt),
2833 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2834 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2835 def : Pat<(store (v8i16 FPR128:$Rt),
2836 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2837 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2838 def : Pat<(store (v4i32 FPR128:$Rt),
2839 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2840 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2841 def : Pat<(store (v2i64 FPR128:$Rt),
2842 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2843 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2844 def : Pat<(store (v2f64 FPR128:$Rt),
2845 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2846 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2847 def : Pat<(store (v8f16 FPR128:$Rt),
2848 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2849 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2852 } // AddedComplexity = 10
2854 // unscaled i64 truncating stores
2855 def : Pat<(truncstorei32 GPR64:$Rt, (am_unscaled32 GPR64sp:$Rn, simm9:$offset)),
2856 (STURWi (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, simm9:$offset)>;
2857 def : Pat<(truncstorei16 GPR64:$Rt, (am_unscaled16 GPR64sp:$Rn, simm9:$offset)),
2858 (STURHHi (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, simm9:$offset)>;
2859 def : Pat<(truncstorei8 GPR64:$Rt, (am_unscaled8 GPR64sp:$Rn, simm9:$offset)),
2860 (STURBBi (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, simm9:$offset)>;
2862 // Match stores from lane 0 to the appropriate subreg's store.
2863 multiclass VecStoreULane0Pat<SDPatternOperator StoreOp,
2864 ValueType VTy, ValueType STy,
2865 SubRegIndex SubRegIdx, Instruction STR> {
2866 defm : VecStoreLane0Pat<am_unscaled128, StoreOp, VTy, STy, SubRegIdx, simm9, STR>;
2869 let AddedComplexity = 19 in {
2870 defm : VecStoreULane0Pat<truncstorei16, v8i16, i32, hsub, STURHi>;
2871 defm : VecStoreULane0Pat<store, v8f16, f16, hsub, STURHi>;
2872 defm : VecStoreULane0Pat<store, v4i32, i32, ssub, STURSi>;
2873 defm : VecStoreULane0Pat<store, v4f32, f32, ssub, STURSi>;
2874 defm : VecStoreULane0Pat<store, v2i64, i64, dsub, STURDi>;
2875 defm : VecStoreULane0Pat<store, v2f64, f64, dsub, STURDi>;
2879 // STR mnemonics fall back to STUR for negative or unaligned offsets.
2880 def : InstAlias<"str $Rt, [$Rn, $offset]",
2881 (STURXi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb64:$offset), 0>;
2882 def : InstAlias<"str $Rt, [$Rn, $offset]",
2883 (STURWi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
2884 def : InstAlias<"str $Rt, [$Rn, $offset]",
2885 (STURBi FPR8Op:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2886 def : InstAlias<"str $Rt, [$Rn, $offset]",
2887 (STURHi FPR16Op:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2888 def : InstAlias<"str $Rt, [$Rn, $offset]",
2889 (STURSi FPR32Op:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
2890 def : InstAlias<"str $Rt, [$Rn, $offset]",
2891 (STURDi FPR64Op:$Rt, GPR64sp:$Rn, simm9_offset_fb64:$offset), 0>;
2892 def : InstAlias<"str $Rt, [$Rn, $offset]",
2893 (STURQi FPR128Op:$Rt, GPR64sp:$Rn, simm9_offset_fb128:$offset), 0>;
2895 def : InstAlias<"strb $Rt, [$Rn, $offset]",
2896 (STURBBi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2897 def : InstAlias<"strh $Rt, [$Rn, $offset]",
2898 (STURHHi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2901 // (unscaled immediate, unprivileged)
2902 defm STTRW : StoreUnprivileged<0b10, 0, 0b00, GPR32, "sttr">;
2903 defm STTRX : StoreUnprivileged<0b11, 0, 0b00, GPR64, "sttr">;
2905 defm STTRH : StoreUnprivileged<0b01, 0, 0b00, GPR32, "sttrh">;
2906 defm STTRB : StoreUnprivileged<0b00, 0, 0b00, GPR32, "sttrb">;
2909 // (immediate pre-indexed)
2910 def STRWpre : StorePreIdx<0b10, 0, 0b00, GPR32z, "str", pre_store, i32>;
2911 def STRXpre : StorePreIdx<0b11, 0, 0b00, GPR64z, "str", pre_store, i64>;
2912 def STRBpre : StorePreIdx<0b00, 1, 0b00, FPR8Op, "str", pre_store, untyped>;
2913 def STRHpre : StorePreIdx<0b01, 1, 0b00, FPR16Op, "str", pre_store, f16>;
2914 def STRSpre : StorePreIdx<0b10, 1, 0b00, FPR32Op, "str", pre_store, f32>;
2915 def STRDpre : StorePreIdx<0b11, 1, 0b00, FPR64Op, "str", pre_store, f64>;
2916 def STRQpre : StorePreIdx<0b00, 1, 0b10, FPR128Op, "str", pre_store, f128>;
2918 def STRBBpre : StorePreIdx<0b00, 0, 0b00, GPR32z, "strb", pre_truncsti8, i32>;
2919 def STRHHpre : StorePreIdx<0b01, 0, 0b00, GPR32z, "strh", pre_truncsti16, i32>;
2922 def : Pat<(pre_truncsti32 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
2923 (STRWpre (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
2925 def : Pat<(pre_truncsti16 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
2926 (STRHHpre (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
2928 def : Pat<(pre_truncsti8 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
2929 (STRBBpre (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
2932 def : Pat<(pre_store (v8i8 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2933 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2934 def : Pat<(pre_store (v4i16 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2935 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2936 def : Pat<(pre_store (v2i32 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2937 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2938 def : Pat<(pre_store (v2f32 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2939 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2940 def : Pat<(pre_store (v1i64 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2941 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2942 def : Pat<(pre_store (v1f64 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2943 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2944 def : Pat<(pre_store (v4f16 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2945 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2947 def : Pat<(pre_store (v16i8 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2948 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2949 def : Pat<(pre_store (v8i16 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2950 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2951 def : Pat<(pre_store (v4i32 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2952 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2953 def : Pat<(pre_store (v4f32 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2954 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2955 def : Pat<(pre_store (v2i64 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2956 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2957 def : Pat<(pre_store (v2f64 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2958 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2959 def : Pat<(pre_store (v8f16 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2960 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2963 // (immediate post-indexed)
2964 def STRWpost : StorePostIdx<0b10, 0, 0b00, GPR32z, "str", post_store, i32>;
2965 def STRXpost : StorePostIdx<0b11, 0, 0b00, GPR64z, "str", post_store, i64>;
2966 def STRBpost : StorePostIdx<0b00, 1, 0b00, FPR8Op, "str", post_store, untyped>;
2967 def STRHpost : StorePostIdx<0b01, 1, 0b00, FPR16Op, "str", post_store, f16>;
2968 def STRSpost : StorePostIdx<0b10, 1, 0b00, FPR32Op, "str", post_store, f32>;
2969 def STRDpost : StorePostIdx<0b11, 1, 0b00, FPR64Op, "str", post_store, f64>;
2970 def STRQpost : StorePostIdx<0b00, 1, 0b10, FPR128Op, "str", post_store, f128>;
2972 def STRBBpost : StorePostIdx<0b00, 0, 0b00, GPR32z, "strb", post_truncsti8, i32>;
2973 def STRHHpost : StorePostIdx<0b01, 0, 0b00, GPR32z, "strh", post_truncsti16, i32>;
2976 def : Pat<(post_truncsti32 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
2977 (STRWpost (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
2979 def : Pat<(post_truncsti16 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
2980 (STRHHpost (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
2982 def : Pat<(post_truncsti8 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
2983 (STRBBpost (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
2986 def : Pat<(post_store (v8i8 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2987 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2988 def : Pat<(post_store (v4i16 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2989 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2990 def : Pat<(post_store (v2i32 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2991 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2992 def : Pat<(post_store (v2f32 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2993 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2994 def : Pat<(post_store (v1i64 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2995 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2996 def : Pat<(post_store (v1f64 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2997 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2998 def : Pat<(post_store (v4f16 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2999 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
3001 def : Pat<(post_store (v16i8 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3002 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3003 def : Pat<(post_store (v8i16 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3004 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3005 def : Pat<(post_store (v4i32 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3006 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3007 def : Pat<(post_store (v4f32 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3008 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3009 def : Pat<(post_store (v2i64 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3010 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3011 def : Pat<(post_store (v2f64 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3012 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3013 def : Pat<(post_store (v8f16 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3014 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3016 //===----------------------------------------------------------------------===//
3017 // Load/store exclusive instructions.
3018 //===----------------------------------------------------------------------===//
3020 def LDARW : LoadAcquire <0b10, 1, 1, 0, 1, GPR32, "ldar">;
3021 def LDARX : LoadAcquire <0b11, 1, 1, 0, 1, GPR64, "ldar">;
3022 def LDARB : LoadAcquire <0b00, 1, 1, 0, 1, GPR32, "ldarb">;
3023 def LDARH : LoadAcquire <0b01, 1, 1, 0, 1, GPR32, "ldarh">;
3025 def LDAXRW : LoadExclusive <0b10, 0, 1, 0, 1, GPR32, "ldaxr">;
3026 def LDAXRX : LoadExclusive <0b11, 0, 1, 0, 1, GPR64, "ldaxr">;
3027 def LDAXRB : LoadExclusive <0b00, 0, 1, 0, 1, GPR32, "ldaxrb">;
3028 def LDAXRH : LoadExclusive <0b01, 0, 1, 0, 1, GPR32, "ldaxrh">;
3030 def LDXRW : LoadExclusive <0b10, 0, 1, 0, 0, GPR32, "ldxr">;
3031 def LDXRX : LoadExclusive <0b11, 0, 1, 0, 0, GPR64, "ldxr">;
3032 def LDXRB : LoadExclusive <0b00, 0, 1, 0, 0, GPR32, "ldxrb">;
3033 def LDXRH : LoadExclusive <0b01, 0, 1, 0, 0, GPR32, "ldxrh">;
3035 def STLRW : StoreRelease <0b10, 1, 0, 0, 1, GPR32, "stlr">;
3036 def STLRX : StoreRelease <0b11, 1, 0, 0, 1, GPR64, "stlr">;
3037 def STLRB : StoreRelease <0b00, 1, 0, 0, 1, GPR32, "stlrb">;
3038 def STLRH : StoreRelease <0b01, 1, 0, 0, 1, GPR32, "stlrh">;
3040 def STLXRW : StoreExclusive<0b10, 0, 0, 0, 1, GPR32, "stlxr">;
3041 def STLXRX : StoreExclusive<0b11, 0, 0, 0, 1, GPR64, "stlxr">;
3042 def STLXRB : StoreExclusive<0b00, 0, 0, 0, 1, GPR32, "stlxrb">;
3043 def STLXRH : StoreExclusive<0b01, 0, 0, 0, 1, GPR32, "stlxrh">;
3045 def STXRW : StoreExclusive<0b10, 0, 0, 0, 0, GPR32, "stxr">;
3046 def STXRX : StoreExclusive<0b11, 0, 0, 0, 0, GPR64, "stxr">;
3047 def STXRB : StoreExclusive<0b00, 0, 0, 0, 0, GPR32, "stxrb">;
3048 def STXRH : StoreExclusive<0b01, 0, 0, 0, 0, GPR32, "stxrh">;
3050 def LDAXPW : LoadExclusivePair<0b10, 0, 1, 1, 1, GPR32, "ldaxp">;
3051 def LDAXPX : LoadExclusivePair<0b11, 0, 1, 1, 1, GPR64, "ldaxp">;
3053 def LDXPW : LoadExclusivePair<0b10, 0, 1, 1, 0, GPR32, "ldxp">;
3054 def LDXPX : LoadExclusivePair<0b11, 0, 1, 1, 0, GPR64, "ldxp">;
3056 def STLXPW : StoreExclusivePair<0b10, 0, 0, 1, 1, GPR32, "stlxp">;
3057 def STLXPX : StoreExclusivePair<0b11, 0, 0, 1, 1, GPR64, "stlxp">;
3059 def STXPW : StoreExclusivePair<0b10, 0, 0, 1, 0, GPR32, "stxp">;
3060 def STXPX : StoreExclusivePair<0b11, 0, 0, 1, 0, GPR64, "stxp">;
3062 let Predicates = [HasLOR] in {
3063 // v8.1a "Limited Order Region" extension load-acquire instructions
3064 def LDLARW : LoadAcquire <0b10, 1, 1, 0, 0, GPR32, "ldlar">;
3065 def LDLARX : LoadAcquire <0b11, 1, 1, 0, 0, GPR64, "ldlar">;
3066 def LDLARB : LoadAcquire <0b00, 1, 1, 0, 0, GPR32, "ldlarb">;
3067 def LDLARH : LoadAcquire <0b01, 1, 1, 0, 0, GPR32, "ldlarh">;
3069 // v8.1a "Limited Order Region" extension store-release instructions
3070 def STLLRW : StoreRelease <0b10, 1, 0, 0, 0, GPR32, "stllr">;
3071 def STLLRX : StoreRelease <0b11, 1, 0, 0, 0, GPR64, "stllr">;
3072 def STLLRB : StoreRelease <0b00, 1, 0, 0, 0, GPR32, "stllrb">;
3073 def STLLRH : StoreRelease <0b01, 1, 0, 0, 0, GPR32, "stllrh">;
3076 //===----------------------------------------------------------------------===//
3077 // Scaled floating point to integer conversion instructions.
3078 //===----------------------------------------------------------------------===//
3080 defm FCVTAS : FPToIntegerUnscaled<0b00, 0b100, "fcvtas", int_aarch64_neon_fcvtas>;
3081 defm FCVTAU : FPToIntegerUnscaled<0b00, 0b101, "fcvtau", int_aarch64_neon_fcvtau>;
3082 defm FCVTMS : FPToIntegerUnscaled<0b10, 0b000, "fcvtms", int_aarch64_neon_fcvtms>;
3083 defm FCVTMU : FPToIntegerUnscaled<0b10, 0b001, "fcvtmu", int_aarch64_neon_fcvtmu>;
3084 defm FCVTNS : FPToIntegerUnscaled<0b00, 0b000, "fcvtns", int_aarch64_neon_fcvtns>;
3085 defm FCVTNU : FPToIntegerUnscaled<0b00, 0b001, "fcvtnu", int_aarch64_neon_fcvtnu>;
3086 defm FCVTPS : FPToIntegerUnscaled<0b01, 0b000, "fcvtps", int_aarch64_neon_fcvtps>;
3087 defm FCVTPU : FPToIntegerUnscaled<0b01, 0b001, "fcvtpu", int_aarch64_neon_fcvtpu>;
3088 defm FCVTZS : FPToIntegerUnscaled<0b11, 0b000, "fcvtzs", fp_to_sint>;
3089 defm FCVTZU : FPToIntegerUnscaled<0b11, 0b001, "fcvtzu", fp_to_uint>;
3090 defm FCVTZS : FPToIntegerScaled<0b11, 0b000, "fcvtzs", fp_to_sint>;
3091 defm FCVTZU : FPToIntegerScaled<0b11, 0b001, "fcvtzu", fp_to_uint>;
3093 multiclass FPToIntegerIntPats<Intrinsic round, string INST> {
3094 def : Pat<(i32 (round f16:$Rn)), (!cast<Instruction>(INST # UWHr) $Rn)>;
3095 def : Pat<(i64 (round f16:$Rn)), (!cast<Instruction>(INST # UXHr) $Rn)>;
3096 def : Pat<(i32 (round f32:$Rn)), (!cast<Instruction>(INST # UWSr) $Rn)>;
3097 def : Pat<(i64 (round f32:$Rn)), (!cast<Instruction>(INST # UXSr) $Rn)>;
3098 def : Pat<(i32 (round f64:$Rn)), (!cast<Instruction>(INST # UWDr) $Rn)>;
3099 def : Pat<(i64 (round f64:$Rn)), (!cast<Instruction>(INST # UXDr) $Rn)>;
3101 def : Pat<(i32 (round (fmul f16:$Rn, fixedpoint_f16_i32:$scale))),
3102 (!cast<Instruction>(INST # SWHri) $Rn, $scale)>;
3103 def : Pat<(i64 (round (fmul f16:$Rn, fixedpoint_f16_i64:$scale))),
3104 (!cast<Instruction>(INST # SXHri) $Rn, $scale)>;
3105 def : Pat<(i32 (round (fmul f32:$Rn, fixedpoint_f32_i32:$scale))),
3106 (!cast<Instruction>(INST # SWSri) $Rn, $scale)>;
3107 def : Pat<(i64 (round (fmul f32:$Rn, fixedpoint_f32_i64:$scale))),
3108 (!cast<Instruction>(INST # SXSri) $Rn, $scale)>;
3109 def : Pat<(i32 (round (fmul f64:$Rn, fixedpoint_f64_i32:$scale))),
3110 (!cast<Instruction>(INST # SWDri) $Rn, $scale)>;
3111 def : Pat<(i64 (round (fmul f64:$Rn, fixedpoint_f64_i64:$scale))),
3112 (!cast<Instruction>(INST # SXDri) $Rn, $scale)>;
3115 defm : FPToIntegerIntPats<int_aarch64_neon_fcvtzs, "FCVTZS">;
3116 defm : FPToIntegerIntPats<int_aarch64_neon_fcvtzu, "FCVTZU">;
3118 multiclass FPToIntegerPats<SDNode to_int, SDNode round, string INST> {
3119 def : Pat<(i32 (to_int (round f32:$Rn))),
3120 (!cast<Instruction>(INST # UWSr) f32:$Rn)>;
3121 def : Pat<(i64 (to_int (round f32:$Rn))),
3122 (!cast<Instruction>(INST # UXSr) f32:$Rn)>;
3123 def : Pat<(i32 (to_int (round f64:$Rn))),
3124 (!cast<Instruction>(INST # UWDr) f64:$Rn)>;
3125 def : Pat<(i64 (to_int (round f64:$Rn))),
3126 (!cast<Instruction>(INST # UXDr) f64:$Rn)>;
3129 defm : FPToIntegerPats<fp_to_sint, fceil, "FCVTPS">;
3130 defm : FPToIntegerPats<fp_to_uint, fceil, "FCVTPU">;
3131 defm : FPToIntegerPats<fp_to_sint, ffloor, "FCVTMS">;
3132 defm : FPToIntegerPats<fp_to_uint, ffloor, "FCVTMU">;
3133 defm : FPToIntegerPats<fp_to_sint, ftrunc, "FCVTZS">;
3134 defm : FPToIntegerPats<fp_to_uint, ftrunc, "FCVTZU">;
3135 defm : FPToIntegerPats<fp_to_sint, fround, "FCVTAS">;
3136 defm : FPToIntegerPats<fp_to_uint, fround, "FCVTAU">;
3138 let Predicates = [HasFullFP16] in {
3139 def : Pat<(i32 (lround f16:$Rn)),
3140 (!cast<Instruction>(FCVTASUWHr) f16:$Rn)>;
3141 def : Pat<(i64 (lround f16:$Rn)),
3142 (!cast<Instruction>(FCVTASUXHr) f16:$Rn)>;
3143 def : Pat<(i64 (llround f16:$Rn)),
3144 (!cast<Instruction>(FCVTASUXHr) f16:$Rn)>;
3146 def : Pat<(i32 (lround f32:$Rn)),
3147 (!cast<Instruction>(FCVTASUWSr) f32:$Rn)>;
3148 def : Pat<(i32 (lround f64:$Rn)),
3149 (!cast<Instruction>(FCVTASUWDr) f64:$Rn)>;
3150 def : Pat<(i64 (lround f32:$Rn)),
3151 (!cast<Instruction>(FCVTASUXSr) f32:$Rn)>;
3152 def : Pat<(i64 (lround f64:$Rn)),
3153 (!cast<Instruction>(FCVTASUXDr) f64:$Rn)>;
3154 def : Pat<(i64 (llround f32:$Rn)),
3155 (!cast<Instruction>(FCVTASUXSr) f32:$Rn)>;
3156 def : Pat<(i64 (llround f64:$Rn)),
3157 (!cast<Instruction>(FCVTASUXDr) f64:$Rn)>;
3159 //===----------------------------------------------------------------------===//
3160 // Scaled integer to floating point conversion instructions.
3161 //===----------------------------------------------------------------------===//
3163 defm SCVTF : IntegerToFP<0, "scvtf", sint_to_fp>;
3164 defm UCVTF : IntegerToFP<1, "ucvtf", uint_to_fp>;
3166 //===----------------------------------------------------------------------===//
3167 // Unscaled integer to floating point conversion instruction.
3168 //===----------------------------------------------------------------------===//
3170 defm FMOV : UnscaledConversion<"fmov">;
3172 // Add pseudo ops for FMOV 0 so we can mark them as isReMaterializable
3173 let isReMaterializable = 1, isCodeGenOnly = 1, isAsCheapAsAMove = 1 in {
3174 def FMOVH0 : Pseudo<(outs FPR16:$Rd), (ins), [(set f16:$Rd, (fpimm0))]>,
3175 Sched<[WriteF]>, Requires<[HasFullFP16]>;
3176 def FMOVS0 : Pseudo<(outs FPR32:$Rd), (ins), [(set f32:$Rd, (fpimm0))]>,
3178 def FMOVD0 : Pseudo<(outs FPR64:$Rd), (ins), [(set f64:$Rd, (fpimm0))]>,
3181 // Similarly add aliases
3182 def : InstAlias<"fmov $Rd, #0.0", (FMOVWHr FPR16:$Rd, WZR), 0>,
3183 Requires<[HasFullFP16]>;
3184 def : InstAlias<"fmov $Rd, #0.0", (FMOVWSr FPR32:$Rd, WZR), 0>;
3185 def : InstAlias<"fmov $Rd, #0.0", (FMOVXDr FPR64:$Rd, XZR), 0>;
3187 //===----------------------------------------------------------------------===//
3188 // Floating point conversion instruction.
3189 //===----------------------------------------------------------------------===//
3191 defm FCVT : FPConversion<"fcvt">;
3193 //===----------------------------------------------------------------------===//
3194 // Floating point single operand instructions.
3195 //===----------------------------------------------------------------------===//
3197 defm FABS : SingleOperandFPData<0b0001, "fabs", fabs>;
3198 defm FMOV : SingleOperandFPData<0b0000, "fmov">;
3199 defm FNEG : SingleOperandFPData<0b0010, "fneg", fneg>;
3200 defm FRINTA : SingleOperandFPData<0b1100, "frinta", fround>;
3201 defm FRINTI : SingleOperandFPData<0b1111, "frinti", fnearbyint>;
3202 defm FRINTM : SingleOperandFPData<0b1010, "frintm", ffloor>;
3203 defm FRINTN : SingleOperandFPData<0b1000, "frintn", int_aarch64_neon_frintn>;
3204 defm FRINTP : SingleOperandFPData<0b1001, "frintp", fceil>;
3206 def : Pat<(v1f64 (int_aarch64_neon_frintn (v1f64 FPR64:$Rn))),
3207 (FRINTNDr FPR64:$Rn)>;
3209 defm FRINTX : SingleOperandFPData<0b1110, "frintx", frint>;
3210 defm FRINTZ : SingleOperandFPData<0b1011, "frintz", ftrunc>;
3212 let SchedRW = [WriteFDiv] in {
3213 defm FSQRT : SingleOperandFPData<0b0011, "fsqrt", fsqrt>;
3216 let Predicates = [HasFRInt3264] in {
3217 defm FRINT32Z : FRIntNNT<0b00, "frint32z">;
3218 defm FRINT64Z : FRIntNNT<0b10, "frint64z">;
3219 defm FRINT32X : FRIntNNT<0b01, "frint32x">;
3220 defm FRINT64X : FRIntNNT<0b11, "frint64x">;
3223 let Predicates = [HasFullFP16] in {
3224 def : Pat<(i32 (lrint f16:$Rn)),
3225 (FCVTZSUWHr (!cast<Instruction>(FRINTXHr) f16:$Rn))>;
3226 def : Pat<(i64 (lrint f16:$Rn)),
3227 (FCVTZSUXHr (!cast<Instruction>(FRINTXHr) f16:$Rn))>;
3228 def : Pat<(i64 (llrint f16:$Rn)),
3229 (FCVTZSUXHr (!cast<Instruction>(FRINTXHr) f16:$Rn))>;
3231 def : Pat<(i32 (lrint f32:$Rn)),
3232 (FCVTZSUWSr (!cast<Instruction>(FRINTXSr) f32:$Rn))>;
3233 def : Pat<(i32 (lrint f64:$Rn)),
3234 (FCVTZSUWDr (!cast<Instruction>(FRINTXDr) f64:$Rn))>;
3235 def : Pat<(i64 (lrint f32:$Rn)),
3236 (FCVTZSUXSr (!cast<Instruction>(FRINTXSr) f32:$Rn))>;
3237 def : Pat<(i64 (lrint f64:$Rn)),
3238 (FCVTZSUXDr (!cast<Instruction>(FRINTXDr) f64:$Rn))>;
3239 def : Pat<(i64 (llrint f32:$Rn)),
3240 (FCVTZSUXSr (!cast<Instruction>(FRINTXSr) f32:$Rn))>;
3241 def : Pat<(i64 (llrint f64:$Rn)),
3242 (FCVTZSUXDr (!cast<Instruction>(FRINTXDr) f64:$Rn))>;
3244 //===----------------------------------------------------------------------===//
3245 // Floating point two operand instructions.
3246 //===----------------------------------------------------------------------===//
3248 defm FADD : TwoOperandFPData<0b0010, "fadd", fadd>;
3249 let SchedRW = [WriteFDiv] in {
3250 defm FDIV : TwoOperandFPData<0b0001, "fdiv", fdiv>;
3252 defm FMAXNM : TwoOperandFPData<0b0110, "fmaxnm", fmaxnum>;
3253 defm FMAX : TwoOperandFPData<0b0100, "fmax", fmaximum>;
3254 defm FMINNM : TwoOperandFPData<0b0111, "fminnm", fminnum>;
3255 defm FMIN : TwoOperandFPData<0b0101, "fmin", fminimum>;
3256 let SchedRW = [WriteFMul] in {
3257 defm FMUL : TwoOperandFPData<0b0000, "fmul", fmul>;
3258 defm FNMUL : TwoOperandFPDataNeg<0b1000, "fnmul", fmul>;
3260 defm FSUB : TwoOperandFPData<0b0011, "fsub", fsub>;
3262 def : Pat<(v1f64 (fmaximum (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
3263 (FMAXDrr FPR64:$Rn, FPR64:$Rm)>;
3264 def : Pat<(v1f64 (fminimum (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
3265 (FMINDrr FPR64:$Rn, FPR64:$Rm)>;
3266 def : Pat<(v1f64 (fmaxnum (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
3267 (FMAXNMDrr FPR64:$Rn, FPR64:$Rm)>;
3268 def : Pat<(v1f64 (fminnum (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
3269 (FMINNMDrr FPR64:$Rn, FPR64:$Rm)>;
3271 //===----------------------------------------------------------------------===//
3272 // Floating point three operand instructions.
3273 //===----------------------------------------------------------------------===//
3275 defm FMADD : ThreeOperandFPData<0, 0, "fmadd", fma>;
3276 defm FMSUB : ThreeOperandFPData<0, 1, "fmsub",
3277 TriOpFrag<(fma node:$LHS, (fneg node:$MHS), node:$RHS)> >;
3278 defm FNMADD : ThreeOperandFPData<1, 0, "fnmadd",
3279 TriOpFrag<(fneg (fma node:$LHS, node:$MHS, node:$RHS))> >;
3280 defm FNMSUB : ThreeOperandFPData<1, 1, "fnmsub",
3281 TriOpFrag<(fma node:$LHS, node:$MHS, (fneg node:$RHS))> >;
3283 // The following def pats catch the case where the LHS of an FMA is negated.
3284 // The TriOpFrag above catches the case where the middle operand is negated.
3286 // N.b. FMSUB etc have the accumulator at the *end* of (outs), unlike
3287 // the NEON variant.
3288 def : Pat<(f32 (fma (fneg FPR32:$Rn), FPR32:$Rm, FPR32:$Ra)),
3289 (FMSUBSrrr FPR32:$Rn, FPR32:$Rm, FPR32:$Ra)>;
3291 def : Pat<(f64 (fma (fneg FPR64:$Rn), FPR64:$Rm, FPR64:$Ra)),
3292 (FMSUBDrrr FPR64:$Rn, FPR64:$Rm, FPR64:$Ra)>;
3294 // We handled -(a + b*c) for FNMADD above, now it's time for "(-a) + (-b)*c" and
3296 def : Pat<(f32 (fma (fneg FPR32:$Rn), FPR32:$Rm, (fneg FPR32:$Ra))),
3297 (FNMADDSrrr FPR32:$Rn, FPR32:$Rm, FPR32:$Ra)>;
3299 def : Pat<(f64 (fma (fneg FPR64:$Rn), FPR64:$Rm, (fneg FPR64:$Ra))),
3300 (FNMADDDrrr FPR64:$Rn, FPR64:$Rm, FPR64:$Ra)>;
3302 def : Pat<(f32 (fma FPR32:$Rn, (fneg FPR32:$Rm), (fneg FPR32:$Ra))),
3303 (FNMADDSrrr FPR32:$Rn, FPR32:$Rm, FPR32:$Ra)>;
3305 def : Pat<(f64 (fma FPR64:$Rn, (fneg FPR64:$Rm), (fneg FPR64:$Ra))),
3306 (FNMADDDrrr FPR64:$Rn, FPR64:$Rm, FPR64:$Ra)>;
3308 //===----------------------------------------------------------------------===//
3309 // Floating point comparison instructions.
3310 //===----------------------------------------------------------------------===//
3312 defm FCMPE : FPComparison<1, "fcmpe">;
3313 defm FCMP : FPComparison<0, "fcmp", AArch64fcmp>;
3315 //===----------------------------------------------------------------------===//
3316 // Floating point conditional comparison instructions.
3317 //===----------------------------------------------------------------------===//
3319 defm FCCMPE : FPCondComparison<1, "fccmpe">;
3320 defm FCCMP : FPCondComparison<0, "fccmp", AArch64fccmp>;
3322 //===----------------------------------------------------------------------===//
3323 // Floating point conditional select instruction.
3324 //===----------------------------------------------------------------------===//
3326 defm FCSEL : FPCondSelect<"fcsel">;
3328 // CSEL instructions providing f128 types need to be handled by a
3329 // pseudo-instruction since the eventual code will need to introduce basic
3330 // blocks and control flow.
3331 def F128CSEL : Pseudo<(outs FPR128:$Rd),
3332 (ins FPR128:$Rn, FPR128:$Rm, ccode:$cond),
3333 [(set (f128 FPR128:$Rd),
3334 (AArch64csel FPR128:$Rn, FPR128:$Rm,
3335 (i32 imm:$cond), NZCV))]> {
3337 let usesCustomInserter = 1;
3338 let hasNoSchedulingInfo = 1;
3341 //===----------------------------------------------------------------------===//
3342 // Instructions used for emitting unwind opcodes on ARM64 Windows.
3343 //===----------------------------------------------------------------------===//
3344 let isPseudo = 1 in {
3345 def SEH_StackAlloc : Pseudo<(outs), (ins i32imm:$size), []>, Sched<[]>;
3346 def SEH_SaveFPLR : Pseudo<(outs), (ins i32imm:$offs), []>, Sched<[]>;
3347 def SEH_SaveFPLR_X : Pseudo<(outs), (ins i32imm:$offs), []>, Sched<[]>;
3348 def SEH_SaveReg : Pseudo<(outs), (ins i32imm:$reg, i32imm:$offs), []>, Sched<[]>;
3349 def SEH_SaveReg_X : Pseudo<(outs), (ins i32imm:$reg, i32imm:$offs), []>, Sched<[]>;
3350 def SEH_SaveRegP : Pseudo<(outs), (ins i32imm:$reg0, i32imm:$reg1, i32imm:$offs), []>, Sched<[]>;
3351 def SEH_SaveRegP_X : Pseudo<(outs), (ins i32imm:$reg0, i32imm:$reg1, i32imm:$offs), []>, Sched<[]>;
3352 def SEH_SaveFReg : Pseudo<(outs), (ins i32imm:$reg, i32imm:$offs), []>, Sched<[]>;
3353 def SEH_SaveFReg_X : Pseudo<(outs), (ins i32imm:$reg, i32imm:$offs), []>, Sched<[]>;
3354 def SEH_SaveFRegP : Pseudo<(outs), (ins i32imm:$reg0, i32imm:$reg1, i32imm:$offs), []>, Sched<[]>;
3355 def SEH_SaveFRegP_X : Pseudo<(outs), (ins i32imm:$reg0, i32imm:$reg1, i32imm:$offs), []>, Sched<[]>;
3356 def SEH_SetFP : Pseudo<(outs), (ins), []>, Sched<[]>;
3357 def SEH_AddFP : Pseudo<(outs), (ins i32imm:$offs), []>, Sched<[]>;
3358 def SEH_Nop : Pseudo<(outs), (ins), []>, Sched<[]>;
3359 def SEH_PrologEnd : Pseudo<(outs), (ins), []>, Sched<[]>;
3360 def SEH_EpilogStart : Pseudo<(outs), (ins), []>, Sched<[]>;
3361 def SEH_EpilogEnd : Pseudo<(outs), (ins), []>, Sched<[]>;
3364 // Pseudo instructions for Windows EH
3365 //===----------------------------------------------------------------------===//
3366 let isTerminator = 1, hasSideEffects = 1, isBarrier = 1, hasCtrlDep = 1,
3367 isCodeGenOnly = 1, isReturn = 1, isEHScopeReturn = 1, isPseudo = 1 in {
3368 def CLEANUPRET : Pseudo<(outs), (ins), [(cleanupret)]>, Sched<[]>;
3369 let usesCustomInserter = 1 in
3370 def CATCHRET : Pseudo<(outs), (ins am_brcond:$dst, am_brcond:$src), [(catchret bb:$dst, bb:$src)]>,
3374 let hasSideEffects = 1, hasCtrlDep = 1, isCodeGenOnly = 1,
3375 usesCustomInserter = 1 in
3376 def CATCHPAD : Pseudo<(outs), (ins), [(catchpad)]>, Sched<[]>;
3378 //===----------------------------------------------------------------------===//
3379 // Floating point immediate move.
3380 //===----------------------------------------------------------------------===//
3382 let isReMaterializable = 1 in {
3383 defm FMOV : FPMoveImmediate<"fmov">;
3386 //===----------------------------------------------------------------------===//
3387 // Advanced SIMD two vector instructions.
3388 //===----------------------------------------------------------------------===//
3390 defm UABDL : SIMDLongThreeVectorBHSabdl<1, 0b0111, "uabdl",
3391 int_aarch64_neon_uabd>;
3392 // Match UABDL in log2-shuffle patterns.
3393 def : Pat<(abs (v8i16 (sub (zext (v8i8 V64:$opA)),
3394 (zext (v8i8 V64:$opB))))),
3395 (UABDLv8i8_v8i16 V64:$opA, V64:$opB)>;
3396 def : Pat<(xor (v8i16 (AArch64vashr v8i16:$src, (i32 15))),
3397 (v8i16 (add (sub (zext (v8i8 V64:$opA)),
3398 (zext (v8i8 V64:$opB))),
3399 (AArch64vashr v8i16:$src, (i32 15))))),
3400 (UABDLv8i8_v8i16 V64:$opA, V64:$opB)>;
3401 def : Pat<(abs (v8i16 (sub (zext (extract_high_v16i8 V128:$opA)),
3402 (zext (extract_high_v16i8 V128:$opB))))),
3403 (UABDLv16i8_v8i16 V128:$opA, V128:$opB)>;
3404 def : Pat<(xor (v8i16 (AArch64vashr v8i16:$src, (i32 15))),
3405 (v8i16 (add (sub (zext (extract_high_v16i8 V128:$opA)),
3406 (zext (extract_high_v16i8 V128:$opB))),
3407 (AArch64vashr v8i16:$src, (i32 15))))),
3408 (UABDLv16i8_v8i16 V128:$opA, V128:$opB)>;
3409 def : Pat<(abs (v4i32 (sub (zext (v4i16 V64:$opA)),
3410 (zext (v4i16 V64:$opB))))),
3411 (UABDLv4i16_v4i32 V64:$opA, V64:$opB)>;
3412 def : Pat<(abs (v4i32 (sub (zext (extract_high_v8i16 V128:$opA)),
3413 (zext (extract_high_v8i16 V128:$opB))))),
3414 (UABDLv8i16_v4i32 V128:$opA, V128:$opB)>;
3415 def : Pat<(abs (v2i64 (sub (zext (v2i32 V64:$opA)),
3416 (zext (v2i32 V64:$opB))))),
3417 (UABDLv2i32_v2i64 V64:$opA, V64:$opB)>;
3418 def : Pat<(abs (v2i64 (sub (zext (extract_high_v4i32 V128:$opA)),
3419 (zext (extract_high_v4i32 V128:$opB))))),
3420 (UABDLv4i32_v2i64 V128:$opA, V128:$opB)>;
3422 defm ABS : SIMDTwoVectorBHSD<0, 0b01011, "abs", abs>;
3423 defm CLS : SIMDTwoVectorBHS<0, 0b00100, "cls", int_aarch64_neon_cls>;
3424 defm CLZ : SIMDTwoVectorBHS<1, 0b00100, "clz", ctlz>;
3425 defm CMEQ : SIMDCmpTwoVector<0, 0b01001, "cmeq", AArch64cmeqz>;
3426 defm CMGE : SIMDCmpTwoVector<1, 0b01000, "cmge", AArch64cmgez>;
3427 defm CMGT : SIMDCmpTwoVector<0, 0b01000, "cmgt", AArch64cmgtz>;
3428 defm CMLE : SIMDCmpTwoVector<1, 0b01001, "cmle", AArch64cmlez>;
3429 defm CMLT : SIMDCmpTwoVector<0, 0b01010, "cmlt", AArch64cmltz>;
3430 defm CNT : SIMDTwoVectorB<0, 0b00, 0b00101, "cnt", ctpop>;
3431 defm FABS : SIMDTwoVectorFP<0, 1, 0b01111, "fabs", fabs>;
3433 defm FCMEQ : SIMDFPCmpTwoVector<0, 1, 0b01101, "fcmeq", AArch64fcmeqz>;
3434 defm FCMGE : SIMDFPCmpTwoVector<1, 1, 0b01100, "fcmge", AArch64fcmgez>;
3435 defm FCMGT : SIMDFPCmpTwoVector<0, 1, 0b01100, "fcmgt", AArch64fcmgtz>;
3436 defm FCMLE : SIMDFPCmpTwoVector<1, 1, 0b01101, "fcmle", AArch64fcmlez>;
3437 defm FCMLT : SIMDFPCmpTwoVector<0, 1, 0b01110, "fcmlt", AArch64fcmltz>;
3438 defm FCVTAS : SIMDTwoVectorFPToInt<0,0,0b11100, "fcvtas",int_aarch64_neon_fcvtas>;
3439 defm FCVTAU : SIMDTwoVectorFPToInt<1,0,0b11100, "fcvtau",int_aarch64_neon_fcvtau>;
3440 defm FCVTL : SIMDFPWidenTwoVector<0, 0, 0b10111, "fcvtl">;
3441 def : Pat<(v4f32 (int_aarch64_neon_vcvthf2fp (v4i16 V64:$Rn))),
3442 (FCVTLv4i16 V64:$Rn)>;
3443 def : Pat<(v4f32 (int_aarch64_neon_vcvthf2fp (extract_subvector (v8i16 V128:$Rn),
3445 (FCVTLv8i16 V128:$Rn)>;
3446 def : Pat<(v2f64 (fpextend (v2f32 V64:$Rn))), (FCVTLv2i32 V64:$Rn)>;
3447 def : Pat<(v2f64 (fpextend (v2f32 (extract_subvector (v4f32 V128:$Rn),
3449 (FCVTLv4i32 V128:$Rn)>;
3451 def : Pat<(v4f32 (fpextend (v4f16 V64:$Rn))), (FCVTLv4i16 V64:$Rn)>;
3452 def : Pat<(v4f32 (fpextend (v4f16 (extract_subvector (v8f16 V128:$Rn),
3454 (FCVTLv8i16 V128:$Rn)>;
3456 defm FCVTMS : SIMDTwoVectorFPToInt<0,0,0b11011, "fcvtms",int_aarch64_neon_fcvtms>;
3457 defm FCVTMU : SIMDTwoVectorFPToInt<1,0,0b11011, "fcvtmu",int_aarch64_neon_fcvtmu>;
3458 defm FCVTNS : SIMDTwoVectorFPToInt<0,0,0b11010, "fcvtns",int_aarch64_neon_fcvtns>;
3459 defm FCVTNU : SIMDTwoVectorFPToInt<1,0,0b11010, "fcvtnu",int_aarch64_neon_fcvtnu>;
3460 defm FCVTN : SIMDFPNarrowTwoVector<0, 0, 0b10110, "fcvtn">;
3461 def : Pat<(v4i16 (int_aarch64_neon_vcvtfp2hf (v4f32 V128:$Rn))),
3462 (FCVTNv4i16 V128:$Rn)>;
3463 def : Pat<(concat_vectors V64:$Rd,
3464 (v4i16 (int_aarch64_neon_vcvtfp2hf (v4f32 V128:$Rn)))),
3465 (FCVTNv8i16 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
3466 def : Pat<(v2f32 (fpround (v2f64 V128:$Rn))), (FCVTNv2i32 V128:$Rn)>;
3467 def : Pat<(v4f16 (fpround (v4f32 V128:$Rn))), (FCVTNv4i16 V128:$Rn)>;
3468 def : Pat<(concat_vectors V64:$Rd, (v2f32 (fpround (v2f64 V128:$Rn)))),
3469 (FCVTNv4i32 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
3470 defm FCVTPS : SIMDTwoVectorFPToInt<0,1,0b11010, "fcvtps",int_aarch64_neon_fcvtps>;
3471 defm FCVTPU : SIMDTwoVectorFPToInt<1,1,0b11010, "fcvtpu",int_aarch64_neon_fcvtpu>;
3472 defm FCVTXN : SIMDFPInexactCvtTwoVector<1, 0, 0b10110, "fcvtxn",
3473 int_aarch64_neon_fcvtxn>;
3474 defm FCVTZS : SIMDTwoVectorFPToInt<0, 1, 0b11011, "fcvtzs", fp_to_sint>;
3475 defm FCVTZU : SIMDTwoVectorFPToInt<1, 1, 0b11011, "fcvtzu", fp_to_uint>;
3477 def : Pat<(v4i16 (int_aarch64_neon_fcvtzs v4f16:$Rn)), (FCVTZSv4f16 $Rn)>;
3478 def : Pat<(v8i16 (int_aarch64_neon_fcvtzs v8f16:$Rn)), (FCVTZSv8f16 $Rn)>;
3479 def : Pat<(v2i32 (int_aarch64_neon_fcvtzs v2f32:$Rn)), (FCVTZSv2f32 $Rn)>;
3480 def : Pat<(v4i32 (int_aarch64_neon_fcvtzs v4f32:$Rn)), (FCVTZSv4f32 $Rn)>;
3481 def : Pat<(v2i64 (int_aarch64_neon_fcvtzs v2f64:$Rn)), (FCVTZSv2f64 $Rn)>;
3483 def : Pat<(v4i16 (int_aarch64_neon_fcvtzu v4f16:$Rn)), (FCVTZUv4f16 $Rn)>;
3484 def : Pat<(v8i16 (int_aarch64_neon_fcvtzu v8f16:$Rn)), (FCVTZUv8f16 $Rn)>;
3485 def : Pat<(v2i32 (int_aarch64_neon_fcvtzu v2f32:$Rn)), (FCVTZUv2f32 $Rn)>;
3486 def : Pat<(v4i32 (int_aarch64_neon_fcvtzu v4f32:$Rn)), (FCVTZUv4f32 $Rn)>;
3487 def : Pat<(v2i64 (int_aarch64_neon_fcvtzu v2f64:$Rn)), (FCVTZUv2f64 $Rn)>;
3489 defm FNEG : SIMDTwoVectorFP<1, 1, 0b01111, "fneg", fneg>;
3490 defm FRECPE : SIMDTwoVectorFP<0, 1, 0b11101, "frecpe", int_aarch64_neon_frecpe>;
3491 defm FRINTA : SIMDTwoVectorFP<1, 0, 0b11000, "frinta", fround>;
3492 defm FRINTI : SIMDTwoVectorFP<1, 1, 0b11001, "frinti", fnearbyint>;
3493 defm FRINTM : SIMDTwoVectorFP<0, 0, 0b11001, "frintm", ffloor>;
3494 defm FRINTN : SIMDTwoVectorFP<0, 0, 0b11000, "frintn", int_aarch64_neon_frintn>;
3495 defm FRINTP : SIMDTwoVectorFP<0, 1, 0b11000, "frintp", fceil>;
3496 defm FRINTX : SIMDTwoVectorFP<1, 0, 0b11001, "frintx", frint>;
3497 defm FRINTZ : SIMDTwoVectorFP<0, 1, 0b11001, "frintz", ftrunc>;
3499 let Predicates = [HasFRInt3264] in {
3500 defm FRINT32Z : FRIntNNTVector<0, 0, "frint32z">;
3501 defm FRINT64Z : FRIntNNTVector<0, 1, "frint64z">;
3502 defm FRINT32X : FRIntNNTVector<1, 0, "frint32x">;
3503 defm FRINT64X : FRIntNNTVector<1, 1, "frint64x">;
3506 defm FRSQRTE: SIMDTwoVectorFP<1, 1, 0b11101, "frsqrte", int_aarch64_neon_frsqrte>;
3507 defm FSQRT : SIMDTwoVectorFP<1, 1, 0b11111, "fsqrt", fsqrt>;
3508 defm NEG : SIMDTwoVectorBHSD<1, 0b01011, "neg",
3509 UnOpFrag<(sub immAllZerosV, node:$LHS)> >;
3510 defm NOT : SIMDTwoVectorB<1, 0b00, 0b00101, "not", vnot>;
3511 // Aliases for MVN -> NOT.
3512 def : InstAlias<"mvn{ $Vd.8b, $Vn.8b|.8b $Vd, $Vn}",
3513 (NOTv8i8 V64:$Vd, V64:$Vn)>;
3514 def : InstAlias<"mvn{ $Vd.16b, $Vn.16b|.16b $Vd, $Vn}",
3515 (NOTv16i8 V128:$Vd, V128:$Vn)>;
3517 def : Pat<(AArch64neg (v8i8 V64:$Rn)), (NEGv8i8 V64:$Rn)>;
3518 def : Pat<(AArch64neg (v16i8 V128:$Rn)), (NEGv16i8 V128:$Rn)>;
3519 def : Pat<(AArch64neg (v4i16 V64:$Rn)), (NEGv4i16 V64:$Rn)>;
3520 def : Pat<(AArch64neg (v8i16 V128:$Rn)), (NEGv8i16 V128:$Rn)>;
3521 def : Pat<(AArch64neg (v2i32 V64:$Rn)), (NEGv2i32 V64:$Rn)>;
3522 def : Pat<(AArch64neg (v4i32 V128:$Rn)), (NEGv4i32 V128:$Rn)>;
3523 def : Pat<(AArch64neg (v2i64 V128:$Rn)), (NEGv2i64 V128:$Rn)>;
3525 def : Pat<(AArch64not (v8i8 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3526 def : Pat<(AArch64not (v16i8 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3527 def : Pat<(AArch64not (v4i16 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3528 def : Pat<(AArch64not (v8i16 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3529 def : Pat<(AArch64not (v2i32 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3530 def : Pat<(AArch64not (v1i64 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3531 def : Pat<(AArch64not (v4i32 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3532 def : Pat<(AArch64not (v2i64 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3534 def : Pat<(vnot (v4i16 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3535 def : Pat<(vnot (v8i16 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3536 def : Pat<(vnot (v2i32 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3537 def : Pat<(vnot (v4i32 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3538 def : Pat<(vnot (v2i64 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3540 defm RBIT : SIMDTwoVectorB<1, 0b01, 0b00101, "rbit", int_aarch64_neon_rbit>;
3541 defm REV16 : SIMDTwoVectorB<0, 0b00, 0b00001, "rev16", AArch64rev16>;
3542 defm REV32 : SIMDTwoVectorBH<1, 0b00000, "rev32", AArch64rev32>;
3543 defm REV64 : SIMDTwoVectorBHS<0, 0b00000, "rev64", AArch64rev64>;
3544 defm SADALP : SIMDLongTwoVectorTied<0, 0b00110, "sadalp",
3545 BinOpFrag<(add node:$LHS, (int_aarch64_neon_saddlp node:$RHS))> >;
3546 defm SADDLP : SIMDLongTwoVector<0, 0b00010, "saddlp", int_aarch64_neon_saddlp>;
3547 defm SCVTF : SIMDTwoVectorIntToFP<0, 0, 0b11101, "scvtf", sint_to_fp>;
3548 defm SHLL : SIMDVectorLShiftLongBySizeBHS;
3549 defm SQABS : SIMDTwoVectorBHSD<0, 0b00111, "sqabs", int_aarch64_neon_sqabs>;
3550 defm SQNEG : SIMDTwoVectorBHSD<1, 0b00111, "sqneg", int_aarch64_neon_sqneg>;
3551 defm SQXTN : SIMDMixedTwoVector<0, 0b10100, "sqxtn", int_aarch64_neon_sqxtn>;
3552 defm SQXTUN : SIMDMixedTwoVector<1, 0b10010, "sqxtun", int_aarch64_neon_sqxtun>;
3553 defm SUQADD : SIMDTwoVectorBHSDTied<0, 0b00011, "suqadd",int_aarch64_neon_suqadd>;
3554 defm UADALP : SIMDLongTwoVectorTied<1, 0b00110, "uadalp",
3555 BinOpFrag<(add node:$LHS, (int_aarch64_neon_uaddlp node:$RHS))> >;
3556 defm UADDLP : SIMDLongTwoVector<1, 0b00010, "uaddlp",
3557 int_aarch64_neon_uaddlp>;
3558 defm UCVTF : SIMDTwoVectorIntToFP<1, 0, 0b11101, "ucvtf", uint_to_fp>;
3559 defm UQXTN : SIMDMixedTwoVector<1, 0b10100, "uqxtn", int_aarch64_neon_uqxtn>;
3560 defm URECPE : SIMDTwoVectorS<0, 1, 0b11100, "urecpe", int_aarch64_neon_urecpe>;
3561 defm URSQRTE: SIMDTwoVectorS<1, 1, 0b11100, "ursqrte", int_aarch64_neon_ursqrte>;
3562 defm USQADD : SIMDTwoVectorBHSDTied<1, 0b00011, "usqadd",int_aarch64_neon_usqadd>;
3563 defm XTN : SIMDMixedTwoVector<0, 0b10010, "xtn", trunc>;
3565 def : Pat<(v4f16 (AArch64rev32 V64:$Rn)), (REV32v4i16 V64:$Rn)>;
3566 def : Pat<(v4f16 (AArch64rev64 V64:$Rn)), (REV64v4i16 V64:$Rn)>;
3567 def : Pat<(v8f16 (AArch64rev32 V128:$Rn)), (REV32v8i16 V128:$Rn)>;
3568 def : Pat<(v8f16 (AArch64rev64 V128:$Rn)), (REV64v8i16 V128:$Rn)>;
3569 def : Pat<(v2f32 (AArch64rev64 V64:$Rn)), (REV64v2i32 V64:$Rn)>;
3570 def : Pat<(v4f32 (AArch64rev64 V128:$Rn)), (REV64v4i32 V128:$Rn)>;
3572 // Patterns for vector long shift (by element width). These need to match all
3573 // three of zext, sext and anyext so it's easier to pull the patterns out of the
3575 multiclass SIMDVectorLShiftLongBySizeBHSPats<SDPatternOperator ext> {
3576 def : Pat<(AArch64vshl (v8i16 (ext (v8i8 V64:$Rn))), (i32 8)),
3577 (SHLLv8i8 V64:$Rn)>;
3578 def : Pat<(AArch64vshl (v8i16 (ext (extract_high_v16i8 V128:$Rn))), (i32 8)),
3579 (SHLLv16i8 V128:$Rn)>;
3580 def : Pat<(AArch64vshl (v4i32 (ext (v4i16 V64:$Rn))), (i32 16)),
3581 (SHLLv4i16 V64:$Rn)>;
3582 def : Pat<(AArch64vshl (v4i32 (ext (extract_high_v8i16 V128:$Rn))), (i32 16)),
3583 (SHLLv8i16 V128:$Rn)>;
3584 def : Pat<(AArch64vshl (v2i64 (ext (v2i32 V64:$Rn))), (i32 32)),
3585 (SHLLv2i32 V64:$Rn)>;
3586 def : Pat<(AArch64vshl (v2i64 (ext (extract_high_v4i32 V128:$Rn))), (i32 32)),
3587 (SHLLv4i32 V128:$Rn)>;
3590 defm : SIMDVectorLShiftLongBySizeBHSPats<anyext>;
3591 defm : SIMDVectorLShiftLongBySizeBHSPats<zext>;
3592 defm : SIMDVectorLShiftLongBySizeBHSPats<sext>;
3594 //===----------------------------------------------------------------------===//
3595 // Advanced SIMD three vector instructions.
3596 //===----------------------------------------------------------------------===//
3598 defm ADD : SIMDThreeSameVector<0, 0b10000, "add", add>;
3599 defm ADDP : SIMDThreeSameVector<0, 0b10111, "addp", int_aarch64_neon_addp>;
3600 defm CMEQ : SIMDThreeSameVector<1, 0b10001, "cmeq", AArch64cmeq>;
3601 defm CMGE : SIMDThreeSameVector<0, 0b00111, "cmge", AArch64cmge>;
3602 defm CMGT : SIMDThreeSameVector<0, 0b00110, "cmgt", AArch64cmgt>;
3603 defm CMHI : SIMDThreeSameVector<1, 0b00110, "cmhi", AArch64cmhi>;
3604 defm CMHS : SIMDThreeSameVector<1, 0b00111, "cmhs", AArch64cmhs>;
3605 defm CMTST : SIMDThreeSameVector<0, 0b10001, "cmtst", AArch64cmtst>;
3606 defm FABD : SIMDThreeSameVectorFP<1,1,0b010,"fabd", int_aarch64_neon_fabd>;
3607 let Predicates = [HasNEON] in {
3608 foreach VT = [ v2f32, v4f32, v2f64 ] in
3609 def : Pat<(fabs (fsub VT:$Rn, VT:$Rm)), (!cast<Instruction>("FABD"#VT) VT:$Rn, VT:$Rm)>;
3611 let Predicates = [HasNEON, HasFullFP16] in {
3612 foreach VT = [ v4f16, v8f16 ] in
3613 def : Pat<(fabs (fsub VT:$Rn, VT:$Rm)), (!cast<Instruction>("FABD"#VT) VT:$Rn, VT:$Rm)>;
3615 defm FACGE : SIMDThreeSameVectorFPCmp<1,0,0b101,"facge",int_aarch64_neon_facge>;
3616 defm FACGT : SIMDThreeSameVectorFPCmp<1,1,0b101,"facgt",int_aarch64_neon_facgt>;
3617 defm FADDP : SIMDThreeSameVectorFP<1,0,0b010,"faddp",int_aarch64_neon_faddp>;
3618 defm FADD : SIMDThreeSameVectorFP<0,0,0b010,"fadd", fadd>;
3619 defm FCMEQ : SIMDThreeSameVectorFPCmp<0, 0, 0b100, "fcmeq", AArch64fcmeq>;
3620 defm FCMGE : SIMDThreeSameVectorFPCmp<1, 0, 0b100, "fcmge", AArch64fcmge>;
3621 defm FCMGT : SIMDThreeSameVectorFPCmp<1, 1, 0b100, "fcmgt", AArch64fcmgt>;
3622 defm FDIV : SIMDThreeSameVectorFP<1,0,0b111,"fdiv", fdiv>;
3623 defm FMAXNMP : SIMDThreeSameVectorFP<1,0,0b000,"fmaxnmp", int_aarch64_neon_fmaxnmp>;
3624 defm FMAXNM : SIMDThreeSameVectorFP<0,0,0b000,"fmaxnm", fmaxnum>;
3625 defm FMAXP : SIMDThreeSameVectorFP<1,0,0b110,"fmaxp", int_aarch64_neon_fmaxp>;
3626 defm FMAX : SIMDThreeSameVectorFP<0,0,0b110,"fmax", fmaximum>;
3627 defm FMINNMP : SIMDThreeSameVectorFP<1,1,0b000,"fminnmp", int_aarch64_neon_fminnmp>;
3628 defm FMINNM : SIMDThreeSameVectorFP<0,1,0b000,"fminnm", fminnum>;
3629 defm FMINP : SIMDThreeSameVectorFP<1,1,0b110,"fminp", int_aarch64_neon_fminp>;
3630 defm FMIN : SIMDThreeSameVectorFP<0,1,0b110,"fmin", fminimum>;
3632 // NOTE: The operands of the PatFrag are reordered on FMLA/FMLS because the
3633 // instruction expects the addend first, while the fma intrinsic puts it last.
3634 defm FMLA : SIMDThreeSameVectorFPTied<0, 0, 0b001, "fmla",
3635 TriOpFrag<(fma node:$RHS, node:$MHS, node:$LHS)> >;
3636 defm FMLS : SIMDThreeSameVectorFPTied<0, 1, 0b001, "fmls",
3637 TriOpFrag<(fma node:$MHS, (fneg node:$RHS), node:$LHS)> >;
3639 // The following def pats catch the case where the LHS of an FMA is negated.
3640 // The TriOpFrag above catches the case where the middle operand is negated.
3641 def : Pat<(v2f32 (fma (fneg V64:$Rn), V64:$Rm, V64:$Rd)),
3642 (FMLSv2f32 V64:$Rd, V64:$Rn, V64:$Rm)>;
3644 def : Pat<(v4f32 (fma (fneg V128:$Rn), V128:$Rm, V128:$Rd)),
3645 (FMLSv4f32 V128:$Rd, V128:$Rn, V128:$Rm)>;
3647 def : Pat<(v2f64 (fma (fneg V128:$Rn), V128:$Rm, V128:$Rd)),
3648 (FMLSv2f64 V128:$Rd, V128:$Rn, V128:$Rm)>;
3650 defm FMULX : SIMDThreeSameVectorFP<0,0,0b011,"fmulx", int_aarch64_neon_fmulx>;
3651 defm FMUL : SIMDThreeSameVectorFP<1,0,0b011,"fmul", fmul>;
3652 defm FRECPS : SIMDThreeSameVectorFP<0,0,0b111,"frecps", int_aarch64_neon_frecps>;
3653 defm FRSQRTS : SIMDThreeSameVectorFP<0,1,0b111,"frsqrts", int_aarch64_neon_frsqrts>;
3654 defm FSUB : SIMDThreeSameVectorFP<0,1,0b010,"fsub", fsub>;
3655 defm MLA : SIMDThreeSameVectorBHSTied<0, 0b10010, "mla",
3656 TriOpFrag<(add node:$LHS, (mul node:$MHS, node:$RHS))> >;
3657 defm MLS : SIMDThreeSameVectorBHSTied<1, 0b10010, "mls",
3658 TriOpFrag<(sub node:$LHS, (mul node:$MHS, node:$RHS))> >;
3659 defm MUL : SIMDThreeSameVectorBHS<0, 0b10011, "mul", mul>;
3660 defm PMUL : SIMDThreeSameVectorB<1, 0b10011, "pmul", int_aarch64_neon_pmul>;
3661 defm SABA : SIMDThreeSameVectorBHSTied<0, 0b01111, "saba",
3662 TriOpFrag<(add node:$LHS, (int_aarch64_neon_sabd node:$MHS, node:$RHS))> >;
3663 defm SABD : SIMDThreeSameVectorBHS<0,0b01110,"sabd", int_aarch64_neon_sabd>;
3664 defm SHADD : SIMDThreeSameVectorBHS<0,0b00000,"shadd", int_aarch64_neon_shadd>;
3665 defm SHSUB : SIMDThreeSameVectorBHS<0,0b00100,"shsub", int_aarch64_neon_shsub>;
3666 defm SMAXP : SIMDThreeSameVectorBHS<0,0b10100,"smaxp", int_aarch64_neon_smaxp>;
3667 defm SMAX : SIMDThreeSameVectorBHS<0,0b01100,"smax", smax>;
3668 defm SMINP : SIMDThreeSameVectorBHS<0,0b10101,"sminp", int_aarch64_neon_sminp>;
3669 defm SMIN : SIMDThreeSameVectorBHS<0,0b01101,"smin", smin>;
3670 defm SQADD : SIMDThreeSameVector<0,0b00001,"sqadd", int_aarch64_neon_sqadd>;
3671 defm SQDMULH : SIMDThreeSameVectorHS<0,0b10110,"sqdmulh",int_aarch64_neon_sqdmulh>;
3672 defm SQRDMULH : SIMDThreeSameVectorHS<1,0b10110,"sqrdmulh",int_aarch64_neon_sqrdmulh>;
3673 defm SQRSHL : SIMDThreeSameVector<0,0b01011,"sqrshl", int_aarch64_neon_sqrshl>;
3674 defm SQSHL : SIMDThreeSameVector<0,0b01001,"sqshl", int_aarch64_neon_sqshl>;
3675 defm SQSUB : SIMDThreeSameVector<0,0b00101,"sqsub", int_aarch64_neon_sqsub>;
3676 defm SRHADD : SIMDThreeSameVectorBHS<0,0b00010,"srhadd",int_aarch64_neon_srhadd>;
3677 defm SRSHL : SIMDThreeSameVector<0,0b01010,"srshl", int_aarch64_neon_srshl>;
3678 defm SSHL : SIMDThreeSameVector<0,0b01000,"sshl", int_aarch64_neon_sshl>;
3679 defm SUB : SIMDThreeSameVector<1,0b10000,"sub", sub>;
3680 defm UABA : SIMDThreeSameVectorBHSTied<1, 0b01111, "uaba",
3681 TriOpFrag<(add node:$LHS, (int_aarch64_neon_uabd node:$MHS, node:$RHS))> >;
3682 defm UABD : SIMDThreeSameVectorBHS<1,0b01110,"uabd", int_aarch64_neon_uabd>;
3683 defm UHADD : SIMDThreeSameVectorBHS<1,0b00000,"uhadd", int_aarch64_neon_uhadd>;
3684 defm UHSUB : SIMDThreeSameVectorBHS<1,0b00100,"uhsub", int_aarch64_neon_uhsub>;
3685 defm UMAXP : SIMDThreeSameVectorBHS<1,0b10100,"umaxp", int_aarch64_neon_umaxp>;
3686 defm UMAX : SIMDThreeSameVectorBHS<1,0b01100,"umax", umax>;
3687 defm UMINP : SIMDThreeSameVectorBHS<1,0b10101,"uminp", int_aarch64_neon_uminp>;
3688 defm UMIN : SIMDThreeSameVectorBHS<1,0b01101,"umin", umin>;
3689 defm UQADD : SIMDThreeSameVector<1,0b00001,"uqadd", int_aarch64_neon_uqadd>;
3690 defm UQRSHL : SIMDThreeSameVector<1,0b01011,"uqrshl", int_aarch64_neon_uqrshl>;
3691 defm UQSHL : SIMDThreeSameVector<1,0b01001,"uqshl", int_aarch64_neon_uqshl>;
3692 defm UQSUB : SIMDThreeSameVector<1,0b00101,"uqsub", int_aarch64_neon_uqsub>;
3693 defm URHADD : SIMDThreeSameVectorBHS<1,0b00010,"urhadd", int_aarch64_neon_urhadd>;
3694 defm URSHL : SIMDThreeSameVector<1,0b01010,"urshl", int_aarch64_neon_urshl>;
3695 defm USHL : SIMDThreeSameVector<1,0b01000,"ushl", int_aarch64_neon_ushl>;
3696 defm SQRDMLAH : SIMDThreeSameVectorSQRDMLxHTiedHS<1,0b10000,"sqrdmlah",
3697 int_aarch64_neon_sqadd>;
3698 defm SQRDMLSH : SIMDThreeSameVectorSQRDMLxHTiedHS<1,0b10001,"sqrdmlsh",
3699 int_aarch64_neon_sqsub>;
3701 defm AND : SIMDLogicalThreeVector<0, 0b00, "and", and>;
3702 defm BIC : SIMDLogicalThreeVector<0, 0b01, "bic",
3703 BinOpFrag<(and node:$LHS, (vnot node:$RHS))> >;
3704 defm BIF : SIMDLogicalThreeVector<1, 0b11, "bif">;
3705 defm BIT : SIMDLogicalThreeVectorTied<1, 0b10, "bit", AArch64bit>;
3706 defm BSL : SIMDLogicalThreeVectorTied<1, 0b01, "bsl",
3707 TriOpFrag<(or (and node:$LHS, node:$MHS), (and (vnot node:$LHS), node:$RHS))>>;
3708 defm EOR : SIMDLogicalThreeVector<1, 0b00, "eor", xor>;
3709 defm ORN : SIMDLogicalThreeVector<0, 0b11, "orn",
3710 BinOpFrag<(or node:$LHS, (vnot node:$RHS))> >;
3711 defm ORR : SIMDLogicalThreeVector<0, 0b10, "orr", or>;
3714 def : Pat<(AArch64bsl (v8i8 V64:$Rd), V64:$Rn, V64:$Rm),
3715 (BSLv8i8 V64:$Rd, V64:$Rn, V64:$Rm)>;
3716 def : Pat<(AArch64bsl (v4i16 V64:$Rd), V64:$Rn, V64:$Rm),
3717 (BSLv8i8 V64:$Rd, V64:$Rn, V64:$Rm)>;
3718 def : Pat<(AArch64bsl (v2i32 V64:$Rd), V64:$Rn, V64:$Rm),
3719 (BSLv8i8 V64:$Rd, V64:$Rn, V64:$Rm)>;
3720 def : Pat<(AArch64bsl (v1i64 V64:$Rd), V64:$Rn, V64:$Rm),
3721 (BSLv8i8 V64:$Rd, V64:$Rn, V64:$Rm)>;
3723 def : Pat<(AArch64bsl (v16i8 V128:$Rd), V128:$Rn, V128:$Rm),
3724 (BSLv16i8 V128:$Rd, V128:$Rn, V128:$Rm)>;
3725 def : Pat<(AArch64bsl (v8i16 V128:$Rd), V128:$Rn, V128:$Rm),
3726 (BSLv16i8 V128:$Rd, V128:$Rn, V128:$Rm)>;
3727 def : Pat<(AArch64bsl (v4i32 V128:$Rd), V128:$Rn, V128:$Rm),
3728 (BSLv16i8 V128:$Rd, V128:$Rn, V128:$Rm)>;
3729 def : Pat<(AArch64bsl (v2i64 V128:$Rd), V128:$Rn, V128:$Rm),
3730 (BSLv16i8 V128:$Rd, V128:$Rn, V128:$Rm)>;
3732 def : InstAlias<"mov{\t$dst.16b, $src.16b|.16b\t$dst, $src}",
3733 (ORRv16i8 V128:$dst, V128:$src, V128:$src), 1>;
3734 def : InstAlias<"mov{\t$dst.8h, $src.8h|.8h\t$dst, $src}",
3735 (ORRv16i8 V128:$dst, V128:$src, V128:$src), 0>;
3736 def : InstAlias<"mov{\t$dst.4s, $src.4s|.4s\t$dst, $src}",
3737 (ORRv16i8 V128:$dst, V128:$src, V128:$src), 0>;
3738 def : InstAlias<"mov{\t$dst.2d, $src.2d|.2d\t$dst, $src}",
3739 (ORRv16i8 V128:$dst, V128:$src, V128:$src), 0>;
3741 def : InstAlias<"mov{\t$dst.8b, $src.8b|.8b\t$dst, $src}",
3742 (ORRv8i8 V64:$dst, V64:$src, V64:$src), 1>;
3743 def : InstAlias<"mov{\t$dst.4h, $src.4h|.4h\t$dst, $src}",
3744 (ORRv8i8 V64:$dst, V64:$src, V64:$src), 0>;
3745 def : InstAlias<"mov{\t$dst.2s, $src.2s|.2s\t$dst, $src}",
3746 (ORRv8i8 V64:$dst, V64:$src, V64:$src), 0>;
3747 def : InstAlias<"mov{\t$dst.1d, $src.1d|.1d\t$dst, $src}",
3748 (ORRv8i8 V64:$dst, V64:$src, V64:$src), 0>;
3750 def : InstAlias<"{cmls\t$dst.8b, $src1.8b, $src2.8b" #
3751 "|cmls.8b\t$dst, $src1, $src2}",
3752 (CMHSv8i8 V64:$dst, V64:$src2, V64:$src1), 0>;
3753 def : InstAlias<"{cmls\t$dst.16b, $src1.16b, $src2.16b" #
3754 "|cmls.16b\t$dst, $src1, $src2}",
3755 (CMHSv16i8 V128:$dst, V128:$src2, V128:$src1), 0>;
3756 def : InstAlias<"{cmls\t$dst.4h, $src1.4h, $src2.4h" #
3757 "|cmls.4h\t$dst, $src1, $src2}",
3758 (CMHSv4i16 V64:$dst, V64:$src2, V64:$src1), 0>;
3759 def : InstAlias<"{cmls\t$dst.8h, $src1.8h, $src2.8h" #
3760 "|cmls.8h\t$dst, $src1, $src2}",
3761 (CMHSv8i16 V128:$dst, V128:$src2, V128:$src1), 0>;
3762 def : InstAlias<"{cmls\t$dst.2s, $src1.2s, $src2.2s" #
3763 "|cmls.2s\t$dst, $src1, $src2}",
3764 (CMHSv2i32 V64:$dst, V64:$src2, V64:$src1), 0>;
3765 def : InstAlias<"{cmls\t$dst.4s, $src1.4s, $src2.4s" #
3766 "|cmls.4s\t$dst, $src1, $src2}",
3767 (CMHSv4i32 V128:$dst, V128:$src2, V128:$src1), 0>;
3768 def : InstAlias<"{cmls\t$dst.2d, $src1.2d, $src2.2d" #
3769 "|cmls.2d\t$dst, $src1, $src2}",
3770 (CMHSv2i64 V128:$dst, V128:$src2, V128:$src1), 0>;
3772 def : InstAlias<"{cmlo\t$dst.8b, $src1.8b, $src2.8b" #
3773 "|cmlo.8b\t$dst, $src1, $src2}",
3774 (CMHIv8i8 V64:$dst, V64:$src2, V64:$src1), 0>;
3775 def : InstAlias<"{cmlo\t$dst.16b, $src1.16b, $src2.16b" #
3776 "|cmlo.16b\t$dst, $src1, $src2}",
3777 (CMHIv16i8 V128:$dst, V128:$src2, V128:$src1), 0>;
3778 def : InstAlias<"{cmlo\t$dst.4h, $src1.4h, $src2.4h" #
3779 "|cmlo.4h\t$dst, $src1, $src2}",
3780 (CMHIv4i16 V64:$dst, V64:$src2, V64:$src1), 0>;
3781 def : InstAlias<"{cmlo\t$dst.8h, $src1.8h, $src2.8h" #
3782 "|cmlo.8h\t$dst, $src1, $src2}",
3783 (CMHIv8i16 V128:$dst, V128:$src2, V128:$src1), 0>;
3784 def : InstAlias<"{cmlo\t$dst.2s, $src1.2s, $src2.2s" #
3785 "|cmlo.2s\t$dst, $src1, $src2}",
3786 (CMHIv2i32 V64:$dst, V64:$src2, V64:$src1), 0>;
3787 def : InstAlias<"{cmlo\t$dst.4s, $src1.4s, $src2.4s" #
3788 "|cmlo.4s\t$dst, $src1, $src2}",
3789 (CMHIv4i32 V128:$dst, V128:$src2, V128:$src1), 0>;
3790 def : InstAlias<"{cmlo\t$dst.2d, $src1.2d, $src2.2d" #
3791 "|cmlo.2d\t$dst, $src1, $src2}",
3792 (CMHIv2i64 V128:$dst, V128:$src2, V128:$src1), 0>;
3794 def : InstAlias<"{cmle\t$dst.8b, $src1.8b, $src2.8b" #
3795 "|cmle.8b\t$dst, $src1, $src2}",
3796 (CMGEv8i8 V64:$dst, V64:$src2, V64:$src1), 0>;
3797 def : InstAlias<"{cmle\t$dst.16b, $src1.16b, $src2.16b" #
3798 "|cmle.16b\t$dst, $src1, $src2}",
3799 (CMGEv16i8 V128:$dst, V128:$src2, V128:$src1), 0>;
3800 def : InstAlias<"{cmle\t$dst.4h, $src1.4h, $src2.4h" #
3801 "|cmle.4h\t$dst, $src1, $src2}",
3802 (CMGEv4i16 V64:$dst, V64:$src2, V64:$src1), 0>;
3803 def : InstAlias<"{cmle\t$dst.8h, $src1.8h, $src2.8h" #
3804 "|cmle.8h\t$dst, $src1, $src2}",
3805 (CMGEv8i16 V128:$dst, V128:$src2, V128:$src1), 0>;
3806 def : InstAlias<"{cmle\t$dst.2s, $src1.2s, $src2.2s" #
3807 "|cmle.2s\t$dst, $src1, $src2}",
3808 (CMGEv2i32 V64:$dst, V64:$src2, V64:$src1), 0>;
3809 def : InstAlias<"{cmle\t$dst.4s, $src1.4s, $src2.4s" #
3810 "|cmle.4s\t$dst, $src1, $src2}",
3811 (CMGEv4i32 V128:$dst, V128:$src2, V128:$src1), 0>;
3812 def : InstAlias<"{cmle\t$dst.2d, $src1.2d, $src2.2d" #
3813 "|cmle.2d\t$dst, $src1, $src2}",
3814 (CMGEv2i64 V128:$dst, V128:$src2, V128:$src1), 0>;
3816 def : InstAlias<"{cmlt\t$dst.8b, $src1.8b, $src2.8b" #
3817 "|cmlt.8b\t$dst, $src1, $src2}",
3818 (CMGTv8i8 V64:$dst, V64:$src2, V64:$src1), 0>;
3819 def : InstAlias<"{cmlt\t$dst.16b, $src1.16b, $src2.16b" #
3820 "|cmlt.16b\t$dst, $src1, $src2}",
3821 (CMGTv16i8 V128:$dst, V128:$src2, V128:$src1), 0>;
3822 def : InstAlias<"{cmlt\t$dst.4h, $src1.4h, $src2.4h" #
3823 "|cmlt.4h\t$dst, $src1, $src2}",
3824 (CMGTv4i16 V64:$dst, V64:$src2, V64:$src1), 0>;
3825 def : InstAlias<"{cmlt\t$dst.8h, $src1.8h, $src2.8h" #
3826 "|cmlt.8h\t$dst, $src1, $src2}",
3827 (CMGTv8i16 V128:$dst, V128:$src2, V128:$src1), 0>;
3828 def : InstAlias<"{cmlt\t$dst.2s, $src1.2s, $src2.2s" #
3829 "|cmlt.2s\t$dst, $src1, $src2}",
3830 (CMGTv2i32 V64:$dst, V64:$src2, V64:$src1), 0>;
3831 def : InstAlias<"{cmlt\t$dst.4s, $src1.4s, $src2.4s" #
3832 "|cmlt.4s\t$dst, $src1, $src2}",
3833 (CMGTv4i32 V128:$dst, V128:$src2, V128:$src1), 0>;
3834 def : InstAlias<"{cmlt\t$dst.2d, $src1.2d, $src2.2d" #
3835 "|cmlt.2d\t$dst, $src1, $src2}",
3836 (CMGTv2i64 V128:$dst, V128:$src2, V128:$src1), 0>;
3838 let Predicates = [HasNEON, HasFullFP16] in {
3839 def : InstAlias<"{fcmle\t$dst.4h, $src1.4h, $src2.4h" #
3840 "|fcmle.4h\t$dst, $src1, $src2}",
3841 (FCMGEv4f16 V64:$dst, V64:$src2, V64:$src1), 0>;
3842 def : InstAlias<"{fcmle\t$dst.8h, $src1.8h, $src2.8h" #
3843 "|fcmle.8h\t$dst, $src1, $src2}",
3844 (FCMGEv8f16 V128:$dst, V128:$src2, V128:$src1), 0>;
3846 def : InstAlias<"{fcmle\t$dst.2s, $src1.2s, $src2.2s" #
3847 "|fcmle.2s\t$dst, $src1, $src2}",
3848 (FCMGEv2f32 V64:$dst, V64:$src2, V64:$src1), 0>;
3849 def : InstAlias<"{fcmle\t$dst.4s, $src1.4s, $src2.4s" #
3850 "|fcmle.4s\t$dst, $src1, $src2}",
3851 (FCMGEv4f32 V128:$dst, V128:$src2, V128:$src1), 0>;
3852 def : InstAlias<"{fcmle\t$dst.2d, $src1.2d, $src2.2d" #
3853 "|fcmle.2d\t$dst, $src1, $src2}",
3854 (FCMGEv2f64 V128:$dst, V128:$src2, V128:$src1), 0>;
3856 let Predicates = [HasNEON, HasFullFP16] in {
3857 def : InstAlias<"{fcmlt\t$dst.4h, $src1.4h, $src2.4h" #
3858 "|fcmlt.4h\t$dst, $src1, $src2}",
3859 (FCMGTv4f16 V64:$dst, V64:$src2, V64:$src1), 0>;
3860 def : InstAlias<"{fcmlt\t$dst.8h, $src1.8h, $src2.8h" #
3861 "|fcmlt.8h\t$dst, $src1, $src2}",
3862 (FCMGTv8f16 V128:$dst, V128:$src2, V128:$src1), 0>;
3864 def : InstAlias<"{fcmlt\t$dst.2s, $src1.2s, $src2.2s" #
3865 "|fcmlt.2s\t$dst, $src1, $src2}",
3866 (FCMGTv2f32 V64:$dst, V64:$src2, V64:$src1), 0>;
3867 def : InstAlias<"{fcmlt\t$dst.4s, $src1.4s, $src2.4s" #
3868 "|fcmlt.4s\t$dst, $src1, $src2}",
3869 (FCMGTv4f32 V128:$dst, V128:$src2, V128:$src1), 0>;
3870 def : InstAlias<"{fcmlt\t$dst.2d, $src1.2d, $src2.2d" #
3871 "|fcmlt.2d\t$dst, $src1, $src2}",
3872 (FCMGTv2f64 V128:$dst, V128:$src2, V128:$src1), 0>;
3874 let Predicates = [HasNEON, HasFullFP16] in {
3875 def : InstAlias<"{facle\t$dst.4h, $src1.4h, $src2.4h" #
3876 "|facle.4h\t$dst, $src1, $src2}",
3877 (FACGEv4f16 V64:$dst, V64:$src2, V64:$src1), 0>;
3878 def : InstAlias<"{facle\t$dst.8h, $src1.8h, $src2.8h" #
3879 "|facle.8h\t$dst, $src1, $src2}",
3880 (FACGEv8f16 V128:$dst, V128:$src2, V128:$src1), 0>;
3882 def : InstAlias<"{facle\t$dst.2s, $src1.2s, $src2.2s" #
3883 "|facle.2s\t$dst, $src1, $src2}",
3884 (FACGEv2f32 V64:$dst, V64:$src2, V64:$src1), 0>;
3885 def : InstAlias<"{facle\t$dst.4s, $src1.4s, $src2.4s" #
3886 "|facle.4s\t$dst, $src1, $src2}",
3887 (FACGEv4f32 V128:$dst, V128:$src2, V128:$src1), 0>;
3888 def : InstAlias<"{facle\t$dst.2d, $src1.2d, $src2.2d" #
3889 "|facle.2d\t$dst, $src1, $src2}",
3890 (FACGEv2f64 V128:$dst, V128:$src2, V128:$src1), 0>;
3892 let Predicates = [HasNEON, HasFullFP16] in {
3893 def : InstAlias<"{faclt\t$dst.4h, $src1.4h, $src2.4h" #
3894 "|faclt.4h\t$dst, $src1, $src2}",
3895 (FACGTv4f16 V64:$dst, V64:$src2, V64:$src1), 0>;
3896 def : InstAlias<"{faclt\t$dst.8h, $src1.8h, $src2.8h" #
3897 "|faclt.8h\t$dst, $src1, $src2}",
3898 (FACGTv8f16 V128:$dst, V128:$src2, V128:$src1), 0>;
3900 def : InstAlias<"{faclt\t$dst.2s, $src1.2s, $src2.2s" #
3901 "|faclt.2s\t$dst, $src1, $src2}",
3902 (FACGTv2f32 V64:$dst, V64:$src2, V64:$src1), 0>;
3903 def : InstAlias<"{faclt\t$dst.4s, $src1.4s, $src2.4s" #
3904 "|faclt.4s\t$dst, $src1, $src2}",
3905 (FACGTv4f32 V128:$dst, V128:$src2, V128:$src1), 0>;
3906 def : InstAlias<"{faclt\t$dst.2d, $src1.2d, $src2.2d" #
3907 "|faclt.2d\t$dst, $src1, $src2}",
3908 (FACGTv2f64 V128:$dst, V128:$src2, V128:$src1), 0>;
3910 //===----------------------------------------------------------------------===//
3911 // Advanced SIMD three scalar instructions.
3912 //===----------------------------------------------------------------------===//
3914 defm ADD : SIMDThreeScalarD<0, 0b10000, "add", add>;
3915 defm CMEQ : SIMDThreeScalarD<1, 0b10001, "cmeq", AArch64cmeq>;
3916 defm CMGE : SIMDThreeScalarD<0, 0b00111, "cmge", AArch64cmge>;
3917 defm CMGT : SIMDThreeScalarD<0, 0b00110, "cmgt", AArch64cmgt>;
3918 defm CMHI : SIMDThreeScalarD<1, 0b00110, "cmhi", AArch64cmhi>;
3919 defm CMHS : SIMDThreeScalarD<1, 0b00111, "cmhs", AArch64cmhs>;
3920 defm CMTST : SIMDThreeScalarD<0, 0b10001, "cmtst", AArch64cmtst>;
3921 defm FABD : SIMDFPThreeScalar<1, 1, 0b010, "fabd", int_aarch64_sisd_fabd>;
3922 def : Pat<(v1f64 (int_aarch64_neon_fabd (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
3923 (FABD64 FPR64:$Rn, FPR64:$Rm)>;
3924 let Predicates = [HasFullFP16] in {
3925 def : Pat<(fabs (fsub f16:$Rn, f16:$Rm)), (FABD16 f16:$Rn, f16:$Rm)>;
3927 def : Pat<(fabs (fsub f32:$Rn, f32:$Rm)), (FABD32 f32:$Rn, f32:$Rm)>;
3928 def : Pat<(fabs (fsub f64:$Rn, f64:$Rm)), (FABD64 f64:$Rn, f64:$Rm)>;
3929 defm FACGE : SIMDThreeScalarFPCmp<1, 0, 0b101, "facge",
3930 int_aarch64_neon_facge>;
3931 defm FACGT : SIMDThreeScalarFPCmp<1, 1, 0b101, "facgt",
3932 int_aarch64_neon_facgt>;
3933 defm FCMEQ : SIMDThreeScalarFPCmp<0, 0, 0b100, "fcmeq", AArch64fcmeq>;
3934 defm FCMGE : SIMDThreeScalarFPCmp<1, 0, 0b100, "fcmge", AArch64fcmge>;
3935 defm FCMGT : SIMDThreeScalarFPCmp<1, 1, 0b100, "fcmgt", AArch64fcmgt>;
3936 defm FMULX : SIMDFPThreeScalar<0, 0, 0b011, "fmulx", int_aarch64_neon_fmulx>;
3937 defm FRECPS : SIMDFPThreeScalar<0, 0, 0b111, "frecps", int_aarch64_neon_frecps>;
3938 defm FRSQRTS : SIMDFPThreeScalar<0, 1, 0b111, "frsqrts", int_aarch64_neon_frsqrts>;
3939 defm SQADD : SIMDThreeScalarBHSD<0, 0b00001, "sqadd", int_aarch64_neon_sqadd>;
3940 defm SQDMULH : SIMDThreeScalarHS< 0, 0b10110, "sqdmulh", int_aarch64_neon_sqdmulh>;
3941 defm SQRDMULH : SIMDThreeScalarHS< 1, 0b10110, "sqrdmulh", int_aarch64_neon_sqrdmulh>;
3942 defm SQRSHL : SIMDThreeScalarBHSD<0, 0b01011, "sqrshl",int_aarch64_neon_sqrshl>;
3943 defm SQSHL : SIMDThreeScalarBHSD<0, 0b01001, "sqshl", int_aarch64_neon_sqshl>;
3944 defm SQSUB : SIMDThreeScalarBHSD<0, 0b00101, "sqsub", int_aarch64_neon_sqsub>;
3945 defm SRSHL : SIMDThreeScalarD< 0, 0b01010, "srshl", int_aarch64_neon_srshl>;
3946 defm SSHL : SIMDThreeScalarD< 0, 0b01000, "sshl", int_aarch64_neon_sshl>;
3947 defm SUB : SIMDThreeScalarD< 1, 0b10000, "sub", sub>;
3948 defm UQADD : SIMDThreeScalarBHSD<1, 0b00001, "uqadd", int_aarch64_neon_uqadd>;
3949 defm UQRSHL : SIMDThreeScalarBHSD<1, 0b01011, "uqrshl",int_aarch64_neon_uqrshl>;
3950 defm UQSHL : SIMDThreeScalarBHSD<1, 0b01001, "uqshl", int_aarch64_neon_uqshl>;
3951 defm UQSUB : SIMDThreeScalarBHSD<1, 0b00101, "uqsub", int_aarch64_neon_uqsub>;
3952 defm URSHL : SIMDThreeScalarD< 1, 0b01010, "urshl", int_aarch64_neon_urshl>;
3953 defm USHL : SIMDThreeScalarD< 1, 0b01000, "ushl", int_aarch64_neon_ushl>;
3954 let Predicates = [HasRDM] in {
3955 defm SQRDMLAH : SIMDThreeScalarHSTied<1, 0, 0b10000, "sqrdmlah">;
3956 defm SQRDMLSH : SIMDThreeScalarHSTied<1, 0, 0b10001, "sqrdmlsh">;
3957 def : Pat<(i32 (int_aarch64_neon_sqadd
3959 (i32 (int_aarch64_neon_sqrdmulh (i32 FPR32:$Rn),
3960 (i32 FPR32:$Rm))))),
3961 (SQRDMLAHv1i32 FPR32:$Rd, FPR32:$Rn, FPR32:$Rm)>;
3962 def : Pat<(i32 (int_aarch64_neon_sqsub
3964 (i32 (int_aarch64_neon_sqrdmulh (i32 FPR32:$Rn),
3965 (i32 FPR32:$Rm))))),
3966 (SQRDMLSHv1i32 FPR32:$Rd, FPR32:$Rn, FPR32:$Rm)>;
3969 def : InstAlias<"cmls $dst, $src1, $src2",
3970 (CMHSv1i64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
3971 def : InstAlias<"cmle $dst, $src1, $src2",
3972 (CMGEv1i64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
3973 def : InstAlias<"cmlo $dst, $src1, $src2",
3974 (CMHIv1i64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
3975 def : InstAlias<"cmlt $dst, $src1, $src2",
3976 (CMGTv1i64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
3977 def : InstAlias<"fcmle $dst, $src1, $src2",
3978 (FCMGE32 FPR32:$dst, FPR32:$src2, FPR32:$src1), 0>;
3979 def : InstAlias<"fcmle $dst, $src1, $src2",
3980 (FCMGE64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
3981 def : InstAlias<"fcmlt $dst, $src1, $src2",
3982 (FCMGT32 FPR32:$dst, FPR32:$src2, FPR32:$src1), 0>;
3983 def : InstAlias<"fcmlt $dst, $src1, $src2",
3984 (FCMGT64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
3985 def : InstAlias<"facle $dst, $src1, $src2",
3986 (FACGE32 FPR32:$dst, FPR32:$src2, FPR32:$src1), 0>;
3987 def : InstAlias<"facle $dst, $src1, $src2",
3988 (FACGE64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
3989 def : InstAlias<"faclt $dst, $src1, $src2",
3990 (FACGT32 FPR32:$dst, FPR32:$src2, FPR32:$src1), 0>;
3991 def : InstAlias<"faclt $dst, $src1, $src2",
3992 (FACGT64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
3994 //===----------------------------------------------------------------------===//
3995 // Advanced SIMD three scalar instructions (mixed operands).
3996 //===----------------------------------------------------------------------===//
3997 defm SQDMULL : SIMDThreeScalarMixedHS<0, 0b11010, "sqdmull",
3998 int_aarch64_neon_sqdmulls_scalar>;
3999 defm SQDMLAL : SIMDThreeScalarMixedTiedHS<0, 0b10010, "sqdmlal">;
4000 defm SQDMLSL : SIMDThreeScalarMixedTiedHS<0, 0b10110, "sqdmlsl">;
4002 def : Pat<(i64 (int_aarch64_neon_sqadd (i64 FPR64:$Rd),
4003 (i64 (int_aarch64_neon_sqdmulls_scalar (i32 FPR32:$Rn),
4004 (i32 FPR32:$Rm))))),
4005 (SQDMLALi32 FPR64:$Rd, FPR32:$Rn, FPR32:$Rm)>;
4006 def : Pat<(i64 (int_aarch64_neon_sqsub (i64 FPR64:$Rd),
4007 (i64 (int_aarch64_neon_sqdmulls_scalar (i32 FPR32:$Rn),
4008 (i32 FPR32:$Rm))))),
4009 (SQDMLSLi32 FPR64:$Rd, FPR32:$Rn, FPR32:$Rm)>;
4011 //===----------------------------------------------------------------------===//
4012 // Advanced SIMD two scalar instructions.
4013 //===----------------------------------------------------------------------===//
4015 defm ABS : SIMDTwoScalarD< 0, 0b01011, "abs", abs>;
4016 defm CMEQ : SIMDCmpTwoScalarD< 0, 0b01001, "cmeq", AArch64cmeqz>;
4017 defm CMGE : SIMDCmpTwoScalarD< 1, 0b01000, "cmge", AArch64cmgez>;
4018 defm CMGT : SIMDCmpTwoScalarD< 0, 0b01000, "cmgt", AArch64cmgtz>;
4019 defm CMLE : SIMDCmpTwoScalarD< 1, 0b01001, "cmle", AArch64cmlez>;
4020 defm CMLT : SIMDCmpTwoScalarD< 0, 0b01010, "cmlt", AArch64cmltz>;
4021 defm FCMEQ : SIMDFPCmpTwoScalar<0, 1, 0b01101, "fcmeq", AArch64fcmeqz>;
4022 defm FCMGE : SIMDFPCmpTwoScalar<1, 1, 0b01100, "fcmge", AArch64fcmgez>;
4023 defm FCMGT : SIMDFPCmpTwoScalar<0, 1, 0b01100, "fcmgt", AArch64fcmgtz>;
4024 defm FCMLE : SIMDFPCmpTwoScalar<1, 1, 0b01101, "fcmle", AArch64fcmlez>;
4025 defm FCMLT : SIMDFPCmpTwoScalar<0, 1, 0b01110, "fcmlt", AArch64fcmltz>;
4026 defm FCVTAS : SIMDFPTwoScalar< 0, 0, 0b11100, "fcvtas">;
4027 defm FCVTAU : SIMDFPTwoScalar< 1, 0, 0b11100, "fcvtau">;
4028 defm FCVTMS : SIMDFPTwoScalar< 0, 0, 0b11011, "fcvtms">;
4029 defm FCVTMU : SIMDFPTwoScalar< 1, 0, 0b11011, "fcvtmu">;
4030 defm FCVTNS : SIMDFPTwoScalar< 0, 0, 0b11010, "fcvtns">;
4031 defm FCVTNU : SIMDFPTwoScalar< 1, 0, 0b11010, "fcvtnu">;
4032 defm FCVTPS : SIMDFPTwoScalar< 0, 1, 0b11010, "fcvtps">;
4033 defm FCVTPU : SIMDFPTwoScalar< 1, 1, 0b11010, "fcvtpu">;
4034 def FCVTXNv1i64 : SIMDInexactCvtTwoScalar<0b10110, "fcvtxn">;
4035 defm FCVTZS : SIMDFPTwoScalar< 0, 1, 0b11011, "fcvtzs">;
4036 defm FCVTZU : SIMDFPTwoScalar< 1, 1, 0b11011, "fcvtzu">;
4037 defm FRECPE : SIMDFPTwoScalar< 0, 1, 0b11101, "frecpe">;
4038 defm FRECPX : SIMDFPTwoScalar< 0, 1, 0b11111, "frecpx">;
4039 defm FRSQRTE : SIMDFPTwoScalar< 1, 1, 0b11101, "frsqrte">;
4040 defm NEG : SIMDTwoScalarD< 1, 0b01011, "neg",
4041 UnOpFrag<(sub immAllZerosV, node:$LHS)> >;
4042 defm SCVTF : SIMDFPTwoScalarCVT< 0, 0, 0b11101, "scvtf", AArch64sitof>;
4043 defm SQABS : SIMDTwoScalarBHSD< 0, 0b00111, "sqabs", int_aarch64_neon_sqabs>;
4044 defm SQNEG : SIMDTwoScalarBHSD< 1, 0b00111, "sqneg", int_aarch64_neon_sqneg>;
4045 defm SQXTN : SIMDTwoScalarMixedBHS< 0, 0b10100, "sqxtn", int_aarch64_neon_scalar_sqxtn>;
4046 defm SQXTUN : SIMDTwoScalarMixedBHS< 1, 0b10010, "sqxtun", int_aarch64_neon_scalar_sqxtun>;
4047 defm SUQADD : SIMDTwoScalarBHSDTied< 0, 0b00011, "suqadd",
4048 int_aarch64_neon_suqadd>;
4049 defm UCVTF : SIMDFPTwoScalarCVT< 1, 0, 0b11101, "ucvtf", AArch64uitof>;
4050 defm UQXTN : SIMDTwoScalarMixedBHS<1, 0b10100, "uqxtn", int_aarch64_neon_scalar_uqxtn>;
4051 defm USQADD : SIMDTwoScalarBHSDTied< 1, 0b00011, "usqadd",
4052 int_aarch64_neon_usqadd>;
4054 def : Pat<(AArch64neg (v1i64 V64:$Rn)), (NEGv1i64 V64:$Rn)>;
4056 def : Pat<(v1i64 (int_aarch64_neon_fcvtas (v1f64 FPR64:$Rn))),
4057 (FCVTASv1i64 FPR64:$Rn)>;
4058 def : Pat<(v1i64 (int_aarch64_neon_fcvtau (v1f64 FPR64:$Rn))),
4059 (FCVTAUv1i64 FPR64:$Rn)>;
4060 def : Pat<(v1i64 (int_aarch64_neon_fcvtms (v1f64 FPR64:$Rn))),
4061 (FCVTMSv1i64 FPR64:$Rn)>;
4062 def : Pat<(v1i64 (int_aarch64_neon_fcvtmu (v1f64 FPR64:$Rn))),
4063 (FCVTMUv1i64 FPR64:$Rn)>;
4064 def : Pat<(v1i64 (int_aarch64_neon_fcvtns (v1f64 FPR64:$Rn))),
4065 (FCVTNSv1i64 FPR64:$Rn)>;
4066 def : Pat<(v1i64 (int_aarch64_neon_fcvtnu (v1f64 FPR64:$Rn))),
4067 (FCVTNUv1i64 FPR64:$Rn)>;
4068 def : Pat<(v1i64 (int_aarch64_neon_fcvtps (v1f64 FPR64:$Rn))),
4069 (FCVTPSv1i64 FPR64:$Rn)>;
4070 def : Pat<(v1i64 (int_aarch64_neon_fcvtpu (v1f64 FPR64:$Rn))),
4071 (FCVTPUv1i64 FPR64:$Rn)>;
4073 def : Pat<(f16 (int_aarch64_neon_frecpe (f16 FPR16:$Rn))),
4074 (FRECPEv1f16 FPR16:$Rn)>;
4075 def : Pat<(f32 (int_aarch64_neon_frecpe (f32 FPR32:$Rn))),
4076 (FRECPEv1i32 FPR32:$Rn)>;
4077 def : Pat<(f64 (int_aarch64_neon_frecpe (f64 FPR64:$Rn))),
4078 (FRECPEv1i64 FPR64:$Rn)>;
4079 def : Pat<(v1f64 (int_aarch64_neon_frecpe (v1f64 FPR64:$Rn))),
4080 (FRECPEv1i64 FPR64:$Rn)>;
4082 def : Pat<(f32 (AArch64frecpe (f32 FPR32:$Rn))),
4083 (FRECPEv1i32 FPR32:$Rn)>;
4084 def : Pat<(v2f32 (AArch64frecpe (v2f32 V64:$Rn))),
4085 (FRECPEv2f32 V64:$Rn)>;
4086 def : Pat<(v4f32 (AArch64frecpe (v4f32 FPR128:$Rn))),
4087 (FRECPEv4f32 FPR128:$Rn)>;
4088 def : Pat<(f64 (AArch64frecpe (f64 FPR64:$Rn))),
4089 (FRECPEv1i64 FPR64:$Rn)>;
4090 def : Pat<(v1f64 (AArch64frecpe (v1f64 FPR64:$Rn))),
4091 (FRECPEv1i64 FPR64:$Rn)>;
4092 def : Pat<(v2f64 (AArch64frecpe (v2f64 FPR128:$Rn))),
4093 (FRECPEv2f64 FPR128:$Rn)>;
4095 def : Pat<(f32 (AArch64frecps (f32 FPR32:$Rn), (f32 FPR32:$Rm))),
4096 (FRECPS32 FPR32:$Rn, FPR32:$Rm)>;
4097 def : Pat<(v2f32 (AArch64frecps (v2f32 V64:$Rn), (v2f32 V64:$Rm))),
4098 (FRECPSv2f32 V64:$Rn, V64:$Rm)>;
4099 def : Pat<(v4f32 (AArch64frecps (v4f32 FPR128:$Rn), (v4f32 FPR128:$Rm))),
4100 (FRECPSv4f32 FPR128:$Rn, FPR128:$Rm)>;
4101 def : Pat<(f64 (AArch64frecps (f64 FPR64:$Rn), (f64 FPR64:$Rm))),
4102 (FRECPS64 FPR64:$Rn, FPR64:$Rm)>;
4103 def : Pat<(v2f64 (AArch64frecps (v2f64 FPR128:$Rn), (v2f64 FPR128:$Rm))),
4104 (FRECPSv2f64 FPR128:$Rn, FPR128:$Rm)>;
4106 def : Pat<(f16 (int_aarch64_neon_frecpx (f16 FPR16:$Rn))),
4107 (FRECPXv1f16 FPR16:$Rn)>;
4108 def : Pat<(f32 (int_aarch64_neon_frecpx (f32 FPR32:$Rn))),
4109 (FRECPXv1i32 FPR32:$Rn)>;
4110 def : Pat<(f64 (int_aarch64_neon_frecpx (f64 FPR64:$Rn))),
4111 (FRECPXv1i64 FPR64:$Rn)>;
4113 def : Pat<(f16 (int_aarch64_neon_frsqrte (f16 FPR16:$Rn))),
4114 (FRSQRTEv1f16 FPR16:$Rn)>;
4115 def : Pat<(f32 (int_aarch64_neon_frsqrte (f32 FPR32:$Rn))),
4116 (FRSQRTEv1i32 FPR32:$Rn)>;
4117 def : Pat<(f64 (int_aarch64_neon_frsqrte (f64 FPR64:$Rn))),
4118 (FRSQRTEv1i64 FPR64:$Rn)>;
4119 def : Pat<(v1f64 (int_aarch64_neon_frsqrte (v1f64 FPR64:$Rn))),
4120 (FRSQRTEv1i64 FPR64:$Rn)>;
4122 def : Pat<(f32 (AArch64frsqrte (f32 FPR32:$Rn))),
4123 (FRSQRTEv1i32 FPR32:$Rn)>;
4124 def : Pat<(v2f32 (AArch64frsqrte (v2f32 V64:$Rn))),
4125 (FRSQRTEv2f32 V64:$Rn)>;
4126 def : Pat<(v4f32 (AArch64frsqrte (v4f32 FPR128:$Rn))),
4127 (FRSQRTEv4f32 FPR128:$Rn)>;
4128 def : Pat<(f64 (AArch64frsqrte (f64 FPR64:$Rn))),
4129 (FRSQRTEv1i64 FPR64:$Rn)>;
4130 def : Pat<(v1f64 (AArch64frsqrte (v1f64 FPR64:$Rn))),
4131 (FRSQRTEv1i64 FPR64:$Rn)>;
4132 def : Pat<(v2f64 (AArch64frsqrte (v2f64 FPR128:$Rn))),
4133 (FRSQRTEv2f64 FPR128:$Rn)>;
4135 def : Pat<(f32 (AArch64frsqrts (f32 FPR32:$Rn), (f32 FPR32:$Rm))),
4136 (FRSQRTS32 FPR32:$Rn, FPR32:$Rm)>;
4137 def : Pat<(v2f32 (AArch64frsqrts (v2f32 V64:$Rn), (v2f32 V64:$Rm))),
4138 (FRSQRTSv2f32 V64:$Rn, V64:$Rm)>;
4139 def : Pat<(v4f32 (AArch64frsqrts (v4f32 FPR128:$Rn), (v4f32 FPR128:$Rm))),
4140 (FRSQRTSv4f32 FPR128:$Rn, FPR128:$Rm)>;
4141 def : Pat<(f64 (AArch64frsqrts (f64 FPR64:$Rn), (f64 FPR64:$Rm))),
4142 (FRSQRTS64 FPR64:$Rn, FPR64:$Rm)>;
4143 def : Pat<(v2f64 (AArch64frsqrts (v2f64 FPR128:$Rn), (v2f64 FPR128:$Rm))),
4144 (FRSQRTSv2f64 FPR128:$Rn, FPR128:$Rm)>;
4146 // If an integer is about to be converted to a floating point value,
4147 // just load it on the floating point unit.
4148 // Here are the patterns for 8 and 16-bits to float.
4150 multiclass UIntToFPROLoadPat<ValueType DstTy, ValueType SrcTy,
4151 SDPatternOperator loadop, Instruction UCVTF,
4152 ROAddrMode ro, Instruction LDRW, Instruction LDRX,
4154 def : Pat<(DstTy (uint_to_fp (SrcTy
4155 (loadop (ro.Wpat GPR64sp:$Rn, GPR32:$Rm,
4156 ro.Wext:$extend))))),
4157 (UCVTF (INSERT_SUBREG (DstTy (IMPLICIT_DEF)),
4158 (LDRW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend),
4161 def : Pat<(DstTy (uint_to_fp (SrcTy
4162 (loadop (ro.Xpat GPR64sp:$Rn, GPR64:$Rm,
4163 ro.Wext:$extend))))),
4164 (UCVTF (INSERT_SUBREG (DstTy (IMPLICIT_DEF)),
4165 (LDRX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend),
4169 defm : UIntToFPROLoadPat<f32, i32, zextloadi8,
4170 UCVTFv1i32, ro8, LDRBroW, LDRBroX, bsub>;
4171 def : Pat <(f32 (uint_to_fp (i32
4172 (zextloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))))),
4173 (UCVTFv1i32 (INSERT_SUBREG (f32 (IMPLICIT_DEF)),
4174 (LDRBui GPR64sp:$Rn, uimm12s1:$offset), bsub))>;
4175 def : Pat <(f32 (uint_to_fp (i32
4176 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))))),
4177 (UCVTFv1i32 (INSERT_SUBREG (f32 (IMPLICIT_DEF)),
4178 (LDURBi GPR64sp:$Rn, simm9:$offset), bsub))>;
4179 // 16-bits -> float.
4180 defm : UIntToFPROLoadPat<f32, i32, zextloadi16,
4181 UCVTFv1i32, ro16, LDRHroW, LDRHroX, hsub>;
4182 def : Pat <(f32 (uint_to_fp (i32
4183 (zextloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))))),
4184 (UCVTFv1i32 (INSERT_SUBREG (f32 (IMPLICIT_DEF)),
4185 (LDRHui GPR64sp:$Rn, uimm12s2:$offset), hsub))>;
4186 def : Pat <(f32 (uint_to_fp (i32
4187 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))))),
4188 (UCVTFv1i32 (INSERT_SUBREG (f32 (IMPLICIT_DEF)),
4189 (LDURHi GPR64sp:$Rn, simm9:$offset), hsub))>;
4190 // 32-bits are handled in target specific dag combine:
4191 // performIntToFpCombine.
4192 // 64-bits integer to 32-bits floating point, not possible with
4193 // UCVTF on floating point registers (both source and destination
4194 // must have the same size).
4196 // Here are the patterns for 8, 16, 32, and 64-bits to double.
4197 // 8-bits -> double.
4198 defm : UIntToFPROLoadPat<f64, i32, zextloadi8,
4199 UCVTFv1i64, ro8, LDRBroW, LDRBroX, bsub>;
4200 def : Pat <(f64 (uint_to_fp (i32
4201 (zextloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))))),
4202 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4203 (LDRBui GPR64sp:$Rn, uimm12s1:$offset), bsub))>;
4204 def : Pat <(f64 (uint_to_fp (i32
4205 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))))),
4206 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4207 (LDURBi GPR64sp:$Rn, simm9:$offset), bsub))>;
4208 // 16-bits -> double.
4209 defm : UIntToFPROLoadPat<f64, i32, zextloadi16,
4210 UCVTFv1i64, ro16, LDRHroW, LDRHroX, hsub>;
4211 def : Pat <(f64 (uint_to_fp (i32
4212 (zextloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))))),
4213 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4214 (LDRHui GPR64sp:$Rn, uimm12s2:$offset), hsub))>;
4215 def : Pat <(f64 (uint_to_fp (i32
4216 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))))),
4217 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4218 (LDURHi GPR64sp:$Rn, simm9:$offset), hsub))>;
4219 // 32-bits -> double.
4220 defm : UIntToFPROLoadPat<f64, i32, load,
4221 UCVTFv1i64, ro32, LDRSroW, LDRSroX, ssub>;
4222 def : Pat <(f64 (uint_to_fp (i32
4223 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))))),
4224 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4225 (LDRSui GPR64sp:$Rn, uimm12s4:$offset), ssub))>;
4226 def : Pat <(f64 (uint_to_fp (i32
4227 (load (am_unscaled32 GPR64sp:$Rn, simm9:$offset))))),
4228 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4229 (LDURSi GPR64sp:$Rn, simm9:$offset), ssub))>;
4230 // 64-bits -> double are handled in target specific dag combine:
4231 // performIntToFpCombine.
4233 //===----------------------------------------------------------------------===//
4234 // Advanced SIMD three different-sized vector instructions.
4235 //===----------------------------------------------------------------------===//
4237 defm ADDHN : SIMDNarrowThreeVectorBHS<0,0b0100,"addhn", int_aarch64_neon_addhn>;
4238 defm SUBHN : SIMDNarrowThreeVectorBHS<0,0b0110,"subhn", int_aarch64_neon_subhn>;
4239 defm RADDHN : SIMDNarrowThreeVectorBHS<1,0b0100,"raddhn",int_aarch64_neon_raddhn>;
4240 defm RSUBHN : SIMDNarrowThreeVectorBHS<1,0b0110,"rsubhn",int_aarch64_neon_rsubhn>;
4241 defm PMULL : SIMDDifferentThreeVectorBD<0,0b1110,"pmull",int_aarch64_neon_pmull>;
4242 defm SABAL : SIMDLongThreeVectorTiedBHSabal<0,0b0101,"sabal",
4243 int_aarch64_neon_sabd>;
4244 defm SABDL : SIMDLongThreeVectorBHSabdl<0, 0b0111, "sabdl",
4245 int_aarch64_neon_sabd>;
4246 defm SADDL : SIMDLongThreeVectorBHS< 0, 0b0000, "saddl",
4247 BinOpFrag<(add (sext node:$LHS), (sext node:$RHS))>>;
4248 defm SADDW : SIMDWideThreeVectorBHS< 0, 0b0001, "saddw",
4249 BinOpFrag<(add node:$LHS, (sext node:$RHS))>>;
4250 defm SMLAL : SIMDLongThreeVectorTiedBHS<0, 0b1000, "smlal",
4251 TriOpFrag<(add node:$LHS, (int_aarch64_neon_smull node:$MHS, node:$RHS))>>;
4252 defm SMLSL : SIMDLongThreeVectorTiedBHS<0, 0b1010, "smlsl",
4253 TriOpFrag<(sub node:$LHS, (int_aarch64_neon_smull node:$MHS, node:$RHS))>>;
4254 defm SMULL : SIMDLongThreeVectorBHS<0, 0b1100, "smull", int_aarch64_neon_smull>;
4255 defm SQDMLAL : SIMDLongThreeVectorSQDMLXTiedHS<0, 0b1001, "sqdmlal",
4256 int_aarch64_neon_sqadd>;
4257 defm SQDMLSL : SIMDLongThreeVectorSQDMLXTiedHS<0, 0b1011, "sqdmlsl",
4258 int_aarch64_neon_sqsub>;
4259 defm SQDMULL : SIMDLongThreeVectorHS<0, 0b1101, "sqdmull",
4260 int_aarch64_neon_sqdmull>;
4261 defm SSUBL : SIMDLongThreeVectorBHS<0, 0b0010, "ssubl",
4262 BinOpFrag<(sub (sext node:$LHS), (sext node:$RHS))>>;
4263 defm SSUBW : SIMDWideThreeVectorBHS<0, 0b0011, "ssubw",
4264 BinOpFrag<(sub node:$LHS, (sext node:$RHS))>>;
4265 defm UABAL : SIMDLongThreeVectorTiedBHSabal<1, 0b0101, "uabal",
4266 int_aarch64_neon_uabd>;
4267 defm UADDL : SIMDLongThreeVectorBHS<1, 0b0000, "uaddl",
4268 BinOpFrag<(add (zext node:$LHS), (zext node:$RHS))>>;
4269 defm UADDW : SIMDWideThreeVectorBHS<1, 0b0001, "uaddw",
4270 BinOpFrag<(add node:$LHS, (zext node:$RHS))>>;
4271 defm UMLAL : SIMDLongThreeVectorTiedBHS<1, 0b1000, "umlal",
4272 TriOpFrag<(add node:$LHS, (int_aarch64_neon_umull node:$MHS, node:$RHS))>>;
4273 defm UMLSL : SIMDLongThreeVectorTiedBHS<1, 0b1010, "umlsl",
4274 TriOpFrag<(sub node:$LHS, (int_aarch64_neon_umull node:$MHS, node:$RHS))>>;
4275 defm UMULL : SIMDLongThreeVectorBHS<1, 0b1100, "umull", int_aarch64_neon_umull>;
4276 defm USUBL : SIMDLongThreeVectorBHS<1, 0b0010, "usubl",
4277 BinOpFrag<(sub (zext node:$LHS), (zext node:$RHS))>>;
4278 defm USUBW : SIMDWideThreeVectorBHS< 1, 0b0011, "usubw",
4279 BinOpFrag<(sub node:$LHS, (zext node:$RHS))>>;
4281 // Additional patterns for SMULL and UMULL
4282 multiclass Neon_mul_widen_patterns<SDPatternOperator opnode,
4283 Instruction INST8B, Instruction INST4H, Instruction INST2S> {
4284 def : Pat<(v8i16 (opnode (v8i8 V64:$Rn), (v8i8 V64:$Rm))),
4285 (INST8B V64:$Rn, V64:$Rm)>;
4286 def : Pat<(v4i32 (opnode (v4i16 V64:$Rn), (v4i16 V64:$Rm))),
4287 (INST4H V64:$Rn, V64:$Rm)>;
4288 def : Pat<(v2i64 (opnode (v2i32 V64:$Rn), (v2i32 V64:$Rm))),
4289 (INST2S V64:$Rn, V64:$Rm)>;
4292 defm : Neon_mul_widen_patterns<AArch64smull, SMULLv8i8_v8i16,
4293 SMULLv4i16_v4i32, SMULLv2i32_v2i64>;
4294 defm : Neon_mul_widen_patterns<AArch64umull, UMULLv8i8_v8i16,
4295 UMULLv4i16_v4i32, UMULLv2i32_v2i64>;
4297 // Additional patterns for SMLAL/SMLSL and UMLAL/UMLSL
4298 multiclass Neon_mulacc_widen_patterns<SDPatternOperator opnode,
4299 Instruction INST8B, Instruction INST4H, Instruction INST2S> {
4300 def : Pat<(v8i16 (opnode (v8i16 V128:$Rd), (v8i8 V64:$Rn), (v8i8 V64:$Rm))),
4301 (INST8B V128:$Rd, V64:$Rn, V64:$Rm)>;
4302 def : Pat<(v4i32 (opnode (v4i32 V128:$Rd), (v4i16 V64:$Rn), (v4i16 V64:$Rm))),
4303 (INST4H V128:$Rd, V64:$Rn, V64:$Rm)>;
4304 def : Pat<(v2i64 (opnode (v2i64 V128:$Rd), (v2i32 V64:$Rn), (v2i32 V64:$Rm))),
4305 (INST2S V128:$Rd, V64:$Rn, V64:$Rm)>;
4308 defm : Neon_mulacc_widen_patterns<
4309 TriOpFrag<(add node:$LHS, (AArch64smull node:$MHS, node:$RHS))>,
4310 SMLALv8i8_v8i16, SMLALv4i16_v4i32, SMLALv2i32_v2i64>;
4311 defm : Neon_mulacc_widen_patterns<
4312 TriOpFrag<(add node:$LHS, (AArch64umull node:$MHS, node:$RHS))>,
4313 UMLALv8i8_v8i16, UMLALv4i16_v4i32, UMLALv2i32_v2i64>;
4314 defm : Neon_mulacc_widen_patterns<
4315 TriOpFrag<(sub node:$LHS, (AArch64smull node:$MHS, node:$RHS))>,
4316 SMLSLv8i8_v8i16, SMLSLv4i16_v4i32, SMLSLv2i32_v2i64>;
4317 defm : Neon_mulacc_widen_patterns<
4318 TriOpFrag<(sub node:$LHS, (AArch64umull node:$MHS, node:$RHS))>,
4319 UMLSLv8i8_v8i16, UMLSLv4i16_v4i32, UMLSLv2i32_v2i64>;
4321 // Patterns for 64-bit pmull
4322 def : Pat<(int_aarch64_neon_pmull64 V64:$Rn, V64:$Rm),
4323 (PMULLv1i64 V64:$Rn, V64:$Rm)>;
4324 def : Pat<(int_aarch64_neon_pmull64 (extractelt (v2i64 V128:$Rn), (i64 1)),
4325 (extractelt (v2i64 V128:$Rm), (i64 1))),
4326 (PMULLv2i64 V128:$Rn, V128:$Rm)>;
4328 // CodeGen patterns for addhn and subhn instructions, which can actually be
4329 // written in LLVM IR without too much difficulty.
4332 def : Pat<(v8i8 (trunc (v8i16 (AArch64vlshr (add V128:$Rn, V128:$Rm), (i32 8))))),
4333 (ADDHNv8i16_v8i8 V128:$Rn, V128:$Rm)>;
4334 def : Pat<(v4i16 (trunc (v4i32 (AArch64vlshr (add V128:$Rn, V128:$Rm),
4336 (ADDHNv4i32_v4i16 V128:$Rn, V128:$Rm)>;
4337 def : Pat<(v2i32 (trunc (v2i64 (AArch64vlshr (add V128:$Rn, V128:$Rm),
4339 (ADDHNv2i64_v2i32 V128:$Rn, V128:$Rm)>;
4340 def : Pat<(concat_vectors (v8i8 V64:$Rd),
4341 (trunc (v8i16 (AArch64vlshr (add V128:$Rn, V128:$Rm),
4343 (ADDHNv8i16_v16i8 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4344 V128:$Rn, V128:$Rm)>;
4345 def : Pat<(concat_vectors (v4i16 V64:$Rd),
4346 (trunc (v4i32 (AArch64vlshr (add V128:$Rn, V128:$Rm),
4348 (ADDHNv4i32_v8i16 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4349 V128:$Rn, V128:$Rm)>;
4350 def : Pat<(concat_vectors (v2i32 V64:$Rd),
4351 (trunc (v2i64 (AArch64vlshr (add V128:$Rn, V128:$Rm),
4353 (ADDHNv2i64_v4i32 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4354 V128:$Rn, V128:$Rm)>;
4357 def : Pat<(v8i8 (trunc (v8i16 (AArch64vlshr (sub V128:$Rn, V128:$Rm), (i32 8))))),
4358 (SUBHNv8i16_v8i8 V128:$Rn, V128:$Rm)>;
4359 def : Pat<(v4i16 (trunc (v4i32 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
4361 (SUBHNv4i32_v4i16 V128:$Rn, V128:$Rm)>;
4362 def : Pat<(v2i32 (trunc (v2i64 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
4364 (SUBHNv2i64_v2i32 V128:$Rn, V128:$Rm)>;
4365 def : Pat<(concat_vectors (v8i8 V64:$Rd),
4366 (trunc (v8i16 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
4368 (SUBHNv8i16_v16i8 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4369 V128:$Rn, V128:$Rm)>;
4370 def : Pat<(concat_vectors (v4i16 V64:$Rd),
4371 (trunc (v4i32 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
4373 (SUBHNv4i32_v8i16 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4374 V128:$Rn, V128:$Rm)>;
4375 def : Pat<(concat_vectors (v2i32 V64:$Rd),
4376 (trunc (v2i64 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
4378 (SUBHNv2i64_v4i32 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4379 V128:$Rn, V128:$Rm)>;
4381 //----------------------------------------------------------------------------
4382 // AdvSIMD bitwise extract from vector instruction.
4383 //----------------------------------------------------------------------------
4385 defm EXT : SIMDBitwiseExtract<"ext">;
4387 def AdjustExtImm : SDNodeXForm<imm, [{
4388 return CurDAG->getTargetConstant(8 + N->getZExtValue(), SDLoc(N), MVT::i32);
4390 multiclass ExtPat<ValueType VT64, ValueType VT128, int N> {
4391 def : Pat<(VT64 (AArch64ext V64:$Rn, V64:$Rm, (i32 imm:$imm))),
4392 (EXTv8i8 V64:$Rn, V64:$Rm, imm:$imm)>;
4393 def : Pat<(VT128 (AArch64ext V128:$Rn, V128:$Rm, (i32 imm:$imm))),
4394 (EXTv16i8 V128:$Rn, V128:$Rm, imm:$imm)>;
4395 // We use EXT to handle extract_subvector to copy the upper 64-bits of a
4397 def : Pat<(VT64 (extract_subvector V128:$Rn, (i64 N))),
4398 (EXTRACT_SUBREG (EXTv16i8 V128:$Rn, V128:$Rn, 8), dsub)>;
4399 // A 64-bit EXT of two halves of the same 128-bit register can be done as a
4400 // single 128-bit EXT.
4401 def : Pat<(VT64 (AArch64ext (extract_subvector V128:$Rn, (i64 0)),
4402 (extract_subvector V128:$Rn, (i64 N)),
4404 (EXTRACT_SUBREG (EXTv16i8 V128:$Rn, V128:$Rn, imm:$imm), dsub)>;
4405 // A 64-bit EXT of the high half of a 128-bit register can be done using a
4406 // 128-bit EXT of the whole register with an adjustment to the immediate. The
4407 // top half of the other operand will be unset, but that doesn't matter as it
4408 // will not be used.
4409 def : Pat<(VT64 (AArch64ext (extract_subvector V128:$Rn, (i64 N)),
4412 (EXTRACT_SUBREG (EXTv16i8 V128:$Rn,
4413 (SUBREG_TO_REG (i32 0), V64:$Rm, dsub),
4414 (AdjustExtImm imm:$imm)), dsub)>;
4417 defm : ExtPat<v8i8, v16i8, 8>;
4418 defm : ExtPat<v4i16, v8i16, 4>;
4419 defm : ExtPat<v4f16, v8f16, 4>;
4420 defm : ExtPat<v2i32, v4i32, 2>;
4421 defm : ExtPat<v2f32, v4f32, 2>;
4422 defm : ExtPat<v1i64, v2i64, 1>;
4423 defm : ExtPat<v1f64, v2f64, 1>;
4425 //----------------------------------------------------------------------------
4426 // AdvSIMD zip vector
4427 //----------------------------------------------------------------------------
4429 defm TRN1 : SIMDZipVector<0b010, "trn1", AArch64trn1>;
4430 defm TRN2 : SIMDZipVector<0b110, "trn2", AArch64trn2>;
4431 defm UZP1 : SIMDZipVector<0b001, "uzp1", AArch64uzp1>;
4432 defm UZP2 : SIMDZipVector<0b101, "uzp2", AArch64uzp2>;
4433 defm ZIP1 : SIMDZipVector<0b011, "zip1", AArch64zip1>;
4434 defm ZIP2 : SIMDZipVector<0b111, "zip2", AArch64zip2>;
4436 //----------------------------------------------------------------------------
4437 // AdvSIMD TBL/TBX instructions
4438 //----------------------------------------------------------------------------
4440 defm TBL : SIMDTableLookup< 0, "tbl">;
4441 defm TBX : SIMDTableLookupTied<1, "tbx">;
4443 def : Pat<(v8i8 (int_aarch64_neon_tbl1 (v16i8 VecListOne128:$Rn), (v8i8 V64:$Ri))),
4444 (TBLv8i8One VecListOne128:$Rn, V64:$Ri)>;
4445 def : Pat<(v16i8 (int_aarch64_neon_tbl1 (v16i8 V128:$Ri), (v16i8 V128:$Rn))),
4446 (TBLv16i8One V128:$Ri, V128:$Rn)>;
4448 def : Pat<(v8i8 (int_aarch64_neon_tbx1 (v8i8 V64:$Rd),
4449 (v16i8 VecListOne128:$Rn), (v8i8 V64:$Ri))),
4450 (TBXv8i8One V64:$Rd, VecListOne128:$Rn, V64:$Ri)>;
4451 def : Pat<(v16i8 (int_aarch64_neon_tbx1 (v16i8 V128:$Rd),
4452 (v16i8 V128:$Ri), (v16i8 V128:$Rn))),
4453 (TBXv16i8One V128:$Rd, V128:$Ri, V128:$Rn)>;
4456 //----------------------------------------------------------------------------
4457 // AdvSIMD scalar CPY instruction
4458 //----------------------------------------------------------------------------
4460 defm CPY : SIMDScalarCPY<"cpy">;
4462 //----------------------------------------------------------------------------
4463 // AdvSIMD scalar pairwise instructions
4464 //----------------------------------------------------------------------------
4466 defm ADDP : SIMDPairwiseScalarD<0, 0b11011, "addp">;
4467 defm FADDP : SIMDFPPairwiseScalar<0, 0b01101, "faddp">;
4468 defm FMAXNMP : SIMDFPPairwiseScalar<0, 0b01100, "fmaxnmp">;
4469 defm FMAXP : SIMDFPPairwiseScalar<0, 0b01111, "fmaxp">;
4470 defm FMINNMP : SIMDFPPairwiseScalar<1, 0b01100, "fminnmp">;
4471 defm FMINP : SIMDFPPairwiseScalar<1, 0b01111, "fminp">;
4472 def : Pat<(v2i64 (AArch64saddv V128:$Rn)),
4473 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)), (ADDPv2i64p V128:$Rn), dsub)>;
4474 def : Pat<(v2i64 (AArch64uaddv V128:$Rn)),
4475 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)), (ADDPv2i64p V128:$Rn), dsub)>;
4476 def : Pat<(f32 (int_aarch64_neon_faddv (v2f32 V64:$Rn))),
4477 (FADDPv2i32p V64:$Rn)>;
4478 def : Pat<(f32 (int_aarch64_neon_faddv (v4f32 V128:$Rn))),
4479 (FADDPv2i32p (EXTRACT_SUBREG (FADDPv4f32 V128:$Rn, V128:$Rn), dsub))>;
4480 def : Pat<(f64 (int_aarch64_neon_faddv (v2f64 V128:$Rn))),
4481 (FADDPv2i64p V128:$Rn)>;
4482 def : Pat<(f32 (int_aarch64_neon_fmaxnmv (v2f32 V64:$Rn))),
4483 (FMAXNMPv2i32p V64:$Rn)>;
4484 def : Pat<(f64 (int_aarch64_neon_fmaxnmv (v2f64 V128:$Rn))),
4485 (FMAXNMPv2i64p V128:$Rn)>;
4486 def : Pat<(f32 (int_aarch64_neon_fmaxv (v2f32 V64:$Rn))),
4487 (FMAXPv2i32p V64:$Rn)>;
4488 def : Pat<(f64 (int_aarch64_neon_fmaxv (v2f64 V128:$Rn))),
4489 (FMAXPv2i64p V128:$Rn)>;
4490 def : Pat<(f32 (int_aarch64_neon_fminnmv (v2f32 V64:$Rn))),
4491 (FMINNMPv2i32p V64:$Rn)>;
4492 def : Pat<(f64 (int_aarch64_neon_fminnmv (v2f64 V128:$Rn))),
4493 (FMINNMPv2i64p V128:$Rn)>;
4494 def : Pat<(f32 (int_aarch64_neon_fminv (v2f32 V64:$Rn))),
4495 (FMINPv2i32p V64:$Rn)>;
4496 def : Pat<(f64 (int_aarch64_neon_fminv (v2f64 V128:$Rn))),
4497 (FMINPv2i64p V128:$Rn)>;
4499 //----------------------------------------------------------------------------
4500 // AdvSIMD INS/DUP instructions
4501 //----------------------------------------------------------------------------
4503 def DUPv8i8gpr : SIMDDupFromMain<0, {?,?,?,?,1}, ".8b", v8i8, V64, GPR32>;
4504 def DUPv16i8gpr : SIMDDupFromMain<1, {?,?,?,?,1}, ".16b", v16i8, V128, GPR32>;
4505 def DUPv4i16gpr : SIMDDupFromMain<0, {?,?,?,1,0}, ".4h", v4i16, V64, GPR32>;
4506 def DUPv8i16gpr : SIMDDupFromMain<1, {?,?,?,1,0}, ".8h", v8i16, V128, GPR32>;
4507 def DUPv2i32gpr : SIMDDupFromMain<0, {?,?,1,0,0}, ".2s", v2i32, V64, GPR32>;
4508 def DUPv4i32gpr : SIMDDupFromMain<1, {?,?,1,0,0}, ".4s", v4i32, V128, GPR32>;
4509 def DUPv2i64gpr : SIMDDupFromMain<1, {?,1,0,0,0}, ".2d", v2i64, V128, GPR64>;
4511 def DUPv2i64lane : SIMDDup64FromElement;
4512 def DUPv2i32lane : SIMDDup32FromElement<0, ".2s", v2i32, V64>;
4513 def DUPv4i32lane : SIMDDup32FromElement<1, ".4s", v4i32, V128>;
4514 def DUPv4i16lane : SIMDDup16FromElement<0, ".4h", v4i16, V64>;
4515 def DUPv8i16lane : SIMDDup16FromElement<1, ".8h", v8i16, V128>;
4516 def DUPv8i8lane : SIMDDup8FromElement <0, ".8b", v8i8, V64>;
4517 def DUPv16i8lane : SIMDDup8FromElement <1, ".16b", v16i8, V128>;
4519 // DUP from a 64-bit register to a 64-bit register is just a copy
4520 def : Pat<(v1i64 (AArch64dup (i64 GPR64:$Rn))),
4521 (COPY_TO_REGCLASS GPR64:$Rn, FPR64)>;
4522 def : Pat<(v1f64 (AArch64dup (f64 FPR64:$Rn))),
4523 (COPY_TO_REGCLASS FPR64:$Rn, FPR64)>;
4525 def : Pat<(v2f32 (AArch64dup (f32 FPR32:$Rn))),
4526 (v2f32 (DUPv2i32lane
4527 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR32:$Rn, ssub),
4529 def : Pat<(v4f32 (AArch64dup (f32 FPR32:$Rn))),
4530 (v4f32 (DUPv4i32lane
4531 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR32:$Rn, ssub),
4533 def : Pat<(v2f64 (AArch64dup (f64 FPR64:$Rn))),
4534 (v2f64 (DUPv2i64lane
4535 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR64:$Rn, dsub),
4537 def : Pat<(v4f16 (AArch64dup (f16 FPR16:$Rn))),
4538 (v4f16 (DUPv4i16lane
4539 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)), FPR16:$Rn, hsub),
4541 def : Pat<(v8f16 (AArch64dup (f16 FPR16:$Rn))),
4542 (v8f16 (DUPv8i16lane
4543 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)), FPR16:$Rn, hsub),
4546 def : Pat<(v4f16 (AArch64duplane16 (v8f16 V128:$Rn), VectorIndexH:$imm)),
4547 (DUPv4i16lane V128:$Rn, VectorIndexH:$imm)>;
4548 def : Pat<(v8f16 (AArch64duplane16 (v8f16 V128:$Rn), VectorIndexH:$imm)),
4549 (DUPv8i16lane V128:$Rn, VectorIndexH:$imm)>;
4551 def : Pat<(v2f32 (AArch64duplane32 (v4f32 V128:$Rn), VectorIndexS:$imm)),
4552 (DUPv2i32lane V128:$Rn, VectorIndexS:$imm)>;
4553 def : Pat<(v4f32 (AArch64duplane32 (v4f32 V128:$Rn), VectorIndexS:$imm)),
4554 (DUPv4i32lane V128:$Rn, VectorIndexS:$imm)>;
4555 def : Pat<(v2f64 (AArch64duplane64 (v2f64 V128:$Rn), VectorIndexD:$imm)),
4556 (DUPv2i64lane V128:$Rn, VectorIndexD:$imm)>;
4558 // If there's an (AArch64dup (vector_extract ...) ...), we can use a duplane
4559 // instruction even if the types don't match: we just have to remap the lane
4560 // carefully. N.b. this trick only applies to truncations.
4561 def VecIndex_x2 : SDNodeXForm<imm, [{
4562 return CurDAG->getTargetConstant(2 * N->getZExtValue(), SDLoc(N), MVT::i64);
4564 def VecIndex_x4 : SDNodeXForm<imm, [{
4565 return CurDAG->getTargetConstant(4 * N->getZExtValue(), SDLoc(N), MVT::i64);
4567 def VecIndex_x8 : SDNodeXForm<imm, [{
4568 return CurDAG->getTargetConstant(8 * N->getZExtValue(), SDLoc(N), MVT::i64);
4571 multiclass DUPWithTruncPats<ValueType ResVT, ValueType Src64VT,
4572 ValueType Src128VT, ValueType ScalVT,
4573 Instruction DUP, SDNodeXForm IdxXFORM> {
4574 def : Pat<(ResVT (AArch64dup (ScalVT (vector_extract (Src128VT V128:$Rn),
4576 (DUP V128:$Rn, (IdxXFORM imm:$idx))>;
4578 def : Pat<(ResVT (AArch64dup (ScalVT (vector_extract (Src64VT V64:$Rn),
4580 (DUP (SUBREG_TO_REG (i64 0), V64:$Rn, dsub), (IdxXFORM imm:$idx))>;
4583 defm : DUPWithTruncPats<v8i8, v4i16, v8i16, i32, DUPv8i8lane, VecIndex_x2>;
4584 defm : DUPWithTruncPats<v8i8, v2i32, v4i32, i32, DUPv8i8lane, VecIndex_x4>;
4585 defm : DUPWithTruncPats<v4i16, v2i32, v4i32, i32, DUPv4i16lane, VecIndex_x2>;
4587 defm : DUPWithTruncPats<v16i8, v4i16, v8i16, i32, DUPv16i8lane, VecIndex_x2>;
4588 defm : DUPWithTruncPats<v16i8, v2i32, v4i32, i32, DUPv16i8lane, VecIndex_x4>;
4589 defm : DUPWithTruncPats<v8i16, v2i32, v4i32, i32, DUPv8i16lane, VecIndex_x2>;
4591 multiclass DUPWithTrunci64Pats<ValueType ResVT, Instruction DUP,
4592 SDNodeXForm IdxXFORM> {
4593 def : Pat<(ResVT (AArch64dup (i32 (trunc (extractelt (v2i64 V128:$Rn),
4595 (DUP V128:$Rn, (IdxXFORM imm:$idx))>;
4597 def : Pat<(ResVT (AArch64dup (i32 (trunc (extractelt (v1i64 V64:$Rn),
4599 (DUP (SUBREG_TO_REG (i64 0), V64:$Rn, dsub), (IdxXFORM imm:$idx))>;
4602 defm : DUPWithTrunci64Pats<v8i8, DUPv8i8lane, VecIndex_x8>;
4603 defm : DUPWithTrunci64Pats<v4i16, DUPv4i16lane, VecIndex_x4>;
4604 defm : DUPWithTrunci64Pats<v2i32, DUPv2i32lane, VecIndex_x2>;
4606 defm : DUPWithTrunci64Pats<v16i8, DUPv16i8lane, VecIndex_x8>;
4607 defm : DUPWithTrunci64Pats<v8i16, DUPv8i16lane, VecIndex_x4>;
4608 defm : DUPWithTrunci64Pats<v4i32, DUPv4i32lane, VecIndex_x2>;
4610 // SMOV and UMOV definitions, with some extra patterns for convenience
4614 def : Pat<(sext_inreg (vector_extract (v16i8 V128:$Rn), VectorIndexB:$idx), i8),
4615 (i32 (SMOVvi8to32 V128:$Rn, VectorIndexB:$idx))>;
4616 def : Pat<(sext_inreg (vector_extract (v16i8 V128:$Rn), VectorIndexB:$idx), i8),
4617 (i64 (SMOVvi8to64 V128:$Rn, VectorIndexB:$idx))>;
4618 def : Pat<(sext_inreg (vector_extract (v8i16 V128:$Rn), VectorIndexH:$idx),i16),
4619 (i32 (SMOVvi16to32 V128:$Rn, VectorIndexH:$idx))>;
4620 def : Pat<(sext_inreg (vector_extract (v8i16 V128:$Rn), VectorIndexH:$idx),i16),
4621 (i64 (SMOVvi16to64 V128:$Rn, VectorIndexH:$idx))>;
4622 def : Pat<(sext_inreg (vector_extract (v8i16 V128:$Rn), VectorIndexH:$idx),i16),
4623 (i32 (SMOVvi16to32 V128:$Rn, VectorIndexH:$idx))>;
4624 def : Pat<(sext (i32 (vector_extract (v4i32 V128:$Rn), VectorIndexS:$idx))),
4625 (i64 (SMOVvi32to64 V128:$Rn, VectorIndexS:$idx))>;
4627 def : Pat<(sext_inreg (i64 (anyext (i32 (vector_extract (v16i8 V128:$Rn),
4628 VectorIndexB:$idx)))), i8),
4629 (i64 (SMOVvi8to64 V128:$Rn, VectorIndexB:$idx))>;
4630 def : Pat<(sext_inreg (i64 (anyext (i32 (vector_extract (v8i16 V128:$Rn),
4631 VectorIndexH:$idx)))), i16),
4632 (i64 (SMOVvi16to64 V128:$Rn, VectorIndexH:$idx))>;
4634 // Extracting i8 or i16 elements will have the zero-extend transformed to
4635 // an 'and' mask by type legalization since neither i8 nor i16 are legal types
4636 // for AArch64. Match these patterns here since UMOV already zeroes out the high
4637 // bits of the destination register.
4638 def : Pat<(and (vector_extract (v16i8 V128:$Rn), VectorIndexB:$idx),
4640 (i32 (UMOVvi8 V128:$Rn, VectorIndexB:$idx))>;
4641 def : Pat<(and (vector_extract (v8i16 V128:$Rn), VectorIndexH:$idx),
4643 (i32 (UMOVvi16 V128:$Rn, VectorIndexH:$idx))>;
4647 def : Pat<(v16i8 (scalar_to_vector GPR32:$Rn)),
4648 (SUBREG_TO_REG (i32 0),
4649 (f32 (COPY_TO_REGCLASS GPR32:$Rn, FPR32)), ssub)>;
4650 def : Pat<(v8i8 (scalar_to_vector GPR32:$Rn)),
4651 (SUBREG_TO_REG (i32 0),
4652 (f32 (COPY_TO_REGCLASS GPR32:$Rn, FPR32)), ssub)>;
4654 def : Pat<(v8i16 (scalar_to_vector GPR32:$Rn)),
4655 (SUBREG_TO_REG (i32 0),
4656 (f32 (COPY_TO_REGCLASS GPR32:$Rn, FPR32)), ssub)>;
4657 def : Pat<(v4i16 (scalar_to_vector GPR32:$Rn)),
4658 (SUBREG_TO_REG (i32 0),
4659 (f32 (COPY_TO_REGCLASS GPR32:$Rn, FPR32)), ssub)>;
4661 def : Pat<(v4f16 (scalar_to_vector (f16 FPR16:$Rn))),
4662 (INSERT_SUBREG (v4f16 (IMPLICIT_DEF)), FPR16:$Rn, hsub)>;
4663 def : Pat<(v8f16 (scalar_to_vector (f16 FPR16:$Rn))),
4664 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR16:$Rn, hsub)>;
4666 def : Pat<(v2i32 (scalar_to_vector (i32 FPR32:$Rn))),
4667 (v2i32 (INSERT_SUBREG (v2i32 (IMPLICIT_DEF)),
4668 (i32 FPR32:$Rn), ssub))>;
4669 def : Pat<(v4i32 (scalar_to_vector (i32 FPR32:$Rn))),
4670 (v4i32 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)),
4671 (i32 FPR32:$Rn), ssub))>;
4673 def : Pat<(v2i64 (scalar_to_vector (i64 FPR64:$Rn))),
4674 (v2i64 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)),
4675 (i64 FPR64:$Rn), dsub))>;
4677 def : Pat<(v4f16 (scalar_to_vector (f16 FPR16:$Rn))),
4678 (INSERT_SUBREG (v4f16 (IMPLICIT_DEF)), FPR16:$Rn, hsub)>;
4679 def : Pat<(v8f16 (scalar_to_vector (f16 FPR16:$Rn))),
4680 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR16:$Rn, hsub)>;
4682 def : Pat<(v4f32 (scalar_to_vector (f32 FPR32:$Rn))),
4683 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FPR32:$Rn, ssub)>;
4684 def : Pat<(v2f32 (scalar_to_vector (f32 FPR32:$Rn))),
4685 (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), FPR32:$Rn, ssub)>;
4687 def : Pat<(v2f64 (scalar_to_vector (f64 FPR64:$Rn))),
4688 (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), FPR64:$Rn, dsub)>;
4690 def : Pat<(v4f16 (vector_insert (v4f16 V64:$Rn),
4691 (f16 FPR16:$Rm), (i64 VectorIndexS:$imm))),
4694 (v8f16 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), V64:$Rn, dsub)),
4696 (v8f16 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR16:$Rm, hsub)),
4700 def : Pat<(v8f16 (vector_insert (v8f16 V128:$Rn),
4701 (f16 FPR16:$Rm), (i64 VectorIndexH:$imm))),
4703 V128:$Rn, VectorIndexH:$imm,
4704 (v8f16 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR16:$Rm, hsub)),
4707 def : Pat<(v2f32 (vector_insert (v2f32 V64:$Rn),
4708 (f32 FPR32:$Rm), (i64 VectorIndexS:$imm))),
4711 (v4f32 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), V64:$Rn, dsub)),
4713 (v4f32 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FPR32:$Rm, ssub)),
4716 def : Pat<(v4f32 (vector_insert (v4f32 V128:$Rn),
4717 (f32 FPR32:$Rm), (i64 VectorIndexS:$imm))),
4719 V128:$Rn, VectorIndexS:$imm,
4720 (v4f32 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FPR32:$Rm, ssub)),
4722 def : Pat<(v2f64 (vector_insert (v2f64 V128:$Rn),
4723 (f64 FPR64:$Rm), (i64 VectorIndexD:$imm))),
4725 V128:$Rn, VectorIndexD:$imm,
4726 (v2f64 (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), FPR64:$Rm, dsub)),
4729 // Copy an element at a constant index in one vector into a constant indexed
4730 // element of another.
4731 // FIXME refactor to a shared class/dev parameterized on vector type, vector
4732 // index type and INS extension
4733 def : Pat<(v16i8 (int_aarch64_neon_vcopy_lane
4734 (v16i8 V128:$Vd), VectorIndexB:$idx, (v16i8 V128:$Vs),
4735 VectorIndexB:$idx2)),
4737 V128:$Vd, VectorIndexB:$idx, V128:$Vs, VectorIndexB:$idx2)
4739 def : Pat<(v8i16 (int_aarch64_neon_vcopy_lane
4740 (v8i16 V128:$Vd), VectorIndexH:$idx, (v8i16 V128:$Vs),
4741 VectorIndexH:$idx2)),
4743 V128:$Vd, VectorIndexH:$idx, V128:$Vs, VectorIndexH:$idx2)
4745 def : Pat<(v4i32 (int_aarch64_neon_vcopy_lane
4746 (v4i32 V128:$Vd), VectorIndexS:$idx, (v4i32 V128:$Vs),
4747 VectorIndexS:$idx2)),
4749 V128:$Vd, VectorIndexS:$idx, V128:$Vs, VectorIndexS:$idx2)
4751 def : Pat<(v2i64 (int_aarch64_neon_vcopy_lane
4752 (v2i64 V128:$Vd), VectorIndexD:$idx, (v2i64 V128:$Vs),
4753 VectorIndexD:$idx2)),
4755 V128:$Vd, VectorIndexD:$idx, V128:$Vs, VectorIndexD:$idx2)
4758 multiclass Neon_INS_elt_pattern<ValueType VT128, ValueType VT64,
4759 ValueType VTScal, Instruction INS> {
4760 def : Pat<(VT128 (vector_insert V128:$src,
4761 (VTScal (vector_extract (VT128 V128:$Rn), imm:$Immn)),
4763 (INS V128:$src, imm:$Immd, V128:$Rn, imm:$Immn)>;
4765 def : Pat<(VT128 (vector_insert V128:$src,
4766 (VTScal (vector_extract (VT64 V64:$Rn), imm:$Immn)),
4768 (INS V128:$src, imm:$Immd,
4769 (SUBREG_TO_REG (i64 0), V64:$Rn, dsub), imm:$Immn)>;
4771 def : Pat<(VT64 (vector_insert V64:$src,
4772 (VTScal (vector_extract (VT128 V128:$Rn), imm:$Immn)),
4774 (EXTRACT_SUBREG (INS (SUBREG_TO_REG (i64 0), V64:$src, dsub),
4775 imm:$Immd, V128:$Rn, imm:$Immn),
4778 def : Pat<(VT64 (vector_insert V64:$src,
4779 (VTScal (vector_extract (VT64 V64:$Rn), imm:$Immn)),
4782 (INS (SUBREG_TO_REG (i64 0), V64:$src, dsub), imm:$Immd,
4783 (SUBREG_TO_REG (i64 0), V64:$Rn, dsub), imm:$Immn),
4787 defm : Neon_INS_elt_pattern<v8f16, v4f16, f16, INSvi16lane>;
4788 defm : Neon_INS_elt_pattern<v4f32, v2f32, f32, INSvi32lane>;
4789 defm : Neon_INS_elt_pattern<v2f64, v1f64, f64, INSvi64lane>;
4792 // Floating point vector extractions are codegen'd as either a sequence of
4793 // subregister extractions, or a MOV (aka CPY here, alias for DUP) if
4794 // the lane number is anything other than zero.
4795 def : Pat<(vector_extract (v2f64 V128:$Rn), 0),
4796 (f64 (EXTRACT_SUBREG V128:$Rn, dsub))>;
4797 def : Pat<(vector_extract (v4f32 V128:$Rn), 0),
4798 (f32 (EXTRACT_SUBREG V128:$Rn, ssub))>;
4799 def : Pat<(vector_extract (v8f16 V128:$Rn), 0),
4800 (f16 (EXTRACT_SUBREG V128:$Rn, hsub))>;
4802 def : Pat<(vector_extract (v2f64 V128:$Rn), VectorIndexD:$idx),
4803 (f64 (CPYi64 V128:$Rn, VectorIndexD:$idx))>;
4804 def : Pat<(vector_extract (v4f32 V128:$Rn), VectorIndexS:$idx),
4805 (f32 (CPYi32 V128:$Rn, VectorIndexS:$idx))>;
4806 def : Pat<(vector_extract (v8f16 V128:$Rn), VectorIndexH:$idx),
4807 (f16 (CPYi16 V128:$Rn, VectorIndexH:$idx))>;
4809 // All concat_vectors operations are canonicalised to act on i64 vectors for
4810 // AArch64. In the general case we need an instruction, which had just as well be
4812 class ConcatPat<ValueType DstTy, ValueType SrcTy>
4813 : Pat<(DstTy (concat_vectors (SrcTy V64:$Rd), V64:$Rn)),
4814 (INSvi64lane (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), 1,
4815 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rn, dsub), 0)>;
4817 def : ConcatPat<v2i64, v1i64>;
4818 def : ConcatPat<v2f64, v1f64>;
4819 def : ConcatPat<v4i32, v2i32>;
4820 def : ConcatPat<v4f32, v2f32>;
4821 def : ConcatPat<v8i16, v4i16>;
4822 def : ConcatPat<v8f16, v4f16>;
4823 def : ConcatPat<v16i8, v8i8>;
4825 // If the high lanes are undef, though, we can just ignore them:
4826 class ConcatUndefPat<ValueType DstTy, ValueType SrcTy>
4827 : Pat<(DstTy (concat_vectors (SrcTy V64:$Rn), undef)),
4828 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rn, dsub)>;
4830 def : ConcatUndefPat<v2i64, v1i64>;
4831 def : ConcatUndefPat<v2f64, v1f64>;
4832 def : ConcatUndefPat<v4i32, v2i32>;
4833 def : ConcatUndefPat<v4f32, v2f32>;
4834 def : ConcatUndefPat<v8i16, v4i16>;
4835 def : ConcatUndefPat<v16i8, v8i8>;
4837 //----------------------------------------------------------------------------
4838 // AdvSIMD across lanes instructions
4839 //----------------------------------------------------------------------------
4841 defm ADDV : SIMDAcrossLanesBHS<0, 0b11011, "addv">;
4842 defm SMAXV : SIMDAcrossLanesBHS<0, 0b01010, "smaxv">;
4843 defm SMINV : SIMDAcrossLanesBHS<0, 0b11010, "sminv">;
4844 defm UMAXV : SIMDAcrossLanesBHS<1, 0b01010, "umaxv">;
4845 defm UMINV : SIMDAcrossLanesBHS<1, 0b11010, "uminv">;
4846 defm SADDLV : SIMDAcrossLanesHSD<0, 0b00011, "saddlv">;
4847 defm UADDLV : SIMDAcrossLanesHSD<1, 0b00011, "uaddlv">;
4848 defm FMAXNMV : SIMDFPAcrossLanes<0b01100, 0, "fmaxnmv", int_aarch64_neon_fmaxnmv>;
4849 defm FMAXV : SIMDFPAcrossLanes<0b01111, 0, "fmaxv", int_aarch64_neon_fmaxv>;
4850 defm FMINNMV : SIMDFPAcrossLanes<0b01100, 1, "fminnmv", int_aarch64_neon_fminnmv>;
4851 defm FMINV : SIMDFPAcrossLanes<0b01111, 1, "fminv", int_aarch64_neon_fminv>;
4853 // Patterns for across-vector intrinsics, that have a node equivalent, that
4854 // returns a vector (with only the low lane defined) instead of a scalar.
4855 // In effect, opNode is the same as (scalar_to_vector (IntNode)).
4856 multiclass SIMDAcrossLanesIntrinsic<string baseOpc,
4857 SDPatternOperator opNode> {
4858 // If a lane instruction caught the vector_extract around opNode, we can
4859 // directly match the latter to the instruction.
4860 def : Pat<(v8i8 (opNode V64:$Rn)),
4861 (INSERT_SUBREG (v8i8 (IMPLICIT_DEF)),
4862 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), bsub)>;
4863 def : Pat<(v16i8 (opNode V128:$Rn)),
4864 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4865 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), bsub)>;
4866 def : Pat<(v4i16 (opNode V64:$Rn)),
4867 (INSERT_SUBREG (v4i16 (IMPLICIT_DEF)),
4868 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), hsub)>;
4869 def : Pat<(v8i16 (opNode V128:$Rn)),
4870 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)),
4871 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), hsub)>;
4872 def : Pat<(v4i32 (opNode V128:$Rn)),
4873 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)),
4874 (!cast<Instruction>(!strconcat(baseOpc, "v4i32v")) V128:$Rn), ssub)>;
4877 // If none did, fallback to the explicit patterns, consuming the vector_extract.
4878 def : Pat<(i32 (vector_extract (insert_subvector undef, (v8i8 (opNode V64:$Rn)),
4879 (i32 0)), (i64 0))),
4880 (EXTRACT_SUBREG (INSERT_SUBREG (v8i8 (IMPLICIT_DEF)),
4881 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn),
4883 def : Pat<(i32 (vector_extract (v16i8 (opNode V128:$Rn)), (i64 0))),
4884 (EXTRACT_SUBREG (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4885 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn),
4887 def : Pat<(i32 (vector_extract (insert_subvector undef,
4888 (v4i16 (opNode V64:$Rn)), (i32 0)), (i64 0))),
4889 (EXTRACT_SUBREG (INSERT_SUBREG (v4i16 (IMPLICIT_DEF)),
4890 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn),
4892 def : Pat<(i32 (vector_extract (v8i16 (opNode V128:$Rn)), (i64 0))),
4893 (EXTRACT_SUBREG (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)),
4894 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn),
4896 def : Pat<(i32 (vector_extract (v4i32 (opNode V128:$Rn)), (i64 0))),
4897 (EXTRACT_SUBREG (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)),
4898 (!cast<Instruction>(!strconcat(baseOpc, "v4i32v")) V128:$Rn),
4903 multiclass SIMDAcrossLanesSignedIntrinsic<string baseOpc,
4904 SDPatternOperator opNode>
4905 : SIMDAcrossLanesIntrinsic<baseOpc, opNode> {
4906 // If there is a sign extension after this intrinsic, consume it as smov already
4908 def : Pat<(i32 (sext_inreg (i32 (vector_extract (insert_subvector undef,
4909 (opNode (v8i8 V64:$Rn)), (i32 0)), (i64 0))), i8)),
4911 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4912 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), bsub),
4914 def : Pat<(i32 (sext_inreg (i32 (vector_extract
4915 (opNode (v16i8 V128:$Rn)), (i64 0))), i8)),
4917 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4918 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), bsub),
4920 def : Pat<(i32 (sext_inreg (i32 (vector_extract (insert_subvector undef,
4921 (opNode (v4i16 V64:$Rn)), (i32 0)), (i64 0))), i16)),
4923 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4924 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), hsub),
4926 def : Pat<(i32 (sext_inreg (i32 (vector_extract
4927 (opNode (v8i16 V128:$Rn)), (i64 0))), i16)),
4929 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4930 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), hsub),
4934 multiclass SIMDAcrossLanesUnsignedIntrinsic<string baseOpc,
4935 SDPatternOperator opNode>
4936 : SIMDAcrossLanesIntrinsic<baseOpc, opNode> {
4937 // If there is a masking operation keeping only what has been actually
4938 // generated, consume it.
4939 def : Pat<(i32 (and (i32 (vector_extract (insert_subvector undef,
4940 (opNode (v8i8 V64:$Rn)), (i32 0)), (i64 0))), maski8_or_more)),
4941 (i32 (EXTRACT_SUBREG
4942 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4943 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), bsub),
4945 def : Pat<(i32 (and (i32 (vector_extract (opNode (v16i8 V128:$Rn)), (i64 0))),
4947 (i32 (EXTRACT_SUBREG
4948 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4949 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), bsub),
4951 def : Pat<(i32 (and (i32 (vector_extract (insert_subvector undef,
4952 (opNode (v4i16 V64:$Rn)), (i32 0)), (i64 0))), maski16_or_more)),
4953 (i32 (EXTRACT_SUBREG
4954 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4955 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), hsub),
4957 def : Pat<(i32 (and (i32 (vector_extract (opNode (v8i16 V128:$Rn)), (i64 0))),
4959 (i32 (EXTRACT_SUBREG
4960 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4961 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), hsub),
4965 defm : SIMDAcrossLanesSignedIntrinsic<"ADDV", AArch64saddv>;
4966 // vaddv_[su]32 is special; -> ADDP Vd.2S,Vn.2S,Vm.2S; return Vd.s[0];Vn==Vm
4967 def : Pat<(v2i32 (AArch64saddv (v2i32 V64:$Rn))),
4968 (ADDPv2i32 V64:$Rn, V64:$Rn)>;
4970 defm : SIMDAcrossLanesUnsignedIntrinsic<"ADDV", AArch64uaddv>;
4971 // vaddv_[su]32 is special; -> ADDP Vd.2S,Vn.2S,Vm.2S; return Vd.s[0];Vn==Vm
4972 def : Pat<(v2i32 (AArch64uaddv (v2i32 V64:$Rn))),
4973 (ADDPv2i32 V64:$Rn, V64:$Rn)>;
4975 defm : SIMDAcrossLanesSignedIntrinsic<"SMAXV", AArch64smaxv>;
4976 def : Pat<(v2i32 (AArch64smaxv (v2i32 V64:$Rn))),
4977 (SMAXPv2i32 V64:$Rn, V64:$Rn)>;
4979 defm : SIMDAcrossLanesSignedIntrinsic<"SMINV", AArch64sminv>;
4980 def : Pat<(v2i32 (AArch64sminv (v2i32 V64:$Rn))),
4981 (SMINPv2i32 V64:$Rn, V64:$Rn)>;
4983 defm : SIMDAcrossLanesUnsignedIntrinsic<"UMAXV", AArch64umaxv>;
4984 def : Pat<(v2i32 (AArch64umaxv (v2i32 V64:$Rn))),
4985 (UMAXPv2i32 V64:$Rn, V64:$Rn)>;
4987 defm : SIMDAcrossLanesUnsignedIntrinsic<"UMINV", AArch64uminv>;
4988 def : Pat<(v2i32 (AArch64uminv (v2i32 V64:$Rn))),
4989 (UMINPv2i32 V64:$Rn, V64:$Rn)>;
4991 multiclass SIMDAcrossLanesSignedLongIntrinsic<string baseOpc, Intrinsic intOp> {
4992 def : Pat<(i32 (intOp (v8i8 V64:$Rn))),
4994 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4995 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), hsub),
4997 def : Pat<(i32 (intOp (v16i8 V128:$Rn))),
4999 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5000 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), hsub),
5003 def : Pat<(i32 (intOp (v4i16 V64:$Rn))),
5004 (i32 (EXTRACT_SUBREG
5005 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5006 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), ssub),
5008 def : Pat<(i32 (intOp (v8i16 V128:$Rn))),
5009 (i32 (EXTRACT_SUBREG
5010 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5011 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), ssub),
5014 def : Pat<(i64 (intOp (v4i32 V128:$Rn))),
5015 (i64 (EXTRACT_SUBREG
5016 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5017 (!cast<Instruction>(!strconcat(baseOpc, "v4i32v")) V128:$Rn), dsub),
5021 multiclass SIMDAcrossLanesUnsignedLongIntrinsic<string baseOpc,
5023 def : Pat<(i32 (intOp (v8i8 V64:$Rn))),
5024 (i32 (EXTRACT_SUBREG
5025 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5026 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), hsub),
5028 def : Pat<(i32 (intOp (v16i8 V128:$Rn))),
5029 (i32 (EXTRACT_SUBREG
5030 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5031 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), hsub),
5034 def : Pat<(i32 (intOp (v4i16 V64:$Rn))),
5035 (i32 (EXTRACT_SUBREG
5036 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5037 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), ssub),
5039 def : Pat<(i32 (intOp (v8i16 V128:$Rn))),
5040 (i32 (EXTRACT_SUBREG
5041 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5042 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), ssub),
5045 def : Pat<(i64 (intOp (v4i32 V128:$Rn))),
5046 (i64 (EXTRACT_SUBREG
5047 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5048 (!cast<Instruction>(!strconcat(baseOpc, "v4i32v")) V128:$Rn), dsub),
5052 defm : SIMDAcrossLanesSignedLongIntrinsic<"SADDLV", int_aarch64_neon_saddlv>;
5053 defm : SIMDAcrossLanesUnsignedLongIntrinsic<"UADDLV", int_aarch64_neon_uaddlv>;
5055 // The vaddlv_s32 intrinsic gets mapped to SADDLP.
5056 def : Pat<(i64 (int_aarch64_neon_saddlv (v2i32 V64:$Rn))),
5057 (i64 (EXTRACT_SUBREG
5058 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5059 (SADDLPv2i32_v1i64 V64:$Rn), dsub),
5061 // The vaddlv_u32 intrinsic gets mapped to UADDLP.
5062 def : Pat<(i64 (int_aarch64_neon_uaddlv (v2i32 V64:$Rn))),
5063 (i64 (EXTRACT_SUBREG
5064 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5065 (UADDLPv2i32_v1i64 V64:$Rn), dsub),
5068 //------------------------------------------------------------------------------
5069 // AdvSIMD modified immediate instructions
5070 //------------------------------------------------------------------------------
5073 defm BIC : SIMDModifiedImmVectorShiftTied<1, 0b11, 0b01, "bic", AArch64bici>;
5075 defm ORR : SIMDModifiedImmVectorShiftTied<0, 0b11, 0b01, "orr", AArch64orri>;
5077 def : InstAlias<"bic $Vd.4h, $imm", (BICv4i16 V64:$Vd, imm0_255:$imm, 0)>;
5078 def : InstAlias<"bic $Vd.8h, $imm", (BICv8i16 V128:$Vd, imm0_255:$imm, 0)>;
5079 def : InstAlias<"bic $Vd.2s, $imm", (BICv2i32 V64:$Vd, imm0_255:$imm, 0)>;
5080 def : InstAlias<"bic $Vd.4s, $imm", (BICv4i32 V128:$Vd, imm0_255:$imm, 0)>;
5082 def : InstAlias<"bic.4h $Vd, $imm", (BICv4i16 V64:$Vd, imm0_255:$imm, 0)>;
5083 def : InstAlias<"bic.8h $Vd, $imm", (BICv8i16 V128:$Vd, imm0_255:$imm, 0)>;
5084 def : InstAlias<"bic.2s $Vd, $imm", (BICv2i32 V64:$Vd, imm0_255:$imm, 0)>;
5085 def : InstAlias<"bic.4s $Vd, $imm", (BICv4i32 V128:$Vd, imm0_255:$imm, 0)>;
5087 def : InstAlias<"orr $Vd.4h, $imm", (ORRv4i16 V64:$Vd, imm0_255:$imm, 0)>;
5088 def : InstAlias<"orr $Vd.8h, $imm", (ORRv8i16 V128:$Vd, imm0_255:$imm, 0)>;
5089 def : InstAlias<"orr $Vd.2s, $imm", (ORRv2i32 V64:$Vd, imm0_255:$imm, 0)>;
5090 def : InstAlias<"orr $Vd.4s, $imm", (ORRv4i32 V128:$Vd, imm0_255:$imm, 0)>;
5092 def : InstAlias<"orr.4h $Vd, $imm", (ORRv4i16 V64:$Vd, imm0_255:$imm, 0)>;
5093 def : InstAlias<"orr.8h $Vd, $imm", (ORRv8i16 V128:$Vd, imm0_255:$imm, 0)>;
5094 def : InstAlias<"orr.2s $Vd, $imm", (ORRv2i32 V64:$Vd, imm0_255:$imm, 0)>;
5095 def : InstAlias<"orr.4s $Vd, $imm", (ORRv4i32 V128:$Vd, imm0_255:$imm, 0)>;
5098 def FMOVv2f64_ns : SIMDModifiedImmVectorNoShift<1, 1, 0, 0b1111, V128, fpimm8,
5100 [(set (v2f64 V128:$Rd), (AArch64fmov imm0_255:$imm8))]>;
5101 def FMOVv2f32_ns : SIMDModifiedImmVectorNoShift<0, 0, 0, 0b1111, V64, fpimm8,
5103 [(set (v2f32 V64:$Rd), (AArch64fmov imm0_255:$imm8))]>;
5104 def FMOVv4f32_ns : SIMDModifiedImmVectorNoShift<1, 0, 0, 0b1111, V128, fpimm8,
5106 [(set (v4f32 V128:$Rd), (AArch64fmov imm0_255:$imm8))]>;
5107 let Predicates = [HasNEON, HasFullFP16] in {
5108 def FMOVv4f16_ns : SIMDModifiedImmVectorNoShift<0, 0, 1, 0b1111, V64, fpimm8,
5110 [(set (v4f16 V64:$Rd), (AArch64fmov imm0_255:$imm8))]>;
5111 def FMOVv8f16_ns : SIMDModifiedImmVectorNoShift<1, 0, 1, 0b1111, V128, fpimm8,
5113 [(set (v8f16 V128:$Rd), (AArch64fmov imm0_255:$imm8))]>;
5114 } // Predicates = [HasNEON, HasFullFP16]
5118 // EDIT byte mask: scalar
5119 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
5120 def MOVID : SIMDModifiedImmScalarNoShift<0, 1, 0b1110, "movi",
5121 [(set FPR64:$Rd, simdimmtype10:$imm8)]>;
5122 // The movi_edit node has the immediate value already encoded, so we use
5123 // a plain imm0_255 here.
5124 def : Pat<(f64 (AArch64movi_edit imm0_255:$shift)),
5125 (MOVID imm0_255:$shift)>;
5127 // EDIT byte mask: 2d
5129 // The movi_edit node has the immediate value already encoded, so we use
5130 // a plain imm0_255 in the pattern
5131 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
5132 def MOVIv2d_ns : SIMDModifiedImmVectorNoShift<1, 1, 0, 0b1110, V128,
5135 [(set (v2i64 V128:$Rd), (AArch64movi_edit imm0_255:$imm8))]>;
5137 def : Pat<(v2i64 immAllZerosV), (MOVIv2d_ns (i32 0))>;
5138 def : Pat<(v4i32 immAllZerosV), (MOVIv2d_ns (i32 0))>;
5139 def : Pat<(v8i16 immAllZerosV), (MOVIv2d_ns (i32 0))>;
5140 def : Pat<(v16i8 immAllZerosV), (MOVIv2d_ns (i32 0))>;
5142 def : Pat<(v2i64 immAllOnesV), (MOVIv2d_ns (i32 255))>;
5143 def : Pat<(v4i32 immAllOnesV), (MOVIv2d_ns (i32 255))>;
5144 def : Pat<(v8i16 immAllOnesV), (MOVIv2d_ns (i32 255))>;
5145 def : Pat<(v16i8 immAllOnesV), (MOVIv2d_ns (i32 255))>;
5147 // Set 64-bit vectors to all 0/1 by extracting from a 128-bit register as the
5148 // extract is free and this gives better MachineCSE results.
5149 def : Pat<(v1i64 immAllZerosV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 0)), dsub)>;
5150 def : Pat<(v2i32 immAllZerosV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 0)), dsub)>;
5151 def : Pat<(v4i16 immAllZerosV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 0)), dsub)>;
5152 def : Pat<(v8i8 immAllZerosV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 0)), dsub)>;
5154 def : Pat<(v1i64 immAllOnesV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 255)), dsub)>;
5155 def : Pat<(v2i32 immAllOnesV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 255)), dsub)>;
5156 def : Pat<(v4i16 immAllOnesV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 255)), dsub)>;
5157 def : Pat<(v8i8 immAllOnesV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 255)), dsub)>;
5159 // EDIT per word & halfword: 2s, 4h, 4s, & 8h
5160 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
5161 defm MOVI : SIMDModifiedImmVectorShift<0, 0b10, 0b00, "movi">;
5163 def : InstAlias<"movi $Vd.4h, $imm", (MOVIv4i16 V64:$Vd, imm0_255:$imm, 0), 0>;
5164 def : InstAlias<"movi $Vd.8h, $imm", (MOVIv8i16 V128:$Vd, imm0_255:$imm, 0), 0>;
5165 def : InstAlias<"movi $Vd.2s, $imm", (MOVIv2i32 V64:$Vd, imm0_255:$imm, 0), 0>;
5166 def : InstAlias<"movi $Vd.4s, $imm", (MOVIv4i32 V128:$Vd, imm0_255:$imm, 0), 0>;
5168 def : InstAlias<"movi.4h $Vd, $imm", (MOVIv4i16 V64:$Vd, imm0_255:$imm, 0), 0>;
5169 def : InstAlias<"movi.8h $Vd, $imm", (MOVIv8i16 V128:$Vd, imm0_255:$imm, 0), 0>;
5170 def : InstAlias<"movi.2s $Vd, $imm", (MOVIv2i32 V64:$Vd, imm0_255:$imm, 0), 0>;
5171 def : InstAlias<"movi.4s $Vd, $imm", (MOVIv4i32 V128:$Vd, imm0_255:$imm, 0), 0>;
5173 def : Pat<(v2i32 (AArch64movi_shift imm0_255:$imm8, (i32 imm:$shift))),
5174 (MOVIv2i32 imm0_255:$imm8, imm:$shift)>;
5175 def : Pat<(v4i32 (AArch64movi_shift imm0_255:$imm8, (i32 imm:$shift))),
5176 (MOVIv4i32 imm0_255:$imm8, imm:$shift)>;
5177 def : Pat<(v4i16 (AArch64movi_shift imm0_255:$imm8, (i32 imm:$shift))),
5178 (MOVIv4i16 imm0_255:$imm8, imm:$shift)>;
5179 def : Pat<(v8i16 (AArch64movi_shift imm0_255:$imm8, (i32 imm:$shift))),
5180 (MOVIv8i16 imm0_255:$imm8, imm:$shift)>;
5182 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
5183 // EDIT per word: 2s & 4s with MSL shifter
5184 def MOVIv2s_msl : SIMDModifiedImmMoveMSL<0, 0, {1,1,0,?}, V64, "movi", ".2s",
5185 [(set (v2i32 V64:$Rd),
5186 (AArch64movi_msl imm0_255:$imm8, (i32 imm:$shift)))]>;
5187 def MOVIv4s_msl : SIMDModifiedImmMoveMSL<1, 0, {1,1,0,?}, V128, "movi", ".4s",
5188 [(set (v4i32 V128:$Rd),
5189 (AArch64movi_msl imm0_255:$imm8, (i32 imm:$shift)))]>;
5191 // Per byte: 8b & 16b
5192 def MOVIv8b_ns : SIMDModifiedImmVectorNoShift<0, 0, 0, 0b1110, V64, imm0_255,
5194 [(set (v8i8 V64:$Rd), (AArch64movi imm0_255:$imm8))]>;
5196 def MOVIv16b_ns : SIMDModifiedImmVectorNoShift<1, 0, 0, 0b1110, V128, imm0_255,
5198 [(set (v16i8 V128:$Rd), (AArch64movi imm0_255:$imm8))]>;
5203 // EDIT per word & halfword: 2s, 4h, 4s, & 8h
5204 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
5205 defm MVNI : SIMDModifiedImmVectorShift<1, 0b10, 0b00, "mvni">;
5207 def : InstAlias<"mvni $Vd.4h, $imm", (MVNIv4i16 V64:$Vd, imm0_255:$imm, 0), 0>;
5208 def : InstAlias<"mvni $Vd.8h, $imm", (MVNIv8i16 V128:$Vd, imm0_255:$imm, 0), 0>;
5209 def : InstAlias<"mvni $Vd.2s, $imm", (MVNIv2i32 V64:$Vd, imm0_255:$imm, 0), 0>;
5210 def : InstAlias<"mvni $Vd.4s, $imm", (MVNIv4i32 V128:$Vd, imm0_255:$imm, 0), 0>;
5212 def : InstAlias<"mvni.4h $Vd, $imm", (MVNIv4i16 V64:$Vd, imm0_255:$imm, 0), 0>;
5213 def : InstAlias<"mvni.8h $Vd, $imm", (MVNIv8i16 V128:$Vd, imm0_255:$imm, 0), 0>;
5214 def : InstAlias<"mvni.2s $Vd, $imm", (MVNIv2i32 V64:$Vd, imm0_255:$imm, 0), 0>;
5215 def : InstAlias<"mvni.4s $Vd, $imm", (MVNIv4i32 V128:$Vd, imm0_255:$imm, 0), 0>;
5217 def : Pat<(v2i32 (AArch64mvni_shift imm0_255:$imm8, (i32 imm:$shift))),
5218 (MVNIv2i32 imm0_255:$imm8, imm:$shift)>;
5219 def : Pat<(v4i32 (AArch64mvni_shift imm0_255:$imm8, (i32 imm:$shift))),
5220 (MVNIv4i32 imm0_255:$imm8, imm:$shift)>;
5221 def : Pat<(v4i16 (AArch64mvni_shift imm0_255:$imm8, (i32 imm:$shift))),
5222 (MVNIv4i16 imm0_255:$imm8, imm:$shift)>;
5223 def : Pat<(v8i16 (AArch64mvni_shift imm0_255:$imm8, (i32 imm:$shift))),
5224 (MVNIv8i16 imm0_255:$imm8, imm:$shift)>;
5226 // EDIT per word: 2s & 4s with MSL shifter
5227 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
5228 def MVNIv2s_msl : SIMDModifiedImmMoveMSL<0, 1, {1,1,0,?}, V64, "mvni", ".2s",
5229 [(set (v2i32 V64:$Rd),
5230 (AArch64mvni_msl imm0_255:$imm8, (i32 imm:$shift)))]>;
5231 def MVNIv4s_msl : SIMDModifiedImmMoveMSL<1, 1, {1,1,0,?}, V128, "mvni", ".4s",
5232 [(set (v4i32 V128:$Rd),
5233 (AArch64mvni_msl imm0_255:$imm8, (i32 imm:$shift)))]>;
5236 //----------------------------------------------------------------------------
5237 // AdvSIMD indexed element
5238 //----------------------------------------------------------------------------
5240 let hasSideEffects = 0 in {
5241 defm FMLA : SIMDFPIndexedTied<0, 0b0001, "fmla">;
5242 defm FMLS : SIMDFPIndexedTied<0, 0b0101, "fmls">;
5245 // NOTE: Operands are reordered in the FMLA/FMLS PatFrags because the
5246 // instruction expects the addend first, while the intrinsic expects it last.
5248 // On the other hand, there are quite a few valid combinatorial options due to
5249 // the commutativity of multiplication and the fact that (-x) * y = x * (-y).
5250 defm : SIMDFPIndexedTiedPatterns<"FMLA",
5251 TriOpFrag<(fma node:$RHS, node:$MHS, node:$LHS)>>;
5252 defm : SIMDFPIndexedTiedPatterns<"FMLA",
5253 TriOpFrag<(fma node:$MHS, node:$RHS, node:$LHS)>>;
5255 defm : SIMDFPIndexedTiedPatterns<"FMLS",
5256 TriOpFrag<(fma node:$MHS, (fneg node:$RHS), node:$LHS)> >;
5257 defm : SIMDFPIndexedTiedPatterns<"FMLS",
5258 TriOpFrag<(fma node:$RHS, (fneg node:$MHS), node:$LHS)> >;
5259 defm : SIMDFPIndexedTiedPatterns<"FMLS",
5260 TriOpFrag<(fma (fneg node:$RHS), node:$MHS, node:$LHS)> >;
5261 defm : SIMDFPIndexedTiedPatterns<"FMLS",
5262 TriOpFrag<(fma (fneg node:$MHS), node:$RHS, node:$LHS)> >;
5264 multiclass FMLSIndexedAfterNegPatterns<SDPatternOperator OpNode> {
5265 // 3 variants for the .2s version: DUPLANE from 128-bit, DUPLANE from 64-bit
5267 def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn),
5268 (AArch64duplane32 (v4f32 (fneg V128:$Rm)),
5269 VectorIndexS:$idx))),
5270 (FMLSv2i32_indexed V64:$Rd, V64:$Rn, V128:$Rm, VectorIndexS:$idx)>;
5271 def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn),
5272 (v2f32 (AArch64duplane32
5273 (v4f32 (insert_subvector undef,
5274 (v2f32 (fneg V64:$Rm)),
5276 VectorIndexS:$idx)))),
5277 (FMLSv2i32_indexed V64:$Rd, V64:$Rn,
5278 (SUBREG_TO_REG (i32 0), V64:$Rm, dsub),
5279 VectorIndexS:$idx)>;
5280 def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn),
5281 (AArch64dup (f32 (fneg FPR32Op:$Rm))))),
5282 (FMLSv2i32_indexed V64:$Rd, V64:$Rn,
5283 (SUBREG_TO_REG (i32 0), FPR32Op:$Rm, ssub), (i64 0))>;
5285 // 3 variants for the .4s version: DUPLANE from 128-bit, DUPLANE from 64-bit
5287 def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn),
5288 (AArch64duplane32 (v4f32 (fneg V128:$Rm)),
5289 VectorIndexS:$idx))),
5290 (FMLSv4i32_indexed V128:$Rd, V128:$Rn, V128:$Rm,
5291 VectorIndexS:$idx)>;
5292 def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn),
5293 (v4f32 (AArch64duplane32
5294 (v4f32 (insert_subvector undef,
5295 (v2f32 (fneg V64:$Rm)),
5297 VectorIndexS:$idx)))),
5298 (FMLSv4i32_indexed V128:$Rd, V128:$Rn,
5299 (SUBREG_TO_REG (i32 0), V64:$Rm, dsub),
5300 VectorIndexS:$idx)>;
5301 def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn),
5302 (AArch64dup (f32 (fneg FPR32Op:$Rm))))),
5303 (FMLSv4i32_indexed V128:$Rd, V128:$Rn,
5304 (SUBREG_TO_REG (i32 0), FPR32Op:$Rm, ssub), (i64 0))>;
5306 // 2 variants for the .2d version: DUPLANE from 128-bit, and DUP scalar
5307 // (DUPLANE from 64-bit would be trivial).
5308 def : Pat<(v2f64 (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn),
5309 (AArch64duplane64 (v2f64 (fneg V128:$Rm)),
5310 VectorIndexD:$idx))),
5312 V128:$Rd, V128:$Rn, V128:$Rm, VectorIndexS:$idx)>;
5313 def : Pat<(v2f64 (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn),
5314 (AArch64dup (f64 (fneg FPR64Op:$Rm))))),
5315 (FMLSv2i64_indexed V128:$Rd, V128:$Rn,
5316 (SUBREG_TO_REG (i32 0), FPR64Op:$Rm, dsub), (i64 0))>;
5318 // 2 variants for 32-bit scalar version: extract from .2s or from .4s
5319 def : Pat<(f32 (OpNode (f32 FPR32:$Rd), (f32 FPR32:$Rn),
5320 (vector_extract (v4f32 (fneg V128:$Rm)),
5321 VectorIndexS:$idx))),
5322 (FMLSv1i32_indexed FPR32:$Rd, FPR32:$Rn,
5323 V128:$Rm, VectorIndexS:$idx)>;
5324 def : Pat<(f32 (OpNode (f32 FPR32:$Rd), (f32 FPR32:$Rn),
5325 (vector_extract (v4f32 (insert_subvector undef,
5326 (v2f32 (fneg V64:$Rm)),
5328 VectorIndexS:$idx))),
5329 (FMLSv1i32_indexed FPR32:$Rd, FPR32:$Rn,
5330 (SUBREG_TO_REG (i32 0), V64:$Rm, dsub), VectorIndexS:$idx)>;
5332 // 1 variant for 64-bit scalar version: extract from .1d or from .2d
5333 def : Pat<(f64 (OpNode (f64 FPR64:$Rd), (f64 FPR64:$Rn),
5334 (vector_extract (v2f64 (fneg V128:$Rm)),
5335 VectorIndexS:$idx))),
5336 (FMLSv1i64_indexed FPR64:$Rd, FPR64:$Rn,
5337 V128:$Rm, VectorIndexS:$idx)>;
5340 defm : FMLSIndexedAfterNegPatterns<
5341 TriOpFrag<(fma node:$RHS, node:$MHS, node:$LHS)> >;
5342 defm : FMLSIndexedAfterNegPatterns<
5343 TriOpFrag<(fma node:$MHS, node:$RHS, node:$LHS)> >;
5345 defm FMULX : SIMDFPIndexed<1, 0b1001, "fmulx", int_aarch64_neon_fmulx>;
5346 defm FMUL : SIMDFPIndexed<0, 0b1001, "fmul", fmul>;
5348 def : Pat<(v2f32 (fmul V64:$Rn, (AArch64dup (f32 FPR32:$Rm)))),
5349 (FMULv2i32_indexed V64:$Rn,
5350 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR32:$Rm, ssub),
5352 def : Pat<(v4f32 (fmul V128:$Rn, (AArch64dup (f32 FPR32:$Rm)))),
5353 (FMULv4i32_indexed V128:$Rn,
5354 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR32:$Rm, ssub),
5356 def : Pat<(v2f64 (fmul V128:$Rn, (AArch64dup (f64 FPR64:$Rm)))),
5357 (FMULv2i64_indexed V128:$Rn,
5358 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR64:$Rm, dsub),
5361 defm SQDMULH : SIMDIndexedHS<0, 0b1100, "sqdmulh", int_aarch64_neon_sqdmulh>;
5362 defm SQRDMULH : SIMDIndexedHS<0, 0b1101, "sqrdmulh", int_aarch64_neon_sqrdmulh>;
5363 defm MLA : SIMDVectorIndexedHSTied<1, 0b0000, "mla",
5364 TriOpFrag<(add node:$LHS, (mul node:$MHS, node:$RHS))>>;
5365 defm MLS : SIMDVectorIndexedHSTied<1, 0b0100, "mls",
5366 TriOpFrag<(sub node:$LHS, (mul node:$MHS, node:$RHS))>>;
5367 defm MUL : SIMDVectorIndexedHS<0, 0b1000, "mul", mul>;
5368 defm SMLAL : SIMDVectorIndexedLongSDTied<0, 0b0010, "smlal",
5369 TriOpFrag<(add node:$LHS, (int_aarch64_neon_smull node:$MHS, node:$RHS))>>;
5370 defm SMLSL : SIMDVectorIndexedLongSDTied<0, 0b0110, "smlsl",
5371 TriOpFrag<(sub node:$LHS, (int_aarch64_neon_smull node:$MHS, node:$RHS))>>;
5372 defm SMULL : SIMDVectorIndexedLongSD<0, 0b1010, "smull",
5373 int_aarch64_neon_smull>;
5374 defm SQDMLAL : SIMDIndexedLongSQDMLXSDTied<0, 0b0011, "sqdmlal",
5375 int_aarch64_neon_sqadd>;
5376 defm SQDMLSL : SIMDIndexedLongSQDMLXSDTied<0, 0b0111, "sqdmlsl",
5377 int_aarch64_neon_sqsub>;
5378 defm SQRDMLAH : SIMDIndexedSQRDMLxHSDTied<1, 0b1101, "sqrdmlah",
5379 int_aarch64_neon_sqadd>;
5380 defm SQRDMLSH : SIMDIndexedSQRDMLxHSDTied<1, 0b1111, "sqrdmlsh",
5381 int_aarch64_neon_sqsub>;
5382 defm SQDMULL : SIMDIndexedLongSD<0, 0b1011, "sqdmull", int_aarch64_neon_sqdmull>;
5383 defm UMLAL : SIMDVectorIndexedLongSDTied<1, 0b0010, "umlal",
5384 TriOpFrag<(add node:$LHS, (int_aarch64_neon_umull node:$MHS, node:$RHS))>>;
5385 defm UMLSL : SIMDVectorIndexedLongSDTied<1, 0b0110, "umlsl",
5386 TriOpFrag<(sub node:$LHS, (int_aarch64_neon_umull node:$MHS, node:$RHS))>>;
5387 defm UMULL : SIMDVectorIndexedLongSD<1, 0b1010, "umull",
5388 int_aarch64_neon_umull>;
5390 // A scalar sqdmull with the second operand being a vector lane can be
5391 // handled directly with the indexed instruction encoding.
5392 def : Pat<(int_aarch64_neon_sqdmulls_scalar (i32 FPR32:$Rn),
5393 (vector_extract (v4i32 V128:$Vm),
5394 VectorIndexS:$idx)),
5395 (SQDMULLv1i64_indexed FPR32:$Rn, V128:$Vm, VectorIndexS:$idx)>;
5397 //----------------------------------------------------------------------------
5398 // AdvSIMD scalar shift instructions
5399 //----------------------------------------------------------------------------
5400 defm FCVTZS : SIMDFPScalarRShift<0, 0b11111, "fcvtzs">;
5401 defm FCVTZU : SIMDFPScalarRShift<1, 0b11111, "fcvtzu">;
5402 defm SCVTF : SIMDFPScalarRShift<0, 0b11100, "scvtf">;
5403 defm UCVTF : SIMDFPScalarRShift<1, 0b11100, "ucvtf">;
5404 // Codegen patterns for the above. We don't put these directly on the
5405 // instructions because TableGen's type inference can't handle the truth.
5406 // Having the same base pattern for fp <--> int totally freaks it out.
5407 def : Pat<(int_aarch64_neon_vcvtfp2fxs FPR32:$Rn, vecshiftR32:$imm),
5408 (FCVTZSs FPR32:$Rn, vecshiftR32:$imm)>;
5409 def : Pat<(int_aarch64_neon_vcvtfp2fxu FPR32:$Rn, vecshiftR32:$imm),
5410 (FCVTZUs FPR32:$Rn, vecshiftR32:$imm)>;
5411 def : Pat<(i64 (int_aarch64_neon_vcvtfp2fxs (f64 FPR64:$Rn), vecshiftR64:$imm)),
5412 (FCVTZSd FPR64:$Rn, vecshiftR64:$imm)>;
5413 def : Pat<(i64 (int_aarch64_neon_vcvtfp2fxu (f64 FPR64:$Rn), vecshiftR64:$imm)),
5414 (FCVTZUd FPR64:$Rn, vecshiftR64:$imm)>;
5415 def : Pat<(v1i64 (int_aarch64_neon_vcvtfp2fxs (v1f64 FPR64:$Rn),
5417 (FCVTZSd FPR64:$Rn, vecshiftR64:$imm)>;
5418 def : Pat<(v1i64 (int_aarch64_neon_vcvtfp2fxu (v1f64 FPR64:$Rn),
5420 (FCVTZUd FPR64:$Rn, vecshiftR64:$imm)>;
5421 def : Pat<(int_aarch64_neon_vcvtfxu2fp FPR32:$Rn, vecshiftR32:$imm),
5422 (UCVTFs FPR32:$Rn, vecshiftR32:$imm)>;
5423 def : Pat<(f64 (int_aarch64_neon_vcvtfxu2fp (i64 FPR64:$Rn), vecshiftR64:$imm)),
5424 (UCVTFd FPR64:$Rn, vecshiftR64:$imm)>;
5425 def : Pat<(v1f64 (int_aarch64_neon_vcvtfxs2fp (v1i64 FPR64:$Rn),
5427 (SCVTFd FPR64:$Rn, vecshiftR64:$imm)>;
5428 def : Pat<(f64 (int_aarch64_neon_vcvtfxs2fp (i64 FPR64:$Rn), vecshiftR64:$imm)),
5429 (SCVTFd FPR64:$Rn, vecshiftR64:$imm)>;
5430 def : Pat<(v1f64 (int_aarch64_neon_vcvtfxu2fp (v1i64 FPR64:$Rn),
5432 (UCVTFd FPR64:$Rn, vecshiftR64:$imm)>;
5433 def : Pat<(int_aarch64_neon_vcvtfxs2fp FPR32:$Rn, vecshiftR32:$imm),
5434 (SCVTFs FPR32:$Rn, vecshiftR32:$imm)>;
5436 // Patterns for FP16 Instrinsics - requires reg copy to/from as i16s not supported.
5438 def : Pat<(f16 (int_aarch64_neon_vcvtfxs2fp (i32 (sext_inreg FPR32:$Rn, i16)), vecshiftR16:$imm)),
5439 (SCVTFh (EXTRACT_SUBREG FPR32:$Rn, hsub), vecshiftR16:$imm)>;
5440 def : Pat<(f16 (int_aarch64_neon_vcvtfxs2fp (i32 FPR32:$Rn), vecshiftR16:$imm)),
5441 (SCVTFh (EXTRACT_SUBREG FPR32:$Rn, hsub), vecshiftR16:$imm)>;
5442 def : Pat<(f16 (int_aarch64_neon_vcvtfxs2fp (i64 FPR64:$Rn), vecshiftR16:$imm)),
5443 (SCVTFh (EXTRACT_SUBREG FPR64:$Rn, hsub), vecshiftR16:$imm)>;
5444 def : Pat<(f16 (int_aarch64_neon_vcvtfxu2fp
5445 (and FPR32:$Rn, (i32 65535)),
5447 (UCVTFh (EXTRACT_SUBREG FPR32:$Rn, hsub), vecshiftR16:$imm)>;
5448 def : Pat<(f16 (int_aarch64_neon_vcvtfxu2fp FPR32:$Rn, vecshiftR16:$imm)),
5449 (UCVTFh (EXTRACT_SUBREG FPR32:$Rn, hsub), vecshiftR16:$imm)>;
5450 def : Pat<(f16 (int_aarch64_neon_vcvtfxu2fp (i64 FPR64:$Rn), vecshiftR16:$imm)),
5451 (UCVTFh (EXTRACT_SUBREG FPR64:$Rn, hsub), vecshiftR16:$imm)>;
5452 def : Pat<(i32 (int_aarch64_neon_vcvtfp2fxs (f16 FPR16:$Rn), vecshiftR32:$imm)),
5454 (i32 (IMPLICIT_DEF)),
5455 (FCVTZSh FPR16:$Rn, vecshiftR32:$imm),
5457 def : Pat<(i64 (int_aarch64_neon_vcvtfp2fxs (f16 FPR16:$Rn), vecshiftR64:$imm)),
5459 (i64 (IMPLICIT_DEF)),
5460 (FCVTZSh FPR16:$Rn, vecshiftR64:$imm),
5462 def : Pat<(i32 (int_aarch64_neon_vcvtfp2fxu (f16 FPR16:$Rn), vecshiftR32:$imm)),
5464 (i32 (IMPLICIT_DEF)),
5465 (FCVTZUh FPR16:$Rn, vecshiftR32:$imm),
5467 def : Pat<(i64 (int_aarch64_neon_vcvtfp2fxu (f16 FPR16:$Rn), vecshiftR64:$imm)),
5469 (i64 (IMPLICIT_DEF)),
5470 (FCVTZUh FPR16:$Rn, vecshiftR64:$imm),
5472 def : Pat<(i32 (int_aarch64_neon_facge (f16 FPR16:$Rn), (f16 FPR16:$Rm))),
5474 (i32 (IMPLICIT_DEF)),
5475 (FACGE16 FPR16:$Rn, FPR16:$Rm),
5477 def : Pat<(i32 (int_aarch64_neon_facgt (f16 FPR16:$Rn), (f16 FPR16:$Rm))),
5479 (i32 (IMPLICIT_DEF)),
5480 (FACGT16 FPR16:$Rn, FPR16:$Rm),
5483 defm SHL : SIMDScalarLShiftD< 0, 0b01010, "shl", AArch64vshl>;
5484 defm SLI : SIMDScalarLShiftDTied<1, 0b01010, "sli">;
5485 defm SQRSHRN : SIMDScalarRShiftBHS< 0, 0b10011, "sqrshrn",
5486 int_aarch64_neon_sqrshrn>;
5487 defm SQRSHRUN : SIMDScalarRShiftBHS< 1, 0b10001, "sqrshrun",
5488 int_aarch64_neon_sqrshrun>;
5489 defm SQSHLU : SIMDScalarLShiftBHSD<1, 0b01100, "sqshlu", AArch64sqshlui>;
5490 defm SQSHL : SIMDScalarLShiftBHSD<0, 0b01110, "sqshl", AArch64sqshli>;
5491 defm SQSHRN : SIMDScalarRShiftBHS< 0, 0b10010, "sqshrn",
5492 int_aarch64_neon_sqshrn>;
5493 defm SQSHRUN : SIMDScalarRShiftBHS< 1, 0b10000, "sqshrun",
5494 int_aarch64_neon_sqshrun>;
5495 defm SRI : SIMDScalarRShiftDTied< 1, 0b01000, "sri">;
5496 defm SRSHR : SIMDScalarRShiftD< 0, 0b00100, "srshr", AArch64srshri>;
5497 defm SRSRA : SIMDScalarRShiftDTied< 0, 0b00110, "srsra",
5498 TriOpFrag<(add node:$LHS,
5499 (AArch64srshri node:$MHS, node:$RHS))>>;
5500 defm SSHR : SIMDScalarRShiftD< 0, 0b00000, "sshr", AArch64vashr>;
5501 defm SSRA : SIMDScalarRShiftDTied< 0, 0b00010, "ssra",
5502 TriOpFrag<(add node:$LHS,
5503 (AArch64vashr node:$MHS, node:$RHS))>>;
5504 defm UQRSHRN : SIMDScalarRShiftBHS< 1, 0b10011, "uqrshrn",
5505 int_aarch64_neon_uqrshrn>;
5506 defm UQSHL : SIMDScalarLShiftBHSD<1, 0b01110, "uqshl", AArch64uqshli>;
5507 defm UQSHRN : SIMDScalarRShiftBHS< 1, 0b10010, "uqshrn",
5508 int_aarch64_neon_uqshrn>;
5509 defm URSHR : SIMDScalarRShiftD< 1, 0b00100, "urshr", AArch64urshri>;
5510 defm URSRA : SIMDScalarRShiftDTied< 1, 0b00110, "ursra",
5511 TriOpFrag<(add node:$LHS,
5512 (AArch64urshri node:$MHS, node:$RHS))>>;
5513 defm USHR : SIMDScalarRShiftD< 1, 0b00000, "ushr", AArch64vlshr>;
5514 defm USRA : SIMDScalarRShiftDTied< 1, 0b00010, "usra",
5515 TriOpFrag<(add node:$LHS,
5516 (AArch64vlshr node:$MHS, node:$RHS))>>;
5518 //----------------------------------------------------------------------------
5519 // AdvSIMD vector shift instructions
5520 //----------------------------------------------------------------------------
5521 defm FCVTZS:SIMDVectorRShiftSD<0, 0b11111, "fcvtzs", int_aarch64_neon_vcvtfp2fxs>;
5522 defm FCVTZU:SIMDVectorRShiftSD<1, 0b11111, "fcvtzu", int_aarch64_neon_vcvtfp2fxu>;
5523 defm SCVTF: SIMDVectorRShiftToFP<0, 0b11100, "scvtf",
5524 int_aarch64_neon_vcvtfxs2fp>;
5525 defm RSHRN : SIMDVectorRShiftNarrowBHS<0, 0b10001, "rshrn",
5526 int_aarch64_neon_rshrn>;
5527 defm SHL : SIMDVectorLShiftBHSD<0, 0b01010, "shl", AArch64vshl>;
5528 defm SHRN : SIMDVectorRShiftNarrowBHS<0, 0b10000, "shrn",
5529 BinOpFrag<(trunc (AArch64vashr node:$LHS, node:$RHS))>>;
5530 defm SLI : SIMDVectorLShiftBHSDTied<1, 0b01010, "sli", int_aarch64_neon_vsli>;
5531 def : Pat<(v1i64 (int_aarch64_neon_vsli (v1i64 FPR64:$Rd), (v1i64 FPR64:$Rn),
5532 (i32 vecshiftL64:$imm))),
5533 (SLId FPR64:$Rd, FPR64:$Rn, vecshiftL64:$imm)>;
5534 defm SQRSHRN : SIMDVectorRShiftNarrowBHS<0, 0b10011, "sqrshrn",
5535 int_aarch64_neon_sqrshrn>;
5536 defm SQRSHRUN: SIMDVectorRShiftNarrowBHS<1, 0b10001, "sqrshrun",
5537 int_aarch64_neon_sqrshrun>;
5538 defm SQSHLU : SIMDVectorLShiftBHSD<1, 0b01100, "sqshlu", AArch64sqshlui>;
5539 defm SQSHL : SIMDVectorLShiftBHSD<0, 0b01110, "sqshl", AArch64sqshli>;
5540 defm SQSHRN : SIMDVectorRShiftNarrowBHS<0, 0b10010, "sqshrn",
5541 int_aarch64_neon_sqshrn>;
5542 defm SQSHRUN : SIMDVectorRShiftNarrowBHS<1, 0b10000, "sqshrun",
5543 int_aarch64_neon_sqshrun>;
5544 defm SRI : SIMDVectorRShiftBHSDTied<1, 0b01000, "sri", int_aarch64_neon_vsri>;
5545 def : Pat<(v1i64 (int_aarch64_neon_vsri (v1i64 FPR64:$Rd), (v1i64 FPR64:$Rn),
5546 (i32 vecshiftR64:$imm))),
5547 (SRId FPR64:$Rd, FPR64:$Rn, vecshiftR64:$imm)>;
5548 defm SRSHR : SIMDVectorRShiftBHSD<0, 0b00100, "srshr", AArch64srshri>;
5549 defm SRSRA : SIMDVectorRShiftBHSDTied<0, 0b00110, "srsra",
5550 TriOpFrag<(add node:$LHS,
5551 (AArch64srshri node:$MHS, node:$RHS))> >;
5552 defm SSHLL : SIMDVectorLShiftLongBHSD<0, 0b10100, "sshll",
5553 BinOpFrag<(AArch64vshl (sext node:$LHS), node:$RHS)>>;
5555 defm SSHR : SIMDVectorRShiftBHSD<0, 0b00000, "sshr", AArch64vashr>;
5556 defm SSRA : SIMDVectorRShiftBHSDTied<0, 0b00010, "ssra",
5557 TriOpFrag<(add node:$LHS, (AArch64vashr node:$MHS, node:$RHS))>>;
5558 defm UCVTF : SIMDVectorRShiftToFP<1, 0b11100, "ucvtf",
5559 int_aarch64_neon_vcvtfxu2fp>;
5560 defm UQRSHRN : SIMDVectorRShiftNarrowBHS<1, 0b10011, "uqrshrn",
5561 int_aarch64_neon_uqrshrn>;
5562 defm UQSHL : SIMDVectorLShiftBHSD<1, 0b01110, "uqshl", AArch64uqshli>;
5563 defm UQSHRN : SIMDVectorRShiftNarrowBHS<1, 0b10010, "uqshrn",
5564 int_aarch64_neon_uqshrn>;
5565 defm URSHR : SIMDVectorRShiftBHSD<1, 0b00100, "urshr", AArch64urshri>;
5566 defm URSRA : SIMDVectorRShiftBHSDTied<1, 0b00110, "ursra",
5567 TriOpFrag<(add node:$LHS,
5568 (AArch64urshri node:$MHS, node:$RHS))> >;
5569 defm USHLL : SIMDVectorLShiftLongBHSD<1, 0b10100, "ushll",
5570 BinOpFrag<(AArch64vshl (zext node:$LHS), node:$RHS)>>;
5571 defm USHR : SIMDVectorRShiftBHSD<1, 0b00000, "ushr", AArch64vlshr>;
5572 defm USRA : SIMDVectorRShiftBHSDTied<1, 0b00010, "usra",
5573 TriOpFrag<(add node:$LHS, (AArch64vlshr node:$MHS, node:$RHS))> >;
5575 // SHRN patterns for when a logical right shift was used instead of arithmetic
5576 // (the immediate guarantees no sign bits actually end up in the result so it
5578 def : Pat<(v8i8 (trunc (AArch64vlshr (v8i16 V128:$Rn), vecshiftR16Narrow:$imm))),
5579 (SHRNv8i8_shift V128:$Rn, vecshiftR16Narrow:$imm)>;
5580 def : Pat<(v4i16 (trunc (AArch64vlshr (v4i32 V128:$Rn), vecshiftR32Narrow:$imm))),
5581 (SHRNv4i16_shift V128:$Rn, vecshiftR32Narrow:$imm)>;
5582 def : Pat<(v2i32 (trunc (AArch64vlshr (v2i64 V128:$Rn), vecshiftR64Narrow:$imm))),
5583 (SHRNv2i32_shift V128:$Rn, vecshiftR64Narrow:$imm)>;
5585 def : Pat<(v16i8 (concat_vectors (v8i8 V64:$Rd),
5586 (trunc (AArch64vlshr (v8i16 V128:$Rn),
5587 vecshiftR16Narrow:$imm)))),
5588 (SHRNv16i8_shift (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
5589 V128:$Rn, vecshiftR16Narrow:$imm)>;
5590 def : Pat<(v8i16 (concat_vectors (v4i16 V64:$Rd),
5591 (trunc (AArch64vlshr (v4i32 V128:$Rn),
5592 vecshiftR32Narrow:$imm)))),
5593 (SHRNv8i16_shift (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
5594 V128:$Rn, vecshiftR32Narrow:$imm)>;
5595 def : Pat<(v4i32 (concat_vectors (v2i32 V64:$Rd),
5596 (trunc (AArch64vlshr (v2i64 V128:$Rn),
5597 vecshiftR64Narrow:$imm)))),
5598 (SHRNv4i32_shift (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
5599 V128:$Rn, vecshiftR32Narrow:$imm)>;
5601 // Vector sign and zero extensions are implemented with SSHLL and USSHLL.
5602 // Anyexts are implemented as zexts.
5603 def : Pat<(v8i16 (sext (v8i8 V64:$Rn))), (SSHLLv8i8_shift V64:$Rn, (i32 0))>;
5604 def : Pat<(v8i16 (zext (v8i8 V64:$Rn))), (USHLLv8i8_shift V64:$Rn, (i32 0))>;
5605 def : Pat<(v8i16 (anyext (v8i8 V64:$Rn))), (USHLLv8i8_shift V64:$Rn, (i32 0))>;
5606 def : Pat<(v4i32 (sext (v4i16 V64:$Rn))), (SSHLLv4i16_shift V64:$Rn, (i32 0))>;
5607 def : Pat<(v4i32 (zext (v4i16 V64:$Rn))), (USHLLv4i16_shift V64:$Rn, (i32 0))>;
5608 def : Pat<(v4i32 (anyext (v4i16 V64:$Rn))), (USHLLv4i16_shift V64:$Rn, (i32 0))>;
5609 def : Pat<(v2i64 (sext (v2i32 V64:$Rn))), (SSHLLv2i32_shift V64:$Rn, (i32 0))>;
5610 def : Pat<(v2i64 (zext (v2i32 V64:$Rn))), (USHLLv2i32_shift V64:$Rn, (i32 0))>;
5611 def : Pat<(v2i64 (anyext (v2i32 V64:$Rn))), (USHLLv2i32_shift V64:$Rn, (i32 0))>;
5612 // Also match an extend from the upper half of a 128 bit source register.
5613 def : Pat<(v8i16 (anyext (v8i8 (extract_subvector V128:$Rn, (i64 8)) ))),
5614 (USHLLv16i8_shift V128:$Rn, (i32 0))>;
5615 def : Pat<(v8i16 (zext (v8i8 (extract_subvector V128:$Rn, (i64 8)) ))),
5616 (USHLLv16i8_shift V128:$Rn, (i32 0))>;
5617 def : Pat<(v8i16 (sext (v8i8 (extract_subvector V128:$Rn, (i64 8)) ))),
5618 (SSHLLv16i8_shift V128:$Rn, (i32 0))>;
5619 def : Pat<(v4i32 (anyext (v4i16 (extract_subvector V128:$Rn, (i64 4)) ))),
5620 (USHLLv8i16_shift V128:$Rn, (i32 0))>;
5621 def : Pat<(v4i32 (zext (v4i16 (extract_subvector V128:$Rn, (i64 4)) ))),
5622 (USHLLv8i16_shift V128:$Rn, (i32 0))>;
5623 def : Pat<(v4i32 (sext (v4i16 (extract_subvector V128:$Rn, (i64 4)) ))),
5624 (SSHLLv8i16_shift V128:$Rn, (i32 0))>;
5625 def : Pat<(v2i64 (anyext (v2i32 (extract_subvector V128:$Rn, (i64 2)) ))),
5626 (USHLLv4i32_shift V128:$Rn, (i32 0))>;
5627 def : Pat<(v2i64 (zext (v2i32 (extract_subvector V128:$Rn, (i64 2)) ))),
5628 (USHLLv4i32_shift V128:$Rn, (i32 0))>;
5629 def : Pat<(v2i64 (sext (v2i32 (extract_subvector V128:$Rn, (i64 2)) ))),
5630 (SSHLLv4i32_shift V128:$Rn, (i32 0))>;
5632 // Vector shift sxtl aliases
5633 def : InstAlias<"sxtl.8h $dst, $src1",
5634 (SSHLLv8i8_shift V128:$dst, V64:$src1, 0)>;
5635 def : InstAlias<"sxtl $dst.8h, $src1.8b",
5636 (SSHLLv8i8_shift V128:$dst, V64:$src1, 0)>;
5637 def : InstAlias<"sxtl.4s $dst, $src1",
5638 (SSHLLv4i16_shift V128:$dst, V64:$src1, 0)>;
5639 def : InstAlias<"sxtl $dst.4s, $src1.4h",
5640 (SSHLLv4i16_shift V128:$dst, V64:$src1, 0)>;
5641 def : InstAlias<"sxtl.2d $dst, $src1",
5642 (SSHLLv2i32_shift V128:$dst, V64:$src1, 0)>;
5643 def : InstAlias<"sxtl $dst.2d, $src1.2s",
5644 (SSHLLv2i32_shift V128:$dst, V64:$src1, 0)>;
5646 // Vector shift sxtl2 aliases
5647 def : InstAlias<"sxtl2.8h $dst, $src1",
5648 (SSHLLv16i8_shift V128:$dst, V128:$src1, 0)>;
5649 def : InstAlias<"sxtl2 $dst.8h, $src1.16b",
5650 (SSHLLv16i8_shift V128:$dst, V128:$src1, 0)>;
5651 def : InstAlias<"sxtl2.4s $dst, $src1",
5652 (SSHLLv8i16_shift V128:$dst, V128:$src1, 0)>;
5653 def : InstAlias<"sxtl2 $dst.4s, $src1.8h",
5654 (SSHLLv8i16_shift V128:$dst, V128:$src1, 0)>;
5655 def : InstAlias<"sxtl2.2d $dst, $src1",
5656 (SSHLLv4i32_shift V128:$dst, V128:$src1, 0)>;
5657 def : InstAlias<"sxtl2 $dst.2d, $src1.4s",
5658 (SSHLLv4i32_shift V128:$dst, V128:$src1, 0)>;
5660 // Vector shift uxtl aliases
5661 def : InstAlias<"uxtl.8h $dst, $src1",
5662 (USHLLv8i8_shift V128:$dst, V64:$src1, 0)>;
5663 def : InstAlias<"uxtl $dst.8h, $src1.8b",
5664 (USHLLv8i8_shift V128:$dst, V64:$src1, 0)>;
5665 def : InstAlias<"uxtl.4s $dst, $src1",
5666 (USHLLv4i16_shift V128:$dst, V64:$src1, 0)>;
5667 def : InstAlias<"uxtl $dst.4s, $src1.4h",
5668 (USHLLv4i16_shift V128:$dst, V64:$src1, 0)>;
5669 def : InstAlias<"uxtl.2d $dst, $src1",
5670 (USHLLv2i32_shift V128:$dst, V64:$src1, 0)>;
5671 def : InstAlias<"uxtl $dst.2d, $src1.2s",
5672 (USHLLv2i32_shift V128:$dst, V64:$src1, 0)>;
5674 // Vector shift uxtl2 aliases
5675 def : InstAlias<"uxtl2.8h $dst, $src1",
5676 (USHLLv16i8_shift V128:$dst, V128:$src1, 0)>;
5677 def : InstAlias<"uxtl2 $dst.8h, $src1.16b",
5678 (USHLLv16i8_shift V128:$dst, V128:$src1, 0)>;
5679 def : InstAlias<"uxtl2.4s $dst, $src1",
5680 (USHLLv8i16_shift V128:$dst, V128:$src1, 0)>;
5681 def : InstAlias<"uxtl2 $dst.4s, $src1.8h",
5682 (USHLLv8i16_shift V128:$dst, V128:$src1, 0)>;
5683 def : InstAlias<"uxtl2.2d $dst, $src1",
5684 (USHLLv4i32_shift V128:$dst, V128:$src1, 0)>;
5685 def : InstAlias<"uxtl2 $dst.2d, $src1.4s",
5686 (USHLLv4i32_shift V128:$dst, V128:$src1, 0)>;
5688 // If an integer is about to be converted to a floating point value,
5689 // just load it on the floating point unit.
5690 // These patterns are more complex because floating point loads do not
5691 // support sign extension.
5692 // The sign extension has to be explicitly added and is only supported for
5693 // one step: byte-to-half, half-to-word, word-to-doubleword.
5694 // SCVTF GPR -> FPR is 9 cycles.
5695 // SCVTF FPR -> FPR is 4 cyclces.
5696 // (sign extension with lengthen) SXTL FPR -> FPR is 2 cycles.
5697 // Therefore, we can do 2 sign extensions and one SCVTF FPR -> FPR
5698 // and still being faster.
5699 // However, this is not good for code size.
5700 // 8-bits -> float. 2 sizes step-up.
5701 class SExtLoadi8CVTf32Pat<dag addrmode, dag INST>
5702 : Pat<(f32 (sint_to_fp (i32 (sextloadi8 addrmode)))),
5703 (SCVTFv1i32 (f32 (EXTRACT_SUBREG
5708 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
5715 Requires<[NotForCodeSize, UseAlternateSExtLoadCVTF32]>;
5717 def : SExtLoadi8CVTf32Pat<(ro8.Wpat GPR64sp:$Rn, GPR32:$Rm, ro8.Wext:$ext),
5718 (LDRBroW GPR64sp:$Rn, GPR32:$Rm, ro8.Wext:$ext)>;
5719 def : SExtLoadi8CVTf32Pat<(ro8.Xpat GPR64sp:$Rn, GPR64:$Rm, ro8.Xext:$ext),
5720 (LDRBroX GPR64sp:$Rn, GPR64:$Rm, ro8.Xext:$ext)>;
5721 def : SExtLoadi8CVTf32Pat<(am_indexed8 GPR64sp:$Rn, uimm12s1:$offset),
5722 (LDRBui GPR64sp:$Rn, uimm12s1:$offset)>;
5723 def : SExtLoadi8CVTf32Pat<(am_unscaled8 GPR64sp:$Rn, simm9:$offset),
5724 (LDURBi GPR64sp:$Rn, simm9:$offset)>;
5726 // 16-bits -> float. 1 size step-up.
5727 class SExtLoadi16CVTf32Pat<dag addrmode, dag INST>
5728 : Pat<(f32 (sint_to_fp (i32 (sextloadi16 addrmode)))),
5729 (SCVTFv1i32 (f32 (EXTRACT_SUBREG
5731 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
5735 ssub)))>, Requires<[NotForCodeSize]>;
5737 def : SExtLoadi16CVTf32Pat<(ro16.Wpat GPR64sp:$Rn, GPR32:$Rm, ro16.Wext:$ext),
5738 (LDRHroW GPR64sp:$Rn, GPR32:$Rm, ro16.Wext:$ext)>;
5739 def : SExtLoadi16CVTf32Pat<(ro16.Xpat GPR64sp:$Rn, GPR64:$Rm, ro16.Xext:$ext),
5740 (LDRHroX GPR64sp:$Rn, GPR64:$Rm, ro16.Xext:$ext)>;
5741 def : SExtLoadi16CVTf32Pat<(am_indexed16 GPR64sp:$Rn, uimm12s2:$offset),
5742 (LDRHui GPR64sp:$Rn, uimm12s2:$offset)>;
5743 def : SExtLoadi16CVTf32Pat<(am_unscaled16 GPR64sp:$Rn, simm9:$offset),
5744 (LDURHi GPR64sp:$Rn, simm9:$offset)>;
5746 // 32-bits to 32-bits are handled in target specific dag combine:
5747 // performIntToFpCombine.
5748 // 64-bits integer to 32-bits floating point, not possible with
5749 // SCVTF on floating point registers (both source and destination
5750 // must have the same size).
5752 // Here are the patterns for 8, 16, 32, and 64-bits to double.
5753 // 8-bits -> double. 3 size step-up: give up.
5754 // 16-bits -> double. 2 size step.
5755 class SExtLoadi16CVTf64Pat<dag addrmode, dag INST>
5756 : Pat <(f64 (sint_to_fp (i32 (sextloadi16 addrmode)))),
5757 (SCVTFv1i64 (f64 (EXTRACT_SUBREG
5762 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
5769 Requires<[NotForCodeSize, UseAlternateSExtLoadCVTF32]>;
5771 def : SExtLoadi16CVTf64Pat<(ro16.Wpat GPR64sp:$Rn, GPR32:$Rm, ro16.Wext:$ext),
5772 (LDRHroW GPR64sp:$Rn, GPR32:$Rm, ro16.Wext:$ext)>;
5773 def : SExtLoadi16CVTf64Pat<(ro16.Xpat GPR64sp:$Rn, GPR64:$Rm, ro16.Xext:$ext),
5774 (LDRHroX GPR64sp:$Rn, GPR64:$Rm, ro16.Xext:$ext)>;
5775 def : SExtLoadi16CVTf64Pat<(am_indexed16 GPR64sp:$Rn, uimm12s2:$offset),
5776 (LDRHui GPR64sp:$Rn, uimm12s2:$offset)>;
5777 def : SExtLoadi16CVTf64Pat<(am_unscaled16 GPR64sp:$Rn, simm9:$offset),
5778 (LDURHi GPR64sp:$Rn, simm9:$offset)>;
5779 // 32-bits -> double. 1 size step-up.
5780 class SExtLoadi32CVTf64Pat<dag addrmode, dag INST>
5781 : Pat <(f64 (sint_to_fp (i32 (load addrmode)))),
5782 (SCVTFv1i64 (f64 (EXTRACT_SUBREG
5784 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
5788 dsub)))>, Requires<[NotForCodeSize]>;
5790 def : SExtLoadi32CVTf64Pat<(ro32.Wpat GPR64sp:$Rn, GPR32:$Rm, ro32.Wext:$ext),
5791 (LDRSroW GPR64sp:$Rn, GPR32:$Rm, ro32.Wext:$ext)>;
5792 def : SExtLoadi32CVTf64Pat<(ro32.Xpat GPR64sp:$Rn, GPR64:$Rm, ro32.Xext:$ext),
5793 (LDRSroX GPR64sp:$Rn, GPR64:$Rm, ro32.Xext:$ext)>;
5794 def : SExtLoadi32CVTf64Pat<(am_indexed32 GPR64sp:$Rn, uimm12s4:$offset),
5795 (LDRSui GPR64sp:$Rn, uimm12s4:$offset)>;
5796 def : SExtLoadi32CVTf64Pat<(am_unscaled32 GPR64sp:$Rn, simm9:$offset),
5797 (LDURSi GPR64sp:$Rn, simm9:$offset)>;
5799 // 64-bits -> double are handled in target specific dag combine:
5800 // performIntToFpCombine.
5803 //----------------------------------------------------------------------------
5804 // AdvSIMD Load-Store Structure
5805 //----------------------------------------------------------------------------
5806 defm LD1 : SIMDLd1Multiple<"ld1">;
5807 defm LD2 : SIMDLd2Multiple<"ld2">;
5808 defm LD3 : SIMDLd3Multiple<"ld3">;
5809 defm LD4 : SIMDLd4Multiple<"ld4">;
5811 defm ST1 : SIMDSt1Multiple<"st1">;
5812 defm ST2 : SIMDSt2Multiple<"st2">;
5813 defm ST3 : SIMDSt3Multiple<"st3">;
5814 defm ST4 : SIMDSt4Multiple<"st4">;
5816 class Ld1Pat<ValueType ty, Instruction INST>
5817 : Pat<(ty (load GPR64sp:$Rn)), (INST GPR64sp:$Rn)>;
5819 def : Ld1Pat<v16i8, LD1Onev16b>;
5820 def : Ld1Pat<v8i16, LD1Onev8h>;
5821 def : Ld1Pat<v4i32, LD1Onev4s>;
5822 def : Ld1Pat<v2i64, LD1Onev2d>;
5823 def : Ld1Pat<v8i8, LD1Onev8b>;
5824 def : Ld1Pat<v4i16, LD1Onev4h>;
5825 def : Ld1Pat<v2i32, LD1Onev2s>;
5826 def : Ld1Pat<v1i64, LD1Onev1d>;
5828 class St1Pat<ValueType ty, Instruction INST>
5829 : Pat<(store ty:$Vt, GPR64sp:$Rn),
5830 (INST ty:$Vt, GPR64sp:$Rn)>;
5832 def : St1Pat<v16i8, ST1Onev16b>;
5833 def : St1Pat<v8i16, ST1Onev8h>;
5834 def : St1Pat<v4i32, ST1Onev4s>;
5835 def : St1Pat<v2i64, ST1Onev2d>;
5836 def : St1Pat<v8i8, ST1Onev8b>;
5837 def : St1Pat<v4i16, ST1Onev4h>;
5838 def : St1Pat<v2i32, ST1Onev2s>;
5839 def : St1Pat<v1i64, ST1Onev1d>;
5845 defm LD1R : SIMDLdR<0, 0b110, 0, "ld1r", "One", 1, 2, 4, 8>;
5846 defm LD2R : SIMDLdR<1, 0b110, 0, "ld2r", "Two", 2, 4, 8, 16>;
5847 defm LD3R : SIMDLdR<0, 0b111, 0, "ld3r", "Three", 3, 6, 12, 24>;
5848 defm LD4R : SIMDLdR<1, 0b111, 0, "ld4r", "Four", 4, 8, 16, 32>;
5849 let mayLoad = 1, hasSideEffects = 0 in {
5850 defm LD1 : SIMDLdSingleBTied<0, 0b000, "ld1", VecListOneb, GPR64pi1>;
5851 defm LD1 : SIMDLdSingleHTied<0, 0b010, 0, "ld1", VecListOneh, GPR64pi2>;
5852 defm LD1 : SIMDLdSingleSTied<0, 0b100, 0b00, "ld1", VecListOnes, GPR64pi4>;
5853 defm LD1 : SIMDLdSingleDTied<0, 0b100, 0b01, "ld1", VecListOned, GPR64pi8>;
5854 defm LD2 : SIMDLdSingleBTied<1, 0b000, "ld2", VecListTwob, GPR64pi2>;
5855 defm LD2 : SIMDLdSingleHTied<1, 0b010, 0, "ld2", VecListTwoh, GPR64pi4>;
5856 defm LD2 : SIMDLdSingleSTied<1, 0b100, 0b00, "ld2", VecListTwos, GPR64pi8>;
5857 defm LD2 : SIMDLdSingleDTied<1, 0b100, 0b01, "ld2", VecListTwod, GPR64pi16>;
5858 defm LD3 : SIMDLdSingleBTied<0, 0b001, "ld3", VecListThreeb, GPR64pi3>;
5859 defm LD3 : SIMDLdSingleHTied<0, 0b011, 0, "ld3", VecListThreeh, GPR64pi6>;
5860 defm LD3 : SIMDLdSingleSTied<0, 0b101, 0b00, "ld3", VecListThrees, GPR64pi12>;
5861 defm LD3 : SIMDLdSingleDTied<0, 0b101, 0b01, "ld3", VecListThreed, GPR64pi24>;
5862 defm LD4 : SIMDLdSingleBTied<1, 0b001, "ld4", VecListFourb, GPR64pi4>;
5863 defm LD4 : SIMDLdSingleHTied<1, 0b011, 0, "ld4", VecListFourh, GPR64pi8>;
5864 defm LD4 : SIMDLdSingleSTied<1, 0b101, 0b00, "ld4", VecListFours, GPR64pi16>;
5865 defm LD4 : SIMDLdSingleDTied<1, 0b101, 0b01, "ld4", VecListFourd, GPR64pi32>;
5868 def : Pat<(v8i8 (AArch64dup (i32 (extloadi8 GPR64sp:$Rn)))),
5869 (LD1Rv8b GPR64sp:$Rn)>;
5870 def : Pat<(v16i8 (AArch64dup (i32 (extloadi8 GPR64sp:$Rn)))),
5871 (LD1Rv16b GPR64sp:$Rn)>;
5872 def : Pat<(v4i16 (AArch64dup (i32 (extloadi16 GPR64sp:$Rn)))),
5873 (LD1Rv4h GPR64sp:$Rn)>;
5874 def : Pat<(v8i16 (AArch64dup (i32 (extloadi16 GPR64sp:$Rn)))),
5875 (LD1Rv8h GPR64sp:$Rn)>;
5876 def : Pat<(v2i32 (AArch64dup (i32 (load GPR64sp:$Rn)))),
5877 (LD1Rv2s GPR64sp:$Rn)>;
5878 def : Pat<(v4i32 (AArch64dup (i32 (load GPR64sp:$Rn)))),
5879 (LD1Rv4s GPR64sp:$Rn)>;
5880 def : Pat<(v2i64 (AArch64dup (i64 (load GPR64sp:$Rn)))),
5881 (LD1Rv2d GPR64sp:$Rn)>;
5882 def : Pat<(v1i64 (AArch64dup (i64 (load GPR64sp:$Rn)))),
5883 (LD1Rv1d GPR64sp:$Rn)>;
5884 // Grab the floating point version too
5885 def : Pat<(v2f32 (AArch64dup (f32 (load GPR64sp:$Rn)))),
5886 (LD1Rv2s GPR64sp:$Rn)>;
5887 def : Pat<(v4f32 (AArch64dup (f32 (load GPR64sp:$Rn)))),
5888 (LD1Rv4s GPR64sp:$Rn)>;
5889 def : Pat<(v2f64 (AArch64dup (f64 (load GPR64sp:$Rn)))),
5890 (LD1Rv2d GPR64sp:$Rn)>;
5891 def : Pat<(v1f64 (AArch64dup (f64 (load GPR64sp:$Rn)))),
5892 (LD1Rv1d GPR64sp:$Rn)>;
5893 def : Pat<(v4f16 (AArch64dup (f16 (load GPR64sp:$Rn)))),
5894 (LD1Rv4h GPR64sp:$Rn)>;
5895 def : Pat<(v8f16 (AArch64dup (f16 (load GPR64sp:$Rn)))),
5896 (LD1Rv8h GPR64sp:$Rn)>;
5898 class Ld1Lane128Pat<SDPatternOperator scalar_load, Operand VecIndex,
5899 ValueType VTy, ValueType STy, Instruction LD1>
5900 : Pat<(vector_insert (VTy VecListOne128:$Rd),
5901 (STy (scalar_load GPR64sp:$Rn)), VecIndex:$idx),
5902 (LD1 VecListOne128:$Rd, VecIndex:$idx, GPR64sp:$Rn)>;
5904 def : Ld1Lane128Pat<extloadi8, VectorIndexB, v16i8, i32, LD1i8>;
5905 def : Ld1Lane128Pat<extloadi16, VectorIndexH, v8i16, i32, LD1i16>;
5906 def : Ld1Lane128Pat<load, VectorIndexS, v4i32, i32, LD1i32>;
5907 def : Ld1Lane128Pat<load, VectorIndexS, v4f32, f32, LD1i32>;
5908 def : Ld1Lane128Pat<load, VectorIndexD, v2i64, i64, LD1i64>;
5909 def : Ld1Lane128Pat<load, VectorIndexD, v2f64, f64, LD1i64>;
5910 def : Ld1Lane128Pat<load, VectorIndexH, v8f16, f16, LD1i16>;
5912 class Ld1Lane64Pat<SDPatternOperator scalar_load, Operand VecIndex,
5913 ValueType VTy, ValueType STy, Instruction LD1>
5914 : Pat<(vector_insert (VTy VecListOne64:$Rd),
5915 (STy (scalar_load GPR64sp:$Rn)), VecIndex:$idx),
5917 (LD1 (SUBREG_TO_REG (i32 0), VecListOne64:$Rd, dsub),
5918 VecIndex:$idx, GPR64sp:$Rn),
5921 def : Ld1Lane64Pat<extloadi8, VectorIndexB, v8i8, i32, LD1i8>;
5922 def : Ld1Lane64Pat<extloadi16, VectorIndexH, v4i16, i32, LD1i16>;
5923 def : Ld1Lane64Pat<load, VectorIndexS, v2i32, i32, LD1i32>;
5924 def : Ld1Lane64Pat<load, VectorIndexS, v2f32, f32, LD1i32>;
5925 def : Ld1Lane64Pat<load, VectorIndexH, v4f16, f16, LD1i16>;
5928 defm LD1 : SIMDLdSt1SingleAliases<"ld1">;
5929 defm LD2 : SIMDLdSt2SingleAliases<"ld2">;
5930 defm LD3 : SIMDLdSt3SingleAliases<"ld3">;
5931 defm LD4 : SIMDLdSt4SingleAliases<"ld4">;
5934 defm ST1 : SIMDStSingleB<0, 0b000, "st1", VecListOneb, GPR64pi1>;
5935 defm ST1 : SIMDStSingleH<0, 0b010, 0, "st1", VecListOneh, GPR64pi2>;
5936 defm ST1 : SIMDStSingleS<0, 0b100, 0b00, "st1", VecListOnes, GPR64pi4>;
5937 defm ST1 : SIMDStSingleD<0, 0b100, 0b01, "st1", VecListOned, GPR64pi8>;
5939 let AddedComplexity = 19 in
5940 class St1Lane128Pat<SDPatternOperator scalar_store, Operand VecIndex,
5941 ValueType VTy, ValueType STy, Instruction ST1>
5943 (STy (vector_extract (VTy VecListOne128:$Vt), VecIndex:$idx)),
5945 (ST1 VecListOne128:$Vt, VecIndex:$idx, GPR64sp:$Rn)>;
5947 def : St1Lane128Pat<truncstorei8, VectorIndexB, v16i8, i32, ST1i8>;
5948 def : St1Lane128Pat<truncstorei16, VectorIndexH, v8i16, i32, ST1i16>;
5949 def : St1Lane128Pat<store, VectorIndexS, v4i32, i32, ST1i32>;
5950 def : St1Lane128Pat<store, VectorIndexS, v4f32, f32, ST1i32>;
5951 def : St1Lane128Pat<store, VectorIndexD, v2i64, i64, ST1i64>;
5952 def : St1Lane128Pat<store, VectorIndexD, v2f64, f64, ST1i64>;
5953 def : St1Lane128Pat<store, VectorIndexH, v8f16, f16, ST1i16>;
5955 let AddedComplexity = 19 in
5956 class St1Lane64Pat<SDPatternOperator scalar_store, Operand VecIndex,
5957 ValueType VTy, ValueType STy, Instruction ST1>
5959 (STy (vector_extract (VTy VecListOne64:$Vt), VecIndex:$idx)),
5961 (ST1 (SUBREG_TO_REG (i32 0), VecListOne64:$Vt, dsub),
5962 VecIndex:$idx, GPR64sp:$Rn)>;
5964 def : St1Lane64Pat<truncstorei8, VectorIndexB, v8i8, i32, ST1i8>;
5965 def : St1Lane64Pat<truncstorei16, VectorIndexH, v4i16, i32, ST1i16>;
5966 def : St1Lane64Pat<store, VectorIndexS, v2i32, i32, ST1i32>;
5967 def : St1Lane64Pat<store, VectorIndexS, v2f32, f32, ST1i32>;
5968 def : St1Lane64Pat<store, VectorIndexH, v4f16, f16, ST1i16>;
5970 multiclass St1LanePost64Pat<SDPatternOperator scalar_store, Operand VecIndex,
5971 ValueType VTy, ValueType STy, Instruction ST1,
5973 def : Pat<(scalar_store
5974 (STy (vector_extract (VTy VecListOne64:$Vt), VecIndex:$idx)),
5975 GPR64sp:$Rn, offset),
5976 (ST1 (SUBREG_TO_REG (i32 0), VecListOne64:$Vt, dsub),
5977 VecIndex:$idx, GPR64sp:$Rn, XZR)>;
5979 def : Pat<(scalar_store
5980 (STy (vector_extract (VTy VecListOne64:$Vt), VecIndex:$idx)),
5981 GPR64sp:$Rn, GPR64:$Rm),
5982 (ST1 (SUBREG_TO_REG (i32 0), VecListOne64:$Vt, dsub),
5983 VecIndex:$idx, GPR64sp:$Rn, $Rm)>;
5986 defm : St1LanePost64Pat<post_truncsti8, VectorIndexB, v8i8, i32, ST1i8_POST, 1>;
5987 defm : St1LanePost64Pat<post_truncsti16, VectorIndexH, v4i16, i32, ST1i16_POST,
5989 defm : St1LanePost64Pat<post_store, VectorIndexS, v2i32, i32, ST1i32_POST, 4>;
5990 defm : St1LanePost64Pat<post_store, VectorIndexS, v2f32, f32, ST1i32_POST, 4>;
5991 defm : St1LanePost64Pat<post_store, VectorIndexD, v1i64, i64, ST1i64_POST, 8>;
5992 defm : St1LanePost64Pat<post_store, VectorIndexD, v1f64, f64, ST1i64_POST, 8>;
5993 defm : St1LanePost64Pat<post_store, VectorIndexH, v4f16, f16, ST1i16_POST, 2>;
5995 multiclass St1LanePost128Pat<SDPatternOperator scalar_store, Operand VecIndex,
5996 ValueType VTy, ValueType STy, Instruction ST1,
5998 def : Pat<(scalar_store
5999 (STy (vector_extract (VTy VecListOne128:$Vt), VecIndex:$idx)),
6000 GPR64sp:$Rn, offset),
6001 (ST1 VecListOne128:$Vt, VecIndex:$idx, GPR64sp:$Rn, XZR)>;
6003 def : Pat<(scalar_store
6004 (STy (vector_extract (VTy VecListOne128:$Vt), VecIndex:$idx)),
6005 GPR64sp:$Rn, GPR64:$Rm),
6006 (ST1 VecListOne128:$Vt, VecIndex:$idx, GPR64sp:$Rn, $Rm)>;
6009 defm : St1LanePost128Pat<post_truncsti8, VectorIndexB, v16i8, i32, ST1i8_POST,
6011 defm : St1LanePost128Pat<post_truncsti16, VectorIndexH, v8i16, i32, ST1i16_POST,
6013 defm : St1LanePost128Pat<post_store, VectorIndexS, v4i32, i32, ST1i32_POST, 4>;
6014 defm : St1LanePost128Pat<post_store, VectorIndexS, v4f32, f32, ST1i32_POST, 4>;
6015 defm : St1LanePost128Pat<post_store, VectorIndexD, v2i64, i64, ST1i64_POST, 8>;
6016 defm : St1LanePost128Pat<post_store, VectorIndexD, v2f64, f64, ST1i64_POST, 8>;
6017 defm : St1LanePost128Pat<post_store, VectorIndexH, v8f16, f16, ST1i16_POST, 2>;
6019 let mayStore = 1, hasSideEffects = 0 in {
6020 defm ST2 : SIMDStSingleB<1, 0b000, "st2", VecListTwob, GPR64pi2>;
6021 defm ST2 : SIMDStSingleH<1, 0b010, 0, "st2", VecListTwoh, GPR64pi4>;
6022 defm ST2 : SIMDStSingleS<1, 0b100, 0b00, "st2", VecListTwos, GPR64pi8>;
6023 defm ST2 : SIMDStSingleD<1, 0b100, 0b01, "st2", VecListTwod, GPR64pi16>;
6024 defm ST3 : SIMDStSingleB<0, 0b001, "st3", VecListThreeb, GPR64pi3>;
6025 defm ST3 : SIMDStSingleH<0, 0b011, 0, "st3", VecListThreeh, GPR64pi6>;
6026 defm ST3 : SIMDStSingleS<0, 0b101, 0b00, "st3", VecListThrees, GPR64pi12>;
6027 defm ST3 : SIMDStSingleD<0, 0b101, 0b01, "st3", VecListThreed, GPR64pi24>;
6028 defm ST4 : SIMDStSingleB<1, 0b001, "st4", VecListFourb, GPR64pi4>;
6029 defm ST4 : SIMDStSingleH<1, 0b011, 0, "st4", VecListFourh, GPR64pi8>;
6030 defm ST4 : SIMDStSingleS<1, 0b101, 0b00, "st4", VecListFours, GPR64pi16>;
6031 defm ST4 : SIMDStSingleD<1, 0b101, 0b01, "st4", VecListFourd, GPR64pi32>;
6034 defm ST1 : SIMDLdSt1SingleAliases<"st1">;
6035 defm ST2 : SIMDLdSt2SingleAliases<"st2">;
6036 defm ST3 : SIMDLdSt3SingleAliases<"st3">;
6037 defm ST4 : SIMDLdSt4SingleAliases<"st4">;
6039 //----------------------------------------------------------------------------
6040 // Crypto extensions
6041 //----------------------------------------------------------------------------
6043 let Predicates = [HasAES] in {
6044 def AESErr : AESTiedInst<0b0100, "aese", int_aarch64_crypto_aese>;
6045 def AESDrr : AESTiedInst<0b0101, "aesd", int_aarch64_crypto_aesd>;
6046 def AESMCrr : AESInst< 0b0110, "aesmc", int_aarch64_crypto_aesmc>;
6047 def AESIMCrr : AESInst< 0b0111, "aesimc", int_aarch64_crypto_aesimc>;
6050 // Pseudo instructions for AESMCrr/AESIMCrr with a register constraint required
6051 // for AES fusion on some CPUs.
6052 let hasSideEffects = 0, mayStore = 0, mayLoad = 0 in {
6053 def AESMCrrTied: Pseudo<(outs V128:$Rd), (ins V128:$Rn), [], "$Rn = $Rd">,
6055 def AESIMCrrTied: Pseudo<(outs V128:$Rd), (ins V128:$Rn), [], "$Rn = $Rd">,
6059 // Only use constrained versions of AES(I)MC instructions if they are paired with
6061 def : Pat<(v16i8 (int_aarch64_crypto_aesmc
6062 (v16i8 (int_aarch64_crypto_aese (v16i8 V128:$src1),
6063 (v16i8 V128:$src2))))),
6064 (v16i8 (AESMCrrTied (v16i8 (AESErr (v16i8 V128:$src1),
6065 (v16i8 V128:$src2)))))>,
6066 Requires<[HasFuseAES]>;
6068 def : Pat<(v16i8 (int_aarch64_crypto_aesimc
6069 (v16i8 (int_aarch64_crypto_aesd (v16i8 V128:$src1),
6070 (v16i8 V128:$src2))))),
6071 (v16i8 (AESIMCrrTied (v16i8 (AESDrr (v16i8 V128:$src1),
6072 (v16i8 V128:$src2)))))>,
6073 Requires<[HasFuseAES]>;
6075 let Predicates = [HasSHA2] in {
6076 def SHA1Crrr : SHATiedInstQSV<0b000, "sha1c", int_aarch64_crypto_sha1c>;
6077 def SHA1Prrr : SHATiedInstQSV<0b001, "sha1p", int_aarch64_crypto_sha1p>;
6078 def SHA1Mrrr : SHATiedInstQSV<0b010, "sha1m", int_aarch64_crypto_sha1m>;
6079 def SHA1SU0rrr : SHATiedInstVVV<0b011, "sha1su0", int_aarch64_crypto_sha1su0>;
6080 def SHA256Hrrr : SHATiedInstQQV<0b100, "sha256h", int_aarch64_crypto_sha256h>;
6081 def SHA256H2rrr : SHATiedInstQQV<0b101, "sha256h2",int_aarch64_crypto_sha256h2>;
6082 def SHA256SU1rrr :SHATiedInstVVV<0b110, "sha256su1",int_aarch64_crypto_sha256su1>;
6084 def SHA1Hrr : SHAInstSS< 0b0000, "sha1h", int_aarch64_crypto_sha1h>;
6085 def SHA1SU1rr : SHATiedInstVV<0b0001, "sha1su1", int_aarch64_crypto_sha1su1>;
6086 def SHA256SU0rr : SHATiedInstVV<0b0010, "sha256su0",int_aarch64_crypto_sha256su0>;
6089 //----------------------------------------------------------------------------
6091 //----------------------------------------------------------------------------
6092 // FIXME: Like for X86, these should go in their own separate .td file.
6094 def def32 : PatLeaf<(i32 GPR32:$src), [{
6098 // In the case of a 32-bit def that is known to implicitly zero-extend,
6099 // we can use a SUBREG_TO_REG.
6100 def : Pat<(i64 (zext def32:$src)), (SUBREG_TO_REG (i64 0), GPR32:$src, sub_32)>;
6102 // For an anyext, we don't care what the high bits are, so we can perform an
6103 // INSERT_SUBREF into an IMPLICIT_DEF.
6104 def : Pat<(i64 (anyext GPR32:$src)),
6105 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GPR32:$src, sub_32)>;
6107 // When we need to explicitly zero-extend, we use a 32-bit MOV instruction and
6108 // then assert the extension has happened.
6109 def : Pat<(i64 (zext GPR32:$src)),
6110 (SUBREG_TO_REG (i32 0), (ORRWrs WZR, GPR32:$src, 0), sub_32)>;
6112 // To sign extend, we use a signed bitfield move instruction (SBFM) on the
6113 // containing super-reg.
6114 def : Pat<(i64 (sext GPR32:$src)),
6115 (SBFMXri (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GPR32:$src, sub_32), 0, 31)>;
6116 def : Pat<(i64 (sext_inreg GPR64:$src, i32)), (SBFMXri GPR64:$src, 0, 31)>;
6117 def : Pat<(i64 (sext_inreg GPR64:$src, i16)), (SBFMXri GPR64:$src, 0, 15)>;
6118 def : Pat<(i64 (sext_inreg GPR64:$src, i8)), (SBFMXri GPR64:$src, 0, 7)>;
6119 def : Pat<(i64 (sext_inreg GPR64:$src, i1)), (SBFMXri GPR64:$src, 0, 0)>;
6120 def : Pat<(i32 (sext_inreg GPR32:$src, i16)), (SBFMWri GPR32:$src, 0, 15)>;
6121 def : Pat<(i32 (sext_inreg GPR32:$src, i8)), (SBFMWri GPR32:$src, 0, 7)>;
6122 def : Pat<(i32 (sext_inreg GPR32:$src, i1)), (SBFMWri GPR32:$src, 0, 0)>;
6124 def : Pat<(shl (sext_inreg GPR32:$Rn, i8), (i64 imm0_31:$imm)),
6125 (SBFMWri GPR32:$Rn, (i64 (i32shift_a imm0_31:$imm)),
6126 (i64 (i32shift_sext_i8 imm0_31:$imm)))>;
6127 def : Pat<(shl (sext_inreg GPR64:$Rn, i8), (i64 imm0_63:$imm)),
6128 (SBFMXri GPR64:$Rn, (i64 (i64shift_a imm0_63:$imm)),
6129 (i64 (i64shift_sext_i8 imm0_63:$imm)))>;
6131 def : Pat<(shl (sext_inreg GPR32:$Rn, i16), (i64 imm0_31:$imm)),
6132 (SBFMWri GPR32:$Rn, (i64 (i32shift_a imm0_31:$imm)),
6133 (i64 (i32shift_sext_i16 imm0_31:$imm)))>;
6134 def : Pat<(shl (sext_inreg GPR64:$Rn, i16), (i64 imm0_63:$imm)),
6135 (SBFMXri GPR64:$Rn, (i64 (i64shift_a imm0_63:$imm)),
6136 (i64 (i64shift_sext_i16 imm0_63:$imm)))>;
6138 def : Pat<(shl (i64 (sext GPR32:$Rn)), (i64 imm0_63:$imm)),
6139 (SBFMXri (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GPR32:$Rn, sub_32),
6140 (i64 (i64shift_a imm0_63:$imm)),
6141 (i64 (i64shift_sext_i32 imm0_63:$imm)))>;
6143 // sra patterns have an AddedComplexity of 10, so make sure we have a higher
6144 // AddedComplexity for the following patterns since we want to match sext + sra
6145 // patterns before we attempt to match a single sra node.
6146 let AddedComplexity = 20 in {
6147 // We support all sext + sra combinations which preserve at least one bit of the
6148 // original value which is to be sign extended. E.g. we support shifts up to
6150 def : Pat<(sra (sext_inreg GPR32:$Rn, i8), (i64 imm0_7:$imm)),
6151 (SBFMWri GPR32:$Rn, (i64 imm0_7:$imm), 7)>;
6152 def : Pat<(sra (sext_inreg GPR64:$Rn, i8), (i64 imm0_7:$imm)),
6153 (SBFMXri GPR64:$Rn, (i64 imm0_7:$imm), 7)>;
6155 def : Pat<(sra (sext_inreg GPR32:$Rn, i16), (i64 imm0_15:$imm)),
6156 (SBFMWri GPR32:$Rn, (i64 imm0_15:$imm), 15)>;
6157 def : Pat<(sra (sext_inreg GPR64:$Rn, i16), (i64 imm0_15:$imm)),
6158 (SBFMXri GPR64:$Rn, (i64 imm0_15:$imm), 15)>;
6160 def : Pat<(sra (i64 (sext GPR32:$Rn)), (i64 imm0_31:$imm)),
6161 (SBFMXri (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GPR32:$Rn, sub_32),
6162 (i64 imm0_31:$imm), 31)>;
6163 } // AddedComplexity = 20
6165 // To truncate, we can simply extract from a subregister.
6166 def : Pat<(i32 (trunc GPR64sp:$src)),
6167 (i32 (EXTRACT_SUBREG GPR64sp:$src, sub_32))>;
6169 // __builtin_trap() uses the BRK instruction on AArch64.
6170 def : Pat<(trap), (BRK 1)>;
6171 def : Pat<(debugtrap), (BRK 0xF000)>, Requires<[IsWindows]>;
6173 // Multiply high patterns which multiply the lower subvector using smull/umull
6174 // and the upper subvector with smull2/umull2. Then shuffle the high the high
6175 // part of both results together.
6176 def : Pat<(v16i8 (mulhs V128:$Rn, V128:$Rm)),
6178 (SMULLv8i8_v8i16 (EXTRACT_SUBREG V128:$Rn, dsub),
6179 (EXTRACT_SUBREG V128:$Rm, dsub)),
6180 (SMULLv16i8_v8i16 V128:$Rn, V128:$Rm))>;
6181 def : Pat<(v8i16 (mulhs V128:$Rn, V128:$Rm)),
6183 (SMULLv4i16_v4i32 (EXTRACT_SUBREG V128:$Rn, dsub),
6184 (EXTRACT_SUBREG V128:$Rm, dsub)),
6185 (SMULLv8i16_v4i32 V128:$Rn, V128:$Rm))>;
6186 def : Pat<(v4i32 (mulhs V128:$Rn, V128:$Rm)),
6188 (SMULLv2i32_v2i64 (EXTRACT_SUBREG V128:$Rn, dsub),
6189 (EXTRACT_SUBREG V128:$Rm, dsub)),
6190 (SMULLv4i32_v2i64 V128:$Rn, V128:$Rm))>;
6192 def : Pat<(v16i8 (mulhu V128:$Rn, V128:$Rm)),
6194 (UMULLv8i8_v8i16 (EXTRACT_SUBREG V128:$Rn, dsub),
6195 (EXTRACT_SUBREG V128:$Rm, dsub)),
6196 (UMULLv16i8_v8i16 V128:$Rn, V128:$Rm))>;
6197 def : Pat<(v8i16 (mulhu V128:$Rn, V128:$Rm)),
6199 (UMULLv4i16_v4i32 (EXTRACT_SUBREG V128:$Rn, dsub),
6200 (EXTRACT_SUBREG V128:$Rm, dsub)),
6201 (UMULLv8i16_v4i32 V128:$Rn, V128:$Rm))>;
6202 def : Pat<(v4i32 (mulhu V128:$Rn, V128:$Rm)),
6204 (UMULLv2i32_v2i64 (EXTRACT_SUBREG V128:$Rn, dsub),
6205 (EXTRACT_SUBREG V128:$Rm, dsub)),
6206 (UMULLv4i32_v2i64 V128:$Rn, V128:$Rm))>;
6208 // Conversions within AdvSIMD types in the same register size are free.
6209 // But because we need a consistent lane ordering, in big endian many
6210 // conversions require one or more REV instructions.
6212 // Consider a simple memory load followed by a bitconvert then a store.
6214 // v1 = BITCAST v2i32 v0 to v4i16
6217 // In big endian mode every memory access has an implicit byte swap. LDR and
6218 // STR do a 64-bit byte swap, whereas LD1/ST1 do a byte swap per lane - that
6219 // is, they treat the vector as a sequence of elements to be byte-swapped.
6220 // The two pairs of instructions are fundamentally incompatible. We've decided
6221 // to use LD1/ST1 only to simplify compiler implementation.
6223 // LD1/ST1 perform the equivalent of a sequence of LDR/STR + REV. This makes
6224 // the original code sequence:
6226 // v1 = REV v2i32 (implicit)
6227 // v2 = BITCAST v2i32 v1 to v4i16
6228 // v3 = REV v4i16 v2 (implicit)
6231 // But this is now broken - the value stored is different to the value loaded
6232 // due to lane reordering. To fix this, on every BITCAST we must perform two
6235 // v1 = REV v2i32 (implicit)
6237 // v3 = BITCAST v2i32 v2 to v4i16
6239 // v5 = REV v4i16 v4 (implicit)
6242 // This means an extra two instructions, but actually in most cases the two REV
6243 // instructions can be combined into one. For example:
6244 // (REV64_2s (REV64_4h X)) === (REV32_4h X)
6246 // There is also no 128-bit REV instruction. This must be synthesized with an
6249 // Most bitconverts require some sort of conversion. The only exceptions are:
6250 // a) Identity conversions - vNfX <-> vNiX
6251 // b) Single-lane-to-scalar - v1fX <-> fX or v1iX <-> iX
6254 // Natural vector casts (64 bit)
6255 def : Pat<(v8i8 (AArch64NvCast (v2i32 FPR64:$src))), (v8i8 FPR64:$src)>;
6256 def : Pat<(v4i16 (AArch64NvCast (v2i32 FPR64:$src))), (v4i16 FPR64:$src)>;
6257 def : Pat<(v4f16 (AArch64NvCast (v2i32 FPR64:$src))), (v4f16 FPR64:$src)>;
6258 def : Pat<(v2i32 (AArch64NvCast (v2i32 FPR64:$src))), (v2i32 FPR64:$src)>;
6259 def : Pat<(v2f32 (AArch64NvCast (v2i32 FPR64:$src))), (v2f32 FPR64:$src)>;
6260 def : Pat<(v1i64 (AArch64NvCast (v2i32 FPR64:$src))), (v1i64 FPR64:$src)>;
6262 def : Pat<(v8i8 (AArch64NvCast (v4i16 FPR64:$src))), (v8i8 FPR64:$src)>;
6263 def : Pat<(v4i16 (AArch64NvCast (v4i16 FPR64:$src))), (v4i16 FPR64:$src)>;
6264 def : Pat<(v4f16 (AArch64NvCast (v4i16 FPR64:$src))), (v4f16 FPR64:$src)>;
6265 def : Pat<(v2i32 (AArch64NvCast (v4i16 FPR64:$src))), (v2i32 FPR64:$src)>;
6266 def : Pat<(v1i64 (AArch64NvCast (v4i16 FPR64:$src))), (v1i64 FPR64:$src)>;
6268 def : Pat<(v8i8 (AArch64NvCast (v8i8 FPR64:$src))), (v8i8 FPR64:$src)>;
6269 def : Pat<(v4i16 (AArch64NvCast (v8i8 FPR64:$src))), (v4i16 FPR64:$src)>;
6270 def : Pat<(v4f16 (AArch64NvCast (v8i8 FPR64:$src))), (v4f16 FPR64:$src)>;
6271 def : Pat<(v2i32 (AArch64NvCast (v8i8 FPR64:$src))), (v2i32 FPR64:$src)>;
6272 def : Pat<(v2f32 (AArch64NvCast (v8i8 FPR64:$src))), (v2f32 FPR64:$src)>;
6273 def : Pat<(v1i64 (AArch64NvCast (v8i8 FPR64:$src))), (v1i64 FPR64:$src)>;
6275 def : Pat<(v8i8 (AArch64NvCast (f64 FPR64:$src))), (v8i8 FPR64:$src)>;
6276 def : Pat<(v4i16 (AArch64NvCast (f64 FPR64:$src))), (v4i16 FPR64:$src)>;
6277 def : Pat<(v4f16 (AArch64NvCast (f64 FPR64:$src))), (v4f16 FPR64:$src)>;
6278 def : Pat<(v2i32 (AArch64NvCast (f64 FPR64:$src))), (v2i32 FPR64:$src)>;
6279 def : Pat<(v2f32 (AArch64NvCast (f64 FPR64:$src))), (v2f32 FPR64:$src)>;
6280 def : Pat<(v1i64 (AArch64NvCast (f64 FPR64:$src))), (v1i64 FPR64:$src)>;
6281 def : Pat<(v1f64 (AArch64NvCast (f64 FPR64:$src))), (v1f64 FPR64:$src)>;
6283 def : Pat<(v8i8 (AArch64NvCast (v2f32 FPR64:$src))), (v8i8 FPR64:$src)>;
6284 def : Pat<(v4i16 (AArch64NvCast (v2f32 FPR64:$src))), (v4i16 FPR64:$src)>;
6285 def : Pat<(v2i32 (AArch64NvCast (v2f32 FPR64:$src))), (v2i32 FPR64:$src)>;
6286 def : Pat<(v2f32 (AArch64NvCast (v2f32 FPR64:$src))), (v2f32 FPR64:$src)>;
6287 def : Pat<(v1i64 (AArch64NvCast (v2f32 FPR64:$src))), (v1i64 FPR64:$src)>;
6288 def : Pat<(v1f64 (AArch64NvCast (v2f32 FPR64:$src))), (v1f64 FPR64:$src)>;
6290 // Natural vector casts (128 bit)
6291 def : Pat<(v16i8 (AArch64NvCast (v4i32 FPR128:$src))), (v16i8 FPR128:$src)>;
6292 def : Pat<(v8i16 (AArch64NvCast (v4i32 FPR128:$src))), (v8i16 FPR128:$src)>;
6293 def : Pat<(v8f16 (AArch64NvCast (v4i32 FPR128:$src))), (v8f16 FPR128:$src)>;
6294 def : Pat<(v4i32 (AArch64NvCast (v4i32 FPR128:$src))), (v4i32 FPR128:$src)>;
6295 def : Pat<(v4f32 (AArch64NvCast (v4i32 FPR128:$src))), (v4f32 FPR128:$src)>;
6296 def : Pat<(v2i64 (AArch64NvCast (v4i32 FPR128:$src))), (v2i64 FPR128:$src)>;
6297 def : Pat<(v2f64 (AArch64NvCast (v4i32 FPR128:$src))), (v2f64 FPR128:$src)>;
6299 def : Pat<(v16i8 (AArch64NvCast (v8i16 FPR128:$src))), (v16i8 FPR128:$src)>;
6300 def : Pat<(v8i16 (AArch64NvCast (v8i16 FPR128:$src))), (v8i16 FPR128:$src)>;
6301 def : Pat<(v8f16 (AArch64NvCast (v8i16 FPR128:$src))), (v8f16 FPR128:$src)>;
6302 def : Pat<(v4i32 (AArch64NvCast (v8i16 FPR128:$src))), (v4i32 FPR128:$src)>;
6303 def : Pat<(v2i64 (AArch64NvCast (v8i16 FPR128:$src))), (v2i64 FPR128:$src)>;
6304 def : Pat<(v4f32 (AArch64NvCast (v8i16 FPR128:$src))), (v4f32 FPR128:$src)>;
6305 def : Pat<(v2f64 (AArch64NvCast (v8i16 FPR128:$src))), (v2f64 FPR128:$src)>;
6307 def : Pat<(v16i8 (AArch64NvCast (v16i8 FPR128:$src))), (v16i8 FPR128:$src)>;
6308 def : Pat<(v8i16 (AArch64NvCast (v16i8 FPR128:$src))), (v8i16 FPR128:$src)>;
6309 def : Pat<(v8f16 (AArch64NvCast (v16i8 FPR128:$src))), (v8f16 FPR128:$src)>;
6310 def : Pat<(v4i32 (AArch64NvCast (v16i8 FPR128:$src))), (v4i32 FPR128:$src)>;
6311 def : Pat<(v2i64 (AArch64NvCast (v16i8 FPR128:$src))), (v2i64 FPR128:$src)>;
6312 def : Pat<(v4f32 (AArch64NvCast (v16i8 FPR128:$src))), (v4f32 FPR128:$src)>;
6313 def : Pat<(v2f64 (AArch64NvCast (v16i8 FPR128:$src))), (v2f64 FPR128:$src)>;
6315 def : Pat<(v16i8 (AArch64NvCast (v2i64 FPR128:$src))), (v16i8 FPR128:$src)>;
6316 def : Pat<(v8i16 (AArch64NvCast (v2i64 FPR128:$src))), (v8i16 FPR128:$src)>;
6317 def : Pat<(v8f16 (AArch64NvCast (v2i64 FPR128:$src))), (v8f16 FPR128:$src)>;
6318 def : Pat<(v4i32 (AArch64NvCast (v2i64 FPR128:$src))), (v4i32 FPR128:$src)>;
6319 def : Pat<(v2i64 (AArch64NvCast (v2i64 FPR128:$src))), (v2i64 FPR128:$src)>;
6320 def : Pat<(v4f32 (AArch64NvCast (v2i64 FPR128:$src))), (v4f32 FPR128:$src)>;
6321 def : Pat<(v2f64 (AArch64NvCast (v2i64 FPR128:$src))), (v2f64 FPR128:$src)>;
6323 def : Pat<(v16i8 (AArch64NvCast (v4f32 FPR128:$src))), (v16i8 FPR128:$src)>;
6324 def : Pat<(v8i16 (AArch64NvCast (v4f32 FPR128:$src))), (v8i16 FPR128:$src)>;
6325 def : Pat<(v4i32 (AArch64NvCast (v4f32 FPR128:$src))), (v4i32 FPR128:$src)>;
6326 def : Pat<(v4f32 (AArch64NvCast (v4f32 FPR128:$src))), (v4f32 FPR128:$src)>;
6327 def : Pat<(v2i64 (AArch64NvCast (v4f32 FPR128:$src))), (v2i64 FPR128:$src)>;
6328 def : Pat<(v8f16 (AArch64NvCast (v4f32 FPR128:$src))), (v8f16 FPR128:$src)>;
6329 def : Pat<(v2f64 (AArch64NvCast (v4f32 FPR128:$src))), (v2f64 FPR128:$src)>;
6331 def : Pat<(v16i8 (AArch64NvCast (v2f64 FPR128:$src))), (v16i8 FPR128:$src)>;
6332 def : Pat<(v8i16 (AArch64NvCast (v2f64 FPR128:$src))), (v8i16 FPR128:$src)>;
6333 def : Pat<(v4i32 (AArch64NvCast (v2f64 FPR128:$src))), (v4i32 FPR128:$src)>;
6334 def : Pat<(v2i64 (AArch64NvCast (v2f64 FPR128:$src))), (v2i64 FPR128:$src)>;
6335 def : Pat<(v2f64 (AArch64NvCast (v2f64 FPR128:$src))), (v2f64 FPR128:$src)>;
6336 def : Pat<(v8f16 (AArch64NvCast (v2f64 FPR128:$src))), (v8f16 FPR128:$src)>;
6337 def : Pat<(v4f32 (AArch64NvCast (v2f64 FPR128:$src))), (v4f32 FPR128:$src)>;
6339 let Predicates = [IsLE] in {
6340 def : Pat<(v8i8 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6341 def : Pat<(v4i16 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6342 def : Pat<(v2i32 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6343 def : Pat<(v4f16 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6344 def : Pat<(v2f32 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6346 def : Pat<(i64 (bitconvert (v8i8 V64:$Vn))),
6347 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6348 def : Pat<(i64 (bitconvert (v4i16 V64:$Vn))),
6349 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6350 def : Pat<(i64 (bitconvert (v2i32 V64:$Vn))),
6351 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6352 def : Pat<(i64 (bitconvert (v4f16 V64:$Vn))),
6353 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6354 def : Pat<(i64 (bitconvert (v2f32 V64:$Vn))),
6355 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6356 def : Pat<(i64 (bitconvert (v1f64 V64:$Vn))),
6357 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6359 let Predicates = [IsBE] in {
6360 def : Pat<(v8i8 (bitconvert GPR64:$Xn)),
6361 (REV64v8i8 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
6362 def : Pat<(v4i16 (bitconvert GPR64:$Xn)),
6363 (REV64v4i16 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
6364 def : Pat<(v2i32 (bitconvert GPR64:$Xn)),
6365 (REV64v2i32 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
6366 def : Pat<(v4f16 (bitconvert GPR64:$Xn)),
6367 (REV64v4i16 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
6368 def : Pat<(v2f32 (bitconvert GPR64:$Xn)),
6369 (REV64v2i32 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
6371 def : Pat<(i64 (bitconvert (v8i8 V64:$Vn))),
6372 (REV64v8i8 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
6373 def : Pat<(i64 (bitconvert (v4i16 V64:$Vn))),
6374 (REV64v4i16 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
6375 def : Pat<(i64 (bitconvert (v2i32 V64:$Vn))),
6376 (REV64v2i32 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
6377 def : Pat<(i64 (bitconvert (v4f16 V64:$Vn))),
6378 (REV64v4i16 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
6379 def : Pat<(i64 (bitconvert (v2f32 V64:$Vn))),
6380 (REV64v2i32 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
6382 def : Pat<(v1i64 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6383 def : Pat<(v1f64 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6384 def : Pat<(i64 (bitconvert (v1i64 V64:$Vn))),
6385 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6386 def : Pat<(v1i64 (scalar_to_vector GPR64:$Xn)),
6387 (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6388 def : Pat<(v1f64 (scalar_to_vector GPR64:$Xn)),
6389 (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6390 def : Pat<(v1f64 (scalar_to_vector (f64 FPR64:$Xn))), (v1f64 FPR64:$Xn)>;
6392 def : Pat<(f32 (bitconvert (i32 GPR32:$Xn))),
6393 (COPY_TO_REGCLASS GPR32:$Xn, FPR32)>;
6394 def : Pat<(i32 (bitconvert (f32 FPR32:$Xn))),
6395 (COPY_TO_REGCLASS FPR32:$Xn, GPR32)>;
6396 def : Pat<(f64 (bitconvert (i64 GPR64:$Xn))),
6397 (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6398 def : Pat<(i64 (bitconvert (f64 FPR64:$Xn))),
6399 (COPY_TO_REGCLASS FPR64:$Xn, GPR64)>;
6400 def : Pat<(i64 (bitconvert (v1f64 V64:$Vn))),
6401 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6403 let Predicates = [IsLE] in {
6404 def : Pat<(v1i64 (bitconvert (v2i32 FPR64:$src))), (v1i64 FPR64:$src)>;
6405 def : Pat<(v1i64 (bitconvert (v4i16 FPR64:$src))), (v1i64 FPR64:$src)>;
6406 def : Pat<(v1i64 (bitconvert (v8i8 FPR64:$src))), (v1i64 FPR64:$src)>;
6407 def : Pat<(v1i64 (bitconvert (v4f16 FPR64:$src))), (v1i64 FPR64:$src)>;
6408 def : Pat<(v1i64 (bitconvert (v2f32 FPR64:$src))), (v1i64 FPR64:$src)>;
6410 let Predicates = [IsBE] in {
6411 def : Pat<(v1i64 (bitconvert (v2i32 FPR64:$src))),
6412 (v1i64 (REV64v2i32 FPR64:$src))>;
6413 def : Pat<(v1i64 (bitconvert (v4i16 FPR64:$src))),
6414 (v1i64 (REV64v4i16 FPR64:$src))>;
6415 def : Pat<(v1i64 (bitconvert (v8i8 FPR64:$src))),
6416 (v1i64 (REV64v8i8 FPR64:$src))>;
6417 def : Pat<(v1i64 (bitconvert (v4f16 FPR64:$src))),
6418 (v1i64 (REV64v4i16 FPR64:$src))>;
6419 def : Pat<(v1i64 (bitconvert (v2f32 FPR64:$src))),
6420 (v1i64 (REV64v2i32 FPR64:$src))>;
6422 def : Pat<(v1i64 (bitconvert (v1f64 FPR64:$src))), (v1i64 FPR64:$src)>;
6423 def : Pat<(v1i64 (bitconvert (f64 FPR64:$src))), (v1i64 FPR64:$src)>;
6425 let Predicates = [IsLE] in {
6426 def : Pat<(v2i32 (bitconvert (v1i64 FPR64:$src))), (v2i32 FPR64:$src)>;
6427 def : Pat<(v2i32 (bitconvert (v4i16 FPR64:$src))), (v2i32 FPR64:$src)>;
6428 def : Pat<(v2i32 (bitconvert (v8i8 FPR64:$src))), (v2i32 FPR64:$src)>;
6429 def : Pat<(v2i32 (bitconvert (f64 FPR64:$src))), (v2i32 FPR64:$src)>;
6430 def : Pat<(v2i32 (bitconvert (v1f64 FPR64:$src))), (v2i32 FPR64:$src)>;
6431 def : Pat<(v2i32 (bitconvert (v4f16 FPR64:$src))), (v2i32 FPR64:$src)>;
6433 let Predicates = [IsBE] in {
6434 def : Pat<(v2i32 (bitconvert (v1i64 FPR64:$src))),
6435 (v2i32 (REV64v2i32 FPR64:$src))>;
6436 def : Pat<(v2i32 (bitconvert (v4i16 FPR64:$src))),
6437 (v2i32 (REV32v4i16 FPR64:$src))>;
6438 def : Pat<(v2i32 (bitconvert (v8i8 FPR64:$src))),
6439 (v2i32 (REV32v8i8 FPR64:$src))>;
6440 def : Pat<(v2i32 (bitconvert (f64 FPR64:$src))),
6441 (v2i32 (REV64v2i32 FPR64:$src))>;
6442 def : Pat<(v2i32 (bitconvert (v1f64 FPR64:$src))),
6443 (v2i32 (REV64v2i32 FPR64:$src))>;
6444 def : Pat<(v2i32 (bitconvert (v4f16 FPR64:$src))),
6445 (v2i32 (REV32v4i16 FPR64:$src))>;
6447 def : Pat<(v2i32 (bitconvert (v2f32 FPR64:$src))), (v2i32 FPR64:$src)>;
6449 let Predicates = [IsLE] in {
6450 def : Pat<(v4i16 (bitconvert (v1i64 FPR64:$src))), (v4i16 FPR64:$src)>;
6451 def : Pat<(v4i16 (bitconvert (v2i32 FPR64:$src))), (v4i16 FPR64:$src)>;
6452 def : Pat<(v4i16 (bitconvert (v8i8 FPR64:$src))), (v4i16 FPR64:$src)>;
6453 def : Pat<(v4i16 (bitconvert (f64 FPR64:$src))), (v4i16 FPR64:$src)>;
6454 def : Pat<(v4i16 (bitconvert (v2f32 FPR64:$src))), (v4i16 FPR64:$src)>;
6455 def : Pat<(v4i16 (bitconvert (v1f64 FPR64:$src))), (v4i16 FPR64:$src)>;
6457 let Predicates = [IsBE] in {
6458 def : Pat<(v4i16 (bitconvert (v1i64 FPR64:$src))),
6459 (v4i16 (REV64v4i16 FPR64:$src))>;
6460 def : Pat<(v4i16 (bitconvert (v2i32 FPR64:$src))),
6461 (v4i16 (REV32v4i16 FPR64:$src))>;
6462 def : Pat<(v4i16 (bitconvert (v8i8 FPR64:$src))),
6463 (v4i16 (REV16v8i8 FPR64:$src))>;
6464 def : Pat<(v4i16 (bitconvert (f64 FPR64:$src))),
6465 (v4i16 (REV64v4i16 FPR64:$src))>;
6466 def : Pat<(v4i16 (bitconvert (v2f32 FPR64:$src))),
6467 (v4i16 (REV32v4i16 FPR64:$src))>;
6468 def : Pat<(v4i16 (bitconvert (v1f64 FPR64:$src))),
6469 (v4i16 (REV64v4i16 FPR64:$src))>;
6471 def : Pat<(v4i16 (bitconvert (v4f16 FPR64:$src))), (v4i16 FPR64:$src)>;
6473 let Predicates = [IsLE] in {
6474 def : Pat<(v4f16 (bitconvert (v1i64 FPR64:$src))), (v4f16 FPR64:$src)>;
6475 def : Pat<(v4f16 (bitconvert (v2i32 FPR64:$src))), (v4f16 FPR64:$src)>;
6476 def : Pat<(v4f16 (bitconvert (v8i8 FPR64:$src))), (v4f16 FPR64:$src)>;
6477 def : Pat<(v4f16 (bitconvert (f64 FPR64:$src))), (v4f16 FPR64:$src)>;
6478 def : Pat<(v4f16 (bitconvert (v2f32 FPR64:$src))), (v4f16 FPR64:$src)>;
6479 def : Pat<(v4f16 (bitconvert (v1f64 FPR64:$src))), (v4f16 FPR64:$src)>;
6481 let Predicates = [IsBE] in {
6482 def : Pat<(v4f16 (bitconvert (v1i64 FPR64:$src))),
6483 (v4f16 (REV64v4i16 FPR64:$src))>;
6484 def : Pat<(v4f16 (bitconvert (v2i32 FPR64:$src))),
6485 (v4f16 (REV32v4i16 FPR64:$src))>;
6486 def : Pat<(v4f16 (bitconvert (v8i8 FPR64:$src))),
6487 (v4f16 (REV16v8i8 FPR64:$src))>;
6488 def : Pat<(v4f16 (bitconvert (f64 FPR64:$src))),
6489 (v4f16 (REV64v4i16 FPR64:$src))>;
6490 def : Pat<(v4f16 (bitconvert (v2f32 FPR64:$src))),
6491 (v4f16 (REV32v4i16 FPR64:$src))>;
6492 def : Pat<(v4f16 (bitconvert (v1f64 FPR64:$src))),
6493 (v4f16 (REV64v4i16 FPR64:$src))>;
6495 def : Pat<(v4f16 (bitconvert (v4i16 FPR64:$src))), (v4f16 FPR64:$src)>;
6497 let Predicates = [IsLE] in {
6498 def : Pat<(v8i8 (bitconvert (v1i64 FPR64:$src))), (v8i8 FPR64:$src)>;
6499 def : Pat<(v8i8 (bitconvert (v2i32 FPR64:$src))), (v8i8 FPR64:$src)>;
6500 def : Pat<(v8i8 (bitconvert (v4i16 FPR64:$src))), (v8i8 FPR64:$src)>;
6501 def : Pat<(v8i8 (bitconvert (f64 FPR64:$src))), (v8i8 FPR64:$src)>;
6502 def : Pat<(v8i8 (bitconvert (v2f32 FPR64:$src))), (v8i8 FPR64:$src)>;
6503 def : Pat<(v8i8 (bitconvert (v1f64 FPR64:$src))), (v8i8 FPR64:$src)>;
6504 def : Pat<(v8i8 (bitconvert (v4f16 FPR64:$src))), (v8i8 FPR64:$src)>;
6506 let Predicates = [IsBE] in {
6507 def : Pat<(v8i8 (bitconvert (v1i64 FPR64:$src))),
6508 (v8i8 (REV64v8i8 FPR64:$src))>;
6509 def : Pat<(v8i8 (bitconvert (v2i32 FPR64:$src))),
6510 (v8i8 (REV32v8i8 FPR64:$src))>;
6511 def : Pat<(v8i8 (bitconvert (v4i16 FPR64:$src))),
6512 (v8i8 (REV16v8i8 FPR64:$src))>;
6513 def : Pat<(v8i8 (bitconvert (f64 FPR64:$src))),
6514 (v8i8 (REV64v8i8 FPR64:$src))>;
6515 def : Pat<(v8i8 (bitconvert (v2f32 FPR64:$src))),
6516 (v8i8 (REV32v8i8 FPR64:$src))>;
6517 def : Pat<(v8i8 (bitconvert (v1f64 FPR64:$src))),
6518 (v8i8 (REV64v8i8 FPR64:$src))>;
6519 def : Pat<(v8i8 (bitconvert (v4f16 FPR64:$src))),
6520 (v8i8 (REV16v8i8 FPR64:$src))>;
6523 let Predicates = [IsLE] in {
6524 def : Pat<(f64 (bitconvert (v2i32 FPR64:$src))), (f64 FPR64:$src)>;
6525 def : Pat<(f64 (bitconvert (v4i16 FPR64:$src))), (f64 FPR64:$src)>;
6526 def : Pat<(f64 (bitconvert (v2f32 FPR64:$src))), (f64 FPR64:$src)>;
6527 def : Pat<(f64 (bitconvert (v8i8 FPR64:$src))), (f64 FPR64:$src)>;
6528 def : Pat<(f64 (bitconvert (v4f16 FPR64:$src))), (f64 FPR64:$src)>;
6530 let Predicates = [IsBE] in {
6531 def : Pat<(f64 (bitconvert (v2i32 FPR64:$src))),
6532 (f64 (REV64v2i32 FPR64:$src))>;
6533 def : Pat<(f64 (bitconvert (v4i16 FPR64:$src))),
6534 (f64 (REV64v4i16 FPR64:$src))>;
6535 def : Pat<(f64 (bitconvert (v2f32 FPR64:$src))),
6536 (f64 (REV64v2i32 FPR64:$src))>;
6537 def : Pat<(f64 (bitconvert (v8i8 FPR64:$src))),
6538 (f64 (REV64v8i8 FPR64:$src))>;
6539 def : Pat<(f64 (bitconvert (v4f16 FPR64:$src))),
6540 (f64 (REV64v4i16 FPR64:$src))>;
6542 def : Pat<(f64 (bitconvert (v1i64 FPR64:$src))), (f64 FPR64:$src)>;
6543 def : Pat<(f64 (bitconvert (v1f64 FPR64:$src))), (f64 FPR64:$src)>;
6545 let Predicates = [IsLE] in {
6546 def : Pat<(v1f64 (bitconvert (v2i32 FPR64:$src))), (v1f64 FPR64:$src)>;
6547 def : Pat<(v1f64 (bitconvert (v4i16 FPR64:$src))), (v1f64 FPR64:$src)>;
6548 def : Pat<(v1f64 (bitconvert (v8i8 FPR64:$src))), (v1f64 FPR64:$src)>;
6549 def : Pat<(v1f64 (bitconvert (v2f32 FPR64:$src))), (v1f64 FPR64:$src)>;
6550 def : Pat<(v1f64 (bitconvert (v4f16 FPR64:$src))), (v1f64 FPR64:$src)>;
6552 let Predicates = [IsBE] in {
6553 def : Pat<(v1f64 (bitconvert (v2i32 FPR64:$src))),
6554 (v1f64 (REV64v2i32 FPR64:$src))>;
6555 def : Pat<(v1f64 (bitconvert (v4i16 FPR64:$src))),
6556 (v1f64 (REV64v4i16 FPR64:$src))>;
6557 def : Pat<(v1f64 (bitconvert (v8i8 FPR64:$src))),
6558 (v1f64 (REV64v8i8 FPR64:$src))>;
6559 def : Pat<(v1f64 (bitconvert (v2f32 FPR64:$src))),
6560 (v1f64 (REV64v2i32 FPR64:$src))>;
6561 def : Pat<(v1f64 (bitconvert (v4f16 FPR64:$src))),
6562 (v1f64 (REV64v4i16 FPR64:$src))>;
6564 def : Pat<(v1f64 (bitconvert (v1i64 FPR64:$src))), (v1f64 FPR64:$src)>;
6565 def : Pat<(v1f64 (bitconvert (f64 FPR64:$src))), (v1f64 FPR64:$src)>;
6567 let Predicates = [IsLE] in {
6568 def : Pat<(v2f32 (bitconvert (v1i64 FPR64:$src))), (v2f32 FPR64:$src)>;
6569 def : Pat<(v2f32 (bitconvert (v4i16 FPR64:$src))), (v2f32 FPR64:$src)>;
6570 def : Pat<(v2f32 (bitconvert (v8i8 FPR64:$src))), (v2f32 FPR64:$src)>;
6571 def : Pat<(v2f32 (bitconvert (v1f64 FPR64:$src))), (v2f32 FPR64:$src)>;
6572 def : Pat<(v2f32 (bitconvert (f64 FPR64:$src))), (v2f32 FPR64:$src)>;
6573 def : Pat<(v2f32 (bitconvert (v4f16 FPR64:$src))), (v2f32 FPR64:$src)>;
6575 let Predicates = [IsBE] in {
6576 def : Pat<(v2f32 (bitconvert (v1i64 FPR64:$src))),
6577 (v2f32 (REV64v2i32 FPR64:$src))>;
6578 def : Pat<(v2f32 (bitconvert (v4i16 FPR64:$src))),
6579 (v2f32 (REV32v4i16 FPR64:$src))>;
6580 def : Pat<(v2f32 (bitconvert (v8i8 FPR64:$src))),
6581 (v2f32 (REV32v8i8 FPR64:$src))>;
6582 def : Pat<(v2f32 (bitconvert (v1f64 FPR64:$src))),
6583 (v2f32 (REV64v2i32 FPR64:$src))>;
6584 def : Pat<(v2f32 (bitconvert (f64 FPR64:$src))),
6585 (v2f32 (REV64v2i32 FPR64:$src))>;
6586 def : Pat<(v2f32 (bitconvert (v4f16 FPR64:$src))),
6587 (v2f32 (REV32v4i16 FPR64:$src))>;
6589 def : Pat<(v2f32 (bitconvert (v2i32 FPR64:$src))), (v2f32 FPR64:$src)>;
6591 let Predicates = [IsLE] in {
6592 def : Pat<(f128 (bitconvert (v2i64 FPR128:$src))), (f128 FPR128:$src)>;
6593 def : Pat<(f128 (bitconvert (v4i32 FPR128:$src))), (f128 FPR128:$src)>;
6594 def : Pat<(f128 (bitconvert (v8i16 FPR128:$src))), (f128 FPR128:$src)>;
6595 def : Pat<(f128 (bitconvert (v2f64 FPR128:$src))), (f128 FPR128:$src)>;
6596 def : Pat<(f128 (bitconvert (v4f32 FPR128:$src))), (f128 FPR128:$src)>;
6597 def : Pat<(f128 (bitconvert (v8f16 FPR128:$src))), (f128 FPR128:$src)>;
6598 def : Pat<(f128 (bitconvert (v16i8 FPR128:$src))), (f128 FPR128:$src)>;
6600 let Predicates = [IsBE] in {
6601 def : Pat<(f128 (bitconvert (v2i64 FPR128:$src))),
6602 (f128 (EXTv16i8 FPR128:$src, FPR128:$src, (i32 8)))>;
6603 def : Pat<(f128 (bitconvert (v4i32 FPR128:$src))),
6604 (f128 (EXTv16i8 (REV64v4i32 FPR128:$src),
6605 (REV64v4i32 FPR128:$src), (i32 8)))>;
6606 def : Pat<(f128 (bitconvert (v8i16 FPR128:$src))),
6607 (f128 (EXTv16i8 (REV64v8i16 FPR128:$src),
6608 (REV64v8i16 FPR128:$src), (i32 8)))>;
6609 def : Pat<(f128 (bitconvert (v8f16 FPR128:$src))),
6610 (f128 (EXTv16i8 (REV64v8i16 FPR128:$src),
6611 (REV64v8i16 FPR128:$src), (i32 8)))>;
6612 def : Pat<(f128 (bitconvert (v2f64 FPR128:$src))),
6613 (f128 (EXTv16i8 FPR128:$src, FPR128:$src, (i32 8)))>;
6614 def : Pat<(f128 (bitconvert (v4f32 FPR128:$src))),
6615 (f128 (EXTv16i8 (REV64v4i32 FPR128:$src),
6616 (REV64v4i32 FPR128:$src), (i32 8)))>;
6617 def : Pat<(f128 (bitconvert (v16i8 FPR128:$src))),
6618 (f128 (EXTv16i8 (REV64v16i8 FPR128:$src),
6619 (REV64v16i8 FPR128:$src), (i32 8)))>;
6622 let Predicates = [IsLE] in {
6623 def : Pat<(v2f64 (bitconvert (f128 FPR128:$src))), (v2f64 FPR128:$src)>;
6624 def : Pat<(v2f64 (bitconvert (v4i32 FPR128:$src))), (v2f64 FPR128:$src)>;
6625 def : Pat<(v2f64 (bitconvert (v8i16 FPR128:$src))), (v2f64 FPR128:$src)>;
6626 def : Pat<(v2f64 (bitconvert (v8f16 FPR128:$src))), (v2f64 FPR128:$src)>;
6627 def : Pat<(v2f64 (bitconvert (v16i8 FPR128:$src))), (v2f64 FPR128:$src)>;
6628 def : Pat<(v2f64 (bitconvert (v4f32 FPR128:$src))), (v2f64 FPR128:$src)>;
6630 let Predicates = [IsBE] in {
6631 def : Pat<(v2f64 (bitconvert (f128 FPR128:$src))),
6632 (v2f64 (EXTv16i8 FPR128:$src,
6633 FPR128:$src, (i32 8)))>;
6634 def : Pat<(v2f64 (bitconvert (v4i32 FPR128:$src))),
6635 (v2f64 (REV64v4i32 FPR128:$src))>;
6636 def : Pat<(v2f64 (bitconvert (v8i16 FPR128:$src))),
6637 (v2f64 (REV64v8i16 FPR128:$src))>;
6638 def : Pat<(v2f64 (bitconvert (v8f16 FPR128:$src))),
6639 (v2f64 (REV64v8i16 FPR128:$src))>;
6640 def : Pat<(v2f64 (bitconvert (v16i8 FPR128:$src))),
6641 (v2f64 (REV64v16i8 FPR128:$src))>;
6642 def : Pat<(v2f64 (bitconvert (v4f32 FPR128:$src))),
6643 (v2f64 (REV64v4i32 FPR128:$src))>;
6645 def : Pat<(v2f64 (bitconvert (v2i64 FPR128:$src))), (v2f64 FPR128:$src)>;
6647 let Predicates = [IsLE] in {
6648 def : Pat<(v4f32 (bitconvert (f128 FPR128:$src))), (v4f32 FPR128:$src)>;
6649 def : Pat<(v4f32 (bitconvert (v8i16 FPR128:$src))), (v4f32 FPR128:$src)>;
6650 def : Pat<(v4f32 (bitconvert (v8f16 FPR128:$src))), (v4f32 FPR128:$src)>;
6651 def : Pat<(v4f32 (bitconvert (v16i8 FPR128:$src))), (v4f32 FPR128:$src)>;
6652 def : Pat<(v4f32 (bitconvert (v2i64 FPR128:$src))), (v4f32 FPR128:$src)>;
6653 def : Pat<(v4f32 (bitconvert (v2f64 FPR128:$src))), (v4f32 FPR128:$src)>;
6655 let Predicates = [IsBE] in {
6656 def : Pat<(v4f32 (bitconvert (f128 FPR128:$src))),
6657 (v4f32 (EXTv16i8 (REV64v4i32 FPR128:$src),
6658 (REV64v4i32 FPR128:$src), (i32 8)))>;
6659 def : Pat<(v4f32 (bitconvert (v8i16 FPR128:$src))),
6660 (v4f32 (REV32v8i16 FPR128:$src))>;
6661 def : Pat<(v4f32 (bitconvert (v8f16 FPR128:$src))),
6662 (v4f32 (REV32v8i16 FPR128:$src))>;
6663 def : Pat<(v4f32 (bitconvert (v16i8 FPR128:$src))),
6664 (v4f32 (REV32v16i8 FPR128:$src))>;
6665 def : Pat<(v4f32 (bitconvert (v2i64 FPR128:$src))),
6666 (v4f32 (REV64v4i32 FPR128:$src))>;
6667 def : Pat<(v4f32 (bitconvert (v2f64 FPR128:$src))),
6668 (v4f32 (REV64v4i32 FPR128:$src))>;
6670 def : Pat<(v4f32 (bitconvert (v4i32 FPR128:$src))), (v4f32 FPR128:$src)>;
6672 let Predicates = [IsLE] in {
6673 def : Pat<(v2i64 (bitconvert (f128 FPR128:$src))), (v2i64 FPR128:$src)>;
6674 def : Pat<(v2i64 (bitconvert (v4i32 FPR128:$src))), (v2i64 FPR128:$src)>;
6675 def : Pat<(v2i64 (bitconvert (v8i16 FPR128:$src))), (v2i64 FPR128:$src)>;
6676 def : Pat<(v2i64 (bitconvert (v16i8 FPR128:$src))), (v2i64 FPR128:$src)>;
6677 def : Pat<(v2i64 (bitconvert (v4f32 FPR128:$src))), (v2i64 FPR128:$src)>;
6678 def : Pat<(v2i64 (bitconvert (v8f16 FPR128:$src))), (v2i64 FPR128:$src)>;
6680 let Predicates = [IsBE] in {
6681 def : Pat<(v2i64 (bitconvert (f128 FPR128:$src))),
6682 (v2i64 (EXTv16i8 FPR128:$src,
6683 FPR128:$src, (i32 8)))>;
6684 def : Pat<(v2i64 (bitconvert (v4i32 FPR128:$src))),
6685 (v2i64 (REV64v4i32 FPR128:$src))>;
6686 def : Pat<(v2i64 (bitconvert (v8i16 FPR128:$src))),
6687 (v2i64 (REV64v8i16 FPR128:$src))>;
6688 def : Pat<(v2i64 (bitconvert (v16i8 FPR128:$src))),
6689 (v2i64 (REV64v16i8 FPR128:$src))>;
6690 def : Pat<(v2i64 (bitconvert (v4f32 FPR128:$src))),
6691 (v2i64 (REV64v4i32 FPR128:$src))>;
6692 def : Pat<(v2i64 (bitconvert (v8f16 FPR128:$src))),
6693 (v2i64 (REV64v8i16 FPR128:$src))>;
6695 def : Pat<(v2i64 (bitconvert (v2f64 FPR128:$src))), (v2i64 FPR128:$src)>;
6697 let Predicates = [IsLE] in {
6698 def : Pat<(v4i32 (bitconvert (f128 FPR128:$src))), (v4i32 FPR128:$src)>;
6699 def : Pat<(v4i32 (bitconvert (v2i64 FPR128:$src))), (v4i32 FPR128:$src)>;
6700 def : Pat<(v4i32 (bitconvert (v8i16 FPR128:$src))), (v4i32 FPR128:$src)>;
6701 def : Pat<(v4i32 (bitconvert (v16i8 FPR128:$src))), (v4i32 FPR128:$src)>;
6702 def : Pat<(v4i32 (bitconvert (v2f64 FPR128:$src))), (v4i32 FPR128:$src)>;
6703 def : Pat<(v4i32 (bitconvert (v8f16 FPR128:$src))), (v4i32 FPR128:$src)>;
6705 let Predicates = [IsBE] in {
6706 def : Pat<(v4i32 (bitconvert (f128 FPR128:$src))),
6707 (v4i32 (EXTv16i8 (REV64v4i32 FPR128:$src),
6708 (REV64v4i32 FPR128:$src),
6710 def : Pat<(v4i32 (bitconvert (v2i64 FPR128:$src))),
6711 (v4i32 (REV64v4i32 FPR128:$src))>;
6712 def : Pat<(v4i32 (bitconvert (v8i16 FPR128:$src))),
6713 (v4i32 (REV32v8i16 FPR128:$src))>;
6714 def : Pat<(v4i32 (bitconvert (v16i8 FPR128:$src))),
6715 (v4i32 (REV32v16i8 FPR128:$src))>;
6716 def : Pat<(v4i32 (bitconvert (v2f64 FPR128:$src))),
6717 (v4i32 (REV64v4i32 FPR128:$src))>;
6718 def : Pat<(v4i32 (bitconvert (v8f16 FPR128:$src))),
6719 (v4i32 (REV32v8i16 FPR128:$src))>;
6721 def : Pat<(v4i32 (bitconvert (v4f32 FPR128:$src))), (v4i32 FPR128:$src)>;
6723 let Predicates = [IsLE] in {
6724 def : Pat<(v8i16 (bitconvert (f128 FPR128:$src))), (v8i16 FPR128:$src)>;
6725 def : Pat<(v8i16 (bitconvert (v2i64 FPR128:$src))), (v8i16 FPR128:$src)>;
6726 def : Pat<(v8i16 (bitconvert (v4i32 FPR128:$src))), (v8i16 FPR128:$src)>;
6727 def : Pat<(v8i16 (bitconvert (v16i8 FPR128:$src))), (v8i16 FPR128:$src)>;
6728 def : Pat<(v8i16 (bitconvert (v2f64 FPR128:$src))), (v8i16 FPR128:$src)>;
6729 def : Pat<(v8i16 (bitconvert (v4f32 FPR128:$src))), (v8i16 FPR128:$src)>;
6731 let Predicates = [IsBE] in {
6732 def : Pat<(v8i16 (bitconvert (f128 FPR128:$src))),
6733 (v8i16 (EXTv16i8 (REV64v8i16 FPR128:$src),
6734 (REV64v8i16 FPR128:$src),
6736 def : Pat<(v8i16 (bitconvert (v2i64 FPR128:$src))),
6737 (v8i16 (REV64v8i16 FPR128:$src))>;
6738 def : Pat<(v8i16 (bitconvert (v4i32 FPR128:$src))),
6739 (v8i16 (REV32v8i16 FPR128:$src))>;
6740 def : Pat<(v8i16 (bitconvert (v16i8 FPR128:$src))),
6741 (v8i16 (REV16v16i8 FPR128:$src))>;
6742 def : Pat<(v8i16 (bitconvert (v2f64 FPR128:$src))),
6743 (v8i16 (REV64v8i16 FPR128:$src))>;
6744 def : Pat<(v8i16 (bitconvert (v4f32 FPR128:$src))),
6745 (v8i16 (REV32v8i16 FPR128:$src))>;
6747 def : Pat<(v8i16 (bitconvert (v8f16 FPR128:$src))), (v8i16 FPR128:$src)>;
6749 let Predicates = [IsLE] in {
6750 def : Pat<(v8f16 (bitconvert (f128 FPR128:$src))), (v8f16 FPR128:$src)>;
6751 def : Pat<(v8f16 (bitconvert (v2i64 FPR128:$src))), (v8f16 FPR128:$src)>;
6752 def : Pat<(v8f16 (bitconvert (v4i32 FPR128:$src))), (v8f16 FPR128:$src)>;
6753 def : Pat<(v8f16 (bitconvert (v16i8 FPR128:$src))), (v8f16 FPR128:$src)>;
6754 def : Pat<(v8f16 (bitconvert (v2f64 FPR128:$src))), (v8f16 FPR128:$src)>;
6755 def : Pat<(v8f16 (bitconvert (v4f32 FPR128:$src))), (v8f16 FPR128:$src)>;
6757 let Predicates = [IsBE] in {
6758 def : Pat<(v8f16 (bitconvert (f128 FPR128:$src))),
6759 (v8f16 (EXTv16i8 (REV64v8i16 FPR128:$src),
6760 (REV64v8i16 FPR128:$src),
6762 def : Pat<(v8f16 (bitconvert (v2i64 FPR128:$src))),
6763 (v8f16 (REV64v8i16 FPR128:$src))>;
6764 def : Pat<(v8f16 (bitconvert (v4i32 FPR128:$src))),
6765 (v8f16 (REV32v8i16 FPR128:$src))>;
6766 def : Pat<(v8f16 (bitconvert (v16i8 FPR128:$src))),
6767 (v8f16 (REV16v16i8 FPR128:$src))>;
6768 def : Pat<(v8f16 (bitconvert (v2f64 FPR128:$src))),
6769 (v8f16 (REV64v8i16 FPR128:$src))>;
6770 def : Pat<(v8f16 (bitconvert (v4f32 FPR128:$src))),
6771 (v8f16 (REV32v8i16 FPR128:$src))>;
6773 def : Pat<(v8f16 (bitconvert (v8i16 FPR128:$src))), (v8f16 FPR128:$src)>;
6775 let Predicates = [IsLE] in {
6776 def : Pat<(v16i8 (bitconvert (f128 FPR128:$src))), (v16i8 FPR128:$src)>;
6777 def : Pat<(v16i8 (bitconvert (v2i64 FPR128:$src))), (v16i8 FPR128:$src)>;
6778 def : Pat<(v16i8 (bitconvert (v4i32 FPR128:$src))), (v16i8 FPR128:$src)>;
6779 def : Pat<(v16i8 (bitconvert (v8i16 FPR128:$src))), (v16i8 FPR128:$src)>;
6780 def : Pat<(v16i8 (bitconvert (v2f64 FPR128:$src))), (v16i8 FPR128:$src)>;
6781 def : Pat<(v16i8 (bitconvert (v4f32 FPR128:$src))), (v16i8 FPR128:$src)>;
6782 def : Pat<(v16i8 (bitconvert (v8f16 FPR128:$src))), (v16i8 FPR128:$src)>;
6784 let Predicates = [IsBE] in {
6785 def : Pat<(v16i8 (bitconvert (f128 FPR128:$src))),
6786 (v16i8 (EXTv16i8 (REV64v16i8 FPR128:$src),
6787 (REV64v16i8 FPR128:$src),
6789 def : Pat<(v16i8 (bitconvert (v2i64 FPR128:$src))),
6790 (v16i8 (REV64v16i8 FPR128:$src))>;
6791 def : Pat<(v16i8 (bitconvert (v4i32 FPR128:$src))),
6792 (v16i8 (REV32v16i8 FPR128:$src))>;
6793 def : Pat<(v16i8 (bitconvert (v8i16 FPR128:$src))),
6794 (v16i8 (REV16v16i8 FPR128:$src))>;
6795 def : Pat<(v16i8 (bitconvert (v2f64 FPR128:$src))),
6796 (v16i8 (REV64v16i8 FPR128:$src))>;
6797 def : Pat<(v16i8 (bitconvert (v4f32 FPR128:$src))),
6798 (v16i8 (REV32v16i8 FPR128:$src))>;
6799 def : Pat<(v16i8 (bitconvert (v8f16 FPR128:$src))),
6800 (v16i8 (REV16v16i8 FPR128:$src))>;
6803 def : Pat<(v4i16 (extract_subvector V128:$Rn, (i64 0))),
6804 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6805 def : Pat<(v8i8 (extract_subvector V128:$Rn, (i64 0))),
6806 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6807 def : Pat<(v2f32 (extract_subvector V128:$Rn, (i64 0))),
6808 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6809 def : Pat<(v4f16 (extract_subvector V128:$Rn, (i64 0))),
6810 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6811 def : Pat<(v2i32 (extract_subvector V128:$Rn, (i64 0))),
6812 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6813 def : Pat<(v1i64 (extract_subvector V128:$Rn, (i64 0))),
6814 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6815 def : Pat<(v1f64 (extract_subvector V128:$Rn, (i64 0))),
6816 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6818 def : Pat<(v8i8 (extract_subvector (v16i8 FPR128:$Rn), (i64 1))),
6819 (EXTRACT_SUBREG (DUPv2i64lane FPR128:$Rn, 1), dsub)>;
6820 def : Pat<(v4i16 (extract_subvector (v8i16 FPR128:$Rn), (i64 1))),
6821 (EXTRACT_SUBREG (DUPv2i64lane FPR128:$Rn, 1), dsub)>;
6822 def : Pat<(v2i32 (extract_subvector (v4i32 FPR128:$Rn), (i64 1))),
6823 (EXTRACT_SUBREG (DUPv2i64lane FPR128:$Rn, 1), dsub)>;
6824 def : Pat<(v1i64 (extract_subvector (v2i64 FPR128:$Rn), (i64 1))),
6825 (EXTRACT_SUBREG (DUPv2i64lane FPR128:$Rn, 1), dsub)>;
6827 // A 64-bit subvector insert to the first 128-bit vector position
6828 // is a subregister copy that needs no instruction.
6829 multiclass InsertSubvectorUndef<ValueType Ty> {
6830 def : Pat<(insert_subvector undef, (v1i64 FPR64:$src), (Ty 0)),
6831 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6832 def : Pat<(insert_subvector undef, (v1f64 FPR64:$src), (Ty 0)),
6833 (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6834 def : Pat<(insert_subvector undef, (v2i32 FPR64:$src), (Ty 0)),
6835 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6836 def : Pat<(insert_subvector undef, (v2f32 FPR64:$src), (Ty 0)),
6837 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6838 def : Pat<(insert_subvector undef, (v4i16 FPR64:$src), (Ty 0)),
6839 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6840 def : Pat<(insert_subvector undef, (v4f16 FPR64:$src), (Ty 0)),
6841 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6842 def : Pat<(insert_subvector undef, (v8i8 FPR64:$src), (Ty 0)),
6843 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6846 defm : InsertSubvectorUndef<i32>;
6847 defm : InsertSubvectorUndef<i64>;
6849 // Use pair-wise add instructions when summing up the lanes for v2f64, v2i64
6851 def : Pat<(i64 (add (vector_extract (v2i64 FPR128:$Rn), (i64 0)),
6852 (vector_extract (v2i64 FPR128:$Rn), (i64 1)))),
6853 (i64 (ADDPv2i64p (v2i64 FPR128:$Rn)))>;
6854 def : Pat<(f64 (fadd (vector_extract (v2f64 FPR128:$Rn), (i64 0)),
6855 (vector_extract (v2f64 FPR128:$Rn), (i64 1)))),
6856 (f64 (FADDPv2i64p (v2f64 FPR128:$Rn)))>;
6857 // vector_extract on 64-bit vectors gets promoted to a 128 bit vector,
6858 // so we match on v4f32 here, not v2f32. This will also catch adding
6859 // the low two lanes of a true v4f32 vector.
6860 def : Pat<(fadd (vector_extract (v4f32 FPR128:$Rn), (i64 0)),
6861 (vector_extract (v4f32 FPR128:$Rn), (i64 1))),
6862 (f32 (FADDPv2i32p (EXTRACT_SUBREG FPR128:$Rn, dsub)))>;
6864 // Scalar 64-bit shifts in FPR64 registers.
6865 def : Pat<(i64 (int_aarch64_neon_sshl (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
6866 (SSHLv1i64 FPR64:$Rn, FPR64:$Rm)>;
6867 def : Pat<(i64 (int_aarch64_neon_ushl (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
6868 (USHLv1i64 FPR64:$Rn, FPR64:$Rm)>;
6869 def : Pat<(i64 (int_aarch64_neon_srshl (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
6870 (SRSHLv1i64 FPR64:$Rn, FPR64:$Rm)>;
6871 def : Pat<(i64 (int_aarch64_neon_urshl (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
6872 (URSHLv1i64 FPR64:$Rn, FPR64:$Rm)>;
6874 // Patterns for nontemporal/no-allocate stores.
6875 // We have to resort to tricks to turn a single-input store into a store pair,
6876 // because there is no single-input nontemporal store, only STNP.
6877 let Predicates = [IsLE] in {
6878 let AddedComplexity = 15 in {
6879 class NTStore128Pat<ValueType VT> :
6880 Pat<(nontemporalstore (VT FPR128:$Rt),
6881 (am_indexed7s64 GPR64sp:$Rn, simm7s8:$offset)),
6882 (STNPDi (EXTRACT_SUBREG FPR128:$Rt, dsub),
6883 (CPYi64 FPR128:$Rt, (i64 1)),
6884 GPR64sp:$Rn, simm7s8:$offset)>;
6886 def : NTStore128Pat<v2i64>;
6887 def : NTStore128Pat<v4i32>;
6888 def : NTStore128Pat<v8i16>;
6889 def : NTStore128Pat<v16i8>;
6891 class NTStore64Pat<ValueType VT> :
6892 Pat<(nontemporalstore (VT FPR64:$Rt),
6893 (am_indexed7s32 GPR64sp:$Rn, simm7s4:$offset)),
6894 (STNPSi (EXTRACT_SUBREG FPR64:$Rt, ssub),
6895 (CPYi32 (SUBREG_TO_REG (i64 0), FPR64:$Rt, dsub), (i64 1)),
6896 GPR64sp:$Rn, simm7s4:$offset)>;
6898 // FIXME: Shouldn't v1f64 loads/stores be promoted to v1i64?
6899 def : NTStore64Pat<v1f64>;
6900 def : NTStore64Pat<v1i64>;
6901 def : NTStore64Pat<v2i32>;
6902 def : NTStore64Pat<v4i16>;
6903 def : NTStore64Pat<v8i8>;
6905 def : Pat<(nontemporalstore GPR64:$Rt,
6906 (am_indexed7s32 GPR64sp:$Rn, simm7s4:$offset)),
6907 (STNPWi (EXTRACT_SUBREG GPR64:$Rt, sub_32),
6908 (EXTRACT_SUBREG (UBFMXri GPR64:$Rt, 32, 63), sub_32),
6909 GPR64sp:$Rn, simm7s4:$offset)>;
6910 } // AddedComplexity=10
6911 } // Predicates = [IsLE]
6913 // Tail call return handling. These are all compiler pseudo-instructions,
6914 // so no encoding information or anything like that.
6915 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in {
6916 def TCRETURNdi : Pseudo<(outs), (ins i64imm:$dst, i32imm:$FPDiff), []>,
6917 Sched<[WriteBrReg]>;
6918 def TCRETURNri : Pseudo<(outs), (ins tcGPR64:$dst, i32imm:$FPDiff), []>,
6919 Sched<[WriteBrReg]>;
6920 // Indirect tail-call with any register allowed, used by MachineOutliner when
6921 // this is proven safe.
6922 // FIXME: If we have to add any more hacks like this, we should instead relax
6923 // some verifier checks for outlined functions.
6924 def TCRETURNriALL : Pseudo<(outs), (ins GPR64:$dst, i32imm:$FPDiff), []>,
6925 Sched<[WriteBrReg]>;
6926 // Indirect tail-call limited to only use registers (x16 and x17) which are
6927 // allowed to tail-call a "BTI c" instruction.
6928 def TCRETURNriBTI : Pseudo<(outs), (ins rtcGPR64:$dst, i32imm:$FPDiff), []>,
6929 Sched<[WriteBrReg]>;
6932 def : Pat<(AArch64tcret tcGPR64:$dst, (i32 timm:$FPDiff)),
6933 (TCRETURNri tcGPR64:$dst, imm:$FPDiff)>,
6934 Requires<[NotUseBTI]>;
6935 def : Pat<(AArch64tcret rtcGPR64:$dst, (i32 timm:$FPDiff)),
6936 (TCRETURNriBTI rtcGPR64:$dst, imm:$FPDiff)>,
6938 def : Pat<(AArch64tcret tglobaladdr:$dst, (i32 timm:$FPDiff)),
6939 (TCRETURNdi texternalsym:$dst, imm:$FPDiff)>;
6940 def : Pat<(AArch64tcret texternalsym:$dst, (i32 timm:$FPDiff)),
6941 (TCRETURNdi texternalsym:$dst, imm:$FPDiff)>;
6943 def MOVMCSym : Pseudo<(outs GPR64:$dst), (ins i64imm:$sym), []>, Sched<[]>;
6944 def : Pat<(i64 (AArch64LocalRecover mcsym:$sym)), (MOVMCSym mcsym:$sym)>;
6946 include "AArch64InstrAtomics.td"
6947 include "AArch64SVEInstrInfo.td"