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(), 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(), 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, MVT::i32);
349 def lo16AllZero : PatLeaf<(i32 imm), [{
350 // Returns true if all low 16-bits are 0.
351 return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
354 class BinOpWithFlagFrag<dag res> :
355 PatFrag<(ops node:$LHS, node:$RHS, node:$FLAG), res>;
356 class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
357 class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
359 // An 'and' node with a single use.
360 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
361 return N->hasOneUse();
364 // An 'xor' node with a single use.
365 def xor_su : PatFrag<(ops node:$lhs, node:$rhs), (xor node:$lhs, node:$rhs), [{
366 return N->hasOneUse();
369 // An 'fmul' node with a single use.
370 def fmul_su : PatFrag<(ops node:$lhs, node:$rhs), (fmul node:$lhs, node:$rhs),[{
371 return N->hasOneUse();
374 // An 'fadd' node which checks for single non-hazardous use.
375 def fadd_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fadd node:$lhs, node:$rhs),[{
376 return hasNoVMLxHazardUse(N);
379 // An 'fsub' node which checks for single non-hazardous use.
380 def fsub_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fsub node:$lhs, node:$rhs),[{
381 return hasNoVMLxHazardUse(N);
384 //===----------------------------------------------------------------------===//
385 // Operand Definitions.
388 // Immediate operands with a shared generic asm render method.
389 class ImmAsmOperand : AsmOperandClass { let RenderMethod = "addImmOperands"; }
391 // Operands that are part of a memory addressing mode.
392 class MemOperand : Operand<i32> { let OperandType = "OPERAND_MEMORY"; }
395 // FIXME: rename brtarget to t2_brtarget
396 def brtarget : Operand<OtherVT> {
397 let EncoderMethod = "getBranchTargetOpValue";
398 let OperandType = "OPERAND_PCREL";
399 let DecoderMethod = "DecodeT2BROperand";
402 // FIXME: get rid of this one?
403 def uncondbrtarget : Operand<OtherVT> {
404 let EncoderMethod = "getUnconditionalBranchTargetOpValue";
405 let OperandType = "OPERAND_PCREL";
408 // Branch target for ARM. Handles conditional/unconditional
409 def br_target : Operand<OtherVT> {
410 let EncoderMethod = "getARMBranchTargetOpValue";
411 let OperandType = "OPERAND_PCREL";
415 // FIXME: rename bltarget to t2_bl_target?
416 def bltarget : Operand<i32> {
417 // Encoded the same as branch targets.
418 let EncoderMethod = "getBranchTargetOpValue";
419 let OperandType = "OPERAND_PCREL";
422 // Call target for ARM. Handles conditional/unconditional
423 // FIXME: rename bl_target to t2_bltarget?
424 def bl_target : Operand<i32> {
425 let EncoderMethod = "getARMBLTargetOpValue";
426 let OperandType = "OPERAND_PCREL";
429 def blx_target : Operand<i32> {
430 let EncoderMethod = "getARMBLXTargetOpValue";
431 let OperandType = "OPERAND_PCREL";
434 // A list of registers separated by comma. Used by load/store multiple.
435 def RegListAsmOperand : AsmOperandClass { let Name = "RegList"; }
436 def reglist : Operand<i32> {
437 let EncoderMethod = "getRegisterListOpValue";
438 let ParserMatchClass = RegListAsmOperand;
439 let PrintMethod = "printRegisterList";
440 let DecoderMethod = "DecodeRegListOperand";
443 def GPRPairOp : RegisterOperand<GPRPair, "printGPRPairOperand">;
445 def DPRRegListAsmOperand : AsmOperandClass { let Name = "DPRRegList"; }
446 def dpr_reglist : Operand<i32> {
447 let EncoderMethod = "getRegisterListOpValue";
448 let ParserMatchClass = DPRRegListAsmOperand;
449 let PrintMethod = "printRegisterList";
450 let DecoderMethod = "DecodeDPRRegListOperand";
453 def SPRRegListAsmOperand : AsmOperandClass { let Name = "SPRRegList"; }
454 def spr_reglist : Operand<i32> {
455 let EncoderMethod = "getRegisterListOpValue";
456 let ParserMatchClass = SPRRegListAsmOperand;
457 let PrintMethod = "printRegisterList";
458 let DecoderMethod = "DecodeSPRRegListOperand";
461 // An operand for the CONSTPOOL_ENTRY pseudo-instruction.
462 def cpinst_operand : Operand<i32> {
463 let PrintMethod = "printCPInstOperand";
467 def pclabel : Operand<i32> {
468 let PrintMethod = "printPCLabel";
471 // ADR instruction labels.
472 def AdrLabelAsmOperand : AsmOperandClass { let Name = "AdrLabel"; }
473 def adrlabel : Operand<i32> {
474 let EncoderMethod = "getAdrLabelOpValue";
475 let ParserMatchClass = AdrLabelAsmOperand;
476 let PrintMethod = "printAdrLabelOperand<0>";
479 def neon_vcvt_imm32 : Operand<i32> {
480 let EncoderMethod = "getNEONVcvtImm32OpValue";
481 let DecoderMethod = "DecodeVCVTImmOperand";
484 // rot_imm: An integer that encodes a rotate amount. Must be 8, 16, or 24.
485 def rot_imm_XFORM: SDNodeXForm<imm, [{
486 switch (N->getZExtValue()){
487 default: llvm_unreachable(nullptr);
488 case 0: return CurDAG->getTargetConstant(0, MVT::i32);
489 case 8: return CurDAG->getTargetConstant(1, MVT::i32);
490 case 16: return CurDAG->getTargetConstant(2, MVT::i32);
491 case 24: return CurDAG->getTargetConstant(3, MVT::i32);
494 def RotImmAsmOperand : AsmOperandClass {
496 let ParserMethod = "parseRotImm";
498 def rot_imm : Operand<i32>, PatLeaf<(i32 imm), [{
499 int32_t v = N->getZExtValue();
500 return v == 8 || v == 16 || v == 24; }],
502 let PrintMethod = "printRotImmOperand";
503 let ParserMatchClass = RotImmAsmOperand;
506 // shift_imm: An integer that encodes a shift amount and the type of shift
507 // (asr or lsl). The 6-bit immediate encodes as:
510 // {4-0} imm5 shift amount.
511 // asr #32 encoded as imm5 == 0.
512 def ShifterImmAsmOperand : AsmOperandClass {
513 let Name = "ShifterImm";
514 let ParserMethod = "parseShifterImm";
516 def shift_imm : Operand<i32> {
517 let PrintMethod = "printShiftImmOperand";
518 let ParserMatchClass = ShifterImmAsmOperand;
521 // shifter_operand operands: so_reg_reg, so_reg_imm, and mod_imm.
522 def ShiftedRegAsmOperand : AsmOperandClass { let Name = "RegShiftedReg"; }
523 def so_reg_reg : Operand<i32>, // reg reg imm
524 ComplexPattern<i32, 3, "SelectRegShifterOperand",
525 [shl, srl, sra, rotr]> {
526 let EncoderMethod = "getSORegRegOpValue";
527 let PrintMethod = "printSORegRegOperand";
528 let DecoderMethod = "DecodeSORegRegOperand";
529 let ParserMatchClass = ShiftedRegAsmOperand;
530 let MIOperandInfo = (ops GPRnopc, GPRnopc, i32imm);
533 def ShiftedImmAsmOperand : AsmOperandClass { let Name = "RegShiftedImm"; }
534 def so_reg_imm : Operand<i32>, // reg imm
535 ComplexPattern<i32, 2, "SelectImmShifterOperand",
536 [shl, srl, sra, rotr]> {
537 let EncoderMethod = "getSORegImmOpValue";
538 let PrintMethod = "printSORegImmOperand";
539 let DecoderMethod = "DecodeSORegImmOperand";
540 let ParserMatchClass = ShiftedImmAsmOperand;
541 let MIOperandInfo = (ops GPR, i32imm);
544 // FIXME: Does this need to be distinct from so_reg?
545 def shift_so_reg_reg : Operand<i32>, // reg reg imm
546 ComplexPattern<i32, 3, "SelectShiftRegShifterOperand",
547 [shl,srl,sra,rotr]> {
548 let EncoderMethod = "getSORegRegOpValue";
549 let PrintMethod = "printSORegRegOperand";
550 let DecoderMethod = "DecodeSORegRegOperand";
551 let ParserMatchClass = ShiftedRegAsmOperand;
552 let MIOperandInfo = (ops GPR, GPR, i32imm);
555 // FIXME: Does this need to be distinct from so_reg?
556 def shift_so_reg_imm : Operand<i32>, // reg reg imm
557 ComplexPattern<i32, 2, "SelectShiftImmShifterOperand",
558 [shl,srl,sra,rotr]> {
559 let EncoderMethod = "getSORegImmOpValue";
560 let PrintMethod = "printSORegImmOperand";
561 let DecoderMethod = "DecodeSORegImmOperand";
562 let ParserMatchClass = ShiftedImmAsmOperand;
563 let MIOperandInfo = (ops GPR, i32imm);
566 // mod_imm: match a 32-bit immediate operand, which can be encoded into
567 // a 12-bit immediate; an 8-bit integer and a 4-bit rotator (See ARMARM
568 // - "Modified Immediate Constants"). Within the MC layer we keep this
569 // immediate in its encoded form.
570 def ModImmAsmOperand: AsmOperandClass {
572 let ParserMethod = "parseModImm";
574 def mod_imm : Operand<i32>, ImmLeaf<i32, [{
575 return ARM_AM::getSOImmVal(Imm) != -1;
577 let EncoderMethod = "getModImmOpValue";
578 let PrintMethod = "printModImmOperand";
579 let ParserMatchClass = ModImmAsmOperand;
582 // Note: the patterns mod_imm_not and mod_imm_neg do not require an encoder
583 // method and such, as they are only used on aliases (Pat<> and InstAlias<>).
584 // The actual parsing, encoding, decoding are handled by the destination
585 // instructions, which use mod_imm.
587 def ModImmNotAsmOperand : AsmOperandClass { let Name = "ModImmNot"; }
588 def mod_imm_not : Operand<i32>, PatLeaf<(imm), [{
589 return ARM_AM::getSOImmVal(~(uint32_t)N->getZExtValue()) != -1;
591 let ParserMatchClass = ModImmNotAsmOperand;
594 def ModImmNegAsmOperand : AsmOperandClass { let Name = "ModImmNeg"; }
595 def mod_imm_neg : Operand<i32>, PatLeaf<(imm), [{
596 unsigned Value = -(unsigned)N->getZExtValue();
597 return Value && ARM_AM::getSOImmVal(Value) != -1;
599 let ParserMatchClass = ModImmNegAsmOperand;
602 /// arm_i32imm - True for +V6T2, or when isSOImmTwoParVal()
603 def arm_i32imm : PatLeaf<(imm), [{
604 if (Subtarget->useMovt(*MF))
606 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
609 /// imm0_1 predicate - Immediate in the range [0,1].
610 def Imm0_1AsmOperand: ImmAsmOperand { let Name = "Imm0_1"; }
611 def imm0_1 : Operand<i32> { let ParserMatchClass = Imm0_1AsmOperand; }
613 /// imm0_3 predicate - Immediate in the range [0,3].
614 def Imm0_3AsmOperand: ImmAsmOperand { let Name = "Imm0_3"; }
615 def imm0_3 : Operand<i32> { let ParserMatchClass = Imm0_3AsmOperand; }
617 /// imm0_7 predicate - Immediate in the range [0,7].
618 def Imm0_7AsmOperand: ImmAsmOperand { let Name = "Imm0_7"; }
619 def imm0_7 : Operand<i32>, ImmLeaf<i32, [{
620 return Imm >= 0 && Imm < 8;
622 let ParserMatchClass = Imm0_7AsmOperand;
625 /// imm8 predicate - Immediate is exactly 8.
626 def Imm8AsmOperand: ImmAsmOperand { let Name = "Imm8"; }
627 def imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 8; }]> {
628 let ParserMatchClass = Imm8AsmOperand;
631 /// imm16 predicate - Immediate is exactly 16.
632 def Imm16AsmOperand: ImmAsmOperand { let Name = "Imm16"; }
633 def imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 16; }]> {
634 let ParserMatchClass = Imm16AsmOperand;
637 /// imm32 predicate - Immediate is exactly 32.
638 def Imm32AsmOperand: ImmAsmOperand { let Name = "Imm32"; }
639 def imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 32; }]> {
640 let ParserMatchClass = Imm32AsmOperand;
643 def imm8_or_16 : ImmLeaf<i32, [{ return Imm == 8 || Imm == 16;}]>;
645 /// imm1_7 predicate - Immediate in the range [1,7].
646 def Imm1_7AsmOperand: ImmAsmOperand { let Name = "Imm1_7"; }
647 def imm1_7 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 8; }]> {
648 let ParserMatchClass = Imm1_7AsmOperand;
651 /// imm1_15 predicate - Immediate in the range [1,15].
652 def Imm1_15AsmOperand: ImmAsmOperand { let Name = "Imm1_15"; }
653 def imm1_15 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 16; }]> {
654 let ParserMatchClass = Imm1_15AsmOperand;
657 /// imm1_31 predicate - Immediate in the range [1,31].
658 def Imm1_31AsmOperand: ImmAsmOperand { let Name = "Imm1_31"; }
659 def imm1_31 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 32; }]> {
660 let ParserMatchClass = Imm1_31AsmOperand;
663 /// imm0_15 predicate - Immediate in the range [0,15].
664 def Imm0_15AsmOperand: ImmAsmOperand {
665 let Name = "Imm0_15";
666 let DiagnosticType = "ImmRange0_15";
668 def imm0_15 : Operand<i32>, ImmLeaf<i32, [{
669 return Imm >= 0 && Imm < 16;
671 let ParserMatchClass = Imm0_15AsmOperand;
674 /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
675 def Imm0_31AsmOperand: ImmAsmOperand { let Name = "Imm0_31"; }
676 def imm0_31 : Operand<i32>, ImmLeaf<i32, [{
677 return Imm >= 0 && Imm < 32;
679 let ParserMatchClass = Imm0_31AsmOperand;
682 /// imm0_32 predicate - True if the 32-bit immediate is in the range [0,32].
683 def Imm0_32AsmOperand: ImmAsmOperand { let Name = "Imm0_32"; }
684 def imm0_32 : Operand<i32>, ImmLeaf<i32, [{
685 return Imm >= 0 && Imm < 32;
687 let ParserMatchClass = Imm0_32AsmOperand;
690 /// imm0_63 predicate - True if the 32-bit immediate is in the range [0,63].
691 def Imm0_63AsmOperand: ImmAsmOperand { let Name = "Imm0_63"; }
692 def imm0_63 : Operand<i32>, ImmLeaf<i32, [{
693 return Imm >= 0 && Imm < 64;
695 let ParserMatchClass = Imm0_63AsmOperand;
698 /// imm0_239 predicate - Immediate in the range [0,239].
699 def Imm0_239AsmOperand : ImmAsmOperand {
700 let Name = "Imm0_239";
701 let DiagnosticType = "ImmRange0_239";
703 def imm0_239 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 240; }]> {
704 let ParserMatchClass = Imm0_239AsmOperand;
707 /// imm0_255 predicate - Immediate in the range [0,255].
708 def Imm0_255AsmOperand : ImmAsmOperand { let Name = "Imm0_255"; }
709 def imm0_255 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 256; }]> {
710 let ParserMatchClass = Imm0_255AsmOperand;
713 /// imm0_65535 - An immediate is in the range [0.65535].
714 def Imm0_65535AsmOperand: ImmAsmOperand { let Name = "Imm0_65535"; }
715 def imm0_65535 : Operand<i32>, ImmLeaf<i32, [{
716 return Imm >= 0 && Imm < 65536;
718 let ParserMatchClass = Imm0_65535AsmOperand;
721 // imm0_65535_neg - An immediate whose negative value is in the range [0.65535].
722 def imm0_65535_neg : Operand<i32>, ImmLeaf<i32, [{
723 return -Imm >= 0 && -Imm < 65536;
726 // imm0_65535_expr - For movt/movw - 16-bit immediate that can also reference
727 // a relocatable expression.
729 // FIXME: This really needs a Thumb version separate from the ARM version.
730 // While the range is the same, and can thus use the same match class,
731 // the encoding is different so it should have a different encoder method.
732 def Imm0_65535ExprAsmOperand: ImmAsmOperand { let Name = "Imm0_65535Expr"; }
733 def imm0_65535_expr : Operand<i32> {
734 let EncoderMethod = "getHiLo16ImmOpValue";
735 let ParserMatchClass = Imm0_65535ExprAsmOperand;
738 def Imm256_65535ExprAsmOperand: ImmAsmOperand { let Name = "Imm256_65535Expr"; }
739 def imm256_65535_expr : Operand<i32> {
740 let ParserMatchClass = Imm256_65535ExprAsmOperand;
743 /// imm24b - True if the 32-bit immediate is encodable in 24 bits.
744 def Imm24bitAsmOperand: ImmAsmOperand { let Name = "Imm24bit"; }
745 def imm24b : Operand<i32>, ImmLeaf<i32, [{
746 return Imm >= 0 && Imm <= 0xffffff;
748 let ParserMatchClass = Imm24bitAsmOperand;
752 /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
754 def BitfieldAsmOperand : AsmOperandClass {
755 let Name = "Bitfield";
756 let ParserMethod = "parseBitfield";
759 def bf_inv_mask_imm : Operand<i32>,
761 return ARM::isBitFieldInvertedMask(N->getZExtValue());
763 let EncoderMethod = "getBitfieldInvertedMaskOpValue";
764 let PrintMethod = "printBitfieldInvMaskImmOperand";
765 let DecoderMethod = "DecodeBitfieldMaskOperand";
766 let ParserMatchClass = BitfieldAsmOperand;
769 def imm1_32_XFORM: SDNodeXForm<imm, [{
770 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, MVT::i32);
772 def Imm1_32AsmOperand: AsmOperandClass { let Name = "Imm1_32"; }
773 def imm1_32 : Operand<i32>, PatLeaf<(imm), [{
774 uint64_t Imm = N->getZExtValue();
775 return Imm > 0 && Imm <= 32;
778 let PrintMethod = "printImmPlusOneOperand";
779 let ParserMatchClass = Imm1_32AsmOperand;
782 def imm1_16_XFORM: SDNodeXForm<imm, [{
783 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, MVT::i32);
785 def Imm1_16AsmOperand: AsmOperandClass { let Name = "Imm1_16"; }
786 def imm1_16 : Operand<i32>, PatLeaf<(imm), [{ return Imm > 0 && Imm <= 16; }],
788 let PrintMethod = "printImmPlusOneOperand";
789 let ParserMatchClass = Imm1_16AsmOperand;
792 // Define ARM specific addressing modes.
793 // addrmode_imm12 := reg +/- imm12
795 def MemImm12OffsetAsmOperand : AsmOperandClass { let Name = "MemImm12Offset"; }
796 class AddrMode_Imm12 : MemOperand,
797 ComplexPattern<i32, 2, "SelectAddrModeImm12", []> {
798 // 12-bit immediate operand. Note that instructions using this encode
799 // #0 and #-0 differently. We flag #-0 as the magic value INT32_MIN. All other
800 // immediate values are as normal.
802 let EncoderMethod = "getAddrModeImm12OpValue";
803 let DecoderMethod = "DecodeAddrModeImm12Operand";
804 let ParserMatchClass = MemImm12OffsetAsmOperand;
805 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
808 def addrmode_imm12 : AddrMode_Imm12 {
809 let PrintMethod = "printAddrModeImm12Operand<false>";
812 def addrmode_imm12_pre : AddrMode_Imm12 {
813 let PrintMethod = "printAddrModeImm12Operand<true>";
816 // ldst_so_reg := reg +/- reg shop imm
818 def MemRegOffsetAsmOperand : AsmOperandClass { let Name = "MemRegOffset"; }
819 def ldst_so_reg : MemOperand,
820 ComplexPattern<i32, 3, "SelectLdStSOReg", []> {
821 let EncoderMethod = "getLdStSORegOpValue";
822 // FIXME: Simplify the printer
823 let PrintMethod = "printAddrMode2Operand";
824 let DecoderMethod = "DecodeSORegMemOperand";
825 let ParserMatchClass = MemRegOffsetAsmOperand;
826 let MIOperandInfo = (ops GPR:$base, GPRnopc:$offsreg, i32imm:$shift);
829 // postidx_imm8 := +/- [0,255]
832 // {8} 1 is imm8 is non-negative. 0 otherwise.
833 // {7-0} [0,255] imm8 value.
834 def PostIdxImm8AsmOperand : AsmOperandClass { let Name = "PostIdxImm8"; }
835 def postidx_imm8 : MemOperand {
836 let PrintMethod = "printPostIdxImm8Operand";
837 let ParserMatchClass = PostIdxImm8AsmOperand;
838 let MIOperandInfo = (ops i32imm);
841 // postidx_imm8s4 := +/- [0,1020]
844 // {8} 1 is imm8 is non-negative. 0 otherwise.
845 // {7-0} [0,255] imm8 value, scaled by 4.
846 def PostIdxImm8s4AsmOperand : AsmOperandClass { let Name = "PostIdxImm8s4"; }
847 def postidx_imm8s4 : MemOperand {
848 let PrintMethod = "printPostIdxImm8s4Operand";
849 let ParserMatchClass = PostIdxImm8s4AsmOperand;
850 let MIOperandInfo = (ops i32imm);
854 // postidx_reg := +/- reg
856 def PostIdxRegAsmOperand : AsmOperandClass {
857 let Name = "PostIdxReg";
858 let ParserMethod = "parsePostIdxReg";
860 def postidx_reg : MemOperand {
861 let EncoderMethod = "getPostIdxRegOpValue";
862 let DecoderMethod = "DecodePostIdxReg";
863 let PrintMethod = "printPostIdxRegOperand";
864 let ParserMatchClass = PostIdxRegAsmOperand;
865 let MIOperandInfo = (ops GPRnopc, i32imm);
869 // addrmode2 := reg +/- imm12
870 // := reg +/- reg shop imm
872 // FIXME: addrmode2 should be refactored the rest of the way to always
873 // use explicit imm vs. reg versions above (addrmode_imm12 and ldst_so_reg).
874 def AddrMode2AsmOperand : AsmOperandClass { let Name = "AddrMode2"; }
875 def addrmode2 : MemOperand,
876 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
877 let EncoderMethod = "getAddrMode2OpValue";
878 let PrintMethod = "printAddrMode2Operand";
879 let ParserMatchClass = AddrMode2AsmOperand;
880 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
883 def PostIdxRegShiftedAsmOperand : AsmOperandClass {
884 let Name = "PostIdxRegShifted";
885 let ParserMethod = "parsePostIdxReg";
887 def am2offset_reg : MemOperand,
888 ComplexPattern<i32, 2, "SelectAddrMode2OffsetReg",
889 [], [SDNPWantRoot]> {
890 let EncoderMethod = "getAddrMode2OffsetOpValue";
891 let PrintMethod = "printAddrMode2OffsetOperand";
892 // When using this for assembly, it's always as a post-index offset.
893 let ParserMatchClass = PostIdxRegShiftedAsmOperand;
894 let MIOperandInfo = (ops GPRnopc, i32imm);
897 // FIXME: am2offset_imm should only need the immediate, not the GPR. Having
898 // the GPR is purely vestigal at this point.
899 def AM2OffsetImmAsmOperand : AsmOperandClass { let Name = "AM2OffsetImm"; }
900 def am2offset_imm : MemOperand,
901 ComplexPattern<i32, 2, "SelectAddrMode2OffsetImm",
902 [], [SDNPWantRoot]> {
903 let EncoderMethod = "getAddrMode2OffsetOpValue";
904 let PrintMethod = "printAddrMode2OffsetOperand";
905 let ParserMatchClass = AM2OffsetImmAsmOperand;
906 let MIOperandInfo = (ops GPRnopc, i32imm);
910 // addrmode3 := reg +/- reg
911 // addrmode3 := reg +/- imm8
913 // FIXME: split into imm vs. reg versions.
914 def AddrMode3AsmOperand : AsmOperandClass { let Name = "AddrMode3"; }
915 class AddrMode3 : MemOperand,
916 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
917 let EncoderMethod = "getAddrMode3OpValue";
918 let ParserMatchClass = AddrMode3AsmOperand;
919 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
922 def addrmode3 : AddrMode3
924 let PrintMethod = "printAddrMode3Operand<false>";
927 def addrmode3_pre : AddrMode3
929 let PrintMethod = "printAddrMode3Operand<true>";
932 // FIXME: split into imm vs. reg versions.
933 // FIXME: parser method to handle +/- register.
934 def AM3OffsetAsmOperand : AsmOperandClass {
935 let Name = "AM3Offset";
936 let ParserMethod = "parseAM3Offset";
938 def am3offset : MemOperand,
939 ComplexPattern<i32, 2, "SelectAddrMode3Offset",
940 [], [SDNPWantRoot]> {
941 let EncoderMethod = "getAddrMode3OffsetOpValue";
942 let PrintMethod = "printAddrMode3OffsetOperand";
943 let ParserMatchClass = AM3OffsetAsmOperand;
944 let MIOperandInfo = (ops GPR, i32imm);
947 // ldstm_mode := {ia, ib, da, db}
949 def ldstm_mode : OptionalDefOperand<OtherVT, (ops i32), (ops (i32 1))> {
950 let EncoderMethod = "getLdStmModeOpValue";
951 let PrintMethod = "printLdStmModeOperand";
954 // addrmode5 := reg +/- imm8*4
956 def AddrMode5AsmOperand : AsmOperandClass { let Name = "AddrMode5"; }
957 class AddrMode5 : MemOperand,
958 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
959 let EncoderMethod = "getAddrMode5OpValue";
960 let DecoderMethod = "DecodeAddrMode5Operand";
961 let ParserMatchClass = AddrMode5AsmOperand;
962 let MIOperandInfo = (ops GPR:$base, i32imm);
965 def addrmode5 : AddrMode5 {
966 let PrintMethod = "printAddrMode5Operand<false>";
969 def addrmode5_pre : AddrMode5 {
970 let PrintMethod = "printAddrMode5Operand<true>";
973 // addrmode6 := reg with optional alignment
975 def AddrMode6AsmOperand : AsmOperandClass { let Name = "AlignedMemory"; }
976 def addrmode6 : MemOperand,
977 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
978 let PrintMethod = "printAddrMode6Operand";
979 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
980 let EncoderMethod = "getAddrMode6AddressOpValue";
981 let DecoderMethod = "DecodeAddrMode6Operand";
982 let ParserMatchClass = AddrMode6AsmOperand;
985 def am6offset : MemOperand,
986 ComplexPattern<i32, 1, "SelectAddrMode6Offset",
987 [], [SDNPWantRoot]> {
988 let PrintMethod = "printAddrMode6OffsetOperand";
989 let MIOperandInfo = (ops GPR);
990 let EncoderMethod = "getAddrMode6OffsetOpValue";
991 let DecoderMethod = "DecodeGPRRegisterClass";
994 // Special version of addrmode6 to handle alignment encoding for VST1/VLD1
995 // (single element from one lane) for size 32.
996 def addrmode6oneL32 : MemOperand,
997 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
998 let PrintMethod = "printAddrMode6Operand";
999 let MIOperandInfo = (ops GPR:$addr, i32imm);
1000 let EncoderMethod = "getAddrMode6OneLane32AddressOpValue";
1003 // Base class for addrmode6 with specific alignment restrictions.
1004 class AddrMode6Align : MemOperand,
1005 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1006 let PrintMethod = "printAddrMode6Operand";
1007 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
1008 let EncoderMethod = "getAddrMode6AddressOpValue";
1009 let DecoderMethod = "DecodeAddrMode6Operand";
1012 // Special version of addrmode6 to handle no allowed alignment encoding for
1013 // VLD/VST instructions and checking the alignment is not specified.
1014 def AddrMode6AlignNoneAsmOperand : AsmOperandClass {
1015 let Name = "AlignedMemoryNone";
1016 let DiagnosticType = "AlignedMemoryRequiresNone";
1018 def addrmode6alignNone : AddrMode6Align {
1019 // The alignment specifier can only be omitted.
1020 let ParserMatchClass = AddrMode6AlignNoneAsmOperand;
1023 // Special version of addrmode6 to handle 16-bit alignment encoding for
1024 // VLD/VST instructions and checking the alignment value.
1025 def AddrMode6Align16AsmOperand : AsmOperandClass {
1026 let Name = "AlignedMemory16";
1027 let DiagnosticType = "AlignedMemoryRequires16";
1029 def addrmode6align16 : AddrMode6Align {
1030 // The alignment specifier can only be 16 or omitted.
1031 let ParserMatchClass = AddrMode6Align16AsmOperand;
1034 // Special version of addrmode6 to handle 32-bit alignment encoding for
1035 // VLD/VST instructions and checking the alignment value.
1036 def AddrMode6Align32AsmOperand : AsmOperandClass {
1037 let Name = "AlignedMemory32";
1038 let DiagnosticType = "AlignedMemoryRequires32";
1040 def addrmode6align32 : AddrMode6Align {
1041 // The alignment specifier can only be 32 or omitted.
1042 let ParserMatchClass = AddrMode6Align32AsmOperand;
1045 // Special version of addrmode6 to handle 64-bit alignment encoding for
1046 // VLD/VST instructions and checking the alignment value.
1047 def AddrMode6Align64AsmOperand : AsmOperandClass {
1048 let Name = "AlignedMemory64";
1049 let DiagnosticType = "AlignedMemoryRequires64";
1051 def addrmode6align64 : AddrMode6Align {
1052 // The alignment specifier can only be 64 or omitted.
1053 let ParserMatchClass = AddrMode6Align64AsmOperand;
1056 // Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding
1057 // for VLD/VST instructions and checking the alignment value.
1058 def AddrMode6Align64or128AsmOperand : AsmOperandClass {
1059 let Name = "AlignedMemory64or128";
1060 let DiagnosticType = "AlignedMemoryRequires64or128";
1062 def addrmode6align64or128 : AddrMode6Align {
1063 // The alignment specifier can only be 64, 128 or omitted.
1064 let ParserMatchClass = AddrMode6Align64or128AsmOperand;
1067 // Special version of addrmode6 to handle 64-bit, 128-bit or 256-bit alignment
1068 // encoding for VLD/VST instructions and checking the alignment value.
1069 def AddrMode6Align64or128or256AsmOperand : AsmOperandClass {
1070 let Name = "AlignedMemory64or128or256";
1071 let DiagnosticType = "AlignedMemoryRequires64or128or256";
1073 def addrmode6align64or128or256 : AddrMode6Align {
1074 // The alignment specifier can only be 64, 128, 256 or omitted.
1075 let ParserMatchClass = AddrMode6Align64or128or256AsmOperand;
1078 // Special version of addrmode6 to handle alignment encoding for VLD-dup
1079 // instructions, specifically VLD4-dup.
1080 def addrmode6dup : MemOperand,
1081 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1082 let PrintMethod = "printAddrMode6Operand";
1083 let MIOperandInfo = (ops GPR:$addr, i32imm);
1084 let EncoderMethod = "getAddrMode6DupAddressOpValue";
1085 // FIXME: This is close, but not quite right. The alignment specifier is
1087 let ParserMatchClass = AddrMode6AsmOperand;
1090 // Base class for addrmode6dup with specific alignment restrictions.
1091 class AddrMode6DupAlign : MemOperand,
1092 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1093 let PrintMethod = "printAddrMode6Operand";
1094 let MIOperandInfo = (ops GPR:$addr, i32imm);
1095 let EncoderMethod = "getAddrMode6DupAddressOpValue";
1098 // Special version of addrmode6 to handle no allowed alignment encoding for
1099 // VLD-dup instruction and checking the alignment is not specified.
1100 def AddrMode6dupAlignNoneAsmOperand : AsmOperandClass {
1101 let Name = "DupAlignedMemoryNone";
1102 let DiagnosticType = "DupAlignedMemoryRequiresNone";
1104 def addrmode6dupalignNone : AddrMode6DupAlign {
1105 // The alignment specifier can only be omitted.
1106 let ParserMatchClass = AddrMode6dupAlignNoneAsmOperand;
1109 // Special version of addrmode6 to handle 16-bit alignment encoding for VLD-dup
1110 // instruction and checking the alignment value.
1111 def AddrMode6dupAlign16AsmOperand : AsmOperandClass {
1112 let Name = "DupAlignedMemory16";
1113 let DiagnosticType = "DupAlignedMemoryRequires16";
1115 def addrmode6dupalign16 : AddrMode6DupAlign {
1116 // The alignment specifier can only be 16 or omitted.
1117 let ParserMatchClass = AddrMode6dupAlign16AsmOperand;
1120 // Special version of addrmode6 to handle 32-bit alignment encoding for VLD-dup
1121 // instruction and checking the alignment value.
1122 def AddrMode6dupAlign32AsmOperand : AsmOperandClass {
1123 let Name = "DupAlignedMemory32";
1124 let DiagnosticType = "DupAlignedMemoryRequires32";
1126 def addrmode6dupalign32 : AddrMode6DupAlign {
1127 // The alignment specifier can only be 32 or omitted.
1128 let ParserMatchClass = AddrMode6dupAlign32AsmOperand;
1131 // Special version of addrmode6 to handle 64-bit alignment encoding for VLD
1132 // instructions and checking the alignment value.
1133 def AddrMode6dupAlign64AsmOperand : AsmOperandClass {
1134 let Name = "DupAlignedMemory64";
1135 let DiagnosticType = "DupAlignedMemoryRequires64";
1137 def addrmode6dupalign64 : AddrMode6DupAlign {
1138 // The alignment specifier can only be 64 or omitted.
1139 let ParserMatchClass = AddrMode6dupAlign64AsmOperand;
1142 // Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding
1143 // for VLD instructions and checking the alignment value.
1144 def AddrMode6dupAlign64or128AsmOperand : AsmOperandClass {
1145 let Name = "DupAlignedMemory64or128";
1146 let DiagnosticType = "DupAlignedMemoryRequires64or128";
1148 def addrmode6dupalign64or128 : AddrMode6DupAlign {
1149 // The alignment specifier can only be 64, 128 or omitted.
1150 let ParserMatchClass = AddrMode6dupAlign64or128AsmOperand;
1153 // addrmodepc := pc + reg
1155 def addrmodepc : MemOperand,
1156 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
1157 let PrintMethod = "printAddrModePCOperand";
1158 let MIOperandInfo = (ops GPR, i32imm);
1161 // addr_offset_none := reg
1163 def MemNoOffsetAsmOperand : AsmOperandClass { let Name = "MemNoOffset"; }
1164 def addr_offset_none : MemOperand,
1165 ComplexPattern<i32, 1, "SelectAddrOffsetNone", []> {
1166 let PrintMethod = "printAddrMode7Operand";
1167 let DecoderMethod = "DecodeAddrMode7Operand";
1168 let ParserMatchClass = MemNoOffsetAsmOperand;
1169 let MIOperandInfo = (ops GPR:$base);
1172 def nohash_imm : Operand<i32> {
1173 let PrintMethod = "printNoHashImmediate";
1176 def CoprocNumAsmOperand : AsmOperandClass {
1177 let Name = "CoprocNum";
1178 let ParserMethod = "parseCoprocNumOperand";
1180 def p_imm : Operand<i32> {
1181 let PrintMethod = "printPImmediate";
1182 let ParserMatchClass = CoprocNumAsmOperand;
1183 let DecoderMethod = "DecodeCoprocessor";
1186 def CoprocRegAsmOperand : AsmOperandClass {
1187 let Name = "CoprocReg";
1188 let ParserMethod = "parseCoprocRegOperand";
1190 def c_imm : Operand<i32> {
1191 let PrintMethod = "printCImmediate";
1192 let ParserMatchClass = CoprocRegAsmOperand;
1194 def CoprocOptionAsmOperand : AsmOperandClass {
1195 let Name = "CoprocOption";
1196 let ParserMethod = "parseCoprocOptionOperand";
1198 def coproc_option_imm : Operand<i32> {
1199 let PrintMethod = "printCoprocOptionImm";
1200 let ParserMatchClass = CoprocOptionAsmOperand;
1203 //===----------------------------------------------------------------------===//
1205 include "ARMInstrFormats.td"
1207 //===----------------------------------------------------------------------===//
1208 // Multiclass helpers...
1211 /// AsI1_bin_irs - Defines a set of (op r, {mod_imm|r|so_reg}) patterns for a
1212 /// binop that produces a value.
1213 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1214 multiclass AsI1_bin_irs<bits<4> opcod, string opc,
1215 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1216 PatFrag opnode, bit Commutable = 0> {
1217 // The register-immediate version is re-materializable. This is useful
1218 // in particular for taking the address of a local.
1219 let isReMaterializable = 1 in {
1220 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm,
1221 iii, opc, "\t$Rd, $Rn, $imm",
1222 [(set GPR:$Rd, (opnode GPR:$Rn, mod_imm:$imm))]>,
1223 Sched<[WriteALU, ReadALU]> {
1228 let Inst{19-16} = Rn;
1229 let Inst{15-12} = Rd;
1230 let Inst{11-0} = imm;
1233 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1234 iir, opc, "\t$Rd, $Rn, $Rm",
1235 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]>,
1236 Sched<[WriteALU, ReadALU, ReadALU]> {
1241 let isCommutable = Commutable;
1242 let Inst{19-16} = Rn;
1243 let Inst{15-12} = Rd;
1244 let Inst{11-4} = 0b00000000;
1248 def rsi : AsI1<opcod, (outs GPR:$Rd),
1249 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1250 iis, opc, "\t$Rd, $Rn, $shift",
1251 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_imm:$shift))]>,
1252 Sched<[WriteALUsi, ReadALU]> {
1257 let Inst{19-16} = Rn;
1258 let Inst{15-12} = Rd;
1259 let Inst{11-5} = shift{11-5};
1261 let Inst{3-0} = shift{3-0};
1264 def rsr : AsI1<opcod, (outs GPR:$Rd),
1265 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1266 iis, opc, "\t$Rd, $Rn, $shift",
1267 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_reg:$shift))]>,
1268 Sched<[WriteALUsr, ReadALUsr]> {
1273 let Inst{19-16} = Rn;
1274 let Inst{15-12} = Rd;
1275 let Inst{11-8} = shift{11-8};
1277 let Inst{6-5} = shift{6-5};
1279 let Inst{3-0} = shift{3-0};
1283 /// AsI1_rbin_irs - Same as AsI1_bin_irs except the order of operands are
1284 /// reversed. The 'rr' form is only defined for the disassembler; for codegen
1285 /// it is equivalent to the AsI1_bin_irs counterpart.
1286 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1287 multiclass AsI1_rbin_irs<bits<4> opcod, string opc,
1288 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1289 PatFrag opnode, bit Commutable = 0> {
1290 // The register-immediate version is re-materializable. This is useful
1291 // in particular for taking the address of a local.
1292 let isReMaterializable = 1 in {
1293 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm,
1294 iii, opc, "\t$Rd, $Rn, $imm",
1295 [(set GPR:$Rd, (opnode mod_imm:$imm, GPR:$Rn))]>,
1296 Sched<[WriteALU, ReadALU]> {
1301 let Inst{19-16} = Rn;
1302 let Inst{15-12} = Rd;
1303 let Inst{11-0} = imm;
1306 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1307 iir, opc, "\t$Rd, $Rn, $Rm",
1308 [/* pattern left blank */]>,
1309 Sched<[WriteALU, ReadALU, ReadALU]> {
1313 let Inst{11-4} = 0b00000000;
1316 let Inst{15-12} = Rd;
1317 let Inst{19-16} = Rn;
1320 def rsi : AsI1<opcod, (outs GPR:$Rd),
1321 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1322 iis, opc, "\t$Rd, $Rn, $shift",
1323 [(set GPR:$Rd, (opnode so_reg_imm:$shift, GPR:$Rn))]>,
1324 Sched<[WriteALUsi, ReadALU]> {
1329 let Inst{19-16} = Rn;
1330 let Inst{15-12} = Rd;
1331 let Inst{11-5} = shift{11-5};
1333 let Inst{3-0} = shift{3-0};
1336 def rsr : AsI1<opcod, (outs GPR:$Rd),
1337 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1338 iis, opc, "\t$Rd, $Rn, $shift",
1339 [(set GPR:$Rd, (opnode so_reg_reg:$shift, GPR:$Rn))]>,
1340 Sched<[WriteALUsr, ReadALUsr]> {
1345 let Inst{19-16} = Rn;
1346 let Inst{15-12} = Rd;
1347 let Inst{11-8} = shift{11-8};
1349 let Inst{6-5} = shift{6-5};
1351 let Inst{3-0} = shift{3-0};
1355 /// AsI1_bin_s_irs - Same as AsI1_bin_irs except it sets the 's' bit by default.
1357 /// These opcodes will be converted to the real non-S opcodes by
1358 /// AdjustInstrPostInstrSelection after giving them an optional CPSR operand.
1359 let hasPostISelHook = 1, Defs = [CPSR] in {
1360 multiclass AsI1_bin_s_irs<InstrItinClass iii, InstrItinClass iir,
1361 InstrItinClass iis, PatFrag opnode,
1362 bit Commutable = 0> {
1363 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p),
1365 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm))]>,
1366 Sched<[WriteALU, ReadALU]>;
1368 def rr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, pred:$p),
1370 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm))]>,
1371 Sched<[WriteALU, ReadALU, ReadALU]> {
1372 let isCommutable = Commutable;
1374 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1375 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1377 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1378 so_reg_imm:$shift))]>,
1379 Sched<[WriteALUsi, ReadALU]>;
1381 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1382 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1384 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1385 so_reg_reg:$shift))]>,
1386 Sched<[WriteALUSsr, ReadALUsr]>;
1390 /// AsI1_rbin_s_is - Same as AsI1_bin_s_irs, except selection DAG
1391 /// operands are reversed.
1392 let hasPostISelHook = 1, Defs = [CPSR] in {
1393 multiclass AsI1_rbin_s_is<InstrItinClass iii, InstrItinClass iir,
1394 InstrItinClass iis, PatFrag opnode,
1395 bit Commutable = 0> {
1396 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p),
1398 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn))]>,
1399 Sched<[WriteALU, ReadALU]>;
1401 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1402 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1404 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift,
1406 Sched<[WriteALUsi, ReadALU]>;
1408 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1409 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1411 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift,
1413 Sched<[WriteALUSsr, ReadALUsr]>;
1417 /// AI1_cmp_irs - Defines a set of (op r, {mod_imm|r|so_reg}) cmp / test
1418 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
1419 /// a explicit result, only implicitly set CPSR.
1420 let isCompare = 1, Defs = [CPSR] in {
1421 multiclass AI1_cmp_irs<bits<4> opcod, string opc,
1422 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1423 PatFrag opnode, bit Commutable = 0> {
1424 def ri : AI1<opcod, (outs), (ins GPR:$Rn, mod_imm:$imm), DPFrm, iii,
1426 [(opnode GPR:$Rn, mod_imm:$imm)]>,
1427 Sched<[WriteCMP, ReadALU]> {
1432 let Inst{19-16} = Rn;
1433 let Inst{15-12} = 0b0000;
1434 let Inst{11-0} = imm;
1436 let Unpredictable{15-12} = 0b1111;
1438 def rr : AI1<opcod, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, iir,
1440 [(opnode GPR:$Rn, GPR:$Rm)]>,
1441 Sched<[WriteCMP, ReadALU, ReadALU]> {
1444 let isCommutable = Commutable;
1447 let Inst{19-16} = Rn;
1448 let Inst{15-12} = 0b0000;
1449 let Inst{11-4} = 0b00000000;
1452 let Unpredictable{15-12} = 0b1111;
1454 def rsi : AI1<opcod, (outs),
1455 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, iis,
1456 opc, "\t$Rn, $shift",
1457 [(opnode GPR:$Rn, so_reg_imm:$shift)]>,
1458 Sched<[WriteCMPsi, ReadALU]> {
1463 let Inst{19-16} = Rn;
1464 let Inst{15-12} = 0b0000;
1465 let Inst{11-5} = shift{11-5};
1467 let Inst{3-0} = shift{3-0};
1469 let Unpredictable{15-12} = 0b1111;
1471 def rsr : AI1<opcod, (outs),
1472 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, iis,
1473 opc, "\t$Rn, $shift",
1474 [(opnode GPRnopc:$Rn, so_reg_reg:$shift)]>,
1475 Sched<[WriteCMPsr, ReadALU]> {
1480 let Inst{19-16} = Rn;
1481 let Inst{15-12} = 0b0000;
1482 let Inst{11-8} = shift{11-8};
1484 let Inst{6-5} = shift{6-5};
1486 let Inst{3-0} = shift{3-0};
1488 let Unpredictable{15-12} = 0b1111;
1494 /// AI_ext_rrot - A unary operation with two forms: one whose operand is a
1495 /// register and one whose operand is a register rotated by 8/16/24.
1496 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
1497 class AI_ext_rrot<bits<8> opcod, string opc, PatFrag opnode>
1498 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1499 IIC_iEXTr, opc, "\t$Rd, $Rm$rot",
1500 [(set GPRnopc:$Rd, (opnode (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1501 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> {
1505 let Inst{19-16} = 0b1111;
1506 let Inst{15-12} = Rd;
1507 let Inst{11-10} = rot;
1511 class AI_ext_rrot_np<bits<8> opcod, string opc>
1512 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1513 IIC_iEXTr, opc, "\t$Rd, $Rm$rot", []>,
1514 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> {
1516 let Inst{19-16} = 0b1111;
1517 let Inst{11-10} = rot;
1520 /// AI_exta_rrot - A binary operation with two forms: one whose operand is a
1521 /// register and one whose operand is a register rotated by 8/16/24.
1522 class AI_exta_rrot<bits<8> opcod, string opc, PatFrag opnode>
1523 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1524 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot",
1525 [(set GPRnopc:$Rd, (opnode GPR:$Rn,
1526 (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1527 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> {
1532 let Inst{19-16} = Rn;
1533 let Inst{15-12} = Rd;
1534 let Inst{11-10} = rot;
1535 let Inst{9-4} = 0b000111;
1539 class AI_exta_rrot_np<bits<8> opcod, string opc>
1540 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1541 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot", []>,
1542 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> {
1545 let Inst{19-16} = Rn;
1546 let Inst{11-10} = rot;
1549 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
1550 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1551 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
1552 bit Commutable = 0> {
1553 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1554 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm),
1555 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1556 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm, CPSR))]>,
1558 Sched<[WriteALU, ReadALU]> {
1563 let Inst{15-12} = Rd;
1564 let Inst{19-16} = Rn;
1565 let Inst{11-0} = imm;
1567 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1568 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1569 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm, CPSR))]>,
1571 Sched<[WriteALU, ReadALU, ReadALU]> {
1575 let Inst{11-4} = 0b00000000;
1577 let isCommutable = Commutable;
1579 let Inst{15-12} = Rd;
1580 let Inst{19-16} = Rn;
1582 def rsi : AsI1<opcod, (outs GPR:$Rd),
1583 (ins GPR:$Rn, so_reg_imm:$shift),
1584 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1585 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_imm:$shift, CPSR))]>,
1587 Sched<[WriteALUsi, ReadALU]> {
1592 let Inst{19-16} = Rn;
1593 let Inst{15-12} = Rd;
1594 let Inst{11-5} = shift{11-5};
1596 let Inst{3-0} = shift{3-0};
1598 def rsr : AsI1<opcod, (outs GPRnopc:$Rd),
1599 (ins GPRnopc:$Rn, so_reg_reg:$shift),
1600 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1601 [(set GPRnopc:$Rd, CPSR,
1602 (opnode GPRnopc:$Rn, so_reg_reg:$shift, CPSR))]>,
1604 Sched<[WriteALUsr, ReadALUsr]> {
1609 let Inst{19-16} = Rn;
1610 let Inst{15-12} = Rd;
1611 let Inst{11-8} = shift{11-8};
1613 let Inst{6-5} = shift{6-5};
1615 let Inst{3-0} = shift{3-0};
1620 /// AI1_rsc_irs - Define instructions and patterns for rsc
1621 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1622 multiclass AI1_rsc_irs<bits<4> opcod, string opc, PatFrag opnode> {
1623 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1624 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm),
1625 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1626 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn, CPSR))]>,
1628 Sched<[WriteALU, ReadALU]> {
1633 let Inst{15-12} = Rd;
1634 let Inst{19-16} = Rn;
1635 let Inst{11-0} = imm;
1637 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1638 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1639 [/* pattern left blank */]>,
1640 Sched<[WriteALU, ReadALU, ReadALU]> {
1644 let Inst{11-4} = 0b00000000;
1647 let Inst{15-12} = Rd;
1648 let Inst{19-16} = Rn;
1650 def rsi : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_imm:$shift),
1651 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1652 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift, GPR:$Rn, CPSR))]>,
1654 Sched<[WriteALUsi, ReadALU]> {
1659 let Inst{19-16} = Rn;
1660 let Inst{15-12} = Rd;
1661 let Inst{11-5} = shift{11-5};
1663 let Inst{3-0} = shift{3-0};
1665 def rsr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_reg:$shift),
1666 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1667 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift, GPR:$Rn, CPSR))]>,
1669 Sched<[WriteALUsr, ReadALUsr]> {
1674 let Inst{19-16} = Rn;
1675 let Inst{15-12} = Rd;
1676 let Inst{11-8} = shift{11-8};
1678 let Inst{6-5} = shift{6-5};
1680 let Inst{3-0} = shift{3-0};
1685 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1686 multiclass AI_ldr1<bit isByte, string opc, InstrItinClass iii,
1687 InstrItinClass iir, PatFrag opnode> {
1688 // Note: We use the complex addrmode_imm12 rather than just an input
1689 // GPR and a constrained immediate so that we can use this to match
1690 // frame index references and avoid matching constant pool references.
1691 def i12: AI2ldst<0b010, 1, isByte, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
1692 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1693 [(set GPR:$Rt, (opnode addrmode_imm12:$addr))]> {
1696 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1697 let Inst{19-16} = addr{16-13}; // Rn
1698 let Inst{15-12} = Rt;
1699 let Inst{11-0} = addr{11-0}; // imm12
1701 def rs : AI2ldst<0b011, 1, isByte, (outs GPR:$Rt), (ins ldst_so_reg:$shift),
1702 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1703 [(set GPR:$Rt, (opnode ldst_so_reg:$shift))]> {
1706 let shift{4} = 0; // Inst{4} = 0
1707 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1708 let Inst{19-16} = shift{16-13}; // Rn
1709 let Inst{15-12} = Rt;
1710 let Inst{11-0} = shift{11-0};
1715 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1716 multiclass AI_ldr1nopc<bit isByte, string opc, InstrItinClass iii,
1717 InstrItinClass iir, PatFrag opnode> {
1718 // Note: We use the complex addrmode_imm12 rather than just an input
1719 // GPR and a constrained immediate so that we can use this to match
1720 // frame index references and avoid matching constant pool references.
1721 def i12: AI2ldst<0b010, 1, isByte, (outs GPRnopc:$Rt),
1722 (ins addrmode_imm12:$addr),
1723 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1724 [(set GPRnopc:$Rt, (opnode addrmode_imm12:$addr))]> {
1727 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1728 let Inst{19-16} = addr{16-13}; // Rn
1729 let Inst{15-12} = Rt;
1730 let Inst{11-0} = addr{11-0}; // imm12
1732 def rs : AI2ldst<0b011, 1, isByte, (outs GPRnopc:$Rt),
1733 (ins ldst_so_reg:$shift),
1734 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1735 [(set GPRnopc:$Rt, (opnode ldst_so_reg:$shift))]> {
1738 let shift{4} = 0; // Inst{4} = 0
1739 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1740 let Inst{19-16} = shift{16-13}; // Rn
1741 let Inst{15-12} = Rt;
1742 let Inst{11-0} = shift{11-0};
1748 multiclass AI_str1<bit isByte, string opc, InstrItinClass iii,
1749 InstrItinClass iir, PatFrag opnode> {
1750 // Note: We use the complex addrmode_imm12 rather than just an input
1751 // GPR and a constrained immediate so that we can use this to match
1752 // frame index references and avoid matching constant pool references.
1753 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1754 (ins GPR:$Rt, addrmode_imm12:$addr),
1755 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1756 [(opnode GPR:$Rt, addrmode_imm12:$addr)]> {
1759 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1760 let Inst{19-16} = addr{16-13}; // Rn
1761 let Inst{15-12} = Rt;
1762 let Inst{11-0} = addr{11-0}; // imm12
1764 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPR:$Rt, ldst_so_reg:$shift),
1765 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1766 [(opnode GPR:$Rt, ldst_so_reg:$shift)]> {
1769 let shift{4} = 0; // Inst{4} = 0
1770 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1771 let Inst{19-16} = shift{16-13}; // Rn
1772 let Inst{15-12} = Rt;
1773 let Inst{11-0} = shift{11-0};
1777 multiclass AI_str1nopc<bit isByte, string opc, InstrItinClass iii,
1778 InstrItinClass iir, PatFrag opnode> {
1779 // Note: We use the complex addrmode_imm12 rather than just an input
1780 // GPR and a constrained immediate so that we can use this to match
1781 // frame index references and avoid matching constant pool references.
1782 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1783 (ins GPRnopc:$Rt, addrmode_imm12:$addr),
1784 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1785 [(opnode GPRnopc:$Rt, addrmode_imm12:$addr)]> {
1788 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1789 let Inst{19-16} = addr{16-13}; // Rn
1790 let Inst{15-12} = Rt;
1791 let Inst{11-0} = addr{11-0}; // imm12
1793 def rs : AI2ldst<0b011, 0, isByte, (outs),
1794 (ins GPRnopc:$Rt, ldst_so_reg:$shift),
1795 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1796 [(opnode GPRnopc:$Rt, ldst_so_reg:$shift)]> {
1799 let shift{4} = 0; // Inst{4} = 0
1800 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1801 let Inst{19-16} = shift{16-13}; // Rn
1802 let Inst{15-12} = Rt;
1803 let Inst{11-0} = shift{11-0};
1808 //===----------------------------------------------------------------------===//
1810 //===----------------------------------------------------------------------===//
1812 //===----------------------------------------------------------------------===//
1813 // Miscellaneous Instructions.
1816 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
1817 /// the function. The first operand is the ID# for this instruction, the second
1818 /// is the index into the MachineConstantPool that this is, the third is the
1819 /// size in bytes of this constant pool entry.
1820 let hasSideEffects = 0, isNotDuplicable = 1 in
1821 def CONSTPOOL_ENTRY :
1822 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1823 i32imm:$size), NoItinerary, []>;
1825 // FIXME: Marking these as hasSideEffects is necessary to prevent machine DCE
1826 // from removing one half of the matched pairs. That breaks PEI, which assumes
1827 // these will always be in pairs, and asserts if it finds otherwise. Better way?
1828 let Defs = [SP], Uses = [SP], hasSideEffects = 1 in {
1829 def ADJCALLSTACKUP :
1830 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary,
1831 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
1833 def ADJCALLSTACKDOWN :
1834 PseudoInst<(outs), (ins i32imm:$amt, pred:$p), NoItinerary,
1835 [(ARMcallseq_start timm:$amt)]>;
1838 def HINT : AI<(outs), (ins imm0_239:$imm), MiscFrm, NoItinerary,
1839 "hint", "\t$imm", [(int_arm_hint imm0_239:$imm)]>,
1840 Requires<[IsARM, HasV6]> {
1842 let Inst{27-8} = 0b00110010000011110000;
1843 let Inst{7-0} = imm;
1846 def : InstAlias<"nop$p", (HINT 0, pred:$p)>, Requires<[IsARM, HasV6K]>;
1847 def : InstAlias<"yield$p", (HINT 1, pred:$p)>, Requires<[IsARM, HasV6K]>;
1848 def : InstAlias<"wfe$p", (HINT 2, pred:$p)>, Requires<[IsARM, HasV6K]>;
1849 def : InstAlias<"wfi$p", (HINT 3, pred:$p)>, Requires<[IsARM, HasV6K]>;
1850 def : InstAlias<"sev$p", (HINT 4, pred:$p)>, Requires<[IsARM, HasV6K]>;
1851 def : InstAlias<"sevl$p", (HINT 5, pred:$p)>, Requires<[IsARM, HasV8]>;
1853 def SEL : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, NoItinerary, "sel",
1854 "\t$Rd, $Rn, $Rm", []>, Requires<[IsARM, HasV6]> {
1859 let Inst{15-12} = Rd;
1860 let Inst{19-16} = Rn;
1861 let Inst{27-20} = 0b01101000;
1862 let Inst{7-4} = 0b1011;
1863 let Inst{11-8} = 0b1111;
1864 let Unpredictable{11-8} = 0b1111;
1867 // The 16-bit operand $val can be used by a debugger to store more information
1868 // about the breakpoint.
1869 def BKPT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
1870 "bkpt", "\t$val", []>, Requires<[IsARM]> {
1872 let Inst{3-0} = val{3-0};
1873 let Inst{19-8} = val{15-4};
1874 let Inst{27-20} = 0b00010010;
1875 let Inst{31-28} = 0xe; // AL
1876 let Inst{7-4} = 0b0111;
1878 // default immediate for breakpoint mnemonic
1879 def : InstAlias<"bkpt", (BKPT 0)>, Requires<[IsARM]>;
1881 def HLT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
1882 "hlt", "\t$val", []>, Requires<[IsARM, HasV8]> {
1884 let Inst{3-0} = val{3-0};
1885 let Inst{19-8} = val{15-4};
1886 let Inst{27-20} = 0b00010000;
1887 let Inst{31-28} = 0xe; // AL
1888 let Inst{7-4} = 0b0111;
1891 // Change Processor State
1892 // FIXME: We should use InstAlias to handle the optional operands.
1893 class CPS<dag iops, string asm_ops>
1894 : AXI<(outs), iops, MiscFrm, NoItinerary, !strconcat("cps", asm_ops),
1895 []>, Requires<[IsARM]> {
1901 let Inst{31-28} = 0b1111;
1902 let Inst{27-20} = 0b00010000;
1903 let Inst{19-18} = imod;
1904 let Inst{17} = M; // Enabled if mode is set;
1905 let Inst{16-9} = 0b00000000;
1906 let Inst{8-6} = iflags;
1908 let Inst{4-0} = mode;
1911 let DecoderMethod = "DecodeCPSInstruction" in {
1913 def CPS3p : CPS<(ins imod_op:$imod, iflags_op:$iflags, imm0_31:$mode),
1914 "$imod\t$iflags, $mode">;
1915 let mode = 0, M = 0 in
1916 def CPS2p : CPS<(ins imod_op:$imod, iflags_op:$iflags), "$imod\t$iflags">;
1918 let imod = 0, iflags = 0, M = 1 in
1919 def CPS1p : CPS<(ins imm0_31:$mode), "\t$mode">;
1922 // Preload signals the memory system of possible future data/instruction access.
1923 multiclass APreLoad<bits<1> read, bits<1> data, string opc> {
1925 def i12 : AXIM<(outs), (ins addrmode_imm12:$addr), AddrMode_i12, MiscFrm,
1926 IIC_Preload, !strconcat(opc, "\t$addr"),
1927 [(ARMPreload addrmode_imm12:$addr, (i32 read), (i32 data))]>,
1928 Sched<[WritePreLd]> {
1931 let Inst{31-26} = 0b111101;
1932 let Inst{25} = 0; // 0 for immediate form
1933 let Inst{24} = data;
1934 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1935 let Inst{22} = read;
1936 let Inst{21-20} = 0b01;
1937 let Inst{19-16} = addr{16-13}; // Rn
1938 let Inst{15-12} = 0b1111;
1939 let Inst{11-0} = addr{11-0}; // imm12
1942 def rs : AXI<(outs), (ins ldst_so_reg:$shift), MiscFrm, IIC_Preload,
1943 !strconcat(opc, "\t$shift"),
1944 [(ARMPreload ldst_so_reg:$shift, (i32 read), (i32 data))]>,
1945 Sched<[WritePreLd]> {
1947 let Inst{31-26} = 0b111101;
1948 let Inst{25} = 1; // 1 for register form
1949 let Inst{24} = data;
1950 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1951 let Inst{22} = read;
1952 let Inst{21-20} = 0b01;
1953 let Inst{19-16} = shift{16-13}; // Rn
1954 let Inst{15-12} = 0b1111;
1955 let Inst{11-0} = shift{11-0};
1960 defm PLD : APreLoad<1, 1, "pld">, Requires<[IsARM]>;
1961 defm PLDW : APreLoad<0, 1, "pldw">, Requires<[IsARM,HasV7,HasMP]>;
1962 defm PLI : APreLoad<1, 0, "pli">, Requires<[IsARM,HasV7]>;
1964 def SETEND : AXI<(outs), (ins setend_op:$end), MiscFrm, NoItinerary,
1965 "setend\t$end", []>, Requires<[IsARM]>, Deprecated<HasV8Ops> {
1967 let Inst{31-10} = 0b1111000100000001000000;
1972 def DBG : AI<(outs), (ins imm0_15:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt",
1973 [(int_arm_dbg imm0_15:$opt)]>, Requires<[IsARM, HasV7]> {
1975 let Inst{27-4} = 0b001100100000111100001111;
1976 let Inst{3-0} = opt;
1979 // A8.8.247 UDF - Undefined (Encoding A1)
1980 def UDF : AInoP<(outs), (ins imm0_65535:$imm16), MiscFrm, NoItinerary,
1981 "udf", "\t$imm16", [(int_arm_undefined imm0_65535:$imm16)]> {
1983 let Inst{31-28} = 0b1110; // AL
1984 let Inst{27-25} = 0b011;
1985 let Inst{24-20} = 0b11111;
1986 let Inst{19-8} = imm16{15-4};
1987 let Inst{7-4} = 0b1111;
1988 let Inst{3-0} = imm16{3-0};
1992 * A5.4 Permanently UNDEFINED instructions.
1994 * For most targets use UDF #65006, for which the OS will generate SIGTRAP.
1995 * Other UDF encodings generate SIGILL.
1997 * NaCl's OS instead chooses an ARM UDF encoding that's also a UDF in Thumb.
1999 * 1110 0111 1111 iiii iiii iiii 1111 iiii
2001 * 1101 1110 iiii iiii
2002 * It uses the following encoding:
2003 * 1110 0111 1111 1110 1101 1110 1111 0000
2004 * - In ARM: UDF #60896;
2005 * - In Thumb: UDF #254 followed by a branch-to-self.
2007 let isBarrier = 1, isTerminator = 1 in
2008 def TRAPNaCl : AXI<(outs), (ins), MiscFrm, NoItinerary,
2010 Requires<[IsARM,UseNaClTrap]> {
2011 let Inst = 0xe7fedef0;
2013 let isBarrier = 1, isTerminator = 1 in
2014 def TRAP : AXI<(outs), (ins), MiscFrm, NoItinerary,
2016 Requires<[IsARM,DontUseNaClTrap]> {
2017 let Inst = 0xe7ffdefe;
2020 // Address computation and loads and stores in PIC mode.
2021 let isNotDuplicable = 1 in {
2022 def PICADD : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
2024 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>,
2025 Sched<[WriteALU, ReadALU]>;
2027 let AddedComplexity = 10 in {
2028 def PICLDR : ARMPseudoInst<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
2030 [(set GPR:$dst, (load addrmodepc:$addr))]>;
2032 def PICLDRH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2034 [(set GPR:$Rt, (zextloadi16 addrmodepc:$addr))]>;
2036 def PICLDRB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2038 [(set GPR:$Rt, (zextloadi8 addrmodepc:$addr))]>;
2040 def PICLDRSH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2042 [(set GPR:$Rt, (sextloadi16 addrmodepc:$addr))]>;
2044 def PICLDRSB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2046 [(set GPR:$Rt, (sextloadi8 addrmodepc:$addr))]>;
2048 let AddedComplexity = 10 in {
2049 def PICSTR : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2050 4, IIC_iStore_r, [(store GPR:$src, addrmodepc:$addr)]>;
2052 def PICSTRH : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2053 4, IIC_iStore_bh_r, [(truncstorei16 GPR:$src,
2054 addrmodepc:$addr)]>;
2056 def PICSTRB : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2057 4, IIC_iStore_bh_r, [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
2059 } // isNotDuplicable = 1
2062 // LEApcrel - Load a pc-relative address into a register without offending the
2064 let hasSideEffects = 0, isReMaterializable = 1 in
2065 // The 'adr' mnemonic encodes differently if the label is before or after
2066 // the instruction. The {24-21} opcode bits are set by the fixup, as we don't
2067 // know until then which form of the instruction will be used.
2068 def ADR : AI1<{0,?,?,0}, (outs GPR:$Rd), (ins adrlabel:$label),
2069 MiscFrm, IIC_iALUi, "adr", "\t$Rd, $label", []>,
2070 Sched<[WriteALU, ReadALU]> {
2073 let Inst{27-25} = 0b001;
2075 let Inst{23-22} = label{13-12};
2078 let Inst{19-16} = 0b1111;
2079 let Inst{15-12} = Rd;
2080 let Inst{11-0} = label{11-0};
2083 let hasSideEffects = 1 in {
2084 def LEApcrel : ARMPseudoInst<(outs GPR:$Rd), (ins i32imm:$label, pred:$p),
2085 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
2087 def LEApcrelJT : ARMPseudoInst<(outs GPR:$Rd),
2088 (ins i32imm:$label, nohash_imm:$id, pred:$p),
2089 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
2092 //===----------------------------------------------------------------------===//
2093 // Control Flow Instructions.
2096 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
2098 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
2099 "bx", "\tlr", [(ARMretflag)]>,
2100 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2101 let Inst{27-0} = 0b0001001011111111111100011110;
2105 def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br,
2106 "mov", "\tpc, lr", [(ARMretflag)]>,
2107 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]> {
2108 let Inst{27-0} = 0b0001101000001111000000001110;
2111 // Exception return: N.b. doesn't set CPSR as far as we're concerned (it sets
2112 // the user-space one).
2113 def SUBS_PC_LR : ARMPseudoInst<(outs), (ins i32imm:$offset, pred:$p),
2115 [(ARMintretflag imm:$offset)]>;
2118 // Indirect branches
2119 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
2121 def BX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
2122 [(brind GPR:$dst)]>,
2123 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2125 let Inst{31-4} = 0b1110000100101111111111110001;
2126 let Inst{3-0} = dst;
2129 def BX_pred : AI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br,
2130 "bx", "\t$dst", [/* pattern left blank */]>,
2131 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2133 let Inst{27-4} = 0b000100101111111111110001;
2134 let Inst{3-0} = dst;
2138 // SP is marked as a use to prevent stack-pointer assignments that appear
2139 // immediately before calls from potentially appearing dead.
2141 // FIXME: Do we really need a non-predicated version? If so, it should
2142 // at least be a pseudo instruction expanding to the predicated version
2143 // at MC lowering time.
2144 Defs = [LR], Uses = [SP] in {
2145 def BL : ABXI<0b1011, (outs), (ins bl_target:$func),
2146 IIC_Br, "bl\t$func",
2147 [(ARMcall tglobaladdr:$func)]>,
2148 Requires<[IsARM]>, Sched<[WriteBrL]> {
2149 let Inst{31-28} = 0b1110;
2151 let Inst{23-0} = func;
2152 let DecoderMethod = "DecodeBranchImmInstruction";
2155 def BL_pred : ABI<0b1011, (outs), (ins bl_target:$func),
2156 IIC_Br, "bl", "\t$func",
2157 [(ARMcall_pred tglobaladdr:$func)]>,
2158 Requires<[IsARM]>, Sched<[WriteBrL]> {
2160 let Inst{23-0} = func;
2161 let DecoderMethod = "DecodeBranchImmInstruction";
2165 def BLX : AXI<(outs), (ins GPR:$func), BrMiscFrm,
2166 IIC_Br, "blx\t$func",
2167 [(ARMcall GPR:$func)]>,
2168 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2170 let Inst{31-4} = 0b1110000100101111111111110011;
2171 let Inst{3-0} = func;
2174 def BLX_pred : AI<(outs), (ins GPR:$func), BrMiscFrm,
2175 IIC_Br, "blx", "\t$func",
2176 [(ARMcall_pred GPR:$func)]>,
2177 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2179 let Inst{27-4} = 0b000100101111111111110011;
2180 let Inst{3-0} = func;
2184 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
2185 def BX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
2186 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
2187 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]>;
2190 def BMOVPCRX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
2191 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
2192 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
2194 // mov lr, pc; b if callee is marked noreturn to avoid confusing the
2195 // return stack predictor.
2196 def BMOVPCB_CALL : ARMPseudoInst<(outs), (ins bl_target:$func),
2197 8, IIC_Br, [(ARMcall_nolink tglobaladdr:$func)]>,
2198 Requires<[IsARM]>, Sched<[WriteBr]>;
2201 let isBranch = 1, isTerminator = 1 in {
2202 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
2203 // a two-value operand where a dag node expects two operands. :(
2204 def Bcc : ABI<0b1010, (outs), (ins br_target:$target),
2205 IIC_Br, "b", "\t$target",
2206 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>,
2209 let Inst{23-0} = target;
2210 let DecoderMethod = "DecodeBranchImmInstruction";
2213 let isBarrier = 1 in {
2214 // B is "predicable" since it's just a Bcc with an 'always' condition.
2215 let isPredicable = 1 in
2216 // FIXME: We shouldn't need this pseudo at all. Just using Bcc directly
2217 // should be sufficient.
2218 // FIXME: Is B really a Barrier? That doesn't seem right.
2219 def B : ARMPseudoExpand<(outs), (ins br_target:$target), 4, IIC_Br,
2220 [(br bb:$target)], (Bcc br_target:$target, (ops 14, zero_reg))>,
2223 let isNotDuplicable = 1, isIndirectBranch = 1 in {
2224 def BR_JTr : ARMPseudoInst<(outs),
2225 (ins GPR:$target, i32imm:$jt, i32imm:$id),
2227 [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]>,
2229 // FIXME: This shouldn't use the generic "addrmode2," but rather be split
2230 // into i12 and rs suffixed versions.
2231 def BR_JTm : ARMPseudoInst<(outs),
2232 (ins addrmode2:$target, i32imm:$jt, i32imm:$id),
2234 [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
2235 imm:$id)]>, Sched<[WriteBrTbl]>;
2236 def BR_JTadd : ARMPseudoInst<(outs),
2237 (ins GPR:$target, GPR:$idx, i32imm:$jt, i32imm:$id),
2239 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
2240 imm:$id)]>, Sched<[WriteBrTbl]>;
2241 } // isNotDuplicable = 1, isIndirectBranch = 1
2247 def BLXi : AXI<(outs), (ins blx_target:$target), BrMiscFrm, NoItinerary,
2248 "blx\t$target", []>,
2249 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2250 let Inst{31-25} = 0b1111101;
2252 let Inst{23-0} = target{24-1};
2253 let Inst{24} = target{0};
2256 // Branch and Exchange Jazelle
2257 def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func",
2258 [/* pattern left blank */]>, Sched<[WriteBr]> {
2260 let Inst{23-20} = 0b0010;
2261 let Inst{19-8} = 0xfff;
2262 let Inst{7-4} = 0b0010;
2263 let Inst{3-0} = func;
2268 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in {
2269 def TCRETURNdi : PseudoInst<(outs), (ins i32imm:$dst), IIC_Br, []>,
2272 def TCRETURNri : PseudoInst<(outs), (ins tcGPR:$dst), IIC_Br, []>,
2275 def TAILJMPd : ARMPseudoExpand<(outs), (ins br_target:$dst),
2277 (Bcc br_target:$dst, (ops 14, zero_reg))>,
2278 Requires<[IsARM]>, Sched<[WriteBr]>;
2280 def TAILJMPr : ARMPseudoExpand<(outs), (ins tcGPR:$dst),
2282 (BX GPR:$dst)>, Sched<[WriteBr]>,
2286 // Secure Monitor Call is a system instruction.
2287 def SMC : ABI<0b0001, (outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt",
2288 []>, Requires<[IsARM, HasTrustZone]> {
2290 let Inst{23-4} = 0b01100000000000000111;
2291 let Inst{3-0} = opt;
2294 // Supervisor Call (Software Interrupt)
2295 let isCall = 1, Uses = [SP] in {
2296 def SVC : ABI<0b1111, (outs), (ins imm24b:$svc), IIC_Br, "svc", "\t$svc", []>,
2299 let Inst{23-0} = svc;
2303 // Store Return State
2304 class SRSI<bit wb, string asm>
2305 : XI<(outs), (ins imm0_31:$mode), AddrModeNone, 4, IndexModeNone, BrFrm,
2306 NoItinerary, asm, "", []> {
2308 let Inst{31-28} = 0b1111;
2309 let Inst{27-25} = 0b100;
2313 let Inst{19-16} = 0b1101; // SP
2314 let Inst{15-5} = 0b00000101000;
2315 let Inst{4-0} = mode;
2318 def SRSDA : SRSI<0, "srsda\tsp, $mode"> {
2319 let Inst{24-23} = 0;
2321 def SRSDA_UPD : SRSI<1, "srsda\tsp!, $mode"> {
2322 let Inst{24-23} = 0;
2324 def SRSDB : SRSI<0, "srsdb\tsp, $mode"> {
2325 let Inst{24-23} = 0b10;
2327 def SRSDB_UPD : SRSI<1, "srsdb\tsp!, $mode"> {
2328 let Inst{24-23} = 0b10;
2330 def SRSIA : SRSI<0, "srsia\tsp, $mode"> {
2331 let Inst{24-23} = 0b01;
2333 def SRSIA_UPD : SRSI<1, "srsia\tsp!, $mode"> {
2334 let Inst{24-23} = 0b01;
2336 def SRSIB : SRSI<0, "srsib\tsp, $mode"> {
2337 let Inst{24-23} = 0b11;
2339 def SRSIB_UPD : SRSI<1, "srsib\tsp!, $mode"> {
2340 let Inst{24-23} = 0b11;
2343 def : ARMInstAlias<"srsda $mode", (SRSDA imm0_31:$mode)>;
2344 def : ARMInstAlias<"srsda $mode!", (SRSDA_UPD imm0_31:$mode)>;
2346 def : ARMInstAlias<"srsdb $mode", (SRSDB imm0_31:$mode)>;
2347 def : ARMInstAlias<"srsdb $mode!", (SRSDB_UPD imm0_31:$mode)>;
2349 def : ARMInstAlias<"srsia $mode", (SRSIA imm0_31:$mode)>;
2350 def : ARMInstAlias<"srsia $mode!", (SRSIA_UPD imm0_31:$mode)>;
2352 def : ARMInstAlias<"srsib $mode", (SRSIB imm0_31:$mode)>;
2353 def : ARMInstAlias<"srsib $mode!", (SRSIB_UPD imm0_31:$mode)>;
2355 // Return From Exception
2356 class RFEI<bit wb, string asm>
2357 : XI<(outs), (ins GPR:$Rn), AddrModeNone, 4, IndexModeNone, BrFrm,
2358 NoItinerary, asm, "", []> {
2360 let Inst{31-28} = 0b1111;
2361 let Inst{27-25} = 0b100;
2365 let Inst{19-16} = Rn;
2366 let Inst{15-0} = 0xa00;
2369 def RFEDA : RFEI<0, "rfeda\t$Rn"> {
2370 let Inst{24-23} = 0;
2372 def RFEDA_UPD : RFEI<1, "rfeda\t$Rn!"> {
2373 let Inst{24-23} = 0;
2375 def RFEDB : RFEI<0, "rfedb\t$Rn"> {
2376 let Inst{24-23} = 0b10;
2378 def RFEDB_UPD : RFEI<1, "rfedb\t$Rn!"> {
2379 let Inst{24-23} = 0b10;
2381 def RFEIA : RFEI<0, "rfeia\t$Rn"> {
2382 let Inst{24-23} = 0b01;
2384 def RFEIA_UPD : RFEI<1, "rfeia\t$Rn!"> {
2385 let Inst{24-23} = 0b01;
2387 def RFEIB : RFEI<0, "rfeib\t$Rn"> {
2388 let Inst{24-23} = 0b11;
2390 def RFEIB_UPD : RFEI<1, "rfeib\t$Rn!"> {
2391 let Inst{24-23} = 0b11;
2394 // Hypervisor Call is a system instruction
2396 def HVC : AInoP< (outs), (ins imm0_65535:$imm), BrFrm, NoItinerary,
2397 "hvc", "\t$imm", []>,
2398 Requires<[IsARM, HasVirtualization]> {
2401 // Even though HVC isn't predicable, it's encoding includes a condition field.
2402 // The instruction is undefined if the condition field is 0xf otherwise it is
2403 // unpredictable if it isn't condition AL (0xe).
2404 let Inst{31-28} = 0b1110;
2405 let Unpredictable{31-28} = 0b1111;
2406 let Inst{27-24} = 0b0001;
2407 let Inst{23-20} = 0b0100;
2408 let Inst{19-8} = imm{15-4};
2409 let Inst{7-4} = 0b0111;
2410 let Inst{3-0} = imm{3-0};
2414 // Return from exception in Hypervisor mode.
2415 let isReturn = 1, isBarrier = 1, isTerminator = 1, Defs = [PC] in
2416 def ERET : ABI<0b0001, (outs), (ins), NoItinerary, "eret", "", []>,
2417 Requires<[IsARM, HasVirtualization]> {
2418 let Inst{23-0} = 0b011000000000000001101110;
2421 //===----------------------------------------------------------------------===//
2422 // Load / Store Instructions.
2428 defm LDR : AI_ldr1<0, "ldr", IIC_iLoad_r, IIC_iLoad_si,
2429 UnOpFrag<(load node:$Src)>>;
2430 defm LDRB : AI_ldr1nopc<1, "ldrb", IIC_iLoad_bh_r, IIC_iLoad_bh_si,
2431 UnOpFrag<(zextloadi8 node:$Src)>>;
2432 defm STR : AI_str1<0, "str", IIC_iStore_r, IIC_iStore_si,
2433 BinOpFrag<(store node:$LHS, node:$RHS)>>;
2434 defm STRB : AI_str1nopc<1, "strb", IIC_iStore_bh_r, IIC_iStore_bh_si,
2435 BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
2437 // Special LDR for loads from non-pc-relative constpools.
2438 let canFoldAsLoad = 1, mayLoad = 1, hasSideEffects = 0,
2439 isReMaterializable = 1, isCodeGenOnly = 1 in
2440 def LDRcp : AI2ldst<0b010, 1, 0, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
2441 AddrMode_i12, LdFrm, IIC_iLoad_r, "ldr", "\t$Rt, $addr",
2445 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2446 let Inst{19-16} = 0b1111;
2447 let Inst{15-12} = Rt;
2448 let Inst{11-0} = addr{11-0}; // imm12
2451 // Loads with zero extension
2452 def LDRH : AI3ld<0b1011, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2453 IIC_iLoad_bh_r, "ldrh", "\t$Rt, $addr",
2454 [(set GPR:$Rt, (zextloadi16 addrmode3:$addr))]>;
2456 // Loads with sign extension
2457 def LDRSH : AI3ld<0b1111, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2458 IIC_iLoad_bh_r, "ldrsh", "\t$Rt, $addr",
2459 [(set GPR:$Rt, (sextloadi16 addrmode3:$addr))]>;
2461 def LDRSB : AI3ld<0b1101, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2462 IIC_iLoad_bh_r, "ldrsb", "\t$Rt, $addr",
2463 [(set GPR:$Rt, (sextloadi8 addrmode3:$addr))]>;
2465 let mayLoad = 1, hasSideEffects = 0, hasExtraDefRegAllocReq = 1 in {
2467 def LDRD : AI3ld<0b1101, 0, (outs GPR:$Rt, GPR:$Rt2), (ins addrmode3:$addr),
2468 LdMiscFrm, IIC_iLoad_d_r, "ldrd", "\t$Rt, $Rt2, $addr", []>,
2469 Requires<[IsARM, HasV5TE]>;
2472 def LDA : AIldracq<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2473 NoItinerary, "lda", "\t$Rt, $addr", []>;
2474 def LDAB : AIldracq<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2475 NoItinerary, "ldab", "\t$Rt, $addr", []>;
2476 def LDAH : AIldracq<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2477 NoItinerary, "ldah", "\t$Rt, $addr", []>;
2480 multiclass AI2_ldridx<bit isByte, string opc,
2481 InstrItinClass iii, InstrItinClass iir> {
2482 def _PRE_IMM : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2483 (ins addrmode_imm12_pre:$addr), IndexModePre, LdFrm, iii,
2484 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2487 let Inst{23} = addr{12};
2488 let Inst{19-16} = addr{16-13};
2489 let Inst{11-0} = addr{11-0};
2490 let DecoderMethod = "DecodeLDRPreImm";
2493 def _PRE_REG : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2494 (ins ldst_so_reg:$addr), IndexModePre, LdFrm, iir,
2495 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2498 let Inst{23} = addr{12};
2499 let Inst{19-16} = addr{16-13};
2500 let Inst{11-0} = addr{11-0};
2502 let DecoderMethod = "DecodeLDRPreReg";
2505 def _POST_REG : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2506 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2507 IndexModePost, LdFrm, iir,
2508 opc, "\t$Rt, $addr, $offset",
2509 "$addr.base = $Rn_wb", []> {
2515 let Inst{23} = offset{12};
2516 let Inst{19-16} = addr;
2517 let Inst{11-0} = offset{11-0};
2520 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2523 def _POST_IMM : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2524 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2525 IndexModePost, LdFrm, iii,
2526 opc, "\t$Rt, $addr, $offset",
2527 "$addr.base = $Rn_wb", []> {
2533 let Inst{23} = offset{12};
2534 let Inst{19-16} = addr;
2535 let Inst{11-0} = offset{11-0};
2537 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2542 let mayLoad = 1, hasSideEffects = 0 in {
2543 // FIXME: for LDR_PRE_REG etc. the itineray should be either IIC_iLoad_ru or
2544 // IIC_iLoad_siu depending on whether it the offset register is shifted.
2545 defm LDR : AI2_ldridx<0, "ldr", IIC_iLoad_iu, IIC_iLoad_ru>;
2546 defm LDRB : AI2_ldridx<1, "ldrb", IIC_iLoad_bh_iu, IIC_iLoad_bh_ru>;
2549 multiclass AI3_ldridx<bits<4> op, string opc, InstrItinClass itin> {
2550 def _PRE : AI3ldstidx<op, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2551 (ins addrmode3_pre:$addr), IndexModePre,
2553 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2555 let Inst{23} = addr{8}; // U bit
2556 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2557 let Inst{19-16} = addr{12-9}; // Rn
2558 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2559 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2560 let DecoderMethod = "DecodeAddrMode3Instruction";
2562 def _POST : AI3ldstidx<op, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2563 (ins addr_offset_none:$addr, am3offset:$offset),
2564 IndexModePost, LdMiscFrm, itin,
2565 opc, "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2569 let Inst{23} = offset{8}; // U bit
2570 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2571 let Inst{19-16} = addr;
2572 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2573 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2574 let DecoderMethod = "DecodeAddrMode3Instruction";
2578 let mayLoad = 1, hasSideEffects = 0 in {
2579 defm LDRH : AI3_ldridx<0b1011, "ldrh", IIC_iLoad_bh_ru>;
2580 defm LDRSH : AI3_ldridx<0b1111, "ldrsh", IIC_iLoad_bh_ru>;
2581 defm LDRSB : AI3_ldridx<0b1101, "ldrsb", IIC_iLoad_bh_ru>;
2582 let hasExtraDefRegAllocReq = 1 in {
2583 def LDRD_PRE : AI3ldstidx<0b1101, 0, 1, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2584 (ins addrmode3_pre:$addr), IndexModePre,
2585 LdMiscFrm, IIC_iLoad_d_ru,
2586 "ldrd", "\t$Rt, $Rt2, $addr!",
2587 "$addr.base = $Rn_wb", []> {
2589 let Inst{23} = addr{8}; // U bit
2590 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2591 let Inst{19-16} = addr{12-9}; // Rn
2592 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2593 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2594 let DecoderMethod = "DecodeAddrMode3Instruction";
2596 def LDRD_POST: AI3ldstidx<0b1101, 0, 0, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2597 (ins addr_offset_none:$addr, am3offset:$offset),
2598 IndexModePost, LdMiscFrm, IIC_iLoad_d_ru,
2599 "ldrd", "\t$Rt, $Rt2, $addr, $offset",
2600 "$addr.base = $Rn_wb", []> {
2603 let Inst{23} = offset{8}; // U bit
2604 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2605 let Inst{19-16} = addr;
2606 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2607 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2608 let DecoderMethod = "DecodeAddrMode3Instruction";
2610 } // hasExtraDefRegAllocReq = 1
2611 } // mayLoad = 1, hasSideEffects = 0
2613 // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT.
2614 let mayLoad = 1, hasSideEffects = 0 in {
2615 def LDRT_POST_REG : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2616 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2617 IndexModePost, LdFrm, IIC_iLoad_ru,
2618 "ldrt", "\t$Rt, $addr, $offset",
2619 "$addr.base = $Rn_wb", []> {
2625 let Inst{23} = offset{12};
2626 let Inst{21} = 1; // overwrite
2627 let Inst{19-16} = addr;
2628 let Inst{11-5} = offset{11-5};
2630 let Inst{3-0} = offset{3-0};
2631 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2635 : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2636 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2637 IndexModePost, LdFrm, IIC_iLoad_ru,
2638 "ldrt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2644 let Inst{23} = offset{12};
2645 let Inst{21} = 1; // overwrite
2646 let Inst{19-16} = addr;
2647 let Inst{11-0} = offset{11-0};
2648 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2651 def LDRBT_POST_REG : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2652 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2653 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2654 "ldrbt", "\t$Rt, $addr, $offset",
2655 "$addr.base = $Rn_wb", []> {
2661 let Inst{23} = offset{12};
2662 let Inst{21} = 1; // overwrite
2663 let Inst{19-16} = addr;
2664 let Inst{11-5} = offset{11-5};
2666 let Inst{3-0} = offset{3-0};
2667 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2671 : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2672 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2673 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2674 "ldrbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2680 let Inst{23} = offset{12};
2681 let Inst{21} = 1; // overwrite
2682 let Inst{19-16} = addr;
2683 let Inst{11-0} = offset{11-0};
2684 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2687 multiclass AI3ldrT<bits<4> op, string opc> {
2688 def i : AI3ldstidxT<op, 1, (outs GPR:$Rt, GPR:$base_wb),
2689 (ins addr_offset_none:$addr, postidx_imm8:$offset),
2690 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2691 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2693 let Inst{23} = offset{8};
2695 let Inst{11-8} = offset{7-4};
2696 let Inst{3-0} = offset{3-0};
2698 def r : AI3ldstidxT<op, 1, (outs GPRnopc:$Rt, GPRnopc:$base_wb),
2699 (ins addr_offset_none:$addr, postidx_reg:$Rm),
2700 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2701 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2703 let Inst{23} = Rm{4};
2706 let Unpredictable{11-8} = 0b1111;
2707 let Inst{3-0} = Rm{3-0};
2708 let DecoderMethod = "DecodeLDR";
2712 defm LDRSBT : AI3ldrT<0b1101, "ldrsbt">;
2713 defm LDRHT : AI3ldrT<0b1011, "ldrht">;
2714 defm LDRSHT : AI3ldrT<0b1111, "ldrsht">;
2718 : ARMAsmPseudo<"ldrt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q),
2722 : ARMAsmPseudo<"ldrbt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q),
2727 // Stores with truncate
2728 def STRH : AI3str<0b1011, (outs), (ins GPR:$Rt, addrmode3:$addr), StMiscFrm,
2729 IIC_iStore_bh_r, "strh", "\t$Rt, $addr",
2730 [(truncstorei16 GPR:$Rt, addrmode3:$addr)]>;
2733 let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
2734 def STRD : AI3str<0b1111, (outs), (ins GPR:$Rt, GPR:$Rt2, addrmode3:$addr),
2735 StMiscFrm, IIC_iStore_d_r, "strd", "\t$Rt, $Rt2, $addr", []>,
2736 Requires<[IsARM, HasV5TE]> {
2742 multiclass AI2_stridx<bit isByte, string opc,
2743 InstrItinClass iii, InstrItinClass iir> {
2744 def _PRE_IMM : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2745 (ins GPR:$Rt, addrmode_imm12_pre:$addr), IndexModePre,
2747 opc, "\t$Rt, $addr!",
2748 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2751 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2752 let Inst{19-16} = addr{16-13}; // Rn
2753 let Inst{11-0} = addr{11-0}; // imm12
2754 let DecoderMethod = "DecodeSTRPreImm";
2757 def _PRE_REG : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2758 (ins GPR:$Rt, ldst_so_reg:$addr),
2759 IndexModePre, StFrm, iir,
2760 opc, "\t$Rt, $addr!",
2761 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2764 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2765 let Inst{19-16} = addr{16-13}; // Rn
2766 let Inst{11-0} = addr{11-0};
2767 let Inst{4} = 0; // Inst{4} = 0
2768 let DecoderMethod = "DecodeSTRPreReg";
2770 def _POST_REG : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2771 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2772 IndexModePost, StFrm, iir,
2773 opc, "\t$Rt, $addr, $offset",
2774 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2780 let Inst{23} = offset{12};
2781 let Inst{19-16} = addr;
2782 let Inst{11-0} = offset{11-0};
2785 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2788 def _POST_IMM : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2789 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2790 IndexModePost, StFrm, iii,
2791 opc, "\t$Rt, $addr, $offset",
2792 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2798 let Inst{23} = offset{12};
2799 let Inst{19-16} = addr;
2800 let Inst{11-0} = offset{11-0};
2802 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2806 let mayStore = 1, hasSideEffects = 0 in {
2807 // FIXME: for STR_PRE_REG etc. the itineray should be either IIC_iStore_ru or
2808 // IIC_iStore_siu depending on whether it the offset register is shifted.
2809 defm STR : AI2_stridx<0, "str", IIC_iStore_iu, IIC_iStore_ru>;
2810 defm STRB : AI2_stridx<1, "strb", IIC_iStore_bh_iu, IIC_iStore_bh_ru>;
2813 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2814 am2offset_reg:$offset),
2815 (STR_POST_REG GPR:$Rt, addr_offset_none:$addr,
2816 am2offset_reg:$offset)>;
2817 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2818 am2offset_imm:$offset),
2819 (STR_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2820 am2offset_imm:$offset)>;
2821 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2822 am2offset_reg:$offset),
2823 (STRB_POST_REG GPR:$Rt, addr_offset_none:$addr,
2824 am2offset_reg:$offset)>;
2825 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2826 am2offset_imm:$offset),
2827 (STRB_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2828 am2offset_imm:$offset)>;
2830 // Pseudo-instructions for pattern matching the pre-indexed stores. We can't
2831 // put the patterns on the instruction definitions directly as ISel wants
2832 // the address base and offset to be separate operands, not a single
2833 // complex operand like we represent the instructions themselves. The
2834 // pseudos map between the two.
2835 let usesCustomInserter = 1,
2836 Constraints = "$Rn = $Rn_wb,@earlyclobber $Rn_wb" in {
2837 def STRi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2838 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2841 (pre_store GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2842 def STRr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2843 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2846 (pre_store GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2847 def STRBi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2848 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2851 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2852 def STRBr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2853 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2856 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2857 def STRH_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2858 (ins GPR:$Rt, GPR:$Rn, am3offset:$offset, pred:$p),
2861 (pre_truncsti16 GPR:$Rt, GPR:$Rn, am3offset:$offset))]>;
2866 def STRH_PRE : AI3ldstidx<0b1011, 0, 1, (outs GPR:$Rn_wb),
2867 (ins GPR:$Rt, addrmode3_pre:$addr), IndexModePre,
2868 StMiscFrm, IIC_iStore_bh_ru,
2869 "strh", "\t$Rt, $addr!",
2870 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2872 let Inst{23} = addr{8}; // U bit
2873 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2874 let Inst{19-16} = addr{12-9}; // Rn
2875 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2876 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2877 let DecoderMethod = "DecodeAddrMode3Instruction";
2880 def STRH_POST : AI3ldstidx<0b1011, 0, 0, (outs GPR:$Rn_wb),
2881 (ins GPR:$Rt, addr_offset_none:$addr, am3offset:$offset),
2882 IndexModePost, StMiscFrm, IIC_iStore_bh_ru,
2883 "strh", "\t$Rt, $addr, $offset",
2884 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb",
2885 [(set GPR:$Rn_wb, (post_truncsti16 GPR:$Rt,
2886 addr_offset_none:$addr,
2887 am3offset:$offset))]> {
2890 let Inst{23} = offset{8}; // U bit
2891 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2892 let Inst{19-16} = addr;
2893 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2894 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2895 let DecoderMethod = "DecodeAddrMode3Instruction";
2898 let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
2899 def STRD_PRE : AI3ldstidx<0b1111, 0, 1, (outs GPR:$Rn_wb),
2900 (ins GPR:$Rt, GPR:$Rt2, addrmode3_pre:$addr),
2901 IndexModePre, StMiscFrm, IIC_iStore_d_ru,
2902 "strd", "\t$Rt, $Rt2, $addr!",
2903 "$addr.base = $Rn_wb", []> {
2905 let Inst{23} = addr{8}; // U bit
2906 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2907 let Inst{19-16} = addr{12-9}; // Rn
2908 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2909 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2910 let DecoderMethod = "DecodeAddrMode3Instruction";
2913 def STRD_POST: AI3ldstidx<0b1111, 0, 0, (outs GPR:$Rn_wb),
2914 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr,
2916 IndexModePost, StMiscFrm, IIC_iStore_d_ru,
2917 "strd", "\t$Rt, $Rt2, $addr, $offset",
2918 "$addr.base = $Rn_wb", []> {
2921 let Inst{23} = offset{8}; // U bit
2922 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2923 let Inst{19-16} = addr;
2924 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2925 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2926 let DecoderMethod = "DecodeAddrMode3Instruction";
2928 } // mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1
2930 // STRT, STRBT, and STRHT
2932 def STRBT_POST_REG : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2933 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2934 IndexModePost, StFrm, IIC_iStore_bh_ru,
2935 "strbt", "\t$Rt, $addr, $offset",
2936 "$addr.base = $Rn_wb", []> {
2942 let Inst{23} = offset{12};
2943 let Inst{21} = 1; // overwrite
2944 let Inst{19-16} = addr;
2945 let Inst{11-5} = offset{11-5};
2947 let Inst{3-0} = offset{3-0};
2948 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2952 : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2953 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2954 IndexModePost, StFrm, IIC_iStore_bh_ru,
2955 "strbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2961 let Inst{23} = offset{12};
2962 let Inst{21} = 1; // overwrite
2963 let Inst{19-16} = addr;
2964 let Inst{11-0} = offset{11-0};
2965 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2969 : ARMAsmPseudo<"strbt${q} $Rt, $addr",
2970 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>;
2972 let mayStore = 1, hasSideEffects = 0 in {
2973 def STRT_POST_REG : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
2974 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2975 IndexModePost, StFrm, IIC_iStore_ru,
2976 "strt", "\t$Rt, $addr, $offset",
2977 "$addr.base = $Rn_wb", []> {
2983 let Inst{23} = offset{12};
2984 let Inst{21} = 1; // overwrite
2985 let Inst{19-16} = addr;
2986 let Inst{11-5} = offset{11-5};
2988 let Inst{3-0} = offset{3-0};
2989 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2993 : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
2994 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2995 IndexModePost, StFrm, IIC_iStore_ru,
2996 "strt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
3002 let Inst{23} = offset{12};
3003 let Inst{21} = 1; // overwrite
3004 let Inst{19-16} = addr;
3005 let Inst{11-0} = offset{11-0};
3006 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3011 : ARMAsmPseudo<"strt${q} $Rt, $addr",
3012 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>;
3014 multiclass AI3strT<bits<4> op, string opc> {
3015 def i : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
3016 (ins GPR:$Rt, addr_offset_none:$addr, postidx_imm8:$offset),
3017 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
3018 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
3020 let Inst{23} = offset{8};
3022 let Inst{11-8} = offset{7-4};
3023 let Inst{3-0} = offset{3-0};
3025 def r : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
3026 (ins GPR:$Rt, addr_offset_none:$addr, postidx_reg:$Rm),
3027 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
3028 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
3030 let Inst{23} = Rm{4};
3033 let Inst{3-0} = Rm{3-0};
3038 defm STRHT : AI3strT<0b1011, "strht">;
3040 def STL : AIstrrel<0b00, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3041 NoItinerary, "stl", "\t$Rt, $addr", []>;
3042 def STLB : AIstrrel<0b10, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3043 NoItinerary, "stlb", "\t$Rt, $addr", []>;
3044 def STLH : AIstrrel<0b11, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3045 NoItinerary, "stlh", "\t$Rt, $addr", []>;
3047 //===----------------------------------------------------------------------===//
3048 // Load / store multiple Instructions.
3051 multiclass arm_ldst_mult<string asm, string sfx, bit L_bit, bit P_bit, Format f,
3052 InstrItinClass itin, InstrItinClass itin_upd> {
3053 // IA is the default, so no need for an explicit suffix on the
3054 // mnemonic here. Without it is the canonical spelling.
3056 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3057 IndexModeNone, f, itin,
3058 !strconcat(asm, "${p}\t$Rn, $regs", sfx), "", []> {
3059 let Inst{24-23} = 0b01; // Increment After
3060 let Inst{22} = P_bit;
3061 let Inst{21} = 0; // No writeback
3062 let Inst{20} = L_bit;
3065 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3066 IndexModeUpd, f, itin_upd,
3067 !strconcat(asm, "${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3068 let Inst{24-23} = 0b01; // Increment After
3069 let Inst{22} = P_bit;
3070 let Inst{21} = 1; // Writeback
3071 let Inst{20} = L_bit;
3073 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3076 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3077 IndexModeNone, f, itin,
3078 !strconcat(asm, "da${p}\t$Rn, $regs", sfx), "", []> {
3079 let Inst{24-23} = 0b00; // Decrement After
3080 let Inst{22} = P_bit;
3081 let Inst{21} = 0; // No writeback
3082 let Inst{20} = L_bit;
3085 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3086 IndexModeUpd, f, itin_upd,
3087 !strconcat(asm, "da${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3088 let Inst{24-23} = 0b00; // Decrement After
3089 let Inst{22} = P_bit;
3090 let Inst{21} = 1; // Writeback
3091 let Inst{20} = L_bit;
3093 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3096 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3097 IndexModeNone, f, itin,
3098 !strconcat(asm, "db${p}\t$Rn, $regs", sfx), "", []> {
3099 let Inst{24-23} = 0b10; // Decrement Before
3100 let Inst{22} = P_bit;
3101 let Inst{21} = 0; // No writeback
3102 let Inst{20} = L_bit;
3105 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3106 IndexModeUpd, f, itin_upd,
3107 !strconcat(asm, "db${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3108 let Inst{24-23} = 0b10; // Decrement Before
3109 let Inst{22} = P_bit;
3110 let Inst{21} = 1; // Writeback
3111 let Inst{20} = L_bit;
3113 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3116 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3117 IndexModeNone, f, itin,
3118 !strconcat(asm, "ib${p}\t$Rn, $regs", sfx), "", []> {
3119 let Inst{24-23} = 0b11; // Increment Before
3120 let Inst{22} = P_bit;
3121 let Inst{21} = 0; // No writeback
3122 let Inst{20} = L_bit;
3125 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3126 IndexModeUpd, f, itin_upd,
3127 !strconcat(asm, "ib${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3128 let Inst{24-23} = 0b11; // Increment Before
3129 let Inst{22} = P_bit;
3130 let Inst{21} = 1; // Writeback
3131 let Inst{20} = L_bit;
3133 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3137 let hasSideEffects = 0 in {
3139 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
3140 defm LDM : arm_ldst_mult<"ldm", "", 1, 0, LdStMulFrm, IIC_iLoad_m,
3141 IIC_iLoad_mu>, ComplexDeprecationPredicate<"ARMLoad">;
3143 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
3144 defm STM : arm_ldst_mult<"stm", "", 0, 0, LdStMulFrm, IIC_iStore_m,
3146 ComplexDeprecationPredicate<"ARMStore">;
3150 // FIXME: remove when we have a way to marking a MI with these properties.
3151 // FIXME: Should pc be an implicit operand like PICADD, etc?
3152 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
3153 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
3154 def LDMIA_RET : ARMPseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p,
3155 reglist:$regs, variable_ops),
3156 4, IIC_iLoad_mBr, [],
3157 (LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>,
3158 RegConstraint<"$Rn = $wb">;
3160 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
3161 defm sysLDM : arm_ldst_mult<"ldm", " ^", 1, 1, LdStMulFrm, IIC_iLoad_m,
3164 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
3165 defm sysSTM : arm_ldst_mult<"stm", " ^", 0, 1, LdStMulFrm, IIC_iStore_m,
3170 //===----------------------------------------------------------------------===//
3171 // Move Instructions.
3174 let hasSideEffects = 0 in
3175 def MOVr : AsI1<0b1101, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMOVr,
3176 "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> {
3180 let Inst{19-16} = 0b0000;
3181 let Inst{11-4} = 0b00000000;
3184 let Inst{15-12} = Rd;
3187 // A version for the smaller set of tail call registers.
3188 let hasSideEffects = 0 in
3189 def MOVr_TC : AsI1<0b1101, (outs tcGPR:$Rd), (ins tcGPR:$Rm), DPFrm,
3190 IIC_iMOVr, "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> {
3194 let Inst{11-4} = 0b00000000;
3197 let Inst{15-12} = Rd;
3200 def MOVsr : AsI1<0b1101, (outs GPRnopc:$Rd), (ins shift_so_reg_reg:$src),
3201 DPSoRegRegFrm, IIC_iMOVsr,
3202 "mov", "\t$Rd, $src",
3203 [(set GPRnopc:$Rd, shift_so_reg_reg:$src)]>, UnaryDP,
3207 let Inst{15-12} = Rd;
3208 let Inst{19-16} = 0b0000;
3209 let Inst{11-8} = src{11-8};
3211 let Inst{6-5} = src{6-5};
3213 let Inst{3-0} = src{3-0};
3217 def MOVsi : AsI1<0b1101, (outs GPR:$Rd), (ins shift_so_reg_imm:$src),
3218 DPSoRegImmFrm, IIC_iMOVsr,
3219 "mov", "\t$Rd, $src", [(set GPR:$Rd, shift_so_reg_imm:$src)]>,
3220 UnaryDP, Sched<[WriteALU]> {
3223 let Inst{15-12} = Rd;
3224 let Inst{19-16} = 0b0000;
3225 let Inst{11-5} = src{11-5};
3227 let Inst{3-0} = src{3-0};
3231 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3232 def MOVi : AsI1<0b1101, (outs GPR:$Rd), (ins mod_imm:$imm), DPFrm, IIC_iMOVi,
3233 "mov", "\t$Rd, $imm", [(set GPR:$Rd, mod_imm:$imm)]>, UnaryDP,
3238 let Inst{15-12} = Rd;
3239 let Inst{19-16} = 0b0000;
3240 let Inst{11-0} = imm;
3243 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3244 def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins imm0_65535_expr:$imm),
3246 "movw", "\t$Rd, $imm",
3247 [(set GPR:$Rd, imm0_65535:$imm)]>,
3248 Requires<[IsARM, HasV6T2]>, UnaryDP, Sched<[WriteALU]> {
3251 let Inst{15-12} = Rd;
3252 let Inst{11-0} = imm{11-0};
3253 let Inst{19-16} = imm{15-12};
3256 let DecoderMethod = "DecodeArmMOVTWInstruction";
3259 def : InstAlias<"mov${p} $Rd, $imm",
3260 (MOVi16 GPR:$Rd, imm0_65535_expr:$imm, pred:$p)>,
3263 def MOVi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
3264 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
3267 let Constraints = "$src = $Rd" in {
3268 def MOVTi16 : AI1<0b1010, (outs GPRnopc:$Rd),
3269 (ins GPR:$src, imm0_65535_expr:$imm),
3271 "movt", "\t$Rd, $imm",
3273 (or (and GPR:$src, 0xffff),
3274 lo16AllZero:$imm))]>, UnaryDP,
3275 Requires<[IsARM, HasV6T2]>, Sched<[WriteALU]> {
3278 let Inst{15-12} = Rd;
3279 let Inst{11-0} = imm{11-0};
3280 let Inst{19-16} = imm{15-12};
3283 let DecoderMethod = "DecodeArmMOVTWInstruction";
3286 def MOVTi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
3287 (ins GPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
3292 def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
3293 Requires<[IsARM, HasV6T2]>;
3295 let Uses = [CPSR] in
3296 def RRX: PseudoInst<(outs GPR:$Rd), (ins GPR:$Rm), IIC_iMOVsi,
3297 [(set GPR:$Rd, (ARMrrx GPR:$Rm))]>, UnaryDP,
3298 Requires<[IsARM]>, Sched<[WriteALU]>;
3300 // These aren't really mov instructions, but we have to define them this way
3301 // due to flag operands.
3303 let Defs = [CPSR] in {
3304 def MOVsrl_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3305 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP,
3306 Sched<[WriteALU]>, Requires<[IsARM]>;
3307 def MOVsra_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3308 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP,
3309 Sched<[WriteALU]>, Requires<[IsARM]>;
3312 //===----------------------------------------------------------------------===//
3313 // Extend Instructions.
3318 def SXTB : AI_ext_rrot<0b01101010,
3319 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
3320 def SXTH : AI_ext_rrot<0b01101011,
3321 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
3323 def SXTAB : AI_exta_rrot<0b01101010,
3324 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
3325 def SXTAH : AI_exta_rrot<0b01101011,
3326 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
3328 def SXTB16 : AI_ext_rrot_np<0b01101000, "sxtb16">;
3330 def SXTAB16 : AI_exta_rrot_np<0b01101000, "sxtab16">;
3334 let AddedComplexity = 16 in {
3335 def UXTB : AI_ext_rrot<0b01101110,
3336 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
3337 def UXTH : AI_ext_rrot<0b01101111,
3338 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
3339 def UXTB16 : AI_ext_rrot<0b01101100,
3340 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
3342 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
3343 // The transformation should probably be done as a combiner action
3344 // instead so we can include a check for masking back in the upper
3345 // eight bits of the source into the lower eight bits of the result.
3346 //def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
3347 // (UXTB16r_rot GPR:$Src, 3)>;
3348 def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
3349 (UXTB16 GPR:$Src, 1)>;
3351 def UXTAB : AI_exta_rrot<0b01101110, "uxtab",
3352 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
3353 def UXTAH : AI_exta_rrot<0b01101111, "uxtah",
3354 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
3357 // This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
3358 def UXTAB16 : AI_exta_rrot_np<0b01101100, "uxtab16">;
3361 def SBFX : I<(outs GPRnopc:$Rd),
3362 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3363 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3364 "sbfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3365 Requires<[IsARM, HasV6T2]> {
3370 let Inst{27-21} = 0b0111101;
3371 let Inst{6-4} = 0b101;
3372 let Inst{20-16} = width;
3373 let Inst{15-12} = Rd;
3374 let Inst{11-7} = lsb;
3378 def UBFX : I<(outs GPRnopc:$Rd),
3379 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3380 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3381 "ubfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3382 Requires<[IsARM, HasV6T2]> {
3387 let Inst{27-21} = 0b0111111;
3388 let Inst{6-4} = 0b101;
3389 let Inst{20-16} = width;
3390 let Inst{15-12} = Rd;
3391 let Inst{11-7} = lsb;
3395 //===----------------------------------------------------------------------===//
3396 // Arithmetic Instructions.
3399 defm ADD : AsI1_bin_irs<0b0100, "add",
3400 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3401 BinOpFrag<(add node:$LHS, node:$RHS)>, 1>;
3402 defm SUB : AsI1_bin_irs<0b0010, "sub",
3403 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3404 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
3406 // ADD and SUB with 's' bit set.
3408 // Currently, ADDS/SUBS are pseudo opcodes that exist only in the
3409 // selection DAG. They are "lowered" to real ADD/SUB opcodes by
3410 // AdjustInstrPostInstrSelection where we determine whether or not to
3411 // set the "s" bit based on CPSR liveness.
3413 // FIXME: Eliminate ADDS/SUBS pseudo opcodes after adding tablegen
3414 // support for an optional CPSR definition that corresponds to the DAG
3415 // node's second value. We can then eliminate the implicit def of CPSR.
3416 defm ADDS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3417 BinOpFrag<(ARMaddc node:$LHS, node:$RHS)>, 1>;
3418 defm SUBS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3419 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
3421 defm ADC : AI1_adde_sube_irs<0b0101, "adc",
3422 BinOpWithFlagFrag<(ARMadde node:$LHS, node:$RHS, node:$FLAG)>, 1>;
3423 defm SBC : AI1_adde_sube_irs<0b0110, "sbc",
3424 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>>;
3426 defm RSB : AsI1_rbin_irs<0b0011, "rsb",
3427 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3428 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
3430 // FIXME: Eliminate them if we can write def : Pat patterns which defines
3431 // CPSR and the implicit def of CPSR is not needed.
3432 defm RSBS : AsI1_rbin_s_is<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3433 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
3435 defm RSC : AI1_rsc_irs<0b0111, "rsc",
3436 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>>;
3438 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
3439 // The assume-no-carry-in form uses the negation of the input since add/sub
3440 // assume opposite meanings of the carry flag (i.e., carry == !borrow).
3441 // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
3443 def : ARMPat<(add GPR:$src, mod_imm_neg:$imm),
3444 (SUBri GPR:$src, mod_imm_neg:$imm)>;
3445 def : ARMPat<(ARMaddc GPR:$src, mod_imm_neg:$imm),
3446 (SUBSri GPR:$src, mod_imm_neg:$imm)>;
3448 def : ARMPat<(add GPR:$src, imm0_65535_neg:$imm),
3449 (SUBrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>,
3450 Requires<[IsARM, HasV6T2]>;
3451 def : ARMPat<(ARMaddc GPR:$src, imm0_65535_neg:$imm),
3452 (SUBSrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>,
3453 Requires<[IsARM, HasV6T2]>;
3455 // The with-carry-in form matches bitwise not instead of the negation.
3456 // Effectively, the inverse interpretation of the carry flag already accounts
3457 // for part of the negation.
3458 def : ARMPat<(ARMadde GPR:$src, mod_imm_not:$imm, CPSR),
3459 (SBCri GPR:$src, mod_imm_not:$imm)>;
3460 def : ARMPat<(ARMadde GPR:$src, imm0_65535_neg:$imm, CPSR),
3461 (SBCrr GPR:$src, (MOVi16 (imm_not_XFORM imm:$imm)))>,
3462 Requires<[IsARM, HasV6T2]>;
3464 // Note: These are implemented in C++ code, because they have to generate
3465 // ADD/SUBrs instructions, which use a complex pattern that a xform function
3467 // (mul X, 2^n+1) -> (add (X << n), X)
3468 // (mul X, 2^n-1) -> (rsb X, (X << n))
3470 // ARM Arithmetic Instruction
3471 // GPR:$dst = GPR:$a op GPR:$b
3472 class AAI<bits<8> op27_20, bits<8> op11_4, string opc,
3473 list<dag> pattern = [],
3474 dag iops = (ins GPRnopc:$Rn, GPRnopc:$Rm),
3475 string asm = "\t$Rd, $Rn, $Rm">
3476 : AI<(outs GPRnopc:$Rd), iops, DPFrm, IIC_iALUr, opc, asm, pattern>,
3477 Sched<[WriteALU, ReadALU, ReadALU]> {
3481 let Inst{27-20} = op27_20;
3482 let Inst{11-4} = op11_4;
3483 let Inst{19-16} = Rn;
3484 let Inst{15-12} = Rd;
3487 let Unpredictable{11-8} = 0b1111;
3490 // Saturating add/subtract
3492 let DecoderMethod = "DecodeQADDInstruction" in
3493 def QADD : AAI<0b00010000, 0b00000101, "qadd",
3494 [(set GPRnopc:$Rd, (int_arm_qadd GPRnopc:$Rm, GPRnopc:$Rn))],
3495 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3497 def QSUB : AAI<0b00010010, 0b00000101, "qsub",
3498 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm, GPRnopc:$Rn))],
3499 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3500 def QDADD : AAI<0b00010100, 0b00000101, "qdadd", [],
3501 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3503 def QDSUB : AAI<0b00010110, 0b00000101, "qdsub", [],
3504 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3507 def QADD16 : AAI<0b01100010, 0b11110001, "qadd16">;
3508 def QADD8 : AAI<0b01100010, 0b11111001, "qadd8">;
3509 def QASX : AAI<0b01100010, 0b11110011, "qasx">;
3510 def QSAX : AAI<0b01100010, 0b11110101, "qsax">;
3511 def QSUB16 : AAI<0b01100010, 0b11110111, "qsub16">;
3512 def QSUB8 : AAI<0b01100010, 0b11111111, "qsub8">;
3513 def UQADD16 : AAI<0b01100110, 0b11110001, "uqadd16">;
3514 def UQADD8 : AAI<0b01100110, 0b11111001, "uqadd8">;
3515 def UQASX : AAI<0b01100110, 0b11110011, "uqasx">;
3516 def UQSAX : AAI<0b01100110, 0b11110101, "uqsax">;
3517 def UQSUB16 : AAI<0b01100110, 0b11110111, "uqsub16">;
3518 def UQSUB8 : AAI<0b01100110, 0b11111111, "uqsub8">;
3520 // Signed/Unsigned add/subtract
3522 def SASX : AAI<0b01100001, 0b11110011, "sasx">;
3523 def SADD16 : AAI<0b01100001, 0b11110001, "sadd16">;
3524 def SADD8 : AAI<0b01100001, 0b11111001, "sadd8">;
3525 def SSAX : AAI<0b01100001, 0b11110101, "ssax">;
3526 def SSUB16 : AAI<0b01100001, 0b11110111, "ssub16">;
3527 def SSUB8 : AAI<0b01100001, 0b11111111, "ssub8">;
3528 def UASX : AAI<0b01100101, 0b11110011, "uasx">;
3529 def UADD16 : AAI<0b01100101, 0b11110001, "uadd16">;
3530 def UADD8 : AAI<0b01100101, 0b11111001, "uadd8">;
3531 def USAX : AAI<0b01100101, 0b11110101, "usax">;
3532 def USUB16 : AAI<0b01100101, 0b11110111, "usub16">;
3533 def USUB8 : AAI<0b01100101, 0b11111111, "usub8">;
3535 // Signed/Unsigned halving add/subtract
3537 def SHASX : AAI<0b01100011, 0b11110011, "shasx">;
3538 def SHADD16 : AAI<0b01100011, 0b11110001, "shadd16">;
3539 def SHADD8 : AAI<0b01100011, 0b11111001, "shadd8">;
3540 def SHSAX : AAI<0b01100011, 0b11110101, "shsax">;
3541 def SHSUB16 : AAI<0b01100011, 0b11110111, "shsub16">;
3542 def SHSUB8 : AAI<0b01100011, 0b11111111, "shsub8">;
3543 def UHASX : AAI<0b01100111, 0b11110011, "uhasx">;
3544 def UHADD16 : AAI<0b01100111, 0b11110001, "uhadd16">;
3545 def UHADD8 : AAI<0b01100111, 0b11111001, "uhadd8">;
3546 def UHSAX : AAI<0b01100111, 0b11110101, "uhsax">;
3547 def UHSUB16 : AAI<0b01100111, 0b11110111, "uhsub16">;
3548 def UHSUB8 : AAI<0b01100111, 0b11111111, "uhsub8">;
3550 // Unsigned Sum of Absolute Differences [and Accumulate].
3552 def USAD8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3553 MulFrm /* for convenience */, NoItinerary, "usad8",
3554 "\t$Rd, $Rn, $Rm", []>,
3555 Requires<[IsARM, HasV6]>, Sched<[WriteALU, ReadALU, ReadALU]> {
3559 let Inst{27-20} = 0b01111000;
3560 let Inst{15-12} = 0b1111;
3561 let Inst{7-4} = 0b0001;
3562 let Inst{19-16} = Rd;
3563 let Inst{11-8} = Rm;
3566 def USADA8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3567 MulFrm /* for convenience */, NoItinerary, "usada8",
3568 "\t$Rd, $Rn, $Rm, $Ra", []>,
3569 Requires<[IsARM, HasV6]>, Sched<[WriteALU, ReadALU, ReadALU]>{
3574 let Inst{27-20} = 0b01111000;
3575 let Inst{7-4} = 0b0001;
3576 let Inst{19-16} = Rd;
3577 let Inst{15-12} = Ra;
3578 let Inst{11-8} = Rm;
3582 // Signed/Unsigned saturate
3584 def SSAT : AI<(outs GPRnopc:$Rd),
3585 (ins imm1_32:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3586 SatFrm, NoItinerary, "ssat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3591 let Inst{27-21} = 0b0110101;
3592 let Inst{5-4} = 0b01;
3593 let Inst{20-16} = sat_imm;
3594 let Inst{15-12} = Rd;
3595 let Inst{11-7} = sh{4-0};
3596 let Inst{6} = sh{5};
3600 def SSAT16 : AI<(outs GPRnopc:$Rd),
3601 (ins imm1_16:$sat_imm, GPRnopc:$Rn), SatFrm,
3602 NoItinerary, "ssat16", "\t$Rd, $sat_imm, $Rn", []> {
3606 let Inst{27-20} = 0b01101010;
3607 let Inst{11-4} = 0b11110011;
3608 let Inst{15-12} = Rd;
3609 let Inst{19-16} = sat_imm;
3613 def USAT : AI<(outs GPRnopc:$Rd),
3614 (ins imm0_31:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3615 SatFrm, NoItinerary, "usat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3620 let Inst{27-21} = 0b0110111;
3621 let Inst{5-4} = 0b01;
3622 let Inst{15-12} = Rd;
3623 let Inst{11-7} = sh{4-0};
3624 let Inst{6} = sh{5};
3625 let Inst{20-16} = sat_imm;
3629 def USAT16 : AI<(outs GPRnopc:$Rd),
3630 (ins imm0_15:$sat_imm, GPRnopc:$Rn), SatFrm,
3631 NoItinerary, "usat16", "\t$Rd, $sat_imm, $Rn", []> {
3635 let Inst{27-20} = 0b01101110;
3636 let Inst{11-4} = 0b11110011;
3637 let Inst{15-12} = Rd;
3638 let Inst{19-16} = sat_imm;
3642 def : ARMV6Pat<(int_arm_ssat GPRnopc:$a, imm:$pos),
3643 (SSAT imm:$pos, GPRnopc:$a, 0)>;
3644 def : ARMV6Pat<(int_arm_usat GPRnopc:$a, imm:$pos),
3645 (USAT imm:$pos, GPRnopc:$a, 0)>;
3647 //===----------------------------------------------------------------------===//
3648 // Bitwise Instructions.
3651 defm AND : AsI1_bin_irs<0b0000, "and",
3652 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3653 BinOpFrag<(and node:$LHS, node:$RHS)>, 1>;
3654 defm ORR : AsI1_bin_irs<0b1100, "orr",
3655 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3656 BinOpFrag<(or node:$LHS, node:$RHS)>, 1>;
3657 defm EOR : AsI1_bin_irs<0b0001, "eor",
3658 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3659 BinOpFrag<(xor node:$LHS, node:$RHS)>, 1>;
3660 defm BIC : AsI1_bin_irs<0b1110, "bic",
3661 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3662 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
3664 // FIXME: bf_inv_mask_imm should be two operands, the lsb and the msb, just
3665 // like in the actual instruction encoding. The complexity of mapping the mask
3666 // to the lsb/msb pair should be handled by ISel, not encapsulated in the
3667 // instruction description.
3668 def BFC : I<(outs GPR:$Rd), (ins GPR:$src, bf_inv_mask_imm:$imm),
3669 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3670 "bfc", "\t$Rd, $imm", "$src = $Rd",
3671 [(set GPR:$Rd, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
3672 Requires<[IsARM, HasV6T2]> {
3675 let Inst{27-21} = 0b0111110;
3676 let Inst{6-0} = 0b0011111;
3677 let Inst{15-12} = Rd;
3678 let Inst{11-7} = imm{4-0}; // lsb
3679 let Inst{20-16} = imm{9-5}; // msb
3682 // A8.6.18 BFI - Bitfield insert (Encoding A1)
3683 def BFI:I<(outs GPRnopc:$Rd), (ins GPRnopc:$src, GPR:$Rn, bf_inv_mask_imm:$imm),
3684 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3685 "bfi", "\t$Rd, $Rn, $imm", "$src = $Rd",
3686 [(set GPRnopc:$Rd, (ARMbfi GPRnopc:$src, GPR:$Rn,
3687 bf_inv_mask_imm:$imm))]>,
3688 Requires<[IsARM, HasV6T2]> {
3692 let Inst{27-21} = 0b0111110;
3693 let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15
3694 let Inst{15-12} = Rd;
3695 let Inst{11-7} = imm{4-0}; // lsb
3696 let Inst{20-16} = imm{9-5}; // width
3700 def MVNr : AsI1<0b1111, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMVNr,
3701 "mvn", "\t$Rd, $Rm",
3702 [(set GPR:$Rd, (not GPR:$Rm))]>, UnaryDP, Sched<[WriteALU]> {
3706 let Inst{19-16} = 0b0000;
3707 let Inst{11-4} = 0b00000000;
3708 let Inst{15-12} = Rd;
3711 def MVNsi : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_imm:$shift),
3712 DPSoRegImmFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3713 [(set GPR:$Rd, (not so_reg_imm:$shift))]>, UnaryDP,
3718 let Inst{19-16} = 0b0000;
3719 let Inst{15-12} = Rd;
3720 let Inst{11-5} = shift{11-5};
3722 let Inst{3-0} = shift{3-0};
3724 def MVNsr : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_reg:$shift),
3725 DPSoRegRegFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3726 [(set GPR:$Rd, (not so_reg_reg:$shift))]>, UnaryDP,
3731 let Inst{19-16} = 0b0000;
3732 let Inst{15-12} = Rd;
3733 let Inst{11-8} = shift{11-8};
3735 let Inst{6-5} = shift{6-5};
3737 let Inst{3-0} = shift{3-0};
3739 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3740 def MVNi : AsI1<0b1111, (outs GPR:$Rd), (ins mod_imm:$imm), DPFrm,
3741 IIC_iMVNi, "mvn", "\t$Rd, $imm",
3742 [(set GPR:$Rd, mod_imm_not:$imm)]>,UnaryDP, Sched<[WriteALU]> {
3746 let Inst{19-16} = 0b0000;
3747 let Inst{15-12} = Rd;
3748 let Inst{11-0} = imm;
3751 def : ARMPat<(and GPR:$src, mod_imm_not:$imm),
3752 (BICri GPR:$src, mod_imm_not:$imm)>;
3754 //===----------------------------------------------------------------------===//
3755 // Multiply Instructions.
3757 class AsMul1I32<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3758 string opc, string asm, list<dag> pattern>
3759 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3763 let Inst{19-16} = Rd;
3764 let Inst{11-8} = Rm;
3767 class AsMul1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3768 string opc, string asm, list<dag> pattern>
3769 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3774 let Inst{19-16} = RdHi;
3775 let Inst{15-12} = RdLo;
3776 let Inst{11-8} = Rm;
3779 class AsMla1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3780 string opc, string asm, list<dag> pattern>
3781 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3786 let Inst{19-16} = RdHi;
3787 let Inst{15-12} = RdLo;
3788 let Inst{11-8} = Rm;
3792 // FIXME: The v5 pseudos are only necessary for the additional Constraint
3793 // property. Remove them when it's possible to add those properties
3794 // on an individual MachineInstr, not just an instruction description.
3795 let isCommutable = 1, TwoOperandAliasConstraint = "$Rn = $Rd" in {
3796 def MUL : AsMul1I32<0b0000000, (outs GPRnopc:$Rd),
3797 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3798 IIC_iMUL32, "mul", "\t$Rd, $Rn, $Rm",
3799 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))]>,
3800 Requires<[IsARM, HasV6]> {
3801 let Inst{15-12} = 0b0000;
3802 let Unpredictable{15-12} = 0b1111;
3805 let Constraints = "@earlyclobber $Rd" in
3806 def MULv5: ARMPseudoExpand<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm,
3807 pred:$p, cc_out:$s),
3809 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))],
3810 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s)>,
3811 Requires<[IsARM, NoV6, UseMulOps]>;
3814 def MLA : AsMul1I32<0b0000001, (outs GPRnopc:$Rd),
3815 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra),
3816 IIC_iMAC32, "mla", "\t$Rd, $Rn, $Rm, $Ra",
3817 [(set GPRnopc:$Rd, (add (mul GPRnopc:$Rn, GPRnopc:$Rm), GPRnopc:$Ra))]>,
3818 Requires<[IsARM, HasV6, UseMulOps]> {
3820 let Inst{15-12} = Ra;
3823 let Constraints = "@earlyclobber $Rd" in
3824 def MLAv5: ARMPseudoExpand<(outs GPRnopc:$Rd),
3825 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra,
3826 pred:$p, cc_out:$s), 4, IIC_iMAC32,
3827 [(set GPRnopc:$Rd, (add (mul GPRnopc:$Rn, GPRnopc:$Rm), GPRnopc:$Ra))],
3828 (MLA GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra, pred:$p, cc_out:$s)>,
3829 Requires<[IsARM, NoV6]>;
3831 def MLS : AMul1I<0b0000011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3832 IIC_iMAC32, "mls", "\t$Rd, $Rn, $Rm, $Ra",
3833 [(set GPR:$Rd, (sub GPR:$Ra, (mul GPR:$Rn, GPR:$Rm)))]>,
3834 Requires<[IsARM, HasV6T2, UseMulOps]> {
3839 let Inst{19-16} = Rd;
3840 let Inst{15-12} = Ra;
3841 let Inst{11-8} = Rm;
3845 // Extra precision multiplies with low / high results
3846 let hasSideEffects = 0 in {
3847 let isCommutable = 1 in {
3848 def SMULL : AsMul1I64<0b0000110, (outs GPR:$RdLo, GPR:$RdHi),
3849 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3850 "smull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3851 Requires<[IsARM, HasV6]>;
3853 def UMULL : AsMul1I64<0b0000100, (outs GPR:$RdLo, GPR:$RdHi),
3854 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3855 "umull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3856 Requires<[IsARM, HasV6]>;
3858 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
3859 def SMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3860 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3862 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3863 Requires<[IsARM, NoV6]>;
3865 def UMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3866 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3868 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3869 Requires<[IsARM, NoV6]>;
3873 // Multiply + accumulate
3874 def SMLAL : AsMla1I64<0b0000111, (outs GPR:$RdLo, GPR:$RdHi),
3875 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64,
3876 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3877 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>;
3878 def UMLAL : AsMla1I64<0b0000101, (outs GPR:$RdLo, GPR:$RdHi),
3879 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64,
3880 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3881 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>;
3883 def UMAAL : AMul1I <0b0000010, (outs GPR:$RdLo, GPR:$RdHi),
3884 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3885 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3886 Requires<[IsARM, HasV6]> {
3891 let Inst{19-16} = RdHi;
3892 let Inst{15-12} = RdLo;
3893 let Inst{11-8} = Rm;
3898 "@earlyclobber $RdLo,@earlyclobber $RdHi,$RLo = $RdLo,$RHi = $RdHi" in {
3899 def SMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3900 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s),
3902 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi,
3903 pred:$p, cc_out:$s)>,
3904 Requires<[IsARM, NoV6]>;
3905 def UMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3906 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s),
3908 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi,
3909 pred:$p, cc_out:$s)>,
3910 Requires<[IsARM, NoV6]>;
3915 // Most significant word multiply
3916 def SMMUL : AMul2I <0b0111010, 0b0001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3917 IIC_iMUL32, "smmul", "\t$Rd, $Rn, $Rm",
3918 [(set GPR:$Rd, (mulhs GPR:$Rn, GPR:$Rm))]>,
3919 Requires<[IsARM, HasV6]> {
3920 let Inst{15-12} = 0b1111;
3923 def SMMULR : AMul2I <0b0111010, 0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3924 IIC_iMUL32, "smmulr", "\t$Rd, $Rn, $Rm", []>,
3925 Requires<[IsARM, HasV6]> {
3926 let Inst{15-12} = 0b1111;
3929 def SMMLA : AMul2Ia <0b0111010, 0b0001, (outs GPR:$Rd),
3930 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3931 IIC_iMAC32, "smmla", "\t$Rd, $Rn, $Rm, $Ra",
3932 [(set GPR:$Rd, (add (mulhs GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
3933 Requires<[IsARM, HasV6, UseMulOps]>;
3935 def SMMLAR : AMul2Ia <0b0111010, 0b0011, (outs GPR:$Rd),
3936 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3937 IIC_iMAC32, "smmlar", "\t$Rd, $Rn, $Rm, $Ra", []>,
3938 Requires<[IsARM, HasV6]>;
3940 def SMMLS : AMul2Ia <0b0111010, 0b1101, (outs GPR:$Rd),
3941 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3942 IIC_iMAC32, "smmls", "\t$Rd, $Rn, $Rm, $Ra", []>,
3943 Requires<[IsARM, HasV6, UseMulOps]>;
3945 def SMMLSR : AMul2Ia <0b0111010, 0b1111, (outs GPR:$Rd),
3946 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3947 IIC_iMAC32, "smmlsr", "\t$Rd, $Rn, $Rm, $Ra", []>,
3948 Requires<[IsARM, HasV6]>;
3950 multiclass AI_smul<string opc, PatFrag opnode> {
3951 def BB : AMulxyI<0b0001011, 0b00, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3952 IIC_iMUL16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm",
3953 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3954 (sext_inreg GPR:$Rm, i16)))]>,
3955 Requires<[IsARM, HasV5TE]>;
3957 def BT : AMulxyI<0b0001011, 0b10, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3958 IIC_iMUL16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm",
3959 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3960 (sra GPR:$Rm, (i32 16))))]>,
3961 Requires<[IsARM, HasV5TE]>;
3963 def TB : AMulxyI<0b0001011, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3964 IIC_iMUL16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm",
3965 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3966 (sext_inreg GPR:$Rm, i16)))]>,
3967 Requires<[IsARM, HasV5TE]>;
3969 def TT : AMulxyI<0b0001011, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3970 IIC_iMUL16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm",
3971 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3972 (sra GPR:$Rm, (i32 16))))]>,
3973 Requires<[IsARM, HasV5TE]>;
3975 def WB : AMulxyI<0b0001001, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3976 IIC_iMUL16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm",
3978 Requires<[IsARM, HasV5TE]>;
3980 def WT : AMulxyI<0b0001001, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3981 IIC_iMUL16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm",
3983 Requires<[IsARM, HasV5TE]>;
3987 multiclass AI_smla<string opc, PatFrag opnode> {
3988 let DecoderMethod = "DecodeSMLAInstruction" in {
3989 def BB : AMulxyIa<0b0001000, 0b00, (outs GPRnopc:$Rd),
3990 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3991 IIC_iMAC16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra",
3992 [(set GPRnopc:$Rd, (add GPR:$Ra,
3993 (opnode (sext_inreg GPRnopc:$Rn, i16),
3994 (sext_inreg GPRnopc:$Rm, i16))))]>,
3995 Requires<[IsARM, HasV5TE, UseMulOps]>;
3997 def BT : AMulxyIa<0b0001000, 0b10, (outs GPRnopc:$Rd),
3998 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3999 IIC_iMAC16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra",
4001 (add GPR:$Ra, (opnode (sext_inreg GPRnopc:$Rn, i16),
4002 (sra GPRnopc:$Rm, (i32 16)))))]>,
4003 Requires<[IsARM, HasV5TE, UseMulOps]>;
4005 def TB : AMulxyIa<0b0001000, 0b01, (outs GPRnopc:$Rd),
4006 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4007 IIC_iMAC16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra",
4009 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
4010 (sext_inreg GPRnopc:$Rm, i16))))]>,
4011 Requires<[IsARM, HasV5TE, UseMulOps]>;
4013 def TT : AMulxyIa<0b0001000, 0b11, (outs GPRnopc:$Rd),
4014 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4015 IIC_iMAC16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra",
4017 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
4018 (sra GPRnopc:$Rm, (i32 16)))))]>,
4019 Requires<[IsARM, HasV5TE, UseMulOps]>;
4021 def WB : AMulxyIa<0b0001001, 0b00, (outs GPRnopc:$Rd),
4022 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4023 IIC_iMAC16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra",
4025 Requires<[IsARM, HasV5TE, UseMulOps]>;
4027 def WT : AMulxyIa<0b0001001, 0b10, (outs GPRnopc:$Rd),
4028 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4029 IIC_iMAC16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra",
4031 Requires<[IsARM, HasV5TE, UseMulOps]>;
4035 defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
4036 defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
4038 // Halfword multiply accumulate long: SMLAL<x><y>.
4039 def SMLALBB : AMulxyI64<0b0001010, 0b00, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4040 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4041 IIC_iMAC64, "smlalbb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4042 Requires<[IsARM, HasV5TE]>;
4044 def SMLALBT : AMulxyI64<0b0001010, 0b10, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4045 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4046 IIC_iMAC64, "smlalbt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4047 Requires<[IsARM, HasV5TE]>;
4049 def SMLALTB : AMulxyI64<0b0001010, 0b01, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4050 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4051 IIC_iMAC64, "smlaltb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4052 Requires<[IsARM, HasV5TE]>;
4054 def SMLALTT : AMulxyI64<0b0001010, 0b11, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4055 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4056 IIC_iMAC64, "smlaltt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4057 Requires<[IsARM, HasV5TE]>;
4059 // Helper class for AI_smld.
4060 class AMulDualIbase<bit long, bit sub, bit swap, dag oops, dag iops,
4061 InstrItinClass itin, string opc, string asm>
4062 : AI<oops, iops, MulFrm, itin, opc, asm, []>, Requires<[IsARM, HasV6]> {
4065 let Inst{27-23} = 0b01110;
4066 let Inst{22} = long;
4067 let Inst{21-20} = 0b00;
4068 let Inst{11-8} = Rm;
4075 class AMulDualI<bit long, bit sub, bit swap, dag oops, dag iops,
4076 InstrItinClass itin, string opc, string asm>
4077 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4079 let Inst{15-12} = 0b1111;
4080 let Inst{19-16} = Rd;
4082 class AMulDualIa<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> {
4087 let Inst{19-16} = Rd;
4088 let Inst{15-12} = Ra;
4090 class AMulDualI64<bit long, bit sub, bit swap, dag oops, dag iops,
4091 InstrItinClass itin, string opc, string asm>
4092 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4095 let Inst{19-16} = RdHi;
4096 let Inst{15-12} = RdLo;
4099 multiclass AI_smld<bit sub, string opc> {
4101 def D : AMulDualIa<0, sub, 0, (outs GPRnopc:$Rd),
4102 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4103 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm, $Ra">;
4105 def DX: AMulDualIa<0, sub, 1, (outs GPRnopc:$Rd),
4106 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4107 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm, $Ra">;
4109 def LD: AMulDualI64<1, sub, 0, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4110 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
4111 !strconcat(opc, "ld"), "\t$RdLo, $RdHi, $Rn, $Rm">;
4113 def LDX : AMulDualI64<1, sub, 1, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4114 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
4115 !strconcat(opc, "ldx"),"\t$RdLo, $RdHi, $Rn, $Rm">;
4119 defm SMLA : AI_smld<0, "smla">;
4120 defm SMLS : AI_smld<1, "smls">;
4122 multiclass AI_sdml<bit sub, string opc> {
4124 def D:AMulDualI<0, sub, 0, (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm),
4125 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm">;
4126 def DX:AMulDualI<0, sub, 1, (outs GPRnopc:$Rd),(ins GPRnopc:$Rn, GPRnopc:$Rm),
4127 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm">;
4130 defm SMUA : AI_sdml<0, "smua">;
4131 defm SMUS : AI_sdml<1, "smus">;
4133 //===----------------------------------------------------------------------===//
4134 // Division Instructions (ARMv7-A with virtualization extension)
4136 def SDIV : ADivA1I<0b001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV,
4137 "sdiv", "\t$Rd, $Rn, $Rm",
4138 [(set GPR:$Rd, (sdiv GPR:$Rn, GPR:$Rm))]>,
4139 Requires<[IsARM, HasDivideInARM]>;
4141 def UDIV : ADivA1I<0b011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV,
4142 "udiv", "\t$Rd, $Rn, $Rm",
4143 [(set GPR:$Rd, (udiv GPR:$Rn, GPR:$Rm))]>,
4144 Requires<[IsARM, HasDivideInARM]>;
4146 //===----------------------------------------------------------------------===//
4147 // Misc. Arithmetic Instructions.
4150 def CLZ : AMiscA1I<0b00010110, 0b0001, (outs GPR:$Rd), (ins GPR:$Rm),
4151 IIC_iUNAr, "clz", "\t$Rd, $Rm",
4152 [(set GPR:$Rd, (ctlz GPR:$Rm))]>, Requires<[IsARM, HasV5T]>,
4155 def RBIT : AMiscA1I<0b01101111, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
4156 IIC_iUNAr, "rbit", "\t$Rd, $Rm",
4157 [(set GPR:$Rd, (ARMrbit GPR:$Rm))]>,
4158 Requires<[IsARM, HasV6T2]>,
4161 def REV : AMiscA1I<0b01101011, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
4162 IIC_iUNAr, "rev", "\t$Rd, $Rm",
4163 [(set GPR:$Rd, (bswap GPR:$Rm))]>, Requires<[IsARM, HasV6]>,
4166 let AddedComplexity = 5 in
4167 def REV16 : AMiscA1I<0b01101011, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
4168 IIC_iUNAr, "rev16", "\t$Rd, $Rm",
4169 [(set GPR:$Rd, (rotr (bswap GPR:$Rm), (i32 16)))]>,
4170 Requires<[IsARM, HasV6]>,
4173 def : ARMV6Pat<(srl (bswap (extloadi16 addrmode3:$addr)), (i32 16)),
4174 (REV16 (LDRH addrmode3:$addr))>;
4175 def : ARMV6Pat<(truncstorei16 (srl (bswap GPR:$Rn), (i32 16)), addrmode3:$addr),
4176 (STRH (REV16 GPR:$Rn), addrmode3:$addr)>;
4178 let AddedComplexity = 5 in
4179 def REVSH : AMiscA1I<0b01101111, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
4180 IIC_iUNAr, "revsh", "\t$Rd, $Rm",
4181 [(set GPR:$Rd, (sra (bswap GPR:$Rm), (i32 16)))]>,
4182 Requires<[IsARM, HasV6]>,
4185 def : ARMV6Pat<(or (sra (shl GPR:$Rm, (i32 24)), (i32 16)),
4186 (and (srl GPR:$Rm, (i32 8)), 0xFF)),
4189 def PKHBT : APKHI<0b01101000, 0, (outs GPRnopc:$Rd),
4190 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_lsl_amt:$sh),
4191 IIC_iALUsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh",
4192 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF),
4193 (and (shl GPRnopc:$Rm, pkh_lsl_amt:$sh),
4195 Requires<[IsARM, HasV6]>,
4196 Sched<[WriteALUsi, ReadALU]>;
4198 // Alternate cases for PKHBT where identities eliminate some nodes.
4199 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (and GPRnopc:$Rm, 0xFFFF0000)),
4200 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, 0)>;
4201 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (shl GPRnopc:$Rm, imm16_31:$sh)),
4202 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, imm16_31:$sh)>;
4204 // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
4205 // will match the pattern below.
4206 def PKHTB : APKHI<0b01101000, 1, (outs GPRnopc:$Rd),
4207 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_asr_amt:$sh),
4208 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh",
4209 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF0000),
4210 (and (sra GPRnopc:$Rm, pkh_asr_amt:$sh),
4212 Requires<[IsARM, HasV6]>,
4213 Sched<[WriteALUsi, ReadALU]>;
4215 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
4216 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
4217 // We also can not replace a srl (17..31) by an arithmetic shift we would use in
4218 // pkhtb src1, src2, asr (17..31).
4219 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4220 (srl GPRnopc:$src2, imm16:$sh)),
4221 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16:$sh)>;
4222 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4223 (sra GPRnopc:$src2, imm16_31:$sh)),
4224 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16_31:$sh)>;
4225 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4226 (and (srl GPRnopc:$src2, imm1_15:$sh), 0xFFFF)),
4227 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm1_15:$sh)>;
4229 //===----------------------------------------------------------------------===//
4233 // + CRC32{B,H,W} 0x04C11DB7
4234 // + CRC32C{B,H,W} 0x1EDC6F41
4237 class AI_crc32<bit C, bits<2> sz, string suffix, SDPatternOperator builtin>
4238 : AInoP<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm), MiscFrm, NoItinerary,
4239 !strconcat("crc32", suffix), "\t$Rd, $Rn, $Rm",
4240 [(set GPRnopc:$Rd, (builtin GPRnopc:$Rn, GPRnopc:$Rm))]>,
4241 Requires<[IsARM, HasV8, HasCRC]> {
4246 let Inst{31-28} = 0b1110;
4247 let Inst{27-23} = 0b00010;
4248 let Inst{22-21} = sz;
4250 let Inst{19-16} = Rn;
4251 let Inst{15-12} = Rd;
4252 let Inst{11-10} = 0b00;
4255 let Inst{7-4} = 0b0100;
4258 let Unpredictable{11-8} = 0b1101;
4261 def CRC32B : AI_crc32<0, 0b00, "b", int_arm_crc32b>;
4262 def CRC32CB : AI_crc32<1, 0b00, "cb", int_arm_crc32cb>;
4263 def CRC32H : AI_crc32<0, 0b01, "h", int_arm_crc32h>;
4264 def CRC32CH : AI_crc32<1, 0b01, "ch", int_arm_crc32ch>;
4265 def CRC32W : AI_crc32<0, 0b10, "w", int_arm_crc32w>;
4266 def CRC32CW : AI_crc32<1, 0b10, "cw", int_arm_crc32cw>;
4268 //===----------------------------------------------------------------------===//
4269 // Comparison Instructions...
4272 defm CMP : AI1_cmp_irs<0b1010, "cmp",
4273 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
4274 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
4276 // ARMcmpZ can re-use the above instruction definitions.
4277 def : ARMPat<(ARMcmpZ GPR:$src, mod_imm:$imm),
4278 (CMPri GPR:$src, mod_imm:$imm)>;
4279 def : ARMPat<(ARMcmpZ GPR:$src, GPR:$rhs),
4280 (CMPrr GPR:$src, GPR:$rhs)>;
4281 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_imm:$rhs),
4282 (CMPrsi GPR:$src, so_reg_imm:$rhs)>;
4283 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_reg:$rhs),
4284 (CMPrsr GPR:$src, so_reg_reg:$rhs)>;
4286 // CMN register-integer
4287 let isCompare = 1, Defs = [CPSR] in {
4288 def CMNri : AI1<0b1011, (outs), (ins GPR:$Rn, mod_imm:$imm), DPFrm, IIC_iCMPi,
4289 "cmn", "\t$Rn, $imm",
4290 [(ARMcmn GPR:$Rn, mod_imm:$imm)]>,
4291 Sched<[WriteCMP, ReadALU]> {
4296 let Inst{19-16} = Rn;
4297 let Inst{15-12} = 0b0000;
4298 let Inst{11-0} = imm;
4300 let Unpredictable{15-12} = 0b1111;
4303 // CMN register-register/shift
4304 def CMNzrr : AI1<0b1011, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, IIC_iCMPr,
4305 "cmn", "\t$Rn, $Rm",
4306 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4307 GPR:$Rn, GPR:$Rm)]>, Sched<[WriteCMP, ReadALU, ReadALU]> {
4310 let isCommutable = 1;
4313 let Inst{19-16} = Rn;
4314 let Inst{15-12} = 0b0000;
4315 let Inst{11-4} = 0b00000000;
4318 let Unpredictable{15-12} = 0b1111;
4321 def CMNzrsi : AI1<0b1011, (outs),
4322 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, IIC_iCMPsr,
4323 "cmn", "\t$Rn, $shift",
4324 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4325 GPR:$Rn, so_reg_imm:$shift)]>,
4326 Sched<[WriteCMPsi, ReadALU]> {
4331 let Inst{19-16} = Rn;
4332 let Inst{15-12} = 0b0000;
4333 let Inst{11-5} = shift{11-5};
4335 let Inst{3-0} = shift{3-0};
4337 let Unpredictable{15-12} = 0b1111;
4340 def CMNzrsr : AI1<0b1011, (outs),
4341 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, IIC_iCMPsr,
4342 "cmn", "\t$Rn, $shift",
4343 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4344 GPRnopc:$Rn, so_reg_reg:$shift)]>,
4345 Sched<[WriteCMPsr, ReadALU]> {
4350 let Inst{19-16} = Rn;
4351 let Inst{15-12} = 0b0000;
4352 let Inst{11-8} = shift{11-8};
4354 let Inst{6-5} = shift{6-5};
4356 let Inst{3-0} = shift{3-0};
4358 let Unpredictable{15-12} = 0b1111;
4363 def : ARMPat<(ARMcmp GPR:$src, mod_imm_neg:$imm),
4364 (CMNri GPR:$src, mod_imm_neg:$imm)>;
4366 def : ARMPat<(ARMcmpZ GPR:$src, mod_imm_neg:$imm),
4367 (CMNri GPR:$src, mod_imm_neg:$imm)>;
4369 // Note that TST/TEQ don't set all the same flags that CMP does!
4370 defm TST : AI1_cmp_irs<0b1000, "tst",
4371 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
4372 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>, 1>;
4373 defm TEQ : AI1_cmp_irs<0b1001, "teq",
4374 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
4375 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>, 1>;
4377 // Pseudo i64 compares for some floating point compares.
4378 let usesCustomInserter = 1, isBranch = 1, isTerminator = 1,
4380 def BCCi64 : PseudoInst<(outs),
4381 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, brtarget:$dst),
4383 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, bb:$dst)]>,
4386 def BCCZi64 : PseudoInst<(outs),
4387 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, brtarget:$dst), IIC_Br,
4388 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, 0, 0, bb:$dst)]>,
4390 } // usesCustomInserter
4393 // Conditional moves
4394 let hasSideEffects = 0 in {
4396 let isCommutable = 1, isSelect = 1 in
4397 def MOVCCr : ARMPseudoInst<(outs GPR:$Rd),
4398 (ins GPR:$false, GPR:$Rm, cmovpred:$p),
4400 [(set GPR:$Rd, (ARMcmov GPR:$false, GPR:$Rm,
4402 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4404 def MOVCCsi : ARMPseudoInst<(outs GPR:$Rd),
4405 (ins GPR:$false, so_reg_imm:$shift, cmovpred:$p),
4408 (ARMcmov GPR:$false, so_reg_imm:$shift,
4410 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4411 def MOVCCsr : ARMPseudoInst<(outs GPR:$Rd),
4412 (ins GPR:$false, so_reg_reg:$shift, cmovpred:$p),
4414 [(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_reg:$shift,
4416 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4419 let isMoveImm = 1 in
4421 : ARMPseudoInst<(outs GPR:$Rd),
4422 (ins GPR:$false, imm0_65535_expr:$imm, cmovpred:$p),
4424 [(set GPR:$Rd, (ARMcmov GPR:$false, imm0_65535:$imm,
4426 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>,
4429 let isMoveImm = 1 in
4430 def MOVCCi : ARMPseudoInst<(outs GPR:$Rd),
4431 (ins GPR:$false, mod_imm:$imm, cmovpred:$p),
4433 [(set GPR:$Rd, (ARMcmov GPR:$false, mod_imm:$imm,
4435 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4437 // Two instruction predicate mov immediate.
4438 let isMoveImm = 1 in
4440 : ARMPseudoInst<(outs GPR:$Rd),
4441 (ins GPR:$false, i32imm:$src, cmovpred:$p),
4443 [(set GPR:$Rd, (ARMcmov GPR:$false, imm:$src,
4445 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>;
4447 let isMoveImm = 1 in
4448 def MVNCCi : ARMPseudoInst<(outs GPR:$Rd),
4449 (ins GPR:$false, mod_imm:$imm, cmovpred:$p),
4451 [(set GPR:$Rd, (ARMcmov GPR:$false, mod_imm_not:$imm,
4453 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4458 //===----------------------------------------------------------------------===//
4459 // Atomic operations intrinsics
4462 def MemBarrierOptOperand : AsmOperandClass {
4463 let Name = "MemBarrierOpt";
4464 let ParserMethod = "parseMemBarrierOptOperand";
4466 def memb_opt : Operand<i32> {
4467 let PrintMethod = "printMemBOption";
4468 let ParserMatchClass = MemBarrierOptOperand;
4469 let DecoderMethod = "DecodeMemBarrierOption";
4472 def InstSyncBarrierOptOperand : AsmOperandClass {
4473 let Name = "InstSyncBarrierOpt";
4474 let ParserMethod = "parseInstSyncBarrierOptOperand";
4476 def instsyncb_opt : Operand<i32> {
4477 let PrintMethod = "printInstSyncBOption";
4478 let ParserMatchClass = InstSyncBarrierOptOperand;
4479 let DecoderMethod = "DecodeInstSyncBarrierOption";
4482 // Memory barriers protect the atomic sequences
4483 let hasSideEffects = 1 in {
4484 def DMB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4485 "dmb", "\t$opt", [(int_arm_dmb (i32 imm0_15:$opt))]>,
4486 Requires<[IsARM, HasDB]> {
4488 let Inst{31-4} = 0xf57ff05;
4489 let Inst{3-0} = opt;
4492 def DSB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4493 "dsb", "\t$opt", [(int_arm_dsb (i32 imm0_15:$opt))]>,
4494 Requires<[IsARM, HasDB]> {
4496 let Inst{31-4} = 0xf57ff04;
4497 let Inst{3-0} = opt;
4500 // ISB has only full system option
4501 def ISB : AInoP<(outs), (ins instsyncb_opt:$opt), MiscFrm, NoItinerary,
4502 "isb", "\t$opt", [(int_arm_isb (i32 imm0_15:$opt))]>,
4503 Requires<[IsARM, HasDB]> {
4505 let Inst{31-4} = 0xf57ff06;
4506 let Inst{3-0} = opt;
4510 let usesCustomInserter = 1, Defs = [CPSR] in {
4512 // Pseudo instruction that combines movs + predicated rsbmi
4513 // to implement integer ABS
4514 def ABS : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$src), 8, NoItinerary, []>;
4517 let usesCustomInserter = 1 in {
4518 def COPY_STRUCT_BYVAL_I32 : PseudoInst<
4519 (outs), (ins GPR:$dst, GPR:$src, i32imm:$size, i32imm:$alignment),
4521 [(ARMcopystructbyval GPR:$dst, GPR:$src, imm:$size, imm:$alignment)]>;
4524 def ldrex_1 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4525 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4528 def ldrex_2 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4529 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4532 def ldrex_4 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4533 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4536 def strex_1 : PatFrag<(ops node:$val, node:$ptr),
4537 (int_arm_strex node:$val, node:$ptr), [{
4538 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4541 def strex_2 : PatFrag<(ops node:$val, node:$ptr),
4542 (int_arm_strex node:$val, node:$ptr), [{
4543 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4546 def strex_4 : PatFrag<(ops node:$val, node:$ptr),
4547 (int_arm_strex node:$val, node:$ptr), [{
4548 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4551 def ldaex_1 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4552 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4555 def ldaex_2 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4556 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4559 def ldaex_4 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4560 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4563 def stlex_1 : PatFrag<(ops node:$val, node:$ptr),
4564 (int_arm_stlex node:$val, node:$ptr), [{
4565 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4568 def stlex_2 : PatFrag<(ops node:$val, node:$ptr),
4569 (int_arm_stlex node:$val, node:$ptr), [{
4570 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4573 def stlex_4 : PatFrag<(ops node:$val, node:$ptr),
4574 (int_arm_stlex node:$val, node:$ptr), [{
4575 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4578 let mayLoad = 1 in {
4579 def LDREXB : AIldrex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4580 NoItinerary, "ldrexb", "\t$Rt, $addr",
4581 [(set GPR:$Rt, (ldrex_1 addr_offset_none:$addr))]>;
4582 def LDREXH : AIldrex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4583 NoItinerary, "ldrexh", "\t$Rt, $addr",
4584 [(set GPR:$Rt, (ldrex_2 addr_offset_none:$addr))]>;
4585 def LDREX : AIldrex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4586 NoItinerary, "ldrex", "\t$Rt, $addr",
4587 [(set GPR:$Rt, (ldrex_4 addr_offset_none:$addr))]>;
4588 let hasExtraDefRegAllocReq = 1 in
4589 def LDREXD : AIldrex<0b01, (outs GPRPairOp:$Rt),(ins addr_offset_none:$addr),
4590 NoItinerary, "ldrexd", "\t$Rt, $addr", []> {
4591 let DecoderMethod = "DecodeDoubleRegLoad";
4594 def LDAEXB : AIldaex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4595 NoItinerary, "ldaexb", "\t$Rt, $addr",
4596 [(set GPR:$Rt, (ldaex_1 addr_offset_none:$addr))]>;
4597 def LDAEXH : AIldaex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4598 NoItinerary, "ldaexh", "\t$Rt, $addr",
4599 [(set GPR:$Rt, (ldaex_2 addr_offset_none:$addr))]>;
4600 def LDAEX : AIldaex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4601 NoItinerary, "ldaex", "\t$Rt, $addr",
4602 [(set GPR:$Rt, (ldaex_4 addr_offset_none:$addr))]>;
4603 let hasExtraDefRegAllocReq = 1 in
4604 def LDAEXD : AIldaex<0b01, (outs GPRPairOp:$Rt),(ins addr_offset_none:$addr),
4605 NoItinerary, "ldaexd", "\t$Rt, $addr", []> {
4606 let DecoderMethod = "DecodeDoubleRegLoad";
4610 let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
4611 def STREXB: AIstrex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4612 NoItinerary, "strexb", "\t$Rd, $Rt, $addr",
4613 [(set GPR:$Rd, (strex_1 GPR:$Rt,
4614 addr_offset_none:$addr))]>;
4615 def STREXH: AIstrex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4616 NoItinerary, "strexh", "\t$Rd, $Rt, $addr",
4617 [(set GPR:$Rd, (strex_2 GPR:$Rt,
4618 addr_offset_none:$addr))]>;
4619 def STREX : AIstrex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4620 NoItinerary, "strex", "\t$Rd, $Rt, $addr",
4621 [(set GPR:$Rd, (strex_4 GPR:$Rt,
4622 addr_offset_none:$addr))]>;
4623 let hasExtraSrcRegAllocReq = 1 in
4624 def STREXD : AIstrex<0b01, (outs GPR:$Rd),
4625 (ins GPRPairOp:$Rt, addr_offset_none:$addr),
4626 NoItinerary, "strexd", "\t$Rd, $Rt, $addr", []> {
4627 let DecoderMethod = "DecodeDoubleRegStore";
4629 def STLEXB: AIstlex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4630 NoItinerary, "stlexb", "\t$Rd, $Rt, $addr",
4632 (stlex_1 GPR:$Rt, addr_offset_none:$addr))]>;
4633 def STLEXH: AIstlex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4634 NoItinerary, "stlexh", "\t$Rd, $Rt, $addr",
4636 (stlex_2 GPR:$Rt, addr_offset_none:$addr))]>;
4637 def STLEX : AIstlex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4638 NoItinerary, "stlex", "\t$Rd, $Rt, $addr",
4640 (stlex_4 GPR:$Rt, addr_offset_none:$addr))]>;
4641 let hasExtraSrcRegAllocReq = 1 in
4642 def STLEXD : AIstlex<0b01, (outs GPR:$Rd),
4643 (ins GPRPairOp:$Rt, addr_offset_none:$addr),
4644 NoItinerary, "stlexd", "\t$Rd, $Rt, $addr", []> {
4645 let DecoderMethod = "DecodeDoubleRegStore";
4649 def CLREX : AXI<(outs), (ins), MiscFrm, NoItinerary, "clrex",
4651 Requires<[IsARM, HasV7]> {
4652 let Inst{31-0} = 0b11110101011111111111000000011111;
4655 def : ARMPat<(strex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr),
4656 (STREXB GPR:$Rt, addr_offset_none:$addr)>;
4657 def : ARMPat<(strex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr),
4658 (STREXH GPR:$Rt, addr_offset_none:$addr)>;
4660 def : ARMPat<(stlex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr),
4661 (STLEXB GPR:$Rt, addr_offset_none:$addr)>;
4662 def : ARMPat<(stlex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr),
4663 (STLEXH GPR:$Rt, addr_offset_none:$addr)>;
4665 class acquiring_load<PatFrag base>
4666 : PatFrag<(ops node:$ptr), (base node:$ptr), [{
4667 AtomicOrdering Ordering = cast<AtomicSDNode>(N)->getOrdering();
4668 return isAtLeastAcquire(Ordering);
4671 def atomic_load_acquire_8 : acquiring_load<atomic_load_8>;
4672 def atomic_load_acquire_16 : acquiring_load<atomic_load_16>;
4673 def atomic_load_acquire_32 : acquiring_load<atomic_load_32>;
4675 class releasing_store<PatFrag base>
4676 : PatFrag<(ops node:$ptr, node:$val), (base node:$ptr, node:$val), [{
4677 AtomicOrdering Ordering = cast<AtomicSDNode>(N)->getOrdering();
4678 return isAtLeastRelease(Ordering);
4681 def atomic_store_release_8 : releasing_store<atomic_store_8>;
4682 def atomic_store_release_16 : releasing_store<atomic_store_16>;
4683 def atomic_store_release_32 : releasing_store<atomic_store_32>;
4685 let AddedComplexity = 8 in {
4686 def : ARMPat<(atomic_load_acquire_8 addr_offset_none:$addr), (LDAB addr_offset_none:$addr)>;
4687 def : ARMPat<(atomic_load_acquire_16 addr_offset_none:$addr), (LDAH addr_offset_none:$addr)>;
4688 def : ARMPat<(atomic_load_acquire_32 addr_offset_none:$addr), (LDA addr_offset_none:$addr)>;
4689 def : ARMPat<(atomic_store_release_8 addr_offset_none:$addr, GPR:$val), (STLB GPR:$val, addr_offset_none:$addr)>;
4690 def : ARMPat<(atomic_store_release_16 addr_offset_none:$addr, GPR:$val), (STLH GPR:$val, addr_offset_none:$addr)>;
4691 def : ARMPat<(atomic_store_release_32 addr_offset_none:$addr, GPR:$val), (STL GPR:$val, addr_offset_none:$addr)>;
4694 // SWP/SWPB are deprecated in V6/V7.
4695 let mayLoad = 1, mayStore = 1 in {
4696 def SWP : AIswp<0, (outs GPRnopc:$Rt),
4697 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swp", []>,
4699 def SWPB: AIswp<1, (outs GPRnopc:$Rt),
4700 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swpb", []>,
4704 //===----------------------------------------------------------------------===//
4705 // Coprocessor Instructions.
4708 def CDP : ABI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4709 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4710 NoItinerary, "cdp", "\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4711 [(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4712 imm:$CRm, imm:$opc2)]>,
4721 let Inst{3-0} = CRm;
4723 let Inst{7-5} = opc2;
4724 let Inst{11-8} = cop;
4725 let Inst{15-12} = CRd;
4726 let Inst{19-16} = CRn;
4727 let Inst{23-20} = opc1;
4730 def CDP2 : ABXI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4731 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4732 NoItinerary, "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4733 [(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4734 imm:$CRm, imm:$opc2)]>,
4736 let Inst{31-28} = 0b1111;
4744 let Inst{3-0} = CRm;
4746 let Inst{7-5} = opc2;
4747 let Inst{11-8} = cop;
4748 let Inst{15-12} = CRd;
4749 let Inst{19-16} = CRn;
4750 let Inst{23-20} = opc1;
4753 class ACI<dag oops, dag iops, string opc, string asm,
4754 IndexMode im = IndexModeNone>
4755 : I<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
4757 let Inst{27-25} = 0b110;
4759 class ACInoP<dag oops, dag iops, string opc, string asm,
4760 IndexMode im = IndexModeNone>
4761 : InoP<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
4763 let Inst{31-28} = 0b1111;
4764 let Inst{27-25} = 0b110;
4766 multiclass LdStCop<bit load, bit Dbit, string asm> {
4767 def _OFFSET : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4768 asm, "\t$cop, $CRd, $addr"> {
4772 let Inst{24} = 1; // P = 1
4773 let Inst{23} = addr{8};
4774 let Inst{22} = Dbit;
4775 let Inst{21} = 0; // W = 0
4776 let Inst{20} = load;
4777 let Inst{19-16} = addr{12-9};
4778 let Inst{15-12} = CRd;
4779 let Inst{11-8} = cop;
4780 let Inst{7-0} = addr{7-0};
4781 let DecoderMethod = "DecodeCopMemInstruction";
4783 def _PRE : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr),
4784 asm, "\t$cop, $CRd, $addr!", IndexModePre> {
4788 let Inst{24} = 1; // P = 1
4789 let Inst{23} = addr{8};
4790 let Inst{22} = Dbit;
4791 let Inst{21} = 1; // W = 1
4792 let Inst{20} = load;
4793 let Inst{19-16} = addr{12-9};
4794 let Inst{15-12} = CRd;
4795 let Inst{11-8} = cop;
4796 let Inst{7-0} = addr{7-0};
4797 let DecoderMethod = "DecodeCopMemInstruction";
4799 def _POST: ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4800 postidx_imm8s4:$offset),
4801 asm, "\t$cop, $CRd, $addr, $offset", IndexModePost> {
4806 let Inst{24} = 0; // P = 0
4807 let Inst{23} = offset{8};
4808 let Inst{22} = Dbit;
4809 let Inst{21} = 1; // W = 1
4810 let Inst{20} = load;
4811 let Inst{19-16} = addr;
4812 let Inst{15-12} = CRd;
4813 let Inst{11-8} = cop;
4814 let Inst{7-0} = offset{7-0};
4815 let DecoderMethod = "DecodeCopMemInstruction";
4817 def _OPTION : ACI<(outs),
4818 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4819 coproc_option_imm:$option),
4820 asm, "\t$cop, $CRd, $addr, $option"> {
4825 let Inst{24} = 0; // P = 0
4826 let Inst{23} = 1; // U = 1
4827 let Inst{22} = Dbit;
4828 let Inst{21} = 0; // W = 0
4829 let Inst{20} = load;
4830 let Inst{19-16} = addr;
4831 let Inst{15-12} = CRd;
4832 let Inst{11-8} = cop;
4833 let Inst{7-0} = option;
4834 let DecoderMethod = "DecodeCopMemInstruction";
4837 multiclass LdSt2Cop<bit load, bit Dbit, string asm> {
4838 def _OFFSET : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4839 asm, "\t$cop, $CRd, $addr"> {
4843 let Inst{24} = 1; // P = 1
4844 let Inst{23} = addr{8};
4845 let Inst{22} = Dbit;
4846 let Inst{21} = 0; // W = 0
4847 let Inst{20} = load;
4848 let Inst{19-16} = addr{12-9};
4849 let Inst{15-12} = CRd;
4850 let Inst{11-8} = cop;
4851 let Inst{7-0} = addr{7-0};
4852 let DecoderMethod = "DecodeCopMemInstruction";
4854 def _PRE : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr),
4855 asm, "\t$cop, $CRd, $addr!", IndexModePre> {
4859 let Inst{24} = 1; // P = 1
4860 let Inst{23} = addr{8};
4861 let Inst{22} = Dbit;
4862 let Inst{21} = 1; // W = 1
4863 let Inst{20} = load;
4864 let Inst{19-16} = addr{12-9};
4865 let Inst{15-12} = CRd;
4866 let Inst{11-8} = cop;
4867 let Inst{7-0} = addr{7-0};
4868 let DecoderMethod = "DecodeCopMemInstruction";
4870 def _POST: ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4871 postidx_imm8s4:$offset),
4872 asm, "\t$cop, $CRd, $addr, $offset", IndexModePost> {
4877 let Inst{24} = 0; // P = 0
4878 let Inst{23} = offset{8};
4879 let Inst{22} = Dbit;
4880 let Inst{21} = 1; // W = 1
4881 let Inst{20} = load;
4882 let Inst{19-16} = addr;
4883 let Inst{15-12} = CRd;
4884 let Inst{11-8} = cop;
4885 let Inst{7-0} = offset{7-0};
4886 let DecoderMethod = "DecodeCopMemInstruction";
4888 def _OPTION : ACInoP<(outs),
4889 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4890 coproc_option_imm:$option),
4891 asm, "\t$cop, $CRd, $addr, $option"> {
4896 let Inst{24} = 0; // P = 0
4897 let Inst{23} = 1; // U = 1
4898 let Inst{22} = Dbit;
4899 let Inst{21} = 0; // W = 0
4900 let Inst{20} = load;
4901 let Inst{19-16} = addr;
4902 let Inst{15-12} = CRd;
4903 let Inst{11-8} = cop;
4904 let Inst{7-0} = option;
4905 let DecoderMethod = "DecodeCopMemInstruction";
4909 defm LDC : LdStCop <1, 0, "ldc">;
4910 defm LDCL : LdStCop <1, 1, "ldcl">;
4911 defm STC : LdStCop <0, 0, "stc">;
4912 defm STCL : LdStCop <0, 1, "stcl">;
4913 defm LDC2 : LdSt2Cop<1, 0, "ldc2">, Requires<[PreV8]>;
4914 defm LDC2L : LdSt2Cop<1, 1, "ldc2l">, Requires<[PreV8]>;
4915 defm STC2 : LdSt2Cop<0, 0, "stc2">, Requires<[PreV8]>;
4916 defm STC2L : LdSt2Cop<0, 1, "stc2l">, Requires<[PreV8]>;
4918 //===----------------------------------------------------------------------===//
4919 // Move between coprocessor and ARM core register.
4922 class MovRCopro<string opc, bit direction, dag oops, dag iops,
4924 : ABI<0b1110, oops, iops, NoItinerary, opc,
4925 "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2", pattern> {
4926 let Inst{20} = direction;
4936 let Inst{15-12} = Rt;
4937 let Inst{11-8} = cop;
4938 let Inst{23-21} = opc1;
4939 let Inst{7-5} = opc2;
4940 let Inst{3-0} = CRm;
4941 let Inst{19-16} = CRn;
4944 def MCR : MovRCopro<"mcr", 0 /* from ARM core register to coprocessor */,
4946 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4947 c_imm:$CRm, imm0_7:$opc2),
4948 [(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
4949 imm:$CRm, imm:$opc2)]>,
4950 ComplexDeprecationPredicate<"MCR">;
4951 def : ARMInstAlias<"mcr${p} $cop, $opc1, $Rt, $CRn, $CRm",
4952 (MCR p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4953 c_imm:$CRm, 0, pred:$p)>;
4954 def MRC : MovRCopro<"mrc", 1 /* from coprocessor to ARM core register */,
4955 (outs GPRwithAPSR:$Rt),
4956 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
4958 def : ARMInstAlias<"mrc${p} $cop, $opc1, $Rt, $CRn, $CRm",
4959 (MRC GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
4960 c_imm:$CRm, 0, pred:$p)>;
4962 def : ARMPat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
4963 (MRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
4965 class MovRCopro2<string opc, bit direction, dag oops, dag iops,
4967 : ABXI<0b1110, oops, iops, NoItinerary,
4968 !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), pattern> {
4969 let Inst{31-24} = 0b11111110;
4970 let Inst{20} = direction;
4980 let Inst{15-12} = Rt;
4981 let Inst{11-8} = cop;
4982 let Inst{23-21} = opc1;
4983 let Inst{7-5} = opc2;
4984 let Inst{3-0} = CRm;
4985 let Inst{19-16} = CRn;
4988 def MCR2 : MovRCopro2<"mcr2", 0 /* from ARM core register to coprocessor */,
4990 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4991 c_imm:$CRm, imm0_7:$opc2),
4992 [(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
4993 imm:$CRm, imm:$opc2)]>,
4995 def : ARMInstAlias<"mcr2 $cop, $opc1, $Rt, $CRn, $CRm",
4996 (MCR2 p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4998 def MRC2 : MovRCopro2<"mrc2", 1 /* from coprocessor to ARM core register */,
4999 (outs GPRwithAPSR:$Rt),
5000 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
5003 def : ARMInstAlias<"mrc2 $cop, $opc1, $Rt, $CRn, $CRm",
5004 (MRC2 GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
5007 def : ARMV5TPat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn,
5008 imm:$CRm, imm:$opc2),
5009 (MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
5011 class MovRRCopro<string opc, bit direction, list<dag> pattern = []>
5012 : ABI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
5013 GPRnopc:$Rt, GPRnopc:$Rt2, c_imm:$CRm),
5014 NoItinerary, opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm", pattern> {
5015 let Inst{23-21} = 0b010;
5016 let Inst{20} = direction;
5024 let Inst{15-12} = Rt;
5025 let Inst{19-16} = Rt2;
5026 let Inst{11-8} = cop;
5027 let Inst{7-4} = opc1;
5028 let Inst{3-0} = CRm;
5031 def MCRR : MovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */,
5032 [(int_arm_mcrr imm:$cop, imm:$opc1, GPRnopc:$Rt,
5033 GPRnopc:$Rt2, imm:$CRm)]>;
5034 def MRRC : MovRRCopro<"mrrc", 1 /* from coprocessor to ARM core register */>;
5036 class MovRRCopro2<string opc, bit direction, list<dag> pattern = []>
5037 : ABXI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
5038 GPRnopc:$Rt, GPRnopc:$Rt2, c_imm:$CRm), NoItinerary,
5039 !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern>,
5041 let Inst{31-28} = 0b1111;
5042 let Inst{23-21} = 0b010;
5043 let Inst{20} = direction;
5051 let Inst{15-12} = Rt;
5052 let Inst{19-16} = Rt2;
5053 let Inst{11-8} = cop;
5054 let Inst{7-4} = opc1;
5055 let Inst{3-0} = CRm;
5057 let DecoderMethod = "DecodeMRRC2";
5060 def MCRR2 : MovRRCopro2<"mcrr2", 0 /* from ARM core register to coprocessor */,
5061 [(int_arm_mcrr2 imm:$cop, imm:$opc1, GPRnopc:$Rt,
5062 GPRnopc:$Rt2, imm:$CRm)]>;
5063 def MRRC2 : MovRRCopro2<"mrrc2", 1 /* from coprocessor to ARM core register */>;
5065 //===----------------------------------------------------------------------===//
5066 // Move between special register and ARM core register
5069 // Move to ARM core register from Special Register
5070 def MRS : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
5071 "mrs", "\t$Rd, apsr", []> {
5073 let Inst{23-16} = 0b00001111;
5074 let Unpredictable{19-17} = 0b111;
5076 let Inst{15-12} = Rd;
5078 let Inst{11-0} = 0b000000000000;
5079 let Unpredictable{11-0} = 0b110100001111;
5082 def : InstAlias<"mrs${p} $Rd, cpsr", (MRS GPRnopc:$Rd, pred:$p)>,
5085 // The MRSsys instruction is the MRS instruction from the ARM ARM,
5086 // section B9.3.9, with the R bit set to 1.
5087 def MRSsys : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
5088 "mrs", "\t$Rd, spsr", []> {
5090 let Inst{23-16} = 0b01001111;
5091 let Unpredictable{19-16} = 0b1111;
5093 let Inst{15-12} = Rd;
5095 let Inst{11-0} = 0b000000000000;
5096 let Unpredictable{11-0} = 0b110100001111;
5099 // However, the MRS (banked register) system instruction (ARMv7VE) *does* have a
5100 // separate encoding (distinguished by bit 5.
5101 def MRSbanked : ABI<0b0001, (outs GPRnopc:$Rd), (ins banked_reg:$banked),
5102 NoItinerary, "mrs", "\t$Rd, $banked", []>,
5103 Requires<[IsARM, HasVirtualization]> {
5108 let Inst{22} = banked{5}; // R bit
5109 let Inst{21-20} = 0b00;
5110 let Inst{19-16} = banked{3-0};
5111 let Inst{15-12} = Rd;
5112 let Inst{11-9} = 0b001;
5113 let Inst{8} = banked{4};
5114 let Inst{7-0} = 0b00000000;
5117 // Move from ARM core register to Special Register
5119 // No need to have both system and application versions of MSR (immediate) or
5120 // MSR (register), the encodings are the same and the assembly parser has no way
5121 // to distinguish between them. The mask operand contains the special register
5122 // (R Bit) in bit 4 and bits 3-0 contains the mask with the fields to be
5123 // accessed in the special register.
5124 def MSR : ABI<0b0001, (outs), (ins msr_mask:$mask, GPR:$Rn), NoItinerary,
5125 "msr", "\t$mask, $Rn", []> {
5130 let Inst{22} = mask{4}; // R bit
5131 let Inst{21-20} = 0b10;
5132 let Inst{19-16} = mask{3-0};
5133 let Inst{15-12} = 0b1111;
5134 let Inst{11-4} = 0b00000000;
5138 def MSRi : ABI<0b0011, (outs), (ins msr_mask:$mask, mod_imm:$imm), NoItinerary,
5139 "msr", "\t$mask, $imm", []> {
5144 let Inst{22} = mask{4}; // R bit
5145 let Inst{21-20} = 0b10;
5146 let Inst{19-16} = mask{3-0};
5147 let Inst{15-12} = 0b1111;
5148 let Inst{11-0} = imm;
5151 // However, the MSR (banked register) system instruction (ARMv7VE) *does* have a
5152 // separate encoding (distinguished by bit 5.
5153 def MSRbanked : ABI<0b0001, (outs), (ins banked_reg:$banked, GPRnopc:$Rn),
5154 NoItinerary, "msr", "\t$banked, $Rn", []>,
5155 Requires<[IsARM, HasVirtualization]> {
5160 let Inst{22} = banked{5}; // R bit
5161 let Inst{21-20} = 0b10;
5162 let Inst{19-16} = banked{3-0};
5163 let Inst{15-12} = 0b1111;
5164 let Inst{11-9} = 0b001;
5165 let Inst{8} = banked{4};
5166 let Inst{7-4} = 0b0000;
5170 // Dynamic stack allocation yields a _chkstk for Windows targets. These calls
5171 // are needed to probe the stack when allocating more than
5172 // 4k bytes in one go. Touching the stack at 4K increments is necessary to
5173 // ensure that the guard pages used by the OS virtual memory manager are
5174 // allocated in correct sequence.
5175 // The main point of having separate instruction are extra unmodelled effects
5176 // (compared to ordinary calls) like stack pointer change.
5178 def win__chkstk : SDNode<"ARMISD::WIN__CHKSTK", SDTNone,
5179 [SDNPHasChain, SDNPSideEffect]>;
5180 let usesCustomInserter = 1, Uses = [R4], Defs = [R4, SP] in
5181 def WIN__CHKSTK : PseudoInst<(outs), (ins), NoItinerary, [(win__chkstk)]>;
5183 //===----------------------------------------------------------------------===//
5187 // __aeabi_read_tp preserves the registers r1-r3.
5188 // This is a pseudo inst so that we can get the encoding right,
5189 // complete with fixup for the aeabi_read_tp function.
5190 // TPsoft is valid for ARM mode only, in case of Thumb mode a tTPsoft pattern
5191 // is defined in "ARMInstrThumb.td".
5193 Defs = [R0, R12, LR, CPSR], Uses = [SP] in {
5194 def TPsoft : ARMPseudoInst<(outs), (ins), 4, IIC_Br,
5195 [(set R0, ARMthread_pointer)]>, Sched<[WriteBr]>;
5198 //===----------------------------------------------------------------------===//
5199 // SJLJ Exception handling intrinsics
5200 // eh_sjlj_setjmp() is an instruction sequence to store the return
5201 // address and save #0 in R0 for the non-longjmp case.
5202 // Since by its nature we may be coming from some other function to get
5203 // here, and we're using the stack frame for the containing function to
5204 // save/restore registers, we can't keep anything live in regs across
5205 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
5206 // when we get here from a longjmp(). We force everything out of registers
5207 // except for our own input by listing the relevant registers in Defs. By
5208 // doing so, we also cause the prologue/epilogue code to actively preserve
5209 // all of the callee-saved resgisters, which is exactly what we want.
5210 // A constant value is passed in $val, and we use the location as a scratch.
5212 // These are pseudo-instructions and are lowered to individual MC-insts, so
5213 // no encoding information is necessary.
5215 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
5216 Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15 ],
5217 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
5218 def Int_eh_sjlj_setjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
5220 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
5221 Requires<[IsARM, HasVFP2]>;
5225 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
5226 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
5227 def Int_eh_sjlj_setjmp_nofp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
5229 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
5230 Requires<[IsARM, NoVFP]>;
5233 // FIXME: Non-IOS version(s)
5234 let isBarrier = 1, hasSideEffects = 1, isTerminator = 1,
5235 Defs = [ R7, LR, SP ] in {
5236 def Int_eh_sjlj_longjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$scratch),
5238 [(ARMeh_sjlj_longjmp GPR:$src, GPR:$scratch)]>,
5242 // eh.sjlj.dispatchsetup pseudo-instruction.
5243 // This pseudo is used for both ARM and Thumb. Any differences are handled when
5244 // the pseudo is expanded (which happens before any passes that need the
5245 // instruction size).
5246 let isBarrier = 1 in
5247 def Int_eh_sjlj_dispatchsetup : PseudoInst<(outs), (ins), NoItinerary, []>;
5250 //===----------------------------------------------------------------------===//
5251 // Non-Instruction Patterns
5254 // ARMv4 indirect branch using (MOVr PC, dst)
5255 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in
5256 def MOVPCRX : ARMPseudoExpand<(outs), (ins GPR:$dst),
5257 4, IIC_Br, [(brind GPR:$dst)],
5258 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>,
5259 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
5261 // Large immediate handling.
5263 // 32-bit immediate using two piece mod_imms or movw + movt.
5264 // This is a single pseudo instruction, the benefit is that it can be remat'd
5265 // as a single unit instead of having to handle reg inputs.
5266 // FIXME: Remove this when we can do generalized remat.
5267 let isReMaterializable = 1, isMoveImm = 1 in
5268 def MOVi32imm : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
5269 [(set GPR:$dst, (arm_i32imm:$src))]>,
5272 def LDRLIT_ga_abs : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iLoad_i,
5273 [(set GPR:$dst, (ARMWrapper tglobaladdr:$src))]>,
5274 Requires<[IsARM, DontUseMovt]>;
5276 // Pseudo instruction that combines movw + movt + add pc (if PIC).
5277 // It also makes it possible to rematerialize the instructions.
5278 // FIXME: Remove this when we can do generalized remat and when machine licm
5279 // can properly the instructions.
5280 let isReMaterializable = 1 in {
5281 def MOV_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5283 [(set GPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>,
5284 Requires<[IsARM, UseMovt]>;
5286 def LDRLIT_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5289 (ARMWrapperPIC tglobaladdr:$addr))]>,
5290 Requires<[IsARM, DontUseMovt]>;
5292 let AddedComplexity = 10 in
5293 def LDRLIT_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5296 (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
5297 Requires<[IsARM, DontUseMovt]>;
5299 let AddedComplexity = 10 in
5300 def MOV_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5302 [(set GPR:$dst, (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
5303 Requires<[IsARM, UseMovt]>;
5304 } // isReMaterializable
5306 // ConstantPool, GlobalAddress, and JumpTable
5307 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
5308 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
5309 Requires<[IsARM, UseMovt]>;
5310 def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
5311 (LEApcrelJT tjumptable:$dst, imm:$id)>;
5313 // TODO: add,sub,and, 3-instr forms?
5315 // Tail calls. These patterns also apply to Thumb mode.
5316 def : Pat<(ARMtcret tcGPR:$dst), (TCRETURNri tcGPR:$dst)>;
5317 def : Pat<(ARMtcret (i32 tglobaladdr:$dst)), (TCRETURNdi texternalsym:$dst)>;
5318 def : Pat<(ARMtcret (i32 texternalsym:$dst)), (TCRETURNdi texternalsym:$dst)>;
5321 def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>;
5322 def : ARMPat<(ARMcall_nolink texternalsym:$func),
5323 (BMOVPCB_CALL texternalsym:$func)>;
5325 // zextload i1 -> zextload i8
5326 def : ARMPat<(zextloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5327 def : ARMPat<(zextloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5329 // extload -> zextload
5330 def : ARMPat<(extloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5331 def : ARMPat<(extloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5332 def : ARMPat<(extloadi8 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5333 def : ARMPat<(extloadi8 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5335 def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
5337 def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
5338 def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
5341 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
5342 (sra (shl GPR:$b, (i32 16)), (i32 16))),
5343 (SMULBB GPR:$a, GPR:$b)>;
5344 def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
5345 (SMULBB GPR:$a, GPR:$b)>;
5346 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
5347 (sra GPR:$b, (i32 16))),
5348 (SMULBT GPR:$a, GPR:$b)>;
5349 def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, (i32 16))),
5350 (SMULBT GPR:$a, GPR:$b)>;
5351 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)),
5352 (sra (shl GPR:$b, (i32 16)), (i32 16))),
5353 (SMULTB GPR:$a, GPR:$b)>;
5354 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), sext_16_node:$b),
5355 (SMULTB GPR:$a, GPR:$b)>;
5357 def : ARMV5MOPat<(add GPR:$acc,
5358 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
5359 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
5360 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5361 def : ARMV5MOPat<(add GPR:$acc,
5362 (mul sext_16_node:$a, sext_16_node:$b)),
5363 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5364 def : ARMV5MOPat<(add GPR:$acc,
5365 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
5366 (sra GPR:$b, (i32 16)))),
5367 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
5368 def : ARMV5MOPat<(add GPR:$acc,
5369 (mul sext_16_node:$a, (sra GPR:$b, (i32 16)))),
5370 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
5371 def : ARMV5MOPat<(add GPR:$acc,
5372 (mul (sra GPR:$a, (i32 16)),
5373 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
5374 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
5375 def : ARMV5MOPat<(add GPR:$acc,
5376 (mul (sra GPR:$a, (i32 16)), sext_16_node:$b)),
5377 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
5380 // Pre-v7 uses MCR for synchronization barriers.
5381 def : ARMPat<(ARMMemBarrierMCR GPR:$zero), (MCR 15, 0, GPR:$zero, 7, 10, 5)>,
5382 Requires<[IsARM, HasV6]>;
5384 // SXT/UXT with no rotate
5385 let AddedComplexity = 16 in {
5386 def : ARMV6Pat<(and GPR:$Src, 0x000000FF), (UXTB GPR:$Src, 0)>;
5387 def : ARMV6Pat<(and GPR:$Src, 0x0000FFFF), (UXTH GPR:$Src, 0)>;
5388 def : ARMV6Pat<(and GPR:$Src, 0x00FF00FF), (UXTB16 GPR:$Src, 0)>;
5389 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0x00FF)),
5390 (UXTAB GPR:$Rn, GPR:$Rm, 0)>;
5391 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0xFFFF)),
5392 (UXTAH GPR:$Rn, GPR:$Rm, 0)>;
5395 def : ARMV6Pat<(sext_inreg GPR:$Src, i8), (SXTB GPR:$Src, 0)>;
5396 def : ARMV6Pat<(sext_inreg GPR:$Src, i16), (SXTH GPR:$Src, 0)>;
5398 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i8)),
5399 (SXTAB GPR:$Rn, GPRnopc:$Rm, 0)>;
5400 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i16)),
5401 (SXTAH GPR:$Rn, GPRnopc:$Rm, 0)>;
5403 // Atomic load/store patterns
5404 def : ARMPat<(atomic_load_8 ldst_so_reg:$src),
5405 (LDRBrs ldst_so_reg:$src)>;
5406 def : ARMPat<(atomic_load_8 addrmode_imm12:$src),
5407 (LDRBi12 addrmode_imm12:$src)>;
5408 def : ARMPat<(atomic_load_16 addrmode3:$src),
5409 (LDRH addrmode3:$src)>;
5410 def : ARMPat<(atomic_load_32 ldst_so_reg:$src),
5411 (LDRrs ldst_so_reg:$src)>;
5412 def : ARMPat<(atomic_load_32 addrmode_imm12:$src),
5413 (LDRi12 addrmode_imm12:$src)>;
5414 def : ARMPat<(atomic_store_8 ldst_so_reg:$ptr, GPR:$val),
5415 (STRBrs GPR:$val, ldst_so_reg:$ptr)>;
5416 def : ARMPat<(atomic_store_8 addrmode_imm12:$ptr, GPR:$val),
5417 (STRBi12 GPR:$val, addrmode_imm12:$ptr)>;
5418 def : ARMPat<(atomic_store_16 addrmode3:$ptr, GPR:$val),
5419 (STRH GPR:$val, addrmode3:$ptr)>;
5420 def : ARMPat<(atomic_store_32 ldst_so_reg:$ptr, GPR:$val),
5421 (STRrs GPR:$val, ldst_so_reg:$ptr)>;
5422 def : ARMPat<(atomic_store_32 addrmode_imm12:$ptr, GPR:$val),
5423 (STRi12 GPR:$val, addrmode_imm12:$ptr)>;
5426 //===----------------------------------------------------------------------===//
5430 include "ARMInstrThumb.td"
5432 //===----------------------------------------------------------------------===//
5436 include "ARMInstrThumb2.td"
5438 //===----------------------------------------------------------------------===//
5439 // Floating Point Support
5442 include "ARMInstrVFP.td"
5444 //===----------------------------------------------------------------------===//
5445 // Advanced SIMD (NEON) Support
5448 include "ARMInstrNEON.td"
5450 //===----------------------------------------------------------------------===//
5451 // Assembler aliases
5455 def : InstAlias<"dmb", (DMB 0xf)>, Requires<[IsARM, HasDB]>;
5456 def : InstAlias<"dsb", (DSB 0xf)>, Requires<[IsARM, HasDB]>;
5457 def : InstAlias<"isb", (ISB 0xf)>, Requires<[IsARM, HasDB]>;
5459 // System instructions
5460 def : MnemonicAlias<"swi", "svc">;
5462 // Load / Store Multiple
5463 def : MnemonicAlias<"ldmfd", "ldm">;
5464 def : MnemonicAlias<"ldmia", "ldm">;
5465 def : MnemonicAlias<"ldmea", "ldmdb">;
5466 def : MnemonicAlias<"stmfd", "stmdb">;
5467 def : MnemonicAlias<"stmia", "stm">;
5468 def : MnemonicAlias<"stmea", "stm">;
5470 // PKHBT/PKHTB with default shift amount. PKHTB is equivalent to PKHBT when the
5471 // shift amount is zero (i.e., unspecified).
5472 def : InstAlias<"pkhbt${p} $Rd, $Rn, $Rm",
5473 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
5474 Requires<[IsARM, HasV6]>;
5475 def : InstAlias<"pkhtb${p} $Rd, $Rn, $Rm",
5476 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
5477 Requires<[IsARM, HasV6]>;
5479 // PUSH/POP aliases for STM/LDM
5480 def : ARMInstAlias<"push${p} $regs", (STMDB_UPD SP, pred:$p, reglist:$regs)>;
5481 def : ARMInstAlias<"pop${p} $regs", (LDMIA_UPD SP, pred:$p, reglist:$regs)>;
5483 // SSAT/USAT optional shift operand.
5484 def : ARMInstAlias<"ssat${p} $Rd, $sat_imm, $Rn",
5485 (SSAT GPRnopc:$Rd, imm1_32:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5486 def : ARMInstAlias<"usat${p} $Rd, $sat_imm, $Rn",
5487 (USAT GPRnopc:$Rd, imm0_31:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5490 // Extend instruction optional rotate operand.
5491 def : ARMInstAlias<"sxtab${p} $Rd, $Rn, $Rm",
5492 (SXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5493 def : ARMInstAlias<"sxtah${p} $Rd, $Rn, $Rm",
5494 (SXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5495 def : ARMInstAlias<"sxtab16${p} $Rd, $Rn, $Rm",
5496 (SXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5497 def : ARMInstAlias<"sxtb${p} $Rd, $Rm",
5498 (SXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5499 def : ARMInstAlias<"sxtb16${p} $Rd, $Rm",
5500 (SXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5501 def : ARMInstAlias<"sxth${p} $Rd, $Rm",
5502 (SXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5504 def : ARMInstAlias<"uxtab${p} $Rd, $Rn, $Rm",
5505 (UXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5506 def : ARMInstAlias<"uxtah${p} $Rd, $Rn, $Rm",
5507 (UXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5508 def : ARMInstAlias<"uxtab16${p} $Rd, $Rn, $Rm",
5509 (UXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5510 def : ARMInstAlias<"uxtb${p} $Rd, $Rm",
5511 (UXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5512 def : ARMInstAlias<"uxtb16${p} $Rd, $Rm",
5513 (UXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5514 def : ARMInstAlias<"uxth${p} $Rd, $Rm",
5515 (UXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5519 def : MnemonicAlias<"rfefa", "rfeda">;
5520 def : MnemonicAlias<"rfeea", "rfedb">;
5521 def : MnemonicAlias<"rfefd", "rfeia">;
5522 def : MnemonicAlias<"rfeed", "rfeib">;
5523 def : MnemonicAlias<"rfe", "rfeia">;
5526 def : MnemonicAlias<"srsfa", "srsib">;
5527 def : MnemonicAlias<"srsea", "srsia">;
5528 def : MnemonicAlias<"srsfd", "srsdb">;
5529 def : MnemonicAlias<"srsed", "srsda">;
5530 def : MnemonicAlias<"srs", "srsia">;
5533 def : MnemonicAlias<"qsubaddx", "qsax">;
5535 def : MnemonicAlias<"saddsubx", "sasx">;
5536 // SHASX == SHADDSUBX
5537 def : MnemonicAlias<"shaddsubx", "shasx">;
5538 // SHSAX == SHSUBADDX
5539 def : MnemonicAlias<"shsubaddx", "shsax">;
5541 def : MnemonicAlias<"ssubaddx", "ssax">;
5543 def : MnemonicAlias<"uaddsubx", "uasx">;
5544 // UHASX == UHADDSUBX
5545 def : MnemonicAlias<"uhaddsubx", "uhasx">;
5546 // UHSAX == UHSUBADDX
5547 def : MnemonicAlias<"uhsubaddx", "uhsax">;
5548 // UQASX == UQADDSUBX
5549 def : MnemonicAlias<"uqaddsubx", "uqasx">;
5550 // UQSAX == UQSUBADDX
5551 def : MnemonicAlias<"uqsubaddx", "uqsax">;
5553 def : MnemonicAlias<"usubaddx", "usax">;
5555 // "mov Rd, mod_imm_not" can be handled via "mvn" in assembly, just like
5557 def : ARMInstAlias<"mov${s}${p} $Rd, $imm",
5558 (MVNi rGPR:$Rd, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
5559 def : ARMInstAlias<"mvn${s}${p} $Rd, $imm",
5560 (MOVi rGPR:$Rd, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
5561 // Same for AND <--> BIC
5562 def : ARMInstAlias<"bic${s}${p} $Rd, $Rn, $imm",
5563 (ANDri rGPR:$Rd, rGPR:$Rn, mod_imm_not:$imm,
5564 pred:$p, cc_out:$s)>;
5565 def : ARMInstAlias<"bic${s}${p} $Rdn, $imm",
5566 (ANDri rGPR:$Rdn, rGPR:$Rdn, mod_imm_not:$imm,
5567 pred:$p, cc_out:$s)>;
5568 def : ARMInstAlias<"and${s}${p} $Rd, $Rn, $imm",
5569 (BICri rGPR:$Rd, rGPR:$Rn, mod_imm_not:$imm,
5570 pred:$p, cc_out:$s)>;
5571 def : ARMInstAlias<"and${s}${p} $Rdn, $imm",
5572 (BICri rGPR:$Rdn, rGPR:$Rdn, mod_imm_not:$imm,
5573 pred:$p, cc_out:$s)>;
5575 // Likewise, "add Rd, mod_imm_neg" -> sub
5576 def : ARMInstAlias<"add${s}${p} $Rd, $Rn, $imm",
5577 (SUBri GPR:$Rd, GPR:$Rn, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
5578 def : ARMInstAlias<"add${s}${p} $Rd, $imm",
5579 (SUBri GPR:$Rd, GPR:$Rd, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
5580 // Same for CMP <--> CMN via mod_imm_neg
5581 def : ARMInstAlias<"cmp${p} $Rd, $imm",
5582 (CMNri rGPR:$Rd, mod_imm_neg:$imm, pred:$p)>;
5583 def : ARMInstAlias<"cmn${p} $Rd, $imm",
5584 (CMPri rGPR:$Rd, mod_imm_neg:$imm, pred:$p)>;
5586 // The shifter forms of the MOV instruction are aliased to the ASR, LSL,
5587 // LSR, ROR, and RRX instructions.
5588 // FIXME: We need C++ parser hooks to map the alias to the MOV
5589 // encoding. It seems we should be able to do that sort of thing
5590 // in tblgen, but it could get ugly.
5591 let TwoOperandAliasConstraint = "$Rm = $Rd" in {
5592 def ASRi : ARMAsmPseudo<"asr${s}${p} $Rd, $Rm, $imm",
5593 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
5595 def LSRi : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rm, $imm",
5596 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
5598 def LSLi : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rm, $imm",
5599 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
5601 def RORi : ARMAsmPseudo<"ror${s}${p} $Rd, $Rm, $imm",
5602 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
5605 def RRXi : ARMAsmPseudo<"rrx${s}${p} $Rd, $Rm",
5606 (ins GPR:$Rd, GPR:$Rm, pred:$p, cc_out:$s)>;
5607 let TwoOperandAliasConstraint = "$Rn = $Rd" in {
5608 def ASRr : ARMAsmPseudo<"asr${s}${p} $Rd, $Rn, $Rm",
5609 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5611 def LSRr : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rn, $Rm",
5612 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5614 def LSLr : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rn, $Rm",
5615 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5617 def RORr : ARMAsmPseudo<"ror${s}${p} $Rd, $Rn, $Rm",
5618 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5622 // "neg" is and alias for "rsb rd, rn, #0"
5623 def : ARMInstAlias<"neg${s}${p} $Rd, $Rm",
5624 (RSBri GPR:$Rd, GPR:$Rm, 0, pred:$p, cc_out:$s)>;
5626 // Pre-v6, 'mov r0, r0' was used as a NOP encoding.
5627 def : InstAlias<"nop${p}", (MOVr R0, R0, pred:$p, zero_reg)>,
5628 Requires<[IsARM, NoV6]>;
5630 // MUL/UMLAL/SMLAL/UMULL/SMULL are available on all arches, but
5631 // the instruction definitions need difference constraints pre-v6.
5632 // Use these aliases for the assembly parsing on pre-v6.
5633 def : InstAlias<"mul${s}${p} $Rd, $Rn, $Rm",
5634 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s)>,
5635 Requires<[IsARM, NoV6]>;
5636 def : InstAlias<"mla${s}${p} $Rd, $Rn, $Rm, $Ra",
5637 (MLA GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra,
5638 pred:$p, cc_out:$s)>,
5639 Requires<[IsARM, NoV6]>;
5640 def : InstAlias<"smlal${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5641 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5642 Requires<[IsARM, NoV6]>;
5643 def : InstAlias<"umlal${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5644 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5645 Requires<[IsARM, NoV6]>;
5646 def : InstAlias<"smull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5647 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5648 Requires<[IsARM, NoV6]>;
5649 def : InstAlias<"umull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5650 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5651 Requires<[IsARM, NoV6]>;
5653 // 'it' blocks in ARM mode just validate the predicates. The IT itself
5655 def ITasm : ARMAsmPseudo<"it$mask $cc", (ins it_pred:$cc, it_mask:$mask)>,
5656 ComplexDeprecationPredicate<"IT">;
5658 let mayLoad = 1, mayStore =1, hasSideEffects = 1 in
5659 def SPACE : PseudoInst<(outs GPR:$Rd), (ins i32imm:$size, GPR:$Rn),
5661 [(set GPR:$Rd, (int_arm_space imm:$size, GPR:$Rn))]>;