1 //=- AArch64InstrInfo.td - Describe the AArch64 Instructions -*- tablegen -*-=//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // AArch64 Instruction definitions.
11 //===----------------------------------------------------------------------===//
13 //===----------------------------------------------------------------------===//
14 // ARM Instruction Predicate Definitions.
16 def HasV8_1a : Predicate<"Subtarget->hasV8_1aOps()">,
17 AssemblerPredicate<"HasV8_1aOps", "armv8.1a">;
18 def HasV8_2a : Predicate<"Subtarget->hasV8_2aOps()">,
19 AssemblerPredicate<"HasV8_2aOps", "armv8.2a">;
20 def HasV8_3a : Predicate<"Subtarget->hasV8_3aOps()">,
21 AssemblerPredicate<"HasV8_3aOps", "armv8.3a">;
22 def HasV8_4a : Predicate<"Subtarget->hasV8_4aOps()">,
23 AssemblerPredicate<"HasV8_4aOps", "armv8.4a">;
24 def HasV8_5a : Predicate<"Subtarget->hasV8_5aOps()">,
25 AssemblerPredicate<"HasV8_5aOps", "armv8.5a">;
26 def HasVH : Predicate<"Subtarget->hasVH()">,
27 AssemblerPredicate<"FeatureVH", "vh">;
29 def HasLOR : Predicate<"Subtarget->hasLOR()">,
30 AssemblerPredicate<"FeatureLOR", "lor">;
32 def HasPA : Predicate<"Subtarget->hasPA()">,
33 AssemblerPredicate<"FeaturePA", "pa">;
35 def HasJS : Predicate<"Subtarget->hasJS()">,
36 AssemblerPredicate<"FeatureJS", "jsconv">;
38 def HasCCIDX : Predicate<"Subtarget->hasCCIDX()">,
39 AssemblerPredicate<"FeatureCCIDX", "ccidx">;
41 def HasComplxNum : Predicate<"Subtarget->hasComplxNum()">,
42 AssemblerPredicate<"FeatureComplxNum", "complxnum">;
44 def HasNV : Predicate<"Subtarget->hasNV()">,
45 AssemblerPredicate<"FeatureNV", "nv">;
47 def HasRASv8_4 : Predicate<"Subtarget->hasRASv8_4()">,
48 AssemblerPredicate<"FeatureRASv8_4", "rasv8_4">;
50 def HasMPAM : Predicate<"Subtarget->hasMPAM()">,
51 AssemblerPredicate<"FeatureMPAM", "mpam">;
53 def HasDIT : Predicate<"Subtarget->hasDIT()">,
54 AssemblerPredicate<"FeatureDIT", "dit">;
56 def HasTRACEV8_4 : Predicate<"Subtarget->hasTRACEV8_4()">,
57 AssemblerPredicate<"FeatureTRACEV8_4", "tracev8.4">;
59 def HasAM : Predicate<"Subtarget->hasAM()">,
60 AssemblerPredicate<"FeatureAM", "am">;
62 def HasSEL2 : Predicate<"Subtarget->hasSEL2()">,
63 AssemblerPredicate<"FeatureSEL2", "sel2">;
65 def HasTLB_RMI : Predicate<"Subtarget->hasTLB_RMI()">,
66 AssemblerPredicate<"FeatureTLB_RMI", "tlb-rmi">;
68 def HasFMI : Predicate<"Subtarget->hasFMI()">,
69 AssemblerPredicate<"FeatureFMI", "fmi">;
71 def HasRCPC_IMMO : Predicate<"Subtarget->hasRCPCImm()">,
72 AssemblerPredicate<"FeatureRCPC_IMMO", "rcpc-immo">;
74 def HasFPARMv8 : Predicate<"Subtarget->hasFPARMv8()">,
75 AssemblerPredicate<"FeatureFPARMv8", "fp-armv8">;
76 def HasNEON : Predicate<"Subtarget->hasNEON()">,
77 AssemblerPredicate<"FeatureNEON", "neon">;
78 def HasCrypto : Predicate<"Subtarget->hasCrypto()">,
79 AssemblerPredicate<"FeatureCrypto", "crypto">;
80 def HasSM4 : Predicate<"Subtarget->hasSM4()">,
81 AssemblerPredicate<"FeatureSM4", "sm4">;
82 def HasSHA3 : Predicate<"Subtarget->hasSHA3()">,
83 AssemblerPredicate<"FeatureSHA3", "sha3">;
84 def HasSHA2 : Predicate<"Subtarget->hasSHA2()">,
85 AssemblerPredicate<"FeatureSHA2", "sha2">;
86 def HasAES : Predicate<"Subtarget->hasAES()">,
87 AssemblerPredicate<"FeatureAES", "aes">;
88 def HasDotProd : Predicate<"Subtarget->hasDotProd()">,
89 AssemblerPredicate<"FeatureDotProd", "dotprod">;
90 def HasCRC : Predicate<"Subtarget->hasCRC()">,
91 AssemblerPredicate<"FeatureCRC", "crc">;
92 def HasLSE : Predicate<"Subtarget->hasLSE()">,
93 AssemblerPredicate<"FeatureLSE", "lse">;
94 def HasRAS : Predicate<"Subtarget->hasRAS()">,
95 AssemblerPredicate<"FeatureRAS", "ras">;
96 def HasRDM : Predicate<"Subtarget->hasRDM()">,
97 AssemblerPredicate<"FeatureRDM", "rdm">;
98 def HasPerfMon : Predicate<"Subtarget->hasPerfMon()">;
99 def HasFullFP16 : Predicate<"Subtarget->hasFullFP16()">,
100 AssemblerPredicate<"FeatureFullFP16", "fullfp16">;
101 def HasFP16FML : Predicate<"Subtarget->hasFP16FML()">,
102 AssemblerPredicate<"FeatureFP16FML", "fp16fml">;
103 def HasSPE : Predicate<"Subtarget->hasSPE()">,
104 AssemblerPredicate<"FeatureSPE", "spe">;
105 def HasFuseAES : Predicate<"Subtarget->hasFuseAES()">,
106 AssemblerPredicate<"FeatureFuseAES",
108 def HasSVE : Predicate<"Subtarget->hasSVE()">,
109 AssemblerPredicate<"FeatureSVE", "sve">;
110 def HasSVE2 : Predicate<"Subtarget->hasSVE2()">,
111 AssemblerPredicate<"FeatureSVE2", "sve2">;
112 def HasSVE2AES : Predicate<"Subtarget->hasSVE2AES()">,
113 AssemblerPredicate<"FeatureSVE2AES", "sve2-aes">;
114 def HasSVE2SM4 : Predicate<"Subtarget->hasSVE2SM4()">,
115 AssemblerPredicate<"FeatureSVE2SM4", "sve2-sm4">;
116 def HasSVE2SHA3 : Predicate<"Subtarget->hasSVE2SHA3()">,
117 AssemblerPredicate<"FeatureSVE2SHA3", "sve2-sha3">;
118 def HasSVE2BitPerm : Predicate<"Subtarget->hasSVE2BitPerm()">,
119 AssemblerPredicate<"FeatureSVE2BitPerm", "sve2-bitperm">;
120 def HasRCPC : Predicate<"Subtarget->hasRCPC()">,
121 AssemblerPredicate<"FeatureRCPC", "rcpc">;
122 def HasAltNZCV : Predicate<"Subtarget->hasAlternativeNZCV()">,
123 AssemblerPredicate<"FeatureAltFPCmp", "altnzcv">;
124 def HasFRInt3264 : Predicate<"Subtarget->hasFRInt3264()">,
125 AssemblerPredicate<"FeatureFRInt3264", "frint3264">;
126 def HasSB : Predicate<"Subtarget->hasSB()">,
127 AssemblerPredicate<"FeatureSB", "sb">;
128 def HasPredRes : Predicate<"Subtarget->hasPredRes()">,
129 AssemblerPredicate<"FeaturePredRes", "predres">;
130 def HasCCDP : Predicate<"Subtarget->hasCCDP()">,
131 AssemblerPredicate<"FeatureCacheDeepPersist", "ccdp">;
132 def HasBTI : Predicate<"Subtarget->hasBTI()">,
133 AssemblerPredicate<"FeatureBranchTargetId", "bti">;
134 def HasMTE : Predicate<"Subtarget->hasMTE()">,
135 AssemblerPredicate<"FeatureMTE", "mte">;
136 def HasTME : Predicate<"Subtarget->hasTME()">,
137 AssemblerPredicate<"FeatureTME", "tme">;
138 def HasETE : Predicate<"Subtarget->hasETE()">,
139 AssemblerPredicate<"FeatureETE", "ete">;
140 def HasTRBE : Predicate<"Subtarget->hasTRBE()">,
141 AssemblerPredicate<"FeatureTRBE", "trbe">;
142 def IsLE : Predicate<"Subtarget->isLittleEndian()">;
143 def IsBE : Predicate<"!Subtarget->isLittleEndian()">;
144 def IsWindows : Predicate<"Subtarget->isTargetWindows()">;
145 def UseAlternateSExtLoadCVTF32
146 : Predicate<"Subtarget->useAlternateSExtLoadCVTF32Pattern()">;
148 def UseNegativeImmediates
149 : Predicate<"false">, AssemblerPredicate<"!FeatureNoNegativeImmediates",
150 "NegativeImmediates">;
152 def AArch64LocalRecover : SDNode<"ISD::LOCAL_RECOVER",
153 SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>,
157 //===----------------------------------------------------------------------===//
158 // AArch64-specific DAG Nodes.
161 // SDTBinaryArithWithFlagsOut - RES1, FLAGS = op LHS, RHS
162 def SDTBinaryArithWithFlagsOut : SDTypeProfile<2, 2,
165 SDTCisInt<0>, SDTCisVT<1, i32>]>;
167 // SDTBinaryArithWithFlagsIn - RES1, FLAGS = op LHS, RHS, FLAGS
168 def SDTBinaryArithWithFlagsIn : SDTypeProfile<1, 3,
174 // SDTBinaryArithWithFlagsInOut - RES1, FLAGS = op LHS, RHS, FLAGS
175 def SDTBinaryArithWithFlagsInOut : SDTypeProfile<2, 3,
182 def SDT_AArch64Brcond : SDTypeProfile<0, 3,
183 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i32>,
185 def SDT_AArch64cbz : SDTypeProfile<0, 2, [SDTCisInt<0>, SDTCisVT<1, OtherVT>]>;
186 def SDT_AArch64tbz : SDTypeProfile<0, 3, [SDTCisInt<0>, SDTCisInt<1>,
187 SDTCisVT<2, OtherVT>]>;
190 def SDT_AArch64CSel : SDTypeProfile<1, 4,
195 def SDT_AArch64CCMP : SDTypeProfile<1, 5,
202 def SDT_AArch64FCCMP : SDTypeProfile<1, 5,
209 def SDT_AArch64FCmp : SDTypeProfile<0, 2,
211 SDTCisSameAs<0, 1>]>;
212 def SDT_AArch64Dup : SDTypeProfile<1, 1, [SDTCisVec<0>]>;
213 def SDT_AArch64DupLane : SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisInt<2>]>;
214 def SDT_AArch64Zip : SDTypeProfile<1, 2, [SDTCisVec<0>,
216 SDTCisSameAs<0, 2>]>;
217 def SDT_AArch64MOVIedit : SDTypeProfile<1, 1, [SDTCisInt<1>]>;
218 def SDT_AArch64MOVIshift : SDTypeProfile<1, 2, [SDTCisInt<1>, SDTCisInt<2>]>;
219 def SDT_AArch64vecimm : SDTypeProfile<1, 3, [SDTCisVec<0>, SDTCisSameAs<0,1>,
220 SDTCisInt<2>, SDTCisInt<3>]>;
221 def SDT_AArch64UnaryVec: SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisSameAs<0,1>]>;
222 def SDT_AArch64ExtVec: SDTypeProfile<1, 3, [SDTCisVec<0>, SDTCisSameAs<0,1>,
223 SDTCisSameAs<0,2>, SDTCisInt<3>]>;
224 def SDT_AArch64vshift : SDTypeProfile<1, 2, [SDTCisSameAs<0,1>, SDTCisInt<2>]>;
226 def SDT_AArch64unvec : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisSameAs<0,1>]>;
227 def SDT_AArch64fcmpz : SDTypeProfile<1, 1, []>;
228 def SDT_AArch64fcmp : SDTypeProfile<1, 2, [SDTCisSameAs<1,2>]>;
229 def SDT_AArch64binvec : SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisSameAs<0,1>,
231 def SDT_AArch64trivec : SDTypeProfile<1, 3, [SDTCisVec<0>, SDTCisSameAs<0,1>,
234 def SDT_AArch64TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>]>;
235 def SDT_AArch64PREFETCH : SDTypeProfile<0, 2, [SDTCisVT<0, i32>, SDTCisPtrTy<1>]>;
237 def SDT_AArch64ITOF : SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisSameAs<0,1>]>;
239 def SDT_AArch64TLSDescCall : SDTypeProfile<0, -2, [SDTCisPtrTy<0>,
242 // Generates the general dynamic sequences, i.e.
243 // adrp x0, :tlsdesc:var
244 // ldr x1, [x0, #:tlsdesc_lo12:var]
245 // add x0, x0, #:tlsdesc_lo12:var
249 // (the TPIDR_EL0 offset is put directly in X0, hence no "result" here)
250 // number of operands (the variable)
251 def SDT_AArch64TLSDescCallSeq : SDTypeProfile<0,1,
254 def SDT_AArch64WrapperLarge : SDTypeProfile<1, 4,
255 [SDTCisVT<0, i64>, SDTCisVT<1, i32>,
256 SDTCisSameAs<1, 2>, SDTCisSameAs<1, 3>,
257 SDTCisSameAs<1, 4>]>;
261 def AArch64adrp : SDNode<"AArch64ISD::ADRP", SDTIntUnaryOp, []>;
262 def AArch64adr : SDNode<"AArch64ISD::ADR", SDTIntUnaryOp, []>;
263 def AArch64addlow : SDNode<"AArch64ISD::ADDlow", SDTIntBinOp, []>;
264 def AArch64LOADgot : SDNode<"AArch64ISD::LOADgot", SDTIntUnaryOp>;
265 def AArch64callseq_start : SDNode<"ISD::CALLSEQ_START",
266 SDCallSeqStart<[ SDTCisVT<0, i32>,
268 [SDNPHasChain, SDNPOutGlue]>;
269 def AArch64callseq_end : SDNode<"ISD::CALLSEQ_END",
270 SDCallSeqEnd<[ SDTCisVT<0, i32>,
272 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
273 def AArch64call : SDNode<"AArch64ISD::CALL",
274 SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>,
275 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
277 def AArch64brcond : SDNode<"AArch64ISD::BRCOND", SDT_AArch64Brcond,
279 def AArch64cbz : SDNode<"AArch64ISD::CBZ", SDT_AArch64cbz,
281 def AArch64cbnz : SDNode<"AArch64ISD::CBNZ", SDT_AArch64cbz,
283 def AArch64tbz : SDNode<"AArch64ISD::TBZ", SDT_AArch64tbz,
285 def AArch64tbnz : SDNode<"AArch64ISD::TBNZ", SDT_AArch64tbz,
289 def AArch64csel : SDNode<"AArch64ISD::CSEL", SDT_AArch64CSel>;
290 def AArch64csinv : SDNode<"AArch64ISD::CSINV", SDT_AArch64CSel>;
291 def AArch64csneg : SDNode<"AArch64ISD::CSNEG", SDT_AArch64CSel>;
292 def AArch64csinc : SDNode<"AArch64ISD::CSINC", SDT_AArch64CSel>;
293 def AArch64retflag : SDNode<"AArch64ISD::RET_FLAG", SDTNone,
294 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
295 def AArch64adc : SDNode<"AArch64ISD::ADC", SDTBinaryArithWithFlagsIn >;
296 def AArch64sbc : SDNode<"AArch64ISD::SBC", SDTBinaryArithWithFlagsIn>;
297 def AArch64add_flag : SDNode<"AArch64ISD::ADDS", SDTBinaryArithWithFlagsOut,
299 def AArch64sub_flag : SDNode<"AArch64ISD::SUBS", SDTBinaryArithWithFlagsOut>;
300 def AArch64and_flag : SDNode<"AArch64ISD::ANDS", SDTBinaryArithWithFlagsOut,
302 def AArch64adc_flag : SDNode<"AArch64ISD::ADCS", SDTBinaryArithWithFlagsInOut>;
303 def AArch64sbc_flag : SDNode<"AArch64ISD::SBCS", SDTBinaryArithWithFlagsInOut>;
305 def AArch64ccmp : SDNode<"AArch64ISD::CCMP", SDT_AArch64CCMP>;
306 def AArch64ccmn : SDNode<"AArch64ISD::CCMN", SDT_AArch64CCMP>;
307 def AArch64fccmp : SDNode<"AArch64ISD::FCCMP", SDT_AArch64FCCMP>;
309 def AArch64threadpointer : SDNode<"AArch64ISD::THREAD_POINTER", SDTPtrLeaf>;
311 def AArch64fcmp : SDNode<"AArch64ISD::FCMP", SDT_AArch64FCmp>;
313 def AArch64dup : SDNode<"AArch64ISD::DUP", SDT_AArch64Dup>;
314 def AArch64duplane8 : SDNode<"AArch64ISD::DUPLANE8", SDT_AArch64DupLane>;
315 def AArch64duplane16 : SDNode<"AArch64ISD::DUPLANE16", SDT_AArch64DupLane>;
316 def AArch64duplane32 : SDNode<"AArch64ISD::DUPLANE32", SDT_AArch64DupLane>;
317 def AArch64duplane64 : SDNode<"AArch64ISD::DUPLANE64", SDT_AArch64DupLane>;
319 def AArch64zip1 : SDNode<"AArch64ISD::ZIP1", SDT_AArch64Zip>;
320 def AArch64zip2 : SDNode<"AArch64ISD::ZIP2", SDT_AArch64Zip>;
321 def AArch64uzp1 : SDNode<"AArch64ISD::UZP1", SDT_AArch64Zip>;
322 def AArch64uzp2 : SDNode<"AArch64ISD::UZP2", SDT_AArch64Zip>;
323 def AArch64trn1 : SDNode<"AArch64ISD::TRN1", SDT_AArch64Zip>;
324 def AArch64trn2 : SDNode<"AArch64ISD::TRN2", SDT_AArch64Zip>;
326 def AArch64movi_edit : SDNode<"AArch64ISD::MOVIedit", SDT_AArch64MOVIedit>;
327 def AArch64movi_shift : SDNode<"AArch64ISD::MOVIshift", SDT_AArch64MOVIshift>;
328 def AArch64movi_msl : SDNode<"AArch64ISD::MOVImsl", SDT_AArch64MOVIshift>;
329 def AArch64mvni_shift : SDNode<"AArch64ISD::MVNIshift", SDT_AArch64MOVIshift>;
330 def AArch64mvni_msl : SDNode<"AArch64ISD::MVNImsl", SDT_AArch64MOVIshift>;
331 def AArch64movi : SDNode<"AArch64ISD::MOVI", SDT_AArch64MOVIedit>;
332 def AArch64fmov : SDNode<"AArch64ISD::FMOV", SDT_AArch64MOVIedit>;
334 def AArch64rev16 : SDNode<"AArch64ISD::REV16", SDT_AArch64UnaryVec>;
335 def AArch64rev32 : SDNode<"AArch64ISD::REV32", SDT_AArch64UnaryVec>;
336 def AArch64rev64 : SDNode<"AArch64ISD::REV64", SDT_AArch64UnaryVec>;
337 def AArch64ext : SDNode<"AArch64ISD::EXT", SDT_AArch64ExtVec>;
339 def AArch64vashr : SDNode<"AArch64ISD::VASHR", SDT_AArch64vshift>;
340 def AArch64vlshr : SDNode<"AArch64ISD::VLSHR", SDT_AArch64vshift>;
341 def AArch64vshl : SDNode<"AArch64ISD::VSHL", SDT_AArch64vshift>;
342 def AArch64sqshli : SDNode<"AArch64ISD::SQSHL_I", SDT_AArch64vshift>;
343 def AArch64uqshli : SDNode<"AArch64ISD::UQSHL_I", SDT_AArch64vshift>;
344 def AArch64sqshlui : SDNode<"AArch64ISD::SQSHLU_I", SDT_AArch64vshift>;
345 def AArch64srshri : SDNode<"AArch64ISD::SRSHR_I", SDT_AArch64vshift>;
346 def AArch64urshri : SDNode<"AArch64ISD::URSHR_I", SDT_AArch64vshift>;
348 def AArch64not: SDNode<"AArch64ISD::NOT", SDT_AArch64unvec>;
349 def AArch64bit: SDNode<"AArch64ISD::BIT", SDT_AArch64trivec>;
350 def AArch64bsl: SDNode<"AArch64ISD::BSL", SDT_AArch64trivec>;
352 def AArch64cmeq: SDNode<"AArch64ISD::CMEQ", SDT_AArch64binvec>;
353 def AArch64cmge: SDNode<"AArch64ISD::CMGE", SDT_AArch64binvec>;
354 def AArch64cmgt: SDNode<"AArch64ISD::CMGT", SDT_AArch64binvec>;
355 def AArch64cmhi: SDNode<"AArch64ISD::CMHI", SDT_AArch64binvec>;
356 def AArch64cmhs: SDNode<"AArch64ISD::CMHS", SDT_AArch64binvec>;
358 def AArch64fcmeq: SDNode<"AArch64ISD::FCMEQ", SDT_AArch64fcmp>;
359 def AArch64fcmge: SDNode<"AArch64ISD::FCMGE", SDT_AArch64fcmp>;
360 def AArch64fcmgt: SDNode<"AArch64ISD::FCMGT", SDT_AArch64fcmp>;
362 def AArch64cmeqz: SDNode<"AArch64ISD::CMEQz", SDT_AArch64unvec>;
363 def AArch64cmgez: SDNode<"AArch64ISD::CMGEz", SDT_AArch64unvec>;
364 def AArch64cmgtz: SDNode<"AArch64ISD::CMGTz", SDT_AArch64unvec>;
365 def AArch64cmlez: SDNode<"AArch64ISD::CMLEz", SDT_AArch64unvec>;
366 def AArch64cmltz: SDNode<"AArch64ISD::CMLTz", SDT_AArch64unvec>;
367 def AArch64cmtst : PatFrag<(ops node:$LHS, node:$RHS),
368 (AArch64not (AArch64cmeqz (and node:$LHS, node:$RHS)))>;
370 def AArch64fcmeqz: SDNode<"AArch64ISD::FCMEQz", SDT_AArch64fcmpz>;
371 def AArch64fcmgez: SDNode<"AArch64ISD::FCMGEz", SDT_AArch64fcmpz>;
372 def AArch64fcmgtz: SDNode<"AArch64ISD::FCMGTz", SDT_AArch64fcmpz>;
373 def AArch64fcmlez: SDNode<"AArch64ISD::FCMLEz", SDT_AArch64fcmpz>;
374 def AArch64fcmltz: SDNode<"AArch64ISD::FCMLTz", SDT_AArch64fcmpz>;
376 def AArch64bici: SDNode<"AArch64ISD::BICi", SDT_AArch64vecimm>;
377 def AArch64orri: SDNode<"AArch64ISD::ORRi", SDT_AArch64vecimm>;
379 def AArch64neg : SDNode<"AArch64ISD::NEG", SDT_AArch64unvec>;
381 def AArch64tcret: SDNode<"AArch64ISD::TC_RETURN", SDT_AArch64TCRET,
382 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
384 def AArch64Prefetch : SDNode<"AArch64ISD::PREFETCH", SDT_AArch64PREFETCH,
385 [SDNPHasChain, SDNPSideEffect]>;
387 def AArch64sitof: SDNode<"AArch64ISD::SITOF", SDT_AArch64ITOF>;
388 def AArch64uitof: SDNode<"AArch64ISD::UITOF", SDT_AArch64ITOF>;
390 def AArch64tlsdesc_callseq : SDNode<"AArch64ISD::TLSDESC_CALLSEQ",
391 SDT_AArch64TLSDescCallSeq,
392 [SDNPInGlue, SDNPOutGlue, SDNPHasChain,
396 def AArch64WrapperLarge : SDNode<"AArch64ISD::WrapperLarge",
397 SDT_AArch64WrapperLarge>;
399 def AArch64NvCast : SDNode<"AArch64ISD::NVCAST", SDTUnaryOp>;
401 def SDT_AArch64mull : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisInt<1>,
402 SDTCisSameAs<1, 2>]>;
403 def AArch64smull : SDNode<"AArch64ISD::SMULL", SDT_AArch64mull>;
404 def AArch64umull : SDNode<"AArch64ISD::UMULL", SDT_AArch64mull>;
406 def AArch64frecpe : SDNode<"AArch64ISD::FRECPE", SDTFPUnaryOp>;
407 def AArch64frecps : SDNode<"AArch64ISD::FRECPS", SDTFPBinOp>;
408 def AArch64frsqrte : SDNode<"AArch64ISD::FRSQRTE", SDTFPUnaryOp>;
409 def AArch64frsqrts : SDNode<"AArch64ISD::FRSQRTS", SDTFPBinOp>;
411 def AArch64saddv : SDNode<"AArch64ISD::SADDV", SDT_AArch64UnaryVec>;
412 def AArch64uaddv : SDNode<"AArch64ISD::UADDV", SDT_AArch64UnaryVec>;
413 def AArch64sminv : SDNode<"AArch64ISD::SMINV", SDT_AArch64UnaryVec>;
414 def AArch64uminv : SDNode<"AArch64ISD::UMINV", SDT_AArch64UnaryVec>;
415 def AArch64smaxv : SDNode<"AArch64ISD::SMAXV", SDT_AArch64UnaryVec>;
416 def AArch64umaxv : SDNode<"AArch64ISD::UMAXV", SDT_AArch64UnaryVec>;
418 def SDT_AArch64SETTAG : SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisPtrTy<1>]>;
419 def AArch64stg : SDNode<"AArch64ISD::STG", SDT_AArch64SETTAG, [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
420 def AArch64stzg : SDNode<"AArch64ISD::STZG", SDT_AArch64SETTAG, [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
421 def AArch64st2g : SDNode<"AArch64ISD::ST2G", SDT_AArch64SETTAG, [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
422 def AArch64stz2g : SDNode<"AArch64ISD::STZ2G", SDT_AArch64SETTAG, [SDNPHasChain, SDNPMayStore, SDNPMemOperand]>;
424 //===----------------------------------------------------------------------===//
426 //===----------------------------------------------------------------------===//
428 // AArch64 Instruction Predicate Definitions.
429 // We could compute these on a per-module basis but doing so requires accessing
430 // the Function object through the <Target>Subtarget and objections were raised
431 // to that (see post-commit review comments for r301750).
432 let RecomputePerFunction = 1 in {
433 def ForCodeSize : Predicate<"MF->getFunction().hasOptSize()">;
434 def NotForCodeSize : Predicate<"!MF->getFunction().hasOptSize()">;
435 // Avoid generating STRQro if it is slow, unless we're optimizing for code size.
436 def UseSTRQro : Predicate<"!Subtarget->isSTRQroSlow() || MF->getFunction().hasOptSize()">;
438 def UseBTI : Predicate<[{ MF->getFunction().hasFnAttribute("branch-target-enforcement") }]>;
439 def NotUseBTI : Predicate<[{ !MF->getFunction().hasFnAttribute("branch-target-enforcement") }]>;
441 // Toggles patterns which aren't beneficial in GlobalISel when we aren't
442 // optimizing. This allows us to selectively use patterns without impacting
443 // SelectionDAG's behaviour.
444 // FIXME: One day there will probably be a nicer way to check for this, but
445 // today is not that day.
446 def OptimizedGISelOrOtherSelector : Predicate<"!MF->getFunction().hasOptNone() || MF->getProperties().hasProperty(MachineFunctionProperties::Property::FailedISel) || !MF->getProperties().hasProperty(MachineFunctionProperties::Property::Legalized)">;
449 include "AArch64InstrFormats.td"
450 include "SVEInstrFormats.td"
452 //===----------------------------------------------------------------------===//
454 //===----------------------------------------------------------------------===//
455 // Miscellaneous instructions.
456 //===----------------------------------------------------------------------===//
458 let Defs = [SP], Uses = [SP], hasSideEffects = 1, isCodeGenOnly = 1 in {
459 // We set Sched to empty list because we expect these instructions to simply get
460 // removed in most cases.
461 def ADJCALLSTACKDOWN : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
462 [(AArch64callseq_start timm:$amt1, timm:$amt2)]>,
464 def ADJCALLSTACKUP : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
465 [(AArch64callseq_end timm:$amt1, timm:$amt2)]>,
467 } // Defs = [SP], Uses = [SP], hasSideEffects = 1, isCodeGenOnly = 1
469 let isReMaterializable = 1, isCodeGenOnly = 1 in {
470 // FIXME: The following pseudo instructions are only needed because remat
471 // cannot handle multiple instructions. When that changes, they can be
472 // removed, along with the AArch64Wrapper node.
474 let AddedComplexity = 10 in
475 def LOADgot : Pseudo<(outs GPR64:$dst), (ins i64imm:$addr),
476 [(set GPR64:$dst, (AArch64LOADgot tglobaladdr:$addr))]>,
479 // The MOVaddr instruction should match only when the add is not folded
480 // into a load or store address.
482 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
483 [(set GPR64:$dst, (AArch64addlow (AArch64adrp tglobaladdr:$hi),
484 tglobaladdr:$low))]>,
485 Sched<[WriteAdrAdr]>;
487 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
488 [(set GPR64:$dst, (AArch64addlow (AArch64adrp tjumptable:$hi),
490 Sched<[WriteAdrAdr]>;
492 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
493 [(set GPR64:$dst, (AArch64addlow (AArch64adrp tconstpool:$hi),
495 Sched<[WriteAdrAdr]>;
497 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
498 [(set GPR64:$dst, (AArch64addlow (AArch64adrp tblockaddress:$hi),
499 tblockaddress:$low))]>,
500 Sched<[WriteAdrAdr]>;
502 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
503 [(set GPR64:$dst, (AArch64addlow (AArch64adrp tglobaltlsaddr:$hi),
504 tglobaltlsaddr:$low))]>,
505 Sched<[WriteAdrAdr]>;
507 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
508 [(set GPR64:$dst, (AArch64addlow (AArch64adrp texternalsym:$hi),
509 texternalsym:$low))]>,
510 Sched<[WriteAdrAdr]>;
511 // Normally AArch64addlow either gets folded into a following ldr/str,
512 // or together with an adrp into MOVaddr above. For cases with TLS, it
513 // might appear without either of them, so allow lowering it into a plain
516 : Pseudo<(outs GPR64:$dst), (ins GPR64:$src, i64imm:$low),
517 [(set GPR64:$dst, (AArch64addlow GPR64:$src,
518 tglobaltlsaddr:$low))]>,
521 } // isReMaterializable, isCodeGenOnly
523 def : Pat<(AArch64LOADgot tglobaltlsaddr:$addr),
524 (LOADgot tglobaltlsaddr:$addr)>;
526 def : Pat<(AArch64LOADgot texternalsym:$addr),
527 (LOADgot texternalsym:$addr)>;
529 def : Pat<(AArch64LOADgot tconstpool:$addr),
530 (LOADgot tconstpool:$addr)>;
532 // 32-bit jump table destination is actually only 2 instructions since we can
533 // use the table itself as a PC-relative base. But optimization occurs after
534 // branch relaxation so be pessimistic.
535 let Size = 12, Constraints = "@earlyclobber $dst,@earlyclobber $scratch" in {
536 def JumpTableDest32 : Pseudo<(outs GPR64:$dst, GPR64sp:$scratch),
537 (ins GPR64:$table, GPR64:$entry, i32imm:$jti), []>,
539 def JumpTableDest16 : Pseudo<(outs GPR64:$dst, GPR64sp:$scratch),
540 (ins GPR64:$table, GPR64:$entry, i32imm:$jti), []>,
542 def JumpTableDest8 : Pseudo<(outs GPR64:$dst, GPR64sp:$scratch),
543 (ins GPR64:$table, GPR64:$entry, i32imm:$jti), []>,
547 // Space-consuming pseudo to aid testing of placement and reachability
548 // algorithms. Immediate operand is the number of bytes this "instruction"
549 // occupies; register operands can be used to enforce dependency and constrain
551 let hasSideEffects = 1, mayLoad = 1, mayStore = 1 in
552 def SPACE : Pseudo<(outs GPR64:$Rd), (ins i32imm:$size, GPR64:$Rn),
553 [(set GPR64:$Rd, (int_aarch64_space imm:$size, GPR64:$Rn))]>,
556 let hasSideEffects = 1, isCodeGenOnly = 1 in {
557 def SpeculationSafeValueX
558 : Pseudo<(outs GPR64:$dst), (ins GPR64:$src), []>, Sched<[]>;
559 def SpeculationSafeValueW
560 : Pseudo<(outs GPR32:$dst), (ins GPR32:$src), []>, Sched<[]>;
564 //===----------------------------------------------------------------------===//
565 // System instructions.
566 //===----------------------------------------------------------------------===//
568 def HINT : HintI<"hint">;
569 def : InstAlias<"nop", (HINT 0b000)>;
570 def : InstAlias<"yield",(HINT 0b001)>;
571 def : InstAlias<"wfe", (HINT 0b010)>;
572 def : InstAlias<"wfi", (HINT 0b011)>;
573 def : InstAlias<"sev", (HINT 0b100)>;
574 def : InstAlias<"sevl", (HINT 0b101)>;
575 def : InstAlias<"esb", (HINT 0b10000)>, Requires<[HasRAS]>;
576 def : InstAlias<"csdb", (HINT 20)>;
577 def : InstAlias<"bti", (HINT 32)>, Requires<[HasBTI]>;
578 def : InstAlias<"bti $op", (HINT btihint_op:$op)>, Requires<[HasBTI]>;
580 // v8.2a Statistical Profiling extension
581 def : InstAlias<"psb $op", (HINT psbhint_op:$op)>, Requires<[HasSPE]>;
583 // As far as LLVM is concerned this writes to the system's exclusive monitors.
584 let mayLoad = 1, mayStore = 1 in
585 def CLREX : CRmSystemI<imm0_15, 0b010, "clrex">;
587 // NOTE: ideally, this would have mayStore = 0, mayLoad = 0, but we cannot
588 // model patterns with sufficiently fine granularity.
589 let mayLoad = ?, mayStore = ? in {
590 def DMB : CRmSystemI<barrier_op, 0b101, "dmb",
591 [(int_aarch64_dmb (i32 imm32_0_15:$CRm))]>;
593 def DSB : CRmSystemI<barrier_op, 0b100, "dsb",
594 [(int_aarch64_dsb (i32 imm32_0_15:$CRm))]>;
596 def ISB : CRmSystemI<barrier_op, 0b110, "isb",
597 [(int_aarch64_isb (i32 imm32_0_15:$CRm))]>;
599 def TSB : CRmSystemI<barrier_op, 0b010, "tsb", []> {
602 let Predicates = [HasTRACEV8_4];
606 // ARMv8.2-A Dot Product
607 let Predicates = [HasDotProd] in {
608 defm SDOT : SIMDThreeSameVectorDot<0, "sdot", int_aarch64_neon_sdot>;
609 defm UDOT : SIMDThreeSameVectorDot<1, "udot", int_aarch64_neon_udot>;
610 defm SDOTlane : SIMDThreeSameVectorDotIndex<0, "sdot", int_aarch64_neon_sdot>;
611 defm UDOTlane : SIMDThreeSameVectorDotIndex<1, "udot", int_aarch64_neon_udot>;
614 // ARMv8.2-A FP16 Fused Multiply-Add Long
615 let Predicates = [HasNEON, HasFP16FML] in {
616 defm FMLAL : SIMDThreeSameVectorFML<0, 1, 0b001, "fmlal", int_aarch64_neon_fmlal>;
617 defm FMLSL : SIMDThreeSameVectorFML<0, 1, 0b101, "fmlsl", int_aarch64_neon_fmlsl>;
618 defm FMLAL2 : SIMDThreeSameVectorFML<1, 0, 0b001, "fmlal2", int_aarch64_neon_fmlal2>;
619 defm FMLSL2 : SIMDThreeSameVectorFML<1, 0, 0b101, "fmlsl2", int_aarch64_neon_fmlsl2>;
620 defm FMLALlane : SIMDThreeSameVectorFMLIndex<0, 0b0000, "fmlal", int_aarch64_neon_fmlal>;
621 defm FMLSLlane : SIMDThreeSameVectorFMLIndex<0, 0b0100, "fmlsl", int_aarch64_neon_fmlsl>;
622 defm FMLAL2lane : SIMDThreeSameVectorFMLIndex<1, 0b1000, "fmlal2", int_aarch64_neon_fmlal2>;
623 defm FMLSL2lane : SIMDThreeSameVectorFMLIndex<1, 0b1100, "fmlsl2", int_aarch64_neon_fmlsl2>;
626 // Armv8.2-A Crypto extensions
627 let Predicates = [HasSHA3] in {
628 def SHA512H : CryptoRRRTied<0b0, 0b00, "sha512h">;
629 def SHA512H2 : CryptoRRRTied<0b0, 0b01, "sha512h2">;
630 def SHA512SU0 : CryptoRRTied_2D<0b0, 0b00, "sha512su0">;
631 def SHA512SU1 : CryptoRRRTied_2D<0b0, 0b10, "sha512su1">;
632 def RAX1 : CryptoRRR_2D<0b0,0b11, "rax1">;
633 def EOR3 : CryptoRRRR_16B<0b00, "eor3">;
634 def BCAX : CryptoRRRR_16B<0b01, "bcax">;
635 def XAR : CryptoRRRi6<"xar">;
638 let Predicates = [HasSM4] in {
639 def SM3TT1A : CryptoRRRi2Tied<0b0, 0b00, "sm3tt1a">;
640 def SM3TT1B : CryptoRRRi2Tied<0b0, 0b01, "sm3tt1b">;
641 def SM3TT2A : CryptoRRRi2Tied<0b0, 0b10, "sm3tt2a">;
642 def SM3TT2B : CryptoRRRi2Tied<0b0, 0b11, "sm3tt2b">;
643 def SM3SS1 : CryptoRRRR_4S<0b10, "sm3ss1">;
644 def SM3PARTW1 : CryptoRRRTied_4S<0b1, 0b00, "sm3partw1">;
645 def SM3PARTW2 : CryptoRRRTied_4S<0b1, 0b01, "sm3partw2">;
646 def SM4ENCKEY : CryptoRRR_4S<0b1, 0b10, "sm4ekey">;
647 def SM4E : CryptoRRTied_4S<0b0, 0b01, "sm4e">;
650 let Predicates = [HasRCPC] in {
651 // v8.3 Release Consistent Processor Consistent support, optional in v8.2.
652 def LDAPRB : RCPCLoad<0b00, "ldaprb", GPR32>;
653 def LDAPRH : RCPCLoad<0b01, "ldaprh", GPR32>;
654 def LDAPRW : RCPCLoad<0b10, "ldapr", GPR32>;
655 def LDAPRX : RCPCLoad<0b11, "ldapr", GPR64>;
658 // v8.3a complex add and multiply-accumulate. No predicate here, that is done
659 // inside the multiclass as the FP16 versions need different predicates.
660 defm FCMLA : SIMDThreeSameVectorTiedComplexHSD<1, 0b110, complexrotateop,
662 defm FCADD : SIMDThreeSameVectorComplexHSD<1, 0b111, complexrotateopodd,
664 defm FCMLA : SIMDIndexedTiedComplexHSD<1, 0, 1, complexrotateop, "fcmla",
667 // v8.3a Pointer Authentication
668 // These instructions inhabit part of the hint space and so can be used for
670 let Uses = [LR], Defs = [LR] in {
671 def PACIAZ : SystemNoOperands<0b000, "paciaz">;
672 def PACIBZ : SystemNoOperands<0b010, "pacibz">;
673 def AUTIAZ : SystemNoOperands<0b100, "autiaz">;
674 def AUTIBZ : SystemNoOperands<0b110, "autibz">;
676 let Uses = [LR, SP], Defs = [LR] in {
677 def PACIASP : SystemNoOperands<0b001, "paciasp">;
678 def PACIBSP : SystemNoOperands<0b011, "pacibsp">;
679 def AUTIASP : SystemNoOperands<0b101, "autiasp">;
680 def AUTIBSP : SystemNoOperands<0b111, "autibsp">;
682 let Uses = [X16, X17], Defs = [X17], CRm = 0b0001 in {
683 def PACIA1716 : SystemNoOperands<0b000, "pacia1716">;
684 def PACIB1716 : SystemNoOperands<0b010, "pacib1716">;
685 def AUTIA1716 : SystemNoOperands<0b100, "autia1716">;
686 def AUTIB1716 : SystemNoOperands<0b110, "autib1716">;
689 let Uses = [LR], Defs = [LR], CRm = 0b0000 in {
690 def XPACLRI : SystemNoOperands<0b111, "xpaclri">;
693 // These pointer authentication isntructions require armv8.3a
694 let Predicates = [HasPA] in {
695 multiclass SignAuth<bits<3> prefix, bits<3> prefix_z, string asm> {
696 def IA : SignAuthOneData<prefix, 0b00, !strconcat(asm, "ia")>;
697 def IB : SignAuthOneData<prefix, 0b01, !strconcat(asm, "ib")>;
698 def DA : SignAuthOneData<prefix, 0b10, !strconcat(asm, "da")>;
699 def DB : SignAuthOneData<prefix, 0b11, !strconcat(asm, "db")>;
700 def IZA : SignAuthZero<prefix_z, 0b00, !strconcat(asm, "iza")>;
701 def DZA : SignAuthZero<prefix_z, 0b10, !strconcat(asm, "dza")>;
702 def IZB : SignAuthZero<prefix_z, 0b01, !strconcat(asm, "izb")>;
703 def DZB : SignAuthZero<prefix_z, 0b11, !strconcat(asm, "dzb")>;
706 defm PAC : SignAuth<0b000, 0b010, "pac">;
707 defm AUT : SignAuth<0b001, 0b011, "aut">;
709 def XPACI : SignAuthZero<0b100, 0b00, "xpaci">;
710 def XPACD : SignAuthZero<0b100, 0b01, "xpacd">;
711 def PACGA : SignAuthTwoOperand<0b1100, "pacga", null_frag>;
713 // Combined Instructions
714 def BRAA : AuthBranchTwoOperands<0, 0, "braa">;
715 def BRAB : AuthBranchTwoOperands<0, 1, "brab">;
716 def BLRAA : AuthBranchTwoOperands<1, 0, "blraa">;
717 def BLRAB : AuthBranchTwoOperands<1, 1, "blrab">;
719 def BRAAZ : AuthOneOperand<0b000, 0, "braaz">;
720 def BRABZ : AuthOneOperand<0b000, 1, "brabz">;
721 def BLRAAZ : AuthOneOperand<0b001, 0, "blraaz">;
722 def BLRABZ : AuthOneOperand<0b001, 1, "blrabz">;
724 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
725 def RETAA : AuthReturn<0b010, 0, "retaa">;
726 def RETAB : AuthReturn<0b010, 1, "retab">;
727 def ERETAA : AuthReturn<0b100, 0, "eretaa">;
728 def ERETAB : AuthReturn<0b100, 1, "eretab">;
731 defm LDRAA : AuthLoad<0, "ldraa", simm10Scaled>;
732 defm LDRAB : AuthLoad<1, "ldrab", simm10Scaled>;
736 // v8.3a floating point conversion for javascript
737 let Predicates = [HasJS, HasFPARMv8] in
738 def FJCVTZS : BaseFPToIntegerUnscaled<0b01, 0b11, 0b110, FPR64, GPR32,
741 (int_aarch64_fjcvtzs FPR64:$Rn))]> {
743 } // HasJS, HasFPARMv8
745 // v8.4 Flag manipulation instructions
746 let Predicates = [HasFMI] in {
747 def CFINV : SimpleSystemI<0, (ins), "cfinv", "">, Sched<[WriteSys]> {
748 let Inst{20-5} = 0b0000001000000000;
750 def SETF8 : BaseFlagManipulation<0, 0, (ins GPR32:$Rn), "setf8", "{\t$Rn}">;
751 def SETF16 : BaseFlagManipulation<0, 1, (ins GPR32:$Rn), "setf16", "{\t$Rn}">;
752 def RMIF : FlagRotate<(ins GPR64:$Rn, uimm6:$imm, imm0_15:$mask), "rmif",
753 "{\t$Rn, $imm, $mask}">;
756 // v8.5 flag manipulation instructions
757 let Predicates = [HasAltNZCV], Uses = [NZCV], Defs = [NZCV] in {
759 def XAFLAG : PstateWriteSimple<(ins), "xaflag", "">, Sched<[WriteSys]> {
760 let Inst{18-16} = 0b000;
761 let Inst{11-8} = 0b0000;
762 let Unpredictable{11-8} = 0b1111;
763 let Inst{7-5} = 0b001;
766 def AXFLAG : PstateWriteSimple<(ins), "axflag", "">, Sched<[WriteSys]> {
767 let Inst{18-16} = 0b000;
768 let Inst{11-8} = 0b0000;
769 let Unpredictable{11-8} = 0b1111;
770 let Inst{7-5} = 0b010;
775 // Armv8.5-A speculation barrier
776 def SB : SimpleSystemI<0, (ins), "sb", "">, Sched<[]> {
777 let Inst{20-5} = 0b0001100110000111;
778 let Unpredictable{11-8} = 0b1111;
779 let Predicates = [HasSB];
780 let hasSideEffects = 1;
783 def : InstAlias<"clrex", (CLREX 0xf)>;
784 def : InstAlias<"isb", (ISB 0xf)>;
785 def : InstAlias<"ssbb", (DSB 0)>;
786 def : InstAlias<"pssbb", (DSB 4)>;
790 def MSRpstateImm1 : MSRpstateImm0_1;
791 def MSRpstateImm4 : MSRpstateImm0_15;
793 // The thread pointer (on Linux, at least, where this has been implemented) is
795 def MOVbaseTLS : Pseudo<(outs GPR64:$dst), (ins),
796 [(set GPR64:$dst, AArch64threadpointer)]>, Sched<[WriteSys]>;
798 let Uses = [ X9 ], Defs = [ X16, X17, LR, NZCV ] in {
799 def HWASAN_CHECK_MEMACCESS : Pseudo<
800 (outs), (ins GPR64noip:$ptr, i32imm:$accessinfo),
801 [(int_hwasan_check_memaccess X9, GPR64noip:$ptr, (i32 timm:$accessinfo))]>,
803 def HWASAN_CHECK_MEMACCESS_SHORTGRANULES : Pseudo<
804 (outs), (ins GPR64noip:$ptr, i32imm:$accessinfo),
805 [(int_hwasan_check_memaccess_shortgranules X9, GPR64noip:$ptr, (i32 timm:$accessinfo))]>,
809 // The cycle counter PMC register is PMCCNTR_EL0.
810 let Predicates = [HasPerfMon] in
811 def : Pat<(readcyclecounter), (MRS 0xdce8)>;
814 def : Pat<(i64 (int_aarch64_get_fpcr)), (MRS 0xda20)>;
816 // Generic system instructions
817 def SYSxt : SystemXtI<0, "sys">;
818 def SYSLxt : SystemLXtI<1, "sysl">;
820 def : InstAlias<"sys $op1, $Cn, $Cm, $op2",
821 (SYSxt imm0_7:$op1, sys_cr_op:$Cn,
822 sys_cr_op:$Cm, imm0_7:$op2, XZR)>;
825 let Predicates = [HasTME] in {
827 def TSTART : TMSystemI<0b0000, "tstart",
828 [(set GPR64:$Rt, (int_aarch64_tstart))]>;
830 def TCOMMIT : TMSystemINoOperand<0b0000, "tcommit", [(int_aarch64_tcommit)]>;
832 def TCANCEL : TMSystemException<0b011, "tcancel",
833 [(int_aarch64_tcancel i64_imm0_65535:$imm)]>;
835 def TTEST : TMSystemI<0b0001, "ttest", [(set GPR64:$Rt, (int_aarch64_ttest))]> {
841 //===----------------------------------------------------------------------===//
842 // Move immediate instructions.
843 //===----------------------------------------------------------------------===//
845 defm MOVK : InsertImmediate<0b11, "movk">;
846 defm MOVN : MoveImmediate<0b00, "movn">;
848 let PostEncoderMethod = "fixMOVZ" in
849 defm MOVZ : MoveImmediate<0b10, "movz">;
851 // First group of aliases covers an implicit "lsl #0".
852 def : InstAlias<"movk $dst, $imm", (MOVKWi GPR32:$dst, i32_imm0_65535:$imm, 0), 0>;
853 def : InstAlias<"movk $dst, $imm", (MOVKXi GPR64:$dst, i32_imm0_65535:$imm, 0), 0>;
854 def : InstAlias<"movn $dst, $imm", (MOVNWi GPR32:$dst, i32_imm0_65535:$imm, 0)>;
855 def : InstAlias<"movn $dst, $imm", (MOVNXi GPR64:$dst, i32_imm0_65535:$imm, 0)>;
856 def : InstAlias<"movz $dst, $imm", (MOVZWi GPR32:$dst, i32_imm0_65535:$imm, 0)>;
857 def : InstAlias<"movz $dst, $imm", (MOVZXi GPR64:$dst, i32_imm0_65535:$imm, 0)>;
859 // Next, we have various ELF relocations with the ":XYZ_g0:sym" syntax.
860 def : InstAlias<"movz $Rd, $sym", (MOVZXi GPR64:$Rd, movw_symbol_g3:$sym, 48)>;
861 def : InstAlias<"movz $Rd, $sym", (MOVZXi GPR64:$Rd, movw_symbol_g2:$sym, 32)>;
862 def : InstAlias<"movz $Rd, $sym", (MOVZXi GPR64:$Rd, movw_symbol_g1:$sym, 16)>;
863 def : InstAlias<"movz $Rd, $sym", (MOVZXi GPR64:$Rd, movw_symbol_g0:$sym, 0)>;
865 def : InstAlias<"movn $Rd, $sym", (MOVNXi GPR64:$Rd, movw_symbol_g3:$sym, 48)>;
866 def : InstAlias<"movn $Rd, $sym", (MOVNXi GPR64:$Rd, movw_symbol_g2:$sym, 32)>;
867 def : InstAlias<"movn $Rd, $sym", (MOVNXi GPR64:$Rd, movw_symbol_g1:$sym, 16)>;
868 def : InstAlias<"movn $Rd, $sym", (MOVNXi GPR64:$Rd, movw_symbol_g0:$sym, 0)>;
870 def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movw_symbol_g3:$sym, 48), 0>;
871 def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movw_symbol_g2:$sym, 32), 0>;
872 def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movw_symbol_g1:$sym, 16), 0>;
873 def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movw_symbol_g0:$sym, 0), 0>;
875 def : InstAlias<"movz $Rd, $sym", (MOVZWi GPR32:$Rd, movw_symbol_g1:$sym, 16)>;
876 def : InstAlias<"movz $Rd, $sym", (MOVZWi GPR32:$Rd, movw_symbol_g0:$sym, 0)>;
878 def : InstAlias<"movn $Rd, $sym", (MOVNWi GPR32:$Rd, movw_symbol_g1:$sym, 16)>;
879 def : InstAlias<"movn $Rd, $sym", (MOVNWi GPR32:$Rd, movw_symbol_g0:$sym, 0)>;
881 def : InstAlias<"movk $Rd, $sym", (MOVKWi GPR32:$Rd, movw_symbol_g1:$sym, 16), 0>;
882 def : InstAlias<"movk $Rd, $sym", (MOVKWi GPR32:$Rd, movw_symbol_g0:$sym, 0), 0>;
884 // Final group of aliases covers true "mov $Rd, $imm" cases.
885 multiclass movw_mov_alias<string basename,Instruction INST, RegisterClass GPR,
886 int width, int shift> {
887 def _asmoperand : AsmOperandClass {
888 let Name = basename # width # "_lsl" # shift # "MovAlias";
889 let PredicateMethod = "is" # basename # "MovAlias<" # width # ", "
891 let RenderMethod = "add" # basename # "MovAliasOperands<" # shift # ">";
894 def _movimm : Operand<i32> {
895 let ParserMatchClass = !cast<AsmOperandClass>(NAME # "_asmoperand");
898 def : InstAlias<"mov $Rd, $imm",
899 (INST GPR:$Rd, !cast<Operand>(NAME # "_movimm"):$imm, shift)>;
902 defm : movw_mov_alias<"MOVZ", MOVZWi, GPR32, 32, 0>;
903 defm : movw_mov_alias<"MOVZ", MOVZWi, GPR32, 32, 16>;
905 defm : movw_mov_alias<"MOVZ", MOVZXi, GPR64, 64, 0>;
906 defm : movw_mov_alias<"MOVZ", MOVZXi, GPR64, 64, 16>;
907 defm : movw_mov_alias<"MOVZ", MOVZXi, GPR64, 64, 32>;
908 defm : movw_mov_alias<"MOVZ", MOVZXi, GPR64, 64, 48>;
910 defm : movw_mov_alias<"MOVN", MOVNWi, GPR32, 32, 0>;
911 defm : movw_mov_alias<"MOVN", MOVNWi, GPR32, 32, 16>;
913 defm : movw_mov_alias<"MOVN", MOVNXi, GPR64, 64, 0>;
914 defm : movw_mov_alias<"MOVN", MOVNXi, GPR64, 64, 16>;
915 defm : movw_mov_alias<"MOVN", MOVNXi, GPR64, 64, 32>;
916 defm : movw_mov_alias<"MOVN", MOVNXi, GPR64, 64, 48>;
918 let isReMaterializable = 1, isCodeGenOnly = 1, isMoveImm = 1,
919 isAsCheapAsAMove = 1 in {
920 // FIXME: The following pseudo instructions are only needed because remat
921 // cannot handle multiple instructions. When that changes, we can select
922 // directly to the real instructions and get rid of these pseudos.
925 : Pseudo<(outs GPR32:$dst), (ins i32imm:$src),
926 [(set GPR32:$dst, imm:$src)]>,
929 : Pseudo<(outs GPR64:$dst), (ins i64imm:$src),
930 [(set GPR64:$dst, imm:$src)]>,
932 } // isReMaterializable, isCodeGenOnly
934 // If possible, we want to use MOVi32imm even for 64-bit moves. This gives the
935 // eventual expansion code fewer bits to worry about getting right. Marshalling
936 // the types is a little tricky though:
937 def i64imm_32bit : ImmLeaf<i64, [{
938 return (Imm & 0xffffffffULL) == static_cast<uint64_t>(Imm);
941 def s64imm_32bit : ImmLeaf<i64, [{
942 int64_t Imm64 = static_cast<int64_t>(Imm);
943 return Imm64 >= std::numeric_limits<int32_t>::min() &&
944 Imm64 <= std::numeric_limits<int32_t>::max();
947 def trunc_imm : SDNodeXForm<imm, [{
948 return CurDAG->getTargetConstant(N->getZExtValue(), SDLoc(N), MVT::i32);
951 def gi_trunc_imm : GICustomOperandRenderer<"renderTruncImm">,
952 GISDNodeXFormEquiv<trunc_imm>;
954 let Predicates = [OptimizedGISelOrOtherSelector] in {
955 // The SUBREG_TO_REG isn't eliminated at -O0, which can result in pointless
957 def : Pat<(i64 i64imm_32bit:$src),
958 (SUBREG_TO_REG (i64 0), (MOVi32imm (trunc_imm imm:$src)), sub_32)>;
961 // Materialize FP constants via MOVi32imm/MOVi64imm (MachO large code model).
962 def bitcast_fpimm_to_i32 : SDNodeXForm<fpimm, [{
963 return CurDAG->getTargetConstant(
964 N->getValueAPF().bitcastToAPInt().getZExtValue(), SDLoc(N), MVT::i32);
967 def bitcast_fpimm_to_i64 : SDNodeXForm<fpimm, [{
968 return CurDAG->getTargetConstant(
969 N->getValueAPF().bitcastToAPInt().getZExtValue(), SDLoc(N), MVT::i64);
973 def : Pat<(f32 fpimm:$in),
974 (COPY_TO_REGCLASS (MOVi32imm (bitcast_fpimm_to_i32 f32:$in)), FPR32)>;
975 def : Pat<(f64 fpimm:$in),
976 (COPY_TO_REGCLASS (MOVi64imm (bitcast_fpimm_to_i64 f64:$in)), FPR64)>;
979 // Deal with the various forms of (ELF) large addressing with MOVZ/MOVK
981 def : Pat<(AArch64WrapperLarge tglobaladdr:$g3, tglobaladdr:$g2,
982 tglobaladdr:$g1, tglobaladdr:$g0),
983 (MOVKXi (MOVKXi (MOVKXi (MOVZXi tglobaladdr:$g0, 0),
984 tglobaladdr:$g1, 16),
985 tglobaladdr:$g2, 32),
986 tglobaladdr:$g3, 48)>;
988 def : Pat<(AArch64WrapperLarge tblockaddress:$g3, tblockaddress:$g2,
989 tblockaddress:$g1, tblockaddress:$g0),
990 (MOVKXi (MOVKXi (MOVKXi (MOVZXi tblockaddress:$g0, 0),
991 tblockaddress:$g1, 16),
992 tblockaddress:$g2, 32),
993 tblockaddress:$g3, 48)>;
995 def : Pat<(AArch64WrapperLarge tconstpool:$g3, tconstpool:$g2,
996 tconstpool:$g1, tconstpool:$g0),
997 (MOVKXi (MOVKXi (MOVKXi (MOVZXi tconstpool:$g0, 0),
1000 tconstpool:$g3, 48)>;
1002 def : Pat<(AArch64WrapperLarge tjumptable:$g3, tjumptable:$g2,
1003 tjumptable:$g1, tjumptable:$g0),
1004 (MOVKXi (MOVKXi (MOVKXi (MOVZXi tjumptable:$g0, 0),
1005 tjumptable:$g1, 16),
1006 tjumptable:$g2, 32),
1007 tjumptable:$g3, 48)>;
1010 //===----------------------------------------------------------------------===//
1011 // Arithmetic instructions.
1012 //===----------------------------------------------------------------------===//
1014 // Add/subtract with carry.
1015 defm ADC : AddSubCarry<0, "adc", "adcs", AArch64adc, AArch64adc_flag>;
1016 defm SBC : AddSubCarry<1, "sbc", "sbcs", AArch64sbc, AArch64sbc_flag>;
1018 def : InstAlias<"ngc $dst, $src", (SBCWr GPR32:$dst, WZR, GPR32:$src)>;
1019 def : InstAlias<"ngc $dst, $src", (SBCXr GPR64:$dst, XZR, GPR64:$src)>;
1020 def : InstAlias<"ngcs $dst, $src", (SBCSWr GPR32:$dst, WZR, GPR32:$src)>;
1021 def : InstAlias<"ngcs $dst, $src", (SBCSXr GPR64:$dst, XZR, GPR64:$src)>;
1024 defm ADD : AddSub<0, "add", "sub", add>;
1025 defm SUB : AddSub<1, "sub", "add">;
1027 def : InstAlias<"mov $dst, $src",
1028 (ADDWri GPR32sponly:$dst, GPR32sp:$src, 0, 0)>;
1029 def : InstAlias<"mov $dst, $src",
1030 (ADDWri GPR32sp:$dst, GPR32sponly:$src, 0, 0)>;
1031 def : InstAlias<"mov $dst, $src",
1032 (ADDXri GPR64sponly:$dst, GPR64sp:$src, 0, 0)>;
1033 def : InstAlias<"mov $dst, $src",
1034 (ADDXri GPR64sp:$dst, GPR64sponly:$src, 0, 0)>;
1036 defm ADDS : AddSubS<0, "adds", AArch64add_flag, "cmn", "subs", "cmp">;
1037 defm SUBS : AddSubS<1, "subs", AArch64sub_flag, "cmp", "adds", "cmn">;
1039 // Use SUBS instead of SUB to enable CSE between SUBS and SUB.
1040 def : Pat<(sub GPR32sp:$Rn, addsub_shifted_imm32:$imm),
1041 (SUBSWri GPR32sp:$Rn, addsub_shifted_imm32:$imm)>;
1042 def : Pat<(sub GPR64sp:$Rn, addsub_shifted_imm64:$imm),
1043 (SUBSXri GPR64sp:$Rn, addsub_shifted_imm64:$imm)>;
1044 def : Pat<(sub GPR32:$Rn, GPR32:$Rm),
1045 (SUBSWrr GPR32:$Rn, GPR32:$Rm)>;
1046 def : Pat<(sub GPR64:$Rn, GPR64:$Rm),
1047 (SUBSXrr GPR64:$Rn, GPR64:$Rm)>;
1048 def : Pat<(sub GPR32:$Rn, arith_shifted_reg32:$Rm),
1049 (SUBSWrs GPR32:$Rn, arith_shifted_reg32:$Rm)>;
1050 def : Pat<(sub GPR64:$Rn, arith_shifted_reg64:$Rm),
1051 (SUBSXrs GPR64:$Rn, arith_shifted_reg64:$Rm)>;
1052 let AddedComplexity = 1 in {
1053 def : Pat<(sub GPR32sp:$R2, arith_extended_reg32_i32:$R3),
1054 (SUBSWrx GPR32sp:$R2, arith_extended_reg32_i32:$R3)>;
1055 def : Pat<(sub GPR64sp:$R2, arith_extended_reg32to64_i64:$R3),
1056 (SUBSXrx GPR64sp:$R2, arith_extended_reg32to64_i64:$R3)>;
1059 // Because of the immediate format for add/sub-imm instructions, the
1060 // expression (add x, -1) must be transformed to (SUB{W,X}ri x, 1).
1061 // These patterns capture that transformation.
1062 let AddedComplexity = 1 in {
1063 def : Pat<(add GPR32:$Rn, neg_addsub_shifted_imm32:$imm),
1064 (SUBSWri GPR32:$Rn, neg_addsub_shifted_imm32:$imm)>;
1065 def : Pat<(add GPR64:$Rn, neg_addsub_shifted_imm64:$imm),
1066 (SUBSXri GPR64:$Rn, neg_addsub_shifted_imm64:$imm)>;
1067 def : Pat<(sub GPR32:$Rn, neg_addsub_shifted_imm32:$imm),
1068 (ADDWri GPR32:$Rn, neg_addsub_shifted_imm32:$imm)>;
1069 def : Pat<(sub GPR64:$Rn, neg_addsub_shifted_imm64:$imm),
1070 (ADDXri GPR64:$Rn, neg_addsub_shifted_imm64:$imm)>;
1073 // Because of the immediate format for add/sub-imm instructions, the
1074 // expression (add x, -1) must be transformed to (SUB{W,X}ri x, 1).
1075 // These patterns capture that transformation.
1076 let AddedComplexity = 1 in {
1077 def : Pat<(AArch64add_flag GPR32:$Rn, neg_addsub_shifted_imm32:$imm),
1078 (SUBSWri GPR32:$Rn, neg_addsub_shifted_imm32:$imm)>;
1079 def : Pat<(AArch64add_flag GPR64:$Rn, neg_addsub_shifted_imm64:$imm),
1080 (SUBSXri GPR64:$Rn, neg_addsub_shifted_imm64:$imm)>;
1081 def : Pat<(AArch64sub_flag GPR32:$Rn, neg_addsub_shifted_imm32:$imm),
1082 (ADDSWri GPR32:$Rn, neg_addsub_shifted_imm32:$imm)>;
1083 def : Pat<(AArch64sub_flag GPR64:$Rn, neg_addsub_shifted_imm64:$imm),
1084 (ADDSXri GPR64:$Rn, neg_addsub_shifted_imm64:$imm)>;
1087 def : InstAlias<"neg $dst, $src", (SUBWrs GPR32:$dst, WZR, GPR32:$src, 0), 3>;
1088 def : InstAlias<"neg $dst, $src", (SUBXrs GPR64:$dst, XZR, GPR64:$src, 0), 3>;
1089 def : InstAlias<"neg $dst, $src$shift",
1090 (SUBWrs GPR32:$dst, WZR, GPR32:$src, arith_shift32:$shift), 2>;
1091 def : InstAlias<"neg $dst, $src$shift",
1092 (SUBXrs GPR64:$dst, XZR, GPR64:$src, arith_shift64:$shift), 2>;
1094 def : InstAlias<"negs $dst, $src", (SUBSWrs GPR32:$dst, WZR, GPR32:$src, 0), 3>;
1095 def : InstAlias<"negs $dst, $src", (SUBSXrs GPR64:$dst, XZR, GPR64:$src, 0), 3>;
1096 def : InstAlias<"negs $dst, $src$shift",
1097 (SUBSWrs GPR32:$dst, WZR, GPR32:$src, arith_shift32:$shift), 2>;
1098 def : InstAlias<"negs $dst, $src$shift",
1099 (SUBSXrs GPR64:$dst, XZR, GPR64:$src, arith_shift64:$shift), 2>;
1102 // Unsigned/Signed divide
1103 defm UDIV : Div<0, "udiv", udiv>;
1104 defm SDIV : Div<1, "sdiv", sdiv>;
1106 def : Pat<(int_aarch64_udiv GPR32:$Rn, GPR32:$Rm), (UDIVWr GPR32:$Rn, GPR32:$Rm)>;
1107 def : Pat<(int_aarch64_udiv GPR64:$Rn, GPR64:$Rm), (UDIVXr GPR64:$Rn, GPR64:$Rm)>;
1108 def : Pat<(int_aarch64_sdiv GPR32:$Rn, GPR32:$Rm), (SDIVWr GPR32:$Rn, GPR32:$Rm)>;
1109 def : Pat<(int_aarch64_sdiv GPR64:$Rn, GPR64:$Rm), (SDIVXr GPR64:$Rn, GPR64:$Rm)>;
1112 defm ASRV : Shift<0b10, "asr", sra>;
1113 defm LSLV : Shift<0b00, "lsl", shl>;
1114 defm LSRV : Shift<0b01, "lsr", srl>;
1115 defm RORV : Shift<0b11, "ror", rotr>;
1117 def : ShiftAlias<"asrv", ASRVWr, GPR32>;
1118 def : ShiftAlias<"asrv", ASRVXr, GPR64>;
1119 def : ShiftAlias<"lslv", LSLVWr, GPR32>;
1120 def : ShiftAlias<"lslv", LSLVXr, GPR64>;
1121 def : ShiftAlias<"lsrv", LSRVWr, GPR32>;
1122 def : ShiftAlias<"lsrv", LSRVXr, GPR64>;
1123 def : ShiftAlias<"rorv", RORVWr, GPR32>;
1124 def : ShiftAlias<"rorv", RORVXr, GPR64>;
1127 let AddedComplexity = 5 in {
1128 defm MADD : MulAccum<0, "madd", add>;
1129 defm MSUB : MulAccum<1, "msub", sub>;
1131 def : Pat<(i32 (mul GPR32:$Rn, GPR32:$Rm)),
1132 (MADDWrrr GPR32:$Rn, GPR32:$Rm, WZR)>;
1133 def : Pat<(i64 (mul GPR64:$Rn, GPR64:$Rm)),
1134 (MADDXrrr GPR64:$Rn, GPR64:$Rm, XZR)>;
1136 def : Pat<(i32 (ineg (mul GPR32:$Rn, GPR32:$Rm))),
1137 (MSUBWrrr GPR32:$Rn, GPR32:$Rm, WZR)>;
1138 def : Pat<(i64 (ineg (mul GPR64:$Rn, GPR64:$Rm))),
1139 (MSUBXrrr GPR64:$Rn, GPR64:$Rm, XZR)>;
1140 def : Pat<(i32 (mul (ineg GPR32:$Rn), GPR32:$Rm)),
1141 (MSUBWrrr GPR32:$Rn, GPR32:$Rm, WZR)>;
1142 def : Pat<(i64 (mul (ineg GPR64:$Rn), GPR64:$Rm)),
1143 (MSUBXrrr GPR64:$Rn, GPR64:$Rm, XZR)>;
1144 } // AddedComplexity = 5
1146 let AddedComplexity = 5 in {
1147 def SMADDLrrr : WideMulAccum<0, 0b001, "smaddl", add, sext>;
1148 def SMSUBLrrr : WideMulAccum<1, 0b001, "smsubl", sub, sext>;
1149 def UMADDLrrr : WideMulAccum<0, 0b101, "umaddl", add, zext>;
1150 def UMSUBLrrr : WideMulAccum<1, 0b101, "umsubl", sub, zext>;
1152 def : Pat<(i64 (mul (sext GPR32:$Rn), (sext GPR32:$Rm))),
1153 (SMADDLrrr GPR32:$Rn, GPR32:$Rm, XZR)>;
1154 def : Pat<(i64 (mul (zext GPR32:$Rn), (zext GPR32:$Rm))),
1155 (UMADDLrrr GPR32:$Rn, GPR32:$Rm, XZR)>;
1157 def : Pat<(i64 (ineg (mul (sext GPR32:$Rn), (sext GPR32:$Rm)))),
1158 (SMSUBLrrr GPR32:$Rn, GPR32:$Rm, XZR)>;
1159 def : Pat<(i64 (ineg (mul (zext GPR32:$Rn), (zext GPR32:$Rm)))),
1160 (UMSUBLrrr GPR32:$Rn, GPR32:$Rm, XZR)>;
1162 def : Pat<(i64 (mul (sext GPR32:$Rn), (s64imm_32bit:$C))),
1163 (SMADDLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1164 def : Pat<(i64 (mul (zext GPR32:$Rn), (i64imm_32bit:$C))),
1165 (UMADDLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1166 def : Pat<(i64 (mul (sext_inreg GPR64:$Rn, i32), (s64imm_32bit:$C))),
1167 (SMADDLrrr (i32 (EXTRACT_SUBREG GPR64:$Rn, sub_32)),
1168 (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1170 def : Pat<(i64 (ineg (mul (sext GPR32:$Rn), (s64imm_32bit:$C)))),
1171 (SMSUBLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1172 def : Pat<(i64 (ineg (mul (zext GPR32:$Rn), (i64imm_32bit:$C)))),
1173 (UMSUBLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1174 def : Pat<(i64 (ineg (mul (sext_inreg GPR64:$Rn, i32), (s64imm_32bit:$C)))),
1175 (SMSUBLrrr (i32 (EXTRACT_SUBREG GPR64:$Rn, sub_32)),
1176 (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1178 def : Pat<(i64 (add (mul (sext GPR32:$Rn), (s64imm_32bit:$C)), GPR64:$Ra)),
1179 (SMADDLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1180 def : Pat<(i64 (add (mul (zext GPR32:$Rn), (i64imm_32bit:$C)), GPR64:$Ra)),
1181 (UMADDLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1182 def : Pat<(i64 (add (mul (sext_inreg GPR64:$Rn, i32), (s64imm_32bit:$C)),
1184 (SMADDLrrr (i32 (EXTRACT_SUBREG GPR64:$Rn, sub_32)),
1185 (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1187 def : Pat<(i64 (sub GPR64:$Ra, (mul (sext GPR32:$Rn), (s64imm_32bit:$C)))),
1188 (SMSUBLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1189 def : Pat<(i64 (sub GPR64:$Ra, (mul (zext GPR32:$Rn), (i64imm_32bit:$C)))),
1190 (UMSUBLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1191 def : Pat<(i64 (sub GPR64:$Ra, (mul (sext_inreg GPR64:$Rn, i32),
1192 (s64imm_32bit:$C)))),
1193 (SMSUBLrrr (i32 (EXTRACT_SUBREG GPR64:$Rn, sub_32)),
1194 (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1195 } // AddedComplexity = 5
1197 def : MulAccumWAlias<"mul", MADDWrrr>;
1198 def : MulAccumXAlias<"mul", MADDXrrr>;
1199 def : MulAccumWAlias<"mneg", MSUBWrrr>;
1200 def : MulAccumXAlias<"mneg", MSUBXrrr>;
1201 def : WideMulAccumAlias<"smull", SMADDLrrr>;
1202 def : WideMulAccumAlias<"smnegl", SMSUBLrrr>;
1203 def : WideMulAccumAlias<"umull", UMADDLrrr>;
1204 def : WideMulAccumAlias<"umnegl", UMSUBLrrr>;
1207 def SMULHrr : MulHi<0b010, "smulh", mulhs>;
1208 def UMULHrr : MulHi<0b110, "umulh", mulhu>;
1211 def CRC32Brr : BaseCRC32<0, 0b00, 0, GPR32, int_aarch64_crc32b, "crc32b">;
1212 def CRC32Hrr : BaseCRC32<0, 0b01, 0, GPR32, int_aarch64_crc32h, "crc32h">;
1213 def CRC32Wrr : BaseCRC32<0, 0b10, 0, GPR32, int_aarch64_crc32w, "crc32w">;
1214 def CRC32Xrr : BaseCRC32<1, 0b11, 0, GPR64, int_aarch64_crc32x, "crc32x">;
1216 def CRC32CBrr : BaseCRC32<0, 0b00, 1, GPR32, int_aarch64_crc32cb, "crc32cb">;
1217 def CRC32CHrr : BaseCRC32<0, 0b01, 1, GPR32, int_aarch64_crc32ch, "crc32ch">;
1218 def CRC32CWrr : BaseCRC32<0, 0b10, 1, GPR32, int_aarch64_crc32cw, "crc32cw">;
1219 def CRC32CXrr : BaseCRC32<1, 0b11, 1, GPR64, int_aarch64_crc32cx, "crc32cx">;
1222 defm CAS : CompareAndSwap<0, 0, "">;
1223 defm CASA : CompareAndSwap<1, 0, "a">;
1224 defm CASL : CompareAndSwap<0, 1, "l">;
1225 defm CASAL : CompareAndSwap<1, 1, "al">;
1228 defm CASP : CompareAndSwapPair<0, 0, "">;
1229 defm CASPA : CompareAndSwapPair<1, 0, "a">;
1230 defm CASPL : CompareAndSwapPair<0, 1, "l">;
1231 defm CASPAL : CompareAndSwapPair<1, 1, "al">;
1234 defm SWP : Swap<0, 0, "">;
1235 defm SWPA : Swap<1, 0, "a">;
1236 defm SWPL : Swap<0, 1, "l">;
1237 defm SWPAL : Swap<1, 1, "al">;
1239 // v8.1 atomic LD<OP>(register). Performs load and then ST<OP>(register)
1240 defm LDADD : LDOPregister<0b000, "add", 0, 0, "">;
1241 defm LDADDA : LDOPregister<0b000, "add", 1, 0, "a">;
1242 defm LDADDL : LDOPregister<0b000, "add", 0, 1, "l">;
1243 defm LDADDAL : LDOPregister<0b000, "add", 1, 1, "al">;
1245 defm LDCLR : LDOPregister<0b001, "clr", 0, 0, "">;
1246 defm LDCLRA : LDOPregister<0b001, "clr", 1, 0, "a">;
1247 defm LDCLRL : LDOPregister<0b001, "clr", 0, 1, "l">;
1248 defm LDCLRAL : LDOPregister<0b001, "clr", 1, 1, "al">;
1250 defm LDEOR : LDOPregister<0b010, "eor", 0, 0, "">;
1251 defm LDEORA : LDOPregister<0b010, "eor", 1, 0, "a">;
1252 defm LDEORL : LDOPregister<0b010, "eor", 0, 1, "l">;
1253 defm LDEORAL : LDOPregister<0b010, "eor", 1, 1, "al">;
1255 defm LDSET : LDOPregister<0b011, "set", 0, 0, "">;
1256 defm LDSETA : LDOPregister<0b011, "set", 1, 0, "a">;
1257 defm LDSETL : LDOPregister<0b011, "set", 0, 1, "l">;
1258 defm LDSETAL : LDOPregister<0b011, "set", 1, 1, "al">;
1260 defm LDSMAX : LDOPregister<0b100, "smax", 0, 0, "">;
1261 defm LDSMAXA : LDOPregister<0b100, "smax", 1, 0, "a">;
1262 defm LDSMAXL : LDOPregister<0b100, "smax", 0, 1, "l">;
1263 defm LDSMAXAL : LDOPregister<0b100, "smax", 1, 1, "al">;
1265 defm LDSMIN : LDOPregister<0b101, "smin", 0, 0, "">;
1266 defm LDSMINA : LDOPregister<0b101, "smin", 1, 0, "a">;
1267 defm LDSMINL : LDOPregister<0b101, "smin", 0, 1, "l">;
1268 defm LDSMINAL : LDOPregister<0b101, "smin", 1, 1, "al">;
1270 defm LDUMAX : LDOPregister<0b110, "umax", 0, 0, "">;
1271 defm LDUMAXA : LDOPregister<0b110, "umax", 1, 0, "a">;
1272 defm LDUMAXL : LDOPregister<0b110, "umax", 0, 1, "l">;
1273 defm LDUMAXAL : LDOPregister<0b110, "umax", 1, 1, "al">;
1275 defm LDUMIN : LDOPregister<0b111, "umin", 0, 0, "">;
1276 defm LDUMINA : LDOPregister<0b111, "umin", 1, 0, "a">;
1277 defm LDUMINL : LDOPregister<0b111, "umin", 0, 1, "l">;
1278 defm LDUMINAL : LDOPregister<0b111, "umin", 1, 1, "al">;
1280 // v8.1 atomic ST<OP>(register) as aliases to "LD<OP>(register) when Rt=xZR"
1281 defm : STOPregister<"stadd","LDADD">; // STADDx
1282 defm : STOPregister<"stclr","LDCLR">; // STCLRx
1283 defm : STOPregister<"steor","LDEOR">; // STEORx
1284 defm : STOPregister<"stset","LDSET">; // STSETx
1285 defm : STOPregister<"stsmax","LDSMAX">;// STSMAXx
1286 defm : STOPregister<"stsmin","LDSMIN">;// STSMINx
1287 defm : STOPregister<"stumax","LDUMAX">;// STUMAXx
1288 defm : STOPregister<"stumin","LDUMIN">;// STUMINx
1290 // v8.5 Memory Tagging Extension
1291 let Predicates = [HasMTE] in {
1293 def IRG : BaseTwoOperand<0b0100, GPR64sp, "irg", int_aarch64_irg, GPR64sp, GPR64>,
1297 def GMI : BaseTwoOperand<0b0101, GPR64, "gmi", int_aarch64_gmi, GPR64sp>, Sched<[]>{
1299 let isNotDuplicable = 1;
1301 def ADDG : AddSubG<0, "addg", null_frag>;
1302 def SUBG : AddSubG<1, "subg", null_frag>;
1304 def : InstAlias<"irg $dst, $src", (IRG GPR64sp:$dst, GPR64sp:$src, XZR), 1>;
1306 def SUBP : SUBP<0, "subp", int_aarch64_subp>, Sched<[]>;
1307 def SUBPS : SUBP<1, "subps", null_frag>, Sched<[]>{
1311 def : InstAlias<"cmpp $lhs, $rhs", (SUBPS XZR, GPR64sp:$lhs, GPR64sp:$rhs), 0>;
1313 def LDG : MemTagLoad<"ldg", "\t$Rt, [$Rn, $offset]">;
1315 def : Pat<(int_aarch64_addg (am_indexedu6s128 GPR64sp:$Rn, uimm6s16:$imm6), imm0_15:$imm4),
1316 (ADDG GPR64sp:$Rn, imm0_63:$imm6, imm0_15:$imm4)>;
1317 def : Pat<(int_aarch64_ldg GPR64:$Rt, (am_indexeds9s128 GPR64sp:$Rn, simm9s16:$offset)),
1318 (LDG GPR64:$Rt, GPR64sp:$Rn, simm9s16:$offset)>;
1320 def : InstAlias<"ldg $Rt, [$Rn]", (LDG GPR64:$Rt, GPR64sp:$Rn, 0), 1>;
1322 def LDGM : MemTagVector<1, "ldgm", "\t$Rt, [$Rn]",
1323 (outs GPR64:$Rt), (ins GPR64sp:$Rn)>;
1324 def STGM : MemTagVector<0, "stgm", "\t$Rt, [$Rn]",
1325 (outs), (ins GPR64:$Rt, GPR64sp:$Rn)>;
1326 def STZGM : MemTagVector<0, "stzgm", "\t$Rt, [$Rn]",
1327 (outs), (ins GPR64:$Rt, GPR64sp:$Rn)> {
1331 defm STG : MemTagStore<0b00, "stg">;
1332 defm STZG : MemTagStore<0b01, "stzg">;
1333 defm ST2G : MemTagStore<0b10, "st2g">;
1334 defm STZ2G : MemTagStore<0b11, "stz2g">;
1336 def : Pat<(AArch64stg GPR64sp:$Rn, (am_indexeds9s128 GPR64sp:$Rm, simm9s16:$imm)),
1337 (STGOffset $Rn, $Rm, $imm)>;
1338 def : Pat<(AArch64stzg GPR64sp:$Rn, (am_indexeds9s128 GPR64sp:$Rm, simm9s16:$imm)),
1339 (STZGOffset $Rn, $Rm, $imm)>;
1340 def : Pat<(AArch64st2g GPR64sp:$Rn, (am_indexeds9s128 GPR64sp:$Rm, simm9s16:$imm)),
1341 (ST2GOffset $Rn, $Rm, $imm)>;
1342 def : Pat<(AArch64stz2g GPR64sp:$Rn, (am_indexeds9s128 GPR64sp:$Rm, simm9s16:$imm)),
1343 (STZ2GOffset $Rn, $Rm, $imm)>;
1345 defm STGP : StorePairOffset <0b01, 0, GPR64z, simm7s16, "stgp">;
1346 def STGPpre : StorePairPreIdx <0b01, 0, GPR64z, simm7s16, "stgp">;
1347 def STGPpost : StorePairPostIdx<0b01, 0, GPR64z, simm7s16, "stgp">;
1349 def : Pat<(int_aarch64_stg GPR64:$Rt, (am_indexeds9s128 GPR64sp:$Rn, simm9s16:$offset)),
1350 (STGOffset GPR64:$Rt, GPR64sp:$Rn, simm9s16:$offset)>;
1352 def : Pat<(int_aarch64_stgp (am_indexed7s128 GPR64sp:$Rn, simm7s16:$imm), GPR64:$Rt, GPR64:$Rt2),
1353 (STGPi $Rt, $Rt2, $Rn, $imm)>;
1356 : Pseudo<(outs GPR64sp:$Rd), (ins GPR64sp:$Rsp, GPR64:$Rm), []>,
1359 : Pseudo<(outs GPR64sp:$Rd), (ins GPR64sp:$Rn, uimm6s16:$imm6, GPR64sp:$Rm, imm0_15:$imm4), []>,
1362 // Explicit SP in the first operand prevents ShrinkWrap optimization
1363 // from leaving this instruction out of the stack frame. When IRGstack
1364 // is transformed into IRG, this operand is replaced with the actual
1365 // register / expression for the tagged base pointer of the current function.
1366 def : Pat<(int_aarch64_irg_sp i64:$Rm), (IRGstack SP, i64:$Rm)>;
1368 // Large STG to be expanded into a loop. $Rm is the size, $Rn is start address.
1369 // $Rn_wback is one past the end of the range.
1370 let isCodeGenOnly=1, mayStore=1 in {
1372 : Pseudo<(outs GPR64common:$Rm_wback, GPR64sp:$Rn_wback), (ins GPR64common:$Rm, GPR64sp:$Rn),
1373 [], "$Rn = $Rn_wback,@earlyclobber $Rn_wback,$Rm = $Rm_wback,@earlyclobber $Rm_wback" >,
1374 Sched<[WriteAdr, WriteST]>;
1377 : Pseudo<(outs GPR64common:$Rm_wback, GPR64sp:$Rn_wback), (ins GPR64common:$Rm, GPR64sp:$Rn),
1378 [], "$Rn = $Rn_wback,@earlyclobber $Rn_wback,$Rm = $Rm_wback,@earlyclobber $Rm_wback" >,
1379 Sched<[WriteAdr, WriteST]>;
1382 } // Predicates = [HasMTE]
1384 //===----------------------------------------------------------------------===//
1385 // Logical instructions.
1386 //===----------------------------------------------------------------------===//
1389 defm ANDS : LogicalImmS<0b11, "ands", AArch64and_flag, "bics">;
1390 defm AND : LogicalImm<0b00, "and", and, "bic">;
1391 defm EOR : LogicalImm<0b10, "eor", xor, "eon">;
1392 defm ORR : LogicalImm<0b01, "orr", or, "orn">;
1394 // FIXME: these aliases *are* canonical sometimes (when movz can't be
1395 // used). Actually, it seems to be working right now, but putting logical_immXX
1396 // here is a bit dodgy on the AsmParser side too.
1397 def : InstAlias<"mov $dst, $imm", (ORRWri GPR32sp:$dst, WZR,
1398 logical_imm32:$imm), 0>;
1399 def : InstAlias<"mov $dst, $imm", (ORRXri GPR64sp:$dst, XZR,
1400 logical_imm64:$imm), 0>;
1404 defm ANDS : LogicalRegS<0b11, 0, "ands", AArch64and_flag>;
1405 defm BICS : LogicalRegS<0b11, 1, "bics",
1406 BinOpFrag<(AArch64and_flag node:$LHS, (not node:$RHS))>>;
1407 defm AND : LogicalReg<0b00, 0, "and", and>;
1408 defm BIC : LogicalReg<0b00, 1, "bic",
1409 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
1410 defm EON : LogicalReg<0b10, 1, "eon",
1411 BinOpFrag<(not (xor node:$LHS, node:$RHS))>>;
1412 defm EOR : LogicalReg<0b10, 0, "eor", xor>;
1413 defm ORN : LogicalReg<0b01, 1, "orn",
1414 BinOpFrag<(or node:$LHS, (not node:$RHS))>>;
1415 defm ORR : LogicalReg<0b01, 0, "orr", or>;
1417 def : InstAlias<"mov $dst, $src", (ORRWrs GPR32:$dst, WZR, GPR32:$src, 0), 2>;
1418 def : InstAlias<"mov $dst, $src", (ORRXrs GPR64:$dst, XZR, GPR64:$src, 0), 2>;
1420 def : InstAlias<"mvn $Wd, $Wm", (ORNWrs GPR32:$Wd, WZR, GPR32:$Wm, 0), 3>;
1421 def : InstAlias<"mvn $Xd, $Xm", (ORNXrs GPR64:$Xd, XZR, GPR64:$Xm, 0), 3>;
1423 def : InstAlias<"mvn $Wd, $Wm$sh",
1424 (ORNWrs GPR32:$Wd, WZR, GPR32:$Wm, logical_shift32:$sh), 2>;
1425 def : InstAlias<"mvn $Xd, $Xm$sh",
1426 (ORNXrs GPR64:$Xd, XZR, GPR64:$Xm, logical_shift64:$sh), 2>;
1428 def : InstAlias<"tst $src1, $src2",
1429 (ANDSWri WZR, GPR32:$src1, logical_imm32:$src2), 2>;
1430 def : InstAlias<"tst $src1, $src2",
1431 (ANDSXri XZR, GPR64:$src1, logical_imm64:$src2), 2>;
1433 def : InstAlias<"tst $src1, $src2",
1434 (ANDSWrs WZR, GPR32:$src1, GPR32:$src2, 0), 3>;
1435 def : InstAlias<"tst $src1, $src2",
1436 (ANDSXrs XZR, GPR64:$src1, GPR64:$src2, 0), 3>;
1438 def : InstAlias<"tst $src1, $src2$sh",
1439 (ANDSWrs WZR, GPR32:$src1, GPR32:$src2, logical_shift32:$sh), 2>;
1440 def : InstAlias<"tst $src1, $src2$sh",
1441 (ANDSXrs XZR, GPR64:$src1, GPR64:$src2, logical_shift64:$sh), 2>;
1444 def : Pat<(not GPR32:$Wm), (ORNWrr WZR, GPR32:$Wm)>;
1445 def : Pat<(not GPR64:$Xm), (ORNXrr XZR, GPR64:$Xm)>;
1448 //===----------------------------------------------------------------------===//
1449 // One operand data processing instructions.
1450 //===----------------------------------------------------------------------===//
1452 defm CLS : OneOperandData<0b101, "cls">;
1453 defm CLZ : OneOperandData<0b100, "clz", ctlz>;
1454 defm RBIT : OneOperandData<0b000, "rbit", bitreverse>;
1456 def REV16Wr : OneWRegData<0b001, "rev16",
1457 UnOpFrag<(rotr (bswap node:$LHS), (i64 16))>>;
1458 def REV16Xr : OneXRegData<0b001, "rev16", null_frag>;
1460 def : Pat<(cttz GPR32:$Rn),
1461 (CLZWr (RBITWr GPR32:$Rn))>;
1462 def : Pat<(cttz GPR64:$Rn),
1463 (CLZXr (RBITXr GPR64:$Rn))>;
1464 def : Pat<(ctlz (or (shl (xor (sra GPR32:$Rn, (i64 31)), GPR32:$Rn), (i64 1)),
1467 def : Pat<(ctlz (or (shl (xor (sra GPR64:$Rn, (i64 63)), GPR64:$Rn), (i64 1)),
1471 // Unlike the other one operand instructions, the instructions with the "rev"
1472 // mnemonic do *not* just different in the size bit, but actually use different
1473 // opcode bits for the different sizes.
1474 def REVWr : OneWRegData<0b010, "rev", bswap>;
1475 def REVXr : OneXRegData<0b011, "rev", bswap>;
1476 def REV32Xr : OneXRegData<0b010, "rev32",
1477 UnOpFrag<(rotr (bswap node:$LHS), (i64 32))>>;
1479 def : InstAlias<"rev64 $Rd, $Rn", (REVXr GPR64:$Rd, GPR64:$Rn), 0>;
1481 // The bswap commutes with the rotr so we want a pattern for both possible
1483 def : Pat<(bswap (rotr GPR32:$Rn, (i64 16))), (REV16Wr GPR32:$Rn)>;
1484 def : Pat<(bswap (rotr GPR64:$Rn, (i64 32))), (REV32Xr GPR64:$Rn)>;
1486 //===----------------------------------------------------------------------===//
1487 // Bitfield immediate extraction instruction.
1488 //===----------------------------------------------------------------------===//
1489 let hasSideEffects = 0 in
1490 defm EXTR : ExtractImm<"extr">;
1491 def : InstAlias<"ror $dst, $src, $shift",
1492 (EXTRWrri GPR32:$dst, GPR32:$src, GPR32:$src, imm0_31:$shift)>;
1493 def : InstAlias<"ror $dst, $src, $shift",
1494 (EXTRXrri GPR64:$dst, GPR64:$src, GPR64:$src, imm0_63:$shift)>;
1496 def : Pat<(rotr GPR32:$Rn, (i64 imm0_31:$imm)),
1497 (EXTRWrri GPR32:$Rn, GPR32:$Rn, imm0_31:$imm)>;
1498 def : Pat<(rotr GPR64:$Rn, (i64 imm0_63:$imm)),
1499 (EXTRXrri GPR64:$Rn, GPR64:$Rn, imm0_63:$imm)>;
1501 //===----------------------------------------------------------------------===//
1502 // Other bitfield immediate instructions.
1503 //===----------------------------------------------------------------------===//
1504 let hasSideEffects = 0 in {
1505 defm BFM : BitfieldImmWith2RegArgs<0b01, "bfm">;
1506 defm SBFM : BitfieldImm<0b00, "sbfm">;
1507 defm UBFM : BitfieldImm<0b10, "ubfm">;
1510 def i32shift_a : Operand<i64>, SDNodeXForm<imm, [{
1511 uint64_t enc = (32 - N->getZExtValue()) & 0x1f;
1512 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1515 def i32shift_b : Operand<i64>, SDNodeXForm<imm, [{
1516 uint64_t enc = 31 - N->getZExtValue();
1517 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1520 // min(7, 31 - shift_amt)
1521 def i32shift_sext_i8 : Operand<i64>, SDNodeXForm<imm, [{
1522 uint64_t enc = 31 - N->getZExtValue();
1523 enc = enc > 7 ? 7 : enc;
1524 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1527 // min(15, 31 - shift_amt)
1528 def i32shift_sext_i16 : Operand<i64>, SDNodeXForm<imm, [{
1529 uint64_t enc = 31 - N->getZExtValue();
1530 enc = enc > 15 ? 15 : enc;
1531 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1534 def i64shift_a : Operand<i64>, SDNodeXForm<imm, [{
1535 uint64_t enc = (64 - N->getZExtValue()) & 0x3f;
1536 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1539 def i64shift_b : Operand<i64>, SDNodeXForm<imm, [{
1540 uint64_t enc = 63 - N->getZExtValue();
1541 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1544 // min(7, 63 - shift_amt)
1545 def i64shift_sext_i8 : Operand<i64>, SDNodeXForm<imm, [{
1546 uint64_t enc = 63 - N->getZExtValue();
1547 enc = enc > 7 ? 7 : enc;
1548 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1551 // min(15, 63 - shift_amt)
1552 def i64shift_sext_i16 : Operand<i64>, SDNodeXForm<imm, [{
1553 uint64_t enc = 63 - N->getZExtValue();
1554 enc = enc > 15 ? 15 : enc;
1555 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1558 // min(31, 63 - shift_amt)
1559 def i64shift_sext_i32 : Operand<i64>, SDNodeXForm<imm, [{
1560 uint64_t enc = 63 - N->getZExtValue();
1561 enc = enc > 31 ? 31 : enc;
1562 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1565 def : Pat<(shl GPR32:$Rn, (i64 imm0_31:$imm)),
1566 (UBFMWri GPR32:$Rn, (i64 (i32shift_a imm0_31:$imm)),
1567 (i64 (i32shift_b imm0_31:$imm)))>;
1568 def : Pat<(shl GPR64:$Rn, (i64 imm0_63:$imm)),
1569 (UBFMXri GPR64:$Rn, (i64 (i64shift_a imm0_63:$imm)),
1570 (i64 (i64shift_b imm0_63:$imm)))>;
1572 let AddedComplexity = 10 in {
1573 def : Pat<(sra GPR32:$Rn, (i64 imm0_31:$imm)),
1574 (SBFMWri GPR32:$Rn, imm0_31:$imm, 31)>;
1575 def : Pat<(sra GPR64:$Rn, (i64 imm0_63:$imm)),
1576 (SBFMXri GPR64:$Rn, imm0_63:$imm, 63)>;
1579 def : InstAlias<"asr $dst, $src, $shift",
1580 (SBFMWri GPR32:$dst, GPR32:$src, imm0_31:$shift, 31)>;
1581 def : InstAlias<"asr $dst, $src, $shift",
1582 (SBFMXri GPR64:$dst, GPR64:$src, imm0_63:$shift, 63)>;
1583 def : InstAlias<"sxtb $dst, $src", (SBFMWri GPR32:$dst, GPR32:$src, 0, 7)>;
1584 def : InstAlias<"sxtb $dst, $src", (SBFMXri GPR64:$dst, GPR64:$src, 0, 7)>;
1585 def : InstAlias<"sxth $dst, $src", (SBFMWri GPR32:$dst, GPR32:$src, 0, 15)>;
1586 def : InstAlias<"sxth $dst, $src", (SBFMXri GPR64:$dst, GPR64:$src, 0, 15)>;
1587 def : InstAlias<"sxtw $dst, $src", (SBFMXri GPR64:$dst, GPR64:$src, 0, 31)>;
1589 def : Pat<(srl GPR32:$Rn, (i64 imm0_31:$imm)),
1590 (UBFMWri GPR32:$Rn, imm0_31:$imm, 31)>;
1591 def : Pat<(srl GPR64:$Rn, (i64 imm0_63:$imm)),
1592 (UBFMXri GPR64:$Rn, imm0_63:$imm, 63)>;
1594 def : InstAlias<"lsr $dst, $src, $shift",
1595 (UBFMWri GPR32:$dst, GPR32:$src, imm0_31:$shift, 31)>;
1596 def : InstAlias<"lsr $dst, $src, $shift",
1597 (UBFMXri GPR64:$dst, GPR64:$src, imm0_63:$shift, 63)>;
1598 def : InstAlias<"uxtb $dst, $src", (UBFMWri GPR32:$dst, GPR32:$src, 0, 7)>;
1599 def : InstAlias<"uxtb $dst, $src", (UBFMXri GPR64:$dst, GPR64:$src, 0, 7)>;
1600 def : InstAlias<"uxth $dst, $src", (UBFMWri GPR32:$dst, GPR32:$src, 0, 15)>;
1601 def : InstAlias<"uxth $dst, $src", (UBFMXri GPR64:$dst, GPR64:$src, 0, 15)>;
1602 def : InstAlias<"uxtw $dst, $src", (UBFMXri GPR64:$dst, GPR64:$src, 0, 31)>;
1604 //===----------------------------------------------------------------------===//
1605 // Conditional comparison instructions.
1606 //===----------------------------------------------------------------------===//
1607 defm CCMN : CondComparison<0, "ccmn", AArch64ccmn>;
1608 defm CCMP : CondComparison<1, "ccmp", AArch64ccmp>;
1610 //===----------------------------------------------------------------------===//
1611 // Conditional select instructions.
1612 //===----------------------------------------------------------------------===//
1613 defm CSEL : CondSelect<0, 0b00, "csel">;
1615 def inc : PatFrag<(ops node:$in), (add node:$in, 1)>;
1616 defm CSINC : CondSelectOp<0, 0b01, "csinc", inc>;
1617 defm CSINV : CondSelectOp<1, 0b00, "csinv", not>;
1618 defm CSNEG : CondSelectOp<1, 0b01, "csneg", ineg>;
1620 def : Pat<(AArch64csinv GPR32:$tval, GPR32:$fval, (i32 imm:$cc), NZCV),
1621 (CSINVWr GPR32:$tval, GPR32:$fval, (i32 imm:$cc))>;
1622 def : Pat<(AArch64csinv GPR64:$tval, GPR64:$fval, (i32 imm:$cc), NZCV),
1623 (CSINVXr GPR64:$tval, GPR64:$fval, (i32 imm:$cc))>;
1624 def : Pat<(AArch64csneg GPR32:$tval, GPR32:$fval, (i32 imm:$cc), NZCV),
1625 (CSNEGWr GPR32:$tval, GPR32:$fval, (i32 imm:$cc))>;
1626 def : Pat<(AArch64csneg GPR64:$tval, GPR64:$fval, (i32 imm:$cc), NZCV),
1627 (CSNEGXr GPR64:$tval, GPR64:$fval, (i32 imm:$cc))>;
1628 def : Pat<(AArch64csinc GPR32:$tval, GPR32:$fval, (i32 imm:$cc), NZCV),
1629 (CSINCWr GPR32:$tval, GPR32:$fval, (i32 imm:$cc))>;
1630 def : Pat<(AArch64csinc GPR64:$tval, GPR64:$fval, (i32 imm:$cc), NZCV),
1631 (CSINCXr GPR64:$tval, GPR64:$fval, (i32 imm:$cc))>;
1633 def : Pat<(AArch64csel (i32 0), (i32 1), (i32 imm:$cc), NZCV),
1634 (CSINCWr WZR, WZR, (i32 imm:$cc))>;
1635 def : Pat<(AArch64csel (i64 0), (i64 1), (i32 imm:$cc), NZCV),
1636 (CSINCXr XZR, XZR, (i32 imm:$cc))>;
1637 def : Pat<(AArch64csel GPR32:$tval, (i32 1), (i32 imm:$cc), NZCV),
1638 (CSINCWr GPR32:$tval, WZR, (i32 imm:$cc))>;
1639 def : Pat<(AArch64csel GPR64:$tval, (i64 1), (i32 imm:$cc), NZCV),
1640 (CSINCXr GPR64:$tval, XZR, (i32 imm:$cc))>;
1641 def : Pat<(AArch64csel (i32 1), GPR32:$fval, (i32 imm:$cc), NZCV),
1642 (CSINCWr GPR32:$fval, WZR, (i32 (inv_cond_XFORM imm:$cc)))>;
1643 def : Pat<(AArch64csel (i64 1), GPR64:$fval, (i32 imm:$cc), NZCV),
1644 (CSINCXr GPR64:$fval, XZR, (i32 (inv_cond_XFORM imm:$cc)))>;
1645 def : Pat<(AArch64csel (i32 0), (i32 -1), (i32 imm:$cc), NZCV),
1646 (CSINVWr WZR, WZR, (i32 imm:$cc))>;
1647 def : Pat<(AArch64csel (i64 0), (i64 -1), (i32 imm:$cc), NZCV),
1648 (CSINVXr XZR, XZR, (i32 imm:$cc))>;
1649 def : Pat<(AArch64csel GPR32:$tval, (i32 -1), (i32 imm:$cc), NZCV),
1650 (CSINVWr GPR32:$tval, WZR, (i32 imm:$cc))>;
1651 def : Pat<(AArch64csel GPR64:$tval, (i64 -1), (i32 imm:$cc), NZCV),
1652 (CSINVXr GPR64:$tval, XZR, (i32 imm:$cc))>;
1653 def : Pat<(AArch64csel (i32 -1), GPR32:$fval, (i32 imm:$cc), NZCV),
1654 (CSINVWr GPR32:$fval, WZR, (i32 (inv_cond_XFORM imm:$cc)))>;
1655 def : Pat<(AArch64csel (i64 -1), GPR64:$fval, (i32 imm:$cc), NZCV),
1656 (CSINVXr GPR64:$fval, XZR, (i32 (inv_cond_XFORM imm:$cc)))>;
1658 // The inverse of the condition code from the alias instruction is what is used
1659 // in the aliased instruction. The parser all ready inverts the condition code
1660 // for these aliases.
1661 def : InstAlias<"cset $dst, $cc",
1662 (CSINCWr GPR32:$dst, WZR, WZR, inv_ccode:$cc)>;
1663 def : InstAlias<"cset $dst, $cc",
1664 (CSINCXr GPR64:$dst, XZR, XZR, inv_ccode:$cc)>;
1666 def : InstAlias<"csetm $dst, $cc",
1667 (CSINVWr GPR32:$dst, WZR, WZR, inv_ccode:$cc)>;
1668 def : InstAlias<"csetm $dst, $cc",
1669 (CSINVXr GPR64:$dst, XZR, XZR, inv_ccode:$cc)>;
1671 def : InstAlias<"cinc $dst, $src, $cc",
1672 (CSINCWr GPR32:$dst, GPR32:$src, GPR32:$src, inv_ccode:$cc)>;
1673 def : InstAlias<"cinc $dst, $src, $cc",
1674 (CSINCXr GPR64:$dst, GPR64:$src, GPR64:$src, inv_ccode:$cc)>;
1676 def : InstAlias<"cinv $dst, $src, $cc",
1677 (CSINVWr GPR32:$dst, GPR32:$src, GPR32:$src, inv_ccode:$cc)>;
1678 def : InstAlias<"cinv $dst, $src, $cc",
1679 (CSINVXr GPR64:$dst, GPR64:$src, GPR64:$src, inv_ccode:$cc)>;
1681 def : InstAlias<"cneg $dst, $src, $cc",
1682 (CSNEGWr GPR32:$dst, GPR32:$src, GPR32:$src, inv_ccode:$cc)>;
1683 def : InstAlias<"cneg $dst, $src, $cc",
1684 (CSNEGXr GPR64:$dst, GPR64:$src, GPR64:$src, inv_ccode:$cc)>;
1686 //===----------------------------------------------------------------------===//
1687 // PC-relative instructions.
1688 //===----------------------------------------------------------------------===//
1689 let isReMaterializable = 1 in {
1690 let hasSideEffects = 0, mayStore = 0, mayLoad = 0 in {
1691 def ADR : ADRI<0, "adr", adrlabel,
1692 [(set GPR64:$Xd, (AArch64adr tglobaladdr:$label))]>;
1693 } // hasSideEffects = 0
1695 def ADRP : ADRI<1, "adrp", adrplabel,
1696 [(set GPR64:$Xd, (AArch64adrp tglobaladdr:$label))]>;
1697 } // isReMaterializable = 1
1699 // page address of a constant pool entry, block address
1700 def : Pat<(AArch64adr tconstpool:$cp), (ADR tconstpool:$cp)>;
1701 def : Pat<(AArch64adr tblockaddress:$cp), (ADR tblockaddress:$cp)>;
1702 def : Pat<(AArch64adr texternalsym:$sym), (ADR texternalsym:$sym)>;
1703 def : Pat<(AArch64adr tjumptable:$sym), (ADR tjumptable:$sym)>;
1704 def : Pat<(AArch64adrp tconstpool:$cp), (ADRP tconstpool:$cp)>;
1705 def : Pat<(AArch64adrp tblockaddress:$cp), (ADRP tblockaddress:$cp)>;
1706 def : Pat<(AArch64adrp texternalsym:$sym), (ADRP texternalsym:$sym)>;
1708 //===----------------------------------------------------------------------===//
1709 // Unconditional branch (register) instructions.
1710 //===----------------------------------------------------------------------===//
1712 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
1713 def RET : BranchReg<0b0010, "ret", []>;
1714 def DRPS : SpecialReturn<0b0101, "drps">;
1715 def ERET : SpecialReturn<0b0100, "eret">;
1716 } // isReturn = 1, isTerminator = 1, isBarrier = 1
1718 // Default to the LR register.
1719 def : InstAlias<"ret", (RET LR)>;
1721 let isCall = 1, Defs = [LR], Uses = [SP] in {
1722 def BLR : BranchReg<0b0001, "blr", [(AArch64call GPR64:$Rn)]>;
1725 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
1726 def BR : BranchReg<0b0000, "br", [(brind GPR64:$Rn)]>;
1727 } // isBranch, isTerminator, isBarrier, isIndirectBranch
1729 // Create a separate pseudo-instruction for codegen to use so that we don't
1730 // flag lr as used in every function. It'll be restored before the RET by the
1731 // epilogue if it's legitimately used.
1732 def RET_ReallyLR : Pseudo<(outs), (ins), [(AArch64retflag)]>,
1733 Sched<[WriteBrReg]> {
1734 let isTerminator = 1;
1739 // This is a directive-like pseudo-instruction. The purpose is to insert an
1740 // R_AARCH64_TLSDESC_CALL relocation at the offset of the following instruction
1741 // (which in the usual case is a BLR).
1742 let hasSideEffects = 1 in
1743 def TLSDESCCALL : Pseudo<(outs), (ins i64imm:$sym), []>, Sched<[]> {
1744 let AsmString = ".tlsdesccall $sym";
1747 // Pseudo instruction to tell the streamer to emit a 'B' character into the
1748 // augmentation string.
1749 def EMITBKEY : Pseudo<(outs), (ins), []>, Sched<[]> {}
1751 // FIXME: maybe the scratch register used shouldn't be fixed to X1?
1752 // FIXME: can "hasSideEffects be dropped?
1753 let isCall = 1, Defs = [LR, X0, X1], hasSideEffects = 1,
1754 isCodeGenOnly = 1 in
1756 : Pseudo<(outs), (ins i64imm:$sym),
1757 [(AArch64tlsdesc_callseq tglobaltlsaddr:$sym)]>,
1758 Sched<[WriteI, WriteLD, WriteI, WriteBrReg]>;
1759 def : Pat<(AArch64tlsdesc_callseq texternalsym:$sym),
1760 (TLSDESC_CALLSEQ texternalsym:$sym)>;
1762 //===----------------------------------------------------------------------===//
1763 // Conditional branch (immediate) instruction.
1764 //===----------------------------------------------------------------------===//
1765 def Bcc : BranchCond;
1767 //===----------------------------------------------------------------------===//
1768 // Compare-and-branch instructions.
1769 //===----------------------------------------------------------------------===//
1770 defm CBZ : CmpBranch<0, "cbz", AArch64cbz>;
1771 defm CBNZ : CmpBranch<1, "cbnz", AArch64cbnz>;
1773 //===----------------------------------------------------------------------===//
1774 // Test-bit-and-branch instructions.
1775 //===----------------------------------------------------------------------===//
1776 defm TBZ : TestBranch<0, "tbz", AArch64tbz>;
1777 defm TBNZ : TestBranch<1, "tbnz", AArch64tbnz>;
1779 //===----------------------------------------------------------------------===//
1780 // Unconditional branch (immediate) instructions.
1781 //===----------------------------------------------------------------------===//
1782 let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
1783 def B : BranchImm<0, "b", [(br bb:$addr)]>;
1784 } // isBranch, isTerminator, isBarrier
1786 let isCall = 1, Defs = [LR], Uses = [SP] in {
1787 def BL : CallImm<1, "bl", [(AArch64call tglobaladdr:$addr)]>;
1789 def : Pat<(AArch64call texternalsym:$func), (BL texternalsym:$func)>;
1791 //===----------------------------------------------------------------------===//
1792 // Exception generation instructions.
1793 //===----------------------------------------------------------------------===//
1795 def BRK : ExceptionGeneration<0b001, 0b00, "brk">;
1797 def DCPS1 : ExceptionGeneration<0b101, 0b01, "dcps1">;
1798 def DCPS2 : ExceptionGeneration<0b101, 0b10, "dcps2">;
1799 def DCPS3 : ExceptionGeneration<0b101, 0b11, "dcps3">;
1800 def HLT : ExceptionGeneration<0b010, 0b00, "hlt">;
1801 def HVC : ExceptionGeneration<0b000, 0b10, "hvc">;
1802 def SMC : ExceptionGeneration<0b000, 0b11, "smc">;
1803 def SVC : ExceptionGeneration<0b000, 0b01, "svc">;
1805 // DCPSn defaults to an immediate operand of zero if unspecified.
1806 def : InstAlias<"dcps1", (DCPS1 0)>;
1807 def : InstAlias<"dcps2", (DCPS2 0)>;
1808 def : InstAlias<"dcps3", (DCPS3 0)>;
1810 def UDF : UDFType<0, "udf">;
1812 //===----------------------------------------------------------------------===//
1813 // Load instructions.
1814 //===----------------------------------------------------------------------===//
1816 // Pair (indexed, offset)
1817 defm LDPW : LoadPairOffset<0b00, 0, GPR32z, simm7s4, "ldp">;
1818 defm LDPX : LoadPairOffset<0b10, 0, GPR64z, simm7s8, "ldp">;
1819 defm LDPS : LoadPairOffset<0b00, 1, FPR32Op, simm7s4, "ldp">;
1820 defm LDPD : LoadPairOffset<0b01, 1, FPR64Op, simm7s8, "ldp">;
1821 defm LDPQ : LoadPairOffset<0b10, 1, FPR128Op, simm7s16, "ldp">;
1823 defm LDPSW : LoadPairOffset<0b01, 0, GPR64z, simm7s4, "ldpsw">;
1825 // Pair (pre-indexed)
1826 def LDPWpre : LoadPairPreIdx<0b00, 0, GPR32z, simm7s4, "ldp">;
1827 def LDPXpre : LoadPairPreIdx<0b10, 0, GPR64z, simm7s8, "ldp">;
1828 def LDPSpre : LoadPairPreIdx<0b00, 1, FPR32Op, simm7s4, "ldp">;
1829 def LDPDpre : LoadPairPreIdx<0b01, 1, FPR64Op, simm7s8, "ldp">;
1830 def LDPQpre : LoadPairPreIdx<0b10, 1, FPR128Op, simm7s16, "ldp">;
1832 def LDPSWpre : LoadPairPreIdx<0b01, 0, GPR64z, simm7s4, "ldpsw">;
1834 // Pair (post-indexed)
1835 def LDPWpost : LoadPairPostIdx<0b00, 0, GPR32z, simm7s4, "ldp">;
1836 def LDPXpost : LoadPairPostIdx<0b10, 0, GPR64z, simm7s8, "ldp">;
1837 def LDPSpost : LoadPairPostIdx<0b00, 1, FPR32Op, simm7s4, "ldp">;
1838 def LDPDpost : LoadPairPostIdx<0b01, 1, FPR64Op, simm7s8, "ldp">;
1839 def LDPQpost : LoadPairPostIdx<0b10, 1, FPR128Op, simm7s16, "ldp">;
1841 def LDPSWpost : LoadPairPostIdx<0b01, 0, GPR64z, simm7s4, "ldpsw">;
1844 // Pair (no allocate)
1845 defm LDNPW : LoadPairNoAlloc<0b00, 0, GPR32z, simm7s4, "ldnp">;
1846 defm LDNPX : LoadPairNoAlloc<0b10, 0, GPR64z, simm7s8, "ldnp">;
1847 defm LDNPS : LoadPairNoAlloc<0b00, 1, FPR32Op, simm7s4, "ldnp">;
1848 defm LDNPD : LoadPairNoAlloc<0b01, 1, FPR64Op, simm7s8, "ldnp">;
1849 defm LDNPQ : LoadPairNoAlloc<0b10, 1, FPR128Op, simm7s16, "ldnp">;
1852 // (register offset)
1856 defm LDRBB : Load8RO<0b00, 0, 0b01, GPR32, "ldrb", i32, zextloadi8>;
1857 defm LDRHH : Load16RO<0b01, 0, 0b01, GPR32, "ldrh", i32, zextloadi16>;
1858 defm LDRW : Load32RO<0b10, 0, 0b01, GPR32, "ldr", i32, load>;
1859 defm LDRX : Load64RO<0b11, 0, 0b01, GPR64, "ldr", i64, load>;
1862 defm LDRB : Load8RO<0b00, 1, 0b01, FPR8Op, "ldr", untyped, load>;
1863 defm LDRH : Load16RO<0b01, 1, 0b01, FPR16Op, "ldr", f16, load>;
1864 defm LDRS : Load32RO<0b10, 1, 0b01, FPR32Op, "ldr", f32, load>;
1865 defm LDRD : Load64RO<0b11, 1, 0b01, FPR64Op, "ldr", f64, load>;
1866 defm LDRQ : Load128RO<0b00, 1, 0b11, FPR128Op, "ldr", f128, load>;
1868 // Load sign-extended half-word
1869 defm LDRSHW : Load16RO<0b01, 0, 0b11, GPR32, "ldrsh", i32, sextloadi16>;
1870 defm LDRSHX : Load16RO<0b01, 0, 0b10, GPR64, "ldrsh", i64, sextloadi16>;
1872 // Load sign-extended byte
1873 defm LDRSBW : Load8RO<0b00, 0, 0b11, GPR32, "ldrsb", i32, sextloadi8>;
1874 defm LDRSBX : Load8RO<0b00, 0, 0b10, GPR64, "ldrsb", i64, sextloadi8>;
1876 // Load sign-extended word
1877 defm LDRSW : Load32RO<0b10, 0, 0b10, GPR64, "ldrsw", i64, sextloadi32>;
1880 defm PRFM : PrefetchRO<0b11, 0, 0b10, "prfm">;
1882 // For regular load, we do not have any alignment requirement.
1883 // Thus, it is safe to directly map the vector loads with interesting
1884 // addressing modes.
1885 // FIXME: We could do the same for bitconvert to floating point vectors.
1886 multiclass ScalToVecROLoadPat<ROAddrMode ro, SDPatternOperator loadop,
1887 ValueType ScalTy, ValueType VecTy,
1888 Instruction LOADW, Instruction LOADX,
1890 def : Pat<(VecTy (scalar_to_vector (ScalTy
1891 (loadop (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$offset))))),
1892 (INSERT_SUBREG (VecTy (IMPLICIT_DEF)),
1893 (LOADW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$offset),
1896 def : Pat<(VecTy (scalar_to_vector (ScalTy
1897 (loadop (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$offset))))),
1898 (INSERT_SUBREG (VecTy (IMPLICIT_DEF)),
1899 (LOADX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$offset),
1903 let AddedComplexity = 10 in {
1904 defm : ScalToVecROLoadPat<ro8, extloadi8, i32, v8i8, LDRBroW, LDRBroX, bsub>;
1905 defm : ScalToVecROLoadPat<ro8, extloadi8, i32, v16i8, LDRBroW, LDRBroX, bsub>;
1907 defm : ScalToVecROLoadPat<ro16, extloadi16, i32, v4i16, LDRHroW, LDRHroX, hsub>;
1908 defm : ScalToVecROLoadPat<ro16, extloadi16, i32, v8i16, LDRHroW, LDRHroX, hsub>;
1910 defm : ScalToVecROLoadPat<ro16, load, i32, v4f16, LDRHroW, LDRHroX, hsub>;
1911 defm : ScalToVecROLoadPat<ro16, load, i32, v8f16, LDRHroW, LDRHroX, hsub>;
1913 defm : ScalToVecROLoadPat<ro32, load, i32, v2i32, LDRSroW, LDRSroX, ssub>;
1914 defm : ScalToVecROLoadPat<ro32, load, i32, v4i32, LDRSroW, LDRSroX, ssub>;
1916 defm : ScalToVecROLoadPat<ro32, load, f32, v2f32, LDRSroW, LDRSroX, ssub>;
1917 defm : ScalToVecROLoadPat<ro32, load, f32, v4f32, LDRSroW, LDRSroX, ssub>;
1919 defm : ScalToVecROLoadPat<ro64, load, i64, v2i64, LDRDroW, LDRDroX, dsub>;
1921 defm : ScalToVecROLoadPat<ro64, load, f64, v2f64, LDRDroW, LDRDroX, dsub>;
1924 def : Pat <(v1i64 (scalar_to_vector (i64
1925 (load (ro_Windexed64 GPR64sp:$Rn, GPR32:$Rm,
1926 ro_Wextend64:$extend))))),
1927 (LDRDroW GPR64sp:$Rn, GPR32:$Rm, ro_Wextend64:$extend)>;
1929 def : Pat <(v1i64 (scalar_to_vector (i64
1930 (load (ro_Xindexed64 GPR64sp:$Rn, GPR64:$Rm,
1931 ro_Xextend64:$extend))))),
1932 (LDRDroX GPR64sp:$Rn, GPR64:$Rm, ro_Xextend64:$extend)>;
1935 // Match all load 64 bits width whose type is compatible with FPR64
1936 multiclass VecROLoadPat<ROAddrMode ro, ValueType VecTy,
1937 Instruction LOADW, Instruction LOADX> {
1939 def : Pat<(VecTy (load (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend))),
1940 (LOADW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
1942 def : Pat<(VecTy (load (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend))),
1943 (LOADX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
1946 let AddedComplexity = 10 in {
1947 let Predicates = [IsLE] in {
1948 // We must do vector loads with LD1 in big-endian.
1949 defm : VecROLoadPat<ro64, v2i32, LDRDroW, LDRDroX>;
1950 defm : VecROLoadPat<ro64, v2f32, LDRDroW, LDRDroX>;
1951 defm : VecROLoadPat<ro64, v8i8, LDRDroW, LDRDroX>;
1952 defm : VecROLoadPat<ro64, v4i16, LDRDroW, LDRDroX>;
1953 defm : VecROLoadPat<ro64, v4f16, LDRDroW, LDRDroX>;
1956 defm : VecROLoadPat<ro64, v1i64, LDRDroW, LDRDroX>;
1957 defm : VecROLoadPat<ro64, v1f64, LDRDroW, LDRDroX>;
1959 // Match all load 128 bits width whose type is compatible with FPR128
1960 let Predicates = [IsLE] in {
1961 // We must do vector loads with LD1 in big-endian.
1962 defm : VecROLoadPat<ro128, v2i64, LDRQroW, LDRQroX>;
1963 defm : VecROLoadPat<ro128, v2f64, LDRQroW, LDRQroX>;
1964 defm : VecROLoadPat<ro128, v4i32, LDRQroW, LDRQroX>;
1965 defm : VecROLoadPat<ro128, v4f32, LDRQroW, LDRQroX>;
1966 defm : VecROLoadPat<ro128, v8i16, LDRQroW, LDRQroX>;
1967 defm : VecROLoadPat<ro128, v8f16, LDRQroW, LDRQroX>;
1968 defm : VecROLoadPat<ro128, v16i8, LDRQroW, LDRQroX>;
1970 } // AddedComplexity = 10
1973 multiclass ExtLoadTo64ROPat<ROAddrMode ro, SDPatternOperator loadop,
1974 Instruction INSTW, Instruction INSTX> {
1975 def : Pat<(i64 (loadop (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend))),
1976 (SUBREG_TO_REG (i64 0),
1977 (INSTW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend),
1980 def : Pat<(i64 (loadop (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend))),
1981 (SUBREG_TO_REG (i64 0),
1982 (INSTX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend),
1986 let AddedComplexity = 10 in {
1987 defm : ExtLoadTo64ROPat<ro8, zextloadi8, LDRBBroW, LDRBBroX>;
1988 defm : ExtLoadTo64ROPat<ro16, zextloadi16, LDRHHroW, LDRHHroX>;
1989 defm : ExtLoadTo64ROPat<ro32, zextloadi32, LDRWroW, LDRWroX>;
1991 // zextloadi1 -> zextloadi8
1992 defm : ExtLoadTo64ROPat<ro8, zextloadi1, LDRBBroW, LDRBBroX>;
1994 // extload -> zextload
1995 defm : ExtLoadTo64ROPat<ro8, extloadi8, LDRBBroW, LDRBBroX>;
1996 defm : ExtLoadTo64ROPat<ro16, extloadi16, LDRHHroW, LDRHHroX>;
1997 defm : ExtLoadTo64ROPat<ro32, extloadi32, LDRWroW, LDRWroX>;
1999 // extloadi1 -> zextloadi8
2000 defm : ExtLoadTo64ROPat<ro8, extloadi1, LDRBBroW, LDRBBroX>;
2005 multiclass ExtLoadTo32ROPat<ROAddrMode ro, SDPatternOperator loadop,
2006 Instruction INSTW, Instruction INSTX> {
2007 def : Pat<(i32 (loadop (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend))),
2008 (INSTW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
2010 def : Pat<(i32 (loadop (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend))),
2011 (INSTX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
2015 let AddedComplexity = 10 in {
2016 // extload -> zextload
2017 defm : ExtLoadTo32ROPat<ro8, extloadi8, LDRBBroW, LDRBBroX>;
2018 defm : ExtLoadTo32ROPat<ro16, extloadi16, LDRHHroW, LDRHHroX>;
2019 defm : ExtLoadTo32ROPat<ro32, extloadi32, LDRWroW, LDRWroX>;
2021 // zextloadi1 -> zextloadi8
2022 defm : ExtLoadTo32ROPat<ro8, zextloadi1, LDRBBroW, LDRBBroX>;
2026 // (unsigned immediate)
2028 defm LDRX : LoadUI<0b11, 0, 0b01, GPR64z, uimm12s8, "ldr",
2030 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)))]>;
2031 defm LDRW : LoadUI<0b10, 0, 0b01, GPR32z, uimm12s4, "ldr",
2033 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset)))]>;
2034 defm LDRB : LoadUI<0b00, 1, 0b01, FPR8Op, uimm12s1, "ldr",
2036 (load (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset)))]>;
2037 defm LDRH : LoadUI<0b01, 1, 0b01, FPR16Op, uimm12s2, "ldr",
2038 [(set (f16 FPR16Op:$Rt),
2039 (load (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset)))]>;
2040 defm LDRS : LoadUI<0b10, 1, 0b01, FPR32Op, uimm12s4, "ldr",
2041 [(set (f32 FPR32Op:$Rt),
2042 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset)))]>;
2043 defm LDRD : LoadUI<0b11, 1, 0b01, FPR64Op, uimm12s8, "ldr",
2044 [(set (f64 FPR64Op:$Rt),
2045 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)))]>;
2046 defm LDRQ : LoadUI<0b00, 1, 0b11, FPR128Op, uimm12s16, "ldr",
2047 [(set (f128 FPR128Op:$Rt),
2048 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)))]>;
2050 // For regular load, we do not have any alignment requirement.
2051 // Thus, it is safe to directly map the vector loads with interesting
2052 // addressing modes.
2053 // FIXME: We could do the same for bitconvert to floating point vectors.
2054 def : Pat <(v8i8 (scalar_to_vector (i32
2055 (extloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))))),
2056 (INSERT_SUBREG (v8i8 (IMPLICIT_DEF)),
2057 (LDRBui GPR64sp:$Rn, uimm12s1:$offset), bsub)>;
2058 def : Pat <(v16i8 (scalar_to_vector (i32
2059 (extloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))))),
2060 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
2061 (LDRBui GPR64sp:$Rn, uimm12s1:$offset), bsub)>;
2062 def : Pat <(v4i16 (scalar_to_vector (i32
2063 (extloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))))),
2064 (INSERT_SUBREG (v4i16 (IMPLICIT_DEF)),
2065 (LDRHui GPR64sp:$Rn, uimm12s2:$offset), hsub)>;
2066 def : Pat <(v8i16 (scalar_to_vector (i32
2067 (extloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))))),
2068 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)),
2069 (LDRHui GPR64sp:$Rn, uimm12s2:$offset), hsub)>;
2070 def : Pat <(v2i32 (scalar_to_vector (i32
2071 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))))),
2072 (INSERT_SUBREG (v2i32 (IMPLICIT_DEF)),
2073 (LDRSui GPR64sp:$Rn, uimm12s4:$offset), ssub)>;
2074 def : Pat <(v4i32 (scalar_to_vector (i32
2075 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))))),
2076 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)),
2077 (LDRSui GPR64sp:$Rn, uimm12s4:$offset), ssub)>;
2078 def : Pat <(v1i64 (scalar_to_vector (i64
2079 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))))),
2080 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2081 def : Pat <(v2i64 (scalar_to_vector (i64
2082 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))))),
2083 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)),
2084 (LDRDui GPR64sp:$Rn, uimm12s8:$offset), dsub)>;
2086 // Match all load 64 bits width whose type is compatible with FPR64
2087 let Predicates = [IsLE] in {
2088 // We must use LD1 to perform vector loads in big-endian.
2089 def : Pat<(v2f32 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2090 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2091 def : Pat<(v8i8 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2092 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2093 def : Pat<(v4i16 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2094 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2095 def : Pat<(v2i32 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2096 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2097 def : Pat<(v4f16 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2098 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2100 def : Pat<(v1f64 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2101 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2102 def : Pat<(v1i64 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2103 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2105 // Match all load 128 bits width whose type is compatible with FPR128
2106 let Predicates = [IsLE] in {
2107 // We must use LD1 to perform vector loads in big-endian.
2108 def : Pat<(v4f32 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2109 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2110 def : Pat<(v2f64 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2111 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2112 def : Pat<(v16i8 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2113 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2114 def : Pat<(v8i16 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2115 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2116 def : Pat<(v4i32 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2117 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2118 def : Pat<(v2i64 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2119 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2120 def : Pat<(v8f16 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2121 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2123 def : Pat<(f128 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2124 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2126 defm LDRHH : LoadUI<0b01, 0, 0b01, GPR32, uimm12s2, "ldrh",
2128 (zextloadi16 (am_indexed16 GPR64sp:$Rn,
2129 uimm12s2:$offset)))]>;
2130 defm LDRBB : LoadUI<0b00, 0, 0b01, GPR32, uimm12s1, "ldrb",
2132 (zextloadi8 (am_indexed8 GPR64sp:$Rn,
2133 uimm12s1:$offset)))]>;
2135 def : Pat<(i64 (zextloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2136 (SUBREG_TO_REG (i64 0), (LDRBBui GPR64sp:$Rn, uimm12s1:$offset), sub_32)>;
2137 def : Pat<(i64 (zextloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))),
2138 (SUBREG_TO_REG (i64 0), (LDRHHui GPR64sp:$Rn, uimm12s2:$offset), sub_32)>;
2140 // zextloadi1 -> zextloadi8
2141 def : Pat<(i32 (zextloadi1 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2142 (LDRBBui GPR64sp:$Rn, uimm12s1:$offset)>;
2143 def : Pat<(i64 (zextloadi1 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2144 (SUBREG_TO_REG (i64 0), (LDRBBui GPR64sp:$Rn, uimm12s1:$offset), sub_32)>;
2146 // extload -> zextload
2147 def : Pat<(i32 (extloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))),
2148 (LDRHHui GPR64sp:$Rn, uimm12s2:$offset)>;
2149 def : Pat<(i32 (extloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2150 (LDRBBui GPR64sp:$Rn, uimm12s1:$offset)>;
2151 def : Pat<(i32 (extloadi1 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2152 (LDRBBui GPR64sp:$Rn, uimm12s1:$offset)>;
2153 def : Pat<(i64 (extloadi32 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))),
2154 (SUBREG_TO_REG (i64 0), (LDRWui GPR64sp:$Rn, uimm12s4:$offset), sub_32)>;
2155 def : Pat<(i64 (extloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))),
2156 (SUBREG_TO_REG (i64 0), (LDRHHui GPR64sp:$Rn, uimm12s2:$offset), sub_32)>;
2157 def : Pat<(i64 (extloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2158 (SUBREG_TO_REG (i64 0), (LDRBBui GPR64sp:$Rn, uimm12s1:$offset), sub_32)>;
2159 def : Pat<(i64 (extloadi1 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2160 (SUBREG_TO_REG (i64 0), (LDRBBui GPR64sp:$Rn, uimm12s1:$offset), sub_32)>;
2162 // load sign-extended half-word
2163 defm LDRSHW : LoadUI<0b01, 0, 0b11, GPR32, uimm12s2, "ldrsh",
2165 (sextloadi16 (am_indexed16 GPR64sp:$Rn,
2166 uimm12s2:$offset)))]>;
2167 defm LDRSHX : LoadUI<0b01, 0, 0b10, GPR64, uimm12s2, "ldrsh",
2169 (sextloadi16 (am_indexed16 GPR64sp:$Rn,
2170 uimm12s2:$offset)))]>;
2172 // load sign-extended byte
2173 defm LDRSBW : LoadUI<0b00, 0, 0b11, GPR32, uimm12s1, "ldrsb",
2175 (sextloadi8 (am_indexed8 GPR64sp:$Rn,
2176 uimm12s1:$offset)))]>;
2177 defm LDRSBX : LoadUI<0b00, 0, 0b10, GPR64, uimm12s1, "ldrsb",
2179 (sextloadi8 (am_indexed8 GPR64sp:$Rn,
2180 uimm12s1:$offset)))]>;
2182 // load sign-extended word
2183 defm LDRSW : LoadUI<0b10, 0, 0b10, GPR64, uimm12s4, "ldrsw",
2185 (sextloadi32 (am_indexed32 GPR64sp:$Rn,
2186 uimm12s4:$offset)))]>;
2188 // load zero-extended word
2189 def : Pat<(i64 (zextloadi32 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))),
2190 (SUBREG_TO_REG (i64 0), (LDRWui GPR64sp:$Rn, uimm12s4:$offset), sub_32)>;
2193 def PRFMui : PrefetchUI<0b11, 0, 0b10, "prfm",
2194 [(AArch64Prefetch imm:$Rt,
2195 (am_indexed64 GPR64sp:$Rn,
2196 uimm12s8:$offset))]>;
2198 def : InstAlias<"prfm $Rt, [$Rn]", (PRFMui prfop:$Rt, GPR64sp:$Rn, 0)>;
2203 def alignedglobal : PatLeaf<(iPTR iPTR:$label), [{
2204 if (auto *G = dyn_cast<GlobalAddressSDNode>(N)) {
2205 const DataLayout &DL = MF->getDataLayout();
2206 unsigned Align = G->getGlobal()->getPointerAlignment(DL);
2207 return Align >= 4 && G->getOffset() % 4 == 0;
2209 if (auto *C = dyn_cast<ConstantPoolSDNode>(N))
2210 return C->getAlignment() >= 4 && C->getOffset() % 4 == 0;
2214 def LDRWl : LoadLiteral<0b00, 0, GPR32z, "ldr",
2215 [(set GPR32z:$Rt, (load (AArch64adr alignedglobal:$label)))]>;
2216 def LDRXl : LoadLiteral<0b01, 0, GPR64z, "ldr",
2217 [(set GPR64z:$Rt, (load (AArch64adr alignedglobal:$label)))]>;
2218 def LDRSl : LoadLiteral<0b00, 1, FPR32Op, "ldr",
2219 [(set (f32 FPR32Op:$Rt), (load (AArch64adr alignedglobal:$label)))]>;
2220 def LDRDl : LoadLiteral<0b01, 1, FPR64Op, "ldr",
2221 [(set (f64 FPR64Op:$Rt), (load (AArch64adr alignedglobal:$label)))]>;
2222 def LDRQl : LoadLiteral<0b10, 1, FPR128Op, "ldr",
2223 [(set (f128 FPR128Op:$Rt), (load (AArch64adr alignedglobal:$label)))]>;
2225 // load sign-extended word
2226 def LDRSWl : LoadLiteral<0b10, 0, GPR64z, "ldrsw",
2227 [(set GPR64z:$Rt, (sextloadi32 (AArch64adr alignedglobal:$label)))]>;
2229 let AddedComplexity = 20 in {
2230 def : Pat<(i64 (zextloadi32 (AArch64adr alignedglobal:$label))),
2231 (SUBREG_TO_REG (i64 0), (LDRWl $label), sub_32)>;
2235 def PRFMl : PrefetchLiteral<0b11, 0, "prfm", []>;
2236 // [(AArch64Prefetch imm:$Rt, tglobaladdr:$label)]>;
2239 // (unscaled immediate)
2240 defm LDURX : LoadUnscaled<0b11, 0, 0b01, GPR64z, "ldur",
2242 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset)))]>;
2243 defm LDURW : LoadUnscaled<0b10, 0, 0b01, GPR32z, "ldur",
2245 (load (am_unscaled32 GPR64sp:$Rn, simm9:$offset)))]>;
2246 defm LDURB : LoadUnscaled<0b00, 1, 0b01, FPR8Op, "ldur",
2248 (load (am_unscaled8 GPR64sp:$Rn, simm9:$offset)))]>;
2249 defm LDURH : LoadUnscaled<0b01, 1, 0b01, FPR16Op, "ldur",
2251 (load (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
2252 defm LDURS : LoadUnscaled<0b10, 1, 0b01, FPR32Op, "ldur",
2253 [(set (f32 FPR32Op:$Rt),
2254 (load (am_unscaled32 GPR64sp:$Rn, simm9:$offset)))]>;
2255 defm LDURD : LoadUnscaled<0b11, 1, 0b01, FPR64Op, "ldur",
2256 [(set (f64 FPR64Op:$Rt),
2257 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset)))]>;
2258 defm LDURQ : LoadUnscaled<0b00, 1, 0b11, FPR128Op, "ldur",
2259 [(set (f128 FPR128Op:$Rt),
2260 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset)))]>;
2263 : LoadUnscaled<0b01, 0, 0b01, GPR32, "ldurh",
2265 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
2267 : LoadUnscaled<0b00, 0, 0b01, GPR32, "ldurb",
2269 (zextloadi8 (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
2271 // Match all load 64 bits width whose type is compatible with FPR64
2272 let Predicates = [IsLE] in {
2273 def : Pat<(v2f32 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2274 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2275 def : Pat<(v2i32 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2276 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2277 def : Pat<(v4i16 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2278 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2279 def : Pat<(v8i8 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2280 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2281 def : Pat<(v4f16 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2282 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2284 def : Pat<(v1f64 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2285 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2286 def : Pat<(v1i64 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2287 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2289 // Match all load 128 bits width whose type is compatible with FPR128
2290 let Predicates = [IsLE] in {
2291 def : Pat<(v2f64 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2292 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2293 def : Pat<(v2i64 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2294 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2295 def : Pat<(v4f32 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2296 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2297 def : Pat<(v4i32 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2298 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2299 def : Pat<(v8i16 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2300 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2301 def : Pat<(v16i8 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2302 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2303 def : Pat<(v8f16 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2304 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2308 def : Pat<(i32 (extloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
2309 (LDURHHi GPR64sp:$Rn, simm9:$offset)>;
2310 def : Pat<(i32 (extloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2311 (LDURBBi GPR64sp:$Rn, simm9:$offset)>;
2312 def : Pat<(i32 (extloadi1 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2313 (LDURBBi GPR64sp:$Rn, simm9:$offset)>;
2314 def : Pat<(i64 (extloadi32 (am_unscaled32 GPR64sp:$Rn, simm9:$offset))),
2315 (SUBREG_TO_REG (i64 0), (LDURWi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2316 def : Pat<(i64 (extloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
2317 (SUBREG_TO_REG (i64 0), (LDURHHi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2318 def : Pat<(i64 (extloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2319 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2320 def : Pat<(i64 (extloadi1 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2321 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2323 def : Pat<(i32 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
2324 (LDURHHi GPR64sp:$Rn, simm9:$offset)>;
2325 def : Pat<(i32 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2326 (LDURBBi GPR64sp:$Rn, simm9:$offset)>;
2327 def : Pat<(i32 (zextloadi1 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2328 (LDURBBi GPR64sp:$Rn, simm9:$offset)>;
2329 def : Pat<(i64 (zextloadi32 (am_unscaled32 GPR64sp:$Rn, simm9:$offset))),
2330 (SUBREG_TO_REG (i64 0), (LDURWi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2331 def : Pat<(i64 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
2332 (SUBREG_TO_REG (i64 0), (LDURHHi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2333 def : Pat<(i64 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2334 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2335 def : Pat<(i64 (zextloadi1 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2336 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2340 // LDR mnemonics fall back to LDUR for negative or unaligned offsets.
2342 // Define new assembler match classes as we want to only match these when
2343 // the don't otherwise match the scaled addressing mode for LDR/STR. Don't
2344 // associate a DiagnosticType either, as we want the diagnostic for the
2345 // canonical form (the scaled operand) to take precedence.
2346 class SImm9OffsetOperand<int Width> : AsmOperandClass {
2347 let Name = "SImm9OffsetFB" # Width;
2348 let PredicateMethod = "isSImm9OffsetFB<" # Width # ">";
2349 let RenderMethod = "addImmOperands";
2352 def SImm9OffsetFB8Operand : SImm9OffsetOperand<8>;
2353 def SImm9OffsetFB16Operand : SImm9OffsetOperand<16>;
2354 def SImm9OffsetFB32Operand : SImm9OffsetOperand<32>;
2355 def SImm9OffsetFB64Operand : SImm9OffsetOperand<64>;
2356 def SImm9OffsetFB128Operand : SImm9OffsetOperand<128>;
2358 def simm9_offset_fb8 : Operand<i64> {
2359 let ParserMatchClass = SImm9OffsetFB8Operand;
2361 def simm9_offset_fb16 : Operand<i64> {
2362 let ParserMatchClass = SImm9OffsetFB16Operand;
2364 def simm9_offset_fb32 : Operand<i64> {
2365 let ParserMatchClass = SImm9OffsetFB32Operand;
2367 def simm9_offset_fb64 : Operand<i64> {
2368 let ParserMatchClass = SImm9OffsetFB64Operand;
2370 def simm9_offset_fb128 : Operand<i64> {
2371 let ParserMatchClass = SImm9OffsetFB128Operand;
2374 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2375 (LDURXi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb64:$offset), 0>;
2376 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2377 (LDURWi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
2378 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2379 (LDURBi FPR8Op:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2380 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2381 (LDURHi FPR16Op:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2382 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2383 (LDURSi FPR32Op:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
2384 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2385 (LDURDi FPR64Op:$Rt, GPR64sp:$Rn, simm9_offset_fb64:$offset), 0>;
2386 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2387 (LDURQi FPR128Op:$Rt, GPR64sp:$Rn, simm9_offset_fb128:$offset), 0>;
2390 def : Pat<(i64 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2391 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2392 def : Pat<(i64 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
2393 (SUBREG_TO_REG (i64 0), (LDURHHi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2395 // load sign-extended half-word
2397 : LoadUnscaled<0b01, 0, 0b11, GPR32, "ldursh",
2399 (sextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
2401 : LoadUnscaled<0b01, 0, 0b10, GPR64, "ldursh",
2403 (sextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
2405 // load sign-extended byte
2407 : LoadUnscaled<0b00, 0, 0b11, GPR32, "ldursb",
2409 (sextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset)))]>;
2411 : LoadUnscaled<0b00, 0, 0b10, GPR64, "ldursb",
2413 (sextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset)))]>;
2415 // load sign-extended word
2417 : LoadUnscaled<0b10, 0, 0b10, GPR64, "ldursw",
2419 (sextloadi32 (am_unscaled32 GPR64sp:$Rn, simm9:$offset)))]>;
2421 // zero and sign extending aliases from generic LDR* mnemonics to LDUR*.
2422 def : InstAlias<"ldrb $Rt, [$Rn, $offset]",
2423 (LDURBBi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2424 def : InstAlias<"ldrh $Rt, [$Rn, $offset]",
2425 (LDURHHi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2426 def : InstAlias<"ldrsb $Rt, [$Rn, $offset]",
2427 (LDURSBWi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2428 def : InstAlias<"ldrsb $Rt, [$Rn, $offset]",
2429 (LDURSBXi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2430 def : InstAlias<"ldrsh $Rt, [$Rn, $offset]",
2431 (LDURSHWi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2432 def : InstAlias<"ldrsh $Rt, [$Rn, $offset]",
2433 (LDURSHXi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2434 def : InstAlias<"ldrsw $Rt, [$Rn, $offset]",
2435 (LDURSWi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
2438 defm PRFUM : PrefetchUnscaled<0b11, 0, 0b10, "prfum",
2439 [(AArch64Prefetch imm:$Rt,
2440 (am_unscaled64 GPR64sp:$Rn, simm9:$offset))]>;
2443 // (unscaled immediate, unprivileged)
2444 defm LDTRX : LoadUnprivileged<0b11, 0, 0b01, GPR64, "ldtr">;
2445 defm LDTRW : LoadUnprivileged<0b10, 0, 0b01, GPR32, "ldtr">;
2447 defm LDTRH : LoadUnprivileged<0b01, 0, 0b01, GPR32, "ldtrh">;
2448 defm LDTRB : LoadUnprivileged<0b00, 0, 0b01, GPR32, "ldtrb">;
2450 // load sign-extended half-word
2451 defm LDTRSHW : LoadUnprivileged<0b01, 0, 0b11, GPR32, "ldtrsh">;
2452 defm LDTRSHX : LoadUnprivileged<0b01, 0, 0b10, GPR64, "ldtrsh">;
2454 // load sign-extended byte
2455 defm LDTRSBW : LoadUnprivileged<0b00, 0, 0b11, GPR32, "ldtrsb">;
2456 defm LDTRSBX : LoadUnprivileged<0b00, 0, 0b10, GPR64, "ldtrsb">;
2458 // load sign-extended word
2459 defm LDTRSW : LoadUnprivileged<0b10, 0, 0b10, GPR64, "ldtrsw">;
2462 // (immediate pre-indexed)
2463 def LDRWpre : LoadPreIdx<0b10, 0, 0b01, GPR32z, "ldr">;
2464 def LDRXpre : LoadPreIdx<0b11, 0, 0b01, GPR64z, "ldr">;
2465 def LDRBpre : LoadPreIdx<0b00, 1, 0b01, FPR8Op, "ldr">;
2466 def LDRHpre : LoadPreIdx<0b01, 1, 0b01, FPR16Op, "ldr">;
2467 def LDRSpre : LoadPreIdx<0b10, 1, 0b01, FPR32Op, "ldr">;
2468 def LDRDpre : LoadPreIdx<0b11, 1, 0b01, FPR64Op, "ldr">;
2469 def LDRQpre : LoadPreIdx<0b00, 1, 0b11, FPR128Op, "ldr">;
2471 // load sign-extended half-word
2472 def LDRSHWpre : LoadPreIdx<0b01, 0, 0b11, GPR32z, "ldrsh">;
2473 def LDRSHXpre : LoadPreIdx<0b01, 0, 0b10, GPR64z, "ldrsh">;
2475 // load sign-extended byte
2476 def LDRSBWpre : LoadPreIdx<0b00, 0, 0b11, GPR32z, "ldrsb">;
2477 def LDRSBXpre : LoadPreIdx<0b00, 0, 0b10, GPR64z, "ldrsb">;
2479 // load zero-extended byte
2480 def LDRBBpre : LoadPreIdx<0b00, 0, 0b01, GPR32z, "ldrb">;
2481 def LDRHHpre : LoadPreIdx<0b01, 0, 0b01, GPR32z, "ldrh">;
2483 // load sign-extended word
2484 def LDRSWpre : LoadPreIdx<0b10, 0, 0b10, GPR64z, "ldrsw">;
2487 // (immediate post-indexed)
2488 def LDRWpost : LoadPostIdx<0b10, 0, 0b01, GPR32z, "ldr">;
2489 def LDRXpost : LoadPostIdx<0b11, 0, 0b01, GPR64z, "ldr">;
2490 def LDRBpost : LoadPostIdx<0b00, 1, 0b01, FPR8Op, "ldr">;
2491 def LDRHpost : LoadPostIdx<0b01, 1, 0b01, FPR16Op, "ldr">;
2492 def LDRSpost : LoadPostIdx<0b10, 1, 0b01, FPR32Op, "ldr">;
2493 def LDRDpost : LoadPostIdx<0b11, 1, 0b01, FPR64Op, "ldr">;
2494 def LDRQpost : LoadPostIdx<0b00, 1, 0b11, FPR128Op, "ldr">;
2496 // load sign-extended half-word
2497 def LDRSHWpost : LoadPostIdx<0b01, 0, 0b11, GPR32z, "ldrsh">;
2498 def LDRSHXpost : LoadPostIdx<0b01, 0, 0b10, GPR64z, "ldrsh">;
2500 // load sign-extended byte
2501 def LDRSBWpost : LoadPostIdx<0b00, 0, 0b11, GPR32z, "ldrsb">;
2502 def LDRSBXpost : LoadPostIdx<0b00, 0, 0b10, GPR64z, "ldrsb">;
2504 // load zero-extended byte
2505 def LDRBBpost : LoadPostIdx<0b00, 0, 0b01, GPR32z, "ldrb">;
2506 def LDRHHpost : LoadPostIdx<0b01, 0, 0b01, GPR32z, "ldrh">;
2508 // load sign-extended word
2509 def LDRSWpost : LoadPostIdx<0b10, 0, 0b10, GPR64z, "ldrsw">;
2511 //===----------------------------------------------------------------------===//
2512 // Store instructions.
2513 //===----------------------------------------------------------------------===//
2515 // Pair (indexed, offset)
2516 // FIXME: Use dedicated range-checked addressing mode operand here.
2517 defm STPW : StorePairOffset<0b00, 0, GPR32z, simm7s4, "stp">;
2518 defm STPX : StorePairOffset<0b10, 0, GPR64z, simm7s8, "stp">;
2519 defm STPS : StorePairOffset<0b00, 1, FPR32Op, simm7s4, "stp">;
2520 defm STPD : StorePairOffset<0b01, 1, FPR64Op, simm7s8, "stp">;
2521 defm STPQ : StorePairOffset<0b10, 1, FPR128Op, simm7s16, "stp">;
2523 // Pair (pre-indexed)
2524 def STPWpre : StorePairPreIdx<0b00, 0, GPR32z, simm7s4, "stp">;
2525 def STPXpre : StorePairPreIdx<0b10, 0, GPR64z, simm7s8, "stp">;
2526 def STPSpre : StorePairPreIdx<0b00, 1, FPR32Op, simm7s4, "stp">;
2527 def STPDpre : StorePairPreIdx<0b01, 1, FPR64Op, simm7s8, "stp">;
2528 def STPQpre : StorePairPreIdx<0b10, 1, FPR128Op, simm7s16, "stp">;
2530 // Pair (pre-indexed)
2531 def STPWpost : StorePairPostIdx<0b00, 0, GPR32z, simm7s4, "stp">;
2532 def STPXpost : StorePairPostIdx<0b10, 0, GPR64z, simm7s8, "stp">;
2533 def STPSpost : StorePairPostIdx<0b00, 1, FPR32Op, simm7s4, "stp">;
2534 def STPDpost : StorePairPostIdx<0b01, 1, FPR64Op, simm7s8, "stp">;
2535 def STPQpost : StorePairPostIdx<0b10, 1, FPR128Op, simm7s16, "stp">;
2537 // Pair (no allocate)
2538 defm STNPW : StorePairNoAlloc<0b00, 0, GPR32z, simm7s4, "stnp">;
2539 defm STNPX : StorePairNoAlloc<0b10, 0, GPR64z, simm7s8, "stnp">;
2540 defm STNPS : StorePairNoAlloc<0b00, 1, FPR32Op, simm7s4, "stnp">;
2541 defm STNPD : StorePairNoAlloc<0b01, 1, FPR64Op, simm7s8, "stnp">;
2542 defm STNPQ : StorePairNoAlloc<0b10, 1, FPR128Op, simm7s16, "stnp">;
2545 // (Register offset)
2548 defm STRBB : Store8RO< 0b00, 0, 0b00, GPR32, "strb", i32, truncstorei8>;
2549 defm STRHH : Store16RO<0b01, 0, 0b00, GPR32, "strh", i32, truncstorei16>;
2550 defm STRW : Store32RO<0b10, 0, 0b00, GPR32, "str", i32, store>;
2551 defm STRX : Store64RO<0b11, 0, 0b00, GPR64, "str", i64, store>;
2555 defm STRB : Store8RO< 0b00, 1, 0b00, FPR8Op, "str", untyped, store>;
2556 defm STRH : Store16RO<0b01, 1, 0b00, FPR16Op, "str", f16, store>;
2557 defm STRS : Store32RO<0b10, 1, 0b00, FPR32Op, "str", f32, store>;
2558 defm STRD : Store64RO<0b11, 1, 0b00, FPR64Op, "str", f64, store>;
2559 defm STRQ : Store128RO<0b00, 1, 0b10, FPR128Op, "str", f128, store>;
2561 let Predicates = [UseSTRQro], AddedComplexity = 10 in {
2562 def : Pat<(store (f128 FPR128:$Rt),
2563 (ro_Windexed128 GPR64sp:$Rn, GPR32:$Rm,
2564 ro_Wextend128:$extend)),
2565 (STRQroW FPR128:$Rt, GPR64sp:$Rn, GPR32:$Rm, ro_Wextend128:$extend)>;
2566 def : Pat<(store (f128 FPR128:$Rt),
2567 (ro_Xindexed128 GPR64sp:$Rn, GPR64:$Rm,
2568 ro_Xextend128:$extend)),
2569 (STRQroX FPR128:$Rt, GPR64sp:$Rn, GPR64:$Rm, ro_Wextend128:$extend)>;
2572 multiclass TruncStoreFrom64ROPat<ROAddrMode ro, SDPatternOperator storeop,
2573 Instruction STRW, Instruction STRX> {
2575 def : Pat<(storeop GPR64:$Rt,
2576 (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)),
2577 (STRW (EXTRACT_SUBREG GPR64:$Rt, sub_32),
2578 GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
2580 def : Pat<(storeop GPR64:$Rt,
2581 (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)),
2582 (STRX (EXTRACT_SUBREG GPR64:$Rt, sub_32),
2583 GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
2586 let AddedComplexity = 10 in {
2588 defm : TruncStoreFrom64ROPat<ro8, truncstorei8, STRBBroW, STRBBroX>;
2589 defm : TruncStoreFrom64ROPat<ro16, truncstorei16, STRHHroW, STRHHroX>;
2590 defm : TruncStoreFrom64ROPat<ro32, truncstorei32, STRWroW, STRWroX>;
2593 multiclass VecROStorePat<ROAddrMode ro, ValueType VecTy, RegisterClass FPR,
2594 Instruction STRW, Instruction STRX> {
2595 def : Pat<(store (VecTy FPR:$Rt),
2596 (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)),
2597 (STRW FPR:$Rt, GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
2599 def : Pat<(store (VecTy FPR:$Rt),
2600 (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)),
2601 (STRX FPR:$Rt, GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
2604 let AddedComplexity = 10 in {
2605 // Match all store 64 bits width whose type is compatible with FPR64
2606 let Predicates = [IsLE] in {
2607 // We must use ST1 to store vectors in big-endian.
2608 defm : VecROStorePat<ro64, v2i32, FPR64, STRDroW, STRDroX>;
2609 defm : VecROStorePat<ro64, v2f32, FPR64, STRDroW, STRDroX>;
2610 defm : VecROStorePat<ro64, v4i16, FPR64, STRDroW, STRDroX>;
2611 defm : VecROStorePat<ro64, v8i8, FPR64, STRDroW, STRDroX>;
2612 defm : VecROStorePat<ro64, v4f16, FPR64, STRDroW, STRDroX>;
2615 defm : VecROStorePat<ro64, v1i64, FPR64, STRDroW, STRDroX>;
2616 defm : VecROStorePat<ro64, v1f64, FPR64, STRDroW, STRDroX>;
2618 // Match all store 128 bits width whose type is compatible with FPR128
2619 let Predicates = [IsLE, UseSTRQro] in {
2620 // We must use ST1 to store vectors in big-endian.
2621 defm : VecROStorePat<ro128, v2i64, FPR128, STRQroW, STRQroX>;
2622 defm : VecROStorePat<ro128, v2f64, FPR128, STRQroW, STRQroX>;
2623 defm : VecROStorePat<ro128, v4i32, FPR128, STRQroW, STRQroX>;
2624 defm : VecROStorePat<ro128, v4f32, FPR128, STRQroW, STRQroX>;
2625 defm : VecROStorePat<ro128, v8i16, FPR128, STRQroW, STRQroX>;
2626 defm : VecROStorePat<ro128, v16i8, FPR128, STRQroW, STRQroX>;
2627 defm : VecROStorePat<ro128, v8f16, FPR128, STRQroW, STRQroX>;
2629 } // AddedComplexity = 10
2631 // Match stores from lane 0 to the appropriate subreg's store.
2632 multiclass VecROStoreLane0Pat<ROAddrMode ro, SDPatternOperator storeop,
2633 ValueType VecTy, ValueType STy,
2634 SubRegIndex SubRegIdx,
2635 Instruction STRW, Instruction STRX> {
2637 def : Pat<(storeop (STy (vector_extract (VecTy VecListOne128:$Vt), 0)),
2638 (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)),
2639 (STRW (EXTRACT_SUBREG VecListOne128:$Vt, SubRegIdx),
2640 GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
2642 def : Pat<(storeop (STy (vector_extract (VecTy VecListOne128:$Vt), 0)),
2643 (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)),
2644 (STRX (EXTRACT_SUBREG VecListOne128:$Vt, SubRegIdx),
2645 GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
2648 let AddedComplexity = 19 in {
2649 defm : VecROStoreLane0Pat<ro16, truncstorei16, v8i16, i32, hsub, STRHroW, STRHroX>;
2650 defm : VecROStoreLane0Pat<ro16, store, v8f16, f16, hsub, STRHroW, STRHroX>;
2651 defm : VecROStoreLane0Pat<ro32, store, v4i32, i32, ssub, STRSroW, STRSroX>;
2652 defm : VecROStoreLane0Pat<ro32, store, v4f32, f32, ssub, STRSroW, STRSroX>;
2653 defm : VecROStoreLane0Pat<ro64, store, v2i64, i64, dsub, STRDroW, STRDroX>;
2654 defm : VecROStoreLane0Pat<ro64, store, v2f64, f64, dsub, STRDroW, STRDroX>;
2658 // (unsigned immediate)
2659 defm STRX : StoreUIz<0b11, 0, 0b00, GPR64z, uimm12s8, "str",
2661 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))]>;
2662 defm STRW : StoreUIz<0b10, 0, 0b00, GPR32z, uimm12s4, "str",
2664 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))]>;
2665 defm STRB : StoreUI<0b00, 1, 0b00, FPR8Op, uimm12s1, "str",
2667 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))]>;
2668 defm STRH : StoreUI<0b01, 1, 0b00, FPR16Op, uimm12s2, "str",
2669 [(store (f16 FPR16Op:$Rt),
2670 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))]>;
2671 defm STRS : StoreUI<0b10, 1, 0b00, FPR32Op, uimm12s4, "str",
2672 [(store (f32 FPR32Op:$Rt),
2673 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))]>;
2674 defm STRD : StoreUI<0b11, 1, 0b00, FPR64Op, uimm12s8, "str",
2675 [(store (f64 FPR64Op:$Rt),
2676 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))]>;
2677 defm STRQ : StoreUI<0b00, 1, 0b10, FPR128Op, uimm12s16, "str", []>;
2679 defm STRHH : StoreUIz<0b01, 0, 0b00, GPR32z, uimm12s2, "strh",
2680 [(truncstorei16 GPR32z:$Rt,
2681 (am_indexed16 GPR64sp:$Rn,
2682 uimm12s2:$offset))]>;
2683 defm STRBB : StoreUIz<0b00, 0, 0b00, GPR32z, uimm12s1, "strb",
2684 [(truncstorei8 GPR32z:$Rt,
2685 (am_indexed8 GPR64sp:$Rn,
2686 uimm12s1:$offset))]>;
2688 let AddedComplexity = 10 in {
2690 // Match all store 64 bits width whose type is compatible with FPR64
2691 def : Pat<(store (v1i64 FPR64:$Rt),
2692 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2693 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2694 def : Pat<(store (v1f64 FPR64:$Rt),
2695 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2696 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2698 let Predicates = [IsLE] in {
2699 // We must use ST1 to store vectors in big-endian.
2700 def : Pat<(store (v2f32 FPR64:$Rt),
2701 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2702 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2703 def : Pat<(store (v8i8 FPR64:$Rt),
2704 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2705 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2706 def : Pat<(store (v4i16 FPR64:$Rt),
2707 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2708 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2709 def : Pat<(store (v2i32 FPR64:$Rt),
2710 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2711 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2712 def : Pat<(store (v4f16 FPR64:$Rt),
2713 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2714 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2717 // Match all store 128 bits width whose type is compatible with FPR128
2718 def : Pat<(store (f128 FPR128:$Rt),
2719 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2720 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2722 let Predicates = [IsLE] in {
2723 // We must use ST1 to store vectors in big-endian.
2724 def : Pat<(store (v4f32 FPR128:$Rt),
2725 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2726 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2727 def : Pat<(store (v2f64 FPR128:$Rt),
2728 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2729 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2730 def : Pat<(store (v16i8 FPR128:$Rt),
2731 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2732 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2733 def : Pat<(store (v8i16 FPR128:$Rt),
2734 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2735 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2736 def : Pat<(store (v4i32 FPR128:$Rt),
2737 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2738 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2739 def : Pat<(store (v2i64 FPR128:$Rt),
2740 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2741 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2742 def : Pat<(store (v8f16 FPR128:$Rt),
2743 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2744 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2748 def : Pat<(truncstorei32 GPR64:$Rt,
2749 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset)),
2750 (STRWui (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, uimm12s4:$offset)>;
2751 def : Pat<(truncstorei16 GPR64:$Rt,
2752 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset)),
2753 (STRHHui (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, uimm12s2:$offset)>;
2754 def : Pat<(truncstorei8 GPR64:$Rt, (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset)),
2755 (STRBBui (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, uimm12s1:$offset)>;
2757 } // AddedComplexity = 10
2759 // Match stores from lane 0 to the appropriate subreg's store.
2760 multiclass VecStoreLane0Pat<Operand UIAddrMode, SDPatternOperator storeop,
2761 ValueType VTy, ValueType STy,
2762 SubRegIndex SubRegIdx, Operand IndexType,
2764 def : Pat<(storeop (STy (vector_extract (VTy VecListOne128:$Vt), 0)),
2765 (UIAddrMode GPR64sp:$Rn, IndexType:$offset)),
2766 (STR (EXTRACT_SUBREG VecListOne128:$Vt, SubRegIdx),
2767 GPR64sp:$Rn, IndexType:$offset)>;
2770 let AddedComplexity = 19 in {
2771 defm : VecStoreLane0Pat<am_indexed16, truncstorei16, v8i16, i32, hsub, uimm12s2, STRHui>;
2772 defm : VecStoreLane0Pat<am_indexed16, store, v8f16, f16, hsub, uimm12s2, STRHui>;
2773 defm : VecStoreLane0Pat<am_indexed32, store, v4i32, i32, ssub, uimm12s4, STRSui>;
2774 defm : VecStoreLane0Pat<am_indexed32, store, v4f32, f32, ssub, uimm12s4, STRSui>;
2775 defm : VecStoreLane0Pat<am_indexed64, store, v2i64, i64, dsub, uimm12s8, STRDui>;
2776 defm : VecStoreLane0Pat<am_indexed64, store, v2f64, f64, dsub, uimm12s8, STRDui>;
2780 // (unscaled immediate)
2781 defm STURX : StoreUnscaled<0b11, 0, 0b00, GPR64z, "stur",
2783 (am_unscaled64 GPR64sp:$Rn, simm9:$offset))]>;
2784 defm STURW : StoreUnscaled<0b10, 0, 0b00, GPR32z, "stur",
2786 (am_unscaled32 GPR64sp:$Rn, simm9:$offset))]>;
2787 defm STURB : StoreUnscaled<0b00, 1, 0b00, FPR8Op, "stur",
2789 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))]>;
2790 defm STURH : StoreUnscaled<0b01, 1, 0b00, FPR16Op, "stur",
2791 [(store (f16 FPR16Op:$Rt),
2792 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))]>;
2793 defm STURS : StoreUnscaled<0b10, 1, 0b00, FPR32Op, "stur",
2794 [(store (f32 FPR32Op:$Rt),
2795 (am_unscaled32 GPR64sp:$Rn, simm9:$offset))]>;
2796 defm STURD : StoreUnscaled<0b11, 1, 0b00, FPR64Op, "stur",
2797 [(store (f64 FPR64Op:$Rt),
2798 (am_unscaled64 GPR64sp:$Rn, simm9:$offset))]>;
2799 defm STURQ : StoreUnscaled<0b00, 1, 0b10, FPR128Op, "stur",
2800 [(store (f128 FPR128Op:$Rt),
2801 (am_unscaled128 GPR64sp:$Rn, simm9:$offset))]>;
2802 defm STURHH : StoreUnscaled<0b01, 0, 0b00, GPR32z, "sturh",
2803 [(truncstorei16 GPR32z:$Rt,
2804 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))]>;
2805 defm STURBB : StoreUnscaled<0b00, 0, 0b00, GPR32z, "sturb",
2806 [(truncstorei8 GPR32z:$Rt,
2807 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))]>;
2809 // Armv8.4 Weaker Release Consistency enhancements
2810 // LDAPR & STLR with Immediate Offset instructions
2811 let Predicates = [HasRCPC_IMMO] in {
2812 defm STLURB : BaseStoreUnscaleV84<"stlurb", 0b00, 0b00, GPR32>;
2813 defm STLURH : BaseStoreUnscaleV84<"stlurh", 0b01, 0b00, GPR32>;
2814 defm STLURW : BaseStoreUnscaleV84<"stlur", 0b10, 0b00, GPR32>;
2815 defm STLURX : BaseStoreUnscaleV84<"stlur", 0b11, 0b00, GPR64>;
2816 defm LDAPURB : BaseLoadUnscaleV84<"ldapurb", 0b00, 0b01, GPR32>;
2817 defm LDAPURSBW : BaseLoadUnscaleV84<"ldapursb", 0b00, 0b11, GPR32>;
2818 defm LDAPURSBX : BaseLoadUnscaleV84<"ldapursb", 0b00, 0b10, GPR64>;
2819 defm LDAPURH : BaseLoadUnscaleV84<"ldapurh", 0b01, 0b01, GPR32>;
2820 defm LDAPURSHW : BaseLoadUnscaleV84<"ldapursh", 0b01, 0b11, GPR32>;
2821 defm LDAPURSHX : BaseLoadUnscaleV84<"ldapursh", 0b01, 0b10, GPR64>;
2822 defm LDAPUR : BaseLoadUnscaleV84<"ldapur", 0b10, 0b01, GPR32>;
2823 defm LDAPURSW : BaseLoadUnscaleV84<"ldapursw", 0b10, 0b10, GPR64>;
2824 defm LDAPURX : BaseLoadUnscaleV84<"ldapur", 0b11, 0b01, GPR64>;
2827 // Match all store 64 bits width whose type is compatible with FPR64
2828 def : Pat<(store (v1f64 FPR64:$Rt), (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2829 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2830 def : Pat<(store (v1i64 FPR64:$Rt), (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2831 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2833 let AddedComplexity = 10 in {
2835 let Predicates = [IsLE] in {
2836 // We must use ST1 to store vectors in big-endian.
2837 def : Pat<(store (v2f32 FPR64:$Rt),
2838 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2839 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2840 def : Pat<(store (v8i8 FPR64:$Rt),
2841 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2842 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2843 def : Pat<(store (v4i16 FPR64:$Rt),
2844 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2845 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2846 def : Pat<(store (v2i32 FPR64:$Rt),
2847 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2848 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2849 def : Pat<(store (v4f16 FPR64:$Rt),
2850 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2851 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2854 // Match all store 128 bits width whose type is compatible with FPR128
2855 def : Pat<(store (f128 FPR128:$Rt), (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2856 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2858 let Predicates = [IsLE] in {
2859 // We must use ST1 to store vectors in big-endian.
2860 def : Pat<(store (v4f32 FPR128:$Rt),
2861 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2862 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2863 def : Pat<(store (v2f64 FPR128:$Rt),
2864 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2865 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2866 def : Pat<(store (v16i8 FPR128:$Rt),
2867 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2868 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2869 def : Pat<(store (v8i16 FPR128:$Rt),
2870 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2871 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2872 def : Pat<(store (v4i32 FPR128:$Rt),
2873 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2874 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2875 def : Pat<(store (v2i64 FPR128:$Rt),
2876 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2877 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2878 def : Pat<(store (v2f64 FPR128:$Rt),
2879 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2880 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2881 def : Pat<(store (v8f16 FPR128:$Rt),
2882 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2883 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2886 } // AddedComplexity = 10
2888 // unscaled i64 truncating stores
2889 def : Pat<(truncstorei32 GPR64:$Rt, (am_unscaled32 GPR64sp:$Rn, simm9:$offset)),
2890 (STURWi (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, simm9:$offset)>;
2891 def : Pat<(truncstorei16 GPR64:$Rt, (am_unscaled16 GPR64sp:$Rn, simm9:$offset)),
2892 (STURHHi (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, simm9:$offset)>;
2893 def : Pat<(truncstorei8 GPR64:$Rt, (am_unscaled8 GPR64sp:$Rn, simm9:$offset)),
2894 (STURBBi (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, simm9:$offset)>;
2896 // Match stores from lane 0 to the appropriate subreg's store.
2897 multiclass VecStoreULane0Pat<SDPatternOperator StoreOp,
2898 ValueType VTy, ValueType STy,
2899 SubRegIndex SubRegIdx, Instruction STR> {
2900 defm : VecStoreLane0Pat<am_unscaled128, StoreOp, VTy, STy, SubRegIdx, simm9, STR>;
2903 let AddedComplexity = 19 in {
2904 defm : VecStoreULane0Pat<truncstorei16, v8i16, i32, hsub, STURHi>;
2905 defm : VecStoreULane0Pat<store, v8f16, f16, hsub, STURHi>;
2906 defm : VecStoreULane0Pat<store, v4i32, i32, ssub, STURSi>;
2907 defm : VecStoreULane0Pat<store, v4f32, f32, ssub, STURSi>;
2908 defm : VecStoreULane0Pat<store, v2i64, i64, dsub, STURDi>;
2909 defm : VecStoreULane0Pat<store, v2f64, f64, dsub, STURDi>;
2913 // STR mnemonics fall back to STUR for negative or unaligned offsets.
2914 def : InstAlias<"str $Rt, [$Rn, $offset]",
2915 (STURXi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb64:$offset), 0>;
2916 def : InstAlias<"str $Rt, [$Rn, $offset]",
2917 (STURWi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
2918 def : InstAlias<"str $Rt, [$Rn, $offset]",
2919 (STURBi FPR8Op:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2920 def : InstAlias<"str $Rt, [$Rn, $offset]",
2921 (STURHi FPR16Op:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2922 def : InstAlias<"str $Rt, [$Rn, $offset]",
2923 (STURSi FPR32Op:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
2924 def : InstAlias<"str $Rt, [$Rn, $offset]",
2925 (STURDi FPR64Op:$Rt, GPR64sp:$Rn, simm9_offset_fb64:$offset), 0>;
2926 def : InstAlias<"str $Rt, [$Rn, $offset]",
2927 (STURQi FPR128Op:$Rt, GPR64sp:$Rn, simm9_offset_fb128:$offset), 0>;
2929 def : InstAlias<"strb $Rt, [$Rn, $offset]",
2930 (STURBBi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2931 def : InstAlias<"strh $Rt, [$Rn, $offset]",
2932 (STURHHi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2935 // (unscaled immediate, unprivileged)
2936 defm STTRW : StoreUnprivileged<0b10, 0, 0b00, GPR32, "sttr">;
2937 defm STTRX : StoreUnprivileged<0b11, 0, 0b00, GPR64, "sttr">;
2939 defm STTRH : StoreUnprivileged<0b01, 0, 0b00, GPR32, "sttrh">;
2940 defm STTRB : StoreUnprivileged<0b00, 0, 0b00, GPR32, "sttrb">;
2943 // (immediate pre-indexed)
2944 def STRWpre : StorePreIdx<0b10, 0, 0b00, GPR32z, "str", pre_store, i32>;
2945 def STRXpre : StorePreIdx<0b11, 0, 0b00, GPR64z, "str", pre_store, i64>;
2946 def STRBpre : StorePreIdx<0b00, 1, 0b00, FPR8Op, "str", pre_store, untyped>;
2947 def STRHpre : StorePreIdx<0b01, 1, 0b00, FPR16Op, "str", pre_store, f16>;
2948 def STRSpre : StorePreIdx<0b10, 1, 0b00, FPR32Op, "str", pre_store, f32>;
2949 def STRDpre : StorePreIdx<0b11, 1, 0b00, FPR64Op, "str", pre_store, f64>;
2950 def STRQpre : StorePreIdx<0b00, 1, 0b10, FPR128Op, "str", pre_store, f128>;
2952 def STRBBpre : StorePreIdx<0b00, 0, 0b00, GPR32z, "strb", pre_truncsti8, i32>;
2953 def STRHHpre : StorePreIdx<0b01, 0, 0b00, GPR32z, "strh", pre_truncsti16, i32>;
2956 def : Pat<(pre_truncsti32 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
2957 (STRWpre (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
2959 def : Pat<(pre_truncsti16 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
2960 (STRHHpre (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
2962 def : Pat<(pre_truncsti8 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
2963 (STRBBpre (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
2966 def : Pat<(pre_store (v8i8 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2967 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2968 def : Pat<(pre_store (v4i16 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2969 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2970 def : Pat<(pre_store (v2i32 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2971 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2972 def : Pat<(pre_store (v2f32 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2973 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2974 def : Pat<(pre_store (v1i64 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2975 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2976 def : Pat<(pre_store (v1f64 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2977 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2978 def : Pat<(pre_store (v4f16 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2979 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2981 def : Pat<(pre_store (v16i8 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2982 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2983 def : Pat<(pre_store (v8i16 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2984 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2985 def : Pat<(pre_store (v4i32 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2986 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2987 def : Pat<(pre_store (v4f32 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2988 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2989 def : Pat<(pre_store (v2i64 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2990 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2991 def : Pat<(pre_store (v2f64 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2992 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2993 def : Pat<(pre_store (v8f16 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2994 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2997 // (immediate post-indexed)
2998 def STRWpost : StorePostIdx<0b10, 0, 0b00, GPR32z, "str", post_store, i32>;
2999 def STRXpost : StorePostIdx<0b11, 0, 0b00, GPR64z, "str", post_store, i64>;
3000 def STRBpost : StorePostIdx<0b00, 1, 0b00, FPR8Op, "str", post_store, untyped>;
3001 def STRHpost : StorePostIdx<0b01, 1, 0b00, FPR16Op, "str", post_store, f16>;
3002 def STRSpost : StorePostIdx<0b10, 1, 0b00, FPR32Op, "str", post_store, f32>;
3003 def STRDpost : StorePostIdx<0b11, 1, 0b00, FPR64Op, "str", post_store, f64>;
3004 def STRQpost : StorePostIdx<0b00, 1, 0b10, FPR128Op, "str", post_store, f128>;
3006 def STRBBpost : StorePostIdx<0b00, 0, 0b00, GPR32z, "strb", post_truncsti8, i32>;
3007 def STRHHpost : StorePostIdx<0b01, 0, 0b00, GPR32z, "strh", post_truncsti16, i32>;
3010 def : Pat<(post_truncsti32 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
3011 (STRWpost (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
3013 def : Pat<(post_truncsti16 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
3014 (STRHHpost (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
3016 def : Pat<(post_truncsti8 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
3017 (STRBBpost (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
3020 def : Pat<(post_store (v8i8 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
3021 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
3022 def : Pat<(post_store (v4i16 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
3023 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
3024 def : Pat<(post_store (v2i32 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
3025 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
3026 def : Pat<(post_store (v2f32 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
3027 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
3028 def : Pat<(post_store (v1i64 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
3029 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
3030 def : Pat<(post_store (v1f64 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
3031 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
3032 def : Pat<(post_store (v4f16 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
3033 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
3035 def : Pat<(post_store (v16i8 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3036 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3037 def : Pat<(post_store (v8i16 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3038 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3039 def : Pat<(post_store (v4i32 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3040 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3041 def : Pat<(post_store (v4f32 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3042 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3043 def : Pat<(post_store (v2i64 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3044 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3045 def : Pat<(post_store (v2f64 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3046 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3047 def : Pat<(post_store (v8f16 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3048 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3050 //===----------------------------------------------------------------------===//
3051 // Load/store exclusive instructions.
3052 //===----------------------------------------------------------------------===//
3054 def LDARW : LoadAcquire <0b10, 1, 1, 0, 1, GPR32, "ldar">;
3055 def LDARX : LoadAcquire <0b11, 1, 1, 0, 1, GPR64, "ldar">;
3056 def LDARB : LoadAcquire <0b00, 1, 1, 0, 1, GPR32, "ldarb">;
3057 def LDARH : LoadAcquire <0b01, 1, 1, 0, 1, GPR32, "ldarh">;
3059 def LDAXRW : LoadExclusive <0b10, 0, 1, 0, 1, GPR32, "ldaxr">;
3060 def LDAXRX : LoadExclusive <0b11, 0, 1, 0, 1, GPR64, "ldaxr">;
3061 def LDAXRB : LoadExclusive <0b00, 0, 1, 0, 1, GPR32, "ldaxrb">;
3062 def LDAXRH : LoadExclusive <0b01, 0, 1, 0, 1, GPR32, "ldaxrh">;
3064 def LDXRW : LoadExclusive <0b10, 0, 1, 0, 0, GPR32, "ldxr">;
3065 def LDXRX : LoadExclusive <0b11, 0, 1, 0, 0, GPR64, "ldxr">;
3066 def LDXRB : LoadExclusive <0b00, 0, 1, 0, 0, GPR32, "ldxrb">;
3067 def LDXRH : LoadExclusive <0b01, 0, 1, 0, 0, GPR32, "ldxrh">;
3069 def STLRW : StoreRelease <0b10, 1, 0, 0, 1, GPR32, "stlr">;
3070 def STLRX : StoreRelease <0b11, 1, 0, 0, 1, GPR64, "stlr">;
3071 def STLRB : StoreRelease <0b00, 1, 0, 0, 1, GPR32, "stlrb">;
3072 def STLRH : StoreRelease <0b01, 1, 0, 0, 1, GPR32, "stlrh">;
3074 def STLXRW : StoreExclusive<0b10, 0, 0, 0, 1, GPR32, "stlxr">;
3075 def STLXRX : StoreExclusive<0b11, 0, 0, 0, 1, GPR64, "stlxr">;
3076 def STLXRB : StoreExclusive<0b00, 0, 0, 0, 1, GPR32, "stlxrb">;
3077 def STLXRH : StoreExclusive<0b01, 0, 0, 0, 1, GPR32, "stlxrh">;
3079 def STXRW : StoreExclusive<0b10, 0, 0, 0, 0, GPR32, "stxr">;
3080 def STXRX : StoreExclusive<0b11, 0, 0, 0, 0, GPR64, "stxr">;
3081 def STXRB : StoreExclusive<0b00, 0, 0, 0, 0, GPR32, "stxrb">;
3082 def STXRH : StoreExclusive<0b01, 0, 0, 0, 0, GPR32, "stxrh">;
3084 def LDAXPW : LoadExclusivePair<0b10, 0, 1, 1, 1, GPR32, "ldaxp">;
3085 def LDAXPX : LoadExclusivePair<0b11, 0, 1, 1, 1, GPR64, "ldaxp">;
3087 def LDXPW : LoadExclusivePair<0b10, 0, 1, 1, 0, GPR32, "ldxp">;
3088 def LDXPX : LoadExclusivePair<0b11, 0, 1, 1, 0, GPR64, "ldxp">;
3090 def STLXPW : StoreExclusivePair<0b10, 0, 0, 1, 1, GPR32, "stlxp">;
3091 def STLXPX : StoreExclusivePair<0b11, 0, 0, 1, 1, GPR64, "stlxp">;
3093 def STXPW : StoreExclusivePair<0b10, 0, 0, 1, 0, GPR32, "stxp">;
3094 def STXPX : StoreExclusivePair<0b11, 0, 0, 1, 0, GPR64, "stxp">;
3096 let Predicates = [HasLOR] in {
3097 // v8.1a "Limited Order Region" extension load-acquire instructions
3098 def LDLARW : LoadAcquire <0b10, 1, 1, 0, 0, GPR32, "ldlar">;
3099 def LDLARX : LoadAcquire <0b11, 1, 1, 0, 0, GPR64, "ldlar">;
3100 def LDLARB : LoadAcquire <0b00, 1, 1, 0, 0, GPR32, "ldlarb">;
3101 def LDLARH : LoadAcquire <0b01, 1, 1, 0, 0, GPR32, "ldlarh">;
3103 // v8.1a "Limited Order Region" extension store-release instructions
3104 def STLLRW : StoreRelease <0b10, 1, 0, 0, 0, GPR32, "stllr">;
3105 def STLLRX : StoreRelease <0b11, 1, 0, 0, 0, GPR64, "stllr">;
3106 def STLLRB : StoreRelease <0b00, 1, 0, 0, 0, GPR32, "stllrb">;
3107 def STLLRH : StoreRelease <0b01, 1, 0, 0, 0, GPR32, "stllrh">;
3110 //===----------------------------------------------------------------------===//
3111 // Scaled floating point to integer conversion instructions.
3112 //===----------------------------------------------------------------------===//
3114 defm FCVTAS : FPToIntegerUnscaled<0b00, 0b100, "fcvtas", int_aarch64_neon_fcvtas>;
3115 defm FCVTAU : FPToIntegerUnscaled<0b00, 0b101, "fcvtau", int_aarch64_neon_fcvtau>;
3116 defm FCVTMS : FPToIntegerUnscaled<0b10, 0b000, "fcvtms", int_aarch64_neon_fcvtms>;
3117 defm FCVTMU : FPToIntegerUnscaled<0b10, 0b001, "fcvtmu", int_aarch64_neon_fcvtmu>;
3118 defm FCVTNS : FPToIntegerUnscaled<0b00, 0b000, "fcvtns", int_aarch64_neon_fcvtns>;
3119 defm FCVTNU : FPToIntegerUnscaled<0b00, 0b001, "fcvtnu", int_aarch64_neon_fcvtnu>;
3120 defm FCVTPS : FPToIntegerUnscaled<0b01, 0b000, "fcvtps", int_aarch64_neon_fcvtps>;
3121 defm FCVTPU : FPToIntegerUnscaled<0b01, 0b001, "fcvtpu", int_aarch64_neon_fcvtpu>;
3122 defm FCVTZS : FPToIntegerUnscaled<0b11, 0b000, "fcvtzs", fp_to_sint>;
3123 defm FCVTZU : FPToIntegerUnscaled<0b11, 0b001, "fcvtzu", fp_to_uint>;
3124 defm FCVTZS : FPToIntegerScaled<0b11, 0b000, "fcvtzs", fp_to_sint>;
3125 defm FCVTZU : FPToIntegerScaled<0b11, 0b001, "fcvtzu", fp_to_uint>;
3127 multiclass FPToIntegerIntPats<Intrinsic round, string INST> {
3128 def : Pat<(i32 (round f16:$Rn)), (!cast<Instruction>(INST # UWHr) $Rn)>;
3129 def : Pat<(i64 (round f16:$Rn)), (!cast<Instruction>(INST # UXHr) $Rn)>;
3130 def : Pat<(i32 (round f32:$Rn)), (!cast<Instruction>(INST # UWSr) $Rn)>;
3131 def : Pat<(i64 (round f32:$Rn)), (!cast<Instruction>(INST # UXSr) $Rn)>;
3132 def : Pat<(i32 (round f64:$Rn)), (!cast<Instruction>(INST # UWDr) $Rn)>;
3133 def : Pat<(i64 (round f64:$Rn)), (!cast<Instruction>(INST # UXDr) $Rn)>;
3135 def : Pat<(i32 (round (fmul f16:$Rn, fixedpoint_f16_i32:$scale))),
3136 (!cast<Instruction>(INST # SWHri) $Rn, $scale)>;
3137 def : Pat<(i64 (round (fmul f16:$Rn, fixedpoint_f16_i64:$scale))),
3138 (!cast<Instruction>(INST # SXHri) $Rn, $scale)>;
3139 def : Pat<(i32 (round (fmul f32:$Rn, fixedpoint_f32_i32:$scale))),
3140 (!cast<Instruction>(INST # SWSri) $Rn, $scale)>;
3141 def : Pat<(i64 (round (fmul f32:$Rn, fixedpoint_f32_i64:$scale))),
3142 (!cast<Instruction>(INST # SXSri) $Rn, $scale)>;
3143 def : Pat<(i32 (round (fmul f64:$Rn, fixedpoint_f64_i32:$scale))),
3144 (!cast<Instruction>(INST # SWDri) $Rn, $scale)>;
3145 def : Pat<(i64 (round (fmul f64:$Rn, fixedpoint_f64_i64:$scale))),
3146 (!cast<Instruction>(INST # SXDri) $Rn, $scale)>;
3149 defm : FPToIntegerIntPats<int_aarch64_neon_fcvtzs, "FCVTZS">;
3150 defm : FPToIntegerIntPats<int_aarch64_neon_fcvtzu, "FCVTZU">;
3152 multiclass FPToIntegerPats<SDNode to_int, SDNode round, string INST> {
3153 def : Pat<(i32 (to_int (round f32:$Rn))),
3154 (!cast<Instruction>(INST # UWSr) f32:$Rn)>;
3155 def : Pat<(i64 (to_int (round f32:$Rn))),
3156 (!cast<Instruction>(INST # UXSr) f32:$Rn)>;
3157 def : Pat<(i32 (to_int (round f64:$Rn))),
3158 (!cast<Instruction>(INST # UWDr) f64:$Rn)>;
3159 def : Pat<(i64 (to_int (round f64:$Rn))),
3160 (!cast<Instruction>(INST # UXDr) f64:$Rn)>;
3163 defm : FPToIntegerPats<fp_to_sint, fceil, "FCVTPS">;
3164 defm : FPToIntegerPats<fp_to_uint, fceil, "FCVTPU">;
3165 defm : FPToIntegerPats<fp_to_sint, ffloor, "FCVTMS">;
3166 defm : FPToIntegerPats<fp_to_uint, ffloor, "FCVTMU">;
3167 defm : FPToIntegerPats<fp_to_sint, ftrunc, "FCVTZS">;
3168 defm : FPToIntegerPats<fp_to_uint, ftrunc, "FCVTZU">;
3169 defm : FPToIntegerPats<fp_to_sint, fround, "FCVTAS">;
3170 defm : FPToIntegerPats<fp_to_uint, fround, "FCVTAU">;
3172 let Predicates = [HasFullFP16] in {
3173 def : Pat<(i32 (lround f16:$Rn)),
3174 (!cast<Instruction>(FCVTASUWHr) f16:$Rn)>;
3175 def : Pat<(i64 (lround f16:$Rn)),
3176 (!cast<Instruction>(FCVTASUXHr) f16:$Rn)>;
3177 def : Pat<(i64 (llround f16:$Rn)),
3178 (!cast<Instruction>(FCVTASUXHr) f16:$Rn)>;
3180 def : Pat<(i32 (lround f32:$Rn)),
3181 (!cast<Instruction>(FCVTASUWSr) f32:$Rn)>;
3182 def : Pat<(i32 (lround f64:$Rn)),
3183 (!cast<Instruction>(FCVTASUWDr) f64:$Rn)>;
3184 def : Pat<(i64 (lround f32:$Rn)),
3185 (!cast<Instruction>(FCVTASUXSr) f32:$Rn)>;
3186 def : Pat<(i64 (lround f64:$Rn)),
3187 (!cast<Instruction>(FCVTASUXDr) f64:$Rn)>;
3188 def : Pat<(i64 (llround f32:$Rn)),
3189 (!cast<Instruction>(FCVTASUXSr) f32:$Rn)>;
3190 def : Pat<(i64 (llround f64:$Rn)),
3191 (!cast<Instruction>(FCVTASUXDr) f64:$Rn)>;
3193 //===----------------------------------------------------------------------===//
3194 // Scaled integer to floating point conversion instructions.
3195 //===----------------------------------------------------------------------===//
3197 defm SCVTF : IntegerToFP<0, "scvtf", sint_to_fp>;
3198 defm UCVTF : IntegerToFP<1, "ucvtf", uint_to_fp>;
3200 //===----------------------------------------------------------------------===//
3201 // Unscaled integer to floating point conversion instruction.
3202 //===----------------------------------------------------------------------===//
3204 defm FMOV : UnscaledConversion<"fmov">;
3206 // Add pseudo ops for FMOV 0 so we can mark them as isReMaterializable
3207 let isReMaterializable = 1, isCodeGenOnly = 1, isAsCheapAsAMove = 1 in {
3208 def FMOVH0 : Pseudo<(outs FPR16:$Rd), (ins), [(set f16:$Rd, (fpimm0))]>,
3209 Sched<[WriteF]>, Requires<[HasFullFP16]>;
3210 def FMOVS0 : Pseudo<(outs FPR32:$Rd), (ins), [(set f32:$Rd, (fpimm0))]>,
3212 def FMOVD0 : Pseudo<(outs FPR64:$Rd), (ins), [(set f64:$Rd, (fpimm0))]>,
3215 // Similarly add aliases
3216 def : InstAlias<"fmov $Rd, #0.0", (FMOVWHr FPR16:$Rd, WZR), 0>,
3217 Requires<[HasFullFP16]>;
3218 def : InstAlias<"fmov $Rd, #0.0", (FMOVWSr FPR32:$Rd, WZR), 0>;
3219 def : InstAlias<"fmov $Rd, #0.0", (FMOVXDr FPR64:$Rd, XZR), 0>;
3221 //===----------------------------------------------------------------------===//
3222 // Floating point conversion instruction.
3223 //===----------------------------------------------------------------------===//
3225 defm FCVT : FPConversion<"fcvt">;
3227 //===----------------------------------------------------------------------===//
3228 // Floating point single operand instructions.
3229 //===----------------------------------------------------------------------===//
3231 defm FABS : SingleOperandFPData<0b0001, "fabs", fabs>;
3232 defm FMOV : SingleOperandFPData<0b0000, "fmov">;
3233 defm FNEG : SingleOperandFPData<0b0010, "fneg", fneg>;
3234 defm FRINTA : SingleOperandFPData<0b1100, "frinta", fround>;
3235 defm FRINTI : SingleOperandFPData<0b1111, "frinti", fnearbyint>;
3236 defm FRINTM : SingleOperandFPData<0b1010, "frintm", ffloor>;
3237 defm FRINTN : SingleOperandFPData<0b1000, "frintn", int_aarch64_neon_frintn>;
3238 defm FRINTP : SingleOperandFPData<0b1001, "frintp", fceil>;
3240 def : Pat<(v1f64 (int_aarch64_neon_frintn (v1f64 FPR64:$Rn))),
3241 (FRINTNDr FPR64:$Rn)>;
3243 defm FRINTX : SingleOperandFPData<0b1110, "frintx", frint>;
3244 defm FRINTZ : SingleOperandFPData<0b1011, "frintz", ftrunc>;
3246 let SchedRW = [WriteFDiv] in {
3247 defm FSQRT : SingleOperandFPData<0b0011, "fsqrt", fsqrt>;
3250 let Predicates = [HasFRInt3264] in {
3251 defm FRINT32Z : FRIntNNT<0b00, "frint32z">;
3252 defm FRINT64Z : FRIntNNT<0b10, "frint64z">;
3253 defm FRINT32X : FRIntNNT<0b01, "frint32x">;
3254 defm FRINT64X : FRIntNNT<0b11, "frint64x">;
3257 let Predicates = [HasFullFP16] in {
3258 def : Pat<(i32 (lrint f16:$Rn)),
3259 (FCVTZSUWHr (!cast<Instruction>(FRINTXHr) f16:$Rn))>;
3260 def : Pat<(i64 (lrint f16:$Rn)),
3261 (FCVTZSUXHr (!cast<Instruction>(FRINTXHr) f16:$Rn))>;
3262 def : Pat<(i64 (llrint f16:$Rn)),
3263 (FCVTZSUXHr (!cast<Instruction>(FRINTXHr) f16:$Rn))>;
3265 def : Pat<(i32 (lrint f32:$Rn)),
3266 (FCVTZSUWSr (!cast<Instruction>(FRINTXSr) f32:$Rn))>;
3267 def : Pat<(i32 (lrint f64:$Rn)),
3268 (FCVTZSUWDr (!cast<Instruction>(FRINTXDr) f64:$Rn))>;
3269 def : Pat<(i64 (lrint f32:$Rn)),
3270 (FCVTZSUXSr (!cast<Instruction>(FRINTXSr) f32:$Rn))>;
3271 def : Pat<(i64 (lrint f64:$Rn)),
3272 (FCVTZSUXDr (!cast<Instruction>(FRINTXDr) f64:$Rn))>;
3273 def : Pat<(i64 (llrint f32:$Rn)),
3274 (FCVTZSUXSr (!cast<Instruction>(FRINTXSr) f32:$Rn))>;
3275 def : Pat<(i64 (llrint f64:$Rn)),
3276 (FCVTZSUXDr (!cast<Instruction>(FRINTXDr) f64:$Rn))>;
3278 //===----------------------------------------------------------------------===//
3279 // Floating point two operand instructions.
3280 //===----------------------------------------------------------------------===//
3282 defm FADD : TwoOperandFPData<0b0010, "fadd", fadd>;
3283 let SchedRW = [WriteFDiv] in {
3284 defm FDIV : TwoOperandFPData<0b0001, "fdiv", fdiv>;
3286 defm FMAXNM : TwoOperandFPData<0b0110, "fmaxnm", fmaxnum>;
3287 defm FMAX : TwoOperandFPData<0b0100, "fmax", fmaximum>;
3288 defm FMINNM : TwoOperandFPData<0b0111, "fminnm", fminnum>;
3289 defm FMIN : TwoOperandFPData<0b0101, "fmin", fminimum>;
3290 let SchedRW = [WriteFMul] in {
3291 defm FMUL : TwoOperandFPData<0b0000, "fmul", fmul>;
3292 defm FNMUL : TwoOperandFPDataNeg<0b1000, "fnmul", fmul>;
3294 defm FSUB : TwoOperandFPData<0b0011, "fsub", fsub>;
3296 def : Pat<(v1f64 (fmaximum (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
3297 (FMAXDrr FPR64:$Rn, FPR64:$Rm)>;
3298 def : Pat<(v1f64 (fminimum (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
3299 (FMINDrr FPR64:$Rn, FPR64:$Rm)>;
3300 def : Pat<(v1f64 (fmaxnum (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
3301 (FMAXNMDrr FPR64:$Rn, FPR64:$Rm)>;
3302 def : Pat<(v1f64 (fminnum (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
3303 (FMINNMDrr FPR64:$Rn, FPR64:$Rm)>;
3305 //===----------------------------------------------------------------------===//
3306 // Floating point three operand instructions.
3307 //===----------------------------------------------------------------------===//
3309 defm FMADD : ThreeOperandFPData<0, 0, "fmadd", fma>;
3310 defm FMSUB : ThreeOperandFPData<0, 1, "fmsub",
3311 TriOpFrag<(fma node:$LHS, (fneg node:$MHS), node:$RHS)> >;
3312 defm FNMADD : ThreeOperandFPData<1, 0, "fnmadd",
3313 TriOpFrag<(fneg (fma node:$LHS, node:$MHS, node:$RHS))> >;
3314 defm FNMSUB : ThreeOperandFPData<1, 1, "fnmsub",
3315 TriOpFrag<(fma node:$LHS, node:$MHS, (fneg node:$RHS))> >;
3317 // The following def pats catch the case where the LHS of an FMA is negated.
3318 // The TriOpFrag above catches the case where the middle operand is negated.
3320 // N.b. FMSUB etc have the accumulator at the *end* of (outs), unlike
3321 // the NEON variant.
3323 // Here we handle first -(a + b*c) for FNMADD:
3325 let Predicates = [HasNEON, HasFullFP16] in
3326 def : Pat<(f16 (fma (fneg FPR16:$Rn), FPR16:$Rm, FPR16:$Ra)),
3327 (FMSUBHrrr FPR16:$Rn, FPR16:$Rm, FPR16:$Ra)>;
3329 def : Pat<(f32 (fma (fneg FPR32:$Rn), FPR32:$Rm, FPR32:$Ra)),
3330 (FMSUBSrrr FPR32:$Rn, FPR32:$Rm, FPR32:$Ra)>;
3332 def : Pat<(f64 (fma (fneg FPR64:$Rn), FPR64:$Rm, FPR64:$Ra)),
3333 (FMSUBDrrr FPR64:$Rn, FPR64:$Rm, FPR64:$Ra)>;
3335 // Now it's time for "(-a) + (-b)*c"
3337 let Predicates = [HasNEON, HasFullFP16] in
3338 def : Pat<(f16 (fma (fneg FPR16:$Rn), FPR16:$Rm, (fneg FPR16:$Ra))),
3339 (FNMADDHrrr FPR16:$Rn, FPR16:$Rm, FPR16:$Ra)>;
3341 def : Pat<(f32 (fma (fneg FPR32:$Rn), FPR32:$Rm, (fneg FPR32:$Ra))),
3342 (FNMADDSrrr FPR32:$Rn, FPR32:$Rm, FPR32:$Ra)>;
3344 def : Pat<(f64 (fma (fneg FPR64:$Rn), FPR64:$Rm, (fneg FPR64:$Ra))),
3345 (FNMADDDrrr FPR64:$Rn, FPR64:$Rm, FPR64:$Ra)>;
3347 // And here "(-a) + b*(-c)"
3349 let Predicates = [HasNEON, HasFullFP16] in
3350 def : Pat<(f16 (fma FPR16:$Rn, (fneg FPR16:$Rm), (fneg FPR16:$Ra))),
3351 (FNMADDHrrr FPR16:$Rn, FPR16:$Rm, FPR16:$Ra)>;
3353 def : Pat<(f32 (fma FPR32:$Rn, (fneg FPR32:$Rm), (fneg FPR32:$Ra))),
3354 (FNMADDSrrr FPR32:$Rn, FPR32:$Rm, FPR32:$Ra)>;
3356 def : Pat<(f64 (fma FPR64:$Rn, (fneg FPR64:$Rm), (fneg FPR64:$Ra))),
3357 (FNMADDDrrr FPR64:$Rn, FPR64:$Rm, FPR64:$Ra)>;
3359 //===----------------------------------------------------------------------===//
3360 // Floating point comparison instructions.
3361 //===----------------------------------------------------------------------===//
3363 defm FCMPE : FPComparison<1, "fcmpe">;
3364 defm FCMP : FPComparison<0, "fcmp", AArch64fcmp>;
3366 //===----------------------------------------------------------------------===//
3367 // Floating point conditional comparison instructions.
3368 //===----------------------------------------------------------------------===//
3370 defm FCCMPE : FPCondComparison<1, "fccmpe">;
3371 defm FCCMP : FPCondComparison<0, "fccmp", AArch64fccmp>;
3373 //===----------------------------------------------------------------------===//
3374 // Floating point conditional select instruction.
3375 //===----------------------------------------------------------------------===//
3377 defm FCSEL : FPCondSelect<"fcsel">;
3379 // CSEL instructions providing f128 types need to be handled by a
3380 // pseudo-instruction since the eventual code will need to introduce basic
3381 // blocks and control flow.
3382 def F128CSEL : Pseudo<(outs FPR128:$Rd),
3383 (ins FPR128:$Rn, FPR128:$Rm, ccode:$cond),
3384 [(set (f128 FPR128:$Rd),
3385 (AArch64csel FPR128:$Rn, FPR128:$Rm,
3386 (i32 imm:$cond), NZCV))]> {
3388 let usesCustomInserter = 1;
3389 let hasNoSchedulingInfo = 1;
3392 //===----------------------------------------------------------------------===//
3393 // Instructions used for emitting unwind opcodes on ARM64 Windows.
3394 //===----------------------------------------------------------------------===//
3395 let isPseudo = 1 in {
3396 def SEH_StackAlloc : Pseudo<(outs), (ins i32imm:$size), []>, Sched<[]>;
3397 def SEH_SaveFPLR : Pseudo<(outs), (ins i32imm:$offs), []>, Sched<[]>;
3398 def SEH_SaveFPLR_X : Pseudo<(outs), (ins i32imm:$offs), []>, Sched<[]>;
3399 def SEH_SaveReg : Pseudo<(outs), (ins i32imm:$reg, i32imm:$offs), []>, Sched<[]>;
3400 def SEH_SaveReg_X : Pseudo<(outs), (ins i32imm:$reg, i32imm:$offs), []>, Sched<[]>;
3401 def SEH_SaveRegP : Pseudo<(outs), (ins i32imm:$reg0, i32imm:$reg1, i32imm:$offs), []>, Sched<[]>;
3402 def SEH_SaveRegP_X : Pseudo<(outs), (ins i32imm:$reg0, i32imm:$reg1, i32imm:$offs), []>, Sched<[]>;
3403 def SEH_SaveFReg : Pseudo<(outs), (ins i32imm:$reg, i32imm:$offs), []>, Sched<[]>;
3404 def SEH_SaveFReg_X : Pseudo<(outs), (ins i32imm:$reg, i32imm:$offs), []>, Sched<[]>;
3405 def SEH_SaveFRegP : Pseudo<(outs), (ins i32imm:$reg0, i32imm:$reg1, i32imm:$offs), []>, Sched<[]>;
3406 def SEH_SaveFRegP_X : Pseudo<(outs), (ins i32imm:$reg0, i32imm:$reg1, i32imm:$offs), []>, Sched<[]>;
3407 def SEH_SetFP : Pseudo<(outs), (ins), []>, Sched<[]>;
3408 def SEH_AddFP : Pseudo<(outs), (ins i32imm:$offs), []>, Sched<[]>;
3409 def SEH_Nop : Pseudo<(outs), (ins), []>, Sched<[]>;
3410 def SEH_PrologEnd : Pseudo<(outs), (ins), []>, Sched<[]>;
3411 def SEH_EpilogStart : Pseudo<(outs), (ins), []>, Sched<[]>;
3412 def SEH_EpilogEnd : Pseudo<(outs), (ins), []>, Sched<[]>;
3415 // Pseudo instructions for Windows EH
3416 //===----------------------------------------------------------------------===//
3417 let isTerminator = 1, hasSideEffects = 1, isBarrier = 1, hasCtrlDep = 1,
3418 isCodeGenOnly = 1, isReturn = 1, isEHScopeReturn = 1, isPseudo = 1 in {
3419 def CLEANUPRET : Pseudo<(outs), (ins), [(cleanupret)]>, Sched<[]>;
3420 let usesCustomInserter = 1 in
3421 def CATCHRET : Pseudo<(outs), (ins am_brcond:$dst, am_brcond:$src), [(catchret bb:$dst, bb:$src)]>,
3425 let hasSideEffects = 1, hasCtrlDep = 1, isCodeGenOnly = 1,
3426 usesCustomInserter = 1 in
3427 def CATCHPAD : Pseudo<(outs), (ins), [(catchpad)]>, Sched<[]>;
3429 //===----------------------------------------------------------------------===//
3430 // Floating point immediate move.
3431 //===----------------------------------------------------------------------===//
3433 let isReMaterializable = 1 in {
3434 defm FMOV : FPMoveImmediate<"fmov">;
3437 //===----------------------------------------------------------------------===//
3438 // Advanced SIMD two vector instructions.
3439 //===----------------------------------------------------------------------===//
3441 defm UABDL : SIMDLongThreeVectorBHSabdl<1, 0b0111, "uabdl",
3442 int_aarch64_neon_uabd>;
3443 // Match UABDL in log2-shuffle patterns.
3444 def : Pat<(abs (v8i16 (sub (zext (v8i8 V64:$opA)),
3445 (zext (v8i8 V64:$opB))))),
3446 (UABDLv8i8_v8i16 V64:$opA, V64:$opB)>;
3447 def : Pat<(xor (v8i16 (AArch64vashr v8i16:$src, (i32 15))),
3448 (v8i16 (add (sub (zext (v8i8 V64:$opA)),
3449 (zext (v8i8 V64:$opB))),
3450 (AArch64vashr v8i16:$src, (i32 15))))),
3451 (UABDLv8i8_v8i16 V64:$opA, V64:$opB)>;
3452 def : Pat<(abs (v8i16 (sub (zext (extract_high_v16i8 V128:$opA)),
3453 (zext (extract_high_v16i8 V128:$opB))))),
3454 (UABDLv16i8_v8i16 V128:$opA, V128:$opB)>;
3455 def : Pat<(xor (v8i16 (AArch64vashr v8i16:$src, (i32 15))),
3456 (v8i16 (add (sub (zext (extract_high_v16i8 V128:$opA)),
3457 (zext (extract_high_v16i8 V128:$opB))),
3458 (AArch64vashr v8i16:$src, (i32 15))))),
3459 (UABDLv16i8_v8i16 V128:$opA, V128:$opB)>;
3460 def : Pat<(abs (v4i32 (sub (zext (v4i16 V64:$opA)),
3461 (zext (v4i16 V64:$opB))))),
3462 (UABDLv4i16_v4i32 V64:$opA, V64:$opB)>;
3463 def : Pat<(abs (v4i32 (sub (zext (extract_high_v8i16 V128:$opA)),
3464 (zext (extract_high_v8i16 V128:$opB))))),
3465 (UABDLv8i16_v4i32 V128:$opA, V128:$opB)>;
3466 def : Pat<(abs (v2i64 (sub (zext (v2i32 V64:$opA)),
3467 (zext (v2i32 V64:$opB))))),
3468 (UABDLv2i32_v2i64 V64:$opA, V64:$opB)>;
3469 def : Pat<(abs (v2i64 (sub (zext (extract_high_v4i32 V128:$opA)),
3470 (zext (extract_high_v4i32 V128:$opB))))),
3471 (UABDLv4i32_v2i64 V128:$opA, V128:$opB)>;
3473 defm ABS : SIMDTwoVectorBHSD<0, 0b01011, "abs", abs>;
3474 defm CLS : SIMDTwoVectorBHS<0, 0b00100, "cls", int_aarch64_neon_cls>;
3475 defm CLZ : SIMDTwoVectorBHS<1, 0b00100, "clz", ctlz>;
3476 defm CMEQ : SIMDCmpTwoVector<0, 0b01001, "cmeq", AArch64cmeqz>;
3477 defm CMGE : SIMDCmpTwoVector<1, 0b01000, "cmge", AArch64cmgez>;
3478 defm CMGT : SIMDCmpTwoVector<0, 0b01000, "cmgt", AArch64cmgtz>;
3479 defm CMLE : SIMDCmpTwoVector<1, 0b01001, "cmle", AArch64cmlez>;
3480 defm CMLT : SIMDCmpTwoVector<0, 0b01010, "cmlt", AArch64cmltz>;
3481 defm CNT : SIMDTwoVectorB<0, 0b00, 0b00101, "cnt", ctpop>;
3482 defm FABS : SIMDTwoVectorFP<0, 1, 0b01111, "fabs", fabs>;
3484 defm FCMEQ : SIMDFPCmpTwoVector<0, 1, 0b01101, "fcmeq", AArch64fcmeqz>;
3485 defm FCMGE : SIMDFPCmpTwoVector<1, 1, 0b01100, "fcmge", AArch64fcmgez>;
3486 defm FCMGT : SIMDFPCmpTwoVector<0, 1, 0b01100, "fcmgt", AArch64fcmgtz>;
3487 defm FCMLE : SIMDFPCmpTwoVector<1, 1, 0b01101, "fcmle", AArch64fcmlez>;
3488 defm FCMLT : SIMDFPCmpTwoVector<0, 1, 0b01110, "fcmlt", AArch64fcmltz>;
3489 defm FCVTAS : SIMDTwoVectorFPToInt<0,0,0b11100, "fcvtas",int_aarch64_neon_fcvtas>;
3490 defm FCVTAU : SIMDTwoVectorFPToInt<1,0,0b11100, "fcvtau",int_aarch64_neon_fcvtau>;
3491 defm FCVTL : SIMDFPWidenTwoVector<0, 0, 0b10111, "fcvtl">;
3492 def : Pat<(v4f32 (int_aarch64_neon_vcvthf2fp (v4i16 V64:$Rn))),
3493 (FCVTLv4i16 V64:$Rn)>;
3494 def : Pat<(v4f32 (int_aarch64_neon_vcvthf2fp (extract_subvector (v8i16 V128:$Rn),
3496 (FCVTLv8i16 V128:$Rn)>;
3497 def : Pat<(v2f64 (fpextend (v2f32 V64:$Rn))), (FCVTLv2i32 V64:$Rn)>;
3498 def : Pat<(v2f64 (fpextend (v2f32 (extract_subvector (v4f32 V128:$Rn),
3500 (FCVTLv4i32 V128:$Rn)>;
3502 def : Pat<(v4f32 (fpextend (v4f16 V64:$Rn))), (FCVTLv4i16 V64:$Rn)>;
3503 def : Pat<(v4f32 (fpextend (v4f16 (extract_subvector (v8f16 V128:$Rn),
3505 (FCVTLv8i16 V128:$Rn)>;
3507 defm FCVTMS : SIMDTwoVectorFPToInt<0,0,0b11011, "fcvtms",int_aarch64_neon_fcvtms>;
3508 defm FCVTMU : SIMDTwoVectorFPToInt<1,0,0b11011, "fcvtmu",int_aarch64_neon_fcvtmu>;
3509 defm FCVTNS : SIMDTwoVectorFPToInt<0,0,0b11010, "fcvtns",int_aarch64_neon_fcvtns>;
3510 defm FCVTNU : SIMDTwoVectorFPToInt<1,0,0b11010, "fcvtnu",int_aarch64_neon_fcvtnu>;
3511 defm FCVTN : SIMDFPNarrowTwoVector<0, 0, 0b10110, "fcvtn">;
3512 def : Pat<(v4i16 (int_aarch64_neon_vcvtfp2hf (v4f32 V128:$Rn))),
3513 (FCVTNv4i16 V128:$Rn)>;
3514 def : Pat<(concat_vectors V64:$Rd,
3515 (v4i16 (int_aarch64_neon_vcvtfp2hf (v4f32 V128:$Rn)))),
3516 (FCVTNv8i16 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
3517 def : Pat<(v2f32 (fpround (v2f64 V128:$Rn))), (FCVTNv2i32 V128:$Rn)>;
3518 def : Pat<(v4f16 (fpround (v4f32 V128:$Rn))), (FCVTNv4i16 V128:$Rn)>;
3519 def : Pat<(concat_vectors V64:$Rd, (v2f32 (fpround (v2f64 V128:$Rn)))),
3520 (FCVTNv4i32 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
3521 defm FCVTPS : SIMDTwoVectorFPToInt<0,1,0b11010, "fcvtps",int_aarch64_neon_fcvtps>;
3522 defm FCVTPU : SIMDTwoVectorFPToInt<1,1,0b11010, "fcvtpu",int_aarch64_neon_fcvtpu>;
3523 defm FCVTXN : SIMDFPInexactCvtTwoVector<1, 0, 0b10110, "fcvtxn",
3524 int_aarch64_neon_fcvtxn>;
3525 defm FCVTZS : SIMDTwoVectorFPToInt<0, 1, 0b11011, "fcvtzs", fp_to_sint>;
3526 defm FCVTZU : SIMDTwoVectorFPToInt<1, 1, 0b11011, "fcvtzu", fp_to_uint>;
3528 def : Pat<(v4i16 (int_aarch64_neon_fcvtzs v4f16:$Rn)), (FCVTZSv4f16 $Rn)>;
3529 def : Pat<(v8i16 (int_aarch64_neon_fcvtzs v8f16:$Rn)), (FCVTZSv8f16 $Rn)>;
3530 def : Pat<(v2i32 (int_aarch64_neon_fcvtzs v2f32:$Rn)), (FCVTZSv2f32 $Rn)>;
3531 def : Pat<(v4i32 (int_aarch64_neon_fcvtzs v4f32:$Rn)), (FCVTZSv4f32 $Rn)>;
3532 def : Pat<(v2i64 (int_aarch64_neon_fcvtzs v2f64:$Rn)), (FCVTZSv2f64 $Rn)>;
3534 def : Pat<(v4i16 (int_aarch64_neon_fcvtzu v4f16:$Rn)), (FCVTZUv4f16 $Rn)>;
3535 def : Pat<(v8i16 (int_aarch64_neon_fcvtzu v8f16:$Rn)), (FCVTZUv8f16 $Rn)>;
3536 def : Pat<(v2i32 (int_aarch64_neon_fcvtzu v2f32:$Rn)), (FCVTZUv2f32 $Rn)>;
3537 def : Pat<(v4i32 (int_aarch64_neon_fcvtzu v4f32:$Rn)), (FCVTZUv4f32 $Rn)>;
3538 def : Pat<(v2i64 (int_aarch64_neon_fcvtzu v2f64:$Rn)), (FCVTZUv2f64 $Rn)>;
3540 defm FNEG : SIMDTwoVectorFP<1, 1, 0b01111, "fneg", fneg>;
3541 defm FRECPE : SIMDTwoVectorFP<0, 1, 0b11101, "frecpe", int_aarch64_neon_frecpe>;
3542 defm FRINTA : SIMDTwoVectorFP<1, 0, 0b11000, "frinta", fround>;
3543 defm FRINTI : SIMDTwoVectorFP<1, 1, 0b11001, "frinti", fnearbyint>;
3544 defm FRINTM : SIMDTwoVectorFP<0, 0, 0b11001, "frintm", ffloor>;
3545 defm FRINTN : SIMDTwoVectorFP<0, 0, 0b11000, "frintn", int_aarch64_neon_frintn>;
3546 defm FRINTP : SIMDTwoVectorFP<0, 1, 0b11000, "frintp", fceil>;
3547 defm FRINTX : SIMDTwoVectorFP<1, 0, 0b11001, "frintx", frint>;
3548 defm FRINTZ : SIMDTwoVectorFP<0, 1, 0b11001, "frintz", ftrunc>;
3550 let Predicates = [HasFRInt3264] in {
3551 defm FRINT32Z : FRIntNNTVector<0, 0, "frint32z">;
3552 defm FRINT64Z : FRIntNNTVector<0, 1, "frint64z">;
3553 defm FRINT32X : FRIntNNTVector<1, 0, "frint32x">;
3554 defm FRINT64X : FRIntNNTVector<1, 1, "frint64x">;
3557 defm FRSQRTE: SIMDTwoVectorFP<1, 1, 0b11101, "frsqrte", int_aarch64_neon_frsqrte>;
3558 defm FSQRT : SIMDTwoVectorFP<1, 1, 0b11111, "fsqrt", fsqrt>;
3559 defm NEG : SIMDTwoVectorBHSD<1, 0b01011, "neg",
3560 UnOpFrag<(sub immAllZerosV, node:$LHS)> >;
3561 defm NOT : SIMDTwoVectorB<1, 0b00, 0b00101, "not", vnot>;
3562 // Aliases for MVN -> NOT.
3563 def : InstAlias<"mvn{ $Vd.8b, $Vn.8b|.8b $Vd, $Vn}",
3564 (NOTv8i8 V64:$Vd, V64:$Vn)>;
3565 def : InstAlias<"mvn{ $Vd.16b, $Vn.16b|.16b $Vd, $Vn}",
3566 (NOTv16i8 V128:$Vd, V128:$Vn)>;
3568 def : Pat<(AArch64neg (v8i8 V64:$Rn)), (NEGv8i8 V64:$Rn)>;
3569 def : Pat<(AArch64neg (v16i8 V128:$Rn)), (NEGv16i8 V128:$Rn)>;
3570 def : Pat<(AArch64neg (v4i16 V64:$Rn)), (NEGv4i16 V64:$Rn)>;
3571 def : Pat<(AArch64neg (v8i16 V128:$Rn)), (NEGv8i16 V128:$Rn)>;
3572 def : Pat<(AArch64neg (v2i32 V64:$Rn)), (NEGv2i32 V64:$Rn)>;
3573 def : Pat<(AArch64neg (v4i32 V128:$Rn)), (NEGv4i32 V128:$Rn)>;
3574 def : Pat<(AArch64neg (v2i64 V128:$Rn)), (NEGv2i64 V128:$Rn)>;
3576 def : Pat<(AArch64not (v8i8 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3577 def : Pat<(AArch64not (v16i8 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3578 def : Pat<(AArch64not (v4i16 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3579 def : Pat<(AArch64not (v8i16 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3580 def : Pat<(AArch64not (v2i32 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3581 def : Pat<(AArch64not (v1i64 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3582 def : Pat<(AArch64not (v4i32 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3583 def : Pat<(AArch64not (v2i64 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3585 def : Pat<(vnot (v4i16 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3586 def : Pat<(vnot (v8i16 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3587 def : Pat<(vnot (v2i32 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3588 def : Pat<(vnot (v4i32 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3589 def : Pat<(vnot (v2i64 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3591 defm RBIT : SIMDTwoVectorB<1, 0b01, 0b00101, "rbit", int_aarch64_neon_rbit>;
3592 defm REV16 : SIMDTwoVectorB<0, 0b00, 0b00001, "rev16", AArch64rev16>;
3593 defm REV32 : SIMDTwoVectorBH<1, 0b00000, "rev32", AArch64rev32>;
3594 defm REV64 : SIMDTwoVectorBHS<0, 0b00000, "rev64", AArch64rev64>;
3595 defm SADALP : SIMDLongTwoVectorTied<0, 0b00110, "sadalp",
3596 BinOpFrag<(add node:$LHS, (int_aarch64_neon_saddlp node:$RHS))> >;
3597 defm SADDLP : SIMDLongTwoVector<0, 0b00010, "saddlp", int_aarch64_neon_saddlp>;
3598 defm SCVTF : SIMDTwoVectorIntToFP<0, 0, 0b11101, "scvtf", sint_to_fp>;
3599 defm SHLL : SIMDVectorLShiftLongBySizeBHS;
3600 defm SQABS : SIMDTwoVectorBHSD<0, 0b00111, "sqabs", int_aarch64_neon_sqabs>;
3601 defm SQNEG : SIMDTwoVectorBHSD<1, 0b00111, "sqneg", int_aarch64_neon_sqneg>;
3602 defm SQXTN : SIMDMixedTwoVector<0, 0b10100, "sqxtn", int_aarch64_neon_sqxtn>;
3603 defm SQXTUN : SIMDMixedTwoVector<1, 0b10010, "sqxtun", int_aarch64_neon_sqxtun>;
3604 defm SUQADD : SIMDTwoVectorBHSDTied<0, 0b00011, "suqadd",int_aarch64_neon_suqadd>;
3605 defm UADALP : SIMDLongTwoVectorTied<1, 0b00110, "uadalp",
3606 BinOpFrag<(add node:$LHS, (int_aarch64_neon_uaddlp node:$RHS))> >;
3607 defm UADDLP : SIMDLongTwoVector<1, 0b00010, "uaddlp",
3608 int_aarch64_neon_uaddlp>;
3609 defm UCVTF : SIMDTwoVectorIntToFP<1, 0, 0b11101, "ucvtf", uint_to_fp>;
3610 defm UQXTN : SIMDMixedTwoVector<1, 0b10100, "uqxtn", int_aarch64_neon_uqxtn>;
3611 defm URECPE : SIMDTwoVectorS<0, 1, 0b11100, "urecpe", int_aarch64_neon_urecpe>;
3612 defm URSQRTE: SIMDTwoVectorS<1, 1, 0b11100, "ursqrte", int_aarch64_neon_ursqrte>;
3613 defm USQADD : SIMDTwoVectorBHSDTied<1, 0b00011, "usqadd",int_aarch64_neon_usqadd>;
3614 defm XTN : SIMDMixedTwoVector<0, 0b10010, "xtn", trunc>;
3616 def : Pat<(v4f16 (AArch64rev32 V64:$Rn)), (REV32v4i16 V64:$Rn)>;
3617 def : Pat<(v4f16 (AArch64rev64 V64:$Rn)), (REV64v4i16 V64:$Rn)>;
3618 def : Pat<(v8f16 (AArch64rev32 V128:$Rn)), (REV32v8i16 V128:$Rn)>;
3619 def : Pat<(v8f16 (AArch64rev64 V128:$Rn)), (REV64v8i16 V128:$Rn)>;
3620 def : Pat<(v2f32 (AArch64rev64 V64:$Rn)), (REV64v2i32 V64:$Rn)>;
3621 def : Pat<(v4f32 (AArch64rev64 V128:$Rn)), (REV64v4i32 V128:$Rn)>;
3623 // Patterns for vector long shift (by element width). These need to match all
3624 // three of zext, sext and anyext so it's easier to pull the patterns out of the
3626 multiclass SIMDVectorLShiftLongBySizeBHSPats<SDPatternOperator ext> {
3627 def : Pat<(AArch64vshl (v8i16 (ext (v8i8 V64:$Rn))), (i32 8)),
3628 (SHLLv8i8 V64:$Rn)>;
3629 def : Pat<(AArch64vshl (v8i16 (ext (extract_high_v16i8 V128:$Rn))), (i32 8)),
3630 (SHLLv16i8 V128:$Rn)>;
3631 def : Pat<(AArch64vshl (v4i32 (ext (v4i16 V64:$Rn))), (i32 16)),
3632 (SHLLv4i16 V64:$Rn)>;
3633 def : Pat<(AArch64vshl (v4i32 (ext (extract_high_v8i16 V128:$Rn))), (i32 16)),
3634 (SHLLv8i16 V128:$Rn)>;
3635 def : Pat<(AArch64vshl (v2i64 (ext (v2i32 V64:$Rn))), (i32 32)),
3636 (SHLLv2i32 V64:$Rn)>;
3637 def : Pat<(AArch64vshl (v2i64 (ext (extract_high_v4i32 V128:$Rn))), (i32 32)),
3638 (SHLLv4i32 V128:$Rn)>;
3641 defm : SIMDVectorLShiftLongBySizeBHSPats<anyext>;
3642 defm : SIMDVectorLShiftLongBySizeBHSPats<zext>;
3643 defm : SIMDVectorLShiftLongBySizeBHSPats<sext>;
3645 //===----------------------------------------------------------------------===//
3646 // Advanced SIMD three vector instructions.
3647 //===----------------------------------------------------------------------===//
3649 defm ADD : SIMDThreeSameVector<0, 0b10000, "add", add>;
3650 defm ADDP : SIMDThreeSameVector<0, 0b10111, "addp", int_aarch64_neon_addp>;
3651 defm CMEQ : SIMDThreeSameVector<1, 0b10001, "cmeq", AArch64cmeq>;
3652 defm CMGE : SIMDThreeSameVector<0, 0b00111, "cmge", AArch64cmge>;
3653 defm CMGT : SIMDThreeSameVector<0, 0b00110, "cmgt", AArch64cmgt>;
3654 defm CMHI : SIMDThreeSameVector<1, 0b00110, "cmhi", AArch64cmhi>;
3655 defm CMHS : SIMDThreeSameVector<1, 0b00111, "cmhs", AArch64cmhs>;
3656 defm CMTST : SIMDThreeSameVector<0, 0b10001, "cmtst", AArch64cmtst>;
3657 defm FABD : SIMDThreeSameVectorFP<1,1,0b010,"fabd", int_aarch64_neon_fabd>;
3658 let Predicates = [HasNEON] in {
3659 foreach VT = [ v2f32, v4f32, v2f64 ] in
3660 def : Pat<(fabs (fsub VT:$Rn, VT:$Rm)), (!cast<Instruction>("FABD"#VT) VT:$Rn, VT:$Rm)>;
3662 let Predicates = [HasNEON, HasFullFP16] in {
3663 foreach VT = [ v4f16, v8f16 ] in
3664 def : Pat<(fabs (fsub VT:$Rn, VT:$Rm)), (!cast<Instruction>("FABD"#VT) VT:$Rn, VT:$Rm)>;
3666 defm FACGE : SIMDThreeSameVectorFPCmp<1,0,0b101,"facge",int_aarch64_neon_facge>;
3667 defm FACGT : SIMDThreeSameVectorFPCmp<1,1,0b101,"facgt",int_aarch64_neon_facgt>;
3668 defm FADDP : SIMDThreeSameVectorFP<1,0,0b010,"faddp",int_aarch64_neon_faddp>;
3669 defm FADD : SIMDThreeSameVectorFP<0,0,0b010,"fadd", fadd>;
3670 defm FCMEQ : SIMDThreeSameVectorFPCmp<0, 0, 0b100, "fcmeq", AArch64fcmeq>;
3671 defm FCMGE : SIMDThreeSameVectorFPCmp<1, 0, 0b100, "fcmge", AArch64fcmge>;
3672 defm FCMGT : SIMDThreeSameVectorFPCmp<1, 1, 0b100, "fcmgt", AArch64fcmgt>;
3673 defm FDIV : SIMDThreeSameVectorFP<1,0,0b111,"fdiv", fdiv>;
3674 defm FMAXNMP : SIMDThreeSameVectorFP<1,0,0b000,"fmaxnmp", int_aarch64_neon_fmaxnmp>;
3675 defm FMAXNM : SIMDThreeSameVectorFP<0,0,0b000,"fmaxnm", fmaxnum>;
3676 defm FMAXP : SIMDThreeSameVectorFP<1,0,0b110,"fmaxp", int_aarch64_neon_fmaxp>;
3677 defm FMAX : SIMDThreeSameVectorFP<0,0,0b110,"fmax", fmaximum>;
3678 defm FMINNMP : SIMDThreeSameVectorFP<1,1,0b000,"fminnmp", int_aarch64_neon_fminnmp>;
3679 defm FMINNM : SIMDThreeSameVectorFP<0,1,0b000,"fminnm", fminnum>;
3680 defm FMINP : SIMDThreeSameVectorFP<1,1,0b110,"fminp", int_aarch64_neon_fminp>;
3681 defm FMIN : SIMDThreeSameVectorFP<0,1,0b110,"fmin", fminimum>;
3683 // NOTE: The operands of the PatFrag are reordered on FMLA/FMLS because the
3684 // instruction expects the addend first, while the fma intrinsic puts it last.
3685 defm FMLA : SIMDThreeSameVectorFPTied<0, 0, 0b001, "fmla",
3686 TriOpFrag<(fma node:$RHS, node:$MHS, node:$LHS)> >;
3687 defm FMLS : SIMDThreeSameVectorFPTied<0, 1, 0b001, "fmls",
3688 TriOpFrag<(fma node:$MHS, (fneg node:$RHS), node:$LHS)> >;
3690 // The following def pats catch the case where the LHS of an FMA is negated.
3691 // The TriOpFrag above catches the case where the middle operand is negated.
3692 def : Pat<(v2f32 (fma (fneg V64:$Rn), V64:$Rm, V64:$Rd)),
3693 (FMLSv2f32 V64:$Rd, V64:$Rn, V64:$Rm)>;
3695 def : Pat<(v4f32 (fma (fneg V128:$Rn), V128:$Rm, V128:$Rd)),
3696 (FMLSv4f32 V128:$Rd, V128:$Rn, V128:$Rm)>;
3698 def : Pat<(v2f64 (fma (fneg V128:$Rn), V128:$Rm, V128:$Rd)),
3699 (FMLSv2f64 V128:$Rd, V128:$Rn, V128:$Rm)>;
3701 defm FMULX : SIMDThreeSameVectorFP<0,0,0b011,"fmulx", int_aarch64_neon_fmulx>;
3702 defm FMUL : SIMDThreeSameVectorFP<1,0,0b011,"fmul", fmul>;
3703 defm FRECPS : SIMDThreeSameVectorFP<0,0,0b111,"frecps", int_aarch64_neon_frecps>;
3704 defm FRSQRTS : SIMDThreeSameVectorFP<0,1,0b111,"frsqrts", int_aarch64_neon_frsqrts>;
3705 defm FSUB : SIMDThreeSameVectorFP<0,1,0b010,"fsub", fsub>;
3706 defm MLA : SIMDThreeSameVectorBHSTied<0, 0b10010, "mla",
3707 TriOpFrag<(add node:$LHS, (mul node:$MHS, node:$RHS))> >;
3708 defm MLS : SIMDThreeSameVectorBHSTied<1, 0b10010, "mls",
3709 TriOpFrag<(sub node:$LHS, (mul node:$MHS, node:$RHS))> >;
3710 defm MUL : SIMDThreeSameVectorBHS<0, 0b10011, "mul", mul>;
3711 defm PMUL : SIMDThreeSameVectorB<1, 0b10011, "pmul", int_aarch64_neon_pmul>;
3712 defm SABA : SIMDThreeSameVectorBHSTied<0, 0b01111, "saba",
3713 TriOpFrag<(add node:$LHS, (int_aarch64_neon_sabd node:$MHS, node:$RHS))> >;
3714 defm SABD : SIMDThreeSameVectorBHS<0,0b01110,"sabd", int_aarch64_neon_sabd>;
3715 defm SHADD : SIMDThreeSameVectorBHS<0,0b00000,"shadd", int_aarch64_neon_shadd>;
3716 defm SHSUB : SIMDThreeSameVectorBHS<0,0b00100,"shsub", int_aarch64_neon_shsub>;
3717 defm SMAXP : SIMDThreeSameVectorBHS<0,0b10100,"smaxp", int_aarch64_neon_smaxp>;
3718 defm SMAX : SIMDThreeSameVectorBHS<0,0b01100,"smax", smax>;
3719 defm SMINP : SIMDThreeSameVectorBHS<0,0b10101,"sminp", int_aarch64_neon_sminp>;
3720 defm SMIN : SIMDThreeSameVectorBHS<0,0b01101,"smin", smin>;
3721 defm SQADD : SIMDThreeSameVector<0,0b00001,"sqadd", int_aarch64_neon_sqadd>;
3722 defm SQDMULH : SIMDThreeSameVectorHS<0,0b10110,"sqdmulh",int_aarch64_neon_sqdmulh>;
3723 defm SQRDMULH : SIMDThreeSameVectorHS<1,0b10110,"sqrdmulh",int_aarch64_neon_sqrdmulh>;
3724 defm SQRSHL : SIMDThreeSameVector<0,0b01011,"sqrshl", int_aarch64_neon_sqrshl>;
3725 defm SQSHL : SIMDThreeSameVector<0,0b01001,"sqshl", int_aarch64_neon_sqshl>;
3726 defm SQSUB : SIMDThreeSameVector<0,0b00101,"sqsub", int_aarch64_neon_sqsub>;
3727 defm SRHADD : SIMDThreeSameVectorBHS<0,0b00010,"srhadd",int_aarch64_neon_srhadd>;
3728 defm SRSHL : SIMDThreeSameVector<0,0b01010,"srshl", int_aarch64_neon_srshl>;
3729 defm SSHL : SIMDThreeSameVector<0,0b01000,"sshl", int_aarch64_neon_sshl>;
3730 defm SUB : SIMDThreeSameVector<1,0b10000,"sub", sub>;
3731 defm UABA : SIMDThreeSameVectorBHSTied<1, 0b01111, "uaba",
3732 TriOpFrag<(add node:$LHS, (int_aarch64_neon_uabd node:$MHS, node:$RHS))> >;
3733 defm UABD : SIMDThreeSameVectorBHS<1,0b01110,"uabd", int_aarch64_neon_uabd>;
3734 defm UHADD : SIMDThreeSameVectorBHS<1,0b00000,"uhadd", int_aarch64_neon_uhadd>;
3735 defm UHSUB : SIMDThreeSameVectorBHS<1,0b00100,"uhsub", int_aarch64_neon_uhsub>;
3736 defm UMAXP : SIMDThreeSameVectorBHS<1,0b10100,"umaxp", int_aarch64_neon_umaxp>;
3737 defm UMAX : SIMDThreeSameVectorBHS<1,0b01100,"umax", umax>;
3738 defm UMINP : SIMDThreeSameVectorBHS<1,0b10101,"uminp", int_aarch64_neon_uminp>;
3739 defm UMIN : SIMDThreeSameVectorBHS<1,0b01101,"umin", umin>;
3740 defm UQADD : SIMDThreeSameVector<1,0b00001,"uqadd", int_aarch64_neon_uqadd>;
3741 defm UQRSHL : SIMDThreeSameVector<1,0b01011,"uqrshl", int_aarch64_neon_uqrshl>;
3742 defm UQSHL : SIMDThreeSameVector<1,0b01001,"uqshl", int_aarch64_neon_uqshl>;
3743 defm UQSUB : SIMDThreeSameVector<1,0b00101,"uqsub", int_aarch64_neon_uqsub>;
3744 defm URHADD : SIMDThreeSameVectorBHS<1,0b00010,"urhadd", int_aarch64_neon_urhadd>;
3745 defm URSHL : SIMDThreeSameVector<1,0b01010,"urshl", int_aarch64_neon_urshl>;
3746 defm USHL : SIMDThreeSameVector<1,0b01000,"ushl", int_aarch64_neon_ushl>;
3747 defm SQRDMLAH : SIMDThreeSameVectorSQRDMLxHTiedHS<1,0b10000,"sqrdmlah",
3748 int_aarch64_neon_sqadd>;
3749 defm SQRDMLSH : SIMDThreeSameVectorSQRDMLxHTiedHS<1,0b10001,"sqrdmlsh",
3750 int_aarch64_neon_sqsub>;
3752 defm AND : SIMDLogicalThreeVector<0, 0b00, "and", and>;
3753 defm BIC : SIMDLogicalThreeVector<0, 0b01, "bic",
3754 BinOpFrag<(and node:$LHS, (vnot node:$RHS))> >;
3755 defm BIF : SIMDLogicalThreeVector<1, 0b11, "bif">;
3756 defm BIT : SIMDLogicalThreeVectorTied<1, 0b10, "bit", AArch64bit>;
3757 defm BSL : SIMDLogicalThreeVectorTied<1, 0b01, "bsl",
3758 TriOpFrag<(or (and node:$LHS, node:$MHS), (and (vnot node:$LHS), node:$RHS))>>;
3759 defm EOR : SIMDLogicalThreeVector<1, 0b00, "eor", xor>;
3760 defm ORN : SIMDLogicalThreeVector<0, 0b11, "orn",
3761 BinOpFrag<(or node:$LHS, (vnot node:$RHS))> >;
3762 defm ORR : SIMDLogicalThreeVector<0, 0b10, "orr", or>;
3765 def : Pat<(AArch64bsl (v8i8 V64:$Rd), V64:$Rn, V64:$Rm),
3766 (BSLv8i8 V64:$Rd, V64:$Rn, V64:$Rm)>;
3767 def : Pat<(AArch64bsl (v4i16 V64:$Rd), V64:$Rn, V64:$Rm),
3768 (BSLv8i8 V64:$Rd, V64:$Rn, V64:$Rm)>;
3769 def : Pat<(AArch64bsl (v2i32 V64:$Rd), V64:$Rn, V64:$Rm),
3770 (BSLv8i8 V64:$Rd, V64:$Rn, V64:$Rm)>;
3771 def : Pat<(AArch64bsl (v1i64 V64:$Rd), V64:$Rn, V64:$Rm),
3772 (BSLv8i8 V64:$Rd, V64:$Rn, V64:$Rm)>;
3774 def : Pat<(AArch64bsl (v16i8 V128:$Rd), V128:$Rn, V128:$Rm),
3775 (BSLv16i8 V128:$Rd, V128:$Rn, V128:$Rm)>;
3776 def : Pat<(AArch64bsl (v8i16 V128:$Rd), V128:$Rn, V128:$Rm),
3777 (BSLv16i8 V128:$Rd, V128:$Rn, V128:$Rm)>;
3778 def : Pat<(AArch64bsl (v4i32 V128:$Rd), V128:$Rn, V128:$Rm),
3779 (BSLv16i8 V128:$Rd, V128:$Rn, V128:$Rm)>;
3780 def : Pat<(AArch64bsl (v2i64 V128:$Rd), V128:$Rn, V128:$Rm),
3781 (BSLv16i8 V128:$Rd, V128:$Rn, V128:$Rm)>;
3783 def : InstAlias<"mov{\t$dst.16b, $src.16b|.16b\t$dst, $src}",
3784 (ORRv16i8 V128:$dst, V128:$src, V128:$src), 1>;
3785 def : InstAlias<"mov{\t$dst.8h, $src.8h|.8h\t$dst, $src}",
3786 (ORRv16i8 V128:$dst, V128:$src, V128:$src), 0>;
3787 def : InstAlias<"mov{\t$dst.4s, $src.4s|.4s\t$dst, $src}",
3788 (ORRv16i8 V128:$dst, V128:$src, V128:$src), 0>;
3789 def : InstAlias<"mov{\t$dst.2d, $src.2d|.2d\t$dst, $src}",
3790 (ORRv16i8 V128:$dst, V128:$src, V128:$src), 0>;
3792 def : InstAlias<"mov{\t$dst.8b, $src.8b|.8b\t$dst, $src}",
3793 (ORRv8i8 V64:$dst, V64:$src, V64:$src), 1>;
3794 def : InstAlias<"mov{\t$dst.4h, $src.4h|.4h\t$dst, $src}",
3795 (ORRv8i8 V64:$dst, V64:$src, V64:$src), 0>;
3796 def : InstAlias<"mov{\t$dst.2s, $src.2s|.2s\t$dst, $src}",
3797 (ORRv8i8 V64:$dst, V64:$src, V64:$src), 0>;
3798 def : InstAlias<"mov{\t$dst.1d, $src.1d|.1d\t$dst, $src}",
3799 (ORRv8i8 V64:$dst, V64:$src, V64:$src), 0>;
3801 def : InstAlias<"{cmls\t$dst.8b, $src1.8b, $src2.8b" #
3802 "|cmls.8b\t$dst, $src1, $src2}",
3803 (CMHSv8i8 V64:$dst, V64:$src2, V64:$src1), 0>;
3804 def : InstAlias<"{cmls\t$dst.16b, $src1.16b, $src2.16b" #
3805 "|cmls.16b\t$dst, $src1, $src2}",
3806 (CMHSv16i8 V128:$dst, V128:$src2, V128:$src1), 0>;
3807 def : InstAlias<"{cmls\t$dst.4h, $src1.4h, $src2.4h" #
3808 "|cmls.4h\t$dst, $src1, $src2}",
3809 (CMHSv4i16 V64:$dst, V64:$src2, V64:$src1), 0>;
3810 def : InstAlias<"{cmls\t$dst.8h, $src1.8h, $src2.8h" #
3811 "|cmls.8h\t$dst, $src1, $src2}",
3812 (CMHSv8i16 V128:$dst, V128:$src2, V128:$src1), 0>;
3813 def : InstAlias<"{cmls\t$dst.2s, $src1.2s, $src2.2s" #
3814 "|cmls.2s\t$dst, $src1, $src2}",
3815 (CMHSv2i32 V64:$dst, V64:$src2, V64:$src1), 0>;
3816 def : InstAlias<"{cmls\t$dst.4s, $src1.4s, $src2.4s" #
3817 "|cmls.4s\t$dst, $src1, $src2}",
3818 (CMHSv4i32 V128:$dst, V128:$src2, V128:$src1), 0>;
3819 def : InstAlias<"{cmls\t$dst.2d, $src1.2d, $src2.2d" #
3820 "|cmls.2d\t$dst, $src1, $src2}",
3821 (CMHSv2i64 V128:$dst, V128:$src2, V128:$src1), 0>;
3823 def : InstAlias<"{cmlo\t$dst.8b, $src1.8b, $src2.8b" #
3824 "|cmlo.8b\t$dst, $src1, $src2}",
3825 (CMHIv8i8 V64:$dst, V64:$src2, V64:$src1), 0>;
3826 def : InstAlias<"{cmlo\t$dst.16b, $src1.16b, $src2.16b" #
3827 "|cmlo.16b\t$dst, $src1, $src2}",
3828 (CMHIv16i8 V128:$dst, V128:$src2, V128:$src1), 0>;
3829 def : InstAlias<"{cmlo\t$dst.4h, $src1.4h, $src2.4h" #
3830 "|cmlo.4h\t$dst, $src1, $src2}",
3831 (CMHIv4i16 V64:$dst, V64:$src2, V64:$src1), 0>;
3832 def : InstAlias<"{cmlo\t$dst.8h, $src1.8h, $src2.8h" #
3833 "|cmlo.8h\t$dst, $src1, $src2}",
3834 (CMHIv8i16 V128:$dst, V128:$src2, V128:$src1), 0>;
3835 def : InstAlias<"{cmlo\t$dst.2s, $src1.2s, $src2.2s" #
3836 "|cmlo.2s\t$dst, $src1, $src2}",
3837 (CMHIv2i32 V64:$dst, V64:$src2, V64:$src1), 0>;
3838 def : InstAlias<"{cmlo\t$dst.4s, $src1.4s, $src2.4s" #
3839 "|cmlo.4s\t$dst, $src1, $src2}",
3840 (CMHIv4i32 V128:$dst, V128:$src2, V128:$src1), 0>;
3841 def : InstAlias<"{cmlo\t$dst.2d, $src1.2d, $src2.2d" #
3842 "|cmlo.2d\t$dst, $src1, $src2}",
3843 (CMHIv2i64 V128:$dst, V128:$src2, V128:$src1), 0>;
3845 def : InstAlias<"{cmle\t$dst.8b, $src1.8b, $src2.8b" #
3846 "|cmle.8b\t$dst, $src1, $src2}",
3847 (CMGEv8i8 V64:$dst, V64:$src2, V64:$src1), 0>;
3848 def : InstAlias<"{cmle\t$dst.16b, $src1.16b, $src2.16b" #
3849 "|cmle.16b\t$dst, $src1, $src2}",
3850 (CMGEv16i8 V128:$dst, V128:$src2, V128:$src1), 0>;
3851 def : InstAlias<"{cmle\t$dst.4h, $src1.4h, $src2.4h" #
3852 "|cmle.4h\t$dst, $src1, $src2}",
3853 (CMGEv4i16 V64:$dst, V64:$src2, V64:$src1), 0>;
3854 def : InstAlias<"{cmle\t$dst.8h, $src1.8h, $src2.8h" #
3855 "|cmle.8h\t$dst, $src1, $src2}",
3856 (CMGEv8i16 V128:$dst, V128:$src2, V128:$src1), 0>;
3857 def : InstAlias<"{cmle\t$dst.2s, $src1.2s, $src2.2s" #
3858 "|cmle.2s\t$dst, $src1, $src2}",
3859 (CMGEv2i32 V64:$dst, V64:$src2, V64:$src1), 0>;
3860 def : InstAlias<"{cmle\t$dst.4s, $src1.4s, $src2.4s" #
3861 "|cmle.4s\t$dst, $src1, $src2}",
3862 (CMGEv4i32 V128:$dst, V128:$src2, V128:$src1), 0>;
3863 def : InstAlias<"{cmle\t$dst.2d, $src1.2d, $src2.2d" #
3864 "|cmle.2d\t$dst, $src1, $src2}",
3865 (CMGEv2i64 V128:$dst, V128:$src2, V128:$src1), 0>;
3867 def : InstAlias<"{cmlt\t$dst.8b, $src1.8b, $src2.8b" #
3868 "|cmlt.8b\t$dst, $src1, $src2}",
3869 (CMGTv8i8 V64:$dst, V64:$src2, V64:$src1), 0>;
3870 def : InstAlias<"{cmlt\t$dst.16b, $src1.16b, $src2.16b" #
3871 "|cmlt.16b\t$dst, $src1, $src2}",
3872 (CMGTv16i8 V128:$dst, V128:$src2, V128:$src1), 0>;
3873 def : InstAlias<"{cmlt\t$dst.4h, $src1.4h, $src2.4h" #
3874 "|cmlt.4h\t$dst, $src1, $src2}",
3875 (CMGTv4i16 V64:$dst, V64:$src2, V64:$src1), 0>;
3876 def : InstAlias<"{cmlt\t$dst.8h, $src1.8h, $src2.8h" #
3877 "|cmlt.8h\t$dst, $src1, $src2}",
3878 (CMGTv8i16 V128:$dst, V128:$src2, V128:$src1), 0>;
3879 def : InstAlias<"{cmlt\t$dst.2s, $src1.2s, $src2.2s" #
3880 "|cmlt.2s\t$dst, $src1, $src2}",
3881 (CMGTv2i32 V64:$dst, V64:$src2, V64:$src1), 0>;
3882 def : InstAlias<"{cmlt\t$dst.4s, $src1.4s, $src2.4s" #
3883 "|cmlt.4s\t$dst, $src1, $src2}",
3884 (CMGTv4i32 V128:$dst, V128:$src2, V128:$src1), 0>;
3885 def : InstAlias<"{cmlt\t$dst.2d, $src1.2d, $src2.2d" #
3886 "|cmlt.2d\t$dst, $src1, $src2}",
3887 (CMGTv2i64 V128:$dst, V128:$src2, V128:$src1), 0>;
3889 let Predicates = [HasNEON, HasFullFP16] in {
3890 def : InstAlias<"{fcmle\t$dst.4h, $src1.4h, $src2.4h" #
3891 "|fcmle.4h\t$dst, $src1, $src2}",
3892 (FCMGEv4f16 V64:$dst, V64:$src2, V64:$src1), 0>;
3893 def : InstAlias<"{fcmle\t$dst.8h, $src1.8h, $src2.8h" #
3894 "|fcmle.8h\t$dst, $src1, $src2}",
3895 (FCMGEv8f16 V128:$dst, V128:$src2, V128:$src1), 0>;
3897 def : InstAlias<"{fcmle\t$dst.2s, $src1.2s, $src2.2s" #
3898 "|fcmle.2s\t$dst, $src1, $src2}",
3899 (FCMGEv2f32 V64:$dst, V64:$src2, V64:$src1), 0>;
3900 def : InstAlias<"{fcmle\t$dst.4s, $src1.4s, $src2.4s" #
3901 "|fcmle.4s\t$dst, $src1, $src2}",
3902 (FCMGEv4f32 V128:$dst, V128:$src2, V128:$src1), 0>;
3903 def : InstAlias<"{fcmle\t$dst.2d, $src1.2d, $src2.2d" #
3904 "|fcmle.2d\t$dst, $src1, $src2}",
3905 (FCMGEv2f64 V128:$dst, V128:$src2, V128:$src1), 0>;
3907 let Predicates = [HasNEON, HasFullFP16] in {
3908 def : InstAlias<"{fcmlt\t$dst.4h, $src1.4h, $src2.4h" #
3909 "|fcmlt.4h\t$dst, $src1, $src2}",
3910 (FCMGTv4f16 V64:$dst, V64:$src2, V64:$src1), 0>;
3911 def : InstAlias<"{fcmlt\t$dst.8h, $src1.8h, $src2.8h" #
3912 "|fcmlt.8h\t$dst, $src1, $src2}",
3913 (FCMGTv8f16 V128:$dst, V128:$src2, V128:$src1), 0>;
3915 def : InstAlias<"{fcmlt\t$dst.2s, $src1.2s, $src2.2s" #
3916 "|fcmlt.2s\t$dst, $src1, $src2}",
3917 (FCMGTv2f32 V64:$dst, V64:$src2, V64:$src1), 0>;
3918 def : InstAlias<"{fcmlt\t$dst.4s, $src1.4s, $src2.4s" #
3919 "|fcmlt.4s\t$dst, $src1, $src2}",
3920 (FCMGTv4f32 V128:$dst, V128:$src2, V128:$src1), 0>;
3921 def : InstAlias<"{fcmlt\t$dst.2d, $src1.2d, $src2.2d" #
3922 "|fcmlt.2d\t$dst, $src1, $src2}",
3923 (FCMGTv2f64 V128:$dst, V128:$src2, V128:$src1), 0>;
3925 let Predicates = [HasNEON, HasFullFP16] in {
3926 def : InstAlias<"{facle\t$dst.4h, $src1.4h, $src2.4h" #
3927 "|facle.4h\t$dst, $src1, $src2}",
3928 (FACGEv4f16 V64:$dst, V64:$src2, V64:$src1), 0>;
3929 def : InstAlias<"{facle\t$dst.8h, $src1.8h, $src2.8h" #
3930 "|facle.8h\t$dst, $src1, $src2}",
3931 (FACGEv8f16 V128:$dst, V128:$src2, V128:$src1), 0>;
3933 def : InstAlias<"{facle\t$dst.2s, $src1.2s, $src2.2s" #
3934 "|facle.2s\t$dst, $src1, $src2}",
3935 (FACGEv2f32 V64:$dst, V64:$src2, V64:$src1), 0>;
3936 def : InstAlias<"{facle\t$dst.4s, $src1.4s, $src2.4s" #
3937 "|facle.4s\t$dst, $src1, $src2}",
3938 (FACGEv4f32 V128:$dst, V128:$src2, V128:$src1), 0>;
3939 def : InstAlias<"{facle\t$dst.2d, $src1.2d, $src2.2d" #
3940 "|facle.2d\t$dst, $src1, $src2}",
3941 (FACGEv2f64 V128:$dst, V128:$src2, V128:$src1), 0>;
3943 let Predicates = [HasNEON, HasFullFP16] in {
3944 def : InstAlias<"{faclt\t$dst.4h, $src1.4h, $src2.4h" #
3945 "|faclt.4h\t$dst, $src1, $src2}",
3946 (FACGTv4f16 V64:$dst, V64:$src2, V64:$src1), 0>;
3947 def : InstAlias<"{faclt\t$dst.8h, $src1.8h, $src2.8h" #
3948 "|faclt.8h\t$dst, $src1, $src2}",
3949 (FACGTv8f16 V128:$dst, V128:$src2, V128:$src1), 0>;
3951 def : InstAlias<"{faclt\t$dst.2s, $src1.2s, $src2.2s" #
3952 "|faclt.2s\t$dst, $src1, $src2}",
3953 (FACGTv2f32 V64:$dst, V64:$src2, V64:$src1), 0>;
3954 def : InstAlias<"{faclt\t$dst.4s, $src1.4s, $src2.4s" #
3955 "|faclt.4s\t$dst, $src1, $src2}",
3956 (FACGTv4f32 V128:$dst, V128:$src2, V128:$src1), 0>;
3957 def : InstAlias<"{faclt\t$dst.2d, $src1.2d, $src2.2d" #
3958 "|faclt.2d\t$dst, $src1, $src2}",
3959 (FACGTv2f64 V128:$dst, V128:$src2, V128:$src1), 0>;
3961 //===----------------------------------------------------------------------===//
3962 // Advanced SIMD three scalar instructions.
3963 //===----------------------------------------------------------------------===//
3965 defm ADD : SIMDThreeScalarD<0, 0b10000, "add", add>;
3966 defm CMEQ : SIMDThreeScalarD<1, 0b10001, "cmeq", AArch64cmeq>;
3967 defm CMGE : SIMDThreeScalarD<0, 0b00111, "cmge", AArch64cmge>;
3968 defm CMGT : SIMDThreeScalarD<0, 0b00110, "cmgt", AArch64cmgt>;
3969 defm CMHI : SIMDThreeScalarD<1, 0b00110, "cmhi", AArch64cmhi>;
3970 defm CMHS : SIMDThreeScalarD<1, 0b00111, "cmhs", AArch64cmhs>;
3971 defm CMTST : SIMDThreeScalarD<0, 0b10001, "cmtst", AArch64cmtst>;
3972 defm FABD : SIMDFPThreeScalar<1, 1, 0b010, "fabd", int_aarch64_sisd_fabd>;
3973 def : Pat<(v1f64 (int_aarch64_neon_fabd (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
3974 (FABD64 FPR64:$Rn, FPR64:$Rm)>;
3975 let Predicates = [HasFullFP16] in {
3976 def : Pat<(fabs (fsub f16:$Rn, f16:$Rm)), (FABD16 f16:$Rn, f16:$Rm)>;
3978 def : Pat<(fabs (fsub f32:$Rn, f32:$Rm)), (FABD32 f32:$Rn, f32:$Rm)>;
3979 def : Pat<(fabs (fsub f64:$Rn, f64:$Rm)), (FABD64 f64:$Rn, f64:$Rm)>;
3980 defm FACGE : SIMDThreeScalarFPCmp<1, 0, 0b101, "facge",
3981 int_aarch64_neon_facge>;
3982 defm FACGT : SIMDThreeScalarFPCmp<1, 1, 0b101, "facgt",
3983 int_aarch64_neon_facgt>;
3984 defm FCMEQ : SIMDThreeScalarFPCmp<0, 0, 0b100, "fcmeq", AArch64fcmeq>;
3985 defm FCMGE : SIMDThreeScalarFPCmp<1, 0, 0b100, "fcmge", AArch64fcmge>;
3986 defm FCMGT : SIMDThreeScalarFPCmp<1, 1, 0b100, "fcmgt", AArch64fcmgt>;
3987 defm FMULX : SIMDFPThreeScalar<0, 0, 0b011, "fmulx", int_aarch64_neon_fmulx>;
3988 defm FRECPS : SIMDFPThreeScalar<0, 0, 0b111, "frecps", int_aarch64_neon_frecps>;
3989 defm FRSQRTS : SIMDFPThreeScalar<0, 1, 0b111, "frsqrts", int_aarch64_neon_frsqrts>;
3990 defm SQADD : SIMDThreeScalarBHSD<0, 0b00001, "sqadd", int_aarch64_neon_sqadd>;
3991 defm SQDMULH : SIMDThreeScalarHS< 0, 0b10110, "sqdmulh", int_aarch64_neon_sqdmulh>;
3992 defm SQRDMULH : SIMDThreeScalarHS< 1, 0b10110, "sqrdmulh", int_aarch64_neon_sqrdmulh>;
3993 defm SQRSHL : SIMDThreeScalarBHSD<0, 0b01011, "sqrshl",int_aarch64_neon_sqrshl>;
3994 defm SQSHL : SIMDThreeScalarBHSD<0, 0b01001, "sqshl", int_aarch64_neon_sqshl>;
3995 defm SQSUB : SIMDThreeScalarBHSD<0, 0b00101, "sqsub", int_aarch64_neon_sqsub>;
3996 defm SRSHL : SIMDThreeScalarD< 0, 0b01010, "srshl", int_aarch64_neon_srshl>;
3997 defm SSHL : SIMDThreeScalarD< 0, 0b01000, "sshl", int_aarch64_neon_sshl>;
3998 defm SUB : SIMDThreeScalarD< 1, 0b10000, "sub", sub>;
3999 defm UQADD : SIMDThreeScalarBHSD<1, 0b00001, "uqadd", int_aarch64_neon_uqadd>;
4000 defm UQRSHL : SIMDThreeScalarBHSD<1, 0b01011, "uqrshl",int_aarch64_neon_uqrshl>;
4001 defm UQSHL : SIMDThreeScalarBHSD<1, 0b01001, "uqshl", int_aarch64_neon_uqshl>;
4002 defm UQSUB : SIMDThreeScalarBHSD<1, 0b00101, "uqsub", int_aarch64_neon_uqsub>;
4003 defm URSHL : SIMDThreeScalarD< 1, 0b01010, "urshl", int_aarch64_neon_urshl>;
4004 defm USHL : SIMDThreeScalarD< 1, 0b01000, "ushl", int_aarch64_neon_ushl>;
4005 let Predicates = [HasRDM] in {
4006 defm SQRDMLAH : SIMDThreeScalarHSTied<1, 0, 0b10000, "sqrdmlah">;
4007 defm SQRDMLSH : SIMDThreeScalarHSTied<1, 0, 0b10001, "sqrdmlsh">;
4008 def : Pat<(i32 (int_aarch64_neon_sqadd
4010 (i32 (int_aarch64_neon_sqrdmulh (i32 FPR32:$Rn),
4011 (i32 FPR32:$Rm))))),
4012 (SQRDMLAHv1i32 FPR32:$Rd, FPR32:$Rn, FPR32:$Rm)>;
4013 def : Pat<(i32 (int_aarch64_neon_sqsub
4015 (i32 (int_aarch64_neon_sqrdmulh (i32 FPR32:$Rn),
4016 (i32 FPR32:$Rm))))),
4017 (SQRDMLSHv1i32 FPR32:$Rd, FPR32:$Rn, FPR32:$Rm)>;
4020 def : InstAlias<"cmls $dst, $src1, $src2",
4021 (CMHSv1i64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
4022 def : InstAlias<"cmle $dst, $src1, $src2",
4023 (CMGEv1i64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
4024 def : InstAlias<"cmlo $dst, $src1, $src2",
4025 (CMHIv1i64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
4026 def : InstAlias<"cmlt $dst, $src1, $src2",
4027 (CMGTv1i64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
4028 def : InstAlias<"fcmle $dst, $src1, $src2",
4029 (FCMGE32 FPR32:$dst, FPR32:$src2, FPR32:$src1), 0>;
4030 def : InstAlias<"fcmle $dst, $src1, $src2",
4031 (FCMGE64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
4032 def : InstAlias<"fcmlt $dst, $src1, $src2",
4033 (FCMGT32 FPR32:$dst, FPR32:$src2, FPR32:$src1), 0>;
4034 def : InstAlias<"fcmlt $dst, $src1, $src2",
4035 (FCMGT64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
4036 def : InstAlias<"facle $dst, $src1, $src2",
4037 (FACGE32 FPR32:$dst, FPR32:$src2, FPR32:$src1), 0>;
4038 def : InstAlias<"facle $dst, $src1, $src2",
4039 (FACGE64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
4040 def : InstAlias<"faclt $dst, $src1, $src2",
4041 (FACGT32 FPR32:$dst, FPR32:$src2, FPR32:$src1), 0>;
4042 def : InstAlias<"faclt $dst, $src1, $src2",
4043 (FACGT64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
4045 //===----------------------------------------------------------------------===//
4046 // Advanced SIMD three scalar instructions (mixed operands).
4047 //===----------------------------------------------------------------------===//
4048 defm SQDMULL : SIMDThreeScalarMixedHS<0, 0b11010, "sqdmull",
4049 int_aarch64_neon_sqdmulls_scalar>;
4050 defm SQDMLAL : SIMDThreeScalarMixedTiedHS<0, 0b10010, "sqdmlal">;
4051 defm SQDMLSL : SIMDThreeScalarMixedTiedHS<0, 0b10110, "sqdmlsl">;
4053 def : Pat<(i64 (int_aarch64_neon_sqadd (i64 FPR64:$Rd),
4054 (i64 (int_aarch64_neon_sqdmulls_scalar (i32 FPR32:$Rn),
4055 (i32 FPR32:$Rm))))),
4056 (SQDMLALi32 FPR64:$Rd, FPR32:$Rn, FPR32:$Rm)>;
4057 def : Pat<(i64 (int_aarch64_neon_sqsub (i64 FPR64:$Rd),
4058 (i64 (int_aarch64_neon_sqdmulls_scalar (i32 FPR32:$Rn),
4059 (i32 FPR32:$Rm))))),
4060 (SQDMLSLi32 FPR64:$Rd, FPR32:$Rn, FPR32:$Rm)>;
4062 //===----------------------------------------------------------------------===//
4063 // Advanced SIMD two scalar instructions.
4064 //===----------------------------------------------------------------------===//
4066 defm ABS : SIMDTwoScalarD< 0, 0b01011, "abs", abs>;
4067 defm CMEQ : SIMDCmpTwoScalarD< 0, 0b01001, "cmeq", AArch64cmeqz>;
4068 defm CMGE : SIMDCmpTwoScalarD< 1, 0b01000, "cmge", AArch64cmgez>;
4069 defm CMGT : SIMDCmpTwoScalarD< 0, 0b01000, "cmgt", AArch64cmgtz>;
4070 defm CMLE : SIMDCmpTwoScalarD< 1, 0b01001, "cmle", AArch64cmlez>;
4071 defm CMLT : SIMDCmpTwoScalarD< 0, 0b01010, "cmlt", AArch64cmltz>;
4072 defm FCMEQ : SIMDFPCmpTwoScalar<0, 1, 0b01101, "fcmeq", AArch64fcmeqz>;
4073 defm FCMGE : SIMDFPCmpTwoScalar<1, 1, 0b01100, "fcmge", AArch64fcmgez>;
4074 defm FCMGT : SIMDFPCmpTwoScalar<0, 1, 0b01100, "fcmgt", AArch64fcmgtz>;
4075 defm FCMLE : SIMDFPCmpTwoScalar<1, 1, 0b01101, "fcmle", AArch64fcmlez>;
4076 defm FCMLT : SIMDFPCmpTwoScalar<0, 1, 0b01110, "fcmlt", AArch64fcmltz>;
4077 defm FCVTAS : SIMDFPTwoScalar< 0, 0, 0b11100, "fcvtas">;
4078 defm FCVTAU : SIMDFPTwoScalar< 1, 0, 0b11100, "fcvtau">;
4079 defm FCVTMS : SIMDFPTwoScalar< 0, 0, 0b11011, "fcvtms">;
4080 defm FCVTMU : SIMDFPTwoScalar< 1, 0, 0b11011, "fcvtmu">;
4081 defm FCVTNS : SIMDFPTwoScalar< 0, 0, 0b11010, "fcvtns">;
4082 defm FCVTNU : SIMDFPTwoScalar< 1, 0, 0b11010, "fcvtnu">;
4083 defm FCVTPS : SIMDFPTwoScalar< 0, 1, 0b11010, "fcvtps">;
4084 defm FCVTPU : SIMDFPTwoScalar< 1, 1, 0b11010, "fcvtpu">;
4085 def FCVTXNv1i64 : SIMDInexactCvtTwoScalar<0b10110, "fcvtxn">;
4086 defm FCVTZS : SIMDFPTwoScalar< 0, 1, 0b11011, "fcvtzs">;
4087 defm FCVTZU : SIMDFPTwoScalar< 1, 1, 0b11011, "fcvtzu">;
4088 defm FRECPE : SIMDFPTwoScalar< 0, 1, 0b11101, "frecpe">;
4089 defm FRECPX : SIMDFPTwoScalar< 0, 1, 0b11111, "frecpx">;
4090 defm FRSQRTE : SIMDFPTwoScalar< 1, 1, 0b11101, "frsqrte">;
4091 defm NEG : SIMDTwoScalarD< 1, 0b01011, "neg",
4092 UnOpFrag<(sub immAllZerosV, node:$LHS)> >;
4093 defm SCVTF : SIMDFPTwoScalarCVT< 0, 0, 0b11101, "scvtf", AArch64sitof>;
4094 defm SQABS : SIMDTwoScalarBHSD< 0, 0b00111, "sqabs", int_aarch64_neon_sqabs>;
4095 defm SQNEG : SIMDTwoScalarBHSD< 1, 0b00111, "sqneg", int_aarch64_neon_sqneg>;
4096 defm SQXTN : SIMDTwoScalarMixedBHS< 0, 0b10100, "sqxtn", int_aarch64_neon_scalar_sqxtn>;
4097 defm SQXTUN : SIMDTwoScalarMixedBHS< 1, 0b10010, "sqxtun", int_aarch64_neon_scalar_sqxtun>;
4098 defm SUQADD : SIMDTwoScalarBHSDTied< 0, 0b00011, "suqadd",
4099 int_aarch64_neon_suqadd>;
4100 defm UCVTF : SIMDFPTwoScalarCVT< 1, 0, 0b11101, "ucvtf", AArch64uitof>;
4101 defm UQXTN : SIMDTwoScalarMixedBHS<1, 0b10100, "uqxtn", int_aarch64_neon_scalar_uqxtn>;
4102 defm USQADD : SIMDTwoScalarBHSDTied< 1, 0b00011, "usqadd",
4103 int_aarch64_neon_usqadd>;
4105 def : Pat<(AArch64neg (v1i64 V64:$Rn)), (NEGv1i64 V64:$Rn)>;
4107 def : Pat<(v1i64 (int_aarch64_neon_fcvtas (v1f64 FPR64:$Rn))),
4108 (FCVTASv1i64 FPR64:$Rn)>;
4109 def : Pat<(v1i64 (int_aarch64_neon_fcvtau (v1f64 FPR64:$Rn))),
4110 (FCVTAUv1i64 FPR64:$Rn)>;
4111 def : Pat<(v1i64 (int_aarch64_neon_fcvtms (v1f64 FPR64:$Rn))),
4112 (FCVTMSv1i64 FPR64:$Rn)>;
4113 def : Pat<(v1i64 (int_aarch64_neon_fcvtmu (v1f64 FPR64:$Rn))),
4114 (FCVTMUv1i64 FPR64:$Rn)>;
4115 def : Pat<(v1i64 (int_aarch64_neon_fcvtns (v1f64 FPR64:$Rn))),
4116 (FCVTNSv1i64 FPR64:$Rn)>;
4117 def : Pat<(v1i64 (int_aarch64_neon_fcvtnu (v1f64 FPR64:$Rn))),
4118 (FCVTNUv1i64 FPR64:$Rn)>;
4119 def : Pat<(v1i64 (int_aarch64_neon_fcvtps (v1f64 FPR64:$Rn))),
4120 (FCVTPSv1i64 FPR64:$Rn)>;
4121 def : Pat<(v1i64 (int_aarch64_neon_fcvtpu (v1f64 FPR64:$Rn))),
4122 (FCVTPUv1i64 FPR64:$Rn)>;
4124 def : Pat<(f16 (int_aarch64_neon_frecpe (f16 FPR16:$Rn))),
4125 (FRECPEv1f16 FPR16:$Rn)>;
4126 def : Pat<(f32 (int_aarch64_neon_frecpe (f32 FPR32:$Rn))),
4127 (FRECPEv1i32 FPR32:$Rn)>;
4128 def : Pat<(f64 (int_aarch64_neon_frecpe (f64 FPR64:$Rn))),
4129 (FRECPEv1i64 FPR64:$Rn)>;
4130 def : Pat<(v1f64 (int_aarch64_neon_frecpe (v1f64 FPR64:$Rn))),
4131 (FRECPEv1i64 FPR64:$Rn)>;
4133 def : Pat<(f32 (AArch64frecpe (f32 FPR32:$Rn))),
4134 (FRECPEv1i32 FPR32:$Rn)>;
4135 def : Pat<(v2f32 (AArch64frecpe (v2f32 V64:$Rn))),
4136 (FRECPEv2f32 V64:$Rn)>;
4137 def : Pat<(v4f32 (AArch64frecpe (v4f32 FPR128:$Rn))),
4138 (FRECPEv4f32 FPR128:$Rn)>;
4139 def : Pat<(f64 (AArch64frecpe (f64 FPR64:$Rn))),
4140 (FRECPEv1i64 FPR64:$Rn)>;
4141 def : Pat<(v1f64 (AArch64frecpe (v1f64 FPR64:$Rn))),
4142 (FRECPEv1i64 FPR64:$Rn)>;
4143 def : Pat<(v2f64 (AArch64frecpe (v2f64 FPR128:$Rn))),
4144 (FRECPEv2f64 FPR128:$Rn)>;
4146 def : Pat<(f32 (AArch64frecps (f32 FPR32:$Rn), (f32 FPR32:$Rm))),
4147 (FRECPS32 FPR32:$Rn, FPR32:$Rm)>;
4148 def : Pat<(v2f32 (AArch64frecps (v2f32 V64:$Rn), (v2f32 V64:$Rm))),
4149 (FRECPSv2f32 V64:$Rn, V64:$Rm)>;
4150 def : Pat<(v4f32 (AArch64frecps (v4f32 FPR128:$Rn), (v4f32 FPR128:$Rm))),
4151 (FRECPSv4f32 FPR128:$Rn, FPR128:$Rm)>;
4152 def : Pat<(f64 (AArch64frecps (f64 FPR64:$Rn), (f64 FPR64:$Rm))),
4153 (FRECPS64 FPR64:$Rn, FPR64:$Rm)>;
4154 def : Pat<(v2f64 (AArch64frecps (v2f64 FPR128:$Rn), (v2f64 FPR128:$Rm))),
4155 (FRECPSv2f64 FPR128:$Rn, FPR128:$Rm)>;
4157 def : Pat<(f16 (int_aarch64_neon_frecpx (f16 FPR16:$Rn))),
4158 (FRECPXv1f16 FPR16:$Rn)>;
4159 def : Pat<(f32 (int_aarch64_neon_frecpx (f32 FPR32:$Rn))),
4160 (FRECPXv1i32 FPR32:$Rn)>;
4161 def : Pat<(f64 (int_aarch64_neon_frecpx (f64 FPR64:$Rn))),
4162 (FRECPXv1i64 FPR64:$Rn)>;
4164 def : Pat<(f16 (int_aarch64_neon_frsqrte (f16 FPR16:$Rn))),
4165 (FRSQRTEv1f16 FPR16:$Rn)>;
4166 def : Pat<(f32 (int_aarch64_neon_frsqrte (f32 FPR32:$Rn))),
4167 (FRSQRTEv1i32 FPR32:$Rn)>;
4168 def : Pat<(f64 (int_aarch64_neon_frsqrte (f64 FPR64:$Rn))),
4169 (FRSQRTEv1i64 FPR64:$Rn)>;
4170 def : Pat<(v1f64 (int_aarch64_neon_frsqrte (v1f64 FPR64:$Rn))),
4171 (FRSQRTEv1i64 FPR64:$Rn)>;
4173 def : Pat<(f32 (AArch64frsqrte (f32 FPR32:$Rn))),
4174 (FRSQRTEv1i32 FPR32:$Rn)>;
4175 def : Pat<(v2f32 (AArch64frsqrte (v2f32 V64:$Rn))),
4176 (FRSQRTEv2f32 V64:$Rn)>;
4177 def : Pat<(v4f32 (AArch64frsqrte (v4f32 FPR128:$Rn))),
4178 (FRSQRTEv4f32 FPR128:$Rn)>;
4179 def : Pat<(f64 (AArch64frsqrte (f64 FPR64:$Rn))),
4180 (FRSQRTEv1i64 FPR64:$Rn)>;
4181 def : Pat<(v1f64 (AArch64frsqrte (v1f64 FPR64:$Rn))),
4182 (FRSQRTEv1i64 FPR64:$Rn)>;
4183 def : Pat<(v2f64 (AArch64frsqrte (v2f64 FPR128:$Rn))),
4184 (FRSQRTEv2f64 FPR128:$Rn)>;
4186 def : Pat<(f32 (AArch64frsqrts (f32 FPR32:$Rn), (f32 FPR32:$Rm))),
4187 (FRSQRTS32 FPR32:$Rn, FPR32:$Rm)>;
4188 def : Pat<(v2f32 (AArch64frsqrts (v2f32 V64:$Rn), (v2f32 V64:$Rm))),
4189 (FRSQRTSv2f32 V64:$Rn, V64:$Rm)>;
4190 def : Pat<(v4f32 (AArch64frsqrts (v4f32 FPR128:$Rn), (v4f32 FPR128:$Rm))),
4191 (FRSQRTSv4f32 FPR128:$Rn, FPR128:$Rm)>;
4192 def : Pat<(f64 (AArch64frsqrts (f64 FPR64:$Rn), (f64 FPR64:$Rm))),
4193 (FRSQRTS64 FPR64:$Rn, FPR64:$Rm)>;
4194 def : Pat<(v2f64 (AArch64frsqrts (v2f64 FPR128:$Rn), (v2f64 FPR128:$Rm))),
4195 (FRSQRTSv2f64 FPR128:$Rn, FPR128:$Rm)>;
4197 // If an integer is about to be converted to a floating point value,
4198 // just load it on the floating point unit.
4199 // Here are the patterns for 8 and 16-bits to float.
4201 multiclass UIntToFPROLoadPat<ValueType DstTy, ValueType SrcTy,
4202 SDPatternOperator loadop, Instruction UCVTF,
4203 ROAddrMode ro, Instruction LDRW, Instruction LDRX,
4205 def : Pat<(DstTy (uint_to_fp (SrcTy
4206 (loadop (ro.Wpat GPR64sp:$Rn, GPR32:$Rm,
4207 ro.Wext:$extend))))),
4208 (UCVTF (INSERT_SUBREG (DstTy (IMPLICIT_DEF)),
4209 (LDRW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend),
4212 def : Pat<(DstTy (uint_to_fp (SrcTy
4213 (loadop (ro.Xpat GPR64sp:$Rn, GPR64:$Rm,
4214 ro.Wext:$extend))))),
4215 (UCVTF (INSERT_SUBREG (DstTy (IMPLICIT_DEF)),
4216 (LDRX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend),
4220 defm : UIntToFPROLoadPat<f32, i32, zextloadi8,
4221 UCVTFv1i32, ro8, LDRBroW, LDRBroX, bsub>;
4222 def : Pat <(f32 (uint_to_fp (i32
4223 (zextloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))))),
4224 (UCVTFv1i32 (INSERT_SUBREG (f32 (IMPLICIT_DEF)),
4225 (LDRBui GPR64sp:$Rn, uimm12s1:$offset), bsub))>;
4226 def : Pat <(f32 (uint_to_fp (i32
4227 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))))),
4228 (UCVTFv1i32 (INSERT_SUBREG (f32 (IMPLICIT_DEF)),
4229 (LDURBi GPR64sp:$Rn, simm9:$offset), bsub))>;
4230 // 16-bits -> float.
4231 defm : UIntToFPROLoadPat<f32, i32, zextloadi16,
4232 UCVTFv1i32, ro16, LDRHroW, LDRHroX, hsub>;
4233 def : Pat <(f32 (uint_to_fp (i32
4234 (zextloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))))),
4235 (UCVTFv1i32 (INSERT_SUBREG (f32 (IMPLICIT_DEF)),
4236 (LDRHui GPR64sp:$Rn, uimm12s2:$offset), hsub))>;
4237 def : Pat <(f32 (uint_to_fp (i32
4238 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))))),
4239 (UCVTFv1i32 (INSERT_SUBREG (f32 (IMPLICIT_DEF)),
4240 (LDURHi GPR64sp:$Rn, simm9:$offset), hsub))>;
4241 // 32-bits are handled in target specific dag combine:
4242 // performIntToFpCombine.
4243 // 64-bits integer to 32-bits floating point, not possible with
4244 // UCVTF on floating point registers (both source and destination
4245 // must have the same size).
4247 // Here are the patterns for 8, 16, 32, and 64-bits to double.
4248 // 8-bits -> double.
4249 defm : UIntToFPROLoadPat<f64, i32, zextloadi8,
4250 UCVTFv1i64, ro8, LDRBroW, LDRBroX, bsub>;
4251 def : Pat <(f64 (uint_to_fp (i32
4252 (zextloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))))),
4253 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4254 (LDRBui GPR64sp:$Rn, uimm12s1:$offset), bsub))>;
4255 def : Pat <(f64 (uint_to_fp (i32
4256 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))))),
4257 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4258 (LDURBi GPR64sp:$Rn, simm9:$offset), bsub))>;
4259 // 16-bits -> double.
4260 defm : UIntToFPROLoadPat<f64, i32, zextloadi16,
4261 UCVTFv1i64, ro16, LDRHroW, LDRHroX, hsub>;
4262 def : Pat <(f64 (uint_to_fp (i32
4263 (zextloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))))),
4264 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4265 (LDRHui GPR64sp:$Rn, uimm12s2:$offset), hsub))>;
4266 def : Pat <(f64 (uint_to_fp (i32
4267 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))))),
4268 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4269 (LDURHi GPR64sp:$Rn, simm9:$offset), hsub))>;
4270 // 32-bits -> double.
4271 defm : UIntToFPROLoadPat<f64, i32, load,
4272 UCVTFv1i64, ro32, LDRSroW, LDRSroX, ssub>;
4273 def : Pat <(f64 (uint_to_fp (i32
4274 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))))),
4275 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4276 (LDRSui GPR64sp:$Rn, uimm12s4:$offset), ssub))>;
4277 def : Pat <(f64 (uint_to_fp (i32
4278 (load (am_unscaled32 GPR64sp:$Rn, simm9:$offset))))),
4279 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4280 (LDURSi GPR64sp:$Rn, simm9:$offset), ssub))>;
4281 // 64-bits -> double are handled in target specific dag combine:
4282 // performIntToFpCombine.
4284 //===----------------------------------------------------------------------===//
4285 // Advanced SIMD three different-sized vector instructions.
4286 //===----------------------------------------------------------------------===//
4288 defm ADDHN : SIMDNarrowThreeVectorBHS<0,0b0100,"addhn", int_aarch64_neon_addhn>;
4289 defm SUBHN : SIMDNarrowThreeVectorBHS<0,0b0110,"subhn", int_aarch64_neon_subhn>;
4290 defm RADDHN : SIMDNarrowThreeVectorBHS<1,0b0100,"raddhn",int_aarch64_neon_raddhn>;
4291 defm RSUBHN : SIMDNarrowThreeVectorBHS<1,0b0110,"rsubhn",int_aarch64_neon_rsubhn>;
4292 defm PMULL : SIMDDifferentThreeVectorBD<0,0b1110,"pmull",int_aarch64_neon_pmull>;
4293 defm SABAL : SIMDLongThreeVectorTiedBHSabal<0,0b0101,"sabal",
4294 int_aarch64_neon_sabd>;
4295 defm SABDL : SIMDLongThreeVectorBHSabdl<0, 0b0111, "sabdl",
4296 int_aarch64_neon_sabd>;
4297 defm SADDL : SIMDLongThreeVectorBHS< 0, 0b0000, "saddl",
4298 BinOpFrag<(add (sext node:$LHS), (sext node:$RHS))>>;
4299 defm SADDW : SIMDWideThreeVectorBHS< 0, 0b0001, "saddw",
4300 BinOpFrag<(add node:$LHS, (sext node:$RHS))>>;
4301 defm SMLAL : SIMDLongThreeVectorTiedBHS<0, 0b1000, "smlal",
4302 TriOpFrag<(add node:$LHS, (int_aarch64_neon_smull node:$MHS, node:$RHS))>>;
4303 defm SMLSL : SIMDLongThreeVectorTiedBHS<0, 0b1010, "smlsl",
4304 TriOpFrag<(sub node:$LHS, (int_aarch64_neon_smull node:$MHS, node:$RHS))>>;
4305 defm SMULL : SIMDLongThreeVectorBHS<0, 0b1100, "smull", int_aarch64_neon_smull>;
4306 defm SQDMLAL : SIMDLongThreeVectorSQDMLXTiedHS<0, 0b1001, "sqdmlal",
4307 int_aarch64_neon_sqadd>;
4308 defm SQDMLSL : SIMDLongThreeVectorSQDMLXTiedHS<0, 0b1011, "sqdmlsl",
4309 int_aarch64_neon_sqsub>;
4310 defm SQDMULL : SIMDLongThreeVectorHS<0, 0b1101, "sqdmull",
4311 int_aarch64_neon_sqdmull>;
4312 defm SSUBL : SIMDLongThreeVectorBHS<0, 0b0010, "ssubl",
4313 BinOpFrag<(sub (sext node:$LHS), (sext node:$RHS))>>;
4314 defm SSUBW : SIMDWideThreeVectorBHS<0, 0b0011, "ssubw",
4315 BinOpFrag<(sub node:$LHS, (sext node:$RHS))>>;
4316 defm UABAL : SIMDLongThreeVectorTiedBHSabal<1, 0b0101, "uabal",
4317 int_aarch64_neon_uabd>;
4318 defm UADDL : SIMDLongThreeVectorBHS<1, 0b0000, "uaddl",
4319 BinOpFrag<(add (zext node:$LHS), (zext node:$RHS))>>;
4320 defm UADDW : SIMDWideThreeVectorBHS<1, 0b0001, "uaddw",
4321 BinOpFrag<(add node:$LHS, (zext node:$RHS))>>;
4322 defm UMLAL : SIMDLongThreeVectorTiedBHS<1, 0b1000, "umlal",
4323 TriOpFrag<(add node:$LHS, (int_aarch64_neon_umull node:$MHS, node:$RHS))>>;
4324 defm UMLSL : SIMDLongThreeVectorTiedBHS<1, 0b1010, "umlsl",
4325 TriOpFrag<(sub node:$LHS, (int_aarch64_neon_umull node:$MHS, node:$RHS))>>;
4326 defm UMULL : SIMDLongThreeVectorBHS<1, 0b1100, "umull", int_aarch64_neon_umull>;
4327 defm USUBL : SIMDLongThreeVectorBHS<1, 0b0010, "usubl",
4328 BinOpFrag<(sub (zext node:$LHS), (zext node:$RHS))>>;
4329 defm USUBW : SIMDWideThreeVectorBHS< 1, 0b0011, "usubw",
4330 BinOpFrag<(sub node:$LHS, (zext node:$RHS))>>;
4332 // Additional patterns for SMULL and UMULL
4333 multiclass Neon_mul_widen_patterns<SDPatternOperator opnode,
4334 Instruction INST8B, Instruction INST4H, Instruction INST2S> {
4335 def : Pat<(v8i16 (opnode (v8i8 V64:$Rn), (v8i8 V64:$Rm))),
4336 (INST8B V64:$Rn, V64:$Rm)>;
4337 def : Pat<(v4i32 (opnode (v4i16 V64:$Rn), (v4i16 V64:$Rm))),
4338 (INST4H V64:$Rn, V64:$Rm)>;
4339 def : Pat<(v2i64 (opnode (v2i32 V64:$Rn), (v2i32 V64:$Rm))),
4340 (INST2S V64:$Rn, V64:$Rm)>;
4343 defm : Neon_mul_widen_patterns<AArch64smull, SMULLv8i8_v8i16,
4344 SMULLv4i16_v4i32, SMULLv2i32_v2i64>;
4345 defm : Neon_mul_widen_patterns<AArch64umull, UMULLv8i8_v8i16,
4346 UMULLv4i16_v4i32, UMULLv2i32_v2i64>;
4348 // Additional patterns for SMLAL/SMLSL and UMLAL/UMLSL
4349 multiclass Neon_mulacc_widen_patterns<SDPatternOperator opnode,
4350 Instruction INST8B, Instruction INST4H, Instruction INST2S> {
4351 def : Pat<(v8i16 (opnode (v8i16 V128:$Rd), (v8i8 V64:$Rn), (v8i8 V64:$Rm))),
4352 (INST8B V128:$Rd, V64:$Rn, V64:$Rm)>;
4353 def : Pat<(v4i32 (opnode (v4i32 V128:$Rd), (v4i16 V64:$Rn), (v4i16 V64:$Rm))),
4354 (INST4H V128:$Rd, V64:$Rn, V64:$Rm)>;
4355 def : Pat<(v2i64 (opnode (v2i64 V128:$Rd), (v2i32 V64:$Rn), (v2i32 V64:$Rm))),
4356 (INST2S V128:$Rd, V64:$Rn, V64:$Rm)>;
4359 defm : Neon_mulacc_widen_patterns<
4360 TriOpFrag<(add node:$LHS, (AArch64smull node:$MHS, node:$RHS))>,
4361 SMLALv8i8_v8i16, SMLALv4i16_v4i32, SMLALv2i32_v2i64>;
4362 defm : Neon_mulacc_widen_patterns<
4363 TriOpFrag<(add node:$LHS, (AArch64umull node:$MHS, node:$RHS))>,
4364 UMLALv8i8_v8i16, UMLALv4i16_v4i32, UMLALv2i32_v2i64>;
4365 defm : Neon_mulacc_widen_patterns<
4366 TriOpFrag<(sub node:$LHS, (AArch64smull node:$MHS, node:$RHS))>,
4367 SMLSLv8i8_v8i16, SMLSLv4i16_v4i32, SMLSLv2i32_v2i64>;
4368 defm : Neon_mulacc_widen_patterns<
4369 TriOpFrag<(sub node:$LHS, (AArch64umull node:$MHS, node:$RHS))>,
4370 UMLSLv8i8_v8i16, UMLSLv4i16_v4i32, UMLSLv2i32_v2i64>;
4372 // Patterns for 64-bit pmull
4373 def : Pat<(int_aarch64_neon_pmull64 V64:$Rn, V64:$Rm),
4374 (PMULLv1i64 V64:$Rn, V64:$Rm)>;
4375 def : Pat<(int_aarch64_neon_pmull64 (extractelt (v2i64 V128:$Rn), (i64 1)),
4376 (extractelt (v2i64 V128:$Rm), (i64 1))),
4377 (PMULLv2i64 V128:$Rn, V128:$Rm)>;
4379 // CodeGen patterns for addhn and subhn instructions, which can actually be
4380 // written in LLVM IR without too much difficulty.
4383 def : Pat<(v8i8 (trunc (v8i16 (AArch64vlshr (add V128:$Rn, V128:$Rm), (i32 8))))),
4384 (ADDHNv8i16_v8i8 V128:$Rn, V128:$Rm)>;
4385 def : Pat<(v4i16 (trunc (v4i32 (AArch64vlshr (add V128:$Rn, V128:$Rm),
4387 (ADDHNv4i32_v4i16 V128:$Rn, V128:$Rm)>;
4388 def : Pat<(v2i32 (trunc (v2i64 (AArch64vlshr (add V128:$Rn, V128:$Rm),
4390 (ADDHNv2i64_v2i32 V128:$Rn, V128:$Rm)>;
4391 def : Pat<(concat_vectors (v8i8 V64:$Rd),
4392 (trunc (v8i16 (AArch64vlshr (add V128:$Rn, V128:$Rm),
4394 (ADDHNv8i16_v16i8 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4395 V128:$Rn, V128:$Rm)>;
4396 def : Pat<(concat_vectors (v4i16 V64:$Rd),
4397 (trunc (v4i32 (AArch64vlshr (add V128:$Rn, V128:$Rm),
4399 (ADDHNv4i32_v8i16 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4400 V128:$Rn, V128:$Rm)>;
4401 def : Pat<(concat_vectors (v2i32 V64:$Rd),
4402 (trunc (v2i64 (AArch64vlshr (add V128:$Rn, V128:$Rm),
4404 (ADDHNv2i64_v4i32 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4405 V128:$Rn, V128:$Rm)>;
4408 def : Pat<(v8i8 (trunc (v8i16 (AArch64vlshr (sub V128:$Rn, V128:$Rm), (i32 8))))),
4409 (SUBHNv8i16_v8i8 V128:$Rn, V128:$Rm)>;
4410 def : Pat<(v4i16 (trunc (v4i32 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
4412 (SUBHNv4i32_v4i16 V128:$Rn, V128:$Rm)>;
4413 def : Pat<(v2i32 (trunc (v2i64 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
4415 (SUBHNv2i64_v2i32 V128:$Rn, V128:$Rm)>;
4416 def : Pat<(concat_vectors (v8i8 V64:$Rd),
4417 (trunc (v8i16 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
4419 (SUBHNv8i16_v16i8 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4420 V128:$Rn, V128:$Rm)>;
4421 def : Pat<(concat_vectors (v4i16 V64:$Rd),
4422 (trunc (v4i32 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
4424 (SUBHNv4i32_v8i16 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4425 V128:$Rn, V128:$Rm)>;
4426 def : Pat<(concat_vectors (v2i32 V64:$Rd),
4427 (trunc (v2i64 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
4429 (SUBHNv2i64_v4i32 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4430 V128:$Rn, V128:$Rm)>;
4432 //----------------------------------------------------------------------------
4433 // AdvSIMD bitwise extract from vector instruction.
4434 //----------------------------------------------------------------------------
4436 defm EXT : SIMDBitwiseExtract<"ext">;
4438 def AdjustExtImm : SDNodeXForm<imm, [{
4439 return CurDAG->getTargetConstant(8 + N->getZExtValue(), SDLoc(N), MVT::i32);
4441 multiclass ExtPat<ValueType VT64, ValueType VT128, int N> {
4442 def : Pat<(VT64 (AArch64ext V64:$Rn, V64:$Rm, (i32 imm:$imm))),
4443 (EXTv8i8 V64:$Rn, V64:$Rm, imm:$imm)>;
4444 def : Pat<(VT128 (AArch64ext V128:$Rn, V128:$Rm, (i32 imm:$imm))),
4445 (EXTv16i8 V128:$Rn, V128:$Rm, imm:$imm)>;
4446 // We use EXT to handle extract_subvector to copy the upper 64-bits of a
4448 def : Pat<(VT64 (extract_subvector V128:$Rn, (i64 N))),
4449 (EXTRACT_SUBREG (EXTv16i8 V128:$Rn, V128:$Rn, 8), dsub)>;
4450 // A 64-bit EXT of two halves of the same 128-bit register can be done as a
4451 // single 128-bit EXT.
4452 def : Pat<(VT64 (AArch64ext (extract_subvector V128:$Rn, (i64 0)),
4453 (extract_subvector V128:$Rn, (i64 N)),
4455 (EXTRACT_SUBREG (EXTv16i8 V128:$Rn, V128:$Rn, imm:$imm), dsub)>;
4456 // A 64-bit EXT of the high half of a 128-bit register can be done using a
4457 // 128-bit EXT of the whole register with an adjustment to the immediate. The
4458 // top half of the other operand will be unset, but that doesn't matter as it
4459 // will not be used.
4460 def : Pat<(VT64 (AArch64ext (extract_subvector V128:$Rn, (i64 N)),
4463 (EXTRACT_SUBREG (EXTv16i8 V128:$Rn,
4464 (SUBREG_TO_REG (i32 0), V64:$Rm, dsub),
4465 (AdjustExtImm imm:$imm)), dsub)>;
4468 defm : ExtPat<v8i8, v16i8, 8>;
4469 defm : ExtPat<v4i16, v8i16, 4>;
4470 defm : ExtPat<v4f16, v8f16, 4>;
4471 defm : ExtPat<v2i32, v4i32, 2>;
4472 defm : ExtPat<v2f32, v4f32, 2>;
4473 defm : ExtPat<v1i64, v2i64, 1>;
4474 defm : ExtPat<v1f64, v2f64, 1>;
4476 //----------------------------------------------------------------------------
4477 // AdvSIMD zip vector
4478 //----------------------------------------------------------------------------
4480 defm TRN1 : SIMDZipVector<0b010, "trn1", AArch64trn1>;
4481 defm TRN2 : SIMDZipVector<0b110, "trn2", AArch64trn2>;
4482 defm UZP1 : SIMDZipVector<0b001, "uzp1", AArch64uzp1>;
4483 defm UZP2 : SIMDZipVector<0b101, "uzp2", AArch64uzp2>;
4484 defm ZIP1 : SIMDZipVector<0b011, "zip1", AArch64zip1>;
4485 defm ZIP2 : SIMDZipVector<0b111, "zip2", AArch64zip2>;
4487 //----------------------------------------------------------------------------
4488 // AdvSIMD TBL/TBX instructions
4489 //----------------------------------------------------------------------------
4491 defm TBL : SIMDTableLookup< 0, "tbl">;
4492 defm TBX : SIMDTableLookupTied<1, "tbx">;
4494 def : Pat<(v8i8 (int_aarch64_neon_tbl1 (v16i8 VecListOne128:$Rn), (v8i8 V64:$Ri))),
4495 (TBLv8i8One VecListOne128:$Rn, V64:$Ri)>;
4496 def : Pat<(v16i8 (int_aarch64_neon_tbl1 (v16i8 V128:$Ri), (v16i8 V128:$Rn))),
4497 (TBLv16i8One V128:$Ri, V128:$Rn)>;
4499 def : Pat<(v8i8 (int_aarch64_neon_tbx1 (v8i8 V64:$Rd),
4500 (v16i8 VecListOne128:$Rn), (v8i8 V64:$Ri))),
4501 (TBXv8i8One V64:$Rd, VecListOne128:$Rn, V64:$Ri)>;
4502 def : Pat<(v16i8 (int_aarch64_neon_tbx1 (v16i8 V128:$Rd),
4503 (v16i8 V128:$Ri), (v16i8 V128:$Rn))),
4504 (TBXv16i8One V128:$Rd, V128:$Ri, V128:$Rn)>;
4507 //----------------------------------------------------------------------------
4508 // AdvSIMD scalar CPY instruction
4509 //----------------------------------------------------------------------------
4511 defm CPY : SIMDScalarCPY<"cpy">;
4513 //----------------------------------------------------------------------------
4514 // AdvSIMD scalar pairwise instructions
4515 //----------------------------------------------------------------------------
4517 defm ADDP : SIMDPairwiseScalarD<0, 0b11011, "addp">;
4518 defm FADDP : SIMDFPPairwiseScalar<0, 0b01101, "faddp">;
4519 defm FMAXNMP : SIMDFPPairwiseScalar<0, 0b01100, "fmaxnmp">;
4520 defm FMAXP : SIMDFPPairwiseScalar<0, 0b01111, "fmaxp">;
4521 defm FMINNMP : SIMDFPPairwiseScalar<1, 0b01100, "fminnmp">;
4522 defm FMINP : SIMDFPPairwiseScalar<1, 0b01111, "fminp">;
4523 def : Pat<(v2i64 (AArch64saddv V128:$Rn)),
4524 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)), (ADDPv2i64p V128:$Rn), dsub)>;
4525 def : Pat<(v2i64 (AArch64uaddv V128:$Rn)),
4526 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)), (ADDPv2i64p V128:$Rn), dsub)>;
4527 def : Pat<(f32 (int_aarch64_neon_faddv (v2f32 V64:$Rn))),
4528 (FADDPv2i32p V64:$Rn)>;
4529 def : Pat<(f32 (int_aarch64_neon_faddv (v4f32 V128:$Rn))),
4530 (FADDPv2i32p (EXTRACT_SUBREG (FADDPv4f32 V128:$Rn, V128:$Rn), dsub))>;
4531 def : Pat<(f64 (int_aarch64_neon_faddv (v2f64 V128:$Rn))),
4532 (FADDPv2i64p V128:$Rn)>;
4533 def : Pat<(f32 (int_aarch64_neon_fmaxnmv (v2f32 V64:$Rn))),
4534 (FMAXNMPv2i32p V64:$Rn)>;
4535 def : Pat<(f64 (int_aarch64_neon_fmaxnmv (v2f64 V128:$Rn))),
4536 (FMAXNMPv2i64p V128:$Rn)>;
4537 def : Pat<(f32 (int_aarch64_neon_fmaxv (v2f32 V64:$Rn))),
4538 (FMAXPv2i32p V64:$Rn)>;
4539 def : Pat<(f64 (int_aarch64_neon_fmaxv (v2f64 V128:$Rn))),
4540 (FMAXPv2i64p V128:$Rn)>;
4541 def : Pat<(f32 (int_aarch64_neon_fminnmv (v2f32 V64:$Rn))),
4542 (FMINNMPv2i32p V64:$Rn)>;
4543 def : Pat<(f64 (int_aarch64_neon_fminnmv (v2f64 V128:$Rn))),
4544 (FMINNMPv2i64p V128:$Rn)>;
4545 def : Pat<(f32 (int_aarch64_neon_fminv (v2f32 V64:$Rn))),
4546 (FMINPv2i32p V64:$Rn)>;
4547 def : Pat<(f64 (int_aarch64_neon_fminv (v2f64 V128:$Rn))),
4548 (FMINPv2i64p V128:$Rn)>;
4550 //----------------------------------------------------------------------------
4551 // AdvSIMD INS/DUP instructions
4552 //----------------------------------------------------------------------------
4554 def DUPv8i8gpr : SIMDDupFromMain<0, {?,?,?,?,1}, ".8b", v8i8, V64, GPR32>;
4555 def DUPv16i8gpr : SIMDDupFromMain<1, {?,?,?,?,1}, ".16b", v16i8, V128, GPR32>;
4556 def DUPv4i16gpr : SIMDDupFromMain<0, {?,?,?,1,0}, ".4h", v4i16, V64, GPR32>;
4557 def DUPv8i16gpr : SIMDDupFromMain<1, {?,?,?,1,0}, ".8h", v8i16, V128, GPR32>;
4558 def DUPv2i32gpr : SIMDDupFromMain<0, {?,?,1,0,0}, ".2s", v2i32, V64, GPR32>;
4559 def DUPv4i32gpr : SIMDDupFromMain<1, {?,?,1,0,0}, ".4s", v4i32, V128, GPR32>;
4560 def DUPv2i64gpr : SIMDDupFromMain<1, {?,1,0,0,0}, ".2d", v2i64, V128, GPR64>;
4562 def DUPv2i64lane : SIMDDup64FromElement;
4563 def DUPv2i32lane : SIMDDup32FromElement<0, ".2s", v2i32, V64>;
4564 def DUPv4i32lane : SIMDDup32FromElement<1, ".4s", v4i32, V128>;
4565 def DUPv4i16lane : SIMDDup16FromElement<0, ".4h", v4i16, V64>;
4566 def DUPv8i16lane : SIMDDup16FromElement<1, ".8h", v8i16, V128>;
4567 def DUPv8i8lane : SIMDDup8FromElement <0, ".8b", v8i8, V64>;
4568 def DUPv16i8lane : SIMDDup8FromElement <1, ".16b", v16i8, V128>;
4570 // DUP from a 64-bit register to a 64-bit register is just a copy
4571 def : Pat<(v1i64 (AArch64dup (i64 GPR64:$Rn))),
4572 (COPY_TO_REGCLASS GPR64:$Rn, FPR64)>;
4573 def : Pat<(v1f64 (AArch64dup (f64 FPR64:$Rn))),
4574 (COPY_TO_REGCLASS FPR64:$Rn, FPR64)>;
4576 def : Pat<(v2f32 (AArch64dup (f32 FPR32:$Rn))),
4577 (v2f32 (DUPv2i32lane
4578 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR32:$Rn, ssub),
4580 def : Pat<(v4f32 (AArch64dup (f32 FPR32:$Rn))),
4581 (v4f32 (DUPv4i32lane
4582 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR32:$Rn, ssub),
4584 def : Pat<(v2f64 (AArch64dup (f64 FPR64:$Rn))),
4585 (v2f64 (DUPv2i64lane
4586 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR64:$Rn, dsub),
4588 def : Pat<(v4f16 (AArch64dup (f16 FPR16:$Rn))),
4589 (v4f16 (DUPv4i16lane
4590 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)), FPR16:$Rn, hsub),
4592 def : Pat<(v8f16 (AArch64dup (f16 FPR16:$Rn))),
4593 (v8f16 (DUPv8i16lane
4594 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)), FPR16:$Rn, hsub),
4597 def : Pat<(v4f16 (AArch64duplane16 (v8f16 V128:$Rn), VectorIndexH:$imm)),
4598 (DUPv4i16lane V128:$Rn, VectorIndexH:$imm)>;
4599 def : Pat<(v8f16 (AArch64duplane16 (v8f16 V128:$Rn), VectorIndexH:$imm)),
4600 (DUPv8i16lane V128:$Rn, VectorIndexH:$imm)>;
4602 def : Pat<(v2f32 (AArch64duplane32 (v4f32 V128:$Rn), VectorIndexS:$imm)),
4603 (DUPv2i32lane V128:$Rn, VectorIndexS:$imm)>;
4604 def : Pat<(v4f32 (AArch64duplane32 (v4f32 V128:$Rn), VectorIndexS:$imm)),
4605 (DUPv4i32lane V128:$Rn, VectorIndexS:$imm)>;
4606 def : Pat<(v2f64 (AArch64duplane64 (v2f64 V128:$Rn), VectorIndexD:$imm)),
4607 (DUPv2i64lane V128:$Rn, VectorIndexD:$imm)>;
4609 // If there's an (AArch64dup (vector_extract ...) ...), we can use a duplane
4610 // instruction even if the types don't match: we just have to remap the lane
4611 // carefully. N.b. this trick only applies to truncations.
4612 def VecIndex_x2 : SDNodeXForm<imm, [{
4613 return CurDAG->getTargetConstant(2 * N->getZExtValue(), SDLoc(N), MVT::i64);
4615 def VecIndex_x4 : SDNodeXForm<imm, [{
4616 return CurDAG->getTargetConstant(4 * N->getZExtValue(), SDLoc(N), MVT::i64);
4618 def VecIndex_x8 : SDNodeXForm<imm, [{
4619 return CurDAG->getTargetConstant(8 * N->getZExtValue(), SDLoc(N), MVT::i64);
4622 multiclass DUPWithTruncPats<ValueType ResVT, ValueType Src64VT,
4623 ValueType Src128VT, ValueType ScalVT,
4624 Instruction DUP, SDNodeXForm IdxXFORM> {
4625 def : Pat<(ResVT (AArch64dup (ScalVT (vector_extract (Src128VT V128:$Rn),
4627 (DUP V128:$Rn, (IdxXFORM imm:$idx))>;
4629 def : Pat<(ResVT (AArch64dup (ScalVT (vector_extract (Src64VT V64:$Rn),
4631 (DUP (SUBREG_TO_REG (i64 0), V64:$Rn, dsub), (IdxXFORM imm:$idx))>;
4634 defm : DUPWithTruncPats<v8i8, v4i16, v8i16, i32, DUPv8i8lane, VecIndex_x2>;
4635 defm : DUPWithTruncPats<v8i8, v2i32, v4i32, i32, DUPv8i8lane, VecIndex_x4>;
4636 defm : DUPWithTruncPats<v4i16, v2i32, v4i32, i32, DUPv4i16lane, VecIndex_x2>;
4638 defm : DUPWithTruncPats<v16i8, v4i16, v8i16, i32, DUPv16i8lane, VecIndex_x2>;
4639 defm : DUPWithTruncPats<v16i8, v2i32, v4i32, i32, DUPv16i8lane, VecIndex_x4>;
4640 defm : DUPWithTruncPats<v8i16, v2i32, v4i32, i32, DUPv8i16lane, VecIndex_x2>;
4642 multiclass DUPWithTrunci64Pats<ValueType ResVT, Instruction DUP,
4643 SDNodeXForm IdxXFORM> {
4644 def : Pat<(ResVT (AArch64dup (i32 (trunc (extractelt (v2i64 V128:$Rn),
4646 (DUP V128:$Rn, (IdxXFORM imm:$idx))>;
4648 def : Pat<(ResVT (AArch64dup (i32 (trunc (extractelt (v1i64 V64:$Rn),
4650 (DUP (SUBREG_TO_REG (i64 0), V64:$Rn, dsub), (IdxXFORM imm:$idx))>;
4653 defm : DUPWithTrunci64Pats<v8i8, DUPv8i8lane, VecIndex_x8>;
4654 defm : DUPWithTrunci64Pats<v4i16, DUPv4i16lane, VecIndex_x4>;
4655 defm : DUPWithTrunci64Pats<v2i32, DUPv2i32lane, VecIndex_x2>;
4657 defm : DUPWithTrunci64Pats<v16i8, DUPv16i8lane, VecIndex_x8>;
4658 defm : DUPWithTrunci64Pats<v8i16, DUPv8i16lane, VecIndex_x4>;
4659 defm : DUPWithTrunci64Pats<v4i32, DUPv4i32lane, VecIndex_x2>;
4661 // SMOV and UMOV definitions, with some extra patterns for convenience
4665 def : Pat<(sext_inreg (vector_extract (v16i8 V128:$Rn), VectorIndexB:$idx), i8),
4666 (i32 (SMOVvi8to32 V128:$Rn, VectorIndexB:$idx))>;
4667 def : Pat<(sext_inreg (vector_extract (v16i8 V128:$Rn), VectorIndexB:$idx), i8),
4668 (i64 (SMOVvi8to64 V128:$Rn, VectorIndexB:$idx))>;
4669 def : Pat<(sext_inreg (vector_extract (v8i16 V128:$Rn), VectorIndexH:$idx),i16),
4670 (i32 (SMOVvi16to32 V128:$Rn, VectorIndexH:$idx))>;
4671 def : Pat<(sext_inreg (vector_extract (v8i16 V128:$Rn), VectorIndexH:$idx),i16),
4672 (i64 (SMOVvi16to64 V128:$Rn, VectorIndexH:$idx))>;
4673 def : Pat<(sext_inreg (vector_extract (v8i16 V128:$Rn), VectorIndexH:$idx),i16),
4674 (i32 (SMOVvi16to32 V128:$Rn, VectorIndexH:$idx))>;
4675 def : Pat<(sext (i32 (vector_extract (v4i32 V128:$Rn), VectorIndexS:$idx))),
4676 (i64 (SMOVvi32to64 V128:$Rn, VectorIndexS:$idx))>;
4678 def : Pat<(sext_inreg (i64 (anyext (i32 (vector_extract (v16i8 V128:$Rn),
4679 VectorIndexB:$idx)))), i8),
4680 (i64 (SMOVvi8to64 V128:$Rn, VectorIndexB:$idx))>;
4681 def : Pat<(sext_inreg (i64 (anyext (i32 (vector_extract (v8i16 V128:$Rn),
4682 VectorIndexH:$idx)))), i16),
4683 (i64 (SMOVvi16to64 V128:$Rn, VectorIndexH:$idx))>;
4685 // Extracting i8 or i16 elements will have the zero-extend transformed to
4686 // an 'and' mask by type legalization since neither i8 nor i16 are legal types
4687 // for AArch64. Match these patterns here since UMOV already zeroes out the high
4688 // bits of the destination register.
4689 def : Pat<(and (vector_extract (v16i8 V128:$Rn), VectorIndexB:$idx),
4691 (i32 (UMOVvi8 V128:$Rn, VectorIndexB:$idx))>;
4692 def : Pat<(and (vector_extract (v8i16 V128:$Rn), VectorIndexH:$idx),
4694 (i32 (UMOVvi16 V128:$Rn, VectorIndexH:$idx))>;
4698 def : Pat<(v16i8 (scalar_to_vector GPR32:$Rn)),
4699 (SUBREG_TO_REG (i32 0),
4700 (f32 (COPY_TO_REGCLASS GPR32:$Rn, FPR32)), ssub)>;
4701 def : Pat<(v8i8 (scalar_to_vector GPR32:$Rn)),
4702 (SUBREG_TO_REG (i32 0),
4703 (f32 (COPY_TO_REGCLASS GPR32:$Rn, FPR32)), ssub)>;
4705 def : Pat<(v8i16 (scalar_to_vector GPR32:$Rn)),
4706 (SUBREG_TO_REG (i32 0),
4707 (f32 (COPY_TO_REGCLASS GPR32:$Rn, FPR32)), ssub)>;
4708 def : Pat<(v4i16 (scalar_to_vector GPR32:$Rn)),
4709 (SUBREG_TO_REG (i32 0),
4710 (f32 (COPY_TO_REGCLASS GPR32:$Rn, FPR32)), ssub)>;
4712 def : Pat<(v4f16 (scalar_to_vector (f16 FPR16:$Rn))),
4713 (INSERT_SUBREG (v4f16 (IMPLICIT_DEF)), FPR16:$Rn, hsub)>;
4714 def : Pat<(v8f16 (scalar_to_vector (f16 FPR16:$Rn))),
4715 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR16:$Rn, hsub)>;
4717 def : Pat<(v2i32 (scalar_to_vector (i32 FPR32:$Rn))),
4718 (v2i32 (INSERT_SUBREG (v2i32 (IMPLICIT_DEF)),
4719 (i32 FPR32:$Rn), ssub))>;
4720 def : Pat<(v4i32 (scalar_to_vector (i32 FPR32:$Rn))),
4721 (v4i32 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)),
4722 (i32 FPR32:$Rn), ssub))>;
4724 def : Pat<(v2i64 (scalar_to_vector (i64 FPR64:$Rn))),
4725 (v2i64 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)),
4726 (i64 FPR64:$Rn), dsub))>;
4728 def : Pat<(v4f16 (scalar_to_vector (f16 FPR16:$Rn))),
4729 (INSERT_SUBREG (v4f16 (IMPLICIT_DEF)), FPR16:$Rn, hsub)>;
4730 def : Pat<(v8f16 (scalar_to_vector (f16 FPR16:$Rn))),
4731 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR16:$Rn, hsub)>;
4733 def : Pat<(v4f32 (scalar_to_vector (f32 FPR32:$Rn))),
4734 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FPR32:$Rn, ssub)>;
4735 def : Pat<(v2f32 (scalar_to_vector (f32 FPR32:$Rn))),
4736 (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), FPR32:$Rn, ssub)>;
4738 def : Pat<(v2f64 (scalar_to_vector (f64 FPR64:$Rn))),
4739 (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), FPR64:$Rn, dsub)>;
4741 def : Pat<(v4f16 (vector_insert (v4f16 V64:$Rn),
4742 (f16 FPR16:$Rm), (i64 VectorIndexS:$imm))),
4745 (v8f16 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), V64:$Rn, dsub)),
4747 (v8f16 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR16:$Rm, hsub)),
4751 def : Pat<(v8f16 (vector_insert (v8f16 V128:$Rn),
4752 (f16 FPR16:$Rm), (i64 VectorIndexH:$imm))),
4754 V128:$Rn, VectorIndexH:$imm,
4755 (v8f16 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR16:$Rm, hsub)),
4758 def : Pat<(v2f32 (vector_insert (v2f32 V64:$Rn),
4759 (f32 FPR32:$Rm), (i64 VectorIndexS:$imm))),
4762 (v4f32 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), V64:$Rn, dsub)),
4764 (v4f32 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FPR32:$Rm, ssub)),
4767 def : Pat<(v4f32 (vector_insert (v4f32 V128:$Rn),
4768 (f32 FPR32:$Rm), (i64 VectorIndexS:$imm))),
4770 V128:$Rn, VectorIndexS:$imm,
4771 (v4f32 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FPR32:$Rm, ssub)),
4773 def : Pat<(v2f64 (vector_insert (v2f64 V128:$Rn),
4774 (f64 FPR64:$Rm), (i64 VectorIndexD:$imm))),
4776 V128:$Rn, VectorIndexD:$imm,
4777 (v2f64 (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), FPR64:$Rm, dsub)),
4780 // Copy an element at a constant index in one vector into a constant indexed
4781 // element of another.
4782 // FIXME refactor to a shared class/dev parameterized on vector type, vector
4783 // index type and INS extension
4784 def : Pat<(v16i8 (int_aarch64_neon_vcopy_lane
4785 (v16i8 V128:$Vd), VectorIndexB:$idx, (v16i8 V128:$Vs),
4786 VectorIndexB:$idx2)),
4788 V128:$Vd, VectorIndexB:$idx, V128:$Vs, VectorIndexB:$idx2)
4790 def : Pat<(v8i16 (int_aarch64_neon_vcopy_lane
4791 (v8i16 V128:$Vd), VectorIndexH:$idx, (v8i16 V128:$Vs),
4792 VectorIndexH:$idx2)),
4794 V128:$Vd, VectorIndexH:$idx, V128:$Vs, VectorIndexH:$idx2)
4796 def : Pat<(v4i32 (int_aarch64_neon_vcopy_lane
4797 (v4i32 V128:$Vd), VectorIndexS:$idx, (v4i32 V128:$Vs),
4798 VectorIndexS:$idx2)),
4800 V128:$Vd, VectorIndexS:$idx, V128:$Vs, VectorIndexS:$idx2)
4802 def : Pat<(v2i64 (int_aarch64_neon_vcopy_lane
4803 (v2i64 V128:$Vd), VectorIndexD:$idx, (v2i64 V128:$Vs),
4804 VectorIndexD:$idx2)),
4806 V128:$Vd, VectorIndexD:$idx, V128:$Vs, VectorIndexD:$idx2)
4809 multiclass Neon_INS_elt_pattern<ValueType VT128, ValueType VT64,
4810 ValueType VTScal, Instruction INS> {
4811 def : Pat<(VT128 (vector_insert V128:$src,
4812 (VTScal (vector_extract (VT128 V128:$Rn), imm:$Immn)),
4814 (INS V128:$src, imm:$Immd, V128:$Rn, imm:$Immn)>;
4816 def : Pat<(VT128 (vector_insert V128:$src,
4817 (VTScal (vector_extract (VT64 V64:$Rn), imm:$Immn)),
4819 (INS V128:$src, imm:$Immd,
4820 (SUBREG_TO_REG (i64 0), V64:$Rn, dsub), imm:$Immn)>;
4822 def : Pat<(VT64 (vector_insert V64:$src,
4823 (VTScal (vector_extract (VT128 V128:$Rn), imm:$Immn)),
4825 (EXTRACT_SUBREG (INS (SUBREG_TO_REG (i64 0), V64:$src, dsub),
4826 imm:$Immd, V128:$Rn, imm:$Immn),
4829 def : Pat<(VT64 (vector_insert V64:$src,
4830 (VTScal (vector_extract (VT64 V64:$Rn), imm:$Immn)),
4833 (INS (SUBREG_TO_REG (i64 0), V64:$src, dsub), imm:$Immd,
4834 (SUBREG_TO_REG (i64 0), V64:$Rn, dsub), imm:$Immn),
4838 defm : Neon_INS_elt_pattern<v8f16, v4f16, f16, INSvi16lane>;
4839 defm : Neon_INS_elt_pattern<v4f32, v2f32, f32, INSvi32lane>;
4840 defm : Neon_INS_elt_pattern<v2f64, v1f64, f64, INSvi64lane>;
4843 // Floating point vector extractions are codegen'd as either a sequence of
4844 // subregister extractions, or a MOV (aka CPY here, alias for DUP) if
4845 // the lane number is anything other than zero.
4846 def : Pat<(vector_extract (v2f64 V128:$Rn), 0),
4847 (f64 (EXTRACT_SUBREG V128:$Rn, dsub))>;
4848 def : Pat<(vector_extract (v4f32 V128:$Rn), 0),
4849 (f32 (EXTRACT_SUBREG V128:$Rn, ssub))>;
4850 def : Pat<(vector_extract (v8f16 V128:$Rn), 0),
4851 (f16 (EXTRACT_SUBREG V128:$Rn, hsub))>;
4853 def : Pat<(vector_extract (v2f64 V128:$Rn), VectorIndexD:$idx),
4854 (f64 (CPYi64 V128:$Rn, VectorIndexD:$idx))>;
4855 def : Pat<(vector_extract (v4f32 V128:$Rn), VectorIndexS:$idx),
4856 (f32 (CPYi32 V128:$Rn, VectorIndexS:$idx))>;
4857 def : Pat<(vector_extract (v8f16 V128:$Rn), VectorIndexH:$idx),
4858 (f16 (CPYi16 V128:$Rn, VectorIndexH:$idx))>;
4860 // All concat_vectors operations are canonicalised to act on i64 vectors for
4861 // AArch64. In the general case we need an instruction, which had just as well be
4863 class ConcatPat<ValueType DstTy, ValueType SrcTy>
4864 : Pat<(DstTy (concat_vectors (SrcTy V64:$Rd), V64:$Rn)),
4865 (INSvi64lane (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), 1,
4866 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rn, dsub), 0)>;
4868 def : ConcatPat<v2i64, v1i64>;
4869 def : ConcatPat<v2f64, v1f64>;
4870 def : ConcatPat<v4i32, v2i32>;
4871 def : ConcatPat<v4f32, v2f32>;
4872 def : ConcatPat<v8i16, v4i16>;
4873 def : ConcatPat<v8f16, v4f16>;
4874 def : ConcatPat<v16i8, v8i8>;
4876 // If the high lanes are undef, though, we can just ignore them:
4877 class ConcatUndefPat<ValueType DstTy, ValueType SrcTy>
4878 : Pat<(DstTy (concat_vectors (SrcTy V64:$Rn), undef)),
4879 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rn, dsub)>;
4881 def : ConcatUndefPat<v2i64, v1i64>;
4882 def : ConcatUndefPat<v2f64, v1f64>;
4883 def : ConcatUndefPat<v4i32, v2i32>;
4884 def : ConcatUndefPat<v4f32, v2f32>;
4885 def : ConcatUndefPat<v8i16, v4i16>;
4886 def : ConcatUndefPat<v16i8, v8i8>;
4888 //----------------------------------------------------------------------------
4889 // AdvSIMD across lanes instructions
4890 //----------------------------------------------------------------------------
4892 defm ADDV : SIMDAcrossLanesBHS<0, 0b11011, "addv">;
4893 defm SMAXV : SIMDAcrossLanesBHS<0, 0b01010, "smaxv">;
4894 defm SMINV : SIMDAcrossLanesBHS<0, 0b11010, "sminv">;
4895 defm UMAXV : SIMDAcrossLanesBHS<1, 0b01010, "umaxv">;
4896 defm UMINV : SIMDAcrossLanesBHS<1, 0b11010, "uminv">;
4897 defm SADDLV : SIMDAcrossLanesHSD<0, 0b00011, "saddlv">;
4898 defm UADDLV : SIMDAcrossLanesHSD<1, 0b00011, "uaddlv">;
4899 defm FMAXNMV : SIMDFPAcrossLanes<0b01100, 0, "fmaxnmv", int_aarch64_neon_fmaxnmv>;
4900 defm FMAXV : SIMDFPAcrossLanes<0b01111, 0, "fmaxv", int_aarch64_neon_fmaxv>;
4901 defm FMINNMV : SIMDFPAcrossLanes<0b01100, 1, "fminnmv", int_aarch64_neon_fminnmv>;
4902 defm FMINV : SIMDFPAcrossLanes<0b01111, 1, "fminv", int_aarch64_neon_fminv>;
4904 // Patterns for across-vector intrinsics, that have a node equivalent, that
4905 // returns a vector (with only the low lane defined) instead of a scalar.
4906 // In effect, opNode is the same as (scalar_to_vector (IntNode)).
4907 multiclass SIMDAcrossLanesIntrinsic<string baseOpc,
4908 SDPatternOperator opNode> {
4909 // If a lane instruction caught the vector_extract around opNode, we can
4910 // directly match the latter to the instruction.
4911 def : Pat<(v8i8 (opNode V64:$Rn)),
4912 (INSERT_SUBREG (v8i8 (IMPLICIT_DEF)),
4913 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), bsub)>;
4914 def : Pat<(v16i8 (opNode V128:$Rn)),
4915 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4916 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), bsub)>;
4917 def : Pat<(v4i16 (opNode V64:$Rn)),
4918 (INSERT_SUBREG (v4i16 (IMPLICIT_DEF)),
4919 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), hsub)>;
4920 def : Pat<(v8i16 (opNode V128:$Rn)),
4921 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)),
4922 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), hsub)>;
4923 def : Pat<(v4i32 (opNode V128:$Rn)),
4924 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)),
4925 (!cast<Instruction>(!strconcat(baseOpc, "v4i32v")) V128:$Rn), ssub)>;
4928 // If none did, fallback to the explicit patterns, consuming the vector_extract.
4929 def : Pat<(i32 (vector_extract (insert_subvector undef, (v8i8 (opNode V64:$Rn)),
4930 (i32 0)), (i64 0))),
4931 (EXTRACT_SUBREG (INSERT_SUBREG (v8i8 (IMPLICIT_DEF)),
4932 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn),
4934 def : Pat<(i32 (vector_extract (v16i8 (opNode V128:$Rn)), (i64 0))),
4935 (EXTRACT_SUBREG (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4936 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn),
4938 def : Pat<(i32 (vector_extract (insert_subvector undef,
4939 (v4i16 (opNode V64:$Rn)), (i32 0)), (i64 0))),
4940 (EXTRACT_SUBREG (INSERT_SUBREG (v4i16 (IMPLICIT_DEF)),
4941 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn),
4943 def : Pat<(i32 (vector_extract (v8i16 (opNode V128:$Rn)), (i64 0))),
4944 (EXTRACT_SUBREG (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)),
4945 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn),
4947 def : Pat<(i32 (vector_extract (v4i32 (opNode V128:$Rn)), (i64 0))),
4948 (EXTRACT_SUBREG (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)),
4949 (!cast<Instruction>(!strconcat(baseOpc, "v4i32v")) V128:$Rn),
4954 multiclass SIMDAcrossLanesSignedIntrinsic<string baseOpc,
4955 SDPatternOperator opNode>
4956 : SIMDAcrossLanesIntrinsic<baseOpc, opNode> {
4957 // If there is a sign extension after this intrinsic, consume it as smov already
4959 def : Pat<(i32 (sext_inreg (i32 (vector_extract (insert_subvector undef,
4960 (opNode (v8i8 V64:$Rn)), (i32 0)), (i64 0))), i8)),
4962 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4963 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), bsub),
4965 def : Pat<(i32 (sext_inreg (i32 (vector_extract
4966 (opNode (v16i8 V128:$Rn)), (i64 0))), i8)),
4968 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4969 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), bsub),
4971 def : Pat<(i32 (sext_inreg (i32 (vector_extract (insert_subvector undef,
4972 (opNode (v4i16 V64:$Rn)), (i32 0)), (i64 0))), i16)),
4974 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4975 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), hsub),
4977 def : Pat<(i32 (sext_inreg (i32 (vector_extract
4978 (opNode (v8i16 V128:$Rn)), (i64 0))), i16)),
4980 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4981 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), hsub),
4985 multiclass SIMDAcrossLanesUnsignedIntrinsic<string baseOpc,
4986 SDPatternOperator opNode>
4987 : SIMDAcrossLanesIntrinsic<baseOpc, opNode> {
4988 // If there is a masking operation keeping only what has been actually
4989 // generated, consume it.
4990 def : Pat<(i32 (and (i32 (vector_extract (insert_subvector undef,
4991 (opNode (v8i8 V64:$Rn)), (i32 0)), (i64 0))), maski8_or_more)),
4992 (i32 (EXTRACT_SUBREG
4993 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4994 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), bsub),
4996 def : Pat<(i32 (and (i32 (vector_extract (opNode (v16i8 V128:$Rn)), (i64 0))),
4998 (i32 (EXTRACT_SUBREG
4999 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5000 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), bsub),
5002 def : Pat<(i32 (and (i32 (vector_extract (insert_subvector undef,
5003 (opNode (v4i16 V64:$Rn)), (i32 0)), (i64 0))), maski16_or_more)),
5004 (i32 (EXTRACT_SUBREG
5005 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5006 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), hsub),
5008 def : Pat<(i32 (and (i32 (vector_extract (opNode (v8i16 V128:$Rn)), (i64 0))),
5010 (i32 (EXTRACT_SUBREG
5011 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5012 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), hsub),
5016 defm : SIMDAcrossLanesSignedIntrinsic<"ADDV", AArch64saddv>;
5017 // vaddv_[su]32 is special; -> ADDP Vd.2S,Vn.2S,Vm.2S; return Vd.s[0];Vn==Vm
5018 def : Pat<(v2i32 (AArch64saddv (v2i32 V64:$Rn))),
5019 (ADDPv2i32 V64:$Rn, V64:$Rn)>;
5021 defm : SIMDAcrossLanesUnsignedIntrinsic<"ADDV", AArch64uaddv>;
5022 // vaddv_[su]32 is special; -> ADDP Vd.2S,Vn.2S,Vm.2S; return Vd.s[0];Vn==Vm
5023 def : Pat<(v2i32 (AArch64uaddv (v2i32 V64:$Rn))),
5024 (ADDPv2i32 V64:$Rn, V64:$Rn)>;
5026 defm : SIMDAcrossLanesSignedIntrinsic<"SMAXV", AArch64smaxv>;
5027 def : Pat<(v2i32 (AArch64smaxv (v2i32 V64:$Rn))),
5028 (SMAXPv2i32 V64:$Rn, V64:$Rn)>;
5030 defm : SIMDAcrossLanesSignedIntrinsic<"SMINV", AArch64sminv>;
5031 def : Pat<(v2i32 (AArch64sminv (v2i32 V64:$Rn))),
5032 (SMINPv2i32 V64:$Rn, V64:$Rn)>;
5034 defm : SIMDAcrossLanesUnsignedIntrinsic<"UMAXV", AArch64umaxv>;
5035 def : Pat<(v2i32 (AArch64umaxv (v2i32 V64:$Rn))),
5036 (UMAXPv2i32 V64:$Rn, V64:$Rn)>;
5038 defm : SIMDAcrossLanesUnsignedIntrinsic<"UMINV", AArch64uminv>;
5039 def : Pat<(v2i32 (AArch64uminv (v2i32 V64:$Rn))),
5040 (UMINPv2i32 V64:$Rn, V64:$Rn)>;
5042 multiclass SIMDAcrossLanesSignedLongIntrinsic<string baseOpc, Intrinsic intOp> {
5043 def : Pat<(i32 (intOp (v8i8 V64:$Rn))),
5045 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5046 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), hsub),
5048 def : Pat<(i32 (intOp (v16i8 V128:$Rn))),
5050 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5051 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), hsub),
5054 def : Pat<(i32 (intOp (v4i16 V64:$Rn))),
5055 (i32 (EXTRACT_SUBREG
5056 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5057 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), ssub),
5059 def : Pat<(i32 (intOp (v8i16 V128:$Rn))),
5060 (i32 (EXTRACT_SUBREG
5061 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5062 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), ssub),
5065 def : Pat<(i64 (intOp (v4i32 V128:$Rn))),
5066 (i64 (EXTRACT_SUBREG
5067 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5068 (!cast<Instruction>(!strconcat(baseOpc, "v4i32v")) V128:$Rn), dsub),
5072 multiclass SIMDAcrossLanesUnsignedLongIntrinsic<string baseOpc,
5074 def : Pat<(i32 (intOp (v8i8 V64:$Rn))),
5075 (i32 (EXTRACT_SUBREG
5076 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5077 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), hsub),
5079 def : Pat<(i32 (intOp (v16i8 V128:$Rn))),
5080 (i32 (EXTRACT_SUBREG
5081 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5082 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), hsub),
5085 def : Pat<(i32 (intOp (v4i16 V64:$Rn))),
5086 (i32 (EXTRACT_SUBREG
5087 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5088 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), ssub),
5090 def : Pat<(i32 (intOp (v8i16 V128:$Rn))),
5091 (i32 (EXTRACT_SUBREG
5092 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5093 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), ssub),
5096 def : Pat<(i64 (intOp (v4i32 V128:$Rn))),
5097 (i64 (EXTRACT_SUBREG
5098 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5099 (!cast<Instruction>(!strconcat(baseOpc, "v4i32v")) V128:$Rn), dsub),
5103 defm : SIMDAcrossLanesSignedLongIntrinsic<"SADDLV", int_aarch64_neon_saddlv>;
5104 defm : SIMDAcrossLanesUnsignedLongIntrinsic<"UADDLV", int_aarch64_neon_uaddlv>;
5106 // The vaddlv_s32 intrinsic gets mapped to SADDLP.
5107 def : Pat<(i64 (int_aarch64_neon_saddlv (v2i32 V64:$Rn))),
5108 (i64 (EXTRACT_SUBREG
5109 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5110 (SADDLPv2i32_v1i64 V64:$Rn), dsub),
5112 // The vaddlv_u32 intrinsic gets mapped to UADDLP.
5113 def : Pat<(i64 (int_aarch64_neon_uaddlv (v2i32 V64:$Rn))),
5114 (i64 (EXTRACT_SUBREG
5115 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5116 (UADDLPv2i32_v1i64 V64:$Rn), dsub),
5119 //------------------------------------------------------------------------------
5120 // AdvSIMD modified immediate instructions
5121 //------------------------------------------------------------------------------
5124 defm BIC : SIMDModifiedImmVectorShiftTied<1, 0b11, 0b01, "bic", AArch64bici>;
5126 defm ORR : SIMDModifiedImmVectorShiftTied<0, 0b11, 0b01, "orr", AArch64orri>;
5128 def : InstAlias<"bic $Vd.4h, $imm", (BICv4i16 V64:$Vd, imm0_255:$imm, 0)>;
5129 def : InstAlias<"bic $Vd.8h, $imm", (BICv8i16 V128:$Vd, imm0_255:$imm, 0)>;
5130 def : InstAlias<"bic $Vd.2s, $imm", (BICv2i32 V64:$Vd, imm0_255:$imm, 0)>;
5131 def : InstAlias<"bic $Vd.4s, $imm", (BICv4i32 V128:$Vd, imm0_255:$imm, 0)>;
5133 def : InstAlias<"bic.4h $Vd, $imm", (BICv4i16 V64:$Vd, imm0_255:$imm, 0)>;
5134 def : InstAlias<"bic.8h $Vd, $imm", (BICv8i16 V128:$Vd, imm0_255:$imm, 0)>;
5135 def : InstAlias<"bic.2s $Vd, $imm", (BICv2i32 V64:$Vd, imm0_255:$imm, 0)>;
5136 def : InstAlias<"bic.4s $Vd, $imm", (BICv4i32 V128:$Vd, imm0_255:$imm, 0)>;
5138 def : InstAlias<"orr $Vd.4h, $imm", (ORRv4i16 V64:$Vd, imm0_255:$imm, 0)>;
5139 def : InstAlias<"orr $Vd.8h, $imm", (ORRv8i16 V128:$Vd, imm0_255:$imm, 0)>;
5140 def : InstAlias<"orr $Vd.2s, $imm", (ORRv2i32 V64:$Vd, imm0_255:$imm, 0)>;
5141 def : InstAlias<"orr $Vd.4s, $imm", (ORRv4i32 V128:$Vd, imm0_255:$imm, 0)>;
5143 def : InstAlias<"orr.4h $Vd, $imm", (ORRv4i16 V64:$Vd, imm0_255:$imm, 0)>;
5144 def : InstAlias<"orr.8h $Vd, $imm", (ORRv8i16 V128:$Vd, imm0_255:$imm, 0)>;
5145 def : InstAlias<"orr.2s $Vd, $imm", (ORRv2i32 V64:$Vd, imm0_255:$imm, 0)>;
5146 def : InstAlias<"orr.4s $Vd, $imm", (ORRv4i32 V128:$Vd, imm0_255:$imm, 0)>;
5149 def FMOVv2f64_ns : SIMDModifiedImmVectorNoShift<1, 1, 0, 0b1111, V128, fpimm8,
5151 [(set (v2f64 V128:$Rd), (AArch64fmov imm0_255:$imm8))]>;
5152 def FMOVv2f32_ns : SIMDModifiedImmVectorNoShift<0, 0, 0, 0b1111, V64, fpimm8,
5154 [(set (v2f32 V64:$Rd), (AArch64fmov imm0_255:$imm8))]>;
5155 def FMOVv4f32_ns : SIMDModifiedImmVectorNoShift<1, 0, 0, 0b1111, V128, fpimm8,
5157 [(set (v4f32 V128:$Rd), (AArch64fmov imm0_255:$imm8))]>;
5158 let Predicates = [HasNEON, HasFullFP16] in {
5159 def FMOVv4f16_ns : SIMDModifiedImmVectorNoShift<0, 0, 1, 0b1111, V64, fpimm8,
5161 [(set (v4f16 V64:$Rd), (AArch64fmov imm0_255:$imm8))]>;
5162 def FMOVv8f16_ns : SIMDModifiedImmVectorNoShift<1, 0, 1, 0b1111, V128, fpimm8,
5164 [(set (v8f16 V128:$Rd), (AArch64fmov imm0_255:$imm8))]>;
5165 } // Predicates = [HasNEON, HasFullFP16]
5169 // EDIT byte mask: scalar
5170 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
5171 def MOVID : SIMDModifiedImmScalarNoShift<0, 1, 0b1110, "movi",
5172 [(set FPR64:$Rd, simdimmtype10:$imm8)]>;
5173 // The movi_edit node has the immediate value already encoded, so we use
5174 // a plain imm0_255 here.
5175 def : Pat<(f64 (AArch64movi_edit imm0_255:$shift)),
5176 (MOVID imm0_255:$shift)>;
5178 // EDIT byte mask: 2d
5180 // The movi_edit node has the immediate value already encoded, so we use
5181 // a plain imm0_255 in the pattern
5182 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
5183 def MOVIv2d_ns : SIMDModifiedImmVectorNoShift<1, 1, 0, 0b1110, V128,
5186 [(set (v2i64 V128:$Rd), (AArch64movi_edit imm0_255:$imm8))]>;
5188 def : Pat<(v2i64 immAllZerosV), (MOVIv2d_ns (i32 0))>;
5189 def : Pat<(v4i32 immAllZerosV), (MOVIv2d_ns (i32 0))>;
5190 def : Pat<(v8i16 immAllZerosV), (MOVIv2d_ns (i32 0))>;
5191 def : Pat<(v16i8 immAllZerosV), (MOVIv2d_ns (i32 0))>;
5193 def : Pat<(v2i64 immAllOnesV), (MOVIv2d_ns (i32 255))>;
5194 def : Pat<(v4i32 immAllOnesV), (MOVIv2d_ns (i32 255))>;
5195 def : Pat<(v8i16 immAllOnesV), (MOVIv2d_ns (i32 255))>;
5196 def : Pat<(v16i8 immAllOnesV), (MOVIv2d_ns (i32 255))>;
5198 // Set 64-bit vectors to all 0/1 by extracting from a 128-bit register as the
5199 // extract is free and this gives better MachineCSE results.
5200 def : Pat<(v1i64 immAllZerosV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 0)), dsub)>;
5201 def : Pat<(v2i32 immAllZerosV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 0)), dsub)>;
5202 def : Pat<(v4i16 immAllZerosV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 0)), dsub)>;
5203 def : Pat<(v8i8 immAllZerosV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 0)), dsub)>;
5205 def : Pat<(v1i64 immAllOnesV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 255)), dsub)>;
5206 def : Pat<(v2i32 immAllOnesV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 255)), dsub)>;
5207 def : Pat<(v4i16 immAllOnesV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 255)), dsub)>;
5208 def : Pat<(v8i8 immAllOnesV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 255)), dsub)>;
5210 // EDIT per word & halfword: 2s, 4h, 4s, & 8h
5211 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
5212 defm MOVI : SIMDModifiedImmVectorShift<0, 0b10, 0b00, "movi">;
5214 def : InstAlias<"movi $Vd.4h, $imm", (MOVIv4i16 V64:$Vd, imm0_255:$imm, 0), 0>;
5215 def : InstAlias<"movi $Vd.8h, $imm", (MOVIv8i16 V128:$Vd, imm0_255:$imm, 0), 0>;
5216 def : InstAlias<"movi $Vd.2s, $imm", (MOVIv2i32 V64:$Vd, imm0_255:$imm, 0), 0>;
5217 def : InstAlias<"movi $Vd.4s, $imm", (MOVIv4i32 V128:$Vd, imm0_255:$imm, 0), 0>;
5219 def : InstAlias<"movi.4h $Vd, $imm", (MOVIv4i16 V64:$Vd, imm0_255:$imm, 0), 0>;
5220 def : InstAlias<"movi.8h $Vd, $imm", (MOVIv8i16 V128:$Vd, imm0_255:$imm, 0), 0>;
5221 def : InstAlias<"movi.2s $Vd, $imm", (MOVIv2i32 V64:$Vd, imm0_255:$imm, 0), 0>;
5222 def : InstAlias<"movi.4s $Vd, $imm", (MOVIv4i32 V128:$Vd, imm0_255:$imm, 0), 0>;
5224 def : Pat<(v2i32 (AArch64movi_shift imm0_255:$imm8, (i32 imm:$shift))),
5225 (MOVIv2i32 imm0_255:$imm8, imm:$shift)>;
5226 def : Pat<(v4i32 (AArch64movi_shift imm0_255:$imm8, (i32 imm:$shift))),
5227 (MOVIv4i32 imm0_255:$imm8, imm:$shift)>;
5228 def : Pat<(v4i16 (AArch64movi_shift imm0_255:$imm8, (i32 imm:$shift))),
5229 (MOVIv4i16 imm0_255:$imm8, imm:$shift)>;
5230 def : Pat<(v8i16 (AArch64movi_shift imm0_255:$imm8, (i32 imm:$shift))),
5231 (MOVIv8i16 imm0_255:$imm8, imm:$shift)>;
5233 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
5234 // EDIT per word: 2s & 4s with MSL shifter
5235 def MOVIv2s_msl : SIMDModifiedImmMoveMSL<0, 0, {1,1,0,?}, V64, "movi", ".2s",
5236 [(set (v2i32 V64:$Rd),
5237 (AArch64movi_msl imm0_255:$imm8, (i32 imm:$shift)))]>;
5238 def MOVIv4s_msl : SIMDModifiedImmMoveMSL<1, 0, {1,1,0,?}, V128, "movi", ".4s",
5239 [(set (v4i32 V128:$Rd),
5240 (AArch64movi_msl imm0_255:$imm8, (i32 imm:$shift)))]>;
5242 // Per byte: 8b & 16b
5243 def MOVIv8b_ns : SIMDModifiedImmVectorNoShift<0, 0, 0, 0b1110, V64, imm0_255,
5245 [(set (v8i8 V64:$Rd), (AArch64movi imm0_255:$imm8))]>;
5247 def MOVIv16b_ns : SIMDModifiedImmVectorNoShift<1, 0, 0, 0b1110, V128, imm0_255,
5249 [(set (v16i8 V128:$Rd), (AArch64movi imm0_255:$imm8))]>;
5254 // EDIT per word & halfword: 2s, 4h, 4s, & 8h
5255 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
5256 defm MVNI : SIMDModifiedImmVectorShift<1, 0b10, 0b00, "mvni">;
5258 def : InstAlias<"mvni $Vd.4h, $imm", (MVNIv4i16 V64:$Vd, imm0_255:$imm, 0), 0>;
5259 def : InstAlias<"mvni $Vd.8h, $imm", (MVNIv8i16 V128:$Vd, imm0_255:$imm, 0), 0>;
5260 def : InstAlias<"mvni $Vd.2s, $imm", (MVNIv2i32 V64:$Vd, imm0_255:$imm, 0), 0>;
5261 def : InstAlias<"mvni $Vd.4s, $imm", (MVNIv4i32 V128:$Vd, imm0_255:$imm, 0), 0>;
5263 def : InstAlias<"mvni.4h $Vd, $imm", (MVNIv4i16 V64:$Vd, imm0_255:$imm, 0), 0>;
5264 def : InstAlias<"mvni.8h $Vd, $imm", (MVNIv8i16 V128:$Vd, imm0_255:$imm, 0), 0>;
5265 def : InstAlias<"mvni.2s $Vd, $imm", (MVNIv2i32 V64:$Vd, imm0_255:$imm, 0), 0>;
5266 def : InstAlias<"mvni.4s $Vd, $imm", (MVNIv4i32 V128:$Vd, imm0_255:$imm, 0), 0>;
5268 def : Pat<(v2i32 (AArch64mvni_shift imm0_255:$imm8, (i32 imm:$shift))),
5269 (MVNIv2i32 imm0_255:$imm8, imm:$shift)>;
5270 def : Pat<(v4i32 (AArch64mvni_shift imm0_255:$imm8, (i32 imm:$shift))),
5271 (MVNIv4i32 imm0_255:$imm8, imm:$shift)>;
5272 def : Pat<(v4i16 (AArch64mvni_shift imm0_255:$imm8, (i32 imm:$shift))),
5273 (MVNIv4i16 imm0_255:$imm8, imm:$shift)>;
5274 def : Pat<(v8i16 (AArch64mvni_shift imm0_255:$imm8, (i32 imm:$shift))),
5275 (MVNIv8i16 imm0_255:$imm8, imm:$shift)>;
5277 // EDIT per word: 2s & 4s with MSL shifter
5278 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
5279 def MVNIv2s_msl : SIMDModifiedImmMoveMSL<0, 1, {1,1,0,?}, V64, "mvni", ".2s",
5280 [(set (v2i32 V64:$Rd),
5281 (AArch64mvni_msl imm0_255:$imm8, (i32 imm:$shift)))]>;
5282 def MVNIv4s_msl : SIMDModifiedImmMoveMSL<1, 1, {1,1,0,?}, V128, "mvni", ".4s",
5283 [(set (v4i32 V128:$Rd),
5284 (AArch64mvni_msl imm0_255:$imm8, (i32 imm:$shift)))]>;
5287 //----------------------------------------------------------------------------
5288 // AdvSIMD indexed element
5289 //----------------------------------------------------------------------------
5291 let hasSideEffects = 0 in {
5292 defm FMLA : SIMDFPIndexedTied<0, 0b0001, "fmla">;
5293 defm FMLS : SIMDFPIndexedTied<0, 0b0101, "fmls">;
5296 // NOTE: Operands are reordered in the FMLA/FMLS PatFrags because the
5297 // instruction expects the addend first, while the intrinsic expects it last.
5299 // On the other hand, there are quite a few valid combinatorial options due to
5300 // the commutativity of multiplication and the fact that (-x) * y = x * (-y).
5301 defm : SIMDFPIndexedTiedPatterns<"FMLA",
5302 TriOpFrag<(fma node:$RHS, node:$MHS, node:$LHS)>>;
5303 defm : SIMDFPIndexedTiedPatterns<"FMLA",
5304 TriOpFrag<(fma node:$MHS, node:$RHS, node:$LHS)>>;
5306 defm : SIMDFPIndexedTiedPatterns<"FMLS",
5307 TriOpFrag<(fma node:$MHS, (fneg node:$RHS), node:$LHS)> >;
5308 defm : SIMDFPIndexedTiedPatterns<"FMLS",
5309 TriOpFrag<(fma node:$RHS, (fneg node:$MHS), node:$LHS)> >;
5310 defm : SIMDFPIndexedTiedPatterns<"FMLS",
5311 TriOpFrag<(fma (fneg node:$RHS), node:$MHS, node:$LHS)> >;
5312 defm : SIMDFPIndexedTiedPatterns<"FMLS",
5313 TriOpFrag<(fma (fneg node:$MHS), node:$RHS, node:$LHS)> >;
5315 multiclass FMLSIndexedAfterNegPatterns<SDPatternOperator OpNode> {
5316 // 3 variants for the .2s version: DUPLANE from 128-bit, DUPLANE from 64-bit
5318 def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn),
5319 (AArch64duplane32 (v4f32 (fneg V128:$Rm)),
5320 VectorIndexS:$idx))),
5321 (FMLSv2i32_indexed V64:$Rd, V64:$Rn, V128:$Rm, VectorIndexS:$idx)>;
5322 def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn),
5323 (v2f32 (AArch64duplane32
5324 (v4f32 (insert_subvector undef,
5325 (v2f32 (fneg V64:$Rm)),
5327 VectorIndexS:$idx)))),
5328 (FMLSv2i32_indexed V64:$Rd, V64:$Rn,
5329 (SUBREG_TO_REG (i32 0), V64:$Rm, dsub),
5330 VectorIndexS:$idx)>;
5331 def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn),
5332 (AArch64dup (f32 (fneg FPR32Op:$Rm))))),
5333 (FMLSv2i32_indexed V64:$Rd, V64:$Rn,
5334 (SUBREG_TO_REG (i32 0), FPR32Op:$Rm, ssub), (i64 0))>;
5336 // 3 variants for the .4s version: DUPLANE from 128-bit, DUPLANE from 64-bit
5338 def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn),
5339 (AArch64duplane32 (v4f32 (fneg V128:$Rm)),
5340 VectorIndexS:$idx))),
5341 (FMLSv4i32_indexed V128:$Rd, V128:$Rn, V128:$Rm,
5342 VectorIndexS:$idx)>;
5343 def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn),
5344 (v4f32 (AArch64duplane32
5345 (v4f32 (insert_subvector undef,
5346 (v2f32 (fneg V64:$Rm)),
5348 VectorIndexS:$idx)))),
5349 (FMLSv4i32_indexed V128:$Rd, V128:$Rn,
5350 (SUBREG_TO_REG (i32 0), V64:$Rm, dsub),
5351 VectorIndexS:$idx)>;
5352 def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn),
5353 (AArch64dup (f32 (fneg FPR32Op:$Rm))))),
5354 (FMLSv4i32_indexed V128:$Rd, V128:$Rn,
5355 (SUBREG_TO_REG (i32 0), FPR32Op:$Rm, ssub), (i64 0))>;
5357 // 2 variants for the .2d version: DUPLANE from 128-bit, and DUP scalar
5358 // (DUPLANE from 64-bit would be trivial).
5359 def : Pat<(v2f64 (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn),
5360 (AArch64duplane64 (v2f64 (fneg V128:$Rm)),
5361 VectorIndexD:$idx))),
5363 V128:$Rd, V128:$Rn, V128:$Rm, VectorIndexS:$idx)>;
5364 def : Pat<(v2f64 (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn),
5365 (AArch64dup (f64 (fneg FPR64Op:$Rm))))),
5366 (FMLSv2i64_indexed V128:$Rd, V128:$Rn,
5367 (SUBREG_TO_REG (i32 0), FPR64Op:$Rm, dsub), (i64 0))>;
5369 // 2 variants for 32-bit scalar version: extract from .2s or from .4s
5370 def : Pat<(f32 (OpNode (f32 FPR32:$Rd), (f32 FPR32:$Rn),
5371 (vector_extract (v4f32 (fneg V128:$Rm)),
5372 VectorIndexS:$idx))),
5373 (FMLSv1i32_indexed FPR32:$Rd, FPR32:$Rn,
5374 V128:$Rm, VectorIndexS:$idx)>;
5375 def : Pat<(f32 (OpNode (f32 FPR32:$Rd), (f32 FPR32:$Rn),
5376 (vector_extract (v4f32 (insert_subvector undef,
5377 (v2f32 (fneg V64:$Rm)),
5379 VectorIndexS:$idx))),
5380 (FMLSv1i32_indexed FPR32:$Rd, FPR32:$Rn,
5381 (SUBREG_TO_REG (i32 0), V64:$Rm, dsub), VectorIndexS:$idx)>;
5383 // 1 variant for 64-bit scalar version: extract from .1d or from .2d
5384 def : Pat<(f64 (OpNode (f64 FPR64:$Rd), (f64 FPR64:$Rn),
5385 (vector_extract (v2f64 (fneg V128:$Rm)),
5386 VectorIndexS:$idx))),
5387 (FMLSv1i64_indexed FPR64:$Rd, FPR64:$Rn,
5388 V128:$Rm, VectorIndexS:$idx)>;
5391 defm : FMLSIndexedAfterNegPatterns<
5392 TriOpFrag<(fma node:$RHS, node:$MHS, node:$LHS)> >;
5393 defm : FMLSIndexedAfterNegPatterns<
5394 TriOpFrag<(fma node:$MHS, node:$RHS, node:$LHS)> >;
5396 defm FMULX : SIMDFPIndexed<1, 0b1001, "fmulx", int_aarch64_neon_fmulx>;
5397 defm FMUL : SIMDFPIndexed<0, 0b1001, "fmul", fmul>;
5399 def : Pat<(v2f32 (fmul V64:$Rn, (AArch64dup (f32 FPR32:$Rm)))),
5400 (FMULv2i32_indexed V64:$Rn,
5401 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR32:$Rm, ssub),
5403 def : Pat<(v4f32 (fmul V128:$Rn, (AArch64dup (f32 FPR32:$Rm)))),
5404 (FMULv4i32_indexed V128:$Rn,
5405 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR32:$Rm, ssub),
5407 def : Pat<(v2f64 (fmul V128:$Rn, (AArch64dup (f64 FPR64:$Rm)))),
5408 (FMULv2i64_indexed V128:$Rn,
5409 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR64:$Rm, dsub),
5412 defm SQDMULH : SIMDIndexedHS<0, 0b1100, "sqdmulh", int_aarch64_neon_sqdmulh>;
5413 defm SQRDMULH : SIMDIndexedHS<0, 0b1101, "sqrdmulh", int_aarch64_neon_sqrdmulh>;
5414 defm MLA : SIMDVectorIndexedHSTied<1, 0b0000, "mla",
5415 TriOpFrag<(add node:$LHS, (mul node:$MHS, node:$RHS))>>;
5416 defm MLS : SIMDVectorIndexedHSTied<1, 0b0100, "mls",
5417 TriOpFrag<(sub node:$LHS, (mul node:$MHS, node:$RHS))>>;
5418 defm MUL : SIMDVectorIndexedHS<0, 0b1000, "mul", mul>;
5419 defm SMLAL : SIMDVectorIndexedLongSDTied<0, 0b0010, "smlal",
5420 TriOpFrag<(add node:$LHS, (int_aarch64_neon_smull node:$MHS, node:$RHS))>>;
5421 defm SMLSL : SIMDVectorIndexedLongSDTied<0, 0b0110, "smlsl",
5422 TriOpFrag<(sub node:$LHS, (int_aarch64_neon_smull node:$MHS, node:$RHS))>>;
5423 defm SMULL : SIMDVectorIndexedLongSD<0, 0b1010, "smull",
5424 int_aarch64_neon_smull>;
5425 defm SQDMLAL : SIMDIndexedLongSQDMLXSDTied<0, 0b0011, "sqdmlal",
5426 int_aarch64_neon_sqadd>;
5427 defm SQDMLSL : SIMDIndexedLongSQDMLXSDTied<0, 0b0111, "sqdmlsl",
5428 int_aarch64_neon_sqsub>;
5429 defm SQRDMLAH : SIMDIndexedSQRDMLxHSDTied<1, 0b1101, "sqrdmlah",
5430 int_aarch64_neon_sqadd>;
5431 defm SQRDMLSH : SIMDIndexedSQRDMLxHSDTied<1, 0b1111, "sqrdmlsh",
5432 int_aarch64_neon_sqsub>;
5433 defm SQDMULL : SIMDIndexedLongSD<0, 0b1011, "sqdmull", int_aarch64_neon_sqdmull>;
5434 defm UMLAL : SIMDVectorIndexedLongSDTied<1, 0b0010, "umlal",
5435 TriOpFrag<(add node:$LHS, (int_aarch64_neon_umull node:$MHS, node:$RHS))>>;
5436 defm UMLSL : SIMDVectorIndexedLongSDTied<1, 0b0110, "umlsl",
5437 TriOpFrag<(sub node:$LHS, (int_aarch64_neon_umull node:$MHS, node:$RHS))>>;
5438 defm UMULL : SIMDVectorIndexedLongSD<1, 0b1010, "umull",
5439 int_aarch64_neon_umull>;
5441 // A scalar sqdmull with the second operand being a vector lane can be
5442 // handled directly with the indexed instruction encoding.
5443 def : Pat<(int_aarch64_neon_sqdmulls_scalar (i32 FPR32:$Rn),
5444 (vector_extract (v4i32 V128:$Vm),
5445 VectorIndexS:$idx)),
5446 (SQDMULLv1i64_indexed FPR32:$Rn, V128:$Vm, VectorIndexS:$idx)>;
5448 //----------------------------------------------------------------------------
5449 // AdvSIMD scalar shift instructions
5450 //----------------------------------------------------------------------------
5451 defm FCVTZS : SIMDFPScalarRShift<0, 0b11111, "fcvtzs">;
5452 defm FCVTZU : SIMDFPScalarRShift<1, 0b11111, "fcvtzu">;
5453 defm SCVTF : SIMDFPScalarRShift<0, 0b11100, "scvtf">;
5454 defm UCVTF : SIMDFPScalarRShift<1, 0b11100, "ucvtf">;
5455 // Codegen patterns for the above. We don't put these directly on the
5456 // instructions because TableGen's type inference can't handle the truth.
5457 // Having the same base pattern for fp <--> int totally freaks it out.
5458 def : Pat<(int_aarch64_neon_vcvtfp2fxs FPR32:$Rn, vecshiftR32:$imm),
5459 (FCVTZSs FPR32:$Rn, vecshiftR32:$imm)>;
5460 def : Pat<(int_aarch64_neon_vcvtfp2fxu FPR32:$Rn, vecshiftR32:$imm),
5461 (FCVTZUs FPR32:$Rn, vecshiftR32:$imm)>;
5462 def : Pat<(i64 (int_aarch64_neon_vcvtfp2fxs (f64 FPR64:$Rn), vecshiftR64:$imm)),
5463 (FCVTZSd FPR64:$Rn, vecshiftR64:$imm)>;
5464 def : Pat<(i64 (int_aarch64_neon_vcvtfp2fxu (f64 FPR64:$Rn), vecshiftR64:$imm)),
5465 (FCVTZUd FPR64:$Rn, vecshiftR64:$imm)>;
5466 def : Pat<(v1i64 (int_aarch64_neon_vcvtfp2fxs (v1f64 FPR64:$Rn),
5468 (FCVTZSd FPR64:$Rn, vecshiftR64:$imm)>;
5469 def : Pat<(v1i64 (int_aarch64_neon_vcvtfp2fxu (v1f64 FPR64:$Rn),
5471 (FCVTZUd FPR64:$Rn, vecshiftR64:$imm)>;
5472 def : Pat<(int_aarch64_neon_vcvtfxu2fp FPR32:$Rn, vecshiftR32:$imm),
5473 (UCVTFs FPR32:$Rn, vecshiftR32:$imm)>;
5474 def : Pat<(f64 (int_aarch64_neon_vcvtfxu2fp (i64 FPR64:$Rn), vecshiftR64:$imm)),
5475 (UCVTFd FPR64:$Rn, vecshiftR64:$imm)>;
5476 def : Pat<(v1f64 (int_aarch64_neon_vcvtfxs2fp (v1i64 FPR64:$Rn),
5478 (SCVTFd FPR64:$Rn, vecshiftR64:$imm)>;
5479 def : Pat<(f64 (int_aarch64_neon_vcvtfxs2fp (i64 FPR64:$Rn), vecshiftR64:$imm)),
5480 (SCVTFd FPR64:$Rn, vecshiftR64:$imm)>;
5481 def : Pat<(v1f64 (int_aarch64_neon_vcvtfxu2fp (v1i64 FPR64:$Rn),
5483 (UCVTFd FPR64:$Rn, vecshiftR64:$imm)>;
5484 def : Pat<(int_aarch64_neon_vcvtfxs2fp FPR32:$Rn, vecshiftR32:$imm),
5485 (SCVTFs FPR32:$Rn, vecshiftR32:$imm)>;
5487 // Patterns for FP16 Instrinsics - requires reg copy to/from as i16s not supported.
5489 def : Pat<(f16 (int_aarch64_neon_vcvtfxs2fp (i32 (sext_inreg FPR32:$Rn, i16)), vecshiftR16:$imm)),
5490 (SCVTFh (EXTRACT_SUBREG FPR32:$Rn, hsub), vecshiftR16:$imm)>;
5491 def : Pat<(f16 (int_aarch64_neon_vcvtfxs2fp (i32 FPR32:$Rn), vecshiftR16:$imm)),
5492 (SCVTFh (EXTRACT_SUBREG FPR32:$Rn, hsub), vecshiftR16:$imm)>;
5493 def : Pat<(f16 (int_aarch64_neon_vcvtfxs2fp (i64 FPR64:$Rn), vecshiftR16:$imm)),
5494 (SCVTFh (EXTRACT_SUBREG FPR64:$Rn, hsub), vecshiftR16:$imm)>;
5495 def : Pat<(f16 (int_aarch64_neon_vcvtfxu2fp
5496 (and FPR32:$Rn, (i32 65535)),
5498 (UCVTFh (EXTRACT_SUBREG FPR32:$Rn, hsub), vecshiftR16:$imm)>;
5499 def : Pat<(f16 (int_aarch64_neon_vcvtfxu2fp FPR32:$Rn, vecshiftR16:$imm)),
5500 (UCVTFh (EXTRACT_SUBREG FPR32:$Rn, hsub), vecshiftR16:$imm)>;
5501 def : Pat<(f16 (int_aarch64_neon_vcvtfxu2fp (i64 FPR64:$Rn), vecshiftR16:$imm)),
5502 (UCVTFh (EXTRACT_SUBREG FPR64:$Rn, hsub), vecshiftR16:$imm)>;
5503 def : Pat<(i32 (int_aarch64_neon_vcvtfp2fxs (f16 FPR16:$Rn), vecshiftR32:$imm)),
5505 (i32 (IMPLICIT_DEF)),
5506 (FCVTZSh FPR16:$Rn, vecshiftR32:$imm),
5508 def : Pat<(i64 (int_aarch64_neon_vcvtfp2fxs (f16 FPR16:$Rn), vecshiftR64:$imm)),
5510 (i64 (IMPLICIT_DEF)),
5511 (FCVTZSh FPR16:$Rn, vecshiftR64:$imm),
5513 def : Pat<(i32 (int_aarch64_neon_vcvtfp2fxu (f16 FPR16:$Rn), vecshiftR32:$imm)),
5515 (i32 (IMPLICIT_DEF)),
5516 (FCVTZUh FPR16:$Rn, vecshiftR32:$imm),
5518 def : Pat<(i64 (int_aarch64_neon_vcvtfp2fxu (f16 FPR16:$Rn), vecshiftR64:$imm)),
5520 (i64 (IMPLICIT_DEF)),
5521 (FCVTZUh FPR16:$Rn, vecshiftR64:$imm),
5523 def : Pat<(i32 (int_aarch64_neon_facge (f16 FPR16:$Rn), (f16 FPR16:$Rm))),
5525 (i32 (IMPLICIT_DEF)),
5526 (FACGE16 FPR16:$Rn, FPR16:$Rm),
5528 def : Pat<(i32 (int_aarch64_neon_facgt (f16 FPR16:$Rn), (f16 FPR16:$Rm))),
5530 (i32 (IMPLICIT_DEF)),
5531 (FACGT16 FPR16:$Rn, FPR16:$Rm),
5534 defm SHL : SIMDScalarLShiftD< 0, 0b01010, "shl", AArch64vshl>;
5535 defm SLI : SIMDScalarLShiftDTied<1, 0b01010, "sli">;
5536 defm SQRSHRN : SIMDScalarRShiftBHS< 0, 0b10011, "sqrshrn",
5537 int_aarch64_neon_sqrshrn>;
5538 defm SQRSHRUN : SIMDScalarRShiftBHS< 1, 0b10001, "sqrshrun",
5539 int_aarch64_neon_sqrshrun>;
5540 defm SQSHLU : SIMDScalarLShiftBHSD<1, 0b01100, "sqshlu", AArch64sqshlui>;
5541 defm SQSHL : SIMDScalarLShiftBHSD<0, 0b01110, "sqshl", AArch64sqshli>;
5542 defm SQSHRN : SIMDScalarRShiftBHS< 0, 0b10010, "sqshrn",
5543 int_aarch64_neon_sqshrn>;
5544 defm SQSHRUN : SIMDScalarRShiftBHS< 1, 0b10000, "sqshrun",
5545 int_aarch64_neon_sqshrun>;
5546 defm SRI : SIMDScalarRShiftDTied< 1, 0b01000, "sri">;
5547 defm SRSHR : SIMDScalarRShiftD< 0, 0b00100, "srshr", AArch64srshri>;
5548 defm SRSRA : SIMDScalarRShiftDTied< 0, 0b00110, "srsra",
5549 TriOpFrag<(add node:$LHS,
5550 (AArch64srshri node:$MHS, node:$RHS))>>;
5551 defm SSHR : SIMDScalarRShiftD< 0, 0b00000, "sshr", AArch64vashr>;
5552 defm SSRA : SIMDScalarRShiftDTied< 0, 0b00010, "ssra",
5553 TriOpFrag<(add node:$LHS,
5554 (AArch64vashr node:$MHS, node:$RHS))>>;
5555 defm UQRSHRN : SIMDScalarRShiftBHS< 1, 0b10011, "uqrshrn",
5556 int_aarch64_neon_uqrshrn>;
5557 defm UQSHL : SIMDScalarLShiftBHSD<1, 0b01110, "uqshl", AArch64uqshli>;
5558 defm UQSHRN : SIMDScalarRShiftBHS< 1, 0b10010, "uqshrn",
5559 int_aarch64_neon_uqshrn>;
5560 defm URSHR : SIMDScalarRShiftD< 1, 0b00100, "urshr", AArch64urshri>;
5561 defm URSRA : SIMDScalarRShiftDTied< 1, 0b00110, "ursra",
5562 TriOpFrag<(add node:$LHS,
5563 (AArch64urshri node:$MHS, node:$RHS))>>;
5564 defm USHR : SIMDScalarRShiftD< 1, 0b00000, "ushr", AArch64vlshr>;
5565 defm USRA : SIMDScalarRShiftDTied< 1, 0b00010, "usra",
5566 TriOpFrag<(add node:$LHS,
5567 (AArch64vlshr node:$MHS, node:$RHS))>>;
5569 //----------------------------------------------------------------------------
5570 // AdvSIMD vector shift instructions
5571 //----------------------------------------------------------------------------
5572 defm FCVTZS:SIMDVectorRShiftSD<0, 0b11111, "fcvtzs", int_aarch64_neon_vcvtfp2fxs>;
5573 defm FCVTZU:SIMDVectorRShiftSD<1, 0b11111, "fcvtzu", int_aarch64_neon_vcvtfp2fxu>;
5574 defm SCVTF: SIMDVectorRShiftToFP<0, 0b11100, "scvtf",
5575 int_aarch64_neon_vcvtfxs2fp>;
5576 defm RSHRN : SIMDVectorRShiftNarrowBHS<0, 0b10001, "rshrn",
5577 int_aarch64_neon_rshrn>;
5578 defm SHL : SIMDVectorLShiftBHSD<0, 0b01010, "shl", AArch64vshl>;
5579 defm SHRN : SIMDVectorRShiftNarrowBHS<0, 0b10000, "shrn",
5580 BinOpFrag<(trunc (AArch64vashr node:$LHS, node:$RHS))>>;
5581 defm SLI : SIMDVectorLShiftBHSDTied<1, 0b01010, "sli", int_aarch64_neon_vsli>;
5582 def : Pat<(v1i64 (int_aarch64_neon_vsli (v1i64 FPR64:$Rd), (v1i64 FPR64:$Rn),
5583 (i32 vecshiftL64:$imm))),
5584 (SLId FPR64:$Rd, FPR64:$Rn, vecshiftL64:$imm)>;
5585 defm SQRSHRN : SIMDVectorRShiftNarrowBHS<0, 0b10011, "sqrshrn",
5586 int_aarch64_neon_sqrshrn>;
5587 defm SQRSHRUN: SIMDVectorRShiftNarrowBHS<1, 0b10001, "sqrshrun",
5588 int_aarch64_neon_sqrshrun>;
5589 defm SQSHLU : SIMDVectorLShiftBHSD<1, 0b01100, "sqshlu", AArch64sqshlui>;
5590 defm SQSHL : SIMDVectorLShiftBHSD<0, 0b01110, "sqshl", AArch64sqshli>;
5591 defm SQSHRN : SIMDVectorRShiftNarrowBHS<0, 0b10010, "sqshrn",
5592 int_aarch64_neon_sqshrn>;
5593 defm SQSHRUN : SIMDVectorRShiftNarrowBHS<1, 0b10000, "sqshrun",
5594 int_aarch64_neon_sqshrun>;
5595 defm SRI : SIMDVectorRShiftBHSDTied<1, 0b01000, "sri", int_aarch64_neon_vsri>;
5596 def : Pat<(v1i64 (int_aarch64_neon_vsri (v1i64 FPR64:$Rd), (v1i64 FPR64:$Rn),
5597 (i32 vecshiftR64:$imm))),
5598 (SRId FPR64:$Rd, FPR64:$Rn, vecshiftR64:$imm)>;
5599 defm SRSHR : SIMDVectorRShiftBHSD<0, 0b00100, "srshr", AArch64srshri>;
5600 defm SRSRA : SIMDVectorRShiftBHSDTied<0, 0b00110, "srsra",
5601 TriOpFrag<(add node:$LHS,
5602 (AArch64srshri node:$MHS, node:$RHS))> >;
5603 defm SSHLL : SIMDVectorLShiftLongBHSD<0, 0b10100, "sshll",
5604 BinOpFrag<(AArch64vshl (sext node:$LHS), node:$RHS)>>;
5606 defm SSHR : SIMDVectorRShiftBHSD<0, 0b00000, "sshr", AArch64vashr>;
5607 defm SSRA : SIMDVectorRShiftBHSDTied<0, 0b00010, "ssra",
5608 TriOpFrag<(add node:$LHS, (AArch64vashr node:$MHS, node:$RHS))>>;
5609 defm UCVTF : SIMDVectorRShiftToFP<1, 0b11100, "ucvtf",
5610 int_aarch64_neon_vcvtfxu2fp>;
5611 defm UQRSHRN : SIMDVectorRShiftNarrowBHS<1, 0b10011, "uqrshrn",
5612 int_aarch64_neon_uqrshrn>;
5613 defm UQSHL : SIMDVectorLShiftBHSD<1, 0b01110, "uqshl", AArch64uqshli>;
5614 defm UQSHRN : SIMDVectorRShiftNarrowBHS<1, 0b10010, "uqshrn",
5615 int_aarch64_neon_uqshrn>;
5616 defm URSHR : SIMDVectorRShiftBHSD<1, 0b00100, "urshr", AArch64urshri>;
5617 defm URSRA : SIMDVectorRShiftBHSDTied<1, 0b00110, "ursra",
5618 TriOpFrag<(add node:$LHS,
5619 (AArch64urshri node:$MHS, node:$RHS))> >;
5620 defm USHLL : SIMDVectorLShiftLongBHSD<1, 0b10100, "ushll",
5621 BinOpFrag<(AArch64vshl (zext node:$LHS), node:$RHS)>>;
5622 defm USHR : SIMDVectorRShiftBHSD<1, 0b00000, "ushr", AArch64vlshr>;
5623 defm USRA : SIMDVectorRShiftBHSDTied<1, 0b00010, "usra",
5624 TriOpFrag<(add node:$LHS, (AArch64vlshr node:$MHS, node:$RHS))> >;
5626 // SHRN patterns for when a logical right shift was used instead of arithmetic
5627 // (the immediate guarantees no sign bits actually end up in the result so it
5629 def : Pat<(v8i8 (trunc (AArch64vlshr (v8i16 V128:$Rn), vecshiftR16Narrow:$imm))),
5630 (SHRNv8i8_shift V128:$Rn, vecshiftR16Narrow:$imm)>;
5631 def : Pat<(v4i16 (trunc (AArch64vlshr (v4i32 V128:$Rn), vecshiftR32Narrow:$imm))),
5632 (SHRNv4i16_shift V128:$Rn, vecshiftR32Narrow:$imm)>;
5633 def : Pat<(v2i32 (trunc (AArch64vlshr (v2i64 V128:$Rn), vecshiftR64Narrow:$imm))),
5634 (SHRNv2i32_shift V128:$Rn, vecshiftR64Narrow:$imm)>;
5636 def : Pat<(v16i8 (concat_vectors (v8i8 V64:$Rd),
5637 (trunc (AArch64vlshr (v8i16 V128:$Rn),
5638 vecshiftR16Narrow:$imm)))),
5639 (SHRNv16i8_shift (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
5640 V128:$Rn, vecshiftR16Narrow:$imm)>;
5641 def : Pat<(v8i16 (concat_vectors (v4i16 V64:$Rd),
5642 (trunc (AArch64vlshr (v4i32 V128:$Rn),
5643 vecshiftR32Narrow:$imm)))),
5644 (SHRNv8i16_shift (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
5645 V128:$Rn, vecshiftR32Narrow:$imm)>;
5646 def : Pat<(v4i32 (concat_vectors (v2i32 V64:$Rd),
5647 (trunc (AArch64vlshr (v2i64 V128:$Rn),
5648 vecshiftR64Narrow:$imm)))),
5649 (SHRNv4i32_shift (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
5650 V128:$Rn, vecshiftR32Narrow:$imm)>;
5652 // Vector sign and zero extensions are implemented with SSHLL and USSHLL.
5653 // Anyexts are implemented as zexts.
5654 def : Pat<(v8i16 (sext (v8i8 V64:$Rn))), (SSHLLv8i8_shift V64:$Rn, (i32 0))>;
5655 def : Pat<(v8i16 (zext (v8i8 V64:$Rn))), (USHLLv8i8_shift V64:$Rn, (i32 0))>;
5656 def : Pat<(v8i16 (anyext (v8i8 V64:$Rn))), (USHLLv8i8_shift V64:$Rn, (i32 0))>;
5657 def : Pat<(v4i32 (sext (v4i16 V64:$Rn))), (SSHLLv4i16_shift V64:$Rn, (i32 0))>;
5658 def : Pat<(v4i32 (zext (v4i16 V64:$Rn))), (USHLLv4i16_shift V64:$Rn, (i32 0))>;
5659 def : Pat<(v4i32 (anyext (v4i16 V64:$Rn))), (USHLLv4i16_shift V64:$Rn, (i32 0))>;
5660 def : Pat<(v2i64 (sext (v2i32 V64:$Rn))), (SSHLLv2i32_shift V64:$Rn, (i32 0))>;
5661 def : Pat<(v2i64 (zext (v2i32 V64:$Rn))), (USHLLv2i32_shift V64:$Rn, (i32 0))>;
5662 def : Pat<(v2i64 (anyext (v2i32 V64:$Rn))), (USHLLv2i32_shift V64:$Rn, (i32 0))>;
5663 // Also match an extend from the upper half of a 128 bit source register.
5664 def : Pat<(v8i16 (anyext (v8i8 (extract_subvector V128:$Rn, (i64 8)) ))),
5665 (USHLLv16i8_shift V128:$Rn, (i32 0))>;
5666 def : Pat<(v8i16 (zext (v8i8 (extract_subvector V128:$Rn, (i64 8)) ))),
5667 (USHLLv16i8_shift V128:$Rn, (i32 0))>;
5668 def : Pat<(v8i16 (sext (v8i8 (extract_subvector V128:$Rn, (i64 8)) ))),
5669 (SSHLLv16i8_shift V128:$Rn, (i32 0))>;
5670 def : Pat<(v4i32 (anyext (v4i16 (extract_subvector V128:$Rn, (i64 4)) ))),
5671 (USHLLv8i16_shift V128:$Rn, (i32 0))>;
5672 def : Pat<(v4i32 (zext (v4i16 (extract_subvector V128:$Rn, (i64 4)) ))),
5673 (USHLLv8i16_shift V128:$Rn, (i32 0))>;
5674 def : Pat<(v4i32 (sext (v4i16 (extract_subvector V128:$Rn, (i64 4)) ))),
5675 (SSHLLv8i16_shift V128:$Rn, (i32 0))>;
5676 def : Pat<(v2i64 (anyext (v2i32 (extract_subvector V128:$Rn, (i64 2)) ))),
5677 (USHLLv4i32_shift V128:$Rn, (i32 0))>;
5678 def : Pat<(v2i64 (zext (v2i32 (extract_subvector V128:$Rn, (i64 2)) ))),
5679 (USHLLv4i32_shift V128:$Rn, (i32 0))>;
5680 def : Pat<(v2i64 (sext (v2i32 (extract_subvector V128:$Rn, (i64 2)) ))),
5681 (SSHLLv4i32_shift V128:$Rn, (i32 0))>;
5683 // Vector shift sxtl aliases
5684 def : InstAlias<"sxtl.8h $dst, $src1",
5685 (SSHLLv8i8_shift V128:$dst, V64:$src1, 0)>;
5686 def : InstAlias<"sxtl $dst.8h, $src1.8b",
5687 (SSHLLv8i8_shift V128:$dst, V64:$src1, 0)>;
5688 def : InstAlias<"sxtl.4s $dst, $src1",
5689 (SSHLLv4i16_shift V128:$dst, V64:$src1, 0)>;
5690 def : InstAlias<"sxtl $dst.4s, $src1.4h",
5691 (SSHLLv4i16_shift V128:$dst, V64:$src1, 0)>;
5692 def : InstAlias<"sxtl.2d $dst, $src1",
5693 (SSHLLv2i32_shift V128:$dst, V64:$src1, 0)>;
5694 def : InstAlias<"sxtl $dst.2d, $src1.2s",
5695 (SSHLLv2i32_shift V128:$dst, V64:$src1, 0)>;
5697 // Vector shift sxtl2 aliases
5698 def : InstAlias<"sxtl2.8h $dst, $src1",
5699 (SSHLLv16i8_shift V128:$dst, V128:$src1, 0)>;
5700 def : InstAlias<"sxtl2 $dst.8h, $src1.16b",
5701 (SSHLLv16i8_shift V128:$dst, V128:$src1, 0)>;
5702 def : InstAlias<"sxtl2.4s $dst, $src1",
5703 (SSHLLv8i16_shift V128:$dst, V128:$src1, 0)>;
5704 def : InstAlias<"sxtl2 $dst.4s, $src1.8h",
5705 (SSHLLv8i16_shift V128:$dst, V128:$src1, 0)>;
5706 def : InstAlias<"sxtl2.2d $dst, $src1",
5707 (SSHLLv4i32_shift V128:$dst, V128:$src1, 0)>;
5708 def : InstAlias<"sxtl2 $dst.2d, $src1.4s",
5709 (SSHLLv4i32_shift V128:$dst, V128:$src1, 0)>;
5711 // Vector shift uxtl aliases
5712 def : InstAlias<"uxtl.8h $dst, $src1",
5713 (USHLLv8i8_shift V128:$dst, V64:$src1, 0)>;
5714 def : InstAlias<"uxtl $dst.8h, $src1.8b",
5715 (USHLLv8i8_shift V128:$dst, V64:$src1, 0)>;
5716 def : InstAlias<"uxtl.4s $dst, $src1",
5717 (USHLLv4i16_shift V128:$dst, V64:$src1, 0)>;
5718 def : InstAlias<"uxtl $dst.4s, $src1.4h",
5719 (USHLLv4i16_shift V128:$dst, V64:$src1, 0)>;
5720 def : InstAlias<"uxtl.2d $dst, $src1",
5721 (USHLLv2i32_shift V128:$dst, V64:$src1, 0)>;
5722 def : InstAlias<"uxtl $dst.2d, $src1.2s",
5723 (USHLLv2i32_shift V128:$dst, V64:$src1, 0)>;
5725 // Vector shift uxtl2 aliases
5726 def : InstAlias<"uxtl2.8h $dst, $src1",
5727 (USHLLv16i8_shift V128:$dst, V128:$src1, 0)>;
5728 def : InstAlias<"uxtl2 $dst.8h, $src1.16b",
5729 (USHLLv16i8_shift V128:$dst, V128:$src1, 0)>;
5730 def : InstAlias<"uxtl2.4s $dst, $src1",
5731 (USHLLv8i16_shift V128:$dst, V128:$src1, 0)>;
5732 def : InstAlias<"uxtl2 $dst.4s, $src1.8h",
5733 (USHLLv8i16_shift V128:$dst, V128:$src1, 0)>;
5734 def : InstAlias<"uxtl2.2d $dst, $src1",
5735 (USHLLv4i32_shift V128:$dst, V128:$src1, 0)>;
5736 def : InstAlias<"uxtl2 $dst.2d, $src1.4s",
5737 (USHLLv4i32_shift V128:$dst, V128:$src1, 0)>;
5739 // If an integer is about to be converted to a floating point value,
5740 // just load it on the floating point unit.
5741 // These patterns are more complex because floating point loads do not
5742 // support sign extension.
5743 // The sign extension has to be explicitly added and is only supported for
5744 // one step: byte-to-half, half-to-word, word-to-doubleword.
5745 // SCVTF GPR -> FPR is 9 cycles.
5746 // SCVTF FPR -> FPR is 4 cyclces.
5747 // (sign extension with lengthen) SXTL FPR -> FPR is 2 cycles.
5748 // Therefore, we can do 2 sign extensions and one SCVTF FPR -> FPR
5749 // and still being faster.
5750 // However, this is not good for code size.
5751 // 8-bits -> float. 2 sizes step-up.
5752 class SExtLoadi8CVTf32Pat<dag addrmode, dag INST>
5753 : Pat<(f32 (sint_to_fp (i32 (sextloadi8 addrmode)))),
5754 (SCVTFv1i32 (f32 (EXTRACT_SUBREG
5759 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
5766 Requires<[NotForCodeSize, UseAlternateSExtLoadCVTF32]>;
5768 def : SExtLoadi8CVTf32Pat<(ro8.Wpat GPR64sp:$Rn, GPR32:$Rm, ro8.Wext:$ext),
5769 (LDRBroW GPR64sp:$Rn, GPR32:$Rm, ro8.Wext:$ext)>;
5770 def : SExtLoadi8CVTf32Pat<(ro8.Xpat GPR64sp:$Rn, GPR64:$Rm, ro8.Xext:$ext),
5771 (LDRBroX GPR64sp:$Rn, GPR64:$Rm, ro8.Xext:$ext)>;
5772 def : SExtLoadi8CVTf32Pat<(am_indexed8 GPR64sp:$Rn, uimm12s1:$offset),
5773 (LDRBui GPR64sp:$Rn, uimm12s1:$offset)>;
5774 def : SExtLoadi8CVTf32Pat<(am_unscaled8 GPR64sp:$Rn, simm9:$offset),
5775 (LDURBi GPR64sp:$Rn, simm9:$offset)>;
5777 // 16-bits -> float. 1 size step-up.
5778 class SExtLoadi16CVTf32Pat<dag addrmode, dag INST>
5779 : Pat<(f32 (sint_to_fp (i32 (sextloadi16 addrmode)))),
5780 (SCVTFv1i32 (f32 (EXTRACT_SUBREG
5782 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
5786 ssub)))>, Requires<[NotForCodeSize]>;
5788 def : SExtLoadi16CVTf32Pat<(ro16.Wpat GPR64sp:$Rn, GPR32:$Rm, ro16.Wext:$ext),
5789 (LDRHroW GPR64sp:$Rn, GPR32:$Rm, ro16.Wext:$ext)>;
5790 def : SExtLoadi16CVTf32Pat<(ro16.Xpat GPR64sp:$Rn, GPR64:$Rm, ro16.Xext:$ext),
5791 (LDRHroX GPR64sp:$Rn, GPR64:$Rm, ro16.Xext:$ext)>;
5792 def : SExtLoadi16CVTf32Pat<(am_indexed16 GPR64sp:$Rn, uimm12s2:$offset),
5793 (LDRHui GPR64sp:$Rn, uimm12s2:$offset)>;
5794 def : SExtLoadi16CVTf32Pat<(am_unscaled16 GPR64sp:$Rn, simm9:$offset),
5795 (LDURHi GPR64sp:$Rn, simm9:$offset)>;
5797 // 32-bits to 32-bits are handled in target specific dag combine:
5798 // performIntToFpCombine.
5799 // 64-bits integer to 32-bits floating point, not possible with
5800 // SCVTF on floating point registers (both source and destination
5801 // must have the same size).
5803 // Here are the patterns for 8, 16, 32, and 64-bits to double.
5804 // 8-bits -> double. 3 size step-up: give up.
5805 // 16-bits -> double. 2 size step.
5806 class SExtLoadi16CVTf64Pat<dag addrmode, dag INST>
5807 : Pat <(f64 (sint_to_fp (i32 (sextloadi16 addrmode)))),
5808 (SCVTFv1i64 (f64 (EXTRACT_SUBREG
5813 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
5820 Requires<[NotForCodeSize, UseAlternateSExtLoadCVTF32]>;
5822 def : SExtLoadi16CVTf64Pat<(ro16.Wpat GPR64sp:$Rn, GPR32:$Rm, ro16.Wext:$ext),
5823 (LDRHroW GPR64sp:$Rn, GPR32:$Rm, ro16.Wext:$ext)>;
5824 def : SExtLoadi16CVTf64Pat<(ro16.Xpat GPR64sp:$Rn, GPR64:$Rm, ro16.Xext:$ext),
5825 (LDRHroX GPR64sp:$Rn, GPR64:$Rm, ro16.Xext:$ext)>;
5826 def : SExtLoadi16CVTf64Pat<(am_indexed16 GPR64sp:$Rn, uimm12s2:$offset),
5827 (LDRHui GPR64sp:$Rn, uimm12s2:$offset)>;
5828 def : SExtLoadi16CVTf64Pat<(am_unscaled16 GPR64sp:$Rn, simm9:$offset),
5829 (LDURHi GPR64sp:$Rn, simm9:$offset)>;
5830 // 32-bits -> double. 1 size step-up.
5831 class SExtLoadi32CVTf64Pat<dag addrmode, dag INST>
5832 : Pat <(f64 (sint_to_fp (i32 (load addrmode)))),
5833 (SCVTFv1i64 (f64 (EXTRACT_SUBREG
5835 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
5839 dsub)))>, Requires<[NotForCodeSize]>;
5841 def : SExtLoadi32CVTf64Pat<(ro32.Wpat GPR64sp:$Rn, GPR32:$Rm, ro32.Wext:$ext),
5842 (LDRSroW GPR64sp:$Rn, GPR32:$Rm, ro32.Wext:$ext)>;
5843 def : SExtLoadi32CVTf64Pat<(ro32.Xpat GPR64sp:$Rn, GPR64:$Rm, ro32.Xext:$ext),
5844 (LDRSroX GPR64sp:$Rn, GPR64:$Rm, ro32.Xext:$ext)>;
5845 def : SExtLoadi32CVTf64Pat<(am_indexed32 GPR64sp:$Rn, uimm12s4:$offset),
5846 (LDRSui GPR64sp:$Rn, uimm12s4:$offset)>;
5847 def : SExtLoadi32CVTf64Pat<(am_unscaled32 GPR64sp:$Rn, simm9:$offset),
5848 (LDURSi GPR64sp:$Rn, simm9:$offset)>;
5850 // 64-bits -> double are handled in target specific dag combine:
5851 // performIntToFpCombine.
5854 //----------------------------------------------------------------------------
5855 // AdvSIMD Load-Store Structure
5856 //----------------------------------------------------------------------------
5857 defm LD1 : SIMDLd1Multiple<"ld1">;
5858 defm LD2 : SIMDLd2Multiple<"ld2">;
5859 defm LD3 : SIMDLd3Multiple<"ld3">;
5860 defm LD4 : SIMDLd4Multiple<"ld4">;
5862 defm ST1 : SIMDSt1Multiple<"st1">;
5863 defm ST2 : SIMDSt2Multiple<"st2">;
5864 defm ST3 : SIMDSt3Multiple<"st3">;
5865 defm ST4 : SIMDSt4Multiple<"st4">;
5867 class Ld1Pat<ValueType ty, Instruction INST>
5868 : Pat<(ty (load GPR64sp:$Rn)), (INST GPR64sp:$Rn)>;
5870 def : Ld1Pat<v16i8, LD1Onev16b>;
5871 def : Ld1Pat<v8i16, LD1Onev8h>;
5872 def : Ld1Pat<v4i32, LD1Onev4s>;
5873 def : Ld1Pat<v2i64, LD1Onev2d>;
5874 def : Ld1Pat<v8i8, LD1Onev8b>;
5875 def : Ld1Pat<v4i16, LD1Onev4h>;
5876 def : Ld1Pat<v2i32, LD1Onev2s>;
5877 def : Ld1Pat<v1i64, LD1Onev1d>;
5879 class St1Pat<ValueType ty, Instruction INST>
5880 : Pat<(store ty:$Vt, GPR64sp:$Rn),
5881 (INST ty:$Vt, GPR64sp:$Rn)>;
5883 def : St1Pat<v16i8, ST1Onev16b>;
5884 def : St1Pat<v8i16, ST1Onev8h>;
5885 def : St1Pat<v4i32, ST1Onev4s>;
5886 def : St1Pat<v2i64, ST1Onev2d>;
5887 def : St1Pat<v8i8, ST1Onev8b>;
5888 def : St1Pat<v4i16, ST1Onev4h>;
5889 def : St1Pat<v2i32, ST1Onev2s>;
5890 def : St1Pat<v1i64, ST1Onev1d>;
5896 defm LD1R : SIMDLdR<0, 0b110, 0, "ld1r", "One", 1, 2, 4, 8>;
5897 defm LD2R : SIMDLdR<1, 0b110, 0, "ld2r", "Two", 2, 4, 8, 16>;
5898 defm LD3R : SIMDLdR<0, 0b111, 0, "ld3r", "Three", 3, 6, 12, 24>;
5899 defm LD4R : SIMDLdR<1, 0b111, 0, "ld4r", "Four", 4, 8, 16, 32>;
5900 let mayLoad = 1, hasSideEffects = 0 in {
5901 defm LD1 : SIMDLdSingleBTied<0, 0b000, "ld1", VecListOneb, GPR64pi1>;
5902 defm LD1 : SIMDLdSingleHTied<0, 0b010, 0, "ld1", VecListOneh, GPR64pi2>;
5903 defm LD1 : SIMDLdSingleSTied<0, 0b100, 0b00, "ld1", VecListOnes, GPR64pi4>;
5904 defm LD1 : SIMDLdSingleDTied<0, 0b100, 0b01, "ld1", VecListOned, GPR64pi8>;
5905 defm LD2 : SIMDLdSingleBTied<1, 0b000, "ld2", VecListTwob, GPR64pi2>;
5906 defm LD2 : SIMDLdSingleHTied<1, 0b010, 0, "ld2", VecListTwoh, GPR64pi4>;
5907 defm LD2 : SIMDLdSingleSTied<1, 0b100, 0b00, "ld2", VecListTwos, GPR64pi8>;
5908 defm LD2 : SIMDLdSingleDTied<1, 0b100, 0b01, "ld2", VecListTwod, GPR64pi16>;
5909 defm LD3 : SIMDLdSingleBTied<0, 0b001, "ld3", VecListThreeb, GPR64pi3>;
5910 defm LD3 : SIMDLdSingleHTied<0, 0b011, 0, "ld3", VecListThreeh, GPR64pi6>;
5911 defm LD3 : SIMDLdSingleSTied<0, 0b101, 0b00, "ld3", VecListThrees, GPR64pi12>;
5912 defm LD3 : SIMDLdSingleDTied<0, 0b101, 0b01, "ld3", VecListThreed, GPR64pi24>;
5913 defm LD4 : SIMDLdSingleBTied<1, 0b001, "ld4", VecListFourb, GPR64pi4>;
5914 defm LD4 : SIMDLdSingleHTied<1, 0b011, 0, "ld4", VecListFourh, GPR64pi8>;
5915 defm LD4 : SIMDLdSingleSTied<1, 0b101, 0b00, "ld4", VecListFours, GPR64pi16>;
5916 defm LD4 : SIMDLdSingleDTied<1, 0b101, 0b01, "ld4", VecListFourd, GPR64pi32>;
5919 def : Pat<(v8i8 (AArch64dup (i32 (extloadi8 GPR64sp:$Rn)))),
5920 (LD1Rv8b GPR64sp:$Rn)>;
5921 def : Pat<(v16i8 (AArch64dup (i32 (extloadi8 GPR64sp:$Rn)))),
5922 (LD1Rv16b GPR64sp:$Rn)>;
5923 def : Pat<(v4i16 (AArch64dup (i32 (extloadi16 GPR64sp:$Rn)))),
5924 (LD1Rv4h GPR64sp:$Rn)>;
5925 def : Pat<(v8i16 (AArch64dup (i32 (extloadi16 GPR64sp:$Rn)))),
5926 (LD1Rv8h GPR64sp:$Rn)>;
5927 def : Pat<(v2i32 (AArch64dup (i32 (load GPR64sp:$Rn)))),
5928 (LD1Rv2s GPR64sp:$Rn)>;
5929 def : Pat<(v4i32 (AArch64dup (i32 (load GPR64sp:$Rn)))),
5930 (LD1Rv4s GPR64sp:$Rn)>;
5931 def : Pat<(v2i64 (AArch64dup (i64 (load GPR64sp:$Rn)))),
5932 (LD1Rv2d GPR64sp:$Rn)>;
5933 def : Pat<(v1i64 (AArch64dup (i64 (load GPR64sp:$Rn)))),
5934 (LD1Rv1d GPR64sp:$Rn)>;
5935 // Grab the floating point version too
5936 def : Pat<(v2f32 (AArch64dup (f32 (load GPR64sp:$Rn)))),
5937 (LD1Rv2s GPR64sp:$Rn)>;
5938 def : Pat<(v4f32 (AArch64dup (f32 (load GPR64sp:$Rn)))),
5939 (LD1Rv4s GPR64sp:$Rn)>;
5940 def : Pat<(v2f64 (AArch64dup (f64 (load GPR64sp:$Rn)))),
5941 (LD1Rv2d GPR64sp:$Rn)>;
5942 def : Pat<(v1f64 (AArch64dup (f64 (load GPR64sp:$Rn)))),
5943 (LD1Rv1d GPR64sp:$Rn)>;
5944 def : Pat<(v4f16 (AArch64dup (f16 (load GPR64sp:$Rn)))),
5945 (LD1Rv4h GPR64sp:$Rn)>;
5946 def : Pat<(v8f16 (AArch64dup (f16 (load GPR64sp:$Rn)))),
5947 (LD1Rv8h GPR64sp:$Rn)>;
5949 class Ld1Lane128Pat<SDPatternOperator scalar_load, Operand VecIndex,
5950 ValueType VTy, ValueType STy, Instruction LD1>
5951 : Pat<(vector_insert (VTy VecListOne128:$Rd),
5952 (STy (scalar_load GPR64sp:$Rn)), VecIndex:$idx),
5953 (LD1 VecListOne128:$Rd, VecIndex:$idx, GPR64sp:$Rn)>;
5955 def : Ld1Lane128Pat<extloadi8, VectorIndexB, v16i8, i32, LD1i8>;
5956 def : Ld1Lane128Pat<extloadi16, VectorIndexH, v8i16, i32, LD1i16>;
5957 def : Ld1Lane128Pat<load, VectorIndexS, v4i32, i32, LD1i32>;
5958 def : Ld1Lane128Pat<load, VectorIndexS, v4f32, f32, LD1i32>;
5959 def : Ld1Lane128Pat<load, VectorIndexD, v2i64, i64, LD1i64>;
5960 def : Ld1Lane128Pat<load, VectorIndexD, v2f64, f64, LD1i64>;
5961 def : Ld1Lane128Pat<load, VectorIndexH, v8f16, f16, LD1i16>;
5963 class Ld1Lane64Pat<SDPatternOperator scalar_load, Operand VecIndex,
5964 ValueType VTy, ValueType STy, Instruction LD1>
5965 : Pat<(vector_insert (VTy VecListOne64:$Rd),
5966 (STy (scalar_load GPR64sp:$Rn)), VecIndex:$idx),
5968 (LD1 (SUBREG_TO_REG (i32 0), VecListOne64:$Rd, dsub),
5969 VecIndex:$idx, GPR64sp:$Rn),
5972 def : Ld1Lane64Pat<extloadi8, VectorIndexB, v8i8, i32, LD1i8>;
5973 def : Ld1Lane64Pat<extloadi16, VectorIndexH, v4i16, i32, LD1i16>;
5974 def : Ld1Lane64Pat<load, VectorIndexS, v2i32, i32, LD1i32>;
5975 def : Ld1Lane64Pat<load, VectorIndexS, v2f32, f32, LD1i32>;
5976 def : Ld1Lane64Pat<load, VectorIndexH, v4f16, f16, LD1i16>;
5979 defm LD1 : SIMDLdSt1SingleAliases<"ld1">;
5980 defm LD2 : SIMDLdSt2SingleAliases<"ld2">;
5981 defm LD3 : SIMDLdSt3SingleAliases<"ld3">;
5982 defm LD4 : SIMDLdSt4SingleAliases<"ld4">;
5985 defm ST1 : SIMDStSingleB<0, 0b000, "st1", VecListOneb, GPR64pi1>;
5986 defm ST1 : SIMDStSingleH<0, 0b010, 0, "st1", VecListOneh, GPR64pi2>;
5987 defm ST1 : SIMDStSingleS<0, 0b100, 0b00, "st1", VecListOnes, GPR64pi4>;
5988 defm ST1 : SIMDStSingleD<0, 0b100, 0b01, "st1", VecListOned, GPR64pi8>;
5990 let AddedComplexity = 19 in
5991 class St1Lane128Pat<SDPatternOperator scalar_store, Operand VecIndex,
5992 ValueType VTy, ValueType STy, Instruction ST1>
5994 (STy (vector_extract (VTy VecListOne128:$Vt), VecIndex:$idx)),
5996 (ST1 VecListOne128:$Vt, VecIndex:$idx, GPR64sp:$Rn)>;
5998 def : St1Lane128Pat<truncstorei8, VectorIndexB, v16i8, i32, ST1i8>;
5999 def : St1Lane128Pat<truncstorei16, VectorIndexH, v8i16, i32, ST1i16>;
6000 def : St1Lane128Pat<store, VectorIndexS, v4i32, i32, ST1i32>;
6001 def : St1Lane128Pat<store, VectorIndexS, v4f32, f32, ST1i32>;
6002 def : St1Lane128Pat<store, VectorIndexD, v2i64, i64, ST1i64>;
6003 def : St1Lane128Pat<store, VectorIndexD, v2f64, f64, ST1i64>;
6004 def : St1Lane128Pat<store, VectorIndexH, v8f16, f16, ST1i16>;
6006 let AddedComplexity = 19 in
6007 class St1Lane64Pat<SDPatternOperator scalar_store, Operand VecIndex,
6008 ValueType VTy, ValueType STy, Instruction ST1>
6010 (STy (vector_extract (VTy VecListOne64:$Vt), VecIndex:$idx)),
6012 (ST1 (SUBREG_TO_REG (i32 0), VecListOne64:$Vt, dsub),
6013 VecIndex:$idx, GPR64sp:$Rn)>;
6015 def : St1Lane64Pat<truncstorei8, VectorIndexB, v8i8, i32, ST1i8>;
6016 def : St1Lane64Pat<truncstorei16, VectorIndexH, v4i16, i32, ST1i16>;
6017 def : St1Lane64Pat<store, VectorIndexS, v2i32, i32, ST1i32>;
6018 def : St1Lane64Pat<store, VectorIndexS, v2f32, f32, ST1i32>;
6019 def : St1Lane64Pat<store, VectorIndexH, v4f16, f16, ST1i16>;
6021 multiclass St1LanePost64Pat<SDPatternOperator scalar_store, Operand VecIndex,
6022 ValueType VTy, ValueType STy, Instruction ST1,
6024 def : Pat<(scalar_store
6025 (STy (vector_extract (VTy VecListOne64:$Vt), VecIndex:$idx)),
6026 GPR64sp:$Rn, offset),
6027 (ST1 (SUBREG_TO_REG (i32 0), VecListOne64:$Vt, dsub),
6028 VecIndex:$idx, GPR64sp:$Rn, XZR)>;
6030 def : Pat<(scalar_store
6031 (STy (vector_extract (VTy VecListOne64:$Vt), VecIndex:$idx)),
6032 GPR64sp:$Rn, GPR64:$Rm),
6033 (ST1 (SUBREG_TO_REG (i32 0), VecListOne64:$Vt, dsub),
6034 VecIndex:$idx, GPR64sp:$Rn, $Rm)>;
6037 defm : St1LanePost64Pat<post_truncsti8, VectorIndexB, v8i8, i32, ST1i8_POST, 1>;
6038 defm : St1LanePost64Pat<post_truncsti16, VectorIndexH, v4i16, i32, ST1i16_POST,
6040 defm : St1LanePost64Pat<post_store, VectorIndexS, v2i32, i32, ST1i32_POST, 4>;
6041 defm : St1LanePost64Pat<post_store, VectorIndexS, v2f32, f32, ST1i32_POST, 4>;
6042 defm : St1LanePost64Pat<post_store, VectorIndexD, v1i64, i64, ST1i64_POST, 8>;
6043 defm : St1LanePost64Pat<post_store, VectorIndexD, v1f64, f64, ST1i64_POST, 8>;
6044 defm : St1LanePost64Pat<post_store, VectorIndexH, v4f16, f16, ST1i16_POST, 2>;
6046 multiclass St1LanePost128Pat<SDPatternOperator scalar_store, Operand VecIndex,
6047 ValueType VTy, ValueType STy, Instruction ST1,
6049 def : Pat<(scalar_store
6050 (STy (vector_extract (VTy VecListOne128:$Vt), VecIndex:$idx)),
6051 GPR64sp:$Rn, offset),
6052 (ST1 VecListOne128:$Vt, VecIndex:$idx, GPR64sp:$Rn, XZR)>;
6054 def : Pat<(scalar_store
6055 (STy (vector_extract (VTy VecListOne128:$Vt), VecIndex:$idx)),
6056 GPR64sp:$Rn, GPR64:$Rm),
6057 (ST1 VecListOne128:$Vt, VecIndex:$idx, GPR64sp:$Rn, $Rm)>;
6060 defm : St1LanePost128Pat<post_truncsti8, VectorIndexB, v16i8, i32, ST1i8_POST,
6062 defm : St1LanePost128Pat<post_truncsti16, VectorIndexH, v8i16, i32, ST1i16_POST,
6064 defm : St1LanePost128Pat<post_store, VectorIndexS, v4i32, i32, ST1i32_POST, 4>;
6065 defm : St1LanePost128Pat<post_store, VectorIndexS, v4f32, f32, ST1i32_POST, 4>;
6066 defm : St1LanePost128Pat<post_store, VectorIndexD, v2i64, i64, ST1i64_POST, 8>;
6067 defm : St1LanePost128Pat<post_store, VectorIndexD, v2f64, f64, ST1i64_POST, 8>;
6068 defm : St1LanePost128Pat<post_store, VectorIndexH, v8f16, f16, ST1i16_POST, 2>;
6070 let mayStore = 1, hasSideEffects = 0 in {
6071 defm ST2 : SIMDStSingleB<1, 0b000, "st2", VecListTwob, GPR64pi2>;
6072 defm ST2 : SIMDStSingleH<1, 0b010, 0, "st2", VecListTwoh, GPR64pi4>;
6073 defm ST2 : SIMDStSingleS<1, 0b100, 0b00, "st2", VecListTwos, GPR64pi8>;
6074 defm ST2 : SIMDStSingleD<1, 0b100, 0b01, "st2", VecListTwod, GPR64pi16>;
6075 defm ST3 : SIMDStSingleB<0, 0b001, "st3", VecListThreeb, GPR64pi3>;
6076 defm ST3 : SIMDStSingleH<0, 0b011, 0, "st3", VecListThreeh, GPR64pi6>;
6077 defm ST3 : SIMDStSingleS<0, 0b101, 0b00, "st3", VecListThrees, GPR64pi12>;
6078 defm ST3 : SIMDStSingleD<0, 0b101, 0b01, "st3", VecListThreed, GPR64pi24>;
6079 defm ST4 : SIMDStSingleB<1, 0b001, "st4", VecListFourb, GPR64pi4>;
6080 defm ST4 : SIMDStSingleH<1, 0b011, 0, "st4", VecListFourh, GPR64pi8>;
6081 defm ST4 : SIMDStSingleS<1, 0b101, 0b00, "st4", VecListFours, GPR64pi16>;
6082 defm ST4 : SIMDStSingleD<1, 0b101, 0b01, "st4", VecListFourd, GPR64pi32>;
6085 defm ST1 : SIMDLdSt1SingleAliases<"st1">;
6086 defm ST2 : SIMDLdSt2SingleAliases<"st2">;
6087 defm ST3 : SIMDLdSt3SingleAliases<"st3">;
6088 defm ST4 : SIMDLdSt4SingleAliases<"st4">;
6090 //----------------------------------------------------------------------------
6091 // Crypto extensions
6092 //----------------------------------------------------------------------------
6094 let Predicates = [HasAES] in {
6095 def AESErr : AESTiedInst<0b0100, "aese", int_aarch64_crypto_aese>;
6096 def AESDrr : AESTiedInst<0b0101, "aesd", int_aarch64_crypto_aesd>;
6097 def AESMCrr : AESInst< 0b0110, "aesmc", int_aarch64_crypto_aesmc>;
6098 def AESIMCrr : AESInst< 0b0111, "aesimc", int_aarch64_crypto_aesimc>;
6101 // Pseudo instructions for AESMCrr/AESIMCrr with a register constraint required
6102 // for AES fusion on some CPUs.
6103 let hasSideEffects = 0, mayStore = 0, mayLoad = 0 in {
6104 def AESMCrrTied: Pseudo<(outs V128:$Rd), (ins V128:$Rn), [], "$Rn = $Rd">,
6106 def AESIMCrrTied: Pseudo<(outs V128:$Rd), (ins V128:$Rn), [], "$Rn = $Rd">,
6110 // Only use constrained versions of AES(I)MC instructions if they are paired with
6112 def : Pat<(v16i8 (int_aarch64_crypto_aesmc
6113 (v16i8 (int_aarch64_crypto_aese (v16i8 V128:$src1),
6114 (v16i8 V128:$src2))))),
6115 (v16i8 (AESMCrrTied (v16i8 (AESErr (v16i8 V128:$src1),
6116 (v16i8 V128:$src2)))))>,
6117 Requires<[HasFuseAES]>;
6119 def : Pat<(v16i8 (int_aarch64_crypto_aesimc
6120 (v16i8 (int_aarch64_crypto_aesd (v16i8 V128:$src1),
6121 (v16i8 V128:$src2))))),
6122 (v16i8 (AESIMCrrTied (v16i8 (AESDrr (v16i8 V128:$src1),
6123 (v16i8 V128:$src2)))))>,
6124 Requires<[HasFuseAES]>;
6126 let Predicates = [HasSHA2] in {
6127 def SHA1Crrr : SHATiedInstQSV<0b000, "sha1c", int_aarch64_crypto_sha1c>;
6128 def SHA1Prrr : SHATiedInstQSV<0b001, "sha1p", int_aarch64_crypto_sha1p>;
6129 def SHA1Mrrr : SHATiedInstQSV<0b010, "sha1m", int_aarch64_crypto_sha1m>;
6130 def SHA1SU0rrr : SHATiedInstVVV<0b011, "sha1su0", int_aarch64_crypto_sha1su0>;
6131 def SHA256Hrrr : SHATiedInstQQV<0b100, "sha256h", int_aarch64_crypto_sha256h>;
6132 def SHA256H2rrr : SHATiedInstQQV<0b101, "sha256h2",int_aarch64_crypto_sha256h2>;
6133 def SHA256SU1rrr :SHATiedInstVVV<0b110, "sha256su1",int_aarch64_crypto_sha256su1>;
6135 def SHA1Hrr : SHAInstSS< 0b0000, "sha1h", int_aarch64_crypto_sha1h>;
6136 def SHA1SU1rr : SHATiedInstVV<0b0001, "sha1su1", int_aarch64_crypto_sha1su1>;
6137 def SHA256SU0rr : SHATiedInstVV<0b0010, "sha256su0",int_aarch64_crypto_sha256su0>;
6140 //----------------------------------------------------------------------------
6142 //----------------------------------------------------------------------------
6143 // FIXME: Like for X86, these should go in their own separate .td file.
6145 def def32 : PatLeaf<(i32 GPR32:$src), [{
6149 // In the case of a 32-bit def that is known to implicitly zero-extend,
6150 // we can use a SUBREG_TO_REG.
6151 def : Pat<(i64 (zext def32:$src)), (SUBREG_TO_REG (i64 0), GPR32:$src, sub_32)>;
6153 // For an anyext, we don't care what the high bits are, so we can perform an
6154 // INSERT_SUBREF into an IMPLICIT_DEF.
6155 def : Pat<(i64 (anyext GPR32:$src)),
6156 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GPR32:$src, sub_32)>;
6158 // When we need to explicitly zero-extend, we use a 32-bit MOV instruction and
6159 // then assert the extension has happened.
6160 def : Pat<(i64 (zext GPR32:$src)),
6161 (SUBREG_TO_REG (i32 0), (ORRWrs WZR, GPR32:$src, 0), sub_32)>;
6163 // To sign extend, we use a signed bitfield move instruction (SBFM) on the
6164 // containing super-reg.
6165 def : Pat<(i64 (sext GPR32:$src)),
6166 (SBFMXri (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GPR32:$src, sub_32), 0, 31)>;
6167 def : Pat<(i64 (sext_inreg GPR64:$src, i32)), (SBFMXri GPR64:$src, 0, 31)>;
6168 def : Pat<(i64 (sext_inreg GPR64:$src, i16)), (SBFMXri GPR64:$src, 0, 15)>;
6169 def : Pat<(i64 (sext_inreg GPR64:$src, i8)), (SBFMXri GPR64:$src, 0, 7)>;
6170 def : Pat<(i64 (sext_inreg GPR64:$src, i1)), (SBFMXri GPR64:$src, 0, 0)>;
6171 def : Pat<(i32 (sext_inreg GPR32:$src, i16)), (SBFMWri GPR32:$src, 0, 15)>;
6172 def : Pat<(i32 (sext_inreg GPR32:$src, i8)), (SBFMWri GPR32:$src, 0, 7)>;
6173 def : Pat<(i32 (sext_inreg GPR32:$src, i1)), (SBFMWri GPR32:$src, 0, 0)>;
6175 def : Pat<(shl (sext_inreg GPR32:$Rn, i8), (i64 imm0_31:$imm)),
6176 (SBFMWri GPR32:$Rn, (i64 (i32shift_a imm0_31:$imm)),
6177 (i64 (i32shift_sext_i8 imm0_31:$imm)))>;
6178 def : Pat<(shl (sext_inreg GPR64:$Rn, i8), (i64 imm0_63:$imm)),
6179 (SBFMXri GPR64:$Rn, (i64 (i64shift_a imm0_63:$imm)),
6180 (i64 (i64shift_sext_i8 imm0_63:$imm)))>;
6182 def : Pat<(shl (sext_inreg GPR32:$Rn, i16), (i64 imm0_31:$imm)),
6183 (SBFMWri GPR32:$Rn, (i64 (i32shift_a imm0_31:$imm)),
6184 (i64 (i32shift_sext_i16 imm0_31:$imm)))>;
6185 def : Pat<(shl (sext_inreg GPR64:$Rn, i16), (i64 imm0_63:$imm)),
6186 (SBFMXri GPR64:$Rn, (i64 (i64shift_a imm0_63:$imm)),
6187 (i64 (i64shift_sext_i16 imm0_63:$imm)))>;
6189 def : Pat<(shl (i64 (sext GPR32:$Rn)), (i64 imm0_63:$imm)),
6190 (SBFMXri (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GPR32:$Rn, sub_32),
6191 (i64 (i64shift_a imm0_63:$imm)),
6192 (i64 (i64shift_sext_i32 imm0_63:$imm)))>;
6194 // sra patterns have an AddedComplexity of 10, so make sure we have a higher
6195 // AddedComplexity for the following patterns since we want to match sext + sra
6196 // patterns before we attempt to match a single sra node.
6197 let AddedComplexity = 20 in {
6198 // We support all sext + sra combinations which preserve at least one bit of the
6199 // original value which is to be sign extended. E.g. we support shifts up to
6201 def : Pat<(sra (sext_inreg GPR32:$Rn, i8), (i64 imm0_7:$imm)),
6202 (SBFMWri GPR32:$Rn, (i64 imm0_7:$imm), 7)>;
6203 def : Pat<(sra (sext_inreg GPR64:$Rn, i8), (i64 imm0_7:$imm)),
6204 (SBFMXri GPR64:$Rn, (i64 imm0_7:$imm), 7)>;
6206 def : Pat<(sra (sext_inreg GPR32:$Rn, i16), (i64 imm0_15:$imm)),
6207 (SBFMWri GPR32:$Rn, (i64 imm0_15:$imm), 15)>;
6208 def : Pat<(sra (sext_inreg GPR64:$Rn, i16), (i64 imm0_15:$imm)),
6209 (SBFMXri GPR64:$Rn, (i64 imm0_15:$imm), 15)>;
6211 def : Pat<(sra (i64 (sext GPR32:$Rn)), (i64 imm0_31:$imm)),
6212 (SBFMXri (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GPR32:$Rn, sub_32),
6213 (i64 imm0_31:$imm), 31)>;
6214 } // AddedComplexity = 20
6216 // To truncate, we can simply extract from a subregister.
6217 def : Pat<(i32 (trunc GPR64sp:$src)),
6218 (i32 (EXTRACT_SUBREG GPR64sp:$src, sub_32))>;
6220 // __builtin_trap() uses the BRK instruction on AArch64.
6221 def : Pat<(trap), (BRK 1)>;
6222 def : Pat<(debugtrap), (BRK 0xF000)>, Requires<[IsWindows]>;
6224 // Multiply high patterns which multiply the lower subvector using smull/umull
6225 // and the upper subvector with smull2/umull2. Then shuffle the high the high
6226 // part of both results together.
6227 def : Pat<(v16i8 (mulhs V128:$Rn, V128:$Rm)),
6229 (SMULLv8i8_v8i16 (EXTRACT_SUBREG V128:$Rn, dsub),
6230 (EXTRACT_SUBREG V128:$Rm, dsub)),
6231 (SMULLv16i8_v8i16 V128:$Rn, V128:$Rm))>;
6232 def : Pat<(v8i16 (mulhs V128:$Rn, V128:$Rm)),
6234 (SMULLv4i16_v4i32 (EXTRACT_SUBREG V128:$Rn, dsub),
6235 (EXTRACT_SUBREG V128:$Rm, dsub)),
6236 (SMULLv8i16_v4i32 V128:$Rn, V128:$Rm))>;
6237 def : Pat<(v4i32 (mulhs V128:$Rn, V128:$Rm)),
6239 (SMULLv2i32_v2i64 (EXTRACT_SUBREG V128:$Rn, dsub),
6240 (EXTRACT_SUBREG V128:$Rm, dsub)),
6241 (SMULLv4i32_v2i64 V128:$Rn, V128:$Rm))>;
6243 def : Pat<(v16i8 (mulhu V128:$Rn, V128:$Rm)),
6245 (UMULLv8i8_v8i16 (EXTRACT_SUBREG V128:$Rn, dsub),
6246 (EXTRACT_SUBREG V128:$Rm, dsub)),
6247 (UMULLv16i8_v8i16 V128:$Rn, V128:$Rm))>;
6248 def : Pat<(v8i16 (mulhu V128:$Rn, V128:$Rm)),
6250 (UMULLv4i16_v4i32 (EXTRACT_SUBREG V128:$Rn, dsub),
6251 (EXTRACT_SUBREG V128:$Rm, dsub)),
6252 (UMULLv8i16_v4i32 V128:$Rn, V128:$Rm))>;
6253 def : Pat<(v4i32 (mulhu V128:$Rn, V128:$Rm)),
6255 (UMULLv2i32_v2i64 (EXTRACT_SUBREG V128:$Rn, dsub),
6256 (EXTRACT_SUBREG V128:$Rm, dsub)),
6257 (UMULLv4i32_v2i64 V128:$Rn, V128:$Rm))>;
6259 // Conversions within AdvSIMD types in the same register size are free.
6260 // But because we need a consistent lane ordering, in big endian many
6261 // conversions require one or more REV instructions.
6263 // Consider a simple memory load followed by a bitconvert then a store.
6265 // v1 = BITCAST v2i32 v0 to v4i16
6268 // In big endian mode every memory access has an implicit byte swap. LDR and
6269 // STR do a 64-bit byte swap, whereas LD1/ST1 do a byte swap per lane - that
6270 // is, they treat the vector as a sequence of elements to be byte-swapped.
6271 // The two pairs of instructions are fundamentally incompatible. We've decided
6272 // to use LD1/ST1 only to simplify compiler implementation.
6274 // LD1/ST1 perform the equivalent of a sequence of LDR/STR + REV. This makes
6275 // the original code sequence:
6277 // v1 = REV v2i32 (implicit)
6278 // v2 = BITCAST v2i32 v1 to v4i16
6279 // v3 = REV v4i16 v2 (implicit)
6282 // But this is now broken - the value stored is different to the value loaded
6283 // due to lane reordering. To fix this, on every BITCAST we must perform two
6286 // v1 = REV v2i32 (implicit)
6288 // v3 = BITCAST v2i32 v2 to v4i16
6290 // v5 = REV v4i16 v4 (implicit)
6293 // This means an extra two instructions, but actually in most cases the two REV
6294 // instructions can be combined into one. For example:
6295 // (REV64_2s (REV64_4h X)) === (REV32_4h X)
6297 // There is also no 128-bit REV instruction. This must be synthesized with an
6300 // Most bitconverts require some sort of conversion. The only exceptions are:
6301 // a) Identity conversions - vNfX <-> vNiX
6302 // b) Single-lane-to-scalar - v1fX <-> fX or v1iX <-> iX
6305 // Natural vector casts (64 bit)
6306 def : Pat<(v8i8 (AArch64NvCast (v2i32 FPR64:$src))), (v8i8 FPR64:$src)>;
6307 def : Pat<(v4i16 (AArch64NvCast (v2i32 FPR64:$src))), (v4i16 FPR64:$src)>;
6308 def : Pat<(v4f16 (AArch64NvCast (v2i32 FPR64:$src))), (v4f16 FPR64:$src)>;
6309 def : Pat<(v2i32 (AArch64NvCast (v2i32 FPR64:$src))), (v2i32 FPR64:$src)>;
6310 def : Pat<(v2f32 (AArch64NvCast (v2i32 FPR64:$src))), (v2f32 FPR64:$src)>;
6311 def : Pat<(v1i64 (AArch64NvCast (v2i32 FPR64:$src))), (v1i64 FPR64:$src)>;
6313 def : Pat<(v8i8 (AArch64NvCast (v4i16 FPR64:$src))), (v8i8 FPR64:$src)>;
6314 def : Pat<(v4i16 (AArch64NvCast (v4i16 FPR64:$src))), (v4i16 FPR64:$src)>;
6315 def : Pat<(v4f16 (AArch64NvCast (v4i16 FPR64:$src))), (v4f16 FPR64:$src)>;
6316 def : Pat<(v2i32 (AArch64NvCast (v4i16 FPR64:$src))), (v2i32 FPR64:$src)>;
6317 def : Pat<(v1i64 (AArch64NvCast (v4i16 FPR64:$src))), (v1i64 FPR64:$src)>;
6319 def : Pat<(v8i8 (AArch64NvCast (v8i8 FPR64:$src))), (v8i8 FPR64:$src)>;
6320 def : Pat<(v4i16 (AArch64NvCast (v8i8 FPR64:$src))), (v4i16 FPR64:$src)>;
6321 def : Pat<(v4f16 (AArch64NvCast (v8i8 FPR64:$src))), (v4f16 FPR64:$src)>;
6322 def : Pat<(v2i32 (AArch64NvCast (v8i8 FPR64:$src))), (v2i32 FPR64:$src)>;
6323 def : Pat<(v2f32 (AArch64NvCast (v8i8 FPR64:$src))), (v2f32 FPR64:$src)>;
6324 def : Pat<(v1i64 (AArch64NvCast (v8i8 FPR64:$src))), (v1i64 FPR64:$src)>;
6326 def : Pat<(v8i8 (AArch64NvCast (f64 FPR64:$src))), (v8i8 FPR64:$src)>;
6327 def : Pat<(v4i16 (AArch64NvCast (f64 FPR64:$src))), (v4i16 FPR64:$src)>;
6328 def : Pat<(v4f16 (AArch64NvCast (f64 FPR64:$src))), (v4f16 FPR64:$src)>;
6329 def : Pat<(v2i32 (AArch64NvCast (f64 FPR64:$src))), (v2i32 FPR64:$src)>;
6330 def : Pat<(v2f32 (AArch64NvCast (f64 FPR64:$src))), (v2f32 FPR64:$src)>;
6331 def : Pat<(v1i64 (AArch64NvCast (f64 FPR64:$src))), (v1i64 FPR64:$src)>;
6332 def : Pat<(v1f64 (AArch64NvCast (f64 FPR64:$src))), (v1f64 FPR64:$src)>;
6334 def : Pat<(v8i8 (AArch64NvCast (v2f32 FPR64:$src))), (v8i8 FPR64:$src)>;
6335 def : Pat<(v4i16 (AArch64NvCast (v2f32 FPR64:$src))), (v4i16 FPR64:$src)>;
6336 def : Pat<(v2i32 (AArch64NvCast (v2f32 FPR64:$src))), (v2i32 FPR64:$src)>;
6337 def : Pat<(v2f32 (AArch64NvCast (v2f32 FPR64:$src))), (v2f32 FPR64:$src)>;
6338 def : Pat<(v1i64 (AArch64NvCast (v2f32 FPR64:$src))), (v1i64 FPR64:$src)>;
6339 def : Pat<(v1f64 (AArch64NvCast (v2f32 FPR64:$src))), (v1f64 FPR64:$src)>;
6341 // Natural vector casts (128 bit)
6342 def : Pat<(v16i8 (AArch64NvCast (v4i32 FPR128:$src))), (v16i8 FPR128:$src)>;
6343 def : Pat<(v8i16 (AArch64NvCast (v4i32 FPR128:$src))), (v8i16 FPR128:$src)>;
6344 def : Pat<(v8f16 (AArch64NvCast (v4i32 FPR128:$src))), (v8f16 FPR128:$src)>;
6345 def : Pat<(v4i32 (AArch64NvCast (v4i32 FPR128:$src))), (v4i32 FPR128:$src)>;
6346 def : Pat<(v4f32 (AArch64NvCast (v4i32 FPR128:$src))), (v4f32 FPR128:$src)>;
6347 def : Pat<(v2i64 (AArch64NvCast (v4i32 FPR128:$src))), (v2i64 FPR128:$src)>;
6348 def : Pat<(v2f64 (AArch64NvCast (v4i32 FPR128:$src))), (v2f64 FPR128:$src)>;
6350 def : Pat<(v16i8 (AArch64NvCast (v8i16 FPR128:$src))), (v16i8 FPR128:$src)>;
6351 def : Pat<(v8i16 (AArch64NvCast (v8i16 FPR128:$src))), (v8i16 FPR128:$src)>;
6352 def : Pat<(v8f16 (AArch64NvCast (v8i16 FPR128:$src))), (v8f16 FPR128:$src)>;
6353 def : Pat<(v4i32 (AArch64NvCast (v8i16 FPR128:$src))), (v4i32 FPR128:$src)>;
6354 def : Pat<(v2i64 (AArch64NvCast (v8i16 FPR128:$src))), (v2i64 FPR128:$src)>;
6355 def : Pat<(v4f32 (AArch64NvCast (v8i16 FPR128:$src))), (v4f32 FPR128:$src)>;
6356 def : Pat<(v2f64 (AArch64NvCast (v8i16 FPR128:$src))), (v2f64 FPR128:$src)>;
6358 def : Pat<(v16i8 (AArch64NvCast (v16i8 FPR128:$src))), (v16i8 FPR128:$src)>;
6359 def : Pat<(v8i16 (AArch64NvCast (v16i8 FPR128:$src))), (v8i16 FPR128:$src)>;
6360 def : Pat<(v8f16 (AArch64NvCast (v16i8 FPR128:$src))), (v8f16 FPR128:$src)>;
6361 def : Pat<(v4i32 (AArch64NvCast (v16i8 FPR128:$src))), (v4i32 FPR128:$src)>;
6362 def : Pat<(v2i64 (AArch64NvCast (v16i8 FPR128:$src))), (v2i64 FPR128:$src)>;
6363 def : Pat<(v4f32 (AArch64NvCast (v16i8 FPR128:$src))), (v4f32 FPR128:$src)>;
6364 def : Pat<(v2f64 (AArch64NvCast (v16i8 FPR128:$src))), (v2f64 FPR128:$src)>;
6366 def : Pat<(v16i8 (AArch64NvCast (v2i64 FPR128:$src))), (v16i8 FPR128:$src)>;
6367 def : Pat<(v8i16 (AArch64NvCast (v2i64 FPR128:$src))), (v8i16 FPR128:$src)>;
6368 def : Pat<(v8f16 (AArch64NvCast (v2i64 FPR128:$src))), (v8f16 FPR128:$src)>;
6369 def : Pat<(v4i32 (AArch64NvCast (v2i64 FPR128:$src))), (v4i32 FPR128:$src)>;
6370 def : Pat<(v2i64 (AArch64NvCast (v2i64 FPR128:$src))), (v2i64 FPR128:$src)>;
6371 def : Pat<(v4f32 (AArch64NvCast (v2i64 FPR128:$src))), (v4f32 FPR128:$src)>;
6372 def : Pat<(v2f64 (AArch64NvCast (v2i64 FPR128:$src))), (v2f64 FPR128:$src)>;
6374 def : Pat<(v16i8 (AArch64NvCast (v4f32 FPR128:$src))), (v16i8 FPR128:$src)>;
6375 def : Pat<(v8i16 (AArch64NvCast (v4f32 FPR128:$src))), (v8i16 FPR128:$src)>;
6376 def : Pat<(v4i32 (AArch64NvCast (v4f32 FPR128:$src))), (v4i32 FPR128:$src)>;
6377 def : Pat<(v4f32 (AArch64NvCast (v4f32 FPR128:$src))), (v4f32 FPR128:$src)>;
6378 def : Pat<(v2i64 (AArch64NvCast (v4f32 FPR128:$src))), (v2i64 FPR128:$src)>;
6379 def : Pat<(v8f16 (AArch64NvCast (v4f32 FPR128:$src))), (v8f16 FPR128:$src)>;
6380 def : Pat<(v2f64 (AArch64NvCast (v4f32 FPR128:$src))), (v2f64 FPR128:$src)>;
6382 def : Pat<(v16i8 (AArch64NvCast (v2f64 FPR128:$src))), (v16i8 FPR128:$src)>;
6383 def : Pat<(v8i16 (AArch64NvCast (v2f64 FPR128:$src))), (v8i16 FPR128:$src)>;
6384 def : Pat<(v4i32 (AArch64NvCast (v2f64 FPR128:$src))), (v4i32 FPR128:$src)>;
6385 def : Pat<(v2i64 (AArch64NvCast (v2f64 FPR128:$src))), (v2i64 FPR128:$src)>;
6386 def : Pat<(v2f64 (AArch64NvCast (v2f64 FPR128:$src))), (v2f64 FPR128:$src)>;
6387 def : Pat<(v8f16 (AArch64NvCast (v2f64 FPR128:$src))), (v8f16 FPR128:$src)>;
6388 def : Pat<(v4f32 (AArch64NvCast (v2f64 FPR128:$src))), (v4f32 FPR128:$src)>;
6390 let Predicates = [IsLE] in {
6391 def : Pat<(v8i8 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6392 def : Pat<(v4i16 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6393 def : Pat<(v2i32 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6394 def : Pat<(v4f16 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6395 def : Pat<(v2f32 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6397 def : Pat<(i64 (bitconvert (v8i8 V64:$Vn))),
6398 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6399 def : Pat<(i64 (bitconvert (v4i16 V64:$Vn))),
6400 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6401 def : Pat<(i64 (bitconvert (v2i32 V64:$Vn))),
6402 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6403 def : Pat<(i64 (bitconvert (v4f16 V64:$Vn))),
6404 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6405 def : Pat<(i64 (bitconvert (v2f32 V64:$Vn))),
6406 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6407 def : Pat<(i64 (bitconvert (v1f64 V64:$Vn))),
6408 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6410 let Predicates = [IsBE] in {
6411 def : Pat<(v8i8 (bitconvert GPR64:$Xn)),
6412 (REV64v8i8 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
6413 def : Pat<(v4i16 (bitconvert GPR64:$Xn)),
6414 (REV64v4i16 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
6415 def : Pat<(v2i32 (bitconvert GPR64:$Xn)),
6416 (REV64v2i32 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
6417 def : Pat<(v4f16 (bitconvert GPR64:$Xn)),
6418 (REV64v4i16 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
6419 def : Pat<(v2f32 (bitconvert GPR64:$Xn)),
6420 (REV64v2i32 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
6422 def : Pat<(i64 (bitconvert (v8i8 V64:$Vn))),
6423 (REV64v8i8 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
6424 def : Pat<(i64 (bitconvert (v4i16 V64:$Vn))),
6425 (REV64v4i16 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
6426 def : Pat<(i64 (bitconvert (v2i32 V64:$Vn))),
6427 (REV64v2i32 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
6428 def : Pat<(i64 (bitconvert (v4f16 V64:$Vn))),
6429 (REV64v4i16 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
6430 def : Pat<(i64 (bitconvert (v2f32 V64:$Vn))),
6431 (REV64v2i32 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
6433 def : Pat<(v1i64 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6434 def : Pat<(v1f64 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6435 def : Pat<(i64 (bitconvert (v1i64 V64:$Vn))),
6436 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6437 def : Pat<(v1i64 (scalar_to_vector GPR64:$Xn)),
6438 (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6439 def : Pat<(v1f64 (scalar_to_vector GPR64:$Xn)),
6440 (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6441 def : Pat<(v1f64 (scalar_to_vector (f64 FPR64:$Xn))), (v1f64 FPR64:$Xn)>;
6443 def : Pat<(f32 (bitconvert (i32 GPR32:$Xn))),
6444 (COPY_TO_REGCLASS GPR32:$Xn, FPR32)>;
6445 def : Pat<(i32 (bitconvert (f32 FPR32:$Xn))),
6446 (COPY_TO_REGCLASS FPR32:$Xn, GPR32)>;
6447 def : Pat<(f64 (bitconvert (i64 GPR64:$Xn))),
6448 (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6449 def : Pat<(i64 (bitconvert (f64 FPR64:$Xn))),
6450 (COPY_TO_REGCLASS FPR64:$Xn, GPR64)>;
6451 def : Pat<(i64 (bitconvert (v1f64 V64:$Vn))),
6452 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6454 let Predicates = [IsLE] in {
6455 def : Pat<(v1i64 (bitconvert (v2i32 FPR64:$src))), (v1i64 FPR64:$src)>;
6456 def : Pat<(v1i64 (bitconvert (v4i16 FPR64:$src))), (v1i64 FPR64:$src)>;
6457 def : Pat<(v1i64 (bitconvert (v8i8 FPR64:$src))), (v1i64 FPR64:$src)>;
6458 def : Pat<(v1i64 (bitconvert (v4f16 FPR64:$src))), (v1i64 FPR64:$src)>;
6459 def : Pat<(v1i64 (bitconvert (v2f32 FPR64:$src))), (v1i64 FPR64:$src)>;
6461 let Predicates = [IsBE] in {
6462 def : Pat<(v1i64 (bitconvert (v2i32 FPR64:$src))),
6463 (v1i64 (REV64v2i32 FPR64:$src))>;
6464 def : Pat<(v1i64 (bitconvert (v4i16 FPR64:$src))),
6465 (v1i64 (REV64v4i16 FPR64:$src))>;
6466 def : Pat<(v1i64 (bitconvert (v8i8 FPR64:$src))),
6467 (v1i64 (REV64v8i8 FPR64:$src))>;
6468 def : Pat<(v1i64 (bitconvert (v4f16 FPR64:$src))),
6469 (v1i64 (REV64v4i16 FPR64:$src))>;
6470 def : Pat<(v1i64 (bitconvert (v2f32 FPR64:$src))),
6471 (v1i64 (REV64v2i32 FPR64:$src))>;
6473 def : Pat<(v1i64 (bitconvert (v1f64 FPR64:$src))), (v1i64 FPR64:$src)>;
6474 def : Pat<(v1i64 (bitconvert (f64 FPR64:$src))), (v1i64 FPR64:$src)>;
6476 let Predicates = [IsLE] in {
6477 def : Pat<(v2i32 (bitconvert (v1i64 FPR64:$src))), (v2i32 FPR64:$src)>;
6478 def : Pat<(v2i32 (bitconvert (v4i16 FPR64:$src))), (v2i32 FPR64:$src)>;
6479 def : Pat<(v2i32 (bitconvert (v8i8 FPR64:$src))), (v2i32 FPR64:$src)>;
6480 def : Pat<(v2i32 (bitconvert (f64 FPR64:$src))), (v2i32 FPR64:$src)>;
6481 def : Pat<(v2i32 (bitconvert (v1f64 FPR64:$src))), (v2i32 FPR64:$src)>;
6482 def : Pat<(v2i32 (bitconvert (v4f16 FPR64:$src))), (v2i32 FPR64:$src)>;
6484 let Predicates = [IsBE] in {
6485 def : Pat<(v2i32 (bitconvert (v1i64 FPR64:$src))),
6486 (v2i32 (REV64v2i32 FPR64:$src))>;
6487 def : Pat<(v2i32 (bitconvert (v4i16 FPR64:$src))),
6488 (v2i32 (REV32v4i16 FPR64:$src))>;
6489 def : Pat<(v2i32 (bitconvert (v8i8 FPR64:$src))),
6490 (v2i32 (REV32v8i8 FPR64:$src))>;
6491 def : Pat<(v2i32 (bitconvert (f64 FPR64:$src))),
6492 (v2i32 (REV64v2i32 FPR64:$src))>;
6493 def : Pat<(v2i32 (bitconvert (v1f64 FPR64:$src))),
6494 (v2i32 (REV64v2i32 FPR64:$src))>;
6495 def : Pat<(v2i32 (bitconvert (v4f16 FPR64:$src))),
6496 (v2i32 (REV32v4i16 FPR64:$src))>;
6498 def : Pat<(v2i32 (bitconvert (v2f32 FPR64:$src))), (v2i32 FPR64:$src)>;
6500 let Predicates = [IsLE] in {
6501 def : Pat<(v4i16 (bitconvert (v1i64 FPR64:$src))), (v4i16 FPR64:$src)>;
6502 def : Pat<(v4i16 (bitconvert (v2i32 FPR64:$src))), (v4i16 FPR64:$src)>;
6503 def : Pat<(v4i16 (bitconvert (v8i8 FPR64:$src))), (v4i16 FPR64:$src)>;
6504 def : Pat<(v4i16 (bitconvert (f64 FPR64:$src))), (v4i16 FPR64:$src)>;
6505 def : Pat<(v4i16 (bitconvert (v2f32 FPR64:$src))), (v4i16 FPR64:$src)>;
6506 def : Pat<(v4i16 (bitconvert (v1f64 FPR64:$src))), (v4i16 FPR64:$src)>;
6508 let Predicates = [IsBE] in {
6509 def : Pat<(v4i16 (bitconvert (v1i64 FPR64:$src))),
6510 (v4i16 (REV64v4i16 FPR64:$src))>;
6511 def : Pat<(v4i16 (bitconvert (v2i32 FPR64:$src))),
6512 (v4i16 (REV32v4i16 FPR64:$src))>;
6513 def : Pat<(v4i16 (bitconvert (v8i8 FPR64:$src))),
6514 (v4i16 (REV16v8i8 FPR64:$src))>;
6515 def : Pat<(v4i16 (bitconvert (f64 FPR64:$src))),
6516 (v4i16 (REV64v4i16 FPR64:$src))>;
6517 def : Pat<(v4i16 (bitconvert (v2f32 FPR64:$src))),
6518 (v4i16 (REV32v4i16 FPR64:$src))>;
6519 def : Pat<(v4i16 (bitconvert (v1f64 FPR64:$src))),
6520 (v4i16 (REV64v4i16 FPR64:$src))>;
6522 def : Pat<(v4i16 (bitconvert (v4f16 FPR64:$src))), (v4i16 FPR64:$src)>;
6524 let Predicates = [IsLE] in {
6525 def : Pat<(v4f16 (bitconvert (v1i64 FPR64:$src))), (v4f16 FPR64:$src)>;
6526 def : Pat<(v4f16 (bitconvert (v2i32 FPR64:$src))), (v4f16 FPR64:$src)>;
6527 def : Pat<(v4f16 (bitconvert (v8i8 FPR64:$src))), (v4f16 FPR64:$src)>;
6528 def : Pat<(v4f16 (bitconvert (f64 FPR64:$src))), (v4f16 FPR64:$src)>;
6529 def : Pat<(v4f16 (bitconvert (v2f32 FPR64:$src))), (v4f16 FPR64:$src)>;
6530 def : Pat<(v4f16 (bitconvert (v1f64 FPR64:$src))), (v4f16 FPR64:$src)>;
6532 let Predicates = [IsBE] in {
6533 def : Pat<(v4f16 (bitconvert (v1i64 FPR64:$src))),
6534 (v4f16 (REV64v4i16 FPR64:$src))>;
6535 def : Pat<(v4f16 (bitconvert (v2i32 FPR64:$src))),
6536 (v4f16 (REV32v4i16 FPR64:$src))>;
6537 def : Pat<(v4f16 (bitconvert (v8i8 FPR64:$src))),
6538 (v4f16 (REV16v8i8 FPR64:$src))>;
6539 def : Pat<(v4f16 (bitconvert (f64 FPR64:$src))),
6540 (v4f16 (REV64v4i16 FPR64:$src))>;
6541 def : Pat<(v4f16 (bitconvert (v2f32 FPR64:$src))),
6542 (v4f16 (REV32v4i16 FPR64:$src))>;
6543 def : Pat<(v4f16 (bitconvert (v1f64 FPR64:$src))),
6544 (v4f16 (REV64v4i16 FPR64:$src))>;
6546 def : Pat<(v4f16 (bitconvert (v4i16 FPR64:$src))), (v4f16 FPR64:$src)>;
6548 let Predicates = [IsLE] in {
6549 def : Pat<(v8i8 (bitconvert (v1i64 FPR64:$src))), (v8i8 FPR64:$src)>;
6550 def : Pat<(v8i8 (bitconvert (v2i32 FPR64:$src))), (v8i8 FPR64:$src)>;
6551 def : Pat<(v8i8 (bitconvert (v4i16 FPR64:$src))), (v8i8 FPR64:$src)>;
6552 def : Pat<(v8i8 (bitconvert (f64 FPR64:$src))), (v8i8 FPR64:$src)>;
6553 def : Pat<(v8i8 (bitconvert (v2f32 FPR64:$src))), (v8i8 FPR64:$src)>;
6554 def : Pat<(v8i8 (bitconvert (v1f64 FPR64:$src))), (v8i8 FPR64:$src)>;
6555 def : Pat<(v8i8 (bitconvert (v4f16 FPR64:$src))), (v8i8 FPR64:$src)>;
6557 let Predicates = [IsBE] in {
6558 def : Pat<(v8i8 (bitconvert (v1i64 FPR64:$src))),
6559 (v8i8 (REV64v8i8 FPR64:$src))>;
6560 def : Pat<(v8i8 (bitconvert (v2i32 FPR64:$src))),
6561 (v8i8 (REV32v8i8 FPR64:$src))>;
6562 def : Pat<(v8i8 (bitconvert (v4i16 FPR64:$src))),
6563 (v8i8 (REV16v8i8 FPR64:$src))>;
6564 def : Pat<(v8i8 (bitconvert (f64 FPR64:$src))),
6565 (v8i8 (REV64v8i8 FPR64:$src))>;
6566 def : Pat<(v8i8 (bitconvert (v2f32 FPR64:$src))),
6567 (v8i8 (REV32v8i8 FPR64:$src))>;
6568 def : Pat<(v8i8 (bitconvert (v1f64 FPR64:$src))),
6569 (v8i8 (REV64v8i8 FPR64:$src))>;
6570 def : Pat<(v8i8 (bitconvert (v4f16 FPR64:$src))),
6571 (v8i8 (REV16v8i8 FPR64:$src))>;
6574 let Predicates = [IsLE] in {
6575 def : Pat<(f64 (bitconvert (v2i32 FPR64:$src))), (f64 FPR64:$src)>;
6576 def : Pat<(f64 (bitconvert (v4i16 FPR64:$src))), (f64 FPR64:$src)>;
6577 def : Pat<(f64 (bitconvert (v2f32 FPR64:$src))), (f64 FPR64:$src)>;
6578 def : Pat<(f64 (bitconvert (v8i8 FPR64:$src))), (f64 FPR64:$src)>;
6579 def : Pat<(f64 (bitconvert (v4f16 FPR64:$src))), (f64 FPR64:$src)>;
6581 let Predicates = [IsBE] in {
6582 def : Pat<(f64 (bitconvert (v2i32 FPR64:$src))),
6583 (f64 (REV64v2i32 FPR64:$src))>;
6584 def : Pat<(f64 (bitconvert (v4i16 FPR64:$src))),
6585 (f64 (REV64v4i16 FPR64:$src))>;
6586 def : Pat<(f64 (bitconvert (v2f32 FPR64:$src))),
6587 (f64 (REV64v2i32 FPR64:$src))>;
6588 def : Pat<(f64 (bitconvert (v8i8 FPR64:$src))),
6589 (f64 (REV64v8i8 FPR64:$src))>;
6590 def : Pat<(f64 (bitconvert (v4f16 FPR64:$src))),
6591 (f64 (REV64v4i16 FPR64:$src))>;
6593 def : Pat<(f64 (bitconvert (v1i64 FPR64:$src))), (f64 FPR64:$src)>;
6594 def : Pat<(f64 (bitconvert (v1f64 FPR64:$src))), (f64 FPR64:$src)>;
6596 let Predicates = [IsLE] in {
6597 def : Pat<(v1f64 (bitconvert (v2i32 FPR64:$src))), (v1f64 FPR64:$src)>;
6598 def : Pat<(v1f64 (bitconvert (v4i16 FPR64:$src))), (v1f64 FPR64:$src)>;
6599 def : Pat<(v1f64 (bitconvert (v8i8 FPR64:$src))), (v1f64 FPR64:$src)>;
6600 def : Pat<(v1f64 (bitconvert (v2f32 FPR64:$src))), (v1f64 FPR64:$src)>;
6601 def : Pat<(v1f64 (bitconvert (v4f16 FPR64:$src))), (v1f64 FPR64:$src)>;
6603 let Predicates = [IsBE] in {
6604 def : Pat<(v1f64 (bitconvert (v2i32 FPR64:$src))),
6605 (v1f64 (REV64v2i32 FPR64:$src))>;
6606 def : Pat<(v1f64 (bitconvert (v4i16 FPR64:$src))),
6607 (v1f64 (REV64v4i16 FPR64:$src))>;
6608 def : Pat<(v1f64 (bitconvert (v8i8 FPR64:$src))),
6609 (v1f64 (REV64v8i8 FPR64:$src))>;
6610 def : Pat<(v1f64 (bitconvert (v2f32 FPR64:$src))),
6611 (v1f64 (REV64v2i32 FPR64:$src))>;
6612 def : Pat<(v1f64 (bitconvert (v4f16 FPR64:$src))),
6613 (v1f64 (REV64v4i16 FPR64:$src))>;
6615 def : Pat<(v1f64 (bitconvert (v1i64 FPR64:$src))), (v1f64 FPR64:$src)>;
6616 def : Pat<(v1f64 (bitconvert (f64 FPR64:$src))), (v1f64 FPR64:$src)>;
6618 let Predicates = [IsLE] in {
6619 def : Pat<(v2f32 (bitconvert (v1i64 FPR64:$src))), (v2f32 FPR64:$src)>;
6620 def : Pat<(v2f32 (bitconvert (v4i16 FPR64:$src))), (v2f32 FPR64:$src)>;
6621 def : Pat<(v2f32 (bitconvert (v8i8 FPR64:$src))), (v2f32 FPR64:$src)>;
6622 def : Pat<(v2f32 (bitconvert (v1f64 FPR64:$src))), (v2f32 FPR64:$src)>;
6623 def : Pat<(v2f32 (bitconvert (f64 FPR64:$src))), (v2f32 FPR64:$src)>;
6624 def : Pat<(v2f32 (bitconvert (v4f16 FPR64:$src))), (v2f32 FPR64:$src)>;
6626 let Predicates = [IsBE] in {
6627 def : Pat<(v2f32 (bitconvert (v1i64 FPR64:$src))),
6628 (v2f32 (REV64v2i32 FPR64:$src))>;
6629 def : Pat<(v2f32 (bitconvert (v4i16 FPR64:$src))),
6630 (v2f32 (REV32v4i16 FPR64:$src))>;
6631 def : Pat<(v2f32 (bitconvert (v8i8 FPR64:$src))),
6632 (v2f32 (REV32v8i8 FPR64:$src))>;
6633 def : Pat<(v2f32 (bitconvert (v1f64 FPR64:$src))),
6634 (v2f32 (REV64v2i32 FPR64:$src))>;
6635 def : Pat<(v2f32 (bitconvert (f64 FPR64:$src))),
6636 (v2f32 (REV64v2i32 FPR64:$src))>;
6637 def : Pat<(v2f32 (bitconvert (v4f16 FPR64:$src))),
6638 (v2f32 (REV32v4i16 FPR64:$src))>;
6640 def : Pat<(v2f32 (bitconvert (v2i32 FPR64:$src))), (v2f32 FPR64:$src)>;
6642 let Predicates = [IsLE] in {
6643 def : Pat<(f128 (bitconvert (v2i64 FPR128:$src))), (f128 FPR128:$src)>;
6644 def : Pat<(f128 (bitconvert (v4i32 FPR128:$src))), (f128 FPR128:$src)>;
6645 def : Pat<(f128 (bitconvert (v8i16 FPR128:$src))), (f128 FPR128:$src)>;
6646 def : Pat<(f128 (bitconvert (v2f64 FPR128:$src))), (f128 FPR128:$src)>;
6647 def : Pat<(f128 (bitconvert (v4f32 FPR128:$src))), (f128 FPR128:$src)>;
6648 def : Pat<(f128 (bitconvert (v8f16 FPR128:$src))), (f128 FPR128:$src)>;
6649 def : Pat<(f128 (bitconvert (v16i8 FPR128:$src))), (f128 FPR128:$src)>;
6651 let Predicates = [IsBE] in {
6652 def : Pat<(f128 (bitconvert (v2i64 FPR128:$src))),
6653 (f128 (EXTv16i8 FPR128:$src, FPR128:$src, (i32 8)))>;
6654 def : Pat<(f128 (bitconvert (v4i32 FPR128:$src))),
6655 (f128 (EXTv16i8 (REV64v4i32 FPR128:$src),
6656 (REV64v4i32 FPR128:$src), (i32 8)))>;
6657 def : Pat<(f128 (bitconvert (v8i16 FPR128:$src))),
6658 (f128 (EXTv16i8 (REV64v8i16 FPR128:$src),
6659 (REV64v8i16 FPR128:$src), (i32 8)))>;
6660 def : Pat<(f128 (bitconvert (v8f16 FPR128:$src))),
6661 (f128 (EXTv16i8 (REV64v8i16 FPR128:$src),
6662 (REV64v8i16 FPR128:$src), (i32 8)))>;
6663 def : Pat<(f128 (bitconvert (v2f64 FPR128:$src))),
6664 (f128 (EXTv16i8 FPR128:$src, FPR128:$src, (i32 8)))>;
6665 def : Pat<(f128 (bitconvert (v4f32 FPR128:$src))),
6666 (f128 (EXTv16i8 (REV64v4i32 FPR128:$src),
6667 (REV64v4i32 FPR128:$src), (i32 8)))>;
6668 def : Pat<(f128 (bitconvert (v16i8 FPR128:$src))),
6669 (f128 (EXTv16i8 (REV64v16i8 FPR128:$src),
6670 (REV64v16i8 FPR128:$src), (i32 8)))>;
6673 let Predicates = [IsLE] in {
6674 def : Pat<(v2f64 (bitconvert (f128 FPR128:$src))), (v2f64 FPR128:$src)>;
6675 def : Pat<(v2f64 (bitconvert (v4i32 FPR128:$src))), (v2f64 FPR128:$src)>;
6676 def : Pat<(v2f64 (bitconvert (v8i16 FPR128:$src))), (v2f64 FPR128:$src)>;
6677 def : Pat<(v2f64 (bitconvert (v8f16 FPR128:$src))), (v2f64 FPR128:$src)>;
6678 def : Pat<(v2f64 (bitconvert (v16i8 FPR128:$src))), (v2f64 FPR128:$src)>;
6679 def : Pat<(v2f64 (bitconvert (v4f32 FPR128:$src))), (v2f64 FPR128:$src)>;
6681 let Predicates = [IsBE] in {
6682 def : Pat<(v2f64 (bitconvert (f128 FPR128:$src))),
6683 (v2f64 (EXTv16i8 FPR128:$src,
6684 FPR128:$src, (i32 8)))>;
6685 def : Pat<(v2f64 (bitconvert (v4i32 FPR128:$src))),
6686 (v2f64 (REV64v4i32 FPR128:$src))>;
6687 def : Pat<(v2f64 (bitconvert (v8i16 FPR128:$src))),
6688 (v2f64 (REV64v8i16 FPR128:$src))>;
6689 def : Pat<(v2f64 (bitconvert (v8f16 FPR128:$src))),
6690 (v2f64 (REV64v8i16 FPR128:$src))>;
6691 def : Pat<(v2f64 (bitconvert (v16i8 FPR128:$src))),
6692 (v2f64 (REV64v16i8 FPR128:$src))>;
6693 def : Pat<(v2f64 (bitconvert (v4f32 FPR128:$src))),
6694 (v2f64 (REV64v4i32 FPR128:$src))>;
6696 def : Pat<(v2f64 (bitconvert (v2i64 FPR128:$src))), (v2f64 FPR128:$src)>;
6698 let Predicates = [IsLE] in {
6699 def : Pat<(v4f32 (bitconvert (f128 FPR128:$src))), (v4f32 FPR128:$src)>;
6700 def : Pat<(v4f32 (bitconvert (v8i16 FPR128:$src))), (v4f32 FPR128:$src)>;
6701 def : Pat<(v4f32 (bitconvert (v8f16 FPR128:$src))), (v4f32 FPR128:$src)>;
6702 def : Pat<(v4f32 (bitconvert (v16i8 FPR128:$src))), (v4f32 FPR128:$src)>;
6703 def : Pat<(v4f32 (bitconvert (v2i64 FPR128:$src))), (v4f32 FPR128:$src)>;
6704 def : Pat<(v4f32 (bitconvert (v2f64 FPR128:$src))), (v4f32 FPR128:$src)>;
6706 let Predicates = [IsBE] in {
6707 def : Pat<(v4f32 (bitconvert (f128 FPR128:$src))),
6708 (v4f32 (EXTv16i8 (REV64v4i32 FPR128:$src),
6709 (REV64v4i32 FPR128:$src), (i32 8)))>;
6710 def : Pat<(v4f32 (bitconvert (v8i16 FPR128:$src))),
6711 (v4f32 (REV32v8i16 FPR128:$src))>;
6712 def : Pat<(v4f32 (bitconvert (v8f16 FPR128:$src))),
6713 (v4f32 (REV32v8i16 FPR128:$src))>;
6714 def : Pat<(v4f32 (bitconvert (v16i8 FPR128:$src))),
6715 (v4f32 (REV32v16i8 FPR128:$src))>;
6716 def : Pat<(v4f32 (bitconvert (v2i64 FPR128:$src))),
6717 (v4f32 (REV64v4i32 FPR128:$src))>;
6718 def : Pat<(v4f32 (bitconvert (v2f64 FPR128:$src))),
6719 (v4f32 (REV64v4i32 FPR128:$src))>;
6721 def : Pat<(v4f32 (bitconvert (v4i32 FPR128:$src))), (v4f32 FPR128:$src)>;
6723 let Predicates = [IsLE] in {
6724 def : Pat<(v2i64 (bitconvert (f128 FPR128:$src))), (v2i64 FPR128:$src)>;
6725 def : Pat<(v2i64 (bitconvert (v4i32 FPR128:$src))), (v2i64 FPR128:$src)>;
6726 def : Pat<(v2i64 (bitconvert (v8i16 FPR128:$src))), (v2i64 FPR128:$src)>;
6727 def : Pat<(v2i64 (bitconvert (v16i8 FPR128:$src))), (v2i64 FPR128:$src)>;
6728 def : Pat<(v2i64 (bitconvert (v4f32 FPR128:$src))), (v2i64 FPR128:$src)>;
6729 def : Pat<(v2i64 (bitconvert (v8f16 FPR128:$src))), (v2i64 FPR128:$src)>;
6731 let Predicates = [IsBE] in {
6732 def : Pat<(v2i64 (bitconvert (f128 FPR128:$src))),
6733 (v2i64 (EXTv16i8 FPR128:$src,
6734 FPR128:$src, (i32 8)))>;
6735 def : Pat<(v2i64 (bitconvert (v4i32 FPR128:$src))),
6736 (v2i64 (REV64v4i32 FPR128:$src))>;
6737 def : Pat<(v2i64 (bitconvert (v8i16 FPR128:$src))),
6738 (v2i64 (REV64v8i16 FPR128:$src))>;
6739 def : Pat<(v2i64 (bitconvert (v16i8 FPR128:$src))),
6740 (v2i64 (REV64v16i8 FPR128:$src))>;
6741 def : Pat<(v2i64 (bitconvert (v4f32 FPR128:$src))),
6742 (v2i64 (REV64v4i32 FPR128:$src))>;
6743 def : Pat<(v2i64 (bitconvert (v8f16 FPR128:$src))),
6744 (v2i64 (REV64v8i16 FPR128:$src))>;
6746 def : Pat<(v2i64 (bitconvert (v2f64 FPR128:$src))), (v2i64 FPR128:$src)>;
6748 let Predicates = [IsLE] in {
6749 def : Pat<(v4i32 (bitconvert (f128 FPR128:$src))), (v4i32 FPR128:$src)>;
6750 def : Pat<(v4i32 (bitconvert (v2i64 FPR128:$src))), (v4i32 FPR128:$src)>;
6751 def : Pat<(v4i32 (bitconvert (v8i16 FPR128:$src))), (v4i32 FPR128:$src)>;
6752 def : Pat<(v4i32 (bitconvert (v16i8 FPR128:$src))), (v4i32 FPR128:$src)>;
6753 def : Pat<(v4i32 (bitconvert (v2f64 FPR128:$src))), (v4i32 FPR128:$src)>;
6754 def : Pat<(v4i32 (bitconvert (v8f16 FPR128:$src))), (v4i32 FPR128:$src)>;
6756 let Predicates = [IsBE] in {
6757 def : Pat<(v4i32 (bitconvert (f128 FPR128:$src))),
6758 (v4i32 (EXTv16i8 (REV64v4i32 FPR128:$src),
6759 (REV64v4i32 FPR128:$src),
6761 def : Pat<(v4i32 (bitconvert (v2i64 FPR128:$src))),
6762 (v4i32 (REV64v4i32 FPR128:$src))>;
6763 def : Pat<(v4i32 (bitconvert (v8i16 FPR128:$src))),
6764 (v4i32 (REV32v8i16 FPR128:$src))>;
6765 def : Pat<(v4i32 (bitconvert (v16i8 FPR128:$src))),
6766 (v4i32 (REV32v16i8 FPR128:$src))>;
6767 def : Pat<(v4i32 (bitconvert (v2f64 FPR128:$src))),
6768 (v4i32 (REV64v4i32 FPR128:$src))>;
6769 def : Pat<(v4i32 (bitconvert (v8f16 FPR128:$src))),
6770 (v4i32 (REV32v8i16 FPR128:$src))>;
6772 def : Pat<(v4i32 (bitconvert (v4f32 FPR128:$src))), (v4i32 FPR128:$src)>;
6774 let Predicates = [IsLE] in {
6775 def : Pat<(v8i16 (bitconvert (f128 FPR128:$src))), (v8i16 FPR128:$src)>;
6776 def : Pat<(v8i16 (bitconvert (v2i64 FPR128:$src))), (v8i16 FPR128:$src)>;
6777 def : Pat<(v8i16 (bitconvert (v4i32 FPR128:$src))), (v8i16 FPR128:$src)>;
6778 def : Pat<(v8i16 (bitconvert (v16i8 FPR128:$src))), (v8i16 FPR128:$src)>;
6779 def : Pat<(v8i16 (bitconvert (v2f64 FPR128:$src))), (v8i16 FPR128:$src)>;
6780 def : Pat<(v8i16 (bitconvert (v4f32 FPR128:$src))), (v8i16 FPR128:$src)>;
6782 let Predicates = [IsBE] in {
6783 def : Pat<(v8i16 (bitconvert (f128 FPR128:$src))),
6784 (v8i16 (EXTv16i8 (REV64v8i16 FPR128:$src),
6785 (REV64v8i16 FPR128:$src),
6787 def : Pat<(v8i16 (bitconvert (v2i64 FPR128:$src))),
6788 (v8i16 (REV64v8i16 FPR128:$src))>;
6789 def : Pat<(v8i16 (bitconvert (v4i32 FPR128:$src))),
6790 (v8i16 (REV32v8i16 FPR128:$src))>;
6791 def : Pat<(v8i16 (bitconvert (v16i8 FPR128:$src))),
6792 (v8i16 (REV16v16i8 FPR128:$src))>;
6793 def : Pat<(v8i16 (bitconvert (v2f64 FPR128:$src))),
6794 (v8i16 (REV64v8i16 FPR128:$src))>;
6795 def : Pat<(v8i16 (bitconvert (v4f32 FPR128:$src))),
6796 (v8i16 (REV32v8i16 FPR128:$src))>;
6798 def : Pat<(v8i16 (bitconvert (v8f16 FPR128:$src))), (v8i16 FPR128:$src)>;
6800 let Predicates = [IsLE] in {
6801 def : Pat<(v8f16 (bitconvert (f128 FPR128:$src))), (v8f16 FPR128:$src)>;
6802 def : Pat<(v8f16 (bitconvert (v2i64 FPR128:$src))), (v8f16 FPR128:$src)>;
6803 def : Pat<(v8f16 (bitconvert (v4i32 FPR128:$src))), (v8f16 FPR128:$src)>;
6804 def : Pat<(v8f16 (bitconvert (v16i8 FPR128:$src))), (v8f16 FPR128:$src)>;
6805 def : Pat<(v8f16 (bitconvert (v2f64 FPR128:$src))), (v8f16 FPR128:$src)>;
6806 def : Pat<(v8f16 (bitconvert (v4f32 FPR128:$src))), (v8f16 FPR128:$src)>;
6808 let Predicates = [IsBE] in {
6809 def : Pat<(v8f16 (bitconvert (f128 FPR128:$src))),
6810 (v8f16 (EXTv16i8 (REV64v8i16 FPR128:$src),
6811 (REV64v8i16 FPR128:$src),
6813 def : Pat<(v8f16 (bitconvert (v2i64 FPR128:$src))),
6814 (v8f16 (REV64v8i16 FPR128:$src))>;
6815 def : Pat<(v8f16 (bitconvert (v4i32 FPR128:$src))),
6816 (v8f16 (REV32v8i16 FPR128:$src))>;
6817 def : Pat<(v8f16 (bitconvert (v16i8 FPR128:$src))),
6818 (v8f16 (REV16v16i8 FPR128:$src))>;
6819 def : Pat<(v8f16 (bitconvert (v2f64 FPR128:$src))),
6820 (v8f16 (REV64v8i16 FPR128:$src))>;
6821 def : Pat<(v8f16 (bitconvert (v4f32 FPR128:$src))),
6822 (v8f16 (REV32v8i16 FPR128:$src))>;
6824 def : Pat<(v8f16 (bitconvert (v8i16 FPR128:$src))), (v8f16 FPR128:$src)>;
6826 let Predicates = [IsLE] in {
6827 def : Pat<(v16i8 (bitconvert (f128 FPR128:$src))), (v16i8 FPR128:$src)>;
6828 def : Pat<(v16i8 (bitconvert (v2i64 FPR128:$src))), (v16i8 FPR128:$src)>;
6829 def : Pat<(v16i8 (bitconvert (v4i32 FPR128:$src))), (v16i8 FPR128:$src)>;
6830 def : Pat<(v16i8 (bitconvert (v8i16 FPR128:$src))), (v16i8 FPR128:$src)>;
6831 def : Pat<(v16i8 (bitconvert (v2f64 FPR128:$src))), (v16i8 FPR128:$src)>;
6832 def : Pat<(v16i8 (bitconvert (v4f32 FPR128:$src))), (v16i8 FPR128:$src)>;
6833 def : Pat<(v16i8 (bitconvert (v8f16 FPR128:$src))), (v16i8 FPR128:$src)>;
6835 let Predicates = [IsBE] in {
6836 def : Pat<(v16i8 (bitconvert (f128 FPR128:$src))),
6837 (v16i8 (EXTv16i8 (REV64v16i8 FPR128:$src),
6838 (REV64v16i8 FPR128:$src),
6840 def : Pat<(v16i8 (bitconvert (v2i64 FPR128:$src))),
6841 (v16i8 (REV64v16i8 FPR128:$src))>;
6842 def : Pat<(v16i8 (bitconvert (v4i32 FPR128:$src))),
6843 (v16i8 (REV32v16i8 FPR128:$src))>;
6844 def : Pat<(v16i8 (bitconvert (v8i16 FPR128:$src))),
6845 (v16i8 (REV16v16i8 FPR128:$src))>;
6846 def : Pat<(v16i8 (bitconvert (v2f64 FPR128:$src))),
6847 (v16i8 (REV64v16i8 FPR128:$src))>;
6848 def : Pat<(v16i8 (bitconvert (v4f32 FPR128:$src))),
6849 (v16i8 (REV32v16i8 FPR128:$src))>;
6850 def : Pat<(v16i8 (bitconvert (v8f16 FPR128:$src))),
6851 (v16i8 (REV16v16i8 FPR128:$src))>;
6854 def : Pat<(v4i16 (extract_subvector V128:$Rn, (i64 0))),
6855 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6856 def : Pat<(v8i8 (extract_subvector V128:$Rn, (i64 0))),
6857 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6858 def : Pat<(v2f32 (extract_subvector V128:$Rn, (i64 0))),
6859 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6860 def : Pat<(v4f16 (extract_subvector V128:$Rn, (i64 0))),
6861 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6862 def : Pat<(v2i32 (extract_subvector V128:$Rn, (i64 0))),
6863 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6864 def : Pat<(v1i64 (extract_subvector V128:$Rn, (i64 0))),
6865 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6866 def : Pat<(v1f64 (extract_subvector V128:$Rn, (i64 0))),
6867 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6869 def : Pat<(v8i8 (extract_subvector (v16i8 FPR128:$Rn), (i64 1))),
6870 (EXTRACT_SUBREG (DUPv2i64lane FPR128:$Rn, 1), dsub)>;
6871 def : Pat<(v4i16 (extract_subvector (v8i16 FPR128:$Rn), (i64 1))),
6872 (EXTRACT_SUBREG (DUPv2i64lane FPR128:$Rn, 1), dsub)>;
6873 def : Pat<(v2i32 (extract_subvector (v4i32 FPR128:$Rn), (i64 1))),
6874 (EXTRACT_SUBREG (DUPv2i64lane FPR128:$Rn, 1), dsub)>;
6875 def : Pat<(v1i64 (extract_subvector (v2i64 FPR128:$Rn), (i64 1))),
6876 (EXTRACT_SUBREG (DUPv2i64lane FPR128:$Rn, 1), dsub)>;
6878 // A 64-bit subvector insert to the first 128-bit vector position
6879 // is a subregister copy that needs no instruction.
6880 multiclass InsertSubvectorUndef<ValueType Ty> {
6881 def : Pat<(insert_subvector undef, (v1i64 FPR64:$src), (Ty 0)),
6882 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6883 def : Pat<(insert_subvector undef, (v1f64 FPR64:$src), (Ty 0)),
6884 (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6885 def : Pat<(insert_subvector undef, (v2i32 FPR64:$src), (Ty 0)),
6886 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6887 def : Pat<(insert_subvector undef, (v2f32 FPR64:$src), (Ty 0)),
6888 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6889 def : Pat<(insert_subvector undef, (v4i16 FPR64:$src), (Ty 0)),
6890 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6891 def : Pat<(insert_subvector undef, (v4f16 FPR64:$src), (Ty 0)),
6892 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6893 def : Pat<(insert_subvector undef, (v8i8 FPR64:$src), (Ty 0)),
6894 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6897 defm : InsertSubvectorUndef<i32>;
6898 defm : InsertSubvectorUndef<i64>;
6900 // Use pair-wise add instructions when summing up the lanes for v2f64, v2i64
6902 def : Pat<(i64 (add (vector_extract (v2i64 FPR128:$Rn), (i64 0)),
6903 (vector_extract (v2i64 FPR128:$Rn), (i64 1)))),
6904 (i64 (ADDPv2i64p (v2i64 FPR128:$Rn)))>;
6905 def : Pat<(f64 (fadd (vector_extract (v2f64 FPR128:$Rn), (i64 0)),
6906 (vector_extract (v2f64 FPR128:$Rn), (i64 1)))),
6907 (f64 (FADDPv2i64p (v2f64 FPR128:$Rn)))>;
6908 // vector_extract on 64-bit vectors gets promoted to a 128 bit vector,
6909 // so we match on v4f32 here, not v2f32. This will also catch adding
6910 // the low two lanes of a true v4f32 vector.
6911 def : Pat<(fadd (vector_extract (v4f32 FPR128:$Rn), (i64 0)),
6912 (vector_extract (v4f32 FPR128:$Rn), (i64 1))),
6913 (f32 (FADDPv2i32p (EXTRACT_SUBREG FPR128:$Rn, dsub)))>;
6915 // Scalar 64-bit shifts in FPR64 registers.
6916 def : Pat<(i64 (int_aarch64_neon_sshl (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
6917 (SSHLv1i64 FPR64:$Rn, FPR64:$Rm)>;
6918 def : Pat<(i64 (int_aarch64_neon_ushl (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
6919 (USHLv1i64 FPR64:$Rn, FPR64:$Rm)>;
6920 def : Pat<(i64 (int_aarch64_neon_srshl (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
6921 (SRSHLv1i64 FPR64:$Rn, FPR64:$Rm)>;
6922 def : Pat<(i64 (int_aarch64_neon_urshl (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
6923 (URSHLv1i64 FPR64:$Rn, FPR64:$Rm)>;
6925 // Patterns for nontemporal/no-allocate stores.
6926 // We have to resort to tricks to turn a single-input store into a store pair,
6927 // because there is no single-input nontemporal store, only STNP.
6928 let Predicates = [IsLE] in {
6929 let AddedComplexity = 15 in {
6930 class NTStore128Pat<ValueType VT> :
6931 Pat<(nontemporalstore (VT FPR128:$Rt),
6932 (am_indexed7s64 GPR64sp:$Rn, simm7s8:$offset)),
6933 (STNPDi (EXTRACT_SUBREG FPR128:$Rt, dsub),
6934 (CPYi64 FPR128:$Rt, (i64 1)),
6935 GPR64sp:$Rn, simm7s8:$offset)>;
6937 def : NTStore128Pat<v2i64>;
6938 def : NTStore128Pat<v4i32>;
6939 def : NTStore128Pat<v8i16>;
6940 def : NTStore128Pat<v16i8>;
6942 class NTStore64Pat<ValueType VT> :
6943 Pat<(nontemporalstore (VT FPR64:$Rt),
6944 (am_indexed7s32 GPR64sp:$Rn, simm7s4:$offset)),
6945 (STNPSi (EXTRACT_SUBREG FPR64:$Rt, ssub),
6946 (CPYi32 (SUBREG_TO_REG (i64 0), FPR64:$Rt, dsub), (i64 1)),
6947 GPR64sp:$Rn, simm7s4:$offset)>;
6949 // FIXME: Shouldn't v1f64 loads/stores be promoted to v1i64?
6950 def : NTStore64Pat<v1f64>;
6951 def : NTStore64Pat<v1i64>;
6952 def : NTStore64Pat<v2i32>;
6953 def : NTStore64Pat<v4i16>;
6954 def : NTStore64Pat<v8i8>;
6956 def : Pat<(nontemporalstore GPR64:$Rt,
6957 (am_indexed7s32 GPR64sp:$Rn, simm7s4:$offset)),
6958 (STNPWi (EXTRACT_SUBREG GPR64:$Rt, sub_32),
6959 (EXTRACT_SUBREG (UBFMXri GPR64:$Rt, 32, 63), sub_32),
6960 GPR64sp:$Rn, simm7s4:$offset)>;
6961 } // AddedComplexity=10
6962 } // Predicates = [IsLE]
6964 // Tail call return handling. These are all compiler pseudo-instructions,
6965 // so no encoding information or anything like that.
6966 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in {
6967 def TCRETURNdi : Pseudo<(outs), (ins i64imm:$dst, i32imm:$FPDiff), []>,
6968 Sched<[WriteBrReg]>;
6969 def TCRETURNri : Pseudo<(outs), (ins tcGPR64:$dst, i32imm:$FPDiff), []>,
6970 Sched<[WriteBrReg]>;
6971 // Indirect tail-call with any register allowed, used by MachineOutliner when
6972 // this is proven safe.
6973 // FIXME: If we have to add any more hacks like this, we should instead relax
6974 // some verifier checks for outlined functions.
6975 def TCRETURNriALL : Pseudo<(outs), (ins GPR64:$dst, i32imm:$FPDiff), []>,
6976 Sched<[WriteBrReg]>;
6977 // Indirect tail-call limited to only use registers (x16 and x17) which are
6978 // allowed to tail-call a "BTI c" instruction.
6979 def TCRETURNriBTI : Pseudo<(outs), (ins rtcGPR64:$dst, i32imm:$FPDiff), []>,
6980 Sched<[WriteBrReg]>;
6983 def : Pat<(AArch64tcret tcGPR64:$dst, (i32 timm:$FPDiff)),
6984 (TCRETURNri tcGPR64:$dst, imm:$FPDiff)>,
6985 Requires<[NotUseBTI]>;
6986 def : Pat<(AArch64tcret rtcGPR64:$dst, (i32 timm:$FPDiff)),
6987 (TCRETURNriBTI rtcGPR64:$dst, imm:$FPDiff)>,
6989 def : Pat<(AArch64tcret tglobaladdr:$dst, (i32 timm:$FPDiff)),
6990 (TCRETURNdi texternalsym:$dst, imm:$FPDiff)>;
6991 def : Pat<(AArch64tcret texternalsym:$dst, (i32 timm:$FPDiff)),
6992 (TCRETURNdi texternalsym:$dst, imm:$FPDiff)>;
6994 def MOVMCSym : Pseudo<(outs GPR64:$dst), (ins i64imm:$sym), []>, Sched<[]>;
6995 def : Pat<(i64 (AArch64LocalRecover mcsym:$sym)), (MOVMCSym mcsym:$sym)>;
6997 // Extracting lane zero is a special case where we can just use a plain
6998 // EXTRACT_SUBREG instruction, which will become FMOV. This is easier for the
6999 // rest of the compiler, especially the register allocator and copy propagation,
7000 // to reason about, so is preferred when it's possible to use it.
7001 let AddedComplexity = 10 in {
7002 def : Pat<(i64 (extractelt (v2i64 V128:$V), (i64 0))), (EXTRACT_SUBREG V128:$V, dsub)>;
7003 def : Pat<(i32 (extractelt (v4i32 V128:$V), (i64 0))), (EXTRACT_SUBREG V128:$V, ssub)>;
7004 def : Pat<(i32 (extractelt (v2i32 V64:$V), (i64 0))), (EXTRACT_SUBREG V64:$V, ssub)>;
7008 class mul_v4i8<SDPatternOperator ldop> :
7009 PatFrag<(ops node:$Rn, node:$Rm, node:$offset),
7010 (mul (ldop (add node:$Rn, node:$offset)),
7011 (ldop (add node:$Rm, node:$offset)))>;
7012 class mulz_v4i8<SDPatternOperator ldop> :
7013 PatFrag<(ops node:$Rn, node:$Rm),
7014 (mul (ldop node:$Rn), (ldop node:$Rm))>;
7017 OutPatFrag<(ops node:$R),
7019 (v2i32 (IMPLICIT_DEF)),
7020 (i32 (COPY_TO_REGCLASS (LDRWui node:$R, (i64 0)), FPR32)),
7023 class dot_v4i8<Instruction DOT, SDPatternOperator ldop> :
7024 Pat<(i32 (add (mul_v4i8<ldop> GPR64sp:$Rn, GPR64sp:$Rm, (i64 3)),
7025 (add (mul_v4i8<ldop> GPR64sp:$Rn, GPR64sp:$Rm, (i64 2)),
7026 (add (mul_v4i8<ldop> GPR64sp:$Rn, GPR64sp:$Rm, (i64 1)),
7027 (mulz_v4i8<ldop> GPR64sp:$Rn, GPR64sp:$Rm))))),
7028 (EXTRACT_SUBREG (i64 (DOT (DUPv2i32gpr WZR),
7029 (load_v4i8 GPR64sp:$Rn),
7030 (load_v4i8 GPR64sp:$Rm))),
7031 sub_32)>, Requires<[HasDotProd]>;
7034 class ee_v8i8<SDPatternOperator extend> :
7035 PatFrag<(ops node:$V, node:$K),
7036 (v4i16 (extract_subvector (v8i16 (extend node:$V)), node:$K))>;
7038 class mul_v8i8<SDPatternOperator mulop, SDPatternOperator extend> :
7039 PatFrag<(ops node:$M, node:$N, node:$K),
7040 (mulop (v4i16 (ee_v8i8<extend> node:$M, node:$K)),
7041 (v4i16 (ee_v8i8<extend> node:$N, node:$K)))>;
7043 class idot_v8i8<SDPatternOperator mulop, SDPatternOperator extend> :
7044 PatFrag<(ops node:$M, node:$N),
7046 (v4i32 (AArch64uaddv
7047 (add (mul_v8i8<mulop, extend> node:$M, node:$N, (i64 0)),
7048 (mul_v8i8<mulop, extend> node:$M, node:$N, (i64 4))))),
7051 // vaddv_[su]32 is special; -> ADDP Vd.2S,Vn.2S,Vm.2S; return Vd.s[0];Vn==Vm
7052 def VADDV_32 : OutPatFrag<(ops node:$R), (ADDPv2i32 node:$R, node:$R)>;
7054 class odot_v8i8<Instruction DOT> :
7055 OutPatFrag<(ops node:$Vm, node:$Vn),
7058 (i64 (DOT (DUPv2i32gpr WZR),
7063 class dot_v8i8<Instruction DOT, SDPatternOperator mulop,
7064 SDPatternOperator extend> :
7065 Pat<(idot_v8i8<mulop, extend> V64:$Vm, V64:$Vn),
7066 (odot_v8i8<DOT> V64:$Vm, V64:$Vn)>,
7067 Requires<[HasDotProd]>;
7070 class ee_v16i8<SDPatternOperator extend> :
7071 PatFrag<(ops node:$V, node:$K1, node:$K2),
7072 (v4i16 (extract_subvector
7074 (v8i8 (extract_subvector node:$V, node:$K1)))), node:$K2))>;
7076 class mul_v16i8<SDPatternOperator mulop, SDPatternOperator extend> :
7077 PatFrag<(ops node:$M, node:$N, node:$K1, node:$K2),
7079 (mulop (v4i16 (ee_v16i8<extend> node:$M, node:$K1, node:$K2)),
7080 (v4i16 (ee_v16i8<extend> node:$N, node:$K1, node:$K2))))>;
7082 class idot_v16i8<SDPatternOperator m, SDPatternOperator x> :
7083 PatFrag<(ops node:$M, node:$N),
7085 (v4i32 (AArch64uaddv
7087 (add (mul_v16i8<m, x> node:$M, node:$N, (i64 0), (i64 0)),
7088 (mul_v16i8<m, x> node:$M, node:$N, (i64 8), (i64 0))),
7089 (add (mul_v16i8<m, x> node:$M, node:$N, (i64 0), (i64 4)),
7090 (mul_v16i8<m, x> node:$M, node:$N, (i64 8), (i64 4)))))),
7093 class odot_v16i8<Instruction DOT> :
7094 OutPatFrag<(ops node:$Vm, node:$Vn),
7096 (DOT (DUPv4i32gpr WZR), node:$Vm, node:$Vn)))>;
7098 class dot_v16i8<Instruction DOT, SDPatternOperator mulop,
7099 SDPatternOperator extend> :
7100 Pat<(idot_v16i8<mulop, extend> V128:$Vm, V128:$Vn),
7101 (odot_v16i8<DOT> V128:$Vm, V128:$Vn)>,
7102 Requires<[HasDotProd]>;
7104 let AddedComplexity = 10 in {
7105 def : dot_v4i8<SDOTv8i8, sextloadi8>;
7106 def : dot_v4i8<UDOTv8i8, zextloadi8>;
7107 def : dot_v8i8<SDOTv8i8, AArch64smull, sext>;
7108 def : dot_v8i8<UDOTv8i8, AArch64umull, zext>;
7109 def : dot_v16i8<SDOTv16i8, AArch64smull, sext>;
7110 def : dot_v16i8<UDOTv16i8, AArch64umull, zext>;
7112 // FIXME: add patterns to generate vector by element dot product.
7113 // FIXME: add SVE dot-product patterns.
7116 include "AArch64InstrAtomics.td"
7117 include "AArch64SVEInstrInfo.td"