1 //===- ARMInstrInfo.td - Target Description for ARM Target -*- tablegen -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file describes the ARM instructions in TableGen format.
11 //===----------------------------------------------------------------------===//
13 //===----------------------------------------------------------------------===//
14 // ARM specific DAG Nodes.
18 def SDT_ARMCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32>,
20 def SDT_ARMCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>, SDTCisVT<1, i32> ]>;
21 def SDT_ARMStructByVal : SDTypeProfile<0, 4,
22 [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
23 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
25 def SDT_ARMSaveCallPC : SDTypeProfile<0, 1, []>;
27 def SDT_ARMcall : SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>;
29 def SDT_ARMCMov : SDTypeProfile<1, 3,
30 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
33 def SDT_ARMBrcond : SDTypeProfile<0, 2,
34 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i32>]>;
36 def SDT_ARMBrJT : SDTypeProfile<0, 2,
37 [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
39 def SDT_ARMBr2JT : SDTypeProfile<0, 3,
40 [SDTCisPtrTy<0>, SDTCisVT<1, i32>,
43 def SDT_ARMBCC_i64 : SDTypeProfile<0, 6,
45 SDTCisVT<1, i32>, SDTCisVT<2, i32>,
46 SDTCisVT<3, i32>, SDTCisVT<4, i32>,
47 SDTCisVT<5, OtherVT>]>;
49 def SDT_ARMAnd : SDTypeProfile<1, 2,
50 [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
53 def SDT_ARMCmp : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
54 def SDT_ARMFCmp : SDTypeProfile<0, 3, [SDTCisSameAs<0, 1>,
57 def SDT_ARMPICAdd : SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>,
58 SDTCisPtrTy<1>, SDTCisVT<2, i32>]>;
60 def SDT_ARMThreadPointer : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
61 def SDT_ARMEH_SJLJ_Setjmp : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisPtrTy<1>,
63 def SDT_ARMEH_SJLJ_Longjmp: SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
64 def SDT_ARMEH_SJLJ_SetupDispatch: SDTypeProfile<0, 0, []>;
66 def SDT_ARMMEMBARRIER : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
68 def SDT_ARMPREFETCH : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisSameAs<1, 2>,
71 def SDT_ARMTCRET : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
73 def SDT_ARMBFI : SDTypeProfile<1, 3, [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
74 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
76 def SDT_WIN__DBZCHK : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
78 def SDT_ARMMEMCPY : SDTypeProfile<2, 3, [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
79 SDTCisVT<2, i32>, SDTCisVT<3, i32>,
82 def SDTBinaryArithWithFlags : SDTypeProfile<2, 2,
85 SDTCisInt<0>, SDTCisVT<1, i32>]>;
87 // SDTBinaryArithWithFlagsInOut - RES1, CPSR = op LHS, RHS, CPSR
88 def SDTBinaryArithWithFlagsInOut : SDTypeProfile<2, 3,
95 def SDT_LongMac : SDTypeProfile<2, 4, [SDTCisVT<0, i32>,
100 SDTCisSameAs<0, 5>]>;
102 def ARMSmlald : SDNode<"ARMISD::SMLALD", SDT_LongMac>;
103 def ARMSmlaldx : SDNode<"ARMISD::SMLALDX", SDT_LongMac>;
104 def ARMSmlsld : SDNode<"ARMISD::SMLSLD", SDT_LongMac>;
105 def ARMSmlsldx : SDNode<"ARMISD::SMLSLDX", SDT_LongMac>;
107 def SDT_MulHSR : SDTypeProfile<1, 3, [SDTCisVT<0,i32>,
110 SDTCisSameAs<0, 3>]>;
112 def ARMsmmlar : SDNode<"ARMISD::SMMLAR", SDT_MulHSR>;
113 def ARMsmmlsr : SDNode<"ARMISD::SMMLSR", SDT_MulHSR>;
116 def ARMWrapper : SDNode<"ARMISD::Wrapper", SDTIntUnaryOp>;
117 def ARMWrapperPIC : SDNode<"ARMISD::WrapperPIC", SDTIntUnaryOp>;
118 def ARMWrapperJT : SDNode<"ARMISD::WrapperJT", SDTIntUnaryOp>;
120 def ARMcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_ARMCallSeqStart,
121 [SDNPHasChain, SDNPSideEffect, SDNPOutGlue]>;
122 def ARMcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_ARMCallSeqEnd,
123 [SDNPHasChain, SDNPSideEffect,
124 SDNPOptInGlue, SDNPOutGlue]>;
125 def ARMcopystructbyval : SDNode<"ARMISD::COPY_STRUCT_BYVAL" ,
127 [SDNPHasChain, SDNPInGlue, SDNPOutGlue,
128 SDNPMayStore, SDNPMayLoad]>;
130 def ARMcall : SDNode<"ARMISD::CALL", SDT_ARMcall,
131 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
133 def ARMcall_pred : SDNode<"ARMISD::CALL_PRED", SDT_ARMcall,
134 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
136 def ARMcall_nolink : SDNode<"ARMISD::CALL_NOLINK", SDT_ARMcall,
137 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
140 def ARMretflag : SDNode<"ARMISD::RET_FLAG", SDTNone,
141 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
142 def ARMintretflag : SDNode<"ARMISD::INTRET_FLAG", SDT_ARMcall,
143 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
144 def ARMcmov : SDNode<"ARMISD::CMOV", SDT_ARMCMov,
146 def ARMsubs : SDNode<"ARMISD::SUBS", SDTIntBinOp, [SDNPOutGlue]>;
148 def ARMssatnoshift : SDNode<"ARMISD::SSAT", SDTIntSatNoShOp, []>;
150 def ARMusatnoshift : SDNode<"ARMISD::USAT", SDTIntSatNoShOp, []>;
152 def ARMbrcond : SDNode<"ARMISD::BRCOND", SDT_ARMBrcond,
153 [SDNPHasChain, SDNPInGlue, SDNPOutGlue]>;
155 def ARMbrjt : SDNode<"ARMISD::BR_JT", SDT_ARMBrJT,
157 def ARMbr2jt : SDNode<"ARMISD::BR2_JT", SDT_ARMBr2JT,
160 def ARMBcci64 : SDNode<"ARMISD::BCC_i64", SDT_ARMBCC_i64,
163 def ARMcmp : SDNode<"ARMISD::CMP", SDT_ARMCmp,
166 def ARMcmn : SDNode<"ARMISD::CMN", SDT_ARMCmp,
169 def ARMcmpZ : SDNode<"ARMISD::CMPZ", SDT_ARMCmp,
170 [SDNPOutGlue, SDNPCommutative]>;
172 def ARMpic_add : SDNode<"ARMISD::PIC_ADD", SDT_ARMPICAdd>;
174 def ARMsrl_flag : SDNode<"ARMISD::SRL_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
175 def ARMsra_flag : SDNode<"ARMISD::SRA_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
176 def ARMrrx : SDNode<"ARMISD::RRX" , SDTIntUnaryOp, [SDNPInGlue ]>;
178 def ARMaddc : SDNode<"ARMISD::ADDC", SDTBinaryArithWithFlags,
180 def ARMsubc : SDNode<"ARMISD::SUBC", SDTBinaryArithWithFlags>;
181 def ARMadde : SDNode<"ARMISD::ADDE", SDTBinaryArithWithFlagsInOut>;
182 def ARMsube : SDNode<"ARMISD::SUBE", SDTBinaryArithWithFlagsInOut>;
184 def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>;
185 def ARMeh_sjlj_setjmp: SDNode<"ARMISD::EH_SJLJ_SETJMP",
186 SDT_ARMEH_SJLJ_Setjmp,
187 [SDNPHasChain, SDNPSideEffect]>;
188 def ARMeh_sjlj_longjmp: SDNode<"ARMISD::EH_SJLJ_LONGJMP",
189 SDT_ARMEH_SJLJ_Longjmp,
190 [SDNPHasChain, SDNPSideEffect]>;
191 def ARMeh_sjlj_setup_dispatch: SDNode<"ARMISD::EH_SJLJ_SETUP_DISPATCH",
192 SDT_ARMEH_SJLJ_SetupDispatch,
193 [SDNPHasChain, SDNPSideEffect]>;
195 def ARMMemBarrierMCR : SDNode<"ARMISD::MEMBARRIER_MCR", SDT_ARMMEMBARRIER,
196 [SDNPHasChain, SDNPSideEffect]>;
197 def ARMPreload : SDNode<"ARMISD::PRELOAD", SDT_ARMPREFETCH,
198 [SDNPHasChain, SDNPMayLoad, SDNPMayStore]>;
200 def ARMtcret : SDNode<"ARMISD::TC_RETURN", SDT_ARMTCRET,
201 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
203 def ARMbfi : SDNode<"ARMISD::BFI", SDT_ARMBFI>;
205 def ARMmemcopy : SDNode<"ARMISD::MEMCPY", SDT_ARMMEMCPY,
206 [SDNPHasChain, SDNPInGlue, SDNPOutGlue,
207 SDNPMayStore, SDNPMayLoad]>;
209 def ARMsmulwb : SDNode<"ARMISD::SMULWB", SDTIntBinOp, []>;
210 def ARMsmulwt : SDNode<"ARMISD::SMULWT", SDTIntBinOp, []>;
211 def ARMsmlalbb : SDNode<"ARMISD::SMLALBB", SDT_LongMac, []>;
212 def ARMsmlalbt : SDNode<"ARMISD::SMLALBT", SDT_LongMac, []>;
213 def ARMsmlaltb : SDNode<"ARMISD::SMLALTB", SDT_LongMac, []>;
214 def ARMsmlaltt : SDNode<"ARMISD::SMLALTT", SDT_LongMac, []>;
216 //===----------------------------------------------------------------------===//
217 // ARM Instruction Predicate Definitions.
219 def HasV4T : Predicate<"Subtarget->hasV4TOps()">,
220 AssemblerPredicate<"HasV4TOps", "armv4t">;
221 def NoV4T : Predicate<"!Subtarget->hasV4TOps()">;
222 def HasV5T : Predicate<"Subtarget->hasV5TOps()">,
223 AssemblerPredicate<"HasV5TOps", "armv5t">;
224 def NoV5T : Predicate<"!Subtarget->hasV5TOps()">;
225 def HasV5TE : Predicate<"Subtarget->hasV5TEOps()">,
226 AssemblerPredicate<"HasV5TEOps", "armv5te">;
227 def HasV6 : Predicate<"Subtarget->hasV6Ops()">,
228 AssemblerPredicate<"HasV6Ops", "armv6">;
229 def NoV6 : Predicate<"!Subtarget->hasV6Ops()">;
230 def HasV6M : Predicate<"Subtarget->hasV6MOps()">,
231 AssemblerPredicate<"HasV6MOps",
232 "armv6m or armv6t2">;
233 def HasV8MBaseline : Predicate<"Subtarget->hasV8MBaselineOps()">,
234 AssemblerPredicate<"HasV8MBaselineOps",
236 def HasV8MMainline : Predicate<"Subtarget->hasV8MMainlineOps()">,
237 AssemblerPredicate<"HasV8MMainlineOps",
239 def HasV6T2 : Predicate<"Subtarget->hasV6T2Ops()">,
240 AssemblerPredicate<"HasV6T2Ops", "armv6t2">;
241 def NoV6T2 : Predicate<"!Subtarget->hasV6T2Ops()">;
242 def HasV6K : Predicate<"Subtarget->hasV6KOps()">,
243 AssemblerPredicate<"HasV6KOps", "armv6k">;
244 def NoV6K : Predicate<"!Subtarget->hasV6KOps()">;
245 def HasV7 : Predicate<"Subtarget->hasV7Ops()">,
246 AssemblerPredicate<"HasV7Ops", "armv7">;
247 def HasV8 : Predicate<"Subtarget->hasV8Ops()">,
248 AssemblerPredicate<"HasV8Ops", "armv8">;
249 def PreV8 : Predicate<"!Subtarget->hasV8Ops()">,
250 AssemblerPredicate<"!HasV8Ops", "armv7 or earlier">;
251 def HasV8_1a : Predicate<"Subtarget->hasV8_1aOps()">,
252 AssemblerPredicate<"HasV8_1aOps", "armv8.1a">;
253 def HasV8_2a : Predicate<"Subtarget->hasV8_2aOps()">,
254 AssemblerPredicate<"HasV8_2aOps", "armv8.2a">;
255 def HasV8_3a : Predicate<"Subtarget->hasV8_3aOps()">,
256 AssemblerPredicate<"HasV8_3aOps", "armv8.3a">;
257 def HasV8_4a : Predicate<"Subtarget->hasV8_4aOps()">,
258 AssemblerPredicate<"HasV8_4aOps", "armv8.4a">;
259 def HasV8_5a : Predicate<"Subtarget->hasV8_5aOps()">,
260 AssemblerPredicate<"HasV8_5aOps", "armv8.5a">;
261 def NoVFP : Predicate<"!Subtarget->hasVFP2()">;
262 def HasVFP2 : Predicate<"Subtarget->hasVFP2()">,
263 AssemblerPredicate<"FeatureVFP2", "VFP2">;
264 def HasVFP3 : Predicate<"Subtarget->hasVFP3()">,
265 AssemblerPredicate<"FeatureVFP3", "VFP3">;
266 def HasVFP4 : Predicate<"Subtarget->hasVFP4()">,
267 AssemblerPredicate<"FeatureVFP4", "VFP4">;
268 def HasDPVFP : Predicate<"!Subtarget->isFPOnlySP()">,
269 AssemblerPredicate<"!FeatureVFPOnlySP",
270 "double precision VFP">;
271 def HasFPARMv8 : Predicate<"Subtarget->hasFPARMv8()">,
272 AssemblerPredicate<"FeatureFPARMv8", "FPARMv8">;
273 def HasNEON : Predicate<"Subtarget->hasNEON()">,
274 AssemblerPredicate<"FeatureNEON", "NEON">;
275 def HasSHA2 : Predicate<"Subtarget->hasSHA2()">,
276 AssemblerPredicate<"FeatureSHA2", "sha2">;
277 def HasAES : Predicate<"Subtarget->hasAES()">,
278 AssemblerPredicate<"FeatureAES", "aes">;
279 def HasCrypto : Predicate<"Subtarget->hasCrypto()">,
280 AssemblerPredicate<"FeatureCrypto", "crypto">;
281 def HasDotProd : Predicate<"Subtarget->hasDotProd()">,
282 AssemblerPredicate<"FeatureDotProd", "dotprod">;
283 def HasCRC : Predicate<"Subtarget->hasCRC()">,
284 AssemblerPredicate<"FeatureCRC", "crc">;
285 def HasRAS : Predicate<"Subtarget->hasRAS()">,
286 AssemblerPredicate<"FeatureRAS", "ras">;
287 def HasFP16 : Predicate<"Subtarget->hasFP16()">,
288 AssemblerPredicate<"FeatureFP16","half-float conversions">;
289 def HasFullFP16 : Predicate<"Subtarget->hasFullFP16()">,
290 AssemblerPredicate<"FeatureFullFP16","full half-float">;
291 def HasFP16FML : Predicate<"Subtarget->hasFP16FML()">,
292 AssemblerPredicate<"FeatureFP16FML","full half-float fml">;
293 def HasDivideInThumb : Predicate<"Subtarget->hasDivideInThumbMode()">,
294 AssemblerPredicate<"FeatureHWDivThumb", "divide in THUMB">;
295 def HasDivideInARM : Predicate<"Subtarget->hasDivideInARMMode()">,
296 AssemblerPredicate<"FeatureHWDivARM", "divide in ARM">;
297 def HasDSP : Predicate<"Subtarget->hasDSP()">,
298 AssemblerPredicate<"FeatureDSP", "dsp">;
299 def HasDB : Predicate<"Subtarget->hasDataBarrier()">,
300 AssemblerPredicate<"FeatureDB",
302 def HasDFB : Predicate<"Subtarget->hasFullDataBarrier()">,
303 AssemblerPredicate<"FeatureDFB",
304 "full-data-barrier">;
305 def HasV7Clrex : Predicate<"Subtarget->hasV7Clrex()">,
306 AssemblerPredicate<"FeatureV7Clrex",
308 def HasAcquireRelease : Predicate<"Subtarget->hasAcquireRelease()">,
309 AssemblerPredicate<"FeatureAcquireRelease",
311 def HasMP : Predicate<"Subtarget->hasMPExtension()">,
312 AssemblerPredicate<"FeatureMP",
314 def HasVirtualization: Predicate<"false">,
315 AssemblerPredicate<"FeatureVirtualization",
316 "virtualization-extensions">;
317 def HasTrustZone : Predicate<"Subtarget->hasTrustZone()">,
318 AssemblerPredicate<"FeatureTrustZone",
320 def Has8MSecExt : Predicate<"Subtarget->has8MSecExt()">,
321 AssemblerPredicate<"Feature8MSecExt",
322 "ARMv8-M Security Extensions">;
323 def HasZCZ : Predicate<"Subtarget->hasZeroCycleZeroing()">;
324 def UseNEONForFP : Predicate<"Subtarget->useNEONForSinglePrecisionFP()">;
325 def DontUseNEONForFP : Predicate<"!Subtarget->useNEONForSinglePrecisionFP()">;
326 def IsThumb : Predicate<"Subtarget->isThumb()">,
327 AssemblerPredicate<"ModeThumb", "thumb">;
328 def IsThumb1Only : Predicate<"Subtarget->isThumb1Only()">;
329 def IsThumb2 : Predicate<"Subtarget->isThumb2()">,
330 AssemblerPredicate<"ModeThumb,FeatureThumb2",
332 def IsMClass : Predicate<"Subtarget->isMClass()">,
333 AssemblerPredicate<"FeatureMClass", "armv*m">;
334 def IsNotMClass : Predicate<"!Subtarget->isMClass()">,
335 AssemblerPredicate<"!FeatureMClass",
337 def IsARM : Predicate<"!Subtarget->isThumb()">,
338 AssemblerPredicate<"!ModeThumb", "arm-mode">;
339 def IsMachO : Predicate<"Subtarget->isTargetMachO()">;
340 def IsNotMachO : Predicate<"!Subtarget->isTargetMachO()">;
341 def IsNaCl : Predicate<"Subtarget->isTargetNaCl()">;
342 def IsWindows : Predicate<"Subtarget->isTargetWindows()">;
343 def IsNotWindows : Predicate<"!Subtarget->isTargetWindows()">;
344 def IsReadTPHard : Predicate<"Subtarget->isReadTPHard()">;
345 def IsReadTPSoft : Predicate<"!Subtarget->isReadTPHard()">;
346 def UseNaClTrap : Predicate<"Subtarget->useNaClTrap()">,
347 AssemblerPredicate<"FeatureNaClTrap", "NaCl">;
348 def DontUseNaClTrap : Predicate<"!Subtarget->useNaClTrap()">;
350 def UseNegativeImmediates :
352 AssemblerPredicate<"!FeatureNoNegativeImmediates",
353 "NegativeImmediates">;
355 // FIXME: Eventually this will be just "hasV6T2Ops".
356 let RecomputePerFunction = 1 in {
357 def UseMovt : Predicate<"Subtarget->useMovt()">;
358 def DontUseMovt : Predicate<"!Subtarget->useMovt()">;
359 def UseMovtInPic : Predicate<"Subtarget->useMovt() && Subtarget->allowPositionIndependentMovt()">;
360 def DontUseMovtInPic : Predicate<"!Subtarget->useMovt() || !Subtarget->allowPositionIndependentMovt()">;
362 def UseFPVMLx: Predicate<"((Subtarget->useFPVMLx() &&"
363 " TM.Options.AllowFPOpFusion != FPOpFusion::Fast) ||"
364 "Subtarget->optForMinSize())">;
366 def UseMulOps : Predicate<"Subtarget->useMulOps()">;
368 // Prefer fused MAC for fp mul + add over fp VMLA / VMLS if they are available.
369 // But only select them if more precision in FP computation is allowed, and when
370 // they are not slower than a mul + add sequence.
371 // Do not use them for Darwin platforms.
372 def UseFusedMAC : Predicate<"(TM.Options.AllowFPOpFusion =="
373 " FPOpFusion::Fast && "
374 " Subtarget->hasVFP4()) && "
375 "!Subtarget->isTargetDarwin() &&"
376 "Subtarget->useFPVMLx()">;
378 def HasFastVGETLNi32 : Predicate<"!Subtarget->hasSlowVGETLNi32()">;
379 def HasSlowVGETLNi32 : Predicate<"Subtarget->hasSlowVGETLNi32()">;
381 def HasFastVDUP32 : Predicate<"!Subtarget->hasSlowVDUP32()">;
382 def HasSlowVDUP32 : Predicate<"Subtarget->hasSlowVDUP32()">;
384 def UseVMOVSR : Predicate<"Subtarget->preferVMOVSR() ||"
385 "!Subtarget->useNEONForSinglePrecisionFP()">;
386 def DontUseVMOVSR : Predicate<"!Subtarget->preferVMOVSR() &&"
387 "Subtarget->useNEONForSinglePrecisionFP()">;
389 let RecomputePerFunction = 1 in {
390 def IsLE : Predicate<"MF->getDataLayout().isLittleEndian()">;
391 def IsBE : Predicate<"MF->getDataLayout().isBigEndian()">;
394 def GenExecuteOnly : Predicate<"Subtarget->genExecuteOnly()">;
396 // Armv8.5-A extensions
397 def HasSB : Predicate<"Subtarget->hasSB()">,
398 AssemblerPredicate<"FeatureSB", "sb">;
400 //===----------------------------------------------------------------------===//
401 // ARM Flag Definitions.
403 class RegConstraint<string C> {
404 string Constraints = C;
407 //===----------------------------------------------------------------------===//
408 // ARM specific transformation functions and pattern fragments.
411 // imm_neg_XFORM - Return the negation of an i32 immediate value.
412 def imm_neg_XFORM : SDNodeXForm<imm, [{
413 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), SDLoc(N), MVT::i32);
416 // imm_not_XFORM - Return the complement of a i32 immediate value.
417 def imm_not_XFORM : SDNodeXForm<imm, [{
418 return CurDAG->getTargetConstant(~(int)N->getZExtValue(), SDLoc(N), MVT::i32);
421 /// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
422 def imm16_31 : ImmLeaf<i32, [{
423 return (int32_t)Imm >= 16 && (int32_t)Imm < 32;
426 // sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
427 def sext_16_node : PatLeaf<(i32 GPR:$a), [{
428 return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17;
431 def sext_bottom_16 : PatFrag<(ops node:$a),
432 (sext_inreg node:$a, i16)>;
433 def sext_top_16 : PatFrag<(ops node:$a),
434 (i32 (sra node:$a, (i32 16)))>;
436 def bb_mul : PatFrag<(ops node:$a, node:$b),
437 (mul (sext_bottom_16 node:$a), (sext_bottom_16 node:$b))>;
438 def bt_mul : PatFrag<(ops node:$a, node:$b),
439 (mul (sext_bottom_16 node:$a), (sra node:$b, (i32 16)))>;
440 def tb_mul : PatFrag<(ops node:$a, node:$b),
441 (mul (sra node:$a, (i32 16)), (sext_bottom_16 node:$b))>;
442 def tt_mul : PatFrag<(ops node:$a, node:$b),
443 (mul (sra node:$a, (i32 16)), (sra node:$b, (i32 16)))>;
445 /// Split a 32-bit immediate into two 16 bit parts.
446 def hi16 : SDNodeXForm<imm, [{
447 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, SDLoc(N),
451 def lo16AllZero : PatLeaf<(i32 imm), [{
452 // Returns true if all low 16-bits are 0.
453 return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
456 class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
457 class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
459 // An 'and' node with a single use.
460 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
461 return N->hasOneUse();
464 // An 'xor' node with a single use.
465 def xor_su : PatFrag<(ops node:$lhs, node:$rhs), (xor node:$lhs, node:$rhs), [{
466 return N->hasOneUse();
469 // An 'fmul' node with a single use.
470 def fmul_su : PatFrag<(ops node:$lhs, node:$rhs), (fmul node:$lhs, node:$rhs),[{
471 return N->hasOneUse();
474 // An 'fadd' node which checks for single non-hazardous use.
475 def fadd_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fadd node:$lhs, node:$rhs),[{
476 return hasNoVMLxHazardUse(N);
479 // An 'fsub' node which checks for single non-hazardous use.
480 def fsub_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fsub node:$lhs, node:$rhs),[{
481 return hasNoVMLxHazardUse(N);
484 //===----------------------------------------------------------------------===//
485 // Operand Definitions.
488 // Immediate operands with a shared generic asm render method.
489 class ImmAsmOperand<int Low, int High> : AsmOperandClass {
490 let RenderMethod = "addImmOperands";
491 let PredicateMethod = "isImmediate<" # Low # "," # High # ">";
492 let DiagnosticString = "operand must be an immediate in the range [" # Low # "," # High # "]";
495 class ImmAsmOperandMinusOne<int Low, int High> : AsmOperandClass {
496 let PredicateMethod = "isImmediate<" # Low # "," # High # ">";
497 let DiagnosticType = "ImmRange" # Low # "_" # High;
498 let DiagnosticString = "operand must be an immediate in the range [" # Low # "," # High # "]";
501 // Operands that are part of a memory addressing mode.
502 class MemOperand : Operand<i32> { let OperandType = "OPERAND_MEMORY"; }
505 // FIXME: rename brtarget to t2_brtarget
506 def brtarget : Operand<OtherVT> {
507 let EncoderMethod = "getBranchTargetOpValue";
508 let OperandType = "OPERAND_PCREL";
509 let DecoderMethod = "DecodeT2BROperand";
512 // Branches targeting ARM-mode must be divisible by 4 if they're a raw
514 def ARMBranchTarget : AsmOperandClass {
515 let Name = "ARMBranchTarget";
518 // Branches targeting Thumb-mode must be divisible by 2 if they're a raw
520 def ThumbBranchTarget : AsmOperandClass {
521 let Name = "ThumbBranchTarget";
524 def arm_br_target : Operand<OtherVT> {
525 let ParserMatchClass = ARMBranchTarget;
526 let EncoderMethod = "getARMBranchTargetOpValue";
527 let OperandType = "OPERAND_PCREL";
530 // Call target for ARM. Handles conditional/unconditional
531 // FIXME: rename bl_target to t2_bltarget?
532 def arm_bl_target : Operand<i32> {
533 let ParserMatchClass = ARMBranchTarget;
534 let EncoderMethod = "getARMBLTargetOpValue";
535 let OperandType = "OPERAND_PCREL";
538 // Target for BLX *from* ARM mode.
539 def arm_blx_target : Operand<i32> {
540 let ParserMatchClass = ThumbBranchTarget;
541 let EncoderMethod = "getARMBLXTargetOpValue";
542 let OperandType = "OPERAND_PCREL";
545 // A list of registers separated by comma. Used by load/store multiple.
546 def RegListAsmOperand : AsmOperandClass { let Name = "RegList"; }
547 def reglist : Operand<i32> {
548 let EncoderMethod = "getRegisterListOpValue";
549 let ParserMatchClass = RegListAsmOperand;
550 let PrintMethod = "printRegisterList";
551 let DecoderMethod = "DecodeRegListOperand";
554 def GPRPairOp : RegisterOperand<GPRPair, "printGPRPairOperand">;
556 def DPRRegListAsmOperand : AsmOperandClass {
557 let Name = "DPRRegList";
558 let DiagnosticType = "DPR_RegList";
560 def dpr_reglist : Operand<i32> {
561 let EncoderMethod = "getRegisterListOpValue";
562 let ParserMatchClass = DPRRegListAsmOperand;
563 let PrintMethod = "printRegisterList";
564 let DecoderMethod = "DecodeDPRRegListOperand";
567 def SPRRegListAsmOperand : AsmOperandClass {
568 let Name = "SPRRegList";
569 let DiagnosticString = "operand must be a list of registers in range [s0, s31]";
571 def spr_reglist : Operand<i32> {
572 let EncoderMethod = "getRegisterListOpValue";
573 let ParserMatchClass = SPRRegListAsmOperand;
574 let PrintMethod = "printRegisterList";
575 let DecoderMethod = "DecodeSPRRegListOperand";
578 // An operand for the CONSTPOOL_ENTRY pseudo-instruction.
579 def cpinst_operand : Operand<i32> {
580 let PrintMethod = "printCPInstOperand";
584 def pclabel : Operand<i32> {
585 let PrintMethod = "printPCLabel";
588 // ADR instruction labels.
589 def AdrLabelAsmOperand : AsmOperandClass { let Name = "AdrLabel"; }
590 def adrlabel : Operand<i32> {
591 let EncoderMethod = "getAdrLabelOpValue";
592 let ParserMatchClass = AdrLabelAsmOperand;
593 let PrintMethod = "printAdrLabelOperand<0>";
596 def neon_vcvt_imm32 : Operand<i32> {
597 let EncoderMethod = "getNEONVcvtImm32OpValue";
598 let DecoderMethod = "DecodeVCVTImmOperand";
601 // rot_imm: An integer that encodes a rotate amount. Must be 8, 16, or 24.
602 def rot_imm_XFORM: SDNodeXForm<imm, [{
603 switch (N->getZExtValue()){
604 default: llvm_unreachable(nullptr);
605 case 0: return CurDAG->getTargetConstant(0, SDLoc(N), MVT::i32);
606 case 8: return CurDAG->getTargetConstant(1, SDLoc(N), MVT::i32);
607 case 16: return CurDAG->getTargetConstant(2, SDLoc(N), MVT::i32);
608 case 24: return CurDAG->getTargetConstant(3, SDLoc(N), MVT::i32);
611 def RotImmAsmOperand : AsmOperandClass {
613 let ParserMethod = "parseRotImm";
615 def rot_imm : Operand<i32>, PatLeaf<(i32 imm), [{
616 int32_t v = N->getZExtValue();
617 return v == 8 || v == 16 || v == 24; }],
619 let PrintMethod = "printRotImmOperand";
620 let ParserMatchClass = RotImmAsmOperand;
623 // shift_imm: An integer that encodes a shift amount and the type of shift
624 // (asr or lsl). The 6-bit immediate encodes as:
627 // {4-0} imm5 shift amount.
628 // asr #32 encoded as imm5 == 0.
629 def ShifterImmAsmOperand : AsmOperandClass {
630 let Name = "ShifterImm";
631 let ParserMethod = "parseShifterImm";
633 def shift_imm : Operand<i32> {
634 let PrintMethod = "printShiftImmOperand";
635 let ParserMatchClass = ShifterImmAsmOperand;
638 // shifter_operand operands: so_reg_reg, so_reg_imm, and mod_imm.
639 def ShiftedRegAsmOperand : AsmOperandClass { let Name = "RegShiftedReg"; }
640 def so_reg_reg : Operand<i32>, // reg reg imm
641 ComplexPattern<i32, 3, "SelectRegShifterOperand",
642 [shl, srl, sra, rotr]> {
643 let EncoderMethod = "getSORegRegOpValue";
644 let PrintMethod = "printSORegRegOperand";
645 let DecoderMethod = "DecodeSORegRegOperand";
646 let ParserMatchClass = ShiftedRegAsmOperand;
647 let MIOperandInfo = (ops GPRnopc, GPRnopc, i32imm);
650 def ShiftedImmAsmOperand : AsmOperandClass { let Name = "RegShiftedImm"; }
651 def so_reg_imm : Operand<i32>, // reg imm
652 ComplexPattern<i32, 2, "SelectImmShifterOperand",
653 [shl, srl, sra, rotr]> {
654 let EncoderMethod = "getSORegImmOpValue";
655 let PrintMethod = "printSORegImmOperand";
656 let DecoderMethod = "DecodeSORegImmOperand";
657 let ParserMatchClass = ShiftedImmAsmOperand;
658 let MIOperandInfo = (ops GPR, i32imm);
661 // FIXME: Does this need to be distinct from so_reg?
662 def shift_so_reg_reg : Operand<i32>, // reg reg imm
663 ComplexPattern<i32, 3, "SelectShiftRegShifterOperand",
664 [shl,srl,sra,rotr]> {
665 let EncoderMethod = "getSORegRegOpValue";
666 let PrintMethod = "printSORegRegOperand";
667 let DecoderMethod = "DecodeSORegRegOperand";
668 let ParserMatchClass = ShiftedRegAsmOperand;
669 let MIOperandInfo = (ops GPR, GPR, i32imm);
672 // FIXME: Does this need to be distinct from so_reg?
673 def shift_so_reg_imm : Operand<i32>, // reg reg imm
674 ComplexPattern<i32, 2, "SelectShiftImmShifterOperand",
675 [shl,srl,sra,rotr]> {
676 let EncoderMethod = "getSORegImmOpValue";
677 let PrintMethod = "printSORegImmOperand";
678 let DecoderMethod = "DecodeSORegImmOperand";
679 let ParserMatchClass = ShiftedImmAsmOperand;
680 let MIOperandInfo = (ops GPR, i32imm);
683 // mod_imm: match a 32-bit immediate operand, which can be encoded into
684 // a 12-bit immediate; an 8-bit integer and a 4-bit rotator (See ARMARM
685 // - "Modified Immediate Constants"). Within the MC layer we keep this
686 // immediate in its encoded form.
687 def ModImmAsmOperand: AsmOperandClass {
689 let ParserMethod = "parseModImm";
691 def mod_imm : Operand<i32>, ImmLeaf<i32, [{
692 return ARM_AM::getSOImmVal(Imm) != -1;
694 let EncoderMethod = "getModImmOpValue";
695 let PrintMethod = "printModImmOperand";
696 let ParserMatchClass = ModImmAsmOperand;
699 // Note: the patterns mod_imm_not and mod_imm_neg do not require an encoder
700 // method and such, as they are only used on aliases (Pat<> and InstAlias<>).
701 // The actual parsing, encoding, decoding are handled by the destination
702 // instructions, which use mod_imm.
704 def ModImmNotAsmOperand : AsmOperandClass { let Name = "ModImmNot"; }
705 def mod_imm_not : Operand<i32>, PatLeaf<(imm), [{
706 return ARM_AM::getSOImmVal(~(uint32_t)N->getZExtValue()) != -1;
708 let ParserMatchClass = ModImmNotAsmOperand;
711 def ModImmNegAsmOperand : AsmOperandClass { let Name = "ModImmNeg"; }
712 def mod_imm_neg : Operand<i32>, PatLeaf<(imm), [{
713 unsigned Value = -(unsigned)N->getZExtValue();
714 return Value && ARM_AM::getSOImmVal(Value) != -1;
716 let ParserMatchClass = ModImmNegAsmOperand;
719 /// arm_i32imm - True for +V6T2, or when isSOImmTwoParVal()
720 def arm_i32imm : PatLeaf<(imm), [{
721 if (Subtarget->useMovt())
723 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
725 // Ideally this would be an IntImmLeaf, but then we wouldn't have access to
726 // the MachineFunction.
727 let GISelPredicateCode = [{
731 const auto &MO = MI.getOperand(1);
734 return ARM_AM::isSOImmTwoPartVal(MO.getCImm()->getZExtValue());
738 /// imm0_1 predicate - Immediate in the range [0,1].
739 def Imm0_1AsmOperand: ImmAsmOperand<0,1> { let Name = "Imm0_1"; }
740 def imm0_1 : Operand<i32> { let ParserMatchClass = Imm0_1AsmOperand; }
742 /// imm0_3 predicate - Immediate in the range [0,3].
743 def Imm0_3AsmOperand: ImmAsmOperand<0,3> { let Name = "Imm0_3"; }
744 def imm0_3 : Operand<i32> { let ParserMatchClass = Imm0_3AsmOperand; }
746 /// imm0_7 predicate - Immediate in the range [0,7].
747 def Imm0_7AsmOperand: ImmAsmOperand<0,7> {
750 def imm0_7 : Operand<i32>, ImmLeaf<i32, [{
751 return Imm >= 0 && Imm < 8;
753 let ParserMatchClass = Imm0_7AsmOperand;
756 /// imm8_255 predicate - Immediate in the range [8,255].
757 def Imm8_255AsmOperand: ImmAsmOperand<8,255> { let Name = "Imm8_255"; }
758 def imm8_255 : Operand<i32>, ImmLeaf<i32, [{
759 return Imm >= 8 && Imm < 256;
761 let ParserMatchClass = Imm8_255AsmOperand;
764 /// imm8 predicate - Immediate is exactly 8.
765 def Imm8AsmOperand: ImmAsmOperand<8,8> { let Name = "Imm8"; }
766 def imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 8; }]> {
767 let ParserMatchClass = Imm8AsmOperand;
770 /// imm16 predicate - Immediate is exactly 16.
771 def Imm16AsmOperand: ImmAsmOperand<16,16> { let Name = "Imm16"; }
772 def imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 16; }]> {
773 let ParserMatchClass = Imm16AsmOperand;
776 /// imm32 predicate - Immediate is exactly 32.
777 def Imm32AsmOperand: ImmAsmOperand<32,32> { let Name = "Imm32"; }
778 def imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 32; }]> {
779 let ParserMatchClass = Imm32AsmOperand;
782 def imm8_or_16 : ImmLeaf<i32, [{ return Imm == 8 || Imm == 16;}]>;
784 /// imm1_7 predicate - Immediate in the range [1,7].
785 def Imm1_7AsmOperand: ImmAsmOperand<1,7> { let Name = "Imm1_7"; }
786 def imm1_7 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 8; }]> {
787 let ParserMatchClass = Imm1_7AsmOperand;
790 /// imm1_15 predicate - Immediate in the range [1,15].
791 def Imm1_15AsmOperand: ImmAsmOperand<1,15> { let Name = "Imm1_15"; }
792 def imm1_15 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 16; }]> {
793 let ParserMatchClass = Imm1_15AsmOperand;
796 /// imm1_31 predicate - Immediate in the range [1,31].
797 def Imm1_31AsmOperand: ImmAsmOperand<1,31> { let Name = "Imm1_31"; }
798 def imm1_31 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 32; }]> {
799 let ParserMatchClass = Imm1_31AsmOperand;
802 /// imm0_15 predicate - Immediate in the range [0,15].
803 def Imm0_15AsmOperand: ImmAsmOperand<0,15> {
804 let Name = "Imm0_15";
806 def imm0_15 : Operand<i32>, ImmLeaf<i32, [{
807 return Imm >= 0 && Imm < 16;
809 let ParserMatchClass = Imm0_15AsmOperand;
812 /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
813 def Imm0_31AsmOperand: ImmAsmOperand<0,31> { let Name = "Imm0_31"; }
814 def imm0_31 : Operand<i32>, ImmLeaf<i32, [{
815 return Imm >= 0 && Imm < 32;
817 let ParserMatchClass = Imm0_31AsmOperand;
820 /// imm0_32 predicate - True if the 32-bit immediate is in the range [0,32].
821 def Imm0_32AsmOperand: ImmAsmOperand<0,32> { let Name = "Imm0_32"; }
822 def imm0_32 : Operand<i32>, ImmLeaf<i32, [{
823 return Imm >= 0 && Imm < 33;
825 let ParserMatchClass = Imm0_32AsmOperand;
828 /// imm0_63 predicate - True if the 32-bit immediate is in the range [0,63].
829 def Imm0_63AsmOperand: ImmAsmOperand<0,63> { let Name = "Imm0_63"; }
830 def imm0_63 : Operand<i32>, ImmLeaf<i32, [{
831 return Imm >= 0 && Imm < 64;
833 let ParserMatchClass = Imm0_63AsmOperand;
836 /// imm0_239 predicate - Immediate in the range [0,239].
837 def Imm0_239AsmOperand : ImmAsmOperand<0,239> {
838 let Name = "Imm0_239";
840 def imm0_239 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 240; }]> {
841 let ParserMatchClass = Imm0_239AsmOperand;
844 /// imm0_255 predicate - Immediate in the range [0,255].
845 def Imm0_255AsmOperand : ImmAsmOperand<0,255> { let Name = "Imm0_255"; }
846 def imm0_255 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 256; }]> {
847 let ParserMatchClass = Imm0_255AsmOperand;
850 /// imm0_65535 - An immediate is in the range [0,65535].
851 def Imm0_65535AsmOperand: ImmAsmOperand<0,65535> { let Name = "Imm0_65535"; }
852 def imm0_65535 : Operand<i32>, ImmLeaf<i32, [{
853 return Imm >= 0 && Imm < 65536;
855 let ParserMatchClass = Imm0_65535AsmOperand;
858 // imm0_65535_neg - An immediate whose negative value is in the range [0.65535].
859 def imm0_65535_neg : Operand<i32>, ImmLeaf<i32, [{
860 return -Imm >= 0 && -Imm < 65536;
863 // imm0_65535_expr - For movt/movw - 16-bit immediate that can also reference
864 // a relocatable expression.
866 // FIXME: This really needs a Thumb version separate from the ARM version.
867 // While the range is the same, and can thus use the same match class,
868 // the encoding is different so it should have a different encoder method.
869 def Imm0_65535ExprAsmOperand: AsmOperandClass {
870 let Name = "Imm0_65535Expr";
871 let RenderMethod = "addImmOperands";
872 let DiagnosticString = "operand must be an immediate in the range [0,0xffff] or a relocatable expression";
875 def imm0_65535_expr : Operand<i32> {
876 let EncoderMethod = "getHiLo16ImmOpValue";
877 let ParserMatchClass = Imm0_65535ExprAsmOperand;
880 def Imm256_65535ExprAsmOperand: ImmAsmOperand<256,65535> { let Name = "Imm256_65535Expr"; }
881 def imm256_65535_expr : Operand<i32> {
882 let ParserMatchClass = Imm256_65535ExprAsmOperand;
885 /// imm24b - True if the 32-bit immediate is encodable in 24 bits.
886 def Imm24bitAsmOperand: ImmAsmOperand<0,0xffffff> {
887 let Name = "Imm24bit";
888 let DiagnosticString = "operand must be an immediate in the range [0,0xffffff]";
890 def imm24b : Operand<i32>, ImmLeaf<i32, [{
891 return Imm >= 0 && Imm <= 0xffffff;
893 let ParserMatchClass = Imm24bitAsmOperand;
897 /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
899 def BitfieldAsmOperand : AsmOperandClass {
900 let Name = "Bitfield";
901 let ParserMethod = "parseBitfield";
904 def bf_inv_mask_imm : Operand<i32>,
906 return ARM::isBitFieldInvertedMask(N->getZExtValue());
908 let EncoderMethod = "getBitfieldInvertedMaskOpValue";
909 let PrintMethod = "printBitfieldInvMaskImmOperand";
910 let DecoderMethod = "DecodeBitfieldMaskOperand";
911 let ParserMatchClass = BitfieldAsmOperand;
912 let GISelPredicateCode = [{
913 // There's better methods of implementing this check. IntImmLeaf<> would be
914 // equivalent and have less boilerplate but we need a test for C++
915 // predicates and this one causes new rules to be imported into GlobalISel
916 // without requiring additional features first.
917 const auto &MO = MI.getOperand(1);
920 return ARM::isBitFieldInvertedMask(MO.getCImm()->getZExtValue());
924 def imm1_32_XFORM: SDNodeXForm<imm, [{
925 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, SDLoc(N),
928 def Imm1_32AsmOperand: ImmAsmOperandMinusOne<1,32> {
929 let Name = "Imm1_32";
931 def imm1_32 : Operand<i32>, PatLeaf<(imm), [{
932 uint64_t Imm = N->getZExtValue();
933 return Imm > 0 && Imm <= 32;
936 let PrintMethod = "printImmPlusOneOperand";
937 let ParserMatchClass = Imm1_32AsmOperand;
940 def imm1_16_XFORM: SDNodeXForm<imm, [{
941 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, SDLoc(N),
944 def Imm1_16AsmOperand: ImmAsmOperandMinusOne<1,16> { let Name = "Imm1_16"; }
945 def imm1_16 : Operand<i32>, ImmLeaf<i32, [{
946 return Imm > 0 && Imm <= 16;
949 let PrintMethod = "printImmPlusOneOperand";
950 let ParserMatchClass = Imm1_16AsmOperand;
953 // Define ARM specific addressing modes.
954 // addrmode_imm12 := reg +/- imm12
956 def MemImm12OffsetAsmOperand : AsmOperandClass { let Name = "MemImm12Offset"; }
957 class AddrMode_Imm12 : MemOperand,
958 ComplexPattern<i32, 2, "SelectAddrModeImm12", []> {
959 // 12-bit immediate operand. Note that instructions using this encode
960 // #0 and #-0 differently. We flag #-0 as the magic value INT32_MIN. All other
961 // immediate values are as normal.
963 let EncoderMethod = "getAddrModeImm12OpValue";
964 let DecoderMethod = "DecodeAddrModeImm12Operand";
965 let ParserMatchClass = MemImm12OffsetAsmOperand;
966 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
969 def addrmode_imm12 : AddrMode_Imm12 {
970 let PrintMethod = "printAddrModeImm12Operand<false>";
973 def addrmode_imm12_pre : AddrMode_Imm12 {
974 let PrintMethod = "printAddrModeImm12Operand<true>";
977 // ldst_so_reg := reg +/- reg shop imm
979 def MemRegOffsetAsmOperand : AsmOperandClass { let Name = "MemRegOffset"; }
980 def ldst_so_reg : MemOperand,
981 ComplexPattern<i32, 3, "SelectLdStSOReg", []> {
982 let EncoderMethod = "getLdStSORegOpValue";
983 // FIXME: Simplify the printer
984 let PrintMethod = "printAddrMode2Operand";
985 let DecoderMethod = "DecodeSORegMemOperand";
986 let ParserMatchClass = MemRegOffsetAsmOperand;
987 let MIOperandInfo = (ops GPR:$base, GPRnopc:$offsreg, i32imm:$shift);
990 // postidx_imm8 := +/- [0,255]
993 // {8} 1 is imm8 is non-negative. 0 otherwise.
994 // {7-0} [0,255] imm8 value.
995 def PostIdxImm8AsmOperand : AsmOperandClass { let Name = "PostIdxImm8"; }
996 def postidx_imm8 : MemOperand {
997 let PrintMethod = "printPostIdxImm8Operand";
998 let ParserMatchClass = PostIdxImm8AsmOperand;
999 let MIOperandInfo = (ops i32imm);
1002 // postidx_imm8s4 := +/- [0,1020]
1005 // {8} 1 is imm8 is non-negative. 0 otherwise.
1006 // {7-0} [0,255] imm8 value, scaled by 4.
1007 def PostIdxImm8s4AsmOperand : AsmOperandClass { let Name = "PostIdxImm8s4"; }
1008 def postidx_imm8s4 : MemOperand {
1009 let PrintMethod = "printPostIdxImm8s4Operand";
1010 let ParserMatchClass = PostIdxImm8s4AsmOperand;
1011 let MIOperandInfo = (ops i32imm);
1015 // postidx_reg := +/- reg
1017 def PostIdxRegAsmOperand : AsmOperandClass {
1018 let Name = "PostIdxReg";
1019 let ParserMethod = "parsePostIdxReg";
1021 def postidx_reg : MemOperand {
1022 let EncoderMethod = "getPostIdxRegOpValue";
1023 let DecoderMethod = "DecodePostIdxReg";
1024 let PrintMethod = "printPostIdxRegOperand";
1025 let ParserMatchClass = PostIdxRegAsmOperand;
1026 let MIOperandInfo = (ops GPRnopc, i32imm);
1029 def PostIdxRegShiftedAsmOperand : AsmOperandClass {
1030 let Name = "PostIdxRegShifted";
1031 let ParserMethod = "parsePostIdxReg";
1033 def am2offset_reg : MemOperand,
1034 ComplexPattern<i32, 2, "SelectAddrMode2OffsetReg",
1035 [], [SDNPWantRoot]> {
1036 let EncoderMethod = "getAddrMode2OffsetOpValue";
1037 let PrintMethod = "printAddrMode2OffsetOperand";
1038 // When using this for assembly, it's always as a post-index offset.
1039 let ParserMatchClass = PostIdxRegShiftedAsmOperand;
1040 let MIOperandInfo = (ops GPRnopc, i32imm);
1043 // FIXME: am2offset_imm should only need the immediate, not the GPR. Having
1044 // the GPR is purely vestigal at this point.
1045 def AM2OffsetImmAsmOperand : AsmOperandClass { let Name = "AM2OffsetImm"; }
1046 def am2offset_imm : MemOperand,
1047 ComplexPattern<i32, 2, "SelectAddrMode2OffsetImm",
1048 [], [SDNPWantRoot]> {
1049 let EncoderMethod = "getAddrMode2OffsetOpValue";
1050 let PrintMethod = "printAddrMode2OffsetOperand";
1051 let ParserMatchClass = AM2OffsetImmAsmOperand;
1052 let MIOperandInfo = (ops GPRnopc, i32imm);
1056 // addrmode3 := reg +/- reg
1057 // addrmode3 := reg +/- imm8
1059 // FIXME: split into imm vs. reg versions.
1060 def AddrMode3AsmOperand : AsmOperandClass { let Name = "AddrMode3"; }
1061 class AddrMode3 : MemOperand,
1062 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
1063 let EncoderMethod = "getAddrMode3OpValue";
1064 let ParserMatchClass = AddrMode3AsmOperand;
1065 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
1068 def addrmode3 : AddrMode3
1070 let PrintMethod = "printAddrMode3Operand<false>";
1073 def addrmode3_pre : AddrMode3
1075 let PrintMethod = "printAddrMode3Operand<true>";
1078 // FIXME: split into imm vs. reg versions.
1079 // FIXME: parser method to handle +/- register.
1080 def AM3OffsetAsmOperand : AsmOperandClass {
1081 let Name = "AM3Offset";
1082 let ParserMethod = "parseAM3Offset";
1084 def am3offset : MemOperand,
1085 ComplexPattern<i32, 2, "SelectAddrMode3Offset",
1086 [], [SDNPWantRoot]> {
1087 let EncoderMethod = "getAddrMode3OffsetOpValue";
1088 let PrintMethod = "printAddrMode3OffsetOperand";
1089 let ParserMatchClass = AM3OffsetAsmOperand;
1090 let MIOperandInfo = (ops GPR, i32imm);
1093 // ldstm_mode := {ia, ib, da, db}
1095 def ldstm_mode : OptionalDefOperand<OtherVT, (ops i32), (ops (i32 1))> {
1096 let EncoderMethod = "getLdStmModeOpValue";
1097 let PrintMethod = "printLdStmModeOperand";
1100 // addrmode5 := reg +/- imm8*4
1102 def AddrMode5AsmOperand : AsmOperandClass { let Name = "AddrMode5"; }
1103 class AddrMode5 : MemOperand,
1104 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
1105 let EncoderMethod = "getAddrMode5OpValue";
1106 let DecoderMethod = "DecodeAddrMode5Operand";
1107 let ParserMatchClass = AddrMode5AsmOperand;
1108 let MIOperandInfo = (ops GPR:$base, i32imm);
1111 def addrmode5 : AddrMode5 {
1112 let PrintMethod = "printAddrMode5Operand<false>";
1115 def addrmode5_pre : AddrMode5 {
1116 let PrintMethod = "printAddrMode5Operand<true>";
1119 // addrmode5fp16 := reg +/- imm8*2
1121 def AddrMode5FP16AsmOperand : AsmOperandClass { let Name = "AddrMode5FP16"; }
1122 class AddrMode5FP16 : Operand<i32>,
1123 ComplexPattern<i32, 2, "SelectAddrMode5FP16", []> {
1124 let EncoderMethod = "getAddrMode5FP16OpValue";
1125 let DecoderMethod = "DecodeAddrMode5FP16Operand";
1126 let ParserMatchClass = AddrMode5FP16AsmOperand;
1127 let MIOperandInfo = (ops GPR:$base, i32imm);
1130 def addrmode5fp16 : AddrMode5FP16 {
1131 let PrintMethod = "printAddrMode5FP16Operand<false>";
1134 // addrmode6 := reg with optional alignment
1136 def AddrMode6AsmOperand : AsmOperandClass { let Name = "AlignedMemory"; }
1137 def addrmode6 : MemOperand,
1138 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1139 let PrintMethod = "printAddrMode6Operand";
1140 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
1141 let EncoderMethod = "getAddrMode6AddressOpValue";
1142 let DecoderMethod = "DecodeAddrMode6Operand";
1143 let ParserMatchClass = AddrMode6AsmOperand;
1146 def am6offset : MemOperand,
1147 ComplexPattern<i32, 1, "SelectAddrMode6Offset",
1148 [], [SDNPWantRoot]> {
1149 let PrintMethod = "printAddrMode6OffsetOperand";
1150 let MIOperandInfo = (ops GPR);
1151 let EncoderMethod = "getAddrMode6OffsetOpValue";
1152 let DecoderMethod = "DecodeGPRRegisterClass";
1155 // Special version of addrmode6 to handle alignment encoding for VST1/VLD1
1156 // (single element from one lane) for size 32.
1157 def addrmode6oneL32 : MemOperand,
1158 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1159 let PrintMethod = "printAddrMode6Operand";
1160 let MIOperandInfo = (ops GPR:$addr, i32imm);
1161 let EncoderMethod = "getAddrMode6OneLane32AddressOpValue";
1164 // Base class for addrmode6 with specific alignment restrictions.
1165 class AddrMode6Align : MemOperand,
1166 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1167 let PrintMethod = "printAddrMode6Operand";
1168 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
1169 let EncoderMethod = "getAddrMode6AddressOpValue";
1170 let DecoderMethod = "DecodeAddrMode6Operand";
1173 // Special version of addrmode6 to handle no allowed alignment encoding for
1174 // VLD/VST instructions and checking the alignment is not specified.
1175 def AddrMode6AlignNoneAsmOperand : AsmOperandClass {
1176 let Name = "AlignedMemoryNone";
1177 let DiagnosticString = "alignment must be omitted";
1179 def addrmode6alignNone : AddrMode6Align {
1180 // The alignment specifier can only be omitted.
1181 let ParserMatchClass = AddrMode6AlignNoneAsmOperand;
1184 // Special version of addrmode6 to handle 16-bit alignment encoding for
1185 // VLD/VST instructions and checking the alignment value.
1186 def AddrMode6Align16AsmOperand : AsmOperandClass {
1187 let Name = "AlignedMemory16";
1188 let DiagnosticString = "alignment must be 16 or omitted";
1190 def addrmode6align16 : AddrMode6Align {
1191 // The alignment specifier can only be 16 or omitted.
1192 let ParserMatchClass = AddrMode6Align16AsmOperand;
1195 // Special version of addrmode6 to handle 32-bit alignment encoding for
1196 // VLD/VST instructions and checking the alignment value.
1197 def AddrMode6Align32AsmOperand : AsmOperandClass {
1198 let Name = "AlignedMemory32";
1199 let DiagnosticString = "alignment must be 32 or omitted";
1201 def addrmode6align32 : AddrMode6Align {
1202 // The alignment specifier can only be 32 or omitted.
1203 let ParserMatchClass = AddrMode6Align32AsmOperand;
1206 // Special version of addrmode6 to handle 64-bit alignment encoding for
1207 // VLD/VST instructions and checking the alignment value.
1208 def AddrMode6Align64AsmOperand : AsmOperandClass {
1209 let Name = "AlignedMemory64";
1210 let DiagnosticString = "alignment must be 64 or omitted";
1212 def addrmode6align64 : AddrMode6Align {
1213 // The alignment specifier can only be 64 or omitted.
1214 let ParserMatchClass = AddrMode6Align64AsmOperand;
1217 // Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding
1218 // for VLD/VST instructions and checking the alignment value.
1219 def AddrMode6Align64or128AsmOperand : AsmOperandClass {
1220 let Name = "AlignedMemory64or128";
1221 let DiagnosticString = "alignment must be 64, 128 or omitted";
1223 def addrmode6align64or128 : AddrMode6Align {
1224 // The alignment specifier can only be 64, 128 or omitted.
1225 let ParserMatchClass = AddrMode6Align64or128AsmOperand;
1228 // Special version of addrmode6 to handle 64-bit, 128-bit or 256-bit alignment
1229 // encoding for VLD/VST instructions and checking the alignment value.
1230 def AddrMode6Align64or128or256AsmOperand : AsmOperandClass {
1231 let Name = "AlignedMemory64or128or256";
1232 let DiagnosticString = "alignment must be 64, 128, 256 or omitted";
1234 def addrmode6align64or128or256 : AddrMode6Align {
1235 // The alignment specifier can only be 64, 128, 256 or omitted.
1236 let ParserMatchClass = AddrMode6Align64or128or256AsmOperand;
1239 // Special version of addrmode6 to handle alignment encoding for VLD-dup
1240 // instructions, specifically VLD4-dup.
1241 def addrmode6dup : MemOperand,
1242 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1243 let PrintMethod = "printAddrMode6Operand";
1244 let MIOperandInfo = (ops GPR:$addr, i32imm);
1245 let EncoderMethod = "getAddrMode6DupAddressOpValue";
1246 // FIXME: This is close, but not quite right. The alignment specifier is
1248 let ParserMatchClass = AddrMode6AsmOperand;
1251 // Base class for addrmode6dup with specific alignment restrictions.
1252 class AddrMode6DupAlign : MemOperand,
1253 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1254 let PrintMethod = "printAddrMode6Operand";
1255 let MIOperandInfo = (ops GPR:$addr, i32imm);
1256 let EncoderMethod = "getAddrMode6DupAddressOpValue";
1259 // Special version of addrmode6 to handle no allowed alignment encoding for
1260 // VLD-dup instruction and checking the alignment is not specified.
1261 def AddrMode6dupAlignNoneAsmOperand : AsmOperandClass {
1262 let Name = "DupAlignedMemoryNone";
1263 let DiagnosticString = "alignment must be omitted";
1265 def addrmode6dupalignNone : AddrMode6DupAlign {
1266 // The alignment specifier can only be omitted.
1267 let ParserMatchClass = AddrMode6dupAlignNoneAsmOperand;
1270 // Special version of addrmode6 to handle 16-bit alignment encoding for VLD-dup
1271 // instruction and checking the alignment value.
1272 def AddrMode6dupAlign16AsmOperand : AsmOperandClass {
1273 let Name = "DupAlignedMemory16";
1274 let DiagnosticString = "alignment must be 16 or omitted";
1276 def addrmode6dupalign16 : AddrMode6DupAlign {
1277 // The alignment specifier can only be 16 or omitted.
1278 let ParserMatchClass = AddrMode6dupAlign16AsmOperand;
1281 // Special version of addrmode6 to handle 32-bit alignment encoding for VLD-dup
1282 // instruction and checking the alignment value.
1283 def AddrMode6dupAlign32AsmOperand : AsmOperandClass {
1284 let Name = "DupAlignedMemory32";
1285 let DiagnosticString = "alignment must be 32 or omitted";
1287 def addrmode6dupalign32 : AddrMode6DupAlign {
1288 // The alignment specifier can only be 32 or omitted.
1289 let ParserMatchClass = AddrMode6dupAlign32AsmOperand;
1292 // Special version of addrmode6 to handle 64-bit alignment encoding for VLD
1293 // instructions and checking the alignment value.
1294 def AddrMode6dupAlign64AsmOperand : AsmOperandClass {
1295 let Name = "DupAlignedMemory64";
1296 let DiagnosticString = "alignment must be 64 or omitted";
1298 def addrmode6dupalign64 : AddrMode6DupAlign {
1299 // The alignment specifier can only be 64 or omitted.
1300 let ParserMatchClass = AddrMode6dupAlign64AsmOperand;
1303 // Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding
1304 // for VLD instructions and checking the alignment value.
1305 def AddrMode6dupAlign64or128AsmOperand : AsmOperandClass {
1306 let Name = "DupAlignedMemory64or128";
1307 let DiagnosticString = "alignment must be 64, 128 or omitted";
1309 def addrmode6dupalign64or128 : AddrMode6DupAlign {
1310 // The alignment specifier can only be 64, 128 or omitted.
1311 let ParserMatchClass = AddrMode6dupAlign64or128AsmOperand;
1314 // addrmodepc := pc + reg
1316 def addrmodepc : MemOperand,
1317 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
1318 let PrintMethod = "printAddrModePCOperand";
1319 let MIOperandInfo = (ops GPR, i32imm);
1322 // addr_offset_none := reg
1324 def MemNoOffsetAsmOperand : AsmOperandClass { let Name = "MemNoOffset"; }
1325 def addr_offset_none : MemOperand,
1326 ComplexPattern<i32, 1, "SelectAddrOffsetNone", []> {
1327 let PrintMethod = "printAddrMode7Operand";
1328 let DecoderMethod = "DecodeAddrMode7Operand";
1329 let ParserMatchClass = MemNoOffsetAsmOperand;
1330 let MIOperandInfo = (ops GPR:$base);
1333 def nohash_imm : Operand<i32> {
1334 let PrintMethod = "printNoHashImmediate";
1337 def CoprocNumAsmOperand : AsmOperandClass {
1338 let Name = "CoprocNum";
1339 let ParserMethod = "parseCoprocNumOperand";
1341 def p_imm : Operand<i32> {
1342 let PrintMethod = "printPImmediate";
1343 let ParserMatchClass = CoprocNumAsmOperand;
1344 let DecoderMethod = "DecodeCoprocessor";
1347 def CoprocRegAsmOperand : AsmOperandClass {
1348 let Name = "CoprocReg";
1349 let ParserMethod = "parseCoprocRegOperand";
1351 def c_imm : Operand<i32> {
1352 let PrintMethod = "printCImmediate";
1353 let ParserMatchClass = CoprocRegAsmOperand;
1355 def CoprocOptionAsmOperand : AsmOperandClass {
1356 let Name = "CoprocOption";
1357 let ParserMethod = "parseCoprocOptionOperand";
1359 def coproc_option_imm : Operand<i32> {
1360 let PrintMethod = "printCoprocOptionImm";
1361 let ParserMatchClass = CoprocOptionAsmOperand;
1364 //===----------------------------------------------------------------------===//
1366 include "ARMInstrFormats.td"
1368 //===----------------------------------------------------------------------===//
1369 // Multiclass helpers...
1372 /// AsI1_bin_irs - Defines a set of (op r, {mod_imm|r|so_reg}) patterns for a
1373 /// binop that produces a value.
1374 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1375 multiclass AsI1_bin_irs<bits<4> opcod, string opc,
1376 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1377 SDPatternOperator opnode, bit Commutable = 0> {
1378 // The register-immediate version is re-materializable. This is useful
1379 // in particular for taking the address of a local.
1380 let isReMaterializable = 1 in {
1381 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm,
1382 iii, opc, "\t$Rd, $Rn, $imm",
1383 [(set GPR:$Rd, (opnode GPR:$Rn, mod_imm:$imm))]>,
1384 Sched<[WriteALU, ReadALU]> {
1389 let Inst{19-16} = Rn;
1390 let Inst{15-12} = Rd;
1391 let Inst{11-0} = imm;
1394 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1395 iir, opc, "\t$Rd, $Rn, $Rm",
1396 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]>,
1397 Sched<[WriteALU, ReadALU, ReadALU]> {
1402 let isCommutable = Commutable;
1403 let Inst{19-16} = Rn;
1404 let Inst{15-12} = Rd;
1405 let Inst{11-4} = 0b00000000;
1409 def rsi : AsI1<opcod, (outs GPR:$Rd),
1410 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1411 iis, opc, "\t$Rd, $Rn, $shift",
1412 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_imm:$shift))]>,
1413 Sched<[WriteALUsi, ReadALU]> {
1418 let Inst{19-16} = Rn;
1419 let Inst{15-12} = Rd;
1420 let Inst{11-5} = shift{11-5};
1422 let Inst{3-0} = shift{3-0};
1425 def rsr : AsI1<opcod, (outs GPR:$Rd),
1426 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1427 iis, opc, "\t$Rd, $Rn, $shift",
1428 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_reg:$shift))]>,
1429 Sched<[WriteALUsr, ReadALUsr]> {
1434 let Inst{19-16} = Rn;
1435 let Inst{15-12} = Rd;
1436 let Inst{11-8} = shift{11-8};
1438 let Inst{6-5} = shift{6-5};
1440 let Inst{3-0} = shift{3-0};
1444 /// AsI1_rbin_irs - Same as AsI1_bin_irs except the order of operands are
1445 /// reversed. The 'rr' form is only defined for the disassembler; for codegen
1446 /// it is equivalent to the AsI1_bin_irs counterpart.
1447 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1448 multiclass AsI1_rbin_irs<bits<4> opcod, string opc,
1449 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1450 SDNode opnode, bit Commutable = 0> {
1451 // The register-immediate version is re-materializable. This is useful
1452 // in particular for taking the address of a local.
1453 let isReMaterializable = 1 in {
1454 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm,
1455 iii, opc, "\t$Rd, $Rn, $imm",
1456 [(set GPR:$Rd, (opnode mod_imm:$imm, GPR:$Rn))]>,
1457 Sched<[WriteALU, ReadALU]> {
1462 let Inst{19-16} = Rn;
1463 let Inst{15-12} = Rd;
1464 let Inst{11-0} = imm;
1467 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1468 iir, opc, "\t$Rd, $Rn, $Rm",
1469 [/* pattern left blank */]>,
1470 Sched<[WriteALU, ReadALU, ReadALU]> {
1474 let Inst{11-4} = 0b00000000;
1477 let Inst{15-12} = Rd;
1478 let Inst{19-16} = Rn;
1481 def rsi : AsI1<opcod, (outs GPR:$Rd),
1482 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1483 iis, opc, "\t$Rd, $Rn, $shift",
1484 [(set GPR:$Rd, (opnode so_reg_imm:$shift, GPR:$Rn))]>,
1485 Sched<[WriteALUsi, ReadALU]> {
1490 let Inst{19-16} = Rn;
1491 let Inst{15-12} = Rd;
1492 let Inst{11-5} = shift{11-5};
1494 let Inst{3-0} = shift{3-0};
1497 def rsr : AsI1<opcod, (outs GPR:$Rd),
1498 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1499 iis, opc, "\t$Rd, $Rn, $shift",
1500 [(set GPR:$Rd, (opnode so_reg_reg:$shift, GPR:$Rn))]>,
1501 Sched<[WriteALUsr, ReadALUsr]> {
1506 let Inst{19-16} = Rn;
1507 let Inst{15-12} = Rd;
1508 let Inst{11-8} = shift{11-8};
1510 let Inst{6-5} = shift{6-5};
1512 let Inst{3-0} = shift{3-0};
1516 /// AsI1_bin_s_irs - Same as AsI1_bin_irs except it sets the 's' bit by default.
1518 /// These opcodes will be converted to the real non-S opcodes by
1519 /// AdjustInstrPostInstrSelection after giving them an optional CPSR operand.
1520 let hasPostISelHook = 1, Defs = [CPSR] in {
1521 multiclass AsI1_bin_s_irs<InstrItinClass iii, InstrItinClass iir,
1522 InstrItinClass iis, SDNode opnode,
1523 bit Commutable = 0> {
1524 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p),
1526 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm))]>,
1527 Sched<[WriteALU, ReadALU]>;
1529 def rr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, pred:$p),
1531 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm))]>,
1532 Sched<[WriteALU, ReadALU, ReadALU]> {
1533 let isCommutable = Commutable;
1535 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1536 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1538 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1539 so_reg_imm:$shift))]>,
1540 Sched<[WriteALUsi, ReadALU]>;
1542 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1543 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1545 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1546 so_reg_reg:$shift))]>,
1547 Sched<[WriteALUSsr, ReadALUsr]>;
1551 /// AsI1_rbin_s_is - Same as AsI1_bin_s_irs, except selection DAG
1552 /// operands are reversed.
1553 let hasPostISelHook = 1, Defs = [CPSR] in {
1554 multiclass AsI1_rbin_s_is<InstrItinClass iii, InstrItinClass iir,
1555 InstrItinClass iis, SDNode opnode,
1556 bit Commutable = 0> {
1557 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p),
1559 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn))]>,
1560 Sched<[WriteALU, ReadALU]>;
1562 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1563 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1565 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift,
1567 Sched<[WriteALUsi, ReadALU]>;
1569 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1570 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1572 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift,
1574 Sched<[WriteALUSsr, ReadALUsr]>;
1578 /// AI1_cmp_irs - Defines a set of (op r, {mod_imm|r|so_reg}) cmp / test
1579 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
1580 /// a explicit result, only implicitly set CPSR.
1581 let isCompare = 1, Defs = [CPSR] in {
1582 multiclass AI1_cmp_irs<bits<4> opcod, string opc,
1583 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1584 SDPatternOperator opnode, bit Commutable = 0,
1585 string rrDecoderMethod = ""> {
1586 def ri : AI1<opcod, (outs), (ins GPR:$Rn, mod_imm:$imm), DPFrm, iii,
1588 [(opnode GPR:$Rn, mod_imm:$imm)]>,
1589 Sched<[WriteCMP, ReadALU]> {
1594 let Inst{19-16} = Rn;
1595 let Inst{15-12} = 0b0000;
1596 let Inst{11-0} = imm;
1598 let Unpredictable{15-12} = 0b1111;
1600 def rr : AI1<opcod, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, iir,
1602 [(opnode GPR:$Rn, GPR:$Rm)]>,
1603 Sched<[WriteCMP, ReadALU, ReadALU]> {
1606 let isCommutable = Commutable;
1609 let Inst{19-16} = Rn;
1610 let Inst{15-12} = 0b0000;
1611 let Inst{11-4} = 0b00000000;
1613 let DecoderMethod = rrDecoderMethod;
1615 let Unpredictable{15-12} = 0b1111;
1617 def rsi : AI1<opcod, (outs),
1618 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, iis,
1619 opc, "\t$Rn, $shift",
1620 [(opnode GPR:$Rn, so_reg_imm:$shift)]>,
1621 Sched<[WriteCMPsi, ReadALU]> {
1626 let Inst{19-16} = Rn;
1627 let Inst{15-12} = 0b0000;
1628 let Inst{11-5} = shift{11-5};
1630 let Inst{3-0} = shift{3-0};
1632 let Unpredictable{15-12} = 0b1111;
1634 def rsr : AI1<opcod, (outs),
1635 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, iis,
1636 opc, "\t$Rn, $shift",
1637 [(opnode GPRnopc:$Rn, so_reg_reg:$shift)]>,
1638 Sched<[WriteCMPsr, ReadALU]> {
1643 let Inst{19-16} = Rn;
1644 let Inst{15-12} = 0b0000;
1645 let Inst{11-8} = shift{11-8};
1647 let Inst{6-5} = shift{6-5};
1649 let Inst{3-0} = shift{3-0};
1651 let Unpredictable{15-12} = 0b1111;
1657 /// AI_ext_rrot - A unary operation with two forms: one whose operand is a
1658 /// register and one whose operand is a register rotated by 8/16/24.
1659 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
1660 class AI_ext_rrot<bits<8> opcod, string opc, PatFrag opnode>
1661 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1662 IIC_iEXTr, opc, "\t$Rd, $Rm$rot",
1663 [(set GPRnopc:$Rd, (opnode (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1664 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> {
1668 let Inst{19-16} = 0b1111;
1669 let Inst{15-12} = Rd;
1670 let Inst{11-10} = rot;
1674 class AI_ext_rrot_np<bits<8> opcod, string opc>
1675 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1676 IIC_iEXTr, opc, "\t$Rd, $Rm$rot", []>,
1677 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> {
1679 let Inst{19-16} = 0b1111;
1680 let Inst{11-10} = rot;
1683 /// AI_exta_rrot - A binary operation with two forms: one whose operand is a
1684 /// register and one whose operand is a register rotated by 8/16/24.
1685 class AI_exta_rrot<bits<8> opcod, string opc, PatFrag opnode>
1686 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1687 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot",
1688 [(set GPRnopc:$Rd, (opnode GPR:$Rn,
1689 (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1690 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> {
1695 let Inst{19-16} = Rn;
1696 let Inst{15-12} = Rd;
1697 let Inst{11-10} = rot;
1698 let Inst{9-4} = 0b000111;
1702 class AI_exta_rrot_np<bits<8> opcod, string opc>
1703 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1704 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot", []>,
1705 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> {
1708 let Inst{19-16} = Rn;
1709 let Inst{11-10} = rot;
1712 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
1713 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1714 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, SDNode opnode,
1715 bit Commutable = 0> {
1716 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1717 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm),
1718 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1719 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm, CPSR))]>,
1721 Sched<[WriteALU, ReadALU]> {
1726 let Inst{15-12} = Rd;
1727 let Inst{19-16} = Rn;
1728 let Inst{11-0} = imm;
1730 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1731 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1732 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm, CPSR))]>,
1734 Sched<[WriteALU, ReadALU, ReadALU]> {
1738 let Inst{11-4} = 0b00000000;
1740 let isCommutable = Commutable;
1742 let Inst{15-12} = Rd;
1743 let Inst{19-16} = Rn;
1745 def rsi : AsI1<opcod, (outs GPR:$Rd),
1746 (ins GPR:$Rn, so_reg_imm:$shift),
1747 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1748 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_imm:$shift, CPSR))]>,
1750 Sched<[WriteALUsi, ReadALU]> {
1755 let Inst{19-16} = Rn;
1756 let Inst{15-12} = Rd;
1757 let Inst{11-5} = shift{11-5};
1759 let Inst{3-0} = shift{3-0};
1761 def rsr : AsI1<opcod, (outs GPRnopc:$Rd),
1762 (ins GPRnopc:$Rn, so_reg_reg:$shift),
1763 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1764 [(set GPRnopc:$Rd, CPSR,
1765 (opnode GPRnopc:$Rn, so_reg_reg:$shift, CPSR))]>,
1767 Sched<[WriteALUsr, ReadALUsr]> {
1772 let Inst{19-16} = Rn;
1773 let Inst{15-12} = Rd;
1774 let Inst{11-8} = shift{11-8};
1776 let Inst{6-5} = shift{6-5};
1778 let Inst{3-0} = shift{3-0};
1783 /// AI1_rsc_irs - Define instructions and patterns for rsc
1784 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1785 multiclass AI1_rsc_irs<bits<4> opcod, string opc, SDNode opnode> {
1786 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1787 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm),
1788 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1789 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn, CPSR))]>,
1791 Sched<[WriteALU, ReadALU]> {
1796 let Inst{15-12} = Rd;
1797 let Inst{19-16} = Rn;
1798 let Inst{11-0} = imm;
1800 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1801 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1802 [/* pattern left blank */]>,
1803 Sched<[WriteALU, ReadALU, ReadALU]> {
1807 let Inst{11-4} = 0b00000000;
1810 let Inst{15-12} = Rd;
1811 let Inst{19-16} = Rn;
1813 def rsi : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_imm:$shift),
1814 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1815 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift, GPR:$Rn, CPSR))]>,
1817 Sched<[WriteALUsi, ReadALU]> {
1822 let Inst{19-16} = Rn;
1823 let Inst{15-12} = Rd;
1824 let Inst{11-5} = shift{11-5};
1826 let Inst{3-0} = shift{3-0};
1828 def rsr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_reg:$shift),
1829 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1830 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift, GPR:$Rn, CPSR))]>,
1832 Sched<[WriteALUsr, ReadALUsr]> {
1837 let Inst{19-16} = Rn;
1838 let Inst{15-12} = Rd;
1839 let Inst{11-8} = shift{11-8};
1841 let Inst{6-5} = shift{6-5};
1843 let Inst{3-0} = shift{3-0};
1848 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1849 multiclass AI_ldr1<bit isByte, string opc, InstrItinClass iii,
1850 InstrItinClass iir, PatFrag opnode> {
1851 // Note: We use the complex addrmode_imm12 rather than just an input
1852 // GPR and a constrained immediate so that we can use this to match
1853 // frame index references and avoid matching constant pool references.
1854 def i12: AI2ldst<0b010, 1, isByte, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
1855 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1856 [(set GPR:$Rt, (opnode addrmode_imm12:$addr))]> {
1859 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1860 let Inst{19-16} = addr{16-13}; // Rn
1861 let Inst{15-12} = Rt;
1862 let Inst{11-0} = addr{11-0}; // imm12
1864 def rs : AI2ldst<0b011, 1, isByte, (outs GPR:$Rt), (ins ldst_so_reg:$shift),
1865 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1866 [(set GPR:$Rt, (opnode ldst_so_reg:$shift))]> {
1869 let shift{4} = 0; // Inst{4} = 0
1870 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1871 let Inst{19-16} = shift{16-13}; // Rn
1872 let Inst{15-12} = Rt;
1873 let Inst{11-0} = shift{11-0};
1878 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1879 multiclass AI_ldr1nopc<bit isByte, string opc, InstrItinClass iii,
1880 InstrItinClass iir, PatFrag opnode> {
1881 // Note: We use the complex addrmode_imm12 rather than just an input
1882 // GPR and a constrained immediate so that we can use this to match
1883 // frame index references and avoid matching constant pool references.
1884 def i12: AI2ldst<0b010, 1, isByte, (outs GPRnopc:$Rt),
1885 (ins addrmode_imm12:$addr),
1886 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1887 [(set GPRnopc:$Rt, (opnode addrmode_imm12:$addr))]> {
1890 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1891 let Inst{19-16} = addr{16-13}; // Rn
1892 let Inst{15-12} = Rt;
1893 let Inst{11-0} = addr{11-0}; // imm12
1895 def rs : AI2ldst<0b011, 1, isByte, (outs GPRnopc:$Rt),
1896 (ins ldst_so_reg:$shift),
1897 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1898 [(set GPRnopc:$Rt, (opnode ldst_so_reg:$shift))]> {
1901 let shift{4} = 0; // Inst{4} = 0
1902 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1903 let Inst{19-16} = shift{16-13}; // Rn
1904 let Inst{15-12} = Rt;
1905 let Inst{11-0} = shift{11-0};
1911 multiclass AI_str1<bit isByte, string opc, InstrItinClass iii,
1912 InstrItinClass iir, PatFrag opnode> {
1913 // Note: We use the complex addrmode_imm12 rather than just an input
1914 // GPR and a constrained immediate so that we can use this to match
1915 // frame index references and avoid matching constant pool references.
1916 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1917 (ins GPR:$Rt, addrmode_imm12:$addr),
1918 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1919 [(opnode GPR:$Rt, addrmode_imm12:$addr)]> {
1922 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1923 let Inst{19-16} = addr{16-13}; // Rn
1924 let Inst{15-12} = Rt;
1925 let Inst{11-0} = addr{11-0}; // imm12
1927 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPR:$Rt, ldst_so_reg:$shift),
1928 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1929 [(opnode GPR:$Rt, ldst_so_reg:$shift)]> {
1932 let shift{4} = 0; // Inst{4} = 0
1933 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1934 let Inst{19-16} = shift{16-13}; // Rn
1935 let Inst{15-12} = Rt;
1936 let Inst{11-0} = shift{11-0};
1940 multiclass AI_str1nopc<bit isByte, string opc, InstrItinClass iii,
1941 InstrItinClass iir, PatFrag opnode> {
1942 // Note: We use the complex addrmode_imm12 rather than just an input
1943 // GPR and a constrained immediate so that we can use this to match
1944 // frame index references and avoid matching constant pool references.
1945 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1946 (ins GPRnopc:$Rt, addrmode_imm12:$addr),
1947 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1948 [(opnode GPRnopc:$Rt, addrmode_imm12:$addr)]> {
1951 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1952 let Inst{19-16} = addr{16-13}; // Rn
1953 let Inst{15-12} = Rt;
1954 let Inst{11-0} = addr{11-0}; // imm12
1956 def rs : AI2ldst<0b011, 0, isByte, (outs),
1957 (ins GPRnopc:$Rt, ldst_so_reg:$shift),
1958 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1959 [(opnode GPRnopc:$Rt, ldst_so_reg:$shift)]> {
1962 let shift{4} = 0; // Inst{4} = 0
1963 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1964 let Inst{19-16} = shift{16-13}; // Rn
1965 let Inst{15-12} = Rt;
1966 let Inst{11-0} = shift{11-0};
1971 //===----------------------------------------------------------------------===//
1973 //===----------------------------------------------------------------------===//
1975 //===----------------------------------------------------------------------===//
1976 // Miscellaneous Instructions.
1979 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
1980 /// the function. The first operand is the ID# for this instruction, the second
1981 /// is the index into the MachineConstantPool that this is, the third is the
1982 /// size in bytes of this constant pool entry.
1983 let hasSideEffects = 0, isNotDuplicable = 1 in
1984 def CONSTPOOL_ENTRY :
1985 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1986 i32imm:$size), NoItinerary, []>;
1988 /// A jumptable consisting of direct 32-bit addresses of the destination basic
1989 /// blocks (either absolute, or relative to the start of the jump-table in PIC
1990 /// mode). Used mostly in ARM and Thumb-1 modes.
1991 def JUMPTABLE_ADDRS :
1992 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1993 i32imm:$size), NoItinerary, []>;
1995 /// A jumptable consisting of 32-bit jump instructions. Used for Thumb-2 tables
1996 /// that cannot be optimised to use TBB or TBH.
1997 def JUMPTABLE_INSTS :
1998 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1999 i32imm:$size), NoItinerary, []>;
2001 /// A jumptable consisting of 8-bit unsigned integers representing offsets from
2002 /// a TBB instruction.
2004 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
2005 i32imm:$size), NoItinerary, []>;
2007 /// A jumptable consisting of 16-bit unsigned integers representing offsets from
2008 /// a TBH instruction.
2010 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
2011 i32imm:$size), NoItinerary, []>;
2014 // FIXME: Marking these as hasSideEffects is necessary to prevent machine DCE
2015 // from removing one half of the matched pairs. That breaks PEI, which assumes
2016 // these will always be in pairs, and asserts if it finds otherwise. Better way?
2017 let Defs = [SP], Uses = [SP], hasSideEffects = 1 in {
2018 def ADJCALLSTACKUP :
2019 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary,
2020 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
2022 def ADJCALLSTACKDOWN :
2023 PseudoInst<(outs), (ins i32imm:$amt, i32imm:$amt2, pred:$p), NoItinerary,
2024 [(ARMcallseq_start timm:$amt, timm:$amt2)]>;
2027 def HINT : AI<(outs), (ins imm0_239:$imm), MiscFrm, NoItinerary,
2028 "hint", "\t$imm", [(int_arm_hint imm0_239:$imm)]>,
2029 Requires<[IsARM, HasV6]> {
2031 let Inst{27-8} = 0b00110010000011110000;
2032 let Inst{7-0} = imm;
2033 let DecoderMethod = "DecodeHINTInstruction";
2036 def : InstAlias<"nop$p", (HINT 0, pred:$p)>, Requires<[IsARM, HasV6K]>;
2037 def : InstAlias<"yield$p", (HINT 1, pred:$p)>, Requires<[IsARM, HasV6K]>;
2038 def : InstAlias<"wfe$p", (HINT 2, pred:$p)>, Requires<[IsARM, HasV6K]>;
2039 def : InstAlias<"wfi$p", (HINT 3, pred:$p)>, Requires<[IsARM, HasV6K]>;
2040 def : InstAlias<"sev$p", (HINT 4, pred:$p)>, Requires<[IsARM, HasV6K]>;
2041 def : InstAlias<"sevl$p", (HINT 5, pred:$p)>, Requires<[IsARM, HasV8]>;
2042 def : InstAlias<"esb$p", (HINT 16, pred:$p)>, Requires<[IsARM, HasRAS]>;
2043 def : InstAlias<"csdb$p", (HINT 20, pred:$p)>, Requires<[IsARM, HasV6K]>;
2045 def SEL : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, NoItinerary, "sel",
2047 [(set GPR:$Rd, (int_arm_sel GPR:$Rn, GPR:$Rm))]>,
2048 Requires<[IsARM, HasV6]> {
2053 let Inst{15-12} = Rd;
2054 let Inst{19-16} = Rn;
2055 let Inst{27-20} = 0b01101000;
2056 let Inst{7-4} = 0b1011;
2057 let Inst{11-8} = 0b1111;
2058 let Unpredictable{11-8} = 0b1111;
2061 // The 16-bit operand $val can be used by a debugger to store more information
2062 // about the breakpoint.
2063 def BKPT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
2064 "bkpt", "\t$val", []>, Requires<[IsARM]> {
2066 let Inst{3-0} = val{3-0};
2067 let Inst{19-8} = val{15-4};
2068 let Inst{27-20} = 0b00010010;
2069 let Inst{31-28} = 0xe; // AL
2070 let Inst{7-4} = 0b0111;
2072 // default immediate for breakpoint mnemonic
2073 def : InstAlias<"bkpt", (BKPT 0), 0>, Requires<[IsARM]>;
2075 def HLT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
2076 "hlt", "\t$val", []>, Requires<[IsARM, HasV8]> {
2078 let Inst{3-0} = val{3-0};
2079 let Inst{19-8} = val{15-4};
2080 let Inst{27-20} = 0b00010000;
2081 let Inst{31-28} = 0xe; // AL
2082 let Inst{7-4} = 0b0111;
2085 // Change Processor State
2086 // FIXME: We should use InstAlias to handle the optional operands.
2087 class CPS<dag iops, string asm_ops>
2088 : AXI<(outs), iops, MiscFrm, NoItinerary, !strconcat("cps", asm_ops),
2089 []>, Requires<[IsARM]> {
2095 let Inst{31-28} = 0b1111;
2096 let Inst{27-20} = 0b00010000;
2097 let Inst{19-18} = imod;
2098 let Inst{17} = M; // Enabled if mode is set;
2099 let Inst{16-9} = 0b00000000;
2100 let Inst{8-6} = iflags;
2102 let Inst{4-0} = mode;
2105 let DecoderMethod = "DecodeCPSInstruction" in {
2107 def CPS3p : CPS<(ins imod_op:$imod, iflags_op:$iflags, imm0_31:$mode),
2108 "$imod\t$iflags, $mode">;
2109 let mode = 0, M = 0 in
2110 def CPS2p : CPS<(ins imod_op:$imod, iflags_op:$iflags), "$imod\t$iflags">;
2112 let imod = 0, iflags = 0, M = 1 in
2113 def CPS1p : CPS<(ins imm0_31:$mode), "\t$mode">;
2116 // Preload signals the memory system of possible future data/instruction access.
2117 multiclass APreLoad<bits<1> read, bits<1> data, string opc> {
2119 def i12 : AXIM<(outs), (ins addrmode_imm12:$addr), AddrMode_i12, MiscFrm,
2120 IIC_Preload, !strconcat(opc, "\t$addr"),
2121 [(ARMPreload addrmode_imm12:$addr, (i32 read), (i32 data))]>,
2122 Sched<[WritePreLd]> {
2125 let Inst{31-26} = 0b111101;
2126 let Inst{25} = 0; // 0 for immediate form
2127 let Inst{24} = data;
2128 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2129 let Inst{22} = read;
2130 let Inst{21-20} = 0b01;
2131 let Inst{19-16} = addr{16-13}; // Rn
2132 let Inst{15-12} = 0b1111;
2133 let Inst{11-0} = addr{11-0}; // imm12
2136 def rs : AXI<(outs), (ins ldst_so_reg:$shift), MiscFrm, IIC_Preload,
2137 !strconcat(opc, "\t$shift"),
2138 [(ARMPreload ldst_so_reg:$shift, (i32 read), (i32 data))]>,
2139 Sched<[WritePreLd]> {
2141 let Inst{31-26} = 0b111101;
2142 let Inst{25} = 1; // 1 for register form
2143 let Inst{24} = data;
2144 let Inst{23} = shift{12}; // U (add = ('U' == 1))
2145 let Inst{22} = read;
2146 let Inst{21-20} = 0b01;
2147 let Inst{19-16} = shift{16-13}; // Rn
2148 let Inst{15-12} = 0b1111;
2149 let Inst{11-0} = shift{11-0};
2154 defm PLD : APreLoad<1, 1, "pld">, Requires<[IsARM]>;
2155 defm PLDW : APreLoad<0, 1, "pldw">, Requires<[IsARM,HasV7,HasMP]>;
2156 defm PLI : APreLoad<1, 0, "pli">, Requires<[IsARM,HasV7]>;
2158 def SETEND : AXI<(outs), (ins setend_op:$end), MiscFrm, NoItinerary,
2159 "setend\t$end", []>, Requires<[IsARM]>, Deprecated<HasV8Ops> {
2161 let Inst{31-10} = 0b1111000100000001000000;
2166 def DBG : AI<(outs), (ins imm0_15:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt",
2167 [(int_arm_dbg imm0_15:$opt)]>, Requires<[IsARM, HasV7]> {
2169 let Inst{27-4} = 0b001100100000111100001111;
2170 let Inst{3-0} = opt;
2173 // A8.8.247 UDF - Undefined (Encoding A1)
2174 def UDF : AInoP<(outs), (ins imm0_65535:$imm16), MiscFrm, NoItinerary,
2175 "udf", "\t$imm16", [(int_arm_undefined imm0_65535:$imm16)]> {
2177 let Inst{31-28} = 0b1110; // AL
2178 let Inst{27-25} = 0b011;
2179 let Inst{24-20} = 0b11111;
2180 let Inst{19-8} = imm16{15-4};
2181 let Inst{7-4} = 0b1111;
2182 let Inst{3-0} = imm16{3-0};
2186 * A5.4 Permanently UNDEFINED instructions.
2188 * For most targets use UDF #65006, for which the OS will generate SIGTRAP.
2189 * Other UDF encodings generate SIGILL.
2191 * NaCl's OS instead chooses an ARM UDF encoding that's also a UDF in Thumb.
2193 * 1110 0111 1111 iiii iiii iiii 1111 iiii
2195 * 1101 1110 iiii iiii
2196 * It uses the following encoding:
2197 * 1110 0111 1111 1110 1101 1110 1111 0000
2198 * - In ARM: UDF #60896;
2199 * - In Thumb: UDF #254 followed by a branch-to-self.
2201 let isBarrier = 1, isTerminator = 1 in
2202 def TRAPNaCl : AXI<(outs), (ins), MiscFrm, NoItinerary,
2204 Requires<[IsARM,UseNaClTrap]> {
2205 let Inst = 0xe7fedef0;
2207 let isBarrier = 1, isTerminator = 1 in
2208 def TRAP : AXI<(outs), (ins), MiscFrm, NoItinerary,
2210 Requires<[IsARM,DontUseNaClTrap]> {
2211 let Inst = 0xe7ffdefe;
2214 def : Pat<(debugtrap), (BKPT 0)>, Requires<[IsARM, HasV5T]>;
2215 def : Pat<(debugtrap), (UDF 254)>, Requires<[IsARM, NoV5T]>;
2217 // Address computation and loads and stores in PIC mode.
2218 let isNotDuplicable = 1 in {
2219 def PICADD : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
2221 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>,
2222 Sched<[WriteALU, ReadALU]>;
2224 let AddedComplexity = 10 in {
2225 def PICLDR : ARMPseudoInst<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
2227 [(set GPR:$dst, (load addrmodepc:$addr))]>;
2229 def PICLDRH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2231 [(set GPR:$Rt, (zextloadi16 addrmodepc:$addr))]>;
2233 def PICLDRB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2235 [(set GPR:$Rt, (zextloadi8 addrmodepc:$addr))]>;
2237 def PICLDRSH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2239 [(set GPR:$Rt, (sextloadi16 addrmodepc:$addr))]>;
2241 def PICLDRSB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2243 [(set GPR:$Rt, (sextloadi8 addrmodepc:$addr))]>;
2245 let AddedComplexity = 10 in {
2246 def PICSTR : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2247 4, IIC_iStore_r, [(store GPR:$src, addrmodepc:$addr)]>;
2249 def PICSTRH : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2250 4, IIC_iStore_bh_r, [(truncstorei16 GPR:$src,
2251 addrmodepc:$addr)]>;
2253 def PICSTRB : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2254 4, IIC_iStore_bh_r, [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
2256 } // isNotDuplicable = 1
2259 // LEApcrel - Load a pc-relative address into a register without offending the
2261 let hasSideEffects = 0, isReMaterializable = 1 in
2262 // The 'adr' mnemonic encodes differently if the label is before or after
2263 // the instruction. The {24-21} opcode bits are set by the fixup, as we don't
2264 // know until then which form of the instruction will be used.
2265 def ADR : AI1<{0,?,?,0}, (outs GPR:$Rd), (ins adrlabel:$label),
2266 MiscFrm, IIC_iALUi, "adr", "\t$Rd, $label", []>,
2267 Sched<[WriteALU, ReadALU]> {
2270 let Inst{27-25} = 0b001;
2272 let Inst{23-22} = label{13-12};
2275 let Inst{19-16} = 0b1111;
2276 let Inst{15-12} = Rd;
2277 let Inst{11-0} = label{11-0};
2280 let hasSideEffects = 1 in {
2281 def LEApcrel : ARMPseudoInst<(outs GPR:$Rd), (ins i32imm:$label, pred:$p),
2282 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
2284 def LEApcrelJT : ARMPseudoInst<(outs GPR:$Rd),
2285 (ins i32imm:$label, pred:$p),
2286 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
2289 //===----------------------------------------------------------------------===//
2290 // Control Flow Instructions.
2293 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
2295 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
2296 "bx", "\tlr", [(ARMretflag)]>,
2297 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2298 let Inst{27-0} = 0b0001001011111111111100011110;
2302 def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br,
2303 "mov", "\tpc, lr", [(ARMretflag)]>,
2304 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]> {
2305 let Inst{27-0} = 0b0001101000001111000000001110;
2308 // Exception return: N.b. doesn't set CPSR as far as we're concerned (it sets
2309 // the user-space one).
2310 def SUBS_PC_LR : ARMPseudoInst<(outs), (ins i32imm:$offset, pred:$p),
2312 [(ARMintretflag imm:$offset)]>;
2315 // Indirect branches
2316 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
2318 def BX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
2319 [(brind GPR:$dst)]>,
2320 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2322 let Inst{31-4} = 0b1110000100101111111111110001;
2323 let Inst{3-0} = dst;
2326 def BX_pred : AI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br,
2327 "bx", "\t$dst", [/* pattern left blank */]>,
2328 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2330 let Inst{27-4} = 0b000100101111111111110001;
2331 let Inst{3-0} = dst;
2335 // SP is marked as a use to prevent stack-pointer assignments that appear
2336 // immediately before calls from potentially appearing dead.
2338 // FIXME: Do we really need a non-predicated version? If so, it should
2339 // at least be a pseudo instruction expanding to the predicated version
2340 // at MC lowering time.
2341 Defs = [LR], Uses = [SP] in {
2342 def BL : ABXI<0b1011, (outs), (ins arm_bl_target:$func),
2343 IIC_Br, "bl\t$func",
2344 [(ARMcall tglobaladdr:$func)]>,
2345 Requires<[IsARM]>, Sched<[WriteBrL]> {
2346 let Inst{31-28} = 0b1110;
2348 let Inst{23-0} = func;
2349 let DecoderMethod = "DecodeBranchImmInstruction";
2352 def BL_pred : ABI<0b1011, (outs), (ins arm_bl_target:$func),
2353 IIC_Br, "bl", "\t$func",
2354 [(ARMcall_pred tglobaladdr:$func)]>,
2355 Requires<[IsARM]>, Sched<[WriteBrL]> {
2357 let Inst{23-0} = func;
2358 let DecoderMethod = "DecodeBranchImmInstruction";
2362 def BLX : AXI<(outs), (ins GPR:$func), BrMiscFrm,
2363 IIC_Br, "blx\t$func",
2364 [(ARMcall GPR:$func)]>,
2365 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2367 let Inst{31-4} = 0b1110000100101111111111110011;
2368 let Inst{3-0} = func;
2371 def BLX_pred : AI<(outs), (ins GPR:$func), BrMiscFrm,
2372 IIC_Br, "blx", "\t$func",
2373 [(ARMcall_pred GPR:$func)]>,
2374 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2376 let Inst{27-4} = 0b000100101111111111110011;
2377 let Inst{3-0} = func;
2381 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
2382 def BX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
2383 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
2384 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]>;
2387 def BMOVPCRX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
2388 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
2389 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
2391 // mov lr, pc; b if callee is marked noreturn to avoid confusing the
2392 // return stack predictor.
2393 def BMOVPCB_CALL : ARMPseudoInst<(outs), (ins arm_bl_target:$func),
2394 8, IIC_Br, [(ARMcall_nolink tglobaladdr:$func)]>,
2395 Requires<[IsARM]>, Sched<[WriteBr]>;
2398 let isBranch = 1, isTerminator = 1 in {
2399 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
2400 // a two-value operand where a dag node expects two operands. :(
2401 def Bcc : ABI<0b1010, (outs), (ins arm_br_target:$target),
2402 IIC_Br, "b", "\t$target",
2403 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>,
2406 let Inst{23-0} = target;
2407 let DecoderMethod = "DecodeBranchImmInstruction";
2410 let isBarrier = 1 in {
2411 // B is "predicable" since it's just a Bcc with an 'always' condition.
2412 let isPredicable = 1 in
2413 // FIXME: We shouldn't need this pseudo at all. Just using Bcc directly
2414 // should be sufficient.
2415 // FIXME: Is B really a Barrier? That doesn't seem right.
2416 def B : ARMPseudoExpand<(outs), (ins arm_br_target:$target), 4, IIC_Br,
2417 [(br bb:$target)], (Bcc arm_br_target:$target,
2418 (ops 14, zero_reg))>,
2421 let Size = 4, isNotDuplicable = 1, isIndirectBranch = 1 in {
2422 def BR_JTr : ARMPseudoInst<(outs),
2423 (ins GPR:$target, i32imm:$jt),
2425 [(ARMbrjt GPR:$target, tjumptable:$jt)]>,
2427 def BR_JTm_i12 : ARMPseudoInst<(outs),
2428 (ins addrmode_imm12:$target, i32imm:$jt),
2430 [(ARMbrjt (i32 (load addrmode_imm12:$target)),
2431 tjumptable:$jt)]>, Sched<[WriteBrTbl]>;
2432 def BR_JTm_rs : ARMPseudoInst<(outs),
2433 (ins ldst_so_reg:$target, i32imm:$jt),
2435 [(ARMbrjt (i32 (load ldst_so_reg:$target)),
2436 tjumptable:$jt)]>, Sched<[WriteBrTbl]>;
2437 def BR_JTadd : ARMPseudoInst<(outs),
2438 (ins GPR:$target, GPR:$idx, i32imm:$jt),
2440 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt)]>,
2441 Sched<[WriteBrTbl]>;
2442 } // isNotDuplicable = 1, isIndirectBranch = 1
2448 def BLXi : AXI<(outs), (ins arm_blx_target:$target), BrMiscFrm, NoItinerary,
2449 "blx\t$target", []>,
2450 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2451 let Inst{31-25} = 0b1111101;
2453 let Inst{23-0} = target{24-1};
2454 let Inst{24} = target{0};
2458 // Branch and Exchange Jazelle
2459 def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func",
2460 [/* pattern left blank */]>, Sched<[WriteBr]> {
2462 let Inst{23-20} = 0b0010;
2463 let Inst{19-8} = 0xfff;
2464 let Inst{7-4} = 0b0010;
2465 let Inst{3-0} = func;
2471 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in {
2472 def TCRETURNdi : PseudoInst<(outs), (ins i32imm:$dst), IIC_Br, []>,
2475 def TCRETURNri : PseudoInst<(outs), (ins tcGPR:$dst), IIC_Br, []>,
2478 def TAILJMPd : ARMPseudoExpand<(outs), (ins arm_br_target:$dst),
2480 (Bcc arm_br_target:$dst, (ops 14, zero_reg))>,
2481 Requires<[IsARM]>, Sched<[WriteBr]>;
2483 def TAILJMPr : ARMPseudoExpand<(outs), (ins tcGPR:$dst),
2485 (BX GPR:$dst)>, Sched<[WriteBr]>,
2486 Requires<[IsARM, HasV4T]>;
2489 // Secure Monitor Call is a system instruction.
2490 def SMC : ABI<0b0001, (outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt",
2491 []>, Requires<[IsARM, HasTrustZone]> {
2493 let Inst{23-4} = 0b01100000000000000111;
2494 let Inst{3-0} = opt;
2496 def : MnemonicAlias<"smi", "smc">;
2498 // Supervisor Call (Software Interrupt)
2499 let isCall = 1, Uses = [SP] in {
2500 def SVC : ABI<0b1111, (outs), (ins imm24b:$svc), IIC_Br, "svc", "\t$svc", []>,
2503 let Inst{23-0} = svc;
2507 // Store Return State
2508 class SRSI<bit wb, string asm>
2509 : XI<(outs), (ins imm0_31:$mode), AddrModeNone, 4, IndexModeNone, BrFrm,
2510 NoItinerary, asm, "", []> {
2512 let Inst{31-28} = 0b1111;
2513 let Inst{27-25} = 0b100;
2517 let Inst{19-16} = 0b1101; // SP
2518 let Inst{15-5} = 0b00000101000;
2519 let Inst{4-0} = mode;
2522 def SRSDA : SRSI<0, "srsda\tsp, $mode"> {
2523 let Inst{24-23} = 0;
2525 def SRSDA_UPD : SRSI<1, "srsda\tsp!, $mode"> {
2526 let Inst{24-23} = 0;
2528 def SRSDB : SRSI<0, "srsdb\tsp, $mode"> {
2529 let Inst{24-23} = 0b10;
2531 def SRSDB_UPD : SRSI<1, "srsdb\tsp!, $mode"> {
2532 let Inst{24-23} = 0b10;
2534 def SRSIA : SRSI<0, "srsia\tsp, $mode"> {
2535 let Inst{24-23} = 0b01;
2537 def SRSIA_UPD : SRSI<1, "srsia\tsp!, $mode"> {
2538 let Inst{24-23} = 0b01;
2540 def SRSIB : SRSI<0, "srsib\tsp, $mode"> {
2541 let Inst{24-23} = 0b11;
2543 def SRSIB_UPD : SRSI<1, "srsib\tsp!, $mode"> {
2544 let Inst{24-23} = 0b11;
2547 def : ARMInstAlias<"srsda $mode", (SRSDA imm0_31:$mode)>;
2548 def : ARMInstAlias<"srsda $mode!", (SRSDA_UPD imm0_31:$mode)>;
2550 def : ARMInstAlias<"srsdb $mode", (SRSDB imm0_31:$mode)>;
2551 def : ARMInstAlias<"srsdb $mode!", (SRSDB_UPD imm0_31:$mode)>;
2553 def : ARMInstAlias<"srsia $mode", (SRSIA imm0_31:$mode)>;
2554 def : ARMInstAlias<"srsia $mode!", (SRSIA_UPD imm0_31:$mode)>;
2556 def : ARMInstAlias<"srsib $mode", (SRSIB imm0_31:$mode)>;
2557 def : ARMInstAlias<"srsib $mode!", (SRSIB_UPD imm0_31:$mode)>;
2559 // Return From Exception
2560 class RFEI<bit wb, string asm>
2561 : XI<(outs), (ins GPR:$Rn), AddrModeNone, 4, IndexModeNone, BrFrm,
2562 NoItinerary, asm, "", []> {
2564 let Inst{31-28} = 0b1111;
2565 let Inst{27-25} = 0b100;
2569 let Inst{19-16} = Rn;
2570 let Inst{15-0} = 0xa00;
2573 def RFEDA : RFEI<0, "rfeda\t$Rn"> {
2574 let Inst{24-23} = 0;
2576 def RFEDA_UPD : RFEI<1, "rfeda\t$Rn!"> {
2577 let Inst{24-23} = 0;
2579 def RFEDB : RFEI<0, "rfedb\t$Rn"> {
2580 let Inst{24-23} = 0b10;
2582 def RFEDB_UPD : RFEI<1, "rfedb\t$Rn!"> {
2583 let Inst{24-23} = 0b10;
2585 def RFEIA : RFEI<0, "rfeia\t$Rn"> {
2586 let Inst{24-23} = 0b01;
2588 def RFEIA_UPD : RFEI<1, "rfeia\t$Rn!"> {
2589 let Inst{24-23} = 0b01;
2591 def RFEIB : RFEI<0, "rfeib\t$Rn"> {
2592 let Inst{24-23} = 0b11;
2594 def RFEIB_UPD : RFEI<1, "rfeib\t$Rn!"> {
2595 let Inst{24-23} = 0b11;
2598 // Hypervisor Call is a system instruction
2600 def HVC : AInoP< (outs), (ins imm0_65535:$imm), BrFrm, NoItinerary,
2601 "hvc", "\t$imm", []>,
2602 Requires<[IsARM, HasVirtualization]> {
2605 // Even though HVC isn't predicable, it's encoding includes a condition field.
2606 // The instruction is undefined if the condition field is 0xf otherwise it is
2607 // unpredictable if it isn't condition AL (0xe).
2608 let Inst{31-28} = 0b1110;
2609 let Unpredictable{31-28} = 0b1111;
2610 let Inst{27-24} = 0b0001;
2611 let Inst{23-20} = 0b0100;
2612 let Inst{19-8} = imm{15-4};
2613 let Inst{7-4} = 0b0111;
2614 let Inst{3-0} = imm{3-0};
2618 // Return from exception in Hypervisor mode.
2619 let isReturn = 1, isBarrier = 1, isTerminator = 1, Defs = [PC] in
2620 def ERET : ABI<0b0001, (outs), (ins), NoItinerary, "eret", "", []>,
2621 Requires<[IsARM, HasVirtualization]> {
2622 let Inst{23-0} = 0b011000000000000001101110;
2625 //===----------------------------------------------------------------------===//
2626 // Load / Store Instructions.
2632 defm LDR : AI_ldr1<0, "ldr", IIC_iLoad_r, IIC_iLoad_si, load>;
2633 defm LDRB : AI_ldr1nopc<1, "ldrb", IIC_iLoad_bh_r, IIC_iLoad_bh_si,
2635 defm STR : AI_str1<0, "str", IIC_iStore_r, IIC_iStore_si, store>;
2636 defm STRB : AI_str1nopc<1, "strb", IIC_iStore_bh_r, IIC_iStore_bh_si,
2639 // Special LDR for loads from non-pc-relative constpools.
2640 let canFoldAsLoad = 1, mayLoad = 1, hasSideEffects = 0,
2641 isReMaterializable = 1, isCodeGenOnly = 1 in
2642 def LDRcp : AI2ldst<0b010, 1, 0, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
2643 AddrMode_i12, LdFrm, IIC_iLoad_r, "ldr", "\t$Rt, $addr",
2647 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2648 let Inst{19-16} = 0b1111;
2649 let Inst{15-12} = Rt;
2650 let Inst{11-0} = addr{11-0}; // imm12
2653 // Loads with zero extension
2654 def LDRH : AI3ld<0b1011, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2655 IIC_iLoad_bh_r, "ldrh", "\t$Rt, $addr",
2656 [(set GPR:$Rt, (zextloadi16 addrmode3:$addr))]>;
2658 // Loads with sign extension
2659 def LDRSH : AI3ld<0b1111, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2660 IIC_iLoad_bh_r, "ldrsh", "\t$Rt, $addr",
2661 [(set GPR:$Rt, (sextloadi16 addrmode3:$addr))]>;
2663 def LDRSB : AI3ld<0b1101, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2664 IIC_iLoad_bh_r, "ldrsb", "\t$Rt, $addr",
2665 [(set GPR:$Rt, (sextloadi8 addrmode3:$addr))]>;
2667 let mayLoad = 1, hasSideEffects = 0, hasExtraDefRegAllocReq = 1 in {
2669 def LDRD : AI3ld<0b1101, 0, (outs GPR:$Rt, GPR:$Rt2), (ins addrmode3:$addr),
2670 LdMiscFrm, IIC_iLoad_d_r, "ldrd", "\t$Rt, $Rt2, $addr", []>,
2671 Requires<[IsARM, HasV5TE]>;
2674 def LDA : AIldracq<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2675 NoItinerary, "lda", "\t$Rt, $addr", []>;
2676 def LDAB : AIldracq<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2677 NoItinerary, "ldab", "\t$Rt, $addr", []>;
2678 def LDAH : AIldracq<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2679 NoItinerary, "ldah", "\t$Rt, $addr", []>;
2682 multiclass AI2_ldridx<bit isByte, string opc,
2683 InstrItinClass iii, InstrItinClass iir> {
2684 def _PRE_IMM : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2685 (ins addrmode_imm12_pre:$addr), IndexModePre, LdFrm, iii,
2686 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2689 let Inst{23} = addr{12};
2690 let Inst{19-16} = addr{16-13};
2691 let Inst{11-0} = addr{11-0};
2692 let DecoderMethod = "DecodeLDRPreImm";
2695 def _PRE_REG : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2696 (ins ldst_so_reg:$addr), IndexModePre, LdFrm, iir,
2697 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2700 let Inst{23} = addr{12};
2701 let Inst{19-16} = addr{16-13};
2702 let Inst{11-0} = addr{11-0};
2704 let DecoderMethod = "DecodeLDRPreReg";
2707 def _POST_REG : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2708 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2709 IndexModePost, LdFrm, iir,
2710 opc, "\t$Rt, $addr, $offset",
2711 "$addr.base = $Rn_wb", []> {
2717 let Inst{23} = offset{12};
2718 let Inst{19-16} = addr;
2719 let Inst{11-0} = offset{11-0};
2722 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2725 def _POST_IMM : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2726 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2727 IndexModePost, LdFrm, iii,
2728 opc, "\t$Rt, $addr, $offset",
2729 "$addr.base = $Rn_wb", []> {
2735 let Inst{23} = offset{12};
2736 let Inst{19-16} = addr;
2737 let Inst{11-0} = offset{11-0};
2739 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2744 let mayLoad = 1, hasSideEffects = 0 in {
2745 // FIXME: for LDR_PRE_REG etc. the itineray should be either IIC_iLoad_ru or
2746 // IIC_iLoad_siu depending on whether it the offset register is shifted.
2747 defm LDR : AI2_ldridx<0, "ldr", IIC_iLoad_iu, IIC_iLoad_ru>;
2748 defm LDRB : AI2_ldridx<1, "ldrb", IIC_iLoad_bh_iu, IIC_iLoad_bh_ru>;
2751 multiclass AI3_ldridx<bits<4> op, string opc, InstrItinClass itin> {
2752 def _PRE : AI3ldstidx<op, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2753 (ins addrmode3_pre:$addr), IndexModePre,
2755 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2757 let Inst{23} = addr{8}; // U bit
2758 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2759 let Inst{19-16} = addr{12-9}; // Rn
2760 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2761 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2762 let DecoderMethod = "DecodeAddrMode3Instruction";
2764 def _POST : AI3ldstidx<op, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2765 (ins addr_offset_none:$addr, am3offset:$offset),
2766 IndexModePost, LdMiscFrm, itin,
2767 opc, "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2771 let Inst{23} = offset{8}; // U bit
2772 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2773 let Inst{19-16} = addr;
2774 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2775 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2776 let DecoderMethod = "DecodeAddrMode3Instruction";
2780 let mayLoad = 1, hasSideEffects = 0 in {
2781 defm LDRH : AI3_ldridx<0b1011, "ldrh", IIC_iLoad_bh_ru>;
2782 defm LDRSH : AI3_ldridx<0b1111, "ldrsh", IIC_iLoad_bh_ru>;
2783 defm LDRSB : AI3_ldridx<0b1101, "ldrsb", IIC_iLoad_bh_ru>;
2784 let hasExtraDefRegAllocReq = 1 in {
2785 def LDRD_PRE : AI3ldstidx<0b1101, 0, 1, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2786 (ins addrmode3_pre:$addr), IndexModePre,
2787 LdMiscFrm, IIC_iLoad_d_ru,
2788 "ldrd", "\t$Rt, $Rt2, $addr!",
2789 "$addr.base = $Rn_wb", []> {
2791 let Inst{23} = addr{8}; // U bit
2792 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2793 let Inst{19-16} = addr{12-9}; // Rn
2794 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2795 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2796 let DecoderMethod = "DecodeAddrMode3Instruction";
2798 def LDRD_POST: AI3ldstidx<0b1101, 0, 0, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2799 (ins addr_offset_none:$addr, am3offset:$offset),
2800 IndexModePost, LdMiscFrm, IIC_iLoad_d_ru,
2801 "ldrd", "\t$Rt, $Rt2, $addr, $offset",
2802 "$addr.base = $Rn_wb", []> {
2805 let Inst{23} = offset{8}; // U bit
2806 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2807 let Inst{19-16} = addr;
2808 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2809 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2810 let DecoderMethod = "DecodeAddrMode3Instruction";
2812 } // hasExtraDefRegAllocReq = 1
2813 } // mayLoad = 1, hasSideEffects = 0
2815 // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT.
2816 let mayLoad = 1, hasSideEffects = 0 in {
2817 def LDRT_POST_REG : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2818 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2819 IndexModePost, LdFrm, IIC_iLoad_ru,
2820 "ldrt", "\t$Rt, $addr, $offset",
2821 "$addr.base = $Rn_wb", []> {
2827 let Inst{23} = offset{12};
2828 let Inst{21} = 1; // overwrite
2829 let Inst{19-16} = addr;
2830 let Inst{11-5} = offset{11-5};
2832 let Inst{3-0} = offset{3-0};
2833 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2837 : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2838 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2839 IndexModePost, LdFrm, IIC_iLoad_ru,
2840 "ldrt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2846 let Inst{23} = offset{12};
2847 let Inst{21} = 1; // overwrite
2848 let Inst{19-16} = addr;
2849 let Inst{11-0} = offset{11-0};
2850 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2853 def LDRBT_POST_REG : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2854 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2855 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2856 "ldrbt", "\t$Rt, $addr, $offset",
2857 "$addr.base = $Rn_wb", []> {
2863 let Inst{23} = offset{12};
2864 let Inst{21} = 1; // overwrite
2865 let Inst{19-16} = addr;
2866 let Inst{11-5} = offset{11-5};
2868 let Inst{3-0} = offset{3-0};
2869 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2873 : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2874 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2875 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2876 "ldrbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2882 let Inst{23} = offset{12};
2883 let Inst{21} = 1; // overwrite
2884 let Inst{19-16} = addr;
2885 let Inst{11-0} = offset{11-0};
2886 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2889 multiclass AI3ldrT<bits<4> op, string opc> {
2890 def i : AI3ldstidxT<op, 1, (outs GPR:$Rt, GPR:$base_wb),
2891 (ins addr_offset_none:$addr, postidx_imm8:$offset),
2892 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2893 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2895 let Inst{23} = offset{8};
2897 let Inst{11-8} = offset{7-4};
2898 let Inst{3-0} = offset{3-0};
2900 def r : AI3ldstidxT<op, 1, (outs GPRnopc:$Rt, GPRnopc:$base_wb),
2901 (ins addr_offset_none:$addr, postidx_reg:$Rm),
2902 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2903 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2905 let Inst{23} = Rm{4};
2908 let Unpredictable{11-8} = 0b1111;
2909 let Inst{3-0} = Rm{3-0};
2910 let DecoderMethod = "DecodeLDR";
2914 defm LDRSBT : AI3ldrT<0b1101, "ldrsbt">;
2915 defm LDRHT : AI3ldrT<0b1011, "ldrht">;
2916 defm LDRSHT : AI3ldrT<0b1111, "ldrsht">;
2920 : ARMAsmPseudo<"ldrt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q),
2924 : ARMAsmPseudo<"ldrbt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q),
2927 // Pseudo instruction ldr Rt, =immediate
2929 : ARMAsmPseudo<"ldr${q} $Rt, $immediate",
2930 (ins const_pool_asm_imm:$immediate, pred:$q),
2935 // Stores with truncate
2936 def STRH : AI3str<0b1011, (outs), (ins GPR:$Rt, addrmode3:$addr), StMiscFrm,
2937 IIC_iStore_bh_r, "strh", "\t$Rt, $addr",
2938 [(truncstorei16 GPR:$Rt, addrmode3:$addr)]>;
2941 let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
2942 def STRD : AI3str<0b1111, (outs), (ins GPR:$Rt, GPR:$Rt2, addrmode3:$addr),
2943 StMiscFrm, IIC_iStore_d_r, "strd", "\t$Rt, $Rt2, $addr", []>,
2944 Requires<[IsARM, HasV5TE]> {
2950 multiclass AI2_stridx<bit isByte, string opc,
2951 InstrItinClass iii, InstrItinClass iir> {
2952 def _PRE_IMM : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2953 (ins GPR:$Rt, addrmode_imm12_pre:$addr), IndexModePre,
2955 opc, "\t$Rt, $addr!",
2956 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2959 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2960 let Inst{19-16} = addr{16-13}; // Rn
2961 let Inst{11-0} = addr{11-0}; // imm12
2962 let DecoderMethod = "DecodeSTRPreImm";
2965 def _PRE_REG : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2966 (ins GPR:$Rt, ldst_so_reg:$addr),
2967 IndexModePre, StFrm, iir,
2968 opc, "\t$Rt, $addr!",
2969 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2972 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2973 let Inst{19-16} = addr{16-13}; // Rn
2974 let Inst{11-0} = addr{11-0};
2975 let Inst{4} = 0; // Inst{4} = 0
2976 let DecoderMethod = "DecodeSTRPreReg";
2978 def _POST_REG : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2979 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2980 IndexModePost, StFrm, iir,
2981 opc, "\t$Rt, $addr, $offset",
2982 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2988 let Inst{23} = offset{12};
2989 let Inst{19-16} = addr;
2990 let Inst{11-0} = offset{11-0};
2993 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2996 def _POST_IMM : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2997 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2998 IndexModePost, StFrm, iii,
2999 opc, "\t$Rt, $addr, $offset",
3000 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
3006 let Inst{23} = offset{12};
3007 let Inst{19-16} = addr;
3008 let Inst{11-0} = offset{11-0};
3010 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3014 let mayStore = 1, hasSideEffects = 0 in {
3015 // FIXME: for STR_PRE_REG etc. the itineray should be either IIC_iStore_ru or
3016 // IIC_iStore_siu depending on whether it the offset register is shifted.
3017 defm STR : AI2_stridx<0, "str", IIC_iStore_iu, IIC_iStore_ru>;
3018 defm STRB : AI2_stridx<1, "strb", IIC_iStore_bh_iu, IIC_iStore_bh_ru>;
3021 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
3022 am2offset_reg:$offset),
3023 (STR_POST_REG GPR:$Rt, addr_offset_none:$addr,
3024 am2offset_reg:$offset)>;
3025 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
3026 am2offset_imm:$offset),
3027 (STR_POST_IMM GPR:$Rt, addr_offset_none:$addr,
3028 am2offset_imm:$offset)>;
3029 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
3030 am2offset_reg:$offset),
3031 (STRB_POST_REG GPR:$Rt, addr_offset_none:$addr,
3032 am2offset_reg:$offset)>;
3033 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
3034 am2offset_imm:$offset),
3035 (STRB_POST_IMM GPR:$Rt, addr_offset_none:$addr,
3036 am2offset_imm:$offset)>;
3038 // Pseudo-instructions for pattern matching the pre-indexed stores. We can't
3039 // put the patterns on the instruction definitions directly as ISel wants
3040 // the address base and offset to be separate operands, not a single
3041 // complex operand like we represent the instructions themselves. The
3042 // pseudos map between the two.
3043 let usesCustomInserter = 1,
3044 Constraints = "$Rn = $Rn_wb,@earlyclobber $Rn_wb" in {
3045 def STRi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3046 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
3049 (pre_store GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
3050 def STRr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3051 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
3054 (pre_store GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
3055 def STRBi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3056 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
3059 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
3060 def STRBr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3061 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
3064 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
3065 def STRH_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3066 (ins GPR:$Rt, GPR:$Rn, am3offset:$offset, pred:$p),
3069 (pre_truncsti16 GPR:$Rt, GPR:$Rn, am3offset:$offset))]>;
3074 def STRH_PRE : AI3ldstidx<0b1011, 0, 1, (outs GPR:$Rn_wb),
3075 (ins GPR:$Rt, addrmode3_pre:$addr), IndexModePre,
3076 StMiscFrm, IIC_iStore_bh_ru,
3077 "strh", "\t$Rt, $addr!",
3078 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
3080 let Inst{23} = addr{8}; // U bit
3081 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
3082 let Inst{19-16} = addr{12-9}; // Rn
3083 let Inst{11-8} = addr{7-4}; // imm7_4/zero
3084 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
3085 let DecoderMethod = "DecodeAddrMode3Instruction";
3088 def STRH_POST : AI3ldstidx<0b1011, 0, 0, (outs GPR:$Rn_wb),
3089 (ins GPR:$Rt, addr_offset_none:$addr, am3offset:$offset),
3090 IndexModePost, StMiscFrm, IIC_iStore_bh_ru,
3091 "strh", "\t$Rt, $addr, $offset",
3092 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb",
3093 [(set GPR:$Rn_wb, (post_truncsti16 GPR:$Rt,
3094 addr_offset_none:$addr,
3095 am3offset:$offset))]> {
3098 let Inst{23} = offset{8}; // U bit
3099 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
3100 let Inst{19-16} = addr;
3101 let Inst{11-8} = offset{7-4}; // imm7_4/zero
3102 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
3103 let DecoderMethod = "DecodeAddrMode3Instruction";
3106 let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
3107 def STRD_PRE : AI3ldstidx<0b1111, 0, 1, (outs GPR:$Rn_wb),
3108 (ins GPR:$Rt, GPR:$Rt2, addrmode3_pre:$addr),
3109 IndexModePre, StMiscFrm, IIC_iStore_d_ru,
3110 "strd", "\t$Rt, $Rt2, $addr!",
3111 "$addr.base = $Rn_wb", []> {
3113 let Inst{23} = addr{8}; // U bit
3114 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
3115 let Inst{19-16} = addr{12-9}; // Rn
3116 let Inst{11-8} = addr{7-4}; // imm7_4/zero
3117 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
3118 let DecoderMethod = "DecodeAddrMode3Instruction";
3121 def STRD_POST: AI3ldstidx<0b1111, 0, 0, (outs GPR:$Rn_wb),
3122 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr,
3124 IndexModePost, StMiscFrm, IIC_iStore_d_ru,
3125 "strd", "\t$Rt, $Rt2, $addr, $offset",
3126 "$addr.base = $Rn_wb", []> {
3129 let Inst{23} = offset{8}; // U bit
3130 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
3131 let Inst{19-16} = addr;
3132 let Inst{11-8} = offset{7-4}; // imm7_4/zero
3133 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
3134 let DecoderMethod = "DecodeAddrMode3Instruction";
3136 } // mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1
3138 // STRT, STRBT, and STRHT
3140 def STRBT_POST_REG : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
3141 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
3142 IndexModePost, StFrm, IIC_iStore_bh_ru,
3143 "strbt", "\t$Rt, $addr, $offset",
3144 "$addr.base = $Rn_wb", []> {
3150 let Inst{23} = offset{12};
3151 let Inst{21} = 1; // overwrite
3152 let Inst{19-16} = addr;
3153 let Inst{11-5} = offset{11-5};
3155 let Inst{3-0} = offset{3-0};
3156 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3160 : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
3161 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
3162 IndexModePost, StFrm, IIC_iStore_bh_ru,
3163 "strbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
3169 let Inst{23} = offset{12};
3170 let Inst{21} = 1; // overwrite
3171 let Inst{19-16} = addr;
3172 let Inst{11-0} = offset{11-0};
3173 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3177 : ARMAsmPseudo<"strbt${q} $Rt, $addr",
3178 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>;
3180 let mayStore = 1, hasSideEffects = 0 in {
3181 def STRT_POST_REG : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
3182 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
3183 IndexModePost, StFrm, IIC_iStore_ru,
3184 "strt", "\t$Rt, $addr, $offset",
3185 "$addr.base = $Rn_wb", []> {
3191 let Inst{23} = offset{12};
3192 let Inst{21} = 1; // overwrite
3193 let Inst{19-16} = addr;
3194 let Inst{11-5} = offset{11-5};
3196 let Inst{3-0} = offset{3-0};
3197 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3201 : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
3202 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
3203 IndexModePost, StFrm, IIC_iStore_ru,
3204 "strt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
3210 let Inst{23} = offset{12};
3211 let Inst{21} = 1; // overwrite
3212 let Inst{19-16} = addr;
3213 let Inst{11-0} = offset{11-0};
3214 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3219 : ARMAsmPseudo<"strt${q} $Rt, $addr",
3220 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>;
3222 multiclass AI3strT<bits<4> op, string opc> {
3223 def i : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
3224 (ins GPR:$Rt, addr_offset_none:$addr, postidx_imm8:$offset),
3225 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
3226 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
3228 let Inst{23} = offset{8};
3230 let Inst{11-8} = offset{7-4};
3231 let Inst{3-0} = offset{3-0};
3233 def r : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
3234 (ins GPR:$Rt, addr_offset_none:$addr, postidx_reg:$Rm),
3235 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
3236 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
3238 let Inst{23} = Rm{4};
3241 let Inst{3-0} = Rm{3-0};
3246 defm STRHT : AI3strT<0b1011, "strht">;
3248 def STL : AIstrrel<0b00, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3249 NoItinerary, "stl", "\t$Rt, $addr", []>;
3250 def STLB : AIstrrel<0b10, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3251 NoItinerary, "stlb", "\t$Rt, $addr", []>;
3252 def STLH : AIstrrel<0b11, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3253 NoItinerary, "stlh", "\t$Rt, $addr", []>;
3255 //===----------------------------------------------------------------------===//
3256 // Load / store multiple Instructions.
3259 multiclass arm_ldst_mult<string asm, string sfx, bit L_bit, bit P_bit, Format f,
3260 InstrItinClass itin, InstrItinClass itin_upd> {
3261 // IA is the default, so no need for an explicit suffix on the
3262 // mnemonic here. Without it is the canonical spelling.
3264 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3265 IndexModeNone, f, itin,
3266 !strconcat(asm, "${p}\t$Rn, $regs", sfx), "", []> {
3267 let Inst{24-23} = 0b01; // Increment After
3268 let Inst{22} = P_bit;
3269 let Inst{21} = 0; // No writeback
3270 let Inst{20} = L_bit;
3273 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3274 IndexModeUpd, f, itin_upd,
3275 !strconcat(asm, "${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3276 let Inst{24-23} = 0b01; // Increment After
3277 let Inst{22} = P_bit;
3278 let Inst{21} = 1; // Writeback
3279 let Inst{20} = L_bit;
3281 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3284 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3285 IndexModeNone, f, itin,
3286 !strconcat(asm, "da${p}\t$Rn, $regs", sfx), "", []> {
3287 let Inst{24-23} = 0b00; // Decrement After
3288 let Inst{22} = P_bit;
3289 let Inst{21} = 0; // No writeback
3290 let Inst{20} = L_bit;
3293 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3294 IndexModeUpd, f, itin_upd,
3295 !strconcat(asm, "da${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3296 let Inst{24-23} = 0b00; // Decrement After
3297 let Inst{22} = P_bit;
3298 let Inst{21} = 1; // Writeback
3299 let Inst{20} = L_bit;
3301 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3304 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3305 IndexModeNone, f, itin,
3306 !strconcat(asm, "db${p}\t$Rn, $regs", sfx), "", []> {
3307 let Inst{24-23} = 0b10; // Decrement Before
3308 let Inst{22} = P_bit;
3309 let Inst{21} = 0; // No writeback
3310 let Inst{20} = L_bit;
3313 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3314 IndexModeUpd, f, itin_upd,
3315 !strconcat(asm, "db${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3316 let Inst{24-23} = 0b10; // Decrement Before
3317 let Inst{22} = P_bit;
3318 let Inst{21} = 1; // Writeback
3319 let Inst{20} = L_bit;
3321 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3324 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3325 IndexModeNone, f, itin,
3326 !strconcat(asm, "ib${p}\t$Rn, $regs", sfx), "", []> {
3327 let Inst{24-23} = 0b11; // Increment Before
3328 let Inst{22} = P_bit;
3329 let Inst{21} = 0; // No writeback
3330 let Inst{20} = L_bit;
3333 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3334 IndexModeUpd, f, itin_upd,
3335 !strconcat(asm, "ib${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3336 let Inst{24-23} = 0b11; // Increment Before
3337 let Inst{22} = P_bit;
3338 let Inst{21} = 1; // Writeback
3339 let Inst{20} = L_bit;
3341 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3345 let hasSideEffects = 0 in {
3347 let mayLoad = 1, hasExtraDefRegAllocReq = 1, variadicOpsAreDefs = 1 in
3348 defm LDM : arm_ldst_mult<"ldm", "", 1, 0, LdStMulFrm, IIC_iLoad_m,
3349 IIC_iLoad_mu>, ComplexDeprecationPredicate<"ARMLoad">;
3351 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
3352 defm STM : arm_ldst_mult<"stm", "", 0, 0, LdStMulFrm, IIC_iStore_m,
3354 ComplexDeprecationPredicate<"ARMStore">;
3358 // FIXME: remove when we have a way to marking a MI with these properties.
3359 // FIXME: Should pc be an implicit operand like PICADD, etc?
3360 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
3361 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
3362 def LDMIA_RET : ARMPseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p,
3363 reglist:$regs, variable_ops),
3364 4, IIC_iLoad_mBr, [],
3365 (LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>,
3366 RegConstraint<"$Rn = $wb">;
3368 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
3369 defm sysLDM : arm_ldst_mult<"ldm", " ^", 1, 1, LdStMulFrm, IIC_iLoad_m,
3372 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
3373 defm sysSTM : arm_ldst_mult<"stm", " ^", 0, 1, LdStMulFrm, IIC_iStore_m,
3378 //===----------------------------------------------------------------------===//
3379 // Move Instructions.
3382 let hasSideEffects = 0, isMoveReg = 1 in
3383 def MOVr : AsI1<0b1101, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMOVr,
3384 "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> {
3388 let Inst{19-16} = 0b0000;
3389 let Inst{11-4} = 0b00000000;
3392 let Inst{15-12} = Rd;
3395 // A version for the smaller set of tail call registers.
3396 let hasSideEffects = 0 in
3397 def MOVr_TC : AsI1<0b1101, (outs tcGPR:$Rd), (ins tcGPR:$Rm), DPFrm,
3398 IIC_iMOVr, "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> {
3402 let Inst{11-4} = 0b00000000;
3405 let Inst{15-12} = Rd;
3408 def MOVsr : AsI1<0b1101, (outs GPRnopc:$Rd), (ins shift_so_reg_reg:$src),
3409 DPSoRegRegFrm, IIC_iMOVsr,
3410 "mov", "\t$Rd, $src",
3411 [(set GPRnopc:$Rd, shift_so_reg_reg:$src)]>, UnaryDP,
3415 let Inst{15-12} = Rd;
3416 let Inst{19-16} = 0b0000;
3417 let Inst{11-8} = src{11-8};
3419 let Inst{6-5} = src{6-5};
3421 let Inst{3-0} = src{3-0};
3425 def MOVsi : AsI1<0b1101, (outs GPR:$Rd), (ins shift_so_reg_imm:$src),
3426 DPSoRegImmFrm, IIC_iMOVsr,
3427 "mov", "\t$Rd, $src", [(set GPR:$Rd, shift_so_reg_imm:$src)]>,
3428 UnaryDP, Sched<[WriteALU]> {
3431 let Inst{15-12} = Rd;
3432 let Inst{19-16} = 0b0000;
3433 let Inst{11-5} = src{11-5};
3435 let Inst{3-0} = src{3-0};
3439 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3440 def MOVi : AsI1<0b1101, (outs GPR:$Rd), (ins mod_imm:$imm), DPFrm, IIC_iMOVi,
3441 "mov", "\t$Rd, $imm", [(set GPR:$Rd, mod_imm:$imm)]>, UnaryDP,
3446 let Inst{15-12} = Rd;
3447 let Inst{19-16} = 0b0000;
3448 let Inst{11-0} = imm;
3451 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3452 def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins imm0_65535_expr:$imm),
3454 "movw", "\t$Rd, $imm",
3455 [(set GPR:$Rd, imm0_65535:$imm)]>,
3456 Requires<[IsARM, HasV6T2]>, UnaryDP, Sched<[WriteALU]> {
3459 let Inst{15-12} = Rd;
3460 let Inst{11-0} = imm{11-0};
3461 let Inst{19-16} = imm{15-12};
3464 let DecoderMethod = "DecodeArmMOVTWInstruction";
3467 def : InstAlias<"mov${p} $Rd, $imm",
3468 (MOVi16 GPR:$Rd, imm0_65535_expr:$imm, pred:$p), 0>,
3469 Requires<[IsARM, HasV6T2]>;
3471 def MOVi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
3472 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
3475 let Constraints = "$src = $Rd" in {
3476 def MOVTi16 : AI1<0b1010, (outs GPRnopc:$Rd),
3477 (ins GPR:$src, imm0_65535_expr:$imm),
3479 "movt", "\t$Rd, $imm",
3481 (or (and GPR:$src, 0xffff),
3482 lo16AllZero:$imm))]>, UnaryDP,
3483 Requires<[IsARM, HasV6T2]>, Sched<[WriteALU]> {
3486 let Inst{15-12} = Rd;
3487 let Inst{11-0} = imm{11-0};
3488 let Inst{19-16} = imm{15-12};
3491 let DecoderMethod = "DecodeArmMOVTWInstruction";
3494 def MOVTi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
3495 (ins GPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
3500 def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
3501 Requires<[IsARM, HasV6T2]>;
3503 let Uses = [CPSR] in
3504 def RRX: PseudoInst<(outs GPR:$Rd), (ins GPR:$Rm), IIC_iMOVsi,
3505 [(set GPR:$Rd, (ARMrrx GPR:$Rm))]>, UnaryDP,
3506 Requires<[IsARM]>, Sched<[WriteALU]>;
3508 // These aren't really mov instructions, but we have to define them this way
3509 // due to flag operands.
3511 let Defs = [CPSR] in {
3512 def MOVsrl_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3513 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP,
3514 Sched<[WriteALU]>, Requires<[IsARM]>;
3515 def MOVsra_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3516 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP,
3517 Sched<[WriteALU]>, Requires<[IsARM]>;
3520 //===----------------------------------------------------------------------===//
3521 // Extend Instructions.
3526 def SXTB : AI_ext_rrot<0b01101010,
3527 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
3528 def SXTH : AI_ext_rrot<0b01101011,
3529 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
3531 def SXTAB : AI_exta_rrot<0b01101010,
3532 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
3533 def SXTAH : AI_exta_rrot<0b01101011,
3534 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
3536 def : ARMV6Pat<(add rGPR:$Rn, (sext_inreg (srl rGPR:$Rm, rot_imm:$rot), i8)),
3537 (SXTAB rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
3538 def : ARMV6Pat<(add rGPR:$Rn, (sext_inreg (srl rGPR:$Rm, imm8_or_16:$rot),
3540 (SXTAH rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
3542 def SXTB16 : AI_ext_rrot_np<0b01101000, "sxtb16">;
3543 def : ARMV6Pat<(int_arm_sxtb16 GPR:$Src),
3544 (SXTB16 GPR:$Src, 0)>;
3545 def : ARMV6Pat<(int_arm_sxtb16 (rotr GPR:$Src, rot_imm:$rot)),
3546 (SXTB16 GPR:$Src, rot_imm:$rot)>;
3548 def SXTAB16 : AI_exta_rrot_np<0b01101000, "sxtab16">;
3549 def : ARMV6Pat<(int_arm_sxtab16 GPR:$LHS, GPR:$RHS),
3550 (SXTAB16 GPR:$LHS, GPR:$RHS, 0)>;
3551 def : ARMV6Pat<(int_arm_sxtab16 GPR:$LHS, (rotr GPR:$RHS, rot_imm:$rot)),
3552 (SXTAB16 GPR:$LHS, GPR:$RHS, rot_imm:$rot)>;
3556 let AddedComplexity = 16 in {
3557 def UXTB : AI_ext_rrot<0b01101110,
3558 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
3559 def UXTH : AI_ext_rrot<0b01101111,
3560 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
3561 def UXTB16 : AI_ext_rrot<0b01101100,
3562 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
3564 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
3565 // The transformation should probably be done as a combiner action
3566 // instead so we can include a check for masking back in the upper
3567 // eight bits of the source into the lower eight bits of the result.
3568 //def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
3569 // (UXTB16r_rot GPR:$Src, 3)>;
3570 def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
3571 (UXTB16 GPR:$Src, 1)>;
3572 def : ARMV6Pat<(int_arm_uxtb16 GPR:$Src),
3573 (UXTB16 GPR:$Src, 0)>;
3574 def : ARMV6Pat<(int_arm_uxtb16 (rotr GPR:$Src, rot_imm:$rot)),
3575 (UXTB16 GPR:$Src, rot_imm:$rot)>;
3577 def UXTAB : AI_exta_rrot<0b01101110, "uxtab",
3578 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
3579 def UXTAH : AI_exta_rrot<0b01101111, "uxtah",
3580 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
3582 def : ARMV6Pat<(add rGPR:$Rn, (and (srl rGPR:$Rm, rot_imm:$rot), 0xFF)),
3583 (UXTAB rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
3584 def : ARMV6Pat<(add rGPR:$Rn, (and (srl rGPR:$Rm, imm8_or_16:$rot), 0xFFFF)),
3585 (UXTAH rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
3588 // This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
3589 def UXTAB16 : AI_exta_rrot_np<0b01101100, "uxtab16">;
3590 def : ARMV6Pat<(int_arm_uxtab16 GPR:$LHS, GPR:$RHS),
3591 (UXTAB16 GPR:$LHS, GPR:$RHS, 0)>;
3592 def : ARMV6Pat<(int_arm_uxtab16 GPR:$LHS, (rotr GPR:$RHS, rot_imm:$rot)),
3593 (UXTAB16 GPR:$LHS, GPR:$RHS, rot_imm:$rot)>;
3596 def SBFX : I<(outs GPRnopc:$Rd),
3597 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3598 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3599 "sbfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3600 Requires<[IsARM, HasV6T2]> {
3605 let Inst{27-21} = 0b0111101;
3606 let Inst{6-4} = 0b101;
3607 let Inst{20-16} = width;
3608 let Inst{15-12} = Rd;
3609 let Inst{11-7} = lsb;
3613 def UBFX : I<(outs GPRnopc:$Rd),
3614 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3615 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3616 "ubfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3617 Requires<[IsARM, HasV6T2]> {
3622 let Inst{27-21} = 0b0111111;
3623 let Inst{6-4} = 0b101;
3624 let Inst{20-16} = width;
3625 let Inst{15-12} = Rd;
3626 let Inst{11-7} = lsb;
3630 //===----------------------------------------------------------------------===//
3631 // Arithmetic Instructions.
3635 defm ADD : AsI1_bin_irs<0b0100, "add",
3636 IIC_iALUi, IIC_iALUr, IIC_iALUsr, add, 1>;
3637 defm SUB : AsI1_bin_irs<0b0010, "sub",
3638 IIC_iALUi, IIC_iALUr, IIC_iALUsr, sub>;
3640 // ADD and SUB with 's' bit set.
3642 // Currently, ADDS/SUBS are pseudo opcodes that exist only in the
3643 // selection DAG. They are "lowered" to real ADD/SUB opcodes by
3644 // AdjustInstrPostInstrSelection where we determine whether or not to
3645 // set the "s" bit based on CPSR liveness.
3647 // FIXME: Eliminate ADDS/SUBS pseudo opcodes after adding tablegen
3648 // support for an optional CPSR definition that corresponds to the DAG
3649 // node's second value. We can then eliminate the implicit def of CPSR.
3651 defm ADDS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr, ARMaddc, 1>;
3652 defm SUBS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr, ARMsubc>;
3654 def : ARMPat<(ARMsubs GPR:$Rn, mod_imm:$imm), (SUBSri $Rn, mod_imm:$imm)>;
3655 def : ARMPat<(ARMsubs GPR:$Rn, GPR:$Rm), (SUBSrr $Rn, $Rm)>;
3656 def : ARMPat<(ARMsubs GPR:$Rn, so_reg_imm:$shift),
3657 (SUBSrsi $Rn, so_reg_imm:$shift)>;
3658 def : ARMPat<(ARMsubs GPR:$Rn, so_reg_reg:$shift),
3659 (SUBSrsr $Rn, so_reg_reg:$shift)>;
3663 defm ADC : AI1_adde_sube_irs<0b0101, "adc", ARMadde, 1>;
3664 defm SBC : AI1_adde_sube_irs<0b0110, "sbc", ARMsube>;
3666 defm RSB : AsI1_rbin_irs<0b0011, "rsb",
3667 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3670 // FIXME: Eliminate them if we can write def : Pat patterns which defines
3671 // CPSR and the implicit def of CPSR is not needed.
3672 defm RSBS : AsI1_rbin_s_is<IIC_iALUi, IIC_iALUr, IIC_iALUsr, ARMsubc>;
3674 defm RSC : AI1_rsc_irs<0b0111, "rsc", ARMsube>;
3676 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
3677 // The assume-no-carry-in form uses the negation of the input since add/sub
3678 // assume opposite meanings of the carry flag (i.e., carry == !borrow).
3679 // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
3681 def : ARMPat<(add GPR:$src, mod_imm_neg:$imm),
3682 (SUBri GPR:$src, mod_imm_neg:$imm)>;
3683 def : ARMPat<(ARMaddc GPR:$src, mod_imm_neg:$imm),
3684 (SUBSri GPR:$src, mod_imm_neg:$imm)>;
3686 def : ARMPat<(add GPR:$src, imm0_65535_neg:$imm),
3687 (SUBrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>,
3688 Requires<[IsARM, HasV6T2]>;
3689 def : ARMPat<(ARMaddc GPR:$src, imm0_65535_neg:$imm),
3690 (SUBSrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>,
3691 Requires<[IsARM, HasV6T2]>;
3693 // The with-carry-in form matches bitwise not instead of the negation.
3694 // Effectively, the inverse interpretation of the carry flag already accounts
3695 // for part of the negation.
3696 def : ARMPat<(ARMadde GPR:$src, mod_imm_not:$imm, CPSR),
3697 (SBCri GPR:$src, mod_imm_not:$imm)>;
3698 def : ARMPat<(ARMadde GPR:$src, imm0_65535_neg:$imm, CPSR),
3699 (SBCrr GPR:$src, (MOVi16 (imm_not_XFORM imm:$imm)))>,
3700 Requires<[IsARM, HasV6T2]>;
3702 // Note: These are implemented in C++ code, because they have to generate
3703 // ADD/SUBrs instructions, which use a complex pattern that a xform function
3705 // (mul X, 2^n+1) -> (add (X << n), X)
3706 // (mul X, 2^n-1) -> (rsb X, (X << n))
3708 // ARM Arithmetic Instruction
3709 // GPR:$dst = GPR:$a op GPR:$b
3710 class AAI<bits<8> op27_20, bits<8> op11_4, string opc,
3711 list<dag> pattern = [],
3712 dag iops = (ins GPRnopc:$Rn, GPRnopc:$Rm),
3713 string asm = "\t$Rd, $Rn, $Rm">
3714 : AI<(outs GPRnopc:$Rd), iops, DPFrm, IIC_iALUr, opc, asm, pattern>,
3715 Sched<[WriteALU, ReadALU, ReadALU]> {
3719 let Inst{27-20} = op27_20;
3720 let Inst{11-4} = op11_4;
3721 let Inst{19-16} = Rn;
3722 let Inst{15-12} = Rd;
3725 let Unpredictable{11-8} = 0b1111;
3728 // Wrappers around the AAI class
3729 class AAIRevOpr<bits<8> op27_20, bits<8> op11_4, string opc,
3730 list<dag> pattern = []>
3731 : AAI<op27_20, op11_4, opc,
3733 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3736 class AAIIntrinsic<bits<8> op27_20, bits<8> op11_4, string opc,
3737 Intrinsic intrinsic>
3738 : AAI<op27_20, op11_4, opc,
3739 [(set GPRnopc:$Rd, (intrinsic GPRnopc:$Rn, GPRnopc:$Rm))]>;
3741 // Saturating add/subtract
3742 let hasSideEffects = 1 in {
3743 def QADD8 : AAIIntrinsic<0b01100010, 0b11111001, "qadd8", int_arm_qadd8>;
3744 def QADD16 : AAIIntrinsic<0b01100010, 0b11110001, "qadd16", int_arm_qadd16>;
3745 def QSUB16 : AAIIntrinsic<0b01100010, 0b11110111, "qsub16", int_arm_qsub16>;
3746 def QSUB8 : AAIIntrinsic<0b01100010, 0b11111111, "qsub8", int_arm_qsub8>;
3748 def QDADD : AAIRevOpr<0b00010100, 0b00000101, "qdadd",
3749 [(set GPRnopc:$Rd, (int_arm_qadd (int_arm_qadd GPRnopc:$Rm,
3752 def QDSUB : AAIRevOpr<0b00010110, 0b00000101, "qdsub",
3753 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm,
3754 (int_arm_qadd GPRnopc:$Rn, GPRnopc:$Rn)))]>;
3755 def QSUB : AAIRevOpr<0b00010010, 0b00000101, "qsub",
3756 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm, GPRnopc:$Rn))]>;
3757 let DecoderMethod = "DecodeQADDInstruction" in
3758 def QADD : AAIRevOpr<0b00010000, 0b00000101, "qadd",
3759 [(set GPRnopc:$Rd, (int_arm_qadd GPRnopc:$Rm, GPRnopc:$Rn))]>;
3762 def UQADD16 : AAIIntrinsic<0b01100110, 0b11110001, "uqadd16", int_arm_uqadd16>;
3763 def UQADD8 : AAIIntrinsic<0b01100110, 0b11111001, "uqadd8", int_arm_uqadd8>;
3764 def UQSUB16 : AAIIntrinsic<0b01100110, 0b11110111, "uqsub16", int_arm_uqsub16>;
3765 def UQSUB8 : AAIIntrinsic<0b01100110, 0b11111111, "uqsub8", int_arm_uqsub8>;
3766 def QASX : AAIIntrinsic<0b01100010, 0b11110011, "qasx", int_arm_qasx>;
3767 def QSAX : AAIIntrinsic<0b01100010, 0b11110101, "qsax", int_arm_qsax>;
3768 def UQASX : AAIIntrinsic<0b01100110, 0b11110011, "uqasx", int_arm_uqasx>;
3769 def UQSAX : AAIIntrinsic<0b01100110, 0b11110101, "uqsax", int_arm_uqsax>;
3771 // Signed/Unsigned add/subtract
3773 def SASX : AAIIntrinsic<0b01100001, 0b11110011, "sasx", int_arm_sasx>;
3774 def SADD16 : AAIIntrinsic<0b01100001, 0b11110001, "sadd16", int_arm_sadd16>;
3775 def SADD8 : AAIIntrinsic<0b01100001, 0b11111001, "sadd8", int_arm_sadd8>;
3776 def SSAX : AAIIntrinsic<0b01100001, 0b11110101, "ssax", int_arm_ssax>;
3777 def SSUB16 : AAIIntrinsic<0b01100001, 0b11110111, "ssub16", int_arm_ssub16>;
3778 def SSUB8 : AAIIntrinsic<0b01100001, 0b11111111, "ssub8", int_arm_ssub8>;
3779 def UASX : AAIIntrinsic<0b01100101, 0b11110011, "uasx", int_arm_uasx>;
3780 def UADD16 : AAIIntrinsic<0b01100101, 0b11110001, "uadd16", int_arm_uadd16>;
3781 def UADD8 : AAIIntrinsic<0b01100101, 0b11111001, "uadd8", int_arm_uadd8>;
3782 def USAX : AAIIntrinsic<0b01100101, 0b11110101, "usax", int_arm_usax>;
3783 def USUB16 : AAIIntrinsic<0b01100101, 0b11110111, "usub16", int_arm_usub16>;
3784 def USUB8 : AAIIntrinsic<0b01100101, 0b11111111, "usub8", int_arm_usub8>;
3786 // Signed/Unsigned halving add/subtract
3788 def SHASX : AAIIntrinsic<0b01100011, 0b11110011, "shasx", int_arm_shasx>;
3789 def SHADD16 : AAIIntrinsic<0b01100011, 0b11110001, "shadd16", int_arm_shadd16>;
3790 def SHADD8 : AAIIntrinsic<0b01100011, 0b11111001, "shadd8", int_arm_shadd8>;
3791 def SHSAX : AAIIntrinsic<0b01100011, 0b11110101, "shsax", int_arm_shsax>;
3792 def SHSUB16 : AAIIntrinsic<0b01100011, 0b11110111, "shsub16", int_arm_shsub16>;
3793 def SHSUB8 : AAIIntrinsic<0b01100011, 0b11111111, "shsub8", int_arm_shsub8>;
3794 def UHASX : AAIIntrinsic<0b01100111, 0b11110011, "uhasx", int_arm_uhasx>;
3795 def UHADD16 : AAIIntrinsic<0b01100111, 0b11110001, "uhadd16", int_arm_uhadd16>;
3796 def UHADD8 : AAIIntrinsic<0b01100111, 0b11111001, "uhadd8", int_arm_uhadd8>;
3797 def UHSAX : AAIIntrinsic<0b01100111, 0b11110101, "uhsax", int_arm_uhsax>;
3798 def UHSUB16 : AAIIntrinsic<0b01100111, 0b11110111, "uhsub16", int_arm_uhsub16>;
3799 def UHSUB8 : AAIIntrinsic<0b01100111, 0b11111111, "uhsub8", int_arm_uhsub8>;
3801 // Unsigned Sum of Absolute Differences [and Accumulate].
3803 def USAD8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3804 MulFrm /* for convenience */, NoItinerary, "usad8",
3806 [(set GPR:$Rd, (int_arm_usad8 GPR:$Rn, GPR:$Rm))]>,
3807 Requires<[IsARM, HasV6]>, Sched<[WriteALU, ReadALU, ReadALU]> {
3811 let Inst{27-20} = 0b01111000;
3812 let Inst{15-12} = 0b1111;
3813 let Inst{7-4} = 0b0001;
3814 let Inst{19-16} = Rd;
3815 let Inst{11-8} = Rm;
3818 def USADA8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3819 MulFrm /* for convenience */, NoItinerary, "usada8",
3820 "\t$Rd, $Rn, $Rm, $Ra",
3821 [(set GPR:$Rd, (int_arm_usada8 GPR:$Rn, GPR:$Rm, GPR:$Ra))]>,
3822 Requires<[IsARM, HasV6]>, Sched<[WriteALU, ReadALU, ReadALU]>{
3827 let Inst{27-20} = 0b01111000;
3828 let Inst{7-4} = 0b0001;
3829 let Inst{19-16} = Rd;
3830 let Inst{15-12} = Ra;
3831 let Inst{11-8} = Rm;
3835 // Signed/Unsigned saturate
3836 def SSAT : AI<(outs GPRnopc:$Rd),
3837 (ins imm1_32:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3838 SatFrm, NoItinerary, "ssat", "\t$Rd, $sat_imm, $Rn$sh", []>,
3839 Requires<[IsARM,HasV6]>{
3844 let Inst{27-21} = 0b0110101;
3845 let Inst{5-4} = 0b01;
3846 let Inst{20-16} = sat_imm;
3847 let Inst{15-12} = Rd;
3848 let Inst{11-7} = sh{4-0};
3849 let Inst{6} = sh{5};
3853 def SSAT16 : AI<(outs GPRnopc:$Rd),
3854 (ins imm1_16:$sat_imm, GPRnopc:$Rn), SatFrm,
3855 NoItinerary, "ssat16", "\t$Rd, $sat_imm, $Rn", []>,
3856 Requires<[IsARM,HasV6]>{
3860 let Inst{27-20} = 0b01101010;
3861 let Inst{11-4} = 0b11110011;
3862 let Inst{15-12} = Rd;
3863 let Inst{19-16} = sat_imm;
3867 def USAT : AI<(outs GPRnopc:$Rd),
3868 (ins imm0_31:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3869 SatFrm, NoItinerary, "usat", "\t$Rd, $sat_imm, $Rn$sh", []>,
3870 Requires<[IsARM,HasV6]> {
3875 let Inst{27-21} = 0b0110111;
3876 let Inst{5-4} = 0b01;
3877 let Inst{15-12} = Rd;
3878 let Inst{11-7} = sh{4-0};
3879 let Inst{6} = sh{5};
3880 let Inst{20-16} = sat_imm;
3884 def USAT16 : AI<(outs GPRnopc:$Rd),
3885 (ins imm0_15:$sat_imm, GPRnopc:$Rn), SatFrm,
3886 NoItinerary, "usat16", "\t$Rd, $sat_imm, $Rn", []>,
3887 Requires<[IsARM,HasV6]>{
3891 let Inst{27-20} = 0b01101110;
3892 let Inst{11-4} = 0b11110011;
3893 let Inst{15-12} = Rd;
3894 let Inst{19-16} = sat_imm;
3898 def : ARMV6Pat<(int_arm_ssat GPRnopc:$a, imm1_32:$pos),
3899 (SSAT imm1_32:$pos, GPRnopc:$a, 0)>;
3900 def : ARMV6Pat<(int_arm_usat GPRnopc:$a, imm0_31:$pos),
3901 (USAT imm0_31:$pos, GPRnopc:$a, 0)>;
3902 def : ARMPat<(ARMssatnoshift GPRnopc:$Rn, imm0_31:$imm),
3903 (SSAT imm0_31:$imm, GPRnopc:$Rn, 0)>;
3904 def : ARMPat<(ARMusatnoshift GPRnopc:$Rn, imm0_31:$imm),
3905 (USAT imm0_31:$imm, GPRnopc:$Rn, 0)>;
3906 def : ARMV6Pat<(int_arm_ssat16 GPRnopc:$a, imm1_16:$pos),
3907 (SSAT16 imm1_16:$pos, GPRnopc:$a)>;
3908 def : ARMV6Pat<(int_arm_usat16 GPRnopc:$a, imm0_15:$pos),
3909 (USAT16 imm0_15:$pos, GPRnopc:$a)>;
3911 //===----------------------------------------------------------------------===//
3912 // Bitwise Instructions.
3915 defm AND : AsI1_bin_irs<0b0000, "and",
3916 IIC_iBITi, IIC_iBITr, IIC_iBITsr, and, 1>;
3917 defm ORR : AsI1_bin_irs<0b1100, "orr",
3918 IIC_iBITi, IIC_iBITr, IIC_iBITsr, or, 1>;
3919 defm EOR : AsI1_bin_irs<0b0001, "eor",
3920 IIC_iBITi, IIC_iBITr, IIC_iBITsr, xor, 1>;
3921 defm BIC : AsI1_bin_irs<0b1110, "bic",
3922 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3923 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
3925 // FIXME: bf_inv_mask_imm should be two operands, the lsb and the msb, just
3926 // like in the actual instruction encoding. The complexity of mapping the mask
3927 // to the lsb/msb pair should be handled by ISel, not encapsulated in the
3928 // instruction description.
3929 def BFC : I<(outs GPR:$Rd), (ins GPR:$src, bf_inv_mask_imm:$imm),
3930 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3931 "bfc", "\t$Rd, $imm", "$src = $Rd",
3932 [(set GPR:$Rd, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
3933 Requires<[IsARM, HasV6T2]> {
3936 let Inst{27-21} = 0b0111110;
3937 let Inst{6-0} = 0b0011111;
3938 let Inst{15-12} = Rd;
3939 let Inst{11-7} = imm{4-0}; // lsb
3940 let Inst{20-16} = imm{9-5}; // msb
3943 // A8.6.18 BFI - Bitfield insert (Encoding A1)
3944 def BFI:I<(outs GPRnopc:$Rd), (ins GPRnopc:$src, GPR:$Rn, bf_inv_mask_imm:$imm),
3945 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3946 "bfi", "\t$Rd, $Rn, $imm", "$src = $Rd",
3947 [(set GPRnopc:$Rd, (ARMbfi GPRnopc:$src, GPR:$Rn,
3948 bf_inv_mask_imm:$imm))]>,
3949 Requires<[IsARM, HasV6T2]> {
3953 let Inst{27-21} = 0b0111110;
3954 let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15
3955 let Inst{15-12} = Rd;
3956 let Inst{11-7} = imm{4-0}; // lsb
3957 let Inst{20-16} = imm{9-5}; // width
3961 def MVNr : AsI1<0b1111, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMVNr,
3962 "mvn", "\t$Rd, $Rm",
3963 [(set GPR:$Rd, (not GPR:$Rm))]>, UnaryDP, Sched<[WriteALU]> {
3967 let Inst{19-16} = 0b0000;
3968 let Inst{11-4} = 0b00000000;
3969 let Inst{15-12} = Rd;
3972 let Unpredictable{19-16} = 0b1111;
3974 def MVNsi : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_imm:$shift),
3975 DPSoRegImmFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3976 [(set GPR:$Rd, (not so_reg_imm:$shift))]>, UnaryDP,
3981 let Inst{19-16} = 0b0000;
3982 let Inst{15-12} = Rd;
3983 let Inst{11-5} = shift{11-5};
3985 let Inst{3-0} = shift{3-0};
3987 let Unpredictable{19-16} = 0b1111;
3989 def MVNsr : AsI1<0b1111, (outs GPRnopc:$Rd), (ins so_reg_reg:$shift),
3990 DPSoRegRegFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3991 [(set GPRnopc:$Rd, (not so_reg_reg:$shift))]>, UnaryDP,
3996 let Inst{19-16} = 0b0000;
3997 let Inst{15-12} = Rd;
3998 let Inst{11-8} = shift{11-8};
4000 let Inst{6-5} = shift{6-5};
4002 let Inst{3-0} = shift{3-0};
4004 let Unpredictable{19-16} = 0b1111;
4006 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
4007 def MVNi : AsI1<0b1111, (outs GPR:$Rd), (ins mod_imm:$imm), DPFrm,
4008 IIC_iMVNi, "mvn", "\t$Rd, $imm",
4009 [(set GPR:$Rd, mod_imm_not:$imm)]>,UnaryDP, Sched<[WriteALU]> {
4013 let Inst{19-16} = 0b0000;
4014 let Inst{15-12} = Rd;
4015 let Inst{11-0} = imm;
4018 let AddedComplexity = 1 in
4019 def : ARMPat<(and GPR:$src, mod_imm_not:$imm),
4020 (BICri GPR:$src, mod_imm_not:$imm)>;
4022 //===----------------------------------------------------------------------===//
4023 // Multiply Instructions.
4025 class AsMul1I32<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
4026 string opc, string asm, list<dag> pattern>
4027 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
4031 let Inst{19-16} = Rd;
4032 let Inst{11-8} = Rm;
4035 class AsMul1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
4036 string opc, string asm, list<dag> pattern>
4037 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
4042 let Inst{19-16} = RdHi;
4043 let Inst{15-12} = RdLo;
4044 let Inst{11-8} = Rm;
4047 class AsMla1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
4048 string opc, string asm, list<dag> pattern>
4049 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
4054 let Inst{19-16} = RdHi;
4055 let Inst{15-12} = RdLo;
4056 let Inst{11-8} = Rm;
4060 // FIXME: The v5 pseudos are only necessary for the additional Constraint
4061 // property. Remove them when it's possible to add those properties
4062 // on an individual MachineInstr, not just an instruction description.
4063 let isCommutable = 1, TwoOperandAliasConstraint = "$Rn = $Rd" in {
4064 def MUL : AsMul1I32<0b0000000, (outs GPRnopc:$Rd),
4065 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4066 IIC_iMUL32, "mul", "\t$Rd, $Rn, $Rm",
4067 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))]>,
4068 Requires<[IsARM, HasV6]>,
4069 Sched<[WriteMUL32, ReadMUL, ReadMUL]> {
4070 let Inst{15-12} = 0b0000;
4071 let Unpredictable{15-12} = 0b1111;
4074 let Constraints = "@earlyclobber $Rd" in
4075 def MULv5: ARMPseudoExpand<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm,
4076 pred:$p, cc_out:$s),
4078 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))],
4079 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s)>,
4080 Requires<[IsARM, NoV6, UseMulOps]>,
4081 Sched<[WriteMUL32, ReadMUL, ReadMUL]>;
4084 def MLA : AsMul1I32<0b0000001, (outs GPRnopc:$Rd),
4085 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra),
4086 IIC_iMAC32, "mla", "\t$Rd, $Rn, $Rm, $Ra",
4087 [(set GPRnopc:$Rd, (add (mul GPRnopc:$Rn, GPRnopc:$Rm), GPRnopc:$Ra))]>,
4088 Requires<[IsARM, HasV6, UseMulOps]>,
4089 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]> {
4091 let Inst{15-12} = Ra;
4094 let Constraints = "@earlyclobber $Rd" in
4095 def MLAv5: ARMPseudoExpand<(outs GPRnopc:$Rd),
4096 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra,
4097 pred:$p, cc_out:$s), 4, IIC_iMAC32,
4098 [(set GPRnopc:$Rd, (add (mul GPRnopc:$Rn, GPRnopc:$Rm), GPRnopc:$Ra))],
4099 (MLA GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra, pred:$p, cc_out:$s)>,
4100 Requires<[IsARM, NoV6]>,
4101 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4103 def MLS : AMul1I<0b0000011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4104 IIC_iMAC32, "mls", "\t$Rd, $Rn, $Rm, $Ra",
4105 [(set GPR:$Rd, (sub GPR:$Ra, (mul GPR:$Rn, GPR:$Rm)))]>,
4106 Requires<[IsARM, HasV6T2, UseMulOps]>,
4107 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]> {
4112 let Inst{19-16} = Rd;
4113 let Inst{15-12} = Ra;
4114 let Inst{11-8} = Rm;
4118 // Extra precision multiplies with low / high results
4119 let hasSideEffects = 0 in {
4120 let isCommutable = 1 in {
4121 def SMULL : AsMul1I64<0b0000110, (outs GPR:$RdLo, GPR:$RdHi),
4122 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
4123 "smull", "\t$RdLo, $RdHi, $Rn, $Rm",
4124 [(set GPR:$RdLo, GPR:$RdHi,
4125 (smullohi GPR:$Rn, GPR:$Rm))]>,
4126 Requires<[IsARM, HasV6]>,
4127 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>;
4129 def UMULL : AsMul1I64<0b0000100, (outs GPR:$RdLo, GPR:$RdHi),
4130 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
4131 "umull", "\t$RdLo, $RdHi, $Rn, $Rm",
4132 [(set GPR:$RdLo, GPR:$RdHi,
4133 (umullohi GPR:$Rn, GPR:$Rm))]>,
4134 Requires<[IsARM, HasV6]>,
4135 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL]>;
4137 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
4138 def SMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
4139 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
4141 [(set GPR:$RdLo, GPR:$RdHi,
4142 (smullohi GPR:$Rn, GPR:$Rm))],
4143 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
4144 Requires<[IsARM, NoV6]>,
4145 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>;
4147 def UMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
4148 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
4150 [(set GPR:$RdLo, GPR:$RdHi,
4151 (umullohi GPR:$Rn, GPR:$Rm))],
4152 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
4153 Requires<[IsARM, NoV6]>,
4154 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>;
4158 // Multiply + accumulate
4159 def SMLAL : AsMla1I64<0b0000111, (outs GPR:$RdLo, GPR:$RdHi),
4160 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64,
4161 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4162 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>,
4163 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4164 def UMLAL : AsMla1I64<0b0000101, (outs GPR:$RdLo, GPR:$RdHi),
4165 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64,
4166 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4167 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>,
4168 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4170 def UMAAL : AMul1I <0b0000010, (outs GPR:$RdLo, GPR:$RdHi),
4171 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4173 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4174 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>,
4175 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]> {
4180 let Inst{19-16} = RdHi;
4181 let Inst{15-12} = RdLo;
4182 let Inst{11-8} = Rm;
4187 "@earlyclobber $RdLo,@earlyclobber $RdHi,$RLo = $RdLo,$RHi = $RdHi" in {
4188 def SMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
4189 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s),
4191 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi,
4192 pred:$p, cc_out:$s)>,
4193 Requires<[IsARM, NoV6]>,
4194 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4195 def UMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
4196 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s),
4198 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi,
4199 pred:$p, cc_out:$s)>,
4200 Requires<[IsARM, NoV6]>,
4201 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4206 // Most significant word multiply
4207 def SMMUL : AMul2I <0b0111010, 0b0001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4208 IIC_iMUL32, "smmul", "\t$Rd, $Rn, $Rm",
4209 [(set GPR:$Rd, (mulhs GPR:$Rn, GPR:$Rm))]>,
4210 Requires<[IsARM, HasV6]>,
4211 Sched<[WriteMUL32, ReadMUL, ReadMUL]> {
4212 let Inst{15-12} = 0b1111;
4215 def SMMULR : AMul2I <0b0111010, 0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4216 IIC_iMUL32, "smmulr", "\t$Rd, $Rn, $Rm",
4217 [(set GPR:$Rd, (ARMsmmlar GPR:$Rn, GPR:$Rm, (i32 0)))]>,
4218 Requires<[IsARM, HasV6]>,
4219 Sched<[WriteMUL32, ReadMUL, ReadMUL]> {
4220 let Inst{15-12} = 0b1111;
4223 def SMMLA : AMul2Ia <0b0111010, 0b0001, (outs GPR:$Rd),
4224 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4225 IIC_iMAC32, "smmla", "\t$Rd, $Rn, $Rm, $Ra",
4226 [(set GPR:$Rd, (add (mulhs GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
4227 Requires<[IsARM, HasV6, UseMulOps]>,
4228 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4230 def SMMLAR : AMul2Ia <0b0111010, 0b0011, (outs GPR:$Rd),
4231 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4232 IIC_iMAC32, "smmlar", "\t$Rd, $Rn, $Rm, $Ra",
4233 [(set GPR:$Rd, (ARMsmmlar GPR:$Rn, GPR:$Rm, GPR:$Ra))]>,
4234 Requires<[IsARM, HasV6]>,
4235 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4237 def SMMLS : AMul2Ia <0b0111010, 0b1101, (outs GPR:$Rd),
4238 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4239 IIC_iMAC32, "smmls", "\t$Rd, $Rn, $Rm, $Ra", []>,
4240 Requires<[IsARM, HasV6, UseMulOps]>,
4241 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4243 def SMMLSR : AMul2Ia <0b0111010, 0b1111, (outs GPR:$Rd),
4244 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4245 IIC_iMAC32, "smmlsr", "\t$Rd, $Rn, $Rm, $Ra",
4246 [(set GPR:$Rd, (ARMsmmlsr GPR:$Rn, GPR:$Rm, GPR:$Ra))]>,
4247 Requires<[IsARM, HasV6]>,
4248 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4250 multiclass AI_smul<string opc> {
4251 def BB : AMulxyI<0b0001011, 0b00, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4252 IIC_iMUL16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm",
4253 [(set GPR:$Rd, (bb_mul GPR:$Rn, GPR:$Rm))]>,
4254 Requires<[IsARM, HasV5TE]>,
4255 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4257 def BT : AMulxyI<0b0001011, 0b10, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4258 IIC_iMUL16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm",
4259 [(set GPR:$Rd, (bt_mul GPR:$Rn, GPR:$Rm))]>,
4260 Requires<[IsARM, HasV5TE]>,
4261 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4263 def TB : AMulxyI<0b0001011, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4264 IIC_iMUL16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm",
4265 [(set GPR:$Rd, (tb_mul GPR:$Rn, GPR:$Rm))]>,
4266 Requires<[IsARM, HasV5TE]>,
4267 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4269 def TT : AMulxyI<0b0001011, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4270 IIC_iMUL16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm",
4271 [(set GPR:$Rd, (tt_mul GPR:$Rn, GPR:$Rm))]>,
4272 Requires<[IsARM, HasV5TE]>,
4273 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4275 def WB : AMulxyI<0b0001001, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4276 IIC_iMUL16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm",
4277 [(set GPR:$Rd, (ARMsmulwb GPR:$Rn, GPR:$Rm))]>,
4278 Requires<[IsARM, HasV5TE]>,
4279 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4281 def WT : AMulxyI<0b0001001, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4282 IIC_iMUL16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm",
4283 [(set GPR:$Rd, (ARMsmulwt GPR:$Rn, GPR:$Rm))]>,
4284 Requires<[IsARM, HasV5TE]>,
4285 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4289 multiclass AI_smla<string opc> {
4290 let DecoderMethod = "DecodeSMLAInstruction" in {
4291 def BB : AMulxyIa<0b0001000, 0b00, (outs GPRnopc:$Rd),
4292 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4293 IIC_iMAC16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra",
4294 [(set GPRnopc:$Rd, (add GPR:$Ra,
4295 (bb_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4296 Requires<[IsARM, HasV5TE, UseMulOps]>,
4297 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4299 def BT : AMulxyIa<0b0001000, 0b10, (outs GPRnopc:$Rd),
4300 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4301 IIC_iMAC16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra",
4302 [(set GPRnopc:$Rd, (add GPR:$Ra,
4303 (bt_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4304 Requires<[IsARM, HasV5TE, UseMulOps]>,
4305 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4307 def TB : AMulxyIa<0b0001000, 0b01, (outs GPRnopc:$Rd),
4308 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4309 IIC_iMAC16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra",
4310 [(set GPRnopc:$Rd, (add GPR:$Ra,
4311 (tb_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4312 Requires<[IsARM, HasV5TE, UseMulOps]>,
4313 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4315 def TT : AMulxyIa<0b0001000, 0b11, (outs GPRnopc:$Rd),
4316 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4317 IIC_iMAC16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra",
4318 [(set GPRnopc:$Rd, (add GPR:$Ra,
4319 (tt_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4320 Requires<[IsARM, HasV5TE, UseMulOps]>,
4321 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4323 def WB : AMulxyIa<0b0001001, 0b00, (outs GPRnopc:$Rd),
4324 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4325 IIC_iMAC16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra",
4327 (add GPR:$Ra, (ARMsmulwb GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4328 Requires<[IsARM, HasV5TE, UseMulOps]>,
4329 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4331 def WT : AMulxyIa<0b0001001, 0b10, (outs GPRnopc:$Rd),
4332 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4333 IIC_iMAC16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra",
4335 (add GPR:$Ra, (ARMsmulwt GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4336 Requires<[IsARM, HasV5TE, UseMulOps]>,
4337 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4341 defm SMUL : AI_smul<"smul">;
4342 defm SMLA : AI_smla<"smla">;
4344 // Halfword multiply accumulate long: SMLAL<x><y>.
4345 class SMLAL<bits<2> opc1, string asm>
4346 : AMulxyI64<0b0001010, opc1,
4347 (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4348 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4349 IIC_iMAC64, asm, "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4350 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">,
4351 Requires<[IsARM, HasV5TE]>,
4352 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4354 def SMLALBB : SMLAL<0b00, "smlalbb">;
4355 def SMLALBT : SMLAL<0b10, "smlalbt">;
4356 def SMLALTB : SMLAL<0b01, "smlaltb">;
4357 def SMLALTT : SMLAL<0b11, "smlaltt">;
4359 def : ARMV5TEPat<(ARMsmlalbb GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4360 (SMLALBB $Rn, $Rm, $RLo, $RHi)>;
4361 def : ARMV5TEPat<(ARMsmlalbt GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4362 (SMLALBT $Rn, $Rm, $RLo, $RHi)>;
4363 def : ARMV5TEPat<(ARMsmlaltb GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4364 (SMLALTB $Rn, $Rm, $RLo, $RHi)>;
4365 def : ARMV5TEPat<(ARMsmlaltt GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4366 (SMLALTT $Rn, $Rm, $RLo, $RHi)>;
4368 // Helper class for AI_smld.
4369 class AMulDualIbase<bit long, bit sub, bit swap, dag oops, dag iops,
4370 InstrItinClass itin, string opc, string asm>
4371 : AI<oops, iops, MulFrm, itin, opc, asm, []>,
4372 Requires<[IsARM, HasV6]> {
4375 let Inst{27-23} = 0b01110;
4376 let Inst{22} = long;
4377 let Inst{21-20} = 0b00;
4378 let Inst{11-8} = Rm;
4385 class AMulDualI<bit long, bit sub, bit swap, dag oops, dag iops,
4386 InstrItinClass itin, string opc, string asm>
4387 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4389 let Inst{15-12} = 0b1111;
4390 let Inst{19-16} = Rd;
4392 class AMulDualIa<bit long, bit sub, bit swap, dag oops, dag iops,
4393 InstrItinClass itin, string opc, string asm>
4394 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4397 let Inst{19-16} = Rd;
4398 let Inst{15-12} = Ra;
4400 class AMulDualI64<bit long, bit sub, bit swap, dag oops, dag iops,
4401 InstrItinClass itin, string opc, string asm>
4402 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4405 let Inst{19-16} = RdHi;
4406 let Inst{15-12} = RdLo;
4409 multiclass AI_smld<bit sub, string opc> {
4411 def D : AMulDualIa<0, sub, 0, (outs GPRnopc:$Rd),
4412 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4413 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm, $Ra">,
4414 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4416 def DX: AMulDualIa<0, sub, 1, (outs GPRnopc:$Rd),
4417 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4418 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm, $Ra">,
4419 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4421 def LD: AMulDualI64<1, sub, 0, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4422 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4424 !strconcat(opc, "ld"), "\t$RdLo, $RdHi, $Rn, $Rm">,
4425 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">,
4426 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4428 def LDX : AMulDualI64<1, sub, 1, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4429 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4431 !strconcat(opc, "ldx"),"\t$RdLo, $RdHi, $Rn, $Rm">,
4432 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">,
4433 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>;
4436 defm SMLA : AI_smld<0, "smla">;
4437 defm SMLS : AI_smld<1, "smls">;
4439 def : ARMV6Pat<(int_arm_smlad GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4440 (SMLAD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>;
4441 def : ARMV6Pat<(int_arm_smladx GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4442 (SMLADX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>;
4443 def : ARMV6Pat<(int_arm_smlsd GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4444 (SMLSD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>;
4445 def : ARMV6Pat<(int_arm_smlsdx GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4446 (SMLSDX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>;
4447 def : ARMV6Pat<(ARMSmlald GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4448 (SMLALD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>;
4449 def : ARMV6Pat<(ARMSmlaldx GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4450 (SMLALDX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>;
4451 def : ARMV6Pat<(ARMSmlsld GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4452 (SMLSLD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>;
4453 def : ARMV6Pat<(ARMSmlsldx GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4454 (SMLSLDX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>;
4456 multiclass AI_sdml<bit sub, string opc> {
4458 def D:AMulDualI<0, sub, 0, (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm),
4459 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm">,
4460 Sched<[WriteMUL32, ReadMUL, ReadMUL]>;
4461 def DX:AMulDualI<0, sub, 1, (outs GPRnopc:$Rd),(ins GPRnopc:$Rn, GPRnopc:$Rm),
4462 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm">,
4463 Sched<[WriteMUL32, ReadMUL, ReadMUL]>;
4466 defm SMUA : AI_sdml<0, "smua">;
4467 defm SMUS : AI_sdml<1, "smus">;
4469 def : ARMV6Pat<(int_arm_smuad GPRnopc:$Rn, GPRnopc:$Rm),
4470 (SMUAD GPRnopc:$Rn, GPRnopc:$Rm)>;
4471 def : ARMV6Pat<(int_arm_smuadx GPRnopc:$Rn, GPRnopc:$Rm),
4472 (SMUADX GPRnopc:$Rn, GPRnopc:$Rm)>;
4473 def : ARMV6Pat<(int_arm_smusd GPRnopc:$Rn, GPRnopc:$Rm),
4474 (SMUSD GPRnopc:$Rn, GPRnopc:$Rm)>;
4475 def : ARMV6Pat<(int_arm_smusdx GPRnopc:$Rn, GPRnopc:$Rm),
4476 (SMUSDX GPRnopc:$Rn, GPRnopc:$Rm)>;
4478 //===----------------------------------------------------------------------===//
4479 // Division Instructions (ARMv7-A with virtualization extension)
4481 def SDIV : ADivA1I<0b001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV,
4482 "sdiv", "\t$Rd, $Rn, $Rm",
4483 [(set GPR:$Rd, (sdiv GPR:$Rn, GPR:$Rm))]>,
4484 Requires<[IsARM, HasDivideInARM]>,
4487 def UDIV : ADivA1I<0b011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV,
4488 "udiv", "\t$Rd, $Rn, $Rm",
4489 [(set GPR:$Rd, (udiv GPR:$Rn, GPR:$Rm))]>,
4490 Requires<[IsARM, HasDivideInARM]>,
4493 //===----------------------------------------------------------------------===//
4494 // Misc. Arithmetic Instructions.
4497 def CLZ : AMiscA1I<0b00010110, 0b0001, (outs GPR:$Rd), (ins GPR:$Rm),
4498 IIC_iUNAr, "clz", "\t$Rd, $Rm",
4499 [(set GPR:$Rd, (ctlz GPR:$Rm))]>, Requires<[IsARM, HasV5T]>,
4502 def RBIT : AMiscA1I<0b01101111, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
4503 IIC_iUNAr, "rbit", "\t$Rd, $Rm",
4504 [(set GPR:$Rd, (bitreverse GPR:$Rm))]>,
4505 Requires<[IsARM, HasV6T2]>,
4508 def REV : AMiscA1I<0b01101011, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
4509 IIC_iUNAr, "rev", "\t$Rd, $Rm",
4510 [(set GPR:$Rd, (bswap GPR:$Rm))]>, Requires<[IsARM, HasV6]>,
4513 let AddedComplexity = 5 in
4514 def REV16 : AMiscA1I<0b01101011, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
4515 IIC_iUNAr, "rev16", "\t$Rd, $Rm",
4516 [(set GPR:$Rd, (rotr (bswap GPR:$Rm), (i32 16)))]>,
4517 Requires<[IsARM, HasV6]>,
4520 def : ARMV6Pat<(srl (bswap (extloadi16 addrmode3:$addr)), (i32 16)),
4521 (REV16 (LDRH addrmode3:$addr))>;
4522 def : ARMV6Pat<(truncstorei16 (srl (bswap GPR:$Rn), (i32 16)), addrmode3:$addr),
4523 (STRH (REV16 GPR:$Rn), addrmode3:$addr)>;
4525 let AddedComplexity = 5 in
4526 def REVSH : AMiscA1I<0b01101111, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
4527 IIC_iUNAr, "revsh", "\t$Rd, $Rm",
4528 [(set GPR:$Rd, (sra (bswap GPR:$Rm), (i32 16)))]>,
4529 Requires<[IsARM, HasV6]>,
4532 def : ARMV6Pat<(or (sra (shl GPR:$Rm, (i32 24)), (i32 16)),
4533 (and (srl GPR:$Rm, (i32 8)), 0xFF)),
4536 def PKHBT : APKHI<0b01101000, 0, (outs GPRnopc:$Rd),
4537 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_lsl_amt:$sh),
4538 IIC_iALUsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh",
4539 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF),
4540 (and (shl GPRnopc:$Rm, pkh_lsl_amt:$sh),
4542 Requires<[IsARM, HasV6]>,
4543 Sched<[WriteALUsi, ReadALU]>;
4545 // Alternate cases for PKHBT where identities eliminate some nodes.
4546 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (and GPRnopc:$Rm, 0xFFFF0000)),
4547 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, 0)>;
4548 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (shl GPRnopc:$Rm, imm16_31:$sh)),
4549 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, imm16_31:$sh)>;
4551 // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
4552 // will match the pattern below.
4553 def PKHTB : APKHI<0b01101000, 1, (outs GPRnopc:$Rd),
4554 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_asr_amt:$sh),
4555 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh",
4556 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF0000),
4557 (and (sra GPRnopc:$Rm, pkh_asr_amt:$sh),
4559 Requires<[IsARM, HasV6]>,
4560 Sched<[WriteALUsi, ReadALU]>;
4562 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
4563 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
4564 // We also can not replace a srl (17..31) by an arithmetic shift we would use in
4565 // pkhtb src1, src2, asr (17..31).
4566 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4567 (srl GPRnopc:$src2, imm16:$sh)),
4568 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16:$sh)>;
4569 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4570 (sra GPRnopc:$src2, imm16_31:$sh)),
4571 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16_31:$sh)>;
4572 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4573 (and (srl GPRnopc:$src2, imm1_15:$sh), 0xFFFF)),
4574 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm1_15:$sh)>;
4576 //===----------------------------------------------------------------------===//
4580 // + CRC32{B,H,W} 0x04C11DB7
4581 // + CRC32C{B,H,W} 0x1EDC6F41
4584 class AI_crc32<bit C, bits<2> sz, string suffix, SDPatternOperator builtin>
4585 : AInoP<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm), MiscFrm, NoItinerary,
4586 !strconcat("crc32", suffix), "\t$Rd, $Rn, $Rm",
4587 [(set GPRnopc:$Rd, (builtin GPRnopc:$Rn, GPRnopc:$Rm))]>,
4588 Requires<[IsARM, HasV8, HasCRC]> {
4593 let Inst{31-28} = 0b1110;
4594 let Inst{27-23} = 0b00010;
4595 let Inst{22-21} = sz;
4597 let Inst{19-16} = Rn;
4598 let Inst{15-12} = Rd;
4599 let Inst{11-10} = 0b00;
4602 let Inst{7-4} = 0b0100;
4605 let Unpredictable{11-8} = 0b1101;
4608 def CRC32B : AI_crc32<0, 0b00, "b", int_arm_crc32b>;
4609 def CRC32CB : AI_crc32<1, 0b00, "cb", int_arm_crc32cb>;
4610 def CRC32H : AI_crc32<0, 0b01, "h", int_arm_crc32h>;
4611 def CRC32CH : AI_crc32<1, 0b01, "ch", int_arm_crc32ch>;
4612 def CRC32W : AI_crc32<0, 0b10, "w", int_arm_crc32w>;
4613 def CRC32CW : AI_crc32<1, 0b10, "cw", int_arm_crc32cw>;
4615 //===----------------------------------------------------------------------===//
4616 // ARMv8.1a Privilege Access Never extension
4620 def SETPAN : AInoP<(outs), (ins imm0_1:$imm), MiscFrm, NoItinerary, "setpan",
4621 "\t$imm", []>, Requires<[IsARM, HasV8, HasV8_1a]> {
4624 let Inst{31-28} = 0b1111;
4625 let Inst{27-20} = 0b00010001;
4626 let Inst{19-16} = 0b0000;
4627 let Inst{15-10} = 0b000000;
4630 let Inst{7-4} = 0b0000;
4631 let Inst{3-0} = 0b0000;
4633 let Unpredictable{19-16} = 0b1111;
4634 let Unpredictable{15-10} = 0b111111;
4635 let Unpredictable{8} = 0b1;
4636 let Unpredictable{3-0} = 0b1111;
4639 //===----------------------------------------------------------------------===//
4640 // Comparison Instructions...
4643 defm CMP : AI1_cmp_irs<0b1010, "cmp",
4644 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr, ARMcmp>;
4646 // ARMcmpZ can re-use the above instruction definitions.
4647 def : ARMPat<(ARMcmpZ GPR:$src, mod_imm:$imm),
4648 (CMPri GPR:$src, mod_imm:$imm)>;
4649 def : ARMPat<(ARMcmpZ GPR:$src, GPR:$rhs),
4650 (CMPrr GPR:$src, GPR:$rhs)>;
4651 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_imm:$rhs),
4652 (CMPrsi GPR:$src, so_reg_imm:$rhs)>;
4653 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_reg:$rhs),
4654 (CMPrsr GPR:$src, so_reg_reg:$rhs)>;
4656 // CMN register-integer
4657 let isCompare = 1, Defs = [CPSR] in {
4658 def CMNri : AI1<0b1011, (outs), (ins GPR:$Rn, mod_imm:$imm), DPFrm, IIC_iCMPi,
4659 "cmn", "\t$Rn, $imm",
4660 [(ARMcmn GPR:$Rn, mod_imm:$imm)]>,
4661 Sched<[WriteCMP, ReadALU]> {
4666 let Inst{19-16} = Rn;
4667 let Inst{15-12} = 0b0000;
4668 let Inst{11-0} = imm;
4670 let Unpredictable{15-12} = 0b1111;
4673 // CMN register-register/shift
4674 def CMNzrr : AI1<0b1011, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, IIC_iCMPr,
4675 "cmn", "\t$Rn, $Rm",
4676 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4677 GPR:$Rn, GPR:$Rm)]>, Sched<[WriteCMP, ReadALU, ReadALU]> {
4680 let isCommutable = 1;
4683 let Inst{19-16} = Rn;
4684 let Inst{15-12} = 0b0000;
4685 let Inst{11-4} = 0b00000000;
4688 let Unpredictable{15-12} = 0b1111;
4691 def CMNzrsi : AI1<0b1011, (outs),
4692 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, IIC_iCMPsr,
4693 "cmn", "\t$Rn, $shift",
4694 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4695 GPR:$Rn, so_reg_imm:$shift)]>,
4696 Sched<[WriteCMPsi, ReadALU]> {
4701 let Inst{19-16} = Rn;
4702 let Inst{15-12} = 0b0000;
4703 let Inst{11-5} = shift{11-5};
4705 let Inst{3-0} = shift{3-0};
4707 let Unpredictable{15-12} = 0b1111;
4710 def CMNzrsr : AI1<0b1011, (outs),
4711 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, IIC_iCMPsr,
4712 "cmn", "\t$Rn, $shift",
4713 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4714 GPRnopc:$Rn, so_reg_reg:$shift)]>,
4715 Sched<[WriteCMPsr, ReadALU]> {
4720 let Inst{19-16} = Rn;
4721 let Inst{15-12} = 0b0000;
4722 let Inst{11-8} = shift{11-8};
4724 let Inst{6-5} = shift{6-5};
4726 let Inst{3-0} = shift{3-0};
4728 let Unpredictable{15-12} = 0b1111;
4733 def : ARMPat<(ARMcmp GPR:$src, mod_imm_neg:$imm),
4734 (CMNri GPR:$src, mod_imm_neg:$imm)>;
4736 def : ARMPat<(ARMcmpZ GPR:$src, mod_imm_neg:$imm),
4737 (CMNri GPR:$src, mod_imm_neg:$imm)>;
4739 // Note that TST/TEQ don't set all the same flags that CMP does!
4740 defm TST : AI1_cmp_irs<0b1000, "tst",
4741 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
4742 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>, 1,
4743 "DecodeTSTInstruction">;
4744 defm TEQ : AI1_cmp_irs<0b1001, "teq",
4745 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
4746 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>, 1>;
4748 // Pseudo i64 compares for some floating point compares.
4749 let usesCustomInserter = 1, isBranch = 1, isTerminator = 1,
4751 def BCCi64 : PseudoInst<(outs),
4752 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, brtarget:$dst),
4754 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, bb:$dst)]>,
4757 def BCCZi64 : PseudoInst<(outs),
4758 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, brtarget:$dst), IIC_Br,
4759 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, 0, 0, bb:$dst)]>,
4761 } // usesCustomInserter
4764 // Conditional moves
4765 let hasSideEffects = 0 in {
4767 let isCommutable = 1, isSelect = 1 in
4768 def MOVCCr : ARMPseudoInst<(outs GPR:$Rd),
4769 (ins GPR:$false, GPR:$Rm, cmovpred:$p),
4771 [(set GPR:$Rd, (ARMcmov GPR:$false, GPR:$Rm,
4773 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4775 def MOVCCsi : ARMPseudoInst<(outs GPR:$Rd),
4776 (ins GPR:$false, so_reg_imm:$shift, cmovpred:$p),
4779 (ARMcmov GPR:$false, so_reg_imm:$shift,
4781 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4782 def MOVCCsr : ARMPseudoInst<(outs GPR:$Rd),
4783 (ins GPR:$false, so_reg_reg:$shift, cmovpred:$p),
4785 [(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_reg:$shift,
4787 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4790 let isMoveImm = 1 in
4792 : ARMPseudoInst<(outs GPR:$Rd),
4793 (ins GPR:$false, imm0_65535_expr:$imm, cmovpred:$p),
4795 [(set GPR:$Rd, (ARMcmov GPR:$false, imm0_65535:$imm,
4797 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>,
4800 let isMoveImm = 1 in
4801 def MOVCCi : ARMPseudoInst<(outs GPR:$Rd),
4802 (ins GPR:$false, mod_imm:$imm, cmovpred:$p),
4804 [(set GPR:$Rd, (ARMcmov GPR:$false, mod_imm:$imm,
4806 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4808 // Two instruction predicate mov immediate.
4809 let isMoveImm = 1 in
4811 : ARMPseudoInst<(outs GPR:$Rd),
4812 (ins GPR:$false, i32imm:$src, cmovpred:$p),
4814 [(set GPR:$Rd, (ARMcmov GPR:$false, imm:$src,
4816 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>;
4818 let isMoveImm = 1 in
4819 def MVNCCi : ARMPseudoInst<(outs GPR:$Rd),
4820 (ins GPR:$false, mod_imm:$imm, cmovpred:$p),
4822 [(set GPR:$Rd, (ARMcmov GPR:$false, mod_imm_not:$imm,
4824 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4829 //===----------------------------------------------------------------------===//
4830 // Atomic operations intrinsics
4833 def MemBarrierOptOperand : AsmOperandClass {
4834 let Name = "MemBarrierOpt";
4835 let ParserMethod = "parseMemBarrierOptOperand";
4837 def memb_opt : Operand<i32> {
4838 let PrintMethod = "printMemBOption";
4839 let ParserMatchClass = MemBarrierOptOperand;
4840 let DecoderMethod = "DecodeMemBarrierOption";
4843 def InstSyncBarrierOptOperand : AsmOperandClass {
4844 let Name = "InstSyncBarrierOpt";
4845 let ParserMethod = "parseInstSyncBarrierOptOperand";
4847 def instsyncb_opt : Operand<i32> {
4848 let PrintMethod = "printInstSyncBOption";
4849 let ParserMatchClass = InstSyncBarrierOptOperand;
4850 let DecoderMethod = "DecodeInstSyncBarrierOption";
4853 def TraceSyncBarrierOptOperand : AsmOperandClass {
4854 let Name = "TraceSyncBarrierOpt";
4855 let ParserMethod = "parseTraceSyncBarrierOptOperand";
4857 def tsb_opt : Operand<i32> {
4858 let PrintMethod = "printTraceSyncBOption";
4859 let ParserMatchClass = TraceSyncBarrierOptOperand;
4862 // Memory barriers protect the atomic sequences
4863 let hasSideEffects = 1 in {
4864 def DMB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4865 "dmb", "\t$opt", [(int_arm_dmb (i32 imm0_15:$opt))]>,
4866 Requires<[IsARM, HasDB]> {
4868 let Inst{31-4} = 0xf57ff05;
4869 let Inst{3-0} = opt;
4872 def DSB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4873 "dsb", "\t$opt", [(int_arm_dsb (i32 imm0_15:$opt))]>,
4874 Requires<[IsARM, HasDB]> {
4876 let Inst{31-4} = 0xf57ff04;
4877 let Inst{3-0} = opt;
4880 // ISB has only full system option
4881 def ISB : AInoP<(outs), (ins instsyncb_opt:$opt), MiscFrm, NoItinerary,
4882 "isb", "\t$opt", [(int_arm_isb (i32 imm0_15:$opt))]>,
4883 Requires<[IsARM, HasDB]> {
4885 let Inst{31-4} = 0xf57ff06;
4886 let Inst{3-0} = opt;
4889 let hasNoSchedulingInfo = 1 in
4890 def TSB : AInoP<(outs), (ins tsb_opt:$opt), MiscFrm, NoItinerary,
4891 "tsb", "\t$opt", []>, Requires<[IsARM, HasV8_4a]> {
4892 let Inst{31-0} = 0xe320f012;
4897 // Armv8.5-A speculation barrier
4898 def SB : AInoP<(outs), (ins), MiscFrm, NoItinerary, "sb", "", []>,
4899 Requires<[IsARM, HasSB]>, Sched<[]> {
4900 let Inst{31-0} = 0xf57ff070;
4901 let Unpredictable = 0x000fff0f;
4902 let hasSideEffects = 1;
4905 let usesCustomInserter = 1, Defs = [CPSR] in {
4907 // Pseudo instruction that combines movs + predicated rsbmi
4908 // to implement integer ABS
4909 def ABS : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$src), 8, NoItinerary, []>;
4912 let usesCustomInserter = 1, Defs = [CPSR] in {
4913 def COPY_STRUCT_BYVAL_I32 : PseudoInst<
4914 (outs), (ins GPR:$dst, GPR:$src, i32imm:$size, i32imm:$alignment),
4916 [(ARMcopystructbyval GPR:$dst, GPR:$src, imm:$size, imm:$alignment)]>;
4919 let hasPostISelHook = 1, Constraints = "$newdst = $dst, $newsrc = $src" in {
4920 // %newsrc, %newdst = MEMCPY %dst, %src, N, ...N scratch regs...
4921 // Copies N registers worth of memory from address %src to address %dst
4922 // and returns the incremented addresses. N scratch register will
4923 // be attached for the copy to use.
4924 def MEMCPY : PseudoInst<
4925 (outs GPR:$newdst, GPR:$newsrc),
4926 (ins GPR:$dst, GPR:$src, i32imm:$nreg, variable_ops),
4928 [(set GPR:$newdst, GPR:$newsrc,
4929 (ARMmemcopy GPR:$dst, GPR:$src, imm:$nreg))]>;
4932 def ldrex_1 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4933 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4936 def ldrex_2 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4937 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4940 def ldrex_4 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4941 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4944 def strex_1 : PatFrag<(ops node:$val, node:$ptr),
4945 (int_arm_strex node:$val, node:$ptr), [{
4946 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4949 def strex_2 : PatFrag<(ops node:$val, node:$ptr),
4950 (int_arm_strex node:$val, node:$ptr), [{
4951 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4954 def strex_4 : PatFrag<(ops node:$val, node:$ptr),
4955 (int_arm_strex node:$val, node:$ptr), [{
4956 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4959 def ldaex_1 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4960 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4963 def ldaex_2 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4964 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4967 def ldaex_4 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4968 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4971 def stlex_1 : PatFrag<(ops node:$val, node:$ptr),
4972 (int_arm_stlex node:$val, node:$ptr), [{
4973 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4976 def stlex_2 : PatFrag<(ops node:$val, node:$ptr),
4977 (int_arm_stlex node:$val, node:$ptr), [{
4978 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4981 def stlex_4 : PatFrag<(ops node:$val, node:$ptr),
4982 (int_arm_stlex node:$val, node:$ptr), [{
4983 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4986 let mayLoad = 1 in {
4987 def LDREXB : AIldrex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4988 NoItinerary, "ldrexb", "\t$Rt, $addr",
4989 [(set GPR:$Rt, (ldrex_1 addr_offset_none:$addr))]>;
4990 def LDREXH : AIldrex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4991 NoItinerary, "ldrexh", "\t$Rt, $addr",
4992 [(set GPR:$Rt, (ldrex_2 addr_offset_none:$addr))]>;
4993 def LDREX : AIldrex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4994 NoItinerary, "ldrex", "\t$Rt, $addr",
4995 [(set GPR:$Rt, (ldrex_4 addr_offset_none:$addr))]>;
4996 let hasExtraDefRegAllocReq = 1 in
4997 def LDREXD : AIldrex<0b01, (outs GPRPairOp:$Rt),(ins addr_offset_none:$addr),
4998 NoItinerary, "ldrexd", "\t$Rt, $addr", []> {
4999 let DecoderMethod = "DecodeDoubleRegLoad";
5002 def LDAEXB : AIldaex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
5003 NoItinerary, "ldaexb", "\t$Rt, $addr",
5004 [(set GPR:$Rt, (ldaex_1 addr_offset_none:$addr))]>;
5005 def LDAEXH : AIldaex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
5006 NoItinerary, "ldaexh", "\t$Rt, $addr",
5007 [(set GPR:$Rt, (ldaex_2 addr_offset_none:$addr))]>;
5008 def LDAEX : AIldaex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
5009 NoItinerary, "ldaex", "\t$Rt, $addr",
5010 [(set GPR:$Rt, (ldaex_4 addr_offset_none:$addr))]>;
5011 let hasExtraDefRegAllocReq = 1 in
5012 def LDAEXD : AIldaex<0b01, (outs GPRPairOp:$Rt),(ins addr_offset_none:$addr),
5013 NoItinerary, "ldaexd", "\t$Rt, $addr", []> {
5014 let DecoderMethod = "DecodeDoubleRegLoad";
5018 let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
5019 def STREXB: AIstrex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5020 NoItinerary, "strexb", "\t$Rd, $Rt, $addr",
5021 [(set GPR:$Rd, (strex_1 GPR:$Rt,
5022 addr_offset_none:$addr))]>;
5023 def STREXH: AIstrex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5024 NoItinerary, "strexh", "\t$Rd, $Rt, $addr",
5025 [(set GPR:$Rd, (strex_2 GPR:$Rt,
5026 addr_offset_none:$addr))]>;
5027 def STREX : AIstrex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5028 NoItinerary, "strex", "\t$Rd, $Rt, $addr",
5029 [(set GPR:$Rd, (strex_4 GPR:$Rt,
5030 addr_offset_none:$addr))]>;
5031 let hasExtraSrcRegAllocReq = 1 in
5032 def STREXD : AIstrex<0b01, (outs GPR:$Rd),
5033 (ins GPRPairOp:$Rt, addr_offset_none:$addr),
5034 NoItinerary, "strexd", "\t$Rd, $Rt, $addr", []> {
5035 let DecoderMethod = "DecodeDoubleRegStore";
5037 def STLEXB: AIstlex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5038 NoItinerary, "stlexb", "\t$Rd, $Rt, $addr",
5040 (stlex_1 GPR:$Rt, addr_offset_none:$addr))]>;
5041 def STLEXH: AIstlex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5042 NoItinerary, "stlexh", "\t$Rd, $Rt, $addr",
5044 (stlex_2 GPR:$Rt, addr_offset_none:$addr))]>;
5045 def STLEX : AIstlex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5046 NoItinerary, "stlex", "\t$Rd, $Rt, $addr",
5048 (stlex_4 GPR:$Rt, addr_offset_none:$addr))]>;
5049 let hasExtraSrcRegAllocReq = 1 in
5050 def STLEXD : AIstlex<0b01, (outs GPR:$Rd),
5051 (ins GPRPairOp:$Rt, addr_offset_none:$addr),
5052 NoItinerary, "stlexd", "\t$Rd, $Rt, $addr", []> {
5053 let DecoderMethod = "DecodeDoubleRegStore";
5057 def CLREX : AXI<(outs), (ins), MiscFrm, NoItinerary, "clrex",
5059 Requires<[IsARM, HasV6K]> {
5060 let Inst{31-0} = 0b11110101011111111111000000011111;
5063 def : ARMPat<(strex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr),
5064 (STREXB GPR:$Rt, addr_offset_none:$addr)>;
5065 def : ARMPat<(strex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr),
5066 (STREXH GPR:$Rt, addr_offset_none:$addr)>;
5068 def : ARMPat<(stlex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr),
5069 (STLEXB GPR:$Rt, addr_offset_none:$addr)>;
5070 def : ARMPat<(stlex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr),
5071 (STLEXH GPR:$Rt, addr_offset_none:$addr)>;
5073 class acquiring_load<PatFrag base>
5074 : PatFrag<(ops node:$ptr), (base node:$ptr), [{
5075 AtomicOrdering Ordering = cast<AtomicSDNode>(N)->getOrdering();
5076 return isAcquireOrStronger(Ordering);
5079 def atomic_load_acquire_8 : acquiring_load<atomic_load_8>;
5080 def atomic_load_acquire_16 : acquiring_load<atomic_load_16>;
5081 def atomic_load_acquire_32 : acquiring_load<atomic_load_32>;
5083 class releasing_store<PatFrag base>
5084 : PatFrag<(ops node:$ptr, node:$val), (base node:$ptr, node:$val), [{
5085 AtomicOrdering Ordering = cast<AtomicSDNode>(N)->getOrdering();
5086 return isReleaseOrStronger(Ordering);
5089 def atomic_store_release_8 : releasing_store<atomic_store_8>;
5090 def atomic_store_release_16 : releasing_store<atomic_store_16>;
5091 def atomic_store_release_32 : releasing_store<atomic_store_32>;
5093 let AddedComplexity = 8 in {
5094 def : ARMPat<(atomic_load_acquire_8 addr_offset_none:$addr), (LDAB addr_offset_none:$addr)>;
5095 def : ARMPat<(atomic_load_acquire_16 addr_offset_none:$addr), (LDAH addr_offset_none:$addr)>;
5096 def : ARMPat<(atomic_load_acquire_32 addr_offset_none:$addr), (LDA addr_offset_none:$addr)>;
5097 def : ARMPat<(atomic_store_release_8 addr_offset_none:$addr, GPR:$val), (STLB GPR:$val, addr_offset_none:$addr)>;
5098 def : ARMPat<(atomic_store_release_16 addr_offset_none:$addr, GPR:$val), (STLH GPR:$val, addr_offset_none:$addr)>;
5099 def : ARMPat<(atomic_store_release_32 addr_offset_none:$addr, GPR:$val), (STL GPR:$val, addr_offset_none:$addr)>;
5102 // SWP/SWPB are deprecated in V6/V7 and optional in v7VE.
5103 // FIXME Use InstAlias to generate LDREX/STREX pairs instead.
5104 let mayLoad = 1, mayStore = 1 in {
5105 def SWP : AIswp<0, (outs GPRnopc:$Rt),
5106 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swp", []>,
5107 Requires<[IsARM,PreV8]>;
5108 def SWPB: AIswp<1, (outs GPRnopc:$Rt),
5109 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swpb", []>,
5110 Requires<[IsARM,PreV8]>;
5113 //===----------------------------------------------------------------------===//
5114 // Coprocessor Instructions.
5117 def CDP : ABI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
5118 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
5119 NoItinerary, "cdp", "\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
5120 [(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
5121 imm:$CRm, imm:$opc2)]>,
5122 Requires<[IsARM,PreV8]> {
5130 let Inst{3-0} = CRm;
5132 let Inst{7-5} = opc2;
5133 let Inst{11-8} = cop;
5134 let Inst{15-12} = CRd;
5135 let Inst{19-16} = CRn;
5136 let Inst{23-20} = opc1;
5138 let DecoderNamespace = "CoProc";
5141 def CDP2 : ABXI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
5142 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
5143 NoItinerary, "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
5144 [(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
5145 imm:$CRm, imm:$opc2)]>,
5146 Requires<[IsARM,PreV8]> {
5147 let Inst{31-28} = 0b1111;
5155 let Inst{3-0} = CRm;
5157 let Inst{7-5} = opc2;
5158 let Inst{11-8} = cop;
5159 let Inst{15-12} = CRd;
5160 let Inst{19-16} = CRn;
5161 let Inst{23-20} = opc1;
5163 let DecoderNamespace = "CoProc";
5166 class ACI<dag oops, dag iops, string opc, string asm,
5167 list<dag> pattern, IndexMode im = IndexModeNone>
5168 : I<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
5169 opc, asm, "", pattern> {
5170 let Inst{27-25} = 0b110;
5172 class ACInoP<dag oops, dag iops, string opc, string asm,
5173 list<dag> pattern, IndexMode im = IndexModeNone>
5174 : InoP<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
5175 opc, asm, "", pattern> {
5176 let Inst{31-28} = 0b1111;
5177 let Inst{27-25} = 0b110;
5180 let DecoderNamespace = "CoProc" in {
5181 multiclass LdStCop<bit load, bit Dbit, string asm, list<dag> pattern> {
5182 def _OFFSET : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
5183 asm, "\t$cop, $CRd, $addr", pattern> {
5187 let Inst{24} = 1; // P = 1
5188 let Inst{23} = addr{8};
5189 let Inst{22} = Dbit;
5190 let Inst{21} = 0; // W = 0
5191 let Inst{20} = load;
5192 let Inst{19-16} = addr{12-9};
5193 let Inst{15-12} = CRd;
5194 let Inst{11-8} = cop;
5195 let Inst{7-0} = addr{7-0};
5196 let DecoderMethod = "DecodeCopMemInstruction";
5198 def _PRE : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr),
5199 asm, "\t$cop, $CRd, $addr!", [], IndexModePre> {
5203 let Inst{24} = 1; // P = 1
5204 let Inst{23} = addr{8};
5205 let Inst{22} = Dbit;
5206 let Inst{21} = 1; // W = 1
5207 let Inst{20} = load;
5208 let Inst{19-16} = addr{12-9};
5209 let Inst{15-12} = CRd;
5210 let Inst{11-8} = cop;
5211 let Inst{7-0} = addr{7-0};
5212 let DecoderMethod = "DecodeCopMemInstruction";
5214 def _POST: ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
5215 postidx_imm8s4:$offset),
5216 asm, "\t$cop, $CRd, $addr, $offset", [], IndexModePost> {
5221 let Inst{24} = 0; // P = 0
5222 let Inst{23} = offset{8};
5223 let Inst{22} = Dbit;
5224 let Inst{21} = 1; // W = 1
5225 let Inst{20} = load;
5226 let Inst{19-16} = addr;
5227 let Inst{15-12} = CRd;
5228 let Inst{11-8} = cop;
5229 let Inst{7-0} = offset{7-0};
5230 let DecoderMethod = "DecodeCopMemInstruction";
5232 def _OPTION : ACI<(outs),
5233 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
5234 coproc_option_imm:$option),
5235 asm, "\t$cop, $CRd, $addr, $option", []> {
5240 let Inst{24} = 0; // P = 0
5241 let Inst{23} = 1; // U = 1
5242 let Inst{22} = Dbit;
5243 let Inst{21} = 0; // W = 0
5244 let Inst{20} = load;
5245 let Inst{19-16} = addr;
5246 let Inst{15-12} = CRd;
5247 let Inst{11-8} = cop;
5248 let Inst{7-0} = option;
5249 let DecoderMethod = "DecodeCopMemInstruction";
5252 multiclass LdSt2Cop<bit load, bit Dbit, string asm, list<dag> pattern> {
5253 def _OFFSET : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
5254 asm, "\t$cop, $CRd, $addr", pattern> {
5258 let Inst{24} = 1; // P = 1
5259 let Inst{23} = addr{8};
5260 let Inst{22} = Dbit;
5261 let Inst{21} = 0; // W = 0
5262 let Inst{20} = load;
5263 let Inst{19-16} = addr{12-9};
5264 let Inst{15-12} = CRd;
5265 let Inst{11-8} = cop;
5266 let Inst{7-0} = addr{7-0};
5267 let DecoderMethod = "DecodeCopMemInstruction";
5269 def _PRE : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr),
5270 asm, "\t$cop, $CRd, $addr!", [], IndexModePre> {
5274 let Inst{24} = 1; // P = 1
5275 let Inst{23} = addr{8};
5276 let Inst{22} = Dbit;
5277 let Inst{21} = 1; // W = 1
5278 let Inst{20} = load;
5279 let Inst{19-16} = addr{12-9};
5280 let Inst{15-12} = CRd;
5281 let Inst{11-8} = cop;
5282 let Inst{7-0} = addr{7-0};
5283 let DecoderMethod = "DecodeCopMemInstruction";
5285 def _POST: ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
5286 postidx_imm8s4:$offset),
5287 asm, "\t$cop, $CRd, $addr, $offset", [], IndexModePost> {
5292 let Inst{24} = 0; // P = 0
5293 let Inst{23} = offset{8};
5294 let Inst{22} = Dbit;
5295 let Inst{21} = 1; // W = 1
5296 let Inst{20} = load;
5297 let Inst{19-16} = addr;
5298 let Inst{15-12} = CRd;
5299 let Inst{11-8} = cop;
5300 let Inst{7-0} = offset{7-0};
5301 let DecoderMethod = "DecodeCopMemInstruction";
5303 def _OPTION : ACInoP<(outs),
5304 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
5305 coproc_option_imm:$option),
5306 asm, "\t$cop, $CRd, $addr, $option", []> {
5311 let Inst{24} = 0; // P = 0
5312 let Inst{23} = 1; // U = 1
5313 let Inst{22} = Dbit;
5314 let Inst{21} = 0; // W = 0
5315 let Inst{20} = load;
5316 let Inst{19-16} = addr;
5317 let Inst{15-12} = CRd;
5318 let Inst{11-8} = cop;
5319 let Inst{7-0} = option;
5320 let DecoderMethod = "DecodeCopMemInstruction";
5324 defm LDC : LdStCop <1, 0, "ldc", [(int_arm_ldc imm:$cop, imm:$CRd, addrmode5:$addr)]>;
5325 defm LDCL : LdStCop <1, 1, "ldcl", [(int_arm_ldcl imm:$cop, imm:$CRd, addrmode5:$addr)]>;
5326 defm LDC2 : LdSt2Cop<1, 0, "ldc2", [(int_arm_ldc2 imm:$cop, imm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>;
5327 defm LDC2L : LdSt2Cop<1, 1, "ldc2l", [(int_arm_ldc2l imm:$cop, imm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>;
5329 defm STC : LdStCop <0, 0, "stc", [(int_arm_stc imm:$cop, imm:$CRd, addrmode5:$addr)]>;
5330 defm STCL : LdStCop <0, 1, "stcl", [(int_arm_stcl imm:$cop, imm:$CRd, addrmode5:$addr)]>;
5331 defm STC2 : LdSt2Cop<0, 0, "stc2", [(int_arm_stc2 imm:$cop, imm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>;
5332 defm STC2L : LdSt2Cop<0, 1, "stc2l", [(int_arm_stc2l imm:$cop, imm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>;
5334 } // DecoderNamespace = "CoProc"
5336 //===----------------------------------------------------------------------===//
5337 // Move between coprocessor and ARM core register.
5340 class MovRCopro<string opc, bit direction, dag oops, dag iops,
5342 : ABI<0b1110, oops, iops, NoItinerary, opc,
5343 "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2", pattern> {
5344 let Inst{20} = direction;
5354 let Inst{15-12} = Rt;
5355 let Inst{11-8} = cop;
5356 let Inst{23-21} = opc1;
5357 let Inst{7-5} = opc2;
5358 let Inst{3-0} = CRm;
5359 let Inst{19-16} = CRn;
5361 let DecoderNamespace = "CoProc";
5364 def MCR : MovRCopro<"mcr", 0 /* from ARM core register to coprocessor */,
5366 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5367 c_imm:$CRm, imm0_7:$opc2),
5368 [(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
5369 imm:$CRm, imm:$opc2)]>,
5370 ComplexDeprecationPredicate<"MCR">;
5371 def : ARMInstAlias<"mcr${p} $cop, $opc1, $Rt, $CRn, $CRm",
5372 (MCR p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5373 c_imm:$CRm, 0, pred:$p)>;
5374 def MRC : MovRCopro<"mrc", 1 /* from coprocessor to ARM core register */,
5375 (outs GPRwithAPSR:$Rt),
5376 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
5378 def : ARMInstAlias<"mrc${p} $cop, $opc1, $Rt, $CRn, $CRm",
5379 (MRC GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
5380 c_imm:$CRm, 0, pred:$p)>;
5382 def : ARMPat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
5383 (MRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
5385 class MovRCopro2<string opc, bit direction, dag oops, dag iops,
5387 : ABXI<0b1110, oops, iops, NoItinerary,
5388 !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), pattern> {
5389 let Inst{31-24} = 0b11111110;
5390 let Inst{20} = direction;
5400 let Inst{15-12} = Rt;
5401 let Inst{11-8} = cop;
5402 let Inst{23-21} = opc1;
5403 let Inst{7-5} = opc2;
5404 let Inst{3-0} = CRm;
5405 let Inst{19-16} = CRn;
5407 let DecoderNamespace = "CoProc";
5410 def MCR2 : MovRCopro2<"mcr2", 0 /* from ARM core register to coprocessor */,
5412 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5413 c_imm:$CRm, imm0_7:$opc2),
5414 [(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
5415 imm:$CRm, imm:$opc2)]>,
5416 Requires<[IsARM,PreV8]>;
5417 def : ARMInstAlias<"mcr2 $cop, $opc1, $Rt, $CRn, $CRm",
5418 (MCR2 p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5420 def MRC2 : MovRCopro2<"mrc2", 1 /* from coprocessor to ARM core register */,
5421 (outs GPRwithAPSR:$Rt),
5422 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
5424 Requires<[IsARM,PreV8]>;
5425 def : ARMInstAlias<"mrc2 $cop, $opc1, $Rt, $CRn, $CRm",
5426 (MRC2 GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
5429 def : ARMV5TPat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn,
5430 imm:$CRm, imm:$opc2),
5431 (MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
5433 class MovRRCopro<string opc, bit direction, dag oops, dag iops, list<dag>
5435 : ABI<0b1100, oops, iops, NoItinerary, opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm",
5438 let Inst{23-21} = 0b010;
5439 let Inst{20} = direction;
5447 let Inst{15-12} = Rt;
5448 let Inst{19-16} = Rt2;
5449 let Inst{11-8} = cop;
5450 let Inst{7-4} = opc1;
5451 let Inst{3-0} = CRm;
5454 def MCRR : MovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */,
5455 (outs), (ins p_imm:$cop, imm0_15:$opc1, GPRnopc:$Rt,
5456 GPRnopc:$Rt2, c_imm:$CRm),
5457 [(int_arm_mcrr imm:$cop, imm:$opc1, GPRnopc:$Rt,
5458 GPRnopc:$Rt2, imm:$CRm)]>;
5459 def MRRC : MovRRCopro<"mrrc", 1 /* from coprocessor to ARM core register */,
5460 (outs GPRnopc:$Rt, GPRnopc:$Rt2),
5461 (ins p_imm:$cop, imm0_15:$opc1, c_imm:$CRm), []>;
5463 class MovRRCopro2<string opc, bit direction, dag oops, dag iops,
5464 list<dag> pattern = []>
5465 : ABXI<0b1100, oops, iops, NoItinerary,
5466 !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern>,
5467 Requires<[IsARM,PreV8]> {
5468 let Inst{31-28} = 0b1111;
5469 let Inst{23-21} = 0b010;
5470 let Inst{20} = direction;
5478 let Inst{15-12} = Rt;
5479 let Inst{19-16} = Rt2;
5480 let Inst{11-8} = cop;
5481 let Inst{7-4} = opc1;
5482 let Inst{3-0} = CRm;
5484 let DecoderMethod = "DecoderForMRRC2AndMCRR2";
5487 def MCRR2 : MovRRCopro2<"mcrr2", 0 /* from ARM core register to coprocessor */,
5488 (outs), (ins p_imm:$cop, imm0_15:$opc1, GPRnopc:$Rt,
5489 GPRnopc:$Rt2, c_imm:$CRm),
5490 [(int_arm_mcrr2 imm:$cop, imm:$opc1, GPRnopc:$Rt,
5491 GPRnopc:$Rt2, imm:$CRm)]>;
5493 def MRRC2 : MovRRCopro2<"mrrc2", 1 /* from coprocessor to ARM core register */,
5494 (outs GPRnopc:$Rt, GPRnopc:$Rt2),
5495 (ins p_imm:$cop, imm0_15:$opc1, c_imm:$CRm), []>;
5497 //===----------------------------------------------------------------------===//
5498 // Move between special register and ARM core register
5501 // Move to ARM core register from Special Register
5502 def MRS : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
5503 "mrs", "\t$Rd, apsr", []> {
5505 let Inst{23-16} = 0b00001111;
5506 let Unpredictable{19-17} = 0b111;
5508 let Inst{15-12} = Rd;
5510 let Inst{11-0} = 0b000000000000;
5511 let Unpredictable{11-0} = 0b110100001111;
5514 def : InstAlias<"mrs${p} $Rd, cpsr", (MRS GPRnopc:$Rd, pred:$p), 0>,
5517 // The MRSsys instruction is the MRS instruction from the ARM ARM,
5518 // section B9.3.9, with the R bit set to 1.
5519 def MRSsys : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
5520 "mrs", "\t$Rd, spsr", []> {
5522 let Inst{23-16} = 0b01001111;
5523 let Unpredictable{19-16} = 0b1111;
5525 let Inst{15-12} = Rd;
5527 let Inst{11-0} = 0b000000000000;
5528 let Unpredictable{11-0} = 0b110100001111;
5531 // However, the MRS (banked register) system instruction (ARMv7VE) *does* have a
5532 // separate encoding (distinguished by bit 5.
5533 def MRSbanked : ABI<0b0001, (outs GPRnopc:$Rd), (ins banked_reg:$banked),
5534 NoItinerary, "mrs", "\t$Rd, $banked", []>,
5535 Requires<[IsARM, HasVirtualization]> {
5540 let Inst{22} = banked{5}; // R bit
5541 let Inst{21-20} = 0b00;
5542 let Inst{19-16} = banked{3-0};
5543 let Inst{15-12} = Rd;
5544 let Inst{11-9} = 0b001;
5545 let Inst{8} = banked{4};
5546 let Inst{7-0} = 0b00000000;
5549 // Move from ARM core register to Special Register
5551 // No need to have both system and application versions of MSR (immediate) or
5552 // MSR (register), the encodings are the same and the assembly parser has no way
5553 // to distinguish between them. The mask operand contains the special register
5554 // (R Bit) in bit 4 and bits 3-0 contains the mask with the fields to be
5555 // accessed in the special register.
5556 let Defs = [CPSR] in
5557 def MSR : ABI<0b0001, (outs), (ins msr_mask:$mask, GPR:$Rn), NoItinerary,
5558 "msr", "\t$mask, $Rn", []> {
5563 let Inst{22} = mask{4}; // R bit
5564 let Inst{21-20} = 0b10;
5565 let Inst{19-16} = mask{3-0};
5566 let Inst{15-12} = 0b1111;
5567 let Inst{11-4} = 0b00000000;
5571 let Defs = [CPSR] in
5572 def MSRi : ABI<0b0011, (outs), (ins msr_mask:$mask, mod_imm:$imm), NoItinerary,
5573 "msr", "\t$mask, $imm", []> {
5578 let Inst{22} = mask{4}; // R bit
5579 let Inst{21-20} = 0b10;
5580 let Inst{19-16} = mask{3-0};
5581 let Inst{15-12} = 0b1111;
5582 let Inst{11-0} = imm;
5585 // However, the MSR (banked register) system instruction (ARMv7VE) *does* have a
5586 // separate encoding (distinguished by bit 5.
5587 def MSRbanked : ABI<0b0001, (outs), (ins banked_reg:$banked, GPRnopc:$Rn),
5588 NoItinerary, "msr", "\t$banked, $Rn", []>,
5589 Requires<[IsARM, HasVirtualization]> {
5594 let Inst{22} = banked{5}; // R bit
5595 let Inst{21-20} = 0b10;
5596 let Inst{19-16} = banked{3-0};
5597 let Inst{15-12} = 0b1111;
5598 let Inst{11-9} = 0b001;
5599 let Inst{8} = banked{4};
5600 let Inst{7-4} = 0b0000;
5604 // Dynamic stack allocation yields a _chkstk for Windows targets. These calls
5605 // are needed to probe the stack when allocating more than
5606 // 4k bytes in one go. Touching the stack at 4K increments is necessary to
5607 // ensure that the guard pages used by the OS virtual memory manager are
5608 // allocated in correct sequence.
5609 // The main point of having separate instruction are extra unmodelled effects
5610 // (compared to ordinary calls) like stack pointer change.
5612 def win__chkstk : SDNode<"ARMISD::WIN__CHKSTK", SDTNone,
5613 [SDNPHasChain, SDNPSideEffect]>;
5614 let usesCustomInserter = 1, Uses = [R4], Defs = [R4, SP] in
5615 def WIN__CHKSTK : PseudoInst<(outs), (ins), NoItinerary, [(win__chkstk)]>;
5617 def win__dbzchk : SDNode<"ARMISD::WIN__DBZCHK", SDT_WIN__DBZCHK,
5618 [SDNPHasChain, SDNPSideEffect, SDNPOutGlue]>;
5619 let usesCustomInserter = 1, Defs = [CPSR] in
5620 def WIN__DBZCHK : PseudoInst<(outs), (ins tGPR:$divisor), NoItinerary,
5621 [(win__dbzchk tGPR:$divisor)]>;
5623 //===----------------------------------------------------------------------===//
5627 // __aeabi_read_tp preserves the registers r1-r3.
5628 // This is a pseudo inst so that we can get the encoding right,
5629 // complete with fixup for the aeabi_read_tp function.
5630 // TPsoft is valid for ARM mode only, in case of Thumb mode a tTPsoft pattern
5631 // is defined in "ARMInstrThumb.td".
5633 Defs = [R0, R12, LR, CPSR], Uses = [SP] in {
5634 def TPsoft : ARMPseudoInst<(outs), (ins), 4, IIC_Br,
5635 [(set R0, ARMthread_pointer)]>, Sched<[WriteBr]>,
5636 Requires<[IsARM, IsReadTPSoft]>;
5639 // Reading thread pointer from coprocessor register
5640 def : ARMPat<(ARMthread_pointer), (MRC 15, 0, 13, 0, 3)>,
5641 Requires<[IsARM, IsReadTPHard]>;
5643 //===----------------------------------------------------------------------===//
5644 // SJLJ Exception handling intrinsics
5645 // eh_sjlj_setjmp() is an instruction sequence to store the return
5646 // address and save #0 in R0 for the non-longjmp case.
5647 // Since by its nature we may be coming from some other function to get
5648 // here, and we're using the stack frame for the containing function to
5649 // save/restore registers, we can't keep anything live in regs across
5650 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
5651 // when we get here from a longjmp(). We force everything out of registers
5652 // except for our own input by listing the relevant registers in Defs. By
5653 // doing so, we also cause the prologue/epilogue code to actively preserve
5654 // all of the callee-saved resgisters, which is exactly what we want.
5655 // A constant value is passed in $val, and we use the location as a scratch.
5657 // These are pseudo-instructions and are lowered to individual MC-insts, so
5658 // no encoding information is necessary.
5660 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
5661 Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15 ],
5662 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
5663 def Int_eh_sjlj_setjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
5665 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
5666 Requires<[IsARM, HasVFP2]>;
5670 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
5671 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
5672 def Int_eh_sjlj_setjmp_nofp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
5674 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
5675 Requires<[IsARM, NoVFP]>;
5678 // FIXME: Non-IOS version(s)
5679 let isBarrier = 1, hasSideEffects = 1, isTerminator = 1,
5680 Defs = [ R7, LR, SP ] in {
5681 def Int_eh_sjlj_longjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$scratch),
5683 [(ARMeh_sjlj_longjmp GPR:$src, GPR:$scratch)]>,
5687 let isBarrier = 1, hasSideEffects = 1, usesCustomInserter = 1 in
5688 def Int_eh_sjlj_setup_dispatch : PseudoInst<(outs), (ins), NoItinerary,
5689 [(ARMeh_sjlj_setup_dispatch)]>;
5691 // eh.sjlj.dispatchsetup pseudo-instruction.
5692 // This pseudo is used for both ARM and Thumb. Any differences are handled when
5693 // the pseudo is expanded (which happens before any passes that need the
5694 // instruction size).
5695 let isBarrier = 1 in
5696 def Int_eh_sjlj_dispatchsetup : PseudoInst<(outs), (ins), NoItinerary, []>;
5699 //===----------------------------------------------------------------------===//
5700 // Non-Instruction Patterns
5703 // ARMv4 indirect branch using (MOVr PC, dst)
5704 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in
5705 def MOVPCRX : ARMPseudoExpand<(outs), (ins GPR:$dst),
5706 4, IIC_Br, [(brind GPR:$dst)],
5707 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>,
5708 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
5710 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in
5711 def TAILJMPr4 : ARMPseudoExpand<(outs), (ins GPR:$dst),
5713 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>,
5714 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
5716 // Large immediate handling.
5718 // 32-bit immediate using two piece mod_imms or movw + movt.
5719 // This is a single pseudo instruction, the benefit is that it can be remat'd
5720 // as a single unit instead of having to handle reg inputs.
5721 // FIXME: Remove this when we can do generalized remat.
5722 let isReMaterializable = 1, isMoveImm = 1 in
5723 def MOVi32imm : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
5724 [(set GPR:$dst, (arm_i32imm:$src))]>,
5727 def LDRLIT_ga_abs : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iLoad_i,
5728 [(set GPR:$dst, (ARMWrapper tglobaladdr:$src))]>,
5729 Requires<[IsARM, DontUseMovt]>;
5731 // Pseudo instruction that combines movw + movt + add pc (if PIC).
5732 // It also makes it possible to rematerialize the instructions.
5733 // FIXME: Remove this when we can do generalized remat and when machine licm
5734 // can properly the instructions.
5735 let isReMaterializable = 1 in {
5736 def MOV_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5738 [(set GPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>,
5739 Requires<[IsARM, UseMovtInPic]>;
5741 def LDRLIT_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5744 (ARMWrapperPIC tglobaladdr:$addr))]>,
5745 Requires<[IsARM, DontUseMovtInPic]>;
5747 let AddedComplexity = 10 in
5748 def LDRLIT_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5751 (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
5752 Requires<[IsARM, DontUseMovtInPic]>;
5754 let AddedComplexity = 10 in
5755 def MOV_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5757 [(set GPR:$dst, (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
5758 Requires<[IsARM, UseMovtInPic]>;
5759 } // isReMaterializable
5761 // The many different faces of TLS access.
5762 def : ARMPat<(ARMWrapper tglobaltlsaddr :$dst),
5763 (MOVi32imm tglobaltlsaddr :$dst)>,
5764 Requires<[IsARM, UseMovt]>;
5766 def : Pat<(ARMWrapper tglobaltlsaddr:$src),
5767 (LDRLIT_ga_abs tglobaltlsaddr:$src)>,
5768 Requires<[IsARM, DontUseMovt]>;
5770 def : Pat<(ARMWrapperPIC tglobaltlsaddr:$addr),
5771 (MOV_ga_pcrel tglobaltlsaddr:$addr)>, Requires<[IsARM, UseMovtInPic]>;
5773 def : Pat<(ARMWrapperPIC tglobaltlsaddr:$addr),
5774 (LDRLIT_ga_pcrel tglobaltlsaddr:$addr)>,
5775 Requires<[IsARM, DontUseMovtInPic]>;
5776 let AddedComplexity = 10 in
5777 def : Pat<(load (ARMWrapperPIC tglobaltlsaddr:$addr)),
5778 (MOV_ga_pcrel_ldr tglobaltlsaddr:$addr)>,
5779 Requires<[IsARM, UseMovtInPic]>;
5782 // ConstantPool, GlobalAddress, and JumpTable
5783 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
5784 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
5785 Requires<[IsARM, UseMovt]>;
5786 def : ARMPat<(ARMWrapper texternalsym :$dst), (MOVi32imm texternalsym :$dst)>,
5787 Requires<[IsARM, UseMovt]>;
5788 def : ARMPat<(ARMWrapperJT tjumptable:$dst),
5789 (LEApcrelJT tjumptable:$dst)>;
5791 // TODO: add,sub,and, 3-instr forms?
5793 // Tail calls. These patterns also apply to Thumb mode.
5794 def : Pat<(ARMtcret tcGPR:$dst), (TCRETURNri tcGPR:$dst)>;
5795 def : Pat<(ARMtcret (i32 tglobaladdr:$dst)), (TCRETURNdi texternalsym:$dst)>;
5796 def : Pat<(ARMtcret (i32 texternalsym:$dst)), (TCRETURNdi texternalsym:$dst)>;
5799 def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>;
5800 def : ARMPat<(ARMcall_nolink texternalsym:$func),
5801 (BMOVPCB_CALL texternalsym:$func)>;
5803 // zextload i1 -> zextload i8
5804 def : ARMPat<(zextloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5805 def : ARMPat<(zextloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5807 // extload -> zextload
5808 def : ARMPat<(extloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5809 def : ARMPat<(extloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5810 def : ARMPat<(extloadi8 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5811 def : ARMPat<(extloadi8 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5813 def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
5815 def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
5816 def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
5819 def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
5820 (SMULBB GPR:$a, GPR:$b)>;
5821 def : ARMV5TEPat<(mul sext_16_node:$a, (sext_bottom_16 GPR:$b)),
5822 (SMULBB GPR:$a, GPR:$b)>;
5823 def : ARMV5TEPat<(mul sext_16_node:$a, (sext_top_16 GPR:$b)),
5824 (SMULBT GPR:$a, GPR:$b)>;
5825 def : ARMV5TEPat<(mul (sext_top_16 GPR:$a), sext_16_node:$b),
5826 (SMULTB GPR:$a, GPR:$b)>;
5827 def : ARMV5MOPat<(add GPR:$acc, (mul sext_16_node:$a, sext_16_node:$b)),
5828 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5829 def : ARMV5MOPat<(add GPR:$acc, (mul sext_16_node:$a, (sext_bottom_16 GPR:$b))),
5830 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5831 def : ARMV5MOPat<(add GPR:$acc, (mul sext_16_node:$a, (sext_top_16 GPR:$b))),
5832 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
5833 def : ARMV5MOPat<(add GPR:$acc, (mul (sext_top_16 GPR:$a), sext_16_node:$b)),
5834 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
5836 def : ARMV5TEPat<(int_arm_smulbb GPR:$a, GPR:$b),
5837 (SMULBB GPR:$a, GPR:$b)>;
5838 def : ARMV5TEPat<(int_arm_smulbt GPR:$a, GPR:$b),
5839 (SMULBT GPR:$a, GPR:$b)>;
5840 def : ARMV5TEPat<(int_arm_smultb GPR:$a, GPR:$b),
5841 (SMULTB GPR:$a, GPR:$b)>;
5842 def : ARMV5TEPat<(int_arm_smultt GPR:$a, GPR:$b),
5843 (SMULTT GPR:$a, GPR:$b)>;
5844 def : ARMV5TEPat<(int_arm_smulwb GPR:$a, GPR:$b),
5845 (SMULWB GPR:$a, GPR:$b)>;
5846 def : ARMV5TEPat<(int_arm_smulwt GPR:$a, GPR:$b),
5847 (SMULWT GPR:$a, GPR:$b)>;
5849 def : ARMV5TEPat<(int_arm_smlabb GPR:$a, GPR:$b, GPR:$acc),
5850 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5851 def : ARMV5TEPat<(int_arm_smlabt GPR:$a, GPR:$b, GPR:$acc),
5852 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
5853 def : ARMV5TEPat<(int_arm_smlatb GPR:$a, GPR:$b, GPR:$acc),
5854 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
5855 def : ARMV5TEPat<(int_arm_smlatt GPR:$a, GPR:$b, GPR:$acc),
5856 (SMLATT GPR:$a, GPR:$b, GPR:$acc)>;
5857 def : ARMV5TEPat<(int_arm_smlawb GPR:$a, GPR:$b, GPR:$acc),
5858 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
5859 def : ARMV5TEPat<(int_arm_smlawt GPR:$a, GPR:$b, GPR:$acc),
5860 (SMLAWT GPR:$a, GPR:$b, GPR:$acc)>;
5862 // Pre-v7 uses MCR for synchronization barriers.
5863 def : ARMPat<(ARMMemBarrierMCR GPR:$zero), (MCR 15, 0, GPR:$zero, 7, 10, 5)>,
5864 Requires<[IsARM, HasV6]>;
5866 // SXT/UXT with no rotate
5867 let AddedComplexity = 16 in {
5868 def : ARMV6Pat<(and GPR:$Src, 0x000000FF), (UXTB GPR:$Src, 0)>;
5869 def : ARMV6Pat<(and GPR:$Src, 0x0000FFFF), (UXTH GPR:$Src, 0)>;
5870 def : ARMV6Pat<(and GPR:$Src, 0x00FF00FF), (UXTB16 GPR:$Src, 0)>;
5871 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0x00FF)),
5872 (UXTAB GPR:$Rn, GPR:$Rm, 0)>;
5873 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0xFFFF)),
5874 (UXTAH GPR:$Rn, GPR:$Rm, 0)>;
5877 def : ARMV6Pat<(sext_inreg GPR:$Src, i8), (SXTB GPR:$Src, 0)>;
5878 def : ARMV6Pat<(sext_inreg GPR:$Src, i16), (SXTH GPR:$Src, 0)>;
5880 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i8)),
5881 (SXTAB GPR:$Rn, GPRnopc:$Rm, 0)>;
5882 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i16)),
5883 (SXTAH GPR:$Rn, GPRnopc:$Rm, 0)>;
5885 // Atomic load/store patterns
5886 def : ARMPat<(atomic_load_8 ldst_so_reg:$src),
5887 (LDRBrs ldst_so_reg:$src)>;
5888 def : ARMPat<(atomic_load_8 addrmode_imm12:$src),
5889 (LDRBi12 addrmode_imm12:$src)>;
5890 def : ARMPat<(atomic_load_16 addrmode3:$src),
5891 (LDRH addrmode3:$src)>;
5892 def : ARMPat<(atomic_load_32 ldst_so_reg:$src),
5893 (LDRrs ldst_so_reg:$src)>;
5894 def : ARMPat<(atomic_load_32 addrmode_imm12:$src),
5895 (LDRi12 addrmode_imm12:$src)>;
5896 def : ARMPat<(atomic_store_8 ldst_so_reg:$ptr, GPR:$val),
5897 (STRBrs GPR:$val, ldst_so_reg:$ptr)>;
5898 def : ARMPat<(atomic_store_8 addrmode_imm12:$ptr, GPR:$val),
5899 (STRBi12 GPR:$val, addrmode_imm12:$ptr)>;
5900 def : ARMPat<(atomic_store_16 addrmode3:$ptr, GPR:$val),
5901 (STRH GPR:$val, addrmode3:$ptr)>;
5902 def : ARMPat<(atomic_store_32 ldst_so_reg:$ptr, GPR:$val),
5903 (STRrs GPR:$val, ldst_so_reg:$ptr)>;
5904 def : ARMPat<(atomic_store_32 addrmode_imm12:$ptr, GPR:$val),
5905 (STRi12 GPR:$val, addrmode_imm12:$ptr)>;
5908 //===----------------------------------------------------------------------===//
5912 include "ARMInstrThumb.td"
5914 //===----------------------------------------------------------------------===//
5918 include "ARMInstrThumb2.td"
5920 //===----------------------------------------------------------------------===//
5921 // Floating Point Support
5924 include "ARMInstrVFP.td"
5926 //===----------------------------------------------------------------------===//
5927 // Advanced SIMD (NEON) Support
5930 include "ARMInstrNEON.td"
5932 //===----------------------------------------------------------------------===//
5933 // Assembler aliases
5937 def : InstAlias<"dmb", (DMB 0xf), 0>, Requires<[IsARM, HasDB]>;
5938 def : InstAlias<"dsb", (DSB 0xf), 0>, Requires<[IsARM, HasDB]>;
5939 def : InstAlias<"ssbb", (DSB 0x0), 1>, Requires<[IsARM, HasDB]>;
5940 def : InstAlias<"pssbb", (DSB 0x4), 1>, Requires<[IsARM, HasDB]>;
5941 def : InstAlias<"isb", (ISB 0xf), 0>, Requires<[IsARM, HasDB]>;
5942 // Armv8-R 'Data Full Barrier'
5943 def : InstAlias<"dfb", (DSB 0xc), 1>, Requires<[IsARM, HasDFB]>;
5945 // System instructions
5946 def : MnemonicAlias<"swi", "svc">;
5948 // Load / Store Multiple
5949 def : MnemonicAlias<"ldmfd", "ldm">;
5950 def : MnemonicAlias<"ldmia", "ldm">;
5951 def : MnemonicAlias<"ldmea", "ldmdb">;
5952 def : MnemonicAlias<"stmfd", "stmdb">;
5953 def : MnemonicAlias<"stmia", "stm">;
5954 def : MnemonicAlias<"stmea", "stm">;
5956 // PKHBT/PKHTB with default shift amount. PKHTB is equivalent to PKHBT with the
5957 // input operands swapped when the shift amount is zero (i.e., unspecified).
5958 def : InstAlias<"pkhbt${p} $Rd, $Rn, $Rm",
5959 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p), 0>,
5960 Requires<[IsARM, HasV6]>;
5961 def : InstAlias<"pkhtb${p} $Rd, $Rn, $Rm",
5962 (PKHBT GPRnopc:$Rd, GPRnopc:$Rm, GPRnopc:$Rn, 0, pred:$p), 0>,
5963 Requires<[IsARM, HasV6]>;
5965 // PUSH/POP aliases for STM/LDM
5966 def : ARMInstAlias<"push${p} $regs", (STMDB_UPD SP, pred:$p, reglist:$regs)>;
5967 def : ARMInstAlias<"pop${p} $regs", (LDMIA_UPD SP, pred:$p, reglist:$regs)>;
5969 // SSAT/USAT optional shift operand.
5970 def : ARMInstAlias<"ssat${p} $Rd, $sat_imm, $Rn",
5971 (SSAT GPRnopc:$Rd, imm1_32:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5972 def : ARMInstAlias<"usat${p} $Rd, $sat_imm, $Rn",
5973 (USAT GPRnopc:$Rd, imm0_31:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5976 // Extend instruction optional rotate operand.
5977 def : ARMInstAlias<"sxtab${p} $Rd, $Rn, $Rm",
5978 (SXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5979 def : ARMInstAlias<"sxtah${p} $Rd, $Rn, $Rm",
5980 (SXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5981 def : ARMInstAlias<"sxtab16${p} $Rd, $Rn, $Rm",
5982 (SXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5983 def : ARMInstAlias<"sxtb${p} $Rd, $Rm",
5984 (SXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5985 def : ARMInstAlias<"sxtb16${p} $Rd, $Rm",
5986 (SXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5987 def : ARMInstAlias<"sxth${p} $Rd, $Rm",
5988 (SXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5990 def : ARMInstAlias<"uxtab${p} $Rd, $Rn, $Rm",
5991 (UXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5992 def : ARMInstAlias<"uxtah${p} $Rd, $Rn, $Rm",
5993 (UXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5994 def : ARMInstAlias<"uxtab16${p} $Rd, $Rn, $Rm",
5995 (UXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5996 def : ARMInstAlias<"uxtb${p} $Rd, $Rm",
5997 (UXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5998 def : ARMInstAlias<"uxtb16${p} $Rd, $Rm",
5999 (UXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
6000 def : ARMInstAlias<"uxth${p} $Rd, $Rm",
6001 (UXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
6005 def : MnemonicAlias<"rfefa", "rfeda">;
6006 def : MnemonicAlias<"rfeea", "rfedb">;
6007 def : MnemonicAlias<"rfefd", "rfeia">;
6008 def : MnemonicAlias<"rfeed", "rfeib">;
6009 def : MnemonicAlias<"rfe", "rfeia">;
6012 def : MnemonicAlias<"srsfa", "srsib">;
6013 def : MnemonicAlias<"srsea", "srsia">;
6014 def : MnemonicAlias<"srsfd", "srsdb">;
6015 def : MnemonicAlias<"srsed", "srsda">;
6016 def : MnemonicAlias<"srs", "srsia">;
6019 def : MnemonicAlias<"qsubaddx", "qsax">;
6021 def : MnemonicAlias<"saddsubx", "sasx">;
6022 // SHASX == SHADDSUBX
6023 def : MnemonicAlias<"shaddsubx", "shasx">;
6024 // SHSAX == SHSUBADDX
6025 def : MnemonicAlias<"shsubaddx", "shsax">;
6027 def : MnemonicAlias<"ssubaddx", "ssax">;
6029 def : MnemonicAlias<"uaddsubx", "uasx">;
6030 // UHASX == UHADDSUBX
6031 def : MnemonicAlias<"uhaddsubx", "uhasx">;
6032 // UHSAX == UHSUBADDX
6033 def : MnemonicAlias<"uhsubaddx", "uhsax">;
6034 // UQASX == UQADDSUBX
6035 def : MnemonicAlias<"uqaddsubx", "uqasx">;
6036 // UQSAX == UQSUBADDX
6037 def : MnemonicAlias<"uqsubaddx", "uqsax">;
6039 def : MnemonicAlias<"usubaddx", "usax">;
6041 // "mov Rd, mod_imm_not" can be handled via "mvn" in assembly, just like
6043 def : ARMInstSubst<"mov${s}${p} $Rd, $imm",
6044 (MVNi rGPR:$Rd, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6045 def : ARMInstSubst<"mvn${s}${p} $Rd, $imm",
6046 (MOVi rGPR:$Rd, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6047 // Same for AND <--> BIC
6048 def : ARMInstSubst<"bic${s}${p} $Rd, $Rn, $imm",
6049 (ANDri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm,
6050 pred:$p, cc_out:$s)>;
6051 def : ARMInstSubst<"bic${s}${p} $Rdn, $imm",
6052 (ANDri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm,
6053 pred:$p, cc_out:$s)>;
6054 def : ARMInstSubst<"and${s}${p} $Rd, $Rn, $imm",
6055 (BICri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm,
6056 pred:$p, cc_out:$s)>;
6057 def : ARMInstSubst<"and${s}${p} $Rdn, $imm",
6058 (BICri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm,
6059 pred:$p, cc_out:$s)>;
6061 // Likewise, "add Rd, mod_imm_neg" -> sub
6062 def : ARMInstSubst<"add${s}${p} $Rd, $Rn, $imm",
6063 (SUBri GPR:$Rd, GPR:$Rn, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
6064 def : ARMInstSubst<"add${s}${p} $Rd, $imm",
6065 (SUBri GPR:$Rd, GPR:$Rd, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
6066 // Likewise, "sub Rd, mod_imm_neg" -> add
6067 def : ARMInstSubst<"sub${s}${p} $Rd, $Rn, $imm",
6068 (ADDri GPR:$Rd, GPR:$Rn, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
6069 def : ARMInstSubst<"sub${s}${p} $Rd, $imm",
6070 (ADDri GPR:$Rd, GPR:$Rd, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
6073 def : ARMInstSubst<"adc${s}${p} $Rd, $Rn, $imm",
6074 (SBCri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6075 def : ARMInstSubst<"adc${s}${p} $Rdn, $imm",
6076 (SBCri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6077 def : ARMInstSubst<"sbc${s}${p} $Rd, $Rn, $imm",
6078 (ADCri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6079 def : ARMInstSubst<"sbc${s}${p} $Rdn, $imm",
6080 (ADCri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6082 // Same for CMP <--> CMN via mod_imm_neg
6083 def : ARMInstSubst<"cmp${p} $Rd, $imm",
6084 (CMNri rGPR:$Rd, mod_imm_neg:$imm, pred:$p)>;
6085 def : ARMInstSubst<"cmn${p} $Rd, $imm",
6086 (CMPri rGPR:$Rd, mod_imm_neg:$imm, pred:$p)>;
6088 // The shifter forms of the MOV instruction are aliased to the ASR, LSL,
6089 // LSR, ROR, and RRX instructions.
6090 // FIXME: We need C++ parser hooks to map the alias to the MOV
6091 // encoding. It seems we should be able to do that sort of thing
6092 // in tblgen, but it could get ugly.
6093 let TwoOperandAliasConstraint = "$Rm = $Rd" in {
6094 def ASRi : ARMAsmPseudo<"asr${s}${p} $Rd, $Rm, $imm",
6095 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
6097 def LSRi : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rm, $imm",
6098 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
6100 def LSLi : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rm, $imm",
6101 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
6103 def RORi : ARMAsmPseudo<"ror${s}${p} $Rd, $Rm, $imm",
6104 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
6107 def RRXi : ARMAsmPseudo<"rrx${s}${p} $Rd, $Rm",
6108 (ins GPR:$Rd, GPR:$Rm, pred:$p, cc_out:$s)>;
6109 let TwoOperandAliasConstraint = "$Rn = $Rd" in {
6110 def ASRr : ARMAsmPseudo<"asr${s}${p} $Rd, $Rn, $Rm",
6111 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
6113 def LSRr : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rn, $Rm",
6114 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
6116 def LSLr : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rn, $Rm",
6117 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
6119 def RORr : ARMAsmPseudo<"ror${s}${p} $Rd, $Rn, $Rm",
6120 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
6124 // "neg" is and alias for "rsb rd, rn, #0"
6125 def : ARMInstAlias<"neg${s}${p} $Rd, $Rm",
6126 (RSBri GPR:$Rd, GPR:$Rm, 0, pred:$p, cc_out:$s)>;
6128 // Pre-v6, 'mov r0, r0' was used as a NOP encoding.
6129 def : InstAlias<"nop${p}", (MOVr R0, R0, pred:$p, zero_reg)>,
6130 Requires<[IsARM, NoV6]>;
6132 // MUL/UMLAL/SMLAL/UMULL/SMULL are available on all arches, but
6133 // the instruction definitions need difference constraints pre-v6.
6134 // Use these aliases for the assembly parsing on pre-v6.
6135 def : InstAlias<"mul${s}${p} $Rd, $Rn, $Rm",
6136 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s), 0>,
6137 Requires<[IsARM, NoV6]>;
6138 def : InstAlias<"mla${s}${p} $Rd, $Rn, $Rm, $Ra",
6139 (MLA GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra,
6140 pred:$p, cc_out:$s), 0>,
6141 Requires<[IsARM, NoV6]>;
6142 def : InstAlias<"smlal${s}${p} $RdLo, $RdHi, $Rn, $Rm",
6143 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>,
6144 Requires<[IsARM, NoV6]>;
6145 def : InstAlias<"umlal${s}${p} $RdLo, $RdHi, $Rn, $Rm",
6146 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>,
6147 Requires<[IsARM, NoV6]>;
6148 def : InstAlias<"smull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
6149 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>,
6150 Requires<[IsARM, NoV6]>;
6151 def : InstAlias<"umull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
6152 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>,
6153 Requires<[IsARM, NoV6]>;
6155 // 'it' blocks in ARM mode just validate the predicates. The IT itself
6157 def ITasm : ARMAsmPseudo<"it$mask $cc", (ins it_pred:$cc, it_mask:$mask)>,
6158 ComplexDeprecationPredicate<"IT">;
6160 let mayLoad = 1, mayStore =1, hasSideEffects = 1 in
6161 def SPACE : PseudoInst<(outs GPR:$Rd), (ins i32imm:$size, GPR:$Rn),
6163 [(set GPR:$Rd, (int_arm_space imm:$size, GPR:$Rn))]>;
6165 //===----------------------------------
6166 // Atomic cmpxchg for -O0
6167 //===----------------------------------
6169 // The fast register allocator used during -O0 inserts spills to cover any VRegs
6170 // live across basic block boundaries. When this happens between an LDXR and an
6171 // STXR it can clear the exclusive monitor, causing all cmpxchg attempts to
6174 // Unfortunately, this means we have to have an alternative (expanded
6175 // post-regalloc) path for -O0 compilations. Fortunately this path can be
6176 // significantly more naive than the standard expansion: we conservatively
6177 // assume seq_cst, strong cmpxchg and omit clrex on failure.
6179 let Constraints = "@earlyclobber $Rd,@earlyclobber $temp",
6180 mayLoad = 1, mayStore = 1 in {
6181 def CMP_SWAP_8 : PseudoInst<(outs GPR:$Rd, GPR:$temp),
6182 (ins GPR:$addr, GPR:$desired, GPR:$new),
6183 NoItinerary, []>, Sched<[]>;
6185 def CMP_SWAP_16 : PseudoInst<(outs GPR:$Rd, GPR:$temp),
6186 (ins GPR:$addr, GPR:$desired, GPR:$new),
6187 NoItinerary, []>, Sched<[]>;
6189 def CMP_SWAP_32 : PseudoInst<(outs GPR:$Rd, GPR:$temp),
6190 (ins GPR:$addr, GPR:$desired, GPR:$new),
6191 NoItinerary, []>, Sched<[]>;
6193 def CMP_SWAP_64 : PseudoInst<(outs GPRPair:$Rd, GPR:$temp),
6194 (ins GPR:$addr, GPRPair:$desired, GPRPair:$new),
6195 NoItinerary, []>, Sched<[]>;
6198 def CompilerBarrier : PseudoInst<(outs), (ins i32imm:$ordering), NoItinerary,
6199 [(atomic_fence imm:$ordering, 0)]> {
6200 let hasSideEffects = 1;
6202 let AsmString = "@ COMPILER BARRIER";