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 NoVFP : Predicate<"!Subtarget->hasVFP2()">;
212 def HasVFP2 : Predicate<"Subtarget->hasVFP2()">,
213 AssemblerPredicate<"FeatureVFP2", "VFP2">;
214 def HasVFP3 : Predicate<"Subtarget->hasVFP3()">,
215 AssemblerPredicate<"FeatureVFP3", "VFP3">;
216 def HasVFP4 : Predicate<"Subtarget->hasVFP4()">,
217 AssemblerPredicate<"FeatureVFP4", "VFP4">;
218 def HasDPVFP : Predicate<"!Subtarget->isFPOnlySP()">,
219 AssemblerPredicate<"!FeatureVFPOnlySP",
220 "double precision VFP">;
221 def HasFPARMv8 : Predicate<"Subtarget->hasFPARMv8()">,
222 AssemblerPredicate<"FeatureFPARMv8", "FPARMv8">;
223 def HasNEON : Predicate<"Subtarget->hasNEON()">,
224 AssemblerPredicate<"FeatureNEON", "NEON">;
225 def HasCrypto : Predicate<"Subtarget->hasCrypto()">,
226 AssemblerPredicate<"FeatureCrypto", "crypto">;
227 def HasCRC : Predicate<"Subtarget->hasCRC()">,
228 AssemblerPredicate<"FeatureCRC", "crc">;
229 def HasV8_1a : Predicate<"Subtarget->hasV8_1a()">,
230 AssemblerPredicate<"FeatureV8_1a", "v8.1a">;
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"; }
392 // FIXME: rename brtarget to t2_brtarget
393 def brtarget : Operand<OtherVT> {
394 let EncoderMethod = "getBranchTargetOpValue";
395 let OperandType = "OPERAND_PCREL";
396 let DecoderMethod = "DecodeT2BROperand";
399 // FIXME: get rid of this one?
400 def uncondbrtarget : Operand<OtherVT> {
401 let EncoderMethod = "getUnconditionalBranchTargetOpValue";
402 let OperandType = "OPERAND_PCREL";
405 // Branch target for ARM. Handles conditional/unconditional
406 def br_target : Operand<OtherVT> {
407 let EncoderMethod = "getARMBranchTargetOpValue";
408 let OperandType = "OPERAND_PCREL";
412 // FIXME: rename bltarget to t2_bl_target?
413 def bltarget : Operand<i32> {
414 // Encoded the same as branch targets.
415 let EncoderMethod = "getBranchTargetOpValue";
416 let OperandType = "OPERAND_PCREL";
419 // Call target for ARM. Handles conditional/unconditional
420 // FIXME: rename bl_target to t2_bltarget?
421 def bl_target : Operand<i32> {
422 let EncoderMethod = "getARMBLTargetOpValue";
423 let OperandType = "OPERAND_PCREL";
426 def blx_target : Operand<i32> {
427 let EncoderMethod = "getARMBLXTargetOpValue";
428 let OperandType = "OPERAND_PCREL";
431 // A list of registers separated by comma. Used by load/store multiple.
432 def RegListAsmOperand : AsmOperandClass { let Name = "RegList"; }
433 def reglist : Operand<i32> {
434 let EncoderMethod = "getRegisterListOpValue";
435 let ParserMatchClass = RegListAsmOperand;
436 let PrintMethod = "printRegisterList";
437 let DecoderMethod = "DecodeRegListOperand";
440 def GPRPairOp : RegisterOperand<GPRPair, "printGPRPairOperand">;
442 def DPRRegListAsmOperand : AsmOperandClass { let Name = "DPRRegList"; }
443 def dpr_reglist : Operand<i32> {
444 let EncoderMethod = "getRegisterListOpValue";
445 let ParserMatchClass = DPRRegListAsmOperand;
446 let PrintMethod = "printRegisterList";
447 let DecoderMethod = "DecodeDPRRegListOperand";
450 def SPRRegListAsmOperand : AsmOperandClass { let Name = "SPRRegList"; }
451 def spr_reglist : Operand<i32> {
452 let EncoderMethod = "getRegisterListOpValue";
453 let ParserMatchClass = SPRRegListAsmOperand;
454 let PrintMethod = "printRegisterList";
455 let DecoderMethod = "DecodeSPRRegListOperand";
458 // An operand for the CONSTPOOL_ENTRY pseudo-instruction.
459 def cpinst_operand : Operand<i32> {
460 let PrintMethod = "printCPInstOperand";
464 def pclabel : Operand<i32> {
465 let PrintMethod = "printPCLabel";
468 // ADR instruction labels.
469 def AdrLabelAsmOperand : AsmOperandClass { let Name = "AdrLabel"; }
470 def adrlabel : Operand<i32> {
471 let EncoderMethod = "getAdrLabelOpValue";
472 let ParserMatchClass = AdrLabelAsmOperand;
473 let PrintMethod = "printAdrLabelOperand<0>";
476 def neon_vcvt_imm32 : Operand<i32> {
477 let EncoderMethod = "getNEONVcvtImm32OpValue";
478 let DecoderMethod = "DecodeVCVTImmOperand";
481 // rot_imm: An integer that encodes a rotate amount. Must be 8, 16, or 24.
482 def rot_imm_XFORM: SDNodeXForm<imm, [{
483 switch (N->getZExtValue()){
484 default: llvm_unreachable(nullptr);
485 case 0: return CurDAG->getTargetConstant(0, MVT::i32);
486 case 8: return CurDAG->getTargetConstant(1, MVT::i32);
487 case 16: return CurDAG->getTargetConstant(2, MVT::i32);
488 case 24: return CurDAG->getTargetConstant(3, MVT::i32);
491 def RotImmAsmOperand : AsmOperandClass {
493 let ParserMethod = "parseRotImm";
495 def rot_imm : Operand<i32>, PatLeaf<(i32 imm), [{
496 int32_t v = N->getZExtValue();
497 return v == 8 || v == 16 || v == 24; }],
499 let PrintMethod = "printRotImmOperand";
500 let ParserMatchClass = RotImmAsmOperand;
503 // shift_imm: An integer that encodes a shift amount and the type of shift
504 // (asr or lsl). The 6-bit immediate encodes as:
507 // {4-0} imm5 shift amount.
508 // asr #32 encoded as imm5 == 0.
509 def ShifterImmAsmOperand : AsmOperandClass {
510 let Name = "ShifterImm";
511 let ParserMethod = "parseShifterImm";
513 def shift_imm : Operand<i32> {
514 let PrintMethod = "printShiftImmOperand";
515 let ParserMatchClass = ShifterImmAsmOperand;
518 // shifter_operand operands: so_reg_reg, so_reg_imm, and mod_imm.
519 def ShiftedRegAsmOperand : AsmOperandClass { let Name = "RegShiftedReg"; }
520 def so_reg_reg : Operand<i32>, // reg reg imm
521 ComplexPattern<i32, 3, "SelectRegShifterOperand",
522 [shl, srl, sra, rotr]> {
523 let EncoderMethod = "getSORegRegOpValue";
524 let PrintMethod = "printSORegRegOperand";
525 let DecoderMethod = "DecodeSORegRegOperand";
526 let ParserMatchClass = ShiftedRegAsmOperand;
527 let MIOperandInfo = (ops GPRnopc, GPRnopc, i32imm);
530 def ShiftedImmAsmOperand : AsmOperandClass { let Name = "RegShiftedImm"; }
531 def so_reg_imm : Operand<i32>, // reg imm
532 ComplexPattern<i32, 2, "SelectImmShifterOperand",
533 [shl, srl, sra, rotr]> {
534 let EncoderMethod = "getSORegImmOpValue";
535 let PrintMethod = "printSORegImmOperand";
536 let DecoderMethod = "DecodeSORegImmOperand";
537 let ParserMatchClass = ShiftedImmAsmOperand;
538 let MIOperandInfo = (ops GPR, i32imm);
541 // FIXME: Does this need to be distinct from so_reg?
542 def shift_so_reg_reg : Operand<i32>, // reg reg imm
543 ComplexPattern<i32, 3, "SelectShiftRegShifterOperand",
544 [shl,srl,sra,rotr]> {
545 let EncoderMethod = "getSORegRegOpValue";
546 let PrintMethod = "printSORegRegOperand";
547 let DecoderMethod = "DecodeSORegRegOperand";
548 let ParserMatchClass = ShiftedRegAsmOperand;
549 let MIOperandInfo = (ops GPR, GPR, i32imm);
552 // FIXME: Does this need to be distinct from so_reg?
553 def shift_so_reg_imm : Operand<i32>, // reg reg imm
554 ComplexPattern<i32, 2, "SelectShiftImmShifterOperand",
555 [shl,srl,sra,rotr]> {
556 let EncoderMethod = "getSORegImmOpValue";
557 let PrintMethod = "printSORegImmOperand";
558 let DecoderMethod = "DecodeSORegImmOperand";
559 let ParserMatchClass = ShiftedImmAsmOperand;
560 let MIOperandInfo = (ops GPR, i32imm);
563 // mod_imm: match a 32-bit immediate operand, which can be encoded into
564 // a 12-bit immediate; an 8-bit integer and a 4-bit rotator (See ARMARM
565 // - "Modified Immediate Constants"). Within the MC layer we keep this
566 // immediate in its encoded form.
567 def ModImmAsmOperand: AsmOperandClass {
569 let ParserMethod = "parseModImm";
571 def mod_imm : Operand<i32>, ImmLeaf<i32, [{
572 return ARM_AM::getSOImmVal(Imm) != -1;
574 let EncoderMethod = "getModImmOpValue";
575 let PrintMethod = "printModImmOperand";
576 let ParserMatchClass = ModImmAsmOperand;
579 // Note: the patterns mod_imm_not and mod_imm_neg do not require an encoder
580 // method and such, as they are only used on aliases (Pat<> and InstAlias<>).
581 // The actual parsing, encoding, decoding are handled by the destination
582 // instructions, which use mod_imm.
584 def ModImmNotAsmOperand : AsmOperandClass { let Name = "ModImmNot"; }
585 def mod_imm_not : Operand<i32>, PatLeaf<(imm), [{
586 return ARM_AM::getSOImmVal(~(uint32_t)N->getZExtValue()) != -1;
588 let ParserMatchClass = ModImmNotAsmOperand;
591 def ModImmNegAsmOperand : AsmOperandClass { let Name = "ModImmNeg"; }
592 def mod_imm_neg : Operand<i32>, PatLeaf<(imm), [{
593 unsigned Value = -(unsigned)N->getZExtValue();
594 return Value && ARM_AM::getSOImmVal(Value) != -1;
596 let ParserMatchClass = ModImmNegAsmOperand;
599 /// arm_i32imm - True for +V6T2, or when isSOImmTwoParVal()
600 def arm_i32imm : PatLeaf<(imm), [{
601 if (Subtarget->useMovt(*MF))
603 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
606 /// imm0_1 predicate - Immediate in the range [0,1].
607 def Imm0_1AsmOperand: ImmAsmOperand { let Name = "Imm0_1"; }
608 def imm0_1 : Operand<i32> { let ParserMatchClass = Imm0_1AsmOperand; }
610 /// imm0_3 predicate - Immediate in the range [0,3].
611 def Imm0_3AsmOperand: ImmAsmOperand { let Name = "Imm0_3"; }
612 def imm0_3 : Operand<i32> { let ParserMatchClass = Imm0_3AsmOperand; }
614 /// imm0_7 predicate - Immediate in the range [0,7].
615 def Imm0_7AsmOperand: ImmAsmOperand { let Name = "Imm0_7"; }
616 def imm0_7 : Operand<i32>, ImmLeaf<i32, [{
617 return Imm >= 0 && Imm < 8;
619 let ParserMatchClass = Imm0_7AsmOperand;
622 /// imm8 predicate - Immediate is exactly 8.
623 def Imm8AsmOperand: ImmAsmOperand { let Name = "Imm8"; }
624 def imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 8; }]> {
625 let ParserMatchClass = Imm8AsmOperand;
628 /// imm16 predicate - Immediate is exactly 16.
629 def Imm16AsmOperand: ImmAsmOperand { let Name = "Imm16"; }
630 def imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 16; }]> {
631 let ParserMatchClass = Imm16AsmOperand;
634 /// imm32 predicate - Immediate is exactly 32.
635 def Imm32AsmOperand: ImmAsmOperand { let Name = "Imm32"; }
636 def imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 32; }]> {
637 let ParserMatchClass = Imm32AsmOperand;
640 def imm8_or_16 : ImmLeaf<i32, [{ return Imm == 8 || Imm == 16;}]>;
642 /// imm1_7 predicate - Immediate in the range [1,7].
643 def Imm1_7AsmOperand: ImmAsmOperand { let Name = "Imm1_7"; }
644 def imm1_7 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 8; }]> {
645 let ParserMatchClass = Imm1_7AsmOperand;
648 /// imm1_15 predicate - Immediate in the range [1,15].
649 def Imm1_15AsmOperand: ImmAsmOperand { let Name = "Imm1_15"; }
650 def imm1_15 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 16; }]> {
651 let ParserMatchClass = Imm1_15AsmOperand;
654 /// imm1_31 predicate - Immediate in the range [1,31].
655 def Imm1_31AsmOperand: ImmAsmOperand { let Name = "Imm1_31"; }
656 def imm1_31 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 32; }]> {
657 let ParserMatchClass = Imm1_31AsmOperand;
660 /// imm0_15 predicate - Immediate in the range [0,15].
661 def Imm0_15AsmOperand: ImmAsmOperand {
662 let Name = "Imm0_15";
663 let DiagnosticType = "ImmRange0_15";
665 def imm0_15 : Operand<i32>, ImmLeaf<i32, [{
666 return Imm >= 0 && Imm < 16;
668 let ParserMatchClass = Imm0_15AsmOperand;
671 /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
672 def Imm0_31AsmOperand: ImmAsmOperand { let Name = "Imm0_31"; }
673 def imm0_31 : Operand<i32>, ImmLeaf<i32, [{
674 return Imm >= 0 && Imm < 32;
676 let ParserMatchClass = Imm0_31AsmOperand;
679 /// imm0_32 predicate - True if the 32-bit immediate is in the range [0,32].
680 def Imm0_32AsmOperand: ImmAsmOperand { let Name = "Imm0_32"; }
681 def imm0_32 : Operand<i32>, ImmLeaf<i32, [{
682 return Imm >= 0 && Imm < 32;
684 let ParserMatchClass = Imm0_32AsmOperand;
687 /// imm0_63 predicate - True if the 32-bit immediate is in the range [0,63].
688 def Imm0_63AsmOperand: ImmAsmOperand { let Name = "Imm0_63"; }
689 def imm0_63 : Operand<i32>, ImmLeaf<i32, [{
690 return Imm >= 0 && Imm < 64;
692 let ParserMatchClass = Imm0_63AsmOperand;
695 /// imm0_239 predicate - Immediate in the range [0,239].
696 def Imm0_239AsmOperand : ImmAsmOperand {
697 let Name = "Imm0_239";
698 let DiagnosticType = "ImmRange0_239";
700 def imm0_239 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 240; }]> {
701 let ParserMatchClass = Imm0_239AsmOperand;
704 /// imm0_255 predicate - Immediate in the range [0,255].
705 def Imm0_255AsmOperand : ImmAsmOperand { let Name = "Imm0_255"; }
706 def imm0_255 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 256; }]> {
707 let ParserMatchClass = Imm0_255AsmOperand;
710 /// imm0_65535 - An immediate is in the range [0.65535].
711 def Imm0_65535AsmOperand: ImmAsmOperand { let Name = "Imm0_65535"; }
712 def imm0_65535 : Operand<i32>, ImmLeaf<i32, [{
713 return Imm >= 0 && Imm < 65536;
715 let ParserMatchClass = Imm0_65535AsmOperand;
718 // imm0_65535_neg - An immediate whose negative value is in the range [0.65535].
719 def imm0_65535_neg : Operand<i32>, ImmLeaf<i32, [{
720 return -Imm >= 0 && -Imm < 65536;
723 // imm0_65535_expr - For movt/movw - 16-bit immediate that can also reference
724 // a relocatable expression.
726 // FIXME: This really needs a Thumb version separate from the ARM version.
727 // While the range is the same, and can thus use the same match class,
728 // the encoding is different so it should have a different encoder method.
729 def Imm0_65535ExprAsmOperand: ImmAsmOperand { let Name = "Imm0_65535Expr"; }
730 def imm0_65535_expr : Operand<i32> {
731 let EncoderMethod = "getHiLo16ImmOpValue";
732 let ParserMatchClass = Imm0_65535ExprAsmOperand;
735 def Imm256_65535ExprAsmOperand: ImmAsmOperand { let Name = "Imm256_65535Expr"; }
736 def imm256_65535_expr : Operand<i32> {
737 let ParserMatchClass = Imm256_65535ExprAsmOperand;
740 /// imm24b - True if the 32-bit immediate is encodable in 24 bits.
741 def Imm24bitAsmOperand: ImmAsmOperand { let Name = "Imm24bit"; }
742 def imm24b : Operand<i32>, ImmLeaf<i32, [{
743 return Imm >= 0 && Imm <= 0xffffff;
745 let ParserMatchClass = Imm24bitAsmOperand;
749 /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
751 def BitfieldAsmOperand : AsmOperandClass {
752 let Name = "Bitfield";
753 let ParserMethod = "parseBitfield";
756 def bf_inv_mask_imm : Operand<i32>,
758 return ARM::isBitFieldInvertedMask(N->getZExtValue());
760 let EncoderMethod = "getBitfieldInvertedMaskOpValue";
761 let PrintMethod = "printBitfieldInvMaskImmOperand";
762 let DecoderMethod = "DecodeBitfieldMaskOperand";
763 let ParserMatchClass = BitfieldAsmOperand;
766 def imm1_32_XFORM: SDNodeXForm<imm, [{
767 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, MVT::i32);
769 def Imm1_32AsmOperand: AsmOperandClass { let Name = "Imm1_32"; }
770 def imm1_32 : Operand<i32>, PatLeaf<(imm), [{
771 uint64_t Imm = N->getZExtValue();
772 return Imm > 0 && Imm <= 32;
775 let PrintMethod = "printImmPlusOneOperand";
776 let ParserMatchClass = Imm1_32AsmOperand;
779 def imm1_16_XFORM: SDNodeXForm<imm, [{
780 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, MVT::i32);
782 def Imm1_16AsmOperand: AsmOperandClass { let Name = "Imm1_16"; }
783 def imm1_16 : Operand<i32>, PatLeaf<(imm), [{ return Imm > 0 && Imm <= 16; }],
785 let PrintMethod = "printImmPlusOneOperand";
786 let ParserMatchClass = Imm1_16AsmOperand;
789 // Define ARM specific addressing modes.
790 // addrmode_imm12 := reg +/- imm12
792 def MemImm12OffsetAsmOperand : AsmOperandClass { let Name = "MemImm12Offset"; }
793 class AddrMode_Imm12 : Operand<i32>,
794 ComplexPattern<i32, 2, "SelectAddrModeImm12", []> {
795 // 12-bit immediate operand. Note that instructions using this encode
796 // #0 and #-0 differently. We flag #-0 as the magic value INT32_MIN. All other
797 // immediate values are as normal.
799 let EncoderMethod = "getAddrModeImm12OpValue";
800 let DecoderMethod = "DecodeAddrModeImm12Operand";
801 let ParserMatchClass = MemImm12OffsetAsmOperand;
802 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
805 def addrmode_imm12 : AddrMode_Imm12 {
806 let PrintMethod = "printAddrModeImm12Operand<false>";
809 def addrmode_imm12_pre : AddrMode_Imm12 {
810 let PrintMethod = "printAddrModeImm12Operand<true>";
813 // ldst_so_reg := reg +/- reg shop imm
815 def MemRegOffsetAsmOperand : AsmOperandClass { let Name = "MemRegOffset"; }
816 def ldst_so_reg : Operand<i32>,
817 ComplexPattern<i32, 3, "SelectLdStSOReg", []> {
818 let EncoderMethod = "getLdStSORegOpValue";
819 // FIXME: Simplify the printer
820 let PrintMethod = "printAddrMode2Operand";
821 let DecoderMethod = "DecodeSORegMemOperand";
822 let ParserMatchClass = MemRegOffsetAsmOperand;
823 let MIOperandInfo = (ops GPR:$base, GPRnopc:$offsreg, i32imm:$shift);
826 // postidx_imm8 := +/- [0,255]
829 // {8} 1 is imm8 is non-negative. 0 otherwise.
830 // {7-0} [0,255] imm8 value.
831 def PostIdxImm8AsmOperand : AsmOperandClass { let Name = "PostIdxImm8"; }
832 def postidx_imm8 : Operand<i32> {
833 let PrintMethod = "printPostIdxImm8Operand";
834 let ParserMatchClass = PostIdxImm8AsmOperand;
835 let MIOperandInfo = (ops i32imm);
838 // postidx_imm8s4 := +/- [0,1020]
841 // {8} 1 is imm8 is non-negative. 0 otherwise.
842 // {7-0} [0,255] imm8 value, scaled by 4.
843 def PostIdxImm8s4AsmOperand : AsmOperandClass { let Name = "PostIdxImm8s4"; }
844 def postidx_imm8s4 : Operand<i32> {
845 let PrintMethod = "printPostIdxImm8s4Operand";
846 let ParserMatchClass = PostIdxImm8s4AsmOperand;
847 let MIOperandInfo = (ops i32imm);
851 // postidx_reg := +/- reg
853 def PostIdxRegAsmOperand : AsmOperandClass {
854 let Name = "PostIdxReg";
855 let ParserMethod = "parsePostIdxReg";
857 def postidx_reg : Operand<i32> {
858 let EncoderMethod = "getPostIdxRegOpValue";
859 let DecoderMethod = "DecodePostIdxReg";
860 let PrintMethod = "printPostIdxRegOperand";
861 let ParserMatchClass = PostIdxRegAsmOperand;
862 let MIOperandInfo = (ops GPRnopc, i32imm);
866 // addrmode2 := reg +/- imm12
867 // := reg +/- reg shop imm
869 // FIXME: addrmode2 should be refactored the rest of the way to always
870 // use explicit imm vs. reg versions above (addrmode_imm12 and ldst_so_reg).
871 def AddrMode2AsmOperand : AsmOperandClass { let Name = "AddrMode2"; }
872 def addrmode2 : Operand<i32>,
873 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
874 let EncoderMethod = "getAddrMode2OpValue";
875 let PrintMethod = "printAddrMode2Operand";
876 let ParserMatchClass = AddrMode2AsmOperand;
877 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
880 def PostIdxRegShiftedAsmOperand : AsmOperandClass {
881 let Name = "PostIdxRegShifted";
882 let ParserMethod = "parsePostIdxReg";
884 def am2offset_reg : Operand<i32>,
885 ComplexPattern<i32, 2, "SelectAddrMode2OffsetReg",
886 [], [SDNPWantRoot]> {
887 let EncoderMethod = "getAddrMode2OffsetOpValue";
888 let PrintMethod = "printAddrMode2OffsetOperand";
889 // When using this for assembly, it's always as a post-index offset.
890 let ParserMatchClass = PostIdxRegShiftedAsmOperand;
891 let MIOperandInfo = (ops GPRnopc, i32imm);
894 // FIXME: am2offset_imm should only need the immediate, not the GPR. Having
895 // the GPR is purely vestigal at this point.
896 def AM2OffsetImmAsmOperand : AsmOperandClass { let Name = "AM2OffsetImm"; }
897 def am2offset_imm : Operand<i32>,
898 ComplexPattern<i32, 2, "SelectAddrMode2OffsetImm",
899 [], [SDNPWantRoot]> {
900 let EncoderMethod = "getAddrMode2OffsetOpValue";
901 let PrintMethod = "printAddrMode2OffsetOperand";
902 let ParserMatchClass = AM2OffsetImmAsmOperand;
903 let MIOperandInfo = (ops GPRnopc, i32imm);
907 // addrmode3 := reg +/- reg
908 // addrmode3 := reg +/- imm8
910 // FIXME: split into imm vs. reg versions.
911 def AddrMode3AsmOperand : AsmOperandClass { let Name = "AddrMode3"; }
912 class AddrMode3 : Operand<i32>,
913 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
914 let EncoderMethod = "getAddrMode3OpValue";
915 let ParserMatchClass = AddrMode3AsmOperand;
916 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
919 def addrmode3 : AddrMode3
921 let PrintMethod = "printAddrMode3Operand<false>";
924 def addrmode3_pre : AddrMode3
926 let PrintMethod = "printAddrMode3Operand<true>";
929 // FIXME: split into imm vs. reg versions.
930 // FIXME: parser method to handle +/- register.
931 def AM3OffsetAsmOperand : AsmOperandClass {
932 let Name = "AM3Offset";
933 let ParserMethod = "parseAM3Offset";
935 def am3offset : Operand<i32>,
936 ComplexPattern<i32, 2, "SelectAddrMode3Offset",
937 [], [SDNPWantRoot]> {
938 let EncoderMethod = "getAddrMode3OffsetOpValue";
939 let PrintMethod = "printAddrMode3OffsetOperand";
940 let ParserMatchClass = AM3OffsetAsmOperand;
941 let MIOperandInfo = (ops GPR, i32imm);
944 // ldstm_mode := {ia, ib, da, db}
946 def ldstm_mode : OptionalDefOperand<OtherVT, (ops i32), (ops (i32 1))> {
947 let EncoderMethod = "getLdStmModeOpValue";
948 let PrintMethod = "printLdStmModeOperand";
951 // addrmode5 := reg +/- imm8*4
953 def AddrMode5AsmOperand : AsmOperandClass { let Name = "AddrMode5"; }
954 class AddrMode5 : Operand<i32>,
955 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
956 let EncoderMethod = "getAddrMode5OpValue";
957 let DecoderMethod = "DecodeAddrMode5Operand";
958 let ParserMatchClass = AddrMode5AsmOperand;
959 let MIOperandInfo = (ops GPR:$base, i32imm);
962 def addrmode5 : AddrMode5 {
963 let PrintMethod = "printAddrMode5Operand<false>";
966 def addrmode5_pre : AddrMode5 {
967 let PrintMethod = "printAddrMode5Operand<true>";
970 // addrmode6 := reg with optional alignment
972 def AddrMode6AsmOperand : AsmOperandClass { let Name = "AlignedMemory"; }
973 def addrmode6 : Operand<i32>,
974 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
975 let PrintMethod = "printAddrMode6Operand";
976 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
977 let EncoderMethod = "getAddrMode6AddressOpValue";
978 let DecoderMethod = "DecodeAddrMode6Operand";
979 let ParserMatchClass = AddrMode6AsmOperand;
982 def am6offset : Operand<i32>,
983 ComplexPattern<i32, 1, "SelectAddrMode6Offset",
984 [], [SDNPWantRoot]> {
985 let PrintMethod = "printAddrMode6OffsetOperand";
986 let MIOperandInfo = (ops GPR);
987 let EncoderMethod = "getAddrMode6OffsetOpValue";
988 let DecoderMethod = "DecodeGPRRegisterClass";
991 // Special version of addrmode6 to handle alignment encoding for VST1/VLD1
992 // (single element from one lane) for size 32.
993 def addrmode6oneL32 : Operand<i32>,
994 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
995 let PrintMethod = "printAddrMode6Operand";
996 let MIOperandInfo = (ops GPR:$addr, i32imm);
997 let EncoderMethod = "getAddrMode6OneLane32AddressOpValue";
1000 // Base class for addrmode6 with specific alignment restrictions.
1001 class AddrMode6Align : Operand<i32>,
1002 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1003 let PrintMethod = "printAddrMode6Operand";
1004 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
1005 let EncoderMethod = "getAddrMode6AddressOpValue";
1006 let DecoderMethod = "DecodeAddrMode6Operand";
1009 // Special version of addrmode6 to handle no allowed alignment encoding for
1010 // VLD/VST instructions and checking the alignment is not specified.
1011 def AddrMode6AlignNoneAsmOperand : AsmOperandClass {
1012 let Name = "AlignedMemoryNone";
1013 let DiagnosticType = "AlignedMemoryRequiresNone";
1015 def addrmode6alignNone : AddrMode6Align {
1016 // The alignment specifier can only be omitted.
1017 let ParserMatchClass = AddrMode6AlignNoneAsmOperand;
1020 // Special version of addrmode6 to handle 16-bit alignment encoding for
1021 // VLD/VST instructions and checking the alignment value.
1022 def AddrMode6Align16AsmOperand : AsmOperandClass {
1023 let Name = "AlignedMemory16";
1024 let DiagnosticType = "AlignedMemoryRequires16";
1026 def addrmode6align16 : AddrMode6Align {
1027 // The alignment specifier can only be 16 or omitted.
1028 let ParserMatchClass = AddrMode6Align16AsmOperand;
1031 // Special version of addrmode6 to handle 32-bit alignment encoding for
1032 // VLD/VST instructions and checking the alignment value.
1033 def AddrMode6Align32AsmOperand : AsmOperandClass {
1034 let Name = "AlignedMemory32";
1035 let DiagnosticType = "AlignedMemoryRequires32";
1037 def addrmode6align32 : AddrMode6Align {
1038 // The alignment specifier can only be 32 or omitted.
1039 let ParserMatchClass = AddrMode6Align32AsmOperand;
1042 // Special version of addrmode6 to handle 64-bit alignment encoding for
1043 // VLD/VST instructions and checking the alignment value.
1044 def AddrMode6Align64AsmOperand : AsmOperandClass {
1045 let Name = "AlignedMemory64";
1046 let DiagnosticType = "AlignedMemoryRequires64";
1048 def addrmode6align64 : AddrMode6Align {
1049 // The alignment specifier can only be 64 or omitted.
1050 let ParserMatchClass = AddrMode6Align64AsmOperand;
1053 // Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding
1054 // for VLD/VST instructions and checking the alignment value.
1055 def AddrMode6Align64or128AsmOperand : AsmOperandClass {
1056 let Name = "AlignedMemory64or128";
1057 let DiagnosticType = "AlignedMemoryRequires64or128";
1059 def addrmode6align64or128 : AddrMode6Align {
1060 // The alignment specifier can only be 64, 128 or omitted.
1061 let ParserMatchClass = AddrMode6Align64or128AsmOperand;
1064 // Special version of addrmode6 to handle 64-bit, 128-bit or 256-bit alignment
1065 // encoding for VLD/VST instructions and checking the alignment value.
1066 def AddrMode6Align64or128or256AsmOperand : AsmOperandClass {
1067 let Name = "AlignedMemory64or128or256";
1068 let DiagnosticType = "AlignedMemoryRequires64or128or256";
1070 def addrmode6align64or128or256 : AddrMode6Align {
1071 // The alignment specifier can only be 64, 128, 256 or omitted.
1072 let ParserMatchClass = AddrMode6Align64or128or256AsmOperand;
1075 // Special version of addrmode6 to handle alignment encoding for VLD-dup
1076 // instructions, specifically VLD4-dup.
1077 def addrmode6dup : Operand<i32>,
1078 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1079 let PrintMethod = "printAddrMode6Operand";
1080 let MIOperandInfo = (ops GPR:$addr, i32imm);
1081 let EncoderMethod = "getAddrMode6DupAddressOpValue";
1082 // FIXME: This is close, but not quite right. The alignment specifier is
1084 let ParserMatchClass = AddrMode6AsmOperand;
1087 // Base class for addrmode6dup with specific alignment restrictions.
1088 class AddrMode6DupAlign : Operand<i32>,
1089 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1090 let PrintMethod = "printAddrMode6Operand";
1091 let MIOperandInfo = (ops GPR:$addr, i32imm);
1092 let EncoderMethod = "getAddrMode6DupAddressOpValue";
1095 // Special version of addrmode6 to handle no allowed alignment encoding for
1096 // VLD-dup instruction and checking the alignment is not specified.
1097 def AddrMode6dupAlignNoneAsmOperand : AsmOperandClass {
1098 let Name = "DupAlignedMemoryNone";
1099 let DiagnosticType = "DupAlignedMemoryRequiresNone";
1101 def addrmode6dupalignNone : AddrMode6DupAlign {
1102 // The alignment specifier can only be omitted.
1103 let ParserMatchClass = AddrMode6dupAlignNoneAsmOperand;
1106 // Special version of addrmode6 to handle 16-bit alignment encoding for VLD-dup
1107 // instruction and checking the alignment value.
1108 def AddrMode6dupAlign16AsmOperand : AsmOperandClass {
1109 let Name = "DupAlignedMemory16";
1110 let DiagnosticType = "DupAlignedMemoryRequires16";
1112 def addrmode6dupalign16 : AddrMode6DupAlign {
1113 // The alignment specifier can only be 16 or omitted.
1114 let ParserMatchClass = AddrMode6dupAlign16AsmOperand;
1117 // Special version of addrmode6 to handle 32-bit alignment encoding for VLD-dup
1118 // instruction and checking the alignment value.
1119 def AddrMode6dupAlign32AsmOperand : AsmOperandClass {
1120 let Name = "DupAlignedMemory32";
1121 let DiagnosticType = "DupAlignedMemoryRequires32";
1123 def addrmode6dupalign32 : AddrMode6DupAlign {
1124 // The alignment specifier can only be 32 or omitted.
1125 let ParserMatchClass = AddrMode6dupAlign32AsmOperand;
1128 // Special version of addrmode6 to handle 64-bit alignment encoding for VLD
1129 // instructions and checking the alignment value.
1130 def AddrMode6dupAlign64AsmOperand : AsmOperandClass {
1131 let Name = "DupAlignedMemory64";
1132 let DiagnosticType = "DupAlignedMemoryRequires64";
1134 def addrmode6dupalign64 : AddrMode6DupAlign {
1135 // The alignment specifier can only be 64 or omitted.
1136 let ParserMatchClass = AddrMode6dupAlign64AsmOperand;
1139 // Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding
1140 // for VLD instructions and checking the alignment value.
1141 def AddrMode6dupAlign64or128AsmOperand : AsmOperandClass {
1142 let Name = "DupAlignedMemory64or128";
1143 let DiagnosticType = "DupAlignedMemoryRequires64or128";
1145 def addrmode6dupalign64or128 : AddrMode6DupAlign {
1146 // The alignment specifier can only be 64, 128 or omitted.
1147 let ParserMatchClass = AddrMode6dupAlign64or128AsmOperand;
1150 // addrmodepc := pc + reg
1152 def addrmodepc : Operand<i32>,
1153 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
1154 let PrintMethod = "printAddrModePCOperand";
1155 let MIOperandInfo = (ops GPR, i32imm);
1158 // addr_offset_none := reg
1160 def MemNoOffsetAsmOperand : AsmOperandClass { let Name = "MemNoOffset"; }
1161 def addr_offset_none : Operand<i32>,
1162 ComplexPattern<i32, 1, "SelectAddrOffsetNone", []> {
1163 let PrintMethod = "printAddrMode7Operand";
1164 let DecoderMethod = "DecodeAddrMode7Operand";
1165 let ParserMatchClass = MemNoOffsetAsmOperand;
1166 let MIOperandInfo = (ops GPR:$base);
1169 def nohash_imm : Operand<i32> {
1170 let PrintMethod = "printNoHashImmediate";
1173 def CoprocNumAsmOperand : AsmOperandClass {
1174 let Name = "CoprocNum";
1175 let ParserMethod = "parseCoprocNumOperand";
1177 def p_imm : Operand<i32> {
1178 let PrintMethod = "printPImmediate";
1179 let ParserMatchClass = CoprocNumAsmOperand;
1180 let DecoderMethod = "DecodeCoprocessor";
1183 def CoprocRegAsmOperand : AsmOperandClass {
1184 let Name = "CoprocReg";
1185 let ParserMethod = "parseCoprocRegOperand";
1187 def c_imm : Operand<i32> {
1188 let PrintMethod = "printCImmediate";
1189 let ParserMatchClass = CoprocRegAsmOperand;
1191 def CoprocOptionAsmOperand : AsmOperandClass {
1192 let Name = "CoprocOption";
1193 let ParserMethod = "parseCoprocOptionOperand";
1195 def coproc_option_imm : Operand<i32> {
1196 let PrintMethod = "printCoprocOptionImm";
1197 let ParserMatchClass = CoprocOptionAsmOperand;
1200 //===----------------------------------------------------------------------===//
1202 include "ARMInstrFormats.td"
1204 //===----------------------------------------------------------------------===//
1205 // Multiclass helpers...
1208 /// AsI1_bin_irs - Defines a set of (op r, {mod_imm|r|so_reg}) patterns for a
1209 /// binop that produces a value.
1210 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1211 multiclass AsI1_bin_irs<bits<4> opcod, string opc,
1212 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1213 PatFrag opnode, bit Commutable = 0> {
1214 // The register-immediate version is re-materializable. This is useful
1215 // in particular for taking the address of a local.
1216 let isReMaterializable = 1 in {
1217 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm,
1218 iii, opc, "\t$Rd, $Rn, $imm",
1219 [(set GPR:$Rd, (opnode GPR:$Rn, mod_imm:$imm))]>,
1220 Sched<[WriteALU, ReadALU]> {
1225 let Inst{19-16} = Rn;
1226 let Inst{15-12} = Rd;
1227 let Inst{11-0} = imm;
1230 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1231 iir, opc, "\t$Rd, $Rn, $Rm",
1232 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]>,
1233 Sched<[WriteALU, ReadALU, ReadALU]> {
1238 let isCommutable = Commutable;
1239 let Inst{19-16} = Rn;
1240 let Inst{15-12} = Rd;
1241 let Inst{11-4} = 0b00000000;
1245 def rsi : AsI1<opcod, (outs GPR:$Rd),
1246 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1247 iis, opc, "\t$Rd, $Rn, $shift",
1248 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_imm:$shift))]>,
1249 Sched<[WriteALUsi, ReadALU]> {
1254 let Inst{19-16} = Rn;
1255 let Inst{15-12} = Rd;
1256 let Inst{11-5} = shift{11-5};
1258 let Inst{3-0} = shift{3-0};
1261 def rsr : AsI1<opcod, (outs GPR:$Rd),
1262 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1263 iis, opc, "\t$Rd, $Rn, $shift",
1264 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_reg:$shift))]>,
1265 Sched<[WriteALUsr, ReadALUsr]> {
1270 let Inst{19-16} = Rn;
1271 let Inst{15-12} = Rd;
1272 let Inst{11-8} = shift{11-8};
1274 let Inst{6-5} = shift{6-5};
1276 let Inst{3-0} = shift{3-0};
1280 /// AsI1_rbin_irs - Same as AsI1_bin_irs except the order of operands are
1281 /// reversed. The 'rr' form is only defined for the disassembler; for codegen
1282 /// it is equivalent to the AsI1_bin_irs counterpart.
1283 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1284 multiclass AsI1_rbin_irs<bits<4> opcod, string opc,
1285 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1286 PatFrag opnode, bit Commutable = 0> {
1287 // The register-immediate version is re-materializable. This is useful
1288 // in particular for taking the address of a local.
1289 let isReMaterializable = 1 in {
1290 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm,
1291 iii, opc, "\t$Rd, $Rn, $imm",
1292 [(set GPR:$Rd, (opnode mod_imm:$imm, GPR:$Rn))]>,
1293 Sched<[WriteALU, ReadALU]> {
1298 let Inst{19-16} = Rn;
1299 let Inst{15-12} = Rd;
1300 let Inst{11-0} = imm;
1303 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1304 iir, opc, "\t$Rd, $Rn, $Rm",
1305 [/* pattern left blank */]>,
1306 Sched<[WriteALU, ReadALU, ReadALU]> {
1310 let Inst{11-4} = 0b00000000;
1313 let Inst{15-12} = Rd;
1314 let Inst{19-16} = Rn;
1317 def rsi : AsI1<opcod, (outs GPR:$Rd),
1318 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1319 iis, opc, "\t$Rd, $Rn, $shift",
1320 [(set GPR:$Rd, (opnode so_reg_imm:$shift, GPR:$Rn))]>,
1321 Sched<[WriteALUsi, ReadALU]> {
1326 let Inst{19-16} = Rn;
1327 let Inst{15-12} = Rd;
1328 let Inst{11-5} = shift{11-5};
1330 let Inst{3-0} = shift{3-0};
1333 def rsr : AsI1<opcod, (outs GPR:$Rd),
1334 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1335 iis, opc, "\t$Rd, $Rn, $shift",
1336 [(set GPR:$Rd, (opnode so_reg_reg:$shift, GPR:$Rn))]>,
1337 Sched<[WriteALUsr, ReadALUsr]> {
1342 let Inst{19-16} = Rn;
1343 let Inst{15-12} = Rd;
1344 let Inst{11-8} = shift{11-8};
1346 let Inst{6-5} = shift{6-5};
1348 let Inst{3-0} = shift{3-0};
1352 /// AsI1_bin_s_irs - Same as AsI1_bin_irs except it sets the 's' bit by default.
1354 /// These opcodes will be converted to the real non-S opcodes by
1355 /// AdjustInstrPostInstrSelection after giving them an optional CPSR operand.
1356 let hasPostISelHook = 1, Defs = [CPSR] in {
1357 multiclass AsI1_bin_s_irs<InstrItinClass iii, InstrItinClass iir,
1358 InstrItinClass iis, PatFrag opnode,
1359 bit Commutable = 0> {
1360 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p),
1362 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm))]>,
1363 Sched<[WriteALU, ReadALU]>;
1365 def rr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, pred:$p),
1367 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm))]>,
1368 Sched<[WriteALU, ReadALU, ReadALU]> {
1369 let isCommutable = Commutable;
1371 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1372 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1374 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1375 so_reg_imm:$shift))]>,
1376 Sched<[WriteALUsi, ReadALU]>;
1378 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1379 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1381 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1382 so_reg_reg:$shift))]>,
1383 Sched<[WriteALUSsr, ReadALUsr]>;
1387 /// AsI1_rbin_s_is - Same as AsI1_bin_s_irs, except selection DAG
1388 /// operands are reversed.
1389 let hasPostISelHook = 1, Defs = [CPSR] in {
1390 multiclass AsI1_rbin_s_is<InstrItinClass iii, InstrItinClass iir,
1391 InstrItinClass iis, PatFrag opnode,
1392 bit Commutable = 0> {
1393 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p),
1395 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn))]>,
1396 Sched<[WriteALU, ReadALU]>;
1398 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1399 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1401 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift,
1403 Sched<[WriteALUsi, ReadALU]>;
1405 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1406 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1408 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift,
1410 Sched<[WriteALUSsr, ReadALUsr]>;
1414 /// AI1_cmp_irs - Defines a set of (op r, {mod_imm|r|so_reg}) cmp / test
1415 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
1416 /// a explicit result, only implicitly set CPSR.
1417 let isCompare = 1, Defs = [CPSR] in {
1418 multiclass AI1_cmp_irs<bits<4> opcod, string opc,
1419 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1420 PatFrag opnode, bit Commutable = 0> {
1421 def ri : AI1<opcod, (outs), (ins GPR:$Rn, mod_imm:$imm), DPFrm, iii,
1423 [(opnode GPR:$Rn, mod_imm:$imm)]>,
1424 Sched<[WriteCMP, ReadALU]> {
1429 let Inst{19-16} = Rn;
1430 let Inst{15-12} = 0b0000;
1431 let Inst{11-0} = imm;
1433 let Unpredictable{15-12} = 0b1111;
1435 def rr : AI1<opcod, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, iir,
1437 [(opnode GPR:$Rn, GPR:$Rm)]>,
1438 Sched<[WriteCMP, ReadALU, ReadALU]> {
1441 let isCommutable = Commutable;
1444 let Inst{19-16} = Rn;
1445 let Inst{15-12} = 0b0000;
1446 let Inst{11-4} = 0b00000000;
1449 let Unpredictable{15-12} = 0b1111;
1451 def rsi : AI1<opcod, (outs),
1452 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, iis,
1453 opc, "\t$Rn, $shift",
1454 [(opnode GPR:$Rn, so_reg_imm:$shift)]>,
1455 Sched<[WriteCMPsi, ReadALU]> {
1460 let Inst{19-16} = Rn;
1461 let Inst{15-12} = 0b0000;
1462 let Inst{11-5} = shift{11-5};
1464 let Inst{3-0} = shift{3-0};
1466 let Unpredictable{15-12} = 0b1111;
1468 def rsr : AI1<opcod, (outs),
1469 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, iis,
1470 opc, "\t$Rn, $shift",
1471 [(opnode GPRnopc:$Rn, so_reg_reg:$shift)]>,
1472 Sched<[WriteCMPsr, ReadALU]> {
1477 let Inst{19-16} = Rn;
1478 let Inst{15-12} = 0b0000;
1479 let Inst{11-8} = shift{11-8};
1481 let Inst{6-5} = shift{6-5};
1483 let Inst{3-0} = shift{3-0};
1485 let Unpredictable{15-12} = 0b1111;
1491 /// AI_ext_rrot - A unary operation with two forms: one whose operand is a
1492 /// register and one whose operand is a register rotated by 8/16/24.
1493 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
1494 class AI_ext_rrot<bits<8> opcod, string opc, PatFrag opnode>
1495 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1496 IIC_iEXTr, opc, "\t$Rd, $Rm$rot",
1497 [(set GPRnopc:$Rd, (opnode (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1498 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> {
1502 let Inst{19-16} = 0b1111;
1503 let Inst{15-12} = Rd;
1504 let Inst{11-10} = rot;
1508 class AI_ext_rrot_np<bits<8> opcod, string opc>
1509 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1510 IIC_iEXTr, opc, "\t$Rd, $Rm$rot", []>,
1511 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> {
1513 let Inst{19-16} = 0b1111;
1514 let Inst{11-10} = rot;
1517 /// AI_exta_rrot - A binary operation with two forms: one whose operand is a
1518 /// register and one whose operand is a register rotated by 8/16/24.
1519 class AI_exta_rrot<bits<8> opcod, string opc, PatFrag opnode>
1520 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1521 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot",
1522 [(set GPRnopc:$Rd, (opnode GPR:$Rn,
1523 (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1524 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> {
1529 let Inst{19-16} = Rn;
1530 let Inst{15-12} = Rd;
1531 let Inst{11-10} = rot;
1532 let Inst{9-4} = 0b000111;
1536 class AI_exta_rrot_np<bits<8> opcod, string opc>
1537 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1538 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot", []>,
1539 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> {
1542 let Inst{19-16} = Rn;
1543 let Inst{11-10} = rot;
1546 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
1547 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1548 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
1549 bit Commutable = 0> {
1550 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1551 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm),
1552 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1553 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm, CPSR))]>,
1555 Sched<[WriteALU, ReadALU]> {
1560 let Inst{15-12} = Rd;
1561 let Inst{19-16} = Rn;
1562 let Inst{11-0} = imm;
1564 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1565 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1566 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm, CPSR))]>,
1568 Sched<[WriteALU, ReadALU, ReadALU]> {
1572 let Inst{11-4} = 0b00000000;
1574 let isCommutable = Commutable;
1576 let Inst{15-12} = Rd;
1577 let Inst{19-16} = Rn;
1579 def rsi : AsI1<opcod, (outs GPR:$Rd),
1580 (ins GPR:$Rn, so_reg_imm:$shift),
1581 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1582 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_imm:$shift, CPSR))]>,
1584 Sched<[WriteALUsi, ReadALU]> {
1589 let Inst{19-16} = Rn;
1590 let Inst{15-12} = Rd;
1591 let Inst{11-5} = shift{11-5};
1593 let Inst{3-0} = shift{3-0};
1595 def rsr : AsI1<opcod, (outs GPRnopc:$Rd),
1596 (ins GPRnopc:$Rn, so_reg_reg:$shift),
1597 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1598 [(set GPRnopc:$Rd, CPSR,
1599 (opnode GPRnopc:$Rn, so_reg_reg:$shift, CPSR))]>,
1601 Sched<[WriteALUsr, ReadALUsr]> {
1606 let Inst{19-16} = Rn;
1607 let Inst{15-12} = Rd;
1608 let Inst{11-8} = shift{11-8};
1610 let Inst{6-5} = shift{6-5};
1612 let Inst{3-0} = shift{3-0};
1617 /// AI1_rsc_irs - Define instructions and patterns for rsc
1618 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1619 multiclass AI1_rsc_irs<bits<4> opcod, string opc, PatFrag opnode> {
1620 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1621 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm),
1622 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1623 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn, CPSR))]>,
1625 Sched<[WriteALU, ReadALU]> {
1630 let Inst{15-12} = Rd;
1631 let Inst{19-16} = Rn;
1632 let Inst{11-0} = imm;
1634 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1635 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1636 [/* pattern left blank */]>,
1637 Sched<[WriteALU, ReadALU, ReadALU]> {
1641 let Inst{11-4} = 0b00000000;
1644 let Inst{15-12} = Rd;
1645 let Inst{19-16} = Rn;
1647 def rsi : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_imm:$shift),
1648 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1649 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift, GPR:$Rn, CPSR))]>,
1651 Sched<[WriteALUsi, ReadALU]> {
1656 let Inst{19-16} = Rn;
1657 let Inst{15-12} = Rd;
1658 let Inst{11-5} = shift{11-5};
1660 let Inst{3-0} = shift{3-0};
1662 def rsr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_reg:$shift),
1663 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1664 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift, GPR:$Rn, CPSR))]>,
1666 Sched<[WriteALUsr, ReadALUsr]> {
1671 let Inst{19-16} = Rn;
1672 let Inst{15-12} = Rd;
1673 let Inst{11-8} = shift{11-8};
1675 let Inst{6-5} = shift{6-5};
1677 let Inst{3-0} = shift{3-0};
1682 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1683 multiclass AI_ldr1<bit isByte, string opc, InstrItinClass iii,
1684 InstrItinClass iir, PatFrag opnode> {
1685 // Note: We use the complex addrmode_imm12 rather than just an input
1686 // GPR and a constrained immediate so that we can use this to match
1687 // frame index references and avoid matching constant pool references.
1688 def i12: AI2ldst<0b010, 1, isByte, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
1689 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1690 [(set GPR:$Rt, (opnode addrmode_imm12:$addr))]> {
1693 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1694 let Inst{19-16} = addr{16-13}; // Rn
1695 let Inst{15-12} = Rt;
1696 let Inst{11-0} = addr{11-0}; // imm12
1698 def rs : AI2ldst<0b011, 1, isByte, (outs GPR:$Rt), (ins ldst_so_reg:$shift),
1699 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1700 [(set GPR:$Rt, (opnode ldst_so_reg:$shift))]> {
1703 let shift{4} = 0; // Inst{4} = 0
1704 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1705 let Inst{19-16} = shift{16-13}; // Rn
1706 let Inst{15-12} = Rt;
1707 let Inst{11-0} = shift{11-0};
1712 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1713 multiclass AI_ldr1nopc<bit isByte, string opc, InstrItinClass iii,
1714 InstrItinClass iir, PatFrag opnode> {
1715 // Note: We use the complex addrmode_imm12 rather than just an input
1716 // GPR and a constrained immediate so that we can use this to match
1717 // frame index references and avoid matching constant pool references.
1718 def i12: AI2ldst<0b010, 1, isByte, (outs GPRnopc:$Rt),
1719 (ins addrmode_imm12:$addr),
1720 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1721 [(set GPRnopc:$Rt, (opnode addrmode_imm12:$addr))]> {
1724 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1725 let Inst{19-16} = addr{16-13}; // Rn
1726 let Inst{15-12} = Rt;
1727 let Inst{11-0} = addr{11-0}; // imm12
1729 def rs : AI2ldst<0b011, 1, isByte, (outs GPRnopc:$Rt),
1730 (ins ldst_so_reg:$shift),
1731 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1732 [(set GPRnopc:$Rt, (opnode ldst_so_reg:$shift))]> {
1735 let shift{4} = 0; // Inst{4} = 0
1736 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1737 let Inst{19-16} = shift{16-13}; // Rn
1738 let Inst{15-12} = Rt;
1739 let Inst{11-0} = shift{11-0};
1745 multiclass AI_str1<bit isByte, string opc, InstrItinClass iii,
1746 InstrItinClass iir, PatFrag opnode> {
1747 // Note: We use the complex addrmode_imm12 rather than just an input
1748 // GPR and a constrained immediate so that we can use this to match
1749 // frame index references and avoid matching constant pool references.
1750 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1751 (ins GPR:$Rt, addrmode_imm12:$addr),
1752 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1753 [(opnode GPR:$Rt, addrmode_imm12:$addr)]> {
1756 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1757 let Inst{19-16} = addr{16-13}; // Rn
1758 let Inst{15-12} = Rt;
1759 let Inst{11-0} = addr{11-0}; // imm12
1761 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPR:$Rt, ldst_so_reg:$shift),
1762 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1763 [(opnode GPR:$Rt, ldst_so_reg:$shift)]> {
1766 let shift{4} = 0; // Inst{4} = 0
1767 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1768 let Inst{19-16} = shift{16-13}; // Rn
1769 let Inst{15-12} = Rt;
1770 let Inst{11-0} = shift{11-0};
1774 multiclass AI_str1nopc<bit isByte, string opc, InstrItinClass iii,
1775 InstrItinClass iir, PatFrag opnode> {
1776 // Note: We use the complex addrmode_imm12 rather than just an input
1777 // GPR and a constrained immediate so that we can use this to match
1778 // frame index references and avoid matching constant pool references.
1779 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1780 (ins GPRnopc:$Rt, addrmode_imm12:$addr),
1781 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1782 [(opnode GPRnopc:$Rt, addrmode_imm12:$addr)]> {
1785 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1786 let Inst{19-16} = addr{16-13}; // Rn
1787 let Inst{15-12} = Rt;
1788 let Inst{11-0} = addr{11-0}; // imm12
1790 def rs : AI2ldst<0b011, 0, isByte, (outs),
1791 (ins GPRnopc:$Rt, ldst_so_reg:$shift),
1792 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1793 [(opnode GPRnopc:$Rt, ldst_so_reg:$shift)]> {
1796 let shift{4} = 0; // Inst{4} = 0
1797 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1798 let Inst{19-16} = shift{16-13}; // Rn
1799 let Inst{15-12} = Rt;
1800 let Inst{11-0} = shift{11-0};
1805 //===----------------------------------------------------------------------===//
1807 //===----------------------------------------------------------------------===//
1809 //===----------------------------------------------------------------------===//
1810 // Miscellaneous Instructions.
1813 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
1814 /// the function. The first operand is the ID# for this instruction, the second
1815 /// is the index into the MachineConstantPool that this is, the third is the
1816 /// size in bytes of this constant pool entry.
1817 let hasSideEffects = 0, isNotDuplicable = 1 in
1818 def CONSTPOOL_ENTRY :
1819 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1820 i32imm:$size), NoItinerary, []>;
1822 // FIXME: Marking these as hasSideEffects is necessary to prevent machine DCE
1823 // from removing one half of the matched pairs. That breaks PEI, which assumes
1824 // these will always be in pairs, and asserts if it finds otherwise. Better way?
1825 let Defs = [SP], Uses = [SP], hasSideEffects = 1 in {
1826 def ADJCALLSTACKUP :
1827 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary,
1828 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
1830 def ADJCALLSTACKDOWN :
1831 PseudoInst<(outs), (ins i32imm:$amt, pred:$p), NoItinerary,
1832 [(ARMcallseq_start timm:$amt)]>;
1835 def HINT : AI<(outs), (ins imm0_239:$imm), MiscFrm, NoItinerary,
1836 "hint", "\t$imm", [(int_arm_hint imm0_239:$imm)]>,
1837 Requires<[IsARM, HasV6]> {
1839 let Inst{27-8} = 0b00110010000011110000;
1840 let Inst{7-0} = imm;
1843 def : InstAlias<"nop$p", (HINT 0, pred:$p)>, Requires<[IsARM, HasV6K]>;
1844 def : InstAlias<"yield$p", (HINT 1, pred:$p)>, Requires<[IsARM, HasV6K]>;
1845 def : InstAlias<"wfe$p", (HINT 2, pred:$p)>, Requires<[IsARM, HasV6K]>;
1846 def : InstAlias<"wfi$p", (HINT 3, pred:$p)>, Requires<[IsARM, HasV6K]>;
1847 def : InstAlias<"sev$p", (HINT 4, pred:$p)>, Requires<[IsARM, HasV6K]>;
1848 def : InstAlias<"sevl$p", (HINT 5, pred:$p)>, Requires<[IsARM, HasV8]>;
1850 def SEL : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, NoItinerary, "sel",
1851 "\t$Rd, $Rn, $Rm", []>, Requires<[IsARM, HasV6]> {
1856 let Inst{15-12} = Rd;
1857 let Inst{19-16} = Rn;
1858 let Inst{27-20} = 0b01101000;
1859 let Inst{7-4} = 0b1011;
1860 let Inst{11-8} = 0b1111;
1861 let Unpredictable{11-8} = 0b1111;
1864 // The 16-bit operand $val can be used by a debugger to store more information
1865 // about the breakpoint.
1866 def BKPT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
1867 "bkpt", "\t$val", []>, Requires<[IsARM]> {
1869 let Inst{3-0} = val{3-0};
1870 let Inst{19-8} = val{15-4};
1871 let Inst{27-20} = 0b00010010;
1872 let Inst{31-28} = 0xe; // AL
1873 let Inst{7-4} = 0b0111;
1875 // default immediate for breakpoint mnemonic
1876 def : InstAlias<"bkpt", (BKPT 0)>, Requires<[IsARM]>;
1878 def HLT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
1879 "hlt", "\t$val", []>, Requires<[IsARM, HasV8]> {
1881 let Inst{3-0} = val{3-0};
1882 let Inst{19-8} = val{15-4};
1883 let Inst{27-20} = 0b00010000;
1884 let Inst{31-28} = 0xe; // AL
1885 let Inst{7-4} = 0b0111;
1888 // Change Processor State
1889 // FIXME: We should use InstAlias to handle the optional operands.
1890 class CPS<dag iops, string asm_ops>
1891 : AXI<(outs), iops, MiscFrm, NoItinerary, !strconcat("cps", asm_ops),
1892 []>, Requires<[IsARM]> {
1898 let Inst{31-28} = 0b1111;
1899 let Inst{27-20} = 0b00010000;
1900 let Inst{19-18} = imod;
1901 let Inst{17} = M; // Enabled if mode is set;
1902 let Inst{16-9} = 0b00000000;
1903 let Inst{8-6} = iflags;
1905 let Inst{4-0} = mode;
1908 let DecoderMethod = "DecodeCPSInstruction" in {
1910 def CPS3p : CPS<(ins imod_op:$imod, iflags_op:$iflags, imm0_31:$mode),
1911 "$imod\t$iflags, $mode">;
1912 let mode = 0, M = 0 in
1913 def CPS2p : CPS<(ins imod_op:$imod, iflags_op:$iflags), "$imod\t$iflags">;
1915 let imod = 0, iflags = 0, M = 1 in
1916 def CPS1p : CPS<(ins imm0_31:$mode), "\t$mode">;
1919 // Preload signals the memory system of possible future data/instruction access.
1920 multiclass APreLoad<bits<1> read, bits<1> data, string opc> {
1922 def i12 : AXIM<(outs), (ins addrmode_imm12:$addr), AddrMode_i12, MiscFrm,
1923 IIC_Preload, !strconcat(opc, "\t$addr"),
1924 [(ARMPreload addrmode_imm12:$addr, (i32 read), (i32 data))]>,
1925 Sched<[WritePreLd]> {
1928 let Inst{31-26} = 0b111101;
1929 let Inst{25} = 0; // 0 for immediate form
1930 let Inst{24} = data;
1931 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1932 let Inst{22} = read;
1933 let Inst{21-20} = 0b01;
1934 let Inst{19-16} = addr{16-13}; // Rn
1935 let Inst{15-12} = 0b1111;
1936 let Inst{11-0} = addr{11-0}; // imm12
1939 def rs : AXI<(outs), (ins ldst_so_reg:$shift), MiscFrm, IIC_Preload,
1940 !strconcat(opc, "\t$shift"),
1941 [(ARMPreload ldst_so_reg:$shift, (i32 read), (i32 data))]>,
1942 Sched<[WritePreLd]> {
1944 let Inst{31-26} = 0b111101;
1945 let Inst{25} = 1; // 1 for register form
1946 let Inst{24} = data;
1947 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1948 let Inst{22} = read;
1949 let Inst{21-20} = 0b01;
1950 let Inst{19-16} = shift{16-13}; // Rn
1951 let Inst{15-12} = 0b1111;
1952 let Inst{11-0} = shift{11-0};
1957 defm PLD : APreLoad<1, 1, "pld">, Requires<[IsARM]>;
1958 defm PLDW : APreLoad<0, 1, "pldw">, Requires<[IsARM,HasV7,HasMP]>;
1959 defm PLI : APreLoad<1, 0, "pli">, Requires<[IsARM,HasV7]>;
1961 def SETEND : AXI<(outs), (ins setend_op:$end), MiscFrm, NoItinerary,
1962 "setend\t$end", []>, Requires<[IsARM]>, Deprecated<HasV8Ops> {
1964 let Inst{31-10} = 0b1111000100000001000000;
1969 def DBG : AI<(outs), (ins imm0_15:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt",
1970 [(int_arm_dbg imm0_15:$opt)]>, Requires<[IsARM, HasV7]> {
1972 let Inst{27-4} = 0b001100100000111100001111;
1973 let Inst{3-0} = opt;
1976 // A8.8.247 UDF - Undefined (Encoding A1)
1977 def UDF : AInoP<(outs), (ins imm0_65535:$imm16), MiscFrm, NoItinerary,
1978 "udf", "\t$imm16", [(int_arm_undefined imm0_65535:$imm16)]> {
1980 let Inst{31-28} = 0b1110; // AL
1981 let Inst{27-25} = 0b011;
1982 let Inst{24-20} = 0b11111;
1983 let Inst{19-8} = imm16{15-4};
1984 let Inst{7-4} = 0b1111;
1985 let Inst{3-0} = imm16{3-0};
1989 * A5.4 Permanently UNDEFINED instructions.
1991 * For most targets use UDF #65006, for which the OS will generate SIGTRAP.
1992 * Other UDF encodings generate SIGILL.
1994 * NaCl's OS instead chooses an ARM UDF encoding that's also a UDF in Thumb.
1996 * 1110 0111 1111 iiii iiii iiii 1111 iiii
1998 * 1101 1110 iiii iiii
1999 * It uses the following encoding:
2000 * 1110 0111 1111 1110 1101 1110 1111 0000
2001 * - In ARM: UDF #60896;
2002 * - In Thumb: UDF #254 followed by a branch-to-self.
2004 let isBarrier = 1, isTerminator = 1 in
2005 def TRAPNaCl : AXI<(outs), (ins), MiscFrm, NoItinerary,
2007 Requires<[IsARM,UseNaClTrap]> {
2008 let Inst = 0xe7fedef0;
2010 let isBarrier = 1, isTerminator = 1 in
2011 def TRAP : AXI<(outs), (ins), MiscFrm, NoItinerary,
2013 Requires<[IsARM,DontUseNaClTrap]> {
2014 let Inst = 0xe7ffdefe;
2017 // Address computation and loads and stores in PIC mode.
2018 let isNotDuplicable = 1 in {
2019 def PICADD : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
2021 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>,
2022 Sched<[WriteALU, ReadALU]>;
2024 let AddedComplexity = 10 in {
2025 def PICLDR : ARMPseudoInst<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
2027 [(set GPR:$dst, (load addrmodepc:$addr))]>;
2029 def PICLDRH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2031 [(set GPR:$Rt, (zextloadi16 addrmodepc:$addr))]>;
2033 def PICLDRB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2035 [(set GPR:$Rt, (zextloadi8 addrmodepc:$addr))]>;
2037 def PICLDRSH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2039 [(set GPR:$Rt, (sextloadi16 addrmodepc:$addr))]>;
2041 def PICLDRSB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2043 [(set GPR:$Rt, (sextloadi8 addrmodepc:$addr))]>;
2045 let AddedComplexity = 10 in {
2046 def PICSTR : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2047 4, IIC_iStore_r, [(store GPR:$src, addrmodepc:$addr)]>;
2049 def PICSTRH : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2050 4, IIC_iStore_bh_r, [(truncstorei16 GPR:$src,
2051 addrmodepc:$addr)]>;
2053 def PICSTRB : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2054 4, IIC_iStore_bh_r, [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
2056 } // isNotDuplicable = 1
2059 // LEApcrel - Load a pc-relative address into a register without offending the
2061 let hasSideEffects = 0, isReMaterializable = 1 in
2062 // The 'adr' mnemonic encodes differently if the label is before or after
2063 // the instruction. The {24-21} opcode bits are set by the fixup, as we don't
2064 // know until then which form of the instruction will be used.
2065 def ADR : AI1<{0,?,?,0}, (outs GPR:$Rd), (ins adrlabel:$label),
2066 MiscFrm, IIC_iALUi, "adr", "\t$Rd, $label", []>,
2067 Sched<[WriteALU, ReadALU]> {
2070 let Inst{27-25} = 0b001;
2072 let Inst{23-22} = label{13-12};
2075 let Inst{19-16} = 0b1111;
2076 let Inst{15-12} = Rd;
2077 let Inst{11-0} = label{11-0};
2080 let hasSideEffects = 1 in {
2081 def LEApcrel : ARMPseudoInst<(outs GPR:$Rd), (ins i32imm:$label, pred:$p),
2082 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
2084 def LEApcrelJT : ARMPseudoInst<(outs GPR:$Rd),
2085 (ins i32imm:$label, nohash_imm:$id, pred:$p),
2086 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
2089 //===----------------------------------------------------------------------===//
2090 // Control Flow Instructions.
2093 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
2095 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
2096 "bx", "\tlr", [(ARMretflag)]>,
2097 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2098 let Inst{27-0} = 0b0001001011111111111100011110;
2102 def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br,
2103 "mov", "\tpc, lr", [(ARMretflag)]>,
2104 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]> {
2105 let Inst{27-0} = 0b0001101000001111000000001110;
2108 // Exception return: N.b. doesn't set CPSR as far as we're concerned (it sets
2109 // the user-space one).
2110 def SUBS_PC_LR : ARMPseudoInst<(outs), (ins i32imm:$offset, pred:$p),
2112 [(ARMintretflag imm:$offset)]>;
2115 // Indirect branches
2116 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
2118 def BX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
2119 [(brind GPR:$dst)]>,
2120 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2122 let Inst{31-4} = 0b1110000100101111111111110001;
2123 let Inst{3-0} = dst;
2126 def BX_pred : AI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br,
2127 "bx", "\t$dst", [/* pattern left blank */]>,
2128 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2130 let Inst{27-4} = 0b000100101111111111110001;
2131 let Inst{3-0} = dst;
2135 // SP is marked as a use to prevent stack-pointer assignments that appear
2136 // immediately before calls from potentially appearing dead.
2138 // FIXME: Do we really need a non-predicated version? If so, it should
2139 // at least be a pseudo instruction expanding to the predicated version
2140 // at MC lowering time.
2141 Defs = [LR], Uses = [SP] in {
2142 def BL : ABXI<0b1011, (outs), (ins bl_target:$func),
2143 IIC_Br, "bl\t$func",
2144 [(ARMcall tglobaladdr:$func)]>,
2145 Requires<[IsARM]>, Sched<[WriteBrL]> {
2146 let Inst{31-28} = 0b1110;
2148 let Inst{23-0} = func;
2149 let DecoderMethod = "DecodeBranchImmInstruction";
2152 def BL_pred : ABI<0b1011, (outs), (ins bl_target:$func),
2153 IIC_Br, "bl", "\t$func",
2154 [(ARMcall_pred tglobaladdr:$func)]>,
2155 Requires<[IsARM]>, Sched<[WriteBrL]> {
2157 let Inst{23-0} = func;
2158 let DecoderMethod = "DecodeBranchImmInstruction";
2162 def BLX : AXI<(outs), (ins GPR:$func), BrMiscFrm,
2163 IIC_Br, "blx\t$func",
2164 [(ARMcall GPR:$func)]>,
2165 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2167 let Inst{31-4} = 0b1110000100101111111111110011;
2168 let Inst{3-0} = func;
2171 def BLX_pred : AI<(outs), (ins GPR:$func), BrMiscFrm,
2172 IIC_Br, "blx", "\t$func",
2173 [(ARMcall_pred GPR:$func)]>,
2174 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2176 let Inst{27-4} = 0b000100101111111111110011;
2177 let Inst{3-0} = func;
2181 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
2182 def BX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
2183 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
2184 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]>;
2187 def BMOVPCRX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
2188 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
2189 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
2191 // mov lr, pc; b if callee is marked noreturn to avoid confusing the
2192 // return stack predictor.
2193 def BMOVPCB_CALL : ARMPseudoInst<(outs), (ins bl_target:$func),
2194 8, IIC_Br, [(ARMcall_nolink tglobaladdr:$func)]>,
2195 Requires<[IsARM]>, Sched<[WriteBr]>;
2198 let isBranch = 1, isTerminator = 1 in {
2199 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
2200 // a two-value operand where a dag node expects two operands. :(
2201 def Bcc : ABI<0b1010, (outs), (ins br_target:$target),
2202 IIC_Br, "b", "\t$target",
2203 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>,
2206 let Inst{23-0} = target;
2207 let DecoderMethod = "DecodeBranchImmInstruction";
2210 let isBarrier = 1 in {
2211 // B is "predicable" since it's just a Bcc with an 'always' condition.
2212 let isPredicable = 1 in
2213 // FIXME: We shouldn't need this pseudo at all. Just using Bcc directly
2214 // should be sufficient.
2215 // FIXME: Is B really a Barrier? That doesn't seem right.
2216 def B : ARMPseudoExpand<(outs), (ins br_target:$target), 4, IIC_Br,
2217 [(br bb:$target)], (Bcc br_target:$target, (ops 14, zero_reg))>,
2220 let isNotDuplicable = 1, isIndirectBranch = 1 in {
2221 def BR_JTr : ARMPseudoInst<(outs),
2222 (ins GPR:$target, i32imm:$jt, i32imm:$id),
2224 [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]>,
2226 // FIXME: This shouldn't use the generic "addrmode2," but rather be split
2227 // into i12 and rs suffixed versions.
2228 def BR_JTm : ARMPseudoInst<(outs),
2229 (ins addrmode2:$target, i32imm:$jt, i32imm:$id),
2231 [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
2232 imm:$id)]>, Sched<[WriteBrTbl]>;
2233 def BR_JTadd : ARMPseudoInst<(outs),
2234 (ins GPR:$target, GPR:$idx, i32imm:$jt, i32imm:$id),
2236 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
2237 imm:$id)]>, Sched<[WriteBrTbl]>;
2238 } // isNotDuplicable = 1, isIndirectBranch = 1
2244 def BLXi : AXI<(outs), (ins blx_target:$target), BrMiscFrm, NoItinerary,
2245 "blx\t$target", []>,
2246 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2247 let Inst{31-25} = 0b1111101;
2249 let Inst{23-0} = target{24-1};
2250 let Inst{24} = target{0};
2253 // Branch and Exchange Jazelle
2254 def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func",
2255 [/* pattern left blank */]>, Sched<[WriteBr]> {
2257 let Inst{23-20} = 0b0010;
2258 let Inst{19-8} = 0xfff;
2259 let Inst{7-4} = 0b0010;
2260 let Inst{3-0} = func;
2265 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in {
2266 def TCRETURNdi : PseudoInst<(outs), (ins i32imm:$dst), IIC_Br, []>,
2269 def TCRETURNri : PseudoInst<(outs), (ins tcGPR:$dst), IIC_Br, []>,
2272 def TAILJMPd : ARMPseudoExpand<(outs), (ins br_target:$dst),
2274 (Bcc br_target:$dst, (ops 14, zero_reg))>,
2275 Requires<[IsARM]>, Sched<[WriteBr]>;
2277 def TAILJMPr : ARMPseudoExpand<(outs), (ins tcGPR:$dst),
2279 (BX GPR:$dst)>, Sched<[WriteBr]>,
2283 // Secure Monitor Call is a system instruction.
2284 def SMC : ABI<0b0001, (outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt",
2285 []>, Requires<[IsARM, HasTrustZone]> {
2287 let Inst{23-4} = 0b01100000000000000111;
2288 let Inst{3-0} = opt;
2291 // Supervisor Call (Software Interrupt)
2292 let isCall = 1, Uses = [SP] in {
2293 def SVC : ABI<0b1111, (outs), (ins imm24b:$svc), IIC_Br, "svc", "\t$svc", []>,
2296 let Inst{23-0} = svc;
2300 // Store Return State
2301 class SRSI<bit wb, string asm>
2302 : XI<(outs), (ins imm0_31:$mode), AddrModeNone, 4, IndexModeNone, BrFrm,
2303 NoItinerary, asm, "", []> {
2305 let Inst{31-28} = 0b1111;
2306 let Inst{27-25} = 0b100;
2310 let Inst{19-16} = 0b1101; // SP
2311 let Inst{15-5} = 0b00000101000;
2312 let Inst{4-0} = mode;
2315 def SRSDA : SRSI<0, "srsda\tsp, $mode"> {
2316 let Inst{24-23} = 0;
2318 def SRSDA_UPD : SRSI<1, "srsda\tsp!, $mode"> {
2319 let Inst{24-23} = 0;
2321 def SRSDB : SRSI<0, "srsdb\tsp, $mode"> {
2322 let Inst{24-23} = 0b10;
2324 def SRSDB_UPD : SRSI<1, "srsdb\tsp!, $mode"> {
2325 let Inst{24-23} = 0b10;
2327 def SRSIA : SRSI<0, "srsia\tsp, $mode"> {
2328 let Inst{24-23} = 0b01;
2330 def SRSIA_UPD : SRSI<1, "srsia\tsp!, $mode"> {
2331 let Inst{24-23} = 0b01;
2333 def SRSIB : SRSI<0, "srsib\tsp, $mode"> {
2334 let Inst{24-23} = 0b11;
2336 def SRSIB_UPD : SRSI<1, "srsib\tsp!, $mode"> {
2337 let Inst{24-23} = 0b11;
2340 def : ARMInstAlias<"srsda $mode", (SRSDA imm0_31:$mode)>;
2341 def : ARMInstAlias<"srsda $mode!", (SRSDA_UPD imm0_31:$mode)>;
2343 def : ARMInstAlias<"srsdb $mode", (SRSDB imm0_31:$mode)>;
2344 def : ARMInstAlias<"srsdb $mode!", (SRSDB_UPD imm0_31:$mode)>;
2346 def : ARMInstAlias<"srsia $mode", (SRSIA imm0_31:$mode)>;
2347 def : ARMInstAlias<"srsia $mode!", (SRSIA_UPD imm0_31:$mode)>;
2349 def : ARMInstAlias<"srsib $mode", (SRSIB imm0_31:$mode)>;
2350 def : ARMInstAlias<"srsib $mode!", (SRSIB_UPD imm0_31:$mode)>;
2352 // Return From Exception
2353 class RFEI<bit wb, string asm>
2354 : XI<(outs), (ins GPR:$Rn), AddrModeNone, 4, IndexModeNone, BrFrm,
2355 NoItinerary, asm, "", []> {
2357 let Inst{31-28} = 0b1111;
2358 let Inst{27-25} = 0b100;
2362 let Inst{19-16} = Rn;
2363 let Inst{15-0} = 0xa00;
2366 def RFEDA : RFEI<0, "rfeda\t$Rn"> {
2367 let Inst{24-23} = 0;
2369 def RFEDA_UPD : RFEI<1, "rfeda\t$Rn!"> {
2370 let Inst{24-23} = 0;
2372 def RFEDB : RFEI<0, "rfedb\t$Rn"> {
2373 let Inst{24-23} = 0b10;
2375 def RFEDB_UPD : RFEI<1, "rfedb\t$Rn!"> {
2376 let Inst{24-23} = 0b10;
2378 def RFEIA : RFEI<0, "rfeia\t$Rn"> {
2379 let Inst{24-23} = 0b01;
2381 def RFEIA_UPD : RFEI<1, "rfeia\t$Rn!"> {
2382 let Inst{24-23} = 0b01;
2384 def RFEIB : RFEI<0, "rfeib\t$Rn"> {
2385 let Inst{24-23} = 0b11;
2387 def RFEIB_UPD : RFEI<1, "rfeib\t$Rn!"> {
2388 let Inst{24-23} = 0b11;
2391 // Hypervisor Call is a system instruction
2393 def HVC : AInoP< (outs), (ins imm0_65535:$imm), BrFrm, NoItinerary,
2394 "hvc", "\t$imm", []>,
2395 Requires<[IsARM, HasVirtualization]> {
2398 // Even though HVC isn't predicable, it's encoding includes a condition field.
2399 // The instruction is undefined if the condition field is 0xf otherwise it is
2400 // unpredictable if it isn't condition AL (0xe).
2401 let Inst{31-28} = 0b1110;
2402 let Unpredictable{31-28} = 0b1111;
2403 let Inst{27-24} = 0b0001;
2404 let Inst{23-20} = 0b0100;
2405 let Inst{19-8} = imm{15-4};
2406 let Inst{7-4} = 0b0111;
2407 let Inst{3-0} = imm{3-0};
2411 // Return from exception in Hypervisor mode.
2412 let isReturn = 1, isBarrier = 1, isTerminator = 1, Defs = [PC] in
2413 def ERET : ABI<0b0001, (outs), (ins), NoItinerary, "eret", "", []>,
2414 Requires<[IsARM, HasVirtualization]> {
2415 let Inst{23-0} = 0b011000000000000001101110;
2418 //===----------------------------------------------------------------------===//
2419 // Load / Store Instructions.
2425 defm LDR : AI_ldr1<0, "ldr", IIC_iLoad_r, IIC_iLoad_si,
2426 UnOpFrag<(load node:$Src)>>;
2427 defm LDRB : AI_ldr1nopc<1, "ldrb", IIC_iLoad_bh_r, IIC_iLoad_bh_si,
2428 UnOpFrag<(zextloadi8 node:$Src)>>;
2429 defm STR : AI_str1<0, "str", IIC_iStore_r, IIC_iStore_si,
2430 BinOpFrag<(store node:$LHS, node:$RHS)>>;
2431 defm STRB : AI_str1nopc<1, "strb", IIC_iStore_bh_r, IIC_iStore_bh_si,
2432 BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
2434 // Special LDR for loads from non-pc-relative constpools.
2435 let canFoldAsLoad = 1, mayLoad = 1, hasSideEffects = 0,
2436 isReMaterializable = 1, isCodeGenOnly = 1 in
2437 def LDRcp : AI2ldst<0b010, 1, 0, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
2438 AddrMode_i12, LdFrm, IIC_iLoad_r, "ldr", "\t$Rt, $addr",
2442 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2443 let Inst{19-16} = 0b1111;
2444 let Inst{15-12} = Rt;
2445 let Inst{11-0} = addr{11-0}; // imm12
2448 // Loads with zero extension
2449 def LDRH : AI3ld<0b1011, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2450 IIC_iLoad_bh_r, "ldrh", "\t$Rt, $addr",
2451 [(set GPR:$Rt, (zextloadi16 addrmode3:$addr))]>;
2453 // Loads with sign extension
2454 def LDRSH : AI3ld<0b1111, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2455 IIC_iLoad_bh_r, "ldrsh", "\t$Rt, $addr",
2456 [(set GPR:$Rt, (sextloadi16 addrmode3:$addr))]>;
2458 def LDRSB : AI3ld<0b1101, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2459 IIC_iLoad_bh_r, "ldrsb", "\t$Rt, $addr",
2460 [(set GPR:$Rt, (sextloadi8 addrmode3:$addr))]>;
2462 let mayLoad = 1, hasSideEffects = 0, hasExtraDefRegAllocReq = 1 in {
2464 def LDRD : AI3ld<0b1101, 0, (outs GPR:$Rt, GPR:$Rt2), (ins addrmode3:$addr),
2465 LdMiscFrm, IIC_iLoad_d_r, "ldrd", "\t$Rt, $Rt2, $addr", []>,
2466 Requires<[IsARM, HasV5TE]>;
2469 def LDA : AIldracq<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2470 NoItinerary, "lda", "\t$Rt, $addr", []>;
2471 def LDAB : AIldracq<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2472 NoItinerary, "ldab", "\t$Rt, $addr", []>;
2473 def LDAH : AIldracq<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2474 NoItinerary, "ldah", "\t$Rt, $addr", []>;
2477 multiclass AI2_ldridx<bit isByte, string opc,
2478 InstrItinClass iii, InstrItinClass iir> {
2479 def _PRE_IMM : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2480 (ins addrmode_imm12_pre:$addr), IndexModePre, LdFrm, iii,
2481 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2484 let Inst{23} = addr{12};
2485 let Inst{19-16} = addr{16-13};
2486 let Inst{11-0} = addr{11-0};
2487 let DecoderMethod = "DecodeLDRPreImm";
2490 def _PRE_REG : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2491 (ins ldst_so_reg:$addr), IndexModePre, LdFrm, iir,
2492 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2495 let Inst{23} = addr{12};
2496 let Inst{19-16} = addr{16-13};
2497 let Inst{11-0} = addr{11-0};
2499 let DecoderMethod = "DecodeLDRPreReg";
2502 def _POST_REG : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2503 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2504 IndexModePost, LdFrm, iir,
2505 opc, "\t$Rt, $addr, $offset",
2506 "$addr.base = $Rn_wb", []> {
2512 let Inst{23} = offset{12};
2513 let Inst{19-16} = addr;
2514 let Inst{11-0} = offset{11-0};
2517 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2520 def _POST_IMM : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2521 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2522 IndexModePost, LdFrm, iii,
2523 opc, "\t$Rt, $addr, $offset",
2524 "$addr.base = $Rn_wb", []> {
2530 let Inst{23} = offset{12};
2531 let Inst{19-16} = addr;
2532 let Inst{11-0} = offset{11-0};
2534 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2539 let mayLoad = 1, hasSideEffects = 0 in {
2540 // FIXME: for LDR_PRE_REG etc. the itineray should be either IIC_iLoad_ru or
2541 // IIC_iLoad_siu depending on whether it the offset register is shifted.
2542 defm LDR : AI2_ldridx<0, "ldr", IIC_iLoad_iu, IIC_iLoad_ru>;
2543 defm LDRB : AI2_ldridx<1, "ldrb", IIC_iLoad_bh_iu, IIC_iLoad_bh_ru>;
2546 multiclass AI3_ldridx<bits<4> op, string opc, InstrItinClass itin> {
2547 def _PRE : AI3ldstidx<op, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2548 (ins addrmode3_pre:$addr), IndexModePre,
2550 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2552 let Inst{23} = addr{8}; // U bit
2553 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2554 let Inst{19-16} = addr{12-9}; // Rn
2555 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2556 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2557 let DecoderMethod = "DecodeAddrMode3Instruction";
2559 def _POST : AI3ldstidx<op, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2560 (ins addr_offset_none:$addr, am3offset:$offset),
2561 IndexModePost, LdMiscFrm, itin,
2562 opc, "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2566 let Inst{23} = offset{8}; // U bit
2567 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2568 let Inst{19-16} = addr;
2569 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2570 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2571 let DecoderMethod = "DecodeAddrMode3Instruction";
2575 let mayLoad = 1, hasSideEffects = 0 in {
2576 defm LDRH : AI3_ldridx<0b1011, "ldrh", IIC_iLoad_bh_ru>;
2577 defm LDRSH : AI3_ldridx<0b1111, "ldrsh", IIC_iLoad_bh_ru>;
2578 defm LDRSB : AI3_ldridx<0b1101, "ldrsb", IIC_iLoad_bh_ru>;
2579 let hasExtraDefRegAllocReq = 1 in {
2580 def LDRD_PRE : AI3ldstidx<0b1101, 0, 1, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2581 (ins addrmode3_pre:$addr), IndexModePre,
2582 LdMiscFrm, IIC_iLoad_d_ru,
2583 "ldrd", "\t$Rt, $Rt2, $addr!",
2584 "$addr.base = $Rn_wb", []> {
2586 let Inst{23} = addr{8}; // U bit
2587 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2588 let Inst{19-16} = addr{12-9}; // Rn
2589 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2590 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2591 let DecoderMethod = "DecodeAddrMode3Instruction";
2593 def LDRD_POST: AI3ldstidx<0b1101, 0, 0, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2594 (ins addr_offset_none:$addr, am3offset:$offset),
2595 IndexModePost, LdMiscFrm, IIC_iLoad_d_ru,
2596 "ldrd", "\t$Rt, $Rt2, $addr, $offset",
2597 "$addr.base = $Rn_wb", []> {
2600 let Inst{23} = offset{8}; // U bit
2601 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2602 let Inst{19-16} = addr;
2603 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2604 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2605 let DecoderMethod = "DecodeAddrMode3Instruction";
2607 } // hasExtraDefRegAllocReq = 1
2608 } // mayLoad = 1, hasSideEffects = 0
2610 // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT.
2611 let mayLoad = 1, hasSideEffects = 0 in {
2612 def LDRT_POST_REG : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2613 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2614 IndexModePost, LdFrm, IIC_iLoad_ru,
2615 "ldrt", "\t$Rt, $addr, $offset",
2616 "$addr.base = $Rn_wb", []> {
2622 let Inst{23} = offset{12};
2623 let Inst{21} = 1; // overwrite
2624 let Inst{19-16} = addr;
2625 let Inst{11-5} = offset{11-5};
2627 let Inst{3-0} = offset{3-0};
2628 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2632 : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2633 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2634 IndexModePost, LdFrm, IIC_iLoad_ru,
2635 "ldrt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2641 let Inst{23} = offset{12};
2642 let Inst{21} = 1; // overwrite
2643 let Inst{19-16} = addr;
2644 let Inst{11-0} = offset{11-0};
2645 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2648 def LDRBT_POST_REG : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2649 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2650 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2651 "ldrbt", "\t$Rt, $addr, $offset",
2652 "$addr.base = $Rn_wb", []> {
2658 let Inst{23} = offset{12};
2659 let Inst{21} = 1; // overwrite
2660 let Inst{19-16} = addr;
2661 let Inst{11-5} = offset{11-5};
2663 let Inst{3-0} = offset{3-0};
2664 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2668 : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2669 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2670 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2671 "ldrbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2677 let Inst{23} = offset{12};
2678 let Inst{21} = 1; // overwrite
2679 let Inst{19-16} = addr;
2680 let Inst{11-0} = offset{11-0};
2681 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2684 multiclass AI3ldrT<bits<4> op, string opc> {
2685 def i : AI3ldstidxT<op, 1, (outs GPR:$Rt, GPR:$base_wb),
2686 (ins addr_offset_none:$addr, postidx_imm8:$offset),
2687 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2688 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2690 let Inst{23} = offset{8};
2692 let Inst{11-8} = offset{7-4};
2693 let Inst{3-0} = offset{3-0};
2695 def r : AI3ldstidxT<op, 1, (outs GPRnopc:$Rt, GPRnopc:$base_wb),
2696 (ins addr_offset_none:$addr, postidx_reg:$Rm),
2697 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2698 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2700 let Inst{23} = Rm{4};
2703 let Unpredictable{11-8} = 0b1111;
2704 let Inst{3-0} = Rm{3-0};
2705 let DecoderMethod = "DecodeLDR";
2709 defm LDRSBT : AI3ldrT<0b1101, "ldrsbt">;
2710 defm LDRHT : AI3ldrT<0b1011, "ldrht">;
2711 defm LDRSHT : AI3ldrT<0b1111, "ldrsht">;
2715 : ARMAsmPseudo<"ldrt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q),
2719 : ARMAsmPseudo<"ldrbt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q),
2724 // Stores with truncate
2725 def STRH : AI3str<0b1011, (outs), (ins GPR:$Rt, addrmode3:$addr), StMiscFrm,
2726 IIC_iStore_bh_r, "strh", "\t$Rt, $addr",
2727 [(truncstorei16 GPR:$Rt, addrmode3:$addr)]>;
2730 let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
2731 def STRD : AI3str<0b1111, (outs), (ins GPR:$Rt, GPR:$Rt2, addrmode3:$addr),
2732 StMiscFrm, IIC_iStore_d_r, "strd", "\t$Rt, $Rt2, $addr", []>,
2733 Requires<[IsARM, HasV5TE]> {
2739 multiclass AI2_stridx<bit isByte, string opc,
2740 InstrItinClass iii, InstrItinClass iir> {
2741 def _PRE_IMM : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2742 (ins GPR:$Rt, addrmode_imm12_pre:$addr), IndexModePre,
2744 opc, "\t$Rt, $addr!",
2745 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2748 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2749 let Inst{19-16} = addr{16-13}; // Rn
2750 let Inst{11-0} = addr{11-0}; // imm12
2751 let DecoderMethod = "DecodeSTRPreImm";
2754 def _PRE_REG : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2755 (ins GPR:$Rt, ldst_so_reg:$addr),
2756 IndexModePre, StFrm, iir,
2757 opc, "\t$Rt, $addr!",
2758 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2761 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2762 let Inst{19-16} = addr{16-13}; // Rn
2763 let Inst{11-0} = addr{11-0};
2764 let Inst{4} = 0; // Inst{4} = 0
2765 let DecoderMethod = "DecodeSTRPreReg";
2767 def _POST_REG : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2768 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2769 IndexModePost, StFrm, iir,
2770 opc, "\t$Rt, $addr, $offset",
2771 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2777 let Inst{23} = offset{12};
2778 let Inst{19-16} = addr;
2779 let Inst{11-0} = offset{11-0};
2782 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2785 def _POST_IMM : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2786 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2787 IndexModePost, StFrm, iii,
2788 opc, "\t$Rt, $addr, $offset",
2789 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2795 let Inst{23} = offset{12};
2796 let Inst{19-16} = addr;
2797 let Inst{11-0} = offset{11-0};
2799 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2803 let mayStore = 1, hasSideEffects = 0 in {
2804 // FIXME: for STR_PRE_REG etc. the itineray should be either IIC_iStore_ru or
2805 // IIC_iStore_siu depending on whether it the offset register is shifted.
2806 defm STR : AI2_stridx<0, "str", IIC_iStore_iu, IIC_iStore_ru>;
2807 defm STRB : AI2_stridx<1, "strb", IIC_iStore_bh_iu, IIC_iStore_bh_ru>;
2810 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2811 am2offset_reg:$offset),
2812 (STR_POST_REG GPR:$Rt, addr_offset_none:$addr,
2813 am2offset_reg:$offset)>;
2814 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2815 am2offset_imm:$offset),
2816 (STR_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2817 am2offset_imm:$offset)>;
2818 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2819 am2offset_reg:$offset),
2820 (STRB_POST_REG GPR:$Rt, addr_offset_none:$addr,
2821 am2offset_reg:$offset)>;
2822 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2823 am2offset_imm:$offset),
2824 (STRB_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2825 am2offset_imm:$offset)>;
2827 // Pseudo-instructions for pattern matching the pre-indexed stores. We can't
2828 // put the patterns on the instruction definitions directly as ISel wants
2829 // the address base and offset to be separate operands, not a single
2830 // complex operand like we represent the instructions themselves. The
2831 // pseudos map between the two.
2832 let usesCustomInserter = 1,
2833 Constraints = "$Rn = $Rn_wb,@earlyclobber $Rn_wb" in {
2834 def STRi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2835 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2838 (pre_store GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2839 def STRr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2840 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2843 (pre_store GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2844 def STRBi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2845 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2848 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2849 def STRBr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2850 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2853 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2854 def STRH_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2855 (ins GPR:$Rt, GPR:$Rn, am3offset:$offset, pred:$p),
2858 (pre_truncsti16 GPR:$Rt, GPR:$Rn, am3offset:$offset))]>;
2863 def STRH_PRE : AI3ldstidx<0b1011, 0, 1, (outs GPR:$Rn_wb),
2864 (ins GPR:$Rt, addrmode3_pre:$addr), IndexModePre,
2865 StMiscFrm, IIC_iStore_bh_ru,
2866 "strh", "\t$Rt, $addr!",
2867 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2869 let Inst{23} = addr{8}; // U bit
2870 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2871 let Inst{19-16} = addr{12-9}; // Rn
2872 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2873 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2874 let DecoderMethod = "DecodeAddrMode3Instruction";
2877 def STRH_POST : AI3ldstidx<0b1011, 0, 0, (outs GPR:$Rn_wb),
2878 (ins GPR:$Rt, addr_offset_none:$addr, am3offset:$offset),
2879 IndexModePost, StMiscFrm, IIC_iStore_bh_ru,
2880 "strh", "\t$Rt, $addr, $offset",
2881 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb",
2882 [(set GPR:$Rn_wb, (post_truncsti16 GPR:$Rt,
2883 addr_offset_none:$addr,
2884 am3offset:$offset))]> {
2887 let Inst{23} = offset{8}; // U bit
2888 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2889 let Inst{19-16} = addr;
2890 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2891 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2892 let DecoderMethod = "DecodeAddrMode3Instruction";
2895 let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
2896 def STRD_PRE : AI3ldstidx<0b1111, 0, 1, (outs GPR:$Rn_wb),
2897 (ins GPR:$Rt, GPR:$Rt2, addrmode3_pre:$addr),
2898 IndexModePre, StMiscFrm, IIC_iStore_d_ru,
2899 "strd", "\t$Rt, $Rt2, $addr!",
2900 "$addr.base = $Rn_wb", []> {
2902 let Inst{23} = addr{8}; // U bit
2903 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2904 let Inst{19-16} = addr{12-9}; // Rn
2905 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2906 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2907 let DecoderMethod = "DecodeAddrMode3Instruction";
2910 def STRD_POST: AI3ldstidx<0b1111, 0, 0, (outs GPR:$Rn_wb),
2911 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr,
2913 IndexModePost, StMiscFrm, IIC_iStore_d_ru,
2914 "strd", "\t$Rt, $Rt2, $addr, $offset",
2915 "$addr.base = $Rn_wb", []> {
2918 let Inst{23} = offset{8}; // U bit
2919 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2920 let Inst{19-16} = addr;
2921 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2922 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2923 let DecoderMethod = "DecodeAddrMode3Instruction";
2925 } // mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1
2927 // STRT, STRBT, and STRHT
2929 def STRBT_POST_REG : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2930 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2931 IndexModePost, StFrm, IIC_iStore_bh_ru,
2932 "strbt", "\t$Rt, $addr, $offset",
2933 "$addr.base = $Rn_wb", []> {
2939 let Inst{23} = offset{12};
2940 let Inst{21} = 1; // overwrite
2941 let Inst{19-16} = addr;
2942 let Inst{11-5} = offset{11-5};
2944 let Inst{3-0} = offset{3-0};
2945 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2949 : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2950 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2951 IndexModePost, StFrm, IIC_iStore_bh_ru,
2952 "strbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2958 let Inst{23} = offset{12};
2959 let Inst{21} = 1; // overwrite
2960 let Inst{19-16} = addr;
2961 let Inst{11-0} = offset{11-0};
2962 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2966 : ARMAsmPseudo<"strbt${q} $Rt, $addr",
2967 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>;
2969 let mayStore = 1, hasSideEffects = 0 in {
2970 def STRT_POST_REG : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
2971 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2972 IndexModePost, StFrm, IIC_iStore_ru,
2973 "strt", "\t$Rt, $addr, $offset",
2974 "$addr.base = $Rn_wb", []> {
2980 let Inst{23} = offset{12};
2981 let Inst{21} = 1; // overwrite
2982 let Inst{19-16} = addr;
2983 let Inst{11-5} = offset{11-5};
2985 let Inst{3-0} = offset{3-0};
2986 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2990 : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
2991 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2992 IndexModePost, StFrm, IIC_iStore_ru,
2993 "strt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2999 let Inst{23} = offset{12};
3000 let Inst{21} = 1; // overwrite
3001 let Inst{19-16} = addr;
3002 let Inst{11-0} = offset{11-0};
3003 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3008 : ARMAsmPseudo<"strt${q} $Rt, $addr",
3009 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>;
3011 multiclass AI3strT<bits<4> op, string opc> {
3012 def i : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
3013 (ins GPR:$Rt, addr_offset_none:$addr, postidx_imm8:$offset),
3014 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
3015 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
3017 let Inst{23} = offset{8};
3019 let Inst{11-8} = offset{7-4};
3020 let Inst{3-0} = offset{3-0};
3022 def r : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
3023 (ins GPR:$Rt, addr_offset_none:$addr, postidx_reg:$Rm),
3024 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
3025 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
3027 let Inst{23} = Rm{4};
3030 let Inst{3-0} = Rm{3-0};
3035 defm STRHT : AI3strT<0b1011, "strht">;
3037 def STL : AIstrrel<0b00, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3038 NoItinerary, "stl", "\t$Rt, $addr", []>;
3039 def STLB : AIstrrel<0b10, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3040 NoItinerary, "stlb", "\t$Rt, $addr", []>;
3041 def STLH : AIstrrel<0b11, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3042 NoItinerary, "stlh", "\t$Rt, $addr", []>;
3044 //===----------------------------------------------------------------------===//
3045 // Load / store multiple Instructions.
3048 multiclass arm_ldst_mult<string asm, string sfx, bit L_bit, bit P_bit, Format f,
3049 InstrItinClass itin, InstrItinClass itin_upd> {
3050 // IA is the default, so no need for an explicit suffix on the
3051 // mnemonic here. Without it is the canonical spelling.
3053 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3054 IndexModeNone, f, itin,
3055 !strconcat(asm, "${p}\t$Rn, $regs", sfx), "", []> {
3056 let Inst{24-23} = 0b01; // Increment After
3057 let Inst{22} = P_bit;
3058 let Inst{21} = 0; // No writeback
3059 let Inst{20} = L_bit;
3062 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3063 IndexModeUpd, f, itin_upd,
3064 !strconcat(asm, "${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3065 let Inst{24-23} = 0b01; // Increment After
3066 let Inst{22} = P_bit;
3067 let Inst{21} = 1; // Writeback
3068 let Inst{20} = L_bit;
3070 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3073 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3074 IndexModeNone, f, itin,
3075 !strconcat(asm, "da${p}\t$Rn, $regs", sfx), "", []> {
3076 let Inst{24-23} = 0b00; // Decrement After
3077 let Inst{22} = P_bit;
3078 let Inst{21} = 0; // No writeback
3079 let Inst{20} = L_bit;
3082 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3083 IndexModeUpd, f, itin_upd,
3084 !strconcat(asm, "da${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3085 let Inst{24-23} = 0b00; // Decrement After
3086 let Inst{22} = P_bit;
3087 let Inst{21} = 1; // Writeback
3088 let Inst{20} = L_bit;
3090 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3093 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3094 IndexModeNone, f, itin,
3095 !strconcat(asm, "db${p}\t$Rn, $regs", sfx), "", []> {
3096 let Inst{24-23} = 0b10; // Decrement Before
3097 let Inst{22} = P_bit;
3098 let Inst{21} = 0; // No writeback
3099 let Inst{20} = L_bit;
3102 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3103 IndexModeUpd, f, itin_upd,
3104 !strconcat(asm, "db${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3105 let Inst{24-23} = 0b10; // Decrement Before
3106 let Inst{22} = P_bit;
3107 let Inst{21} = 1; // Writeback
3108 let Inst{20} = L_bit;
3110 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3113 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3114 IndexModeNone, f, itin,
3115 !strconcat(asm, "ib${p}\t$Rn, $regs", sfx), "", []> {
3116 let Inst{24-23} = 0b11; // Increment Before
3117 let Inst{22} = P_bit;
3118 let Inst{21} = 0; // No writeback
3119 let Inst{20} = L_bit;
3122 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3123 IndexModeUpd, f, itin_upd,
3124 !strconcat(asm, "ib${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3125 let Inst{24-23} = 0b11; // Increment Before
3126 let Inst{22} = P_bit;
3127 let Inst{21} = 1; // Writeback
3128 let Inst{20} = L_bit;
3130 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3134 let hasSideEffects = 0 in {
3136 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
3137 defm LDM : arm_ldst_mult<"ldm", "", 1, 0, LdStMulFrm, IIC_iLoad_m,
3138 IIC_iLoad_mu>, ComplexDeprecationPredicate<"ARMLoad">;
3140 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
3141 defm STM : arm_ldst_mult<"stm", "", 0, 0, LdStMulFrm, IIC_iStore_m,
3143 ComplexDeprecationPredicate<"ARMStore">;
3147 // FIXME: remove when we have a way to marking a MI with these properties.
3148 // FIXME: Should pc be an implicit operand like PICADD, etc?
3149 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
3150 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
3151 def LDMIA_RET : ARMPseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p,
3152 reglist:$regs, variable_ops),
3153 4, IIC_iLoad_mBr, [],
3154 (LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>,
3155 RegConstraint<"$Rn = $wb">;
3157 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
3158 defm sysLDM : arm_ldst_mult<"ldm", " ^", 1, 1, LdStMulFrm, IIC_iLoad_m,
3161 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
3162 defm sysSTM : arm_ldst_mult<"stm", " ^", 0, 1, LdStMulFrm, IIC_iStore_m,
3167 //===----------------------------------------------------------------------===//
3168 // Move Instructions.
3171 let hasSideEffects = 0 in
3172 def MOVr : AsI1<0b1101, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMOVr,
3173 "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> {
3177 let Inst{19-16} = 0b0000;
3178 let Inst{11-4} = 0b00000000;
3181 let Inst{15-12} = Rd;
3184 // A version for the smaller set of tail call registers.
3185 let hasSideEffects = 0 in
3186 def MOVr_TC : AsI1<0b1101, (outs tcGPR:$Rd), (ins tcGPR:$Rm), DPFrm,
3187 IIC_iMOVr, "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> {
3191 let Inst{11-4} = 0b00000000;
3194 let Inst{15-12} = Rd;
3197 def MOVsr : AsI1<0b1101, (outs GPRnopc:$Rd), (ins shift_so_reg_reg:$src),
3198 DPSoRegRegFrm, IIC_iMOVsr,
3199 "mov", "\t$Rd, $src",
3200 [(set GPRnopc:$Rd, shift_so_reg_reg:$src)]>, UnaryDP,
3204 let Inst{15-12} = Rd;
3205 let Inst{19-16} = 0b0000;
3206 let Inst{11-8} = src{11-8};
3208 let Inst{6-5} = src{6-5};
3210 let Inst{3-0} = src{3-0};
3214 def MOVsi : AsI1<0b1101, (outs GPR:$Rd), (ins shift_so_reg_imm:$src),
3215 DPSoRegImmFrm, IIC_iMOVsr,
3216 "mov", "\t$Rd, $src", [(set GPR:$Rd, shift_so_reg_imm:$src)]>,
3217 UnaryDP, Sched<[WriteALU]> {
3220 let Inst{15-12} = Rd;
3221 let Inst{19-16} = 0b0000;
3222 let Inst{11-5} = src{11-5};
3224 let Inst{3-0} = src{3-0};
3228 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3229 def MOVi : AsI1<0b1101, (outs GPR:$Rd), (ins mod_imm:$imm), DPFrm, IIC_iMOVi,
3230 "mov", "\t$Rd, $imm", [(set GPR:$Rd, mod_imm:$imm)]>, UnaryDP,
3235 let Inst{15-12} = Rd;
3236 let Inst{19-16} = 0b0000;
3237 let Inst{11-0} = imm;
3240 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3241 def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins imm0_65535_expr:$imm),
3243 "movw", "\t$Rd, $imm",
3244 [(set GPR:$Rd, imm0_65535:$imm)]>,
3245 Requires<[IsARM, HasV6T2]>, UnaryDP, Sched<[WriteALU]> {
3248 let Inst{15-12} = Rd;
3249 let Inst{11-0} = imm{11-0};
3250 let Inst{19-16} = imm{15-12};
3253 let DecoderMethod = "DecodeArmMOVTWInstruction";
3256 def : InstAlias<"mov${p} $Rd, $imm",
3257 (MOVi16 GPR:$Rd, imm0_65535_expr:$imm, pred:$p)>,
3260 def MOVi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
3261 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
3264 let Constraints = "$src = $Rd" in {
3265 def MOVTi16 : AI1<0b1010, (outs GPRnopc:$Rd),
3266 (ins GPR:$src, imm0_65535_expr:$imm),
3268 "movt", "\t$Rd, $imm",
3270 (or (and GPR:$src, 0xffff),
3271 lo16AllZero:$imm))]>, UnaryDP,
3272 Requires<[IsARM, HasV6T2]>, Sched<[WriteALU]> {
3275 let Inst{15-12} = Rd;
3276 let Inst{11-0} = imm{11-0};
3277 let Inst{19-16} = imm{15-12};
3280 let DecoderMethod = "DecodeArmMOVTWInstruction";
3283 def MOVTi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
3284 (ins GPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
3289 def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
3290 Requires<[IsARM, HasV6T2]>;
3292 let Uses = [CPSR] in
3293 def RRX: PseudoInst<(outs GPR:$Rd), (ins GPR:$Rm), IIC_iMOVsi,
3294 [(set GPR:$Rd, (ARMrrx GPR:$Rm))]>, UnaryDP,
3295 Requires<[IsARM]>, Sched<[WriteALU]>;
3297 // These aren't really mov instructions, but we have to define them this way
3298 // due to flag operands.
3300 let Defs = [CPSR] in {
3301 def MOVsrl_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3302 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP,
3303 Sched<[WriteALU]>, Requires<[IsARM]>;
3304 def MOVsra_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3305 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP,
3306 Sched<[WriteALU]>, Requires<[IsARM]>;
3309 //===----------------------------------------------------------------------===//
3310 // Extend Instructions.
3315 def SXTB : AI_ext_rrot<0b01101010,
3316 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
3317 def SXTH : AI_ext_rrot<0b01101011,
3318 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
3320 def SXTAB : AI_exta_rrot<0b01101010,
3321 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
3322 def SXTAH : AI_exta_rrot<0b01101011,
3323 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
3325 def SXTB16 : AI_ext_rrot_np<0b01101000, "sxtb16">;
3327 def SXTAB16 : AI_exta_rrot_np<0b01101000, "sxtab16">;
3331 let AddedComplexity = 16 in {
3332 def UXTB : AI_ext_rrot<0b01101110,
3333 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
3334 def UXTH : AI_ext_rrot<0b01101111,
3335 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
3336 def UXTB16 : AI_ext_rrot<0b01101100,
3337 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
3339 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
3340 // The transformation should probably be done as a combiner action
3341 // instead so we can include a check for masking back in the upper
3342 // eight bits of the source into the lower eight bits of the result.
3343 //def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
3344 // (UXTB16r_rot GPR:$Src, 3)>;
3345 def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
3346 (UXTB16 GPR:$Src, 1)>;
3348 def UXTAB : AI_exta_rrot<0b01101110, "uxtab",
3349 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
3350 def UXTAH : AI_exta_rrot<0b01101111, "uxtah",
3351 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
3354 // This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
3355 def UXTAB16 : AI_exta_rrot_np<0b01101100, "uxtab16">;
3358 def SBFX : I<(outs GPRnopc:$Rd),
3359 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3360 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3361 "sbfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3362 Requires<[IsARM, HasV6T2]> {
3367 let Inst{27-21} = 0b0111101;
3368 let Inst{6-4} = 0b101;
3369 let Inst{20-16} = width;
3370 let Inst{15-12} = Rd;
3371 let Inst{11-7} = lsb;
3375 def UBFX : I<(outs GPRnopc:$Rd),
3376 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3377 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3378 "ubfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3379 Requires<[IsARM, HasV6T2]> {
3384 let Inst{27-21} = 0b0111111;
3385 let Inst{6-4} = 0b101;
3386 let Inst{20-16} = width;
3387 let Inst{15-12} = Rd;
3388 let Inst{11-7} = lsb;
3392 //===----------------------------------------------------------------------===//
3393 // Arithmetic Instructions.
3396 defm ADD : AsI1_bin_irs<0b0100, "add",
3397 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3398 BinOpFrag<(add node:$LHS, node:$RHS)>, 1>;
3399 defm SUB : AsI1_bin_irs<0b0010, "sub",
3400 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3401 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
3403 // ADD and SUB with 's' bit set.
3405 // Currently, ADDS/SUBS are pseudo opcodes that exist only in the
3406 // selection DAG. They are "lowered" to real ADD/SUB opcodes by
3407 // AdjustInstrPostInstrSelection where we determine whether or not to
3408 // set the "s" bit based on CPSR liveness.
3410 // FIXME: Eliminate ADDS/SUBS pseudo opcodes after adding tablegen
3411 // support for an optional CPSR definition that corresponds to the DAG
3412 // node's second value. We can then eliminate the implicit def of CPSR.
3413 defm ADDS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3414 BinOpFrag<(ARMaddc node:$LHS, node:$RHS)>, 1>;
3415 defm SUBS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3416 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
3418 defm ADC : AI1_adde_sube_irs<0b0101, "adc",
3419 BinOpWithFlagFrag<(ARMadde node:$LHS, node:$RHS, node:$FLAG)>, 1>;
3420 defm SBC : AI1_adde_sube_irs<0b0110, "sbc",
3421 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>>;
3423 defm RSB : AsI1_rbin_irs<0b0011, "rsb",
3424 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3425 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
3427 // FIXME: Eliminate them if we can write def : Pat patterns which defines
3428 // CPSR and the implicit def of CPSR is not needed.
3429 defm RSBS : AsI1_rbin_s_is<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3430 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
3432 defm RSC : AI1_rsc_irs<0b0111, "rsc",
3433 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>>;
3435 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
3436 // The assume-no-carry-in form uses the negation of the input since add/sub
3437 // assume opposite meanings of the carry flag (i.e., carry == !borrow).
3438 // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
3440 def : ARMPat<(add GPR:$src, mod_imm_neg:$imm),
3441 (SUBri GPR:$src, mod_imm_neg:$imm)>;
3442 def : ARMPat<(ARMaddc GPR:$src, mod_imm_neg:$imm),
3443 (SUBSri GPR:$src, mod_imm_neg:$imm)>;
3445 def : ARMPat<(add GPR:$src, imm0_65535_neg:$imm),
3446 (SUBrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>,
3447 Requires<[IsARM, HasV6T2]>;
3448 def : ARMPat<(ARMaddc GPR:$src, imm0_65535_neg:$imm),
3449 (SUBSrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>,
3450 Requires<[IsARM, HasV6T2]>;
3452 // The with-carry-in form matches bitwise not instead of the negation.
3453 // Effectively, the inverse interpretation of the carry flag already accounts
3454 // for part of the negation.
3455 def : ARMPat<(ARMadde GPR:$src, mod_imm_not:$imm, CPSR),
3456 (SBCri GPR:$src, mod_imm_not:$imm)>;
3457 def : ARMPat<(ARMadde GPR:$src, imm0_65535_neg:$imm, CPSR),
3458 (SBCrr GPR:$src, (MOVi16 (imm_not_XFORM imm:$imm)))>,
3459 Requires<[IsARM, HasV6T2]>;
3461 // Note: These are implemented in C++ code, because they have to generate
3462 // ADD/SUBrs instructions, which use a complex pattern that a xform function
3464 // (mul X, 2^n+1) -> (add (X << n), X)
3465 // (mul X, 2^n-1) -> (rsb X, (X << n))
3467 // ARM Arithmetic Instruction
3468 // GPR:$dst = GPR:$a op GPR:$b
3469 class AAI<bits<8> op27_20, bits<8> op11_4, string opc,
3470 list<dag> pattern = [],
3471 dag iops = (ins GPRnopc:$Rn, GPRnopc:$Rm),
3472 string asm = "\t$Rd, $Rn, $Rm">
3473 : AI<(outs GPRnopc:$Rd), iops, DPFrm, IIC_iALUr, opc, asm, pattern>,
3474 Sched<[WriteALU, ReadALU, ReadALU]> {
3478 let Inst{27-20} = op27_20;
3479 let Inst{11-4} = op11_4;
3480 let Inst{19-16} = Rn;
3481 let Inst{15-12} = Rd;
3484 let Unpredictable{11-8} = 0b1111;
3487 // Saturating add/subtract
3489 let DecoderMethod = "DecodeQADDInstruction" in
3490 def QADD : AAI<0b00010000, 0b00000101, "qadd",
3491 [(set GPRnopc:$Rd, (int_arm_qadd GPRnopc:$Rm, GPRnopc:$Rn))],
3492 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3494 def QSUB : AAI<0b00010010, 0b00000101, "qsub",
3495 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm, GPRnopc:$Rn))],
3496 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3497 def QDADD : AAI<0b00010100, 0b00000101, "qdadd", [],
3498 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3500 def QDSUB : AAI<0b00010110, 0b00000101, "qdsub", [],
3501 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3504 def QADD16 : AAI<0b01100010, 0b11110001, "qadd16">;
3505 def QADD8 : AAI<0b01100010, 0b11111001, "qadd8">;
3506 def QASX : AAI<0b01100010, 0b11110011, "qasx">;
3507 def QSAX : AAI<0b01100010, 0b11110101, "qsax">;
3508 def QSUB16 : AAI<0b01100010, 0b11110111, "qsub16">;
3509 def QSUB8 : AAI<0b01100010, 0b11111111, "qsub8">;
3510 def UQADD16 : AAI<0b01100110, 0b11110001, "uqadd16">;
3511 def UQADD8 : AAI<0b01100110, 0b11111001, "uqadd8">;
3512 def UQASX : AAI<0b01100110, 0b11110011, "uqasx">;
3513 def UQSAX : AAI<0b01100110, 0b11110101, "uqsax">;
3514 def UQSUB16 : AAI<0b01100110, 0b11110111, "uqsub16">;
3515 def UQSUB8 : AAI<0b01100110, 0b11111111, "uqsub8">;
3517 // Signed/Unsigned add/subtract
3519 def SASX : AAI<0b01100001, 0b11110011, "sasx">;
3520 def SADD16 : AAI<0b01100001, 0b11110001, "sadd16">;
3521 def SADD8 : AAI<0b01100001, 0b11111001, "sadd8">;
3522 def SSAX : AAI<0b01100001, 0b11110101, "ssax">;
3523 def SSUB16 : AAI<0b01100001, 0b11110111, "ssub16">;
3524 def SSUB8 : AAI<0b01100001, 0b11111111, "ssub8">;
3525 def UASX : AAI<0b01100101, 0b11110011, "uasx">;
3526 def UADD16 : AAI<0b01100101, 0b11110001, "uadd16">;
3527 def UADD8 : AAI<0b01100101, 0b11111001, "uadd8">;
3528 def USAX : AAI<0b01100101, 0b11110101, "usax">;
3529 def USUB16 : AAI<0b01100101, 0b11110111, "usub16">;
3530 def USUB8 : AAI<0b01100101, 0b11111111, "usub8">;
3532 // Signed/Unsigned halving add/subtract
3534 def SHASX : AAI<0b01100011, 0b11110011, "shasx">;
3535 def SHADD16 : AAI<0b01100011, 0b11110001, "shadd16">;
3536 def SHADD8 : AAI<0b01100011, 0b11111001, "shadd8">;
3537 def SHSAX : AAI<0b01100011, 0b11110101, "shsax">;
3538 def SHSUB16 : AAI<0b01100011, 0b11110111, "shsub16">;
3539 def SHSUB8 : AAI<0b01100011, 0b11111111, "shsub8">;
3540 def UHASX : AAI<0b01100111, 0b11110011, "uhasx">;
3541 def UHADD16 : AAI<0b01100111, 0b11110001, "uhadd16">;
3542 def UHADD8 : AAI<0b01100111, 0b11111001, "uhadd8">;
3543 def UHSAX : AAI<0b01100111, 0b11110101, "uhsax">;
3544 def UHSUB16 : AAI<0b01100111, 0b11110111, "uhsub16">;
3545 def UHSUB8 : AAI<0b01100111, 0b11111111, "uhsub8">;
3547 // Unsigned Sum of Absolute Differences [and Accumulate].
3549 def USAD8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3550 MulFrm /* for convenience */, NoItinerary, "usad8",
3551 "\t$Rd, $Rn, $Rm", []>,
3552 Requires<[IsARM, HasV6]>, Sched<[WriteALU, ReadALU, ReadALU]> {
3556 let Inst{27-20} = 0b01111000;
3557 let Inst{15-12} = 0b1111;
3558 let Inst{7-4} = 0b0001;
3559 let Inst{19-16} = Rd;
3560 let Inst{11-8} = Rm;
3563 def USADA8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3564 MulFrm /* for convenience */, NoItinerary, "usada8",
3565 "\t$Rd, $Rn, $Rm, $Ra", []>,
3566 Requires<[IsARM, HasV6]>, Sched<[WriteALU, ReadALU, ReadALU]>{
3571 let Inst{27-20} = 0b01111000;
3572 let Inst{7-4} = 0b0001;
3573 let Inst{19-16} = Rd;
3574 let Inst{15-12} = Ra;
3575 let Inst{11-8} = Rm;
3579 // Signed/Unsigned saturate
3581 def SSAT : AI<(outs GPRnopc:$Rd),
3582 (ins imm1_32:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3583 SatFrm, NoItinerary, "ssat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3588 let Inst{27-21} = 0b0110101;
3589 let Inst{5-4} = 0b01;
3590 let Inst{20-16} = sat_imm;
3591 let Inst{15-12} = Rd;
3592 let Inst{11-7} = sh{4-0};
3593 let Inst{6} = sh{5};
3597 def SSAT16 : AI<(outs GPRnopc:$Rd),
3598 (ins imm1_16:$sat_imm, GPRnopc:$Rn), SatFrm,
3599 NoItinerary, "ssat16", "\t$Rd, $sat_imm, $Rn", []> {
3603 let Inst{27-20} = 0b01101010;
3604 let Inst{11-4} = 0b11110011;
3605 let Inst{15-12} = Rd;
3606 let Inst{19-16} = sat_imm;
3610 def USAT : AI<(outs GPRnopc:$Rd),
3611 (ins imm0_31:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3612 SatFrm, NoItinerary, "usat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3617 let Inst{27-21} = 0b0110111;
3618 let Inst{5-4} = 0b01;
3619 let Inst{15-12} = Rd;
3620 let Inst{11-7} = sh{4-0};
3621 let Inst{6} = sh{5};
3622 let Inst{20-16} = sat_imm;
3626 def USAT16 : AI<(outs GPRnopc:$Rd),
3627 (ins imm0_15:$sat_imm, GPRnopc:$Rn), SatFrm,
3628 NoItinerary, "usat16", "\t$Rd, $sat_imm, $Rn", []> {
3632 let Inst{27-20} = 0b01101110;
3633 let Inst{11-4} = 0b11110011;
3634 let Inst{15-12} = Rd;
3635 let Inst{19-16} = sat_imm;
3639 def : ARMV6Pat<(int_arm_ssat GPRnopc:$a, imm:$pos),
3640 (SSAT imm:$pos, GPRnopc:$a, 0)>;
3641 def : ARMV6Pat<(int_arm_usat GPRnopc:$a, imm:$pos),
3642 (USAT imm:$pos, GPRnopc:$a, 0)>;
3644 //===----------------------------------------------------------------------===//
3645 // Bitwise Instructions.
3648 defm AND : AsI1_bin_irs<0b0000, "and",
3649 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3650 BinOpFrag<(and node:$LHS, node:$RHS)>, 1>;
3651 defm ORR : AsI1_bin_irs<0b1100, "orr",
3652 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3653 BinOpFrag<(or node:$LHS, node:$RHS)>, 1>;
3654 defm EOR : AsI1_bin_irs<0b0001, "eor",
3655 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3656 BinOpFrag<(xor node:$LHS, node:$RHS)>, 1>;
3657 defm BIC : AsI1_bin_irs<0b1110, "bic",
3658 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3659 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
3661 // FIXME: bf_inv_mask_imm should be two operands, the lsb and the msb, just
3662 // like in the actual instruction encoding. The complexity of mapping the mask
3663 // to the lsb/msb pair should be handled by ISel, not encapsulated in the
3664 // instruction description.
3665 def BFC : I<(outs GPR:$Rd), (ins GPR:$src, bf_inv_mask_imm:$imm),
3666 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3667 "bfc", "\t$Rd, $imm", "$src = $Rd",
3668 [(set GPR:$Rd, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
3669 Requires<[IsARM, HasV6T2]> {
3672 let Inst{27-21} = 0b0111110;
3673 let Inst{6-0} = 0b0011111;
3674 let Inst{15-12} = Rd;
3675 let Inst{11-7} = imm{4-0}; // lsb
3676 let Inst{20-16} = imm{9-5}; // msb
3679 // A8.6.18 BFI - Bitfield insert (Encoding A1)
3680 def BFI:I<(outs GPRnopc:$Rd), (ins GPRnopc:$src, GPR:$Rn, bf_inv_mask_imm:$imm),
3681 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3682 "bfi", "\t$Rd, $Rn, $imm", "$src = $Rd",
3683 [(set GPRnopc:$Rd, (ARMbfi GPRnopc:$src, GPR:$Rn,
3684 bf_inv_mask_imm:$imm))]>,
3685 Requires<[IsARM, HasV6T2]> {
3689 let Inst{27-21} = 0b0111110;
3690 let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15
3691 let Inst{15-12} = Rd;
3692 let Inst{11-7} = imm{4-0}; // lsb
3693 let Inst{20-16} = imm{9-5}; // width
3697 def MVNr : AsI1<0b1111, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMVNr,
3698 "mvn", "\t$Rd, $Rm",
3699 [(set GPR:$Rd, (not GPR:$Rm))]>, UnaryDP, Sched<[WriteALU]> {
3703 let Inst{19-16} = 0b0000;
3704 let Inst{11-4} = 0b00000000;
3705 let Inst{15-12} = Rd;
3708 def MVNsi : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_imm:$shift),
3709 DPSoRegImmFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3710 [(set GPR:$Rd, (not so_reg_imm:$shift))]>, UnaryDP,
3715 let Inst{19-16} = 0b0000;
3716 let Inst{15-12} = Rd;
3717 let Inst{11-5} = shift{11-5};
3719 let Inst{3-0} = shift{3-0};
3721 def MVNsr : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_reg:$shift),
3722 DPSoRegRegFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3723 [(set GPR:$Rd, (not so_reg_reg:$shift))]>, UnaryDP,
3728 let Inst{19-16} = 0b0000;
3729 let Inst{15-12} = Rd;
3730 let Inst{11-8} = shift{11-8};
3732 let Inst{6-5} = shift{6-5};
3734 let Inst{3-0} = shift{3-0};
3736 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3737 def MVNi : AsI1<0b1111, (outs GPR:$Rd), (ins mod_imm:$imm), DPFrm,
3738 IIC_iMVNi, "mvn", "\t$Rd, $imm",
3739 [(set GPR:$Rd, mod_imm_not:$imm)]>,UnaryDP, Sched<[WriteALU]> {
3743 let Inst{19-16} = 0b0000;
3744 let Inst{15-12} = Rd;
3745 let Inst{11-0} = imm;
3748 def : ARMPat<(and GPR:$src, mod_imm_not:$imm),
3749 (BICri GPR:$src, mod_imm_not:$imm)>;
3751 //===----------------------------------------------------------------------===//
3752 // Multiply Instructions.
3754 class AsMul1I32<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3755 string opc, string asm, list<dag> pattern>
3756 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3760 let Inst{19-16} = Rd;
3761 let Inst{11-8} = Rm;
3764 class AsMul1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3765 string opc, string asm, list<dag> pattern>
3766 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3771 let Inst{19-16} = RdHi;
3772 let Inst{15-12} = RdLo;
3773 let Inst{11-8} = Rm;
3776 class AsMla1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3777 string opc, string asm, list<dag> pattern>
3778 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3783 let Inst{19-16} = RdHi;
3784 let Inst{15-12} = RdLo;
3785 let Inst{11-8} = Rm;
3789 // FIXME: The v5 pseudos are only necessary for the additional Constraint
3790 // property. Remove them when it's possible to add those properties
3791 // on an individual MachineInstr, not just an instruction description.
3792 let isCommutable = 1, TwoOperandAliasConstraint = "$Rn = $Rd" in {
3793 def MUL : AsMul1I32<0b0000000, (outs GPRnopc:$Rd),
3794 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3795 IIC_iMUL32, "mul", "\t$Rd, $Rn, $Rm",
3796 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))]>,
3797 Requires<[IsARM, HasV6]> {
3798 let Inst{15-12} = 0b0000;
3799 let Unpredictable{15-12} = 0b1111;
3802 let Constraints = "@earlyclobber $Rd" in
3803 def MULv5: ARMPseudoExpand<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm,
3804 pred:$p, cc_out:$s),
3806 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))],
3807 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s)>,
3808 Requires<[IsARM, NoV6, UseMulOps]>;
3811 def MLA : AsMul1I32<0b0000001, (outs GPRnopc:$Rd),
3812 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra),
3813 IIC_iMAC32, "mla", "\t$Rd, $Rn, $Rm, $Ra",
3814 [(set GPRnopc:$Rd, (add (mul GPRnopc:$Rn, GPRnopc:$Rm), GPRnopc:$Ra))]>,
3815 Requires<[IsARM, HasV6, UseMulOps]> {
3817 let Inst{15-12} = Ra;
3820 let Constraints = "@earlyclobber $Rd" in
3821 def MLAv5: ARMPseudoExpand<(outs GPRnopc:$Rd),
3822 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra,
3823 pred:$p, cc_out:$s), 4, IIC_iMAC32,
3824 [(set GPRnopc:$Rd, (add (mul GPRnopc:$Rn, GPRnopc:$Rm), GPRnopc:$Ra))],
3825 (MLA GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra, pred:$p, cc_out:$s)>,
3826 Requires<[IsARM, NoV6]>;
3828 def MLS : AMul1I<0b0000011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3829 IIC_iMAC32, "mls", "\t$Rd, $Rn, $Rm, $Ra",
3830 [(set GPR:$Rd, (sub GPR:$Ra, (mul GPR:$Rn, GPR:$Rm)))]>,
3831 Requires<[IsARM, HasV6T2, UseMulOps]> {
3836 let Inst{19-16} = Rd;
3837 let Inst{15-12} = Ra;
3838 let Inst{11-8} = Rm;
3842 // Extra precision multiplies with low / high results
3843 let hasSideEffects = 0 in {
3844 let isCommutable = 1 in {
3845 def SMULL : AsMul1I64<0b0000110, (outs GPR:$RdLo, GPR:$RdHi),
3846 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3847 "smull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3848 Requires<[IsARM, HasV6]>;
3850 def UMULL : AsMul1I64<0b0000100, (outs GPR:$RdLo, GPR:$RdHi),
3851 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3852 "umull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3853 Requires<[IsARM, HasV6]>;
3855 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
3856 def SMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3857 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3859 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3860 Requires<[IsARM, NoV6]>;
3862 def UMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3863 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3865 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3866 Requires<[IsARM, NoV6]>;
3870 // Multiply + accumulate
3871 def SMLAL : AsMla1I64<0b0000111, (outs GPR:$RdLo, GPR:$RdHi),
3872 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64,
3873 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3874 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>;
3875 def UMLAL : AsMla1I64<0b0000101, (outs GPR:$RdLo, GPR:$RdHi),
3876 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64,
3877 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3878 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>;
3880 def UMAAL : AMul1I <0b0000010, (outs GPR:$RdLo, GPR:$RdHi),
3881 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3882 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3883 Requires<[IsARM, HasV6]> {
3888 let Inst{19-16} = RdHi;
3889 let Inst{15-12} = RdLo;
3890 let Inst{11-8} = Rm;
3895 "@earlyclobber $RdLo,@earlyclobber $RdHi,$RLo = $RdLo,$RHi = $RdHi" in {
3896 def SMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3897 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s),
3899 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi,
3900 pred:$p, cc_out:$s)>,
3901 Requires<[IsARM, NoV6]>;
3902 def UMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3903 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s),
3905 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi,
3906 pred:$p, cc_out:$s)>,
3907 Requires<[IsARM, NoV6]>;
3912 // Most significant word multiply
3913 def SMMUL : AMul2I <0b0111010, 0b0001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3914 IIC_iMUL32, "smmul", "\t$Rd, $Rn, $Rm",
3915 [(set GPR:$Rd, (mulhs GPR:$Rn, GPR:$Rm))]>,
3916 Requires<[IsARM, HasV6]> {
3917 let Inst{15-12} = 0b1111;
3920 def SMMULR : AMul2I <0b0111010, 0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3921 IIC_iMUL32, "smmulr", "\t$Rd, $Rn, $Rm", []>,
3922 Requires<[IsARM, HasV6]> {
3923 let Inst{15-12} = 0b1111;
3926 def SMMLA : AMul2Ia <0b0111010, 0b0001, (outs GPR:$Rd),
3927 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3928 IIC_iMAC32, "smmla", "\t$Rd, $Rn, $Rm, $Ra",
3929 [(set GPR:$Rd, (add (mulhs GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
3930 Requires<[IsARM, HasV6, UseMulOps]>;
3932 def SMMLAR : AMul2Ia <0b0111010, 0b0011, (outs GPR:$Rd),
3933 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3934 IIC_iMAC32, "smmlar", "\t$Rd, $Rn, $Rm, $Ra", []>,
3935 Requires<[IsARM, HasV6]>;
3937 def SMMLS : AMul2Ia <0b0111010, 0b1101, (outs GPR:$Rd),
3938 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3939 IIC_iMAC32, "smmls", "\t$Rd, $Rn, $Rm, $Ra", []>,
3940 Requires<[IsARM, HasV6, UseMulOps]>;
3942 def SMMLSR : AMul2Ia <0b0111010, 0b1111, (outs GPR:$Rd),
3943 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3944 IIC_iMAC32, "smmlsr", "\t$Rd, $Rn, $Rm, $Ra", []>,
3945 Requires<[IsARM, HasV6]>;
3947 multiclass AI_smul<string opc, PatFrag opnode> {
3948 def BB : AMulxyI<0b0001011, 0b00, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3949 IIC_iMUL16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm",
3950 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3951 (sext_inreg GPR:$Rm, i16)))]>,
3952 Requires<[IsARM, HasV5TE]>;
3954 def BT : AMulxyI<0b0001011, 0b10, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3955 IIC_iMUL16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm",
3956 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3957 (sra GPR:$Rm, (i32 16))))]>,
3958 Requires<[IsARM, HasV5TE]>;
3960 def TB : AMulxyI<0b0001011, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3961 IIC_iMUL16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm",
3962 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3963 (sext_inreg GPR:$Rm, i16)))]>,
3964 Requires<[IsARM, HasV5TE]>;
3966 def TT : AMulxyI<0b0001011, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3967 IIC_iMUL16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm",
3968 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3969 (sra GPR:$Rm, (i32 16))))]>,
3970 Requires<[IsARM, HasV5TE]>;
3972 def WB : AMulxyI<0b0001001, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3973 IIC_iMUL16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm",
3975 Requires<[IsARM, HasV5TE]>;
3977 def WT : AMulxyI<0b0001001, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3978 IIC_iMUL16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm",
3980 Requires<[IsARM, HasV5TE]>;
3984 multiclass AI_smla<string opc, PatFrag opnode> {
3985 let DecoderMethod = "DecodeSMLAInstruction" in {
3986 def BB : AMulxyIa<0b0001000, 0b00, (outs GPRnopc:$Rd),
3987 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3988 IIC_iMAC16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra",
3989 [(set GPRnopc:$Rd, (add GPR:$Ra,
3990 (opnode (sext_inreg GPRnopc:$Rn, i16),
3991 (sext_inreg GPRnopc:$Rm, i16))))]>,
3992 Requires<[IsARM, HasV5TE, UseMulOps]>;
3994 def BT : AMulxyIa<0b0001000, 0b10, (outs GPRnopc:$Rd),
3995 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3996 IIC_iMAC16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra",
3998 (add GPR:$Ra, (opnode (sext_inreg GPRnopc:$Rn, i16),
3999 (sra GPRnopc:$Rm, (i32 16)))))]>,
4000 Requires<[IsARM, HasV5TE, UseMulOps]>;
4002 def TB : AMulxyIa<0b0001000, 0b01, (outs GPRnopc:$Rd),
4003 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4004 IIC_iMAC16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra",
4006 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
4007 (sext_inreg GPRnopc:$Rm, i16))))]>,
4008 Requires<[IsARM, HasV5TE, UseMulOps]>;
4010 def TT : AMulxyIa<0b0001000, 0b11, (outs GPRnopc:$Rd),
4011 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4012 IIC_iMAC16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra",
4014 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
4015 (sra GPRnopc:$Rm, (i32 16)))))]>,
4016 Requires<[IsARM, HasV5TE, UseMulOps]>;
4018 def WB : AMulxyIa<0b0001001, 0b00, (outs GPRnopc:$Rd),
4019 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4020 IIC_iMAC16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra",
4022 Requires<[IsARM, HasV5TE, UseMulOps]>;
4024 def WT : AMulxyIa<0b0001001, 0b10, (outs GPRnopc:$Rd),
4025 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4026 IIC_iMAC16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra",
4028 Requires<[IsARM, HasV5TE, UseMulOps]>;
4032 defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
4033 defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
4035 // Halfword multiply accumulate long: SMLAL<x><y>.
4036 def SMLALBB : AMulxyI64<0b0001010, 0b00, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4037 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4038 IIC_iMAC64, "smlalbb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4039 Requires<[IsARM, HasV5TE]>;
4041 def SMLALBT : AMulxyI64<0b0001010, 0b10, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4042 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4043 IIC_iMAC64, "smlalbt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4044 Requires<[IsARM, HasV5TE]>;
4046 def SMLALTB : AMulxyI64<0b0001010, 0b01, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4047 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4048 IIC_iMAC64, "smlaltb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4049 Requires<[IsARM, HasV5TE]>;
4051 def SMLALTT : AMulxyI64<0b0001010, 0b11, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4052 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4053 IIC_iMAC64, "smlaltt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4054 Requires<[IsARM, HasV5TE]>;
4056 // Helper class for AI_smld.
4057 class AMulDualIbase<bit long, bit sub, bit swap, dag oops, dag iops,
4058 InstrItinClass itin, string opc, string asm>
4059 : AI<oops, iops, MulFrm, itin, opc, asm, []>, Requires<[IsARM, HasV6]> {
4062 let Inst{27-23} = 0b01110;
4063 let Inst{22} = long;
4064 let Inst{21-20} = 0b00;
4065 let Inst{11-8} = Rm;
4072 class AMulDualI<bit long, bit sub, bit swap, dag oops, dag iops,
4073 InstrItinClass itin, string opc, string asm>
4074 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4076 let Inst{15-12} = 0b1111;
4077 let Inst{19-16} = Rd;
4079 class AMulDualIa<bit long, bit sub, bit swap, dag oops, dag iops,
4080 InstrItinClass itin, string opc, string asm>
4081 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4084 let Inst{19-16} = Rd;
4085 let Inst{15-12} = Ra;
4087 class AMulDualI64<bit long, bit sub, bit swap, dag oops, dag iops,
4088 InstrItinClass itin, string opc, string asm>
4089 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4092 let Inst{19-16} = RdHi;
4093 let Inst{15-12} = RdLo;
4096 multiclass AI_smld<bit sub, string opc> {
4098 def D : AMulDualIa<0, sub, 0, (outs GPRnopc:$Rd),
4099 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4100 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm, $Ra">;
4102 def DX: AMulDualIa<0, sub, 1, (outs GPRnopc:$Rd),
4103 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4104 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm, $Ra">;
4106 def LD: AMulDualI64<1, sub, 0, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4107 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
4108 !strconcat(opc, "ld"), "\t$RdLo, $RdHi, $Rn, $Rm">;
4110 def LDX : AMulDualI64<1, sub, 1, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4111 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
4112 !strconcat(opc, "ldx"),"\t$RdLo, $RdHi, $Rn, $Rm">;
4116 defm SMLA : AI_smld<0, "smla">;
4117 defm SMLS : AI_smld<1, "smls">;
4119 multiclass AI_sdml<bit sub, string opc> {
4121 def D:AMulDualI<0, sub, 0, (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm),
4122 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm">;
4123 def DX:AMulDualI<0, sub, 1, (outs GPRnopc:$Rd),(ins GPRnopc:$Rn, GPRnopc:$Rm),
4124 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm">;
4127 defm SMUA : AI_sdml<0, "smua">;
4128 defm SMUS : AI_sdml<1, "smus">;
4130 //===----------------------------------------------------------------------===//
4131 // Division Instructions (ARMv7-A with virtualization extension)
4133 def SDIV : ADivA1I<0b001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV,
4134 "sdiv", "\t$Rd, $Rn, $Rm",
4135 [(set GPR:$Rd, (sdiv GPR:$Rn, GPR:$Rm))]>,
4136 Requires<[IsARM, HasDivideInARM]>;
4138 def UDIV : ADivA1I<0b011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV,
4139 "udiv", "\t$Rd, $Rn, $Rm",
4140 [(set GPR:$Rd, (udiv GPR:$Rn, GPR:$Rm))]>,
4141 Requires<[IsARM, HasDivideInARM]>;
4143 //===----------------------------------------------------------------------===//
4144 // Misc. Arithmetic Instructions.
4147 def CLZ : AMiscA1I<0b00010110, 0b0001, (outs GPR:$Rd), (ins GPR:$Rm),
4148 IIC_iUNAr, "clz", "\t$Rd, $Rm",
4149 [(set GPR:$Rd, (ctlz GPR:$Rm))]>, Requires<[IsARM, HasV5T]>,
4152 def RBIT : AMiscA1I<0b01101111, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
4153 IIC_iUNAr, "rbit", "\t$Rd, $Rm",
4154 [(set GPR:$Rd, (ARMrbit GPR:$Rm))]>,
4155 Requires<[IsARM, HasV6T2]>,
4158 def REV : AMiscA1I<0b01101011, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
4159 IIC_iUNAr, "rev", "\t$Rd, $Rm",
4160 [(set GPR:$Rd, (bswap GPR:$Rm))]>, Requires<[IsARM, HasV6]>,
4163 let AddedComplexity = 5 in
4164 def REV16 : AMiscA1I<0b01101011, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
4165 IIC_iUNAr, "rev16", "\t$Rd, $Rm",
4166 [(set GPR:$Rd, (rotr (bswap GPR:$Rm), (i32 16)))]>,
4167 Requires<[IsARM, HasV6]>,
4170 def : ARMV6Pat<(srl (bswap (extloadi16 addrmode3:$addr)), (i32 16)),
4171 (REV16 (LDRH addrmode3:$addr))>;
4172 def : ARMV6Pat<(truncstorei16 (srl (bswap GPR:$Rn), (i32 16)), addrmode3:$addr),
4173 (STRH (REV16 GPR:$Rn), addrmode3:$addr)>;
4175 let AddedComplexity = 5 in
4176 def REVSH : AMiscA1I<0b01101111, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
4177 IIC_iUNAr, "revsh", "\t$Rd, $Rm",
4178 [(set GPR:$Rd, (sra (bswap GPR:$Rm), (i32 16)))]>,
4179 Requires<[IsARM, HasV6]>,
4182 def : ARMV6Pat<(or (sra (shl GPR:$Rm, (i32 24)), (i32 16)),
4183 (and (srl GPR:$Rm, (i32 8)), 0xFF)),
4186 def PKHBT : APKHI<0b01101000, 0, (outs GPRnopc:$Rd),
4187 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_lsl_amt:$sh),
4188 IIC_iALUsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh",
4189 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF),
4190 (and (shl GPRnopc:$Rm, pkh_lsl_amt:$sh),
4192 Requires<[IsARM, HasV6]>,
4193 Sched<[WriteALUsi, ReadALU]>;
4195 // Alternate cases for PKHBT where identities eliminate some nodes.
4196 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (and GPRnopc:$Rm, 0xFFFF0000)),
4197 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, 0)>;
4198 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (shl GPRnopc:$Rm, imm16_31:$sh)),
4199 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, imm16_31:$sh)>;
4201 // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
4202 // will match the pattern below.
4203 def PKHTB : APKHI<0b01101000, 1, (outs GPRnopc:$Rd),
4204 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_asr_amt:$sh),
4205 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh",
4206 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF0000),
4207 (and (sra GPRnopc:$Rm, pkh_asr_amt:$sh),
4209 Requires<[IsARM, HasV6]>,
4210 Sched<[WriteALUsi, ReadALU]>;
4212 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
4213 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
4214 // We also can not replace a srl (17..31) by an arithmetic shift we would use in
4215 // pkhtb src1, src2, asr (17..31).
4216 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4217 (srl GPRnopc:$src2, imm16:$sh)),
4218 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16:$sh)>;
4219 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4220 (sra GPRnopc:$src2, imm16_31:$sh)),
4221 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16_31:$sh)>;
4222 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4223 (and (srl GPRnopc:$src2, imm1_15:$sh), 0xFFFF)),
4224 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm1_15:$sh)>;
4226 //===----------------------------------------------------------------------===//
4230 // + CRC32{B,H,W} 0x04C11DB7
4231 // + CRC32C{B,H,W} 0x1EDC6F41
4234 class AI_crc32<bit C, bits<2> sz, string suffix, SDPatternOperator builtin>
4235 : AInoP<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm), MiscFrm, NoItinerary,
4236 !strconcat("crc32", suffix), "\t$Rd, $Rn, $Rm",
4237 [(set GPRnopc:$Rd, (builtin GPRnopc:$Rn, GPRnopc:$Rm))]>,
4238 Requires<[IsARM, HasV8, HasCRC]> {
4243 let Inst{31-28} = 0b1110;
4244 let Inst{27-23} = 0b00010;
4245 let Inst{22-21} = sz;
4247 let Inst{19-16} = Rn;
4248 let Inst{15-12} = Rd;
4249 let Inst{11-10} = 0b00;
4252 let Inst{7-4} = 0b0100;
4255 let Unpredictable{11-8} = 0b1101;
4258 def CRC32B : AI_crc32<0, 0b00, "b", int_arm_crc32b>;
4259 def CRC32CB : AI_crc32<1, 0b00, "cb", int_arm_crc32cb>;
4260 def CRC32H : AI_crc32<0, 0b01, "h", int_arm_crc32h>;
4261 def CRC32CH : AI_crc32<1, 0b01, "ch", int_arm_crc32ch>;
4262 def CRC32W : AI_crc32<0, 0b10, "w", int_arm_crc32w>;
4263 def CRC32CW : AI_crc32<1, 0b10, "cw", int_arm_crc32cw>;
4265 //===----------------------------------------------------------------------===//
4266 // Comparison Instructions...
4269 defm CMP : AI1_cmp_irs<0b1010, "cmp",
4270 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
4271 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
4273 // ARMcmpZ can re-use the above instruction definitions.
4274 def : ARMPat<(ARMcmpZ GPR:$src, mod_imm:$imm),
4275 (CMPri GPR:$src, mod_imm:$imm)>;
4276 def : ARMPat<(ARMcmpZ GPR:$src, GPR:$rhs),
4277 (CMPrr GPR:$src, GPR:$rhs)>;
4278 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_imm:$rhs),
4279 (CMPrsi GPR:$src, so_reg_imm:$rhs)>;
4280 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_reg:$rhs),
4281 (CMPrsr GPR:$src, so_reg_reg:$rhs)>;
4283 // CMN register-integer
4284 let isCompare = 1, Defs = [CPSR] in {
4285 def CMNri : AI1<0b1011, (outs), (ins GPR:$Rn, mod_imm:$imm), DPFrm, IIC_iCMPi,
4286 "cmn", "\t$Rn, $imm",
4287 [(ARMcmn GPR:$Rn, mod_imm:$imm)]>,
4288 Sched<[WriteCMP, ReadALU]> {
4293 let Inst{19-16} = Rn;
4294 let Inst{15-12} = 0b0000;
4295 let Inst{11-0} = imm;
4297 let Unpredictable{15-12} = 0b1111;
4300 // CMN register-register/shift
4301 def CMNzrr : AI1<0b1011, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, IIC_iCMPr,
4302 "cmn", "\t$Rn, $Rm",
4303 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4304 GPR:$Rn, GPR:$Rm)]>, Sched<[WriteCMP, ReadALU, ReadALU]> {
4307 let isCommutable = 1;
4310 let Inst{19-16} = Rn;
4311 let Inst{15-12} = 0b0000;
4312 let Inst{11-4} = 0b00000000;
4315 let Unpredictable{15-12} = 0b1111;
4318 def CMNzrsi : AI1<0b1011, (outs),
4319 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, IIC_iCMPsr,
4320 "cmn", "\t$Rn, $shift",
4321 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4322 GPR:$Rn, so_reg_imm:$shift)]>,
4323 Sched<[WriteCMPsi, ReadALU]> {
4328 let Inst{19-16} = Rn;
4329 let Inst{15-12} = 0b0000;
4330 let Inst{11-5} = shift{11-5};
4332 let Inst{3-0} = shift{3-0};
4334 let Unpredictable{15-12} = 0b1111;
4337 def CMNzrsr : AI1<0b1011, (outs),
4338 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, IIC_iCMPsr,
4339 "cmn", "\t$Rn, $shift",
4340 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4341 GPRnopc:$Rn, so_reg_reg:$shift)]>,
4342 Sched<[WriteCMPsr, ReadALU]> {
4347 let Inst{19-16} = Rn;
4348 let Inst{15-12} = 0b0000;
4349 let Inst{11-8} = shift{11-8};
4351 let Inst{6-5} = shift{6-5};
4353 let Inst{3-0} = shift{3-0};
4355 let Unpredictable{15-12} = 0b1111;
4360 def : ARMPat<(ARMcmp GPR:$src, mod_imm_neg:$imm),
4361 (CMNri GPR:$src, mod_imm_neg:$imm)>;
4363 def : ARMPat<(ARMcmpZ GPR:$src, mod_imm_neg:$imm),
4364 (CMNri GPR:$src, mod_imm_neg:$imm)>;
4366 // Note that TST/TEQ don't set all the same flags that CMP does!
4367 defm TST : AI1_cmp_irs<0b1000, "tst",
4368 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
4369 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>, 1>;
4370 defm TEQ : AI1_cmp_irs<0b1001, "teq",
4371 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
4372 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>, 1>;
4374 // Pseudo i64 compares for some floating point compares.
4375 let usesCustomInserter = 1, isBranch = 1, isTerminator = 1,
4377 def BCCi64 : PseudoInst<(outs),
4378 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, brtarget:$dst),
4380 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, bb:$dst)]>,
4383 def BCCZi64 : PseudoInst<(outs),
4384 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, brtarget:$dst), IIC_Br,
4385 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, 0, 0, bb:$dst)]>,
4387 } // usesCustomInserter
4390 // Conditional moves
4391 let hasSideEffects = 0 in {
4393 let isCommutable = 1, isSelect = 1 in
4394 def MOVCCr : ARMPseudoInst<(outs GPR:$Rd),
4395 (ins GPR:$false, GPR:$Rm, cmovpred:$p),
4397 [(set GPR:$Rd, (ARMcmov GPR:$false, GPR:$Rm,
4399 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4401 def MOVCCsi : ARMPseudoInst<(outs GPR:$Rd),
4402 (ins GPR:$false, so_reg_imm:$shift, cmovpred:$p),
4405 (ARMcmov GPR:$false, so_reg_imm:$shift,
4407 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4408 def MOVCCsr : ARMPseudoInst<(outs GPR:$Rd),
4409 (ins GPR:$false, so_reg_reg:$shift, cmovpred:$p),
4411 [(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_reg:$shift,
4413 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4416 let isMoveImm = 1 in
4418 : ARMPseudoInst<(outs GPR:$Rd),
4419 (ins GPR:$false, imm0_65535_expr:$imm, cmovpred:$p),
4421 [(set GPR:$Rd, (ARMcmov GPR:$false, imm0_65535:$imm,
4423 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>,
4426 let isMoveImm = 1 in
4427 def MOVCCi : ARMPseudoInst<(outs GPR:$Rd),
4428 (ins GPR:$false, mod_imm:$imm, cmovpred:$p),
4430 [(set GPR:$Rd, (ARMcmov GPR:$false, mod_imm:$imm,
4432 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4434 // Two instruction predicate mov immediate.
4435 let isMoveImm = 1 in
4437 : ARMPseudoInst<(outs GPR:$Rd),
4438 (ins GPR:$false, i32imm:$src, cmovpred:$p),
4440 [(set GPR:$Rd, (ARMcmov GPR:$false, imm:$src,
4442 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>;
4444 let isMoveImm = 1 in
4445 def MVNCCi : ARMPseudoInst<(outs GPR:$Rd),
4446 (ins GPR:$false, mod_imm:$imm, cmovpred:$p),
4448 [(set GPR:$Rd, (ARMcmov GPR:$false, mod_imm_not:$imm,
4450 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4455 //===----------------------------------------------------------------------===//
4456 // Atomic operations intrinsics
4459 def MemBarrierOptOperand : AsmOperandClass {
4460 let Name = "MemBarrierOpt";
4461 let ParserMethod = "parseMemBarrierOptOperand";
4463 def memb_opt : Operand<i32> {
4464 let PrintMethod = "printMemBOption";
4465 let ParserMatchClass = MemBarrierOptOperand;
4466 let DecoderMethod = "DecodeMemBarrierOption";
4469 def InstSyncBarrierOptOperand : AsmOperandClass {
4470 let Name = "InstSyncBarrierOpt";
4471 let ParserMethod = "parseInstSyncBarrierOptOperand";
4473 def instsyncb_opt : Operand<i32> {
4474 let PrintMethod = "printInstSyncBOption";
4475 let ParserMatchClass = InstSyncBarrierOptOperand;
4476 let DecoderMethod = "DecodeInstSyncBarrierOption";
4479 // Memory barriers protect the atomic sequences
4480 let hasSideEffects = 1 in {
4481 def DMB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4482 "dmb", "\t$opt", [(int_arm_dmb (i32 imm0_15:$opt))]>,
4483 Requires<[IsARM, HasDB]> {
4485 let Inst{31-4} = 0xf57ff05;
4486 let Inst{3-0} = opt;
4489 def DSB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4490 "dsb", "\t$opt", [(int_arm_dsb (i32 imm0_15:$opt))]>,
4491 Requires<[IsARM, HasDB]> {
4493 let Inst{31-4} = 0xf57ff04;
4494 let Inst{3-0} = opt;
4497 // ISB has only full system option
4498 def ISB : AInoP<(outs), (ins instsyncb_opt:$opt), MiscFrm, NoItinerary,
4499 "isb", "\t$opt", [(int_arm_isb (i32 imm0_15:$opt))]>,
4500 Requires<[IsARM, HasDB]> {
4502 let Inst{31-4} = 0xf57ff06;
4503 let Inst{3-0} = opt;
4507 let usesCustomInserter = 1, Defs = [CPSR] in {
4509 // Pseudo instruction that combines movs + predicated rsbmi
4510 // to implement integer ABS
4511 def ABS : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$src), 8, NoItinerary, []>;
4514 let usesCustomInserter = 1 in {
4515 def COPY_STRUCT_BYVAL_I32 : PseudoInst<
4516 (outs), (ins GPR:$dst, GPR:$src, i32imm:$size, i32imm:$alignment),
4518 [(ARMcopystructbyval GPR:$dst, GPR:$src, imm:$size, imm:$alignment)]>;
4521 def ldrex_1 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4522 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4525 def ldrex_2 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4526 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4529 def ldrex_4 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4530 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4533 def strex_1 : PatFrag<(ops node:$val, node:$ptr),
4534 (int_arm_strex node:$val, node:$ptr), [{
4535 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4538 def strex_2 : PatFrag<(ops node:$val, node:$ptr),
4539 (int_arm_strex node:$val, node:$ptr), [{
4540 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4543 def strex_4 : PatFrag<(ops node:$val, node:$ptr),
4544 (int_arm_strex node:$val, node:$ptr), [{
4545 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4548 def ldaex_1 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4549 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4552 def ldaex_2 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4553 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4556 def ldaex_4 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4557 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4560 def stlex_1 : PatFrag<(ops node:$val, node:$ptr),
4561 (int_arm_stlex node:$val, node:$ptr), [{
4562 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4565 def stlex_2 : PatFrag<(ops node:$val, node:$ptr),
4566 (int_arm_stlex node:$val, node:$ptr), [{
4567 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4570 def stlex_4 : PatFrag<(ops node:$val, node:$ptr),
4571 (int_arm_stlex node:$val, node:$ptr), [{
4572 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4575 let mayLoad = 1 in {
4576 def LDREXB : AIldrex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4577 NoItinerary, "ldrexb", "\t$Rt, $addr",
4578 [(set GPR:$Rt, (ldrex_1 addr_offset_none:$addr))]>;
4579 def LDREXH : AIldrex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4580 NoItinerary, "ldrexh", "\t$Rt, $addr",
4581 [(set GPR:$Rt, (ldrex_2 addr_offset_none:$addr))]>;
4582 def LDREX : AIldrex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4583 NoItinerary, "ldrex", "\t$Rt, $addr",
4584 [(set GPR:$Rt, (ldrex_4 addr_offset_none:$addr))]>;
4585 let hasExtraDefRegAllocReq = 1 in
4586 def LDREXD : AIldrex<0b01, (outs GPRPairOp:$Rt),(ins addr_offset_none:$addr),
4587 NoItinerary, "ldrexd", "\t$Rt, $addr", []> {
4588 let DecoderMethod = "DecodeDoubleRegLoad";
4591 def LDAEXB : AIldaex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4592 NoItinerary, "ldaexb", "\t$Rt, $addr",
4593 [(set GPR:$Rt, (ldaex_1 addr_offset_none:$addr))]>;
4594 def LDAEXH : AIldaex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4595 NoItinerary, "ldaexh", "\t$Rt, $addr",
4596 [(set GPR:$Rt, (ldaex_2 addr_offset_none:$addr))]>;
4597 def LDAEX : AIldaex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4598 NoItinerary, "ldaex", "\t$Rt, $addr",
4599 [(set GPR:$Rt, (ldaex_4 addr_offset_none:$addr))]>;
4600 let hasExtraDefRegAllocReq = 1 in
4601 def LDAEXD : AIldaex<0b01, (outs GPRPairOp:$Rt),(ins addr_offset_none:$addr),
4602 NoItinerary, "ldaexd", "\t$Rt, $addr", []> {
4603 let DecoderMethod = "DecodeDoubleRegLoad";
4607 let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
4608 def STREXB: AIstrex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4609 NoItinerary, "strexb", "\t$Rd, $Rt, $addr",
4610 [(set GPR:$Rd, (strex_1 GPR:$Rt,
4611 addr_offset_none:$addr))]>;
4612 def STREXH: AIstrex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4613 NoItinerary, "strexh", "\t$Rd, $Rt, $addr",
4614 [(set GPR:$Rd, (strex_2 GPR:$Rt,
4615 addr_offset_none:$addr))]>;
4616 def STREX : AIstrex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4617 NoItinerary, "strex", "\t$Rd, $Rt, $addr",
4618 [(set GPR:$Rd, (strex_4 GPR:$Rt,
4619 addr_offset_none:$addr))]>;
4620 let hasExtraSrcRegAllocReq = 1 in
4621 def STREXD : AIstrex<0b01, (outs GPR:$Rd),
4622 (ins GPRPairOp:$Rt, addr_offset_none:$addr),
4623 NoItinerary, "strexd", "\t$Rd, $Rt, $addr", []> {
4624 let DecoderMethod = "DecodeDoubleRegStore";
4626 def STLEXB: AIstlex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4627 NoItinerary, "stlexb", "\t$Rd, $Rt, $addr",
4629 (stlex_1 GPR:$Rt, addr_offset_none:$addr))]>;
4630 def STLEXH: AIstlex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4631 NoItinerary, "stlexh", "\t$Rd, $Rt, $addr",
4633 (stlex_2 GPR:$Rt, addr_offset_none:$addr))]>;
4634 def STLEX : AIstlex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4635 NoItinerary, "stlex", "\t$Rd, $Rt, $addr",
4637 (stlex_4 GPR:$Rt, addr_offset_none:$addr))]>;
4638 let hasExtraSrcRegAllocReq = 1 in
4639 def STLEXD : AIstlex<0b01, (outs GPR:$Rd),
4640 (ins GPRPairOp:$Rt, addr_offset_none:$addr),
4641 NoItinerary, "stlexd", "\t$Rd, $Rt, $addr", []> {
4642 let DecoderMethod = "DecodeDoubleRegStore";
4646 def CLREX : AXI<(outs), (ins), MiscFrm, NoItinerary, "clrex",
4648 Requires<[IsARM, HasV7]> {
4649 let Inst{31-0} = 0b11110101011111111111000000011111;
4652 def : ARMPat<(strex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr),
4653 (STREXB GPR:$Rt, addr_offset_none:$addr)>;
4654 def : ARMPat<(strex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr),
4655 (STREXH GPR:$Rt, addr_offset_none:$addr)>;
4657 def : ARMPat<(stlex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr),
4658 (STLEXB GPR:$Rt, addr_offset_none:$addr)>;
4659 def : ARMPat<(stlex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr),
4660 (STLEXH GPR:$Rt, addr_offset_none:$addr)>;
4662 class acquiring_load<PatFrag base>
4663 : PatFrag<(ops node:$ptr), (base node:$ptr), [{
4664 AtomicOrdering Ordering = cast<AtomicSDNode>(N)->getOrdering();
4665 return isAtLeastAcquire(Ordering);
4668 def atomic_load_acquire_8 : acquiring_load<atomic_load_8>;
4669 def atomic_load_acquire_16 : acquiring_load<atomic_load_16>;
4670 def atomic_load_acquire_32 : acquiring_load<atomic_load_32>;
4672 class releasing_store<PatFrag base>
4673 : PatFrag<(ops node:$ptr, node:$val), (base node:$ptr, node:$val), [{
4674 AtomicOrdering Ordering = cast<AtomicSDNode>(N)->getOrdering();
4675 return isAtLeastRelease(Ordering);
4678 def atomic_store_release_8 : releasing_store<atomic_store_8>;
4679 def atomic_store_release_16 : releasing_store<atomic_store_16>;
4680 def atomic_store_release_32 : releasing_store<atomic_store_32>;
4682 let AddedComplexity = 8 in {
4683 def : ARMPat<(atomic_load_acquire_8 addr_offset_none:$addr), (LDAB addr_offset_none:$addr)>;
4684 def : ARMPat<(atomic_load_acquire_16 addr_offset_none:$addr), (LDAH addr_offset_none:$addr)>;
4685 def : ARMPat<(atomic_load_acquire_32 addr_offset_none:$addr), (LDA addr_offset_none:$addr)>;
4686 def : ARMPat<(atomic_store_release_8 addr_offset_none:$addr, GPR:$val), (STLB GPR:$val, addr_offset_none:$addr)>;
4687 def : ARMPat<(atomic_store_release_16 addr_offset_none:$addr, GPR:$val), (STLH GPR:$val, addr_offset_none:$addr)>;
4688 def : ARMPat<(atomic_store_release_32 addr_offset_none:$addr, GPR:$val), (STL GPR:$val, addr_offset_none:$addr)>;
4691 // SWP/SWPB are deprecated in V6/V7.
4692 let mayLoad = 1, mayStore = 1 in {
4693 def SWP : AIswp<0, (outs GPRnopc:$Rt),
4694 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swp", []>,
4696 def SWPB: AIswp<1, (outs GPRnopc:$Rt),
4697 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swpb", []>,
4701 //===----------------------------------------------------------------------===//
4702 // Coprocessor Instructions.
4705 def CDP : ABI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4706 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4707 NoItinerary, "cdp", "\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4708 [(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4709 imm:$CRm, imm:$opc2)]>,
4718 let Inst{3-0} = CRm;
4720 let Inst{7-5} = opc2;
4721 let Inst{11-8} = cop;
4722 let Inst{15-12} = CRd;
4723 let Inst{19-16} = CRn;
4724 let Inst{23-20} = opc1;
4727 def CDP2 : ABXI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4728 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4729 NoItinerary, "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4730 [(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4731 imm:$CRm, imm:$opc2)]>,
4733 let Inst{31-28} = 0b1111;
4741 let Inst{3-0} = CRm;
4743 let Inst{7-5} = opc2;
4744 let Inst{11-8} = cop;
4745 let Inst{15-12} = CRd;
4746 let Inst{19-16} = CRn;
4747 let Inst{23-20} = opc1;
4750 class ACI<dag oops, dag iops, string opc, string asm,
4751 IndexMode im = IndexModeNone>
4752 : I<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
4754 let Inst{27-25} = 0b110;
4756 class ACInoP<dag oops, dag iops, string opc, string asm,
4757 IndexMode im = IndexModeNone>
4758 : InoP<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
4760 let Inst{31-28} = 0b1111;
4761 let Inst{27-25} = 0b110;
4763 multiclass LdStCop<bit load, bit Dbit, string asm> {
4764 def _OFFSET : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4765 asm, "\t$cop, $CRd, $addr"> {
4769 let Inst{24} = 1; // P = 1
4770 let Inst{23} = addr{8};
4771 let Inst{22} = Dbit;
4772 let Inst{21} = 0; // W = 0
4773 let Inst{20} = load;
4774 let Inst{19-16} = addr{12-9};
4775 let Inst{15-12} = CRd;
4776 let Inst{11-8} = cop;
4777 let Inst{7-0} = addr{7-0};
4778 let DecoderMethod = "DecodeCopMemInstruction";
4780 def _PRE : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr),
4781 asm, "\t$cop, $CRd, $addr!", IndexModePre> {
4785 let Inst{24} = 1; // P = 1
4786 let Inst{23} = addr{8};
4787 let Inst{22} = Dbit;
4788 let Inst{21} = 1; // W = 1
4789 let Inst{20} = load;
4790 let Inst{19-16} = addr{12-9};
4791 let Inst{15-12} = CRd;
4792 let Inst{11-8} = cop;
4793 let Inst{7-0} = addr{7-0};
4794 let DecoderMethod = "DecodeCopMemInstruction";
4796 def _POST: ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4797 postidx_imm8s4:$offset),
4798 asm, "\t$cop, $CRd, $addr, $offset", IndexModePost> {
4803 let Inst{24} = 0; // P = 0
4804 let Inst{23} = offset{8};
4805 let Inst{22} = Dbit;
4806 let Inst{21} = 1; // W = 1
4807 let Inst{20} = load;
4808 let Inst{19-16} = addr;
4809 let Inst{15-12} = CRd;
4810 let Inst{11-8} = cop;
4811 let Inst{7-0} = offset{7-0};
4812 let DecoderMethod = "DecodeCopMemInstruction";
4814 def _OPTION : ACI<(outs),
4815 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4816 coproc_option_imm:$option),
4817 asm, "\t$cop, $CRd, $addr, $option"> {
4822 let Inst{24} = 0; // P = 0
4823 let Inst{23} = 1; // U = 1
4824 let Inst{22} = Dbit;
4825 let Inst{21} = 0; // W = 0
4826 let Inst{20} = load;
4827 let Inst{19-16} = addr;
4828 let Inst{15-12} = CRd;
4829 let Inst{11-8} = cop;
4830 let Inst{7-0} = option;
4831 let DecoderMethod = "DecodeCopMemInstruction";
4834 multiclass LdSt2Cop<bit load, bit Dbit, string asm> {
4835 def _OFFSET : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4836 asm, "\t$cop, $CRd, $addr"> {
4840 let Inst{24} = 1; // P = 1
4841 let Inst{23} = addr{8};
4842 let Inst{22} = Dbit;
4843 let Inst{21} = 0; // W = 0
4844 let Inst{20} = load;
4845 let Inst{19-16} = addr{12-9};
4846 let Inst{15-12} = CRd;
4847 let Inst{11-8} = cop;
4848 let Inst{7-0} = addr{7-0};
4849 let DecoderMethod = "DecodeCopMemInstruction";
4851 def _PRE : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr),
4852 asm, "\t$cop, $CRd, $addr!", IndexModePre> {
4856 let Inst{24} = 1; // P = 1
4857 let Inst{23} = addr{8};
4858 let Inst{22} = Dbit;
4859 let Inst{21} = 1; // W = 1
4860 let Inst{20} = load;
4861 let Inst{19-16} = addr{12-9};
4862 let Inst{15-12} = CRd;
4863 let Inst{11-8} = cop;
4864 let Inst{7-0} = addr{7-0};
4865 let DecoderMethod = "DecodeCopMemInstruction";
4867 def _POST: ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4868 postidx_imm8s4:$offset),
4869 asm, "\t$cop, $CRd, $addr, $offset", IndexModePost> {
4874 let Inst{24} = 0; // P = 0
4875 let Inst{23} = offset{8};
4876 let Inst{22} = Dbit;
4877 let Inst{21} = 1; // W = 1
4878 let Inst{20} = load;
4879 let Inst{19-16} = addr;
4880 let Inst{15-12} = CRd;
4881 let Inst{11-8} = cop;
4882 let Inst{7-0} = offset{7-0};
4883 let DecoderMethod = "DecodeCopMemInstruction";
4885 def _OPTION : ACInoP<(outs),
4886 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4887 coproc_option_imm:$option),
4888 asm, "\t$cop, $CRd, $addr, $option"> {
4893 let Inst{24} = 0; // P = 0
4894 let Inst{23} = 1; // U = 1
4895 let Inst{22} = Dbit;
4896 let Inst{21} = 0; // W = 0
4897 let Inst{20} = load;
4898 let Inst{19-16} = addr;
4899 let Inst{15-12} = CRd;
4900 let Inst{11-8} = cop;
4901 let Inst{7-0} = option;
4902 let DecoderMethod = "DecodeCopMemInstruction";
4906 defm LDC : LdStCop <1, 0, "ldc">;
4907 defm LDCL : LdStCop <1, 1, "ldcl">;
4908 defm STC : LdStCop <0, 0, "stc">;
4909 defm STCL : LdStCop <0, 1, "stcl">;
4910 defm LDC2 : LdSt2Cop<1, 0, "ldc2">, Requires<[PreV8]>;
4911 defm LDC2L : LdSt2Cop<1, 1, "ldc2l">, Requires<[PreV8]>;
4912 defm STC2 : LdSt2Cop<0, 0, "stc2">, Requires<[PreV8]>;
4913 defm STC2L : LdSt2Cop<0, 1, "stc2l">, Requires<[PreV8]>;
4915 //===----------------------------------------------------------------------===//
4916 // Move between coprocessor and ARM core register.
4919 class MovRCopro<string opc, bit direction, dag oops, dag iops,
4921 : ABI<0b1110, oops, iops, NoItinerary, opc,
4922 "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2", pattern> {
4923 let Inst{20} = direction;
4933 let Inst{15-12} = Rt;
4934 let Inst{11-8} = cop;
4935 let Inst{23-21} = opc1;
4936 let Inst{7-5} = opc2;
4937 let Inst{3-0} = CRm;
4938 let Inst{19-16} = CRn;
4941 def MCR : MovRCopro<"mcr", 0 /* from ARM core register to coprocessor */,
4943 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4944 c_imm:$CRm, imm0_7:$opc2),
4945 [(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
4946 imm:$CRm, imm:$opc2)]>,
4947 ComplexDeprecationPredicate<"MCR">;
4948 def : ARMInstAlias<"mcr${p} $cop, $opc1, $Rt, $CRn, $CRm",
4949 (MCR p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4950 c_imm:$CRm, 0, pred:$p)>;
4951 def MRC : MovRCopro<"mrc", 1 /* from coprocessor to ARM core register */,
4952 (outs GPRwithAPSR:$Rt),
4953 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
4955 def : ARMInstAlias<"mrc${p} $cop, $opc1, $Rt, $CRn, $CRm",
4956 (MRC GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
4957 c_imm:$CRm, 0, pred:$p)>;
4959 def : ARMPat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
4960 (MRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
4962 class MovRCopro2<string opc, bit direction, dag oops, dag iops,
4964 : ABXI<0b1110, oops, iops, NoItinerary,
4965 !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), pattern> {
4966 let Inst{31-24} = 0b11111110;
4967 let Inst{20} = direction;
4977 let Inst{15-12} = Rt;
4978 let Inst{11-8} = cop;
4979 let Inst{23-21} = opc1;
4980 let Inst{7-5} = opc2;
4981 let Inst{3-0} = CRm;
4982 let Inst{19-16} = CRn;
4985 def MCR2 : MovRCopro2<"mcr2", 0 /* from ARM core register to coprocessor */,
4987 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4988 c_imm:$CRm, imm0_7:$opc2),
4989 [(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
4990 imm:$CRm, imm:$opc2)]>,
4992 def : ARMInstAlias<"mcr2 $cop, $opc1, $Rt, $CRn, $CRm",
4993 (MCR2 p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4995 def MRC2 : MovRCopro2<"mrc2", 1 /* from coprocessor to ARM core register */,
4996 (outs GPRwithAPSR:$Rt),
4997 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
5000 def : ARMInstAlias<"mrc2 $cop, $opc1, $Rt, $CRn, $CRm",
5001 (MRC2 GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
5004 def : ARMV5TPat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn,
5005 imm:$CRm, imm:$opc2),
5006 (MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
5008 class MovRRCopro<string opc, bit direction, list<dag> pattern = []>
5009 : ABI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
5010 GPRnopc:$Rt, GPRnopc:$Rt2, c_imm:$CRm),
5011 NoItinerary, opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm", pattern> {
5012 let Inst{23-21} = 0b010;
5013 let Inst{20} = direction;
5021 let Inst{15-12} = Rt;
5022 let Inst{19-16} = Rt2;
5023 let Inst{11-8} = cop;
5024 let Inst{7-4} = opc1;
5025 let Inst{3-0} = CRm;
5028 def MCRR : MovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */,
5029 [(int_arm_mcrr imm:$cop, imm:$opc1, GPRnopc:$Rt,
5030 GPRnopc:$Rt2, imm:$CRm)]>;
5031 def MRRC : MovRRCopro<"mrrc", 1 /* from coprocessor to ARM core register */>;
5033 class MovRRCopro2<string opc, bit direction, list<dag> pattern = []>
5034 : ABXI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
5035 GPRnopc:$Rt, GPRnopc:$Rt2, c_imm:$CRm), NoItinerary,
5036 !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern>,
5038 let Inst{31-28} = 0b1111;
5039 let Inst{23-21} = 0b010;
5040 let Inst{20} = direction;
5048 let Inst{15-12} = Rt;
5049 let Inst{19-16} = Rt2;
5050 let Inst{11-8} = cop;
5051 let Inst{7-4} = opc1;
5052 let Inst{3-0} = CRm;
5054 let DecoderMethod = "DecodeMRRC2";
5057 def MCRR2 : MovRRCopro2<"mcrr2", 0 /* from ARM core register to coprocessor */,
5058 [(int_arm_mcrr2 imm:$cop, imm:$opc1, GPRnopc:$Rt,
5059 GPRnopc:$Rt2, imm:$CRm)]>;
5060 def MRRC2 : MovRRCopro2<"mrrc2", 1 /* from coprocessor to ARM core register */>;
5062 //===----------------------------------------------------------------------===//
5063 // Move between special register and ARM core register
5066 // Move to ARM core register from Special Register
5067 def MRS : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
5068 "mrs", "\t$Rd, apsr", []> {
5070 let Inst{23-16} = 0b00001111;
5071 let Unpredictable{19-17} = 0b111;
5073 let Inst{15-12} = Rd;
5075 let Inst{11-0} = 0b000000000000;
5076 let Unpredictable{11-0} = 0b110100001111;
5079 def : InstAlias<"mrs${p} $Rd, cpsr", (MRS GPRnopc:$Rd, pred:$p)>,
5082 // The MRSsys instruction is the MRS instruction from the ARM ARM,
5083 // section B9.3.9, with the R bit set to 1.
5084 def MRSsys : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
5085 "mrs", "\t$Rd, spsr", []> {
5087 let Inst{23-16} = 0b01001111;
5088 let Unpredictable{19-16} = 0b1111;
5090 let Inst{15-12} = Rd;
5092 let Inst{11-0} = 0b000000000000;
5093 let Unpredictable{11-0} = 0b110100001111;
5096 // However, the MRS (banked register) system instruction (ARMv7VE) *does* have a
5097 // separate encoding (distinguished by bit 5.
5098 def MRSbanked : ABI<0b0001, (outs GPRnopc:$Rd), (ins banked_reg:$banked),
5099 NoItinerary, "mrs", "\t$Rd, $banked", []>,
5100 Requires<[IsARM, HasVirtualization]> {
5105 let Inst{22} = banked{5}; // R bit
5106 let Inst{21-20} = 0b00;
5107 let Inst{19-16} = banked{3-0};
5108 let Inst{15-12} = Rd;
5109 let Inst{11-9} = 0b001;
5110 let Inst{8} = banked{4};
5111 let Inst{7-0} = 0b00000000;
5114 // Move from ARM core register to Special Register
5116 // No need to have both system and application versions of MSR (immediate) or
5117 // MSR (register), the encodings are the same and the assembly parser has no way
5118 // to distinguish between them. The mask operand contains the special register
5119 // (R Bit) in bit 4 and bits 3-0 contains the mask with the fields to be
5120 // accessed in the special register.
5121 def MSR : ABI<0b0001, (outs), (ins msr_mask:$mask, GPR:$Rn), NoItinerary,
5122 "msr", "\t$mask, $Rn", []> {
5127 let Inst{22} = mask{4}; // R bit
5128 let Inst{21-20} = 0b10;
5129 let Inst{19-16} = mask{3-0};
5130 let Inst{15-12} = 0b1111;
5131 let Inst{11-4} = 0b00000000;
5135 def MSRi : ABI<0b0011, (outs), (ins msr_mask:$mask, mod_imm:$imm), NoItinerary,
5136 "msr", "\t$mask, $imm", []> {
5141 let Inst{22} = mask{4}; // R bit
5142 let Inst{21-20} = 0b10;
5143 let Inst{19-16} = mask{3-0};
5144 let Inst{15-12} = 0b1111;
5145 let Inst{11-0} = imm;
5148 // However, the MSR (banked register) system instruction (ARMv7VE) *does* have a
5149 // separate encoding (distinguished by bit 5.
5150 def MSRbanked : ABI<0b0001, (outs), (ins banked_reg:$banked, GPRnopc:$Rn),
5151 NoItinerary, "msr", "\t$banked, $Rn", []>,
5152 Requires<[IsARM, HasVirtualization]> {
5157 let Inst{22} = banked{5}; // R bit
5158 let Inst{21-20} = 0b10;
5159 let Inst{19-16} = banked{3-0};
5160 let Inst{15-12} = 0b1111;
5161 let Inst{11-9} = 0b001;
5162 let Inst{8} = banked{4};
5163 let Inst{7-4} = 0b0000;
5167 // Dynamic stack allocation yields a _chkstk for Windows targets. These calls
5168 // are needed to probe the stack when allocating more than
5169 // 4k bytes in one go. Touching the stack at 4K increments is necessary to
5170 // ensure that the guard pages used by the OS virtual memory manager are
5171 // allocated in correct sequence.
5172 // The main point of having separate instruction are extra unmodelled effects
5173 // (compared to ordinary calls) like stack pointer change.
5175 def win__chkstk : SDNode<"ARMISD::WIN__CHKSTK", SDTNone,
5176 [SDNPHasChain, SDNPSideEffect]>;
5177 let usesCustomInserter = 1, Uses = [R4], Defs = [R4, SP] in
5178 def WIN__CHKSTK : PseudoInst<(outs), (ins), NoItinerary, [(win__chkstk)]>;
5180 //===----------------------------------------------------------------------===//
5184 // __aeabi_read_tp preserves the registers r1-r3.
5185 // This is a pseudo inst so that we can get the encoding right,
5186 // complete with fixup for the aeabi_read_tp function.
5187 // TPsoft is valid for ARM mode only, in case of Thumb mode a tTPsoft pattern
5188 // is defined in "ARMInstrThumb.td".
5190 Defs = [R0, R12, LR, CPSR], Uses = [SP] in {
5191 def TPsoft : ARMPseudoInst<(outs), (ins), 4, IIC_Br,
5192 [(set R0, ARMthread_pointer)]>, Sched<[WriteBr]>;
5195 //===----------------------------------------------------------------------===//
5196 // SJLJ Exception handling intrinsics
5197 // eh_sjlj_setjmp() is an instruction sequence to store the return
5198 // address and save #0 in R0 for the non-longjmp case.
5199 // Since by its nature we may be coming from some other function to get
5200 // here, and we're using the stack frame for the containing function to
5201 // save/restore registers, we can't keep anything live in regs across
5202 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
5203 // when we get here from a longjmp(). We force everything out of registers
5204 // except for our own input by listing the relevant registers in Defs. By
5205 // doing so, we also cause the prologue/epilogue code to actively preserve
5206 // all of the callee-saved resgisters, which is exactly what we want.
5207 // A constant value is passed in $val, and we use the location as a scratch.
5209 // These are pseudo-instructions and are lowered to individual MC-insts, so
5210 // no encoding information is necessary.
5212 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
5213 Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15 ],
5214 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
5215 def Int_eh_sjlj_setjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
5217 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
5218 Requires<[IsARM, HasVFP2]>;
5222 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
5223 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
5224 def Int_eh_sjlj_setjmp_nofp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
5226 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
5227 Requires<[IsARM, NoVFP]>;
5230 // FIXME: Non-IOS version(s)
5231 let isBarrier = 1, hasSideEffects = 1, isTerminator = 1,
5232 Defs = [ R7, LR, SP ] in {
5233 def Int_eh_sjlj_longjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$scratch),
5235 [(ARMeh_sjlj_longjmp GPR:$src, GPR:$scratch)]>,
5239 // eh.sjlj.dispatchsetup pseudo-instruction.
5240 // This pseudo is used for both ARM and Thumb. Any differences are handled when
5241 // the pseudo is expanded (which happens before any passes that need the
5242 // instruction size).
5243 let isBarrier = 1 in
5244 def Int_eh_sjlj_dispatchsetup : PseudoInst<(outs), (ins), NoItinerary, []>;
5247 //===----------------------------------------------------------------------===//
5248 // Non-Instruction Patterns
5251 // ARMv4 indirect branch using (MOVr PC, dst)
5252 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in
5253 def MOVPCRX : ARMPseudoExpand<(outs), (ins GPR:$dst),
5254 4, IIC_Br, [(brind GPR:$dst)],
5255 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>,
5256 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
5258 // Large immediate handling.
5260 // 32-bit immediate using two piece mod_imms or movw + movt.
5261 // This is a single pseudo instruction, the benefit is that it can be remat'd
5262 // as a single unit instead of having to handle reg inputs.
5263 // FIXME: Remove this when we can do generalized remat.
5264 let isReMaterializable = 1, isMoveImm = 1 in
5265 def MOVi32imm : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
5266 [(set GPR:$dst, (arm_i32imm:$src))]>,
5269 def LDRLIT_ga_abs : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iLoad_i,
5270 [(set GPR:$dst, (ARMWrapper tglobaladdr:$src))]>,
5271 Requires<[IsARM, DontUseMovt]>;
5273 // Pseudo instruction that combines movw + movt + add pc (if PIC).
5274 // It also makes it possible to rematerialize the instructions.
5275 // FIXME: Remove this when we can do generalized remat and when machine licm
5276 // can properly the instructions.
5277 let isReMaterializable = 1 in {
5278 def MOV_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5280 [(set GPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>,
5281 Requires<[IsARM, UseMovt]>;
5283 def LDRLIT_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5286 (ARMWrapperPIC tglobaladdr:$addr))]>,
5287 Requires<[IsARM, DontUseMovt]>;
5289 let AddedComplexity = 10 in
5290 def LDRLIT_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5293 (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
5294 Requires<[IsARM, DontUseMovt]>;
5296 let AddedComplexity = 10 in
5297 def MOV_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5299 [(set GPR:$dst, (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
5300 Requires<[IsARM, UseMovt]>;
5301 } // isReMaterializable
5303 // ConstantPool, GlobalAddress, and JumpTable
5304 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
5305 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
5306 Requires<[IsARM, UseMovt]>;
5307 def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
5308 (LEApcrelJT tjumptable:$dst, imm:$id)>;
5310 // TODO: add,sub,and, 3-instr forms?
5312 // Tail calls. These patterns also apply to Thumb mode.
5313 def : Pat<(ARMtcret tcGPR:$dst), (TCRETURNri tcGPR:$dst)>;
5314 def : Pat<(ARMtcret (i32 tglobaladdr:$dst)), (TCRETURNdi texternalsym:$dst)>;
5315 def : Pat<(ARMtcret (i32 texternalsym:$dst)), (TCRETURNdi texternalsym:$dst)>;
5318 def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>;
5319 def : ARMPat<(ARMcall_nolink texternalsym:$func),
5320 (BMOVPCB_CALL texternalsym:$func)>;
5322 // zextload i1 -> zextload i8
5323 def : ARMPat<(zextloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5324 def : ARMPat<(zextloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5326 // extload -> zextload
5327 def : ARMPat<(extloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5328 def : ARMPat<(extloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5329 def : ARMPat<(extloadi8 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5330 def : ARMPat<(extloadi8 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5332 def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
5334 def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
5335 def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
5338 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
5339 (sra (shl GPR:$b, (i32 16)), (i32 16))),
5340 (SMULBB GPR:$a, GPR:$b)>;
5341 def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
5342 (SMULBB GPR:$a, GPR:$b)>;
5343 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
5344 (sra GPR:$b, (i32 16))),
5345 (SMULBT GPR:$a, GPR:$b)>;
5346 def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, (i32 16))),
5347 (SMULBT GPR:$a, GPR:$b)>;
5348 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)),
5349 (sra (shl GPR:$b, (i32 16)), (i32 16))),
5350 (SMULTB GPR:$a, GPR:$b)>;
5351 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), sext_16_node:$b),
5352 (SMULTB GPR:$a, GPR:$b)>;
5354 def : ARMV5MOPat<(add GPR:$acc,
5355 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
5356 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
5357 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5358 def : ARMV5MOPat<(add GPR:$acc,
5359 (mul sext_16_node:$a, sext_16_node:$b)),
5360 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5361 def : ARMV5MOPat<(add GPR:$acc,
5362 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
5363 (sra GPR:$b, (i32 16)))),
5364 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
5365 def : ARMV5MOPat<(add GPR:$acc,
5366 (mul sext_16_node:$a, (sra GPR:$b, (i32 16)))),
5367 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
5368 def : ARMV5MOPat<(add GPR:$acc,
5369 (mul (sra GPR:$a, (i32 16)),
5370 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
5371 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
5372 def : ARMV5MOPat<(add GPR:$acc,
5373 (mul (sra GPR:$a, (i32 16)), sext_16_node:$b)),
5374 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
5377 // Pre-v7 uses MCR for synchronization barriers.
5378 def : ARMPat<(ARMMemBarrierMCR GPR:$zero), (MCR 15, 0, GPR:$zero, 7, 10, 5)>,
5379 Requires<[IsARM, HasV6]>;
5381 // SXT/UXT with no rotate
5382 let AddedComplexity = 16 in {
5383 def : ARMV6Pat<(and GPR:$Src, 0x000000FF), (UXTB GPR:$Src, 0)>;
5384 def : ARMV6Pat<(and GPR:$Src, 0x0000FFFF), (UXTH GPR:$Src, 0)>;
5385 def : ARMV6Pat<(and GPR:$Src, 0x00FF00FF), (UXTB16 GPR:$Src, 0)>;
5386 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0x00FF)),
5387 (UXTAB GPR:$Rn, GPR:$Rm, 0)>;
5388 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0xFFFF)),
5389 (UXTAH GPR:$Rn, GPR:$Rm, 0)>;
5392 def : ARMV6Pat<(sext_inreg GPR:$Src, i8), (SXTB GPR:$Src, 0)>;
5393 def : ARMV6Pat<(sext_inreg GPR:$Src, i16), (SXTH GPR:$Src, 0)>;
5395 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i8)),
5396 (SXTAB GPR:$Rn, GPRnopc:$Rm, 0)>;
5397 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i16)),
5398 (SXTAH GPR:$Rn, GPRnopc:$Rm, 0)>;
5400 // Atomic load/store patterns
5401 def : ARMPat<(atomic_load_8 ldst_so_reg:$src),
5402 (LDRBrs ldst_so_reg:$src)>;
5403 def : ARMPat<(atomic_load_8 addrmode_imm12:$src),
5404 (LDRBi12 addrmode_imm12:$src)>;
5405 def : ARMPat<(atomic_load_16 addrmode3:$src),
5406 (LDRH addrmode3:$src)>;
5407 def : ARMPat<(atomic_load_32 ldst_so_reg:$src),
5408 (LDRrs ldst_so_reg:$src)>;
5409 def : ARMPat<(atomic_load_32 addrmode_imm12:$src),
5410 (LDRi12 addrmode_imm12:$src)>;
5411 def : ARMPat<(atomic_store_8 ldst_so_reg:$ptr, GPR:$val),
5412 (STRBrs GPR:$val, ldst_so_reg:$ptr)>;
5413 def : ARMPat<(atomic_store_8 addrmode_imm12:$ptr, GPR:$val),
5414 (STRBi12 GPR:$val, addrmode_imm12:$ptr)>;
5415 def : ARMPat<(atomic_store_16 addrmode3:$ptr, GPR:$val),
5416 (STRH GPR:$val, addrmode3:$ptr)>;
5417 def : ARMPat<(atomic_store_32 ldst_so_reg:$ptr, GPR:$val),
5418 (STRrs GPR:$val, ldst_so_reg:$ptr)>;
5419 def : ARMPat<(atomic_store_32 addrmode_imm12:$ptr, GPR:$val),
5420 (STRi12 GPR:$val, addrmode_imm12:$ptr)>;
5423 //===----------------------------------------------------------------------===//
5427 include "ARMInstrThumb.td"
5429 //===----------------------------------------------------------------------===//
5433 include "ARMInstrThumb2.td"
5435 //===----------------------------------------------------------------------===//
5436 // Floating Point Support
5439 include "ARMInstrVFP.td"
5441 //===----------------------------------------------------------------------===//
5442 // Advanced SIMD (NEON) Support
5445 include "ARMInstrNEON.td"
5447 //===----------------------------------------------------------------------===//
5448 // Assembler aliases
5452 def : InstAlias<"dmb", (DMB 0xf)>, Requires<[IsARM, HasDB]>;
5453 def : InstAlias<"dsb", (DSB 0xf)>, Requires<[IsARM, HasDB]>;
5454 def : InstAlias<"isb", (ISB 0xf)>, Requires<[IsARM, HasDB]>;
5456 // System instructions
5457 def : MnemonicAlias<"swi", "svc">;
5459 // Load / Store Multiple
5460 def : MnemonicAlias<"ldmfd", "ldm">;
5461 def : MnemonicAlias<"ldmia", "ldm">;
5462 def : MnemonicAlias<"ldmea", "ldmdb">;
5463 def : MnemonicAlias<"stmfd", "stmdb">;
5464 def : MnemonicAlias<"stmia", "stm">;
5465 def : MnemonicAlias<"stmea", "stm">;
5467 // PKHBT/PKHTB with default shift amount. PKHTB is equivalent to PKHBT when the
5468 // shift amount is zero (i.e., unspecified).
5469 def : InstAlias<"pkhbt${p} $Rd, $Rn, $Rm",
5470 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
5471 Requires<[IsARM, HasV6]>;
5472 def : InstAlias<"pkhtb${p} $Rd, $Rn, $Rm",
5473 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
5474 Requires<[IsARM, HasV6]>;
5476 // PUSH/POP aliases for STM/LDM
5477 def : ARMInstAlias<"push${p} $regs", (STMDB_UPD SP, pred:$p, reglist:$regs)>;
5478 def : ARMInstAlias<"pop${p} $regs", (LDMIA_UPD SP, pred:$p, reglist:$regs)>;
5480 // SSAT/USAT optional shift operand.
5481 def : ARMInstAlias<"ssat${p} $Rd, $sat_imm, $Rn",
5482 (SSAT GPRnopc:$Rd, imm1_32:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5483 def : ARMInstAlias<"usat${p} $Rd, $sat_imm, $Rn",
5484 (USAT GPRnopc:$Rd, imm0_31:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5487 // Extend instruction optional rotate operand.
5488 def : ARMInstAlias<"sxtab${p} $Rd, $Rn, $Rm",
5489 (SXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5490 def : ARMInstAlias<"sxtah${p} $Rd, $Rn, $Rm",
5491 (SXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5492 def : ARMInstAlias<"sxtab16${p} $Rd, $Rn, $Rm",
5493 (SXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5494 def : ARMInstAlias<"sxtb${p} $Rd, $Rm",
5495 (SXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5496 def : ARMInstAlias<"sxtb16${p} $Rd, $Rm",
5497 (SXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5498 def : ARMInstAlias<"sxth${p} $Rd, $Rm",
5499 (SXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5501 def : ARMInstAlias<"uxtab${p} $Rd, $Rn, $Rm",
5502 (UXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5503 def : ARMInstAlias<"uxtah${p} $Rd, $Rn, $Rm",
5504 (UXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5505 def : ARMInstAlias<"uxtab16${p} $Rd, $Rn, $Rm",
5506 (UXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5507 def : ARMInstAlias<"uxtb${p} $Rd, $Rm",
5508 (UXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5509 def : ARMInstAlias<"uxtb16${p} $Rd, $Rm",
5510 (UXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5511 def : ARMInstAlias<"uxth${p} $Rd, $Rm",
5512 (UXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5516 def : MnemonicAlias<"rfefa", "rfeda">;
5517 def : MnemonicAlias<"rfeea", "rfedb">;
5518 def : MnemonicAlias<"rfefd", "rfeia">;
5519 def : MnemonicAlias<"rfeed", "rfeib">;
5520 def : MnemonicAlias<"rfe", "rfeia">;
5523 def : MnemonicAlias<"srsfa", "srsib">;
5524 def : MnemonicAlias<"srsea", "srsia">;
5525 def : MnemonicAlias<"srsfd", "srsdb">;
5526 def : MnemonicAlias<"srsed", "srsda">;
5527 def : MnemonicAlias<"srs", "srsia">;
5530 def : MnemonicAlias<"qsubaddx", "qsax">;
5532 def : MnemonicAlias<"saddsubx", "sasx">;
5533 // SHASX == SHADDSUBX
5534 def : MnemonicAlias<"shaddsubx", "shasx">;
5535 // SHSAX == SHSUBADDX
5536 def : MnemonicAlias<"shsubaddx", "shsax">;
5538 def : MnemonicAlias<"ssubaddx", "ssax">;
5540 def : MnemonicAlias<"uaddsubx", "uasx">;
5541 // UHASX == UHADDSUBX
5542 def : MnemonicAlias<"uhaddsubx", "uhasx">;
5543 // UHSAX == UHSUBADDX
5544 def : MnemonicAlias<"uhsubaddx", "uhsax">;
5545 // UQASX == UQADDSUBX
5546 def : MnemonicAlias<"uqaddsubx", "uqasx">;
5547 // UQSAX == UQSUBADDX
5548 def : MnemonicAlias<"uqsubaddx", "uqsax">;
5550 def : MnemonicAlias<"usubaddx", "usax">;
5552 // "mov Rd, mod_imm_not" can be handled via "mvn" in assembly, just like
5554 def : ARMInstAlias<"mov${s}${p} $Rd, $imm",
5555 (MVNi rGPR:$Rd, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
5556 def : ARMInstAlias<"mvn${s}${p} $Rd, $imm",
5557 (MOVi rGPR:$Rd, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
5558 // Same for AND <--> BIC
5559 def : ARMInstAlias<"bic${s}${p} $Rd, $Rn, $imm",
5560 (ANDri rGPR:$Rd, rGPR:$Rn, mod_imm_not:$imm,
5561 pred:$p, cc_out:$s)>;
5562 def : ARMInstAlias<"bic${s}${p} $Rdn, $imm",
5563 (ANDri rGPR:$Rdn, rGPR:$Rdn, mod_imm_not:$imm,
5564 pred:$p, cc_out:$s)>;
5565 def : ARMInstAlias<"and${s}${p} $Rd, $Rn, $imm",
5566 (BICri rGPR:$Rd, rGPR:$Rn, mod_imm_not:$imm,
5567 pred:$p, cc_out:$s)>;
5568 def : ARMInstAlias<"and${s}${p} $Rdn, $imm",
5569 (BICri rGPR:$Rdn, rGPR:$Rdn, mod_imm_not:$imm,
5570 pred:$p, cc_out:$s)>;
5572 // Likewise, "add Rd, mod_imm_neg" -> sub
5573 def : ARMInstAlias<"add${s}${p} $Rd, $Rn, $imm",
5574 (SUBri GPR:$Rd, GPR:$Rn, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
5575 def : ARMInstAlias<"add${s}${p} $Rd, $imm",
5576 (SUBri GPR:$Rd, GPR:$Rd, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
5577 // Same for CMP <--> CMN via mod_imm_neg
5578 def : ARMInstAlias<"cmp${p} $Rd, $imm",
5579 (CMNri rGPR:$Rd, mod_imm_neg:$imm, pred:$p)>;
5580 def : ARMInstAlias<"cmn${p} $Rd, $imm",
5581 (CMPri rGPR:$Rd, mod_imm_neg:$imm, pred:$p)>;
5583 // The shifter forms of the MOV instruction are aliased to the ASR, LSL,
5584 // LSR, ROR, and RRX instructions.
5585 // FIXME: We need C++ parser hooks to map the alias to the MOV
5586 // encoding. It seems we should be able to do that sort of thing
5587 // in tblgen, but it could get ugly.
5588 let TwoOperandAliasConstraint = "$Rm = $Rd" in {
5589 def ASRi : ARMAsmPseudo<"asr${s}${p} $Rd, $Rm, $imm",
5590 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
5592 def LSRi : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rm, $imm",
5593 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
5595 def LSLi : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rm, $imm",
5596 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
5598 def RORi : ARMAsmPseudo<"ror${s}${p} $Rd, $Rm, $imm",
5599 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
5602 def RRXi : ARMAsmPseudo<"rrx${s}${p} $Rd, $Rm",
5603 (ins GPR:$Rd, GPR:$Rm, pred:$p, cc_out:$s)>;
5604 let TwoOperandAliasConstraint = "$Rn = $Rd" in {
5605 def ASRr : ARMAsmPseudo<"asr${s}${p} $Rd, $Rn, $Rm",
5606 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5608 def LSRr : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rn, $Rm",
5609 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5611 def LSLr : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rn, $Rm",
5612 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5614 def RORr : ARMAsmPseudo<"ror${s}${p} $Rd, $Rn, $Rm",
5615 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5619 // "neg" is and alias for "rsb rd, rn, #0"
5620 def : ARMInstAlias<"neg${s}${p} $Rd, $Rm",
5621 (RSBri GPR:$Rd, GPR:$Rm, 0, pred:$p, cc_out:$s)>;
5623 // Pre-v6, 'mov r0, r0' was used as a NOP encoding.
5624 def : InstAlias<"nop${p}", (MOVr R0, R0, pred:$p, zero_reg)>,
5625 Requires<[IsARM, NoV6]>;
5627 // MUL/UMLAL/SMLAL/UMULL/SMULL are available on all arches, but
5628 // the instruction definitions need difference constraints pre-v6.
5629 // Use these aliases for the assembly parsing on pre-v6.
5630 def : InstAlias<"mul${s}${p} $Rd, $Rn, $Rm",
5631 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s)>,
5632 Requires<[IsARM, NoV6]>;
5633 def : InstAlias<"mla${s}${p} $Rd, $Rn, $Rm, $Ra",
5634 (MLA GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra,
5635 pred:$p, cc_out:$s)>,
5636 Requires<[IsARM, NoV6]>;
5637 def : InstAlias<"smlal${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5638 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5639 Requires<[IsARM, NoV6]>;
5640 def : InstAlias<"umlal${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5641 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5642 Requires<[IsARM, NoV6]>;
5643 def : InstAlias<"smull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5644 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5645 Requires<[IsARM, NoV6]>;
5646 def : InstAlias<"umull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5647 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5648 Requires<[IsARM, NoV6]>;
5650 // 'it' blocks in ARM mode just validate the predicates. The IT itself
5652 def ITasm : ARMAsmPseudo<"it$mask $cc", (ins it_pred:$cc, it_mask:$mask)>,
5653 ComplexDeprecationPredicate<"IT">;
5655 let mayLoad = 1, mayStore =1, hasSideEffects = 1 in
5656 def SPACE : PseudoInst<(outs GPR:$Rd), (ins i32imm:$size, GPR:$Rn),
5658 [(set GPR:$Rd, (int_arm_space imm:$size, GPR:$Rn))]>;