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 HasRCPC : Predicate<"Subtarget->hasRCPC()">,
111 AssemblerPredicate<"FeatureRCPC", "rcpc">;
112 def HasAltNZCV : Predicate<"Subtarget->hasAlternativeNZCV()">,
113 AssemblerPredicate<"FeatureAltFPCmp", "altnzcv">;
114 def HasFRInt3264 : Predicate<"Subtarget->hasFRInt3264()">,
115 AssemblerPredicate<"FeatureFRInt3264", "frint3264">;
116 def HasSB : Predicate<"Subtarget->hasSB()">,
117 AssemblerPredicate<"FeatureSB", "sb">;
118 def HasPredRes : Predicate<"Subtarget->hasPredRes()">,
119 AssemblerPredicate<"FeaturePredRes", "predres">;
120 def HasCCDP : Predicate<"Subtarget->hasCCDP()">,
121 AssemblerPredicate<"FeatureCacheDeepPersist", "ccdp">;
122 def HasBTI : Predicate<"Subtarget->hasBTI()">,
123 AssemblerPredicate<"FeatureBranchTargetId", "bti">;
124 def HasMTE : Predicate<"Subtarget->hasMTE()">,
125 AssemblerPredicate<"FeatureMTE", "mte">;
126 def IsLE : Predicate<"Subtarget->isLittleEndian()">;
127 def IsBE : Predicate<"!Subtarget->isLittleEndian()">;
128 def UseAlternateSExtLoadCVTF32
129 : Predicate<"Subtarget->useAlternateSExtLoadCVTF32Pattern()">;
131 def UseNegativeImmediates
132 : Predicate<"false">, AssemblerPredicate<"!FeatureNoNegativeImmediates",
133 "NegativeImmediates">;
135 def AArch64LocalRecover : SDNode<"ISD::LOCAL_RECOVER",
136 SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>,
140 //===----------------------------------------------------------------------===//
141 // AArch64-specific DAG Nodes.
144 // SDTBinaryArithWithFlagsOut - RES1, FLAGS = op LHS, RHS
145 def SDTBinaryArithWithFlagsOut : SDTypeProfile<2, 2,
148 SDTCisInt<0>, SDTCisVT<1, i32>]>;
150 // SDTBinaryArithWithFlagsIn - RES1, FLAGS = op LHS, RHS, FLAGS
151 def SDTBinaryArithWithFlagsIn : SDTypeProfile<1, 3,
157 // SDTBinaryArithWithFlagsInOut - RES1, FLAGS = op LHS, RHS, FLAGS
158 def SDTBinaryArithWithFlagsInOut : SDTypeProfile<2, 3,
165 def SDT_AArch64Brcond : SDTypeProfile<0, 3,
166 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i32>,
168 def SDT_AArch64cbz : SDTypeProfile<0, 2, [SDTCisInt<0>, SDTCisVT<1, OtherVT>]>;
169 def SDT_AArch64tbz : SDTypeProfile<0, 3, [SDTCisInt<0>, SDTCisInt<1>,
170 SDTCisVT<2, OtherVT>]>;
173 def SDT_AArch64CSel : SDTypeProfile<1, 4,
178 def SDT_AArch64CCMP : SDTypeProfile<1, 5,
185 def SDT_AArch64FCCMP : SDTypeProfile<1, 5,
192 def SDT_AArch64FCmp : SDTypeProfile<0, 2,
194 SDTCisSameAs<0, 1>]>;
195 def SDT_AArch64Dup : SDTypeProfile<1, 1, [SDTCisVec<0>]>;
196 def SDT_AArch64DupLane : SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisInt<2>]>;
197 def SDT_AArch64Zip : SDTypeProfile<1, 2, [SDTCisVec<0>,
199 SDTCisSameAs<0, 2>]>;
200 def SDT_AArch64MOVIedit : SDTypeProfile<1, 1, [SDTCisInt<1>]>;
201 def SDT_AArch64MOVIshift : SDTypeProfile<1, 2, [SDTCisInt<1>, SDTCisInt<2>]>;
202 def SDT_AArch64vecimm : SDTypeProfile<1, 3, [SDTCisVec<0>, SDTCisSameAs<0,1>,
203 SDTCisInt<2>, SDTCisInt<3>]>;
204 def SDT_AArch64UnaryVec: SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisSameAs<0,1>]>;
205 def SDT_AArch64ExtVec: SDTypeProfile<1, 3, [SDTCisVec<0>, SDTCisSameAs<0,1>,
206 SDTCisSameAs<0,2>, SDTCisInt<3>]>;
207 def SDT_AArch64vshift : SDTypeProfile<1, 2, [SDTCisSameAs<0,1>, SDTCisInt<2>]>;
209 def SDT_AArch64unvec : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisSameAs<0,1>]>;
210 def SDT_AArch64fcmpz : SDTypeProfile<1, 1, []>;
211 def SDT_AArch64fcmp : SDTypeProfile<1, 2, [SDTCisSameAs<1,2>]>;
212 def SDT_AArch64binvec : SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisSameAs<0,1>,
214 def SDT_AArch64trivec : SDTypeProfile<1, 3, [SDTCisVec<0>, SDTCisSameAs<0,1>,
217 def SDT_AArch64TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>]>;
218 def SDT_AArch64PREFETCH : SDTypeProfile<0, 2, [SDTCisVT<0, i32>, SDTCisPtrTy<1>]>;
220 def SDT_AArch64ITOF : SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisSameAs<0,1>]>;
222 def SDT_AArch64TLSDescCall : SDTypeProfile<0, -2, [SDTCisPtrTy<0>,
225 // Generates the general dynamic sequences, i.e.
226 // adrp x0, :tlsdesc:var
227 // ldr x1, [x0, #:tlsdesc_lo12:var]
228 // add x0, x0, #:tlsdesc_lo12:var
232 // (the TPIDR_EL0 offset is put directly in X0, hence no "result" here)
233 // number of operands (the variable)
234 def SDT_AArch64TLSDescCallSeq : SDTypeProfile<0,1,
237 def SDT_AArch64WrapperLarge : SDTypeProfile<1, 4,
238 [SDTCisVT<0, i64>, SDTCisVT<1, i32>,
239 SDTCisSameAs<1, 2>, SDTCisSameAs<1, 3>,
240 SDTCisSameAs<1, 4>]>;
244 def AArch64adrp : SDNode<"AArch64ISD::ADRP", SDTIntUnaryOp, []>;
245 def AArch64adr : SDNode<"AArch64ISD::ADR", SDTIntUnaryOp, []>;
246 def AArch64addlow : SDNode<"AArch64ISD::ADDlow", SDTIntBinOp, []>;
247 def AArch64LOADgot : SDNode<"AArch64ISD::LOADgot", SDTIntUnaryOp>;
248 def AArch64callseq_start : SDNode<"ISD::CALLSEQ_START",
249 SDCallSeqStart<[ SDTCisVT<0, i32>,
251 [SDNPHasChain, SDNPOutGlue]>;
252 def AArch64callseq_end : SDNode<"ISD::CALLSEQ_END",
253 SDCallSeqEnd<[ SDTCisVT<0, i32>,
255 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
256 def AArch64call : SDNode<"AArch64ISD::CALL",
257 SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>,
258 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
260 def AArch64brcond : SDNode<"AArch64ISD::BRCOND", SDT_AArch64Brcond,
262 def AArch64cbz : SDNode<"AArch64ISD::CBZ", SDT_AArch64cbz,
264 def AArch64cbnz : SDNode<"AArch64ISD::CBNZ", SDT_AArch64cbz,
266 def AArch64tbz : SDNode<"AArch64ISD::TBZ", SDT_AArch64tbz,
268 def AArch64tbnz : SDNode<"AArch64ISD::TBNZ", SDT_AArch64tbz,
272 def AArch64csel : SDNode<"AArch64ISD::CSEL", SDT_AArch64CSel>;
273 def AArch64csinv : SDNode<"AArch64ISD::CSINV", SDT_AArch64CSel>;
274 def AArch64csneg : SDNode<"AArch64ISD::CSNEG", SDT_AArch64CSel>;
275 def AArch64csinc : SDNode<"AArch64ISD::CSINC", SDT_AArch64CSel>;
276 def AArch64retflag : SDNode<"AArch64ISD::RET_FLAG", SDTNone,
277 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
278 def AArch64adc : SDNode<"AArch64ISD::ADC", SDTBinaryArithWithFlagsIn >;
279 def AArch64sbc : SDNode<"AArch64ISD::SBC", SDTBinaryArithWithFlagsIn>;
280 def AArch64add_flag : SDNode<"AArch64ISD::ADDS", SDTBinaryArithWithFlagsOut,
282 def AArch64sub_flag : SDNode<"AArch64ISD::SUBS", SDTBinaryArithWithFlagsOut>;
283 def AArch64and_flag : SDNode<"AArch64ISD::ANDS", SDTBinaryArithWithFlagsOut,
285 def AArch64adc_flag : SDNode<"AArch64ISD::ADCS", SDTBinaryArithWithFlagsInOut>;
286 def AArch64sbc_flag : SDNode<"AArch64ISD::SBCS", SDTBinaryArithWithFlagsInOut>;
288 def AArch64ccmp : SDNode<"AArch64ISD::CCMP", SDT_AArch64CCMP>;
289 def AArch64ccmn : SDNode<"AArch64ISD::CCMN", SDT_AArch64CCMP>;
290 def AArch64fccmp : SDNode<"AArch64ISD::FCCMP", SDT_AArch64FCCMP>;
292 def AArch64threadpointer : SDNode<"AArch64ISD::THREAD_POINTER", SDTPtrLeaf>;
294 def AArch64fcmp : SDNode<"AArch64ISD::FCMP", SDT_AArch64FCmp>;
296 def AArch64dup : SDNode<"AArch64ISD::DUP", SDT_AArch64Dup>;
297 def AArch64duplane8 : SDNode<"AArch64ISD::DUPLANE8", SDT_AArch64DupLane>;
298 def AArch64duplane16 : SDNode<"AArch64ISD::DUPLANE16", SDT_AArch64DupLane>;
299 def AArch64duplane32 : SDNode<"AArch64ISD::DUPLANE32", SDT_AArch64DupLane>;
300 def AArch64duplane64 : SDNode<"AArch64ISD::DUPLANE64", SDT_AArch64DupLane>;
302 def AArch64zip1 : SDNode<"AArch64ISD::ZIP1", SDT_AArch64Zip>;
303 def AArch64zip2 : SDNode<"AArch64ISD::ZIP2", SDT_AArch64Zip>;
304 def AArch64uzp1 : SDNode<"AArch64ISD::UZP1", SDT_AArch64Zip>;
305 def AArch64uzp2 : SDNode<"AArch64ISD::UZP2", SDT_AArch64Zip>;
306 def AArch64trn1 : SDNode<"AArch64ISD::TRN1", SDT_AArch64Zip>;
307 def AArch64trn2 : SDNode<"AArch64ISD::TRN2", SDT_AArch64Zip>;
309 def AArch64movi_edit : SDNode<"AArch64ISD::MOVIedit", SDT_AArch64MOVIedit>;
310 def AArch64movi_shift : SDNode<"AArch64ISD::MOVIshift", SDT_AArch64MOVIshift>;
311 def AArch64movi_msl : SDNode<"AArch64ISD::MOVImsl", SDT_AArch64MOVIshift>;
312 def AArch64mvni_shift : SDNode<"AArch64ISD::MVNIshift", SDT_AArch64MOVIshift>;
313 def AArch64mvni_msl : SDNode<"AArch64ISD::MVNImsl", SDT_AArch64MOVIshift>;
314 def AArch64movi : SDNode<"AArch64ISD::MOVI", SDT_AArch64MOVIedit>;
315 def AArch64fmov : SDNode<"AArch64ISD::FMOV", SDT_AArch64MOVIedit>;
317 def AArch64rev16 : SDNode<"AArch64ISD::REV16", SDT_AArch64UnaryVec>;
318 def AArch64rev32 : SDNode<"AArch64ISD::REV32", SDT_AArch64UnaryVec>;
319 def AArch64rev64 : SDNode<"AArch64ISD::REV64", SDT_AArch64UnaryVec>;
320 def AArch64ext : SDNode<"AArch64ISD::EXT", SDT_AArch64ExtVec>;
322 def AArch64vashr : SDNode<"AArch64ISD::VASHR", SDT_AArch64vshift>;
323 def AArch64vlshr : SDNode<"AArch64ISD::VLSHR", SDT_AArch64vshift>;
324 def AArch64vshl : SDNode<"AArch64ISD::VSHL", SDT_AArch64vshift>;
325 def AArch64sqshli : SDNode<"AArch64ISD::SQSHL_I", SDT_AArch64vshift>;
326 def AArch64uqshli : SDNode<"AArch64ISD::UQSHL_I", SDT_AArch64vshift>;
327 def AArch64sqshlui : SDNode<"AArch64ISD::SQSHLU_I", SDT_AArch64vshift>;
328 def AArch64srshri : SDNode<"AArch64ISD::SRSHR_I", SDT_AArch64vshift>;
329 def AArch64urshri : SDNode<"AArch64ISD::URSHR_I", SDT_AArch64vshift>;
331 def AArch64not: SDNode<"AArch64ISD::NOT", SDT_AArch64unvec>;
332 def AArch64bit: SDNode<"AArch64ISD::BIT", SDT_AArch64trivec>;
333 def AArch64bsl: SDNode<"AArch64ISD::BSL", SDT_AArch64trivec>;
335 def AArch64cmeq: SDNode<"AArch64ISD::CMEQ", SDT_AArch64binvec>;
336 def AArch64cmge: SDNode<"AArch64ISD::CMGE", SDT_AArch64binvec>;
337 def AArch64cmgt: SDNode<"AArch64ISD::CMGT", SDT_AArch64binvec>;
338 def AArch64cmhi: SDNode<"AArch64ISD::CMHI", SDT_AArch64binvec>;
339 def AArch64cmhs: SDNode<"AArch64ISD::CMHS", SDT_AArch64binvec>;
341 def AArch64fcmeq: SDNode<"AArch64ISD::FCMEQ", SDT_AArch64fcmp>;
342 def AArch64fcmge: SDNode<"AArch64ISD::FCMGE", SDT_AArch64fcmp>;
343 def AArch64fcmgt: SDNode<"AArch64ISD::FCMGT", SDT_AArch64fcmp>;
345 def AArch64cmeqz: SDNode<"AArch64ISD::CMEQz", SDT_AArch64unvec>;
346 def AArch64cmgez: SDNode<"AArch64ISD::CMGEz", SDT_AArch64unvec>;
347 def AArch64cmgtz: SDNode<"AArch64ISD::CMGTz", SDT_AArch64unvec>;
348 def AArch64cmlez: SDNode<"AArch64ISD::CMLEz", SDT_AArch64unvec>;
349 def AArch64cmltz: SDNode<"AArch64ISD::CMLTz", SDT_AArch64unvec>;
350 def AArch64cmtst : PatFrag<(ops node:$LHS, node:$RHS),
351 (AArch64not (AArch64cmeqz (and node:$LHS, node:$RHS)))>;
353 def AArch64fcmeqz: SDNode<"AArch64ISD::FCMEQz", SDT_AArch64fcmpz>;
354 def AArch64fcmgez: SDNode<"AArch64ISD::FCMGEz", SDT_AArch64fcmpz>;
355 def AArch64fcmgtz: SDNode<"AArch64ISD::FCMGTz", SDT_AArch64fcmpz>;
356 def AArch64fcmlez: SDNode<"AArch64ISD::FCMLEz", SDT_AArch64fcmpz>;
357 def AArch64fcmltz: SDNode<"AArch64ISD::FCMLTz", SDT_AArch64fcmpz>;
359 def AArch64bici: SDNode<"AArch64ISD::BICi", SDT_AArch64vecimm>;
360 def AArch64orri: SDNode<"AArch64ISD::ORRi", SDT_AArch64vecimm>;
362 def AArch64neg : SDNode<"AArch64ISD::NEG", SDT_AArch64unvec>;
364 def AArch64tcret: SDNode<"AArch64ISD::TC_RETURN", SDT_AArch64TCRET,
365 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
367 def AArch64Prefetch : SDNode<"AArch64ISD::PREFETCH", SDT_AArch64PREFETCH,
368 [SDNPHasChain, SDNPSideEffect]>;
370 def AArch64sitof: SDNode<"AArch64ISD::SITOF", SDT_AArch64ITOF>;
371 def AArch64uitof: SDNode<"AArch64ISD::UITOF", SDT_AArch64ITOF>;
373 def AArch64tlsdesc_callseq : SDNode<"AArch64ISD::TLSDESC_CALLSEQ",
374 SDT_AArch64TLSDescCallSeq,
375 [SDNPInGlue, SDNPOutGlue, SDNPHasChain,
379 def AArch64WrapperLarge : SDNode<"AArch64ISD::WrapperLarge",
380 SDT_AArch64WrapperLarge>;
382 def AArch64NvCast : SDNode<"AArch64ISD::NVCAST", SDTUnaryOp>;
384 def SDT_AArch64mull : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisInt<1>,
385 SDTCisSameAs<1, 2>]>;
386 def AArch64smull : SDNode<"AArch64ISD::SMULL", SDT_AArch64mull>;
387 def AArch64umull : SDNode<"AArch64ISD::UMULL", SDT_AArch64mull>;
389 def AArch64frecpe : SDNode<"AArch64ISD::FRECPE", SDTFPUnaryOp>;
390 def AArch64frecps : SDNode<"AArch64ISD::FRECPS", SDTFPBinOp>;
391 def AArch64frsqrte : SDNode<"AArch64ISD::FRSQRTE", SDTFPUnaryOp>;
392 def AArch64frsqrts : SDNode<"AArch64ISD::FRSQRTS", SDTFPBinOp>;
394 def AArch64saddv : SDNode<"AArch64ISD::SADDV", SDT_AArch64UnaryVec>;
395 def AArch64uaddv : SDNode<"AArch64ISD::UADDV", SDT_AArch64UnaryVec>;
396 def AArch64sminv : SDNode<"AArch64ISD::SMINV", SDT_AArch64UnaryVec>;
397 def AArch64uminv : SDNode<"AArch64ISD::UMINV", SDT_AArch64UnaryVec>;
398 def AArch64smaxv : SDNode<"AArch64ISD::SMAXV", SDT_AArch64UnaryVec>;
399 def AArch64umaxv : SDNode<"AArch64ISD::UMAXV", SDT_AArch64UnaryVec>;
401 //===----------------------------------------------------------------------===//
403 //===----------------------------------------------------------------------===//
405 // AArch64 Instruction Predicate Definitions.
406 // We could compute these on a per-module basis but doing so requires accessing
407 // the Function object through the <Target>Subtarget and objections were raised
408 // to that (see post-commit review comments for r301750).
409 let RecomputePerFunction = 1 in {
410 def ForCodeSize : Predicate<"MF->getFunction().optForSize()">;
411 def NotForCodeSize : Predicate<"!MF->getFunction().optForSize()">;
412 // Avoid generating STRQro if it is slow, unless we're optimizing for code size.
413 def UseSTRQro : Predicate<"!Subtarget->isSTRQroSlow() || MF->getFunction().optForSize()">;
415 def UseBTI : Predicate<[{ MF->getFunction().hasFnAttribute("branch-target-enforcement") }]>;
416 def NotUseBTI : Predicate<[{ !MF->getFunction().hasFnAttribute("branch-target-enforcement") }]>;
419 include "AArch64InstrFormats.td"
420 include "SVEInstrFormats.td"
422 //===----------------------------------------------------------------------===//
424 //===----------------------------------------------------------------------===//
425 // Miscellaneous instructions.
426 //===----------------------------------------------------------------------===//
428 let Defs = [SP], Uses = [SP], hasSideEffects = 1, isCodeGenOnly = 1 in {
429 // We set Sched to empty list because we expect these instructions to simply get
430 // removed in most cases.
431 def ADJCALLSTACKDOWN : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
432 [(AArch64callseq_start timm:$amt1, timm:$amt2)]>,
434 def ADJCALLSTACKUP : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
435 [(AArch64callseq_end timm:$amt1, timm:$amt2)]>,
437 } // Defs = [SP], Uses = [SP], hasSideEffects = 1, isCodeGenOnly = 1
439 let isReMaterializable = 1, isCodeGenOnly = 1 in {
440 // FIXME: The following pseudo instructions are only needed because remat
441 // cannot handle multiple instructions. When that changes, they can be
442 // removed, along with the AArch64Wrapper node.
444 let AddedComplexity = 10 in
445 def LOADgot : Pseudo<(outs GPR64:$dst), (ins i64imm:$addr),
446 [(set GPR64:$dst, (AArch64LOADgot tglobaladdr:$addr))]>,
449 // The MOVaddr instruction should match only when the add is not folded
450 // into a load or store address.
452 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
453 [(set GPR64:$dst, (AArch64addlow (AArch64adrp tglobaladdr:$hi),
454 tglobaladdr:$low))]>,
455 Sched<[WriteAdrAdr]>;
457 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
458 [(set GPR64:$dst, (AArch64addlow (AArch64adrp tjumptable:$hi),
460 Sched<[WriteAdrAdr]>;
462 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
463 [(set GPR64:$dst, (AArch64addlow (AArch64adrp tconstpool:$hi),
465 Sched<[WriteAdrAdr]>;
467 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
468 [(set GPR64:$dst, (AArch64addlow (AArch64adrp tblockaddress:$hi),
469 tblockaddress:$low))]>,
470 Sched<[WriteAdrAdr]>;
472 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
473 [(set GPR64:$dst, (AArch64addlow (AArch64adrp tglobaltlsaddr:$hi),
474 tglobaltlsaddr:$low))]>,
475 Sched<[WriteAdrAdr]>;
477 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
478 [(set GPR64:$dst, (AArch64addlow (AArch64adrp texternalsym:$hi),
479 texternalsym:$low))]>,
480 Sched<[WriteAdrAdr]>;
481 // Normally AArch64addlow either gets folded into a following ldr/str,
482 // or together with an adrp into MOVaddr above. For cases with TLS, it
483 // might appear without either of them, so allow lowering it into a plain
486 : Pseudo<(outs GPR64:$dst), (ins GPR64:$src, i64imm:$low),
487 [(set GPR64:$dst, (AArch64addlow GPR64:$src,
488 tglobaltlsaddr:$low))]>,
491 } // isReMaterializable, isCodeGenOnly
493 def : Pat<(AArch64LOADgot tglobaltlsaddr:$addr),
494 (LOADgot tglobaltlsaddr:$addr)>;
496 def : Pat<(AArch64LOADgot texternalsym:$addr),
497 (LOADgot texternalsym:$addr)>;
499 def : Pat<(AArch64LOADgot tconstpool:$addr),
500 (LOADgot tconstpool:$addr)>;
502 // 32-bit jump table destination is actually only 2 instructions since we can
503 // use the table itself as a PC-relative base. But optimization occurs after
504 // branch relaxation so be pessimistic.
505 let Size = 12, Constraints = "@earlyclobber $dst,@earlyclobber $scratch" in {
506 def JumpTableDest32 : Pseudo<(outs GPR64:$dst, GPR64sp:$scratch),
507 (ins GPR64:$table, GPR64:$entry, i32imm:$jti), []>,
509 def JumpTableDest16 : Pseudo<(outs GPR64:$dst, GPR64sp:$scratch),
510 (ins GPR64:$table, GPR64:$entry, i32imm:$jti), []>,
512 def JumpTableDest8 : Pseudo<(outs GPR64:$dst, GPR64sp:$scratch),
513 (ins GPR64:$table, GPR64:$entry, i32imm:$jti), []>,
517 // Space-consuming pseudo to aid testing of placement and reachability
518 // algorithms. Immediate operand is the number of bytes this "instruction"
519 // occupies; register operands can be used to enforce dependency and constrain
521 let hasSideEffects = 1, mayLoad = 1, mayStore = 1 in
522 def SPACE : Pseudo<(outs GPR64:$Rd), (ins i32imm:$size, GPR64:$Rn),
523 [(set GPR64:$Rd, (int_aarch64_space imm:$size, GPR64:$Rn))]>,
526 let hasSideEffects = 1, isCodeGenOnly = 1 in {
527 def SpeculationSafeValueX
528 : Pseudo<(outs GPR64:$dst), (ins GPR64:$src), []>, Sched<[]>;
529 def SpeculationSafeValueW
530 : Pseudo<(outs GPR32:$dst), (ins GPR32:$src), []>, Sched<[]>;
534 //===----------------------------------------------------------------------===//
535 // System instructions.
536 //===----------------------------------------------------------------------===//
538 def HINT : HintI<"hint">;
539 def : InstAlias<"nop", (HINT 0b000)>;
540 def : InstAlias<"yield",(HINT 0b001)>;
541 def : InstAlias<"wfe", (HINT 0b010)>;
542 def : InstAlias<"wfi", (HINT 0b011)>;
543 def : InstAlias<"sev", (HINT 0b100)>;
544 def : InstAlias<"sevl", (HINT 0b101)>;
545 def : InstAlias<"esb", (HINT 0b10000)>, Requires<[HasRAS]>;
546 def : InstAlias<"csdb", (HINT 20)>;
547 def : InstAlias<"bti", (HINT 32)>, Requires<[HasBTI]>;
548 def : InstAlias<"bti $op", (HINT btihint_op:$op)>, Requires<[HasBTI]>;
550 // v8.2a Statistical Profiling extension
551 def : InstAlias<"psb $op", (HINT psbhint_op:$op)>, Requires<[HasSPE]>;
553 // As far as LLVM is concerned this writes to the system's exclusive monitors.
554 let mayLoad = 1, mayStore = 1 in
555 def CLREX : CRmSystemI<imm0_15, 0b010, "clrex">;
557 // NOTE: ideally, this would have mayStore = 0, mayLoad = 0, but we cannot
558 // model patterns with sufficiently fine granularity.
559 let mayLoad = ?, mayStore = ? in {
560 def DMB : CRmSystemI<barrier_op, 0b101, "dmb",
561 [(int_aarch64_dmb (i32 imm32_0_15:$CRm))]>;
563 def DSB : CRmSystemI<barrier_op, 0b100, "dsb",
564 [(int_aarch64_dsb (i32 imm32_0_15:$CRm))]>;
566 def ISB : CRmSystemI<barrier_op, 0b110, "isb",
567 [(int_aarch64_isb (i32 imm32_0_15:$CRm))]>;
569 def TSB : CRmSystemI<barrier_op, 0b010, "tsb", []> {
572 let Predicates = [HasTRACEV8_4];
576 // ARMv8.2-A Dot Product
577 let Predicates = [HasDotProd] in {
578 defm SDOT : SIMDThreeSameVectorDot<0, "sdot", int_aarch64_neon_sdot>;
579 defm UDOT : SIMDThreeSameVectorDot<1, "udot", int_aarch64_neon_udot>;
580 defm SDOTlane : SIMDThreeSameVectorDotIndex<0, "sdot", int_aarch64_neon_sdot>;
581 defm UDOTlane : SIMDThreeSameVectorDotIndex<1, "udot", int_aarch64_neon_udot>;
584 // ARMv8.2-A FP16 Fused Multiply-Add Long
585 let Predicates = [HasNEON, HasFP16FML] in {
586 defm FMLAL : SIMDThreeSameVectorFML<0, 1, 0b001, "fmlal", int_aarch64_neon_fmlal>;
587 defm FMLSL : SIMDThreeSameVectorFML<0, 1, 0b101, "fmlsl", int_aarch64_neon_fmlsl>;
588 defm FMLAL2 : SIMDThreeSameVectorFML<1, 0, 0b001, "fmlal2", int_aarch64_neon_fmlal2>;
589 defm FMLSL2 : SIMDThreeSameVectorFML<1, 0, 0b101, "fmlsl2", int_aarch64_neon_fmlsl2>;
590 defm FMLALlane : SIMDThreeSameVectorFMLIndex<0, 0b0000, "fmlal", int_aarch64_neon_fmlal>;
591 defm FMLSLlane : SIMDThreeSameVectorFMLIndex<0, 0b0100, "fmlsl", int_aarch64_neon_fmlsl>;
592 defm FMLAL2lane : SIMDThreeSameVectorFMLIndex<1, 0b1000, "fmlal2", int_aarch64_neon_fmlal2>;
593 defm FMLSL2lane : SIMDThreeSameVectorFMLIndex<1, 0b1100, "fmlsl2", int_aarch64_neon_fmlsl2>;
596 // Armv8.2-A Crypto extensions
597 let Predicates = [HasSHA3] in {
598 def SHA512H : CryptoRRRTied<0b0, 0b00, "sha512h">;
599 def SHA512H2 : CryptoRRRTied<0b0, 0b01, "sha512h2">;
600 def SHA512SU0 : CryptoRRTied_2D<0b0, 0b00, "sha512su0">;
601 def SHA512SU1 : CryptoRRRTied_2D<0b0, 0b10, "sha512su1">;
602 def RAX1 : CryptoRRR_2D<0b0,0b11, "rax1">;
603 def EOR3 : CryptoRRRR_16B<0b00, "eor3">;
604 def BCAX : CryptoRRRR_16B<0b01, "bcax">;
605 def XAR : CryptoRRRi6<"xar">;
608 let Predicates = [HasSM4] in {
609 def SM3TT1A : CryptoRRRi2Tied<0b0, 0b00, "sm3tt1a">;
610 def SM3TT1B : CryptoRRRi2Tied<0b0, 0b01, "sm3tt1b">;
611 def SM3TT2A : CryptoRRRi2Tied<0b0, 0b10, "sm3tt2a">;
612 def SM3TT2B : CryptoRRRi2Tied<0b0, 0b11, "sm3tt2b">;
613 def SM3SS1 : CryptoRRRR_4S<0b10, "sm3ss1">;
614 def SM3PARTW1 : CryptoRRRTied_4S<0b1, 0b00, "sm3partw1">;
615 def SM3PARTW2 : CryptoRRRTied_4S<0b1, 0b01, "sm3partw2">;
616 def SM4ENCKEY : CryptoRRR_4S<0b1, 0b10, "sm4ekey">;
617 def SM4E : CryptoRRTied_4S<0b0, 0b01, "sm4e">;
620 let Predicates = [HasRCPC] in {
621 // v8.3 Release Consistent Processor Consistent support, optional in v8.2.
622 def LDAPRB : RCPCLoad<0b00, "ldaprb", GPR32>;
623 def LDAPRH : RCPCLoad<0b01, "ldaprh", GPR32>;
624 def LDAPRW : RCPCLoad<0b10, "ldapr", GPR32>;
625 def LDAPRX : RCPCLoad<0b11, "ldapr", GPR64>;
628 // v8.3a complex add and multiply-accumulate. No predicate here, that is done
629 // inside the multiclass as the FP16 versions need different predicates.
630 defm FCMLA : SIMDThreeSameVectorTiedComplexHSD<1, 0b110, complexrotateop,
632 defm FCADD : SIMDThreeSameVectorComplexHSD<1, 0b111, complexrotateopodd,
634 defm FCMLA : SIMDIndexedTiedComplexHSD<1, 0, 1, complexrotateop, "fcmla",
637 // v8.3a Pointer Authentication
638 // These instructions inhabit part of the hint space and so can be used for
640 let Uses = [LR], Defs = [LR] in {
641 def PACIAZ : SystemNoOperands<0b000, "paciaz">;
642 def PACIBZ : SystemNoOperands<0b010, "pacibz">;
643 def AUTIAZ : SystemNoOperands<0b100, "autiaz">;
644 def AUTIBZ : SystemNoOperands<0b110, "autibz">;
646 let Uses = [LR, SP], Defs = [LR] in {
647 def PACIASP : SystemNoOperands<0b001, "paciasp">;
648 def PACIBSP : SystemNoOperands<0b011, "pacibsp">;
649 def AUTIASP : SystemNoOperands<0b101, "autiasp">;
650 def AUTIBSP : SystemNoOperands<0b111, "autibsp">;
652 let Uses = [X16, X17], Defs = [X17], CRm = 0b0001 in {
653 def PACIA1716 : SystemNoOperands<0b000, "pacia1716">;
654 def PACIB1716 : SystemNoOperands<0b010, "pacib1716">;
655 def AUTIA1716 : SystemNoOperands<0b100, "autia1716">;
656 def AUTIB1716 : SystemNoOperands<0b110, "autib1716">;
659 let Uses = [LR], Defs = [LR], CRm = 0b0000 in {
660 def XPACLRI : SystemNoOperands<0b111, "xpaclri">;
663 // These pointer authentication isntructions require armv8.3a
664 let Predicates = [HasPA] in {
665 multiclass SignAuth<bits<3> prefix, bits<3> prefix_z, string asm> {
666 def IA : SignAuthOneData<prefix, 0b00, !strconcat(asm, "ia")>;
667 def IB : SignAuthOneData<prefix, 0b01, !strconcat(asm, "ib")>;
668 def DA : SignAuthOneData<prefix, 0b10, !strconcat(asm, "da")>;
669 def DB : SignAuthOneData<prefix, 0b11, !strconcat(asm, "db")>;
670 def IZA : SignAuthZero<prefix_z, 0b00, !strconcat(asm, "iza")>;
671 def DZA : SignAuthZero<prefix_z, 0b10, !strconcat(asm, "dza")>;
672 def IZB : SignAuthZero<prefix_z, 0b01, !strconcat(asm, "izb")>;
673 def DZB : SignAuthZero<prefix_z, 0b11, !strconcat(asm, "dzb")>;
676 defm PAC : SignAuth<0b000, 0b010, "pac">;
677 defm AUT : SignAuth<0b001, 0b011, "aut">;
679 def XPACI : SignAuthZero<0b100, 0b00, "xpaci">;
680 def XPACD : SignAuthZero<0b100, 0b01, "xpacd">;
681 def PACGA : SignAuthTwoOperand<0b1100, "pacga", null_frag>;
683 // Combined Instructions
684 def BRAA : AuthBranchTwoOperands<0, 0, "braa">;
685 def BRAB : AuthBranchTwoOperands<0, 1, "brab">;
686 def BLRAA : AuthBranchTwoOperands<1, 0, "blraa">;
687 def BLRAB : AuthBranchTwoOperands<1, 1, "blrab">;
689 def BRAAZ : AuthOneOperand<0b000, 0, "braaz">;
690 def BRABZ : AuthOneOperand<0b000, 1, "brabz">;
691 def BLRAAZ : AuthOneOperand<0b001, 0, "blraaz">;
692 def BLRABZ : AuthOneOperand<0b001, 1, "blrabz">;
694 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
695 def RETAA : AuthReturn<0b010, 0, "retaa">;
696 def RETAB : AuthReturn<0b010, 1, "retab">;
697 def ERETAA : AuthReturn<0b100, 0, "eretaa">;
698 def ERETAB : AuthReturn<0b100, 1, "eretab">;
701 defm LDRAA : AuthLoad<0, "ldraa", simm10Scaled>;
702 defm LDRAB : AuthLoad<1, "ldrab", simm10Scaled>;
706 // v8.3a floating point conversion for javascript
707 let Predicates = [HasJS, HasFPARMv8] in
708 def FJCVTZS : BaseFPToIntegerUnscaled<0b01, 0b11, 0b110, FPR64, GPR32,
711 } // HasJS, HasFPARMv8
713 // v8.4 Flag manipulation instructions
714 let Predicates = [HasFMI] in {
715 def CFINV : SimpleSystemI<0, (ins), "cfinv", "">, Sched<[WriteSys]> {
716 let Inst{20-5} = 0b0000001000000000;
718 def SETF8 : BaseFlagManipulation<0, 0, (ins GPR32:$Rn), "setf8", "{\t$Rn}">;
719 def SETF16 : BaseFlagManipulation<0, 1, (ins GPR32:$Rn), "setf16", "{\t$Rn}">;
720 def RMIF : FlagRotate<(ins GPR64:$Rn, uimm6:$imm, imm0_15:$mask), "rmif",
721 "{\t$Rn, $imm, $mask}">;
724 // v8.5 flag manipulation instructions
725 let Predicates = [HasAltNZCV], Uses = [NZCV], Defs = [NZCV] in {
727 def XAFLAG : PstateWriteSimple<(ins), "xaflag", "">, Sched<[WriteSys]> {
728 let Inst{18-16} = 0b000;
729 let Inst{11-8} = 0b0000;
730 let Unpredictable{11-8} = 0b1111;
731 let Inst{7-5} = 0b001;
734 def AXFLAG : PstateWriteSimple<(ins), "axflag", "">, Sched<[WriteSys]> {
735 let Inst{18-16} = 0b000;
736 let Inst{11-8} = 0b0000;
737 let Unpredictable{11-8} = 0b1111;
738 let Inst{7-5} = 0b010;
743 // Armv8.5-A speculation barrier
744 def SB : SimpleSystemI<0, (ins), "sb", "">, Sched<[]> {
745 let Inst{20-5} = 0b0001100110000111;
746 let Unpredictable{11-8} = 0b1111;
747 let Predicates = [HasSB];
748 let hasSideEffects = 1;
751 def : InstAlias<"clrex", (CLREX 0xf)>;
752 def : InstAlias<"isb", (ISB 0xf)>;
753 def : InstAlias<"ssbb", (DSB 0)>;
754 def : InstAlias<"pssbb", (DSB 4)>;
758 def MSRpstateImm1 : MSRpstateImm0_1;
759 def MSRpstateImm4 : MSRpstateImm0_15;
761 // The thread pointer (on Linux, at least, where this has been implemented) is
763 def MOVbaseTLS : Pseudo<(outs GPR64:$dst), (ins),
764 [(set GPR64:$dst, AArch64threadpointer)]>, Sched<[WriteSys]>;
766 let Uses = [ X9 ], Defs = [ X16, X17, LR, NZCV ] in {
767 def HWASAN_CHECK_MEMACCESS : Pseudo<
768 (outs), (ins GPR64noip:$ptr, i32imm:$accessinfo),
769 [(int_hwasan_check_memaccess X9, GPR64noip:$ptr, (i32 imm:$accessinfo))]>,
773 // The cycle counter PMC register is PMCCNTR_EL0.
774 let Predicates = [HasPerfMon] in
775 def : Pat<(readcyclecounter), (MRS 0xdce8)>;
778 def : Pat<(i64 (int_aarch64_get_fpcr)), (MRS 0xda20)>;
780 // Generic system instructions
781 def SYSxt : SystemXtI<0, "sys">;
782 def SYSLxt : SystemLXtI<1, "sysl">;
784 def : InstAlias<"sys $op1, $Cn, $Cm, $op2",
785 (SYSxt imm0_7:$op1, sys_cr_op:$Cn,
786 sys_cr_op:$Cm, imm0_7:$op2, XZR)>;
788 //===----------------------------------------------------------------------===//
789 // Move immediate instructions.
790 //===----------------------------------------------------------------------===//
792 defm MOVK : InsertImmediate<0b11, "movk">;
793 defm MOVN : MoveImmediate<0b00, "movn">;
795 let PostEncoderMethod = "fixMOVZ" in
796 defm MOVZ : MoveImmediate<0b10, "movz">;
798 // First group of aliases covers an implicit "lsl #0".
799 def : InstAlias<"movk $dst, $imm", (MOVKWi GPR32:$dst, imm0_65535:$imm, 0), 0>;
800 def : InstAlias<"movk $dst, $imm", (MOVKXi GPR64:$dst, imm0_65535:$imm, 0), 0>;
801 def : InstAlias<"movn $dst, $imm", (MOVNWi GPR32:$dst, imm0_65535:$imm, 0)>;
802 def : InstAlias<"movn $dst, $imm", (MOVNXi GPR64:$dst, imm0_65535:$imm, 0)>;
803 def : InstAlias<"movz $dst, $imm", (MOVZWi GPR32:$dst, imm0_65535:$imm, 0)>;
804 def : InstAlias<"movz $dst, $imm", (MOVZXi GPR64:$dst, imm0_65535:$imm, 0)>;
806 // Next, we have various ELF relocations with the ":XYZ_g0:sym" syntax.
807 def : InstAlias<"movz $Rd, $sym", (MOVZXi GPR64:$Rd, movz_symbol_g3:$sym, 48)>;
808 def : InstAlias<"movz $Rd, $sym", (MOVZXi GPR64:$Rd, movz_symbol_g2:$sym, 32)>;
809 def : InstAlias<"movz $Rd, $sym", (MOVZXi GPR64:$Rd, movz_symbol_g1:$sym, 16)>;
810 def : InstAlias<"movz $Rd, $sym", (MOVZXi GPR64:$Rd, movz_symbol_g0:$sym, 0)>;
812 def : InstAlias<"movn $Rd, $sym", (MOVNXi GPR64:$Rd, movz_symbol_g3:$sym, 48)>;
813 def : InstAlias<"movn $Rd, $sym", (MOVNXi GPR64:$Rd, movz_symbol_g2:$sym, 32)>;
814 def : InstAlias<"movn $Rd, $sym", (MOVNXi GPR64:$Rd, movz_symbol_g1:$sym, 16)>;
815 def : InstAlias<"movn $Rd, $sym", (MOVNXi GPR64:$Rd, movz_symbol_g0:$sym, 0)>;
817 def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movk_symbol_g3:$sym, 48), 0>;
818 def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movk_symbol_g2:$sym, 32), 0>;
819 def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movk_symbol_g1:$sym, 16), 0>;
820 def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movk_symbol_g0:$sym, 0), 0>;
822 def : InstAlias<"movz $Rd, $sym", (MOVZWi GPR32:$Rd, movz_symbol_g1:$sym, 16)>;
823 def : InstAlias<"movz $Rd, $sym", (MOVZWi GPR32:$Rd, movz_symbol_g0:$sym, 0)>;
825 def : InstAlias<"movn $Rd, $sym", (MOVNWi GPR32:$Rd, movz_symbol_g1:$sym, 16)>;
826 def : InstAlias<"movn $Rd, $sym", (MOVNWi GPR32:$Rd, movz_symbol_g0:$sym, 0)>;
828 def : InstAlias<"movk $Rd, $sym", (MOVKWi GPR32:$Rd, movk_symbol_g1:$sym, 16), 0>;
829 def : InstAlias<"movk $Rd, $sym", (MOVKWi GPR32:$Rd, movk_symbol_g0:$sym, 0), 0>;
831 // Final group of aliases covers true "mov $Rd, $imm" cases.
832 multiclass movw_mov_alias<string basename,Instruction INST, RegisterClass GPR,
833 int width, int shift> {
834 def _asmoperand : AsmOperandClass {
835 let Name = basename # width # "_lsl" # shift # "MovAlias";
836 let PredicateMethod = "is" # basename # "MovAlias<" # width # ", "
838 let RenderMethod = "add" # basename # "MovAliasOperands<" # shift # ">";
841 def _movimm : Operand<i32> {
842 let ParserMatchClass = !cast<AsmOperandClass>(NAME # "_asmoperand");
845 def : InstAlias<"mov $Rd, $imm",
846 (INST GPR:$Rd, !cast<Operand>(NAME # "_movimm"):$imm, shift)>;
849 defm : movw_mov_alias<"MOVZ", MOVZWi, GPR32, 32, 0>;
850 defm : movw_mov_alias<"MOVZ", MOVZWi, GPR32, 32, 16>;
852 defm : movw_mov_alias<"MOVZ", MOVZXi, GPR64, 64, 0>;
853 defm : movw_mov_alias<"MOVZ", MOVZXi, GPR64, 64, 16>;
854 defm : movw_mov_alias<"MOVZ", MOVZXi, GPR64, 64, 32>;
855 defm : movw_mov_alias<"MOVZ", MOVZXi, GPR64, 64, 48>;
857 defm : movw_mov_alias<"MOVN", MOVNWi, GPR32, 32, 0>;
858 defm : movw_mov_alias<"MOVN", MOVNWi, GPR32, 32, 16>;
860 defm : movw_mov_alias<"MOVN", MOVNXi, GPR64, 64, 0>;
861 defm : movw_mov_alias<"MOVN", MOVNXi, GPR64, 64, 16>;
862 defm : movw_mov_alias<"MOVN", MOVNXi, GPR64, 64, 32>;
863 defm : movw_mov_alias<"MOVN", MOVNXi, GPR64, 64, 48>;
865 let isReMaterializable = 1, isCodeGenOnly = 1, isMoveImm = 1,
866 isAsCheapAsAMove = 1 in {
867 // FIXME: The following pseudo instructions are only needed because remat
868 // cannot handle multiple instructions. When that changes, we can select
869 // directly to the real instructions and get rid of these pseudos.
872 : Pseudo<(outs GPR32:$dst), (ins i32imm:$src),
873 [(set GPR32:$dst, imm:$src)]>,
876 : Pseudo<(outs GPR64:$dst), (ins i64imm:$src),
877 [(set GPR64:$dst, imm:$src)]>,
879 } // isReMaterializable, isCodeGenOnly
881 // If possible, we want to use MOVi32imm even for 64-bit moves. This gives the
882 // eventual expansion code fewer bits to worry about getting right. Marshalling
883 // the types is a little tricky though:
884 def i64imm_32bit : ImmLeaf<i64, [{
885 return (Imm & 0xffffffffULL) == static_cast<uint64_t>(Imm);
888 def s64imm_32bit : ImmLeaf<i64, [{
889 int64_t Imm64 = static_cast<int64_t>(Imm);
890 return Imm64 >= std::numeric_limits<int32_t>::min() &&
891 Imm64 <= std::numeric_limits<int32_t>::max();
894 def trunc_imm : SDNodeXForm<imm, [{
895 return CurDAG->getTargetConstant(N->getZExtValue(), SDLoc(N), MVT::i32);
898 def gi_trunc_imm : GICustomOperandRenderer<"renderTruncImm">,
899 GISDNodeXFormEquiv<trunc_imm>;
901 def : Pat<(i64 i64imm_32bit:$src),
902 (SUBREG_TO_REG (i64 0), (MOVi32imm (trunc_imm imm:$src)), sub_32)>;
904 // Materialize FP constants via MOVi32imm/MOVi64imm (MachO large code model).
905 def bitcast_fpimm_to_i32 : SDNodeXForm<fpimm, [{
906 return CurDAG->getTargetConstant(
907 N->getValueAPF().bitcastToAPInt().getZExtValue(), SDLoc(N), MVT::i32);
910 def bitcast_fpimm_to_i64 : SDNodeXForm<fpimm, [{
911 return CurDAG->getTargetConstant(
912 N->getValueAPF().bitcastToAPInt().getZExtValue(), SDLoc(N), MVT::i64);
916 def : Pat<(f32 fpimm:$in),
917 (COPY_TO_REGCLASS (MOVi32imm (bitcast_fpimm_to_i32 f32:$in)), FPR32)>;
918 def : Pat<(f64 fpimm:$in),
919 (COPY_TO_REGCLASS (MOVi64imm (bitcast_fpimm_to_i64 f64:$in)), FPR64)>;
922 // Deal with the various forms of (ELF) large addressing with MOVZ/MOVK
924 def : Pat<(AArch64WrapperLarge tglobaladdr:$g3, tglobaladdr:$g2,
925 tglobaladdr:$g1, tglobaladdr:$g0),
926 (MOVKXi (MOVKXi (MOVKXi (MOVZXi tglobaladdr:$g0, 0),
927 tglobaladdr:$g1, 16),
928 tglobaladdr:$g2, 32),
929 tglobaladdr:$g3, 48)>;
931 def : Pat<(AArch64WrapperLarge tblockaddress:$g3, tblockaddress:$g2,
932 tblockaddress:$g1, tblockaddress:$g0),
933 (MOVKXi (MOVKXi (MOVKXi (MOVZXi tblockaddress:$g0, 0),
934 tblockaddress:$g1, 16),
935 tblockaddress:$g2, 32),
936 tblockaddress:$g3, 48)>;
938 def : Pat<(AArch64WrapperLarge tconstpool:$g3, tconstpool:$g2,
939 tconstpool:$g1, tconstpool:$g0),
940 (MOVKXi (MOVKXi (MOVKXi (MOVZXi tconstpool:$g0, 0),
943 tconstpool:$g3, 48)>;
945 def : Pat<(AArch64WrapperLarge tjumptable:$g3, tjumptable:$g2,
946 tjumptable:$g1, tjumptable:$g0),
947 (MOVKXi (MOVKXi (MOVKXi (MOVZXi tjumptable:$g0, 0),
950 tjumptable:$g3, 48)>;
953 //===----------------------------------------------------------------------===//
954 // Arithmetic instructions.
955 //===----------------------------------------------------------------------===//
957 // Add/subtract with carry.
958 defm ADC : AddSubCarry<0, "adc", "adcs", AArch64adc, AArch64adc_flag>;
959 defm SBC : AddSubCarry<1, "sbc", "sbcs", AArch64sbc, AArch64sbc_flag>;
961 def : InstAlias<"ngc $dst, $src", (SBCWr GPR32:$dst, WZR, GPR32:$src)>;
962 def : InstAlias<"ngc $dst, $src", (SBCXr GPR64:$dst, XZR, GPR64:$src)>;
963 def : InstAlias<"ngcs $dst, $src", (SBCSWr GPR32:$dst, WZR, GPR32:$src)>;
964 def : InstAlias<"ngcs $dst, $src", (SBCSXr GPR64:$dst, XZR, GPR64:$src)>;
967 defm ADD : AddSub<0, "add", "sub", add>;
968 defm SUB : AddSub<1, "sub", "add">;
970 def : InstAlias<"mov $dst, $src",
971 (ADDWri GPR32sponly:$dst, GPR32sp:$src, 0, 0)>;
972 def : InstAlias<"mov $dst, $src",
973 (ADDWri GPR32sp:$dst, GPR32sponly:$src, 0, 0)>;
974 def : InstAlias<"mov $dst, $src",
975 (ADDXri GPR64sponly:$dst, GPR64sp:$src, 0, 0)>;
976 def : InstAlias<"mov $dst, $src",
977 (ADDXri GPR64sp:$dst, GPR64sponly:$src, 0, 0)>;
979 defm ADDS : AddSubS<0, "adds", AArch64add_flag, "cmn", "subs", "cmp">;
980 defm SUBS : AddSubS<1, "subs", AArch64sub_flag, "cmp", "adds", "cmn">;
982 // Use SUBS instead of SUB to enable CSE between SUBS and SUB.
983 def : Pat<(sub GPR32sp:$Rn, addsub_shifted_imm32:$imm),
984 (SUBSWri GPR32sp:$Rn, addsub_shifted_imm32:$imm)>;
985 def : Pat<(sub GPR64sp:$Rn, addsub_shifted_imm64:$imm),
986 (SUBSXri GPR64sp:$Rn, addsub_shifted_imm64:$imm)>;
987 def : Pat<(sub GPR32:$Rn, GPR32:$Rm),
988 (SUBSWrr GPR32:$Rn, GPR32:$Rm)>;
989 def : Pat<(sub GPR64:$Rn, GPR64:$Rm),
990 (SUBSXrr GPR64:$Rn, GPR64:$Rm)>;
991 def : Pat<(sub GPR32:$Rn, arith_shifted_reg32:$Rm),
992 (SUBSWrs GPR32:$Rn, arith_shifted_reg32:$Rm)>;
993 def : Pat<(sub GPR64:$Rn, arith_shifted_reg64:$Rm),
994 (SUBSXrs GPR64:$Rn, arith_shifted_reg64:$Rm)>;
995 let AddedComplexity = 1 in {
996 def : Pat<(sub GPR32sp:$R2, arith_extended_reg32<i32>:$R3),
997 (SUBSWrx GPR32sp:$R2, arith_extended_reg32<i32>:$R3)>;
998 def : Pat<(sub GPR64sp:$R2, arith_extended_reg32to64<i64>:$R3),
999 (SUBSXrx GPR64sp:$R2, arith_extended_reg32to64<i64>:$R3)>;
1002 // Because of the immediate format for add/sub-imm instructions, the
1003 // expression (add x, -1) must be transformed to (SUB{W,X}ri x, 1).
1004 // These patterns capture that transformation.
1005 let AddedComplexity = 1 in {
1006 def : Pat<(add GPR32:$Rn, neg_addsub_shifted_imm32:$imm),
1007 (SUBSWri GPR32:$Rn, neg_addsub_shifted_imm32:$imm)>;
1008 def : Pat<(add GPR64:$Rn, neg_addsub_shifted_imm64:$imm),
1009 (SUBSXri GPR64:$Rn, neg_addsub_shifted_imm64:$imm)>;
1010 def : Pat<(sub GPR32:$Rn, neg_addsub_shifted_imm32:$imm),
1011 (ADDWri GPR32:$Rn, neg_addsub_shifted_imm32:$imm)>;
1012 def : Pat<(sub GPR64:$Rn, neg_addsub_shifted_imm64:$imm),
1013 (ADDXri GPR64:$Rn, neg_addsub_shifted_imm64:$imm)>;
1016 // Because of the immediate format for add/sub-imm instructions, the
1017 // expression (add x, -1) must be transformed to (SUB{W,X}ri x, 1).
1018 // These patterns capture that transformation.
1019 let AddedComplexity = 1 in {
1020 def : Pat<(AArch64add_flag GPR32:$Rn, neg_addsub_shifted_imm32:$imm),
1021 (SUBSWri GPR32:$Rn, neg_addsub_shifted_imm32:$imm)>;
1022 def : Pat<(AArch64add_flag GPR64:$Rn, neg_addsub_shifted_imm64:$imm),
1023 (SUBSXri GPR64:$Rn, neg_addsub_shifted_imm64:$imm)>;
1024 def : Pat<(AArch64sub_flag GPR32:$Rn, neg_addsub_shifted_imm32:$imm),
1025 (ADDSWri GPR32:$Rn, neg_addsub_shifted_imm32:$imm)>;
1026 def : Pat<(AArch64sub_flag GPR64:$Rn, neg_addsub_shifted_imm64:$imm),
1027 (ADDSXri GPR64:$Rn, neg_addsub_shifted_imm64:$imm)>;
1030 def : InstAlias<"neg $dst, $src", (SUBWrs GPR32:$dst, WZR, GPR32:$src, 0), 3>;
1031 def : InstAlias<"neg $dst, $src", (SUBXrs GPR64:$dst, XZR, GPR64:$src, 0), 3>;
1032 def : InstAlias<"neg $dst, $src$shift",
1033 (SUBWrs GPR32:$dst, WZR, GPR32:$src, arith_shift32:$shift), 2>;
1034 def : InstAlias<"neg $dst, $src$shift",
1035 (SUBXrs GPR64:$dst, XZR, GPR64:$src, arith_shift64:$shift), 2>;
1037 def : InstAlias<"negs $dst, $src", (SUBSWrs GPR32:$dst, WZR, GPR32:$src, 0), 3>;
1038 def : InstAlias<"negs $dst, $src", (SUBSXrs GPR64:$dst, XZR, GPR64:$src, 0), 3>;
1039 def : InstAlias<"negs $dst, $src$shift",
1040 (SUBSWrs GPR32:$dst, WZR, GPR32:$src, arith_shift32:$shift), 2>;
1041 def : InstAlias<"negs $dst, $src$shift",
1042 (SUBSXrs GPR64:$dst, XZR, GPR64:$src, arith_shift64:$shift), 2>;
1045 // Unsigned/Signed divide
1046 defm UDIV : Div<0, "udiv", udiv>;
1047 defm SDIV : Div<1, "sdiv", sdiv>;
1049 def : Pat<(int_aarch64_udiv GPR32:$Rn, GPR32:$Rm), (UDIVWr GPR32:$Rn, GPR32:$Rm)>;
1050 def : Pat<(int_aarch64_udiv GPR64:$Rn, GPR64:$Rm), (UDIVXr GPR64:$Rn, GPR64:$Rm)>;
1051 def : Pat<(int_aarch64_sdiv GPR32:$Rn, GPR32:$Rm), (SDIVWr GPR32:$Rn, GPR32:$Rm)>;
1052 def : Pat<(int_aarch64_sdiv GPR64:$Rn, GPR64:$Rm), (SDIVXr GPR64:$Rn, GPR64:$Rm)>;
1055 defm ASRV : Shift<0b10, "asr", sra>;
1056 defm LSLV : Shift<0b00, "lsl", shl>;
1057 defm LSRV : Shift<0b01, "lsr", srl>;
1058 defm RORV : Shift<0b11, "ror", rotr>;
1060 def : ShiftAlias<"asrv", ASRVWr, GPR32>;
1061 def : ShiftAlias<"asrv", ASRVXr, GPR64>;
1062 def : ShiftAlias<"lslv", LSLVWr, GPR32>;
1063 def : ShiftAlias<"lslv", LSLVXr, GPR64>;
1064 def : ShiftAlias<"lsrv", LSRVWr, GPR32>;
1065 def : ShiftAlias<"lsrv", LSRVXr, GPR64>;
1066 def : ShiftAlias<"rorv", RORVWr, GPR32>;
1067 def : ShiftAlias<"rorv", RORVXr, GPR64>;
1070 let AddedComplexity = 5 in {
1071 defm MADD : MulAccum<0, "madd", add>;
1072 defm MSUB : MulAccum<1, "msub", sub>;
1074 def : Pat<(i32 (mul GPR32:$Rn, GPR32:$Rm)),
1075 (MADDWrrr GPR32:$Rn, GPR32:$Rm, WZR)>;
1076 def : Pat<(i64 (mul GPR64:$Rn, GPR64:$Rm)),
1077 (MADDXrrr GPR64:$Rn, GPR64:$Rm, XZR)>;
1079 def : Pat<(i32 (ineg (mul GPR32:$Rn, GPR32:$Rm))),
1080 (MSUBWrrr GPR32:$Rn, GPR32:$Rm, WZR)>;
1081 def : Pat<(i64 (ineg (mul GPR64:$Rn, GPR64:$Rm))),
1082 (MSUBXrrr GPR64:$Rn, GPR64:$Rm, XZR)>;
1083 def : Pat<(i32 (mul (ineg GPR32:$Rn), GPR32:$Rm)),
1084 (MSUBWrrr GPR32:$Rn, GPR32:$Rm, WZR)>;
1085 def : Pat<(i64 (mul (ineg GPR64:$Rn), GPR64:$Rm)),
1086 (MSUBXrrr GPR64:$Rn, GPR64:$Rm, XZR)>;
1087 } // AddedComplexity = 5
1089 let AddedComplexity = 5 in {
1090 def SMADDLrrr : WideMulAccum<0, 0b001, "smaddl", add, sext>;
1091 def SMSUBLrrr : WideMulAccum<1, 0b001, "smsubl", sub, sext>;
1092 def UMADDLrrr : WideMulAccum<0, 0b101, "umaddl", add, zext>;
1093 def UMSUBLrrr : WideMulAccum<1, 0b101, "umsubl", sub, zext>;
1095 def : Pat<(i64 (mul (sext GPR32:$Rn), (sext GPR32:$Rm))),
1096 (SMADDLrrr GPR32:$Rn, GPR32:$Rm, XZR)>;
1097 def : Pat<(i64 (mul (zext GPR32:$Rn), (zext GPR32:$Rm))),
1098 (UMADDLrrr GPR32:$Rn, GPR32:$Rm, XZR)>;
1100 def : Pat<(i64 (ineg (mul (sext GPR32:$Rn), (sext GPR32:$Rm)))),
1101 (SMSUBLrrr GPR32:$Rn, GPR32:$Rm, XZR)>;
1102 def : Pat<(i64 (ineg (mul (zext GPR32:$Rn), (zext GPR32:$Rm)))),
1103 (UMSUBLrrr GPR32:$Rn, GPR32:$Rm, XZR)>;
1105 def : Pat<(i64 (mul (sext GPR32:$Rn), (s64imm_32bit:$C))),
1106 (SMADDLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1107 def : Pat<(i64 (mul (zext GPR32:$Rn), (i64imm_32bit:$C))),
1108 (UMADDLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1109 def : Pat<(i64 (mul (sext_inreg GPR64:$Rn, i32), (s64imm_32bit:$C))),
1110 (SMADDLrrr (i32 (EXTRACT_SUBREG GPR64:$Rn, sub_32)),
1111 (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1113 def : Pat<(i64 (ineg (mul (sext GPR32:$Rn), (s64imm_32bit:$C)))),
1114 (SMSUBLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1115 def : Pat<(i64 (ineg (mul (zext GPR32:$Rn), (i64imm_32bit:$C)))),
1116 (UMSUBLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1117 def : Pat<(i64 (ineg (mul (sext_inreg GPR64:$Rn, i32), (s64imm_32bit:$C)))),
1118 (SMSUBLrrr (i32 (EXTRACT_SUBREG GPR64:$Rn, sub_32)),
1119 (MOVi32imm (trunc_imm imm:$C)), XZR)>;
1121 def : Pat<(i64 (add (mul (sext GPR32:$Rn), (s64imm_32bit:$C)), GPR64:$Ra)),
1122 (SMADDLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1123 def : Pat<(i64 (add (mul (zext GPR32:$Rn), (i64imm_32bit:$C)), GPR64:$Ra)),
1124 (UMADDLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1125 def : Pat<(i64 (add (mul (sext_inreg GPR64:$Rn, i32), (s64imm_32bit:$C)),
1127 (SMADDLrrr (i32 (EXTRACT_SUBREG GPR64:$Rn, sub_32)),
1128 (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1130 def : Pat<(i64 (sub GPR64:$Ra, (mul (sext GPR32:$Rn), (s64imm_32bit:$C)))),
1131 (SMSUBLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1132 def : Pat<(i64 (sub GPR64:$Ra, (mul (zext GPR32:$Rn), (i64imm_32bit:$C)))),
1133 (UMSUBLrrr GPR32:$Rn, (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1134 def : Pat<(i64 (sub GPR64:$Ra, (mul (sext_inreg GPR64:$Rn, i32),
1135 (s64imm_32bit:$C)))),
1136 (SMSUBLrrr (i32 (EXTRACT_SUBREG GPR64:$Rn, sub_32)),
1137 (MOVi32imm (trunc_imm imm:$C)), GPR64:$Ra)>;
1138 } // AddedComplexity = 5
1140 def : MulAccumWAlias<"mul", MADDWrrr>;
1141 def : MulAccumXAlias<"mul", MADDXrrr>;
1142 def : MulAccumWAlias<"mneg", MSUBWrrr>;
1143 def : MulAccumXAlias<"mneg", MSUBXrrr>;
1144 def : WideMulAccumAlias<"smull", SMADDLrrr>;
1145 def : WideMulAccumAlias<"smnegl", SMSUBLrrr>;
1146 def : WideMulAccumAlias<"umull", UMADDLrrr>;
1147 def : WideMulAccumAlias<"umnegl", UMSUBLrrr>;
1150 def SMULHrr : MulHi<0b010, "smulh", mulhs>;
1151 def UMULHrr : MulHi<0b110, "umulh", mulhu>;
1154 def CRC32Brr : BaseCRC32<0, 0b00, 0, GPR32, int_aarch64_crc32b, "crc32b">;
1155 def CRC32Hrr : BaseCRC32<0, 0b01, 0, GPR32, int_aarch64_crc32h, "crc32h">;
1156 def CRC32Wrr : BaseCRC32<0, 0b10, 0, GPR32, int_aarch64_crc32w, "crc32w">;
1157 def CRC32Xrr : BaseCRC32<1, 0b11, 0, GPR64, int_aarch64_crc32x, "crc32x">;
1159 def CRC32CBrr : BaseCRC32<0, 0b00, 1, GPR32, int_aarch64_crc32cb, "crc32cb">;
1160 def CRC32CHrr : BaseCRC32<0, 0b01, 1, GPR32, int_aarch64_crc32ch, "crc32ch">;
1161 def CRC32CWrr : BaseCRC32<0, 0b10, 1, GPR32, int_aarch64_crc32cw, "crc32cw">;
1162 def CRC32CXrr : BaseCRC32<1, 0b11, 1, GPR64, int_aarch64_crc32cx, "crc32cx">;
1165 defm CAS : CompareAndSwap<0, 0, "">;
1166 defm CASA : CompareAndSwap<1, 0, "a">;
1167 defm CASL : CompareAndSwap<0, 1, "l">;
1168 defm CASAL : CompareAndSwap<1, 1, "al">;
1171 defm CASP : CompareAndSwapPair<0, 0, "">;
1172 defm CASPA : CompareAndSwapPair<1, 0, "a">;
1173 defm CASPL : CompareAndSwapPair<0, 1, "l">;
1174 defm CASPAL : CompareAndSwapPair<1, 1, "al">;
1177 defm SWP : Swap<0, 0, "">;
1178 defm SWPA : Swap<1, 0, "a">;
1179 defm SWPL : Swap<0, 1, "l">;
1180 defm SWPAL : Swap<1, 1, "al">;
1182 // v8.1 atomic LD<OP>(register). Performs load and then ST<OP>(register)
1183 defm LDADD : LDOPregister<0b000, "add", 0, 0, "">;
1184 defm LDADDA : LDOPregister<0b000, "add", 1, 0, "a">;
1185 defm LDADDL : LDOPregister<0b000, "add", 0, 1, "l">;
1186 defm LDADDAL : LDOPregister<0b000, "add", 1, 1, "al">;
1188 defm LDCLR : LDOPregister<0b001, "clr", 0, 0, "">;
1189 defm LDCLRA : LDOPregister<0b001, "clr", 1, 0, "a">;
1190 defm LDCLRL : LDOPregister<0b001, "clr", 0, 1, "l">;
1191 defm LDCLRAL : LDOPregister<0b001, "clr", 1, 1, "al">;
1193 defm LDEOR : LDOPregister<0b010, "eor", 0, 0, "">;
1194 defm LDEORA : LDOPregister<0b010, "eor", 1, 0, "a">;
1195 defm LDEORL : LDOPregister<0b010, "eor", 0, 1, "l">;
1196 defm LDEORAL : LDOPregister<0b010, "eor", 1, 1, "al">;
1198 defm LDSET : LDOPregister<0b011, "set", 0, 0, "">;
1199 defm LDSETA : LDOPregister<0b011, "set", 1, 0, "a">;
1200 defm LDSETL : LDOPregister<0b011, "set", 0, 1, "l">;
1201 defm LDSETAL : LDOPregister<0b011, "set", 1, 1, "al">;
1203 defm LDSMAX : LDOPregister<0b100, "smax", 0, 0, "">;
1204 defm LDSMAXA : LDOPregister<0b100, "smax", 1, 0, "a">;
1205 defm LDSMAXL : LDOPregister<0b100, "smax", 0, 1, "l">;
1206 defm LDSMAXAL : LDOPregister<0b100, "smax", 1, 1, "al">;
1208 defm LDSMIN : LDOPregister<0b101, "smin", 0, 0, "">;
1209 defm LDSMINA : LDOPregister<0b101, "smin", 1, 0, "a">;
1210 defm LDSMINL : LDOPregister<0b101, "smin", 0, 1, "l">;
1211 defm LDSMINAL : LDOPregister<0b101, "smin", 1, 1, "al">;
1213 defm LDUMAX : LDOPregister<0b110, "umax", 0, 0, "">;
1214 defm LDUMAXA : LDOPregister<0b110, "umax", 1, 0, "a">;
1215 defm LDUMAXL : LDOPregister<0b110, "umax", 0, 1, "l">;
1216 defm LDUMAXAL : LDOPregister<0b110, "umax", 1, 1, "al">;
1218 defm LDUMIN : LDOPregister<0b111, "umin", 0, 0, "">;
1219 defm LDUMINA : LDOPregister<0b111, "umin", 1, 0, "a">;
1220 defm LDUMINL : LDOPregister<0b111, "umin", 0, 1, "l">;
1221 defm LDUMINAL : LDOPregister<0b111, "umin", 1, 1, "al">;
1223 // v8.1 atomic ST<OP>(register) as aliases to "LD<OP>(register) when Rt=xZR"
1224 defm : STOPregister<"stadd","LDADD">; // STADDx
1225 defm : STOPregister<"stclr","LDCLR">; // STCLRx
1226 defm : STOPregister<"steor","LDEOR">; // STEORx
1227 defm : STOPregister<"stset","LDSET">; // STSETx
1228 defm : STOPregister<"stsmax","LDSMAX">;// STSMAXx
1229 defm : STOPregister<"stsmin","LDSMIN">;// STSMINx
1230 defm : STOPregister<"stumax","LDUMAX">;// STUMAXx
1231 defm : STOPregister<"stumin","LDUMIN">;// STUMINx
1233 // v8.5 Memory Tagging Extension
1234 let Predicates = [HasMTE] in {
1236 def IRG : BaseTwoOperand<0b0100, GPR64sp, "irg", null_frag, GPR64sp, GPR64>,
1240 def GMI : BaseTwoOperand<0b0101, GPR64, "gmi", null_frag, GPR64sp>, Sched<[]>{
1242 let isNotDuplicable = 1;
1244 def ADDG : AddSubG<0, "addg", null_frag>;
1245 def SUBG : AddSubG<1, "subg", null_frag>;
1247 def : InstAlias<"irg $dst, $src", (IRG GPR64sp:$dst, GPR64sp:$src, XZR), 1>;
1249 def SUBP : SUBP<0, "subp", null_frag>, Sched<[]>;
1250 def SUBPS : SUBP<1, "subps", null_frag>, Sched<[]>{
1254 def : InstAlias<"cmpp $lhs, $rhs", (SUBPS XZR, GPR64sp:$lhs, GPR64sp:$rhs), 0>;
1256 def LDG : MemTagLoad<"ldg", "\t$Rt, [$Rn, $offset]">;
1257 def : InstAlias<"ldg $Rt, [$Rn]", (LDG GPR64:$Rt, GPR64sp:$Rn, 0), 1>;
1259 def LDGV : MemTagVector<1, "ldgv", "\t$Rt, [$Rn]!",
1260 (outs GPR64sp:$wback, GPR64:$Rt), (ins GPR64sp:$Rn)> {
1261 let DecoderMethod = "DecodeLoadAllocTagArrayInstruction";
1263 def STGV : MemTagVector<0, "stgv", "\t$Rt, [$Rn]!",
1264 (outs GPR64sp:$wback), (ins GPR64:$Rt, GPR64sp:$Rn)>;
1266 defm STG : MemTagStore<0b00, "stg">;
1267 defm STZG : MemTagStore<0b01, "stzg">;
1268 defm ST2G : MemTagStore<0b10, "st2g">;
1269 defm STZ2G : MemTagStore<0b11, "stz2g">;
1271 defm STGP : StorePairOffset <0b01, 0, GPR64z, simm7s16, "stgp">;
1272 def STGPpre : StorePairPreIdx <0b01, 0, GPR64z, simm7s16, "stgp">;
1273 def STGPpost : StorePairPostIdx<0b01, 0, GPR64z, simm7s16, "stgp">;
1275 } // Predicates = [HasMTE]
1277 //===----------------------------------------------------------------------===//
1278 // Logical instructions.
1279 //===----------------------------------------------------------------------===//
1282 defm ANDS : LogicalImmS<0b11, "ands", AArch64and_flag, "bics">;
1283 defm AND : LogicalImm<0b00, "and", and, "bic">;
1284 defm EOR : LogicalImm<0b10, "eor", xor, "eon">;
1285 defm ORR : LogicalImm<0b01, "orr", or, "orn">;
1287 // FIXME: these aliases *are* canonical sometimes (when movz can't be
1288 // used). Actually, it seems to be working right now, but putting logical_immXX
1289 // here is a bit dodgy on the AsmParser side too.
1290 def : InstAlias<"mov $dst, $imm", (ORRWri GPR32sp:$dst, WZR,
1291 logical_imm32:$imm), 0>;
1292 def : InstAlias<"mov $dst, $imm", (ORRXri GPR64sp:$dst, XZR,
1293 logical_imm64:$imm), 0>;
1297 defm ANDS : LogicalRegS<0b11, 0, "ands", AArch64and_flag>;
1298 defm BICS : LogicalRegS<0b11, 1, "bics",
1299 BinOpFrag<(AArch64and_flag node:$LHS, (not node:$RHS))>>;
1300 defm AND : LogicalReg<0b00, 0, "and", and>;
1301 defm BIC : LogicalReg<0b00, 1, "bic",
1302 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
1303 defm EON : LogicalReg<0b10, 1, "eon",
1304 BinOpFrag<(not (xor node:$LHS, node:$RHS))>>;
1305 defm EOR : LogicalReg<0b10, 0, "eor", xor>;
1306 defm ORN : LogicalReg<0b01, 1, "orn",
1307 BinOpFrag<(or node:$LHS, (not node:$RHS))>>;
1308 defm ORR : LogicalReg<0b01, 0, "orr", or>;
1310 def : InstAlias<"mov $dst, $src", (ORRWrs GPR32:$dst, WZR, GPR32:$src, 0), 2>;
1311 def : InstAlias<"mov $dst, $src", (ORRXrs GPR64:$dst, XZR, GPR64:$src, 0), 2>;
1313 def : InstAlias<"mvn $Wd, $Wm", (ORNWrs GPR32:$Wd, WZR, GPR32:$Wm, 0), 3>;
1314 def : InstAlias<"mvn $Xd, $Xm", (ORNXrs GPR64:$Xd, XZR, GPR64:$Xm, 0), 3>;
1316 def : InstAlias<"mvn $Wd, $Wm$sh",
1317 (ORNWrs GPR32:$Wd, WZR, GPR32:$Wm, logical_shift32:$sh), 2>;
1318 def : InstAlias<"mvn $Xd, $Xm$sh",
1319 (ORNXrs GPR64:$Xd, XZR, GPR64:$Xm, logical_shift64:$sh), 2>;
1321 def : InstAlias<"tst $src1, $src2",
1322 (ANDSWri WZR, GPR32:$src1, logical_imm32:$src2), 2>;
1323 def : InstAlias<"tst $src1, $src2",
1324 (ANDSXri XZR, GPR64:$src1, logical_imm64:$src2), 2>;
1326 def : InstAlias<"tst $src1, $src2",
1327 (ANDSWrs WZR, GPR32:$src1, GPR32:$src2, 0), 3>;
1328 def : InstAlias<"tst $src1, $src2",
1329 (ANDSXrs XZR, GPR64:$src1, GPR64:$src2, 0), 3>;
1331 def : InstAlias<"tst $src1, $src2$sh",
1332 (ANDSWrs WZR, GPR32:$src1, GPR32:$src2, logical_shift32:$sh), 2>;
1333 def : InstAlias<"tst $src1, $src2$sh",
1334 (ANDSXrs XZR, GPR64:$src1, GPR64:$src2, logical_shift64:$sh), 2>;
1337 def : Pat<(not GPR32:$Wm), (ORNWrr WZR, GPR32:$Wm)>;
1338 def : Pat<(not GPR64:$Xm), (ORNXrr XZR, GPR64:$Xm)>;
1341 //===----------------------------------------------------------------------===//
1342 // One operand data processing instructions.
1343 //===----------------------------------------------------------------------===//
1345 defm CLS : OneOperandData<0b101, "cls">;
1346 defm CLZ : OneOperandData<0b100, "clz", ctlz>;
1347 defm RBIT : OneOperandData<0b000, "rbit", bitreverse>;
1349 def REV16Wr : OneWRegData<0b001, "rev16",
1350 UnOpFrag<(rotr (bswap node:$LHS), (i64 16))>>;
1351 def REV16Xr : OneXRegData<0b001, "rev16", null_frag>;
1353 def : Pat<(cttz GPR32:$Rn),
1354 (CLZWr (RBITWr GPR32:$Rn))>;
1355 def : Pat<(cttz GPR64:$Rn),
1356 (CLZXr (RBITXr GPR64:$Rn))>;
1357 def : Pat<(ctlz (or (shl (xor (sra GPR32:$Rn, (i64 31)), GPR32:$Rn), (i64 1)),
1360 def : Pat<(ctlz (or (shl (xor (sra GPR64:$Rn, (i64 63)), GPR64:$Rn), (i64 1)),
1364 // Unlike the other one operand instructions, the instructions with the "rev"
1365 // mnemonic do *not* just different in the size bit, but actually use different
1366 // opcode bits for the different sizes.
1367 def REVWr : OneWRegData<0b010, "rev", bswap>;
1368 def REVXr : OneXRegData<0b011, "rev", bswap>;
1369 def REV32Xr : OneXRegData<0b010, "rev32",
1370 UnOpFrag<(rotr (bswap node:$LHS), (i64 32))>>;
1372 def : InstAlias<"rev64 $Rd, $Rn", (REVXr GPR64:$Rd, GPR64:$Rn), 0>;
1374 // The bswap commutes with the rotr so we want a pattern for both possible
1376 def : Pat<(bswap (rotr GPR32:$Rn, (i64 16))), (REV16Wr GPR32:$Rn)>;
1377 def : Pat<(bswap (rotr GPR64:$Rn, (i64 32))), (REV32Xr GPR64:$Rn)>;
1379 //===----------------------------------------------------------------------===//
1380 // Bitfield immediate extraction instruction.
1381 //===----------------------------------------------------------------------===//
1382 let hasSideEffects = 0 in
1383 defm EXTR : ExtractImm<"extr">;
1384 def : InstAlias<"ror $dst, $src, $shift",
1385 (EXTRWrri GPR32:$dst, GPR32:$src, GPR32:$src, imm0_31:$shift)>;
1386 def : InstAlias<"ror $dst, $src, $shift",
1387 (EXTRXrri GPR64:$dst, GPR64:$src, GPR64:$src, imm0_63:$shift)>;
1389 def : Pat<(rotr GPR32:$Rn, (i64 imm0_31:$imm)),
1390 (EXTRWrri GPR32:$Rn, GPR32:$Rn, imm0_31:$imm)>;
1391 def : Pat<(rotr GPR64:$Rn, (i64 imm0_63:$imm)),
1392 (EXTRXrri GPR64:$Rn, GPR64:$Rn, imm0_63:$imm)>;
1394 //===----------------------------------------------------------------------===//
1395 // Other bitfield immediate instructions.
1396 //===----------------------------------------------------------------------===//
1397 let hasSideEffects = 0 in {
1398 defm BFM : BitfieldImmWith2RegArgs<0b01, "bfm">;
1399 defm SBFM : BitfieldImm<0b00, "sbfm">;
1400 defm UBFM : BitfieldImm<0b10, "ubfm">;
1403 def i32shift_a : Operand<i64>, SDNodeXForm<imm, [{
1404 uint64_t enc = (32 - N->getZExtValue()) & 0x1f;
1405 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1408 def i32shift_b : Operand<i64>, SDNodeXForm<imm, [{
1409 uint64_t enc = 31 - N->getZExtValue();
1410 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1413 // min(7, 31 - shift_amt)
1414 def i32shift_sext_i8 : Operand<i64>, SDNodeXForm<imm, [{
1415 uint64_t enc = 31 - N->getZExtValue();
1416 enc = enc > 7 ? 7 : enc;
1417 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1420 // min(15, 31 - shift_amt)
1421 def i32shift_sext_i16 : Operand<i64>, SDNodeXForm<imm, [{
1422 uint64_t enc = 31 - N->getZExtValue();
1423 enc = enc > 15 ? 15 : enc;
1424 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1427 def i64shift_a : Operand<i64>, SDNodeXForm<imm, [{
1428 uint64_t enc = (64 - N->getZExtValue()) & 0x3f;
1429 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1432 def i64shift_b : Operand<i64>, SDNodeXForm<imm, [{
1433 uint64_t enc = 63 - N->getZExtValue();
1434 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1437 // min(7, 63 - shift_amt)
1438 def i64shift_sext_i8 : Operand<i64>, SDNodeXForm<imm, [{
1439 uint64_t enc = 63 - N->getZExtValue();
1440 enc = enc > 7 ? 7 : enc;
1441 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1444 // min(15, 63 - shift_amt)
1445 def i64shift_sext_i16 : Operand<i64>, SDNodeXForm<imm, [{
1446 uint64_t enc = 63 - N->getZExtValue();
1447 enc = enc > 15 ? 15 : enc;
1448 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1451 // min(31, 63 - shift_amt)
1452 def i64shift_sext_i32 : Operand<i64>, SDNodeXForm<imm, [{
1453 uint64_t enc = 63 - N->getZExtValue();
1454 enc = enc > 31 ? 31 : enc;
1455 return CurDAG->getTargetConstant(enc, SDLoc(N), MVT::i64);
1458 def : Pat<(shl GPR32:$Rn, (i64 imm0_31:$imm)),
1459 (UBFMWri GPR32:$Rn, (i64 (i32shift_a imm0_31:$imm)),
1460 (i64 (i32shift_b imm0_31:$imm)))>;
1461 def : Pat<(shl GPR64:$Rn, (i64 imm0_63:$imm)),
1462 (UBFMXri GPR64:$Rn, (i64 (i64shift_a imm0_63:$imm)),
1463 (i64 (i64shift_b imm0_63:$imm)))>;
1465 let AddedComplexity = 10 in {
1466 def : Pat<(sra GPR32:$Rn, (i64 imm0_31:$imm)),
1467 (SBFMWri GPR32:$Rn, imm0_31:$imm, 31)>;
1468 def : Pat<(sra GPR64:$Rn, (i64 imm0_63:$imm)),
1469 (SBFMXri GPR64:$Rn, imm0_63:$imm, 63)>;
1472 def : InstAlias<"asr $dst, $src, $shift",
1473 (SBFMWri GPR32:$dst, GPR32:$src, imm0_31:$shift, 31)>;
1474 def : InstAlias<"asr $dst, $src, $shift",
1475 (SBFMXri GPR64:$dst, GPR64:$src, imm0_63:$shift, 63)>;
1476 def : InstAlias<"sxtb $dst, $src", (SBFMWri GPR32:$dst, GPR32:$src, 0, 7)>;
1477 def : InstAlias<"sxtb $dst, $src", (SBFMXri GPR64:$dst, GPR64:$src, 0, 7)>;
1478 def : InstAlias<"sxth $dst, $src", (SBFMWri GPR32:$dst, GPR32:$src, 0, 15)>;
1479 def : InstAlias<"sxth $dst, $src", (SBFMXri GPR64:$dst, GPR64:$src, 0, 15)>;
1480 def : InstAlias<"sxtw $dst, $src", (SBFMXri GPR64:$dst, GPR64:$src, 0, 31)>;
1482 def : Pat<(srl GPR32:$Rn, (i64 imm0_31:$imm)),
1483 (UBFMWri GPR32:$Rn, imm0_31:$imm, 31)>;
1484 def : Pat<(srl GPR64:$Rn, (i64 imm0_63:$imm)),
1485 (UBFMXri GPR64:$Rn, imm0_63:$imm, 63)>;
1487 def : InstAlias<"lsr $dst, $src, $shift",
1488 (UBFMWri GPR32:$dst, GPR32:$src, imm0_31:$shift, 31)>;
1489 def : InstAlias<"lsr $dst, $src, $shift",
1490 (UBFMXri GPR64:$dst, GPR64:$src, imm0_63:$shift, 63)>;
1491 def : InstAlias<"uxtb $dst, $src", (UBFMWri GPR32:$dst, GPR32:$src, 0, 7)>;
1492 def : InstAlias<"uxtb $dst, $src", (UBFMXri GPR64:$dst, GPR64:$src, 0, 7)>;
1493 def : InstAlias<"uxth $dst, $src", (UBFMWri GPR32:$dst, GPR32:$src, 0, 15)>;
1494 def : InstAlias<"uxth $dst, $src", (UBFMXri GPR64:$dst, GPR64:$src, 0, 15)>;
1495 def : InstAlias<"uxtw $dst, $src", (UBFMXri GPR64:$dst, GPR64:$src, 0, 31)>;
1497 //===----------------------------------------------------------------------===//
1498 // Conditional comparison instructions.
1499 //===----------------------------------------------------------------------===//
1500 defm CCMN : CondComparison<0, "ccmn", AArch64ccmn>;
1501 defm CCMP : CondComparison<1, "ccmp", AArch64ccmp>;
1503 //===----------------------------------------------------------------------===//
1504 // Conditional select instructions.
1505 //===----------------------------------------------------------------------===//
1506 defm CSEL : CondSelect<0, 0b00, "csel">;
1508 def inc : PatFrag<(ops node:$in), (add node:$in, 1)>;
1509 defm CSINC : CondSelectOp<0, 0b01, "csinc", inc>;
1510 defm CSINV : CondSelectOp<1, 0b00, "csinv", not>;
1511 defm CSNEG : CondSelectOp<1, 0b01, "csneg", ineg>;
1513 def : Pat<(AArch64csinv GPR32:$tval, GPR32:$fval, (i32 imm:$cc), NZCV),
1514 (CSINVWr GPR32:$tval, GPR32:$fval, (i32 imm:$cc))>;
1515 def : Pat<(AArch64csinv GPR64:$tval, GPR64:$fval, (i32 imm:$cc), NZCV),
1516 (CSINVXr GPR64:$tval, GPR64:$fval, (i32 imm:$cc))>;
1517 def : Pat<(AArch64csneg GPR32:$tval, GPR32:$fval, (i32 imm:$cc), NZCV),
1518 (CSNEGWr GPR32:$tval, GPR32:$fval, (i32 imm:$cc))>;
1519 def : Pat<(AArch64csneg GPR64:$tval, GPR64:$fval, (i32 imm:$cc), NZCV),
1520 (CSNEGXr GPR64:$tval, GPR64:$fval, (i32 imm:$cc))>;
1521 def : Pat<(AArch64csinc GPR32:$tval, GPR32:$fval, (i32 imm:$cc), NZCV),
1522 (CSINCWr GPR32:$tval, GPR32:$fval, (i32 imm:$cc))>;
1523 def : Pat<(AArch64csinc GPR64:$tval, GPR64:$fval, (i32 imm:$cc), NZCV),
1524 (CSINCXr GPR64:$tval, GPR64:$fval, (i32 imm:$cc))>;
1526 def : Pat<(AArch64csel (i32 0), (i32 1), (i32 imm:$cc), NZCV),
1527 (CSINCWr WZR, WZR, (i32 imm:$cc))>;
1528 def : Pat<(AArch64csel (i64 0), (i64 1), (i32 imm:$cc), NZCV),
1529 (CSINCXr XZR, XZR, (i32 imm:$cc))>;
1530 def : Pat<(AArch64csel GPR32:$tval, (i32 1), (i32 imm:$cc), NZCV),
1531 (CSINCWr GPR32:$tval, WZR, (i32 imm:$cc))>;
1532 def : Pat<(AArch64csel GPR64:$tval, (i64 1), (i32 imm:$cc), NZCV),
1533 (CSINCXr GPR64:$tval, XZR, (i32 imm:$cc))>;
1534 def : Pat<(AArch64csel (i32 1), GPR32:$fval, (i32 imm:$cc), NZCV),
1535 (CSINCWr GPR32:$fval, WZR, (i32 (inv_cond_XFORM imm:$cc)))>;
1536 def : Pat<(AArch64csel (i64 1), GPR64:$fval, (i32 imm:$cc), NZCV),
1537 (CSINCXr GPR64:$fval, XZR, (i32 (inv_cond_XFORM imm:$cc)))>;
1538 def : Pat<(AArch64csel (i32 0), (i32 -1), (i32 imm:$cc), NZCV),
1539 (CSINVWr WZR, WZR, (i32 imm:$cc))>;
1540 def : Pat<(AArch64csel (i64 0), (i64 -1), (i32 imm:$cc), NZCV),
1541 (CSINVXr XZR, XZR, (i32 imm:$cc))>;
1542 def : Pat<(AArch64csel GPR32:$tval, (i32 -1), (i32 imm:$cc), NZCV),
1543 (CSINVWr GPR32:$tval, WZR, (i32 imm:$cc))>;
1544 def : Pat<(AArch64csel GPR64:$tval, (i64 -1), (i32 imm:$cc), NZCV),
1545 (CSINVXr GPR64:$tval, XZR, (i32 imm:$cc))>;
1546 def : Pat<(AArch64csel (i32 -1), GPR32:$fval, (i32 imm:$cc), NZCV),
1547 (CSINVWr GPR32:$fval, WZR, (i32 (inv_cond_XFORM imm:$cc)))>;
1548 def : Pat<(AArch64csel (i64 -1), GPR64:$fval, (i32 imm:$cc), NZCV),
1549 (CSINVXr GPR64:$fval, XZR, (i32 (inv_cond_XFORM imm:$cc)))>;
1551 // The inverse of the condition code from the alias instruction is what is used
1552 // in the aliased instruction. The parser all ready inverts the condition code
1553 // for these aliases.
1554 def : InstAlias<"cset $dst, $cc",
1555 (CSINCWr GPR32:$dst, WZR, WZR, inv_ccode:$cc)>;
1556 def : InstAlias<"cset $dst, $cc",
1557 (CSINCXr GPR64:$dst, XZR, XZR, inv_ccode:$cc)>;
1559 def : InstAlias<"csetm $dst, $cc",
1560 (CSINVWr GPR32:$dst, WZR, WZR, inv_ccode:$cc)>;
1561 def : InstAlias<"csetm $dst, $cc",
1562 (CSINVXr GPR64:$dst, XZR, XZR, inv_ccode:$cc)>;
1564 def : InstAlias<"cinc $dst, $src, $cc",
1565 (CSINCWr GPR32:$dst, GPR32:$src, GPR32:$src, inv_ccode:$cc)>;
1566 def : InstAlias<"cinc $dst, $src, $cc",
1567 (CSINCXr GPR64:$dst, GPR64:$src, GPR64:$src, inv_ccode:$cc)>;
1569 def : InstAlias<"cinv $dst, $src, $cc",
1570 (CSINVWr GPR32:$dst, GPR32:$src, GPR32:$src, inv_ccode:$cc)>;
1571 def : InstAlias<"cinv $dst, $src, $cc",
1572 (CSINVXr GPR64:$dst, GPR64:$src, GPR64:$src, inv_ccode:$cc)>;
1574 def : InstAlias<"cneg $dst, $src, $cc",
1575 (CSNEGWr GPR32:$dst, GPR32:$src, GPR32:$src, inv_ccode:$cc)>;
1576 def : InstAlias<"cneg $dst, $src, $cc",
1577 (CSNEGXr GPR64:$dst, GPR64:$src, GPR64:$src, inv_ccode:$cc)>;
1579 //===----------------------------------------------------------------------===//
1580 // PC-relative instructions.
1581 //===----------------------------------------------------------------------===//
1582 let isReMaterializable = 1 in {
1583 let hasSideEffects = 0, mayStore = 0, mayLoad = 0 in {
1584 def ADR : ADRI<0, "adr", adrlabel,
1585 [(set GPR64:$Xd, (AArch64adr tglobaladdr:$label))]>;
1586 } // hasSideEffects = 0
1588 def ADRP : ADRI<1, "adrp", adrplabel,
1589 [(set GPR64:$Xd, (AArch64adrp tglobaladdr:$label))]>;
1590 } // isReMaterializable = 1
1592 // page address of a constant pool entry, block address
1593 def : Pat<(AArch64adr tconstpool:$cp), (ADR tconstpool:$cp)>;
1594 def : Pat<(AArch64adr tblockaddress:$cp), (ADR tblockaddress:$cp)>;
1595 def : Pat<(AArch64adr texternalsym:$sym), (ADR texternalsym:$sym)>;
1596 def : Pat<(AArch64adr tjumptable:$sym), (ADR tjumptable:$sym)>;
1597 def : Pat<(AArch64adrp tconstpool:$cp), (ADRP tconstpool:$cp)>;
1598 def : Pat<(AArch64adrp tblockaddress:$cp), (ADRP tblockaddress:$cp)>;
1599 def : Pat<(AArch64adrp texternalsym:$sym), (ADRP texternalsym:$sym)>;
1601 //===----------------------------------------------------------------------===//
1602 // Unconditional branch (register) instructions.
1603 //===----------------------------------------------------------------------===//
1605 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
1606 def RET : BranchReg<0b0010, "ret", []>;
1607 def DRPS : SpecialReturn<0b0101, "drps">;
1608 def ERET : SpecialReturn<0b0100, "eret">;
1609 } // isReturn = 1, isTerminator = 1, isBarrier = 1
1611 // Default to the LR register.
1612 def : InstAlias<"ret", (RET LR)>;
1614 let isCall = 1, Defs = [LR], Uses = [SP] in {
1615 def BLR : BranchReg<0b0001, "blr", [(AArch64call GPR64:$Rn)]>;
1618 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
1619 def BR : BranchReg<0b0000, "br", [(brind GPR64:$Rn)]>;
1620 } // isBranch, isTerminator, isBarrier, isIndirectBranch
1622 // Create a separate pseudo-instruction for codegen to use so that we don't
1623 // flag lr as used in every function. It'll be restored before the RET by the
1624 // epilogue if it's legitimately used.
1625 def RET_ReallyLR : Pseudo<(outs), (ins), [(AArch64retflag)]>,
1626 Sched<[WriteBrReg]> {
1627 let isTerminator = 1;
1632 // This is a directive-like pseudo-instruction. The purpose is to insert an
1633 // R_AARCH64_TLSDESC_CALL relocation at the offset of the following instruction
1634 // (which in the usual case is a BLR).
1635 let hasSideEffects = 1 in
1636 def TLSDESCCALL : Pseudo<(outs), (ins i64imm:$sym), []>, Sched<[]> {
1637 let AsmString = ".tlsdesccall $sym";
1640 // Pseudo instruction to tell the streamer to emit a 'B' character into the
1641 // augmentation string.
1642 def EMITBKEY : Pseudo<(outs), (ins), []>, Sched<[]> {}
1644 // FIXME: maybe the scratch register used shouldn't be fixed to X1?
1645 // FIXME: can "hasSideEffects be dropped?
1646 let isCall = 1, Defs = [LR, X0, X1], hasSideEffects = 1,
1647 isCodeGenOnly = 1 in
1649 : Pseudo<(outs), (ins i64imm:$sym),
1650 [(AArch64tlsdesc_callseq tglobaltlsaddr:$sym)]>,
1651 Sched<[WriteI, WriteLD, WriteI, WriteBrReg]>;
1652 def : Pat<(AArch64tlsdesc_callseq texternalsym:$sym),
1653 (TLSDESC_CALLSEQ texternalsym:$sym)>;
1655 //===----------------------------------------------------------------------===//
1656 // Conditional branch (immediate) instruction.
1657 //===----------------------------------------------------------------------===//
1658 def Bcc : BranchCond;
1660 //===----------------------------------------------------------------------===//
1661 // Compare-and-branch instructions.
1662 //===----------------------------------------------------------------------===//
1663 defm CBZ : CmpBranch<0, "cbz", AArch64cbz>;
1664 defm CBNZ : CmpBranch<1, "cbnz", AArch64cbnz>;
1666 //===----------------------------------------------------------------------===//
1667 // Test-bit-and-branch instructions.
1668 //===----------------------------------------------------------------------===//
1669 defm TBZ : TestBranch<0, "tbz", AArch64tbz>;
1670 defm TBNZ : TestBranch<1, "tbnz", AArch64tbnz>;
1672 //===----------------------------------------------------------------------===//
1673 // Unconditional branch (immediate) instructions.
1674 //===----------------------------------------------------------------------===//
1675 let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
1676 def B : BranchImm<0, "b", [(br bb:$addr)]>;
1677 } // isBranch, isTerminator, isBarrier
1679 let isCall = 1, Defs = [LR], Uses = [SP] in {
1680 def BL : CallImm<1, "bl", [(AArch64call tglobaladdr:$addr)]>;
1682 def : Pat<(AArch64call texternalsym:$func), (BL texternalsym:$func)>;
1684 //===----------------------------------------------------------------------===//
1685 // Exception generation instructions.
1686 //===----------------------------------------------------------------------===//
1688 def BRK : ExceptionGeneration<0b001, 0b00, "brk">;
1690 def DCPS1 : ExceptionGeneration<0b101, 0b01, "dcps1">;
1691 def DCPS2 : ExceptionGeneration<0b101, 0b10, "dcps2">;
1692 def DCPS3 : ExceptionGeneration<0b101, 0b11, "dcps3">;
1693 def HLT : ExceptionGeneration<0b010, 0b00, "hlt">;
1694 def HVC : ExceptionGeneration<0b000, 0b10, "hvc">;
1695 def SMC : ExceptionGeneration<0b000, 0b11, "smc">;
1696 def SVC : ExceptionGeneration<0b000, 0b01, "svc">;
1698 // DCPSn defaults to an immediate operand of zero if unspecified.
1699 def : InstAlias<"dcps1", (DCPS1 0)>;
1700 def : InstAlias<"dcps2", (DCPS2 0)>;
1701 def : InstAlias<"dcps3", (DCPS3 0)>;
1703 def UDF : UDFType<0, "udf">;
1705 //===----------------------------------------------------------------------===//
1706 // Load instructions.
1707 //===----------------------------------------------------------------------===//
1709 // Pair (indexed, offset)
1710 defm LDPW : LoadPairOffset<0b00, 0, GPR32z, simm7s4, "ldp">;
1711 defm LDPX : LoadPairOffset<0b10, 0, GPR64z, simm7s8, "ldp">;
1712 defm LDPS : LoadPairOffset<0b00, 1, FPR32Op, simm7s4, "ldp">;
1713 defm LDPD : LoadPairOffset<0b01, 1, FPR64Op, simm7s8, "ldp">;
1714 defm LDPQ : LoadPairOffset<0b10, 1, FPR128Op, simm7s16, "ldp">;
1716 defm LDPSW : LoadPairOffset<0b01, 0, GPR64z, simm7s4, "ldpsw">;
1718 // Pair (pre-indexed)
1719 def LDPWpre : LoadPairPreIdx<0b00, 0, GPR32z, simm7s4, "ldp">;
1720 def LDPXpre : LoadPairPreIdx<0b10, 0, GPR64z, simm7s8, "ldp">;
1721 def LDPSpre : LoadPairPreIdx<0b00, 1, FPR32Op, simm7s4, "ldp">;
1722 def LDPDpre : LoadPairPreIdx<0b01, 1, FPR64Op, simm7s8, "ldp">;
1723 def LDPQpre : LoadPairPreIdx<0b10, 1, FPR128Op, simm7s16, "ldp">;
1725 def LDPSWpre : LoadPairPreIdx<0b01, 0, GPR64z, simm7s4, "ldpsw">;
1727 // Pair (post-indexed)
1728 def LDPWpost : LoadPairPostIdx<0b00, 0, GPR32z, simm7s4, "ldp">;
1729 def LDPXpost : LoadPairPostIdx<0b10, 0, GPR64z, simm7s8, "ldp">;
1730 def LDPSpost : LoadPairPostIdx<0b00, 1, FPR32Op, simm7s4, "ldp">;
1731 def LDPDpost : LoadPairPostIdx<0b01, 1, FPR64Op, simm7s8, "ldp">;
1732 def LDPQpost : LoadPairPostIdx<0b10, 1, FPR128Op, simm7s16, "ldp">;
1734 def LDPSWpost : LoadPairPostIdx<0b01, 0, GPR64z, simm7s4, "ldpsw">;
1737 // Pair (no allocate)
1738 defm LDNPW : LoadPairNoAlloc<0b00, 0, GPR32z, simm7s4, "ldnp">;
1739 defm LDNPX : LoadPairNoAlloc<0b10, 0, GPR64z, simm7s8, "ldnp">;
1740 defm LDNPS : LoadPairNoAlloc<0b00, 1, FPR32Op, simm7s4, "ldnp">;
1741 defm LDNPD : LoadPairNoAlloc<0b01, 1, FPR64Op, simm7s8, "ldnp">;
1742 defm LDNPQ : LoadPairNoAlloc<0b10, 1, FPR128Op, simm7s16, "ldnp">;
1745 // (register offset)
1749 defm LDRBB : Load8RO<0b00, 0, 0b01, GPR32, "ldrb", i32, zextloadi8>;
1750 defm LDRHH : Load16RO<0b01, 0, 0b01, GPR32, "ldrh", i32, zextloadi16>;
1751 defm LDRW : Load32RO<0b10, 0, 0b01, GPR32, "ldr", i32, load>;
1752 defm LDRX : Load64RO<0b11, 0, 0b01, GPR64, "ldr", i64, load>;
1755 defm LDRB : Load8RO<0b00, 1, 0b01, FPR8Op, "ldr", untyped, load>;
1756 defm LDRH : Load16RO<0b01, 1, 0b01, FPR16Op, "ldr", f16, load>;
1757 defm LDRS : Load32RO<0b10, 1, 0b01, FPR32Op, "ldr", f32, load>;
1758 defm LDRD : Load64RO<0b11, 1, 0b01, FPR64Op, "ldr", f64, load>;
1759 defm LDRQ : Load128RO<0b00, 1, 0b11, FPR128Op, "ldr", f128, load>;
1761 // Load sign-extended half-word
1762 defm LDRSHW : Load16RO<0b01, 0, 0b11, GPR32, "ldrsh", i32, sextloadi16>;
1763 defm LDRSHX : Load16RO<0b01, 0, 0b10, GPR64, "ldrsh", i64, sextloadi16>;
1765 // Load sign-extended byte
1766 defm LDRSBW : Load8RO<0b00, 0, 0b11, GPR32, "ldrsb", i32, sextloadi8>;
1767 defm LDRSBX : Load8RO<0b00, 0, 0b10, GPR64, "ldrsb", i64, sextloadi8>;
1769 // Load sign-extended word
1770 defm LDRSW : Load32RO<0b10, 0, 0b10, GPR64, "ldrsw", i64, sextloadi32>;
1773 defm PRFM : PrefetchRO<0b11, 0, 0b10, "prfm">;
1775 // For regular load, we do not have any alignment requirement.
1776 // Thus, it is safe to directly map the vector loads with interesting
1777 // addressing modes.
1778 // FIXME: We could do the same for bitconvert to floating point vectors.
1779 multiclass ScalToVecROLoadPat<ROAddrMode ro, SDPatternOperator loadop,
1780 ValueType ScalTy, ValueType VecTy,
1781 Instruction LOADW, Instruction LOADX,
1783 def : Pat<(VecTy (scalar_to_vector (ScalTy
1784 (loadop (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$offset))))),
1785 (INSERT_SUBREG (VecTy (IMPLICIT_DEF)),
1786 (LOADW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$offset),
1789 def : Pat<(VecTy (scalar_to_vector (ScalTy
1790 (loadop (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$offset))))),
1791 (INSERT_SUBREG (VecTy (IMPLICIT_DEF)),
1792 (LOADX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$offset),
1796 let AddedComplexity = 10 in {
1797 defm : ScalToVecROLoadPat<ro8, extloadi8, i32, v8i8, LDRBroW, LDRBroX, bsub>;
1798 defm : ScalToVecROLoadPat<ro8, extloadi8, i32, v16i8, LDRBroW, LDRBroX, bsub>;
1800 defm : ScalToVecROLoadPat<ro16, extloadi16, i32, v4i16, LDRHroW, LDRHroX, hsub>;
1801 defm : ScalToVecROLoadPat<ro16, extloadi16, i32, v8i16, LDRHroW, LDRHroX, hsub>;
1803 defm : ScalToVecROLoadPat<ro16, load, i32, v4f16, LDRHroW, LDRHroX, hsub>;
1804 defm : ScalToVecROLoadPat<ro16, load, i32, v8f16, LDRHroW, LDRHroX, hsub>;
1806 defm : ScalToVecROLoadPat<ro32, load, i32, v2i32, LDRSroW, LDRSroX, ssub>;
1807 defm : ScalToVecROLoadPat<ro32, load, i32, v4i32, LDRSroW, LDRSroX, ssub>;
1809 defm : ScalToVecROLoadPat<ro32, load, f32, v2f32, LDRSroW, LDRSroX, ssub>;
1810 defm : ScalToVecROLoadPat<ro32, load, f32, v4f32, LDRSroW, LDRSroX, ssub>;
1812 defm : ScalToVecROLoadPat<ro64, load, i64, v2i64, LDRDroW, LDRDroX, dsub>;
1814 defm : ScalToVecROLoadPat<ro64, load, f64, v2f64, LDRDroW, LDRDroX, dsub>;
1817 def : Pat <(v1i64 (scalar_to_vector (i64
1818 (load (ro_Windexed64 GPR64sp:$Rn, GPR32:$Rm,
1819 ro_Wextend64:$extend))))),
1820 (LDRDroW GPR64sp:$Rn, GPR32:$Rm, ro_Wextend64:$extend)>;
1822 def : Pat <(v1i64 (scalar_to_vector (i64
1823 (load (ro_Xindexed64 GPR64sp:$Rn, GPR64:$Rm,
1824 ro_Xextend64:$extend))))),
1825 (LDRDroX GPR64sp:$Rn, GPR64:$Rm, ro_Xextend64:$extend)>;
1828 // Match all load 64 bits width whose type is compatible with FPR64
1829 multiclass VecROLoadPat<ROAddrMode ro, ValueType VecTy,
1830 Instruction LOADW, Instruction LOADX> {
1832 def : Pat<(VecTy (load (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend))),
1833 (LOADW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
1835 def : Pat<(VecTy (load (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend))),
1836 (LOADX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
1839 let AddedComplexity = 10 in {
1840 let Predicates = [IsLE] in {
1841 // We must do vector loads with LD1 in big-endian.
1842 defm : VecROLoadPat<ro64, v2i32, LDRDroW, LDRDroX>;
1843 defm : VecROLoadPat<ro64, v2f32, LDRDroW, LDRDroX>;
1844 defm : VecROLoadPat<ro64, v8i8, LDRDroW, LDRDroX>;
1845 defm : VecROLoadPat<ro64, v4i16, LDRDroW, LDRDroX>;
1846 defm : VecROLoadPat<ro64, v4f16, LDRDroW, LDRDroX>;
1849 defm : VecROLoadPat<ro64, v1i64, LDRDroW, LDRDroX>;
1850 defm : VecROLoadPat<ro64, v1f64, LDRDroW, LDRDroX>;
1852 // Match all load 128 bits width whose type is compatible with FPR128
1853 let Predicates = [IsLE] in {
1854 // We must do vector loads with LD1 in big-endian.
1855 defm : VecROLoadPat<ro128, v2i64, LDRQroW, LDRQroX>;
1856 defm : VecROLoadPat<ro128, v2f64, LDRQroW, LDRQroX>;
1857 defm : VecROLoadPat<ro128, v4i32, LDRQroW, LDRQroX>;
1858 defm : VecROLoadPat<ro128, v4f32, LDRQroW, LDRQroX>;
1859 defm : VecROLoadPat<ro128, v8i16, LDRQroW, LDRQroX>;
1860 defm : VecROLoadPat<ro128, v8f16, LDRQroW, LDRQroX>;
1861 defm : VecROLoadPat<ro128, v16i8, LDRQroW, LDRQroX>;
1863 } // AddedComplexity = 10
1866 multiclass ExtLoadTo64ROPat<ROAddrMode ro, SDPatternOperator loadop,
1867 Instruction INSTW, Instruction INSTX> {
1868 def : Pat<(i64 (loadop (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend))),
1869 (SUBREG_TO_REG (i64 0),
1870 (INSTW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend),
1873 def : Pat<(i64 (loadop (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend))),
1874 (SUBREG_TO_REG (i64 0),
1875 (INSTX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend),
1879 let AddedComplexity = 10 in {
1880 defm : ExtLoadTo64ROPat<ro8, zextloadi8, LDRBBroW, LDRBBroX>;
1881 defm : ExtLoadTo64ROPat<ro16, zextloadi16, LDRHHroW, LDRHHroX>;
1882 defm : ExtLoadTo64ROPat<ro32, zextloadi32, LDRWroW, LDRWroX>;
1884 // zextloadi1 -> zextloadi8
1885 defm : ExtLoadTo64ROPat<ro8, zextloadi1, LDRBBroW, LDRBBroX>;
1887 // extload -> zextload
1888 defm : ExtLoadTo64ROPat<ro8, extloadi8, LDRBBroW, LDRBBroX>;
1889 defm : ExtLoadTo64ROPat<ro16, extloadi16, LDRHHroW, LDRHHroX>;
1890 defm : ExtLoadTo64ROPat<ro32, extloadi32, LDRWroW, LDRWroX>;
1892 // extloadi1 -> zextloadi8
1893 defm : ExtLoadTo64ROPat<ro8, extloadi1, LDRBBroW, LDRBBroX>;
1898 multiclass ExtLoadTo32ROPat<ROAddrMode ro, SDPatternOperator loadop,
1899 Instruction INSTW, Instruction INSTX> {
1900 def : Pat<(i32 (loadop (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend))),
1901 (INSTW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
1903 def : Pat<(i32 (loadop (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend))),
1904 (INSTX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
1908 let AddedComplexity = 10 in {
1909 // extload -> zextload
1910 defm : ExtLoadTo32ROPat<ro8, extloadi8, LDRBBroW, LDRBBroX>;
1911 defm : ExtLoadTo32ROPat<ro16, extloadi16, LDRHHroW, LDRHHroX>;
1912 defm : ExtLoadTo32ROPat<ro32, extloadi32, LDRWroW, LDRWroX>;
1914 // zextloadi1 -> zextloadi8
1915 defm : ExtLoadTo32ROPat<ro8, zextloadi1, LDRBBroW, LDRBBroX>;
1919 // (unsigned immediate)
1921 defm LDRX : LoadUI<0b11, 0, 0b01, GPR64z, uimm12s8, "ldr",
1923 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)))]>;
1924 defm LDRW : LoadUI<0b10, 0, 0b01, GPR32z, uimm12s4, "ldr",
1926 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset)))]>;
1927 defm LDRB : LoadUI<0b00, 1, 0b01, FPR8Op, uimm12s1, "ldr",
1929 (load (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset)))]>;
1930 defm LDRH : LoadUI<0b01, 1, 0b01, FPR16Op, uimm12s2, "ldr",
1931 [(set (f16 FPR16Op:$Rt),
1932 (load (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset)))]>;
1933 defm LDRS : LoadUI<0b10, 1, 0b01, FPR32Op, uimm12s4, "ldr",
1934 [(set (f32 FPR32Op:$Rt),
1935 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset)))]>;
1936 defm LDRD : LoadUI<0b11, 1, 0b01, FPR64Op, uimm12s8, "ldr",
1937 [(set (f64 FPR64Op:$Rt),
1938 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)))]>;
1939 defm LDRQ : LoadUI<0b00, 1, 0b11, FPR128Op, uimm12s16, "ldr",
1940 [(set (f128 FPR128Op:$Rt),
1941 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)))]>;
1943 // For regular load, we do not have any alignment requirement.
1944 // Thus, it is safe to directly map the vector loads with interesting
1945 // addressing modes.
1946 // FIXME: We could do the same for bitconvert to floating point vectors.
1947 def : Pat <(v8i8 (scalar_to_vector (i32
1948 (extloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))))),
1949 (INSERT_SUBREG (v8i8 (IMPLICIT_DEF)),
1950 (LDRBui GPR64sp:$Rn, uimm12s1:$offset), bsub)>;
1951 def : Pat <(v16i8 (scalar_to_vector (i32
1952 (extloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))))),
1953 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
1954 (LDRBui GPR64sp:$Rn, uimm12s1:$offset), bsub)>;
1955 def : Pat <(v4i16 (scalar_to_vector (i32
1956 (extloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))))),
1957 (INSERT_SUBREG (v4i16 (IMPLICIT_DEF)),
1958 (LDRHui GPR64sp:$Rn, uimm12s2:$offset), hsub)>;
1959 def : Pat <(v8i16 (scalar_to_vector (i32
1960 (extloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))))),
1961 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)),
1962 (LDRHui GPR64sp:$Rn, uimm12s2:$offset), hsub)>;
1963 def : Pat <(v2i32 (scalar_to_vector (i32
1964 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))))),
1965 (INSERT_SUBREG (v2i32 (IMPLICIT_DEF)),
1966 (LDRSui GPR64sp:$Rn, uimm12s4:$offset), ssub)>;
1967 def : Pat <(v4i32 (scalar_to_vector (i32
1968 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))))),
1969 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)),
1970 (LDRSui GPR64sp:$Rn, uimm12s4:$offset), ssub)>;
1971 def : Pat <(v1i64 (scalar_to_vector (i64
1972 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))))),
1973 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
1974 def : Pat <(v2i64 (scalar_to_vector (i64
1975 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))))),
1976 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)),
1977 (LDRDui GPR64sp:$Rn, uimm12s8:$offset), dsub)>;
1979 // Match all load 64 bits width whose type is compatible with FPR64
1980 let Predicates = [IsLE] in {
1981 // We must use LD1 to perform vector loads in big-endian.
1982 def : Pat<(v2f32 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
1983 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
1984 def : Pat<(v8i8 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
1985 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
1986 def : Pat<(v4i16 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
1987 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
1988 def : Pat<(v2i32 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
1989 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
1990 def : Pat<(v4f16 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
1991 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
1993 def : Pat<(v1f64 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
1994 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
1995 def : Pat<(v1i64 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
1996 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
1998 // Match all load 128 bits width whose type is compatible with FPR128
1999 let Predicates = [IsLE] in {
2000 // We must use LD1 to perform vector loads in big-endian.
2001 def : Pat<(v4f32 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2002 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2003 def : Pat<(v2f64 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2004 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2005 def : Pat<(v16i8 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2006 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2007 def : Pat<(v8i16 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2008 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2009 def : Pat<(v4i32 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2010 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2011 def : Pat<(v2i64 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2012 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2013 def : Pat<(v8f16 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2014 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2016 def : Pat<(f128 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
2017 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
2019 defm LDRHH : LoadUI<0b01, 0, 0b01, GPR32, uimm12s2, "ldrh",
2021 (zextloadi16 (am_indexed16 GPR64sp:$Rn,
2022 uimm12s2:$offset)))]>;
2023 defm LDRBB : LoadUI<0b00, 0, 0b01, GPR32, uimm12s1, "ldrb",
2025 (zextloadi8 (am_indexed8 GPR64sp:$Rn,
2026 uimm12s1:$offset)))]>;
2028 def : Pat<(i64 (zextloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2029 (SUBREG_TO_REG (i64 0), (LDRBBui GPR64sp:$Rn, uimm12s1:$offset), sub_32)>;
2030 def : Pat<(i64 (zextloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))),
2031 (SUBREG_TO_REG (i64 0), (LDRHHui GPR64sp:$Rn, uimm12s2:$offset), sub_32)>;
2033 // zextloadi1 -> zextloadi8
2034 def : Pat<(i32 (zextloadi1 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2035 (LDRBBui GPR64sp:$Rn, uimm12s1:$offset)>;
2036 def : Pat<(i64 (zextloadi1 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2037 (SUBREG_TO_REG (i64 0), (LDRBBui GPR64sp:$Rn, uimm12s1:$offset), sub_32)>;
2039 // extload -> zextload
2040 def : Pat<(i32 (extloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))),
2041 (LDRHHui GPR64sp:$Rn, uimm12s2:$offset)>;
2042 def : Pat<(i32 (extloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2043 (LDRBBui GPR64sp:$Rn, uimm12s1:$offset)>;
2044 def : Pat<(i32 (extloadi1 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2045 (LDRBBui GPR64sp:$Rn, uimm12s1:$offset)>;
2046 def : Pat<(i64 (extloadi32 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))),
2047 (SUBREG_TO_REG (i64 0), (LDRWui GPR64sp:$Rn, uimm12s4:$offset), sub_32)>;
2048 def : Pat<(i64 (extloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))),
2049 (SUBREG_TO_REG (i64 0), (LDRHHui GPR64sp:$Rn, uimm12s2:$offset), sub_32)>;
2050 def : Pat<(i64 (extloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2051 (SUBREG_TO_REG (i64 0), (LDRBBui GPR64sp:$Rn, uimm12s1:$offset), sub_32)>;
2052 def : Pat<(i64 (extloadi1 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
2053 (SUBREG_TO_REG (i64 0), (LDRBBui GPR64sp:$Rn, uimm12s1:$offset), sub_32)>;
2055 // load sign-extended half-word
2056 defm LDRSHW : LoadUI<0b01, 0, 0b11, GPR32, uimm12s2, "ldrsh",
2058 (sextloadi16 (am_indexed16 GPR64sp:$Rn,
2059 uimm12s2:$offset)))]>;
2060 defm LDRSHX : LoadUI<0b01, 0, 0b10, GPR64, uimm12s2, "ldrsh",
2062 (sextloadi16 (am_indexed16 GPR64sp:$Rn,
2063 uimm12s2:$offset)))]>;
2065 // load sign-extended byte
2066 defm LDRSBW : LoadUI<0b00, 0, 0b11, GPR32, uimm12s1, "ldrsb",
2068 (sextloadi8 (am_indexed8 GPR64sp:$Rn,
2069 uimm12s1:$offset)))]>;
2070 defm LDRSBX : LoadUI<0b00, 0, 0b10, GPR64, uimm12s1, "ldrsb",
2072 (sextloadi8 (am_indexed8 GPR64sp:$Rn,
2073 uimm12s1:$offset)))]>;
2075 // load sign-extended word
2076 defm LDRSW : LoadUI<0b10, 0, 0b10, GPR64, uimm12s4, "ldrsw",
2078 (sextloadi32 (am_indexed32 GPR64sp:$Rn,
2079 uimm12s4:$offset)))]>;
2081 // load zero-extended word
2082 def : Pat<(i64 (zextloadi32 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))),
2083 (SUBREG_TO_REG (i64 0), (LDRWui GPR64sp:$Rn, uimm12s4:$offset), sub_32)>;
2086 def PRFMui : PrefetchUI<0b11, 0, 0b10, "prfm",
2087 [(AArch64Prefetch imm:$Rt,
2088 (am_indexed64 GPR64sp:$Rn,
2089 uimm12s8:$offset))]>;
2091 def : InstAlias<"prfm $Rt, [$Rn]", (PRFMui prfop:$Rt, GPR64sp:$Rn, 0)>;
2096 def alignedglobal : PatLeaf<(iPTR iPTR:$label), [{
2097 if (auto *G = dyn_cast<GlobalAddressSDNode>(N)) {
2098 const DataLayout &DL = MF->getDataLayout();
2099 unsigned Align = G->getGlobal()->getPointerAlignment(DL);
2100 return Align >= 4 && G->getOffset() % 4 == 0;
2102 if (auto *C = dyn_cast<ConstantPoolSDNode>(N))
2103 return C->getAlignment() >= 4 && C->getOffset() % 4 == 0;
2107 def LDRWl : LoadLiteral<0b00, 0, GPR32z, "ldr",
2108 [(set GPR32z:$Rt, (load (AArch64adr alignedglobal:$label)))]>;
2109 def LDRXl : LoadLiteral<0b01, 0, GPR64z, "ldr",
2110 [(set GPR64z:$Rt, (load (AArch64adr alignedglobal:$label)))]>;
2111 def LDRSl : LoadLiteral<0b00, 1, FPR32Op, "ldr",
2112 [(set (f32 FPR32Op:$Rt), (load (AArch64adr alignedglobal:$label)))]>;
2113 def LDRDl : LoadLiteral<0b01, 1, FPR64Op, "ldr",
2114 [(set (f64 FPR64Op:$Rt), (load (AArch64adr alignedglobal:$label)))]>;
2115 def LDRQl : LoadLiteral<0b10, 1, FPR128Op, "ldr",
2116 [(set (f128 FPR128Op:$Rt), (load (AArch64adr alignedglobal:$label)))]>;
2118 // load sign-extended word
2119 def LDRSWl : LoadLiteral<0b10, 0, GPR64z, "ldrsw",
2120 [(set GPR64z:$Rt, (sextloadi32 (AArch64adr alignedglobal:$label)))]>;
2122 let AddedComplexity = 20 in {
2123 def : Pat<(i64 (zextloadi32 (AArch64adr alignedglobal:$label))),
2124 (SUBREG_TO_REG (i64 0), (LDRWl $label), sub_32)>;
2128 def PRFMl : PrefetchLiteral<0b11, 0, "prfm", []>;
2129 // [(AArch64Prefetch imm:$Rt, tglobaladdr:$label)]>;
2132 // (unscaled immediate)
2133 defm LDURX : LoadUnscaled<0b11, 0, 0b01, GPR64z, "ldur",
2135 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset)))]>;
2136 defm LDURW : LoadUnscaled<0b10, 0, 0b01, GPR32z, "ldur",
2138 (load (am_unscaled32 GPR64sp:$Rn, simm9:$offset)))]>;
2139 defm LDURB : LoadUnscaled<0b00, 1, 0b01, FPR8Op, "ldur",
2141 (load (am_unscaled8 GPR64sp:$Rn, simm9:$offset)))]>;
2142 defm LDURH : LoadUnscaled<0b01, 1, 0b01, FPR16Op, "ldur",
2144 (load (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
2145 defm LDURS : LoadUnscaled<0b10, 1, 0b01, FPR32Op, "ldur",
2146 [(set (f32 FPR32Op:$Rt),
2147 (load (am_unscaled32 GPR64sp:$Rn, simm9:$offset)))]>;
2148 defm LDURD : LoadUnscaled<0b11, 1, 0b01, FPR64Op, "ldur",
2149 [(set (f64 FPR64Op:$Rt),
2150 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset)))]>;
2151 defm LDURQ : LoadUnscaled<0b00, 1, 0b11, FPR128Op, "ldur",
2152 [(set (f128 FPR128Op:$Rt),
2153 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset)))]>;
2156 : LoadUnscaled<0b01, 0, 0b01, GPR32, "ldurh",
2158 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
2160 : LoadUnscaled<0b00, 0, 0b01, GPR32, "ldurb",
2162 (zextloadi8 (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
2164 // Match all load 64 bits width whose type is compatible with FPR64
2165 let Predicates = [IsLE] in {
2166 def : Pat<(v2f32 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2167 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2168 def : Pat<(v2i32 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2169 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2170 def : Pat<(v4i16 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2171 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2172 def : Pat<(v8i8 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2173 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2174 def : Pat<(v4f16 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2175 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2177 def : Pat<(v1f64 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2178 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2179 def : Pat<(v1i64 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
2180 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
2182 // Match all load 128 bits width whose type is compatible with FPR128
2183 let Predicates = [IsLE] in {
2184 def : Pat<(v2f64 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2185 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2186 def : Pat<(v2i64 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2187 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2188 def : Pat<(v4f32 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2189 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2190 def : Pat<(v4i32 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2191 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2192 def : Pat<(v8i16 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2193 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2194 def : Pat<(v16i8 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2195 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2196 def : Pat<(v8f16 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
2197 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
2201 def : Pat<(i32 (extloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
2202 (LDURHHi GPR64sp:$Rn, simm9:$offset)>;
2203 def : Pat<(i32 (extloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2204 (LDURBBi GPR64sp:$Rn, simm9:$offset)>;
2205 def : Pat<(i32 (extloadi1 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2206 (LDURBBi GPR64sp:$Rn, simm9:$offset)>;
2207 def : Pat<(i64 (extloadi32 (am_unscaled32 GPR64sp:$Rn, simm9:$offset))),
2208 (SUBREG_TO_REG (i64 0), (LDURWi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2209 def : Pat<(i64 (extloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
2210 (SUBREG_TO_REG (i64 0), (LDURHHi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2211 def : Pat<(i64 (extloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2212 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2213 def : Pat<(i64 (extloadi1 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2214 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2216 def : Pat<(i32 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
2217 (LDURHHi GPR64sp:$Rn, simm9:$offset)>;
2218 def : Pat<(i32 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2219 (LDURBBi GPR64sp:$Rn, simm9:$offset)>;
2220 def : Pat<(i32 (zextloadi1 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2221 (LDURBBi GPR64sp:$Rn, simm9:$offset)>;
2222 def : Pat<(i64 (zextloadi32 (am_unscaled32 GPR64sp:$Rn, simm9:$offset))),
2223 (SUBREG_TO_REG (i64 0), (LDURWi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2224 def : Pat<(i64 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
2225 (SUBREG_TO_REG (i64 0), (LDURHHi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2226 def : Pat<(i64 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2227 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2228 def : Pat<(i64 (zextloadi1 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2229 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2233 // LDR mnemonics fall back to LDUR for negative or unaligned offsets.
2235 // Define new assembler match classes as we want to only match these when
2236 // the don't otherwise match the scaled addressing mode for LDR/STR. Don't
2237 // associate a DiagnosticType either, as we want the diagnostic for the
2238 // canonical form (the scaled operand) to take precedence.
2239 class SImm9OffsetOperand<int Width> : AsmOperandClass {
2240 let Name = "SImm9OffsetFB" # Width;
2241 let PredicateMethod = "isSImm9OffsetFB<" # Width # ">";
2242 let RenderMethod = "addImmOperands";
2245 def SImm9OffsetFB8Operand : SImm9OffsetOperand<8>;
2246 def SImm9OffsetFB16Operand : SImm9OffsetOperand<16>;
2247 def SImm9OffsetFB32Operand : SImm9OffsetOperand<32>;
2248 def SImm9OffsetFB64Operand : SImm9OffsetOperand<64>;
2249 def SImm9OffsetFB128Operand : SImm9OffsetOperand<128>;
2251 def simm9_offset_fb8 : Operand<i64> {
2252 let ParserMatchClass = SImm9OffsetFB8Operand;
2254 def simm9_offset_fb16 : Operand<i64> {
2255 let ParserMatchClass = SImm9OffsetFB16Operand;
2257 def simm9_offset_fb32 : Operand<i64> {
2258 let ParserMatchClass = SImm9OffsetFB32Operand;
2260 def simm9_offset_fb64 : Operand<i64> {
2261 let ParserMatchClass = SImm9OffsetFB64Operand;
2263 def simm9_offset_fb128 : Operand<i64> {
2264 let ParserMatchClass = SImm9OffsetFB128Operand;
2267 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2268 (LDURXi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb64:$offset), 0>;
2269 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2270 (LDURWi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
2271 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2272 (LDURBi FPR8Op:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2273 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2274 (LDURHi FPR16Op:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2275 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2276 (LDURSi FPR32Op:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
2277 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2278 (LDURDi FPR64Op:$Rt, GPR64sp:$Rn, simm9_offset_fb64:$offset), 0>;
2279 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
2280 (LDURQi FPR128Op:$Rt, GPR64sp:$Rn, simm9_offset_fb128:$offset), 0>;
2283 def : Pat<(i64 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
2284 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2285 def : Pat<(i64 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
2286 (SUBREG_TO_REG (i64 0), (LDURHHi GPR64sp:$Rn, simm9:$offset), sub_32)>;
2288 // load sign-extended half-word
2290 : LoadUnscaled<0b01, 0, 0b11, GPR32, "ldursh",
2292 (sextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
2294 : LoadUnscaled<0b01, 0, 0b10, GPR64, "ldursh",
2296 (sextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
2298 // load sign-extended byte
2300 : LoadUnscaled<0b00, 0, 0b11, GPR32, "ldursb",
2302 (sextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset)))]>;
2304 : LoadUnscaled<0b00, 0, 0b10, GPR64, "ldursb",
2306 (sextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset)))]>;
2308 // load sign-extended word
2310 : LoadUnscaled<0b10, 0, 0b10, GPR64, "ldursw",
2312 (sextloadi32 (am_unscaled32 GPR64sp:$Rn, simm9:$offset)))]>;
2314 // zero and sign extending aliases from generic LDR* mnemonics to LDUR*.
2315 def : InstAlias<"ldrb $Rt, [$Rn, $offset]",
2316 (LDURBBi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2317 def : InstAlias<"ldrh $Rt, [$Rn, $offset]",
2318 (LDURHHi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2319 def : InstAlias<"ldrsb $Rt, [$Rn, $offset]",
2320 (LDURSBWi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2321 def : InstAlias<"ldrsb $Rt, [$Rn, $offset]",
2322 (LDURSBXi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2323 def : InstAlias<"ldrsh $Rt, [$Rn, $offset]",
2324 (LDURSHWi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2325 def : InstAlias<"ldrsh $Rt, [$Rn, $offset]",
2326 (LDURSHXi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2327 def : InstAlias<"ldrsw $Rt, [$Rn, $offset]",
2328 (LDURSWi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
2331 defm PRFUM : PrefetchUnscaled<0b11, 0, 0b10, "prfum",
2332 [(AArch64Prefetch imm:$Rt,
2333 (am_unscaled64 GPR64sp:$Rn, simm9:$offset))]>;
2336 // (unscaled immediate, unprivileged)
2337 defm LDTRX : LoadUnprivileged<0b11, 0, 0b01, GPR64, "ldtr">;
2338 defm LDTRW : LoadUnprivileged<0b10, 0, 0b01, GPR32, "ldtr">;
2340 defm LDTRH : LoadUnprivileged<0b01, 0, 0b01, GPR32, "ldtrh">;
2341 defm LDTRB : LoadUnprivileged<0b00, 0, 0b01, GPR32, "ldtrb">;
2343 // load sign-extended half-word
2344 defm LDTRSHW : LoadUnprivileged<0b01, 0, 0b11, GPR32, "ldtrsh">;
2345 defm LDTRSHX : LoadUnprivileged<0b01, 0, 0b10, GPR64, "ldtrsh">;
2347 // load sign-extended byte
2348 defm LDTRSBW : LoadUnprivileged<0b00, 0, 0b11, GPR32, "ldtrsb">;
2349 defm LDTRSBX : LoadUnprivileged<0b00, 0, 0b10, GPR64, "ldtrsb">;
2351 // load sign-extended word
2352 defm LDTRSW : LoadUnprivileged<0b10, 0, 0b10, GPR64, "ldtrsw">;
2355 // (immediate pre-indexed)
2356 def LDRWpre : LoadPreIdx<0b10, 0, 0b01, GPR32z, "ldr">;
2357 def LDRXpre : LoadPreIdx<0b11, 0, 0b01, GPR64z, "ldr">;
2358 def LDRBpre : LoadPreIdx<0b00, 1, 0b01, FPR8Op, "ldr">;
2359 def LDRHpre : LoadPreIdx<0b01, 1, 0b01, FPR16Op, "ldr">;
2360 def LDRSpre : LoadPreIdx<0b10, 1, 0b01, FPR32Op, "ldr">;
2361 def LDRDpre : LoadPreIdx<0b11, 1, 0b01, FPR64Op, "ldr">;
2362 def LDRQpre : LoadPreIdx<0b00, 1, 0b11, FPR128Op, "ldr">;
2364 // load sign-extended half-word
2365 def LDRSHWpre : LoadPreIdx<0b01, 0, 0b11, GPR32z, "ldrsh">;
2366 def LDRSHXpre : LoadPreIdx<0b01, 0, 0b10, GPR64z, "ldrsh">;
2368 // load sign-extended byte
2369 def LDRSBWpre : LoadPreIdx<0b00, 0, 0b11, GPR32z, "ldrsb">;
2370 def LDRSBXpre : LoadPreIdx<0b00, 0, 0b10, GPR64z, "ldrsb">;
2372 // load zero-extended byte
2373 def LDRBBpre : LoadPreIdx<0b00, 0, 0b01, GPR32z, "ldrb">;
2374 def LDRHHpre : LoadPreIdx<0b01, 0, 0b01, GPR32z, "ldrh">;
2376 // load sign-extended word
2377 def LDRSWpre : LoadPreIdx<0b10, 0, 0b10, GPR64z, "ldrsw">;
2380 // (immediate post-indexed)
2381 def LDRWpost : LoadPostIdx<0b10, 0, 0b01, GPR32z, "ldr">;
2382 def LDRXpost : LoadPostIdx<0b11, 0, 0b01, GPR64z, "ldr">;
2383 def LDRBpost : LoadPostIdx<0b00, 1, 0b01, FPR8Op, "ldr">;
2384 def LDRHpost : LoadPostIdx<0b01, 1, 0b01, FPR16Op, "ldr">;
2385 def LDRSpost : LoadPostIdx<0b10, 1, 0b01, FPR32Op, "ldr">;
2386 def LDRDpost : LoadPostIdx<0b11, 1, 0b01, FPR64Op, "ldr">;
2387 def LDRQpost : LoadPostIdx<0b00, 1, 0b11, FPR128Op, "ldr">;
2389 // load sign-extended half-word
2390 def LDRSHWpost : LoadPostIdx<0b01, 0, 0b11, GPR32z, "ldrsh">;
2391 def LDRSHXpost : LoadPostIdx<0b01, 0, 0b10, GPR64z, "ldrsh">;
2393 // load sign-extended byte
2394 def LDRSBWpost : LoadPostIdx<0b00, 0, 0b11, GPR32z, "ldrsb">;
2395 def LDRSBXpost : LoadPostIdx<0b00, 0, 0b10, GPR64z, "ldrsb">;
2397 // load zero-extended byte
2398 def LDRBBpost : LoadPostIdx<0b00, 0, 0b01, GPR32z, "ldrb">;
2399 def LDRHHpost : LoadPostIdx<0b01, 0, 0b01, GPR32z, "ldrh">;
2401 // load sign-extended word
2402 def LDRSWpost : LoadPostIdx<0b10, 0, 0b10, GPR64z, "ldrsw">;
2404 //===----------------------------------------------------------------------===//
2405 // Store instructions.
2406 //===----------------------------------------------------------------------===//
2408 // Pair (indexed, offset)
2409 // FIXME: Use dedicated range-checked addressing mode operand here.
2410 defm STPW : StorePairOffset<0b00, 0, GPR32z, simm7s4, "stp">;
2411 defm STPX : StorePairOffset<0b10, 0, GPR64z, simm7s8, "stp">;
2412 defm STPS : StorePairOffset<0b00, 1, FPR32Op, simm7s4, "stp">;
2413 defm STPD : StorePairOffset<0b01, 1, FPR64Op, simm7s8, "stp">;
2414 defm STPQ : StorePairOffset<0b10, 1, FPR128Op, simm7s16, "stp">;
2416 // Pair (pre-indexed)
2417 def STPWpre : StorePairPreIdx<0b00, 0, GPR32z, simm7s4, "stp">;
2418 def STPXpre : StorePairPreIdx<0b10, 0, GPR64z, simm7s8, "stp">;
2419 def STPSpre : StorePairPreIdx<0b00, 1, FPR32Op, simm7s4, "stp">;
2420 def STPDpre : StorePairPreIdx<0b01, 1, FPR64Op, simm7s8, "stp">;
2421 def STPQpre : StorePairPreIdx<0b10, 1, FPR128Op, simm7s16, "stp">;
2423 // Pair (pre-indexed)
2424 def STPWpost : StorePairPostIdx<0b00, 0, GPR32z, simm7s4, "stp">;
2425 def STPXpost : StorePairPostIdx<0b10, 0, GPR64z, simm7s8, "stp">;
2426 def STPSpost : StorePairPostIdx<0b00, 1, FPR32Op, simm7s4, "stp">;
2427 def STPDpost : StorePairPostIdx<0b01, 1, FPR64Op, simm7s8, "stp">;
2428 def STPQpost : StorePairPostIdx<0b10, 1, FPR128Op, simm7s16, "stp">;
2430 // Pair (no allocate)
2431 defm STNPW : StorePairNoAlloc<0b00, 0, GPR32z, simm7s4, "stnp">;
2432 defm STNPX : StorePairNoAlloc<0b10, 0, GPR64z, simm7s8, "stnp">;
2433 defm STNPS : StorePairNoAlloc<0b00, 1, FPR32Op, simm7s4, "stnp">;
2434 defm STNPD : StorePairNoAlloc<0b01, 1, FPR64Op, simm7s8, "stnp">;
2435 defm STNPQ : StorePairNoAlloc<0b10, 1, FPR128Op, simm7s16, "stnp">;
2438 // (Register offset)
2441 defm STRBB : Store8RO< 0b00, 0, 0b00, GPR32, "strb", i32, truncstorei8>;
2442 defm STRHH : Store16RO<0b01, 0, 0b00, GPR32, "strh", i32, truncstorei16>;
2443 defm STRW : Store32RO<0b10, 0, 0b00, GPR32, "str", i32, store>;
2444 defm STRX : Store64RO<0b11, 0, 0b00, GPR64, "str", i64, store>;
2448 defm STRB : Store8RO< 0b00, 1, 0b00, FPR8Op, "str", untyped, store>;
2449 defm STRH : Store16RO<0b01, 1, 0b00, FPR16Op, "str", f16, store>;
2450 defm STRS : Store32RO<0b10, 1, 0b00, FPR32Op, "str", f32, store>;
2451 defm STRD : Store64RO<0b11, 1, 0b00, FPR64Op, "str", f64, store>;
2452 defm STRQ : Store128RO<0b00, 1, 0b10, FPR128Op, "str", f128, store>;
2454 let Predicates = [UseSTRQro], AddedComplexity = 10 in {
2455 def : Pat<(store (f128 FPR128:$Rt),
2456 (ro_Windexed128 GPR64sp:$Rn, GPR32:$Rm,
2457 ro_Wextend128:$extend)),
2458 (STRQroW FPR128:$Rt, GPR64sp:$Rn, GPR32:$Rm, ro_Wextend128:$extend)>;
2459 def : Pat<(store (f128 FPR128:$Rt),
2460 (ro_Xindexed128 GPR64sp:$Rn, GPR64:$Rm,
2461 ro_Xextend128:$extend)),
2462 (STRQroX FPR128:$Rt, GPR64sp:$Rn, GPR64:$Rm, ro_Wextend128:$extend)>;
2465 multiclass TruncStoreFrom64ROPat<ROAddrMode ro, SDPatternOperator storeop,
2466 Instruction STRW, Instruction STRX> {
2468 def : Pat<(storeop GPR64:$Rt,
2469 (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)),
2470 (STRW (EXTRACT_SUBREG GPR64:$Rt, sub_32),
2471 GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
2473 def : Pat<(storeop GPR64:$Rt,
2474 (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)),
2475 (STRX (EXTRACT_SUBREG GPR64:$Rt, sub_32),
2476 GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
2479 let AddedComplexity = 10 in {
2481 defm : TruncStoreFrom64ROPat<ro8, truncstorei8, STRBBroW, STRBBroX>;
2482 defm : TruncStoreFrom64ROPat<ro16, truncstorei16, STRHHroW, STRHHroX>;
2483 defm : TruncStoreFrom64ROPat<ro32, truncstorei32, STRWroW, STRWroX>;
2486 multiclass VecROStorePat<ROAddrMode ro, ValueType VecTy, RegisterClass FPR,
2487 Instruction STRW, Instruction STRX> {
2488 def : Pat<(store (VecTy FPR:$Rt),
2489 (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)),
2490 (STRW FPR:$Rt, GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
2492 def : Pat<(store (VecTy FPR:$Rt),
2493 (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)),
2494 (STRX FPR:$Rt, GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
2497 let AddedComplexity = 10 in {
2498 // Match all store 64 bits width whose type is compatible with FPR64
2499 let Predicates = [IsLE] in {
2500 // We must use ST1 to store vectors in big-endian.
2501 defm : VecROStorePat<ro64, v2i32, FPR64, STRDroW, STRDroX>;
2502 defm : VecROStorePat<ro64, v2f32, FPR64, STRDroW, STRDroX>;
2503 defm : VecROStorePat<ro64, v4i16, FPR64, STRDroW, STRDroX>;
2504 defm : VecROStorePat<ro64, v8i8, FPR64, STRDroW, STRDroX>;
2505 defm : VecROStorePat<ro64, v4f16, FPR64, STRDroW, STRDroX>;
2508 defm : VecROStorePat<ro64, v1i64, FPR64, STRDroW, STRDroX>;
2509 defm : VecROStorePat<ro64, v1f64, FPR64, STRDroW, STRDroX>;
2511 // Match all store 128 bits width whose type is compatible with FPR128
2512 let Predicates = [IsLE, UseSTRQro] in {
2513 // We must use ST1 to store vectors in big-endian.
2514 defm : VecROStorePat<ro128, v2i64, FPR128, STRQroW, STRQroX>;
2515 defm : VecROStorePat<ro128, v2f64, FPR128, STRQroW, STRQroX>;
2516 defm : VecROStorePat<ro128, v4i32, FPR128, STRQroW, STRQroX>;
2517 defm : VecROStorePat<ro128, v4f32, FPR128, STRQroW, STRQroX>;
2518 defm : VecROStorePat<ro128, v8i16, FPR128, STRQroW, STRQroX>;
2519 defm : VecROStorePat<ro128, v16i8, FPR128, STRQroW, STRQroX>;
2520 defm : VecROStorePat<ro128, v8f16, FPR128, STRQroW, STRQroX>;
2522 } // AddedComplexity = 10
2524 // Match stores from lane 0 to the appropriate subreg's store.
2525 multiclass VecROStoreLane0Pat<ROAddrMode ro, SDPatternOperator storeop,
2526 ValueType VecTy, ValueType STy,
2527 SubRegIndex SubRegIdx,
2528 Instruction STRW, Instruction STRX> {
2530 def : Pat<(storeop (STy (vector_extract (VecTy VecListOne128:$Vt), 0)),
2531 (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)),
2532 (STRW (EXTRACT_SUBREG VecListOne128:$Vt, SubRegIdx),
2533 GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
2535 def : Pat<(storeop (STy (vector_extract (VecTy VecListOne128:$Vt), 0)),
2536 (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)),
2537 (STRX (EXTRACT_SUBREG VecListOne128:$Vt, SubRegIdx),
2538 GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
2541 let AddedComplexity = 19 in {
2542 defm : VecROStoreLane0Pat<ro16, truncstorei16, v8i16, i32, hsub, STRHroW, STRHroX>;
2543 defm : VecROStoreLane0Pat<ro16, store, v8f16, f16, hsub, STRHroW, STRHroX>;
2544 defm : VecROStoreLane0Pat<ro32, store, v4i32, i32, ssub, STRSroW, STRSroX>;
2545 defm : VecROStoreLane0Pat<ro32, store, v4f32, f32, ssub, STRSroW, STRSroX>;
2546 defm : VecROStoreLane0Pat<ro64, store, v2i64, i64, dsub, STRDroW, STRDroX>;
2547 defm : VecROStoreLane0Pat<ro64, store, v2f64, f64, dsub, STRDroW, STRDroX>;
2551 // (unsigned immediate)
2552 defm STRX : StoreUIz<0b11, 0, 0b00, GPR64z, uimm12s8, "str",
2554 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))]>;
2555 defm STRW : StoreUIz<0b10, 0, 0b00, GPR32z, uimm12s4, "str",
2557 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))]>;
2558 defm STRB : StoreUI<0b00, 1, 0b00, FPR8Op, uimm12s1, "str",
2560 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))]>;
2561 defm STRH : StoreUI<0b01, 1, 0b00, FPR16Op, uimm12s2, "str",
2562 [(store (f16 FPR16Op:$Rt),
2563 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))]>;
2564 defm STRS : StoreUI<0b10, 1, 0b00, FPR32Op, uimm12s4, "str",
2565 [(store (f32 FPR32Op:$Rt),
2566 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))]>;
2567 defm STRD : StoreUI<0b11, 1, 0b00, FPR64Op, uimm12s8, "str",
2568 [(store (f64 FPR64Op:$Rt),
2569 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))]>;
2570 defm STRQ : StoreUI<0b00, 1, 0b10, FPR128Op, uimm12s16, "str", []>;
2572 defm STRHH : StoreUIz<0b01, 0, 0b00, GPR32z, uimm12s2, "strh",
2573 [(truncstorei16 GPR32z:$Rt,
2574 (am_indexed16 GPR64sp:$Rn,
2575 uimm12s2:$offset))]>;
2576 defm STRBB : StoreUIz<0b00, 0, 0b00, GPR32z, uimm12s1, "strb",
2577 [(truncstorei8 GPR32z:$Rt,
2578 (am_indexed8 GPR64sp:$Rn,
2579 uimm12s1:$offset))]>;
2581 let AddedComplexity = 10 in {
2583 // Match all store 64 bits width whose type is compatible with FPR64
2584 def : Pat<(store (v1i64 FPR64:$Rt),
2585 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2586 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2587 def : Pat<(store (v1f64 FPR64:$Rt),
2588 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2589 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2591 let Predicates = [IsLE] in {
2592 // We must use ST1 to store vectors in big-endian.
2593 def : Pat<(store (v2f32 FPR64:$Rt),
2594 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2595 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2596 def : Pat<(store (v8i8 FPR64:$Rt),
2597 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2598 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2599 def : Pat<(store (v4i16 FPR64:$Rt),
2600 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2601 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2602 def : Pat<(store (v2i32 FPR64:$Rt),
2603 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2604 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2605 def : Pat<(store (v4f16 FPR64:$Rt),
2606 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
2607 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
2610 // Match all store 128 bits width whose type is compatible with FPR128
2611 def : Pat<(store (f128 FPR128:$Rt),
2612 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2613 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2615 let Predicates = [IsLE] in {
2616 // We must use ST1 to store vectors in big-endian.
2617 def : Pat<(store (v4f32 FPR128:$Rt),
2618 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2619 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2620 def : Pat<(store (v2f64 FPR128:$Rt),
2621 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2622 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2623 def : Pat<(store (v16i8 FPR128:$Rt),
2624 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2625 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2626 def : Pat<(store (v8i16 FPR128:$Rt),
2627 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2628 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2629 def : Pat<(store (v4i32 FPR128:$Rt),
2630 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2631 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2632 def : Pat<(store (v2i64 FPR128:$Rt),
2633 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2634 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2635 def : Pat<(store (v8f16 FPR128:$Rt),
2636 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
2637 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
2641 def : Pat<(truncstorei32 GPR64:$Rt,
2642 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset)),
2643 (STRWui (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, uimm12s4:$offset)>;
2644 def : Pat<(truncstorei16 GPR64:$Rt,
2645 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset)),
2646 (STRHHui (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, uimm12s2:$offset)>;
2647 def : Pat<(truncstorei8 GPR64:$Rt, (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset)),
2648 (STRBBui (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, uimm12s1:$offset)>;
2650 } // AddedComplexity = 10
2652 // Match stores from lane 0 to the appropriate subreg's store.
2653 multiclass VecStoreLane0Pat<Operand UIAddrMode, SDPatternOperator storeop,
2654 ValueType VTy, ValueType STy,
2655 SubRegIndex SubRegIdx, Operand IndexType,
2657 def : Pat<(storeop (STy (vector_extract (VTy VecListOne128:$Vt), 0)),
2658 (UIAddrMode GPR64sp:$Rn, IndexType:$offset)),
2659 (STR (EXTRACT_SUBREG VecListOne128:$Vt, SubRegIdx),
2660 GPR64sp:$Rn, IndexType:$offset)>;
2663 let AddedComplexity = 19 in {
2664 defm : VecStoreLane0Pat<am_indexed16, truncstorei16, v8i16, i32, hsub, uimm12s2, STRHui>;
2665 defm : VecStoreLane0Pat<am_indexed16, store, v8f16, f16, hsub, uimm12s2, STRHui>;
2666 defm : VecStoreLane0Pat<am_indexed32, store, v4i32, i32, ssub, uimm12s4, STRSui>;
2667 defm : VecStoreLane0Pat<am_indexed32, store, v4f32, f32, ssub, uimm12s4, STRSui>;
2668 defm : VecStoreLane0Pat<am_indexed64, store, v2i64, i64, dsub, uimm12s8, STRDui>;
2669 defm : VecStoreLane0Pat<am_indexed64, store, v2f64, f64, dsub, uimm12s8, STRDui>;
2673 // (unscaled immediate)
2674 defm STURX : StoreUnscaled<0b11, 0, 0b00, GPR64z, "stur",
2676 (am_unscaled64 GPR64sp:$Rn, simm9:$offset))]>;
2677 defm STURW : StoreUnscaled<0b10, 0, 0b00, GPR32z, "stur",
2679 (am_unscaled32 GPR64sp:$Rn, simm9:$offset))]>;
2680 defm STURB : StoreUnscaled<0b00, 1, 0b00, FPR8Op, "stur",
2682 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))]>;
2683 defm STURH : StoreUnscaled<0b01, 1, 0b00, FPR16Op, "stur",
2684 [(store (f16 FPR16Op:$Rt),
2685 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))]>;
2686 defm STURS : StoreUnscaled<0b10, 1, 0b00, FPR32Op, "stur",
2687 [(store (f32 FPR32Op:$Rt),
2688 (am_unscaled32 GPR64sp:$Rn, simm9:$offset))]>;
2689 defm STURD : StoreUnscaled<0b11, 1, 0b00, FPR64Op, "stur",
2690 [(store (f64 FPR64Op:$Rt),
2691 (am_unscaled64 GPR64sp:$Rn, simm9:$offset))]>;
2692 defm STURQ : StoreUnscaled<0b00, 1, 0b10, FPR128Op, "stur",
2693 [(store (f128 FPR128Op:$Rt),
2694 (am_unscaled128 GPR64sp:$Rn, simm9:$offset))]>;
2695 defm STURHH : StoreUnscaled<0b01, 0, 0b00, GPR32z, "sturh",
2696 [(truncstorei16 GPR32z:$Rt,
2697 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))]>;
2698 defm STURBB : StoreUnscaled<0b00, 0, 0b00, GPR32z, "sturb",
2699 [(truncstorei8 GPR32z:$Rt,
2700 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))]>;
2702 // Armv8.4 Weaker Release Consistency enhancements
2703 // LDAPR & STLR with Immediate Offset instructions
2704 let Predicates = [HasRCPC_IMMO] in {
2705 defm STLURB : BaseStoreUnscaleV84<"stlurb", 0b00, 0b00, GPR32>;
2706 defm STLURH : BaseStoreUnscaleV84<"stlurh", 0b01, 0b00, GPR32>;
2707 defm STLURW : BaseStoreUnscaleV84<"stlur", 0b10, 0b00, GPR32>;
2708 defm STLURX : BaseStoreUnscaleV84<"stlur", 0b11, 0b00, GPR64>;
2709 defm LDAPURB : BaseLoadUnscaleV84<"ldapurb", 0b00, 0b01, GPR32>;
2710 defm LDAPURSBW : BaseLoadUnscaleV84<"ldapursb", 0b00, 0b11, GPR32>;
2711 defm LDAPURSBX : BaseLoadUnscaleV84<"ldapursb", 0b00, 0b10, GPR64>;
2712 defm LDAPURH : BaseLoadUnscaleV84<"ldapurh", 0b01, 0b01, GPR32>;
2713 defm LDAPURSHW : BaseLoadUnscaleV84<"ldapursh", 0b01, 0b11, GPR32>;
2714 defm LDAPURSHX : BaseLoadUnscaleV84<"ldapursh", 0b01, 0b10, GPR64>;
2715 defm LDAPUR : BaseLoadUnscaleV84<"ldapur", 0b10, 0b01, GPR32>;
2716 defm LDAPURSW : BaseLoadUnscaleV84<"ldapursw", 0b10, 0b10, GPR64>;
2717 defm LDAPURX : BaseLoadUnscaleV84<"ldapur", 0b11, 0b01, GPR64>;
2720 // Match all store 64 bits width whose type is compatible with FPR64
2721 def : Pat<(store (v1f64 FPR64:$Rt), (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2722 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2723 def : Pat<(store (v1i64 FPR64:$Rt), (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2724 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2726 let AddedComplexity = 10 in {
2728 let Predicates = [IsLE] in {
2729 // We must use ST1 to store vectors in big-endian.
2730 def : Pat<(store (v2f32 FPR64:$Rt),
2731 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2732 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2733 def : Pat<(store (v8i8 FPR64:$Rt),
2734 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2735 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2736 def : Pat<(store (v4i16 FPR64:$Rt),
2737 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2738 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2739 def : Pat<(store (v2i32 FPR64:$Rt),
2740 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2741 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2742 def : Pat<(store (v4f16 FPR64:$Rt),
2743 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2744 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2747 // Match all store 128 bits width whose type is compatible with FPR128
2748 def : Pat<(store (f128 FPR128:$Rt), (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2749 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2751 let Predicates = [IsLE] in {
2752 // We must use ST1 to store vectors in big-endian.
2753 def : Pat<(store (v4f32 FPR128:$Rt),
2754 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2755 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2756 def : Pat<(store (v2f64 FPR128:$Rt),
2757 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2758 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2759 def : Pat<(store (v16i8 FPR128:$Rt),
2760 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2761 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2762 def : Pat<(store (v8i16 FPR128:$Rt),
2763 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2764 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2765 def : Pat<(store (v4i32 FPR128:$Rt),
2766 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2767 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2768 def : Pat<(store (v2i64 FPR128:$Rt),
2769 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2770 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2771 def : Pat<(store (v2f64 FPR128:$Rt),
2772 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2773 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2774 def : Pat<(store (v8f16 FPR128:$Rt),
2775 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2776 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2779 } // AddedComplexity = 10
2781 // unscaled i64 truncating stores
2782 def : Pat<(truncstorei32 GPR64:$Rt, (am_unscaled32 GPR64sp:$Rn, simm9:$offset)),
2783 (STURWi (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, simm9:$offset)>;
2784 def : Pat<(truncstorei16 GPR64:$Rt, (am_unscaled16 GPR64sp:$Rn, simm9:$offset)),
2785 (STURHHi (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, simm9:$offset)>;
2786 def : Pat<(truncstorei8 GPR64:$Rt, (am_unscaled8 GPR64sp:$Rn, simm9:$offset)),
2787 (STURBBi (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, simm9:$offset)>;
2789 // Match stores from lane 0 to the appropriate subreg's store.
2790 multiclass VecStoreULane0Pat<SDPatternOperator StoreOp,
2791 ValueType VTy, ValueType STy,
2792 SubRegIndex SubRegIdx, Instruction STR> {
2793 defm : VecStoreLane0Pat<am_unscaled128, StoreOp, VTy, STy, SubRegIdx, simm9, STR>;
2796 let AddedComplexity = 19 in {
2797 defm : VecStoreULane0Pat<truncstorei16, v8i16, i32, hsub, STURHi>;
2798 defm : VecStoreULane0Pat<store, v8f16, f16, hsub, STURHi>;
2799 defm : VecStoreULane0Pat<store, v4i32, i32, ssub, STURSi>;
2800 defm : VecStoreULane0Pat<store, v4f32, f32, ssub, STURSi>;
2801 defm : VecStoreULane0Pat<store, v2i64, i64, dsub, STURDi>;
2802 defm : VecStoreULane0Pat<store, v2f64, f64, dsub, STURDi>;
2806 // STR mnemonics fall back to STUR for negative or unaligned offsets.
2807 def : InstAlias<"str $Rt, [$Rn, $offset]",
2808 (STURXi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb64:$offset), 0>;
2809 def : InstAlias<"str $Rt, [$Rn, $offset]",
2810 (STURWi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
2811 def : InstAlias<"str $Rt, [$Rn, $offset]",
2812 (STURBi FPR8Op:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2813 def : InstAlias<"str $Rt, [$Rn, $offset]",
2814 (STURHi FPR16Op:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2815 def : InstAlias<"str $Rt, [$Rn, $offset]",
2816 (STURSi FPR32Op:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
2817 def : InstAlias<"str $Rt, [$Rn, $offset]",
2818 (STURDi FPR64Op:$Rt, GPR64sp:$Rn, simm9_offset_fb64:$offset), 0>;
2819 def : InstAlias<"str $Rt, [$Rn, $offset]",
2820 (STURQi FPR128Op:$Rt, GPR64sp:$Rn, simm9_offset_fb128:$offset), 0>;
2822 def : InstAlias<"strb $Rt, [$Rn, $offset]",
2823 (STURBBi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2824 def : InstAlias<"strh $Rt, [$Rn, $offset]",
2825 (STURHHi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2828 // (unscaled immediate, unprivileged)
2829 defm STTRW : StoreUnprivileged<0b10, 0, 0b00, GPR32, "sttr">;
2830 defm STTRX : StoreUnprivileged<0b11, 0, 0b00, GPR64, "sttr">;
2832 defm STTRH : StoreUnprivileged<0b01, 0, 0b00, GPR32, "sttrh">;
2833 defm STTRB : StoreUnprivileged<0b00, 0, 0b00, GPR32, "sttrb">;
2836 // (immediate pre-indexed)
2837 def STRWpre : StorePreIdx<0b10, 0, 0b00, GPR32z, "str", pre_store, i32>;
2838 def STRXpre : StorePreIdx<0b11, 0, 0b00, GPR64z, "str", pre_store, i64>;
2839 def STRBpre : StorePreIdx<0b00, 1, 0b00, FPR8Op, "str", pre_store, untyped>;
2840 def STRHpre : StorePreIdx<0b01, 1, 0b00, FPR16Op, "str", pre_store, f16>;
2841 def STRSpre : StorePreIdx<0b10, 1, 0b00, FPR32Op, "str", pre_store, f32>;
2842 def STRDpre : StorePreIdx<0b11, 1, 0b00, FPR64Op, "str", pre_store, f64>;
2843 def STRQpre : StorePreIdx<0b00, 1, 0b10, FPR128Op, "str", pre_store, f128>;
2845 def STRBBpre : StorePreIdx<0b00, 0, 0b00, GPR32z, "strb", pre_truncsti8, i32>;
2846 def STRHHpre : StorePreIdx<0b01, 0, 0b00, GPR32z, "strh", pre_truncsti16, i32>;
2849 def : Pat<(pre_truncsti32 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
2850 (STRWpre (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
2852 def : Pat<(pre_truncsti16 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
2853 (STRHHpre (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
2855 def : Pat<(pre_truncsti8 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
2856 (STRBBpre (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
2859 def : Pat<(pre_store (v8i8 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2860 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2861 def : Pat<(pre_store (v4i16 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2862 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2863 def : Pat<(pre_store (v2i32 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2864 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2865 def : Pat<(pre_store (v2f32 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2866 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2867 def : Pat<(pre_store (v1i64 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2868 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2869 def : Pat<(pre_store (v1f64 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2870 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2871 def : Pat<(pre_store (v4f16 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2872 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2874 def : Pat<(pre_store (v16i8 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2875 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2876 def : Pat<(pre_store (v8i16 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2877 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2878 def : Pat<(pre_store (v4i32 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2879 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2880 def : Pat<(pre_store (v4f32 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2881 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2882 def : Pat<(pre_store (v2i64 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2883 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2884 def : Pat<(pre_store (v2f64 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2885 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2886 def : Pat<(pre_store (v8f16 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2887 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2890 // (immediate post-indexed)
2891 def STRWpost : StorePostIdx<0b10, 0, 0b00, GPR32z, "str", post_store, i32>;
2892 def STRXpost : StorePostIdx<0b11, 0, 0b00, GPR64z, "str", post_store, i64>;
2893 def STRBpost : StorePostIdx<0b00, 1, 0b00, FPR8Op, "str", post_store, untyped>;
2894 def STRHpost : StorePostIdx<0b01, 1, 0b00, FPR16Op, "str", post_store, f16>;
2895 def STRSpost : StorePostIdx<0b10, 1, 0b00, FPR32Op, "str", post_store, f32>;
2896 def STRDpost : StorePostIdx<0b11, 1, 0b00, FPR64Op, "str", post_store, f64>;
2897 def STRQpost : StorePostIdx<0b00, 1, 0b10, FPR128Op, "str", post_store, f128>;
2899 def STRBBpost : StorePostIdx<0b00, 0, 0b00, GPR32z, "strb", post_truncsti8, i32>;
2900 def STRHHpost : StorePostIdx<0b01, 0, 0b00, GPR32z, "strh", post_truncsti16, i32>;
2903 def : Pat<(post_truncsti32 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
2904 (STRWpost (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
2906 def : Pat<(post_truncsti16 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
2907 (STRHHpost (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
2909 def : Pat<(post_truncsti8 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
2910 (STRBBpost (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
2913 def : Pat<(post_store (v8i8 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2914 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2915 def : Pat<(post_store (v4i16 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2916 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2917 def : Pat<(post_store (v2i32 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2918 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2919 def : Pat<(post_store (v2f32 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2920 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2921 def : Pat<(post_store (v1i64 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2922 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2923 def : Pat<(post_store (v1f64 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2924 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2925 def : Pat<(post_store (v4f16 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2926 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2928 def : Pat<(post_store (v16i8 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2929 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2930 def : Pat<(post_store (v8i16 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2931 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2932 def : Pat<(post_store (v4i32 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2933 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2934 def : Pat<(post_store (v4f32 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2935 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2936 def : Pat<(post_store (v2i64 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2937 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2938 def : Pat<(post_store (v2f64 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2939 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2940 def : Pat<(post_store (v8f16 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2941 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2943 //===----------------------------------------------------------------------===//
2944 // Load/store exclusive instructions.
2945 //===----------------------------------------------------------------------===//
2947 def LDARW : LoadAcquire <0b10, 1, 1, 0, 1, GPR32, "ldar">;
2948 def LDARX : LoadAcquire <0b11, 1, 1, 0, 1, GPR64, "ldar">;
2949 def LDARB : LoadAcquire <0b00, 1, 1, 0, 1, GPR32, "ldarb">;
2950 def LDARH : LoadAcquire <0b01, 1, 1, 0, 1, GPR32, "ldarh">;
2952 def LDAXRW : LoadExclusive <0b10, 0, 1, 0, 1, GPR32, "ldaxr">;
2953 def LDAXRX : LoadExclusive <0b11, 0, 1, 0, 1, GPR64, "ldaxr">;
2954 def LDAXRB : LoadExclusive <0b00, 0, 1, 0, 1, GPR32, "ldaxrb">;
2955 def LDAXRH : LoadExclusive <0b01, 0, 1, 0, 1, GPR32, "ldaxrh">;
2957 def LDXRW : LoadExclusive <0b10, 0, 1, 0, 0, GPR32, "ldxr">;
2958 def LDXRX : LoadExclusive <0b11, 0, 1, 0, 0, GPR64, "ldxr">;
2959 def LDXRB : LoadExclusive <0b00, 0, 1, 0, 0, GPR32, "ldxrb">;
2960 def LDXRH : LoadExclusive <0b01, 0, 1, 0, 0, GPR32, "ldxrh">;
2962 def STLRW : StoreRelease <0b10, 1, 0, 0, 1, GPR32, "stlr">;
2963 def STLRX : StoreRelease <0b11, 1, 0, 0, 1, GPR64, "stlr">;
2964 def STLRB : StoreRelease <0b00, 1, 0, 0, 1, GPR32, "stlrb">;
2965 def STLRH : StoreRelease <0b01, 1, 0, 0, 1, GPR32, "stlrh">;
2967 def STLXRW : StoreExclusive<0b10, 0, 0, 0, 1, GPR32, "stlxr">;
2968 def STLXRX : StoreExclusive<0b11, 0, 0, 0, 1, GPR64, "stlxr">;
2969 def STLXRB : StoreExclusive<0b00, 0, 0, 0, 1, GPR32, "stlxrb">;
2970 def STLXRH : StoreExclusive<0b01, 0, 0, 0, 1, GPR32, "stlxrh">;
2972 def STXRW : StoreExclusive<0b10, 0, 0, 0, 0, GPR32, "stxr">;
2973 def STXRX : StoreExclusive<0b11, 0, 0, 0, 0, GPR64, "stxr">;
2974 def STXRB : StoreExclusive<0b00, 0, 0, 0, 0, GPR32, "stxrb">;
2975 def STXRH : StoreExclusive<0b01, 0, 0, 0, 0, GPR32, "stxrh">;
2977 def LDAXPW : LoadExclusivePair<0b10, 0, 1, 1, 1, GPR32, "ldaxp">;
2978 def LDAXPX : LoadExclusivePair<0b11, 0, 1, 1, 1, GPR64, "ldaxp">;
2980 def LDXPW : LoadExclusivePair<0b10, 0, 1, 1, 0, GPR32, "ldxp">;
2981 def LDXPX : LoadExclusivePair<0b11, 0, 1, 1, 0, GPR64, "ldxp">;
2983 def STLXPW : StoreExclusivePair<0b10, 0, 0, 1, 1, GPR32, "stlxp">;
2984 def STLXPX : StoreExclusivePair<0b11, 0, 0, 1, 1, GPR64, "stlxp">;
2986 def STXPW : StoreExclusivePair<0b10, 0, 0, 1, 0, GPR32, "stxp">;
2987 def STXPX : StoreExclusivePair<0b11, 0, 0, 1, 0, GPR64, "stxp">;
2989 let Predicates = [HasLOR] in {
2990 // v8.1a "Limited Order Region" extension load-acquire instructions
2991 def LDLARW : LoadAcquire <0b10, 1, 1, 0, 0, GPR32, "ldlar">;
2992 def LDLARX : LoadAcquire <0b11, 1, 1, 0, 0, GPR64, "ldlar">;
2993 def LDLARB : LoadAcquire <0b00, 1, 1, 0, 0, GPR32, "ldlarb">;
2994 def LDLARH : LoadAcquire <0b01, 1, 1, 0, 0, GPR32, "ldlarh">;
2996 // v8.1a "Limited Order Region" extension store-release instructions
2997 def STLLRW : StoreRelease <0b10, 1, 0, 0, 0, GPR32, "stllr">;
2998 def STLLRX : StoreRelease <0b11, 1, 0, 0, 0, GPR64, "stllr">;
2999 def STLLRB : StoreRelease <0b00, 1, 0, 0, 0, GPR32, "stllrb">;
3000 def STLLRH : StoreRelease <0b01, 1, 0, 0, 0, GPR32, "stllrh">;
3003 //===----------------------------------------------------------------------===//
3004 // Scaled floating point to integer conversion instructions.
3005 //===----------------------------------------------------------------------===//
3007 defm FCVTAS : FPToIntegerUnscaled<0b00, 0b100, "fcvtas", int_aarch64_neon_fcvtas>;
3008 defm FCVTAU : FPToIntegerUnscaled<0b00, 0b101, "fcvtau", int_aarch64_neon_fcvtau>;
3009 defm FCVTMS : FPToIntegerUnscaled<0b10, 0b000, "fcvtms", int_aarch64_neon_fcvtms>;
3010 defm FCVTMU : FPToIntegerUnscaled<0b10, 0b001, "fcvtmu", int_aarch64_neon_fcvtmu>;
3011 defm FCVTNS : FPToIntegerUnscaled<0b00, 0b000, "fcvtns", int_aarch64_neon_fcvtns>;
3012 defm FCVTNU : FPToIntegerUnscaled<0b00, 0b001, "fcvtnu", int_aarch64_neon_fcvtnu>;
3013 defm FCVTPS : FPToIntegerUnscaled<0b01, 0b000, "fcvtps", int_aarch64_neon_fcvtps>;
3014 defm FCVTPU : FPToIntegerUnscaled<0b01, 0b001, "fcvtpu", int_aarch64_neon_fcvtpu>;
3015 defm FCVTZS : FPToIntegerUnscaled<0b11, 0b000, "fcvtzs", fp_to_sint>;
3016 defm FCVTZU : FPToIntegerUnscaled<0b11, 0b001, "fcvtzu", fp_to_uint>;
3017 defm FCVTZS : FPToIntegerScaled<0b11, 0b000, "fcvtzs", fp_to_sint>;
3018 defm FCVTZU : FPToIntegerScaled<0b11, 0b001, "fcvtzu", fp_to_uint>;
3020 multiclass FPToIntegerIntPats<Intrinsic round, string INST> {
3021 def : Pat<(i32 (round f16:$Rn)), (!cast<Instruction>(INST # UWHr) $Rn)>;
3022 def : Pat<(i64 (round f16:$Rn)), (!cast<Instruction>(INST # UXHr) $Rn)>;
3023 def : Pat<(i32 (round f32:$Rn)), (!cast<Instruction>(INST # UWSr) $Rn)>;
3024 def : Pat<(i64 (round f32:$Rn)), (!cast<Instruction>(INST # UXSr) $Rn)>;
3025 def : Pat<(i32 (round f64:$Rn)), (!cast<Instruction>(INST # UWDr) $Rn)>;
3026 def : Pat<(i64 (round f64:$Rn)), (!cast<Instruction>(INST # UXDr) $Rn)>;
3028 def : Pat<(i32 (round (fmul f16:$Rn, fixedpoint_f16_i32:$scale))),
3029 (!cast<Instruction>(INST # SWHri) $Rn, $scale)>;
3030 def : Pat<(i64 (round (fmul f16:$Rn, fixedpoint_f16_i64:$scale))),
3031 (!cast<Instruction>(INST # SXHri) $Rn, $scale)>;
3032 def : Pat<(i32 (round (fmul f32:$Rn, fixedpoint_f32_i32:$scale))),
3033 (!cast<Instruction>(INST # SWSri) $Rn, $scale)>;
3034 def : Pat<(i64 (round (fmul f32:$Rn, fixedpoint_f32_i64:$scale))),
3035 (!cast<Instruction>(INST # SXSri) $Rn, $scale)>;
3036 def : Pat<(i32 (round (fmul f64:$Rn, fixedpoint_f64_i32:$scale))),
3037 (!cast<Instruction>(INST # SWDri) $Rn, $scale)>;
3038 def : Pat<(i64 (round (fmul f64:$Rn, fixedpoint_f64_i64:$scale))),
3039 (!cast<Instruction>(INST # SXDri) $Rn, $scale)>;
3042 defm : FPToIntegerIntPats<int_aarch64_neon_fcvtzs, "FCVTZS">;
3043 defm : FPToIntegerIntPats<int_aarch64_neon_fcvtzu, "FCVTZU">;
3045 multiclass FPToIntegerPats<SDNode to_int, SDNode round, string INST> {
3046 def : Pat<(i32 (to_int (round f32:$Rn))),
3047 (!cast<Instruction>(INST # UWSr) f32:$Rn)>;
3048 def : Pat<(i64 (to_int (round f32:$Rn))),
3049 (!cast<Instruction>(INST # UXSr) f32:$Rn)>;
3050 def : Pat<(i32 (to_int (round f64:$Rn))),
3051 (!cast<Instruction>(INST # UWDr) f64:$Rn)>;
3052 def : Pat<(i64 (to_int (round f64:$Rn))),
3053 (!cast<Instruction>(INST # UXDr) f64:$Rn)>;
3056 defm : FPToIntegerPats<fp_to_sint, fceil, "FCVTPS">;
3057 defm : FPToIntegerPats<fp_to_uint, fceil, "FCVTPU">;
3058 defm : FPToIntegerPats<fp_to_sint, ffloor, "FCVTMS">;
3059 defm : FPToIntegerPats<fp_to_uint, ffloor, "FCVTMU">;
3060 defm : FPToIntegerPats<fp_to_sint, ftrunc, "FCVTZS">;
3061 defm : FPToIntegerPats<fp_to_uint, ftrunc, "FCVTZU">;
3062 defm : FPToIntegerPats<fp_to_sint, fround, "FCVTAS">;
3063 defm : FPToIntegerPats<fp_to_uint, fround, "FCVTAU">;
3065 //===----------------------------------------------------------------------===//
3066 // Scaled integer to floating point conversion instructions.
3067 //===----------------------------------------------------------------------===//
3069 defm SCVTF : IntegerToFP<0, "scvtf", sint_to_fp>;
3070 defm UCVTF : IntegerToFP<1, "ucvtf", uint_to_fp>;
3072 //===----------------------------------------------------------------------===//
3073 // Unscaled integer to floating point conversion instruction.
3074 //===----------------------------------------------------------------------===//
3076 defm FMOV : UnscaledConversion<"fmov">;
3078 // Add pseudo ops for FMOV 0 so we can mark them as isReMaterializable
3079 let isReMaterializable = 1, isCodeGenOnly = 1, isAsCheapAsAMove = 1 in {
3080 def FMOVH0 : Pseudo<(outs FPR16:$Rd), (ins), [(set f16:$Rd, (fpimm0))]>,
3081 Sched<[WriteF]>, Requires<[HasFullFP16]>;
3082 def FMOVS0 : Pseudo<(outs FPR32:$Rd), (ins), [(set f32:$Rd, (fpimm0))]>,
3084 def FMOVD0 : Pseudo<(outs FPR64:$Rd), (ins), [(set f64:$Rd, (fpimm0))]>,
3087 // Similarly add aliases
3088 def : InstAlias<"fmov $Rd, #0.0", (FMOVWHr FPR16:$Rd, WZR), 0>,
3089 Requires<[HasFullFP16]>;
3090 def : InstAlias<"fmov $Rd, #0.0", (FMOVWSr FPR32:$Rd, WZR), 0>;
3091 def : InstAlias<"fmov $Rd, #0.0", (FMOVXDr FPR64:$Rd, XZR), 0>;
3093 //===----------------------------------------------------------------------===//
3094 // Floating point conversion instruction.
3095 //===----------------------------------------------------------------------===//
3097 defm FCVT : FPConversion<"fcvt">;
3099 //===----------------------------------------------------------------------===//
3100 // Floating point single operand instructions.
3101 //===----------------------------------------------------------------------===//
3103 defm FABS : SingleOperandFPData<0b0001, "fabs", fabs>;
3104 defm FMOV : SingleOperandFPData<0b0000, "fmov">;
3105 defm FNEG : SingleOperandFPData<0b0010, "fneg", fneg>;
3106 defm FRINTA : SingleOperandFPData<0b1100, "frinta", fround>;
3107 defm FRINTI : SingleOperandFPData<0b1111, "frinti", fnearbyint>;
3108 defm FRINTM : SingleOperandFPData<0b1010, "frintm", ffloor>;
3109 defm FRINTN : SingleOperandFPData<0b1000, "frintn", int_aarch64_neon_frintn>;
3110 defm FRINTP : SingleOperandFPData<0b1001, "frintp", fceil>;
3112 def : Pat<(v1f64 (int_aarch64_neon_frintn (v1f64 FPR64:$Rn))),
3113 (FRINTNDr FPR64:$Rn)>;
3115 defm FRINTX : SingleOperandFPData<0b1110, "frintx", frint>;
3116 defm FRINTZ : SingleOperandFPData<0b1011, "frintz", ftrunc>;
3118 let SchedRW = [WriteFDiv] in {
3119 defm FSQRT : SingleOperandFPData<0b0011, "fsqrt", fsqrt>;
3122 let Predicates = [HasFRInt3264] in {
3123 defm FRINT32Z : FRIntNNT<0b00, "frint32z">;
3124 defm FRINT64Z : FRIntNNT<0b10, "frint64z">;
3125 defm FRINT32X : FRIntNNT<0b01, "frint32x">;
3126 defm FRINT64X : FRIntNNT<0b11, "frint64x">;
3129 //===----------------------------------------------------------------------===//
3130 // Floating point two operand instructions.
3131 //===----------------------------------------------------------------------===//
3133 defm FADD : TwoOperandFPData<0b0010, "fadd", fadd>;
3134 let SchedRW = [WriteFDiv] in {
3135 defm FDIV : TwoOperandFPData<0b0001, "fdiv", fdiv>;
3137 defm FMAXNM : TwoOperandFPData<0b0110, "fmaxnm", fmaxnum>;
3138 defm FMAX : TwoOperandFPData<0b0100, "fmax", fmaximum>;
3139 defm FMINNM : TwoOperandFPData<0b0111, "fminnm", fminnum>;
3140 defm FMIN : TwoOperandFPData<0b0101, "fmin", fminimum>;
3141 let SchedRW = [WriteFMul] in {
3142 defm FMUL : TwoOperandFPData<0b0000, "fmul", fmul>;
3143 defm FNMUL : TwoOperandFPDataNeg<0b1000, "fnmul", fmul>;
3145 defm FSUB : TwoOperandFPData<0b0011, "fsub", fsub>;
3147 def : Pat<(v1f64 (fmaximum (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
3148 (FMAXDrr FPR64:$Rn, FPR64:$Rm)>;
3149 def : Pat<(v1f64 (fminimum (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
3150 (FMINDrr FPR64:$Rn, FPR64:$Rm)>;
3151 def : Pat<(v1f64 (fmaxnum (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
3152 (FMAXNMDrr FPR64:$Rn, FPR64:$Rm)>;
3153 def : Pat<(v1f64 (fminnum (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
3154 (FMINNMDrr FPR64:$Rn, FPR64:$Rm)>;
3156 //===----------------------------------------------------------------------===//
3157 // Floating point three operand instructions.
3158 //===----------------------------------------------------------------------===//
3160 defm FMADD : ThreeOperandFPData<0, 0, "fmadd", fma>;
3161 defm FMSUB : ThreeOperandFPData<0, 1, "fmsub",
3162 TriOpFrag<(fma node:$LHS, (fneg node:$MHS), node:$RHS)> >;
3163 defm FNMADD : ThreeOperandFPData<1, 0, "fnmadd",
3164 TriOpFrag<(fneg (fma node:$LHS, node:$MHS, node:$RHS))> >;
3165 defm FNMSUB : ThreeOperandFPData<1, 1, "fnmsub",
3166 TriOpFrag<(fma node:$LHS, node:$MHS, (fneg node:$RHS))> >;
3168 // The following def pats catch the case where the LHS of an FMA is negated.
3169 // The TriOpFrag above catches the case where the middle operand is negated.
3171 // N.b. FMSUB etc have the accumulator at the *end* of (outs), unlike
3172 // the NEON variant.
3173 def : Pat<(f32 (fma (fneg FPR32:$Rn), FPR32:$Rm, FPR32:$Ra)),
3174 (FMSUBSrrr FPR32:$Rn, FPR32:$Rm, FPR32:$Ra)>;
3176 def : Pat<(f64 (fma (fneg FPR64:$Rn), FPR64:$Rm, FPR64:$Ra)),
3177 (FMSUBDrrr FPR64:$Rn, FPR64:$Rm, FPR64:$Ra)>;
3179 // We handled -(a + b*c) for FNMADD above, now it's time for "(-a) + (-b)*c" and
3181 def : Pat<(f32 (fma (fneg FPR32:$Rn), FPR32:$Rm, (fneg FPR32:$Ra))),
3182 (FNMADDSrrr FPR32:$Rn, FPR32:$Rm, FPR32:$Ra)>;
3184 def : Pat<(f64 (fma (fneg FPR64:$Rn), FPR64:$Rm, (fneg FPR64:$Ra))),
3185 (FNMADDDrrr FPR64:$Rn, FPR64:$Rm, FPR64:$Ra)>;
3187 def : Pat<(f32 (fma FPR32:$Rn, (fneg FPR32:$Rm), (fneg FPR32:$Ra))),
3188 (FNMADDSrrr FPR32:$Rn, FPR32:$Rm, FPR32:$Ra)>;
3190 def : Pat<(f64 (fma FPR64:$Rn, (fneg FPR64:$Rm), (fneg FPR64:$Ra))),
3191 (FNMADDDrrr FPR64:$Rn, FPR64:$Rm, FPR64:$Ra)>;
3193 //===----------------------------------------------------------------------===//
3194 // Floating point comparison instructions.
3195 //===----------------------------------------------------------------------===//
3197 defm FCMPE : FPComparison<1, "fcmpe">;
3198 defm FCMP : FPComparison<0, "fcmp", AArch64fcmp>;
3200 //===----------------------------------------------------------------------===//
3201 // Floating point conditional comparison instructions.
3202 //===----------------------------------------------------------------------===//
3204 defm FCCMPE : FPCondComparison<1, "fccmpe">;
3205 defm FCCMP : FPCondComparison<0, "fccmp", AArch64fccmp>;
3207 //===----------------------------------------------------------------------===//
3208 // Floating point conditional select instruction.
3209 //===----------------------------------------------------------------------===//
3211 defm FCSEL : FPCondSelect<"fcsel">;
3213 // CSEL instructions providing f128 types need to be handled by a
3214 // pseudo-instruction since the eventual code will need to introduce basic
3215 // blocks and control flow.
3216 def F128CSEL : Pseudo<(outs FPR128:$Rd),
3217 (ins FPR128:$Rn, FPR128:$Rm, ccode:$cond),
3218 [(set (f128 FPR128:$Rd),
3219 (AArch64csel FPR128:$Rn, FPR128:$Rm,
3220 (i32 imm:$cond), NZCV))]> {
3222 let usesCustomInserter = 1;
3223 let hasNoSchedulingInfo = 1;
3226 //===----------------------------------------------------------------------===//
3227 // Instructions used for emitting unwind opcodes on ARM64 Windows.
3228 //===----------------------------------------------------------------------===//
3229 let isPseudo = 1 in {
3230 def SEH_StackAlloc : Pseudo<(outs), (ins i32imm:$size), []>, Sched<[]>;
3231 def SEH_SaveFPLR : Pseudo<(outs), (ins i32imm:$offs), []>, Sched<[]>;
3232 def SEH_SaveFPLR_X : Pseudo<(outs), (ins i32imm:$offs), []>, Sched<[]>;
3233 def SEH_SaveReg : Pseudo<(outs), (ins i32imm:$reg, i32imm:$offs), []>, Sched<[]>;
3234 def SEH_SaveReg_X : Pseudo<(outs), (ins i32imm:$reg, i32imm:$offs), []>, Sched<[]>;
3235 def SEH_SaveRegP : Pseudo<(outs), (ins i32imm:$reg0, i32imm:$reg1, i32imm:$offs), []>, Sched<[]>;
3236 def SEH_SaveRegP_X : Pseudo<(outs), (ins i32imm:$reg0, i32imm:$reg1, i32imm:$offs), []>, Sched<[]>;
3237 def SEH_SaveFReg : Pseudo<(outs), (ins i32imm:$reg, i32imm:$offs), []>, Sched<[]>;
3238 def SEH_SaveFReg_X : Pseudo<(outs), (ins i32imm:$reg, i32imm:$offs), []>, Sched<[]>;
3239 def SEH_SaveFRegP : Pseudo<(outs), (ins i32imm:$reg0, i32imm:$reg1, i32imm:$offs), []>, Sched<[]>;
3240 def SEH_SaveFRegP_X : Pseudo<(outs), (ins i32imm:$reg0, i32imm:$reg1, i32imm:$offs), []>, Sched<[]>;
3241 def SEH_SetFP : Pseudo<(outs), (ins), []>, Sched<[]>;
3242 def SEH_AddFP : Pseudo<(outs), (ins i32imm:$offs), []>, Sched<[]>;
3243 def SEH_Nop : Pseudo<(outs), (ins), []>, Sched<[]>;
3244 def SEH_PrologEnd : Pseudo<(outs), (ins), []>, Sched<[]>;
3245 def SEH_EpilogStart : Pseudo<(outs), (ins), []>, Sched<[]>;
3246 def SEH_EpilogEnd : Pseudo<(outs), (ins), []>, Sched<[]>;
3249 // Pseudo instructions for Windows EH
3250 //===----------------------------------------------------------------------===//
3251 let isTerminator = 1, hasSideEffects = 1, isBarrier = 1, hasCtrlDep = 1,
3252 isCodeGenOnly = 1, isReturn = 1, isEHScopeReturn = 1, isPseudo = 1 in {
3253 def CLEANUPRET : Pseudo<(outs), (ins), [(cleanupret)]>, Sched<[]>;
3254 let usesCustomInserter = 1 in
3255 def CATCHRET : Pseudo<(outs), (ins am_brcond:$dst, am_brcond:$src), [(catchret bb:$dst, bb:$src)]>,
3259 let hasSideEffects = 1, hasCtrlDep = 1, isCodeGenOnly = 1,
3260 usesCustomInserter = 1 in
3261 def CATCHPAD : Pseudo<(outs), (ins), [(catchpad)]>, Sched<[]>;
3263 //===----------------------------------------------------------------------===//
3264 // Floating point immediate move.
3265 //===----------------------------------------------------------------------===//
3267 let isReMaterializable = 1 in {
3268 defm FMOV : FPMoveImmediate<"fmov">;
3271 //===----------------------------------------------------------------------===//
3272 // Advanced SIMD two vector instructions.
3273 //===----------------------------------------------------------------------===//
3275 defm UABDL : SIMDLongThreeVectorBHSabdl<1, 0b0111, "uabdl",
3276 int_aarch64_neon_uabd>;
3277 // Match UABDL in log2-shuffle patterns.
3278 def : Pat<(abs (v8i16 (sub (zext (v8i8 V64:$opA)),
3279 (zext (v8i8 V64:$opB))))),
3280 (UABDLv8i8_v8i16 V64:$opA, V64:$opB)>;
3281 def : Pat<(xor (v8i16 (AArch64vashr v8i16:$src, (i32 15))),
3282 (v8i16 (add (sub (zext (v8i8 V64:$opA)),
3283 (zext (v8i8 V64:$opB))),
3284 (AArch64vashr v8i16:$src, (i32 15))))),
3285 (UABDLv8i8_v8i16 V64:$opA, V64:$opB)>;
3286 def : Pat<(abs (v8i16 (sub (zext (extract_high_v16i8 V128:$opA)),
3287 (zext (extract_high_v16i8 V128:$opB))))),
3288 (UABDLv16i8_v8i16 V128:$opA, V128:$opB)>;
3289 def : Pat<(xor (v8i16 (AArch64vashr v8i16:$src, (i32 15))),
3290 (v8i16 (add (sub (zext (extract_high_v16i8 V128:$opA)),
3291 (zext (extract_high_v16i8 V128:$opB))),
3292 (AArch64vashr v8i16:$src, (i32 15))))),
3293 (UABDLv16i8_v8i16 V128:$opA, V128:$opB)>;
3294 def : Pat<(abs (v4i32 (sub (zext (v4i16 V64:$opA)),
3295 (zext (v4i16 V64:$opB))))),
3296 (UABDLv4i16_v4i32 V64:$opA, V64:$opB)>;
3297 def : Pat<(abs (v4i32 (sub (zext (extract_high_v8i16 V128:$opA)),
3298 (zext (extract_high_v8i16 V128:$opB))))),
3299 (UABDLv8i16_v4i32 V128:$opA, V128:$opB)>;
3300 def : Pat<(abs (v2i64 (sub (zext (v2i32 V64:$opA)),
3301 (zext (v2i32 V64:$opB))))),
3302 (UABDLv2i32_v2i64 V64:$opA, V64:$opB)>;
3303 def : Pat<(abs (v2i64 (sub (zext (extract_high_v4i32 V128:$opA)),
3304 (zext (extract_high_v4i32 V128:$opB))))),
3305 (UABDLv4i32_v2i64 V128:$opA, V128:$opB)>;
3307 defm ABS : SIMDTwoVectorBHSD<0, 0b01011, "abs", abs>;
3308 defm CLS : SIMDTwoVectorBHS<0, 0b00100, "cls", int_aarch64_neon_cls>;
3309 defm CLZ : SIMDTwoVectorBHS<1, 0b00100, "clz", ctlz>;
3310 defm CMEQ : SIMDCmpTwoVector<0, 0b01001, "cmeq", AArch64cmeqz>;
3311 defm CMGE : SIMDCmpTwoVector<1, 0b01000, "cmge", AArch64cmgez>;
3312 defm CMGT : SIMDCmpTwoVector<0, 0b01000, "cmgt", AArch64cmgtz>;
3313 defm CMLE : SIMDCmpTwoVector<1, 0b01001, "cmle", AArch64cmlez>;
3314 defm CMLT : SIMDCmpTwoVector<0, 0b01010, "cmlt", AArch64cmltz>;
3315 defm CNT : SIMDTwoVectorB<0, 0b00, 0b00101, "cnt", ctpop>;
3316 defm FABS : SIMDTwoVectorFP<0, 1, 0b01111, "fabs", fabs>;
3318 defm FCMEQ : SIMDFPCmpTwoVector<0, 1, 0b01101, "fcmeq", AArch64fcmeqz>;
3319 defm FCMGE : SIMDFPCmpTwoVector<1, 1, 0b01100, "fcmge", AArch64fcmgez>;
3320 defm FCMGT : SIMDFPCmpTwoVector<0, 1, 0b01100, "fcmgt", AArch64fcmgtz>;
3321 defm FCMLE : SIMDFPCmpTwoVector<1, 1, 0b01101, "fcmle", AArch64fcmlez>;
3322 defm FCMLT : SIMDFPCmpTwoVector<0, 1, 0b01110, "fcmlt", AArch64fcmltz>;
3323 defm FCVTAS : SIMDTwoVectorFPToInt<0,0,0b11100, "fcvtas",int_aarch64_neon_fcvtas>;
3324 defm FCVTAU : SIMDTwoVectorFPToInt<1,0,0b11100, "fcvtau",int_aarch64_neon_fcvtau>;
3325 defm FCVTL : SIMDFPWidenTwoVector<0, 0, 0b10111, "fcvtl">;
3326 def : Pat<(v4f32 (int_aarch64_neon_vcvthf2fp (v4i16 V64:$Rn))),
3327 (FCVTLv4i16 V64:$Rn)>;
3328 def : Pat<(v4f32 (int_aarch64_neon_vcvthf2fp (extract_subvector (v8i16 V128:$Rn),
3330 (FCVTLv8i16 V128:$Rn)>;
3331 def : Pat<(v2f64 (fpextend (v2f32 V64:$Rn))), (FCVTLv2i32 V64:$Rn)>;
3332 def : Pat<(v2f64 (fpextend (v2f32 (extract_subvector (v4f32 V128:$Rn),
3334 (FCVTLv4i32 V128:$Rn)>;
3336 def : Pat<(v4f32 (fpextend (v4f16 V64:$Rn))), (FCVTLv4i16 V64:$Rn)>;
3337 def : Pat<(v4f32 (fpextend (v4f16 (extract_subvector (v8f16 V128:$Rn),
3339 (FCVTLv8i16 V128:$Rn)>;
3341 defm FCVTMS : SIMDTwoVectorFPToInt<0,0,0b11011, "fcvtms",int_aarch64_neon_fcvtms>;
3342 defm FCVTMU : SIMDTwoVectorFPToInt<1,0,0b11011, "fcvtmu",int_aarch64_neon_fcvtmu>;
3343 defm FCVTNS : SIMDTwoVectorFPToInt<0,0,0b11010, "fcvtns",int_aarch64_neon_fcvtns>;
3344 defm FCVTNU : SIMDTwoVectorFPToInt<1,0,0b11010, "fcvtnu",int_aarch64_neon_fcvtnu>;
3345 defm FCVTN : SIMDFPNarrowTwoVector<0, 0, 0b10110, "fcvtn">;
3346 def : Pat<(v4i16 (int_aarch64_neon_vcvtfp2hf (v4f32 V128:$Rn))),
3347 (FCVTNv4i16 V128:$Rn)>;
3348 def : Pat<(concat_vectors V64:$Rd,
3349 (v4i16 (int_aarch64_neon_vcvtfp2hf (v4f32 V128:$Rn)))),
3350 (FCVTNv8i16 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
3351 def : Pat<(v2f32 (fpround (v2f64 V128:$Rn))), (FCVTNv2i32 V128:$Rn)>;
3352 def : Pat<(v4f16 (fpround (v4f32 V128:$Rn))), (FCVTNv4i16 V128:$Rn)>;
3353 def : Pat<(concat_vectors V64:$Rd, (v2f32 (fpround (v2f64 V128:$Rn)))),
3354 (FCVTNv4i32 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
3355 defm FCVTPS : SIMDTwoVectorFPToInt<0,1,0b11010, "fcvtps",int_aarch64_neon_fcvtps>;
3356 defm FCVTPU : SIMDTwoVectorFPToInt<1,1,0b11010, "fcvtpu",int_aarch64_neon_fcvtpu>;
3357 defm FCVTXN : SIMDFPInexactCvtTwoVector<1, 0, 0b10110, "fcvtxn",
3358 int_aarch64_neon_fcvtxn>;
3359 defm FCVTZS : SIMDTwoVectorFPToInt<0, 1, 0b11011, "fcvtzs", fp_to_sint>;
3360 defm FCVTZU : SIMDTwoVectorFPToInt<1, 1, 0b11011, "fcvtzu", fp_to_uint>;
3362 def : Pat<(v4i16 (int_aarch64_neon_fcvtzs v4f16:$Rn)), (FCVTZSv4f16 $Rn)>;
3363 def : Pat<(v8i16 (int_aarch64_neon_fcvtzs v8f16:$Rn)), (FCVTZSv8f16 $Rn)>;
3364 def : Pat<(v2i32 (int_aarch64_neon_fcvtzs v2f32:$Rn)), (FCVTZSv2f32 $Rn)>;
3365 def : Pat<(v4i32 (int_aarch64_neon_fcvtzs v4f32:$Rn)), (FCVTZSv4f32 $Rn)>;
3366 def : Pat<(v2i64 (int_aarch64_neon_fcvtzs v2f64:$Rn)), (FCVTZSv2f64 $Rn)>;
3368 def : Pat<(v4i16 (int_aarch64_neon_fcvtzu v4f16:$Rn)), (FCVTZUv4f16 $Rn)>;
3369 def : Pat<(v8i16 (int_aarch64_neon_fcvtzu v8f16:$Rn)), (FCVTZUv8f16 $Rn)>;
3370 def : Pat<(v2i32 (int_aarch64_neon_fcvtzu v2f32:$Rn)), (FCVTZUv2f32 $Rn)>;
3371 def : Pat<(v4i32 (int_aarch64_neon_fcvtzu v4f32:$Rn)), (FCVTZUv4f32 $Rn)>;
3372 def : Pat<(v2i64 (int_aarch64_neon_fcvtzu v2f64:$Rn)), (FCVTZUv2f64 $Rn)>;
3374 defm FNEG : SIMDTwoVectorFP<1, 1, 0b01111, "fneg", fneg>;
3375 defm FRECPE : SIMDTwoVectorFP<0, 1, 0b11101, "frecpe", int_aarch64_neon_frecpe>;
3376 defm FRINTA : SIMDTwoVectorFP<1, 0, 0b11000, "frinta", fround>;
3377 defm FRINTI : SIMDTwoVectorFP<1, 1, 0b11001, "frinti", fnearbyint>;
3378 defm FRINTM : SIMDTwoVectorFP<0, 0, 0b11001, "frintm", ffloor>;
3379 defm FRINTN : SIMDTwoVectorFP<0, 0, 0b11000, "frintn", int_aarch64_neon_frintn>;
3380 defm FRINTP : SIMDTwoVectorFP<0, 1, 0b11000, "frintp", fceil>;
3381 defm FRINTX : SIMDTwoVectorFP<1, 0, 0b11001, "frintx", frint>;
3382 defm FRINTZ : SIMDTwoVectorFP<0, 1, 0b11001, "frintz", ftrunc>;
3384 let Predicates = [HasFRInt3264] in {
3385 defm FRINT32Z : FRIntNNTVector<0, 0, "frint32z">;
3386 defm FRINT64Z : FRIntNNTVector<0, 1, "frint64z">;
3387 defm FRINT32X : FRIntNNTVector<1, 0, "frint32x">;
3388 defm FRINT64X : FRIntNNTVector<1, 1, "frint64x">;
3391 defm FRSQRTE: SIMDTwoVectorFP<1, 1, 0b11101, "frsqrte", int_aarch64_neon_frsqrte>;
3392 defm FSQRT : SIMDTwoVectorFP<1, 1, 0b11111, "fsqrt", fsqrt>;
3393 defm NEG : SIMDTwoVectorBHSD<1, 0b01011, "neg",
3394 UnOpFrag<(sub immAllZerosV, node:$LHS)> >;
3395 defm NOT : SIMDTwoVectorB<1, 0b00, 0b00101, "not", vnot>;
3396 // Aliases for MVN -> NOT.
3397 def : InstAlias<"mvn{ $Vd.8b, $Vn.8b|.8b $Vd, $Vn}",
3398 (NOTv8i8 V64:$Vd, V64:$Vn)>;
3399 def : InstAlias<"mvn{ $Vd.16b, $Vn.16b|.16b $Vd, $Vn}",
3400 (NOTv16i8 V128:$Vd, V128:$Vn)>;
3402 def : Pat<(AArch64neg (v8i8 V64:$Rn)), (NEGv8i8 V64:$Rn)>;
3403 def : Pat<(AArch64neg (v16i8 V128:$Rn)), (NEGv16i8 V128:$Rn)>;
3404 def : Pat<(AArch64neg (v4i16 V64:$Rn)), (NEGv4i16 V64:$Rn)>;
3405 def : Pat<(AArch64neg (v8i16 V128:$Rn)), (NEGv8i16 V128:$Rn)>;
3406 def : Pat<(AArch64neg (v2i32 V64:$Rn)), (NEGv2i32 V64:$Rn)>;
3407 def : Pat<(AArch64neg (v4i32 V128:$Rn)), (NEGv4i32 V128:$Rn)>;
3408 def : Pat<(AArch64neg (v2i64 V128:$Rn)), (NEGv2i64 V128:$Rn)>;
3410 def : Pat<(AArch64not (v8i8 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3411 def : Pat<(AArch64not (v16i8 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3412 def : Pat<(AArch64not (v4i16 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3413 def : Pat<(AArch64not (v8i16 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3414 def : Pat<(AArch64not (v2i32 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3415 def : Pat<(AArch64not (v1i64 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3416 def : Pat<(AArch64not (v4i32 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3417 def : Pat<(AArch64not (v2i64 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3419 def : Pat<(vnot (v4i16 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3420 def : Pat<(vnot (v8i16 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3421 def : Pat<(vnot (v2i32 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
3422 def : Pat<(vnot (v4i32 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3423 def : Pat<(vnot (v2i64 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
3425 defm RBIT : SIMDTwoVectorB<1, 0b01, 0b00101, "rbit", int_aarch64_neon_rbit>;
3426 defm REV16 : SIMDTwoVectorB<0, 0b00, 0b00001, "rev16", AArch64rev16>;
3427 defm REV32 : SIMDTwoVectorBH<1, 0b00000, "rev32", AArch64rev32>;
3428 defm REV64 : SIMDTwoVectorBHS<0, 0b00000, "rev64", AArch64rev64>;
3429 defm SADALP : SIMDLongTwoVectorTied<0, 0b00110, "sadalp",
3430 BinOpFrag<(add node:$LHS, (int_aarch64_neon_saddlp node:$RHS))> >;
3431 defm SADDLP : SIMDLongTwoVector<0, 0b00010, "saddlp", int_aarch64_neon_saddlp>;
3432 defm SCVTF : SIMDTwoVectorIntToFP<0, 0, 0b11101, "scvtf", sint_to_fp>;
3433 defm SHLL : SIMDVectorLShiftLongBySizeBHS;
3434 defm SQABS : SIMDTwoVectorBHSD<0, 0b00111, "sqabs", int_aarch64_neon_sqabs>;
3435 defm SQNEG : SIMDTwoVectorBHSD<1, 0b00111, "sqneg", int_aarch64_neon_sqneg>;
3436 defm SQXTN : SIMDMixedTwoVector<0, 0b10100, "sqxtn", int_aarch64_neon_sqxtn>;
3437 defm SQXTUN : SIMDMixedTwoVector<1, 0b10010, "sqxtun", int_aarch64_neon_sqxtun>;
3438 defm SUQADD : SIMDTwoVectorBHSDTied<0, 0b00011, "suqadd",int_aarch64_neon_suqadd>;
3439 defm UADALP : SIMDLongTwoVectorTied<1, 0b00110, "uadalp",
3440 BinOpFrag<(add node:$LHS, (int_aarch64_neon_uaddlp node:$RHS))> >;
3441 defm UADDLP : SIMDLongTwoVector<1, 0b00010, "uaddlp",
3442 int_aarch64_neon_uaddlp>;
3443 defm UCVTF : SIMDTwoVectorIntToFP<1, 0, 0b11101, "ucvtf", uint_to_fp>;
3444 defm UQXTN : SIMDMixedTwoVector<1, 0b10100, "uqxtn", int_aarch64_neon_uqxtn>;
3445 defm URECPE : SIMDTwoVectorS<0, 1, 0b11100, "urecpe", int_aarch64_neon_urecpe>;
3446 defm URSQRTE: SIMDTwoVectorS<1, 1, 0b11100, "ursqrte", int_aarch64_neon_ursqrte>;
3447 defm USQADD : SIMDTwoVectorBHSDTied<1, 0b00011, "usqadd",int_aarch64_neon_usqadd>;
3448 defm XTN : SIMDMixedTwoVector<0, 0b10010, "xtn", trunc>;
3450 def : Pat<(v4f16 (AArch64rev32 V64:$Rn)), (REV32v4i16 V64:$Rn)>;
3451 def : Pat<(v4f16 (AArch64rev64 V64:$Rn)), (REV64v4i16 V64:$Rn)>;
3452 def : Pat<(v8f16 (AArch64rev32 V128:$Rn)), (REV32v8i16 V128:$Rn)>;
3453 def : Pat<(v8f16 (AArch64rev64 V128:$Rn)), (REV64v8i16 V128:$Rn)>;
3454 def : Pat<(v2f32 (AArch64rev64 V64:$Rn)), (REV64v2i32 V64:$Rn)>;
3455 def : Pat<(v4f32 (AArch64rev64 V128:$Rn)), (REV64v4i32 V128:$Rn)>;
3457 // Patterns for vector long shift (by element width). These need to match all
3458 // three of zext, sext and anyext so it's easier to pull the patterns out of the
3460 multiclass SIMDVectorLShiftLongBySizeBHSPats<SDPatternOperator ext> {
3461 def : Pat<(AArch64vshl (v8i16 (ext (v8i8 V64:$Rn))), (i32 8)),
3462 (SHLLv8i8 V64:$Rn)>;
3463 def : Pat<(AArch64vshl (v8i16 (ext (extract_high_v16i8 V128:$Rn))), (i32 8)),
3464 (SHLLv16i8 V128:$Rn)>;
3465 def : Pat<(AArch64vshl (v4i32 (ext (v4i16 V64:$Rn))), (i32 16)),
3466 (SHLLv4i16 V64:$Rn)>;
3467 def : Pat<(AArch64vshl (v4i32 (ext (extract_high_v8i16 V128:$Rn))), (i32 16)),
3468 (SHLLv8i16 V128:$Rn)>;
3469 def : Pat<(AArch64vshl (v2i64 (ext (v2i32 V64:$Rn))), (i32 32)),
3470 (SHLLv2i32 V64:$Rn)>;
3471 def : Pat<(AArch64vshl (v2i64 (ext (extract_high_v4i32 V128:$Rn))), (i32 32)),
3472 (SHLLv4i32 V128:$Rn)>;
3475 defm : SIMDVectorLShiftLongBySizeBHSPats<anyext>;
3476 defm : SIMDVectorLShiftLongBySizeBHSPats<zext>;
3477 defm : SIMDVectorLShiftLongBySizeBHSPats<sext>;
3479 //===----------------------------------------------------------------------===//
3480 // Advanced SIMD three vector instructions.
3481 //===----------------------------------------------------------------------===//
3483 defm ADD : SIMDThreeSameVector<0, 0b10000, "add", add>;
3484 defm ADDP : SIMDThreeSameVector<0, 0b10111, "addp", int_aarch64_neon_addp>;
3485 defm CMEQ : SIMDThreeSameVector<1, 0b10001, "cmeq", AArch64cmeq>;
3486 defm CMGE : SIMDThreeSameVector<0, 0b00111, "cmge", AArch64cmge>;
3487 defm CMGT : SIMDThreeSameVector<0, 0b00110, "cmgt", AArch64cmgt>;
3488 defm CMHI : SIMDThreeSameVector<1, 0b00110, "cmhi", AArch64cmhi>;
3489 defm CMHS : SIMDThreeSameVector<1, 0b00111, "cmhs", AArch64cmhs>;
3490 defm CMTST : SIMDThreeSameVector<0, 0b10001, "cmtst", AArch64cmtst>;
3491 defm FABD : SIMDThreeSameVectorFP<1,1,0b010,"fabd", int_aarch64_neon_fabd>;
3492 let Predicates = [HasNEON] in {
3493 foreach VT = [ v2f32, v4f32, v2f64 ] in
3494 def : Pat<(fabs (fsub VT:$Rn, VT:$Rm)), (!cast<Instruction>("FABD"#VT) VT:$Rn, VT:$Rm)>;
3496 let Predicates = [HasNEON, HasFullFP16] in {
3497 foreach VT = [ v4f16, v8f16 ] in
3498 def : Pat<(fabs (fsub VT:$Rn, VT:$Rm)), (!cast<Instruction>("FABD"#VT) VT:$Rn, VT:$Rm)>;
3500 defm FACGE : SIMDThreeSameVectorFPCmp<1,0,0b101,"facge",int_aarch64_neon_facge>;
3501 defm FACGT : SIMDThreeSameVectorFPCmp<1,1,0b101,"facgt",int_aarch64_neon_facgt>;
3502 defm FADDP : SIMDThreeSameVectorFP<1,0,0b010,"faddp",int_aarch64_neon_addp>;
3503 defm FADD : SIMDThreeSameVectorFP<0,0,0b010,"fadd", fadd>;
3504 defm FCMEQ : SIMDThreeSameVectorFPCmp<0, 0, 0b100, "fcmeq", AArch64fcmeq>;
3505 defm FCMGE : SIMDThreeSameVectorFPCmp<1, 0, 0b100, "fcmge", AArch64fcmge>;
3506 defm FCMGT : SIMDThreeSameVectorFPCmp<1, 1, 0b100, "fcmgt", AArch64fcmgt>;
3507 defm FDIV : SIMDThreeSameVectorFP<1,0,0b111,"fdiv", fdiv>;
3508 defm FMAXNMP : SIMDThreeSameVectorFP<1,0,0b000,"fmaxnmp", int_aarch64_neon_fmaxnmp>;
3509 defm FMAXNM : SIMDThreeSameVectorFP<0,0,0b000,"fmaxnm", fmaxnum>;
3510 defm FMAXP : SIMDThreeSameVectorFP<1,0,0b110,"fmaxp", int_aarch64_neon_fmaxp>;
3511 defm FMAX : SIMDThreeSameVectorFP<0,0,0b110,"fmax", fmaximum>;
3512 defm FMINNMP : SIMDThreeSameVectorFP<1,1,0b000,"fminnmp", int_aarch64_neon_fminnmp>;
3513 defm FMINNM : SIMDThreeSameVectorFP<0,1,0b000,"fminnm", fminnum>;
3514 defm FMINP : SIMDThreeSameVectorFP<1,1,0b110,"fminp", int_aarch64_neon_fminp>;
3515 defm FMIN : SIMDThreeSameVectorFP<0,1,0b110,"fmin", fminimum>;
3517 // NOTE: The operands of the PatFrag are reordered on FMLA/FMLS because the
3518 // instruction expects the addend first, while the fma intrinsic puts it last.
3519 defm FMLA : SIMDThreeSameVectorFPTied<0, 0, 0b001, "fmla",
3520 TriOpFrag<(fma node:$RHS, node:$MHS, node:$LHS)> >;
3521 defm FMLS : SIMDThreeSameVectorFPTied<0, 1, 0b001, "fmls",
3522 TriOpFrag<(fma node:$MHS, (fneg node:$RHS), node:$LHS)> >;
3524 // The following def pats catch the case where the LHS of an FMA is negated.
3525 // The TriOpFrag above catches the case where the middle operand is negated.
3526 def : Pat<(v2f32 (fma (fneg V64:$Rn), V64:$Rm, V64:$Rd)),
3527 (FMLSv2f32 V64:$Rd, V64:$Rn, V64:$Rm)>;
3529 def : Pat<(v4f32 (fma (fneg V128:$Rn), V128:$Rm, V128:$Rd)),
3530 (FMLSv4f32 V128:$Rd, V128:$Rn, V128:$Rm)>;
3532 def : Pat<(v2f64 (fma (fneg V128:$Rn), V128:$Rm, V128:$Rd)),
3533 (FMLSv2f64 V128:$Rd, V128:$Rn, V128:$Rm)>;
3535 defm FMULX : SIMDThreeSameVectorFP<0,0,0b011,"fmulx", int_aarch64_neon_fmulx>;
3536 defm FMUL : SIMDThreeSameVectorFP<1,0,0b011,"fmul", fmul>;
3537 defm FRECPS : SIMDThreeSameVectorFP<0,0,0b111,"frecps", int_aarch64_neon_frecps>;
3538 defm FRSQRTS : SIMDThreeSameVectorFP<0,1,0b111,"frsqrts", int_aarch64_neon_frsqrts>;
3539 defm FSUB : SIMDThreeSameVectorFP<0,1,0b010,"fsub", fsub>;
3540 defm MLA : SIMDThreeSameVectorBHSTied<0, 0b10010, "mla",
3541 TriOpFrag<(add node:$LHS, (mul node:$MHS, node:$RHS))> >;
3542 defm MLS : SIMDThreeSameVectorBHSTied<1, 0b10010, "mls",
3543 TriOpFrag<(sub node:$LHS, (mul node:$MHS, node:$RHS))> >;
3544 defm MUL : SIMDThreeSameVectorBHS<0, 0b10011, "mul", mul>;
3545 defm PMUL : SIMDThreeSameVectorB<1, 0b10011, "pmul", int_aarch64_neon_pmul>;
3546 defm SABA : SIMDThreeSameVectorBHSTied<0, 0b01111, "saba",
3547 TriOpFrag<(add node:$LHS, (int_aarch64_neon_sabd node:$MHS, node:$RHS))> >;
3548 defm SABD : SIMDThreeSameVectorBHS<0,0b01110,"sabd", int_aarch64_neon_sabd>;
3549 defm SHADD : SIMDThreeSameVectorBHS<0,0b00000,"shadd", int_aarch64_neon_shadd>;
3550 defm SHSUB : SIMDThreeSameVectorBHS<0,0b00100,"shsub", int_aarch64_neon_shsub>;
3551 defm SMAXP : SIMDThreeSameVectorBHS<0,0b10100,"smaxp", int_aarch64_neon_smaxp>;
3552 defm SMAX : SIMDThreeSameVectorBHS<0,0b01100,"smax", smax>;
3553 defm SMINP : SIMDThreeSameVectorBHS<0,0b10101,"sminp", int_aarch64_neon_sminp>;
3554 defm SMIN : SIMDThreeSameVectorBHS<0,0b01101,"smin", smin>;
3555 defm SQADD : SIMDThreeSameVector<0,0b00001,"sqadd", int_aarch64_neon_sqadd>;
3556 defm SQDMULH : SIMDThreeSameVectorHS<0,0b10110,"sqdmulh",int_aarch64_neon_sqdmulh>;
3557 defm SQRDMULH : SIMDThreeSameVectorHS<1,0b10110,"sqrdmulh",int_aarch64_neon_sqrdmulh>;
3558 defm SQRSHL : SIMDThreeSameVector<0,0b01011,"sqrshl", int_aarch64_neon_sqrshl>;
3559 defm SQSHL : SIMDThreeSameVector<0,0b01001,"sqshl", int_aarch64_neon_sqshl>;
3560 defm SQSUB : SIMDThreeSameVector<0,0b00101,"sqsub", int_aarch64_neon_sqsub>;
3561 defm SRHADD : SIMDThreeSameVectorBHS<0,0b00010,"srhadd",int_aarch64_neon_srhadd>;
3562 defm SRSHL : SIMDThreeSameVector<0,0b01010,"srshl", int_aarch64_neon_srshl>;
3563 defm SSHL : SIMDThreeSameVector<0,0b01000,"sshl", int_aarch64_neon_sshl>;
3564 defm SUB : SIMDThreeSameVector<1,0b10000,"sub", sub>;
3565 defm UABA : SIMDThreeSameVectorBHSTied<1, 0b01111, "uaba",
3566 TriOpFrag<(add node:$LHS, (int_aarch64_neon_uabd node:$MHS, node:$RHS))> >;
3567 defm UABD : SIMDThreeSameVectorBHS<1,0b01110,"uabd", int_aarch64_neon_uabd>;
3568 defm UHADD : SIMDThreeSameVectorBHS<1,0b00000,"uhadd", int_aarch64_neon_uhadd>;
3569 defm UHSUB : SIMDThreeSameVectorBHS<1,0b00100,"uhsub", int_aarch64_neon_uhsub>;
3570 defm UMAXP : SIMDThreeSameVectorBHS<1,0b10100,"umaxp", int_aarch64_neon_umaxp>;
3571 defm UMAX : SIMDThreeSameVectorBHS<1,0b01100,"umax", umax>;
3572 defm UMINP : SIMDThreeSameVectorBHS<1,0b10101,"uminp", int_aarch64_neon_uminp>;
3573 defm UMIN : SIMDThreeSameVectorBHS<1,0b01101,"umin", umin>;
3574 defm UQADD : SIMDThreeSameVector<1,0b00001,"uqadd", int_aarch64_neon_uqadd>;
3575 defm UQRSHL : SIMDThreeSameVector<1,0b01011,"uqrshl", int_aarch64_neon_uqrshl>;
3576 defm UQSHL : SIMDThreeSameVector<1,0b01001,"uqshl", int_aarch64_neon_uqshl>;
3577 defm UQSUB : SIMDThreeSameVector<1,0b00101,"uqsub", int_aarch64_neon_uqsub>;
3578 defm URHADD : SIMDThreeSameVectorBHS<1,0b00010,"urhadd", int_aarch64_neon_urhadd>;
3579 defm URSHL : SIMDThreeSameVector<1,0b01010,"urshl", int_aarch64_neon_urshl>;
3580 defm USHL : SIMDThreeSameVector<1,0b01000,"ushl", int_aarch64_neon_ushl>;
3581 defm SQRDMLAH : SIMDThreeSameVectorSQRDMLxHTiedHS<1,0b10000,"sqrdmlah",
3582 int_aarch64_neon_sqadd>;
3583 defm SQRDMLSH : SIMDThreeSameVectorSQRDMLxHTiedHS<1,0b10001,"sqrdmlsh",
3584 int_aarch64_neon_sqsub>;
3586 defm AND : SIMDLogicalThreeVector<0, 0b00, "and", and>;
3587 defm BIC : SIMDLogicalThreeVector<0, 0b01, "bic",
3588 BinOpFrag<(and node:$LHS, (vnot node:$RHS))> >;
3589 defm BIF : SIMDLogicalThreeVector<1, 0b11, "bif">;
3590 defm BIT : SIMDLogicalThreeVectorTied<1, 0b10, "bit", AArch64bit>;
3591 defm BSL : SIMDLogicalThreeVectorTied<1, 0b01, "bsl",
3592 TriOpFrag<(or (and node:$LHS, node:$MHS), (and (vnot node:$LHS), node:$RHS))>>;
3593 defm EOR : SIMDLogicalThreeVector<1, 0b00, "eor", xor>;
3594 defm ORN : SIMDLogicalThreeVector<0, 0b11, "orn",
3595 BinOpFrag<(or node:$LHS, (vnot node:$RHS))> >;
3596 defm ORR : SIMDLogicalThreeVector<0, 0b10, "orr", or>;
3599 def : Pat<(AArch64bsl (v8i8 V64:$Rd), V64:$Rn, V64:$Rm),
3600 (BSLv8i8 V64:$Rd, V64:$Rn, V64:$Rm)>;
3601 def : Pat<(AArch64bsl (v4i16 V64:$Rd), V64:$Rn, V64:$Rm),
3602 (BSLv8i8 V64:$Rd, V64:$Rn, V64:$Rm)>;
3603 def : Pat<(AArch64bsl (v2i32 V64:$Rd), V64:$Rn, V64:$Rm),
3604 (BSLv8i8 V64:$Rd, V64:$Rn, V64:$Rm)>;
3605 def : Pat<(AArch64bsl (v1i64 V64:$Rd), V64:$Rn, V64:$Rm),
3606 (BSLv8i8 V64:$Rd, V64:$Rn, V64:$Rm)>;
3608 def : Pat<(AArch64bsl (v16i8 V128:$Rd), V128:$Rn, V128:$Rm),
3609 (BSLv16i8 V128:$Rd, V128:$Rn, V128:$Rm)>;
3610 def : Pat<(AArch64bsl (v8i16 V128:$Rd), V128:$Rn, V128:$Rm),
3611 (BSLv16i8 V128:$Rd, V128:$Rn, V128:$Rm)>;
3612 def : Pat<(AArch64bsl (v4i32 V128:$Rd), V128:$Rn, V128:$Rm),
3613 (BSLv16i8 V128:$Rd, V128:$Rn, V128:$Rm)>;
3614 def : Pat<(AArch64bsl (v2i64 V128:$Rd), V128:$Rn, V128:$Rm),
3615 (BSLv16i8 V128:$Rd, V128:$Rn, V128:$Rm)>;
3617 def : InstAlias<"mov{\t$dst.16b, $src.16b|.16b\t$dst, $src}",
3618 (ORRv16i8 V128:$dst, V128:$src, V128:$src), 1>;
3619 def : InstAlias<"mov{\t$dst.8h, $src.8h|.8h\t$dst, $src}",
3620 (ORRv16i8 V128:$dst, V128:$src, V128:$src), 0>;
3621 def : InstAlias<"mov{\t$dst.4s, $src.4s|.4s\t$dst, $src}",
3622 (ORRv16i8 V128:$dst, V128:$src, V128:$src), 0>;
3623 def : InstAlias<"mov{\t$dst.2d, $src.2d|.2d\t$dst, $src}",
3624 (ORRv16i8 V128:$dst, V128:$src, V128:$src), 0>;
3626 def : InstAlias<"mov{\t$dst.8b, $src.8b|.8b\t$dst, $src}",
3627 (ORRv8i8 V64:$dst, V64:$src, V64:$src), 1>;
3628 def : InstAlias<"mov{\t$dst.4h, $src.4h|.4h\t$dst, $src}",
3629 (ORRv8i8 V64:$dst, V64:$src, V64:$src), 0>;
3630 def : InstAlias<"mov{\t$dst.2s, $src.2s|.2s\t$dst, $src}",
3631 (ORRv8i8 V64:$dst, V64:$src, V64:$src), 0>;
3632 def : InstAlias<"mov{\t$dst.1d, $src.1d|.1d\t$dst, $src}",
3633 (ORRv8i8 V64:$dst, V64:$src, V64:$src), 0>;
3635 def : InstAlias<"{cmls\t$dst.8b, $src1.8b, $src2.8b" #
3636 "|cmls.8b\t$dst, $src1, $src2}",
3637 (CMHSv8i8 V64:$dst, V64:$src2, V64:$src1), 0>;
3638 def : InstAlias<"{cmls\t$dst.16b, $src1.16b, $src2.16b" #
3639 "|cmls.16b\t$dst, $src1, $src2}",
3640 (CMHSv16i8 V128:$dst, V128:$src2, V128:$src1), 0>;
3641 def : InstAlias<"{cmls\t$dst.4h, $src1.4h, $src2.4h" #
3642 "|cmls.4h\t$dst, $src1, $src2}",
3643 (CMHSv4i16 V64:$dst, V64:$src2, V64:$src1), 0>;
3644 def : InstAlias<"{cmls\t$dst.8h, $src1.8h, $src2.8h" #
3645 "|cmls.8h\t$dst, $src1, $src2}",
3646 (CMHSv8i16 V128:$dst, V128:$src2, V128:$src1), 0>;
3647 def : InstAlias<"{cmls\t$dst.2s, $src1.2s, $src2.2s" #
3648 "|cmls.2s\t$dst, $src1, $src2}",
3649 (CMHSv2i32 V64:$dst, V64:$src2, V64:$src1), 0>;
3650 def : InstAlias<"{cmls\t$dst.4s, $src1.4s, $src2.4s" #
3651 "|cmls.4s\t$dst, $src1, $src2}",
3652 (CMHSv4i32 V128:$dst, V128:$src2, V128:$src1), 0>;
3653 def : InstAlias<"{cmls\t$dst.2d, $src1.2d, $src2.2d" #
3654 "|cmls.2d\t$dst, $src1, $src2}",
3655 (CMHSv2i64 V128:$dst, V128:$src2, V128:$src1), 0>;
3657 def : InstAlias<"{cmlo\t$dst.8b, $src1.8b, $src2.8b" #
3658 "|cmlo.8b\t$dst, $src1, $src2}",
3659 (CMHIv8i8 V64:$dst, V64:$src2, V64:$src1), 0>;
3660 def : InstAlias<"{cmlo\t$dst.16b, $src1.16b, $src2.16b" #
3661 "|cmlo.16b\t$dst, $src1, $src2}",
3662 (CMHIv16i8 V128:$dst, V128:$src2, V128:$src1), 0>;
3663 def : InstAlias<"{cmlo\t$dst.4h, $src1.4h, $src2.4h" #
3664 "|cmlo.4h\t$dst, $src1, $src2}",
3665 (CMHIv4i16 V64:$dst, V64:$src2, V64:$src1), 0>;
3666 def : InstAlias<"{cmlo\t$dst.8h, $src1.8h, $src2.8h" #
3667 "|cmlo.8h\t$dst, $src1, $src2}",
3668 (CMHIv8i16 V128:$dst, V128:$src2, V128:$src1), 0>;
3669 def : InstAlias<"{cmlo\t$dst.2s, $src1.2s, $src2.2s" #
3670 "|cmlo.2s\t$dst, $src1, $src2}",
3671 (CMHIv2i32 V64:$dst, V64:$src2, V64:$src1), 0>;
3672 def : InstAlias<"{cmlo\t$dst.4s, $src1.4s, $src2.4s" #
3673 "|cmlo.4s\t$dst, $src1, $src2}",
3674 (CMHIv4i32 V128:$dst, V128:$src2, V128:$src1), 0>;
3675 def : InstAlias<"{cmlo\t$dst.2d, $src1.2d, $src2.2d" #
3676 "|cmlo.2d\t$dst, $src1, $src2}",
3677 (CMHIv2i64 V128:$dst, V128:$src2, V128:$src1), 0>;
3679 def : InstAlias<"{cmle\t$dst.8b, $src1.8b, $src2.8b" #
3680 "|cmle.8b\t$dst, $src1, $src2}",
3681 (CMGEv8i8 V64:$dst, V64:$src2, V64:$src1), 0>;
3682 def : InstAlias<"{cmle\t$dst.16b, $src1.16b, $src2.16b" #
3683 "|cmle.16b\t$dst, $src1, $src2}",
3684 (CMGEv16i8 V128:$dst, V128:$src2, V128:$src1), 0>;
3685 def : InstAlias<"{cmle\t$dst.4h, $src1.4h, $src2.4h" #
3686 "|cmle.4h\t$dst, $src1, $src2}",
3687 (CMGEv4i16 V64:$dst, V64:$src2, V64:$src1), 0>;
3688 def : InstAlias<"{cmle\t$dst.8h, $src1.8h, $src2.8h" #
3689 "|cmle.8h\t$dst, $src1, $src2}",
3690 (CMGEv8i16 V128:$dst, V128:$src2, V128:$src1), 0>;
3691 def : InstAlias<"{cmle\t$dst.2s, $src1.2s, $src2.2s" #
3692 "|cmle.2s\t$dst, $src1, $src2}",
3693 (CMGEv2i32 V64:$dst, V64:$src2, V64:$src1), 0>;
3694 def : InstAlias<"{cmle\t$dst.4s, $src1.4s, $src2.4s" #
3695 "|cmle.4s\t$dst, $src1, $src2}",
3696 (CMGEv4i32 V128:$dst, V128:$src2, V128:$src1), 0>;
3697 def : InstAlias<"{cmle\t$dst.2d, $src1.2d, $src2.2d" #
3698 "|cmle.2d\t$dst, $src1, $src2}",
3699 (CMGEv2i64 V128:$dst, V128:$src2, V128:$src1), 0>;
3701 def : InstAlias<"{cmlt\t$dst.8b, $src1.8b, $src2.8b" #
3702 "|cmlt.8b\t$dst, $src1, $src2}",
3703 (CMGTv8i8 V64:$dst, V64:$src2, V64:$src1), 0>;
3704 def : InstAlias<"{cmlt\t$dst.16b, $src1.16b, $src2.16b" #
3705 "|cmlt.16b\t$dst, $src1, $src2}",
3706 (CMGTv16i8 V128:$dst, V128:$src2, V128:$src1), 0>;
3707 def : InstAlias<"{cmlt\t$dst.4h, $src1.4h, $src2.4h" #
3708 "|cmlt.4h\t$dst, $src1, $src2}",
3709 (CMGTv4i16 V64:$dst, V64:$src2, V64:$src1), 0>;
3710 def : InstAlias<"{cmlt\t$dst.8h, $src1.8h, $src2.8h" #
3711 "|cmlt.8h\t$dst, $src1, $src2}",
3712 (CMGTv8i16 V128:$dst, V128:$src2, V128:$src1), 0>;
3713 def : InstAlias<"{cmlt\t$dst.2s, $src1.2s, $src2.2s" #
3714 "|cmlt.2s\t$dst, $src1, $src2}",
3715 (CMGTv2i32 V64:$dst, V64:$src2, V64:$src1), 0>;
3716 def : InstAlias<"{cmlt\t$dst.4s, $src1.4s, $src2.4s" #
3717 "|cmlt.4s\t$dst, $src1, $src2}",
3718 (CMGTv4i32 V128:$dst, V128:$src2, V128:$src1), 0>;
3719 def : InstAlias<"{cmlt\t$dst.2d, $src1.2d, $src2.2d" #
3720 "|cmlt.2d\t$dst, $src1, $src2}",
3721 (CMGTv2i64 V128:$dst, V128:$src2, V128:$src1), 0>;
3723 let Predicates = [HasNEON, HasFullFP16] in {
3724 def : InstAlias<"{fcmle\t$dst.4h, $src1.4h, $src2.4h" #
3725 "|fcmle.4h\t$dst, $src1, $src2}",
3726 (FCMGEv4f16 V64:$dst, V64:$src2, V64:$src1), 0>;
3727 def : InstAlias<"{fcmle\t$dst.8h, $src1.8h, $src2.8h" #
3728 "|fcmle.8h\t$dst, $src1, $src2}",
3729 (FCMGEv8f16 V128:$dst, V128:$src2, V128:$src1), 0>;
3731 def : InstAlias<"{fcmle\t$dst.2s, $src1.2s, $src2.2s" #
3732 "|fcmle.2s\t$dst, $src1, $src2}",
3733 (FCMGEv2f32 V64:$dst, V64:$src2, V64:$src1), 0>;
3734 def : InstAlias<"{fcmle\t$dst.4s, $src1.4s, $src2.4s" #
3735 "|fcmle.4s\t$dst, $src1, $src2}",
3736 (FCMGEv4f32 V128:$dst, V128:$src2, V128:$src1), 0>;
3737 def : InstAlias<"{fcmle\t$dst.2d, $src1.2d, $src2.2d" #
3738 "|fcmle.2d\t$dst, $src1, $src2}",
3739 (FCMGEv2f64 V128:$dst, V128:$src2, V128:$src1), 0>;
3741 let Predicates = [HasNEON, HasFullFP16] in {
3742 def : InstAlias<"{fcmlt\t$dst.4h, $src1.4h, $src2.4h" #
3743 "|fcmlt.4h\t$dst, $src1, $src2}",
3744 (FCMGTv4f16 V64:$dst, V64:$src2, V64:$src1), 0>;
3745 def : InstAlias<"{fcmlt\t$dst.8h, $src1.8h, $src2.8h" #
3746 "|fcmlt.8h\t$dst, $src1, $src2}",
3747 (FCMGTv8f16 V128:$dst, V128:$src2, V128:$src1), 0>;
3749 def : InstAlias<"{fcmlt\t$dst.2s, $src1.2s, $src2.2s" #
3750 "|fcmlt.2s\t$dst, $src1, $src2}",
3751 (FCMGTv2f32 V64:$dst, V64:$src2, V64:$src1), 0>;
3752 def : InstAlias<"{fcmlt\t$dst.4s, $src1.4s, $src2.4s" #
3753 "|fcmlt.4s\t$dst, $src1, $src2}",
3754 (FCMGTv4f32 V128:$dst, V128:$src2, V128:$src1), 0>;
3755 def : InstAlias<"{fcmlt\t$dst.2d, $src1.2d, $src2.2d" #
3756 "|fcmlt.2d\t$dst, $src1, $src2}",
3757 (FCMGTv2f64 V128:$dst, V128:$src2, V128:$src1), 0>;
3759 let Predicates = [HasNEON, HasFullFP16] in {
3760 def : InstAlias<"{facle\t$dst.4h, $src1.4h, $src2.4h" #
3761 "|facle.4h\t$dst, $src1, $src2}",
3762 (FACGEv4f16 V64:$dst, V64:$src2, V64:$src1), 0>;
3763 def : InstAlias<"{facle\t$dst.8h, $src1.8h, $src2.8h" #
3764 "|facle.8h\t$dst, $src1, $src2}",
3765 (FACGEv8f16 V128:$dst, V128:$src2, V128:$src1), 0>;
3767 def : InstAlias<"{facle\t$dst.2s, $src1.2s, $src2.2s" #
3768 "|facle.2s\t$dst, $src1, $src2}",
3769 (FACGEv2f32 V64:$dst, V64:$src2, V64:$src1), 0>;
3770 def : InstAlias<"{facle\t$dst.4s, $src1.4s, $src2.4s" #
3771 "|facle.4s\t$dst, $src1, $src2}",
3772 (FACGEv4f32 V128:$dst, V128:$src2, V128:$src1), 0>;
3773 def : InstAlias<"{facle\t$dst.2d, $src1.2d, $src2.2d" #
3774 "|facle.2d\t$dst, $src1, $src2}",
3775 (FACGEv2f64 V128:$dst, V128:$src2, V128:$src1), 0>;
3777 let Predicates = [HasNEON, HasFullFP16] in {
3778 def : InstAlias<"{faclt\t$dst.4h, $src1.4h, $src2.4h" #
3779 "|faclt.4h\t$dst, $src1, $src2}",
3780 (FACGTv4f16 V64:$dst, V64:$src2, V64:$src1), 0>;
3781 def : InstAlias<"{faclt\t$dst.8h, $src1.8h, $src2.8h" #
3782 "|faclt.8h\t$dst, $src1, $src2}",
3783 (FACGTv8f16 V128:$dst, V128:$src2, V128:$src1), 0>;
3785 def : InstAlias<"{faclt\t$dst.2s, $src1.2s, $src2.2s" #
3786 "|faclt.2s\t$dst, $src1, $src2}",
3787 (FACGTv2f32 V64:$dst, V64:$src2, V64:$src1), 0>;
3788 def : InstAlias<"{faclt\t$dst.4s, $src1.4s, $src2.4s" #
3789 "|faclt.4s\t$dst, $src1, $src2}",
3790 (FACGTv4f32 V128:$dst, V128:$src2, V128:$src1), 0>;
3791 def : InstAlias<"{faclt\t$dst.2d, $src1.2d, $src2.2d" #
3792 "|faclt.2d\t$dst, $src1, $src2}",
3793 (FACGTv2f64 V128:$dst, V128:$src2, V128:$src1), 0>;
3795 //===----------------------------------------------------------------------===//
3796 // Advanced SIMD three scalar instructions.
3797 //===----------------------------------------------------------------------===//
3799 defm ADD : SIMDThreeScalarD<0, 0b10000, "add", add>;
3800 defm CMEQ : SIMDThreeScalarD<1, 0b10001, "cmeq", AArch64cmeq>;
3801 defm CMGE : SIMDThreeScalarD<0, 0b00111, "cmge", AArch64cmge>;
3802 defm CMGT : SIMDThreeScalarD<0, 0b00110, "cmgt", AArch64cmgt>;
3803 defm CMHI : SIMDThreeScalarD<1, 0b00110, "cmhi", AArch64cmhi>;
3804 defm CMHS : SIMDThreeScalarD<1, 0b00111, "cmhs", AArch64cmhs>;
3805 defm CMTST : SIMDThreeScalarD<0, 0b10001, "cmtst", AArch64cmtst>;
3806 defm FABD : SIMDFPThreeScalar<1, 1, 0b010, "fabd", int_aarch64_sisd_fabd>;
3807 def : Pat<(v1f64 (int_aarch64_neon_fabd (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
3808 (FABD64 FPR64:$Rn, FPR64:$Rm)>;
3809 let Predicates = [HasFullFP16] in {
3810 def : Pat<(fabs (fsub f16:$Rn, f16:$Rm)), (FABD16 f16:$Rn, f16:$Rm)>;
3812 def : Pat<(fabs (fsub f32:$Rn, f32:$Rm)), (FABD32 f32:$Rn, f32:$Rm)>;
3813 def : Pat<(fabs (fsub f64:$Rn, f64:$Rm)), (FABD64 f64:$Rn, f64:$Rm)>;
3814 defm FACGE : SIMDThreeScalarFPCmp<1, 0, 0b101, "facge",
3815 int_aarch64_neon_facge>;
3816 defm FACGT : SIMDThreeScalarFPCmp<1, 1, 0b101, "facgt",
3817 int_aarch64_neon_facgt>;
3818 defm FCMEQ : SIMDThreeScalarFPCmp<0, 0, 0b100, "fcmeq", AArch64fcmeq>;
3819 defm FCMGE : SIMDThreeScalarFPCmp<1, 0, 0b100, "fcmge", AArch64fcmge>;
3820 defm FCMGT : SIMDThreeScalarFPCmp<1, 1, 0b100, "fcmgt", AArch64fcmgt>;
3821 defm FMULX : SIMDFPThreeScalar<0, 0, 0b011, "fmulx", int_aarch64_neon_fmulx>;
3822 defm FRECPS : SIMDFPThreeScalar<0, 0, 0b111, "frecps", int_aarch64_neon_frecps>;
3823 defm FRSQRTS : SIMDFPThreeScalar<0, 1, 0b111, "frsqrts", int_aarch64_neon_frsqrts>;
3824 defm SQADD : SIMDThreeScalarBHSD<0, 0b00001, "sqadd", int_aarch64_neon_sqadd>;
3825 defm SQDMULH : SIMDThreeScalarHS< 0, 0b10110, "sqdmulh", int_aarch64_neon_sqdmulh>;
3826 defm SQRDMULH : SIMDThreeScalarHS< 1, 0b10110, "sqrdmulh", int_aarch64_neon_sqrdmulh>;
3827 defm SQRSHL : SIMDThreeScalarBHSD<0, 0b01011, "sqrshl",int_aarch64_neon_sqrshl>;
3828 defm SQSHL : SIMDThreeScalarBHSD<0, 0b01001, "sqshl", int_aarch64_neon_sqshl>;
3829 defm SQSUB : SIMDThreeScalarBHSD<0, 0b00101, "sqsub", int_aarch64_neon_sqsub>;
3830 defm SRSHL : SIMDThreeScalarD< 0, 0b01010, "srshl", int_aarch64_neon_srshl>;
3831 defm SSHL : SIMDThreeScalarD< 0, 0b01000, "sshl", int_aarch64_neon_sshl>;
3832 defm SUB : SIMDThreeScalarD< 1, 0b10000, "sub", sub>;
3833 defm UQADD : SIMDThreeScalarBHSD<1, 0b00001, "uqadd", int_aarch64_neon_uqadd>;
3834 defm UQRSHL : SIMDThreeScalarBHSD<1, 0b01011, "uqrshl",int_aarch64_neon_uqrshl>;
3835 defm UQSHL : SIMDThreeScalarBHSD<1, 0b01001, "uqshl", int_aarch64_neon_uqshl>;
3836 defm UQSUB : SIMDThreeScalarBHSD<1, 0b00101, "uqsub", int_aarch64_neon_uqsub>;
3837 defm URSHL : SIMDThreeScalarD< 1, 0b01010, "urshl", int_aarch64_neon_urshl>;
3838 defm USHL : SIMDThreeScalarD< 1, 0b01000, "ushl", int_aarch64_neon_ushl>;
3839 let Predicates = [HasRDM] in {
3840 defm SQRDMLAH : SIMDThreeScalarHSTied<1, 0, 0b10000, "sqrdmlah">;
3841 defm SQRDMLSH : SIMDThreeScalarHSTied<1, 0, 0b10001, "sqrdmlsh">;
3842 def : Pat<(i32 (int_aarch64_neon_sqadd
3844 (i32 (int_aarch64_neon_sqrdmulh (i32 FPR32:$Rn),
3845 (i32 FPR32:$Rm))))),
3846 (SQRDMLAHv1i32 FPR32:$Rd, FPR32:$Rn, FPR32:$Rm)>;
3847 def : Pat<(i32 (int_aarch64_neon_sqsub
3849 (i32 (int_aarch64_neon_sqrdmulh (i32 FPR32:$Rn),
3850 (i32 FPR32:$Rm))))),
3851 (SQRDMLSHv1i32 FPR32:$Rd, FPR32:$Rn, FPR32:$Rm)>;
3854 def : InstAlias<"cmls $dst, $src1, $src2",
3855 (CMHSv1i64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
3856 def : InstAlias<"cmle $dst, $src1, $src2",
3857 (CMGEv1i64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
3858 def : InstAlias<"cmlo $dst, $src1, $src2",
3859 (CMHIv1i64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
3860 def : InstAlias<"cmlt $dst, $src1, $src2",
3861 (CMGTv1i64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
3862 def : InstAlias<"fcmle $dst, $src1, $src2",
3863 (FCMGE32 FPR32:$dst, FPR32:$src2, FPR32:$src1), 0>;
3864 def : InstAlias<"fcmle $dst, $src1, $src2",
3865 (FCMGE64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
3866 def : InstAlias<"fcmlt $dst, $src1, $src2",
3867 (FCMGT32 FPR32:$dst, FPR32:$src2, FPR32:$src1), 0>;
3868 def : InstAlias<"fcmlt $dst, $src1, $src2",
3869 (FCMGT64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
3870 def : InstAlias<"facle $dst, $src1, $src2",
3871 (FACGE32 FPR32:$dst, FPR32:$src2, FPR32:$src1), 0>;
3872 def : InstAlias<"facle $dst, $src1, $src2",
3873 (FACGE64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
3874 def : InstAlias<"faclt $dst, $src1, $src2",
3875 (FACGT32 FPR32:$dst, FPR32:$src2, FPR32:$src1), 0>;
3876 def : InstAlias<"faclt $dst, $src1, $src2",
3877 (FACGT64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
3879 //===----------------------------------------------------------------------===//
3880 // Advanced SIMD three scalar instructions (mixed operands).
3881 //===----------------------------------------------------------------------===//
3882 defm SQDMULL : SIMDThreeScalarMixedHS<0, 0b11010, "sqdmull",
3883 int_aarch64_neon_sqdmulls_scalar>;
3884 defm SQDMLAL : SIMDThreeScalarMixedTiedHS<0, 0b10010, "sqdmlal">;
3885 defm SQDMLSL : SIMDThreeScalarMixedTiedHS<0, 0b10110, "sqdmlsl">;
3887 def : Pat<(i64 (int_aarch64_neon_sqadd (i64 FPR64:$Rd),
3888 (i64 (int_aarch64_neon_sqdmulls_scalar (i32 FPR32:$Rn),
3889 (i32 FPR32:$Rm))))),
3890 (SQDMLALi32 FPR64:$Rd, FPR32:$Rn, FPR32:$Rm)>;
3891 def : Pat<(i64 (int_aarch64_neon_sqsub (i64 FPR64:$Rd),
3892 (i64 (int_aarch64_neon_sqdmulls_scalar (i32 FPR32:$Rn),
3893 (i32 FPR32:$Rm))))),
3894 (SQDMLSLi32 FPR64:$Rd, FPR32:$Rn, FPR32:$Rm)>;
3896 //===----------------------------------------------------------------------===//
3897 // Advanced SIMD two scalar instructions.
3898 //===----------------------------------------------------------------------===//
3900 defm ABS : SIMDTwoScalarD< 0, 0b01011, "abs", abs>;
3901 defm CMEQ : SIMDCmpTwoScalarD< 0, 0b01001, "cmeq", AArch64cmeqz>;
3902 defm CMGE : SIMDCmpTwoScalarD< 1, 0b01000, "cmge", AArch64cmgez>;
3903 defm CMGT : SIMDCmpTwoScalarD< 0, 0b01000, "cmgt", AArch64cmgtz>;
3904 defm CMLE : SIMDCmpTwoScalarD< 1, 0b01001, "cmle", AArch64cmlez>;
3905 defm CMLT : SIMDCmpTwoScalarD< 0, 0b01010, "cmlt", AArch64cmltz>;
3906 defm FCMEQ : SIMDFPCmpTwoScalar<0, 1, 0b01101, "fcmeq", AArch64fcmeqz>;
3907 defm FCMGE : SIMDFPCmpTwoScalar<1, 1, 0b01100, "fcmge", AArch64fcmgez>;
3908 defm FCMGT : SIMDFPCmpTwoScalar<0, 1, 0b01100, "fcmgt", AArch64fcmgtz>;
3909 defm FCMLE : SIMDFPCmpTwoScalar<1, 1, 0b01101, "fcmle", AArch64fcmlez>;
3910 defm FCMLT : SIMDFPCmpTwoScalar<0, 1, 0b01110, "fcmlt", AArch64fcmltz>;
3911 defm FCVTAS : SIMDFPTwoScalar< 0, 0, 0b11100, "fcvtas">;
3912 defm FCVTAU : SIMDFPTwoScalar< 1, 0, 0b11100, "fcvtau">;
3913 defm FCVTMS : SIMDFPTwoScalar< 0, 0, 0b11011, "fcvtms">;
3914 defm FCVTMU : SIMDFPTwoScalar< 1, 0, 0b11011, "fcvtmu">;
3915 defm FCVTNS : SIMDFPTwoScalar< 0, 0, 0b11010, "fcvtns">;
3916 defm FCVTNU : SIMDFPTwoScalar< 1, 0, 0b11010, "fcvtnu">;
3917 defm FCVTPS : SIMDFPTwoScalar< 0, 1, 0b11010, "fcvtps">;
3918 defm FCVTPU : SIMDFPTwoScalar< 1, 1, 0b11010, "fcvtpu">;
3919 def FCVTXNv1i64 : SIMDInexactCvtTwoScalar<0b10110, "fcvtxn">;
3920 defm FCVTZS : SIMDFPTwoScalar< 0, 1, 0b11011, "fcvtzs">;
3921 defm FCVTZU : SIMDFPTwoScalar< 1, 1, 0b11011, "fcvtzu">;
3922 defm FRECPE : SIMDFPTwoScalar< 0, 1, 0b11101, "frecpe">;
3923 defm FRECPX : SIMDFPTwoScalar< 0, 1, 0b11111, "frecpx">;
3924 defm FRSQRTE : SIMDFPTwoScalar< 1, 1, 0b11101, "frsqrte">;
3925 defm NEG : SIMDTwoScalarD< 1, 0b01011, "neg",
3926 UnOpFrag<(sub immAllZerosV, node:$LHS)> >;
3927 defm SCVTF : SIMDFPTwoScalarCVT< 0, 0, 0b11101, "scvtf", AArch64sitof>;
3928 defm SQABS : SIMDTwoScalarBHSD< 0, 0b00111, "sqabs", int_aarch64_neon_sqabs>;
3929 defm SQNEG : SIMDTwoScalarBHSD< 1, 0b00111, "sqneg", int_aarch64_neon_sqneg>;
3930 defm SQXTN : SIMDTwoScalarMixedBHS< 0, 0b10100, "sqxtn", int_aarch64_neon_scalar_sqxtn>;
3931 defm SQXTUN : SIMDTwoScalarMixedBHS< 1, 0b10010, "sqxtun", int_aarch64_neon_scalar_sqxtun>;
3932 defm SUQADD : SIMDTwoScalarBHSDTied< 0, 0b00011, "suqadd",
3933 int_aarch64_neon_suqadd>;
3934 defm UCVTF : SIMDFPTwoScalarCVT< 1, 0, 0b11101, "ucvtf", AArch64uitof>;
3935 defm UQXTN : SIMDTwoScalarMixedBHS<1, 0b10100, "uqxtn", int_aarch64_neon_scalar_uqxtn>;
3936 defm USQADD : SIMDTwoScalarBHSDTied< 1, 0b00011, "usqadd",
3937 int_aarch64_neon_usqadd>;
3939 def : Pat<(AArch64neg (v1i64 V64:$Rn)), (NEGv1i64 V64:$Rn)>;
3941 def : Pat<(v1i64 (int_aarch64_neon_fcvtas (v1f64 FPR64:$Rn))),
3942 (FCVTASv1i64 FPR64:$Rn)>;
3943 def : Pat<(v1i64 (int_aarch64_neon_fcvtau (v1f64 FPR64:$Rn))),
3944 (FCVTAUv1i64 FPR64:$Rn)>;
3945 def : Pat<(v1i64 (int_aarch64_neon_fcvtms (v1f64 FPR64:$Rn))),
3946 (FCVTMSv1i64 FPR64:$Rn)>;
3947 def : Pat<(v1i64 (int_aarch64_neon_fcvtmu (v1f64 FPR64:$Rn))),
3948 (FCVTMUv1i64 FPR64:$Rn)>;
3949 def : Pat<(v1i64 (int_aarch64_neon_fcvtns (v1f64 FPR64:$Rn))),
3950 (FCVTNSv1i64 FPR64:$Rn)>;
3951 def : Pat<(v1i64 (int_aarch64_neon_fcvtnu (v1f64 FPR64:$Rn))),
3952 (FCVTNUv1i64 FPR64:$Rn)>;
3953 def : Pat<(v1i64 (int_aarch64_neon_fcvtps (v1f64 FPR64:$Rn))),
3954 (FCVTPSv1i64 FPR64:$Rn)>;
3955 def : Pat<(v1i64 (int_aarch64_neon_fcvtpu (v1f64 FPR64:$Rn))),
3956 (FCVTPUv1i64 FPR64:$Rn)>;
3958 def : Pat<(f16 (int_aarch64_neon_frecpe (f16 FPR16:$Rn))),
3959 (FRECPEv1f16 FPR16:$Rn)>;
3960 def : Pat<(f32 (int_aarch64_neon_frecpe (f32 FPR32:$Rn))),
3961 (FRECPEv1i32 FPR32:$Rn)>;
3962 def : Pat<(f64 (int_aarch64_neon_frecpe (f64 FPR64:$Rn))),
3963 (FRECPEv1i64 FPR64:$Rn)>;
3964 def : Pat<(v1f64 (int_aarch64_neon_frecpe (v1f64 FPR64:$Rn))),
3965 (FRECPEv1i64 FPR64:$Rn)>;
3967 def : Pat<(f32 (AArch64frecpe (f32 FPR32:$Rn))),
3968 (FRECPEv1i32 FPR32:$Rn)>;
3969 def : Pat<(v2f32 (AArch64frecpe (v2f32 V64:$Rn))),
3970 (FRECPEv2f32 V64:$Rn)>;
3971 def : Pat<(v4f32 (AArch64frecpe (v4f32 FPR128:$Rn))),
3972 (FRECPEv4f32 FPR128:$Rn)>;
3973 def : Pat<(f64 (AArch64frecpe (f64 FPR64:$Rn))),
3974 (FRECPEv1i64 FPR64:$Rn)>;
3975 def : Pat<(v1f64 (AArch64frecpe (v1f64 FPR64:$Rn))),
3976 (FRECPEv1i64 FPR64:$Rn)>;
3977 def : Pat<(v2f64 (AArch64frecpe (v2f64 FPR128:$Rn))),
3978 (FRECPEv2f64 FPR128:$Rn)>;
3980 def : Pat<(f32 (AArch64frecps (f32 FPR32:$Rn), (f32 FPR32:$Rm))),
3981 (FRECPS32 FPR32:$Rn, FPR32:$Rm)>;
3982 def : Pat<(v2f32 (AArch64frecps (v2f32 V64:$Rn), (v2f32 V64:$Rm))),
3983 (FRECPSv2f32 V64:$Rn, V64:$Rm)>;
3984 def : Pat<(v4f32 (AArch64frecps (v4f32 FPR128:$Rn), (v4f32 FPR128:$Rm))),
3985 (FRECPSv4f32 FPR128:$Rn, FPR128:$Rm)>;
3986 def : Pat<(f64 (AArch64frecps (f64 FPR64:$Rn), (f64 FPR64:$Rm))),
3987 (FRECPS64 FPR64:$Rn, FPR64:$Rm)>;
3988 def : Pat<(v2f64 (AArch64frecps (v2f64 FPR128:$Rn), (v2f64 FPR128:$Rm))),
3989 (FRECPSv2f64 FPR128:$Rn, FPR128:$Rm)>;
3991 def : Pat<(f16 (int_aarch64_neon_frecpx (f16 FPR16:$Rn))),
3992 (FRECPXv1f16 FPR16:$Rn)>;
3993 def : Pat<(f32 (int_aarch64_neon_frecpx (f32 FPR32:$Rn))),
3994 (FRECPXv1i32 FPR32:$Rn)>;
3995 def : Pat<(f64 (int_aarch64_neon_frecpx (f64 FPR64:$Rn))),
3996 (FRECPXv1i64 FPR64:$Rn)>;
3998 def : Pat<(f16 (int_aarch64_neon_frsqrte (f16 FPR16:$Rn))),
3999 (FRSQRTEv1f16 FPR16:$Rn)>;
4000 def : Pat<(f32 (int_aarch64_neon_frsqrte (f32 FPR32:$Rn))),
4001 (FRSQRTEv1i32 FPR32:$Rn)>;
4002 def : Pat<(f64 (int_aarch64_neon_frsqrte (f64 FPR64:$Rn))),
4003 (FRSQRTEv1i64 FPR64:$Rn)>;
4004 def : Pat<(v1f64 (int_aarch64_neon_frsqrte (v1f64 FPR64:$Rn))),
4005 (FRSQRTEv1i64 FPR64:$Rn)>;
4007 def : Pat<(f32 (AArch64frsqrte (f32 FPR32:$Rn))),
4008 (FRSQRTEv1i32 FPR32:$Rn)>;
4009 def : Pat<(v2f32 (AArch64frsqrte (v2f32 V64:$Rn))),
4010 (FRSQRTEv2f32 V64:$Rn)>;
4011 def : Pat<(v4f32 (AArch64frsqrte (v4f32 FPR128:$Rn))),
4012 (FRSQRTEv4f32 FPR128:$Rn)>;
4013 def : Pat<(f64 (AArch64frsqrte (f64 FPR64:$Rn))),
4014 (FRSQRTEv1i64 FPR64:$Rn)>;
4015 def : Pat<(v1f64 (AArch64frsqrte (v1f64 FPR64:$Rn))),
4016 (FRSQRTEv1i64 FPR64:$Rn)>;
4017 def : Pat<(v2f64 (AArch64frsqrte (v2f64 FPR128:$Rn))),
4018 (FRSQRTEv2f64 FPR128:$Rn)>;
4020 def : Pat<(f32 (AArch64frsqrts (f32 FPR32:$Rn), (f32 FPR32:$Rm))),
4021 (FRSQRTS32 FPR32:$Rn, FPR32:$Rm)>;
4022 def : Pat<(v2f32 (AArch64frsqrts (v2f32 V64:$Rn), (v2f32 V64:$Rm))),
4023 (FRSQRTSv2f32 V64:$Rn, V64:$Rm)>;
4024 def : Pat<(v4f32 (AArch64frsqrts (v4f32 FPR128:$Rn), (v4f32 FPR128:$Rm))),
4025 (FRSQRTSv4f32 FPR128:$Rn, FPR128:$Rm)>;
4026 def : Pat<(f64 (AArch64frsqrts (f64 FPR64:$Rn), (f64 FPR64:$Rm))),
4027 (FRSQRTS64 FPR64:$Rn, FPR64:$Rm)>;
4028 def : Pat<(v2f64 (AArch64frsqrts (v2f64 FPR128:$Rn), (v2f64 FPR128:$Rm))),
4029 (FRSQRTSv2f64 FPR128:$Rn, FPR128:$Rm)>;
4031 // If an integer is about to be converted to a floating point value,
4032 // just load it on the floating point unit.
4033 // Here are the patterns for 8 and 16-bits to float.
4035 multiclass UIntToFPROLoadPat<ValueType DstTy, ValueType SrcTy,
4036 SDPatternOperator loadop, Instruction UCVTF,
4037 ROAddrMode ro, Instruction LDRW, Instruction LDRX,
4039 def : Pat<(DstTy (uint_to_fp (SrcTy
4040 (loadop (ro.Wpat GPR64sp:$Rn, GPR32:$Rm,
4041 ro.Wext:$extend))))),
4042 (UCVTF (INSERT_SUBREG (DstTy (IMPLICIT_DEF)),
4043 (LDRW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend),
4046 def : Pat<(DstTy (uint_to_fp (SrcTy
4047 (loadop (ro.Xpat GPR64sp:$Rn, GPR64:$Rm,
4048 ro.Wext:$extend))))),
4049 (UCVTF (INSERT_SUBREG (DstTy (IMPLICIT_DEF)),
4050 (LDRX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend),
4054 defm : UIntToFPROLoadPat<f32, i32, zextloadi8,
4055 UCVTFv1i32, ro8, LDRBroW, LDRBroX, bsub>;
4056 def : Pat <(f32 (uint_to_fp (i32
4057 (zextloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))))),
4058 (UCVTFv1i32 (INSERT_SUBREG (f32 (IMPLICIT_DEF)),
4059 (LDRBui GPR64sp:$Rn, uimm12s1:$offset), bsub))>;
4060 def : Pat <(f32 (uint_to_fp (i32
4061 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))))),
4062 (UCVTFv1i32 (INSERT_SUBREG (f32 (IMPLICIT_DEF)),
4063 (LDURBi GPR64sp:$Rn, simm9:$offset), bsub))>;
4064 // 16-bits -> float.
4065 defm : UIntToFPROLoadPat<f32, i32, zextloadi16,
4066 UCVTFv1i32, ro16, LDRHroW, LDRHroX, hsub>;
4067 def : Pat <(f32 (uint_to_fp (i32
4068 (zextloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))))),
4069 (UCVTFv1i32 (INSERT_SUBREG (f32 (IMPLICIT_DEF)),
4070 (LDRHui GPR64sp:$Rn, uimm12s2:$offset), hsub))>;
4071 def : Pat <(f32 (uint_to_fp (i32
4072 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))))),
4073 (UCVTFv1i32 (INSERT_SUBREG (f32 (IMPLICIT_DEF)),
4074 (LDURHi GPR64sp:$Rn, simm9:$offset), hsub))>;
4075 // 32-bits are handled in target specific dag combine:
4076 // performIntToFpCombine.
4077 // 64-bits integer to 32-bits floating point, not possible with
4078 // UCVTF on floating point registers (both source and destination
4079 // must have the same size).
4081 // Here are the patterns for 8, 16, 32, and 64-bits to double.
4082 // 8-bits -> double.
4083 defm : UIntToFPROLoadPat<f64, i32, zextloadi8,
4084 UCVTFv1i64, ro8, LDRBroW, LDRBroX, bsub>;
4085 def : Pat <(f64 (uint_to_fp (i32
4086 (zextloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))))),
4087 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4088 (LDRBui GPR64sp:$Rn, uimm12s1:$offset), bsub))>;
4089 def : Pat <(f64 (uint_to_fp (i32
4090 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))))),
4091 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4092 (LDURBi GPR64sp:$Rn, simm9:$offset), bsub))>;
4093 // 16-bits -> double.
4094 defm : UIntToFPROLoadPat<f64, i32, zextloadi16,
4095 UCVTFv1i64, ro16, LDRHroW, LDRHroX, hsub>;
4096 def : Pat <(f64 (uint_to_fp (i32
4097 (zextloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))))),
4098 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4099 (LDRHui GPR64sp:$Rn, uimm12s2:$offset), hsub))>;
4100 def : Pat <(f64 (uint_to_fp (i32
4101 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))))),
4102 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4103 (LDURHi GPR64sp:$Rn, simm9:$offset), hsub))>;
4104 // 32-bits -> double.
4105 defm : UIntToFPROLoadPat<f64, i32, load,
4106 UCVTFv1i64, ro32, LDRSroW, LDRSroX, ssub>;
4107 def : Pat <(f64 (uint_to_fp (i32
4108 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))))),
4109 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4110 (LDRSui GPR64sp:$Rn, uimm12s4:$offset), ssub))>;
4111 def : Pat <(f64 (uint_to_fp (i32
4112 (load (am_unscaled32 GPR64sp:$Rn, simm9:$offset))))),
4113 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4114 (LDURSi GPR64sp:$Rn, simm9:$offset), ssub))>;
4115 // 64-bits -> double are handled in target specific dag combine:
4116 // performIntToFpCombine.
4118 //===----------------------------------------------------------------------===//
4119 // Advanced SIMD three different-sized vector instructions.
4120 //===----------------------------------------------------------------------===//
4122 defm ADDHN : SIMDNarrowThreeVectorBHS<0,0b0100,"addhn", int_aarch64_neon_addhn>;
4123 defm SUBHN : SIMDNarrowThreeVectorBHS<0,0b0110,"subhn", int_aarch64_neon_subhn>;
4124 defm RADDHN : SIMDNarrowThreeVectorBHS<1,0b0100,"raddhn",int_aarch64_neon_raddhn>;
4125 defm RSUBHN : SIMDNarrowThreeVectorBHS<1,0b0110,"rsubhn",int_aarch64_neon_rsubhn>;
4126 defm PMULL : SIMDDifferentThreeVectorBD<0,0b1110,"pmull",int_aarch64_neon_pmull>;
4127 defm SABAL : SIMDLongThreeVectorTiedBHSabal<0,0b0101,"sabal",
4128 int_aarch64_neon_sabd>;
4129 defm SABDL : SIMDLongThreeVectorBHSabdl<0, 0b0111, "sabdl",
4130 int_aarch64_neon_sabd>;
4131 defm SADDL : SIMDLongThreeVectorBHS< 0, 0b0000, "saddl",
4132 BinOpFrag<(add (sext node:$LHS), (sext node:$RHS))>>;
4133 defm SADDW : SIMDWideThreeVectorBHS< 0, 0b0001, "saddw",
4134 BinOpFrag<(add node:$LHS, (sext node:$RHS))>>;
4135 defm SMLAL : SIMDLongThreeVectorTiedBHS<0, 0b1000, "smlal",
4136 TriOpFrag<(add node:$LHS, (int_aarch64_neon_smull node:$MHS, node:$RHS))>>;
4137 defm SMLSL : SIMDLongThreeVectorTiedBHS<0, 0b1010, "smlsl",
4138 TriOpFrag<(sub node:$LHS, (int_aarch64_neon_smull node:$MHS, node:$RHS))>>;
4139 defm SMULL : SIMDLongThreeVectorBHS<0, 0b1100, "smull", int_aarch64_neon_smull>;
4140 defm SQDMLAL : SIMDLongThreeVectorSQDMLXTiedHS<0, 0b1001, "sqdmlal",
4141 int_aarch64_neon_sqadd>;
4142 defm SQDMLSL : SIMDLongThreeVectorSQDMLXTiedHS<0, 0b1011, "sqdmlsl",
4143 int_aarch64_neon_sqsub>;
4144 defm SQDMULL : SIMDLongThreeVectorHS<0, 0b1101, "sqdmull",
4145 int_aarch64_neon_sqdmull>;
4146 defm SSUBL : SIMDLongThreeVectorBHS<0, 0b0010, "ssubl",
4147 BinOpFrag<(sub (sext node:$LHS), (sext node:$RHS))>>;
4148 defm SSUBW : SIMDWideThreeVectorBHS<0, 0b0011, "ssubw",
4149 BinOpFrag<(sub node:$LHS, (sext node:$RHS))>>;
4150 defm UABAL : SIMDLongThreeVectorTiedBHSabal<1, 0b0101, "uabal",
4151 int_aarch64_neon_uabd>;
4152 defm UADDL : SIMDLongThreeVectorBHS<1, 0b0000, "uaddl",
4153 BinOpFrag<(add (zext node:$LHS), (zext node:$RHS))>>;
4154 defm UADDW : SIMDWideThreeVectorBHS<1, 0b0001, "uaddw",
4155 BinOpFrag<(add node:$LHS, (zext node:$RHS))>>;
4156 defm UMLAL : SIMDLongThreeVectorTiedBHS<1, 0b1000, "umlal",
4157 TriOpFrag<(add node:$LHS, (int_aarch64_neon_umull node:$MHS, node:$RHS))>>;
4158 defm UMLSL : SIMDLongThreeVectorTiedBHS<1, 0b1010, "umlsl",
4159 TriOpFrag<(sub node:$LHS, (int_aarch64_neon_umull node:$MHS, node:$RHS))>>;
4160 defm UMULL : SIMDLongThreeVectorBHS<1, 0b1100, "umull", int_aarch64_neon_umull>;
4161 defm USUBL : SIMDLongThreeVectorBHS<1, 0b0010, "usubl",
4162 BinOpFrag<(sub (zext node:$LHS), (zext node:$RHS))>>;
4163 defm USUBW : SIMDWideThreeVectorBHS< 1, 0b0011, "usubw",
4164 BinOpFrag<(sub node:$LHS, (zext node:$RHS))>>;
4166 // Additional patterns for SMULL and UMULL
4167 multiclass Neon_mul_widen_patterns<SDPatternOperator opnode,
4168 Instruction INST8B, Instruction INST4H, Instruction INST2S> {
4169 def : Pat<(v8i16 (opnode (v8i8 V64:$Rn), (v8i8 V64:$Rm))),
4170 (INST8B V64:$Rn, V64:$Rm)>;
4171 def : Pat<(v4i32 (opnode (v4i16 V64:$Rn), (v4i16 V64:$Rm))),
4172 (INST4H V64:$Rn, V64:$Rm)>;
4173 def : Pat<(v2i64 (opnode (v2i32 V64:$Rn), (v2i32 V64:$Rm))),
4174 (INST2S V64:$Rn, V64:$Rm)>;
4177 defm : Neon_mul_widen_patterns<AArch64smull, SMULLv8i8_v8i16,
4178 SMULLv4i16_v4i32, SMULLv2i32_v2i64>;
4179 defm : Neon_mul_widen_patterns<AArch64umull, UMULLv8i8_v8i16,
4180 UMULLv4i16_v4i32, UMULLv2i32_v2i64>;
4182 // Additional patterns for SMLAL/SMLSL and UMLAL/UMLSL
4183 multiclass Neon_mulacc_widen_patterns<SDPatternOperator opnode,
4184 Instruction INST8B, Instruction INST4H, Instruction INST2S> {
4185 def : Pat<(v8i16 (opnode (v8i16 V128:$Rd), (v8i8 V64:$Rn), (v8i8 V64:$Rm))),
4186 (INST8B V128:$Rd, V64:$Rn, V64:$Rm)>;
4187 def : Pat<(v4i32 (opnode (v4i32 V128:$Rd), (v4i16 V64:$Rn), (v4i16 V64:$Rm))),
4188 (INST4H V128:$Rd, V64:$Rn, V64:$Rm)>;
4189 def : Pat<(v2i64 (opnode (v2i64 V128:$Rd), (v2i32 V64:$Rn), (v2i32 V64:$Rm))),
4190 (INST2S V128:$Rd, V64:$Rn, V64:$Rm)>;
4193 defm : Neon_mulacc_widen_patterns<
4194 TriOpFrag<(add node:$LHS, (AArch64smull node:$MHS, node:$RHS))>,
4195 SMLALv8i8_v8i16, SMLALv4i16_v4i32, SMLALv2i32_v2i64>;
4196 defm : Neon_mulacc_widen_patterns<
4197 TriOpFrag<(add node:$LHS, (AArch64umull node:$MHS, node:$RHS))>,
4198 UMLALv8i8_v8i16, UMLALv4i16_v4i32, UMLALv2i32_v2i64>;
4199 defm : Neon_mulacc_widen_patterns<
4200 TriOpFrag<(sub node:$LHS, (AArch64smull node:$MHS, node:$RHS))>,
4201 SMLSLv8i8_v8i16, SMLSLv4i16_v4i32, SMLSLv2i32_v2i64>;
4202 defm : Neon_mulacc_widen_patterns<
4203 TriOpFrag<(sub node:$LHS, (AArch64umull node:$MHS, node:$RHS))>,
4204 UMLSLv8i8_v8i16, UMLSLv4i16_v4i32, UMLSLv2i32_v2i64>;
4206 // Patterns for 64-bit pmull
4207 def : Pat<(int_aarch64_neon_pmull64 V64:$Rn, V64:$Rm),
4208 (PMULLv1i64 V64:$Rn, V64:$Rm)>;
4209 def : Pat<(int_aarch64_neon_pmull64 (extractelt (v2i64 V128:$Rn), (i64 1)),
4210 (extractelt (v2i64 V128:$Rm), (i64 1))),
4211 (PMULLv2i64 V128:$Rn, V128:$Rm)>;
4213 // CodeGen patterns for addhn and subhn instructions, which can actually be
4214 // written in LLVM IR without too much difficulty.
4217 def : Pat<(v8i8 (trunc (v8i16 (AArch64vlshr (add V128:$Rn, V128:$Rm), (i32 8))))),
4218 (ADDHNv8i16_v8i8 V128:$Rn, V128:$Rm)>;
4219 def : Pat<(v4i16 (trunc (v4i32 (AArch64vlshr (add V128:$Rn, V128:$Rm),
4221 (ADDHNv4i32_v4i16 V128:$Rn, V128:$Rm)>;
4222 def : Pat<(v2i32 (trunc (v2i64 (AArch64vlshr (add V128:$Rn, V128:$Rm),
4224 (ADDHNv2i64_v2i32 V128:$Rn, V128:$Rm)>;
4225 def : Pat<(concat_vectors (v8i8 V64:$Rd),
4226 (trunc (v8i16 (AArch64vlshr (add V128:$Rn, V128:$Rm),
4228 (ADDHNv8i16_v16i8 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4229 V128:$Rn, V128:$Rm)>;
4230 def : Pat<(concat_vectors (v4i16 V64:$Rd),
4231 (trunc (v4i32 (AArch64vlshr (add V128:$Rn, V128:$Rm),
4233 (ADDHNv4i32_v8i16 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4234 V128:$Rn, V128:$Rm)>;
4235 def : Pat<(concat_vectors (v2i32 V64:$Rd),
4236 (trunc (v2i64 (AArch64vlshr (add V128:$Rn, V128:$Rm),
4238 (ADDHNv2i64_v4i32 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4239 V128:$Rn, V128:$Rm)>;
4242 def : Pat<(v8i8 (trunc (v8i16 (AArch64vlshr (sub V128:$Rn, V128:$Rm), (i32 8))))),
4243 (SUBHNv8i16_v8i8 V128:$Rn, V128:$Rm)>;
4244 def : Pat<(v4i16 (trunc (v4i32 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
4246 (SUBHNv4i32_v4i16 V128:$Rn, V128:$Rm)>;
4247 def : Pat<(v2i32 (trunc (v2i64 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
4249 (SUBHNv2i64_v2i32 V128:$Rn, V128:$Rm)>;
4250 def : Pat<(concat_vectors (v8i8 V64:$Rd),
4251 (trunc (v8i16 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
4253 (SUBHNv8i16_v16i8 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4254 V128:$Rn, V128:$Rm)>;
4255 def : Pat<(concat_vectors (v4i16 V64:$Rd),
4256 (trunc (v4i32 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
4258 (SUBHNv4i32_v8i16 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4259 V128:$Rn, V128:$Rm)>;
4260 def : Pat<(concat_vectors (v2i32 V64:$Rd),
4261 (trunc (v2i64 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
4263 (SUBHNv2i64_v4i32 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
4264 V128:$Rn, V128:$Rm)>;
4266 //----------------------------------------------------------------------------
4267 // AdvSIMD bitwise extract from vector instruction.
4268 //----------------------------------------------------------------------------
4270 defm EXT : SIMDBitwiseExtract<"ext">;
4272 def AdjustExtImm : SDNodeXForm<imm, [{
4273 return CurDAG->getTargetConstant(8 + N->getZExtValue(), SDLoc(N), MVT::i32);
4275 multiclass ExtPat<ValueType VT64, ValueType VT128, int N> {
4276 def : Pat<(VT64 (AArch64ext V64:$Rn, V64:$Rm, (i32 imm:$imm))),
4277 (EXTv8i8 V64:$Rn, V64:$Rm, imm:$imm)>;
4278 def : Pat<(VT128 (AArch64ext V128:$Rn, V128:$Rm, (i32 imm:$imm))),
4279 (EXTv16i8 V128:$Rn, V128:$Rm, imm:$imm)>;
4280 // We use EXT to handle extract_subvector to copy the upper 64-bits of a
4282 def : Pat<(VT64 (extract_subvector V128:$Rn, (i64 N))),
4283 (EXTRACT_SUBREG (EXTv16i8 V128:$Rn, V128:$Rn, 8), dsub)>;
4284 // A 64-bit EXT of two halves of the same 128-bit register can be done as a
4285 // single 128-bit EXT.
4286 def : Pat<(VT64 (AArch64ext (extract_subvector V128:$Rn, (i64 0)),
4287 (extract_subvector V128:$Rn, (i64 N)),
4289 (EXTRACT_SUBREG (EXTv16i8 V128:$Rn, V128:$Rn, imm:$imm), dsub)>;
4290 // A 64-bit EXT of the high half of a 128-bit register can be done using a
4291 // 128-bit EXT of the whole register with an adjustment to the immediate. The
4292 // top half of the other operand will be unset, but that doesn't matter as it
4293 // will not be used.
4294 def : Pat<(VT64 (AArch64ext (extract_subvector V128:$Rn, (i64 N)),
4297 (EXTRACT_SUBREG (EXTv16i8 V128:$Rn,
4298 (SUBREG_TO_REG (i32 0), V64:$Rm, dsub),
4299 (AdjustExtImm imm:$imm)), dsub)>;
4302 defm : ExtPat<v8i8, v16i8, 8>;
4303 defm : ExtPat<v4i16, v8i16, 4>;
4304 defm : ExtPat<v4f16, v8f16, 4>;
4305 defm : ExtPat<v2i32, v4i32, 2>;
4306 defm : ExtPat<v2f32, v4f32, 2>;
4307 defm : ExtPat<v1i64, v2i64, 1>;
4308 defm : ExtPat<v1f64, v2f64, 1>;
4310 //----------------------------------------------------------------------------
4311 // AdvSIMD zip vector
4312 //----------------------------------------------------------------------------
4314 defm TRN1 : SIMDZipVector<0b010, "trn1", AArch64trn1>;
4315 defm TRN2 : SIMDZipVector<0b110, "trn2", AArch64trn2>;
4316 defm UZP1 : SIMDZipVector<0b001, "uzp1", AArch64uzp1>;
4317 defm UZP2 : SIMDZipVector<0b101, "uzp2", AArch64uzp2>;
4318 defm ZIP1 : SIMDZipVector<0b011, "zip1", AArch64zip1>;
4319 defm ZIP2 : SIMDZipVector<0b111, "zip2", AArch64zip2>;
4321 //----------------------------------------------------------------------------
4322 // AdvSIMD TBL/TBX instructions
4323 //----------------------------------------------------------------------------
4325 defm TBL : SIMDTableLookup< 0, "tbl">;
4326 defm TBX : SIMDTableLookupTied<1, "tbx">;
4328 def : Pat<(v8i8 (int_aarch64_neon_tbl1 (v16i8 VecListOne128:$Rn), (v8i8 V64:$Ri))),
4329 (TBLv8i8One VecListOne128:$Rn, V64:$Ri)>;
4330 def : Pat<(v16i8 (int_aarch64_neon_tbl1 (v16i8 V128:$Ri), (v16i8 V128:$Rn))),
4331 (TBLv16i8One V128:$Ri, V128:$Rn)>;
4333 def : Pat<(v8i8 (int_aarch64_neon_tbx1 (v8i8 V64:$Rd),
4334 (v16i8 VecListOne128:$Rn), (v8i8 V64:$Ri))),
4335 (TBXv8i8One V64:$Rd, VecListOne128:$Rn, V64:$Ri)>;
4336 def : Pat<(v16i8 (int_aarch64_neon_tbx1 (v16i8 V128:$Rd),
4337 (v16i8 V128:$Ri), (v16i8 V128:$Rn))),
4338 (TBXv16i8One V128:$Rd, V128:$Ri, V128:$Rn)>;
4341 //----------------------------------------------------------------------------
4342 // AdvSIMD scalar CPY instruction
4343 //----------------------------------------------------------------------------
4345 defm CPY : SIMDScalarCPY<"cpy">;
4347 //----------------------------------------------------------------------------
4348 // AdvSIMD scalar pairwise instructions
4349 //----------------------------------------------------------------------------
4351 defm ADDP : SIMDPairwiseScalarD<0, 0b11011, "addp">;
4352 defm FADDP : SIMDFPPairwiseScalar<0, 0b01101, "faddp">;
4353 defm FMAXNMP : SIMDFPPairwiseScalar<0, 0b01100, "fmaxnmp">;
4354 defm FMAXP : SIMDFPPairwiseScalar<0, 0b01111, "fmaxp">;
4355 defm FMINNMP : SIMDFPPairwiseScalar<1, 0b01100, "fminnmp">;
4356 defm FMINP : SIMDFPPairwiseScalar<1, 0b01111, "fminp">;
4357 def : Pat<(v2i64 (AArch64saddv V128:$Rn)),
4358 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)), (ADDPv2i64p V128:$Rn), dsub)>;
4359 def : Pat<(v2i64 (AArch64uaddv V128:$Rn)),
4360 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)), (ADDPv2i64p V128:$Rn), dsub)>;
4361 def : Pat<(f32 (int_aarch64_neon_faddv (v2f32 V64:$Rn))),
4362 (FADDPv2i32p V64:$Rn)>;
4363 def : Pat<(f32 (int_aarch64_neon_faddv (v4f32 V128:$Rn))),
4364 (FADDPv2i32p (EXTRACT_SUBREG (FADDPv4f32 V128:$Rn, V128:$Rn), dsub))>;
4365 def : Pat<(f64 (int_aarch64_neon_faddv (v2f64 V128:$Rn))),
4366 (FADDPv2i64p V128:$Rn)>;
4367 def : Pat<(f32 (int_aarch64_neon_fmaxnmv (v2f32 V64:$Rn))),
4368 (FMAXNMPv2i32p V64:$Rn)>;
4369 def : Pat<(f64 (int_aarch64_neon_fmaxnmv (v2f64 V128:$Rn))),
4370 (FMAXNMPv2i64p V128:$Rn)>;
4371 def : Pat<(f32 (int_aarch64_neon_fmaxv (v2f32 V64:$Rn))),
4372 (FMAXPv2i32p V64:$Rn)>;
4373 def : Pat<(f64 (int_aarch64_neon_fmaxv (v2f64 V128:$Rn))),
4374 (FMAXPv2i64p V128:$Rn)>;
4375 def : Pat<(f32 (int_aarch64_neon_fminnmv (v2f32 V64:$Rn))),
4376 (FMINNMPv2i32p V64:$Rn)>;
4377 def : Pat<(f64 (int_aarch64_neon_fminnmv (v2f64 V128:$Rn))),
4378 (FMINNMPv2i64p V128:$Rn)>;
4379 def : Pat<(f32 (int_aarch64_neon_fminv (v2f32 V64:$Rn))),
4380 (FMINPv2i32p V64:$Rn)>;
4381 def : Pat<(f64 (int_aarch64_neon_fminv (v2f64 V128:$Rn))),
4382 (FMINPv2i64p V128:$Rn)>;
4384 //----------------------------------------------------------------------------
4385 // AdvSIMD INS/DUP instructions
4386 //----------------------------------------------------------------------------
4388 def DUPv8i8gpr : SIMDDupFromMain<0, {?,?,?,?,1}, ".8b", v8i8, V64, GPR32>;
4389 def DUPv16i8gpr : SIMDDupFromMain<1, {?,?,?,?,1}, ".16b", v16i8, V128, GPR32>;
4390 def DUPv4i16gpr : SIMDDupFromMain<0, {?,?,?,1,0}, ".4h", v4i16, V64, GPR32>;
4391 def DUPv8i16gpr : SIMDDupFromMain<1, {?,?,?,1,0}, ".8h", v8i16, V128, GPR32>;
4392 def DUPv2i32gpr : SIMDDupFromMain<0, {?,?,1,0,0}, ".2s", v2i32, V64, GPR32>;
4393 def DUPv4i32gpr : SIMDDupFromMain<1, {?,?,1,0,0}, ".4s", v4i32, V128, GPR32>;
4394 def DUPv2i64gpr : SIMDDupFromMain<1, {?,1,0,0,0}, ".2d", v2i64, V128, GPR64>;
4396 def DUPv2i64lane : SIMDDup64FromElement;
4397 def DUPv2i32lane : SIMDDup32FromElement<0, ".2s", v2i32, V64>;
4398 def DUPv4i32lane : SIMDDup32FromElement<1, ".4s", v4i32, V128>;
4399 def DUPv4i16lane : SIMDDup16FromElement<0, ".4h", v4i16, V64>;
4400 def DUPv8i16lane : SIMDDup16FromElement<1, ".8h", v8i16, V128>;
4401 def DUPv8i8lane : SIMDDup8FromElement <0, ".8b", v8i8, V64>;
4402 def DUPv16i8lane : SIMDDup8FromElement <1, ".16b", v16i8, V128>;
4404 // DUP from a 64-bit register to a 64-bit register is just a copy
4405 def : Pat<(v1i64 (AArch64dup (i64 GPR64:$Rn))),
4406 (COPY_TO_REGCLASS GPR64:$Rn, FPR64)>;
4407 def : Pat<(v1f64 (AArch64dup (f64 FPR64:$Rn))),
4408 (COPY_TO_REGCLASS FPR64:$Rn, FPR64)>;
4410 def : Pat<(v2f32 (AArch64dup (f32 FPR32:$Rn))),
4411 (v2f32 (DUPv2i32lane
4412 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR32:$Rn, ssub),
4414 def : Pat<(v4f32 (AArch64dup (f32 FPR32:$Rn))),
4415 (v4f32 (DUPv4i32lane
4416 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR32:$Rn, ssub),
4418 def : Pat<(v2f64 (AArch64dup (f64 FPR64:$Rn))),
4419 (v2f64 (DUPv2i64lane
4420 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR64:$Rn, dsub),
4422 def : Pat<(v4f16 (AArch64dup (f16 FPR16:$Rn))),
4423 (v4f16 (DUPv4i16lane
4424 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)), FPR16:$Rn, hsub),
4426 def : Pat<(v8f16 (AArch64dup (f16 FPR16:$Rn))),
4427 (v8f16 (DUPv8i16lane
4428 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)), FPR16:$Rn, hsub),
4431 def : Pat<(v4f16 (AArch64duplane16 (v8f16 V128:$Rn), VectorIndexH:$imm)),
4432 (DUPv4i16lane V128:$Rn, VectorIndexH:$imm)>;
4433 def : Pat<(v8f16 (AArch64duplane16 (v8f16 V128:$Rn), VectorIndexH:$imm)),
4434 (DUPv8i16lane V128:$Rn, VectorIndexH:$imm)>;
4436 def : Pat<(v2f32 (AArch64duplane32 (v4f32 V128:$Rn), VectorIndexS:$imm)),
4437 (DUPv2i32lane V128:$Rn, VectorIndexS:$imm)>;
4438 def : Pat<(v4f32 (AArch64duplane32 (v4f32 V128:$Rn), VectorIndexS:$imm)),
4439 (DUPv4i32lane V128:$Rn, VectorIndexS:$imm)>;
4440 def : Pat<(v2f64 (AArch64duplane64 (v2f64 V128:$Rn), VectorIndexD:$imm)),
4441 (DUPv2i64lane V128:$Rn, VectorIndexD:$imm)>;
4443 // If there's an (AArch64dup (vector_extract ...) ...), we can use a duplane
4444 // instruction even if the types don't match: we just have to remap the lane
4445 // carefully. N.b. this trick only applies to truncations.
4446 def VecIndex_x2 : SDNodeXForm<imm, [{
4447 return CurDAG->getTargetConstant(2 * N->getZExtValue(), SDLoc(N), MVT::i64);
4449 def VecIndex_x4 : SDNodeXForm<imm, [{
4450 return CurDAG->getTargetConstant(4 * N->getZExtValue(), SDLoc(N), MVT::i64);
4452 def VecIndex_x8 : SDNodeXForm<imm, [{
4453 return CurDAG->getTargetConstant(8 * N->getZExtValue(), SDLoc(N), MVT::i64);
4456 multiclass DUPWithTruncPats<ValueType ResVT, ValueType Src64VT,
4457 ValueType Src128VT, ValueType ScalVT,
4458 Instruction DUP, SDNodeXForm IdxXFORM> {
4459 def : Pat<(ResVT (AArch64dup (ScalVT (vector_extract (Src128VT V128:$Rn),
4461 (DUP V128:$Rn, (IdxXFORM imm:$idx))>;
4463 def : Pat<(ResVT (AArch64dup (ScalVT (vector_extract (Src64VT V64:$Rn),
4465 (DUP (SUBREG_TO_REG (i64 0), V64:$Rn, dsub), (IdxXFORM imm:$idx))>;
4468 defm : DUPWithTruncPats<v8i8, v4i16, v8i16, i32, DUPv8i8lane, VecIndex_x2>;
4469 defm : DUPWithTruncPats<v8i8, v2i32, v4i32, i32, DUPv8i8lane, VecIndex_x4>;
4470 defm : DUPWithTruncPats<v4i16, v2i32, v4i32, i32, DUPv4i16lane, VecIndex_x2>;
4472 defm : DUPWithTruncPats<v16i8, v4i16, v8i16, i32, DUPv16i8lane, VecIndex_x2>;
4473 defm : DUPWithTruncPats<v16i8, v2i32, v4i32, i32, DUPv16i8lane, VecIndex_x4>;
4474 defm : DUPWithTruncPats<v8i16, v2i32, v4i32, i32, DUPv8i16lane, VecIndex_x2>;
4476 multiclass DUPWithTrunci64Pats<ValueType ResVT, Instruction DUP,
4477 SDNodeXForm IdxXFORM> {
4478 def : Pat<(ResVT (AArch64dup (i32 (trunc (extractelt (v2i64 V128:$Rn),
4480 (DUP V128:$Rn, (IdxXFORM imm:$idx))>;
4482 def : Pat<(ResVT (AArch64dup (i32 (trunc (extractelt (v1i64 V64:$Rn),
4484 (DUP (SUBREG_TO_REG (i64 0), V64:$Rn, dsub), (IdxXFORM imm:$idx))>;
4487 defm : DUPWithTrunci64Pats<v8i8, DUPv8i8lane, VecIndex_x8>;
4488 defm : DUPWithTrunci64Pats<v4i16, DUPv4i16lane, VecIndex_x4>;
4489 defm : DUPWithTrunci64Pats<v2i32, DUPv2i32lane, VecIndex_x2>;
4491 defm : DUPWithTrunci64Pats<v16i8, DUPv16i8lane, VecIndex_x8>;
4492 defm : DUPWithTrunci64Pats<v8i16, DUPv8i16lane, VecIndex_x4>;
4493 defm : DUPWithTrunci64Pats<v4i32, DUPv4i32lane, VecIndex_x2>;
4495 // SMOV and UMOV definitions, with some extra patterns for convenience
4499 def : Pat<(sext_inreg (vector_extract (v16i8 V128:$Rn), VectorIndexB:$idx), i8),
4500 (i32 (SMOVvi8to32 V128:$Rn, VectorIndexB:$idx))>;
4501 def : Pat<(sext_inreg (vector_extract (v16i8 V128:$Rn), VectorIndexB:$idx), i8),
4502 (i64 (SMOVvi8to64 V128:$Rn, VectorIndexB:$idx))>;
4503 def : Pat<(sext_inreg (vector_extract (v8i16 V128:$Rn), VectorIndexH:$idx),i16),
4504 (i32 (SMOVvi16to32 V128:$Rn, VectorIndexH:$idx))>;
4505 def : Pat<(sext_inreg (vector_extract (v8i16 V128:$Rn), VectorIndexH:$idx),i16),
4506 (i64 (SMOVvi16to64 V128:$Rn, VectorIndexH:$idx))>;
4507 def : Pat<(sext_inreg (vector_extract (v8i16 V128:$Rn), VectorIndexH:$idx),i16),
4508 (i32 (SMOVvi16to32 V128:$Rn, VectorIndexH:$idx))>;
4509 def : Pat<(sext (i32 (vector_extract (v4i32 V128:$Rn), VectorIndexS:$idx))),
4510 (i64 (SMOVvi32to64 V128:$Rn, VectorIndexS:$idx))>;
4512 def : Pat<(sext_inreg (i64 (anyext (i32 (vector_extract (v16i8 V128:$Rn),
4513 VectorIndexB:$idx)))), i8),
4514 (i64 (SMOVvi8to64 V128:$Rn, VectorIndexB:$idx))>;
4515 def : Pat<(sext_inreg (i64 (anyext (i32 (vector_extract (v8i16 V128:$Rn),
4516 VectorIndexH:$idx)))), i16),
4517 (i64 (SMOVvi16to64 V128:$Rn, VectorIndexH:$idx))>;
4519 // Extracting i8 or i16 elements will have the zero-extend transformed to
4520 // an 'and' mask by type legalization since neither i8 nor i16 are legal types
4521 // for AArch64. Match these patterns here since UMOV already zeroes out the high
4522 // bits of the destination register.
4523 def : Pat<(and (vector_extract (v16i8 V128:$Rn), VectorIndexB:$idx),
4525 (i32 (UMOVvi8 V128:$Rn, VectorIndexB:$idx))>;
4526 def : Pat<(and (vector_extract (v8i16 V128:$Rn), VectorIndexH:$idx),
4528 (i32 (UMOVvi16 V128:$Rn, VectorIndexH:$idx))>;
4532 def : Pat<(v16i8 (scalar_to_vector GPR32:$Rn)),
4533 (SUBREG_TO_REG (i32 0),
4534 (f32 (COPY_TO_REGCLASS GPR32:$Rn, FPR32)), ssub)>;
4535 def : Pat<(v8i8 (scalar_to_vector GPR32:$Rn)),
4536 (SUBREG_TO_REG (i32 0),
4537 (f32 (COPY_TO_REGCLASS GPR32:$Rn, FPR32)), ssub)>;
4539 def : Pat<(v8i16 (scalar_to_vector GPR32:$Rn)),
4540 (SUBREG_TO_REG (i32 0),
4541 (f32 (COPY_TO_REGCLASS GPR32:$Rn, FPR32)), ssub)>;
4542 def : Pat<(v4i16 (scalar_to_vector GPR32:$Rn)),
4543 (SUBREG_TO_REG (i32 0),
4544 (f32 (COPY_TO_REGCLASS GPR32:$Rn, FPR32)), ssub)>;
4546 def : Pat<(v4f16 (scalar_to_vector (f16 FPR16:$Rn))),
4547 (INSERT_SUBREG (v4f16 (IMPLICIT_DEF)), FPR16:$Rn, hsub)>;
4548 def : Pat<(v8f16 (scalar_to_vector (f16 FPR16:$Rn))),
4549 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR16:$Rn, hsub)>;
4551 def : Pat<(v2i32 (scalar_to_vector (i32 FPR32:$Rn))),
4552 (v2i32 (INSERT_SUBREG (v2i32 (IMPLICIT_DEF)),
4553 (i32 FPR32:$Rn), ssub))>;
4554 def : Pat<(v4i32 (scalar_to_vector (i32 FPR32:$Rn))),
4555 (v4i32 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)),
4556 (i32 FPR32:$Rn), ssub))>;
4558 def : Pat<(v2i64 (scalar_to_vector (i64 FPR64:$Rn))),
4559 (v2i64 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)),
4560 (i64 FPR64:$Rn), dsub))>;
4562 def : Pat<(v4f16 (scalar_to_vector (f16 FPR16:$Rn))),
4563 (INSERT_SUBREG (v4f16 (IMPLICIT_DEF)), FPR16:$Rn, hsub)>;
4564 def : Pat<(v8f16 (scalar_to_vector (f16 FPR16:$Rn))),
4565 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR16:$Rn, hsub)>;
4567 def : Pat<(v4f32 (scalar_to_vector (f32 FPR32:$Rn))),
4568 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FPR32:$Rn, ssub)>;
4569 def : Pat<(v2f32 (scalar_to_vector (f32 FPR32:$Rn))),
4570 (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), FPR32:$Rn, ssub)>;
4572 def : Pat<(v2f64 (scalar_to_vector (f64 FPR64:$Rn))),
4573 (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), FPR64:$Rn, dsub)>;
4575 def : Pat<(v4f16 (vector_insert (v4f16 V64:$Rn),
4576 (f16 FPR16:$Rm), (i64 VectorIndexS:$imm))),
4579 (v8f16 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), V64:$Rn, dsub)),
4581 (v8f16 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR16:$Rm, hsub)),
4585 def : Pat<(v8f16 (vector_insert (v8f16 V128:$Rn),
4586 (f16 FPR16:$Rm), (i64 VectorIndexH:$imm))),
4588 V128:$Rn, VectorIndexH:$imm,
4589 (v8f16 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR16:$Rm, hsub)),
4592 def : Pat<(v2f32 (vector_insert (v2f32 V64:$Rn),
4593 (f32 FPR32:$Rm), (i64 VectorIndexS:$imm))),
4596 (v4f32 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), V64:$Rn, dsub)),
4598 (v4f32 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FPR32:$Rm, ssub)),
4601 def : Pat<(v4f32 (vector_insert (v4f32 V128:$Rn),
4602 (f32 FPR32:$Rm), (i64 VectorIndexS:$imm))),
4604 V128:$Rn, VectorIndexS:$imm,
4605 (v4f32 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FPR32:$Rm, ssub)),
4607 def : Pat<(v2f64 (vector_insert (v2f64 V128:$Rn),
4608 (f64 FPR64:$Rm), (i64 VectorIndexD:$imm))),
4610 V128:$Rn, VectorIndexD:$imm,
4611 (v2f64 (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), FPR64:$Rm, dsub)),
4614 // Copy an element at a constant index in one vector into a constant indexed
4615 // element of another.
4616 // FIXME refactor to a shared class/dev parameterized on vector type, vector
4617 // index type and INS extension
4618 def : Pat<(v16i8 (int_aarch64_neon_vcopy_lane
4619 (v16i8 V128:$Vd), VectorIndexB:$idx, (v16i8 V128:$Vs),
4620 VectorIndexB:$idx2)),
4622 V128:$Vd, VectorIndexB:$idx, V128:$Vs, VectorIndexB:$idx2)
4624 def : Pat<(v8i16 (int_aarch64_neon_vcopy_lane
4625 (v8i16 V128:$Vd), VectorIndexH:$idx, (v8i16 V128:$Vs),
4626 VectorIndexH:$idx2)),
4628 V128:$Vd, VectorIndexH:$idx, V128:$Vs, VectorIndexH:$idx2)
4630 def : Pat<(v4i32 (int_aarch64_neon_vcopy_lane
4631 (v4i32 V128:$Vd), VectorIndexS:$idx, (v4i32 V128:$Vs),
4632 VectorIndexS:$idx2)),
4634 V128:$Vd, VectorIndexS:$idx, V128:$Vs, VectorIndexS:$idx2)
4636 def : Pat<(v2i64 (int_aarch64_neon_vcopy_lane
4637 (v2i64 V128:$Vd), VectorIndexD:$idx, (v2i64 V128:$Vs),
4638 VectorIndexD:$idx2)),
4640 V128:$Vd, VectorIndexD:$idx, V128:$Vs, VectorIndexD:$idx2)
4643 multiclass Neon_INS_elt_pattern<ValueType VT128, ValueType VT64,
4644 ValueType VTScal, Instruction INS> {
4645 def : Pat<(VT128 (vector_insert V128:$src,
4646 (VTScal (vector_extract (VT128 V128:$Rn), imm:$Immn)),
4648 (INS V128:$src, imm:$Immd, V128:$Rn, imm:$Immn)>;
4650 def : Pat<(VT128 (vector_insert V128:$src,
4651 (VTScal (vector_extract (VT64 V64:$Rn), imm:$Immn)),
4653 (INS V128:$src, imm:$Immd,
4654 (SUBREG_TO_REG (i64 0), V64:$Rn, dsub), imm:$Immn)>;
4656 def : Pat<(VT64 (vector_insert V64:$src,
4657 (VTScal (vector_extract (VT128 V128:$Rn), imm:$Immn)),
4659 (EXTRACT_SUBREG (INS (SUBREG_TO_REG (i64 0), V64:$src, dsub),
4660 imm:$Immd, V128:$Rn, imm:$Immn),
4663 def : Pat<(VT64 (vector_insert V64:$src,
4664 (VTScal (vector_extract (VT64 V64:$Rn), imm:$Immn)),
4667 (INS (SUBREG_TO_REG (i64 0), V64:$src, dsub), imm:$Immd,
4668 (SUBREG_TO_REG (i64 0), V64:$Rn, dsub), imm:$Immn),
4672 defm : Neon_INS_elt_pattern<v8f16, v4f16, f16, INSvi16lane>;
4673 defm : Neon_INS_elt_pattern<v4f32, v2f32, f32, INSvi32lane>;
4674 defm : Neon_INS_elt_pattern<v2f64, v1f64, f64, INSvi64lane>;
4677 // Floating point vector extractions are codegen'd as either a sequence of
4678 // subregister extractions, or a MOV (aka CPY here, alias for DUP) if
4679 // the lane number is anything other than zero.
4680 def : Pat<(vector_extract (v2f64 V128:$Rn), 0),
4681 (f64 (EXTRACT_SUBREG V128:$Rn, dsub))>;
4682 def : Pat<(vector_extract (v4f32 V128:$Rn), 0),
4683 (f32 (EXTRACT_SUBREG V128:$Rn, ssub))>;
4684 def : Pat<(vector_extract (v8f16 V128:$Rn), 0),
4685 (f16 (EXTRACT_SUBREG V128:$Rn, hsub))>;
4687 def : Pat<(vector_extract (v2f64 V128:$Rn), VectorIndexD:$idx),
4688 (f64 (CPYi64 V128:$Rn, VectorIndexD:$idx))>;
4689 def : Pat<(vector_extract (v4f32 V128:$Rn), VectorIndexS:$idx),
4690 (f32 (CPYi32 V128:$Rn, VectorIndexS:$idx))>;
4691 def : Pat<(vector_extract (v8f16 V128:$Rn), VectorIndexH:$idx),
4692 (f16 (CPYi16 V128:$Rn, VectorIndexH:$idx))>;
4694 // All concat_vectors operations are canonicalised to act on i64 vectors for
4695 // AArch64. In the general case we need an instruction, which had just as well be
4697 class ConcatPat<ValueType DstTy, ValueType SrcTy>
4698 : Pat<(DstTy (concat_vectors (SrcTy V64:$Rd), V64:$Rn)),
4699 (INSvi64lane (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), 1,
4700 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rn, dsub), 0)>;
4702 def : ConcatPat<v2i64, v1i64>;
4703 def : ConcatPat<v2f64, v1f64>;
4704 def : ConcatPat<v4i32, v2i32>;
4705 def : ConcatPat<v4f32, v2f32>;
4706 def : ConcatPat<v8i16, v4i16>;
4707 def : ConcatPat<v8f16, v4f16>;
4708 def : ConcatPat<v16i8, v8i8>;
4710 // If the high lanes are undef, though, we can just ignore them:
4711 class ConcatUndefPat<ValueType DstTy, ValueType SrcTy>
4712 : Pat<(DstTy (concat_vectors (SrcTy V64:$Rn), undef)),
4713 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rn, dsub)>;
4715 def : ConcatUndefPat<v2i64, v1i64>;
4716 def : ConcatUndefPat<v2f64, v1f64>;
4717 def : ConcatUndefPat<v4i32, v2i32>;
4718 def : ConcatUndefPat<v4f32, v2f32>;
4719 def : ConcatUndefPat<v8i16, v4i16>;
4720 def : ConcatUndefPat<v16i8, v8i8>;
4722 //----------------------------------------------------------------------------
4723 // AdvSIMD across lanes instructions
4724 //----------------------------------------------------------------------------
4726 defm ADDV : SIMDAcrossLanesBHS<0, 0b11011, "addv">;
4727 defm SMAXV : SIMDAcrossLanesBHS<0, 0b01010, "smaxv">;
4728 defm SMINV : SIMDAcrossLanesBHS<0, 0b11010, "sminv">;
4729 defm UMAXV : SIMDAcrossLanesBHS<1, 0b01010, "umaxv">;
4730 defm UMINV : SIMDAcrossLanesBHS<1, 0b11010, "uminv">;
4731 defm SADDLV : SIMDAcrossLanesHSD<0, 0b00011, "saddlv">;
4732 defm UADDLV : SIMDAcrossLanesHSD<1, 0b00011, "uaddlv">;
4733 defm FMAXNMV : SIMDFPAcrossLanes<0b01100, 0, "fmaxnmv", int_aarch64_neon_fmaxnmv>;
4734 defm FMAXV : SIMDFPAcrossLanes<0b01111, 0, "fmaxv", int_aarch64_neon_fmaxv>;
4735 defm FMINNMV : SIMDFPAcrossLanes<0b01100, 1, "fminnmv", int_aarch64_neon_fminnmv>;
4736 defm FMINV : SIMDFPAcrossLanes<0b01111, 1, "fminv", int_aarch64_neon_fminv>;
4738 // Patterns for across-vector intrinsics, that have a node equivalent, that
4739 // returns a vector (with only the low lane defined) instead of a scalar.
4740 // In effect, opNode is the same as (scalar_to_vector (IntNode)).
4741 multiclass SIMDAcrossLanesIntrinsic<string baseOpc,
4742 SDPatternOperator opNode> {
4743 // If a lane instruction caught the vector_extract around opNode, we can
4744 // directly match the latter to the instruction.
4745 def : Pat<(v8i8 (opNode V64:$Rn)),
4746 (INSERT_SUBREG (v8i8 (IMPLICIT_DEF)),
4747 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), bsub)>;
4748 def : Pat<(v16i8 (opNode V128:$Rn)),
4749 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4750 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), bsub)>;
4751 def : Pat<(v4i16 (opNode V64:$Rn)),
4752 (INSERT_SUBREG (v4i16 (IMPLICIT_DEF)),
4753 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), hsub)>;
4754 def : Pat<(v8i16 (opNode V128:$Rn)),
4755 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)),
4756 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), hsub)>;
4757 def : Pat<(v4i32 (opNode V128:$Rn)),
4758 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)),
4759 (!cast<Instruction>(!strconcat(baseOpc, "v4i32v")) V128:$Rn), ssub)>;
4762 // If none did, fallback to the explicit patterns, consuming the vector_extract.
4763 def : Pat<(i32 (vector_extract (insert_subvector undef, (v8i8 (opNode V64:$Rn)),
4764 (i32 0)), (i64 0))),
4765 (EXTRACT_SUBREG (INSERT_SUBREG (v8i8 (IMPLICIT_DEF)),
4766 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn),
4768 def : Pat<(i32 (vector_extract (v16i8 (opNode V128:$Rn)), (i64 0))),
4769 (EXTRACT_SUBREG (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4770 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn),
4772 def : Pat<(i32 (vector_extract (insert_subvector undef,
4773 (v4i16 (opNode V64:$Rn)), (i32 0)), (i64 0))),
4774 (EXTRACT_SUBREG (INSERT_SUBREG (v4i16 (IMPLICIT_DEF)),
4775 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn),
4777 def : Pat<(i32 (vector_extract (v8i16 (opNode V128:$Rn)), (i64 0))),
4778 (EXTRACT_SUBREG (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)),
4779 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn),
4781 def : Pat<(i32 (vector_extract (v4i32 (opNode V128:$Rn)), (i64 0))),
4782 (EXTRACT_SUBREG (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)),
4783 (!cast<Instruction>(!strconcat(baseOpc, "v4i32v")) V128:$Rn),
4788 multiclass SIMDAcrossLanesSignedIntrinsic<string baseOpc,
4789 SDPatternOperator opNode>
4790 : SIMDAcrossLanesIntrinsic<baseOpc, opNode> {
4791 // If there is a sign extension after this intrinsic, consume it as smov already
4793 def : Pat<(i32 (sext_inreg (i32 (vector_extract (insert_subvector undef,
4794 (opNode (v8i8 V64:$Rn)), (i32 0)), (i64 0))), i8)),
4796 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4797 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), bsub),
4799 def : Pat<(i32 (sext_inreg (i32 (vector_extract
4800 (opNode (v16i8 V128:$Rn)), (i64 0))), i8)),
4802 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4803 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), bsub),
4805 def : Pat<(i32 (sext_inreg (i32 (vector_extract (insert_subvector undef,
4806 (opNode (v4i16 V64:$Rn)), (i32 0)), (i64 0))), i16)),
4808 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4809 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), hsub),
4811 def : Pat<(i32 (sext_inreg (i32 (vector_extract
4812 (opNode (v8i16 V128:$Rn)), (i64 0))), i16)),
4814 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4815 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), hsub),
4819 multiclass SIMDAcrossLanesUnsignedIntrinsic<string baseOpc,
4820 SDPatternOperator opNode>
4821 : SIMDAcrossLanesIntrinsic<baseOpc, opNode> {
4822 // If there is a masking operation keeping only what has been actually
4823 // generated, consume it.
4824 def : Pat<(i32 (and (i32 (vector_extract (insert_subvector undef,
4825 (opNode (v8i8 V64:$Rn)), (i32 0)), (i64 0))), maski8_or_more)),
4826 (i32 (EXTRACT_SUBREG
4827 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4828 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), bsub),
4830 def : Pat<(i32 (and (i32 (vector_extract (opNode (v16i8 V128:$Rn)), (i64 0))),
4832 (i32 (EXTRACT_SUBREG
4833 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4834 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), bsub),
4836 def : Pat<(i32 (and (i32 (vector_extract (insert_subvector undef,
4837 (opNode (v4i16 V64:$Rn)), (i32 0)), (i64 0))), maski16_or_more)),
4838 (i32 (EXTRACT_SUBREG
4839 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4840 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), hsub),
4842 def : Pat<(i32 (and (i32 (vector_extract (opNode (v8i16 V128:$Rn)), (i64 0))),
4844 (i32 (EXTRACT_SUBREG
4845 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4846 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), hsub),
4850 defm : SIMDAcrossLanesSignedIntrinsic<"ADDV", AArch64saddv>;
4851 // vaddv_[su]32 is special; -> ADDP Vd.2S,Vn.2S,Vm.2S; return Vd.s[0];Vn==Vm
4852 def : Pat<(v2i32 (AArch64saddv (v2i32 V64:$Rn))),
4853 (ADDPv2i32 V64:$Rn, V64:$Rn)>;
4855 defm : SIMDAcrossLanesUnsignedIntrinsic<"ADDV", AArch64uaddv>;
4856 // vaddv_[su]32 is special; -> ADDP Vd.2S,Vn.2S,Vm.2S; return Vd.s[0];Vn==Vm
4857 def : Pat<(v2i32 (AArch64uaddv (v2i32 V64:$Rn))),
4858 (ADDPv2i32 V64:$Rn, V64:$Rn)>;
4860 defm : SIMDAcrossLanesSignedIntrinsic<"SMAXV", AArch64smaxv>;
4861 def : Pat<(v2i32 (AArch64smaxv (v2i32 V64:$Rn))),
4862 (SMAXPv2i32 V64:$Rn, V64:$Rn)>;
4864 defm : SIMDAcrossLanesSignedIntrinsic<"SMINV", AArch64sminv>;
4865 def : Pat<(v2i32 (AArch64sminv (v2i32 V64:$Rn))),
4866 (SMINPv2i32 V64:$Rn, V64:$Rn)>;
4868 defm : SIMDAcrossLanesUnsignedIntrinsic<"UMAXV", AArch64umaxv>;
4869 def : Pat<(v2i32 (AArch64umaxv (v2i32 V64:$Rn))),
4870 (UMAXPv2i32 V64:$Rn, V64:$Rn)>;
4872 defm : SIMDAcrossLanesUnsignedIntrinsic<"UMINV", AArch64uminv>;
4873 def : Pat<(v2i32 (AArch64uminv (v2i32 V64:$Rn))),
4874 (UMINPv2i32 V64:$Rn, V64:$Rn)>;
4876 multiclass SIMDAcrossLanesSignedLongIntrinsic<string baseOpc, Intrinsic intOp> {
4877 def : Pat<(i32 (intOp (v8i8 V64:$Rn))),
4879 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4880 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), hsub),
4882 def : Pat<(i32 (intOp (v16i8 V128:$Rn))),
4884 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4885 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), hsub),
4888 def : Pat<(i32 (intOp (v4i16 V64:$Rn))),
4889 (i32 (EXTRACT_SUBREG
4890 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4891 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), ssub),
4893 def : Pat<(i32 (intOp (v8i16 V128:$Rn))),
4894 (i32 (EXTRACT_SUBREG
4895 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4896 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), ssub),
4899 def : Pat<(i64 (intOp (v4i32 V128:$Rn))),
4900 (i64 (EXTRACT_SUBREG
4901 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4902 (!cast<Instruction>(!strconcat(baseOpc, "v4i32v")) V128:$Rn), dsub),
4906 multiclass SIMDAcrossLanesUnsignedLongIntrinsic<string baseOpc,
4908 def : Pat<(i32 (intOp (v8i8 V64:$Rn))),
4909 (i32 (EXTRACT_SUBREG
4910 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4911 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), hsub),
4913 def : Pat<(i32 (intOp (v16i8 V128:$Rn))),
4914 (i32 (EXTRACT_SUBREG
4915 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4916 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), hsub),
4919 def : Pat<(i32 (intOp (v4i16 V64:$Rn))),
4920 (i32 (EXTRACT_SUBREG
4921 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4922 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), ssub),
4924 def : Pat<(i32 (intOp (v8i16 V128:$Rn))),
4925 (i32 (EXTRACT_SUBREG
4926 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4927 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), ssub),
4930 def : Pat<(i64 (intOp (v4i32 V128:$Rn))),
4931 (i64 (EXTRACT_SUBREG
4932 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4933 (!cast<Instruction>(!strconcat(baseOpc, "v4i32v")) V128:$Rn), dsub),
4937 defm : SIMDAcrossLanesSignedLongIntrinsic<"SADDLV", int_aarch64_neon_saddlv>;
4938 defm : SIMDAcrossLanesUnsignedLongIntrinsic<"UADDLV", int_aarch64_neon_uaddlv>;
4940 // The vaddlv_s32 intrinsic gets mapped to SADDLP.
4941 def : Pat<(i64 (int_aarch64_neon_saddlv (v2i32 V64:$Rn))),
4942 (i64 (EXTRACT_SUBREG
4943 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4944 (SADDLPv2i32_v1i64 V64:$Rn), dsub),
4946 // The vaddlv_u32 intrinsic gets mapped to UADDLP.
4947 def : Pat<(i64 (int_aarch64_neon_uaddlv (v2i32 V64:$Rn))),
4948 (i64 (EXTRACT_SUBREG
4949 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
4950 (UADDLPv2i32_v1i64 V64:$Rn), dsub),
4953 //------------------------------------------------------------------------------
4954 // AdvSIMD modified immediate instructions
4955 //------------------------------------------------------------------------------
4958 defm BIC : SIMDModifiedImmVectorShiftTied<1, 0b11, 0b01, "bic", AArch64bici>;
4960 defm ORR : SIMDModifiedImmVectorShiftTied<0, 0b11, 0b01, "orr", AArch64orri>;
4962 def : InstAlias<"bic $Vd.4h, $imm", (BICv4i16 V64:$Vd, imm0_255:$imm, 0)>;
4963 def : InstAlias<"bic $Vd.8h, $imm", (BICv8i16 V128:$Vd, imm0_255:$imm, 0)>;
4964 def : InstAlias<"bic $Vd.2s, $imm", (BICv2i32 V64:$Vd, imm0_255:$imm, 0)>;
4965 def : InstAlias<"bic $Vd.4s, $imm", (BICv4i32 V128:$Vd, imm0_255:$imm, 0)>;
4967 def : InstAlias<"bic.4h $Vd, $imm", (BICv4i16 V64:$Vd, imm0_255:$imm, 0)>;
4968 def : InstAlias<"bic.8h $Vd, $imm", (BICv8i16 V128:$Vd, imm0_255:$imm, 0)>;
4969 def : InstAlias<"bic.2s $Vd, $imm", (BICv2i32 V64:$Vd, imm0_255:$imm, 0)>;
4970 def : InstAlias<"bic.4s $Vd, $imm", (BICv4i32 V128:$Vd, imm0_255:$imm, 0)>;
4972 def : InstAlias<"orr $Vd.4h, $imm", (ORRv4i16 V64:$Vd, imm0_255:$imm, 0)>;
4973 def : InstAlias<"orr $Vd.8h, $imm", (ORRv8i16 V128:$Vd, imm0_255:$imm, 0)>;
4974 def : InstAlias<"orr $Vd.2s, $imm", (ORRv2i32 V64:$Vd, imm0_255:$imm, 0)>;
4975 def : InstAlias<"orr $Vd.4s, $imm", (ORRv4i32 V128:$Vd, imm0_255:$imm, 0)>;
4977 def : InstAlias<"orr.4h $Vd, $imm", (ORRv4i16 V64:$Vd, imm0_255:$imm, 0)>;
4978 def : InstAlias<"orr.8h $Vd, $imm", (ORRv8i16 V128:$Vd, imm0_255:$imm, 0)>;
4979 def : InstAlias<"orr.2s $Vd, $imm", (ORRv2i32 V64:$Vd, imm0_255:$imm, 0)>;
4980 def : InstAlias<"orr.4s $Vd, $imm", (ORRv4i32 V128:$Vd, imm0_255:$imm, 0)>;
4983 def FMOVv2f64_ns : SIMDModifiedImmVectorNoShift<1, 1, 0, 0b1111, V128, fpimm8,
4985 [(set (v2f64 V128:$Rd), (AArch64fmov imm0_255:$imm8))]>;
4986 def FMOVv2f32_ns : SIMDModifiedImmVectorNoShift<0, 0, 0, 0b1111, V64, fpimm8,
4988 [(set (v2f32 V64:$Rd), (AArch64fmov imm0_255:$imm8))]>;
4989 def FMOVv4f32_ns : SIMDModifiedImmVectorNoShift<1, 0, 0, 0b1111, V128, fpimm8,
4991 [(set (v4f32 V128:$Rd), (AArch64fmov imm0_255:$imm8))]>;
4992 let Predicates = [HasNEON, HasFullFP16] in {
4993 def FMOVv4f16_ns : SIMDModifiedImmVectorNoShift<0, 0, 1, 0b1111, V64, fpimm8,
4995 [(set (v4f16 V64:$Rd), (AArch64fmov imm0_255:$imm8))]>;
4996 def FMOVv8f16_ns : SIMDModifiedImmVectorNoShift<1, 0, 1, 0b1111, V128, fpimm8,
4998 [(set (v8f16 V128:$Rd), (AArch64fmov imm0_255:$imm8))]>;
4999 } // Predicates = [HasNEON, HasFullFP16]
5003 // EDIT byte mask: scalar
5004 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
5005 def MOVID : SIMDModifiedImmScalarNoShift<0, 1, 0b1110, "movi",
5006 [(set FPR64:$Rd, simdimmtype10:$imm8)]>;
5007 // The movi_edit node has the immediate value already encoded, so we use
5008 // a plain imm0_255 here.
5009 def : Pat<(f64 (AArch64movi_edit imm0_255:$shift)),
5010 (MOVID imm0_255:$shift)>;
5012 // EDIT byte mask: 2d
5014 // The movi_edit node has the immediate value already encoded, so we use
5015 // a plain imm0_255 in the pattern
5016 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
5017 def MOVIv2d_ns : SIMDModifiedImmVectorNoShift<1, 1, 0, 0b1110, V128,
5020 [(set (v2i64 V128:$Rd), (AArch64movi_edit imm0_255:$imm8))]>;
5022 def : Pat<(v2i64 immAllZerosV), (MOVIv2d_ns (i32 0))>;
5023 def : Pat<(v4i32 immAllZerosV), (MOVIv2d_ns (i32 0))>;
5024 def : Pat<(v8i16 immAllZerosV), (MOVIv2d_ns (i32 0))>;
5025 def : Pat<(v16i8 immAllZerosV), (MOVIv2d_ns (i32 0))>;
5027 def : Pat<(v2i64 immAllOnesV), (MOVIv2d_ns (i32 255))>;
5028 def : Pat<(v4i32 immAllOnesV), (MOVIv2d_ns (i32 255))>;
5029 def : Pat<(v8i16 immAllOnesV), (MOVIv2d_ns (i32 255))>;
5030 def : Pat<(v16i8 immAllOnesV), (MOVIv2d_ns (i32 255))>;
5032 // Set 64-bit vectors to all 0/1 by extracting from a 128-bit register as the
5033 // extract is free and this gives better MachineCSE results.
5034 def : Pat<(v1i64 immAllZerosV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 0)), dsub)>;
5035 def : Pat<(v2i32 immAllZerosV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 0)), dsub)>;
5036 def : Pat<(v4i16 immAllZerosV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 0)), dsub)>;
5037 def : Pat<(v8i8 immAllZerosV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 0)), dsub)>;
5039 def : Pat<(v1i64 immAllOnesV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 255)), dsub)>;
5040 def : Pat<(v2i32 immAllOnesV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 255)), dsub)>;
5041 def : Pat<(v4i16 immAllOnesV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 255)), dsub)>;
5042 def : Pat<(v8i8 immAllOnesV), (EXTRACT_SUBREG (MOVIv2d_ns (i32 255)), dsub)>;
5044 // EDIT per word & halfword: 2s, 4h, 4s, & 8h
5045 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
5046 defm MOVI : SIMDModifiedImmVectorShift<0, 0b10, 0b00, "movi">;
5048 def : InstAlias<"movi $Vd.4h, $imm", (MOVIv4i16 V64:$Vd, imm0_255:$imm, 0), 0>;
5049 def : InstAlias<"movi $Vd.8h, $imm", (MOVIv8i16 V128:$Vd, imm0_255:$imm, 0), 0>;
5050 def : InstAlias<"movi $Vd.2s, $imm", (MOVIv2i32 V64:$Vd, imm0_255:$imm, 0), 0>;
5051 def : InstAlias<"movi $Vd.4s, $imm", (MOVIv4i32 V128:$Vd, imm0_255:$imm, 0), 0>;
5053 def : InstAlias<"movi.4h $Vd, $imm", (MOVIv4i16 V64:$Vd, imm0_255:$imm, 0), 0>;
5054 def : InstAlias<"movi.8h $Vd, $imm", (MOVIv8i16 V128:$Vd, imm0_255:$imm, 0), 0>;
5055 def : InstAlias<"movi.2s $Vd, $imm", (MOVIv2i32 V64:$Vd, imm0_255:$imm, 0), 0>;
5056 def : InstAlias<"movi.4s $Vd, $imm", (MOVIv4i32 V128:$Vd, imm0_255:$imm, 0), 0>;
5058 def : Pat<(v2i32 (AArch64movi_shift imm0_255:$imm8, (i32 imm:$shift))),
5059 (MOVIv2i32 imm0_255:$imm8, imm:$shift)>;
5060 def : Pat<(v4i32 (AArch64movi_shift imm0_255:$imm8, (i32 imm:$shift))),
5061 (MOVIv4i32 imm0_255:$imm8, imm:$shift)>;
5062 def : Pat<(v4i16 (AArch64movi_shift imm0_255:$imm8, (i32 imm:$shift))),
5063 (MOVIv4i16 imm0_255:$imm8, imm:$shift)>;
5064 def : Pat<(v8i16 (AArch64movi_shift imm0_255:$imm8, (i32 imm:$shift))),
5065 (MOVIv8i16 imm0_255:$imm8, imm:$shift)>;
5067 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
5068 // EDIT per word: 2s & 4s with MSL shifter
5069 def MOVIv2s_msl : SIMDModifiedImmMoveMSL<0, 0, {1,1,0,?}, V64, "movi", ".2s",
5070 [(set (v2i32 V64:$Rd),
5071 (AArch64movi_msl imm0_255:$imm8, (i32 imm:$shift)))]>;
5072 def MOVIv4s_msl : SIMDModifiedImmMoveMSL<1, 0, {1,1,0,?}, V128, "movi", ".4s",
5073 [(set (v4i32 V128:$Rd),
5074 (AArch64movi_msl imm0_255:$imm8, (i32 imm:$shift)))]>;
5076 // Per byte: 8b & 16b
5077 def MOVIv8b_ns : SIMDModifiedImmVectorNoShift<0, 0, 0, 0b1110, V64, imm0_255,
5079 [(set (v8i8 V64:$Rd), (AArch64movi imm0_255:$imm8))]>;
5081 def MOVIv16b_ns : SIMDModifiedImmVectorNoShift<1, 0, 0, 0b1110, V128, imm0_255,
5083 [(set (v16i8 V128:$Rd), (AArch64movi imm0_255:$imm8))]>;
5088 // EDIT per word & halfword: 2s, 4h, 4s, & 8h
5089 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
5090 defm MVNI : SIMDModifiedImmVectorShift<1, 0b10, 0b00, "mvni">;
5092 def : InstAlias<"mvni $Vd.4h, $imm", (MVNIv4i16 V64:$Vd, imm0_255:$imm, 0), 0>;
5093 def : InstAlias<"mvni $Vd.8h, $imm", (MVNIv8i16 V128:$Vd, imm0_255:$imm, 0), 0>;
5094 def : InstAlias<"mvni $Vd.2s, $imm", (MVNIv2i32 V64:$Vd, imm0_255:$imm, 0), 0>;
5095 def : InstAlias<"mvni $Vd.4s, $imm", (MVNIv4i32 V128:$Vd, imm0_255:$imm, 0), 0>;
5097 def : InstAlias<"mvni.4h $Vd, $imm", (MVNIv4i16 V64:$Vd, imm0_255:$imm, 0), 0>;
5098 def : InstAlias<"mvni.8h $Vd, $imm", (MVNIv8i16 V128:$Vd, imm0_255:$imm, 0), 0>;
5099 def : InstAlias<"mvni.2s $Vd, $imm", (MVNIv2i32 V64:$Vd, imm0_255:$imm, 0), 0>;
5100 def : InstAlias<"mvni.4s $Vd, $imm", (MVNIv4i32 V128:$Vd, imm0_255:$imm, 0), 0>;
5102 def : Pat<(v2i32 (AArch64mvni_shift imm0_255:$imm8, (i32 imm:$shift))),
5103 (MVNIv2i32 imm0_255:$imm8, imm:$shift)>;
5104 def : Pat<(v4i32 (AArch64mvni_shift imm0_255:$imm8, (i32 imm:$shift))),
5105 (MVNIv4i32 imm0_255:$imm8, imm:$shift)>;
5106 def : Pat<(v4i16 (AArch64mvni_shift imm0_255:$imm8, (i32 imm:$shift))),
5107 (MVNIv4i16 imm0_255:$imm8, imm:$shift)>;
5108 def : Pat<(v8i16 (AArch64mvni_shift imm0_255:$imm8, (i32 imm:$shift))),
5109 (MVNIv8i16 imm0_255:$imm8, imm:$shift)>;
5111 // EDIT per word: 2s & 4s with MSL shifter
5112 let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
5113 def MVNIv2s_msl : SIMDModifiedImmMoveMSL<0, 1, {1,1,0,?}, V64, "mvni", ".2s",
5114 [(set (v2i32 V64:$Rd),
5115 (AArch64mvni_msl imm0_255:$imm8, (i32 imm:$shift)))]>;
5116 def MVNIv4s_msl : SIMDModifiedImmMoveMSL<1, 1, {1,1,0,?}, V128, "mvni", ".4s",
5117 [(set (v4i32 V128:$Rd),
5118 (AArch64mvni_msl imm0_255:$imm8, (i32 imm:$shift)))]>;
5121 //----------------------------------------------------------------------------
5122 // AdvSIMD indexed element
5123 //----------------------------------------------------------------------------
5125 let hasSideEffects = 0 in {
5126 defm FMLA : SIMDFPIndexedTied<0, 0b0001, "fmla">;
5127 defm FMLS : SIMDFPIndexedTied<0, 0b0101, "fmls">;
5130 // NOTE: Operands are reordered in the FMLA/FMLS PatFrags because the
5131 // instruction expects the addend first, while the intrinsic expects it last.
5133 // On the other hand, there are quite a few valid combinatorial options due to
5134 // the commutativity of multiplication and the fact that (-x) * y = x * (-y).
5135 defm : SIMDFPIndexedTiedPatterns<"FMLA",
5136 TriOpFrag<(fma node:$RHS, node:$MHS, node:$LHS)>>;
5137 defm : SIMDFPIndexedTiedPatterns<"FMLA",
5138 TriOpFrag<(fma node:$MHS, node:$RHS, node:$LHS)>>;
5140 defm : SIMDFPIndexedTiedPatterns<"FMLS",
5141 TriOpFrag<(fma node:$MHS, (fneg node:$RHS), node:$LHS)> >;
5142 defm : SIMDFPIndexedTiedPatterns<"FMLS",
5143 TriOpFrag<(fma node:$RHS, (fneg node:$MHS), node:$LHS)> >;
5144 defm : SIMDFPIndexedTiedPatterns<"FMLS",
5145 TriOpFrag<(fma (fneg node:$RHS), node:$MHS, node:$LHS)> >;
5146 defm : SIMDFPIndexedTiedPatterns<"FMLS",
5147 TriOpFrag<(fma (fneg node:$MHS), node:$RHS, node:$LHS)> >;
5149 multiclass FMLSIndexedAfterNegPatterns<SDPatternOperator OpNode> {
5150 // 3 variants for the .2s version: DUPLANE from 128-bit, DUPLANE from 64-bit
5152 def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn),
5153 (AArch64duplane32 (v4f32 (fneg V128:$Rm)),
5154 VectorIndexS:$idx))),
5155 (FMLSv2i32_indexed V64:$Rd, V64:$Rn, V128:$Rm, VectorIndexS:$idx)>;
5156 def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn),
5157 (v2f32 (AArch64duplane32
5158 (v4f32 (insert_subvector undef,
5159 (v2f32 (fneg V64:$Rm)),
5161 VectorIndexS:$idx)))),
5162 (FMLSv2i32_indexed V64:$Rd, V64:$Rn,
5163 (SUBREG_TO_REG (i32 0), V64:$Rm, dsub),
5164 VectorIndexS:$idx)>;
5165 def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn),
5166 (AArch64dup (f32 (fneg FPR32Op:$Rm))))),
5167 (FMLSv2i32_indexed V64:$Rd, V64:$Rn,
5168 (SUBREG_TO_REG (i32 0), FPR32Op:$Rm, ssub), (i64 0))>;
5170 // 3 variants for the .4s version: DUPLANE from 128-bit, DUPLANE from 64-bit
5172 def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn),
5173 (AArch64duplane32 (v4f32 (fneg V128:$Rm)),
5174 VectorIndexS:$idx))),
5175 (FMLSv4i32_indexed V128:$Rd, V128:$Rn, V128:$Rm,
5176 VectorIndexS:$idx)>;
5177 def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn),
5178 (v4f32 (AArch64duplane32
5179 (v4f32 (insert_subvector undef,
5180 (v2f32 (fneg V64:$Rm)),
5182 VectorIndexS:$idx)))),
5183 (FMLSv4i32_indexed V128:$Rd, V128:$Rn,
5184 (SUBREG_TO_REG (i32 0), V64:$Rm, dsub),
5185 VectorIndexS:$idx)>;
5186 def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn),
5187 (AArch64dup (f32 (fneg FPR32Op:$Rm))))),
5188 (FMLSv4i32_indexed V128:$Rd, V128:$Rn,
5189 (SUBREG_TO_REG (i32 0), FPR32Op:$Rm, ssub), (i64 0))>;
5191 // 2 variants for the .2d version: DUPLANE from 128-bit, and DUP scalar
5192 // (DUPLANE from 64-bit would be trivial).
5193 def : Pat<(v2f64 (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn),
5194 (AArch64duplane64 (v2f64 (fneg V128:$Rm)),
5195 VectorIndexD:$idx))),
5197 V128:$Rd, V128:$Rn, V128:$Rm, VectorIndexS:$idx)>;
5198 def : Pat<(v2f64 (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn),
5199 (AArch64dup (f64 (fneg FPR64Op:$Rm))))),
5200 (FMLSv2i64_indexed V128:$Rd, V128:$Rn,
5201 (SUBREG_TO_REG (i32 0), FPR64Op:$Rm, dsub), (i64 0))>;
5203 // 2 variants for 32-bit scalar version: extract from .2s or from .4s
5204 def : Pat<(f32 (OpNode (f32 FPR32:$Rd), (f32 FPR32:$Rn),
5205 (vector_extract (v4f32 (fneg V128:$Rm)),
5206 VectorIndexS:$idx))),
5207 (FMLSv1i32_indexed FPR32:$Rd, FPR32:$Rn,
5208 V128:$Rm, VectorIndexS:$idx)>;
5209 def : Pat<(f32 (OpNode (f32 FPR32:$Rd), (f32 FPR32:$Rn),
5210 (vector_extract (v4f32 (insert_subvector undef,
5211 (v2f32 (fneg V64:$Rm)),
5213 VectorIndexS:$idx))),
5214 (FMLSv1i32_indexed FPR32:$Rd, FPR32:$Rn,
5215 (SUBREG_TO_REG (i32 0), V64:$Rm, dsub), VectorIndexS:$idx)>;
5217 // 1 variant for 64-bit scalar version: extract from .1d or from .2d
5218 def : Pat<(f64 (OpNode (f64 FPR64:$Rd), (f64 FPR64:$Rn),
5219 (vector_extract (v2f64 (fneg V128:$Rm)),
5220 VectorIndexS:$idx))),
5221 (FMLSv1i64_indexed FPR64:$Rd, FPR64:$Rn,
5222 V128:$Rm, VectorIndexS:$idx)>;
5225 defm : FMLSIndexedAfterNegPatterns<
5226 TriOpFrag<(fma node:$RHS, node:$MHS, node:$LHS)> >;
5227 defm : FMLSIndexedAfterNegPatterns<
5228 TriOpFrag<(fma node:$MHS, node:$RHS, node:$LHS)> >;
5230 defm FMULX : SIMDFPIndexed<1, 0b1001, "fmulx", int_aarch64_neon_fmulx>;
5231 defm FMUL : SIMDFPIndexed<0, 0b1001, "fmul", fmul>;
5233 def : Pat<(v2f32 (fmul V64:$Rn, (AArch64dup (f32 FPR32:$Rm)))),
5234 (FMULv2i32_indexed V64:$Rn,
5235 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR32:$Rm, ssub),
5237 def : Pat<(v4f32 (fmul V128:$Rn, (AArch64dup (f32 FPR32:$Rm)))),
5238 (FMULv4i32_indexed V128:$Rn,
5239 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR32:$Rm, ssub),
5241 def : Pat<(v2f64 (fmul V128:$Rn, (AArch64dup (f64 FPR64:$Rm)))),
5242 (FMULv2i64_indexed V128:$Rn,
5243 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR64:$Rm, dsub),
5246 defm SQDMULH : SIMDIndexedHS<0, 0b1100, "sqdmulh", int_aarch64_neon_sqdmulh>;
5247 defm SQRDMULH : SIMDIndexedHS<0, 0b1101, "sqrdmulh", int_aarch64_neon_sqrdmulh>;
5248 defm MLA : SIMDVectorIndexedHSTied<1, 0b0000, "mla",
5249 TriOpFrag<(add node:$LHS, (mul node:$MHS, node:$RHS))>>;
5250 defm MLS : SIMDVectorIndexedHSTied<1, 0b0100, "mls",
5251 TriOpFrag<(sub node:$LHS, (mul node:$MHS, node:$RHS))>>;
5252 defm MUL : SIMDVectorIndexedHS<0, 0b1000, "mul", mul>;
5253 defm SMLAL : SIMDVectorIndexedLongSDTied<0, 0b0010, "smlal",
5254 TriOpFrag<(add node:$LHS, (int_aarch64_neon_smull node:$MHS, node:$RHS))>>;
5255 defm SMLSL : SIMDVectorIndexedLongSDTied<0, 0b0110, "smlsl",
5256 TriOpFrag<(sub node:$LHS, (int_aarch64_neon_smull node:$MHS, node:$RHS))>>;
5257 defm SMULL : SIMDVectorIndexedLongSD<0, 0b1010, "smull",
5258 int_aarch64_neon_smull>;
5259 defm SQDMLAL : SIMDIndexedLongSQDMLXSDTied<0, 0b0011, "sqdmlal",
5260 int_aarch64_neon_sqadd>;
5261 defm SQDMLSL : SIMDIndexedLongSQDMLXSDTied<0, 0b0111, "sqdmlsl",
5262 int_aarch64_neon_sqsub>;
5263 defm SQRDMLAH : SIMDIndexedSQRDMLxHSDTied<1, 0b1101, "sqrdmlah",
5264 int_aarch64_neon_sqadd>;
5265 defm SQRDMLSH : SIMDIndexedSQRDMLxHSDTied<1, 0b1111, "sqrdmlsh",
5266 int_aarch64_neon_sqsub>;
5267 defm SQDMULL : SIMDIndexedLongSD<0, 0b1011, "sqdmull", int_aarch64_neon_sqdmull>;
5268 defm UMLAL : SIMDVectorIndexedLongSDTied<1, 0b0010, "umlal",
5269 TriOpFrag<(add node:$LHS, (int_aarch64_neon_umull node:$MHS, node:$RHS))>>;
5270 defm UMLSL : SIMDVectorIndexedLongSDTied<1, 0b0110, "umlsl",
5271 TriOpFrag<(sub node:$LHS, (int_aarch64_neon_umull node:$MHS, node:$RHS))>>;
5272 defm UMULL : SIMDVectorIndexedLongSD<1, 0b1010, "umull",
5273 int_aarch64_neon_umull>;
5275 // A scalar sqdmull with the second operand being a vector lane can be
5276 // handled directly with the indexed instruction encoding.
5277 def : Pat<(int_aarch64_neon_sqdmulls_scalar (i32 FPR32:$Rn),
5278 (vector_extract (v4i32 V128:$Vm),
5279 VectorIndexS:$idx)),
5280 (SQDMULLv1i64_indexed FPR32:$Rn, V128:$Vm, VectorIndexS:$idx)>;
5282 //----------------------------------------------------------------------------
5283 // AdvSIMD scalar shift instructions
5284 //----------------------------------------------------------------------------
5285 defm FCVTZS : SIMDFPScalarRShift<0, 0b11111, "fcvtzs">;
5286 defm FCVTZU : SIMDFPScalarRShift<1, 0b11111, "fcvtzu">;
5287 defm SCVTF : SIMDFPScalarRShift<0, 0b11100, "scvtf">;
5288 defm UCVTF : SIMDFPScalarRShift<1, 0b11100, "ucvtf">;
5289 // Codegen patterns for the above. We don't put these directly on the
5290 // instructions because TableGen's type inference can't handle the truth.
5291 // Having the same base pattern for fp <--> int totally freaks it out.
5292 def : Pat<(int_aarch64_neon_vcvtfp2fxs FPR32:$Rn, vecshiftR32:$imm),
5293 (FCVTZSs FPR32:$Rn, vecshiftR32:$imm)>;
5294 def : Pat<(int_aarch64_neon_vcvtfp2fxu FPR32:$Rn, vecshiftR32:$imm),
5295 (FCVTZUs FPR32:$Rn, vecshiftR32:$imm)>;
5296 def : Pat<(i64 (int_aarch64_neon_vcvtfp2fxs (f64 FPR64:$Rn), vecshiftR64:$imm)),
5297 (FCVTZSd FPR64:$Rn, vecshiftR64:$imm)>;
5298 def : Pat<(i64 (int_aarch64_neon_vcvtfp2fxu (f64 FPR64:$Rn), vecshiftR64:$imm)),
5299 (FCVTZUd FPR64:$Rn, vecshiftR64:$imm)>;
5300 def : Pat<(v1i64 (int_aarch64_neon_vcvtfp2fxs (v1f64 FPR64:$Rn),
5302 (FCVTZSd FPR64:$Rn, vecshiftR64:$imm)>;
5303 def : Pat<(v1i64 (int_aarch64_neon_vcvtfp2fxu (v1f64 FPR64:$Rn),
5305 (FCVTZUd FPR64:$Rn, vecshiftR64:$imm)>;
5306 def : Pat<(int_aarch64_neon_vcvtfxu2fp FPR32:$Rn, vecshiftR32:$imm),
5307 (UCVTFs FPR32:$Rn, vecshiftR32:$imm)>;
5308 def : Pat<(f64 (int_aarch64_neon_vcvtfxu2fp (i64 FPR64:$Rn), vecshiftR64:$imm)),
5309 (UCVTFd FPR64:$Rn, vecshiftR64:$imm)>;
5310 def : Pat<(v1f64 (int_aarch64_neon_vcvtfxs2fp (v1i64 FPR64:$Rn),
5312 (SCVTFd FPR64:$Rn, vecshiftR64:$imm)>;
5313 def : Pat<(f64 (int_aarch64_neon_vcvtfxs2fp (i64 FPR64:$Rn), vecshiftR64:$imm)),
5314 (SCVTFd FPR64:$Rn, vecshiftR64:$imm)>;
5315 def : Pat<(v1f64 (int_aarch64_neon_vcvtfxu2fp (v1i64 FPR64:$Rn),
5317 (UCVTFd FPR64:$Rn, vecshiftR64:$imm)>;
5318 def : Pat<(int_aarch64_neon_vcvtfxs2fp FPR32:$Rn, vecshiftR32:$imm),
5319 (SCVTFs FPR32:$Rn, vecshiftR32:$imm)>;
5321 // Patterns for FP16 Instrinsics - requires reg copy to/from as i16s not supported.
5323 def : Pat<(f16 (int_aarch64_neon_vcvtfxs2fp (i32 (sext_inreg FPR32:$Rn, i16)), vecshiftR16:$imm)),
5324 (SCVTFh (EXTRACT_SUBREG FPR32:$Rn, hsub), vecshiftR16:$imm)>;
5325 def : Pat<(f16 (int_aarch64_neon_vcvtfxs2fp (i32 FPR32:$Rn), vecshiftR16:$imm)),
5326 (SCVTFh (EXTRACT_SUBREG FPR32:$Rn, hsub), vecshiftR16:$imm)>;
5327 def : Pat<(f16 (int_aarch64_neon_vcvtfxu2fp
5328 (and FPR32:$Rn, (i32 65535)),
5330 (UCVTFh (EXTRACT_SUBREG FPR32:$Rn, hsub), vecshiftR16:$imm)>;
5331 def : Pat<(f16 (int_aarch64_neon_vcvtfxu2fp FPR32:$Rn, vecshiftR16:$imm)),
5332 (UCVTFh (EXTRACT_SUBREG FPR32:$Rn, hsub), vecshiftR16:$imm)>;
5333 def : Pat<(f16 (int_aarch64_neon_vcvtfxu2fp (i64 FPR64:$Rn), vecshiftR16:$imm)),
5334 (UCVTFh (EXTRACT_SUBREG FPR64:$Rn, hsub), vecshiftR16:$imm)>;
5335 def : Pat<(i32 (int_aarch64_neon_vcvtfp2fxs (f16 FPR16:$Rn), vecshiftR32:$imm)),
5337 (i32 (IMPLICIT_DEF)),
5338 (FCVTZSh FPR16:$Rn, vecshiftR32:$imm),
5340 def : Pat<(i64 (int_aarch64_neon_vcvtfp2fxs (f16 FPR16:$Rn), vecshiftR64:$imm)),
5342 (i64 (IMPLICIT_DEF)),
5343 (FCVTZSh FPR16:$Rn, vecshiftR64:$imm),
5345 def : Pat<(i32 (int_aarch64_neon_vcvtfp2fxu (f16 FPR16:$Rn), vecshiftR32:$imm)),
5347 (i32 (IMPLICIT_DEF)),
5348 (FCVTZUh FPR16:$Rn, vecshiftR32:$imm),
5350 def : Pat<(i64 (int_aarch64_neon_vcvtfp2fxu (f16 FPR16:$Rn), vecshiftR64:$imm)),
5352 (i64 (IMPLICIT_DEF)),
5353 (FCVTZUh FPR16:$Rn, vecshiftR64:$imm),
5356 defm SHL : SIMDScalarLShiftD< 0, 0b01010, "shl", AArch64vshl>;
5357 defm SLI : SIMDScalarLShiftDTied<1, 0b01010, "sli">;
5358 defm SQRSHRN : SIMDScalarRShiftBHS< 0, 0b10011, "sqrshrn",
5359 int_aarch64_neon_sqrshrn>;
5360 defm SQRSHRUN : SIMDScalarRShiftBHS< 1, 0b10001, "sqrshrun",
5361 int_aarch64_neon_sqrshrun>;
5362 defm SQSHLU : SIMDScalarLShiftBHSD<1, 0b01100, "sqshlu", AArch64sqshlui>;
5363 defm SQSHL : SIMDScalarLShiftBHSD<0, 0b01110, "sqshl", AArch64sqshli>;
5364 defm SQSHRN : SIMDScalarRShiftBHS< 0, 0b10010, "sqshrn",
5365 int_aarch64_neon_sqshrn>;
5366 defm SQSHRUN : SIMDScalarRShiftBHS< 1, 0b10000, "sqshrun",
5367 int_aarch64_neon_sqshrun>;
5368 defm SRI : SIMDScalarRShiftDTied< 1, 0b01000, "sri">;
5369 defm SRSHR : SIMDScalarRShiftD< 0, 0b00100, "srshr", AArch64srshri>;
5370 defm SRSRA : SIMDScalarRShiftDTied< 0, 0b00110, "srsra",
5371 TriOpFrag<(add node:$LHS,
5372 (AArch64srshri node:$MHS, node:$RHS))>>;
5373 defm SSHR : SIMDScalarRShiftD< 0, 0b00000, "sshr", AArch64vashr>;
5374 defm SSRA : SIMDScalarRShiftDTied< 0, 0b00010, "ssra",
5375 TriOpFrag<(add node:$LHS,
5376 (AArch64vashr node:$MHS, node:$RHS))>>;
5377 defm UQRSHRN : SIMDScalarRShiftBHS< 1, 0b10011, "uqrshrn",
5378 int_aarch64_neon_uqrshrn>;
5379 defm UQSHL : SIMDScalarLShiftBHSD<1, 0b01110, "uqshl", AArch64uqshli>;
5380 defm UQSHRN : SIMDScalarRShiftBHS< 1, 0b10010, "uqshrn",
5381 int_aarch64_neon_uqshrn>;
5382 defm URSHR : SIMDScalarRShiftD< 1, 0b00100, "urshr", AArch64urshri>;
5383 defm URSRA : SIMDScalarRShiftDTied< 1, 0b00110, "ursra",
5384 TriOpFrag<(add node:$LHS,
5385 (AArch64urshri node:$MHS, node:$RHS))>>;
5386 defm USHR : SIMDScalarRShiftD< 1, 0b00000, "ushr", AArch64vlshr>;
5387 defm USRA : SIMDScalarRShiftDTied< 1, 0b00010, "usra",
5388 TriOpFrag<(add node:$LHS,
5389 (AArch64vlshr node:$MHS, node:$RHS))>>;
5391 //----------------------------------------------------------------------------
5392 // AdvSIMD vector shift instructions
5393 //----------------------------------------------------------------------------
5394 defm FCVTZS:SIMDVectorRShiftSD<0, 0b11111, "fcvtzs", int_aarch64_neon_vcvtfp2fxs>;
5395 defm FCVTZU:SIMDVectorRShiftSD<1, 0b11111, "fcvtzu", int_aarch64_neon_vcvtfp2fxu>;
5396 defm SCVTF: SIMDVectorRShiftToFP<0, 0b11100, "scvtf",
5397 int_aarch64_neon_vcvtfxs2fp>;
5398 defm RSHRN : SIMDVectorRShiftNarrowBHS<0, 0b10001, "rshrn",
5399 int_aarch64_neon_rshrn>;
5400 defm SHL : SIMDVectorLShiftBHSD<0, 0b01010, "shl", AArch64vshl>;
5401 defm SHRN : SIMDVectorRShiftNarrowBHS<0, 0b10000, "shrn",
5402 BinOpFrag<(trunc (AArch64vashr node:$LHS, node:$RHS))>>;
5403 defm SLI : SIMDVectorLShiftBHSDTied<1, 0b01010, "sli", int_aarch64_neon_vsli>;
5404 def : Pat<(v1i64 (int_aarch64_neon_vsli (v1i64 FPR64:$Rd), (v1i64 FPR64:$Rn),
5405 (i32 vecshiftL64:$imm))),
5406 (SLId FPR64:$Rd, FPR64:$Rn, vecshiftL64:$imm)>;
5407 defm SQRSHRN : SIMDVectorRShiftNarrowBHS<0, 0b10011, "sqrshrn",
5408 int_aarch64_neon_sqrshrn>;
5409 defm SQRSHRUN: SIMDVectorRShiftNarrowBHS<1, 0b10001, "sqrshrun",
5410 int_aarch64_neon_sqrshrun>;
5411 defm SQSHLU : SIMDVectorLShiftBHSD<1, 0b01100, "sqshlu", AArch64sqshlui>;
5412 defm SQSHL : SIMDVectorLShiftBHSD<0, 0b01110, "sqshl", AArch64sqshli>;
5413 defm SQSHRN : SIMDVectorRShiftNarrowBHS<0, 0b10010, "sqshrn",
5414 int_aarch64_neon_sqshrn>;
5415 defm SQSHRUN : SIMDVectorRShiftNarrowBHS<1, 0b10000, "sqshrun",
5416 int_aarch64_neon_sqshrun>;
5417 defm SRI : SIMDVectorRShiftBHSDTied<1, 0b01000, "sri", int_aarch64_neon_vsri>;
5418 def : Pat<(v1i64 (int_aarch64_neon_vsri (v1i64 FPR64:$Rd), (v1i64 FPR64:$Rn),
5419 (i32 vecshiftR64:$imm))),
5420 (SRId FPR64:$Rd, FPR64:$Rn, vecshiftR64:$imm)>;
5421 defm SRSHR : SIMDVectorRShiftBHSD<0, 0b00100, "srshr", AArch64srshri>;
5422 defm SRSRA : SIMDVectorRShiftBHSDTied<0, 0b00110, "srsra",
5423 TriOpFrag<(add node:$LHS,
5424 (AArch64srshri node:$MHS, node:$RHS))> >;
5425 defm SSHLL : SIMDVectorLShiftLongBHSD<0, 0b10100, "sshll",
5426 BinOpFrag<(AArch64vshl (sext node:$LHS), node:$RHS)>>;
5428 defm SSHR : SIMDVectorRShiftBHSD<0, 0b00000, "sshr", AArch64vashr>;
5429 defm SSRA : SIMDVectorRShiftBHSDTied<0, 0b00010, "ssra",
5430 TriOpFrag<(add node:$LHS, (AArch64vashr node:$MHS, node:$RHS))>>;
5431 defm UCVTF : SIMDVectorRShiftToFP<1, 0b11100, "ucvtf",
5432 int_aarch64_neon_vcvtfxu2fp>;
5433 defm UQRSHRN : SIMDVectorRShiftNarrowBHS<1, 0b10011, "uqrshrn",
5434 int_aarch64_neon_uqrshrn>;
5435 defm UQSHL : SIMDVectorLShiftBHSD<1, 0b01110, "uqshl", AArch64uqshli>;
5436 defm UQSHRN : SIMDVectorRShiftNarrowBHS<1, 0b10010, "uqshrn",
5437 int_aarch64_neon_uqshrn>;
5438 defm URSHR : SIMDVectorRShiftBHSD<1, 0b00100, "urshr", AArch64urshri>;
5439 defm URSRA : SIMDVectorRShiftBHSDTied<1, 0b00110, "ursra",
5440 TriOpFrag<(add node:$LHS,
5441 (AArch64urshri node:$MHS, node:$RHS))> >;
5442 defm USHLL : SIMDVectorLShiftLongBHSD<1, 0b10100, "ushll",
5443 BinOpFrag<(AArch64vshl (zext node:$LHS), node:$RHS)>>;
5444 defm USHR : SIMDVectorRShiftBHSD<1, 0b00000, "ushr", AArch64vlshr>;
5445 defm USRA : SIMDVectorRShiftBHSDTied<1, 0b00010, "usra",
5446 TriOpFrag<(add node:$LHS, (AArch64vlshr node:$MHS, node:$RHS))> >;
5448 // SHRN patterns for when a logical right shift was used instead of arithmetic
5449 // (the immediate guarantees no sign bits actually end up in the result so it
5451 def : Pat<(v8i8 (trunc (AArch64vlshr (v8i16 V128:$Rn), vecshiftR16Narrow:$imm))),
5452 (SHRNv8i8_shift V128:$Rn, vecshiftR16Narrow:$imm)>;
5453 def : Pat<(v4i16 (trunc (AArch64vlshr (v4i32 V128:$Rn), vecshiftR32Narrow:$imm))),
5454 (SHRNv4i16_shift V128:$Rn, vecshiftR32Narrow:$imm)>;
5455 def : Pat<(v2i32 (trunc (AArch64vlshr (v2i64 V128:$Rn), vecshiftR64Narrow:$imm))),
5456 (SHRNv2i32_shift V128:$Rn, vecshiftR64Narrow:$imm)>;
5458 def : Pat<(v16i8 (concat_vectors (v8i8 V64:$Rd),
5459 (trunc (AArch64vlshr (v8i16 V128:$Rn),
5460 vecshiftR16Narrow:$imm)))),
5461 (SHRNv16i8_shift (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
5462 V128:$Rn, vecshiftR16Narrow:$imm)>;
5463 def : Pat<(v8i16 (concat_vectors (v4i16 V64:$Rd),
5464 (trunc (AArch64vlshr (v4i32 V128:$Rn),
5465 vecshiftR32Narrow:$imm)))),
5466 (SHRNv8i16_shift (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
5467 V128:$Rn, vecshiftR32Narrow:$imm)>;
5468 def : Pat<(v4i32 (concat_vectors (v2i32 V64:$Rd),
5469 (trunc (AArch64vlshr (v2i64 V128:$Rn),
5470 vecshiftR64Narrow:$imm)))),
5471 (SHRNv4i32_shift (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
5472 V128:$Rn, vecshiftR32Narrow:$imm)>;
5474 // Vector sign and zero extensions are implemented with SSHLL and USSHLL.
5475 // Anyexts are implemented as zexts.
5476 def : Pat<(v8i16 (sext (v8i8 V64:$Rn))), (SSHLLv8i8_shift V64:$Rn, (i32 0))>;
5477 def : Pat<(v8i16 (zext (v8i8 V64:$Rn))), (USHLLv8i8_shift V64:$Rn, (i32 0))>;
5478 def : Pat<(v8i16 (anyext (v8i8 V64:$Rn))), (USHLLv8i8_shift V64:$Rn, (i32 0))>;
5479 def : Pat<(v4i32 (sext (v4i16 V64:$Rn))), (SSHLLv4i16_shift V64:$Rn, (i32 0))>;
5480 def : Pat<(v4i32 (zext (v4i16 V64:$Rn))), (USHLLv4i16_shift V64:$Rn, (i32 0))>;
5481 def : Pat<(v4i32 (anyext (v4i16 V64:$Rn))), (USHLLv4i16_shift V64:$Rn, (i32 0))>;
5482 def : Pat<(v2i64 (sext (v2i32 V64:$Rn))), (SSHLLv2i32_shift V64:$Rn, (i32 0))>;
5483 def : Pat<(v2i64 (zext (v2i32 V64:$Rn))), (USHLLv2i32_shift V64:$Rn, (i32 0))>;
5484 def : Pat<(v2i64 (anyext (v2i32 V64:$Rn))), (USHLLv2i32_shift V64:$Rn, (i32 0))>;
5485 // Also match an extend from the upper half of a 128 bit source register.
5486 def : Pat<(v8i16 (anyext (v8i8 (extract_subvector V128:$Rn, (i64 8)) ))),
5487 (USHLLv16i8_shift V128:$Rn, (i32 0))>;
5488 def : Pat<(v8i16 (zext (v8i8 (extract_subvector V128:$Rn, (i64 8)) ))),
5489 (USHLLv16i8_shift V128:$Rn, (i32 0))>;
5490 def : Pat<(v8i16 (sext (v8i8 (extract_subvector V128:$Rn, (i64 8)) ))),
5491 (SSHLLv16i8_shift V128:$Rn, (i32 0))>;
5492 def : Pat<(v4i32 (anyext (v4i16 (extract_subvector V128:$Rn, (i64 4)) ))),
5493 (USHLLv8i16_shift V128:$Rn, (i32 0))>;
5494 def : Pat<(v4i32 (zext (v4i16 (extract_subvector V128:$Rn, (i64 4)) ))),
5495 (USHLLv8i16_shift V128:$Rn, (i32 0))>;
5496 def : Pat<(v4i32 (sext (v4i16 (extract_subvector V128:$Rn, (i64 4)) ))),
5497 (SSHLLv8i16_shift V128:$Rn, (i32 0))>;
5498 def : Pat<(v2i64 (anyext (v2i32 (extract_subvector V128:$Rn, (i64 2)) ))),
5499 (USHLLv4i32_shift V128:$Rn, (i32 0))>;
5500 def : Pat<(v2i64 (zext (v2i32 (extract_subvector V128:$Rn, (i64 2)) ))),
5501 (USHLLv4i32_shift V128:$Rn, (i32 0))>;
5502 def : Pat<(v2i64 (sext (v2i32 (extract_subvector V128:$Rn, (i64 2)) ))),
5503 (SSHLLv4i32_shift V128:$Rn, (i32 0))>;
5505 // Vector shift sxtl aliases
5506 def : InstAlias<"sxtl.8h $dst, $src1",
5507 (SSHLLv8i8_shift V128:$dst, V64:$src1, 0)>;
5508 def : InstAlias<"sxtl $dst.8h, $src1.8b",
5509 (SSHLLv8i8_shift V128:$dst, V64:$src1, 0)>;
5510 def : InstAlias<"sxtl.4s $dst, $src1",
5511 (SSHLLv4i16_shift V128:$dst, V64:$src1, 0)>;
5512 def : InstAlias<"sxtl $dst.4s, $src1.4h",
5513 (SSHLLv4i16_shift V128:$dst, V64:$src1, 0)>;
5514 def : InstAlias<"sxtl.2d $dst, $src1",
5515 (SSHLLv2i32_shift V128:$dst, V64:$src1, 0)>;
5516 def : InstAlias<"sxtl $dst.2d, $src1.2s",
5517 (SSHLLv2i32_shift V128:$dst, V64:$src1, 0)>;
5519 // Vector shift sxtl2 aliases
5520 def : InstAlias<"sxtl2.8h $dst, $src1",
5521 (SSHLLv16i8_shift V128:$dst, V128:$src1, 0)>;
5522 def : InstAlias<"sxtl2 $dst.8h, $src1.16b",
5523 (SSHLLv16i8_shift V128:$dst, V128:$src1, 0)>;
5524 def : InstAlias<"sxtl2.4s $dst, $src1",
5525 (SSHLLv8i16_shift V128:$dst, V128:$src1, 0)>;
5526 def : InstAlias<"sxtl2 $dst.4s, $src1.8h",
5527 (SSHLLv8i16_shift V128:$dst, V128:$src1, 0)>;
5528 def : InstAlias<"sxtl2.2d $dst, $src1",
5529 (SSHLLv4i32_shift V128:$dst, V128:$src1, 0)>;
5530 def : InstAlias<"sxtl2 $dst.2d, $src1.4s",
5531 (SSHLLv4i32_shift V128:$dst, V128:$src1, 0)>;
5533 // Vector shift uxtl aliases
5534 def : InstAlias<"uxtl.8h $dst, $src1",
5535 (USHLLv8i8_shift V128:$dst, V64:$src1, 0)>;
5536 def : InstAlias<"uxtl $dst.8h, $src1.8b",
5537 (USHLLv8i8_shift V128:$dst, V64:$src1, 0)>;
5538 def : InstAlias<"uxtl.4s $dst, $src1",
5539 (USHLLv4i16_shift V128:$dst, V64:$src1, 0)>;
5540 def : InstAlias<"uxtl $dst.4s, $src1.4h",
5541 (USHLLv4i16_shift V128:$dst, V64:$src1, 0)>;
5542 def : InstAlias<"uxtl.2d $dst, $src1",
5543 (USHLLv2i32_shift V128:$dst, V64:$src1, 0)>;
5544 def : InstAlias<"uxtl $dst.2d, $src1.2s",
5545 (USHLLv2i32_shift V128:$dst, V64:$src1, 0)>;
5547 // Vector shift uxtl2 aliases
5548 def : InstAlias<"uxtl2.8h $dst, $src1",
5549 (USHLLv16i8_shift V128:$dst, V128:$src1, 0)>;
5550 def : InstAlias<"uxtl2 $dst.8h, $src1.16b",
5551 (USHLLv16i8_shift V128:$dst, V128:$src1, 0)>;
5552 def : InstAlias<"uxtl2.4s $dst, $src1",
5553 (USHLLv8i16_shift V128:$dst, V128:$src1, 0)>;
5554 def : InstAlias<"uxtl2 $dst.4s, $src1.8h",
5555 (USHLLv8i16_shift V128:$dst, V128:$src1, 0)>;
5556 def : InstAlias<"uxtl2.2d $dst, $src1",
5557 (USHLLv4i32_shift V128:$dst, V128:$src1, 0)>;
5558 def : InstAlias<"uxtl2 $dst.2d, $src1.4s",
5559 (USHLLv4i32_shift V128:$dst, V128:$src1, 0)>;
5561 // If an integer is about to be converted to a floating point value,
5562 // just load it on the floating point unit.
5563 // These patterns are more complex because floating point loads do not
5564 // support sign extension.
5565 // The sign extension has to be explicitly added and is only supported for
5566 // one step: byte-to-half, half-to-word, word-to-doubleword.
5567 // SCVTF GPR -> FPR is 9 cycles.
5568 // SCVTF FPR -> FPR is 4 cyclces.
5569 // (sign extension with lengthen) SXTL FPR -> FPR is 2 cycles.
5570 // Therefore, we can do 2 sign extensions and one SCVTF FPR -> FPR
5571 // and still being faster.
5572 // However, this is not good for code size.
5573 // 8-bits -> float. 2 sizes step-up.
5574 class SExtLoadi8CVTf32Pat<dag addrmode, dag INST>
5575 : Pat<(f32 (sint_to_fp (i32 (sextloadi8 addrmode)))),
5576 (SCVTFv1i32 (f32 (EXTRACT_SUBREG
5581 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
5588 Requires<[NotForCodeSize, UseAlternateSExtLoadCVTF32]>;
5590 def : SExtLoadi8CVTf32Pat<(ro8.Wpat GPR64sp:$Rn, GPR32:$Rm, ro8.Wext:$ext),
5591 (LDRBroW GPR64sp:$Rn, GPR32:$Rm, ro8.Wext:$ext)>;
5592 def : SExtLoadi8CVTf32Pat<(ro8.Xpat GPR64sp:$Rn, GPR64:$Rm, ro8.Xext:$ext),
5593 (LDRBroX GPR64sp:$Rn, GPR64:$Rm, ro8.Xext:$ext)>;
5594 def : SExtLoadi8CVTf32Pat<(am_indexed8 GPR64sp:$Rn, uimm12s1:$offset),
5595 (LDRBui GPR64sp:$Rn, uimm12s1:$offset)>;
5596 def : SExtLoadi8CVTf32Pat<(am_unscaled8 GPR64sp:$Rn, simm9:$offset),
5597 (LDURBi GPR64sp:$Rn, simm9:$offset)>;
5599 // 16-bits -> float. 1 size step-up.
5600 class SExtLoadi16CVTf32Pat<dag addrmode, dag INST>
5601 : Pat<(f32 (sint_to_fp (i32 (sextloadi16 addrmode)))),
5602 (SCVTFv1i32 (f32 (EXTRACT_SUBREG
5604 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
5608 ssub)))>, Requires<[NotForCodeSize]>;
5610 def : SExtLoadi16CVTf32Pat<(ro16.Wpat GPR64sp:$Rn, GPR32:$Rm, ro16.Wext:$ext),
5611 (LDRHroW GPR64sp:$Rn, GPR32:$Rm, ro16.Wext:$ext)>;
5612 def : SExtLoadi16CVTf32Pat<(ro16.Xpat GPR64sp:$Rn, GPR64:$Rm, ro16.Xext:$ext),
5613 (LDRHroX GPR64sp:$Rn, GPR64:$Rm, ro16.Xext:$ext)>;
5614 def : SExtLoadi16CVTf32Pat<(am_indexed16 GPR64sp:$Rn, uimm12s2:$offset),
5615 (LDRHui GPR64sp:$Rn, uimm12s2:$offset)>;
5616 def : SExtLoadi16CVTf32Pat<(am_unscaled16 GPR64sp:$Rn, simm9:$offset),
5617 (LDURHi GPR64sp:$Rn, simm9:$offset)>;
5619 // 32-bits to 32-bits are handled in target specific dag combine:
5620 // performIntToFpCombine.
5621 // 64-bits integer to 32-bits floating point, not possible with
5622 // SCVTF on floating point registers (both source and destination
5623 // must have the same size).
5625 // Here are the patterns for 8, 16, 32, and 64-bits to double.
5626 // 8-bits -> double. 3 size step-up: give up.
5627 // 16-bits -> double. 2 size step.
5628 class SExtLoadi16CVTf64Pat<dag addrmode, dag INST>
5629 : Pat <(f64 (sint_to_fp (i32 (sextloadi16 addrmode)))),
5630 (SCVTFv1i64 (f64 (EXTRACT_SUBREG
5635 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
5642 Requires<[NotForCodeSize, UseAlternateSExtLoadCVTF32]>;
5644 def : SExtLoadi16CVTf64Pat<(ro16.Wpat GPR64sp:$Rn, GPR32:$Rm, ro16.Wext:$ext),
5645 (LDRHroW GPR64sp:$Rn, GPR32:$Rm, ro16.Wext:$ext)>;
5646 def : SExtLoadi16CVTf64Pat<(ro16.Xpat GPR64sp:$Rn, GPR64:$Rm, ro16.Xext:$ext),
5647 (LDRHroX GPR64sp:$Rn, GPR64:$Rm, ro16.Xext:$ext)>;
5648 def : SExtLoadi16CVTf64Pat<(am_indexed16 GPR64sp:$Rn, uimm12s2:$offset),
5649 (LDRHui GPR64sp:$Rn, uimm12s2:$offset)>;
5650 def : SExtLoadi16CVTf64Pat<(am_unscaled16 GPR64sp:$Rn, simm9:$offset),
5651 (LDURHi GPR64sp:$Rn, simm9:$offset)>;
5652 // 32-bits -> double. 1 size step-up.
5653 class SExtLoadi32CVTf64Pat<dag addrmode, dag INST>
5654 : Pat <(f64 (sint_to_fp (i32 (load addrmode)))),
5655 (SCVTFv1i64 (f64 (EXTRACT_SUBREG
5657 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
5661 dsub)))>, Requires<[NotForCodeSize]>;
5663 def : SExtLoadi32CVTf64Pat<(ro32.Wpat GPR64sp:$Rn, GPR32:$Rm, ro32.Wext:$ext),
5664 (LDRSroW GPR64sp:$Rn, GPR32:$Rm, ro32.Wext:$ext)>;
5665 def : SExtLoadi32CVTf64Pat<(ro32.Xpat GPR64sp:$Rn, GPR64:$Rm, ro32.Xext:$ext),
5666 (LDRSroX GPR64sp:$Rn, GPR64:$Rm, ro32.Xext:$ext)>;
5667 def : SExtLoadi32CVTf64Pat<(am_indexed32 GPR64sp:$Rn, uimm12s4:$offset),
5668 (LDRSui GPR64sp:$Rn, uimm12s4:$offset)>;
5669 def : SExtLoadi32CVTf64Pat<(am_unscaled32 GPR64sp:$Rn, simm9:$offset),
5670 (LDURSi GPR64sp:$Rn, simm9:$offset)>;
5672 // 64-bits -> double are handled in target specific dag combine:
5673 // performIntToFpCombine.
5676 //----------------------------------------------------------------------------
5677 // AdvSIMD Load-Store Structure
5678 //----------------------------------------------------------------------------
5679 defm LD1 : SIMDLd1Multiple<"ld1">;
5680 defm LD2 : SIMDLd2Multiple<"ld2">;
5681 defm LD3 : SIMDLd3Multiple<"ld3">;
5682 defm LD4 : SIMDLd4Multiple<"ld4">;
5684 defm ST1 : SIMDSt1Multiple<"st1">;
5685 defm ST2 : SIMDSt2Multiple<"st2">;
5686 defm ST3 : SIMDSt3Multiple<"st3">;
5687 defm ST4 : SIMDSt4Multiple<"st4">;
5689 class Ld1Pat<ValueType ty, Instruction INST>
5690 : Pat<(ty (load GPR64sp:$Rn)), (INST GPR64sp:$Rn)>;
5692 def : Ld1Pat<v16i8, LD1Onev16b>;
5693 def : Ld1Pat<v8i16, LD1Onev8h>;
5694 def : Ld1Pat<v4i32, LD1Onev4s>;
5695 def : Ld1Pat<v2i64, LD1Onev2d>;
5696 def : Ld1Pat<v8i8, LD1Onev8b>;
5697 def : Ld1Pat<v4i16, LD1Onev4h>;
5698 def : Ld1Pat<v2i32, LD1Onev2s>;
5699 def : Ld1Pat<v1i64, LD1Onev1d>;
5701 class St1Pat<ValueType ty, Instruction INST>
5702 : Pat<(store ty:$Vt, GPR64sp:$Rn),
5703 (INST ty:$Vt, GPR64sp:$Rn)>;
5705 def : St1Pat<v16i8, ST1Onev16b>;
5706 def : St1Pat<v8i16, ST1Onev8h>;
5707 def : St1Pat<v4i32, ST1Onev4s>;
5708 def : St1Pat<v2i64, ST1Onev2d>;
5709 def : St1Pat<v8i8, ST1Onev8b>;
5710 def : St1Pat<v4i16, ST1Onev4h>;
5711 def : St1Pat<v2i32, ST1Onev2s>;
5712 def : St1Pat<v1i64, ST1Onev1d>;
5718 defm LD1R : SIMDLdR<0, 0b110, 0, "ld1r", "One", 1, 2, 4, 8>;
5719 defm LD2R : SIMDLdR<1, 0b110, 0, "ld2r", "Two", 2, 4, 8, 16>;
5720 defm LD3R : SIMDLdR<0, 0b111, 0, "ld3r", "Three", 3, 6, 12, 24>;
5721 defm LD4R : SIMDLdR<1, 0b111, 0, "ld4r", "Four", 4, 8, 16, 32>;
5722 let mayLoad = 1, hasSideEffects = 0 in {
5723 defm LD1 : SIMDLdSingleBTied<0, 0b000, "ld1", VecListOneb, GPR64pi1>;
5724 defm LD1 : SIMDLdSingleHTied<0, 0b010, 0, "ld1", VecListOneh, GPR64pi2>;
5725 defm LD1 : SIMDLdSingleSTied<0, 0b100, 0b00, "ld1", VecListOnes, GPR64pi4>;
5726 defm LD1 : SIMDLdSingleDTied<0, 0b100, 0b01, "ld1", VecListOned, GPR64pi8>;
5727 defm LD2 : SIMDLdSingleBTied<1, 0b000, "ld2", VecListTwob, GPR64pi2>;
5728 defm LD2 : SIMDLdSingleHTied<1, 0b010, 0, "ld2", VecListTwoh, GPR64pi4>;
5729 defm LD2 : SIMDLdSingleSTied<1, 0b100, 0b00, "ld2", VecListTwos, GPR64pi8>;
5730 defm LD2 : SIMDLdSingleDTied<1, 0b100, 0b01, "ld2", VecListTwod, GPR64pi16>;
5731 defm LD3 : SIMDLdSingleBTied<0, 0b001, "ld3", VecListThreeb, GPR64pi3>;
5732 defm LD3 : SIMDLdSingleHTied<0, 0b011, 0, "ld3", VecListThreeh, GPR64pi6>;
5733 defm LD3 : SIMDLdSingleSTied<0, 0b101, 0b00, "ld3", VecListThrees, GPR64pi12>;
5734 defm LD3 : SIMDLdSingleDTied<0, 0b101, 0b01, "ld3", VecListThreed, GPR64pi24>;
5735 defm LD4 : SIMDLdSingleBTied<1, 0b001, "ld4", VecListFourb, GPR64pi4>;
5736 defm LD4 : SIMDLdSingleHTied<1, 0b011, 0, "ld4", VecListFourh, GPR64pi8>;
5737 defm LD4 : SIMDLdSingleSTied<1, 0b101, 0b00, "ld4", VecListFours, GPR64pi16>;
5738 defm LD4 : SIMDLdSingleDTied<1, 0b101, 0b01, "ld4", VecListFourd, GPR64pi32>;
5741 def : Pat<(v8i8 (AArch64dup (i32 (extloadi8 GPR64sp:$Rn)))),
5742 (LD1Rv8b GPR64sp:$Rn)>;
5743 def : Pat<(v16i8 (AArch64dup (i32 (extloadi8 GPR64sp:$Rn)))),
5744 (LD1Rv16b GPR64sp:$Rn)>;
5745 def : Pat<(v4i16 (AArch64dup (i32 (extloadi16 GPR64sp:$Rn)))),
5746 (LD1Rv4h GPR64sp:$Rn)>;
5747 def : Pat<(v8i16 (AArch64dup (i32 (extloadi16 GPR64sp:$Rn)))),
5748 (LD1Rv8h GPR64sp:$Rn)>;
5749 def : Pat<(v2i32 (AArch64dup (i32 (load GPR64sp:$Rn)))),
5750 (LD1Rv2s GPR64sp:$Rn)>;
5751 def : Pat<(v4i32 (AArch64dup (i32 (load GPR64sp:$Rn)))),
5752 (LD1Rv4s GPR64sp:$Rn)>;
5753 def : Pat<(v2i64 (AArch64dup (i64 (load GPR64sp:$Rn)))),
5754 (LD1Rv2d GPR64sp:$Rn)>;
5755 def : Pat<(v1i64 (AArch64dup (i64 (load GPR64sp:$Rn)))),
5756 (LD1Rv1d GPR64sp:$Rn)>;
5757 // Grab the floating point version too
5758 def : Pat<(v2f32 (AArch64dup (f32 (load GPR64sp:$Rn)))),
5759 (LD1Rv2s GPR64sp:$Rn)>;
5760 def : Pat<(v4f32 (AArch64dup (f32 (load GPR64sp:$Rn)))),
5761 (LD1Rv4s GPR64sp:$Rn)>;
5762 def : Pat<(v2f64 (AArch64dup (f64 (load GPR64sp:$Rn)))),
5763 (LD1Rv2d GPR64sp:$Rn)>;
5764 def : Pat<(v1f64 (AArch64dup (f64 (load GPR64sp:$Rn)))),
5765 (LD1Rv1d GPR64sp:$Rn)>;
5766 def : Pat<(v4f16 (AArch64dup (f16 (load GPR64sp:$Rn)))),
5767 (LD1Rv4h GPR64sp:$Rn)>;
5768 def : Pat<(v8f16 (AArch64dup (f16 (load GPR64sp:$Rn)))),
5769 (LD1Rv8h GPR64sp:$Rn)>;
5771 class Ld1Lane128Pat<SDPatternOperator scalar_load, Operand VecIndex,
5772 ValueType VTy, ValueType STy, Instruction LD1>
5773 : Pat<(vector_insert (VTy VecListOne128:$Rd),
5774 (STy (scalar_load GPR64sp:$Rn)), VecIndex:$idx),
5775 (LD1 VecListOne128:$Rd, VecIndex:$idx, GPR64sp:$Rn)>;
5777 def : Ld1Lane128Pat<extloadi8, VectorIndexB, v16i8, i32, LD1i8>;
5778 def : Ld1Lane128Pat<extloadi16, VectorIndexH, v8i16, i32, LD1i16>;
5779 def : Ld1Lane128Pat<load, VectorIndexS, v4i32, i32, LD1i32>;
5780 def : Ld1Lane128Pat<load, VectorIndexS, v4f32, f32, LD1i32>;
5781 def : Ld1Lane128Pat<load, VectorIndexD, v2i64, i64, LD1i64>;
5782 def : Ld1Lane128Pat<load, VectorIndexD, v2f64, f64, LD1i64>;
5783 def : Ld1Lane128Pat<load, VectorIndexH, v8f16, f16, LD1i16>;
5785 class Ld1Lane64Pat<SDPatternOperator scalar_load, Operand VecIndex,
5786 ValueType VTy, ValueType STy, Instruction LD1>
5787 : Pat<(vector_insert (VTy VecListOne64:$Rd),
5788 (STy (scalar_load GPR64sp:$Rn)), VecIndex:$idx),
5790 (LD1 (SUBREG_TO_REG (i32 0), VecListOne64:$Rd, dsub),
5791 VecIndex:$idx, GPR64sp:$Rn),
5794 def : Ld1Lane64Pat<extloadi8, VectorIndexB, v8i8, i32, LD1i8>;
5795 def : Ld1Lane64Pat<extloadi16, VectorIndexH, v4i16, i32, LD1i16>;
5796 def : Ld1Lane64Pat<load, VectorIndexS, v2i32, i32, LD1i32>;
5797 def : Ld1Lane64Pat<load, VectorIndexS, v2f32, f32, LD1i32>;
5798 def : Ld1Lane64Pat<load, VectorIndexH, v4f16, f16, LD1i16>;
5801 defm LD1 : SIMDLdSt1SingleAliases<"ld1">;
5802 defm LD2 : SIMDLdSt2SingleAliases<"ld2">;
5803 defm LD3 : SIMDLdSt3SingleAliases<"ld3">;
5804 defm LD4 : SIMDLdSt4SingleAliases<"ld4">;
5807 defm ST1 : SIMDStSingleB<0, 0b000, "st1", VecListOneb, GPR64pi1>;
5808 defm ST1 : SIMDStSingleH<0, 0b010, 0, "st1", VecListOneh, GPR64pi2>;
5809 defm ST1 : SIMDStSingleS<0, 0b100, 0b00, "st1", VecListOnes, GPR64pi4>;
5810 defm ST1 : SIMDStSingleD<0, 0b100, 0b01, "st1", VecListOned, GPR64pi8>;
5812 let AddedComplexity = 19 in
5813 class St1Lane128Pat<SDPatternOperator scalar_store, Operand VecIndex,
5814 ValueType VTy, ValueType STy, Instruction ST1>
5816 (STy (vector_extract (VTy VecListOne128:$Vt), VecIndex:$idx)),
5818 (ST1 VecListOne128:$Vt, VecIndex:$idx, GPR64sp:$Rn)>;
5820 def : St1Lane128Pat<truncstorei8, VectorIndexB, v16i8, i32, ST1i8>;
5821 def : St1Lane128Pat<truncstorei16, VectorIndexH, v8i16, i32, ST1i16>;
5822 def : St1Lane128Pat<store, VectorIndexS, v4i32, i32, ST1i32>;
5823 def : St1Lane128Pat<store, VectorIndexS, v4f32, f32, ST1i32>;
5824 def : St1Lane128Pat<store, VectorIndexD, v2i64, i64, ST1i64>;
5825 def : St1Lane128Pat<store, VectorIndexD, v2f64, f64, ST1i64>;
5826 def : St1Lane128Pat<store, VectorIndexH, v8f16, f16, ST1i16>;
5828 let AddedComplexity = 19 in
5829 class St1Lane64Pat<SDPatternOperator scalar_store, Operand VecIndex,
5830 ValueType VTy, ValueType STy, Instruction ST1>
5832 (STy (vector_extract (VTy VecListOne64:$Vt), VecIndex:$idx)),
5834 (ST1 (SUBREG_TO_REG (i32 0), VecListOne64:$Vt, dsub),
5835 VecIndex:$idx, GPR64sp:$Rn)>;
5837 def : St1Lane64Pat<truncstorei8, VectorIndexB, v8i8, i32, ST1i8>;
5838 def : St1Lane64Pat<truncstorei16, VectorIndexH, v4i16, i32, ST1i16>;
5839 def : St1Lane64Pat<store, VectorIndexS, v2i32, i32, ST1i32>;
5840 def : St1Lane64Pat<store, VectorIndexS, v2f32, f32, ST1i32>;
5841 def : St1Lane64Pat<store, VectorIndexH, v4f16, f16, ST1i16>;
5843 multiclass St1LanePost64Pat<SDPatternOperator scalar_store, Operand VecIndex,
5844 ValueType VTy, ValueType STy, Instruction ST1,
5846 def : Pat<(scalar_store
5847 (STy (vector_extract (VTy VecListOne64:$Vt), VecIndex:$idx)),
5848 GPR64sp:$Rn, offset),
5849 (ST1 (SUBREG_TO_REG (i32 0), VecListOne64:$Vt, dsub),
5850 VecIndex:$idx, GPR64sp:$Rn, XZR)>;
5852 def : Pat<(scalar_store
5853 (STy (vector_extract (VTy VecListOne64:$Vt), VecIndex:$idx)),
5854 GPR64sp:$Rn, GPR64:$Rm),
5855 (ST1 (SUBREG_TO_REG (i32 0), VecListOne64:$Vt, dsub),
5856 VecIndex:$idx, GPR64sp:$Rn, $Rm)>;
5859 defm : St1LanePost64Pat<post_truncsti8, VectorIndexB, v8i8, i32, ST1i8_POST, 1>;
5860 defm : St1LanePost64Pat<post_truncsti16, VectorIndexH, v4i16, i32, ST1i16_POST,
5862 defm : St1LanePost64Pat<post_store, VectorIndexS, v2i32, i32, ST1i32_POST, 4>;
5863 defm : St1LanePost64Pat<post_store, VectorIndexS, v2f32, f32, ST1i32_POST, 4>;
5864 defm : St1LanePost64Pat<post_store, VectorIndexD, v1i64, i64, ST1i64_POST, 8>;
5865 defm : St1LanePost64Pat<post_store, VectorIndexD, v1f64, f64, ST1i64_POST, 8>;
5866 defm : St1LanePost64Pat<post_store, VectorIndexH, v4f16, f16, ST1i16_POST, 2>;
5868 multiclass St1LanePost128Pat<SDPatternOperator scalar_store, Operand VecIndex,
5869 ValueType VTy, ValueType STy, Instruction ST1,
5871 def : Pat<(scalar_store
5872 (STy (vector_extract (VTy VecListOne128:$Vt), VecIndex:$idx)),
5873 GPR64sp:$Rn, offset),
5874 (ST1 VecListOne128:$Vt, VecIndex:$idx, GPR64sp:$Rn, XZR)>;
5876 def : Pat<(scalar_store
5877 (STy (vector_extract (VTy VecListOne128:$Vt), VecIndex:$idx)),
5878 GPR64sp:$Rn, GPR64:$Rm),
5879 (ST1 VecListOne128:$Vt, VecIndex:$idx, GPR64sp:$Rn, $Rm)>;
5882 defm : St1LanePost128Pat<post_truncsti8, VectorIndexB, v16i8, i32, ST1i8_POST,
5884 defm : St1LanePost128Pat<post_truncsti16, VectorIndexH, v8i16, i32, ST1i16_POST,
5886 defm : St1LanePost128Pat<post_store, VectorIndexS, v4i32, i32, ST1i32_POST, 4>;
5887 defm : St1LanePost128Pat<post_store, VectorIndexS, v4f32, f32, ST1i32_POST, 4>;
5888 defm : St1LanePost128Pat<post_store, VectorIndexD, v2i64, i64, ST1i64_POST, 8>;
5889 defm : St1LanePost128Pat<post_store, VectorIndexD, v2f64, f64, ST1i64_POST, 8>;
5890 defm : St1LanePost128Pat<post_store, VectorIndexH, v8f16, f16, ST1i16_POST, 2>;
5892 let mayStore = 1, hasSideEffects = 0 in {
5893 defm ST2 : SIMDStSingleB<1, 0b000, "st2", VecListTwob, GPR64pi2>;
5894 defm ST2 : SIMDStSingleH<1, 0b010, 0, "st2", VecListTwoh, GPR64pi4>;
5895 defm ST2 : SIMDStSingleS<1, 0b100, 0b00, "st2", VecListTwos, GPR64pi8>;
5896 defm ST2 : SIMDStSingleD<1, 0b100, 0b01, "st2", VecListTwod, GPR64pi16>;
5897 defm ST3 : SIMDStSingleB<0, 0b001, "st3", VecListThreeb, GPR64pi3>;
5898 defm ST3 : SIMDStSingleH<0, 0b011, 0, "st3", VecListThreeh, GPR64pi6>;
5899 defm ST3 : SIMDStSingleS<0, 0b101, 0b00, "st3", VecListThrees, GPR64pi12>;
5900 defm ST3 : SIMDStSingleD<0, 0b101, 0b01, "st3", VecListThreed, GPR64pi24>;
5901 defm ST4 : SIMDStSingleB<1, 0b001, "st4", VecListFourb, GPR64pi4>;
5902 defm ST4 : SIMDStSingleH<1, 0b011, 0, "st4", VecListFourh, GPR64pi8>;
5903 defm ST4 : SIMDStSingleS<1, 0b101, 0b00, "st4", VecListFours, GPR64pi16>;
5904 defm ST4 : SIMDStSingleD<1, 0b101, 0b01, "st4", VecListFourd, GPR64pi32>;
5907 defm ST1 : SIMDLdSt1SingleAliases<"st1">;
5908 defm ST2 : SIMDLdSt2SingleAliases<"st2">;
5909 defm ST3 : SIMDLdSt3SingleAliases<"st3">;
5910 defm ST4 : SIMDLdSt4SingleAliases<"st4">;
5912 //----------------------------------------------------------------------------
5913 // Crypto extensions
5914 //----------------------------------------------------------------------------
5916 let Predicates = [HasAES] in {
5917 def AESErr : AESTiedInst<0b0100, "aese", int_aarch64_crypto_aese>;
5918 def AESDrr : AESTiedInst<0b0101, "aesd", int_aarch64_crypto_aesd>;
5919 def AESMCrr : AESInst< 0b0110, "aesmc", int_aarch64_crypto_aesmc>;
5920 def AESIMCrr : AESInst< 0b0111, "aesimc", int_aarch64_crypto_aesimc>;
5923 // Pseudo instructions for AESMCrr/AESIMCrr with a register constraint required
5924 // for AES fusion on some CPUs.
5925 let hasSideEffects = 0, mayStore = 0, mayLoad = 0 in {
5926 def AESMCrrTied: Pseudo<(outs V128:$Rd), (ins V128:$Rn), [], "$Rn = $Rd">,
5928 def AESIMCrrTied: Pseudo<(outs V128:$Rd), (ins V128:$Rn), [], "$Rn = $Rd">,
5932 // Only use constrained versions of AES(I)MC instructions if they are paired with
5934 def : Pat<(v16i8 (int_aarch64_crypto_aesmc
5935 (v16i8 (int_aarch64_crypto_aese (v16i8 V128:$src1),
5936 (v16i8 V128:$src2))))),
5937 (v16i8 (AESMCrrTied (v16i8 (AESErr (v16i8 V128:$src1),
5938 (v16i8 V128:$src2)))))>,
5939 Requires<[HasFuseAES]>;
5941 def : Pat<(v16i8 (int_aarch64_crypto_aesimc
5942 (v16i8 (int_aarch64_crypto_aesd (v16i8 V128:$src1),
5943 (v16i8 V128:$src2))))),
5944 (v16i8 (AESIMCrrTied (v16i8 (AESDrr (v16i8 V128:$src1),
5945 (v16i8 V128:$src2)))))>,
5946 Requires<[HasFuseAES]>;
5948 let Predicates = [HasSHA2] in {
5949 def SHA1Crrr : SHATiedInstQSV<0b000, "sha1c", int_aarch64_crypto_sha1c>;
5950 def SHA1Prrr : SHATiedInstQSV<0b001, "sha1p", int_aarch64_crypto_sha1p>;
5951 def SHA1Mrrr : SHATiedInstQSV<0b010, "sha1m", int_aarch64_crypto_sha1m>;
5952 def SHA1SU0rrr : SHATiedInstVVV<0b011, "sha1su0", int_aarch64_crypto_sha1su0>;
5953 def SHA256Hrrr : SHATiedInstQQV<0b100, "sha256h", int_aarch64_crypto_sha256h>;
5954 def SHA256H2rrr : SHATiedInstQQV<0b101, "sha256h2",int_aarch64_crypto_sha256h2>;
5955 def SHA256SU1rrr :SHATiedInstVVV<0b110, "sha256su1",int_aarch64_crypto_sha256su1>;
5957 def SHA1Hrr : SHAInstSS< 0b0000, "sha1h", int_aarch64_crypto_sha1h>;
5958 def SHA1SU1rr : SHATiedInstVV<0b0001, "sha1su1", int_aarch64_crypto_sha1su1>;
5959 def SHA256SU0rr : SHATiedInstVV<0b0010, "sha256su0",int_aarch64_crypto_sha256su0>;
5962 //----------------------------------------------------------------------------
5964 //----------------------------------------------------------------------------
5965 // FIXME: Like for X86, these should go in their own separate .td file.
5967 def def32 : PatLeaf<(i32 GPR32:$src), [{
5971 // In the case of a 32-bit def that is known to implicitly zero-extend,
5972 // we can use a SUBREG_TO_REG.
5973 def : Pat<(i64 (zext def32:$src)), (SUBREG_TO_REG (i64 0), GPR32:$src, sub_32)>;
5975 // For an anyext, we don't care what the high bits are, so we can perform an
5976 // INSERT_SUBREF into an IMPLICIT_DEF.
5977 def : Pat<(i64 (anyext GPR32:$src)),
5978 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GPR32:$src, sub_32)>;
5980 // When we need to explicitly zero-extend, we use a 32-bit MOV instruction and
5981 // then assert the extension has happened.
5982 def : Pat<(i64 (zext GPR32:$src)),
5983 (SUBREG_TO_REG (i32 0), (ORRWrs WZR, GPR32:$src, 0), sub_32)>;
5985 // To sign extend, we use a signed bitfield move instruction (SBFM) on the
5986 // containing super-reg.
5987 def : Pat<(i64 (sext GPR32:$src)),
5988 (SBFMXri (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GPR32:$src, sub_32), 0, 31)>;
5989 def : Pat<(i64 (sext_inreg GPR64:$src, i32)), (SBFMXri GPR64:$src, 0, 31)>;
5990 def : Pat<(i64 (sext_inreg GPR64:$src, i16)), (SBFMXri GPR64:$src, 0, 15)>;
5991 def : Pat<(i64 (sext_inreg GPR64:$src, i8)), (SBFMXri GPR64:$src, 0, 7)>;
5992 def : Pat<(i64 (sext_inreg GPR64:$src, i1)), (SBFMXri GPR64:$src, 0, 0)>;
5993 def : Pat<(i32 (sext_inreg GPR32:$src, i16)), (SBFMWri GPR32:$src, 0, 15)>;
5994 def : Pat<(i32 (sext_inreg GPR32:$src, i8)), (SBFMWri GPR32:$src, 0, 7)>;
5995 def : Pat<(i32 (sext_inreg GPR32:$src, i1)), (SBFMWri GPR32:$src, 0, 0)>;
5997 def : Pat<(shl (sext_inreg GPR32:$Rn, i8), (i64 imm0_31:$imm)),
5998 (SBFMWri GPR32:$Rn, (i64 (i32shift_a imm0_31:$imm)),
5999 (i64 (i32shift_sext_i8 imm0_31:$imm)))>;
6000 def : Pat<(shl (sext_inreg GPR64:$Rn, i8), (i64 imm0_63:$imm)),
6001 (SBFMXri GPR64:$Rn, (i64 (i64shift_a imm0_63:$imm)),
6002 (i64 (i64shift_sext_i8 imm0_63:$imm)))>;
6004 def : Pat<(shl (sext_inreg GPR32:$Rn, i16), (i64 imm0_31:$imm)),
6005 (SBFMWri GPR32:$Rn, (i64 (i32shift_a imm0_31:$imm)),
6006 (i64 (i32shift_sext_i16 imm0_31:$imm)))>;
6007 def : Pat<(shl (sext_inreg GPR64:$Rn, i16), (i64 imm0_63:$imm)),
6008 (SBFMXri GPR64:$Rn, (i64 (i64shift_a imm0_63:$imm)),
6009 (i64 (i64shift_sext_i16 imm0_63:$imm)))>;
6011 def : Pat<(shl (i64 (sext GPR32:$Rn)), (i64 imm0_63:$imm)),
6012 (SBFMXri (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GPR32:$Rn, sub_32),
6013 (i64 (i64shift_a imm0_63:$imm)),
6014 (i64 (i64shift_sext_i32 imm0_63:$imm)))>;
6016 // sra patterns have an AddedComplexity of 10, so make sure we have a higher
6017 // AddedComplexity for the following patterns since we want to match sext + sra
6018 // patterns before we attempt to match a single sra node.
6019 let AddedComplexity = 20 in {
6020 // We support all sext + sra combinations which preserve at least one bit of the
6021 // original value which is to be sign extended. E.g. we support shifts up to
6023 def : Pat<(sra (sext_inreg GPR32:$Rn, i8), (i64 imm0_7:$imm)),
6024 (SBFMWri GPR32:$Rn, (i64 imm0_7:$imm), 7)>;
6025 def : Pat<(sra (sext_inreg GPR64:$Rn, i8), (i64 imm0_7:$imm)),
6026 (SBFMXri GPR64:$Rn, (i64 imm0_7:$imm), 7)>;
6028 def : Pat<(sra (sext_inreg GPR32:$Rn, i16), (i64 imm0_15:$imm)),
6029 (SBFMWri GPR32:$Rn, (i64 imm0_15:$imm), 15)>;
6030 def : Pat<(sra (sext_inreg GPR64:$Rn, i16), (i64 imm0_15:$imm)),
6031 (SBFMXri GPR64:$Rn, (i64 imm0_15:$imm), 15)>;
6033 def : Pat<(sra (i64 (sext GPR32:$Rn)), (i64 imm0_31:$imm)),
6034 (SBFMXri (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GPR32:$Rn, sub_32),
6035 (i64 imm0_31:$imm), 31)>;
6036 } // AddedComplexity = 20
6038 // To truncate, we can simply extract from a subregister.
6039 def : Pat<(i32 (trunc GPR64sp:$src)),
6040 (i32 (EXTRACT_SUBREG GPR64sp:$src, sub_32))>;
6042 // __builtin_trap() uses the BRK instruction on AArch64.
6043 def : Pat<(trap), (BRK 1)>;
6045 // Multiply high patterns which multiply the lower subvector using smull/umull
6046 // and the upper subvector with smull2/umull2. Then shuffle the high the high
6047 // part of both results together.
6048 def : Pat<(v16i8 (mulhs V128:$Rn, V128:$Rm)),
6050 (SMULLv8i8_v8i16 (EXTRACT_SUBREG V128:$Rn, dsub),
6051 (EXTRACT_SUBREG V128:$Rm, dsub)),
6052 (SMULLv16i8_v8i16 V128:$Rn, V128:$Rm))>;
6053 def : Pat<(v8i16 (mulhs V128:$Rn, V128:$Rm)),
6055 (SMULLv4i16_v4i32 (EXTRACT_SUBREG V128:$Rn, dsub),
6056 (EXTRACT_SUBREG V128:$Rm, dsub)),
6057 (SMULLv8i16_v4i32 V128:$Rn, V128:$Rm))>;
6058 def : Pat<(v4i32 (mulhs V128:$Rn, V128:$Rm)),
6060 (SMULLv2i32_v2i64 (EXTRACT_SUBREG V128:$Rn, dsub),
6061 (EXTRACT_SUBREG V128:$Rm, dsub)),
6062 (SMULLv4i32_v2i64 V128:$Rn, V128:$Rm))>;
6064 def : Pat<(v16i8 (mulhu V128:$Rn, V128:$Rm)),
6066 (UMULLv8i8_v8i16 (EXTRACT_SUBREG V128:$Rn, dsub),
6067 (EXTRACT_SUBREG V128:$Rm, dsub)),
6068 (UMULLv16i8_v8i16 V128:$Rn, V128:$Rm))>;
6069 def : Pat<(v8i16 (mulhu V128:$Rn, V128:$Rm)),
6071 (UMULLv4i16_v4i32 (EXTRACT_SUBREG V128:$Rn, dsub),
6072 (EXTRACT_SUBREG V128:$Rm, dsub)),
6073 (UMULLv8i16_v4i32 V128:$Rn, V128:$Rm))>;
6074 def : Pat<(v4i32 (mulhu V128:$Rn, V128:$Rm)),
6076 (UMULLv2i32_v2i64 (EXTRACT_SUBREG V128:$Rn, dsub),
6077 (EXTRACT_SUBREG V128:$Rm, dsub)),
6078 (UMULLv4i32_v2i64 V128:$Rn, V128:$Rm))>;
6080 // Conversions within AdvSIMD types in the same register size are free.
6081 // But because we need a consistent lane ordering, in big endian many
6082 // conversions require one or more REV instructions.
6084 // Consider a simple memory load followed by a bitconvert then a store.
6086 // v1 = BITCAST v2i32 v0 to v4i16
6089 // In big endian mode every memory access has an implicit byte swap. LDR and
6090 // STR do a 64-bit byte swap, whereas LD1/ST1 do a byte swap per lane - that
6091 // is, they treat the vector as a sequence of elements to be byte-swapped.
6092 // The two pairs of instructions are fundamentally incompatible. We've decided
6093 // to use LD1/ST1 only to simplify compiler implementation.
6095 // LD1/ST1 perform the equivalent of a sequence of LDR/STR + REV. This makes
6096 // the original code sequence:
6098 // v1 = REV v2i32 (implicit)
6099 // v2 = BITCAST v2i32 v1 to v4i16
6100 // v3 = REV v4i16 v2 (implicit)
6103 // But this is now broken - the value stored is different to the value loaded
6104 // due to lane reordering. To fix this, on every BITCAST we must perform two
6107 // v1 = REV v2i32 (implicit)
6109 // v3 = BITCAST v2i32 v2 to v4i16
6111 // v5 = REV v4i16 v4 (implicit)
6114 // This means an extra two instructions, but actually in most cases the two REV
6115 // instructions can be combined into one. For example:
6116 // (REV64_2s (REV64_4h X)) === (REV32_4h X)
6118 // There is also no 128-bit REV instruction. This must be synthesized with an
6121 // Most bitconverts require some sort of conversion. The only exceptions are:
6122 // a) Identity conversions - vNfX <-> vNiX
6123 // b) Single-lane-to-scalar - v1fX <-> fX or v1iX <-> iX
6126 // Natural vector casts (64 bit)
6127 def : Pat<(v8i8 (AArch64NvCast (v2i32 FPR64:$src))), (v8i8 FPR64:$src)>;
6128 def : Pat<(v4i16 (AArch64NvCast (v2i32 FPR64:$src))), (v4i16 FPR64:$src)>;
6129 def : Pat<(v4f16 (AArch64NvCast (v2i32 FPR64:$src))), (v4f16 FPR64:$src)>;
6130 def : Pat<(v2i32 (AArch64NvCast (v2i32 FPR64:$src))), (v2i32 FPR64:$src)>;
6131 def : Pat<(v2f32 (AArch64NvCast (v2i32 FPR64:$src))), (v2f32 FPR64:$src)>;
6132 def : Pat<(v1i64 (AArch64NvCast (v2i32 FPR64:$src))), (v1i64 FPR64:$src)>;
6134 def : Pat<(v8i8 (AArch64NvCast (v4i16 FPR64:$src))), (v8i8 FPR64:$src)>;
6135 def : Pat<(v4i16 (AArch64NvCast (v4i16 FPR64:$src))), (v4i16 FPR64:$src)>;
6136 def : Pat<(v4f16 (AArch64NvCast (v4i16 FPR64:$src))), (v4f16 FPR64:$src)>;
6137 def : Pat<(v2i32 (AArch64NvCast (v4i16 FPR64:$src))), (v2i32 FPR64:$src)>;
6138 def : Pat<(v1i64 (AArch64NvCast (v4i16 FPR64:$src))), (v1i64 FPR64:$src)>;
6140 def : Pat<(v8i8 (AArch64NvCast (v8i8 FPR64:$src))), (v8i8 FPR64:$src)>;
6141 def : Pat<(v4i16 (AArch64NvCast (v8i8 FPR64:$src))), (v4i16 FPR64:$src)>;
6142 def : Pat<(v4f16 (AArch64NvCast (v8i8 FPR64:$src))), (v4f16 FPR64:$src)>;
6143 def : Pat<(v2i32 (AArch64NvCast (v8i8 FPR64:$src))), (v2i32 FPR64:$src)>;
6144 def : Pat<(v2f32 (AArch64NvCast (v8i8 FPR64:$src))), (v2f32 FPR64:$src)>;
6145 def : Pat<(v1i64 (AArch64NvCast (v8i8 FPR64:$src))), (v1i64 FPR64:$src)>;
6147 def : Pat<(v8i8 (AArch64NvCast (f64 FPR64:$src))), (v8i8 FPR64:$src)>;
6148 def : Pat<(v4i16 (AArch64NvCast (f64 FPR64:$src))), (v4i16 FPR64:$src)>;
6149 def : Pat<(v4f16 (AArch64NvCast (f64 FPR64:$src))), (v4f16 FPR64:$src)>;
6150 def : Pat<(v2i32 (AArch64NvCast (f64 FPR64:$src))), (v2i32 FPR64:$src)>;
6151 def : Pat<(v2f32 (AArch64NvCast (f64 FPR64:$src))), (v2f32 FPR64:$src)>;
6152 def : Pat<(v1i64 (AArch64NvCast (f64 FPR64:$src))), (v1i64 FPR64:$src)>;
6153 def : Pat<(v1f64 (AArch64NvCast (f64 FPR64:$src))), (v1f64 FPR64:$src)>;
6155 def : Pat<(v8i8 (AArch64NvCast (v2f32 FPR64:$src))), (v8i8 FPR64:$src)>;
6156 def : Pat<(v4i16 (AArch64NvCast (v2f32 FPR64:$src))), (v4i16 FPR64:$src)>;
6157 def : Pat<(v2i32 (AArch64NvCast (v2f32 FPR64:$src))), (v2i32 FPR64:$src)>;
6158 def : Pat<(v2f32 (AArch64NvCast (v2f32 FPR64:$src))), (v2f32 FPR64:$src)>;
6159 def : Pat<(v1i64 (AArch64NvCast (v2f32 FPR64:$src))), (v1i64 FPR64:$src)>;
6161 // Natural vector casts (128 bit)
6162 def : Pat<(v16i8 (AArch64NvCast (v4i32 FPR128:$src))), (v16i8 FPR128:$src)>;
6163 def : Pat<(v8i16 (AArch64NvCast (v4i32 FPR128:$src))), (v8i16 FPR128:$src)>;
6164 def : Pat<(v8f16 (AArch64NvCast (v4i32 FPR128:$src))), (v8f16 FPR128:$src)>;
6165 def : Pat<(v4i32 (AArch64NvCast (v4i32 FPR128:$src))), (v4i32 FPR128:$src)>;
6166 def : Pat<(v4f32 (AArch64NvCast (v4i32 FPR128:$src))), (v4f32 FPR128:$src)>;
6167 def : Pat<(v2i64 (AArch64NvCast (v4i32 FPR128:$src))), (v2i64 FPR128:$src)>;
6168 def : Pat<(v2f64 (AArch64NvCast (v4i32 FPR128:$src))), (v2f64 FPR128:$src)>;
6170 def : Pat<(v16i8 (AArch64NvCast (v8i16 FPR128:$src))), (v16i8 FPR128:$src)>;
6171 def : Pat<(v8i16 (AArch64NvCast (v8i16 FPR128:$src))), (v8i16 FPR128:$src)>;
6172 def : Pat<(v8f16 (AArch64NvCast (v8i16 FPR128:$src))), (v8f16 FPR128:$src)>;
6173 def : Pat<(v4i32 (AArch64NvCast (v8i16 FPR128:$src))), (v4i32 FPR128:$src)>;
6174 def : Pat<(v2i64 (AArch64NvCast (v8i16 FPR128:$src))), (v2i64 FPR128:$src)>;
6175 def : Pat<(v4f32 (AArch64NvCast (v8i16 FPR128:$src))), (v4f32 FPR128:$src)>;
6176 def : Pat<(v2f64 (AArch64NvCast (v8i16 FPR128:$src))), (v2f64 FPR128:$src)>;
6178 def : Pat<(v16i8 (AArch64NvCast (v16i8 FPR128:$src))), (v16i8 FPR128:$src)>;
6179 def : Pat<(v8i16 (AArch64NvCast (v16i8 FPR128:$src))), (v8i16 FPR128:$src)>;
6180 def : Pat<(v8f16 (AArch64NvCast (v16i8 FPR128:$src))), (v8f16 FPR128:$src)>;
6181 def : Pat<(v4i32 (AArch64NvCast (v16i8 FPR128:$src))), (v4i32 FPR128:$src)>;
6182 def : Pat<(v2i64 (AArch64NvCast (v16i8 FPR128:$src))), (v2i64 FPR128:$src)>;
6183 def : Pat<(v4f32 (AArch64NvCast (v16i8 FPR128:$src))), (v4f32 FPR128:$src)>;
6184 def : Pat<(v2f64 (AArch64NvCast (v16i8 FPR128:$src))), (v2f64 FPR128:$src)>;
6186 def : Pat<(v16i8 (AArch64NvCast (v2i64 FPR128:$src))), (v16i8 FPR128:$src)>;
6187 def : Pat<(v8i16 (AArch64NvCast (v2i64 FPR128:$src))), (v8i16 FPR128:$src)>;
6188 def : Pat<(v8f16 (AArch64NvCast (v2i64 FPR128:$src))), (v8f16 FPR128:$src)>;
6189 def : Pat<(v4i32 (AArch64NvCast (v2i64 FPR128:$src))), (v4i32 FPR128:$src)>;
6190 def : Pat<(v2i64 (AArch64NvCast (v2i64 FPR128:$src))), (v2i64 FPR128:$src)>;
6191 def : Pat<(v4f32 (AArch64NvCast (v2i64 FPR128:$src))), (v4f32 FPR128:$src)>;
6192 def : Pat<(v2f64 (AArch64NvCast (v2i64 FPR128:$src))), (v2f64 FPR128:$src)>;
6194 def : Pat<(v16i8 (AArch64NvCast (v4f32 FPR128:$src))), (v16i8 FPR128:$src)>;
6195 def : Pat<(v8i16 (AArch64NvCast (v4f32 FPR128:$src))), (v8i16 FPR128:$src)>;
6196 def : Pat<(v4i32 (AArch64NvCast (v4f32 FPR128:$src))), (v4i32 FPR128:$src)>;
6197 def : Pat<(v4f32 (AArch64NvCast (v4f32 FPR128:$src))), (v4f32 FPR128:$src)>;
6198 def : Pat<(v2i64 (AArch64NvCast (v4f32 FPR128:$src))), (v2i64 FPR128:$src)>;
6199 def : Pat<(v8f16 (AArch64NvCast (v4f32 FPR128:$src))), (v8f16 FPR128:$src)>;
6200 def : Pat<(v2f64 (AArch64NvCast (v4f32 FPR128:$src))), (v2f64 FPR128:$src)>;
6202 def : Pat<(v16i8 (AArch64NvCast (v2f64 FPR128:$src))), (v16i8 FPR128:$src)>;
6203 def : Pat<(v8i16 (AArch64NvCast (v2f64 FPR128:$src))), (v8i16 FPR128:$src)>;
6204 def : Pat<(v4i32 (AArch64NvCast (v2f64 FPR128:$src))), (v4i32 FPR128:$src)>;
6205 def : Pat<(v2i64 (AArch64NvCast (v2f64 FPR128:$src))), (v2i64 FPR128:$src)>;
6206 def : Pat<(v2f64 (AArch64NvCast (v2f64 FPR128:$src))), (v2f64 FPR128:$src)>;
6207 def : Pat<(v8f16 (AArch64NvCast (v2f64 FPR128:$src))), (v8f16 FPR128:$src)>;
6208 def : Pat<(v4f32 (AArch64NvCast (v2f64 FPR128:$src))), (v4f32 FPR128:$src)>;
6210 let Predicates = [IsLE] in {
6211 def : Pat<(v8i8 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6212 def : Pat<(v4i16 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6213 def : Pat<(v2i32 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6214 def : Pat<(v4f16 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6215 def : Pat<(v2f32 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6217 def : Pat<(i64 (bitconvert (v8i8 V64:$Vn))),
6218 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6219 def : Pat<(i64 (bitconvert (v4i16 V64:$Vn))),
6220 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6221 def : Pat<(i64 (bitconvert (v2i32 V64:$Vn))),
6222 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6223 def : Pat<(i64 (bitconvert (v4f16 V64:$Vn))),
6224 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6225 def : Pat<(i64 (bitconvert (v2f32 V64:$Vn))),
6226 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6227 def : Pat<(i64 (bitconvert (v1f64 V64:$Vn))),
6228 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6230 let Predicates = [IsBE] in {
6231 def : Pat<(v8i8 (bitconvert GPR64:$Xn)),
6232 (REV64v8i8 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
6233 def : Pat<(v4i16 (bitconvert GPR64:$Xn)),
6234 (REV64v4i16 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
6235 def : Pat<(v2i32 (bitconvert GPR64:$Xn)),
6236 (REV64v2i32 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
6237 def : Pat<(v4f16 (bitconvert GPR64:$Xn)),
6238 (REV64v4i16 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
6239 def : Pat<(v2f32 (bitconvert GPR64:$Xn)),
6240 (REV64v2i32 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
6242 def : Pat<(i64 (bitconvert (v8i8 V64:$Vn))),
6243 (REV64v8i8 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
6244 def : Pat<(i64 (bitconvert (v4i16 V64:$Vn))),
6245 (REV64v4i16 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
6246 def : Pat<(i64 (bitconvert (v2i32 V64:$Vn))),
6247 (REV64v2i32 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
6248 def : Pat<(i64 (bitconvert (v4f16 V64:$Vn))),
6249 (REV64v4i16 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
6250 def : Pat<(i64 (bitconvert (v2f32 V64:$Vn))),
6251 (REV64v2i32 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
6253 def : Pat<(v1i64 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6254 def : Pat<(v1f64 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6255 def : Pat<(i64 (bitconvert (v1i64 V64:$Vn))),
6256 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6257 def : Pat<(v1i64 (scalar_to_vector GPR64:$Xn)),
6258 (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6259 def : Pat<(v1f64 (scalar_to_vector GPR64:$Xn)),
6260 (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6261 def : Pat<(v1f64 (scalar_to_vector (f64 FPR64:$Xn))), (v1f64 FPR64:$Xn)>;
6263 def : Pat<(f32 (bitconvert (i32 GPR32:$Xn))),
6264 (COPY_TO_REGCLASS GPR32:$Xn, FPR32)>;
6265 def : Pat<(i32 (bitconvert (f32 FPR32:$Xn))),
6266 (COPY_TO_REGCLASS FPR32:$Xn, GPR32)>;
6267 def : Pat<(f64 (bitconvert (i64 GPR64:$Xn))),
6268 (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
6269 def : Pat<(i64 (bitconvert (f64 FPR64:$Xn))),
6270 (COPY_TO_REGCLASS FPR64:$Xn, GPR64)>;
6271 def : Pat<(i64 (bitconvert (v1f64 V64:$Vn))),
6272 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
6274 let Predicates = [IsLE] in {
6275 def : Pat<(v1i64 (bitconvert (v2i32 FPR64:$src))), (v1i64 FPR64:$src)>;
6276 def : Pat<(v1i64 (bitconvert (v4i16 FPR64:$src))), (v1i64 FPR64:$src)>;
6277 def : Pat<(v1i64 (bitconvert (v8i8 FPR64:$src))), (v1i64 FPR64:$src)>;
6278 def : Pat<(v1i64 (bitconvert (v4f16 FPR64:$src))), (v1i64 FPR64:$src)>;
6279 def : Pat<(v1i64 (bitconvert (v2f32 FPR64:$src))), (v1i64 FPR64:$src)>;
6281 let Predicates = [IsBE] in {
6282 def : Pat<(v1i64 (bitconvert (v2i32 FPR64:$src))),
6283 (v1i64 (REV64v2i32 FPR64:$src))>;
6284 def : Pat<(v1i64 (bitconvert (v4i16 FPR64:$src))),
6285 (v1i64 (REV64v4i16 FPR64:$src))>;
6286 def : Pat<(v1i64 (bitconvert (v8i8 FPR64:$src))),
6287 (v1i64 (REV64v8i8 FPR64:$src))>;
6288 def : Pat<(v1i64 (bitconvert (v4f16 FPR64:$src))),
6289 (v1i64 (REV64v4i16 FPR64:$src))>;
6290 def : Pat<(v1i64 (bitconvert (v2f32 FPR64:$src))),
6291 (v1i64 (REV64v2i32 FPR64:$src))>;
6293 def : Pat<(v1i64 (bitconvert (v1f64 FPR64:$src))), (v1i64 FPR64:$src)>;
6294 def : Pat<(v1i64 (bitconvert (f64 FPR64:$src))), (v1i64 FPR64:$src)>;
6296 let Predicates = [IsLE] in {
6297 def : Pat<(v2i32 (bitconvert (v1i64 FPR64:$src))), (v2i32 FPR64:$src)>;
6298 def : Pat<(v2i32 (bitconvert (v4i16 FPR64:$src))), (v2i32 FPR64:$src)>;
6299 def : Pat<(v2i32 (bitconvert (v8i8 FPR64:$src))), (v2i32 FPR64:$src)>;
6300 def : Pat<(v2i32 (bitconvert (f64 FPR64:$src))), (v2i32 FPR64:$src)>;
6301 def : Pat<(v2i32 (bitconvert (v1f64 FPR64:$src))), (v2i32 FPR64:$src)>;
6302 def : Pat<(v2i32 (bitconvert (v4f16 FPR64:$src))), (v2i32 FPR64:$src)>;
6304 let Predicates = [IsBE] in {
6305 def : Pat<(v2i32 (bitconvert (v1i64 FPR64:$src))),
6306 (v2i32 (REV64v2i32 FPR64:$src))>;
6307 def : Pat<(v2i32 (bitconvert (v4i16 FPR64:$src))),
6308 (v2i32 (REV32v4i16 FPR64:$src))>;
6309 def : Pat<(v2i32 (bitconvert (v8i8 FPR64:$src))),
6310 (v2i32 (REV32v8i8 FPR64:$src))>;
6311 def : Pat<(v2i32 (bitconvert (f64 FPR64:$src))),
6312 (v2i32 (REV64v2i32 FPR64:$src))>;
6313 def : Pat<(v2i32 (bitconvert (v1f64 FPR64:$src))),
6314 (v2i32 (REV64v2i32 FPR64:$src))>;
6315 def : Pat<(v2i32 (bitconvert (v4f16 FPR64:$src))),
6316 (v2i32 (REV32v4i16 FPR64:$src))>;
6318 def : Pat<(v2i32 (bitconvert (v2f32 FPR64:$src))), (v2i32 FPR64:$src)>;
6320 let Predicates = [IsLE] in {
6321 def : Pat<(v4i16 (bitconvert (v1i64 FPR64:$src))), (v4i16 FPR64:$src)>;
6322 def : Pat<(v4i16 (bitconvert (v2i32 FPR64:$src))), (v4i16 FPR64:$src)>;
6323 def : Pat<(v4i16 (bitconvert (v8i8 FPR64:$src))), (v4i16 FPR64:$src)>;
6324 def : Pat<(v4i16 (bitconvert (f64 FPR64:$src))), (v4i16 FPR64:$src)>;
6325 def : Pat<(v4i16 (bitconvert (v2f32 FPR64:$src))), (v4i16 FPR64:$src)>;
6326 def : Pat<(v4i16 (bitconvert (v1f64 FPR64:$src))), (v4i16 FPR64:$src)>;
6328 let Predicates = [IsBE] in {
6329 def : Pat<(v4i16 (bitconvert (v1i64 FPR64:$src))),
6330 (v4i16 (REV64v4i16 FPR64:$src))>;
6331 def : Pat<(v4i16 (bitconvert (v2i32 FPR64:$src))),
6332 (v4i16 (REV32v4i16 FPR64:$src))>;
6333 def : Pat<(v4i16 (bitconvert (v8i8 FPR64:$src))),
6334 (v4i16 (REV16v8i8 FPR64:$src))>;
6335 def : Pat<(v4i16 (bitconvert (f64 FPR64:$src))),
6336 (v4i16 (REV64v4i16 FPR64:$src))>;
6337 def : Pat<(v4i16 (bitconvert (v2f32 FPR64:$src))),
6338 (v4i16 (REV32v4i16 FPR64:$src))>;
6339 def : Pat<(v4i16 (bitconvert (v1f64 FPR64:$src))),
6340 (v4i16 (REV64v4i16 FPR64:$src))>;
6342 def : Pat<(v4i16 (bitconvert (v4f16 FPR64:$src))), (v4i16 FPR64:$src)>;
6344 let Predicates = [IsLE] in {
6345 def : Pat<(v4f16 (bitconvert (v1i64 FPR64:$src))), (v4f16 FPR64:$src)>;
6346 def : Pat<(v4f16 (bitconvert (v2i32 FPR64:$src))), (v4f16 FPR64:$src)>;
6347 def : Pat<(v4f16 (bitconvert (v8i8 FPR64:$src))), (v4f16 FPR64:$src)>;
6348 def : Pat<(v4f16 (bitconvert (f64 FPR64:$src))), (v4f16 FPR64:$src)>;
6349 def : Pat<(v4f16 (bitconvert (v2f32 FPR64:$src))), (v4f16 FPR64:$src)>;
6350 def : Pat<(v4f16 (bitconvert (v1f64 FPR64:$src))), (v4f16 FPR64:$src)>;
6352 let Predicates = [IsBE] in {
6353 def : Pat<(v4f16 (bitconvert (v1i64 FPR64:$src))),
6354 (v4f16 (REV64v4i16 FPR64:$src))>;
6355 def : Pat<(v4f16 (bitconvert (v2i32 FPR64:$src))),
6356 (v4f16 (REV32v4i16 FPR64:$src))>;
6357 def : Pat<(v4f16 (bitconvert (v8i8 FPR64:$src))),
6358 (v4f16 (REV16v8i8 FPR64:$src))>;
6359 def : Pat<(v4f16 (bitconvert (f64 FPR64:$src))),
6360 (v4f16 (REV64v4i16 FPR64:$src))>;
6361 def : Pat<(v4f16 (bitconvert (v2f32 FPR64:$src))),
6362 (v4f16 (REV32v4i16 FPR64:$src))>;
6363 def : Pat<(v4f16 (bitconvert (v1f64 FPR64:$src))),
6364 (v4f16 (REV64v4i16 FPR64:$src))>;
6366 def : Pat<(v4f16 (bitconvert (v4i16 FPR64:$src))), (v4f16 FPR64:$src)>;
6368 let Predicates = [IsLE] in {
6369 def : Pat<(v8i8 (bitconvert (v1i64 FPR64:$src))), (v8i8 FPR64:$src)>;
6370 def : Pat<(v8i8 (bitconvert (v2i32 FPR64:$src))), (v8i8 FPR64:$src)>;
6371 def : Pat<(v8i8 (bitconvert (v4i16 FPR64:$src))), (v8i8 FPR64:$src)>;
6372 def : Pat<(v8i8 (bitconvert (f64 FPR64:$src))), (v8i8 FPR64:$src)>;
6373 def : Pat<(v8i8 (bitconvert (v2f32 FPR64:$src))), (v8i8 FPR64:$src)>;
6374 def : Pat<(v8i8 (bitconvert (v1f64 FPR64:$src))), (v8i8 FPR64:$src)>;
6375 def : Pat<(v8i8 (bitconvert (v4f16 FPR64:$src))), (v8i8 FPR64:$src)>;
6377 let Predicates = [IsBE] in {
6378 def : Pat<(v8i8 (bitconvert (v1i64 FPR64:$src))),
6379 (v8i8 (REV64v8i8 FPR64:$src))>;
6380 def : Pat<(v8i8 (bitconvert (v2i32 FPR64:$src))),
6381 (v8i8 (REV32v8i8 FPR64:$src))>;
6382 def : Pat<(v8i8 (bitconvert (v4i16 FPR64:$src))),
6383 (v8i8 (REV16v8i8 FPR64:$src))>;
6384 def : Pat<(v8i8 (bitconvert (f64 FPR64:$src))),
6385 (v8i8 (REV64v8i8 FPR64:$src))>;
6386 def : Pat<(v8i8 (bitconvert (v2f32 FPR64:$src))),
6387 (v8i8 (REV32v8i8 FPR64:$src))>;
6388 def : Pat<(v8i8 (bitconvert (v1f64 FPR64:$src))),
6389 (v8i8 (REV64v8i8 FPR64:$src))>;
6390 def : Pat<(v8i8 (bitconvert (v4f16 FPR64:$src))),
6391 (v8i8 (REV16v8i8 FPR64:$src))>;
6394 let Predicates = [IsLE] in {
6395 def : Pat<(f64 (bitconvert (v2i32 FPR64:$src))), (f64 FPR64:$src)>;
6396 def : Pat<(f64 (bitconvert (v4i16 FPR64:$src))), (f64 FPR64:$src)>;
6397 def : Pat<(f64 (bitconvert (v2f32 FPR64:$src))), (f64 FPR64:$src)>;
6398 def : Pat<(f64 (bitconvert (v8i8 FPR64:$src))), (f64 FPR64:$src)>;
6399 def : Pat<(f64 (bitconvert (v4f16 FPR64:$src))), (f64 FPR64:$src)>;
6401 let Predicates = [IsBE] in {
6402 def : Pat<(f64 (bitconvert (v2i32 FPR64:$src))),
6403 (f64 (REV64v2i32 FPR64:$src))>;
6404 def : Pat<(f64 (bitconvert (v4i16 FPR64:$src))),
6405 (f64 (REV64v4i16 FPR64:$src))>;
6406 def : Pat<(f64 (bitconvert (v2f32 FPR64:$src))),
6407 (f64 (REV64v2i32 FPR64:$src))>;
6408 def : Pat<(f64 (bitconvert (v8i8 FPR64:$src))),
6409 (f64 (REV64v8i8 FPR64:$src))>;
6410 def : Pat<(f64 (bitconvert (v4f16 FPR64:$src))),
6411 (f64 (REV64v4i16 FPR64:$src))>;
6413 def : Pat<(f64 (bitconvert (v1i64 FPR64:$src))), (f64 FPR64:$src)>;
6414 def : Pat<(f64 (bitconvert (v1f64 FPR64:$src))), (f64 FPR64:$src)>;
6416 let Predicates = [IsLE] in {
6417 def : Pat<(v1f64 (bitconvert (v2i32 FPR64:$src))), (v1f64 FPR64:$src)>;
6418 def : Pat<(v1f64 (bitconvert (v4i16 FPR64:$src))), (v1f64 FPR64:$src)>;
6419 def : Pat<(v1f64 (bitconvert (v8i8 FPR64:$src))), (v1f64 FPR64:$src)>;
6420 def : Pat<(v1f64 (bitconvert (v2f32 FPR64:$src))), (v1f64 FPR64:$src)>;
6421 def : Pat<(v1f64 (bitconvert (v4f16 FPR64:$src))), (v1f64 FPR64:$src)>;
6423 let Predicates = [IsBE] in {
6424 def : Pat<(v1f64 (bitconvert (v2i32 FPR64:$src))),
6425 (v1f64 (REV64v2i32 FPR64:$src))>;
6426 def : Pat<(v1f64 (bitconvert (v4i16 FPR64:$src))),
6427 (v1f64 (REV64v4i16 FPR64:$src))>;
6428 def : Pat<(v1f64 (bitconvert (v8i8 FPR64:$src))),
6429 (v1f64 (REV64v8i8 FPR64:$src))>;
6430 def : Pat<(v1f64 (bitconvert (v2f32 FPR64:$src))),
6431 (v1f64 (REV64v2i32 FPR64:$src))>;
6432 def : Pat<(v1f64 (bitconvert (v4f16 FPR64:$src))),
6433 (v1f64 (REV64v4i16 FPR64:$src))>;
6435 def : Pat<(v1f64 (bitconvert (v1i64 FPR64:$src))), (v1f64 FPR64:$src)>;
6436 def : Pat<(v1f64 (bitconvert (f64 FPR64:$src))), (v1f64 FPR64:$src)>;
6438 let Predicates = [IsLE] in {
6439 def : Pat<(v2f32 (bitconvert (v1i64 FPR64:$src))), (v2f32 FPR64:$src)>;
6440 def : Pat<(v2f32 (bitconvert (v4i16 FPR64:$src))), (v2f32 FPR64:$src)>;
6441 def : Pat<(v2f32 (bitconvert (v8i8 FPR64:$src))), (v2f32 FPR64:$src)>;
6442 def : Pat<(v2f32 (bitconvert (v1f64 FPR64:$src))), (v2f32 FPR64:$src)>;
6443 def : Pat<(v2f32 (bitconvert (f64 FPR64:$src))), (v2f32 FPR64:$src)>;
6444 def : Pat<(v2f32 (bitconvert (v4f16 FPR64:$src))), (v2f32 FPR64:$src)>;
6446 let Predicates = [IsBE] in {
6447 def : Pat<(v2f32 (bitconvert (v1i64 FPR64:$src))),
6448 (v2f32 (REV64v2i32 FPR64:$src))>;
6449 def : Pat<(v2f32 (bitconvert (v4i16 FPR64:$src))),
6450 (v2f32 (REV32v4i16 FPR64:$src))>;
6451 def : Pat<(v2f32 (bitconvert (v8i8 FPR64:$src))),
6452 (v2f32 (REV32v8i8 FPR64:$src))>;
6453 def : Pat<(v2f32 (bitconvert (v1f64 FPR64:$src))),
6454 (v2f32 (REV64v2i32 FPR64:$src))>;
6455 def : Pat<(v2f32 (bitconvert (f64 FPR64:$src))),
6456 (v2f32 (REV64v2i32 FPR64:$src))>;
6457 def : Pat<(v2f32 (bitconvert (v4f16 FPR64:$src))),
6458 (v2f32 (REV32v4i16 FPR64:$src))>;
6460 def : Pat<(v2f32 (bitconvert (v2i32 FPR64:$src))), (v2f32 FPR64:$src)>;
6462 let Predicates = [IsLE] in {
6463 def : Pat<(f128 (bitconvert (v2i64 FPR128:$src))), (f128 FPR128:$src)>;
6464 def : Pat<(f128 (bitconvert (v4i32 FPR128:$src))), (f128 FPR128:$src)>;
6465 def : Pat<(f128 (bitconvert (v8i16 FPR128:$src))), (f128 FPR128:$src)>;
6466 def : Pat<(f128 (bitconvert (v2f64 FPR128:$src))), (f128 FPR128:$src)>;
6467 def : Pat<(f128 (bitconvert (v4f32 FPR128:$src))), (f128 FPR128:$src)>;
6468 def : Pat<(f128 (bitconvert (v8f16 FPR128:$src))), (f128 FPR128:$src)>;
6469 def : Pat<(f128 (bitconvert (v16i8 FPR128:$src))), (f128 FPR128:$src)>;
6471 let Predicates = [IsBE] in {
6472 def : Pat<(f128 (bitconvert (v2i64 FPR128:$src))),
6473 (f128 (EXTv16i8 FPR128:$src, FPR128:$src, (i32 8)))>;
6474 def : Pat<(f128 (bitconvert (v4i32 FPR128:$src))),
6475 (f128 (EXTv16i8 (REV64v4i32 FPR128:$src),
6476 (REV64v4i32 FPR128:$src), (i32 8)))>;
6477 def : Pat<(f128 (bitconvert (v8i16 FPR128:$src))),
6478 (f128 (EXTv16i8 (REV64v8i16 FPR128:$src),
6479 (REV64v8i16 FPR128:$src), (i32 8)))>;
6480 def : Pat<(f128 (bitconvert (v8f16 FPR128:$src))),
6481 (f128 (EXTv16i8 (REV64v8i16 FPR128:$src),
6482 (REV64v8i16 FPR128:$src), (i32 8)))>;
6483 def : Pat<(f128 (bitconvert (v2f64 FPR128:$src))),
6484 (f128 (EXTv16i8 FPR128:$src, FPR128:$src, (i32 8)))>;
6485 def : Pat<(f128 (bitconvert (v4f32 FPR128:$src))),
6486 (f128 (EXTv16i8 (REV64v4i32 FPR128:$src),
6487 (REV64v4i32 FPR128:$src), (i32 8)))>;
6488 def : Pat<(f128 (bitconvert (v16i8 FPR128:$src))),
6489 (f128 (EXTv16i8 (REV64v16i8 FPR128:$src),
6490 (REV64v16i8 FPR128:$src), (i32 8)))>;
6493 let Predicates = [IsLE] in {
6494 def : Pat<(v2f64 (bitconvert (f128 FPR128:$src))), (v2f64 FPR128:$src)>;
6495 def : Pat<(v2f64 (bitconvert (v4i32 FPR128:$src))), (v2f64 FPR128:$src)>;
6496 def : Pat<(v2f64 (bitconvert (v8i16 FPR128:$src))), (v2f64 FPR128:$src)>;
6497 def : Pat<(v2f64 (bitconvert (v8f16 FPR128:$src))), (v2f64 FPR128:$src)>;
6498 def : Pat<(v2f64 (bitconvert (v16i8 FPR128:$src))), (v2f64 FPR128:$src)>;
6499 def : Pat<(v2f64 (bitconvert (v4f32 FPR128:$src))), (v2f64 FPR128:$src)>;
6501 let Predicates = [IsBE] in {
6502 def : Pat<(v2f64 (bitconvert (f128 FPR128:$src))),
6503 (v2f64 (EXTv16i8 FPR128:$src,
6504 FPR128:$src, (i32 8)))>;
6505 def : Pat<(v2f64 (bitconvert (v4i32 FPR128:$src))),
6506 (v2f64 (REV64v4i32 FPR128:$src))>;
6507 def : Pat<(v2f64 (bitconvert (v8i16 FPR128:$src))),
6508 (v2f64 (REV64v8i16 FPR128:$src))>;
6509 def : Pat<(v2f64 (bitconvert (v8f16 FPR128:$src))),
6510 (v2f64 (REV64v8i16 FPR128:$src))>;
6511 def : Pat<(v2f64 (bitconvert (v16i8 FPR128:$src))),
6512 (v2f64 (REV64v16i8 FPR128:$src))>;
6513 def : Pat<(v2f64 (bitconvert (v4f32 FPR128:$src))),
6514 (v2f64 (REV64v4i32 FPR128:$src))>;
6516 def : Pat<(v2f64 (bitconvert (v2i64 FPR128:$src))), (v2f64 FPR128:$src)>;
6518 let Predicates = [IsLE] in {
6519 def : Pat<(v4f32 (bitconvert (f128 FPR128:$src))), (v4f32 FPR128:$src)>;
6520 def : Pat<(v4f32 (bitconvert (v8i16 FPR128:$src))), (v4f32 FPR128:$src)>;
6521 def : Pat<(v4f32 (bitconvert (v8f16 FPR128:$src))), (v4f32 FPR128:$src)>;
6522 def : Pat<(v4f32 (bitconvert (v16i8 FPR128:$src))), (v4f32 FPR128:$src)>;
6523 def : Pat<(v4f32 (bitconvert (v2i64 FPR128:$src))), (v4f32 FPR128:$src)>;
6524 def : Pat<(v4f32 (bitconvert (v2f64 FPR128:$src))), (v4f32 FPR128:$src)>;
6526 let Predicates = [IsBE] in {
6527 def : Pat<(v4f32 (bitconvert (f128 FPR128:$src))),
6528 (v4f32 (EXTv16i8 (REV64v4i32 FPR128:$src),
6529 (REV64v4i32 FPR128:$src), (i32 8)))>;
6530 def : Pat<(v4f32 (bitconvert (v8i16 FPR128:$src))),
6531 (v4f32 (REV32v8i16 FPR128:$src))>;
6532 def : Pat<(v4f32 (bitconvert (v8f16 FPR128:$src))),
6533 (v4f32 (REV32v8i16 FPR128:$src))>;
6534 def : Pat<(v4f32 (bitconvert (v16i8 FPR128:$src))),
6535 (v4f32 (REV32v16i8 FPR128:$src))>;
6536 def : Pat<(v4f32 (bitconvert (v2i64 FPR128:$src))),
6537 (v4f32 (REV64v4i32 FPR128:$src))>;
6538 def : Pat<(v4f32 (bitconvert (v2f64 FPR128:$src))),
6539 (v4f32 (REV64v4i32 FPR128:$src))>;
6541 def : Pat<(v4f32 (bitconvert (v4i32 FPR128:$src))), (v4f32 FPR128:$src)>;
6543 let Predicates = [IsLE] in {
6544 def : Pat<(v2i64 (bitconvert (f128 FPR128:$src))), (v2i64 FPR128:$src)>;
6545 def : Pat<(v2i64 (bitconvert (v4i32 FPR128:$src))), (v2i64 FPR128:$src)>;
6546 def : Pat<(v2i64 (bitconvert (v8i16 FPR128:$src))), (v2i64 FPR128:$src)>;
6547 def : Pat<(v2i64 (bitconvert (v16i8 FPR128:$src))), (v2i64 FPR128:$src)>;
6548 def : Pat<(v2i64 (bitconvert (v4f32 FPR128:$src))), (v2i64 FPR128:$src)>;
6549 def : Pat<(v2i64 (bitconvert (v8f16 FPR128:$src))), (v2i64 FPR128:$src)>;
6551 let Predicates = [IsBE] in {
6552 def : Pat<(v2i64 (bitconvert (f128 FPR128:$src))),
6553 (v2i64 (EXTv16i8 FPR128:$src,
6554 FPR128:$src, (i32 8)))>;
6555 def : Pat<(v2i64 (bitconvert (v4i32 FPR128:$src))),
6556 (v2i64 (REV64v4i32 FPR128:$src))>;
6557 def : Pat<(v2i64 (bitconvert (v8i16 FPR128:$src))),
6558 (v2i64 (REV64v8i16 FPR128:$src))>;
6559 def : Pat<(v2i64 (bitconvert (v16i8 FPR128:$src))),
6560 (v2i64 (REV64v16i8 FPR128:$src))>;
6561 def : Pat<(v2i64 (bitconvert (v4f32 FPR128:$src))),
6562 (v2i64 (REV64v4i32 FPR128:$src))>;
6563 def : Pat<(v2i64 (bitconvert (v8f16 FPR128:$src))),
6564 (v2i64 (REV64v8i16 FPR128:$src))>;
6566 def : Pat<(v2i64 (bitconvert (v2f64 FPR128:$src))), (v2i64 FPR128:$src)>;
6568 let Predicates = [IsLE] in {
6569 def : Pat<(v4i32 (bitconvert (f128 FPR128:$src))), (v4i32 FPR128:$src)>;
6570 def : Pat<(v4i32 (bitconvert (v2i64 FPR128:$src))), (v4i32 FPR128:$src)>;
6571 def : Pat<(v4i32 (bitconvert (v8i16 FPR128:$src))), (v4i32 FPR128:$src)>;
6572 def : Pat<(v4i32 (bitconvert (v16i8 FPR128:$src))), (v4i32 FPR128:$src)>;
6573 def : Pat<(v4i32 (bitconvert (v2f64 FPR128:$src))), (v4i32 FPR128:$src)>;
6574 def : Pat<(v4i32 (bitconvert (v8f16 FPR128:$src))), (v4i32 FPR128:$src)>;
6576 let Predicates = [IsBE] in {
6577 def : Pat<(v4i32 (bitconvert (f128 FPR128:$src))),
6578 (v4i32 (EXTv16i8 (REV64v4i32 FPR128:$src),
6579 (REV64v4i32 FPR128:$src),
6581 def : Pat<(v4i32 (bitconvert (v2i64 FPR128:$src))),
6582 (v4i32 (REV64v4i32 FPR128:$src))>;
6583 def : Pat<(v4i32 (bitconvert (v8i16 FPR128:$src))),
6584 (v4i32 (REV32v8i16 FPR128:$src))>;
6585 def : Pat<(v4i32 (bitconvert (v16i8 FPR128:$src))),
6586 (v4i32 (REV32v16i8 FPR128:$src))>;
6587 def : Pat<(v4i32 (bitconvert (v2f64 FPR128:$src))),
6588 (v4i32 (REV64v4i32 FPR128:$src))>;
6589 def : Pat<(v4i32 (bitconvert (v8f16 FPR128:$src))),
6590 (v4i32 (REV32v8i16 FPR128:$src))>;
6592 def : Pat<(v4i32 (bitconvert (v4f32 FPR128:$src))), (v4i32 FPR128:$src)>;
6594 let Predicates = [IsLE] in {
6595 def : Pat<(v8i16 (bitconvert (f128 FPR128:$src))), (v8i16 FPR128:$src)>;
6596 def : Pat<(v8i16 (bitconvert (v2i64 FPR128:$src))), (v8i16 FPR128:$src)>;
6597 def : Pat<(v8i16 (bitconvert (v4i32 FPR128:$src))), (v8i16 FPR128:$src)>;
6598 def : Pat<(v8i16 (bitconvert (v16i8 FPR128:$src))), (v8i16 FPR128:$src)>;
6599 def : Pat<(v8i16 (bitconvert (v2f64 FPR128:$src))), (v8i16 FPR128:$src)>;
6600 def : Pat<(v8i16 (bitconvert (v4f32 FPR128:$src))), (v8i16 FPR128:$src)>;
6602 let Predicates = [IsBE] in {
6603 def : Pat<(v8i16 (bitconvert (f128 FPR128:$src))),
6604 (v8i16 (EXTv16i8 (REV64v8i16 FPR128:$src),
6605 (REV64v8i16 FPR128:$src),
6607 def : Pat<(v8i16 (bitconvert (v2i64 FPR128:$src))),
6608 (v8i16 (REV64v8i16 FPR128:$src))>;
6609 def : Pat<(v8i16 (bitconvert (v4i32 FPR128:$src))),
6610 (v8i16 (REV32v8i16 FPR128:$src))>;
6611 def : Pat<(v8i16 (bitconvert (v16i8 FPR128:$src))),
6612 (v8i16 (REV16v16i8 FPR128:$src))>;
6613 def : Pat<(v8i16 (bitconvert (v2f64 FPR128:$src))),
6614 (v8i16 (REV64v8i16 FPR128:$src))>;
6615 def : Pat<(v8i16 (bitconvert (v4f32 FPR128:$src))),
6616 (v8i16 (REV32v8i16 FPR128:$src))>;
6618 def : Pat<(v8i16 (bitconvert (v8f16 FPR128:$src))), (v8i16 FPR128:$src)>;
6620 let Predicates = [IsLE] in {
6621 def : Pat<(v8f16 (bitconvert (f128 FPR128:$src))), (v8f16 FPR128:$src)>;
6622 def : Pat<(v8f16 (bitconvert (v2i64 FPR128:$src))), (v8f16 FPR128:$src)>;
6623 def : Pat<(v8f16 (bitconvert (v4i32 FPR128:$src))), (v8f16 FPR128:$src)>;
6624 def : Pat<(v8f16 (bitconvert (v16i8 FPR128:$src))), (v8f16 FPR128:$src)>;
6625 def : Pat<(v8f16 (bitconvert (v2f64 FPR128:$src))), (v8f16 FPR128:$src)>;
6626 def : Pat<(v8f16 (bitconvert (v4f32 FPR128:$src))), (v8f16 FPR128:$src)>;
6628 let Predicates = [IsBE] in {
6629 def : Pat<(v8f16 (bitconvert (f128 FPR128:$src))),
6630 (v8f16 (EXTv16i8 (REV64v8i16 FPR128:$src),
6631 (REV64v8i16 FPR128:$src),
6633 def : Pat<(v8f16 (bitconvert (v2i64 FPR128:$src))),
6634 (v8f16 (REV64v8i16 FPR128:$src))>;
6635 def : Pat<(v8f16 (bitconvert (v4i32 FPR128:$src))),
6636 (v8f16 (REV32v8i16 FPR128:$src))>;
6637 def : Pat<(v8f16 (bitconvert (v16i8 FPR128:$src))),
6638 (v8f16 (REV16v16i8 FPR128:$src))>;
6639 def : Pat<(v8f16 (bitconvert (v2f64 FPR128:$src))),
6640 (v8f16 (REV64v8i16 FPR128:$src))>;
6641 def : Pat<(v8f16 (bitconvert (v4f32 FPR128:$src))),
6642 (v8f16 (REV32v8i16 FPR128:$src))>;
6644 def : Pat<(v8f16 (bitconvert (v8i16 FPR128:$src))), (v8f16 FPR128:$src)>;
6646 let Predicates = [IsLE] in {
6647 def : Pat<(v16i8 (bitconvert (f128 FPR128:$src))), (v16i8 FPR128:$src)>;
6648 def : Pat<(v16i8 (bitconvert (v2i64 FPR128:$src))), (v16i8 FPR128:$src)>;
6649 def : Pat<(v16i8 (bitconvert (v4i32 FPR128:$src))), (v16i8 FPR128:$src)>;
6650 def : Pat<(v16i8 (bitconvert (v8i16 FPR128:$src))), (v16i8 FPR128:$src)>;
6651 def : Pat<(v16i8 (bitconvert (v2f64 FPR128:$src))), (v16i8 FPR128:$src)>;
6652 def : Pat<(v16i8 (bitconvert (v4f32 FPR128:$src))), (v16i8 FPR128:$src)>;
6653 def : Pat<(v16i8 (bitconvert (v8f16 FPR128:$src))), (v16i8 FPR128:$src)>;
6655 let Predicates = [IsBE] in {
6656 def : Pat<(v16i8 (bitconvert (f128 FPR128:$src))),
6657 (v16i8 (EXTv16i8 (REV64v16i8 FPR128:$src),
6658 (REV64v16i8 FPR128:$src),
6660 def : Pat<(v16i8 (bitconvert (v2i64 FPR128:$src))),
6661 (v16i8 (REV64v16i8 FPR128:$src))>;
6662 def : Pat<(v16i8 (bitconvert (v4i32 FPR128:$src))),
6663 (v16i8 (REV32v16i8 FPR128:$src))>;
6664 def : Pat<(v16i8 (bitconvert (v8i16 FPR128:$src))),
6665 (v16i8 (REV16v16i8 FPR128:$src))>;
6666 def : Pat<(v16i8 (bitconvert (v2f64 FPR128:$src))),
6667 (v16i8 (REV64v16i8 FPR128:$src))>;
6668 def : Pat<(v16i8 (bitconvert (v4f32 FPR128:$src))),
6669 (v16i8 (REV32v16i8 FPR128:$src))>;
6670 def : Pat<(v16i8 (bitconvert (v8f16 FPR128:$src))),
6671 (v16i8 (REV16v16i8 FPR128:$src))>;
6674 def : Pat<(v4i16 (extract_subvector V128:$Rn, (i64 0))),
6675 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6676 def : Pat<(v8i8 (extract_subvector V128:$Rn, (i64 0))),
6677 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6678 def : Pat<(v2f32 (extract_subvector V128:$Rn, (i64 0))),
6679 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6680 def : Pat<(v4f16 (extract_subvector V128:$Rn, (i64 0))),
6681 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6682 def : Pat<(v2i32 (extract_subvector V128:$Rn, (i64 0))),
6683 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6684 def : Pat<(v1i64 (extract_subvector V128:$Rn, (i64 0))),
6685 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6686 def : Pat<(v1f64 (extract_subvector V128:$Rn, (i64 0))),
6687 (EXTRACT_SUBREG V128:$Rn, dsub)>;
6689 def : Pat<(v8i8 (extract_subvector (v16i8 FPR128:$Rn), (i64 1))),
6690 (EXTRACT_SUBREG (DUPv2i64lane FPR128:$Rn, 1), dsub)>;
6691 def : Pat<(v4i16 (extract_subvector (v8i16 FPR128:$Rn), (i64 1))),
6692 (EXTRACT_SUBREG (DUPv2i64lane FPR128:$Rn, 1), dsub)>;
6693 def : Pat<(v2i32 (extract_subvector (v4i32 FPR128:$Rn), (i64 1))),
6694 (EXTRACT_SUBREG (DUPv2i64lane FPR128:$Rn, 1), dsub)>;
6695 def : Pat<(v1i64 (extract_subvector (v2i64 FPR128:$Rn), (i64 1))),
6696 (EXTRACT_SUBREG (DUPv2i64lane FPR128:$Rn, 1), dsub)>;
6698 // A 64-bit subvector insert to the first 128-bit vector position
6699 // is a subregister copy that needs no instruction.
6700 multiclass InsertSubvectorUndef<ValueType Ty> {
6701 def : Pat<(insert_subvector undef, (v1i64 FPR64:$src), (Ty 0)),
6702 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6703 def : Pat<(insert_subvector undef, (v1f64 FPR64:$src), (Ty 0)),
6704 (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6705 def : Pat<(insert_subvector undef, (v2i32 FPR64:$src), (Ty 0)),
6706 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6707 def : Pat<(insert_subvector undef, (v2f32 FPR64:$src), (Ty 0)),
6708 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6709 def : Pat<(insert_subvector undef, (v4i16 FPR64:$src), (Ty 0)),
6710 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6711 def : Pat<(insert_subvector undef, (v4f16 FPR64:$src), (Ty 0)),
6712 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6713 def : Pat<(insert_subvector undef, (v8i8 FPR64:$src), (Ty 0)),
6714 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
6717 defm : InsertSubvectorUndef<i32>;
6718 defm : InsertSubvectorUndef<i64>;
6720 // Use pair-wise add instructions when summing up the lanes for v2f64, v2i64
6722 def : Pat<(i64 (add (vector_extract (v2i64 FPR128:$Rn), (i64 0)),
6723 (vector_extract (v2i64 FPR128:$Rn), (i64 1)))),
6724 (i64 (ADDPv2i64p (v2i64 FPR128:$Rn)))>;
6725 def : Pat<(f64 (fadd (vector_extract (v2f64 FPR128:$Rn), (i64 0)),
6726 (vector_extract (v2f64 FPR128:$Rn), (i64 1)))),
6727 (f64 (FADDPv2i64p (v2f64 FPR128:$Rn)))>;
6728 // vector_extract on 64-bit vectors gets promoted to a 128 bit vector,
6729 // so we match on v4f32 here, not v2f32. This will also catch adding
6730 // the low two lanes of a true v4f32 vector.
6731 def : Pat<(fadd (vector_extract (v4f32 FPR128:$Rn), (i64 0)),
6732 (vector_extract (v4f32 FPR128:$Rn), (i64 1))),
6733 (f32 (FADDPv2i32p (EXTRACT_SUBREG FPR128:$Rn, dsub)))>;
6735 // Scalar 64-bit shifts in FPR64 registers.
6736 def : Pat<(i64 (int_aarch64_neon_sshl (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
6737 (SSHLv1i64 FPR64:$Rn, FPR64:$Rm)>;
6738 def : Pat<(i64 (int_aarch64_neon_ushl (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
6739 (USHLv1i64 FPR64:$Rn, FPR64:$Rm)>;
6740 def : Pat<(i64 (int_aarch64_neon_srshl (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
6741 (SRSHLv1i64 FPR64:$Rn, FPR64:$Rm)>;
6742 def : Pat<(i64 (int_aarch64_neon_urshl (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
6743 (URSHLv1i64 FPR64:$Rn, FPR64:$Rm)>;
6745 // Patterns for nontemporal/no-allocate stores.
6746 // We have to resort to tricks to turn a single-input store into a store pair,
6747 // because there is no single-input nontemporal store, only STNP.
6748 let Predicates = [IsLE] in {
6749 let AddedComplexity = 15 in {
6750 class NTStore128Pat<ValueType VT> :
6751 Pat<(nontemporalstore (VT FPR128:$Rt),
6752 (am_indexed7s64 GPR64sp:$Rn, simm7s8:$offset)),
6753 (STNPDi (EXTRACT_SUBREG FPR128:$Rt, dsub),
6754 (CPYi64 FPR128:$Rt, (i64 1)),
6755 GPR64sp:$Rn, simm7s8:$offset)>;
6757 def : NTStore128Pat<v2i64>;
6758 def : NTStore128Pat<v4i32>;
6759 def : NTStore128Pat<v8i16>;
6760 def : NTStore128Pat<v16i8>;
6762 class NTStore64Pat<ValueType VT> :
6763 Pat<(nontemporalstore (VT FPR64:$Rt),
6764 (am_indexed7s32 GPR64sp:$Rn, simm7s4:$offset)),
6765 (STNPSi (EXTRACT_SUBREG FPR64:$Rt, ssub),
6766 (CPYi32 (SUBREG_TO_REG (i64 0), FPR64:$Rt, dsub), (i64 1)),
6767 GPR64sp:$Rn, simm7s4:$offset)>;
6769 // FIXME: Shouldn't v1f64 loads/stores be promoted to v1i64?
6770 def : NTStore64Pat<v1f64>;
6771 def : NTStore64Pat<v1i64>;
6772 def : NTStore64Pat<v2i32>;
6773 def : NTStore64Pat<v4i16>;
6774 def : NTStore64Pat<v8i8>;
6776 def : Pat<(nontemporalstore GPR64:$Rt,
6777 (am_indexed7s32 GPR64sp:$Rn, simm7s4:$offset)),
6778 (STNPWi (EXTRACT_SUBREG GPR64:$Rt, sub_32),
6779 (EXTRACT_SUBREG (UBFMXri GPR64:$Rt, 32, 63), sub_32),
6780 GPR64sp:$Rn, simm7s4:$offset)>;
6781 } // AddedComplexity=10
6782 } // Predicates = [IsLE]
6784 // Tail call return handling. These are all compiler pseudo-instructions,
6785 // so no encoding information or anything like that.
6786 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in {
6787 def TCRETURNdi : Pseudo<(outs), (ins i64imm:$dst, i32imm:$FPDiff), []>,
6788 Sched<[WriteBrReg]>;
6789 def TCRETURNri : Pseudo<(outs), (ins tcGPR64:$dst, i32imm:$FPDiff), []>,
6790 Sched<[WriteBrReg]>;
6791 // Indirect tail-call with any register allowed, used by MachineOutliner when
6792 // this is proven safe.
6793 // FIXME: If we have to add any more hacks like this, we should instead relax
6794 // some verifier checks for outlined functions.
6795 def TCRETURNriALL : Pseudo<(outs), (ins GPR64:$dst, i32imm:$FPDiff), []>,
6796 Sched<[WriteBrReg]>;
6797 // Indirect tail-call limited to only use registers (x16 and x17) which are
6798 // allowed to tail-call a "BTI c" instruction.
6799 def TCRETURNriBTI : Pseudo<(outs), (ins rtcGPR64:$dst, i32imm:$FPDiff), []>,
6800 Sched<[WriteBrReg]>;
6803 def : Pat<(AArch64tcret tcGPR64:$dst, (i32 timm:$FPDiff)),
6804 (TCRETURNri tcGPR64:$dst, imm:$FPDiff)>,
6805 Requires<[NotUseBTI]>;
6806 def : Pat<(AArch64tcret rtcGPR64:$dst, (i32 timm:$FPDiff)),
6807 (TCRETURNriBTI rtcGPR64:$dst, imm:$FPDiff)>,
6809 def : Pat<(AArch64tcret tglobaladdr:$dst, (i32 timm:$FPDiff)),
6810 (TCRETURNdi texternalsym:$dst, imm:$FPDiff)>;
6811 def : Pat<(AArch64tcret texternalsym:$dst, (i32 timm:$FPDiff)),
6812 (TCRETURNdi texternalsym:$dst, imm:$FPDiff)>;
6814 def MOVMCSym : Pseudo<(outs GPR64:$dst), (ins i64imm:$sym), []>, Sched<[]>;
6815 def : Pat<(i64 (AArch64LocalRecover mcsym:$sym)), (MOVMCSym mcsym:$sym)>;
6817 include "AArch64InstrAtomics.td"
6818 include "AArch64SVEInstrInfo.td"