1 //=- AArch64InstrInfo.td - Describe the AArch64 Instructions -*- tablegen -*-=//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // AArch64 Instruction definitions.
12 //===----------------------------------------------------------------------===//
14 //===----------------------------------------------------------------------===//
15 // ARM Instruction Predicate Definitions.
17 def HasFPARMv8 : Predicate<"Subtarget->hasFPARMv8()">,
18 AssemblerPredicate<"FeatureFPARMv8", "fp-armv8">;
19 def HasNEON : Predicate<"Subtarget->hasNEON()">,
20 AssemblerPredicate<"FeatureNEON", "neon">;
21 def HasCrypto : Predicate<"Subtarget->hasCrypto()">,
22 AssemblerPredicate<"FeatureCrypto", "crypto">;
23 def HasCRC : Predicate<"Subtarget->hasCRC()">,
24 AssemblerPredicate<"FeatureCRC", "crc">;
25 def IsLE : Predicate<"Subtarget->isLittleEndian()">;
26 def IsBE : Predicate<"!Subtarget->isLittleEndian()">;
27 def IsCyclone : Predicate<"Subtarget->isCyclone()">;
29 //===----------------------------------------------------------------------===//
30 // AArch64-specific DAG Nodes.
33 // SDTBinaryArithWithFlagsOut - RES1, FLAGS = op LHS, RHS
34 def SDTBinaryArithWithFlagsOut : SDTypeProfile<2, 2,
37 SDTCisInt<0>, SDTCisVT<1, i32>]>;
39 // SDTBinaryArithWithFlagsIn - RES1, FLAGS = op LHS, RHS, FLAGS
40 def SDTBinaryArithWithFlagsIn : SDTypeProfile<1, 3,
46 // SDTBinaryArithWithFlagsInOut - RES1, FLAGS = op LHS, RHS, FLAGS
47 def SDTBinaryArithWithFlagsInOut : SDTypeProfile<2, 3,
54 def SDT_AArch64Brcond : SDTypeProfile<0, 3,
55 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i32>,
57 def SDT_AArch64cbz : SDTypeProfile<0, 2, [SDTCisInt<0>, SDTCisVT<1, OtherVT>]>;
58 def SDT_AArch64tbz : SDTypeProfile<0, 3, [SDTCisInt<0>, SDTCisInt<1>,
59 SDTCisVT<2, OtherVT>]>;
62 def SDT_AArch64CSel : SDTypeProfile<1, 4,
67 def SDT_AArch64FCmp : SDTypeProfile<0, 2,
70 def SDT_AArch64Dup : SDTypeProfile<1, 1, [SDTCisVec<0>]>;
71 def SDT_AArch64DupLane : SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisInt<2>]>;
72 def SDT_AArch64Zip : SDTypeProfile<1, 2, [SDTCisVec<0>,
75 def SDT_AArch64MOVIedit : SDTypeProfile<1, 1, [SDTCisInt<1>]>;
76 def SDT_AArch64MOVIshift : SDTypeProfile<1, 2, [SDTCisInt<1>, SDTCisInt<2>]>;
77 def SDT_AArch64vecimm : SDTypeProfile<1, 3, [SDTCisVec<0>, SDTCisSameAs<0,1>,
78 SDTCisInt<2>, SDTCisInt<3>]>;
79 def SDT_AArch64UnaryVec: SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisSameAs<0,1>]>;
80 def SDT_AArch64ExtVec: SDTypeProfile<1, 3, [SDTCisVec<0>, SDTCisSameAs<0,1>,
81 SDTCisSameAs<0,2>, SDTCisInt<3>]>;
82 def SDT_AArch64vshift : SDTypeProfile<1, 2, [SDTCisSameAs<0,1>, SDTCisInt<2>]>;
84 def SDT_AArch64unvec : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisSameAs<0,1>]>;
85 def SDT_AArch64fcmpz : SDTypeProfile<1, 1, []>;
86 def SDT_AArch64fcmp : SDTypeProfile<1, 2, [SDTCisSameAs<1,2>]>;
87 def SDT_AArch64binvec : SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisSameAs<0,1>,
89 def SDT_AArch64trivec : SDTypeProfile<1, 3, [SDTCisVec<0>, SDTCisSameAs<0,1>,
92 def SDT_AArch64TCRET : SDTypeProfile<0, 2, [SDTCisPtrTy<0>]>;
93 def SDT_AArch64PREFETCH : SDTypeProfile<0, 2, [SDTCisVT<0, i32>, SDTCisPtrTy<1>]>;
95 def SDT_AArch64ITOF : SDTypeProfile<1, 1, [SDTCisFP<0>, SDTCisSameAs<0,1>]>;
97 def SDT_AArch64TLSDescCall : SDTypeProfile<0, -2, [SDTCisPtrTy<0>,
99 def SDT_AArch64WrapperLarge : SDTypeProfile<1, 4,
100 [SDTCisVT<0, i64>, SDTCisVT<1, i32>,
101 SDTCisSameAs<1, 2>, SDTCisSameAs<1, 3>,
102 SDTCisSameAs<1, 4>]>;
106 def AArch64adrp : SDNode<"AArch64ISD::ADRP", SDTIntUnaryOp, []>;
107 def AArch64addlow : SDNode<"AArch64ISD::ADDlow", SDTIntBinOp, []>;
108 def AArch64LOADgot : SDNode<"AArch64ISD::LOADgot", SDTIntUnaryOp>;
109 def AArch64callseq_start : SDNode<"ISD::CALLSEQ_START",
110 SDCallSeqStart<[ SDTCisVT<0, i32> ]>,
111 [SDNPHasChain, SDNPOutGlue]>;
112 def AArch64callseq_end : SDNode<"ISD::CALLSEQ_END",
113 SDCallSeqEnd<[ SDTCisVT<0, i32>,
115 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
116 def AArch64call : SDNode<"AArch64ISD::CALL",
117 SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>,
118 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
120 def AArch64brcond : SDNode<"AArch64ISD::BRCOND", SDT_AArch64Brcond,
122 def AArch64cbz : SDNode<"AArch64ISD::CBZ", SDT_AArch64cbz,
124 def AArch64cbnz : SDNode<"AArch64ISD::CBNZ", SDT_AArch64cbz,
126 def AArch64tbz : SDNode<"AArch64ISD::TBZ", SDT_AArch64tbz,
128 def AArch64tbnz : SDNode<"AArch64ISD::TBNZ", SDT_AArch64tbz,
132 def AArch64csel : SDNode<"AArch64ISD::CSEL", SDT_AArch64CSel>;
133 def AArch64csinv : SDNode<"AArch64ISD::CSINV", SDT_AArch64CSel>;
134 def AArch64csneg : SDNode<"AArch64ISD::CSNEG", SDT_AArch64CSel>;
135 def AArch64csinc : SDNode<"AArch64ISD::CSINC", SDT_AArch64CSel>;
136 def AArch64retflag : SDNode<"AArch64ISD::RET_FLAG", SDTNone,
137 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
138 def AArch64adc : SDNode<"AArch64ISD::ADC", SDTBinaryArithWithFlagsIn >;
139 def AArch64sbc : SDNode<"AArch64ISD::SBC", SDTBinaryArithWithFlagsIn>;
140 def AArch64add_flag : SDNode<"AArch64ISD::ADDS", SDTBinaryArithWithFlagsOut,
142 def AArch64sub_flag : SDNode<"AArch64ISD::SUBS", SDTBinaryArithWithFlagsOut>;
143 def AArch64and_flag : SDNode<"AArch64ISD::ANDS", SDTBinaryArithWithFlagsOut,
145 def AArch64adc_flag : SDNode<"AArch64ISD::ADCS", SDTBinaryArithWithFlagsInOut>;
146 def AArch64sbc_flag : SDNode<"AArch64ISD::SBCS", SDTBinaryArithWithFlagsInOut>;
148 def AArch64threadpointer : SDNode<"AArch64ISD::THREAD_POINTER", SDTPtrLeaf>;
150 def AArch64fcmp : SDNode<"AArch64ISD::FCMP", SDT_AArch64FCmp>;
152 def AArch64fmax : SDNode<"AArch64ISD::FMAX", SDTFPBinOp>;
153 def AArch64fmin : SDNode<"AArch64ISD::FMIN", SDTFPBinOp>;
155 def AArch64dup : SDNode<"AArch64ISD::DUP", SDT_AArch64Dup>;
156 def AArch64duplane8 : SDNode<"AArch64ISD::DUPLANE8", SDT_AArch64DupLane>;
157 def AArch64duplane16 : SDNode<"AArch64ISD::DUPLANE16", SDT_AArch64DupLane>;
158 def AArch64duplane32 : SDNode<"AArch64ISD::DUPLANE32", SDT_AArch64DupLane>;
159 def AArch64duplane64 : SDNode<"AArch64ISD::DUPLANE64", SDT_AArch64DupLane>;
161 def AArch64zip1 : SDNode<"AArch64ISD::ZIP1", SDT_AArch64Zip>;
162 def AArch64zip2 : SDNode<"AArch64ISD::ZIP2", SDT_AArch64Zip>;
163 def AArch64uzp1 : SDNode<"AArch64ISD::UZP1", SDT_AArch64Zip>;
164 def AArch64uzp2 : SDNode<"AArch64ISD::UZP2", SDT_AArch64Zip>;
165 def AArch64trn1 : SDNode<"AArch64ISD::TRN1", SDT_AArch64Zip>;
166 def AArch64trn2 : SDNode<"AArch64ISD::TRN2", SDT_AArch64Zip>;
168 def AArch64movi_edit : SDNode<"AArch64ISD::MOVIedit", SDT_AArch64MOVIedit>;
169 def AArch64movi_shift : SDNode<"AArch64ISD::MOVIshift", SDT_AArch64MOVIshift>;
170 def AArch64movi_msl : SDNode<"AArch64ISD::MOVImsl", SDT_AArch64MOVIshift>;
171 def AArch64mvni_shift : SDNode<"AArch64ISD::MVNIshift", SDT_AArch64MOVIshift>;
172 def AArch64mvni_msl : SDNode<"AArch64ISD::MVNImsl", SDT_AArch64MOVIshift>;
173 def AArch64movi : SDNode<"AArch64ISD::MOVI", SDT_AArch64MOVIedit>;
174 def AArch64fmov : SDNode<"AArch64ISD::FMOV", SDT_AArch64MOVIedit>;
176 def AArch64rev16 : SDNode<"AArch64ISD::REV16", SDT_AArch64UnaryVec>;
177 def AArch64rev32 : SDNode<"AArch64ISD::REV32", SDT_AArch64UnaryVec>;
178 def AArch64rev64 : SDNode<"AArch64ISD::REV64", SDT_AArch64UnaryVec>;
179 def AArch64ext : SDNode<"AArch64ISD::EXT", SDT_AArch64ExtVec>;
181 def AArch64vashr : SDNode<"AArch64ISD::VASHR", SDT_AArch64vshift>;
182 def AArch64vlshr : SDNode<"AArch64ISD::VLSHR", SDT_AArch64vshift>;
183 def AArch64vshl : SDNode<"AArch64ISD::VSHL", SDT_AArch64vshift>;
184 def AArch64sqshli : SDNode<"AArch64ISD::SQSHL_I", SDT_AArch64vshift>;
185 def AArch64uqshli : SDNode<"AArch64ISD::UQSHL_I", SDT_AArch64vshift>;
186 def AArch64sqshlui : SDNode<"AArch64ISD::SQSHLU_I", SDT_AArch64vshift>;
187 def AArch64srshri : SDNode<"AArch64ISD::SRSHR_I", SDT_AArch64vshift>;
188 def AArch64urshri : SDNode<"AArch64ISD::URSHR_I", SDT_AArch64vshift>;
190 def AArch64not: SDNode<"AArch64ISD::NOT", SDT_AArch64unvec>;
191 def AArch64bit: SDNode<"AArch64ISD::BIT", SDT_AArch64trivec>;
192 def AArch64bsl: SDNode<"AArch64ISD::BSL", SDT_AArch64trivec>;
194 def AArch64cmeq: SDNode<"AArch64ISD::CMEQ", SDT_AArch64binvec>;
195 def AArch64cmge: SDNode<"AArch64ISD::CMGE", SDT_AArch64binvec>;
196 def AArch64cmgt: SDNode<"AArch64ISD::CMGT", SDT_AArch64binvec>;
197 def AArch64cmhi: SDNode<"AArch64ISD::CMHI", SDT_AArch64binvec>;
198 def AArch64cmhs: SDNode<"AArch64ISD::CMHS", SDT_AArch64binvec>;
200 def AArch64fcmeq: SDNode<"AArch64ISD::FCMEQ", SDT_AArch64fcmp>;
201 def AArch64fcmge: SDNode<"AArch64ISD::FCMGE", SDT_AArch64fcmp>;
202 def AArch64fcmgt: SDNode<"AArch64ISD::FCMGT", SDT_AArch64fcmp>;
204 def AArch64cmeqz: SDNode<"AArch64ISD::CMEQz", SDT_AArch64unvec>;
205 def AArch64cmgez: SDNode<"AArch64ISD::CMGEz", SDT_AArch64unvec>;
206 def AArch64cmgtz: SDNode<"AArch64ISD::CMGTz", SDT_AArch64unvec>;
207 def AArch64cmlez: SDNode<"AArch64ISD::CMLEz", SDT_AArch64unvec>;
208 def AArch64cmltz: SDNode<"AArch64ISD::CMLTz", SDT_AArch64unvec>;
209 def AArch64cmtst : PatFrag<(ops node:$LHS, node:$RHS),
210 (AArch64not (AArch64cmeqz (and node:$LHS, node:$RHS)))>;
212 def AArch64fcmeqz: SDNode<"AArch64ISD::FCMEQz", SDT_AArch64fcmpz>;
213 def AArch64fcmgez: SDNode<"AArch64ISD::FCMGEz", SDT_AArch64fcmpz>;
214 def AArch64fcmgtz: SDNode<"AArch64ISD::FCMGTz", SDT_AArch64fcmpz>;
215 def AArch64fcmlez: SDNode<"AArch64ISD::FCMLEz", SDT_AArch64fcmpz>;
216 def AArch64fcmltz: SDNode<"AArch64ISD::FCMLTz", SDT_AArch64fcmpz>;
218 def AArch64bici: SDNode<"AArch64ISD::BICi", SDT_AArch64vecimm>;
219 def AArch64orri: SDNode<"AArch64ISD::ORRi", SDT_AArch64vecimm>;
221 def AArch64neg : SDNode<"AArch64ISD::NEG", SDT_AArch64unvec>;
223 def AArch64tcret: SDNode<"AArch64ISD::TC_RETURN", SDT_AArch64TCRET,
224 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
226 def AArch64Prefetch : SDNode<"AArch64ISD::PREFETCH", SDT_AArch64PREFETCH,
227 [SDNPHasChain, SDNPSideEffect]>;
229 def AArch64sitof: SDNode<"AArch64ISD::SITOF", SDT_AArch64ITOF>;
230 def AArch64uitof: SDNode<"AArch64ISD::UITOF", SDT_AArch64ITOF>;
232 def AArch64tlsdesc_call : SDNode<"AArch64ISD::TLSDESC_CALL",
233 SDT_AArch64TLSDescCall,
234 [SDNPInGlue, SDNPOutGlue, SDNPHasChain,
237 def AArch64WrapperLarge : SDNode<"AArch64ISD::WrapperLarge",
238 SDT_AArch64WrapperLarge>;
240 def AArch64NvCast : SDNode<"AArch64ISD::NVCAST", SDTUnaryOp>;
242 def SDT_AArch64mull : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisInt<1>,
243 SDTCisSameAs<1, 2>]>;
244 def AArch64smull : SDNode<"AArch64ISD::SMULL", SDT_AArch64mull>;
245 def AArch64umull : SDNode<"AArch64ISD::UMULL", SDT_AArch64mull>;
247 //===----------------------------------------------------------------------===//
249 //===----------------------------------------------------------------------===//
251 // AArch64 Instruction Predicate Definitions.
253 def HasZCZ : Predicate<"Subtarget->hasZeroCycleZeroing()">;
254 def NoZCZ : Predicate<"!Subtarget->hasZeroCycleZeroing()">;
255 def IsDarwin : Predicate<"Subtarget->isTargetDarwin()">;
256 def IsNotDarwin: Predicate<"!Subtarget->isTargetDarwin()">;
257 def ForCodeSize : Predicate<"ForCodeSize">;
258 def NotForCodeSize : Predicate<"!ForCodeSize">;
260 include "AArch64InstrFormats.td"
262 //===----------------------------------------------------------------------===//
264 //===----------------------------------------------------------------------===//
265 // Miscellaneous instructions.
266 //===----------------------------------------------------------------------===//
268 let Defs = [SP], Uses = [SP], hasSideEffects = 1, isCodeGenOnly = 1 in {
269 def ADJCALLSTACKDOWN : Pseudo<(outs), (ins i32imm:$amt),
270 [(AArch64callseq_start timm:$amt)]>;
271 def ADJCALLSTACKUP : Pseudo<(outs), (ins i32imm:$amt1, i32imm:$amt2),
272 [(AArch64callseq_end timm:$amt1, timm:$amt2)]>;
273 } // Defs = [SP], Uses = [SP], hasSideEffects = 1, isCodeGenOnly = 1
275 let isReMaterializable = 1, isCodeGenOnly = 1 in {
276 // FIXME: The following pseudo instructions are only needed because remat
277 // cannot handle multiple instructions. When that changes, they can be
278 // removed, along with the AArch64Wrapper node.
280 let AddedComplexity = 10 in
281 def LOADgot : Pseudo<(outs GPR64:$dst), (ins i64imm:$addr),
282 [(set GPR64:$dst, (AArch64LOADgot tglobaladdr:$addr))]>,
285 // The MOVaddr instruction should match only when the add is not folded
286 // into a load or store address.
288 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
289 [(set GPR64:$dst, (AArch64addlow (AArch64adrp tglobaladdr:$hi),
290 tglobaladdr:$low))]>,
291 Sched<[WriteAdrAdr]>;
293 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
294 [(set GPR64:$dst, (AArch64addlow (AArch64adrp tjumptable:$hi),
296 Sched<[WriteAdrAdr]>;
298 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
299 [(set GPR64:$dst, (AArch64addlow (AArch64adrp tconstpool:$hi),
301 Sched<[WriteAdrAdr]>;
303 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
304 [(set GPR64:$dst, (AArch64addlow (AArch64adrp tblockaddress:$hi),
305 tblockaddress:$low))]>,
306 Sched<[WriteAdrAdr]>;
308 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
309 [(set GPR64:$dst, (AArch64addlow (AArch64adrp tglobaltlsaddr:$hi),
310 tglobaltlsaddr:$low))]>,
311 Sched<[WriteAdrAdr]>;
313 : Pseudo<(outs GPR64:$dst), (ins i64imm:$hi, i64imm:$low),
314 [(set GPR64:$dst, (AArch64addlow (AArch64adrp texternalsym:$hi),
315 texternalsym:$low))]>,
316 Sched<[WriteAdrAdr]>;
318 } // isReMaterializable, isCodeGenOnly
320 def : Pat<(AArch64LOADgot tglobaltlsaddr:$addr),
321 (LOADgot tglobaltlsaddr:$addr)>;
323 def : Pat<(AArch64LOADgot texternalsym:$addr),
324 (LOADgot texternalsym:$addr)>;
326 def : Pat<(AArch64LOADgot tconstpool:$addr),
327 (LOADgot tconstpool:$addr)>;
329 //===----------------------------------------------------------------------===//
330 // System instructions.
331 //===----------------------------------------------------------------------===//
333 def HINT : HintI<"hint">;
334 def : InstAlias<"nop", (HINT 0b000)>;
335 def : InstAlias<"yield",(HINT 0b001)>;
336 def : InstAlias<"wfe", (HINT 0b010)>;
337 def : InstAlias<"wfi", (HINT 0b011)>;
338 def : InstAlias<"sev", (HINT 0b100)>;
339 def : InstAlias<"sevl", (HINT 0b101)>;
341 // As far as LLVM is concerned this writes to the system's exclusive monitors.
342 let mayLoad = 1, mayStore = 1 in
343 def CLREX : CRmSystemI<imm0_15, 0b010, "clrex">;
345 // NOTE: ideally, this would have mayStore = 0, mayLoad = 0, but we cannot
346 // model patterns with sufficiently fine granularity.
347 let mayLoad = ?, mayStore = ? in {
348 def DMB : CRmSystemI<barrier_op, 0b101, "dmb",
349 [(int_aarch64_dmb (i32 imm32_0_15:$CRm))]>;
351 def DSB : CRmSystemI<barrier_op, 0b100, "dsb",
352 [(int_aarch64_dsb (i32 imm32_0_15:$CRm))]>;
354 def ISB : CRmSystemI<barrier_op, 0b110, "isb",
355 [(int_aarch64_isb (i32 imm32_0_15:$CRm))]>;
358 def : InstAlias<"clrex", (CLREX 0xf)>;
359 def : InstAlias<"isb", (ISB 0xf)>;
363 def MSRpstate: MSRpstateI;
365 // The thread pointer (on Linux, at least, where this has been implemented) is
367 def : Pat<(AArch64threadpointer), (MRS 0xde82)>;
369 // Generic system instructions
370 def SYSxt : SystemXtI<0, "sys">;
371 def SYSLxt : SystemLXtI<1, "sysl">;
373 def : InstAlias<"sys $op1, $Cn, $Cm, $op2",
374 (SYSxt imm0_7:$op1, sys_cr_op:$Cn,
375 sys_cr_op:$Cm, imm0_7:$op2, XZR)>;
377 //===----------------------------------------------------------------------===//
378 // Move immediate instructions.
379 //===----------------------------------------------------------------------===//
381 defm MOVK : InsertImmediate<0b11, "movk">;
382 defm MOVN : MoveImmediate<0b00, "movn">;
384 let PostEncoderMethod = "fixMOVZ" in
385 defm MOVZ : MoveImmediate<0b10, "movz">;
387 // First group of aliases covers an implicit "lsl #0".
388 def : InstAlias<"movk $dst, $imm", (MOVKWi GPR32:$dst, imm0_65535:$imm, 0)>;
389 def : InstAlias<"movk $dst, $imm", (MOVKXi GPR64:$dst, imm0_65535:$imm, 0)>;
390 def : InstAlias<"movn $dst, $imm", (MOVNWi GPR32:$dst, imm0_65535:$imm, 0)>;
391 def : InstAlias<"movn $dst, $imm", (MOVNXi GPR64:$dst, imm0_65535:$imm, 0)>;
392 def : InstAlias<"movz $dst, $imm", (MOVZWi GPR32:$dst, imm0_65535:$imm, 0)>;
393 def : InstAlias<"movz $dst, $imm", (MOVZXi GPR64:$dst, imm0_65535:$imm, 0)>;
395 // Next, we have various ELF relocations with the ":XYZ_g0:sym" syntax.
396 def : InstAlias<"movz $Rd, $sym", (MOVZXi GPR64:$Rd, movz_symbol_g3:$sym, 48)>;
397 def : InstAlias<"movz $Rd, $sym", (MOVZXi GPR64:$Rd, movz_symbol_g2:$sym, 32)>;
398 def : InstAlias<"movz $Rd, $sym", (MOVZXi GPR64:$Rd, movz_symbol_g1:$sym, 16)>;
399 def : InstAlias<"movz $Rd, $sym", (MOVZXi GPR64:$Rd, movz_symbol_g0:$sym, 0)>;
401 def : InstAlias<"movn $Rd, $sym", (MOVNXi GPR64:$Rd, movz_symbol_g3:$sym, 48)>;
402 def : InstAlias<"movn $Rd, $sym", (MOVNXi GPR64:$Rd, movz_symbol_g2:$sym, 32)>;
403 def : InstAlias<"movn $Rd, $sym", (MOVNXi GPR64:$Rd, movz_symbol_g1:$sym, 16)>;
404 def : InstAlias<"movn $Rd, $sym", (MOVNXi GPR64:$Rd, movz_symbol_g0:$sym, 0)>;
406 def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movk_symbol_g3:$sym, 48)>;
407 def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movk_symbol_g2:$sym, 32)>;
408 def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movk_symbol_g1:$sym, 16)>;
409 def : InstAlias<"movk $Rd, $sym", (MOVKXi GPR64:$Rd, movk_symbol_g0:$sym, 0)>;
411 def : InstAlias<"movz $Rd, $sym", (MOVZWi GPR32:$Rd, movz_symbol_g1:$sym, 16)>;
412 def : InstAlias<"movz $Rd, $sym", (MOVZWi GPR32:$Rd, movz_symbol_g0:$sym, 0)>;
414 def : InstAlias<"movn $Rd, $sym", (MOVNWi GPR32:$Rd, movz_symbol_g1:$sym, 16)>;
415 def : InstAlias<"movn $Rd, $sym", (MOVNWi GPR32:$Rd, movz_symbol_g0:$sym, 0)>;
417 def : InstAlias<"movk $Rd, $sym", (MOVKWi GPR32:$Rd, movk_symbol_g1:$sym, 16)>;
418 def : InstAlias<"movk $Rd, $sym", (MOVKWi GPR32:$Rd, movk_symbol_g0:$sym, 0)>;
420 // Final group of aliases covers true "mov $Rd, $imm" cases.
421 multiclass movw_mov_alias<string basename,Instruction INST, RegisterClass GPR,
422 int width, int shift> {
423 def _asmoperand : AsmOperandClass {
424 let Name = basename # width # "_lsl" # shift # "MovAlias";
425 let PredicateMethod = "is" # basename # "MovAlias<" # width # ", "
427 let RenderMethod = "add" # basename # "MovAliasOperands<" # shift # ">";
430 def _movimm : Operand<i32> {
431 let ParserMatchClass = !cast<AsmOperandClass>(NAME # "_asmoperand");
434 def : InstAlias<"mov $Rd, $imm",
435 (INST GPR:$Rd, !cast<Operand>(NAME # "_movimm"):$imm, shift)>;
438 defm : movw_mov_alias<"MOVZ", MOVZWi, GPR32, 32, 0>;
439 defm : movw_mov_alias<"MOVZ", MOVZWi, GPR32, 32, 16>;
441 defm : movw_mov_alias<"MOVZ", MOVZXi, GPR64, 64, 0>;
442 defm : movw_mov_alias<"MOVZ", MOVZXi, GPR64, 64, 16>;
443 defm : movw_mov_alias<"MOVZ", MOVZXi, GPR64, 64, 32>;
444 defm : movw_mov_alias<"MOVZ", MOVZXi, GPR64, 64, 48>;
446 defm : movw_mov_alias<"MOVN", MOVNWi, GPR32, 32, 0>;
447 defm : movw_mov_alias<"MOVN", MOVNWi, GPR32, 32, 16>;
449 defm : movw_mov_alias<"MOVN", MOVNXi, GPR64, 64, 0>;
450 defm : movw_mov_alias<"MOVN", MOVNXi, GPR64, 64, 16>;
451 defm : movw_mov_alias<"MOVN", MOVNXi, GPR64, 64, 32>;
452 defm : movw_mov_alias<"MOVN", MOVNXi, GPR64, 64, 48>;
454 let isReMaterializable = 1, isCodeGenOnly = 1, isMoveImm = 1,
455 isAsCheapAsAMove = 1 in {
456 // FIXME: The following pseudo instructions are only needed because remat
457 // cannot handle multiple instructions. When that changes, we can select
458 // directly to the real instructions and get rid of these pseudos.
461 : Pseudo<(outs GPR32:$dst), (ins i32imm:$src),
462 [(set GPR32:$dst, imm:$src)]>,
465 : Pseudo<(outs GPR64:$dst), (ins i64imm:$src),
466 [(set GPR64:$dst, imm:$src)]>,
468 } // isReMaterializable, isCodeGenOnly
470 // If possible, we want to use MOVi32imm even for 64-bit moves. This gives the
471 // eventual expansion code fewer bits to worry about getting right. Marshalling
472 // the types is a little tricky though:
473 def i64imm_32bit : ImmLeaf<i64, [{
474 return (Imm & 0xffffffffULL) == static_cast<uint64_t>(Imm);
477 def trunc_imm : SDNodeXForm<imm, [{
478 return CurDAG->getTargetConstant(N->getZExtValue(), MVT::i32);
481 def : Pat<(i64 i64imm_32bit:$src),
482 (SUBREG_TO_REG (i64 0), (MOVi32imm (trunc_imm imm:$src)), sub_32)>;
484 // Deal with the various forms of (ELF) large addressing with MOVZ/MOVK
486 def : Pat<(AArch64WrapperLarge tglobaladdr:$g3, tglobaladdr:$g2,
487 tglobaladdr:$g1, tglobaladdr:$g0),
488 (MOVKXi (MOVKXi (MOVKXi (MOVZXi tglobaladdr:$g3, 48),
489 tglobaladdr:$g2, 32),
490 tglobaladdr:$g1, 16),
491 tglobaladdr:$g0, 0)>;
493 def : Pat<(AArch64WrapperLarge tblockaddress:$g3, tblockaddress:$g2,
494 tblockaddress:$g1, tblockaddress:$g0),
495 (MOVKXi (MOVKXi (MOVKXi (MOVZXi tblockaddress:$g3, 48),
496 tblockaddress:$g2, 32),
497 tblockaddress:$g1, 16),
498 tblockaddress:$g0, 0)>;
500 def : Pat<(AArch64WrapperLarge tconstpool:$g3, tconstpool:$g2,
501 tconstpool:$g1, tconstpool:$g0),
502 (MOVKXi (MOVKXi (MOVKXi (MOVZXi tconstpool:$g3, 48),
507 def : Pat<(AArch64WrapperLarge tjumptable:$g3, tjumptable:$g2,
508 tjumptable:$g1, tjumptable:$g0),
509 (MOVKXi (MOVKXi (MOVKXi (MOVZXi tjumptable:$g3, 48),
515 //===----------------------------------------------------------------------===//
516 // Arithmetic instructions.
517 //===----------------------------------------------------------------------===//
519 // Add/subtract with carry.
520 defm ADC : AddSubCarry<0, "adc", "adcs", AArch64adc, AArch64adc_flag>;
521 defm SBC : AddSubCarry<1, "sbc", "sbcs", AArch64sbc, AArch64sbc_flag>;
523 def : InstAlias<"ngc $dst, $src", (SBCWr GPR32:$dst, WZR, GPR32:$src)>;
524 def : InstAlias<"ngc $dst, $src", (SBCXr GPR64:$dst, XZR, GPR64:$src)>;
525 def : InstAlias<"ngcs $dst, $src", (SBCSWr GPR32:$dst, WZR, GPR32:$src)>;
526 def : InstAlias<"ngcs $dst, $src", (SBCSXr GPR64:$dst, XZR, GPR64:$src)>;
529 defm ADD : AddSub<0, "add", add>;
530 defm SUB : AddSub<1, "sub">;
532 def : InstAlias<"mov $dst, $src",
533 (ADDWri GPR32sponly:$dst, GPR32sp:$src, 0, 0)>;
534 def : InstAlias<"mov $dst, $src",
535 (ADDWri GPR32sp:$dst, GPR32sponly:$src, 0, 0)>;
536 def : InstAlias<"mov $dst, $src",
537 (ADDXri GPR64sponly:$dst, GPR64sp:$src, 0, 0)>;
538 def : InstAlias<"mov $dst, $src",
539 (ADDXri GPR64sp:$dst, GPR64sponly:$src, 0, 0)>;
541 defm ADDS : AddSubS<0, "adds", AArch64add_flag, "cmn">;
542 defm SUBS : AddSubS<1, "subs", AArch64sub_flag, "cmp">;
544 // Use SUBS instead of SUB to enable CSE between SUBS and SUB.
545 def : Pat<(sub GPR32sp:$Rn, addsub_shifted_imm32:$imm),
546 (SUBSWri GPR32sp:$Rn, addsub_shifted_imm32:$imm)>;
547 def : Pat<(sub GPR64sp:$Rn, addsub_shifted_imm64:$imm),
548 (SUBSXri GPR64sp:$Rn, addsub_shifted_imm64:$imm)>;
549 def : Pat<(sub GPR32:$Rn, GPR32:$Rm),
550 (SUBSWrr GPR32:$Rn, GPR32:$Rm)>;
551 def : Pat<(sub GPR64:$Rn, GPR64:$Rm),
552 (SUBSXrr GPR64:$Rn, GPR64:$Rm)>;
553 def : Pat<(sub GPR32:$Rn, arith_shifted_reg32:$Rm),
554 (SUBSWrs GPR32:$Rn, arith_shifted_reg32:$Rm)>;
555 def : Pat<(sub GPR64:$Rn, arith_shifted_reg64:$Rm),
556 (SUBSXrs GPR64:$Rn, arith_shifted_reg64:$Rm)>;
557 def : Pat<(sub GPR32sp:$R2, arith_extended_reg32<i32>:$R3),
558 (SUBSWrx GPR32sp:$R2, arith_extended_reg32<i32>:$R3)>;
559 def : Pat<(sub GPR64sp:$R2, arith_extended_reg32to64<i64>:$R3),
560 (SUBSXrx GPR64sp:$R2, arith_extended_reg32to64<i64>:$R3)>;
562 // Because of the immediate format for add/sub-imm instructions, the
563 // expression (add x, -1) must be transformed to (SUB{W,X}ri x, 1).
564 // These patterns capture that transformation.
565 let AddedComplexity = 1 in {
566 def : Pat<(add GPR32:$Rn, neg_addsub_shifted_imm32:$imm),
567 (SUBSWri GPR32:$Rn, neg_addsub_shifted_imm32:$imm)>;
568 def : Pat<(add GPR64:$Rn, neg_addsub_shifted_imm64:$imm),
569 (SUBSXri GPR64:$Rn, neg_addsub_shifted_imm64:$imm)>;
570 def : Pat<(sub GPR32:$Rn, neg_addsub_shifted_imm32:$imm),
571 (ADDWri GPR32:$Rn, neg_addsub_shifted_imm32:$imm)>;
572 def : Pat<(sub GPR64:$Rn, neg_addsub_shifted_imm64:$imm),
573 (ADDXri GPR64:$Rn, neg_addsub_shifted_imm64:$imm)>;
576 // Because of the immediate format for add/sub-imm instructions, the
577 // expression (add x, -1) must be transformed to (SUB{W,X}ri x, 1).
578 // These patterns capture that transformation.
579 let AddedComplexity = 1 in {
580 def : Pat<(AArch64add_flag GPR32:$Rn, neg_addsub_shifted_imm32:$imm),
581 (SUBSWri GPR32:$Rn, neg_addsub_shifted_imm32:$imm)>;
582 def : Pat<(AArch64add_flag GPR64:$Rn, neg_addsub_shifted_imm64:$imm),
583 (SUBSXri GPR64:$Rn, neg_addsub_shifted_imm64:$imm)>;
584 def : Pat<(AArch64sub_flag GPR32:$Rn, neg_addsub_shifted_imm32:$imm),
585 (ADDSWri GPR32:$Rn, neg_addsub_shifted_imm32:$imm)>;
586 def : Pat<(AArch64sub_flag GPR64:$Rn, neg_addsub_shifted_imm64:$imm),
587 (ADDSXri GPR64:$Rn, neg_addsub_shifted_imm64:$imm)>;
590 def : InstAlias<"neg $dst, $src", (SUBWrs GPR32:$dst, WZR, GPR32:$src, 0), 3>;
591 def : InstAlias<"neg $dst, $src", (SUBXrs GPR64:$dst, XZR, GPR64:$src, 0), 3>;
592 def : InstAlias<"neg $dst, $src$shift",
593 (SUBWrs GPR32:$dst, WZR, GPR32:$src, arith_shift32:$shift), 2>;
594 def : InstAlias<"neg $dst, $src$shift",
595 (SUBXrs GPR64:$dst, XZR, GPR64:$src, arith_shift64:$shift), 2>;
597 def : InstAlias<"negs $dst, $src", (SUBSWrs GPR32:$dst, WZR, GPR32:$src, 0), 3>;
598 def : InstAlias<"negs $dst, $src", (SUBSXrs GPR64:$dst, XZR, GPR64:$src, 0), 3>;
599 def : InstAlias<"negs $dst, $src$shift",
600 (SUBSWrs GPR32:$dst, WZR, GPR32:$src, arith_shift32:$shift), 2>;
601 def : InstAlias<"negs $dst, $src$shift",
602 (SUBSXrs GPR64:$dst, XZR, GPR64:$src, arith_shift64:$shift), 2>;
605 // Unsigned/Signed divide
606 defm UDIV : Div<0, "udiv", udiv>;
607 defm SDIV : Div<1, "sdiv", sdiv>;
608 let isCodeGenOnly = 1 in {
609 defm UDIV_Int : Div<0, "udiv", int_aarch64_udiv>;
610 defm SDIV_Int : Div<1, "sdiv", int_aarch64_sdiv>;
614 defm ASRV : Shift<0b10, "asr", sra>;
615 defm LSLV : Shift<0b00, "lsl", shl>;
616 defm LSRV : Shift<0b01, "lsr", srl>;
617 defm RORV : Shift<0b11, "ror", rotr>;
619 def : ShiftAlias<"asrv", ASRVWr, GPR32>;
620 def : ShiftAlias<"asrv", ASRVXr, GPR64>;
621 def : ShiftAlias<"lslv", LSLVWr, GPR32>;
622 def : ShiftAlias<"lslv", LSLVXr, GPR64>;
623 def : ShiftAlias<"lsrv", LSRVWr, GPR32>;
624 def : ShiftAlias<"lsrv", LSRVXr, GPR64>;
625 def : ShiftAlias<"rorv", RORVWr, GPR32>;
626 def : ShiftAlias<"rorv", RORVXr, GPR64>;
629 let AddedComplexity = 7 in {
630 defm MADD : MulAccum<0, "madd", add>;
631 defm MSUB : MulAccum<1, "msub", sub>;
633 def : Pat<(i32 (mul GPR32:$Rn, GPR32:$Rm)),
634 (MADDWrrr GPR32:$Rn, GPR32:$Rm, WZR)>;
635 def : Pat<(i64 (mul GPR64:$Rn, GPR64:$Rm)),
636 (MADDXrrr GPR64:$Rn, GPR64:$Rm, XZR)>;
638 def : Pat<(i32 (ineg (mul GPR32:$Rn, GPR32:$Rm))),
639 (MSUBWrrr GPR32:$Rn, GPR32:$Rm, WZR)>;
640 def : Pat<(i64 (ineg (mul GPR64:$Rn, GPR64:$Rm))),
641 (MSUBXrrr GPR64:$Rn, GPR64:$Rm, XZR)>;
642 } // AddedComplexity = 7
644 let AddedComplexity = 5 in {
645 def SMADDLrrr : WideMulAccum<0, 0b001, "smaddl", add, sext>;
646 def SMSUBLrrr : WideMulAccum<1, 0b001, "smsubl", sub, sext>;
647 def UMADDLrrr : WideMulAccum<0, 0b101, "umaddl", add, zext>;
648 def UMSUBLrrr : WideMulAccum<1, 0b101, "umsubl", sub, zext>;
650 def : Pat<(i64 (mul (sext GPR32:$Rn), (sext GPR32:$Rm))),
651 (SMADDLrrr GPR32:$Rn, GPR32:$Rm, XZR)>;
652 def : Pat<(i64 (mul (zext GPR32:$Rn), (zext GPR32:$Rm))),
653 (UMADDLrrr GPR32:$Rn, GPR32:$Rm, XZR)>;
655 def : Pat<(i64 (ineg (mul (sext GPR32:$Rn), (sext GPR32:$Rm)))),
656 (SMSUBLrrr GPR32:$Rn, GPR32:$Rm, XZR)>;
657 def : Pat<(i64 (ineg (mul (zext GPR32:$Rn), (zext GPR32:$Rm)))),
658 (UMSUBLrrr GPR32:$Rn, GPR32:$Rm, XZR)>;
659 } // AddedComplexity = 5
661 def : MulAccumWAlias<"mul", MADDWrrr>;
662 def : MulAccumXAlias<"mul", MADDXrrr>;
663 def : MulAccumWAlias<"mneg", MSUBWrrr>;
664 def : MulAccumXAlias<"mneg", MSUBXrrr>;
665 def : WideMulAccumAlias<"smull", SMADDLrrr>;
666 def : WideMulAccumAlias<"smnegl", SMSUBLrrr>;
667 def : WideMulAccumAlias<"umull", UMADDLrrr>;
668 def : WideMulAccumAlias<"umnegl", UMSUBLrrr>;
671 def SMULHrr : MulHi<0b010, "smulh", mulhs>;
672 def UMULHrr : MulHi<0b110, "umulh", mulhu>;
675 def CRC32Brr : BaseCRC32<0, 0b00, 0, GPR32, int_aarch64_crc32b, "crc32b">;
676 def CRC32Hrr : BaseCRC32<0, 0b01, 0, GPR32, int_aarch64_crc32h, "crc32h">;
677 def CRC32Wrr : BaseCRC32<0, 0b10, 0, GPR32, int_aarch64_crc32w, "crc32w">;
678 def CRC32Xrr : BaseCRC32<1, 0b11, 0, GPR64, int_aarch64_crc32x, "crc32x">;
680 def CRC32CBrr : BaseCRC32<0, 0b00, 1, GPR32, int_aarch64_crc32cb, "crc32cb">;
681 def CRC32CHrr : BaseCRC32<0, 0b01, 1, GPR32, int_aarch64_crc32ch, "crc32ch">;
682 def CRC32CWrr : BaseCRC32<0, 0b10, 1, GPR32, int_aarch64_crc32cw, "crc32cw">;
683 def CRC32CXrr : BaseCRC32<1, 0b11, 1, GPR64, int_aarch64_crc32cx, "crc32cx">;
686 //===----------------------------------------------------------------------===//
687 // Logical instructions.
688 //===----------------------------------------------------------------------===//
691 defm ANDS : LogicalImmS<0b11, "ands", AArch64and_flag, "bics">;
692 defm AND : LogicalImm<0b00, "and", and, "bic">;
693 defm EOR : LogicalImm<0b10, "eor", xor, "eon">;
694 defm ORR : LogicalImm<0b01, "orr", or, "orn">;
696 // FIXME: these aliases *are* canonical sometimes (when movz can't be
697 // used). Actually, it seems to be working right now, but putting logical_immXX
698 // here is a bit dodgy on the AsmParser side too.
699 def : InstAlias<"mov $dst, $imm", (ORRWri GPR32sp:$dst, WZR,
700 logical_imm32:$imm), 0>;
701 def : InstAlias<"mov $dst, $imm", (ORRXri GPR64sp:$dst, XZR,
702 logical_imm64:$imm), 0>;
706 defm ANDS : LogicalRegS<0b11, 0, "ands", AArch64and_flag>;
707 defm BICS : LogicalRegS<0b11, 1, "bics",
708 BinOpFrag<(AArch64and_flag node:$LHS, (not node:$RHS))>>;
709 defm AND : LogicalReg<0b00, 0, "and", and>;
710 defm BIC : LogicalReg<0b00, 1, "bic",
711 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
712 defm EON : LogicalReg<0b10, 1, "eon",
713 BinOpFrag<(xor node:$LHS, (not node:$RHS))>>;
714 defm EOR : LogicalReg<0b10, 0, "eor", xor>;
715 defm ORN : LogicalReg<0b01, 1, "orn",
716 BinOpFrag<(or node:$LHS, (not node:$RHS))>>;
717 defm ORR : LogicalReg<0b01, 0, "orr", or>;
719 def : InstAlias<"mov $dst, $src", (ORRWrs GPR32:$dst, WZR, GPR32:$src, 0), 2>;
720 def : InstAlias<"mov $dst, $src", (ORRXrs GPR64:$dst, XZR, GPR64:$src, 0), 2>;
722 def : InstAlias<"mvn $Wd, $Wm", (ORNWrs GPR32:$Wd, WZR, GPR32:$Wm, 0), 3>;
723 def : InstAlias<"mvn $Xd, $Xm", (ORNXrs GPR64:$Xd, XZR, GPR64:$Xm, 0), 3>;
725 def : InstAlias<"mvn $Wd, $Wm$sh",
726 (ORNWrs GPR32:$Wd, WZR, GPR32:$Wm, logical_shift32:$sh), 2>;
727 def : InstAlias<"mvn $Xd, $Xm$sh",
728 (ORNXrs GPR64:$Xd, XZR, GPR64:$Xm, logical_shift64:$sh), 2>;
730 def : InstAlias<"tst $src1, $src2",
731 (ANDSWri WZR, GPR32:$src1, logical_imm32:$src2), 2>;
732 def : InstAlias<"tst $src1, $src2",
733 (ANDSXri XZR, GPR64:$src1, logical_imm64:$src2), 2>;
735 def : InstAlias<"tst $src1, $src2",
736 (ANDSWrs WZR, GPR32:$src1, GPR32:$src2, 0), 3>;
737 def : InstAlias<"tst $src1, $src2",
738 (ANDSXrs XZR, GPR64:$src1, GPR64:$src2, 0), 3>;
740 def : InstAlias<"tst $src1, $src2$sh",
741 (ANDSWrs WZR, GPR32:$src1, GPR32:$src2, logical_shift32:$sh), 2>;
742 def : InstAlias<"tst $src1, $src2$sh",
743 (ANDSXrs XZR, GPR64:$src1, GPR64:$src2, logical_shift64:$sh), 2>;
746 def : Pat<(not GPR32:$Wm), (ORNWrr WZR, GPR32:$Wm)>;
747 def : Pat<(not GPR64:$Xm), (ORNXrr XZR, GPR64:$Xm)>;
750 //===----------------------------------------------------------------------===//
751 // One operand data processing instructions.
752 //===----------------------------------------------------------------------===//
754 defm CLS : OneOperandData<0b101, "cls">;
755 defm CLZ : OneOperandData<0b100, "clz", ctlz>;
756 defm RBIT : OneOperandData<0b000, "rbit">;
758 def : Pat<(int_aarch64_rbit GPR32:$Rn), (RBITWr $Rn)>;
759 def : Pat<(int_aarch64_rbit GPR64:$Rn), (RBITXr $Rn)>;
761 def REV16Wr : OneWRegData<0b001, "rev16",
762 UnOpFrag<(rotr (bswap node:$LHS), (i64 16))>>;
763 def REV16Xr : OneXRegData<0b001, "rev16", null_frag>;
765 def : Pat<(cttz GPR32:$Rn),
766 (CLZWr (RBITWr GPR32:$Rn))>;
767 def : Pat<(cttz GPR64:$Rn),
768 (CLZXr (RBITXr GPR64:$Rn))>;
769 def : Pat<(ctlz (or (shl (xor (sra GPR32:$Rn, (i64 31)), GPR32:$Rn), (i64 1)),
772 def : Pat<(ctlz (or (shl (xor (sra GPR64:$Rn, (i64 63)), GPR64:$Rn), (i64 1)),
776 // Unlike the other one operand instructions, the instructions with the "rev"
777 // mnemonic do *not* just different in the size bit, but actually use different
778 // opcode bits for the different sizes.
779 def REVWr : OneWRegData<0b010, "rev", bswap>;
780 def REVXr : OneXRegData<0b011, "rev", bswap>;
781 def REV32Xr : OneXRegData<0b010, "rev32",
782 UnOpFrag<(rotr (bswap node:$LHS), (i64 32))>>;
784 // The bswap commutes with the rotr so we want a pattern for both possible
786 def : Pat<(bswap (rotr GPR32:$Rn, (i64 16))), (REV16Wr GPR32:$Rn)>;
787 def : Pat<(bswap (rotr GPR64:$Rn, (i64 32))), (REV32Xr GPR64:$Rn)>;
789 //===----------------------------------------------------------------------===//
790 // Bitfield immediate extraction instruction.
791 //===----------------------------------------------------------------------===//
792 let hasSideEffects = 0 in
793 defm EXTR : ExtractImm<"extr">;
794 def : InstAlias<"ror $dst, $src, $shift",
795 (EXTRWrri GPR32:$dst, GPR32:$src, GPR32:$src, imm0_31:$shift)>;
796 def : InstAlias<"ror $dst, $src, $shift",
797 (EXTRXrri GPR64:$dst, GPR64:$src, GPR64:$src, imm0_63:$shift)>;
799 def : Pat<(rotr GPR32:$Rn, (i64 imm0_31:$imm)),
800 (EXTRWrri GPR32:$Rn, GPR32:$Rn, imm0_31:$imm)>;
801 def : Pat<(rotr GPR64:$Rn, (i64 imm0_63:$imm)),
802 (EXTRXrri GPR64:$Rn, GPR64:$Rn, imm0_63:$imm)>;
804 //===----------------------------------------------------------------------===//
805 // Other bitfield immediate instructions.
806 //===----------------------------------------------------------------------===//
807 let hasSideEffects = 0 in {
808 defm BFM : BitfieldImmWith2RegArgs<0b01, "bfm">;
809 defm SBFM : BitfieldImm<0b00, "sbfm">;
810 defm UBFM : BitfieldImm<0b10, "ubfm">;
813 def i32shift_a : Operand<i64>, SDNodeXForm<imm, [{
814 uint64_t enc = (32 - N->getZExtValue()) & 0x1f;
815 return CurDAG->getTargetConstant(enc, MVT::i64);
818 def i32shift_b : Operand<i64>, SDNodeXForm<imm, [{
819 uint64_t enc = 31 - N->getZExtValue();
820 return CurDAG->getTargetConstant(enc, MVT::i64);
823 // min(7, 31 - shift_amt)
824 def i32shift_sext_i8 : Operand<i64>, SDNodeXForm<imm, [{
825 uint64_t enc = 31 - N->getZExtValue();
826 enc = enc > 7 ? 7 : enc;
827 return CurDAG->getTargetConstant(enc, MVT::i64);
830 // min(15, 31 - shift_amt)
831 def i32shift_sext_i16 : Operand<i64>, SDNodeXForm<imm, [{
832 uint64_t enc = 31 - N->getZExtValue();
833 enc = enc > 15 ? 15 : enc;
834 return CurDAG->getTargetConstant(enc, MVT::i64);
837 def i64shift_a : Operand<i64>, SDNodeXForm<imm, [{
838 uint64_t enc = (64 - N->getZExtValue()) & 0x3f;
839 return CurDAG->getTargetConstant(enc, MVT::i64);
842 def i64shift_b : Operand<i64>, SDNodeXForm<imm, [{
843 uint64_t enc = 63 - N->getZExtValue();
844 return CurDAG->getTargetConstant(enc, MVT::i64);
847 // min(7, 63 - shift_amt)
848 def i64shift_sext_i8 : Operand<i64>, SDNodeXForm<imm, [{
849 uint64_t enc = 63 - N->getZExtValue();
850 enc = enc > 7 ? 7 : enc;
851 return CurDAG->getTargetConstant(enc, MVT::i64);
854 // min(15, 63 - shift_amt)
855 def i64shift_sext_i16 : Operand<i64>, SDNodeXForm<imm, [{
856 uint64_t enc = 63 - N->getZExtValue();
857 enc = enc > 15 ? 15 : enc;
858 return CurDAG->getTargetConstant(enc, MVT::i64);
861 // min(31, 63 - shift_amt)
862 def i64shift_sext_i32 : Operand<i64>, SDNodeXForm<imm, [{
863 uint64_t enc = 63 - N->getZExtValue();
864 enc = enc > 31 ? 31 : enc;
865 return CurDAG->getTargetConstant(enc, MVT::i64);
868 def : Pat<(shl GPR32:$Rn, (i64 imm0_31:$imm)),
869 (UBFMWri GPR32:$Rn, (i64 (i32shift_a imm0_31:$imm)),
870 (i64 (i32shift_b imm0_31:$imm)))>;
871 def : Pat<(shl GPR64:$Rn, (i64 imm0_63:$imm)),
872 (UBFMXri GPR64:$Rn, (i64 (i64shift_a imm0_63:$imm)),
873 (i64 (i64shift_b imm0_63:$imm)))>;
875 let AddedComplexity = 10 in {
876 def : Pat<(sra GPR32:$Rn, (i64 imm0_31:$imm)),
877 (SBFMWri GPR32:$Rn, imm0_31:$imm, 31)>;
878 def : Pat<(sra GPR64:$Rn, (i64 imm0_63:$imm)),
879 (SBFMXri GPR64:$Rn, imm0_63:$imm, 63)>;
882 def : InstAlias<"asr $dst, $src, $shift",
883 (SBFMWri GPR32:$dst, GPR32:$src, imm0_31:$shift, 31)>;
884 def : InstAlias<"asr $dst, $src, $shift",
885 (SBFMXri GPR64:$dst, GPR64:$src, imm0_63:$shift, 63)>;
886 def : InstAlias<"sxtb $dst, $src", (SBFMWri GPR32:$dst, GPR32:$src, 0, 7)>;
887 def : InstAlias<"sxtb $dst, $src", (SBFMXri GPR64:$dst, GPR64:$src, 0, 7)>;
888 def : InstAlias<"sxth $dst, $src", (SBFMWri GPR32:$dst, GPR32:$src, 0, 15)>;
889 def : InstAlias<"sxth $dst, $src", (SBFMXri GPR64:$dst, GPR64:$src, 0, 15)>;
890 def : InstAlias<"sxtw $dst, $src", (SBFMXri GPR64:$dst, GPR64:$src, 0, 31)>;
892 def : Pat<(srl GPR32:$Rn, (i64 imm0_31:$imm)),
893 (UBFMWri GPR32:$Rn, imm0_31:$imm, 31)>;
894 def : Pat<(srl GPR64:$Rn, (i64 imm0_63:$imm)),
895 (UBFMXri GPR64:$Rn, imm0_63:$imm, 63)>;
897 def : InstAlias<"lsr $dst, $src, $shift",
898 (UBFMWri GPR32:$dst, GPR32:$src, imm0_31:$shift, 31)>;
899 def : InstAlias<"lsr $dst, $src, $shift",
900 (UBFMXri GPR64:$dst, GPR64:$src, imm0_63:$shift, 63)>;
901 def : InstAlias<"uxtb $dst, $src", (UBFMWri GPR32:$dst, GPR32:$src, 0, 7)>;
902 def : InstAlias<"uxtb $dst, $src", (UBFMXri GPR64:$dst, GPR64:$src, 0, 7)>;
903 def : InstAlias<"uxth $dst, $src", (UBFMWri GPR32:$dst, GPR32:$src, 0, 15)>;
904 def : InstAlias<"uxth $dst, $src", (UBFMXri GPR64:$dst, GPR64:$src, 0, 15)>;
905 def : InstAlias<"uxtw $dst, $src", (UBFMXri GPR64:$dst, GPR64:$src, 0, 31)>;
907 //===----------------------------------------------------------------------===//
908 // Conditionally set flags instructions.
909 //===----------------------------------------------------------------------===//
910 defm CCMN : CondSetFlagsImm<0, "ccmn">;
911 defm CCMP : CondSetFlagsImm<1, "ccmp">;
913 defm CCMN : CondSetFlagsReg<0, "ccmn">;
914 defm CCMP : CondSetFlagsReg<1, "ccmp">;
916 //===----------------------------------------------------------------------===//
917 // Conditional select instructions.
918 //===----------------------------------------------------------------------===//
919 defm CSEL : CondSelect<0, 0b00, "csel">;
921 def inc : PatFrag<(ops node:$in), (add node:$in, 1)>;
922 defm CSINC : CondSelectOp<0, 0b01, "csinc", inc>;
923 defm CSINV : CondSelectOp<1, 0b00, "csinv", not>;
924 defm CSNEG : CondSelectOp<1, 0b01, "csneg", ineg>;
926 def : Pat<(AArch64csinv GPR32:$tval, GPR32:$fval, (i32 imm:$cc), NZCV),
927 (CSINVWr GPR32:$tval, GPR32:$fval, (i32 imm:$cc))>;
928 def : Pat<(AArch64csinv GPR64:$tval, GPR64:$fval, (i32 imm:$cc), NZCV),
929 (CSINVXr GPR64:$tval, GPR64:$fval, (i32 imm:$cc))>;
930 def : Pat<(AArch64csneg GPR32:$tval, GPR32:$fval, (i32 imm:$cc), NZCV),
931 (CSNEGWr GPR32:$tval, GPR32:$fval, (i32 imm:$cc))>;
932 def : Pat<(AArch64csneg GPR64:$tval, GPR64:$fval, (i32 imm:$cc), NZCV),
933 (CSNEGXr GPR64:$tval, GPR64:$fval, (i32 imm:$cc))>;
934 def : Pat<(AArch64csinc GPR32:$tval, GPR32:$fval, (i32 imm:$cc), NZCV),
935 (CSINCWr GPR32:$tval, GPR32:$fval, (i32 imm:$cc))>;
936 def : Pat<(AArch64csinc GPR64:$tval, GPR64:$fval, (i32 imm:$cc), NZCV),
937 (CSINCXr GPR64:$tval, GPR64:$fval, (i32 imm:$cc))>;
939 def : Pat<(AArch64csel (i32 0), (i32 1), (i32 imm:$cc), NZCV),
940 (CSINCWr WZR, WZR, (i32 imm:$cc))>;
941 def : Pat<(AArch64csel (i64 0), (i64 1), (i32 imm:$cc), NZCV),
942 (CSINCXr XZR, XZR, (i32 imm:$cc))>;
943 def : Pat<(AArch64csel (i32 0), (i32 -1), (i32 imm:$cc), NZCV),
944 (CSINVWr WZR, WZR, (i32 imm:$cc))>;
945 def : Pat<(AArch64csel (i64 0), (i64 -1), (i32 imm:$cc), NZCV),
946 (CSINVXr XZR, XZR, (i32 imm:$cc))>;
948 // The inverse of the condition code from the alias instruction is what is used
949 // in the aliased instruction. The parser all ready inverts the condition code
950 // for these aliases.
951 def : InstAlias<"cset $dst, $cc",
952 (CSINCWr GPR32:$dst, WZR, WZR, inv_ccode:$cc)>;
953 def : InstAlias<"cset $dst, $cc",
954 (CSINCXr GPR64:$dst, XZR, XZR, inv_ccode:$cc)>;
956 def : InstAlias<"csetm $dst, $cc",
957 (CSINVWr GPR32:$dst, WZR, WZR, inv_ccode:$cc)>;
958 def : InstAlias<"csetm $dst, $cc",
959 (CSINVXr GPR64:$dst, XZR, XZR, inv_ccode:$cc)>;
961 def : InstAlias<"cinc $dst, $src, $cc",
962 (CSINCWr GPR32:$dst, GPR32:$src, GPR32:$src, inv_ccode:$cc)>;
963 def : InstAlias<"cinc $dst, $src, $cc",
964 (CSINCXr GPR64:$dst, GPR64:$src, GPR64:$src, inv_ccode:$cc)>;
966 def : InstAlias<"cinv $dst, $src, $cc",
967 (CSINVWr GPR32:$dst, GPR32:$src, GPR32:$src, inv_ccode:$cc)>;
968 def : InstAlias<"cinv $dst, $src, $cc",
969 (CSINVXr GPR64:$dst, GPR64:$src, GPR64:$src, inv_ccode:$cc)>;
971 def : InstAlias<"cneg $dst, $src, $cc",
972 (CSNEGWr GPR32:$dst, GPR32:$src, GPR32:$src, inv_ccode:$cc)>;
973 def : InstAlias<"cneg $dst, $src, $cc",
974 (CSNEGXr GPR64:$dst, GPR64:$src, GPR64:$src, inv_ccode:$cc)>;
976 //===----------------------------------------------------------------------===//
977 // PC-relative instructions.
978 //===----------------------------------------------------------------------===//
979 let isReMaterializable = 1 in {
980 let hasSideEffects = 0, mayStore = 0, mayLoad = 0 in {
981 def ADR : ADRI<0, "adr", adrlabel, []>;
982 } // hasSideEffects = 0
984 def ADRP : ADRI<1, "adrp", adrplabel,
985 [(set GPR64:$Xd, (AArch64adrp tglobaladdr:$label))]>;
986 } // isReMaterializable = 1
988 // page address of a constant pool entry, block address
989 def : Pat<(AArch64adrp tconstpool:$cp), (ADRP tconstpool:$cp)>;
990 def : Pat<(AArch64adrp tblockaddress:$cp), (ADRP tblockaddress:$cp)>;
992 //===----------------------------------------------------------------------===//
993 // Unconditional branch (register) instructions.
994 //===----------------------------------------------------------------------===//
996 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
997 def RET : BranchReg<0b0010, "ret", []>;
998 def DRPS : SpecialReturn<0b0101, "drps">;
999 def ERET : SpecialReturn<0b0100, "eret">;
1000 } // isReturn = 1, isTerminator = 1, isBarrier = 1
1002 // Default to the LR register.
1003 def : InstAlias<"ret", (RET LR)>;
1005 let isCall = 1, Defs = [LR], Uses = [SP] in {
1006 def BLR : BranchReg<0b0001, "blr", [(AArch64call GPR64:$Rn)]>;
1009 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
1010 def BR : BranchReg<0b0000, "br", [(brind GPR64:$Rn)]>;
1011 } // isBranch, isTerminator, isBarrier, isIndirectBranch
1013 // Create a separate pseudo-instruction for codegen to use so that we don't
1014 // flag lr as used in every function. It'll be restored before the RET by the
1015 // epilogue if it's legitimately used.
1016 def RET_ReallyLR : Pseudo<(outs), (ins), [(AArch64retflag)]> {
1017 let isTerminator = 1;
1022 // This is a directive-like pseudo-instruction. The purpose is to insert an
1023 // R_AARCH64_TLSDESC_CALL relocation at the offset of the following instruction
1024 // (which in the usual case is a BLR).
1025 let hasSideEffects = 1 in
1026 def TLSDESCCALL : Pseudo<(outs), (ins i64imm:$sym), []> {
1027 let AsmString = ".tlsdesccall $sym";
1030 // Pseudo-instruction representing a BLR with attached TLSDESC relocation. It
1031 // gets expanded to two MCInsts during lowering.
1032 let isCall = 1, Defs = [LR] in
1034 : Pseudo<(outs), (ins GPR64:$dest, i64imm:$sym),
1035 [(AArch64tlsdesc_call GPR64:$dest, tglobaltlsaddr:$sym)]>;
1037 def : Pat<(AArch64tlsdesc_call GPR64:$dest, texternalsym:$sym),
1038 (TLSDESC_BLR GPR64:$dest, texternalsym:$sym)>;
1039 //===----------------------------------------------------------------------===//
1040 // Conditional branch (immediate) instruction.
1041 //===----------------------------------------------------------------------===//
1042 def Bcc : BranchCond;
1044 //===----------------------------------------------------------------------===//
1045 // Compare-and-branch instructions.
1046 //===----------------------------------------------------------------------===//
1047 defm CBZ : CmpBranch<0, "cbz", AArch64cbz>;
1048 defm CBNZ : CmpBranch<1, "cbnz", AArch64cbnz>;
1050 //===----------------------------------------------------------------------===//
1051 // Test-bit-and-branch instructions.
1052 //===----------------------------------------------------------------------===//
1053 defm TBZ : TestBranch<0, "tbz", AArch64tbz>;
1054 defm TBNZ : TestBranch<1, "tbnz", AArch64tbnz>;
1056 //===----------------------------------------------------------------------===//
1057 // Unconditional branch (immediate) instructions.
1058 //===----------------------------------------------------------------------===//
1059 let isBranch = 1, isTerminator = 1, isBarrier = 1 in {
1060 def B : BranchImm<0, "b", [(br bb:$addr)]>;
1061 } // isBranch, isTerminator, isBarrier
1063 let isCall = 1, Defs = [LR], Uses = [SP] in {
1064 def BL : CallImm<1, "bl", [(AArch64call tglobaladdr:$addr)]>;
1066 def : Pat<(AArch64call texternalsym:$func), (BL texternalsym:$func)>;
1068 //===----------------------------------------------------------------------===//
1069 // Exception generation instructions.
1070 //===----------------------------------------------------------------------===//
1071 def BRK : ExceptionGeneration<0b001, 0b00, "brk">;
1072 def DCPS1 : ExceptionGeneration<0b101, 0b01, "dcps1">;
1073 def DCPS2 : ExceptionGeneration<0b101, 0b10, "dcps2">;
1074 def DCPS3 : ExceptionGeneration<0b101, 0b11, "dcps3">;
1075 def HLT : ExceptionGeneration<0b010, 0b00, "hlt">;
1076 def HVC : ExceptionGeneration<0b000, 0b10, "hvc">;
1077 def SMC : ExceptionGeneration<0b000, 0b11, "smc">;
1078 def SVC : ExceptionGeneration<0b000, 0b01, "svc">;
1080 // DCPSn defaults to an immediate operand of zero if unspecified.
1081 def : InstAlias<"dcps1", (DCPS1 0)>;
1082 def : InstAlias<"dcps2", (DCPS2 0)>;
1083 def : InstAlias<"dcps3", (DCPS3 0)>;
1085 //===----------------------------------------------------------------------===//
1086 // Load instructions.
1087 //===----------------------------------------------------------------------===//
1089 // Pair (indexed, offset)
1090 defm LDPW : LoadPairOffset<0b00, 0, GPR32, simm7s4, "ldp">;
1091 defm LDPX : LoadPairOffset<0b10, 0, GPR64, simm7s8, "ldp">;
1092 defm LDPS : LoadPairOffset<0b00, 1, FPR32, simm7s4, "ldp">;
1093 defm LDPD : LoadPairOffset<0b01, 1, FPR64, simm7s8, "ldp">;
1094 defm LDPQ : LoadPairOffset<0b10, 1, FPR128, simm7s16, "ldp">;
1096 defm LDPSW : LoadPairOffset<0b01, 0, GPR64, simm7s4, "ldpsw">;
1098 // Pair (pre-indexed)
1099 def LDPWpre : LoadPairPreIdx<0b00, 0, GPR32, simm7s4, "ldp">;
1100 def LDPXpre : LoadPairPreIdx<0b10, 0, GPR64, simm7s8, "ldp">;
1101 def LDPSpre : LoadPairPreIdx<0b00, 1, FPR32, simm7s4, "ldp">;
1102 def LDPDpre : LoadPairPreIdx<0b01, 1, FPR64, simm7s8, "ldp">;
1103 def LDPQpre : LoadPairPreIdx<0b10, 1, FPR128, simm7s16, "ldp">;
1105 def LDPSWpre : LoadPairPreIdx<0b01, 0, GPR64, simm7s4, "ldpsw">;
1107 // Pair (post-indexed)
1108 def LDPWpost : LoadPairPostIdx<0b00, 0, GPR32, simm7s4, "ldp">;
1109 def LDPXpost : LoadPairPostIdx<0b10, 0, GPR64, simm7s8, "ldp">;
1110 def LDPSpost : LoadPairPostIdx<0b00, 1, FPR32, simm7s4, "ldp">;
1111 def LDPDpost : LoadPairPostIdx<0b01, 1, FPR64, simm7s8, "ldp">;
1112 def LDPQpost : LoadPairPostIdx<0b10, 1, FPR128, simm7s16, "ldp">;
1114 def LDPSWpost : LoadPairPostIdx<0b01, 0, GPR64, simm7s4, "ldpsw">;
1117 // Pair (no allocate)
1118 defm LDNPW : LoadPairNoAlloc<0b00, 0, GPR32, simm7s4, "ldnp">;
1119 defm LDNPX : LoadPairNoAlloc<0b10, 0, GPR64, simm7s8, "ldnp">;
1120 defm LDNPS : LoadPairNoAlloc<0b00, 1, FPR32, simm7s4, "ldnp">;
1121 defm LDNPD : LoadPairNoAlloc<0b01, 1, FPR64, simm7s8, "ldnp">;
1122 defm LDNPQ : LoadPairNoAlloc<0b10, 1, FPR128, simm7s16, "ldnp">;
1125 // (register offset)
1129 defm LDRBB : Load8RO<0b00, 0, 0b01, GPR32, "ldrb", i32, zextloadi8>;
1130 defm LDRHH : Load16RO<0b01, 0, 0b01, GPR32, "ldrh", i32, zextloadi16>;
1131 defm LDRW : Load32RO<0b10, 0, 0b01, GPR32, "ldr", i32, load>;
1132 defm LDRX : Load64RO<0b11, 0, 0b01, GPR64, "ldr", i64, load>;
1135 defm LDRB : Load8RO<0b00, 1, 0b01, FPR8, "ldr", untyped, load>;
1136 defm LDRH : Load16RO<0b01, 1, 0b01, FPR16, "ldr", f16, load>;
1137 defm LDRS : Load32RO<0b10, 1, 0b01, FPR32, "ldr", f32, load>;
1138 defm LDRD : Load64RO<0b11, 1, 0b01, FPR64, "ldr", f64, load>;
1139 defm LDRQ : Load128RO<0b00, 1, 0b11, FPR128, "ldr", f128, load>;
1141 // Load sign-extended half-word
1142 defm LDRSHW : Load16RO<0b01, 0, 0b11, GPR32, "ldrsh", i32, sextloadi16>;
1143 defm LDRSHX : Load16RO<0b01, 0, 0b10, GPR64, "ldrsh", i64, sextloadi16>;
1145 // Load sign-extended byte
1146 defm LDRSBW : Load8RO<0b00, 0, 0b11, GPR32, "ldrsb", i32, sextloadi8>;
1147 defm LDRSBX : Load8RO<0b00, 0, 0b10, GPR64, "ldrsb", i64, sextloadi8>;
1149 // Load sign-extended word
1150 defm LDRSW : Load32RO<0b10, 0, 0b10, GPR64, "ldrsw", i64, sextloadi32>;
1153 defm PRFM : PrefetchRO<0b11, 0, 0b10, "prfm">;
1155 // For regular load, we do not have any alignment requirement.
1156 // Thus, it is safe to directly map the vector loads with interesting
1157 // addressing modes.
1158 // FIXME: We could do the same for bitconvert to floating point vectors.
1159 multiclass ScalToVecROLoadPat<ROAddrMode ro, SDPatternOperator loadop,
1160 ValueType ScalTy, ValueType VecTy,
1161 Instruction LOADW, Instruction LOADX,
1163 def : Pat<(VecTy (scalar_to_vector (ScalTy
1164 (loadop (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$offset))))),
1165 (INSERT_SUBREG (VecTy (IMPLICIT_DEF)),
1166 (LOADW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$offset),
1169 def : Pat<(VecTy (scalar_to_vector (ScalTy
1170 (loadop (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$offset))))),
1171 (INSERT_SUBREG (VecTy (IMPLICIT_DEF)),
1172 (LOADX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$offset),
1176 let AddedComplexity = 10 in {
1177 defm : ScalToVecROLoadPat<ro8, extloadi8, i32, v8i8, LDRBroW, LDRBroX, bsub>;
1178 defm : ScalToVecROLoadPat<ro8, extloadi8, i32, v16i8, LDRBroW, LDRBroX, bsub>;
1180 defm : ScalToVecROLoadPat<ro16, extloadi16, i32, v4i16, LDRHroW, LDRHroX, hsub>;
1181 defm : ScalToVecROLoadPat<ro16, extloadi16, i32, v8i16, LDRHroW, LDRHroX, hsub>;
1183 defm : ScalToVecROLoadPat<ro16, load, i32, v4f16, LDRHroW, LDRHroX, hsub>;
1184 defm : ScalToVecROLoadPat<ro16, load, i32, v8f16, LDRHroW, LDRHroX, hsub>;
1186 defm : ScalToVecROLoadPat<ro32, load, i32, v2i32, LDRSroW, LDRSroX, ssub>;
1187 defm : ScalToVecROLoadPat<ro32, load, i32, v4i32, LDRSroW, LDRSroX, ssub>;
1189 defm : ScalToVecROLoadPat<ro32, load, f32, v2f32, LDRSroW, LDRSroX, ssub>;
1190 defm : ScalToVecROLoadPat<ro32, load, f32, v4f32, LDRSroW, LDRSroX, ssub>;
1192 defm : ScalToVecROLoadPat<ro64, load, i64, v2i64, LDRDroW, LDRDroX, dsub>;
1194 defm : ScalToVecROLoadPat<ro64, load, f64, v2f64, LDRDroW, LDRDroX, dsub>;
1197 def : Pat <(v1i64 (scalar_to_vector (i64
1198 (load (ro_Windexed64 GPR64sp:$Rn, GPR32:$Rm,
1199 ro_Wextend64:$extend))))),
1200 (LDRDroW GPR64sp:$Rn, GPR32:$Rm, ro_Wextend64:$extend)>;
1202 def : Pat <(v1i64 (scalar_to_vector (i64
1203 (load (ro_Xindexed64 GPR64sp:$Rn, GPR64:$Rm,
1204 ro_Xextend64:$extend))))),
1205 (LDRDroX GPR64sp:$Rn, GPR64:$Rm, ro_Xextend64:$extend)>;
1208 // Match all load 64 bits width whose type is compatible with FPR64
1209 multiclass VecROLoadPat<ROAddrMode ro, ValueType VecTy,
1210 Instruction LOADW, Instruction LOADX> {
1212 def : Pat<(VecTy (load (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend))),
1213 (LOADW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
1215 def : Pat<(VecTy (load (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend))),
1216 (LOADX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
1219 let AddedComplexity = 10 in {
1220 let Predicates = [IsLE] in {
1221 // We must do vector loads with LD1 in big-endian.
1222 defm : VecROLoadPat<ro64, v2i32, LDRDroW, LDRDroX>;
1223 defm : VecROLoadPat<ro64, v2f32, LDRDroW, LDRDroX>;
1224 defm : VecROLoadPat<ro64, v8i8, LDRDroW, LDRDroX>;
1225 defm : VecROLoadPat<ro64, v4i16, LDRDroW, LDRDroX>;
1226 defm : VecROLoadPat<ro64, v4f16, LDRDroW, LDRDroX>;
1229 defm : VecROLoadPat<ro64, v1i64, LDRDroW, LDRDroX>;
1230 defm : VecROLoadPat<ro64, v1f64, LDRDroW, LDRDroX>;
1232 // Match all load 128 bits width whose type is compatible with FPR128
1233 let Predicates = [IsLE] in {
1234 // We must do vector loads with LD1 in big-endian.
1235 defm : VecROLoadPat<ro128, v2i64, LDRQroW, LDRQroX>;
1236 defm : VecROLoadPat<ro128, v2f64, LDRQroW, LDRQroX>;
1237 defm : VecROLoadPat<ro128, v4i32, LDRQroW, LDRQroX>;
1238 defm : VecROLoadPat<ro128, v4f32, LDRQroW, LDRQroX>;
1239 defm : VecROLoadPat<ro128, v8i16, LDRQroW, LDRQroX>;
1240 defm : VecROLoadPat<ro128, v8f16, LDRQroW, LDRQroX>;
1241 defm : VecROLoadPat<ro128, v16i8, LDRQroW, LDRQroX>;
1243 } // AddedComplexity = 10
1246 multiclass ExtLoadTo64ROPat<ROAddrMode ro, SDPatternOperator loadop,
1247 Instruction INSTW, Instruction INSTX> {
1248 def : Pat<(i64 (loadop (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend))),
1249 (SUBREG_TO_REG (i64 0),
1250 (INSTW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend),
1253 def : Pat<(i64 (loadop (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend))),
1254 (SUBREG_TO_REG (i64 0),
1255 (INSTX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend),
1259 let AddedComplexity = 10 in {
1260 defm : ExtLoadTo64ROPat<ro8, zextloadi8, LDRBBroW, LDRBBroX>;
1261 defm : ExtLoadTo64ROPat<ro16, zextloadi16, LDRHHroW, LDRHHroX>;
1262 defm : ExtLoadTo64ROPat<ro32, zextloadi32, LDRWroW, LDRWroX>;
1264 // zextloadi1 -> zextloadi8
1265 defm : ExtLoadTo64ROPat<ro8, zextloadi1, LDRBBroW, LDRBBroX>;
1267 // extload -> zextload
1268 defm : ExtLoadTo64ROPat<ro8, extloadi8, LDRBBroW, LDRBBroX>;
1269 defm : ExtLoadTo64ROPat<ro16, extloadi16, LDRHHroW, LDRHHroX>;
1270 defm : ExtLoadTo64ROPat<ro32, extloadi32, LDRWroW, LDRWroX>;
1272 // extloadi1 -> zextloadi8
1273 defm : ExtLoadTo64ROPat<ro8, extloadi1, LDRBBroW, LDRBBroX>;
1278 multiclass ExtLoadTo32ROPat<ROAddrMode ro, SDPatternOperator loadop,
1279 Instruction INSTW, Instruction INSTX> {
1280 def : Pat<(i32 (loadop (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend))),
1281 (INSTW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
1283 def : Pat<(i32 (loadop (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend))),
1284 (INSTX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
1288 let AddedComplexity = 10 in {
1289 // extload -> zextload
1290 defm : ExtLoadTo32ROPat<ro8, extloadi8, LDRBBroW, LDRBBroX>;
1291 defm : ExtLoadTo32ROPat<ro16, extloadi16, LDRHHroW, LDRHHroX>;
1292 defm : ExtLoadTo32ROPat<ro32, extloadi32, LDRWroW, LDRWroX>;
1294 // zextloadi1 -> zextloadi8
1295 defm : ExtLoadTo32ROPat<ro8, zextloadi1, LDRBBroW, LDRBBroX>;
1299 // (unsigned immediate)
1301 defm LDRX : LoadUI<0b11, 0, 0b01, GPR64, uimm12s8, "ldr",
1303 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)))]>;
1304 defm LDRW : LoadUI<0b10, 0, 0b01, GPR32, uimm12s4, "ldr",
1306 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset)))]>;
1307 defm LDRB : LoadUI<0b00, 1, 0b01, FPR8, uimm12s1, "ldr",
1309 (load (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset)))]>;
1310 defm LDRH : LoadUI<0b01, 1, 0b01, FPR16, uimm12s2, "ldr",
1311 [(set (f16 FPR16:$Rt),
1312 (load (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset)))]>;
1313 defm LDRS : LoadUI<0b10, 1, 0b01, FPR32, uimm12s4, "ldr",
1314 [(set (f32 FPR32:$Rt),
1315 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset)))]>;
1316 defm LDRD : LoadUI<0b11, 1, 0b01, FPR64, uimm12s8, "ldr",
1317 [(set (f64 FPR64:$Rt),
1318 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)))]>;
1319 defm LDRQ : LoadUI<0b00, 1, 0b11, FPR128, uimm12s16, "ldr",
1320 [(set (f128 FPR128:$Rt),
1321 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)))]>;
1323 // For regular load, we do not have any alignment requirement.
1324 // Thus, it is safe to directly map the vector loads with interesting
1325 // addressing modes.
1326 // FIXME: We could do the same for bitconvert to floating point vectors.
1327 def : Pat <(v8i8 (scalar_to_vector (i32
1328 (extloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))))),
1329 (INSERT_SUBREG (v8i8 (IMPLICIT_DEF)),
1330 (LDRBui GPR64sp:$Rn, uimm12s1:$offset), bsub)>;
1331 def : Pat <(v16i8 (scalar_to_vector (i32
1332 (extloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))))),
1333 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
1334 (LDRBui GPR64sp:$Rn, uimm12s1:$offset), bsub)>;
1335 def : Pat <(v4i16 (scalar_to_vector (i32
1336 (extloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))))),
1337 (INSERT_SUBREG (v4i16 (IMPLICIT_DEF)),
1338 (LDRHui GPR64sp:$Rn, uimm12s2:$offset), hsub)>;
1339 def : Pat <(v8i16 (scalar_to_vector (i32
1340 (extloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))))),
1341 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)),
1342 (LDRHui GPR64sp:$Rn, uimm12s2:$offset), hsub)>;
1343 def : Pat <(v2i32 (scalar_to_vector (i32
1344 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))))),
1345 (INSERT_SUBREG (v2i32 (IMPLICIT_DEF)),
1346 (LDRSui GPR64sp:$Rn, uimm12s4:$offset), ssub)>;
1347 def : Pat <(v4i32 (scalar_to_vector (i32
1348 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))))),
1349 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)),
1350 (LDRSui GPR64sp:$Rn, uimm12s4:$offset), ssub)>;
1351 def : Pat <(v1i64 (scalar_to_vector (i64
1352 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))))),
1353 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
1354 def : Pat <(v2i64 (scalar_to_vector (i64
1355 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))))),
1356 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)),
1357 (LDRDui GPR64sp:$Rn, uimm12s8:$offset), dsub)>;
1359 // Match all load 64 bits width whose type is compatible with FPR64
1360 let Predicates = [IsLE] in {
1361 // We must use LD1 to perform vector loads in big-endian.
1362 def : Pat<(v2f32 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
1363 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
1364 def : Pat<(v8i8 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
1365 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
1366 def : Pat<(v4i16 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
1367 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
1368 def : Pat<(v2i32 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
1369 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
1370 def : Pat<(v4f16 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
1371 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
1373 def : Pat<(v1f64 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
1374 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
1375 def : Pat<(v1i64 (load (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))),
1376 (LDRDui GPR64sp:$Rn, uimm12s8:$offset)>;
1378 // Match all load 128 bits width whose type is compatible with FPR128
1379 let Predicates = [IsLE] in {
1380 // We must use LD1 to perform vector loads in big-endian.
1381 def : Pat<(v4f32 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
1382 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
1383 def : Pat<(v2f64 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
1384 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
1385 def : Pat<(v16i8 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
1386 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
1387 def : Pat<(v8i16 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
1388 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
1389 def : Pat<(v4i32 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
1390 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
1391 def : Pat<(v2i64 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
1392 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
1393 def : Pat<(v8f16 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
1394 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
1396 def : Pat<(f128 (load (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset))),
1397 (LDRQui GPR64sp:$Rn, uimm12s16:$offset)>;
1399 defm LDRHH : LoadUI<0b01, 0, 0b01, GPR32, uimm12s2, "ldrh",
1401 (zextloadi16 (am_indexed16 GPR64sp:$Rn,
1402 uimm12s2:$offset)))]>;
1403 defm LDRBB : LoadUI<0b00, 0, 0b01, GPR32, uimm12s1, "ldrb",
1405 (zextloadi8 (am_indexed8 GPR64sp:$Rn,
1406 uimm12s1:$offset)))]>;
1408 def : Pat<(i64 (zextloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
1409 (SUBREG_TO_REG (i64 0), (LDRBBui GPR64sp:$Rn, uimm12s1:$offset), sub_32)>;
1410 def : Pat<(i64 (zextloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))),
1411 (SUBREG_TO_REG (i64 0), (LDRHHui GPR64sp:$Rn, uimm12s2:$offset), sub_32)>;
1413 // zextloadi1 -> zextloadi8
1414 def : Pat<(i32 (zextloadi1 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
1415 (LDRBBui GPR64sp:$Rn, uimm12s1:$offset)>;
1416 def : Pat<(i64 (zextloadi1 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
1417 (SUBREG_TO_REG (i64 0), (LDRBBui GPR64sp:$Rn, uimm12s1:$offset), sub_32)>;
1419 // extload -> zextload
1420 def : Pat<(i32 (extloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))),
1421 (LDRHHui GPR64sp:$Rn, uimm12s2:$offset)>;
1422 def : Pat<(i32 (extloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
1423 (LDRBBui GPR64sp:$Rn, uimm12s1:$offset)>;
1424 def : Pat<(i32 (extloadi1 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
1425 (LDRBBui GPR64sp:$Rn, uimm12s1:$offset)>;
1426 def : Pat<(i64 (extloadi32 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))),
1427 (SUBREG_TO_REG (i64 0), (LDRWui GPR64sp:$Rn, uimm12s4:$offset), sub_32)>;
1428 def : Pat<(i64 (extloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))),
1429 (SUBREG_TO_REG (i64 0), (LDRHHui GPR64sp:$Rn, uimm12s2:$offset), sub_32)>;
1430 def : Pat<(i64 (extloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
1431 (SUBREG_TO_REG (i64 0), (LDRBBui GPR64sp:$Rn, uimm12s1:$offset), sub_32)>;
1432 def : Pat<(i64 (extloadi1 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))),
1433 (SUBREG_TO_REG (i64 0), (LDRBBui GPR64sp:$Rn, uimm12s1:$offset), sub_32)>;
1435 // load sign-extended half-word
1436 defm LDRSHW : LoadUI<0b01, 0, 0b11, GPR32, uimm12s2, "ldrsh",
1438 (sextloadi16 (am_indexed16 GPR64sp:$Rn,
1439 uimm12s2:$offset)))]>;
1440 defm LDRSHX : LoadUI<0b01, 0, 0b10, GPR64, uimm12s2, "ldrsh",
1442 (sextloadi16 (am_indexed16 GPR64sp:$Rn,
1443 uimm12s2:$offset)))]>;
1445 // load sign-extended byte
1446 defm LDRSBW : LoadUI<0b00, 0, 0b11, GPR32, uimm12s1, "ldrsb",
1448 (sextloadi8 (am_indexed8 GPR64sp:$Rn,
1449 uimm12s1:$offset)))]>;
1450 defm LDRSBX : LoadUI<0b00, 0, 0b10, GPR64, uimm12s1, "ldrsb",
1452 (sextloadi8 (am_indexed8 GPR64sp:$Rn,
1453 uimm12s1:$offset)))]>;
1455 // load sign-extended word
1456 defm LDRSW : LoadUI<0b10, 0, 0b10, GPR64, uimm12s4, "ldrsw",
1458 (sextloadi32 (am_indexed32 GPR64sp:$Rn,
1459 uimm12s4:$offset)))]>;
1461 // load zero-extended word
1462 def : Pat<(i64 (zextloadi32 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))),
1463 (SUBREG_TO_REG (i64 0), (LDRWui GPR64sp:$Rn, uimm12s4:$offset), sub_32)>;
1466 def PRFMui : PrefetchUI<0b11, 0, 0b10, "prfm",
1467 [(AArch64Prefetch imm:$Rt,
1468 (am_indexed64 GPR64sp:$Rn,
1469 uimm12s8:$offset))]>;
1471 def : InstAlias<"prfm $Rt, [$Rn]", (PRFMui prfop:$Rt, GPR64sp:$Rn, 0)>;
1475 def LDRWl : LoadLiteral<0b00, 0, GPR32, "ldr">;
1476 def LDRXl : LoadLiteral<0b01, 0, GPR64, "ldr">;
1477 def LDRSl : LoadLiteral<0b00, 1, FPR32, "ldr">;
1478 def LDRDl : LoadLiteral<0b01, 1, FPR64, "ldr">;
1479 def LDRQl : LoadLiteral<0b10, 1, FPR128, "ldr">;
1481 // load sign-extended word
1482 def LDRSWl : LoadLiteral<0b10, 0, GPR64, "ldrsw">;
1485 def PRFMl : PrefetchLiteral<0b11, 0, "prfm", []>;
1486 // [(AArch64Prefetch imm:$Rt, tglobaladdr:$label)]>;
1489 // (unscaled immediate)
1490 defm LDURX : LoadUnscaled<0b11, 0, 0b01, GPR64, "ldur",
1492 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset)))]>;
1493 defm LDURW : LoadUnscaled<0b10, 0, 0b01, GPR32, "ldur",
1495 (load (am_unscaled32 GPR64sp:$Rn, simm9:$offset)))]>;
1496 defm LDURB : LoadUnscaled<0b00, 1, 0b01, FPR8, "ldur",
1498 (load (am_unscaled8 GPR64sp:$Rn, simm9:$offset)))]>;
1499 defm LDURH : LoadUnscaled<0b01, 1, 0b01, FPR16, "ldur",
1501 (load (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
1502 defm LDURS : LoadUnscaled<0b10, 1, 0b01, FPR32, "ldur",
1503 [(set (f32 FPR32:$Rt),
1504 (load (am_unscaled32 GPR64sp:$Rn, simm9:$offset)))]>;
1505 defm LDURD : LoadUnscaled<0b11, 1, 0b01, FPR64, "ldur",
1506 [(set (f64 FPR64:$Rt),
1507 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset)))]>;
1508 defm LDURQ : LoadUnscaled<0b00, 1, 0b11, FPR128, "ldur",
1509 [(set (f128 FPR128:$Rt),
1510 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset)))]>;
1513 : LoadUnscaled<0b01, 0, 0b01, GPR32, "ldurh",
1515 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
1517 : LoadUnscaled<0b00, 0, 0b01, GPR32, "ldurb",
1519 (zextloadi8 (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
1521 // Match all load 64 bits width whose type is compatible with FPR64
1522 let Predicates = [IsLE] in {
1523 def : Pat<(v2f32 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
1524 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
1525 def : Pat<(v2i32 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
1526 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
1527 def : Pat<(v4i16 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
1528 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
1529 def : Pat<(v8i8 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
1530 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
1531 def : Pat<(v4f16 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
1532 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
1534 def : Pat<(v1f64 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
1535 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
1536 def : Pat<(v1i64 (load (am_unscaled64 GPR64sp:$Rn, simm9:$offset))),
1537 (LDURDi GPR64sp:$Rn, simm9:$offset)>;
1539 // Match all load 128 bits width whose type is compatible with FPR128
1540 let Predicates = [IsLE] in {
1541 def : Pat<(v2f64 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
1542 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
1543 def : Pat<(v2i64 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
1544 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
1545 def : Pat<(v4f32 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
1546 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
1547 def : Pat<(v4i32 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
1548 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
1549 def : Pat<(v8i16 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
1550 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
1551 def : Pat<(v16i8 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
1552 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
1553 def : Pat<(v8f16 (load (am_unscaled128 GPR64sp:$Rn, simm9:$offset))),
1554 (LDURQi GPR64sp:$Rn, simm9:$offset)>;
1558 def : Pat<(i32 (extloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
1559 (LDURHHi GPR64sp:$Rn, simm9:$offset)>;
1560 def : Pat<(i32 (extloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
1561 (LDURBBi GPR64sp:$Rn, simm9:$offset)>;
1562 def : Pat<(i32 (extloadi1 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
1563 (LDURBBi GPR64sp:$Rn, simm9:$offset)>;
1564 def : Pat<(i64 (extloadi32 (am_unscaled32 GPR64sp:$Rn, simm9:$offset))),
1565 (SUBREG_TO_REG (i64 0), (LDURWi GPR64sp:$Rn, simm9:$offset), sub_32)>;
1566 def : Pat<(i64 (extloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
1567 (SUBREG_TO_REG (i64 0), (LDURHHi GPR64sp:$Rn, simm9:$offset), sub_32)>;
1568 def : Pat<(i64 (extloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
1569 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
1570 def : Pat<(i64 (extloadi1 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
1571 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
1573 def : Pat<(i32 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
1574 (LDURHHi GPR64sp:$Rn, simm9:$offset)>;
1575 def : Pat<(i32 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
1576 (LDURBBi GPR64sp:$Rn, simm9:$offset)>;
1577 def : Pat<(i32 (zextloadi1 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
1578 (LDURBBi GPR64sp:$Rn, simm9:$offset)>;
1579 def : Pat<(i64 (zextloadi32 (am_unscaled32 GPR64sp:$Rn, simm9:$offset))),
1580 (SUBREG_TO_REG (i64 0), (LDURWi GPR64sp:$Rn, simm9:$offset), sub_32)>;
1581 def : Pat<(i64 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
1582 (SUBREG_TO_REG (i64 0), (LDURHHi GPR64sp:$Rn, simm9:$offset), sub_32)>;
1583 def : Pat<(i64 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
1584 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
1585 def : Pat<(i64 (zextloadi1 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
1586 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
1590 // LDR mnemonics fall back to LDUR for negative or unaligned offsets.
1592 // Define new assembler match classes as we want to only match these when
1593 // the don't otherwise match the scaled addressing mode for LDR/STR. Don't
1594 // associate a DiagnosticType either, as we want the diagnostic for the
1595 // canonical form (the scaled operand) to take precedence.
1596 class SImm9OffsetOperand<int Width> : AsmOperandClass {
1597 let Name = "SImm9OffsetFB" # Width;
1598 let PredicateMethod = "isSImm9OffsetFB<" # Width # ">";
1599 let RenderMethod = "addImmOperands";
1602 def SImm9OffsetFB8Operand : SImm9OffsetOperand<8>;
1603 def SImm9OffsetFB16Operand : SImm9OffsetOperand<16>;
1604 def SImm9OffsetFB32Operand : SImm9OffsetOperand<32>;
1605 def SImm9OffsetFB64Operand : SImm9OffsetOperand<64>;
1606 def SImm9OffsetFB128Operand : SImm9OffsetOperand<128>;
1608 def simm9_offset_fb8 : Operand<i64> {
1609 let ParserMatchClass = SImm9OffsetFB8Operand;
1611 def simm9_offset_fb16 : Operand<i64> {
1612 let ParserMatchClass = SImm9OffsetFB16Operand;
1614 def simm9_offset_fb32 : Operand<i64> {
1615 let ParserMatchClass = SImm9OffsetFB32Operand;
1617 def simm9_offset_fb64 : Operand<i64> {
1618 let ParserMatchClass = SImm9OffsetFB64Operand;
1620 def simm9_offset_fb128 : Operand<i64> {
1621 let ParserMatchClass = SImm9OffsetFB128Operand;
1624 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
1625 (LDURXi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb64:$offset), 0>;
1626 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
1627 (LDURWi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
1628 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
1629 (LDURBi FPR8:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
1630 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
1631 (LDURHi FPR16:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
1632 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
1633 (LDURSi FPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
1634 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
1635 (LDURDi FPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb64:$offset), 0>;
1636 def : InstAlias<"ldr $Rt, [$Rn, $offset]",
1637 (LDURQi FPR128:$Rt, GPR64sp:$Rn, simm9_offset_fb128:$offset), 0>;
1640 def : Pat<(i64 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))),
1641 (SUBREG_TO_REG (i64 0), (LDURBBi GPR64sp:$Rn, simm9:$offset), sub_32)>;
1642 def : Pat<(i64 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))),
1643 (SUBREG_TO_REG (i64 0), (LDURHHi GPR64sp:$Rn, simm9:$offset), sub_32)>;
1645 // load sign-extended half-word
1647 : LoadUnscaled<0b01, 0, 0b11, GPR32, "ldursh",
1649 (sextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
1651 : LoadUnscaled<0b01, 0, 0b10, GPR64, "ldursh",
1653 (sextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset)))]>;
1655 // load sign-extended byte
1657 : LoadUnscaled<0b00, 0, 0b11, GPR32, "ldursb",
1659 (sextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset)))]>;
1661 : LoadUnscaled<0b00, 0, 0b10, GPR64, "ldursb",
1663 (sextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset)))]>;
1665 // load sign-extended word
1667 : LoadUnscaled<0b10, 0, 0b10, GPR64, "ldursw",
1669 (sextloadi32 (am_unscaled32 GPR64sp:$Rn, simm9:$offset)))]>;
1671 // zero and sign extending aliases from generic LDR* mnemonics to LDUR*.
1672 def : InstAlias<"ldrb $Rt, [$Rn, $offset]",
1673 (LDURBBi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
1674 def : InstAlias<"ldrh $Rt, [$Rn, $offset]",
1675 (LDURHHi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
1676 def : InstAlias<"ldrsb $Rt, [$Rn, $offset]",
1677 (LDURSBWi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
1678 def : InstAlias<"ldrsb $Rt, [$Rn, $offset]",
1679 (LDURSBXi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
1680 def : InstAlias<"ldrsh $Rt, [$Rn, $offset]",
1681 (LDURSHWi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
1682 def : InstAlias<"ldrsh $Rt, [$Rn, $offset]",
1683 (LDURSHXi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
1684 def : InstAlias<"ldrsw $Rt, [$Rn, $offset]",
1685 (LDURSWi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
1688 defm PRFUM : PrefetchUnscaled<0b11, 0, 0b10, "prfum",
1689 [(AArch64Prefetch imm:$Rt,
1690 (am_unscaled64 GPR64sp:$Rn, simm9:$offset))]>;
1693 // (unscaled immediate, unprivileged)
1694 defm LDTRX : LoadUnprivileged<0b11, 0, 0b01, GPR64, "ldtr">;
1695 defm LDTRW : LoadUnprivileged<0b10, 0, 0b01, GPR32, "ldtr">;
1697 defm LDTRH : LoadUnprivileged<0b01, 0, 0b01, GPR32, "ldtrh">;
1698 defm LDTRB : LoadUnprivileged<0b00, 0, 0b01, GPR32, "ldtrb">;
1700 // load sign-extended half-word
1701 defm LDTRSHW : LoadUnprivileged<0b01, 0, 0b11, GPR32, "ldtrsh">;
1702 defm LDTRSHX : LoadUnprivileged<0b01, 0, 0b10, GPR64, "ldtrsh">;
1704 // load sign-extended byte
1705 defm LDTRSBW : LoadUnprivileged<0b00, 0, 0b11, GPR32, "ldtrsb">;
1706 defm LDTRSBX : LoadUnprivileged<0b00, 0, 0b10, GPR64, "ldtrsb">;
1708 // load sign-extended word
1709 defm LDTRSW : LoadUnprivileged<0b10, 0, 0b10, GPR64, "ldtrsw">;
1712 // (immediate pre-indexed)
1713 def LDRWpre : LoadPreIdx<0b10, 0, 0b01, GPR32, "ldr">;
1714 def LDRXpre : LoadPreIdx<0b11, 0, 0b01, GPR64, "ldr">;
1715 def LDRBpre : LoadPreIdx<0b00, 1, 0b01, FPR8, "ldr">;
1716 def LDRHpre : LoadPreIdx<0b01, 1, 0b01, FPR16, "ldr">;
1717 def LDRSpre : LoadPreIdx<0b10, 1, 0b01, FPR32, "ldr">;
1718 def LDRDpre : LoadPreIdx<0b11, 1, 0b01, FPR64, "ldr">;
1719 def LDRQpre : LoadPreIdx<0b00, 1, 0b11, FPR128, "ldr">;
1721 // load sign-extended half-word
1722 def LDRSHWpre : LoadPreIdx<0b01, 0, 0b11, GPR32, "ldrsh">;
1723 def LDRSHXpre : LoadPreIdx<0b01, 0, 0b10, GPR64, "ldrsh">;
1725 // load sign-extended byte
1726 def LDRSBWpre : LoadPreIdx<0b00, 0, 0b11, GPR32, "ldrsb">;
1727 def LDRSBXpre : LoadPreIdx<0b00, 0, 0b10, GPR64, "ldrsb">;
1729 // load zero-extended byte
1730 def LDRBBpre : LoadPreIdx<0b00, 0, 0b01, GPR32, "ldrb">;
1731 def LDRHHpre : LoadPreIdx<0b01, 0, 0b01, GPR32, "ldrh">;
1733 // load sign-extended word
1734 def LDRSWpre : LoadPreIdx<0b10, 0, 0b10, GPR64, "ldrsw">;
1737 // (immediate post-indexed)
1738 def LDRWpost : LoadPostIdx<0b10, 0, 0b01, GPR32, "ldr">;
1739 def LDRXpost : LoadPostIdx<0b11, 0, 0b01, GPR64, "ldr">;
1740 def LDRBpost : LoadPostIdx<0b00, 1, 0b01, FPR8, "ldr">;
1741 def LDRHpost : LoadPostIdx<0b01, 1, 0b01, FPR16, "ldr">;
1742 def LDRSpost : LoadPostIdx<0b10, 1, 0b01, FPR32, "ldr">;
1743 def LDRDpost : LoadPostIdx<0b11, 1, 0b01, FPR64, "ldr">;
1744 def LDRQpost : LoadPostIdx<0b00, 1, 0b11, FPR128, "ldr">;
1746 // load sign-extended half-word
1747 def LDRSHWpost : LoadPostIdx<0b01, 0, 0b11, GPR32, "ldrsh">;
1748 def LDRSHXpost : LoadPostIdx<0b01, 0, 0b10, GPR64, "ldrsh">;
1750 // load sign-extended byte
1751 def LDRSBWpost : LoadPostIdx<0b00, 0, 0b11, GPR32, "ldrsb">;
1752 def LDRSBXpost : LoadPostIdx<0b00, 0, 0b10, GPR64, "ldrsb">;
1754 // load zero-extended byte
1755 def LDRBBpost : LoadPostIdx<0b00, 0, 0b01, GPR32, "ldrb">;
1756 def LDRHHpost : LoadPostIdx<0b01, 0, 0b01, GPR32, "ldrh">;
1758 // load sign-extended word
1759 def LDRSWpost : LoadPostIdx<0b10, 0, 0b10, GPR64, "ldrsw">;
1761 //===----------------------------------------------------------------------===//
1762 // Store instructions.
1763 //===----------------------------------------------------------------------===//
1765 // Pair (indexed, offset)
1766 // FIXME: Use dedicated range-checked addressing mode operand here.
1767 defm STPW : StorePairOffset<0b00, 0, GPR32, simm7s4, "stp">;
1768 defm STPX : StorePairOffset<0b10, 0, GPR64, simm7s8, "stp">;
1769 defm STPS : StorePairOffset<0b00, 1, FPR32, simm7s4, "stp">;
1770 defm STPD : StorePairOffset<0b01, 1, FPR64, simm7s8, "stp">;
1771 defm STPQ : StorePairOffset<0b10, 1, FPR128, simm7s16, "stp">;
1773 // Pair (pre-indexed)
1774 def STPWpre : StorePairPreIdx<0b00, 0, GPR32, simm7s4, "stp">;
1775 def STPXpre : StorePairPreIdx<0b10, 0, GPR64, simm7s8, "stp">;
1776 def STPSpre : StorePairPreIdx<0b00, 1, FPR32, simm7s4, "stp">;
1777 def STPDpre : StorePairPreIdx<0b01, 1, FPR64, simm7s8, "stp">;
1778 def STPQpre : StorePairPreIdx<0b10, 1, FPR128, simm7s16, "stp">;
1780 // Pair (pre-indexed)
1781 def STPWpost : StorePairPostIdx<0b00, 0, GPR32, simm7s4, "stp">;
1782 def STPXpost : StorePairPostIdx<0b10, 0, GPR64, simm7s8, "stp">;
1783 def STPSpost : StorePairPostIdx<0b00, 1, FPR32, simm7s4, "stp">;
1784 def STPDpost : StorePairPostIdx<0b01, 1, FPR64, simm7s8, "stp">;
1785 def STPQpost : StorePairPostIdx<0b10, 1, FPR128, simm7s16, "stp">;
1787 // Pair (no allocate)
1788 defm STNPW : StorePairNoAlloc<0b00, 0, GPR32, simm7s4, "stnp">;
1789 defm STNPX : StorePairNoAlloc<0b10, 0, GPR64, simm7s8, "stnp">;
1790 defm STNPS : StorePairNoAlloc<0b00, 1, FPR32, simm7s4, "stnp">;
1791 defm STNPD : StorePairNoAlloc<0b01, 1, FPR64, simm7s8, "stnp">;
1792 defm STNPQ : StorePairNoAlloc<0b10, 1, FPR128, simm7s16, "stnp">;
1795 // (Register offset)
1798 defm STRBB : Store8RO< 0b00, 0, 0b00, GPR32, "strb", i32, truncstorei8>;
1799 defm STRHH : Store16RO<0b01, 0, 0b00, GPR32, "strh", i32, truncstorei16>;
1800 defm STRW : Store32RO<0b10, 0, 0b00, GPR32, "str", i32, store>;
1801 defm STRX : Store64RO<0b11, 0, 0b00, GPR64, "str", i64, store>;
1805 defm STRB : Store8RO< 0b00, 1, 0b00, FPR8, "str", untyped, store>;
1806 defm STRH : Store16RO<0b01, 1, 0b00, FPR16, "str", f16, store>;
1807 defm STRS : Store32RO<0b10, 1, 0b00, FPR32, "str", f32, store>;
1808 defm STRD : Store64RO<0b11, 1, 0b00, FPR64, "str", f64, store>;
1809 defm STRQ : Store128RO<0b00, 1, 0b10, FPR128, "str", f128, store>;
1811 multiclass TruncStoreFrom64ROPat<ROAddrMode ro, SDPatternOperator storeop,
1812 Instruction STRW, Instruction STRX> {
1814 def : Pat<(storeop GPR64:$Rt,
1815 (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)),
1816 (STRW (EXTRACT_SUBREG GPR64:$Rt, sub_32),
1817 GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
1819 def : Pat<(storeop GPR64:$Rt,
1820 (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)),
1821 (STRX (EXTRACT_SUBREG GPR64:$Rt, sub_32),
1822 GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
1825 let AddedComplexity = 10 in {
1827 defm : TruncStoreFrom64ROPat<ro8, truncstorei8, STRBBroW, STRBBroX>;
1828 defm : TruncStoreFrom64ROPat<ro16, truncstorei16, STRHHroW, STRHHroX>;
1829 defm : TruncStoreFrom64ROPat<ro32, truncstorei32, STRWroW, STRWroX>;
1832 multiclass VecROStorePat<ROAddrMode ro, ValueType VecTy, RegisterClass FPR,
1833 Instruction STRW, Instruction STRX> {
1834 def : Pat<(store (VecTy FPR:$Rt),
1835 (ro.Wpat GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)),
1836 (STRW FPR:$Rt, GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend)>;
1838 def : Pat<(store (VecTy FPR:$Rt),
1839 (ro.Xpat GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)),
1840 (STRX FPR:$Rt, GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend)>;
1843 let AddedComplexity = 10 in {
1844 // Match all store 64 bits width whose type is compatible with FPR64
1845 let Predicates = [IsLE] in {
1846 // We must use ST1 to store vectors in big-endian.
1847 defm : VecROStorePat<ro64, v2i32, FPR64, STRDroW, STRDroX>;
1848 defm : VecROStorePat<ro64, v2f32, FPR64, STRDroW, STRDroX>;
1849 defm : VecROStorePat<ro64, v4i16, FPR64, STRDroW, STRDroX>;
1850 defm : VecROStorePat<ro64, v8i8, FPR64, STRDroW, STRDroX>;
1851 defm : VecROStorePat<ro64, v4f16, FPR64, STRDroW, STRDroX>;
1854 defm : VecROStorePat<ro64, v1i64, FPR64, STRDroW, STRDroX>;
1855 defm : VecROStorePat<ro64, v1f64, FPR64, STRDroW, STRDroX>;
1857 // Match all store 128 bits width whose type is compatible with FPR128
1858 let Predicates = [IsLE] in {
1859 // We must use ST1 to store vectors in big-endian.
1860 defm : VecROStorePat<ro128, v2i64, FPR128, STRQroW, STRQroX>;
1861 defm : VecROStorePat<ro128, v2f64, FPR128, STRQroW, STRQroX>;
1862 defm : VecROStorePat<ro128, v4i32, FPR128, STRQroW, STRQroX>;
1863 defm : VecROStorePat<ro128, v4f32, FPR128, STRQroW, STRQroX>;
1864 defm : VecROStorePat<ro128, v8i16, FPR128, STRQroW, STRQroX>;
1865 defm : VecROStorePat<ro128, v16i8, FPR128, STRQroW, STRQroX>;
1866 defm : VecROStorePat<ro128, v8f16, FPR128, STRQroW, STRQroX>;
1868 } // AddedComplexity = 10
1871 // (unsigned immediate)
1872 defm STRX : StoreUI<0b11, 0, 0b00, GPR64, uimm12s8, "str",
1874 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))]>;
1875 defm STRW : StoreUI<0b10, 0, 0b00, GPR32, uimm12s4, "str",
1877 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))]>;
1878 defm STRB : StoreUI<0b00, 1, 0b00, FPR8, uimm12s1, "str",
1880 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))]>;
1881 defm STRH : StoreUI<0b01, 1, 0b00, FPR16, uimm12s2, "str",
1882 [(store (f16 FPR16:$Rt),
1883 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))]>;
1884 defm STRS : StoreUI<0b10, 1, 0b00, FPR32, uimm12s4, "str",
1885 [(store (f32 FPR32:$Rt),
1886 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))]>;
1887 defm STRD : StoreUI<0b11, 1, 0b00, FPR64, uimm12s8, "str",
1888 [(store (f64 FPR64:$Rt),
1889 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset))]>;
1890 defm STRQ : StoreUI<0b00, 1, 0b10, FPR128, uimm12s16, "str", []>;
1892 defm STRHH : StoreUI<0b01, 0, 0b00, GPR32, uimm12s2, "strh",
1893 [(truncstorei16 GPR32:$Rt,
1894 (am_indexed16 GPR64sp:$Rn,
1895 uimm12s2:$offset))]>;
1896 defm STRBB : StoreUI<0b00, 0, 0b00, GPR32, uimm12s1, "strb",
1897 [(truncstorei8 GPR32:$Rt,
1898 (am_indexed8 GPR64sp:$Rn,
1899 uimm12s1:$offset))]>;
1901 // Match all store 64 bits width whose type is compatible with FPR64
1902 let AddedComplexity = 10 in {
1903 let Predicates = [IsLE] in {
1904 // We must use ST1 to store vectors in big-endian.
1905 def : Pat<(store (v2f32 FPR64:$Rt),
1906 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
1907 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
1908 def : Pat<(store (v8i8 FPR64:$Rt),
1909 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
1910 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
1911 def : Pat<(store (v4i16 FPR64:$Rt),
1912 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
1913 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
1914 def : Pat<(store (v2i32 FPR64:$Rt),
1915 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
1916 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
1917 def : Pat<(store (v4f16 FPR64:$Rt),
1918 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
1919 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
1921 def : Pat<(store (v1f64 FPR64:$Rt),
1922 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
1923 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
1924 def : Pat<(store (v1i64 FPR64:$Rt),
1925 (am_indexed64 GPR64sp:$Rn, uimm12s8:$offset)),
1926 (STRDui FPR64:$Rt, GPR64sp:$Rn, uimm12s8:$offset)>;
1928 // Match all store 128 bits width whose type is compatible with FPR128
1929 let Predicates = [IsLE] in {
1930 // We must use ST1 to store vectors in big-endian.
1931 def : Pat<(store (v4f32 FPR128:$Rt),
1932 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
1933 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
1934 def : Pat<(store (v2f64 FPR128:$Rt),
1935 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
1936 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
1937 def : Pat<(store (v16i8 FPR128:$Rt),
1938 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
1939 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
1940 def : Pat<(store (v8i16 FPR128:$Rt),
1941 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
1942 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
1943 def : Pat<(store (v4i32 FPR128:$Rt),
1944 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
1945 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
1946 def : Pat<(store (v2i64 FPR128:$Rt),
1947 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
1948 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
1949 def : Pat<(store (v8f16 FPR128:$Rt),
1950 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
1951 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
1953 def : Pat<(store (f128 FPR128:$Rt),
1954 (am_indexed128 GPR64sp:$Rn, uimm12s16:$offset)),
1955 (STRQui FPR128:$Rt, GPR64sp:$Rn, uimm12s16:$offset)>;
1958 def : Pat<(truncstorei32 GPR64:$Rt,
1959 (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset)),
1960 (STRWui (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, uimm12s4:$offset)>;
1961 def : Pat<(truncstorei16 GPR64:$Rt,
1962 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset)),
1963 (STRHHui (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, uimm12s2:$offset)>;
1964 def : Pat<(truncstorei8 GPR64:$Rt, (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset)),
1965 (STRBBui (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, uimm12s1:$offset)>;
1967 } // AddedComplexity = 10
1970 // (unscaled immediate)
1971 defm STURX : StoreUnscaled<0b11, 0, 0b00, GPR64, "stur",
1973 (am_unscaled64 GPR64sp:$Rn, simm9:$offset))]>;
1974 defm STURW : StoreUnscaled<0b10, 0, 0b00, GPR32, "stur",
1976 (am_unscaled32 GPR64sp:$Rn, simm9:$offset))]>;
1977 defm STURB : StoreUnscaled<0b00, 1, 0b00, FPR8, "stur",
1979 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))]>;
1980 defm STURH : StoreUnscaled<0b01, 1, 0b00, FPR16, "stur",
1981 [(store (f16 FPR16:$Rt),
1982 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))]>;
1983 defm STURS : StoreUnscaled<0b10, 1, 0b00, FPR32, "stur",
1984 [(store (f32 FPR32:$Rt),
1985 (am_unscaled32 GPR64sp:$Rn, simm9:$offset))]>;
1986 defm STURD : StoreUnscaled<0b11, 1, 0b00, FPR64, "stur",
1987 [(store (f64 FPR64:$Rt),
1988 (am_unscaled64 GPR64sp:$Rn, simm9:$offset))]>;
1989 defm STURQ : StoreUnscaled<0b00, 1, 0b10, FPR128, "stur",
1990 [(store (f128 FPR128:$Rt),
1991 (am_unscaled128 GPR64sp:$Rn, simm9:$offset))]>;
1992 defm STURHH : StoreUnscaled<0b01, 0, 0b00, GPR32, "sturh",
1993 [(truncstorei16 GPR32:$Rt,
1994 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))]>;
1995 defm STURBB : StoreUnscaled<0b00, 0, 0b00, GPR32, "sturb",
1996 [(truncstorei8 GPR32:$Rt,
1997 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))]>;
1999 // Match all store 64 bits width whose type is compatible with FPR64
2000 let Predicates = [IsLE] in {
2001 // We must use ST1 to store vectors in big-endian.
2002 def : Pat<(store (v2f32 FPR64:$Rt),
2003 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2004 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2005 def : Pat<(store (v8i8 FPR64:$Rt),
2006 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2007 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2008 def : Pat<(store (v4i16 FPR64:$Rt),
2009 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2010 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2011 def : Pat<(store (v2i32 FPR64:$Rt),
2012 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2013 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2014 def : Pat<(store (v4f16 FPR64:$Rt),
2015 (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2016 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2018 def : Pat<(store (v1f64 FPR64:$Rt), (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2019 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2020 def : Pat<(store (v1i64 FPR64:$Rt), (am_unscaled64 GPR64sp:$Rn, simm9:$offset)),
2021 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2023 // Match all store 128 bits width whose type is compatible with FPR128
2024 let Predicates = [IsLE] in {
2025 // We must use ST1 to store vectors in big-endian.
2026 def : Pat<(store (v4f32 FPR128:$Rt),
2027 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2028 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2029 def : Pat<(store (v2f64 FPR128:$Rt),
2030 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2031 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2032 def : Pat<(store (v16i8 FPR128:$Rt),
2033 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2034 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2035 def : Pat<(store (v8i16 FPR128:$Rt),
2036 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2037 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2038 def : Pat<(store (v4i32 FPR128:$Rt),
2039 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2040 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2041 def : Pat<(store (v2i64 FPR128:$Rt),
2042 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2043 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2044 def : Pat<(store (v2f64 FPR128:$Rt),
2045 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2046 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2047 def : Pat<(store (v8f16 FPR128:$Rt),
2048 (am_unscaled128 GPR64sp:$Rn, simm9:$offset)),
2049 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9:$offset)>;
2052 // unscaled i64 truncating stores
2053 def : Pat<(truncstorei32 GPR64:$Rt, (am_unscaled32 GPR64sp:$Rn, simm9:$offset)),
2054 (STURWi (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, simm9:$offset)>;
2055 def : Pat<(truncstorei16 GPR64:$Rt, (am_unscaled16 GPR64sp:$Rn, simm9:$offset)),
2056 (STURHHi (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, simm9:$offset)>;
2057 def : Pat<(truncstorei8 GPR64:$Rt, (am_unscaled8 GPR64sp:$Rn, simm9:$offset)),
2058 (STURBBi (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$Rn, simm9:$offset)>;
2061 // STR mnemonics fall back to STUR for negative or unaligned offsets.
2062 def : InstAlias<"str $Rt, [$Rn, $offset]",
2063 (STURXi GPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb64:$offset), 0>;
2064 def : InstAlias<"str $Rt, [$Rn, $offset]",
2065 (STURWi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
2066 def : InstAlias<"str $Rt, [$Rn, $offset]",
2067 (STURBi FPR8:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2068 def : InstAlias<"str $Rt, [$Rn, $offset]",
2069 (STURHi FPR16:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2070 def : InstAlias<"str $Rt, [$Rn, $offset]",
2071 (STURSi FPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb32:$offset), 0>;
2072 def : InstAlias<"str $Rt, [$Rn, $offset]",
2073 (STURDi FPR64:$Rt, GPR64sp:$Rn, simm9_offset_fb64:$offset), 0>;
2074 def : InstAlias<"str $Rt, [$Rn, $offset]",
2075 (STURQi FPR128:$Rt, GPR64sp:$Rn, simm9_offset_fb128:$offset), 0>;
2077 def : InstAlias<"strb $Rt, [$Rn, $offset]",
2078 (STURBBi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb8:$offset), 0>;
2079 def : InstAlias<"strh $Rt, [$Rn, $offset]",
2080 (STURHHi GPR32:$Rt, GPR64sp:$Rn, simm9_offset_fb16:$offset), 0>;
2083 // (unscaled immediate, unprivileged)
2084 defm STTRW : StoreUnprivileged<0b10, 0, 0b00, GPR32, "sttr">;
2085 defm STTRX : StoreUnprivileged<0b11, 0, 0b00, GPR64, "sttr">;
2087 defm STTRH : StoreUnprivileged<0b01, 0, 0b00, GPR32, "sttrh">;
2088 defm STTRB : StoreUnprivileged<0b00, 0, 0b00, GPR32, "sttrb">;
2091 // (immediate pre-indexed)
2092 def STRWpre : StorePreIdx<0b10, 0, 0b00, GPR32, "str", pre_store, i32>;
2093 def STRXpre : StorePreIdx<0b11, 0, 0b00, GPR64, "str", pre_store, i64>;
2094 def STRBpre : StorePreIdx<0b00, 1, 0b00, FPR8, "str", pre_store, untyped>;
2095 def STRHpre : StorePreIdx<0b01, 1, 0b00, FPR16, "str", pre_store, f16>;
2096 def STRSpre : StorePreIdx<0b10, 1, 0b00, FPR32, "str", pre_store, f32>;
2097 def STRDpre : StorePreIdx<0b11, 1, 0b00, FPR64, "str", pre_store, f64>;
2098 def STRQpre : StorePreIdx<0b00, 1, 0b10, FPR128, "str", pre_store, f128>;
2100 def STRBBpre : StorePreIdx<0b00, 0, 0b00, GPR32, "strb", pre_truncsti8, i32>;
2101 def STRHHpre : StorePreIdx<0b01, 0, 0b00, GPR32, "strh", pre_truncsti16, i32>;
2104 def : Pat<(pre_truncsti32 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
2105 (STRWpre (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
2107 def : Pat<(pre_truncsti16 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
2108 (STRHHpre (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
2110 def : Pat<(pre_truncsti8 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
2111 (STRBBpre (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
2114 def : Pat<(pre_store (v8i8 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2115 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2116 def : Pat<(pre_store (v4i16 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2117 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2118 def : Pat<(pre_store (v2i32 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2119 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2120 def : Pat<(pre_store (v2f32 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2121 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2122 def : Pat<(pre_store (v1i64 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2123 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2124 def : Pat<(pre_store (v1f64 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2125 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2126 def : Pat<(pre_store (v4f16 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2127 (STRDpre FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2129 def : Pat<(pre_store (v16i8 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2130 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2131 def : Pat<(pre_store (v8i16 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2132 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2133 def : Pat<(pre_store (v4i32 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2134 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2135 def : Pat<(pre_store (v4f32 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2136 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2137 def : Pat<(pre_store (v2i64 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2138 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2139 def : Pat<(pre_store (v2f64 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2140 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2141 def : Pat<(pre_store (v8f16 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2142 (STRQpre FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2145 // (immediate post-indexed)
2146 def STRWpost : StorePostIdx<0b10, 0, 0b00, GPR32, "str", post_store, i32>;
2147 def STRXpost : StorePostIdx<0b11, 0, 0b00, GPR64, "str", post_store, i64>;
2148 def STRBpost : StorePostIdx<0b00, 1, 0b00, FPR8, "str", post_store, untyped>;
2149 def STRHpost : StorePostIdx<0b01, 1, 0b00, FPR16, "str", post_store, f16>;
2150 def STRSpost : StorePostIdx<0b10, 1, 0b00, FPR32, "str", post_store, f32>;
2151 def STRDpost : StorePostIdx<0b11, 1, 0b00, FPR64, "str", post_store, f64>;
2152 def STRQpost : StorePostIdx<0b00, 1, 0b10, FPR128, "str", post_store, f128>;
2154 def STRBBpost : StorePostIdx<0b00, 0, 0b00, GPR32, "strb", post_truncsti8, i32>;
2155 def STRHHpost : StorePostIdx<0b01, 0, 0b00, GPR32, "strh", post_truncsti16, i32>;
2158 def : Pat<(post_truncsti32 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
2159 (STRWpost (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
2161 def : Pat<(post_truncsti16 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
2162 (STRHHpost (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
2164 def : Pat<(post_truncsti8 GPR64:$Rt, GPR64sp:$addr, simm9:$off),
2165 (STRBBpost (EXTRACT_SUBREG GPR64:$Rt, sub_32), GPR64sp:$addr,
2168 def : Pat<(post_store (v8i8 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2169 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2170 def : Pat<(post_store (v4i16 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2171 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2172 def : Pat<(post_store (v2i32 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2173 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2174 def : Pat<(post_store (v2f32 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2175 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2176 def : Pat<(post_store (v1i64 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2177 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2178 def : Pat<(post_store (v1f64 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2179 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2180 def : Pat<(post_store (v4f16 FPR64:$Rt), GPR64sp:$addr, simm9:$off),
2181 (STRDpost FPR64:$Rt, GPR64sp:$addr, simm9:$off)>;
2183 def : Pat<(post_store (v16i8 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2184 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2185 def : Pat<(post_store (v8i16 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2186 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2187 def : Pat<(post_store (v4i32 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2188 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2189 def : Pat<(post_store (v4f32 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2190 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2191 def : Pat<(post_store (v2i64 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2192 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2193 def : Pat<(post_store (v2f64 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2194 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2195 def : Pat<(post_store (v8f16 FPR128:$Rt), GPR64sp:$addr, simm9:$off),
2196 (STRQpost FPR128:$Rt, GPR64sp:$addr, simm9:$off)>;
2198 //===----------------------------------------------------------------------===//
2199 // Load/store exclusive instructions.
2200 //===----------------------------------------------------------------------===//
2202 def LDARW : LoadAcquire <0b10, 1, 1, 0, 1, GPR32, "ldar">;
2203 def LDARX : LoadAcquire <0b11, 1, 1, 0, 1, GPR64, "ldar">;
2204 def LDARB : LoadAcquire <0b00, 1, 1, 0, 1, GPR32, "ldarb">;
2205 def LDARH : LoadAcquire <0b01, 1, 1, 0, 1, GPR32, "ldarh">;
2207 def LDAXRW : LoadExclusive <0b10, 0, 1, 0, 1, GPR32, "ldaxr">;
2208 def LDAXRX : LoadExclusive <0b11, 0, 1, 0, 1, GPR64, "ldaxr">;
2209 def LDAXRB : LoadExclusive <0b00, 0, 1, 0, 1, GPR32, "ldaxrb">;
2210 def LDAXRH : LoadExclusive <0b01, 0, 1, 0, 1, GPR32, "ldaxrh">;
2212 def LDXRW : LoadExclusive <0b10, 0, 1, 0, 0, GPR32, "ldxr">;
2213 def LDXRX : LoadExclusive <0b11, 0, 1, 0, 0, GPR64, "ldxr">;
2214 def LDXRB : LoadExclusive <0b00, 0, 1, 0, 0, GPR32, "ldxrb">;
2215 def LDXRH : LoadExclusive <0b01, 0, 1, 0, 0, GPR32, "ldxrh">;
2217 def STLRW : StoreRelease <0b10, 1, 0, 0, 1, GPR32, "stlr">;
2218 def STLRX : StoreRelease <0b11, 1, 0, 0, 1, GPR64, "stlr">;
2219 def STLRB : StoreRelease <0b00, 1, 0, 0, 1, GPR32, "stlrb">;
2220 def STLRH : StoreRelease <0b01, 1, 0, 0, 1, GPR32, "stlrh">;
2222 def STLXRW : StoreExclusive<0b10, 0, 0, 0, 1, GPR32, "stlxr">;
2223 def STLXRX : StoreExclusive<0b11, 0, 0, 0, 1, GPR64, "stlxr">;
2224 def STLXRB : StoreExclusive<0b00, 0, 0, 0, 1, GPR32, "stlxrb">;
2225 def STLXRH : StoreExclusive<0b01, 0, 0, 0, 1, GPR32, "stlxrh">;
2227 def STXRW : StoreExclusive<0b10, 0, 0, 0, 0, GPR32, "stxr">;
2228 def STXRX : StoreExclusive<0b11, 0, 0, 0, 0, GPR64, "stxr">;
2229 def STXRB : StoreExclusive<0b00, 0, 0, 0, 0, GPR32, "stxrb">;
2230 def STXRH : StoreExclusive<0b01, 0, 0, 0, 0, GPR32, "stxrh">;
2232 def LDAXPW : LoadExclusivePair<0b10, 0, 1, 1, 1, GPR32, "ldaxp">;
2233 def LDAXPX : LoadExclusivePair<0b11, 0, 1, 1, 1, GPR64, "ldaxp">;
2235 def LDXPW : LoadExclusivePair<0b10, 0, 1, 1, 0, GPR32, "ldxp">;
2236 def LDXPX : LoadExclusivePair<0b11, 0, 1, 1, 0, GPR64, "ldxp">;
2238 def STLXPW : StoreExclusivePair<0b10, 0, 0, 1, 1, GPR32, "stlxp">;
2239 def STLXPX : StoreExclusivePair<0b11, 0, 0, 1, 1, GPR64, "stlxp">;
2241 def STXPW : StoreExclusivePair<0b10, 0, 0, 1, 0, GPR32, "stxp">;
2242 def STXPX : StoreExclusivePair<0b11, 0, 0, 1, 0, GPR64, "stxp">;
2244 //===----------------------------------------------------------------------===//
2245 // Scaled floating point to integer conversion instructions.
2246 //===----------------------------------------------------------------------===//
2248 defm FCVTAS : FPToIntegerUnscaled<0b00, 0b100, "fcvtas", int_aarch64_neon_fcvtas>;
2249 defm FCVTAU : FPToIntegerUnscaled<0b00, 0b101, "fcvtau", int_aarch64_neon_fcvtau>;
2250 defm FCVTMS : FPToIntegerUnscaled<0b10, 0b000, "fcvtms", int_aarch64_neon_fcvtms>;
2251 defm FCVTMU : FPToIntegerUnscaled<0b10, 0b001, "fcvtmu", int_aarch64_neon_fcvtmu>;
2252 defm FCVTNS : FPToIntegerUnscaled<0b00, 0b000, "fcvtns", int_aarch64_neon_fcvtns>;
2253 defm FCVTNU : FPToIntegerUnscaled<0b00, 0b001, "fcvtnu", int_aarch64_neon_fcvtnu>;
2254 defm FCVTPS : FPToIntegerUnscaled<0b01, 0b000, "fcvtps", int_aarch64_neon_fcvtps>;
2255 defm FCVTPU : FPToIntegerUnscaled<0b01, 0b001, "fcvtpu", int_aarch64_neon_fcvtpu>;
2256 defm FCVTZS : FPToIntegerUnscaled<0b11, 0b000, "fcvtzs", fp_to_sint>;
2257 defm FCVTZU : FPToIntegerUnscaled<0b11, 0b001, "fcvtzu", fp_to_uint>;
2258 defm FCVTZS : FPToIntegerScaled<0b11, 0b000, "fcvtzs", fp_to_sint>;
2259 defm FCVTZU : FPToIntegerScaled<0b11, 0b001, "fcvtzu", fp_to_uint>;
2260 let isCodeGenOnly = 1 in {
2261 defm FCVTZS_Int : FPToIntegerUnscaled<0b11, 0b000, "fcvtzs", int_aarch64_neon_fcvtzs>;
2262 defm FCVTZU_Int : FPToIntegerUnscaled<0b11, 0b001, "fcvtzu", int_aarch64_neon_fcvtzu>;
2263 defm FCVTZS_Int : FPToIntegerScaled<0b11, 0b000, "fcvtzs", int_aarch64_neon_fcvtzs>;
2264 defm FCVTZU_Int : FPToIntegerScaled<0b11, 0b001, "fcvtzu", int_aarch64_neon_fcvtzu>;
2267 //===----------------------------------------------------------------------===//
2268 // Scaled integer to floating point conversion instructions.
2269 //===----------------------------------------------------------------------===//
2271 defm SCVTF : IntegerToFP<0, "scvtf", sint_to_fp>;
2272 defm UCVTF : IntegerToFP<1, "ucvtf", uint_to_fp>;
2274 //===----------------------------------------------------------------------===//
2275 // Unscaled integer to floating point conversion instruction.
2276 //===----------------------------------------------------------------------===//
2278 defm FMOV : UnscaledConversion<"fmov">;
2280 def : Pat<(f32 (fpimm0)), (FMOVWSr WZR)>, Requires<[NoZCZ]>;
2281 def : Pat<(f64 (fpimm0)), (FMOVXDr XZR)>, Requires<[NoZCZ]>;
2283 //===----------------------------------------------------------------------===//
2284 // Floating point conversion instruction.
2285 //===----------------------------------------------------------------------===//
2287 defm FCVT : FPConversion<"fcvt">;
2289 //===----------------------------------------------------------------------===//
2290 // Floating point single operand instructions.
2291 //===----------------------------------------------------------------------===//
2293 defm FABS : SingleOperandFPData<0b0001, "fabs", fabs>;
2294 defm FMOV : SingleOperandFPData<0b0000, "fmov">;
2295 defm FNEG : SingleOperandFPData<0b0010, "fneg", fneg>;
2296 defm FRINTA : SingleOperandFPData<0b1100, "frinta", frnd>;
2297 defm FRINTI : SingleOperandFPData<0b1111, "frinti", fnearbyint>;
2298 defm FRINTM : SingleOperandFPData<0b1010, "frintm", ffloor>;
2299 defm FRINTN : SingleOperandFPData<0b1000, "frintn", int_aarch64_neon_frintn>;
2300 defm FRINTP : SingleOperandFPData<0b1001, "frintp", fceil>;
2302 def : Pat<(v1f64 (int_aarch64_neon_frintn (v1f64 FPR64:$Rn))),
2303 (FRINTNDr FPR64:$Rn)>;
2305 // FRINTX is inserted to set the flags as required by FENV_ACCESS ON behavior
2306 // in the C spec. Setting hasSideEffects ensures it is not DCE'd.
2307 // <rdar://problem/13715968>
2308 // TODO: We should really model the FPSR flags correctly. This is really ugly.
2309 let hasSideEffects = 1 in {
2310 defm FRINTX : SingleOperandFPData<0b1110, "frintx", frint>;
2313 defm FRINTZ : SingleOperandFPData<0b1011, "frintz", ftrunc>;
2315 let SchedRW = [WriteFDiv] in {
2316 defm FSQRT : SingleOperandFPData<0b0011, "fsqrt", fsqrt>;
2319 //===----------------------------------------------------------------------===//
2320 // Floating point two operand instructions.
2321 //===----------------------------------------------------------------------===//
2323 defm FADD : TwoOperandFPData<0b0010, "fadd", fadd>;
2324 let SchedRW = [WriteFDiv] in {
2325 defm FDIV : TwoOperandFPData<0b0001, "fdiv", fdiv>;
2327 defm FMAXNM : TwoOperandFPData<0b0110, "fmaxnm", int_aarch64_neon_fmaxnm>;
2328 defm FMAX : TwoOperandFPData<0b0100, "fmax", AArch64fmax>;
2329 defm FMINNM : TwoOperandFPData<0b0111, "fminnm", int_aarch64_neon_fminnm>;
2330 defm FMIN : TwoOperandFPData<0b0101, "fmin", AArch64fmin>;
2331 let SchedRW = [WriteFMul] in {
2332 defm FMUL : TwoOperandFPData<0b0000, "fmul", fmul>;
2333 defm FNMUL : TwoOperandFPDataNeg<0b1000, "fnmul", fmul>;
2335 defm FSUB : TwoOperandFPData<0b0011, "fsub", fsub>;
2337 def : Pat<(v1f64 (AArch64fmax (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
2338 (FMAXDrr FPR64:$Rn, FPR64:$Rm)>;
2339 def : Pat<(v1f64 (AArch64fmin (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
2340 (FMINDrr FPR64:$Rn, FPR64:$Rm)>;
2341 def : Pat<(v1f64 (int_aarch64_neon_fmaxnm (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
2342 (FMAXNMDrr FPR64:$Rn, FPR64:$Rm)>;
2343 def : Pat<(v1f64 (int_aarch64_neon_fminnm (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
2344 (FMINNMDrr FPR64:$Rn, FPR64:$Rm)>;
2346 //===----------------------------------------------------------------------===//
2347 // Floating point three operand instructions.
2348 //===----------------------------------------------------------------------===//
2350 defm FMADD : ThreeOperandFPData<0, 0, "fmadd", fma>;
2351 defm FMSUB : ThreeOperandFPData<0, 1, "fmsub",
2352 TriOpFrag<(fma node:$LHS, (fneg node:$MHS), node:$RHS)> >;
2353 defm FNMADD : ThreeOperandFPData<1, 0, "fnmadd",
2354 TriOpFrag<(fneg (fma node:$LHS, node:$MHS, node:$RHS))> >;
2355 defm FNMSUB : ThreeOperandFPData<1, 1, "fnmsub",
2356 TriOpFrag<(fma node:$LHS, node:$MHS, (fneg node:$RHS))> >;
2358 // The following def pats catch the case where the LHS of an FMA is negated.
2359 // The TriOpFrag above catches the case where the middle operand is negated.
2361 // N.b. FMSUB etc have the accumulator at the *end* of (outs), unlike
2362 // the NEON variant.
2363 def : Pat<(f32 (fma (fneg FPR32:$Rn), FPR32:$Rm, FPR32:$Ra)),
2364 (FMSUBSrrr FPR32:$Rn, FPR32:$Rm, FPR32:$Ra)>;
2366 def : Pat<(f64 (fma (fneg FPR64:$Rn), FPR64:$Rm, FPR64:$Ra)),
2367 (FMSUBDrrr FPR64:$Rn, FPR64:$Rm, FPR64:$Ra)>;
2369 // We handled -(a + b*c) for FNMADD above, now it's time for "(-a) + (-b)*c" and
2371 def : Pat<(f32 (fma (fneg FPR32:$Rn), FPR32:$Rm, (fneg FPR32:$Ra))),
2372 (FNMADDSrrr FPR32:$Rn, FPR32:$Rm, FPR32:$Ra)>;
2374 def : Pat<(f64 (fma (fneg FPR64:$Rn), FPR64:$Rm, (fneg FPR64:$Ra))),
2375 (FNMADDDrrr FPR64:$Rn, FPR64:$Rm, FPR64:$Ra)>;
2377 def : Pat<(f32 (fma FPR32:$Rn, (fneg FPR32:$Rm), (fneg FPR32:$Ra))),
2378 (FNMADDSrrr FPR32:$Rn, FPR32:$Rm, FPR32:$Ra)>;
2380 def : Pat<(f64 (fma FPR64:$Rn, (fneg FPR64:$Rm), (fneg FPR64:$Ra))),
2381 (FNMADDDrrr FPR64:$Rn, FPR64:$Rm, FPR64:$Ra)>;
2383 //===----------------------------------------------------------------------===//
2384 // Floating point comparison instructions.
2385 //===----------------------------------------------------------------------===//
2387 defm FCMPE : FPComparison<1, "fcmpe">;
2388 defm FCMP : FPComparison<0, "fcmp", AArch64fcmp>;
2390 //===----------------------------------------------------------------------===//
2391 // Floating point conditional comparison instructions.
2392 //===----------------------------------------------------------------------===//
2394 defm FCCMPE : FPCondComparison<1, "fccmpe">;
2395 defm FCCMP : FPCondComparison<0, "fccmp">;
2397 //===----------------------------------------------------------------------===//
2398 // Floating point conditional select instruction.
2399 //===----------------------------------------------------------------------===//
2401 defm FCSEL : FPCondSelect<"fcsel">;
2403 // CSEL instructions providing f128 types need to be handled by a
2404 // pseudo-instruction since the eventual code will need to introduce basic
2405 // blocks and control flow.
2406 def F128CSEL : Pseudo<(outs FPR128:$Rd),
2407 (ins FPR128:$Rn, FPR128:$Rm, ccode:$cond),
2408 [(set (f128 FPR128:$Rd),
2409 (AArch64csel FPR128:$Rn, FPR128:$Rm,
2410 (i32 imm:$cond), NZCV))]> {
2412 let usesCustomInserter = 1;
2416 //===----------------------------------------------------------------------===//
2417 // Floating point immediate move.
2418 //===----------------------------------------------------------------------===//
2420 let isReMaterializable = 1 in {
2421 defm FMOV : FPMoveImmediate<"fmov">;
2424 //===----------------------------------------------------------------------===//
2425 // Advanced SIMD two vector instructions.
2426 //===----------------------------------------------------------------------===//
2428 defm ABS : SIMDTwoVectorBHSD<0, 0b01011, "abs", int_aarch64_neon_abs>;
2429 def : Pat<(xor (v8i8 (AArch64vashr V64:$src, (i32 7))),
2430 (v8i8 (add V64:$src, (AArch64vashr V64:$src, (i32 7))))),
2431 (ABSv8i8 V64:$src)>;
2432 def : Pat<(xor (v4i16 (AArch64vashr V64:$src, (i32 15))),
2433 (v4i16 (add V64:$src, (AArch64vashr V64:$src, (i32 15))))),
2434 (ABSv4i16 V64:$src)>;
2435 def : Pat<(xor (v2i32 (AArch64vashr V64:$src, (i32 31))),
2436 (v2i32 (add V64:$src, (AArch64vashr V64:$src, (i32 31))))),
2437 (ABSv2i32 V64:$src)>;
2438 def : Pat<(xor (v16i8 (AArch64vashr V128:$src, (i32 7))),
2439 (v16i8 (add V128:$src, (AArch64vashr V128:$src, (i32 7))))),
2440 (ABSv16i8 V128:$src)>;
2441 def : Pat<(xor (v8i16 (AArch64vashr V128:$src, (i32 15))),
2442 (v8i16 (add V128:$src, (AArch64vashr V128:$src, (i32 15))))),
2443 (ABSv8i16 V128:$src)>;
2444 def : Pat<(xor (v4i32 (AArch64vashr V128:$src, (i32 31))),
2445 (v4i32 (add V128:$src, (AArch64vashr V128:$src, (i32 31))))),
2446 (ABSv4i32 V128:$src)>;
2447 def : Pat<(xor (v2i64 (AArch64vashr V128:$src, (i32 63))),
2448 (v2i64 (add V128:$src, (AArch64vashr V128:$src, (i32 63))))),
2449 (ABSv2i64 V128:$src)>;
2451 defm CLS : SIMDTwoVectorBHS<0, 0b00100, "cls", int_aarch64_neon_cls>;
2452 defm CLZ : SIMDTwoVectorBHS<1, 0b00100, "clz", ctlz>;
2453 defm CMEQ : SIMDCmpTwoVector<0, 0b01001, "cmeq", AArch64cmeqz>;
2454 defm CMGE : SIMDCmpTwoVector<1, 0b01000, "cmge", AArch64cmgez>;
2455 defm CMGT : SIMDCmpTwoVector<0, 0b01000, "cmgt", AArch64cmgtz>;
2456 defm CMLE : SIMDCmpTwoVector<1, 0b01001, "cmle", AArch64cmlez>;
2457 defm CMLT : SIMDCmpTwoVector<0, 0b01010, "cmlt", AArch64cmltz>;
2458 defm CNT : SIMDTwoVectorB<0, 0b00, 0b00101, "cnt", ctpop>;
2459 defm FABS : SIMDTwoVectorFP<0, 1, 0b01111, "fabs", fabs>;
2461 defm FCMEQ : SIMDFPCmpTwoVector<0, 1, 0b01101, "fcmeq", AArch64fcmeqz>;
2462 defm FCMGE : SIMDFPCmpTwoVector<1, 1, 0b01100, "fcmge", AArch64fcmgez>;
2463 defm FCMGT : SIMDFPCmpTwoVector<0, 1, 0b01100, "fcmgt", AArch64fcmgtz>;
2464 defm FCMLE : SIMDFPCmpTwoVector<1, 1, 0b01101, "fcmle", AArch64fcmlez>;
2465 defm FCMLT : SIMDFPCmpTwoVector<0, 1, 0b01110, "fcmlt", AArch64fcmltz>;
2466 defm FCVTAS : SIMDTwoVectorFPToInt<0,0,0b11100, "fcvtas",int_aarch64_neon_fcvtas>;
2467 defm FCVTAU : SIMDTwoVectorFPToInt<1,0,0b11100, "fcvtau",int_aarch64_neon_fcvtau>;
2468 defm FCVTL : SIMDFPWidenTwoVector<0, 0, 0b10111, "fcvtl">;
2469 def : Pat<(v4f32 (int_aarch64_neon_vcvthf2fp (v4i16 V64:$Rn))),
2470 (FCVTLv4i16 V64:$Rn)>;
2471 def : Pat<(v4f32 (int_aarch64_neon_vcvthf2fp (extract_subvector (v8i16 V128:$Rn),
2473 (FCVTLv8i16 V128:$Rn)>;
2474 def : Pat<(v2f64 (fextend (v2f32 V64:$Rn))), (FCVTLv2i32 V64:$Rn)>;
2475 def : Pat<(v2f64 (fextend (v2f32 (extract_subvector (v4f32 V128:$Rn),
2477 (FCVTLv4i32 V128:$Rn)>;
2479 def : Pat<(v4f32 (fextend (v4f16 V64:$Rn))), (FCVTLv4i16 V64:$Rn)>;
2480 def : Pat<(v4f32 (fextend (v4f16 (extract_subvector (v8f16 V128:$Rn),
2482 (FCVTLv8i16 V128:$Rn)>;
2484 defm FCVTMS : SIMDTwoVectorFPToInt<0,0,0b11011, "fcvtms",int_aarch64_neon_fcvtms>;
2485 defm FCVTMU : SIMDTwoVectorFPToInt<1,0,0b11011, "fcvtmu",int_aarch64_neon_fcvtmu>;
2486 defm FCVTNS : SIMDTwoVectorFPToInt<0,0,0b11010, "fcvtns",int_aarch64_neon_fcvtns>;
2487 defm FCVTNU : SIMDTwoVectorFPToInt<1,0,0b11010, "fcvtnu",int_aarch64_neon_fcvtnu>;
2488 defm FCVTN : SIMDFPNarrowTwoVector<0, 0, 0b10110, "fcvtn">;
2489 def : Pat<(v4i16 (int_aarch64_neon_vcvtfp2hf (v4f32 V128:$Rn))),
2490 (FCVTNv4i16 V128:$Rn)>;
2491 def : Pat<(concat_vectors V64:$Rd,
2492 (v4i16 (int_aarch64_neon_vcvtfp2hf (v4f32 V128:$Rn)))),
2493 (FCVTNv8i16 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
2494 def : Pat<(v2f32 (fround (v2f64 V128:$Rn))), (FCVTNv2i32 V128:$Rn)>;
2495 def : Pat<(v4f16 (fround (v4f32 V128:$Rn))), (FCVTNv4i16 V128:$Rn)>;
2496 def : Pat<(concat_vectors V64:$Rd, (v2f32 (fround (v2f64 V128:$Rn)))),
2497 (FCVTNv4i32 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), V128:$Rn)>;
2498 defm FCVTPS : SIMDTwoVectorFPToInt<0,1,0b11010, "fcvtps",int_aarch64_neon_fcvtps>;
2499 defm FCVTPU : SIMDTwoVectorFPToInt<1,1,0b11010, "fcvtpu",int_aarch64_neon_fcvtpu>;
2500 defm FCVTXN : SIMDFPInexactCvtTwoVector<1, 0, 0b10110, "fcvtxn",
2501 int_aarch64_neon_fcvtxn>;
2502 defm FCVTZS : SIMDTwoVectorFPToInt<0, 1, 0b11011, "fcvtzs", fp_to_sint>;
2503 defm FCVTZU : SIMDTwoVectorFPToInt<1, 1, 0b11011, "fcvtzu", fp_to_uint>;
2504 let isCodeGenOnly = 1 in {
2505 defm FCVTZS_Int : SIMDTwoVectorFPToInt<0, 1, 0b11011, "fcvtzs",
2506 int_aarch64_neon_fcvtzs>;
2507 defm FCVTZU_Int : SIMDTwoVectorFPToInt<1, 1, 0b11011, "fcvtzu",
2508 int_aarch64_neon_fcvtzu>;
2510 defm FNEG : SIMDTwoVectorFP<1, 1, 0b01111, "fneg", fneg>;
2511 defm FRECPE : SIMDTwoVectorFP<0, 1, 0b11101, "frecpe", int_aarch64_neon_frecpe>;
2512 defm FRINTA : SIMDTwoVectorFP<1, 0, 0b11000, "frinta", frnd>;
2513 defm FRINTI : SIMDTwoVectorFP<1, 1, 0b11001, "frinti", fnearbyint>;
2514 defm FRINTM : SIMDTwoVectorFP<0, 0, 0b11001, "frintm", ffloor>;
2515 defm FRINTN : SIMDTwoVectorFP<0, 0, 0b11000, "frintn", int_aarch64_neon_frintn>;
2516 defm FRINTP : SIMDTwoVectorFP<0, 1, 0b11000, "frintp", fceil>;
2517 defm FRINTX : SIMDTwoVectorFP<1, 0, 0b11001, "frintx", frint>;
2518 defm FRINTZ : SIMDTwoVectorFP<0, 1, 0b11001, "frintz", ftrunc>;
2519 defm FRSQRTE: SIMDTwoVectorFP<1, 1, 0b11101, "frsqrte", int_aarch64_neon_frsqrte>;
2520 defm FSQRT : SIMDTwoVectorFP<1, 1, 0b11111, "fsqrt", fsqrt>;
2521 defm NEG : SIMDTwoVectorBHSD<1, 0b01011, "neg",
2522 UnOpFrag<(sub immAllZerosV, node:$LHS)> >;
2523 defm NOT : SIMDTwoVectorB<1, 0b00, 0b00101, "not", vnot>;
2524 // Aliases for MVN -> NOT.
2525 def : InstAlias<"mvn{ $Vd.8b, $Vn.8b|.8b $Vd, $Vn}",
2526 (NOTv8i8 V64:$Vd, V64:$Vn)>;
2527 def : InstAlias<"mvn{ $Vd.16b, $Vn.16b|.16b $Vd, $Vn}",
2528 (NOTv16i8 V128:$Vd, V128:$Vn)>;
2530 def : Pat<(AArch64neg (v8i8 V64:$Rn)), (NEGv8i8 V64:$Rn)>;
2531 def : Pat<(AArch64neg (v16i8 V128:$Rn)), (NEGv16i8 V128:$Rn)>;
2532 def : Pat<(AArch64neg (v4i16 V64:$Rn)), (NEGv4i16 V64:$Rn)>;
2533 def : Pat<(AArch64neg (v8i16 V128:$Rn)), (NEGv8i16 V128:$Rn)>;
2534 def : Pat<(AArch64neg (v2i32 V64:$Rn)), (NEGv2i32 V64:$Rn)>;
2535 def : Pat<(AArch64neg (v4i32 V128:$Rn)), (NEGv4i32 V128:$Rn)>;
2536 def : Pat<(AArch64neg (v2i64 V128:$Rn)), (NEGv2i64 V128:$Rn)>;
2538 def : Pat<(AArch64not (v8i8 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
2539 def : Pat<(AArch64not (v16i8 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
2540 def : Pat<(AArch64not (v4i16 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
2541 def : Pat<(AArch64not (v8i16 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
2542 def : Pat<(AArch64not (v2i32 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
2543 def : Pat<(AArch64not (v1i64 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
2544 def : Pat<(AArch64not (v4i32 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
2545 def : Pat<(AArch64not (v2i64 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
2547 def : Pat<(vnot (v4i16 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
2548 def : Pat<(vnot (v8i16 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
2549 def : Pat<(vnot (v2i32 V64:$Rn)), (NOTv8i8 V64:$Rn)>;
2550 def : Pat<(vnot (v4i32 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
2551 def : Pat<(vnot (v2i64 V128:$Rn)), (NOTv16i8 V128:$Rn)>;
2553 defm RBIT : SIMDTwoVectorB<1, 0b01, 0b00101, "rbit", int_aarch64_neon_rbit>;
2554 defm REV16 : SIMDTwoVectorB<0, 0b00, 0b00001, "rev16", AArch64rev16>;
2555 defm REV32 : SIMDTwoVectorBH<1, 0b00000, "rev32", AArch64rev32>;
2556 defm REV64 : SIMDTwoVectorBHS<0, 0b00000, "rev64", AArch64rev64>;
2557 defm SADALP : SIMDLongTwoVectorTied<0, 0b00110, "sadalp",
2558 BinOpFrag<(add node:$LHS, (int_aarch64_neon_saddlp node:$RHS))> >;
2559 defm SADDLP : SIMDLongTwoVector<0, 0b00010, "saddlp", int_aarch64_neon_saddlp>;
2560 defm SCVTF : SIMDTwoVectorIntToFP<0, 0, 0b11101, "scvtf", sint_to_fp>;
2561 defm SHLL : SIMDVectorLShiftLongBySizeBHS;
2562 defm SQABS : SIMDTwoVectorBHSD<0, 0b00111, "sqabs", int_aarch64_neon_sqabs>;
2563 defm SQNEG : SIMDTwoVectorBHSD<1, 0b00111, "sqneg", int_aarch64_neon_sqneg>;
2564 defm SQXTN : SIMDMixedTwoVector<0, 0b10100, "sqxtn", int_aarch64_neon_sqxtn>;
2565 defm SQXTUN : SIMDMixedTwoVector<1, 0b10010, "sqxtun", int_aarch64_neon_sqxtun>;
2566 defm SUQADD : SIMDTwoVectorBHSDTied<0, 0b00011, "suqadd",int_aarch64_neon_suqadd>;
2567 defm UADALP : SIMDLongTwoVectorTied<1, 0b00110, "uadalp",
2568 BinOpFrag<(add node:$LHS, (int_aarch64_neon_uaddlp node:$RHS))> >;
2569 defm UADDLP : SIMDLongTwoVector<1, 0b00010, "uaddlp",
2570 int_aarch64_neon_uaddlp>;
2571 defm UCVTF : SIMDTwoVectorIntToFP<1, 0, 0b11101, "ucvtf", uint_to_fp>;
2572 defm UQXTN : SIMDMixedTwoVector<1, 0b10100, "uqxtn", int_aarch64_neon_uqxtn>;
2573 defm URECPE : SIMDTwoVectorS<0, 1, 0b11100, "urecpe", int_aarch64_neon_urecpe>;
2574 defm URSQRTE: SIMDTwoVectorS<1, 1, 0b11100, "ursqrte", int_aarch64_neon_ursqrte>;
2575 defm USQADD : SIMDTwoVectorBHSDTied<1, 0b00011, "usqadd",int_aarch64_neon_usqadd>;
2576 defm XTN : SIMDMixedTwoVector<0, 0b10010, "xtn", trunc>;
2578 def : Pat<(v4f16 (AArch64rev32 V64:$Rn)), (REV32v4i16 V64:$Rn)>;
2579 def : Pat<(v4f16 (AArch64rev64 V64:$Rn)), (REV64v4i16 V64:$Rn)>;
2580 def : Pat<(v8f16 (AArch64rev32 V128:$Rn)), (REV32v8i16 V128:$Rn)>;
2581 def : Pat<(v8f16 (AArch64rev64 V128:$Rn)), (REV64v8i16 V128:$Rn)>;
2582 def : Pat<(v2f32 (AArch64rev64 V64:$Rn)), (REV64v2i32 V64:$Rn)>;
2583 def : Pat<(v4f32 (AArch64rev64 V128:$Rn)), (REV64v4i32 V128:$Rn)>;
2585 // Patterns for vector long shift (by element width). These need to match all
2586 // three of zext, sext and anyext so it's easier to pull the patterns out of the
2588 multiclass SIMDVectorLShiftLongBySizeBHSPats<SDPatternOperator ext> {
2589 def : Pat<(AArch64vshl (v8i16 (ext (v8i8 V64:$Rn))), (i32 8)),
2590 (SHLLv8i8 V64:$Rn)>;
2591 def : Pat<(AArch64vshl (v8i16 (ext (extract_high_v16i8 V128:$Rn))), (i32 8)),
2592 (SHLLv16i8 V128:$Rn)>;
2593 def : Pat<(AArch64vshl (v4i32 (ext (v4i16 V64:$Rn))), (i32 16)),
2594 (SHLLv4i16 V64:$Rn)>;
2595 def : Pat<(AArch64vshl (v4i32 (ext (extract_high_v8i16 V128:$Rn))), (i32 16)),
2596 (SHLLv8i16 V128:$Rn)>;
2597 def : Pat<(AArch64vshl (v2i64 (ext (v2i32 V64:$Rn))), (i32 32)),
2598 (SHLLv2i32 V64:$Rn)>;
2599 def : Pat<(AArch64vshl (v2i64 (ext (extract_high_v4i32 V128:$Rn))), (i32 32)),
2600 (SHLLv4i32 V128:$Rn)>;
2603 defm : SIMDVectorLShiftLongBySizeBHSPats<anyext>;
2604 defm : SIMDVectorLShiftLongBySizeBHSPats<zext>;
2605 defm : SIMDVectorLShiftLongBySizeBHSPats<sext>;
2607 //===----------------------------------------------------------------------===//
2608 // Advanced SIMD three vector instructions.
2609 //===----------------------------------------------------------------------===//
2611 defm ADD : SIMDThreeSameVector<0, 0b10000, "add", add>;
2612 defm ADDP : SIMDThreeSameVector<0, 0b10111, "addp", int_aarch64_neon_addp>;
2613 defm CMEQ : SIMDThreeSameVector<1, 0b10001, "cmeq", AArch64cmeq>;
2614 defm CMGE : SIMDThreeSameVector<0, 0b00111, "cmge", AArch64cmge>;
2615 defm CMGT : SIMDThreeSameVector<0, 0b00110, "cmgt", AArch64cmgt>;
2616 defm CMHI : SIMDThreeSameVector<1, 0b00110, "cmhi", AArch64cmhi>;
2617 defm CMHS : SIMDThreeSameVector<1, 0b00111, "cmhs", AArch64cmhs>;
2618 defm CMTST : SIMDThreeSameVector<0, 0b10001, "cmtst", AArch64cmtst>;
2619 defm FABD : SIMDThreeSameVectorFP<1,1,0b11010,"fabd", int_aarch64_neon_fabd>;
2620 defm FACGE : SIMDThreeSameVectorFPCmp<1,0,0b11101,"facge",int_aarch64_neon_facge>;
2621 defm FACGT : SIMDThreeSameVectorFPCmp<1,1,0b11101,"facgt",int_aarch64_neon_facgt>;
2622 defm FADDP : SIMDThreeSameVectorFP<1,0,0b11010,"faddp",int_aarch64_neon_addp>;
2623 defm FADD : SIMDThreeSameVectorFP<0,0,0b11010,"fadd", fadd>;
2624 defm FCMEQ : SIMDThreeSameVectorFPCmp<0, 0, 0b11100, "fcmeq", AArch64fcmeq>;
2625 defm FCMGE : SIMDThreeSameVectorFPCmp<1, 0, 0b11100, "fcmge", AArch64fcmge>;
2626 defm FCMGT : SIMDThreeSameVectorFPCmp<1, 1, 0b11100, "fcmgt", AArch64fcmgt>;
2627 defm FDIV : SIMDThreeSameVectorFP<1,0,0b11111,"fdiv", fdiv>;
2628 defm FMAXNMP : SIMDThreeSameVectorFP<1,0,0b11000,"fmaxnmp", int_aarch64_neon_fmaxnmp>;
2629 defm FMAXNM : SIMDThreeSameVectorFP<0,0,0b11000,"fmaxnm", int_aarch64_neon_fmaxnm>;
2630 defm FMAXP : SIMDThreeSameVectorFP<1,0,0b11110,"fmaxp", int_aarch64_neon_fmaxp>;
2631 defm FMAX : SIMDThreeSameVectorFP<0,0,0b11110,"fmax", AArch64fmax>;
2632 defm FMINNMP : SIMDThreeSameVectorFP<1,1,0b11000,"fminnmp", int_aarch64_neon_fminnmp>;
2633 defm FMINNM : SIMDThreeSameVectorFP<0,1,0b11000,"fminnm", int_aarch64_neon_fminnm>;
2634 defm FMINP : SIMDThreeSameVectorFP<1,1,0b11110,"fminp", int_aarch64_neon_fminp>;
2635 defm FMIN : SIMDThreeSameVectorFP<0,1,0b11110,"fmin", AArch64fmin>;
2637 // NOTE: The operands of the PatFrag are reordered on FMLA/FMLS because the
2638 // instruction expects the addend first, while the fma intrinsic puts it last.
2639 defm FMLA : SIMDThreeSameVectorFPTied<0, 0, 0b11001, "fmla",
2640 TriOpFrag<(fma node:$RHS, node:$MHS, node:$LHS)> >;
2641 defm FMLS : SIMDThreeSameVectorFPTied<0, 1, 0b11001, "fmls",
2642 TriOpFrag<(fma node:$MHS, (fneg node:$RHS), node:$LHS)> >;
2644 // The following def pats catch the case where the LHS of an FMA is negated.
2645 // The TriOpFrag above catches the case where the middle operand is negated.
2646 def : Pat<(v2f32 (fma (fneg V64:$Rn), V64:$Rm, V64:$Rd)),
2647 (FMLSv2f32 V64:$Rd, V64:$Rn, V64:$Rm)>;
2649 def : Pat<(v4f32 (fma (fneg V128:$Rn), V128:$Rm, V128:$Rd)),
2650 (FMLSv4f32 V128:$Rd, V128:$Rn, V128:$Rm)>;
2652 def : Pat<(v2f64 (fma (fneg V128:$Rn), V128:$Rm, V128:$Rd)),
2653 (FMLSv2f64 V128:$Rd, V128:$Rn, V128:$Rm)>;
2655 defm FMULX : SIMDThreeSameVectorFP<0,0,0b11011,"fmulx", int_aarch64_neon_fmulx>;
2656 defm FMUL : SIMDThreeSameVectorFP<1,0,0b11011,"fmul", fmul>;
2657 defm FRECPS : SIMDThreeSameVectorFP<0,0,0b11111,"frecps", int_aarch64_neon_frecps>;
2658 defm FRSQRTS : SIMDThreeSameVectorFP<0,1,0b11111,"frsqrts", int_aarch64_neon_frsqrts>;
2659 defm FSUB : SIMDThreeSameVectorFP<0,1,0b11010,"fsub", fsub>;
2660 defm MLA : SIMDThreeSameVectorBHSTied<0, 0b10010, "mla",
2661 TriOpFrag<(add node:$LHS, (mul node:$MHS, node:$RHS))> >;
2662 defm MLS : SIMDThreeSameVectorBHSTied<1, 0b10010, "mls",
2663 TriOpFrag<(sub node:$LHS, (mul node:$MHS, node:$RHS))> >;
2664 defm MUL : SIMDThreeSameVectorBHS<0, 0b10011, "mul", mul>;
2665 defm PMUL : SIMDThreeSameVectorB<1, 0b10011, "pmul", int_aarch64_neon_pmul>;
2666 defm SABA : SIMDThreeSameVectorBHSTied<0, 0b01111, "saba",
2667 TriOpFrag<(add node:$LHS, (int_aarch64_neon_sabd node:$MHS, node:$RHS))> >;
2668 defm SABD : SIMDThreeSameVectorBHS<0,0b01110,"sabd", int_aarch64_neon_sabd>;
2669 defm SHADD : SIMDThreeSameVectorBHS<0,0b00000,"shadd", int_aarch64_neon_shadd>;
2670 defm SHSUB : SIMDThreeSameVectorBHS<0,0b00100,"shsub", int_aarch64_neon_shsub>;
2671 defm SMAXP : SIMDThreeSameVectorBHS<0,0b10100,"smaxp", int_aarch64_neon_smaxp>;
2672 defm SMAX : SIMDThreeSameVectorBHS<0,0b01100,"smax", int_aarch64_neon_smax>;
2673 defm SMINP : SIMDThreeSameVectorBHS<0,0b10101,"sminp", int_aarch64_neon_sminp>;
2674 defm SMIN : SIMDThreeSameVectorBHS<0,0b01101,"smin", int_aarch64_neon_smin>;
2675 defm SQADD : SIMDThreeSameVector<0,0b00001,"sqadd", int_aarch64_neon_sqadd>;
2676 defm SQDMULH : SIMDThreeSameVectorHS<0,0b10110,"sqdmulh",int_aarch64_neon_sqdmulh>;
2677 defm SQRDMULH : SIMDThreeSameVectorHS<1,0b10110,"sqrdmulh",int_aarch64_neon_sqrdmulh>;
2678 defm SQRSHL : SIMDThreeSameVector<0,0b01011,"sqrshl", int_aarch64_neon_sqrshl>;
2679 defm SQSHL : SIMDThreeSameVector<0,0b01001,"sqshl", int_aarch64_neon_sqshl>;
2680 defm SQSUB : SIMDThreeSameVector<0,0b00101,"sqsub", int_aarch64_neon_sqsub>;
2681 defm SRHADD : SIMDThreeSameVectorBHS<0,0b00010,"srhadd",int_aarch64_neon_srhadd>;
2682 defm SRSHL : SIMDThreeSameVector<0,0b01010,"srshl", int_aarch64_neon_srshl>;
2683 defm SSHL : SIMDThreeSameVector<0,0b01000,"sshl", int_aarch64_neon_sshl>;
2684 defm SUB : SIMDThreeSameVector<1,0b10000,"sub", sub>;
2685 defm UABA : SIMDThreeSameVectorBHSTied<1, 0b01111, "uaba",
2686 TriOpFrag<(add node:$LHS, (int_aarch64_neon_uabd node:$MHS, node:$RHS))> >;
2687 defm UABD : SIMDThreeSameVectorBHS<1,0b01110,"uabd", int_aarch64_neon_uabd>;
2688 defm UHADD : SIMDThreeSameVectorBHS<1,0b00000,"uhadd", int_aarch64_neon_uhadd>;
2689 defm UHSUB : SIMDThreeSameVectorBHS<1,0b00100,"uhsub", int_aarch64_neon_uhsub>;
2690 defm UMAXP : SIMDThreeSameVectorBHS<1,0b10100,"umaxp", int_aarch64_neon_umaxp>;
2691 defm UMAX : SIMDThreeSameVectorBHS<1,0b01100,"umax", int_aarch64_neon_umax>;
2692 defm UMINP : SIMDThreeSameVectorBHS<1,0b10101,"uminp", int_aarch64_neon_uminp>;
2693 defm UMIN : SIMDThreeSameVectorBHS<1,0b01101,"umin", int_aarch64_neon_umin>;
2694 defm UQADD : SIMDThreeSameVector<1,0b00001,"uqadd", int_aarch64_neon_uqadd>;
2695 defm UQRSHL : SIMDThreeSameVector<1,0b01011,"uqrshl", int_aarch64_neon_uqrshl>;
2696 defm UQSHL : SIMDThreeSameVector<1,0b01001,"uqshl", int_aarch64_neon_uqshl>;
2697 defm UQSUB : SIMDThreeSameVector<1,0b00101,"uqsub", int_aarch64_neon_uqsub>;
2698 defm URHADD : SIMDThreeSameVectorBHS<1,0b00010,"urhadd", int_aarch64_neon_urhadd>;
2699 defm URSHL : SIMDThreeSameVector<1,0b01010,"urshl", int_aarch64_neon_urshl>;
2700 defm USHL : SIMDThreeSameVector<1,0b01000,"ushl", int_aarch64_neon_ushl>;
2702 defm AND : SIMDLogicalThreeVector<0, 0b00, "and", and>;
2703 defm BIC : SIMDLogicalThreeVector<0, 0b01, "bic",
2704 BinOpFrag<(and node:$LHS, (vnot node:$RHS))> >;
2705 defm BIF : SIMDLogicalThreeVector<1, 0b11, "bif">;
2706 defm BIT : SIMDLogicalThreeVectorTied<1, 0b10, "bit", AArch64bit>;
2707 defm BSL : SIMDLogicalThreeVectorTied<1, 0b01, "bsl",
2708 TriOpFrag<(or (and node:$LHS, node:$MHS), (and (vnot node:$LHS), node:$RHS))>>;
2709 defm EOR : SIMDLogicalThreeVector<1, 0b00, "eor", xor>;
2710 defm ORN : SIMDLogicalThreeVector<0, 0b11, "orn",
2711 BinOpFrag<(or node:$LHS, (vnot node:$RHS))> >;
2712 defm ORR : SIMDLogicalThreeVector<0, 0b10, "orr", or>;
2714 def : Pat<(AArch64bsl (v8i8 V64:$Rd), V64:$Rn, V64:$Rm),
2715 (BSLv8i8 V64:$Rd, V64:$Rn, V64:$Rm)>;
2716 def : Pat<(AArch64bsl (v4i16 V64:$Rd), V64:$Rn, V64:$Rm),
2717 (BSLv8i8 V64:$Rd, V64:$Rn, V64:$Rm)>;
2718 def : Pat<(AArch64bsl (v2i32 V64:$Rd), V64:$Rn, V64:$Rm),
2719 (BSLv8i8 V64:$Rd, V64:$Rn, V64:$Rm)>;
2720 def : Pat<(AArch64bsl (v1i64 V64:$Rd), V64:$Rn, V64:$Rm),
2721 (BSLv8i8 V64:$Rd, V64:$Rn, V64:$Rm)>;
2723 def : Pat<(AArch64bsl (v16i8 V128:$Rd), V128:$Rn, V128:$Rm),
2724 (BSLv16i8 V128:$Rd, V128:$Rn, V128:$Rm)>;
2725 def : Pat<(AArch64bsl (v8i16 V128:$Rd), V128:$Rn, V128:$Rm),
2726 (BSLv16i8 V128:$Rd, V128:$Rn, V128:$Rm)>;
2727 def : Pat<(AArch64bsl (v4i32 V128:$Rd), V128:$Rn, V128:$Rm),
2728 (BSLv16i8 V128:$Rd, V128:$Rn, V128:$Rm)>;
2729 def : Pat<(AArch64bsl (v2i64 V128:$Rd), V128:$Rn, V128:$Rm),
2730 (BSLv16i8 V128:$Rd, V128:$Rn, V128:$Rm)>;
2732 def : InstAlias<"mov{\t$dst.16b, $src.16b|.16b\t$dst, $src}",
2733 (ORRv16i8 V128:$dst, V128:$src, V128:$src), 1>;
2734 def : InstAlias<"mov{\t$dst.8h, $src.8h|.8h\t$dst, $src}",
2735 (ORRv16i8 V128:$dst, V128:$src, V128:$src), 0>;
2736 def : InstAlias<"mov{\t$dst.4s, $src.4s|.4s\t$dst, $src}",
2737 (ORRv16i8 V128:$dst, V128:$src, V128:$src), 0>;
2738 def : InstAlias<"mov{\t$dst.2d, $src.2d|.2d\t$dst, $src}",
2739 (ORRv16i8 V128:$dst, V128:$src, V128:$src), 0>;
2741 def : InstAlias<"mov{\t$dst.8b, $src.8b|.8b\t$dst, $src}",
2742 (ORRv8i8 V64:$dst, V64:$src, V64:$src), 1>;
2743 def : InstAlias<"mov{\t$dst.4h, $src.4h|.4h\t$dst, $src}",
2744 (ORRv8i8 V64:$dst, V64:$src, V64:$src), 0>;
2745 def : InstAlias<"mov{\t$dst.2s, $src.2s|.2s\t$dst, $src}",
2746 (ORRv8i8 V64:$dst, V64:$src, V64:$src), 0>;
2747 def : InstAlias<"mov{\t$dst.1d, $src.1d|.1d\t$dst, $src}",
2748 (ORRv8i8 V64:$dst, V64:$src, V64:$src), 0>;
2750 def : InstAlias<"{cmls\t$dst.8b, $src1.8b, $src2.8b" #
2751 "|cmls.8b\t$dst, $src1, $src2}",
2752 (CMHSv8i8 V64:$dst, V64:$src2, V64:$src1), 0>;
2753 def : InstAlias<"{cmls\t$dst.16b, $src1.16b, $src2.16b" #
2754 "|cmls.16b\t$dst, $src1, $src2}",
2755 (CMHSv16i8 V128:$dst, V128:$src2, V128:$src1), 0>;
2756 def : InstAlias<"{cmls\t$dst.4h, $src1.4h, $src2.4h" #
2757 "|cmls.4h\t$dst, $src1, $src2}",
2758 (CMHSv4i16 V64:$dst, V64:$src2, V64:$src1), 0>;
2759 def : InstAlias<"{cmls\t$dst.8h, $src1.8h, $src2.8h" #
2760 "|cmls.8h\t$dst, $src1, $src2}",
2761 (CMHSv8i16 V128:$dst, V128:$src2, V128:$src1), 0>;
2762 def : InstAlias<"{cmls\t$dst.2s, $src1.2s, $src2.2s" #
2763 "|cmls.2s\t$dst, $src1, $src2}",
2764 (CMHSv2i32 V64:$dst, V64:$src2, V64:$src1), 0>;
2765 def : InstAlias<"{cmls\t$dst.4s, $src1.4s, $src2.4s" #
2766 "|cmls.4s\t$dst, $src1, $src2}",
2767 (CMHSv4i32 V128:$dst, V128:$src2, V128:$src1), 0>;
2768 def : InstAlias<"{cmls\t$dst.2d, $src1.2d, $src2.2d" #
2769 "|cmls.2d\t$dst, $src1, $src2}",
2770 (CMHSv2i64 V128:$dst, V128:$src2, V128:$src1), 0>;
2772 def : InstAlias<"{cmlo\t$dst.8b, $src1.8b, $src2.8b" #
2773 "|cmlo.8b\t$dst, $src1, $src2}",
2774 (CMHIv8i8 V64:$dst, V64:$src2, V64:$src1), 0>;
2775 def : InstAlias<"{cmlo\t$dst.16b, $src1.16b, $src2.16b" #
2776 "|cmlo.16b\t$dst, $src1, $src2}",
2777 (CMHIv16i8 V128:$dst, V128:$src2, V128:$src1), 0>;
2778 def : InstAlias<"{cmlo\t$dst.4h, $src1.4h, $src2.4h" #
2779 "|cmlo.4h\t$dst, $src1, $src2}",
2780 (CMHIv4i16 V64:$dst, V64:$src2, V64:$src1), 0>;
2781 def : InstAlias<"{cmlo\t$dst.8h, $src1.8h, $src2.8h" #
2782 "|cmlo.8h\t$dst, $src1, $src2}",
2783 (CMHIv8i16 V128:$dst, V128:$src2, V128:$src1), 0>;
2784 def : InstAlias<"{cmlo\t$dst.2s, $src1.2s, $src2.2s" #
2785 "|cmlo.2s\t$dst, $src1, $src2}",
2786 (CMHIv2i32 V64:$dst, V64:$src2, V64:$src1), 0>;
2787 def : InstAlias<"{cmlo\t$dst.4s, $src1.4s, $src2.4s" #
2788 "|cmlo.4s\t$dst, $src1, $src2}",
2789 (CMHIv4i32 V128:$dst, V128:$src2, V128:$src1), 0>;
2790 def : InstAlias<"{cmlo\t$dst.2d, $src1.2d, $src2.2d" #
2791 "|cmlo.2d\t$dst, $src1, $src2}",
2792 (CMHIv2i64 V128:$dst, V128:$src2, V128:$src1), 0>;
2794 def : InstAlias<"{cmle\t$dst.8b, $src1.8b, $src2.8b" #
2795 "|cmle.8b\t$dst, $src1, $src2}",
2796 (CMGEv8i8 V64:$dst, V64:$src2, V64:$src1), 0>;
2797 def : InstAlias<"{cmle\t$dst.16b, $src1.16b, $src2.16b" #
2798 "|cmle.16b\t$dst, $src1, $src2}",
2799 (CMGEv16i8 V128:$dst, V128:$src2, V128:$src1), 0>;
2800 def : InstAlias<"{cmle\t$dst.4h, $src1.4h, $src2.4h" #
2801 "|cmle.4h\t$dst, $src1, $src2}",
2802 (CMGEv4i16 V64:$dst, V64:$src2, V64:$src1), 0>;
2803 def : InstAlias<"{cmle\t$dst.8h, $src1.8h, $src2.8h" #
2804 "|cmle.8h\t$dst, $src1, $src2}",
2805 (CMGEv8i16 V128:$dst, V128:$src2, V128:$src1), 0>;
2806 def : InstAlias<"{cmle\t$dst.2s, $src1.2s, $src2.2s" #
2807 "|cmle.2s\t$dst, $src1, $src2}",
2808 (CMGEv2i32 V64:$dst, V64:$src2, V64:$src1), 0>;
2809 def : InstAlias<"{cmle\t$dst.4s, $src1.4s, $src2.4s" #
2810 "|cmle.4s\t$dst, $src1, $src2}",
2811 (CMGEv4i32 V128:$dst, V128:$src2, V128:$src1), 0>;
2812 def : InstAlias<"{cmle\t$dst.2d, $src1.2d, $src2.2d" #
2813 "|cmle.2d\t$dst, $src1, $src2}",
2814 (CMGEv2i64 V128:$dst, V128:$src2, V128:$src1), 0>;
2816 def : InstAlias<"{cmlt\t$dst.8b, $src1.8b, $src2.8b" #
2817 "|cmlt.8b\t$dst, $src1, $src2}",
2818 (CMGTv8i8 V64:$dst, V64:$src2, V64:$src1), 0>;
2819 def : InstAlias<"{cmlt\t$dst.16b, $src1.16b, $src2.16b" #
2820 "|cmlt.16b\t$dst, $src1, $src2}",
2821 (CMGTv16i8 V128:$dst, V128:$src2, V128:$src1), 0>;
2822 def : InstAlias<"{cmlt\t$dst.4h, $src1.4h, $src2.4h" #
2823 "|cmlt.4h\t$dst, $src1, $src2}",
2824 (CMGTv4i16 V64:$dst, V64:$src2, V64:$src1), 0>;
2825 def : InstAlias<"{cmlt\t$dst.8h, $src1.8h, $src2.8h" #
2826 "|cmlt.8h\t$dst, $src1, $src2}",
2827 (CMGTv8i16 V128:$dst, V128:$src2, V128:$src1), 0>;
2828 def : InstAlias<"{cmlt\t$dst.2s, $src1.2s, $src2.2s" #
2829 "|cmlt.2s\t$dst, $src1, $src2}",
2830 (CMGTv2i32 V64:$dst, V64:$src2, V64:$src1), 0>;
2831 def : InstAlias<"{cmlt\t$dst.4s, $src1.4s, $src2.4s" #
2832 "|cmlt.4s\t$dst, $src1, $src2}",
2833 (CMGTv4i32 V128:$dst, V128:$src2, V128:$src1), 0>;
2834 def : InstAlias<"{cmlt\t$dst.2d, $src1.2d, $src2.2d" #
2835 "|cmlt.2d\t$dst, $src1, $src2}",
2836 (CMGTv2i64 V128:$dst, V128:$src2, V128:$src1), 0>;
2838 def : InstAlias<"{fcmle\t$dst.2s, $src1.2s, $src2.2s" #
2839 "|fcmle.2s\t$dst, $src1, $src2}",
2840 (FCMGEv2f32 V64:$dst, V64:$src2, V64:$src1), 0>;
2841 def : InstAlias<"{fcmle\t$dst.4s, $src1.4s, $src2.4s" #
2842 "|fcmle.4s\t$dst, $src1, $src2}",
2843 (FCMGEv4f32 V128:$dst, V128:$src2, V128:$src1), 0>;
2844 def : InstAlias<"{fcmle\t$dst.2d, $src1.2d, $src2.2d" #
2845 "|fcmle.2d\t$dst, $src1, $src2}",
2846 (FCMGEv2f64 V128:$dst, V128:$src2, V128:$src1), 0>;
2848 def : InstAlias<"{fcmlt\t$dst.2s, $src1.2s, $src2.2s" #
2849 "|fcmlt.2s\t$dst, $src1, $src2}",
2850 (FCMGTv2f32 V64:$dst, V64:$src2, V64:$src1), 0>;
2851 def : InstAlias<"{fcmlt\t$dst.4s, $src1.4s, $src2.4s" #
2852 "|fcmlt.4s\t$dst, $src1, $src2}",
2853 (FCMGTv4f32 V128:$dst, V128:$src2, V128:$src1), 0>;
2854 def : InstAlias<"{fcmlt\t$dst.2d, $src1.2d, $src2.2d" #
2855 "|fcmlt.2d\t$dst, $src1, $src2}",
2856 (FCMGTv2f64 V128:$dst, V128:$src2, V128:$src1), 0>;
2858 def : InstAlias<"{facle\t$dst.2s, $src1.2s, $src2.2s" #
2859 "|facle.2s\t$dst, $src1, $src2}",
2860 (FACGEv2f32 V64:$dst, V64:$src2, V64:$src1), 0>;
2861 def : InstAlias<"{facle\t$dst.4s, $src1.4s, $src2.4s" #
2862 "|facle.4s\t$dst, $src1, $src2}",
2863 (FACGEv4f32 V128:$dst, V128:$src2, V128:$src1), 0>;
2864 def : InstAlias<"{facle\t$dst.2d, $src1.2d, $src2.2d" #
2865 "|facle.2d\t$dst, $src1, $src2}",
2866 (FACGEv2f64 V128:$dst, V128:$src2, V128:$src1), 0>;
2868 def : InstAlias<"{faclt\t$dst.2s, $src1.2s, $src2.2s" #
2869 "|faclt.2s\t$dst, $src1, $src2}",
2870 (FACGTv2f32 V64:$dst, V64:$src2, V64:$src1), 0>;
2871 def : InstAlias<"{faclt\t$dst.4s, $src1.4s, $src2.4s" #
2872 "|faclt.4s\t$dst, $src1, $src2}",
2873 (FACGTv4f32 V128:$dst, V128:$src2, V128:$src1), 0>;
2874 def : InstAlias<"{faclt\t$dst.2d, $src1.2d, $src2.2d" #
2875 "|faclt.2d\t$dst, $src1, $src2}",
2876 (FACGTv2f64 V128:$dst, V128:$src2, V128:$src1), 0>;
2878 //===----------------------------------------------------------------------===//
2879 // Advanced SIMD three scalar instructions.
2880 //===----------------------------------------------------------------------===//
2882 defm ADD : SIMDThreeScalarD<0, 0b10000, "add", add>;
2883 defm CMEQ : SIMDThreeScalarD<1, 0b10001, "cmeq", AArch64cmeq>;
2884 defm CMGE : SIMDThreeScalarD<0, 0b00111, "cmge", AArch64cmge>;
2885 defm CMGT : SIMDThreeScalarD<0, 0b00110, "cmgt", AArch64cmgt>;
2886 defm CMHI : SIMDThreeScalarD<1, 0b00110, "cmhi", AArch64cmhi>;
2887 defm CMHS : SIMDThreeScalarD<1, 0b00111, "cmhs", AArch64cmhs>;
2888 defm CMTST : SIMDThreeScalarD<0, 0b10001, "cmtst", AArch64cmtst>;
2889 defm FABD : SIMDThreeScalarSD<1, 1, 0b11010, "fabd", int_aarch64_sisd_fabd>;
2890 def : Pat<(v1f64 (int_aarch64_neon_fabd (v1f64 FPR64:$Rn), (v1f64 FPR64:$Rm))),
2891 (FABD64 FPR64:$Rn, FPR64:$Rm)>;
2892 defm FACGE : SIMDThreeScalarFPCmp<1, 0, 0b11101, "facge",
2893 int_aarch64_neon_facge>;
2894 defm FACGT : SIMDThreeScalarFPCmp<1, 1, 0b11101, "facgt",
2895 int_aarch64_neon_facgt>;
2896 defm FCMEQ : SIMDThreeScalarFPCmp<0, 0, 0b11100, "fcmeq", AArch64fcmeq>;
2897 defm FCMGE : SIMDThreeScalarFPCmp<1, 0, 0b11100, "fcmge", AArch64fcmge>;
2898 defm FCMGT : SIMDThreeScalarFPCmp<1, 1, 0b11100, "fcmgt", AArch64fcmgt>;
2899 defm FMULX : SIMDThreeScalarSD<0, 0, 0b11011, "fmulx", int_aarch64_neon_fmulx>;
2900 defm FRECPS : SIMDThreeScalarSD<0, 0, 0b11111, "frecps", int_aarch64_neon_frecps>;
2901 defm FRSQRTS : SIMDThreeScalarSD<0, 1, 0b11111, "frsqrts", int_aarch64_neon_frsqrts>;
2902 defm SQADD : SIMDThreeScalarBHSD<0, 0b00001, "sqadd", int_aarch64_neon_sqadd>;
2903 defm SQDMULH : SIMDThreeScalarHS< 0, 0b10110, "sqdmulh", int_aarch64_neon_sqdmulh>;
2904 defm SQRDMULH : SIMDThreeScalarHS< 1, 0b10110, "sqrdmulh", int_aarch64_neon_sqrdmulh>;
2905 defm SQRSHL : SIMDThreeScalarBHSD<0, 0b01011, "sqrshl",int_aarch64_neon_sqrshl>;
2906 defm SQSHL : SIMDThreeScalarBHSD<0, 0b01001, "sqshl", int_aarch64_neon_sqshl>;
2907 defm SQSUB : SIMDThreeScalarBHSD<0, 0b00101, "sqsub", int_aarch64_neon_sqsub>;
2908 defm SRSHL : SIMDThreeScalarD< 0, 0b01010, "srshl", int_aarch64_neon_srshl>;
2909 defm SSHL : SIMDThreeScalarD< 0, 0b01000, "sshl", int_aarch64_neon_sshl>;
2910 defm SUB : SIMDThreeScalarD< 1, 0b10000, "sub", sub>;
2911 defm UQADD : SIMDThreeScalarBHSD<1, 0b00001, "uqadd", int_aarch64_neon_uqadd>;
2912 defm UQRSHL : SIMDThreeScalarBHSD<1, 0b01011, "uqrshl",int_aarch64_neon_uqrshl>;
2913 defm UQSHL : SIMDThreeScalarBHSD<1, 0b01001, "uqshl", int_aarch64_neon_uqshl>;
2914 defm UQSUB : SIMDThreeScalarBHSD<1, 0b00101, "uqsub", int_aarch64_neon_uqsub>;
2915 defm URSHL : SIMDThreeScalarD< 1, 0b01010, "urshl", int_aarch64_neon_urshl>;
2916 defm USHL : SIMDThreeScalarD< 1, 0b01000, "ushl", int_aarch64_neon_ushl>;
2918 def : InstAlias<"cmls $dst, $src1, $src2",
2919 (CMHSv1i64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
2920 def : InstAlias<"cmle $dst, $src1, $src2",
2921 (CMGEv1i64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
2922 def : InstAlias<"cmlo $dst, $src1, $src2",
2923 (CMHIv1i64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
2924 def : InstAlias<"cmlt $dst, $src1, $src2",
2925 (CMGTv1i64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
2926 def : InstAlias<"fcmle $dst, $src1, $src2",
2927 (FCMGE32 FPR32:$dst, FPR32:$src2, FPR32:$src1), 0>;
2928 def : InstAlias<"fcmle $dst, $src1, $src2",
2929 (FCMGE64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
2930 def : InstAlias<"fcmlt $dst, $src1, $src2",
2931 (FCMGT32 FPR32:$dst, FPR32:$src2, FPR32:$src1), 0>;
2932 def : InstAlias<"fcmlt $dst, $src1, $src2",
2933 (FCMGT64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
2934 def : InstAlias<"facle $dst, $src1, $src2",
2935 (FACGE32 FPR32:$dst, FPR32:$src2, FPR32:$src1), 0>;
2936 def : InstAlias<"facle $dst, $src1, $src2",
2937 (FACGE64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
2938 def : InstAlias<"faclt $dst, $src1, $src2",
2939 (FACGT32 FPR32:$dst, FPR32:$src2, FPR32:$src1), 0>;
2940 def : InstAlias<"faclt $dst, $src1, $src2",
2941 (FACGT64 FPR64:$dst, FPR64:$src2, FPR64:$src1), 0>;
2943 //===----------------------------------------------------------------------===//
2944 // Advanced SIMD three scalar instructions (mixed operands).
2945 //===----------------------------------------------------------------------===//
2946 defm SQDMULL : SIMDThreeScalarMixedHS<0, 0b11010, "sqdmull",
2947 int_aarch64_neon_sqdmulls_scalar>;
2948 defm SQDMLAL : SIMDThreeScalarMixedTiedHS<0, 0b10010, "sqdmlal">;
2949 defm SQDMLSL : SIMDThreeScalarMixedTiedHS<0, 0b10110, "sqdmlsl">;
2951 def : Pat<(i64 (int_aarch64_neon_sqadd (i64 FPR64:$Rd),
2952 (i64 (int_aarch64_neon_sqdmulls_scalar (i32 FPR32:$Rn),
2953 (i32 FPR32:$Rm))))),
2954 (SQDMLALi32 FPR64:$Rd, FPR32:$Rn, FPR32:$Rm)>;
2955 def : Pat<(i64 (int_aarch64_neon_sqsub (i64 FPR64:$Rd),
2956 (i64 (int_aarch64_neon_sqdmulls_scalar (i32 FPR32:$Rn),
2957 (i32 FPR32:$Rm))))),
2958 (SQDMLSLi32 FPR64:$Rd, FPR32:$Rn, FPR32:$Rm)>;
2960 //===----------------------------------------------------------------------===//
2961 // Advanced SIMD two scalar instructions.
2962 //===----------------------------------------------------------------------===//
2964 defm ABS : SIMDTwoScalarD< 0, 0b01011, "abs", int_aarch64_neon_abs>;
2965 defm CMEQ : SIMDCmpTwoScalarD< 0, 0b01001, "cmeq", AArch64cmeqz>;
2966 defm CMGE : SIMDCmpTwoScalarD< 1, 0b01000, "cmge", AArch64cmgez>;
2967 defm CMGT : SIMDCmpTwoScalarD< 0, 0b01000, "cmgt", AArch64cmgtz>;
2968 defm CMLE : SIMDCmpTwoScalarD< 1, 0b01001, "cmle", AArch64cmlez>;
2969 defm CMLT : SIMDCmpTwoScalarD< 0, 0b01010, "cmlt", AArch64cmltz>;
2970 defm FCMEQ : SIMDCmpTwoScalarSD<0, 1, 0b01101, "fcmeq", AArch64fcmeqz>;
2971 defm FCMGE : SIMDCmpTwoScalarSD<1, 1, 0b01100, "fcmge", AArch64fcmgez>;
2972 defm FCMGT : SIMDCmpTwoScalarSD<0, 1, 0b01100, "fcmgt", AArch64fcmgtz>;
2973 defm FCMLE : SIMDCmpTwoScalarSD<1, 1, 0b01101, "fcmle", AArch64fcmlez>;
2974 defm FCMLT : SIMDCmpTwoScalarSD<0, 1, 0b01110, "fcmlt", AArch64fcmltz>;
2975 defm FCVTAS : SIMDTwoScalarSD< 0, 0, 0b11100, "fcvtas">;
2976 defm FCVTAU : SIMDTwoScalarSD< 1, 0, 0b11100, "fcvtau">;
2977 defm FCVTMS : SIMDTwoScalarSD< 0, 0, 0b11011, "fcvtms">;
2978 defm FCVTMU : SIMDTwoScalarSD< 1, 0, 0b11011, "fcvtmu">;
2979 defm FCVTNS : SIMDTwoScalarSD< 0, 0, 0b11010, "fcvtns">;
2980 defm FCVTNU : SIMDTwoScalarSD< 1, 0, 0b11010, "fcvtnu">;
2981 defm FCVTPS : SIMDTwoScalarSD< 0, 1, 0b11010, "fcvtps">;
2982 defm FCVTPU : SIMDTwoScalarSD< 1, 1, 0b11010, "fcvtpu">;
2983 def FCVTXNv1i64 : SIMDInexactCvtTwoScalar<0b10110, "fcvtxn">;
2984 defm FCVTZS : SIMDTwoScalarSD< 0, 1, 0b11011, "fcvtzs">;
2985 defm FCVTZU : SIMDTwoScalarSD< 1, 1, 0b11011, "fcvtzu">;
2986 defm FRECPE : SIMDTwoScalarSD< 0, 1, 0b11101, "frecpe">;
2987 defm FRECPX : SIMDTwoScalarSD< 0, 1, 0b11111, "frecpx">;
2988 defm FRSQRTE : SIMDTwoScalarSD< 1, 1, 0b11101, "frsqrte">;
2989 defm NEG : SIMDTwoScalarD< 1, 0b01011, "neg",
2990 UnOpFrag<(sub immAllZerosV, node:$LHS)> >;
2991 defm SCVTF : SIMDTwoScalarCVTSD< 0, 0, 0b11101, "scvtf", AArch64sitof>;
2992 defm SQABS : SIMDTwoScalarBHSD< 0, 0b00111, "sqabs", int_aarch64_neon_sqabs>;
2993 defm SQNEG : SIMDTwoScalarBHSD< 1, 0b00111, "sqneg", int_aarch64_neon_sqneg>;
2994 defm SQXTN : SIMDTwoScalarMixedBHS< 0, 0b10100, "sqxtn", int_aarch64_neon_scalar_sqxtn>;
2995 defm SQXTUN : SIMDTwoScalarMixedBHS< 1, 0b10010, "sqxtun", int_aarch64_neon_scalar_sqxtun>;
2996 defm SUQADD : SIMDTwoScalarBHSDTied< 0, 0b00011, "suqadd",
2997 int_aarch64_neon_suqadd>;
2998 defm UCVTF : SIMDTwoScalarCVTSD< 1, 0, 0b11101, "ucvtf", AArch64uitof>;
2999 defm UQXTN : SIMDTwoScalarMixedBHS<1, 0b10100, "uqxtn", int_aarch64_neon_scalar_uqxtn>;
3000 defm USQADD : SIMDTwoScalarBHSDTied< 1, 0b00011, "usqadd",
3001 int_aarch64_neon_usqadd>;
3003 def : Pat<(AArch64neg (v1i64 V64:$Rn)), (NEGv1i64 V64:$Rn)>;
3005 def : Pat<(v1i64 (int_aarch64_neon_fcvtas (v1f64 FPR64:$Rn))),
3006 (FCVTASv1i64 FPR64:$Rn)>;
3007 def : Pat<(v1i64 (int_aarch64_neon_fcvtau (v1f64 FPR64:$Rn))),
3008 (FCVTAUv1i64 FPR64:$Rn)>;
3009 def : Pat<(v1i64 (int_aarch64_neon_fcvtms (v1f64 FPR64:$Rn))),
3010 (FCVTMSv1i64 FPR64:$Rn)>;
3011 def : Pat<(v1i64 (int_aarch64_neon_fcvtmu (v1f64 FPR64:$Rn))),
3012 (FCVTMUv1i64 FPR64:$Rn)>;
3013 def : Pat<(v1i64 (int_aarch64_neon_fcvtns (v1f64 FPR64:$Rn))),
3014 (FCVTNSv1i64 FPR64:$Rn)>;
3015 def : Pat<(v1i64 (int_aarch64_neon_fcvtnu (v1f64 FPR64:$Rn))),
3016 (FCVTNUv1i64 FPR64:$Rn)>;
3017 def : Pat<(v1i64 (int_aarch64_neon_fcvtps (v1f64 FPR64:$Rn))),
3018 (FCVTPSv1i64 FPR64:$Rn)>;
3019 def : Pat<(v1i64 (int_aarch64_neon_fcvtpu (v1f64 FPR64:$Rn))),
3020 (FCVTPUv1i64 FPR64:$Rn)>;
3022 def : Pat<(f32 (int_aarch64_neon_frecpe (f32 FPR32:$Rn))),
3023 (FRECPEv1i32 FPR32:$Rn)>;
3024 def : Pat<(f64 (int_aarch64_neon_frecpe (f64 FPR64:$Rn))),
3025 (FRECPEv1i64 FPR64:$Rn)>;
3026 def : Pat<(v1f64 (int_aarch64_neon_frecpe (v1f64 FPR64:$Rn))),
3027 (FRECPEv1i64 FPR64:$Rn)>;
3029 def : Pat<(f32 (int_aarch64_neon_frecpx (f32 FPR32:$Rn))),
3030 (FRECPXv1i32 FPR32:$Rn)>;
3031 def : Pat<(f64 (int_aarch64_neon_frecpx (f64 FPR64:$Rn))),
3032 (FRECPXv1i64 FPR64:$Rn)>;
3034 def : Pat<(f32 (int_aarch64_neon_frsqrte (f32 FPR32:$Rn))),
3035 (FRSQRTEv1i32 FPR32:$Rn)>;
3036 def : Pat<(f64 (int_aarch64_neon_frsqrte (f64 FPR64:$Rn))),
3037 (FRSQRTEv1i64 FPR64:$Rn)>;
3038 def : Pat<(v1f64 (int_aarch64_neon_frsqrte (v1f64 FPR64:$Rn))),
3039 (FRSQRTEv1i64 FPR64:$Rn)>;
3041 // If an integer is about to be converted to a floating point value,
3042 // just load it on the floating point unit.
3043 // Here are the patterns for 8 and 16-bits to float.
3045 multiclass UIntToFPROLoadPat<ValueType DstTy, ValueType SrcTy,
3046 SDPatternOperator loadop, Instruction UCVTF,
3047 ROAddrMode ro, Instruction LDRW, Instruction LDRX,
3049 def : Pat<(DstTy (uint_to_fp (SrcTy
3050 (loadop (ro.Wpat GPR64sp:$Rn, GPR32:$Rm,
3051 ro.Wext:$extend))))),
3052 (UCVTF (INSERT_SUBREG (DstTy (IMPLICIT_DEF)),
3053 (LDRW GPR64sp:$Rn, GPR32:$Rm, ro.Wext:$extend),
3056 def : Pat<(DstTy (uint_to_fp (SrcTy
3057 (loadop (ro.Xpat GPR64sp:$Rn, GPR64:$Rm,
3058 ro.Wext:$extend))))),
3059 (UCVTF (INSERT_SUBREG (DstTy (IMPLICIT_DEF)),
3060 (LDRX GPR64sp:$Rn, GPR64:$Rm, ro.Xext:$extend),
3064 defm : UIntToFPROLoadPat<f32, i32, zextloadi8,
3065 UCVTFv1i32, ro8, LDRBroW, LDRBroX, bsub>;
3066 def : Pat <(f32 (uint_to_fp (i32
3067 (zextloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))))),
3068 (UCVTFv1i32 (INSERT_SUBREG (f32 (IMPLICIT_DEF)),
3069 (LDRBui GPR64sp:$Rn, uimm12s1:$offset), bsub))>;
3070 def : Pat <(f32 (uint_to_fp (i32
3071 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))))),
3072 (UCVTFv1i32 (INSERT_SUBREG (f32 (IMPLICIT_DEF)),
3073 (LDURBi GPR64sp:$Rn, simm9:$offset), bsub))>;
3074 // 16-bits -> float.
3075 defm : UIntToFPROLoadPat<f32, i32, zextloadi16,
3076 UCVTFv1i32, ro16, LDRHroW, LDRHroX, hsub>;
3077 def : Pat <(f32 (uint_to_fp (i32
3078 (zextloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))))),
3079 (UCVTFv1i32 (INSERT_SUBREG (f32 (IMPLICIT_DEF)),
3080 (LDRHui GPR64sp:$Rn, uimm12s2:$offset), hsub))>;
3081 def : Pat <(f32 (uint_to_fp (i32
3082 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))))),
3083 (UCVTFv1i32 (INSERT_SUBREG (f32 (IMPLICIT_DEF)),
3084 (LDURHi GPR64sp:$Rn, simm9:$offset), hsub))>;
3085 // 32-bits are handled in target specific dag combine:
3086 // performIntToFpCombine.
3087 // 64-bits integer to 32-bits floating point, not possible with
3088 // UCVTF on floating point registers (both source and destination
3089 // must have the same size).
3091 // Here are the patterns for 8, 16, 32, and 64-bits to double.
3092 // 8-bits -> double.
3093 defm : UIntToFPROLoadPat<f64, i32, zextloadi8,
3094 UCVTFv1i64, ro8, LDRBroW, LDRBroX, bsub>;
3095 def : Pat <(f64 (uint_to_fp (i32
3096 (zextloadi8 (am_indexed8 GPR64sp:$Rn, uimm12s1:$offset))))),
3097 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
3098 (LDRBui GPR64sp:$Rn, uimm12s1:$offset), bsub))>;
3099 def : Pat <(f64 (uint_to_fp (i32
3100 (zextloadi8 (am_unscaled8 GPR64sp:$Rn, simm9:$offset))))),
3101 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
3102 (LDURBi GPR64sp:$Rn, simm9:$offset), bsub))>;
3103 // 16-bits -> double.
3104 defm : UIntToFPROLoadPat<f64, i32, zextloadi16,
3105 UCVTFv1i64, ro16, LDRHroW, LDRHroX, hsub>;
3106 def : Pat <(f64 (uint_to_fp (i32
3107 (zextloadi16 (am_indexed16 GPR64sp:$Rn, uimm12s2:$offset))))),
3108 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
3109 (LDRHui GPR64sp:$Rn, uimm12s2:$offset), hsub))>;
3110 def : Pat <(f64 (uint_to_fp (i32
3111 (zextloadi16 (am_unscaled16 GPR64sp:$Rn, simm9:$offset))))),
3112 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
3113 (LDURHi GPR64sp:$Rn, simm9:$offset), hsub))>;
3114 // 32-bits -> double.
3115 defm : UIntToFPROLoadPat<f64, i32, load,
3116 UCVTFv1i64, ro32, LDRSroW, LDRSroX, ssub>;
3117 def : Pat <(f64 (uint_to_fp (i32
3118 (load (am_indexed32 GPR64sp:$Rn, uimm12s4:$offset))))),
3119 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
3120 (LDRSui GPR64sp:$Rn, uimm12s4:$offset), ssub))>;
3121 def : Pat <(f64 (uint_to_fp (i32
3122 (load (am_unscaled32 GPR64sp:$Rn, simm9:$offset))))),
3123 (UCVTFv1i64 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
3124 (LDURSi GPR64sp:$Rn, simm9:$offset), ssub))>;
3125 // 64-bits -> double are handled in target specific dag combine:
3126 // performIntToFpCombine.
3128 //===----------------------------------------------------------------------===//
3129 // Advanced SIMD three different-sized vector instructions.
3130 //===----------------------------------------------------------------------===//
3132 defm ADDHN : SIMDNarrowThreeVectorBHS<0,0b0100,"addhn", int_aarch64_neon_addhn>;
3133 defm SUBHN : SIMDNarrowThreeVectorBHS<0,0b0110,"subhn", int_aarch64_neon_subhn>;
3134 defm RADDHN : SIMDNarrowThreeVectorBHS<1,0b0100,"raddhn",int_aarch64_neon_raddhn>;
3135 defm RSUBHN : SIMDNarrowThreeVectorBHS<1,0b0110,"rsubhn",int_aarch64_neon_rsubhn>;
3136 defm PMULL : SIMDDifferentThreeVectorBD<0,0b1110,"pmull",int_aarch64_neon_pmull>;
3137 defm SABAL : SIMDLongThreeVectorTiedBHSabal<0,0b0101,"sabal",
3138 int_aarch64_neon_sabd>;
3139 defm SABDL : SIMDLongThreeVectorBHSabdl<0, 0b0111, "sabdl",
3140 int_aarch64_neon_sabd>;
3141 defm SADDL : SIMDLongThreeVectorBHS< 0, 0b0000, "saddl",
3142 BinOpFrag<(add (sext node:$LHS), (sext node:$RHS))>>;
3143 defm SADDW : SIMDWideThreeVectorBHS< 0, 0b0001, "saddw",
3144 BinOpFrag<(add node:$LHS, (sext node:$RHS))>>;
3145 defm SMLAL : SIMDLongThreeVectorTiedBHS<0, 0b1000, "smlal",
3146 TriOpFrag<(add node:$LHS, (int_aarch64_neon_smull node:$MHS, node:$RHS))>>;
3147 defm SMLSL : SIMDLongThreeVectorTiedBHS<0, 0b1010, "smlsl",
3148 TriOpFrag<(sub node:$LHS, (int_aarch64_neon_smull node:$MHS, node:$RHS))>>;
3149 defm SMULL : SIMDLongThreeVectorBHS<0, 0b1100, "smull", int_aarch64_neon_smull>;
3150 defm SQDMLAL : SIMDLongThreeVectorSQDMLXTiedHS<0, 0b1001, "sqdmlal",
3151 int_aarch64_neon_sqadd>;
3152 defm SQDMLSL : SIMDLongThreeVectorSQDMLXTiedHS<0, 0b1011, "sqdmlsl",
3153 int_aarch64_neon_sqsub>;
3154 defm SQDMULL : SIMDLongThreeVectorHS<0, 0b1101, "sqdmull",
3155 int_aarch64_neon_sqdmull>;
3156 defm SSUBL : SIMDLongThreeVectorBHS<0, 0b0010, "ssubl",
3157 BinOpFrag<(sub (sext node:$LHS), (sext node:$RHS))>>;
3158 defm SSUBW : SIMDWideThreeVectorBHS<0, 0b0011, "ssubw",
3159 BinOpFrag<(sub node:$LHS, (sext node:$RHS))>>;
3160 defm UABAL : SIMDLongThreeVectorTiedBHSabal<1, 0b0101, "uabal",
3161 int_aarch64_neon_uabd>;
3162 defm UABDL : SIMDLongThreeVectorBHSabdl<1, 0b0111, "uabdl",
3163 int_aarch64_neon_uabd>;
3164 defm UADDL : SIMDLongThreeVectorBHS<1, 0b0000, "uaddl",
3165 BinOpFrag<(add (zext node:$LHS), (zext node:$RHS))>>;
3166 defm UADDW : SIMDWideThreeVectorBHS<1, 0b0001, "uaddw",
3167 BinOpFrag<(add node:$LHS, (zext node:$RHS))>>;
3168 defm UMLAL : SIMDLongThreeVectorTiedBHS<1, 0b1000, "umlal",
3169 TriOpFrag<(add node:$LHS, (int_aarch64_neon_umull node:$MHS, node:$RHS))>>;
3170 defm UMLSL : SIMDLongThreeVectorTiedBHS<1, 0b1010, "umlsl",
3171 TriOpFrag<(sub node:$LHS, (int_aarch64_neon_umull node:$MHS, node:$RHS))>>;
3172 defm UMULL : SIMDLongThreeVectorBHS<1, 0b1100, "umull", int_aarch64_neon_umull>;
3173 defm USUBL : SIMDLongThreeVectorBHS<1, 0b0010, "usubl",
3174 BinOpFrag<(sub (zext node:$LHS), (zext node:$RHS))>>;
3175 defm USUBW : SIMDWideThreeVectorBHS< 1, 0b0011, "usubw",
3176 BinOpFrag<(sub node:$LHS, (zext node:$RHS))>>;
3178 // Additional patterns for SMULL and UMULL
3179 multiclass Neon_mul_widen_patterns<SDPatternOperator opnode,
3180 Instruction INST8B, Instruction INST4H, Instruction INST2S> {
3181 def : Pat<(v8i16 (opnode (v8i8 V64:$Rn), (v8i8 V64:$Rm))),
3182 (INST8B V64:$Rn, V64:$Rm)>;
3183 def : Pat<(v4i32 (opnode (v4i16 V64:$Rn), (v4i16 V64:$Rm))),
3184 (INST4H V64:$Rn, V64:$Rm)>;
3185 def : Pat<(v2i64 (opnode (v2i32 V64:$Rn), (v2i32 V64:$Rm))),
3186 (INST2S V64:$Rn, V64:$Rm)>;
3189 defm : Neon_mul_widen_patterns<AArch64smull, SMULLv8i8_v8i16,
3190 SMULLv4i16_v4i32, SMULLv2i32_v2i64>;
3191 defm : Neon_mul_widen_patterns<AArch64umull, UMULLv8i8_v8i16,
3192 UMULLv4i16_v4i32, UMULLv2i32_v2i64>;
3194 // Additional patterns for SMLAL/SMLSL and UMLAL/UMLSL
3195 multiclass Neon_mulacc_widen_patterns<SDPatternOperator opnode,
3196 Instruction INST8B, Instruction INST4H, Instruction INST2S> {
3197 def : Pat<(v8i16 (opnode (v8i16 V128:$Rd), (v8i8 V64:$Rn), (v8i8 V64:$Rm))),
3198 (INST8B V128:$Rd, V64:$Rn, V64:$Rm)>;
3199 def : Pat<(v4i32 (opnode (v4i32 V128:$Rd), (v4i16 V64:$Rn), (v4i16 V64:$Rm))),
3200 (INST4H V128:$Rd, V64:$Rn, V64:$Rm)>;
3201 def : Pat<(v2i64 (opnode (v2i64 V128:$Rd), (v2i32 V64:$Rn), (v2i32 V64:$Rm))),
3202 (INST2S V128:$Rd, V64:$Rn, V64:$Rm)>;
3205 defm : Neon_mulacc_widen_patterns<
3206 TriOpFrag<(add node:$LHS, (AArch64smull node:$MHS, node:$RHS))>,
3207 SMLALv8i8_v8i16, SMLALv4i16_v4i32, SMLALv2i32_v2i64>;
3208 defm : Neon_mulacc_widen_patterns<
3209 TriOpFrag<(add node:$LHS, (AArch64umull node:$MHS, node:$RHS))>,
3210 UMLALv8i8_v8i16, UMLALv4i16_v4i32, UMLALv2i32_v2i64>;
3211 defm : Neon_mulacc_widen_patterns<
3212 TriOpFrag<(sub node:$LHS, (AArch64smull node:$MHS, node:$RHS))>,
3213 SMLSLv8i8_v8i16, SMLSLv4i16_v4i32, SMLSLv2i32_v2i64>;
3214 defm : Neon_mulacc_widen_patterns<
3215 TriOpFrag<(sub node:$LHS, (AArch64umull node:$MHS, node:$RHS))>,
3216 UMLSLv8i8_v8i16, UMLSLv4i16_v4i32, UMLSLv2i32_v2i64>;
3218 // Patterns for 64-bit pmull
3219 def : Pat<(int_aarch64_neon_pmull64 V64:$Rn, V64:$Rm),
3220 (PMULLv1i64 V64:$Rn, V64:$Rm)>;
3221 def : Pat<(int_aarch64_neon_pmull64 (vector_extract (v2i64 V128:$Rn), (i64 1)),
3222 (vector_extract (v2i64 V128:$Rm), (i64 1))),
3223 (PMULLv2i64 V128:$Rn, V128:$Rm)>;
3225 // CodeGen patterns for addhn and subhn instructions, which can actually be
3226 // written in LLVM IR without too much difficulty.
3229 def : Pat<(v8i8 (trunc (v8i16 (AArch64vlshr (add V128:$Rn, V128:$Rm), (i32 8))))),
3230 (ADDHNv8i16_v8i8 V128:$Rn, V128:$Rm)>;
3231 def : Pat<(v4i16 (trunc (v4i32 (AArch64vlshr (add V128:$Rn, V128:$Rm),
3233 (ADDHNv4i32_v4i16 V128:$Rn, V128:$Rm)>;
3234 def : Pat<(v2i32 (trunc (v2i64 (AArch64vlshr (add V128:$Rn, V128:$Rm),
3236 (ADDHNv2i64_v2i32 V128:$Rn, V128:$Rm)>;
3237 def : Pat<(concat_vectors (v8i8 V64:$Rd),
3238 (trunc (v8i16 (AArch64vlshr (add V128:$Rn, V128:$Rm),
3240 (ADDHNv8i16_v16i8 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
3241 V128:$Rn, V128:$Rm)>;
3242 def : Pat<(concat_vectors (v4i16 V64:$Rd),
3243 (trunc (v4i32 (AArch64vlshr (add V128:$Rn, V128:$Rm),
3245 (ADDHNv4i32_v8i16 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
3246 V128:$Rn, V128:$Rm)>;
3247 def : Pat<(concat_vectors (v2i32 V64:$Rd),
3248 (trunc (v2i64 (AArch64vlshr (add V128:$Rn, V128:$Rm),
3250 (ADDHNv2i64_v4i32 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
3251 V128:$Rn, V128:$Rm)>;
3254 def : Pat<(v8i8 (trunc (v8i16 (AArch64vlshr (sub V128:$Rn, V128:$Rm), (i32 8))))),
3255 (SUBHNv8i16_v8i8 V128:$Rn, V128:$Rm)>;
3256 def : Pat<(v4i16 (trunc (v4i32 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
3258 (SUBHNv4i32_v4i16 V128:$Rn, V128:$Rm)>;
3259 def : Pat<(v2i32 (trunc (v2i64 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
3261 (SUBHNv2i64_v2i32 V128:$Rn, V128:$Rm)>;
3262 def : Pat<(concat_vectors (v8i8 V64:$Rd),
3263 (trunc (v8i16 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
3265 (SUBHNv8i16_v16i8 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
3266 V128:$Rn, V128:$Rm)>;
3267 def : Pat<(concat_vectors (v4i16 V64:$Rd),
3268 (trunc (v4i32 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
3270 (SUBHNv4i32_v8i16 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
3271 V128:$Rn, V128:$Rm)>;
3272 def : Pat<(concat_vectors (v2i32 V64:$Rd),
3273 (trunc (v2i64 (AArch64vlshr (sub V128:$Rn, V128:$Rm),
3275 (SUBHNv2i64_v4i32 (SUBREG_TO_REG (i32 0), V64:$Rd, dsub),
3276 V128:$Rn, V128:$Rm)>;
3278 //----------------------------------------------------------------------------
3279 // AdvSIMD bitwise extract from vector instruction.
3280 //----------------------------------------------------------------------------
3282 defm EXT : SIMDBitwiseExtract<"ext">;
3284 def : Pat<(v4i16 (AArch64ext V64:$Rn, V64:$Rm, (i32 imm:$imm))),
3285 (EXTv8i8 V64:$Rn, V64:$Rm, imm:$imm)>;
3286 def : Pat<(v8i16 (AArch64ext V128:$Rn, V128:$Rm, (i32 imm:$imm))),
3287 (EXTv16i8 V128:$Rn, V128:$Rm, imm:$imm)>;
3288 def : Pat<(v2i32 (AArch64ext V64:$Rn, V64:$Rm, (i32 imm:$imm))),
3289 (EXTv8i8 V64:$Rn, V64:$Rm, imm:$imm)>;
3290 def : Pat<(v2f32 (AArch64ext V64:$Rn, V64:$Rm, (i32 imm:$imm))),
3291 (EXTv8i8 V64:$Rn, V64:$Rm, imm:$imm)>;
3292 def : Pat<(v4i32 (AArch64ext V128:$Rn, V128:$Rm, (i32 imm:$imm))),
3293 (EXTv16i8 V128:$Rn, V128:$Rm, imm:$imm)>;
3294 def : Pat<(v4f32 (AArch64ext V128:$Rn, V128:$Rm, (i32 imm:$imm))),
3295 (EXTv16i8 V128:$Rn, V128:$Rm, imm:$imm)>;
3296 def : Pat<(v2i64 (AArch64ext V128:$Rn, V128:$Rm, (i32 imm:$imm))),
3297 (EXTv16i8 V128:$Rn, V128:$Rm, imm:$imm)>;
3298 def : Pat<(v2f64 (AArch64ext V128:$Rn, V128:$Rm, (i32 imm:$imm))),
3299 (EXTv16i8 V128:$Rn, V128:$Rm, imm:$imm)>;
3300 def : Pat<(v4f16 (AArch64ext V64:$Rn, V64:$Rm, (i32 imm:$imm))),
3301 (EXTv8i8 V64:$Rn, V64:$Rm, imm:$imm)>;
3302 def : Pat<(v8f16 (AArch64ext V128:$Rn, V128:$Rm, (i32 imm:$imm))),
3303 (EXTv16i8 V128:$Rn, V128:$Rm, imm:$imm)>;
3305 // We use EXT to handle extract_subvector to copy the upper 64-bits of a
3307 def : Pat<(v8i8 (extract_subvector V128:$Rn, (i64 8))),
3308 (EXTRACT_SUBREG (EXTv16i8 V128:$Rn, V128:$Rn, 8), dsub)>;
3309 def : Pat<(v4i16 (extract_subvector V128:$Rn, (i64 4))),
3310 (EXTRACT_SUBREG (EXTv16i8 V128:$Rn, V128:$Rn, 8), dsub)>;
3311 def : Pat<(v2i32 (extract_subvector V128:$Rn, (i64 2))),
3312 (EXTRACT_SUBREG (EXTv16i8 V128:$Rn, V128:$Rn, 8), dsub)>;
3313 def : Pat<(v1i64 (extract_subvector V128:$Rn, (i64 1))),
3314 (EXTRACT_SUBREG (EXTv16i8 V128:$Rn, V128:$Rn, 8), dsub)>;
3315 def : Pat<(v4f16 (extract_subvector V128:$Rn, (i64 4))),
3316 (EXTRACT_SUBREG (EXTv16i8 V128:$Rn, V128:$Rn, 8), dsub)>;
3317 def : Pat<(v2f32 (extract_subvector V128:$Rn, (i64 2))),
3318 (EXTRACT_SUBREG (EXTv16i8 V128:$Rn, V128:$Rn, 8), dsub)>;
3319 def : Pat<(v1f64 (extract_subvector V128:$Rn, (i64 1))),
3320 (EXTRACT_SUBREG (EXTv16i8 V128:$Rn, V128:$Rn, 8), dsub)>;
3323 //----------------------------------------------------------------------------
3324 // AdvSIMD zip vector
3325 //----------------------------------------------------------------------------
3327 defm TRN1 : SIMDZipVector<0b010, "trn1", AArch64trn1>;
3328 defm TRN2 : SIMDZipVector<0b110, "trn2", AArch64trn2>;
3329 defm UZP1 : SIMDZipVector<0b001, "uzp1", AArch64uzp1>;
3330 defm UZP2 : SIMDZipVector<0b101, "uzp2", AArch64uzp2>;
3331 defm ZIP1 : SIMDZipVector<0b011, "zip1", AArch64zip1>;
3332 defm ZIP2 : SIMDZipVector<0b111, "zip2", AArch64zip2>;
3334 //----------------------------------------------------------------------------
3335 // AdvSIMD TBL/TBX instructions
3336 //----------------------------------------------------------------------------
3338 defm TBL : SIMDTableLookup< 0, "tbl">;
3339 defm TBX : SIMDTableLookupTied<1, "tbx">;
3341 def : Pat<(v8i8 (int_aarch64_neon_tbl1 (v16i8 VecListOne128:$Rn), (v8i8 V64:$Ri))),
3342 (TBLv8i8One VecListOne128:$Rn, V64:$Ri)>;
3343 def : Pat<(v16i8 (int_aarch64_neon_tbl1 (v16i8 V128:$Ri), (v16i8 V128:$Rn))),
3344 (TBLv16i8One V128:$Ri, V128:$Rn)>;
3346 def : Pat<(v8i8 (int_aarch64_neon_tbx1 (v8i8 V64:$Rd),
3347 (v16i8 VecListOne128:$Rn), (v8i8 V64:$Ri))),
3348 (TBXv8i8One V64:$Rd, VecListOne128:$Rn, V64:$Ri)>;
3349 def : Pat<(v16i8 (int_aarch64_neon_tbx1 (v16i8 V128:$Rd),
3350 (v16i8 V128:$Ri), (v16i8 V128:$Rn))),
3351 (TBXv16i8One V128:$Rd, V128:$Ri, V128:$Rn)>;
3354 //----------------------------------------------------------------------------
3355 // AdvSIMD scalar CPY instruction
3356 //----------------------------------------------------------------------------
3358 defm CPY : SIMDScalarCPY<"cpy">;
3360 //----------------------------------------------------------------------------
3361 // AdvSIMD scalar pairwise instructions
3362 //----------------------------------------------------------------------------
3364 defm ADDP : SIMDPairwiseScalarD<0, 0b11011, "addp">;
3365 defm FADDP : SIMDPairwiseScalarSD<1, 0, 0b01101, "faddp">;
3366 defm FMAXNMP : SIMDPairwiseScalarSD<1, 0, 0b01100, "fmaxnmp">;
3367 defm FMAXP : SIMDPairwiseScalarSD<1, 0, 0b01111, "fmaxp">;
3368 defm FMINNMP : SIMDPairwiseScalarSD<1, 1, 0b01100, "fminnmp">;
3369 defm FMINP : SIMDPairwiseScalarSD<1, 1, 0b01111, "fminp">;
3370 def : Pat<(i64 (int_aarch64_neon_saddv (v2i64 V128:$Rn))),
3371 (ADDPv2i64p V128:$Rn)>;
3372 def : Pat<(i64 (int_aarch64_neon_uaddv (v2i64 V128:$Rn))),
3373 (ADDPv2i64p V128:$Rn)>;
3374 def : Pat<(f32 (int_aarch64_neon_faddv (v2f32 V64:$Rn))),
3375 (FADDPv2i32p V64:$Rn)>;
3376 def : Pat<(f32 (int_aarch64_neon_faddv (v4f32 V128:$Rn))),
3377 (FADDPv2i32p (EXTRACT_SUBREG (FADDPv4f32 V128:$Rn, V128:$Rn), dsub))>;
3378 def : Pat<(f64 (int_aarch64_neon_faddv (v2f64 V128:$Rn))),
3379 (FADDPv2i64p V128:$Rn)>;
3380 def : Pat<(f32 (int_aarch64_neon_fmaxnmv (v2f32 V64:$Rn))),
3381 (FMAXNMPv2i32p V64:$Rn)>;
3382 def : Pat<(f64 (int_aarch64_neon_fmaxnmv (v2f64 V128:$Rn))),
3383 (FMAXNMPv2i64p V128:$Rn)>;
3384 def : Pat<(f32 (int_aarch64_neon_fmaxv (v2f32 V64:$Rn))),
3385 (FMAXPv2i32p V64:$Rn)>;
3386 def : Pat<(f64 (int_aarch64_neon_fmaxv (v2f64 V128:$Rn))),
3387 (FMAXPv2i64p V128:$Rn)>;
3388 def : Pat<(f32 (int_aarch64_neon_fminnmv (v2f32 V64:$Rn))),
3389 (FMINNMPv2i32p V64:$Rn)>;
3390 def : Pat<(f64 (int_aarch64_neon_fminnmv (v2f64 V128:$Rn))),
3391 (FMINNMPv2i64p V128:$Rn)>;
3392 def : Pat<(f32 (int_aarch64_neon_fminv (v2f32 V64:$Rn))),
3393 (FMINPv2i32p V64:$Rn)>;
3394 def : Pat<(f64 (int_aarch64_neon_fminv (v2f64 V128:$Rn))),
3395 (FMINPv2i64p V128:$Rn)>;
3397 //----------------------------------------------------------------------------
3398 // AdvSIMD INS/DUP instructions
3399 //----------------------------------------------------------------------------
3401 def DUPv8i8gpr : SIMDDupFromMain<0, 0b00001, ".8b", v8i8, V64, GPR32>;
3402 def DUPv16i8gpr : SIMDDupFromMain<1, 0b00001, ".16b", v16i8, V128, GPR32>;
3403 def DUPv4i16gpr : SIMDDupFromMain<0, 0b00010, ".4h", v4i16, V64, GPR32>;
3404 def DUPv8i16gpr : SIMDDupFromMain<1, 0b00010, ".8h", v8i16, V128, GPR32>;
3405 def DUPv2i32gpr : SIMDDupFromMain<0, 0b00100, ".2s", v2i32, V64, GPR32>;
3406 def DUPv4i32gpr : SIMDDupFromMain<1, 0b00100, ".4s", v4i32, V128, GPR32>;
3407 def DUPv2i64gpr : SIMDDupFromMain<1, 0b01000, ".2d", v2i64, V128, GPR64>;
3409 def DUPv2i64lane : SIMDDup64FromElement;
3410 def DUPv2i32lane : SIMDDup32FromElement<0, ".2s", v2i32, V64>;
3411 def DUPv4i32lane : SIMDDup32FromElement<1, ".4s", v4i32, V128>;
3412 def DUPv4i16lane : SIMDDup16FromElement<0, ".4h", v4i16, V64>;
3413 def DUPv8i16lane : SIMDDup16FromElement<1, ".8h", v8i16, V128>;
3414 def DUPv8i8lane : SIMDDup8FromElement <0, ".8b", v8i8, V64>;
3415 def DUPv16i8lane : SIMDDup8FromElement <1, ".16b", v16i8, V128>;
3417 def : Pat<(v2f32 (AArch64dup (f32 FPR32:$Rn))),
3418 (v2f32 (DUPv2i32lane
3419 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR32:$Rn, ssub),
3421 def : Pat<(v4f32 (AArch64dup (f32 FPR32:$Rn))),
3422 (v4f32 (DUPv4i32lane
3423 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR32:$Rn, ssub),
3425 def : Pat<(v2f64 (AArch64dup (f64 FPR64:$Rn))),
3426 (v2f64 (DUPv2i64lane
3427 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR64:$Rn, dsub),
3429 def : Pat<(v4f16 (AArch64dup (f16 FPR16:$Rn))),
3430 (v4f16 (DUPv4i16lane
3431 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)), FPR16:$Rn, hsub),
3433 def : Pat<(v8f16 (AArch64dup (f16 FPR16:$Rn))),
3434 (v8f16 (DUPv8i16lane
3435 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)), FPR16:$Rn, hsub),
3438 def : Pat<(v4f16 (AArch64duplane16 (v8f16 V128:$Rn), VectorIndexH:$imm)),
3439 (DUPv4i16lane V128:$Rn, VectorIndexH:$imm)>;
3440 def : Pat<(v8f16 (AArch64duplane16 (v8f16 V128:$Rn), VectorIndexH:$imm)),
3441 (DUPv8i16lane V128:$Rn, VectorIndexH:$imm)>;
3443 def : Pat<(v2f32 (AArch64duplane32 (v4f32 V128:$Rn), VectorIndexS:$imm)),
3444 (DUPv2i32lane V128:$Rn, VectorIndexS:$imm)>;
3445 def : Pat<(v4f32 (AArch64duplane32 (v4f32 V128:$Rn), VectorIndexS:$imm)),
3446 (DUPv4i32lane V128:$Rn, VectorIndexS:$imm)>;
3447 def : Pat<(v2f64 (AArch64duplane64 (v2f64 V128:$Rn), VectorIndexD:$imm)),
3448 (DUPv2i64lane V128:$Rn, VectorIndexD:$imm)>;
3450 // If there's an (AArch64dup (vector_extract ...) ...), we can use a duplane
3451 // instruction even if the types don't match: we just have to remap the lane
3452 // carefully. N.b. this trick only applies to truncations.
3453 def VecIndex_x2 : SDNodeXForm<imm, [{
3454 return CurDAG->getTargetConstant(2 * N->getZExtValue(), MVT::i64);
3456 def VecIndex_x4 : SDNodeXForm<imm, [{
3457 return CurDAG->getTargetConstant(4 * N->getZExtValue(), MVT::i64);
3459 def VecIndex_x8 : SDNodeXForm<imm, [{
3460 return CurDAG->getTargetConstant(8 * N->getZExtValue(), MVT::i64);
3463 multiclass DUPWithTruncPats<ValueType ResVT, ValueType Src64VT,
3464 ValueType Src128VT, ValueType ScalVT,
3465 Instruction DUP, SDNodeXForm IdxXFORM> {
3466 def : Pat<(ResVT (AArch64dup (ScalVT (vector_extract (Src128VT V128:$Rn),
3468 (DUP V128:$Rn, (IdxXFORM imm:$idx))>;
3470 def : Pat<(ResVT (AArch64dup (ScalVT (vector_extract (Src64VT V64:$Rn),
3472 (DUP (SUBREG_TO_REG (i64 0), V64:$Rn, dsub), (IdxXFORM imm:$idx))>;
3475 defm : DUPWithTruncPats<v8i8, v4i16, v8i16, i32, DUPv8i8lane, VecIndex_x2>;
3476 defm : DUPWithTruncPats<v8i8, v2i32, v4i32, i32, DUPv8i8lane, VecIndex_x4>;
3477 defm : DUPWithTruncPats<v4i16, v2i32, v4i32, i32, DUPv4i16lane, VecIndex_x2>;
3479 defm : DUPWithTruncPats<v16i8, v4i16, v8i16, i32, DUPv16i8lane, VecIndex_x2>;
3480 defm : DUPWithTruncPats<v16i8, v2i32, v4i32, i32, DUPv16i8lane, VecIndex_x4>;
3481 defm : DUPWithTruncPats<v8i16, v2i32, v4i32, i32, DUPv8i16lane, VecIndex_x2>;
3483 multiclass DUPWithTrunci64Pats<ValueType ResVT, Instruction DUP,
3484 SDNodeXForm IdxXFORM> {
3485 def : Pat<(ResVT (AArch64dup (i32 (trunc (vector_extract (v2i64 V128:$Rn),
3487 (DUP V128:$Rn, (IdxXFORM imm:$idx))>;
3489 def : Pat<(ResVT (AArch64dup (i32 (trunc (vector_extract (v1i64 V64:$Rn),
3491 (DUP (SUBREG_TO_REG (i64 0), V64:$Rn, dsub), (IdxXFORM imm:$idx))>;
3494 defm : DUPWithTrunci64Pats<v8i8, DUPv8i8lane, VecIndex_x8>;
3495 defm : DUPWithTrunci64Pats<v4i16, DUPv4i16lane, VecIndex_x4>;
3496 defm : DUPWithTrunci64Pats<v2i32, DUPv2i32lane, VecIndex_x2>;
3498 defm : DUPWithTrunci64Pats<v16i8, DUPv16i8lane, VecIndex_x8>;
3499 defm : DUPWithTrunci64Pats<v8i16, DUPv8i16lane, VecIndex_x4>;
3500 defm : DUPWithTrunci64Pats<v4i32, DUPv4i32lane, VecIndex_x2>;
3502 // SMOV and UMOV definitions, with some extra patterns for convenience
3506 def : Pat<(sext_inreg (vector_extract (v16i8 V128:$Rn), VectorIndexB:$idx), i8),
3507 (i32 (SMOVvi8to32 V128:$Rn, VectorIndexB:$idx))>;
3508 def : Pat<(sext_inreg (vector_extract (v16i8 V128:$Rn), VectorIndexB:$idx), i8),
3509 (i64 (SMOVvi8to64 V128:$Rn, VectorIndexB:$idx))>;
3510 def : Pat<(sext_inreg (vector_extract (v8i16 V128:$Rn), VectorIndexH:$idx),i16),
3511 (i32 (SMOVvi16to32 V128:$Rn, VectorIndexH:$idx))>;
3512 def : Pat<(sext_inreg (vector_extract (v8i16 V128:$Rn), VectorIndexH:$idx),i16),
3513 (i64 (SMOVvi16to64 V128:$Rn, VectorIndexH:$idx))>;
3514 def : Pat<(sext_inreg (vector_extract (v8i16 V128:$Rn), VectorIndexH:$idx),i16),
3515 (i32 (SMOVvi16to32 V128:$Rn, VectorIndexH:$idx))>;
3516 def : Pat<(sext (i32 (vector_extract (v4i32 V128:$Rn), VectorIndexS:$idx))),
3517 (i64 (SMOVvi32to64 V128:$Rn, VectorIndexS:$idx))>;
3519 // Extracting i8 or i16 elements will have the zero-extend transformed to
3520 // an 'and' mask by type legalization since neither i8 nor i16 are legal types
3521 // for AArch64. Match these patterns here since UMOV already zeroes out the high
3522 // bits of the destination register.
3523 def : Pat<(and (vector_extract (v16i8 V128:$Rn), VectorIndexB:$idx),
3525 (i32 (UMOVvi8 V128:$Rn, VectorIndexB:$idx))>;
3526 def : Pat<(and (vector_extract (v8i16 V128:$Rn), VectorIndexH:$idx),
3528 (i32 (UMOVvi16 V128:$Rn, VectorIndexH:$idx))>;
3532 def : Pat<(v16i8 (scalar_to_vector GPR32:$Rn)),
3533 (SUBREG_TO_REG (i32 0),
3534 (f32 (COPY_TO_REGCLASS GPR32:$Rn, FPR32)), ssub)>;
3535 def : Pat<(v8i8 (scalar_to_vector GPR32:$Rn)),
3536 (SUBREG_TO_REG (i32 0),
3537 (f32 (COPY_TO_REGCLASS GPR32:$Rn, FPR32)), ssub)>;
3539 def : Pat<(v8i16 (scalar_to_vector GPR32:$Rn)),
3540 (SUBREG_TO_REG (i32 0),
3541 (f32 (COPY_TO_REGCLASS GPR32:$Rn, FPR32)), ssub)>;
3542 def : Pat<(v4i16 (scalar_to_vector GPR32:$Rn)),
3543 (SUBREG_TO_REG (i32 0),
3544 (f32 (COPY_TO_REGCLASS GPR32:$Rn, FPR32)), ssub)>;
3546 def : Pat<(v2i32 (scalar_to_vector (i32 FPR32:$Rn))),
3547 (v2i32 (INSERT_SUBREG (v2i32 (IMPLICIT_DEF)),
3548 (i32 FPR32:$Rn), ssub))>;
3549 def : Pat<(v4i32 (scalar_to_vector (i32 FPR32:$Rn))),
3550 (v4i32 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)),
3551 (i32 FPR32:$Rn), ssub))>;
3552 def : Pat<(v2i64 (scalar_to_vector (i64 FPR64:$Rn))),
3553 (v2i64 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)),
3554 (i64 FPR64:$Rn), dsub))>;
3556 def : Pat<(v4f32 (scalar_to_vector (f32 FPR32:$Rn))),
3557 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FPR32:$Rn, ssub)>;
3558 def : Pat<(v2f32 (scalar_to_vector (f32 FPR32:$Rn))),
3559 (INSERT_SUBREG (v2f32 (IMPLICIT_DEF)), FPR32:$Rn, ssub)>;
3560 def : Pat<(v2f64 (scalar_to_vector (f64 FPR64:$Rn))),
3561 (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), FPR64:$Rn, dsub)>;
3563 def : Pat<(v4f16 (vector_insert (v4f16 V64:$Rn),
3564 (f16 FPR16:$Rm), (i64 VectorIndexS:$imm))),
3567 (v8f16 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), V64:$Rn, dsub)),
3569 (v8f16 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR16:$Rm, hsub)),
3573 def : Pat<(v8f16 (vector_insert (v8f16 V128:$Rn),
3574 (f16 FPR16:$Rm), (i64 VectorIndexH:$imm))),
3576 V128:$Rn, VectorIndexH:$imm,
3577 (v8f16 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR16:$Rm, hsub)),
3580 def : Pat<(v2f32 (vector_insert (v2f32 V64:$Rn),
3581 (f32 FPR32:$Rm), (i64 VectorIndexS:$imm))),
3584 (v4f32 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), V64:$Rn, dsub)),
3586 (v4f32 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FPR32:$Rm, ssub)),
3589 def : Pat<(v4f32 (vector_insert (v4f32 V128:$Rn),
3590 (f32 FPR32:$Rm), (i64 VectorIndexS:$imm))),
3592 V128:$Rn, VectorIndexS:$imm,
3593 (v4f32 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FPR32:$Rm, ssub)),
3595 def : Pat<(v2f64 (vector_insert (v2f64 V128:$Rn),
3596 (f64 FPR64:$Rm), (i64 VectorIndexD:$imm))),
3598 V128:$Rn, VectorIndexD:$imm,
3599 (v2f64 (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), FPR64:$Rm, dsub)),
3602 // Copy an element at a constant index in one vector into a constant indexed
3603 // element of another.
3604 // FIXME refactor to a shared class/dev parameterized on vector type, vector
3605 // index type and INS extension
3606 def : Pat<(v16i8 (int_aarch64_neon_vcopy_lane
3607 (v16i8 V128:$Vd), VectorIndexB:$idx, (v16i8 V128:$Vs),
3608 VectorIndexB:$idx2)),
3610 V128:$Vd, VectorIndexB:$idx, V128:$Vs, VectorIndexB:$idx2)
3612 def : Pat<(v8i16 (int_aarch64_neon_vcopy_lane
3613 (v8i16 V128:$Vd), VectorIndexH:$idx, (v8i16 V128:$Vs),
3614 VectorIndexH:$idx2)),
3616 V128:$Vd, VectorIndexH:$idx, V128:$Vs, VectorIndexH:$idx2)
3618 def : Pat<(v4i32 (int_aarch64_neon_vcopy_lane
3619 (v4i32 V128:$Vd), VectorIndexS:$idx, (v4i32 V128:$Vs),
3620 VectorIndexS:$idx2)),
3622 V128:$Vd, VectorIndexS:$idx, V128:$Vs, VectorIndexS:$idx2)
3624 def : Pat<(v2i64 (int_aarch64_neon_vcopy_lane
3625 (v2i64 V128:$Vd), VectorIndexD:$idx, (v2i64 V128:$Vs),
3626 VectorIndexD:$idx2)),
3628 V128:$Vd, VectorIndexD:$idx, V128:$Vs, VectorIndexD:$idx2)
3631 multiclass Neon_INS_elt_pattern<ValueType VT128, ValueType VT64,
3632 ValueType VTScal, Instruction INS> {
3633 def : Pat<(VT128 (vector_insert V128:$src,
3634 (VTScal (vector_extract (VT128 V128:$Rn), imm:$Immn)),
3636 (INS V128:$src, imm:$Immd, V128:$Rn, imm:$Immn)>;
3638 def : Pat<(VT128 (vector_insert V128:$src,
3639 (VTScal (vector_extract (VT64 V64:$Rn), imm:$Immn)),
3641 (INS V128:$src, imm:$Immd,
3642 (SUBREG_TO_REG (i64 0), V64:$Rn, dsub), imm:$Immn)>;
3644 def : Pat<(VT64 (vector_insert V64:$src,
3645 (VTScal (vector_extract (VT128 V128:$Rn), imm:$Immn)),
3647 (EXTRACT_SUBREG (INS (SUBREG_TO_REG (i64 0), V64:$src, dsub),
3648 imm:$Immd, V128:$Rn, imm:$Immn),
3651 def : Pat<(VT64 (vector_insert V64:$src,
3652 (VTScal (vector_extract (VT64 V64:$Rn), imm:$Immn)),
3655 (INS (SUBREG_TO_REG (i64 0), V64:$src, dsub), imm:$Immd,
3656 (SUBREG_TO_REG (i64 0), V64:$Rn, dsub), imm:$Immn),
3660 defm : Neon_INS_elt_pattern<v8f16, v4f16, f16, INSvi16lane>;
3661 defm : Neon_INS_elt_pattern<v4f32, v2f32, f32, INSvi32lane>;
3662 defm : Neon_INS_elt_pattern<v2f64, v1f64, f64, INSvi64lane>;
3663 defm : Neon_INS_elt_pattern<v16i8, v8i8, i32, INSvi8lane>;
3664 defm : Neon_INS_elt_pattern<v8i16, v4i16, i32, INSvi16lane>;
3665 defm : Neon_INS_elt_pattern<v4i32, v2i32, i32, INSvi32lane>;
3666 defm : Neon_INS_elt_pattern<v2i64, v1i64, i64, INSvi32lane>;
3669 // Floating point vector extractions are codegen'd as either a sequence of
3670 // subregister extractions, possibly fed by an INS if the lane number is
3671 // anything other than zero.
3672 def : Pat<(vector_extract (v2f64 V128:$Rn), 0),
3673 (f64 (EXTRACT_SUBREG V128:$Rn, dsub))>;
3674 def : Pat<(vector_extract (v4f32 V128:$Rn), 0),
3675 (f32 (EXTRACT_SUBREG V128:$Rn, ssub))>;
3676 def : Pat<(vector_extract (v8f16 V128:$Rn), 0),
3677 (f16 (EXTRACT_SUBREG V128:$Rn, hsub))>;
3678 def : Pat<(vector_extract (v2f64 V128:$Rn), VectorIndexD:$idx),
3679 (f64 (EXTRACT_SUBREG
3680 (INSvi64lane (v2f64 (IMPLICIT_DEF)), 0,
3681 V128:$Rn, VectorIndexD:$idx),
3683 def : Pat<(vector_extract (v4f32 V128:$Rn), VectorIndexS:$idx),
3684 (f32 (EXTRACT_SUBREG
3685 (INSvi32lane (v4f32 (IMPLICIT_DEF)), 0,
3686 V128:$Rn, VectorIndexS:$idx),
3688 def : Pat<(vector_extract (v8f16 V128:$Rn), VectorIndexH:$idx),
3689 (f16 (EXTRACT_SUBREG
3690 (INSvi16lane (v8f16 (IMPLICIT_DEF)), 0,
3691 V128:$Rn, VectorIndexH:$idx),
3694 // All concat_vectors operations are canonicalised to act on i64 vectors for
3695 // AArch64. In the general case we need an instruction, which had just as well be
3697 class ConcatPat<ValueType DstTy, ValueType SrcTy>
3698 : Pat<(DstTy (concat_vectors (SrcTy V64:$Rd), V64:$Rn)),
3699 (INSvi64lane (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub), 1,
3700 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rn, dsub), 0)>;
3702 def : ConcatPat<v2i64, v1i64>;
3703 def : ConcatPat<v2f64, v1f64>;
3704 def : ConcatPat<v4i32, v2i32>;
3705 def : ConcatPat<v4f32, v2f32>;
3706 def : ConcatPat<v8i16, v4i16>;
3707 def : ConcatPat<v8f16, v4f16>;
3708 def : ConcatPat<v16i8, v8i8>;
3710 // If the high lanes are undef, though, we can just ignore them:
3711 class ConcatUndefPat<ValueType DstTy, ValueType SrcTy>
3712 : Pat<(DstTy (concat_vectors (SrcTy V64:$Rn), undef)),
3713 (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rn, dsub)>;
3715 def : ConcatUndefPat<v2i64, v1i64>;
3716 def : ConcatUndefPat<v2f64, v1f64>;
3717 def : ConcatUndefPat<v4i32, v2i32>;
3718 def : ConcatUndefPat<v4f32, v2f32>;
3719 def : ConcatUndefPat<v8i16, v4i16>;
3720 def : ConcatUndefPat<v16i8, v8i8>;
3722 //----------------------------------------------------------------------------
3723 // AdvSIMD across lanes instructions
3724 //----------------------------------------------------------------------------
3726 defm ADDV : SIMDAcrossLanesBHS<0, 0b11011, "addv">;
3727 defm SMAXV : SIMDAcrossLanesBHS<0, 0b01010, "smaxv">;
3728 defm SMINV : SIMDAcrossLanesBHS<0, 0b11010, "sminv">;
3729 defm UMAXV : SIMDAcrossLanesBHS<1, 0b01010, "umaxv">;
3730 defm UMINV : SIMDAcrossLanesBHS<1, 0b11010, "uminv">;
3731 defm SADDLV : SIMDAcrossLanesHSD<0, 0b00011, "saddlv">;
3732 defm UADDLV : SIMDAcrossLanesHSD<1, 0b00011, "uaddlv">;
3733 defm FMAXNMV : SIMDAcrossLanesS<0b01100, 0, "fmaxnmv", int_aarch64_neon_fmaxnmv>;
3734 defm FMAXV : SIMDAcrossLanesS<0b01111, 0, "fmaxv", int_aarch64_neon_fmaxv>;
3735 defm FMINNMV : SIMDAcrossLanesS<0b01100, 1, "fminnmv", int_aarch64_neon_fminnmv>;
3736 defm FMINV : SIMDAcrossLanesS<0b01111, 1, "fminv", int_aarch64_neon_fminv>;
3738 multiclass SIMDAcrossLanesSignedIntrinsic<string baseOpc, Intrinsic intOp> {
3739 // If there is a sign extension after this intrinsic, consume it as smov already
3741 def : Pat<(i32 (sext_inreg (i32 (intOp (v8i8 V64:$Rn))), i8)),
3743 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3744 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), bsub),
3746 def : Pat<(i32 (intOp (v8i8 V64:$Rn))),
3748 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3749 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), bsub),
3751 // If there is a sign extension after this intrinsic, consume it as smov already
3753 def : Pat<(i32 (sext_inreg (i32 (intOp (v16i8 V128:$Rn))), i8)),
3755 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3756 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), bsub),
3758 def : Pat<(i32 (intOp (v16i8 V128:$Rn))),
3760 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3761 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), bsub),
3763 // If there is a sign extension after this intrinsic, consume it as smov already
3765 def : Pat<(i32 (sext_inreg (i32 (intOp (v4i16 V64:$Rn))), i16)),
3767 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3768 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), hsub),
3770 def : Pat<(i32 (intOp (v4i16 V64:$Rn))),
3772 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3773 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), hsub),
3775 // If there is a sign extension after this intrinsic, consume it as smov already
3777 def : Pat<(i32 (sext_inreg (i32 (intOp (v8i16 V128:$Rn))), i16)),
3779 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3780 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), hsub),
3782 def : Pat<(i32 (intOp (v8i16 V128:$Rn))),
3784 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3785 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), hsub),
3788 def : Pat<(i32 (intOp (v4i32 V128:$Rn))),
3789 (i32 (EXTRACT_SUBREG
3790 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3791 (!cast<Instruction>(!strconcat(baseOpc, "v4i32v")) V128:$Rn), ssub),
3795 multiclass SIMDAcrossLanesUnsignedIntrinsic<string baseOpc, Intrinsic intOp> {
3796 // If there is a masking operation keeping only what has been actually
3797 // generated, consume it.
3798 def : Pat<(i32 (and (i32 (intOp (v8i8 V64:$Rn))), maski8_or_more)),
3799 (i32 (EXTRACT_SUBREG
3800 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3801 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), bsub),
3803 def : Pat<(i32 (intOp (v8i8 V64:$Rn))),
3804 (i32 (EXTRACT_SUBREG
3805 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3806 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), bsub),
3808 // If there is a masking operation keeping only what has been actually
3809 // generated, consume it.
3810 def : Pat<(i32 (and (i32 (intOp (v16i8 V128:$Rn))), maski8_or_more)),
3811 (i32 (EXTRACT_SUBREG
3812 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3813 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), bsub),
3815 def : Pat<(i32 (intOp (v16i8 V128:$Rn))),
3816 (i32 (EXTRACT_SUBREG
3817 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3818 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), bsub),
3821 // If there is a masking operation keeping only what has been actually
3822 // generated, consume it.
3823 def : Pat<(i32 (and (i32 (intOp (v4i16 V64:$Rn))), maski16_or_more)),
3824 (i32 (EXTRACT_SUBREG
3825 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3826 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), hsub),
3828 def : Pat<(i32 (intOp (v4i16 V64:$Rn))),
3829 (i32 (EXTRACT_SUBREG
3830 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3831 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), hsub),
3833 // If there is a masking operation keeping only what has been actually
3834 // generated, consume it.
3835 def : Pat<(i32 (and (i32 (intOp (v8i16 V128:$Rn))), maski16_or_more)),
3836 (i32 (EXTRACT_SUBREG
3837 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3838 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), hsub),
3840 def : Pat<(i32 (intOp (v8i16 V128:$Rn))),
3841 (i32 (EXTRACT_SUBREG
3842 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3843 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), hsub),
3846 def : Pat<(i32 (intOp (v4i32 V128:$Rn))),
3847 (i32 (EXTRACT_SUBREG
3848 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3849 (!cast<Instruction>(!strconcat(baseOpc, "v4i32v")) V128:$Rn), ssub),
3854 multiclass SIMDAcrossLanesSignedLongIntrinsic<string baseOpc, Intrinsic intOp> {
3855 def : Pat<(i32 (intOp (v8i8 V64:$Rn))),
3857 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3858 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), hsub),
3860 def : Pat<(i32 (intOp (v16i8 V128:$Rn))),
3862 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3863 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), hsub),
3866 def : Pat<(i32 (intOp (v4i16 V64:$Rn))),
3867 (i32 (EXTRACT_SUBREG
3868 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3869 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), ssub),
3871 def : Pat<(i32 (intOp (v8i16 V128:$Rn))),
3872 (i32 (EXTRACT_SUBREG
3873 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3874 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), ssub),
3877 def : Pat<(i64 (intOp (v4i32 V128:$Rn))),
3878 (i64 (EXTRACT_SUBREG
3879 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3880 (!cast<Instruction>(!strconcat(baseOpc, "v4i32v")) V128:$Rn), dsub),
3884 multiclass SIMDAcrossLanesUnsignedLongIntrinsic<string baseOpc,
3886 def : Pat<(i32 (intOp (v8i8 V64:$Rn))),
3887 (i32 (EXTRACT_SUBREG
3888 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3889 (!cast<Instruction>(!strconcat(baseOpc, "v8i8v")) V64:$Rn), hsub),
3891 def : Pat<(i32 (intOp (v16i8 V128:$Rn))),
3892 (i32 (EXTRACT_SUBREG
3893 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3894 (!cast<Instruction>(!strconcat(baseOpc, "v16i8v")) V128:$Rn), hsub),
3897 def : Pat<(i32 (intOp (v4i16 V64:$Rn))),
3898 (i32 (EXTRACT_SUBREG
3899 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3900 (!cast<Instruction>(!strconcat(baseOpc, "v4i16v")) V64:$Rn), ssub),
3902 def : Pat<(i32 (intOp (v8i16 V128:$Rn))),
3903 (i32 (EXTRACT_SUBREG
3904 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3905 (!cast<Instruction>(!strconcat(baseOpc, "v8i16v")) V128:$Rn), ssub),
3908 def : Pat<(i64 (intOp (v4i32 V128:$Rn))),
3909 (i64 (EXTRACT_SUBREG
3910 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3911 (!cast<Instruction>(!strconcat(baseOpc, "v4i32v")) V128:$Rn), dsub),
3915 defm : SIMDAcrossLanesSignedIntrinsic<"ADDV", int_aarch64_neon_saddv>;
3916 // vaddv_[su]32 is special; -> ADDP Vd.2S,Vn.2S,Vm.2S; return Vd.s[0];Vn==Vm
3917 def : Pat<(i32 (int_aarch64_neon_saddv (v2i32 V64:$Rn))),
3918 (EXTRACT_SUBREG (ADDPv2i32 V64:$Rn, V64:$Rn), ssub)>;
3920 defm : SIMDAcrossLanesUnsignedIntrinsic<"ADDV", int_aarch64_neon_uaddv>;
3921 // vaddv_[su]32 is special; -> ADDP Vd.2S,Vn.2S,Vm.2S; return Vd.s[0];Vn==Vm
3922 def : Pat<(i32 (int_aarch64_neon_uaddv (v2i32 V64:$Rn))),
3923 (EXTRACT_SUBREG (ADDPv2i32 V64:$Rn, V64:$Rn), ssub)>;
3925 defm : SIMDAcrossLanesSignedIntrinsic<"SMAXV", int_aarch64_neon_smaxv>;
3926 def : Pat<(i32 (int_aarch64_neon_smaxv (v2i32 V64:$Rn))),
3927 (EXTRACT_SUBREG (SMAXPv2i32 V64:$Rn, V64:$Rn), ssub)>;
3929 defm : SIMDAcrossLanesSignedIntrinsic<"SMINV", int_aarch64_neon_sminv>;
3930 def : Pat<(i32 (int_aarch64_neon_sminv (v2i32 V64:$Rn))),
3931 (EXTRACT_SUBREG (SMINPv2i32 V64:$Rn, V64:$Rn), ssub)>;
3933 defm : SIMDAcrossLanesUnsignedIntrinsic<"UMAXV", int_aarch64_neon_umaxv>;
3934 def : Pat<(i32 (int_aarch64_neon_umaxv (v2i32 V64:$Rn))),
3935 (EXTRACT_SUBREG (UMAXPv2i32 V64:$Rn, V64:$Rn), ssub)>;
3937 defm : SIMDAcrossLanesUnsignedIntrinsic<"UMINV", int_aarch64_neon_uminv>;
3938 def : Pat<(i32 (int_aarch64_neon_uminv (v2i32 V64:$Rn))),
3939 (EXTRACT_SUBREG (UMINPv2i32 V64:$Rn, V64:$Rn), ssub)>;
3941 defm : SIMDAcrossLanesSignedLongIntrinsic<"SADDLV", int_aarch64_neon_saddlv>;
3942 defm : SIMDAcrossLanesUnsignedLongIntrinsic<"UADDLV", int_aarch64_neon_uaddlv>;
3944 // The vaddlv_s32 intrinsic gets mapped to SADDLP.
3945 def : Pat<(i64 (int_aarch64_neon_saddlv (v2i32 V64:$Rn))),
3946 (i64 (EXTRACT_SUBREG
3947 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3948 (SADDLPv2i32_v1i64 V64:$Rn), dsub),
3950 // The vaddlv_u32 intrinsic gets mapped to UADDLP.
3951 def : Pat<(i64 (int_aarch64_neon_uaddlv (v2i32 V64:$Rn))),
3952 (i64 (EXTRACT_SUBREG
3953 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)),
3954 (UADDLPv2i32_v1i64 V64:$Rn), dsub),
3957 //------------------------------------------------------------------------------
3958 // AdvSIMD modified immediate instructions
3959 //------------------------------------------------------------------------------
3962 defm BIC : SIMDModifiedImmVectorShiftTied<1, 0b11, 0b01, "bic", AArch64bici>;
3964 defm ORR : SIMDModifiedImmVectorShiftTied<0, 0b11, 0b01, "orr", AArch64orri>;
3966 def : InstAlias<"bic $Vd.4h, $imm", (BICv4i16 V64:$Vd, imm0_255:$imm, 0)>;
3967 def : InstAlias<"bic $Vd.8h, $imm", (BICv8i16 V128:$Vd, imm0_255:$imm, 0)>;
3968 def : InstAlias<"bic $Vd.2s, $imm", (BICv2i32 V64:$Vd, imm0_255:$imm, 0)>;
3969 def : InstAlias<"bic $Vd.4s, $imm", (BICv4i32 V128:$Vd, imm0_255:$imm, 0)>;
3971 def : InstAlias<"bic.4h $Vd, $imm", (BICv4i16 V64:$Vd, imm0_255:$imm, 0), 0>;
3972 def : InstAlias<"bic.8h $Vd, $imm", (BICv8i16 V128:$Vd, imm0_255:$imm, 0), 0>;
3973 def : InstAlias<"bic.2s $Vd, $imm", (BICv2i32 V64:$Vd, imm0_255:$imm, 0), 0>;
3974 def : InstAlias<"bic.4s $Vd, $imm", (BICv4i32 V128:$Vd, imm0_255:$imm, 0), 0>;
3976 def : InstAlias<"orr $Vd.4h, $imm", (ORRv4i16 V64:$Vd, imm0_255:$imm, 0)>;
3977 def : InstAlias<"orr $Vd.8h, $imm", (ORRv8i16 V128:$Vd, imm0_255:$imm, 0)>;
3978 def : InstAlias<"orr $Vd.2s, $imm", (ORRv2i32 V64:$Vd, imm0_255:$imm, 0)>;
3979 def : InstAlias<"orr $Vd.4s, $imm", (ORRv4i32 V128:$Vd, imm0_255:$imm, 0)>;
3981 def : InstAlias<"orr.4h $Vd, $imm", (ORRv4i16 V64:$Vd, imm0_255:$imm, 0), 0>;
3982 def : InstAlias<"orr.8h $Vd, $imm", (ORRv8i16 V128:$Vd, imm0_255:$imm, 0), 0>;
3983 def : InstAlias<"orr.2s $Vd, $imm", (ORRv2i32 V64:$Vd, imm0_255:$imm, 0), 0>;
3984 def : InstAlias<"orr.4s $Vd, $imm", (ORRv4i32 V128:$Vd, imm0_255:$imm, 0), 0>;
3987 def FMOVv2f64_ns : SIMDModifiedImmVectorNoShift<1, 1, 0b1111, V128, fpimm8,
3989 [(set (v2f64 V128:$Rd), (AArch64fmov imm0_255:$imm8))]>;
3990 def FMOVv2f32_ns : SIMDModifiedImmVectorNoShift<0, 0, 0b1111, V64, fpimm8,
3992 [(set (v2f32 V64:$Rd), (AArch64fmov imm0_255:$imm8))]>;
3993 def FMOVv4f32_ns : SIMDModifiedImmVectorNoShift<1, 0, 0b1111, V128, fpimm8,
3995 [(set (v4f32 V128:$Rd), (AArch64fmov imm0_255:$imm8))]>;
3999 // EDIT byte mask: scalar
4000 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
4001 def MOVID : SIMDModifiedImmScalarNoShift<0, 1, 0b1110, "movi",
4002 [(set FPR64:$Rd, simdimmtype10:$imm8)]>;
4003 // The movi_edit node has the immediate value already encoded, so we use
4004 // a plain imm0_255 here.
4005 def : Pat<(f64 (AArch64movi_edit imm0_255:$shift)),
4006 (MOVID imm0_255:$shift)>;
4008 def : Pat<(v1i64 immAllZerosV), (MOVID (i32 0))>;
4009 def : Pat<(v2i32 immAllZerosV), (MOVID (i32 0))>;
4010 def : Pat<(v4i16 immAllZerosV), (MOVID (i32 0))>;
4011 def : Pat<(v8i8 immAllZerosV), (MOVID (i32 0))>;
4013 def : Pat<(v1i64 immAllOnesV), (MOVID (i32 255))>;
4014 def : Pat<(v2i32 immAllOnesV), (MOVID (i32 255))>;
4015 def : Pat<(v4i16 immAllOnesV), (MOVID (i32 255))>;
4016 def : Pat<(v8i8 immAllOnesV), (MOVID (i32 255))>;
4018 // EDIT byte mask: 2d
4020 // The movi_edit node has the immediate value already encoded, so we use
4021 // a plain imm0_255 in the pattern
4022 let isReMaterializable = 1, isAsCheapAsAMove = 1 in
4023 def MOVIv2d_ns : SIMDModifiedImmVectorNoShift<1, 1, 0b1110, V128,
4026 [(set (v2i64 V128:$Rd), (AArch64movi_edit imm0_255:$imm8))]>;
4029 // Use movi.2d to materialize 0.0 if the HW does zero-cycle zeroing.
4030 // Complexity is added to break a tie with a plain MOVI.
4031 let AddedComplexity = 1 in {
4032 def : Pat<(f32 fpimm0),
4033 (f32 (EXTRACT_SUBREG (v2i64 (MOVIv2d_ns (i32 0))), ssub))>,
4035 def : Pat<(f64 fpimm0),
4036 (f64 (EXTRACT_SUBREG (v2i64 (MOVIv2d_ns (i32 0))), dsub))>,
4040 def : Pat<(v2i64 immAllZerosV), (MOVIv2d_ns (i32 0))>;
4041 def : Pat<(v4i32 immAllZerosV), (MOVIv2d_ns (i32 0))>;
4042 def : Pat<(v8i16 immAllZerosV), (MOVIv2d_ns (i32 0))>;
4043 def : Pat<(v16i8 immAllZerosV), (MOVIv2d_ns (i32 0))>;
4045 def : Pat<(v2i64 immAllOnesV), (MOVIv2d_ns (i32 255))>;
4046 def : Pat<(v4i32 immAllOnesV), (MOVIv2d_ns (i32 255))>;
4047 def : Pat<(v8i16 immAllOnesV), (MOVIv2d_ns (i32 255))>;
4048 def : Pat<(v16i8 immAllOnesV), (MOVIv2d_ns (i32 255))>;
4050 def : Pat<(v2f64 (AArch64dup (f64 fpimm0))), (MOVIv2d_ns (i32 0))>;
4051 def : Pat<(v4f32 (AArch64dup (f32 fpimm0))), (MOVIv2d_ns (i32 0))>;
4053 // EDIT per word & halfword: 2s, 4h, 4s, & 8h
4054 defm MOVI : SIMDModifiedImmVectorShift<0, 0b10, 0b00, "movi">;
4056 def : InstAlias<"movi $Vd.4h, $imm", (MOVIv4i16 V64:$Vd, imm0_255:$imm, 0), 0>;
4057 def : InstAlias<"movi $Vd.8h, $imm", (MOVIv8i16 V128:$Vd, imm0_255:$imm, 0), 0>;
4058 def : InstAlias<"movi $Vd.2s, $imm", (MOVIv2i32 V64:$Vd, imm0_255:$imm, 0), 0>;
4059 def : InstAlias<"movi $Vd.4s, $imm", (MOVIv4i32 V128:$Vd, imm0_255:$imm, 0), 0>;
4061 def : InstAlias<"movi.4h $Vd, $imm", (MOVIv4i16 V64:$Vd, imm0_255:$imm, 0), 0>;
4062 def : InstAlias<"movi.8h $Vd, $imm", (MOVIv8i16 V128:$Vd, imm0_255:$imm, 0), 0>;
4063 def : InstAlias<"movi.2s $Vd, $imm", (MOVIv2i32 V64:$Vd, imm0_255:$imm, 0), 0>;
4064 def : InstAlias<"movi.4s $Vd, $imm", (MOVIv4i32 V128:$Vd, imm0_255:$imm, 0), 0>;
4066 def : Pat<(v2i32 (AArch64movi_shift imm0_255:$imm8, (i32 imm:$shift))),
4067 (MOVIv2i32 imm0_255:$imm8, imm:$shift)>;
4068 def : Pat<(v4i32 (AArch64movi_shift imm0_255:$imm8, (i32 imm:$shift))),
4069 (MOVIv4i32 imm0_255:$imm8, imm:$shift)>;
4070 def : Pat<(v4i16 (AArch64movi_shift imm0_255:$imm8, (i32 imm:$shift))),
4071 (MOVIv4i16 imm0_255:$imm8, imm:$shift)>;
4072 def : Pat<(v8i16 (AArch64movi_shift imm0_255:$imm8, (i32 imm:$shift))),
4073 (MOVIv8i16 imm0_255:$imm8, imm:$shift)>;
4075 // EDIT per word: 2s & 4s with MSL shifter
4076 def MOVIv2s_msl : SIMDModifiedImmMoveMSL<0, 0, {1,1,0,?}, V64, "movi", ".2s",
4077 [(set (v2i32 V64:$Rd),
4078 (AArch64movi_msl imm0_255:$imm8, (i32 imm:$shift)))]>;
4079 def MOVIv4s_msl : SIMDModifiedImmMoveMSL<1, 0, {1,1,0,?}, V128, "movi", ".4s",
4080 [(set (v4i32 V128:$Rd),
4081 (AArch64movi_msl imm0_255:$imm8, (i32 imm:$shift)))]>;
4083 // Per byte: 8b & 16b
4084 def MOVIv8b_ns : SIMDModifiedImmVectorNoShift<0, 0, 0b1110, V64, imm0_255,
4086 [(set (v8i8 V64:$Rd), (AArch64movi imm0_255:$imm8))]>;
4087 def MOVIv16b_ns : SIMDModifiedImmVectorNoShift<1, 0, 0b1110, V128, imm0_255,
4089 [(set (v16i8 V128:$Rd), (AArch64movi imm0_255:$imm8))]>;
4093 // EDIT per word & halfword: 2s, 4h, 4s, & 8h
4094 defm MVNI : SIMDModifiedImmVectorShift<1, 0b10, 0b00, "mvni">;
4096 def : InstAlias<"mvni $Vd.4h, $imm", (MVNIv4i16 V64:$Vd, imm0_255:$imm, 0), 0>;
4097 def : InstAlias<"mvni $Vd.8h, $imm", (MVNIv8i16 V128:$Vd, imm0_255:$imm, 0), 0>;
4098 def : InstAlias<"mvni $Vd.2s, $imm", (MVNIv2i32 V64:$Vd, imm0_255:$imm, 0), 0>;
4099 def : InstAlias<"mvni $Vd.4s, $imm", (MVNIv4i32 V128:$Vd, imm0_255:$imm, 0), 0>;
4101 def : InstAlias<"mvni.4h $Vd, $imm", (MVNIv4i16 V64:$Vd, imm0_255:$imm, 0), 0>;
4102 def : InstAlias<"mvni.8h $Vd, $imm", (MVNIv8i16 V128:$Vd, imm0_255:$imm, 0), 0>;
4103 def : InstAlias<"mvni.2s $Vd, $imm", (MVNIv2i32 V64:$Vd, imm0_255:$imm, 0), 0>;
4104 def : InstAlias<"mvni.4s $Vd, $imm", (MVNIv4i32 V128:$Vd, imm0_255:$imm, 0), 0>;
4106 def : Pat<(v2i32 (AArch64mvni_shift imm0_255:$imm8, (i32 imm:$shift))),
4107 (MVNIv2i32 imm0_255:$imm8, imm:$shift)>;
4108 def : Pat<(v4i32 (AArch64mvni_shift imm0_255:$imm8, (i32 imm:$shift))),
4109 (MVNIv4i32 imm0_255:$imm8, imm:$shift)>;
4110 def : Pat<(v4i16 (AArch64mvni_shift imm0_255:$imm8, (i32 imm:$shift))),
4111 (MVNIv4i16 imm0_255:$imm8, imm:$shift)>;
4112 def : Pat<(v8i16 (AArch64mvni_shift imm0_255:$imm8, (i32 imm:$shift))),
4113 (MVNIv8i16 imm0_255:$imm8, imm:$shift)>;
4115 // EDIT per word: 2s & 4s with MSL shifter
4116 def MVNIv2s_msl : SIMDModifiedImmMoveMSL<0, 1, {1,1,0,?}, V64, "mvni", ".2s",
4117 [(set (v2i32 V64:$Rd),
4118 (AArch64mvni_msl imm0_255:$imm8, (i32 imm:$shift)))]>;
4119 def MVNIv4s_msl : SIMDModifiedImmMoveMSL<1, 1, {1,1,0,?}, V128, "mvni", ".4s",
4120 [(set (v4i32 V128:$Rd),
4121 (AArch64mvni_msl imm0_255:$imm8, (i32 imm:$shift)))]>;
4123 //----------------------------------------------------------------------------
4124 // AdvSIMD indexed element
4125 //----------------------------------------------------------------------------
4127 let hasSideEffects = 0 in {
4128 defm FMLA : SIMDFPIndexedSDTied<0, 0b0001, "fmla">;
4129 defm FMLS : SIMDFPIndexedSDTied<0, 0b0101, "fmls">;
4132 // NOTE: Operands are reordered in the FMLA/FMLS PatFrags because the
4133 // instruction expects the addend first, while the intrinsic expects it last.
4135 // On the other hand, there are quite a few valid combinatorial options due to
4136 // the commutativity of multiplication and the fact that (-x) * y = x * (-y).
4137 defm : SIMDFPIndexedSDTiedPatterns<"FMLA",
4138 TriOpFrag<(fma node:$RHS, node:$MHS, node:$LHS)>>;
4139 defm : SIMDFPIndexedSDTiedPatterns<"FMLA",
4140 TriOpFrag<(fma node:$MHS, node:$RHS, node:$LHS)>>;
4142 defm : SIMDFPIndexedSDTiedPatterns<"FMLS",
4143 TriOpFrag<(fma node:$MHS, (fneg node:$RHS), node:$LHS)> >;
4144 defm : SIMDFPIndexedSDTiedPatterns<"FMLS",
4145 TriOpFrag<(fma node:$RHS, (fneg node:$MHS), node:$LHS)> >;
4146 defm : SIMDFPIndexedSDTiedPatterns<"FMLS",
4147 TriOpFrag<(fma (fneg node:$RHS), node:$MHS, node:$LHS)> >;
4148 defm : SIMDFPIndexedSDTiedPatterns<"FMLS",
4149 TriOpFrag<(fma (fneg node:$MHS), node:$RHS, node:$LHS)> >;
4151 multiclass FMLSIndexedAfterNegPatterns<SDPatternOperator OpNode> {
4152 // 3 variants for the .2s version: DUPLANE from 128-bit, DUPLANE from 64-bit
4154 def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn),
4155 (AArch64duplane32 (v4f32 (fneg V128:$Rm)),
4156 VectorIndexS:$idx))),
4157 (FMLSv2i32_indexed V64:$Rd, V64:$Rn, V128:$Rm, VectorIndexS:$idx)>;
4158 def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn),
4159 (v2f32 (AArch64duplane32
4160 (v4f32 (insert_subvector undef,
4161 (v2f32 (fneg V64:$Rm)),
4163 VectorIndexS:$idx)))),
4164 (FMLSv2i32_indexed V64:$Rd, V64:$Rn,
4165 (SUBREG_TO_REG (i32 0), V64:$Rm, dsub),
4166 VectorIndexS:$idx)>;
4167 def : Pat<(v2f32 (OpNode (v2f32 V64:$Rd), (v2f32 V64:$Rn),
4168 (AArch64dup (f32 (fneg FPR32Op:$Rm))))),
4169 (FMLSv2i32_indexed V64:$Rd, V64:$Rn,
4170 (SUBREG_TO_REG (i32 0), FPR32Op:$Rm, ssub), (i64 0))>;
4172 // 3 variants for the .4s version: DUPLANE from 128-bit, DUPLANE from 64-bit
4174 def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn),
4175 (AArch64duplane32 (v4f32 (fneg V128:$Rm)),
4176 VectorIndexS:$idx))),
4177 (FMLSv4i32_indexed V128:$Rd, V128:$Rn, V128:$Rm,
4178 VectorIndexS:$idx)>;
4179 def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn),
4180 (v4f32 (AArch64duplane32
4181 (v4f32 (insert_subvector undef,
4182 (v2f32 (fneg V64:$Rm)),
4184 VectorIndexS:$idx)))),
4185 (FMLSv4i32_indexed V128:$Rd, V128:$Rn,
4186 (SUBREG_TO_REG (i32 0), V64:$Rm, dsub),
4187 VectorIndexS:$idx)>;
4188 def : Pat<(v4f32 (OpNode (v4f32 V128:$Rd), (v4f32 V128:$Rn),
4189 (AArch64dup (f32 (fneg FPR32Op:$Rm))))),
4190 (FMLSv4i32_indexed V128:$Rd, V128:$Rn,
4191 (SUBREG_TO_REG (i32 0), FPR32Op:$Rm, ssub), (i64 0))>;
4193 // 2 variants for the .2d version: DUPLANE from 128-bit, and DUP scalar
4194 // (DUPLANE from 64-bit would be trivial).
4195 def : Pat<(v2f64 (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn),
4196 (AArch64duplane64 (v2f64 (fneg V128:$Rm)),
4197 VectorIndexD:$idx))),
4199 V128:$Rd, V128:$Rn, V128:$Rm, VectorIndexS:$idx)>;
4200 def : Pat<(v2f64 (OpNode (v2f64 V128:$Rd), (v2f64 V128:$Rn),
4201 (AArch64dup (f64 (fneg FPR64Op:$Rm))))),
4202 (FMLSv2i64_indexed V128:$Rd, V128:$Rn,
4203 (SUBREG_TO_REG (i32 0), FPR64Op:$Rm, dsub), (i64 0))>;
4205 // 2 variants for 32-bit scalar version: extract from .2s or from .4s
4206 def : Pat<(f32 (OpNode (f32 FPR32:$Rd), (f32 FPR32:$Rn),
4207 (vector_extract (v4f32 (fneg V128:$Rm)),
4208 VectorIndexS:$idx))),
4209 (FMLSv1i32_indexed FPR32:$Rd, FPR32:$Rn,
4210 V128:$Rm, VectorIndexS:$idx)>;
4211 def : Pat<(f32 (OpNode (f32 FPR32:$Rd), (f32 FPR32:$Rn),
4212 (vector_extract (v2f32 (fneg V64:$Rm)),
4213 VectorIndexS:$idx))),
4214 (FMLSv1i32_indexed FPR32:$Rd, FPR32:$Rn,
4215 (SUBREG_TO_REG (i32 0), V64:$Rm, dsub), VectorIndexS:$idx)>;
4217 // 1 variant for 64-bit scalar version: extract from .1d or from .2d
4218 def : Pat<(f64 (OpNode (f64 FPR64:$Rd), (f64 FPR64:$Rn),
4219 (vector_extract (v2f64 (fneg V128:$Rm)),
4220 VectorIndexS:$idx))),
4221 (FMLSv1i64_indexed FPR64:$Rd, FPR64:$Rn,
4222 V128:$Rm, VectorIndexS:$idx)>;
4225 defm : FMLSIndexedAfterNegPatterns<
4226 TriOpFrag<(fma node:$RHS, node:$MHS, node:$LHS)> >;
4227 defm : FMLSIndexedAfterNegPatterns<
4228 TriOpFrag<(fma node:$MHS, node:$RHS, node:$LHS)> >;
4230 defm FMULX : SIMDFPIndexedSD<1, 0b1001, "fmulx", int_aarch64_neon_fmulx>;
4231 defm FMUL : SIMDFPIndexedSD<0, 0b1001, "fmul", fmul>;
4233 def : Pat<(v2f32 (fmul V64:$Rn, (AArch64dup (f32 FPR32:$Rm)))),
4234 (FMULv2i32_indexed V64:$Rn,
4235 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR32:$Rm, ssub),
4237 def : Pat<(v4f32 (fmul V128:$Rn, (AArch64dup (f32 FPR32:$Rm)))),
4238 (FMULv4i32_indexed V128:$Rn,
4239 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR32:$Rm, ssub),
4241 def : Pat<(v2f64 (fmul V128:$Rn, (AArch64dup (f64 FPR64:$Rm)))),
4242 (FMULv2i64_indexed V128:$Rn,
4243 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR64:$Rm, dsub),
4246 defm SQDMULH : SIMDIndexedHS<0, 0b1100, "sqdmulh", int_aarch64_neon_sqdmulh>;
4247 defm SQRDMULH : SIMDIndexedHS<0, 0b1101, "sqrdmulh", int_aarch64_neon_sqrdmulh>;
4248 defm MLA : SIMDVectorIndexedHSTied<1, 0b0000, "mla",
4249 TriOpFrag<(add node:$LHS, (mul node:$MHS, node:$RHS))>>;
4250 defm MLS : SIMDVectorIndexedHSTied<1, 0b0100, "mls",
4251 TriOpFrag<(sub node:$LHS, (mul node:$MHS, node:$RHS))>>;
4252 defm MUL : SIMDVectorIndexedHS<0, 0b1000, "mul", mul>;
4253 defm SMLAL : SIMDVectorIndexedLongSDTied<0, 0b0010, "smlal",
4254 TriOpFrag<(add node:$LHS, (int_aarch64_neon_smull node:$MHS, node:$RHS))>>;
4255 defm SMLSL : SIMDVectorIndexedLongSDTied<0, 0b0110, "smlsl",
4256 TriOpFrag<(sub node:$LHS, (int_aarch64_neon_smull node:$MHS, node:$RHS))>>;
4257 defm SMULL : SIMDVectorIndexedLongSD<0, 0b1010, "smull",
4258 int_aarch64_neon_smull>;
4259 defm SQDMLAL : SIMDIndexedLongSQDMLXSDTied<0, 0b0011, "sqdmlal",
4260 int_aarch64_neon_sqadd>;
4261 defm SQDMLSL : SIMDIndexedLongSQDMLXSDTied<0, 0b0111, "sqdmlsl",
4262 int_aarch64_neon_sqsub>;
4263 defm SQDMULL : SIMDIndexedLongSD<0, 0b1011, "sqdmull", int_aarch64_neon_sqdmull>;
4264 defm UMLAL : SIMDVectorIndexedLongSDTied<1, 0b0010, "umlal",
4265 TriOpFrag<(add node:$LHS, (int_aarch64_neon_umull node:$MHS, node:$RHS))>>;
4266 defm UMLSL : SIMDVectorIndexedLongSDTied<1, 0b0110, "umlsl",
4267 TriOpFrag<(sub node:$LHS, (int_aarch64_neon_umull node:$MHS, node:$RHS))>>;
4268 defm UMULL : SIMDVectorIndexedLongSD<1, 0b1010, "umull",
4269 int_aarch64_neon_umull>;
4271 // A scalar sqdmull with the second operand being a vector lane can be
4272 // handled directly with the indexed instruction encoding.
4273 def : Pat<(int_aarch64_neon_sqdmulls_scalar (i32 FPR32:$Rn),
4274 (vector_extract (v4i32 V128:$Vm),
4275 VectorIndexS:$idx)),
4276 (SQDMULLv1i64_indexed FPR32:$Rn, V128:$Vm, VectorIndexS:$idx)>;
4278 //----------------------------------------------------------------------------
4279 // AdvSIMD scalar shift instructions
4280 //----------------------------------------------------------------------------
4281 defm FCVTZS : SIMDScalarRShiftSD<0, 0b11111, "fcvtzs">;
4282 defm FCVTZU : SIMDScalarRShiftSD<1, 0b11111, "fcvtzu">;
4283 defm SCVTF : SIMDScalarRShiftSD<0, 0b11100, "scvtf">;
4284 defm UCVTF : SIMDScalarRShiftSD<1, 0b11100, "ucvtf">;
4285 // Codegen patterns for the above. We don't put these directly on the
4286 // instructions because TableGen's type inference can't handle the truth.
4287 // Having the same base pattern for fp <--> int totally freaks it out.
4288 def : Pat<(int_aarch64_neon_vcvtfp2fxs FPR32:$Rn, vecshiftR32:$imm),
4289 (FCVTZSs FPR32:$Rn, vecshiftR32:$imm)>;
4290 def : Pat<(int_aarch64_neon_vcvtfp2fxu FPR32:$Rn, vecshiftR32:$imm),
4291 (FCVTZUs FPR32:$Rn, vecshiftR32:$imm)>;
4292 def : Pat<(i64 (int_aarch64_neon_vcvtfp2fxs (f64 FPR64:$Rn), vecshiftR64:$imm)),
4293 (FCVTZSd FPR64:$Rn, vecshiftR64:$imm)>;
4294 def : Pat<(i64 (int_aarch64_neon_vcvtfp2fxu (f64 FPR64:$Rn), vecshiftR64:$imm)),
4295 (FCVTZUd FPR64:$Rn, vecshiftR64:$imm)>;
4296 def : Pat<(v1i64 (int_aarch64_neon_vcvtfp2fxs (v1f64 FPR64:$Rn),
4298 (FCVTZSd FPR64:$Rn, vecshiftR64:$imm)>;
4299 def : Pat<(v1i64 (int_aarch64_neon_vcvtfp2fxu (v1f64 FPR64:$Rn),
4301 (FCVTZUd FPR64:$Rn, vecshiftR64:$imm)>;
4302 def : Pat<(int_aarch64_neon_vcvtfxs2fp FPR32:$Rn, vecshiftR32:$imm),
4303 (SCVTFs FPR32:$Rn, vecshiftR32:$imm)>;
4304 def : Pat<(int_aarch64_neon_vcvtfxu2fp FPR32:$Rn, vecshiftR32:$imm),
4305 (UCVTFs FPR32:$Rn, vecshiftR32:$imm)>;
4306 def : Pat<(f64 (int_aarch64_neon_vcvtfxs2fp (i64 FPR64:$Rn), vecshiftR64:$imm)),
4307 (SCVTFd FPR64:$Rn, vecshiftR64:$imm)>;
4308 def : Pat<(f64 (int_aarch64_neon_vcvtfxu2fp (i64 FPR64:$Rn), vecshiftR64:$imm)),
4309 (UCVTFd FPR64:$Rn, vecshiftR64:$imm)>;
4310 def : Pat<(v1f64 (int_aarch64_neon_vcvtfxs2fp (v1i64 FPR64:$Rn),
4312 (SCVTFd FPR64:$Rn, vecshiftR64:$imm)>;
4313 def : Pat<(v1f64 (int_aarch64_neon_vcvtfxu2fp (v1i64 FPR64:$Rn),
4315 (UCVTFd FPR64:$Rn, vecshiftR64:$imm)>;
4317 defm SHL : SIMDScalarLShiftD< 0, 0b01010, "shl", AArch64vshl>;
4318 defm SLI : SIMDScalarLShiftDTied<1, 0b01010, "sli">;
4319 defm SQRSHRN : SIMDScalarRShiftBHS< 0, 0b10011, "sqrshrn",
4320 int_aarch64_neon_sqrshrn>;
4321 defm SQRSHRUN : SIMDScalarRShiftBHS< 1, 0b10001, "sqrshrun",
4322 int_aarch64_neon_sqrshrun>;
4323 defm SQSHLU : SIMDScalarLShiftBHSD<1, 0b01100, "sqshlu", AArch64sqshlui>;
4324 defm SQSHL : SIMDScalarLShiftBHSD<0, 0b01110, "sqshl", AArch64sqshli>;
4325 defm SQSHRN : SIMDScalarRShiftBHS< 0, 0b10010, "sqshrn",
4326 int_aarch64_neon_sqshrn>;
4327 defm SQSHRUN : SIMDScalarRShiftBHS< 1, 0b10000, "sqshrun",
4328 int_aarch64_neon_sqshrun>;
4329 defm SRI : SIMDScalarRShiftDTied< 1, 0b01000, "sri">;
4330 defm SRSHR : SIMDScalarRShiftD< 0, 0b00100, "srshr", AArch64srshri>;
4331 defm SRSRA : SIMDScalarRShiftDTied< 0, 0b00110, "srsra",
4332 TriOpFrag<(add node:$LHS,
4333 (AArch64srshri node:$MHS, node:$RHS))>>;
4334 defm SSHR : SIMDScalarRShiftD< 0, 0b00000, "sshr", AArch64vashr>;
4335 defm SSRA : SIMDScalarRShiftDTied< 0, 0b00010, "ssra",
4336 TriOpFrag<(add node:$LHS,
4337 (AArch64vashr node:$MHS, node:$RHS))>>;
4338 defm UQRSHRN : SIMDScalarRShiftBHS< 1, 0b10011, "uqrshrn",
4339 int_aarch64_neon_uqrshrn>;
4340 defm UQSHL : SIMDScalarLShiftBHSD<1, 0b01110, "uqshl", AArch64uqshli>;
4341 defm UQSHRN : SIMDScalarRShiftBHS< 1, 0b10010, "uqshrn",
4342 int_aarch64_neon_uqshrn>;
4343 defm URSHR : SIMDScalarRShiftD< 1, 0b00100, "urshr", AArch64urshri>;
4344 defm URSRA : SIMDScalarRShiftDTied< 1, 0b00110, "ursra",
4345 TriOpFrag<(add node:$LHS,
4346 (AArch64urshri node:$MHS, node:$RHS))>>;
4347 defm USHR : SIMDScalarRShiftD< 1, 0b00000, "ushr", AArch64vlshr>;
4348 defm USRA : SIMDScalarRShiftDTied< 1, 0b00010, "usra",
4349 TriOpFrag<(add node:$LHS,
4350 (AArch64vlshr node:$MHS, node:$RHS))>>;
4352 //----------------------------------------------------------------------------
4353 // AdvSIMD vector shift instructions
4354 //----------------------------------------------------------------------------
4355 defm FCVTZS:SIMDVectorRShiftSD<0, 0b11111, "fcvtzs", int_aarch64_neon_vcvtfp2fxs>;
4356 defm FCVTZU:SIMDVectorRShiftSD<1, 0b11111, "fcvtzu", int_aarch64_neon_vcvtfp2fxu>;
4357 defm SCVTF: SIMDVectorRShiftSDToFP<0, 0b11100, "scvtf",
4358 int_aarch64_neon_vcvtfxs2fp>;
4359 defm RSHRN : SIMDVectorRShiftNarrowBHS<0, 0b10001, "rshrn",
4360 int_aarch64_neon_rshrn>;
4361 defm SHL : SIMDVectorLShiftBHSD<0, 0b01010, "shl", AArch64vshl>;
4362 defm SHRN : SIMDVectorRShiftNarrowBHS<0, 0b10000, "shrn",
4363 BinOpFrag<(trunc (AArch64vashr node:$LHS, node:$RHS))>>;
4364 defm SLI : SIMDVectorLShiftBHSDTied<1, 0b01010, "sli", int_aarch64_neon_vsli>;
4365 def : Pat<(v1i64 (int_aarch64_neon_vsli (v1i64 FPR64:$Rd), (v1i64 FPR64:$Rn),
4366 (i32 vecshiftL64:$imm))),
4367 (SLId FPR64:$Rd, FPR64:$Rn, vecshiftL64:$imm)>;
4368 defm SQRSHRN : SIMDVectorRShiftNarrowBHS<0, 0b10011, "sqrshrn",
4369 int_aarch64_neon_sqrshrn>;
4370 defm SQRSHRUN: SIMDVectorRShiftNarrowBHS<1, 0b10001, "sqrshrun",
4371 int_aarch64_neon_sqrshrun>;
4372 defm SQSHLU : SIMDVectorLShiftBHSD<1, 0b01100, "sqshlu", AArch64sqshlui>;
4373 defm SQSHL : SIMDVectorLShiftBHSD<0, 0b01110, "sqshl", AArch64sqshli>;
4374 defm SQSHRN : SIMDVectorRShiftNarrowBHS<0, 0b10010, "sqshrn",
4375 int_aarch64_neon_sqshrn>;
4376 defm SQSHRUN : SIMDVectorRShiftNarrowBHS<1, 0b10000, "sqshrun",
4377 int_aarch64_neon_sqshrun>;
4378 defm SRI : SIMDVectorRShiftBHSDTied<1, 0b01000, "sri", int_aarch64_neon_vsri>;
4379 def : Pat<(v1i64 (int_aarch64_neon_vsri (v1i64 FPR64:$Rd), (v1i64 FPR64:$Rn),
4380 (i32 vecshiftR64:$imm))),
4381 (SRId FPR64:$Rd, FPR64:$Rn, vecshiftR64:$imm)>;
4382 defm SRSHR : SIMDVectorRShiftBHSD<0, 0b00100, "srshr", AArch64srshri>;
4383 defm SRSRA : SIMDVectorRShiftBHSDTied<0, 0b00110, "srsra",
4384 TriOpFrag<(add node:$LHS,
4385 (AArch64srshri node:$MHS, node:$RHS))> >;
4386 defm SSHLL : SIMDVectorLShiftLongBHSD<0, 0b10100, "sshll",
4387 BinOpFrag<(AArch64vshl (sext node:$LHS), node:$RHS)>>;
4389 defm SSHR : SIMDVectorRShiftBHSD<0, 0b00000, "sshr", AArch64vashr>;
4390 defm SSRA : SIMDVectorRShiftBHSDTied<0, 0b00010, "ssra",
4391 TriOpFrag<(add node:$LHS, (AArch64vashr node:$MHS, node:$RHS))>>;
4392 defm UCVTF : SIMDVectorRShiftSDToFP<1, 0b11100, "ucvtf",
4393 int_aarch64_neon_vcvtfxu2fp>;
4394 defm UQRSHRN : SIMDVectorRShiftNarrowBHS<1, 0b10011, "uqrshrn",
4395 int_aarch64_neon_uqrshrn>;
4396 defm UQSHL : SIMDVectorLShiftBHSD<1, 0b01110, "uqshl", AArch64uqshli>;
4397 defm UQSHRN : SIMDVectorRShiftNarrowBHS<1, 0b10010, "uqshrn",
4398 int_aarch64_neon_uqshrn>;
4399 defm URSHR : SIMDVectorRShiftBHSD<1, 0b00100, "urshr", AArch64urshri>;
4400 defm URSRA : SIMDVectorRShiftBHSDTied<1, 0b00110, "ursra",
4401 TriOpFrag<(add node:$LHS,
4402 (AArch64urshri node:$MHS, node:$RHS))> >;
4403 defm USHLL : SIMDVectorLShiftLongBHSD<1, 0b10100, "ushll",
4404 BinOpFrag<(AArch64vshl (zext node:$LHS), node:$RHS)>>;
4405 defm USHR : SIMDVectorRShiftBHSD<1, 0b00000, "ushr", AArch64vlshr>;
4406 defm USRA : SIMDVectorRShiftBHSDTied<1, 0b00010, "usra",
4407 TriOpFrag<(add node:$LHS, (AArch64vlshr node:$MHS, node:$RHS))> >;
4409 // SHRN patterns for when a logical right shift was used instead of arithmetic
4410 // (the immediate guarantees no sign bits actually end up in the result so it
4412 def : Pat<(v8i8 (trunc (AArch64vlshr (v8i16 V128:$Rn), vecshiftR16Narrow:$imm))),
4413 (SHRNv8i8_shift V128:$Rn, vecshiftR16Narrow:$imm)>;
4414 def : Pat<(v4i16 (trunc (AArch64vlshr (v4i32 V128:$Rn), vecshiftR32Narrow:$imm))),
4415 (SHRNv4i16_shift V128:$Rn, vecshiftR32Narrow:$imm)>;
4416 def : Pat<(v2i32 (trunc (AArch64vlshr (v2i64 V128:$Rn), vecshiftR64Narrow:$imm))),
4417 (SHRNv2i32_shift V128:$Rn, vecshiftR64Narrow:$imm)>;
4419 def : Pat<(v16i8 (concat_vectors (v8i8 V64:$Rd),
4420 (trunc (AArch64vlshr (v8i16 V128:$Rn),
4421 vecshiftR16Narrow:$imm)))),
4422 (SHRNv16i8_shift (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
4423 V128:$Rn, vecshiftR16Narrow:$imm)>;
4424 def : Pat<(v8i16 (concat_vectors (v4i16 V64:$Rd),
4425 (trunc (AArch64vlshr (v4i32 V128:$Rn),
4426 vecshiftR32Narrow:$imm)))),
4427 (SHRNv8i16_shift (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
4428 V128:$Rn, vecshiftR32Narrow:$imm)>;
4429 def : Pat<(v4i32 (concat_vectors (v2i32 V64:$Rd),
4430 (trunc (AArch64vlshr (v2i64 V128:$Rn),
4431 vecshiftR64Narrow:$imm)))),
4432 (SHRNv4i32_shift (INSERT_SUBREG (IMPLICIT_DEF), V64:$Rd, dsub),
4433 V128:$Rn, vecshiftR32Narrow:$imm)>;
4435 // Vector sign and zero extensions are implemented with SSHLL and USSHLL.
4436 // Anyexts are implemented as zexts.
4437 def : Pat<(v8i16 (sext (v8i8 V64:$Rn))), (SSHLLv8i8_shift V64:$Rn, (i32 0))>;
4438 def : Pat<(v8i16 (zext (v8i8 V64:$Rn))), (USHLLv8i8_shift V64:$Rn, (i32 0))>;
4439 def : Pat<(v8i16 (anyext (v8i8 V64:$Rn))), (USHLLv8i8_shift V64:$Rn, (i32 0))>;
4440 def : Pat<(v4i32 (sext (v4i16 V64:$Rn))), (SSHLLv4i16_shift V64:$Rn, (i32 0))>;
4441 def : Pat<(v4i32 (zext (v4i16 V64:$Rn))), (USHLLv4i16_shift V64:$Rn, (i32 0))>;
4442 def : Pat<(v4i32 (anyext (v4i16 V64:$Rn))), (USHLLv4i16_shift V64:$Rn, (i32 0))>;
4443 def : Pat<(v2i64 (sext (v2i32 V64:$Rn))), (SSHLLv2i32_shift V64:$Rn, (i32 0))>;
4444 def : Pat<(v2i64 (zext (v2i32 V64:$Rn))), (USHLLv2i32_shift V64:$Rn, (i32 0))>;
4445 def : Pat<(v2i64 (anyext (v2i32 V64:$Rn))), (USHLLv2i32_shift V64:$Rn, (i32 0))>;
4446 // Also match an extend from the upper half of a 128 bit source register.
4447 def : Pat<(v8i16 (anyext (v8i8 (extract_subvector V128:$Rn, (i64 8)) ))),
4448 (USHLLv16i8_shift V128:$Rn, (i32 0))>;
4449 def : Pat<(v8i16 (zext (v8i8 (extract_subvector V128:$Rn, (i64 8)) ))),
4450 (USHLLv16i8_shift V128:$Rn, (i32 0))>;
4451 def : Pat<(v8i16 (sext (v8i8 (extract_subvector V128:$Rn, (i64 8)) ))),
4452 (SSHLLv16i8_shift V128:$Rn, (i32 0))>;
4453 def : Pat<(v4i32 (anyext (v4i16 (extract_subvector V128:$Rn, (i64 4)) ))),
4454 (USHLLv8i16_shift V128:$Rn, (i32 0))>;
4455 def : Pat<(v4i32 (zext (v4i16 (extract_subvector V128:$Rn, (i64 4)) ))),
4456 (USHLLv8i16_shift V128:$Rn, (i32 0))>;
4457 def : Pat<(v4i32 (sext (v4i16 (extract_subvector V128:$Rn, (i64 4)) ))),
4458 (SSHLLv8i16_shift V128:$Rn, (i32 0))>;
4459 def : Pat<(v2i64 (anyext (v2i32 (extract_subvector V128:$Rn, (i64 2)) ))),
4460 (USHLLv4i32_shift V128:$Rn, (i32 0))>;
4461 def : Pat<(v2i64 (zext (v2i32 (extract_subvector V128:$Rn, (i64 2)) ))),
4462 (USHLLv4i32_shift V128:$Rn, (i32 0))>;
4463 def : Pat<(v2i64 (sext (v2i32 (extract_subvector V128:$Rn, (i64 2)) ))),
4464 (SSHLLv4i32_shift V128:$Rn, (i32 0))>;
4466 // Vector shift sxtl aliases
4467 def : InstAlias<"sxtl.8h $dst, $src1",
4468 (SSHLLv8i8_shift V128:$dst, V64:$src1, 0)>;
4469 def : InstAlias<"sxtl $dst.8h, $src1.8b",
4470 (SSHLLv8i8_shift V128:$dst, V64:$src1, 0)>;
4471 def : InstAlias<"sxtl.4s $dst, $src1",
4472 (SSHLLv4i16_shift V128:$dst, V64:$src1, 0)>;
4473 def : InstAlias<"sxtl $dst.4s, $src1.4h",
4474 (SSHLLv4i16_shift V128:$dst, V64:$src1, 0)>;
4475 def : InstAlias<"sxtl.2d $dst, $src1",
4476 (SSHLLv2i32_shift V128:$dst, V64:$src1, 0)>;
4477 def : InstAlias<"sxtl $dst.2d, $src1.2s",
4478 (SSHLLv2i32_shift V128:$dst, V64:$src1, 0)>;
4480 // Vector shift sxtl2 aliases
4481 def : InstAlias<"sxtl2.8h $dst, $src1",
4482 (SSHLLv16i8_shift V128:$dst, V128:$src1, 0)>;
4483 def : InstAlias<"sxtl2 $dst.8h, $src1.16b",
4484 (SSHLLv16i8_shift V128:$dst, V128:$src1, 0)>;
4485 def : InstAlias<"sxtl2.4s $dst, $src1",
4486 (SSHLLv8i16_shift V128:$dst, V128:$src1, 0)>;
4487 def : InstAlias<"sxtl2 $dst.4s, $src1.8h",
4488 (SSHLLv8i16_shift V128:$dst, V128:$src1, 0)>;
4489 def : InstAlias<"sxtl2.2d $dst, $src1",
4490 (SSHLLv4i32_shift V128:$dst, V128:$src1, 0)>;
4491 def : InstAlias<"sxtl2 $dst.2d, $src1.4s",
4492 (SSHLLv4i32_shift V128:$dst, V128:$src1, 0)>;
4494 // Vector shift uxtl aliases
4495 def : InstAlias<"uxtl.8h $dst, $src1",
4496 (USHLLv8i8_shift V128:$dst, V64:$src1, 0)>;
4497 def : InstAlias<"uxtl $dst.8h, $src1.8b",
4498 (USHLLv8i8_shift V128:$dst, V64:$src1, 0)>;
4499 def : InstAlias<"uxtl.4s $dst, $src1",
4500 (USHLLv4i16_shift V128:$dst, V64:$src1, 0)>;
4501 def : InstAlias<"uxtl $dst.4s, $src1.4h",
4502 (USHLLv4i16_shift V128:$dst, V64:$src1, 0)>;
4503 def : InstAlias<"uxtl.2d $dst, $src1",
4504 (USHLLv2i32_shift V128:$dst, V64:$src1, 0)>;
4505 def : InstAlias<"uxtl $dst.2d, $src1.2s",
4506 (USHLLv2i32_shift V128:$dst, V64:$src1, 0)>;
4508 // Vector shift uxtl2 aliases
4509 def : InstAlias<"uxtl2.8h $dst, $src1",
4510 (USHLLv16i8_shift V128:$dst, V128:$src1, 0)>;
4511 def : InstAlias<"uxtl2 $dst.8h, $src1.16b",
4512 (USHLLv16i8_shift V128:$dst, V128:$src1, 0)>;
4513 def : InstAlias<"uxtl2.4s $dst, $src1",
4514 (USHLLv8i16_shift V128:$dst, V128:$src1, 0)>;
4515 def : InstAlias<"uxtl2 $dst.4s, $src1.8h",
4516 (USHLLv8i16_shift V128:$dst, V128:$src1, 0)>;
4517 def : InstAlias<"uxtl2.2d $dst, $src1",
4518 (USHLLv4i32_shift V128:$dst, V128:$src1, 0)>;
4519 def : InstAlias<"uxtl2 $dst.2d, $src1.4s",
4520 (USHLLv4i32_shift V128:$dst, V128:$src1, 0)>;
4522 // If an integer is about to be converted to a floating point value,
4523 // just load it on the floating point unit.
4524 // These patterns are more complex because floating point loads do not
4525 // support sign extension.
4526 // The sign extension has to be explicitly added and is only supported for
4527 // one step: byte-to-half, half-to-word, word-to-doubleword.
4528 // SCVTF GPR -> FPR is 9 cycles.
4529 // SCVTF FPR -> FPR is 4 cyclces.
4530 // (sign extension with lengthen) SXTL FPR -> FPR is 2 cycles.
4531 // Therefore, we can do 2 sign extensions and one SCVTF FPR -> FPR
4532 // and still being faster.
4533 // However, this is not good for code size.
4534 // 8-bits -> float. 2 sizes step-up.
4535 class SExtLoadi8CVTf32Pat<dag addrmode, dag INST>
4536 : Pat<(f32 (sint_to_fp (i32 (sextloadi8 addrmode)))),
4537 (SCVTFv1i32 (f32 (EXTRACT_SUBREG
4542 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4548 ssub)))>, Requires<[NotForCodeSize, IsCyclone]>;
4550 def : SExtLoadi8CVTf32Pat<(ro8.Wpat GPR64sp:$Rn, GPR32:$Rm, ro8.Wext:$ext),
4551 (LDRBroW GPR64sp:$Rn, GPR32:$Rm, ro8.Wext:$ext)>;
4552 def : SExtLoadi8CVTf32Pat<(ro8.Xpat GPR64sp:$Rn, GPR64:$Rm, ro8.Xext:$ext),
4553 (LDRBroX GPR64sp:$Rn, GPR64:$Rm, ro8.Xext:$ext)>;
4554 def : SExtLoadi8CVTf32Pat<(am_indexed8 GPR64sp:$Rn, uimm12s1:$offset),
4555 (LDRBui GPR64sp:$Rn, uimm12s1:$offset)>;
4556 def : SExtLoadi8CVTf32Pat<(am_unscaled8 GPR64sp:$Rn, simm9:$offset),
4557 (LDURBi GPR64sp:$Rn, simm9:$offset)>;
4559 // 16-bits -> float. 1 size step-up.
4560 class SExtLoadi16CVTf32Pat<dag addrmode, dag INST>
4561 : Pat<(f32 (sint_to_fp (i32 (sextloadi16 addrmode)))),
4562 (SCVTFv1i32 (f32 (EXTRACT_SUBREG
4564 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4568 ssub)))>, Requires<[NotForCodeSize]>;
4570 def : SExtLoadi16CVTf32Pat<(ro16.Wpat GPR64sp:$Rn, GPR32:$Rm, ro16.Wext:$ext),
4571 (LDRHroW GPR64sp:$Rn, GPR32:$Rm, ro16.Wext:$ext)>;
4572 def : SExtLoadi16CVTf32Pat<(ro16.Xpat GPR64sp:$Rn, GPR64:$Rm, ro16.Xext:$ext),
4573 (LDRHroX GPR64sp:$Rn, GPR64:$Rm, ro16.Xext:$ext)>;
4574 def : SExtLoadi16CVTf32Pat<(am_indexed16 GPR64sp:$Rn, uimm12s2:$offset),
4575 (LDRHui GPR64sp:$Rn, uimm12s2:$offset)>;
4576 def : SExtLoadi16CVTf32Pat<(am_unscaled16 GPR64sp:$Rn, simm9:$offset),
4577 (LDURHi GPR64sp:$Rn, simm9:$offset)>;
4579 // 32-bits to 32-bits are handled in target specific dag combine:
4580 // performIntToFpCombine.
4581 // 64-bits integer to 32-bits floating point, not possible with
4582 // SCVTF on floating point registers (both source and destination
4583 // must have the same size).
4585 // Here are the patterns for 8, 16, 32, and 64-bits to double.
4586 // 8-bits -> double. 3 size step-up: give up.
4587 // 16-bits -> double. 2 size step.
4588 class SExtLoadi16CVTf64Pat<dag addrmode, dag INST>
4589 : Pat <(f64 (sint_to_fp (i32 (sextloadi16 addrmode)))),
4590 (SCVTFv1i64 (f64 (EXTRACT_SUBREG
4595 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4601 dsub)))>, Requires<[NotForCodeSize, IsCyclone]>;
4603 def : SExtLoadi16CVTf64Pat<(ro16.Wpat GPR64sp:$Rn, GPR32:$Rm, ro16.Wext:$ext),
4604 (LDRHroW GPR64sp:$Rn, GPR32:$Rm, ro16.Wext:$ext)>;
4605 def : SExtLoadi16CVTf64Pat<(ro16.Xpat GPR64sp:$Rn, GPR64:$Rm, ro16.Xext:$ext),
4606 (LDRHroX GPR64sp:$Rn, GPR64:$Rm, ro16.Xext:$ext)>;
4607 def : SExtLoadi16CVTf64Pat<(am_indexed16 GPR64sp:$Rn, uimm12s2:$offset),
4608 (LDRHui GPR64sp:$Rn, uimm12s2:$offset)>;
4609 def : SExtLoadi16CVTf64Pat<(am_unscaled16 GPR64sp:$Rn, simm9:$offset),
4610 (LDURHi GPR64sp:$Rn, simm9:$offset)>;
4611 // 32-bits -> double. 1 size step-up.
4612 class SExtLoadi32CVTf64Pat<dag addrmode, dag INST>
4613 : Pat <(f64 (sint_to_fp (i32 (load addrmode)))),
4614 (SCVTFv1i64 (f64 (EXTRACT_SUBREG
4616 (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
4620 dsub)))>, Requires<[NotForCodeSize]>;
4622 def : SExtLoadi32CVTf64Pat<(ro32.Wpat GPR64sp:$Rn, GPR32:$Rm, ro32.Wext:$ext),
4623 (LDRSroW GPR64sp:$Rn, GPR32:$Rm, ro32.Wext:$ext)>;
4624 def : SExtLoadi32CVTf64Pat<(ro32.Xpat GPR64sp:$Rn, GPR64:$Rm, ro32.Xext:$ext),
4625 (LDRSroX GPR64sp:$Rn, GPR64:$Rm, ro32.Xext:$ext)>;
4626 def : SExtLoadi32CVTf64Pat<(am_indexed32 GPR64sp:$Rn, uimm12s4:$offset),
4627 (LDRSui GPR64sp:$Rn, uimm12s4:$offset)>;
4628 def : SExtLoadi32CVTf64Pat<(am_unscaled32 GPR64sp:$Rn, simm9:$offset),
4629 (LDURSi GPR64sp:$Rn, simm9:$offset)>;
4631 // 64-bits -> double are handled in target specific dag combine:
4632 // performIntToFpCombine.
4635 //----------------------------------------------------------------------------
4636 // AdvSIMD Load-Store Structure
4637 //----------------------------------------------------------------------------
4638 defm LD1 : SIMDLd1Multiple<"ld1">;
4639 defm LD2 : SIMDLd2Multiple<"ld2">;
4640 defm LD3 : SIMDLd3Multiple<"ld3">;
4641 defm LD4 : SIMDLd4Multiple<"ld4">;
4643 defm ST1 : SIMDSt1Multiple<"st1">;
4644 defm ST2 : SIMDSt2Multiple<"st2">;
4645 defm ST3 : SIMDSt3Multiple<"st3">;
4646 defm ST4 : SIMDSt4Multiple<"st4">;
4648 class Ld1Pat<ValueType ty, Instruction INST>
4649 : Pat<(ty (load GPR64sp:$Rn)), (INST GPR64sp:$Rn)>;
4651 def : Ld1Pat<v16i8, LD1Onev16b>;
4652 def : Ld1Pat<v8i16, LD1Onev8h>;
4653 def : Ld1Pat<v4i32, LD1Onev4s>;
4654 def : Ld1Pat<v2i64, LD1Onev2d>;
4655 def : Ld1Pat<v8i8, LD1Onev8b>;
4656 def : Ld1Pat<v4i16, LD1Onev4h>;
4657 def : Ld1Pat<v2i32, LD1Onev2s>;
4658 def : Ld1Pat<v1i64, LD1Onev1d>;
4660 class St1Pat<ValueType ty, Instruction INST>
4661 : Pat<(store ty:$Vt, GPR64sp:$Rn),
4662 (INST ty:$Vt, GPR64sp:$Rn)>;
4664 def : St1Pat<v16i8, ST1Onev16b>;
4665 def : St1Pat<v8i16, ST1Onev8h>;
4666 def : St1Pat<v4i32, ST1Onev4s>;
4667 def : St1Pat<v2i64, ST1Onev2d>;
4668 def : St1Pat<v8i8, ST1Onev8b>;
4669 def : St1Pat<v4i16, ST1Onev4h>;
4670 def : St1Pat<v2i32, ST1Onev2s>;
4671 def : St1Pat<v1i64, ST1Onev1d>;
4677 defm LD1R : SIMDLdR<0, 0b110, 0, "ld1r", "One", 1, 2, 4, 8>;
4678 defm LD2R : SIMDLdR<1, 0b110, 0, "ld2r", "Two", 2, 4, 8, 16>;
4679 defm LD3R : SIMDLdR<0, 0b111, 0, "ld3r", "Three", 3, 6, 12, 24>;
4680 defm LD4R : SIMDLdR<1, 0b111, 0, "ld4r", "Four", 4, 8, 16, 32>;
4681 let mayLoad = 1, hasSideEffects = 0 in {
4682 defm LD1 : SIMDLdSingleBTied<0, 0b000, "ld1", VecListOneb, GPR64pi1>;
4683 defm LD1 : SIMDLdSingleHTied<0, 0b010, 0, "ld1", VecListOneh, GPR64pi2>;
4684 defm LD1 : SIMDLdSingleSTied<0, 0b100, 0b00, "ld1", VecListOnes, GPR64pi4>;
4685 defm LD1 : SIMDLdSingleDTied<0, 0b100, 0b01, "ld1", VecListOned, GPR64pi8>;
4686 defm LD2 : SIMDLdSingleBTied<1, 0b000, "ld2", VecListTwob, GPR64pi2>;
4687 defm LD2 : SIMDLdSingleHTied<1, 0b010, 0, "ld2", VecListTwoh, GPR64pi4>;
4688 defm LD2 : SIMDLdSingleSTied<1, 0b100, 0b00, "ld2", VecListTwos, GPR64pi8>;
4689 defm LD2 : SIMDLdSingleDTied<1, 0b100, 0b01, "ld2", VecListTwod, GPR64pi16>;
4690 defm LD3 : SIMDLdSingleBTied<0, 0b001, "ld3", VecListThreeb, GPR64pi3>;
4691 defm LD3 : SIMDLdSingleHTied<0, 0b011, 0, "ld3", VecListThreeh, GPR64pi6>;
4692 defm LD3 : SIMDLdSingleSTied<0, 0b101, 0b00, "ld3", VecListThrees, GPR64pi12>;
4693 defm LD3 : SIMDLdSingleDTied<0, 0b101, 0b01, "ld3", VecListThreed, GPR64pi24>;
4694 defm LD4 : SIMDLdSingleBTied<1, 0b001, "ld4", VecListFourb, GPR64pi4>;
4695 defm LD4 : SIMDLdSingleHTied<1, 0b011, 0, "ld4", VecListFourh, GPR64pi8>;
4696 defm LD4 : SIMDLdSingleSTied<1, 0b101, 0b00, "ld4", VecListFours, GPR64pi16>;
4697 defm LD4 : SIMDLdSingleDTied<1, 0b101, 0b01, "ld4", VecListFourd, GPR64pi32>;
4700 def : Pat<(v8i8 (AArch64dup (i32 (extloadi8 GPR64sp:$Rn)))),
4701 (LD1Rv8b GPR64sp:$Rn)>;
4702 def : Pat<(v16i8 (AArch64dup (i32 (extloadi8 GPR64sp:$Rn)))),
4703 (LD1Rv16b GPR64sp:$Rn)>;
4704 def : Pat<(v4i16 (AArch64dup (i32 (extloadi16 GPR64sp:$Rn)))),
4705 (LD1Rv4h GPR64sp:$Rn)>;
4706 def : Pat<(v8i16 (AArch64dup (i32 (extloadi16 GPR64sp:$Rn)))),
4707 (LD1Rv8h GPR64sp:$Rn)>;
4708 def : Pat<(v2i32 (AArch64dup (i32 (load GPR64sp:$Rn)))),
4709 (LD1Rv2s GPR64sp:$Rn)>;
4710 def : Pat<(v4i32 (AArch64dup (i32 (load GPR64sp:$Rn)))),
4711 (LD1Rv4s GPR64sp:$Rn)>;
4712 def : Pat<(v2i64 (AArch64dup (i64 (load GPR64sp:$Rn)))),
4713 (LD1Rv2d GPR64sp:$Rn)>;
4714 def : Pat<(v1i64 (AArch64dup (i64 (load GPR64sp:$Rn)))),
4715 (LD1Rv1d GPR64sp:$Rn)>;
4716 // Grab the floating point version too
4717 def : Pat<(v2f32 (AArch64dup (f32 (load GPR64sp:$Rn)))),
4718 (LD1Rv2s GPR64sp:$Rn)>;
4719 def : Pat<(v4f32 (AArch64dup (f32 (load GPR64sp:$Rn)))),
4720 (LD1Rv4s GPR64sp:$Rn)>;
4721 def : Pat<(v2f64 (AArch64dup (f64 (load GPR64sp:$Rn)))),
4722 (LD1Rv2d GPR64sp:$Rn)>;
4723 def : Pat<(v1f64 (AArch64dup (f64 (load GPR64sp:$Rn)))),
4724 (LD1Rv1d GPR64sp:$Rn)>;
4725 def : Pat<(v4f16 (AArch64dup (f16 (load GPR64sp:$Rn)))),
4726 (LD1Rv4h GPR64sp:$Rn)>;
4727 def : Pat<(v8f16 (AArch64dup (f16 (load GPR64sp:$Rn)))),
4728 (LD1Rv8h GPR64sp:$Rn)>;
4730 class Ld1Lane128Pat<SDPatternOperator scalar_load, Operand VecIndex,
4731 ValueType VTy, ValueType STy, Instruction LD1>
4732 : Pat<(vector_insert (VTy VecListOne128:$Rd),
4733 (STy (scalar_load GPR64sp:$Rn)), VecIndex:$idx),
4734 (LD1 VecListOne128:$Rd, VecIndex:$idx, GPR64sp:$Rn)>;
4736 def : Ld1Lane128Pat<extloadi8, VectorIndexB, v16i8, i32, LD1i8>;
4737 def : Ld1Lane128Pat<extloadi16, VectorIndexH, v8i16, i32, LD1i16>;
4738 def : Ld1Lane128Pat<load, VectorIndexS, v4i32, i32, LD1i32>;
4739 def : Ld1Lane128Pat<load, VectorIndexS, v4f32, f32, LD1i32>;
4740 def : Ld1Lane128Pat<load, VectorIndexD, v2i64, i64, LD1i64>;
4741 def : Ld1Lane128Pat<load, VectorIndexD, v2f64, f64, LD1i64>;
4742 def : Ld1Lane128Pat<load, VectorIndexH, v8f16, f16, LD1i16>;
4744 class Ld1Lane64Pat<SDPatternOperator scalar_load, Operand VecIndex,
4745 ValueType VTy, ValueType STy, Instruction LD1>
4746 : Pat<(vector_insert (VTy VecListOne64:$Rd),
4747 (STy (scalar_load GPR64sp:$Rn)), VecIndex:$idx),
4749 (LD1 (SUBREG_TO_REG (i32 0), VecListOne64:$Rd, dsub),
4750 VecIndex:$idx, GPR64sp:$Rn),
4753 def : Ld1Lane64Pat<extloadi8, VectorIndexB, v8i8, i32, LD1i8>;
4754 def : Ld1Lane64Pat<extloadi16, VectorIndexH, v4i16, i32, LD1i16>;
4755 def : Ld1Lane64Pat<load, VectorIndexS, v2i32, i32, LD1i32>;
4756 def : Ld1Lane64Pat<load, VectorIndexS, v2f32, f32, LD1i32>;
4757 def : Ld1Lane64Pat<load, VectorIndexH, v4f16, f16, LD1i16>;
4760 defm LD1 : SIMDLdSt1SingleAliases<"ld1">;
4761 defm LD2 : SIMDLdSt2SingleAliases<"ld2">;
4762 defm LD3 : SIMDLdSt3SingleAliases<"ld3">;
4763 defm LD4 : SIMDLdSt4SingleAliases<"ld4">;
4766 defm ST1 : SIMDStSingleB<0, 0b000, "st1", VecListOneb, GPR64pi1>;
4767 defm ST1 : SIMDStSingleH<0, 0b010, 0, "st1", VecListOneh, GPR64pi2>;
4768 defm ST1 : SIMDStSingleS<0, 0b100, 0b00, "st1", VecListOnes, GPR64pi4>;
4769 defm ST1 : SIMDStSingleD<0, 0b100, 0b01, "st1", VecListOned, GPR64pi8>;
4771 let AddedComplexity = 15 in
4772 class St1Lane128Pat<SDPatternOperator scalar_store, Operand VecIndex,
4773 ValueType VTy, ValueType STy, Instruction ST1>
4775 (STy (vector_extract (VTy VecListOne128:$Vt), VecIndex:$idx)),
4777 (ST1 VecListOne128:$Vt, VecIndex:$idx, GPR64sp:$Rn)>;
4779 def : St1Lane128Pat<truncstorei8, VectorIndexB, v16i8, i32, ST1i8>;
4780 def : St1Lane128Pat<truncstorei16, VectorIndexH, v8i16, i32, ST1i16>;
4781 def : St1Lane128Pat<store, VectorIndexS, v4i32, i32, ST1i32>;
4782 def : St1Lane128Pat<store, VectorIndexS, v4f32, f32, ST1i32>;
4783 def : St1Lane128Pat<store, VectorIndexD, v2i64, i64, ST1i64>;
4784 def : St1Lane128Pat<store, VectorIndexD, v2f64, f64, ST1i64>;
4785 def : St1Lane128Pat<store, VectorIndexH, v8f16, f16, ST1i16>;
4787 let AddedComplexity = 15 in
4788 class St1Lane64Pat<SDPatternOperator scalar_store, Operand VecIndex,
4789 ValueType VTy, ValueType STy, Instruction ST1>
4791 (STy (vector_extract (VTy VecListOne64:$Vt), VecIndex:$idx)),
4793 (ST1 (SUBREG_TO_REG (i32 0), VecListOne64:$Vt, dsub),
4794 VecIndex:$idx, GPR64sp:$Rn)>;
4796 def : St1Lane64Pat<truncstorei8, VectorIndexB, v8i8, i32, ST1i8>;
4797 def : St1Lane64Pat<truncstorei16, VectorIndexH, v4i16, i32, ST1i16>;
4798 def : St1Lane64Pat<store, VectorIndexS, v2i32, i32, ST1i32>;
4799 def : St1Lane64Pat<store, VectorIndexS, v2f32, f32, ST1i32>;
4800 def : St1Lane64Pat<store, VectorIndexH, v4f16, f16, ST1i16>;
4802 multiclass St1LanePost64Pat<SDPatternOperator scalar_store, Operand VecIndex,
4803 ValueType VTy, ValueType STy, Instruction ST1,
4805 def : Pat<(scalar_store
4806 (STy (vector_extract (VTy VecListOne64:$Vt), VecIndex:$idx)),
4807 GPR64sp:$Rn, offset),
4808 (ST1 (SUBREG_TO_REG (i32 0), VecListOne64:$Vt, dsub),
4809 VecIndex:$idx, GPR64sp:$Rn, XZR)>;
4811 def : Pat<(scalar_store
4812 (STy (vector_extract (VTy VecListOne64:$Vt), VecIndex:$idx)),
4813 GPR64sp:$Rn, GPR64:$Rm),
4814 (ST1 (SUBREG_TO_REG (i32 0), VecListOne64:$Vt, dsub),
4815 VecIndex:$idx, GPR64sp:$Rn, $Rm)>;
4818 defm : St1LanePost64Pat<post_truncsti8, VectorIndexB, v8i8, i32, ST1i8_POST, 1>;
4819 defm : St1LanePost64Pat<post_truncsti16, VectorIndexH, v4i16, i32, ST1i16_POST,
4821 defm : St1LanePost64Pat<post_store, VectorIndexS, v2i32, i32, ST1i32_POST, 4>;
4822 defm : St1LanePost64Pat<post_store, VectorIndexS, v2f32, f32, ST1i32_POST, 4>;
4823 defm : St1LanePost64Pat<post_store, VectorIndexD, v1i64, i64, ST1i64_POST, 8>;
4824 defm : St1LanePost64Pat<post_store, VectorIndexD, v1f64, f64, ST1i64_POST, 8>;
4825 defm : St1LanePost64Pat<post_store, VectorIndexH, v4f16, f16, ST1i16_POST, 2>;
4827 multiclass St1LanePost128Pat<SDPatternOperator scalar_store, Operand VecIndex,
4828 ValueType VTy, ValueType STy, Instruction ST1,
4830 def : Pat<(scalar_store
4831 (STy (vector_extract (VTy VecListOne128:$Vt), VecIndex:$idx)),
4832 GPR64sp:$Rn, offset),
4833 (ST1 VecListOne128:$Vt, VecIndex:$idx, GPR64sp:$Rn, XZR)>;
4835 def : Pat<(scalar_store
4836 (STy (vector_extract (VTy VecListOne128:$Vt), VecIndex:$idx)),
4837 GPR64sp:$Rn, GPR64:$Rm),
4838 (ST1 VecListOne128:$Vt, VecIndex:$idx, GPR64sp:$Rn, $Rm)>;
4841 defm : St1LanePost128Pat<post_truncsti8, VectorIndexB, v16i8, i32, ST1i8_POST,
4843 defm : St1LanePost128Pat<post_truncsti16, VectorIndexH, v8i16, i32, ST1i16_POST,
4845 defm : St1LanePost128Pat<post_store, VectorIndexS, v4i32, i32, ST1i32_POST, 4>;
4846 defm : St1LanePost128Pat<post_store, VectorIndexS, v4f32, f32, ST1i32_POST, 4>;
4847 defm : St1LanePost128Pat<post_store, VectorIndexD, v2i64, i64, ST1i64_POST, 8>;
4848 defm : St1LanePost128Pat<post_store, VectorIndexD, v2f64, f64, ST1i64_POST, 8>;
4849 defm : St1LanePost128Pat<post_store, VectorIndexH, v8f16, f16, ST1i16_POST, 2>;
4851 let mayStore = 1, hasSideEffects = 0 in {
4852 defm ST2 : SIMDStSingleB<1, 0b000, "st2", VecListTwob, GPR64pi2>;
4853 defm ST2 : SIMDStSingleH<1, 0b010, 0, "st2", VecListTwoh, GPR64pi4>;
4854 defm ST2 : SIMDStSingleS<1, 0b100, 0b00, "st2", VecListTwos, GPR64pi8>;
4855 defm ST2 : SIMDStSingleD<1, 0b100, 0b01, "st2", VecListTwod, GPR64pi16>;
4856 defm ST3 : SIMDStSingleB<0, 0b001, "st3", VecListThreeb, GPR64pi3>;
4857 defm ST3 : SIMDStSingleH<0, 0b011, 0, "st3", VecListThreeh, GPR64pi6>;
4858 defm ST3 : SIMDStSingleS<0, 0b101, 0b00, "st3", VecListThrees, GPR64pi12>;
4859 defm ST3 : SIMDStSingleD<0, 0b101, 0b01, "st3", VecListThreed, GPR64pi24>;
4860 defm ST4 : SIMDStSingleB<1, 0b001, "st4", VecListFourb, GPR64pi4>;
4861 defm ST4 : SIMDStSingleH<1, 0b011, 0, "st4", VecListFourh, GPR64pi8>;
4862 defm ST4 : SIMDStSingleS<1, 0b101, 0b00, "st4", VecListFours, GPR64pi16>;
4863 defm ST4 : SIMDStSingleD<1, 0b101, 0b01, "st4", VecListFourd, GPR64pi32>;
4866 defm ST1 : SIMDLdSt1SingleAliases<"st1">;
4867 defm ST2 : SIMDLdSt2SingleAliases<"st2">;
4868 defm ST3 : SIMDLdSt3SingleAliases<"st3">;
4869 defm ST4 : SIMDLdSt4SingleAliases<"st4">;
4871 //----------------------------------------------------------------------------
4872 // Crypto extensions
4873 //----------------------------------------------------------------------------
4875 def AESErr : AESTiedInst<0b0100, "aese", int_aarch64_crypto_aese>;
4876 def AESDrr : AESTiedInst<0b0101, "aesd", int_aarch64_crypto_aesd>;
4877 def AESMCrr : AESInst< 0b0110, "aesmc", int_aarch64_crypto_aesmc>;
4878 def AESIMCrr : AESInst< 0b0111, "aesimc", int_aarch64_crypto_aesimc>;
4880 def SHA1Crrr : SHATiedInstQSV<0b000, "sha1c", int_aarch64_crypto_sha1c>;
4881 def SHA1Prrr : SHATiedInstQSV<0b001, "sha1p", int_aarch64_crypto_sha1p>;
4882 def SHA1Mrrr : SHATiedInstQSV<0b010, "sha1m", int_aarch64_crypto_sha1m>;
4883 def SHA1SU0rrr : SHATiedInstVVV<0b011, "sha1su0", int_aarch64_crypto_sha1su0>;
4884 def SHA256Hrrr : SHATiedInstQQV<0b100, "sha256h", int_aarch64_crypto_sha256h>;
4885 def SHA256H2rrr : SHATiedInstQQV<0b101, "sha256h2",int_aarch64_crypto_sha256h2>;
4886 def SHA256SU1rrr :SHATiedInstVVV<0b110, "sha256su1",int_aarch64_crypto_sha256su1>;
4888 def SHA1Hrr : SHAInstSS< 0b0000, "sha1h", int_aarch64_crypto_sha1h>;
4889 def SHA1SU1rr : SHATiedInstVV<0b0001, "sha1su1", int_aarch64_crypto_sha1su1>;
4890 def SHA256SU0rr : SHATiedInstVV<0b0010, "sha256su0",int_aarch64_crypto_sha256su0>;
4892 //----------------------------------------------------------------------------
4894 //----------------------------------------------------------------------------
4895 // FIXME: Like for X86, these should go in their own separate .td file.
4897 // Any instruction that defines a 32-bit result leaves the high half of the
4898 // register. Truncate can be lowered to EXTRACT_SUBREG. CopyFromReg may
4899 // be copying from a truncate. But any other 32-bit operation will zero-extend
4901 // FIXME: X86 also checks for CMOV here. Do we need something similar?
4902 def def32 : PatLeaf<(i32 GPR32:$src), [{
4903 return N->getOpcode() != ISD::TRUNCATE &&
4904 N->getOpcode() != TargetOpcode::EXTRACT_SUBREG &&
4905 N->getOpcode() != ISD::CopyFromReg;
4908 // In the case of a 32-bit def that is known to implicitly zero-extend,
4909 // we can use a SUBREG_TO_REG.
4910 def : Pat<(i64 (zext def32:$src)), (SUBREG_TO_REG (i64 0), GPR32:$src, sub_32)>;
4912 // For an anyext, we don't care what the high bits are, so we can perform an
4913 // INSERT_SUBREF into an IMPLICIT_DEF.
4914 def : Pat<(i64 (anyext GPR32:$src)),
4915 (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GPR32:$src, sub_32)>;
4917 // When we need to explicitly zero-extend, we use an unsigned bitfield move
4918 // instruction (UBFM) on the enclosing super-reg.
4919 def : Pat<(i64 (zext GPR32:$src)),
4920 (UBFMXri (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GPR32:$src, sub_32), 0, 31)>;
4922 // To sign extend, we use a signed bitfield move instruction (SBFM) on the
4923 // containing super-reg.
4924 def : Pat<(i64 (sext GPR32:$src)),
4925 (SBFMXri (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GPR32:$src, sub_32), 0, 31)>;
4926 def : Pat<(i64 (sext_inreg GPR64:$src, i32)), (SBFMXri GPR64:$src, 0, 31)>;
4927 def : Pat<(i64 (sext_inreg GPR64:$src, i16)), (SBFMXri GPR64:$src, 0, 15)>;
4928 def : Pat<(i64 (sext_inreg GPR64:$src, i8)), (SBFMXri GPR64:$src, 0, 7)>;
4929 def : Pat<(i64 (sext_inreg GPR64:$src, i1)), (SBFMXri GPR64:$src, 0, 0)>;
4930 def : Pat<(i32 (sext_inreg GPR32:$src, i16)), (SBFMWri GPR32:$src, 0, 15)>;
4931 def : Pat<(i32 (sext_inreg GPR32:$src, i8)), (SBFMWri GPR32:$src, 0, 7)>;
4932 def : Pat<(i32 (sext_inreg GPR32:$src, i1)), (SBFMWri GPR32:$src, 0, 0)>;
4934 def : Pat<(shl (sext_inreg GPR32:$Rn, i8), (i64 imm0_31:$imm)),
4935 (SBFMWri GPR32:$Rn, (i64 (i32shift_a imm0_31:$imm)),
4936 (i64 (i32shift_sext_i8 imm0_31:$imm)))>;
4937 def : Pat<(shl (sext_inreg GPR64:$Rn, i8), (i64 imm0_63:$imm)),
4938 (SBFMXri GPR64:$Rn, (i64 (i64shift_a imm0_63:$imm)),
4939 (i64 (i64shift_sext_i8 imm0_63:$imm)))>;
4941 def : Pat<(shl (sext_inreg GPR32:$Rn, i16), (i64 imm0_31:$imm)),
4942 (SBFMWri GPR32:$Rn, (i64 (i32shift_a imm0_31:$imm)),
4943 (i64 (i32shift_sext_i16 imm0_31:$imm)))>;
4944 def : Pat<(shl (sext_inreg GPR64:$Rn, i16), (i64 imm0_63:$imm)),
4945 (SBFMXri GPR64:$Rn, (i64 (i64shift_a imm0_63:$imm)),
4946 (i64 (i64shift_sext_i16 imm0_63:$imm)))>;
4948 def : Pat<(shl (i64 (sext GPR32:$Rn)), (i64 imm0_63:$imm)),
4949 (SBFMXri (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GPR32:$Rn, sub_32),
4950 (i64 (i64shift_a imm0_63:$imm)),
4951 (i64 (i64shift_sext_i32 imm0_63:$imm)))>;
4953 // sra patterns have an AddedComplexity of 10, so make sure we have a higher
4954 // AddedComplexity for the following patterns since we want to match sext + sra
4955 // patterns before we attempt to match a single sra node.
4956 let AddedComplexity = 20 in {
4957 // We support all sext + sra combinations which preserve at least one bit of the
4958 // original value which is to be sign extended. E.g. we support shifts up to
4960 def : Pat<(sra (sext_inreg GPR32:$Rn, i8), (i64 imm0_7:$imm)),
4961 (SBFMWri GPR32:$Rn, (i64 imm0_7:$imm), 7)>;
4962 def : Pat<(sra (sext_inreg GPR64:$Rn, i8), (i64 imm0_7:$imm)),
4963 (SBFMXri GPR64:$Rn, (i64 imm0_7:$imm), 7)>;
4965 def : Pat<(sra (sext_inreg GPR32:$Rn, i16), (i64 imm0_15:$imm)),
4966 (SBFMWri GPR32:$Rn, (i64 imm0_15:$imm), 15)>;
4967 def : Pat<(sra (sext_inreg GPR64:$Rn, i16), (i64 imm0_15:$imm)),
4968 (SBFMXri GPR64:$Rn, (i64 imm0_15:$imm), 15)>;
4970 def : Pat<(sra (i64 (sext GPR32:$Rn)), (i64 imm0_31:$imm)),
4971 (SBFMXri (INSERT_SUBREG (i64 (IMPLICIT_DEF)), GPR32:$Rn, sub_32),
4972 (i64 imm0_31:$imm), 31)>;
4973 } // AddedComplexity = 20
4975 // To truncate, we can simply extract from a subregister.
4976 def : Pat<(i32 (trunc GPR64sp:$src)),
4977 (i32 (EXTRACT_SUBREG GPR64sp:$src, sub_32))>;
4979 // __builtin_trap() uses the BRK instruction on AArch64.
4980 def : Pat<(trap), (BRK 1)>;
4982 // Conversions within AdvSIMD types in the same register size are free.
4983 // But because we need a consistent lane ordering, in big endian many
4984 // conversions require one or more REV instructions.
4986 // Consider a simple memory load followed by a bitconvert then a store.
4988 // v1 = BITCAST v2i32 v0 to v4i16
4991 // In big endian mode every memory access has an implicit byte swap. LDR and
4992 // STR do a 64-bit byte swap, whereas LD1/ST1 do a byte swap per lane - that
4993 // is, they treat the vector as a sequence of elements to be byte-swapped.
4994 // The two pairs of instructions are fundamentally incompatible. We've decided
4995 // to use LD1/ST1 only to simplify compiler implementation.
4997 // LD1/ST1 perform the equivalent of a sequence of LDR/STR + REV. This makes
4998 // the original code sequence:
5000 // v1 = REV v2i32 (implicit)
5001 // v2 = BITCAST v2i32 v1 to v4i16
5002 // v3 = REV v4i16 v2 (implicit)
5005 // But this is now broken - the value stored is different to the value loaded
5006 // due to lane reordering. To fix this, on every BITCAST we must perform two
5009 // v1 = REV v2i32 (implicit)
5011 // v3 = BITCAST v2i32 v2 to v4i16
5013 // v5 = REV v4i16 v4 (implicit)
5016 // This means an extra two instructions, but actually in most cases the two REV
5017 // instructions can be combined into one. For example:
5018 // (REV64_2s (REV64_4h X)) === (REV32_4h X)
5020 // There is also no 128-bit REV instruction. This must be synthesized with an
5023 // Most bitconverts require some sort of conversion. The only exceptions are:
5024 // a) Identity conversions - vNfX <-> vNiX
5025 // b) Single-lane-to-scalar - v1fX <-> fX or v1iX <-> iX
5028 // Natural vector casts (64 bit)
5029 def : Pat<(v8i8 (AArch64NvCast (v2i32 FPR64:$src))), (v8i8 FPR64:$src)>;
5030 def : Pat<(v4i16 (AArch64NvCast (v2i32 FPR64:$src))), (v4i16 FPR64:$src)>;
5031 def : Pat<(v2i32 (AArch64NvCast (v2i32 FPR64:$src))), (v2i32 FPR64:$src)>;
5032 def : Pat<(v2f32 (AArch64NvCast (v2i32 FPR64:$src))), (v2f32 FPR64:$src)>;
5033 def : Pat<(v1i64 (AArch64NvCast (v2i32 FPR64:$src))), (v1i64 FPR64:$src)>;
5035 def : Pat<(v8i8 (AArch64NvCast (v4i16 FPR64:$src))), (v8i8 FPR64:$src)>;
5036 def : Pat<(v4i16 (AArch64NvCast (v4i16 FPR64:$src))), (v4i16 FPR64:$src)>;
5037 def : Pat<(v2i32 (AArch64NvCast (v4i16 FPR64:$src))), (v2i32 FPR64:$src)>;
5038 def : Pat<(v1i64 (AArch64NvCast (v4i16 FPR64:$src))), (v1i64 FPR64:$src)>;
5040 def : Pat<(v8i8 (AArch64NvCast (v8i8 FPR64:$src))), (v8i8 FPR64:$src)>;
5041 def : Pat<(v4i16 (AArch64NvCast (v8i8 FPR64:$src))), (v4i16 FPR64:$src)>;
5042 def : Pat<(v2i32 (AArch64NvCast (v8i8 FPR64:$src))), (v2i32 FPR64:$src)>;
5043 def : Pat<(v1i64 (AArch64NvCast (v8i8 FPR64:$src))), (v1i64 FPR64:$src)>;
5045 def : Pat<(v8i8 (AArch64NvCast (f64 FPR64:$src))), (v8i8 FPR64:$src)>;
5046 def : Pat<(v4i16 (AArch64NvCast (f64 FPR64:$src))), (v4i16 FPR64:$src)>;
5047 def : Pat<(v2i32 (AArch64NvCast (f64 FPR64:$src))), (v2i32 FPR64:$src)>;
5048 def : Pat<(v2f32 (AArch64NvCast (f64 FPR64:$src))), (v2f32 FPR64:$src)>;
5049 def : Pat<(v1i64 (AArch64NvCast (f64 FPR64:$src))), (v1i64 FPR64:$src)>;
5050 def : Pat<(v1f64 (AArch64NvCast (f64 FPR64:$src))), (v1f64 FPR64:$src)>;
5052 def : Pat<(v8i8 (AArch64NvCast (v2f32 FPR64:$src))), (v8i8 FPR64:$src)>;
5053 def : Pat<(v4i16 (AArch64NvCast (v2f32 FPR64:$src))), (v4i16 FPR64:$src)>;
5054 def : Pat<(v2i32 (AArch64NvCast (v2f32 FPR64:$src))), (v2i32 FPR64:$src)>;
5055 def : Pat<(v2f32 (AArch64NvCast (v2f32 FPR64:$src))), (v2f32 FPR64:$src)>;
5056 def : Pat<(v1i64 (AArch64NvCast (v2f32 FPR64:$src))), (v1i64 FPR64:$src)>;
5058 // Natural vector casts (128 bit)
5059 def : Pat<(v16i8 (AArch64NvCast (v4i32 FPR128:$src))), (v16i8 FPR128:$src)>;
5060 def : Pat<(v8i16 (AArch64NvCast (v4i32 FPR128:$src))), (v8i16 FPR128:$src)>;
5061 def : Pat<(v4i32 (AArch64NvCast (v4i32 FPR128:$src))), (v4i32 FPR128:$src)>;
5062 def : Pat<(v4f32 (AArch64NvCast (v4i32 FPR128:$src))), (v4f32 FPR128:$src)>;
5063 def : Pat<(v2i64 (AArch64NvCast (v4i32 FPR128:$src))), (v2i64 FPR128:$src)>;
5065 def : Pat<(v16i8 (AArch64NvCast (v8i16 FPR128:$src))), (v16i8 FPR128:$src)>;
5066 def : Pat<(v8i16 (AArch64NvCast (v8i16 FPR128:$src))), (v8i16 FPR128:$src)>;
5067 def : Pat<(v4i32 (AArch64NvCast (v8i16 FPR128:$src))), (v4i32 FPR128:$src)>;
5068 def : Pat<(v2i64 (AArch64NvCast (v8i16 FPR128:$src))), (v2i64 FPR128:$src)>;
5070 def : Pat<(v16i8 (AArch64NvCast (v16i8 FPR128:$src))), (v16i8 FPR128:$src)>;
5071 def : Pat<(v8i16 (AArch64NvCast (v16i8 FPR128:$src))), (v8i16 FPR128:$src)>;
5072 def : Pat<(v4i32 (AArch64NvCast (v16i8 FPR128:$src))), (v4i32 FPR128:$src)>;
5073 def : Pat<(v2i64 (AArch64NvCast (v16i8 FPR128:$src))), (v2i64 FPR128:$src)>;
5075 def : Pat<(v16i8 (AArch64NvCast (v2i64 FPR128:$src))), (v16i8 FPR128:$src)>;
5076 def : Pat<(v8i16 (AArch64NvCast (v2i64 FPR128:$src))), (v8i16 FPR128:$src)>;
5077 def : Pat<(v4i32 (AArch64NvCast (v2i64 FPR128:$src))), (v4i32 FPR128:$src)>;
5078 def : Pat<(v2i64 (AArch64NvCast (v2i64 FPR128:$src))), (v2i64 FPR128:$src)>;
5079 def : Pat<(v4f32 (AArch64NvCast (v2i64 FPR128:$src))), (v4f32 FPR128:$src)>;
5080 def : Pat<(v2f64 (AArch64NvCast (v2i64 FPR128:$src))), (v2f64 FPR128:$src)>;
5082 def : Pat<(v16i8 (AArch64NvCast (v4f32 FPR128:$src))), (v16i8 FPR128:$src)>;
5083 def : Pat<(v8i16 (AArch64NvCast (v4f32 FPR128:$src))), (v8i16 FPR128:$src)>;
5084 def : Pat<(v4i32 (AArch64NvCast (v4f32 FPR128:$src))), (v4i32 FPR128:$src)>;
5085 def : Pat<(v4f32 (AArch64NvCast (v4f32 FPR128:$src))), (v4f32 FPR128:$src)>;
5086 def : Pat<(v2i64 (AArch64NvCast (v4f32 FPR128:$src))), (v2i64 FPR128:$src)>;
5088 def : Pat<(v16i8 (AArch64NvCast (v2f64 FPR128:$src))), (v16i8 FPR128:$src)>;
5089 def : Pat<(v8i16 (AArch64NvCast (v2f64 FPR128:$src))), (v8i16 FPR128:$src)>;
5090 def : Pat<(v4i32 (AArch64NvCast (v2f64 FPR128:$src))), (v4i32 FPR128:$src)>;
5091 def : Pat<(v2i64 (AArch64NvCast (v2f64 FPR128:$src))), (v2i64 FPR128:$src)>;
5092 def : Pat<(v2f64 (AArch64NvCast (v2f64 FPR128:$src))), (v2f64 FPR128:$src)>;
5094 let Predicates = [IsLE] in {
5095 def : Pat<(v8i8 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
5096 def : Pat<(v4i16 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
5097 def : Pat<(v2i32 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
5098 def : Pat<(v4f16 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
5099 def : Pat<(v2f32 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
5101 def : Pat<(i64 (bitconvert (v8i8 V64:$Vn))),
5102 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
5103 def : Pat<(i64 (bitconvert (v4i16 V64:$Vn))),
5104 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
5105 def : Pat<(i64 (bitconvert (v2i32 V64:$Vn))),
5106 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
5107 def : Pat<(i64 (bitconvert (v4f16 V64:$Vn))),
5108 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
5109 def : Pat<(i64 (bitconvert (v2f32 V64:$Vn))),
5110 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
5111 def : Pat<(i64 (bitconvert (v1f64 V64:$Vn))),
5112 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
5114 let Predicates = [IsBE] in {
5115 def : Pat<(v8i8 (bitconvert GPR64:$Xn)),
5116 (REV64v8i8 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
5117 def : Pat<(v4i16 (bitconvert GPR64:$Xn)),
5118 (REV64v4i16 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
5119 def : Pat<(v2i32 (bitconvert GPR64:$Xn)),
5120 (REV64v2i32 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
5121 def : Pat<(v4f16 (bitconvert GPR64:$Xn)),
5122 (REV64v4i16 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
5123 def : Pat<(v2f32 (bitconvert GPR64:$Xn)),
5124 (REV64v2i32 (COPY_TO_REGCLASS GPR64:$Xn, FPR64))>;
5126 def : Pat<(i64 (bitconvert (v8i8 V64:$Vn))),
5127 (REV64v8i8 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
5128 def : Pat<(i64 (bitconvert (v4i16 V64:$Vn))),
5129 (REV64v4i16 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
5130 def : Pat<(i64 (bitconvert (v2i32 V64:$Vn))),
5131 (REV64v2i32 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
5132 def : Pat<(i64 (bitconvert (v4f16 V64:$Vn))),
5133 (REV64v4i16 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
5134 def : Pat<(i64 (bitconvert (v2f32 V64:$Vn))),
5135 (REV64v2i32 (COPY_TO_REGCLASS V64:$Vn, GPR64))>;
5137 def : Pat<(v1i64 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
5138 def : Pat<(v1f64 (bitconvert GPR64:$Xn)), (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
5139 def : Pat<(i64 (bitconvert (v1i64 V64:$Vn))),
5140 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
5141 def : Pat<(v1i64 (scalar_to_vector GPR64:$Xn)),
5142 (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
5143 def : Pat<(v1f64 (scalar_to_vector GPR64:$Xn)),
5144 (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
5145 def : Pat<(v1f64 (scalar_to_vector (f64 FPR64:$Xn))), (v1f64 FPR64:$Xn)>;
5147 def : Pat<(f32 (bitconvert (i32 GPR32:$Xn))),
5148 (COPY_TO_REGCLASS GPR32:$Xn, FPR32)>;
5149 def : Pat<(i32 (bitconvert (f32 FPR32:$Xn))),
5150 (COPY_TO_REGCLASS FPR32:$Xn, GPR32)>;
5151 def : Pat<(f64 (bitconvert (i64 GPR64:$Xn))),
5152 (COPY_TO_REGCLASS GPR64:$Xn, FPR64)>;
5153 def : Pat<(i64 (bitconvert (f64 FPR64:$Xn))),
5154 (COPY_TO_REGCLASS FPR64:$Xn, GPR64)>;
5155 def : Pat<(i64 (bitconvert (v1f64 V64:$Vn))),
5156 (COPY_TO_REGCLASS V64:$Vn, GPR64)>;
5158 let Predicates = [IsLE] in {
5159 def : Pat<(v1i64 (bitconvert (v2i32 FPR64:$src))), (v1i64 FPR64:$src)>;
5160 def : Pat<(v1i64 (bitconvert (v4i16 FPR64:$src))), (v1i64 FPR64:$src)>;
5161 def : Pat<(v1i64 (bitconvert (v8i8 FPR64:$src))), (v1i64 FPR64:$src)>;
5162 def : Pat<(v1i64 (bitconvert (v4f16 FPR64:$src))), (v1i64 FPR64:$src)>;
5163 def : Pat<(v1i64 (bitconvert (v2f32 FPR64:$src))), (v1i64 FPR64:$src)>;
5165 let Predicates = [IsBE] in {
5166 def : Pat<(v1i64 (bitconvert (v2i32 FPR64:$src))),
5167 (v1i64 (REV64v2i32 FPR64:$src))>;
5168 def : Pat<(v1i64 (bitconvert (v4i16 FPR64:$src))),
5169 (v1i64 (REV64v4i16 FPR64:$src))>;
5170 def : Pat<(v1i64 (bitconvert (v8i8 FPR64:$src))),
5171 (v1i64 (REV64v8i8 FPR64:$src))>;
5172 def : Pat<(v1i64 (bitconvert (v4f16 FPR64:$src))),
5173 (v1i64 (REV64v4i16 FPR64:$src))>;
5174 def : Pat<(v1i64 (bitconvert (v2f32 FPR64:$src))),
5175 (v1i64 (REV64v2i32 FPR64:$src))>;
5177 def : Pat<(v1i64 (bitconvert (v1f64 FPR64:$src))), (v1i64 FPR64:$src)>;
5178 def : Pat<(v1i64 (bitconvert (f64 FPR64:$src))), (v1i64 FPR64:$src)>;
5180 let Predicates = [IsLE] in {
5181 def : Pat<(v2i32 (bitconvert (v1i64 FPR64:$src))), (v2i32 FPR64:$src)>;
5182 def : Pat<(v2i32 (bitconvert (v4i16 FPR64:$src))), (v2i32 FPR64:$src)>;
5183 def : Pat<(v2i32 (bitconvert (v8i8 FPR64:$src))), (v2i32 FPR64:$src)>;
5184 def : Pat<(v2i32 (bitconvert (f64 FPR64:$src))), (v2i32 FPR64:$src)>;
5185 def : Pat<(v2i32 (bitconvert (v1f64 FPR64:$src))), (v2i32 FPR64:$src)>;
5186 def : Pat<(v2i32 (bitconvert (v4f16 FPR64:$src))), (v2i32 FPR64:$src)>;
5188 let Predicates = [IsBE] in {
5189 def : Pat<(v2i32 (bitconvert (v1i64 FPR64:$src))),
5190 (v2i32 (REV64v2i32 FPR64:$src))>;
5191 def : Pat<(v2i32 (bitconvert (v4i16 FPR64:$src))),
5192 (v2i32 (REV32v4i16 FPR64:$src))>;
5193 def : Pat<(v2i32 (bitconvert (v8i8 FPR64:$src))),
5194 (v2i32 (REV32v8i8 FPR64:$src))>;
5195 def : Pat<(v2i32 (bitconvert (f64 FPR64:$src))),
5196 (v2i32 (REV64v2i32 FPR64:$src))>;
5197 def : Pat<(v2i32 (bitconvert (v1f64 FPR64:$src))),
5198 (v2i32 (REV64v2i32 FPR64:$src))>;
5199 def : Pat<(v2i32 (bitconvert (v4f16 FPR64:$src))),
5200 (v2i32 (REV64v4i16 FPR64:$src))>;
5202 def : Pat<(v2i32 (bitconvert (v2f32 FPR64:$src))), (v2i32 FPR64:$src)>;
5204 let Predicates = [IsLE] in {
5205 def : Pat<(v4i16 (bitconvert (v1i64 FPR64:$src))), (v4i16 FPR64:$src)>;
5206 def : Pat<(v4i16 (bitconvert (v2i32 FPR64:$src))), (v4i16 FPR64:$src)>;
5207 def : Pat<(v4i16 (bitconvert (v8i8 FPR64:$src))), (v4i16 FPR64:$src)>;
5208 def : Pat<(v4i16 (bitconvert (f64 FPR64:$src))), (v4i16 FPR64:$src)>;
5209 def : Pat<(v4i16 (bitconvert (v4f16 FPR64:$src))), (v4i16 FPR64:$src)>;
5210 def : Pat<(v4i16 (bitconvert (v2f32 FPR64:$src))), (v4i16 FPR64:$src)>;
5211 def : Pat<(v4i16 (bitconvert (v1f64 FPR64:$src))), (v4i16 FPR64:$src)>;
5213 let Predicates = [IsBE] in {
5214 def : Pat<(v4i16 (bitconvert (v1i64 FPR64:$src))),
5215 (v4i16 (REV64v4i16 FPR64:$src))>;
5216 def : Pat<(v4i16 (bitconvert (v2i32 FPR64:$src))),
5217 (v4i16 (REV32v4i16 FPR64:$src))>;
5218 def : Pat<(v4i16 (bitconvert (v8i8 FPR64:$src))),
5219 (v4i16 (REV16v8i8 FPR64:$src))>;
5220 def : Pat<(v4i16 (bitconvert (f64 FPR64:$src))),
5221 (v4i16 (REV64v4i16 FPR64:$src))>;
5222 def : Pat<(v4i16 (bitconvert (v4f16 FPR64:$src))),
5223 (v4i16 (REV32v4i16 FPR64:$src))>;
5224 def : Pat<(v4i16 (bitconvert (v2f32 FPR64:$src))),
5225 (v4i16 (REV32v4i16 FPR64:$src))>;
5226 def : Pat<(v4i16 (bitconvert (v1f64 FPR64:$src))),
5227 (v4i16 (REV64v4i16 FPR64:$src))>;
5230 let Predicates = [IsLE] in {
5231 def : Pat<(v4f16 (bitconvert (v1i64 FPR64:$src))), (v4f16 FPR64:$src)>;
5232 def : Pat<(v4f16 (bitconvert (v2i32 FPR64:$src))), (v4f16 FPR64:$src)>;
5233 def : Pat<(v4f16 (bitconvert (v4i16 FPR64:$src))), (v4f16 FPR64:$src)>;
5234 def : Pat<(v4f16 (bitconvert (v8i8 FPR64:$src))), (v4f16 FPR64:$src)>;
5235 def : Pat<(v4f16 (bitconvert (f64 FPR64:$src))), (v4f16 FPR64:$src)>;
5236 def : Pat<(v4f16 (bitconvert (v2f32 FPR64:$src))), (v4f16 FPR64:$src)>;
5237 def : Pat<(v4f16 (bitconvert (v1f64 FPR64:$src))), (v4f16 FPR64:$src)>;
5239 let Predicates = [IsBE] in {
5240 def : Pat<(v4f16 (bitconvert (v1i64 FPR64:$src))),
5241 (v4f16 (REV64v4i16 FPR64:$src))>;
5242 def : Pat<(v4f16 (bitconvert (v2i32 FPR64:$src))),
5243 (v4f16 (REV64v4i16 FPR64:$src))>;
5244 def : Pat<(v4f16 (bitconvert (v4i16 FPR64:$src))),
5245 (v4f16 (REV64v4i16 FPR64:$src))>;
5246 def : Pat<(v4f16 (bitconvert (v8i8 FPR64:$src))),
5247 (v4f16 (REV16v8i8 FPR64:$src))>;
5248 def : Pat<(v4f16 (bitconvert (f64 FPR64:$src))),
5249 (v4f16 (REV64v4i16 FPR64:$src))>;
5250 def : Pat<(v4f16 (bitconvert (v2f32 FPR64:$src))),
5251 (v4f16 (REV64v4i16 FPR64:$src))>;
5252 def : Pat<(v4f16 (bitconvert (v1f64 FPR64:$src))),
5253 (v4f16 (REV64v4i16 FPR64:$src))>;
5258 let Predicates = [IsLE] in {
5259 def : Pat<(v8i8 (bitconvert (v1i64 FPR64:$src))), (v8i8 FPR64:$src)>;
5260 def : Pat<(v8i8 (bitconvert (v2i32 FPR64:$src))), (v8i8 FPR64:$src)>;
5261 def : Pat<(v8i8 (bitconvert (v4i16 FPR64:$src))), (v8i8 FPR64:$src)>;
5262 def : Pat<(v8i8 (bitconvert (f64 FPR64:$src))), (v8i8 FPR64:$src)>;
5263 def : Pat<(v8i8 (bitconvert (v2f32 FPR64:$src))), (v8i8 FPR64:$src)>;
5264 def : Pat<(v8i8 (bitconvert (v1f64 FPR64:$src))), (v8i8 FPR64:$src)>;
5265 def : Pat<(v8i8 (bitconvert (v4f16 FPR64:$src))), (v8i8 FPR64:$src)>;
5267 let Predicates = [IsBE] in {
5268 def : Pat<(v8i8 (bitconvert (v1i64 FPR64:$src))),
5269 (v8i8 (REV64v8i8 FPR64:$src))>;
5270 def : Pat<(v8i8 (bitconvert (v2i32 FPR64:$src))),
5271 (v8i8 (REV32v8i8 FPR64:$src))>;
5272 def : Pat<(v8i8 (bitconvert (v4i16 FPR64:$src))),
5273 (v8i8 (REV16v8i8 FPR64:$src))>;
5274 def : Pat<(v8i8 (bitconvert (f64 FPR64:$src))),
5275 (v8i8 (REV64v8i8 FPR64:$src))>;
5276 def : Pat<(v8i8 (bitconvert (v2f32 FPR64:$src))),
5277 (v8i8 (REV32v8i8 FPR64:$src))>;
5278 def : Pat<(v8i8 (bitconvert (v1f64 FPR64:$src))),
5279 (v8i8 (REV64v8i8 FPR64:$src))>;
5280 def : Pat<(v8i8 (bitconvert (v4f16 FPR64:$src))),
5281 (v8i8 (REV16v8i8 FPR64:$src))>;
5284 let Predicates = [IsLE] in {
5285 def : Pat<(f64 (bitconvert (v2i32 FPR64:$src))), (f64 FPR64:$src)>;
5286 def : Pat<(f64 (bitconvert (v4i16 FPR64:$src))), (f64 FPR64:$src)>;
5287 def : Pat<(f64 (bitconvert (v2f32 FPR64:$src))), (f64 FPR64:$src)>;
5288 def : Pat<(f64 (bitconvert (v8i8 FPR64:$src))), (f64 FPR64:$src)>;
5289 def : Pat<(f64 (bitconvert (v4f16 FPR64:$src))), (f64 FPR64:$src)>;
5291 let Predicates = [IsBE] in {
5292 def : Pat<(f64 (bitconvert (v2i32 FPR64:$src))),
5293 (f64 (REV64v2i32 FPR64:$src))>;
5294 def : Pat<(f64 (bitconvert (v4i16 FPR64:$src))),
5295 (f64 (REV64v4i16 FPR64:$src))>;
5296 def : Pat<(f64 (bitconvert (v2f32 FPR64:$src))),
5297 (f64 (REV64v2i32 FPR64:$src))>;
5298 def : Pat<(f64 (bitconvert (v8i8 FPR64:$src))),
5299 (f64 (REV64v8i8 FPR64:$src))>;
5300 def : Pat<(f64 (bitconvert (v4f16 FPR64:$src))),
5301 (f64 (REV64v4i16 FPR64:$src))>;
5303 def : Pat<(f64 (bitconvert (v1i64 FPR64:$src))), (f64 FPR64:$src)>;
5304 def : Pat<(f64 (bitconvert (v1f64 FPR64:$src))), (f64 FPR64:$src)>;
5306 let Predicates = [IsLE] in {
5307 def : Pat<(v1f64 (bitconvert (v2i32 FPR64:$src))), (v1f64 FPR64:$src)>;
5308 def : Pat<(v1f64 (bitconvert (v4i16 FPR64:$src))), (v1f64 FPR64:$src)>;
5309 def : Pat<(v1f64 (bitconvert (v8i8 FPR64:$src))), (v1f64 FPR64:$src)>;
5310 def : Pat<(v1f64 (bitconvert (v2f32 FPR64:$src))), (v1f64 FPR64:$src)>;
5311 def : Pat<(v1f64 (bitconvert (v4f16 FPR64:$src))), (v1f64 FPR64:$src)>;
5313 let Predicates = [IsBE] in {
5314 def : Pat<(v1f64 (bitconvert (v2i32 FPR64:$src))),
5315 (v1f64 (REV64v2i32 FPR64:$src))>;
5316 def : Pat<(v1f64 (bitconvert (v4i16 FPR64:$src))),
5317 (v1f64 (REV64v4i16 FPR64:$src))>;
5318 def : Pat<(v1f64 (bitconvert (v8i8 FPR64:$src))),
5319 (v1f64 (REV64v8i8 FPR64:$src))>;
5320 def : Pat<(v1f64 (bitconvert (v2f32 FPR64:$src))),
5321 (v1f64 (REV64v2i32 FPR64:$src))>;
5322 def : Pat<(v1f64 (bitconvert (v4f16 FPR64:$src))),
5323 (v1f64 (REV64v4i16 FPR64:$src))>;
5325 def : Pat<(v1f64 (bitconvert (v1i64 FPR64:$src))), (v1f64 FPR64:$src)>;
5326 def : Pat<(v1f64 (bitconvert (f64 FPR64:$src))), (v1f64 FPR64:$src)>;
5328 let Predicates = [IsLE] in {
5329 def : Pat<(v2f32 (bitconvert (v1i64 FPR64:$src))), (v2f32 FPR64:$src)>;
5330 def : Pat<(v2f32 (bitconvert (v4i16 FPR64:$src))), (v2f32 FPR64:$src)>;
5331 def : Pat<(v2f32 (bitconvert (v8i8 FPR64:$src))), (v2f32 FPR64:$src)>;
5332 def : Pat<(v2f32 (bitconvert (v1f64 FPR64:$src))), (v2f32 FPR64:$src)>;
5333 def : Pat<(v2f32 (bitconvert (f64 FPR64:$src))), (v2f32 FPR64:$src)>;
5334 def : Pat<(v2f32 (bitconvert (v4f16 FPR64:$src))), (v2f32 FPR64:$src)>;
5336 let Predicates = [IsBE] in {
5337 def : Pat<(v2f32 (bitconvert (v1i64 FPR64:$src))),
5338 (v2f32 (REV64v2i32 FPR64:$src))>;
5339 def : Pat<(v2f32 (bitconvert (v4i16 FPR64:$src))),
5340 (v2f32 (REV32v4i16 FPR64:$src))>;
5341 def : Pat<(v2f32 (bitconvert (v8i8 FPR64:$src))),
5342 (v2f32 (REV32v8i8 FPR64:$src))>;
5343 def : Pat<(v2f32 (bitconvert (v1f64 FPR64:$src))),
5344 (v2f32 (REV64v2i32 FPR64:$src))>;
5345 def : Pat<(v2f32 (bitconvert (f64 FPR64:$src))),
5346 (v2f32 (REV64v2i32 FPR64:$src))>;
5347 def : Pat<(v2f32 (bitconvert (v4f16 FPR64:$src))),
5348 (v2f32 (REV64v4i16 FPR64:$src))>;
5350 def : Pat<(v2f32 (bitconvert (v2i32 FPR64:$src))), (v2f32 FPR64:$src)>;
5352 let Predicates = [IsLE] in {
5353 def : Pat<(f128 (bitconvert (v2i64 FPR128:$src))), (f128 FPR128:$src)>;
5354 def : Pat<(f128 (bitconvert (v4i32 FPR128:$src))), (f128 FPR128:$src)>;
5355 def : Pat<(f128 (bitconvert (v8i16 FPR128:$src))), (f128 FPR128:$src)>;
5356 def : Pat<(f128 (bitconvert (v2f64 FPR128:$src))), (f128 FPR128:$src)>;
5357 def : Pat<(f128 (bitconvert (v4f32 FPR128:$src))), (f128 FPR128:$src)>;
5358 def : Pat<(f128 (bitconvert (v8f16 FPR128:$src))), (f128 FPR128:$src)>;
5359 def : Pat<(f128 (bitconvert (v16i8 FPR128:$src))), (f128 FPR128:$src)>;
5361 let Predicates = [IsBE] in {
5362 def : Pat<(f128 (bitconvert (v2i64 FPR128:$src))),
5363 (f128 (EXTv16i8 FPR128:$src, FPR128:$src, (i32 8)))>;
5364 def : Pat<(f128 (bitconvert (v4i32 FPR128:$src))),
5365 (f128 (EXTv16i8 (REV64v4i32 FPR128:$src),
5366 (REV64v4i32 FPR128:$src), (i32 8)))>;
5367 def : Pat<(f128 (bitconvert (v8i16 FPR128:$src))),
5368 (f128 (EXTv16i8 (REV64v8i16 FPR128:$src),
5369 (REV64v8i16 FPR128:$src), (i32 8)))>;
5370 def : Pat<(f128 (bitconvert (v8f16 FPR128:$src))),
5371 (f128 (EXTv16i8 (REV64v8i16 FPR128:$src),
5372 (REV64v8i16 FPR128:$src), (i32 8)))>;
5373 def : Pat<(f128 (bitconvert (v2f64 FPR128:$src))),
5374 (f128 (EXTv16i8 FPR128:$src, FPR128:$src, (i32 8)))>;
5375 def : Pat<(f128 (bitconvert (v4f32 FPR128:$src))),
5376 (f128 (EXTv16i8 (REV64v4i32 FPR128:$src),
5377 (REV64v4i32 FPR128:$src), (i32 8)))>;
5378 def : Pat<(f128 (bitconvert (v16i8 FPR128:$src))),
5379 (f128 (EXTv16i8 (REV64v16i8 FPR128:$src),
5380 (REV64v16i8 FPR128:$src), (i32 8)))>;
5383 let Predicates = [IsLE] in {
5384 def : Pat<(v2f64 (bitconvert (f128 FPR128:$src))), (v2f64 FPR128:$src)>;
5385 def : Pat<(v2f64 (bitconvert (v4i32 FPR128:$src))), (v2f64 FPR128:$src)>;
5386 def : Pat<(v2f64 (bitconvert (v8i16 FPR128:$src))), (v2f64 FPR128:$src)>;
5387 def : Pat<(v2f64 (bitconvert (v8f16 FPR128:$src))), (v2f64 FPR128:$src)>;
5388 def : Pat<(v2f64 (bitconvert (v16i8 FPR128:$src))), (v2f64 FPR128:$src)>;
5389 def : Pat<(v2f64 (bitconvert (v4f32 FPR128:$src))), (v2f64 FPR128:$src)>;
5391 let Predicates = [IsBE] in {
5392 def : Pat<(v2f64 (bitconvert (f128 FPR128:$src))),
5393 (v2f64 (EXTv16i8 FPR128:$src,
5394 FPR128:$src, (i32 8)))>;
5395 def : Pat<(v2f64 (bitconvert (v4i32 FPR128:$src))),
5396 (v2f64 (REV64v4i32 FPR128:$src))>;
5397 def : Pat<(v2f64 (bitconvert (v8i16 FPR128:$src))),
5398 (v2f64 (REV64v8i16 FPR128:$src))>;
5399 def : Pat<(v2f64 (bitconvert (v8f16 FPR128:$src))),
5400 (v2f64 (REV64v8i16 FPR128:$src))>;
5401 def : Pat<(v2f64 (bitconvert (v16i8 FPR128:$src))),
5402 (v2f64 (REV64v16i8 FPR128:$src))>;
5403 def : Pat<(v2f64 (bitconvert (v4f32 FPR128:$src))),
5404 (v2f64 (REV64v4i32 FPR128:$src))>;
5406 def : Pat<(v2f64 (bitconvert (v2i64 FPR128:$src))), (v2f64 FPR128:$src)>;
5408 let Predicates = [IsLE] in {
5409 def : Pat<(v4f32 (bitconvert (f128 FPR128:$src))), (v4f32 FPR128:$src)>;
5410 def : Pat<(v4f32 (bitconvert (v8i16 FPR128:$src))), (v4f32 FPR128:$src)>;
5411 def : Pat<(v4f32 (bitconvert (v8f16 FPR128:$src))), (v4f32 FPR128:$src)>;
5412 def : Pat<(v4f32 (bitconvert (v16i8 FPR128:$src))), (v4f32 FPR128:$src)>;
5413 def : Pat<(v4f32 (bitconvert (v2i64 FPR128:$src))), (v4f32 FPR128:$src)>;
5414 def : Pat<(v4f32 (bitconvert (v2f64 FPR128:$src))), (v4f32 FPR128:$src)>;
5416 let Predicates = [IsBE] in {
5417 def : Pat<(v4f32 (bitconvert (f128 FPR128:$src))),
5418 (v4f32 (EXTv16i8 (REV64v4i32 FPR128:$src),
5419 (REV64v4i32 FPR128:$src), (i32 8)))>;
5420 def : Pat<(v4f32 (bitconvert (v8i16 FPR128:$src))),
5421 (v4f32 (REV32v8i16 FPR128:$src))>;
5422 def : Pat<(v4f32 (bitconvert (v8f16 FPR128:$src))),
5423 (v4f32 (REV32v8i16 FPR128:$src))>;
5424 def : Pat<(v4f32 (bitconvert (v16i8 FPR128:$src))),
5425 (v4f32 (REV32v16i8 FPR128:$src))>;
5426 def : Pat<(v4f32 (bitconvert (v2i64 FPR128:$src))),
5427 (v4f32 (REV64v4i32 FPR128:$src))>;
5428 def : Pat<(v4f32 (bitconvert (v2f64 FPR128:$src))),
5429 (v4f32 (REV64v4i32 FPR128:$src))>;
5431 def : Pat<(v4f32 (bitconvert (v4i32 FPR128:$src))), (v4f32 FPR128:$src)>;
5433 let Predicates = [IsLE] in {
5434 def : Pat<(v2i64 (bitconvert (f128 FPR128:$src))), (v2i64 FPR128:$src)>;
5435 def : Pat<(v2i64 (bitconvert (v4i32 FPR128:$src))), (v2i64 FPR128:$src)>;
5436 def : Pat<(v2i64 (bitconvert (v8i16 FPR128:$src))), (v2i64 FPR128:$src)>;
5437 def : Pat<(v2i64 (bitconvert (v16i8 FPR128:$src))), (v2i64 FPR128:$src)>;
5438 def : Pat<(v2i64 (bitconvert (v4f32 FPR128:$src))), (v2i64 FPR128:$src)>;
5439 def : Pat<(v2i64 (bitconvert (v8f16 FPR128:$src))), (v2i64 FPR128:$src)>;
5441 let Predicates = [IsBE] in {
5442 def : Pat<(v2i64 (bitconvert (f128 FPR128:$src))),
5443 (v2i64 (EXTv16i8 FPR128:$src,
5444 FPR128:$src, (i32 8)))>;
5445 def : Pat<(v2i64 (bitconvert (v4i32 FPR128:$src))),
5446 (v2i64 (REV64v4i32 FPR128:$src))>;
5447 def : Pat<(v2i64 (bitconvert (v8i16 FPR128:$src))),
5448 (v2i64 (REV64v8i16 FPR128:$src))>;
5449 def : Pat<(v2i64 (bitconvert (v16i8 FPR128:$src))),
5450 (v2i64 (REV64v16i8 FPR128:$src))>;
5451 def : Pat<(v2i64 (bitconvert (v4f32 FPR128:$src))),
5452 (v2i64 (REV64v4i32 FPR128:$src))>;
5453 def : Pat<(v2i64 (bitconvert (v8f16 FPR128:$src))),
5454 (v2i64 (REV64v8i16 FPR128:$src))>;
5456 def : Pat<(v2i64 (bitconvert (v2f64 FPR128:$src))), (v2i64 FPR128:$src)>;
5458 let Predicates = [IsLE] in {
5459 def : Pat<(v4i32 (bitconvert (f128 FPR128:$src))), (v4i32 FPR128:$src)>;
5460 def : Pat<(v4i32 (bitconvert (v2i64 FPR128:$src))), (v4i32 FPR128:$src)>;
5461 def : Pat<(v4i32 (bitconvert (v8i16 FPR128:$src))), (v4i32 FPR128:$src)>;
5462 def : Pat<(v4i32 (bitconvert (v16i8 FPR128:$src))), (v4i32 FPR128:$src)>;
5463 def : Pat<(v4i32 (bitconvert (v2f64 FPR128:$src))), (v4i32 FPR128:$src)>;
5464 def : Pat<(v4i32 (bitconvert (v8f16 FPR128:$src))), (v4i32 FPR128:$src)>;
5466 let Predicates = [IsBE] in {
5467 def : Pat<(v4i32 (bitconvert (f128 FPR128:$src))),
5468 (v4i32 (EXTv16i8 (REV64v4i32 FPR128:$src),
5469 (REV64v4i32 FPR128:$src),
5471 def : Pat<(v4i32 (bitconvert (v2i64 FPR128:$src))),
5472 (v4i32 (REV64v4i32 FPR128:$src))>;
5473 def : Pat<(v4i32 (bitconvert (v8i16 FPR128:$src))),
5474 (v4i32 (REV32v8i16 FPR128:$src))>;
5475 def : Pat<(v4i32 (bitconvert (v16i8 FPR128:$src))),
5476 (v4i32 (REV32v16i8 FPR128:$src))>;
5477 def : Pat<(v4i32 (bitconvert (v2f64 FPR128:$src))),
5478 (v4i32 (REV64v4i32 FPR128:$src))>;
5479 def : Pat<(v4i32 (bitconvert (v8f16 FPR128:$src))),
5480 (v4i32 (REV32v8i16 FPR128:$src))>;
5482 def : Pat<(v4i32 (bitconvert (v4f32 FPR128:$src))), (v4i32 FPR128:$src)>;
5484 let Predicates = [IsLE] in {
5485 def : Pat<(v8i16 (bitconvert (f128 FPR128:$src))), (v8i16 FPR128:$src)>;
5486 def : Pat<(v8i16 (bitconvert (v2i64 FPR128:$src))), (v8i16 FPR128:$src)>;
5487 def : Pat<(v8i16 (bitconvert (v4i32 FPR128:$src))), (v8i16 FPR128:$src)>;
5488 def : Pat<(v8i16 (bitconvert (v16i8 FPR128:$src))), (v8i16 FPR128:$src)>;
5489 def : Pat<(v8i16 (bitconvert (v2f64 FPR128:$src))), (v8i16 FPR128:$src)>;
5490 def : Pat<(v8i16 (bitconvert (v4f32 FPR128:$src))), (v8i16 FPR128:$src)>;
5491 def : Pat<(v8i16 (bitconvert (v8f16 FPR128:$src))), (v8i16 FPR128:$src)>;
5493 let Predicates = [IsBE] in {
5494 def : Pat<(v8i16 (bitconvert (f128 FPR128:$src))),
5495 (v8i16 (EXTv16i8 (REV64v8i16 FPR128:$src),
5496 (REV64v8i16 FPR128:$src),
5498 def : Pat<(v8i16 (bitconvert (v2i64 FPR128:$src))),
5499 (v8i16 (REV64v8i16 FPR128:$src))>;
5500 def : Pat<(v8i16 (bitconvert (v4i32 FPR128:$src))),
5501 (v8i16 (REV32v8i16 FPR128:$src))>;
5502 def : Pat<(v8i16 (bitconvert (v16i8 FPR128:$src))),
5503 (v8i16 (REV16v16i8 FPR128:$src))>;
5504 def : Pat<(v8i16 (bitconvert (v2f64 FPR128:$src))),
5505 (v8i16 (REV64v8i16 FPR128:$src))>;
5506 def : Pat<(v8i16 (bitconvert (v4f32 FPR128:$src))),
5507 (v8i16 (REV32v8i16 FPR128:$src))>;
5508 def : Pat<(v8i16 (bitconvert (v8f16 FPR128:$src))),
5509 (v8i16 (REV32v8i16 FPR128:$src))>;
5512 let Predicates = [IsLE] in {
5513 def : Pat<(v8f16 (bitconvert (f128 FPR128:$src))), (v8f16 FPR128:$src)>;
5514 def : Pat<(v8f16 (bitconvert (v2i64 FPR128:$src))), (v8f16 FPR128:$src)>;
5515 def : Pat<(v8f16 (bitconvert (v4i32 FPR128:$src))), (v8f16 FPR128:$src)>;
5516 def : Pat<(v8f16 (bitconvert (v8i16 FPR128:$src))), (v8f16 FPR128:$src)>;
5517 def : Pat<(v8f16 (bitconvert (v16i8 FPR128:$src))), (v8f16 FPR128:$src)>;
5518 def : Pat<(v8f16 (bitconvert (v2f64 FPR128:$src))), (v8f16 FPR128:$src)>;
5519 def : Pat<(v8f16 (bitconvert (v4f32 FPR128:$src))), (v8f16 FPR128:$src)>;
5521 let Predicates = [IsBE] in {
5522 def : Pat<(v8f16 (bitconvert (f128 FPR128:$src))),
5523 (v8f16 (EXTv16i8 (REV64v8i16 FPR128:$src),
5524 (REV64v8i16 FPR128:$src),
5526 def : Pat<(v8f16 (bitconvert (v2i64 FPR128:$src))),
5527 (v8f16 (REV64v8i16 FPR128:$src))>;
5528 def : Pat<(v8f16 (bitconvert (v4i32 FPR128:$src))),
5529 (v8f16 (REV32v8i16 FPR128:$src))>;
5530 def : Pat<(v8f16 (bitconvert (v8i16 FPR128:$src))),
5531 (v8f16 (REV64v8i16 FPR128:$src))>;
5532 def : Pat<(v8f16 (bitconvert (v16i8 FPR128:$src))),
5533 (v8f16 (REV16v16i8 FPR128:$src))>;
5534 def : Pat<(v8f16 (bitconvert (v2f64 FPR128:$src))),
5535 (v8f16 (REV64v8i16 FPR128:$src))>;
5536 def : Pat<(v8f16 (bitconvert (v4f32 FPR128:$src))),
5537 (v8f16 (REV32v8i16 FPR128:$src))>;
5540 let Predicates = [IsLE] in {
5541 def : Pat<(v16i8 (bitconvert (f128 FPR128:$src))), (v16i8 FPR128:$src)>;
5542 def : Pat<(v16i8 (bitconvert (v2i64 FPR128:$src))), (v16i8 FPR128:$src)>;
5543 def : Pat<(v16i8 (bitconvert (v4i32 FPR128:$src))), (v16i8 FPR128:$src)>;
5544 def : Pat<(v16i8 (bitconvert (v8i16 FPR128:$src))), (v16i8 FPR128:$src)>;
5545 def : Pat<(v16i8 (bitconvert (v2f64 FPR128:$src))), (v16i8 FPR128:$src)>;
5546 def : Pat<(v16i8 (bitconvert (v4f32 FPR128:$src))), (v16i8 FPR128:$src)>;
5547 def : Pat<(v16i8 (bitconvert (v8f16 FPR128:$src))), (v16i8 FPR128:$src)>;
5549 let Predicates = [IsBE] in {
5550 def : Pat<(v16i8 (bitconvert (f128 FPR128:$src))),
5551 (v16i8 (EXTv16i8 (REV64v16i8 FPR128:$src),
5552 (REV64v16i8 FPR128:$src),
5554 def : Pat<(v16i8 (bitconvert (v2i64 FPR128:$src))),
5555 (v16i8 (REV64v16i8 FPR128:$src))>;
5556 def : Pat<(v16i8 (bitconvert (v4i32 FPR128:$src))),
5557 (v16i8 (REV32v16i8 FPR128:$src))>;
5558 def : Pat<(v16i8 (bitconvert (v8i16 FPR128:$src))),
5559 (v16i8 (REV16v16i8 FPR128:$src))>;
5560 def : Pat<(v16i8 (bitconvert (v2f64 FPR128:$src))),
5561 (v16i8 (REV64v16i8 FPR128:$src))>;
5562 def : Pat<(v16i8 (bitconvert (v4f32 FPR128:$src))),
5563 (v16i8 (REV32v16i8 FPR128:$src))>;
5564 def : Pat<(v16i8 (bitconvert (v8f16 FPR128:$src))),
5565 (v16i8 (REV16v16i8 FPR128:$src))>;
5568 def : Pat<(v8i8 (extract_subvector (v16i8 FPR128:$Rn), (i64 1))),
5569 (EXTRACT_SUBREG (DUPv2i64lane FPR128:$Rn, 1), dsub)>;
5570 def : Pat<(v4i16 (extract_subvector (v8i16 FPR128:$Rn), (i64 1))),
5571 (EXTRACT_SUBREG (DUPv2i64lane FPR128:$Rn, 1), dsub)>;
5572 def : Pat<(v2i32 (extract_subvector (v4i32 FPR128:$Rn), (i64 1))),
5573 (EXTRACT_SUBREG (DUPv2i64lane FPR128:$Rn, 1), dsub)>;
5574 def : Pat<(v1i64 (extract_subvector (v2i64 FPR128:$Rn), (i64 1))),
5575 (EXTRACT_SUBREG (DUPv2i64lane FPR128:$Rn, 1), dsub)>;
5577 // A 64-bit subvector insert to the first 128-bit vector position
5578 // is a subregister copy that needs no instruction.
5579 def : Pat<(insert_subvector undef, (v1i64 FPR64:$src), (i32 0)),
5580 (INSERT_SUBREG (v2i64 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
5581 def : Pat<(insert_subvector undef, (v1f64 FPR64:$src), (i32 0)),
5582 (INSERT_SUBREG (v2f64 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
5583 def : Pat<(insert_subvector undef, (v2i32 FPR64:$src), (i32 0)),
5584 (INSERT_SUBREG (v4i32 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
5585 def : Pat<(insert_subvector undef, (v2f32 FPR64:$src), (i32 0)),
5586 (INSERT_SUBREG (v4f32 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
5587 def : Pat<(insert_subvector undef, (v4i16 FPR64:$src), (i32 0)),
5588 (INSERT_SUBREG (v8i16 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
5589 def : Pat<(insert_subvector undef, (v4f16 FPR64:$src), (i32 0)),
5590 (INSERT_SUBREG (v8f16 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
5591 def : Pat<(insert_subvector undef, (v8i8 FPR64:$src), (i32 0)),
5592 (INSERT_SUBREG (v16i8 (IMPLICIT_DEF)), FPR64:$src, dsub)>;
5594 // Use pair-wise add instructions when summing up the lanes for v2f64, v2i64
5596 def : Pat<(i64 (add (vector_extract (v2i64 FPR128:$Rn), (i64 0)),
5597 (vector_extract (v2i64 FPR128:$Rn), (i64 1)))),
5598 (i64 (ADDPv2i64p (v2i64 FPR128:$Rn)))>;
5599 def : Pat<(f64 (fadd (vector_extract (v2f64 FPR128:$Rn), (i64 0)),
5600 (vector_extract (v2f64 FPR128:$Rn), (i64 1)))),
5601 (f64 (FADDPv2i64p (v2f64 FPR128:$Rn)))>;
5602 // vector_extract on 64-bit vectors gets promoted to a 128 bit vector,
5603 // so we match on v4f32 here, not v2f32. This will also catch adding
5604 // the low two lanes of a true v4f32 vector.
5605 def : Pat<(fadd (vector_extract (v4f32 FPR128:$Rn), (i64 0)),
5606 (vector_extract (v4f32 FPR128:$Rn), (i64 1))),
5607 (f32 (FADDPv2i32p (EXTRACT_SUBREG FPR128:$Rn, dsub)))>;
5609 // Scalar 64-bit shifts in FPR64 registers.
5610 def : Pat<(i64 (int_aarch64_neon_sshl (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
5611 (SSHLv1i64 FPR64:$Rn, FPR64:$Rm)>;
5612 def : Pat<(i64 (int_aarch64_neon_ushl (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
5613 (USHLv1i64 FPR64:$Rn, FPR64:$Rm)>;
5614 def : Pat<(i64 (int_aarch64_neon_srshl (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
5615 (SRSHLv1i64 FPR64:$Rn, FPR64:$Rm)>;
5616 def : Pat<(i64 (int_aarch64_neon_urshl (i64 FPR64:$Rn), (i64 FPR64:$Rm))),
5617 (URSHLv1i64 FPR64:$Rn, FPR64:$Rm)>;
5619 // Tail call return handling. These are all compiler pseudo-instructions,
5620 // so no encoding information or anything like that.
5621 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in {
5622 def TCRETURNdi : Pseudo<(outs), (ins i64imm:$dst, i32imm:$FPDiff),[]>;
5623 def TCRETURNri : Pseudo<(outs), (ins tcGPR64:$dst, i32imm:$FPDiff), []>;
5626 def : Pat<(AArch64tcret tcGPR64:$dst, (i32 timm:$FPDiff)),
5627 (TCRETURNri tcGPR64:$dst, imm:$FPDiff)>;
5628 def : Pat<(AArch64tcret tglobaladdr:$dst, (i32 timm:$FPDiff)),
5629 (TCRETURNdi texternalsym:$dst, imm:$FPDiff)>;
5630 def : Pat<(AArch64tcret texternalsym:$dst, (i32 timm:$FPDiff)),
5631 (TCRETURNdi texternalsym:$dst, imm:$FPDiff)>;
5633 include "AArch64InstrAtomics.td"