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 imm:$accessinfo))]>,
805 // The cycle counter PMC register is PMCCNTR_EL0.
806 let Predicates = [HasPerfMon] in
807 def : Pat<(readcyclecounter), (MRS 0xdce8)>;
810 def : Pat<(i64 (int_aarch64_get_fpcr)), (MRS 0xda20)>;
812 // Generic system instructions
813 def SYSxt : SystemXtI<0, "sys">;
814 def SYSLxt : SystemLXtI<1, "sysl">;
816 def : InstAlias<"sys $op1, $Cn, $Cm, $op2",
817 (SYSxt imm0_7:$op1, sys_cr_op:$Cn,
818 sys_cr_op:$Cm, imm0_7:$op2, XZR)>;
821 let Predicates = [HasTME] in {
823 def TSTART : TMSystemI<0b0000, "tstart",
824 [(set GPR64:$Rt, (int_aarch64_tstart))]>;
826 def TCOMMIT : TMSystemINoOperand<0b0000, "tcommit", [(int_aarch64_tcommit)]>;
828 def TCANCEL : TMSystemException<0b011, "tcancel",
829 [(int_aarch64_tcancel i64_imm0_65535:$imm)]>;
831 def TTEST : TMSystemI<0b0001, "ttest", [(set GPR64:$Rt, (int_aarch64_ttest))]> {
837 //===----------------------------------------------------------------------===//
838 // Move immediate instructions.
839 //===----------------------------------------------------------------------===//
841 defm MOVK : InsertImmediate<0b11, "movk">;
842 defm MOVN : MoveImmediate<0b00, "movn">;
844 let PostEncoderMethod = "fixMOVZ" in
845 defm MOVZ : MoveImmediate<0b10, "movz">;
847 // First group of aliases covers an implicit "lsl #0".
848 def : InstAlias<"movk $dst, $imm", (MOVKWi GPR32:$dst, i32_imm0_65535:$imm, 0), 0>;
849 def : InstAlias<"movk $dst, $imm", (MOVKXi GPR64:$dst, i32_imm0_65535:$imm, 0), 0>;
850 def : InstAlias<"movn $dst, $imm", (MOVNWi GPR32:$dst, i32_imm0_65535:$imm, 0)>;
851 def : InstAlias<"movn $dst, $imm", (MOVNXi GPR64:$dst, i32_imm0_65535:$imm, 0)>;
852 def : InstAlias<"movz $dst, $imm", (MOVZWi GPR32:$dst, i32_imm0_65535:$imm, 0)>;
853 def : InstAlias<"movz $dst, $imm", (MOVZXi GPR64:$dst, i32_imm0_65535:$imm, 0)>;
855 // Next, we have various ELF relocations with the ":XYZ_g0:sym" syntax.
856 def : InstAlias<"movz $Rd, $sym", (MOVZXi GPR64:$Rd, movw_symbol_g3:$sym, 48)>;
857 def : InstAlias<"movz $Rd, $sym", (MOVZXi GPR64:$Rd, movw_symbol_g2:$sym, 32)>;
858 def : InstAlias<"movz $Rd, $sym", (MOVZXi GPR64:$Rd, movw_symbol_g1:$sym, 16)>;
859 def : InstAlias<"movz $Rd, $sym", (MOVZXi GPR64:$Rd, movw_symbol_g0:$sym, 0)>;
861 def : InstAlias<"movn $Rd, $sym", (MOVNXi GPR64:$Rd, movw_symbol_g3:$sym, 48)>;
862 def : InstAlias<"movn $Rd, $sym", (MOVNXi GPR64:$Rd, movw_symbol_g2:$sym, 32)>;
863 def : InstAlias<"movn $Rd, $sym", (MOVNXi GPR64:$Rd, movw_symbol_g1:$sym, 16)>;
864 def : InstAlias<"movn $Rd, $sym", (MOVNXi GPR64:$Rd, movw_symbol_g0:$sym, 0)>;
866 def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movw_symbol_g3:$sym, 48), 0>;
867 def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movw_symbol_g2:$sym, 32), 0>;
868 def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movw_symbol_g1:$sym, 16), 0>;
869 def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movw_symbol_g0:$sym, 0), 0>;
871 def : InstAlias<"movz $Rd, $sym", (MOVZWi GPR32:$Rd, movw_symbol_g1:$sym, 16)>;
872 def : InstAlias<"movz $Rd, $sym", (MOVZWi GPR32:$Rd, movw_symbol_g0:$sym, 0)>;
874 def : InstAlias<"movn $Rd, $sym", (MOVNWi GPR32:$Rd, movw_symbol_g1:$sym, 16)>;
875 def : InstAlias<"movn $Rd, $sym", (MOVNWi GPR32:$Rd, movw_symbol_g0:$sym, 0)>;
877 def : InstAlias<"movk $Rd, $sym", (MOVKWi GPR32:$Rd, movw_symbol_g1:$sym, 16), 0>;
878 def : InstAlias<"movk $Rd, $sym", (MOVKWi GPR32:$Rd, movw_symbol_g0:$sym, 0), 0>;
880 // Final group of aliases covers true "mov $Rd, $imm" cases.
881 multiclass movw_mov_alias<string basename,Instruction INST, RegisterClass GPR,
882 int width, int shift> {
883 def _asmoperand : AsmOperandClass {
884 let Name = basename # width # "_lsl" # shift # "MovAlias";
885 let PredicateMethod = "is" # basename # "MovAlias<" # width # ", "
887 let RenderMethod = "add" # basename # "MovAliasOperands<" # shift # ">";
890 def _movimm : Operand<i32> {
891 let ParserMatchClass = !cast<AsmOperandClass>(NAME # "_asmoperand");
894 def : InstAlias<"mov $Rd, $imm",
895 (INST GPR:$Rd, !cast<Operand>(NAME # "_movimm"):$imm, shift)>;
898 defm : movw_mov_alias<"MOVZ", MOVZWi, GPR32, 32, 0>;
899 defm : movw_mov_alias<"MOVZ", MOVZWi, GPR32, 32, 16>;
901 defm : movw_mov_alias<"MOVZ", MOVZXi, GPR64, 64, 0>;
902 defm : movw_mov_alias<"MOVZ", MOVZXi, GPR64, 64, 16>;
903 defm : movw_mov_alias<"MOVZ", MOVZXi, GPR64, 64, 32>;
904 defm : movw_mov_alias<"MOVZ", MOVZXi, GPR64, 64, 48>;
906 defm : movw_mov_alias<"MOVN", MOVNWi, GPR32, 32, 0>;
907 defm : movw_mov_alias<"MOVN", MOVNWi, GPR32, 32, 16>;
909 defm : movw_mov_alias<"MOVN", MOVNXi, GPR64, 64, 0>;
910 defm : movw_mov_alias<"MOVN", MOVNXi, GPR64, 64, 16>;
911 defm : movw_mov_alias<"MOVN", MOVNXi, GPR64, 64, 32>;
912 defm : movw_mov_alias<"MOVN", MOVNXi, GPR64, 64, 48>;
914 let isReMaterializable = 1, isCodeGenOnly = 1, isMoveImm = 1,
915 isAsCheapAsAMove = 1 in {
916 // FIXME: The following pseudo instructions are only needed because remat
917 // cannot handle multiple instructions. When that changes, we can select
918 // directly to the real instructions and get rid of these pseudos.
921 : Pseudo<(outs GPR32:$dst), (ins i32imm:$src),
922 [(set GPR32:$dst, imm:$src)]>,
925 : Pseudo<(outs GPR64:$dst), (ins i64imm:$src),
926 [(set GPR64:$dst, imm:$src)]>,
928 } // isReMaterializable, isCodeGenOnly
930 // If possible, we want to use MOVi32imm even for 64-bit moves. This gives the
931 // eventual expansion code fewer bits to worry about getting right. Marshalling
932 // the types is a little tricky though:
933 def i64imm_32bit : ImmLeaf<i64, [{
934 return (Imm & 0xffffffffULL) == static_cast<uint64_t>(Imm);
937 def s64imm_32bit : ImmLeaf<i64, [{
938 int64_t Imm64 = static_cast<int64_t>(Imm);
939 return Imm64 >= std::numeric_limits<int32_t>::min() &&
940 Imm64 <= std::numeric_limits<int32_t>::max();
943 def trunc_imm : SDNodeXForm<imm, [{
944 return CurDAG->getTargetConstant(N->getZExtValue(), SDLoc(N), MVT::i32);
947 def gi_trunc_imm : GICustomOperandRenderer<"renderTruncImm">,
948 GISDNodeXFormEquiv<trunc_imm>;
950 let Predicates = [OptimizedGISelOrOtherSelector] in {
951 // The SUBREG_TO_REG isn't eliminated at -O0, which can result in pointless
953 def : Pat<(i64 i64imm_32bit:$src),
954 (SUBREG_TO_REG (i64 0), (MOVi32imm (trunc_imm imm:$src)), sub_32)>;
957 // Materialize FP constants via MOVi32imm/MOVi64imm (MachO large code model).
958 def bitcast_fpimm_to_i32 : SDNodeXForm<fpimm, [{
959 return CurDAG->getTargetConstant(
960 N->getValueAPF().bitcastToAPInt().getZExtValue(), SDLoc(N), MVT::i32);
963 def bitcast_fpimm_to_i64 : SDNodeXForm<fpimm, [{
964 return CurDAG->getTargetConstant(
965 N->getValueAPF().bitcastToAPInt().getZExtValue(), SDLoc(N), MVT::i64);
969 def : Pat<(f32 fpimm:$in),
970 (COPY_TO_REGCLASS (MOVi32imm (bitcast_fpimm_to_i32 f32:$in)), FPR32)>;
971 def : Pat<(f64 fpimm:$in),
972 (COPY_TO_REGCLASS (MOVi64imm (bitcast_fpimm_to_i64 f64:$in)), FPR64)>;
975 // Deal with the various forms of (ELF) large addressing with MOVZ/MOVK
977 def : Pat<(AArch64WrapperLarge tglobaladdr:$g3, tglobaladdr:$g2,
978 tglobaladdr:$g1, tglobaladdr:$g0),
979 (MOVKXi (MOVKXi (MOVKXi (MOVZXi tglobaladdr:$g0, 0),
980 tglobaladdr:$g1, 16),
981 tglobaladdr:$g2, 32),
982 tglobaladdr:$g3, 48)>;
984 def : Pat<(AArch64WrapperLarge tblockaddress:$g3, tblockaddress:$g2,
985 tblockaddress:$g1, tblockaddress:$g0),
986 (MOVKXi (MOVKXi (MOVKXi (MOVZXi tblockaddress:$g0, 0),
987 tblockaddress:$g1, 16),
988 tblockaddress:$g2, 32),
989 tblockaddress:$g3, 48)>;
991 def : Pat<(AArch64WrapperLarge tconstpool:$g3, tconstpool:$g2,
992 tconstpool:$g1, tconstpool:$g0),
993 (MOVKXi (MOVKXi (MOVKXi (MOVZXi tconstpool:$g0, 0),
996 tconstpool:$g3, 48)>;
998 def : Pat<(AArch64WrapperLarge tjumptable:$g3, tjumptable:$g2,
999 tjumptable:$g1, tjumptable:$g0),
1000 (MOVKXi (MOVKXi (MOVKXi (MOVZXi tjumptable:$g0, 0),
1001 tjumptable:$g1, 16),
1002 tjumptable:$g2, 32),
1003 tjumptable:$g3, 48)>;
1006 //===----------------------------------------------------------------------===//
1007 // Arithmetic instructions.
1008 //===----------------------------------------------------------------------===//
1010 // Add/subtract with carry.
1011 defm ADC : AddSubCarry<0, "adc", "adcs", AArch64adc, AArch64adc_flag>;
1012 defm SBC : AddSubCarry<1, "sbc", "sbcs", AArch64sbc, AArch64sbc_flag>;
1014 def : InstAlias<"ngc $dst, $src", (SBCWr GPR32:$dst, WZR, GPR32:$src)>;
1015 def : InstAlias<"ngc $dst, $src", (SBCXr GPR64:$dst, XZR, GPR64:$src)>;
1016 def : InstAlias<"ngcs $dst, $src", (SBCSWr GPR32:$dst, WZR, GPR32:$src)>;
1017 def : InstAlias<"ngcs $dst, $src", (SBCSXr GPR64:$dst, XZR, GPR64:$src)>;
1020 defm ADD : AddSub<0, "add", "sub", add>;
1021 defm SUB : AddSub<1, "sub", "add">;
1023 def : InstAlias<"mov $dst, $src",
1024 (ADDWri GPR32sponly:$dst, GPR32sp:$src, 0, 0)>;
1025 def : InstAlias<"mov $dst, $src",
1026 (ADDWri GPR32sp:$dst, GPR32sponly:$src, 0, 0)>;
1027 def : InstAlias<"mov $dst, $src",
1028 (ADDXri GPR64sponly:$dst, GPR64sp:$src, 0, 0)>;
1029 def : InstAlias<"mov $dst, $src",
1030 (ADDXri GPR64sp:$dst, GPR64sponly:$src, 0, 0)>;
1032 defm ADDS : AddSubS<0, "adds", AArch64add_flag, "cmn", "subs", "cmp">;
1033 defm SUBS : AddSubS<1, "subs", AArch64sub_flag, "cmp", "adds", "cmn">;
1035 // Use SUBS instead of SUB to enable CSE between SUBS and SUB.
1036 def : Pat<(sub GPR32sp:$Rn, addsub_shifted_imm32:$imm),
1037 (SUBSWri GPR32sp:$Rn, addsub_shifted_imm32:$imm)>;
1038 def : Pat<(sub GPR64sp:$Rn, addsub_shifted_imm64:$imm),
1039 (SUBSXri GPR64sp:$Rn, addsub_shifted_imm64:$imm)>;
1040 def : Pat<(sub GPR32:$Rn, GPR32:$Rm),
1041 (SUBSWrr GPR32:$Rn, GPR32:$Rm)>;
1042 def : Pat<(sub GPR64:$Rn, GPR64:$Rm),
1043 (SUBSXrr GPR64:$Rn, GPR64:$Rm)>;
1044 def : Pat<(sub GPR32:$Rn, arith_shifted_reg32:$Rm),
1045 (SUBSWrs GPR32:$Rn, arith_shifted_reg32:$Rm)>;
1046 def : Pat<(sub GPR64:$Rn, arith_shifted_reg64:$Rm),
1047 (SUBSXrs GPR64:$Rn, arith_shifted_reg64:$Rm)>;
1048 let AddedComplexity = 1 in {
1049 def : Pat<(sub GPR32sp:$R2, arith_extended_reg32_i32:$R3),
1050 (SUBSWrx GPR32sp:$R2, arith_extended_reg32_i32:$R3)>;
1051 def : Pat<(sub GPR64sp:$R2, arith_extended_reg32to64_i64:$R3),
1052 (SUBSXrx GPR64sp:$R2, arith_extended_reg32to64_i64:$R3)>;
1055 // Because of the immediate format for add/sub-imm instructions, the
1056 // expression (add x, -1) must be transformed to (SUB{W,X}ri x, 1).
1057 // These patterns capture that transformation.
1058 let AddedComplexity = 1 in {
1059 def : Pat<(add GPR32:$Rn, neg_addsub_shifted_imm32:$imm),
1060 (SUBSWri GPR32:$Rn, neg_addsub_shifted_imm32:$imm)>;
1061 def : Pat<(add GPR64:$Rn, neg_addsub_shifted_imm64:$imm),
1062 (SUBSXri GPR64:$Rn, neg_addsub_shifted_imm64:$imm)>;
1063 def : Pat<(sub GPR32:$Rn, neg_addsub_shifted_imm32:$imm),
1064 (ADDWri GPR32:$Rn, neg_addsub_shifted_imm32:$imm)>;
1065 def : Pat<(sub GPR64:$Rn, neg_addsub_shifted_imm64:$imm),
1066 (ADDXri GPR64:$Rn, neg_addsub_shifted_imm64:$imm)>;
1069 // Because of the immediate format for add/sub-imm instructions, the
1070 // expression (add x, -1) must be transformed to (SUB{W,X}ri x, 1).
1071 // These patterns capture that transformation.
1072 let AddedComplexity = 1 in {
1073 def : Pat<(AArch64add_flag GPR32:$Rn, neg_addsub_shifted_imm32:$imm),
1074 (SUBSWri GPR32:$Rn, neg_addsub_shifted_imm32:$imm)>;
1075 def : Pat<(AArch64add_flag GPR64:$Rn, neg_addsub_shifted_imm64:$imm),
1076 (SUBSXri GPR64:$Rn, neg_addsub_shifted_imm64:$imm)>;
1077 def : Pat<(AArch64sub_flag GPR32:$Rn, neg_addsub_shifted_imm32:$imm),
1078 (ADDSWri GPR32:$Rn, neg_addsub_shifted_imm32:$imm)>;
1079 def : Pat<(AArch64sub_flag GPR64:$Rn, neg_addsub_shifted_imm64:$imm),
1080 (ADDSXri GPR64:$Rn, neg_addsub_shifted_imm64:$imm)>;
1083 def : InstAlias<"neg $dst, $src", (SUBWrs GPR32:$dst, WZR, GPR32:$src, 0), 3>;
1084 def : InstAlias<"neg $dst, $src", (SUBXrs GPR64:$dst, XZR, GPR64:$src, 0), 3>;
1085 def : InstAlias<"neg $dst, $src$shift",
1086 (SUBWrs GPR32:$dst, WZR, GPR32:$src, arith_shift32:$shift), 2>;
1087 def : InstAlias<"neg $dst, $src$shift",
1088 (SUBXrs GPR64:$dst, XZR, GPR64:$src, arith_shift64:$shift), 2>;
1090 def : InstAlias<"negs $dst, $src", (SUBSWrs GPR32:$dst, WZR, GPR32:$src, 0), 3>;
1091 def : InstAlias<"negs $dst, $src", (SUBSXrs GPR64:$dst, XZR, GPR64:$src, 0), 3>;
1092 def : InstAlias<"negs $dst, $src$shift",
1093 (SUBSWrs GPR32:$dst, WZR, GPR32:$src, arith_shift32:$shift), 2>;
1094 def : InstAlias<"negs $dst, $src$shift",
1095 (SUBSXrs GPR64:$dst, XZR, GPR64:$src, arith_shift64:$shift), 2>;
1098 // Unsigned/Signed divide
1099 defm UDIV : Div<0, "udiv", udiv>;
1100 defm SDIV : Div<1, "sdiv", sdiv>;
1102 def : Pat<(int_aarch64_udiv GPR32:$Rn, GPR32:$Rm), (UDIVWr GPR32:$Rn, GPR32:$Rm)>;
1103 def : Pat<(int_aarch64_udiv GPR64:$Rn, GPR64:$Rm), (UDIVXr GPR64:$Rn, GPR64:$Rm)>;
1104 def : Pat<(int_aarch64_sdiv GPR32:$Rn, GPR32:$Rm), (SDIVWr GPR32:$Rn, GPR32:$Rm)>;
1105 def : Pat<(int_aarch64_sdiv GPR64:$Rn, GPR64:$Rm), (SDIVXr GPR64:$Rn, GPR64:$Rm)>;
1108 defm ASRV : Shift<0b10, "asr", sra>;
1109 defm LSLV : Shift<0b00, "lsl", shl>;
1110 defm LSRV : Shift<0b01, "lsr", srl>;
1111 defm RORV : Shift<0b11, "ror", rotr>;
1113 def : ShiftAlias<"asrv", ASRVWr, GPR32>;
1114 def : ShiftAlias<"asrv", ASRVXr, GPR64>;
1115 def : ShiftAlias<"lslv", LSLVWr, GPR32>;
1116 def : ShiftAlias<"lslv", LSLVXr, GPR64>;
1117 def : ShiftAlias<"lsrv", LSRVWr, GPR32>;
1118 def : ShiftAlias<"lsrv", LSRVXr, GPR64>;
1119 def : ShiftAlias<"rorv", RORVWr, GPR32>;
1120 def : ShiftAlias<"rorv", RORVXr, GPR64>;
1123 let AddedComplexity = 5 in {
1124 defm MADD : MulAccum<0, "madd", add>;
1125 defm MSUB : MulAccum<1, "msub", sub>;
1127 def : Pat<(i32 (mul GPR32:$Rn, GPR32:$Rm)),
1128 (MADDWrrr GPR32:$Rn, GPR32:$Rm, WZR)>;
1129 def : Pat<(i64 (mul GPR64:$Rn, GPR64:$Rm)),
1130 (MADDXrrr GPR64:$Rn, GPR64:$Rm, XZR)>;
1132 def : Pat<(i32 (ineg (mul GPR32:$Rn, GPR32:$Rm))),
1133 (MSUBWrrr GPR32:$Rn, GPR32:$Rm, WZR)>;
1134 def : Pat<(i64 (ineg (mul GPR64:$Rn, GPR64:$Rm))),
1135 (MSUBXrrr GPR64:$Rn, GPR64:$Rm, XZR)>;
1136 def : Pat<(i32 (mul (ineg GPR32:$Rn), GPR32:$Rm)),
1137 (MSUBWrrr GPR32:$Rn, GPR32:$Rm, WZR)>;
1138 def : Pat<(i64 (mul (ineg GPR64:$Rn), GPR64:$Rm)),
1139 (MSUBXrrr GPR64:$Rn, GPR64:$Rm, XZR)>;
1140 } // AddedComplexity = 5
1142 let AddedComplexity = 5 in {
1143 def SMADDLrrr : WideMulAccum<0, 0b001, "smaddl", add, sext>;
1144 def SMSUBLrrr : WideMulAccum<1, 0b001, "smsubl", sub, sext>;
1145 def UMADDLrrr : WideMulAccum<0, 0b101, "umaddl", add, zext>;
1146 def UMSUBLrrr : WideMulAccum<1, 0b101, "umsubl", sub, zext>;
1148 def : Pat<(i64 (mul (sext GPR32:$Rn), (sext GPR32:$Rm))),
1149 (SMADDLrrr GPR32:$Rn, GPR32:$Rm, XZR)>;
1150 def : Pat<(i64 (mul (zext GPR32:$Rn), (zext GPR32:$Rm))),
1151 (UMADDLrrr GPR32:$Rn, GPR32:$Rm, XZR)>;
1153 def : Pat<(i64 (ineg (mul (sext GPR32:$Rn), (sext GPR32:$Rm)))),
1154 (SMSUBLrrr GPR32:$Rn, GPR32:$Rm, XZR)>;
1155 def : Pat<(i64 (ineg (mul (zext GPR32:$Rn), (zext GPR32:$Rm)))),
1156 (UMSUBLrrr GPR32:$Rn, GPR32:$Rm, XZR)>;
1158 def : Pat<(i64 (mul (sext GPR32:$Rn), (s64imm_32bit:$C))),
1159 (SMADDLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1160 def : Pat<(i64 (mul (zext GPR32:$Rn), (i64imm_32bit:$C))),
1161 (UMADDLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1162 def : Pat<(i64 (mul (sext_inreg GPR64:$Rn, i32), (s64imm_32bit:$C))),
1163 (SMADDLrrr (i32 (EXTRACT_SUBREG GPR64:$Rn, sub_32)),
1164 (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1166 def : Pat<(i64 (ineg (mul (sext GPR32:$Rn), (s64imm_32bit:$C)))),
1167 (SMSUBLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1168 def : Pat<(i64 (ineg (mul (zext GPR32:$Rn), (i64imm_32bit:$C)))),
1169 (UMSUBLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1170 def : Pat<(i64 (ineg (mul (sext_inreg GPR64:$Rn, i32), (s64imm_32bit:$C)))),
1171 (SMSUBLrrr (i32 (EXTRACT_SUBREG GPR64:$Rn, sub_32)),
1172 (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1174 def : Pat<(i64 (add (mul (sext GPR32:$Rn), (s64imm_32bit:$C)), GPR64:$Ra)),
1175 (SMADDLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1176 def : Pat<(i64 (add (mul (zext GPR32:$Rn), (i64imm_32bit:$C)), GPR64:$Ra)),
1177 (UMADDLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1178 def : Pat<(i64 (add (mul (sext_inreg GPR64:$Rn, i32), (s64imm_32bit:$C)),
1180 (SMADDLrrr (i32 (EXTRACT_SUBREG GPR64:$Rn, sub_32)),
1181 (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1183 def : Pat<(i64 (sub GPR64:$Ra, (mul (sext GPR32:$Rn), (s64imm_32bit:$C)))),
1184 (SMSUBLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1185 def : Pat<(i64 (sub GPR64:$Ra, (mul (zext GPR32:$Rn), (i64imm_32bit:$C)))),
1186 (UMSUBLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1187 def : Pat<(i64 (sub GPR64:$Ra, (mul (sext_inreg GPR64:$Rn, i32),
1188 (s64imm_32bit:$C)))),
1189 (SMSUBLrrr (i32 (EXTRACT_SUBREG GPR64:$Rn, sub_32)),
1190 (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1191 } // AddedComplexity = 5
1193 def : MulAccumWAlias<"mul", MADDWrrr>;
1194 def : MulAccumXAlias<"mul", MADDXrrr>;
1195 def : MulAccumWAlias<"mneg", MSUBWrrr>;
1196 def : MulAccumXAlias<"mneg", MSUBXrrr>;
1197 def : WideMulAccumAlias<"smull", SMADDLrrr>;
1198 def : WideMulAccumAlias<"smnegl", SMSUBLrrr>;
1199 def : WideMulAccumAlias<"umull", UMADDLrrr>;
1200 def : WideMulAccumAlias<"umnegl", UMSUBLrrr>;
1203 def SMULHrr : MulHi<0b010, "smulh", mulhs>;
1204 def UMULHrr : MulHi<0b110, "umulh", mulhu>;
1207 def CRC32Brr : BaseCRC32<0, 0b00, 0, GPR32, int_aarch64_crc32b, "crc32b">;
1208 def CRC32Hrr : BaseCRC32<0, 0b01, 0, GPR32, int_aarch64_crc32h, "crc32h">;
1209 def CRC32Wrr : BaseCRC32<0, 0b10, 0, GPR32, int_aarch64_crc32w, "crc32w">;
1210 def CRC32Xrr : BaseCRC32<1, 0b11, 0, GPR64, int_aarch64_crc32x, "crc32x">;
1212 def CRC32CBrr : BaseCRC32<0, 0b00, 1, GPR32, int_aarch64_crc32cb, "crc32cb">;
1213 def CRC32CHrr : BaseCRC32<0, 0b01, 1, GPR32, int_aarch64_crc32ch, "crc32ch">;
1214 def CRC32CWrr : BaseCRC32<0, 0b10, 1, GPR32, int_aarch64_crc32cw, "crc32cw">;
1215 def CRC32CXrr : BaseCRC32<1, 0b11, 1, GPR64, int_aarch64_crc32cx, "crc32cx">;
1218 defm CAS : CompareAndSwap<0, 0, "">;
1219 defm CASA : CompareAndSwap<1, 0, "a">;
1220 defm CASL : CompareAndSwap<0, 1, "l">;
1221 defm CASAL : CompareAndSwap<1, 1, "al">;
1224 defm CASP : CompareAndSwapPair<0, 0, "">;
1225 defm CASPA : CompareAndSwapPair<1, 0, "a">;
1226 defm CASPL : CompareAndSwapPair<0, 1, "l">;
1227 defm CASPAL : CompareAndSwapPair<1, 1, "al">;
1230 defm SWP : Swap<0, 0, "">;
1231 defm SWPA : Swap<1, 0, "a">;
1232 defm SWPL : Swap<0, 1, "l">;
1233 defm SWPAL : Swap<1, 1, "al">;
1235 // v8.1 atomic LD<OP>(register). Performs load and then ST<OP>(register)
1236 defm LDADD : LDOPregister<0b000, "add", 0, 0, "">;
1237 defm LDADDA : LDOPregister<0b000, "add", 1, 0, "a">;
1238 defm LDADDL : LDOPregister<0b000, "add", 0, 1, "l">;
1239 defm LDADDAL : LDOPregister<0b000, "add", 1, 1, "al">;
1241 defm LDCLR : LDOPregister<0b001, "clr", 0, 0, "">;
1242 defm LDCLRA : LDOPregister<0b001, "clr", 1, 0, "a">;
1243 defm LDCLRL : LDOPregister<0b001, "clr", 0, 1, "l">;
1244 defm LDCLRAL : LDOPregister<0b001, "clr", 1, 1, "al">;
1246 defm LDEOR : LDOPregister<0b010, "eor", 0, 0, "">;
1247 defm LDEORA : LDOPregister<0b010, "eor", 1, 0, "a">;
1248 defm LDEORL : LDOPregister<0b010, "eor", 0, 1, "l">;
1249 defm LDEORAL : LDOPregister<0b010, "eor", 1, 1, "al">;
1251 defm LDSET : LDOPregister<0b011, "set", 0, 0, "">;
1252 defm LDSETA : LDOPregister<0b011, "set", 1, 0, "a">;
1253 defm LDSETL : LDOPregister<0b011, "set", 0, 1, "l">;
1254 defm LDSETAL : LDOPregister<0b011, "set", 1, 1, "al">;
1256 defm LDSMAX : LDOPregister<0b100, "smax", 0, 0, "">;
1257 defm LDSMAXA : LDOPregister<0b100, "smax", 1, 0, "a">;
1258 defm LDSMAXL : LDOPregister<0b100, "smax", 0, 1, "l">;
1259 defm LDSMAXAL : LDOPregister<0b100, "smax", 1, 1, "al">;
1261 defm LDSMIN : LDOPregister<0b101, "smin", 0, 0, "">;
1262 defm LDSMINA : LDOPregister<0b101, "smin", 1, 0, "a">;
1263 defm LDSMINL : LDOPregister<0b101, "smin", 0, 1, "l">;
1264 defm LDSMINAL : LDOPregister<0b101, "smin", 1, 1, "al">;
1266 defm LDUMAX : LDOPregister<0b110, "umax", 0, 0, "">;
1267 defm LDUMAXA : LDOPregister<0b110, "umax", 1, 0, "a">;
1268 defm LDUMAXL : LDOPregister<0b110, "umax", 0, 1, "l">;
1269 defm LDUMAXAL : LDOPregister<0b110, "umax", 1, 1, "al">;
1271 defm LDUMIN : LDOPregister<0b111, "umin", 0, 0, "">;
1272 defm LDUMINA : LDOPregister<0b111, "umin", 1, 0, "a">;
1273 defm LDUMINL : LDOPregister<0b111, "umin", 0, 1, "l">;
1274 defm LDUMINAL : LDOPregister<0b111, "umin", 1, 1, "al">;
1276 // v8.1 atomic ST<OP>(register) as aliases to "LD<OP>(register) when Rt=xZR"
1277 defm : STOPregister<"stadd","LDADD">; // STADDx
1278 defm : STOPregister<"stclr","LDCLR">; // STCLRx
1279 defm : STOPregister<"steor","LDEOR">; // STEORx
1280 defm : STOPregister<"stset","LDSET">; // STSETx
1281 defm : STOPregister<"stsmax","LDSMAX">;// STSMAXx
1282 defm : STOPregister<"stsmin","LDSMIN">;// STSMINx
1283 defm : STOPregister<"stumax","LDUMAX">;// STUMAXx
1284 defm : STOPregister<"stumin","LDUMIN">;// STUMINx
1286 // v8.5 Memory Tagging Extension
1287 let Predicates = [HasMTE] in {
1289 def IRG : BaseTwoOperand<0b0100, GPR64sp, "irg", int_aarch64_irg, GPR64sp, GPR64>,
1293 def GMI : BaseTwoOperand<0b0101, GPR64, "gmi", int_aarch64_gmi, GPR64sp>, Sched<[]>{
1295 let isNotDuplicable = 1;
1297 def ADDG : AddSubG<0, "addg", null_frag>;
1298 def SUBG : AddSubG<1, "subg", null_frag>;
1300 def : InstAlias<"irg $dst, $src", (IRG GPR64sp:$dst, GPR64sp:$src, XZR), 1>;
1302 def SUBP : SUBP<0, "subp", int_aarch64_subp>, Sched<[]>;
1303 def SUBPS : SUBP<1, "subps", null_frag>, Sched<[]>{
1307 def : InstAlias<"cmpp $lhs, $rhs", (SUBPS XZR, GPR64sp:$lhs, GPR64sp:$rhs), 0>;
1309 def LDG : MemTagLoad<"ldg", "\t$Rt, [$Rn, $offset]">;
1311 def : Pat<(int_aarch64_addg (am_indexedu6s128 GPR64sp:$Rn, uimm6s16:$imm6), imm0_15:$imm4),
1312 (ADDG GPR64sp:$Rn, imm0_63:$imm6, imm0_15:$imm4)>;
1313 def : Pat<(int_aarch64_ldg GPR64:$Rt, (am_indexeds9s128 GPR64sp:$Rn, simm9s16:$offset)),
1314 (LDG GPR64:$Rt, GPR64sp:$Rn, simm9s16:$offset)>;
1316 def : InstAlias<"ldg $Rt, [$Rn]", (LDG GPR64:$Rt, GPR64sp:$Rn, 0), 1>;
1318 def LDGM : MemTagVector<1, "ldgm", "\t$Rt, [$Rn]",
1319 (outs GPR64:$Rt), (ins GPR64sp:$Rn)>;
1320 def STGM : MemTagVector<0, "stgm", "\t$Rt, [$Rn]",
1321 (outs), (ins GPR64:$Rt, GPR64sp:$Rn)>;
1322 def STZGM : MemTagVector<0, "stzgm", "\t$Rt, [$Rn]",
1323 (outs), (ins GPR64:$Rt, GPR64sp:$Rn)> {
1327 defm STG : MemTagStore<0b00, "stg">;
1328 defm STZG : MemTagStore<0b01, "stzg">;
1329 defm ST2G : MemTagStore<0b10, "st2g">;
1330 defm STZ2G : MemTagStore<0b11, "stz2g">;
1332 def : Pat<(AArch64stg GPR64sp:$Rn, (am_indexeds9s128 GPR64sp:$Rm, simm9s16:$imm)),
1333 (STGOffset $Rn, $Rm, $imm)>;
1334 def : Pat<(AArch64stzg GPR64sp:$Rn, (am_indexeds9s128 GPR64sp:$Rm, simm9s16:$imm)),
1335 (STZGOffset $Rn, $Rm, $imm)>;
1336 def : Pat<(AArch64st2g GPR64sp:$Rn, (am_indexeds9s128 GPR64sp:$Rm, simm9s16:$imm)),
1337 (ST2GOffset $Rn, $Rm, $imm)>;
1338 def : Pat<(AArch64stz2g GPR64sp:$Rn, (am_indexeds9s128 GPR64sp:$Rm, simm9s16:$imm)),
1339 (STZ2GOffset $Rn, $Rm, $imm)>;
1341 defm STGP : StorePairOffset <0b01, 0, GPR64z, simm7s16, "stgp">;
1342 def STGPpre : StorePairPreIdx <0b01, 0, GPR64z, simm7s16, "stgp">;
1343 def STGPpost : StorePairPostIdx<0b01, 0, GPR64z, simm7s16, "stgp">;
1345 def : Pat<(int_aarch64_stg GPR64:$Rt, (am_indexeds9s128 GPR64sp:$Rn, simm9s16:$offset)),
1346 (STGOffset GPR64:$Rt, GPR64sp:$Rn, simm9s16:$offset)>;
1348 def : Pat<(int_aarch64_stgp (am_indexed7s128 GPR64sp:$Rn, simm7s16:$imm), GPR64:$Rt, GPR64:$Rt2),
1349 (STGPi $Rt, $Rt2, $Rn, $imm)>;
1352 : Pseudo<(outs GPR64sp:$Rd), (ins GPR64sp:$Rsp, GPR64:$Rm), []>,
1355 : Pseudo<(outs GPR64sp:$Rd), (ins GPR64sp:$Rn, uimm6s16:$imm6, GPR64sp:$Rm, imm0_15:$imm4), []>,
1358 // Explicit SP in the first operand prevents ShrinkWrap optimization
1359 // from leaving this instruction out of the stack frame. When IRGstack
1360 // is transformed into IRG, this operand is replaced with the actual
1361 // register / expression for the tagged base pointer of the current function.
1362 def : Pat<(int_aarch64_irg_sp i64:$Rm), (IRGstack SP, i64:$Rm)>;
1364 // Large STG to be expanded into a loop. $Rm is the size, $Rn is start address.
1365 // $Rn_wback is one past the end of the range.
1366 let isCodeGenOnly=1, mayStore=1 in {
1368 : Pseudo<(outs GPR64common:$Rm_wback, GPR64sp:$Rn_wback), (ins GPR64common:$Rm, GPR64sp:$Rn),
1369 [], "$Rn = $Rn_wback,@earlyclobber $Rn_wback,$Rm = $Rm_wback,@earlyclobber $Rm_wback" >,
1370 Sched<[WriteAdr, WriteST]>;
1373 : Pseudo<(outs GPR64common:$Rm_wback, GPR64sp:$Rn_wback), (ins GPR64common:$Rm, GPR64sp:$Rn),
1374 [], "$Rn = $Rn_wback,@earlyclobber $Rn_wback,$Rm = $Rm_wback,@earlyclobber $Rm_wback" >,
1375 Sched<[WriteAdr, WriteST]>;
1378 } // Predicates = [HasMTE]
1380 //===----------------------------------------------------------------------===//
1381 // Logical instructions.
1382 //===----------------------------------------------------------------------===//
1385 defm ANDS : LogicalImmS<0b11, "ands", AArch64and_flag, "bics">;
1386 defm AND : LogicalImm<0b00, "and", and, "bic">;
1387 defm EOR : LogicalImm<0b10, "eor", xor, "eon">;
1388 defm ORR : LogicalImm<0b01, "orr", or, "orn">;
1390 // FIXME: these aliases *are* canonical sometimes (when movz can't be
1391 // used). Actually, it seems to be working right now, but putting logical_immXX
1392 // here is a bit dodgy on the AsmParser side too.
1393 def : InstAlias<"mov $dst, $imm", (ORRWri GPR32sp:$dst, WZR,
1394 logical_imm32:$imm), 0>;
1395 def : InstAlias<"mov $dst, $imm", (ORRXri GPR64sp:$dst, XZR,
1396 logical_imm64:$imm), 0>;
1400 defm ANDS : LogicalRegS<0b11, 0, "ands", AArch64and_flag>;
1401 defm BICS : LogicalRegS<0b11, 1, "bics",
1402 BinOpFrag<(AArch64and_flag node:$LHS, (not node:$RHS))>>;
1403 defm AND : LogicalReg<0b00, 0, "and", and>;
1404 defm BIC : LogicalReg<0b00, 1, "bic",
1405 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
1406 defm EON : LogicalReg<0b10, 1, "eon",
1407 BinOpFrag<(not (xor node:$LHS, node:$RHS))>>;
1408 defm EOR : LogicalReg<0b10, 0, "eor", xor>;
1409 defm ORN : LogicalReg<0b01, 1, "orn",
1410 BinOpFrag<(or node:$LHS, (not node:$RHS))>>;
1411 defm ORR : LogicalReg<0b01, 0, "orr", or>;
1413 def : InstAlias<"mov $dst, $src", (ORRWrs GPR32:$dst, WZR, GPR32:$src, 0), 2>;
1414 def : InstAlias<"mov $dst, $src", (ORRXrs GPR64:$dst, XZR, GPR64:$src, 0), 2>;
1416 def : InstAlias<"mvn $Wd, $Wm", (ORNWrs GPR32:$Wd, WZR, GPR32:$Wm, 0), 3>;
1417 def : InstAlias<"mvn $Xd, $Xm", (ORNXrs GPR64:$Xd, XZR, GPR64:$Xm, 0), 3>;
1419 def : InstAlias<"mvn $Wd, $Wm$sh",
1420 (ORNWrs GPR32:$Wd, WZR, GPR32:$Wm, logical_shift32:$sh), 2>;
1421 def : InstAlias<"mvn $Xd, $Xm$sh",
1422 (ORNXrs GPR64:$Xd, XZR, GPR64:$Xm, logical_shift64:$sh), 2>;
1424 def : InstAlias<"tst $src1, $src2",
1425 (ANDSWri WZR, GPR32:$src1, logical_imm32:$src2), 2>;
1426 def : InstAlias<"tst $src1, $src2",
1427 (ANDSXri XZR, GPR64:$src1, logical_imm64:$src2), 2>;
1429 def : InstAlias<"tst $src1, $src2",
1430 (ANDSWrs WZR, GPR32:$src1, GPR32:$src2, 0), 3>;
1431 def : InstAlias<"tst $src1, $src2",
1432 (ANDSXrs XZR, GPR64:$src1, GPR64:$src2, 0), 3>;
1434 def : InstAlias<"tst $src1, $src2$sh",
1435 (ANDSWrs WZR, GPR32:$src1, GPR32:$src2, logical_shift32:$sh), 2>;
1436 def : InstAlias<"tst $src1, $src2$sh",
1437 (ANDSXrs XZR, GPR64:$src1, GPR64:$src2, logical_shift64:$sh), 2>;
1440 def : Pat<(not GPR32:$Wm), (ORNWrr WZR, GPR32:$Wm)>;
1441 def : Pat<(not GPR64:$Xm), (ORNXrr XZR, GPR64:$Xm)>;
1444 //===----------------------------------------------------------------------===//
1445 // One operand data processing instructions.
1446 //===----------------------------------------------------------------------===//
1448 defm CLS : OneOperandData<0b101, "cls">;
1449 defm CLZ : OneOperandData<0b100, "clz", ctlz>;
1450 defm RBIT : OneOperandData<0b000, "rbit", bitreverse>;
1452 def REV16Wr : OneWRegData<0b001, "rev16",
1453 UnOpFrag<(rotr (bswap node:$LHS), (i64 16))>>;
1454 def REV16Xr : OneXRegData<0b001, "rev16", null_frag>;
1456 def : Pat<(cttz GPR32:$Rn),
1457 (CLZWr (RBITWr GPR32:$Rn))>;
1458 def : Pat<(cttz GPR64:$Rn),
1459 (CLZXr (RBITXr GPR64:$Rn))>;
1460 def : Pat<(ctlz (or (shl (xor (sra GPR32:$Rn, (i64 31)), GPR32:$Rn), (i64 1)),
1463 def : Pat<(ctlz (or (shl (xor (sra GPR64:$Rn, (i64 63)), GPR64:$Rn), (i64 1)),
1467 // Unlike the other one operand instructions, the instructions with the "rev"
1468 // mnemonic do *not* just different in the size bit, but actually use different
1469 // opcode bits for the different sizes.
1470 def REVWr : OneWRegData<0b010, "rev", bswap>;
1471 def REVXr : OneXRegData<0b011, "rev", bswap>;
1472 def REV32Xr : OneXRegData<0b010, "rev32",
1473 UnOpFrag<(rotr (bswap node:$LHS), (i64 32))>>;
1475 def : InstAlias<"rev64 $Rd, $Rn", (REVXr GPR64:$Rd, GPR64:$Rn), 0>;
1477 // The bswap commutes with the rotr so we want a pattern for both possible
1479 def : Pat<(bswap (rotr GPR32:$Rn, (i64 16))), (REV16Wr GPR32:$Rn)>;
1480 def : Pat<(bswap (rotr GPR64:$Rn, (i64 32))), (REV32Xr GPR64:$Rn)>;
1482 //===----------------------------------------------------------------------===//
1483 // Bitfield immediate extraction instruction.
1484 //===----------------------------------------------------------------------===//
1485 let hasSideEffects = 0 in
1486 defm EXTR : ExtractImm<"extr">;
1487 def : InstAlias<"ror $dst, $src, $shift",
1488 (EXTRWrri GPR32:$dst, GPR32:$src, GPR32:$src, imm0_31:$shift)>;
1489 def : InstAlias<"ror $dst, $src, $shift",
1490 (EXTRXrri GPR64:$dst, GPR64:$src, GPR64:$src, imm0_63:$shift)>;
1492 def : Pat<(rotr GPR32:$Rn, (i64 imm0_31:$imm)),
1493 (EXTRWrri GPR32:$Rn, GPR32:$Rn, imm0_31:$imm)>;
1494 def : Pat<(rotr GPR64:$Rn, (i64 imm0_63:$imm)),
1495 (EXTRXrri GPR64:$Rn, GPR64:$Rn, imm0_63:$imm)>;
1497 //===----------------------------------------------------------------------===//
1498 // Other bitfield immediate instructions.
1499 //===----------------------------------------------------------------------===//
1500 let hasSideEffects = 0 in {
1501 defm BFM : BitfieldImmWith2RegArgs<0b01, "bfm">;
1502 defm SBFM : BitfieldImm<0b00, "sbfm">;
1503 defm UBFM : BitfieldImm<0b10, "ubfm">;
1506 def i32shift_a : Operand<i64>, SDNodeXForm<imm, [{
1507 uint64_t enc = (32 - N->getZExtValue()) & 0x1f;
1508 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1511 def i32shift_b : Operand<i64>, SDNodeXForm<imm, [{
1512 uint64_t enc = 31 - N->getZExtValue();
1513 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1516 // min(7, 31 - shift_amt)
1517 def i32shift_sext_i8 : Operand<i64>, SDNodeXForm<imm, [{
1518 uint64_t enc = 31 - N->getZExtValue();
1519 enc = enc > 7 ? 7 : enc;
1520 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1523 // min(15, 31 - shift_amt)
1524 def i32shift_sext_i16 : Operand<i64>, SDNodeXForm<imm, [{
1525 uint64_t enc = 31 - N->getZExtValue();
1526 enc = enc > 15 ? 15 : enc;
1527 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1530 def i64shift_a : Operand<i64>, SDNodeXForm<imm, [{
1531 uint64_t enc = (64 - N->getZExtValue()) & 0x3f;
1532 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1535 def i64shift_b : Operand<i64>, SDNodeXForm<imm, [{
1536 uint64_t enc = 63 - N->getZExtValue();
1537 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1540 // min(7, 63 - shift_amt)
1541 def i64shift_sext_i8 : Operand<i64>, SDNodeXForm<imm, [{
1542 uint64_t enc = 63 - N->getZExtValue();
1543 enc = enc > 7 ? 7 : enc;
1544 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1547 // min(15, 63 - shift_amt)
1548 def i64shift_sext_i16 : Operand<i64>, SDNodeXForm<imm, [{
1549 uint64_t enc = 63 - N->getZExtValue();
1550 enc = enc > 15 ? 15 : enc;
1551 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1554 // min(31, 63 - shift_amt)
1555 def i64shift_sext_i32 : Operand<i64>, SDNodeXForm<imm, [{
1556 uint64_t enc = 63 - N->getZExtValue();
1557 enc = enc > 31 ? 31 : enc;
1558 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1561 def : Pat<(shl GPR32:$Rn, (i64 imm0_31:$imm)),
1562 (UBFMWri GPR32:$Rn, (i64 (i32shift_a imm0_31:$imm)),
1563 (i64 (i32shift_b imm0_31:$imm)))>;
1564 def : Pat<(shl GPR64:$Rn, (i64 imm0_63:$imm)),
1565 (UBFMXri GPR64:$Rn, (i64 (i64shift_a imm0_63:$imm)),
1566 (i64 (i64shift_b imm0_63:$imm)))>;
1568 let AddedComplexity = 10 in {
1569 def : Pat<(sra GPR32:$Rn, (i64 imm0_31:$imm)),
1570 (SBFMWri GPR32:$Rn, imm0_31:$imm, 31)>;
1571 def : Pat<(sra GPR64:$Rn, (i64 imm0_63:$imm)),
1572 (SBFMXri GPR64:$Rn, imm0_63:$imm, 63)>;
1575 def : InstAlias<"asr $dst, $src, $shift",
1576 (SBFMWri GPR32:$dst, GPR32:$src, imm0_31:$shift, 31)>;
1577 def : InstAlias<"asr $dst, $src, $shift",
1578 (SBFMXri GPR64:$dst, GPR64:$src, imm0_63:$shift, 63)>;
1579 def : InstAlias<"sxtb $dst, $src", (SBFMWri GPR32:$dst, GPR32:$src, 0, 7)>;
1580 def : InstAlias<"sxtb $dst, $src", (SBFMXri GPR64:$dst, GPR64:$src, 0, 7)>;
1581 def : InstAlias<"sxth $dst, $src", (SBFMWri GPR32:$dst, GPR32:$src, 0, 15)>;
1582 def : InstAlias<"sxth $dst, $src", (SBFMXri GPR64:$dst, GPR64:$src, 0, 15)>;
1583 def : InstAlias<"sxtw $dst, $src", (SBFMXri GPR64:$dst, GPR64:$src, 0, 31)>;
1585 def : Pat<(srl GPR32:$Rn, (i64 imm0_31:$imm)),
1586 (UBFMWri GPR32:$Rn, imm0_31:$imm, 31)>;
1587 def : Pat<(srl GPR64:$Rn, (i64 imm0_63:$imm)),
1588 (UBFMXri GPR64:$Rn, imm0_63:$imm, 63)>;
1590 def : InstAlias<"lsr $dst, $src, $shift",
1591 (UBFMWri GPR32:$dst, GPR32:$src, imm0_31:$shift, 31)>;
1592 def : InstAlias<"lsr $dst, $src, $shift",
1593 (UBFMXri GPR64:$dst, GPR64:$src, imm0_63:$shift, 63)>;
1594 def : InstAlias<"uxtb $dst, $src", (UBFMWri GPR32:$dst, GPR32:$src, 0, 7)>;
1595 def : InstAlias<"uxtb $dst, $src", (UBFMXri GPR64:$dst, GPR64:$src, 0, 7)>;
1596 def : InstAlias<"uxth $dst, $src", (UBFMWri GPR32:$dst, GPR32:$src, 0, 15)>;
1597 def : InstAlias<"uxth $dst, $src", (UBFMXri GPR64:$dst, GPR64:$src, 0, 15)>;
1598 def : InstAlias<"uxtw $dst, $src", (UBFMXri GPR64:$dst, GPR64:$src, 0, 31)>;
1600 //===----------------------------------------------------------------------===//
1601 // Conditional comparison instructions.
1602 //===----------------------------------------------------------------------===//
1603 defm CCMN : CondComparison<0, "ccmn", AArch64ccmn>;
1604 defm CCMP : CondComparison<1, "ccmp", AArch64ccmp>;
1606 //===----------------------------------------------------------------------===//
1607 // Conditional select instructions.
1608 //===----------------------------------------------------------------------===//
1609 defm CSEL : CondSelect<0, 0b00, "csel">;
1611 def inc : PatFrag<(ops node:$in), (add node:$in, 1)>;
1612 defm CSINC : CondSelectOp<0, 0b01, "csinc", inc>;
1613 defm CSINV : CondSelectOp<1, 0b00, "csinv", not>;
1614 defm CSNEG : CondSelectOp<1, 0b01, "csneg", ineg>;
1616 def : Pat<(AArch64csinv GPR32:$tval, GPR32:$fval, (i32 imm:$cc), NZCV),
1617 (CSINVWr GPR32:$tval, GPR32:$fval, (i32 imm:$cc))>;
1618 def : Pat<(AArch64csinv GPR64:$tval, GPR64:$fval, (i32 imm:$cc), NZCV),
1619 (CSINVXr GPR64:$tval, GPR64:$fval, (i32 imm:$cc))>;
1620 def : Pat<(AArch64csneg GPR32:$tval, GPR32:$fval, (i32 imm:$cc), NZCV),
1621 (CSNEGWr GPR32:$tval, GPR32:$fval, (i32 imm:$cc))>;
1622 def : Pat<(AArch64csneg GPR64:$tval, GPR64:$fval, (i32 imm:$cc), NZCV),
1623 (CSNEGXr GPR64:$tval, GPR64:$fval, (i32 imm:$cc))>;
1624 def : Pat<(AArch64csinc GPR32:$tval, GPR32:$fval, (i32 imm:$cc), NZCV),
1625 (CSINCWr GPR32:$tval, GPR32:$fval, (i32 imm:$cc))>;
1626 def : Pat<(AArch64csinc GPR64:$tval, GPR64:$fval, (i32 imm:$cc), NZCV),
1627 (CSINCXr GPR64:$tval, GPR64:$fval, (i32 imm:$cc))>;
1629 def : Pat<(AArch64csel (i32 0), (i32 1), (i32 imm:$cc), NZCV),
1630 (CSINCWr WZR, WZR, (i32 imm:$cc))>;
1631 def : Pat<(AArch64csel (i64 0), (i64 1), (i32 imm:$cc), NZCV),
1632 (CSINCXr XZR, XZR, (i32 imm:$cc))>;
1633 def : Pat<(AArch64csel GPR32:$tval, (i32 1), (i32 imm:$cc), NZCV),
1634 (CSINCWr GPR32:$tval, WZR, (i32 imm:$cc))>;
1635 def : Pat<(AArch64csel GPR64:$tval, (i64 1), (i32 imm:$cc), NZCV),
1636 (CSINCXr GPR64:$tval, XZR, (i32 imm:$cc))>;
1637 def : Pat<(AArch64csel (i32 1), GPR32:$fval, (i32 imm:$cc), NZCV),
1638 (CSINCWr GPR32:$fval, WZR, (i32 (inv_cond_XFORM imm:$cc)))>;
1639 def : Pat<(AArch64csel (i64 1), GPR64:$fval, (i32 imm:$cc), NZCV),
1640 (CSINCXr GPR64:$fval, XZR, (i32 (inv_cond_XFORM imm:$cc)))>;
1641 def : Pat<(AArch64csel (i32 0), (i32 -1), (i32 imm:$cc), NZCV),
1642 (CSINVWr WZR, WZR, (i32 imm:$cc))>;
1643 def : Pat<(AArch64csel (i64 0), (i64 -1), (i32 imm:$cc), NZCV),
1644 (CSINVXr XZR, XZR, (i32 imm:$cc))>;
1645 def : Pat<(AArch64csel GPR32:$tval, (i32 -1), (i32 imm:$cc), NZCV),
1646 (CSINVWr GPR32:$tval, WZR, (i32 imm:$cc))>;
1647 def : Pat<(AArch64csel GPR64:$tval, (i64 -1), (i32 imm:$cc), NZCV),
1648 (CSINVXr GPR64:$tval, XZR, (i32 imm:$cc))>;
1649 def : Pat<(AArch64csel (i32 -1), GPR32:$fval, (i32 imm:$cc), NZCV),
1650 (CSINVWr GPR32:$fval, WZR, (i32 (inv_cond_XFORM imm:$cc)))>;
1651 def : Pat<(AArch64csel (i64 -1), GPR64:$fval, (i32 imm:$cc), NZCV),
1652 (CSINVXr GPR64:$fval, XZR, (i32 (inv_cond_XFORM imm:$cc)))>;
1654 // The inverse of the condition code from the alias instruction is what is used
1655 // in the aliased instruction. The parser all ready inverts the condition code
1656 // for these aliases.
1657 def : InstAlias<"cset $dst, $cc",
1658 (CSINCWr GPR32:$dst, WZR, WZR, inv_ccode:$cc)>;
1659 def : InstAlias<"cset $dst, $cc",
1660 (CSINCXr GPR64:$dst, XZR, XZR, inv_ccode:$cc)>;
1662 def : InstAlias<"csetm $dst, $cc",
1663 (CSINVWr GPR32:$dst, WZR, WZR, inv_ccode:$cc)>;
1664 def : InstAlias<"csetm $dst, $cc",
1665 (CSINVXr GPR64:$dst, XZR, XZR, inv_ccode:$cc)>;
1667 def : InstAlias<"cinc $dst, $src, $cc",
1668 (CSINCWr GPR32:$dst, GPR32:$src, GPR32:$src, inv_ccode:$cc)>;
1669 def : InstAlias<"cinc $dst, $src, $cc",
1670 (CSINCXr GPR64:$dst, GPR64:$src, GPR64:$src, inv_ccode:$cc)>;
1672 def : InstAlias<"cinv $dst, $src, $cc",
1673 (CSINVWr GPR32:$dst, GPR32:$src, GPR32:$src, inv_ccode:$cc)>;
1674 def : InstAlias<"cinv $dst, $src, $cc",
1675 (CSINVXr GPR64:$dst, GPR64:$src, GPR64:$src, inv_ccode:$cc)>;
1677 def : InstAlias<"cneg $dst, $src, $cc",
1678 (CSNEGWr GPR32:$dst, GPR32:$src, GPR32:$src, inv_ccode:$cc)>;
1679 def : InstAlias<"cneg $dst, $src, $cc",
1680 (CSNEGXr GPR64:$dst, GPR64:$src, GPR64:$src, inv_ccode:$cc)>;
1682 //===----------------------------------------------------------------------===//
1683 // PC-relative instructions.
1684 //===----------------------------------------------------------------------===//
1685 let isReMaterializable = 1 in {
1686 let hasSideEffects = 0, mayStore = 0, mayLoad = 0 in {
1687 def ADR : ADRI<0, "adr", adrlabel,
1688 [(set GPR64:$Xd, (AArch64adr tglobaladdr:$label))]>;
1689 } // hasSideEffects = 0
1691 def ADRP : ADRI<1, "adrp", adrplabel,
1692 [(set GPR64:$Xd, (AArch64adrp tglobaladdr:$label))]>;
1693 } // isReMaterializable = 1
1695 // page address of a constant pool entry, block address
1696 def : Pat<(AArch64adr tconstpool:$cp), (ADR tconstpool:$cp)>;
1697 def : Pat<(AArch64adr tblockaddress:$cp), (ADR tblockaddress:$cp)>;
1698 def : Pat<(AArch64adr texternalsym:$sym), (ADR texternalsym:$sym)>;
1699 def : Pat<(AArch64adr tjumptable:$sym), (ADR tjumptable:$sym)>;
1700 def : Pat<(AArch64adrp tconstpool:$cp), (ADRP tconstpool:$cp)>;
1701 def : Pat<(AArch64adrp tblockaddress:$cp), (ADRP tblockaddress:$cp)>;
1702 def : Pat<(AArch64adrp texternalsym:$sym), (ADRP texternalsym:$sym)>;
1704 //===----------------------------------------------------------------------===//
1705 // Unconditional branch (register) instructions.
1706 //===----------------------------------------------------------------------===//
1708 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
1709 def RET : BranchReg<0b0010, "ret", []>;
1710 def DRPS : SpecialReturn<0b0101, "drps">;
1711 def ERET : SpecialReturn<0b0100, "eret">;
1712 } // isReturn = 1, isTerminator = 1, isBarrier = 1
1714 // Default to the LR register.
1715 def : InstAlias<"ret", (RET LR)>;
1717 let isCall = 1, Defs = [LR], Uses = [SP] in {
1718 def BLR : BranchReg<0b0001, "blr", [(AArch64call GPR64:$Rn)]>;
1721 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
1722 def BR : BranchReg<0b0000, "br", [(brind GPR64:$Rn)]>;
1723 } // isBranch, isTerminator, isBarrier, isIndirectBranch
1725 // Create a separate pseudo-instruction for codegen to use so that we don't
1726 // flag lr as used in every function. It'll be restored before the RET by the
1727 // epilogue if it's legitimately used.
1728 def RET_ReallyLR : Pseudo<(outs), (ins), [(AArch64retflag)]>,
1729 Sched<[WriteBrReg]> {
1730 let isTerminator = 1;
1735 // This is a directive-like pseudo-instruction. The purpose is to insert an
1736 // R_AARCH64_TLSDESC_CALL relocation at the offset of the following instruction
1737 // (which in the usual case is a BLR).
1738 let hasSideEffects = 1 in
1739 def TLSDESCCALL : Pseudo<(outs), (ins i64imm:$sym), []>, Sched<[]> {
1740 let AsmString = ".tlsdesccall $sym";
1743 // Pseudo instruction to tell the streamer to emit a 'B' character into the
1744 // augmentation string.
1745 def EMITBKEY : Pseudo<(outs), (ins), []>, Sched<[]> {}
1747 // FIXME: maybe the scratch register used shouldn't be fixed to X1?
1748 // FIXME: can "hasSideEffects be dropped?
1749 let isCall = 1, Defs = [LR, X0, X1], hasSideEffects = 1,
1750 isCodeGenOnly = 1 in
1752 : Pseudo<(outs), (ins i64imm:$sym),
1753 [(AArch64tlsdesc_callseq tglobaltlsaddr:$sym)]>,
1754 Sched<[WriteI, WriteLD, WriteI, WriteBrReg]>;
1755 def : Pat<(AArch64tlsdesc_callseq texternalsym:$sym),
1756 (TLSDESC_CALLSEQ texternalsym:$sym)>;
1758 //===----------------------------------------------------------------------===//
1759 // Conditional branch (immediate) instruction.
1760 //===----------------------------------------------------------------------===//
1761 def Bcc : BranchCond;
1763 //===----------------------------------------------------------------------===//
1764 // Compare-and-branch instructions.
1765 //===----------------------------------------------------------------------===//
1766 defm CBZ : CmpBranch<0, "cbz", AArch64cbz>;
1767 defm CBNZ : CmpBranch<1, "cbnz", AArch64cbnz>;
1769 //===----------------------------------------------------------------------===//
1770 // Test-bit-and-branch instructions.
1771 //===----------------------------------------------------------------------===//
1772 defm TBZ : TestBranch<0, "tbz", AArch64tbz>;
1773 defm TBNZ : TestBranch<1, "tbnz", AArch64tbnz>;
1775 //===----------------------------------------------------------------------===//
1776 // Unconditional branch (immediate) instructions.
1777 //===----------------------------------------------------------------------===//
1778 let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
1779 def B : BranchImm<0, "b", [(br bb:$addr)]>;
1780 } // isBranch, isTerminator, isBarrier
1782 let isCall = 1, Defs = [LR], Uses = [SP] in {
1783 def BL : CallImm<1, "bl", [(AArch64call tglobaladdr:$addr)]>;
1785 def : Pat<(AArch64call texternalsym:$func), (BL texternalsym:$func)>;
1787 //===----------------------------------------------------------------------===//
1788 // Exception generation instructions.
1789 //===----------------------------------------------------------------------===//
1791 def BRK : ExceptionGeneration<0b001, 0b00, "brk">;
1793 def DCPS1 : ExceptionGeneration<0b101, 0b01, "dcps1">;
1794 def DCPS2 : ExceptionGeneration<0b101, 0b10, "dcps2">;
1795 def DCPS3 : ExceptionGeneration<0b101, 0b11, "dcps3">;
1796 def HLT : ExceptionGeneration<0b010, 0b00, "hlt">;
1797 def HVC : ExceptionGeneration<0b000, 0b10, "hvc">;
1798 def SMC : ExceptionGeneration<0b000, 0b11, "smc">;
1799 def SVC : ExceptionGeneration<0b000, 0b01, "svc">;
1801 // DCPSn defaults to an immediate operand of zero if unspecified.
1802 def : InstAlias<"dcps1", (DCPS1 0)>;
1803 def : InstAlias<"dcps2", (DCPS2 0)>;
1804 def : InstAlias<"dcps3", (DCPS3 0)>;
1806 def UDF : UDFType<0, "udf">;
1808 //===----------------------------------------------------------------------===//
1809 // Load instructions.
1810 //===----------------------------------------------------------------------===//
1812 // Pair (indexed, offset)
1813 defm LDPW : LoadPairOffset<0b00, 0, GPR32z, simm7s4, "ldp">;
1814 defm LDPX : LoadPairOffset<0b10, 0, GPR64z, simm7s8, "ldp">;
1815 defm LDPS : LoadPairOffset<0b00, 1, FPR32Op, simm7s4, "ldp">;
1816 defm LDPD : LoadPairOffset<0b01, 1, FPR64Op, simm7s8, "ldp">;
1817 defm LDPQ : LoadPairOffset<0b10, 1, FPR128Op, simm7s16, "ldp">;
1819 defm LDPSW : LoadPairOffset<0b01, 0, GPR64z, simm7s4, "ldpsw">;
1821 // Pair (pre-indexed)
1822 def LDPWpre : LoadPairPreIdx<0b00, 0, GPR32z, simm7s4, "ldp">;
1823 def LDPXpre : LoadPairPreIdx<0b10, 0, GPR64z, simm7s8, "ldp">;
1824 def LDPSpre : LoadPairPreIdx<0b00, 1, FPR32Op, simm7s4, "ldp">;
1825 def LDPDpre : LoadPairPreIdx<0b01, 1, FPR64Op, simm7s8, "ldp">;
1826 def LDPQpre : LoadPairPreIdx<0b10, 1, FPR128Op, simm7s16, "ldp">;
1828 def LDPSWpre : LoadPairPreIdx<0b01, 0, GPR64z, simm7s4, "ldpsw">;
1830 // Pair (post-indexed)
1831 def LDPWpost : LoadPairPostIdx<0b00, 0, GPR32z, simm7s4, "ldp">;
1832 def LDPXpost : LoadPairPostIdx<0b10, 0, GPR64z, simm7s8, "ldp">;
1833 def LDPSpost : LoadPairPostIdx<0b00, 1, FPR32Op, simm7s4, "ldp">;
1834 def LDPDpost : LoadPairPostIdx<0b01, 1, FPR64Op, simm7s8, "ldp">;
1835 def LDPQpost : LoadPairPostIdx<0b10, 1, FPR128Op, simm7s16, "ldp">;
1837 def LDPSWpost : LoadPairPostIdx<0b01, 0, GPR64z, simm7s4, "ldpsw">;
1840 // Pair (no allocate)
1841 defm LDNPW : LoadPairNoAlloc<0b00, 0, GPR32z, simm7s4, "ldnp">;
1842 defm LDNPX : LoadPairNoAlloc<0b10, 0, GPR64z, simm7s8, "ldnp">;
1843 defm LDNPS : LoadPairNoAlloc<0b00, 1, FPR32Op, simm7s4, "ldnp">;
1844 defm LDNPD : LoadPairNoAlloc<0b01, 1, FPR64Op, simm7s8, "ldnp">;
1845 defm LDNPQ : LoadPairNoAlloc<0b10, 1, FPR128Op, simm7s16, "ldnp">;
1848 // (register offset)
1852 defm LDRBB : Load8RO<0b00, 0, 0b01, GPR32, "ldrb", i32, zextloadi8>;
1853 defm LDRHH : Load16RO<0b01, 0, 0b01, GPR32, "ldrh", i32, zextloadi16>;
1854 defm LDRW : Load32RO<0b10, 0, 0b01, GPR32, "ldr", i32, load>;
1855 defm LDRX : Load64RO<0b11, 0, 0b01, GPR64, "ldr", i64, load>;
1858 defm LDRB : Load8RO<0b00, 1, 0b01, FPR8Op, "ldr", untyped, load>;
1859 defm LDRH : Load16RO<0b01, 1, 0b01, FPR16Op, "ldr", f16, load>;
1860 defm LDRS : Load32RO<0b10, 1, 0b01, FPR32Op, "ldr", f32, load>;
1861 defm LDRD : Load64RO<0b11, 1, 0b01, FPR64Op, "ldr", f64, load>;
1862 defm LDRQ : Load128RO<0b00, 1, 0b11, FPR128Op, "ldr", f128, load>;
1864 // Load sign-extended half-word
1865 defm LDRSHW : Load16RO<0b01, 0, 0b11, GPR32, "ldrsh", i32, sextloadi16>;
1866 defm LDRSHX : Load16RO<0b01, 0, 0b10, GPR64, "ldrsh", i64, sextloadi16>;
1868 // Load sign-extended byte
1869 defm LDRSBW : Load8RO<0b00, 0, 0b11, GPR32, "ldrsb", i32, sextloadi8>;
1870 defm LDRSBX : Load8RO<0b00, 0, 0b10, GPR64, "ldrsb", i64, sextloadi8>;
1872 // Load sign-extended word
1873 defm LDRSW : Load32RO<0b10, 0, 0b10, GPR64, "ldrsw", i64, sextloadi32>;
1876 defm PRFM : PrefetchRO<0b11, 0, 0b10, "prfm">;
1878 // For regular load, we do not have any alignment requirement.
1879 // Thus, it is safe to directly map the vector loads with interesting
1880 // addressing modes.
1881 // FIXME: We could do the same for bitconvert to floating point vectors.
1882 multiclass ScalToVecROLoadPat<ROAddrMode ro, SDPatternOperator loadop,
1883 ValueType ScalTy, ValueType VecTy,
1884 Instruction LOADW, Instruction LOADX,
1886 def : Pat<(VecTy (scalar_to_vector (ScalTy
1887 (loadop (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$offset))))),
1888 (INSERT_SUBREG (VecTy (IMPLICIT_DEF)),
1889 (LOADW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$offset),
1892 def : Pat<(VecTy (scalar_to_vector (ScalTy
1893 (loadop (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$offset))))),
1894 (INSERT_SUBREG (VecTy (IMPLICIT_DEF)),
1895 (LOADX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$offset),
1899 let AddedComplexity = 10 in {
1900 defm : ScalToVecROLoadPat<ro8, extloadi8, i32, v8i8, LDRBroW, LDRBroX, bsub>;
1901 defm : ScalToVecROLoadPat<ro8, extloadi8, i32, v16i8, LDRBroW, LDRBroX, bsub>;
1903 defm : ScalToVecROLoadPat<ro16, extloadi16, i32, v4i16, LDRHroW, LDRHroX, hsub>;
1904 defm : ScalToVecROLoadPat<ro16, extloadi16, i32, v8i16, LDRHroW, LDRHroX, hsub>;
1906 defm : ScalToVecROLoadPat<ro16, load, i32, v4f16, LDRHroW, LDRHroX, hsub>;
1907 defm : ScalToVecROLoadPat<ro16, load, i32, v8f16, LDRHroW, LDRHroX, hsub>;
1909 defm : ScalToVecROLoadPat<ro32, load, i32, v2i32, LDRSroW, LDRSroX, ssub>;
1910 defm : ScalToVecROLoadPat<ro32, load, i32, v4i32, LDRSroW, LDRSroX, ssub>;
1912 defm : ScalToVecROLoadPat<ro32, load, f32, v2f32, LDRSroW, LDRSroX, ssub>;
1913 defm : ScalToVecROLoadPat<ro32, load, f32, v4f32, LDRSroW, LDRSroX, ssub>;
1915 defm : ScalToVecROLoadPat<ro64, load, i64, v2i64, LDRDroW, LDRDroX, dsub>;
1917 defm : ScalToVecROLoadPat<ro64, load, f64, v2f64, LDRDroW, LDRDroX, dsub>;
1920 def : Pat <(v1i64 (scalar_to_vector (i64
1921 (load (ro_Windexed64 GPR64sp:$Rn, GPR32:$Rm,
1922 ro_Wextend64:$extend))))),
1923 (LDRDroW GPR64sp:$Rn, GPR32:$Rm, ro_Wextend64:$extend)>;
1925 def : Pat <(v1i64 (scalar_to_vector (i64
1926 (load (ro_Xindexed64 GPR64sp:$Rn, GPR64:$Rm,
1927 ro_Xextend64:$extend))))),
1928 (LDRDroX GPR64sp:$Rn, GPR64:$Rm, ro_Xextend64:$extend)>;
1931 // Match all load 64 bits width whose type is compatible with FPR64
1932 multiclass VecROLoadPat<ROAddrMode ro, ValueType VecTy,
1933 Instruction LOADW, Instruction LOADX> {
1935 def : Pat<(VecTy (load (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend))),
1936 (LOADW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
1938 def : Pat<(VecTy (load (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend))),
1939 (LOADX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
1942 let AddedComplexity = 10 in {
1943 let Predicates = [IsLE] in {
1944 // We must do vector loads with LD1 in big-endian.
1945 defm : VecROLoadPat<ro64, v2i32, LDRDroW, LDRDroX>;
1946 defm : VecROLoadPat<ro64, v2f32, LDRDroW, LDRDroX>;
1947 defm : VecROLoadPat<ro64, v8i8, LDRDroW, LDRDroX>;
1948 defm : VecROLoadPat<ro64, v4i16, LDRDroW, LDRDroX>;
1949 defm : VecROLoadPat<ro64, v4f16, LDRDroW, LDRDroX>;
1952 defm : VecROLoadPat<ro64, v1i64, LDRDroW, LDRDroX>;
1953 defm : VecROLoadPat<ro64, v1f64, LDRDroW, LDRDroX>;
1955 // Match all load 128 bits width whose type is compatible with FPR128
1956 let Predicates = [IsLE] in {
1957 // We must do vector loads with LD1 in big-endian.
1958 defm : VecROLoadPat<ro128, v2i64, LDRQroW, LDRQroX>;
1959 defm : VecROLoadPat<ro128, v2f64, LDRQroW, LDRQroX>;
1960 defm : VecROLoadPat<ro128, v4i32, LDRQroW, LDRQroX>;
1961 defm : VecROLoadPat<ro128, v4f32, LDRQroW, LDRQroX>;
1962 defm : VecROLoadPat<ro128, v8i16, LDRQroW, LDRQroX>;
1963 defm : VecROLoadPat<ro128, v8f16, LDRQroW, LDRQroX>;
1964 defm : VecROLoadPat<ro128, v16i8, LDRQroW, LDRQroX>;
1966 } // AddedComplexity = 10
1969 multiclass ExtLoadTo64ROPat<ROAddrMode ro, SDPatternOperator loadop,
1970 Instruction INSTW, Instruction INSTX> {
1971 def : Pat<(i64 (loadop (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend))),
1972 (SUBREG_TO_REG (i64 0),
1973 (INSTW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend),
1976 def : Pat<(i64 (loadop (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend))),
1977 (SUBREG_TO_REG (i64 0),
1978 (INSTX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend),
1982 let AddedComplexity = 10 in {
1983 defm : ExtLoadTo64ROPat<ro8, zextloadi8, LDRBBroW, LDRBBroX>;
1984 defm : ExtLoadTo64ROPat<ro16, zextloadi16, LDRHHroW, LDRHHroX>;
1985 defm : ExtLoadTo64ROPat<ro32, zextloadi32, LDRWroW, LDRWroX>;
1987 // zextloadi1 -> zextloadi8
1988 defm : ExtLoadTo64ROPat<ro8, zextloadi1, LDRBBroW, LDRBBroX>;
1990 // extload -> zextload
1991 defm : ExtLoadTo64ROPat<ro8, extloadi8, LDRBBroW, LDRBBroX>;
1992 defm : ExtLoadTo64ROPat<ro16, extloadi16, LDRHHroW, LDRHHroX>;
1993 defm : ExtLoadTo64ROPat<ro32, extloadi32, LDRWroW, LDRWroX>;
1995 // extloadi1 -> zextloadi8
1996 defm : ExtLoadTo64ROPat<ro8, extloadi1, LDRBBroW, LDRBBroX>;
2001 multiclass ExtLoadTo32ROPat<ROAddrMode ro, SDPatternOperator loadop,
2002 Instruction INSTW, Instruction INSTX> {
2003 def : Pat<(i32 (loadop (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend))),
2004 (INSTW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
2006 def : Pat<(i32 (loadop (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend))),
2007 (INSTX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
2011 let AddedComplexity = 10 in {
2012 // extload -> zextload
2013 defm : ExtLoadTo32ROPat<ro8, extloadi8, LDRBBroW, LDRBBroX>;
2014 defm : ExtLoadTo32ROPat<ro16, extloadi16, LDRHHroW, LDRHHroX>;
2015 defm : ExtLoadTo32ROPat<ro32, extloadi32, LDRWroW, LDRWroX>;
2017 // zextloadi1 -> zextloadi8
2018 defm : ExtLoadTo32ROPat<ro8, zextloadi1, LDRBBroW, LDRBBroX>;
2022 // (unsigned immediate)
2024 defm LDRX : LoadUI<0b11, 0, 0b01, GPR64z, uimm12s8, "ldr",
2026 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)))]>;
2027 defm LDRW : LoadUI<0b10, 0, 0b01, GPR32z, uimm12s4, "ldr",
2029 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset)))]>;
2030 defm LDRB : LoadUI<0b00, 1, 0b01, FPR8Op, uimm12s1, "ldr",
2032 (load (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset)))]>;
2033 defm LDRH : LoadUI<0b01, 1, 0b01, FPR16Op, uimm12s2, "ldr",
2034 [(set (f16 FPR16Op:$Rt),
2035 (load (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset)))]>;
2036 defm LDRS : LoadUI<0b10, 1, 0b01, FPR32Op, uimm12s4, "ldr",
2037 [(set (f32 FPR32Op:$Rt),
2038 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset)))]>;
2039 defm LDRD : LoadUI<0b11, 1, 0b01, FPR64Op, uimm12s8, "ldr",
2040 [(set (f64 FPR64Op:$Rt),
2041 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)))]>;
2042 defm LDRQ : LoadUI<0b00, 1, 0b11, FPR128Op, uimm12s16, "ldr",
2043 [(set (f128 FPR128Op:$Rt),
2044 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)))]>;
2046 // For regular load, we do not have any alignment requirement.
2047 // Thus, it is safe to directly map the vector loads with interesting
2048 // addressing modes.
2049 // FIXME: We could do the same for bitconvert to floating point vectors.
2050 def : Pat <(v8i8 (scalar_to_vector (i32
2051 (extloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))))),
2052 (INSERT_SUBREG (v8i8 (IMPLICIT_DEF)),
2053 (LDRBui GPR64sp:$Rn, uimm12s1:$offset), bsub)>;
2054 def : Pat <(v16i8 (scalar_to_vector (i32
2055 (extloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))))),
2056 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
2057 (LDRBui GPR64sp:$Rn, uimm12s1:$offset), bsub)>;
2058 def : Pat <(v4i16 (scalar_to_vector (i32
2059 (extloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))))),
2060 (INSERT_SUBREG (v4i16 (IMPLICIT_DEF)),
2061 (LDRHui GPR64sp:$Rn, uimm12s2:$offset), hsub)>;
2062 def : Pat <(v8i16 (scalar_to_vector (i32
2063 (extloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))))),
2064 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)),
2065 (LDRHui GPR64sp:$Rn, uimm12s2:$offset), hsub)>;
2066 def : Pat <(v2i32 (scalar_to_vector (i32
2067 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))))),
2068 (INSERT_SUBREG (v2i32 (IMPLICIT_DEF)),
2069 (LDRSui GPR64sp:$Rn, uimm12s4:$offset), ssub)>;
2070 def : Pat <(v4i32 (scalar_to_vector (i32
2071 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))))),
2072 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)),
2073 (LDRSui GPR64sp:$Rn, uimm12s4:$offset), ssub)>;
2074 def : Pat <(v1i64 (scalar_to_vector (i64
2075 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))))),
2076 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2077 def : Pat <(v2i64 (scalar_to_vector (i64
2078 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))))),
2079 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)),
2080 (LDRDui GPR64sp:$Rn, uimm12s8:$offset), dsub)>;
2082 // Match all load 64 bits width whose type is compatible with FPR64
2083 let Predicates = [IsLE] in {
2084 // We must use LD1 to perform vector loads in big-endian.
2085 def : Pat<(v2f32 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2086 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2087 def : Pat<(v8i8 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2088 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2089 def : Pat<(v4i16 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2090 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2091 def : Pat<(v2i32 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2092 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2093 def : Pat<(v4f16 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2094 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2096 def : Pat<(v1f64 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2097 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2098 def : Pat<(v1i64 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
2099 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
2101 // Match all load 128 bits width whose type is compatible with FPR128
2102 let Predicates = [IsLE] in {
2103 // We must use LD1 to perform vector loads in big-endian.
2104 def : Pat<(v4f32 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2105 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2106 def : Pat<(v2f64 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2107 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2108 def : Pat<(v16i8 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2109 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2110 def : Pat<(v8i16 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2111 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2112 def : Pat<(v4i32 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2113 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2114 def : Pat<(v2i64 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2115 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2116 def : Pat<(v8f16 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2117 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2119 def : Pat<(f128 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2120 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2122 defm LDRHH : LoadUI<0b01, 0, 0b01, GPR32, uimm12s2, "ldrh",
2124 (zextloadi16 (am_indexed16 GPR64sp:$Rn,
2125 uimm12s2:$offset)))]>;
2126 defm LDRBB : LoadUI<0b00, 0, 0b01, GPR32, uimm12s1, "ldrb",
2128 (zextloadi8 (am_indexed8 GPR64sp:$Rn,
2129 uimm12s1:$offset)))]>;
2131 def : Pat<(i64 (zextloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2132 (SUBREG_TO_REG (i64 0), (LDRBBui GPR64sp:$Rn, uimm12s1:$offset), sub_32)>;
2133 def : Pat<(i64 (zextloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))),
2134 (SUBREG_TO_REG (i64 0), (LDRHHui GPR64sp:$Rn, uimm12s2:$offset), sub_32)>;
2136 // zextloadi1 -> zextloadi8
2137 def : Pat<(i32 (zextloadi1 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2138 (LDRBBui GPR64sp:$Rn, uimm12s1:$offset)>;
2139 def : Pat<(i64 (zextloadi1 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2140 (SUBREG_TO_REG (i64 0), (LDRBBui GPR64sp:$Rn, uimm12s1:$offset), sub_32)>;
2142 // extload -> zextload
2143 def : Pat<(i32 (extloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))),
2144 (LDRHHui GPR64sp:$Rn, uimm12s2:$offset)>;
2145 def : Pat<(i32 (extloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2146 (LDRBBui GPR64sp:$Rn, uimm12s1:$offset)>;
2147 def : Pat<(i32 (extloadi1 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2148 (LDRBBui GPR64sp:$Rn, uimm12s1:$offset)>;
2149 def : Pat<(i64 (extloadi32 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))),
2150 (SUBREG_TO_REG (i64 0), (LDRWui GPR64sp:$Rn, uimm12s4:$offset), sub_32)>;
2151 def : Pat<(i64 (extloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))),
2152 (SUBREG_TO_REG (i64 0), (LDRHHui GPR64sp:$Rn, uimm12s2:$offset), sub_32)>;
2153 def : Pat<(i64 (extloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2154 (SUBREG_TO_REG (i64 0), (LDRBBui GPR64sp:$Rn, uimm12s1:$offset), sub_32)>;
2155 def : Pat<(i64 (extloadi1 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2156 (SUBREG_TO_REG (i64 0), (LDRBBui GPR64sp:$Rn, uimm12s1:$offset), sub_32)>;
2158 // load sign-extended half-word
2159 defm LDRSHW : LoadUI<0b01, 0, 0b11, GPR32, uimm12s2, "ldrsh",
2161 (sextloadi16 (am_indexed16 GPR64sp:$Rn,
2162 uimm12s2:$offset)))]>;
2163 defm LDRSHX : LoadUI<0b01, 0, 0b10, GPR64, uimm12s2, "ldrsh",
2165 (sextloadi16 (am_indexed16 GPR64sp:$Rn,
2166 uimm12s2:$offset)))]>;
2168 // load sign-extended byte
2169 defm LDRSBW : LoadUI<0b00, 0, 0b11, GPR32, uimm12s1, "ldrsb",
2171 (sextloadi8 (am_indexed8 GPR64sp:$Rn,
2172 uimm12s1:$offset)))]>;
2173 defm LDRSBX : LoadUI<0b00, 0, 0b10, GPR64, uimm12s1, "ldrsb",
2175 (sextloadi8 (am_indexed8 GPR64sp:$Rn,
2176 uimm12s1:$offset)))]>;
2178 // load sign-extended word
2179 defm LDRSW : LoadUI<0b10, 0, 0b10, GPR64, uimm12s4, "ldrsw",
2181 (sextloadi32 (am_indexed32 GPR64sp:$Rn,
2182 uimm12s4:$offset)))]>;
2184 // load zero-extended word
2185 def : Pat<(i64 (zextloadi32 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))),
2186 (SUBREG_TO_REG (i64 0), (LDRWui GPR64sp:$Rn, uimm12s4:$offset), sub_32)>;
2189 def PRFMui : PrefetchUI<0b11, 0, 0b10, "prfm",
2190 [(AArch64Prefetch imm:$Rt,
2191 (am_indexed64 GPR64sp:$Rn,
2192 uimm12s8:$offset))]>;
2194 def : InstAlias<"prfm $Rt, [$Rn]", (PRFMui prfop:$Rt, GPR64sp:$Rn, 0)>;
2199 def alignedglobal : PatLeaf<(iPTR iPTR:$label), [{
2200 if (auto *G = dyn_cast<GlobalAddressSDNode>(N)) {
2201 const DataLayout &DL = MF->getDataLayout();
2202 unsigned Align = G->getGlobal()->getPointerAlignment(DL);
2203 return Align >= 4 && G->getOffset() % 4 == 0;
2205 if (auto *C = dyn_cast<ConstantPoolSDNode>(N))
2206 return C->getAlignment() >= 4 && C->getOffset() % 4 == 0;
2210 def LDRWl : LoadLiteral<0b00, 0, GPR32z, "ldr",
2211 [(set GPR32z:$Rt, (load (AArch64adr alignedglobal:$label)))]>;
2212 def LDRXl : LoadLiteral<0b01, 0, GPR64z, "ldr",
2213 [(set GPR64z:$Rt, (load (AArch64adr alignedglobal:$label)))]>;
2214 def LDRSl : LoadLiteral<0b00, 1, FPR32Op, "ldr",
2215 [(set (f32 FPR32Op:$Rt), (load (AArch64adr alignedglobal:$label)))]>;
2216 def LDRDl : LoadLiteral<0b01, 1, FPR64Op, "ldr",
2217 [(set (f64 FPR64Op:$Rt), (load (AArch64adr alignedglobal:$label)))]>;
2218 def LDRQl : LoadLiteral<0b10, 1, FPR128Op, "ldr",
2219 [(set (f128 FPR128Op:$Rt), (load (AArch64adr alignedglobal:$label)))]>;
2221 // load sign-extended word
2222 def LDRSWl : LoadLiteral<0b10, 0, GPR64z, "ldrsw",
2223 [(set GPR64z:$Rt, (sextloadi32 (AArch64adr alignedglobal:$label)))]>;
2225 let AddedComplexity = 20 in {
2226 def : Pat<(i64 (zextloadi32 (AArch64adr alignedglobal:$label))),
2227 (SUBREG_TO_REG (i64 0), (LDRWl $label), sub_32)>;
2231 def PRFMl : PrefetchLiteral<0b11, 0, "prfm", []>;
2232 // [(AArch64Prefetch imm:$Rt, tglobaladdr:$label)]>;
2235 // (unscaled immediate)
2236 defm LDURX : LoadUnscaled<0b11, 0, 0b01, GPR64z, "ldur",
2238 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset)))]>;
2239 defm LDURW : LoadUnscaled<0b10, 0, 0b01, GPR32z, "ldur",
2241 (load (am_unscaled32 GPR64sp:$Rn, simm9:$offset)))]>;
2242 defm LDURB : LoadUnscaled<0b00, 1, 0b01, FPR8Op, "ldur",
2244 (load (am_unscaled8 GPR64sp:$Rn, simm9:$offset)))]>;
2245 defm LDURH : LoadUnscaled<0b01, 1, 0b01, FPR16Op, "ldur",
2247 (load (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
2248 defm LDURS : LoadUnscaled<0b10, 1, 0b01, FPR32Op, "ldur",
2249 [(set (f32 FPR32Op:$Rt),
2250 (load (am_unscaled32 GPR64sp:$Rn, simm9:$offset)))]>;
2251 defm LDURD : LoadUnscaled<0b11, 1, 0b01, FPR64Op, "ldur",
2252 [(set (f64 FPR64Op:$Rt),
2253 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset)))]>;
2254 defm LDURQ : LoadUnscaled<0b00, 1, 0b11, FPR128Op, "ldur",
2255 [(set (f128 FPR128Op:$Rt),
2256 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset)))]>;
2259 : LoadUnscaled<0b01, 0, 0b01, GPR32, "ldurh",
2261 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
2263 : LoadUnscaled<0b00, 0, 0b01, GPR32, "ldurb",
2265 (zextloadi8 (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
2267 // Match all load 64 bits width whose type is compatible with FPR64
2268 let Predicates = [IsLE] in {
2269 def : Pat<(v2f32 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2270 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2271 def : Pat<(v2i32 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2272 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2273 def : Pat<(v4i16 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2274 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2275 def : Pat<(v8i8 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2276 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2277 def : Pat<(v4f16 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2278 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2280 def : Pat<(v1f64 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2281 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2282 def : Pat<(v1i64 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2283 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2285 // Match all load 128 bits width whose type is compatible with FPR128
2286 let Predicates = [IsLE] in {
2287 def : Pat<(v2f64 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2288 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2289 def : Pat<(v2i64 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2290 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2291 def : Pat<(v4f32 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2292 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2293 def : Pat<(v4i32 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2294 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2295 def : Pat<(v8i16 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2296 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2297 def : Pat<(v16i8 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2298 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2299 def : Pat<(v8f16 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2300 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2304 def : Pat<(i32 (extloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
2305 (LDURHHi GPR64sp:$Rn, simm9:$offset)>;
2306 def : Pat<(i32 (extloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2307 (LDURBBi GPR64sp:$Rn, simm9:$offset)>;
2308 def : Pat<(i32 (extloadi1 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2309 (LDURBBi GPR64sp:$Rn, simm9:$offset)>;
2310 def : Pat<(i64 (extloadi32 (am_unscaled32 GPR64sp:$Rn, simm9:$offset))),
2311 (SUBREG_TO_REG (i64 0), (LDURWi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2312 def : Pat<(i64 (extloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
2313 (SUBREG_TO_REG (i64 0), (LDURHHi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2314 def : Pat<(i64 (extloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2315 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2316 def : Pat<(i64 (extloadi1 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2317 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2319 def : Pat<(i32 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
2320 (LDURHHi GPR64sp:$Rn, simm9:$offset)>;
2321 def : Pat<(i32 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2322 (LDURBBi GPR64sp:$Rn, simm9:$offset)>;
2323 def : Pat<(i32 (zextloadi1 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2324 (LDURBBi GPR64sp:$Rn, simm9:$offset)>;
2325 def : Pat<(i64 (zextloadi32 (am_unscaled32 GPR64sp:$Rn, simm9:$offset))),
2326 (SUBREG_TO_REG (i64 0), (LDURWi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2327 def : Pat<(i64 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
2328 (SUBREG_TO_REG (i64 0), (LDURHHi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2329 def : Pat<(i64 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2330 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2331 def : Pat<(i64 (zextloadi1 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2332 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2336 // LDR mnemonics fall back to LDUR for negative or unaligned offsets.
2338 // Define new assembler match classes as we want to only match these when
2339 // the don't otherwise match the scaled addressing mode for LDR/STR. Don't
2340 // associate a DiagnosticType either, as we want the diagnostic for the
2341 // canonical form (the scaled operand) to take precedence.
2342 class SImm9OffsetOperand<int Width> : AsmOperandClass {
2343 let Name = "SImm9OffsetFB" # Width;
2344 let PredicateMethod = "isSImm9OffsetFB<" # Width # ">";
2345 let RenderMethod = "addImmOperands";
2348 def SImm9OffsetFB8Operand : SImm9OffsetOperand<8>;
2349 def SImm9OffsetFB16Operand : SImm9OffsetOperand<16>;
2350 def SImm9OffsetFB32Operand : SImm9OffsetOperand<32>;
2351 def SImm9OffsetFB64Operand : SImm9OffsetOperand<64>;
2352 def SImm9OffsetFB128Operand : SImm9OffsetOperand<128>;
2354 def simm9_offset_fb8 : Operand<i64> {
2355 let ParserMatchClass = SImm9OffsetFB8Operand;
2357 def simm9_offset_fb16 : Operand<i64> {
2358 let ParserMatchClass = SImm9OffsetFB16Operand;
2360 def simm9_offset_fb32 : Operand<i64> {
2361 let ParserMatchClass = SImm9OffsetFB32Operand;
2363 def simm9_offset_fb64 : Operand<i64> {
2364 let ParserMatchClass = SImm9OffsetFB64Operand;
2366 def simm9_offset_fb128 : Operand<i64> {
2367 let ParserMatchClass = SImm9OffsetFB128Operand;
2370 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2371 (LDURXi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb64:$offset), 0>;
2372 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2373 (LDURWi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
2374 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2375 (LDURBi FPR8Op:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2376 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2377 (LDURHi FPR16Op:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2378 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2379 (LDURSi FPR32Op:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
2380 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2381 (LDURDi FPR64Op:$Rt, GPR64sp:$Rn, simm9_offset_fb64:$offset), 0>;
2382 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2383 (LDURQi FPR128Op:$Rt, GPR64sp:$Rn, simm9_offset_fb128:$offset), 0>;
2386 def : Pat<(i64 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2387 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2388 def : Pat<(i64 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
2389 (SUBREG_TO_REG (i64 0), (LDURHHi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2391 // load sign-extended half-word
2393 : LoadUnscaled<0b01, 0, 0b11, GPR32, "ldursh",
2395 (sextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
2397 : LoadUnscaled<0b01, 0, 0b10, GPR64, "ldursh",
2399 (sextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
2401 // load sign-extended byte
2403 : LoadUnscaled<0b00, 0, 0b11, GPR32, "ldursb",
2405 (sextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset)))]>;
2407 : LoadUnscaled<0b00, 0, 0b10, GPR64, "ldursb",
2409 (sextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset)))]>;
2411 // load sign-extended word
2413 : LoadUnscaled<0b10, 0, 0b10, GPR64, "ldursw",
2415 (sextloadi32 (am_unscaled32 GPR64sp:$Rn, simm9:$offset)))]>;
2417 // zero and sign extending aliases from generic LDR* mnemonics to LDUR*.
2418 def : InstAlias<"ldrb $Rt, [$Rn, $offset]",
2419 (LDURBBi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2420 def : InstAlias<"ldrh $Rt, [$Rn, $offset]",
2421 (LDURHHi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2422 def : InstAlias<"ldrsb $Rt, [$Rn, $offset]",
2423 (LDURSBWi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2424 def : InstAlias<"ldrsb $Rt, [$Rn, $offset]",
2425 (LDURSBXi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2426 def : InstAlias<"ldrsh $Rt, [$Rn, $offset]",
2427 (LDURSHWi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2428 def : InstAlias<"ldrsh $Rt, [$Rn, $offset]",
2429 (LDURSHXi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2430 def : InstAlias<"ldrsw $Rt, [$Rn, $offset]",
2431 (LDURSWi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
2434 defm PRFUM : PrefetchUnscaled<0b11, 0, 0b10, "prfum",
2435 [(AArch64Prefetch imm:$Rt,
2436 (am_unscaled64 GPR64sp:$Rn, simm9:$offset))]>;
2439 // (unscaled immediate, unprivileged)
2440 defm LDTRX : LoadUnprivileged<0b11, 0, 0b01, GPR64, "ldtr">;
2441 defm LDTRW : LoadUnprivileged<0b10, 0, 0b01, GPR32, "ldtr">;
2443 defm LDTRH : LoadUnprivileged<0b01, 0, 0b01, GPR32, "ldtrh">;
2444 defm LDTRB : LoadUnprivileged<0b00, 0, 0b01, GPR32, "ldtrb">;
2446 // load sign-extended half-word
2447 defm LDTRSHW : LoadUnprivileged<0b01, 0, 0b11, GPR32, "ldtrsh">;
2448 defm LDTRSHX : LoadUnprivileged<0b01, 0, 0b10, GPR64, "ldtrsh">;
2450 // load sign-extended byte
2451 defm LDTRSBW : LoadUnprivileged<0b00, 0, 0b11, GPR32, "ldtrsb">;
2452 defm LDTRSBX : LoadUnprivileged<0b00, 0, 0b10, GPR64, "ldtrsb">;
2454 // load sign-extended word
2455 defm LDTRSW : LoadUnprivileged<0b10, 0, 0b10, GPR64, "ldtrsw">;
2458 // (immediate pre-indexed)
2459 def LDRWpre : LoadPreIdx<0b10, 0, 0b01, GPR32z, "ldr">;
2460 def LDRXpre : LoadPreIdx<0b11, 0, 0b01, GPR64z, "ldr">;
2461 def LDRBpre : LoadPreIdx<0b00, 1, 0b01, FPR8Op, "ldr">;
2462 def LDRHpre : LoadPreIdx<0b01, 1, 0b01, FPR16Op, "ldr">;
2463 def LDRSpre : LoadPreIdx<0b10, 1, 0b01, FPR32Op, "ldr">;
2464 def LDRDpre : LoadPreIdx<0b11, 1, 0b01, FPR64Op, "ldr">;
2465 def LDRQpre : LoadPreIdx<0b00, 1, 0b11, FPR128Op, "ldr">;
2467 // load sign-extended half-word
2468 def LDRSHWpre : LoadPreIdx<0b01, 0, 0b11, GPR32z, "ldrsh">;
2469 def LDRSHXpre : LoadPreIdx<0b01, 0, 0b10, GPR64z, "ldrsh">;
2471 // load sign-extended byte
2472 def LDRSBWpre : LoadPreIdx<0b00, 0, 0b11, GPR32z, "ldrsb">;
2473 def LDRSBXpre : LoadPreIdx<0b00, 0, 0b10, GPR64z, "ldrsb">;
2475 // load zero-extended byte
2476 def LDRBBpre : LoadPreIdx<0b00, 0, 0b01, GPR32z, "ldrb">;
2477 def LDRHHpre : LoadPreIdx<0b01, 0, 0b01, GPR32z, "ldrh">;
2479 // load sign-extended word
2480 def LDRSWpre : LoadPreIdx<0b10, 0, 0b10, GPR64z, "ldrsw">;
2483 // (immediate post-indexed)
2484 def LDRWpost : LoadPostIdx<0b10, 0, 0b01, GPR32z, "ldr">;
2485 def LDRXpost : LoadPostIdx<0b11, 0, 0b01, GPR64z, "ldr">;
2486 def LDRBpost : LoadPostIdx<0b00, 1, 0b01, FPR8Op, "ldr">;
2487 def LDRHpost : LoadPostIdx<0b01, 1, 0b01, FPR16Op, "ldr">;
2488 def LDRSpost : LoadPostIdx<0b10, 1, 0b01, FPR32Op, "ldr">;
2489 def LDRDpost : LoadPostIdx<0b11, 1, 0b01, FPR64Op, "ldr">;
2490 def LDRQpost : LoadPostIdx<0b00, 1, 0b11, FPR128Op, "ldr">;
2492 // load sign-extended half-word
2493 def LDRSHWpost : LoadPostIdx<0b01, 0, 0b11, GPR32z, "ldrsh">;
2494 def LDRSHXpost : LoadPostIdx<0b01, 0, 0b10, GPR64z, "ldrsh">;
2496 // load sign-extended byte
2497 def LDRSBWpost : LoadPostIdx<0b00, 0, 0b11, GPR32z, "ldrsb">;
2498 def LDRSBXpost : LoadPostIdx<0b00, 0, 0b10, GPR64z, "ldrsb">;
2500 // load zero-extended byte
2501 def LDRBBpost : LoadPostIdx<0b00, 0, 0b01, GPR32z, "ldrb">;
2502 def LDRHHpost : LoadPostIdx<0b01, 0, 0b01, GPR32z, "ldrh">;
2504 // load sign-extended word
2505 def LDRSWpost : LoadPostIdx<0b10, 0, 0b10, GPR64z, "ldrsw">;
2507 //===----------------------------------------------------------------------===//
2508 // Store instructions.
2509 //===----------------------------------------------------------------------===//
2511 // Pair (indexed, offset)
2512 // FIXME: Use dedicated range-checked addressing mode operand here.
2513 defm STPW : StorePairOffset<0b00, 0, GPR32z, simm7s4, "stp">;
2514 defm STPX : StorePairOffset<0b10, 0, GPR64z, simm7s8, "stp">;
2515 defm STPS : StorePairOffset<0b00, 1, FPR32Op, simm7s4, "stp">;
2516 defm STPD : StorePairOffset<0b01, 1, FPR64Op, simm7s8, "stp">;
2517 defm STPQ : StorePairOffset<0b10, 1, FPR128Op, simm7s16, "stp">;
2519 // Pair (pre-indexed)
2520 def STPWpre : StorePairPreIdx<0b00, 0, GPR32z, simm7s4, "stp">;
2521 def STPXpre : StorePairPreIdx<0b10, 0, GPR64z, simm7s8, "stp">;
2522 def STPSpre : StorePairPreIdx<0b00, 1, FPR32Op, simm7s4, "stp">;
2523 def STPDpre : StorePairPreIdx<0b01, 1, FPR64Op, simm7s8, "stp">;
2524 def STPQpre : StorePairPreIdx<0b10, 1, FPR128Op, simm7s16, "stp">;
2526 // Pair (pre-indexed)
2527 def STPWpost : StorePairPostIdx<0b00, 0, GPR32z, simm7s4, "stp">;
2528 def STPXpost : StorePairPostIdx<0b10, 0, GPR64z, simm7s8, "stp">;
2529 def STPSpost : StorePairPostIdx<0b00, 1, FPR32Op, simm7s4, "stp">;
2530 def STPDpost : StorePairPostIdx<0b01, 1, FPR64Op, simm7s8, "stp">;
2531 def STPQpost : StorePairPostIdx<0b10, 1, FPR128Op, simm7s16, "stp">;
2533 // Pair (no allocate)
2534 defm STNPW : StorePairNoAlloc<0b00, 0, GPR32z, simm7s4, "stnp">;
2535 defm STNPX : StorePairNoAlloc<0b10, 0, GPR64z, simm7s8, "stnp">;
2536 defm STNPS : StorePairNoAlloc<0b00, 1, FPR32Op, simm7s4, "stnp">;
2537 defm STNPD : StorePairNoAlloc<0b01, 1, FPR64Op, simm7s8, "stnp">;
2538 defm STNPQ : StorePairNoAlloc<0b10, 1, FPR128Op, simm7s16, "stnp">;
2541 // (Register offset)
2544 defm STRBB : Store8RO< 0b00, 0, 0b00, GPR32, "strb", i32, truncstorei8>;
2545 defm STRHH : Store16RO<0b01, 0, 0b00, GPR32, "strh", i32, truncstorei16>;
2546 defm STRW : Store32RO<0b10, 0, 0b00, GPR32, "str", i32, store>;
2547 defm STRX : Store64RO<0b11, 0, 0b00, GPR64, "str", i64, store>;
2551 defm STRB : Store8RO< 0b00, 1, 0b00, FPR8Op, "str", untyped, store>;
2552 defm STRH : Store16RO<0b01, 1, 0b00, FPR16Op, "str", f16, store>;
2553 defm STRS : Store32RO<0b10, 1, 0b00, FPR32Op, "str", f32, store>;
2554 defm STRD : Store64RO<0b11, 1, 0b00, FPR64Op, "str", f64, store>;
2555 defm STRQ : Store128RO<0b00, 1, 0b10, FPR128Op, "str", f128, store>;
2557 let Predicates = [UseSTRQro], AddedComplexity = 10 in {
2558 def : Pat<(store (f128 FPR128:$Rt),
2559 (ro_Windexed128 GPR64sp:$Rn, GPR32:$Rm,
2560 ro_Wextend128:$extend)),
2561 (STRQroW FPR128:$Rt, GPR64sp:$Rn, GPR32:$Rm, ro_Wextend128:$extend)>;
2562 def : Pat<(store (f128 FPR128:$Rt),
2563 (ro_Xindexed128 GPR64sp:$Rn, GPR64:$Rm,
2564 ro_Xextend128:$extend)),
2565 (STRQroX FPR128:$Rt, GPR64sp:$Rn, GPR64:$Rm, ro_Wextend128:$extend)>;
2568 multiclass TruncStoreFrom64ROPat<ROAddrMode ro, SDPatternOperator storeop,
2569 Instruction STRW, Instruction STRX> {
2571 def : Pat<(storeop GPR64:$Rt,
2572 (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)),
2573 (STRW (EXTRACT_SUBREG GPR64:$Rt, sub_32),
2574 GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
2576 def : Pat<(storeop GPR64:$Rt,
2577 (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)),
2578 (STRX (EXTRACT_SUBREG GPR64:$Rt, sub_32),
2579 GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
2582 let AddedComplexity = 10 in {
2584 defm : TruncStoreFrom64ROPat<ro8, truncstorei8, STRBBroW, STRBBroX>;
2585 defm : TruncStoreFrom64ROPat<ro16, truncstorei16, STRHHroW, STRHHroX>;
2586 defm : TruncStoreFrom64ROPat<ro32, truncstorei32, STRWroW, STRWroX>;
2589 multiclass VecROStorePat<ROAddrMode ro, ValueType VecTy, RegisterClass FPR,
2590 Instruction STRW, Instruction STRX> {
2591 def : Pat<(store (VecTy FPR:$Rt),
2592 (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)),
2593 (STRW FPR:$Rt, GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
2595 def : Pat<(store (VecTy FPR:$Rt),
2596 (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)),
2597 (STRX FPR:$Rt, GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
2600 let AddedComplexity = 10 in {
2601 // Match all store 64 bits width whose type is compatible with FPR64
2602 let Predicates = [IsLE] in {
2603 // We must use ST1 to store vectors in big-endian.
2604 defm : VecROStorePat<ro64, v2i32, FPR64, STRDroW, STRDroX>;
2605 defm : VecROStorePat<ro64, v2f32, FPR64, STRDroW, STRDroX>;
2606 defm : VecROStorePat<ro64, v4i16, FPR64, STRDroW, STRDroX>;
2607 defm : VecROStorePat<ro64, v8i8, FPR64, STRDroW, STRDroX>;
2608 defm : VecROStorePat<ro64, v4f16, FPR64, STRDroW, STRDroX>;
2611 defm : VecROStorePat<ro64, v1i64, FPR64, STRDroW, STRDroX>;
2612 defm : VecROStorePat<ro64, v1f64, FPR64, STRDroW, STRDroX>;
2614 // Match all store 128 bits width whose type is compatible with FPR128
2615 let Predicates = [IsLE, UseSTRQro] in {
2616 // We must use ST1 to store vectors in big-endian.
2617 defm : VecROStorePat<ro128, v2i64, FPR128, STRQroW, STRQroX>;
2618 defm : VecROStorePat<ro128, v2f64, FPR128, STRQroW, STRQroX>;
2619 defm : VecROStorePat<ro128, v4i32, FPR128, STRQroW, STRQroX>;
2620 defm : VecROStorePat<ro128, v4f32, FPR128, STRQroW, STRQroX>;
2621 defm : VecROStorePat<ro128, v8i16, FPR128, STRQroW, STRQroX>;
2622 defm : VecROStorePat<ro128, v16i8, FPR128, STRQroW, STRQroX>;
2623 defm : VecROStorePat<ro128, v8f16, FPR128, STRQroW, STRQroX>;
2625 } // AddedComplexity = 10
2627 // Match stores from lane 0 to the appropriate subreg's store.
2628 multiclass VecROStoreLane0Pat<ROAddrMode ro, SDPatternOperator storeop,
2629 ValueType VecTy, ValueType STy,
2630 SubRegIndex SubRegIdx,
2631 Instruction STRW, Instruction STRX> {
2633 def : Pat<(storeop (STy (vector_extract (VecTy VecListOne128:$Vt), 0)),
2634 (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)),
2635 (STRW (EXTRACT_SUBREG VecListOne128:$Vt, SubRegIdx),
2636 GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
2638 def : Pat<(storeop (STy (vector_extract (VecTy VecListOne128:$Vt), 0)),
2639 (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)),
2640 (STRX (EXTRACT_SUBREG VecListOne128:$Vt, SubRegIdx),
2641 GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
2644 let AddedComplexity = 19 in {
2645 defm : VecROStoreLane0Pat<ro16, truncstorei16, v8i16, i32, hsub, STRHroW, STRHroX>;
2646 defm : VecROStoreLane0Pat<ro16, store, v8f16, f16, hsub, STRHroW, STRHroX>;
2647 defm : VecROStoreLane0Pat<ro32, store, v4i32, i32, ssub, STRSroW, STRSroX>;
2648 defm : VecROStoreLane0Pat<ro32, store, v4f32, f32, ssub, STRSroW, STRSroX>;
2649 defm : VecROStoreLane0Pat<ro64, store, v2i64, i64, dsub, STRDroW, STRDroX>;
2650 defm : VecROStoreLane0Pat<ro64, store, v2f64, f64, dsub, STRDroW, STRDroX>;
2654 // (unsigned immediate)
2655 defm STRX : StoreUIz<0b11, 0, 0b00, GPR64z, uimm12s8, "str",
2657 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))]>;
2658 defm STRW : StoreUIz<0b10, 0, 0b00, GPR32z, uimm12s4, "str",
2660 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))]>;
2661 defm STRB : StoreUI<0b00, 1, 0b00, FPR8Op, uimm12s1, "str",
2663 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))]>;
2664 defm STRH : StoreUI<0b01, 1, 0b00, FPR16Op, uimm12s2, "str",
2665 [(store (f16 FPR16Op:$Rt),
2666 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))]>;
2667 defm STRS : StoreUI<0b10, 1, 0b00, FPR32Op, uimm12s4, "str",
2668 [(store (f32 FPR32Op:$Rt),
2669 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))]>;
2670 defm STRD : StoreUI<0b11, 1, 0b00, FPR64Op, uimm12s8, "str",
2671 [(store (f64 FPR64Op:$Rt),
2672 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))]>;
2673 defm STRQ : StoreUI<0b00, 1, 0b10, FPR128Op, uimm12s16, "str", []>;
2675 defm STRHH : StoreUIz<0b01, 0, 0b00, GPR32z, uimm12s2, "strh",
2676 [(truncstorei16 GPR32z:$Rt,
2677 (am_indexed16 GPR64sp:$Rn,
2678 uimm12s2:$offset))]>;
2679 defm STRBB : StoreUIz<0b00, 0, 0b00, GPR32z, uimm12s1, "strb",
2680 [(truncstorei8 GPR32z:$Rt,
2681 (am_indexed8 GPR64sp:$Rn,
2682 uimm12s1:$offset))]>;
2684 let AddedComplexity = 10 in {
2686 // Match all store 64 bits width whose type is compatible with FPR64
2687 def : Pat<(store (v1i64 FPR64:$Rt),
2688 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2689 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2690 def : Pat<(store (v1f64 FPR64:$Rt),
2691 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2692 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2694 let Predicates = [IsLE] in {
2695 // We must use ST1 to store vectors in big-endian.
2696 def : Pat<(store (v2f32 FPR64:$Rt),
2697 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2698 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2699 def : Pat<(store (v8i8 FPR64:$Rt),
2700 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2701 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2702 def : Pat<(store (v4i16 FPR64:$Rt),
2703 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2704 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2705 def : Pat<(store (v2i32 FPR64:$Rt),
2706 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2707 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2708 def : Pat<(store (v4f16 FPR64:$Rt),
2709 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2710 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2713 // Match all store 128 bits width whose type is compatible with FPR128
2714 def : Pat<(store (f128 FPR128:$Rt),
2715 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2716 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2718 let Predicates = [IsLE] in {
2719 // We must use ST1 to store vectors in big-endian.
2720 def : Pat<(store (v4f32 FPR128:$Rt),
2721 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2722 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2723 def : Pat<(store (v2f64 FPR128:$Rt),
2724 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2725 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2726 def : Pat<(store (v16i8 FPR128:$Rt),
2727 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2728 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2729 def : Pat<(store (v8i16 FPR128:$Rt),
2730 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2731 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2732 def : Pat<(store (v4i32 FPR128:$Rt),
2733 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2734 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2735 def : Pat<(store (v2i64 FPR128:$Rt),
2736 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2737 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2738 def : Pat<(store (v8f16 FPR128:$Rt),
2739 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2740 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2744 def : Pat<(truncstorei32 GPR64:$Rt,
2745 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset)),
2746 (STRWui (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, uimm12s4:$offset)>;
2747 def : Pat<(truncstorei16 GPR64:$Rt,
2748 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset)),
2749 (STRHHui (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, uimm12s2:$offset)>;
2750 def : Pat<(truncstorei8 GPR64:$Rt, (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset)),
2751 (STRBBui (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, uimm12s1:$offset)>;
2753 } // AddedComplexity = 10
2755 // Match stores from lane 0 to the appropriate subreg's store.
2756 multiclass VecStoreLane0Pat<Operand UIAddrMode, SDPatternOperator storeop,
2757 ValueType VTy, ValueType STy,
2758 SubRegIndex SubRegIdx, Operand IndexType,
2760 def : Pat<(storeop (STy (vector_extract (VTy VecListOne128:$Vt), 0)),
2761 (UIAddrMode GPR64sp:$Rn, IndexType:$offset)),
2762 (STR (EXTRACT_SUBREG VecListOne128:$Vt, SubRegIdx),
2763 GPR64sp:$Rn, IndexType:$offset)>;
2766 let AddedComplexity = 19 in {
2767 defm : VecStoreLane0Pat<am_indexed16, truncstorei16, v8i16, i32, hsub, uimm12s2, STRHui>;
2768 defm : VecStoreLane0Pat<am_indexed16, store, v8f16, f16, hsub, uimm12s2, STRHui>;
2769 defm : VecStoreLane0Pat<am_indexed32, store, v4i32, i32, ssub, uimm12s4, STRSui>;
2770 defm : VecStoreLane0Pat<am_indexed32, store, v4f32, f32, ssub, uimm12s4, STRSui>;
2771 defm : VecStoreLane0Pat<am_indexed64, store, v2i64, i64, dsub, uimm12s8, STRDui>;
2772 defm : VecStoreLane0Pat<am_indexed64, store, v2f64, f64, dsub, uimm12s8, STRDui>;
2776 // (unscaled immediate)
2777 defm STURX : StoreUnscaled<0b11, 0, 0b00, GPR64z, "stur",
2779 (am_unscaled64 GPR64sp:$Rn, simm9:$offset))]>;
2780 defm STURW : StoreUnscaled<0b10, 0, 0b00, GPR32z, "stur",
2782 (am_unscaled32 GPR64sp:$Rn, simm9:$offset))]>;
2783 defm STURB : StoreUnscaled<0b00, 1, 0b00, FPR8Op, "stur",
2785 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))]>;
2786 defm STURH : StoreUnscaled<0b01, 1, 0b00, FPR16Op, "stur",
2787 [(store (f16 FPR16Op:$Rt),
2788 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))]>;
2789 defm STURS : StoreUnscaled<0b10, 1, 0b00, FPR32Op, "stur",
2790 [(store (f32 FPR32Op:$Rt),
2791 (am_unscaled32 GPR64sp:$Rn, simm9:$offset))]>;
2792 defm STURD : StoreUnscaled<0b11, 1, 0b00, FPR64Op, "stur",
2793 [(store (f64 FPR64Op:$Rt),
2794 (am_unscaled64 GPR64sp:$Rn, simm9:$offset))]>;
2795 defm STURQ : StoreUnscaled<0b00, 1, 0b10, FPR128Op, "stur",
2796 [(store (f128 FPR128Op:$Rt),
2797 (am_unscaled128 GPR64sp:$Rn, simm9:$offset))]>;
2798 defm STURHH : StoreUnscaled<0b01, 0, 0b00, GPR32z, "sturh",
2799 [(truncstorei16 GPR32z:$Rt,
2800 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))]>;
2801 defm STURBB : StoreUnscaled<0b00, 0, 0b00, GPR32z, "sturb",
2802 [(truncstorei8 GPR32z:$Rt,
2803 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))]>;
2805 // Armv8.4 Weaker Release Consistency enhancements
2806 // LDAPR & STLR with Immediate Offset instructions
2807 let Predicates = [HasRCPC_IMMO] in {
2808 defm STLURB : BaseStoreUnscaleV84<"stlurb", 0b00, 0b00, GPR32>;
2809 defm STLURH : BaseStoreUnscaleV84<"stlurh", 0b01, 0b00, GPR32>;
2810 defm STLURW : BaseStoreUnscaleV84<"stlur", 0b10, 0b00, GPR32>;
2811 defm STLURX : BaseStoreUnscaleV84<"stlur", 0b11, 0b00, GPR64>;
2812 defm LDAPURB : BaseLoadUnscaleV84<"ldapurb", 0b00, 0b01, GPR32>;
2813 defm LDAPURSBW : BaseLoadUnscaleV84<"ldapursb", 0b00, 0b11, GPR32>;
2814 defm LDAPURSBX : BaseLoadUnscaleV84<"ldapursb", 0b00, 0b10, GPR64>;
2815 defm LDAPURH : BaseLoadUnscaleV84<"ldapurh", 0b01, 0b01, GPR32>;
2816 defm LDAPURSHW : BaseLoadUnscaleV84<"ldapursh", 0b01, 0b11, GPR32>;
2817 defm LDAPURSHX : BaseLoadUnscaleV84<"ldapursh", 0b01, 0b10, GPR64>;
2818 defm LDAPUR : BaseLoadUnscaleV84<"ldapur", 0b10, 0b01, GPR32>;
2819 defm LDAPURSW : BaseLoadUnscaleV84<"ldapursw", 0b10, 0b10, GPR64>;
2820 defm LDAPURX : BaseLoadUnscaleV84<"ldapur", 0b11, 0b01, GPR64>;
2823 // Match all store 64 bits width whose type is compatible with FPR64
2824 def : Pat<(store (v1f64 FPR64:$Rt), (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2825 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2826 def : Pat<(store (v1i64 FPR64:$Rt), (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2827 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2829 let AddedComplexity = 10 in {
2831 let Predicates = [IsLE] in {
2832 // We must use ST1 to store vectors in big-endian.
2833 def : Pat<(store (v2f32 FPR64:$Rt),
2834 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2835 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2836 def : Pat<(store (v8i8 FPR64:$Rt),
2837 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2838 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2839 def : Pat<(store (v4i16 FPR64:$Rt),
2840 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2841 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2842 def : Pat<(store (v2i32 FPR64:$Rt),
2843 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2844 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2845 def : Pat<(store (v4f16 FPR64:$Rt),
2846 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2847 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2850 // Match all store 128 bits width whose type is compatible with FPR128
2851 def : Pat<(store (f128 FPR128:$Rt), (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2852 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2854 let Predicates = [IsLE] in {
2855 // We must use ST1 to store vectors in big-endian.
2856 def : Pat<(store (v4f32 FPR128:$Rt),
2857 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2858 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2859 def : Pat<(store (v2f64 FPR128:$Rt),
2860 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2861 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2862 def : Pat<(store (v16i8 FPR128:$Rt),
2863 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2864 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2865 def : Pat<(store (v8i16 FPR128:$Rt),
2866 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2867 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2868 def : Pat<(store (v4i32 FPR128:$Rt),
2869 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2870 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2871 def : Pat<(store (v2i64 FPR128:$Rt),
2872 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2873 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2874 def : Pat<(store (v2f64 FPR128:$Rt),
2875 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2876 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2877 def : Pat<(store (v8f16 FPR128:$Rt),
2878 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2879 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2882 } // AddedComplexity = 10
2884 // unscaled i64 truncating stores
2885 def : Pat<(truncstorei32 GPR64:$Rt, (am_unscaled32 GPR64sp:$Rn, simm9:$offset)),
2886 (STURWi (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, simm9:$offset)>;
2887 def : Pat<(truncstorei16 GPR64:$Rt, (am_unscaled16 GPR64sp:$Rn, simm9:$offset)),
2888 (STURHHi (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, simm9:$offset)>;
2889 def : Pat<(truncstorei8 GPR64:$Rt, (am_unscaled8 GPR64sp:$Rn, simm9:$offset)),
2890 (STURBBi (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, simm9:$offset)>;
2892 // Match stores from lane 0 to the appropriate subreg's store.
2893 multiclass VecStoreULane0Pat<SDPatternOperator StoreOp,
2894 ValueType VTy, ValueType STy,
2895 SubRegIndex SubRegIdx, Instruction STR> {
2896 defm : VecStoreLane0Pat<am_unscaled128, StoreOp, VTy, STy, SubRegIdx, simm9, STR>;
2899 let AddedComplexity = 19 in {
2900 defm : VecStoreULane0Pat<truncstorei16, v8i16, i32, hsub, STURHi>;
2901 defm : VecStoreULane0Pat<store, v8f16, f16, hsub, STURHi>;
2902 defm : VecStoreULane0Pat<store, v4i32, i32, ssub, STURSi>;
2903 defm : VecStoreULane0Pat<store, v4f32, f32, ssub, STURSi>;
2904 defm : VecStoreULane0Pat<store, v2i64, i64, dsub, STURDi>;
2905 defm : VecStoreULane0Pat<store, v2f64, f64, dsub, STURDi>;
2909 // STR mnemonics fall back to STUR for negative or unaligned offsets.
2910 def : InstAlias<"str $Rt, [$Rn, $offset]",
2911 (STURXi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb64:$offset), 0>;
2912 def : InstAlias<"str $Rt, [$Rn, $offset]",
2913 (STURWi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
2914 def : InstAlias<"str $Rt, [$Rn, $offset]",
2915 (STURBi FPR8Op:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2916 def : InstAlias<"str $Rt, [$Rn, $offset]",
2917 (STURHi FPR16Op:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2918 def : InstAlias<"str $Rt, [$Rn, $offset]",
2919 (STURSi FPR32Op:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
2920 def : InstAlias<"str $Rt, [$Rn, $offset]",
2921 (STURDi FPR64Op:$Rt, GPR64sp:$Rn, simm9_offset_fb64:$offset), 0>;
2922 def : InstAlias<"str $Rt, [$Rn, $offset]",
2923 (STURQi FPR128Op:$Rt, GPR64sp:$Rn, simm9_offset_fb128:$offset), 0>;
2925 def : InstAlias<"strb $Rt, [$Rn, $offset]",
2926 (STURBBi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2927 def : InstAlias<"strh $Rt, [$Rn, $offset]",
2928 (STURHHi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2931 // (unscaled immediate, unprivileged)
2932 defm STTRW : StoreUnprivileged<0b10, 0, 0b00, GPR32, "sttr">;
2933 defm STTRX : StoreUnprivileged<0b11, 0, 0b00, GPR64, "sttr">;
2935 defm STTRH : StoreUnprivileged<0b01, 0, 0b00, GPR32, "sttrh">;
2936 defm STTRB : StoreUnprivileged<0b00, 0, 0b00, GPR32, "sttrb">;
2939 // (immediate pre-indexed)
2940 def STRWpre : StorePreIdx<0b10, 0, 0b00, GPR32z, "str", pre_store, i32>;
2941 def STRXpre : StorePreIdx<0b11, 0, 0b00, GPR64z, "str", pre_store, i64>;
2942 def STRBpre : StorePreIdx<0b00, 1, 0b00, FPR8Op, "str", pre_store, untyped>;
2943 def STRHpre : StorePreIdx<0b01, 1, 0b00, FPR16Op, "str", pre_store, f16>;
2944 def STRSpre : StorePreIdx<0b10, 1, 0b00, FPR32Op, "str", pre_store, f32>;
2945 def STRDpre : StorePreIdx<0b11, 1, 0b00, FPR64Op, "str", pre_store, f64>;
2946 def STRQpre : StorePreIdx<0b00, 1, 0b10, FPR128Op, "str", pre_store, f128>;
2948 def STRBBpre : StorePreIdx<0b00, 0, 0b00, GPR32z, "strb", pre_truncsti8, i32>;
2949 def STRHHpre : StorePreIdx<0b01, 0, 0b00, GPR32z, "strh", pre_truncsti16, i32>;
2952 def : Pat<(pre_truncsti32 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
2953 (STRWpre (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
2955 def : Pat<(pre_truncsti16 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
2956 (STRHHpre (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
2958 def : Pat<(pre_truncsti8 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
2959 (STRBBpre (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
2962 def : Pat<(pre_store (v8i8 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2963 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2964 def : Pat<(pre_store (v4i16 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2965 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2966 def : Pat<(pre_store (v2i32 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2967 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2968 def : Pat<(pre_store (v2f32 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2969 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2970 def : Pat<(pre_store (v1i64 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2971 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2972 def : Pat<(pre_store (v1f64 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2973 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2974 def : Pat<(pre_store (v4f16 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2975 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2977 def : Pat<(pre_store (v16i8 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2978 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2979 def : Pat<(pre_store (v8i16 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2980 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2981 def : Pat<(pre_store (v4i32 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2982 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2983 def : Pat<(pre_store (v4f32 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2984 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2985 def : Pat<(pre_store (v2i64 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2986 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2987 def : Pat<(pre_store (v2f64 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2988 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2989 def : Pat<(pre_store (v8f16 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2990 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2993 // (immediate post-indexed)
2994 def STRWpost : StorePostIdx<0b10, 0, 0b00, GPR32z, "str", post_store, i32>;
2995 def STRXpost : StorePostIdx<0b11, 0, 0b00, GPR64z, "str", post_store, i64>;
2996 def STRBpost : StorePostIdx<0b00, 1, 0b00, FPR8Op, "str", post_store, untyped>;
2997 def STRHpost : StorePostIdx<0b01, 1, 0b00, FPR16Op, "str", post_store, f16>;
2998 def STRSpost : StorePostIdx<0b10, 1, 0b00, FPR32Op, "str", post_store, f32>;
2999 def STRDpost : StorePostIdx<0b11, 1, 0b00, FPR64Op, "str", post_store, f64>;
3000 def STRQpost : StorePostIdx<0b00, 1, 0b10, FPR128Op, "str", post_store, f128>;
3002 def STRBBpost : StorePostIdx<0b00, 0, 0b00, GPR32z, "strb", post_truncsti8, i32>;
3003 def STRHHpost : StorePostIdx<0b01, 0, 0b00, GPR32z, "strh", post_truncsti16, i32>;
3006 def : Pat<(post_truncsti32 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
3007 (STRWpost (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
3009 def : Pat<(post_truncsti16 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
3010 (STRHHpost (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
3012 def : Pat<(post_truncsti8 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
3013 (STRBBpost (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
3016 def : Pat<(post_store (v8i8 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
3017 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
3018 def : Pat<(post_store (v4i16 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
3019 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
3020 def : Pat<(post_store (v2i32 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
3021 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
3022 def : Pat<(post_store (v2f32 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
3023 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
3024 def : Pat<(post_store (v1i64 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
3025 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
3026 def : Pat<(post_store (v1f64 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
3027 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
3028 def : Pat<(post_store (v4f16 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
3029 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
3031 def : Pat<(post_store (v16i8 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3032 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3033 def : Pat<(post_store (v8i16 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3034 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3035 def : Pat<(post_store (v4i32 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3036 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3037 def : Pat<(post_store (v4f32 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3038 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3039 def : Pat<(post_store (v2i64 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3040 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3041 def : Pat<(post_store (v2f64 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3042 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3043 def : Pat<(post_store (v8f16 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
3044 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
3046 //===----------------------------------------------------------------------===//
3047 // Load/store exclusive instructions.
3048 //===----------------------------------------------------------------------===//
3050 def LDARW : LoadAcquire <0b10, 1, 1, 0, 1, GPR32, "ldar">;
3051 def LDARX : LoadAcquire <0b11, 1, 1, 0, 1, GPR64, "ldar">;
3052 def LDARB : LoadAcquire <0b00, 1, 1, 0, 1, GPR32, "ldarb">;
3053 def LDARH : LoadAcquire <0b01, 1, 1, 0, 1, GPR32, "ldarh">;
3055 def LDAXRW : LoadExclusive <0b10, 0, 1, 0, 1, GPR32, "ldaxr">;
3056 def LDAXRX : LoadExclusive <0b11, 0, 1, 0, 1, GPR64, "ldaxr">;
3057 def LDAXRB : LoadExclusive <0b00, 0, 1, 0, 1, GPR32, "ldaxrb">;
3058 def LDAXRH : LoadExclusive <0b01, 0, 1, 0, 1, GPR32, "ldaxrh">;
3060 def LDXRW : LoadExclusive <0b10, 0, 1, 0, 0, GPR32, "ldxr">;
3061 def LDXRX : LoadExclusive <0b11, 0, 1, 0, 0, GPR64, "ldxr">;
3062 def LDXRB : LoadExclusive <0b00, 0, 1, 0, 0, GPR32, "ldxrb">;
3063 def LDXRH : LoadExclusive <0b01, 0, 1, 0, 0, GPR32, "ldxrh">;
3065 def STLRW : StoreRelease <0b10, 1, 0, 0, 1, GPR32, "stlr">;
3066 def STLRX : StoreRelease <0b11, 1, 0, 0, 1, GPR64, "stlr">;
3067 def STLRB : StoreRelease <0b00, 1, 0, 0, 1, GPR32, "stlrb">;
3068 def STLRH : StoreRelease <0b01, 1, 0, 0, 1, GPR32, "stlrh">;
3070 def STLXRW : StoreExclusive<0b10, 0, 0, 0, 1, GPR32, "stlxr">;
3071 def STLXRX : StoreExclusive<0b11, 0, 0, 0, 1, GPR64, "stlxr">;
3072 def STLXRB : StoreExclusive<0b00, 0, 0, 0, 1, GPR32, "stlxrb">;
3073 def STLXRH : StoreExclusive<0b01, 0, 0, 0, 1, GPR32, "stlxrh">;
3075 def STXRW : StoreExclusive<0b10, 0, 0, 0, 0, GPR32, "stxr">;
3076 def STXRX : StoreExclusive<0b11, 0, 0, 0, 0, GPR64, "stxr">;
3077 def STXRB : StoreExclusive<0b00, 0, 0, 0, 0, GPR32, "stxrb">;
3078 def STXRH : StoreExclusive<0b01, 0, 0, 0, 0, GPR32, "stxrh">;
3080 def LDAXPW : LoadExclusivePair<0b10, 0, 1, 1, 1, GPR32, "ldaxp">;
3081 def LDAXPX : LoadExclusivePair<0b11, 0, 1, 1, 1, GPR64, "ldaxp">;
3083 def LDXPW : LoadExclusivePair<0b10, 0, 1, 1, 0, GPR32, "ldxp">;
3084 def LDXPX : LoadExclusivePair<0b11, 0, 1, 1, 0, GPR64, "ldxp">;
3086 def STLXPW : StoreExclusivePair<0b10, 0, 0, 1, 1, GPR32, "stlxp">;
3087 def STLXPX : StoreExclusivePair<0b11, 0, 0, 1, 1, GPR64, "stlxp">;
3089 def STXPW : StoreExclusivePair<0b10, 0, 0, 1, 0, GPR32, "stxp">;
3090 def STXPX : StoreExclusivePair<0b11, 0, 0, 1, 0, GPR64, "stxp">;
3092 let Predicates = [HasLOR] in {
3093 // v8.1a "Limited Order Region" extension load-acquire instructions
3094 def LDLARW : LoadAcquire <0b10, 1, 1, 0, 0, GPR32, "ldlar">;
3095 def LDLARX : LoadAcquire <0b11, 1, 1, 0, 0, GPR64, "ldlar">;
3096 def LDLARB : LoadAcquire <0b00, 1, 1, 0, 0, GPR32, "ldlarb">;
3097 def LDLARH : LoadAcquire <0b01, 1, 1, 0, 0, GPR32, "ldlarh">;
3099 // v8.1a "Limited Order Region" extension store-release instructions
3100 def STLLRW : StoreRelease <0b10, 1, 0, 0, 0, GPR32, "stllr">;
3101 def STLLRX : StoreRelease <0b11, 1, 0, 0, 0, GPR64, "stllr">;
3102 def STLLRB : StoreRelease <0b00, 1, 0, 0, 0, GPR32, "stllrb">;
3103 def STLLRH : StoreRelease <0b01, 1, 0, 0, 0, GPR32, "stllrh">;
3106 //===----------------------------------------------------------------------===//
3107 // Scaled floating point to integer conversion instructions.
3108 //===----------------------------------------------------------------------===//
3110 defm FCVTAS : FPToIntegerUnscaled<0b00, 0b100, "fcvtas", int_aarch64_neon_fcvtas>;
3111 defm FCVTAU : FPToIntegerUnscaled<0b00, 0b101, "fcvtau", int_aarch64_neon_fcvtau>;
3112 defm FCVTMS : FPToIntegerUnscaled<0b10, 0b000, "fcvtms", int_aarch64_neon_fcvtms>;
3113 defm FCVTMU : FPToIntegerUnscaled<0b10, 0b001, "fcvtmu", int_aarch64_neon_fcvtmu>;
3114 defm FCVTNS : FPToIntegerUnscaled<0b00, 0b000, "fcvtns", int_aarch64_neon_fcvtns>;
3115 defm FCVTNU : FPToIntegerUnscaled<0b00, 0b001, "fcvtnu", int_aarch64_neon_fcvtnu>;
3116 defm FCVTPS : FPToIntegerUnscaled<0b01, 0b000, "fcvtps", int_aarch64_neon_fcvtps>;
3117 defm FCVTPU : FPToIntegerUnscaled<0b01, 0b001, "fcvtpu", int_aarch64_neon_fcvtpu>;
3118 defm FCVTZS : FPToIntegerUnscaled<0b11, 0b000, "fcvtzs", fp_to_sint>;
3119 defm FCVTZU : FPToIntegerUnscaled<0b11, 0b001, "fcvtzu", fp_to_uint>;
3120 defm FCVTZS : FPToIntegerScaled<0b11, 0b000, "fcvtzs", fp_to_sint>;
3121 defm FCVTZU : FPToIntegerScaled<0b11, 0b001, "fcvtzu", fp_to_uint>;
3123 multiclass FPToIntegerIntPats<Intrinsic round, string INST> {
3124 def : Pat<(i32 (round f16:$Rn)), (!cast<Instruction>(INST # UWHr) $Rn)>;
3125 def : Pat<(i64 (round f16:$Rn)), (!cast<Instruction>(INST # UXHr) $Rn)>;
3126 def : Pat<(i32 (round f32:$Rn)), (!cast<Instruction>(INST # UWSr) $Rn)>;
3127 def : Pat<(i64 (round f32:$Rn)), (!cast<Instruction>(INST # UXSr) $Rn)>;
3128 def : Pat<(i32 (round f64:$Rn)), (!cast<Instruction>(INST # UWDr) $Rn)>;
3129 def : Pat<(i64 (round f64:$Rn)), (!cast<Instruction>(INST # UXDr) $Rn)>;
3131 def : Pat<(i32 (round (fmul f16:$Rn, fixedpoint_f16_i32:$scale))),
3132 (!cast<Instruction>(INST # SWHri) $Rn, $scale)>;
3133 def : Pat<(i64 (round (fmul f16:$Rn, fixedpoint_f16_i64:$scale))),
3134 (!cast<Instruction>(INST # SXHri) $Rn, $scale)>;
3135 def : Pat<(i32 (round (fmul f32:$Rn, fixedpoint_f32_i32:$scale))),
3136 (!cast<Instruction>(INST # SWSri) $Rn, $scale)>;
3137 def : Pat<(i64 (round (fmul f32:$Rn, fixedpoint_f32_i64:$scale))),
3138 (!cast<Instruction>(INST # SXSri) $Rn, $scale)>;
3139 def : Pat<(i32 (round (fmul f64:$Rn, fixedpoint_f64_i32:$scale))),
3140 (!cast<Instruction>(INST # SWDri) $Rn, $scale)>;
3141 def : Pat<(i64 (round (fmul f64:$Rn, fixedpoint_f64_i64:$scale))),
3142 (!cast<Instruction>(INST # SXDri) $Rn, $scale)>;
3145 defm : FPToIntegerIntPats<int_aarch64_neon_fcvtzs, "FCVTZS">;
3146 defm : FPToIntegerIntPats<int_aarch64_neon_fcvtzu, "FCVTZU">;
3148 multiclass FPToIntegerPats<SDNode to_int, SDNode round, string INST> {
3149 def : Pat<(i32 (to_int (round f32:$Rn))),
3150 (!cast<Instruction>(INST # UWSr) f32:$Rn)>;
3151 def : Pat<(i64 (to_int (round f32:$Rn))),
3152 (!cast<Instruction>(INST # UXSr) f32:$Rn)>;
3153 def : Pat<(i32 (to_int (round f64:$Rn))),
3154 (!cast<Instruction>(INST # UWDr) f64:$Rn)>;
3155 def : Pat<(i64 (to_int (round f64:$Rn))),
3156 (!cast<Instruction>(INST # UXDr) f64:$Rn)>;
3159 defm : FPToIntegerPats<fp_to_sint, fceil, "FCVTPS">;
3160 defm : FPToIntegerPats<fp_to_uint, fceil, "FCVTPU">;
3161 defm : FPToIntegerPats<fp_to_sint, ffloor, "FCVTMS">;
3162 defm : FPToIntegerPats<fp_to_uint, ffloor, "FCVTMU">;
3163 defm : FPToIntegerPats<fp_to_sint, ftrunc, "FCVTZS">;
3164 defm : FPToIntegerPats<fp_to_uint, ftrunc, "FCVTZU">;
3165 defm : FPToIntegerPats<fp_to_sint, fround, "FCVTAS">;
3166 defm : FPToIntegerPats<fp_to_uint, fround, "FCVTAU">;
3168 let Predicates = [HasFullFP16] in {
3169 def : Pat<(i32 (lround f16:$Rn)),
3170 (!cast<Instruction>(FCVTASUWHr) f16:$Rn)>;
3171 def : Pat<(i64 (lround f16:$Rn)),
3172 (!cast<Instruction>(FCVTASUXHr) f16:$Rn)>;
3173 def : Pat<(i64 (llround f16:$Rn)),
3174 (!cast<Instruction>(FCVTASUXHr) f16:$Rn)>;
3176 def : Pat<(i32 (lround f32:$Rn)),
3177 (!cast<Instruction>(FCVTASUWSr) f32:$Rn)>;
3178 def : Pat<(i32 (lround f64:$Rn)),
3179 (!cast<Instruction>(FCVTASUWDr) f64:$Rn)>;
3180 def : Pat<(i64 (lround f32:$Rn)),
3181 (!cast<Instruction>(FCVTASUXSr) f32:$Rn)>;
3182 def : Pat<(i64 (lround f64:$Rn)),
3183 (!cast<Instruction>(FCVTASUXDr) f64:$Rn)>;
3184 def : Pat<(i64 (llround f32:$Rn)),
3185 (!cast<Instruction>(FCVTASUXSr) f32:$Rn)>;
3186 def : Pat<(i64 (llround f64:$Rn)),
3187 (!cast<Instruction>(FCVTASUXDr) f64:$Rn)>;
3189 //===----------------------------------------------------------------------===//
3190 // Scaled integer to floating point conversion instructions.
3191 //===----------------------------------------------------------------------===//
3193 defm SCVTF : IntegerToFP<0, "scvtf", sint_to_fp>;
3194 defm UCVTF : IntegerToFP<1, "ucvtf", uint_to_fp>;
3196 //===----------------------------------------------------------------------===//
3197 // Unscaled integer to floating point conversion instruction.
3198 //===----------------------------------------------------------------------===//
3200 defm FMOV : UnscaledConversion<"fmov">;
3202 // Add pseudo ops for FMOV 0 so we can mark them as isReMaterializable
3203 let isReMaterializable = 1, isCodeGenOnly = 1, isAsCheapAsAMove = 1 in {
3204 def FMOVH0 : Pseudo<(outs FPR16:$Rd), (ins), [(set f16:$Rd, (fpimm0))]>,
3205 Sched<[WriteF]>, Requires<[HasFullFP16]>;
3206 def FMOVS0 : Pseudo<(outs FPR32:$Rd), (ins), [(set f32:$Rd, (fpimm0))]>,
3208 def FMOVD0 : Pseudo<(outs FPR64:$Rd), (ins), [(set f64:$Rd, (fpimm0))]>,
3211 // Similarly add aliases
3212 def : InstAlias<"fmov $Rd, #0.0", (FMOVWHr FPR16:$Rd, WZR), 0>,
3213 Requires<[HasFullFP16]>;
3214 def : InstAlias<"fmov $Rd, #0.0", (FMOVWSr FPR32:$Rd, WZR), 0>;
3215 def : InstAlias<"fmov $Rd, #0.0", (FMOVXDr FPR64:$Rd, XZR), 0>;
3217 //===----------------------------------------------------------------------===//
3218 // Floating point conversion instruction.
3219 //===----------------------------------------------------------------------===//
3221 defm FCVT : FPConversion<"fcvt">;
3223 //===----------------------------------------------------------------------===//
3224 // Floating point single operand instructions.
3225 //===----------------------------------------------------------------------===//
3227 defm FABS : SingleOperandFPData<0b0001, "fabs", fabs>;
3228 defm FMOV : SingleOperandFPData<0b0000, "fmov">;
3229 defm FNEG : SingleOperandFPData<0b0010, "fneg", fneg>;
3230 defm FRINTA : SingleOperandFPData<0b1100, "frinta", fround>;
3231 defm FRINTI : SingleOperandFPData<0b1111, "frinti", fnearbyint>;
3232 defm FRINTM : SingleOperandFPData<0b1010, "frintm", ffloor>;
3233 defm FRINTN : SingleOperandFPData<0b1000, "frintn", int_aarch64_neon_frintn>;
3234 defm FRINTP : SingleOperandFPData<0b1001, "frintp", fceil>;
3236 def : Pat<(v1f64 (int_aarch64_neon_frintn (v1f64 FPR64:$Rn))),
3237 (FRINTNDr FPR64:$Rn)>;
3239 defm FRINTX : SingleOperandFPData<0b1110, "frintx", frint>;
3240 defm FRINTZ : SingleOperandFPData<0b1011, "frintz", ftrunc>;
3242 let SchedRW = [WriteFDiv] in {
3243 defm FSQRT : SingleOperandFPData<0b0011, "fsqrt", fsqrt>;
3246 let Predicates = [HasFRInt3264] in {
3247 defm FRINT32Z : FRIntNNT<0b00, "frint32z">;
3248 defm FRINT64Z : FRIntNNT<0b10, "frint64z">;
3249 defm FRINT32X : FRIntNNT<0b01, "frint32x">;
3250 defm FRINT64X : FRIntNNT<0b11, "frint64x">;
3253 let Predicates = [HasFullFP16] in {
3254 def : Pat<(i32 (lrint f16:$Rn)),
3255 (FCVTZSUWHr (!cast<Instruction>(FRINTXHr) f16:$Rn))>;
3256 def : Pat<(i64 (lrint f16:$Rn)),
3257 (FCVTZSUXHr (!cast<Instruction>(FRINTXHr) f16:$Rn))>;
3258 def : Pat<(i64 (llrint f16:$Rn)),
3259 (FCVTZSUXHr (!cast<Instruction>(FRINTXHr) f16:$Rn))>;
3261 def : Pat<(i32 (lrint f32:$Rn)),
3262 (FCVTZSUWSr (!cast<Instruction>(FRINTXSr) f32:$Rn))>;
3263 def : Pat<(i32 (lrint f64:$Rn)),
3264 (FCVTZSUWDr (!cast<Instruction>(FRINTXDr) f64:$Rn))>;
3265 def : Pat<(i64 (lrint f32:$Rn)),
3266 (FCVTZSUXSr (!cast<Instruction>(FRINTXSr) f32:$Rn))>;
3267 def : Pat<(i64 (lrint f64:$Rn)),
3268 (FCVTZSUXDr (!cast<Instruction>(FRINTXDr) f64:$Rn))>;
3269 def : Pat<(i64 (llrint f32:$Rn)),
3270 (FCVTZSUXSr (!cast<Instruction>(FRINTXSr) f32:$Rn))>;
3271 def : Pat<(i64 (llrint f64:$Rn)),
3272 (FCVTZSUXDr (!cast<Instruction>(FRINTXDr) f64:$Rn))>;
3274 //===----------------------------------------------------------------------===//
3275 // Floating point two operand instructions.
3276 //===----------------------------------------------------------------------===//
3278 defm FADD : TwoOperandFPData<0b0010, "fadd", fadd>;
3279 let SchedRW = [WriteFDiv] in {
3280 defm FDIV : TwoOperandFPData<0b0001, "fdiv", fdiv>;
3282 defm FMAXNM : TwoOperandFPData<0b0110, "fmaxnm", fmaxnum>;
3283 defm FMAX : TwoOperandFPData<0b0100, "fmax", fmaximum>;
3284 defm FMINNM : TwoOperandFPData<0b0111, "fminnm", fminnum>;
3285 defm FMIN : TwoOperandFPData<0b0101, "fmin", fminimum>;
3286 let SchedRW = [WriteFMul] in {
3287 defm FMUL : TwoOperandFPData<0b0000, "fmul", fmul>;
3288 defm FNMUL : TwoOperandFPDataNeg<0b1000, "fnmul", fmul>;
3290 defm FSUB : TwoOperandFPData<0b0011, "fsub", fsub>;
3292 def : Pat<(v1f64 (fmaximum (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
3293 (FMAXDrr FPR64:$Rn, FPR64:$Rm)>;
3294 def : Pat<(v1f64 (fminimum (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
3295 (FMINDrr FPR64:$Rn, FPR64:$Rm)>;
3296 def : Pat<(v1f64 (fmaxnum (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
3297 (FMAXNMDrr FPR64:$Rn, FPR64:$Rm)>;
3298 def : Pat<(v1f64 (fminnum (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
3299 (FMINNMDrr FPR64:$Rn, FPR64:$Rm)>;
3301 //===----------------------------------------------------------------------===//
3302 // Floating point three operand instructions.
3303 //===----------------------------------------------------------------------===//
3305 defm FMADD : ThreeOperandFPData<0, 0, "fmadd", fma>;
3306 defm FMSUB : ThreeOperandFPData<0, 1, "fmsub",
3307 TriOpFrag<(fma node:$LHS, (fneg node:$MHS), node:$RHS)> >;
3308 defm FNMADD : ThreeOperandFPData<1, 0, "fnmadd",
3309 TriOpFrag<(fneg (fma node:$LHS, node:$MHS, node:$RHS))> >;
3310 defm FNMSUB : ThreeOperandFPData<1, 1, "fnmsub",
3311 TriOpFrag<(fma node:$LHS, node:$MHS, (fneg node:$RHS))> >;
3313 // The following def pats catch the case where the LHS of an FMA is negated.
3314 // The TriOpFrag above catches the case where the middle operand is negated.
3316 // N.b. FMSUB etc have the accumulator at the *end* of (outs), unlike
3317 // the NEON variant.
3318 def : Pat<(f32 (fma (fneg FPR32:$Rn), FPR32:$Rm, FPR32:$Ra)),
3319 (FMSUBSrrr FPR32:$Rn, FPR32:$Rm, FPR32:$Ra)>;
3321 def : Pat<(f64 (fma (fneg FPR64:$Rn), FPR64:$Rm, FPR64:$Ra)),
3322 (FMSUBDrrr FPR64:$Rn, FPR64:$Rm, FPR64:$Ra)>;
3324 // We handled -(a + b*c) for FNMADD above, now it's time for "(-a) + (-b)*c" and
3326 def : Pat<(f32 (fma (fneg FPR32:$Rn), FPR32:$Rm, (fneg FPR32:$Ra))),
3327 (FNMADDSrrr FPR32:$Rn, FPR32:$Rm, FPR32:$Ra)>;
3329 def : Pat<(f64 (fma (fneg FPR64:$Rn), FPR64:$Rm, (fneg FPR64:$Ra))),
3330 (FNMADDDrrr FPR64:$Rn, FPR64:$Rm, FPR64:$Ra)>;
3332 def : Pat<(f32 (fma FPR32:$Rn, (fneg FPR32:$Rm), (fneg FPR32:$Ra))),
3333 (FNMADDSrrr FPR32:$Rn, FPR32:$Rm, FPR32:$Ra)>;
3335 def : Pat<(f64 (fma FPR64:$Rn, (fneg FPR64:$Rm), (fneg FPR64:$Ra))),
3336 (FNMADDDrrr FPR64:$Rn, FPR64:$Rm, FPR64:$Ra)>;
3338 //===----------------------------------------------------------------------===//
3339 // Floating point comparison instructions.
3340 //===----------------------------------------------------------------------===//
3342 defm FCMPE : FPComparison<1, "fcmpe">;
3343 defm FCMP : FPComparison<0, "fcmp", AArch64fcmp>;
3345 //===----------------------------------------------------------------------===//
3346 // Floating point conditional comparison instructions.
3347 //===----------------------------------------------------------------------===//
3349 defm FCCMPE : FPCondComparison<1, "fccmpe">;
3350 defm FCCMP : FPCondComparison<0, "fccmp", AArch64fccmp>;
3352 //===----------------------------------------------------------------------===//
3353 // Floating point conditional select instruction.
3354 //===----------------------------------------------------------------------===//
3356 defm FCSEL : FPCondSelect<"fcsel">;
3358 // CSEL instructions providing f128 types need to be handled by a
3359 // pseudo-instruction since the eventual code will need to introduce basic
3360 // blocks and control flow.
3361 def F128CSEL : Pseudo<(outs FPR128:$Rd),
3362 (ins FPR128:$Rn, FPR128:$Rm, ccode:$cond),
3363 [(set (f128 FPR128:$Rd),
3364 (AArch64csel FPR128:$Rn, FPR128:$Rm,
3365 (i32 imm:$cond), NZCV))]> {
3367 let usesCustomInserter = 1;
3368 let hasNoSchedulingInfo = 1;
3371 //===----------------------------------------------------------------------===//
3372 // Instructions used for emitting unwind opcodes on ARM64 Windows.
3373 //===----------------------------------------------------------------------===//
3374 let isPseudo = 1 in {
3375 def SEH_StackAlloc : Pseudo<(outs), (ins i32imm:$size), []>, Sched<[]>;
3376 def SEH_SaveFPLR : Pseudo<(outs), (ins i32imm:$offs), []>, Sched<[]>;
3377 def SEH_SaveFPLR_X : Pseudo<(outs), (ins i32imm:$offs), []>, Sched<[]>;
3378 def SEH_SaveReg : Pseudo<(outs), (ins i32imm:$reg, i32imm:$offs), []>, Sched<[]>;
3379 def SEH_SaveReg_X : Pseudo<(outs), (ins i32imm:$reg, i32imm:$offs), []>, Sched<[]>;
3380 def SEH_SaveRegP : Pseudo<(outs), (ins i32imm:$reg0, i32imm:$reg1, i32imm:$offs), []>, Sched<[]>;
3381 def SEH_SaveRegP_X : Pseudo<(outs), (ins i32imm:$reg0, i32imm:$reg1, i32imm:$offs), []>, Sched<[]>;
3382 def SEH_SaveFReg : Pseudo<(outs), (ins i32imm:$reg, i32imm:$offs), []>, Sched<[]>;
3383 def SEH_SaveFReg_X : Pseudo<(outs), (ins i32imm:$reg, i32imm:$offs), []>, Sched<[]>;
3384 def SEH_SaveFRegP : Pseudo<(outs), (ins i32imm:$reg0, i32imm:$reg1, i32imm:$offs), []>, Sched<[]>;
3385 def SEH_SaveFRegP_X : Pseudo<(outs), (ins i32imm:$reg0, i32imm:$reg1, i32imm:$offs), []>, Sched<[]>;
3386 def SEH_SetFP : Pseudo<(outs), (ins), []>, Sched<[]>;
3387 def SEH_AddFP : Pseudo<(outs), (ins i32imm:$offs), []>, Sched<[]>;
3388 def SEH_Nop : Pseudo<(outs), (ins), []>, Sched<[]>;
3389 def SEH_PrologEnd : Pseudo<(outs), (ins), []>, Sched<[]>;
3390 def SEH_EpilogStart : Pseudo<(outs), (ins), []>, Sched<[]>;
3391 def SEH_EpilogEnd : Pseudo<(outs), (ins), []>, Sched<[]>;
3394 // Pseudo instructions for Windows EH
3395 //===----------------------------------------------------------------------===//
3396 let isTerminator = 1, hasSideEffects = 1, isBarrier = 1, hasCtrlDep = 1,
3397 isCodeGenOnly = 1, isReturn = 1, isEHScopeReturn = 1, isPseudo = 1 in {
3398 def CLEANUPRET : Pseudo<(outs), (ins), [(cleanupret)]>, Sched<[]>;
3399 let usesCustomInserter = 1 in
3400 def CATCHRET : Pseudo<(outs), (ins am_brcond:$dst, am_brcond:$src), [(catchret bb:$dst, bb:$src)]>,
3404 let hasSideEffects = 1, hasCtrlDep = 1, isCodeGenOnly = 1,
3405 usesCustomInserter = 1 in
3406 def CATCHPAD : Pseudo<(outs), (ins), [(catchpad)]>, Sched<[]>;
3408 //===----------------------------------------------------------------------===//
3409 // Floating point immediate move.
3410 //===----------------------------------------------------------------------===//
3412 let isReMaterializable = 1 in {
3413 defm FMOV : FPMoveImmediate<"fmov">;
3416 //===----------------------------------------------------------------------===//
3417 // Advanced SIMD two vector instructions.
3418 //===----------------------------------------------------------------------===//
3420 defm UABDL : SIMDLongThreeVectorBHSabdl<1, 0b0111, "uabdl",
3421 int_aarch64_neon_uabd>;
3422 // Match UABDL in log2-shuffle patterns.
3423 def : Pat<(abs (v8i16 (sub (zext (v8i8 V64:$opA)),
3424 (zext (v8i8 V64:$opB))))),
3425 (UABDLv8i8_v8i16 V64:$opA, V64:$opB)>;
3426 def : Pat<(xor (v8i16 (AArch64vashr v8i16:$src, (i32 15))),
3427 (v8i16 (add (sub (zext (v8i8 V64:$opA)),
3428 (zext (v8i8 V64:$opB))),
3429 (AArch64vashr v8i16:$src, (i32 15))))),
3430 (UABDLv8i8_v8i16 V64:$opA, V64:$opB)>;
3431 def : Pat<(abs (v8i16 (sub (zext (extract_high_v16i8 V128:$opA)),
3432 (zext (extract_high_v16i8 V128:$opB))))),
3433 (UABDLv16i8_v8i16 V128:$opA, V128:$opB)>;
3434 def : Pat<(xor (v8i16 (AArch64vashr v8i16:$src, (i32 15))),
3435 (v8i16 (add (sub (zext (extract_high_v16i8 V128:$opA)),
3436 (zext (extract_high_v16i8 V128:$opB))),
3437 (AArch64vashr v8i16:$src, (i32 15))))),
3438 (UABDLv16i8_v8i16 V128:$opA, V128:$opB)>;
3439 def : Pat<(abs (v4i32 (sub (zext (v4i16 V64:$opA)),
3440 (zext (v4i16 V64:$opB))))),
3441 (UABDLv4i16_v4i32 V64:$opA, V64:$opB)>;
3442 def : Pat<(abs (v4i32 (sub (zext (extract_high_v8i16 V128:$opA)),
3443 (zext (extract_high_v8i16 V128:$opB))))),
3444 (UABDLv8i16_v4i32 V128:$opA, V128:$opB)>;
3445 def : Pat<(abs (v2i64 (sub (zext (v2i32 V64:$opA)),
3446 (zext (v2i32 V64:$opB))))),
3447 (UABDLv2i32_v2i64 V64:$opA, V64:$opB)>;
3448 def : Pat<(abs (v2i64 (sub (zext (extract_high_v4i32 V128:$opA)),
3449 (zext (extract_high_v4i32 V128:$opB))))),
3450 (UABDLv4i32_v2i64 V128:$opA, V128:$opB)>;
3452 defm ABS : SIMDTwoVectorBHSD<0, 0b01011, "abs", abs>;
3453 defm CLS : SIMDTwoVectorBHS<0, 0b00100, "cls", int_aarch64_neon_cls>;
3454 defm CLZ : SIMDTwoVectorBHS<1, 0b00100, "clz", ctlz>;
3455 defm CMEQ : SIMDCmpTwoVector<0, 0b01001, "cmeq", AArch64cmeqz>;
3456 defm CMGE : SIMDCmpTwoVector<1, 0b01000, "cmge", AArch64cmgez>;
3457 defm CMGT : SIMDCmpTwoVector<0, 0b01000, "cmgt", AArch64cmgtz>;
3458 defm CMLE : SIMDCmpTwoVector<1, 0b01001, "cmle", AArch64cmlez>;
3459 defm CMLT : SIMDCmpTwoVector<0, 0b01010, "cmlt", AArch64cmltz>;
3460 defm CNT : SIMDTwoVectorB<0, 0b00, 0b00101, "cnt", ctpop>;
3461 defm FABS : SIMDTwoVectorFP<0, 1, 0b01111, "fabs", fabs>;
3463 defm FCMEQ : SIMDFPCmpTwoVector<0, 1, 0b01101, "fcmeq", AArch64fcmeqz>;
3464 defm FCMGE : SIMDFPCmpTwoVector<1, 1, 0b01100, "fcmge", AArch64fcmgez>;
3465 defm FCMGT : SIMDFPCmpTwoVector<0, 1, 0b01100, "fcmgt", AArch64fcmgtz>;
3466 defm FCMLE : SIMDFPCmpTwoVector<1, 1, 0b01101, "fcmle", AArch64fcmlez>;
3467 defm FCMLT : SIMDFPCmpTwoVector<0, 1, 0b01110, "fcmlt", AArch64fcmltz>;
3468 defm FCVTAS : SIMDTwoVectorFPToInt<0,0,0b11100, "fcvtas",int_aarch64_neon_fcvtas>;
3469 defm FCVTAU : SIMDTwoVectorFPToInt<1,0,0b11100, "fcvtau",int_aarch64_neon_fcvtau>;
3470 defm FCVTL : SIMDFPWidenTwoVector<0, 0, 0b10111, "fcvtl">;
3471 def : Pat<(v4f32 (int_aarch64_neon_vcvthf2fp (v4i16 V64:$Rn))),
3472 (FCVTLv4i16 V64:$Rn)>;
3473 def : Pat<(v4f32 (int_aarch64_neon_vcvthf2fp (extract_subvector (v8i16 V128:$Rn),
3475 (FCVTLv8i16 V128:$Rn)>;
3476 def : Pat<(v2f64 (fpextend (v2f32 V64:$Rn))), (FCVTLv2i32 V64:$Rn)>;
3477 def : Pat<(v2f64 (fpextend (v2f32 (extract_subvector (v4f32 V128:$Rn),
3479 (FCVTLv4i32 V128:$Rn)>;
3481 def : Pat<(v4f32 (fpextend (v4f16 V64:$Rn))), (FCVTLv4i16 V64:$Rn)>;
3482 def : Pat<(v4f32 (fpextend (v4f16 (extract_subvector (v8f16 V128:$Rn),
3484 (FCVTLv8i16 V128:$Rn)>;
3486 defm FCVTMS : SIMDTwoVectorFPToInt<0,0,0b11011, "fcvtms",int_aarch64_neon_fcvtms>;
3487 defm FCVTMU : SIMDTwoVectorFPToInt<1,0,0b11011, "fcvtmu",int_aarch64_neon_fcvtmu>;
3488 defm FCVTNS : SIMDTwoVectorFPToInt<0,0,0b11010, "fcvtns",int_aarch64_neon_fcvtns>;
3489 defm FCVTNU : SIMDTwoVectorFPToInt<1,0,0b11010, "fcvtnu",int_aarch64_neon_fcvtnu>;
3490 defm FCVTN : SIMDFPNarrowTwoVector<0, 0, 0b10110, "fcvtn">;
3491 def : Pat<(v4i16 (int_aarch64_neon_vcvtfp2hf (v4f32 V128:$Rn))),
3492 (FCVTNv4i16 V128:$Rn)>;
3493 def : Pat<(concat_vectors V64:$Rd,
3494 (v4i16 (int_aarch64_neon_vcvtfp2hf (v4f32 V128:$Rn)))),
3495 (FCVTNv8i16 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
3496 def : Pat<(v2f32 (fpround (v2f64 V128:$Rn))), (FCVTNv2i32 V128:$Rn)>;
3497 def : Pat<(v4f16 (fpround (v4f32 V128:$Rn))), (FCVTNv4i16 V128:$Rn)>;
3498 def : Pat<(concat_vectors V64:$Rd, (v2f32 (fpround (v2f64 V128:$Rn)))),
3499 (FCVTNv4i32 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
3500 defm FCVTPS : SIMDTwoVectorFPToInt<0,1,0b11010, "fcvtps",int_aarch64_neon_fcvtps>;
3501 defm FCVTPU : SIMDTwoVectorFPToInt<1,1,0b11010, "fcvtpu",int_aarch64_neon_fcvtpu>;
3502 defm FCVTXN : SIMDFPInexactCvtTwoVector<1, 0, 0b10110, "fcvtxn",
3503 int_aarch64_neon_fcvtxn>;
3504 defm FCVTZS : SIMDTwoVectorFPToInt<0, 1, 0b11011, "fcvtzs", fp_to_sint>;
3505 defm FCVTZU : SIMDTwoVectorFPToInt<1, 1, 0b11011, "fcvtzu", fp_to_uint>;
3507 def : Pat<(v4i16 (int_aarch64_neon_fcvtzs v4f16:$Rn)), (FCVTZSv4f16 $Rn)>;
3508 def : Pat<(v8i16 (int_aarch64_neon_fcvtzs v8f16:$Rn)), (FCVTZSv8f16 $Rn)>;
3509 def : Pat<(v2i32 (int_aarch64_neon_fcvtzs v2f32:$Rn)), (FCVTZSv2f32 $Rn)>;
3510 def : Pat<(v4i32 (int_aarch64_neon_fcvtzs v4f32:$Rn)), (FCVTZSv4f32 $Rn)>;
3511 def : Pat<(v2i64 (int_aarch64_neon_fcvtzs v2f64:$Rn)), (FCVTZSv2f64 $Rn)>;
3513 def : Pat<(v4i16 (int_aarch64_neon_fcvtzu v4f16:$Rn)), (FCVTZUv4f16 $Rn)>;
3514 def : Pat<(v8i16 (int_aarch64_neon_fcvtzu v8f16:$Rn)), (FCVTZUv8f16 $Rn)>;
3515 def : Pat<(v2i32 (int_aarch64_neon_fcvtzu v2f32:$Rn)), (FCVTZUv2f32 $Rn)>;
3516 def : Pat<(v4i32 (int_aarch64_neon_fcvtzu v4f32:$Rn)), (FCVTZUv4f32 $Rn)>;
3517 def : Pat<(v2i64 (int_aarch64_neon_fcvtzu v2f64:$Rn)), (FCVTZUv2f64 $Rn)>;
3519 defm FNEG : SIMDTwoVectorFP<1, 1, 0b01111, "fneg", fneg>;
3520 defm FRECPE : SIMDTwoVectorFP<0, 1, 0b11101, "frecpe", int_aarch64_neon_frecpe>;
3521 defm FRINTA : SIMDTwoVectorFP<1, 0, 0b11000, "frinta", fround>;
3522 defm FRINTI : SIMDTwoVectorFP<1, 1, 0b11001, "frinti", fnearbyint>;
3523 defm FRINTM : SIMDTwoVectorFP<0, 0, 0b11001, "frintm", ffloor>;
3524 defm FRINTN : SIMDTwoVectorFP<0, 0, 0b11000, "frintn", int_aarch64_neon_frintn>;
3525 defm FRINTP : SIMDTwoVectorFP<0, 1, 0b11000, "frintp", fceil>;
3526 defm FRINTX : SIMDTwoVectorFP<1, 0, 0b11001, "frintx", frint>;
3527 defm FRINTZ : SIMDTwoVectorFP<0, 1, 0b11001, "frintz", ftrunc>;
3529 let Predicates = [HasFRInt3264] in {
3530 defm FRINT32Z : FRIntNNTVector<0, 0, "frint32z">;
3531 defm FRINT64Z : FRIntNNTVector<0, 1, "frint64z">;
3532 defm FRINT32X : FRIntNNTVector<1, 0, "frint32x">;
3533 defm FRINT64X : FRIntNNTVector<1, 1, "frint64x">;
3536 defm FRSQRTE: SIMDTwoVectorFP<1, 1, 0b11101, "frsqrte", int_aarch64_neon_frsqrte>;
3537 defm FSQRT : SIMDTwoVectorFP<1, 1, 0b11111, "fsqrt", fsqrt>;
3538 defm NEG : SIMDTwoVectorBHSD<1, 0b01011, "neg",
3539 UnOpFrag<(sub immAllZerosV, node:$LHS)> >;
3540 defm NOT : SIMDTwoVectorB<1, 0b00, 0b00101, "not", vnot>;
3541 // Aliases for MVN -> NOT.
3542 def : InstAlias<"mvn{ $Vd.8b, $Vn.8b|.8b $Vd, $Vn}",
3543 (NOTv8i8 V64:$Vd, V64:$Vn)>;
3544 def : InstAlias<"mvn{ $Vd.16b, $Vn.16b|.16b $Vd, $Vn}",
3545 (NOTv16i8 V128:$Vd, V128:$Vn)>;
3547 def : Pat<(AArch64neg (v8i8 V64:$Rn)), (NEGv8i8 V64:$Rn)>;
3548 def : Pat<(AArch64neg (v16i8 V128:$Rn)), (NEGv16i8 V128:$Rn)>;
3549 def : Pat<(AArch64neg (v4i16 V64:$Rn)), (NEGv4i16 V64:$Rn)>;
3550 def : Pat<(AArch64neg (v8i16 V128:$Rn)), (NEGv8i16 V128:$Rn)>;
3551 def : Pat<(AArch64neg (v2i32 V64:$Rn)), (NEGv2i32 V64:$Rn)>;
3552 def : Pat<(AArch64neg (v4i32 V128:$Rn)), (NEGv4i32 V128:$Rn)>;
3553 def : Pat<(AArch64neg (v2i64 V128:$Rn)), (NEGv2i64 V128:$Rn)>;
3555 def : Pat<(AArch64not (v8i8 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3556 def : Pat<(AArch64not (v16i8 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3557 def : Pat<(AArch64not (v4i16 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3558 def : Pat<(AArch64not (v8i16 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3559 def : Pat<(AArch64not (v2i32 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3560 def : Pat<(AArch64not (v1i64 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3561 def : Pat<(AArch64not (v4i32 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3562 def : Pat<(AArch64not (v2i64 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3564 def : Pat<(vnot (v4i16 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3565 def : Pat<(vnot (v8i16 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3566 def : Pat<(vnot (v2i32 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3567 def : Pat<(vnot (v4i32 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3568 def : Pat<(vnot (v2i64 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3570 defm RBIT : SIMDTwoVectorB<1, 0b01, 0b00101, "rbit", int_aarch64_neon_rbit>;
3571 defm REV16 : SIMDTwoVectorB<0, 0b00, 0b00001, "rev16", AArch64rev16>;
3572 defm REV32 : SIMDTwoVectorBH<1, 0b00000, "rev32", AArch64rev32>;
3573 defm REV64 : SIMDTwoVectorBHS<0, 0b00000, "rev64", AArch64rev64>;
3574 defm SADALP : SIMDLongTwoVectorTied<0, 0b00110, "sadalp",
3575 BinOpFrag<(add node:$LHS, (int_aarch64_neon_saddlp node:$RHS))> >;
3576 defm SADDLP : SIMDLongTwoVector<0, 0b00010, "saddlp", int_aarch64_neon_saddlp>;
3577 defm SCVTF : SIMDTwoVectorIntToFP<0, 0, 0b11101, "scvtf", sint_to_fp>;
3578 defm SHLL : SIMDVectorLShiftLongBySizeBHS;
3579 defm SQABS : SIMDTwoVectorBHSD<0, 0b00111, "sqabs", int_aarch64_neon_sqabs>;
3580 defm SQNEG : SIMDTwoVectorBHSD<1, 0b00111, "sqneg", int_aarch64_neon_sqneg>;
3581 defm SQXTN : SIMDMixedTwoVector<0, 0b10100, "sqxtn", int_aarch64_neon_sqxtn>;
3582 defm SQXTUN : SIMDMixedTwoVector<1, 0b10010, "sqxtun", int_aarch64_neon_sqxtun>;
3583 defm SUQADD : SIMDTwoVectorBHSDTied<0, 0b00011, "suqadd",int_aarch64_neon_suqadd>;
3584 defm UADALP : SIMDLongTwoVectorTied<1, 0b00110, "uadalp",
3585 BinOpFrag<(add node:$LHS, (int_aarch64_neon_uaddlp node:$RHS))> >;
3586 defm UADDLP : SIMDLongTwoVector<1, 0b00010, "uaddlp",
3587 int_aarch64_neon_uaddlp>;
3588 defm UCVTF : SIMDTwoVectorIntToFP<1, 0, 0b11101, "ucvtf", uint_to_fp>;
3589 defm UQXTN : SIMDMixedTwoVector<1, 0b10100, "uqxtn", int_aarch64_neon_uqxtn>;
3590 defm URECPE : SIMDTwoVectorS<0, 1, 0b11100, "urecpe", int_aarch64_neon_urecpe>;
3591 defm URSQRTE: SIMDTwoVectorS<1, 1, 0b11100, "ursqrte", int_aarch64_neon_ursqrte>;
3592 defm USQADD : SIMDTwoVectorBHSDTied<1, 0b00011, "usqadd",int_aarch64_neon_usqadd>;
3593 defm XTN : SIMDMixedTwoVector<0, 0b10010, "xtn", trunc>;
3595 def : Pat<(v4f16 (AArch64rev32 V64:$Rn)), (REV32v4i16 V64:$Rn)>;
3596 def : Pat<(v4f16 (AArch64rev64 V64:$Rn)), (REV64v4i16 V64:$Rn)>;
3597 def : Pat<(v8f16 (AArch64rev32 V128:$Rn)), (REV32v8i16 V128:$Rn)>;
3598 def : Pat<(v8f16 (AArch64rev64 V128:$Rn)), (REV64v8i16 V128:$Rn)>;
3599 def : Pat<(v2f32 (AArch64rev64 V64:$Rn)), (REV64v2i32 V64:$Rn)>;
3600 def : Pat<(v4f32 (AArch64rev64 V128:$Rn)), (REV64v4i32 V128:$Rn)>;
3602 // Patterns for vector long shift (by element width). These need to match all
3603 // three of zext, sext and anyext so it's easier to pull the patterns out of the
3605 multiclass SIMDVectorLShiftLongBySizeBHSPats<SDPatternOperator ext> {
3606 def : Pat<(AArch64vshl (v8i16 (ext (v8i8 V64:$Rn))), (i32 8)),
3607 (SHLLv8i8 V64:$Rn)>;
3608 def : Pat<(AArch64vshl (v8i16 (ext (extract_high_v16i8 V128:$Rn))), (i32 8)),
3609 (SHLLv16i8 V128:$Rn)>;
3610 def : Pat<(AArch64vshl (v4i32 (ext (v4i16 V64:$Rn))), (i32 16)),
3611 (SHLLv4i16 V64:$Rn)>;
3612 def : Pat<(AArch64vshl (v4i32 (ext (extract_high_v8i16 V128:$Rn))), (i32 16)),
3613 (SHLLv8i16 V128:$Rn)>;
3614 def : Pat<(AArch64vshl (v2i64 (ext (v2i32 V64:$Rn))), (i32 32)),
3615 (SHLLv2i32 V64:$Rn)>;
3616 def : Pat<(AArch64vshl (v2i64 (ext (extract_high_v4i32 V128:$Rn))), (i32 32)),
3617 (SHLLv4i32 V128:$Rn)>;
3620 defm : SIMDVectorLShiftLongBySizeBHSPats<anyext>;
3621 defm : SIMDVectorLShiftLongBySizeBHSPats<zext>;
3622 defm : SIMDVectorLShiftLongBySizeBHSPats<sext>;
3624 //===----------------------------------------------------------------------===//
3625 // Advanced SIMD three vector instructions.
3626 //===----------------------------------------------------------------------===//
3628 defm ADD : SIMDThreeSameVector<0, 0b10000, "add", add>;
3629 defm ADDP : SIMDThreeSameVector<0, 0b10111, "addp", int_aarch64_neon_addp>;
3630 defm CMEQ : SIMDThreeSameVector<1, 0b10001, "cmeq", AArch64cmeq>;
3631 defm CMGE : SIMDThreeSameVector<0, 0b00111, "cmge", AArch64cmge>;
3632 defm CMGT : SIMDThreeSameVector<0, 0b00110, "cmgt", AArch64cmgt>;
3633 defm CMHI : SIMDThreeSameVector<1, 0b00110, "cmhi", AArch64cmhi>;
3634 defm CMHS : SIMDThreeSameVector<1, 0b00111, "cmhs", AArch64cmhs>;
3635 defm CMTST : SIMDThreeSameVector<0, 0b10001, "cmtst", AArch64cmtst>;
3636 defm FABD : SIMDThreeSameVectorFP<1,1,0b010,"fabd", int_aarch64_neon_fabd>;
3637 let Predicates = [HasNEON] in {
3638 foreach VT = [ v2f32, v4f32, v2f64 ] in
3639 def : Pat<(fabs (fsub VT:$Rn, VT:$Rm)), (!cast<Instruction>("FABD"#VT) VT:$Rn, VT:$Rm)>;
3641 let Predicates = [HasNEON, HasFullFP16] in {
3642 foreach VT = [ v4f16, v8f16 ] in
3643 def : Pat<(fabs (fsub VT:$Rn, VT:$Rm)), (!cast<Instruction>("FABD"#VT) VT:$Rn, VT:$Rm)>;
3645 defm FACGE : SIMDThreeSameVectorFPCmp<1,0,0b101,"facge",int_aarch64_neon_facge>;
3646 defm FACGT : SIMDThreeSameVectorFPCmp<1,1,0b101,"facgt",int_aarch64_neon_facgt>;
3647 defm FADDP : SIMDThreeSameVectorFP<1,0,0b010,"faddp",int_aarch64_neon_faddp>;
3648 defm FADD : SIMDThreeSameVectorFP<0,0,0b010,"fadd", fadd>;
3649 defm FCMEQ : SIMDThreeSameVectorFPCmp<0, 0, 0b100, "fcmeq", AArch64fcmeq>;
3650 defm FCMGE : SIMDThreeSameVectorFPCmp<1, 0, 0b100, "fcmge", AArch64fcmge>;
3651 defm FCMGT : SIMDThreeSameVectorFPCmp<1, 1, 0b100, "fcmgt", AArch64fcmgt>;
3652 defm FDIV : SIMDThreeSameVectorFP<1,0,0b111,"fdiv", fdiv>;
3653 defm FMAXNMP : SIMDThreeSameVectorFP<1,0,0b000,"fmaxnmp", int_aarch64_neon_fmaxnmp>;
3654 defm FMAXNM : SIMDThreeSameVectorFP<0,0,0b000,"fmaxnm", fmaxnum>;
3655 defm FMAXP : SIMDThreeSameVectorFP<1,0,0b110,"fmaxp", int_aarch64_neon_fmaxp>;
3656 defm FMAX : SIMDThreeSameVectorFP<0,0,0b110,"fmax", fmaximum>;
3657 defm FMINNMP : SIMDThreeSameVectorFP<1,1,0b000,"fminnmp", int_aarch64_neon_fminnmp>;
3658 defm FMINNM : SIMDThreeSameVectorFP<0,1,0b000,"fminnm", fminnum>;
3659 defm FMINP : SIMDThreeSameVectorFP<1,1,0b110,"fminp", int_aarch64_neon_fminp>;
3660 defm FMIN : SIMDThreeSameVectorFP<0,1,0b110,"fmin", fminimum>;
3662 // NOTE: The operands of the PatFrag are reordered on FMLA/FMLS because the
3663 // instruction expects the addend first, while the fma intrinsic puts it last.
3664 defm FMLA : SIMDThreeSameVectorFPTied<0, 0, 0b001, "fmla",
3665 TriOpFrag<(fma node:$RHS, node:$MHS, node:$LHS)> >;
3666 defm FMLS : SIMDThreeSameVectorFPTied<0, 1, 0b001, "fmls",
3667 TriOpFrag<(fma node:$MHS, (fneg node:$RHS), node:$LHS)> >;
3669 // The following def pats catch the case where the LHS of an FMA is negated.
3670 // The TriOpFrag above catches the case where the middle operand is negated.
3671 def : Pat<(v2f32 (fma (fneg V64:$Rn), V64:$Rm, V64:$Rd)),
3672 (FMLSv2f32 V64:$Rd, V64:$Rn, V64:$Rm)>;
3674 def : Pat<(v4f32 (fma (fneg V128:$Rn), V128:$Rm, V128:$Rd)),
3675 (FMLSv4f32 V128:$Rd, V128:$Rn, V128:$Rm)>;
3677 def : Pat<(v2f64 (fma (fneg V128:$Rn), V128:$Rm, V128:$Rd)),
3678 (FMLSv2f64 V128:$Rd, V128:$Rn, V128:$Rm)>;
3680 defm FMULX : SIMDThreeSameVectorFP<0,0,0b011,"fmulx", int_aarch64_neon_fmulx>;
3681 defm FMUL : SIMDThreeSameVectorFP<1,0,0b011,"fmul", fmul>;
3682 defm FRECPS : SIMDThreeSameVectorFP<0,0,0b111,"frecps", int_aarch64_neon_frecps>;
3683 defm FRSQRTS : SIMDThreeSameVectorFP<0,1,0b111,"frsqrts", int_aarch64_neon_frsqrts>;
3684 defm FSUB : SIMDThreeSameVectorFP<0,1,0b010,"fsub", fsub>;
3685 defm MLA : SIMDThreeSameVectorBHSTied<0, 0b10010, "mla",
3686 TriOpFrag<(add node:$LHS, (mul node:$MHS, node:$RHS))> >;
3687 defm MLS : SIMDThreeSameVectorBHSTied<1, 0b10010, "mls",
3688 TriOpFrag<(sub node:$LHS, (mul node:$MHS, node:$RHS))> >;
3689 defm MUL : SIMDThreeSameVectorBHS<0, 0b10011, "mul", mul>;
3690 defm PMUL : SIMDThreeSameVectorB<1, 0b10011, "pmul", int_aarch64_neon_pmul>;
3691 defm SABA : SIMDThreeSameVectorBHSTied<0, 0b01111, "saba",
3692 TriOpFrag<(add node:$LHS, (int_aarch64_neon_sabd node:$MHS, node:$RHS))> >;
3693 defm SABD : SIMDThreeSameVectorBHS<0,0b01110,"sabd", int_aarch64_neon_sabd>;
3694 defm SHADD : SIMDThreeSameVectorBHS<0,0b00000,"shadd", int_aarch64_neon_shadd>;
3695 defm SHSUB : SIMDThreeSameVectorBHS<0,0b00100,"shsub", int_aarch64_neon_shsub>;
3696 defm SMAXP : SIMDThreeSameVectorBHS<0,0b10100,"smaxp", int_aarch64_neon_smaxp>;
3697 defm SMAX : SIMDThreeSameVectorBHS<0,0b01100,"smax", smax>;
3698 defm SMINP : SIMDThreeSameVectorBHS<0,0b10101,"sminp", int_aarch64_neon_sminp>;
3699 defm SMIN : SIMDThreeSameVectorBHS<0,0b01101,"smin", smin>;
3700 defm SQADD : SIMDThreeSameVector<0,0b00001,"sqadd", int_aarch64_neon_sqadd>;
3701 defm SQDMULH : SIMDThreeSameVectorHS<0,0b10110,"sqdmulh",int_aarch64_neon_sqdmulh>;
3702 defm SQRDMULH : SIMDThreeSameVectorHS<1,0b10110,"sqrdmulh",int_aarch64_neon_sqrdmulh>;
3703 defm SQRSHL : SIMDThreeSameVector<0,0b01011,"sqrshl", int_aarch64_neon_sqrshl>;
3704 defm SQSHL : SIMDThreeSameVector<0,0b01001,"sqshl", int_aarch64_neon_sqshl>;
3705 defm SQSUB : SIMDThreeSameVector<0,0b00101,"sqsub", int_aarch64_neon_sqsub>;
3706 defm SRHADD : SIMDThreeSameVectorBHS<0,0b00010,"srhadd",int_aarch64_neon_srhadd>;
3707 defm SRSHL : SIMDThreeSameVector<0,0b01010,"srshl", int_aarch64_neon_srshl>;
3708 defm SSHL : SIMDThreeSameVector<0,0b01000,"sshl", int_aarch64_neon_sshl>;
3709 defm SUB : SIMDThreeSameVector<1,0b10000,"sub", sub>;
3710 defm UABA : SIMDThreeSameVectorBHSTied<1, 0b01111, "uaba",
3711 TriOpFrag<(add node:$LHS, (int_aarch64_neon_uabd node:$MHS, node:$RHS))> >;
3712 defm UABD : SIMDThreeSameVectorBHS<1,0b01110,"uabd", int_aarch64_neon_uabd>;
3713 defm UHADD : SIMDThreeSameVectorBHS<1,0b00000,"uhadd", int_aarch64_neon_uhadd>;
3714 defm UHSUB : SIMDThreeSameVectorBHS<1,0b00100,"uhsub", int_aarch64_neon_uhsub>;
3715 defm UMAXP : SIMDThreeSameVectorBHS<1,0b10100,"umaxp", int_aarch64_neon_umaxp>;
3716 defm UMAX : SIMDThreeSameVectorBHS<1,0b01100,"umax", umax>;
3717 defm UMINP : SIMDThreeSameVectorBHS<1,0b10101,"uminp", int_aarch64_neon_uminp>;
3718 defm UMIN : SIMDThreeSameVectorBHS<1,0b01101,"umin", umin>;
3719 defm UQADD : SIMDThreeSameVector<1,0b00001,"uqadd", int_aarch64_neon_uqadd>;
3720 defm UQRSHL : SIMDThreeSameVector<1,0b01011,"uqrshl", int_aarch64_neon_uqrshl>;
3721 defm UQSHL : SIMDThreeSameVector<1,0b01001,"uqshl", int_aarch64_neon_uqshl>;
3722 defm UQSUB : SIMDThreeSameVector<1,0b00101,"uqsub", int_aarch64_neon_uqsub>;
3723 defm URHADD : SIMDThreeSameVectorBHS<1,0b00010,"urhadd", int_aarch64_neon_urhadd>;
3724 defm URSHL : SIMDThreeSameVector<1,0b01010,"urshl", int_aarch64_neon_urshl>;
3725 defm USHL : SIMDThreeSameVector<1,0b01000,"ushl", int_aarch64_neon_ushl>;
3726 defm SQRDMLAH : SIMDThreeSameVectorSQRDMLxHTiedHS<1,0b10000,"sqrdmlah",
3727 int_aarch64_neon_sqadd>;
3728 defm SQRDMLSH : SIMDThreeSameVectorSQRDMLxHTiedHS<1,0b10001,"sqrdmlsh",
3729 int_aarch64_neon_sqsub>;
3731 defm AND : SIMDLogicalThreeVector<0, 0b00, "and", and>;
3732 defm BIC : SIMDLogicalThreeVector<0, 0b01, "bic",
3733 BinOpFrag<(and node:$LHS, (vnot node:$RHS))> >;
3734 defm BIF : SIMDLogicalThreeVector<1, 0b11, "bif">;
3735 defm BIT : SIMDLogicalThreeVectorTied<1, 0b10, "bit", AArch64bit>;
3736 defm BSL : SIMDLogicalThreeVectorTied<1, 0b01, "bsl",
3737 TriOpFrag<(or (and node:$LHS, node:$MHS), (and (vnot node:$LHS), node:$RHS))>>;
3738 defm EOR : SIMDLogicalThreeVector<1, 0b00, "eor", xor>;
3739 defm ORN : SIMDLogicalThreeVector<0, 0b11, "orn",
3740 BinOpFrag<(or node:$LHS, (vnot node:$RHS))> >;
3741 defm ORR : SIMDLogicalThreeVector<0, 0b10, "orr", or>;
3744 def : Pat<(AArch64bsl (v8i8 V64:$Rd), V64:$Rn, V64:$Rm),
3745 (BSLv8i8 V64:$Rd, V64:$Rn, V64:$Rm)>;
3746 def : Pat<(AArch64bsl (v4i16 V64:$Rd), V64:$Rn, V64:$Rm),
3747 (BSLv8i8 V64:$Rd, V64:$Rn, V64:$Rm)>;
3748 def : Pat<(AArch64bsl (v2i32 V64:$Rd), V64:$Rn, V64:$Rm),
3749 (BSLv8i8 V64:$Rd, V64:$Rn, V64:$Rm)>;
3750 def : Pat<(AArch64bsl (v1i64 V64:$Rd), V64:$Rn, V64:$Rm),
3751 (BSLv8i8 V64:$Rd, V64:$Rn, V64:$Rm)>;
3753 def : Pat<(AArch64bsl (v16i8 V128:$Rd), V128:$Rn, V128:$Rm),
3754 (BSLv16i8 V128:$Rd, V128:$Rn, V128:$Rm)>;
3755 def : Pat<(AArch64bsl (v8i16 V128:$Rd), V128:$Rn, V128:$Rm),
3756 (BSLv16i8 V128:$Rd, V128:$Rn, V128:$Rm)>;
3757 def : Pat<(AArch64bsl (v4i32 V128:$Rd), V128:$Rn, V128:$Rm),
3758 (BSLv16i8 V128:$Rd, V128:$Rn, V128:$Rm)>;
3759 def : Pat<(AArch64bsl (v2i64 V128:$Rd), V128:$Rn, V128:$Rm),
3760 (BSLv16i8 V128:$Rd, V128:$Rn, V128:$Rm)>;
3762 def : InstAlias<"mov{\t$dst.16b, $src.16b|.16b\t$dst, $src}",
3763 (ORRv16i8 V128:$dst, V128:$src, V128:$src), 1>;
3764 def : InstAlias<"mov{\t$dst.8h, $src.8h|.8h\t$dst, $src}",
3765 (ORRv16i8 V128:$dst, V128:$src, V128:$src), 0>;
3766 def : InstAlias<"mov{\t$dst.4s, $src.4s|.4s\t$dst, $src}",
3767 (ORRv16i8 V128:$dst, V128:$src, V128:$src), 0>;
3768 def : InstAlias<"mov{\t$dst.2d, $src.2d|.2d\t$dst, $src}",
3769 (ORRv16i8 V128:$dst, V128:$src, V128:$src), 0>;
3771 def : InstAlias<"mov{\t$dst.8b, $src.8b|.8b\t$dst, $src}",
3772 (ORRv8i8 V64:$dst, V64:$src, V64:$src), 1>;
3773 def : InstAlias<"mov{\t$dst.4h, $src.4h|.4h\t$dst, $src}",
3774 (ORRv8i8 V64:$dst, V64:$src, V64:$src), 0>;
3775 def : InstAlias<"mov{\t$dst.2s, $src.2s|.2s\t$dst, $src}",
3776 (ORRv8i8 V64:$dst, V64:$src, V64:$src), 0>;
3777 def : InstAlias<"mov{\t$dst.1d, $src.1d|.1d\t$dst, $src}",
3778 (ORRv8i8 V64:$dst, V64:$src, V64:$src), 0>;
3780 def : InstAlias<"{cmls\t$dst.8b, $src1.8b, $src2.8b" #
3781 "|cmls.8b\t$dst, $src1, $src2}",
3782 (CMHSv8i8 V64:$dst, V64:$src2, V64:$src1), 0>;
3783 def : InstAlias<"{cmls\t$dst.16b, $src1.16b, $src2.16b" #
3784 "|cmls.16b\t$dst, $src1, $src2}",
3785 (CMHSv16i8 V128:$dst, V128:$src2, V128:$src1), 0>;
3786 def : InstAlias<"{cmls\t$dst.4h, $src1.4h, $src2.4h" #
3787 "|cmls.4h\t$dst, $src1, $src2}",
3788 (CMHSv4i16 V64:$dst, V64:$src2, V64:$src1), 0>;
3789 def : InstAlias<"{cmls\t$dst.8h, $src1.8h, $src2.8h" #
3790 "|cmls.8h\t$dst, $src1, $src2}",
3791 (CMHSv8i16 V128:$dst, V128:$src2, V128:$src1), 0>;
3792 def : InstAlias<"{cmls\t$dst.2s, $src1.2s, $src2.2s" #
3793 "|cmls.2s\t$dst, $src1, $src2}",
3794 (CMHSv2i32 V64:$dst, V64:$src2, V64:$src1), 0>;
3795 def : InstAlias<"{cmls\t$dst.4s, $src1.4s, $src2.4s" #
3796 "|cmls.4s\t$dst, $src1, $src2}",
3797 (CMHSv4i32 V128:$dst, V128:$src2, V128:$src1), 0>;
3798 def : InstAlias<"{cmls\t$dst.2d, $src1.2d, $src2.2d" #
3799 "|cmls.2d\t$dst, $src1, $src2}",
3800 (CMHSv2i64 V128:$dst, V128:$src2, V128:$src1), 0>;
3802 def : InstAlias<"{cmlo\t$dst.8b, $src1.8b, $src2.8b" #
3803 "|cmlo.8b\t$dst, $src1, $src2}",
3804 (CMHIv8i8 V64:$dst, V64:$src2, V64:$src1), 0>;
3805 def : InstAlias<"{cmlo\t$dst.16b, $src1.16b, $src2.16b" #
3806 "|cmlo.16b\t$dst, $src1, $src2}",
3807 (CMHIv16i8 V128:$dst, V128:$src2, V128:$src1), 0>;
3808 def : InstAlias<"{cmlo\t$dst.4h, $src1.4h, $src2.4h" #
3809 "|cmlo.4h\t$dst, $src1, $src2}",
3810 (CMHIv4i16 V64:$dst, V64:$src2, V64:$src1), 0>;
3811 def : InstAlias<"{cmlo\t$dst.8h, $src1.8h, $src2.8h" #
3812 "|cmlo.8h\t$dst, $src1, $src2}",
3813 (CMHIv8i16 V128:$dst, V128:$src2, V128:$src1), 0>;
3814 def : InstAlias<"{cmlo\t$dst.2s, $src1.2s, $src2.2s" #
3815 "|cmlo.2s\t$dst, $src1, $src2}",
3816 (CMHIv2i32 V64:$dst, V64:$src2, V64:$src1), 0>;
3817 def : InstAlias<"{cmlo\t$dst.4s, $src1.4s, $src2.4s" #
3818 "|cmlo.4s\t$dst, $src1, $src2}",
3819 (CMHIv4i32 V128:$dst, V128:$src2, V128:$src1), 0>;
3820 def : InstAlias<"{cmlo\t$dst.2d, $src1.2d, $src2.2d" #
3821 "|cmlo.2d\t$dst, $src1, $src2}",
3822 (CMHIv2i64 V128:$dst, V128:$src2, V128:$src1), 0>;
3824 def : InstAlias<"{cmle\t$dst.8b, $src1.8b, $src2.8b" #
3825 "|cmle.8b\t$dst, $src1, $src2}",
3826 (CMGEv8i8 V64:$dst, V64:$src2, V64:$src1), 0>;
3827 def : InstAlias<"{cmle\t$dst.16b, $src1.16b, $src2.16b" #
3828 "|cmle.16b\t$dst, $src1, $src2}",
3829 (CMGEv16i8 V128:$dst, V128:$src2, V128:$src1), 0>;
3830 def : InstAlias<"{cmle\t$dst.4h, $src1.4h, $src2.4h" #
3831 "|cmle.4h\t$dst, $src1, $src2}",
3832 (CMGEv4i16 V64:$dst, V64:$src2, V64:$src1), 0>;
3833 def : InstAlias<"{cmle\t$dst.8h, $src1.8h, $src2.8h" #
3834 "|cmle.8h\t$dst, $src1, $src2}",
3835 (CMGEv8i16 V128:$dst, V128:$src2, V128:$src1), 0>;
3836 def : InstAlias<"{cmle\t$dst.2s, $src1.2s, $src2.2s" #
3837 "|cmle.2s\t$dst, $src1, $src2}",
3838 (CMGEv2i32 V64:$dst, V64:$src2, V64:$src1), 0>;
3839 def : InstAlias<"{cmle\t$dst.4s, $src1.4s, $src2.4s" #
3840 "|cmle.4s\t$dst, $src1, $src2}",
3841 (CMGEv4i32 V128:$dst, V128:$src2, V128:$src1), 0>;
3842 def : InstAlias<"{cmle\t$dst.2d, $src1.2d, $src2.2d" #
3843 "|cmle.2d\t$dst, $src1, $src2}",
3844 (CMGEv2i64 V128:$dst, V128:$src2, V128:$src1), 0>;
3846 def : InstAlias<"{cmlt\t$dst.8b, $src1.8b, $src2.8b" #
3847 "|cmlt.8b\t$dst, $src1, $src2}",
3848 (CMGTv8i8 V64:$dst, V64:$src2, V64:$src1), 0>;
3849 def : InstAlias<"{cmlt\t$dst.16b, $src1.16b, $src2.16b" #
3850 "|cmlt.16b\t$dst, $src1, $src2}",
3851 (CMGTv16i8 V128:$dst, V128:$src2, V128:$src1), 0>;
3852 def : InstAlias<"{cmlt\t$dst.4h, $src1.4h, $src2.4h" #
3853 "|cmlt.4h\t$dst, $src1, $src2}",
3854 (CMGTv4i16 V64:$dst, V64:$src2, V64:$src1), 0>;
3855 def : InstAlias<"{cmlt\t$dst.8h, $src1.8h, $src2.8h" #
3856 "|cmlt.8h\t$dst, $src1, $src2}",
3857 (CMGTv8i16 V128:$dst, V128:$src2, V128:$src1), 0>;
3858 def : InstAlias<"{cmlt\t$dst.2s, $src1.2s, $src2.2s" #
3859 "|cmlt.2s\t$dst, $src1, $src2}",
3860 (CMGTv2i32 V64:$dst, V64:$src2, V64:$src1), 0>;
3861 def : InstAlias<"{cmlt\t$dst.4s, $src1.4s, $src2.4s" #
3862 "|cmlt.4s\t$dst, $src1, $src2}",
3863 (CMGTv4i32 V128:$dst, V128:$src2, V128:$src1), 0>;
3864 def : InstAlias<"{cmlt\t$dst.2d, $src1.2d, $src2.2d" #
3865 "|cmlt.2d\t$dst, $src1, $src2}",
3866 (CMGTv2i64 V128:$dst, V128:$src2, V128:$src1), 0>;
3868 let Predicates = [HasNEON, HasFullFP16] in {
3869 def : InstAlias<"{fcmle\t$dst.4h, $src1.4h, $src2.4h" #
3870 "|fcmle.4h\t$dst, $src1, $src2}",
3871 (FCMGEv4f16 V64:$dst, V64:$src2, V64:$src1), 0>;
3872 def : InstAlias<"{fcmle\t$dst.8h, $src1.8h, $src2.8h" #
3873 "|fcmle.8h\t$dst, $src1, $src2}",
3874 (FCMGEv8f16 V128:$dst, V128:$src2, V128:$src1), 0>;
3876 def : InstAlias<"{fcmle\t$dst.2s, $src1.2s, $src2.2s" #
3877 "|fcmle.2s\t$dst, $src1, $src2}",
3878 (FCMGEv2f32 V64:$dst, V64:$src2, V64:$src1), 0>;
3879 def : InstAlias<"{fcmle\t$dst.4s, $src1.4s, $src2.4s" #
3880 "|fcmle.4s\t$dst, $src1, $src2}",
3881 (FCMGEv4f32 V128:$dst, V128:$src2, V128:$src1), 0>;
3882 def : InstAlias<"{fcmle\t$dst.2d, $src1.2d, $src2.2d" #
3883 "|fcmle.2d\t$dst, $src1, $src2}",
3884 (FCMGEv2f64 V128:$dst, V128:$src2, V128:$src1), 0>;
3886 let Predicates = [HasNEON, HasFullFP16] in {
3887 def : InstAlias<"{fcmlt\t$dst.4h, $src1.4h, $src2.4h" #
3888 "|fcmlt.4h\t$dst, $src1, $src2}",
3889 (FCMGTv4f16 V64:$dst, V64:$src2, V64:$src1), 0>;
3890 def : InstAlias<"{fcmlt\t$dst.8h, $src1.8h, $src2.8h" #
3891 "|fcmlt.8h\t$dst, $src1, $src2}",
3892 (FCMGTv8f16 V128:$dst, V128:$src2, V128:$src1), 0>;
3894 def : InstAlias<"{fcmlt\t$dst.2s, $src1.2s, $src2.2s" #
3895 "|fcmlt.2s\t$dst, $src1, $src2}",
3896 (FCMGTv2f32 V64:$dst, V64:$src2, V64:$src1), 0>;
3897 def : InstAlias<"{fcmlt\t$dst.4s, $src1.4s, $src2.4s" #
3898 "|fcmlt.4s\t$dst, $src1, $src2}",
3899 (FCMGTv4f32 V128:$dst, V128:$src2, V128:$src1), 0>;
3900 def : InstAlias<"{fcmlt\t$dst.2d, $src1.2d, $src2.2d" #
3901 "|fcmlt.2d\t$dst, $src1, $src2}",
3902 (FCMGTv2f64 V128:$dst, V128:$src2, V128:$src1), 0>;
3904 let Predicates = [HasNEON, HasFullFP16] in {
3905 def : InstAlias<"{facle\t$dst.4h, $src1.4h, $src2.4h" #
3906 "|facle.4h\t$dst, $src1, $src2}",
3907 (FACGEv4f16 V64:$dst, V64:$src2, V64:$src1), 0>;
3908 def : InstAlias<"{facle\t$dst.8h, $src1.8h, $src2.8h" #
3909 "|facle.8h\t$dst, $src1, $src2}",
3910 (FACGEv8f16 V128:$dst, V128:$src2, V128:$src1), 0>;
3912 def : InstAlias<"{facle\t$dst.2s, $src1.2s, $src2.2s" #
3913 "|facle.2s\t$dst, $src1, $src2}",
3914 (FACGEv2f32 V64:$dst, V64:$src2, V64:$src1), 0>;
3915 def : InstAlias<"{facle\t$dst.4s, $src1.4s, $src2.4s" #
3916 "|facle.4s\t$dst, $src1, $src2}",
3917 (FACGEv4f32 V128:$dst, V128:$src2, V128:$src1), 0>;
3918 def : InstAlias<"{facle\t$dst.2d, $src1.2d, $src2.2d" #
3919 "|facle.2d\t$dst, $src1, $src2}",
3920 (FACGEv2f64 V128:$dst, V128:$src2, V128:$src1), 0>;
3922 let Predicates = [HasNEON, HasFullFP16] in {
3923 def : InstAlias<"{faclt\t$dst.4h, $src1.4h, $src2.4h" #
3924 "|faclt.4h\t$dst, $src1, $src2}",
3925 (FACGTv4f16 V64:$dst, V64:$src2, V64:$src1), 0>;
3926 def : InstAlias<"{faclt\t$dst.8h, $src1.8h, $src2.8h" #
3927 "|faclt.8h\t$dst, $src1, $src2}",
3928 (FACGTv8f16 V128:$dst, V128:$src2, V128:$src1), 0>;
3930 def : InstAlias<"{faclt\t$dst.2s, $src1.2s, $src2.2s" #
3931 "|faclt.2s\t$dst, $src1, $src2}",
3932 (FACGTv2f32 V64:$dst, V64:$src2, V64:$src1), 0>;
3933 def : InstAlias<"{faclt\t$dst.4s, $src1.4s, $src2.4s" #
3934 "|faclt.4s\t$dst, $src1, $src2}",
3935 (FACGTv4f32 V128:$dst, V128:$src2, V128:$src1), 0>;
3936 def : InstAlias<"{faclt\t$dst.2d, $src1.2d, $src2.2d" #
3937 "|faclt.2d\t$dst, $src1, $src2}",
3938 (FACGTv2f64 V128:$dst, V128:$src2, V128:$src1), 0>;
3940 //===----------------------------------------------------------------------===//
3941 // Advanced SIMD three scalar instructions.
3942 //===----------------------------------------------------------------------===//
3944 defm ADD : SIMDThreeScalarD<0, 0b10000, "add", add>;
3945 defm CMEQ : SIMDThreeScalarD<1, 0b10001, "cmeq", AArch64cmeq>;
3946 defm CMGE : SIMDThreeScalarD<0, 0b00111, "cmge", AArch64cmge>;
3947 defm CMGT : SIMDThreeScalarD<0, 0b00110, "cmgt", AArch64cmgt>;
3948 defm CMHI : SIMDThreeScalarD<1, 0b00110, "cmhi", AArch64cmhi>;
3949 defm CMHS : SIMDThreeScalarD<1, 0b00111, "cmhs", AArch64cmhs>;
3950 defm CMTST : SIMDThreeScalarD<0, 0b10001, "cmtst", AArch64cmtst>;
3951 defm FABD : SIMDFPThreeScalar<1, 1, 0b010, "fabd", int_aarch64_sisd_fabd>;
3952 def : Pat<(v1f64 (int_aarch64_neon_fabd (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
3953 (FABD64 FPR64:$Rn, FPR64:$Rm)>;
3954 let Predicates = [HasFullFP16] in {
3955 def : Pat<(fabs (fsub f16:$Rn, f16:$Rm)), (FABD16 f16:$Rn, f16:$Rm)>;
3957 def : Pat<(fabs (fsub f32:$Rn, f32:$Rm)), (FABD32 f32:$Rn, f32:$Rm)>;
3958 def : Pat<(fabs (fsub f64:$Rn, f64:$Rm)), (FABD64 f64:$Rn, f64:$Rm)>;
3959 defm FACGE : SIMDThreeScalarFPCmp<1, 0, 0b101, "facge",
3960 int_aarch64_neon_facge>;
3961 defm FACGT : SIMDThreeScalarFPCmp<1, 1, 0b101, "facgt",
3962 int_aarch64_neon_facgt>;
3963 defm FCMEQ : SIMDThreeScalarFPCmp<0, 0, 0b100, "fcmeq", AArch64fcmeq>;
3964 defm FCMGE : SIMDThreeScalarFPCmp<1, 0, 0b100, "fcmge", AArch64fcmge>;
3965 defm FCMGT : SIMDThreeScalarFPCmp<1, 1, 0b100, "fcmgt", AArch64fcmgt>;
3966 defm FMULX : SIMDFPThreeScalar<0, 0, 0b011, "fmulx", int_aarch64_neon_fmulx>;
3967 defm FRECPS : SIMDFPThreeScalar<0, 0, 0b111, "frecps", int_aarch64_neon_frecps>;
3968 defm FRSQRTS : SIMDFPThreeScalar<0, 1, 0b111, "frsqrts", int_aarch64_neon_frsqrts>;
3969 defm SQADD : SIMDThreeScalarBHSD<0, 0b00001, "sqadd", int_aarch64_neon_sqadd>;
3970 defm SQDMULH : SIMDThreeScalarHS< 0, 0b10110, "sqdmulh", int_aarch64_neon_sqdmulh>;
3971 defm SQRDMULH : SIMDThreeScalarHS< 1, 0b10110, "sqrdmulh", int_aarch64_neon_sqrdmulh>;
3972 defm SQRSHL : SIMDThreeScalarBHSD<0, 0b01011, "sqrshl",int_aarch64_neon_sqrshl>;
3973 defm SQSHL : SIMDThreeScalarBHSD<0, 0b01001, "sqshl", int_aarch64_neon_sqshl>;
3974 defm SQSUB : SIMDThreeScalarBHSD<0, 0b00101, "sqsub", int_aarch64_neon_sqsub>;
3975 defm SRSHL : SIMDThreeScalarD< 0, 0b01010, "srshl", int_aarch64_neon_srshl>;
3976 defm SSHL : SIMDThreeScalarD< 0, 0b01000, "sshl", int_aarch64_neon_sshl>;
3977 defm SUB : SIMDThreeScalarD< 1, 0b10000, "sub", sub>;
3978 defm UQADD : SIMDThreeScalarBHSD<1, 0b00001, "uqadd", int_aarch64_neon_uqadd>;
3979 defm UQRSHL : SIMDThreeScalarBHSD<1, 0b01011, "uqrshl",int_aarch64_neon_uqrshl>;
3980 defm UQSHL : SIMDThreeScalarBHSD<1, 0b01001, "uqshl", int_aarch64_neon_uqshl>;
3981 defm UQSUB : SIMDThreeScalarBHSD<1, 0b00101, "uqsub", int_aarch64_neon_uqsub>;
3982 defm URSHL : SIMDThreeScalarD< 1, 0b01010, "urshl", int_aarch64_neon_urshl>;
3983 defm USHL : SIMDThreeScalarD< 1, 0b01000, "ushl", int_aarch64_neon_ushl>;
3984 let Predicates = [HasRDM] in {
3985 defm SQRDMLAH : SIMDThreeScalarHSTied<1, 0, 0b10000, "sqrdmlah">;
3986 defm SQRDMLSH : SIMDThreeScalarHSTied<1, 0, 0b10001, "sqrdmlsh">;
3987 def : Pat<(i32 (int_aarch64_neon_sqadd
3989 (i32 (int_aarch64_neon_sqrdmulh (i32 FPR32:$Rn),
3990 (i32 FPR32:$Rm))))),
3991 (SQRDMLAHv1i32 FPR32:$Rd, FPR32:$Rn, FPR32:$Rm)>;
3992 def : Pat<(i32 (int_aarch64_neon_sqsub
3994 (i32 (int_aarch64_neon_sqrdmulh (i32 FPR32:$Rn),
3995 (i32 FPR32:$Rm))))),
3996 (SQRDMLSHv1i32 FPR32:$Rd, FPR32:$Rn, FPR32:$Rm)>;
3999 def : InstAlias<"cmls $dst, $src1, $src2",
4000 (CMHSv1i64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
4001 def : InstAlias<"cmle $dst, $src1, $src2",
4002 (CMGEv1i64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
4003 def : InstAlias<"cmlo $dst, $src1, $src2",
4004 (CMHIv1i64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
4005 def : InstAlias<"cmlt $dst, $src1, $src2",
4006 (CMGTv1i64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
4007 def : InstAlias<"fcmle $dst, $src1, $src2",
4008 (FCMGE32 FPR32:$dst, FPR32:$src2, FPR32:$src1), 0>;
4009 def : InstAlias<"fcmle $dst, $src1, $src2",
4010 (FCMGE64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
4011 def : InstAlias<"fcmlt $dst, $src1, $src2",
4012 (FCMGT32 FPR32:$dst, FPR32:$src2, FPR32:$src1), 0>;
4013 def : InstAlias<"fcmlt $dst, $src1, $src2",
4014 (FCMGT64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
4015 def : InstAlias<"facle $dst, $src1, $src2",
4016 (FACGE32 FPR32:$dst, FPR32:$src2, FPR32:$src1), 0>;
4017 def : InstAlias<"facle $dst, $src1, $src2",
4018 (FACGE64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
4019 def : InstAlias<"faclt $dst, $src1, $src2",
4020 (FACGT32 FPR32:$dst, FPR32:$src2, FPR32:$src1), 0>;
4021 def : InstAlias<"faclt $dst, $src1, $src2",
4022 (FACGT64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
4024 //===----------------------------------------------------------------------===//
4025 // Advanced SIMD three scalar instructions (mixed operands).
4026 //===----------------------------------------------------------------------===//
4027 defm SQDMULL : SIMDThreeScalarMixedHS<0, 0b11010, "sqdmull",
4028 int_aarch64_neon_sqdmulls_scalar>;
4029 defm SQDMLAL : SIMDThreeScalarMixedTiedHS<0, 0b10010, "sqdmlal">;
4030 defm SQDMLSL : SIMDThreeScalarMixedTiedHS<0, 0b10110, "sqdmlsl">;
4032 def : Pat<(i64 (int_aarch64_neon_sqadd (i64 FPR64:$Rd),
4033 (i64 (int_aarch64_neon_sqdmulls_scalar (i32 FPR32:$Rn),
4034 (i32 FPR32:$Rm))))),
4035 (SQDMLALi32 FPR64:$Rd, FPR32:$Rn, FPR32:$Rm)>;
4036 def : Pat<(i64 (int_aarch64_neon_sqsub (i64 FPR64:$Rd),
4037 (i64 (int_aarch64_neon_sqdmulls_scalar (i32 FPR32:$Rn),
4038 (i32 FPR32:$Rm))))),
4039 (SQDMLSLi32 FPR64:$Rd, FPR32:$Rn, FPR32:$Rm)>;
4041 //===----------------------------------------------------------------------===//
4042 // Advanced SIMD two scalar instructions.
4043 //===----------------------------------------------------------------------===//
4045 defm ABS : SIMDTwoScalarD< 0, 0b01011, "abs", abs>;
4046 defm CMEQ : SIMDCmpTwoScalarD< 0, 0b01001, "cmeq", AArch64cmeqz>;
4047 defm CMGE : SIMDCmpTwoScalarD< 1, 0b01000, "cmge", AArch64cmgez>;
4048 defm CMGT : SIMDCmpTwoScalarD< 0, 0b01000, "cmgt", AArch64cmgtz>;
4049 defm CMLE : SIMDCmpTwoScalarD< 1, 0b01001, "cmle", AArch64cmlez>;
4050 defm CMLT : SIMDCmpTwoScalarD< 0, 0b01010, "cmlt", AArch64cmltz>;
4051 defm FCMEQ : SIMDFPCmpTwoScalar<0, 1, 0b01101, "fcmeq", AArch64fcmeqz>;
4052 defm FCMGE : SIMDFPCmpTwoScalar<1, 1, 0b01100, "fcmge", AArch64fcmgez>;
4053 defm FCMGT : SIMDFPCmpTwoScalar<0, 1, 0b01100, "fcmgt", AArch64fcmgtz>;
4054 defm FCMLE : SIMDFPCmpTwoScalar<1, 1, 0b01101, "fcmle", AArch64fcmlez>;
4055 defm FCMLT : SIMDFPCmpTwoScalar<0, 1, 0b01110, "fcmlt", AArch64fcmltz>;
4056 defm FCVTAS : SIMDFPTwoScalar< 0, 0, 0b11100, "fcvtas">;
4057 defm FCVTAU : SIMDFPTwoScalar< 1, 0, 0b11100, "fcvtau">;
4058 defm FCVTMS : SIMDFPTwoScalar< 0, 0, 0b11011, "fcvtms">;
4059 defm FCVTMU : SIMDFPTwoScalar< 1, 0, 0b11011, "fcvtmu">;
4060 defm FCVTNS : SIMDFPTwoScalar< 0, 0, 0b11010, "fcvtns">;
4061 defm FCVTNU : SIMDFPTwoScalar< 1, 0, 0b11010, "fcvtnu">;
4062 defm FCVTPS : SIMDFPTwoScalar< 0, 1, 0b11010, "fcvtps">;
4063 defm FCVTPU : SIMDFPTwoScalar< 1, 1, 0b11010, "fcvtpu">;
4064 def FCVTXNv1i64 : SIMDInexactCvtTwoScalar<0b10110, "fcvtxn">;
4065 defm FCVTZS : SIMDFPTwoScalar< 0, 1, 0b11011, "fcvtzs">;
4066 defm FCVTZU : SIMDFPTwoScalar< 1, 1, 0b11011, "fcvtzu">;
4067 defm FRECPE : SIMDFPTwoScalar< 0, 1, 0b11101, "frecpe">;
4068 defm FRECPX : SIMDFPTwoScalar< 0, 1, 0b11111, "frecpx">;
4069 defm FRSQRTE : SIMDFPTwoScalar< 1, 1, 0b11101, "frsqrte">;
4070 defm NEG : SIMDTwoScalarD< 1, 0b01011, "neg",
4071 UnOpFrag<(sub immAllZerosV, node:$LHS)> >;
4072 defm SCVTF : SIMDFPTwoScalarCVT< 0, 0, 0b11101, "scvtf", AArch64sitof>;
4073 defm SQABS : SIMDTwoScalarBHSD< 0, 0b00111, "sqabs", int_aarch64_neon_sqabs>;
4074 defm SQNEG : SIMDTwoScalarBHSD< 1, 0b00111, "sqneg", int_aarch64_neon_sqneg>;
4075 defm SQXTN : SIMDTwoScalarMixedBHS< 0, 0b10100, "sqxtn", int_aarch64_neon_scalar_sqxtn>;
4076 defm SQXTUN : SIMDTwoScalarMixedBHS< 1, 0b10010, "sqxtun", int_aarch64_neon_scalar_sqxtun>;
4077 defm SUQADD : SIMDTwoScalarBHSDTied< 0, 0b00011, "suqadd",
4078 int_aarch64_neon_suqadd>;
4079 defm UCVTF : SIMDFPTwoScalarCVT< 1, 0, 0b11101, "ucvtf", AArch64uitof>;
4080 defm UQXTN : SIMDTwoScalarMixedBHS<1, 0b10100, "uqxtn", int_aarch64_neon_scalar_uqxtn>;
4081 defm USQADD : SIMDTwoScalarBHSDTied< 1, 0b00011, "usqadd",
4082 int_aarch64_neon_usqadd>;
4084 def : Pat<(AArch64neg (v1i64 V64:$Rn)), (NEGv1i64 V64:$Rn)>;
4086 def : Pat<(v1i64 (int_aarch64_neon_fcvtas (v1f64 FPR64:$Rn))),
4087 (FCVTASv1i64 FPR64:$Rn)>;
4088 def : Pat<(v1i64 (int_aarch64_neon_fcvtau (v1f64 FPR64:$Rn))),
4089 (FCVTAUv1i64 FPR64:$Rn)>;
4090 def : Pat<(v1i64 (int_aarch64_neon_fcvtms (v1f64 FPR64:$Rn))),
4091 (FCVTMSv1i64 FPR64:$Rn)>;
4092 def : Pat<(v1i64 (int_aarch64_neon_fcvtmu (v1f64 FPR64:$Rn))),
4093 (FCVTMUv1i64 FPR64:$Rn)>;
4094 def : Pat<(v1i64 (int_aarch64_neon_fcvtns (v1f64 FPR64:$Rn))),
4095 (FCVTNSv1i64 FPR64:$Rn)>;
4096 def : Pat<(v1i64 (int_aarch64_neon_fcvtnu (v1f64 FPR64:$Rn))),
4097 (FCVTNUv1i64 FPR64:$Rn)>;
4098 def : Pat<(v1i64 (int_aarch64_neon_fcvtps (v1f64 FPR64:$Rn))),
4099 (FCVTPSv1i64 FPR64:$Rn)>;
4100 def : Pat<(v1i64 (int_aarch64_neon_fcvtpu (v1f64 FPR64:$Rn))),
4101 (FCVTPUv1i64 FPR64:$Rn)>;
4103 def : Pat<(f16 (int_aarch64_neon_frecpe (f16 FPR16:$Rn))),
4104 (FRECPEv1f16 FPR16:$Rn)>;
4105 def : Pat<(f32 (int_aarch64_neon_frecpe (f32 FPR32:$Rn))),
4106 (FRECPEv1i32 FPR32:$Rn)>;
4107 def : Pat<(f64 (int_aarch64_neon_frecpe (f64 FPR64:$Rn))),
4108 (FRECPEv1i64 FPR64:$Rn)>;
4109 def : Pat<(v1f64 (int_aarch64_neon_frecpe (v1f64 FPR64:$Rn))),
4110 (FRECPEv1i64 FPR64:$Rn)>;
4112 def : Pat<(f32 (AArch64frecpe (f32 FPR32:$Rn))),
4113 (FRECPEv1i32 FPR32:$Rn)>;
4114 def : Pat<(v2f32 (AArch64frecpe (v2f32 V64:$Rn))),
4115 (FRECPEv2f32 V64:$Rn)>;
4116 def : Pat<(v4f32 (AArch64frecpe (v4f32 FPR128:$Rn))),
4117 (FRECPEv4f32 FPR128:$Rn)>;
4118 def : Pat<(f64 (AArch64frecpe (f64 FPR64:$Rn))),
4119 (FRECPEv1i64 FPR64:$Rn)>;
4120 def : Pat<(v1f64 (AArch64frecpe (v1f64 FPR64:$Rn))),
4121 (FRECPEv1i64 FPR64:$Rn)>;
4122 def : Pat<(v2f64 (AArch64frecpe (v2f64 FPR128:$Rn))),
4123 (FRECPEv2f64 FPR128:$Rn)>;
4125 def : Pat<(f32 (AArch64frecps (f32 FPR32:$Rn), (f32 FPR32:$Rm))),
4126 (FRECPS32 FPR32:$Rn, FPR32:$Rm)>;
4127 def : Pat<(v2f32 (AArch64frecps (v2f32 V64:$Rn), (v2f32 V64:$Rm))),
4128 (FRECPSv2f32 V64:$Rn, V64:$Rm)>;
4129 def : Pat<(v4f32 (AArch64frecps (v4f32 FPR128:$Rn), (v4f32 FPR128:$Rm))),
4130 (FRECPSv4f32 FPR128:$Rn, FPR128:$Rm)>;
4131 def : Pat<(f64 (AArch64frecps (f64 FPR64:$Rn), (f64 FPR64:$Rm))),
4132 (FRECPS64 FPR64:$Rn, FPR64:$Rm)>;
4133 def : Pat<(v2f64 (AArch64frecps (v2f64 FPR128:$Rn), (v2f64 FPR128:$Rm))),
4134 (FRECPSv2f64 FPR128:$Rn, FPR128:$Rm)>;
4136 def : Pat<(f16 (int_aarch64_neon_frecpx (f16 FPR16:$Rn))),
4137 (FRECPXv1f16 FPR16:$Rn)>;
4138 def : Pat<(f32 (int_aarch64_neon_frecpx (f32 FPR32:$Rn))),
4139 (FRECPXv1i32 FPR32:$Rn)>;
4140 def : Pat<(f64 (int_aarch64_neon_frecpx (f64 FPR64:$Rn))),
4141 (FRECPXv1i64 FPR64:$Rn)>;
4143 def : Pat<(f16 (int_aarch64_neon_frsqrte (f16 FPR16:$Rn))),
4144 (FRSQRTEv1f16 FPR16:$Rn)>;
4145 def : Pat<(f32 (int_aarch64_neon_frsqrte (f32 FPR32:$Rn))),
4146 (FRSQRTEv1i32 FPR32:$Rn)>;
4147 def : Pat<(f64 (int_aarch64_neon_frsqrte (f64 FPR64:$Rn))),
4148 (FRSQRTEv1i64 FPR64:$Rn)>;
4149 def : Pat<(v1f64 (int_aarch64_neon_frsqrte (v1f64 FPR64:$Rn))),
4150 (FRSQRTEv1i64 FPR64:$Rn)>;
4152 def : Pat<(f32 (AArch64frsqrte (f32 FPR32:$Rn))),
4153 (FRSQRTEv1i32 FPR32:$Rn)>;
4154 def : Pat<(v2f32 (AArch64frsqrte (v2f32 V64:$Rn))),
4155 (FRSQRTEv2f32 V64:$Rn)>;
4156 def : Pat<(v4f32 (AArch64frsqrte (v4f32 FPR128:$Rn))),
4157 (FRSQRTEv4f32 FPR128:$Rn)>;
4158 def : Pat<(f64 (AArch64frsqrte (f64 FPR64:$Rn))),
4159 (FRSQRTEv1i64 FPR64:$Rn)>;
4160 def : Pat<(v1f64 (AArch64frsqrte (v1f64 FPR64:$Rn))),
4161 (FRSQRTEv1i64 FPR64:$Rn)>;
4162 def : Pat<(v2f64 (AArch64frsqrte (v2f64 FPR128:$Rn))),
4163 (FRSQRTEv2f64 FPR128:$Rn)>;
4165 def : Pat<(f32 (AArch64frsqrts (f32 FPR32:$Rn), (f32 FPR32:$Rm))),
4166 (FRSQRTS32 FPR32:$Rn, FPR32:$Rm)>;
4167 def : Pat<(v2f32 (AArch64frsqrts (v2f32 V64:$Rn), (v2f32 V64:$Rm))),
4168 (FRSQRTSv2f32 V64:$Rn, V64:$Rm)>;
4169 def : Pat<(v4f32 (AArch64frsqrts (v4f32 FPR128:$Rn), (v4f32 FPR128:$Rm))),
4170 (FRSQRTSv4f32 FPR128:$Rn, FPR128:$Rm)>;
4171 def : Pat<(f64 (AArch64frsqrts (f64 FPR64:$Rn), (f64 FPR64:$Rm))),
4172 (FRSQRTS64 FPR64:$Rn, FPR64:$Rm)>;
4173 def : Pat<(v2f64 (AArch64frsqrts (v2f64 FPR128:$Rn), (v2f64 FPR128:$Rm))),
4174 (FRSQRTSv2f64 FPR128:$Rn, FPR128:$Rm)>;
4176 // If an integer is about to be converted to a floating point value,
4177 // just load it on the floating point unit.
4178 // Here are the patterns for 8 and 16-bits to float.
4180 multiclass UIntToFPROLoadPat<ValueType DstTy, ValueType SrcTy,
4181 SDPatternOperator loadop, Instruction UCVTF,
4182 ROAddrMode ro, Instruction LDRW, Instruction LDRX,
4184 def : Pat<(DstTy (uint_to_fp (SrcTy
4185 (loadop (ro.Wpat GPR64sp:$Rn, GPR32:$Rm,
4186 ro.Wext:$extend))))),
4187 (UCVTF (INSERT_SUBREG (DstTy (IMPLICIT_DEF)),
4188 (LDRW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend),
4191 def : Pat<(DstTy (uint_to_fp (SrcTy
4192 (loadop (ro.Xpat GPR64sp:$Rn, GPR64:$Rm,
4193 ro.Wext:$extend))))),
4194 (UCVTF (INSERT_SUBREG (DstTy (IMPLICIT_DEF)),
4195 (LDRX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend),
4199 defm : UIntToFPROLoadPat<f32, i32, zextloadi8,
4200 UCVTFv1i32, ro8, LDRBroW, LDRBroX, bsub>;
4201 def : Pat <(f32 (uint_to_fp (i32
4202 (zextloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))))),
4203 (UCVTFv1i32 (INSERT_SUBREG (f32 (IMPLICIT_DEF)),
4204 (LDRBui GPR64sp:$Rn, uimm12s1:$offset), bsub))>;
4205 def : Pat <(f32 (uint_to_fp (i32
4206 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))))),
4207 (UCVTFv1i32 (INSERT_SUBREG (f32 (IMPLICIT_DEF)),
4208 (LDURBi GPR64sp:$Rn, simm9:$offset), bsub))>;
4209 // 16-bits -> float.
4210 defm : UIntToFPROLoadPat<f32, i32, zextloadi16,
4211 UCVTFv1i32, ro16, LDRHroW, LDRHroX, hsub>;
4212 def : Pat <(f32 (uint_to_fp (i32
4213 (zextloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))))),
4214 (UCVTFv1i32 (INSERT_SUBREG (f32 (IMPLICIT_DEF)),
4215 (LDRHui GPR64sp:$Rn, uimm12s2:$offset), hsub))>;
4216 def : Pat <(f32 (uint_to_fp (i32
4217 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))))),
4218 (UCVTFv1i32 (INSERT_SUBREG (f32 (IMPLICIT_DEF)),
4219 (LDURHi GPR64sp:$Rn, simm9:$offset), hsub))>;
4220 // 32-bits are handled in target specific dag combine:
4221 // performIntToFpCombine.
4222 // 64-bits integer to 32-bits floating point, not possible with
4223 // UCVTF on floating point registers (both source and destination
4224 // must have the same size).
4226 // Here are the patterns for 8, 16, 32, and 64-bits to double.
4227 // 8-bits -> double.
4228 defm : UIntToFPROLoadPat<f64, i32, zextloadi8,
4229 UCVTFv1i64, ro8, LDRBroW, LDRBroX, bsub>;
4230 def : Pat <(f64 (uint_to_fp (i32
4231 (zextloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))))),
4232 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4233 (LDRBui GPR64sp:$Rn, uimm12s1:$offset), bsub))>;
4234 def : Pat <(f64 (uint_to_fp (i32
4235 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))))),
4236 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4237 (LDURBi GPR64sp:$Rn, simm9:$offset), bsub))>;
4238 // 16-bits -> double.
4239 defm : UIntToFPROLoadPat<f64, i32, zextloadi16,
4240 UCVTFv1i64, ro16, LDRHroW, LDRHroX, hsub>;
4241 def : Pat <(f64 (uint_to_fp (i32
4242 (zextloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))))),
4243 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4244 (LDRHui GPR64sp:$Rn, uimm12s2:$offset), hsub))>;
4245 def : Pat <(f64 (uint_to_fp (i32
4246 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))))),
4247 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4248 (LDURHi GPR64sp:$Rn, simm9:$offset), hsub))>;
4249 // 32-bits -> double.
4250 defm : UIntToFPROLoadPat<f64, i32, load,
4251 UCVTFv1i64, ro32, LDRSroW, LDRSroX, ssub>;
4252 def : Pat <(f64 (uint_to_fp (i32
4253 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))))),
4254 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4255 (LDRSui GPR64sp:$Rn, uimm12s4:$offset), ssub))>;
4256 def : Pat <(f64 (uint_to_fp (i32
4257 (load (am_unscaled32 GPR64sp:$Rn, simm9:$offset))))),
4258 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4259 (LDURSi GPR64sp:$Rn, simm9:$offset), ssub))>;
4260 // 64-bits -> double are handled in target specific dag combine:
4261 // performIntToFpCombine.
4263 //===----------------------------------------------------------------------===//
4264 // Advanced SIMD three different-sized vector instructions.
4265 //===----------------------------------------------------------------------===//
4267 defm ADDHN : SIMDNarrowThreeVectorBHS<0,0b0100,"addhn", int_aarch64_neon_addhn>;
4268 defm SUBHN : SIMDNarrowThreeVectorBHS<0,0b0110,"subhn", int_aarch64_neon_subhn>;
4269 defm RADDHN : SIMDNarrowThreeVectorBHS<1,0b0100,"raddhn",int_aarch64_neon_raddhn>;
4270 defm RSUBHN : SIMDNarrowThreeVectorBHS<1,0b0110,"rsubhn",int_aarch64_neon_rsubhn>;
4271 defm PMULL : SIMDDifferentThreeVectorBD<0,0b1110,"pmull",int_aarch64_neon_pmull>;
4272 defm SABAL : SIMDLongThreeVectorTiedBHSabal<0,0b0101,"sabal",
4273 int_aarch64_neon_sabd>;
4274 defm SABDL : SIMDLongThreeVectorBHSabdl<0, 0b0111, "sabdl",
4275 int_aarch64_neon_sabd>;
4276 defm SADDL : SIMDLongThreeVectorBHS< 0, 0b0000, "saddl",
4277 BinOpFrag<(add (sext node:$LHS), (sext node:$RHS))>>;
4278 defm SADDW : SIMDWideThreeVectorBHS< 0, 0b0001, "saddw",
4279 BinOpFrag<(add node:$LHS, (sext node:$RHS))>>;
4280 defm SMLAL : SIMDLongThreeVectorTiedBHS<0, 0b1000, "smlal",
4281 TriOpFrag<(add node:$LHS, (int_aarch64_neon_smull node:$MHS, node:$RHS))>>;
4282 defm SMLSL : SIMDLongThreeVectorTiedBHS<0, 0b1010, "smlsl",
4283 TriOpFrag<(sub node:$LHS, (int_aarch64_neon_smull node:$MHS, node:$RHS))>>;
4284 defm SMULL : SIMDLongThreeVectorBHS<0, 0b1100, "smull", int_aarch64_neon_smull>;
4285 defm SQDMLAL : SIMDLongThreeVectorSQDMLXTiedHS<0, 0b1001, "sqdmlal",
4286 int_aarch64_neon_sqadd>;
4287 defm SQDMLSL : SIMDLongThreeVectorSQDMLXTiedHS<0, 0b1011, "sqdmlsl",
4288 int_aarch64_neon_sqsub>;
4289 defm SQDMULL : SIMDLongThreeVectorHS<0, 0b1101, "sqdmull",
4290 int_aarch64_neon_sqdmull>;
4291 defm SSUBL : SIMDLongThreeVectorBHS<0, 0b0010, "ssubl",
4292 BinOpFrag<(sub (sext node:$LHS), (sext node:$RHS))>>;
4293 defm SSUBW : SIMDWideThreeVectorBHS<0, 0b0011, "ssubw",
4294 BinOpFrag<(sub node:$LHS, (sext node:$RHS))>>;
4295 defm UABAL : SIMDLongThreeVectorTiedBHSabal<1, 0b0101, "uabal",
4296 int_aarch64_neon_uabd>;
4297 defm UADDL : SIMDLongThreeVectorBHS<1, 0b0000, "uaddl",
4298 BinOpFrag<(add (zext node:$LHS), (zext node:$RHS))>>;
4299 defm UADDW : SIMDWideThreeVectorBHS<1, 0b0001, "uaddw",
4300 BinOpFrag<(add node:$LHS, (zext node:$RHS))>>;
4301 defm UMLAL : SIMDLongThreeVectorTiedBHS<1, 0b1000, "umlal",
4302 TriOpFrag<(add node:$LHS, (int_aarch64_neon_umull node:$MHS, node:$RHS))>>;
4303 defm UMLSL : SIMDLongThreeVectorTiedBHS<1, 0b1010, "umlsl",
4304 TriOpFrag<(sub node:$LHS, (int_aarch64_neon_umull node:$MHS, node:$RHS))>>;
4305 defm UMULL : SIMDLongThreeVectorBHS<1, 0b1100, "umull", int_aarch64_neon_umull>;
4306 defm USUBL : SIMDLongThreeVectorBHS<1, 0b0010, "usubl",
4307 BinOpFrag<(sub (zext node:$LHS), (zext node:$RHS))>>;
4308 defm USUBW : SIMDWideThreeVectorBHS< 1, 0b0011, "usubw",
4309 BinOpFrag<(sub node:$LHS, (zext node:$RHS))>>;
4311 // Additional patterns for SMULL and UMULL
4312 multiclass Neon_mul_widen_patterns<SDPatternOperator opnode,
4313 Instruction INST8B, Instruction INST4H, Instruction INST2S> {
4314 def : Pat<(v8i16 (opnode (v8i8 V64:$Rn), (v8i8 V64:$Rm))),
4315 (INST8B V64:$Rn, V64:$Rm)>;
4316 def : Pat<(v4i32 (opnode (v4i16 V64:$Rn), (v4i16 V64:$Rm))),
4317 (INST4H V64:$Rn, V64:$Rm)>;
4318 def : Pat<(v2i64 (opnode (v2i32 V64:$Rn), (v2i32 V64:$Rm))),
4319 (INST2S V64:$Rn, V64:$Rm)>;
4322 defm : Neon_mul_widen_patterns<AArch64smull, SMULLv8i8_v8i16,
4323 SMULLv4i16_v4i32, SMULLv2i32_v2i64>;
4324 defm : Neon_mul_widen_patterns<AArch64umull, UMULLv8i8_v8i16,
4325 UMULLv4i16_v4i32, UMULLv2i32_v2i64>;
4327 // Additional patterns for SMLAL/SMLSL and UMLAL/UMLSL
4328 multiclass Neon_mulacc_widen_patterns<SDPatternOperator opnode,
4329 Instruction INST8B, Instruction INST4H, Instruction INST2S> {
4330 def : Pat<(v8i16 (opnode (v8i16 V128:$Rd), (v8i8 V64:$Rn), (v8i8 V64:$Rm))),
4331 (INST8B V128:$Rd, V64:$Rn, V64:$Rm)>;
4332 def : Pat<(v4i32 (opnode (v4i32 V128:$Rd), (v4i16 V64:$Rn), (v4i16 V64:$Rm))),
4333 (INST4H V128:$Rd, V64:$Rn, V64:$Rm)>;
4334 def : Pat<(v2i64 (opnode (v2i64 V128:$Rd), (v2i32 V64:$Rn), (v2i32 V64:$Rm))),
4335 (INST2S V128:$Rd, V64:$Rn, V64:$Rm)>;
4338 defm : Neon_mulacc_widen_patterns<
4339 TriOpFrag<(add node:$LHS, (AArch64smull node:$MHS, node:$RHS))>,
4340 SMLALv8i8_v8i16, SMLALv4i16_v4i32, SMLALv2i32_v2i64>;
4341 defm : Neon_mulacc_widen_patterns<
4342 TriOpFrag<(add node:$LHS, (AArch64umull node:$MHS, node:$RHS))>,
4343 UMLALv8i8_v8i16, UMLALv4i16_v4i32, UMLALv2i32_v2i64>;
4344 defm : Neon_mulacc_widen_patterns<
4345 TriOpFrag<(sub node:$LHS, (AArch64smull node:$MHS, node:$RHS))>,
4346 SMLSLv8i8_v8i16, SMLSLv4i16_v4i32, SMLSLv2i32_v2i64>;
4347 defm : Neon_mulacc_widen_patterns<
4348 TriOpFrag<(sub node:$LHS, (AArch64umull node:$MHS, node:$RHS))>,
4349 UMLSLv8i8_v8i16, UMLSLv4i16_v4i32, UMLSLv2i32_v2i64>;
4351 // Patterns for 64-bit pmull
4352 def : Pat<(int_aarch64_neon_pmull64 V64:$Rn, V64:$Rm),
4353 (PMULLv1i64 V64:$Rn, V64:$Rm)>;
4354 def : Pat<(int_aarch64_neon_pmull64 (extractelt (v2i64 V128:$Rn), (i64 1)),
4355 (extractelt (v2i64 V128:$Rm), (i64 1))),
4356 (PMULLv2i64 V128:$Rn, V128:$Rm)>;
4358 // CodeGen patterns for addhn and subhn instructions, which can actually be
4359 // written in LLVM IR without too much difficulty.
4362 def : Pat<(v8i8 (trunc (v8i16 (AArch64vlshr (add V128:$Rn, V128:$Rm), (i32 8))))),
4363 (ADDHNv8i16_v8i8 V128:$Rn, V128:$Rm)>;
4364 def : Pat<(v4i16 (trunc (v4i32 (AArch64vlshr (add V128:$Rn, V128:$Rm),
4366 (ADDHNv4i32_v4i16 V128:$Rn, V128:$Rm)>;
4367 def : Pat<(v2i32 (trunc (v2i64 (AArch64vlshr (add V128:$Rn, V128:$Rm),
4369 (ADDHNv2i64_v2i32 V128:$Rn, V128:$Rm)>;
4370 def : Pat<(concat_vectors (v8i8 V64:$Rd),
4371 (trunc (v8i16 (AArch64vlshr (add V128:$Rn, V128:$Rm),
4373 (ADDHNv8i16_v16i8 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4374 V128:$Rn, V128:$Rm)>;
4375 def : Pat<(concat_vectors (v4i16 V64:$Rd),
4376 (trunc (v4i32 (AArch64vlshr (add V128:$Rn, V128:$Rm),
4378 (ADDHNv4i32_v8i16 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4379 V128:$Rn, V128:$Rm)>;
4380 def : Pat<(concat_vectors (v2i32 V64:$Rd),
4381 (trunc (v2i64 (AArch64vlshr (add V128:$Rn, V128:$Rm),
4383 (ADDHNv2i64_v4i32 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4384 V128:$Rn, V128:$Rm)>;
4387 def : Pat<(v8i8 (trunc (v8i16 (AArch64vlshr (sub V128:$Rn, V128:$Rm), (i32 8))))),
4388 (SUBHNv8i16_v8i8 V128:$Rn, V128:$Rm)>;
4389 def : Pat<(v4i16 (trunc (v4i32 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
4391 (SUBHNv4i32_v4i16 V128:$Rn, V128:$Rm)>;
4392 def : Pat<(v2i32 (trunc (v2i64 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
4394 (SUBHNv2i64_v2i32 V128:$Rn, V128:$Rm)>;
4395 def : Pat<(concat_vectors (v8i8 V64:$Rd),
4396 (trunc (v8i16 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
4398 (SUBHNv8i16_v16i8 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4399 V128:$Rn, V128:$Rm)>;
4400 def : Pat<(concat_vectors (v4i16 V64:$Rd),
4401 (trunc (v4i32 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
4403 (SUBHNv4i32_v8i16 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4404 V128:$Rn, V128:$Rm)>;
4405 def : Pat<(concat_vectors (v2i32 V64:$Rd),
4406 (trunc (v2i64 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
4408 (SUBHNv2i64_v4i32 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4409 V128:$Rn, V128:$Rm)>;
4411 //----------------------------------------------------------------------------
4412 // AdvSIMD bitwise extract from vector instruction.
4413 //----------------------------------------------------------------------------
4415 defm EXT : SIMDBitwiseExtract<"ext">;
4417 def AdjustExtImm : SDNodeXForm<imm, [{
4418 return CurDAG->getTargetConstant(8 + N->getZExtValue(), SDLoc(N), MVT::i32);
4420 multiclass ExtPat<ValueType VT64, ValueType VT128, int N> {
4421 def : Pat<(VT64 (AArch64ext V64:$Rn, V64:$Rm, (i32 imm:$imm))),
4422 (EXTv8i8 V64:$Rn, V64:$Rm, imm:$imm)>;
4423 def : Pat<(VT128 (AArch64ext V128:$Rn, V128:$Rm, (i32 imm:$imm))),
4424 (EXTv16i8 V128:$Rn, V128:$Rm, imm:$imm)>;
4425 // We use EXT to handle extract_subvector to copy the upper 64-bits of a
4427 def : Pat<(VT64 (extract_subvector V128:$Rn, (i64 N))),
4428 (EXTRACT_SUBREG (EXTv16i8 V128:$Rn, V128:$Rn, 8), dsub)>;
4429 // A 64-bit EXT of two halves of the same 128-bit register can be done as a
4430 // single 128-bit EXT.
4431 def : Pat<(VT64 (AArch64ext (extract_subvector V128:$Rn, (i64 0)),
4432 (extract_subvector V128:$Rn, (i64 N)),
4434 (EXTRACT_SUBREG (EXTv16i8 V128:$Rn, V128:$Rn, imm:$imm), dsub)>;
4435 // A 64-bit EXT of the high half of a 128-bit register can be done using a
4436 // 128-bit EXT of the whole register with an adjustment to the immediate. The
4437 // top half of the other operand will be unset, but that doesn't matter as it
4438 // will not be used.
4439 def : Pat<(VT64 (AArch64ext (extract_subvector V128:$Rn, (i64 N)),
4442 (EXTRACT_SUBREG (EXTv16i8 V128:$Rn,
4443 (SUBREG_TO_REG (i32 0), V64:$Rm, dsub),
4444 (AdjustExtImm imm:$imm)), dsub)>;
4447 defm : ExtPat<v8i8, v16i8, 8>;
4448 defm : ExtPat<v4i16, v8i16, 4>;
4449 defm : ExtPat<v4f16, v8f16, 4>;
4450 defm : ExtPat<v2i32, v4i32, 2>;
4451 defm : ExtPat<v2f32, v4f32, 2>;
4452 defm : ExtPat<v1i64, v2i64, 1>;
4453 defm : ExtPat<v1f64, v2f64, 1>;
4455 //----------------------------------------------------------------------------
4456 // AdvSIMD zip vector
4457 //----------------------------------------------------------------------------
4459 defm TRN1 : SIMDZipVector<0b010, "trn1", AArch64trn1>;
4460 defm TRN2 : SIMDZipVector<0b110, "trn2", AArch64trn2>;
4461 defm UZP1 : SIMDZipVector<0b001, "uzp1", AArch64uzp1>;
4462 defm UZP2 : SIMDZipVector<0b101, "uzp2", AArch64uzp2>;
4463 defm ZIP1 : SIMDZipVector<0b011, "zip1", AArch64zip1>;
4464 defm ZIP2 : SIMDZipVector<0b111, "zip2", AArch64zip2>;
4466 //----------------------------------------------------------------------------
4467 // AdvSIMD TBL/TBX instructions
4468 //----------------------------------------------------------------------------
4470 defm TBL : SIMDTableLookup< 0, "tbl">;
4471 defm TBX : SIMDTableLookupTied<1, "tbx">;
4473 def : Pat<(v8i8 (int_aarch64_neon_tbl1 (v16i8 VecListOne128:$Rn), (v8i8 V64:$Ri))),
4474 (TBLv8i8One VecListOne128:$Rn, V64:$Ri)>;
4475 def : Pat<(v16i8 (int_aarch64_neon_tbl1 (v16i8 V128:$Ri), (v16i8 V128:$Rn))),
4476 (TBLv16i8One V128:$Ri, V128:$Rn)>;
4478 def : Pat<(v8i8 (int_aarch64_neon_tbx1 (v8i8 V64:$Rd),
4479 (v16i8 VecListOne128:$Rn), (v8i8 V64:$Ri))),
4480 (TBXv8i8One V64:$Rd, VecListOne128:$Rn, V64:$Ri)>;
4481 def : Pat<(v16i8 (int_aarch64_neon_tbx1 (v16i8 V128:$Rd),
4482 (v16i8 V128:$Ri), (v16i8 V128:$Rn))),
4483 (TBXv16i8One V128:$Rd, V128:$Ri, V128:$Rn)>;
4486 //----------------------------------------------------------------------------
4487 // AdvSIMD scalar CPY instruction
4488 //----------------------------------------------------------------------------
4490 defm CPY : SIMDScalarCPY<"cpy">;
4492 //----------------------------------------------------------------------------
4493 // AdvSIMD scalar pairwise instructions
4494 //----------------------------------------------------------------------------
4496 defm ADDP : SIMDPairwiseScalarD<0, 0b11011, "addp">;
4497 defm FADDP : SIMDFPPairwiseScalar<0, 0b01101, "faddp">;
4498 defm FMAXNMP : SIMDFPPairwiseScalar<0, 0b01100, "fmaxnmp">;
4499 defm FMAXP : SIMDFPPairwiseScalar<0, 0b01111, "fmaxp">;
4500 defm FMINNMP : SIMDFPPairwiseScalar<1, 0b01100, "fminnmp">;
4501 defm FMINP : SIMDFPPairwiseScalar<1, 0b01111, "fminp">;
4502 def : Pat<(v2i64 (AArch64saddv V128:$Rn)),
4503 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)), (ADDPv2i64p V128:$Rn), dsub)>;
4504 def : Pat<(v2i64 (AArch64uaddv V128:$Rn)),
4505 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)), (ADDPv2i64p V128:$Rn), dsub)>;
4506 def : Pat<(f32 (int_aarch64_neon_faddv (v2f32 V64:$Rn))),
4507 (FADDPv2i32p V64:$Rn)>;
4508 def : Pat<(f32 (int_aarch64_neon_faddv (v4f32 V128:$Rn))),
4509 (FADDPv2i32p (EXTRACT_SUBREG (FADDPv4f32 V128:$Rn, V128:$Rn), dsub))>;
4510 def : Pat<(f64 (int_aarch64_neon_faddv (v2f64 V128:$Rn))),
4511 (FADDPv2i64p V128:$Rn)>;
4512 def : Pat<(f32 (int_aarch64_neon_fmaxnmv (v2f32 V64:$Rn))),
4513 (FMAXNMPv2i32p V64:$Rn)>;
4514 def : Pat<(f64 (int_aarch64_neon_fmaxnmv (v2f64 V128:$Rn))),
4515 (FMAXNMPv2i64p V128:$Rn)>;
4516 def : Pat<(f32 (int_aarch64_neon_fmaxv (v2f32 V64:$Rn))),
4517 (FMAXPv2i32p V64:$Rn)>;
4518 def : Pat<(f64 (int_aarch64_neon_fmaxv (v2f64 V128:$Rn))),
4519 (FMAXPv2i64p V128:$Rn)>;
4520 def : Pat<(f32 (int_aarch64_neon_fminnmv (v2f32 V64:$Rn))),
4521 (FMINNMPv2i32p V64:$Rn)>;
4522 def : Pat<(f64 (int_aarch64_neon_fminnmv (v2f64 V128:$Rn))),
4523 (FMINNMPv2i64p V128:$Rn)>;
4524 def : Pat<(f32 (int_aarch64_neon_fminv (v2f32 V64:$Rn))),
4525 (FMINPv2i32p V64:$Rn)>;
4526 def : Pat<(f64 (int_aarch64_neon_fminv (v2f64 V128:$Rn))),
4527 (FMINPv2i64p V128:$Rn)>;
4529 //----------------------------------------------------------------------------
4530 // AdvSIMD INS/DUP instructions
4531 //----------------------------------------------------------------------------
4533 def DUPv8i8gpr : SIMDDupFromMain<0, {?,?,?,?,1}, ".8b", v8i8, V64, GPR32>;
4534 def DUPv16i8gpr : SIMDDupFromMain<1, {?,?,?,?,1}, ".16b", v16i8, V128, GPR32>;
4535 def DUPv4i16gpr : SIMDDupFromMain<0, {?,?,?,1,0}, ".4h", v4i16, V64, GPR32>;
4536 def DUPv8i16gpr : SIMDDupFromMain<1, {?,?,?,1,0}, ".8h", v8i16, V128, GPR32>;
4537 def DUPv2i32gpr : SIMDDupFromMain<0, {?,?,1,0,0}, ".2s", v2i32, V64, GPR32>;
4538 def DUPv4i32gpr : SIMDDupFromMain<1, {?,?,1,0,0}, ".4s", v4i32, V128, GPR32>;
4539 def DUPv2i64gpr : SIMDDupFromMain<1, {?,1,0,0,0}, ".2d", v2i64, V128, GPR64>;
4541 def DUPv2i64lane : SIMDDup64FromElement;
4542 def DUPv2i32lane : SIMDDup32FromElement<0, ".2s", v2i32, V64>;
4543 def DUPv4i32lane : SIMDDup32FromElement<1, ".4s", v4i32, V128>;
4544 def DUPv4i16lane : SIMDDup16FromElement<0, ".4h", v4i16, V64>;
4545 def DUPv8i16lane : SIMDDup16FromElement<1, ".8h", v8i16, V128>;
4546 def DUPv8i8lane : SIMDDup8FromElement <0, ".8b", v8i8, V64>;
4547 def DUPv16i8lane : SIMDDup8FromElement <1, ".16b", v16i8, V128>;
4549 // DUP from a 64-bit register to a 64-bit register is just a copy
4550 def : Pat<(v1i64 (AArch64dup (i64 GPR64:$Rn))),
4551 (COPY_TO_REGCLASS GPR64:$Rn, FPR64)>;
4552 def : Pat<(v1f64 (AArch64dup (f64 FPR64:$Rn))),
4553 (COPY_TO_REGCLASS FPR64:$Rn, FPR64)>;
4555 def : Pat<(v2f32 (AArch64dup (f32 FPR32:$Rn))),
4556 (v2f32 (DUPv2i32lane
4557 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR32:$Rn, ssub),
4559 def : Pat<(v4f32 (AArch64dup (f32 FPR32:$Rn))),
4560 (v4f32 (DUPv4i32lane
4561 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR32:$Rn, ssub),
4563 def : Pat<(v2f64 (AArch64dup (f64 FPR64:$Rn))),
4564 (v2f64 (DUPv2i64lane
4565 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR64:$Rn, dsub),
4567 def : Pat<(v4f16 (AArch64dup (f16 FPR16:$Rn))),
4568 (v4f16 (DUPv4i16lane
4569 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)), FPR16:$Rn, hsub),
4571 def : Pat<(v8f16 (AArch64dup (f16 FPR16:$Rn))),
4572 (v8f16 (DUPv8i16lane
4573 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)), FPR16:$Rn, hsub),
4576 def : Pat<(v4f16 (AArch64duplane16 (v8f16 V128:$Rn), VectorIndexH:$imm)),
4577 (DUPv4i16lane V128:$Rn, VectorIndexH:$imm)>;
4578 def : Pat<(v8f16 (AArch64duplane16 (v8f16 V128:$Rn), VectorIndexH:$imm)),
4579 (DUPv8i16lane V128:$Rn, VectorIndexH:$imm)>;
4581 def : Pat<(v2f32 (AArch64duplane32 (v4f32 V128:$Rn), VectorIndexS:$imm)),
4582 (DUPv2i32lane V128:$Rn, VectorIndexS:$imm)>;
4583 def : Pat<(v4f32 (AArch64duplane32 (v4f32 V128:$Rn), VectorIndexS:$imm)),
4584 (DUPv4i32lane V128:$Rn, VectorIndexS:$imm)>;
4585 def : Pat<(v2f64 (AArch64duplane64 (v2f64 V128:$Rn), VectorIndexD:$imm)),
4586 (DUPv2i64lane V128:$Rn, VectorIndexD:$imm)>;
4588 // If there's an (AArch64dup (vector_extract ...) ...), we can use a duplane
4589 // instruction even if the types don't match: we just have to remap the lane
4590 // carefully. N.b. this trick only applies to truncations.
4591 def VecIndex_x2 : SDNodeXForm<imm, [{
4592 return CurDAG->getTargetConstant(2 * N->getZExtValue(), SDLoc(N), MVT::i64);
4594 def VecIndex_x4 : SDNodeXForm<imm, [{
4595 return CurDAG->getTargetConstant(4 * N->getZExtValue(), SDLoc(N), MVT::i64);
4597 def VecIndex_x8 : SDNodeXForm<imm, [{
4598 return CurDAG->getTargetConstant(8 * N->getZExtValue(), SDLoc(N), MVT::i64);
4601 multiclass DUPWithTruncPats<ValueType ResVT, ValueType Src64VT,
4602 ValueType Src128VT, ValueType ScalVT,
4603 Instruction DUP, SDNodeXForm IdxXFORM> {
4604 def : Pat<(ResVT (AArch64dup (ScalVT (vector_extract (Src128VT V128:$Rn),
4606 (DUP V128:$Rn, (IdxXFORM imm:$idx))>;
4608 def : Pat<(ResVT (AArch64dup (ScalVT (vector_extract (Src64VT V64:$Rn),
4610 (DUP (SUBREG_TO_REG (i64 0), V64:$Rn, dsub), (IdxXFORM imm:$idx))>;
4613 defm : DUPWithTruncPats<v8i8, v4i16, v8i16, i32, DUPv8i8lane, VecIndex_x2>;
4614 defm : DUPWithTruncPats<v8i8, v2i32, v4i32, i32, DUPv8i8lane, VecIndex_x4>;
4615 defm : DUPWithTruncPats<v4i16, v2i32, v4i32, i32, DUPv4i16lane, VecIndex_x2>;
4617 defm : DUPWithTruncPats<v16i8, v4i16, v8i16, i32, DUPv16i8lane, VecIndex_x2>;
4618 defm : DUPWithTruncPats<v16i8, v2i32, v4i32, i32, DUPv16i8lane, VecIndex_x4>;
4619 defm : DUPWithTruncPats<v8i16, v2i32, v4i32, i32, DUPv8i16lane, VecIndex_x2>;
4621 multiclass DUPWithTrunci64Pats<ValueType ResVT, Instruction DUP,
4622 SDNodeXForm IdxXFORM> {
4623 def : Pat<(ResVT (AArch64dup (i32 (trunc (extractelt (v2i64 V128:$Rn),
4625 (DUP V128:$Rn, (IdxXFORM imm:$idx))>;
4627 def : Pat<(ResVT (AArch64dup (i32 (trunc (extractelt (v1i64 V64:$Rn),
4629 (DUP (SUBREG_TO_REG (i64 0), V64:$Rn, dsub), (IdxXFORM imm:$idx))>;
4632 defm : DUPWithTrunci64Pats<v8i8, DUPv8i8lane, VecIndex_x8>;
4633 defm : DUPWithTrunci64Pats<v4i16, DUPv4i16lane, VecIndex_x4>;
4634 defm : DUPWithTrunci64Pats<v2i32, DUPv2i32lane, VecIndex_x2>;
4636 defm : DUPWithTrunci64Pats<v16i8, DUPv16i8lane, VecIndex_x8>;
4637 defm : DUPWithTrunci64Pats<v8i16, DUPv8i16lane, VecIndex_x4>;
4638 defm : DUPWithTrunci64Pats<v4i32, DUPv4i32lane, VecIndex_x2>;
4640 // SMOV and UMOV definitions, with some extra patterns for convenience
4644 def : Pat<(sext_inreg (vector_extract (v16i8 V128:$Rn), VectorIndexB:$idx), i8),
4645 (i32 (SMOVvi8to32 V128:$Rn, VectorIndexB:$idx))>;
4646 def : Pat<(sext_inreg (vector_extract (v16i8 V128:$Rn), VectorIndexB:$idx), i8),
4647 (i64 (SMOVvi8to64 V128:$Rn, VectorIndexB:$idx))>;
4648 def : Pat<(sext_inreg (vector_extract (v8i16 V128:$Rn), VectorIndexH:$idx),i16),
4649 (i32 (SMOVvi16to32 V128:$Rn, VectorIndexH:$idx))>;
4650 def : Pat<(sext_inreg (vector_extract (v8i16 V128:$Rn), VectorIndexH:$idx),i16),
4651 (i64 (SMOVvi16to64 V128:$Rn, VectorIndexH:$idx))>;
4652 def : Pat<(sext_inreg (vector_extract (v8i16 V128:$Rn), VectorIndexH:$idx),i16),
4653 (i32 (SMOVvi16to32 V128:$Rn, VectorIndexH:$idx))>;
4654 def : Pat<(sext (i32 (vector_extract (v4i32 V128:$Rn), VectorIndexS:$idx))),
4655 (i64 (SMOVvi32to64 V128:$Rn, VectorIndexS:$idx))>;
4657 def : Pat<(sext_inreg (i64 (anyext (i32 (vector_extract (v16i8 V128:$Rn),
4658 VectorIndexB:$idx)))), i8),
4659 (i64 (SMOVvi8to64 V128:$Rn, VectorIndexB:$idx))>;
4660 def : Pat<(sext_inreg (i64 (anyext (i32 (vector_extract (v8i16 V128:$Rn),
4661 VectorIndexH:$idx)))), i16),
4662 (i64 (SMOVvi16to64 V128:$Rn, VectorIndexH:$idx))>;
4664 // Extracting i8 or i16 elements will have the zero-extend transformed to
4665 // an 'and' mask by type legalization since neither i8 nor i16 are legal types
4666 // for AArch64. Match these patterns here since UMOV already zeroes out the high
4667 // bits of the destination register.
4668 def : Pat<(and (vector_extract (v16i8 V128:$Rn), VectorIndexB:$idx),
4670 (i32 (UMOVvi8 V128:$Rn, VectorIndexB:$idx))>;
4671 def : Pat<(and (vector_extract (v8i16 V128:$Rn), VectorIndexH:$idx),
4673 (i32 (UMOVvi16 V128:$Rn, VectorIndexH:$idx))>;
4677 def : Pat<(v16i8 (scalar_to_vector GPR32:$Rn)),
4678 (SUBREG_TO_REG (i32 0),
4679 (f32 (COPY_TO_REGCLASS GPR32:$Rn, FPR32)), ssub)>;
4680 def : Pat<(v8i8 (scalar_to_vector GPR32:$Rn)),
4681 (SUBREG_TO_REG (i32 0),
4682 (f32 (COPY_TO_REGCLASS GPR32:$Rn, FPR32)), ssub)>;
4684 def : Pat<(v8i16 (scalar_to_vector GPR32:$Rn)),
4685 (SUBREG_TO_REG (i32 0),
4686 (f32 (COPY_TO_REGCLASS GPR32:$Rn, FPR32)), ssub)>;
4687 def : Pat<(v4i16 (scalar_to_vector GPR32:$Rn)),
4688 (SUBREG_TO_REG (i32 0),
4689 (f32 (COPY_TO_REGCLASS GPR32:$Rn, FPR32)), ssub)>;
4691 def : Pat<(v4f16 (scalar_to_vector (f16 FPR16:$Rn))),
4692 (INSERT_SUBREG (v4f16 (IMPLICIT_DEF)), FPR16:$Rn, hsub)>;
4693 def : Pat<(v8f16 (scalar_to_vector (f16 FPR16:$Rn))),
4694 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR16:$Rn, hsub)>;
4696 def : Pat<(v2i32 (scalar_to_vector (i32 FPR32:$Rn))),
4697 (v2i32 (INSERT_SUBREG (v2i32 (IMPLICIT_DEF)),
4698 (i32 FPR32:$Rn), ssub))>;
4699 def : Pat<(v4i32 (scalar_to_vector (i32 FPR32:$Rn))),
4700 (v4i32 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)),
4701 (i32 FPR32:$Rn), ssub))>;
4703 def : Pat<(v2i64 (scalar_to_vector (i64 FPR64:$Rn))),
4704 (v2i64 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)),
4705 (i64 FPR64:$Rn), dsub))>;
4707 def : Pat<(v4f16 (scalar_to_vector (f16 FPR16:$Rn))),
4708 (INSERT_SUBREG (v4f16 (IMPLICIT_DEF)), FPR16:$Rn, hsub)>;
4709 def : Pat<(v8f16 (scalar_to_vector (f16 FPR16:$Rn))),
4710 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR16:$Rn, hsub)>;
4712 def : Pat<(v4f32 (scalar_to_vector (f32 FPR32:$Rn))),
4713 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FPR32:$Rn, ssub)>;
4714 def : Pat<(v2f32 (scalar_to_vector (f32 FPR32:$Rn))),
4715 (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), FPR32:$Rn, ssub)>;
4717 def : Pat<(v2f64 (scalar_to_vector (f64 FPR64:$Rn))),
4718 (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), FPR64:$Rn, dsub)>;
4720 def : Pat<(v4f16 (vector_insert (v4f16 V64:$Rn),
4721 (f16 FPR16:$Rm), (i64 VectorIndexS:$imm))),
4724 (v8f16 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), V64:$Rn, dsub)),
4726 (v8f16 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR16:$Rm, hsub)),
4730 def : Pat<(v8f16 (vector_insert (v8f16 V128:$Rn),
4731 (f16 FPR16:$Rm), (i64 VectorIndexH:$imm))),
4733 V128:$Rn, VectorIndexH:$imm,
4734 (v8f16 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR16:$Rm, hsub)),
4737 def : Pat<(v2f32 (vector_insert (v2f32 V64:$Rn),
4738 (f32 FPR32:$Rm), (i64 VectorIndexS:$imm))),
4741 (v4f32 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), V64:$Rn, dsub)),
4743 (v4f32 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FPR32:$Rm, ssub)),
4746 def : Pat<(v4f32 (vector_insert (v4f32 V128:$Rn),
4747 (f32 FPR32:$Rm), (i64 VectorIndexS:$imm))),
4749 V128:$Rn, VectorIndexS:$imm,
4750 (v4f32 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FPR32:$Rm, ssub)),
4752 def : Pat<(v2f64 (vector_insert (v2f64 V128:$Rn),
4753 (f64 FPR64:$Rm), (i64 VectorIndexD:$imm))),
4755 V128:$Rn, VectorIndexD:$imm,
4756 (v2f64 (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), FPR64:$Rm, dsub)),
4759 // Copy an element at a constant index in one vector into a constant indexed
4760 // element of another.
4761 // FIXME refactor to a shared class/dev parameterized on vector type, vector
4762 // index type and INS extension
4763 def : Pat<(v16i8 (int_aarch64_neon_vcopy_lane
4764 (v16i8 V128:$Vd), VectorIndexB:$idx, (v16i8 V128:$Vs),
4765 VectorIndexB:$idx2)),
4767 V128:$Vd, VectorIndexB:$idx, V128:$Vs, VectorIndexB:$idx2)
4769 def : Pat<(v8i16 (int_aarch64_neon_vcopy_lane
4770 (v8i16 V128:$Vd), VectorIndexH:$idx, (v8i16 V128:$Vs),
4771 VectorIndexH:$idx2)),
4773 V128:$Vd, VectorIndexH:$idx, V128:$Vs, VectorIndexH:$idx2)
4775 def : Pat<(v4i32 (int_aarch64_neon_vcopy_lane
4776 (v4i32 V128:$Vd), VectorIndexS:$idx, (v4i32 V128:$Vs),
4777 VectorIndexS:$idx2)),
4779 V128:$Vd, VectorIndexS:$idx, V128:$Vs, VectorIndexS:$idx2)
4781 def : Pat<(v2i64 (int_aarch64_neon_vcopy_lane
4782 (v2i64 V128:$Vd), VectorIndexD:$idx, (v2i64 V128:$Vs),
4783 VectorIndexD:$idx2)),
4785 V128:$Vd, VectorIndexD:$idx, V128:$Vs, VectorIndexD:$idx2)
4788 multiclass Neon_INS_elt_pattern<ValueType VT128, ValueType VT64,
4789 ValueType VTScal, Instruction INS> {
4790 def : Pat<(VT128 (vector_insert V128:$src,
4791 (VTScal (vector_extract (VT128 V128:$Rn), imm:$Immn)),
4793 (INS V128:$src, imm:$Immd, V128:$Rn, imm:$Immn)>;
4795 def : Pat<(VT128 (vector_insert V128:$src,
4796 (VTScal (vector_extract (VT64 V64:$Rn), imm:$Immn)),
4798 (INS V128:$src, imm:$Immd,
4799 (SUBREG_TO_REG (i64 0), V64:$Rn, dsub), imm:$Immn)>;
4801 def : Pat<(VT64 (vector_insert V64:$src,
4802 (VTScal (vector_extract (VT128 V128:$Rn), imm:$Immn)),
4804 (EXTRACT_SUBREG (INS (SUBREG_TO_REG (i64 0), V64:$src, dsub),
4805 imm:$Immd, V128:$Rn, imm:$Immn),
4808 def : Pat<(VT64 (vector_insert V64:$src,
4809 (VTScal (vector_extract (VT64 V64:$Rn), imm:$Immn)),
4812 (INS (SUBREG_TO_REG (i64 0), V64:$src, dsub), imm:$Immd,
4813 (SUBREG_TO_REG (i64 0), V64:$Rn, dsub), imm:$Immn),
4817 defm : Neon_INS_elt_pattern<v8f16, v4f16, f16, INSvi16lane>;
4818 defm : Neon_INS_elt_pattern<v4f32, v2f32, f32, INSvi32lane>;
4819 defm : Neon_INS_elt_pattern<v2f64, v1f64, f64, INSvi64lane>;
4822 // Floating point vector extractions are codegen'd as either a sequence of
4823 // subregister extractions, or a MOV (aka CPY here, alias for DUP) if
4824 // the lane number is anything other than zero.
4825 def : Pat<(vector_extract (v2f64 V128:$Rn), 0),
4826 (f64 (EXTRACT_SUBREG V128:$Rn, dsub))>;
4827 def : Pat<(vector_extract (v4f32 V128:$Rn), 0),
4828 (f32 (EXTRACT_SUBREG V128:$Rn, ssub))>;
4829 def : Pat<(vector_extract (v8f16 V128:$Rn), 0),
4830 (f16 (EXTRACT_SUBREG V128:$Rn, hsub))>;
4832 def : Pat<(vector_extract (v2f64 V128:$Rn), VectorIndexD:$idx),
4833 (f64 (CPYi64 V128:$Rn, VectorIndexD:$idx))>;
4834 def : Pat<(vector_extract (v4f32 V128:$Rn), VectorIndexS:$idx),
4835 (f32 (CPYi32 V128:$Rn, VectorIndexS:$idx))>;
4836 def : Pat<(vector_extract (v8f16 V128:$Rn), VectorIndexH:$idx),
4837 (f16 (CPYi16 V128:$Rn, VectorIndexH:$idx))>;
4839 // All concat_vectors operations are canonicalised to act on i64 vectors for
4840 // AArch64. In the general case we need an instruction, which had just as well be
4842 class ConcatPat<ValueType DstTy, ValueType SrcTy>
4843 : Pat<(DstTy (concat_vectors (SrcTy V64:$Rd), V64:$Rn)),
4844 (INSvi64lane (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), 1,
4845 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rn, dsub), 0)>;
4847 def : ConcatPat<v2i64, v1i64>;
4848 def : ConcatPat<v2f64, v1f64>;
4849 def : ConcatPat<v4i32, v2i32>;
4850 def : ConcatPat<v4f32, v2f32>;
4851 def : ConcatPat<v8i16, v4i16>;
4852 def : ConcatPat<v8f16, v4f16>;
4853 def : ConcatPat<v16i8, v8i8>;
4855 // If the high lanes are undef, though, we can just ignore them:
4856 class ConcatUndefPat<ValueType DstTy, ValueType SrcTy>
4857 : Pat<(DstTy (concat_vectors (SrcTy V64:$Rn), undef)),
4858 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rn, dsub)>;
4860 def : ConcatUndefPat<v2i64, v1i64>;
4861 def : ConcatUndefPat<v2f64, v1f64>;
4862 def : ConcatUndefPat<v4i32, v2i32>;
4863 def : ConcatUndefPat<v4f32, v2f32>;
4864 def : ConcatUndefPat<v8i16, v4i16>;
4865 def : ConcatUndefPat<v16i8, v8i8>;
4867 //----------------------------------------------------------------------------
4868 // AdvSIMD across lanes instructions
4869 //----------------------------------------------------------------------------
4871 defm ADDV : SIMDAcrossLanesBHS<0, 0b11011, "addv">;
4872 defm SMAXV : SIMDAcrossLanesBHS<0, 0b01010, "smaxv">;
4873 defm SMINV : SIMDAcrossLanesBHS<0, 0b11010, "sminv">;
4874 defm UMAXV : SIMDAcrossLanesBHS<1, 0b01010, "umaxv">;
4875 defm UMINV : SIMDAcrossLanesBHS<1, 0b11010, "uminv">;
4876 defm SADDLV : SIMDAcrossLanesHSD<0, 0b00011, "saddlv">;
4877 defm UADDLV : SIMDAcrossLanesHSD<1, 0b00011, "uaddlv">;
4878 defm FMAXNMV : SIMDFPAcrossLanes<0b01100, 0, "fmaxnmv", int_aarch64_neon_fmaxnmv>;
4879 defm FMAXV : SIMDFPAcrossLanes<0b01111, 0, "fmaxv", int_aarch64_neon_fmaxv>;
4880 defm FMINNMV : SIMDFPAcrossLanes<0b01100, 1, "fminnmv", int_aarch64_neon_fminnmv>;
4881 defm FMINV : SIMDFPAcrossLanes<0b01111, 1, "fminv", int_aarch64_neon_fminv>;
4883 // Patterns for across-vector intrinsics, that have a node equivalent, that
4884 // returns a vector (with only the low lane defined) instead of a scalar.
4885 // In effect, opNode is the same as (scalar_to_vector (IntNode)).
4886 multiclass SIMDAcrossLanesIntrinsic<string baseOpc,
4887 SDPatternOperator opNode> {
4888 // If a lane instruction caught the vector_extract around opNode, we can
4889 // directly match the latter to the instruction.
4890 def : Pat<(v8i8 (opNode V64:$Rn)),
4891 (INSERT_SUBREG (v8i8 (IMPLICIT_DEF)),
4892 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), bsub)>;
4893 def : Pat<(v16i8 (opNode V128:$Rn)),
4894 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4895 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), bsub)>;
4896 def : Pat<(v4i16 (opNode V64:$Rn)),
4897 (INSERT_SUBREG (v4i16 (IMPLICIT_DEF)),
4898 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), hsub)>;
4899 def : Pat<(v8i16 (opNode V128:$Rn)),
4900 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)),
4901 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), hsub)>;
4902 def : Pat<(v4i32 (opNode V128:$Rn)),
4903 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)),
4904 (!cast<Instruction>(!strconcat(baseOpc, "v4i32v")) V128:$Rn), ssub)>;
4907 // If none did, fallback to the explicit patterns, consuming the vector_extract.
4908 def : Pat<(i32 (vector_extract (insert_subvector undef, (v8i8 (opNode V64:$Rn)),
4909 (i32 0)), (i64 0))),
4910 (EXTRACT_SUBREG (INSERT_SUBREG (v8i8 (IMPLICIT_DEF)),
4911 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn),
4913 def : Pat<(i32 (vector_extract (v16i8 (opNode V128:$Rn)), (i64 0))),
4914 (EXTRACT_SUBREG (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4915 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn),
4917 def : Pat<(i32 (vector_extract (insert_subvector undef,
4918 (v4i16 (opNode V64:$Rn)), (i32 0)), (i64 0))),
4919 (EXTRACT_SUBREG (INSERT_SUBREG (v4i16 (IMPLICIT_DEF)),
4920 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn),
4922 def : Pat<(i32 (vector_extract (v8i16 (opNode V128:$Rn)), (i64 0))),
4923 (EXTRACT_SUBREG (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)),
4924 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn),
4926 def : Pat<(i32 (vector_extract (v4i32 (opNode V128:$Rn)), (i64 0))),
4927 (EXTRACT_SUBREG (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)),
4928 (!cast<Instruction>(!strconcat(baseOpc, "v4i32v")) V128:$Rn),
4933 multiclass SIMDAcrossLanesSignedIntrinsic<string baseOpc,
4934 SDPatternOperator opNode>
4935 : SIMDAcrossLanesIntrinsic<baseOpc, opNode> {
4936 // If there is a sign extension after this intrinsic, consume it as smov already
4938 def : Pat<(i32 (sext_inreg (i32 (vector_extract (insert_subvector undef,
4939 (opNode (v8i8 V64:$Rn)), (i32 0)), (i64 0))), i8)),
4941 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4942 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), bsub),
4944 def : Pat<(i32 (sext_inreg (i32 (vector_extract
4945 (opNode (v16i8 V128:$Rn)), (i64 0))), i8)),
4947 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4948 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), bsub),
4950 def : Pat<(i32 (sext_inreg (i32 (vector_extract (insert_subvector undef,
4951 (opNode (v4i16 V64:$Rn)), (i32 0)), (i64 0))), i16)),
4953 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4954 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), hsub),
4956 def : Pat<(i32 (sext_inreg (i32 (vector_extract
4957 (opNode (v8i16 V128:$Rn)), (i64 0))), i16)),
4959 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4960 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), hsub),
4964 multiclass SIMDAcrossLanesUnsignedIntrinsic<string baseOpc,
4965 SDPatternOperator opNode>
4966 : SIMDAcrossLanesIntrinsic<baseOpc, opNode> {
4967 // If there is a masking operation keeping only what has been actually
4968 // generated, consume it.
4969 def : Pat<(i32 (and (i32 (vector_extract (insert_subvector undef,
4970 (opNode (v8i8 V64:$Rn)), (i32 0)), (i64 0))), maski8_or_more)),
4971 (i32 (EXTRACT_SUBREG
4972 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4973 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), bsub),
4975 def : Pat<(i32 (and (i32 (vector_extract (opNode (v16i8 V128:$Rn)), (i64 0))),
4977 (i32 (EXTRACT_SUBREG
4978 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4979 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), bsub),
4981 def : Pat<(i32 (and (i32 (vector_extract (insert_subvector undef,
4982 (opNode (v4i16 V64:$Rn)), (i32 0)), (i64 0))), maski16_or_more)),
4983 (i32 (EXTRACT_SUBREG
4984 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4985 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), hsub),
4987 def : Pat<(i32 (and (i32 (vector_extract (opNode (v8i16 V128:$Rn)), (i64 0))),
4989 (i32 (EXTRACT_SUBREG
4990 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4991 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), hsub),
4995 defm : SIMDAcrossLanesSignedIntrinsic<"ADDV", AArch64saddv>;
4996 // vaddv_[su]32 is special; -> ADDP Vd.2S,Vn.2S,Vm.2S; return Vd.s[0];Vn==Vm
4997 def : Pat<(v2i32 (AArch64saddv (v2i32 V64:$Rn))),
4998 (ADDPv2i32 V64:$Rn, V64:$Rn)>;
5000 defm : SIMDAcrossLanesUnsignedIntrinsic<"ADDV", AArch64uaddv>;
5001 // vaddv_[su]32 is special; -> ADDP Vd.2S,Vn.2S,Vm.2S; return Vd.s[0];Vn==Vm
5002 def : Pat<(v2i32 (AArch64uaddv (v2i32 V64:$Rn))),
5003 (ADDPv2i32 V64:$Rn, V64:$Rn)>;
5005 defm : SIMDAcrossLanesSignedIntrinsic<"SMAXV", AArch64smaxv>;
5006 def : Pat<(v2i32 (AArch64smaxv (v2i32 V64:$Rn))),
5007 (SMAXPv2i32 V64:$Rn, V64:$Rn)>;
5009 defm : SIMDAcrossLanesSignedIntrinsic<"SMINV", AArch64sminv>;
5010 def : Pat<(v2i32 (AArch64sminv (v2i32 V64:$Rn))),
5011 (SMINPv2i32 V64:$Rn, V64:$Rn)>;
5013 defm : SIMDAcrossLanesUnsignedIntrinsic<"UMAXV", AArch64umaxv>;
5014 def : Pat<(v2i32 (AArch64umaxv (v2i32 V64:$Rn))),
5015 (UMAXPv2i32 V64:$Rn, V64:$Rn)>;
5017 defm : SIMDAcrossLanesUnsignedIntrinsic<"UMINV", AArch64uminv>;
5018 def : Pat<(v2i32 (AArch64uminv (v2i32 V64:$Rn))),
5019 (UMINPv2i32 V64:$Rn, V64:$Rn)>;
5021 multiclass SIMDAcrossLanesSignedLongIntrinsic<string baseOpc, Intrinsic intOp> {
5022 def : Pat<(i32 (intOp (v8i8 V64:$Rn))),
5024 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5025 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), hsub),
5027 def : Pat<(i32 (intOp (v16i8 V128:$Rn))),
5029 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5030 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), hsub),
5033 def : Pat<(i32 (intOp (v4i16 V64:$Rn))),
5034 (i32 (EXTRACT_SUBREG
5035 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5036 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), ssub),
5038 def : Pat<(i32 (intOp (v8i16 V128:$Rn))),
5039 (i32 (EXTRACT_SUBREG
5040 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5041 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), ssub),
5044 def : Pat<(i64 (intOp (v4i32 V128:$Rn))),
5045 (i64 (EXTRACT_SUBREG
5046 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5047 (!cast<Instruction>(!strconcat(baseOpc, "v4i32v")) V128:$Rn), dsub),
5051 multiclass SIMDAcrossLanesUnsignedLongIntrinsic<string baseOpc,
5053 def : Pat<(i32 (intOp (v8i8 V64:$Rn))),
5054 (i32 (EXTRACT_SUBREG
5055 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5056 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), hsub),
5058 def : Pat<(i32 (intOp (v16i8 V128:$Rn))),
5059 (i32 (EXTRACT_SUBREG
5060 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5061 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), hsub),
5064 def : Pat<(i32 (intOp (v4i16 V64:$Rn))),
5065 (i32 (EXTRACT_SUBREG
5066 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5067 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), ssub),
5069 def : Pat<(i32 (intOp (v8i16 V128:$Rn))),
5070 (i32 (EXTRACT_SUBREG
5071 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5072 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), ssub),
5075 def : Pat<(i64 (intOp (v4i32 V128:$Rn))),
5076 (i64 (EXTRACT_SUBREG
5077 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5078 (!cast<Instruction>(!strconcat(baseOpc, "v4i32v")) V128:$Rn), dsub),
5082 defm : SIMDAcrossLanesSignedLongIntrinsic<"SADDLV", int_aarch64_neon_saddlv>;
5083 defm : SIMDAcrossLanesUnsignedLongIntrinsic<"UADDLV", int_aarch64_neon_uaddlv>;
5085 // The vaddlv_s32 intrinsic gets mapped to SADDLP.
5086 def : Pat<(i64 (int_aarch64_neon_saddlv (v2i32 V64:$Rn))),
5087 (i64 (EXTRACT_SUBREG
5088 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5089 (SADDLPv2i32_v1i64 V64:$Rn), dsub),
5091 // The vaddlv_u32 intrinsic gets mapped to UADDLP.
5092 def : Pat<(i64 (int_aarch64_neon_uaddlv (v2i32 V64:$Rn))),
5093 (i64 (EXTRACT_SUBREG
5094 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
5095 (UADDLPv2i32_v1i64 V64:$Rn), dsub),
5098 //------------------------------------------------------------------------------
5099 // AdvSIMD modified immediate instructions
5100 //------------------------------------------------------------------------------
5103 defm BIC : SIMDModifiedImmVectorShiftTied<1, 0b11, 0b01, "bic", AArch64bici>;
5105 defm ORR : SIMDModifiedImmVectorShiftTied<0, 0b11, 0b01, "orr", AArch64orri>;
5107 def : InstAlias<"bic $Vd.4h, $imm", (BICv4i16 V64:$Vd, imm0_255:$imm, 0)>;
5108 def : InstAlias<"bic $Vd.8h, $imm", (BICv8i16 V128:$Vd, imm0_255:$imm, 0)>;
5109 def : InstAlias<"bic $Vd.2s, $imm", (BICv2i32 V64:$Vd, imm0_255:$imm, 0)>;
5110 def : InstAlias<"bic $Vd.4s, $imm", (BICv4i32 V128:$Vd, imm0_255:$imm, 0)>;
5112 def : InstAlias<"bic.4h $Vd, $imm", (BICv4i16 V64:$Vd, imm0_255:$imm, 0)>;
5113 def : InstAlias<"bic.8h $Vd, $imm", (BICv8i16 V128:$Vd, imm0_255:$imm, 0)>;
5114 def : InstAlias<"bic.2s $Vd, $imm", (BICv2i32 V64:$Vd, imm0_255:$imm, 0)>;
5115 def : InstAlias<"bic.4s $Vd, $imm", (BICv4i32 V128:$Vd, imm0_255:$imm, 0)>;
5117 def : InstAlias<"orr $Vd.4h, $imm", (ORRv4i16 V64:$Vd, imm0_255:$imm, 0)>;
5118 def : InstAlias<"orr $Vd.8h, $imm", (ORRv8i16 V128:$Vd, imm0_255:$imm, 0)>;
5119 def : InstAlias<"orr $Vd.2s, $imm", (ORRv2i32 V64:$Vd, imm0_255:$imm, 0)>;
5120 def : InstAlias<"orr $Vd.4s, $imm", (ORRv4i32 V128:$Vd, imm0_255:$imm, 0)>;
5122 def : InstAlias<"orr.4h $Vd, $imm", (ORRv4i16 V64:$Vd, imm0_255:$imm, 0)>;
5123 def : InstAlias<"orr.8h $Vd, $imm", (ORRv8i16 V128:$Vd, imm0_255:$imm, 0)>;
5124 def : InstAlias<"orr.2s $Vd, $imm", (ORRv2i32 V64:$Vd, imm0_255:$imm, 0)>;
5125 def : InstAlias<"orr.4s $Vd, $imm", (ORRv4i32 V128:$Vd, imm0_255:$imm, 0)>;
5128 def FMOVv2f64_ns : SIMDModifiedImmVectorNoShift<1, 1, 0, 0b1111, V128, fpimm8,
5130 [(set (v2f64 V128:$Rd), (AArch64fmov imm0_255:$imm8))]>;
5131 def FMOVv2f32_ns : SIMDModifiedImmVectorNoShift<0, 0, 0, 0b1111, V64, fpimm8,
5133 [(set (v2f32 V64:$Rd), (AArch64fmov imm0_255:$imm8))]>;
5134 def FMOVv4f32_ns : SIMDModifiedImmVectorNoShift<1, 0, 0, 0b1111, V128, fpimm8,
5136 [(set (v4f32 V128:$Rd), (AArch64fmov imm0_255:$imm8))]>;
5137 let Predicates = [HasNEON, HasFullFP16] in {
5138 def FMOVv4f16_ns : SIMDModifiedImmVectorNoShift<0, 0, 1, 0b1111, V64, fpimm8,
5140 [(set (v4f16 V64:$Rd), (AArch64fmov imm0_255:$imm8))]>;
5141 def FMOVv8f16_ns : SIMDModifiedImmVectorNoShift<1, 0, 1, 0b1111, V128, fpimm8,
5143 [(set (v8f16 V128:$Rd), (AArch64fmov imm0_255:$imm8))]>;
5144 } // Predicates = [HasNEON, HasFullFP16]
5148 // EDIT byte mask: scalar
5149 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
5150 def MOVID : SIMDModifiedImmScalarNoShift<0, 1, 0b1110, "movi",
5151 [(set FPR64:$Rd, simdimmtype10:$imm8)]>;
5152 // The movi_edit node has the immediate value already encoded, so we use
5153 // a plain imm0_255 here.
5154 def : Pat<(f64 (AArch64movi_edit imm0_255:$shift)),
5155 (MOVID imm0_255:$shift)>;
5157 // EDIT byte mask: 2d
5159 // The movi_edit node has the immediate value already encoded, so we use
5160 // a plain imm0_255 in the pattern
5161 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
5162 def MOVIv2d_ns : SIMDModifiedImmVectorNoShift<1, 1, 0, 0b1110, V128,
5165 [(set (v2i64 V128:$Rd), (AArch64movi_edit imm0_255:$imm8))]>;
5167 def : Pat<(v2i64 immAllZerosV), (MOVIv2d_ns (i32 0))>;
5168 def : Pat<(v4i32 immAllZerosV), (MOVIv2d_ns (i32 0))>;
5169 def : Pat<(v8i16 immAllZerosV), (MOVIv2d_ns (i32 0))>;
5170 def : Pat<(v16i8 immAllZerosV), (MOVIv2d_ns (i32 0))>;
5172 def : Pat<(v2i64 immAllOnesV), (MOVIv2d_ns (i32 255))>;
5173 def : Pat<(v4i32 immAllOnesV), (MOVIv2d_ns (i32 255))>;
5174 def : Pat<(v8i16 immAllOnesV), (MOVIv2d_ns (i32 255))>;
5175 def : Pat<(v16i8 immAllOnesV), (MOVIv2d_ns (i32 255))>;
5177 // Set 64-bit vectors to all 0/1 by extracting from a 128-bit register as the
5178 // extract is free and this gives better MachineCSE results.
5179 def : Pat<(v1i64 immAllZerosV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 0)), dsub)>;
5180 def : Pat<(v2i32 immAllZerosV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 0)), dsub)>;
5181 def : Pat<(v4i16 immAllZerosV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 0)), dsub)>;
5182 def : Pat<(v8i8 immAllZerosV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 0)), dsub)>;
5184 def : Pat<(v1i64 immAllOnesV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 255)), dsub)>;
5185 def : Pat<(v2i32 immAllOnesV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 255)), dsub)>;
5186 def : Pat<(v4i16 immAllOnesV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 255)), dsub)>;
5187 def : Pat<(v8i8 immAllOnesV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 255)), dsub)>;
5189 // EDIT per word & halfword: 2s, 4h, 4s, & 8h
5190 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
5191 defm MOVI : SIMDModifiedImmVectorShift<0, 0b10, 0b00, "movi">;
5193 def : InstAlias<"movi $Vd.4h, $imm", (MOVIv4i16 V64:$Vd, imm0_255:$imm, 0), 0>;
5194 def : InstAlias<"movi $Vd.8h, $imm", (MOVIv8i16 V128:$Vd, imm0_255:$imm, 0), 0>;
5195 def : InstAlias<"movi $Vd.2s, $imm", (MOVIv2i32 V64:$Vd, imm0_255:$imm, 0), 0>;
5196 def : InstAlias<"movi $Vd.4s, $imm", (MOVIv4i32 V128:$Vd, imm0_255:$imm, 0), 0>;
5198 def : InstAlias<"movi.4h $Vd, $imm", (MOVIv4i16 V64:$Vd, imm0_255:$imm, 0), 0>;
5199 def : InstAlias<"movi.8h $Vd, $imm", (MOVIv8i16 V128:$Vd, imm0_255:$imm, 0), 0>;
5200 def : InstAlias<"movi.2s $Vd, $imm", (MOVIv2i32 V64:$Vd, imm0_255:$imm, 0), 0>;
5201 def : InstAlias<"movi.4s $Vd, $imm", (MOVIv4i32 V128:$Vd, imm0_255:$imm, 0), 0>;
5203 def : Pat<(v2i32 (AArch64movi_shift imm0_255:$imm8, (i32 imm:$shift))),
5204 (MOVIv2i32 imm0_255:$imm8, imm:$shift)>;
5205 def : Pat<(v4i32 (AArch64movi_shift imm0_255:$imm8, (i32 imm:$shift))),
5206 (MOVIv4i32 imm0_255:$imm8, imm:$shift)>;
5207 def : Pat<(v4i16 (AArch64movi_shift imm0_255:$imm8, (i32 imm:$shift))),
5208 (MOVIv4i16 imm0_255:$imm8, imm:$shift)>;
5209 def : Pat<(v8i16 (AArch64movi_shift imm0_255:$imm8, (i32 imm:$shift))),
5210 (MOVIv8i16 imm0_255:$imm8, imm:$shift)>;
5212 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
5213 // EDIT per word: 2s & 4s with MSL shifter
5214 def MOVIv2s_msl : SIMDModifiedImmMoveMSL<0, 0, {1,1,0,?}, V64, "movi", ".2s",
5215 [(set (v2i32 V64:$Rd),
5216 (AArch64movi_msl imm0_255:$imm8, (i32 imm:$shift)))]>;
5217 def MOVIv4s_msl : SIMDModifiedImmMoveMSL<1, 0, {1,1,0,?}, V128, "movi", ".4s",
5218 [(set (v4i32 V128:$Rd),
5219 (AArch64movi_msl imm0_255:$imm8, (i32 imm:$shift)))]>;
5221 // Per byte: 8b & 16b
5222 def MOVIv8b_ns : SIMDModifiedImmVectorNoShift<0, 0, 0, 0b1110, V64, imm0_255,
5224 [(set (v8i8 V64:$Rd), (AArch64movi imm0_255:$imm8))]>;
5226 def MOVIv16b_ns : SIMDModifiedImmVectorNoShift<1, 0, 0, 0b1110, V128, imm0_255,
5228 [(set (v16i8 V128:$Rd), (AArch64movi imm0_255:$imm8))]>;
5233 // EDIT per word & halfword: 2s, 4h, 4s, & 8h
5234 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
5235 defm MVNI : SIMDModifiedImmVectorShift<1, 0b10, 0b00, "mvni">;
5237 def : InstAlias<"mvni $Vd.4h, $imm", (MVNIv4i16 V64:$Vd, imm0_255:$imm, 0), 0>;
5238 def : InstAlias<"mvni $Vd.8h, $imm", (MVNIv8i16 V128:$Vd, imm0_255:$imm, 0), 0>;
5239 def : InstAlias<"mvni $Vd.2s, $imm", (MVNIv2i32 V64:$Vd, imm0_255:$imm, 0), 0>;
5240 def : InstAlias<"mvni $Vd.4s, $imm", (MVNIv4i32 V128:$Vd, imm0_255:$imm, 0), 0>;
5242 def : InstAlias<"mvni.4h $Vd, $imm", (MVNIv4i16 V64:$Vd, imm0_255:$imm, 0), 0>;
5243 def : InstAlias<"mvni.8h $Vd, $imm", (MVNIv8i16 V128:$Vd, imm0_255:$imm, 0), 0>;
5244 def : InstAlias<"mvni.2s $Vd, $imm", (MVNIv2i32 V64:$Vd, imm0_255:$imm, 0), 0>;
5245 def : InstAlias<"mvni.4s $Vd, $imm", (MVNIv4i32 V128:$Vd, imm0_255:$imm, 0), 0>;
5247 def : Pat<(v2i32 (AArch64mvni_shift imm0_255:$imm8, (i32 imm:$shift))),
5248 (MVNIv2i32 imm0_255:$imm8, imm:$shift)>;
5249 def : Pat<(v4i32 (AArch64mvni_shift imm0_255:$imm8, (i32 imm:$shift))),
5250 (MVNIv4i32 imm0_255:$imm8, imm:$shift)>;
5251 def : Pat<(v4i16 (AArch64mvni_shift imm0_255:$imm8, (i32 imm:$shift))),
5252 (MVNIv4i16 imm0_255:$imm8, imm:$shift)>;
5253 def : Pat<(v8i16 (AArch64mvni_shift imm0_255:$imm8, (i32 imm:$shift))),
5254 (MVNIv8i16 imm0_255:$imm8, imm:$shift)>;
5256 // EDIT per word: 2s & 4s with MSL shifter
5257 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
5258 def MVNIv2s_msl : SIMDModifiedImmMoveMSL<0, 1, {1,1,0,?}, V64, "mvni", ".2s",
5259 [(set (v2i32 V64:$Rd),
5260 (AArch64mvni_msl imm0_255:$imm8, (i32 imm:$shift)))]>;
5261 def MVNIv4s_msl : SIMDModifiedImmMoveMSL<1, 1, {1,1,0,?}, V128, "mvni", ".4s",
5262 [(set (v4i32 V128:$Rd),
5263 (AArch64mvni_msl imm0_255:$imm8, (i32 imm:$shift)))]>;
5266 //----------------------------------------------------------------------------
5267 // AdvSIMD indexed element
5268 //----------------------------------------------------------------------------
5270 let hasSideEffects = 0 in {
5271 defm FMLA : SIMDFPIndexedTied<0, 0b0001, "fmla">;
5272 defm FMLS : SIMDFPIndexedTied<0, 0b0101, "fmls">;
5275 // NOTE: Operands are reordered in the FMLA/FMLS PatFrags because the
5276 // instruction expects the addend first, while the intrinsic expects it last.
5278 // On the other hand, there are quite a few valid combinatorial options due to
5279 // the commutativity of multiplication and the fact that (-x) * y = x * (-y).
5280 defm : SIMDFPIndexedTiedPatterns<"FMLA",
5281 TriOpFrag<(fma node:$RHS, node:$MHS, node:$LHS)>>;
5282 defm : SIMDFPIndexedTiedPatterns<"FMLA",
5283 TriOpFrag<(fma node:$MHS, node:$RHS, node:$LHS)>>;
5285 defm : SIMDFPIndexedTiedPatterns<"FMLS",
5286 TriOpFrag<(fma node:$MHS, (fneg node:$RHS), node:$LHS)> >;
5287 defm : SIMDFPIndexedTiedPatterns<"FMLS",
5288 TriOpFrag<(fma node:$RHS, (fneg node:$MHS), node:$LHS)> >;
5289 defm : SIMDFPIndexedTiedPatterns<"FMLS",
5290 TriOpFrag<(fma (fneg node:$RHS), node:$MHS, node:$LHS)> >;
5291 defm : SIMDFPIndexedTiedPatterns<"FMLS",
5292 TriOpFrag<(fma (fneg node:$MHS), node:$RHS, node:$LHS)> >;
5294 multiclass FMLSIndexedAfterNegPatterns<SDPatternOperator OpNode> {
5295 // 3 variants for the .2s version: DUPLANE from 128-bit, DUPLANE from 64-bit
5297 def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn),
5298 (AArch64duplane32 (v4f32 (fneg V128:$Rm)),
5299 VectorIndexS:$idx))),
5300 (FMLSv2i32_indexed V64:$Rd, V64:$Rn, V128:$Rm, VectorIndexS:$idx)>;
5301 def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn),
5302 (v2f32 (AArch64duplane32
5303 (v4f32 (insert_subvector undef,
5304 (v2f32 (fneg V64:$Rm)),
5306 VectorIndexS:$idx)))),
5307 (FMLSv2i32_indexed V64:$Rd, V64:$Rn,
5308 (SUBREG_TO_REG (i32 0), V64:$Rm, dsub),
5309 VectorIndexS:$idx)>;
5310 def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn),
5311 (AArch64dup (f32 (fneg FPR32Op:$Rm))))),
5312 (FMLSv2i32_indexed V64:$Rd, V64:$Rn,
5313 (SUBREG_TO_REG (i32 0), FPR32Op:$Rm, ssub), (i64 0))>;
5315 // 3 variants for the .4s version: DUPLANE from 128-bit, DUPLANE from 64-bit
5317 def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn),
5318 (AArch64duplane32 (v4f32 (fneg V128:$Rm)),
5319 VectorIndexS:$idx))),
5320 (FMLSv4i32_indexed V128:$Rd, V128:$Rn, V128:$Rm,
5321 VectorIndexS:$idx)>;
5322 def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn),
5323 (v4f32 (AArch64duplane32
5324 (v4f32 (insert_subvector undef,
5325 (v2f32 (fneg V64:$Rm)),
5327 VectorIndexS:$idx)))),
5328 (FMLSv4i32_indexed V128:$Rd, V128:$Rn,
5329 (SUBREG_TO_REG (i32 0), V64:$Rm, dsub),
5330 VectorIndexS:$idx)>;
5331 def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn),
5332 (AArch64dup (f32 (fneg FPR32Op:$Rm))))),
5333 (FMLSv4i32_indexed V128:$Rd, V128:$Rn,
5334 (SUBREG_TO_REG (i32 0), FPR32Op:$Rm, ssub), (i64 0))>;
5336 // 2 variants for the .2d version: DUPLANE from 128-bit, and DUP scalar
5337 // (DUPLANE from 64-bit would be trivial).
5338 def : Pat<(v2f64 (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn),
5339 (AArch64duplane64 (v2f64 (fneg V128:$Rm)),
5340 VectorIndexD:$idx))),
5342 V128:$Rd, V128:$Rn, V128:$Rm, VectorIndexS:$idx)>;
5343 def : Pat<(v2f64 (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn),
5344 (AArch64dup (f64 (fneg FPR64Op:$Rm))))),
5345 (FMLSv2i64_indexed V128:$Rd, V128:$Rn,
5346 (SUBREG_TO_REG (i32 0), FPR64Op:$Rm, dsub), (i64 0))>;
5348 // 2 variants for 32-bit scalar version: extract from .2s or from .4s
5349 def : Pat<(f32 (OpNode (f32 FPR32:$Rd), (f32 FPR32:$Rn),
5350 (vector_extract (v4f32 (fneg V128:$Rm)),
5351 VectorIndexS:$idx))),
5352 (FMLSv1i32_indexed FPR32:$Rd, FPR32:$Rn,
5353 V128:$Rm, VectorIndexS:$idx)>;
5354 def : Pat<(f32 (OpNode (f32 FPR32:$Rd), (f32 FPR32:$Rn),
5355 (vector_extract (v4f32 (insert_subvector undef,
5356 (v2f32 (fneg V64:$Rm)),
5358 VectorIndexS:$idx))),
5359 (FMLSv1i32_indexed FPR32:$Rd, FPR32:$Rn,
5360 (SUBREG_TO_REG (i32 0), V64:$Rm, dsub), VectorIndexS:$idx)>;
5362 // 1 variant for 64-bit scalar version: extract from .1d or from .2d
5363 def : Pat<(f64 (OpNode (f64 FPR64:$Rd), (f64 FPR64:$Rn),
5364 (vector_extract (v2f64 (fneg V128:$Rm)),
5365 VectorIndexS:$idx))),
5366 (FMLSv1i64_indexed FPR64:$Rd, FPR64:$Rn,
5367 V128:$Rm, VectorIndexS:$idx)>;
5370 defm : FMLSIndexedAfterNegPatterns<
5371 TriOpFrag<(fma node:$RHS, node:$MHS, node:$LHS)> >;
5372 defm : FMLSIndexedAfterNegPatterns<
5373 TriOpFrag<(fma node:$MHS, node:$RHS, node:$LHS)> >;
5375 defm FMULX : SIMDFPIndexed<1, 0b1001, "fmulx", int_aarch64_neon_fmulx>;
5376 defm FMUL : SIMDFPIndexed<0, 0b1001, "fmul", fmul>;
5378 def : Pat<(v2f32 (fmul V64:$Rn, (AArch64dup (f32 FPR32:$Rm)))),
5379 (FMULv2i32_indexed V64:$Rn,
5380 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR32:$Rm, ssub),
5382 def : Pat<(v4f32 (fmul V128:$Rn, (AArch64dup (f32 FPR32:$Rm)))),
5383 (FMULv4i32_indexed V128:$Rn,
5384 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR32:$Rm, ssub),
5386 def : Pat<(v2f64 (fmul V128:$Rn, (AArch64dup (f64 FPR64:$Rm)))),
5387 (FMULv2i64_indexed V128:$Rn,
5388 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR64:$Rm, dsub),
5391 defm SQDMULH : SIMDIndexedHS<0, 0b1100, "sqdmulh", int_aarch64_neon_sqdmulh>;
5392 defm SQRDMULH : SIMDIndexedHS<0, 0b1101, "sqrdmulh", int_aarch64_neon_sqrdmulh>;
5393 defm MLA : SIMDVectorIndexedHSTied<1, 0b0000, "mla",
5394 TriOpFrag<(add node:$LHS, (mul node:$MHS, node:$RHS))>>;
5395 defm MLS : SIMDVectorIndexedHSTied<1, 0b0100, "mls",
5396 TriOpFrag<(sub node:$LHS, (mul node:$MHS, node:$RHS))>>;
5397 defm MUL : SIMDVectorIndexedHS<0, 0b1000, "mul", mul>;
5398 defm SMLAL : SIMDVectorIndexedLongSDTied<0, 0b0010, "smlal",
5399 TriOpFrag<(add node:$LHS, (int_aarch64_neon_smull node:$MHS, node:$RHS))>>;
5400 defm SMLSL : SIMDVectorIndexedLongSDTied<0, 0b0110, "smlsl",
5401 TriOpFrag<(sub node:$LHS, (int_aarch64_neon_smull node:$MHS, node:$RHS))>>;
5402 defm SMULL : SIMDVectorIndexedLongSD<0, 0b1010, "smull",
5403 int_aarch64_neon_smull>;
5404 defm SQDMLAL : SIMDIndexedLongSQDMLXSDTied<0, 0b0011, "sqdmlal",
5405 int_aarch64_neon_sqadd>;
5406 defm SQDMLSL : SIMDIndexedLongSQDMLXSDTied<0, 0b0111, "sqdmlsl",
5407 int_aarch64_neon_sqsub>;
5408 defm SQRDMLAH : SIMDIndexedSQRDMLxHSDTied<1, 0b1101, "sqrdmlah",
5409 int_aarch64_neon_sqadd>;
5410 defm SQRDMLSH : SIMDIndexedSQRDMLxHSDTied<1, 0b1111, "sqrdmlsh",
5411 int_aarch64_neon_sqsub>;
5412 defm SQDMULL : SIMDIndexedLongSD<0, 0b1011, "sqdmull", int_aarch64_neon_sqdmull>;
5413 defm UMLAL : SIMDVectorIndexedLongSDTied<1, 0b0010, "umlal",
5414 TriOpFrag<(add node:$LHS, (int_aarch64_neon_umull node:$MHS, node:$RHS))>>;
5415 defm UMLSL : SIMDVectorIndexedLongSDTied<1, 0b0110, "umlsl",
5416 TriOpFrag<(sub node:$LHS, (int_aarch64_neon_umull node:$MHS, node:$RHS))>>;
5417 defm UMULL : SIMDVectorIndexedLongSD<1, 0b1010, "umull",
5418 int_aarch64_neon_umull>;
5420 // A scalar sqdmull with the second operand being a vector lane can be
5421 // handled directly with the indexed instruction encoding.
5422 def : Pat<(int_aarch64_neon_sqdmulls_scalar (i32 FPR32:$Rn),
5423 (vector_extract (v4i32 V128:$Vm),
5424 VectorIndexS:$idx)),
5425 (SQDMULLv1i64_indexed FPR32:$Rn, V128:$Vm, VectorIndexS:$idx)>;
5427 //----------------------------------------------------------------------------
5428 // AdvSIMD scalar shift instructions
5429 //----------------------------------------------------------------------------
5430 defm FCVTZS : SIMDFPScalarRShift<0, 0b11111, "fcvtzs">;
5431 defm FCVTZU : SIMDFPScalarRShift<1, 0b11111, "fcvtzu">;
5432 defm SCVTF : SIMDFPScalarRShift<0, 0b11100, "scvtf">;
5433 defm UCVTF : SIMDFPScalarRShift<1, 0b11100, "ucvtf">;
5434 // Codegen patterns for the above. We don't put these directly on the
5435 // instructions because TableGen's type inference can't handle the truth.
5436 // Having the same base pattern for fp <--> int totally freaks it out.
5437 def : Pat<(int_aarch64_neon_vcvtfp2fxs FPR32:$Rn, vecshiftR32:$imm),
5438 (FCVTZSs FPR32:$Rn, vecshiftR32:$imm)>;
5439 def : Pat<(int_aarch64_neon_vcvtfp2fxu FPR32:$Rn, vecshiftR32:$imm),
5440 (FCVTZUs FPR32:$Rn, vecshiftR32:$imm)>;
5441 def : Pat<(i64 (int_aarch64_neon_vcvtfp2fxs (f64 FPR64:$Rn), vecshiftR64:$imm)),
5442 (FCVTZSd FPR64:$Rn, vecshiftR64:$imm)>;
5443 def : Pat<(i64 (int_aarch64_neon_vcvtfp2fxu (f64 FPR64:$Rn), vecshiftR64:$imm)),
5444 (FCVTZUd FPR64:$Rn, vecshiftR64:$imm)>;
5445 def : Pat<(v1i64 (int_aarch64_neon_vcvtfp2fxs (v1f64 FPR64:$Rn),
5447 (FCVTZSd FPR64:$Rn, vecshiftR64:$imm)>;
5448 def : Pat<(v1i64 (int_aarch64_neon_vcvtfp2fxu (v1f64 FPR64:$Rn),
5450 (FCVTZUd FPR64:$Rn, vecshiftR64:$imm)>;
5451 def : Pat<(int_aarch64_neon_vcvtfxu2fp FPR32:$Rn, vecshiftR32:$imm),
5452 (UCVTFs FPR32:$Rn, vecshiftR32:$imm)>;
5453 def : Pat<(f64 (int_aarch64_neon_vcvtfxu2fp (i64 FPR64:$Rn), vecshiftR64:$imm)),
5454 (UCVTFd FPR64:$Rn, vecshiftR64:$imm)>;
5455 def : Pat<(v1f64 (int_aarch64_neon_vcvtfxs2fp (v1i64 FPR64:$Rn),
5457 (SCVTFd FPR64:$Rn, vecshiftR64:$imm)>;
5458 def : Pat<(f64 (int_aarch64_neon_vcvtfxs2fp (i64 FPR64:$Rn), vecshiftR64:$imm)),
5459 (SCVTFd FPR64:$Rn, vecshiftR64:$imm)>;
5460 def : Pat<(v1f64 (int_aarch64_neon_vcvtfxu2fp (v1i64 FPR64:$Rn),
5462 (UCVTFd FPR64:$Rn, vecshiftR64:$imm)>;
5463 def : Pat<(int_aarch64_neon_vcvtfxs2fp FPR32:$Rn, vecshiftR32:$imm),
5464 (SCVTFs FPR32:$Rn, vecshiftR32:$imm)>;
5466 // Patterns for FP16 Instrinsics - requires reg copy to/from as i16s not supported.
5468 def : Pat<(f16 (int_aarch64_neon_vcvtfxs2fp (i32 (sext_inreg FPR32:$Rn, i16)), vecshiftR16:$imm)),
5469 (SCVTFh (EXTRACT_SUBREG FPR32:$Rn, hsub), vecshiftR16:$imm)>;
5470 def : Pat<(f16 (int_aarch64_neon_vcvtfxs2fp (i32 FPR32:$Rn), vecshiftR16:$imm)),
5471 (SCVTFh (EXTRACT_SUBREG FPR32:$Rn, hsub), vecshiftR16:$imm)>;
5472 def : Pat<(f16 (int_aarch64_neon_vcvtfxs2fp (i64 FPR64:$Rn), vecshiftR16:$imm)),
5473 (SCVTFh (EXTRACT_SUBREG FPR64:$Rn, hsub), vecshiftR16:$imm)>;
5474 def : Pat<(f16 (int_aarch64_neon_vcvtfxu2fp
5475 (and FPR32:$Rn, (i32 65535)),
5477 (UCVTFh (EXTRACT_SUBREG FPR32:$Rn, hsub), vecshiftR16:$imm)>;
5478 def : Pat<(f16 (int_aarch64_neon_vcvtfxu2fp FPR32:$Rn, vecshiftR16:$imm)),
5479 (UCVTFh (EXTRACT_SUBREG FPR32:$Rn, hsub), vecshiftR16:$imm)>;
5480 def : Pat<(f16 (int_aarch64_neon_vcvtfxu2fp (i64 FPR64:$Rn), vecshiftR16:$imm)),
5481 (UCVTFh (EXTRACT_SUBREG FPR64:$Rn, hsub), vecshiftR16:$imm)>;
5482 def : Pat<(i32 (int_aarch64_neon_vcvtfp2fxs (f16 FPR16:$Rn), vecshiftR32:$imm)),
5484 (i32 (IMPLICIT_DEF)),
5485 (FCVTZSh FPR16:$Rn, vecshiftR32:$imm),
5487 def : Pat<(i64 (int_aarch64_neon_vcvtfp2fxs (f16 FPR16:$Rn), vecshiftR64:$imm)),
5489 (i64 (IMPLICIT_DEF)),
5490 (FCVTZSh FPR16:$Rn, vecshiftR64:$imm),
5492 def : Pat<(i32 (int_aarch64_neon_vcvtfp2fxu (f16 FPR16:$Rn), vecshiftR32:$imm)),
5494 (i32 (IMPLICIT_DEF)),
5495 (FCVTZUh FPR16:$Rn, vecshiftR32:$imm),
5497 def : Pat<(i64 (int_aarch64_neon_vcvtfp2fxu (f16 FPR16:$Rn), vecshiftR64:$imm)),
5499 (i64 (IMPLICIT_DEF)),
5500 (FCVTZUh FPR16:$Rn, vecshiftR64:$imm),
5502 def : Pat<(i32 (int_aarch64_neon_facge (f16 FPR16:$Rn), (f16 FPR16:$Rm))),
5504 (i32 (IMPLICIT_DEF)),
5505 (FACGE16 FPR16:$Rn, FPR16:$Rm),
5507 def : Pat<(i32 (int_aarch64_neon_facgt (f16 FPR16:$Rn), (f16 FPR16:$Rm))),
5509 (i32 (IMPLICIT_DEF)),
5510 (FACGT16 FPR16:$Rn, FPR16:$Rm),
5513 defm SHL : SIMDScalarLShiftD< 0, 0b01010, "shl", AArch64vshl>;
5514 defm SLI : SIMDScalarLShiftDTied<1, 0b01010, "sli">;
5515 defm SQRSHRN : SIMDScalarRShiftBHS< 0, 0b10011, "sqrshrn",
5516 int_aarch64_neon_sqrshrn>;
5517 defm SQRSHRUN : SIMDScalarRShiftBHS< 1, 0b10001, "sqrshrun",
5518 int_aarch64_neon_sqrshrun>;
5519 defm SQSHLU : SIMDScalarLShiftBHSD<1, 0b01100, "sqshlu", AArch64sqshlui>;
5520 defm SQSHL : SIMDScalarLShiftBHSD<0, 0b01110, "sqshl", AArch64sqshli>;
5521 defm SQSHRN : SIMDScalarRShiftBHS< 0, 0b10010, "sqshrn",
5522 int_aarch64_neon_sqshrn>;
5523 defm SQSHRUN : SIMDScalarRShiftBHS< 1, 0b10000, "sqshrun",
5524 int_aarch64_neon_sqshrun>;
5525 defm SRI : SIMDScalarRShiftDTied< 1, 0b01000, "sri">;
5526 defm SRSHR : SIMDScalarRShiftD< 0, 0b00100, "srshr", AArch64srshri>;
5527 defm SRSRA : SIMDScalarRShiftDTied< 0, 0b00110, "srsra",
5528 TriOpFrag<(add node:$LHS,
5529 (AArch64srshri node:$MHS, node:$RHS))>>;
5530 defm SSHR : SIMDScalarRShiftD< 0, 0b00000, "sshr", AArch64vashr>;
5531 defm SSRA : SIMDScalarRShiftDTied< 0, 0b00010, "ssra",
5532 TriOpFrag<(add node:$LHS,
5533 (AArch64vashr node:$MHS, node:$RHS))>>;
5534 defm UQRSHRN : SIMDScalarRShiftBHS< 1, 0b10011, "uqrshrn",
5535 int_aarch64_neon_uqrshrn>;
5536 defm UQSHL : SIMDScalarLShiftBHSD<1, 0b01110, "uqshl", AArch64uqshli>;
5537 defm UQSHRN : SIMDScalarRShiftBHS< 1, 0b10010, "uqshrn",
5538 int_aarch64_neon_uqshrn>;
5539 defm URSHR : SIMDScalarRShiftD< 1, 0b00100, "urshr", AArch64urshri>;
5540 defm URSRA : SIMDScalarRShiftDTied< 1, 0b00110, "ursra",
5541 TriOpFrag<(add node:$LHS,
5542 (AArch64urshri node:$MHS, node:$RHS))>>;
5543 defm USHR : SIMDScalarRShiftD< 1, 0b00000, "ushr", AArch64vlshr>;
5544 defm USRA : SIMDScalarRShiftDTied< 1, 0b00010, "usra",
5545 TriOpFrag<(add node:$LHS,
5546 (AArch64vlshr node:$MHS, node:$RHS))>>;
5548 //----------------------------------------------------------------------------
5549 // AdvSIMD vector shift instructions
5550 //----------------------------------------------------------------------------
5551 defm FCVTZS:SIMDVectorRShiftSD<0, 0b11111, "fcvtzs", int_aarch64_neon_vcvtfp2fxs>;
5552 defm FCVTZU:SIMDVectorRShiftSD<1, 0b11111, "fcvtzu", int_aarch64_neon_vcvtfp2fxu>;
5553 defm SCVTF: SIMDVectorRShiftToFP<0, 0b11100, "scvtf",
5554 int_aarch64_neon_vcvtfxs2fp>;
5555 defm RSHRN : SIMDVectorRShiftNarrowBHS<0, 0b10001, "rshrn",
5556 int_aarch64_neon_rshrn>;
5557 defm SHL : SIMDVectorLShiftBHSD<0, 0b01010, "shl", AArch64vshl>;
5558 defm SHRN : SIMDVectorRShiftNarrowBHS<0, 0b10000, "shrn",
5559 BinOpFrag<(trunc (AArch64vashr node:$LHS, node:$RHS))>>;
5560 defm SLI : SIMDVectorLShiftBHSDTied<1, 0b01010, "sli", int_aarch64_neon_vsli>;
5561 def : Pat<(v1i64 (int_aarch64_neon_vsli (v1i64 FPR64:$Rd), (v1i64 FPR64:$Rn),
5562 (i32 vecshiftL64:$imm))),
5563 (SLId FPR64:$Rd, FPR64:$Rn, vecshiftL64:$imm)>;
5564 defm SQRSHRN : SIMDVectorRShiftNarrowBHS<0, 0b10011, "sqrshrn",
5565 int_aarch64_neon_sqrshrn>;
5566 defm SQRSHRUN: SIMDVectorRShiftNarrowBHS<1, 0b10001, "sqrshrun",
5567 int_aarch64_neon_sqrshrun>;
5568 defm SQSHLU : SIMDVectorLShiftBHSD<1, 0b01100, "sqshlu", AArch64sqshlui>;
5569 defm SQSHL : SIMDVectorLShiftBHSD<0, 0b01110, "sqshl", AArch64sqshli>;
5570 defm SQSHRN : SIMDVectorRShiftNarrowBHS<0, 0b10010, "sqshrn",
5571 int_aarch64_neon_sqshrn>;
5572 defm SQSHRUN : SIMDVectorRShiftNarrowBHS<1, 0b10000, "sqshrun",
5573 int_aarch64_neon_sqshrun>;
5574 defm SRI : SIMDVectorRShiftBHSDTied<1, 0b01000, "sri", int_aarch64_neon_vsri>;
5575 def : Pat<(v1i64 (int_aarch64_neon_vsri (v1i64 FPR64:$Rd), (v1i64 FPR64:$Rn),
5576 (i32 vecshiftR64:$imm))),
5577 (SRId FPR64:$Rd, FPR64:$Rn, vecshiftR64:$imm)>;
5578 defm SRSHR : SIMDVectorRShiftBHSD<0, 0b00100, "srshr", AArch64srshri>;
5579 defm SRSRA : SIMDVectorRShiftBHSDTied<0, 0b00110, "srsra",
5580 TriOpFrag<(add node:$LHS,
5581 (AArch64srshri node:$MHS, node:$RHS))> >;
5582 defm SSHLL : SIMDVectorLShiftLongBHSD<0, 0b10100, "sshll",
5583 BinOpFrag<(AArch64vshl (sext node:$LHS), node:$RHS)>>;
5585 defm SSHR : SIMDVectorRShiftBHSD<0, 0b00000, "sshr", AArch64vashr>;
5586 defm SSRA : SIMDVectorRShiftBHSDTied<0, 0b00010, "ssra",
5587 TriOpFrag<(add node:$LHS, (AArch64vashr node:$MHS, node:$RHS))>>;
5588 defm UCVTF : SIMDVectorRShiftToFP<1, 0b11100, "ucvtf",
5589 int_aarch64_neon_vcvtfxu2fp>;
5590 defm UQRSHRN : SIMDVectorRShiftNarrowBHS<1, 0b10011, "uqrshrn",
5591 int_aarch64_neon_uqrshrn>;
5592 defm UQSHL : SIMDVectorLShiftBHSD<1, 0b01110, "uqshl", AArch64uqshli>;
5593 defm UQSHRN : SIMDVectorRShiftNarrowBHS<1, 0b10010, "uqshrn",
5594 int_aarch64_neon_uqshrn>;
5595 defm URSHR : SIMDVectorRShiftBHSD<1, 0b00100, "urshr", AArch64urshri>;
5596 defm URSRA : SIMDVectorRShiftBHSDTied<1, 0b00110, "ursra",
5597 TriOpFrag<(add node:$LHS,
5598 (AArch64urshri node:$MHS, node:$RHS))> >;
5599 defm USHLL : SIMDVectorLShiftLongBHSD<1, 0b10100, "ushll",
5600 BinOpFrag<(AArch64vshl (zext node:$LHS), node:$RHS)>>;
5601 defm USHR : SIMDVectorRShiftBHSD<1, 0b00000, "ushr", AArch64vlshr>;
5602 defm USRA : SIMDVectorRShiftBHSDTied<1, 0b00010, "usra",
5603 TriOpFrag<(add node:$LHS, (AArch64vlshr node:$MHS, node:$RHS))> >;
5605 // SHRN patterns for when a logical right shift was used instead of arithmetic
5606 // (the immediate guarantees no sign bits actually end up in the result so it
5608 def : Pat<(v8i8 (trunc (AArch64vlshr (v8i16 V128:$Rn), vecshiftR16Narrow:$imm))),
5609 (SHRNv8i8_shift V128:$Rn, vecshiftR16Narrow:$imm)>;
5610 def : Pat<(v4i16 (trunc (AArch64vlshr (v4i32 V128:$Rn), vecshiftR32Narrow:$imm))),
5611 (SHRNv4i16_shift V128:$Rn, vecshiftR32Narrow:$imm)>;
5612 def : Pat<(v2i32 (trunc (AArch64vlshr (v2i64 V128:$Rn), vecshiftR64Narrow:$imm))),
5613 (SHRNv2i32_shift V128:$Rn, vecshiftR64Narrow:$imm)>;
5615 def : Pat<(v16i8 (concat_vectors (v8i8 V64:$Rd),
5616 (trunc (AArch64vlshr (v8i16 V128:$Rn),
5617 vecshiftR16Narrow:$imm)))),
5618 (SHRNv16i8_shift (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
5619 V128:$Rn, vecshiftR16Narrow:$imm)>;
5620 def : Pat<(v8i16 (concat_vectors (v4i16 V64:$Rd),
5621 (trunc (AArch64vlshr (v4i32 V128:$Rn),
5622 vecshiftR32Narrow:$imm)))),
5623 (SHRNv8i16_shift (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
5624 V128:$Rn, vecshiftR32Narrow:$imm)>;
5625 def : Pat<(v4i32 (concat_vectors (v2i32 V64:$Rd),
5626 (trunc (AArch64vlshr (v2i64 V128:$Rn),
5627 vecshiftR64Narrow:$imm)))),
5628 (SHRNv4i32_shift (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
5629 V128:$Rn, vecshiftR32Narrow:$imm)>;
5631 // Vector sign and zero extensions are implemented with SSHLL and USSHLL.
5632 // Anyexts are implemented as zexts.
5633 def : Pat<(v8i16 (sext (v8i8 V64:$Rn))), (SSHLLv8i8_shift V64:$Rn, (i32 0))>;
5634 def : Pat<(v8i16 (zext (v8i8 V64:$Rn))), (USHLLv8i8_shift V64:$Rn, (i32 0))>;
5635 def : Pat<(v8i16 (anyext (v8i8 V64:$Rn))), (USHLLv8i8_shift V64:$Rn, (i32 0))>;
5636 def : Pat<(v4i32 (sext (v4i16 V64:$Rn))), (SSHLLv4i16_shift V64:$Rn, (i32 0))>;
5637 def : Pat<(v4i32 (zext (v4i16 V64:$Rn))), (USHLLv4i16_shift V64:$Rn, (i32 0))>;
5638 def : Pat<(v4i32 (anyext (v4i16 V64:$Rn))), (USHLLv4i16_shift V64:$Rn, (i32 0))>;
5639 def : Pat<(v2i64 (sext (v2i32 V64:$Rn))), (SSHLLv2i32_shift V64:$Rn, (i32 0))>;
5640 def : Pat<(v2i64 (zext (v2i32 V64:$Rn))), (USHLLv2i32_shift V64:$Rn, (i32 0))>;
5641 def : Pat<(v2i64 (anyext (v2i32 V64:$Rn))), (USHLLv2i32_shift V64:$Rn, (i32 0))>;
5642 // Also match an extend from the upper half of a 128 bit source register.
5643 def : Pat<(v8i16 (anyext (v8i8 (extract_subvector V128:$Rn, (i64 8)) ))),
5644 (USHLLv16i8_shift V128:$Rn, (i32 0))>;
5645 def : Pat<(v8i16 (zext (v8i8 (extract_subvector V128:$Rn, (i64 8)) ))),
5646 (USHLLv16i8_shift V128:$Rn, (i32 0))>;
5647 def : Pat<(v8i16 (sext (v8i8 (extract_subvector V128:$Rn, (i64 8)) ))),
5648 (SSHLLv16i8_shift V128:$Rn, (i32 0))>;
5649 def : Pat<(v4i32 (anyext (v4i16 (extract_subvector V128:$Rn, (i64 4)) ))),
5650 (USHLLv8i16_shift V128:$Rn, (i32 0))>;
5651 def : Pat<(v4i32 (zext (v4i16 (extract_subvector V128:$Rn, (i64 4)) ))),
5652 (USHLLv8i16_shift V128:$Rn, (i32 0))>;
5653 def : Pat<(v4i32 (sext (v4i16 (extract_subvector V128:$Rn, (i64 4)) ))),
5654 (SSHLLv8i16_shift V128:$Rn, (i32 0))>;
5655 def : Pat<(v2i64 (anyext (v2i32 (extract_subvector V128:$Rn, (i64 2)) ))),
5656 (USHLLv4i32_shift V128:$Rn, (i32 0))>;
5657 def : Pat<(v2i64 (zext (v2i32 (extract_subvector V128:$Rn, (i64 2)) ))),
5658 (USHLLv4i32_shift V128:$Rn, (i32 0))>;
5659 def : Pat<(v2i64 (sext (v2i32 (extract_subvector V128:$Rn, (i64 2)) ))),
5660 (SSHLLv4i32_shift V128:$Rn, (i32 0))>;
5662 // Vector shift sxtl aliases
5663 def : InstAlias<"sxtl.8h $dst, $src1",
5664 (SSHLLv8i8_shift V128:$dst, V64:$src1, 0)>;
5665 def : InstAlias<"sxtl $dst.8h, $src1.8b",
5666 (SSHLLv8i8_shift V128:$dst, V64:$src1, 0)>;
5667 def : InstAlias<"sxtl.4s $dst, $src1",
5668 (SSHLLv4i16_shift V128:$dst, V64:$src1, 0)>;
5669 def : InstAlias<"sxtl $dst.4s, $src1.4h",
5670 (SSHLLv4i16_shift V128:$dst, V64:$src1, 0)>;
5671 def : InstAlias<"sxtl.2d $dst, $src1",
5672 (SSHLLv2i32_shift V128:$dst, V64:$src1, 0)>;
5673 def : InstAlias<"sxtl $dst.2d, $src1.2s",
5674 (SSHLLv2i32_shift V128:$dst, V64:$src1, 0)>;
5676 // Vector shift sxtl2 aliases
5677 def : InstAlias<"sxtl2.8h $dst, $src1",
5678 (SSHLLv16i8_shift V128:$dst, V128:$src1, 0)>;
5679 def : InstAlias<"sxtl2 $dst.8h, $src1.16b",
5680 (SSHLLv16i8_shift V128:$dst, V128:$src1, 0)>;
5681 def : InstAlias<"sxtl2.4s $dst, $src1",
5682 (SSHLLv8i16_shift V128:$dst, V128:$src1, 0)>;
5683 def : InstAlias<"sxtl2 $dst.4s, $src1.8h",
5684 (SSHLLv8i16_shift V128:$dst, V128:$src1, 0)>;
5685 def : InstAlias<"sxtl2.2d $dst, $src1",
5686 (SSHLLv4i32_shift V128:$dst, V128:$src1, 0)>;
5687 def : InstAlias<"sxtl2 $dst.2d, $src1.4s",
5688 (SSHLLv4i32_shift V128:$dst, V128:$src1, 0)>;
5690 // Vector shift uxtl aliases
5691 def : InstAlias<"uxtl.8h $dst, $src1",
5692 (USHLLv8i8_shift V128:$dst, V64:$src1, 0)>;
5693 def : InstAlias<"uxtl $dst.8h, $src1.8b",
5694 (USHLLv8i8_shift V128:$dst, V64:$src1, 0)>;
5695 def : InstAlias<"uxtl.4s $dst, $src1",
5696 (USHLLv4i16_shift V128:$dst, V64:$src1, 0)>;
5697 def : InstAlias<"uxtl $dst.4s, $src1.4h",
5698 (USHLLv4i16_shift V128:$dst, V64:$src1, 0)>;
5699 def : InstAlias<"uxtl.2d $dst, $src1",
5700 (USHLLv2i32_shift V128:$dst, V64:$src1, 0)>;
5701 def : InstAlias<"uxtl $dst.2d, $src1.2s",
5702 (USHLLv2i32_shift V128:$dst, V64:$src1, 0)>;
5704 // Vector shift uxtl2 aliases
5705 def : InstAlias<"uxtl2.8h $dst, $src1",
5706 (USHLLv16i8_shift V128:$dst, V128:$src1, 0)>;
5707 def : InstAlias<"uxtl2 $dst.8h, $src1.16b",
5708 (USHLLv16i8_shift V128:$dst, V128:$src1, 0)>;
5709 def : InstAlias<"uxtl2.4s $dst, $src1",
5710 (USHLLv8i16_shift V128:$dst, V128:$src1, 0)>;
5711 def : InstAlias<"uxtl2 $dst.4s, $src1.8h",
5712 (USHLLv8i16_shift V128:$dst, V128:$src1, 0)>;
5713 def : InstAlias<"uxtl2.2d $dst, $src1",
5714 (USHLLv4i32_shift V128:$dst, V128:$src1, 0)>;
5715 def : InstAlias<"uxtl2 $dst.2d, $src1.4s",
5716 (USHLLv4i32_shift V128:$dst, V128:$src1, 0)>;
5718 // If an integer is about to be converted to a floating point value,
5719 // just load it on the floating point unit.
5720 // These patterns are more complex because floating point loads do not
5721 // support sign extension.
5722 // The sign extension has to be explicitly added and is only supported for
5723 // one step: byte-to-half, half-to-word, word-to-doubleword.
5724 // SCVTF GPR -> FPR is 9 cycles.
5725 // SCVTF FPR -> FPR is 4 cyclces.
5726 // (sign extension with lengthen) SXTL FPR -> FPR is 2 cycles.
5727 // Therefore, we can do 2 sign extensions and one SCVTF FPR -> FPR
5728 // and still being faster.
5729 // However, this is not good for code size.
5730 // 8-bits -> float. 2 sizes step-up.
5731 class SExtLoadi8CVTf32Pat<dag addrmode, dag INST>
5732 : Pat<(f32 (sint_to_fp (i32 (sextloadi8 addrmode)))),
5733 (SCVTFv1i32 (f32 (EXTRACT_SUBREG
5738 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
5745 Requires<[NotForCodeSize, UseAlternateSExtLoadCVTF32]>;
5747 def : SExtLoadi8CVTf32Pat<(ro8.Wpat GPR64sp:$Rn, GPR32:$Rm, ro8.Wext:$ext),
5748 (LDRBroW GPR64sp:$Rn, GPR32:$Rm, ro8.Wext:$ext)>;
5749 def : SExtLoadi8CVTf32Pat<(ro8.Xpat GPR64sp:$Rn, GPR64:$Rm, ro8.Xext:$ext),
5750 (LDRBroX GPR64sp:$Rn, GPR64:$Rm, ro8.Xext:$ext)>;
5751 def : SExtLoadi8CVTf32Pat<(am_indexed8 GPR64sp:$Rn, uimm12s1:$offset),
5752 (LDRBui GPR64sp:$Rn, uimm12s1:$offset)>;
5753 def : SExtLoadi8CVTf32Pat<(am_unscaled8 GPR64sp:$Rn, simm9:$offset),
5754 (LDURBi GPR64sp:$Rn, simm9:$offset)>;
5756 // 16-bits -> float. 1 size step-up.
5757 class SExtLoadi16CVTf32Pat<dag addrmode, dag INST>
5758 : Pat<(f32 (sint_to_fp (i32 (sextloadi16 addrmode)))),
5759 (SCVTFv1i32 (f32 (EXTRACT_SUBREG
5761 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
5765 ssub)))>, Requires<[NotForCodeSize]>;
5767 def : SExtLoadi16CVTf32Pat<(ro16.Wpat GPR64sp:$Rn, GPR32:$Rm, ro16.Wext:$ext),
5768 (LDRHroW GPR64sp:$Rn, GPR32:$Rm, ro16.Wext:$ext)>;
5769 def : SExtLoadi16CVTf32Pat<(ro16.Xpat GPR64sp:$Rn, GPR64:$Rm, ro16.Xext:$ext),
5770 (LDRHroX GPR64sp:$Rn, GPR64:$Rm, ro16.Xext:$ext)>;
5771 def : SExtLoadi16CVTf32Pat<(am_indexed16 GPR64sp:$Rn, uimm12s2:$offset),
5772 (LDRHui GPR64sp:$Rn, uimm12s2:$offset)>;
5773 def : SExtLoadi16CVTf32Pat<(am_unscaled16 GPR64sp:$Rn, simm9:$offset),
5774 (LDURHi GPR64sp:$Rn, simm9:$offset)>;
5776 // 32-bits to 32-bits are handled in target specific dag combine:
5777 // performIntToFpCombine.
5778 // 64-bits integer to 32-bits floating point, not possible with
5779 // SCVTF on floating point registers (both source and destination
5780 // must have the same size).
5782 // Here are the patterns for 8, 16, 32, and 64-bits to double.
5783 // 8-bits -> double. 3 size step-up: give up.
5784 // 16-bits -> double. 2 size step.
5785 class SExtLoadi16CVTf64Pat<dag addrmode, dag INST>
5786 : Pat <(f64 (sint_to_fp (i32 (sextloadi16 addrmode)))),
5787 (SCVTFv1i64 (f64 (EXTRACT_SUBREG
5792 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
5799 Requires<[NotForCodeSize, UseAlternateSExtLoadCVTF32]>;
5801 def : SExtLoadi16CVTf64Pat<(ro16.Wpat GPR64sp:$Rn, GPR32:$Rm, ro16.Wext:$ext),
5802 (LDRHroW GPR64sp:$Rn, GPR32:$Rm, ro16.Wext:$ext)>;
5803 def : SExtLoadi16CVTf64Pat<(ro16.Xpat GPR64sp:$Rn, GPR64:$Rm, ro16.Xext:$ext),
5804 (LDRHroX GPR64sp:$Rn, GPR64:$Rm, ro16.Xext:$ext)>;
5805 def : SExtLoadi16CVTf64Pat<(am_indexed16 GPR64sp:$Rn, uimm12s2:$offset),
5806 (LDRHui GPR64sp:$Rn, uimm12s2:$offset)>;
5807 def : SExtLoadi16CVTf64Pat<(am_unscaled16 GPR64sp:$Rn, simm9:$offset),
5808 (LDURHi GPR64sp:$Rn, simm9:$offset)>;
5809 // 32-bits -> double. 1 size step-up.
5810 class SExtLoadi32CVTf64Pat<dag addrmode, dag INST>
5811 : Pat <(f64 (sint_to_fp (i32 (load addrmode)))),
5812 (SCVTFv1i64 (f64 (EXTRACT_SUBREG
5814 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
5818 dsub)))>, Requires<[NotForCodeSize]>;
5820 def : SExtLoadi32CVTf64Pat<(ro32.Wpat GPR64sp:$Rn, GPR32:$Rm, ro32.Wext:$ext),
5821 (LDRSroW GPR64sp:$Rn, GPR32:$Rm, ro32.Wext:$ext)>;
5822 def : SExtLoadi32CVTf64Pat<(ro32.Xpat GPR64sp:$Rn, GPR64:$Rm, ro32.Xext:$ext),
5823 (LDRSroX GPR64sp:$Rn, GPR64:$Rm, ro32.Xext:$ext)>;
5824 def : SExtLoadi32CVTf64Pat<(am_indexed32 GPR64sp:$Rn, uimm12s4:$offset),
5825 (LDRSui GPR64sp:$Rn, uimm12s4:$offset)>;
5826 def : SExtLoadi32CVTf64Pat<(am_unscaled32 GPR64sp:$Rn, simm9:$offset),
5827 (LDURSi GPR64sp:$Rn, simm9:$offset)>;
5829 // 64-bits -> double are handled in target specific dag combine:
5830 // performIntToFpCombine.
5833 //----------------------------------------------------------------------------
5834 // AdvSIMD Load-Store Structure
5835 //----------------------------------------------------------------------------
5836 defm LD1 : SIMDLd1Multiple<"ld1">;
5837 defm LD2 : SIMDLd2Multiple<"ld2">;
5838 defm LD3 : SIMDLd3Multiple<"ld3">;
5839 defm LD4 : SIMDLd4Multiple<"ld4">;
5841 defm ST1 : SIMDSt1Multiple<"st1">;
5842 defm ST2 : SIMDSt2Multiple<"st2">;
5843 defm ST3 : SIMDSt3Multiple<"st3">;
5844 defm ST4 : SIMDSt4Multiple<"st4">;
5846 class Ld1Pat<ValueType ty, Instruction INST>
5847 : Pat<(ty (load GPR64sp:$Rn)), (INST GPR64sp:$Rn)>;
5849 def : Ld1Pat<v16i8, LD1Onev16b>;
5850 def : Ld1Pat<v8i16, LD1Onev8h>;
5851 def : Ld1Pat<v4i32, LD1Onev4s>;
5852 def : Ld1Pat<v2i64, LD1Onev2d>;
5853 def : Ld1Pat<v8i8, LD1Onev8b>;
5854 def : Ld1Pat<v4i16, LD1Onev4h>;
5855 def : Ld1Pat<v2i32, LD1Onev2s>;
5856 def : Ld1Pat<v1i64, LD1Onev1d>;
5858 class St1Pat<ValueType ty, Instruction INST>
5859 : Pat<(store ty:$Vt, GPR64sp:$Rn),
5860 (INST ty:$Vt, GPR64sp:$Rn)>;
5862 def : St1Pat<v16i8, ST1Onev16b>;
5863 def : St1Pat<v8i16, ST1Onev8h>;
5864 def : St1Pat<v4i32, ST1Onev4s>;
5865 def : St1Pat<v2i64, ST1Onev2d>;
5866 def : St1Pat<v8i8, ST1Onev8b>;
5867 def : St1Pat<v4i16, ST1Onev4h>;
5868 def : St1Pat<v2i32, ST1Onev2s>;
5869 def : St1Pat<v1i64, ST1Onev1d>;
5875 defm LD1R : SIMDLdR<0, 0b110, 0, "ld1r", "One", 1, 2, 4, 8>;
5876 defm LD2R : SIMDLdR<1, 0b110, 0, "ld2r", "Two", 2, 4, 8, 16>;
5877 defm LD3R : SIMDLdR<0, 0b111, 0, "ld3r", "Three", 3, 6, 12, 24>;
5878 defm LD4R : SIMDLdR<1, 0b111, 0, "ld4r", "Four", 4, 8, 16, 32>;
5879 let mayLoad = 1, hasSideEffects = 0 in {
5880 defm LD1 : SIMDLdSingleBTied<0, 0b000, "ld1", VecListOneb, GPR64pi1>;
5881 defm LD1 : SIMDLdSingleHTied<0, 0b010, 0, "ld1", VecListOneh, GPR64pi2>;
5882 defm LD1 : SIMDLdSingleSTied<0, 0b100, 0b00, "ld1", VecListOnes, GPR64pi4>;
5883 defm LD1 : SIMDLdSingleDTied<0, 0b100, 0b01, "ld1", VecListOned, GPR64pi8>;
5884 defm LD2 : SIMDLdSingleBTied<1, 0b000, "ld2", VecListTwob, GPR64pi2>;
5885 defm LD2 : SIMDLdSingleHTied<1, 0b010, 0, "ld2", VecListTwoh, GPR64pi4>;
5886 defm LD2 : SIMDLdSingleSTied<1, 0b100, 0b00, "ld2", VecListTwos, GPR64pi8>;
5887 defm LD2 : SIMDLdSingleDTied<1, 0b100, 0b01, "ld2", VecListTwod, GPR64pi16>;
5888 defm LD3 : SIMDLdSingleBTied<0, 0b001, "ld3", VecListThreeb, GPR64pi3>;
5889 defm LD3 : SIMDLdSingleHTied<0, 0b011, 0, "ld3", VecListThreeh, GPR64pi6>;
5890 defm LD3 : SIMDLdSingleSTied<0, 0b101, 0b00, "ld3", VecListThrees, GPR64pi12>;
5891 defm LD3 : SIMDLdSingleDTied<0, 0b101, 0b01, "ld3", VecListThreed, GPR64pi24>;
5892 defm LD4 : SIMDLdSingleBTied<1, 0b001, "ld4", VecListFourb, GPR64pi4>;
5893 defm LD4 : SIMDLdSingleHTied<1, 0b011, 0, "ld4", VecListFourh, GPR64pi8>;
5894 defm LD4 : SIMDLdSingleSTied<1, 0b101, 0b00, "ld4", VecListFours, GPR64pi16>;
5895 defm LD4 : SIMDLdSingleDTied<1, 0b101, 0b01, "ld4", VecListFourd, GPR64pi32>;
5898 def : Pat<(v8i8 (AArch64dup (i32 (extloadi8 GPR64sp:$Rn)))),
5899 (LD1Rv8b GPR64sp:$Rn)>;
5900 def : Pat<(v16i8 (AArch64dup (i32 (extloadi8 GPR64sp:$Rn)))),
5901 (LD1Rv16b GPR64sp:$Rn)>;
5902 def : Pat<(v4i16 (AArch64dup (i32 (extloadi16 GPR64sp:$Rn)))),
5903 (LD1Rv4h GPR64sp:$Rn)>;
5904 def : Pat<(v8i16 (AArch64dup (i32 (extloadi16 GPR64sp:$Rn)))),
5905 (LD1Rv8h GPR64sp:$Rn)>;
5906 def : Pat<(v2i32 (AArch64dup (i32 (load GPR64sp:$Rn)))),
5907 (LD1Rv2s GPR64sp:$Rn)>;
5908 def : Pat<(v4i32 (AArch64dup (i32 (load GPR64sp:$Rn)))),
5909 (LD1Rv4s GPR64sp:$Rn)>;
5910 def : Pat<(v2i64 (AArch64dup (i64 (load GPR64sp:$Rn)))),
5911 (LD1Rv2d GPR64sp:$Rn)>;
5912 def : Pat<(v1i64 (AArch64dup (i64 (load GPR64sp:$Rn)))),
5913 (LD1Rv1d GPR64sp:$Rn)>;
5914 // Grab the floating point version too
5915 def : Pat<(v2f32 (AArch64dup (f32 (load GPR64sp:$Rn)))),
5916 (LD1Rv2s GPR64sp:$Rn)>;
5917 def : Pat<(v4f32 (AArch64dup (f32 (load GPR64sp:$Rn)))),
5918 (LD1Rv4s GPR64sp:$Rn)>;
5919 def : Pat<(v2f64 (AArch64dup (f64 (load GPR64sp:$Rn)))),
5920 (LD1Rv2d GPR64sp:$Rn)>;
5921 def : Pat<(v1f64 (AArch64dup (f64 (load GPR64sp:$Rn)))),
5922 (LD1Rv1d GPR64sp:$Rn)>;
5923 def : Pat<(v4f16 (AArch64dup (f16 (load GPR64sp:$Rn)))),
5924 (LD1Rv4h GPR64sp:$Rn)>;
5925 def : Pat<(v8f16 (AArch64dup (f16 (load GPR64sp:$Rn)))),
5926 (LD1Rv8h GPR64sp:$Rn)>;
5928 class Ld1Lane128Pat<SDPatternOperator scalar_load, Operand VecIndex,
5929 ValueType VTy, ValueType STy, Instruction LD1>
5930 : Pat<(vector_insert (VTy VecListOne128:$Rd),
5931 (STy (scalar_load GPR64sp:$Rn)), VecIndex:$idx),
5932 (LD1 VecListOne128:$Rd, VecIndex:$idx, GPR64sp:$Rn)>;
5934 def : Ld1Lane128Pat<extloadi8, VectorIndexB, v16i8, i32, LD1i8>;
5935 def : Ld1Lane128Pat<extloadi16, VectorIndexH, v8i16, i32, LD1i16>;
5936 def : Ld1Lane128Pat<load, VectorIndexS, v4i32, i32, LD1i32>;
5937 def : Ld1Lane128Pat<load, VectorIndexS, v4f32, f32, LD1i32>;
5938 def : Ld1Lane128Pat<load, VectorIndexD, v2i64, i64, LD1i64>;
5939 def : Ld1Lane128Pat<load, VectorIndexD, v2f64, f64, LD1i64>;
5940 def : Ld1Lane128Pat<load, VectorIndexH, v8f16, f16, LD1i16>;
5942 class Ld1Lane64Pat<SDPatternOperator scalar_load, Operand VecIndex,
5943 ValueType VTy, ValueType STy, Instruction LD1>
5944 : Pat<(vector_insert (VTy VecListOne64:$Rd),
5945 (STy (scalar_load GPR64sp:$Rn)), VecIndex:$idx),
5947 (LD1 (SUBREG_TO_REG (i32 0), VecListOne64:$Rd, dsub),
5948 VecIndex:$idx, GPR64sp:$Rn),
5951 def : Ld1Lane64Pat<extloadi8, VectorIndexB, v8i8, i32, LD1i8>;
5952 def : Ld1Lane64Pat<extloadi16, VectorIndexH, v4i16, i32, LD1i16>;
5953 def : Ld1Lane64Pat<load, VectorIndexS, v2i32, i32, LD1i32>;
5954 def : Ld1Lane64Pat<load, VectorIndexS, v2f32, f32, LD1i32>;
5955 def : Ld1Lane64Pat<load, VectorIndexH, v4f16, f16, LD1i16>;
5958 defm LD1 : SIMDLdSt1SingleAliases<"ld1">;
5959 defm LD2 : SIMDLdSt2SingleAliases<"ld2">;
5960 defm LD3 : SIMDLdSt3SingleAliases<"ld3">;
5961 defm LD4 : SIMDLdSt4SingleAliases<"ld4">;
5964 defm ST1 : SIMDStSingleB<0, 0b000, "st1", VecListOneb, GPR64pi1>;
5965 defm ST1 : SIMDStSingleH<0, 0b010, 0, "st1", VecListOneh, GPR64pi2>;
5966 defm ST1 : SIMDStSingleS<0, 0b100, 0b00, "st1", VecListOnes, GPR64pi4>;
5967 defm ST1 : SIMDStSingleD<0, 0b100, 0b01, "st1", VecListOned, GPR64pi8>;
5969 let AddedComplexity = 19 in
5970 class St1Lane128Pat<SDPatternOperator scalar_store, Operand VecIndex,
5971 ValueType VTy, ValueType STy, Instruction ST1>
5973 (STy (vector_extract (VTy VecListOne128:$Vt), VecIndex:$idx)),
5975 (ST1 VecListOne128:$Vt, VecIndex:$idx, GPR64sp:$Rn)>;
5977 def : St1Lane128Pat<truncstorei8, VectorIndexB, v16i8, i32, ST1i8>;
5978 def : St1Lane128Pat<truncstorei16, VectorIndexH, v8i16, i32, ST1i16>;
5979 def : St1Lane128Pat<store, VectorIndexS, v4i32, i32, ST1i32>;
5980 def : St1Lane128Pat<store, VectorIndexS, v4f32, f32, ST1i32>;
5981 def : St1Lane128Pat<store, VectorIndexD, v2i64, i64, ST1i64>;
5982 def : St1Lane128Pat<store, VectorIndexD, v2f64, f64, ST1i64>;
5983 def : St1Lane128Pat<store, VectorIndexH, v8f16, f16, ST1i16>;
5985 let AddedComplexity = 19 in
5986 class St1Lane64Pat<SDPatternOperator scalar_store, Operand VecIndex,
5987 ValueType VTy, ValueType STy, Instruction ST1>
5989 (STy (vector_extract (VTy VecListOne64:$Vt), VecIndex:$idx)),
5991 (ST1 (SUBREG_TO_REG (i32 0), VecListOne64:$Vt, dsub),
5992 VecIndex:$idx, GPR64sp:$Rn)>;
5994 def : St1Lane64Pat<truncstorei8, VectorIndexB, v8i8, i32, ST1i8>;
5995 def : St1Lane64Pat<truncstorei16, VectorIndexH, v4i16, i32, ST1i16>;
5996 def : St1Lane64Pat<store, VectorIndexS, v2i32, i32, ST1i32>;
5997 def : St1Lane64Pat<store, VectorIndexS, v2f32, f32, ST1i32>;
5998 def : St1Lane64Pat<store, VectorIndexH, v4f16, f16, ST1i16>;
6000 multiclass St1LanePost64Pat<SDPatternOperator scalar_store, Operand VecIndex,
6001 ValueType VTy, ValueType STy, Instruction ST1,
6003 def : Pat<(scalar_store
6004 (STy (vector_extract (VTy VecListOne64:$Vt), VecIndex:$idx)),
6005 GPR64sp:$Rn, offset),
6006 (ST1 (SUBREG_TO_REG (i32 0), VecListOne64:$Vt, dsub),
6007 VecIndex:$idx, GPR64sp:$Rn, XZR)>;
6009 def : Pat<(scalar_store
6010 (STy (vector_extract (VTy VecListOne64:$Vt), VecIndex:$idx)),
6011 GPR64sp:$Rn, GPR64:$Rm),
6012 (ST1 (SUBREG_TO_REG (i32 0), VecListOne64:$Vt, dsub),
6013 VecIndex:$idx, GPR64sp:$Rn, $Rm)>;
6016 defm : St1LanePost64Pat<post_truncsti8, VectorIndexB, v8i8, i32, ST1i8_POST, 1>;
6017 defm : St1LanePost64Pat<post_truncsti16, VectorIndexH, v4i16, i32, ST1i16_POST,
6019 defm : St1LanePost64Pat<post_store, VectorIndexS, v2i32, i32, ST1i32_POST, 4>;
6020 defm : St1LanePost64Pat<post_store, VectorIndexS, v2f32, f32, ST1i32_POST, 4>;
6021 defm : St1LanePost64Pat<post_store, VectorIndexD, v1i64, i64, ST1i64_POST, 8>;
6022 defm : St1LanePost64Pat<post_store, VectorIndexD, v1f64, f64, ST1i64_POST, 8>;
6023 defm : St1LanePost64Pat<post_store, VectorIndexH, v4f16, f16, ST1i16_POST, 2>;
6025 multiclass St1LanePost128Pat<SDPatternOperator scalar_store, Operand VecIndex,
6026 ValueType VTy, ValueType STy, Instruction ST1,
6028 def : Pat<(scalar_store
6029 (STy (vector_extract (VTy VecListOne128:$Vt), VecIndex:$idx)),
6030 GPR64sp:$Rn, offset),
6031 (ST1 VecListOne128:$Vt, VecIndex:$idx, GPR64sp:$Rn, XZR)>;
6033 def : Pat<(scalar_store
6034 (STy (vector_extract (VTy VecListOne128:$Vt), VecIndex:$idx)),
6035 GPR64sp:$Rn, GPR64:$Rm),
6036 (ST1 VecListOne128:$Vt, VecIndex:$idx, GPR64sp:$Rn, $Rm)>;
6039 defm : St1LanePost128Pat<post_truncsti8, VectorIndexB, v16i8, i32, ST1i8_POST,
6041 defm : St1LanePost128Pat<post_truncsti16, VectorIndexH, v8i16, i32, ST1i16_POST,
6043 defm : St1LanePost128Pat<post_store, VectorIndexS, v4i32, i32, ST1i32_POST, 4>;
6044 defm : St1LanePost128Pat<post_store, VectorIndexS, v4f32, f32, ST1i32_POST, 4>;
6045 defm : St1LanePost128Pat<post_store, VectorIndexD, v2i64, i64, ST1i64_POST, 8>;
6046 defm : St1LanePost128Pat<post_store, VectorIndexD, v2f64, f64, ST1i64_POST, 8>;
6047 defm : St1LanePost128Pat<post_store, VectorIndexH, v8f16, f16, ST1i16_POST, 2>;
6049 let mayStore = 1, hasSideEffects = 0 in {
6050 defm ST2 : SIMDStSingleB<1, 0b000, "st2", VecListTwob, GPR64pi2>;
6051 defm ST2 : SIMDStSingleH<1, 0b010, 0, "st2", VecListTwoh, GPR64pi4>;
6052 defm ST2 : SIMDStSingleS<1, 0b100, 0b00, "st2", VecListTwos, GPR64pi8>;
6053 defm ST2 : SIMDStSingleD<1, 0b100, 0b01, "st2", VecListTwod, GPR64pi16>;
6054 defm ST3 : SIMDStSingleB<0, 0b001, "st3", VecListThreeb, GPR64pi3>;
6055 defm ST3 : SIMDStSingleH<0, 0b011, 0, "st3", VecListThreeh, GPR64pi6>;
6056 defm ST3 : SIMDStSingleS<0, 0b101, 0b00, "st3", VecListThrees, GPR64pi12>;
6057 defm ST3 : SIMDStSingleD<0, 0b101, 0b01, "st3", VecListThreed, GPR64pi24>;
6058 defm ST4 : SIMDStSingleB<1, 0b001, "st4", VecListFourb, GPR64pi4>;
6059 defm ST4 : SIMDStSingleH<1, 0b011, 0, "st4", VecListFourh, GPR64pi8>;
6060 defm ST4 : SIMDStSingleS<1, 0b101, 0b00, "st4", VecListFours, GPR64pi16>;
6061 defm ST4 : SIMDStSingleD<1, 0b101, 0b01, "st4", VecListFourd, GPR64pi32>;
6064 defm ST1 : SIMDLdSt1SingleAliases<"st1">;
6065 defm ST2 : SIMDLdSt2SingleAliases<"st2">;
6066 defm ST3 : SIMDLdSt3SingleAliases<"st3">;
6067 defm ST4 : SIMDLdSt4SingleAliases<"st4">;
6069 //----------------------------------------------------------------------------
6070 // Crypto extensions
6071 //----------------------------------------------------------------------------
6073 let Predicates = [HasAES] in {
6074 def AESErr : AESTiedInst<0b0100, "aese", int_aarch64_crypto_aese>;
6075 def AESDrr : AESTiedInst<0b0101, "aesd", int_aarch64_crypto_aesd>;
6076 def AESMCrr : AESInst< 0b0110, "aesmc", int_aarch64_crypto_aesmc>;
6077 def AESIMCrr : AESInst< 0b0111, "aesimc", int_aarch64_crypto_aesimc>;
6080 // Pseudo instructions for AESMCrr/AESIMCrr with a register constraint required
6081 // for AES fusion on some CPUs.
6082 let hasSideEffects = 0, mayStore = 0, mayLoad = 0 in {
6083 def AESMCrrTied: Pseudo<(outs V128:$Rd), (ins V128:$Rn), [], "$Rn = $Rd">,
6085 def AESIMCrrTied: Pseudo<(outs V128:$Rd), (ins V128:$Rn), [], "$Rn = $Rd">,
6089 // Only use constrained versions of AES(I)MC instructions if they are paired with
6091 def : Pat<(v16i8 (int_aarch64_crypto_aesmc
6092 (v16i8 (int_aarch64_crypto_aese (v16i8 V128:$src1),
6093 (v16i8 V128:$src2))))),
6094 (v16i8 (AESMCrrTied (v16i8 (AESErr (v16i8 V128:$src1),
6095 (v16i8 V128:$src2)))))>,
6096 Requires<[HasFuseAES]>;
6098 def : Pat<(v16i8 (int_aarch64_crypto_aesimc
6099 (v16i8 (int_aarch64_crypto_aesd (v16i8 V128:$src1),
6100 (v16i8 V128:$src2))))),
6101 (v16i8 (AESIMCrrTied (v16i8 (AESDrr (v16i8 V128:$src1),
6102 (v16i8 V128:$src2)))))>,
6103 Requires<[HasFuseAES]>;
6105 let Predicates = [HasSHA2] in {
6106 def SHA1Crrr : SHATiedInstQSV<0b000, "sha1c", int_aarch64_crypto_sha1c>;
6107 def SHA1Prrr : SHATiedInstQSV<0b001, "sha1p", int_aarch64_crypto_sha1p>;
6108 def SHA1Mrrr : SHATiedInstQSV<0b010, "sha1m", int_aarch64_crypto_sha1m>;
6109 def SHA1SU0rrr : SHATiedInstVVV<0b011, "sha1su0", int_aarch64_crypto_sha1su0>;
6110 def SHA256Hrrr : SHATiedInstQQV<0b100, "sha256h", int_aarch64_crypto_sha256h>;
6111 def SHA256H2rrr : SHATiedInstQQV<0b101, "sha256h2",int_aarch64_crypto_sha256h2>;
6112 def SHA256SU1rrr :SHATiedInstVVV<0b110, "sha256su1",int_aarch64_crypto_sha256su1>;
6114 def SHA1Hrr : SHAInstSS< 0b0000, "sha1h", int_aarch64_crypto_sha1h>;
6115 def SHA1SU1rr : SHATiedInstVV<0b0001, "sha1su1", int_aarch64_crypto_sha1su1>;
6116 def SHA256SU0rr : SHATiedInstVV<0b0010, "sha256su0",int_aarch64_crypto_sha256su0>;
6119 //----------------------------------------------------------------------------
6121 //----------------------------------------------------------------------------
6122 // FIXME: Like for X86, these should go in their own separate .td file.
6124 def def32 : PatLeaf<(i32 GPR32:$src), [{
6128 // In the case of a 32-bit def that is known to implicitly zero-extend,
6129 // we can use a SUBREG_TO_REG.
6130 def : Pat<(i64 (zext def32:$src)), (SUBREG_TO_REG (i64 0), GPR32:$src, sub_32)>;
6132 // For an anyext, we don't care what the high bits are, so we can perform an
6133 // INSERT_SUBREF into an IMPLICIT_DEF.
6134 def : Pat<(i64 (anyext GPR32:$src)),
6135 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GPR32:$src, sub_32)>;
6137 // When we need to explicitly zero-extend, we use a 32-bit MOV instruction and
6138 // then assert the extension has happened.
6139 def : Pat<(i64 (zext GPR32:$src)),
6140 (SUBREG_TO_REG (i32 0), (ORRWrs WZR, GPR32:$src, 0), sub_32)>;
6142 // To sign extend, we use a signed bitfield move instruction (SBFM) on the
6143 // containing super-reg.
6144 def : Pat<(i64 (sext GPR32:$src)),
6145 (SBFMXri (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GPR32:$src, sub_32), 0, 31)>;
6146 def : Pat<(i64 (sext_inreg GPR64:$src, i32)), (SBFMXri GPR64:$src, 0, 31)>;
6147 def : Pat<(i64 (sext_inreg GPR64:$src, i16)), (SBFMXri GPR64:$src, 0, 15)>;
6148 def : Pat<(i64 (sext_inreg GPR64:$src, i8)), (SBFMXri GPR64:$src, 0, 7)>;
6149 def : Pat<(i64 (sext_inreg GPR64:$src, i1)), (SBFMXri GPR64:$src, 0, 0)>;
6150 def : Pat<(i32 (sext_inreg GPR32:$src, i16)), (SBFMWri GPR32:$src, 0, 15)>;
6151 def : Pat<(i32 (sext_inreg GPR32:$src, i8)), (SBFMWri GPR32:$src, 0, 7)>;
6152 def : Pat<(i32 (sext_inreg GPR32:$src, i1)), (SBFMWri GPR32:$src, 0, 0)>;
6154 def : Pat<(shl (sext_inreg GPR32:$Rn, i8), (i64 imm0_31:$imm)),
6155 (SBFMWri GPR32:$Rn, (i64 (i32shift_a imm0_31:$imm)),
6156 (i64 (i32shift_sext_i8 imm0_31:$imm)))>;
6157 def : Pat<(shl (sext_inreg GPR64:$Rn, i8), (i64 imm0_63:$imm)),
6158 (SBFMXri GPR64:$Rn, (i64 (i64shift_a imm0_63:$imm)),
6159 (i64 (i64shift_sext_i8 imm0_63:$imm)))>;
6161 def : Pat<(shl (sext_inreg GPR32:$Rn, i16), (i64 imm0_31:$imm)),
6162 (SBFMWri GPR32:$Rn, (i64 (i32shift_a imm0_31:$imm)),
6163 (i64 (i32shift_sext_i16 imm0_31:$imm)))>;
6164 def : Pat<(shl (sext_inreg GPR64:$Rn, i16), (i64 imm0_63:$imm)),
6165 (SBFMXri GPR64:$Rn, (i64 (i64shift_a imm0_63:$imm)),
6166 (i64 (i64shift_sext_i16 imm0_63:$imm)))>;
6168 def : Pat<(shl (i64 (sext GPR32:$Rn)), (i64 imm0_63:$imm)),
6169 (SBFMXri (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GPR32:$Rn, sub_32),
6170 (i64 (i64shift_a imm0_63:$imm)),
6171 (i64 (i64shift_sext_i32 imm0_63:$imm)))>;
6173 // sra patterns have an AddedComplexity of 10, so make sure we have a higher
6174 // AddedComplexity for the following patterns since we want to match sext + sra
6175 // patterns before we attempt to match a single sra node.
6176 let AddedComplexity = 20 in {
6177 // We support all sext + sra combinations which preserve at least one bit of the
6178 // original value which is to be sign extended. E.g. we support shifts up to
6180 def : Pat<(sra (sext_inreg GPR32:$Rn, i8), (i64 imm0_7:$imm)),
6181 (SBFMWri GPR32:$Rn, (i64 imm0_7:$imm), 7)>;
6182 def : Pat<(sra (sext_inreg GPR64:$Rn, i8), (i64 imm0_7:$imm)),
6183 (SBFMXri GPR64:$Rn, (i64 imm0_7:$imm), 7)>;
6185 def : Pat<(sra (sext_inreg GPR32:$Rn, i16), (i64 imm0_15:$imm)),
6186 (SBFMWri GPR32:$Rn, (i64 imm0_15:$imm), 15)>;
6187 def : Pat<(sra (sext_inreg GPR64:$Rn, i16), (i64 imm0_15:$imm)),
6188 (SBFMXri GPR64:$Rn, (i64 imm0_15:$imm), 15)>;
6190 def : Pat<(sra (i64 (sext GPR32:$Rn)), (i64 imm0_31:$imm)),
6191 (SBFMXri (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GPR32:$Rn, sub_32),
6192 (i64 imm0_31:$imm), 31)>;
6193 } // AddedComplexity = 20
6195 // To truncate, we can simply extract from a subregister.
6196 def : Pat<(i32 (trunc GPR64sp:$src)),
6197 (i32 (EXTRACT_SUBREG GPR64sp:$src, sub_32))>;
6199 // __builtin_trap() uses the BRK instruction on AArch64.
6200 def : Pat<(trap), (BRK 1)>;
6201 def : Pat<(debugtrap), (BRK 0xF000)>, Requires<[IsWindows]>;
6203 // Multiply high patterns which multiply the lower subvector using smull/umull
6204 // and the upper subvector with smull2/umull2. Then shuffle the high the high
6205 // part of both results together.
6206 def : Pat<(v16i8 (mulhs V128:$Rn, V128:$Rm)),
6208 (SMULLv8i8_v8i16 (EXTRACT_SUBREG V128:$Rn, dsub),
6209 (EXTRACT_SUBREG V128:$Rm, dsub)),
6210 (SMULLv16i8_v8i16 V128:$Rn, V128:$Rm))>;
6211 def : Pat<(v8i16 (mulhs V128:$Rn, V128:$Rm)),
6213 (SMULLv4i16_v4i32 (EXTRACT_SUBREG V128:$Rn, dsub),
6214 (EXTRACT_SUBREG V128:$Rm, dsub)),
6215 (SMULLv8i16_v4i32 V128:$Rn, V128:$Rm))>;
6216 def : Pat<(v4i32 (mulhs V128:$Rn, V128:$Rm)),
6218 (SMULLv2i32_v2i64 (EXTRACT_SUBREG V128:$Rn, dsub),
6219 (EXTRACT_SUBREG V128:$Rm, dsub)),
6220 (SMULLv4i32_v2i64 V128:$Rn, V128:$Rm))>;
6222 def : Pat<(v16i8 (mulhu V128:$Rn, V128:$Rm)),
6224 (UMULLv8i8_v8i16 (EXTRACT_SUBREG V128:$Rn, dsub),
6225 (EXTRACT_SUBREG V128:$Rm, dsub)),
6226 (UMULLv16i8_v8i16 V128:$Rn, V128:$Rm))>;
6227 def : Pat<(v8i16 (mulhu V128:$Rn, V128:$Rm)),
6229 (UMULLv4i16_v4i32 (EXTRACT_SUBREG V128:$Rn, dsub),
6230 (EXTRACT_SUBREG V128:$Rm, dsub)),
6231 (UMULLv8i16_v4i32 V128:$Rn, V128:$Rm))>;
6232 def : Pat<(v4i32 (mulhu V128:$Rn, V128:$Rm)),
6234 (UMULLv2i32_v2i64 (EXTRACT_SUBREG V128:$Rn, dsub),
6235 (EXTRACT_SUBREG V128:$Rm, dsub)),
6236 (UMULLv4i32_v2i64 V128:$Rn, V128:$Rm))>;
6238 // Conversions within AdvSIMD types in the same register size are free.
6239 // But because we need a consistent lane ordering, in big endian many
6240 // conversions require one or more REV instructions.
6242 // Consider a simple memory load followed by a bitconvert then a store.
6244 // v1 = BITCAST v2i32 v0 to v4i16
6247 // In big endian mode every memory access has an implicit byte swap. LDR and
6248 // STR do a 64-bit byte swap, whereas LD1/ST1 do a byte swap per lane - that
6249 // is, they treat the vector as a sequence of elements to be byte-swapped.
6250 // The two pairs of instructions are fundamentally incompatible. We've decided
6251 // to use LD1/ST1 only to simplify compiler implementation.
6253 // LD1/ST1 perform the equivalent of a sequence of LDR/STR + REV. This makes
6254 // the original code sequence:
6256 // v1 = REV v2i32 (implicit)
6257 // v2 = BITCAST v2i32 v1 to v4i16
6258 // v3 = REV v4i16 v2 (implicit)
6261 // But this is now broken - the value stored is different to the value loaded
6262 // due to lane reordering. To fix this, on every BITCAST we must perform two
6265 // v1 = REV v2i32 (implicit)
6267 // v3 = BITCAST v2i32 v2 to v4i16
6269 // v5 = REV v4i16 v4 (implicit)
6272 // This means an extra two instructions, but actually in most cases the two REV
6273 // instructions can be combined into one. For example:
6274 // (REV64_2s (REV64_4h X)) === (REV32_4h X)
6276 // There is also no 128-bit REV instruction. This must be synthesized with an
6279 // Most bitconverts require some sort of conversion. The only exceptions are:
6280 // a) Identity conversions - vNfX <-> vNiX
6281 // b) Single-lane-to-scalar - v1fX <-> fX or v1iX <-> iX
6284 // Natural vector casts (64 bit)
6285 def : Pat<(v8i8 (AArch64NvCast (v2i32 FPR64:$src))), (v8i8 FPR64:$src)>;
6286 def : Pat<(v4i16 (AArch64NvCast (v2i32 FPR64:$src))), (v4i16 FPR64:$src)>;
6287 def : Pat<(v4f16 (AArch64NvCast (v2i32 FPR64:$src))), (v4f16 FPR64:$src)>;
6288 def : Pat<(v2i32 (AArch64NvCast (v2i32 FPR64:$src))), (v2i32 FPR64:$src)>;
6289 def : Pat<(v2f32 (AArch64NvCast (v2i32 FPR64:$src))), (v2f32 FPR64:$src)>;
6290 def : Pat<(v1i64 (AArch64NvCast (v2i32 FPR64:$src))), (v1i64 FPR64:$src)>;
6292 def : Pat<(v8i8 (AArch64NvCast (v4i16 FPR64:$src))), (v8i8 FPR64:$src)>;
6293 def : Pat<(v4i16 (AArch64NvCast (v4i16 FPR64:$src))), (v4i16 FPR64:$src)>;
6294 def : Pat<(v4f16 (AArch64NvCast (v4i16 FPR64:$src))), (v4f16 FPR64:$src)>;
6295 def : Pat<(v2i32 (AArch64NvCast (v4i16 FPR64:$src))), (v2i32 FPR64:$src)>;
6296 def : Pat<(v1i64 (AArch64NvCast (v4i16 FPR64:$src))), (v1i64 FPR64:$src)>;
6298 def : Pat<(v8i8 (AArch64NvCast (v8i8 FPR64:$src))), (v8i8 FPR64:$src)>;
6299 def : Pat<(v4i16 (AArch64NvCast (v8i8 FPR64:$src))), (v4i16 FPR64:$src)>;
6300 def : Pat<(v4f16 (AArch64NvCast (v8i8 FPR64:$src))), (v4f16 FPR64:$src)>;
6301 def : Pat<(v2i32 (AArch64NvCast (v8i8 FPR64:$src))), (v2i32 FPR64:$src)>;
6302 def : Pat<(v2f32 (AArch64NvCast (v8i8 FPR64:$src))), (v2f32 FPR64:$src)>;
6303 def : Pat<(v1i64 (AArch64NvCast (v8i8 FPR64:$src))), (v1i64 FPR64:$src)>;
6305 def : Pat<(v8i8 (AArch64NvCast (f64 FPR64:$src))), (v8i8 FPR64:$src)>;
6306 def : Pat<(v4i16 (AArch64NvCast (f64 FPR64:$src))), (v4i16 FPR64:$src)>;
6307 def : Pat<(v4f16 (AArch64NvCast (f64 FPR64:$src))), (v4f16 FPR64:$src)>;
6308 def : Pat<(v2i32 (AArch64NvCast (f64 FPR64:$src))), (v2i32 FPR64:$src)>;
6309 def : Pat<(v2f32 (AArch64NvCast (f64 FPR64:$src))), (v2f32 FPR64:$src)>;
6310 def : Pat<(v1i64 (AArch64NvCast (f64 FPR64:$src))), (v1i64 FPR64:$src)>;
6311 def : Pat<(v1f64 (AArch64NvCast (f64 FPR64:$src))), (v1f64 FPR64:$src)>;
6313 def : Pat<(v8i8 (AArch64NvCast (v2f32 FPR64:$src))), (v8i8 FPR64:$src)>;
6314 def : Pat<(v4i16 (AArch64NvCast (v2f32 FPR64:$src))), (v4i16 FPR64:$src)>;
6315 def : Pat<(v2i32 (AArch64NvCast (v2f32 FPR64:$src))), (v2i32 FPR64:$src)>;
6316 def : Pat<(v2f32 (AArch64NvCast (v2f32 FPR64:$src))), (v2f32 FPR64:$src)>;
6317 def : Pat<(v1i64 (AArch64NvCast (v2f32 FPR64:$src))), (v1i64 FPR64:$src)>;
6318 def : Pat<(v1f64 (AArch64NvCast (v2f32 FPR64:$src))), (v1f64 FPR64:$src)>;
6320 // Natural vector casts (128 bit)
6321 def : Pat<(v16i8 (AArch64NvCast (v4i32 FPR128:$src))), (v16i8 FPR128:$src)>;
6322 def : Pat<(v8i16 (AArch64NvCast (v4i32 FPR128:$src))), (v8i16 FPR128:$src)>;
6323 def : Pat<(v8f16 (AArch64NvCast (v4i32 FPR128:$src))), (v8f16 FPR128:$src)>;
6324 def : Pat<(v4i32 (AArch64NvCast (v4i32 FPR128:$src))), (v4i32 FPR128:$src)>;
6325 def : Pat<(v4f32 (AArch64NvCast (v4i32 FPR128:$src))), (v4f32 FPR128:$src)>;
6326 def : Pat<(v2i64 (AArch64NvCast (v4i32 FPR128:$src))), (v2i64 FPR128:$src)>;
6327 def : Pat<(v2f64 (AArch64NvCast (v4i32 FPR128:$src))), (v2f64 FPR128:$src)>;
6329 def : Pat<(v16i8 (AArch64NvCast (v8i16 FPR128:$src))), (v16i8 FPR128:$src)>;
6330 def : Pat<(v8i16 (AArch64NvCast (v8i16 FPR128:$src))), (v8i16 FPR128:$src)>;
6331 def : Pat<(v8f16 (AArch64NvCast (v8i16 FPR128:$src))), (v8f16 FPR128:$src)>;
6332 def : Pat<(v4i32 (AArch64NvCast (v8i16 FPR128:$src))), (v4i32 FPR128:$src)>;
6333 def : Pat<(v2i64 (AArch64NvCast (v8i16 FPR128:$src))), (v2i64 FPR128:$src)>;
6334 def : Pat<(v4f32 (AArch64NvCast (v8i16 FPR128:$src))), (v4f32 FPR128:$src)>;
6335 def : Pat<(v2f64 (AArch64NvCast (v8i16 FPR128:$src))), (v2f64 FPR128:$src)>;
6337 def : Pat<(v16i8 (AArch64NvCast (v16i8 FPR128:$src))), (v16i8 FPR128:$src)>;
6338 def : Pat<(v8i16 (AArch64NvCast (v16i8 FPR128:$src))), (v8i16 FPR128:$src)>;
6339 def : Pat<(v8f16 (AArch64NvCast (v16i8 FPR128:$src))), (v8f16 FPR128:$src)>;
6340 def : Pat<(v4i32 (AArch64NvCast (v16i8 FPR128:$src))), (v4i32 FPR128:$src)>;
6341 def : Pat<(v2i64 (AArch64NvCast (v16i8 FPR128:$src))), (v2i64 FPR128:$src)>;
6342 def : Pat<(v4f32 (AArch64NvCast (v16i8 FPR128:$src))), (v4f32 FPR128:$src)>;
6343 def : Pat<(v2f64 (AArch64NvCast (v16i8 FPR128:$src))), (v2f64 FPR128:$src)>;
6345 def : Pat<(v16i8 (AArch64NvCast (v2i64 FPR128:$src))), (v16i8 FPR128:$src)>;
6346 def : Pat<(v8i16 (AArch64NvCast (v2i64 FPR128:$src))), (v8i16 FPR128:$src)>;
6347 def : Pat<(v8f16 (AArch64NvCast (v2i64 FPR128:$src))), (v8f16 FPR128:$src)>;
6348 def : Pat<(v4i32 (AArch64NvCast (v2i64 FPR128:$src))), (v4i32 FPR128:$src)>;
6349 def : Pat<(v2i64 (AArch64NvCast (v2i64 FPR128:$src))), (v2i64 FPR128:$src)>;
6350 def : Pat<(v4f32 (AArch64NvCast (v2i64 FPR128:$src))), (v4f32 FPR128:$src)>;
6351 def : Pat<(v2f64 (AArch64NvCast (v2i64 FPR128:$src))), (v2f64 FPR128:$src)>;
6353 def : Pat<(v16i8 (AArch64NvCast (v4f32 FPR128:$src))), (v16i8 FPR128:$src)>;
6354 def : Pat<(v8i16 (AArch64NvCast (v4f32 FPR128:$src))), (v8i16 FPR128:$src)>;
6355 def : Pat<(v4i32 (AArch64NvCast (v4f32 FPR128:$src))), (v4i32 FPR128:$src)>;
6356 def : Pat<(v4f32 (AArch64NvCast (v4f32 FPR128:$src))), (v4f32 FPR128:$src)>;
6357 def : Pat<(v2i64 (AArch64NvCast (v4f32 FPR128:$src))), (v2i64 FPR128:$src)>;
6358 def : Pat<(v8f16 (AArch64NvCast (v4f32 FPR128:$src))), (v8f16 FPR128:$src)>;
6359 def : Pat<(v2f64 (AArch64NvCast (v4f32 FPR128:$src))), (v2f64 FPR128:$src)>;
6361 def : Pat<(v16i8 (AArch64NvCast (v2f64 FPR128:$src))), (v16i8 FPR128:$src)>;
6362 def : Pat<(v8i16 (AArch64NvCast (v2f64 FPR128:$src))), (v8i16 FPR128:$src)>;
6363 def : Pat<(v4i32 (AArch64NvCast (v2f64 FPR128:$src))), (v4i32 FPR128:$src)>;
6364 def : Pat<(v2i64 (AArch64NvCast (v2f64 FPR128:$src))), (v2i64 FPR128:$src)>;
6365 def : Pat<(v2f64 (AArch64NvCast (v2f64 FPR128:$src))), (v2f64 FPR128:$src)>;
6366 def : Pat<(v8f16 (AArch64NvCast (v2f64 FPR128:$src))), (v8f16 FPR128:$src)>;
6367 def : Pat<(v4f32 (AArch64NvCast (v2f64 FPR128:$src))), (v4f32 FPR128:$src)>;
6369 let Predicates = [IsLE] in {
6370 def : Pat<(v8i8 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6371 def : Pat<(v4i16 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6372 def : Pat<(v2i32 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6373 def : Pat<(v4f16 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6374 def : Pat<(v2f32 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6376 def : Pat<(i64 (bitconvert (v8i8 V64:$Vn))),
6377 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6378 def : Pat<(i64 (bitconvert (v4i16 V64:$Vn))),
6379 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6380 def : Pat<(i64 (bitconvert (v2i32 V64:$Vn))),
6381 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6382 def : Pat<(i64 (bitconvert (v4f16 V64:$Vn))),
6383 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6384 def : Pat<(i64 (bitconvert (v2f32 V64:$Vn))),
6385 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6386 def : Pat<(i64 (bitconvert (v1f64 V64:$Vn))),
6387 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6389 let Predicates = [IsBE] in {
6390 def : Pat<(v8i8 (bitconvert GPR64:$Xn)),
6391 (REV64v8i8 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
6392 def : Pat<(v4i16 (bitconvert GPR64:$Xn)),
6393 (REV64v4i16 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
6394 def : Pat<(v2i32 (bitconvert GPR64:$Xn)),
6395 (REV64v2i32 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
6396 def : Pat<(v4f16 (bitconvert GPR64:$Xn)),
6397 (REV64v4i16 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
6398 def : Pat<(v2f32 (bitconvert GPR64:$Xn)),
6399 (REV64v2i32 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
6401 def : Pat<(i64 (bitconvert (v8i8 V64:$Vn))),
6402 (REV64v8i8 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
6403 def : Pat<(i64 (bitconvert (v4i16 V64:$Vn))),
6404 (REV64v4i16 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
6405 def : Pat<(i64 (bitconvert (v2i32 V64:$Vn))),
6406 (REV64v2i32 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
6407 def : Pat<(i64 (bitconvert (v4f16 V64:$Vn))),
6408 (REV64v4i16 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
6409 def : Pat<(i64 (bitconvert (v2f32 V64:$Vn))),
6410 (REV64v2i32 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
6412 def : Pat<(v1i64 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6413 def : Pat<(v1f64 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6414 def : Pat<(i64 (bitconvert (v1i64 V64:$Vn))),
6415 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6416 def : Pat<(v1i64 (scalar_to_vector GPR64:$Xn)),
6417 (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6418 def : Pat<(v1f64 (scalar_to_vector GPR64:$Xn)),
6419 (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6420 def : Pat<(v1f64 (scalar_to_vector (f64 FPR64:$Xn))), (v1f64 FPR64:$Xn)>;
6422 def : Pat<(f32 (bitconvert (i32 GPR32:$Xn))),
6423 (COPY_TO_REGCLASS GPR32:$Xn, FPR32)>;
6424 def : Pat<(i32 (bitconvert (f32 FPR32:$Xn))),
6425 (COPY_TO_REGCLASS FPR32:$Xn, GPR32)>;
6426 def : Pat<(f64 (bitconvert (i64 GPR64:$Xn))),
6427 (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6428 def : Pat<(i64 (bitconvert (f64 FPR64:$Xn))),
6429 (COPY_TO_REGCLASS FPR64:$Xn, GPR64)>;
6430 def : Pat<(i64 (bitconvert (v1f64 V64:$Vn))),
6431 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6433 let Predicates = [IsLE] in {
6434 def : Pat<(v1i64 (bitconvert (v2i32 FPR64:$src))), (v1i64 FPR64:$src)>;
6435 def : Pat<(v1i64 (bitconvert (v4i16 FPR64:$src))), (v1i64 FPR64:$src)>;
6436 def : Pat<(v1i64 (bitconvert (v8i8 FPR64:$src))), (v1i64 FPR64:$src)>;
6437 def : Pat<(v1i64 (bitconvert (v4f16 FPR64:$src))), (v1i64 FPR64:$src)>;
6438 def : Pat<(v1i64 (bitconvert (v2f32 FPR64:$src))), (v1i64 FPR64:$src)>;
6440 let Predicates = [IsBE] in {
6441 def : Pat<(v1i64 (bitconvert (v2i32 FPR64:$src))),
6442 (v1i64 (REV64v2i32 FPR64:$src))>;
6443 def : Pat<(v1i64 (bitconvert (v4i16 FPR64:$src))),
6444 (v1i64 (REV64v4i16 FPR64:$src))>;
6445 def : Pat<(v1i64 (bitconvert (v8i8 FPR64:$src))),
6446 (v1i64 (REV64v8i8 FPR64:$src))>;
6447 def : Pat<(v1i64 (bitconvert (v4f16 FPR64:$src))),
6448 (v1i64 (REV64v4i16 FPR64:$src))>;
6449 def : Pat<(v1i64 (bitconvert (v2f32 FPR64:$src))),
6450 (v1i64 (REV64v2i32 FPR64:$src))>;
6452 def : Pat<(v1i64 (bitconvert (v1f64 FPR64:$src))), (v1i64 FPR64:$src)>;
6453 def : Pat<(v1i64 (bitconvert (f64 FPR64:$src))), (v1i64 FPR64:$src)>;
6455 let Predicates = [IsLE] in {
6456 def : Pat<(v2i32 (bitconvert (v1i64 FPR64:$src))), (v2i32 FPR64:$src)>;
6457 def : Pat<(v2i32 (bitconvert (v4i16 FPR64:$src))), (v2i32 FPR64:$src)>;
6458 def : Pat<(v2i32 (bitconvert (v8i8 FPR64:$src))), (v2i32 FPR64:$src)>;
6459 def : Pat<(v2i32 (bitconvert (f64 FPR64:$src))), (v2i32 FPR64:$src)>;
6460 def : Pat<(v2i32 (bitconvert (v1f64 FPR64:$src))), (v2i32 FPR64:$src)>;
6461 def : Pat<(v2i32 (bitconvert (v4f16 FPR64:$src))), (v2i32 FPR64:$src)>;
6463 let Predicates = [IsBE] in {
6464 def : Pat<(v2i32 (bitconvert (v1i64 FPR64:$src))),
6465 (v2i32 (REV64v2i32 FPR64:$src))>;
6466 def : Pat<(v2i32 (bitconvert (v4i16 FPR64:$src))),
6467 (v2i32 (REV32v4i16 FPR64:$src))>;
6468 def : Pat<(v2i32 (bitconvert (v8i8 FPR64:$src))),
6469 (v2i32 (REV32v8i8 FPR64:$src))>;
6470 def : Pat<(v2i32 (bitconvert (f64 FPR64:$src))),
6471 (v2i32 (REV64v2i32 FPR64:$src))>;
6472 def : Pat<(v2i32 (bitconvert (v1f64 FPR64:$src))),
6473 (v2i32 (REV64v2i32 FPR64:$src))>;
6474 def : Pat<(v2i32 (bitconvert (v4f16 FPR64:$src))),
6475 (v2i32 (REV32v4i16 FPR64:$src))>;
6477 def : Pat<(v2i32 (bitconvert (v2f32 FPR64:$src))), (v2i32 FPR64:$src)>;
6479 let Predicates = [IsLE] in {
6480 def : Pat<(v4i16 (bitconvert (v1i64 FPR64:$src))), (v4i16 FPR64:$src)>;
6481 def : Pat<(v4i16 (bitconvert (v2i32 FPR64:$src))), (v4i16 FPR64:$src)>;
6482 def : Pat<(v4i16 (bitconvert (v8i8 FPR64:$src))), (v4i16 FPR64:$src)>;
6483 def : Pat<(v4i16 (bitconvert (f64 FPR64:$src))), (v4i16 FPR64:$src)>;
6484 def : Pat<(v4i16 (bitconvert (v2f32 FPR64:$src))), (v4i16 FPR64:$src)>;
6485 def : Pat<(v4i16 (bitconvert (v1f64 FPR64:$src))), (v4i16 FPR64:$src)>;
6487 let Predicates = [IsBE] in {
6488 def : Pat<(v4i16 (bitconvert (v1i64 FPR64:$src))),
6489 (v4i16 (REV64v4i16 FPR64:$src))>;
6490 def : Pat<(v4i16 (bitconvert (v2i32 FPR64:$src))),
6491 (v4i16 (REV32v4i16 FPR64:$src))>;
6492 def : Pat<(v4i16 (bitconvert (v8i8 FPR64:$src))),
6493 (v4i16 (REV16v8i8 FPR64:$src))>;
6494 def : Pat<(v4i16 (bitconvert (f64 FPR64:$src))),
6495 (v4i16 (REV64v4i16 FPR64:$src))>;
6496 def : Pat<(v4i16 (bitconvert (v2f32 FPR64:$src))),
6497 (v4i16 (REV32v4i16 FPR64:$src))>;
6498 def : Pat<(v4i16 (bitconvert (v1f64 FPR64:$src))),
6499 (v4i16 (REV64v4i16 FPR64:$src))>;
6501 def : Pat<(v4i16 (bitconvert (v4f16 FPR64:$src))), (v4i16 FPR64:$src)>;
6503 let Predicates = [IsLE] in {
6504 def : Pat<(v4f16 (bitconvert (v1i64 FPR64:$src))), (v4f16 FPR64:$src)>;
6505 def : Pat<(v4f16 (bitconvert (v2i32 FPR64:$src))), (v4f16 FPR64:$src)>;
6506 def : Pat<(v4f16 (bitconvert (v8i8 FPR64:$src))), (v4f16 FPR64:$src)>;
6507 def : Pat<(v4f16 (bitconvert (f64 FPR64:$src))), (v4f16 FPR64:$src)>;
6508 def : Pat<(v4f16 (bitconvert (v2f32 FPR64:$src))), (v4f16 FPR64:$src)>;
6509 def : Pat<(v4f16 (bitconvert (v1f64 FPR64:$src))), (v4f16 FPR64:$src)>;
6511 let Predicates = [IsBE] in {
6512 def : Pat<(v4f16 (bitconvert (v1i64 FPR64:$src))),
6513 (v4f16 (REV64v4i16 FPR64:$src))>;
6514 def : Pat<(v4f16 (bitconvert (v2i32 FPR64:$src))),
6515 (v4f16 (REV32v4i16 FPR64:$src))>;
6516 def : Pat<(v4f16 (bitconvert (v8i8 FPR64:$src))),
6517 (v4f16 (REV16v8i8 FPR64:$src))>;
6518 def : Pat<(v4f16 (bitconvert (f64 FPR64:$src))),
6519 (v4f16 (REV64v4i16 FPR64:$src))>;
6520 def : Pat<(v4f16 (bitconvert (v2f32 FPR64:$src))),
6521 (v4f16 (REV32v4i16 FPR64:$src))>;
6522 def : Pat<(v4f16 (bitconvert (v1f64 FPR64:$src))),
6523 (v4f16 (REV64v4i16 FPR64:$src))>;
6525 def : Pat<(v4f16 (bitconvert (v4i16 FPR64:$src))), (v4f16 FPR64:$src)>;
6527 let Predicates = [IsLE] in {
6528 def : Pat<(v8i8 (bitconvert (v1i64 FPR64:$src))), (v8i8 FPR64:$src)>;
6529 def : Pat<(v8i8 (bitconvert (v2i32 FPR64:$src))), (v8i8 FPR64:$src)>;
6530 def : Pat<(v8i8 (bitconvert (v4i16 FPR64:$src))), (v8i8 FPR64:$src)>;
6531 def : Pat<(v8i8 (bitconvert (f64 FPR64:$src))), (v8i8 FPR64:$src)>;
6532 def : Pat<(v8i8 (bitconvert (v2f32 FPR64:$src))), (v8i8 FPR64:$src)>;
6533 def : Pat<(v8i8 (bitconvert (v1f64 FPR64:$src))), (v8i8 FPR64:$src)>;
6534 def : Pat<(v8i8 (bitconvert (v4f16 FPR64:$src))), (v8i8 FPR64:$src)>;
6536 let Predicates = [IsBE] in {
6537 def : Pat<(v8i8 (bitconvert (v1i64 FPR64:$src))),
6538 (v8i8 (REV64v8i8 FPR64:$src))>;
6539 def : Pat<(v8i8 (bitconvert (v2i32 FPR64:$src))),
6540 (v8i8 (REV32v8i8 FPR64:$src))>;
6541 def : Pat<(v8i8 (bitconvert (v4i16 FPR64:$src))),
6542 (v8i8 (REV16v8i8 FPR64:$src))>;
6543 def : Pat<(v8i8 (bitconvert (f64 FPR64:$src))),
6544 (v8i8 (REV64v8i8 FPR64:$src))>;
6545 def : Pat<(v8i8 (bitconvert (v2f32 FPR64:$src))),
6546 (v8i8 (REV32v8i8 FPR64:$src))>;
6547 def : Pat<(v8i8 (bitconvert (v1f64 FPR64:$src))),
6548 (v8i8 (REV64v8i8 FPR64:$src))>;
6549 def : Pat<(v8i8 (bitconvert (v4f16 FPR64:$src))),
6550 (v8i8 (REV16v8i8 FPR64:$src))>;
6553 let Predicates = [IsLE] in {
6554 def : Pat<(f64 (bitconvert (v2i32 FPR64:$src))), (f64 FPR64:$src)>;
6555 def : Pat<(f64 (bitconvert (v4i16 FPR64:$src))), (f64 FPR64:$src)>;
6556 def : Pat<(f64 (bitconvert (v2f32 FPR64:$src))), (f64 FPR64:$src)>;
6557 def : Pat<(f64 (bitconvert (v8i8 FPR64:$src))), (f64 FPR64:$src)>;
6558 def : Pat<(f64 (bitconvert (v4f16 FPR64:$src))), (f64 FPR64:$src)>;
6560 let Predicates = [IsBE] in {
6561 def : Pat<(f64 (bitconvert (v2i32 FPR64:$src))),
6562 (f64 (REV64v2i32 FPR64:$src))>;
6563 def : Pat<(f64 (bitconvert (v4i16 FPR64:$src))),
6564 (f64 (REV64v4i16 FPR64:$src))>;
6565 def : Pat<(f64 (bitconvert (v2f32 FPR64:$src))),
6566 (f64 (REV64v2i32 FPR64:$src))>;
6567 def : Pat<(f64 (bitconvert (v8i8 FPR64:$src))),
6568 (f64 (REV64v8i8 FPR64:$src))>;
6569 def : Pat<(f64 (bitconvert (v4f16 FPR64:$src))),
6570 (f64 (REV64v4i16 FPR64:$src))>;
6572 def : Pat<(f64 (bitconvert (v1i64 FPR64:$src))), (f64 FPR64:$src)>;
6573 def : Pat<(f64 (bitconvert (v1f64 FPR64:$src))), (f64 FPR64:$src)>;
6575 let Predicates = [IsLE] in {
6576 def : Pat<(v1f64 (bitconvert (v2i32 FPR64:$src))), (v1f64 FPR64:$src)>;
6577 def : Pat<(v1f64 (bitconvert (v4i16 FPR64:$src))), (v1f64 FPR64:$src)>;
6578 def : Pat<(v1f64 (bitconvert (v8i8 FPR64:$src))), (v1f64 FPR64:$src)>;
6579 def : Pat<(v1f64 (bitconvert (v2f32 FPR64:$src))), (v1f64 FPR64:$src)>;
6580 def : Pat<(v1f64 (bitconvert (v4f16 FPR64:$src))), (v1f64 FPR64:$src)>;
6582 let Predicates = [IsBE] in {
6583 def : Pat<(v1f64 (bitconvert (v2i32 FPR64:$src))),
6584 (v1f64 (REV64v2i32 FPR64:$src))>;
6585 def : Pat<(v1f64 (bitconvert (v4i16 FPR64:$src))),
6586 (v1f64 (REV64v4i16 FPR64:$src))>;
6587 def : Pat<(v1f64 (bitconvert (v8i8 FPR64:$src))),
6588 (v1f64 (REV64v8i8 FPR64:$src))>;
6589 def : Pat<(v1f64 (bitconvert (v2f32 FPR64:$src))),
6590 (v1f64 (REV64v2i32 FPR64:$src))>;
6591 def : Pat<(v1f64 (bitconvert (v4f16 FPR64:$src))),
6592 (v1f64 (REV64v4i16 FPR64:$src))>;
6594 def : Pat<(v1f64 (bitconvert (v1i64 FPR64:$src))), (v1f64 FPR64:$src)>;
6595 def : Pat<(v1f64 (bitconvert (f64 FPR64:$src))), (v1f64 FPR64:$src)>;
6597 let Predicates = [IsLE] in {
6598 def : Pat<(v2f32 (bitconvert (v1i64 FPR64:$src))), (v2f32 FPR64:$src)>;
6599 def : Pat<(v2f32 (bitconvert (v4i16 FPR64:$src))), (v2f32 FPR64:$src)>;
6600 def : Pat<(v2f32 (bitconvert (v8i8 FPR64:$src))), (v2f32 FPR64:$src)>;
6601 def : Pat<(v2f32 (bitconvert (v1f64 FPR64:$src))), (v2f32 FPR64:$src)>;
6602 def : Pat<(v2f32 (bitconvert (f64 FPR64:$src))), (v2f32 FPR64:$src)>;
6603 def : Pat<(v2f32 (bitconvert (v4f16 FPR64:$src))), (v2f32 FPR64:$src)>;
6605 let Predicates = [IsBE] in {
6606 def : Pat<(v2f32 (bitconvert (v1i64 FPR64:$src))),
6607 (v2f32 (REV64v2i32 FPR64:$src))>;
6608 def : Pat<(v2f32 (bitconvert (v4i16 FPR64:$src))),
6609 (v2f32 (REV32v4i16 FPR64:$src))>;
6610 def : Pat<(v2f32 (bitconvert (v8i8 FPR64:$src))),
6611 (v2f32 (REV32v8i8 FPR64:$src))>;
6612 def : Pat<(v2f32 (bitconvert (v1f64 FPR64:$src))),
6613 (v2f32 (REV64v2i32 FPR64:$src))>;
6614 def : Pat<(v2f32 (bitconvert (f64 FPR64:$src))),
6615 (v2f32 (REV64v2i32 FPR64:$src))>;
6616 def : Pat<(v2f32 (bitconvert (v4f16 FPR64:$src))),
6617 (v2f32 (REV32v4i16 FPR64:$src))>;
6619 def : Pat<(v2f32 (bitconvert (v2i32 FPR64:$src))), (v2f32 FPR64:$src)>;
6621 let Predicates = [IsLE] in {
6622 def : Pat<(f128 (bitconvert (v2i64 FPR128:$src))), (f128 FPR128:$src)>;
6623 def : Pat<(f128 (bitconvert (v4i32 FPR128:$src))), (f128 FPR128:$src)>;
6624 def : Pat<(f128 (bitconvert (v8i16 FPR128:$src))), (f128 FPR128:$src)>;
6625 def : Pat<(f128 (bitconvert (v2f64 FPR128:$src))), (f128 FPR128:$src)>;
6626 def : Pat<(f128 (bitconvert (v4f32 FPR128:$src))), (f128 FPR128:$src)>;
6627 def : Pat<(f128 (bitconvert (v8f16 FPR128:$src))), (f128 FPR128:$src)>;
6628 def : Pat<(f128 (bitconvert (v16i8 FPR128:$src))), (f128 FPR128:$src)>;
6630 let Predicates = [IsBE] in {
6631 def : Pat<(f128 (bitconvert (v2i64 FPR128:$src))),
6632 (f128 (EXTv16i8 FPR128:$src, FPR128:$src, (i32 8)))>;
6633 def : Pat<(f128 (bitconvert (v4i32 FPR128:$src))),
6634 (f128 (EXTv16i8 (REV64v4i32 FPR128:$src),
6635 (REV64v4i32 FPR128:$src), (i32 8)))>;
6636 def : Pat<(f128 (bitconvert (v8i16 FPR128:$src))),
6637 (f128 (EXTv16i8 (REV64v8i16 FPR128:$src),
6638 (REV64v8i16 FPR128:$src), (i32 8)))>;
6639 def : Pat<(f128 (bitconvert (v8f16 FPR128:$src))),
6640 (f128 (EXTv16i8 (REV64v8i16 FPR128:$src),
6641 (REV64v8i16 FPR128:$src), (i32 8)))>;
6642 def : Pat<(f128 (bitconvert (v2f64 FPR128:$src))),
6643 (f128 (EXTv16i8 FPR128:$src, FPR128:$src, (i32 8)))>;
6644 def : Pat<(f128 (bitconvert (v4f32 FPR128:$src))),
6645 (f128 (EXTv16i8 (REV64v4i32 FPR128:$src),
6646 (REV64v4i32 FPR128:$src), (i32 8)))>;
6647 def : Pat<(f128 (bitconvert (v16i8 FPR128:$src))),
6648 (f128 (EXTv16i8 (REV64v16i8 FPR128:$src),
6649 (REV64v16i8 FPR128:$src), (i32 8)))>;
6652 let Predicates = [IsLE] in {
6653 def : Pat<(v2f64 (bitconvert (f128 FPR128:$src))), (v2f64 FPR128:$src)>;
6654 def : Pat<(v2f64 (bitconvert (v4i32 FPR128:$src))), (v2f64 FPR128:$src)>;
6655 def : Pat<(v2f64 (bitconvert (v8i16 FPR128:$src))), (v2f64 FPR128:$src)>;
6656 def : Pat<(v2f64 (bitconvert (v8f16 FPR128:$src))), (v2f64 FPR128:$src)>;
6657 def : Pat<(v2f64 (bitconvert (v16i8 FPR128:$src))), (v2f64 FPR128:$src)>;
6658 def : Pat<(v2f64 (bitconvert (v4f32 FPR128:$src))), (v2f64 FPR128:$src)>;
6660 let Predicates = [IsBE] in {
6661 def : Pat<(v2f64 (bitconvert (f128 FPR128:$src))),
6662 (v2f64 (EXTv16i8 FPR128:$src,
6663 FPR128:$src, (i32 8)))>;
6664 def : Pat<(v2f64 (bitconvert (v4i32 FPR128:$src))),
6665 (v2f64 (REV64v4i32 FPR128:$src))>;
6666 def : Pat<(v2f64 (bitconvert (v8i16 FPR128:$src))),
6667 (v2f64 (REV64v8i16 FPR128:$src))>;
6668 def : Pat<(v2f64 (bitconvert (v8f16 FPR128:$src))),
6669 (v2f64 (REV64v8i16 FPR128:$src))>;
6670 def : Pat<(v2f64 (bitconvert (v16i8 FPR128:$src))),
6671 (v2f64 (REV64v16i8 FPR128:$src))>;
6672 def : Pat<(v2f64 (bitconvert (v4f32 FPR128:$src))),
6673 (v2f64 (REV64v4i32 FPR128:$src))>;
6675 def : Pat<(v2f64 (bitconvert (v2i64 FPR128:$src))), (v2f64 FPR128:$src)>;
6677 let Predicates = [IsLE] in {
6678 def : Pat<(v4f32 (bitconvert (f128 FPR128:$src))), (v4f32 FPR128:$src)>;
6679 def : Pat<(v4f32 (bitconvert (v8i16 FPR128:$src))), (v4f32 FPR128:$src)>;
6680 def : Pat<(v4f32 (bitconvert (v8f16 FPR128:$src))), (v4f32 FPR128:$src)>;
6681 def : Pat<(v4f32 (bitconvert (v16i8 FPR128:$src))), (v4f32 FPR128:$src)>;
6682 def : Pat<(v4f32 (bitconvert (v2i64 FPR128:$src))), (v4f32 FPR128:$src)>;
6683 def : Pat<(v4f32 (bitconvert (v2f64 FPR128:$src))), (v4f32 FPR128:$src)>;
6685 let Predicates = [IsBE] in {
6686 def : Pat<(v4f32 (bitconvert (f128 FPR128:$src))),
6687 (v4f32 (EXTv16i8 (REV64v4i32 FPR128:$src),
6688 (REV64v4i32 FPR128:$src), (i32 8)))>;
6689 def : Pat<(v4f32 (bitconvert (v8i16 FPR128:$src))),
6690 (v4f32 (REV32v8i16 FPR128:$src))>;
6691 def : Pat<(v4f32 (bitconvert (v8f16 FPR128:$src))),
6692 (v4f32 (REV32v8i16 FPR128:$src))>;
6693 def : Pat<(v4f32 (bitconvert (v16i8 FPR128:$src))),
6694 (v4f32 (REV32v16i8 FPR128:$src))>;
6695 def : Pat<(v4f32 (bitconvert (v2i64 FPR128:$src))),
6696 (v4f32 (REV64v4i32 FPR128:$src))>;
6697 def : Pat<(v4f32 (bitconvert (v2f64 FPR128:$src))),
6698 (v4f32 (REV64v4i32 FPR128:$src))>;
6700 def : Pat<(v4f32 (bitconvert (v4i32 FPR128:$src))), (v4f32 FPR128:$src)>;
6702 let Predicates = [IsLE] in {
6703 def : Pat<(v2i64 (bitconvert (f128 FPR128:$src))), (v2i64 FPR128:$src)>;
6704 def : Pat<(v2i64 (bitconvert (v4i32 FPR128:$src))), (v2i64 FPR128:$src)>;
6705 def : Pat<(v2i64 (bitconvert (v8i16 FPR128:$src))), (v2i64 FPR128:$src)>;
6706 def : Pat<(v2i64 (bitconvert (v16i8 FPR128:$src))), (v2i64 FPR128:$src)>;
6707 def : Pat<(v2i64 (bitconvert (v4f32 FPR128:$src))), (v2i64 FPR128:$src)>;
6708 def : Pat<(v2i64 (bitconvert (v8f16 FPR128:$src))), (v2i64 FPR128:$src)>;
6710 let Predicates = [IsBE] in {
6711 def : Pat<(v2i64 (bitconvert (f128 FPR128:$src))),
6712 (v2i64 (EXTv16i8 FPR128:$src,
6713 FPR128:$src, (i32 8)))>;
6714 def : Pat<(v2i64 (bitconvert (v4i32 FPR128:$src))),
6715 (v2i64 (REV64v4i32 FPR128:$src))>;
6716 def : Pat<(v2i64 (bitconvert (v8i16 FPR128:$src))),
6717 (v2i64 (REV64v8i16 FPR128:$src))>;
6718 def : Pat<(v2i64 (bitconvert (v16i8 FPR128:$src))),
6719 (v2i64 (REV64v16i8 FPR128:$src))>;
6720 def : Pat<(v2i64 (bitconvert (v4f32 FPR128:$src))),
6721 (v2i64 (REV64v4i32 FPR128:$src))>;
6722 def : Pat<(v2i64 (bitconvert (v8f16 FPR128:$src))),
6723 (v2i64 (REV64v8i16 FPR128:$src))>;
6725 def : Pat<(v2i64 (bitconvert (v2f64 FPR128:$src))), (v2i64 FPR128:$src)>;
6727 let Predicates = [IsLE] in {
6728 def : Pat<(v4i32 (bitconvert (f128 FPR128:$src))), (v4i32 FPR128:$src)>;
6729 def : Pat<(v4i32 (bitconvert (v2i64 FPR128:$src))), (v4i32 FPR128:$src)>;
6730 def : Pat<(v4i32 (bitconvert (v8i16 FPR128:$src))), (v4i32 FPR128:$src)>;
6731 def : Pat<(v4i32 (bitconvert (v16i8 FPR128:$src))), (v4i32 FPR128:$src)>;
6732 def : Pat<(v4i32 (bitconvert (v2f64 FPR128:$src))), (v4i32 FPR128:$src)>;
6733 def : Pat<(v4i32 (bitconvert (v8f16 FPR128:$src))), (v4i32 FPR128:$src)>;
6735 let Predicates = [IsBE] in {
6736 def : Pat<(v4i32 (bitconvert (f128 FPR128:$src))),
6737 (v4i32 (EXTv16i8 (REV64v4i32 FPR128:$src),
6738 (REV64v4i32 FPR128:$src),
6740 def : Pat<(v4i32 (bitconvert (v2i64 FPR128:$src))),
6741 (v4i32 (REV64v4i32 FPR128:$src))>;
6742 def : Pat<(v4i32 (bitconvert (v8i16 FPR128:$src))),
6743 (v4i32 (REV32v8i16 FPR128:$src))>;
6744 def : Pat<(v4i32 (bitconvert (v16i8 FPR128:$src))),
6745 (v4i32 (REV32v16i8 FPR128:$src))>;
6746 def : Pat<(v4i32 (bitconvert (v2f64 FPR128:$src))),
6747 (v4i32 (REV64v4i32 FPR128:$src))>;
6748 def : Pat<(v4i32 (bitconvert (v8f16 FPR128:$src))),
6749 (v4i32 (REV32v8i16 FPR128:$src))>;
6751 def : Pat<(v4i32 (bitconvert (v4f32 FPR128:$src))), (v4i32 FPR128:$src)>;
6753 let Predicates = [IsLE] in {
6754 def : Pat<(v8i16 (bitconvert (f128 FPR128:$src))), (v8i16 FPR128:$src)>;
6755 def : Pat<(v8i16 (bitconvert (v2i64 FPR128:$src))), (v8i16 FPR128:$src)>;
6756 def : Pat<(v8i16 (bitconvert (v4i32 FPR128:$src))), (v8i16 FPR128:$src)>;
6757 def : Pat<(v8i16 (bitconvert (v16i8 FPR128:$src))), (v8i16 FPR128:$src)>;
6758 def : Pat<(v8i16 (bitconvert (v2f64 FPR128:$src))), (v8i16 FPR128:$src)>;
6759 def : Pat<(v8i16 (bitconvert (v4f32 FPR128:$src))), (v8i16 FPR128:$src)>;
6761 let Predicates = [IsBE] in {
6762 def : Pat<(v8i16 (bitconvert (f128 FPR128:$src))),
6763 (v8i16 (EXTv16i8 (REV64v8i16 FPR128:$src),
6764 (REV64v8i16 FPR128:$src),
6766 def : Pat<(v8i16 (bitconvert (v2i64 FPR128:$src))),
6767 (v8i16 (REV64v8i16 FPR128:$src))>;
6768 def : Pat<(v8i16 (bitconvert (v4i32 FPR128:$src))),
6769 (v8i16 (REV32v8i16 FPR128:$src))>;
6770 def : Pat<(v8i16 (bitconvert (v16i8 FPR128:$src))),
6771 (v8i16 (REV16v16i8 FPR128:$src))>;
6772 def : Pat<(v8i16 (bitconvert (v2f64 FPR128:$src))),
6773 (v8i16 (REV64v8i16 FPR128:$src))>;
6774 def : Pat<(v8i16 (bitconvert (v4f32 FPR128:$src))),
6775 (v8i16 (REV32v8i16 FPR128:$src))>;
6777 def : Pat<(v8i16 (bitconvert (v8f16 FPR128:$src))), (v8i16 FPR128:$src)>;
6779 let Predicates = [IsLE] in {
6780 def : Pat<(v8f16 (bitconvert (f128 FPR128:$src))), (v8f16 FPR128:$src)>;
6781 def : Pat<(v8f16 (bitconvert (v2i64 FPR128:$src))), (v8f16 FPR128:$src)>;
6782 def : Pat<(v8f16 (bitconvert (v4i32 FPR128:$src))), (v8f16 FPR128:$src)>;
6783 def : Pat<(v8f16 (bitconvert (v16i8 FPR128:$src))), (v8f16 FPR128:$src)>;
6784 def : Pat<(v8f16 (bitconvert (v2f64 FPR128:$src))), (v8f16 FPR128:$src)>;
6785 def : Pat<(v8f16 (bitconvert (v4f32 FPR128:$src))), (v8f16 FPR128:$src)>;
6787 let Predicates = [IsBE] in {
6788 def : Pat<(v8f16 (bitconvert (f128 FPR128:$src))),
6789 (v8f16 (EXTv16i8 (REV64v8i16 FPR128:$src),
6790 (REV64v8i16 FPR128:$src),
6792 def : Pat<(v8f16 (bitconvert (v2i64 FPR128:$src))),
6793 (v8f16 (REV64v8i16 FPR128:$src))>;
6794 def : Pat<(v8f16 (bitconvert (v4i32 FPR128:$src))),
6795 (v8f16 (REV32v8i16 FPR128:$src))>;
6796 def : Pat<(v8f16 (bitconvert (v16i8 FPR128:$src))),
6797 (v8f16 (REV16v16i8 FPR128:$src))>;
6798 def : Pat<(v8f16 (bitconvert (v2f64 FPR128:$src))),
6799 (v8f16 (REV64v8i16 FPR128:$src))>;
6800 def : Pat<(v8f16 (bitconvert (v4f32 FPR128:$src))),
6801 (v8f16 (REV32v8i16 FPR128:$src))>;
6803 def : Pat<(v8f16 (bitconvert (v8i16 FPR128:$src))), (v8f16 FPR128:$src)>;
6805 let Predicates = [IsLE] in {
6806 def : Pat<(v16i8 (bitconvert (f128 FPR128:$src))), (v16i8 FPR128:$src)>;
6807 def : Pat<(v16i8 (bitconvert (v2i64 FPR128:$src))), (v16i8 FPR128:$src)>;
6808 def : Pat<(v16i8 (bitconvert (v4i32 FPR128:$src))), (v16i8 FPR128:$src)>;
6809 def : Pat<(v16i8 (bitconvert (v8i16 FPR128:$src))), (v16i8 FPR128:$src)>;
6810 def : Pat<(v16i8 (bitconvert (v2f64 FPR128:$src))), (v16i8 FPR128:$src)>;
6811 def : Pat<(v16i8 (bitconvert (v4f32 FPR128:$src))), (v16i8 FPR128:$src)>;
6812 def : Pat<(v16i8 (bitconvert (v8f16 FPR128:$src))), (v16i8 FPR128:$src)>;
6814 let Predicates = [IsBE] in {
6815 def : Pat<(v16i8 (bitconvert (f128 FPR128:$src))),
6816 (v16i8 (EXTv16i8 (REV64v16i8 FPR128:$src),
6817 (REV64v16i8 FPR128:$src),
6819 def : Pat<(v16i8 (bitconvert (v2i64 FPR128:$src))),
6820 (v16i8 (REV64v16i8 FPR128:$src))>;
6821 def : Pat<(v16i8 (bitconvert (v4i32 FPR128:$src))),
6822 (v16i8 (REV32v16i8 FPR128:$src))>;
6823 def : Pat<(v16i8 (bitconvert (v8i16 FPR128:$src))),
6824 (v16i8 (REV16v16i8 FPR128:$src))>;
6825 def : Pat<(v16i8 (bitconvert (v2f64 FPR128:$src))),
6826 (v16i8 (REV64v16i8 FPR128:$src))>;
6827 def : Pat<(v16i8 (bitconvert (v4f32 FPR128:$src))),
6828 (v16i8 (REV32v16i8 FPR128:$src))>;
6829 def : Pat<(v16i8 (bitconvert (v8f16 FPR128:$src))),
6830 (v16i8 (REV16v16i8 FPR128:$src))>;
6833 def : Pat<(v4i16 (extract_subvector V128:$Rn, (i64 0))),
6834 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6835 def : Pat<(v8i8 (extract_subvector V128:$Rn, (i64 0))),
6836 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6837 def : Pat<(v2f32 (extract_subvector V128:$Rn, (i64 0))),
6838 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6839 def : Pat<(v4f16 (extract_subvector V128:$Rn, (i64 0))),
6840 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6841 def : Pat<(v2i32 (extract_subvector V128:$Rn, (i64 0))),
6842 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6843 def : Pat<(v1i64 (extract_subvector V128:$Rn, (i64 0))),
6844 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6845 def : Pat<(v1f64 (extract_subvector V128:$Rn, (i64 0))),
6846 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6848 def : Pat<(v8i8 (extract_subvector (v16i8 FPR128:$Rn), (i64 1))),
6849 (EXTRACT_SUBREG (DUPv2i64lane FPR128:$Rn, 1), dsub)>;
6850 def : Pat<(v4i16 (extract_subvector (v8i16 FPR128:$Rn), (i64 1))),
6851 (EXTRACT_SUBREG (DUPv2i64lane FPR128:$Rn, 1), dsub)>;
6852 def : Pat<(v2i32 (extract_subvector (v4i32 FPR128:$Rn), (i64 1))),
6853 (EXTRACT_SUBREG (DUPv2i64lane FPR128:$Rn, 1), dsub)>;
6854 def : Pat<(v1i64 (extract_subvector (v2i64 FPR128:$Rn), (i64 1))),
6855 (EXTRACT_SUBREG (DUPv2i64lane FPR128:$Rn, 1), dsub)>;
6857 // A 64-bit subvector insert to the first 128-bit vector position
6858 // is a subregister copy that needs no instruction.
6859 multiclass InsertSubvectorUndef<ValueType Ty> {
6860 def : Pat<(insert_subvector undef, (v1i64 FPR64:$src), (Ty 0)),
6861 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6862 def : Pat<(insert_subvector undef, (v1f64 FPR64:$src), (Ty 0)),
6863 (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6864 def : Pat<(insert_subvector undef, (v2i32 FPR64:$src), (Ty 0)),
6865 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6866 def : Pat<(insert_subvector undef, (v2f32 FPR64:$src), (Ty 0)),
6867 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6868 def : Pat<(insert_subvector undef, (v4i16 FPR64:$src), (Ty 0)),
6869 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6870 def : Pat<(insert_subvector undef, (v4f16 FPR64:$src), (Ty 0)),
6871 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6872 def : Pat<(insert_subvector undef, (v8i8 FPR64:$src), (Ty 0)),
6873 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6876 defm : InsertSubvectorUndef<i32>;
6877 defm : InsertSubvectorUndef<i64>;
6879 // Use pair-wise add instructions when summing up the lanes for v2f64, v2i64
6881 def : Pat<(i64 (add (vector_extract (v2i64 FPR128:$Rn), (i64 0)),
6882 (vector_extract (v2i64 FPR128:$Rn), (i64 1)))),
6883 (i64 (ADDPv2i64p (v2i64 FPR128:$Rn)))>;
6884 def : Pat<(f64 (fadd (vector_extract (v2f64 FPR128:$Rn), (i64 0)),
6885 (vector_extract (v2f64 FPR128:$Rn), (i64 1)))),
6886 (f64 (FADDPv2i64p (v2f64 FPR128:$Rn)))>;
6887 // vector_extract on 64-bit vectors gets promoted to a 128 bit vector,
6888 // so we match on v4f32 here, not v2f32. This will also catch adding
6889 // the low two lanes of a true v4f32 vector.
6890 def : Pat<(fadd (vector_extract (v4f32 FPR128:$Rn), (i64 0)),
6891 (vector_extract (v4f32 FPR128:$Rn), (i64 1))),
6892 (f32 (FADDPv2i32p (EXTRACT_SUBREG FPR128:$Rn, dsub)))>;
6894 // Scalar 64-bit shifts in FPR64 registers.
6895 def : Pat<(i64 (int_aarch64_neon_sshl (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
6896 (SSHLv1i64 FPR64:$Rn, FPR64:$Rm)>;
6897 def : Pat<(i64 (int_aarch64_neon_ushl (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
6898 (USHLv1i64 FPR64:$Rn, FPR64:$Rm)>;
6899 def : Pat<(i64 (int_aarch64_neon_srshl (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
6900 (SRSHLv1i64 FPR64:$Rn, FPR64:$Rm)>;
6901 def : Pat<(i64 (int_aarch64_neon_urshl (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
6902 (URSHLv1i64 FPR64:$Rn, FPR64:$Rm)>;
6904 // Patterns for nontemporal/no-allocate stores.
6905 // We have to resort to tricks to turn a single-input store into a store pair,
6906 // because there is no single-input nontemporal store, only STNP.
6907 let Predicates = [IsLE] in {
6908 let AddedComplexity = 15 in {
6909 class NTStore128Pat<ValueType VT> :
6910 Pat<(nontemporalstore (VT FPR128:$Rt),
6911 (am_indexed7s64 GPR64sp:$Rn, simm7s8:$offset)),
6912 (STNPDi (EXTRACT_SUBREG FPR128:$Rt, dsub),
6913 (CPYi64 FPR128:$Rt, (i64 1)),
6914 GPR64sp:$Rn, simm7s8:$offset)>;
6916 def : NTStore128Pat<v2i64>;
6917 def : NTStore128Pat<v4i32>;
6918 def : NTStore128Pat<v8i16>;
6919 def : NTStore128Pat<v16i8>;
6921 class NTStore64Pat<ValueType VT> :
6922 Pat<(nontemporalstore (VT FPR64:$Rt),
6923 (am_indexed7s32 GPR64sp:$Rn, simm7s4:$offset)),
6924 (STNPSi (EXTRACT_SUBREG FPR64:$Rt, ssub),
6925 (CPYi32 (SUBREG_TO_REG (i64 0), FPR64:$Rt, dsub), (i64 1)),
6926 GPR64sp:$Rn, simm7s4:$offset)>;
6928 // FIXME: Shouldn't v1f64 loads/stores be promoted to v1i64?
6929 def : NTStore64Pat<v1f64>;
6930 def : NTStore64Pat<v1i64>;
6931 def : NTStore64Pat<v2i32>;
6932 def : NTStore64Pat<v4i16>;
6933 def : NTStore64Pat<v8i8>;
6935 def : Pat<(nontemporalstore GPR64:$Rt,
6936 (am_indexed7s32 GPR64sp:$Rn, simm7s4:$offset)),
6937 (STNPWi (EXTRACT_SUBREG GPR64:$Rt, sub_32),
6938 (EXTRACT_SUBREG (UBFMXri GPR64:$Rt, 32, 63), sub_32),
6939 GPR64sp:$Rn, simm7s4:$offset)>;
6940 } // AddedComplexity=10
6941 } // Predicates = [IsLE]
6943 // Tail call return handling. These are all compiler pseudo-instructions,
6944 // so no encoding information or anything like that.
6945 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in {
6946 def TCRETURNdi : Pseudo<(outs), (ins i64imm:$dst, i32imm:$FPDiff), []>,
6947 Sched<[WriteBrReg]>;
6948 def TCRETURNri : Pseudo<(outs), (ins tcGPR64:$dst, i32imm:$FPDiff), []>,
6949 Sched<[WriteBrReg]>;
6950 // Indirect tail-call with any register allowed, used by MachineOutliner when
6951 // this is proven safe.
6952 // FIXME: If we have to add any more hacks like this, we should instead relax
6953 // some verifier checks for outlined functions.
6954 def TCRETURNriALL : Pseudo<(outs), (ins GPR64:$dst, i32imm:$FPDiff), []>,
6955 Sched<[WriteBrReg]>;
6956 // Indirect tail-call limited to only use registers (x16 and x17) which are
6957 // allowed to tail-call a "BTI c" instruction.
6958 def TCRETURNriBTI : Pseudo<(outs), (ins rtcGPR64:$dst, i32imm:$FPDiff), []>,
6959 Sched<[WriteBrReg]>;
6962 def : Pat<(AArch64tcret tcGPR64:$dst, (i32 timm:$FPDiff)),
6963 (TCRETURNri tcGPR64:$dst, imm:$FPDiff)>,
6964 Requires<[NotUseBTI]>;
6965 def : Pat<(AArch64tcret rtcGPR64:$dst, (i32 timm:$FPDiff)),
6966 (TCRETURNriBTI rtcGPR64:$dst, imm:$FPDiff)>,
6968 def : Pat<(AArch64tcret tglobaladdr:$dst, (i32 timm:$FPDiff)),
6969 (TCRETURNdi texternalsym:$dst, imm:$FPDiff)>;
6970 def : Pat<(AArch64tcret texternalsym:$dst, (i32 timm:$FPDiff)),
6971 (TCRETURNdi texternalsym:$dst, imm:$FPDiff)>;
6973 def MOVMCSym : Pseudo<(outs GPR64:$dst), (ins i64imm:$sym), []>, Sched<[]>;
6974 def : Pat<(i64 (AArch64LocalRecover mcsym:$sym)), (MOVMCSym mcsym:$sym)>;
6976 include "AArch64InstrAtomics.td"
6977 include "AArch64SVEInstrInfo.td"