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 HasPMU : Predicate<"Subtarget->hasPMU()">,
66 AssemblerPredicate<"FeaturePMU", "pmu">;
68 def HasTLB_RMI : Predicate<"Subtarget->hasTLB_RMI()">,
69 AssemblerPredicate<"FeatureTLB_RMI", "tlb-rmi">;
71 def HasFMI : Predicate<"Subtarget->hasFMI()">,
72 AssemblerPredicate<"FeatureFMI", "fmi">;
74 def HasRCPC_IMMO : Predicate<"Subtarget->hasRCPCImm()">,
75 AssemblerPredicate<"FeatureRCPC_IMMO", "rcpc-immo">;
77 def HasFPARMv8 : Predicate<"Subtarget->hasFPARMv8()">,
78 AssemblerPredicate<"FeatureFPARMv8", "fp-armv8">;
79 def HasNEON : Predicate<"Subtarget->hasNEON()">,
80 AssemblerPredicate<"FeatureNEON", "neon">;
81 def HasCrypto : Predicate<"Subtarget->hasCrypto()">,
82 AssemblerPredicate<"FeatureCrypto", "crypto">;
83 def HasSM4 : Predicate<"Subtarget->hasSM4()">,
84 AssemblerPredicate<"FeatureSM4", "sm4">;
85 def HasSHA3 : Predicate<"Subtarget->hasSHA3()">,
86 AssemblerPredicate<"FeatureSHA3", "sha3">;
87 def HasSHA2 : Predicate<"Subtarget->hasSHA2()">,
88 AssemblerPredicate<"FeatureSHA2", "sha2">;
89 def HasAES : Predicate<"Subtarget->hasAES()">,
90 AssemblerPredicate<"FeatureAES", "aes">;
91 def HasDotProd : Predicate<"Subtarget->hasDotProd()">,
92 AssemblerPredicate<"FeatureDotProd", "dotprod">;
93 def HasCRC : Predicate<"Subtarget->hasCRC()">,
94 AssemblerPredicate<"FeatureCRC", "crc">;
95 def HasLSE : Predicate<"Subtarget->hasLSE()">,
96 AssemblerPredicate<"FeatureLSE", "lse">;
97 def HasRAS : Predicate<"Subtarget->hasRAS()">,
98 AssemblerPredicate<"FeatureRAS", "ras">;
99 def HasRDM : Predicate<"Subtarget->hasRDM()">,
100 AssemblerPredicate<"FeatureRDM", "rdm">;
101 def HasPerfMon : Predicate<"Subtarget->hasPerfMon()">;
102 def HasFullFP16 : Predicate<"Subtarget->hasFullFP16()">,
103 AssemblerPredicate<"FeatureFullFP16", "fullfp16">;
104 def HasFP16FML : Predicate<"Subtarget->hasFP16FML()">,
105 AssemblerPredicate<"FeatureFP16FML", "fp16fml">;
106 def HasSPE : Predicate<"Subtarget->hasSPE()">,
107 AssemblerPredicate<"FeatureSPE", "spe">;
108 def HasFuseAES : Predicate<"Subtarget->hasFuseAES()">,
109 AssemblerPredicate<"FeatureFuseAES",
111 def HasSVE : Predicate<"Subtarget->hasSVE()">,
112 AssemblerPredicate<"FeatureSVE", "sve">;
113 def HasSVE2 : Predicate<"Subtarget->hasSVE2()">,
114 AssemblerPredicate<"FeatureSVE2", "sve2">;
115 def HasSVE2AES : Predicate<"Subtarget->hasSVE2AES()">,
116 AssemblerPredicate<"FeatureSVE2AES", "sve2-aes">;
117 def HasSVE2SM4 : Predicate<"Subtarget->hasSVE2SM4()">,
118 AssemblerPredicate<"FeatureSVE2SM4", "sve2-sm4">;
119 def HasSVE2SHA3 : Predicate<"Subtarget->hasSVE2SHA3()">,
120 AssemblerPredicate<"FeatureSVE2SHA3", "sve2-sha3">;
121 def HasSVE2BitPerm : Predicate<"Subtarget->hasSVE2BitPerm()">,
122 AssemblerPredicate<"FeatureSVE2BitPerm", "sve2-bitperm">;
123 def HasRCPC : Predicate<"Subtarget->hasRCPC()">,
124 AssemblerPredicate<"FeatureRCPC", "rcpc">;
125 def HasAltNZCV : Predicate<"Subtarget->hasAlternativeNZCV()">,
126 AssemblerPredicate<"FeatureAltFPCmp", "altnzcv">;
127 def HasFRInt3264 : Predicate<"Subtarget->hasFRInt3264()">,
128 AssemblerPredicate<"FeatureFRInt3264", "frint3264">;
129 def HasSB : Predicate<"Subtarget->hasSB()">,
130 AssemblerPredicate<"FeatureSB", "sb">;
131 def HasPredRes : Predicate<"Subtarget->hasPredRes()">,
132 AssemblerPredicate<"FeaturePredRes", "predres">;
133 def HasCCDP : Predicate<"Subtarget->hasCCDP()">,
134 AssemblerPredicate<"FeatureCacheDeepPersist", "ccdp">;
135 def HasBTI : Predicate<"Subtarget->hasBTI()">,
136 AssemblerPredicate<"FeatureBranchTargetId", "bti">;
137 def HasMTE : Predicate<"Subtarget->hasMTE()">,
138 AssemblerPredicate<"FeatureMTE", "mte">;
139 def HasTME : Predicate<"Subtarget->hasTME()">,
140 AssemblerPredicate<"FeatureTME", "tme">;
141 def HasETE : Predicate<"Subtarget->hasETE()">,
142 AssemblerPredicate<"FeatureETE", "ete">;
143 def HasTRBE : Predicate<"Subtarget->hasTRBE()">,
144 AssemblerPredicate<"FeatureTRBE", "trbe">;
145 def IsLE : Predicate<"Subtarget->isLittleEndian()">;
146 def IsBE : Predicate<"!Subtarget->isLittleEndian()">;
147 def IsWindows : Predicate<"Subtarget->isTargetWindows()">;
148 def UseAlternateSExtLoadCVTF32
149 : Predicate<"Subtarget->useAlternateSExtLoadCVTF32Pattern()">;
151 def UseNegativeImmediates
152 : Predicate<"false">, AssemblerPredicate<"!FeatureNoNegativeImmediates",
153 "NegativeImmediates">;
155 def AArch64LocalRecover : SDNode<"ISD::LOCAL_RECOVER",
156 SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>,
160 //===----------------------------------------------------------------------===//
161 // AArch64-specific DAG Nodes.
164 // SDTBinaryArithWithFlagsOut - RES1, FLAGS = op LHS, RHS
165 def SDTBinaryArithWithFlagsOut : SDTypeProfile<2, 2,
168 SDTCisInt<0>, SDTCisVT<1, i32>]>;
170 // SDTBinaryArithWithFlagsIn - RES1, FLAGS = op LHS, RHS, FLAGS
171 def SDTBinaryArithWithFlagsIn : SDTypeProfile<1, 3,
177 // SDTBinaryArithWithFlagsInOut - RES1, FLAGS = op LHS, RHS, FLAGS
178 def SDTBinaryArithWithFlagsInOut : SDTypeProfile<2, 3,
185 def SDT_AArch64Brcond : SDTypeProfile<0, 3,
186 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i32>,
188 def SDT_AArch64cbz : SDTypeProfile<0, 2, [SDTCisInt<0>, SDTCisVT<1, OtherVT>]>;
189 def SDT_AArch64tbz : SDTypeProfile<0, 3, [SDTCisInt<0>, SDTCisInt<1>,
190 SDTCisVT<2, OtherVT>]>;
193 def SDT_AArch64CSel : SDTypeProfile<1, 4,
198 def SDT_AArch64CCMP : SDTypeProfile<1, 5,
205 def SDT_AArch64FCCMP : SDTypeProfile<1, 5,
212 def SDT_AArch64FCmp : SDTypeProfile<0, 2,
214 SDTCisSameAs<0, 1>]>;
215 def SDT_AArch64Dup : SDTypeProfile<1, 1, [SDTCisVec<0>]>;
216 def SDT_AArch64DupLane : SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisInt<2>]>;
217 def SDT_AArch64Zip : SDTypeProfile<1, 2, [SDTCisVec<0>,
219 SDTCisSameAs<0, 2>]>;
220 def SDT_AArch64MOVIedit : SDTypeProfile<1, 1, [SDTCisInt<1>]>;
221 def SDT_AArch64MOVIshift : SDTypeProfile<1, 2, [SDTCisInt<1>, SDTCisInt<2>]>;
222 def SDT_AArch64vecimm : SDTypeProfile<1, 3, [SDTCisVec<0>, SDTCisSameAs<0,1>,
223 SDTCisInt<2>, SDTCisInt<3>]>;
224 def SDT_AArch64UnaryVec: SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisSameAs<0,1>]>;
225 def SDT_AArch64ExtVec: SDTypeProfile<1, 3, [SDTCisVec<0>, SDTCisSameAs<0,1>,
226 SDTCisSameAs<0,2>, SDTCisInt<3>]>;
227 def SDT_AArch64vshift : SDTypeProfile<1, 2, [SDTCisSameAs<0,1>, SDTCisInt<2>]>;
229 def SDT_AArch64unvec : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisSameAs<0,1>]>;
230 def SDT_AArch64fcmpz : SDTypeProfile<1, 1, []>;
231 def SDT_AArch64fcmp : SDTypeProfile<1, 2, [SDTCisSameAs<1,2>]>;
232 def SDT_AArch64binvec : SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisSameAs<0,1>,
234 def SDT_AArch64trivec : SDTypeProfile<1, 3, [SDTCisVec<0>, SDTCisSameAs<0,1>,
237 def SDT_AArch64TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>]>;
238 def SDT_AArch64PREFETCH : SDTypeProfile<0, 2, [SDTCisVT<0, i32>, SDTCisPtrTy<1>]>;
240 def SDT_AArch64ITOF : SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisSameAs<0,1>]>;
242 def SDT_AArch64TLSDescCall : SDTypeProfile<0, -2, [SDTCisPtrTy<0>,
245 // Generates the general dynamic sequences, i.e.
246 // adrp x0, :tlsdesc:var
247 // ldr x1, [x0, #:tlsdesc_lo12:var]
248 // add x0, x0, #:tlsdesc_lo12:var
252 // (the TPIDR_EL0 offset is put directly in X0, hence no "result" here)
253 // number of operands (the variable)
254 def SDT_AArch64TLSDescCallSeq : SDTypeProfile<0,1,
257 def SDT_AArch64WrapperLarge : SDTypeProfile<1, 4,
258 [SDTCisVT<0, i64>, SDTCisVT<1, i32>,
259 SDTCisSameAs<1, 2>, SDTCisSameAs<1, 3>,
260 SDTCisSameAs<1, 4>]>;
264 def AArch64adrp : SDNode<"AArch64ISD::ADRP", SDTIntUnaryOp, []>;
265 def AArch64adr : SDNode<"AArch64ISD::ADR", SDTIntUnaryOp, []>;
266 def AArch64addlow : SDNode<"AArch64ISD::ADDlow", SDTIntBinOp, []>;
267 def AArch64LOADgot : SDNode<"AArch64ISD::LOADgot", SDTIntUnaryOp>;
268 def AArch64callseq_start : SDNode<"ISD::CALLSEQ_START",
269 SDCallSeqStart<[ SDTCisVT<0, i32>,
271 [SDNPHasChain, SDNPOutGlue]>;
272 def AArch64callseq_end : SDNode<"ISD::CALLSEQ_END",
273 SDCallSeqEnd<[ SDTCisVT<0, i32>,
275 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
276 def AArch64call : SDNode<"AArch64ISD::CALL",
277 SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>,
278 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
280 def AArch64brcond : SDNode<"AArch64ISD::BRCOND", SDT_AArch64Brcond,
282 def AArch64cbz : SDNode<"AArch64ISD::CBZ", SDT_AArch64cbz,
284 def AArch64cbnz : SDNode<"AArch64ISD::CBNZ", SDT_AArch64cbz,
286 def AArch64tbz : SDNode<"AArch64ISD::TBZ", SDT_AArch64tbz,
288 def AArch64tbnz : SDNode<"AArch64ISD::TBNZ", SDT_AArch64tbz,
292 def AArch64csel : SDNode<"AArch64ISD::CSEL", SDT_AArch64CSel>;
293 def AArch64csinv : SDNode<"AArch64ISD::CSINV", SDT_AArch64CSel>;
294 def AArch64csneg : SDNode<"AArch64ISD::CSNEG", SDT_AArch64CSel>;
295 def AArch64csinc : SDNode<"AArch64ISD::CSINC", SDT_AArch64CSel>;
296 def AArch64retflag : SDNode<"AArch64ISD::RET_FLAG", SDTNone,
297 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
298 def AArch64adc : SDNode<"AArch64ISD::ADC", SDTBinaryArithWithFlagsIn >;
299 def AArch64sbc : SDNode<"AArch64ISD::SBC", SDTBinaryArithWithFlagsIn>;
300 def AArch64add_flag : SDNode<"AArch64ISD::ADDS", SDTBinaryArithWithFlagsOut,
302 def AArch64sub_flag : SDNode<"AArch64ISD::SUBS", SDTBinaryArithWithFlagsOut>;
303 def AArch64and_flag : SDNode<"AArch64ISD::ANDS", SDTBinaryArithWithFlagsOut,
305 def AArch64adc_flag : SDNode<"AArch64ISD::ADCS", SDTBinaryArithWithFlagsInOut>;
306 def AArch64sbc_flag : SDNode<"AArch64ISD::SBCS", SDTBinaryArithWithFlagsInOut>;
308 def AArch64ccmp : SDNode<"AArch64ISD::CCMP", SDT_AArch64CCMP>;
309 def AArch64ccmn : SDNode<"AArch64ISD::CCMN", SDT_AArch64CCMP>;
310 def AArch64fccmp : SDNode<"AArch64ISD::FCCMP", SDT_AArch64FCCMP>;
312 def AArch64threadpointer : SDNode<"AArch64ISD::THREAD_POINTER", SDTPtrLeaf>;
314 def AArch64fcmp : SDNode<"AArch64ISD::FCMP", SDT_AArch64FCmp>;
316 def AArch64dup : SDNode<"AArch64ISD::DUP", SDT_AArch64Dup>;
317 def AArch64duplane8 : SDNode<"AArch64ISD::DUPLANE8", SDT_AArch64DupLane>;
318 def AArch64duplane16 : SDNode<"AArch64ISD::DUPLANE16", SDT_AArch64DupLane>;
319 def AArch64duplane32 : SDNode<"AArch64ISD::DUPLANE32", SDT_AArch64DupLane>;
320 def AArch64duplane64 : SDNode<"AArch64ISD::DUPLANE64", SDT_AArch64DupLane>;
322 def AArch64zip1 : SDNode<"AArch64ISD::ZIP1", SDT_AArch64Zip>;
323 def AArch64zip2 : SDNode<"AArch64ISD::ZIP2", SDT_AArch64Zip>;
324 def AArch64uzp1 : SDNode<"AArch64ISD::UZP1", SDT_AArch64Zip>;
325 def AArch64uzp2 : SDNode<"AArch64ISD::UZP2", SDT_AArch64Zip>;
326 def AArch64trn1 : SDNode<"AArch64ISD::TRN1", SDT_AArch64Zip>;
327 def AArch64trn2 : SDNode<"AArch64ISD::TRN2", SDT_AArch64Zip>;
329 def AArch64movi_edit : SDNode<"AArch64ISD::MOVIedit", SDT_AArch64MOVIedit>;
330 def AArch64movi_shift : SDNode<"AArch64ISD::MOVIshift", SDT_AArch64MOVIshift>;
331 def AArch64movi_msl : SDNode<"AArch64ISD::MOVImsl", SDT_AArch64MOVIshift>;
332 def AArch64mvni_shift : SDNode<"AArch64ISD::MVNIshift", SDT_AArch64MOVIshift>;
333 def AArch64mvni_msl : SDNode<"AArch64ISD::MVNImsl", SDT_AArch64MOVIshift>;
334 def AArch64movi : SDNode<"AArch64ISD::MOVI", SDT_AArch64MOVIedit>;
335 def AArch64fmov : SDNode<"AArch64ISD::FMOV", SDT_AArch64MOVIedit>;
337 def AArch64rev16 : SDNode<"AArch64ISD::REV16", SDT_AArch64UnaryVec>;
338 def AArch64rev32 : SDNode<"AArch64ISD::REV32", SDT_AArch64UnaryVec>;
339 def AArch64rev64 : SDNode<"AArch64ISD::REV64", SDT_AArch64UnaryVec>;
340 def AArch64ext : SDNode<"AArch64ISD::EXT", SDT_AArch64ExtVec>;
342 def AArch64vashr : SDNode<"AArch64ISD::VASHR", SDT_AArch64vshift>;
343 def AArch64vlshr : SDNode<"AArch64ISD::VLSHR", SDT_AArch64vshift>;
344 def AArch64vshl : SDNode<"AArch64ISD::VSHL", SDT_AArch64vshift>;
345 def AArch64sqshli : SDNode<"AArch64ISD::SQSHL_I", SDT_AArch64vshift>;
346 def AArch64uqshli : SDNode<"AArch64ISD::UQSHL_I", SDT_AArch64vshift>;
347 def AArch64sqshlui : SDNode<"AArch64ISD::SQSHLU_I", SDT_AArch64vshift>;
348 def AArch64srshri : SDNode<"AArch64ISD::SRSHR_I", SDT_AArch64vshift>;
349 def AArch64urshri : SDNode<"AArch64ISD::URSHR_I", SDT_AArch64vshift>;
351 def AArch64not: SDNode<"AArch64ISD::NOT", SDT_AArch64unvec>;
352 def AArch64bit: SDNode<"AArch64ISD::BIT", SDT_AArch64trivec>;
353 def AArch64bsl: SDNode<"AArch64ISD::BSL", SDT_AArch64trivec>;
355 def AArch64cmeq: SDNode<"AArch64ISD::CMEQ", SDT_AArch64binvec>;
356 def AArch64cmge: SDNode<"AArch64ISD::CMGE", SDT_AArch64binvec>;
357 def AArch64cmgt: SDNode<"AArch64ISD::CMGT", SDT_AArch64binvec>;
358 def AArch64cmhi: SDNode<"AArch64ISD::CMHI", SDT_AArch64binvec>;
359 def AArch64cmhs: SDNode<"AArch64ISD::CMHS", SDT_AArch64binvec>;
361 def AArch64fcmeq: SDNode<"AArch64ISD::FCMEQ", SDT_AArch64fcmp>;
362 def AArch64fcmge: SDNode<"AArch64ISD::FCMGE", SDT_AArch64fcmp>;
363 def AArch64fcmgt: SDNode<"AArch64ISD::FCMGT", SDT_AArch64fcmp>;
365 def AArch64cmeqz: SDNode<"AArch64ISD::CMEQz", SDT_AArch64unvec>;
366 def AArch64cmgez: SDNode<"AArch64ISD::CMGEz", SDT_AArch64unvec>;
367 def AArch64cmgtz: SDNode<"AArch64ISD::CMGTz", SDT_AArch64unvec>;
368 def AArch64cmlez: SDNode<"AArch64ISD::CMLEz", SDT_AArch64unvec>;
369 def AArch64cmltz: SDNode<"AArch64ISD::CMLTz", SDT_AArch64unvec>;
370 def AArch64cmtst : PatFrag<(ops node:$LHS, node:$RHS),
371 (AArch64not (AArch64cmeqz (and node:$LHS, node:$RHS)))>;
373 def AArch64fcmeqz: SDNode<"AArch64ISD::FCMEQz", SDT_AArch64fcmpz>;
374 def AArch64fcmgez: SDNode<"AArch64ISD::FCMGEz", SDT_AArch64fcmpz>;
375 def AArch64fcmgtz: SDNode<"AArch64ISD::FCMGTz", SDT_AArch64fcmpz>;
376 def AArch64fcmlez: SDNode<"AArch64ISD::FCMLEz", SDT_AArch64fcmpz>;
377 def AArch64fcmltz: SDNode<"AArch64ISD::FCMLTz", SDT_AArch64fcmpz>;
379 def AArch64bici: SDNode<"AArch64ISD::BICi", SDT_AArch64vecimm>;
380 def AArch64orri: SDNode<"AArch64ISD::ORRi", SDT_AArch64vecimm>;
382 def AArch64neg : SDNode<"AArch64ISD::NEG", SDT_AArch64unvec>;
384 def AArch64tcret: SDNode<"AArch64ISD::TC_RETURN", SDT_AArch64TCRET,
385 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
387 def AArch64Prefetch : SDNode<"AArch64ISD::PREFETCH", SDT_AArch64PREFETCH,
388 [SDNPHasChain, SDNPSideEffect]>;
390 def AArch64sitof: SDNode<"AArch64ISD::SITOF", SDT_AArch64ITOF>;
391 def AArch64uitof: SDNode<"AArch64ISD::UITOF", SDT_AArch64ITOF>;
393 def AArch64tlsdesc_callseq : SDNode<"AArch64ISD::TLSDESC_CALLSEQ",
394 SDT_AArch64TLSDescCallSeq,
395 [SDNPInGlue, SDNPOutGlue, SDNPHasChain,
399 def AArch64WrapperLarge : SDNode<"AArch64ISD::WrapperLarge",
400 SDT_AArch64WrapperLarge>;
402 def AArch64NvCast : SDNode<"AArch64ISD::NVCAST", SDTUnaryOp>;
404 def SDT_AArch64mull : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisInt<1>,
405 SDTCisSameAs<1, 2>]>;
406 def AArch64smull : SDNode<"AArch64ISD::SMULL", SDT_AArch64mull>;
407 def AArch64umull : SDNode<"AArch64ISD::UMULL", SDT_AArch64mull>;
409 def AArch64frecpe : SDNode<"AArch64ISD::FRECPE", SDTFPUnaryOp>;
410 def AArch64frecps : SDNode<"AArch64ISD::FRECPS", SDTFPBinOp>;
411 def AArch64frsqrte : SDNode<"AArch64ISD::FRSQRTE", SDTFPUnaryOp>;
412 def AArch64frsqrts : SDNode<"AArch64ISD::FRSQRTS", SDTFPBinOp>;
414 def AArch64saddv : SDNode<"AArch64ISD::SADDV", SDT_AArch64UnaryVec>;
415 def AArch64uaddv : SDNode<"AArch64ISD::UADDV", SDT_AArch64UnaryVec>;
416 def AArch64sminv : SDNode<"AArch64ISD::SMINV", SDT_AArch64UnaryVec>;
417 def AArch64uminv : SDNode<"AArch64ISD::UMINV", SDT_AArch64UnaryVec>;
418 def AArch64smaxv : SDNode<"AArch64ISD::SMAXV", SDT_AArch64UnaryVec>;
419 def AArch64umaxv : SDNode<"AArch64ISD::UMAXV", SDT_AArch64UnaryVec>;
421 def SDT_AArch64SETTAG : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisPtrTy<1>]>;
422 def AArch64stg : SDNode<"AArch64ISD::STG", SDT_AArch64SETTAG, [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
423 def AArch64stzg : SDNode<"AArch64ISD::STZG", SDT_AArch64SETTAG, [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
424 def AArch64st2g : SDNode<"AArch64ISD::ST2G", SDT_AArch64SETTAG, [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
425 def AArch64stz2g : SDNode<"AArch64ISD::STZ2G", SDT_AArch64SETTAG, [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
427 def SDT_AArch64unpk : SDTypeProfile<1, 1, [
428 SDTCisInt<0>, SDTCisInt<1>, SDTCisOpSmallerThanOp<1, 0>
430 def AArch64sunpkhi : SDNode<"AArch64ISD::SUNPKHI", SDT_AArch64unpk>;
431 def AArch64sunpklo : SDNode<"AArch64ISD::SUNPKLO", SDT_AArch64unpk>;
432 def AArch64uunpkhi : SDNode<"AArch64ISD::UUNPKHI", SDT_AArch64unpk>;
433 def AArch64uunpklo : SDNode<"AArch64ISD::UUNPKLO", SDT_AArch64unpk>;
435 //===----------------------------------------------------------------------===//
437 //===----------------------------------------------------------------------===//
439 // AArch64 Instruction Predicate Definitions.
440 // We could compute these on a per-module basis but doing so requires accessing
441 // the Function object through the <Target>Subtarget and objections were raised
442 // to that (see post-commit review comments for r301750).
443 let RecomputePerFunction = 1 in {
444 def ForCodeSize : Predicate<"MF->getFunction().hasOptSize()">;
445 def NotForCodeSize : Predicate<"!MF->getFunction().hasOptSize()">;
446 // Avoid generating STRQro if it is slow, unless we're optimizing for code size.
447 def UseSTRQro : Predicate<"!Subtarget->isSTRQroSlow() || MF->getFunction().hasOptSize()">;
449 def UseBTI : Predicate<[{ MF->getFunction().hasFnAttribute("branch-target-enforcement") }]>;
450 def NotUseBTI : Predicate<[{ !MF->getFunction().hasFnAttribute("branch-target-enforcement") }]>;
452 // Toggles patterns which aren't beneficial in GlobalISel when we aren't
453 // optimizing. This allows us to selectively use patterns without impacting
454 // SelectionDAG's behaviour.
455 // FIXME: One day there will probably be a nicer way to check for this, but
456 // today is not that day.
457 def OptimizedGISelOrOtherSelector : Predicate<"!MF->getFunction().hasOptNone() || MF->getProperties().hasProperty(MachineFunctionProperties::Property::FailedISel) || !MF->getProperties().hasProperty(MachineFunctionProperties::Property::Legalized)">;
460 include "AArch64InstrFormats.td"
461 include "SVEInstrFormats.td"
463 //===----------------------------------------------------------------------===//
465 //===----------------------------------------------------------------------===//
466 // Miscellaneous instructions.
467 //===----------------------------------------------------------------------===//
469 let Defs = [SP], Uses = [SP], hasSideEffects = 1, isCodeGenOnly = 1 in {
470 // We set Sched to empty list because we expect these instructions to simply get
471 // removed in most cases.
472 def ADJCALLSTACKDOWN : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
473 [(AArch64callseq_start timm:$amt1, timm:$amt2)]>,
475 def ADJCALLSTACKUP : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
476 [(AArch64callseq_end timm:$amt1, timm:$amt2)]>,
478 } // Defs = [SP], Uses = [SP], hasSideEffects = 1, isCodeGenOnly = 1
480 let isReMaterializable = 1, isCodeGenOnly = 1 in {
481 // FIXME: The following pseudo instructions are only needed because remat
482 // cannot handle multiple instructions. When that changes, they can be
483 // removed, along with the AArch64Wrapper node.
485 let AddedComplexity = 10 in
486 def LOADgot : Pseudo<(outs GPR64:$dst), (ins i64imm:$addr),
487 [(set GPR64:$dst, (AArch64LOADgot tglobaladdr:$addr))]>,
490 // The MOVaddr instruction should match only when the add is not folded
491 // into a load or store address.
493 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
494 [(set GPR64:$dst, (AArch64addlow (AArch64adrp tglobaladdr:$hi),
495 tglobaladdr:$low))]>,
496 Sched<[WriteAdrAdr]>;
498 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
499 [(set GPR64:$dst, (AArch64addlow (AArch64adrp tjumptable:$hi),
501 Sched<[WriteAdrAdr]>;
503 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
504 [(set GPR64:$dst, (AArch64addlow (AArch64adrp tconstpool:$hi),
506 Sched<[WriteAdrAdr]>;
508 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
509 [(set GPR64:$dst, (AArch64addlow (AArch64adrp tblockaddress:$hi),
510 tblockaddress:$low))]>,
511 Sched<[WriteAdrAdr]>;
513 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
514 [(set GPR64:$dst, (AArch64addlow (AArch64adrp tglobaltlsaddr:$hi),
515 tglobaltlsaddr:$low))]>,
516 Sched<[WriteAdrAdr]>;
518 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
519 [(set GPR64:$dst, (AArch64addlow (AArch64adrp texternalsym:$hi),
520 texternalsym:$low))]>,
521 Sched<[WriteAdrAdr]>;
522 // Normally AArch64addlow either gets folded into a following ldr/str,
523 // or together with an adrp into MOVaddr above. For cases with TLS, it
524 // might appear without either of them, so allow lowering it into a plain
527 : Pseudo<(outs GPR64:$dst), (ins GPR64:$src, i64imm:$low),
528 [(set GPR64:$dst, (AArch64addlow GPR64:$src,
529 tglobaltlsaddr:$low))]>,
532 } // isReMaterializable, isCodeGenOnly
534 def : Pat<(AArch64LOADgot tglobaltlsaddr:$addr),
535 (LOADgot tglobaltlsaddr:$addr)>;
537 def : Pat<(AArch64LOADgot texternalsym:$addr),
538 (LOADgot texternalsym:$addr)>;
540 def : Pat<(AArch64LOADgot tconstpool:$addr),
541 (LOADgot tconstpool:$addr)>;
543 // 32-bit jump table destination is actually only 2 instructions since we can
544 // use the table itself as a PC-relative base. But optimization occurs after
545 // branch relaxation so be pessimistic.
546 let Size = 12, Constraints = "@earlyclobber $dst,@earlyclobber $scratch" in {
547 def JumpTableDest32 : Pseudo<(outs GPR64:$dst, GPR64sp:$scratch),
548 (ins GPR64:$table, GPR64:$entry, i32imm:$jti), []>,
550 def JumpTableDest16 : Pseudo<(outs GPR64:$dst, GPR64sp:$scratch),
551 (ins GPR64:$table, GPR64:$entry, i32imm:$jti), []>,
553 def JumpTableDest8 : Pseudo<(outs GPR64:$dst, GPR64sp:$scratch),
554 (ins GPR64:$table, GPR64:$entry, i32imm:$jti), []>,
558 // Space-consuming pseudo to aid testing of placement and reachability
559 // algorithms. Immediate operand is the number of bytes this "instruction"
560 // occupies; register operands can be used to enforce dependency and constrain
562 let hasSideEffects = 1, mayLoad = 1, mayStore = 1 in
563 def SPACE : Pseudo<(outs GPR64:$Rd), (ins i32imm:$size, GPR64:$Rn),
564 [(set GPR64:$Rd, (int_aarch64_space imm:$size, GPR64:$Rn))]>,
567 let hasSideEffects = 1, isCodeGenOnly = 1 in {
568 def SpeculationSafeValueX
569 : Pseudo<(outs GPR64:$dst), (ins GPR64:$src), []>, Sched<[]>;
570 def SpeculationSafeValueW
571 : Pseudo<(outs GPR32:$dst), (ins GPR32:$src), []>, Sched<[]>;
575 //===----------------------------------------------------------------------===//
576 // System instructions.
577 //===----------------------------------------------------------------------===//
579 def HINT : HintI<"hint">;
580 def : InstAlias<"nop", (HINT 0b000)>;
581 def : InstAlias<"yield",(HINT 0b001)>;
582 def : InstAlias<"wfe", (HINT 0b010)>;
583 def : InstAlias<"wfi", (HINT 0b011)>;
584 def : InstAlias<"sev", (HINT 0b100)>;
585 def : InstAlias<"sevl", (HINT 0b101)>;
586 def : InstAlias<"esb", (HINT 0b10000)>, Requires<[HasRAS]>;
587 def : InstAlias<"csdb", (HINT 20)>;
588 def : InstAlias<"bti", (HINT 32)>, Requires<[HasBTI]>;
589 def : InstAlias<"bti $op", (HINT btihint_op:$op)>, Requires<[HasBTI]>;
591 // v8.2a Statistical Profiling extension
592 def : InstAlias<"psb $op", (HINT psbhint_op:$op)>, Requires<[HasSPE]>;
594 // As far as LLVM is concerned this writes to the system's exclusive monitors.
595 let mayLoad = 1, mayStore = 1 in
596 def CLREX : CRmSystemI<imm0_15, 0b010, "clrex">;
598 // NOTE: ideally, this would have mayStore = 0, mayLoad = 0, but we cannot
599 // model patterns with sufficiently fine granularity.
600 let mayLoad = ?, mayStore = ? in {
601 def DMB : CRmSystemI<barrier_op, 0b101, "dmb",
602 [(int_aarch64_dmb (i32 imm32_0_15:$CRm))]>;
604 def DSB : CRmSystemI<barrier_op, 0b100, "dsb",
605 [(int_aarch64_dsb (i32 imm32_0_15:$CRm))]>;
607 def ISB : CRmSystemI<barrier_op, 0b110, "isb",
608 [(int_aarch64_isb (i32 imm32_0_15:$CRm))]>;
610 def TSB : CRmSystemI<barrier_op, 0b010, "tsb", []> {
613 let Predicates = [HasTRACEV8_4];
617 // ARMv8.2-A Dot Product
618 let Predicates = [HasDotProd] in {
619 defm SDOT : SIMDThreeSameVectorDot<0, "sdot", int_aarch64_neon_sdot>;
620 defm UDOT : SIMDThreeSameVectorDot<1, "udot", int_aarch64_neon_udot>;
621 defm SDOTlane : SIMDThreeSameVectorDotIndex<0, "sdot", int_aarch64_neon_sdot>;
622 defm UDOTlane : SIMDThreeSameVectorDotIndex<1, "udot", int_aarch64_neon_udot>;
625 // ARMv8.2-A FP16 Fused Multiply-Add Long
626 let Predicates = [HasNEON, HasFP16FML] in {
627 defm FMLAL : SIMDThreeSameVectorFML<0, 1, 0b001, "fmlal", int_aarch64_neon_fmlal>;
628 defm FMLSL : SIMDThreeSameVectorFML<0, 1, 0b101, "fmlsl", int_aarch64_neon_fmlsl>;
629 defm FMLAL2 : SIMDThreeSameVectorFML<1, 0, 0b001, "fmlal2", int_aarch64_neon_fmlal2>;
630 defm FMLSL2 : SIMDThreeSameVectorFML<1, 0, 0b101, "fmlsl2", int_aarch64_neon_fmlsl2>;
631 defm FMLALlane : SIMDThreeSameVectorFMLIndex<0, 0b0000, "fmlal", int_aarch64_neon_fmlal>;
632 defm FMLSLlane : SIMDThreeSameVectorFMLIndex<0, 0b0100, "fmlsl", int_aarch64_neon_fmlsl>;
633 defm FMLAL2lane : SIMDThreeSameVectorFMLIndex<1, 0b1000, "fmlal2", int_aarch64_neon_fmlal2>;
634 defm FMLSL2lane : SIMDThreeSameVectorFMLIndex<1, 0b1100, "fmlsl2", int_aarch64_neon_fmlsl2>;
637 // Armv8.2-A Crypto extensions
638 let Predicates = [HasSHA3] in {
639 def SHA512H : CryptoRRRTied<0b0, 0b00, "sha512h">;
640 def SHA512H2 : CryptoRRRTied<0b0, 0b01, "sha512h2">;
641 def SHA512SU0 : CryptoRRTied_2D<0b0, 0b00, "sha512su0">;
642 def SHA512SU1 : CryptoRRRTied_2D<0b0, 0b10, "sha512su1">;
643 def RAX1 : CryptoRRR_2D<0b0,0b11, "rax1">;
644 def EOR3 : CryptoRRRR_16B<0b00, "eor3">;
645 def BCAX : CryptoRRRR_16B<0b01, "bcax">;
646 def XAR : CryptoRRRi6<"xar">;
649 let Predicates = [HasSM4] in {
650 def SM3TT1A : CryptoRRRi2Tied<0b0, 0b00, "sm3tt1a">;
651 def SM3TT1B : CryptoRRRi2Tied<0b0, 0b01, "sm3tt1b">;
652 def SM3TT2A : CryptoRRRi2Tied<0b0, 0b10, "sm3tt2a">;
653 def SM3TT2B : CryptoRRRi2Tied<0b0, 0b11, "sm3tt2b">;
654 def SM3SS1 : CryptoRRRR_4S<0b10, "sm3ss1">;
655 def SM3PARTW1 : CryptoRRRTied_4S<0b1, 0b00, "sm3partw1">;
656 def SM3PARTW2 : CryptoRRRTied_4S<0b1, 0b01, "sm3partw2">;
657 def SM4ENCKEY : CryptoRRR_4S<0b1, 0b10, "sm4ekey">;
658 def SM4E : CryptoRRTied_4S<0b0, 0b01, "sm4e">;
661 let Predicates = [HasRCPC] in {
662 // v8.3 Release Consistent Processor Consistent support, optional in v8.2.
663 def LDAPRB : RCPCLoad<0b00, "ldaprb", GPR32>;
664 def LDAPRH : RCPCLoad<0b01, "ldaprh", GPR32>;
665 def LDAPRW : RCPCLoad<0b10, "ldapr", GPR32>;
666 def LDAPRX : RCPCLoad<0b11, "ldapr", GPR64>;
669 // v8.3a complex add and multiply-accumulate. No predicate here, that is done
670 // inside the multiclass as the FP16 versions need different predicates.
671 defm FCMLA : SIMDThreeSameVectorTiedComplexHSD<1, 0b110, complexrotateop,
673 defm FCADD : SIMDThreeSameVectorComplexHSD<1, 0b111, complexrotateopodd,
675 defm FCMLA : SIMDIndexedTiedComplexHSD<1, 0, 1, complexrotateop, "fcmla",
678 // v8.3a Pointer Authentication
679 // These instructions inhabit part of the hint space and so can be used for
681 let Uses = [LR], Defs = [LR] in {
682 def PACIAZ : SystemNoOperands<0b000, "paciaz">;
683 def PACIBZ : SystemNoOperands<0b010, "pacibz">;
684 def AUTIAZ : SystemNoOperands<0b100, "autiaz">;
685 def AUTIBZ : SystemNoOperands<0b110, "autibz">;
687 let Uses = [LR, SP], Defs = [LR] in {
688 def PACIASP : SystemNoOperands<0b001, "paciasp">;
689 def PACIBSP : SystemNoOperands<0b011, "pacibsp">;
690 def AUTIASP : SystemNoOperands<0b101, "autiasp">;
691 def AUTIBSP : SystemNoOperands<0b111, "autibsp">;
693 let Uses = [X16, X17], Defs = [X17], CRm = 0b0001 in {
694 def PACIA1716 : SystemNoOperands<0b000, "pacia1716">;
695 def PACIB1716 : SystemNoOperands<0b010, "pacib1716">;
696 def AUTIA1716 : SystemNoOperands<0b100, "autia1716">;
697 def AUTIB1716 : SystemNoOperands<0b110, "autib1716">;
700 let Uses = [LR], Defs = [LR], CRm = 0b0000 in {
701 def XPACLRI : SystemNoOperands<0b111, "xpaclri">;
704 // These pointer authentication isntructions require armv8.3a
705 let Predicates = [HasPA] in {
706 multiclass SignAuth<bits<3> prefix, bits<3> prefix_z, string asm> {
707 def IA : SignAuthOneData<prefix, 0b00, !strconcat(asm, "ia")>;
708 def IB : SignAuthOneData<prefix, 0b01, !strconcat(asm, "ib")>;
709 def DA : SignAuthOneData<prefix, 0b10, !strconcat(asm, "da")>;
710 def DB : SignAuthOneData<prefix, 0b11, !strconcat(asm, "db")>;
711 def IZA : SignAuthZero<prefix_z, 0b00, !strconcat(asm, "iza")>;
712 def DZA : SignAuthZero<prefix_z, 0b10, !strconcat(asm, "dza")>;
713 def IZB : SignAuthZero<prefix_z, 0b01, !strconcat(asm, "izb")>;
714 def DZB : SignAuthZero<prefix_z, 0b11, !strconcat(asm, "dzb")>;
717 defm PAC : SignAuth<0b000, 0b010, "pac">;
718 defm AUT : SignAuth<0b001, 0b011, "aut">;
720 def XPACI : SignAuthZero<0b100, 0b00, "xpaci">;
721 def XPACD : SignAuthZero<0b100, 0b01, "xpacd">;
722 def PACGA : SignAuthTwoOperand<0b1100, "pacga", null_frag>;
724 // Combined Instructions
725 def BRAA : AuthBranchTwoOperands<0, 0, "braa">;
726 def BRAB : AuthBranchTwoOperands<0, 1, "brab">;
727 def BLRAA : AuthBranchTwoOperands<1, 0, "blraa">;
728 def BLRAB : AuthBranchTwoOperands<1, 1, "blrab">;
730 def BRAAZ : AuthOneOperand<0b000, 0, "braaz">;
731 def BRABZ : AuthOneOperand<0b000, 1, "brabz">;
732 def BLRAAZ : AuthOneOperand<0b001, 0, "blraaz">;
733 def BLRABZ : AuthOneOperand<0b001, 1, "blrabz">;
735 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
736 def RETAA : AuthReturn<0b010, 0, "retaa">;
737 def RETAB : AuthReturn<0b010, 1, "retab">;
738 def ERETAA : AuthReturn<0b100, 0, "eretaa">;
739 def ERETAB : AuthReturn<0b100, 1, "eretab">;
742 defm LDRAA : AuthLoad<0, "ldraa", simm10Scaled>;
743 defm LDRAB : AuthLoad<1, "ldrab", simm10Scaled>;
747 // v8.3a floating point conversion for javascript
748 let Predicates = [HasJS, HasFPARMv8] in
749 def FJCVTZS : BaseFPToIntegerUnscaled<0b01, 0b11, 0b110, FPR64, GPR32,
752 (int_aarch64_fjcvtzs FPR64:$Rn))]> {
754 } // HasJS, HasFPARMv8
756 // v8.4 Flag manipulation instructions
757 let Predicates = [HasFMI] in {
758 def CFINV : SimpleSystemI<0, (ins), "cfinv", "">, Sched<[WriteSys]> {
759 let Inst{20-5} = 0b0000001000000000;
761 def SETF8 : BaseFlagManipulation<0, 0, (ins GPR32:$Rn), "setf8", "{\t$Rn}">;
762 def SETF16 : BaseFlagManipulation<0, 1, (ins GPR32:$Rn), "setf16", "{\t$Rn}">;
763 def RMIF : FlagRotate<(ins GPR64:$Rn, uimm6:$imm, imm0_15:$mask), "rmif",
764 "{\t$Rn, $imm, $mask}">;
767 // v8.5 flag manipulation instructions
768 let Predicates = [HasAltNZCV], Uses = [NZCV], Defs = [NZCV] in {
770 def XAFLAG : PstateWriteSimple<(ins), "xaflag", "">, Sched<[WriteSys]> {
771 let Inst{18-16} = 0b000;
772 let Inst{11-8} = 0b0000;
773 let Unpredictable{11-8} = 0b1111;
774 let Inst{7-5} = 0b001;
777 def AXFLAG : PstateWriteSimple<(ins), "axflag", "">, Sched<[WriteSys]> {
778 let Inst{18-16} = 0b000;
779 let Inst{11-8} = 0b0000;
780 let Unpredictable{11-8} = 0b1111;
781 let Inst{7-5} = 0b010;
786 // Armv8.5-A speculation barrier
787 def SB : SimpleSystemI<0, (ins), "sb", "">, Sched<[]> {
788 let Inst{20-5} = 0b0001100110000111;
789 let Unpredictable{11-8} = 0b1111;
790 let Predicates = [HasSB];
791 let hasSideEffects = 1;
794 def : InstAlias<"clrex", (CLREX 0xf)>;
795 def : InstAlias<"isb", (ISB 0xf)>;
796 def : InstAlias<"ssbb", (DSB 0)>;
797 def : InstAlias<"pssbb", (DSB 4)>;
801 def MSRpstateImm1 : MSRpstateImm0_1;
802 def MSRpstateImm4 : MSRpstateImm0_15;
804 // The thread pointer (on Linux, at least, where this has been implemented) is
806 def MOVbaseTLS : Pseudo<(outs GPR64:$dst), (ins),
807 [(set GPR64:$dst, AArch64threadpointer)]>, Sched<[WriteSys]>;
809 let Uses = [ X9 ], Defs = [ X16, X17, LR, NZCV ] in {
810 def HWASAN_CHECK_MEMACCESS : Pseudo<
811 (outs), (ins GPR64noip:$ptr, i32imm:$accessinfo),
812 [(int_hwasan_check_memaccess X9, GPR64noip:$ptr, (i32 timm:$accessinfo))]>,
814 def HWASAN_CHECK_MEMACCESS_SHORTGRANULES : Pseudo<
815 (outs), (ins GPR64noip:$ptr, i32imm:$accessinfo),
816 [(int_hwasan_check_memaccess_shortgranules X9, GPR64noip:$ptr, (i32 timm:$accessinfo))]>,
820 // The cycle counter PMC register is PMCCNTR_EL0.
821 let Predicates = [HasPerfMon] in
822 def : Pat<(readcyclecounter), (MRS 0xdce8)>;
825 def : Pat<(i64 (int_aarch64_get_fpcr)), (MRS 0xda20)>;
827 // Generic system instructions
828 def SYSxt : SystemXtI<0, "sys">;
829 def SYSLxt : SystemLXtI<1, "sysl">;
831 def : InstAlias<"sys $op1, $Cn, $Cm, $op2",
832 (SYSxt imm0_7:$op1, sys_cr_op:$Cn,
833 sys_cr_op:$Cm, imm0_7:$op2, XZR)>;
836 let Predicates = [HasTME] in {
838 def TSTART : TMSystemI<0b0000, "tstart",
839 [(set GPR64:$Rt, (int_aarch64_tstart))]>;
841 def TCOMMIT : TMSystemINoOperand<0b0000, "tcommit", [(int_aarch64_tcommit)]>;
843 def TCANCEL : TMSystemException<0b011, "tcancel",
844 [(int_aarch64_tcancel i64_imm0_65535:$imm)]>;
846 def TTEST : TMSystemI<0b0001, "ttest", [(set GPR64:$Rt, (int_aarch64_ttest))]> {
852 //===----------------------------------------------------------------------===//
853 // Move immediate instructions.
854 //===----------------------------------------------------------------------===//
856 defm MOVK : InsertImmediate<0b11, "movk">;
857 defm MOVN : MoveImmediate<0b00, "movn">;
859 let PostEncoderMethod = "fixMOVZ" in
860 defm MOVZ : MoveImmediate<0b10, "movz">;
862 // First group of aliases covers an implicit "lsl #0".
863 def : InstAlias<"movk $dst, $imm", (MOVKWi GPR32:$dst, i32_imm0_65535:$imm, 0), 0>;
864 def : InstAlias<"movk $dst, $imm", (MOVKXi GPR64:$dst, i32_imm0_65535:$imm, 0), 0>;
865 def : InstAlias<"movn $dst, $imm", (MOVNWi GPR32:$dst, i32_imm0_65535:$imm, 0)>;
866 def : InstAlias<"movn $dst, $imm", (MOVNXi GPR64:$dst, i32_imm0_65535:$imm, 0)>;
867 def : InstAlias<"movz $dst, $imm", (MOVZWi GPR32:$dst, i32_imm0_65535:$imm, 0)>;
868 def : InstAlias<"movz $dst, $imm", (MOVZXi GPR64:$dst, i32_imm0_65535:$imm, 0)>;
870 // Next, we have various ELF relocations with the ":XYZ_g0:sym" syntax.
871 def : InstAlias<"movz $Rd, $sym", (MOVZXi GPR64:$Rd, movw_symbol_g3:$sym, 48)>;
872 def : InstAlias<"movz $Rd, $sym", (MOVZXi GPR64:$Rd, movw_symbol_g2:$sym, 32)>;
873 def : InstAlias<"movz $Rd, $sym", (MOVZXi GPR64:$Rd, movw_symbol_g1:$sym, 16)>;
874 def : InstAlias<"movz $Rd, $sym", (MOVZXi GPR64:$Rd, movw_symbol_g0:$sym, 0)>;
876 def : InstAlias<"movn $Rd, $sym", (MOVNXi GPR64:$Rd, movw_symbol_g3:$sym, 48)>;
877 def : InstAlias<"movn $Rd, $sym", (MOVNXi GPR64:$Rd, movw_symbol_g2:$sym, 32)>;
878 def : InstAlias<"movn $Rd, $sym", (MOVNXi GPR64:$Rd, movw_symbol_g1:$sym, 16)>;
879 def : InstAlias<"movn $Rd, $sym", (MOVNXi GPR64:$Rd, movw_symbol_g0:$sym, 0)>;
881 def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movw_symbol_g3:$sym, 48), 0>;
882 def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movw_symbol_g2:$sym, 32), 0>;
883 def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movw_symbol_g1:$sym, 16), 0>;
884 def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movw_symbol_g0:$sym, 0), 0>;
886 def : InstAlias<"movz $Rd, $sym", (MOVZWi GPR32:$Rd, movw_symbol_g1:$sym, 16)>;
887 def : InstAlias<"movz $Rd, $sym", (MOVZWi GPR32:$Rd, movw_symbol_g0:$sym, 0)>;
889 def : InstAlias<"movn $Rd, $sym", (MOVNWi GPR32:$Rd, movw_symbol_g1:$sym, 16)>;
890 def : InstAlias<"movn $Rd, $sym", (MOVNWi GPR32:$Rd, movw_symbol_g0:$sym, 0)>;
892 def : InstAlias<"movk $Rd, $sym", (MOVKWi GPR32:$Rd, movw_symbol_g1:$sym, 16), 0>;
893 def : InstAlias<"movk $Rd, $sym", (MOVKWi GPR32:$Rd, movw_symbol_g0:$sym, 0), 0>;
895 // Final group of aliases covers true "mov $Rd, $imm" cases.
896 multiclass movw_mov_alias<string basename,Instruction INST, RegisterClass GPR,
897 int width, int shift> {
898 def _asmoperand : AsmOperandClass {
899 let Name = basename # width # "_lsl" # shift # "MovAlias";
900 let PredicateMethod = "is" # basename # "MovAlias<" # width # ", "
902 let RenderMethod = "add" # basename # "MovAliasOperands<" # shift # ">";
905 def _movimm : Operand<i32> {
906 let ParserMatchClass = !cast<AsmOperandClass>(NAME # "_asmoperand");
909 def : InstAlias<"mov $Rd, $imm",
910 (INST GPR:$Rd, !cast<Operand>(NAME # "_movimm"):$imm, shift)>;
913 defm : movw_mov_alias<"MOVZ", MOVZWi, GPR32, 32, 0>;
914 defm : movw_mov_alias<"MOVZ", MOVZWi, GPR32, 32, 16>;
916 defm : movw_mov_alias<"MOVZ", MOVZXi, GPR64, 64, 0>;
917 defm : movw_mov_alias<"MOVZ", MOVZXi, GPR64, 64, 16>;
918 defm : movw_mov_alias<"MOVZ", MOVZXi, GPR64, 64, 32>;
919 defm : movw_mov_alias<"MOVZ", MOVZXi, GPR64, 64, 48>;
921 defm : movw_mov_alias<"MOVN", MOVNWi, GPR32, 32, 0>;
922 defm : movw_mov_alias<"MOVN", MOVNWi, GPR32, 32, 16>;
924 defm : movw_mov_alias<"MOVN", MOVNXi, GPR64, 64, 0>;
925 defm : movw_mov_alias<"MOVN", MOVNXi, GPR64, 64, 16>;
926 defm : movw_mov_alias<"MOVN", MOVNXi, GPR64, 64, 32>;
927 defm : movw_mov_alias<"MOVN", MOVNXi, GPR64, 64, 48>;
929 let isReMaterializable = 1, isCodeGenOnly = 1, isMoveImm = 1,
930 isAsCheapAsAMove = 1 in {
931 // FIXME: The following pseudo instructions are only needed because remat
932 // cannot handle multiple instructions. When that changes, we can select
933 // directly to the real instructions and get rid of these pseudos.
936 : Pseudo<(outs GPR32:$dst), (ins i32imm:$src),
937 [(set GPR32:$dst, imm:$src)]>,
940 : Pseudo<(outs GPR64:$dst), (ins i64imm:$src),
941 [(set GPR64:$dst, imm:$src)]>,
943 } // isReMaterializable, isCodeGenOnly
945 // If possible, we want to use MOVi32imm even for 64-bit moves. This gives the
946 // eventual expansion code fewer bits to worry about getting right. Marshalling
947 // the types is a little tricky though:
948 def i64imm_32bit : ImmLeaf<i64, [{
949 return (Imm & 0xffffffffULL) == static_cast<uint64_t>(Imm);
952 def s64imm_32bit : ImmLeaf<i64, [{
953 int64_t Imm64 = static_cast<int64_t>(Imm);
954 return Imm64 >= std::numeric_limits<int32_t>::min() &&
955 Imm64 <= std::numeric_limits<int32_t>::max();
958 def trunc_imm : SDNodeXForm<imm, [{
959 return CurDAG->getTargetConstant(N->getZExtValue(), SDLoc(N), MVT::i32);
962 def gi_trunc_imm : GICustomOperandRenderer<"renderTruncImm">,
963 GISDNodeXFormEquiv<trunc_imm>;
965 let Predicates = [OptimizedGISelOrOtherSelector] in {
966 // The SUBREG_TO_REG isn't eliminated at -O0, which can result in pointless
968 def : Pat<(i64 i64imm_32bit:$src),
969 (SUBREG_TO_REG (i64 0), (MOVi32imm (trunc_imm imm:$src)), sub_32)>;
972 // Materialize FP constants via MOVi32imm/MOVi64imm (MachO large code model).
973 def bitcast_fpimm_to_i32 : SDNodeXForm<fpimm, [{
974 return CurDAG->getTargetConstant(
975 N->getValueAPF().bitcastToAPInt().getZExtValue(), SDLoc(N), MVT::i32);
978 def bitcast_fpimm_to_i64 : SDNodeXForm<fpimm, [{
979 return CurDAG->getTargetConstant(
980 N->getValueAPF().bitcastToAPInt().getZExtValue(), SDLoc(N), MVT::i64);
984 def : Pat<(f32 fpimm:$in),
985 (COPY_TO_REGCLASS (MOVi32imm (bitcast_fpimm_to_i32 f32:$in)), FPR32)>;
986 def : Pat<(f64 fpimm:$in),
987 (COPY_TO_REGCLASS (MOVi64imm (bitcast_fpimm_to_i64 f64:$in)), FPR64)>;
990 // Deal with the various forms of (ELF) large addressing with MOVZ/MOVK
992 def : Pat<(AArch64WrapperLarge tglobaladdr:$g3, tglobaladdr:$g2,
993 tglobaladdr:$g1, tglobaladdr:$g0),
994 (MOVKXi (MOVKXi (MOVKXi (MOVZXi tglobaladdr:$g0, 0),
995 tglobaladdr:$g1, 16),
996 tglobaladdr:$g2, 32),
997 tglobaladdr:$g3, 48)>;
999 def : Pat<(AArch64WrapperLarge tblockaddress:$g3, tblockaddress:$g2,
1000 tblockaddress:$g1, tblockaddress:$g0),
1001 (MOVKXi (MOVKXi (MOVKXi (MOVZXi tblockaddress:$g0, 0),
1002 tblockaddress:$g1, 16),
1003 tblockaddress:$g2, 32),
1004 tblockaddress:$g3, 48)>;
1006 def : Pat<(AArch64WrapperLarge tconstpool:$g3, tconstpool:$g2,
1007 tconstpool:$g1, tconstpool:$g0),
1008 (MOVKXi (MOVKXi (MOVKXi (MOVZXi tconstpool:$g0, 0),
1009 tconstpool:$g1, 16),
1010 tconstpool:$g2, 32),
1011 tconstpool:$g3, 48)>;
1013 def : Pat<(AArch64WrapperLarge tjumptable:$g3, tjumptable:$g2,
1014 tjumptable:$g1, tjumptable:$g0),
1015 (MOVKXi (MOVKXi (MOVKXi (MOVZXi tjumptable:$g0, 0),
1016 tjumptable:$g1, 16),
1017 tjumptable:$g2, 32),
1018 tjumptable:$g3, 48)>;
1021 //===----------------------------------------------------------------------===//
1022 // Arithmetic instructions.
1023 //===----------------------------------------------------------------------===//
1025 // Add/subtract with carry.
1026 defm ADC : AddSubCarry<0, "adc", "adcs", AArch64adc, AArch64adc_flag>;
1027 defm SBC : AddSubCarry<1, "sbc", "sbcs", AArch64sbc, AArch64sbc_flag>;
1029 def : InstAlias<"ngc $dst, $src", (SBCWr GPR32:$dst, WZR, GPR32:$src)>;
1030 def : InstAlias<"ngc $dst, $src", (SBCXr GPR64:$dst, XZR, GPR64:$src)>;
1031 def : InstAlias<"ngcs $dst, $src", (SBCSWr GPR32:$dst, WZR, GPR32:$src)>;
1032 def : InstAlias<"ngcs $dst, $src", (SBCSXr GPR64:$dst, XZR, GPR64:$src)>;
1035 defm ADD : AddSub<0, "add", "sub", add>;
1036 defm SUB : AddSub<1, "sub", "add">;
1038 def : InstAlias<"mov $dst, $src",
1039 (ADDWri GPR32sponly:$dst, GPR32sp:$src, 0, 0)>;
1040 def : InstAlias<"mov $dst, $src",
1041 (ADDWri GPR32sp:$dst, GPR32sponly:$src, 0, 0)>;
1042 def : InstAlias<"mov $dst, $src",
1043 (ADDXri GPR64sponly:$dst, GPR64sp:$src, 0, 0)>;
1044 def : InstAlias<"mov $dst, $src",
1045 (ADDXri GPR64sp:$dst, GPR64sponly:$src, 0, 0)>;
1047 defm ADDS : AddSubS<0, "adds", AArch64add_flag, "cmn", "subs", "cmp">;
1048 defm SUBS : AddSubS<1, "subs", AArch64sub_flag, "cmp", "adds", "cmn">;
1050 // Use SUBS instead of SUB to enable CSE between SUBS and SUB.
1051 def : Pat<(sub GPR32sp:$Rn, addsub_shifted_imm32:$imm),
1052 (SUBSWri GPR32sp:$Rn, addsub_shifted_imm32:$imm)>;
1053 def : Pat<(sub GPR64sp:$Rn, addsub_shifted_imm64:$imm),
1054 (SUBSXri GPR64sp:$Rn, addsub_shifted_imm64:$imm)>;
1055 def : Pat<(sub GPR32:$Rn, GPR32:$Rm),
1056 (SUBSWrr GPR32:$Rn, GPR32:$Rm)>;
1057 def : Pat<(sub GPR64:$Rn, GPR64:$Rm),
1058 (SUBSXrr GPR64:$Rn, GPR64:$Rm)>;
1059 def : Pat<(sub GPR32:$Rn, arith_shifted_reg32:$Rm),
1060 (SUBSWrs GPR32:$Rn, arith_shifted_reg32:$Rm)>;
1061 def : Pat<(sub GPR64:$Rn, arith_shifted_reg64:$Rm),
1062 (SUBSXrs GPR64:$Rn, arith_shifted_reg64:$Rm)>;
1063 let AddedComplexity = 1 in {
1064 def : Pat<(sub GPR32sp:$R2, arith_extended_reg32_i32:$R3),
1065 (SUBSWrx GPR32sp:$R2, arith_extended_reg32_i32:$R3)>;
1066 def : Pat<(sub GPR64sp:$R2, arith_extended_reg32to64_i64:$R3),
1067 (SUBSXrx GPR64sp:$R2, arith_extended_reg32to64_i64:$R3)>;
1070 // Because of the immediate format for add/sub-imm instructions, the
1071 // expression (add x, -1) must be transformed to (SUB{W,X}ri x, 1).
1072 // These patterns capture that transformation.
1073 let AddedComplexity = 1 in {
1074 def : Pat<(add GPR32:$Rn, neg_addsub_shifted_imm32:$imm),
1075 (SUBSWri GPR32:$Rn, neg_addsub_shifted_imm32:$imm)>;
1076 def : Pat<(add GPR64:$Rn, neg_addsub_shifted_imm64:$imm),
1077 (SUBSXri GPR64:$Rn, neg_addsub_shifted_imm64:$imm)>;
1078 def : Pat<(sub GPR32:$Rn, neg_addsub_shifted_imm32:$imm),
1079 (ADDWri GPR32:$Rn, neg_addsub_shifted_imm32:$imm)>;
1080 def : Pat<(sub GPR64:$Rn, neg_addsub_shifted_imm64:$imm),
1081 (ADDXri GPR64:$Rn, neg_addsub_shifted_imm64:$imm)>;
1084 // Because of the immediate format for add/sub-imm instructions, the
1085 // expression (add x, -1) must be transformed to (SUB{W,X}ri x, 1).
1086 // These patterns capture that transformation.
1087 let AddedComplexity = 1 in {
1088 def : Pat<(AArch64add_flag GPR32:$Rn, neg_addsub_shifted_imm32:$imm),
1089 (SUBSWri GPR32:$Rn, neg_addsub_shifted_imm32:$imm)>;
1090 def : Pat<(AArch64add_flag GPR64:$Rn, neg_addsub_shifted_imm64:$imm),
1091 (SUBSXri GPR64:$Rn, neg_addsub_shifted_imm64:$imm)>;
1092 def : Pat<(AArch64sub_flag GPR32:$Rn, neg_addsub_shifted_imm32:$imm),
1093 (ADDSWri GPR32:$Rn, neg_addsub_shifted_imm32:$imm)>;
1094 def : Pat<(AArch64sub_flag GPR64:$Rn, neg_addsub_shifted_imm64:$imm),
1095 (ADDSXri GPR64:$Rn, neg_addsub_shifted_imm64:$imm)>;
1098 def : InstAlias<"neg $dst, $src", (SUBWrs GPR32:$dst, WZR, GPR32:$src, 0), 3>;
1099 def : InstAlias<"neg $dst, $src", (SUBXrs GPR64:$dst, XZR, GPR64:$src, 0), 3>;
1100 def : InstAlias<"neg $dst, $src$shift",
1101 (SUBWrs GPR32:$dst, WZR, GPR32:$src, arith_shift32:$shift), 2>;
1102 def : InstAlias<"neg $dst, $src$shift",
1103 (SUBXrs GPR64:$dst, XZR, GPR64:$src, arith_shift64:$shift), 2>;
1105 def : InstAlias<"negs $dst, $src", (SUBSWrs GPR32:$dst, WZR, GPR32:$src, 0), 3>;
1106 def : InstAlias<"negs $dst, $src", (SUBSXrs GPR64:$dst, XZR, GPR64:$src, 0), 3>;
1107 def : InstAlias<"negs $dst, $src$shift",
1108 (SUBSWrs GPR32:$dst, WZR, GPR32:$src, arith_shift32:$shift), 2>;
1109 def : InstAlias<"negs $dst, $src$shift",
1110 (SUBSXrs GPR64:$dst, XZR, GPR64:$src, arith_shift64:$shift), 2>;
1113 // Unsigned/Signed divide
1114 defm UDIV : Div<0, "udiv", udiv>;
1115 defm SDIV : Div<1, "sdiv", sdiv>;
1117 def : Pat<(int_aarch64_udiv GPR32:$Rn, GPR32:$Rm), (UDIVWr GPR32:$Rn, GPR32:$Rm)>;
1118 def : Pat<(int_aarch64_udiv GPR64:$Rn, GPR64:$Rm), (UDIVXr GPR64:$Rn, GPR64:$Rm)>;
1119 def : Pat<(int_aarch64_sdiv GPR32:$Rn, GPR32:$Rm), (SDIVWr GPR32:$Rn, GPR32:$Rm)>;
1120 def : Pat<(int_aarch64_sdiv GPR64:$Rn, GPR64:$Rm), (SDIVXr GPR64:$Rn, GPR64:$Rm)>;
1123 defm ASRV : Shift<0b10, "asr", sra>;
1124 defm LSLV : Shift<0b00, "lsl", shl>;
1125 defm LSRV : Shift<0b01, "lsr", srl>;
1126 defm RORV : Shift<0b11, "ror", rotr>;
1128 def : ShiftAlias<"asrv", ASRVWr, GPR32>;
1129 def : ShiftAlias<"asrv", ASRVXr, GPR64>;
1130 def : ShiftAlias<"lslv", LSLVWr, GPR32>;
1131 def : ShiftAlias<"lslv", LSLVXr, GPR64>;
1132 def : ShiftAlias<"lsrv", LSRVWr, GPR32>;
1133 def : ShiftAlias<"lsrv", LSRVXr, GPR64>;
1134 def : ShiftAlias<"rorv", RORVWr, GPR32>;
1135 def : ShiftAlias<"rorv", RORVXr, GPR64>;
1138 let AddedComplexity = 5 in {
1139 defm MADD : MulAccum<0, "madd", add>;
1140 defm MSUB : MulAccum<1, "msub", sub>;
1142 def : Pat<(i32 (mul GPR32:$Rn, GPR32:$Rm)),
1143 (MADDWrrr GPR32:$Rn, GPR32:$Rm, WZR)>;
1144 def : Pat<(i64 (mul GPR64:$Rn, GPR64:$Rm)),
1145 (MADDXrrr GPR64:$Rn, GPR64:$Rm, XZR)>;
1147 def : Pat<(i32 (ineg (mul GPR32:$Rn, GPR32:$Rm))),
1148 (MSUBWrrr GPR32:$Rn, GPR32:$Rm, WZR)>;
1149 def : Pat<(i64 (ineg (mul GPR64:$Rn, GPR64:$Rm))),
1150 (MSUBXrrr GPR64:$Rn, GPR64:$Rm, XZR)>;
1151 def : Pat<(i32 (mul (ineg GPR32:$Rn), GPR32:$Rm)),
1152 (MSUBWrrr GPR32:$Rn, GPR32:$Rm, WZR)>;
1153 def : Pat<(i64 (mul (ineg GPR64:$Rn), GPR64:$Rm)),
1154 (MSUBXrrr GPR64:$Rn, GPR64:$Rm, XZR)>;
1155 } // AddedComplexity = 5
1157 let AddedComplexity = 5 in {
1158 def SMADDLrrr : WideMulAccum<0, 0b001, "smaddl", add, sext>;
1159 def SMSUBLrrr : WideMulAccum<1, 0b001, "smsubl", sub, sext>;
1160 def UMADDLrrr : WideMulAccum<0, 0b101, "umaddl", add, zext>;
1161 def UMSUBLrrr : WideMulAccum<1, 0b101, "umsubl", sub, zext>;
1163 def : Pat<(i64 (mul (sext GPR32:$Rn), (sext GPR32:$Rm))),
1164 (SMADDLrrr GPR32:$Rn, GPR32:$Rm, XZR)>;
1165 def : Pat<(i64 (mul (zext GPR32:$Rn), (zext GPR32:$Rm))),
1166 (UMADDLrrr GPR32:$Rn, GPR32:$Rm, XZR)>;
1168 def : Pat<(i64 (ineg (mul (sext GPR32:$Rn), (sext GPR32:$Rm)))),
1169 (SMSUBLrrr GPR32:$Rn, GPR32:$Rm, XZR)>;
1170 def : Pat<(i64 (ineg (mul (zext GPR32:$Rn), (zext GPR32:$Rm)))),
1171 (UMSUBLrrr GPR32:$Rn, GPR32:$Rm, XZR)>;
1173 def : Pat<(i64 (mul (sext GPR32:$Rn), (s64imm_32bit:$C))),
1174 (SMADDLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1175 def : Pat<(i64 (mul (zext GPR32:$Rn), (i64imm_32bit:$C))),
1176 (UMADDLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1177 def : Pat<(i64 (mul (sext_inreg GPR64:$Rn, i32), (s64imm_32bit:$C))),
1178 (SMADDLrrr (i32 (EXTRACT_SUBREG GPR64:$Rn, sub_32)),
1179 (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1181 def : Pat<(i64 (ineg (mul (sext GPR32:$Rn), (s64imm_32bit:$C)))),
1182 (SMSUBLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1183 def : Pat<(i64 (ineg (mul (zext GPR32:$Rn), (i64imm_32bit:$C)))),
1184 (UMSUBLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1185 def : Pat<(i64 (ineg (mul (sext_inreg GPR64:$Rn, i32), (s64imm_32bit:$C)))),
1186 (SMSUBLrrr (i32 (EXTRACT_SUBREG GPR64:$Rn, sub_32)),
1187 (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1189 def : Pat<(i64 (add (mul (sext GPR32:$Rn), (s64imm_32bit:$C)), GPR64:$Ra)),
1190 (SMADDLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1191 def : Pat<(i64 (add (mul (zext GPR32:$Rn), (i64imm_32bit:$C)), GPR64:$Ra)),
1192 (UMADDLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1193 def : Pat<(i64 (add (mul (sext_inreg GPR64:$Rn, i32), (s64imm_32bit:$C)),
1195 (SMADDLrrr (i32 (EXTRACT_SUBREG GPR64:$Rn, sub_32)),
1196 (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1198 def : Pat<(i64 (sub GPR64:$Ra, (mul (sext GPR32:$Rn), (s64imm_32bit:$C)))),
1199 (SMSUBLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1200 def : Pat<(i64 (sub GPR64:$Ra, (mul (zext GPR32:$Rn), (i64imm_32bit:$C)))),
1201 (UMSUBLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1202 def : Pat<(i64 (sub GPR64:$Ra, (mul (sext_inreg GPR64:$Rn, i32),
1203 (s64imm_32bit:$C)))),
1204 (SMSUBLrrr (i32 (EXTRACT_SUBREG GPR64:$Rn, sub_32)),
1205 (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1206 } // AddedComplexity = 5
1208 def : MulAccumWAlias<"mul", MADDWrrr>;
1209 def : MulAccumXAlias<"mul", MADDXrrr>;
1210 def : MulAccumWAlias<"mneg", MSUBWrrr>;
1211 def : MulAccumXAlias<"mneg", MSUBXrrr>;
1212 def : WideMulAccumAlias<"smull", SMADDLrrr>;
1213 def : WideMulAccumAlias<"smnegl", SMSUBLrrr>;
1214 def : WideMulAccumAlias<"umull", UMADDLrrr>;
1215 def : WideMulAccumAlias<"umnegl", UMSUBLrrr>;
1218 def SMULHrr : MulHi<0b010, "smulh", mulhs>;
1219 def UMULHrr : MulHi<0b110, "umulh", mulhu>;
1222 def CRC32Brr : BaseCRC32<0, 0b00, 0, GPR32, int_aarch64_crc32b, "crc32b">;
1223 def CRC32Hrr : BaseCRC32<0, 0b01, 0, GPR32, int_aarch64_crc32h, "crc32h">;
1224 def CRC32Wrr : BaseCRC32<0, 0b10, 0, GPR32, int_aarch64_crc32w, "crc32w">;
1225 def CRC32Xrr : BaseCRC32<1, 0b11, 0, GPR64, int_aarch64_crc32x, "crc32x">;
1227 def CRC32CBrr : BaseCRC32<0, 0b00, 1, GPR32, int_aarch64_crc32cb, "crc32cb">;
1228 def CRC32CHrr : BaseCRC32<0, 0b01, 1, GPR32, int_aarch64_crc32ch, "crc32ch">;
1229 def CRC32CWrr : BaseCRC32<0, 0b10, 1, GPR32, int_aarch64_crc32cw, "crc32cw">;
1230 def CRC32CXrr : BaseCRC32<1, 0b11, 1, GPR64, int_aarch64_crc32cx, "crc32cx">;
1233 defm CAS : CompareAndSwap<0, 0, "">;
1234 defm CASA : CompareAndSwap<1, 0, "a">;
1235 defm CASL : CompareAndSwap<0, 1, "l">;
1236 defm CASAL : CompareAndSwap<1, 1, "al">;
1239 defm CASP : CompareAndSwapPair<0, 0, "">;
1240 defm CASPA : CompareAndSwapPair<1, 0, "a">;
1241 defm CASPL : CompareAndSwapPair<0, 1, "l">;
1242 defm CASPAL : CompareAndSwapPair<1, 1, "al">;
1245 defm SWP : Swap<0, 0, "">;
1246 defm SWPA : Swap<1, 0, "a">;
1247 defm SWPL : Swap<0, 1, "l">;
1248 defm SWPAL : Swap<1, 1, "al">;
1250 // v8.1 atomic LD<OP>(register). Performs load and then ST<OP>(register)
1251 defm LDADD : LDOPregister<0b000, "add", 0, 0, "">;
1252 defm LDADDA : LDOPregister<0b000, "add", 1, 0, "a">;
1253 defm LDADDL : LDOPregister<0b000, "add", 0, 1, "l">;
1254 defm LDADDAL : LDOPregister<0b000, "add", 1, 1, "al">;
1256 defm LDCLR : LDOPregister<0b001, "clr", 0, 0, "">;
1257 defm LDCLRA : LDOPregister<0b001, "clr", 1, 0, "a">;
1258 defm LDCLRL : LDOPregister<0b001, "clr", 0, 1, "l">;
1259 defm LDCLRAL : LDOPregister<0b001, "clr", 1, 1, "al">;
1261 defm LDEOR : LDOPregister<0b010, "eor", 0, 0, "">;
1262 defm LDEORA : LDOPregister<0b010, "eor", 1, 0, "a">;
1263 defm LDEORL : LDOPregister<0b010, "eor", 0, 1, "l">;
1264 defm LDEORAL : LDOPregister<0b010, "eor", 1, 1, "al">;
1266 defm LDSET : LDOPregister<0b011, "set", 0, 0, "">;
1267 defm LDSETA : LDOPregister<0b011, "set", 1, 0, "a">;
1268 defm LDSETL : LDOPregister<0b011, "set", 0, 1, "l">;
1269 defm LDSETAL : LDOPregister<0b011, "set", 1, 1, "al">;
1271 defm LDSMAX : LDOPregister<0b100, "smax", 0, 0, "">;
1272 defm LDSMAXA : LDOPregister<0b100, "smax", 1, 0, "a">;
1273 defm LDSMAXL : LDOPregister<0b100, "smax", 0, 1, "l">;
1274 defm LDSMAXAL : LDOPregister<0b100, "smax", 1, 1, "al">;
1276 defm LDSMIN : LDOPregister<0b101, "smin", 0, 0, "">;
1277 defm LDSMINA : LDOPregister<0b101, "smin", 1, 0, "a">;
1278 defm LDSMINL : LDOPregister<0b101, "smin", 0, 1, "l">;
1279 defm LDSMINAL : LDOPregister<0b101, "smin", 1, 1, "al">;
1281 defm LDUMAX : LDOPregister<0b110, "umax", 0, 0, "">;
1282 defm LDUMAXA : LDOPregister<0b110, "umax", 1, 0, "a">;
1283 defm LDUMAXL : LDOPregister<0b110, "umax", 0, 1, "l">;
1284 defm LDUMAXAL : LDOPregister<0b110, "umax", 1, 1, "al">;
1286 defm LDUMIN : LDOPregister<0b111, "umin", 0, 0, "">;
1287 defm LDUMINA : LDOPregister<0b111, "umin", 1, 0, "a">;
1288 defm LDUMINL : LDOPregister<0b111, "umin", 0, 1, "l">;
1289 defm LDUMINAL : LDOPregister<0b111, "umin", 1, 1, "al">;
1291 // v8.1 atomic ST<OP>(register) as aliases to "LD<OP>(register) when Rt=xZR"
1292 defm : STOPregister<"stadd","LDADD">; // STADDx
1293 defm : STOPregister<"stclr","LDCLR">; // STCLRx
1294 defm : STOPregister<"steor","LDEOR">; // STEORx
1295 defm : STOPregister<"stset","LDSET">; // STSETx
1296 defm : STOPregister<"stsmax","LDSMAX">;// STSMAXx
1297 defm : STOPregister<"stsmin","LDSMIN">;// STSMINx
1298 defm : STOPregister<"stumax","LDUMAX">;// STUMAXx
1299 defm : STOPregister<"stumin","LDUMIN">;// STUMINx
1301 // v8.5 Memory Tagging Extension
1302 let Predicates = [HasMTE] in {
1304 def IRG : BaseTwoOperand<0b0100, GPR64sp, "irg", int_aarch64_irg, GPR64sp, GPR64>,
1308 def GMI : BaseTwoOperand<0b0101, GPR64, "gmi", int_aarch64_gmi, GPR64sp>, Sched<[]>{
1310 let isNotDuplicable = 1;
1312 def ADDG : AddSubG<0, "addg", null_frag>;
1313 def SUBG : AddSubG<1, "subg", null_frag>;
1315 def : InstAlias<"irg $dst, $src", (IRG GPR64sp:$dst, GPR64sp:$src, XZR), 1>;
1317 def SUBP : SUBP<0, "subp", int_aarch64_subp>, Sched<[]>;
1318 def SUBPS : SUBP<1, "subps", null_frag>, Sched<[]>{
1322 def : InstAlias<"cmpp $lhs, $rhs", (SUBPS XZR, GPR64sp:$lhs, GPR64sp:$rhs), 0>;
1324 def LDG : MemTagLoad<"ldg", "\t$Rt, [$Rn, $offset]">;
1326 def : Pat<(int_aarch64_addg (am_indexedu6s128 GPR64sp:$Rn, uimm6s16:$imm6), imm0_15:$imm4),
1327 (ADDG GPR64sp:$Rn, imm0_63:$imm6, imm0_15:$imm4)>;
1328 def : Pat<(int_aarch64_ldg GPR64:$Rt, (am_indexeds9s128 GPR64sp:$Rn, simm9s16:$offset)),
1329 (LDG GPR64:$Rt, GPR64sp:$Rn, simm9s16:$offset)>;
1331 def : InstAlias<"ldg $Rt, [$Rn]", (LDG GPR64:$Rt, GPR64sp:$Rn, 0), 1>;
1333 def LDGM : MemTagVector<1, "ldgm", "\t$Rt, [$Rn]",
1334 (outs GPR64:$Rt), (ins GPR64sp:$Rn)>;
1335 def STGM : MemTagVector<0, "stgm", "\t$Rt, [$Rn]",
1336 (outs), (ins GPR64:$Rt, GPR64sp:$Rn)>;
1337 def STZGM : MemTagVector<0, "stzgm", "\t$Rt, [$Rn]",
1338 (outs), (ins GPR64:$Rt, GPR64sp:$Rn)> {
1342 defm STG : MemTagStore<0b00, "stg">;
1343 defm STZG : MemTagStore<0b01, "stzg">;
1344 defm ST2G : MemTagStore<0b10, "st2g">;
1345 defm STZ2G : MemTagStore<0b11, "stz2g">;
1347 def : Pat<(AArch64stg GPR64sp:$Rn, (am_indexeds9s128 GPR64sp:$Rm, simm9s16:$imm)),
1348 (STGOffset $Rn, $Rm, $imm)>;
1349 def : Pat<(AArch64stzg GPR64sp:$Rn, (am_indexeds9s128 GPR64sp:$Rm, simm9s16:$imm)),
1350 (STZGOffset $Rn, $Rm, $imm)>;
1351 def : Pat<(AArch64st2g GPR64sp:$Rn, (am_indexeds9s128 GPR64sp:$Rm, simm9s16:$imm)),
1352 (ST2GOffset $Rn, $Rm, $imm)>;
1353 def : Pat<(AArch64stz2g GPR64sp:$Rn, (am_indexeds9s128 GPR64sp:$Rm, simm9s16:$imm)),
1354 (STZ2GOffset $Rn, $Rm, $imm)>;
1356 defm STGP : StorePairOffset <0b01, 0, GPR64z, simm7s16, "stgp">;
1357 def STGPpre : StorePairPreIdx <0b01, 0, GPR64z, simm7s16, "stgp">;
1358 def STGPpost : StorePairPostIdx<0b01, 0, GPR64z, simm7s16, "stgp">;
1360 def : Pat<(int_aarch64_stg GPR64:$Rt, (am_indexeds9s128 GPR64sp:$Rn, simm9s16:$offset)),
1361 (STGOffset GPR64:$Rt, GPR64sp:$Rn, simm9s16:$offset)>;
1363 def : Pat<(int_aarch64_stgp (am_indexed7s128 GPR64sp:$Rn, simm7s16:$imm), GPR64:$Rt, GPR64:$Rt2),
1364 (STGPi $Rt, $Rt2, $Rn, $imm)>;
1367 : Pseudo<(outs GPR64sp:$Rd), (ins GPR64sp:$Rsp, GPR64:$Rm), []>,
1370 : Pseudo<(outs GPR64sp:$Rd), (ins GPR64sp:$Rn, uimm6s16:$imm6, GPR64sp:$Rm, imm0_15:$imm4), []>,
1373 // Explicit SP in the first operand prevents ShrinkWrap optimization
1374 // from leaving this instruction out of the stack frame. When IRGstack
1375 // is transformed into IRG, this operand is replaced with the actual
1376 // register / expression for the tagged base pointer of the current function.
1377 def : Pat<(int_aarch64_irg_sp i64:$Rm), (IRGstack SP, i64:$Rm)>;
1379 // Large STG to be expanded into a loop. $Rm is the size, $Rn is start address.
1380 // $Rn_wback is one past the end of the range.
1381 let isCodeGenOnly=1, mayStore=1 in {
1383 : Pseudo<(outs GPR64common:$Rm_wback, GPR64sp:$Rn_wback), (ins GPR64common:$Rm, GPR64sp:$Rn),
1384 [], "$Rn = $Rn_wback,@earlyclobber $Rn_wback,$Rm = $Rm_wback,@earlyclobber $Rm_wback" >,
1385 Sched<[WriteAdr, WriteST]>;
1388 : Pseudo<(outs GPR64common:$Rm_wback, GPR64sp:$Rn_wback), (ins GPR64common:$Rm, GPR64sp:$Rn),
1389 [], "$Rn = $Rn_wback,@earlyclobber $Rn_wback,$Rm = $Rm_wback,@earlyclobber $Rm_wback" >,
1390 Sched<[WriteAdr, WriteST]>;
1393 } // Predicates = [HasMTE]
1395 //===----------------------------------------------------------------------===//
1396 // Logical instructions.
1397 //===----------------------------------------------------------------------===//
1400 defm ANDS : LogicalImmS<0b11, "ands", AArch64and_flag, "bics">;
1401 defm AND : LogicalImm<0b00, "and", and, "bic">;
1402 defm EOR : LogicalImm<0b10, "eor", xor, "eon">;
1403 defm ORR : LogicalImm<0b01, "orr", or, "orn">;
1405 // FIXME: these aliases *are* canonical sometimes (when movz can't be
1406 // used). Actually, it seems to be working right now, but putting logical_immXX
1407 // here is a bit dodgy on the AsmParser side too.
1408 def : InstAlias<"mov $dst, $imm", (ORRWri GPR32sp:$dst, WZR,
1409 logical_imm32:$imm), 0>;
1410 def : InstAlias<"mov $dst, $imm", (ORRXri GPR64sp:$dst, XZR,
1411 logical_imm64:$imm), 0>;
1415 defm ANDS : LogicalRegS<0b11, 0, "ands", AArch64and_flag>;
1416 defm BICS : LogicalRegS<0b11, 1, "bics",
1417 BinOpFrag<(AArch64and_flag node:$LHS, (not node:$RHS))>>;
1418 defm AND : LogicalReg<0b00, 0, "and", and>;
1419 defm BIC : LogicalReg<0b00, 1, "bic",
1420 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
1421 defm EON : LogicalReg<0b10, 1, "eon",
1422 BinOpFrag<(not (xor node:$LHS, node:$RHS))>>;
1423 defm EOR : LogicalReg<0b10, 0, "eor", xor>;
1424 defm ORN : LogicalReg<0b01, 1, "orn",
1425 BinOpFrag<(or node:$LHS, (not node:$RHS))>>;
1426 defm ORR : LogicalReg<0b01, 0, "orr", or>;
1428 def : InstAlias<"mov $dst, $src", (ORRWrs GPR32:$dst, WZR, GPR32:$src, 0), 2>;
1429 def : InstAlias<"mov $dst, $src", (ORRXrs GPR64:$dst, XZR, GPR64:$src, 0), 2>;
1431 def : InstAlias<"mvn $Wd, $Wm", (ORNWrs GPR32:$Wd, WZR, GPR32:$Wm, 0), 3>;
1432 def : InstAlias<"mvn $Xd, $Xm", (ORNXrs GPR64:$Xd, XZR, GPR64:$Xm, 0), 3>;
1434 def : InstAlias<"mvn $Wd, $Wm$sh",
1435 (ORNWrs GPR32:$Wd, WZR, GPR32:$Wm, logical_shift32:$sh), 2>;
1436 def : InstAlias<"mvn $Xd, $Xm$sh",
1437 (ORNXrs GPR64:$Xd, XZR, GPR64:$Xm, logical_shift64:$sh), 2>;
1439 def : InstAlias<"tst $src1, $src2",
1440 (ANDSWri WZR, GPR32:$src1, logical_imm32:$src2), 2>;
1441 def : InstAlias<"tst $src1, $src2",
1442 (ANDSXri XZR, GPR64:$src1, logical_imm64:$src2), 2>;
1444 def : InstAlias<"tst $src1, $src2",
1445 (ANDSWrs WZR, GPR32:$src1, GPR32:$src2, 0), 3>;
1446 def : InstAlias<"tst $src1, $src2",
1447 (ANDSXrs XZR, GPR64:$src1, GPR64:$src2, 0), 3>;
1449 def : InstAlias<"tst $src1, $src2$sh",
1450 (ANDSWrs WZR, GPR32:$src1, GPR32:$src2, logical_shift32:$sh), 2>;
1451 def : InstAlias<"tst $src1, $src2$sh",
1452 (ANDSXrs XZR, GPR64:$src1, GPR64:$src2, logical_shift64:$sh), 2>;
1455 def : Pat<(not GPR32:$Wm), (ORNWrr WZR, GPR32:$Wm)>;
1456 def : Pat<(not GPR64:$Xm), (ORNXrr XZR, GPR64:$Xm)>;
1459 //===----------------------------------------------------------------------===//
1460 // One operand data processing instructions.
1461 //===----------------------------------------------------------------------===//
1463 defm CLS : OneOperandData<0b101, "cls">;
1464 defm CLZ : OneOperandData<0b100, "clz", ctlz>;
1465 defm RBIT : OneOperandData<0b000, "rbit", bitreverse>;
1467 def REV16Wr : OneWRegData<0b001, "rev16",
1468 UnOpFrag<(rotr (bswap node:$LHS), (i64 16))>>;
1469 def REV16Xr : OneXRegData<0b001, "rev16", null_frag>;
1471 def : Pat<(cttz GPR32:$Rn),
1472 (CLZWr (RBITWr GPR32:$Rn))>;
1473 def : Pat<(cttz GPR64:$Rn),
1474 (CLZXr (RBITXr GPR64:$Rn))>;
1475 def : Pat<(ctlz (or (shl (xor (sra GPR32:$Rn, (i64 31)), GPR32:$Rn), (i64 1)),
1478 def : Pat<(ctlz (or (shl (xor (sra GPR64:$Rn, (i64 63)), GPR64:$Rn), (i64 1)),
1482 // Unlike the other one operand instructions, the instructions with the "rev"
1483 // mnemonic do *not* just different in the size bit, but actually use different
1484 // opcode bits for the different sizes.
1485 def REVWr : OneWRegData<0b010, "rev", bswap>;
1486 def REVXr : OneXRegData<0b011, "rev", bswap>;
1487 def REV32Xr : OneXRegData<0b010, "rev32",
1488 UnOpFrag<(rotr (bswap node:$LHS), (i64 32))>>;
1490 def : InstAlias<"rev64 $Rd, $Rn", (REVXr GPR64:$Rd, GPR64:$Rn), 0>;
1492 // The bswap commutes with the rotr so we want a pattern for both possible
1494 def : Pat<(bswap (rotr GPR32:$Rn, (i64 16))), (REV16Wr GPR32:$Rn)>;
1495 def : Pat<(bswap (rotr GPR64:$Rn, (i64 32))), (REV32Xr GPR64:$Rn)>;
1497 //===----------------------------------------------------------------------===//
1498 // Bitfield immediate extraction instruction.
1499 //===----------------------------------------------------------------------===//
1500 let hasSideEffects = 0 in
1501 defm EXTR : ExtractImm<"extr">;
1502 def : InstAlias<"ror $dst, $src, $shift",
1503 (EXTRWrri GPR32:$dst, GPR32:$src, GPR32:$src, imm0_31:$shift)>;
1504 def : InstAlias<"ror $dst, $src, $shift",
1505 (EXTRXrri GPR64:$dst, GPR64:$src, GPR64:$src, imm0_63:$shift)>;
1507 def : Pat<(rotr GPR32:$Rn, (i64 imm0_31:$imm)),
1508 (EXTRWrri GPR32:$Rn, GPR32:$Rn, imm0_31:$imm)>;
1509 def : Pat<(rotr GPR64:$Rn, (i64 imm0_63:$imm)),
1510 (EXTRXrri GPR64:$Rn, GPR64:$Rn, imm0_63:$imm)>;
1512 //===----------------------------------------------------------------------===//
1513 // Other bitfield immediate instructions.
1514 //===----------------------------------------------------------------------===//
1515 let hasSideEffects = 0 in {
1516 defm BFM : BitfieldImmWith2RegArgs<0b01, "bfm">;
1517 defm SBFM : BitfieldImm<0b00, "sbfm">;
1518 defm UBFM : BitfieldImm<0b10, "ubfm">;
1521 def i32shift_a : Operand<i64>, SDNodeXForm<imm, [{
1522 uint64_t enc = (32 - N->getZExtValue()) & 0x1f;
1523 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1526 def i32shift_b : Operand<i64>, SDNodeXForm<imm, [{
1527 uint64_t enc = 31 - N->getZExtValue();
1528 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1531 // min(7, 31 - shift_amt)
1532 def i32shift_sext_i8 : Operand<i64>, SDNodeXForm<imm, [{
1533 uint64_t enc = 31 - N->getZExtValue();
1534 enc = enc > 7 ? 7 : enc;
1535 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1538 // min(15, 31 - shift_amt)
1539 def i32shift_sext_i16 : Operand<i64>, SDNodeXForm<imm, [{
1540 uint64_t enc = 31 - N->getZExtValue();
1541 enc = enc > 15 ? 15 : enc;
1542 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1545 def i64shift_a : Operand<i64>, SDNodeXForm<imm, [{
1546 uint64_t enc = (64 - N->getZExtValue()) & 0x3f;
1547 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1550 def i64shift_b : Operand<i64>, SDNodeXForm<imm, [{
1551 uint64_t enc = 63 - N->getZExtValue();
1552 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1555 // min(7, 63 - shift_amt)
1556 def i64shift_sext_i8 : Operand<i64>, SDNodeXForm<imm, [{
1557 uint64_t enc = 63 - N->getZExtValue();
1558 enc = enc > 7 ? 7 : enc;
1559 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1562 // min(15, 63 - shift_amt)
1563 def i64shift_sext_i16 : Operand<i64>, SDNodeXForm<imm, [{
1564 uint64_t enc = 63 - N->getZExtValue();
1565 enc = enc > 15 ? 15 : enc;
1566 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1569 // min(31, 63 - shift_amt)
1570 def i64shift_sext_i32 : Operand<i64>, SDNodeXForm<imm, [{
1571 uint64_t enc = 63 - N->getZExtValue();
1572 enc = enc > 31 ? 31 : enc;
1573 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1576 def : Pat<(shl GPR32:$Rn, (i64 imm0_31:$imm)),
1577 (UBFMWri GPR32:$Rn, (i64 (i32shift_a imm0_31:$imm)),
1578 (i64 (i32shift_b imm0_31:$imm)))>;
1579 def : Pat<(shl GPR64:$Rn, (i64 imm0_63:$imm)),
1580 (UBFMXri GPR64:$Rn, (i64 (i64shift_a imm0_63:$imm)),
1581 (i64 (i64shift_b imm0_63:$imm)))>;
1583 let AddedComplexity = 10 in {
1584 def : Pat<(sra GPR32:$Rn, (i64 imm0_31:$imm)),
1585 (SBFMWri GPR32:$Rn, imm0_31:$imm, 31)>;
1586 def : Pat<(sra GPR64:$Rn, (i64 imm0_63:$imm)),
1587 (SBFMXri GPR64:$Rn, imm0_63:$imm, 63)>;
1590 def : InstAlias<"asr $dst, $src, $shift",
1591 (SBFMWri GPR32:$dst, GPR32:$src, imm0_31:$shift, 31)>;
1592 def : InstAlias<"asr $dst, $src, $shift",
1593 (SBFMXri GPR64:$dst, GPR64:$src, imm0_63:$shift, 63)>;
1594 def : InstAlias<"sxtb $dst, $src", (SBFMWri GPR32:$dst, GPR32:$src, 0, 7)>;
1595 def : InstAlias<"sxtb $dst, $src", (SBFMXri GPR64:$dst, GPR64:$src, 0, 7)>;
1596 def : InstAlias<"sxth $dst, $src", (SBFMWri GPR32:$dst, GPR32:$src, 0, 15)>;
1597 def : InstAlias<"sxth $dst, $src", (SBFMXri GPR64:$dst, GPR64:$src, 0, 15)>;
1598 def : InstAlias<"sxtw $dst, $src", (SBFMXri GPR64:$dst, GPR64:$src, 0, 31)>;
1600 def : Pat<(srl GPR32:$Rn, (i64 imm0_31:$imm)),
1601 (UBFMWri GPR32:$Rn, imm0_31:$imm, 31)>;
1602 def : Pat<(srl GPR64:$Rn, (i64 imm0_63:$imm)),
1603 (UBFMXri GPR64:$Rn, imm0_63:$imm, 63)>;
1605 def : InstAlias<"lsr $dst, $src, $shift",
1606 (UBFMWri GPR32:$dst, GPR32:$src, imm0_31:$shift, 31)>;
1607 def : InstAlias<"lsr $dst, $src, $shift",
1608 (UBFMXri GPR64:$dst, GPR64:$src, imm0_63:$shift, 63)>;
1609 def : InstAlias<"uxtb $dst, $src", (UBFMWri GPR32:$dst, GPR32:$src, 0, 7)>;
1610 def : InstAlias<"uxtb $dst, $src", (UBFMXri GPR64:$dst, GPR64:$src, 0, 7)>;
1611 def : InstAlias<"uxth $dst, $src", (UBFMWri GPR32:$dst, GPR32:$src, 0, 15)>;
1612 def : InstAlias<"uxth $dst, $src", (UBFMXri GPR64:$dst, GPR64:$src, 0, 15)>;
1613 def : InstAlias<"uxtw $dst, $src", (UBFMXri GPR64:$dst, GPR64:$src, 0, 31)>;
1615 //===----------------------------------------------------------------------===//
1616 // Conditional comparison instructions.
1617 //===----------------------------------------------------------------------===//
1618 defm CCMN : CondComparison<0, "ccmn", AArch64ccmn>;
1619 defm CCMP : CondComparison<1, "ccmp", AArch64ccmp>;
1621 //===----------------------------------------------------------------------===//
1622 // Conditional select instructions.
1623 //===----------------------------------------------------------------------===//
1624 defm CSEL : CondSelect<0, 0b00, "csel">;
1626 def inc : PatFrag<(ops node:$in), (add node:$in, 1)>;
1627 defm CSINC : CondSelectOp<0, 0b01, "csinc", inc>;
1628 defm CSINV : CondSelectOp<1, 0b00, "csinv", not>;
1629 defm CSNEG : CondSelectOp<1, 0b01, "csneg", ineg>;
1631 def : Pat<(AArch64csinv GPR32:$tval, GPR32:$fval, (i32 imm:$cc), NZCV),
1632 (CSINVWr GPR32:$tval, GPR32:$fval, (i32 imm:$cc))>;
1633 def : Pat<(AArch64csinv GPR64:$tval, GPR64:$fval, (i32 imm:$cc), NZCV),
1634 (CSINVXr GPR64:$tval, GPR64:$fval, (i32 imm:$cc))>;
1635 def : Pat<(AArch64csneg GPR32:$tval, GPR32:$fval, (i32 imm:$cc), NZCV),
1636 (CSNEGWr GPR32:$tval, GPR32:$fval, (i32 imm:$cc))>;
1637 def : Pat<(AArch64csneg GPR64:$tval, GPR64:$fval, (i32 imm:$cc), NZCV),
1638 (CSNEGXr GPR64:$tval, GPR64:$fval, (i32 imm:$cc))>;
1639 def : Pat<(AArch64csinc GPR32:$tval, GPR32:$fval, (i32 imm:$cc), NZCV),
1640 (CSINCWr GPR32:$tval, GPR32:$fval, (i32 imm:$cc))>;
1641 def : Pat<(AArch64csinc GPR64:$tval, GPR64:$fval, (i32 imm:$cc), NZCV),
1642 (CSINCXr GPR64:$tval, GPR64:$fval, (i32 imm:$cc))>;
1644 def : Pat<(AArch64csel (i32 0), (i32 1), (i32 imm:$cc), NZCV),
1645 (CSINCWr WZR, WZR, (i32 imm:$cc))>;
1646 def : Pat<(AArch64csel (i64 0), (i64 1), (i32 imm:$cc), NZCV),
1647 (CSINCXr XZR, XZR, (i32 imm:$cc))>;
1648 def : Pat<(AArch64csel GPR32:$tval, (i32 1), (i32 imm:$cc), NZCV),
1649 (CSINCWr GPR32:$tval, WZR, (i32 imm:$cc))>;
1650 def : Pat<(AArch64csel GPR64:$tval, (i64 1), (i32 imm:$cc), NZCV),
1651 (CSINCXr GPR64:$tval, XZR, (i32 imm:$cc))>;
1652 def : Pat<(AArch64csel (i32 1), GPR32:$fval, (i32 imm:$cc), NZCV),
1653 (CSINCWr GPR32:$fval, WZR, (i32 (inv_cond_XFORM imm:$cc)))>;
1654 def : Pat<(AArch64csel (i64 1), GPR64:$fval, (i32 imm:$cc), NZCV),
1655 (CSINCXr GPR64:$fval, XZR, (i32 (inv_cond_XFORM imm:$cc)))>;
1656 def : Pat<(AArch64csel (i32 0), (i32 -1), (i32 imm:$cc), NZCV),
1657 (CSINVWr WZR, WZR, (i32 imm:$cc))>;
1658 def : Pat<(AArch64csel (i64 0), (i64 -1), (i32 imm:$cc), NZCV),
1659 (CSINVXr XZR, XZR, (i32 imm:$cc))>;
1660 def : Pat<(AArch64csel GPR32:$tval, (i32 -1), (i32 imm:$cc), NZCV),
1661 (CSINVWr GPR32:$tval, WZR, (i32 imm:$cc))>;
1662 def : Pat<(AArch64csel GPR64:$tval, (i64 -1), (i32 imm:$cc), NZCV),
1663 (CSINVXr GPR64:$tval, XZR, (i32 imm:$cc))>;
1664 def : Pat<(AArch64csel (i32 -1), GPR32:$fval, (i32 imm:$cc), NZCV),
1665 (CSINVWr GPR32:$fval, WZR, (i32 (inv_cond_XFORM imm:$cc)))>;
1666 def : Pat<(AArch64csel (i64 -1), GPR64:$fval, (i32 imm:$cc), NZCV),
1667 (CSINVXr GPR64:$fval, XZR, (i32 (inv_cond_XFORM imm:$cc)))>;
1669 // The inverse of the condition code from the alias instruction is what is used
1670 // in the aliased instruction. The parser all ready inverts the condition code
1671 // for these aliases.
1672 def : InstAlias<"cset $dst, $cc",
1673 (CSINCWr GPR32:$dst, WZR, WZR, inv_ccode:$cc)>;
1674 def : InstAlias<"cset $dst, $cc",
1675 (CSINCXr GPR64:$dst, XZR, XZR, inv_ccode:$cc)>;
1677 def : InstAlias<"csetm $dst, $cc",
1678 (CSINVWr GPR32:$dst, WZR, WZR, inv_ccode:$cc)>;
1679 def : InstAlias<"csetm $dst, $cc",
1680 (CSINVXr GPR64:$dst, XZR, XZR, inv_ccode:$cc)>;
1682 def : InstAlias<"cinc $dst, $src, $cc",
1683 (CSINCWr GPR32:$dst, GPR32:$src, GPR32:$src, inv_ccode:$cc)>;
1684 def : InstAlias<"cinc $dst, $src, $cc",
1685 (CSINCXr GPR64:$dst, GPR64:$src, GPR64:$src, inv_ccode:$cc)>;
1687 def : InstAlias<"cinv $dst, $src, $cc",
1688 (CSINVWr GPR32:$dst, GPR32:$src, GPR32:$src, inv_ccode:$cc)>;
1689 def : InstAlias<"cinv $dst, $src, $cc",
1690 (CSINVXr GPR64:$dst, GPR64:$src, GPR64:$src, inv_ccode:$cc)>;
1692 def : InstAlias<"cneg $dst, $src, $cc",
1693 (CSNEGWr GPR32:$dst, GPR32:$src, GPR32:$src, inv_ccode:$cc)>;
1694 def : InstAlias<"cneg $dst, $src, $cc",
1695 (CSNEGXr GPR64:$dst, GPR64:$src, GPR64:$src, inv_ccode:$cc)>;
1697 //===----------------------------------------------------------------------===//
1698 // PC-relative instructions.
1699 //===----------------------------------------------------------------------===//
1700 let isReMaterializable = 1 in {
1701 let hasSideEffects = 0, mayStore = 0, mayLoad = 0 in {
1702 def ADR : ADRI<0, "adr", adrlabel,
1703 [(set GPR64:$Xd, (AArch64adr tglobaladdr:$label))]>;
1704 } // hasSideEffects = 0
1706 def ADRP : ADRI<1, "adrp", adrplabel,
1707 [(set GPR64:$Xd, (AArch64adrp tglobaladdr:$label))]>;
1708 } // isReMaterializable = 1
1710 // page address of a constant pool entry, block address
1711 def : Pat<(AArch64adr tconstpool:$cp), (ADR tconstpool:$cp)>;
1712 def : Pat<(AArch64adr tblockaddress:$cp), (ADR tblockaddress:$cp)>;
1713 def : Pat<(AArch64adr texternalsym:$sym), (ADR texternalsym:$sym)>;
1714 def : Pat<(AArch64adr tjumptable:$sym), (ADR tjumptable:$sym)>;
1715 def : Pat<(AArch64adrp tconstpool:$cp), (ADRP tconstpool:$cp)>;
1716 def : Pat<(AArch64adrp tblockaddress:$cp), (ADRP tblockaddress:$cp)>;
1717 def : Pat<(AArch64adrp texternalsym:$sym), (ADRP texternalsym:$sym)>;
1719 //===----------------------------------------------------------------------===//
1720 // Unconditional branch (register) instructions.
1721 //===----------------------------------------------------------------------===//
1723 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
1724 def RET : BranchReg<0b0010, "ret", []>;
1725 def DRPS : SpecialReturn<0b0101, "drps">;
1726 def ERET : SpecialReturn<0b0100, "eret">;
1727 } // isReturn = 1, isTerminator = 1, isBarrier = 1
1729 // Default to the LR register.
1730 def : InstAlias<"ret", (RET LR)>;
1732 let isCall = 1, Defs = [LR], Uses = [SP] in {
1733 def BLR : BranchReg<0b0001, "blr", [(AArch64call GPR64:$Rn)]>;
1736 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
1737 def BR : BranchReg<0b0000, "br", [(brind GPR64:$Rn)]>;
1738 } // isBranch, isTerminator, isBarrier, isIndirectBranch
1740 // Create a separate pseudo-instruction for codegen to use so that we don't
1741 // flag lr as used in every function. It'll be restored before the RET by the
1742 // epilogue if it's legitimately used.
1743 def RET_ReallyLR : Pseudo<(outs), (ins), [(AArch64retflag)]>,
1744 Sched<[WriteBrReg]> {
1745 let isTerminator = 1;
1750 // This is a directive-like pseudo-instruction. The purpose is to insert an
1751 // R_AARCH64_TLSDESC_CALL relocation at the offset of the following instruction
1752 // (which in the usual case is a BLR).
1753 let hasSideEffects = 1 in
1754 def TLSDESCCALL : Pseudo<(outs), (ins i64imm:$sym), []>, Sched<[]> {
1755 let AsmString = ".tlsdesccall $sym";
1758 // Pseudo instruction to tell the streamer to emit a 'B' character into the
1759 // augmentation string.
1760 def EMITBKEY : Pseudo<(outs), (ins), []>, Sched<[]> {}
1762 // FIXME: maybe the scratch register used shouldn't be fixed to X1?
1763 // FIXME: can "hasSideEffects be dropped?
1764 let isCall = 1, Defs = [LR, X0, X1], hasSideEffects = 1,
1765 isCodeGenOnly = 1 in
1767 : Pseudo<(outs), (ins i64imm:$sym),
1768 [(AArch64tlsdesc_callseq tglobaltlsaddr:$sym)]>,
1769 Sched<[WriteI, WriteLD, WriteI, WriteBrReg]>;
1770 def : Pat<(AArch64tlsdesc_callseq texternalsym:$sym),
1771 (TLSDESC_CALLSEQ texternalsym:$sym)>;
1773 //===----------------------------------------------------------------------===//
1774 // Conditional branch (immediate) instruction.
1775 //===----------------------------------------------------------------------===//
1776 def Bcc : BranchCond;
1778 //===----------------------------------------------------------------------===//
1779 // Compare-and-branch instructions.
1780 //===----------------------------------------------------------------------===//
1781 defm CBZ : CmpBranch<0, "cbz", AArch64cbz>;
1782 defm CBNZ : CmpBranch<1, "cbnz", AArch64cbnz>;
1784 //===----------------------------------------------------------------------===//
1785 // Test-bit-and-branch instructions.
1786 //===----------------------------------------------------------------------===//
1787 defm TBZ : TestBranch<0, "tbz", AArch64tbz>;
1788 defm TBNZ : TestBranch<1, "tbnz", AArch64tbnz>;
1790 //===----------------------------------------------------------------------===//
1791 // Unconditional branch (immediate) instructions.
1792 //===----------------------------------------------------------------------===//
1793 let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
1794 def B : BranchImm<0, "b", [(br bb:$addr)]>;
1795 } // isBranch, isTerminator, isBarrier
1797 let isCall = 1, Defs = [LR], Uses = [SP] in {
1798 def BL : CallImm<1, "bl", [(AArch64call tglobaladdr:$addr)]>;
1800 def : Pat<(AArch64call texternalsym:$func), (BL texternalsym:$func)>;
1802 //===----------------------------------------------------------------------===//
1803 // Exception generation instructions.
1804 //===----------------------------------------------------------------------===//
1806 def BRK : ExceptionGeneration<0b001, 0b00, "brk">;
1808 def DCPS1 : ExceptionGeneration<0b101, 0b01, "dcps1">;
1809 def DCPS2 : ExceptionGeneration<0b101, 0b10, "dcps2">;
1810 def DCPS3 : ExceptionGeneration<0b101, 0b11, "dcps3">;
1811 def HLT : ExceptionGeneration<0b010, 0b00, "hlt">;
1812 def HVC : ExceptionGeneration<0b000, 0b10, "hvc">;
1813 def SMC : ExceptionGeneration<0b000, 0b11, "smc">;
1814 def SVC : ExceptionGeneration<0b000, 0b01, "svc">;
1816 // DCPSn defaults to an immediate operand of zero if unspecified.
1817 def : InstAlias<"dcps1", (DCPS1 0)>;
1818 def : InstAlias<"dcps2", (DCPS2 0)>;
1819 def : InstAlias<"dcps3", (DCPS3 0)>;
1821 def UDF : UDFType<0, "udf">;
1823 //===----------------------------------------------------------------------===//
1824 // Load instructions.
1825 //===----------------------------------------------------------------------===//
1827 // Pair (indexed, offset)
1828 defm LDPW : LoadPairOffset<0b00, 0, GPR32z, simm7s4, "ldp">;
1829 defm LDPX : LoadPairOffset<0b10, 0, GPR64z, simm7s8, "ldp">;
1830 defm LDPS : LoadPairOffset<0b00, 1, FPR32Op, simm7s4, "ldp">;
1831 defm LDPD : LoadPairOffset<0b01, 1, FPR64Op, simm7s8, "ldp">;
1832 defm LDPQ : LoadPairOffset<0b10, 1, FPR128Op, simm7s16, "ldp">;
1834 defm LDPSW : LoadPairOffset<0b01, 0, GPR64z, simm7s4, "ldpsw">;
1836 // Pair (pre-indexed)
1837 def LDPWpre : LoadPairPreIdx<0b00, 0, GPR32z, simm7s4, "ldp">;
1838 def LDPXpre : LoadPairPreIdx<0b10, 0, GPR64z, simm7s8, "ldp">;
1839 def LDPSpre : LoadPairPreIdx<0b00, 1, FPR32Op, simm7s4, "ldp">;
1840 def LDPDpre : LoadPairPreIdx<0b01, 1, FPR64Op, simm7s8, "ldp">;
1841 def LDPQpre : LoadPairPreIdx<0b10, 1, FPR128Op, simm7s16, "ldp">;
1843 def LDPSWpre : LoadPairPreIdx<0b01, 0, GPR64z, simm7s4, "ldpsw">;
1845 // Pair (post-indexed)
1846 def LDPWpost : LoadPairPostIdx<0b00, 0, GPR32z, simm7s4, "ldp">;
1847 def LDPXpost : LoadPairPostIdx<0b10, 0, GPR64z, simm7s8, "ldp">;
1848 def LDPSpost : LoadPairPostIdx<0b00, 1, FPR32Op, simm7s4, "ldp">;
1849 def LDPDpost : LoadPairPostIdx<0b01, 1, FPR64Op, simm7s8, "ldp">;
1850 def LDPQpost : LoadPairPostIdx<0b10, 1, FPR128Op, simm7s16, "ldp">;
1852 def LDPSWpost : LoadPairPostIdx<0b01, 0, GPR64z, simm7s4, "ldpsw">;
1855 // Pair (no allocate)
1856 defm LDNPW : LoadPairNoAlloc<0b00, 0, GPR32z, simm7s4, "ldnp">;
1857 defm LDNPX : LoadPairNoAlloc<0b10, 0, GPR64z, simm7s8, "ldnp">;
1858 defm LDNPS : LoadPairNoAlloc<0b00, 1, FPR32Op, simm7s4, "ldnp">;
1859 defm LDNPD : LoadPairNoAlloc<0b01, 1, FPR64Op, simm7s8, "ldnp">;
1860 defm LDNPQ : LoadPairNoAlloc<0b10, 1, FPR128Op, simm7s16, "ldnp">;
1863 // (register offset)
1867 defm LDRBB : Load8RO<0b00, 0, 0b01, GPR32, "ldrb", i32, zextloadi8>;
1868 defm LDRHH : Load16RO<0b01, 0, 0b01, GPR32, "ldrh", i32, zextloadi16>;
1869 defm LDRW : Load32RO<0b10, 0, 0b01, GPR32, "ldr", i32, load>;
1870 defm LDRX : Load64RO<0b11, 0, 0b01, GPR64, "ldr", i64, load>;
1873 defm LDRB : Load8RO<0b00, 1, 0b01, FPR8Op, "ldr", untyped, load>;
1874 defm LDRH : Load16RO<0b01, 1, 0b01, FPR16Op, "ldr", f16, load>;
1875 defm LDRS : Load32RO<0b10, 1, 0b01, FPR32Op, "ldr", f32, load>;
1876 defm LDRD : Load64RO<0b11, 1, 0b01, FPR64Op, "ldr", f64, load>;
1877 defm LDRQ : Load128RO<0b00, 1, 0b11, FPR128Op, "ldr", f128, load>;
1879 // Load sign-extended half-word
1880 defm LDRSHW : Load16RO<0b01, 0, 0b11, GPR32, "ldrsh", i32, sextloadi16>;
1881 defm LDRSHX : Load16RO<0b01, 0, 0b10, GPR64, "ldrsh", i64, sextloadi16>;
1883 // Load sign-extended byte
1884 defm LDRSBW : Load8RO<0b00, 0, 0b11, GPR32, "ldrsb", i32, sextloadi8>;
1885 defm LDRSBX : Load8RO<0b00, 0, 0b10, GPR64, "ldrsb", i64, sextloadi8>;
1887 // Load sign-extended word
1888 defm LDRSW : Load32RO<0b10, 0, 0b10, GPR64, "ldrsw", i64, sextloadi32>;
1891 defm PRFM : PrefetchRO<0b11, 0, 0b10, "prfm">;
1893 // For regular load, we do not have any alignment requirement.
1894 // Thus, it is safe to directly map the vector loads with interesting
1895 // addressing modes.
1896 // FIXME: We could do the same for bitconvert to floating point vectors.
1897 multiclass ScalToVecROLoadPat<ROAddrMode ro, SDPatternOperator loadop,
1898 ValueType ScalTy, ValueType VecTy,
1899 Instruction LOADW, Instruction LOADX,
1901 def : Pat<(VecTy (scalar_to_vector (ScalTy
1902 (loadop (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$offset))))),
1903 (INSERT_SUBREG (VecTy (IMPLICIT_DEF)),
1904 (LOADW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$offset),
1907 def : Pat<(VecTy (scalar_to_vector (ScalTy
1908 (loadop (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$offset))))),
1909 (INSERT_SUBREG (VecTy (IMPLICIT_DEF)),
1910 (LOADX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$offset),
1914 let AddedComplexity = 10 in {
1915 defm : ScalToVecROLoadPat<ro8, extloadi8, i32, v8i8, LDRBroW, LDRBroX, bsub>;
1916 defm : ScalToVecROLoadPat<ro8, extloadi8, i32, v16i8, LDRBroW, LDRBroX, bsub>;
1918 defm : ScalToVecROLoadPat<ro16, extloadi16, i32, v4i16, LDRHroW, LDRHroX, hsub>;
1919 defm : ScalToVecROLoadPat<ro16, extloadi16, i32, v8i16, LDRHroW, LDRHroX, hsub>;
1921 defm : ScalToVecROLoadPat<ro16, load, i32, v4f16, LDRHroW, LDRHroX, hsub>;
1922 defm : ScalToVecROLoadPat<ro16, load, i32, v8f16, LDRHroW, LDRHroX, hsub>;
1924 defm : ScalToVecROLoadPat<ro32, load, i32, v2i32, LDRSroW, LDRSroX, ssub>;
1925 defm : ScalToVecROLoadPat<ro32, load, i32, v4i32, LDRSroW, LDRSroX, ssub>;
1927 defm : ScalToVecROLoadPat<ro32, load, f32, v2f32, LDRSroW, LDRSroX, ssub>;
1928 defm : ScalToVecROLoadPat<ro32, load, f32, v4f32, LDRSroW, LDRSroX, ssub>;
1930 defm : ScalToVecROLoadPat<ro64, load, i64, v2i64, LDRDroW, LDRDroX, dsub>;
1932 defm : ScalToVecROLoadPat<ro64, load, f64, v2f64, LDRDroW, LDRDroX, dsub>;
1935 def : Pat <(v1i64 (scalar_to_vector (i64
1936 (load (ro_Windexed64 GPR64sp:$Rn, GPR32:$Rm,
1937 ro_Wextend64:$extend))))),
1938 (LDRDroW GPR64sp:$Rn, GPR32:$Rm, ro_Wextend64:$extend)>;
1940 def : Pat <(v1i64 (scalar_to_vector (i64
1941 (load (ro_Xindexed64 GPR64sp:$Rn, GPR64:$Rm,
1942 ro_Xextend64:$extend))))),
1943 (LDRDroX GPR64sp:$Rn, GPR64:$Rm, ro_Xextend64:$extend)>;
1946 // Match all load 64 bits width whose type is compatible with FPR64
1947 multiclass VecROLoadPat<ROAddrMode ro, ValueType VecTy,
1948 Instruction LOADW, Instruction LOADX> {
1950 def : Pat<(VecTy (load (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend))),
1951 (LOADW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
1953 def : Pat<(VecTy (load (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend))),
1954 (LOADX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
1957 let AddedComplexity = 10 in {
1958 let Predicates = [IsLE] in {
1959 // We must do vector loads with LD1 in big-endian.
1960 defm : VecROLoadPat<ro64, v2i32, LDRDroW, LDRDroX>;
1961 defm : VecROLoadPat<ro64, v2f32, LDRDroW, LDRDroX>;
1962 defm : VecROLoadPat<ro64, v8i8, LDRDroW, LDRDroX>;
1963 defm : VecROLoadPat<ro64, v4i16, LDRDroW, LDRDroX>;
1964 defm : VecROLoadPat<ro64, v4f16, LDRDroW, LDRDroX>;
1967 defm : VecROLoadPat<ro64, v1i64, LDRDroW, LDRDroX>;
1968 defm : VecROLoadPat<ro64, v1f64, LDRDroW, LDRDroX>;
1970 // Match all load 128 bits width whose type is compatible with FPR128
1971 let Predicates = [IsLE] in {
1972 // We must do vector loads with LD1 in big-endian.
1973 defm : VecROLoadPat<ro128, v2i64, LDRQroW, LDRQroX>;
1974 defm : VecROLoadPat<ro128, v2f64, LDRQroW, LDRQroX>;
1975 defm : VecROLoadPat<ro128, v4i32, LDRQroW, LDRQroX>;
1976 defm : VecROLoadPat<ro128, v4f32, LDRQroW, LDRQroX>;
1977 defm : VecROLoadPat<ro128, v8i16, LDRQroW, LDRQroX>;
1978 defm : VecROLoadPat<ro128, v8f16, LDRQroW, LDRQroX>;
1979 defm : VecROLoadPat<ro128, v16i8, LDRQroW, LDRQroX>;
1981 } // AddedComplexity = 10
1984 multiclass ExtLoadTo64ROPat<ROAddrMode ro, SDPatternOperator loadop,
1985 Instruction INSTW, Instruction INSTX> {
1986 def : Pat<(i64 (loadop (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend))),
1987 (SUBREG_TO_REG (i64 0),
1988 (INSTW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend),
1991 def : Pat<(i64 (loadop (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend))),
1992 (SUBREG_TO_REG (i64 0),
1993 (INSTX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend),
1997 let AddedComplexity = 10 in {
1998 defm : ExtLoadTo64ROPat<ro8, zextloadi8, LDRBBroW, LDRBBroX>;
1999 defm : ExtLoadTo64ROPat<ro16, zextloadi16, LDRHHroW, LDRHHroX>;
2000 defm : ExtLoadTo64ROPat<ro32, zextloadi32, LDRWroW, LDRWroX>;
2002 // zextloadi1 -> zextloadi8
2003 defm : ExtLoadTo64ROPat<ro8, zextloadi1, LDRBBroW, LDRBBroX>;
2005 // extload -> zextload
2006 defm : ExtLoadTo64ROPat<ro8, extloadi8, LDRBBroW, LDRBBroX>;
2007 defm : ExtLoadTo64ROPat<ro16, extloadi16, LDRHHroW, LDRHHroX>;
2008 defm : ExtLoadTo64ROPat<ro32, extloadi32, LDRWroW, LDRWroX>;
2010 // extloadi1 -> zextloadi8
2011 defm : ExtLoadTo64ROPat<ro8, extloadi1, LDRBBroW, LDRBBroX>;
2016 multiclass ExtLoadTo32ROPat<ROAddrMode ro, SDPatternOperator loadop,
2017 Instruction INSTW, Instruction INSTX> {
2018 def : Pat<(i32 (loadop (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend))),
2019 (INSTW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
2021 def : Pat<(i32 (loadop (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend))),
2022 (INSTX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
2026 let AddedComplexity = 10 in {
2027 // extload -> zextload
2028 defm : ExtLoadTo32ROPat<ro8, extloadi8, LDRBBroW, LDRBBroX>;
2029 defm : ExtLoadTo32ROPat<ro16, extloadi16, LDRHHroW, LDRHHroX>;
2030 defm : ExtLoadTo32ROPat<ro32, extloadi32, LDRWroW, LDRWroX>;
2032 // zextloadi1 -> zextloadi8
2033 defm : ExtLoadTo32ROPat<ro8, zextloadi1, LDRBBroW, LDRBBroX>;
2037 // (unsigned immediate)
2039 defm LDRX : LoadUI<0b11, 0, 0b01, GPR64z, uimm12s8, "ldr",
2041 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)))]>;
2042 defm LDRW : LoadUI<0b10, 0, 0b01, GPR32z, uimm12s4, "ldr",
2044 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset)))]>;
2045 defm LDRB : LoadUI<0b00, 1, 0b01, FPR8Op, uimm12s1, "ldr",
2047 (load (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset)))]>;
2048 defm LDRH : LoadUI<0b01, 1, 0b01, FPR16Op, uimm12s2, "ldr",
2049 [(set (f16 FPR16Op:$Rt),
2050 (load (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset)))]>;
2051 defm LDRS : LoadUI<0b10, 1, 0b01, FPR32Op, uimm12s4, "ldr",
2052 [(set (f32 FPR32Op:$Rt),
2053 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset)))]>;
2054 defm LDRD : LoadUI<0b11, 1, 0b01, FPR64Op, uimm12s8, "ldr",
2055 [(set (f64 FPR64Op:$Rt),
2056 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)))]>;
2057 defm LDRQ : LoadUI<0b00, 1, 0b11, FPR128Op, uimm12s16, "ldr",
2058 [(set (f128 FPR128Op:$Rt),
2059 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)))]>;
2061 // For regular load, we do not have any alignment requirement.
2062 // Thus, it is safe to directly map the vector loads with interesting
2063 // addressing modes.
2064 // FIXME: We could do the same for bitconvert to floating point vectors.
2065 def : Pat <(v8i8 (scalar_to_vector (i32
2066 (extloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))))),
2067 (INSERT_SUBREG (v8i8 (IMPLICIT_DEF)),
2068 (LDRBui GPR64sp:$Rn, uimm12s1:$offset), bsub)>;
2069 def : Pat <(v16i8 (scalar_to_vector (i32
2070 (extloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))))),
2071 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
2072 (LDRBui GPR64sp:$Rn, uimm12s1:$offset), bsub)>;
2073 def : Pat <(v4i16 (scalar_to_vector (i32
2074 (extloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))))),
2075 (INSERT_SUBREG (v4i16 (IMPLICIT_DEF)),
2076 (LDRHui GPR64sp:$Rn, uimm12s2:$offset), hsub)>;
2077 def : Pat <(v8i16 (scalar_to_vector (i32
2078 (extloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))))),
2079 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)),
2080 (LDRHui GPR64sp:$Rn, uimm12s2:$offset), hsub)>;
2081 def : Pat <(v2i32 (scalar_to_vector (i32
2082 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))))),
2083 (INSERT_SUBREG (v2i32 (IMPLICIT_DEF)),
2084 (LDRSui GPR64sp:$Rn, uimm12s4:$offset), ssub)>;
2085 def : Pat <(v4i32 (scalar_to_vector (i32
2086 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))))),
2087 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)),
2088 (LDRSui GPR64sp:$Rn, uimm12s4:$offset), ssub)>;
2089 def : Pat <(v1i64 (scalar_to_vector (i64
2090 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))))),
2091 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2092 def : Pat <(v2i64 (scalar_to_vector (i64
2093 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))))),
2094 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)),
2095 (LDRDui GPR64sp:$Rn, uimm12s8:$offset), dsub)>;
2097 // Match all load 64 bits width whose type is compatible with FPR64
2098 let Predicates = [IsLE] in {
2099 // We must use LD1 to perform vector loads in big-endian.
2100 def : Pat<(v2f32 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2101 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2102 def : Pat<(v8i8 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2103 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2104 def : Pat<(v4i16 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2105 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2106 def : Pat<(v2i32 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2107 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2108 def : Pat<(v4f16 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2109 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2111 def : Pat<(v1f64 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2112 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2113 def : Pat<(v1i64 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2114 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2116 // Match all load 128 bits width whose type is compatible with FPR128
2117 let Predicates = [IsLE] in {
2118 // We must use LD1 to perform vector loads in big-endian.
2119 def : Pat<(v4f32 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2120 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2121 def : Pat<(v2f64 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2122 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2123 def : Pat<(v16i8 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2124 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2125 def : Pat<(v8i16 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2126 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2127 def : Pat<(v4i32 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2128 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2129 def : Pat<(v2i64 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2130 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2131 def : Pat<(v8f16 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2132 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2134 def : Pat<(f128 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2135 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2137 defm LDRHH : LoadUI<0b01, 0, 0b01, GPR32, uimm12s2, "ldrh",
2139 (zextloadi16 (am_indexed16 GPR64sp:$Rn,
2140 uimm12s2:$offset)))]>;
2141 defm LDRBB : LoadUI<0b00, 0, 0b01, GPR32, uimm12s1, "ldrb",
2143 (zextloadi8 (am_indexed8 GPR64sp:$Rn,
2144 uimm12s1:$offset)))]>;
2146 def : Pat<(i64 (zextloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2147 (SUBREG_TO_REG (i64 0), (LDRBBui GPR64sp:$Rn, uimm12s1:$offset), sub_32)>;
2148 def : Pat<(i64 (zextloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))),
2149 (SUBREG_TO_REG (i64 0), (LDRHHui GPR64sp:$Rn, uimm12s2:$offset), sub_32)>;
2151 // zextloadi1 -> zextloadi8
2152 def : Pat<(i32 (zextloadi1 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2153 (LDRBBui GPR64sp:$Rn, uimm12s1:$offset)>;
2154 def : Pat<(i64 (zextloadi1 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2155 (SUBREG_TO_REG (i64 0), (LDRBBui GPR64sp:$Rn, uimm12s1:$offset), sub_32)>;
2157 // extload -> zextload
2158 def : Pat<(i32 (extloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))),
2159 (LDRHHui GPR64sp:$Rn, uimm12s2:$offset)>;
2160 def : Pat<(i32 (extloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2161 (LDRBBui GPR64sp:$Rn, uimm12s1:$offset)>;
2162 def : Pat<(i32 (extloadi1 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2163 (LDRBBui GPR64sp:$Rn, uimm12s1:$offset)>;
2164 def : Pat<(i64 (extloadi32 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))),
2165 (SUBREG_TO_REG (i64 0), (LDRWui GPR64sp:$Rn, uimm12s4:$offset), sub_32)>;
2166 def : Pat<(i64 (extloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))),
2167 (SUBREG_TO_REG (i64 0), (LDRHHui GPR64sp:$Rn, uimm12s2:$offset), sub_32)>;
2168 def : Pat<(i64 (extloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2169 (SUBREG_TO_REG (i64 0), (LDRBBui GPR64sp:$Rn, uimm12s1:$offset), sub_32)>;
2170 def : Pat<(i64 (extloadi1 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2171 (SUBREG_TO_REG (i64 0), (LDRBBui GPR64sp:$Rn, uimm12s1:$offset), sub_32)>;
2173 // load sign-extended half-word
2174 defm LDRSHW : LoadUI<0b01, 0, 0b11, GPR32, uimm12s2, "ldrsh",
2176 (sextloadi16 (am_indexed16 GPR64sp:$Rn,
2177 uimm12s2:$offset)))]>;
2178 defm LDRSHX : LoadUI<0b01, 0, 0b10, GPR64, uimm12s2, "ldrsh",
2180 (sextloadi16 (am_indexed16 GPR64sp:$Rn,
2181 uimm12s2:$offset)))]>;
2183 // load sign-extended byte
2184 defm LDRSBW : LoadUI<0b00, 0, 0b11, GPR32, uimm12s1, "ldrsb",
2186 (sextloadi8 (am_indexed8 GPR64sp:$Rn,
2187 uimm12s1:$offset)))]>;
2188 defm LDRSBX : LoadUI<0b00, 0, 0b10, GPR64, uimm12s1, "ldrsb",
2190 (sextloadi8 (am_indexed8 GPR64sp:$Rn,
2191 uimm12s1:$offset)))]>;
2193 // load sign-extended word
2194 defm LDRSW : LoadUI<0b10, 0, 0b10, GPR64, uimm12s4, "ldrsw",
2196 (sextloadi32 (am_indexed32 GPR64sp:$Rn,
2197 uimm12s4:$offset)))]>;
2199 // load zero-extended word
2200 def : Pat<(i64 (zextloadi32 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))),
2201 (SUBREG_TO_REG (i64 0), (LDRWui GPR64sp:$Rn, uimm12s4:$offset), sub_32)>;
2204 def PRFMui : PrefetchUI<0b11, 0, 0b10, "prfm",
2205 [(AArch64Prefetch imm:$Rt,
2206 (am_indexed64 GPR64sp:$Rn,
2207 uimm12s8:$offset))]>;
2209 def : InstAlias<"prfm $Rt, [$Rn]", (PRFMui prfop:$Rt, GPR64sp:$Rn, 0)>;
2214 def alignedglobal : PatLeaf<(iPTR iPTR:$label), [{
2215 if (auto *G = dyn_cast<GlobalAddressSDNode>(N)) {
2216 const DataLayout &DL = MF->getDataLayout();
2217 MaybeAlign Align = G->getGlobal()->getPointerAlignment(DL);
2218 return Align && *Align >= 4 && G->getOffset() % 4 == 0;
2220 if (auto *C = dyn_cast<ConstantPoolSDNode>(N))
2221 return C->getAlignment() >= 4 && C->getOffset() % 4 == 0;
2225 def LDRWl : LoadLiteral<0b00, 0, GPR32z, "ldr",
2226 [(set GPR32z:$Rt, (load (AArch64adr alignedglobal:$label)))]>;
2227 def LDRXl : LoadLiteral<0b01, 0, GPR64z, "ldr",
2228 [(set GPR64z:$Rt, (load (AArch64adr alignedglobal:$label)))]>;
2229 def LDRSl : LoadLiteral<0b00, 1, FPR32Op, "ldr",
2230 [(set (f32 FPR32Op:$Rt), (load (AArch64adr alignedglobal:$label)))]>;
2231 def LDRDl : LoadLiteral<0b01, 1, FPR64Op, "ldr",
2232 [(set (f64 FPR64Op:$Rt), (load (AArch64adr alignedglobal:$label)))]>;
2233 def LDRQl : LoadLiteral<0b10, 1, FPR128Op, "ldr",
2234 [(set (f128 FPR128Op:$Rt), (load (AArch64adr alignedglobal:$label)))]>;
2236 // load sign-extended word
2237 def LDRSWl : LoadLiteral<0b10, 0, GPR64z, "ldrsw",
2238 [(set GPR64z:$Rt, (sextloadi32 (AArch64adr alignedglobal:$label)))]>;
2240 let AddedComplexity = 20 in {
2241 def : Pat<(i64 (zextloadi32 (AArch64adr alignedglobal:$label))),
2242 (SUBREG_TO_REG (i64 0), (LDRWl $label), sub_32)>;
2246 def PRFMl : PrefetchLiteral<0b11, 0, "prfm", []>;
2247 // [(AArch64Prefetch imm:$Rt, tglobaladdr:$label)]>;
2250 // (unscaled immediate)
2251 defm LDURX : LoadUnscaled<0b11, 0, 0b01, GPR64z, "ldur",
2253 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset)))]>;
2254 defm LDURW : LoadUnscaled<0b10, 0, 0b01, GPR32z, "ldur",
2256 (load (am_unscaled32 GPR64sp:$Rn, simm9:$offset)))]>;
2257 defm LDURB : LoadUnscaled<0b00, 1, 0b01, FPR8Op, "ldur",
2259 (load (am_unscaled8 GPR64sp:$Rn, simm9:$offset)))]>;
2260 defm LDURH : LoadUnscaled<0b01, 1, 0b01, FPR16Op, "ldur",
2262 (load (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
2263 defm LDURS : LoadUnscaled<0b10, 1, 0b01, FPR32Op, "ldur",
2264 [(set (f32 FPR32Op:$Rt),
2265 (load (am_unscaled32 GPR64sp:$Rn, simm9:$offset)))]>;
2266 defm LDURD : LoadUnscaled<0b11, 1, 0b01, FPR64Op, "ldur",
2267 [(set (f64 FPR64Op:$Rt),
2268 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset)))]>;
2269 defm LDURQ : LoadUnscaled<0b00, 1, 0b11, FPR128Op, "ldur",
2270 [(set (f128 FPR128Op:$Rt),
2271 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset)))]>;
2274 : LoadUnscaled<0b01, 0, 0b01, GPR32, "ldurh",
2276 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
2278 : LoadUnscaled<0b00, 0, 0b01, GPR32, "ldurb",
2280 (zextloadi8 (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
2282 // Match all load 64 bits width whose type is compatible with FPR64
2283 let Predicates = [IsLE] in {
2284 def : Pat<(v2f32 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2285 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2286 def : Pat<(v2i32 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2287 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2288 def : Pat<(v4i16 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2289 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2290 def : Pat<(v8i8 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2291 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2292 def : Pat<(v4f16 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2293 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2295 def : Pat<(v1f64 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2296 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2297 def : Pat<(v1i64 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2298 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2300 // Match all load 128 bits width whose type is compatible with FPR128
2301 let Predicates = [IsLE] in {
2302 def : Pat<(v2f64 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2303 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2304 def : Pat<(v2i64 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2305 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2306 def : Pat<(v4f32 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2307 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2308 def : Pat<(v4i32 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2309 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2310 def : Pat<(v8i16 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2311 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2312 def : Pat<(v16i8 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2313 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2314 def : Pat<(v8f16 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2315 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2319 def : Pat<(i32 (extloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
2320 (LDURHHi GPR64sp:$Rn, simm9:$offset)>;
2321 def : Pat<(i32 (extloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2322 (LDURBBi GPR64sp:$Rn, simm9:$offset)>;
2323 def : Pat<(i32 (extloadi1 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2324 (LDURBBi GPR64sp:$Rn, simm9:$offset)>;
2325 def : Pat<(i64 (extloadi32 (am_unscaled32 GPR64sp:$Rn, simm9:$offset))),
2326 (SUBREG_TO_REG (i64 0), (LDURWi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2327 def : Pat<(i64 (extloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
2328 (SUBREG_TO_REG (i64 0), (LDURHHi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2329 def : Pat<(i64 (extloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2330 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2331 def : Pat<(i64 (extloadi1 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2332 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2334 def : Pat<(i32 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
2335 (LDURHHi GPR64sp:$Rn, simm9:$offset)>;
2336 def : Pat<(i32 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2337 (LDURBBi GPR64sp:$Rn, simm9:$offset)>;
2338 def : Pat<(i32 (zextloadi1 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2339 (LDURBBi GPR64sp:$Rn, simm9:$offset)>;
2340 def : Pat<(i64 (zextloadi32 (am_unscaled32 GPR64sp:$Rn, simm9:$offset))),
2341 (SUBREG_TO_REG (i64 0), (LDURWi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2342 def : Pat<(i64 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
2343 (SUBREG_TO_REG (i64 0), (LDURHHi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2344 def : Pat<(i64 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2345 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2346 def : Pat<(i64 (zextloadi1 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2347 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2351 // LDR mnemonics fall back to LDUR for negative or unaligned offsets.
2353 // Define new assembler match classes as we want to only match these when
2354 // the don't otherwise match the scaled addressing mode for LDR/STR. Don't
2355 // associate a DiagnosticType either, as we want the diagnostic for the
2356 // canonical form (the scaled operand) to take precedence.
2357 class SImm9OffsetOperand<int Width> : AsmOperandClass {
2358 let Name = "SImm9OffsetFB" # Width;
2359 let PredicateMethod = "isSImm9OffsetFB<" # Width # ">";
2360 let RenderMethod = "addImmOperands";
2363 def SImm9OffsetFB8Operand : SImm9OffsetOperand<8>;
2364 def SImm9OffsetFB16Operand : SImm9OffsetOperand<16>;
2365 def SImm9OffsetFB32Operand : SImm9OffsetOperand<32>;
2366 def SImm9OffsetFB64Operand : SImm9OffsetOperand<64>;
2367 def SImm9OffsetFB128Operand : SImm9OffsetOperand<128>;
2369 def simm9_offset_fb8 : Operand<i64> {
2370 let ParserMatchClass = SImm9OffsetFB8Operand;
2372 def simm9_offset_fb16 : Operand<i64> {
2373 let ParserMatchClass = SImm9OffsetFB16Operand;
2375 def simm9_offset_fb32 : Operand<i64> {
2376 let ParserMatchClass = SImm9OffsetFB32Operand;
2378 def simm9_offset_fb64 : Operand<i64> {
2379 let ParserMatchClass = SImm9OffsetFB64Operand;
2381 def simm9_offset_fb128 : Operand<i64> {
2382 let ParserMatchClass = SImm9OffsetFB128Operand;
2385 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2386 (LDURXi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb64:$offset), 0>;
2387 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2388 (LDURWi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
2389 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2390 (LDURBi FPR8Op:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2391 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2392 (LDURHi FPR16Op:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2393 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2394 (LDURSi FPR32Op:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
2395 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2396 (LDURDi FPR64Op:$Rt, GPR64sp:$Rn, simm9_offset_fb64:$offset), 0>;
2397 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2398 (LDURQi FPR128Op:$Rt, GPR64sp:$Rn, simm9_offset_fb128:$offset), 0>;
2401 def : Pat<(i64 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2402 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2403 def : Pat<(i64 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
2404 (SUBREG_TO_REG (i64 0), (LDURHHi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2406 // load sign-extended half-word
2408 : LoadUnscaled<0b01, 0, 0b11, GPR32, "ldursh",
2410 (sextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
2412 : LoadUnscaled<0b01, 0, 0b10, GPR64, "ldursh",
2414 (sextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
2416 // load sign-extended byte
2418 : LoadUnscaled<0b00, 0, 0b11, GPR32, "ldursb",
2420 (sextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset)))]>;
2422 : LoadUnscaled<0b00, 0, 0b10, GPR64, "ldursb",
2424 (sextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset)))]>;
2426 // load sign-extended word
2428 : LoadUnscaled<0b10, 0, 0b10, GPR64, "ldursw",
2430 (sextloadi32 (am_unscaled32 GPR64sp:$Rn, simm9:$offset)))]>;
2432 // zero and sign extending aliases from generic LDR* mnemonics to LDUR*.
2433 def : InstAlias<"ldrb $Rt, [$Rn, $offset]",
2434 (LDURBBi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2435 def : InstAlias<"ldrh $Rt, [$Rn, $offset]",
2436 (LDURHHi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2437 def : InstAlias<"ldrsb $Rt, [$Rn, $offset]",
2438 (LDURSBWi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2439 def : InstAlias<"ldrsb $Rt, [$Rn, $offset]",
2440 (LDURSBXi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2441 def : InstAlias<"ldrsh $Rt, [$Rn, $offset]",
2442 (LDURSHWi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2443 def : InstAlias<"ldrsh $Rt, [$Rn, $offset]",
2444 (LDURSHXi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2445 def : InstAlias<"ldrsw $Rt, [$Rn, $offset]",
2446 (LDURSWi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
2449 defm PRFUM : PrefetchUnscaled<0b11, 0, 0b10, "prfum",
2450 [(AArch64Prefetch imm:$Rt,
2451 (am_unscaled64 GPR64sp:$Rn, simm9:$offset))]>;
2454 // (unscaled immediate, unprivileged)
2455 defm LDTRX : LoadUnprivileged<0b11, 0, 0b01, GPR64, "ldtr">;
2456 defm LDTRW : LoadUnprivileged<0b10, 0, 0b01, GPR32, "ldtr">;
2458 defm LDTRH : LoadUnprivileged<0b01, 0, 0b01, GPR32, "ldtrh">;
2459 defm LDTRB : LoadUnprivileged<0b00, 0, 0b01, GPR32, "ldtrb">;
2461 // load sign-extended half-word
2462 defm LDTRSHW : LoadUnprivileged<0b01, 0, 0b11, GPR32, "ldtrsh">;
2463 defm LDTRSHX : LoadUnprivileged<0b01, 0, 0b10, GPR64, "ldtrsh">;
2465 // load sign-extended byte
2466 defm LDTRSBW : LoadUnprivileged<0b00, 0, 0b11, GPR32, "ldtrsb">;
2467 defm LDTRSBX : LoadUnprivileged<0b00, 0, 0b10, GPR64, "ldtrsb">;
2469 // load sign-extended word
2470 defm LDTRSW : LoadUnprivileged<0b10, 0, 0b10, GPR64, "ldtrsw">;
2473 // (immediate pre-indexed)
2474 def LDRWpre : LoadPreIdx<0b10, 0, 0b01, GPR32z, "ldr">;
2475 def LDRXpre : LoadPreIdx<0b11, 0, 0b01, GPR64z, "ldr">;
2476 def LDRBpre : LoadPreIdx<0b00, 1, 0b01, FPR8Op, "ldr">;
2477 def LDRHpre : LoadPreIdx<0b01, 1, 0b01, FPR16Op, "ldr">;
2478 def LDRSpre : LoadPreIdx<0b10, 1, 0b01, FPR32Op, "ldr">;
2479 def LDRDpre : LoadPreIdx<0b11, 1, 0b01, FPR64Op, "ldr">;
2480 def LDRQpre : LoadPreIdx<0b00, 1, 0b11, FPR128Op, "ldr">;
2482 // load sign-extended half-word
2483 def LDRSHWpre : LoadPreIdx<0b01, 0, 0b11, GPR32z, "ldrsh">;
2484 def LDRSHXpre : LoadPreIdx<0b01, 0, 0b10, GPR64z, "ldrsh">;
2486 // load sign-extended byte
2487 def LDRSBWpre : LoadPreIdx<0b00, 0, 0b11, GPR32z, "ldrsb">;
2488 def LDRSBXpre : LoadPreIdx<0b00, 0, 0b10, GPR64z, "ldrsb">;
2490 // load zero-extended byte
2491 def LDRBBpre : LoadPreIdx<0b00, 0, 0b01, GPR32z, "ldrb">;
2492 def LDRHHpre : LoadPreIdx<0b01, 0, 0b01, GPR32z, "ldrh">;
2494 // load sign-extended word
2495 def LDRSWpre : LoadPreIdx<0b10, 0, 0b10, GPR64z, "ldrsw">;
2498 // (immediate post-indexed)
2499 def LDRWpost : LoadPostIdx<0b10, 0, 0b01, GPR32z, "ldr">;
2500 def LDRXpost : LoadPostIdx<0b11, 0, 0b01, GPR64z, "ldr">;
2501 def LDRBpost : LoadPostIdx<0b00, 1, 0b01, FPR8Op, "ldr">;
2502 def LDRHpost : LoadPostIdx<0b01, 1, 0b01, FPR16Op, "ldr">;
2503 def LDRSpost : LoadPostIdx<0b10, 1, 0b01, FPR32Op, "ldr">;
2504 def LDRDpost : LoadPostIdx<0b11, 1, 0b01, FPR64Op, "ldr">;
2505 def LDRQpost : LoadPostIdx<0b00, 1, 0b11, FPR128Op, "ldr">;
2507 // load sign-extended half-word
2508 def LDRSHWpost : LoadPostIdx<0b01, 0, 0b11, GPR32z, "ldrsh">;
2509 def LDRSHXpost : LoadPostIdx<0b01, 0, 0b10, GPR64z, "ldrsh">;
2511 // load sign-extended byte
2512 def LDRSBWpost : LoadPostIdx<0b00, 0, 0b11, GPR32z, "ldrsb">;
2513 def LDRSBXpost : LoadPostIdx<0b00, 0, 0b10, GPR64z, "ldrsb">;
2515 // load zero-extended byte
2516 def LDRBBpost : LoadPostIdx<0b00, 0, 0b01, GPR32z, "ldrb">;
2517 def LDRHHpost : LoadPostIdx<0b01, 0, 0b01, GPR32z, "ldrh">;
2519 // load sign-extended word
2520 def LDRSWpost : LoadPostIdx<0b10, 0, 0b10, GPR64z, "ldrsw">;
2522 //===----------------------------------------------------------------------===//
2523 // Store instructions.
2524 //===----------------------------------------------------------------------===//
2526 // Pair (indexed, offset)
2527 // FIXME: Use dedicated range-checked addressing mode operand here.
2528 defm STPW : StorePairOffset<0b00, 0, GPR32z, simm7s4, "stp">;
2529 defm STPX : StorePairOffset<0b10, 0, GPR64z, simm7s8, "stp">;
2530 defm STPS : StorePairOffset<0b00, 1, FPR32Op, simm7s4, "stp">;
2531 defm STPD : StorePairOffset<0b01, 1, FPR64Op, simm7s8, "stp">;
2532 defm STPQ : StorePairOffset<0b10, 1, FPR128Op, simm7s16, "stp">;
2534 // Pair (pre-indexed)
2535 def STPWpre : StorePairPreIdx<0b00, 0, GPR32z, simm7s4, "stp">;
2536 def STPXpre : StorePairPreIdx<0b10, 0, GPR64z, simm7s8, "stp">;
2537 def STPSpre : StorePairPreIdx<0b00, 1, FPR32Op, simm7s4, "stp">;
2538 def STPDpre : StorePairPreIdx<0b01, 1, FPR64Op, simm7s8, "stp">;
2539 def STPQpre : StorePairPreIdx<0b10, 1, FPR128Op, simm7s16, "stp">;
2541 // Pair (pre-indexed)
2542 def STPWpost : StorePairPostIdx<0b00, 0, GPR32z, simm7s4, "stp">;
2543 def STPXpost : StorePairPostIdx<0b10, 0, GPR64z, simm7s8, "stp">;
2544 def STPSpost : StorePairPostIdx<0b00, 1, FPR32Op, simm7s4, "stp">;
2545 def STPDpost : StorePairPostIdx<0b01, 1, FPR64Op, simm7s8, "stp">;
2546 def STPQpost : StorePairPostIdx<0b10, 1, FPR128Op, simm7s16, "stp">;
2548 // Pair (no allocate)
2549 defm STNPW : StorePairNoAlloc<0b00, 0, GPR32z, simm7s4, "stnp">;
2550 defm STNPX : StorePairNoAlloc<0b10, 0, GPR64z, simm7s8, "stnp">;
2551 defm STNPS : StorePairNoAlloc<0b00, 1, FPR32Op, simm7s4, "stnp">;
2552 defm STNPD : StorePairNoAlloc<0b01, 1, FPR64Op, simm7s8, "stnp">;
2553 defm STNPQ : StorePairNoAlloc<0b10, 1, FPR128Op, simm7s16, "stnp">;
2556 // (Register offset)
2559 defm STRBB : Store8RO< 0b00, 0, 0b00, GPR32, "strb", i32, truncstorei8>;
2560 defm STRHH : Store16RO<0b01, 0, 0b00, GPR32, "strh", i32, truncstorei16>;
2561 defm STRW : Store32RO<0b10, 0, 0b00, GPR32, "str", i32, store>;
2562 defm STRX : Store64RO<0b11, 0, 0b00, GPR64, "str", i64, store>;
2566 defm STRB : Store8RO< 0b00, 1, 0b00, FPR8Op, "str", untyped, store>;
2567 defm STRH : Store16RO<0b01, 1, 0b00, FPR16Op, "str", f16, store>;
2568 defm STRS : Store32RO<0b10, 1, 0b00, FPR32Op, "str", f32, store>;
2569 defm STRD : Store64RO<0b11, 1, 0b00, FPR64Op, "str", f64, store>;
2570 defm STRQ : Store128RO<0b00, 1, 0b10, FPR128Op, "str", f128, store>;
2572 let Predicates = [UseSTRQro], AddedComplexity = 10 in {
2573 def : Pat<(store (f128 FPR128:$Rt),
2574 (ro_Windexed128 GPR64sp:$Rn, GPR32:$Rm,
2575 ro_Wextend128:$extend)),
2576 (STRQroW FPR128:$Rt, GPR64sp:$Rn, GPR32:$Rm, ro_Wextend128:$extend)>;
2577 def : Pat<(store (f128 FPR128:$Rt),
2578 (ro_Xindexed128 GPR64sp:$Rn, GPR64:$Rm,
2579 ro_Xextend128:$extend)),
2580 (STRQroX FPR128:$Rt, GPR64sp:$Rn, GPR64:$Rm, ro_Wextend128:$extend)>;
2583 multiclass TruncStoreFrom64ROPat<ROAddrMode ro, SDPatternOperator storeop,
2584 Instruction STRW, Instruction STRX> {
2586 def : Pat<(storeop GPR64:$Rt,
2587 (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)),
2588 (STRW (EXTRACT_SUBREG GPR64:$Rt, sub_32),
2589 GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
2591 def : Pat<(storeop GPR64:$Rt,
2592 (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)),
2593 (STRX (EXTRACT_SUBREG GPR64:$Rt, sub_32),
2594 GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
2597 let AddedComplexity = 10 in {
2599 defm : TruncStoreFrom64ROPat<ro8, truncstorei8, STRBBroW, STRBBroX>;
2600 defm : TruncStoreFrom64ROPat<ro16, truncstorei16, STRHHroW, STRHHroX>;
2601 defm : TruncStoreFrom64ROPat<ro32, truncstorei32, STRWroW, STRWroX>;
2604 multiclass VecROStorePat<ROAddrMode ro, ValueType VecTy, RegisterClass FPR,
2605 Instruction STRW, Instruction STRX> {
2606 def : Pat<(store (VecTy FPR:$Rt),
2607 (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)),
2608 (STRW FPR:$Rt, GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
2610 def : Pat<(store (VecTy FPR:$Rt),
2611 (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)),
2612 (STRX FPR:$Rt, GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
2615 let AddedComplexity = 10 in {
2616 // Match all store 64 bits width whose type is compatible with FPR64
2617 let Predicates = [IsLE] in {
2618 // We must use ST1 to store vectors in big-endian.
2619 defm : VecROStorePat<ro64, v2i32, FPR64, STRDroW, STRDroX>;
2620 defm : VecROStorePat<ro64, v2f32, FPR64, STRDroW, STRDroX>;
2621 defm : VecROStorePat<ro64, v4i16, FPR64, STRDroW, STRDroX>;
2622 defm : VecROStorePat<ro64, v8i8, FPR64, STRDroW, STRDroX>;
2623 defm : VecROStorePat<ro64, v4f16, FPR64, STRDroW, STRDroX>;
2626 defm : VecROStorePat<ro64, v1i64, FPR64, STRDroW, STRDroX>;
2627 defm : VecROStorePat<ro64, v1f64, FPR64, STRDroW, STRDroX>;
2629 // Match all store 128 bits width whose type is compatible with FPR128
2630 let Predicates = [IsLE, UseSTRQro] in {
2631 // We must use ST1 to store vectors in big-endian.
2632 defm : VecROStorePat<ro128, v2i64, FPR128, STRQroW, STRQroX>;
2633 defm : VecROStorePat<ro128, v2f64, FPR128, STRQroW, STRQroX>;
2634 defm : VecROStorePat<ro128, v4i32, FPR128, STRQroW, STRQroX>;
2635 defm : VecROStorePat<ro128, v4f32, FPR128, STRQroW, STRQroX>;
2636 defm : VecROStorePat<ro128, v8i16, FPR128, STRQroW, STRQroX>;
2637 defm : VecROStorePat<ro128, v16i8, FPR128, STRQroW, STRQroX>;
2638 defm : VecROStorePat<ro128, v8f16, FPR128, STRQroW, STRQroX>;
2640 } // AddedComplexity = 10
2642 // Match stores from lane 0 to the appropriate subreg's store.
2643 multiclass VecROStoreLane0Pat<ROAddrMode ro, SDPatternOperator storeop,
2644 ValueType VecTy, ValueType STy,
2645 SubRegIndex SubRegIdx,
2646 Instruction STRW, Instruction STRX> {
2648 def : Pat<(storeop (STy (vector_extract (VecTy VecListOne128:$Vt), 0)),
2649 (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)),
2650 (STRW (EXTRACT_SUBREG VecListOne128:$Vt, SubRegIdx),
2651 GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
2653 def : Pat<(storeop (STy (vector_extract (VecTy VecListOne128:$Vt), 0)),
2654 (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)),
2655 (STRX (EXTRACT_SUBREG VecListOne128:$Vt, SubRegIdx),
2656 GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
2659 let AddedComplexity = 19 in {
2660 defm : VecROStoreLane0Pat<ro16, truncstorei16, v8i16, i32, hsub, STRHroW, STRHroX>;
2661 defm : VecROStoreLane0Pat<ro16, store, v8f16, f16, hsub, STRHroW, STRHroX>;
2662 defm : VecROStoreLane0Pat<ro32, store, v4i32, i32, ssub, STRSroW, STRSroX>;
2663 defm : VecROStoreLane0Pat<ro32, store, v4f32, f32, ssub, STRSroW, STRSroX>;
2664 defm : VecROStoreLane0Pat<ro64, store, v2i64, i64, dsub, STRDroW, STRDroX>;
2665 defm : VecROStoreLane0Pat<ro64, store, v2f64, f64, dsub, STRDroW, STRDroX>;
2669 // (unsigned immediate)
2670 defm STRX : StoreUIz<0b11, 0, 0b00, GPR64z, uimm12s8, "str",
2672 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))]>;
2673 defm STRW : StoreUIz<0b10, 0, 0b00, GPR32z, uimm12s4, "str",
2675 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))]>;
2676 defm STRB : StoreUI<0b00, 1, 0b00, FPR8Op, uimm12s1, "str",
2678 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))]>;
2679 defm STRH : StoreUI<0b01, 1, 0b00, FPR16Op, uimm12s2, "str",
2680 [(store (f16 FPR16Op:$Rt),
2681 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))]>;
2682 defm STRS : StoreUI<0b10, 1, 0b00, FPR32Op, uimm12s4, "str",
2683 [(store (f32 FPR32Op:$Rt),
2684 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))]>;
2685 defm STRD : StoreUI<0b11, 1, 0b00, FPR64Op, uimm12s8, "str",
2686 [(store (f64 FPR64Op:$Rt),
2687 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))]>;
2688 defm STRQ : StoreUI<0b00, 1, 0b10, FPR128Op, uimm12s16, "str", []>;
2690 defm STRHH : StoreUIz<0b01, 0, 0b00, GPR32z, uimm12s2, "strh",
2691 [(truncstorei16 GPR32z:$Rt,
2692 (am_indexed16 GPR64sp:$Rn,
2693 uimm12s2:$offset))]>;
2694 defm STRBB : StoreUIz<0b00, 0, 0b00, GPR32z, uimm12s1, "strb",
2695 [(truncstorei8 GPR32z:$Rt,
2696 (am_indexed8 GPR64sp:$Rn,
2697 uimm12s1:$offset))]>;
2699 let AddedComplexity = 10 in {
2701 // Match all store 64 bits width whose type is compatible with FPR64
2702 def : Pat<(store (v1i64 FPR64:$Rt),
2703 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2704 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2705 def : Pat<(store (v1f64 FPR64:$Rt),
2706 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2707 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2709 let Predicates = [IsLE] in {
2710 // We must use ST1 to store vectors in big-endian.
2711 def : Pat<(store (v2f32 FPR64:$Rt),
2712 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2713 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2714 def : Pat<(store (v8i8 FPR64:$Rt),
2715 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2716 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2717 def : Pat<(store (v4i16 FPR64:$Rt),
2718 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2719 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2720 def : Pat<(store (v2i32 FPR64:$Rt),
2721 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2722 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2723 def : Pat<(store (v4f16 FPR64:$Rt),
2724 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2725 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2728 // Match all store 128 bits width whose type is compatible with FPR128
2729 def : Pat<(store (f128 FPR128:$Rt),
2730 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2731 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2733 let Predicates = [IsLE] in {
2734 // We must use ST1 to store vectors in big-endian.
2735 def : Pat<(store (v4f32 FPR128:$Rt),
2736 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2737 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2738 def : Pat<(store (v2f64 FPR128:$Rt),
2739 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2740 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2741 def : Pat<(store (v16i8 FPR128:$Rt),
2742 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2743 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2744 def : Pat<(store (v8i16 FPR128:$Rt),
2745 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2746 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2747 def : Pat<(store (v4i32 FPR128:$Rt),
2748 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2749 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2750 def : Pat<(store (v2i64 FPR128:$Rt),
2751 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2752 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2753 def : Pat<(store (v8f16 FPR128:$Rt),
2754 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2755 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2759 def : Pat<(truncstorei32 GPR64:$Rt,
2760 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset)),
2761 (STRWui (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, uimm12s4:$offset)>;
2762 def : Pat<(truncstorei16 GPR64:$Rt,
2763 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset)),
2764 (STRHHui (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, uimm12s2:$offset)>;
2765 def : Pat<(truncstorei8 GPR64:$Rt, (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset)),
2766 (STRBBui (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, uimm12s1:$offset)>;
2768 } // AddedComplexity = 10
2770 // Match stores from lane 0 to the appropriate subreg's store.
2771 multiclass VecStoreLane0Pat<Operand UIAddrMode, SDPatternOperator storeop,
2772 ValueType VTy, ValueType STy,
2773 SubRegIndex SubRegIdx, Operand IndexType,
2775 def : Pat<(storeop (STy (vector_extract (VTy VecListOne128:$Vt), 0)),
2776 (UIAddrMode GPR64sp:$Rn, IndexType:$offset)),
2777 (STR (EXTRACT_SUBREG VecListOne128:$Vt, SubRegIdx),
2778 GPR64sp:$Rn, IndexType:$offset)>;
2781 let AddedComplexity = 19 in {
2782 defm : VecStoreLane0Pat<am_indexed16, truncstorei16, v8i16, i32, hsub, uimm12s2, STRHui>;
2783 defm : VecStoreLane0Pat<am_indexed16, store, v8f16, f16, hsub, uimm12s2, STRHui>;
2784 defm : VecStoreLane0Pat<am_indexed32, store, v4i32, i32, ssub, uimm12s4, STRSui>;
2785 defm : VecStoreLane0Pat<am_indexed32, store, v4f32, f32, ssub, uimm12s4, STRSui>;
2786 defm : VecStoreLane0Pat<am_indexed64, store, v2i64, i64, dsub, uimm12s8, STRDui>;
2787 defm : VecStoreLane0Pat<am_indexed64, store, v2f64, f64, dsub, uimm12s8, STRDui>;
2791 // (unscaled immediate)
2792 defm STURX : StoreUnscaled<0b11, 0, 0b00, GPR64z, "stur",
2794 (am_unscaled64 GPR64sp:$Rn, simm9:$offset))]>;
2795 defm STURW : StoreUnscaled<0b10, 0, 0b00, GPR32z, "stur",
2797 (am_unscaled32 GPR64sp:$Rn, simm9:$offset))]>;
2798 defm STURB : StoreUnscaled<0b00, 1, 0b00, FPR8Op, "stur",
2800 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))]>;
2801 defm STURH : StoreUnscaled<0b01, 1, 0b00, FPR16Op, "stur",
2802 [(store (f16 FPR16Op:$Rt),
2803 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))]>;
2804 defm STURS : StoreUnscaled<0b10, 1, 0b00, FPR32Op, "stur",
2805 [(store (f32 FPR32Op:$Rt),
2806 (am_unscaled32 GPR64sp:$Rn, simm9:$offset))]>;
2807 defm STURD : StoreUnscaled<0b11, 1, 0b00, FPR64Op, "stur",
2808 [(store (f64 FPR64Op:$Rt),
2809 (am_unscaled64 GPR64sp:$Rn, simm9:$offset))]>;
2810 defm STURQ : StoreUnscaled<0b00, 1, 0b10, FPR128Op, "stur",
2811 [(store (f128 FPR128Op:$Rt),
2812 (am_unscaled128 GPR64sp:$Rn, simm9:$offset))]>;
2813 defm STURHH : StoreUnscaled<0b01, 0, 0b00, GPR32z, "sturh",
2814 [(truncstorei16 GPR32z:$Rt,
2815 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))]>;
2816 defm STURBB : StoreUnscaled<0b00, 0, 0b00, GPR32z, "sturb",
2817 [(truncstorei8 GPR32z:$Rt,
2818 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))]>;
2820 // Armv8.4 Weaker Release Consistency enhancements
2821 // LDAPR & STLR with Immediate Offset instructions
2822 let Predicates = [HasRCPC_IMMO] in {
2823 defm STLURB : BaseStoreUnscaleV84<"stlurb", 0b00, 0b00, GPR32>;
2824 defm STLURH : BaseStoreUnscaleV84<"stlurh", 0b01, 0b00, GPR32>;
2825 defm STLURW : BaseStoreUnscaleV84<"stlur", 0b10, 0b00, GPR32>;
2826 defm STLURX : BaseStoreUnscaleV84<"stlur", 0b11, 0b00, GPR64>;
2827 defm LDAPURB : BaseLoadUnscaleV84<"ldapurb", 0b00, 0b01, GPR32>;
2828 defm LDAPURSBW : BaseLoadUnscaleV84<"ldapursb", 0b00, 0b11, GPR32>;
2829 defm LDAPURSBX : BaseLoadUnscaleV84<"ldapursb", 0b00, 0b10, GPR64>;
2830 defm LDAPURH : BaseLoadUnscaleV84<"ldapurh", 0b01, 0b01, GPR32>;
2831 defm LDAPURSHW : BaseLoadUnscaleV84<"ldapursh", 0b01, 0b11, GPR32>;
2832 defm LDAPURSHX : BaseLoadUnscaleV84<"ldapursh", 0b01, 0b10, GPR64>;
2833 defm LDAPUR : BaseLoadUnscaleV84<"ldapur", 0b10, 0b01, GPR32>;
2834 defm LDAPURSW : BaseLoadUnscaleV84<"ldapursw", 0b10, 0b10, GPR64>;
2835 defm LDAPURX : BaseLoadUnscaleV84<"ldapur", 0b11, 0b01, GPR64>;
2838 // Match all store 64 bits width whose type is compatible with FPR64
2839 def : Pat<(store (v1f64 FPR64:$Rt), (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2840 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2841 def : Pat<(store (v1i64 FPR64:$Rt), (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2842 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2844 let AddedComplexity = 10 in {
2846 let Predicates = [IsLE] in {
2847 // We must use ST1 to store vectors in big-endian.
2848 def : Pat<(store (v2f32 FPR64:$Rt),
2849 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2850 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2851 def : Pat<(store (v8i8 FPR64:$Rt),
2852 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2853 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2854 def : Pat<(store (v4i16 FPR64:$Rt),
2855 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2856 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2857 def : Pat<(store (v2i32 FPR64:$Rt),
2858 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2859 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2860 def : Pat<(store (v4f16 FPR64:$Rt),
2861 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2862 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2865 // Match all store 128 bits width whose type is compatible with FPR128
2866 def : Pat<(store (f128 FPR128:$Rt), (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2867 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2869 let Predicates = [IsLE] in {
2870 // We must use ST1 to store vectors in big-endian.
2871 def : Pat<(store (v4f32 FPR128:$Rt),
2872 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2873 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2874 def : Pat<(store (v2f64 FPR128:$Rt),
2875 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2876 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2877 def : Pat<(store (v16i8 FPR128:$Rt),
2878 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2879 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2880 def : Pat<(store (v8i16 FPR128:$Rt),
2881 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2882 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2883 def : Pat<(store (v4i32 FPR128:$Rt),
2884 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2885 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2886 def : Pat<(store (v2i64 FPR128:$Rt),
2887 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2888 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2889 def : Pat<(store (v2f64 FPR128:$Rt),
2890 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2891 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2892 def : Pat<(store (v8f16 FPR128:$Rt),
2893 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2894 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2897 } // AddedComplexity = 10
2899 // unscaled i64 truncating stores
2900 def : Pat<(truncstorei32 GPR64:$Rt, (am_unscaled32 GPR64sp:$Rn, simm9:$offset)),
2901 (STURWi (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, simm9:$offset)>;
2902 def : Pat<(truncstorei16 GPR64:$Rt, (am_unscaled16 GPR64sp:$Rn, simm9:$offset)),
2903 (STURHHi (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, simm9:$offset)>;
2904 def : Pat<(truncstorei8 GPR64:$Rt, (am_unscaled8 GPR64sp:$Rn, simm9:$offset)),
2905 (STURBBi (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, simm9:$offset)>;
2907 // Match stores from lane 0 to the appropriate subreg's store.
2908 multiclass VecStoreULane0Pat<SDPatternOperator StoreOp,
2909 ValueType VTy, ValueType STy,
2910 SubRegIndex SubRegIdx, Instruction STR> {
2911 defm : VecStoreLane0Pat<am_unscaled128, StoreOp, VTy, STy, SubRegIdx, simm9, STR>;
2914 let AddedComplexity = 19 in {
2915 defm : VecStoreULane0Pat<truncstorei16, v8i16, i32, hsub, STURHi>;
2916 defm : VecStoreULane0Pat<store, v8f16, f16, hsub, STURHi>;
2917 defm : VecStoreULane0Pat<store, v4i32, i32, ssub, STURSi>;
2918 defm : VecStoreULane0Pat<store, v4f32, f32, ssub, STURSi>;
2919 defm : VecStoreULane0Pat<store, v2i64, i64, dsub, STURDi>;
2920 defm : VecStoreULane0Pat<store, v2f64, f64, dsub, STURDi>;
2924 // STR mnemonics fall back to STUR for negative or unaligned offsets.
2925 def : InstAlias<"str $Rt, [$Rn, $offset]",
2926 (STURXi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb64:$offset), 0>;
2927 def : InstAlias<"str $Rt, [$Rn, $offset]",
2928 (STURWi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
2929 def : InstAlias<"str $Rt, [$Rn, $offset]",
2930 (STURBi FPR8Op:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2931 def : InstAlias<"str $Rt, [$Rn, $offset]",
2932 (STURHi FPR16Op:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2933 def : InstAlias<"str $Rt, [$Rn, $offset]",
2934 (STURSi FPR32Op:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
2935 def : InstAlias<"str $Rt, [$Rn, $offset]",
2936 (STURDi FPR64Op:$Rt, GPR64sp:$Rn, simm9_offset_fb64:$offset), 0>;
2937 def : InstAlias<"str $Rt, [$Rn, $offset]",
2938 (STURQi FPR128Op:$Rt, GPR64sp:$Rn, simm9_offset_fb128:$offset), 0>;
2940 def : InstAlias<"strb $Rt, [$Rn, $offset]",
2941 (STURBBi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2942 def : InstAlias<"strh $Rt, [$Rn, $offset]",
2943 (STURHHi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2946 // (unscaled immediate, unprivileged)
2947 defm STTRW : StoreUnprivileged<0b10, 0, 0b00, GPR32, "sttr">;
2948 defm STTRX : StoreUnprivileged<0b11, 0, 0b00, GPR64, "sttr">;
2950 defm STTRH : StoreUnprivileged<0b01, 0, 0b00, GPR32, "sttrh">;
2951 defm STTRB : StoreUnprivileged<0b00, 0, 0b00, GPR32, "sttrb">;
2954 // (immediate pre-indexed)
2955 def STRWpre : StorePreIdx<0b10, 0, 0b00, GPR32z, "str", pre_store, i32>;
2956 def STRXpre : StorePreIdx<0b11, 0, 0b00, GPR64z, "str", pre_store, i64>;
2957 def STRBpre : StorePreIdx<0b00, 1, 0b00, FPR8Op, "str", pre_store, untyped>;
2958 def STRHpre : StorePreIdx<0b01, 1, 0b00, FPR16Op, "str", pre_store, f16>;
2959 def STRSpre : StorePreIdx<0b10, 1, 0b00, FPR32Op, "str", pre_store, f32>;
2960 def STRDpre : StorePreIdx<0b11, 1, 0b00, FPR64Op, "str", pre_store, f64>;
2961 def STRQpre : StorePreIdx<0b00, 1, 0b10, FPR128Op, "str", pre_store, f128>;
2963 def STRBBpre : StorePreIdx<0b00, 0, 0b00, GPR32z, "strb", pre_truncsti8, i32>;
2964 def STRHHpre : StorePreIdx<0b01, 0, 0b00, GPR32z, "strh", pre_truncsti16, i32>;
2967 def : Pat<(pre_truncsti32 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
2968 (STRWpre (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
2970 def : Pat<(pre_truncsti16 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
2971 (STRHHpre (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
2973 def : Pat<(pre_truncsti8 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
2974 (STRBBpre (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
2977 def : Pat<(pre_store (v8i8 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2978 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2979 def : Pat<(pre_store (v4i16 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2980 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2981 def : Pat<(pre_store (v2i32 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2982 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2983 def : Pat<(pre_store (v2f32 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2984 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2985 def : Pat<(pre_store (v1i64 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2986 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2987 def : Pat<(pre_store (v1f64 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2988 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2989 def : Pat<(pre_store (v4f16 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2990 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2992 def : Pat<(pre_store (v16i8 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2993 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2994 def : Pat<(pre_store (v8i16 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2995 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2996 def : Pat<(pre_store (v4i32 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2997 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2998 def : Pat<(pre_store (v4f32 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2999 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3000 def : Pat<(pre_store (v2i64 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3001 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3002 def : Pat<(pre_store (v2f64 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3003 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3004 def : Pat<(pre_store (v8f16 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3005 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3008 // (immediate post-indexed)
3009 def STRWpost : StorePostIdx<0b10, 0, 0b00, GPR32z, "str", post_store, i32>;
3010 def STRXpost : StorePostIdx<0b11, 0, 0b00, GPR64z, "str", post_store, i64>;
3011 def STRBpost : StorePostIdx<0b00, 1, 0b00, FPR8Op, "str", post_store, untyped>;
3012 def STRHpost : StorePostIdx<0b01, 1, 0b00, FPR16Op, "str", post_store, f16>;
3013 def STRSpost : StorePostIdx<0b10, 1, 0b00, FPR32Op, "str", post_store, f32>;
3014 def STRDpost : StorePostIdx<0b11, 1, 0b00, FPR64Op, "str", post_store, f64>;
3015 def STRQpost : StorePostIdx<0b00, 1, 0b10, FPR128Op, "str", post_store, f128>;
3017 def STRBBpost : StorePostIdx<0b00, 0, 0b00, GPR32z, "strb", post_truncsti8, i32>;
3018 def STRHHpost : StorePostIdx<0b01, 0, 0b00, GPR32z, "strh", post_truncsti16, i32>;
3021 def : Pat<(post_truncsti32 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
3022 (STRWpost (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
3024 def : Pat<(post_truncsti16 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
3025 (STRHHpost (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
3027 def : Pat<(post_truncsti8 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
3028 (STRBBpost (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
3031 def : Pat<(post_store (v8i8 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
3032 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
3033 def : Pat<(post_store (v4i16 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
3034 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
3035 def : Pat<(post_store (v2i32 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
3036 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
3037 def : Pat<(post_store (v2f32 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
3038 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
3039 def : Pat<(post_store (v1i64 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
3040 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
3041 def : Pat<(post_store (v1f64 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
3042 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
3043 def : Pat<(post_store (v4f16 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
3044 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
3046 def : Pat<(post_store (v16i8 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3047 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3048 def : Pat<(post_store (v8i16 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3049 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3050 def : Pat<(post_store (v4i32 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3051 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3052 def : Pat<(post_store (v4f32 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3053 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3054 def : Pat<(post_store (v2i64 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3055 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3056 def : Pat<(post_store (v2f64 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3057 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3058 def : Pat<(post_store (v8f16 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3059 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3061 //===----------------------------------------------------------------------===//
3062 // Load/store exclusive instructions.
3063 //===----------------------------------------------------------------------===//
3065 def LDARW : LoadAcquire <0b10, 1, 1, 0, 1, GPR32, "ldar">;
3066 def LDARX : LoadAcquire <0b11, 1, 1, 0, 1, GPR64, "ldar">;
3067 def LDARB : LoadAcquire <0b00, 1, 1, 0, 1, GPR32, "ldarb">;
3068 def LDARH : LoadAcquire <0b01, 1, 1, 0, 1, GPR32, "ldarh">;
3070 def LDAXRW : LoadExclusive <0b10, 0, 1, 0, 1, GPR32, "ldaxr">;
3071 def LDAXRX : LoadExclusive <0b11, 0, 1, 0, 1, GPR64, "ldaxr">;
3072 def LDAXRB : LoadExclusive <0b00, 0, 1, 0, 1, GPR32, "ldaxrb">;
3073 def LDAXRH : LoadExclusive <0b01, 0, 1, 0, 1, GPR32, "ldaxrh">;
3075 def LDXRW : LoadExclusive <0b10, 0, 1, 0, 0, GPR32, "ldxr">;
3076 def LDXRX : LoadExclusive <0b11, 0, 1, 0, 0, GPR64, "ldxr">;
3077 def LDXRB : LoadExclusive <0b00, 0, 1, 0, 0, GPR32, "ldxrb">;
3078 def LDXRH : LoadExclusive <0b01, 0, 1, 0, 0, GPR32, "ldxrh">;
3080 def STLRW : StoreRelease <0b10, 1, 0, 0, 1, GPR32, "stlr">;
3081 def STLRX : StoreRelease <0b11, 1, 0, 0, 1, GPR64, "stlr">;
3082 def STLRB : StoreRelease <0b00, 1, 0, 0, 1, GPR32, "stlrb">;
3083 def STLRH : StoreRelease <0b01, 1, 0, 0, 1, GPR32, "stlrh">;
3085 def STLXRW : StoreExclusive<0b10, 0, 0, 0, 1, GPR32, "stlxr">;
3086 def STLXRX : StoreExclusive<0b11, 0, 0, 0, 1, GPR64, "stlxr">;
3087 def STLXRB : StoreExclusive<0b00, 0, 0, 0, 1, GPR32, "stlxrb">;
3088 def STLXRH : StoreExclusive<0b01, 0, 0, 0, 1, GPR32, "stlxrh">;
3090 def STXRW : StoreExclusive<0b10, 0, 0, 0, 0, GPR32, "stxr">;
3091 def STXRX : StoreExclusive<0b11, 0, 0, 0, 0, GPR64, "stxr">;
3092 def STXRB : StoreExclusive<0b00, 0, 0, 0, 0, GPR32, "stxrb">;
3093 def STXRH : StoreExclusive<0b01, 0, 0, 0, 0, GPR32, "stxrh">;
3095 def LDAXPW : LoadExclusivePair<0b10, 0, 1, 1, 1, GPR32, "ldaxp">;
3096 def LDAXPX : LoadExclusivePair<0b11, 0, 1, 1, 1, GPR64, "ldaxp">;
3098 def LDXPW : LoadExclusivePair<0b10, 0, 1, 1, 0, GPR32, "ldxp">;
3099 def LDXPX : LoadExclusivePair<0b11, 0, 1, 1, 0, GPR64, "ldxp">;
3101 def STLXPW : StoreExclusivePair<0b10, 0, 0, 1, 1, GPR32, "stlxp">;
3102 def STLXPX : StoreExclusivePair<0b11, 0, 0, 1, 1, GPR64, "stlxp">;
3104 def STXPW : StoreExclusivePair<0b10, 0, 0, 1, 0, GPR32, "stxp">;
3105 def STXPX : StoreExclusivePair<0b11, 0, 0, 1, 0, GPR64, "stxp">;
3107 let Predicates = [HasLOR] in {
3108 // v8.1a "Limited Order Region" extension load-acquire instructions
3109 def LDLARW : LoadAcquire <0b10, 1, 1, 0, 0, GPR32, "ldlar">;
3110 def LDLARX : LoadAcquire <0b11, 1, 1, 0, 0, GPR64, "ldlar">;
3111 def LDLARB : LoadAcquire <0b00, 1, 1, 0, 0, GPR32, "ldlarb">;
3112 def LDLARH : LoadAcquire <0b01, 1, 1, 0, 0, GPR32, "ldlarh">;
3114 // v8.1a "Limited Order Region" extension store-release instructions
3115 def STLLRW : StoreRelease <0b10, 1, 0, 0, 0, GPR32, "stllr">;
3116 def STLLRX : StoreRelease <0b11, 1, 0, 0, 0, GPR64, "stllr">;
3117 def STLLRB : StoreRelease <0b00, 1, 0, 0, 0, GPR32, "stllrb">;
3118 def STLLRH : StoreRelease <0b01, 1, 0, 0, 0, GPR32, "stllrh">;
3121 //===----------------------------------------------------------------------===//
3122 // Scaled floating point to integer conversion instructions.
3123 //===----------------------------------------------------------------------===//
3125 defm FCVTAS : FPToIntegerUnscaled<0b00, 0b100, "fcvtas", int_aarch64_neon_fcvtas>;
3126 defm FCVTAU : FPToIntegerUnscaled<0b00, 0b101, "fcvtau", int_aarch64_neon_fcvtau>;
3127 defm FCVTMS : FPToIntegerUnscaled<0b10, 0b000, "fcvtms", int_aarch64_neon_fcvtms>;
3128 defm FCVTMU : FPToIntegerUnscaled<0b10, 0b001, "fcvtmu", int_aarch64_neon_fcvtmu>;
3129 defm FCVTNS : FPToIntegerUnscaled<0b00, 0b000, "fcvtns", int_aarch64_neon_fcvtns>;
3130 defm FCVTNU : FPToIntegerUnscaled<0b00, 0b001, "fcvtnu", int_aarch64_neon_fcvtnu>;
3131 defm FCVTPS : FPToIntegerUnscaled<0b01, 0b000, "fcvtps", int_aarch64_neon_fcvtps>;
3132 defm FCVTPU : FPToIntegerUnscaled<0b01, 0b001, "fcvtpu", int_aarch64_neon_fcvtpu>;
3133 defm FCVTZS : FPToIntegerUnscaled<0b11, 0b000, "fcvtzs", fp_to_sint>;
3134 defm FCVTZU : FPToIntegerUnscaled<0b11, 0b001, "fcvtzu", fp_to_uint>;
3135 defm FCVTZS : FPToIntegerScaled<0b11, 0b000, "fcvtzs", fp_to_sint>;
3136 defm FCVTZU : FPToIntegerScaled<0b11, 0b001, "fcvtzu", fp_to_uint>;
3138 multiclass FPToIntegerIntPats<Intrinsic round, string INST> {
3139 def : Pat<(i32 (round f16:$Rn)), (!cast<Instruction>(INST # UWHr) $Rn)>;
3140 def : Pat<(i64 (round f16:$Rn)), (!cast<Instruction>(INST # UXHr) $Rn)>;
3141 def : Pat<(i32 (round f32:$Rn)), (!cast<Instruction>(INST # UWSr) $Rn)>;
3142 def : Pat<(i64 (round f32:$Rn)), (!cast<Instruction>(INST # UXSr) $Rn)>;
3143 def : Pat<(i32 (round f64:$Rn)), (!cast<Instruction>(INST # UWDr) $Rn)>;
3144 def : Pat<(i64 (round f64:$Rn)), (!cast<Instruction>(INST # UXDr) $Rn)>;
3146 def : Pat<(i32 (round (fmul f16:$Rn, fixedpoint_f16_i32:$scale))),
3147 (!cast<Instruction>(INST # SWHri) $Rn, $scale)>;
3148 def : Pat<(i64 (round (fmul f16:$Rn, fixedpoint_f16_i64:$scale))),
3149 (!cast<Instruction>(INST # SXHri) $Rn, $scale)>;
3150 def : Pat<(i32 (round (fmul f32:$Rn, fixedpoint_f32_i32:$scale))),
3151 (!cast<Instruction>(INST # SWSri) $Rn, $scale)>;
3152 def : Pat<(i64 (round (fmul f32:$Rn, fixedpoint_f32_i64:$scale))),
3153 (!cast<Instruction>(INST # SXSri) $Rn, $scale)>;
3154 def : Pat<(i32 (round (fmul f64:$Rn, fixedpoint_f64_i32:$scale))),
3155 (!cast<Instruction>(INST # SWDri) $Rn, $scale)>;
3156 def : Pat<(i64 (round (fmul f64:$Rn, fixedpoint_f64_i64:$scale))),
3157 (!cast<Instruction>(INST # SXDri) $Rn, $scale)>;
3160 defm : FPToIntegerIntPats<int_aarch64_neon_fcvtzs, "FCVTZS">;
3161 defm : FPToIntegerIntPats<int_aarch64_neon_fcvtzu, "FCVTZU">;
3163 multiclass FPToIntegerPats<SDNode to_int, SDNode round, string INST> {
3164 def : Pat<(i32 (to_int (round f32:$Rn))),
3165 (!cast<Instruction>(INST # UWSr) f32:$Rn)>;
3166 def : Pat<(i64 (to_int (round f32:$Rn))),
3167 (!cast<Instruction>(INST # UXSr) f32:$Rn)>;
3168 def : Pat<(i32 (to_int (round f64:$Rn))),
3169 (!cast<Instruction>(INST # UWDr) f64:$Rn)>;
3170 def : Pat<(i64 (to_int (round f64:$Rn))),
3171 (!cast<Instruction>(INST # UXDr) f64:$Rn)>;
3174 defm : FPToIntegerPats<fp_to_sint, fceil, "FCVTPS">;
3175 defm : FPToIntegerPats<fp_to_uint, fceil, "FCVTPU">;
3176 defm : FPToIntegerPats<fp_to_sint, ffloor, "FCVTMS">;
3177 defm : FPToIntegerPats<fp_to_uint, ffloor, "FCVTMU">;
3178 defm : FPToIntegerPats<fp_to_sint, ftrunc, "FCVTZS">;
3179 defm : FPToIntegerPats<fp_to_uint, ftrunc, "FCVTZU">;
3180 defm : FPToIntegerPats<fp_to_sint, fround, "FCVTAS">;
3181 defm : FPToIntegerPats<fp_to_uint, fround, "FCVTAU">;
3183 let Predicates = [HasFullFP16] in {
3184 def : Pat<(i32 (lround f16:$Rn)),
3185 (!cast<Instruction>(FCVTASUWHr) f16:$Rn)>;
3186 def : Pat<(i64 (lround f16:$Rn)),
3187 (!cast<Instruction>(FCVTASUXHr) f16:$Rn)>;
3188 def : Pat<(i64 (llround f16:$Rn)),
3189 (!cast<Instruction>(FCVTASUXHr) f16:$Rn)>;
3191 def : Pat<(i32 (lround f32:$Rn)),
3192 (!cast<Instruction>(FCVTASUWSr) f32:$Rn)>;
3193 def : Pat<(i32 (lround f64:$Rn)),
3194 (!cast<Instruction>(FCVTASUWDr) f64:$Rn)>;
3195 def : Pat<(i64 (lround f32:$Rn)),
3196 (!cast<Instruction>(FCVTASUXSr) f32:$Rn)>;
3197 def : Pat<(i64 (lround f64:$Rn)),
3198 (!cast<Instruction>(FCVTASUXDr) f64:$Rn)>;
3199 def : Pat<(i64 (llround f32:$Rn)),
3200 (!cast<Instruction>(FCVTASUXSr) f32:$Rn)>;
3201 def : Pat<(i64 (llround f64:$Rn)),
3202 (!cast<Instruction>(FCVTASUXDr) f64:$Rn)>;
3204 //===----------------------------------------------------------------------===//
3205 // Scaled integer to floating point conversion instructions.
3206 //===----------------------------------------------------------------------===//
3208 defm SCVTF : IntegerToFP<0, "scvtf", sint_to_fp>;
3209 defm UCVTF : IntegerToFP<1, "ucvtf", uint_to_fp>;
3211 //===----------------------------------------------------------------------===//
3212 // Unscaled integer to floating point conversion instruction.
3213 //===----------------------------------------------------------------------===//
3215 defm FMOV : UnscaledConversion<"fmov">;
3217 // Add pseudo ops for FMOV 0 so we can mark them as isReMaterializable
3218 let isReMaterializable = 1, isCodeGenOnly = 1, isAsCheapAsAMove = 1 in {
3219 def FMOVH0 : Pseudo<(outs FPR16:$Rd), (ins), [(set f16:$Rd, (fpimm0))]>,
3220 Sched<[WriteF]>, Requires<[HasFullFP16]>;
3221 def FMOVS0 : Pseudo<(outs FPR32:$Rd), (ins), [(set f32:$Rd, (fpimm0))]>,
3223 def FMOVD0 : Pseudo<(outs FPR64:$Rd), (ins), [(set f64:$Rd, (fpimm0))]>,
3226 // Similarly add aliases
3227 def : InstAlias<"fmov $Rd, #0.0", (FMOVWHr FPR16:$Rd, WZR), 0>,
3228 Requires<[HasFullFP16]>;
3229 def : InstAlias<"fmov $Rd, #0.0", (FMOVWSr FPR32:$Rd, WZR), 0>;
3230 def : InstAlias<"fmov $Rd, #0.0", (FMOVXDr FPR64:$Rd, XZR), 0>;
3232 //===----------------------------------------------------------------------===//
3233 // Floating point conversion instruction.
3234 //===----------------------------------------------------------------------===//
3236 defm FCVT : FPConversion<"fcvt">;
3238 //===----------------------------------------------------------------------===//
3239 // Floating point single operand instructions.
3240 //===----------------------------------------------------------------------===//
3242 defm FABS : SingleOperandFPData<0b0001, "fabs", fabs>;
3243 defm FMOV : SingleOperandFPData<0b0000, "fmov">;
3244 defm FNEG : SingleOperandFPData<0b0010, "fneg", fneg>;
3245 defm FRINTA : SingleOperandFPData<0b1100, "frinta", fround>;
3246 defm FRINTI : SingleOperandFPData<0b1111, "frinti", fnearbyint>;
3247 defm FRINTM : SingleOperandFPData<0b1010, "frintm", ffloor>;
3248 defm FRINTN : SingleOperandFPData<0b1000, "frintn", int_aarch64_neon_frintn>;
3249 defm FRINTP : SingleOperandFPData<0b1001, "frintp", fceil>;
3251 def : Pat<(v1f64 (int_aarch64_neon_frintn (v1f64 FPR64:$Rn))),
3252 (FRINTNDr FPR64:$Rn)>;
3254 defm FRINTX : SingleOperandFPData<0b1110, "frintx", frint>;
3255 defm FRINTZ : SingleOperandFPData<0b1011, "frintz", ftrunc>;
3257 let SchedRW = [WriteFDiv] in {
3258 defm FSQRT : SingleOperandFPData<0b0011, "fsqrt", fsqrt>;
3261 let Predicates = [HasFRInt3264] in {
3262 defm FRINT32Z : FRIntNNT<0b00, "frint32z">;
3263 defm FRINT64Z : FRIntNNT<0b10, "frint64z">;
3264 defm FRINT32X : FRIntNNT<0b01, "frint32x">;
3265 defm FRINT64X : FRIntNNT<0b11, "frint64x">;
3268 let Predicates = [HasFullFP16] in {
3269 def : Pat<(i32 (lrint f16:$Rn)),
3270 (FCVTZSUWHr (!cast<Instruction>(FRINTXHr) f16:$Rn))>;
3271 def : Pat<(i64 (lrint f16:$Rn)),
3272 (FCVTZSUXHr (!cast<Instruction>(FRINTXHr) f16:$Rn))>;
3273 def : Pat<(i64 (llrint f16:$Rn)),
3274 (FCVTZSUXHr (!cast<Instruction>(FRINTXHr) f16:$Rn))>;
3276 def : Pat<(i32 (lrint f32:$Rn)),
3277 (FCVTZSUWSr (!cast<Instruction>(FRINTXSr) f32:$Rn))>;
3278 def : Pat<(i32 (lrint f64:$Rn)),
3279 (FCVTZSUWDr (!cast<Instruction>(FRINTXDr) f64:$Rn))>;
3280 def : Pat<(i64 (lrint f32:$Rn)),
3281 (FCVTZSUXSr (!cast<Instruction>(FRINTXSr) f32:$Rn))>;
3282 def : Pat<(i64 (lrint f64:$Rn)),
3283 (FCVTZSUXDr (!cast<Instruction>(FRINTXDr) f64:$Rn))>;
3284 def : Pat<(i64 (llrint f32:$Rn)),
3285 (FCVTZSUXSr (!cast<Instruction>(FRINTXSr) f32:$Rn))>;
3286 def : Pat<(i64 (llrint f64:$Rn)),
3287 (FCVTZSUXDr (!cast<Instruction>(FRINTXDr) f64:$Rn))>;
3289 //===----------------------------------------------------------------------===//
3290 // Floating point two operand instructions.
3291 //===----------------------------------------------------------------------===//
3293 defm FADD : TwoOperandFPData<0b0010, "fadd", fadd>;
3294 let SchedRW = [WriteFDiv] in {
3295 defm FDIV : TwoOperandFPData<0b0001, "fdiv", fdiv>;
3297 defm FMAXNM : TwoOperandFPData<0b0110, "fmaxnm", fmaxnum>;
3298 defm FMAX : TwoOperandFPData<0b0100, "fmax", fmaximum>;
3299 defm FMINNM : TwoOperandFPData<0b0111, "fminnm", fminnum>;
3300 defm FMIN : TwoOperandFPData<0b0101, "fmin", fminimum>;
3301 let SchedRW = [WriteFMul] in {
3302 defm FMUL : TwoOperandFPData<0b0000, "fmul", fmul>;
3303 defm FNMUL : TwoOperandFPDataNeg<0b1000, "fnmul", fmul>;
3305 defm FSUB : TwoOperandFPData<0b0011, "fsub", fsub>;
3307 def : Pat<(v1f64 (fmaximum (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
3308 (FMAXDrr FPR64:$Rn, FPR64:$Rm)>;
3309 def : Pat<(v1f64 (fminimum (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
3310 (FMINDrr FPR64:$Rn, FPR64:$Rm)>;
3311 def : Pat<(v1f64 (fmaxnum (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
3312 (FMAXNMDrr FPR64:$Rn, FPR64:$Rm)>;
3313 def : Pat<(v1f64 (fminnum (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
3314 (FMINNMDrr FPR64:$Rn, FPR64:$Rm)>;
3316 //===----------------------------------------------------------------------===//
3317 // Floating point three operand instructions.
3318 //===----------------------------------------------------------------------===//
3320 defm FMADD : ThreeOperandFPData<0, 0, "fmadd", fma>;
3321 defm FMSUB : ThreeOperandFPData<0, 1, "fmsub",
3322 TriOpFrag<(fma node:$LHS, (fneg node:$MHS), node:$RHS)> >;
3323 defm FNMADD : ThreeOperandFPData<1, 0, "fnmadd",
3324 TriOpFrag<(fneg (fma node:$LHS, node:$MHS, node:$RHS))> >;
3325 defm FNMSUB : ThreeOperandFPData<1, 1, "fnmsub",
3326 TriOpFrag<(fma node:$LHS, node:$MHS, (fneg node:$RHS))> >;
3328 // The following def pats catch the case where the LHS of an FMA is negated.
3329 // The TriOpFrag above catches the case where the middle operand is negated.
3331 // N.b. FMSUB etc have the accumulator at the *end* of (outs), unlike
3332 // the NEON variant.
3334 // Here we handle first -(a + b*c) for FNMADD:
3336 let Predicates = [HasNEON, HasFullFP16] in
3337 def : Pat<(f16 (fma (fneg FPR16:$Rn), FPR16:$Rm, FPR16:$Ra)),
3338 (FMSUBHrrr FPR16:$Rn, FPR16:$Rm, FPR16:$Ra)>;
3340 def : Pat<(f32 (fma (fneg FPR32:$Rn), FPR32:$Rm, FPR32:$Ra)),
3341 (FMSUBSrrr FPR32:$Rn, FPR32:$Rm, FPR32:$Ra)>;
3343 def : Pat<(f64 (fma (fneg FPR64:$Rn), FPR64:$Rm, FPR64:$Ra)),
3344 (FMSUBDrrr FPR64:$Rn, FPR64:$Rm, FPR64:$Ra)>;
3346 // Now it's time for "(-a) + (-b)*c"
3348 let Predicates = [HasNEON, HasFullFP16] in
3349 def : Pat<(f16 (fma (fneg FPR16:$Rn), FPR16:$Rm, (fneg FPR16:$Ra))),
3350 (FNMADDHrrr FPR16:$Rn, FPR16:$Rm, FPR16:$Ra)>;
3352 def : Pat<(f32 (fma (fneg FPR32:$Rn), FPR32:$Rm, (fneg FPR32:$Ra))),
3353 (FNMADDSrrr FPR32:$Rn, FPR32:$Rm, FPR32:$Ra)>;
3355 def : Pat<(f64 (fma (fneg FPR64:$Rn), FPR64:$Rm, (fneg FPR64:$Ra))),
3356 (FNMADDDrrr FPR64:$Rn, FPR64:$Rm, FPR64:$Ra)>;
3358 // And here "(-a) + b*(-c)"
3360 let Predicates = [HasNEON, HasFullFP16] in
3361 def : Pat<(f16 (fma FPR16:$Rn, (fneg FPR16:$Rm), (fneg FPR16:$Ra))),
3362 (FNMADDHrrr FPR16:$Rn, FPR16:$Rm, FPR16:$Ra)>;
3364 def : Pat<(f32 (fma FPR32:$Rn, (fneg FPR32:$Rm), (fneg FPR32:$Ra))),
3365 (FNMADDSrrr FPR32:$Rn, FPR32:$Rm, FPR32:$Ra)>;
3367 def : Pat<(f64 (fma FPR64:$Rn, (fneg FPR64:$Rm), (fneg FPR64:$Ra))),
3368 (FNMADDDrrr FPR64:$Rn, FPR64:$Rm, FPR64:$Ra)>;
3370 //===----------------------------------------------------------------------===//
3371 // Floating point comparison instructions.
3372 //===----------------------------------------------------------------------===//
3374 defm FCMPE : FPComparison<1, "fcmpe">;
3375 defm FCMP : FPComparison<0, "fcmp", AArch64fcmp>;
3377 //===----------------------------------------------------------------------===//
3378 // Floating point conditional comparison instructions.
3379 //===----------------------------------------------------------------------===//
3381 defm FCCMPE : FPCondComparison<1, "fccmpe">;
3382 defm FCCMP : FPCondComparison<0, "fccmp", AArch64fccmp>;
3384 //===----------------------------------------------------------------------===//
3385 // Floating point conditional select instruction.
3386 //===----------------------------------------------------------------------===//
3388 defm FCSEL : FPCondSelect<"fcsel">;
3390 // CSEL instructions providing f128 types need to be handled by a
3391 // pseudo-instruction since the eventual code will need to introduce basic
3392 // blocks and control flow.
3393 def F128CSEL : Pseudo<(outs FPR128:$Rd),
3394 (ins FPR128:$Rn, FPR128:$Rm, ccode:$cond),
3395 [(set (f128 FPR128:$Rd),
3396 (AArch64csel FPR128:$Rn, FPR128:$Rm,
3397 (i32 imm:$cond), NZCV))]> {
3399 let usesCustomInserter = 1;
3400 let hasNoSchedulingInfo = 1;
3403 //===----------------------------------------------------------------------===//
3404 // Instructions used for emitting unwind opcodes on ARM64 Windows.
3405 //===----------------------------------------------------------------------===//
3406 let isPseudo = 1 in {
3407 def SEH_StackAlloc : Pseudo<(outs), (ins i32imm:$size), []>, Sched<[]>;
3408 def SEH_SaveFPLR : Pseudo<(outs), (ins i32imm:$offs), []>, Sched<[]>;
3409 def SEH_SaveFPLR_X : Pseudo<(outs), (ins i32imm:$offs), []>, Sched<[]>;
3410 def SEH_SaveReg : Pseudo<(outs), (ins i32imm:$reg, i32imm:$offs), []>, Sched<[]>;
3411 def SEH_SaveReg_X : Pseudo<(outs), (ins i32imm:$reg, i32imm:$offs), []>, Sched<[]>;
3412 def SEH_SaveRegP : Pseudo<(outs), (ins i32imm:$reg0, i32imm:$reg1, i32imm:$offs), []>, Sched<[]>;
3413 def SEH_SaveRegP_X : Pseudo<(outs), (ins i32imm:$reg0, i32imm:$reg1, i32imm:$offs), []>, Sched<[]>;
3414 def SEH_SaveFReg : Pseudo<(outs), (ins i32imm:$reg, i32imm:$offs), []>, Sched<[]>;
3415 def SEH_SaveFReg_X : Pseudo<(outs), (ins i32imm:$reg, i32imm:$offs), []>, Sched<[]>;
3416 def SEH_SaveFRegP : Pseudo<(outs), (ins i32imm:$reg0, i32imm:$reg1, i32imm:$offs), []>, Sched<[]>;
3417 def SEH_SaveFRegP_X : Pseudo<(outs), (ins i32imm:$reg0, i32imm:$reg1, i32imm:$offs), []>, Sched<[]>;
3418 def SEH_SetFP : Pseudo<(outs), (ins), []>, Sched<[]>;
3419 def SEH_AddFP : Pseudo<(outs), (ins i32imm:$offs), []>, Sched<[]>;
3420 def SEH_Nop : Pseudo<(outs), (ins), []>, Sched<[]>;
3421 def SEH_PrologEnd : Pseudo<(outs), (ins), []>, Sched<[]>;
3422 def SEH_EpilogStart : Pseudo<(outs), (ins), []>, Sched<[]>;
3423 def SEH_EpilogEnd : Pseudo<(outs), (ins), []>, Sched<[]>;
3426 // Pseudo instructions for Windows EH
3427 //===----------------------------------------------------------------------===//
3428 let isTerminator = 1, hasSideEffects = 1, isBarrier = 1, hasCtrlDep = 1,
3429 isCodeGenOnly = 1, isReturn = 1, isEHScopeReturn = 1, isPseudo = 1 in {
3430 def CLEANUPRET : Pseudo<(outs), (ins), [(cleanupret)]>, Sched<[]>;
3431 let usesCustomInserter = 1 in
3432 def CATCHRET : Pseudo<(outs), (ins am_brcond:$dst, am_brcond:$src), [(catchret bb:$dst, bb:$src)]>,
3436 let hasSideEffects = 1, hasCtrlDep = 1, isCodeGenOnly = 1,
3437 usesCustomInserter = 1 in
3438 def CATCHPAD : Pseudo<(outs), (ins), [(catchpad)]>, Sched<[]>;
3440 //===----------------------------------------------------------------------===//
3441 // Floating point immediate move.
3442 //===----------------------------------------------------------------------===//
3444 let isReMaterializable = 1 in {
3445 defm FMOV : FPMoveImmediate<"fmov">;
3448 //===----------------------------------------------------------------------===//
3449 // Advanced SIMD two vector instructions.
3450 //===----------------------------------------------------------------------===//
3452 defm UABDL : SIMDLongThreeVectorBHSabdl<1, 0b0111, "uabdl",
3453 int_aarch64_neon_uabd>;
3454 // Match UABDL in log2-shuffle patterns.
3455 def : Pat<(abs (v8i16 (sub (zext (v8i8 V64:$opA)),
3456 (zext (v8i8 V64:$opB))))),
3457 (UABDLv8i8_v8i16 V64:$opA, V64:$opB)>;
3458 def : Pat<(xor (v8i16 (AArch64vashr v8i16:$src, (i32 15))),
3459 (v8i16 (add (sub (zext (v8i8 V64:$opA)),
3460 (zext (v8i8 V64:$opB))),
3461 (AArch64vashr v8i16:$src, (i32 15))))),
3462 (UABDLv8i8_v8i16 V64:$opA, V64:$opB)>;
3463 def : Pat<(abs (v8i16 (sub (zext (extract_high_v16i8 V128:$opA)),
3464 (zext (extract_high_v16i8 V128:$opB))))),
3465 (UABDLv16i8_v8i16 V128:$opA, V128:$opB)>;
3466 def : Pat<(xor (v8i16 (AArch64vashr v8i16:$src, (i32 15))),
3467 (v8i16 (add (sub (zext (extract_high_v16i8 V128:$opA)),
3468 (zext (extract_high_v16i8 V128:$opB))),
3469 (AArch64vashr v8i16:$src, (i32 15))))),
3470 (UABDLv16i8_v8i16 V128:$opA, V128:$opB)>;
3471 def : Pat<(abs (v4i32 (sub (zext (v4i16 V64:$opA)),
3472 (zext (v4i16 V64:$opB))))),
3473 (UABDLv4i16_v4i32 V64:$opA, V64:$opB)>;
3474 def : Pat<(abs (v4i32 (sub (zext (extract_high_v8i16 V128:$opA)),
3475 (zext (extract_high_v8i16 V128:$opB))))),
3476 (UABDLv8i16_v4i32 V128:$opA, V128:$opB)>;
3477 def : Pat<(abs (v2i64 (sub (zext (v2i32 V64:$opA)),
3478 (zext (v2i32 V64:$opB))))),
3479 (UABDLv2i32_v2i64 V64:$opA, V64:$opB)>;
3480 def : Pat<(abs (v2i64 (sub (zext (extract_high_v4i32 V128:$opA)),
3481 (zext (extract_high_v4i32 V128:$opB))))),
3482 (UABDLv4i32_v2i64 V128:$opA, V128:$opB)>;
3484 defm ABS : SIMDTwoVectorBHSD<0, 0b01011, "abs", abs>;
3485 defm CLS : SIMDTwoVectorBHS<0, 0b00100, "cls", int_aarch64_neon_cls>;
3486 defm CLZ : SIMDTwoVectorBHS<1, 0b00100, "clz", ctlz>;
3487 defm CMEQ : SIMDCmpTwoVector<0, 0b01001, "cmeq", AArch64cmeqz>;
3488 defm CMGE : SIMDCmpTwoVector<1, 0b01000, "cmge", AArch64cmgez>;
3489 defm CMGT : SIMDCmpTwoVector<0, 0b01000, "cmgt", AArch64cmgtz>;
3490 defm CMLE : SIMDCmpTwoVector<1, 0b01001, "cmle", AArch64cmlez>;
3491 defm CMLT : SIMDCmpTwoVector<0, 0b01010, "cmlt", AArch64cmltz>;
3492 defm CNT : SIMDTwoVectorB<0, 0b00, 0b00101, "cnt", ctpop>;
3493 defm FABS : SIMDTwoVectorFP<0, 1, 0b01111, "fabs", fabs>;
3495 defm FCMEQ : SIMDFPCmpTwoVector<0, 1, 0b01101, "fcmeq", AArch64fcmeqz>;
3496 defm FCMGE : SIMDFPCmpTwoVector<1, 1, 0b01100, "fcmge", AArch64fcmgez>;
3497 defm FCMGT : SIMDFPCmpTwoVector<0, 1, 0b01100, "fcmgt", AArch64fcmgtz>;
3498 defm FCMLE : SIMDFPCmpTwoVector<1, 1, 0b01101, "fcmle", AArch64fcmlez>;
3499 defm FCMLT : SIMDFPCmpTwoVector<0, 1, 0b01110, "fcmlt", AArch64fcmltz>;
3500 defm FCVTAS : SIMDTwoVectorFPToInt<0,0,0b11100, "fcvtas",int_aarch64_neon_fcvtas>;
3501 defm FCVTAU : SIMDTwoVectorFPToInt<1,0,0b11100, "fcvtau",int_aarch64_neon_fcvtau>;
3502 defm FCVTL : SIMDFPWidenTwoVector<0, 0, 0b10111, "fcvtl">;
3503 def : Pat<(v4f32 (int_aarch64_neon_vcvthf2fp (v4i16 V64:$Rn))),
3504 (FCVTLv4i16 V64:$Rn)>;
3505 def : Pat<(v4f32 (int_aarch64_neon_vcvthf2fp (extract_subvector (v8i16 V128:$Rn),
3507 (FCVTLv8i16 V128:$Rn)>;
3508 def : Pat<(v2f64 (fpextend (v2f32 V64:$Rn))), (FCVTLv2i32 V64:$Rn)>;
3509 def : Pat<(v2f64 (fpextend (v2f32 (extract_subvector (v4f32 V128:$Rn),
3511 (FCVTLv4i32 V128:$Rn)>;
3513 def : Pat<(v4f32 (fpextend (v4f16 V64:$Rn))), (FCVTLv4i16 V64:$Rn)>;
3514 def : Pat<(v4f32 (fpextend (v4f16 (extract_subvector (v8f16 V128:$Rn),
3516 (FCVTLv8i16 V128:$Rn)>;
3518 defm FCVTMS : SIMDTwoVectorFPToInt<0,0,0b11011, "fcvtms",int_aarch64_neon_fcvtms>;
3519 defm FCVTMU : SIMDTwoVectorFPToInt<1,0,0b11011, "fcvtmu",int_aarch64_neon_fcvtmu>;
3520 defm FCVTNS : SIMDTwoVectorFPToInt<0,0,0b11010, "fcvtns",int_aarch64_neon_fcvtns>;
3521 defm FCVTNU : SIMDTwoVectorFPToInt<1,0,0b11010, "fcvtnu",int_aarch64_neon_fcvtnu>;
3522 defm FCVTN : SIMDFPNarrowTwoVector<0, 0, 0b10110, "fcvtn">;
3523 def : Pat<(v4i16 (int_aarch64_neon_vcvtfp2hf (v4f32 V128:$Rn))),
3524 (FCVTNv4i16 V128:$Rn)>;
3525 def : Pat<(concat_vectors V64:$Rd,
3526 (v4i16 (int_aarch64_neon_vcvtfp2hf (v4f32 V128:$Rn)))),
3527 (FCVTNv8i16 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
3528 def : Pat<(v2f32 (fpround (v2f64 V128:$Rn))), (FCVTNv2i32 V128:$Rn)>;
3529 def : Pat<(v4f16 (fpround (v4f32 V128:$Rn))), (FCVTNv4i16 V128:$Rn)>;
3530 def : Pat<(concat_vectors V64:$Rd, (v2f32 (fpround (v2f64 V128:$Rn)))),
3531 (FCVTNv4i32 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
3532 defm FCVTPS : SIMDTwoVectorFPToInt<0,1,0b11010, "fcvtps",int_aarch64_neon_fcvtps>;
3533 defm FCVTPU : SIMDTwoVectorFPToInt<1,1,0b11010, "fcvtpu",int_aarch64_neon_fcvtpu>;
3534 defm FCVTXN : SIMDFPInexactCvtTwoVector<1, 0, 0b10110, "fcvtxn",
3535 int_aarch64_neon_fcvtxn>;
3536 defm FCVTZS : SIMDTwoVectorFPToInt<0, 1, 0b11011, "fcvtzs", fp_to_sint>;
3537 defm FCVTZU : SIMDTwoVectorFPToInt<1, 1, 0b11011, "fcvtzu", fp_to_uint>;
3539 def : Pat<(v4i16 (int_aarch64_neon_fcvtzs v4f16:$Rn)), (FCVTZSv4f16 $Rn)>;
3540 def : Pat<(v8i16 (int_aarch64_neon_fcvtzs v8f16:$Rn)), (FCVTZSv8f16 $Rn)>;
3541 def : Pat<(v2i32 (int_aarch64_neon_fcvtzs v2f32:$Rn)), (FCVTZSv2f32 $Rn)>;
3542 def : Pat<(v4i32 (int_aarch64_neon_fcvtzs v4f32:$Rn)), (FCVTZSv4f32 $Rn)>;
3543 def : Pat<(v2i64 (int_aarch64_neon_fcvtzs v2f64:$Rn)), (FCVTZSv2f64 $Rn)>;
3545 def : Pat<(v4i16 (int_aarch64_neon_fcvtzu v4f16:$Rn)), (FCVTZUv4f16 $Rn)>;
3546 def : Pat<(v8i16 (int_aarch64_neon_fcvtzu v8f16:$Rn)), (FCVTZUv8f16 $Rn)>;
3547 def : Pat<(v2i32 (int_aarch64_neon_fcvtzu v2f32:$Rn)), (FCVTZUv2f32 $Rn)>;
3548 def : Pat<(v4i32 (int_aarch64_neon_fcvtzu v4f32:$Rn)), (FCVTZUv4f32 $Rn)>;
3549 def : Pat<(v2i64 (int_aarch64_neon_fcvtzu v2f64:$Rn)), (FCVTZUv2f64 $Rn)>;
3551 defm FNEG : SIMDTwoVectorFP<1, 1, 0b01111, "fneg", fneg>;
3552 defm FRECPE : SIMDTwoVectorFP<0, 1, 0b11101, "frecpe", int_aarch64_neon_frecpe>;
3553 defm FRINTA : SIMDTwoVectorFP<1, 0, 0b11000, "frinta", fround>;
3554 defm FRINTI : SIMDTwoVectorFP<1, 1, 0b11001, "frinti", fnearbyint>;
3555 defm FRINTM : SIMDTwoVectorFP<0, 0, 0b11001, "frintm", ffloor>;
3556 defm FRINTN : SIMDTwoVectorFP<0, 0, 0b11000, "frintn", int_aarch64_neon_frintn>;
3557 defm FRINTP : SIMDTwoVectorFP<0, 1, 0b11000, "frintp", fceil>;
3558 defm FRINTX : SIMDTwoVectorFP<1, 0, 0b11001, "frintx", frint>;
3559 defm FRINTZ : SIMDTwoVectorFP<0, 1, 0b11001, "frintz", ftrunc>;
3561 let Predicates = [HasFRInt3264] in {
3562 defm FRINT32Z : FRIntNNTVector<0, 0, "frint32z">;
3563 defm FRINT64Z : FRIntNNTVector<0, 1, "frint64z">;
3564 defm FRINT32X : FRIntNNTVector<1, 0, "frint32x">;
3565 defm FRINT64X : FRIntNNTVector<1, 1, "frint64x">;
3568 defm FRSQRTE: SIMDTwoVectorFP<1, 1, 0b11101, "frsqrte", int_aarch64_neon_frsqrte>;
3569 defm FSQRT : SIMDTwoVectorFP<1, 1, 0b11111, "fsqrt", fsqrt>;
3570 defm NEG : SIMDTwoVectorBHSD<1, 0b01011, "neg",
3571 UnOpFrag<(sub immAllZerosV, node:$LHS)> >;
3572 defm NOT : SIMDTwoVectorB<1, 0b00, 0b00101, "not", vnot>;
3573 // Aliases for MVN -> NOT.
3574 def : InstAlias<"mvn{ $Vd.8b, $Vn.8b|.8b $Vd, $Vn}",
3575 (NOTv8i8 V64:$Vd, V64:$Vn)>;
3576 def : InstAlias<"mvn{ $Vd.16b, $Vn.16b|.16b $Vd, $Vn}",
3577 (NOTv16i8 V128:$Vd, V128:$Vn)>;
3579 def : Pat<(AArch64neg (v8i8 V64:$Rn)), (NEGv8i8 V64:$Rn)>;
3580 def : Pat<(AArch64neg (v16i8 V128:$Rn)), (NEGv16i8 V128:$Rn)>;
3581 def : Pat<(AArch64neg (v4i16 V64:$Rn)), (NEGv4i16 V64:$Rn)>;
3582 def : Pat<(AArch64neg (v8i16 V128:$Rn)), (NEGv8i16 V128:$Rn)>;
3583 def : Pat<(AArch64neg (v2i32 V64:$Rn)), (NEGv2i32 V64:$Rn)>;
3584 def : Pat<(AArch64neg (v4i32 V128:$Rn)), (NEGv4i32 V128:$Rn)>;
3585 def : Pat<(AArch64neg (v2i64 V128:$Rn)), (NEGv2i64 V128:$Rn)>;
3587 def : Pat<(AArch64not (v8i8 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3588 def : Pat<(AArch64not (v16i8 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3589 def : Pat<(AArch64not (v4i16 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3590 def : Pat<(AArch64not (v8i16 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3591 def : Pat<(AArch64not (v2i32 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3592 def : Pat<(AArch64not (v1i64 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3593 def : Pat<(AArch64not (v4i32 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3594 def : Pat<(AArch64not (v2i64 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3596 def : Pat<(vnot (v4i16 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3597 def : Pat<(vnot (v8i16 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3598 def : Pat<(vnot (v2i32 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3599 def : Pat<(vnot (v4i32 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3600 def : Pat<(vnot (v2i64 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3602 defm RBIT : SIMDTwoVectorB<1, 0b01, 0b00101, "rbit", int_aarch64_neon_rbit>;
3603 defm REV16 : SIMDTwoVectorB<0, 0b00, 0b00001, "rev16", AArch64rev16>;
3604 defm REV32 : SIMDTwoVectorBH<1, 0b00000, "rev32", AArch64rev32>;
3605 defm REV64 : SIMDTwoVectorBHS<0, 0b00000, "rev64", AArch64rev64>;
3606 defm SADALP : SIMDLongTwoVectorTied<0, 0b00110, "sadalp",
3607 BinOpFrag<(add node:$LHS, (int_aarch64_neon_saddlp node:$RHS))> >;
3608 defm SADDLP : SIMDLongTwoVector<0, 0b00010, "saddlp", int_aarch64_neon_saddlp>;
3609 defm SCVTF : SIMDTwoVectorIntToFP<0, 0, 0b11101, "scvtf", sint_to_fp>;
3610 defm SHLL : SIMDVectorLShiftLongBySizeBHS;
3611 defm SQABS : SIMDTwoVectorBHSD<0, 0b00111, "sqabs", int_aarch64_neon_sqabs>;
3612 defm SQNEG : SIMDTwoVectorBHSD<1, 0b00111, "sqneg", int_aarch64_neon_sqneg>;
3613 defm SQXTN : SIMDMixedTwoVector<0, 0b10100, "sqxtn", int_aarch64_neon_sqxtn>;
3614 defm SQXTUN : SIMDMixedTwoVector<1, 0b10010, "sqxtun", int_aarch64_neon_sqxtun>;
3615 defm SUQADD : SIMDTwoVectorBHSDTied<0, 0b00011, "suqadd",int_aarch64_neon_suqadd>;
3616 defm UADALP : SIMDLongTwoVectorTied<1, 0b00110, "uadalp",
3617 BinOpFrag<(add node:$LHS, (int_aarch64_neon_uaddlp node:$RHS))> >;
3618 defm UADDLP : SIMDLongTwoVector<1, 0b00010, "uaddlp",
3619 int_aarch64_neon_uaddlp>;
3620 defm UCVTF : SIMDTwoVectorIntToFP<1, 0, 0b11101, "ucvtf", uint_to_fp>;
3621 defm UQXTN : SIMDMixedTwoVector<1, 0b10100, "uqxtn", int_aarch64_neon_uqxtn>;
3622 defm URECPE : SIMDTwoVectorS<0, 1, 0b11100, "urecpe", int_aarch64_neon_urecpe>;
3623 defm URSQRTE: SIMDTwoVectorS<1, 1, 0b11100, "ursqrte", int_aarch64_neon_ursqrte>;
3624 defm USQADD : SIMDTwoVectorBHSDTied<1, 0b00011, "usqadd",int_aarch64_neon_usqadd>;
3625 defm XTN : SIMDMixedTwoVector<0, 0b10010, "xtn", trunc>;
3627 def : Pat<(v4f16 (AArch64rev32 V64:$Rn)), (REV32v4i16 V64:$Rn)>;
3628 def : Pat<(v4f16 (AArch64rev64 V64:$Rn)), (REV64v4i16 V64:$Rn)>;
3629 def : Pat<(v8f16 (AArch64rev32 V128:$Rn)), (REV32v8i16 V128:$Rn)>;
3630 def : Pat<(v8f16 (AArch64rev64 V128:$Rn)), (REV64v8i16 V128:$Rn)>;
3631 def : Pat<(v2f32 (AArch64rev64 V64:$Rn)), (REV64v2i32 V64:$Rn)>;
3632 def : Pat<(v4f32 (AArch64rev64 V128:$Rn)), (REV64v4i32 V128:$Rn)>;
3634 // Patterns for vector long shift (by element width). These need to match all
3635 // three of zext, sext and anyext so it's easier to pull the patterns out of the
3637 multiclass SIMDVectorLShiftLongBySizeBHSPats<SDPatternOperator ext> {
3638 def : Pat<(AArch64vshl (v8i16 (ext (v8i8 V64:$Rn))), (i32 8)),
3639 (SHLLv8i8 V64:$Rn)>;
3640 def : Pat<(AArch64vshl (v8i16 (ext (extract_high_v16i8 V128:$Rn))), (i32 8)),
3641 (SHLLv16i8 V128:$Rn)>;
3642 def : Pat<(AArch64vshl (v4i32 (ext (v4i16 V64:$Rn))), (i32 16)),
3643 (SHLLv4i16 V64:$Rn)>;
3644 def : Pat<(AArch64vshl (v4i32 (ext (extract_high_v8i16 V128:$Rn))), (i32 16)),
3645 (SHLLv8i16 V128:$Rn)>;
3646 def : Pat<(AArch64vshl (v2i64 (ext (v2i32 V64:$Rn))), (i32 32)),
3647 (SHLLv2i32 V64:$Rn)>;
3648 def : Pat<(AArch64vshl (v2i64 (ext (extract_high_v4i32 V128:$Rn))), (i32 32)),
3649 (SHLLv4i32 V128:$Rn)>;
3652 defm : SIMDVectorLShiftLongBySizeBHSPats<anyext>;
3653 defm : SIMDVectorLShiftLongBySizeBHSPats<zext>;
3654 defm : SIMDVectorLShiftLongBySizeBHSPats<sext>;
3656 //===----------------------------------------------------------------------===//
3657 // Advanced SIMD three vector instructions.
3658 //===----------------------------------------------------------------------===//
3660 defm ADD : SIMDThreeSameVector<0, 0b10000, "add", add>;
3661 defm ADDP : SIMDThreeSameVector<0, 0b10111, "addp", int_aarch64_neon_addp>;
3662 defm CMEQ : SIMDThreeSameVector<1, 0b10001, "cmeq", AArch64cmeq>;
3663 defm CMGE : SIMDThreeSameVector<0, 0b00111, "cmge", AArch64cmge>;
3664 defm CMGT : SIMDThreeSameVector<0, 0b00110, "cmgt", AArch64cmgt>;
3665 defm CMHI : SIMDThreeSameVector<1, 0b00110, "cmhi", AArch64cmhi>;
3666 defm CMHS : SIMDThreeSameVector<1, 0b00111, "cmhs", AArch64cmhs>;
3667 defm CMTST : SIMDThreeSameVector<0, 0b10001, "cmtst", AArch64cmtst>;
3668 defm FABD : SIMDThreeSameVectorFP<1,1,0b010,"fabd", int_aarch64_neon_fabd>;
3669 let Predicates = [HasNEON] in {
3670 foreach VT = [ v2f32, v4f32, v2f64 ] in
3671 def : Pat<(fabs (fsub VT:$Rn, VT:$Rm)), (!cast<Instruction>("FABD"#VT) VT:$Rn, VT:$Rm)>;
3673 let Predicates = [HasNEON, HasFullFP16] in {
3674 foreach VT = [ v4f16, v8f16 ] in
3675 def : Pat<(fabs (fsub VT:$Rn, VT:$Rm)), (!cast<Instruction>("FABD"#VT) VT:$Rn, VT:$Rm)>;
3677 defm FACGE : SIMDThreeSameVectorFPCmp<1,0,0b101,"facge",int_aarch64_neon_facge>;
3678 defm FACGT : SIMDThreeSameVectorFPCmp<1,1,0b101,"facgt",int_aarch64_neon_facgt>;
3679 defm FADDP : SIMDThreeSameVectorFP<1,0,0b010,"faddp",int_aarch64_neon_faddp>;
3680 defm FADD : SIMDThreeSameVectorFP<0,0,0b010,"fadd", fadd>;
3681 defm FCMEQ : SIMDThreeSameVectorFPCmp<0, 0, 0b100, "fcmeq", AArch64fcmeq>;
3682 defm FCMGE : SIMDThreeSameVectorFPCmp<1, 0, 0b100, "fcmge", AArch64fcmge>;
3683 defm FCMGT : SIMDThreeSameVectorFPCmp<1, 1, 0b100, "fcmgt", AArch64fcmgt>;
3684 defm FDIV : SIMDThreeSameVectorFP<1,0,0b111,"fdiv", fdiv>;
3685 defm FMAXNMP : SIMDThreeSameVectorFP<1,0,0b000,"fmaxnmp", int_aarch64_neon_fmaxnmp>;
3686 defm FMAXNM : SIMDThreeSameVectorFP<0,0,0b000,"fmaxnm", fmaxnum>;
3687 defm FMAXP : SIMDThreeSameVectorFP<1,0,0b110,"fmaxp", int_aarch64_neon_fmaxp>;
3688 defm FMAX : SIMDThreeSameVectorFP<0,0,0b110,"fmax", fmaximum>;
3689 defm FMINNMP : SIMDThreeSameVectorFP<1,1,0b000,"fminnmp", int_aarch64_neon_fminnmp>;
3690 defm FMINNM : SIMDThreeSameVectorFP<0,1,0b000,"fminnm", fminnum>;
3691 defm FMINP : SIMDThreeSameVectorFP<1,1,0b110,"fminp", int_aarch64_neon_fminp>;
3692 defm FMIN : SIMDThreeSameVectorFP<0,1,0b110,"fmin", fminimum>;
3694 // NOTE: The operands of the PatFrag are reordered on FMLA/FMLS because the
3695 // instruction expects the addend first, while the fma intrinsic puts it last.
3696 defm FMLA : SIMDThreeSameVectorFPTied<0, 0, 0b001, "fmla",
3697 TriOpFrag<(fma node:$RHS, node:$MHS, node:$LHS)> >;
3698 defm FMLS : SIMDThreeSameVectorFPTied<0, 1, 0b001, "fmls",
3699 TriOpFrag<(fma node:$MHS, (fneg node:$RHS), node:$LHS)> >;
3701 // The following def pats catch the case where the LHS of an FMA is negated.
3702 // The TriOpFrag above catches the case where the middle operand is negated.
3703 def : Pat<(v2f32 (fma (fneg V64:$Rn), V64:$Rm, V64:$Rd)),
3704 (FMLSv2f32 V64:$Rd, V64:$Rn, V64:$Rm)>;
3706 def : Pat<(v4f32 (fma (fneg V128:$Rn), V128:$Rm, V128:$Rd)),
3707 (FMLSv4f32 V128:$Rd, V128:$Rn, V128:$Rm)>;
3709 def : Pat<(v2f64 (fma (fneg V128:$Rn), V128:$Rm, V128:$Rd)),
3710 (FMLSv2f64 V128:$Rd, V128:$Rn, V128:$Rm)>;
3712 defm FMULX : SIMDThreeSameVectorFP<0,0,0b011,"fmulx", int_aarch64_neon_fmulx>;
3713 defm FMUL : SIMDThreeSameVectorFP<1,0,0b011,"fmul", fmul>;
3714 defm FRECPS : SIMDThreeSameVectorFP<0,0,0b111,"frecps", int_aarch64_neon_frecps>;
3715 defm FRSQRTS : SIMDThreeSameVectorFP<0,1,0b111,"frsqrts", int_aarch64_neon_frsqrts>;
3716 defm FSUB : SIMDThreeSameVectorFP<0,1,0b010,"fsub", fsub>;
3717 defm MLA : SIMDThreeSameVectorBHSTied<0, 0b10010, "mla",
3718 TriOpFrag<(add node:$LHS, (mul node:$MHS, node:$RHS))> >;
3719 defm MLS : SIMDThreeSameVectorBHSTied<1, 0b10010, "mls",
3720 TriOpFrag<(sub node:$LHS, (mul node:$MHS, node:$RHS))> >;
3721 defm MUL : SIMDThreeSameVectorBHS<0, 0b10011, "mul", mul>;
3722 defm PMUL : SIMDThreeSameVectorB<1, 0b10011, "pmul", int_aarch64_neon_pmul>;
3723 defm SABA : SIMDThreeSameVectorBHSTied<0, 0b01111, "saba",
3724 TriOpFrag<(add node:$LHS, (int_aarch64_neon_sabd node:$MHS, node:$RHS))> >;
3725 defm SABD : SIMDThreeSameVectorBHS<0,0b01110,"sabd", int_aarch64_neon_sabd>;
3726 defm SHADD : SIMDThreeSameVectorBHS<0,0b00000,"shadd", int_aarch64_neon_shadd>;
3727 defm SHSUB : SIMDThreeSameVectorBHS<0,0b00100,"shsub", int_aarch64_neon_shsub>;
3728 defm SMAXP : SIMDThreeSameVectorBHS<0,0b10100,"smaxp", int_aarch64_neon_smaxp>;
3729 defm SMAX : SIMDThreeSameVectorBHS<0,0b01100,"smax", smax>;
3730 defm SMINP : SIMDThreeSameVectorBHS<0,0b10101,"sminp", int_aarch64_neon_sminp>;
3731 defm SMIN : SIMDThreeSameVectorBHS<0,0b01101,"smin", smin>;
3732 defm SQADD : SIMDThreeSameVector<0,0b00001,"sqadd", int_aarch64_neon_sqadd>;
3733 defm SQDMULH : SIMDThreeSameVectorHS<0,0b10110,"sqdmulh",int_aarch64_neon_sqdmulh>;
3734 defm SQRDMULH : SIMDThreeSameVectorHS<1,0b10110,"sqrdmulh",int_aarch64_neon_sqrdmulh>;
3735 defm SQRSHL : SIMDThreeSameVector<0,0b01011,"sqrshl", int_aarch64_neon_sqrshl>;
3736 defm SQSHL : SIMDThreeSameVector<0,0b01001,"sqshl", int_aarch64_neon_sqshl>;
3737 defm SQSUB : SIMDThreeSameVector<0,0b00101,"sqsub", int_aarch64_neon_sqsub>;
3738 defm SRHADD : SIMDThreeSameVectorBHS<0,0b00010,"srhadd",int_aarch64_neon_srhadd>;
3739 defm SRSHL : SIMDThreeSameVector<0,0b01010,"srshl", int_aarch64_neon_srshl>;
3740 defm SSHL : SIMDThreeSameVector<0,0b01000,"sshl", int_aarch64_neon_sshl>;
3741 defm SUB : SIMDThreeSameVector<1,0b10000,"sub", sub>;
3742 defm UABA : SIMDThreeSameVectorBHSTied<1, 0b01111, "uaba",
3743 TriOpFrag<(add node:$LHS, (int_aarch64_neon_uabd node:$MHS, node:$RHS))> >;
3744 defm UABD : SIMDThreeSameVectorBHS<1,0b01110,"uabd", int_aarch64_neon_uabd>;
3745 defm UHADD : SIMDThreeSameVectorBHS<1,0b00000,"uhadd", int_aarch64_neon_uhadd>;
3746 defm UHSUB : SIMDThreeSameVectorBHS<1,0b00100,"uhsub", int_aarch64_neon_uhsub>;
3747 defm UMAXP : SIMDThreeSameVectorBHS<1,0b10100,"umaxp", int_aarch64_neon_umaxp>;
3748 defm UMAX : SIMDThreeSameVectorBHS<1,0b01100,"umax", umax>;
3749 defm UMINP : SIMDThreeSameVectorBHS<1,0b10101,"uminp", int_aarch64_neon_uminp>;
3750 defm UMIN : SIMDThreeSameVectorBHS<1,0b01101,"umin", umin>;
3751 defm UQADD : SIMDThreeSameVector<1,0b00001,"uqadd", int_aarch64_neon_uqadd>;
3752 defm UQRSHL : SIMDThreeSameVector<1,0b01011,"uqrshl", int_aarch64_neon_uqrshl>;
3753 defm UQSHL : SIMDThreeSameVector<1,0b01001,"uqshl", int_aarch64_neon_uqshl>;
3754 defm UQSUB : SIMDThreeSameVector<1,0b00101,"uqsub", int_aarch64_neon_uqsub>;
3755 defm URHADD : SIMDThreeSameVectorBHS<1,0b00010,"urhadd", int_aarch64_neon_urhadd>;
3756 defm URSHL : SIMDThreeSameVector<1,0b01010,"urshl", int_aarch64_neon_urshl>;
3757 defm USHL : SIMDThreeSameVector<1,0b01000,"ushl", int_aarch64_neon_ushl>;
3758 defm SQRDMLAH : SIMDThreeSameVectorSQRDMLxHTiedHS<1,0b10000,"sqrdmlah",
3759 int_aarch64_neon_sqadd>;
3760 defm SQRDMLSH : SIMDThreeSameVectorSQRDMLxHTiedHS<1,0b10001,"sqrdmlsh",
3761 int_aarch64_neon_sqsub>;
3763 defm AND : SIMDLogicalThreeVector<0, 0b00, "and", and>;
3764 defm BIC : SIMDLogicalThreeVector<0, 0b01, "bic",
3765 BinOpFrag<(and node:$LHS, (vnot node:$RHS))> >;
3766 defm BIF : SIMDLogicalThreeVector<1, 0b11, "bif">;
3767 defm BIT : SIMDLogicalThreeVectorTied<1, 0b10, "bit", AArch64bit>;
3768 defm BSL : SIMDLogicalThreeVectorTied<1, 0b01, "bsl",
3769 TriOpFrag<(or (and node:$LHS, node:$MHS), (and (vnot node:$LHS), node:$RHS))>>;
3770 defm EOR : SIMDLogicalThreeVector<1, 0b00, "eor", xor>;
3771 defm ORN : SIMDLogicalThreeVector<0, 0b11, "orn",
3772 BinOpFrag<(or node:$LHS, (vnot node:$RHS))> >;
3773 defm ORR : SIMDLogicalThreeVector<0, 0b10, "orr", or>;
3776 def : Pat<(AArch64bsl (v8i8 V64:$Rd), V64:$Rn, V64:$Rm),
3777 (BSLv8i8 V64:$Rd, V64:$Rn, V64:$Rm)>;
3778 def : Pat<(AArch64bsl (v4i16 V64:$Rd), V64:$Rn, V64:$Rm),
3779 (BSLv8i8 V64:$Rd, V64:$Rn, V64:$Rm)>;
3780 def : Pat<(AArch64bsl (v2i32 V64:$Rd), V64:$Rn, V64:$Rm),
3781 (BSLv8i8 V64:$Rd, V64:$Rn, V64:$Rm)>;
3782 def : Pat<(AArch64bsl (v1i64 V64:$Rd), V64:$Rn, V64:$Rm),
3783 (BSLv8i8 V64:$Rd, V64:$Rn, V64:$Rm)>;
3785 def : Pat<(AArch64bsl (v16i8 V128:$Rd), V128:$Rn, V128:$Rm),
3786 (BSLv16i8 V128:$Rd, V128:$Rn, V128:$Rm)>;
3787 def : Pat<(AArch64bsl (v8i16 V128:$Rd), V128:$Rn, V128:$Rm),
3788 (BSLv16i8 V128:$Rd, V128:$Rn, V128:$Rm)>;
3789 def : Pat<(AArch64bsl (v4i32 V128:$Rd), V128:$Rn, V128:$Rm),
3790 (BSLv16i8 V128:$Rd, V128:$Rn, V128:$Rm)>;
3791 def : Pat<(AArch64bsl (v2i64 V128:$Rd), V128:$Rn, V128:$Rm),
3792 (BSLv16i8 V128:$Rd, V128:$Rn, V128:$Rm)>;
3794 def : InstAlias<"mov{\t$dst.16b, $src.16b|.16b\t$dst, $src}",
3795 (ORRv16i8 V128:$dst, V128:$src, V128:$src), 1>;
3796 def : InstAlias<"mov{\t$dst.8h, $src.8h|.8h\t$dst, $src}",
3797 (ORRv16i8 V128:$dst, V128:$src, V128:$src), 0>;
3798 def : InstAlias<"mov{\t$dst.4s, $src.4s|.4s\t$dst, $src}",
3799 (ORRv16i8 V128:$dst, V128:$src, V128:$src), 0>;
3800 def : InstAlias<"mov{\t$dst.2d, $src.2d|.2d\t$dst, $src}",
3801 (ORRv16i8 V128:$dst, V128:$src, V128:$src), 0>;
3803 def : InstAlias<"mov{\t$dst.8b, $src.8b|.8b\t$dst, $src}",
3804 (ORRv8i8 V64:$dst, V64:$src, V64:$src), 1>;
3805 def : InstAlias<"mov{\t$dst.4h, $src.4h|.4h\t$dst, $src}",
3806 (ORRv8i8 V64:$dst, V64:$src, V64:$src), 0>;
3807 def : InstAlias<"mov{\t$dst.2s, $src.2s|.2s\t$dst, $src}",
3808 (ORRv8i8 V64:$dst, V64:$src, V64:$src), 0>;
3809 def : InstAlias<"mov{\t$dst.1d, $src.1d|.1d\t$dst, $src}",
3810 (ORRv8i8 V64:$dst, V64:$src, V64:$src), 0>;
3812 def : InstAlias<"{cmls\t$dst.8b, $src1.8b, $src2.8b" #
3813 "|cmls.8b\t$dst, $src1, $src2}",
3814 (CMHSv8i8 V64:$dst, V64:$src2, V64:$src1), 0>;
3815 def : InstAlias<"{cmls\t$dst.16b, $src1.16b, $src2.16b" #
3816 "|cmls.16b\t$dst, $src1, $src2}",
3817 (CMHSv16i8 V128:$dst, V128:$src2, V128:$src1), 0>;
3818 def : InstAlias<"{cmls\t$dst.4h, $src1.4h, $src2.4h" #
3819 "|cmls.4h\t$dst, $src1, $src2}",
3820 (CMHSv4i16 V64:$dst, V64:$src2, V64:$src1), 0>;
3821 def : InstAlias<"{cmls\t$dst.8h, $src1.8h, $src2.8h" #
3822 "|cmls.8h\t$dst, $src1, $src2}",
3823 (CMHSv8i16 V128:$dst, V128:$src2, V128:$src1), 0>;
3824 def : InstAlias<"{cmls\t$dst.2s, $src1.2s, $src2.2s" #
3825 "|cmls.2s\t$dst, $src1, $src2}",
3826 (CMHSv2i32 V64:$dst, V64:$src2, V64:$src1), 0>;
3827 def : InstAlias<"{cmls\t$dst.4s, $src1.4s, $src2.4s" #
3828 "|cmls.4s\t$dst, $src1, $src2}",
3829 (CMHSv4i32 V128:$dst, V128:$src2, V128:$src1), 0>;
3830 def : InstAlias<"{cmls\t$dst.2d, $src1.2d, $src2.2d" #
3831 "|cmls.2d\t$dst, $src1, $src2}",
3832 (CMHSv2i64 V128:$dst, V128:$src2, V128:$src1), 0>;
3834 def : InstAlias<"{cmlo\t$dst.8b, $src1.8b, $src2.8b" #
3835 "|cmlo.8b\t$dst, $src1, $src2}",
3836 (CMHIv8i8 V64:$dst, V64:$src2, V64:$src1), 0>;
3837 def : InstAlias<"{cmlo\t$dst.16b, $src1.16b, $src2.16b" #
3838 "|cmlo.16b\t$dst, $src1, $src2}",
3839 (CMHIv16i8 V128:$dst, V128:$src2, V128:$src1), 0>;
3840 def : InstAlias<"{cmlo\t$dst.4h, $src1.4h, $src2.4h" #
3841 "|cmlo.4h\t$dst, $src1, $src2}",
3842 (CMHIv4i16 V64:$dst, V64:$src2, V64:$src1), 0>;
3843 def : InstAlias<"{cmlo\t$dst.8h, $src1.8h, $src2.8h" #
3844 "|cmlo.8h\t$dst, $src1, $src2}",
3845 (CMHIv8i16 V128:$dst, V128:$src2, V128:$src1), 0>;
3846 def : InstAlias<"{cmlo\t$dst.2s, $src1.2s, $src2.2s" #
3847 "|cmlo.2s\t$dst, $src1, $src2}",
3848 (CMHIv2i32 V64:$dst, V64:$src2, V64:$src1), 0>;
3849 def : InstAlias<"{cmlo\t$dst.4s, $src1.4s, $src2.4s" #
3850 "|cmlo.4s\t$dst, $src1, $src2}",
3851 (CMHIv4i32 V128:$dst, V128:$src2, V128:$src1), 0>;
3852 def : InstAlias<"{cmlo\t$dst.2d, $src1.2d, $src2.2d" #
3853 "|cmlo.2d\t$dst, $src1, $src2}",
3854 (CMHIv2i64 V128:$dst, V128:$src2, V128:$src1), 0>;
3856 def : InstAlias<"{cmle\t$dst.8b, $src1.8b, $src2.8b" #
3857 "|cmle.8b\t$dst, $src1, $src2}",
3858 (CMGEv8i8 V64:$dst, V64:$src2, V64:$src1), 0>;
3859 def : InstAlias<"{cmle\t$dst.16b, $src1.16b, $src2.16b" #
3860 "|cmle.16b\t$dst, $src1, $src2}",
3861 (CMGEv16i8 V128:$dst, V128:$src2, V128:$src1), 0>;
3862 def : InstAlias<"{cmle\t$dst.4h, $src1.4h, $src2.4h" #
3863 "|cmle.4h\t$dst, $src1, $src2}",
3864 (CMGEv4i16 V64:$dst, V64:$src2, V64:$src1), 0>;
3865 def : InstAlias<"{cmle\t$dst.8h, $src1.8h, $src2.8h" #
3866 "|cmle.8h\t$dst, $src1, $src2}",
3867 (CMGEv8i16 V128:$dst, V128:$src2, V128:$src1), 0>;
3868 def : InstAlias<"{cmle\t$dst.2s, $src1.2s, $src2.2s" #
3869 "|cmle.2s\t$dst, $src1, $src2}",
3870 (CMGEv2i32 V64:$dst, V64:$src2, V64:$src1), 0>;
3871 def : InstAlias<"{cmle\t$dst.4s, $src1.4s, $src2.4s" #
3872 "|cmle.4s\t$dst, $src1, $src2}",
3873 (CMGEv4i32 V128:$dst, V128:$src2, V128:$src1), 0>;
3874 def : InstAlias<"{cmle\t$dst.2d, $src1.2d, $src2.2d" #
3875 "|cmle.2d\t$dst, $src1, $src2}",
3876 (CMGEv2i64 V128:$dst, V128:$src2, V128:$src1), 0>;
3878 def : InstAlias<"{cmlt\t$dst.8b, $src1.8b, $src2.8b" #
3879 "|cmlt.8b\t$dst, $src1, $src2}",
3880 (CMGTv8i8 V64:$dst, V64:$src2, V64:$src1), 0>;
3881 def : InstAlias<"{cmlt\t$dst.16b, $src1.16b, $src2.16b" #
3882 "|cmlt.16b\t$dst, $src1, $src2}",
3883 (CMGTv16i8 V128:$dst, V128:$src2, V128:$src1), 0>;
3884 def : InstAlias<"{cmlt\t$dst.4h, $src1.4h, $src2.4h" #
3885 "|cmlt.4h\t$dst, $src1, $src2}",
3886 (CMGTv4i16 V64:$dst, V64:$src2, V64:$src1), 0>;
3887 def : InstAlias<"{cmlt\t$dst.8h, $src1.8h, $src2.8h" #
3888 "|cmlt.8h\t$dst, $src1, $src2}",
3889 (CMGTv8i16 V128:$dst, V128:$src2, V128:$src1), 0>;
3890 def : InstAlias<"{cmlt\t$dst.2s, $src1.2s, $src2.2s" #
3891 "|cmlt.2s\t$dst, $src1, $src2}",
3892 (CMGTv2i32 V64:$dst, V64:$src2, V64:$src1), 0>;
3893 def : InstAlias<"{cmlt\t$dst.4s, $src1.4s, $src2.4s" #
3894 "|cmlt.4s\t$dst, $src1, $src2}",
3895 (CMGTv4i32 V128:$dst, V128:$src2, V128:$src1), 0>;
3896 def : InstAlias<"{cmlt\t$dst.2d, $src1.2d, $src2.2d" #
3897 "|cmlt.2d\t$dst, $src1, $src2}",
3898 (CMGTv2i64 V128:$dst, V128:$src2, V128:$src1), 0>;
3900 let Predicates = [HasNEON, HasFullFP16] in {
3901 def : InstAlias<"{fcmle\t$dst.4h, $src1.4h, $src2.4h" #
3902 "|fcmle.4h\t$dst, $src1, $src2}",
3903 (FCMGEv4f16 V64:$dst, V64:$src2, V64:$src1), 0>;
3904 def : InstAlias<"{fcmle\t$dst.8h, $src1.8h, $src2.8h" #
3905 "|fcmle.8h\t$dst, $src1, $src2}",
3906 (FCMGEv8f16 V128:$dst, V128:$src2, V128:$src1), 0>;
3908 def : InstAlias<"{fcmle\t$dst.2s, $src1.2s, $src2.2s" #
3909 "|fcmle.2s\t$dst, $src1, $src2}",
3910 (FCMGEv2f32 V64:$dst, V64:$src2, V64:$src1), 0>;
3911 def : InstAlias<"{fcmle\t$dst.4s, $src1.4s, $src2.4s" #
3912 "|fcmle.4s\t$dst, $src1, $src2}",
3913 (FCMGEv4f32 V128:$dst, V128:$src2, V128:$src1), 0>;
3914 def : InstAlias<"{fcmle\t$dst.2d, $src1.2d, $src2.2d" #
3915 "|fcmle.2d\t$dst, $src1, $src2}",
3916 (FCMGEv2f64 V128:$dst, V128:$src2, V128:$src1), 0>;
3918 let Predicates = [HasNEON, HasFullFP16] in {
3919 def : InstAlias<"{fcmlt\t$dst.4h, $src1.4h, $src2.4h" #
3920 "|fcmlt.4h\t$dst, $src1, $src2}",
3921 (FCMGTv4f16 V64:$dst, V64:$src2, V64:$src1), 0>;
3922 def : InstAlias<"{fcmlt\t$dst.8h, $src1.8h, $src2.8h" #
3923 "|fcmlt.8h\t$dst, $src1, $src2}",
3924 (FCMGTv8f16 V128:$dst, V128:$src2, V128:$src1), 0>;
3926 def : InstAlias<"{fcmlt\t$dst.2s, $src1.2s, $src2.2s" #
3927 "|fcmlt.2s\t$dst, $src1, $src2}",
3928 (FCMGTv2f32 V64:$dst, V64:$src2, V64:$src1), 0>;
3929 def : InstAlias<"{fcmlt\t$dst.4s, $src1.4s, $src2.4s" #
3930 "|fcmlt.4s\t$dst, $src1, $src2}",
3931 (FCMGTv4f32 V128:$dst, V128:$src2, V128:$src1), 0>;
3932 def : InstAlias<"{fcmlt\t$dst.2d, $src1.2d, $src2.2d" #
3933 "|fcmlt.2d\t$dst, $src1, $src2}",
3934 (FCMGTv2f64 V128:$dst, V128:$src2, V128:$src1), 0>;
3936 let Predicates = [HasNEON, HasFullFP16] in {
3937 def : InstAlias<"{facle\t$dst.4h, $src1.4h, $src2.4h" #
3938 "|facle.4h\t$dst, $src1, $src2}",
3939 (FACGEv4f16 V64:$dst, V64:$src2, V64:$src1), 0>;
3940 def : InstAlias<"{facle\t$dst.8h, $src1.8h, $src2.8h" #
3941 "|facle.8h\t$dst, $src1, $src2}",
3942 (FACGEv8f16 V128:$dst, V128:$src2, V128:$src1), 0>;
3944 def : InstAlias<"{facle\t$dst.2s, $src1.2s, $src2.2s" #
3945 "|facle.2s\t$dst, $src1, $src2}",
3946 (FACGEv2f32 V64:$dst, V64:$src2, V64:$src1), 0>;
3947 def : InstAlias<"{facle\t$dst.4s, $src1.4s, $src2.4s" #
3948 "|facle.4s\t$dst, $src1, $src2}",
3949 (FACGEv4f32 V128:$dst, V128:$src2, V128:$src1), 0>;
3950 def : InstAlias<"{facle\t$dst.2d, $src1.2d, $src2.2d" #
3951 "|facle.2d\t$dst, $src1, $src2}",
3952 (FACGEv2f64 V128:$dst, V128:$src2, V128:$src1), 0>;
3954 let Predicates = [HasNEON, HasFullFP16] in {
3955 def : InstAlias<"{faclt\t$dst.4h, $src1.4h, $src2.4h" #
3956 "|faclt.4h\t$dst, $src1, $src2}",
3957 (FACGTv4f16 V64:$dst, V64:$src2, V64:$src1), 0>;
3958 def : InstAlias<"{faclt\t$dst.8h, $src1.8h, $src2.8h" #
3959 "|faclt.8h\t$dst, $src1, $src2}",
3960 (FACGTv8f16 V128:$dst, V128:$src2, V128:$src1), 0>;
3962 def : InstAlias<"{faclt\t$dst.2s, $src1.2s, $src2.2s" #
3963 "|faclt.2s\t$dst, $src1, $src2}",
3964 (FACGTv2f32 V64:$dst, V64:$src2, V64:$src1), 0>;
3965 def : InstAlias<"{faclt\t$dst.4s, $src1.4s, $src2.4s" #
3966 "|faclt.4s\t$dst, $src1, $src2}",
3967 (FACGTv4f32 V128:$dst, V128:$src2, V128:$src1), 0>;
3968 def : InstAlias<"{faclt\t$dst.2d, $src1.2d, $src2.2d" #
3969 "|faclt.2d\t$dst, $src1, $src2}",
3970 (FACGTv2f64 V128:$dst, V128:$src2, V128:$src1), 0>;
3972 //===----------------------------------------------------------------------===//
3973 // Advanced SIMD three scalar instructions.
3974 //===----------------------------------------------------------------------===//
3976 defm ADD : SIMDThreeScalarD<0, 0b10000, "add", add>;
3977 defm CMEQ : SIMDThreeScalarD<1, 0b10001, "cmeq", AArch64cmeq>;
3978 defm CMGE : SIMDThreeScalarD<0, 0b00111, "cmge", AArch64cmge>;
3979 defm CMGT : SIMDThreeScalarD<0, 0b00110, "cmgt", AArch64cmgt>;
3980 defm CMHI : SIMDThreeScalarD<1, 0b00110, "cmhi", AArch64cmhi>;
3981 defm CMHS : SIMDThreeScalarD<1, 0b00111, "cmhs", AArch64cmhs>;
3982 defm CMTST : SIMDThreeScalarD<0, 0b10001, "cmtst", AArch64cmtst>;
3983 defm FABD : SIMDFPThreeScalar<1, 1, 0b010, "fabd", int_aarch64_sisd_fabd>;
3984 def : Pat<(v1f64 (int_aarch64_neon_fabd (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
3985 (FABD64 FPR64:$Rn, FPR64:$Rm)>;
3986 let Predicates = [HasFullFP16] in {
3987 def : Pat<(fabs (fsub f16:$Rn, f16:$Rm)), (FABD16 f16:$Rn, f16:$Rm)>;
3989 def : Pat<(fabs (fsub f32:$Rn, f32:$Rm)), (FABD32 f32:$Rn, f32:$Rm)>;
3990 def : Pat<(fabs (fsub f64:$Rn, f64:$Rm)), (FABD64 f64:$Rn, f64:$Rm)>;
3991 defm FACGE : SIMDThreeScalarFPCmp<1, 0, 0b101, "facge",
3992 int_aarch64_neon_facge>;
3993 defm FACGT : SIMDThreeScalarFPCmp<1, 1, 0b101, "facgt",
3994 int_aarch64_neon_facgt>;
3995 defm FCMEQ : SIMDThreeScalarFPCmp<0, 0, 0b100, "fcmeq", AArch64fcmeq>;
3996 defm FCMGE : SIMDThreeScalarFPCmp<1, 0, 0b100, "fcmge", AArch64fcmge>;
3997 defm FCMGT : SIMDThreeScalarFPCmp<1, 1, 0b100, "fcmgt", AArch64fcmgt>;
3998 defm FMULX : SIMDFPThreeScalar<0, 0, 0b011, "fmulx", int_aarch64_neon_fmulx>;
3999 defm FRECPS : SIMDFPThreeScalar<0, 0, 0b111, "frecps", int_aarch64_neon_frecps>;
4000 defm FRSQRTS : SIMDFPThreeScalar<0, 1, 0b111, "frsqrts", int_aarch64_neon_frsqrts>;
4001 defm SQADD : SIMDThreeScalarBHSD<0, 0b00001, "sqadd", int_aarch64_neon_sqadd>;
4002 defm SQDMULH : SIMDThreeScalarHS< 0, 0b10110, "sqdmulh", int_aarch64_neon_sqdmulh>;
4003 defm SQRDMULH : SIMDThreeScalarHS< 1, 0b10110, "sqrdmulh", int_aarch64_neon_sqrdmulh>;
4004 defm SQRSHL : SIMDThreeScalarBHSD<0, 0b01011, "sqrshl",int_aarch64_neon_sqrshl>;
4005 defm SQSHL : SIMDThreeScalarBHSD<0, 0b01001, "sqshl", int_aarch64_neon_sqshl>;
4006 defm SQSUB : SIMDThreeScalarBHSD<0, 0b00101, "sqsub", int_aarch64_neon_sqsub>;
4007 defm SRSHL : SIMDThreeScalarD< 0, 0b01010, "srshl", int_aarch64_neon_srshl>;
4008 defm SSHL : SIMDThreeScalarD< 0, 0b01000, "sshl", int_aarch64_neon_sshl>;
4009 defm SUB : SIMDThreeScalarD< 1, 0b10000, "sub", sub>;
4010 defm UQADD : SIMDThreeScalarBHSD<1, 0b00001, "uqadd", int_aarch64_neon_uqadd>;
4011 defm UQRSHL : SIMDThreeScalarBHSD<1, 0b01011, "uqrshl",int_aarch64_neon_uqrshl>;
4012 defm UQSHL : SIMDThreeScalarBHSD<1, 0b01001, "uqshl", int_aarch64_neon_uqshl>;
4013 defm UQSUB : SIMDThreeScalarBHSD<1, 0b00101, "uqsub", int_aarch64_neon_uqsub>;
4014 defm URSHL : SIMDThreeScalarD< 1, 0b01010, "urshl", int_aarch64_neon_urshl>;
4015 defm USHL : SIMDThreeScalarD< 1, 0b01000, "ushl", int_aarch64_neon_ushl>;
4016 let Predicates = [HasRDM] in {
4017 defm SQRDMLAH : SIMDThreeScalarHSTied<1, 0, 0b10000, "sqrdmlah">;
4018 defm SQRDMLSH : SIMDThreeScalarHSTied<1, 0, 0b10001, "sqrdmlsh">;
4019 def : Pat<(i32 (int_aarch64_neon_sqadd
4021 (i32 (int_aarch64_neon_sqrdmulh (i32 FPR32:$Rn),
4022 (i32 FPR32:$Rm))))),
4023 (SQRDMLAHv1i32 FPR32:$Rd, FPR32:$Rn, FPR32:$Rm)>;
4024 def : Pat<(i32 (int_aarch64_neon_sqsub
4026 (i32 (int_aarch64_neon_sqrdmulh (i32 FPR32:$Rn),
4027 (i32 FPR32:$Rm))))),
4028 (SQRDMLSHv1i32 FPR32:$Rd, FPR32:$Rn, FPR32:$Rm)>;
4031 def : InstAlias<"cmls $dst, $src1, $src2",
4032 (CMHSv1i64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
4033 def : InstAlias<"cmle $dst, $src1, $src2",
4034 (CMGEv1i64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
4035 def : InstAlias<"cmlo $dst, $src1, $src2",
4036 (CMHIv1i64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
4037 def : InstAlias<"cmlt $dst, $src1, $src2",
4038 (CMGTv1i64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
4039 def : InstAlias<"fcmle $dst, $src1, $src2",
4040 (FCMGE32 FPR32:$dst, FPR32:$src2, FPR32:$src1), 0>;
4041 def : InstAlias<"fcmle $dst, $src1, $src2",
4042 (FCMGE64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
4043 def : InstAlias<"fcmlt $dst, $src1, $src2",
4044 (FCMGT32 FPR32:$dst, FPR32:$src2, FPR32:$src1), 0>;
4045 def : InstAlias<"fcmlt $dst, $src1, $src2",
4046 (FCMGT64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
4047 def : InstAlias<"facle $dst, $src1, $src2",
4048 (FACGE32 FPR32:$dst, FPR32:$src2, FPR32:$src1), 0>;
4049 def : InstAlias<"facle $dst, $src1, $src2",
4050 (FACGE64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
4051 def : InstAlias<"faclt $dst, $src1, $src2",
4052 (FACGT32 FPR32:$dst, FPR32:$src2, FPR32:$src1), 0>;
4053 def : InstAlias<"faclt $dst, $src1, $src2",
4054 (FACGT64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
4056 //===----------------------------------------------------------------------===//
4057 // Advanced SIMD three scalar instructions (mixed operands).
4058 //===----------------------------------------------------------------------===//
4059 defm SQDMULL : SIMDThreeScalarMixedHS<0, 0b11010, "sqdmull",
4060 int_aarch64_neon_sqdmulls_scalar>;
4061 defm SQDMLAL : SIMDThreeScalarMixedTiedHS<0, 0b10010, "sqdmlal">;
4062 defm SQDMLSL : SIMDThreeScalarMixedTiedHS<0, 0b10110, "sqdmlsl">;
4064 def : Pat<(i64 (int_aarch64_neon_sqadd (i64 FPR64:$Rd),
4065 (i64 (int_aarch64_neon_sqdmulls_scalar (i32 FPR32:$Rn),
4066 (i32 FPR32:$Rm))))),
4067 (SQDMLALi32 FPR64:$Rd, FPR32:$Rn, FPR32:$Rm)>;
4068 def : Pat<(i64 (int_aarch64_neon_sqsub (i64 FPR64:$Rd),
4069 (i64 (int_aarch64_neon_sqdmulls_scalar (i32 FPR32:$Rn),
4070 (i32 FPR32:$Rm))))),
4071 (SQDMLSLi32 FPR64:$Rd, FPR32:$Rn, FPR32:$Rm)>;
4073 //===----------------------------------------------------------------------===//
4074 // Advanced SIMD two scalar instructions.
4075 //===----------------------------------------------------------------------===//
4077 defm ABS : SIMDTwoScalarD< 0, 0b01011, "abs", abs>;
4078 defm CMEQ : SIMDCmpTwoScalarD< 0, 0b01001, "cmeq", AArch64cmeqz>;
4079 defm CMGE : SIMDCmpTwoScalarD< 1, 0b01000, "cmge", AArch64cmgez>;
4080 defm CMGT : SIMDCmpTwoScalarD< 0, 0b01000, "cmgt", AArch64cmgtz>;
4081 defm CMLE : SIMDCmpTwoScalarD< 1, 0b01001, "cmle", AArch64cmlez>;
4082 defm CMLT : SIMDCmpTwoScalarD< 0, 0b01010, "cmlt", AArch64cmltz>;
4083 defm FCMEQ : SIMDFPCmpTwoScalar<0, 1, 0b01101, "fcmeq", AArch64fcmeqz>;
4084 defm FCMGE : SIMDFPCmpTwoScalar<1, 1, 0b01100, "fcmge", AArch64fcmgez>;
4085 defm FCMGT : SIMDFPCmpTwoScalar<0, 1, 0b01100, "fcmgt", AArch64fcmgtz>;
4086 defm FCMLE : SIMDFPCmpTwoScalar<1, 1, 0b01101, "fcmle", AArch64fcmlez>;
4087 defm FCMLT : SIMDFPCmpTwoScalar<0, 1, 0b01110, "fcmlt", AArch64fcmltz>;
4088 defm FCVTAS : SIMDFPTwoScalar< 0, 0, 0b11100, "fcvtas">;
4089 defm FCVTAU : SIMDFPTwoScalar< 1, 0, 0b11100, "fcvtau">;
4090 defm FCVTMS : SIMDFPTwoScalar< 0, 0, 0b11011, "fcvtms">;
4091 defm FCVTMU : SIMDFPTwoScalar< 1, 0, 0b11011, "fcvtmu">;
4092 defm FCVTNS : SIMDFPTwoScalar< 0, 0, 0b11010, "fcvtns">;
4093 defm FCVTNU : SIMDFPTwoScalar< 1, 0, 0b11010, "fcvtnu">;
4094 defm FCVTPS : SIMDFPTwoScalar< 0, 1, 0b11010, "fcvtps">;
4095 defm FCVTPU : SIMDFPTwoScalar< 1, 1, 0b11010, "fcvtpu">;
4096 def FCVTXNv1i64 : SIMDInexactCvtTwoScalar<0b10110, "fcvtxn">;
4097 defm FCVTZS : SIMDFPTwoScalar< 0, 1, 0b11011, "fcvtzs">;
4098 defm FCVTZU : SIMDFPTwoScalar< 1, 1, 0b11011, "fcvtzu">;
4099 defm FRECPE : SIMDFPTwoScalar< 0, 1, 0b11101, "frecpe">;
4100 defm FRECPX : SIMDFPTwoScalar< 0, 1, 0b11111, "frecpx">;
4101 defm FRSQRTE : SIMDFPTwoScalar< 1, 1, 0b11101, "frsqrte">;
4102 defm NEG : SIMDTwoScalarD< 1, 0b01011, "neg",
4103 UnOpFrag<(sub immAllZerosV, node:$LHS)> >;
4104 defm SCVTF : SIMDFPTwoScalarCVT< 0, 0, 0b11101, "scvtf", AArch64sitof>;
4105 defm SQABS : SIMDTwoScalarBHSD< 0, 0b00111, "sqabs", int_aarch64_neon_sqabs>;
4106 defm SQNEG : SIMDTwoScalarBHSD< 1, 0b00111, "sqneg", int_aarch64_neon_sqneg>;
4107 defm SQXTN : SIMDTwoScalarMixedBHS< 0, 0b10100, "sqxtn", int_aarch64_neon_scalar_sqxtn>;
4108 defm SQXTUN : SIMDTwoScalarMixedBHS< 1, 0b10010, "sqxtun", int_aarch64_neon_scalar_sqxtun>;
4109 defm SUQADD : SIMDTwoScalarBHSDTied< 0, 0b00011, "suqadd",
4110 int_aarch64_neon_suqadd>;
4111 defm UCVTF : SIMDFPTwoScalarCVT< 1, 0, 0b11101, "ucvtf", AArch64uitof>;
4112 defm UQXTN : SIMDTwoScalarMixedBHS<1, 0b10100, "uqxtn", int_aarch64_neon_scalar_uqxtn>;
4113 defm USQADD : SIMDTwoScalarBHSDTied< 1, 0b00011, "usqadd",
4114 int_aarch64_neon_usqadd>;
4116 def : Pat<(AArch64neg (v1i64 V64:$Rn)), (NEGv1i64 V64:$Rn)>;
4118 def : Pat<(v1i64 (int_aarch64_neon_fcvtas (v1f64 FPR64:$Rn))),
4119 (FCVTASv1i64 FPR64:$Rn)>;
4120 def : Pat<(v1i64 (int_aarch64_neon_fcvtau (v1f64 FPR64:$Rn))),
4121 (FCVTAUv1i64 FPR64:$Rn)>;
4122 def : Pat<(v1i64 (int_aarch64_neon_fcvtms (v1f64 FPR64:$Rn))),
4123 (FCVTMSv1i64 FPR64:$Rn)>;
4124 def : Pat<(v1i64 (int_aarch64_neon_fcvtmu (v1f64 FPR64:$Rn))),
4125 (FCVTMUv1i64 FPR64:$Rn)>;
4126 def : Pat<(v1i64 (int_aarch64_neon_fcvtns (v1f64 FPR64:$Rn))),
4127 (FCVTNSv1i64 FPR64:$Rn)>;
4128 def : Pat<(v1i64 (int_aarch64_neon_fcvtnu (v1f64 FPR64:$Rn))),
4129 (FCVTNUv1i64 FPR64:$Rn)>;
4130 def : Pat<(v1i64 (int_aarch64_neon_fcvtps (v1f64 FPR64:$Rn))),
4131 (FCVTPSv1i64 FPR64:$Rn)>;
4132 def : Pat<(v1i64 (int_aarch64_neon_fcvtpu (v1f64 FPR64:$Rn))),
4133 (FCVTPUv1i64 FPR64:$Rn)>;
4135 def : Pat<(f16 (int_aarch64_neon_frecpe (f16 FPR16:$Rn))),
4136 (FRECPEv1f16 FPR16:$Rn)>;
4137 def : Pat<(f32 (int_aarch64_neon_frecpe (f32 FPR32:$Rn))),
4138 (FRECPEv1i32 FPR32:$Rn)>;
4139 def : Pat<(f64 (int_aarch64_neon_frecpe (f64 FPR64:$Rn))),
4140 (FRECPEv1i64 FPR64:$Rn)>;
4141 def : Pat<(v1f64 (int_aarch64_neon_frecpe (v1f64 FPR64:$Rn))),
4142 (FRECPEv1i64 FPR64:$Rn)>;
4144 def : Pat<(f32 (AArch64frecpe (f32 FPR32:$Rn))),
4145 (FRECPEv1i32 FPR32:$Rn)>;
4146 def : Pat<(v2f32 (AArch64frecpe (v2f32 V64:$Rn))),
4147 (FRECPEv2f32 V64:$Rn)>;
4148 def : Pat<(v4f32 (AArch64frecpe (v4f32 FPR128:$Rn))),
4149 (FRECPEv4f32 FPR128:$Rn)>;
4150 def : Pat<(f64 (AArch64frecpe (f64 FPR64:$Rn))),
4151 (FRECPEv1i64 FPR64:$Rn)>;
4152 def : Pat<(v1f64 (AArch64frecpe (v1f64 FPR64:$Rn))),
4153 (FRECPEv1i64 FPR64:$Rn)>;
4154 def : Pat<(v2f64 (AArch64frecpe (v2f64 FPR128:$Rn))),
4155 (FRECPEv2f64 FPR128:$Rn)>;
4157 def : Pat<(f32 (AArch64frecps (f32 FPR32:$Rn), (f32 FPR32:$Rm))),
4158 (FRECPS32 FPR32:$Rn, FPR32:$Rm)>;
4159 def : Pat<(v2f32 (AArch64frecps (v2f32 V64:$Rn), (v2f32 V64:$Rm))),
4160 (FRECPSv2f32 V64:$Rn, V64:$Rm)>;
4161 def : Pat<(v4f32 (AArch64frecps (v4f32 FPR128:$Rn), (v4f32 FPR128:$Rm))),
4162 (FRECPSv4f32 FPR128:$Rn, FPR128:$Rm)>;
4163 def : Pat<(f64 (AArch64frecps (f64 FPR64:$Rn), (f64 FPR64:$Rm))),
4164 (FRECPS64 FPR64:$Rn, FPR64:$Rm)>;
4165 def : Pat<(v2f64 (AArch64frecps (v2f64 FPR128:$Rn), (v2f64 FPR128:$Rm))),
4166 (FRECPSv2f64 FPR128:$Rn, FPR128:$Rm)>;
4168 def : Pat<(f16 (int_aarch64_neon_frecpx (f16 FPR16:$Rn))),
4169 (FRECPXv1f16 FPR16:$Rn)>;
4170 def : Pat<(f32 (int_aarch64_neon_frecpx (f32 FPR32:$Rn))),
4171 (FRECPXv1i32 FPR32:$Rn)>;
4172 def : Pat<(f64 (int_aarch64_neon_frecpx (f64 FPR64:$Rn))),
4173 (FRECPXv1i64 FPR64:$Rn)>;
4175 def : Pat<(f16 (int_aarch64_neon_frsqrte (f16 FPR16:$Rn))),
4176 (FRSQRTEv1f16 FPR16:$Rn)>;
4177 def : Pat<(f32 (int_aarch64_neon_frsqrte (f32 FPR32:$Rn))),
4178 (FRSQRTEv1i32 FPR32:$Rn)>;
4179 def : Pat<(f64 (int_aarch64_neon_frsqrte (f64 FPR64:$Rn))),
4180 (FRSQRTEv1i64 FPR64:$Rn)>;
4181 def : Pat<(v1f64 (int_aarch64_neon_frsqrte (v1f64 FPR64:$Rn))),
4182 (FRSQRTEv1i64 FPR64:$Rn)>;
4184 def : Pat<(f32 (AArch64frsqrte (f32 FPR32:$Rn))),
4185 (FRSQRTEv1i32 FPR32:$Rn)>;
4186 def : Pat<(v2f32 (AArch64frsqrte (v2f32 V64:$Rn))),
4187 (FRSQRTEv2f32 V64:$Rn)>;
4188 def : Pat<(v4f32 (AArch64frsqrte (v4f32 FPR128:$Rn))),
4189 (FRSQRTEv4f32 FPR128:$Rn)>;
4190 def : Pat<(f64 (AArch64frsqrte (f64 FPR64:$Rn))),
4191 (FRSQRTEv1i64 FPR64:$Rn)>;
4192 def : Pat<(v1f64 (AArch64frsqrte (v1f64 FPR64:$Rn))),
4193 (FRSQRTEv1i64 FPR64:$Rn)>;
4194 def : Pat<(v2f64 (AArch64frsqrte (v2f64 FPR128:$Rn))),
4195 (FRSQRTEv2f64 FPR128:$Rn)>;
4197 def : Pat<(f32 (AArch64frsqrts (f32 FPR32:$Rn), (f32 FPR32:$Rm))),
4198 (FRSQRTS32 FPR32:$Rn, FPR32:$Rm)>;
4199 def : Pat<(v2f32 (AArch64frsqrts (v2f32 V64:$Rn), (v2f32 V64:$Rm))),
4200 (FRSQRTSv2f32 V64:$Rn, V64:$Rm)>;
4201 def : Pat<(v4f32 (AArch64frsqrts (v4f32 FPR128:$Rn), (v4f32 FPR128:$Rm))),
4202 (FRSQRTSv4f32 FPR128:$Rn, FPR128:$Rm)>;
4203 def : Pat<(f64 (AArch64frsqrts (f64 FPR64:$Rn), (f64 FPR64:$Rm))),
4204 (FRSQRTS64 FPR64:$Rn, FPR64:$Rm)>;
4205 def : Pat<(v2f64 (AArch64frsqrts (v2f64 FPR128:$Rn), (v2f64 FPR128:$Rm))),
4206 (FRSQRTSv2f64 FPR128:$Rn, FPR128:$Rm)>;
4208 // If an integer is about to be converted to a floating point value,
4209 // just load it on the floating point unit.
4210 // Here are the patterns for 8 and 16-bits to float.
4212 multiclass UIntToFPROLoadPat<ValueType DstTy, ValueType SrcTy,
4213 SDPatternOperator loadop, Instruction UCVTF,
4214 ROAddrMode ro, Instruction LDRW, Instruction LDRX,
4216 def : Pat<(DstTy (uint_to_fp (SrcTy
4217 (loadop (ro.Wpat GPR64sp:$Rn, GPR32:$Rm,
4218 ro.Wext:$extend))))),
4219 (UCVTF (INSERT_SUBREG (DstTy (IMPLICIT_DEF)),
4220 (LDRW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend),
4223 def : Pat<(DstTy (uint_to_fp (SrcTy
4224 (loadop (ro.Xpat GPR64sp:$Rn, GPR64:$Rm,
4225 ro.Wext:$extend))))),
4226 (UCVTF (INSERT_SUBREG (DstTy (IMPLICIT_DEF)),
4227 (LDRX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend),
4231 defm : UIntToFPROLoadPat<f32, i32, zextloadi8,
4232 UCVTFv1i32, ro8, LDRBroW, LDRBroX, bsub>;
4233 def : Pat <(f32 (uint_to_fp (i32
4234 (zextloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))))),
4235 (UCVTFv1i32 (INSERT_SUBREG (f32 (IMPLICIT_DEF)),
4236 (LDRBui GPR64sp:$Rn, uimm12s1:$offset), bsub))>;
4237 def : Pat <(f32 (uint_to_fp (i32
4238 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))))),
4239 (UCVTFv1i32 (INSERT_SUBREG (f32 (IMPLICIT_DEF)),
4240 (LDURBi GPR64sp:$Rn, simm9:$offset), bsub))>;
4241 // 16-bits -> float.
4242 defm : UIntToFPROLoadPat<f32, i32, zextloadi16,
4243 UCVTFv1i32, ro16, LDRHroW, LDRHroX, hsub>;
4244 def : Pat <(f32 (uint_to_fp (i32
4245 (zextloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))))),
4246 (UCVTFv1i32 (INSERT_SUBREG (f32 (IMPLICIT_DEF)),
4247 (LDRHui GPR64sp:$Rn, uimm12s2:$offset), hsub))>;
4248 def : Pat <(f32 (uint_to_fp (i32
4249 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))))),
4250 (UCVTFv1i32 (INSERT_SUBREG (f32 (IMPLICIT_DEF)),
4251 (LDURHi GPR64sp:$Rn, simm9:$offset), hsub))>;
4252 // 32-bits are handled in target specific dag combine:
4253 // performIntToFpCombine.
4254 // 64-bits integer to 32-bits floating point, not possible with
4255 // UCVTF on floating point registers (both source and destination
4256 // must have the same size).
4258 // Here are the patterns for 8, 16, 32, and 64-bits to double.
4259 // 8-bits -> double.
4260 defm : UIntToFPROLoadPat<f64, i32, zextloadi8,
4261 UCVTFv1i64, ro8, LDRBroW, LDRBroX, bsub>;
4262 def : Pat <(f64 (uint_to_fp (i32
4263 (zextloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))))),
4264 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4265 (LDRBui GPR64sp:$Rn, uimm12s1:$offset), bsub))>;
4266 def : Pat <(f64 (uint_to_fp (i32
4267 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))))),
4268 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4269 (LDURBi GPR64sp:$Rn, simm9:$offset), bsub))>;
4270 // 16-bits -> double.
4271 defm : UIntToFPROLoadPat<f64, i32, zextloadi16,
4272 UCVTFv1i64, ro16, LDRHroW, LDRHroX, hsub>;
4273 def : Pat <(f64 (uint_to_fp (i32
4274 (zextloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))))),
4275 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4276 (LDRHui GPR64sp:$Rn, uimm12s2:$offset), hsub))>;
4277 def : Pat <(f64 (uint_to_fp (i32
4278 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))))),
4279 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4280 (LDURHi GPR64sp:$Rn, simm9:$offset), hsub))>;
4281 // 32-bits -> double.
4282 defm : UIntToFPROLoadPat<f64, i32, load,
4283 UCVTFv1i64, ro32, LDRSroW, LDRSroX, ssub>;
4284 def : Pat <(f64 (uint_to_fp (i32
4285 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))))),
4286 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4287 (LDRSui GPR64sp:$Rn, uimm12s4:$offset), ssub))>;
4288 def : Pat <(f64 (uint_to_fp (i32
4289 (load (am_unscaled32 GPR64sp:$Rn, simm9:$offset))))),
4290 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4291 (LDURSi GPR64sp:$Rn, simm9:$offset), ssub))>;
4292 // 64-bits -> double are handled in target specific dag combine:
4293 // performIntToFpCombine.
4295 //===----------------------------------------------------------------------===//
4296 // Advanced SIMD three different-sized vector instructions.
4297 //===----------------------------------------------------------------------===//
4299 defm ADDHN : SIMDNarrowThreeVectorBHS<0,0b0100,"addhn", int_aarch64_neon_addhn>;
4300 defm SUBHN : SIMDNarrowThreeVectorBHS<0,0b0110,"subhn", int_aarch64_neon_subhn>;
4301 defm RADDHN : SIMDNarrowThreeVectorBHS<1,0b0100,"raddhn",int_aarch64_neon_raddhn>;
4302 defm RSUBHN : SIMDNarrowThreeVectorBHS<1,0b0110,"rsubhn",int_aarch64_neon_rsubhn>;
4303 defm PMULL : SIMDDifferentThreeVectorBD<0,0b1110,"pmull",int_aarch64_neon_pmull>;
4304 defm SABAL : SIMDLongThreeVectorTiedBHSabal<0,0b0101,"sabal",
4305 int_aarch64_neon_sabd>;
4306 defm SABDL : SIMDLongThreeVectorBHSabdl<0, 0b0111, "sabdl",
4307 int_aarch64_neon_sabd>;
4308 defm SADDL : SIMDLongThreeVectorBHS< 0, 0b0000, "saddl",
4309 BinOpFrag<(add (sext node:$LHS), (sext node:$RHS))>>;
4310 defm SADDW : SIMDWideThreeVectorBHS< 0, 0b0001, "saddw",
4311 BinOpFrag<(add node:$LHS, (sext node:$RHS))>>;
4312 defm SMLAL : SIMDLongThreeVectorTiedBHS<0, 0b1000, "smlal",
4313 TriOpFrag<(add node:$LHS, (int_aarch64_neon_smull node:$MHS, node:$RHS))>>;
4314 defm SMLSL : SIMDLongThreeVectorTiedBHS<0, 0b1010, "smlsl",
4315 TriOpFrag<(sub node:$LHS, (int_aarch64_neon_smull node:$MHS, node:$RHS))>>;
4316 defm SMULL : SIMDLongThreeVectorBHS<0, 0b1100, "smull", int_aarch64_neon_smull>;
4317 defm SQDMLAL : SIMDLongThreeVectorSQDMLXTiedHS<0, 0b1001, "sqdmlal",
4318 int_aarch64_neon_sqadd>;
4319 defm SQDMLSL : SIMDLongThreeVectorSQDMLXTiedHS<0, 0b1011, "sqdmlsl",
4320 int_aarch64_neon_sqsub>;
4321 defm SQDMULL : SIMDLongThreeVectorHS<0, 0b1101, "sqdmull",
4322 int_aarch64_neon_sqdmull>;
4323 defm SSUBL : SIMDLongThreeVectorBHS<0, 0b0010, "ssubl",
4324 BinOpFrag<(sub (sext node:$LHS), (sext node:$RHS))>>;
4325 defm SSUBW : SIMDWideThreeVectorBHS<0, 0b0011, "ssubw",
4326 BinOpFrag<(sub node:$LHS, (sext node:$RHS))>>;
4327 defm UABAL : SIMDLongThreeVectorTiedBHSabal<1, 0b0101, "uabal",
4328 int_aarch64_neon_uabd>;
4329 defm UADDL : SIMDLongThreeVectorBHS<1, 0b0000, "uaddl",
4330 BinOpFrag<(add (zext node:$LHS), (zext node:$RHS))>>;
4331 defm UADDW : SIMDWideThreeVectorBHS<1, 0b0001, "uaddw",
4332 BinOpFrag<(add node:$LHS, (zext node:$RHS))>>;
4333 defm UMLAL : SIMDLongThreeVectorTiedBHS<1, 0b1000, "umlal",
4334 TriOpFrag<(add node:$LHS, (int_aarch64_neon_umull node:$MHS, node:$RHS))>>;
4335 defm UMLSL : SIMDLongThreeVectorTiedBHS<1, 0b1010, "umlsl",
4336 TriOpFrag<(sub node:$LHS, (int_aarch64_neon_umull node:$MHS, node:$RHS))>>;
4337 defm UMULL : SIMDLongThreeVectorBHS<1, 0b1100, "umull", int_aarch64_neon_umull>;
4338 defm USUBL : SIMDLongThreeVectorBHS<1, 0b0010, "usubl",
4339 BinOpFrag<(sub (zext node:$LHS), (zext node:$RHS))>>;
4340 defm USUBW : SIMDWideThreeVectorBHS< 1, 0b0011, "usubw",
4341 BinOpFrag<(sub node:$LHS, (zext node:$RHS))>>;
4343 // Additional patterns for SMULL and UMULL
4344 multiclass Neon_mul_widen_patterns<SDPatternOperator opnode,
4345 Instruction INST8B, Instruction INST4H, Instruction INST2S> {
4346 def : Pat<(v8i16 (opnode (v8i8 V64:$Rn), (v8i8 V64:$Rm))),
4347 (INST8B V64:$Rn, V64:$Rm)>;
4348 def : Pat<(v4i32 (opnode (v4i16 V64:$Rn), (v4i16 V64:$Rm))),
4349 (INST4H V64:$Rn, V64:$Rm)>;
4350 def : Pat<(v2i64 (opnode (v2i32 V64:$Rn), (v2i32 V64:$Rm))),
4351 (INST2S V64:$Rn, V64:$Rm)>;
4354 defm : Neon_mul_widen_patterns<AArch64smull, SMULLv8i8_v8i16,
4355 SMULLv4i16_v4i32, SMULLv2i32_v2i64>;
4356 defm : Neon_mul_widen_patterns<AArch64umull, UMULLv8i8_v8i16,
4357 UMULLv4i16_v4i32, UMULLv2i32_v2i64>;
4359 // Additional patterns for SMLAL/SMLSL and UMLAL/UMLSL
4360 multiclass Neon_mulacc_widen_patterns<SDPatternOperator opnode,
4361 Instruction INST8B, Instruction INST4H, Instruction INST2S> {
4362 def : Pat<(v8i16 (opnode (v8i16 V128:$Rd), (v8i8 V64:$Rn), (v8i8 V64:$Rm))),
4363 (INST8B V128:$Rd, V64:$Rn, V64:$Rm)>;
4364 def : Pat<(v4i32 (opnode (v4i32 V128:$Rd), (v4i16 V64:$Rn), (v4i16 V64:$Rm))),
4365 (INST4H V128:$Rd, V64:$Rn, V64:$Rm)>;
4366 def : Pat<(v2i64 (opnode (v2i64 V128:$Rd), (v2i32 V64:$Rn), (v2i32 V64:$Rm))),
4367 (INST2S V128:$Rd, V64:$Rn, V64:$Rm)>;
4370 defm : Neon_mulacc_widen_patterns<
4371 TriOpFrag<(add node:$LHS, (AArch64smull node:$MHS, node:$RHS))>,
4372 SMLALv8i8_v8i16, SMLALv4i16_v4i32, SMLALv2i32_v2i64>;
4373 defm : Neon_mulacc_widen_patterns<
4374 TriOpFrag<(add node:$LHS, (AArch64umull node:$MHS, node:$RHS))>,
4375 UMLALv8i8_v8i16, UMLALv4i16_v4i32, UMLALv2i32_v2i64>;
4376 defm : Neon_mulacc_widen_patterns<
4377 TriOpFrag<(sub node:$LHS, (AArch64smull node:$MHS, node:$RHS))>,
4378 SMLSLv8i8_v8i16, SMLSLv4i16_v4i32, SMLSLv2i32_v2i64>;
4379 defm : Neon_mulacc_widen_patterns<
4380 TriOpFrag<(sub node:$LHS, (AArch64umull node:$MHS, node:$RHS))>,
4381 UMLSLv8i8_v8i16, UMLSLv4i16_v4i32, UMLSLv2i32_v2i64>;
4383 // Patterns for 64-bit pmull
4384 def : Pat<(int_aarch64_neon_pmull64 V64:$Rn, V64:$Rm),
4385 (PMULLv1i64 V64:$Rn, V64:$Rm)>;
4386 def : Pat<(int_aarch64_neon_pmull64 (extractelt (v2i64 V128:$Rn), (i64 1)),
4387 (extractelt (v2i64 V128:$Rm), (i64 1))),
4388 (PMULLv2i64 V128:$Rn, V128:$Rm)>;
4390 // CodeGen patterns for addhn and subhn instructions, which can actually be
4391 // written in LLVM IR without too much difficulty.
4394 def : Pat<(v8i8 (trunc (v8i16 (AArch64vlshr (add V128:$Rn, V128:$Rm), (i32 8))))),
4395 (ADDHNv8i16_v8i8 V128:$Rn, V128:$Rm)>;
4396 def : Pat<(v4i16 (trunc (v4i32 (AArch64vlshr (add V128:$Rn, V128:$Rm),
4398 (ADDHNv4i32_v4i16 V128:$Rn, V128:$Rm)>;
4399 def : Pat<(v2i32 (trunc (v2i64 (AArch64vlshr (add V128:$Rn, V128:$Rm),
4401 (ADDHNv2i64_v2i32 V128:$Rn, V128:$Rm)>;
4402 def : Pat<(concat_vectors (v8i8 V64:$Rd),
4403 (trunc (v8i16 (AArch64vlshr (add V128:$Rn, V128:$Rm),
4405 (ADDHNv8i16_v16i8 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4406 V128:$Rn, V128:$Rm)>;
4407 def : Pat<(concat_vectors (v4i16 V64:$Rd),
4408 (trunc (v4i32 (AArch64vlshr (add V128:$Rn, V128:$Rm),
4410 (ADDHNv4i32_v8i16 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4411 V128:$Rn, V128:$Rm)>;
4412 def : Pat<(concat_vectors (v2i32 V64:$Rd),
4413 (trunc (v2i64 (AArch64vlshr (add V128:$Rn, V128:$Rm),
4415 (ADDHNv2i64_v4i32 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4416 V128:$Rn, V128:$Rm)>;
4419 def : Pat<(v8i8 (trunc (v8i16 (AArch64vlshr (sub V128:$Rn, V128:$Rm), (i32 8))))),
4420 (SUBHNv8i16_v8i8 V128:$Rn, V128:$Rm)>;
4421 def : Pat<(v4i16 (trunc (v4i32 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
4423 (SUBHNv4i32_v4i16 V128:$Rn, V128:$Rm)>;
4424 def : Pat<(v2i32 (trunc (v2i64 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
4426 (SUBHNv2i64_v2i32 V128:$Rn, V128:$Rm)>;
4427 def : Pat<(concat_vectors (v8i8 V64:$Rd),
4428 (trunc (v8i16 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
4430 (SUBHNv8i16_v16i8 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4431 V128:$Rn, V128:$Rm)>;
4432 def : Pat<(concat_vectors (v4i16 V64:$Rd),
4433 (trunc (v4i32 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
4435 (SUBHNv4i32_v8i16 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4436 V128:$Rn, V128:$Rm)>;
4437 def : Pat<(concat_vectors (v2i32 V64:$Rd),
4438 (trunc (v2i64 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
4440 (SUBHNv2i64_v4i32 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4441 V128:$Rn, V128:$Rm)>;
4443 //----------------------------------------------------------------------------
4444 // AdvSIMD bitwise extract from vector instruction.
4445 //----------------------------------------------------------------------------
4447 defm EXT : SIMDBitwiseExtract<"ext">;
4449 def AdjustExtImm : SDNodeXForm<imm, [{
4450 return CurDAG->getTargetConstant(8 + N->getZExtValue(), SDLoc(N), MVT::i32);
4452 multiclass ExtPat<ValueType VT64, ValueType VT128, int N> {
4453 def : Pat<(VT64 (AArch64ext V64:$Rn, V64:$Rm, (i32 imm:$imm))),
4454 (EXTv8i8 V64:$Rn, V64:$Rm, imm:$imm)>;
4455 def : Pat<(VT128 (AArch64ext V128:$Rn, V128:$Rm, (i32 imm:$imm))),
4456 (EXTv16i8 V128:$Rn, V128:$Rm, imm:$imm)>;
4457 // We use EXT to handle extract_subvector to copy the upper 64-bits of a
4459 def : Pat<(VT64 (extract_subvector V128:$Rn, (i64 N))),
4460 (EXTRACT_SUBREG (EXTv16i8 V128:$Rn, V128:$Rn, 8), dsub)>;
4461 // A 64-bit EXT of two halves of the same 128-bit register can be done as a
4462 // single 128-bit EXT.
4463 def : Pat<(VT64 (AArch64ext (extract_subvector V128:$Rn, (i64 0)),
4464 (extract_subvector V128:$Rn, (i64 N)),
4466 (EXTRACT_SUBREG (EXTv16i8 V128:$Rn, V128:$Rn, imm:$imm), dsub)>;
4467 // A 64-bit EXT of the high half of a 128-bit register can be done using a
4468 // 128-bit EXT of the whole register with an adjustment to the immediate. The
4469 // top half of the other operand will be unset, but that doesn't matter as it
4470 // will not be used.
4471 def : Pat<(VT64 (AArch64ext (extract_subvector V128:$Rn, (i64 N)),
4474 (EXTRACT_SUBREG (EXTv16i8 V128:$Rn,
4475 (SUBREG_TO_REG (i32 0), V64:$Rm, dsub),
4476 (AdjustExtImm imm:$imm)), dsub)>;
4479 defm : ExtPat<v8i8, v16i8, 8>;
4480 defm : ExtPat<v4i16, v8i16, 4>;
4481 defm : ExtPat<v4f16, v8f16, 4>;
4482 defm : ExtPat<v2i32, v4i32, 2>;
4483 defm : ExtPat<v2f32, v4f32, 2>;
4484 defm : ExtPat<v1i64, v2i64, 1>;
4485 defm : ExtPat<v1f64, v2f64, 1>;
4487 //----------------------------------------------------------------------------
4488 // AdvSIMD zip vector
4489 //----------------------------------------------------------------------------
4491 defm TRN1 : SIMDZipVector<0b010, "trn1", AArch64trn1>;
4492 defm TRN2 : SIMDZipVector<0b110, "trn2", AArch64trn2>;
4493 defm UZP1 : SIMDZipVector<0b001, "uzp1", AArch64uzp1>;
4494 defm UZP2 : SIMDZipVector<0b101, "uzp2", AArch64uzp2>;
4495 defm ZIP1 : SIMDZipVector<0b011, "zip1", AArch64zip1>;
4496 defm ZIP2 : SIMDZipVector<0b111, "zip2", AArch64zip2>;
4498 //----------------------------------------------------------------------------
4499 // AdvSIMD TBL/TBX instructions
4500 //----------------------------------------------------------------------------
4502 defm TBL : SIMDTableLookup< 0, "tbl">;
4503 defm TBX : SIMDTableLookupTied<1, "tbx">;
4505 def : Pat<(v8i8 (int_aarch64_neon_tbl1 (v16i8 VecListOne128:$Rn), (v8i8 V64:$Ri))),
4506 (TBLv8i8One VecListOne128:$Rn, V64:$Ri)>;
4507 def : Pat<(v16i8 (int_aarch64_neon_tbl1 (v16i8 V128:$Ri), (v16i8 V128:$Rn))),
4508 (TBLv16i8One V128:$Ri, V128:$Rn)>;
4510 def : Pat<(v8i8 (int_aarch64_neon_tbx1 (v8i8 V64:$Rd),
4511 (v16i8 VecListOne128:$Rn), (v8i8 V64:$Ri))),
4512 (TBXv8i8One V64:$Rd, VecListOne128:$Rn, V64:$Ri)>;
4513 def : Pat<(v16i8 (int_aarch64_neon_tbx1 (v16i8 V128:$Rd),
4514 (v16i8 V128:$Ri), (v16i8 V128:$Rn))),
4515 (TBXv16i8One V128:$Rd, V128:$Ri, V128:$Rn)>;
4518 //----------------------------------------------------------------------------
4519 // AdvSIMD scalar CPY instruction
4520 //----------------------------------------------------------------------------
4522 defm CPY : SIMDScalarCPY<"cpy">;
4524 //----------------------------------------------------------------------------
4525 // AdvSIMD scalar pairwise instructions
4526 //----------------------------------------------------------------------------
4528 defm ADDP : SIMDPairwiseScalarD<0, 0b11011, "addp">;
4529 defm FADDP : SIMDFPPairwiseScalar<0, 0b01101, "faddp">;
4530 defm FMAXNMP : SIMDFPPairwiseScalar<0, 0b01100, "fmaxnmp">;
4531 defm FMAXP : SIMDFPPairwiseScalar<0, 0b01111, "fmaxp">;
4532 defm FMINNMP : SIMDFPPairwiseScalar<1, 0b01100, "fminnmp">;
4533 defm FMINP : SIMDFPPairwiseScalar<1, 0b01111, "fminp">;
4534 def : Pat<(v2i64 (AArch64saddv V128:$Rn)),
4535 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)), (ADDPv2i64p V128:$Rn), dsub)>;
4536 def : Pat<(v2i64 (AArch64uaddv V128:$Rn)),
4537 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)), (ADDPv2i64p V128:$Rn), dsub)>;
4538 def : Pat<(f32 (int_aarch64_neon_faddv (v2f32 V64:$Rn))),
4539 (FADDPv2i32p V64:$Rn)>;
4540 def : Pat<(f32 (int_aarch64_neon_faddv (v4f32 V128:$Rn))),
4541 (FADDPv2i32p (EXTRACT_SUBREG (FADDPv4f32 V128:$Rn, V128:$Rn), dsub))>;
4542 def : Pat<(f64 (int_aarch64_neon_faddv (v2f64 V128:$Rn))),
4543 (FADDPv2i64p V128:$Rn)>;
4544 def : Pat<(f32 (int_aarch64_neon_fmaxnmv (v2f32 V64:$Rn))),
4545 (FMAXNMPv2i32p V64:$Rn)>;
4546 def : Pat<(f64 (int_aarch64_neon_fmaxnmv (v2f64 V128:$Rn))),
4547 (FMAXNMPv2i64p V128:$Rn)>;
4548 def : Pat<(f32 (int_aarch64_neon_fmaxv (v2f32 V64:$Rn))),
4549 (FMAXPv2i32p V64:$Rn)>;
4550 def : Pat<(f64 (int_aarch64_neon_fmaxv (v2f64 V128:$Rn))),
4551 (FMAXPv2i64p V128:$Rn)>;
4552 def : Pat<(f32 (int_aarch64_neon_fminnmv (v2f32 V64:$Rn))),
4553 (FMINNMPv2i32p V64:$Rn)>;
4554 def : Pat<(f64 (int_aarch64_neon_fminnmv (v2f64 V128:$Rn))),
4555 (FMINNMPv2i64p V128:$Rn)>;
4556 def : Pat<(f32 (int_aarch64_neon_fminv (v2f32 V64:$Rn))),
4557 (FMINPv2i32p V64:$Rn)>;
4558 def : Pat<(f64 (int_aarch64_neon_fminv (v2f64 V128:$Rn))),
4559 (FMINPv2i64p V128:$Rn)>;
4561 //----------------------------------------------------------------------------
4562 // AdvSIMD INS/DUP instructions
4563 //----------------------------------------------------------------------------
4565 def DUPv8i8gpr : SIMDDupFromMain<0, {?,?,?,?,1}, ".8b", v8i8, V64, GPR32>;
4566 def DUPv16i8gpr : SIMDDupFromMain<1, {?,?,?,?,1}, ".16b", v16i8, V128, GPR32>;
4567 def DUPv4i16gpr : SIMDDupFromMain<0, {?,?,?,1,0}, ".4h", v4i16, V64, GPR32>;
4568 def DUPv8i16gpr : SIMDDupFromMain<1, {?,?,?,1,0}, ".8h", v8i16, V128, GPR32>;
4569 def DUPv2i32gpr : SIMDDupFromMain<0, {?,?,1,0,0}, ".2s", v2i32, V64, GPR32>;
4570 def DUPv4i32gpr : SIMDDupFromMain<1, {?,?,1,0,0}, ".4s", v4i32, V128, GPR32>;
4571 def DUPv2i64gpr : SIMDDupFromMain<1, {?,1,0,0,0}, ".2d", v2i64, V128, GPR64>;
4573 def DUPv2i64lane : SIMDDup64FromElement;
4574 def DUPv2i32lane : SIMDDup32FromElement<0, ".2s", v2i32, V64>;
4575 def DUPv4i32lane : SIMDDup32FromElement<1, ".4s", v4i32, V128>;
4576 def DUPv4i16lane : SIMDDup16FromElement<0, ".4h", v4i16, V64>;
4577 def DUPv8i16lane : SIMDDup16FromElement<1, ".8h", v8i16, V128>;
4578 def DUPv8i8lane : SIMDDup8FromElement <0, ".8b", v8i8, V64>;
4579 def DUPv16i8lane : SIMDDup8FromElement <1, ".16b", v16i8, V128>;
4581 // DUP from a 64-bit register to a 64-bit register is just a copy
4582 def : Pat<(v1i64 (AArch64dup (i64 GPR64:$Rn))),
4583 (COPY_TO_REGCLASS GPR64:$Rn, FPR64)>;
4584 def : Pat<(v1f64 (AArch64dup (f64 FPR64:$Rn))),
4585 (COPY_TO_REGCLASS FPR64:$Rn, FPR64)>;
4587 def : Pat<(v2f32 (AArch64dup (f32 FPR32:$Rn))),
4588 (v2f32 (DUPv2i32lane
4589 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR32:$Rn, ssub),
4591 def : Pat<(v4f32 (AArch64dup (f32 FPR32:$Rn))),
4592 (v4f32 (DUPv4i32lane
4593 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR32:$Rn, ssub),
4595 def : Pat<(v2f64 (AArch64dup (f64 FPR64:$Rn))),
4596 (v2f64 (DUPv2i64lane
4597 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR64:$Rn, dsub),
4599 def : Pat<(v4f16 (AArch64dup (f16 FPR16:$Rn))),
4600 (v4f16 (DUPv4i16lane
4601 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)), FPR16:$Rn, hsub),
4603 def : Pat<(v8f16 (AArch64dup (f16 FPR16:$Rn))),
4604 (v8f16 (DUPv8i16lane
4605 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)), FPR16:$Rn, hsub),
4608 def : Pat<(v4f16 (AArch64duplane16 (v8f16 V128:$Rn), VectorIndexH:$imm)),
4609 (DUPv4i16lane V128:$Rn, VectorIndexH:$imm)>;
4610 def : Pat<(v8f16 (AArch64duplane16 (v8f16 V128:$Rn), VectorIndexH:$imm)),
4611 (DUPv8i16lane V128:$Rn, VectorIndexH:$imm)>;
4613 def : Pat<(v2f32 (AArch64duplane32 (v4f32 V128:$Rn), VectorIndexS:$imm)),
4614 (DUPv2i32lane V128:$Rn, VectorIndexS:$imm)>;
4615 def : Pat<(v4f32 (AArch64duplane32 (v4f32 V128:$Rn), VectorIndexS:$imm)),
4616 (DUPv4i32lane V128:$Rn, VectorIndexS:$imm)>;
4617 def : Pat<(v2f64 (AArch64duplane64 (v2f64 V128:$Rn), VectorIndexD:$imm)),
4618 (DUPv2i64lane V128:$Rn, VectorIndexD:$imm)>;
4620 // If there's an (AArch64dup (vector_extract ...) ...), we can use a duplane
4621 // instruction even if the types don't match: we just have to remap the lane
4622 // carefully. N.b. this trick only applies to truncations.
4623 def VecIndex_x2 : SDNodeXForm<imm, [{
4624 return CurDAG->getTargetConstant(2 * N->getZExtValue(), SDLoc(N), MVT::i64);
4626 def VecIndex_x4 : SDNodeXForm<imm, [{
4627 return CurDAG->getTargetConstant(4 * N->getZExtValue(), SDLoc(N), MVT::i64);
4629 def VecIndex_x8 : SDNodeXForm<imm, [{
4630 return CurDAG->getTargetConstant(8 * N->getZExtValue(), SDLoc(N), MVT::i64);
4633 multiclass DUPWithTruncPats<ValueType ResVT, ValueType Src64VT,
4634 ValueType Src128VT, ValueType ScalVT,
4635 Instruction DUP, SDNodeXForm IdxXFORM> {
4636 def : Pat<(ResVT (AArch64dup (ScalVT (vector_extract (Src128VT V128:$Rn),
4638 (DUP V128:$Rn, (IdxXFORM imm:$idx))>;
4640 def : Pat<(ResVT (AArch64dup (ScalVT (vector_extract (Src64VT V64:$Rn),
4642 (DUP (SUBREG_TO_REG (i64 0), V64:$Rn, dsub), (IdxXFORM imm:$idx))>;
4645 defm : DUPWithTruncPats<v8i8, v4i16, v8i16, i32, DUPv8i8lane, VecIndex_x2>;
4646 defm : DUPWithTruncPats<v8i8, v2i32, v4i32, i32, DUPv8i8lane, VecIndex_x4>;
4647 defm : DUPWithTruncPats<v4i16, v2i32, v4i32, i32, DUPv4i16lane, VecIndex_x2>;
4649 defm : DUPWithTruncPats<v16i8, v4i16, v8i16, i32, DUPv16i8lane, VecIndex_x2>;
4650 defm : DUPWithTruncPats<v16i8, v2i32, v4i32, i32, DUPv16i8lane, VecIndex_x4>;
4651 defm : DUPWithTruncPats<v8i16, v2i32, v4i32, i32, DUPv8i16lane, VecIndex_x2>;
4653 multiclass DUPWithTrunci64Pats<ValueType ResVT, Instruction DUP,
4654 SDNodeXForm IdxXFORM> {
4655 def : Pat<(ResVT (AArch64dup (i32 (trunc (extractelt (v2i64 V128:$Rn),
4657 (DUP V128:$Rn, (IdxXFORM imm:$idx))>;
4659 def : Pat<(ResVT (AArch64dup (i32 (trunc (extractelt (v1i64 V64:$Rn),
4661 (DUP (SUBREG_TO_REG (i64 0), V64:$Rn, dsub), (IdxXFORM imm:$idx))>;
4664 defm : DUPWithTrunci64Pats<v8i8, DUPv8i8lane, VecIndex_x8>;
4665 defm : DUPWithTrunci64Pats<v4i16, DUPv4i16lane, VecIndex_x4>;
4666 defm : DUPWithTrunci64Pats<v2i32, DUPv2i32lane, VecIndex_x2>;
4668 defm : DUPWithTrunci64Pats<v16i8, DUPv16i8lane, VecIndex_x8>;
4669 defm : DUPWithTrunci64Pats<v8i16, DUPv8i16lane, VecIndex_x4>;
4670 defm : DUPWithTrunci64Pats<v4i32, DUPv4i32lane, VecIndex_x2>;
4672 // SMOV and UMOV definitions, with some extra patterns for convenience
4676 def : Pat<(sext_inreg (vector_extract (v16i8 V128:$Rn), VectorIndexB:$idx), i8),
4677 (i32 (SMOVvi8to32 V128:$Rn, VectorIndexB:$idx))>;
4678 def : Pat<(sext_inreg (vector_extract (v16i8 V128:$Rn), VectorIndexB:$idx), i8),
4679 (i64 (SMOVvi8to64 V128:$Rn, VectorIndexB:$idx))>;
4680 def : Pat<(sext_inreg (vector_extract (v8i16 V128:$Rn), VectorIndexH:$idx),i16),
4681 (i32 (SMOVvi16to32 V128:$Rn, VectorIndexH:$idx))>;
4682 def : Pat<(sext_inreg (vector_extract (v8i16 V128:$Rn), VectorIndexH:$idx),i16),
4683 (i64 (SMOVvi16to64 V128:$Rn, VectorIndexH:$idx))>;
4684 def : Pat<(sext_inreg (vector_extract (v8i16 V128:$Rn), VectorIndexH:$idx),i16),
4685 (i32 (SMOVvi16to32 V128:$Rn, VectorIndexH:$idx))>;
4686 def : Pat<(sext (i32 (vector_extract (v4i32 V128:$Rn), VectorIndexS:$idx))),
4687 (i64 (SMOVvi32to64 V128:$Rn, VectorIndexS:$idx))>;
4689 def : Pat<(sext_inreg (i64 (anyext (i32 (vector_extract (v16i8 V128:$Rn),
4690 VectorIndexB:$idx)))), i8),
4691 (i64 (SMOVvi8to64 V128:$Rn, VectorIndexB:$idx))>;
4692 def : Pat<(sext_inreg (i64 (anyext (i32 (vector_extract (v8i16 V128:$Rn),
4693 VectorIndexH:$idx)))), i16),
4694 (i64 (SMOVvi16to64 V128:$Rn, VectorIndexH:$idx))>;
4696 // Extracting i8 or i16 elements will have the zero-extend transformed to
4697 // an 'and' mask by type legalization since neither i8 nor i16 are legal types
4698 // for AArch64. Match these patterns here since UMOV already zeroes out the high
4699 // bits of the destination register.
4700 def : Pat<(and (vector_extract (v16i8 V128:$Rn), VectorIndexB:$idx),
4702 (i32 (UMOVvi8 V128:$Rn, VectorIndexB:$idx))>;
4703 def : Pat<(and (vector_extract (v8i16 V128:$Rn), VectorIndexH:$idx),
4705 (i32 (UMOVvi16 V128:$Rn, VectorIndexH:$idx))>;
4709 def : Pat<(v16i8 (scalar_to_vector GPR32:$Rn)),
4710 (SUBREG_TO_REG (i32 0),
4711 (f32 (COPY_TO_REGCLASS GPR32:$Rn, FPR32)), ssub)>;
4712 def : Pat<(v8i8 (scalar_to_vector GPR32:$Rn)),
4713 (SUBREG_TO_REG (i32 0),
4714 (f32 (COPY_TO_REGCLASS GPR32:$Rn, FPR32)), ssub)>;
4716 def : Pat<(v8i16 (scalar_to_vector GPR32:$Rn)),
4717 (SUBREG_TO_REG (i32 0),
4718 (f32 (COPY_TO_REGCLASS GPR32:$Rn, FPR32)), ssub)>;
4719 def : Pat<(v4i16 (scalar_to_vector GPR32:$Rn)),
4720 (SUBREG_TO_REG (i32 0),
4721 (f32 (COPY_TO_REGCLASS GPR32:$Rn, FPR32)), ssub)>;
4723 def : Pat<(v4f16 (scalar_to_vector (f16 FPR16:$Rn))),
4724 (INSERT_SUBREG (v4f16 (IMPLICIT_DEF)), FPR16:$Rn, hsub)>;
4725 def : Pat<(v8f16 (scalar_to_vector (f16 FPR16:$Rn))),
4726 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR16:$Rn, hsub)>;
4728 def : Pat<(v2i32 (scalar_to_vector (i32 FPR32:$Rn))),
4729 (v2i32 (INSERT_SUBREG (v2i32 (IMPLICIT_DEF)),
4730 (i32 FPR32:$Rn), ssub))>;
4731 def : Pat<(v4i32 (scalar_to_vector (i32 FPR32:$Rn))),
4732 (v4i32 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)),
4733 (i32 FPR32:$Rn), ssub))>;
4735 def : Pat<(v2i64 (scalar_to_vector (i64 FPR64:$Rn))),
4736 (v2i64 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)),
4737 (i64 FPR64:$Rn), dsub))>;
4739 def : Pat<(v4f16 (scalar_to_vector (f16 FPR16:$Rn))),
4740 (INSERT_SUBREG (v4f16 (IMPLICIT_DEF)), FPR16:$Rn, hsub)>;
4741 def : Pat<(v8f16 (scalar_to_vector (f16 FPR16:$Rn))),
4742 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR16:$Rn, hsub)>;
4744 def : Pat<(v4f32 (scalar_to_vector (f32 FPR32:$Rn))),
4745 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FPR32:$Rn, ssub)>;
4746 def : Pat<(v2f32 (scalar_to_vector (f32 FPR32:$Rn))),
4747 (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), FPR32:$Rn, ssub)>;
4749 def : Pat<(v2f64 (scalar_to_vector (f64 FPR64:$Rn))),
4750 (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), FPR64:$Rn, dsub)>;
4752 def : Pat<(v4f16 (vector_insert (v4f16 V64:$Rn),
4753 (f16 FPR16:$Rm), (i64 VectorIndexS:$imm))),
4756 (v8f16 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), V64:$Rn, dsub)),
4758 (v8f16 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR16:$Rm, hsub)),
4762 def : Pat<(v8f16 (vector_insert (v8f16 V128:$Rn),
4763 (f16 FPR16:$Rm), (i64 VectorIndexH:$imm))),
4765 V128:$Rn, VectorIndexH:$imm,
4766 (v8f16 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR16:$Rm, hsub)),
4769 def : Pat<(v2f32 (vector_insert (v2f32 V64:$Rn),
4770 (f32 FPR32:$Rm), (i64 VectorIndexS:$imm))),
4773 (v4f32 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), V64:$Rn, dsub)),
4775 (v4f32 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FPR32:$Rm, ssub)),
4778 def : Pat<(v4f32 (vector_insert (v4f32 V128:$Rn),
4779 (f32 FPR32:$Rm), (i64 VectorIndexS:$imm))),
4781 V128:$Rn, VectorIndexS:$imm,
4782 (v4f32 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FPR32:$Rm, ssub)),
4784 def : Pat<(v2f64 (vector_insert (v2f64 V128:$Rn),
4785 (f64 FPR64:$Rm), (i64 VectorIndexD:$imm))),
4787 V128:$Rn, VectorIndexD:$imm,
4788 (v2f64 (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), FPR64:$Rm, dsub)),
4791 // Copy an element at a constant index in one vector into a constant indexed
4792 // element of another.
4793 // FIXME refactor to a shared class/dev parameterized on vector type, vector
4794 // index type and INS extension
4795 def : Pat<(v16i8 (int_aarch64_neon_vcopy_lane
4796 (v16i8 V128:$Vd), VectorIndexB:$idx, (v16i8 V128:$Vs),
4797 VectorIndexB:$idx2)),
4799 V128:$Vd, VectorIndexB:$idx, V128:$Vs, VectorIndexB:$idx2)
4801 def : Pat<(v8i16 (int_aarch64_neon_vcopy_lane
4802 (v8i16 V128:$Vd), VectorIndexH:$idx, (v8i16 V128:$Vs),
4803 VectorIndexH:$idx2)),
4805 V128:$Vd, VectorIndexH:$idx, V128:$Vs, VectorIndexH:$idx2)
4807 def : Pat<(v4i32 (int_aarch64_neon_vcopy_lane
4808 (v4i32 V128:$Vd), VectorIndexS:$idx, (v4i32 V128:$Vs),
4809 VectorIndexS:$idx2)),
4811 V128:$Vd, VectorIndexS:$idx, V128:$Vs, VectorIndexS:$idx2)
4813 def : Pat<(v2i64 (int_aarch64_neon_vcopy_lane
4814 (v2i64 V128:$Vd), VectorIndexD:$idx, (v2i64 V128:$Vs),
4815 VectorIndexD:$idx2)),
4817 V128:$Vd, VectorIndexD:$idx, V128:$Vs, VectorIndexD:$idx2)
4820 multiclass Neon_INS_elt_pattern<ValueType VT128, ValueType VT64,
4821 ValueType VTScal, Instruction INS> {
4822 def : Pat<(VT128 (vector_insert V128:$src,
4823 (VTScal (vector_extract (VT128 V128:$Rn), imm:$Immn)),
4825 (INS V128:$src, imm:$Immd, V128:$Rn, imm:$Immn)>;
4827 def : Pat<(VT128 (vector_insert V128:$src,
4828 (VTScal (vector_extract (VT64 V64:$Rn), imm:$Immn)),
4830 (INS V128:$src, imm:$Immd,
4831 (SUBREG_TO_REG (i64 0), V64:$Rn, dsub), imm:$Immn)>;
4833 def : Pat<(VT64 (vector_insert V64:$src,
4834 (VTScal (vector_extract (VT128 V128:$Rn), imm:$Immn)),
4836 (EXTRACT_SUBREG (INS (SUBREG_TO_REG (i64 0), V64:$src, dsub),
4837 imm:$Immd, V128:$Rn, imm:$Immn),
4840 def : Pat<(VT64 (vector_insert V64:$src,
4841 (VTScal (vector_extract (VT64 V64:$Rn), imm:$Immn)),
4844 (INS (SUBREG_TO_REG (i64 0), V64:$src, dsub), imm:$Immd,
4845 (SUBREG_TO_REG (i64 0), V64:$Rn, dsub), imm:$Immn),
4849 defm : Neon_INS_elt_pattern<v8f16, v4f16, f16, INSvi16lane>;
4850 defm : Neon_INS_elt_pattern<v4f32, v2f32, f32, INSvi32lane>;
4851 defm : Neon_INS_elt_pattern<v2f64, v1f64, f64, INSvi64lane>;
4854 // Floating point vector extractions are codegen'd as either a sequence of
4855 // subregister extractions, or a MOV (aka CPY here, alias for DUP) if
4856 // the lane number is anything other than zero.
4857 def : Pat<(vector_extract (v2f64 V128:$Rn), 0),
4858 (f64 (EXTRACT_SUBREG V128:$Rn, dsub))>;
4859 def : Pat<(vector_extract (v4f32 V128:$Rn), 0),
4860 (f32 (EXTRACT_SUBREG V128:$Rn, ssub))>;
4861 def : Pat<(vector_extract (v8f16 V128:$Rn), 0),
4862 (f16 (EXTRACT_SUBREG V128:$Rn, hsub))>;
4864 def : Pat<(vector_extract (v2f64 V128:$Rn), VectorIndexD:$idx),
4865 (f64 (CPYi64 V128:$Rn, VectorIndexD:$idx))>;
4866 def : Pat<(vector_extract (v4f32 V128:$Rn), VectorIndexS:$idx),
4867 (f32 (CPYi32 V128:$Rn, VectorIndexS:$idx))>;
4868 def : Pat<(vector_extract (v8f16 V128:$Rn), VectorIndexH:$idx),
4869 (f16 (CPYi16 V128:$Rn, VectorIndexH:$idx))>;
4871 // All concat_vectors operations are canonicalised to act on i64 vectors for
4872 // AArch64. In the general case we need an instruction, which had just as well be
4874 class ConcatPat<ValueType DstTy, ValueType SrcTy>
4875 : Pat<(DstTy (concat_vectors (SrcTy V64:$Rd), V64:$Rn)),
4876 (INSvi64lane (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), 1,
4877 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rn, dsub), 0)>;
4879 def : ConcatPat<v2i64, v1i64>;
4880 def : ConcatPat<v2f64, v1f64>;
4881 def : ConcatPat<v4i32, v2i32>;
4882 def : ConcatPat<v4f32, v2f32>;
4883 def : ConcatPat<v8i16, v4i16>;
4884 def : ConcatPat<v8f16, v4f16>;
4885 def : ConcatPat<v16i8, v8i8>;
4887 // If the high lanes are undef, though, we can just ignore them:
4888 class ConcatUndefPat<ValueType DstTy, ValueType SrcTy>
4889 : Pat<(DstTy (concat_vectors (SrcTy V64:$Rn), undef)),
4890 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rn, dsub)>;
4892 def : ConcatUndefPat<v2i64, v1i64>;
4893 def : ConcatUndefPat<v2f64, v1f64>;
4894 def : ConcatUndefPat<v4i32, v2i32>;
4895 def : ConcatUndefPat<v4f32, v2f32>;
4896 def : ConcatUndefPat<v8i16, v4i16>;
4897 def : ConcatUndefPat<v16i8, v8i8>;
4899 //----------------------------------------------------------------------------
4900 // AdvSIMD across lanes instructions
4901 //----------------------------------------------------------------------------
4903 defm ADDV : SIMDAcrossLanesBHS<0, 0b11011, "addv">;
4904 defm SMAXV : SIMDAcrossLanesBHS<0, 0b01010, "smaxv">;
4905 defm SMINV : SIMDAcrossLanesBHS<0, 0b11010, "sminv">;
4906 defm UMAXV : SIMDAcrossLanesBHS<1, 0b01010, "umaxv">;
4907 defm UMINV : SIMDAcrossLanesBHS<1, 0b11010, "uminv">;
4908 defm SADDLV : SIMDAcrossLanesHSD<0, 0b00011, "saddlv">;
4909 defm UADDLV : SIMDAcrossLanesHSD<1, 0b00011, "uaddlv">;
4910 defm FMAXNMV : SIMDFPAcrossLanes<0b01100, 0, "fmaxnmv", int_aarch64_neon_fmaxnmv>;
4911 defm FMAXV : SIMDFPAcrossLanes<0b01111, 0, "fmaxv", int_aarch64_neon_fmaxv>;
4912 defm FMINNMV : SIMDFPAcrossLanes<0b01100, 1, "fminnmv", int_aarch64_neon_fminnmv>;
4913 defm FMINV : SIMDFPAcrossLanes<0b01111, 1, "fminv", int_aarch64_neon_fminv>;
4915 // Patterns for across-vector intrinsics, that have a node equivalent, that
4916 // returns a vector (with only the low lane defined) instead of a scalar.
4917 // In effect, opNode is the same as (scalar_to_vector (IntNode)).
4918 multiclass SIMDAcrossLanesIntrinsic<string baseOpc,
4919 SDPatternOperator opNode> {
4920 // If a lane instruction caught the vector_extract around opNode, we can
4921 // directly match the latter to the instruction.
4922 def : Pat<(v8i8 (opNode V64:$Rn)),
4923 (INSERT_SUBREG (v8i8 (IMPLICIT_DEF)),
4924 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), bsub)>;
4925 def : Pat<(v16i8 (opNode V128:$Rn)),
4926 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4927 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), bsub)>;
4928 def : Pat<(v4i16 (opNode V64:$Rn)),
4929 (INSERT_SUBREG (v4i16 (IMPLICIT_DEF)),
4930 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), hsub)>;
4931 def : Pat<(v8i16 (opNode V128:$Rn)),
4932 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)),
4933 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), hsub)>;
4934 def : Pat<(v4i32 (opNode V128:$Rn)),
4935 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)),
4936 (!cast<Instruction>(!strconcat(baseOpc, "v4i32v")) V128:$Rn), ssub)>;
4939 // If none did, fallback to the explicit patterns, consuming the vector_extract.
4940 def : Pat<(i32 (vector_extract (insert_subvector undef, (v8i8 (opNode V64:$Rn)),
4941 (i32 0)), (i64 0))),
4942 (EXTRACT_SUBREG (INSERT_SUBREG (v8i8 (IMPLICIT_DEF)),
4943 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn),
4945 def : Pat<(i32 (vector_extract (v16i8 (opNode V128:$Rn)), (i64 0))),
4946 (EXTRACT_SUBREG (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4947 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn),
4949 def : Pat<(i32 (vector_extract (insert_subvector undef,
4950 (v4i16 (opNode V64:$Rn)), (i32 0)), (i64 0))),
4951 (EXTRACT_SUBREG (INSERT_SUBREG (v4i16 (IMPLICIT_DEF)),
4952 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn),
4954 def : Pat<(i32 (vector_extract (v8i16 (opNode V128:$Rn)), (i64 0))),
4955 (EXTRACT_SUBREG (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)),
4956 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn),
4958 def : Pat<(i32 (vector_extract (v4i32 (opNode V128:$Rn)), (i64 0))),
4959 (EXTRACT_SUBREG (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)),
4960 (!cast<Instruction>(!strconcat(baseOpc, "v4i32v")) V128:$Rn),
4965 multiclass SIMDAcrossLanesSignedIntrinsic<string baseOpc,
4966 SDPatternOperator opNode>
4967 : SIMDAcrossLanesIntrinsic<baseOpc, opNode> {
4968 // If there is a sign extension after this intrinsic, consume it as smov already
4970 def : Pat<(i32 (sext_inreg (i32 (vector_extract (insert_subvector undef,
4971 (opNode (v8i8 V64:$Rn)), (i32 0)), (i64 0))), i8)),
4973 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4974 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), bsub),
4976 def : Pat<(i32 (sext_inreg (i32 (vector_extract
4977 (opNode (v16i8 V128:$Rn)), (i64 0))), i8)),
4979 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4980 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), bsub),
4982 def : Pat<(i32 (sext_inreg (i32 (vector_extract (insert_subvector undef,
4983 (opNode (v4i16 V64:$Rn)), (i32 0)), (i64 0))), i16)),
4985 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4986 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), hsub),
4988 def : Pat<(i32 (sext_inreg (i32 (vector_extract
4989 (opNode (v8i16 V128:$Rn)), (i64 0))), i16)),
4991 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4992 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), hsub),
4996 multiclass SIMDAcrossLanesUnsignedIntrinsic<string baseOpc,
4997 SDPatternOperator opNode>
4998 : SIMDAcrossLanesIntrinsic<baseOpc, opNode> {
4999 // If there is a masking operation keeping only what has been actually
5000 // generated, consume it.
5001 def : Pat<(i32 (and (i32 (vector_extract (insert_subvector undef,
5002 (opNode (v8i8 V64:$Rn)), (i32 0)), (i64 0))), maski8_or_more)),
5003 (i32 (EXTRACT_SUBREG
5004 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5005 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), bsub),
5007 def : Pat<(i32 (and (i32 (vector_extract (opNode (v16i8 V128:$Rn)), (i64 0))),
5009 (i32 (EXTRACT_SUBREG
5010 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5011 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), bsub),
5013 def : Pat<(i32 (and (i32 (vector_extract (insert_subvector undef,
5014 (opNode (v4i16 V64:$Rn)), (i32 0)), (i64 0))), maski16_or_more)),
5015 (i32 (EXTRACT_SUBREG
5016 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5017 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), hsub),
5019 def : Pat<(i32 (and (i32 (vector_extract (opNode (v8i16 V128:$Rn)), (i64 0))),
5021 (i32 (EXTRACT_SUBREG
5022 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5023 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), hsub),
5027 defm : SIMDAcrossLanesSignedIntrinsic<"ADDV", AArch64saddv>;
5028 // vaddv_[su]32 is special; -> ADDP Vd.2S,Vn.2S,Vm.2S; return Vd.s[0];Vn==Vm
5029 def : Pat<(v2i32 (AArch64saddv (v2i32 V64:$Rn))),
5030 (ADDPv2i32 V64:$Rn, V64:$Rn)>;
5032 defm : SIMDAcrossLanesUnsignedIntrinsic<"ADDV", AArch64uaddv>;
5033 // vaddv_[su]32 is special; -> ADDP Vd.2S,Vn.2S,Vm.2S; return Vd.s[0];Vn==Vm
5034 def : Pat<(v2i32 (AArch64uaddv (v2i32 V64:$Rn))),
5035 (ADDPv2i32 V64:$Rn, V64:$Rn)>;
5037 defm : SIMDAcrossLanesSignedIntrinsic<"SMAXV", AArch64smaxv>;
5038 def : Pat<(v2i32 (AArch64smaxv (v2i32 V64:$Rn))),
5039 (SMAXPv2i32 V64:$Rn, V64:$Rn)>;
5041 defm : SIMDAcrossLanesSignedIntrinsic<"SMINV", AArch64sminv>;
5042 def : Pat<(v2i32 (AArch64sminv (v2i32 V64:$Rn))),
5043 (SMINPv2i32 V64:$Rn, V64:$Rn)>;
5045 defm : SIMDAcrossLanesUnsignedIntrinsic<"UMAXV", AArch64umaxv>;
5046 def : Pat<(v2i32 (AArch64umaxv (v2i32 V64:$Rn))),
5047 (UMAXPv2i32 V64:$Rn, V64:$Rn)>;
5049 defm : SIMDAcrossLanesUnsignedIntrinsic<"UMINV", AArch64uminv>;
5050 def : Pat<(v2i32 (AArch64uminv (v2i32 V64:$Rn))),
5051 (UMINPv2i32 V64:$Rn, V64:$Rn)>;
5053 multiclass SIMDAcrossLanesSignedLongIntrinsic<string baseOpc, Intrinsic intOp> {
5054 def : Pat<(i32 (intOp (v8i8 V64:$Rn))),
5056 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5057 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), hsub),
5059 def : Pat<(i32 (intOp (v16i8 V128:$Rn))),
5061 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5062 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), hsub),
5065 def : Pat<(i32 (intOp (v4i16 V64:$Rn))),
5066 (i32 (EXTRACT_SUBREG
5067 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5068 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), ssub),
5070 def : Pat<(i32 (intOp (v8i16 V128:$Rn))),
5071 (i32 (EXTRACT_SUBREG
5072 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5073 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), ssub),
5076 def : Pat<(i64 (intOp (v4i32 V128:$Rn))),
5077 (i64 (EXTRACT_SUBREG
5078 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5079 (!cast<Instruction>(!strconcat(baseOpc, "v4i32v")) V128:$Rn), dsub),
5083 multiclass SIMDAcrossLanesUnsignedLongIntrinsic<string baseOpc,
5085 def : Pat<(i32 (intOp (v8i8 V64:$Rn))),
5086 (i32 (EXTRACT_SUBREG
5087 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5088 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), hsub),
5090 def : Pat<(i32 (intOp (v16i8 V128:$Rn))),
5091 (i32 (EXTRACT_SUBREG
5092 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5093 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), hsub),
5096 def : Pat<(i32 (intOp (v4i16 V64:$Rn))),
5097 (i32 (EXTRACT_SUBREG
5098 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5099 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), ssub),
5101 def : Pat<(i32 (intOp (v8i16 V128:$Rn))),
5102 (i32 (EXTRACT_SUBREG
5103 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5104 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), ssub),
5107 def : Pat<(i64 (intOp (v4i32 V128:$Rn))),
5108 (i64 (EXTRACT_SUBREG
5109 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5110 (!cast<Instruction>(!strconcat(baseOpc, "v4i32v")) V128:$Rn), dsub),
5114 defm : SIMDAcrossLanesSignedLongIntrinsic<"SADDLV", int_aarch64_neon_saddlv>;
5115 defm : SIMDAcrossLanesUnsignedLongIntrinsic<"UADDLV", int_aarch64_neon_uaddlv>;
5117 // The vaddlv_s32 intrinsic gets mapped to SADDLP.
5118 def : Pat<(i64 (int_aarch64_neon_saddlv (v2i32 V64:$Rn))),
5119 (i64 (EXTRACT_SUBREG
5120 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5121 (SADDLPv2i32_v1i64 V64:$Rn), dsub),
5123 // The vaddlv_u32 intrinsic gets mapped to UADDLP.
5124 def : Pat<(i64 (int_aarch64_neon_uaddlv (v2i32 V64:$Rn))),
5125 (i64 (EXTRACT_SUBREG
5126 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5127 (UADDLPv2i32_v1i64 V64:$Rn), dsub),
5130 //------------------------------------------------------------------------------
5131 // AdvSIMD modified immediate instructions
5132 //------------------------------------------------------------------------------
5135 defm BIC : SIMDModifiedImmVectorShiftTied<1, 0b11, 0b01, "bic", AArch64bici>;
5137 defm ORR : SIMDModifiedImmVectorShiftTied<0, 0b11, 0b01, "orr", AArch64orri>;
5139 def : InstAlias<"bic $Vd.4h, $imm", (BICv4i16 V64:$Vd, imm0_255:$imm, 0)>;
5140 def : InstAlias<"bic $Vd.8h, $imm", (BICv8i16 V128:$Vd, imm0_255:$imm, 0)>;
5141 def : InstAlias<"bic $Vd.2s, $imm", (BICv2i32 V64:$Vd, imm0_255:$imm, 0)>;
5142 def : InstAlias<"bic $Vd.4s, $imm", (BICv4i32 V128:$Vd, imm0_255:$imm, 0)>;
5144 def : InstAlias<"bic.4h $Vd, $imm", (BICv4i16 V64:$Vd, imm0_255:$imm, 0)>;
5145 def : InstAlias<"bic.8h $Vd, $imm", (BICv8i16 V128:$Vd, imm0_255:$imm, 0)>;
5146 def : InstAlias<"bic.2s $Vd, $imm", (BICv2i32 V64:$Vd, imm0_255:$imm, 0)>;
5147 def : InstAlias<"bic.4s $Vd, $imm", (BICv4i32 V128:$Vd, imm0_255:$imm, 0)>;
5149 def : InstAlias<"orr $Vd.4h, $imm", (ORRv4i16 V64:$Vd, imm0_255:$imm, 0)>;
5150 def : InstAlias<"orr $Vd.8h, $imm", (ORRv8i16 V128:$Vd, imm0_255:$imm, 0)>;
5151 def : InstAlias<"orr $Vd.2s, $imm", (ORRv2i32 V64:$Vd, imm0_255:$imm, 0)>;
5152 def : InstAlias<"orr $Vd.4s, $imm", (ORRv4i32 V128:$Vd, imm0_255:$imm, 0)>;
5154 def : InstAlias<"orr.4h $Vd, $imm", (ORRv4i16 V64:$Vd, imm0_255:$imm, 0)>;
5155 def : InstAlias<"orr.8h $Vd, $imm", (ORRv8i16 V128:$Vd, imm0_255:$imm, 0)>;
5156 def : InstAlias<"orr.2s $Vd, $imm", (ORRv2i32 V64:$Vd, imm0_255:$imm, 0)>;
5157 def : InstAlias<"orr.4s $Vd, $imm", (ORRv4i32 V128:$Vd, imm0_255:$imm, 0)>;
5160 def FMOVv2f64_ns : SIMDModifiedImmVectorNoShift<1, 1, 0, 0b1111, V128, fpimm8,
5162 [(set (v2f64 V128:$Rd), (AArch64fmov imm0_255:$imm8))]>;
5163 def FMOVv2f32_ns : SIMDModifiedImmVectorNoShift<0, 0, 0, 0b1111, V64, fpimm8,
5165 [(set (v2f32 V64:$Rd), (AArch64fmov imm0_255:$imm8))]>;
5166 def FMOVv4f32_ns : SIMDModifiedImmVectorNoShift<1, 0, 0, 0b1111, V128, fpimm8,
5168 [(set (v4f32 V128:$Rd), (AArch64fmov imm0_255:$imm8))]>;
5169 let Predicates = [HasNEON, HasFullFP16] in {
5170 def FMOVv4f16_ns : SIMDModifiedImmVectorNoShift<0, 0, 1, 0b1111, V64, fpimm8,
5172 [(set (v4f16 V64:$Rd), (AArch64fmov imm0_255:$imm8))]>;
5173 def FMOVv8f16_ns : SIMDModifiedImmVectorNoShift<1, 0, 1, 0b1111, V128, fpimm8,
5175 [(set (v8f16 V128:$Rd), (AArch64fmov imm0_255:$imm8))]>;
5176 } // Predicates = [HasNEON, HasFullFP16]
5180 // EDIT byte mask: scalar
5181 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
5182 def MOVID : SIMDModifiedImmScalarNoShift<0, 1, 0b1110, "movi",
5183 [(set FPR64:$Rd, simdimmtype10:$imm8)]>;
5184 // The movi_edit node has the immediate value already encoded, so we use
5185 // a plain imm0_255 here.
5186 def : Pat<(f64 (AArch64movi_edit imm0_255:$shift)),
5187 (MOVID imm0_255:$shift)>;
5189 // EDIT byte mask: 2d
5191 // The movi_edit node has the immediate value already encoded, so we use
5192 // a plain imm0_255 in the pattern
5193 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
5194 def MOVIv2d_ns : SIMDModifiedImmVectorNoShift<1, 1, 0, 0b1110, V128,
5197 [(set (v2i64 V128:$Rd), (AArch64movi_edit imm0_255:$imm8))]>;
5199 def : Pat<(v2i64 immAllZerosV), (MOVIv2d_ns (i32 0))>;
5200 def : Pat<(v4i32 immAllZerosV), (MOVIv2d_ns (i32 0))>;
5201 def : Pat<(v8i16 immAllZerosV), (MOVIv2d_ns (i32 0))>;
5202 def : Pat<(v16i8 immAllZerosV), (MOVIv2d_ns (i32 0))>;
5204 def : Pat<(v2i64 immAllOnesV), (MOVIv2d_ns (i32 255))>;
5205 def : Pat<(v4i32 immAllOnesV), (MOVIv2d_ns (i32 255))>;
5206 def : Pat<(v8i16 immAllOnesV), (MOVIv2d_ns (i32 255))>;
5207 def : Pat<(v16i8 immAllOnesV), (MOVIv2d_ns (i32 255))>;
5209 // Set 64-bit vectors to all 0/1 by extracting from a 128-bit register as the
5210 // extract is free and this gives better MachineCSE results.
5211 def : Pat<(v1i64 immAllZerosV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 0)), dsub)>;
5212 def : Pat<(v2i32 immAllZerosV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 0)), dsub)>;
5213 def : Pat<(v4i16 immAllZerosV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 0)), dsub)>;
5214 def : Pat<(v8i8 immAllZerosV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 0)), dsub)>;
5216 def : Pat<(v1i64 immAllOnesV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 255)), dsub)>;
5217 def : Pat<(v2i32 immAllOnesV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 255)), dsub)>;
5218 def : Pat<(v4i16 immAllOnesV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 255)), dsub)>;
5219 def : Pat<(v8i8 immAllOnesV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 255)), dsub)>;
5221 // EDIT per word & halfword: 2s, 4h, 4s, & 8h
5222 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
5223 defm MOVI : SIMDModifiedImmVectorShift<0, 0b10, 0b00, "movi">;
5225 def : InstAlias<"movi $Vd.4h, $imm", (MOVIv4i16 V64:$Vd, imm0_255:$imm, 0), 0>;
5226 def : InstAlias<"movi $Vd.8h, $imm", (MOVIv8i16 V128:$Vd, imm0_255:$imm, 0), 0>;
5227 def : InstAlias<"movi $Vd.2s, $imm", (MOVIv2i32 V64:$Vd, imm0_255:$imm, 0), 0>;
5228 def : InstAlias<"movi $Vd.4s, $imm", (MOVIv4i32 V128:$Vd, imm0_255:$imm, 0), 0>;
5230 def : InstAlias<"movi.4h $Vd, $imm", (MOVIv4i16 V64:$Vd, imm0_255:$imm, 0), 0>;
5231 def : InstAlias<"movi.8h $Vd, $imm", (MOVIv8i16 V128:$Vd, imm0_255:$imm, 0), 0>;
5232 def : InstAlias<"movi.2s $Vd, $imm", (MOVIv2i32 V64:$Vd, imm0_255:$imm, 0), 0>;
5233 def : InstAlias<"movi.4s $Vd, $imm", (MOVIv4i32 V128:$Vd, imm0_255:$imm, 0), 0>;
5235 def : Pat<(v2i32 (AArch64movi_shift imm0_255:$imm8, (i32 imm:$shift))),
5236 (MOVIv2i32 imm0_255:$imm8, imm:$shift)>;
5237 def : Pat<(v4i32 (AArch64movi_shift imm0_255:$imm8, (i32 imm:$shift))),
5238 (MOVIv4i32 imm0_255:$imm8, imm:$shift)>;
5239 def : Pat<(v4i16 (AArch64movi_shift imm0_255:$imm8, (i32 imm:$shift))),
5240 (MOVIv4i16 imm0_255:$imm8, imm:$shift)>;
5241 def : Pat<(v8i16 (AArch64movi_shift imm0_255:$imm8, (i32 imm:$shift))),
5242 (MOVIv8i16 imm0_255:$imm8, imm:$shift)>;
5244 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
5245 // EDIT per word: 2s & 4s with MSL shifter
5246 def MOVIv2s_msl : SIMDModifiedImmMoveMSL<0, 0, {1,1,0,?}, V64, "movi", ".2s",
5247 [(set (v2i32 V64:$Rd),
5248 (AArch64movi_msl imm0_255:$imm8, (i32 imm:$shift)))]>;
5249 def MOVIv4s_msl : SIMDModifiedImmMoveMSL<1, 0, {1,1,0,?}, V128, "movi", ".4s",
5250 [(set (v4i32 V128:$Rd),
5251 (AArch64movi_msl imm0_255:$imm8, (i32 imm:$shift)))]>;
5253 // Per byte: 8b & 16b
5254 def MOVIv8b_ns : SIMDModifiedImmVectorNoShift<0, 0, 0, 0b1110, V64, imm0_255,
5256 [(set (v8i8 V64:$Rd), (AArch64movi imm0_255:$imm8))]>;
5258 def MOVIv16b_ns : SIMDModifiedImmVectorNoShift<1, 0, 0, 0b1110, V128, imm0_255,
5260 [(set (v16i8 V128:$Rd), (AArch64movi imm0_255:$imm8))]>;
5265 // EDIT per word & halfword: 2s, 4h, 4s, & 8h
5266 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
5267 defm MVNI : SIMDModifiedImmVectorShift<1, 0b10, 0b00, "mvni">;
5269 def : InstAlias<"mvni $Vd.4h, $imm", (MVNIv4i16 V64:$Vd, imm0_255:$imm, 0), 0>;
5270 def : InstAlias<"mvni $Vd.8h, $imm", (MVNIv8i16 V128:$Vd, imm0_255:$imm, 0), 0>;
5271 def : InstAlias<"mvni $Vd.2s, $imm", (MVNIv2i32 V64:$Vd, imm0_255:$imm, 0), 0>;
5272 def : InstAlias<"mvni $Vd.4s, $imm", (MVNIv4i32 V128:$Vd, imm0_255:$imm, 0), 0>;
5274 def : InstAlias<"mvni.4h $Vd, $imm", (MVNIv4i16 V64:$Vd, imm0_255:$imm, 0), 0>;
5275 def : InstAlias<"mvni.8h $Vd, $imm", (MVNIv8i16 V128:$Vd, imm0_255:$imm, 0), 0>;
5276 def : InstAlias<"mvni.2s $Vd, $imm", (MVNIv2i32 V64:$Vd, imm0_255:$imm, 0), 0>;
5277 def : InstAlias<"mvni.4s $Vd, $imm", (MVNIv4i32 V128:$Vd, imm0_255:$imm, 0), 0>;
5279 def : Pat<(v2i32 (AArch64mvni_shift imm0_255:$imm8, (i32 imm:$shift))),
5280 (MVNIv2i32 imm0_255:$imm8, imm:$shift)>;
5281 def : Pat<(v4i32 (AArch64mvni_shift imm0_255:$imm8, (i32 imm:$shift))),
5282 (MVNIv4i32 imm0_255:$imm8, imm:$shift)>;
5283 def : Pat<(v4i16 (AArch64mvni_shift imm0_255:$imm8, (i32 imm:$shift))),
5284 (MVNIv4i16 imm0_255:$imm8, imm:$shift)>;
5285 def : Pat<(v8i16 (AArch64mvni_shift imm0_255:$imm8, (i32 imm:$shift))),
5286 (MVNIv8i16 imm0_255:$imm8, imm:$shift)>;
5288 // EDIT per word: 2s & 4s with MSL shifter
5289 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
5290 def MVNIv2s_msl : SIMDModifiedImmMoveMSL<0, 1, {1,1,0,?}, V64, "mvni", ".2s",
5291 [(set (v2i32 V64:$Rd),
5292 (AArch64mvni_msl imm0_255:$imm8, (i32 imm:$shift)))]>;
5293 def MVNIv4s_msl : SIMDModifiedImmMoveMSL<1, 1, {1,1,0,?}, V128, "mvni", ".4s",
5294 [(set (v4i32 V128:$Rd),
5295 (AArch64mvni_msl imm0_255:$imm8, (i32 imm:$shift)))]>;
5298 //----------------------------------------------------------------------------
5299 // AdvSIMD indexed element
5300 //----------------------------------------------------------------------------
5302 let hasSideEffects = 0 in {
5303 defm FMLA : SIMDFPIndexedTied<0, 0b0001, "fmla">;
5304 defm FMLS : SIMDFPIndexedTied<0, 0b0101, "fmls">;
5307 // NOTE: Operands are reordered in the FMLA/FMLS PatFrags because the
5308 // instruction expects the addend first, while the intrinsic expects it last.
5310 // On the other hand, there are quite a few valid combinatorial options due to
5311 // the commutativity of multiplication and the fact that (-x) * y = x * (-y).
5312 defm : SIMDFPIndexedTiedPatterns<"FMLA",
5313 TriOpFrag<(fma node:$RHS, node:$MHS, node:$LHS)>>;
5314 defm : SIMDFPIndexedTiedPatterns<"FMLA",
5315 TriOpFrag<(fma node:$MHS, node:$RHS, node:$LHS)>>;
5317 defm : SIMDFPIndexedTiedPatterns<"FMLS",
5318 TriOpFrag<(fma node:$MHS, (fneg node:$RHS), node:$LHS)> >;
5319 defm : SIMDFPIndexedTiedPatterns<"FMLS",
5320 TriOpFrag<(fma node:$RHS, (fneg node:$MHS), node:$LHS)> >;
5321 defm : SIMDFPIndexedTiedPatterns<"FMLS",
5322 TriOpFrag<(fma (fneg node:$RHS), node:$MHS, node:$LHS)> >;
5323 defm : SIMDFPIndexedTiedPatterns<"FMLS",
5324 TriOpFrag<(fma (fneg node:$MHS), node:$RHS, node:$LHS)> >;
5326 multiclass FMLSIndexedAfterNegPatterns<SDPatternOperator OpNode> {
5327 // 3 variants for the .2s version: DUPLANE from 128-bit, DUPLANE from 64-bit
5329 def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn),
5330 (AArch64duplane32 (v4f32 (fneg V128:$Rm)),
5331 VectorIndexS:$idx))),
5332 (FMLSv2i32_indexed V64:$Rd, V64:$Rn, V128:$Rm, VectorIndexS:$idx)>;
5333 def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn),
5334 (v2f32 (AArch64duplane32
5335 (v4f32 (insert_subvector undef,
5336 (v2f32 (fneg V64:$Rm)),
5338 VectorIndexS:$idx)))),
5339 (FMLSv2i32_indexed V64:$Rd, V64:$Rn,
5340 (SUBREG_TO_REG (i32 0), V64:$Rm, dsub),
5341 VectorIndexS:$idx)>;
5342 def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn),
5343 (AArch64dup (f32 (fneg FPR32Op:$Rm))))),
5344 (FMLSv2i32_indexed V64:$Rd, V64:$Rn,
5345 (SUBREG_TO_REG (i32 0), FPR32Op:$Rm, ssub), (i64 0))>;
5347 // 3 variants for the .4s version: DUPLANE from 128-bit, DUPLANE from 64-bit
5349 def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn),
5350 (AArch64duplane32 (v4f32 (fneg V128:$Rm)),
5351 VectorIndexS:$idx))),
5352 (FMLSv4i32_indexed V128:$Rd, V128:$Rn, V128:$Rm,
5353 VectorIndexS:$idx)>;
5354 def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn),
5355 (v4f32 (AArch64duplane32
5356 (v4f32 (insert_subvector undef,
5357 (v2f32 (fneg V64:$Rm)),
5359 VectorIndexS:$idx)))),
5360 (FMLSv4i32_indexed V128:$Rd, V128:$Rn,
5361 (SUBREG_TO_REG (i32 0), V64:$Rm, dsub),
5362 VectorIndexS:$idx)>;
5363 def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn),
5364 (AArch64dup (f32 (fneg FPR32Op:$Rm))))),
5365 (FMLSv4i32_indexed V128:$Rd, V128:$Rn,
5366 (SUBREG_TO_REG (i32 0), FPR32Op:$Rm, ssub), (i64 0))>;
5368 // 2 variants for the .2d version: DUPLANE from 128-bit, and DUP scalar
5369 // (DUPLANE from 64-bit would be trivial).
5370 def : Pat<(v2f64 (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn),
5371 (AArch64duplane64 (v2f64 (fneg V128:$Rm)),
5372 VectorIndexD:$idx))),
5374 V128:$Rd, V128:$Rn, V128:$Rm, VectorIndexS:$idx)>;
5375 def : Pat<(v2f64 (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn),
5376 (AArch64dup (f64 (fneg FPR64Op:$Rm))))),
5377 (FMLSv2i64_indexed V128:$Rd, V128:$Rn,
5378 (SUBREG_TO_REG (i32 0), FPR64Op:$Rm, dsub), (i64 0))>;
5380 // 2 variants for 32-bit scalar version: extract from .2s or from .4s
5381 def : Pat<(f32 (OpNode (f32 FPR32:$Rd), (f32 FPR32:$Rn),
5382 (vector_extract (v4f32 (fneg V128:$Rm)),
5383 VectorIndexS:$idx))),
5384 (FMLSv1i32_indexed FPR32:$Rd, FPR32:$Rn,
5385 V128:$Rm, VectorIndexS:$idx)>;
5386 def : Pat<(f32 (OpNode (f32 FPR32:$Rd), (f32 FPR32:$Rn),
5387 (vector_extract (v4f32 (insert_subvector undef,
5388 (v2f32 (fneg V64:$Rm)),
5390 VectorIndexS:$idx))),
5391 (FMLSv1i32_indexed FPR32:$Rd, FPR32:$Rn,
5392 (SUBREG_TO_REG (i32 0), V64:$Rm, dsub), VectorIndexS:$idx)>;
5394 // 1 variant for 64-bit scalar version: extract from .1d or from .2d
5395 def : Pat<(f64 (OpNode (f64 FPR64:$Rd), (f64 FPR64:$Rn),
5396 (vector_extract (v2f64 (fneg V128:$Rm)),
5397 VectorIndexS:$idx))),
5398 (FMLSv1i64_indexed FPR64:$Rd, FPR64:$Rn,
5399 V128:$Rm, VectorIndexS:$idx)>;
5402 defm : FMLSIndexedAfterNegPatterns<
5403 TriOpFrag<(fma node:$RHS, node:$MHS, node:$LHS)> >;
5404 defm : FMLSIndexedAfterNegPatterns<
5405 TriOpFrag<(fma node:$MHS, node:$RHS, node:$LHS)> >;
5407 defm FMULX : SIMDFPIndexed<1, 0b1001, "fmulx", int_aarch64_neon_fmulx>;
5408 defm FMUL : SIMDFPIndexed<0, 0b1001, "fmul", fmul>;
5410 def : Pat<(v2f32 (fmul V64:$Rn, (AArch64dup (f32 FPR32:$Rm)))),
5411 (FMULv2i32_indexed V64:$Rn,
5412 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR32:$Rm, ssub),
5414 def : Pat<(v4f32 (fmul V128:$Rn, (AArch64dup (f32 FPR32:$Rm)))),
5415 (FMULv4i32_indexed V128:$Rn,
5416 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR32:$Rm, ssub),
5418 def : Pat<(v2f64 (fmul V128:$Rn, (AArch64dup (f64 FPR64:$Rm)))),
5419 (FMULv2i64_indexed V128:$Rn,
5420 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR64:$Rm, dsub),
5423 defm SQDMULH : SIMDIndexedHS<0, 0b1100, "sqdmulh", int_aarch64_neon_sqdmulh>;
5424 defm SQRDMULH : SIMDIndexedHS<0, 0b1101, "sqrdmulh", int_aarch64_neon_sqrdmulh>;
5425 defm MLA : SIMDVectorIndexedHSTied<1, 0b0000, "mla",
5426 TriOpFrag<(add node:$LHS, (mul node:$MHS, node:$RHS))>>;
5427 defm MLS : SIMDVectorIndexedHSTied<1, 0b0100, "mls",
5428 TriOpFrag<(sub node:$LHS, (mul node:$MHS, node:$RHS))>>;
5429 defm MUL : SIMDVectorIndexedHS<0, 0b1000, "mul", mul>;
5430 defm SMLAL : SIMDVectorIndexedLongSDTied<0, 0b0010, "smlal",
5431 TriOpFrag<(add node:$LHS, (int_aarch64_neon_smull node:$MHS, node:$RHS))>>;
5432 defm SMLSL : SIMDVectorIndexedLongSDTied<0, 0b0110, "smlsl",
5433 TriOpFrag<(sub node:$LHS, (int_aarch64_neon_smull node:$MHS, node:$RHS))>>;
5434 defm SMULL : SIMDVectorIndexedLongSD<0, 0b1010, "smull",
5435 int_aarch64_neon_smull>;
5436 defm SQDMLAL : SIMDIndexedLongSQDMLXSDTied<0, 0b0011, "sqdmlal",
5437 int_aarch64_neon_sqadd>;
5438 defm SQDMLSL : SIMDIndexedLongSQDMLXSDTied<0, 0b0111, "sqdmlsl",
5439 int_aarch64_neon_sqsub>;
5440 defm SQRDMLAH : SIMDIndexedSQRDMLxHSDTied<1, 0b1101, "sqrdmlah",
5441 int_aarch64_neon_sqadd>;
5442 defm SQRDMLSH : SIMDIndexedSQRDMLxHSDTied<1, 0b1111, "sqrdmlsh",
5443 int_aarch64_neon_sqsub>;
5444 defm SQDMULL : SIMDIndexedLongSD<0, 0b1011, "sqdmull", int_aarch64_neon_sqdmull>;
5445 defm UMLAL : SIMDVectorIndexedLongSDTied<1, 0b0010, "umlal",
5446 TriOpFrag<(add node:$LHS, (int_aarch64_neon_umull node:$MHS, node:$RHS))>>;
5447 defm UMLSL : SIMDVectorIndexedLongSDTied<1, 0b0110, "umlsl",
5448 TriOpFrag<(sub node:$LHS, (int_aarch64_neon_umull node:$MHS, node:$RHS))>>;
5449 defm UMULL : SIMDVectorIndexedLongSD<1, 0b1010, "umull",
5450 int_aarch64_neon_umull>;
5452 // A scalar sqdmull with the second operand being a vector lane can be
5453 // handled directly with the indexed instruction encoding.
5454 def : Pat<(int_aarch64_neon_sqdmulls_scalar (i32 FPR32:$Rn),
5455 (vector_extract (v4i32 V128:$Vm),
5456 VectorIndexS:$idx)),
5457 (SQDMULLv1i64_indexed FPR32:$Rn, V128:$Vm, VectorIndexS:$idx)>;
5459 //----------------------------------------------------------------------------
5460 // AdvSIMD scalar shift instructions
5461 //----------------------------------------------------------------------------
5462 defm FCVTZS : SIMDFPScalarRShift<0, 0b11111, "fcvtzs">;
5463 defm FCVTZU : SIMDFPScalarRShift<1, 0b11111, "fcvtzu">;
5464 defm SCVTF : SIMDFPScalarRShift<0, 0b11100, "scvtf">;
5465 defm UCVTF : SIMDFPScalarRShift<1, 0b11100, "ucvtf">;
5466 // Codegen patterns for the above. We don't put these directly on the
5467 // instructions because TableGen's type inference can't handle the truth.
5468 // Having the same base pattern for fp <--> int totally freaks it out.
5469 def : Pat<(int_aarch64_neon_vcvtfp2fxs FPR32:$Rn, vecshiftR32:$imm),
5470 (FCVTZSs FPR32:$Rn, vecshiftR32:$imm)>;
5471 def : Pat<(int_aarch64_neon_vcvtfp2fxu FPR32:$Rn, vecshiftR32:$imm),
5472 (FCVTZUs FPR32:$Rn, vecshiftR32:$imm)>;
5473 def : Pat<(i64 (int_aarch64_neon_vcvtfp2fxs (f64 FPR64:$Rn), vecshiftR64:$imm)),
5474 (FCVTZSd FPR64:$Rn, vecshiftR64:$imm)>;
5475 def : Pat<(i64 (int_aarch64_neon_vcvtfp2fxu (f64 FPR64:$Rn), vecshiftR64:$imm)),
5476 (FCVTZUd FPR64:$Rn, vecshiftR64:$imm)>;
5477 def : Pat<(v1i64 (int_aarch64_neon_vcvtfp2fxs (v1f64 FPR64:$Rn),
5479 (FCVTZSd FPR64:$Rn, vecshiftR64:$imm)>;
5480 def : Pat<(v1i64 (int_aarch64_neon_vcvtfp2fxu (v1f64 FPR64:$Rn),
5482 (FCVTZUd FPR64:$Rn, vecshiftR64:$imm)>;
5483 def : Pat<(int_aarch64_neon_vcvtfxu2fp FPR32:$Rn, vecshiftR32:$imm),
5484 (UCVTFs FPR32:$Rn, vecshiftR32:$imm)>;
5485 def : Pat<(f64 (int_aarch64_neon_vcvtfxu2fp (i64 FPR64:$Rn), vecshiftR64:$imm)),
5486 (UCVTFd FPR64:$Rn, vecshiftR64:$imm)>;
5487 def : Pat<(v1f64 (int_aarch64_neon_vcvtfxs2fp (v1i64 FPR64:$Rn),
5489 (SCVTFd FPR64:$Rn, vecshiftR64:$imm)>;
5490 def : Pat<(f64 (int_aarch64_neon_vcvtfxs2fp (i64 FPR64:$Rn), vecshiftR64:$imm)),
5491 (SCVTFd FPR64:$Rn, vecshiftR64:$imm)>;
5492 def : Pat<(v1f64 (int_aarch64_neon_vcvtfxu2fp (v1i64 FPR64:$Rn),
5494 (UCVTFd FPR64:$Rn, vecshiftR64:$imm)>;
5495 def : Pat<(int_aarch64_neon_vcvtfxs2fp FPR32:$Rn, vecshiftR32:$imm),
5496 (SCVTFs FPR32:$Rn, vecshiftR32:$imm)>;
5498 // Patterns for FP16 Instrinsics - requires reg copy to/from as i16s not supported.
5500 def : Pat<(f16 (int_aarch64_neon_vcvtfxs2fp (i32 (sext_inreg FPR32:$Rn, i16)), vecshiftR16:$imm)),
5501 (SCVTFh (EXTRACT_SUBREG FPR32:$Rn, hsub), vecshiftR16:$imm)>;
5502 def : Pat<(f16 (int_aarch64_neon_vcvtfxs2fp (i32 FPR32:$Rn), vecshiftR16:$imm)),
5503 (SCVTFh (EXTRACT_SUBREG FPR32:$Rn, hsub), vecshiftR16:$imm)>;
5504 def : Pat<(f16 (int_aarch64_neon_vcvtfxs2fp (i64 FPR64:$Rn), vecshiftR16:$imm)),
5505 (SCVTFh (EXTRACT_SUBREG FPR64:$Rn, hsub), vecshiftR16:$imm)>;
5506 def : Pat<(f16 (int_aarch64_neon_vcvtfxu2fp
5507 (and FPR32:$Rn, (i32 65535)),
5509 (UCVTFh (EXTRACT_SUBREG FPR32:$Rn, hsub), vecshiftR16:$imm)>;
5510 def : Pat<(f16 (int_aarch64_neon_vcvtfxu2fp FPR32:$Rn, vecshiftR16:$imm)),
5511 (UCVTFh (EXTRACT_SUBREG FPR32:$Rn, hsub), vecshiftR16:$imm)>;
5512 def : Pat<(f16 (int_aarch64_neon_vcvtfxu2fp (i64 FPR64:$Rn), vecshiftR16:$imm)),
5513 (UCVTFh (EXTRACT_SUBREG FPR64:$Rn, hsub), vecshiftR16:$imm)>;
5514 def : Pat<(i32 (int_aarch64_neon_vcvtfp2fxs (f16 FPR16:$Rn), vecshiftR32:$imm)),
5516 (i32 (IMPLICIT_DEF)),
5517 (FCVTZSh FPR16:$Rn, vecshiftR32:$imm),
5519 def : Pat<(i64 (int_aarch64_neon_vcvtfp2fxs (f16 FPR16:$Rn), vecshiftR64:$imm)),
5521 (i64 (IMPLICIT_DEF)),
5522 (FCVTZSh FPR16:$Rn, vecshiftR64:$imm),
5524 def : Pat<(i32 (int_aarch64_neon_vcvtfp2fxu (f16 FPR16:$Rn), vecshiftR32:$imm)),
5526 (i32 (IMPLICIT_DEF)),
5527 (FCVTZUh FPR16:$Rn, vecshiftR32:$imm),
5529 def : Pat<(i64 (int_aarch64_neon_vcvtfp2fxu (f16 FPR16:$Rn), vecshiftR64:$imm)),
5531 (i64 (IMPLICIT_DEF)),
5532 (FCVTZUh FPR16:$Rn, vecshiftR64:$imm),
5534 def : Pat<(i32 (int_aarch64_neon_facge (f16 FPR16:$Rn), (f16 FPR16:$Rm))),
5536 (i32 (IMPLICIT_DEF)),
5537 (FACGE16 FPR16:$Rn, FPR16:$Rm),
5539 def : Pat<(i32 (int_aarch64_neon_facgt (f16 FPR16:$Rn), (f16 FPR16:$Rm))),
5541 (i32 (IMPLICIT_DEF)),
5542 (FACGT16 FPR16:$Rn, FPR16:$Rm),
5545 defm SHL : SIMDScalarLShiftD< 0, 0b01010, "shl", AArch64vshl>;
5546 defm SLI : SIMDScalarLShiftDTied<1, 0b01010, "sli">;
5547 defm SQRSHRN : SIMDScalarRShiftBHS< 0, 0b10011, "sqrshrn",
5548 int_aarch64_neon_sqrshrn>;
5549 defm SQRSHRUN : SIMDScalarRShiftBHS< 1, 0b10001, "sqrshrun",
5550 int_aarch64_neon_sqrshrun>;
5551 defm SQSHLU : SIMDScalarLShiftBHSD<1, 0b01100, "sqshlu", AArch64sqshlui>;
5552 defm SQSHL : SIMDScalarLShiftBHSD<0, 0b01110, "sqshl", AArch64sqshli>;
5553 defm SQSHRN : SIMDScalarRShiftBHS< 0, 0b10010, "sqshrn",
5554 int_aarch64_neon_sqshrn>;
5555 defm SQSHRUN : SIMDScalarRShiftBHS< 1, 0b10000, "sqshrun",
5556 int_aarch64_neon_sqshrun>;
5557 defm SRI : SIMDScalarRShiftDTied< 1, 0b01000, "sri">;
5558 defm SRSHR : SIMDScalarRShiftD< 0, 0b00100, "srshr", AArch64srshri>;
5559 defm SRSRA : SIMDScalarRShiftDTied< 0, 0b00110, "srsra",
5560 TriOpFrag<(add node:$LHS,
5561 (AArch64srshri node:$MHS, node:$RHS))>>;
5562 defm SSHR : SIMDScalarRShiftD< 0, 0b00000, "sshr", AArch64vashr>;
5563 defm SSRA : SIMDScalarRShiftDTied< 0, 0b00010, "ssra",
5564 TriOpFrag<(add node:$LHS,
5565 (AArch64vashr node:$MHS, node:$RHS))>>;
5566 defm UQRSHRN : SIMDScalarRShiftBHS< 1, 0b10011, "uqrshrn",
5567 int_aarch64_neon_uqrshrn>;
5568 defm UQSHL : SIMDScalarLShiftBHSD<1, 0b01110, "uqshl", AArch64uqshli>;
5569 defm UQSHRN : SIMDScalarRShiftBHS< 1, 0b10010, "uqshrn",
5570 int_aarch64_neon_uqshrn>;
5571 defm URSHR : SIMDScalarRShiftD< 1, 0b00100, "urshr", AArch64urshri>;
5572 defm URSRA : SIMDScalarRShiftDTied< 1, 0b00110, "ursra",
5573 TriOpFrag<(add node:$LHS,
5574 (AArch64urshri node:$MHS, node:$RHS))>>;
5575 defm USHR : SIMDScalarRShiftD< 1, 0b00000, "ushr", AArch64vlshr>;
5576 defm USRA : SIMDScalarRShiftDTied< 1, 0b00010, "usra",
5577 TriOpFrag<(add node:$LHS,
5578 (AArch64vlshr node:$MHS, node:$RHS))>>;
5580 //----------------------------------------------------------------------------
5581 // AdvSIMD vector shift instructions
5582 //----------------------------------------------------------------------------
5583 defm FCVTZS:SIMDVectorRShiftSD<0, 0b11111, "fcvtzs", int_aarch64_neon_vcvtfp2fxs>;
5584 defm FCVTZU:SIMDVectorRShiftSD<1, 0b11111, "fcvtzu", int_aarch64_neon_vcvtfp2fxu>;
5585 defm SCVTF: SIMDVectorRShiftToFP<0, 0b11100, "scvtf",
5586 int_aarch64_neon_vcvtfxs2fp>;
5587 defm RSHRN : SIMDVectorRShiftNarrowBHS<0, 0b10001, "rshrn",
5588 int_aarch64_neon_rshrn>;
5589 defm SHL : SIMDVectorLShiftBHSD<0, 0b01010, "shl", AArch64vshl>;
5590 defm SHRN : SIMDVectorRShiftNarrowBHS<0, 0b10000, "shrn",
5591 BinOpFrag<(trunc (AArch64vashr node:$LHS, node:$RHS))>>;
5592 defm SLI : SIMDVectorLShiftBHSDTied<1, 0b01010, "sli", int_aarch64_neon_vsli>;
5593 def : Pat<(v1i64 (int_aarch64_neon_vsli (v1i64 FPR64:$Rd), (v1i64 FPR64:$Rn),
5594 (i32 vecshiftL64:$imm))),
5595 (SLId FPR64:$Rd, FPR64:$Rn, vecshiftL64:$imm)>;
5596 defm SQRSHRN : SIMDVectorRShiftNarrowBHS<0, 0b10011, "sqrshrn",
5597 int_aarch64_neon_sqrshrn>;
5598 defm SQRSHRUN: SIMDVectorRShiftNarrowBHS<1, 0b10001, "sqrshrun",
5599 int_aarch64_neon_sqrshrun>;
5600 defm SQSHLU : SIMDVectorLShiftBHSD<1, 0b01100, "sqshlu", AArch64sqshlui>;
5601 defm SQSHL : SIMDVectorLShiftBHSD<0, 0b01110, "sqshl", AArch64sqshli>;
5602 defm SQSHRN : SIMDVectorRShiftNarrowBHS<0, 0b10010, "sqshrn",
5603 int_aarch64_neon_sqshrn>;
5604 defm SQSHRUN : SIMDVectorRShiftNarrowBHS<1, 0b10000, "sqshrun",
5605 int_aarch64_neon_sqshrun>;
5606 defm SRI : SIMDVectorRShiftBHSDTied<1, 0b01000, "sri", int_aarch64_neon_vsri>;
5607 def : Pat<(v1i64 (int_aarch64_neon_vsri (v1i64 FPR64:$Rd), (v1i64 FPR64:$Rn),
5608 (i32 vecshiftR64:$imm))),
5609 (SRId FPR64:$Rd, FPR64:$Rn, vecshiftR64:$imm)>;
5610 defm SRSHR : SIMDVectorRShiftBHSD<0, 0b00100, "srshr", AArch64srshri>;
5611 defm SRSRA : SIMDVectorRShiftBHSDTied<0, 0b00110, "srsra",
5612 TriOpFrag<(add node:$LHS,
5613 (AArch64srshri node:$MHS, node:$RHS))> >;
5614 defm SSHLL : SIMDVectorLShiftLongBHSD<0, 0b10100, "sshll",
5615 BinOpFrag<(AArch64vshl (sext node:$LHS), node:$RHS)>>;
5617 defm SSHR : SIMDVectorRShiftBHSD<0, 0b00000, "sshr", AArch64vashr>;
5618 defm SSRA : SIMDVectorRShiftBHSDTied<0, 0b00010, "ssra",
5619 TriOpFrag<(add node:$LHS, (AArch64vashr node:$MHS, node:$RHS))>>;
5620 defm UCVTF : SIMDVectorRShiftToFP<1, 0b11100, "ucvtf",
5621 int_aarch64_neon_vcvtfxu2fp>;
5622 defm UQRSHRN : SIMDVectorRShiftNarrowBHS<1, 0b10011, "uqrshrn",
5623 int_aarch64_neon_uqrshrn>;
5624 defm UQSHL : SIMDVectorLShiftBHSD<1, 0b01110, "uqshl", AArch64uqshli>;
5625 defm UQSHRN : SIMDVectorRShiftNarrowBHS<1, 0b10010, "uqshrn",
5626 int_aarch64_neon_uqshrn>;
5627 defm URSHR : SIMDVectorRShiftBHSD<1, 0b00100, "urshr", AArch64urshri>;
5628 defm URSRA : SIMDVectorRShiftBHSDTied<1, 0b00110, "ursra",
5629 TriOpFrag<(add node:$LHS,
5630 (AArch64urshri node:$MHS, node:$RHS))> >;
5631 defm USHLL : SIMDVectorLShiftLongBHSD<1, 0b10100, "ushll",
5632 BinOpFrag<(AArch64vshl (zext node:$LHS), node:$RHS)>>;
5633 defm USHR : SIMDVectorRShiftBHSD<1, 0b00000, "ushr", AArch64vlshr>;
5634 defm USRA : SIMDVectorRShiftBHSDTied<1, 0b00010, "usra",
5635 TriOpFrag<(add node:$LHS, (AArch64vlshr node:$MHS, node:$RHS))> >;
5637 // SHRN patterns for when a logical right shift was used instead of arithmetic
5638 // (the immediate guarantees no sign bits actually end up in the result so it
5640 def : Pat<(v8i8 (trunc (AArch64vlshr (v8i16 V128:$Rn), vecshiftR16Narrow:$imm))),
5641 (SHRNv8i8_shift V128:$Rn, vecshiftR16Narrow:$imm)>;
5642 def : Pat<(v4i16 (trunc (AArch64vlshr (v4i32 V128:$Rn), vecshiftR32Narrow:$imm))),
5643 (SHRNv4i16_shift V128:$Rn, vecshiftR32Narrow:$imm)>;
5644 def : Pat<(v2i32 (trunc (AArch64vlshr (v2i64 V128:$Rn), vecshiftR64Narrow:$imm))),
5645 (SHRNv2i32_shift V128:$Rn, vecshiftR64Narrow:$imm)>;
5647 def : Pat<(v16i8 (concat_vectors (v8i8 V64:$Rd),
5648 (trunc (AArch64vlshr (v8i16 V128:$Rn),
5649 vecshiftR16Narrow:$imm)))),
5650 (SHRNv16i8_shift (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
5651 V128:$Rn, vecshiftR16Narrow:$imm)>;
5652 def : Pat<(v8i16 (concat_vectors (v4i16 V64:$Rd),
5653 (trunc (AArch64vlshr (v4i32 V128:$Rn),
5654 vecshiftR32Narrow:$imm)))),
5655 (SHRNv8i16_shift (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
5656 V128:$Rn, vecshiftR32Narrow:$imm)>;
5657 def : Pat<(v4i32 (concat_vectors (v2i32 V64:$Rd),
5658 (trunc (AArch64vlshr (v2i64 V128:$Rn),
5659 vecshiftR64Narrow:$imm)))),
5660 (SHRNv4i32_shift (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
5661 V128:$Rn, vecshiftR32Narrow:$imm)>;
5663 // Vector sign and zero extensions are implemented with SSHLL and USSHLL.
5664 // Anyexts are implemented as zexts.
5665 def : Pat<(v8i16 (sext (v8i8 V64:$Rn))), (SSHLLv8i8_shift V64:$Rn, (i32 0))>;
5666 def : Pat<(v8i16 (zext (v8i8 V64:$Rn))), (USHLLv8i8_shift V64:$Rn, (i32 0))>;
5667 def : Pat<(v8i16 (anyext (v8i8 V64:$Rn))), (USHLLv8i8_shift V64:$Rn, (i32 0))>;
5668 def : Pat<(v4i32 (sext (v4i16 V64:$Rn))), (SSHLLv4i16_shift V64:$Rn, (i32 0))>;
5669 def : Pat<(v4i32 (zext (v4i16 V64:$Rn))), (USHLLv4i16_shift V64:$Rn, (i32 0))>;
5670 def : Pat<(v4i32 (anyext (v4i16 V64:$Rn))), (USHLLv4i16_shift V64:$Rn, (i32 0))>;
5671 def : Pat<(v2i64 (sext (v2i32 V64:$Rn))), (SSHLLv2i32_shift V64:$Rn, (i32 0))>;
5672 def : Pat<(v2i64 (zext (v2i32 V64:$Rn))), (USHLLv2i32_shift V64:$Rn, (i32 0))>;
5673 def : Pat<(v2i64 (anyext (v2i32 V64:$Rn))), (USHLLv2i32_shift V64:$Rn, (i32 0))>;
5674 // Also match an extend from the upper half of a 128 bit source register.
5675 def : Pat<(v8i16 (anyext (v8i8 (extract_subvector V128:$Rn, (i64 8)) ))),
5676 (USHLLv16i8_shift V128:$Rn, (i32 0))>;
5677 def : Pat<(v8i16 (zext (v8i8 (extract_subvector V128:$Rn, (i64 8)) ))),
5678 (USHLLv16i8_shift V128:$Rn, (i32 0))>;
5679 def : Pat<(v8i16 (sext (v8i8 (extract_subvector V128:$Rn, (i64 8)) ))),
5680 (SSHLLv16i8_shift V128:$Rn, (i32 0))>;
5681 def : Pat<(v4i32 (anyext (v4i16 (extract_subvector V128:$Rn, (i64 4)) ))),
5682 (USHLLv8i16_shift V128:$Rn, (i32 0))>;
5683 def : Pat<(v4i32 (zext (v4i16 (extract_subvector V128:$Rn, (i64 4)) ))),
5684 (USHLLv8i16_shift V128:$Rn, (i32 0))>;
5685 def : Pat<(v4i32 (sext (v4i16 (extract_subvector V128:$Rn, (i64 4)) ))),
5686 (SSHLLv8i16_shift V128:$Rn, (i32 0))>;
5687 def : Pat<(v2i64 (anyext (v2i32 (extract_subvector V128:$Rn, (i64 2)) ))),
5688 (USHLLv4i32_shift V128:$Rn, (i32 0))>;
5689 def : Pat<(v2i64 (zext (v2i32 (extract_subvector V128:$Rn, (i64 2)) ))),
5690 (USHLLv4i32_shift V128:$Rn, (i32 0))>;
5691 def : Pat<(v2i64 (sext (v2i32 (extract_subvector V128:$Rn, (i64 2)) ))),
5692 (SSHLLv4i32_shift V128:$Rn, (i32 0))>;
5694 // Vector shift sxtl aliases
5695 def : InstAlias<"sxtl.8h $dst, $src1",
5696 (SSHLLv8i8_shift V128:$dst, V64:$src1, 0)>;
5697 def : InstAlias<"sxtl $dst.8h, $src1.8b",
5698 (SSHLLv8i8_shift V128:$dst, V64:$src1, 0)>;
5699 def : InstAlias<"sxtl.4s $dst, $src1",
5700 (SSHLLv4i16_shift V128:$dst, V64:$src1, 0)>;
5701 def : InstAlias<"sxtl $dst.4s, $src1.4h",
5702 (SSHLLv4i16_shift V128:$dst, V64:$src1, 0)>;
5703 def : InstAlias<"sxtl.2d $dst, $src1",
5704 (SSHLLv2i32_shift V128:$dst, V64:$src1, 0)>;
5705 def : InstAlias<"sxtl $dst.2d, $src1.2s",
5706 (SSHLLv2i32_shift V128:$dst, V64:$src1, 0)>;
5708 // Vector shift sxtl2 aliases
5709 def : InstAlias<"sxtl2.8h $dst, $src1",
5710 (SSHLLv16i8_shift V128:$dst, V128:$src1, 0)>;
5711 def : InstAlias<"sxtl2 $dst.8h, $src1.16b",
5712 (SSHLLv16i8_shift V128:$dst, V128:$src1, 0)>;
5713 def : InstAlias<"sxtl2.4s $dst, $src1",
5714 (SSHLLv8i16_shift V128:$dst, V128:$src1, 0)>;
5715 def : InstAlias<"sxtl2 $dst.4s, $src1.8h",
5716 (SSHLLv8i16_shift V128:$dst, V128:$src1, 0)>;
5717 def : InstAlias<"sxtl2.2d $dst, $src1",
5718 (SSHLLv4i32_shift V128:$dst, V128:$src1, 0)>;
5719 def : InstAlias<"sxtl2 $dst.2d, $src1.4s",
5720 (SSHLLv4i32_shift V128:$dst, V128:$src1, 0)>;
5722 // Vector shift uxtl aliases
5723 def : InstAlias<"uxtl.8h $dst, $src1",
5724 (USHLLv8i8_shift V128:$dst, V64:$src1, 0)>;
5725 def : InstAlias<"uxtl $dst.8h, $src1.8b",
5726 (USHLLv8i8_shift V128:$dst, V64:$src1, 0)>;
5727 def : InstAlias<"uxtl.4s $dst, $src1",
5728 (USHLLv4i16_shift V128:$dst, V64:$src1, 0)>;
5729 def : InstAlias<"uxtl $dst.4s, $src1.4h",
5730 (USHLLv4i16_shift V128:$dst, V64:$src1, 0)>;
5731 def : InstAlias<"uxtl.2d $dst, $src1",
5732 (USHLLv2i32_shift V128:$dst, V64:$src1, 0)>;
5733 def : InstAlias<"uxtl $dst.2d, $src1.2s",
5734 (USHLLv2i32_shift V128:$dst, V64:$src1, 0)>;
5736 // Vector shift uxtl2 aliases
5737 def : InstAlias<"uxtl2.8h $dst, $src1",
5738 (USHLLv16i8_shift V128:$dst, V128:$src1, 0)>;
5739 def : InstAlias<"uxtl2 $dst.8h, $src1.16b",
5740 (USHLLv16i8_shift V128:$dst, V128:$src1, 0)>;
5741 def : InstAlias<"uxtl2.4s $dst, $src1",
5742 (USHLLv8i16_shift V128:$dst, V128:$src1, 0)>;
5743 def : InstAlias<"uxtl2 $dst.4s, $src1.8h",
5744 (USHLLv8i16_shift V128:$dst, V128:$src1, 0)>;
5745 def : InstAlias<"uxtl2.2d $dst, $src1",
5746 (USHLLv4i32_shift V128:$dst, V128:$src1, 0)>;
5747 def : InstAlias<"uxtl2 $dst.2d, $src1.4s",
5748 (USHLLv4i32_shift V128:$dst, V128:$src1, 0)>;
5750 // If an integer is about to be converted to a floating point value,
5751 // just load it on the floating point unit.
5752 // These patterns are more complex because floating point loads do not
5753 // support sign extension.
5754 // The sign extension has to be explicitly added and is only supported for
5755 // one step: byte-to-half, half-to-word, word-to-doubleword.
5756 // SCVTF GPR -> FPR is 9 cycles.
5757 // SCVTF FPR -> FPR is 4 cyclces.
5758 // (sign extension with lengthen) SXTL FPR -> FPR is 2 cycles.
5759 // Therefore, we can do 2 sign extensions and one SCVTF FPR -> FPR
5760 // and still being faster.
5761 // However, this is not good for code size.
5762 // 8-bits -> float. 2 sizes step-up.
5763 class SExtLoadi8CVTf32Pat<dag addrmode, dag INST>
5764 : Pat<(f32 (sint_to_fp (i32 (sextloadi8 addrmode)))),
5765 (SCVTFv1i32 (f32 (EXTRACT_SUBREG
5770 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
5777 Requires<[NotForCodeSize, UseAlternateSExtLoadCVTF32]>;
5779 def : SExtLoadi8CVTf32Pat<(ro8.Wpat GPR64sp:$Rn, GPR32:$Rm, ro8.Wext:$ext),
5780 (LDRBroW GPR64sp:$Rn, GPR32:$Rm, ro8.Wext:$ext)>;
5781 def : SExtLoadi8CVTf32Pat<(ro8.Xpat GPR64sp:$Rn, GPR64:$Rm, ro8.Xext:$ext),
5782 (LDRBroX GPR64sp:$Rn, GPR64:$Rm, ro8.Xext:$ext)>;
5783 def : SExtLoadi8CVTf32Pat<(am_indexed8 GPR64sp:$Rn, uimm12s1:$offset),
5784 (LDRBui GPR64sp:$Rn, uimm12s1:$offset)>;
5785 def : SExtLoadi8CVTf32Pat<(am_unscaled8 GPR64sp:$Rn, simm9:$offset),
5786 (LDURBi GPR64sp:$Rn, simm9:$offset)>;
5788 // 16-bits -> float. 1 size step-up.
5789 class SExtLoadi16CVTf32Pat<dag addrmode, dag INST>
5790 : Pat<(f32 (sint_to_fp (i32 (sextloadi16 addrmode)))),
5791 (SCVTFv1i32 (f32 (EXTRACT_SUBREG
5793 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
5797 ssub)))>, Requires<[NotForCodeSize]>;
5799 def : SExtLoadi16CVTf32Pat<(ro16.Wpat GPR64sp:$Rn, GPR32:$Rm, ro16.Wext:$ext),
5800 (LDRHroW GPR64sp:$Rn, GPR32:$Rm, ro16.Wext:$ext)>;
5801 def : SExtLoadi16CVTf32Pat<(ro16.Xpat GPR64sp:$Rn, GPR64:$Rm, ro16.Xext:$ext),
5802 (LDRHroX GPR64sp:$Rn, GPR64:$Rm, ro16.Xext:$ext)>;
5803 def : SExtLoadi16CVTf32Pat<(am_indexed16 GPR64sp:$Rn, uimm12s2:$offset),
5804 (LDRHui GPR64sp:$Rn, uimm12s2:$offset)>;
5805 def : SExtLoadi16CVTf32Pat<(am_unscaled16 GPR64sp:$Rn, simm9:$offset),
5806 (LDURHi GPR64sp:$Rn, simm9:$offset)>;
5808 // 32-bits to 32-bits are handled in target specific dag combine:
5809 // performIntToFpCombine.
5810 // 64-bits integer to 32-bits floating point, not possible with
5811 // SCVTF on floating point registers (both source and destination
5812 // must have the same size).
5814 // Here are the patterns for 8, 16, 32, and 64-bits to double.
5815 // 8-bits -> double. 3 size step-up: give up.
5816 // 16-bits -> double. 2 size step.
5817 class SExtLoadi16CVTf64Pat<dag addrmode, dag INST>
5818 : Pat <(f64 (sint_to_fp (i32 (sextloadi16 addrmode)))),
5819 (SCVTFv1i64 (f64 (EXTRACT_SUBREG
5824 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
5831 Requires<[NotForCodeSize, UseAlternateSExtLoadCVTF32]>;
5833 def : SExtLoadi16CVTf64Pat<(ro16.Wpat GPR64sp:$Rn, GPR32:$Rm, ro16.Wext:$ext),
5834 (LDRHroW GPR64sp:$Rn, GPR32:$Rm, ro16.Wext:$ext)>;
5835 def : SExtLoadi16CVTf64Pat<(ro16.Xpat GPR64sp:$Rn, GPR64:$Rm, ro16.Xext:$ext),
5836 (LDRHroX GPR64sp:$Rn, GPR64:$Rm, ro16.Xext:$ext)>;
5837 def : SExtLoadi16CVTf64Pat<(am_indexed16 GPR64sp:$Rn, uimm12s2:$offset),
5838 (LDRHui GPR64sp:$Rn, uimm12s2:$offset)>;
5839 def : SExtLoadi16CVTf64Pat<(am_unscaled16 GPR64sp:$Rn, simm9:$offset),
5840 (LDURHi GPR64sp:$Rn, simm9:$offset)>;
5841 // 32-bits -> double. 1 size step-up.
5842 class SExtLoadi32CVTf64Pat<dag addrmode, dag INST>
5843 : Pat <(f64 (sint_to_fp (i32 (load addrmode)))),
5844 (SCVTFv1i64 (f64 (EXTRACT_SUBREG
5846 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
5850 dsub)))>, Requires<[NotForCodeSize]>;
5852 def : SExtLoadi32CVTf64Pat<(ro32.Wpat GPR64sp:$Rn, GPR32:$Rm, ro32.Wext:$ext),
5853 (LDRSroW GPR64sp:$Rn, GPR32:$Rm, ro32.Wext:$ext)>;
5854 def : SExtLoadi32CVTf64Pat<(ro32.Xpat GPR64sp:$Rn, GPR64:$Rm, ro32.Xext:$ext),
5855 (LDRSroX GPR64sp:$Rn, GPR64:$Rm, ro32.Xext:$ext)>;
5856 def : SExtLoadi32CVTf64Pat<(am_indexed32 GPR64sp:$Rn, uimm12s4:$offset),
5857 (LDRSui GPR64sp:$Rn, uimm12s4:$offset)>;
5858 def : SExtLoadi32CVTf64Pat<(am_unscaled32 GPR64sp:$Rn, simm9:$offset),
5859 (LDURSi GPR64sp:$Rn, simm9:$offset)>;
5861 // 64-bits -> double are handled in target specific dag combine:
5862 // performIntToFpCombine.
5865 //----------------------------------------------------------------------------
5866 // AdvSIMD Load-Store Structure
5867 //----------------------------------------------------------------------------
5868 defm LD1 : SIMDLd1Multiple<"ld1">;
5869 defm LD2 : SIMDLd2Multiple<"ld2">;
5870 defm LD3 : SIMDLd3Multiple<"ld3">;
5871 defm LD4 : SIMDLd4Multiple<"ld4">;
5873 defm ST1 : SIMDSt1Multiple<"st1">;
5874 defm ST2 : SIMDSt2Multiple<"st2">;
5875 defm ST3 : SIMDSt3Multiple<"st3">;
5876 defm ST4 : SIMDSt4Multiple<"st4">;
5878 class Ld1Pat<ValueType ty, Instruction INST>
5879 : Pat<(ty (load GPR64sp:$Rn)), (INST GPR64sp:$Rn)>;
5881 def : Ld1Pat<v16i8, LD1Onev16b>;
5882 def : Ld1Pat<v8i16, LD1Onev8h>;
5883 def : Ld1Pat<v4i32, LD1Onev4s>;
5884 def : Ld1Pat<v2i64, LD1Onev2d>;
5885 def : Ld1Pat<v8i8, LD1Onev8b>;
5886 def : Ld1Pat<v4i16, LD1Onev4h>;
5887 def : Ld1Pat<v2i32, LD1Onev2s>;
5888 def : Ld1Pat<v1i64, LD1Onev1d>;
5890 class St1Pat<ValueType ty, Instruction INST>
5891 : Pat<(store ty:$Vt, GPR64sp:$Rn),
5892 (INST ty:$Vt, GPR64sp:$Rn)>;
5894 def : St1Pat<v16i8, ST1Onev16b>;
5895 def : St1Pat<v8i16, ST1Onev8h>;
5896 def : St1Pat<v4i32, ST1Onev4s>;
5897 def : St1Pat<v2i64, ST1Onev2d>;
5898 def : St1Pat<v8i8, ST1Onev8b>;
5899 def : St1Pat<v4i16, ST1Onev4h>;
5900 def : St1Pat<v2i32, ST1Onev2s>;
5901 def : St1Pat<v1i64, ST1Onev1d>;
5907 defm LD1R : SIMDLdR<0, 0b110, 0, "ld1r", "One", 1, 2, 4, 8>;
5908 defm LD2R : SIMDLdR<1, 0b110, 0, "ld2r", "Two", 2, 4, 8, 16>;
5909 defm LD3R : SIMDLdR<0, 0b111, 0, "ld3r", "Three", 3, 6, 12, 24>;
5910 defm LD4R : SIMDLdR<1, 0b111, 0, "ld4r", "Four", 4, 8, 16, 32>;
5911 let mayLoad = 1, hasSideEffects = 0 in {
5912 defm LD1 : SIMDLdSingleBTied<0, 0b000, "ld1", VecListOneb, GPR64pi1>;
5913 defm LD1 : SIMDLdSingleHTied<0, 0b010, 0, "ld1", VecListOneh, GPR64pi2>;
5914 defm LD1 : SIMDLdSingleSTied<0, 0b100, 0b00, "ld1", VecListOnes, GPR64pi4>;
5915 defm LD1 : SIMDLdSingleDTied<0, 0b100, 0b01, "ld1", VecListOned, GPR64pi8>;
5916 defm LD2 : SIMDLdSingleBTied<1, 0b000, "ld2", VecListTwob, GPR64pi2>;
5917 defm LD2 : SIMDLdSingleHTied<1, 0b010, 0, "ld2", VecListTwoh, GPR64pi4>;
5918 defm LD2 : SIMDLdSingleSTied<1, 0b100, 0b00, "ld2", VecListTwos, GPR64pi8>;
5919 defm LD2 : SIMDLdSingleDTied<1, 0b100, 0b01, "ld2", VecListTwod, GPR64pi16>;
5920 defm LD3 : SIMDLdSingleBTied<0, 0b001, "ld3", VecListThreeb, GPR64pi3>;
5921 defm LD3 : SIMDLdSingleHTied<0, 0b011, 0, "ld3", VecListThreeh, GPR64pi6>;
5922 defm LD3 : SIMDLdSingleSTied<0, 0b101, 0b00, "ld3", VecListThrees, GPR64pi12>;
5923 defm LD3 : SIMDLdSingleDTied<0, 0b101, 0b01, "ld3", VecListThreed, GPR64pi24>;
5924 defm LD4 : SIMDLdSingleBTied<1, 0b001, "ld4", VecListFourb, GPR64pi4>;
5925 defm LD4 : SIMDLdSingleHTied<1, 0b011, 0, "ld4", VecListFourh, GPR64pi8>;
5926 defm LD4 : SIMDLdSingleSTied<1, 0b101, 0b00, "ld4", VecListFours, GPR64pi16>;
5927 defm LD4 : SIMDLdSingleDTied<1, 0b101, 0b01, "ld4", VecListFourd, GPR64pi32>;
5930 def : Pat<(v8i8 (AArch64dup (i32 (extloadi8 GPR64sp:$Rn)))),
5931 (LD1Rv8b GPR64sp:$Rn)>;
5932 def : Pat<(v16i8 (AArch64dup (i32 (extloadi8 GPR64sp:$Rn)))),
5933 (LD1Rv16b GPR64sp:$Rn)>;
5934 def : Pat<(v4i16 (AArch64dup (i32 (extloadi16 GPR64sp:$Rn)))),
5935 (LD1Rv4h GPR64sp:$Rn)>;
5936 def : Pat<(v8i16 (AArch64dup (i32 (extloadi16 GPR64sp:$Rn)))),
5937 (LD1Rv8h GPR64sp:$Rn)>;
5938 def : Pat<(v2i32 (AArch64dup (i32 (load GPR64sp:$Rn)))),
5939 (LD1Rv2s GPR64sp:$Rn)>;
5940 def : Pat<(v4i32 (AArch64dup (i32 (load GPR64sp:$Rn)))),
5941 (LD1Rv4s GPR64sp:$Rn)>;
5942 def : Pat<(v2i64 (AArch64dup (i64 (load GPR64sp:$Rn)))),
5943 (LD1Rv2d GPR64sp:$Rn)>;
5944 def : Pat<(v1i64 (AArch64dup (i64 (load GPR64sp:$Rn)))),
5945 (LD1Rv1d GPR64sp:$Rn)>;
5946 // Grab the floating point version too
5947 def : Pat<(v2f32 (AArch64dup (f32 (load GPR64sp:$Rn)))),
5948 (LD1Rv2s GPR64sp:$Rn)>;
5949 def : Pat<(v4f32 (AArch64dup (f32 (load GPR64sp:$Rn)))),
5950 (LD1Rv4s GPR64sp:$Rn)>;
5951 def : Pat<(v2f64 (AArch64dup (f64 (load GPR64sp:$Rn)))),
5952 (LD1Rv2d GPR64sp:$Rn)>;
5953 def : Pat<(v1f64 (AArch64dup (f64 (load GPR64sp:$Rn)))),
5954 (LD1Rv1d GPR64sp:$Rn)>;
5955 def : Pat<(v4f16 (AArch64dup (f16 (load GPR64sp:$Rn)))),
5956 (LD1Rv4h GPR64sp:$Rn)>;
5957 def : Pat<(v8f16 (AArch64dup (f16 (load GPR64sp:$Rn)))),
5958 (LD1Rv8h GPR64sp:$Rn)>;
5960 class Ld1Lane128Pat<SDPatternOperator scalar_load, Operand VecIndex,
5961 ValueType VTy, ValueType STy, Instruction LD1>
5962 : Pat<(vector_insert (VTy VecListOne128:$Rd),
5963 (STy (scalar_load GPR64sp:$Rn)), VecIndex:$idx),
5964 (LD1 VecListOne128:$Rd, VecIndex:$idx, GPR64sp:$Rn)>;
5966 def : Ld1Lane128Pat<extloadi8, VectorIndexB, v16i8, i32, LD1i8>;
5967 def : Ld1Lane128Pat<extloadi16, VectorIndexH, v8i16, i32, LD1i16>;
5968 def : Ld1Lane128Pat<load, VectorIndexS, v4i32, i32, LD1i32>;
5969 def : Ld1Lane128Pat<load, VectorIndexS, v4f32, f32, LD1i32>;
5970 def : Ld1Lane128Pat<load, VectorIndexD, v2i64, i64, LD1i64>;
5971 def : Ld1Lane128Pat<load, VectorIndexD, v2f64, f64, LD1i64>;
5972 def : Ld1Lane128Pat<load, VectorIndexH, v8f16, f16, LD1i16>;
5974 class Ld1Lane64Pat<SDPatternOperator scalar_load, Operand VecIndex,
5975 ValueType VTy, ValueType STy, Instruction LD1>
5976 : Pat<(vector_insert (VTy VecListOne64:$Rd),
5977 (STy (scalar_load GPR64sp:$Rn)), VecIndex:$idx),
5979 (LD1 (SUBREG_TO_REG (i32 0), VecListOne64:$Rd, dsub),
5980 VecIndex:$idx, GPR64sp:$Rn),
5983 def : Ld1Lane64Pat<extloadi8, VectorIndexB, v8i8, i32, LD1i8>;
5984 def : Ld1Lane64Pat<extloadi16, VectorIndexH, v4i16, i32, LD1i16>;
5985 def : Ld1Lane64Pat<load, VectorIndexS, v2i32, i32, LD1i32>;
5986 def : Ld1Lane64Pat<load, VectorIndexS, v2f32, f32, LD1i32>;
5987 def : Ld1Lane64Pat<load, VectorIndexH, v4f16, f16, LD1i16>;
5990 defm LD1 : SIMDLdSt1SingleAliases<"ld1">;
5991 defm LD2 : SIMDLdSt2SingleAliases<"ld2">;
5992 defm LD3 : SIMDLdSt3SingleAliases<"ld3">;
5993 defm LD4 : SIMDLdSt4SingleAliases<"ld4">;
5996 defm ST1 : SIMDStSingleB<0, 0b000, "st1", VecListOneb, GPR64pi1>;
5997 defm ST1 : SIMDStSingleH<0, 0b010, 0, "st1", VecListOneh, GPR64pi2>;
5998 defm ST1 : SIMDStSingleS<0, 0b100, 0b00, "st1", VecListOnes, GPR64pi4>;
5999 defm ST1 : SIMDStSingleD<0, 0b100, 0b01, "st1", VecListOned, GPR64pi8>;
6001 let AddedComplexity = 19 in
6002 class St1Lane128Pat<SDPatternOperator scalar_store, Operand VecIndex,
6003 ValueType VTy, ValueType STy, Instruction ST1>
6005 (STy (vector_extract (VTy VecListOne128:$Vt), VecIndex:$idx)),
6007 (ST1 VecListOne128:$Vt, VecIndex:$idx, GPR64sp:$Rn)>;
6009 def : St1Lane128Pat<truncstorei8, VectorIndexB, v16i8, i32, ST1i8>;
6010 def : St1Lane128Pat<truncstorei16, VectorIndexH, v8i16, i32, ST1i16>;
6011 def : St1Lane128Pat<store, VectorIndexS, v4i32, i32, ST1i32>;
6012 def : St1Lane128Pat<store, VectorIndexS, v4f32, f32, ST1i32>;
6013 def : St1Lane128Pat<store, VectorIndexD, v2i64, i64, ST1i64>;
6014 def : St1Lane128Pat<store, VectorIndexD, v2f64, f64, ST1i64>;
6015 def : St1Lane128Pat<store, VectorIndexH, v8f16, f16, ST1i16>;
6017 let AddedComplexity = 19 in
6018 class St1Lane64Pat<SDPatternOperator scalar_store, Operand VecIndex,
6019 ValueType VTy, ValueType STy, Instruction ST1>
6021 (STy (vector_extract (VTy VecListOne64:$Vt), VecIndex:$idx)),
6023 (ST1 (SUBREG_TO_REG (i32 0), VecListOne64:$Vt, dsub),
6024 VecIndex:$idx, GPR64sp:$Rn)>;
6026 def : St1Lane64Pat<truncstorei8, VectorIndexB, v8i8, i32, ST1i8>;
6027 def : St1Lane64Pat<truncstorei16, VectorIndexH, v4i16, i32, ST1i16>;
6028 def : St1Lane64Pat<store, VectorIndexS, v2i32, i32, ST1i32>;
6029 def : St1Lane64Pat<store, VectorIndexS, v2f32, f32, ST1i32>;
6030 def : St1Lane64Pat<store, VectorIndexH, v4f16, f16, ST1i16>;
6032 multiclass St1LanePost64Pat<SDPatternOperator scalar_store, Operand VecIndex,
6033 ValueType VTy, ValueType STy, Instruction ST1,
6035 def : Pat<(scalar_store
6036 (STy (vector_extract (VTy VecListOne64:$Vt), VecIndex:$idx)),
6037 GPR64sp:$Rn, offset),
6038 (ST1 (SUBREG_TO_REG (i32 0), VecListOne64:$Vt, dsub),
6039 VecIndex:$idx, GPR64sp:$Rn, XZR)>;
6041 def : Pat<(scalar_store
6042 (STy (vector_extract (VTy VecListOne64:$Vt), VecIndex:$idx)),
6043 GPR64sp:$Rn, GPR64:$Rm),
6044 (ST1 (SUBREG_TO_REG (i32 0), VecListOne64:$Vt, dsub),
6045 VecIndex:$idx, GPR64sp:$Rn, $Rm)>;
6048 defm : St1LanePost64Pat<post_truncsti8, VectorIndexB, v8i8, i32, ST1i8_POST, 1>;
6049 defm : St1LanePost64Pat<post_truncsti16, VectorIndexH, v4i16, i32, ST1i16_POST,
6051 defm : St1LanePost64Pat<post_store, VectorIndexS, v2i32, i32, ST1i32_POST, 4>;
6052 defm : St1LanePost64Pat<post_store, VectorIndexS, v2f32, f32, ST1i32_POST, 4>;
6053 defm : St1LanePost64Pat<post_store, VectorIndexD, v1i64, i64, ST1i64_POST, 8>;
6054 defm : St1LanePost64Pat<post_store, VectorIndexD, v1f64, f64, ST1i64_POST, 8>;
6055 defm : St1LanePost64Pat<post_store, VectorIndexH, v4f16, f16, ST1i16_POST, 2>;
6057 multiclass St1LanePost128Pat<SDPatternOperator scalar_store, Operand VecIndex,
6058 ValueType VTy, ValueType STy, Instruction ST1,
6060 def : Pat<(scalar_store
6061 (STy (vector_extract (VTy VecListOne128:$Vt), VecIndex:$idx)),
6062 GPR64sp:$Rn, offset),
6063 (ST1 VecListOne128:$Vt, VecIndex:$idx, GPR64sp:$Rn, XZR)>;
6065 def : Pat<(scalar_store
6066 (STy (vector_extract (VTy VecListOne128:$Vt), VecIndex:$idx)),
6067 GPR64sp:$Rn, GPR64:$Rm),
6068 (ST1 VecListOne128:$Vt, VecIndex:$idx, GPR64sp:$Rn, $Rm)>;
6071 defm : St1LanePost128Pat<post_truncsti8, VectorIndexB, v16i8, i32, ST1i8_POST,
6073 defm : St1LanePost128Pat<post_truncsti16, VectorIndexH, v8i16, i32, ST1i16_POST,
6075 defm : St1LanePost128Pat<post_store, VectorIndexS, v4i32, i32, ST1i32_POST, 4>;
6076 defm : St1LanePost128Pat<post_store, VectorIndexS, v4f32, f32, ST1i32_POST, 4>;
6077 defm : St1LanePost128Pat<post_store, VectorIndexD, v2i64, i64, ST1i64_POST, 8>;
6078 defm : St1LanePost128Pat<post_store, VectorIndexD, v2f64, f64, ST1i64_POST, 8>;
6079 defm : St1LanePost128Pat<post_store, VectorIndexH, v8f16, f16, ST1i16_POST, 2>;
6081 let mayStore = 1, hasSideEffects = 0 in {
6082 defm ST2 : SIMDStSingleB<1, 0b000, "st2", VecListTwob, GPR64pi2>;
6083 defm ST2 : SIMDStSingleH<1, 0b010, 0, "st2", VecListTwoh, GPR64pi4>;
6084 defm ST2 : SIMDStSingleS<1, 0b100, 0b00, "st2", VecListTwos, GPR64pi8>;
6085 defm ST2 : SIMDStSingleD<1, 0b100, 0b01, "st2", VecListTwod, GPR64pi16>;
6086 defm ST3 : SIMDStSingleB<0, 0b001, "st3", VecListThreeb, GPR64pi3>;
6087 defm ST3 : SIMDStSingleH<0, 0b011, 0, "st3", VecListThreeh, GPR64pi6>;
6088 defm ST3 : SIMDStSingleS<0, 0b101, 0b00, "st3", VecListThrees, GPR64pi12>;
6089 defm ST3 : SIMDStSingleD<0, 0b101, 0b01, "st3", VecListThreed, GPR64pi24>;
6090 defm ST4 : SIMDStSingleB<1, 0b001, "st4", VecListFourb, GPR64pi4>;
6091 defm ST4 : SIMDStSingleH<1, 0b011, 0, "st4", VecListFourh, GPR64pi8>;
6092 defm ST4 : SIMDStSingleS<1, 0b101, 0b00, "st4", VecListFours, GPR64pi16>;
6093 defm ST4 : SIMDStSingleD<1, 0b101, 0b01, "st4", VecListFourd, GPR64pi32>;
6096 defm ST1 : SIMDLdSt1SingleAliases<"st1">;
6097 defm ST2 : SIMDLdSt2SingleAliases<"st2">;
6098 defm ST3 : SIMDLdSt3SingleAliases<"st3">;
6099 defm ST4 : SIMDLdSt4SingleAliases<"st4">;
6101 //----------------------------------------------------------------------------
6102 // Crypto extensions
6103 //----------------------------------------------------------------------------
6105 let Predicates = [HasAES] in {
6106 def AESErr : AESTiedInst<0b0100, "aese", int_aarch64_crypto_aese>;
6107 def AESDrr : AESTiedInst<0b0101, "aesd", int_aarch64_crypto_aesd>;
6108 def AESMCrr : AESInst< 0b0110, "aesmc", int_aarch64_crypto_aesmc>;
6109 def AESIMCrr : AESInst< 0b0111, "aesimc", int_aarch64_crypto_aesimc>;
6112 // Pseudo instructions for AESMCrr/AESIMCrr with a register constraint required
6113 // for AES fusion on some CPUs.
6114 let hasSideEffects = 0, mayStore = 0, mayLoad = 0 in {
6115 def AESMCrrTied: Pseudo<(outs V128:$Rd), (ins V128:$Rn), [], "$Rn = $Rd">,
6117 def AESIMCrrTied: Pseudo<(outs V128:$Rd), (ins V128:$Rn), [], "$Rn = $Rd">,
6121 // Only use constrained versions of AES(I)MC instructions if they are paired with
6123 def : Pat<(v16i8 (int_aarch64_crypto_aesmc
6124 (v16i8 (int_aarch64_crypto_aese (v16i8 V128:$src1),
6125 (v16i8 V128:$src2))))),
6126 (v16i8 (AESMCrrTied (v16i8 (AESErr (v16i8 V128:$src1),
6127 (v16i8 V128:$src2)))))>,
6128 Requires<[HasFuseAES]>;
6130 def : Pat<(v16i8 (int_aarch64_crypto_aesimc
6131 (v16i8 (int_aarch64_crypto_aesd (v16i8 V128:$src1),
6132 (v16i8 V128:$src2))))),
6133 (v16i8 (AESIMCrrTied (v16i8 (AESDrr (v16i8 V128:$src1),
6134 (v16i8 V128:$src2)))))>,
6135 Requires<[HasFuseAES]>;
6137 let Predicates = [HasSHA2] in {
6138 def SHA1Crrr : SHATiedInstQSV<0b000, "sha1c", int_aarch64_crypto_sha1c>;
6139 def SHA1Prrr : SHATiedInstQSV<0b001, "sha1p", int_aarch64_crypto_sha1p>;
6140 def SHA1Mrrr : SHATiedInstQSV<0b010, "sha1m", int_aarch64_crypto_sha1m>;
6141 def SHA1SU0rrr : SHATiedInstVVV<0b011, "sha1su0", int_aarch64_crypto_sha1su0>;
6142 def SHA256Hrrr : SHATiedInstQQV<0b100, "sha256h", int_aarch64_crypto_sha256h>;
6143 def SHA256H2rrr : SHATiedInstQQV<0b101, "sha256h2",int_aarch64_crypto_sha256h2>;
6144 def SHA256SU1rrr :SHATiedInstVVV<0b110, "sha256su1",int_aarch64_crypto_sha256su1>;
6146 def SHA1Hrr : SHAInstSS< 0b0000, "sha1h", int_aarch64_crypto_sha1h>;
6147 def SHA1SU1rr : SHATiedInstVV<0b0001, "sha1su1", int_aarch64_crypto_sha1su1>;
6148 def SHA256SU0rr : SHATiedInstVV<0b0010, "sha256su0",int_aarch64_crypto_sha256su0>;
6151 //----------------------------------------------------------------------------
6153 //----------------------------------------------------------------------------
6154 // FIXME: Like for X86, these should go in their own separate .td file.
6156 def def32 : PatLeaf<(i32 GPR32:$src), [{
6160 // In the case of a 32-bit def that is known to implicitly zero-extend,
6161 // we can use a SUBREG_TO_REG.
6162 def : Pat<(i64 (zext def32:$src)), (SUBREG_TO_REG (i64 0), GPR32:$src, sub_32)>;
6164 // For an anyext, we don't care what the high bits are, so we can perform an
6165 // INSERT_SUBREF into an IMPLICIT_DEF.
6166 def : Pat<(i64 (anyext GPR32:$src)),
6167 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GPR32:$src, sub_32)>;
6169 // When we need to explicitly zero-extend, we use a 32-bit MOV instruction and
6170 // then assert the extension has happened.
6171 def : Pat<(i64 (zext GPR32:$src)),
6172 (SUBREG_TO_REG (i32 0), (ORRWrs WZR, GPR32:$src, 0), sub_32)>;
6174 // To sign extend, we use a signed bitfield move instruction (SBFM) on the
6175 // containing super-reg.
6176 def : Pat<(i64 (sext GPR32:$src)),
6177 (SBFMXri (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GPR32:$src, sub_32), 0, 31)>;
6178 def : Pat<(i64 (sext_inreg GPR64:$src, i32)), (SBFMXri GPR64:$src, 0, 31)>;
6179 def : Pat<(i64 (sext_inreg GPR64:$src, i16)), (SBFMXri GPR64:$src, 0, 15)>;
6180 def : Pat<(i64 (sext_inreg GPR64:$src, i8)), (SBFMXri GPR64:$src, 0, 7)>;
6181 def : Pat<(i64 (sext_inreg GPR64:$src, i1)), (SBFMXri GPR64:$src, 0, 0)>;
6182 def : Pat<(i32 (sext_inreg GPR32:$src, i16)), (SBFMWri GPR32:$src, 0, 15)>;
6183 def : Pat<(i32 (sext_inreg GPR32:$src, i8)), (SBFMWri GPR32:$src, 0, 7)>;
6184 def : Pat<(i32 (sext_inreg GPR32:$src, i1)), (SBFMWri GPR32:$src, 0, 0)>;
6186 def : Pat<(shl (sext_inreg GPR32:$Rn, i8), (i64 imm0_31:$imm)),
6187 (SBFMWri GPR32:$Rn, (i64 (i32shift_a imm0_31:$imm)),
6188 (i64 (i32shift_sext_i8 imm0_31:$imm)))>;
6189 def : Pat<(shl (sext_inreg GPR64:$Rn, i8), (i64 imm0_63:$imm)),
6190 (SBFMXri GPR64:$Rn, (i64 (i64shift_a imm0_63:$imm)),
6191 (i64 (i64shift_sext_i8 imm0_63:$imm)))>;
6193 def : Pat<(shl (sext_inreg GPR32:$Rn, i16), (i64 imm0_31:$imm)),
6194 (SBFMWri GPR32:$Rn, (i64 (i32shift_a imm0_31:$imm)),
6195 (i64 (i32shift_sext_i16 imm0_31:$imm)))>;
6196 def : Pat<(shl (sext_inreg GPR64:$Rn, i16), (i64 imm0_63:$imm)),
6197 (SBFMXri GPR64:$Rn, (i64 (i64shift_a imm0_63:$imm)),
6198 (i64 (i64shift_sext_i16 imm0_63:$imm)))>;
6200 def : Pat<(shl (i64 (sext GPR32:$Rn)), (i64 imm0_63:$imm)),
6201 (SBFMXri (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GPR32:$Rn, sub_32),
6202 (i64 (i64shift_a imm0_63:$imm)),
6203 (i64 (i64shift_sext_i32 imm0_63:$imm)))>;
6205 // sra patterns have an AddedComplexity of 10, so make sure we have a higher
6206 // AddedComplexity for the following patterns since we want to match sext + sra
6207 // patterns before we attempt to match a single sra node.
6208 let AddedComplexity = 20 in {
6209 // We support all sext + sra combinations which preserve at least one bit of the
6210 // original value which is to be sign extended. E.g. we support shifts up to
6212 def : Pat<(sra (sext_inreg GPR32:$Rn, i8), (i64 imm0_7:$imm)),
6213 (SBFMWri GPR32:$Rn, (i64 imm0_7:$imm), 7)>;
6214 def : Pat<(sra (sext_inreg GPR64:$Rn, i8), (i64 imm0_7:$imm)),
6215 (SBFMXri GPR64:$Rn, (i64 imm0_7:$imm), 7)>;
6217 def : Pat<(sra (sext_inreg GPR32:$Rn, i16), (i64 imm0_15:$imm)),
6218 (SBFMWri GPR32:$Rn, (i64 imm0_15:$imm), 15)>;
6219 def : Pat<(sra (sext_inreg GPR64:$Rn, i16), (i64 imm0_15:$imm)),
6220 (SBFMXri GPR64:$Rn, (i64 imm0_15:$imm), 15)>;
6222 def : Pat<(sra (i64 (sext GPR32:$Rn)), (i64 imm0_31:$imm)),
6223 (SBFMXri (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GPR32:$Rn, sub_32),
6224 (i64 imm0_31:$imm), 31)>;
6225 } // AddedComplexity = 20
6227 // To truncate, we can simply extract from a subregister.
6228 def : Pat<(i32 (trunc GPR64sp:$src)),
6229 (i32 (EXTRACT_SUBREG GPR64sp:$src, sub_32))>;
6231 // __builtin_trap() uses the BRK instruction on AArch64.
6232 def : Pat<(trap), (BRK 1)>;
6233 def : Pat<(debugtrap), (BRK 0xF000)>, Requires<[IsWindows]>;
6235 // Multiply high patterns which multiply the lower subvector using smull/umull
6236 // and the upper subvector with smull2/umull2. Then shuffle the high the high
6237 // part of both results together.
6238 def : Pat<(v16i8 (mulhs V128:$Rn, V128:$Rm)),
6240 (SMULLv8i8_v8i16 (EXTRACT_SUBREG V128:$Rn, dsub),
6241 (EXTRACT_SUBREG V128:$Rm, dsub)),
6242 (SMULLv16i8_v8i16 V128:$Rn, V128:$Rm))>;
6243 def : Pat<(v8i16 (mulhs V128:$Rn, V128:$Rm)),
6245 (SMULLv4i16_v4i32 (EXTRACT_SUBREG V128:$Rn, dsub),
6246 (EXTRACT_SUBREG V128:$Rm, dsub)),
6247 (SMULLv8i16_v4i32 V128:$Rn, V128:$Rm))>;
6248 def : Pat<(v4i32 (mulhs V128:$Rn, V128:$Rm)),
6250 (SMULLv2i32_v2i64 (EXTRACT_SUBREG V128:$Rn, dsub),
6251 (EXTRACT_SUBREG V128:$Rm, dsub)),
6252 (SMULLv4i32_v2i64 V128:$Rn, V128:$Rm))>;
6254 def : Pat<(v16i8 (mulhu V128:$Rn, V128:$Rm)),
6256 (UMULLv8i8_v8i16 (EXTRACT_SUBREG V128:$Rn, dsub),
6257 (EXTRACT_SUBREG V128:$Rm, dsub)),
6258 (UMULLv16i8_v8i16 V128:$Rn, V128:$Rm))>;
6259 def : Pat<(v8i16 (mulhu V128:$Rn, V128:$Rm)),
6261 (UMULLv4i16_v4i32 (EXTRACT_SUBREG V128:$Rn, dsub),
6262 (EXTRACT_SUBREG V128:$Rm, dsub)),
6263 (UMULLv8i16_v4i32 V128:$Rn, V128:$Rm))>;
6264 def : Pat<(v4i32 (mulhu V128:$Rn, V128:$Rm)),
6266 (UMULLv2i32_v2i64 (EXTRACT_SUBREG V128:$Rn, dsub),
6267 (EXTRACT_SUBREG V128:$Rm, dsub)),
6268 (UMULLv4i32_v2i64 V128:$Rn, V128:$Rm))>;
6270 // Conversions within AdvSIMD types in the same register size are free.
6271 // But because we need a consistent lane ordering, in big endian many
6272 // conversions require one or more REV instructions.
6274 // Consider a simple memory load followed by a bitconvert then a store.
6276 // v1 = BITCAST v2i32 v0 to v4i16
6279 // In big endian mode every memory access has an implicit byte swap. LDR and
6280 // STR do a 64-bit byte swap, whereas LD1/ST1 do a byte swap per lane - that
6281 // is, they treat the vector as a sequence of elements to be byte-swapped.
6282 // The two pairs of instructions are fundamentally incompatible. We've decided
6283 // to use LD1/ST1 only to simplify compiler implementation.
6285 // LD1/ST1 perform the equivalent of a sequence of LDR/STR + REV. This makes
6286 // the original code sequence:
6288 // v1 = REV v2i32 (implicit)
6289 // v2 = BITCAST v2i32 v1 to v4i16
6290 // v3 = REV v4i16 v2 (implicit)
6293 // But this is now broken - the value stored is different to the value loaded
6294 // due to lane reordering. To fix this, on every BITCAST we must perform two
6297 // v1 = REV v2i32 (implicit)
6299 // v3 = BITCAST v2i32 v2 to v4i16
6301 // v5 = REV v4i16 v4 (implicit)
6304 // This means an extra two instructions, but actually in most cases the two REV
6305 // instructions can be combined into one. For example:
6306 // (REV64_2s (REV64_4h X)) === (REV32_4h X)
6308 // There is also no 128-bit REV instruction. This must be synthesized with an
6311 // Most bitconverts require some sort of conversion. The only exceptions are:
6312 // a) Identity conversions - vNfX <-> vNiX
6313 // b) Single-lane-to-scalar - v1fX <-> fX or v1iX <-> iX
6316 // Natural vector casts (64 bit)
6317 def : Pat<(v8i8 (AArch64NvCast (v2i32 FPR64:$src))), (v8i8 FPR64:$src)>;
6318 def : Pat<(v4i16 (AArch64NvCast (v2i32 FPR64:$src))), (v4i16 FPR64:$src)>;
6319 def : Pat<(v4f16 (AArch64NvCast (v2i32 FPR64:$src))), (v4f16 FPR64:$src)>;
6320 def : Pat<(v2i32 (AArch64NvCast (v2i32 FPR64:$src))), (v2i32 FPR64:$src)>;
6321 def : Pat<(v2f32 (AArch64NvCast (v2i32 FPR64:$src))), (v2f32 FPR64:$src)>;
6322 def : Pat<(v1i64 (AArch64NvCast (v2i32 FPR64:$src))), (v1i64 FPR64:$src)>;
6324 def : Pat<(v8i8 (AArch64NvCast (v4i16 FPR64:$src))), (v8i8 FPR64:$src)>;
6325 def : Pat<(v4i16 (AArch64NvCast (v4i16 FPR64:$src))), (v4i16 FPR64:$src)>;
6326 def : Pat<(v4f16 (AArch64NvCast (v4i16 FPR64:$src))), (v4f16 FPR64:$src)>;
6327 def : Pat<(v2i32 (AArch64NvCast (v4i16 FPR64:$src))), (v2i32 FPR64:$src)>;
6328 def : Pat<(v1i64 (AArch64NvCast (v4i16 FPR64:$src))), (v1i64 FPR64:$src)>;
6330 def : Pat<(v8i8 (AArch64NvCast (v8i8 FPR64:$src))), (v8i8 FPR64:$src)>;
6331 def : Pat<(v4i16 (AArch64NvCast (v8i8 FPR64:$src))), (v4i16 FPR64:$src)>;
6332 def : Pat<(v4f16 (AArch64NvCast (v8i8 FPR64:$src))), (v4f16 FPR64:$src)>;
6333 def : Pat<(v2i32 (AArch64NvCast (v8i8 FPR64:$src))), (v2i32 FPR64:$src)>;
6334 def : Pat<(v2f32 (AArch64NvCast (v8i8 FPR64:$src))), (v2f32 FPR64:$src)>;
6335 def : Pat<(v1i64 (AArch64NvCast (v8i8 FPR64:$src))), (v1i64 FPR64:$src)>;
6337 def : Pat<(v8i8 (AArch64NvCast (f64 FPR64:$src))), (v8i8 FPR64:$src)>;
6338 def : Pat<(v4i16 (AArch64NvCast (f64 FPR64:$src))), (v4i16 FPR64:$src)>;
6339 def : Pat<(v4f16 (AArch64NvCast (f64 FPR64:$src))), (v4f16 FPR64:$src)>;
6340 def : Pat<(v2i32 (AArch64NvCast (f64 FPR64:$src))), (v2i32 FPR64:$src)>;
6341 def : Pat<(v2f32 (AArch64NvCast (f64 FPR64:$src))), (v2f32 FPR64:$src)>;
6342 def : Pat<(v1i64 (AArch64NvCast (f64 FPR64:$src))), (v1i64 FPR64:$src)>;
6343 def : Pat<(v1f64 (AArch64NvCast (f64 FPR64:$src))), (v1f64 FPR64:$src)>;
6345 def : Pat<(v8i8 (AArch64NvCast (v2f32 FPR64:$src))), (v8i8 FPR64:$src)>;
6346 def : Pat<(v4i16 (AArch64NvCast (v2f32 FPR64:$src))), (v4i16 FPR64:$src)>;
6347 def : Pat<(v2i32 (AArch64NvCast (v2f32 FPR64:$src))), (v2i32 FPR64:$src)>;
6348 def : Pat<(v2f32 (AArch64NvCast (v2f32 FPR64:$src))), (v2f32 FPR64:$src)>;
6349 def : Pat<(v1i64 (AArch64NvCast (v2f32 FPR64:$src))), (v1i64 FPR64:$src)>;
6350 def : Pat<(v1f64 (AArch64NvCast (v2f32 FPR64:$src))), (v1f64 FPR64:$src)>;
6352 // Natural vector casts (128 bit)
6353 def : Pat<(v16i8 (AArch64NvCast (v4i32 FPR128:$src))), (v16i8 FPR128:$src)>;
6354 def : Pat<(v8i16 (AArch64NvCast (v4i32 FPR128:$src))), (v8i16 FPR128:$src)>;
6355 def : Pat<(v8f16 (AArch64NvCast (v4i32 FPR128:$src))), (v8f16 FPR128:$src)>;
6356 def : Pat<(v4i32 (AArch64NvCast (v4i32 FPR128:$src))), (v4i32 FPR128:$src)>;
6357 def : Pat<(v4f32 (AArch64NvCast (v4i32 FPR128:$src))), (v4f32 FPR128:$src)>;
6358 def : Pat<(v2i64 (AArch64NvCast (v4i32 FPR128:$src))), (v2i64 FPR128:$src)>;
6359 def : Pat<(v2f64 (AArch64NvCast (v4i32 FPR128:$src))), (v2f64 FPR128:$src)>;
6361 def : Pat<(v16i8 (AArch64NvCast (v8i16 FPR128:$src))), (v16i8 FPR128:$src)>;
6362 def : Pat<(v8i16 (AArch64NvCast (v8i16 FPR128:$src))), (v8i16 FPR128:$src)>;
6363 def : Pat<(v8f16 (AArch64NvCast (v8i16 FPR128:$src))), (v8f16 FPR128:$src)>;
6364 def : Pat<(v4i32 (AArch64NvCast (v8i16 FPR128:$src))), (v4i32 FPR128:$src)>;
6365 def : Pat<(v2i64 (AArch64NvCast (v8i16 FPR128:$src))), (v2i64 FPR128:$src)>;
6366 def : Pat<(v4f32 (AArch64NvCast (v8i16 FPR128:$src))), (v4f32 FPR128:$src)>;
6367 def : Pat<(v2f64 (AArch64NvCast (v8i16 FPR128:$src))), (v2f64 FPR128:$src)>;
6369 def : Pat<(v16i8 (AArch64NvCast (v16i8 FPR128:$src))), (v16i8 FPR128:$src)>;
6370 def : Pat<(v8i16 (AArch64NvCast (v16i8 FPR128:$src))), (v8i16 FPR128:$src)>;
6371 def : Pat<(v8f16 (AArch64NvCast (v16i8 FPR128:$src))), (v8f16 FPR128:$src)>;
6372 def : Pat<(v4i32 (AArch64NvCast (v16i8 FPR128:$src))), (v4i32 FPR128:$src)>;
6373 def : Pat<(v2i64 (AArch64NvCast (v16i8 FPR128:$src))), (v2i64 FPR128:$src)>;
6374 def : Pat<(v4f32 (AArch64NvCast (v16i8 FPR128:$src))), (v4f32 FPR128:$src)>;
6375 def : Pat<(v2f64 (AArch64NvCast (v16i8 FPR128:$src))), (v2f64 FPR128:$src)>;
6377 def : Pat<(v16i8 (AArch64NvCast (v2i64 FPR128:$src))), (v16i8 FPR128:$src)>;
6378 def : Pat<(v8i16 (AArch64NvCast (v2i64 FPR128:$src))), (v8i16 FPR128:$src)>;
6379 def : Pat<(v8f16 (AArch64NvCast (v2i64 FPR128:$src))), (v8f16 FPR128:$src)>;
6380 def : Pat<(v4i32 (AArch64NvCast (v2i64 FPR128:$src))), (v4i32 FPR128:$src)>;
6381 def : Pat<(v2i64 (AArch64NvCast (v2i64 FPR128:$src))), (v2i64 FPR128:$src)>;
6382 def : Pat<(v4f32 (AArch64NvCast (v2i64 FPR128:$src))), (v4f32 FPR128:$src)>;
6383 def : Pat<(v2f64 (AArch64NvCast (v2i64 FPR128:$src))), (v2f64 FPR128:$src)>;
6385 def : Pat<(v16i8 (AArch64NvCast (v4f32 FPR128:$src))), (v16i8 FPR128:$src)>;
6386 def : Pat<(v8i16 (AArch64NvCast (v4f32 FPR128:$src))), (v8i16 FPR128:$src)>;
6387 def : Pat<(v4i32 (AArch64NvCast (v4f32 FPR128:$src))), (v4i32 FPR128:$src)>;
6388 def : Pat<(v4f32 (AArch64NvCast (v4f32 FPR128:$src))), (v4f32 FPR128:$src)>;
6389 def : Pat<(v2i64 (AArch64NvCast (v4f32 FPR128:$src))), (v2i64 FPR128:$src)>;
6390 def : Pat<(v8f16 (AArch64NvCast (v4f32 FPR128:$src))), (v8f16 FPR128:$src)>;
6391 def : Pat<(v2f64 (AArch64NvCast (v4f32 FPR128:$src))), (v2f64 FPR128:$src)>;
6393 def : Pat<(v16i8 (AArch64NvCast (v2f64 FPR128:$src))), (v16i8 FPR128:$src)>;
6394 def : Pat<(v8i16 (AArch64NvCast (v2f64 FPR128:$src))), (v8i16 FPR128:$src)>;
6395 def : Pat<(v4i32 (AArch64NvCast (v2f64 FPR128:$src))), (v4i32 FPR128:$src)>;
6396 def : Pat<(v2i64 (AArch64NvCast (v2f64 FPR128:$src))), (v2i64 FPR128:$src)>;
6397 def : Pat<(v2f64 (AArch64NvCast (v2f64 FPR128:$src))), (v2f64 FPR128:$src)>;
6398 def : Pat<(v8f16 (AArch64NvCast (v2f64 FPR128:$src))), (v8f16 FPR128:$src)>;
6399 def : Pat<(v4f32 (AArch64NvCast (v2f64 FPR128:$src))), (v4f32 FPR128:$src)>;
6401 let Predicates = [IsLE] in {
6402 def : Pat<(v8i8 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6403 def : Pat<(v4i16 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6404 def : Pat<(v2i32 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6405 def : Pat<(v4f16 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6406 def : Pat<(v2f32 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6408 def : Pat<(i64 (bitconvert (v8i8 V64:$Vn))),
6409 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6410 def : Pat<(i64 (bitconvert (v4i16 V64:$Vn))),
6411 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6412 def : Pat<(i64 (bitconvert (v2i32 V64:$Vn))),
6413 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6414 def : Pat<(i64 (bitconvert (v4f16 V64:$Vn))),
6415 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6416 def : Pat<(i64 (bitconvert (v2f32 V64:$Vn))),
6417 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6418 def : Pat<(i64 (bitconvert (v1f64 V64:$Vn))),
6419 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6421 let Predicates = [IsBE] in {
6422 def : Pat<(v8i8 (bitconvert GPR64:$Xn)),
6423 (REV64v8i8 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
6424 def : Pat<(v4i16 (bitconvert GPR64:$Xn)),
6425 (REV64v4i16 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
6426 def : Pat<(v2i32 (bitconvert GPR64:$Xn)),
6427 (REV64v2i32 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
6428 def : Pat<(v4f16 (bitconvert GPR64:$Xn)),
6429 (REV64v4i16 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
6430 def : Pat<(v2f32 (bitconvert GPR64:$Xn)),
6431 (REV64v2i32 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
6433 def : Pat<(i64 (bitconvert (v8i8 V64:$Vn))),
6434 (REV64v8i8 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
6435 def : Pat<(i64 (bitconvert (v4i16 V64:$Vn))),
6436 (REV64v4i16 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
6437 def : Pat<(i64 (bitconvert (v2i32 V64:$Vn))),
6438 (REV64v2i32 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
6439 def : Pat<(i64 (bitconvert (v4f16 V64:$Vn))),
6440 (REV64v4i16 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
6441 def : Pat<(i64 (bitconvert (v2f32 V64:$Vn))),
6442 (REV64v2i32 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
6444 def : Pat<(v1i64 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6445 def : Pat<(v1f64 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6446 def : Pat<(i64 (bitconvert (v1i64 V64:$Vn))),
6447 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6448 def : Pat<(v1i64 (scalar_to_vector GPR64:$Xn)),
6449 (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6450 def : Pat<(v1f64 (scalar_to_vector GPR64:$Xn)),
6451 (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6452 def : Pat<(v1f64 (scalar_to_vector (f64 FPR64:$Xn))), (v1f64 FPR64:$Xn)>;
6454 def : Pat<(f32 (bitconvert (i32 GPR32:$Xn))),
6455 (COPY_TO_REGCLASS GPR32:$Xn, FPR32)>;
6456 def : Pat<(i32 (bitconvert (f32 FPR32:$Xn))),
6457 (COPY_TO_REGCLASS FPR32:$Xn, GPR32)>;
6458 def : Pat<(f64 (bitconvert (i64 GPR64:$Xn))),
6459 (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6460 def : Pat<(i64 (bitconvert (f64 FPR64:$Xn))),
6461 (COPY_TO_REGCLASS FPR64:$Xn, GPR64)>;
6462 def : Pat<(i64 (bitconvert (v1f64 V64:$Vn))),
6463 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6465 let Predicates = [IsLE] in {
6466 def : Pat<(v1i64 (bitconvert (v2i32 FPR64:$src))), (v1i64 FPR64:$src)>;
6467 def : Pat<(v1i64 (bitconvert (v4i16 FPR64:$src))), (v1i64 FPR64:$src)>;
6468 def : Pat<(v1i64 (bitconvert (v8i8 FPR64:$src))), (v1i64 FPR64:$src)>;
6469 def : Pat<(v1i64 (bitconvert (v4f16 FPR64:$src))), (v1i64 FPR64:$src)>;
6470 def : Pat<(v1i64 (bitconvert (v2f32 FPR64:$src))), (v1i64 FPR64:$src)>;
6472 let Predicates = [IsBE] in {
6473 def : Pat<(v1i64 (bitconvert (v2i32 FPR64:$src))),
6474 (v1i64 (REV64v2i32 FPR64:$src))>;
6475 def : Pat<(v1i64 (bitconvert (v4i16 FPR64:$src))),
6476 (v1i64 (REV64v4i16 FPR64:$src))>;
6477 def : Pat<(v1i64 (bitconvert (v8i8 FPR64:$src))),
6478 (v1i64 (REV64v8i8 FPR64:$src))>;
6479 def : Pat<(v1i64 (bitconvert (v4f16 FPR64:$src))),
6480 (v1i64 (REV64v4i16 FPR64:$src))>;
6481 def : Pat<(v1i64 (bitconvert (v2f32 FPR64:$src))),
6482 (v1i64 (REV64v2i32 FPR64:$src))>;
6484 def : Pat<(v1i64 (bitconvert (v1f64 FPR64:$src))), (v1i64 FPR64:$src)>;
6485 def : Pat<(v1i64 (bitconvert (f64 FPR64:$src))), (v1i64 FPR64:$src)>;
6487 let Predicates = [IsLE] in {
6488 def : Pat<(v2i32 (bitconvert (v1i64 FPR64:$src))), (v2i32 FPR64:$src)>;
6489 def : Pat<(v2i32 (bitconvert (v4i16 FPR64:$src))), (v2i32 FPR64:$src)>;
6490 def : Pat<(v2i32 (bitconvert (v8i8 FPR64:$src))), (v2i32 FPR64:$src)>;
6491 def : Pat<(v2i32 (bitconvert (f64 FPR64:$src))), (v2i32 FPR64:$src)>;
6492 def : Pat<(v2i32 (bitconvert (v1f64 FPR64:$src))), (v2i32 FPR64:$src)>;
6493 def : Pat<(v2i32 (bitconvert (v4f16 FPR64:$src))), (v2i32 FPR64:$src)>;
6495 let Predicates = [IsBE] in {
6496 def : Pat<(v2i32 (bitconvert (v1i64 FPR64:$src))),
6497 (v2i32 (REV64v2i32 FPR64:$src))>;
6498 def : Pat<(v2i32 (bitconvert (v4i16 FPR64:$src))),
6499 (v2i32 (REV32v4i16 FPR64:$src))>;
6500 def : Pat<(v2i32 (bitconvert (v8i8 FPR64:$src))),
6501 (v2i32 (REV32v8i8 FPR64:$src))>;
6502 def : Pat<(v2i32 (bitconvert (f64 FPR64:$src))),
6503 (v2i32 (REV64v2i32 FPR64:$src))>;
6504 def : Pat<(v2i32 (bitconvert (v1f64 FPR64:$src))),
6505 (v2i32 (REV64v2i32 FPR64:$src))>;
6506 def : Pat<(v2i32 (bitconvert (v4f16 FPR64:$src))),
6507 (v2i32 (REV32v4i16 FPR64:$src))>;
6509 def : Pat<(v2i32 (bitconvert (v2f32 FPR64:$src))), (v2i32 FPR64:$src)>;
6511 let Predicates = [IsLE] in {
6512 def : Pat<(v4i16 (bitconvert (v1i64 FPR64:$src))), (v4i16 FPR64:$src)>;
6513 def : Pat<(v4i16 (bitconvert (v2i32 FPR64:$src))), (v4i16 FPR64:$src)>;
6514 def : Pat<(v4i16 (bitconvert (v8i8 FPR64:$src))), (v4i16 FPR64:$src)>;
6515 def : Pat<(v4i16 (bitconvert (f64 FPR64:$src))), (v4i16 FPR64:$src)>;
6516 def : Pat<(v4i16 (bitconvert (v2f32 FPR64:$src))), (v4i16 FPR64:$src)>;
6517 def : Pat<(v4i16 (bitconvert (v1f64 FPR64:$src))), (v4i16 FPR64:$src)>;
6519 let Predicates = [IsBE] in {
6520 def : Pat<(v4i16 (bitconvert (v1i64 FPR64:$src))),
6521 (v4i16 (REV64v4i16 FPR64:$src))>;
6522 def : Pat<(v4i16 (bitconvert (v2i32 FPR64:$src))),
6523 (v4i16 (REV32v4i16 FPR64:$src))>;
6524 def : Pat<(v4i16 (bitconvert (v8i8 FPR64:$src))),
6525 (v4i16 (REV16v8i8 FPR64:$src))>;
6526 def : Pat<(v4i16 (bitconvert (f64 FPR64:$src))),
6527 (v4i16 (REV64v4i16 FPR64:$src))>;
6528 def : Pat<(v4i16 (bitconvert (v2f32 FPR64:$src))),
6529 (v4i16 (REV32v4i16 FPR64:$src))>;
6530 def : Pat<(v4i16 (bitconvert (v1f64 FPR64:$src))),
6531 (v4i16 (REV64v4i16 FPR64:$src))>;
6533 def : Pat<(v4i16 (bitconvert (v4f16 FPR64:$src))), (v4i16 FPR64:$src)>;
6535 let Predicates = [IsLE] in {
6536 def : Pat<(v4f16 (bitconvert (v1i64 FPR64:$src))), (v4f16 FPR64:$src)>;
6537 def : Pat<(v4f16 (bitconvert (v2i32 FPR64:$src))), (v4f16 FPR64:$src)>;
6538 def : Pat<(v4f16 (bitconvert (v8i8 FPR64:$src))), (v4f16 FPR64:$src)>;
6539 def : Pat<(v4f16 (bitconvert (f64 FPR64:$src))), (v4f16 FPR64:$src)>;
6540 def : Pat<(v4f16 (bitconvert (v2f32 FPR64:$src))), (v4f16 FPR64:$src)>;
6541 def : Pat<(v4f16 (bitconvert (v1f64 FPR64:$src))), (v4f16 FPR64:$src)>;
6543 let Predicates = [IsBE] in {
6544 def : Pat<(v4f16 (bitconvert (v1i64 FPR64:$src))),
6545 (v4f16 (REV64v4i16 FPR64:$src))>;
6546 def : Pat<(v4f16 (bitconvert (v2i32 FPR64:$src))),
6547 (v4f16 (REV32v4i16 FPR64:$src))>;
6548 def : Pat<(v4f16 (bitconvert (v8i8 FPR64:$src))),
6549 (v4f16 (REV16v8i8 FPR64:$src))>;
6550 def : Pat<(v4f16 (bitconvert (f64 FPR64:$src))),
6551 (v4f16 (REV64v4i16 FPR64:$src))>;
6552 def : Pat<(v4f16 (bitconvert (v2f32 FPR64:$src))),
6553 (v4f16 (REV32v4i16 FPR64:$src))>;
6554 def : Pat<(v4f16 (bitconvert (v1f64 FPR64:$src))),
6555 (v4f16 (REV64v4i16 FPR64:$src))>;
6557 def : Pat<(v4f16 (bitconvert (v4i16 FPR64:$src))), (v4f16 FPR64:$src)>;
6559 let Predicates = [IsLE] in {
6560 def : Pat<(v8i8 (bitconvert (v1i64 FPR64:$src))), (v8i8 FPR64:$src)>;
6561 def : Pat<(v8i8 (bitconvert (v2i32 FPR64:$src))), (v8i8 FPR64:$src)>;
6562 def : Pat<(v8i8 (bitconvert (v4i16 FPR64:$src))), (v8i8 FPR64:$src)>;
6563 def : Pat<(v8i8 (bitconvert (f64 FPR64:$src))), (v8i8 FPR64:$src)>;
6564 def : Pat<(v8i8 (bitconvert (v2f32 FPR64:$src))), (v8i8 FPR64:$src)>;
6565 def : Pat<(v8i8 (bitconvert (v1f64 FPR64:$src))), (v8i8 FPR64:$src)>;
6566 def : Pat<(v8i8 (bitconvert (v4f16 FPR64:$src))), (v8i8 FPR64:$src)>;
6568 let Predicates = [IsBE] in {
6569 def : Pat<(v8i8 (bitconvert (v1i64 FPR64:$src))),
6570 (v8i8 (REV64v8i8 FPR64:$src))>;
6571 def : Pat<(v8i8 (bitconvert (v2i32 FPR64:$src))),
6572 (v8i8 (REV32v8i8 FPR64:$src))>;
6573 def : Pat<(v8i8 (bitconvert (v4i16 FPR64:$src))),
6574 (v8i8 (REV16v8i8 FPR64:$src))>;
6575 def : Pat<(v8i8 (bitconvert (f64 FPR64:$src))),
6576 (v8i8 (REV64v8i8 FPR64:$src))>;
6577 def : Pat<(v8i8 (bitconvert (v2f32 FPR64:$src))),
6578 (v8i8 (REV32v8i8 FPR64:$src))>;
6579 def : Pat<(v8i8 (bitconvert (v1f64 FPR64:$src))),
6580 (v8i8 (REV64v8i8 FPR64:$src))>;
6581 def : Pat<(v8i8 (bitconvert (v4f16 FPR64:$src))),
6582 (v8i8 (REV16v8i8 FPR64:$src))>;
6585 let Predicates = [IsLE] in {
6586 def : Pat<(f64 (bitconvert (v2i32 FPR64:$src))), (f64 FPR64:$src)>;
6587 def : Pat<(f64 (bitconvert (v4i16 FPR64:$src))), (f64 FPR64:$src)>;
6588 def : Pat<(f64 (bitconvert (v2f32 FPR64:$src))), (f64 FPR64:$src)>;
6589 def : Pat<(f64 (bitconvert (v8i8 FPR64:$src))), (f64 FPR64:$src)>;
6590 def : Pat<(f64 (bitconvert (v4f16 FPR64:$src))), (f64 FPR64:$src)>;
6592 let Predicates = [IsBE] in {
6593 def : Pat<(f64 (bitconvert (v2i32 FPR64:$src))),
6594 (f64 (REV64v2i32 FPR64:$src))>;
6595 def : Pat<(f64 (bitconvert (v4i16 FPR64:$src))),
6596 (f64 (REV64v4i16 FPR64:$src))>;
6597 def : Pat<(f64 (bitconvert (v2f32 FPR64:$src))),
6598 (f64 (REV64v2i32 FPR64:$src))>;
6599 def : Pat<(f64 (bitconvert (v8i8 FPR64:$src))),
6600 (f64 (REV64v8i8 FPR64:$src))>;
6601 def : Pat<(f64 (bitconvert (v4f16 FPR64:$src))),
6602 (f64 (REV64v4i16 FPR64:$src))>;
6604 def : Pat<(f64 (bitconvert (v1i64 FPR64:$src))), (f64 FPR64:$src)>;
6605 def : Pat<(f64 (bitconvert (v1f64 FPR64:$src))), (f64 FPR64:$src)>;
6607 let Predicates = [IsLE] in {
6608 def : Pat<(v1f64 (bitconvert (v2i32 FPR64:$src))), (v1f64 FPR64:$src)>;
6609 def : Pat<(v1f64 (bitconvert (v4i16 FPR64:$src))), (v1f64 FPR64:$src)>;
6610 def : Pat<(v1f64 (bitconvert (v8i8 FPR64:$src))), (v1f64 FPR64:$src)>;
6611 def : Pat<(v1f64 (bitconvert (v2f32 FPR64:$src))), (v1f64 FPR64:$src)>;
6612 def : Pat<(v1f64 (bitconvert (v4f16 FPR64:$src))), (v1f64 FPR64:$src)>;
6614 let Predicates = [IsBE] in {
6615 def : Pat<(v1f64 (bitconvert (v2i32 FPR64:$src))),
6616 (v1f64 (REV64v2i32 FPR64:$src))>;
6617 def : Pat<(v1f64 (bitconvert (v4i16 FPR64:$src))),
6618 (v1f64 (REV64v4i16 FPR64:$src))>;
6619 def : Pat<(v1f64 (bitconvert (v8i8 FPR64:$src))),
6620 (v1f64 (REV64v8i8 FPR64:$src))>;
6621 def : Pat<(v1f64 (bitconvert (v2f32 FPR64:$src))),
6622 (v1f64 (REV64v2i32 FPR64:$src))>;
6623 def : Pat<(v1f64 (bitconvert (v4f16 FPR64:$src))),
6624 (v1f64 (REV64v4i16 FPR64:$src))>;
6626 def : Pat<(v1f64 (bitconvert (v1i64 FPR64:$src))), (v1f64 FPR64:$src)>;
6627 def : Pat<(v1f64 (bitconvert (f64 FPR64:$src))), (v1f64 FPR64:$src)>;
6629 let Predicates = [IsLE] in {
6630 def : Pat<(v2f32 (bitconvert (v1i64 FPR64:$src))), (v2f32 FPR64:$src)>;
6631 def : Pat<(v2f32 (bitconvert (v4i16 FPR64:$src))), (v2f32 FPR64:$src)>;
6632 def : Pat<(v2f32 (bitconvert (v8i8 FPR64:$src))), (v2f32 FPR64:$src)>;
6633 def : Pat<(v2f32 (bitconvert (v1f64 FPR64:$src))), (v2f32 FPR64:$src)>;
6634 def : Pat<(v2f32 (bitconvert (f64 FPR64:$src))), (v2f32 FPR64:$src)>;
6635 def : Pat<(v2f32 (bitconvert (v4f16 FPR64:$src))), (v2f32 FPR64:$src)>;
6637 let Predicates = [IsBE] in {
6638 def : Pat<(v2f32 (bitconvert (v1i64 FPR64:$src))),
6639 (v2f32 (REV64v2i32 FPR64:$src))>;
6640 def : Pat<(v2f32 (bitconvert (v4i16 FPR64:$src))),
6641 (v2f32 (REV32v4i16 FPR64:$src))>;
6642 def : Pat<(v2f32 (bitconvert (v8i8 FPR64:$src))),
6643 (v2f32 (REV32v8i8 FPR64:$src))>;
6644 def : Pat<(v2f32 (bitconvert (v1f64 FPR64:$src))),
6645 (v2f32 (REV64v2i32 FPR64:$src))>;
6646 def : Pat<(v2f32 (bitconvert (f64 FPR64:$src))),
6647 (v2f32 (REV64v2i32 FPR64:$src))>;
6648 def : Pat<(v2f32 (bitconvert (v4f16 FPR64:$src))),
6649 (v2f32 (REV32v4i16 FPR64:$src))>;
6651 def : Pat<(v2f32 (bitconvert (v2i32 FPR64:$src))), (v2f32 FPR64:$src)>;
6653 let Predicates = [IsLE] in {
6654 def : Pat<(f128 (bitconvert (v2i64 FPR128:$src))), (f128 FPR128:$src)>;
6655 def : Pat<(f128 (bitconvert (v4i32 FPR128:$src))), (f128 FPR128:$src)>;
6656 def : Pat<(f128 (bitconvert (v8i16 FPR128:$src))), (f128 FPR128:$src)>;
6657 def : Pat<(f128 (bitconvert (v2f64 FPR128:$src))), (f128 FPR128:$src)>;
6658 def : Pat<(f128 (bitconvert (v4f32 FPR128:$src))), (f128 FPR128:$src)>;
6659 def : Pat<(f128 (bitconvert (v8f16 FPR128:$src))), (f128 FPR128:$src)>;
6660 def : Pat<(f128 (bitconvert (v16i8 FPR128:$src))), (f128 FPR128:$src)>;
6662 let Predicates = [IsBE] in {
6663 def : Pat<(f128 (bitconvert (v2i64 FPR128:$src))),
6664 (f128 (EXTv16i8 FPR128:$src, FPR128:$src, (i32 8)))>;
6665 def : Pat<(f128 (bitconvert (v4i32 FPR128:$src))),
6666 (f128 (EXTv16i8 (REV64v4i32 FPR128:$src),
6667 (REV64v4i32 FPR128:$src), (i32 8)))>;
6668 def : Pat<(f128 (bitconvert (v8i16 FPR128:$src))),
6669 (f128 (EXTv16i8 (REV64v8i16 FPR128:$src),
6670 (REV64v8i16 FPR128:$src), (i32 8)))>;
6671 def : Pat<(f128 (bitconvert (v8f16 FPR128:$src))),
6672 (f128 (EXTv16i8 (REV64v8i16 FPR128:$src),
6673 (REV64v8i16 FPR128:$src), (i32 8)))>;
6674 def : Pat<(f128 (bitconvert (v2f64 FPR128:$src))),
6675 (f128 (EXTv16i8 FPR128:$src, FPR128:$src, (i32 8)))>;
6676 def : Pat<(f128 (bitconvert (v4f32 FPR128:$src))),
6677 (f128 (EXTv16i8 (REV64v4i32 FPR128:$src),
6678 (REV64v4i32 FPR128:$src), (i32 8)))>;
6679 def : Pat<(f128 (bitconvert (v16i8 FPR128:$src))),
6680 (f128 (EXTv16i8 (REV64v16i8 FPR128:$src),
6681 (REV64v16i8 FPR128:$src), (i32 8)))>;
6684 let Predicates = [IsLE] in {
6685 def : Pat<(v2f64 (bitconvert (f128 FPR128:$src))), (v2f64 FPR128:$src)>;
6686 def : Pat<(v2f64 (bitconvert (v4i32 FPR128:$src))), (v2f64 FPR128:$src)>;
6687 def : Pat<(v2f64 (bitconvert (v8i16 FPR128:$src))), (v2f64 FPR128:$src)>;
6688 def : Pat<(v2f64 (bitconvert (v8f16 FPR128:$src))), (v2f64 FPR128:$src)>;
6689 def : Pat<(v2f64 (bitconvert (v16i8 FPR128:$src))), (v2f64 FPR128:$src)>;
6690 def : Pat<(v2f64 (bitconvert (v4f32 FPR128:$src))), (v2f64 FPR128:$src)>;
6692 let Predicates = [IsBE] in {
6693 def : Pat<(v2f64 (bitconvert (f128 FPR128:$src))),
6694 (v2f64 (EXTv16i8 FPR128:$src,
6695 FPR128:$src, (i32 8)))>;
6696 def : Pat<(v2f64 (bitconvert (v4i32 FPR128:$src))),
6697 (v2f64 (REV64v4i32 FPR128:$src))>;
6698 def : Pat<(v2f64 (bitconvert (v8i16 FPR128:$src))),
6699 (v2f64 (REV64v8i16 FPR128:$src))>;
6700 def : Pat<(v2f64 (bitconvert (v8f16 FPR128:$src))),
6701 (v2f64 (REV64v8i16 FPR128:$src))>;
6702 def : Pat<(v2f64 (bitconvert (v16i8 FPR128:$src))),
6703 (v2f64 (REV64v16i8 FPR128:$src))>;
6704 def : Pat<(v2f64 (bitconvert (v4f32 FPR128:$src))),
6705 (v2f64 (REV64v4i32 FPR128:$src))>;
6707 def : Pat<(v2f64 (bitconvert (v2i64 FPR128:$src))), (v2f64 FPR128:$src)>;
6709 let Predicates = [IsLE] in {
6710 def : Pat<(v4f32 (bitconvert (f128 FPR128:$src))), (v4f32 FPR128:$src)>;
6711 def : Pat<(v4f32 (bitconvert (v8i16 FPR128:$src))), (v4f32 FPR128:$src)>;
6712 def : Pat<(v4f32 (bitconvert (v8f16 FPR128:$src))), (v4f32 FPR128:$src)>;
6713 def : Pat<(v4f32 (bitconvert (v16i8 FPR128:$src))), (v4f32 FPR128:$src)>;
6714 def : Pat<(v4f32 (bitconvert (v2i64 FPR128:$src))), (v4f32 FPR128:$src)>;
6715 def : Pat<(v4f32 (bitconvert (v2f64 FPR128:$src))), (v4f32 FPR128:$src)>;
6717 let Predicates = [IsBE] in {
6718 def : Pat<(v4f32 (bitconvert (f128 FPR128:$src))),
6719 (v4f32 (EXTv16i8 (REV64v4i32 FPR128:$src),
6720 (REV64v4i32 FPR128:$src), (i32 8)))>;
6721 def : Pat<(v4f32 (bitconvert (v8i16 FPR128:$src))),
6722 (v4f32 (REV32v8i16 FPR128:$src))>;
6723 def : Pat<(v4f32 (bitconvert (v8f16 FPR128:$src))),
6724 (v4f32 (REV32v8i16 FPR128:$src))>;
6725 def : Pat<(v4f32 (bitconvert (v16i8 FPR128:$src))),
6726 (v4f32 (REV32v16i8 FPR128:$src))>;
6727 def : Pat<(v4f32 (bitconvert (v2i64 FPR128:$src))),
6728 (v4f32 (REV64v4i32 FPR128:$src))>;
6729 def : Pat<(v4f32 (bitconvert (v2f64 FPR128:$src))),
6730 (v4f32 (REV64v4i32 FPR128:$src))>;
6732 def : Pat<(v4f32 (bitconvert (v4i32 FPR128:$src))), (v4f32 FPR128:$src)>;
6734 let Predicates = [IsLE] in {
6735 def : Pat<(v2i64 (bitconvert (f128 FPR128:$src))), (v2i64 FPR128:$src)>;
6736 def : Pat<(v2i64 (bitconvert (v4i32 FPR128:$src))), (v2i64 FPR128:$src)>;
6737 def : Pat<(v2i64 (bitconvert (v8i16 FPR128:$src))), (v2i64 FPR128:$src)>;
6738 def : Pat<(v2i64 (bitconvert (v16i8 FPR128:$src))), (v2i64 FPR128:$src)>;
6739 def : Pat<(v2i64 (bitconvert (v4f32 FPR128:$src))), (v2i64 FPR128:$src)>;
6740 def : Pat<(v2i64 (bitconvert (v8f16 FPR128:$src))), (v2i64 FPR128:$src)>;
6742 let Predicates = [IsBE] in {
6743 def : Pat<(v2i64 (bitconvert (f128 FPR128:$src))),
6744 (v2i64 (EXTv16i8 FPR128:$src,
6745 FPR128:$src, (i32 8)))>;
6746 def : Pat<(v2i64 (bitconvert (v4i32 FPR128:$src))),
6747 (v2i64 (REV64v4i32 FPR128:$src))>;
6748 def : Pat<(v2i64 (bitconvert (v8i16 FPR128:$src))),
6749 (v2i64 (REV64v8i16 FPR128:$src))>;
6750 def : Pat<(v2i64 (bitconvert (v16i8 FPR128:$src))),
6751 (v2i64 (REV64v16i8 FPR128:$src))>;
6752 def : Pat<(v2i64 (bitconvert (v4f32 FPR128:$src))),
6753 (v2i64 (REV64v4i32 FPR128:$src))>;
6754 def : Pat<(v2i64 (bitconvert (v8f16 FPR128:$src))),
6755 (v2i64 (REV64v8i16 FPR128:$src))>;
6757 def : Pat<(v2i64 (bitconvert (v2f64 FPR128:$src))), (v2i64 FPR128:$src)>;
6759 let Predicates = [IsLE] in {
6760 def : Pat<(v4i32 (bitconvert (f128 FPR128:$src))), (v4i32 FPR128:$src)>;
6761 def : Pat<(v4i32 (bitconvert (v2i64 FPR128:$src))), (v4i32 FPR128:$src)>;
6762 def : Pat<(v4i32 (bitconvert (v8i16 FPR128:$src))), (v4i32 FPR128:$src)>;
6763 def : Pat<(v4i32 (bitconvert (v16i8 FPR128:$src))), (v4i32 FPR128:$src)>;
6764 def : Pat<(v4i32 (bitconvert (v2f64 FPR128:$src))), (v4i32 FPR128:$src)>;
6765 def : Pat<(v4i32 (bitconvert (v8f16 FPR128:$src))), (v4i32 FPR128:$src)>;
6767 let Predicates = [IsBE] in {
6768 def : Pat<(v4i32 (bitconvert (f128 FPR128:$src))),
6769 (v4i32 (EXTv16i8 (REV64v4i32 FPR128:$src),
6770 (REV64v4i32 FPR128:$src),
6772 def : Pat<(v4i32 (bitconvert (v2i64 FPR128:$src))),
6773 (v4i32 (REV64v4i32 FPR128:$src))>;
6774 def : Pat<(v4i32 (bitconvert (v8i16 FPR128:$src))),
6775 (v4i32 (REV32v8i16 FPR128:$src))>;
6776 def : Pat<(v4i32 (bitconvert (v16i8 FPR128:$src))),
6777 (v4i32 (REV32v16i8 FPR128:$src))>;
6778 def : Pat<(v4i32 (bitconvert (v2f64 FPR128:$src))),
6779 (v4i32 (REV64v4i32 FPR128:$src))>;
6780 def : Pat<(v4i32 (bitconvert (v8f16 FPR128:$src))),
6781 (v4i32 (REV32v8i16 FPR128:$src))>;
6783 def : Pat<(v4i32 (bitconvert (v4f32 FPR128:$src))), (v4i32 FPR128:$src)>;
6785 let Predicates = [IsLE] in {
6786 def : Pat<(v8i16 (bitconvert (f128 FPR128:$src))), (v8i16 FPR128:$src)>;
6787 def : Pat<(v8i16 (bitconvert (v2i64 FPR128:$src))), (v8i16 FPR128:$src)>;
6788 def : Pat<(v8i16 (bitconvert (v4i32 FPR128:$src))), (v8i16 FPR128:$src)>;
6789 def : Pat<(v8i16 (bitconvert (v16i8 FPR128:$src))), (v8i16 FPR128:$src)>;
6790 def : Pat<(v8i16 (bitconvert (v2f64 FPR128:$src))), (v8i16 FPR128:$src)>;
6791 def : Pat<(v8i16 (bitconvert (v4f32 FPR128:$src))), (v8i16 FPR128:$src)>;
6793 let Predicates = [IsBE] in {
6794 def : Pat<(v8i16 (bitconvert (f128 FPR128:$src))),
6795 (v8i16 (EXTv16i8 (REV64v8i16 FPR128:$src),
6796 (REV64v8i16 FPR128:$src),
6798 def : Pat<(v8i16 (bitconvert (v2i64 FPR128:$src))),
6799 (v8i16 (REV64v8i16 FPR128:$src))>;
6800 def : Pat<(v8i16 (bitconvert (v4i32 FPR128:$src))),
6801 (v8i16 (REV32v8i16 FPR128:$src))>;
6802 def : Pat<(v8i16 (bitconvert (v16i8 FPR128:$src))),
6803 (v8i16 (REV16v16i8 FPR128:$src))>;
6804 def : Pat<(v8i16 (bitconvert (v2f64 FPR128:$src))),
6805 (v8i16 (REV64v8i16 FPR128:$src))>;
6806 def : Pat<(v8i16 (bitconvert (v4f32 FPR128:$src))),
6807 (v8i16 (REV32v8i16 FPR128:$src))>;
6809 def : Pat<(v8i16 (bitconvert (v8f16 FPR128:$src))), (v8i16 FPR128:$src)>;
6811 let Predicates = [IsLE] in {
6812 def : Pat<(v8f16 (bitconvert (f128 FPR128:$src))), (v8f16 FPR128:$src)>;
6813 def : Pat<(v8f16 (bitconvert (v2i64 FPR128:$src))), (v8f16 FPR128:$src)>;
6814 def : Pat<(v8f16 (bitconvert (v4i32 FPR128:$src))), (v8f16 FPR128:$src)>;
6815 def : Pat<(v8f16 (bitconvert (v16i8 FPR128:$src))), (v8f16 FPR128:$src)>;
6816 def : Pat<(v8f16 (bitconvert (v2f64 FPR128:$src))), (v8f16 FPR128:$src)>;
6817 def : Pat<(v8f16 (bitconvert (v4f32 FPR128:$src))), (v8f16 FPR128:$src)>;
6819 let Predicates = [IsBE] in {
6820 def : Pat<(v8f16 (bitconvert (f128 FPR128:$src))),
6821 (v8f16 (EXTv16i8 (REV64v8i16 FPR128:$src),
6822 (REV64v8i16 FPR128:$src),
6824 def : Pat<(v8f16 (bitconvert (v2i64 FPR128:$src))),
6825 (v8f16 (REV64v8i16 FPR128:$src))>;
6826 def : Pat<(v8f16 (bitconvert (v4i32 FPR128:$src))),
6827 (v8f16 (REV32v8i16 FPR128:$src))>;
6828 def : Pat<(v8f16 (bitconvert (v16i8 FPR128:$src))),
6829 (v8f16 (REV16v16i8 FPR128:$src))>;
6830 def : Pat<(v8f16 (bitconvert (v2f64 FPR128:$src))),
6831 (v8f16 (REV64v8i16 FPR128:$src))>;
6832 def : Pat<(v8f16 (bitconvert (v4f32 FPR128:$src))),
6833 (v8f16 (REV32v8i16 FPR128:$src))>;
6835 def : Pat<(v8f16 (bitconvert (v8i16 FPR128:$src))), (v8f16 FPR128:$src)>;
6837 let Predicates = [IsLE] in {
6838 def : Pat<(v16i8 (bitconvert (f128 FPR128:$src))), (v16i8 FPR128:$src)>;
6839 def : Pat<(v16i8 (bitconvert (v2i64 FPR128:$src))), (v16i8 FPR128:$src)>;
6840 def : Pat<(v16i8 (bitconvert (v4i32 FPR128:$src))), (v16i8 FPR128:$src)>;
6841 def : Pat<(v16i8 (bitconvert (v8i16 FPR128:$src))), (v16i8 FPR128:$src)>;
6842 def : Pat<(v16i8 (bitconvert (v2f64 FPR128:$src))), (v16i8 FPR128:$src)>;
6843 def : Pat<(v16i8 (bitconvert (v4f32 FPR128:$src))), (v16i8 FPR128:$src)>;
6844 def : Pat<(v16i8 (bitconvert (v8f16 FPR128:$src))), (v16i8 FPR128:$src)>;
6846 let Predicates = [IsBE] in {
6847 def : Pat<(v16i8 (bitconvert (f128 FPR128:$src))),
6848 (v16i8 (EXTv16i8 (REV64v16i8 FPR128:$src),
6849 (REV64v16i8 FPR128:$src),
6851 def : Pat<(v16i8 (bitconvert (v2i64 FPR128:$src))),
6852 (v16i8 (REV64v16i8 FPR128:$src))>;
6853 def : Pat<(v16i8 (bitconvert (v4i32 FPR128:$src))),
6854 (v16i8 (REV32v16i8 FPR128:$src))>;
6855 def : Pat<(v16i8 (bitconvert (v8i16 FPR128:$src))),
6856 (v16i8 (REV16v16i8 FPR128:$src))>;
6857 def : Pat<(v16i8 (bitconvert (v2f64 FPR128:$src))),
6858 (v16i8 (REV64v16i8 FPR128:$src))>;
6859 def : Pat<(v16i8 (bitconvert (v4f32 FPR128:$src))),
6860 (v16i8 (REV32v16i8 FPR128:$src))>;
6861 def : Pat<(v16i8 (bitconvert (v8f16 FPR128:$src))),
6862 (v16i8 (REV16v16i8 FPR128:$src))>;
6865 def : Pat<(v4i16 (extract_subvector V128:$Rn, (i64 0))),
6866 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6867 def : Pat<(v8i8 (extract_subvector V128:$Rn, (i64 0))),
6868 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6869 def : Pat<(v2f32 (extract_subvector V128:$Rn, (i64 0))),
6870 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6871 def : Pat<(v4f16 (extract_subvector V128:$Rn, (i64 0))),
6872 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6873 def : Pat<(v2i32 (extract_subvector V128:$Rn, (i64 0))),
6874 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6875 def : Pat<(v1i64 (extract_subvector V128:$Rn, (i64 0))),
6876 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6877 def : Pat<(v1f64 (extract_subvector V128:$Rn, (i64 0))),
6878 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6880 def : Pat<(v8i8 (extract_subvector (v16i8 FPR128:$Rn), (i64 1))),
6881 (EXTRACT_SUBREG (DUPv2i64lane FPR128:$Rn, 1), dsub)>;
6882 def : Pat<(v4i16 (extract_subvector (v8i16 FPR128:$Rn), (i64 1))),
6883 (EXTRACT_SUBREG (DUPv2i64lane FPR128:$Rn, 1), dsub)>;
6884 def : Pat<(v2i32 (extract_subvector (v4i32 FPR128:$Rn), (i64 1))),
6885 (EXTRACT_SUBREG (DUPv2i64lane FPR128:$Rn, 1), dsub)>;
6886 def : Pat<(v1i64 (extract_subvector (v2i64 FPR128:$Rn), (i64 1))),
6887 (EXTRACT_SUBREG (DUPv2i64lane FPR128:$Rn, 1), dsub)>;
6889 // A 64-bit subvector insert to the first 128-bit vector position
6890 // is a subregister copy that needs no instruction.
6891 multiclass InsertSubvectorUndef<ValueType Ty> {
6892 def : Pat<(insert_subvector undef, (v1i64 FPR64:$src), (Ty 0)),
6893 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6894 def : Pat<(insert_subvector undef, (v1f64 FPR64:$src), (Ty 0)),
6895 (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6896 def : Pat<(insert_subvector undef, (v2i32 FPR64:$src), (Ty 0)),
6897 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6898 def : Pat<(insert_subvector undef, (v2f32 FPR64:$src), (Ty 0)),
6899 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6900 def : Pat<(insert_subvector undef, (v4i16 FPR64:$src), (Ty 0)),
6901 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6902 def : Pat<(insert_subvector undef, (v4f16 FPR64:$src), (Ty 0)),
6903 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6904 def : Pat<(insert_subvector undef, (v8i8 FPR64:$src), (Ty 0)),
6905 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6908 defm : InsertSubvectorUndef<i32>;
6909 defm : InsertSubvectorUndef<i64>;
6911 // Use pair-wise add instructions when summing up the lanes for v2f64, v2i64
6913 def : Pat<(i64 (add (vector_extract (v2i64 FPR128:$Rn), (i64 0)),
6914 (vector_extract (v2i64 FPR128:$Rn), (i64 1)))),
6915 (i64 (ADDPv2i64p (v2i64 FPR128:$Rn)))>;
6916 def : Pat<(f64 (fadd (vector_extract (v2f64 FPR128:$Rn), (i64 0)),
6917 (vector_extract (v2f64 FPR128:$Rn), (i64 1)))),
6918 (f64 (FADDPv2i64p (v2f64 FPR128:$Rn)))>;
6919 // vector_extract on 64-bit vectors gets promoted to a 128 bit vector,
6920 // so we match on v4f32 here, not v2f32. This will also catch adding
6921 // the low two lanes of a true v4f32 vector.
6922 def : Pat<(fadd (vector_extract (v4f32 FPR128:$Rn), (i64 0)),
6923 (vector_extract (v4f32 FPR128:$Rn), (i64 1))),
6924 (f32 (FADDPv2i32p (EXTRACT_SUBREG FPR128:$Rn, dsub)))>;
6926 // Scalar 64-bit shifts in FPR64 registers.
6927 def : Pat<(i64 (int_aarch64_neon_sshl (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
6928 (SSHLv1i64 FPR64:$Rn, FPR64:$Rm)>;
6929 def : Pat<(i64 (int_aarch64_neon_ushl (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
6930 (USHLv1i64 FPR64:$Rn, FPR64:$Rm)>;
6931 def : Pat<(i64 (int_aarch64_neon_srshl (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
6932 (SRSHLv1i64 FPR64:$Rn, FPR64:$Rm)>;
6933 def : Pat<(i64 (int_aarch64_neon_urshl (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
6934 (URSHLv1i64 FPR64:$Rn, FPR64:$Rm)>;
6936 // Patterns for nontemporal/no-allocate stores.
6937 // We have to resort to tricks to turn a single-input store into a store pair,
6938 // because there is no single-input nontemporal store, only STNP.
6939 let Predicates = [IsLE] in {
6940 let AddedComplexity = 15 in {
6941 class NTStore128Pat<ValueType VT> :
6942 Pat<(nontemporalstore (VT FPR128:$Rt),
6943 (am_indexed7s64 GPR64sp:$Rn, simm7s8:$offset)),
6944 (STNPDi (EXTRACT_SUBREG FPR128:$Rt, dsub),
6945 (CPYi64 FPR128:$Rt, (i64 1)),
6946 GPR64sp:$Rn, simm7s8:$offset)>;
6948 def : NTStore128Pat<v2i64>;
6949 def : NTStore128Pat<v4i32>;
6950 def : NTStore128Pat<v8i16>;
6951 def : NTStore128Pat<v16i8>;
6953 class NTStore64Pat<ValueType VT> :
6954 Pat<(nontemporalstore (VT FPR64:$Rt),
6955 (am_indexed7s32 GPR64sp:$Rn, simm7s4:$offset)),
6956 (STNPSi (EXTRACT_SUBREG FPR64:$Rt, ssub),
6957 (CPYi32 (SUBREG_TO_REG (i64 0), FPR64:$Rt, dsub), (i64 1)),
6958 GPR64sp:$Rn, simm7s4:$offset)>;
6960 // FIXME: Shouldn't v1f64 loads/stores be promoted to v1i64?
6961 def : NTStore64Pat<v1f64>;
6962 def : NTStore64Pat<v1i64>;
6963 def : NTStore64Pat<v2i32>;
6964 def : NTStore64Pat<v4i16>;
6965 def : NTStore64Pat<v8i8>;
6967 def : Pat<(nontemporalstore GPR64:$Rt,
6968 (am_indexed7s32 GPR64sp:$Rn, simm7s4:$offset)),
6969 (STNPWi (EXTRACT_SUBREG GPR64:$Rt, sub_32),
6970 (EXTRACT_SUBREG (UBFMXri GPR64:$Rt, 32, 63), sub_32),
6971 GPR64sp:$Rn, simm7s4:$offset)>;
6972 } // AddedComplexity=10
6973 } // Predicates = [IsLE]
6975 // Tail call return handling. These are all compiler pseudo-instructions,
6976 // so no encoding information or anything like that.
6977 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in {
6978 def TCRETURNdi : Pseudo<(outs), (ins i64imm:$dst, i32imm:$FPDiff), []>,
6979 Sched<[WriteBrReg]>;
6980 def TCRETURNri : Pseudo<(outs), (ins tcGPR64:$dst, i32imm:$FPDiff), []>,
6981 Sched<[WriteBrReg]>;
6982 // Indirect tail-call with any register allowed, used by MachineOutliner when
6983 // this is proven safe.
6984 // FIXME: If we have to add any more hacks like this, we should instead relax
6985 // some verifier checks for outlined functions.
6986 def TCRETURNriALL : Pseudo<(outs), (ins GPR64:$dst, i32imm:$FPDiff), []>,
6987 Sched<[WriteBrReg]>;
6988 // Indirect tail-call limited to only use registers (x16 and x17) which are
6989 // allowed to tail-call a "BTI c" instruction.
6990 def TCRETURNriBTI : Pseudo<(outs), (ins rtcGPR64:$dst, i32imm:$FPDiff), []>,
6991 Sched<[WriteBrReg]>;
6994 def : Pat<(AArch64tcret tcGPR64:$dst, (i32 timm:$FPDiff)),
6995 (TCRETURNri tcGPR64:$dst, imm:$FPDiff)>,
6996 Requires<[NotUseBTI]>;
6997 def : Pat<(AArch64tcret rtcGPR64:$dst, (i32 timm:$FPDiff)),
6998 (TCRETURNriBTI rtcGPR64:$dst, imm:$FPDiff)>,
7000 def : Pat<(AArch64tcret tglobaladdr:$dst, (i32 timm:$FPDiff)),
7001 (TCRETURNdi texternalsym:$dst, imm:$FPDiff)>;
7002 def : Pat<(AArch64tcret texternalsym:$dst, (i32 timm:$FPDiff)),
7003 (TCRETURNdi texternalsym:$dst, imm:$FPDiff)>;
7005 def MOVMCSym : Pseudo<(outs GPR64:$dst), (ins i64imm:$sym), []>, Sched<[]>;
7006 def : Pat<(i64 (AArch64LocalRecover mcsym:$sym)), (MOVMCSym mcsym:$sym)>;
7008 // Extracting lane zero is a special case where we can just use a plain
7009 // EXTRACT_SUBREG instruction, which will become FMOV. This is easier for the
7010 // rest of the compiler, especially the register allocator and copy propagation,
7011 // to reason about, so is preferred when it's possible to use it.
7012 let AddedComplexity = 10 in {
7013 def : Pat<(i64 (extractelt (v2i64 V128:$V), (i64 0))), (EXTRACT_SUBREG V128:$V, dsub)>;
7014 def : Pat<(i32 (extractelt (v4i32 V128:$V), (i64 0))), (EXTRACT_SUBREG V128:$V, ssub)>;
7015 def : Pat<(i32 (extractelt (v2i32 V64:$V), (i64 0))), (EXTRACT_SUBREG V64:$V, ssub)>;
7019 class mul_v4i8<SDPatternOperator ldop> :
7020 PatFrag<(ops node:$Rn, node:$Rm, node:$offset),
7021 (mul (ldop (add node:$Rn, node:$offset)),
7022 (ldop (add node:$Rm, node:$offset)))>;
7023 class mulz_v4i8<SDPatternOperator ldop> :
7024 PatFrag<(ops node:$Rn, node:$Rm),
7025 (mul (ldop node:$Rn), (ldop node:$Rm))>;
7028 OutPatFrag<(ops node:$R),
7030 (v2i32 (IMPLICIT_DEF)),
7031 (i32 (COPY_TO_REGCLASS (LDRWui node:$R, (i64 0)), FPR32)),
7034 class dot_v4i8<Instruction DOT, SDPatternOperator ldop> :
7035 Pat<(i32 (add (mul_v4i8<ldop> GPR64sp:$Rn, GPR64sp:$Rm, (i64 3)),
7036 (add (mul_v4i8<ldop> GPR64sp:$Rn, GPR64sp:$Rm, (i64 2)),
7037 (add (mul_v4i8<ldop> GPR64sp:$Rn, GPR64sp:$Rm, (i64 1)),
7038 (mulz_v4i8<ldop> GPR64sp:$Rn, GPR64sp:$Rm))))),
7039 (EXTRACT_SUBREG (i64 (DOT (DUPv2i32gpr WZR),
7040 (load_v4i8 GPR64sp:$Rn),
7041 (load_v4i8 GPR64sp:$Rm))),
7042 sub_32)>, Requires<[HasDotProd]>;
7045 class ee_v8i8<SDPatternOperator extend> :
7046 PatFrag<(ops node:$V, node:$K),
7047 (v4i16 (extract_subvector (v8i16 (extend node:$V)), node:$K))>;
7049 class mul_v8i8<SDPatternOperator mulop, SDPatternOperator extend> :
7050 PatFrag<(ops node:$M, node:$N, node:$K),
7051 (mulop (v4i16 (ee_v8i8<extend> node:$M, node:$K)),
7052 (v4i16 (ee_v8i8<extend> node:$N, node:$K)))>;
7054 class idot_v8i8<SDPatternOperator mulop, SDPatternOperator extend> :
7055 PatFrag<(ops node:$M, node:$N),
7057 (v4i32 (AArch64uaddv
7058 (add (mul_v8i8<mulop, extend> node:$M, node:$N, (i64 0)),
7059 (mul_v8i8<mulop, extend> node:$M, node:$N, (i64 4))))),
7062 // vaddv_[su]32 is special; -> ADDP Vd.2S,Vn.2S,Vm.2S; return Vd.s[0];Vn==Vm
7063 def VADDV_32 : OutPatFrag<(ops node:$R), (ADDPv2i32 node:$R, node:$R)>;
7065 class odot_v8i8<Instruction DOT> :
7066 OutPatFrag<(ops node:$Vm, node:$Vn),
7069 (i64 (DOT (DUPv2i32gpr WZR),
7074 class dot_v8i8<Instruction DOT, SDPatternOperator mulop,
7075 SDPatternOperator extend> :
7076 Pat<(idot_v8i8<mulop, extend> V64:$Vm, V64:$Vn),
7077 (odot_v8i8<DOT> V64:$Vm, V64:$Vn)>,
7078 Requires<[HasDotProd]>;
7081 class ee_v16i8<SDPatternOperator extend> :
7082 PatFrag<(ops node:$V, node:$K1, node:$K2),
7083 (v4i16 (extract_subvector
7085 (v8i8 (extract_subvector node:$V, node:$K1)))), node:$K2))>;
7087 class mul_v16i8<SDPatternOperator mulop, SDPatternOperator extend> :
7088 PatFrag<(ops node:$M, node:$N, node:$K1, node:$K2),
7090 (mulop (v4i16 (ee_v16i8<extend> node:$M, node:$K1, node:$K2)),
7091 (v4i16 (ee_v16i8<extend> node:$N, node:$K1, node:$K2))))>;
7093 class idot_v16i8<SDPatternOperator m, SDPatternOperator x> :
7094 PatFrag<(ops node:$M, node:$N),
7096 (v4i32 (AArch64uaddv
7098 (add (mul_v16i8<m, x> node:$M, node:$N, (i64 0), (i64 0)),
7099 (mul_v16i8<m, x> node:$M, node:$N, (i64 8), (i64 0))),
7100 (add (mul_v16i8<m, x> node:$M, node:$N, (i64 0), (i64 4)),
7101 (mul_v16i8<m, x> node:$M, node:$N, (i64 8), (i64 4)))))),
7104 class odot_v16i8<Instruction DOT> :
7105 OutPatFrag<(ops node:$Vm, node:$Vn),
7107 (DOT (DUPv4i32gpr WZR), node:$Vm, node:$Vn)))>;
7109 class dot_v16i8<Instruction DOT, SDPatternOperator mulop,
7110 SDPatternOperator extend> :
7111 Pat<(idot_v16i8<mulop, extend> V128:$Vm, V128:$Vn),
7112 (odot_v16i8<DOT> V128:$Vm, V128:$Vn)>,
7113 Requires<[HasDotProd]>;
7115 let AddedComplexity = 10 in {
7116 def : dot_v4i8<SDOTv8i8, sextloadi8>;
7117 def : dot_v4i8<UDOTv8i8, zextloadi8>;
7118 def : dot_v8i8<SDOTv8i8, AArch64smull, sext>;
7119 def : dot_v8i8<UDOTv8i8, AArch64umull, zext>;
7120 def : dot_v16i8<SDOTv16i8, AArch64smull, sext>;
7121 def : dot_v16i8<UDOTv16i8, AArch64umull, zext>;
7123 // FIXME: add patterns to generate vector by element dot product.
7124 // FIXME: add SVE dot-product patterns.
7127 include "AArch64InstrAtomics.td"
7128 include "AArch64SVEInstrInfo.td"