1 //===- ARMInstrInfo.td - Target Description for ARM Target -*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the ARM instructions in TableGen format.
12 //===----------------------------------------------------------------------===//
14 //===----------------------------------------------------------------------===//
15 // ARM specific DAG Nodes.
19 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, 3,
37 [SDTCisPtrTy<0>, SDTCisVT<1, i32>,
40 def SDT_ARMBr2JT : SDTypeProfile<0, 4,
41 [SDTCisPtrTy<0>, SDTCisVT<1, i32>,
42 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
44 def SDT_ARMBCC_i64 : SDTypeProfile<0, 6,
46 SDTCisVT<1, i32>, SDTCisVT<2, i32>,
47 SDTCisVT<3, i32>, SDTCisVT<4, i32>,
48 SDTCisVT<5, OtherVT>]>;
50 def SDT_ARMAnd : SDTypeProfile<1, 2,
51 [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
54 def SDT_ARMCmp : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
56 def SDT_ARMPICAdd : SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>,
57 SDTCisPtrTy<1>, SDTCisVT<2, i32>]>;
59 def SDT_ARMThreadPointer : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
60 def SDT_ARMEH_SJLJ_Setjmp : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisPtrTy<1>,
62 def SDT_ARMEH_SJLJ_Longjmp: SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
64 def SDT_ARMMEMBARRIER : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
66 def SDT_ARMPREFETCH : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisSameAs<1, 2>,
69 def SDT_ARMTCRET : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
71 def SDT_ARMBFI : SDTypeProfile<1, 3, [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
72 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
74 def SDT_ARMVMAXNM : SDTypeProfile<1, 2, [SDTCisFP<0>, SDTCisFP<1>, SDTCisFP<2>]>;
75 def SDT_ARMVMINNM : SDTypeProfile<1, 2, [SDTCisFP<0>, SDTCisFP<1>, SDTCisFP<2>]>;
77 def SDTBinaryArithWithFlags : SDTypeProfile<2, 2,
80 SDTCisInt<0>, SDTCisVT<1, i32>]>;
82 // SDTBinaryArithWithFlagsInOut - RES1, CPSR = op LHS, RHS, CPSR
83 def SDTBinaryArithWithFlagsInOut : SDTypeProfile<2, 3,
90 def SDT_ARM64bitmlal : SDTypeProfile<2,4, [ SDTCisVT<0, i32>, SDTCisVT<1, i32>,
91 SDTCisVT<2, i32>, SDTCisVT<3, i32>,
92 SDTCisVT<4, i32>, SDTCisVT<5, i32> ] >;
93 def ARMUmlal : SDNode<"ARMISD::UMLAL", SDT_ARM64bitmlal>;
94 def ARMSmlal : SDNode<"ARMISD::SMLAL", SDT_ARM64bitmlal>;
97 def ARMWrapper : SDNode<"ARMISD::Wrapper", SDTIntUnaryOp>;
98 def ARMWrapperPIC : SDNode<"ARMISD::WrapperPIC", SDTIntUnaryOp>;
99 def ARMWrapperJT : SDNode<"ARMISD::WrapperJT", SDTIntBinOp>;
101 def ARMcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_ARMCallSeqStart,
102 [SDNPHasChain, SDNPSideEffect, SDNPOutGlue]>;
103 def ARMcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_ARMCallSeqEnd,
104 [SDNPHasChain, SDNPSideEffect,
105 SDNPOptInGlue, SDNPOutGlue]>;
106 def ARMcopystructbyval : SDNode<"ARMISD::COPY_STRUCT_BYVAL" ,
108 [SDNPHasChain, SDNPInGlue, SDNPOutGlue,
109 SDNPMayStore, SDNPMayLoad]>;
111 def ARMcall : SDNode<"ARMISD::CALL", SDT_ARMcall,
112 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
114 def ARMcall_pred : SDNode<"ARMISD::CALL_PRED", SDT_ARMcall,
115 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
117 def ARMcall_nolink : SDNode<"ARMISD::CALL_NOLINK", SDT_ARMcall,
118 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
121 def ARMretflag : SDNode<"ARMISD::RET_FLAG", SDTNone,
122 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
123 def ARMintretflag : SDNode<"ARMISD::INTRET_FLAG", SDT_ARMcall,
124 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
125 def ARMcmov : SDNode<"ARMISD::CMOV", SDT_ARMCMov,
128 def ARMbrcond : SDNode<"ARMISD::BRCOND", SDT_ARMBrcond,
129 [SDNPHasChain, SDNPInGlue, SDNPOutGlue]>;
131 def ARMbrjt : SDNode<"ARMISD::BR_JT", SDT_ARMBrJT,
133 def ARMbr2jt : SDNode<"ARMISD::BR2_JT", SDT_ARMBr2JT,
136 def ARMBcci64 : SDNode<"ARMISD::BCC_i64", SDT_ARMBCC_i64,
139 def ARMcmp : SDNode<"ARMISD::CMP", SDT_ARMCmp,
142 def ARMcmn : SDNode<"ARMISD::CMN", SDT_ARMCmp,
145 def ARMcmpZ : SDNode<"ARMISD::CMPZ", SDT_ARMCmp,
146 [SDNPOutGlue, SDNPCommutative]>;
148 def ARMpic_add : SDNode<"ARMISD::PIC_ADD", SDT_ARMPICAdd>;
150 def ARMsrl_flag : SDNode<"ARMISD::SRL_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
151 def ARMsra_flag : SDNode<"ARMISD::SRA_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
152 def ARMrrx : SDNode<"ARMISD::RRX" , SDTIntUnaryOp, [SDNPInGlue ]>;
154 def ARMaddc : SDNode<"ARMISD::ADDC", SDTBinaryArithWithFlags,
156 def ARMsubc : SDNode<"ARMISD::SUBC", SDTBinaryArithWithFlags>;
157 def ARMadde : SDNode<"ARMISD::ADDE", SDTBinaryArithWithFlagsInOut>;
158 def ARMsube : SDNode<"ARMISD::SUBE", SDTBinaryArithWithFlagsInOut>;
160 def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>;
161 def ARMeh_sjlj_setjmp: SDNode<"ARMISD::EH_SJLJ_SETJMP",
162 SDT_ARMEH_SJLJ_Setjmp,
163 [SDNPHasChain, SDNPSideEffect]>;
164 def ARMeh_sjlj_longjmp: SDNode<"ARMISD::EH_SJLJ_LONGJMP",
165 SDT_ARMEH_SJLJ_Longjmp,
166 [SDNPHasChain, SDNPSideEffect]>;
168 def ARMMemBarrierMCR : SDNode<"ARMISD::MEMBARRIER_MCR", SDT_ARMMEMBARRIER,
169 [SDNPHasChain, SDNPSideEffect]>;
170 def ARMPreload : SDNode<"ARMISD::PRELOAD", SDT_ARMPREFETCH,
171 [SDNPHasChain, SDNPMayLoad, SDNPMayStore]>;
173 def ARMrbit : SDNode<"ARMISD::RBIT", SDTIntUnaryOp>;
175 def ARMtcret : SDNode<"ARMISD::TC_RETURN", SDT_ARMTCRET,
176 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
178 def ARMbfi : SDNode<"ARMISD::BFI", SDT_ARMBFI>;
180 def ARMvmaxnm : SDNode<"ARMISD::VMAXNM", SDT_ARMVMAXNM, []>;
181 def ARMvminnm : SDNode<"ARMISD::VMINNM", SDT_ARMVMINNM, []>;
183 //===----------------------------------------------------------------------===//
184 // ARM Instruction Predicate Definitions.
186 def HasV4T : Predicate<"Subtarget->hasV4TOps()">,
187 AssemblerPredicate<"HasV4TOps", "armv4t">;
188 def NoV4T : Predicate<"!Subtarget->hasV4TOps()">;
189 def HasV5T : Predicate<"Subtarget->hasV5TOps()">,
190 AssemblerPredicate<"HasV5TOps", "armv5t">;
191 def HasV5TE : Predicate<"Subtarget->hasV5TEOps()">,
192 AssemblerPredicate<"HasV5TEOps", "armv5te">;
193 def HasV6 : Predicate<"Subtarget->hasV6Ops()">,
194 AssemblerPredicate<"HasV6Ops", "armv6">;
195 def NoV6 : Predicate<"!Subtarget->hasV6Ops()">;
196 def HasV6M : Predicate<"Subtarget->hasV6MOps()">,
197 AssemblerPredicate<"HasV6MOps",
198 "armv6m or armv6t2">;
199 def HasV6T2 : Predicate<"Subtarget->hasV6T2Ops()">,
200 AssemblerPredicate<"HasV6T2Ops", "armv6t2">;
201 def NoV6T2 : Predicate<"!Subtarget->hasV6T2Ops()">;
202 def HasV6K : Predicate<"Subtarget->hasV6KOps()">,
203 AssemblerPredicate<"HasV6KOps", "armv6k">;
204 def NoV6K : Predicate<"!Subtarget->hasV6KOps()">;
205 def HasV7 : Predicate<"Subtarget->hasV7Ops()">,
206 AssemblerPredicate<"HasV7Ops", "armv7">;
207 def HasV8 : Predicate<"Subtarget->hasV8Ops()">,
208 AssemblerPredicate<"HasV8Ops", "armv8">;
209 def PreV8 : Predicate<"!Subtarget->hasV8Ops()">,
210 AssemblerPredicate<"!HasV8Ops", "armv7 or earlier">;
211 def HasV8_1a : Predicate<"Subtarget->hasV8_1aOps()">,
212 AssemblerPredicate<"HasV8_1aOps", "armv8.1a">;
213 def NoVFP : Predicate<"!Subtarget->hasVFP2()">;
214 def HasVFP2 : Predicate<"Subtarget->hasVFP2()">,
215 AssemblerPredicate<"FeatureVFP2", "VFP2">;
216 def HasVFP3 : Predicate<"Subtarget->hasVFP3()">,
217 AssemblerPredicate<"FeatureVFP3", "VFP3">;
218 def HasVFP4 : Predicate<"Subtarget->hasVFP4()">,
219 AssemblerPredicate<"FeatureVFP4", "VFP4">;
220 def HasDPVFP : Predicate<"!Subtarget->isFPOnlySP()">,
221 AssemblerPredicate<"!FeatureVFPOnlySP",
222 "double precision VFP">;
223 def HasFPARMv8 : Predicate<"Subtarget->hasFPARMv8()">,
224 AssemblerPredicate<"FeatureFPARMv8", "FPARMv8">;
225 def HasNEON : Predicate<"Subtarget->hasNEON()">,
226 AssemblerPredicate<"FeatureNEON", "NEON">;
227 def HasCrypto : Predicate<"Subtarget->hasCrypto()">,
228 AssemblerPredicate<"FeatureCrypto", "crypto">;
229 def HasCRC : Predicate<"Subtarget->hasCRC()">,
230 AssemblerPredicate<"FeatureCRC", "crc">;
231 def HasFP16 : Predicate<"Subtarget->hasFP16()">,
232 AssemblerPredicate<"FeatureFP16","half-float">;
233 def HasDivide : Predicate<"Subtarget->hasDivide()">,
234 AssemblerPredicate<"FeatureHWDiv", "divide in THUMB">;
235 def HasDivideInARM : Predicate<"Subtarget->hasDivideInARMMode()">,
236 AssemblerPredicate<"FeatureHWDivARM", "divide in ARM">;
237 def HasT2ExtractPack : Predicate<"Subtarget->hasT2ExtractPack()">,
238 AssemblerPredicate<"FeatureT2XtPk",
240 def HasThumb2DSP : Predicate<"Subtarget->hasThumb2DSP()">,
241 AssemblerPredicate<"FeatureDSPThumb2",
243 def HasDB : Predicate<"Subtarget->hasDataBarrier()">,
244 AssemblerPredicate<"FeatureDB",
246 def HasMP : Predicate<"Subtarget->hasMPExtension()">,
247 AssemblerPredicate<"FeatureMP",
249 def HasVirtualization: Predicate<"false">,
250 AssemblerPredicate<"FeatureVirtualization",
251 "virtualization-extensions">;
252 def HasTrustZone : Predicate<"Subtarget->hasTrustZone()">,
253 AssemblerPredicate<"FeatureTrustZone",
255 def HasZCZ : Predicate<"Subtarget->hasZeroCycleZeroing()">;
256 def UseNEONForFP : Predicate<"Subtarget->useNEONForSinglePrecisionFP()">;
257 def DontUseNEONForFP : Predicate<"!Subtarget->useNEONForSinglePrecisionFP()">;
258 def IsThumb : Predicate<"Subtarget->isThumb()">,
259 AssemblerPredicate<"ModeThumb", "thumb">;
260 def IsThumb1Only : Predicate<"Subtarget->isThumb1Only()">;
261 def IsThumb2 : Predicate<"Subtarget->isThumb2()">,
262 AssemblerPredicate<"ModeThumb,FeatureThumb2",
264 def IsMClass : Predicate<"Subtarget->isMClass()">,
265 AssemblerPredicate<"FeatureMClass", "armv*m">;
266 def IsNotMClass : Predicate<"!Subtarget->isMClass()">,
267 AssemblerPredicate<"!FeatureMClass",
269 def IsARM : Predicate<"!Subtarget->isThumb()">,
270 AssemblerPredicate<"!ModeThumb", "arm-mode">;
271 def IsMachO : Predicate<"Subtarget->isTargetMachO()">;
272 def IsNotMachO : Predicate<"!Subtarget->isTargetMachO()">;
273 def IsNaCl : Predicate<"Subtarget->isTargetNaCl()">;
274 def UseNaClTrap : Predicate<"Subtarget->useNaClTrap()">,
275 AssemblerPredicate<"FeatureNaClTrap", "NaCl">;
276 def DontUseNaClTrap : Predicate<"!Subtarget->useNaClTrap()">;
278 // FIXME: Eventually this will be just "hasV6T2Ops".
279 def UseMovt : Predicate<"Subtarget->useMovt(*MF)">;
280 def DontUseMovt : Predicate<"!Subtarget->useMovt(*MF)">;
281 def UseFPVMLx : Predicate<"Subtarget->useFPVMLx()">;
282 def UseMulOps : Predicate<"Subtarget->useMulOps()">;
284 // Prefer fused MAC for fp mul + add over fp VMLA / VMLS if they are available.
285 // But only select them if more precision in FP computation is allowed.
286 // Do not use them for Darwin platforms.
287 def UseFusedMAC : Predicate<"(TM.Options.AllowFPOpFusion =="
288 " FPOpFusion::Fast && "
289 " Subtarget->hasVFP4()) && "
290 "!Subtarget->isTargetDarwin()">;
291 def DontUseFusedMAC : Predicate<"!(TM.Options.AllowFPOpFusion =="
292 " FPOpFusion::Fast &&"
293 " Subtarget->hasVFP4()) || "
294 "Subtarget->isTargetDarwin()">;
296 // VGETLNi32 is microcoded on Swift - prefer VMOV.
297 def HasFastVGETLNi32 : Predicate<"!Subtarget->isSwift()">;
298 def HasSlowVGETLNi32 : Predicate<"Subtarget->isSwift()">;
300 // VDUP.32 is microcoded on Swift - prefer VMOV.
301 def HasFastVDUP32 : Predicate<"!Subtarget->isSwift()">;
302 def HasSlowVDUP32 : Predicate<"Subtarget->isSwift()">;
304 // Cortex-A9 prefers VMOVSR to VMOVDRR even when using NEON for scalar FP, as
305 // this allows more effective execution domain optimization. See
306 // setExecutionDomain().
307 def UseVMOVSR : Predicate<"Subtarget->isCortexA9() || !Subtarget->useNEONForSinglePrecisionFP()">;
308 def DontUseVMOVSR : Predicate<"!Subtarget->isCortexA9() && Subtarget->useNEONForSinglePrecisionFP()">;
310 def IsLE : Predicate<"getTargetLowering()->isLittleEndian()">;
311 def IsBE : Predicate<"getTargetLowering()->isBigEndian()">;
313 //===----------------------------------------------------------------------===//
314 // ARM Flag Definitions.
316 class RegConstraint<string C> {
317 string Constraints = C;
320 //===----------------------------------------------------------------------===//
321 // ARM specific transformation functions and pattern fragments.
324 // imm_neg_XFORM - Return the negation of an i32 immediate value.
325 def imm_neg_XFORM : SDNodeXForm<imm, [{
326 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), SDLoc(N), MVT::i32);
329 // imm_not_XFORM - Return the complement of a i32 immediate value.
330 def imm_not_XFORM : SDNodeXForm<imm, [{
331 return CurDAG->getTargetConstant(~(int)N->getZExtValue(), SDLoc(N), MVT::i32);
334 /// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
335 def imm16_31 : ImmLeaf<i32, [{
336 return (int32_t)Imm >= 16 && (int32_t)Imm < 32;
339 // sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
340 def sext_16_node : PatLeaf<(i32 GPR:$a), [{
341 return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17;
344 /// Split a 32-bit immediate into two 16 bit parts.
345 def hi16 : SDNodeXForm<imm, [{
346 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, SDLoc(N),
350 def lo16AllZero : PatLeaf<(i32 imm), [{
351 // Returns true if all low 16-bits are 0.
352 return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
355 class BinOpWithFlagFrag<dag res> :
356 PatFrag<(ops node:$LHS, node:$RHS, node:$FLAG), res>;
357 class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
358 class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
360 // An 'and' node with a single use.
361 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
362 return N->hasOneUse();
365 // An 'xor' node with a single use.
366 def xor_su : PatFrag<(ops node:$lhs, node:$rhs), (xor node:$lhs, node:$rhs), [{
367 return N->hasOneUse();
370 // An 'fmul' node with a single use.
371 def fmul_su : PatFrag<(ops node:$lhs, node:$rhs), (fmul node:$lhs, node:$rhs),[{
372 return N->hasOneUse();
375 // An 'fadd' node which checks for single non-hazardous use.
376 def fadd_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fadd node:$lhs, node:$rhs),[{
377 return hasNoVMLxHazardUse(N);
380 // An 'fsub' node which checks for single non-hazardous use.
381 def fsub_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fsub node:$lhs, node:$rhs),[{
382 return hasNoVMLxHazardUse(N);
385 //===----------------------------------------------------------------------===//
386 // Operand Definitions.
389 // Immediate operands with a shared generic asm render method.
390 class ImmAsmOperand : AsmOperandClass { let RenderMethod = "addImmOperands"; }
392 // Operands that are part of a memory addressing mode.
393 class MemOperand : Operand<i32> { let OperandType = "OPERAND_MEMORY"; }
396 // FIXME: rename brtarget to t2_brtarget
397 def brtarget : Operand<OtherVT> {
398 let EncoderMethod = "getBranchTargetOpValue";
399 let OperandType = "OPERAND_PCREL";
400 let DecoderMethod = "DecodeT2BROperand";
403 // FIXME: get rid of this one?
404 def uncondbrtarget : Operand<OtherVT> {
405 let EncoderMethod = "getUnconditionalBranchTargetOpValue";
406 let OperandType = "OPERAND_PCREL";
409 // Branch target for ARM. Handles conditional/unconditional
410 def br_target : Operand<OtherVT> {
411 let EncoderMethod = "getARMBranchTargetOpValue";
412 let OperandType = "OPERAND_PCREL";
416 // FIXME: rename bltarget to t2_bl_target?
417 def bltarget : Operand<i32> {
418 // Encoded the same as branch targets.
419 let EncoderMethod = "getBranchTargetOpValue";
420 let OperandType = "OPERAND_PCREL";
423 // Call target for ARM. Handles conditional/unconditional
424 // FIXME: rename bl_target to t2_bltarget?
425 def bl_target : Operand<i32> {
426 let EncoderMethod = "getARMBLTargetOpValue";
427 let OperandType = "OPERAND_PCREL";
430 def blx_target : Operand<i32> {
431 let EncoderMethod = "getARMBLXTargetOpValue";
432 let OperandType = "OPERAND_PCREL";
435 // A list of registers separated by comma. Used by load/store multiple.
436 def RegListAsmOperand : AsmOperandClass { let Name = "RegList"; }
437 def reglist : Operand<i32> {
438 let EncoderMethod = "getRegisterListOpValue";
439 let ParserMatchClass = RegListAsmOperand;
440 let PrintMethod = "printRegisterList";
441 let DecoderMethod = "DecodeRegListOperand";
444 def GPRPairOp : RegisterOperand<GPRPair, "printGPRPairOperand">;
446 def DPRRegListAsmOperand : AsmOperandClass { let Name = "DPRRegList"; }
447 def dpr_reglist : Operand<i32> {
448 let EncoderMethod = "getRegisterListOpValue";
449 let ParserMatchClass = DPRRegListAsmOperand;
450 let PrintMethod = "printRegisterList";
451 let DecoderMethod = "DecodeDPRRegListOperand";
454 def SPRRegListAsmOperand : AsmOperandClass { let Name = "SPRRegList"; }
455 def spr_reglist : Operand<i32> {
456 let EncoderMethod = "getRegisterListOpValue";
457 let ParserMatchClass = SPRRegListAsmOperand;
458 let PrintMethod = "printRegisterList";
459 let DecoderMethod = "DecodeSPRRegListOperand";
462 // An operand for the CONSTPOOL_ENTRY pseudo-instruction.
463 def cpinst_operand : Operand<i32> {
464 let PrintMethod = "printCPInstOperand";
468 def pclabel : Operand<i32> {
469 let PrintMethod = "printPCLabel";
472 // ADR instruction labels.
473 def AdrLabelAsmOperand : AsmOperandClass { let Name = "AdrLabel"; }
474 def adrlabel : Operand<i32> {
475 let EncoderMethod = "getAdrLabelOpValue";
476 let ParserMatchClass = AdrLabelAsmOperand;
477 let PrintMethod = "printAdrLabelOperand<0>";
480 def neon_vcvt_imm32 : Operand<i32> {
481 let EncoderMethod = "getNEONVcvtImm32OpValue";
482 let DecoderMethod = "DecodeVCVTImmOperand";
485 // rot_imm: An integer that encodes a rotate amount. Must be 8, 16, or 24.
486 def rot_imm_XFORM: SDNodeXForm<imm, [{
487 switch (N->getZExtValue()){
488 default: llvm_unreachable(nullptr);
489 case 0: return CurDAG->getTargetConstant(0, SDLoc(N), MVT::i32);
490 case 8: return CurDAG->getTargetConstant(1, SDLoc(N), MVT::i32);
491 case 16: return CurDAG->getTargetConstant(2, SDLoc(N), MVT::i32);
492 case 24: return CurDAG->getTargetConstant(3, SDLoc(N), MVT::i32);
495 def RotImmAsmOperand : AsmOperandClass {
497 let ParserMethod = "parseRotImm";
499 def rot_imm : Operand<i32>, PatLeaf<(i32 imm), [{
500 int32_t v = N->getZExtValue();
501 return v == 8 || v == 16 || v == 24; }],
503 let PrintMethod = "printRotImmOperand";
504 let ParserMatchClass = RotImmAsmOperand;
507 // shift_imm: An integer that encodes a shift amount and the type of shift
508 // (asr or lsl). The 6-bit immediate encodes as:
511 // {4-0} imm5 shift amount.
512 // asr #32 encoded as imm5 == 0.
513 def ShifterImmAsmOperand : AsmOperandClass {
514 let Name = "ShifterImm";
515 let ParserMethod = "parseShifterImm";
517 def shift_imm : Operand<i32> {
518 let PrintMethod = "printShiftImmOperand";
519 let ParserMatchClass = ShifterImmAsmOperand;
522 // shifter_operand operands: so_reg_reg, so_reg_imm, and mod_imm.
523 def ShiftedRegAsmOperand : AsmOperandClass { let Name = "RegShiftedReg"; }
524 def so_reg_reg : Operand<i32>, // reg reg imm
525 ComplexPattern<i32, 3, "SelectRegShifterOperand",
526 [shl, srl, sra, rotr]> {
527 let EncoderMethod = "getSORegRegOpValue";
528 let PrintMethod = "printSORegRegOperand";
529 let DecoderMethod = "DecodeSORegRegOperand";
530 let ParserMatchClass = ShiftedRegAsmOperand;
531 let MIOperandInfo = (ops GPRnopc, GPRnopc, i32imm);
534 def ShiftedImmAsmOperand : AsmOperandClass { let Name = "RegShiftedImm"; }
535 def so_reg_imm : Operand<i32>, // reg imm
536 ComplexPattern<i32, 2, "SelectImmShifterOperand",
537 [shl, srl, sra, rotr]> {
538 let EncoderMethod = "getSORegImmOpValue";
539 let PrintMethod = "printSORegImmOperand";
540 let DecoderMethod = "DecodeSORegImmOperand";
541 let ParserMatchClass = ShiftedImmAsmOperand;
542 let MIOperandInfo = (ops GPR, i32imm);
545 // FIXME: Does this need to be distinct from so_reg?
546 def shift_so_reg_reg : Operand<i32>, // reg reg imm
547 ComplexPattern<i32, 3, "SelectShiftRegShifterOperand",
548 [shl,srl,sra,rotr]> {
549 let EncoderMethod = "getSORegRegOpValue";
550 let PrintMethod = "printSORegRegOperand";
551 let DecoderMethod = "DecodeSORegRegOperand";
552 let ParserMatchClass = ShiftedRegAsmOperand;
553 let MIOperandInfo = (ops GPR, GPR, i32imm);
556 // FIXME: Does this need to be distinct from so_reg?
557 def shift_so_reg_imm : Operand<i32>, // reg reg imm
558 ComplexPattern<i32, 2, "SelectShiftImmShifterOperand",
559 [shl,srl,sra,rotr]> {
560 let EncoderMethod = "getSORegImmOpValue";
561 let PrintMethod = "printSORegImmOperand";
562 let DecoderMethod = "DecodeSORegImmOperand";
563 let ParserMatchClass = ShiftedImmAsmOperand;
564 let MIOperandInfo = (ops GPR, i32imm);
567 // mod_imm: match a 32-bit immediate operand, which can be encoded into
568 // a 12-bit immediate; an 8-bit integer and a 4-bit rotator (See ARMARM
569 // - "Modified Immediate Constants"). Within the MC layer we keep this
570 // immediate in its encoded form.
571 def ModImmAsmOperand: AsmOperandClass {
573 let ParserMethod = "parseModImm";
575 def mod_imm : Operand<i32>, ImmLeaf<i32, [{
576 return ARM_AM::getSOImmVal(Imm) != -1;
578 let EncoderMethod = "getModImmOpValue";
579 let PrintMethod = "printModImmOperand";
580 let ParserMatchClass = ModImmAsmOperand;
583 // Note: the patterns mod_imm_not and mod_imm_neg do not require an encoder
584 // method and such, as they are only used on aliases (Pat<> and InstAlias<>).
585 // The actual parsing, encoding, decoding are handled by the destination
586 // instructions, which use mod_imm.
588 def ModImmNotAsmOperand : AsmOperandClass { let Name = "ModImmNot"; }
589 def mod_imm_not : Operand<i32>, PatLeaf<(imm), [{
590 return ARM_AM::getSOImmVal(~(uint32_t)N->getZExtValue()) != -1;
592 let ParserMatchClass = ModImmNotAsmOperand;
595 def ModImmNegAsmOperand : AsmOperandClass { let Name = "ModImmNeg"; }
596 def mod_imm_neg : Operand<i32>, PatLeaf<(imm), [{
597 unsigned Value = -(unsigned)N->getZExtValue();
598 return Value && ARM_AM::getSOImmVal(Value) != -1;
600 let ParserMatchClass = ModImmNegAsmOperand;
603 /// arm_i32imm - True for +V6T2, or when isSOImmTwoParVal()
604 def arm_i32imm : PatLeaf<(imm), [{
605 if (Subtarget->useMovt(*MF))
607 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
610 /// imm0_1 predicate - Immediate in the range [0,1].
611 def Imm0_1AsmOperand: ImmAsmOperand { let Name = "Imm0_1"; }
612 def imm0_1 : Operand<i32> { let ParserMatchClass = Imm0_1AsmOperand; }
614 /// imm0_3 predicate - Immediate in the range [0,3].
615 def Imm0_3AsmOperand: ImmAsmOperand { let Name = "Imm0_3"; }
616 def imm0_3 : Operand<i32> { let ParserMatchClass = Imm0_3AsmOperand; }
618 /// imm0_7 predicate - Immediate in the range [0,7].
619 def Imm0_7AsmOperand: ImmAsmOperand { let Name = "Imm0_7"; }
620 def imm0_7 : Operand<i32>, ImmLeaf<i32, [{
621 return Imm >= 0 && Imm < 8;
623 let ParserMatchClass = Imm0_7AsmOperand;
626 /// imm8 predicate - Immediate is exactly 8.
627 def Imm8AsmOperand: ImmAsmOperand { let Name = "Imm8"; }
628 def imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 8; }]> {
629 let ParserMatchClass = Imm8AsmOperand;
632 /// imm16 predicate - Immediate is exactly 16.
633 def Imm16AsmOperand: ImmAsmOperand { let Name = "Imm16"; }
634 def imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 16; }]> {
635 let ParserMatchClass = Imm16AsmOperand;
638 /// imm32 predicate - Immediate is exactly 32.
639 def Imm32AsmOperand: ImmAsmOperand { let Name = "Imm32"; }
640 def imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 32; }]> {
641 let ParserMatchClass = Imm32AsmOperand;
644 def imm8_or_16 : ImmLeaf<i32, [{ return Imm == 8 || Imm == 16;}]>;
646 /// imm1_7 predicate - Immediate in the range [1,7].
647 def Imm1_7AsmOperand: ImmAsmOperand { let Name = "Imm1_7"; }
648 def imm1_7 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 8; }]> {
649 let ParserMatchClass = Imm1_7AsmOperand;
652 /// imm1_15 predicate - Immediate in the range [1,15].
653 def Imm1_15AsmOperand: ImmAsmOperand { let Name = "Imm1_15"; }
654 def imm1_15 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 16; }]> {
655 let ParserMatchClass = Imm1_15AsmOperand;
658 /// imm1_31 predicate - Immediate in the range [1,31].
659 def Imm1_31AsmOperand: ImmAsmOperand { let Name = "Imm1_31"; }
660 def imm1_31 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 32; }]> {
661 let ParserMatchClass = Imm1_31AsmOperand;
664 /// imm0_15 predicate - Immediate in the range [0,15].
665 def Imm0_15AsmOperand: ImmAsmOperand {
666 let Name = "Imm0_15";
667 let DiagnosticType = "ImmRange0_15";
669 def imm0_15 : Operand<i32>, ImmLeaf<i32, [{
670 return Imm >= 0 && Imm < 16;
672 let ParserMatchClass = Imm0_15AsmOperand;
675 /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
676 def Imm0_31AsmOperand: ImmAsmOperand { let Name = "Imm0_31"; }
677 def imm0_31 : Operand<i32>, ImmLeaf<i32, [{
678 return Imm >= 0 && Imm < 32;
680 let ParserMatchClass = Imm0_31AsmOperand;
683 /// imm0_32 predicate - True if the 32-bit immediate is in the range [0,32].
684 def Imm0_32AsmOperand: ImmAsmOperand { let Name = "Imm0_32"; }
685 def imm0_32 : Operand<i32>, ImmLeaf<i32, [{
686 return Imm >= 0 && Imm < 32;
688 let ParserMatchClass = Imm0_32AsmOperand;
691 /// imm0_63 predicate - True if the 32-bit immediate is in the range [0,63].
692 def Imm0_63AsmOperand: ImmAsmOperand { let Name = "Imm0_63"; }
693 def imm0_63 : Operand<i32>, ImmLeaf<i32, [{
694 return Imm >= 0 && Imm < 64;
696 let ParserMatchClass = Imm0_63AsmOperand;
699 /// imm0_239 predicate - Immediate in the range [0,239].
700 def Imm0_239AsmOperand : ImmAsmOperand {
701 let Name = "Imm0_239";
702 let DiagnosticType = "ImmRange0_239";
704 def imm0_239 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 240; }]> {
705 let ParserMatchClass = Imm0_239AsmOperand;
708 /// imm0_255 predicate - Immediate in the range [0,255].
709 def Imm0_255AsmOperand : ImmAsmOperand { let Name = "Imm0_255"; }
710 def imm0_255 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 256; }]> {
711 let ParserMatchClass = Imm0_255AsmOperand;
714 /// imm0_65535 - An immediate is in the range [0.65535].
715 def Imm0_65535AsmOperand: ImmAsmOperand { let Name = "Imm0_65535"; }
716 def imm0_65535 : Operand<i32>, ImmLeaf<i32, [{
717 return Imm >= 0 && Imm < 65536;
719 let ParserMatchClass = Imm0_65535AsmOperand;
722 // imm0_65535_neg - An immediate whose negative value is in the range [0.65535].
723 def imm0_65535_neg : Operand<i32>, ImmLeaf<i32, [{
724 return -Imm >= 0 && -Imm < 65536;
727 // imm0_65535_expr - For movt/movw - 16-bit immediate that can also reference
728 // a relocatable expression.
730 // FIXME: This really needs a Thumb version separate from the ARM version.
731 // While the range is the same, and can thus use the same match class,
732 // the encoding is different so it should have a different encoder method.
733 def Imm0_65535ExprAsmOperand: ImmAsmOperand { let Name = "Imm0_65535Expr"; }
734 def imm0_65535_expr : Operand<i32> {
735 let EncoderMethod = "getHiLo16ImmOpValue";
736 let ParserMatchClass = Imm0_65535ExprAsmOperand;
739 def Imm256_65535ExprAsmOperand: ImmAsmOperand { let Name = "Imm256_65535Expr"; }
740 def imm256_65535_expr : Operand<i32> {
741 let ParserMatchClass = Imm256_65535ExprAsmOperand;
744 /// imm24b - True if the 32-bit immediate is encodable in 24 bits.
745 def Imm24bitAsmOperand: ImmAsmOperand { let Name = "Imm24bit"; }
746 def imm24b : Operand<i32>, ImmLeaf<i32, [{
747 return Imm >= 0 && Imm <= 0xffffff;
749 let ParserMatchClass = Imm24bitAsmOperand;
753 /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
755 def BitfieldAsmOperand : AsmOperandClass {
756 let Name = "Bitfield";
757 let ParserMethod = "parseBitfield";
760 def bf_inv_mask_imm : Operand<i32>,
762 return ARM::isBitFieldInvertedMask(N->getZExtValue());
764 let EncoderMethod = "getBitfieldInvertedMaskOpValue";
765 let PrintMethod = "printBitfieldInvMaskImmOperand";
766 let DecoderMethod = "DecodeBitfieldMaskOperand";
767 let ParserMatchClass = BitfieldAsmOperand;
770 def imm1_32_XFORM: SDNodeXForm<imm, [{
771 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, SDLoc(N),
774 def Imm1_32AsmOperand: AsmOperandClass { let Name = "Imm1_32"; }
775 def imm1_32 : Operand<i32>, PatLeaf<(imm), [{
776 uint64_t Imm = N->getZExtValue();
777 return Imm > 0 && Imm <= 32;
780 let PrintMethod = "printImmPlusOneOperand";
781 let ParserMatchClass = Imm1_32AsmOperand;
784 def imm1_16_XFORM: SDNodeXForm<imm, [{
785 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, SDLoc(N),
788 def Imm1_16AsmOperand: AsmOperandClass { let Name = "Imm1_16"; }
789 def imm1_16 : Operand<i32>, PatLeaf<(imm), [{ return Imm > 0 && Imm <= 16; }],
791 let PrintMethod = "printImmPlusOneOperand";
792 let ParserMatchClass = Imm1_16AsmOperand;
795 // Define ARM specific addressing modes.
796 // addrmode_imm12 := reg +/- imm12
798 def MemImm12OffsetAsmOperand : AsmOperandClass { let Name = "MemImm12Offset"; }
799 class AddrMode_Imm12 : MemOperand,
800 ComplexPattern<i32, 2, "SelectAddrModeImm12", []> {
801 // 12-bit immediate operand. Note that instructions using this encode
802 // #0 and #-0 differently. We flag #-0 as the magic value INT32_MIN. All other
803 // immediate values are as normal.
805 let EncoderMethod = "getAddrModeImm12OpValue";
806 let DecoderMethod = "DecodeAddrModeImm12Operand";
807 let ParserMatchClass = MemImm12OffsetAsmOperand;
808 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
811 def addrmode_imm12 : AddrMode_Imm12 {
812 let PrintMethod = "printAddrModeImm12Operand<false>";
815 def addrmode_imm12_pre : AddrMode_Imm12 {
816 let PrintMethod = "printAddrModeImm12Operand<true>";
819 // ldst_so_reg := reg +/- reg shop imm
821 def MemRegOffsetAsmOperand : AsmOperandClass { let Name = "MemRegOffset"; }
822 def ldst_so_reg : MemOperand,
823 ComplexPattern<i32, 3, "SelectLdStSOReg", []> {
824 let EncoderMethod = "getLdStSORegOpValue";
825 // FIXME: Simplify the printer
826 let PrintMethod = "printAddrMode2Operand";
827 let DecoderMethod = "DecodeSORegMemOperand";
828 let ParserMatchClass = MemRegOffsetAsmOperand;
829 let MIOperandInfo = (ops GPR:$base, GPRnopc:$offsreg, i32imm:$shift);
832 // postidx_imm8 := +/- [0,255]
835 // {8} 1 is imm8 is non-negative. 0 otherwise.
836 // {7-0} [0,255] imm8 value.
837 def PostIdxImm8AsmOperand : AsmOperandClass { let Name = "PostIdxImm8"; }
838 def postidx_imm8 : MemOperand {
839 let PrintMethod = "printPostIdxImm8Operand";
840 let ParserMatchClass = PostIdxImm8AsmOperand;
841 let MIOperandInfo = (ops i32imm);
844 // postidx_imm8s4 := +/- [0,1020]
847 // {8} 1 is imm8 is non-negative. 0 otherwise.
848 // {7-0} [0,255] imm8 value, scaled by 4.
849 def PostIdxImm8s4AsmOperand : AsmOperandClass { let Name = "PostIdxImm8s4"; }
850 def postidx_imm8s4 : MemOperand {
851 let PrintMethod = "printPostIdxImm8s4Operand";
852 let ParserMatchClass = PostIdxImm8s4AsmOperand;
853 let MIOperandInfo = (ops i32imm);
857 // postidx_reg := +/- reg
859 def PostIdxRegAsmOperand : AsmOperandClass {
860 let Name = "PostIdxReg";
861 let ParserMethod = "parsePostIdxReg";
863 def postidx_reg : MemOperand {
864 let EncoderMethod = "getPostIdxRegOpValue";
865 let DecoderMethod = "DecodePostIdxReg";
866 let PrintMethod = "printPostIdxRegOperand";
867 let ParserMatchClass = PostIdxRegAsmOperand;
868 let MIOperandInfo = (ops GPRnopc, i32imm);
872 // addrmode2 := reg +/- imm12
873 // := reg +/- reg shop imm
875 // FIXME: addrmode2 should be refactored the rest of the way to always
876 // use explicit imm vs. reg versions above (addrmode_imm12 and ldst_so_reg).
877 def AddrMode2AsmOperand : AsmOperandClass { let Name = "AddrMode2"; }
878 def addrmode2 : MemOperand,
879 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
880 let EncoderMethod = "getAddrMode2OpValue";
881 let PrintMethod = "printAddrMode2Operand";
882 let ParserMatchClass = AddrMode2AsmOperand;
883 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
886 def PostIdxRegShiftedAsmOperand : AsmOperandClass {
887 let Name = "PostIdxRegShifted";
888 let ParserMethod = "parsePostIdxReg";
890 def am2offset_reg : MemOperand,
891 ComplexPattern<i32, 2, "SelectAddrMode2OffsetReg",
892 [], [SDNPWantRoot]> {
893 let EncoderMethod = "getAddrMode2OffsetOpValue";
894 let PrintMethod = "printAddrMode2OffsetOperand";
895 // When using this for assembly, it's always as a post-index offset.
896 let ParserMatchClass = PostIdxRegShiftedAsmOperand;
897 let MIOperandInfo = (ops GPRnopc, i32imm);
900 // FIXME: am2offset_imm should only need the immediate, not the GPR. Having
901 // the GPR is purely vestigal at this point.
902 def AM2OffsetImmAsmOperand : AsmOperandClass { let Name = "AM2OffsetImm"; }
903 def am2offset_imm : MemOperand,
904 ComplexPattern<i32, 2, "SelectAddrMode2OffsetImm",
905 [], [SDNPWantRoot]> {
906 let EncoderMethod = "getAddrMode2OffsetOpValue";
907 let PrintMethod = "printAddrMode2OffsetOperand";
908 let ParserMatchClass = AM2OffsetImmAsmOperand;
909 let MIOperandInfo = (ops GPRnopc, i32imm);
913 // addrmode3 := reg +/- reg
914 // addrmode3 := reg +/- imm8
916 // FIXME: split into imm vs. reg versions.
917 def AddrMode3AsmOperand : AsmOperandClass { let Name = "AddrMode3"; }
918 class AddrMode3 : MemOperand,
919 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
920 let EncoderMethod = "getAddrMode3OpValue";
921 let ParserMatchClass = AddrMode3AsmOperand;
922 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
925 def addrmode3 : AddrMode3
927 let PrintMethod = "printAddrMode3Operand<false>";
930 def addrmode3_pre : AddrMode3
932 let PrintMethod = "printAddrMode3Operand<true>";
935 // FIXME: split into imm vs. reg versions.
936 // FIXME: parser method to handle +/- register.
937 def AM3OffsetAsmOperand : AsmOperandClass {
938 let Name = "AM3Offset";
939 let ParserMethod = "parseAM3Offset";
941 def am3offset : MemOperand,
942 ComplexPattern<i32, 2, "SelectAddrMode3Offset",
943 [], [SDNPWantRoot]> {
944 let EncoderMethod = "getAddrMode3OffsetOpValue";
945 let PrintMethod = "printAddrMode3OffsetOperand";
946 let ParserMatchClass = AM3OffsetAsmOperand;
947 let MIOperandInfo = (ops GPR, i32imm);
950 // ldstm_mode := {ia, ib, da, db}
952 def ldstm_mode : OptionalDefOperand<OtherVT, (ops i32), (ops (i32 1))> {
953 let EncoderMethod = "getLdStmModeOpValue";
954 let PrintMethod = "printLdStmModeOperand";
957 // addrmode5 := reg +/- imm8*4
959 def AddrMode5AsmOperand : AsmOperandClass { let Name = "AddrMode5"; }
960 class AddrMode5 : MemOperand,
961 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
962 let EncoderMethod = "getAddrMode5OpValue";
963 let DecoderMethod = "DecodeAddrMode5Operand";
964 let ParserMatchClass = AddrMode5AsmOperand;
965 let MIOperandInfo = (ops GPR:$base, i32imm);
968 def addrmode5 : AddrMode5 {
969 let PrintMethod = "printAddrMode5Operand<false>";
972 def addrmode5_pre : AddrMode5 {
973 let PrintMethod = "printAddrMode5Operand<true>";
976 // addrmode6 := reg with optional alignment
978 def AddrMode6AsmOperand : AsmOperandClass { let Name = "AlignedMemory"; }
979 def addrmode6 : MemOperand,
980 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
981 let PrintMethod = "printAddrMode6Operand";
982 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
983 let EncoderMethod = "getAddrMode6AddressOpValue";
984 let DecoderMethod = "DecodeAddrMode6Operand";
985 let ParserMatchClass = AddrMode6AsmOperand;
988 def am6offset : MemOperand,
989 ComplexPattern<i32, 1, "SelectAddrMode6Offset",
990 [], [SDNPWantRoot]> {
991 let PrintMethod = "printAddrMode6OffsetOperand";
992 let MIOperandInfo = (ops GPR);
993 let EncoderMethod = "getAddrMode6OffsetOpValue";
994 let DecoderMethod = "DecodeGPRRegisterClass";
997 // Special version of addrmode6 to handle alignment encoding for VST1/VLD1
998 // (single element from one lane) for size 32.
999 def addrmode6oneL32 : MemOperand,
1000 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1001 let PrintMethod = "printAddrMode6Operand";
1002 let MIOperandInfo = (ops GPR:$addr, i32imm);
1003 let EncoderMethod = "getAddrMode6OneLane32AddressOpValue";
1006 // Base class for addrmode6 with specific alignment restrictions.
1007 class AddrMode6Align : MemOperand,
1008 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1009 let PrintMethod = "printAddrMode6Operand";
1010 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
1011 let EncoderMethod = "getAddrMode6AddressOpValue";
1012 let DecoderMethod = "DecodeAddrMode6Operand";
1015 // Special version of addrmode6 to handle no allowed alignment encoding for
1016 // VLD/VST instructions and checking the alignment is not specified.
1017 def AddrMode6AlignNoneAsmOperand : AsmOperandClass {
1018 let Name = "AlignedMemoryNone";
1019 let DiagnosticType = "AlignedMemoryRequiresNone";
1021 def addrmode6alignNone : AddrMode6Align {
1022 // The alignment specifier can only be omitted.
1023 let ParserMatchClass = AddrMode6AlignNoneAsmOperand;
1026 // Special version of addrmode6 to handle 16-bit alignment encoding for
1027 // VLD/VST instructions and checking the alignment value.
1028 def AddrMode6Align16AsmOperand : AsmOperandClass {
1029 let Name = "AlignedMemory16";
1030 let DiagnosticType = "AlignedMemoryRequires16";
1032 def addrmode6align16 : AddrMode6Align {
1033 // The alignment specifier can only be 16 or omitted.
1034 let ParserMatchClass = AddrMode6Align16AsmOperand;
1037 // Special version of addrmode6 to handle 32-bit alignment encoding for
1038 // VLD/VST instructions and checking the alignment value.
1039 def AddrMode6Align32AsmOperand : AsmOperandClass {
1040 let Name = "AlignedMemory32";
1041 let DiagnosticType = "AlignedMemoryRequires32";
1043 def addrmode6align32 : AddrMode6Align {
1044 // The alignment specifier can only be 32 or omitted.
1045 let ParserMatchClass = AddrMode6Align32AsmOperand;
1048 // Special version of addrmode6 to handle 64-bit alignment encoding for
1049 // VLD/VST instructions and checking the alignment value.
1050 def AddrMode6Align64AsmOperand : AsmOperandClass {
1051 let Name = "AlignedMemory64";
1052 let DiagnosticType = "AlignedMemoryRequires64";
1054 def addrmode6align64 : AddrMode6Align {
1055 // The alignment specifier can only be 64 or omitted.
1056 let ParserMatchClass = AddrMode6Align64AsmOperand;
1059 // Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding
1060 // for VLD/VST instructions and checking the alignment value.
1061 def AddrMode6Align64or128AsmOperand : AsmOperandClass {
1062 let Name = "AlignedMemory64or128";
1063 let DiagnosticType = "AlignedMemoryRequires64or128";
1065 def addrmode6align64or128 : AddrMode6Align {
1066 // The alignment specifier can only be 64, 128 or omitted.
1067 let ParserMatchClass = AddrMode6Align64or128AsmOperand;
1070 // Special version of addrmode6 to handle 64-bit, 128-bit or 256-bit alignment
1071 // encoding for VLD/VST instructions and checking the alignment value.
1072 def AddrMode6Align64or128or256AsmOperand : AsmOperandClass {
1073 let Name = "AlignedMemory64or128or256";
1074 let DiagnosticType = "AlignedMemoryRequires64or128or256";
1076 def addrmode6align64or128or256 : AddrMode6Align {
1077 // The alignment specifier can only be 64, 128, 256 or omitted.
1078 let ParserMatchClass = AddrMode6Align64or128or256AsmOperand;
1081 // Special version of addrmode6 to handle alignment encoding for VLD-dup
1082 // instructions, specifically VLD4-dup.
1083 def addrmode6dup : MemOperand,
1084 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1085 let PrintMethod = "printAddrMode6Operand";
1086 let MIOperandInfo = (ops GPR:$addr, i32imm);
1087 let EncoderMethod = "getAddrMode6DupAddressOpValue";
1088 // FIXME: This is close, but not quite right. The alignment specifier is
1090 let ParserMatchClass = AddrMode6AsmOperand;
1093 // Base class for addrmode6dup with specific alignment restrictions.
1094 class AddrMode6DupAlign : MemOperand,
1095 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1096 let PrintMethod = "printAddrMode6Operand";
1097 let MIOperandInfo = (ops GPR:$addr, i32imm);
1098 let EncoderMethod = "getAddrMode6DupAddressOpValue";
1101 // Special version of addrmode6 to handle no allowed alignment encoding for
1102 // VLD-dup instruction and checking the alignment is not specified.
1103 def AddrMode6dupAlignNoneAsmOperand : AsmOperandClass {
1104 let Name = "DupAlignedMemoryNone";
1105 let DiagnosticType = "DupAlignedMemoryRequiresNone";
1107 def addrmode6dupalignNone : AddrMode6DupAlign {
1108 // The alignment specifier can only be omitted.
1109 let ParserMatchClass = AddrMode6dupAlignNoneAsmOperand;
1112 // Special version of addrmode6 to handle 16-bit alignment encoding for VLD-dup
1113 // instruction and checking the alignment value.
1114 def AddrMode6dupAlign16AsmOperand : AsmOperandClass {
1115 let Name = "DupAlignedMemory16";
1116 let DiagnosticType = "DupAlignedMemoryRequires16";
1118 def addrmode6dupalign16 : AddrMode6DupAlign {
1119 // The alignment specifier can only be 16 or omitted.
1120 let ParserMatchClass = AddrMode6dupAlign16AsmOperand;
1123 // Special version of addrmode6 to handle 32-bit alignment encoding for VLD-dup
1124 // instruction and checking the alignment value.
1125 def AddrMode6dupAlign32AsmOperand : AsmOperandClass {
1126 let Name = "DupAlignedMemory32";
1127 let DiagnosticType = "DupAlignedMemoryRequires32";
1129 def addrmode6dupalign32 : AddrMode6DupAlign {
1130 // The alignment specifier can only be 32 or omitted.
1131 let ParserMatchClass = AddrMode6dupAlign32AsmOperand;
1134 // Special version of addrmode6 to handle 64-bit alignment encoding for VLD
1135 // instructions and checking the alignment value.
1136 def AddrMode6dupAlign64AsmOperand : AsmOperandClass {
1137 let Name = "DupAlignedMemory64";
1138 let DiagnosticType = "DupAlignedMemoryRequires64";
1140 def addrmode6dupalign64 : AddrMode6DupAlign {
1141 // The alignment specifier can only be 64 or omitted.
1142 let ParserMatchClass = AddrMode6dupAlign64AsmOperand;
1145 // Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding
1146 // for VLD instructions and checking the alignment value.
1147 def AddrMode6dupAlign64or128AsmOperand : AsmOperandClass {
1148 let Name = "DupAlignedMemory64or128";
1149 let DiagnosticType = "DupAlignedMemoryRequires64or128";
1151 def addrmode6dupalign64or128 : AddrMode6DupAlign {
1152 // The alignment specifier can only be 64, 128 or omitted.
1153 let ParserMatchClass = AddrMode6dupAlign64or128AsmOperand;
1156 // addrmodepc := pc + reg
1158 def addrmodepc : MemOperand,
1159 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
1160 let PrintMethod = "printAddrModePCOperand";
1161 let MIOperandInfo = (ops GPR, i32imm);
1164 // addr_offset_none := reg
1166 def MemNoOffsetAsmOperand : AsmOperandClass { let Name = "MemNoOffset"; }
1167 def addr_offset_none : MemOperand,
1168 ComplexPattern<i32, 1, "SelectAddrOffsetNone", []> {
1169 let PrintMethod = "printAddrMode7Operand";
1170 let DecoderMethod = "DecodeAddrMode7Operand";
1171 let ParserMatchClass = MemNoOffsetAsmOperand;
1172 let MIOperandInfo = (ops GPR:$base);
1175 def nohash_imm : Operand<i32> {
1176 let PrintMethod = "printNoHashImmediate";
1179 def CoprocNumAsmOperand : AsmOperandClass {
1180 let Name = "CoprocNum";
1181 let ParserMethod = "parseCoprocNumOperand";
1183 def p_imm : Operand<i32> {
1184 let PrintMethod = "printPImmediate";
1185 let ParserMatchClass = CoprocNumAsmOperand;
1186 let DecoderMethod = "DecodeCoprocessor";
1189 def CoprocRegAsmOperand : AsmOperandClass {
1190 let Name = "CoprocReg";
1191 let ParserMethod = "parseCoprocRegOperand";
1193 def c_imm : Operand<i32> {
1194 let PrintMethod = "printCImmediate";
1195 let ParserMatchClass = CoprocRegAsmOperand;
1197 def CoprocOptionAsmOperand : AsmOperandClass {
1198 let Name = "CoprocOption";
1199 let ParserMethod = "parseCoprocOptionOperand";
1201 def coproc_option_imm : Operand<i32> {
1202 let PrintMethod = "printCoprocOptionImm";
1203 let ParserMatchClass = CoprocOptionAsmOperand;
1206 //===----------------------------------------------------------------------===//
1208 include "ARMInstrFormats.td"
1210 //===----------------------------------------------------------------------===//
1211 // Multiclass helpers...
1214 /// AsI1_bin_irs - Defines a set of (op r, {mod_imm|r|so_reg}) patterns for a
1215 /// binop that produces a value.
1216 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1217 multiclass AsI1_bin_irs<bits<4> opcod, string opc,
1218 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1219 PatFrag opnode, bit Commutable = 0> {
1220 // The register-immediate version is re-materializable. This is useful
1221 // in particular for taking the address of a local.
1222 let isReMaterializable = 1 in {
1223 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm,
1224 iii, opc, "\t$Rd, $Rn, $imm",
1225 [(set GPR:$Rd, (opnode GPR:$Rn, mod_imm:$imm))]>,
1226 Sched<[WriteALU, ReadALU]> {
1231 let Inst{19-16} = Rn;
1232 let Inst{15-12} = Rd;
1233 let Inst{11-0} = imm;
1236 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1237 iir, opc, "\t$Rd, $Rn, $Rm",
1238 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]>,
1239 Sched<[WriteALU, ReadALU, ReadALU]> {
1244 let isCommutable = Commutable;
1245 let Inst{19-16} = Rn;
1246 let Inst{15-12} = Rd;
1247 let Inst{11-4} = 0b00000000;
1251 def rsi : AsI1<opcod, (outs GPR:$Rd),
1252 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1253 iis, opc, "\t$Rd, $Rn, $shift",
1254 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_imm:$shift))]>,
1255 Sched<[WriteALUsi, ReadALU]> {
1260 let Inst{19-16} = Rn;
1261 let Inst{15-12} = Rd;
1262 let Inst{11-5} = shift{11-5};
1264 let Inst{3-0} = shift{3-0};
1267 def rsr : AsI1<opcod, (outs GPR:$Rd),
1268 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1269 iis, opc, "\t$Rd, $Rn, $shift",
1270 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_reg:$shift))]>,
1271 Sched<[WriteALUsr, ReadALUsr]> {
1276 let Inst{19-16} = Rn;
1277 let Inst{15-12} = Rd;
1278 let Inst{11-8} = shift{11-8};
1280 let Inst{6-5} = shift{6-5};
1282 let Inst{3-0} = shift{3-0};
1286 /// AsI1_rbin_irs - Same as AsI1_bin_irs except the order of operands are
1287 /// reversed. The 'rr' form is only defined for the disassembler; for codegen
1288 /// it is equivalent to the AsI1_bin_irs counterpart.
1289 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1290 multiclass AsI1_rbin_irs<bits<4> opcod, string opc,
1291 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1292 PatFrag opnode, bit Commutable = 0> {
1293 // The register-immediate version is re-materializable. This is useful
1294 // in particular for taking the address of a local.
1295 let isReMaterializable = 1 in {
1296 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm,
1297 iii, opc, "\t$Rd, $Rn, $imm",
1298 [(set GPR:$Rd, (opnode mod_imm:$imm, GPR:$Rn))]>,
1299 Sched<[WriteALU, ReadALU]> {
1304 let Inst{19-16} = Rn;
1305 let Inst{15-12} = Rd;
1306 let Inst{11-0} = imm;
1309 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1310 iir, opc, "\t$Rd, $Rn, $Rm",
1311 [/* pattern left blank */]>,
1312 Sched<[WriteALU, ReadALU, ReadALU]> {
1316 let Inst{11-4} = 0b00000000;
1319 let Inst{15-12} = Rd;
1320 let Inst{19-16} = Rn;
1323 def rsi : AsI1<opcod, (outs GPR:$Rd),
1324 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1325 iis, opc, "\t$Rd, $Rn, $shift",
1326 [(set GPR:$Rd, (opnode so_reg_imm:$shift, GPR:$Rn))]>,
1327 Sched<[WriteALUsi, ReadALU]> {
1332 let Inst{19-16} = Rn;
1333 let Inst{15-12} = Rd;
1334 let Inst{11-5} = shift{11-5};
1336 let Inst{3-0} = shift{3-0};
1339 def rsr : AsI1<opcod, (outs GPR:$Rd),
1340 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1341 iis, opc, "\t$Rd, $Rn, $shift",
1342 [(set GPR:$Rd, (opnode so_reg_reg:$shift, GPR:$Rn))]>,
1343 Sched<[WriteALUsr, ReadALUsr]> {
1348 let Inst{19-16} = Rn;
1349 let Inst{15-12} = Rd;
1350 let Inst{11-8} = shift{11-8};
1352 let Inst{6-5} = shift{6-5};
1354 let Inst{3-0} = shift{3-0};
1358 /// AsI1_bin_s_irs - Same as AsI1_bin_irs except it sets the 's' bit by default.
1360 /// These opcodes will be converted to the real non-S opcodes by
1361 /// AdjustInstrPostInstrSelection after giving them an optional CPSR operand.
1362 let hasPostISelHook = 1, Defs = [CPSR] in {
1363 multiclass AsI1_bin_s_irs<InstrItinClass iii, InstrItinClass iir,
1364 InstrItinClass iis, PatFrag opnode,
1365 bit Commutable = 0> {
1366 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p),
1368 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm))]>,
1369 Sched<[WriteALU, ReadALU]>;
1371 def rr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, pred:$p),
1373 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm))]>,
1374 Sched<[WriteALU, ReadALU, ReadALU]> {
1375 let isCommutable = Commutable;
1377 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1378 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1380 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1381 so_reg_imm:$shift))]>,
1382 Sched<[WriteALUsi, ReadALU]>;
1384 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1385 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1387 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1388 so_reg_reg:$shift))]>,
1389 Sched<[WriteALUSsr, ReadALUsr]>;
1393 /// AsI1_rbin_s_is - Same as AsI1_bin_s_irs, except selection DAG
1394 /// operands are reversed.
1395 let hasPostISelHook = 1, Defs = [CPSR] in {
1396 multiclass AsI1_rbin_s_is<InstrItinClass iii, InstrItinClass iir,
1397 InstrItinClass iis, PatFrag opnode,
1398 bit Commutable = 0> {
1399 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p),
1401 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn))]>,
1402 Sched<[WriteALU, ReadALU]>;
1404 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1405 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1407 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift,
1409 Sched<[WriteALUsi, ReadALU]>;
1411 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1412 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1414 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift,
1416 Sched<[WriteALUSsr, ReadALUsr]>;
1420 /// AI1_cmp_irs - Defines a set of (op r, {mod_imm|r|so_reg}) cmp / test
1421 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
1422 /// a explicit result, only implicitly set CPSR.
1423 let isCompare = 1, Defs = [CPSR] in {
1424 multiclass AI1_cmp_irs<bits<4> opcod, string opc,
1425 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1426 PatFrag opnode, bit Commutable = 0,
1427 string rrDecoderMethod = ""> {
1428 def ri : AI1<opcod, (outs), (ins GPR:$Rn, mod_imm:$imm), DPFrm, iii,
1430 [(opnode GPR:$Rn, mod_imm:$imm)]>,
1431 Sched<[WriteCMP, ReadALU]> {
1436 let Inst{19-16} = Rn;
1437 let Inst{15-12} = 0b0000;
1438 let Inst{11-0} = imm;
1440 let Unpredictable{15-12} = 0b1111;
1442 def rr : AI1<opcod, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, iir,
1444 [(opnode GPR:$Rn, GPR:$Rm)]>,
1445 Sched<[WriteCMP, ReadALU, ReadALU]> {
1448 let isCommutable = Commutable;
1451 let Inst{19-16} = Rn;
1452 let Inst{15-12} = 0b0000;
1453 let Inst{11-4} = 0b00000000;
1455 let DecoderMethod = rrDecoderMethod;
1457 let Unpredictable{15-12} = 0b1111;
1459 def rsi : AI1<opcod, (outs),
1460 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, iis,
1461 opc, "\t$Rn, $shift",
1462 [(opnode GPR:$Rn, so_reg_imm:$shift)]>,
1463 Sched<[WriteCMPsi, ReadALU]> {
1468 let Inst{19-16} = Rn;
1469 let Inst{15-12} = 0b0000;
1470 let Inst{11-5} = shift{11-5};
1472 let Inst{3-0} = shift{3-0};
1474 let Unpredictable{15-12} = 0b1111;
1476 def rsr : AI1<opcod, (outs),
1477 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, iis,
1478 opc, "\t$Rn, $shift",
1479 [(opnode GPRnopc:$Rn, so_reg_reg:$shift)]>,
1480 Sched<[WriteCMPsr, ReadALU]> {
1485 let Inst{19-16} = Rn;
1486 let Inst{15-12} = 0b0000;
1487 let Inst{11-8} = shift{11-8};
1489 let Inst{6-5} = shift{6-5};
1491 let Inst{3-0} = shift{3-0};
1493 let Unpredictable{15-12} = 0b1111;
1499 /// AI_ext_rrot - A unary operation with two forms: one whose operand is a
1500 /// register and one whose operand is a register rotated by 8/16/24.
1501 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
1502 class AI_ext_rrot<bits<8> opcod, string opc, PatFrag opnode>
1503 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1504 IIC_iEXTr, opc, "\t$Rd, $Rm$rot",
1505 [(set GPRnopc:$Rd, (opnode (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1506 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> {
1510 let Inst{19-16} = 0b1111;
1511 let Inst{15-12} = Rd;
1512 let Inst{11-10} = rot;
1516 class AI_ext_rrot_np<bits<8> opcod, string opc>
1517 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1518 IIC_iEXTr, opc, "\t$Rd, $Rm$rot", []>,
1519 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> {
1521 let Inst{19-16} = 0b1111;
1522 let Inst{11-10} = rot;
1525 /// AI_exta_rrot - A binary operation with two forms: one whose operand is a
1526 /// register and one whose operand is a register rotated by 8/16/24.
1527 class AI_exta_rrot<bits<8> opcod, string opc, PatFrag opnode>
1528 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1529 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot",
1530 [(set GPRnopc:$Rd, (opnode GPR:$Rn,
1531 (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1532 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> {
1537 let Inst{19-16} = Rn;
1538 let Inst{15-12} = Rd;
1539 let Inst{11-10} = rot;
1540 let Inst{9-4} = 0b000111;
1544 class AI_exta_rrot_np<bits<8> opcod, string opc>
1545 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1546 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot", []>,
1547 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> {
1550 let Inst{19-16} = Rn;
1551 let Inst{11-10} = rot;
1554 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
1555 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1556 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
1557 bit Commutable = 0> {
1558 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1559 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm),
1560 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1561 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm, CPSR))]>,
1563 Sched<[WriteALU, ReadALU]> {
1568 let Inst{15-12} = Rd;
1569 let Inst{19-16} = Rn;
1570 let Inst{11-0} = imm;
1572 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1573 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1574 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm, CPSR))]>,
1576 Sched<[WriteALU, ReadALU, ReadALU]> {
1580 let Inst{11-4} = 0b00000000;
1582 let isCommutable = Commutable;
1584 let Inst{15-12} = Rd;
1585 let Inst{19-16} = Rn;
1587 def rsi : AsI1<opcod, (outs GPR:$Rd),
1588 (ins GPR:$Rn, so_reg_imm:$shift),
1589 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1590 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_imm:$shift, CPSR))]>,
1592 Sched<[WriteALUsi, ReadALU]> {
1597 let Inst{19-16} = Rn;
1598 let Inst{15-12} = Rd;
1599 let Inst{11-5} = shift{11-5};
1601 let Inst{3-0} = shift{3-0};
1603 def rsr : AsI1<opcod, (outs GPRnopc:$Rd),
1604 (ins GPRnopc:$Rn, so_reg_reg:$shift),
1605 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1606 [(set GPRnopc:$Rd, CPSR,
1607 (opnode GPRnopc:$Rn, so_reg_reg:$shift, CPSR))]>,
1609 Sched<[WriteALUsr, ReadALUsr]> {
1614 let Inst{19-16} = Rn;
1615 let Inst{15-12} = Rd;
1616 let Inst{11-8} = shift{11-8};
1618 let Inst{6-5} = shift{6-5};
1620 let Inst{3-0} = shift{3-0};
1625 /// AI1_rsc_irs - Define instructions and patterns for rsc
1626 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1627 multiclass AI1_rsc_irs<bits<4> opcod, string opc, PatFrag opnode> {
1628 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1629 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm),
1630 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1631 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn, CPSR))]>,
1633 Sched<[WriteALU, ReadALU]> {
1638 let Inst{15-12} = Rd;
1639 let Inst{19-16} = Rn;
1640 let Inst{11-0} = imm;
1642 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1643 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1644 [/* pattern left blank */]>,
1645 Sched<[WriteALU, ReadALU, ReadALU]> {
1649 let Inst{11-4} = 0b00000000;
1652 let Inst{15-12} = Rd;
1653 let Inst{19-16} = Rn;
1655 def rsi : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_imm:$shift),
1656 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1657 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift, GPR:$Rn, CPSR))]>,
1659 Sched<[WriteALUsi, ReadALU]> {
1664 let Inst{19-16} = Rn;
1665 let Inst{15-12} = Rd;
1666 let Inst{11-5} = shift{11-5};
1668 let Inst{3-0} = shift{3-0};
1670 def rsr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_reg:$shift),
1671 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1672 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift, GPR:$Rn, CPSR))]>,
1674 Sched<[WriteALUsr, ReadALUsr]> {
1679 let Inst{19-16} = Rn;
1680 let Inst{15-12} = Rd;
1681 let Inst{11-8} = shift{11-8};
1683 let Inst{6-5} = shift{6-5};
1685 let Inst{3-0} = shift{3-0};
1690 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1691 multiclass AI_ldr1<bit isByte, string opc, InstrItinClass iii,
1692 InstrItinClass iir, PatFrag opnode> {
1693 // Note: We use the complex addrmode_imm12 rather than just an input
1694 // GPR and a constrained immediate so that we can use this to match
1695 // frame index references and avoid matching constant pool references.
1696 def i12: AI2ldst<0b010, 1, isByte, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
1697 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1698 [(set GPR:$Rt, (opnode addrmode_imm12:$addr))]> {
1701 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1702 let Inst{19-16} = addr{16-13}; // Rn
1703 let Inst{15-12} = Rt;
1704 let Inst{11-0} = addr{11-0}; // imm12
1706 def rs : AI2ldst<0b011, 1, isByte, (outs GPR:$Rt), (ins ldst_so_reg:$shift),
1707 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1708 [(set GPR:$Rt, (opnode ldst_so_reg:$shift))]> {
1711 let shift{4} = 0; // Inst{4} = 0
1712 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1713 let Inst{19-16} = shift{16-13}; // Rn
1714 let Inst{15-12} = Rt;
1715 let Inst{11-0} = shift{11-0};
1720 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1721 multiclass AI_ldr1nopc<bit isByte, string opc, InstrItinClass iii,
1722 InstrItinClass iir, PatFrag opnode> {
1723 // Note: We use the complex addrmode_imm12 rather than just an input
1724 // GPR and a constrained immediate so that we can use this to match
1725 // frame index references and avoid matching constant pool references.
1726 def i12: AI2ldst<0b010, 1, isByte, (outs GPRnopc:$Rt),
1727 (ins addrmode_imm12:$addr),
1728 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1729 [(set GPRnopc:$Rt, (opnode addrmode_imm12:$addr))]> {
1732 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1733 let Inst{19-16} = addr{16-13}; // Rn
1734 let Inst{15-12} = Rt;
1735 let Inst{11-0} = addr{11-0}; // imm12
1737 def rs : AI2ldst<0b011, 1, isByte, (outs GPRnopc:$Rt),
1738 (ins ldst_so_reg:$shift),
1739 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1740 [(set GPRnopc:$Rt, (opnode ldst_so_reg:$shift))]> {
1743 let shift{4} = 0; // Inst{4} = 0
1744 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1745 let Inst{19-16} = shift{16-13}; // Rn
1746 let Inst{15-12} = Rt;
1747 let Inst{11-0} = shift{11-0};
1753 multiclass AI_str1<bit isByte, string opc, InstrItinClass iii,
1754 InstrItinClass iir, PatFrag opnode> {
1755 // Note: We use the complex addrmode_imm12 rather than just an input
1756 // GPR and a constrained immediate so that we can use this to match
1757 // frame index references and avoid matching constant pool references.
1758 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1759 (ins GPR:$Rt, addrmode_imm12:$addr),
1760 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1761 [(opnode GPR:$Rt, addrmode_imm12:$addr)]> {
1764 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1765 let Inst{19-16} = addr{16-13}; // Rn
1766 let Inst{15-12} = Rt;
1767 let Inst{11-0} = addr{11-0}; // imm12
1769 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPR:$Rt, ldst_so_reg:$shift),
1770 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1771 [(opnode GPR:$Rt, ldst_so_reg:$shift)]> {
1774 let shift{4} = 0; // Inst{4} = 0
1775 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1776 let Inst{19-16} = shift{16-13}; // Rn
1777 let Inst{15-12} = Rt;
1778 let Inst{11-0} = shift{11-0};
1782 multiclass AI_str1nopc<bit isByte, string opc, InstrItinClass iii,
1783 InstrItinClass iir, PatFrag opnode> {
1784 // Note: We use the complex addrmode_imm12 rather than just an input
1785 // GPR and a constrained immediate so that we can use this to match
1786 // frame index references and avoid matching constant pool references.
1787 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1788 (ins GPRnopc:$Rt, addrmode_imm12:$addr),
1789 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1790 [(opnode GPRnopc:$Rt, addrmode_imm12:$addr)]> {
1793 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1794 let Inst{19-16} = addr{16-13}; // Rn
1795 let Inst{15-12} = Rt;
1796 let Inst{11-0} = addr{11-0}; // imm12
1798 def rs : AI2ldst<0b011, 0, isByte, (outs),
1799 (ins GPRnopc:$Rt, ldst_so_reg:$shift),
1800 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1801 [(opnode GPRnopc:$Rt, ldst_so_reg:$shift)]> {
1804 let shift{4} = 0; // Inst{4} = 0
1805 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1806 let Inst{19-16} = shift{16-13}; // Rn
1807 let Inst{15-12} = Rt;
1808 let Inst{11-0} = shift{11-0};
1813 //===----------------------------------------------------------------------===//
1815 //===----------------------------------------------------------------------===//
1817 //===----------------------------------------------------------------------===//
1818 // Miscellaneous Instructions.
1821 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
1822 /// the function. The first operand is the ID# for this instruction, the second
1823 /// is the index into the MachineConstantPool that this is, the third is the
1824 /// size in bytes of this constant pool entry.
1825 let hasSideEffects = 0, isNotDuplicable = 1 in
1826 def CONSTPOOL_ENTRY :
1827 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1828 i32imm:$size), NoItinerary, []>;
1830 // FIXME: Marking these as hasSideEffects is necessary to prevent machine DCE
1831 // from removing one half of the matched pairs. That breaks PEI, which assumes
1832 // these will always be in pairs, and asserts if it finds otherwise. Better way?
1833 let Defs = [SP], Uses = [SP], hasSideEffects = 1 in {
1834 def ADJCALLSTACKUP :
1835 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary,
1836 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
1838 def ADJCALLSTACKDOWN :
1839 PseudoInst<(outs), (ins i32imm:$amt, pred:$p), NoItinerary,
1840 [(ARMcallseq_start timm:$amt)]>;
1843 def HINT : AI<(outs), (ins imm0_239:$imm), MiscFrm, NoItinerary,
1844 "hint", "\t$imm", [(int_arm_hint imm0_239:$imm)]>,
1845 Requires<[IsARM, HasV6]> {
1847 let Inst{27-8} = 0b00110010000011110000;
1848 let Inst{7-0} = imm;
1851 def : InstAlias<"nop$p", (HINT 0, pred:$p)>, Requires<[IsARM, HasV6K]>;
1852 def : InstAlias<"yield$p", (HINT 1, pred:$p)>, Requires<[IsARM, HasV6K]>;
1853 def : InstAlias<"wfe$p", (HINT 2, pred:$p)>, Requires<[IsARM, HasV6K]>;
1854 def : InstAlias<"wfi$p", (HINT 3, pred:$p)>, Requires<[IsARM, HasV6K]>;
1855 def : InstAlias<"sev$p", (HINT 4, pred:$p)>, Requires<[IsARM, HasV6K]>;
1856 def : InstAlias<"sevl$p", (HINT 5, pred:$p)>, Requires<[IsARM, HasV8]>;
1858 def SEL : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, NoItinerary, "sel",
1859 "\t$Rd, $Rn, $Rm", []>, Requires<[IsARM, HasV6]> {
1864 let Inst{15-12} = Rd;
1865 let Inst{19-16} = Rn;
1866 let Inst{27-20} = 0b01101000;
1867 let Inst{7-4} = 0b1011;
1868 let Inst{11-8} = 0b1111;
1869 let Unpredictable{11-8} = 0b1111;
1872 // The 16-bit operand $val can be used by a debugger to store more information
1873 // about the breakpoint.
1874 def BKPT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
1875 "bkpt", "\t$val", []>, Requires<[IsARM]> {
1877 let Inst{3-0} = val{3-0};
1878 let Inst{19-8} = val{15-4};
1879 let Inst{27-20} = 0b00010010;
1880 let Inst{31-28} = 0xe; // AL
1881 let Inst{7-4} = 0b0111;
1883 // default immediate for breakpoint mnemonic
1884 def : InstAlias<"bkpt", (BKPT 0)>, Requires<[IsARM]>;
1886 def HLT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
1887 "hlt", "\t$val", []>, Requires<[IsARM, HasV8]> {
1889 let Inst{3-0} = val{3-0};
1890 let Inst{19-8} = val{15-4};
1891 let Inst{27-20} = 0b00010000;
1892 let Inst{31-28} = 0xe; // AL
1893 let Inst{7-4} = 0b0111;
1896 // Change Processor State
1897 // FIXME: We should use InstAlias to handle the optional operands.
1898 class CPS<dag iops, string asm_ops>
1899 : AXI<(outs), iops, MiscFrm, NoItinerary, !strconcat("cps", asm_ops),
1900 []>, Requires<[IsARM]> {
1906 let Inst{31-28} = 0b1111;
1907 let Inst{27-20} = 0b00010000;
1908 let Inst{19-18} = imod;
1909 let Inst{17} = M; // Enabled if mode is set;
1910 let Inst{16-9} = 0b00000000;
1911 let Inst{8-6} = iflags;
1913 let Inst{4-0} = mode;
1916 let DecoderMethod = "DecodeCPSInstruction" in {
1918 def CPS3p : CPS<(ins imod_op:$imod, iflags_op:$iflags, imm0_31:$mode),
1919 "$imod\t$iflags, $mode">;
1920 let mode = 0, M = 0 in
1921 def CPS2p : CPS<(ins imod_op:$imod, iflags_op:$iflags), "$imod\t$iflags">;
1923 let imod = 0, iflags = 0, M = 1 in
1924 def CPS1p : CPS<(ins imm0_31:$mode), "\t$mode">;
1927 // Preload signals the memory system of possible future data/instruction access.
1928 multiclass APreLoad<bits<1> read, bits<1> data, string opc> {
1930 def i12 : AXIM<(outs), (ins addrmode_imm12:$addr), AddrMode_i12, MiscFrm,
1931 IIC_Preload, !strconcat(opc, "\t$addr"),
1932 [(ARMPreload addrmode_imm12:$addr, (i32 read), (i32 data))]>,
1933 Sched<[WritePreLd]> {
1936 let Inst{31-26} = 0b111101;
1937 let Inst{25} = 0; // 0 for immediate form
1938 let Inst{24} = data;
1939 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1940 let Inst{22} = read;
1941 let Inst{21-20} = 0b01;
1942 let Inst{19-16} = addr{16-13}; // Rn
1943 let Inst{15-12} = 0b1111;
1944 let Inst{11-0} = addr{11-0}; // imm12
1947 def rs : AXI<(outs), (ins ldst_so_reg:$shift), MiscFrm, IIC_Preload,
1948 !strconcat(opc, "\t$shift"),
1949 [(ARMPreload ldst_so_reg:$shift, (i32 read), (i32 data))]>,
1950 Sched<[WritePreLd]> {
1952 let Inst{31-26} = 0b111101;
1953 let Inst{25} = 1; // 1 for register form
1954 let Inst{24} = data;
1955 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1956 let Inst{22} = read;
1957 let Inst{21-20} = 0b01;
1958 let Inst{19-16} = shift{16-13}; // Rn
1959 let Inst{15-12} = 0b1111;
1960 let Inst{11-0} = shift{11-0};
1965 defm PLD : APreLoad<1, 1, "pld">, Requires<[IsARM]>;
1966 defm PLDW : APreLoad<0, 1, "pldw">, Requires<[IsARM,HasV7,HasMP]>;
1967 defm PLI : APreLoad<1, 0, "pli">, Requires<[IsARM,HasV7]>;
1969 def SETEND : AXI<(outs), (ins setend_op:$end), MiscFrm, NoItinerary,
1970 "setend\t$end", []>, Requires<[IsARM]>, Deprecated<HasV8Ops> {
1972 let Inst{31-10} = 0b1111000100000001000000;
1977 def DBG : AI<(outs), (ins imm0_15:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt",
1978 [(int_arm_dbg imm0_15:$opt)]>, Requires<[IsARM, HasV7]> {
1980 let Inst{27-4} = 0b001100100000111100001111;
1981 let Inst{3-0} = opt;
1984 // A8.8.247 UDF - Undefined (Encoding A1)
1985 def UDF : AInoP<(outs), (ins imm0_65535:$imm16), MiscFrm, NoItinerary,
1986 "udf", "\t$imm16", [(int_arm_undefined imm0_65535:$imm16)]> {
1988 let Inst{31-28} = 0b1110; // AL
1989 let Inst{27-25} = 0b011;
1990 let Inst{24-20} = 0b11111;
1991 let Inst{19-8} = imm16{15-4};
1992 let Inst{7-4} = 0b1111;
1993 let Inst{3-0} = imm16{3-0};
1997 * A5.4 Permanently UNDEFINED instructions.
1999 * For most targets use UDF #65006, for which the OS will generate SIGTRAP.
2000 * Other UDF encodings generate SIGILL.
2002 * NaCl's OS instead chooses an ARM UDF encoding that's also a UDF in Thumb.
2004 * 1110 0111 1111 iiii iiii iiii 1111 iiii
2006 * 1101 1110 iiii iiii
2007 * It uses the following encoding:
2008 * 1110 0111 1111 1110 1101 1110 1111 0000
2009 * - In ARM: UDF #60896;
2010 * - In Thumb: UDF #254 followed by a branch-to-self.
2012 let isBarrier = 1, isTerminator = 1 in
2013 def TRAPNaCl : AXI<(outs), (ins), MiscFrm, NoItinerary,
2015 Requires<[IsARM,UseNaClTrap]> {
2016 let Inst = 0xe7fedef0;
2018 let isBarrier = 1, isTerminator = 1 in
2019 def TRAP : AXI<(outs), (ins), MiscFrm, NoItinerary,
2021 Requires<[IsARM,DontUseNaClTrap]> {
2022 let Inst = 0xe7ffdefe;
2025 // Address computation and loads and stores in PIC mode.
2026 let isNotDuplicable = 1 in {
2027 def PICADD : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
2029 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>,
2030 Sched<[WriteALU, ReadALU]>;
2032 let AddedComplexity = 10 in {
2033 def PICLDR : ARMPseudoInst<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
2035 [(set GPR:$dst, (load addrmodepc:$addr))]>;
2037 def PICLDRH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2039 [(set GPR:$Rt, (zextloadi16 addrmodepc:$addr))]>;
2041 def PICLDRB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2043 [(set GPR:$Rt, (zextloadi8 addrmodepc:$addr))]>;
2045 def PICLDRSH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2047 [(set GPR:$Rt, (sextloadi16 addrmodepc:$addr))]>;
2049 def PICLDRSB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2051 [(set GPR:$Rt, (sextloadi8 addrmodepc:$addr))]>;
2053 let AddedComplexity = 10 in {
2054 def PICSTR : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2055 4, IIC_iStore_r, [(store GPR:$src, addrmodepc:$addr)]>;
2057 def PICSTRH : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2058 4, IIC_iStore_bh_r, [(truncstorei16 GPR:$src,
2059 addrmodepc:$addr)]>;
2061 def PICSTRB : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2062 4, IIC_iStore_bh_r, [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
2064 } // isNotDuplicable = 1
2067 // LEApcrel - Load a pc-relative address into a register without offending the
2069 let hasSideEffects = 0, isReMaterializable = 1 in
2070 // The 'adr' mnemonic encodes differently if the label is before or after
2071 // the instruction. The {24-21} opcode bits are set by the fixup, as we don't
2072 // know until then which form of the instruction will be used.
2073 def ADR : AI1<{0,?,?,0}, (outs GPR:$Rd), (ins adrlabel:$label),
2074 MiscFrm, IIC_iALUi, "adr", "\t$Rd, $label", []>,
2075 Sched<[WriteALU, ReadALU]> {
2078 let Inst{27-25} = 0b001;
2080 let Inst{23-22} = label{13-12};
2083 let Inst{19-16} = 0b1111;
2084 let Inst{15-12} = Rd;
2085 let Inst{11-0} = label{11-0};
2088 let hasSideEffects = 1 in {
2089 def LEApcrel : ARMPseudoInst<(outs GPR:$Rd), (ins i32imm:$label, pred:$p),
2090 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
2092 def LEApcrelJT : ARMPseudoInst<(outs GPR:$Rd),
2093 (ins i32imm:$label, nohash_imm:$id, pred:$p),
2094 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
2097 //===----------------------------------------------------------------------===//
2098 // Control Flow Instructions.
2101 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
2103 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
2104 "bx", "\tlr", [(ARMretflag)]>,
2105 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2106 let Inst{27-0} = 0b0001001011111111111100011110;
2110 def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br,
2111 "mov", "\tpc, lr", [(ARMretflag)]>,
2112 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]> {
2113 let Inst{27-0} = 0b0001101000001111000000001110;
2116 // Exception return: N.b. doesn't set CPSR as far as we're concerned (it sets
2117 // the user-space one).
2118 def SUBS_PC_LR : ARMPseudoInst<(outs), (ins i32imm:$offset, pred:$p),
2120 [(ARMintretflag imm:$offset)]>;
2123 // Indirect branches
2124 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
2126 def BX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
2127 [(brind GPR:$dst)]>,
2128 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2130 let Inst{31-4} = 0b1110000100101111111111110001;
2131 let Inst{3-0} = dst;
2134 def BX_pred : AI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br,
2135 "bx", "\t$dst", [/* pattern left blank */]>,
2136 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2138 let Inst{27-4} = 0b000100101111111111110001;
2139 let Inst{3-0} = dst;
2143 // SP is marked as a use to prevent stack-pointer assignments that appear
2144 // immediately before calls from potentially appearing dead.
2146 // FIXME: Do we really need a non-predicated version? If so, it should
2147 // at least be a pseudo instruction expanding to the predicated version
2148 // at MC lowering time.
2149 Defs = [LR], Uses = [SP] in {
2150 def BL : ABXI<0b1011, (outs), (ins bl_target:$func),
2151 IIC_Br, "bl\t$func",
2152 [(ARMcall tglobaladdr:$func)]>,
2153 Requires<[IsARM]>, Sched<[WriteBrL]> {
2154 let Inst{31-28} = 0b1110;
2156 let Inst{23-0} = func;
2157 let DecoderMethod = "DecodeBranchImmInstruction";
2160 def BL_pred : ABI<0b1011, (outs), (ins bl_target:$func),
2161 IIC_Br, "bl", "\t$func",
2162 [(ARMcall_pred tglobaladdr:$func)]>,
2163 Requires<[IsARM]>, Sched<[WriteBrL]> {
2165 let Inst{23-0} = func;
2166 let DecoderMethod = "DecodeBranchImmInstruction";
2170 def BLX : AXI<(outs), (ins GPR:$func), BrMiscFrm,
2171 IIC_Br, "blx\t$func",
2172 [(ARMcall GPR:$func)]>,
2173 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2175 let Inst{31-4} = 0b1110000100101111111111110011;
2176 let Inst{3-0} = func;
2179 def BLX_pred : AI<(outs), (ins GPR:$func), BrMiscFrm,
2180 IIC_Br, "blx", "\t$func",
2181 [(ARMcall_pred GPR:$func)]>,
2182 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2184 let Inst{27-4} = 0b000100101111111111110011;
2185 let Inst{3-0} = func;
2189 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
2190 def BX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
2191 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
2192 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]>;
2195 def BMOVPCRX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
2196 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
2197 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
2199 // mov lr, pc; b if callee is marked noreturn to avoid confusing the
2200 // return stack predictor.
2201 def BMOVPCB_CALL : ARMPseudoInst<(outs), (ins bl_target:$func),
2202 8, IIC_Br, [(ARMcall_nolink tglobaladdr:$func)]>,
2203 Requires<[IsARM]>, Sched<[WriteBr]>;
2206 let isBranch = 1, isTerminator = 1 in {
2207 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
2208 // a two-value operand where a dag node expects two operands. :(
2209 def Bcc : ABI<0b1010, (outs), (ins br_target:$target),
2210 IIC_Br, "b", "\t$target",
2211 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>,
2214 let Inst{23-0} = target;
2215 let DecoderMethod = "DecodeBranchImmInstruction";
2218 let isBarrier = 1 in {
2219 // B is "predicable" since it's just a Bcc with an 'always' condition.
2220 let isPredicable = 1 in
2221 // FIXME: We shouldn't need this pseudo at all. Just using Bcc directly
2222 // should be sufficient.
2223 // FIXME: Is B really a Barrier? That doesn't seem right.
2224 def B : ARMPseudoExpand<(outs), (ins br_target:$target), 4, IIC_Br,
2225 [(br bb:$target)], (Bcc br_target:$target, (ops 14, zero_reg))>,
2228 let isNotDuplicable = 1, isIndirectBranch = 1 in {
2229 def BR_JTr : ARMPseudoInst<(outs),
2230 (ins GPR:$target, i32imm:$jt, i32imm:$id),
2232 [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]>,
2234 // FIXME: This shouldn't use the generic "addrmode2," but rather be split
2235 // into i12 and rs suffixed versions.
2236 def BR_JTm : ARMPseudoInst<(outs),
2237 (ins addrmode2:$target, i32imm:$jt, i32imm:$id),
2239 [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
2240 imm:$id)]>, Sched<[WriteBrTbl]>;
2241 def BR_JTadd : ARMPseudoInst<(outs),
2242 (ins GPR:$target, GPR:$idx, i32imm:$jt, i32imm:$id),
2244 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
2245 imm:$id)]>, Sched<[WriteBrTbl]>;
2246 } // isNotDuplicable = 1, isIndirectBranch = 1
2252 def BLXi : AXI<(outs), (ins blx_target:$target), BrMiscFrm, NoItinerary,
2253 "blx\t$target", []>,
2254 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2255 let Inst{31-25} = 0b1111101;
2257 let Inst{23-0} = target{24-1};
2258 let Inst{24} = target{0};
2262 // Branch and Exchange Jazelle
2263 def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func",
2264 [/* pattern left blank */]>, Sched<[WriteBr]> {
2266 let Inst{23-20} = 0b0010;
2267 let Inst{19-8} = 0xfff;
2268 let Inst{7-4} = 0b0010;
2269 let Inst{3-0} = func;
2275 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in {
2276 def TCRETURNdi : PseudoInst<(outs), (ins i32imm:$dst), IIC_Br, []>,
2279 def TCRETURNri : PseudoInst<(outs), (ins tcGPR:$dst), IIC_Br, []>,
2282 def TAILJMPd : ARMPseudoExpand<(outs), (ins br_target:$dst),
2284 (Bcc br_target:$dst, (ops 14, zero_reg))>,
2285 Requires<[IsARM]>, Sched<[WriteBr]>;
2287 def TAILJMPr : ARMPseudoExpand<(outs), (ins tcGPR:$dst),
2289 (BX GPR:$dst)>, Sched<[WriteBr]>,
2293 // Secure Monitor Call is a system instruction.
2294 def SMC : ABI<0b0001, (outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt",
2295 []>, Requires<[IsARM, HasTrustZone]> {
2297 let Inst{23-4} = 0b01100000000000000111;
2298 let Inst{3-0} = opt;
2301 // Supervisor Call (Software Interrupt)
2302 let isCall = 1, Uses = [SP] in {
2303 def SVC : ABI<0b1111, (outs), (ins imm24b:$svc), IIC_Br, "svc", "\t$svc", []>,
2306 let Inst{23-0} = svc;
2310 // Store Return State
2311 class SRSI<bit wb, string asm>
2312 : XI<(outs), (ins imm0_31:$mode), AddrModeNone, 4, IndexModeNone, BrFrm,
2313 NoItinerary, asm, "", []> {
2315 let Inst{31-28} = 0b1111;
2316 let Inst{27-25} = 0b100;
2320 let Inst{19-16} = 0b1101; // SP
2321 let Inst{15-5} = 0b00000101000;
2322 let Inst{4-0} = mode;
2325 def SRSDA : SRSI<0, "srsda\tsp, $mode"> {
2326 let Inst{24-23} = 0;
2328 def SRSDA_UPD : SRSI<1, "srsda\tsp!, $mode"> {
2329 let Inst{24-23} = 0;
2331 def SRSDB : SRSI<0, "srsdb\tsp, $mode"> {
2332 let Inst{24-23} = 0b10;
2334 def SRSDB_UPD : SRSI<1, "srsdb\tsp!, $mode"> {
2335 let Inst{24-23} = 0b10;
2337 def SRSIA : SRSI<0, "srsia\tsp, $mode"> {
2338 let Inst{24-23} = 0b01;
2340 def SRSIA_UPD : SRSI<1, "srsia\tsp!, $mode"> {
2341 let Inst{24-23} = 0b01;
2343 def SRSIB : SRSI<0, "srsib\tsp, $mode"> {
2344 let Inst{24-23} = 0b11;
2346 def SRSIB_UPD : SRSI<1, "srsib\tsp!, $mode"> {
2347 let Inst{24-23} = 0b11;
2350 def : ARMInstAlias<"srsda $mode", (SRSDA imm0_31:$mode)>;
2351 def : ARMInstAlias<"srsda $mode!", (SRSDA_UPD imm0_31:$mode)>;
2353 def : ARMInstAlias<"srsdb $mode", (SRSDB imm0_31:$mode)>;
2354 def : ARMInstAlias<"srsdb $mode!", (SRSDB_UPD imm0_31:$mode)>;
2356 def : ARMInstAlias<"srsia $mode", (SRSIA imm0_31:$mode)>;
2357 def : ARMInstAlias<"srsia $mode!", (SRSIA_UPD imm0_31:$mode)>;
2359 def : ARMInstAlias<"srsib $mode", (SRSIB imm0_31:$mode)>;
2360 def : ARMInstAlias<"srsib $mode!", (SRSIB_UPD imm0_31:$mode)>;
2362 // Return From Exception
2363 class RFEI<bit wb, string asm>
2364 : XI<(outs), (ins GPR:$Rn), AddrModeNone, 4, IndexModeNone, BrFrm,
2365 NoItinerary, asm, "", []> {
2367 let Inst{31-28} = 0b1111;
2368 let Inst{27-25} = 0b100;
2372 let Inst{19-16} = Rn;
2373 let Inst{15-0} = 0xa00;
2376 def RFEDA : RFEI<0, "rfeda\t$Rn"> {
2377 let Inst{24-23} = 0;
2379 def RFEDA_UPD : RFEI<1, "rfeda\t$Rn!"> {
2380 let Inst{24-23} = 0;
2382 def RFEDB : RFEI<0, "rfedb\t$Rn"> {
2383 let Inst{24-23} = 0b10;
2385 def RFEDB_UPD : RFEI<1, "rfedb\t$Rn!"> {
2386 let Inst{24-23} = 0b10;
2388 def RFEIA : RFEI<0, "rfeia\t$Rn"> {
2389 let Inst{24-23} = 0b01;
2391 def RFEIA_UPD : RFEI<1, "rfeia\t$Rn!"> {
2392 let Inst{24-23} = 0b01;
2394 def RFEIB : RFEI<0, "rfeib\t$Rn"> {
2395 let Inst{24-23} = 0b11;
2397 def RFEIB_UPD : RFEI<1, "rfeib\t$Rn!"> {
2398 let Inst{24-23} = 0b11;
2401 // Hypervisor Call is a system instruction
2403 def HVC : AInoP< (outs), (ins imm0_65535:$imm), BrFrm, NoItinerary,
2404 "hvc", "\t$imm", []>,
2405 Requires<[IsARM, HasVirtualization]> {
2408 // Even though HVC isn't predicable, it's encoding includes a condition field.
2409 // The instruction is undefined if the condition field is 0xf otherwise it is
2410 // unpredictable if it isn't condition AL (0xe).
2411 let Inst{31-28} = 0b1110;
2412 let Unpredictable{31-28} = 0b1111;
2413 let Inst{27-24} = 0b0001;
2414 let Inst{23-20} = 0b0100;
2415 let Inst{19-8} = imm{15-4};
2416 let Inst{7-4} = 0b0111;
2417 let Inst{3-0} = imm{3-0};
2421 // Return from exception in Hypervisor mode.
2422 let isReturn = 1, isBarrier = 1, isTerminator = 1, Defs = [PC] in
2423 def ERET : ABI<0b0001, (outs), (ins), NoItinerary, "eret", "", []>,
2424 Requires<[IsARM, HasVirtualization]> {
2425 let Inst{23-0} = 0b011000000000000001101110;
2428 //===----------------------------------------------------------------------===//
2429 // Load / Store Instructions.
2435 defm LDR : AI_ldr1<0, "ldr", IIC_iLoad_r, IIC_iLoad_si,
2436 UnOpFrag<(load node:$Src)>>;
2437 defm LDRB : AI_ldr1nopc<1, "ldrb", IIC_iLoad_bh_r, IIC_iLoad_bh_si,
2438 UnOpFrag<(zextloadi8 node:$Src)>>;
2439 defm STR : AI_str1<0, "str", IIC_iStore_r, IIC_iStore_si,
2440 BinOpFrag<(store node:$LHS, node:$RHS)>>;
2441 defm STRB : AI_str1nopc<1, "strb", IIC_iStore_bh_r, IIC_iStore_bh_si,
2442 BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
2444 // Special LDR for loads from non-pc-relative constpools.
2445 let canFoldAsLoad = 1, mayLoad = 1, hasSideEffects = 0,
2446 isReMaterializable = 1, isCodeGenOnly = 1 in
2447 def LDRcp : AI2ldst<0b010, 1, 0, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
2448 AddrMode_i12, LdFrm, IIC_iLoad_r, "ldr", "\t$Rt, $addr",
2452 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2453 let Inst{19-16} = 0b1111;
2454 let Inst{15-12} = Rt;
2455 let Inst{11-0} = addr{11-0}; // imm12
2458 // Loads with zero extension
2459 def LDRH : AI3ld<0b1011, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2460 IIC_iLoad_bh_r, "ldrh", "\t$Rt, $addr",
2461 [(set GPR:$Rt, (zextloadi16 addrmode3:$addr))]>;
2463 // Loads with sign extension
2464 def LDRSH : AI3ld<0b1111, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2465 IIC_iLoad_bh_r, "ldrsh", "\t$Rt, $addr",
2466 [(set GPR:$Rt, (sextloadi16 addrmode3:$addr))]>;
2468 def LDRSB : AI3ld<0b1101, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2469 IIC_iLoad_bh_r, "ldrsb", "\t$Rt, $addr",
2470 [(set GPR:$Rt, (sextloadi8 addrmode3:$addr))]>;
2472 let mayLoad = 1, hasSideEffects = 0, hasExtraDefRegAllocReq = 1 in {
2474 def LDRD : AI3ld<0b1101, 0, (outs GPR:$Rt, GPR:$Rt2), (ins addrmode3:$addr),
2475 LdMiscFrm, IIC_iLoad_d_r, "ldrd", "\t$Rt, $Rt2, $addr", []>,
2476 Requires<[IsARM, HasV5TE]>;
2479 def LDA : AIldracq<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2480 NoItinerary, "lda", "\t$Rt, $addr", []>;
2481 def LDAB : AIldracq<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2482 NoItinerary, "ldab", "\t$Rt, $addr", []>;
2483 def LDAH : AIldracq<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2484 NoItinerary, "ldah", "\t$Rt, $addr", []>;
2487 multiclass AI2_ldridx<bit isByte, string opc,
2488 InstrItinClass iii, InstrItinClass iir> {
2489 def _PRE_IMM : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2490 (ins addrmode_imm12_pre:$addr), IndexModePre, LdFrm, iii,
2491 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2494 let Inst{23} = addr{12};
2495 let Inst{19-16} = addr{16-13};
2496 let Inst{11-0} = addr{11-0};
2497 let DecoderMethod = "DecodeLDRPreImm";
2500 def _PRE_REG : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2501 (ins ldst_so_reg:$addr), IndexModePre, LdFrm, iir,
2502 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2505 let Inst{23} = addr{12};
2506 let Inst{19-16} = addr{16-13};
2507 let Inst{11-0} = addr{11-0};
2509 let DecoderMethod = "DecodeLDRPreReg";
2512 def _POST_REG : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2513 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2514 IndexModePost, LdFrm, iir,
2515 opc, "\t$Rt, $addr, $offset",
2516 "$addr.base = $Rn_wb", []> {
2522 let Inst{23} = offset{12};
2523 let Inst{19-16} = addr;
2524 let Inst{11-0} = offset{11-0};
2527 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2530 def _POST_IMM : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2531 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2532 IndexModePost, LdFrm, iii,
2533 opc, "\t$Rt, $addr, $offset",
2534 "$addr.base = $Rn_wb", []> {
2540 let Inst{23} = offset{12};
2541 let Inst{19-16} = addr;
2542 let Inst{11-0} = offset{11-0};
2544 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2549 let mayLoad = 1, hasSideEffects = 0 in {
2550 // FIXME: for LDR_PRE_REG etc. the itineray should be either IIC_iLoad_ru or
2551 // IIC_iLoad_siu depending on whether it the offset register is shifted.
2552 defm LDR : AI2_ldridx<0, "ldr", IIC_iLoad_iu, IIC_iLoad_ru>;
2553 defm LDRB : AI2_ldridx<1, "ldrb", IIC_iLoad_bh_iu, IIC_iLoad_bh_ru>;
2556 multiclass AI3_ldridx<bits<4> op, string opc, InstrItinClass itin> {
2557 def _PRE : AI3ldstidx<op, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2558 (ins addrmode3_pre:$addr), IndexModePre,
2560 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2562 let Inst{23} = addr{8}; // U bit
2563 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2564 let Inst{19-16} = addr{12-9}; // Rn
2565 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2566 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2567 let DecoderMethod = "DecodeAddrMode3Instruction";
2569 def _POST : AI3ldstidx<op, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2570 (ins addr_offset_none:$addr, am3offset:$offset),
2571 IndexModePost, LdMiscFrm, itin,
2572 opc, "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2576 let Inst{23} = offset{8}; // U bit
2577 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2578 let Inst{19-16} = addr;
2579 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2580 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2581 let DecoderMethod = "DecodeAddrMode3Instruction";
2585 let mayLoad = 1, hasSideEffects = 0 in {
2586 defm LDRH : AI3_ldridx<0b1011, "ldrh", IIC_iLoad_bh_ru>;
2587 defm LDRSH : AI3_ldridx<0b1111, "ldrsh", IIC_iLoad_bh_ru>;
2588 defm LDRSB : AI3_ldridx<0b1101, "ldrsb", IIC_iLoad_bh_ru>;
2589 let hasExtraDefRegAllocReq = 1 in {
2590 def LDRD_PRE : AI3ldstidx<0b1101, 0, 1, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2591 (ins addrmode3_pre:$addr), IndexModePre,
2592 LdMiscFrm, IIC_iLoad_d_ru,
2593 "ldrd", "\t$Rt, $Rt2, $addr!",
2594 "$addr.base = $Rn_wb", []> {
2596 let Inst{23} = addr{8}; // U bit
2597 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2598 let Inst{19-16} = addr{12-9}; // Rn
2599 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2600 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2601 let DecoderMethod = "DecodeAddrMode3Instruction";
2603 def LDRD_POST: AI3ldstidx<0b1101, 0, 0, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2604 (ins addr_offset_none:$addr, am3offset:$offset),
2605 IndexModePost, LdMiscFrm, IIC_iLoad_d_ru,
2606 "ldrd", "\t$Rt, $Rt2, $addr, $offset",
2607 "$addr.base = $Rn_wb", []> {
2610 let Inst{23} = offset{8}; // U bit
2611 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2612 let Inst{19-16} = addr;
2613 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2614 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2615 let DecoderMethod = "DecodeAddrMode3Instruction";
2617 } // hasExtraDefRegAllocReq = 1
2618 } // mayLoad = 1, hasSideEffects = 0
2620 // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT.
2621 let mayLoad = 1, hasSideEffects = 0 in {
2622 def LDRT_POST_REG : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2623 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2624 IndexModePost, LdFrm, IIC_iLoad_ru,
2625 "ldrt", "\t$Rt, $addr, $offset",
2626 "$addr.base = $Rn_wb", []> {
2632 let Inst{23} = offset{12};
2633 let Inst{21} = 1; // overwrite
2634 let Inst{19-16} = addr;
2635 let Inst{11-5} = offset{11-5};
2637 let Inst{3-0} = offset{3-0};
2638 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2642 : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2643 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2644 IndexModePost, LdFrm, IIC_iLoad_ru,
2645 "ldrt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2651 let Inst{23} = offset{12};
2652 let Inst{21} = 1; // overwrite
2653 let Inst{19-16} = addr;
2654 let Inst{11-0} = offset{11-0};
2655 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2658 def LDRBT_POST_REG : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2659 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2660 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2661 "ldrbt", "\t$Rt, $addr, $offset",
2662 "$addr.base = $Rn_wb", []> {
2668 let Inst{23} = offset{12};
2669 let Inst{21} = 1; // overwrite
2670 let Inst{19-16} = addr;
2671 let Inst{11-5} = offset{11-5};
2673 let Inst{3-0} = offset{3-0};
2674 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2678 : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2679 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2680 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2681 "ldrbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2687 let Inst{23} = offset{12};
2688 let Inst{21} = 1; // overwrite
2689 let Inst{19-16} = addr;
2690 let Inst{11-0} = offset{11-0};
2691 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2694 multiclass AI3ldrT<bits<4> op, string opc> {
2695 def i : AI3ldstidxT<op, 1, (outs GPR:$Rt, GPR:$base_wb),
2696 (ins addr_offset_none:$addr, postidx_imm8:$offset),
2697 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2698 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2700 let Inst{23} = offset{8};
2702 let Inst{11-8} = offset{7-4};
2703 let Inst{3-0} = offset{3-0};
2705 def r : AI3ldstidxT<op, 1, (outs GPRnopc:$Rt, GPRnopc:$base_wb),
2706 (ins addr_offset_none:$addr, postidx_reg:$Rm),
2707 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2708 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2710 let Inst{23} = Rm{4};
2713 let Unpredictable{11-8} = 0b1111;
2714 let Inst{3-0} = Rm{3-0};
2715 let DecoderMethod = "DecodeLDR";
2719 defm LDRSBT : AI3ldrT<0b1101, "ldrsbt">;
2720 defm LDRHT : AI3ldrT<0b1011, "ldrht">;
2721 defm LDRSHT : AI3ldrT<0b1111, "ldrsht">;
2725 : ARMAsmPseudo<"ldrt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q),
2729 : ARMAsmPseudo<"ldrbt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q),
2734 // Stores with truncate
2735 def STRH : AI3str<0b1011, (outs), (ins GPR:$Rt, addrmode3:$addr), StMiscFrm,
2736 IIC_iStore_bh_r, "strh", "\t$Rt, $addr",
2737 [(truncstorei16 GPR:$Rt, addrmode3:$addr)]>;
2740 let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
2741 def STRD : AI3str<0b1111, (outs), (ins GPR:$Rt, GPR:$Rt2, addrmode3:$addr),
2742 StMiscFrm, IIC_iStore_d_r, "strd", "\t$Rt, $Rt2, $addr", []>,
2743 Requires<[IsARM, HasV5TE]> {
2749 multiclass AI2_stridx<bit isByte, string opc,
2750 InstrItinClass iii, InstrItinClass iir> {
2751 def _PRE_IMM : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2752 (ins GPR:$Rt, addrmode_imm12_pre:$addr), IndexModePre,
2754 opc, "\t$Rt, $addr!",
2755 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2758 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2759 let Inst{19-16} = addr{16-13}; // Rn
2760 let Inst{11-0} = addr{11-0}; // imm12
2761 let DecoderMethod = "DecodeSTRPreImm";
2764 def _PRE_REG : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2765 (ins GPR:$Rt, ldst_so_reg:$addr),
2766 IndexModePre, StFrm, iir,
2767 opc, "\t$Rt, $addr!",
2768 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2771 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2772 let Inst{19-16} = addr{16-13}; // Rn
2773 let Inst{11-0} = addr{11-0};
2774 let Inst{4} = 0; // Inst{4} = 0
2775 let DecoderMethod = "DecodeSTRPreReg";
2777 def _POST_REG : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2778 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2779 IndexModePost, StFrm, iir,
2780 opc, "\t$Rt, $addr, $offset",
2781 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2787 let Inst{23} = offset{12};
2788 let Inst{19-16} = addr;
2789 let Inst{11-0} = offset{11-0};
2792 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2795 def _POST_IMM : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2796 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2797 IndexModePost, StFrm, iii,
2798 opc, "\t$Rt, $addr, $offset",
2799 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2805 let Inst{23} = offset{12};
2806 let Inst{19-16} = addr;
2807 let Inst{11-0} = offset{11-0};
2809 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2813 let mayStore = 1, hasSideEffects = 0 in {
2814 // FIXME: for STR_PRE_REG etc. the itineray should be either IIC_iStore_ru or
2815 // IIC_iStore_siu depending on whether it the offset register is shifted.
2816 defm STR : AI2_stridx<0, "str", IIC_iStore_iu, IIC_iStore_ru>;
2817 defm STRB : AI2_stridx<1, "strb", IIC_iStore_bh_iu, IIC_iStore_bh_ru>;
2820 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2821 am2offset_reg:$offset),
2822 (STR_POST_REG GPR:$Rt, addr_offset_none:$addr,
2823 am2offset_reg:$offset)>;
2824 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2825 am2offset_imm:$offset),
2826 (STR_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2827 am2offset_imm:$offset)>;
2828 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2829 am2offset_reg:$offset),
2830 (STRB_POST_REG GPR:$Rt, addr_offset_none:$addr,
2831 am2offset_reg:$offset)>;
2832 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2833 am2offset_imm:$offset),
2834 (STRB_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2835 am2offset_imm:$offset)>;
2837 // Pseudo-instructions for pattern matching the pre-indexed stores. We can't
2838 // put the patterns on the instruction definitions directly as ISel wants
2839 // the address base and offset to be separate operands, not a single
2840 // complex operand like we represent the instructions themselves. The
2841 // pseudos map between the two.
2842 let usesCustomInserter = 1,
2843 Constraints = "$Rn = $Rn_wb,@earlyclobber $Rn_wb" in {
2844 def STRi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2845 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2848 (pre_store GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2849 def STRr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2850 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2853 (pre_store GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2854 def STRBi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2855 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2858 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2859 def STRBr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2860 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2863 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2864 def STRH_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2865 (ins GPR:$Rt, GPR:$Rn, am3offset:$offset, pred:$p),
2868 (pre_truncsti16 GPR:$Rt, GPR:$Rn, am3offset:$offset))]>;
2873 def STRH_PRE : AI3ldstidx<0b1011, 0, 1, (outs GPR:$Rn_wb),
2874 (ins GPR:$Rt, addrmode3_pre:$addr), IndexModePre,
2875 StMiscFrm, IIC_iStore_bh_ru,
2876 "strh", "\t$Rt, $addr!",
2877 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2879 let Inst{23} = addr{8}; // U bit
2880 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2881 let Inst{19-16} = addr{12-9}; // Rn
2882 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2883 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2884 let DecoderMethod = "DecodeAddrMode3Instruction";
2887 def STRH_POST : AI3ldstidx<0b1011, 0, 0, (outs GPR:$Rn_wb),
2888 (ins GPR:$Rt, addr_offset_none:$addr, am3offset:$offset),
2889 IndexModePost, StMiscFrm, IIC_iStore_bh_ru,
2890 "strh", "\t$Rt, $addr, $offset",
2891 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb",
2892 [(set GPR:$Rn_wb, (post_truncsti16 GPR:$Rt,
2893 addr_offset_none:$addr,
2894 am3offset:$offset))]> {
2897 let Inst{23} = offset{8}; // U bit
2898 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2899 let Inst{19-16} = addr;
2900 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2901 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2902 let DecoderMethod = "DecodeAddrMode3Instruction";
2905 let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
2906 def STRD_PRE : AI3ldstidx<0b1111, 0, 1, (outs GPR:$Rn_wb),
2907 (ins GPR:$Rt, GPR:$Rt2, addrmode3_pre:$addr),
2908 IndexModePre, StMiscFrm, IIC_iStore_d_ru,
2909 "strd", "\t$Rt, $Rt2, $addr!",
2910 "$addr.base = $Rn_wb", []> {
2912 let Inst{23} = addr{8}; // U bit
2913 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2914 let Inst{19-16} = addr{12-9}; // Rn
2915 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2916 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2917 let DecoderMethod = "DecodeAddrMode3Instruction";
2920 def STRD_POST: AI3ldstidx<0b1111, 0, 0, (outs GPR:$Rn_wb),
2921 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr,
2923 IndexModePost, StMiscFrm, IIC_iStore_d_ru,
2924 "strd", "\t$Rt, $Rt2, $addr, $offset",
2925 "$addr.base = $Rn_wb", []> {
2928 let Inst{23} = offset{8}; // U bit
2929 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2930 let Inst{19-16} = addr;
2931 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2932 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2933 let DecoderMethod = "DecodeAddrMode3Instruction";
2935 } // mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1
2937 // STRT, STRBT, and STRHT
2939 def STRBT_POST_REG : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2940 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2941 IndexModePost, StFrm, IIC_iStore_bh_ru,
2942 "strbt", "\t$Rt, $addr, $offset",
2943 "$addr.base = $Rn_wb", []> {
2949 let Inst{23} = offset{12};
2950 let Inst{21} = 1; // overwrite
2951 let Inst{19-16} = addr;
2952 let Inst{11-5} = offset{11-5};
2954 let Inst{3-0} = offset{3-0};
2955 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2959 : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2960 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2961 IndexModePost, StFrm, IIC_iStore_bh_ru,
2962 "strbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2968 let Inst{23} = offset{12};
2969 let Inst{21} = 1; // overwrite
2970 let Inst{19-16} = addr;
2971 let Inst{11-0} = offset{11-0};
2972 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2976 : ARMAsmPseudo<"strbt${q} $Rt, $addr",
2977 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>;
2979 let mayStore = 1, hasSideEffects = 0 in {
2980 def STRT_POST_REG : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
2981 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2982 IndexModePost, StFrm, IIC_iStore_ru,
2983 "strt", "\t$Rt, $addr, $offset",
2984 "$addr.base = $Rn_wb", []> {
2990 let Inst{23} = offset{12};
2991 let Inst{21} = 1; // overwrite
2992 let Inst{19-16} = addr;
2993 let Inst{11-5} = offset{11-5};
2995 let Inst{3-0} = offset{3-0};
2996 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3000 : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
3001 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
3002 IndexModePost, StFrm, IIC_iStore_ru,
3003 "strt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
3009 let Inst{23} = offset{12};
3010 let Inst{21} = 1; // overwrite
3011 let Inst{19-16} = addr;
3012 let Inst{11-0} = offset{11-0};
3013 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3018 : ARMAsmPseudo<"strt${q} $Rt, $addr",
3019 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>;
3021 multiclass AI3strT<bits<4> op, string opc> {
3022 def i : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
3023 (ins GPR:$Rt, addr_offset_none:$addr, postidx_imm8:$offset),
3024 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
3025 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
3027 let Inst{23} = offset{8};
3029 let Inst{11-8} = offset{7-4};
3030 let Inst{3-0} = offset{3-0};
3032 def r : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
3033 (ins GPR:$Rt, addr_offset_none:$addr, postidx_reg:$Rm),
3034 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
3035 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
3037 let Inst{23} = Rm{4};
3040 let Inst{3-0} = Rm{3-0};
3045 defm STRHT : AI3strT<0b1011, "strht">;
3047 def STL : AIstrrel<0b00, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3048 NoItinerary, "stl", "\t$Rt, $addr", []>;
3049 def STLB : AIstrrel<0b10, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3050 NoItinerary, "stlb", "\t$Rt, $addr", []>;
3051 def STLH : AIstrrel<0b11, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3052 NoItinerary, "stlh", "\t$Rt, $addr", []>;
3054 //===----------------------------------------------------------------------===//
3055 // Load / store multiple Instructions.
3058 multiclass arm_ldst_mult<string asm, string sfx, bit L_bit, bit P_bit, Format f,
3059 InstrItinClass itin, InstrItinClass itin_upd> {
3060 // IA is the default, so no need for an explicit suffix on the
3061 // mnemonic here. Without it is the canonical spelling.
3063 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3064 IndexModeNone, f, itin,
3065 !strconcat(asm, "${p}\t$Rn, $regs", sfx), "", []> {
3066 let Inst{24-23} = 0b01; // Increment After
3067 let Inst{22} = P_bit;
3068 let Inst{21} = 0; // No writeback
3069 let Inst{20} = L_bit;
3072 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3073 IndexModeUpd, f, itin_upd,
3074 !strconcat(asm, "${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3075 let Inst{24-23} = 0b01; // Increment After
3076 let Inst{22} = P_bit;
3077 let Inst{21} = 1; // Writeback
3078 let Inst{20} = L_bit;
3080 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3083 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3084 IndexModeNone, f, itin,
3085 !strconcat(asm, "da${p}\t$Rn, $regs", sfx), "", []> {
3086 let Inst{24-23} = 0b00; // Decrement After
3087 let Inst{22} = P_bit;
3088 let Inst{21} = 0; // No writeback
3089 let Inst{20} = L_bit;
3092 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3093 IndexModeUpd, f, itin_upd,
3094 !strconcat(asm, "da${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3095 let Inst{24-23} = 0b00; // Decrement After
3096 let Inst{22} = P_bit;
3097 let Inst{21} = 1; // Writeback
3098 let Inst{20} = L_bit;
3100 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3103 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3104 IndexModeNone, f, itin,
3105 !strconcat(asm, "db${p}\t$Rn, $regs", sfx), "", []> {
3106 let Inst{24-23} = 0b10; // Decrement Before
3107 let Inst{22} = P_bit;
3108 let Inst{21} = 0; // No writeback
3109 let Inst{20} = L_bit;
3112 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3113 IndexModeUpd, f, itin_upd,
3114 !strconcat(asm, "db${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3115 let Inst{24-23} = 0b10; // Decrement Before
3116 let Inst{22} = P_bit;
3117 let Inst{21} = 1; // Writeback
3118 let Inst{20} = L_bit;
3120 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3123 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3124 IndexModeNone, f, itin,
3125 !strconcat(asm, "ib${p}\t$Rn, $regs", sfx), "", []> {
3126 let Inst{24-23} = 0b11; // Increment Before
3127 let Inst{22} = P_bit;
3128 let Inst{21} = 0; // No writeback
3129 let Inst{20} = L_bit;
3132 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3133 IndexModeUpd, f, itin_upd,
3134 !strconcat(asm, "ib${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3135 let Inst{24-23} = 0b11; // Increment Before
3136 let Inst{22} = P_bit;
3137 let Inst{21} = 1; // Writeback
3138 let Inst{20} = L_bit;
3140 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3144 let hasSideEffects = 0 in {
3146 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
3147 defm LDM : arm_ldst_mult<"ldm", "", 1, 0, LdStMulFrm, IIC_iLoad_m,
3148 IIC_iLoad_mu>, ComplexDeprecationPredicate<"ARMLoad">;
3150 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
3151 defm STM : arm_ldst_mult<"stm", "", 0, 0, LdStMulFrm, IIC_iStore_m,
3153 ComplexDeprecationPredicate<"ARMStore">;
3157 // FIXME: remove when we have a way to marking a MI with these properties.
3158 // FIXME: Should pc be an implicit operand like PICADD, etc?
3159 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
3160 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
3161 def LDMIA_RET : ARMPseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p,
3162 reglist:$regs, variable_ops),
3163 4, IIC_iLoad_mBr, [],
3164 (LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>,
3165 RegConstraint<"$Rn = $wb">;
3167 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
3168 defm sysLDM : arm_ldst_mult<"ldm", " ^", 1, 1, LdStMulFrm, IIC_iLoad_m,
3171 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
3172 defm sysSTM : arm_ldst_mult<"stm", " ^", 0, 1, LdStMulFrm, IIC_iStore_m,
3177 //===----------------------------------------------------------------------===//
3178 // Move Instructions.
3181 let hasSideEffects = 0 in
3182 def MOVr : AsI1<0b1101, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMOVr,
3183 "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> {
3187 let Inst{19-16} = 0b0000;
3188 let Inst{11-4} = 0b00000000;
3191 let Inst{15-12} = Rd;
3194 // A version for the smaller set of tail call registers.
3195 let hasSideEffects = 0 in
3196 def MOVr_TC : AsI1<0b1101, (outs tcGPR:$Rd), (ins tcGPR:$Rm), DPFrm,
3197 IIC_iMOVr, "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> {
3201 let Inst{11-4} = 0b00000000;
3204 let Inst{15-12} = Rd;
3207 def MOVsr : AsI1<0b1101, (outs GPRnopc:$Rd), (ins shift_so_reg_reg:$src),
3208 DPSoRegRegFrm, IIC_iMOVsr,
3209 "mov", "\t$Rd, $src",
3210 [(set GPRnopc:$Rd, shift_so_reg_reg:$src)]>, UnaryDP,
3214 let Inst{15-12} = Rd;
3215 let Inst{19-16} = 0b0000;
3216 let Inst{11-8} = src{11-8};
3218 let Inst{6-5} = src{6-5};
3220 let Inst{3-0} = src{3-0};
3224 def MOVsi : AsI1<0b1101, (outs GPR:$Rd), (ins shift_so_reg_imm:$src),
3225 DPSoRegImmFrm, IIC_iMOVsr,
3226 "mov", "\t$Rd, $src", [(set GPR:$Rd, shift_so_reg_imm:$src)]>,
3227 UnaryDP, Sched<[WriteALU]> {
3230 let Inst{15-12} = Rd;
3231 let Inst{19-16} = 0b0000;
3232 let Inst{11-5} = src{11-5};
3234 let Inst{3-0} = src{3-0};
3238 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3239 def MOVi : AsI1<0b1101, (outs GPR:$Rd), (ins mod_imm:$imm), DPFrm, IIC_iMOVi,
3240 "mov", "\t$Rd, $imm", [(set GPR:$Rd, mod_imm:$imm)]>, UnaryDP,
3245 let Inst{15-12} = Rd;
3246 let Inst{19-16} = 0b0000;
3247 let Inst{11-0} = imm;
3250 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3251 def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins imm0_65535_expr:$imm),
3253 "movw", "\t$Rd, $imm",
3254 [(set GPR:$Rd, imm0_65535:$imm)]>,
3255 Requires<[IsARM, HasV6T2]>, UnaryDP, Sched<[WriteALU]> {
3258 let Inst{15-12} = Rd;
3259 let Inst{11-0} = imm{11-0};
3260 let Inst{19-16} = imm{15-12};
3263 let DecoderMethod = "DecodeArmMOVTWInstruction";
3266 def : InstAlias<"mov${p} $Rd, $imm",
3267 (MOVi16 GPR:$Rd, imm0_65535_expr:$imm, pred:$p)>,
3270 def MOVi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
3271 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
3274 let Constraints = "$src = $Rd" in {
3275 def MOVTi16 : AI1<0b1010, (outs GPRnopc:$Rd),
3276 (ins GPR:$src, imm0_65535_expr:$imm),
3278 "movt", "\t$Rd, $imm",
3280 (or (and GPR:$src, 0xffff),
3281 lo16AllZero:$imm))]>, UnaryDP,
3282 Requires<[IsARM, HasV6T2]>, Sched<[WriteALU]> {
3285 let Inst{15-12} = Rd;
3286 let Inst{11-0} = imm{11-0};
3287 let Inst{19-16} = imm{15-12};
3290 let DecoderMethod = "DecodeArmMOVTWInstruction";
3293 def MOVTi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
3294 (ins GPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
3299 def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
3300 Requires<[IsARM, HasV6T2]>;
3302 let Uses = [CPSR] in
3303 def RRX: PseudoInst<(outs GPR:$Rd), (ins GPR:$Rm), IIC_iMOVsi,
3304 [(set GPR:$Rd, (ARMrrx GPR:$Rm))]>, UnaryDP,
3305 Requires<[IsARM]>, Sched<[WriteALU]>;
3307 // These aren't really mov instructions, but we have to define them this way
3308 // due to flag operands.
3310 let Defs = [CPSR] in {
3311 def MOVsrl_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3312 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP,
3313 Sched<[WriteALU]>, Requires<[IsARM]>;
3314 def MOVsra_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3315 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP,
3316 Sched<[WriteALU]>, Requires<[IsARM]>;
3319 //===----------------------------------------------------------------------===//
3320 // Extend Instructions.
3325 def SXTB : AI_ext_rrot<0b01101010,
3326 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
3327 def SXTH : AI_ext_rrot<0b01101011,
3328 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
3330 def SXTAB : AI_exta_rrot<0b01101010,
3331 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
3332 def SXTAH : AI_exta_rrot<0b01101011,
3333 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
3335 def SXTB16 : AI_ext_rrot_np<0b01101000, "sxtb16">;
3337 def SXTAB16 : AI_exta_rrot_np<0b01101000, "sxtab16">;
3341 let AddedComplexity = 16 in {
3342 def UXTB : AI_ext_rrot<0b01101110,
3343 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
3344 def UXTH : AI_ext_rrot<0b01101111,
3345 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
3346 def UXTB16 : AI_ext_rrot<0b01101100,
3347 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
3349 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
3350 // The transformation should probably be done as a combiner action
3351 // instead so we can include a check for masking back in the upper
3352 // eight bits of the source into the lower eight bits of the result.
3353 //def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
3354 // (UXTB16r_rot GPR:$Src, 3)>;
3355 def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
3356 (UXTB16 GPR:$Src, 1)>;
3358 def UXTAB : AI_exta_rrot<0b01101110, "uxtab",
3359 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
3360 def UXTAH : AI_exta_rrot<0b01101111, "uxtah",
3361 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
3364 // This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
3365 def UXTAB16 : AI_exta_rrot_np<0b01101100, "uxtab16">;
3368 def SBFX : I<(outs GPRnopc:$Rd),
3369 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3370 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3371 "sbfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3372 Requires<[IsARM, HasV6T2]> {
3377 let Inst{27-21} = 0b0111101;
3378 let Inst{6-4} = 0b101;
3379 let Inst{20-16} = width;
3380 let Inst{15-12} = Rd;
3381 let Inst{11-7} = lsb;
3385 def UBFX : I<(outs GPRnopc:$Rd),
3386 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3387 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3388 "ubfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3389 Requires<[IsARM, HasV6T2]> {
3394 let Inst{27-21} = 0b0111111;
3395 let Inst{6-4} = 0b101;
3396 let Inst{20-16} = width;
3397 let Inst{15-12} = Rd;
3398 let Inst{11-7} = lsb;
3402 //===----------------------------------------------------------------------===//
3403 // Arithmetic Instructions.
3406 defm ADD : AsI1_bin_irs<0b0100, "add",
3407 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3408 BinOpFrag<(add node:$LHS, node:$RHS)>, 1>;
3409 defm SUB : AsI1_bin_irs<0b0010, "sub",
3410 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3411 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
3413 // ADD and SUB with 's' bit set.
3415 // Currently, ADDS/SUBS are pseudo opcodes that exist only in the
3416 // selection DAG. They are "lowered" to real ADD/SUB opcodes by
3417 // AdjustInstrPostInstrSelection where we determine whether or not to
3418 // set the "s" bit based on CPSR liveness.
3420 // FIXME: Eliminate ADDS/SUBS pseudo opcodes after adding tablegen
3421 // support for an optional CPSR definition that corresponds to the DAG
3422 // node's second value. We can then eliminate the implicit def of CPSR.
3423 defm ADDS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3424 BinOpFrag<(ARMaddc node:$LHS, node:$RHS)>, 1>;
3425 defm SUBS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3426 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
3428 defm ADC : AI1_adde_sube_irs<0b0101, "adc",
3429 BinOpWithFlagFrag<(ARMadde node:$LHS, node:$RHS, node:$FLAG)>, 1>;
3430 defm SBC : AI1_adde_sube_irs<0b0110, "sbc",
3431 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>>;
3433 defm RSB : AsI1_rbin_irs<0b0011, "rsb",
3434 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3435 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
3437 // FIXME: Eliminate them if we can write def : Pat patterns which defines
3438 // CPSR and the implicit def of CPSR is not needed.
3439 defm RSBS : AsI1_rbin_s_is<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3440 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
3442 defm RSC : AI1_rsc_irs<0b0111, "rsc",
3443 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>>;
3445 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
3446 // The assume-no-carry-in form uses the negation of the input since add/sub
3447 // assume opposite meanings of the carry flag (i.e., carry == !borrow).
3448 // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
3450 def : ARMPat<(add GPR:$src, mod_imm_neg:$imm),
3451 (SUBri GPR:$src, mod_imm_neg:$imm)>;
3452 def : ARMPat<(ARMaddc GPR:$src, mod_imm_neg:$imm),
3453 (SUBSri GPR:$src, mod_imm_neg:$imm)>;
3455 def : ARMPat<(add GPR:$src, imm0_65535_neg:$imm),
3456 (SUBrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>,
3457 Requires<[IsARM, HasV6T2]>;
3458 def : ARMPat<(ARMaddc GPR:$src, imm0_65535_neg:$imm),
3459 (SUBSrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>,
3460 Requires<[IsARM, HasV6T2]>;
3462 // The with-carry-in form matches bitwise not instead of the negation.
3463 // Effectively, the inverse interpretation of the carry flag already accounts
3464 // for part of the negation.
3465 def : ARMPat<(ARMadde GPR:$src, mod_imm_not:$imm, CPSR),
3466 (SBCri GPR:$src, mod_imm_not:$imm)>;
3467 def : ARMPat<(ARMadde GPR:$src, imm0_65535_neg:$imm, CPSR),
3468 (SBCrr GPR:$src, (MOVi16 (imm_not_XFORM imm:$imm)))>,
3469 Requires<[IsARM, HasV6T2]>;
3471 // Note: These are implemented in C++ code, because they have to generate
3472 // ADD/SUBrs instructions, which use a complex pattern that a xform function
3474 // (mul X, 2^n+1) -> (add (X << n), X)
3475 // (mul X, 2^n-1) -> (rsb X, (X << n))
3477 // ARM Arithmetic Instruction
3478 // GPR:$dst = GPR:$a op GPR:$b
3479 class AAI<bits<8> op27_20, bits<8> op11_4, string opc,
3480 list<dag> pattern = [],
3481 dag iops = (ins GPRnopc:$Rn, GPRnopc:$Rm),
3482 string asm = "\t$Rd, $Rn, $Rm">
3483 : AI<(outs GPRnopc:$Rd), iops, DPFrm, IIC_iALUr, opc, asm, pattern>,
3484 Sched<[WriteALU, ReadALU, ReadALU]> {
3488 let Inst{27-20} = op27_20;
3489 let Inst{11-4} = op11_4;
3490 let Inst{19-16} = Rn;
3491 let Inst{15-12} = Rd;
3494 let Unpredictable{11-8} = 0b1111;
3497 // Saturating add/subtract
3499 let DecoderMethod = "DecodeQADDInstruction" in
3500 def QADD : AAI<0b00010000, 0b00000101, "qadd",
3501 [(set GPRnopc:$Rd, (int_arm_qadd GPRnopc:$Rm, GPRnopc:$Rn))],
3502 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3504 def QSUB : AAI<0b00010010, 0b00000101, "qsub",
3505 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm, GPRnopc:$Rn))],
3506 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3507 def QDADD : AAI<0b00010100, 0b00000101, "qdadd", [],
3508 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3510 def QDSUB : AAI<0b00010110, 0b00000101, "qdsub", [],
3511 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3514 def QADD16 : AAI<0b01100010, 0b11110001, "qadd16">;
3515 def QADD8 : AAI<0b01100010, 0b11111001, "qadd8">;
3516 def QASX : AAI<0b01100010, 0b11110011, "qasx">;
3517 def QSAX : AAI<0b01100010, 0b11110101, "qsax">;
3518 def QSUB16 : AAI<0b01100010, 0b11110111, "qsub16">;
3519 def QSUB8 : AAI<0b01100010, 0b11111111, "qsub8">;
3520 def UQADD16 : AAI<0b01100110, 0b11110001, "uqadd16">;
3521 def UQADD8 : AAI<0b01100110, 0b11111001, "uqadd8">;
3522 def UQASX : AAI<0b01100110, 0b11110011, "uqasx">;
3523 def UQSAX : AAI<0b01100110, 0b11110101, "uqsax">;
3524 def UQSUB16 : AAI<0b01100110, 0b11110111, "uqsub16">;
3525 def UQSUB8 : AAI<0b01100110, 0b11111111, "uqsub8">;
3527 // Signed/Unsigned add/subtract
3529 def SASX : AAI<0b01100001, 0b11110011, "sasx">;
3530 def SADD16 : AAI<0b01100001, 0b11110001, "sadd16">;
3531 def SADD8 : AAI<0b01100001, 0b11111001, "sadd8">;
3532 def SSAX : AAI<0b01100001, 0b11110101, "ssax">;
3533 def SSUB16 : AAI<0b01100001, 0b11110111, "ssub16">;
3534 def SSUB8 : AAI<0b01100001, 0b11111111, "ssub8">;
3535 def UASX : AAI<0b01100101, 0b11110011, "uasx">;
3536 def UADD16 : AAI<0b01100101, 0b11110001, "uadd16">;
3537 def UADD8 : AAI<0b01100101, 0b11111001, "uadd8">;
3538 def USAX : AAI<0b01100101, 0b11110101, "usax">;
3539 def USUB16 : AAI<0b01100101, 0b11110111, "usub16">;
3540 def USUB8 : AAI<0b01100101, 0b11111111, "usub8">;
3542 // Signed/Unsigned halving add/subtract
3544 def SHASX : AAI<0b01100011, 0b11110011, "shasx">;
3545 def SHADD16 : AAI<0b01100011, 0b11110001, "shadd16">;
3546 def SHADD8 : AAI<0b01100011, 0b11111001, "shadd8">;
3547 def SHSAX : AAI<0b01100011, 0b11110101, "shsax">;
3548 def SHSUB16 : AAI<0b01100011, 0b11110111, "shsub16">;
3549 def SHSUB8 : AAI<0b01100011, 0b11111111, "shsub8">;
3550 def UHASX : AAI<0b01100111, 0b11110011, "uhasx">;
3551 def UHADD16 : AAI<0b01100111, 0b11110001, "uhadd16">;
3552 def UHADD8 : AAI<0b01100111, 0b11111001, "uhadd8">;
3553 def UHSAX : AAI<0b01100111, 0b11110101, "uhsax">;
3554 def UHSUB16 : AAI<0b01100111, 0b11110111, "uhsub16">;
3555 def UHSUB8 : AAI<0b01100111, 0b11111111, "uhsub8">;
3557 // Unsigned Sum of Absolute Differences [and Accumulate].
3559 def USAD8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3560 MulFrm /* for convenience */, NoItinerary, "usad8",
3561 "\t$Rd, $Rn, $Rm", []>,
3562 Requires<[IsARM, HasV6]>, Sched<[WriteALU, ReadALU, ReadALU]> {
3566 let Inst{27-20} = 0b01111000;
3567 let Inst{15-12} = 0b1111;
3568 let Inst{7-4} = 0b0001;
3569 let Inst{19-16} = Rd;
3570 let Inst{11-8} = Rm;
3573 def USADA8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3574 MulFrm /* for convenience */, NoItinerary, "usada8",
3575 "\t$Rd, $Rn, $Rm, $Ra", []>,
3576 Requires<[IsARM, HasV6]>, Sched<[WriteALU, ReadALU, ReadALU]>{
3581 let Inst{27-20} = 0b01111000;
3582 let Inst{7-4} = 0b0001;
3583 let Inst{19-16} = Rd;
3584 let Inst{15-12} = Ra;
3585 let Inst{11-8} = Rm;
3589 // Signed/Unsigned saturate
3591 def SSAT : AI<(outs GPRnopc:$Rd),
3592 (ins imm1_32:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3593 SatFrm, NoItinerary, "ssat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3598 let Inst{27-21} = 0b0110101;
3599 let Inst{5-4} = 0b01;
3600 let Inst{20-16} = sat_imm;
3601 let Inst{15-12} = Rd;
3602 let Inst{11-7} = sh{4-0};
3603 let Inst{6} = sh{5};
3607 def SSAT16 : AI<(outs GPRnopc:$Rd),
3608 (ins imm1_16:$sat_imm, GPRnopc:$Rn), SatFrm,
3609 NoItinerary, "ssat16", "\t$Rd, $sat_imm, $Rn", []> {
3613 let Inst{27-20} = 0b01101010;
3614 let Inst{11-4} = 0b11110011;
3615 let Inst{15-12} = Rd;
3616 let Inst{19-16} = sat_imm;
3620 def USAT : AI<(outs GPRnopc:$Rd),
3621 (ins imm0_31:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3622 SatFrm, NoItinerary, "usat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3627 let Inst{27-21} = 0b0110111;
3628 let Inst{5-4} = 0b01;
3629 let Inst{15-12} = Rd;
3630 let Inst{11-7} = sh{4-0};
3631 let Inst{6} = sh{5};
3632 let Inst{20-16} = sat_imm;
3636 def USAT16 : AI<(outs GPRnopc:$Rd),
3637 (ins imm0_15:$sat_imm, GPRnopc:$Rn), SatFrm,
3638 NoItinerary, "usat16", "\t$Rd, $sat_imm, $Rn", []> {
3642 let Inst{27-20} = 0b01101110;
3643 let Inst{11-4} = 0b11110011;
3644 let Inst{15-12} = Rd;
3645 let Inst{19-16} = sat_imm;
3649 def : ARMV6Pat<(int_arm_ssat GPRnopc:$a, imm:$pos),
3650 (SSAT imm:$pos, GPRnopc:$a, 0)>;
3651 def : ARMV6Pat<(int_arm_usat GPRnopc:$a, imm:$pos),
3652 (USAT imm:$pos, GPRnopc:$a, 0)>;
3654 //===----------------------------------------------------------------------===//
3655 // Bitwise Instructions.
3658 defm AND : AsI1_bin_irs<0b0000, "and",
3659 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3660 BinOpFrag<(and node:$LHS, node:$RHS)>, 1>;
3661 defm ORR : AsI1_bin_irs<0b1100, "orr",
3662 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3663 BinOpFrag<(or node:$LHS, node:$RHS)>, 1>;
3664 defm EOR : AsI1_bin_irs<0b0001, "eor",
3665 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3666 BinOpFrag<(xor node:$LHS, node:$RHS)>, 1>;
3667 defm BIC : AsI1_bin_irs<0b1110, "bic",
3668 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3669 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
3671 // FIXME: bf_inv_mask_imm should be two operands, the lsb and the msb, just
3672 // like in the actual instruction encoding. The complexity of mapping the mask
3673 // to the lsb/msb pair should be handled by ISel, not encapsulated in the
3674 // instruction description.
3675 def BFC : I<(outs GPR:$Rd), (ins GPR:$src, bf_inv_mask_imm:$imm),
3676 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3677 "bfc", "\t$Rd, $imm", "$src = $Rd",
3678 [(set GPR:$Rd, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
3679 Requires<[IsARM, HasV6T2]> {
3682 let Inst{27-21} = 0b0111110;
3683 let Inst{6-0} = 0b0011111;
3684 let Inst{15-12} = Rd;
3685 let Inst{11-7} = imm{4-0}; // lsb
3686 let Inst{20-16} = imm{9-5}; // msb
3689 // A8.6.18 BFI - Bitfield insert (Encoding A1)
3690 def BFI:I<(outs GPRnopc:$Rd), (ins GPRnopc:$src, GPR:$Rn, bf_inv_mask_imm:$imm),
3691 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3692 "bfi", "\t$Rd, $Rn, $imm", "$src = $Rd",
3693 [(set GPRnopc:$Rd, (ARMbfi GPRnopc:$src, GPR:$Rn,
3694 bf_inv_mask_imm:$imm))]>,
3695 Requires<[IsARM, HasV6T2]> {
3699 let Inst{27-21} = 0b0111110;
3700 let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15
3701 let Inst{15-12} = Rd;
3702 let Inst{11-7} = imm{4-0}; // lsb
3703 let Inst{20-16} = imm{9-5}; // width
3707 def MVNr : AsI1<0b1111, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMVNr,
3708 "mvn", "\t$Rd, $Rm",
3709 [(set GPR:$Rd, (not GPR:$Rm))]>, UnaryDP, Sched<[WriteALU]> {
3713 let Inst{19-16} = 0b0000;
3714 let Inst{11-4} = 0b00000000;
3715 let Inst{15-12} = Rd;
3718 def MVNsi : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_imm:$shift),
3719 DPSoRegImmFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3720 [(set GPR:$Rd, (not so_reg_imm:$shift))]>, UnaryDP,
3725 let Inst{19-16} = 0b0000;
3726 let Inst{15-12} = Rd;
3727 let Inst{11-5} = shift{11-5};
3729 let Inst{3-0} = shift{3-0};
3731 def MVNsr : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_reg:$shift),
3732 DPSoRegRegFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3733 [(set GPR:$Rd, (not so_reg_reg:$shift))]>, UnaryDP,
3738 let Inst{19-16} = 0b0000;
3739 let Inst{15-12} = Rd;
3740 let Inst{11-8} = shift{11-8};
3742 let Inst{6-5} = shift{6-5};
3744 let Inst{3-0} = shift{3-0};
3746 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3747 def MVNi : AsI1<0b1111, (outs GPR:$Rd), (ins mod_imm:$imm), DPFrm,
3748 IIC_iMVNi, "mvn", "\t$Rd, $imm",
3749 [(set GPR:$Rd, mod_imm_not:$imm)]>,UnaryDP, Sched<[WriteALU]> {
3753 let Inst{19-16} = 0b0000;
3754 let Inst{15-12} = Rd;
3755 let Inst{11-0} = imm;
3758 def : ARMPat<(and GPR:$src, mod_imm_not:$imm),
3759 (BICri GPR:$src, mod_imm_not:$imm)>;
3761 //===----------------------------------------------------------------------===//
3762 // Multiply Instructions.
3764 class AsMul1I32<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3765 string opc, string asm, list<dag> pattern>
3766 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3770 let Inst{19-16} = Rd;
3771 let Inst{11-8} = Rm;
3774 class AsMul1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3775 string opc, string asm, list<dag> pattern>
3776 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3781 let Inst{19-16} = RdHi;
3782 let Inst{15-12} = RdLo;
3783 let Inst{11-8} = Rm;
3786 class AsMla1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3787 string opc, string asm, list<dag> pattern>
3788 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3793 let Inst{19-16} = RdHi;
3794 let Inst{15-12} = RdLo;
3795 let Inst{11-8} = Rm;
3799 // FIXME: The v5 pseudos are only necessary for the additional Constraint
3800 // property. Remove them when it's possible to add those properties
3801 // on an individual MachineInstr, not just an instruction description.
3802 let isCommutable = 1, TwoOperandAliasConstraint = "$Rn = $Rd" in {
3803 def MUL : AsMul1I32<0b0000000, (outs GPRnopc:$Rd),
3804 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3805 IIC_iMUL32, "mul", "\t$Rd, $Rn, $Rm",
3806 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))]>,
3807 Requires<[IsARM, HasV6]> {
3808 let Inst{15-12} = 0b0000;
3809 let Unpredictable{15-12} = 0b1111;
3812 let Constraints = "@earlyclobber $Rd" in
3813 def MULv5: ARMPseudoExpand<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm,
3814 pred:$p, cc_out:$s),
3816 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))],
3817 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s)>,
3818 Requires<[IsARM, NoV6, UseMulOps]>;
3821 def MLA : AsMul1I32<0b0000001, (outs GPRnopc:$Rd),
3822 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra),
3823 IIC_iMAC32, "mla", "\t$Rd, $Rn, $Rm, $Ra",
3824 [(set GPRnopc:$Rd, (add (mul GPRnopc:$Rn, GPRnopc:$Rm), GPRnopc:$Ra))]>,
3825 Requires<[IsARM, HasV6, UseMulOps]> {
3827 let Inst{15-12} = Ra;
3830 let Constraints = "@earlyclobber $Rd" in
3831 def MLAv5: ARMPseudoExpand<(outs GPRnopc:$Rd),
3832 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra,
3833 pred:$p, cc_out:$s), 4, IIC_iMAC32,
3834 [(set GPRnopc:$Rd, (add (mul GPRnopc:$Rn, GPRnopc:$Rm), GPRnopc:$Ra))],
3835 (MLA GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra, pred:$p, cc_out:$s)>,
3836 Requires<[IsARM, NoV6]>;
3838 def MLS : AMul1I<0b0000011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3839 IIC_iMAC32, "mls", "\t$Rd, $Rn, $Rm, $Ra",
3840 [(set GPR:$Rd, (sub GPR:$Ra, (mul GPR:$Rn, GPR:$Rm)))]>,
3841 Requires<[IsARM, HasV6T2, UseMulOps]> {
3846 let Inst{19-16} = Rd;
3847 let Inst{15-12} = Ra;
3848 let Inst{11-8} = Rm;
3852 // Extra precision multiplies with low / high results
3853 let hasSideEffects = 0 in {
3854 let isCommutable = 1 in {
3855 def SMULL : AsMul1I64<0b0000110, (outs GPR:$RdLo, GPR:$RdHi),
3856 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3857 "smull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3858 Requires<[IsARM, HasV6]>;
3860 def UMULL : AsMul1I64<0b0000100, (outs GPR:$RdLo, GPR:$RdHi),
3861 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3862 "umull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3863 Requires<[IsARM, HasV6]>;
3865 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
3866 def SMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3867 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3869 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3870 Requires<[IsARM, NoV6]>;
3872 def UMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3873 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3875 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3876 Requires<[IsARM, NoV6]>;
3880 // Multiply + accumulate
3881 def SMLAL : AsMla1I64<0b0000111, (outs GPR:$RdLo, GPR:$RdHi),
3882 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64,
3883 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3884 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>;
3885 def UMLAL : AsMla1I64<0b0000101, (outs GPR:$RdLo, GPR:$RdHi),
3886 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64,
3887 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3888 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>;
3890 def UMAAL : AMul1I <0b0000010, (outs GPR:$RdLo, GPR:$RdHi),
3891 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3892 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3893 Requires<[IsARM, HasV6]> {
3898 let Inst{19-16} = RdHi;
3899 let Inst{15-12} = RdLo;
3900 let Inst{11-8} = Rm;
3905 "@earlyclobber $RdLo,@earlyclobber $RdHi,$RLo = $RdLo,$RHi = $RdHi" in {
3906 def SMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3907 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s),
3909 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi,
3910 pred:$p, cc_out:$s)>,
3911 Requires<[IsARM, NoV6]>;
3912 def UMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3913 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s),
3915 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi,
3916 pred:$p, cc_out:$s)>,
3917 Requires<[IsARM, NoV6]>;
3922 // Most significant word multiply
3923 def SMMUL : AMul2I <0b0111010, 0b0001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3924 IIC_iMUL32, "smmul", "\t$Rd, $Rn, $Rm",
3925 [(set GPR:$Rd, (mulhs GPR:$Rn, GPR:$Rm))]>,
3926 Requires<[IsARM, HasV6]> {
3927 let Inst{15-12} = 0b1111;
3930 def SMMULR : AMul2I <0b0111010, 0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3931 IIC_iMUL32, "smmulr", "\t$Rd, $Rn, $Rm", []>,
3932 Requires<[IsARM, HasV6]> {
3933 let Inst{15-12} = 0b1111;
3936 def SMMLA : AMul2Ia <0b0111010, 0b0001, (outs GPR:$Rd),
3937 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3938 IIC_iMAC32, "smmla", "\t$Rd, $Rn, $Rm, $Ra",
3939 [(set GPR:$Rd, (add (mulhs GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
3940 Requires<[IsARM, HasV6, UseMulOps]>;
3942 def SMMLAR : AMul2Ia <0b0111010, 0b0011, (outs GPR:$Rd),
3943 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3944 IIC_iMAC32, "smmlar", "\t$Rd, $Rn, $Rm, $Ra", []>,
3945 Requires<[IsARM, HasV6]>;
3947 def SMMLS : AMul2Ia <0b0111010, 0b1101, (outs GPR:$Rd),
3948 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3949 IIC_iMAC32, "smmls", "\t$Rd, $Rn, $Rm, $Ra", []>,
3950 Requires<[IsARM, HasV6, UseMulOps]>;
3952 def SMMLSR : AMul2Ia <0b0111010, 0b1111, (outs GPR:$Rd),
3953 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3954 IIC_iMAC32, "smmlsr", "\t$Rd, $Rn, $Rm, $Ra", []>,
3955 Requires<[IsARM, HasV6]>;
3957 multiclass AI_smul<string opc, PatFrag opnode> {
3958 def BB : AMulxyI<0b0001011, 0b00, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3959 IIC_iMUL16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm",
3960 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3961 (sext_inreg GPR:$Rm, i16)))]>,
3962 Requires<[IsARM, HasV5TE]>;
3964 def BT : AMulxyI<0b0001011, 0b10, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3965 IIC_iMUL16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm",
3966 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3967 (sra GPR:$Rm, (i32 16))))]>,
3968 Requires<[IsARM, HasV5TE]>;
3970 def TB : AMulxyI<0b0001011, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3971 IIC_iMUL16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm",
3972 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3973 (sext_inreg GPR:$Rm, i16)))]>,
3974 Requires<[IsARM, HasV5TE]>;
3976 def TT : AMulxyI<0b0001011, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3977 IIC_iMUL16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm",
3978 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3979 (sra GPR:$Rm, (i32 16))))]>,
3980 Requires<[IsARM, HasV5TE]>;
3982 def WB : AMulxyI<0b0001001, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3983 IIC_iMUL16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm",
3985 Requires<[IsARM, HasV5TE]>;
3987 def WT : AMulxyI<0b0001001, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3988 IIC_iMUL16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm",
3990 Requires<[IsARM, HasV5TE]>;
3994 multiclass AI_smla<string opc, PatFrag opnode> {
3995 let DecoderMethod = "DecodeSMLAInstruction" in {
3996 def BB : AMulxyIa<0b0001000, 0b00, (outs GPRnopc:$Rd),
3997 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3998 IIC_iMAC16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra",
3999 [(set GPRnopc:$Rd, (add GPR:$Ra,
4000 (opnode (sext_inreg GPRnopc:$Rn, i16),
4001 (sext_inreg GPRnopc:$Rm, i16))))]>,
4002 Requires<[IsARM, HasV5TE, UseMulOps]>;
4004 def BT : AMulxyIa<0b0001000, 0b10, (outs GPRnopc:$Rd),
4005 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4006 IIC_iMAC16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra",
4008 (add GPR:$Ra, (opnode (sext_inreg GPRnopc:$Rn, i16),
4009 (sra GPRnopc:$Rm, (i32 16)))))]>,
4010 Requires<[IsARM, HasV5TE, UseMulOps]>;
4012 def TB : AMulxyIa<0b0001000, 0b01, (outs GPRnopc:$Rd),
4013 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4014 IIC_iMAC16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra",
4016 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
4017 (sext_inreg GPRnopc:$Rm, i16))))]>,
4018 Requires<[IsARM, HasV5TE, UseMulOps]>;
4020 def TT : AMulxyIa<0b0001000, 0b11, (outs GPRnopc:$Rd),
4021 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4022 IIC_iMAC16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra",
4024 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
4025 (sra GPRnopc:$Rm, (i32 16)))))]>,
4026 Requires<[IsARM, HasV5TE, UseMulOps]>;
4028 def WB : AMulxyIa<0b0001001, 0b00, (outs GPRnopc:$Rd),
4029 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4030 IIC_iMAC16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra",
4032 Requires<[IsARM, HasV5TE, UseMulOps]>;
4034 def WT : AMulxyIa<0b0001001, 0b10, (outs GPRnopc:$Rd),
4035 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4036 IIC_iMAC16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra",
4038 Requires<[IsARM, HasV5TE, UseMulOps]>;
4042 defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
4043 defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
4045 // Halfword multiply accumulate long: SMLAL<x><y>.
4046 def SMLALBB : AMulxyI64<0b0001010, 0b00, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4047 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4048 IIC_iMAC64, "smlalbb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4049 Requires<[IsARM, HasV5TE]>;
4051 def SMLALBT : AMulxyI64<0b0001010, 0b10, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4052 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4053 IIC_iMAC64, "smlalbt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4054 Requires<[IsARM, HasV5TE]>;
4056 def SMLALTB : AMulxyI64<0b0001010, 0b01, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4057 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4058 IIC_iMAC64, "smlaltb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4059 Requires<[IsARM, HasV5TE]>;
4061 def SMLALTT : AMulxyI64<0b0001010, 0b11, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4062 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4063 IIC_iMAC64, "smlaltt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4064 Requires<[IsARM, HasV5TE]>;
4066 // Helper class for AI_smld.
4067 class AMulDualIbase<bit long, bit sub, bit swap, dag oops, dag iops,
4068 InstrItinClass itin, string opc, string asm>
4069 : AI<oops, iops, MulFrm, itin, opc, asm, []>, Requires<[IsARM, HasV6]> {
4072 let Inst{27-23} = 0b01110;
4073 let Inst{22} = long;
4074 let Inst{21-20} = 0b00;
4075 let Inst{11-8} = Rm;
4082 class AMulDualI<bit long, bit sub, bit swap, dag oops, dag iops,
4083 InstrItinClass itin, string opc, string asm>
4084 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4086 let Inst{15-12} = 0b1111;
4087 let Inst{19-16} = Rd;
4089 class AMulDualIa<bit long, bit sub, bit swap, dag oops, dag iops,
4090 InstrItinClass itin, string opc, string asm>
4091 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4094 let Inst{19-16} = Rd;
4095 let Inst{15-12} = Ra;
4097 class AMulDualI64<bit long, bit sub, bit swap, dag oops, dag iops,
4098 InstrItinClass itin, string opc, string asm>
4099 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4102 let Inst{19-16} = RdHi;
4103 let Inst{15-12} = RdLo;
4106 multiclass AI_smld<bit sub, string opc> {
4108 def D : AMulDualIa<0, sub, 0, (outs GPRnopc:$Rd),
4109 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4110 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm, $Ra">;
4112 def DX: AMulDualIa<0, sub, 1, (outs GPRnopc:$Rd),
4113 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4114 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm, $Ra">;
4116 def LD: AMulDualI64<1, sub, 0, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4117 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
4118 !strconcat(opc, "ld"), "\t$RdLo, $RdHi, $Rn, $Rm">;
4120 def LDX : AMulDualI64<1, sub, 1, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4121 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
4122 !strconcat(opc, "ldx"),"\t$RdLo, $RdHi, $Rn, $Rm">;
4126 defm SMLA : AI_smld<0, "smla">;
4127 defm SMLS : AI_smld<1, "smls">;
4129 multiclass AI_sdml<bit sub, string opc> {
4131 def D:AMulDualI<0, sub, 0, (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm),
4132 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm">;
4133 def DX:AMulDualI<0, sub, 1, (outs GPRnopc:$Rd),(ins GPRnopc:$Rn, GPRnopc:$Rm),
4134 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm">;
4137 defm SMUA : AI_sdml<0, "smua">;
4138 defm SMUS : AI_sdml<1, "smus">;
4140 //===----------------------------------------------------------------------===//
4141 // Division Instructions (ARMv7-A with virtualization extension)
4143 def SDIV : ADivA1I<0b001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV,
4144 "sdiv", "\t$Rd, $Rn, $Rm",
4145 [(set GPR:$Rd, (sdiv GPR:$Rn, GPR:$Rm))]>,
4146 Requires<[IsARM, HasDivideInARM]>;
4148 def UDIV : ADivA1I<0b011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV,
4149 "udiv", "\t$Rd, $Rn, $Rm",
4150 [(set GPR:$Rd, (udiv GPR:$Rn, GPR:$Rm))]>,
4151 Requires<[IsARM, HasDivideInARM]>;
4153 //===----------------------------------------------------------------------===//
4154 // Misc. Arithmetic Instructions.
4157 def CLZ : AMiscA1I<0b00010110, 0b0001, (outs GPR:$Rd), (ins GPR:$Rm),
4158 IIC_iUNAr, "clz", "\t$Rd, $Rm",
4159 [(set GPR:$Rd, (ctlz GPR:$Rm))]>, Requires<[IsARM, HasV5T]>,
4162 def RBIT : AMiscA1I<0b01101111, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
4163 IIC_iUNAr, "rbit", "\t$Rd, $Rm",
4164 [(set GPR:$Rd, (ARMrbit GPR:$Rm))]>,
4165 Requires<[IsARM, HasV6T2]>,
4168 def REV : AMiscA1I<0b01101011, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
4169 IIC_iUNAr, "rev", "\t$Rd, $Rm",
4170 [(set GPR:$Rd, (bswap GPR:$Rm))]>, Requires<[IsARM, HasV6]>,
4173 let AddedComplexity = 5 in
4174 def REV16 : AMiscA1I<0b01101011, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
4175 IIC_iUNAr, "rev16", "\t$Rd, $Rm",
4176 [(set GPR:$Rd, (rotr (bswap GPR:$Rm), (i32 16)))]>,
4177 Requires<[IsARM, HasV6]>,
4180 def : ARMV6Pat<(srl (bswap (extloadi16 addrmode3:$addr)), (i32 16)),
4181 (REV16 (LDRH addrmode3:$addr))>;
4182 def : ARMV6Pat<(truncstorei16 (srl (bswap GPR:$Rn), (i32 16)), addrmode3:$addr),
4183 (STRH (REV16 GPR:$Rn), addrmode3:$addr)>;
4185 let AddedComplexity = 5 in
4186 def REVSH : AMiscA1I<0b01101111, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
4187 IIC_iUNAr, "revsh", "\t$Rd, $Rm",
4188 [(set GPR:$Rd, (sra (bswap GPR:$Rm), (i32 16)))]>,
4189 Requires<[IsARM, HasV6]>,
4192 def : ARMV6Pat<(or (sra (shl GPR:$Rm, (i32 24)), (i32 16)),
4193 (and (srl GPR:$Rm, (i32 8)), 0xFF)),
4196 def PKHBT : APKHI<0b01101000, 0, (outs GPRnopc:$Rd),
4197 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_lsl_amt:$sh),
4198 IIC_iALUsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh",
4199 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF),
4200 (and (shl GPRnopc:$Rm, pkh_lsl_amt:$sh),
4202 Requires<[IsARM, HasV6]>,
4203 Sched<[WriteALUsi, ReadALU]>;
4205 // Alternate cases for PKHBT where identities eliminate some nodes.
4206 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (and GPRnopc:$Rm, 0xFFFF0000)),
4207 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, 0)>;
4208 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (shl GPRnopc:$Rm, imm16_31:$sh)),
4209 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, imm16_31:$sh)>;
4211 // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
4212 // will match the pattern below.
4213 def PKHTB : APKHI<0b01101000, 1, (outs GPRnopc:$Rd),
4214 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_asr_amt:$sh),
4215 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh",
4216 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF0000),
4217 (and (sra GPRnopc:$Rm, pkh_asr_amt:$sh),
4219 Requires<[IsARM, HasV6]>,
4220 Sched<[WriteALUsi, ReadALU]>;
4222 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
4223 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
4224 // We also can not replace a srl (17..31) by an arithmetic shift we would use in
4225 // pkhtb src1, src2, asr (17..31).
4226 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4227 (srl GPRnopc:$src2, imm16:$sh)),
4228 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16:$sh)>;
4229 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4230 (sra GPRnopc:$src2, imm16_31:$sh)),
4231 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16_31:$sh)>;
4232 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4233 (and (srl GPRnopc:$src2, imm1_15:$sh), 0xFFFF)),
4234 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm1_15:$sh)>;
4236 //===----------------------------------------------------------------------===//
4240 // + CRC32{B,H,W} 0x04C11DB7
4241 // + CRC32C{B,H,W} 0x1EDC6F41
4244 class AI_crc32<bit C, bits<2> sz, string suffix, SDPatternOperator builtin>
4245 : AInoP<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm), MiscFrm, NoItinerary,
4246 !strconcat("crc32", suffix), "\t$Rd, $Rn, $Rm",
4247 [(set GPRnopc:$Rd, (builtin GPRnopc:$Rn, GPRnopc:$Rm))]>,
4248 Requires<[IsARM, HasV8, HasCRC]> {
4253 let Inst{31-28} = 0b1110;
4254 let Inst{27-23} = 0b00010;
4255 let Inst{22-21} = sz;
4257 let Inst{19-16} = Rn;
4258 let Inst{15-12} = Rd;
4259 let Inst{11-10} = 0b00;
4262 let Inst{7-4} = 0b0100;
4265 let Unpredictable{11-8} = 0b1101;
4268 def CRC32B : AI_crc32<0, 0b00, "b", int_arm_crc32b>;
4269 def CRC32CB : AI_crc32<1, 0b00, "cb", int_arm_crc32cb>;
4270 def CRC32H : AI_crc32<0, 0b01, "h", int_arm_crc32h>;
4271 def CRC32CH : AI_crc32<1, 0b01, "ch", int_arm_crc32ch>;
4272 def CRC32W : AI_crc32<0, 0b10, "w", int_arm_crc32w>;
4273 def CRC32CW : AI_crc32<1, 0b10, "cw", int_arm_crc32cw>;
4275 //===----------------------------------------------------------------------===//
4276 // ARMv8.1a Privilege Access Never extension
4280 def SETPAN : AInoP<(outs), (ins imm0_1:$imm), MiscFrm, NoItinerary, "setpan",
4281 "\t$imm", []>, Requires<[IsARM, HasV8, HasV8_1a]> {
4284 let Inst{31-28} = 0b1111;
4285 let Inst{27-20} = 0b00010001;
4286 let Inst{19-16} = 0b0000;
4287 let Inst{15-10} = 0b000000;
4290 let Inst{7-4} = 0b0000;
4291 let Inst{3-0} = 0b0000;
4293 let Unpredictable{19-16} = 0b1111;
4294 let Unpredictable{15-10} = 0b111111;
4295 let Unpredictable{8} = 0b1;
4296 let Unpredictable{3-0} = 0b1111;
4299 //===----------------------------------------------------------------------===//
4300 // Comparison Instructions...
4303 defm CMP : AI1_cmp_irs<0b1010, "cmp",
4304 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
4305 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
4307 // ARMcmpZ can re-use the above instruction definitions.
4308 def : ARMPat<(ARMcmpZ GPR:$src, mod_imm:$imm),
4309 (CMPri GPR:$src, mod_imm:$imm)>;
4310 def : ARMPat<(ARMcmpZ GPR:$src, GPR:$rhs),
4311 (CMPrr GPR:$src, GPR:$rhs)>;
4312 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_imm:$rhs),
4313 (CMPrsi GPR:$src, so_reg_imm:$rhs)>;
4314 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_reg:$rhs),
4315 (CMPrsr GPR:$src, so_reg_reg:$rhs)>;
4317 // CMN register-integer
4318 let isCompare = 1, Defs = [CPSR] in {
4319 def CMNri : AI1<0b1011, (outs), (ins GPR:$Rn, mod_imm:$imm), DPFrm, IIC_iCMPi,
4320 "cmn", "\t$Rn, $imm",
4321 [(ARMcmn GPR:$Rn, mod_imm:$imm)]>,
4322 Sched<[WriteCMP, ReadALU]> {
4327 let Inst{19-16} = Rn;
4328 let Inst{15-12} = 0b0000;
4329 let Inst{11-0} = imm;
4331 let Unpredictable{15-12} = 0b1111;
4334 // CMN register-register/shift
4335 def CMNzrr : AI1<0b1011, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, IIC_iCMPr,
4336 "cmn", "\t$Rn, $Rm",
4337 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4338 GPR:$Rn, GPR:$Rm)]>, Sched<[WriteCMP, ReadALU, ReadALU]> {
4341 let isCommutable = 1;
4344 let Inst{19-16} = Rn;
4345 let Inst{15-12} = 0b0000;
4346 let Inst{11-4} = 0b00000000;
4349 let Unpredictable{15-12} = 0b1111;
4352 def CMNzrsi : AI1<0b1011, (outs),
4353 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, IIC_iCMPsr,
4354 "cmn", "\t$Rn, $shift",
4355 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4356 GPR:$Rn, so_reg_imm:$shift)]>,
4357 Sched<[WriteCMPsi, ReadALU]> {
4362 let Inst{19-16} = Rn;
4363 let Inst{15-12} = 0b0000;
4364 let Inst{11-5} = shift{11-5};
4366 let Inst{3-0} = shift{3-0};
4368 let Unpredictable{15-12} = 0b1111;
4371 def CMNzrsr : AI1<0b1011, (outs),
4372 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, IIC_iCMPsr,
4373 "cmn", "\t$Rn, $shift",
4374 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4375 GPRnopc:$Rn, so_reg_reg:$shift)]>,
4376 Sched<[WriteCMPsr, ReadALU]> {
4381 let Inst{19-16} = Rn;
4382 let Inst{15-12} = 0b0000;
4383 let Inst{11-8} = shift{11-8};
4385 let Inst{6-5} = shift{6-5};
4387 let Inst{3-0} = shift{3-0};
4389 let Unpredictable{15-12} = 0b1111;
4394 def : ARMPat<(ARMcmp GPR:$src, mod_imm_neg:$imm),
4395 (CMNri GPR:$src, mod_imm_neg:$imm)>;
4397 def : ARMPat<(ARMcmpZ GPR:$src, mod_imm_neg:$imm),
4398 (CMNri GPR:$src, mod_imm_neg:$imm)>;
4400 // Note that TST/TEQ don't set all the same flags that CMP does!
4401 defm TST : AI1_cmp_irs<0b1000, "tst",
4402 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
4403 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>, 1,
4404 "DecodeTSTInstruction">;
4405 defm TEQ : AI1_cmp_irs<0b1001, "teq",
4406 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
4407 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>, 1>;
4409 // Pseudo i64 compares for some floating point compares.
4410 let usesCustomInserter = 1, isBranch = 1, isTerminator = 1,
4412 def BCCi64 : PseudoInst<(outs),
4413 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, brtarget:$dst),
4415 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, bb:$dst)]>,
4418 def BCCZi64 : PseudoInst<(outs),
4419 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, brtarget:$dst), IIC_Br,
4420 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, 0, 0, bb:$dst)]>,
4422 } // usesCustomInserter
4425 // Conditional moves
4426 let hasSideEffects = 0 in {
4428 let isCommutable = 1, isSelect = 1 in
4429 def MOVCCr : ARMPseudoInst<(outs GPR:$Rd),
4430 (ins GPR:$false, GPR:$Rm, cmovpred:$p),
4432 [(set GPR:$Rd, (ARMcmov GPR:$false, GPR:$Rm,
4434 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4436 def MOVCCsi : ARMPseudoInst<(outs GPR:$Rd),
4437 (ins GPR:$false, so_reg_imm:$shift, cmovpred:$p),
4440 (ARMcmov GPR:$false, so_reg_imm:$shift,
4442 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4443 def MOVCCsr : ARMPseudoInst<(outs GPR:$Rd),
4444 (ins GPR:$false, so_reg_reg:$shift, cmovpred:$p),
4446 [(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_reg:$shift,
4448 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4451 let isMoveImm = 1 in
4453 : ARMPseudoInst<(outs GPR:$Rd),
4454 (ins GPR:$false, imm0_65535_expr:$imm, cmovpred:$p),
4456 [(set GPR:$Rd, (ARMcmov GPR:$false, imm0_65535:$imm,
4458 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>,
4461 let isMoveImm = 1 in
4462 def MOVCCi : ARMPseudoInst<(outs GPR:$Rd),
4463 (ins GPR:$false, mod_imm:$imm, cmovpred:$p),
4465 [(set GPR:$Rd, (ARMcmov GPR:$false, mod_imm:$imm,
4467 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4469 // Two instruction predicate mov immediate.
4470 let isMoveImm = 1 in
4472 : ARMPseudoInst<(outs GPR:$Rd),
4473 (ins GPR:$false, i32imm:$src, cmovpred:$p),
4475 [(set GPR:$Rd, (ARMcmov GPR:$false, imm:$src,
4477 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>;
4479 let isMoveImm = 1 in
4480 def MVNCCi : ARMPseudoInst<(outs GPR:$Rd),
4481 (ins GPR:$false, mod_imm:$imm, cmovpred:$p),
4483 [(set GPR:$Rd, (ARMcmov GPR:$false, mod_imm_not:$imm,
4485 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4490 //===----------------------------------------------------------------------===//
4491 // Atomic operations intrinsics
4494 def MemBarrierOptOperand : AsmOperandClass {
4495 let Name = "MemBarrierOpt";
4496 let ParserMethod = "parseMemBarrierOptOperand";
4498 def memb_opt : Operand<i32> {
4499 let PrintMethod = "printMemBOption";
4500 let ParserMatchClass = MemBarrierOptOperand;
4501 let DecoderMethod = "DecodeMemBarrierOption";
4504 def InstSyncBarrierOptOperand : AsmOperandClass {
4505 let Name = "InstSyncBarrierOpt";
4506 let ParserMethod = "parseInstSyncBarrierOptOperand";
4508 def instsyncb_opt : Operand<i32> {
4509 let PrintMethod = "printInstSyncBOption";
4510 let ParserMatchClass = InstSyncBarrierOptOperand;
4511 let DecoderMethod = "DecodeInstSyncBarrierOption";
4514 // Memory barriers protect the atomic sequences
4515 let hasSideEffects = 1 in {
4516 def DMB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4517 "dmb", "\t$opt", [(int_arm_dmb (i32 imm0_15:$opt))]>,
4518 Requires<[IsARM, HasDB]> {
4520 let Inst{31-4} = 0xf57ff05;
4521 let Inst{3-0} = opt;
4524 def DSB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4525 "dsb", "\t$opt", [(int_arm_dsb (i32 imm0_15:$opt))]>,
4526 Requires<[IsARM, HasDB]> {
4528 let Inst{31-4} = 0xf57ff04;
4529 let Inst{3-0} = opt;
4532 // ISB has only full system option
4533 def ISB : AInoP<(outs), (ins instsyncb_opt:$opt), MiscFrm, NoItinerary,
4534 "isb", "\t$opt", [(int_arm_isb (i32 imm0_15:$opt))]>,
4535 Requires<[IsARM, HasDB]> {
4537 let Inst{31-4} = 0xf57ff06;
4538 let Inst{3-0} = opt;
4542 let usesCustomInserter = 1, Defs = [CPSR] in {
4544 // Pseudo instruction that combines movs + predicated rsbmi
4545 // to implement integer ABS
4546 def ABS : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$src), 8, NoItinerary, []>;
4549 let usesCustomInserter = 1 in {
4550 def COPY_STRUCT_BYVAL_I32 : PseudoInst<
4551 (outs), (ins GPR:$dst, GPR:$src, i32imm:$size, i32imm:$alignment),
4553 [(ARMcopystructbyval GPR:$dst, GPR:$src, imm:$size, imm:$alignment)]>;
4556 def ldrex_1 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4557 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4560 def ldrex_2 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4561 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4564 def ldrex_4 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4565 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4568 def strex_1 : PatFrag<(ops node:$val, node:$ptr),
4569 (int_arm_strex node:$val, node:$ptr), [{
4570 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4573 def strex_2 : PatFrag<(ops node:$val, node:$ptr),
4574 (int_arm_strex node:$val, node:$ptr), [{
4575 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4578 def strex_4 : PatFrag<(ops node:$val, node:$ptr),
4579 (int_arm_strex node:$val, node:$ptr), [{
4580 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4583 def ldaex_1 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4584 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4587 def ldaex_2 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4588 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4591 def ldaex_4 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4592 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4595 def stlex_1 : PatFrag<(ops node:$val, node:$ptr),
4596 (int_arm_stlex node:$val, node:$ptr), [{
4597 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4600 def stlex_2 : PatFrag<(ops node:$val, node:$ptr),
4601 (int_arm_stlex node:$val, node:$ptr), [{
4602 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4605 def stlex_4 : PatFrag<(ops node:$val, node:$ptr),
4606 (int_arm_stlex node:$val, node:$ptr), [{
4607 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4610 let mayLoad = 1 in {
4611 def LDREXB : AIldrex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4612 NoItinerary, "ldrexb", "\t$Rt, $addr",
4613 [(set GPR:$Rt, (ldrex_1 addr_offset_none:$addr))]>;
4614 def LDREXH : AIldrex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4615 NoItinerary, "ldrexh", "\t$Rt, $addr",
4616 [(set GPR:$Rt, (ldrex_2 addr_offset_none:$addr))]>;
4617 def LDREX : AIldrex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4618 NoItinerary, "ldrex", "\t$Rt, $addr",
4619 [(set GPR:$Rt, (ldrex_4 addr_offset_none:$addr))]>;
4620 let hasExtraDefRegAllocReq = 1 in
4621 def LDREXD : AIldrex<0b01, (outs GPRPairOp:$Rt),(ins addr_offset_none:$addr),
4622 NoItinerary, "ldrexd", "\t$Rt, $addr", []> {
4623 let DecoderMethod = "DecodeDoubleRegLoad";
4626 def LDAEXB : AIldaex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4627 NoItinerary, "ldaexb", "\t$Rt, $addr",
4628 [(set GPR:$Rt, (ldaex_1 addr_offset_none:$addr))]>;
4629 def LDAEXH : AIldaex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4630 NoItinerary, "ldaexh", "\t$Rt, $addr",
4631 [(set GPR:$Rt, (ldaex_2 addr_offset_none:$addr))]>;
4632 def LDAEX : AIldaex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4633 NoItinerary, "ldaex", "\t$Rt, $addr",
4634 [(set GPR:$Rt, (ldaex_4 addr_offset_none:$addr))]>;
4635 let hasExtraDefRegAllocReq = 1 in
4636 def LDAEXD : AIldaex<0b01, (outs GPRPairOp:$Rt),(ins addr_offset_none:$addr),
4637 NoItinerary, "ldaexd", "\t$Rt, $addr", []> {
4638 let DecoderMethod = "DecodeDoubleRegLoad";
4642 let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
4643 def STREXB: AIstrex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4644 NoItinerary, "strexb", "\t$Rd, $Rt, $addr",
4645 [(set GPR:$Rd, (strex_1 GPR:$Rt,
4646 addr_offset_none:$addr))]>;
4647 def STREXH: AIstrex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4648 NoItinerary, "strexh", "\t$Rd, $Rt, $addr",
4649 [(set GPR:$Rd, (strex_2 GPR:$Rt,
4650 addr_offset_none:$addr))]>;
4651 def STREX : AIstrex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4652 NoItinerary, "strex", "\t$Rd, $Rt, $addr",
4653 [(set GPR:$Rd, (strex_4 GPR:$Rt,
4654 addr_offset_none:$addr))]>;
4655 let hasExtraSrcRegAllocReq = 1 in
4656 def STREXD : AIstrex<0b01, (outs GPR:$Rd),
4657 (ins GPRPairOp:$Rt, addr_offset_none:$addr),
4658 NoItinerary, "strexd", "\t$Rd, $Rt, $addr", []> {
4659 let DecoderMethod = "DecodeDoubleRegStore";
4661 def STLEXB: AIstlex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4662 NoItinerary, "stlexb", "\t$Rd, $Rt, $addr",
4664 (stlex_1 GPR:$Rt, addr_offset_none:$addr))]>;
4665 def STLEXH: AIstlex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4666 NoItinerary, "stlexh", "\t$Rd, $Rt, $addr",
4668 (stlex_2 GPR:$Rt, addr_offset_none:$addr))]>;
4669 def STLEX : AIstlex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4670 NoItinerary, "stlex", "\t$Rd, $Rt, $addr",
4672 (stlex_4 GPR:$Rt, addr_offset_none:$addr))]>;
4673 let hasExtraSrcRegAllocReq = 1 in
4674 def STLEXD : AIstlex<0b01, (outs GPR:$Rd),
4675 (ins GPRPairOp:$Rt, addr_offset_none:$addr),
4676 NoItinerary, "stlexd", "\t$Rd, $Rt, $addr", []> {
4677 let DecoderMethod = "DecodeDoubleRegStore";
4681 def CLREX : AXI<(outs), (ins), MiscFrm, NoItinerary, "clrex",
4683 Requires<[IsARM, HasV7]> {
4684 let Inst{31-0} = 0b11110101011111111111000000011111;
4687 def : ARMPat<(strex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr),
4688 (STREXB GPR:$Rt, addr_offset_none:$addr)>;
4689 def : ARMPat<(strex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr),
4690 (STREXH GPR:$Rt, addr_offset_none:$addr)>;
4692 def : ARMPat<(stlex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr),
4693 (STLEXB GPR:$Rt, addr_offset_none:$addr)>;
4694 def : ARMPat<(stlex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr),
4695 (STLEXH GPR:$Rt, addr_offset_none:$addr)>;
4697 class acquiring_load<PatFrag base>
4698 : PatFrag<(ops node:$ptr), (base node:$ptr), [{
4699 AtomicOrdering Ordering = cast<AtomicSDNode>(N)->getOrdering();
4700 return isAtLeastAcquire(Ordering);
4703 def atomic_load_acquire_8 : acquiring_load<atomic_load_8>;
4704 def atomic_load_acquire_16 : acquiring_load<atomic_load_16>;
4705 def atomic_load_acquire_32 : acquiring_load<atomic_load_32>;
4707 class releasing_store<PatFrag base>
4708 : PatFrag<(ops node:$ptr, node:$val), (base node:$ptr, node:$val), [{
4709 AtomicOrdering Ordering = cast<AtomicSDNode>(N)->getOrdering();
4710 return isAtLeastRelease(Ordering);
4713 def atomic_store_release_8 : releasing_store<atomic_store_8>;
4714 def atomic_store_release_16 : releasing_store<atomic_store_16>;
4715 def atomic_store_release_32 : releasing_store<atomic_store_32>;
4717 let AddedComplexity = 8 in {
4718 def : ARMPat<(atomic_load_acquire_8 addr_offset_none:$addr), (LDAB addr_offset_none:$addr)>;
4719 def : ARMPat<(atomic_load_acquire_16 addr_offset_none:$addr), (LDAH addr_offset_none:$addr)>;
4720 def : ARMPat<(atomic_load_acquire_32 addr_offset_none:$addr), (LDA addr_offset_none:$addr)>;
4721 def : ARMPat<(atomic_store_release_8 addr_offset_none:$addr, GPR:$val), (STLB GPR:$val, addr_offset_none:$addr)>;
4722 def : ARMPat<(atomic_store_release_16 addr_offset_none:$addr, GPR:$val), (STLH GPR:$val, addr_offset_none:$addr)>;
4723 def : ARMPat<(atomic_store_release_32 addr_offset_none:$addr, GPR:$val), (STL GPR:$val, addr_offset_none:$addr)>;
4726 // SWP/SWPB are deprecated in V6/V7.
4727 let mayLoad = 1, mayStore = 1 in {
4728 def SWP : AIswp<0, (outs GPRnopc:$Rt),
4729 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swp", []>,
4731 def SWPB: AIswp<1, (outs GPRnopc:$Rt),
4732 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swpb", []>,
4736 //===----------------------------------------------------------------------===//
4737 // Coprocessor Instructions.
4740 def CDP : ABI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4741 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4742 NoItinerary, "cdp", "\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4743 [(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4744 imm:$CRm, imm:$opc2)]>,
4753 let Inst{3-0} = CRm;
4755 let Inst{7-5} = opc2;
4756 let Inst{11-8} = cop;
4757 let Inst{15-12} = CRd;
4758 let Inst{19-16} = CRn;
4759 let Inst{23-20} = opc1;
4762 def CDP2 : ABXI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4763 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4764 NoItinerary, "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4765 [(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4766 imm:$CRm, imm:$opc2)]>,
4768 let Inst{31-28} = 0b1111;
4776 let Inst{3-0} = CRm;
4778 let Inst{7-5} = opc2;
4779 let Inst{11-8} = cop;
4780 let Inst{15-12} = CRd;
4781 let Inst{19-16} = CRn;
4782 let Inst{23-20} = opc1;
4785 class ACI<dag oops, dag iops, string opc, string asm,
4786 IndexMode im = IndexModeNone>
4787 : I<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
4789 let Inst{27-25} = 0b110;
4791 class ACInoP<dag oops, dag iops, string opc, string asm,
4792 IndexMode im = IndexModeNone>
4793 : InoP<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
4795 let Inst{31-28} = 0b1111;
4796 let Inst{27-25} = 0b110;
4798 multiclass LdStCop<bit load, bit Dbit, string asm> {
4799 def _OFFSET : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4800 asm, "\t$cop, $CRd, $addr"> {
4804 let Inst{24} = 1; // P = 1
4805 let Inst{23} = addr{8};
4806 let Inst{22} = Dbit;
4807 let Inst{21} = 0; // W = 0
4808 let Inst{20} = load;
4809 let Inst{19-16} = addr{12-9};
4810 let Inst{15-12} = CRd;
4811 let Inst{11-8} = cop;
4812 let Inst{7-0} = addr{7-0};
4813 let DecoderMethod = "DecodeCopMemInstruction";
4815 def _PRE : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr),
4816 asm, "\t$cop, $CRd, $addr!", IndexModePre> {
4820 let Inst{24} = 1; // P = 1
4821 let Inst{23} = addr{8};
4822 let Inst{22} = Dbit;
4823 let Inst{21} = 1; // W = 1
4824 let Inst{20} = load;
4825 let Inst{19-16} = addr{12-9};
4826 let Inst{15-12} = CRd;
4827 let Inst{11-8} = cop;
4828 let Inst{7-0} = addr{7-0};
4829 let DecoderMethod = "DecodeCopMemInstruction";
4831 def _POST: ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4832 postidx_imm8s4:$offset),
4833 asm, "\t$cop, $CRd, $addr, $offset", IndexModePost> {
4838 let Inst{24} = 0; // P = 0
4839 let Inst{23} = offset{8};
4840 let Inst{22} = Dbit;
4841 let Inst{21} = 1; // W = 1
4842 let Inst{20} = load;
4843 let Inst{19-16} = addr;
4844 let Inst{15-12} = CRd;
4845 let Inst{11-8} = cop;
4846 let Inst{7-0} = offset{7-0};
4847 let DecoderMethod = "DecodeCopMemInstruction";
4849 def _OPTION : ACI<(outs),
4850 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4851 coproc_option_imm:$option),
4852 asm, "\t$cop, $CRd, $addr, $option"> {
4857 let Inst{24} = 0; // P = 0
4858 let Inst{23} = 1; // U = 1
4859 let Inst{22} = Dbit;
4860 let Inst{21} = 0; // W = 0
4861 let Inst{20} = load;
4862 let Inst{19-16} = addr;
4863 let Inst{15-12} = CRd;
4864 let Inst{11-8} = cop;
4865 let Inst{7-0} = option;
4866 let DecoderMethod = "DecodeCopMemInstruction";
4869 multiclass LdSt2Cop<bit load, bit Dbit, string asm> {
4870 def _OFFSET : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4871 asm, "\t$cop, $CRd, $addr"> {
4875 let Inst{24} = 1; // P = 1
4876 let Inst{23} = addr{8};
4877 let Inst{22} = Dbit;
4878 let Inst{21} = 0; // W = 0
4879 let Inst{20} = load;
4880 let Inst{19-16} = addr{12-9};
4881 let Inst{15-12} = CRd;
4882 let Inst{11-8} = cop;
4883 let Inst{7-0} = addr{7-0};
4884 let DecoderMethod = "DecodeCopMemInstruction";
4886 def _PRE : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr),
4887 asm, "\t$cop, $CRd, $addr!", IndexModePre> {
4891 let Inst{24} = 1; // P = 1
4892 let Inst{23} = addr{8};
4893 let Inst{22} = Dbit;
4894 let Inst{21} = 1; // W = 1
4895 let Inst{20} = load;
4896 let Inst{19-16} = addr{12-9};
4897 let Inst{15-12} = CRd;
4898 let Inst{11-8} = cop;
4899 let Inst{7-0} = addr{7-0};
4900 let DecoderMethod = "DecodeCopMemInstruction";
4902 def _POST: ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4903 postidx_imm8s4:$offset),
4904 asm, "\t$cop, $CRd, $addr, $offset", IndexModePost> {
4909 let Inst{24} = 0; // P = 0
4910 let Inst{23} = offset{8};
4911 let Inst{22} = Dbit;
4912 let Inst{21} = 1; // W = 1
4913 let Inst{20} = load;
4914 let Inst{19-16} = addr;
4915 let Inst{15-12} = CRd;
4916 let Inst{11-8} = cop;
4917 let Inst{7-0} = offset{7-0};
4918 let DecoderMethod = "DecodeCopMemInstruction";
4920 def _OPTION : ACInoP<(outs),
4921 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4922 coproc_option_imm:$option),
4923 asm, "\t$cop, $CRd, $addr, $option"> {
4928 let Inst{24} = 0; // P = 0
4929 let Inst{23} = 1; // U = 1
4930 let Inst{22} = Dbit;
4931 let Inst{21} = 0; // W = 0
4932 let Inst{20} = load;
4933 let Inst{19-16} = addr;
4934 let Inst{15-12} = CRd;
4935 let Inst{11-8} = cop;
4936 let Inst{7-0} = option;
4937 let DecoderMethod = "DecodeCopMemInstruction";
4941 defm LDC : LdStCop <1, 0, "ldc">;
4942 defm LDCL : LdStCop <1, 1, "ldcl">;
4943 defm STC : LdStCop <0, 0, "stc">;
4944 defm STCL : LdStCop <0, 1, "stcl">;
4945 defm LDC2 : LdSt2Cop<1, 0, "ldc2">, Requires<[PreV8]>;
4946 defm LDC2L : LdSt2Cop<1, 1, "ldc2l">, Requires<[PreV8]>;
4947 defm STC2 : LdSt2Cop<0, 0, "stc2">, Requires<[PreV8]>;
4948 defm STC2L : LdSt2Cop<0, 1, "stc2l">, Requires<[PreV8]>;
4950 //===----------------------------------------------------------------------===//
4951 // Move between coprocessor and ARM core register.
4954 class MovRCopro<string opc, bit direction, dag oops, dag iops,
4956 : ABI<0b1110, oops, iops, NoItinerary, opc,
4957 "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2", pattern> {
4958 let Inst{20} = direction;
4968 let Inst{15-12} = Rt;
4969 let Inst{11-8} = cop;
4970 let Inst{23-21} = opc1;
4971 let Inst{7-5} = opc2;
4972 let Inst{3-0} = CRm;
4973 let Inst{19-16} = CRn;
4976 def MCR : MovRCopro<"mcr", 0 /* from ARM core register to coprocessor */,
4978 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4979 c_imm:$CRm, imm0_7:$opc2),
4980 [(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
4981 imm:$CRm, imm:$opc2)]>,
4982 ComplexDeprecationPredicate<"MCR">;
4983 def : ARMInstAlias<"mcr${p} $cop, $opc1, $Rt, $CRn, $CRm",
4984 (MCR p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4985 c_imm:$CRm, 0, pred:$p)>;
4986 def MRC : MovRCopro<"mrc", 1 /* from coprocessor to ARM core register */,
4987 (outs GPRwithAPSR:$Rt),
4988 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
4990 def : ARMInstAlias<"mrc${p} $cop, $opc1, $Rt, $CRn, $CRm",
4991 (MRC GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
4992 c_imm:$CRm, 0, pred:$p)>;
4994 def : ARMPat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
4995 (MRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
4997 class MovRCopro2<string opc, bit direction, dag oops, dag iops,
4999 : ABXI<0b1110, oops, iops, NoItinerary,
5000 !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), pattern> {
5001 let Inst{31-24} = 0b11111110;
5002 let Inst{20} = direction;
5012 let Inst{15-12} = Rt;
5013 let Inst{11-8} = cop;
5014 let Inst{23-21} = opc1;
5015 let Inst{7-5} = opc2;
5016 let Inst{3-0} = CRm;
5017 let Inst{19-16} = CRn;
5020 def MCR2 : MovRCopro2<"mcr2", 0 /* from ARM core register to coprocessor */,
5022 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5023 c_imm:$CRm, imm0_7:$opc2),
5024 [(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
5025 imm:$CRm, imm:$opc2)]>,
5027 def : ARMInstAlias<"mcr2 $cop, $opc1, $Rt, $CRn, $CRm",
5028 (MCR2 p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5030 def MRC2 : MovRCopro2<"mrc2", 1 /* from coprocessor to ARM core register */,
5031 (outs GPRwithAPSR:$Rt),
5032 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
5035 def : ARMInstAlias<"mrc2 $cop, $opc1, $Rt, $CRn, $CRm",
5036 (MRC2 GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
5039 def : ARMV5TPat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn,
5040 imm:$CRm, imm:$opc2),
5041 (MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
5043 class MovRRCopro<string opc, bit direction, list<dag> pattern = []>
5044 : ABI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
5045 GPRnopc:$Rt, GPRnopc:$Rt2, c_imm:$CRm),
5046 NoItinerary, opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm", pattern> {
5047 let Inst{23-21} = 0b010;
5048 let Inst{20} = direction;
5056 let Inst{15-12} = Rt;
5057 let Inst{19-16} = Rt2;
5058 let Inst{11-8} = cop;
5059 let Inst{7-4} = opc1;
5060 let Inst{3-0} = CRm;
5063 def MCRR : MovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */,
5064 [(int_arm_mcrr imm:$cop, imm:$opc1, GPRnopc:$Rt,
5065 GPRnopc:$Rt2, imm:$CRm)]>;
5066 def MRRC : MovRRCopro<"mrrc", 1 /* from coprocessor to ARM core register */>;
5068 class MovRRCopro2<string opc, bit direction, list<dag> pattern = []>
5069 : ABXI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
5070 GPRnopc:$Rt, GPRnopc:$Rt2, c_imm:$CRm), NoItinerary,
5071 !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern>,
5073 let Inst{31-28} = 0b1111;
5074 let Inst{23-21} = 0b010;
5075 let Inst{20} = direction;
5083 let Inst{15-12} = Rt;
5084 let Inst{19-16} = Rt2;
5085 let Inst{11-8} = cop;
5086 let Inst{7-4} = opc1;
5087 let Inst{3-0} = CRm;
5089 let DecoderMethod = "DecodeMRRC2";
5092 def MCRR2 : MovRRCopro2<"mcrr2", 0 /* from ARM core register to coprocessor */,
5093 [(int_arm_mcrr2 imm:$cop, imm:$opc1, GPRnopc:$Rt,
5094 GPRnopc:$Rt2, imm:$CRm)]>;
5095 def MRRC2 : MovRRCopro2<"mrrc2", 1 /* from coprocessor to ARM core register */>;
5097 //===----------------------------------------------------------------------===//
5098 // Move between special register and ARM core register
5101 // Move to ARM core register from Special Register
5102 def MRS : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
5103 "mrs", "\t$Rd, apsr", []> {
5105 let Inst{23-16} = 0b00001111;
5106 let Unpredictable{19-17} = 0b111;
5108 let Inst{15-12} = Rd;
5110 let Inst{11-0} = 0b000000000000;
5111 let Unpredictable{11-0} = 0b110100001111;
5114 def : InstAlias<"mrs${p} $Rd, cpsr", (MRS GPRnopc:$Rd, pred:$p)>,
5117 // The MRSsys instruction is the MRS instruction from the ARM ARM,
5118 // section B9.3.9, with the R bit set to 1.
5119 def MRSsys : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
5120 "mrs", "\t$Rd, spsr", []> {
5122 let Inst{23-16} = 0b01001111;
5123 let Unpredictable{19-16} = 0b1111;
5125 let Inst{15-12} = Rd;
5127 let Inst{11-0} = 0b000000000000;
5128 let Unpredictable{11-0} = 0b110100001111;
5131 // However, the MRS (banked register) system instruction (ARMv7VE) *does* have a
5132 // separate encoding (distinguished by bit 5.
5133 def MRSbanked : ABI<0b0001, (outs GPRnopc:$Rd), (ins banked_reg:$banked),
5134 NoItinerary, "mrs", "\t$Rd, $banked", []>,
5135 Requires<[IsARM, HasVirtualization]> {
5140 let Inst{22} = banked{5}; // R bit
5141 let Inst{21-20} = 0b00;
5142 let Inst{19-16} = banked{3-0};
5143 let Inst{15-12} = Rd;
5144 let Inst{11-9} = 0b001;
5145 let Inst{8} = banked{4};
5146 let Inst{7-0} = 0b00000000;
5149 // Move from ARM core register to Special Register
5151 // No need to have both system and application versions of MSR (immediate) or
5152 // MSR (register), the encodings are the same and the assembly parser has no way
5153 // to distinguish between them. The mask operand contains the special register
5154 // (R Bit) in bit 4 and bits 3-0 contains the mask with the fields to be
5155 // accessed in the special register.
5156 def MSR : ABI<0b0001, (outs), (ins msr_mask:$mask, GPR:$Rn), NoItinerary,
5157 "msr", "\t$mask, $Rn", []> {
5162 let Inst{22} = mask{4}; // R bit
5163 let Inst{21-20} = 0b10;
5164 let Inst{19-16} = mask{3-0};
5165 let Inst{15-12} = 0b1111;
5166 let Inst{11-4} = 0b00000000;
5170 def MSRi : ABI<0b0011, (outs), (ins msr_mask:$mask, mod_imm:$imm), NoItinerary,
5171 "msr", "\t$mask, $imm", []> {
5176 let Inst{22} = mask{4}; // R bit
5177 let Inst{21-20} = 0b10;
5178 let Inst{19-16} = mask{3-0};
5179 let Inst{15-12} = 0b1111;
5180 let Inst{11-0} = imm;
5183 // However, the MSR (banked register) system instruction (ARMv7VE) *does* have a
5184 // separate encoding (distinguished by bit 5.
5185 def MSRbanked : ABI<0b0001, (outs), (ins banked_reg:$banked, GPRnopc:$Rn),
5186 NoItinerary, "msr", "\t$banked, $Rn", []>,
5187 Requires<[IsARM, HasVirtualization]> {
5192 let Inst{22} = banked{5}; // R bit
5193 let Inst{21-20} = 0b10;
5194 let Inst{19-16} = banked{3-0};
5195 let Inst{15-12} = 0b1111;
5196 let Inst{11-9} = 0b001;
5197 let Inst{8} = banked{4};
5198 let Inst{7-4} = 0b0000;
5202 // Dynamic stack allocation yields a _chkstk for Windows targets. These calls
5203 // are needed to probe the stack when allocating more than
5204 // 4k bytes in one go. Touching the stack at 4K increments is necessary to
5205 // ensure that the guard pages used by the OS virtual memory manager are
5206 // allocated in correct sequence.
5207 // The main point of having separate instruction are extra unmodelled effects
5208 // (compared to ordinary calls) like stack pointer change.
5210 def win__chkstk : SDNode<"ARMISD::WIN__CHKSTK", SDTNone,
5211 [SDNPHasChain, SDNPSideEffect]>;
5212 let usesCustomInserter = 1, Uses = [R4], Defs = [R4, SP] in
5213 def WIN__CHKSTK : PseudoInst<(outs), (ins), NoItinerary, [(win__chkstk)]>;
5215 //===----------------------------------------------------------------------===//
5219 // __aeabi_read_tp preserves the registers r1-r3.
5220 // This is a pseudo inst so that we can get the encoding right,
5221 // complete with fixup for the aeabi_read_tp function.
5222 // TPsoft is valid for ARM mode only, in case of Thumb mode a tTPsoft pattern
5223 // is defined in "ARMInstrThumb.td".
5225 Defs = [R0, R12, LR, CPSR], Uses = [SP] in {
5226 def TPsoft : ARMPseudoInst<(outs), (ins), 4, IIC_Br,
5227 [(set R0, ARMthread_pointer)]>, Sched<[WriteBr]>;
5230 //===----------------------------------------------------------------------===//
5231 // SJLJ Exception handling intrinsics
5232 // eh_sjlj_setjmp() is an instruction sequence to store the return
5233 // address and save #0 in R0 for the non-longjmp case.
5234 // Since by its nature we may be coming from some other function to get
5235 // here, and we're using the stack frame for the containing function to
5236 // save/restore registers, we can't keep anything live in regs across
5237 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
5238 // when we get here from a longjmp(). We force everything out of registers
5239 // except for our own input by listing the relevant registers in Defs. By
5240 // doing so, we also cause the prologue/epilogue code to actively preserve
5241 // all of the callee-saved resgisters, which is exactly what we want.
5242 // A constant value is passed in $val, and we use the location as a scratch.
5244 // These are pseudo-instructions and are lowered to individual MC-insts, so
5245 // no encoding information is necessary.
5247 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
5248 Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15 ],
5249 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
5250 def Int_eh_sjlj_setjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
5252 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
5253 Requires<[IsARM, HasVFP2]>;
5257 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
5258 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
5259 def Int_eh_sjlj_setjmp_nofp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
5261 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
5262 Requires<[IsARM, NoVFP]>;
5265 // FIXME: Non-IOS version(s)
5266 let isBarrier = 1, hasSideEffects = 1, isTerminator = 1,
5267 Defs = [ R7, LR, SP ] in {
5268 def Int_eh_sjlj_longjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$scratch),
5270 [(ARMeh_sjlj_longjmp GPR:$src, GPR:$scratch)]>,
5274 // eh.sjlj.dispatchsetup pseudo-instruction.
5275 // This pseudo is used for both ARM and Thumb. Any differences are handled when
5276 // the pseudo is expanded (which happens before any passes that need the
5277 // instruction size).
5278 let isBarrier = 1 in
5279 def Int_eh_sjlj_dispatchsetup : PseudoInst<(outs), (ins), NoItinerary, []>;
5282 //===----------------------------------------------------------------------===//
5283 // Non-Instruction Patterns
5286 // ARMv4 indirect branch using (MOVr PC, dst)
5287 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in
5288 def MOVPCRX : ARMPseudoExpand<(outs), (ins GPR:$dst),
5289 4, IIC_Br, [(brind GPR:$dst)],
5290 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>,
5291 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
5293 // Large immediate handling.
5295 // 32-bit immediate using two piece mod_imms or movw + movt.
5296 // This is a single pseudo instruction, the benefit is that it can be remat'd
5297 // as a single unit instead of having to handle reg inputs.
5298 // FIXME: Remove this when we can do generalized remat.
5299 let isReMaterializable = 1, isMoveImm = 1 in
5300 def MOVi32imm : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
5301 [(set GPR:$dst, (arm_i32imm:$src))]>,
5304 def LDRLIT_ga_abs : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iLoad_i,
5305 [(set GPR:$dst, (ARMWrapper tglobaladdr:$src))]>,
5306 Requires<[IsARM, DontUseMovt]>;
5308 // Pseudo instruction that combines movw + movt + add pc (if PIC).
5309 // It also makes it possible to rematerialize the instructions.
5310 // FIXME: Remove this when we can do generalized remat and when machine licm
5311 // can properly the instructions.
5312 let isReMaterializable = 1 in {
5313 def MOV_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5315 [(set GPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>,
5316 Requires<[IsARM, UseMovt]>;
5318 def LDRLIT_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5321 (ARMWrapperPIC tglobaladdr:$addr))]>,
5322 Requires<[IsARM, DontUseMovt]>;
5324 let AddedComplexity = 10 in
5325 def LDRLIT_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5328 (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
5329 Requires<[IsARM, DontUseMovt]>;
5331 let AddedComplexity = 10 in
5332 def MOV_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5334 [(set GPR:$dst, (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
5335 Requires<[IsARM, UseMovt]>;
5336 } // isReMaterializable
5338 // ConstantPool, GlobalAddress, and JumpTable
5339 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
5340 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
5341 Requires<[IsARM, UseMovt]>;
5342 def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
5343 (LEApcrelJT tjumptable:$dst, imm:$id)>;
5345 // TODO: add,sub,and, 3-instr forms?
5347 // Tail calls. These patterns also apply to Thumb mode.
5348 def : Pat<(ARMtcret tcGPR:$dst), (TCRETURNri tcGPR:$dst)>;
5349 def : Pat<(ARMtcret (i32 tglobaladdr:$dst)), (TCRETURNdi texternalsym:$dst)>;
5350 def : Pat<(ARMtcret (i32 texternalsym:$dst)), (TCRETURNdi texternalsym:$dst)>;
5353 def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>;
5354 def : ARMPat<(ARMcall_nolink texternalsym:$func),
5355 (BMOVPCB_CALL texternalsym:$func)>;
5357 // zextload i1 -> zextload i8
5358 def : ARMPat<(zextloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5359 def : ARMPat<(zextloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5361 // extload -> zextload
5362 def : ARMPat<(extloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5363 def : ARMPat<(extloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5364 def : ARMPat<(extloadi8 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5365 def : ARMPat<(extloadi8 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5367 def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
5369 def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
5370 def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
5373 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
5374 (sra (shl GPR:$b, (i32 16)), (i32 16))),
5375 (SMULBB GPR:$a, GPR:$b)>;
5376 def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
5377 (SMULBB GPR:$a, GPR:$b)>;
5378 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
5379 (sra GPR:$b, (i32 16))),
5380 (SMULBT GPR:$a, GPR:$b)>;
5381 def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, (i32 16))),
5382 (SMULBT GPR:$a, GPR:$b)>;
5383 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)),
5384 (sra (shl GPR:$b, (i32 16)), (i32 16))),
5385 (SMULTB GPR:$a, GPR:$b)>;
5386 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), sext_16_node:$b),
5387 (SMULTB GPR:$a, GPR:$b)>;
5389 def : ARMV5MOPat<(add GPR:$acc,
5390 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
5391 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
5392 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5393 def : ARMV5MOPat<(add GPR:$acc,
5394 (mul sext_16_node:$a, sext_16_node:$b)),
5395 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5396 def : ARMV5MOPat<(add GPR:$acc,
5397 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
5398 (sra GPR:$b, (i32 16)))),
5399 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
5400 def : ARMV5MOPat<(add GPR:$acc,
5401 (mul sext_16_node:$a, (sra GPR:$b, (i32 16)))),
5402 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
5403 def : ARMV5MOPat<(add GPR:$acc,
5404 (mul (sra GPR:$a, (i32 16)),
5405 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
5406 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
5407 def : ARMV5MOPat<(add GPR:$acc,
5408 (mul (sra GPR:$a, (i32 16)), sext_16_node:$b)),
5409 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
5412 // Pre-v7 uses MCR for synchronization barriers.
5413 def : ARMPat<(ARMMemBarrierMCR GPR:$zero), (MCR 15, 0, GPR:$zero, 7, 10, 5)>,
5414 Requires<[IsARM, HasV6]>;
5416 // SXT/UXT with no rotate
5417 let AddedComplexity = 16 in {
5418 def : ARMV6Pat<(and GPR:$Src, 0x000000FF), (UXTB GPR:$Src, 0)>;
5419 def : ARMV6Pat<(and GPR:$Src, 0x0000FFFF), (UXTH GPR:$Src, 0)>;
5420 def : ARMV6Pat<(and GPR:$Src, 0x00FF00FF), (UXTB16 GPR:$Src, 0)>;
5421 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0x00FF)),
5422 (UXTAB GPR:$Rn, GPR:$Rm, 0)>;
5423 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0xFFFF)),
5424 (UXTAH GPR:$Rn, GPR:$Rm, 0)>;
5427 def : ARMV6Pat<(sext_inreg GPR:$Src, i8), (SXTB GPR:$Src, 0)>;
5428 def : ARMV6Pat<(sext_inreg GPR:$Src, i16), (SXTH GPR:$Src, 0)>;
5430 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i8)),
5431 (SXTAB GPR:$Rn, GPRnopc:$Rm, 0)>;
5432 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i16)),
5433 (SXTAH GPR:$Rn, GPRnopc:$Rm, 0)>;
5435 // Atomic load/store patterns
5436 def : ARMPat<(atomic_load_8 ldst_so_reg:$src),
5437 (LDRBrs ldst_so_reg:$src)>;
5438 def : ARMPat<(atomic_load_8 addrmode_imm12:$src),
5439 (LDRBi12 addrmode_imm12:$src)>;
5440 def : ARMPat<(atomic_load_16 addrmode3:$src),
5441 (LDRH addrmode3:$src)>;
5442 def : ARMPat<(atomic_load_32 ldst_so_reg:$src),
5443 (LDRrs ldst_so_reg:$src)>;
5444 def : ARMPat<(atomic_load_32 addrmode_imm12:$src),
5445 (LDRi12 addrmode_imm12:$src)>;
5446 def : ARMPat<(atomic_store_8 ldst_so_reg:$ptr, GPR:$val),
5447 (STRBrs GPR:$val, ldst_so_reg:$ptr)>;
5448 def : ARMPat<(atomic_store_8 addrmode_imm12:$ptr, GPR:$val),
5449 (STRBi12 GPR:$val, addrmode_imm12:$ptr)>;
5450 def : ARMPat<(atomic_store_16 addrmode3:$ptr, GPR:$val),
5451 (STRH GPR:$val, addrmode3:$ptr)>;
5452 def : ARMPat<(atomic_store_32 ldst_so_reg:$ptr, GPR:$val),
5453 (STRrs GPR:$val, ldst_so_reg:$ptr)>;
5454 def : ARMPat<(atomic_store_32 addrmode_imm12:$ptr, GPR:$val),
5455 (STRi12 GPR:$val, addrmode_imm12:$ptr)>;
5458 //===----------------------------------------------------------------------===//
5462 include "ARMInstrThumb.td"
5464 //===----------------------------------------------------------------------===//
5468 include "ARMInstrThumb2.td"
5470 //===----------------------------------------------------------------------===//
5471 // Floating Point Support
5474 include "ARMInstrVFP.td"
5476 //===----------------------------------------------------------------------===//
5477 // Advanced SIMD (NEON) Support
5480 include "ARMInstrNEON.td"
5482 //===----------------------------------------------------------------------===//
5483 // Assembler aliases
5487 def : InstAlias<"dmb", (DMB 0xf)>, Requires<[IsARM, HasDB]>;
5488 def : InstAlias<"dsb", (DSB 0xf)>, Requires<[IsARM, HasDB]>;
5489 def : InstAlias<"isb", (ISB 0xf)>, Requires<[IsARM, HasDB]>;
5491 // System instructions
5492 def : MnemonicAlias<"swi", "svc">;
5494 // Load / Store Multiple
5495 def : MnemonicAlias<"ldmfd", "ldm">;
5496 def : MnemonicAlias<"ldmia", "ldm">;
5497 def : MnemonicAlias<"ldmea", "ldmdb">;
5498 def : MnemonicAlias<"stmfd", "stmdb">;
5499 def : MnemonicAlias<"stmia", "stm">;
5500 def : MnemonicAlias<"stmea", "stm">;
5502 // PKHBT/PKHTB with default shift amount. PKHTB is equivalent to PKHBT when the
5503 // shift amount is zero (i.e., unspecified).
5504 def : InstAlias<"pkhbt${p} $Rd, $Rn, $Rm",
5505 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
5506 Requires<[IsARM, HasV6]>;
5507 def : InstAlias<"pkhtb${p} $Rd, $Rn, $Rm",
5508 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
5509 Requires<[IsARM, HasV6]>;
5511 // PUSH/POP aliases for STM/LDM
5512 def : ARMInstAlias<"push${p} $regs", (STMDB_UPD SP, pred:$p, reglist:$regs)>;
5513 def : ARMInstAlias<"pop${p} $regs", (LDMIA_UPD SP, pred:$p, reglist:$regs)>;
5515 // SSAT/USAT optional shift operand.
5516 def : ARMInstAlias<"ssat${p} $Rd, $sat_imm, $Rn",
5517 (SSAT GPRnopc:$Rd, imm1_32:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5518 def : ARMInstAlias<"usat${p} $Rd, $sat_imm, $Rn",
5519 (USAT GPRnopc:$Rd, imm0_31:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5522 // Extend instruction optional rotate operand.
5523 def : ARMInstAlias<"sxtab${p} $Rd, $Rn, $Rm",
5524 (SXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5525 def : ARMInstAlias<"sxtah${p} $Rd, $Rn, $Rm",
5526 (SXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5527 def : ARMInstAlias<"sxtab16${p} $Rd, $Rn, $Rm",
5528 (SXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5529 def : ARMInstAlias<"sxtb${p} $Rd, $Rm",
5530 (SXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5531 def : ARMInstAlias<"sxtb16${p} $Rd, $Rm",
5532 (SXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5533 def : ARMInstAlias<"sxth${p} $Rd, $Rm",
5534 (SXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5536 def : ARMInstAlias<"uxtab${p} $Rd, $Rn, $Rm",
5537 (UXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5538 def : ARMInstAlias<"uxtah${p} $Rd, $Rn, $Rm",
5539 (UXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5540 def : ARMInstAlias<"uxtab16${p} $Rd, $Rn, $Rm",
5541 (UXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5542 def : ARMInstAlias<"uxtb${p} $Rd, $Rm",
5543 (UXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5544 def : ARMInstAlias<"uxtb16${p} $Rd, $Rm",
5545 (UXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5546 def : ARMInstAlias<"uxth${p} $Rd, $Rm",
5547 (UXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5551 def : MnemonicAlias<"rfefa", "rfeda">;
5552 def : MnemonicAlias<"rfeea", "rfedb">;
5553 def : MnemonicAlias<"rfefd", "rfeia">;
5554 def : MnemonicAlias<"rfeed", "rfeib">;
5555 def : MnemonicAlias<"rfe", "rfeia">;
5558 def : MnemonicAlias<"srsfa", "srsib">;
5559 def : MnemonicAlias<"srsea", "srsia">;
5560 def : MnemonicAlias<"srsfd", "srsdb">;
5561 def : MnemonicAlias<"srsed", "srsda">;
5562 def : MnemonicAlias<"srs", "srsia">;
5565 def : MnemonicAlias<"qsubaddx", "qsax">;
5567 def : MnemonicAlias<"saddsubx", "sasx">;
5568 // SHASX == SHADDSUBX
5569 def : MnemonicAlias<"shaddsubx", "shasx">;
5570 // SHSAX == SHSUBADDX
5571 def : MnemonicAlias<"shsubaddx", "shsax">;
5573 def : MnemonicAlias<"ssubaddx", "ssax">;
5575 def : MnemonicAlias<"uaddsubx", "uasx">;
5576 // UHASX == UHADDSUBX
5577 def : MnemonicAlias<"uhaddsubx", "uhasx">;
5578 // UHSAX == UHSUBADDX
5579 def : MnemonicAlias<"uhsubaddx", "uhsax">;
5580 // UQASX == UQADDSUBX
5581 def : MnemonicAlias<"uqaddsubx", "uqasx">;
5582 // UQSAX == UQSUBADDX
5583 def : MnemonicAlias<"uqsubaddx", "uqsax">;
5585 def : MnemonicAlias<"usubaddx", "usax">;
5587 // "mov Rd, mod_imm_not" can be handled via "mvn" in assembly, just like
5589 def : ARMInstAlias<"mov${s}${p} $Rd, $imm",
5590 (MVNi rGPR:$Rd, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
5591 def : ARMInstAlias<"mvn${s}${p} $Rd, $imm",
5592 (MOVi rGPR:$Rd, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
5593 // Same for AND <--> BIC
5594 def : ARMInstAlias<"bic${s}${p} $Rd, $Rn, $imm",
5595 (ANDri rGPR:$Rd, rGPR:$Rn, mod_imm_not:$imm,
5596 pred:$p, cc_out:$s)>;
5597 def : ARMInstAlias<"bic${s}${p} $Rdn, $imm",
5598 (ANDri rGPR:$Rdn, rGPR:$Rdn, mod_imm_not:$imm,
5599 pred:$p, cc_out:$s)>;
5600 def : ARMInstAlias<"and${s}${p} $Rd, $Rn, $imm",
5601 (BICri rGPR:$Rd, rGPR:$Rn, mod_imm_not:$imm,
5602 pred:$p, cc_out:$s)>;
5603 def : ARMInstAlias<"and${s}${p} $Rdn, $imm",
5604 (BICri rGPR:$Rdn, rGPR:$Rdn, mod_imm_not:$imm,
5605 pred:$p, cc_out:$s)>;
5607 // Likewise, "add Rd, mod_imm_neg" -> sub
5608 def : ARMInstAlias<"add${s}${p} $Rd, $Rn, $imm",
5609 (SUBri GPR:$Rd, GPR:$Rn, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
5610 def : ARMInstAlias<"add${s}${p} $Rd, $imm",
5611 (SUBri GPR:$Rd, GPR:$Rd, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
5612 // Same for CMP <--> CMN via mod_imm_neg
5613 def : ARMInstAlias<"cmp${p} $Rd, $imm",
5614 (CMNri rGPR:$Rd, mod_imm_neg:$imm, pred:$p)>;
5615 def : ARMInstAlias<"cmn${p} $Rd, $imm",
5616 (CMPri rGPR:$Rd, mod_imm_neg:$imm, pred:$p)>;
5618 // The shifter forms of the MOV instruction are aliased to the ASR, LSL,
5619 // LSR, ROR, and RRX instructions.
5620 // FIXME: We need C++ parser hooks to map the alias to the MOV
5621 // encoding. It seems we should be able to do that sort of thing
5622 // in tblgen, but it could get ugly.
5623 let TwoOperandAliasConstraint = "$Rm = $Rd" in {
5624 def ASRi : ARMAsmPseudo<"asr${s}${p} $Rd, $Rm, $imm",
5625 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
5627 def LSRi : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rm, $imm",
5628 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
5630 def LSLi : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rm, $imm",
5631 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
5633 def RORi : ARMAsmPseudo<"ror${s}${p} $Rd, $Rm, $imm",
5634 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
5637 def RRXi : ARMAsmPseudo<"rrx${s}${p} $Rd, $Rm",
5638 (ins GPR:$Rd, GPR:$Rm, pred:$p, cc_out:$s)>;
5639 let TwoOperandAliasConstraint = "$Rn = $Rd" in {
5640 def ASRr : ARMAsmPseudo<"asr${s}${p} $Rd, $Rn, $Rm",
5641 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5643 def LSRr : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rn, $Rm",
5644 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5646 def LSLr : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rn, $Rm",
5647 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5649 def RORr : ARMAsmPseudo<"ror${s}${p} $Rd, $Rn, $Rm",
5650 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5654 // "neg" is and alias for "rsb rd, rn, #0"
5655 def : ARMInstAlias<"neg${s}${p} $Rd, $Rm",
5656 (RSBri GPR:$Rd, GPR:$Rm, 0, pred:$p, cc_out:$s)>;
5658 // Pre-v6, 'mov r0, r0' was used as a NOP encoding.
5659 def : InstAlias<"nop${p}", (MOVr R0, R0, pred:$p, zero_reg)>,
5660 Requires<[IsARM, NoV6]>;
5662 // MUL/UMLAL/SMLAL/UMULL/SMULL are available on all arches, but
5663 // the instruction definitions need difference constraints pre-v6.
5664 // Use these aliases for the assembly parsing on pre-v6.
5665 def : InstAlias<"mul${s}${p} $Rd, $Rn, $Rm",
5666 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s)>,
5667 Requires<[IsARM, NoV6]>;
5668 def : InstAlias<"mla${s}${p} $Rd, $Rn, $Rm, $Ra",
5669 (MLA GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra,
5670 pred:$p, cc_out:$s)>,
5671 Requires<[IsARM, NoV6]>;
5672 def : InstAlias<"smlal${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5673 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5674 Requires<[IsARM, NoV6]>;
5675 def : InstAlias<"umlal${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5676 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5677 Requires<[IsARM, NoV6]>;
5678 def : InstAlias<"smull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5679 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5680 Requires<[IsARM, NoV6]>;
5681 def : InstAlias<"umull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5682 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5683 Requires<[IsARM, NoV6]>;
5685 // 'it' blocks in ARM mode just validate the predicates. The IT itself
5687 def ITasm : ARMAsmPseudo<"it$mask $cc", (ins it_pred:$cc, it_mask:$mask)>,
5688 ComplexDeprecationPredicate<"IT">;
5690 let mayLoad = 1, mayStore =1, hasSideEffects = 1 in
5691 def SPACE : PseudoInst<(outs GPR:$Rd), (ins i32imm:$size, GPR:$Rn),
5693 [(set GPR:$Rd, (int_arm_space imm:$size, GPR:$Rn))]>;