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 HasV7 : Predicate<"Subtarget->hasV7Ops()">,
203 AssemblerPredicate<"HasV7Ops", "armv7">;
204 def HasV8 : Predicate<"Subtarget->hasV8Ops()">,
205 AssemblerPredicate<"HasV8Ops", "armv8">;
206 def PreV8 : Predicate<"!Subtarget->hasV8Ops()">,
207 AssemblerPredicate<"!HasV8Ops", "armv7 or earlier">;
208 def NoVFP : Predicate<"!Subtarget->hasVFP2()">;
209 def HasVFP2 : Predicate<"Subtarget->hasVFP2()">,
210 AssemblerPredicate<"FeatureVFP2", "VFP2">;
211 def HasVFP3 : Predicate<"Subtarget->hasVFP3()">,
212 AssemblerPredicate<"FeatureVFP3", "VFP3">;
213 def HasVFP4 : Predicate<"Subtarget->hasVFP4()">,
214 AssemblerPredicate<"FeatureVFP4", "VFP4">;
215 def HasDPVFP : Predicate<"!Subtarget->isFPOnlySP()">,
216 AssemblerPredicate<"!FeatureVFPOnlySP",
217 "double precision VFP">;
218 def HasFPARMv8 : Predicate<"Subtarget->hasFPARMv8()">,
219 AssemblerPredicate<"FeatureFPARMv8", "FPARMv8">;
220 def HasNEON : Predicate<"Subtarget->hasNEON()">,
221 AssemblerPredicate<"FeatureNEON", "NEON">;
222 def HasCrypto : Predicate<"Subtarget->hasCrypto()">,
223 AssemblerPredicate<"FeatureCrypto", "crypto">;
224 def HasCRC : Predicate<"Subtarget->hasCRC()">,
225 AssemblerPredicate<"FeatureCRC", "crc">;
226 def HasFP16 : Predicate<"Subtarget->hasFP16()">,
227 AssemblerPredicate<"FeatureFP16","half-float">;
228 def HasDivide : Predicate<"Subtarget->hasDivide()">,
229 AssemblerPredicate<"FeatureHWDiv", "divide in THUMB">;
230 def HasDivideInARM : Predicate<"Subtarget->hasDivideInARMMode()">,
231 AssemblerPredicate<"FeatureHWDivARM", "divide in ARM">;
232 def HasT2ExtractPack : Predicate<"Subtarget->hasT2ExtractPack()">,
233 AssemblerPredicate<"FeatureT2XtPk",
235 def HasThumb2DSP : Predicate<"Subtarget->hasThumb2DSP()">,
236 AssemblerPredicate<"FeatureDSPThumb2",
238 def HasDB : Predicate<"Subtarget->hasDataBarrier()">,
239 AssemblerPredicate<"FeatureDB",
241 def HasMP : Predicate<"Subtarget->hasMPExtension()">,
242 AssemblerPredicate<"FeatureMP",
244 def HasVirtualization: Predicate<"false">,
245 AssemblerPredicate<"FeatureVirtualization",
246 "virtualization-extensions">;
247 def HasTrustZone : Predicate<"Subtarget->hasTrustZone()">,
248 AssemblerPredicate<"FeatureTrustZone",
250 def HasZCZ : Predicate<"Subtarget->hasZeroCycleZeroing()">;
251 def UseNEONForFP : Predicate<"Subtarget->useNEONForSinglePrecisionFP()">;
252 def DontUseNEONForFP : Predicate<"!Subtarget->useNEONForSinglePrecisionFP()">;
253 def IsThumb : Predicate<"Subtarget->isThumb()">,
254 AssemblerPredicate<"ModeThumb", "thumb">;
255 def IsThumb1Only : Predicate<"Subtarget->isThumb1Only()">;
256 def IsThumb2 : Predicate<"Subtarget->isThumb2()">,
257 AssemblerPredicate<"ModeThumb,FeatureThumb2",
259 def IsMClass : Predicate<"Subtarget->isMClass()">,
260 AssemblerPredicate<"FeatureMClass", "armv*m">;
261 def IsNotMClass : Predicate<"!Subtarget->isMClass()">,
262 AssemblerPredicate<"!FeatureMClass",
264 def IsARM : Predicate<"!Subtarget->isThumb()">,
265 AssemblerPredicate<"!ModeThumb", "arm-mode">;
266 def IsIOS : Predicate<"Subtarget->isTargetIOS()">;
267 def IsNotIOS : Predicate<"!Subtarget->isTargetIOS()">;
268 def IsMachO : Predicate<"Subtarget->isTargetMachO()">;
269 def IsNotMachO : Predicate<"!Subtarget->isTargetMachO()">;
270 def IsNaCl : Predicate<"Subtarget->isTargetNaCl()">;
271 def UseNaClTrap : Predicate<"Subtarget->useNaClTrap()">,
272 AssemblerPredicate<"FeatureNaClTrap", "NaCl">;
273 def DontUseNaClTrap : Predicate<"!Subtarget->useNaClTrap()">;
275 // FIXME: Eventually this will be just "hasV6T2Ops".
276 def UseMovt : Predicate<"Subtarget->useMovt(*MF)">;
277 def DontUseMovt : Predicate<"!Subtarget->useMovt(*MF)">;
278 def UseFPVMLx : Predicate<"Subtarget->useFPVMLx()">;
279 def UseMulOps : Predicate<"Subtarget->useMulOps()">;
281 // Prefer fused MAC for fp mul + add over fp VMLA / VMLS if they are available.
282 // But only select them if more precision in FP computation is allowed.
283 // Do not use them for Darwin platforms.
284 def UseFusedMAC : Predicate<"(TM.Options.AllowFPOpFusion =="
285 " FPOpFusion::Fast && "
286 " Subtarget->hasVFP4()) && "
287 "!Subtarget->isTargetDarwin()">;
288 def DontUseFusedMAC : Predicate<"!(TM.Options.AllowFPOpFusion =="
289 " FPOpFusion::Fast &&"
290 " Subtarget->hasVFP4()) || "
291 "Subtarget->isTargetDarwin()">;
293 // VGETLNi32 is microcoded on Swift - prefer VMOV.
294 def HasFastVGETLNi32 : Predicate<"!Subtarget->isSwift()">;
295 def HasSlowVGETLNi32 : Predicate<"Subtarget->isSwift()">;
297 // VDUP.32 is microcoded on Swift - prefer VMOV.
298 def HasFastVDUP32 : Predicate<"!Subtarget->isSwift()">;
299 def HasSlowVDUP32 : Predicate<"Subtarget->isSwift()">;
301 // Cortex-A9 prefers VMOVSR to VMOVDRR even when using NEON for scalar FP, as
302 // this allows more effective execution domain optimization. See
303 // setExecutionDomain().
304 def UseVMOVSR : Predicate<"Subtarget->isCortexA9() || !Subtarget->useNEONForSinglePrecisionFP()">;
305 def DontUseVMOVSR : Predicate<"!Subtarget->isCortexA9() && Subtarget->useNEONForSinglePrecisionFP()">;
307 def IsLE : Predicate<"getTargetLowering()->isLittleEndian()">;
308 def IsBE : Predicate<"getTargetLowering()->isBigEndian()">;
310 //===----------------------------------------------------------------------===//
311 // ARM Flag Definitions.
313 class RegConstraint<string C> {
314 string Constraints = C;
317 //===----------------------------------------------------------------------===//
318 // ARM specific transformation functions and pattern fragments.
321 // imm_neg_XFORM - Return the negation of an i32 immediate value.
322 def imm_neg_XFORM : SDNodeXForm<imm, [{
323 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), MVT::i32);
326 // imm_not_XFORM - Return the complement of a i32 immediate value.
327 def imm_not_XFORM : SDNodeXForm<imm, [{
328 return CurDAG->getTargetConstant(~(int)N->getZExtValue(), MVT::i32);
331 /// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
332 def imm16_31 : ImmLeaf<i32, [{
333 return (int32_t)Imm >= 16 && (int32_t)Imm < 32;
336 def so_imm_neg_asmoperand : AsmOperandClass { let Name = "ARMSOImmNeg"; }
337 def so_imm_neg : Operand<i32>, PatLeaf<(imm), [{
338 unsigned Value = -(unsigned)N->getZExtValue();
339 return Value && ARM_AM::getSOImmVal(Value) != -1;
341 let ParserMatchClass = so_imm_neg_asmoperand;
344 // Note: this pattern doesn't require an encoder method and such, as it's
345 // only used on aliases (Pat<> and InstAlias<>). The actual encoding
346 // is handled by the destination instructions, which use so_imm.
347 def so_imm_not_asmoperand : AsmOperandClass { let Name = "ARMSOImmNot"; }
348 def so_imm_not : Operand<i32>, PatLeaf<(imm), [{
349 return ARM_AM::getSOImmVal(~(uint32_t)N->getZExtValue()) != -1;
351 let ParserMatchClass = so_imm_not_asmoperand;
354 // sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
355 def sext_16_node : PatLeaf<(i32 GPR:$a), [{
356 return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17;
359 /// Split a 32-bit immediate into two 16 bit parts.
360 def hi16 : SDNodeXForm<imm, [{
361 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, MVT::i32);
364 def lo16AllZero : PatLeaf<(i32 imm), [{
365 // Returns true if all low 16-bits are 0.
366 return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
369 class BinOpWithFlagFrag<dag res> :
370 PatFrag<(ops node:$LHS, node:$RHS, node:$FLAG), res>;
371 class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
372 class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
374 // An 'and' node with a single use.
375 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
376 return N->hasOneUse();
379 // An 'xor' node with a single use.
380 def xor_su : PatFrag<(ops node:$lhs, node:$rhs), (xor node:$lhs, node:$rhs), [{
381 return N->hasOneUse();
384 // An 'fmul' node with a single use.
385 def fmul_su : PatFrag<(ops node:$lhs, node:$rhs), (fmul node:$lhs, node:$rhs),[{
386 return N->hasOneUse();
389 // An 'fadd' node which checks for single non-hazardous use.
390 def fadd_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fadd node:$lhs, node:$rhs),[{
391 return hasNoVMLxHazardUse(N);
394 // An 'fsub' node which checks for single non-hazardous use.
395 def fsub_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fsub node:$lhs, node:$rhs),[{
396 return hasNoVMLxHazardUse(N);
399 //===----------------------------------------------------------------------===//
400 // Operand Definitions.
403 // Immediate operands with a shared generic asm render method.
404 class ImmAsmOperand : AsmOperandClass { let RenderMethod = "addImmOperands"; }
407 // FIXME: rename brtarget to t2_brtarget
408 def brtarget : Operand<OtherVT> {
409 let EncoderMethod = "getBranchTargetOpValue";
410 let OperandType = "OPERAND_PCREL";
411 let DecoderMethod = "DecodeT2BROperand";
414 // FIXME: get rid of this one?
415 def uncondbrtarget : Operand<OtherVT> {
416 let EncoderMethod = "getUnconditionalBranchTargetOpValue";
417 let OperandType = "OPERAND_PCREL";
420 // Branch target for ARM. Handles conditional/unconditional
421 def br_target : Operand<OtherVT> {
422 let EncoderMethod = "getARMBranchTargetOpValue";
423 let OperandType = "OPERAND_PCREL";
427 // FIXME: rename bltarget to t2_bl_target?
428 def bltarget : Operand<i32> {
429 // Encoded the same as branch targets.
430 let EncoderMethod = "getBranchTargetOpValue";
431 let OperandType = "OPERAND_PCREL";
434 // Call target for ARM. Handles conditional/unconditional
435 // FIXME: rename bl_target to t2_bltarget?
436 def bl_target : Operand<i32> {
437 let EncoderMethod = "getARMBLTargetOpValue";
438 let OperandType = "OPERAND_PCREL";
441 def blx_target : Operand<i32> {
442 let EncoderMethod = "getARMBLXTargetOpValue";
443 let OperandType = "OPERAND_PCREL";
446 // A list of registers separated by comma. Used by load/store multiple.
447 def RegListAsmOperand : AsmOperandClass { let Name = "RegList"; }
448 def reglist : Operand<i32> {
449 let EncoderMethod = "getRegisterListOpValue";
450 let ParserMatchClass = RegListAsmOperand;
451 let PrintMethod = "printRegisterList";
452 let DecoderMethod = "DecodeRegListOperand";
455 def GPRPairOp : RegisterOperand<GPRPair, "printGPRPairOperand">;
457 def DPRRegListAsmOperand : AsmOperandClass { let Name = "DPRRegList"; }
458 def dpr_reglist : Operand<i32> {
459 let EncoderMethod = "getRegisterListOpValue";
460 let ParserMatchClass = DPRRegListAsmOperand;
461 let PrintMethod = "printRegisterList";
462 let DecoderMethod = "DecodeDPRRegListOperand";
465 def SPRRegListAsmOperand : AsmOperandClass { let Name = "SPRRegList"; }
466 def spr_reglist : Operand<i32> {
467 let EncoderMethod = "getRegisterListOpValue";
468 let ParserMatchClass = SPRRegListAsmOperand;
469 let PrintMethod = "printRegisterList";
470 let DecoderMethod = "DecodeSPRRegListOperand";
473 // An operand for the CONSTPOOL_ENTRY pseudo-instruction.
474 def cpinst_operand : Operand<i32> {
475 let PrintMethod = "printCPInstOperand";
479 def pclabel : Operand<i32> {
480 let PrintMethod = "printPCLabel";
483 // ADR instruction labels.
484 def AdrLabelAsmOperand : AsmOperandClass { let Name = "AdrLabel"; }
485 def adrlabel : Operand<i32> {
486 let EncoderMethod = "getAdrLabelOpValue";
487 let ParserMatchClass = AdrLabelAsmOperand;
488 let PrintMethod = "printAdrLabelOperand<0>";
491 def neon_vcvt_imm32 : Operand<i32> {
492 let EncoderMethod = "getNEONVcvtImm32OpValue";
493 let DecoderMethod = "DecodeVCVTImmOperand";
496 // rot_imm: An integer that encodes a rotate amount. Must be 8, 16, or 24.
497 def rot_imm_XFORM: SDNodeXForm<imm, [{
498 switch (N->getZExtValue()){
499 default: llvm_unreachable(nullptr);
500 case 0: return CurDAG->getTargetConstant(0, MVT::i32);
501 case 8: return CurDAG->getTargetConstant(1, MVT::i32);
502 case 16: return CurDAG->getTargetConstant(2, MVT::i32);
503 case 24: return CurDAG->getTargetConstant(3, MVT::i32);
506 def RotImmAsmOperand : AsmOperandClass {
508 let ParserMethod = "parseRotImm";
510 def rot_imm : Operand<i32>, PatLeaf<(i32 imm), [{
511 int32_t v = N->getZExtValue();
512 return v == 8 || v == 16 || v == 24; }],
514 let PrintMethod = "printRotImmOperand";
515 let ParserMatchClass = RotImmAsmOperand;
518 // shift_imm: An integer that encodes a shift amount and the type of shift
519 // (asr or lsl). The 6-bit immediate encodes as:
522 // {4-0} imm5 shift amount.
523 // asr #32 encoded as imm5 == 0.
524 def ShifterImmAsmOperand : AsmOperandClass {
525 let Name = "ShifterImm";
526 let ParserMethod = "parseShifterImm";
528 def shift_imm : Operand<i32> {
529 let PrintMethod = "printShiftImmOperand";
530 let ParserMatchClass = ShifterImmAsmOperand;
533 // shifter_operand operands: so_reg_reg, so_reg_imm, and so_imm.
534 def ShiftedRegAsmOperand : AsmOperandClass { let Name = "RegShiftedReg"; }
535 def so_reg_reg : Operand<i32>, // reg reg imm
536 ComplexPattern<i32, 3, "SelectRegShifterOperand",
537 [shl, srl, sra, rotr]> {
538 let EncoderMethod = "getSORegRegOpValue";
539 let PrintMethod = "printSORegRegOperand";
540 let DecoderMethod = "DecodeSORegRegOperand";
541 let ParserMatchClass = ShiftedRegAsmOperand;
542 let MIOperandInfo = (ops GPRnopc, GPRnopc, i32imm);
545 def ShiftedImmAsmOperand : AsmOperandClass { let Name = "RegShiftedImm"; }
546 def so_reg_imm : Operand<i32>, // reg imm
547 ComplexPattern<i32, 2, "SelectImmShifterOperand",
548 [shl, srl, sra, rotr]> {
549 let EncoderMethod = "getSORegImmOpValue";
550 let PrintMethod = "printSORegImmOperand";
551 let DecoderMethod = "DecodeSORegImmOperand";
552 let ParserMatchClass = ShiftedImmAsmOperand;
553 let MIOperandInfo = (ops GPR, i32imm);
556 // FIXME: Does this need to be distinct from so_reg?
557 def shift_so_reg_reg : Operand<i32>, // reg reg imm
558 ComplexPattern<i32, 3, "SelectShiftRegShifterOperand",
559 [shl,srl,sra,rotr]> {
560 let EncoderMethod = "getSORegRegOpValue";
561 let PrintMethod = "printSORegRegOperand";
562 let DecoderMethod = "DecodeSORegRegOperand";
563 let ParserMatchClass = ShiftedRegAsmOperand;
564 let MIOperandInfo = (ops GPR, GPR, i32imm);
567 // FIXME: Does this need to be distinct from so_reg?
568 def shift_so_reg_imm : Operand<i32>, // reg reg imm
569 ComplexPattern<i32, 2, "SelectShiftImmShifterOperand",
570 [shl,srl,sra,rotr]> {
571 let EncoderMethod = "getSORegImmOpValue";
572 let PrintMethod = "printSORegImmOperand";
573 let DecoderMethod = "DecodeSORegImmOperand";
574 let ParserMatchClass = ShiftedImmAsmOperand;
575 let MIOperandInfo = (ops GPR, i32imm);
579 // so_imm - Match a 32-bit shifter_operand immediate operand, which is an
580 // 8-bit immediate rotated by an arbitrary number of bits.
581 def SOImmAsmOperand: ImmAsmOperand { let Name = "ARMSOImm"; }
582 def so_imm : Operand<i32>, ImmLeaf<i32, [{
583 return ARM_AM::getSOImmVal(Imm) != -1;
585 let EncoderMethod = "getSOImmOpValue";
586 let ParserMatchClass = SOImmAsmOperand;
587 let DecoderMethod = "DecodeSOImmOperand";
590 // mod_imm: match a 32-bit immediate operand, which is encoded as a 12-bit
591 // immediate (See ARMARM - "Modified Immediate Constants"). Unlike so_imm,
592 // mod_imm keeps the immediate in its encoded form (within the MC layer).
593 def ModImmAsmOperand: AsmOperandClass {
595 let ParserMethod = "parseModImm";
597 def mod_imm : Operand<i32>, ImmLeaf<i32, [{
598 return ARM_AM::getSOImmVal(Imm) != -1;
600 let EncoderMethod = "getModImmOpValue";
601 let PrintMethod = "printModImmOperand";
602 let ParserMatchClass = ModImmAsmOperand;
605 // similar to so_imm_not, but keeps the immediate in its encoded form
606 def ModImmNotAsmOperand : AsmOperandClass { let Name = "ModImmNot"; }
607 def mod_imm_not : Operand<i32>, PatLeaf<(imm), [{
608 return ARM_AM::getSOImmVal(~(uint32_t)N->getZExtValue()) != -1;
610 let ParserMatchClass = ModImmNotAsmOperand;
613 // similar to so_imm_neg, but keeps the immediate in its encoded form
614 def ModImmNegAsmOperand : AsmOperandClass { let Name = "ModImmNeg"; }
615 def mod_imm_neg : Operand<i32>, PatLeaf<(imm), [{
616 unsigned Value = -(unsigned)N->getZExtValue();
617 return Value && ARM_AM::getSOImmVal(Value) != -1;
619 let ParserMatchClass = ModImmNegAsmOperand;
622 // Break so_imm's up into two pieces. This handles immediates with up to 16
623 // bits set in them. This uses so_imm2part to match and so_imm2part_[12] to
624 // get the first/second pieces.
625 def so_imm2part : PatLeaf<(imm), [{
626 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
629 /// arm_i32imm - True for +V6T2, or true only if so_imm2part is true.
631 def arm_i32imm : PatLeaf<(imm), [{
632 if (Subtarget->useMovt(*MF))
634 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
637 /// imm0_1 predicate - Immediate in the range [0,1].
638 def Imm0_1AsmOperand: ImmAsmOperand { let Name = "Imm0_1"; }
639 def imm0_1 : Operand<i32> { let ParserMatchClass = Imm0_1AsmOperand; }
641 /// imm0_3 predicate - Immediate in the range [0,3].
642 def Imm0_3AsmOperand: ImmAsmOperand { let Name = "Imm0_3"; }
643 def imm0_3 : Operand<i32> { let ParserMatchClass = Imm0_3AsmOperand; }
645 /// imm0_7 predicate - Immediate in the range [0,7].
646 def Imm0_7AsmOperand: ImmAsmOperand { let Name = "Imm0_7"; }
647 def imm0_7 : Operand<i32>, ImmLeaf<i32, [{
648 return Imm >= 0 && Imm < 8;
650 let ParserMatchClass = Imm0_7AsmOperand;
653 /// imm8 predicate - Immediate is exactly 8.
654 def Imm8AsmOperand: ImmAsmOperand { let Name = "Imm8"; }
655 def imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 8; }]> {
656 let ParserMatchClass = Imm8AsmOperand;
659 /// imm16 predicate - Immediate is exactly 16.
660 def Imm16AsmOperand: ImmAsmOperand { let Name = "Imm16"; }
661 def imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 16; }]> {
662 let ParserMatchClass = Imm16AsmOperand;
665 /// imm32 predicate - Immediate is exactly 32.
666 def Imm32AsmOperand: ImmAsmOperand { let Name = "Imm32"; }
667 def imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 32; }]> {
668 let ParserMatchClass = Imm32AsmOperand;
671 def imm8_or_16 : ImmLeaf<i32, [{ return Imm == 8 || Imm == 16;}]>;
673 /// imm1_7 predicate - Immediate in the range [1,7].
674 def Imm1_7AsmOperand: ImmAsmOperand { let Name = "Imm1_7"; }
675 def imm1_7 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 8; }]> {
676 let ParserMatchClass = Imm1_7AsmOperand;
679 /// imm1_15 predicate - Immediate in the range [1,15].
680 def Imm1_15AsmOperand: ImmAsmOperand { let Name = "Imm1_15"; }
681 def imm1_15 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 16; }]> {
682 let ParserMatchClass = Imm1_15AsmOperand;
685 /// imm1_31 predicate - Immediate in the range [1,31].
686 def Imm1_31AsmOperand: ImmAsmOperand { let Name = "Imm1_31"; }
687 def imm1_31 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 32; }]> {
688 let ParserMatchClass = Imm1_31AsmOperand;
691 /// imm0_15 predicate - Immediate in the range [0,15].
692 def Imm0_15AsmOperand: ImmAsmOperand {
693 let Name = "Imm0_15";
694 let DiagnosticType = "ImmRange0_15";
696 def imm0_15 : Operand<i32>, ImmLeaf<i32, [{
697 return Imm >= 0 && Imm < 16;
699 let ParserMatchClass = Imm0_15AsmOperand;
702 /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
703 def Imm0_31AsmOperand: ImmAsmOperand { let Name = "Imm0_31"; }
704 def imm0_31 : Operand<i32>, ImmLeaf<i32, [{
705 return Imm >= 0 && Imm < 32;
707 let ParserMatchClass = Imm0_31AsmOperand;
710 /// imm0_32 predicate - True if the 32-bit immediate is in the range [0,32].
711 def Imm0_32AsmOperand: ImmAsmOperand { let Name = "Imm0_32"; }
712 def imm0_32 : Operand<i32>, ImmLeaf<i32, [{
713 return Imm >= 0 && Imm < 32;
715 let ParserMatchClass = Imm0_32AsmOperand;
718 /// imm0_63 predicate - True if the 32-bit immediate is in the range [0,63].
719 def Imm0_63AsmOperand: ImmAsmOperand { let Name = "Imm0_63"; }
720 def imm0_63 : Operand<i32>, ImmLeaf<i32, [{
721 return Imm >= 0 && Imm < 64;
723 let ParserMatchClass = Imm0_63AsmOperand;
726 /// imm0_239 predicate - Immediate in the range [0,239].
727 def Imm0_239AsmOperand : ImmAsmOperand {
728 let Name = "Imm0_239";
729 let DiagnosticType = "ImmRange0_239";
731 def imm0_239 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 240; }]> {
732 let ParserMatchClass = Imm0_239AsmOperand;
735 /// imm0_255 predicate - Immediate in the range [0,255].
736 def Imm0_255AsmOperand : ImmAsmOperand { let Name = "Imm0_255"; }
737 def imm0_255 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 256; }]> {
738 let ParserMatchClass = Imm0_255AsmOperand;
741 /// imm0_65535 - An immediate is in the range [0.65535].
742 def Imm0_65535AsmOperand: ImmAsmOperand { let Name = "Imm0_65535"; }
743 def imm0_65535 : Operand<i32>, ImmLeaf<i32, [{
744 return Imm >= 0 && Imm < 65536;
746 let ParserMatchClass = Imm0_65535AsmOperand;
749 // imm0_65535_neg - An immediate whose negative value is in the range [0.65535].
750 def imm0_65535_neg : Operand<i32>, ImmLeaf<i32, [{
751 return -Imm >= 0 && -Imm < 65536;
754 // imm0_65535_expr - For movt/movw - 16-bit immediate that can also reference
755 // a relocatable expression.
757 // FIXME: This really needs a Thumb version separate from the ARM version.
758 // While the range is the same, and can thus use the same match class,
759 // the encoding is different so it should have a different encoder method.
760 def Imm0_65535ExprAsmOperand: ImmAsmOperand { let Name = "Imm0_65535Expr"; }
761 def imm0_65535_expr : Operand<i32> {
762 let EncoderMethod = "getHiLo16ImmOpValue";
763 let ParserMatchClass = Imm0_65535ExprAsmOperand;
766 def Imm256_65535ExprAsmOperand: ImmAsmOperand { let Name = "Imm256_65535Expr"; }
767 def imm256_65535_expr : Operand<i32> {
768 let ParserMatchClass = Imm256_65535ExprAsmOperand;
771 /// imm24b - True if the 32-bit immediate is encodable in 24 bits.
772 def Imm24bitAsmOperand: ImmAsmOperand { let Name = "Imm24bit"; }
773 def imm24b : Operand<i32>, ImmLeaf<i32, [{
774 return Imm >= 0 && Imm <= 0xffffff;
776 let ParserMatchClass = Imm24bitAsmOperand;
780 /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
782 def BitfieldAsmOperand : AsmOperandClass {
783 let Name = "Bitfield";
784 let ParserMethod = "parseBitfield";
787 def bf_inv_mask_imm : Operand<i32>,
789 return ARM::isBitFieldInvertedMask(N->getZExtValue());
791 let EncoderMethod = "getBitfieldInvertedMaskOpValue";
792 let PrintMethod = "printBitfieldInvMaskImmOperand";
793 let DecoderMethod = "DecodeBitfieldMaskOperand";
794 let ParserMatchClass = BitfieldAsmOperand;
797 def imm1_32_XFORM: SDNodeXForm<imm, [{
798 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, MVT::i32);
800 def Imm1_32AsmOperand: AsmOperandClass { let Name = "Imm1_32"; }
801 def imm1_32 : Operand<i32>, PatLeaf<(imm), [{
802 uint64_t Imm = N->getZExtValue();
803 return Imm > 0 && Imm <= 32;
806 let PrintMethod = "printImmPlusOneOperand";
807 let ParserMatchClass = Imm1_32AsmOperand;
810 def imm1_16_XFORM: SDNodeXForm<imm, [{
811 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, MVT::i32);
813 def Imm1_16AsmOperand: AsmOperandClass { let Name = "Imm1_16"; }
814 def imm1_16 : Operand<i32>, PatLeaf<(imm), [{ return Imm > 0 && Imm <= 16; }],
816 let PrintMethod = "printImmPlusOneOperand";
817 let ParserMatchClass = Imm1_16AsmOperand;
820 // Define ARM specific addressing modes.
821 // addrmode_imm12 := reg +/- imm12
823 def MemImm12OffsetAsmOperand : AsmOperandClass { let Name = "MemImm12Offset"; }
824 class AddrMode_Imm12 : Operand<i32>,
825 ComplexPattern<i32, 2, "SelectAddrModeImm12", []> {
826 // 12-bit immediate operand. Note that instructions using this encode
827 // #0 and #-0 differently. We flag #-0 as the magic value INT32_MIN. All other
828 // immediate values are as normal.
830 let EncoderMethod = "getAddrModeImm12OpValue";
831 let DecoderMethod = "DecodeAddrModeImm12Operand";
832 let ParserMatchClass = MemImm12OffsetAsmOperand;
833 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
836 def addrmode_imm12 : AddrMode_Imm12 {
837 let PrintMethod = "printAddrModeImm12Operand<false>";
840 def addrmode_imm12_pre : AddrMode_Imm12 {
841 let PrintMethod = "printAddrModeImm12Operand<true>";
844 // ldst_so_reg := reg +/- reg shop imm
846 def MemRegOffsetAsmOperand : AsmOperandClass { let Name = "MemRegOffset"; }
847 def ldst_so_reg : Operand<i32>,
848 ComplexPattern<i32, 3, "SelectLdStSOReg", []> {
849 let EncoderMethod = "getLdStSORegOpValue";
850 // FIXME: Simplify the printer
851 let PrintMethod = "printAddrMode2Operand";
852 let DecoderMethod = "DecodeSORegMemOperand";
853 let ParserMatchClass = MemRegOffsetAsmOperand;
854 let MIOperandInfo = (ops GPR:$base, GPRnopc:$offsreg, i32imm:$shift);
857 // postidx_imm8 := +/- [0,255]
860 // {8} 1 is imm8 is non-negative. 0 otherwise.
861 // {7-0} [0,255] imm8 value.
862 def PostIdxImm8AsmOperand : AsmOperandClass { let Name = "PostIdxImm8"; }
863 def postidx_imm8 : Operand<i32> {
864 let PrintMethod = "printPostIdxImm8Operand";
865 let ParserMatchClass = PostIdxImm8AsmOperand;
866 let MIOperandInfo = (ops i32imm);
869 // postidx_imm8s4 := +/- [0,1020]
872 // {8} 1 is imm8 is non-negative. 0 otherwise.
873 // {7-0} [0,255] imm8 value, scaled by 4.
874 def PostIdxImm8s4AsmOperand : AsmOperandClass { let Name = "PostIdxImm8s4"; }
875 def postidx_imm8s4 : Operand<i32> {
876 let PrintMethod = "printPostIdxImm8s4Operand";
877 let ParserMatchClass = PostIdxImm8s4AsmOperand;
878 let MIOperandInfo = (ops i32imm);
882 // postidx_reg := +/- reg
884 def PostIdxRegAsmOperand : AsmOperandClass {
885 let Name = "PostIdxReg";
886 let ParserMethod = "parsePostIdxReg";
888 def postidx_reg : Operand<i32> {
889 let EncoderMethod = "getPostIdxRegOpValue";
890 let DecoderMethod = "DecodePostIdxReg";
891 let PrintMethod = "printPostIdxRegOperand";
892 let ParserMatchClass = PostIdxRegAsmOperand;
893 let MIOperandInfo = (ops GPRnopc, i32imm);
897 // addrmode2 := reg +/- imm12
898 // := reg +/- reg shop imm
900 // FIXME: addrmode2 should be refactored the rest of the way to always
901 // use explicit imm vs. reg versions above (addrmode_imm12 and ldst_so_reg).
902 def AddrMode2AsmOperand : AsmOperandClass { let Name = "AddrMode2"; }
903 def addrmode2 : Operand<i32>,
904 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
905 let EncoderMethod = "getAddrMode2OpValue";
906 let PrintMethod = "printAddrMode2Operand";
907 let ParserMatchClass = AddrMode2AsmOperand;
908 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
911 def PostIdxRegShiftedAsmOperand : AsmOperandClass {
912 let Name = "PostIdxRegShifted";
913 let ParserMethod = "parsePostIdxReg";
915 def am2offset_reg : Operand<i32>,
916 ComplexPattern<i32, 2, "SelectAddrMode2OffsetReg",
917 [], [SDNPWantRoot]> {
918 let EncoderMethod = "getAddrMode2OffsetOpValue";
919 let PrintMethod = "printAddrMode2OffsetOperand";
920 // When using this for assembly, it's always as a post-index offset.
921 let ParserMatchClass = PostIdxRegShiftedAsmOperand;
922 let MIOperandInfo = (ops GPRnopc, i32imm);
925 // FIXME: am2offset_imm should only need the immediate, not the GPR. Having
926 // the GPR is purely vestigal at this point.
927 def AM2OffsetImmAsmOperand : AsmOperandClass { let Name = "AM2OffsetImm"; }
928 def am2offset_imm : Operand<i32>,
929 ComplexPattern<i32, 2, "SelectAddrMode2OffsetImm",
930 [], [SDNPWantRoot]> {
931 let EncoderMethod = "getAddrMode2OffsetOpValue";
932 let PrintMethod = "printAddrMode2OffsetOperand";
933 let ParserMatchClass = AM2OffsetImmAsmOperand;
934 let MIOperandInfo = (ops GPRnopc, i32imm);
938 // addrmode3 := reg +/- reg
939 // addrmode3 := reg +/- imm8
941 // FIXME: split into imm vs. reg versions.
942 def AddrMode3AsmOperand : AsmOperandClass { let Name = "AddrMode3"; }
943 class AddrMode3 : Operand<i32>,
944 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
945 let EncoderMethod = "getAddrMode3OpValue";
946 let ParserMatchClass = AddrMode3AsmOperand;
947 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
950 def addrmode3 : AddrMode3
952 let PrintMethod = "printAddrMode3Operand<false>";
955 def addrmode3_pre : AddrMode3
957 let PrintMethod = "printAddrMode3Operand<true>";
960 // FIXME: split into imm vs. reg versions.
961 // FIXME: parser method to handle +/- register.
962 def AM3OffsetAsmOperand : AsmOperandClass {
963 let Name = "AM3Offset";
964 let ParserMethod = "parseAM3Offset";
966 def am3offset : Operand<i32>,
967 ComplexPattern<i32, 2, "SelectAddrMode3Offset",
968 [], [SDNPWantRoot]> {
969 let EncoderMethod = "getAddrMode3OffsetOpValue";
970 let PrintMethod = "printAddrMode3OffsetOperand";
971 let ParserMatchClass = AM3OffsetAsmOperand;
972 let MIOperandInfo = (ops GPR, i32imm);
975 // ldstm_mode := {ia, ib, da, db}
977 def ldstm_mode : OptionalDefOperand<OtherVT, (ops i32), (ops (i32 1))> {
978 let EncoderMethod = "getLdStmModeOpValue";
979 let PrintMethod = "printLdStmModeOperand";
982 // addrmode5 := reg +/- imm8*4
984 def AddrMode5AsmOperand : AsmOperandClass { let Name = "AddrMode5"; }
985 class AddrMode5 : Operand<i32>,
986 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
987 let EncoderMethod = "getAddrMode5OpValue";
988 let DecoderMethod = "DecodeAddrMode5Operand";
989 let ParserMatchClass = AddrMode5AsmOperand;
990 let MIOperandInfo = (ops GPR:$base, i32imm);
993 def addrmode5 : AddrMode5 {
994 let PrintMethod = "printAddrMode5Operand<false>";
997 def addrmode5_pre : AddrMode5 {
998 let PrintMethod = "printAddrMode5Operand<true>";
1001 // addrmode6 := reg with optional alignment
1003 def AddrMode6AsmOperand : AsmOperandClass { let Name = "AlignedMemory"; }
1004 def addrmode6 : Operand<i32>,
1005 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1006 let PrintMethod = "printAddrMode6Operand";
1007 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
1008 let EncoderMethod = "getAddrMode6AddressOpValue";
1009 let DecoderMethod = "DecodeAddrMode6Operand";
1010 let ParserMatchClass = AddrMode6AsmOperand;
1013 def am6offset : Operand<i32>,
1014 ComplexPattern<i32, 1, "SelectAddrMode6Offset",
1015 [], [SDNPWantRoot]> {
1016 let PrintMethod = "printAddrMode6OffsetOperand";
1017 let MIOperandInfo = (ops GPR);
1018 let EncoderMethod = "getAddrMode6OffsetOpValue";
1019 let DecoderMethod = "DecodeGPRRegisterClass";
1022 // Special version of addrmode6 to handle alignment encoding for VST1/VLD1
1023 // (single element from one lane) for size 32.
1024 def addrmode6oneL32 : Operand<i32>,
1025 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1026 let PrintMethod = "printAddrMode6Operand";
1027 let MIOperandInfo = (ops GPR:$addr, i32imm);
1028 let EncoderMethod = "getAddrMode6OneLane32AddressOpValue";
1031 // Base class for addrmode6 with specific alignment restrictions.
1032 class AddrMode6Align : Operand<i32>,
1033 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1034 let PrintMethod = "printAddrMode6Operand";
1035 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
1036 let EncoderMethod = "getAddrMode6AddressOpValue";
1037 let DecoderMethod = "DecodeAddrMode6Operand";
1040 // Special version of addrmode6 to handle no allowed alignment encoding for
1041 // VLD/VST instructions and checking the alignment is not specified.
1042 def AddrMode6AlignNoneAsmOperand : AsmOperandClass {
1043 let Name = "AlignedMemoryNone";
1044 let DiagnosticType = "AlignedMemoryRequiresNone";
1046 def addrmode6alignNone : AddrMode6Align {
1047 // The alignment specifier can only be omitted.
1048 let ParserMatchClass = AddrMode6AlignNoneAsmOperand;
1051 // Special version of addrmode6 to handle 16-bit alignment encoding for
1052 // VLD/VST instructions and checking the alignment value.
1053 def AddrMode6Align16AsmOperand : AsmOperandClass {
1054 let Name = "AlignedMemory16";
1055 let DiagnosticType = "AlignedMemoryRequires16";
1057 def addrmode6align16 : AddrMode6Align {
1058 // The alignment specifier can only be 16 or omitted.
1059 let ParserMatchClass = AddrMode6Align16AsmOperand;
1062 // Special version of addrmode6 to handle 32-bit alignment encoding for
1063 // VLD/VST instructions and checking the alignment value.
1064 def AddrMode6Align32AsmOperand : AsmOperandClass {
1065 let Name = "AlignedMemory32";
1066 let DiagnosticType = "AlignedMemoryRequires32";
1068 def addrmode6align32 : AddrMode6Align {
1069 // The alignment specifier can only be 32 or omitted.
1070 let ParserMatchClass = AddrMode6Align32AsmOperand;
1073 // Special version of addrmode6 to handle 64-bit alignment encoding for
1074 // VLD/VST instructions and checking the alignment value.
1075 def AddrMode6Align64AsmOperand : AsmOperandClass {
1076 let Name = "AlignedMemory64";
1077 let DiagnosticType = "AlignedMemoryRequires64";
1079 def addrmode6align64 : AddrMode6Align {
1080 // The alignment specifier can only be 64 or omitted.
1081 let ParserMatchClass = AddrMode6Align64AsmOperand;
1084 // Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding
1085 // for VLD/VST instructions and checking the alignment value.
1086 def AddrMode6Align64or128AsmOperand : AsmOperandClass {
1087 let Name = "AlignedMemory64or128";
1088 let DiagnosticType = "AlignedMemoryRequires64or128";
1090 def addrmode6align64or128 : AddrMode6Align {
1091 // The alignment specifier can only be 64, 128 or omitted.
1092 let ParserMatchClass = AddrMode6Align64or128AsmOperand;
1095 // Special version of addrmode6 to handle 64-bit, 128-bit or 256-bit alignment
1096 // encoding for VLD/VST instructions and checking the alignment value.
1097 def AddrMode6Align64or128or256AsmOperand : AsmOperandClass {
1098 let Name = "AlignedMemory64or128or256";
1099 let DiagnosticType = "AlignedMemoryRequires64or128or256";
1101 def addrmode6align64or128or256 : AddrMode6Align {
1102 // The alignment specifier can only be 64, 128, 256 or omitted.
1103 let ParserMatchClass = AddrMode6Align64or128or256AsmOperand;
1106 // Special version of addrmode6 to handle alignment encoding for VLD-dup
1107 // instructions, specifically VLD4-dup.
1108 def addrmode6dup : Operand<i32>,
1109 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1110 let PrintMethod = "printAddrMode6Operand";
1111 let MIOperandInfo = (ops GPR:$addr, i32imm);
1112 let EncoderMethod = "getAddrMode6DupAddressOpValue";
1113 // FIXME: This is close, but not quite right. The alignment specifier is
1115 let ParserMatchClass = AddrMode6AsmOperand;
1118 // Base class for addrmode6dup with specific alignment restrictions.
1119 class AddrMode6DupAlign : Operand<i32>,
1120 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1121 let PrintMethod = "printAddrMode6Operand";
1122 let MIOperandInfo = (ops GPR:$addr, i32imm);
1123 let EncoderMethod = "getAddrMode6DupAddressOpValue";
1126 // Special version of addrmode6 to handle no allowed alignment encoding for
1127 // VLD-dup instruction and checking the alignment is not specified.
1128 def AddrMode6dupAlignNoneAsmOperand : AsmOperandClass {
1129 let Name = "DupAlignedMemoryNone";
1130 let DiagnosticType = "DupAlignedMemoryRequiresNone";
1132 def addrmode6dupalignNone : AddrMode6DupAlign {
1133 // The alignment specifier can only be omitted.
1134 let ParserMatchClass = AddrMode6dupAlignNoneAsmOperand;
1137 // Special version of addrmode6 to handle 16-bit alignment encoding for VLD-dup
1138 // instruction and checking the alignment value.
1139 def AddrMode6dupAlign16AsmOperand : AsmOperandClass {
1140 let Name = "DupAlignedMemory16";
1141 let DiagnosticType = "DupAlignedMemoryRequires16";
1143 def addrmode6dupalign16 : AddrMode6DupAlign {
1144 // The alignment specifier can only be 16 or omitted.
1145 let ParserMatchClass = AddrMode6dupAlign16AsmOperand;
1148 // Special version of addrmode6 to handle 32-bit alignment encoding for VLD-dup
1149 // instruction and checking the alignment value.
1150 def AddrMode6dupAlign32AsmOperand : AsmOperandClass {
1151 let Name = "DupAlignedMemory32";
1152 let DiagnosticType = "DupAlignedMemoryRequires32";
1154 def addrmode6dupalign32 : AddrMode6DupAlign {
1155 // The alignment specifier can only be 32 or omitted.
1156 let ParserMatchClass = AddrMode6dupAlign32AsmOperand;
1159 // Special version of addrmode6 to handle 64-bit alignment encoding for VLD
1160 // instructions and checking the alignment value.
1161 def AddrMode6dupAlign64AsmOperand : AsmOperandClass {
1162 let Name = "DupAlignedMemory64";
1163 let DiagnosticType = "DupAlignedMemoryRequires64";
1165 def addrmode6dupalign64 : AddrMode6DupAlign {
1166 // The alignment specifier can only be 64 or omitted.
1167 let ParserMatchClass = AddrMode6dupAlign64AsmOperand;
1170 // Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding
1171 // for VLD instructions and checking the alignment value.
1172 def AddrMode6dupAlign64or128AsmOperand : AsmOperandClass {
1173 let Name = "DupAlignedMemory64or128";
1174 let DiagnosticType = "DupAlignedMemoryRequires64or128";
1176 def addrmode6dupalign64or128 : AddrMode6DupAlign {
1177 // The alignment specifier can only be 64, 128 or omitted.
1178 let ParserMatchClass = AddrMode6dupAlign64or128AsmOperand;
1181 // addrmodepc := pc + reg
1183 def addrmodepc : Operand<i32>,
1184 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
1185 let PrintMethod = "printAddrModePCOperand";
1186 let MIOperandInfo = (ops GPR, i32imm);
1189 // addr_offset_none := reg
1191 def MemNoOffsetAsmOperand : AsmOperandClass { let Name = "MemNoOffset"; }
1192 def addr_offset_none : Operand<i32>,
1193 ComplexPattern<i32, 1, "SelectAddrOffsetNone", []> {
1194 let PrintMethod = "printAddrMode7Operand";
1195 let DecoderMethod = "DecodeAddrMode7Operand";
1196 let ParserMatchClass = MemNoOffsetAsmOperand;
1197 let MIOperandInfo = (ops GPR:$base);
1200 def nohash_imm : Operand<i32> {
1201 let PrintMethod = "printNoHashImmediate";
1204 def CoprocNumAsmOperand : AsmOperandClass {
1205 let Name = "CoprocNum";
1206 let ParserMethod = "parseCoprocNumOperand";
1208 def p_imm : Operand<i32> {
1209 let PrintMethod = "printPImmediate";
1210 let ParserMatchClass = CoprocNumAsmOperand;
1211 let DecoderMethod = "DecodeCoprocessor";
1214 def CoprocRegAsmOperand : AsmOperandClass {
1215 let Name = "CoprocReg";
1216 let ParserMethod = "parseCoprocRegOperand";
1218 def c_imm : Operand<i32> {
1219 let PrintMethod = "printCImmediate";
1220 let ParserMatchClass = CoprocRegAsmOperand;
1222 def CoprocOptionAsmOperand : AsmOperandClass {
1223 let Name = "CoprocOption";
1224 let ParserMethod = "parseCoprocOptionOperand";
1226 def coproc_option_imm : Operand<i32> {
1227 let PrintMethod = "printCoprocOptionImm";
1228 let ParserMatchClass = CoprocOptionAsmOperand;
1231 //===----------------------------------------------------------------------===//
1233 include "ARMInstrFormats.td"
1235 //===----------------------------------------------------------------------===//
1236 // Multiclass helpers...
1239 /// AsI1_bin_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns for a
1240 /// binop that produces a value.
1241 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1242 multiclass AsI1_bin_irs<bits<4> opcod, string opc,
1243 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1244 PatFrag opnode, bit Commutable = 0> {
1245 // The register-immediate version is re-materializable. This is useful
1246 // in particular for taking the address of a local.
1247 let isReMaterializable = 1 in {
1248 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm,
1249 iii, opc, "\t$Rd, $Rn, $imm",
1250 [(set GPR:$Rd, (opnode GPR:$Rn, mod_imm:$imm))]>,
1251 Sched<[WriteALU, ReadALU]> {
1256 let Inst{19-16} = Rn;
1257 let Inst{15-12} = Rd;
1258 let Inst{11-0} = imm;
1261 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1262 iir, opc, "\t$Rd, $Rn, $Rm",
1263 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]>,
1264 Sched<[WriteALU, ReadALU, ReadALU]> {
1269 let isCommutable = Commutable;
1270 let Inst{19-16} = Rn;
1271 let Inst{15-12} = Rd;
1272 let Inst{11-4} = 0b00000000;
1276 def rsi : AsI1<opcod, (outs GPR:$Rd),
1277 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1278 iis, opc, "\t$Rd, $Rn, $shift",
1279 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_imm:$shift))]>,
1280 Sched<[WriteALUsi, ReadALU]> {
1285 let Inst{19-16} = Rn;
1286 let Inst{15-12} = Rd;
1287 let Inst{11-5} = shift{11-5};
1289 let Inst{3-0} = shift{3-0};
1292 def rsr : AsI1<opcod, (outs GPR:$Rd),
1293 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1294 iis, opc, "\t$Rd, $Rn, $shift",
1295 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_reg:$shift))]>,
1296 Sched<[WriteALUsr, ReadALUsr]> {
1301 let Inst{19-16} = Rn;
1302 let Inst{15-12} = Rd;
1303 let Inst{11-8} = shift{11-8};
1305 let Inst{6-5} = shift{6-5};
1307 let Inst{3-0} = shift{3-0};
1311 /// AsI1_rbin_irs - Same as AsI1_bin_irs except the order of operands are
1312 /// reversed. The 'rr' form is only defined for the disassembler; for codegen
1313 /// it is equivalent to the AsI1_bin_irs counterpart.
1314 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1315 multiclass AsI1_rbin_irs<bits<4> opcod, string opc,
1316 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1317 PatFrag opnode, bit Commutable = 0> {
1318 // The register-immediate version is re-materializable. This is useful
1319 // in particular for taking the address of a local.
1320 let isReMaterializable = 1 in {
1321 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm,
1322 iii, opc, "\t$Rd, $Rn, $imm",
1323 [(set GPR:$Rd, (opnode mod_imm:$imm, GPR:$Rn))]>,
1324 Sched<[WriteALU, ReadALU]> {
1329 let Inst{19-16} = Rn;
1330 let Inst{15-12} = Rd;
1331 let Inst{11-0} = imm;
1334 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1335 iir, opc, "\t$Rd, $Rn, $Rm",
1336 [/* pattern left blank */]>,
1337 Sched<[WriteALU, ReadALU, ReadALU]> {
1341 let Inst{11-4} = 0b00000000;
1344 let Inst{15-12} = Rd;
1345 let Inst{19-16} = Rn;
1348 def rsi : AsI1<opcod, (outs GPR:$Rd),
1349 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1350 iis, opc, "\t$Rd, $Rn, $shift",
1351 [(set GPR:$Rd, (opnode so_reg_imm:$shift, GPR:$Rn))]>,
1352 Sched<[WriteALUsi, ReadALU]> {
1357 let Inst{19-16} = Rn;
1358 let Inst{15-12} = Rd;
1359 let Inst{11-5} = shift{11-5};
1361 let Inst{3-0} = shift{3-0};
1364 def rsr : AsI1<opcod, (outs GPR:$Rd),
1365 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1366 iis, opc, "\t$Rd, $Rn, $shift",
1367 [(set GPR:$Rd, (opnode so_reg_reg:$shift, GPR:$Rn))]>,
1368 Sched<[WriteALUsr, ReadALUsr]> {
1373 let Inst{19-16} = Rn;
1374 let Inst{15-12} = Rd;
1375 let Inst{11-8} = shift{11-8};
1377 let Inst{6-5} = shift{6-5};
1379 let Inst{3-0} = shift{3-0};
1383 /// AsI1_bin_s_irs - Same as AsI1_bin_irs except it sets the 's' bit by default.
1385 /// These opcodes will be converted to the real non-S opcodes by
1386 /// AdjustInstrPostInstrSelection after giving them an optional CPSR operand.
1387 let hasPostISelHook = 1, Defs = [CPSR] in {
1388 multiclass AsI1_bin_s_irs<InstrItinClass iii, InstrItinClass iir,
1389 InstrItinClass iis, PatFrag opnode,
1390 bit Commutable = 0> {
1391 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p),
1393 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm))]>,
1394 Sched<[WriteALU, ReadALU]>;
1396 def rr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, pred:$p),
1398 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm))]>,
1399 Sched<[WriteALU, ReadALU, ReadALU]> {
1400 let isCommutable = Commutable;
1402 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1403 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1405 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1406 so_reg_imm:$shift))]>,
1407 Sched<[WriteALUsi, ReadALU]>;
1409 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1410 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1412 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1413 so_reg_reg:$shift))]>,
1414 Sched<[WriteALUSsr, ReadALUsr]>;
1418 /// AsI1_rbin_s_is - Same as AsI1_bin_s_irs, except selection DAG
1419 /// operands are reversed.
1420 let hasPostISelHook = 1, Defs = [CPSR] in {
1421 multiclass AsI1_rbin_s_is<InstrItinClass iii, InstrItinClass iir,
1422 InstrItinClass iis, PatFrag opnode,
1423 bit Commutable = 0> {
1424 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p),
1426 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn))]>,
1427 Sched<[WriteALU, ReadALU]>;
1429 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1430 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1432 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift,
1434 Sched<[WriteALUsi, ReadALU]>;
1436 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1437 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1439 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift,
1441 Sched<[WriteALUSsr, ReadALUsr]>;
1445 /// AI1_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
1446 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
1447 /// a explicit result, only implicitly set CPSR.
1448 let isCompare = 1, Defs = [CPSR] in {
1449 multiclass AI1_cmp_irs<bits<4> opcod, string opc,
1450 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1451 PatFrag opnode, bit Commutable = 0> {
1452 def ri : AI1<opcod, (outs), (ins GPR:$Rn, mod_imm:$imm), DPFrm, iii,
1454 [(opnode GPR:$Rn, mod_imm:$imm)]>,
1455 Sched<[WriteCMP, ReadALU]> {
1460 let Inst{19-16} = Rn;
1461 let Inst{15-12} = 0b0000;
1462 let Inst{11-0} = imm;
1464 let Unpredictable{15-12} = 0b1111;
1466 def rr : AI1<opcod, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, iir,
1468 [(opnode GPR:$Rn, GPR:$Rm)]>,
1469 Sched<[WriteCMP, ReadALU, ReadALU]> {
1472 let isCommutable = Commutable;
1475 let Inst{19-16} = Rn;
1476 let Inst{15-12} = 0b0000;
1477 let Inst{11-4} = 0b00000000;
1480 let Unpredictable{15-12} = 0b1111;
1482 def rsi : AI1<opcod, (outs),
1483 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, iis,
1484 opc, "\t$Rn, $shift",
1485 [(opnode GPR:$Rn, so_reg_imm:$shift)]>,
1486 Sched<[WriteCMPsi, ReadALU]> {
1491 let Inst{19-16} = Rn;
1492 let Inst{15-12} = 0b0000;
1493 let Inst{11-5} = shift{11-5};
1495 let Inst{3-0} = shift{3-0};
1497 let Unpredictable{15-12} = 0b1111;
1499 def rsr : AI1<opcod, (outs),
1500 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, iis,
1501 opc, "\t$Rn, $shift",
1502 [(opnode GPRnopc:$Rn, so_reg_reg:$shift)]>,
1503 Sched<[WriteCMPsr, ReadALU]> {
1508 let Inst{19-16} = Rn;
1509 let Inst{15-12} = 0b0000;
1510 let Inst{11-8} = shift{11-8};
1512 let Inst{6-5} = shift{6-5};
1514 let Inst{3-0} = shift{3-0};
1516 let Unpredictable{15-12} = 0b1111;
1522 /// AI_ext_rrot - A unary operation with two forms: one whose operand is a
1523 /// register and one whose operand is a register rotated by 8/16/24.
1524 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
1525 class AI_ext_rrot<bits<8> opcod, string opc, PatFrag opnode>
1526 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1527 IIC_iEXTr, opc, "\t$Rd, $Rm$rot",
1528 [(set GPRnopc:$Rd, (opnode (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1529 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> {
1533 let Inst{19-16} = 0b1111;
1534 let Inst{15-12} = Rd;
1535 let Inst{11-10} = rot;
1539 class AI_ext_rrot_np<bits<8> opcod, string opc>
1540 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1541 IIC_iEXTr, opc, "\t$Rd, $Rm$rot", []>,
1542 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> {
1544 let Inst{19-16} = 0b1111;
1545 let Inst{11-10} = rot;
1548 /// AI_exta_rrot - A binary operation with two forms: one whose operand is a
1549 /// register and one whose operand is a register rotated by 8/16/24.
1550 class AI_exta_rrot<bits<8> opcod, string opc, PatFrag opnode>
1551 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1552 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot",
1553 [(set GPRnopc:$Rd, (opnode GPR:$Rn,
1554 (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1555 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> {
1560 let Inst{19-16} = Rn;
1561 let Inst{15-12} = Rd;
1562 let Inst{11-10} = rot;
1563 let Inst{9-4} = 0b000111;
1567 class AI_exta_rrot_np<bits<8> opcod, string opc>
1568 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1569 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot", []>,
1570 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> {
1573 let Inst{19-16} = Rn;
1574 let Inst{11-10} = rot;
1577 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
1578 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1579 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
1580 bit Commutable = 0> {
1581 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1582 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm),
1583 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1584 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm, CPSR))]>,
1586 Sched<[WriteALU, ReadALU]> {
1591 let Inst{15-12} = Rd;
1592 let Inst{19-16} = Rn;
1593 let Inst{11-0} = imm;
1595 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1596 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1597 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm, CPSR))]>,
1599 Sched<[WriteALU, ReadALU, ReadALU]> {
1603 let Inst{11-4} = 0b00000000;
1605 let isCommutable = Commutable;
1607 let Inst{15-12} = Rd;
1608 let Inst{19-16} = Rn;
1610 def rsi : AsI1<opcod, (outs GPR:$Rd),
1611 (ins GPR:$Rn, so_reg_imm:$shift),
1612 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1613 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_imm:$shift, CPSR))]>,
1615 Sched<[WriteALUsi, ReadALU]> {
1620 let Inst{19-16} = Rn;
1621 let Inst{15-12} = Rd;
1622 let Inst{11-5} = shift{11-5};
1624 let Inst{3-0} = shift{3-0};
1626 def rsr : AsI1<opcod, (outs GPRnopc:$Rd),
1627 (ins GPRnopc:$Rn, so_reg_reg:$shift),
1628 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1629 [(set GPRnopc:$Rd, CPSR,
1630 (opnode GPRnopc:$Rn, so_reg_reg:$shift, CPSR))]>,
1632 Sched<[WriteALUsr, ReadALUsr]> {
1637 let Inst{19-16} = Rn;
1638 let Inst{15-12} = Rd;
1639 let Inst{11-8} = shift{11-8};
1641 let Inst{6-5} = shift{6-5};
1643 let Inst{3-0} = shift{3-0};
1648 /// AI1_rsc_irs - Define instructions and patterns for rsc
1649 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1650 multiclass AI1_rsc_irs<bits<4> opcod, string opc, PatFrag opnode> {
1651 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1652 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm),
1653 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1654 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn, CPSR))]>,
1656 Sched<[WriteALU, ReadALU]> {
1661 let Inst{15-12} = Rd;
1662 let Inst{19-16} = Rn;
1663 let Inst{11-0} = imm;
1665 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1666 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1667 [/* pattern left blank */]>,
1668 Sched<[WriteALU, ReadALU, ReadALU]> {
1672 let Inst{11-4} = 0b00000000;
1675 let Inst{15-12} = Rd;
1676 let Inst{19-16} = Rn;
1678 def rsi : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_imm:$shift),
1679 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1680 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift, GPR:$Rn, CPSR))]>,
1682 Sched<[WriteALUsi, ReadALU]> {
1687 let Inst{19-16} = Rn;
1688 let Inst{15-12} = Rd;
1689 let Inst{11-5} = shift{11-5};
1691 let Inst{3-0} = shift{3-0};
1693 def rsr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_reg:$shift),
1694 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1695 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift, GPR:$Rn, CPSR))]>,
1697 Sched<[WriteALUsr, ReadALUsr]> {
1702 let Inst{19-16} = Rn;
1703 let Inst{15-12} = Rd;
1704 let Inst{11-8} = shift{11-8};
1706 let Inst{6-5} = shift{6-5};
1708 let Inst{3-0} = shift{3-0};
1713 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1714 multiclass AI_ldr1<bit isByte, string opc, InstrItinClass iii,
1715 InstrItinClass iir, PatFrag opnode> {
1716 // Note: We use the complex addrmode_imm12 rather than just an input
1717 // GPR and a constrained immediate so that we can use this to match
1718 // frame index references and avoid matching constant pool references.
1719 def i12: AI2ldst<0b010, 1, isByte, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
1720 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1721 [(set GPR:$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 GPR:$Rt), (ins ldst_so_reg:$shift),
1730 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1731 [(set GPR:$Rt, (opnode ldst_so_reg:$shift))]> {
1734 let shift{4} = 0; // Inst{4} = 0
1735 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1736 let Inst{19-16} = shift{16-13}; // Rn
1737 let Inst{15-12} = Rt;
1738 let Inst{11-0} = shift{11-0};
1743 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1744 multiclass AI_ldr1nopc<bit isByte, string opc, InstrItinClass iii,
1745 InstrItinClass iir, PatFrag opnode> {
1746 // Note: We use the complex addrmode_imm12 rather than just an input
1747 // GPR and a constrained immediate so that we can use this to match
1748 // frame index references and avoid matching constant pool references.
1749 def i12: AI2ldst<0b010, 1, isByte, (outs GPRnopc:$Rt),
1750 (ins addrmode_imm12:$addr),
1751 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1752 [(set GPRnopc:$Rt, (opnode addrmode_imm12:$addr))]> {
1755 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1756 let Inst{19-16} = addr{16-13}; // Rn
1757 let Inst{15-12} = Rt;
1758 let Inst{11-0} = addr{11-0}; // imm12
1760 def rs : AI2ldst<0b011, 1, isByte, (outs GPRnopc:$Rt),
1761 (ins ldst_so_reg:$shift),
1762 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1763 [(set GPRnopc:$Rt, (opnode 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};
1776 multiclass AI_str1<bit isByte, string opc, InstrItinClass iii,
1777 InstrItinClass iir, PatFrag opnode> {
1778 // Note: We use the complex addrmode_imm12 rather than just an input
1779 // GPR and a constrained immediate so that we can use this to match
1780 // frame index references and avoid matching constant pool references.
1781 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1782 (ins GPR:$Rt, addrmode_imm12:$addr),
1783 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1784 [(opnode GPR:$Rt, addrmode_imm12:$addr)]> {
1787 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1788 let Inst{19-16} = addr{16-13}; // Rn
1789 let Inst{15-12} = Rt;
1790 let Inst{11-0} = addr{11-0}; // imm12
1792 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPR:$Rt, ldst_so_reg:$shift),
1793 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1794 [(opnode GPR:$Rt, ldst_so_reg:$shift)]> {
1797 let shift{4} = 0; // Inst{4} = 0
1798 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1799 let Inst{19-16} = shift{16-13}; // Rn
1800 let Inst{15-12} = Rt;
1801 let Inst{11-0} = shift{11-0};
1805 multiclass AI_str1nopc<bit isByte, string opc, InstrItinClass iii,
1806 InstrItinClass iir, PatFrag opnode> {
1807 // Note: We use the complex addrmode_imm12 rather than just an input
1808 // GPR and a constrained immediate so that we can use this to match
1809 // frame index references and avoid matching constant pool references.
1810 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1811 (ins GPRnopc:$Rt, addrmode_imm12:$addr),
1812 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1813 [(opnode GPRnopc:$Rt, addrmode_imm12:$addr)]> {
1816 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1817 let Inst{19-16} = addr{16-13}; // Rn
1818 let Inst{15-12} = Rt;
1819 let Inst{11-0} = addr{11-0}; // imm12
1821 def rs : AI2ldst<0b011, 0, isByte, (outs),
1822 (ins GPRnopc:$Rt, ldst_so_reg:$shift),
1823 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1824 [(opnode GPRnopc:$Rt, ldst_so_reg:$shift)]> {
1827 let shift{4} = 0; // Inst{4} = 0
1828 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1829 let Inst{19-16} = shift{16-13}; // Rn
1830 let Inst{15-12} = Rt;
1831 let Inst{11-0} = shift{11-0};
1836 //===----------------------------------------------------------------------===//
1838 //===----------------------------------------------------------------------===//
1840 //===----------------------------------------------------------------------===//
1841 // Miscellaneous Instructions.
1844 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
1845 /// the function. The first operand is the ID# for this instruction, the second
1846 /// is the index into the MachineConstantPool that this is, the third is the
1847 /// size in bytes of this constant pool entry.
1848 let hasSideEffects = 0, isNotDuplicable = 1 in
1849 def CONSTPOOL_ENTRY :
1850 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1851 i32imm:$size), NoItinerary, []>;
1853 // FIXME: Marking these as hasSideEffects is necessary to prevent machine DCE
1854 // from removing one half of the matched pairs. That breaks PEI, which assumes
1855 // these will always be in pairs, and asserts if it finds otherwise. Better way?
1856 let Defs = [SP], Uses = [SP], hasSideEffects = 1 in {
1857 def ADJCALLSTACKUP :
1858 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary,
1859 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
1861 def ADJCALLSTACKDOWN :
1862 PseudoInst<(outs), (ins i32imm:$amt, pred:$p), NoItinerary,
1863 [(ARMcallseq_start timm:$amt)]>;
1866 def HINT : AI<(outs), (ins imm0_239:$imm), MiscFrm, NoItinerary,
1867 "hint", "\t$imm", [(int_arm_hint imm0_239:$imm)]>,
1868 Requires<[IsARM, HasV6]> {
1870 let Inst{27-8} = 0b00110010000011110000;
1871 let Inst{7-0} = imm;
1874 def : InstAlias<"nop$p", (HINT 0, pred:$p)>, Requires<[IsARM, HasV6T2]>;
1875 def : InstAlias<"yield$p", (HINT 1, pred:$p)>, Requires<[IsARM, HasV6T2]>;
1876 def : InstAlias<"wfe$p", (HINT 2, pred:$p)>, Requires<[IsARM, HasV6T2]>;
1877 def : InstAlias<"wfi$p", (HINT 3, pred:$p)>, Requires<[IsARM, HasV6T2]>;
1878 def : InstAlias<"sev$p", (HINT 4, pred:$p)>, Requires<[IsARM, HasV6T2]>;
1879 def : InstAlias<"sevl$p", (HINT 5, pred:$p)>, Requires<[IsARM, HasV8]>;
1881 def SEL : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, NoItinerary, "sel",
1882 "\t$Rd, $Rn, $Rm", []>, Requires<[IsARM, HasV6]> {
1887 let Inst{15-12} = Rd;
1888 let Inst{19-16} = Rn;
1889 let Inst{27-20} = 0b01101000;
1890 let Inst{7-4} = 0b1011;
1891 let Inst{11-8} = 0b1111;
1892 let Unpredictable{11-8} = 0b1111;
1895 // The 16-bit operand $val can be used by a debugger to store more information
1896 // about the breakpoint.
1897 def BKPT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
1898 "bkpt", "\t$val", []>, Requires<[IsARM]> {
1900 let Inst{3-0} = val{3-0};
1901 let Inst{19-8} = val{15-4};
1902 let Inst{27-20} = 0b00010010;
1903 let Inst{31-28} = 0xe; // AL
1904 let Inst{7-4} = 0b0111;
1906 // default immediate for breakpoint mnemonic
1907 def : InstAlias<"bkpt", (BKPT 0)>, Requires<[IsARM]>;
1909 def HLT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
1910 "hlt", "\t$val", []>, Requires<[IsARM, HasV8]> {
1912 let Inst{3-0} = val{3-0};
1913 let Inst{19-8} = val{15-4};
1914 let Inst{27-20} = 0b00010000;
1915 let Inst{31-28} = 0xe; // AL
1916 let Inst{7-4} = 0b0111;
1919 // Change Processor State
1920 // FIXME: We should use InstAlias to handle the optional operands.
1921 class CPS<dag iops, string asm_ops>
1922 : AXI<(outs), iops, MiscFrm, NoItinerary, !strconcat("cps", asm_ops),
1923 []>, Requires<[IsARM]> {
1929 let Inst{31-28} = 0b1111;
1930 let Inst{27-20} = 0b00010000;
1931 let Inst{19-18} = imod;
1932 let Inst{17} = M; // Enabled if mode is set;
1933 let Inst{16-9} = 0b00000000;
1934 let Inst{8-6} = iflags;
1936 let Inst{4-0} = mode;
1939 let DecoderMethod = "DecodeCPSInstruction" in {
1941 def CPS3p : CPS<(ins imod_op:$imod, iflags_op:$iflags, imm0_31:$mode),
1942 "$imod\t$iflags, $mode">;
1943 let mode = 0, M = 0 in
1944 def CPS2p : CPS<(ins imod_op:$imod, iflags_op:$iflags), "$imod\t$iflags">;
1946 let imod = 0, iflags = 0, M = 1 in
1947 def CPS1p : CPS<(ins imm0_31:$mode), "\t$mode">;
1950 // Preload signals the memory system of possible future data/instruction access.
1951 multiclass APreLoad<bits<1> read, bits<1> data, string opc> {
1953 def i12 : AXIM<(outs), (ins addrmode_imm12:$addr), AddrMode_i12, MiscFrm,
1954 IIC_Preload, !strconcat(opc, "\t$addr"),
1955 [(ARMPreload addrmode_imm12:$addr, (i32 read), (i32 data))]>,
1956 Sched<[WritePreLd]> {
1959 let Inst{31-26} = 0b111101;
1960 let Inst{25} = 0; // 0 for immediate form
1961 let Inst{24} = data;
1962 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1963 let Inst{22} = read;
1964 let Inst{21-20} = 0b01;
1965 let Inst{19-16} = addr{16-13}; // Rn
1966 let Inst{15-12} = 0b1111;
1967 let Inst{11-0} = addr{11-0}; // imm12
1970 def rs : AXI<(outs), (ins ldst_so_reg:$shift), MiscFrm, IIC_Preload,
1971 !strconcat(opc, "\t$shift"),
1972 [(ARMPreload ldst_so_reg:$shift, (i32 read), (i32 data))]>,
1973 Sched<[WritePreLd]> {
1975 let Inst{31-26} = 0b111101;
1976 let Inst{25} = 1; // 1 for register form
1977 let Inst{24} = data;
1978 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1979 let Inst{22} = read;
1980 let Inst{21-20} = 0b01;
1981 let Inst{19-16} = shift{16-13}; // Rn
1982 let Inst{15-12} = 0b1111;
1983 let Inst{11-0} = shift{11-0};
1988 defm PLD : APreLoad<1, 1, "pld">, Requires<[IsARM]>;
1989 defm PLDW : APreLoad<0, 1, "pldw">, Requires<[IsARM,HasV7,HasMP]>;
1990 defm PLI : APreLoad<1, 0, "pli">, Requires<[IsARM,HasV7]>;
1992 def SETEND : AXI<(outs), (ins setend_op:$end), MiscFrm, NoItinerary,
1993 "setend\t$end", []>, Requires<[IsARM]>, Deprecated<HasV8Ops> {
1995 let Inst{31-10} = 0b1111000100000001000000;
2000 def DBG : AI<(outs), (ins imm0_15:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt",
2001 [(int_arm_dbg imm0_15:$opt)]>, Requires<[IsARM, HasV7]> {
2003 let Inst{27-4} = 0b001100100000111100001111;
2004 let Inst{3-0} = opt;
2007 // A8.8.247 UDF - Undefined (Encoding A1)
2008 def UDF : AInoP<(outs), (ins imm0_65535:$imm16), MiscFrm, NoItinerary,
2009 "udf", "\t$imm16", [(int_arm_undefined imm0_65535:$imm16)]> {
2011 let Inst{31-28} = 0b1110; // AL
2012 let Inst{27-25} = 0b011;
2013 let Inst{24-20} = 0b11111;
2014 let Inst{19-8} = imm16{15-4};
2015 let Inst{7-4} = 0b1111;
2016 let Inst{3-0} = imm16{3-0};
2020 * A5.4 Permanently UNDEFINED instructions.
2022 * For most targets use UDF #65006, for which the OS will generate SIGTRAP.
2023 * Other UDF encodings generate SIGILL.
2025 * NaCl's OS instead chooses an ARM UDF encoding that's also a UDF in Thumb.
2027 * 1110 0111 1111 iiii iiii iiii 1111 iiii
2029 * 1101 1110 iiii iiii
2030 * It uses the following encoding:
2031 * 1110 0111 1111 1110 1101 1110 1111 0000
2032 * - In ARM: UDF #60896;
2033 * - In Thumb: UDF #254 followed by a branch-to-self.
2035 let isBarrier = 1, isTerminator = 1 in
2036 def TRAPNaCl : AXI<(outs), (ins), MiscFrm, NoItinerary,
2038 Requires<[IsARM,UseNaClTrap]> {
2039 let Inst = 0xe7fedef0;
2041 let isBarrier = 1, isTerminator = 1 in
2042 def TRAP : AXI<(outs), (ins), MiscFrm, NoItinerary,
2044 Requires<[IsARM,DontUseNaClTrap]> {
2045 let Inst = 0xe7ffdefe;
2048 // Address computation and loads and stores in PIC mode.
2049 let isNotDuplicable = 1 in {
2050 def PICADD : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
2052 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>,
2053 Sched<[WriteALU, ReadALU]>;
2055 let AddedComplexity = 10 in {
2056 def PICLDR : ARMPseudoInst<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
2058 [(set GPR:$dst, (load addrmodepc:$addr))]>;
2060 def PICLDRH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2062 [(set GPR:$Rt, (zextloadi16 addrmodepc:$addr))]>;
2064 def PICLDRB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2066 [(set GPR:$Rt, (zextloadi8 addrmodepc:$addr))]>;
2068 def PICLDRSH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2070 [(set GPR:$Rt, (sextloadi16 addrmodepc:$addr))]>;
2072 def PICLDRSB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2074 [(set GPR:$Rt, (sextloadi8 addrmodepc:$addr))]>;
2076 let AddedComplexity = 10 in {
2077 def PICSTR : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2078 4, IIC_iStore_r, [(store GPR:$src, addrmodepc:$addr)]>;
2080 def PICSTRH : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2081 4, IIC_iStore_bh_r, [(truncstorei16 GPR:$src,
2082 addrmodepc:$addr)]>;
2084 def PICSTRB : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2085 4, IIC_iStore_bh_r, [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
2087 } // isNotDuplicable = 1
2090 // LEApcrel - Load a pc-relative address into a register without offending the
2092 let hasSideEffects = 0, isReMaterializable = 1 in
2093 // The 'adr' mnemonic encodes differently if the label is before or after
2094 // the instruction. The {24-21} opcode bits are set by the fixup, as we don't
2095 // know until then which form of the instruction will be used.
2096 def ADR : AI1<{0,?,?,0}, (outs GPR:$Rd), (ins adrlabel:$label),
2097 MiscFrm, IIC_iALUi, "adr", "\t$Rd, $label", []>,
2098 Sched<[WriteALU, ReadALU]> {
2101 let Inst{27-25} = 0b001;
2103 let Inst{23-22} = label{13-12};
2106 let Inst{19-16} = 0b1111;
2107 let Inst{15-12} = Rd;
2108 let Inst{11-0} = label{11-0};
2111 let hasSideEffects = 1 in {
2112 def LEApcrel : ARMPseudoInst<(outs GPR:$Rd), (ins i32imm:$label, pred:$p),
2113 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
2115 def LEApcrelJT : ARMPseudoInst<(outs GPR:$Rd),
2116 (ins i32imm:$label, nohash_imm:$id, pred:$p),
2117 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
2120 //===----------------------------------------------------------------------===//
2121 // Control Flow Instructions.
2124 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
2126 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
2127 "bx", "\tlr", [(ARMretflag)]>,
2128 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2129 let Inst{27-0} = 0b0001001011111111111100011110;
2133 def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br,
2134 "mov", "\tpc, lr", [(ARMretflag)]>,
2135 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]> {
2136 let Inst{27-0} = 0b0001101000001111000000001110;
2139 // Exception return: N.b. doesn't set CPSR as far as we're concerned (it sets
2140 // the user-space one).
2141 def SUBS_PC_LR : ARMPseudoInst<(outs), (ins i32imm:$offset, pred:$p),
2143 [(ARMintretflag imm:$offset)]>;
2146 // Indirect branches
2147 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
2149 def BX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
2150 [(brind GPR:$dst)]>,
2151 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2153 let Inst{31-4} = 0b1110000100101111111111110001;
2154 let Inst{3-0} = dst;
2157 def BX_pred : AI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br,
2158 "bx", "\t$dst", [/* pattern left blank */]>,
2159 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2161 let Inst{27-4} = 0b000100101111111111110001;
2162 let Inst{3-0} = dst;
2166 // SP is marked as a use to prevent stack-pointer assignments that appear
2167 // immediately before calls from potentially appearing dead.
2169 // FIXME: Do we really need a non-predicated version? If so, it should
2170 // at least be a pseudo instruction expanding to the predicated version
2171 // at MC lowering time.
2172 Defs = [LR], Uses = [SP] in {
2173 def BL : ABXI<0b1011, (outs), (ins bl_target:$func),
2174 IIC_Br, "bl\t$func",
2175 [(ARMcall tglobaladdr:$func)]>,
2176 Requires<[IsARM]>, Sched<[WriteBrL]> {
2177 let Inst{31-28} = 0b1110;
2179 let Inst{23-0} = func;
2180 let DecoderMethod = "DecodeBranchImmInstruction";
2183 def BL_pred : ABI<0b1011, (outs), (ins bl_target:$func),
2184 IIC_Br, "bl", "\t$func",
2185 [(ARMcall_pred tglobaladdr:$func)]>,
2186 Requires<[IsARM]>, Sched<[WriteBrL]> {
2188 let Inst{23-0} = func;
2189 let DecoderMethod = "DecodeBranchImmInstruction";
2193 def BLX : AXI<(outs), (ins GPR:$func), BrMiscFrm,
2194 IIC_Br, "blx\t$func",
2195 [(ARMcall GPR:$func)]>,
2196 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2198 let Inst{31-4} = 0b1110000100101111111111110011;
2199 let Inst{3-0} = func;
2202 def BLX_pred : AI<(outs), (ins GPR:$func), BrMiscFrm,
2203 IIC_Br, "blx", "\t$func",
2204 [(ARMcall_pred GPR:$func)]>,
2205 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2207 let Inst{27-4} = 0b000100101111111111110011;
2208 let Inst{3-0} = func;
2212 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
2213 def BX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
2214 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
2215 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]>;
2218 def BMOVPCRX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
2219 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
2220 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
2222 // mov lr, pc; b if callee is marked noreturn to avoid confusing the
2223 // return stack predictor.
2224 def BMOVPCB_CALL : ARMPseudoInst<(outs), (ins bl_target:$func),
2225 8, IIC_Br, [(ARMcall_nolink tglobaladdr:$func)]>,
2226 Requires<[IsARM]>, Sched<[WriteBr]>;
2229 let isBranch = 1, isTerminator = 1 in {
2230 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
2231 // a two-value operand where a dag node expects two operands. :(
2232 def Bcc : ABI<0b1010, (outs), (ins br_target:$target),
2233 IIC_Br, "b", "\t$target",
2234 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>,
2237 let Inst{23-0} = target;
2238 let DecoderMethod = "DecodeBranchImmInstruction";
2241 let isBarrier = 1 in {
2242 // B is "predicable" since it's just a Bcc with an 'always' condition.
2243 let isPredicable = 1 in
2244 // FIXME: We shouldn't need this pseudo at all. Just using Bcc directly
2245 // should be sufficient.
2246 // FIXME: Is B really a Barrier? That doesn't seem right.
2247 def B : ARMPseudoExpand<(outs), (ins br_target:$target), 4, IIC_Br,
2248 [(br bb:$target)], (Bcc br_target:$target, (ops 14, zero_reg))>,
2251 let isNotDuplicable = 1, isIndirectBranch = 1 in {
2252 def BR_JTr : ARMPseudoInst<(outs),
2253 (ins GPR:$target, i32imm:$jt, i32imm:$id),
2255 [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]>,
2257 // FIXME: This shouldn't use the generic "addrmode2," but rather be split
2258 // into i12 and rs suffixed versions.
2259 def BR_JTm : ARMPseudoInst<(outs),
2260 (ins addrmode2:$target, i32imm:$jt, i32imm:$id),
2262 [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
2263 imm:$id)]>, Sched<[WriteBrTbl]>;
2264 def BR_JTadd : ARMPseudoInst<(outs),
2265 (ins GPR:$target, GPR:$idx, i32imm:$jt, i32imm:$id),
2267 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
2268 imm:$id)]>, Sched<[WriteBrTbl]>;
2269 } // isNotDuplicable = 1, isIndirectBranch = 1
2275 def BLXi : AXI<(outs), (ins blx_target:$target), BrMiscFrm, NoItinerary,
2276 "blx\t$target", []>,
2277 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2278 let Inst{31-25} = 0b1111101;
2280 let Inst{23-0} = target{24-1};
2281 let Inst{24} = target{0};
2284 // Branch and Exchange Jazelle
2285 def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func",
2286 [/* pattern left blank */]>, Sched<[WriteBr]> {
2288 let Inst{23-20} = 0b0010;
2289 let Inst{19-8} = 0xfff;
2290 let Inst{7-4} = 0b0010;
2291 let Inst{3-0} = func;
2296 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in {
2297 def TCRETURNdi : PseudoInst<(outs), (ins i32imm:$dst), IIC_Br, []>,
2300 def TCRETURNri : PseudoInst<(outs), (ins tcGPR:$dst), IIC_Br, []>,
2303 def TAILJMPd : ARMPseudoExpand<(outs), (ins br_target:$dst),
2305 (Bcc br_target:$dst, (ops 14, zero_reg))>,
2306 Requires<[IsARM]>, Sched<[WriteBr]>;
2308 def TAILJMPr : ARMPseudoExpand<(outs), (ins tcGPR:$dst),
2310 (BX GPR:$dst)>, Sched<[WriteBr]>,
2314 // Secure Monitor Call is a system instruction.
2315 def SMC : ABI<0b0001, (outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt",
2316 []>, Requires<[IsARM, HasTrustZone]> {
2318 let Inst{23-4} = 0b01100000000000000111;
2319 let Inst{3-0} = opt;
2322 // Supervisor Call (Software Interrupt)
2323 let isCall = 1, Uses = [SP] in {
2324 def SVC : ABI<0b1111, (outs), (ins imm24b:$svc), IIC_Br, "svc", "\t$svc", []>,
2327 let Inst{23-0} = svc;
2331 // Store Return State
2332 class SRSI<bit wb, string asm>
2333 : XI<(outs), (ins imm0_31:$mode), AddrModeNone, 4, IndexModeNone, BrFrm,
2334 NoItinerary, asm, "", []> {
2336 let Inst{31-28} = 0b1111;
2337 let Inst{27-25} = 0b100;
2341 let Inst{19-16} = 0b1101; // SP
2342 let Inst{15-5} = 0b00000101000;
2343 let Inst{4-0} = mode;
2346 def SRSDA : SRSI<0, "srsda\tsp, $mode"> {
2347 let Inst{24-23} = 0;
2349 def SRSDA_UPD : SRSI<1, "srsda\tsp!, $mode"> {
2350 let Inst{24-23} = 0;
2352 def SRSDB : SRSI<0, "srsdb\tsp, $mode"> {
2353 let Inst{24-23} = 0b10;
2355 def SRSDB_UPD : SRSI<1, "srsdb\tsp!, $mode"> {
2356 let Inst{24-23} = 0b10;
2358 def SRSIA : SRSI<0, "srsia\tsp, $mode"> {
2359 let Inst{24-23} = 0b01;
2361 def SRSIA_UPD : SRSI<1, "srsia\tsp!, $mode"> {
2362 let Inst{24-23} = 0b01;
2364 def SRSIB : SRSI<0, "srsib\tsp, $mode"> {
2365 let Inst{24-23} = 0b11;
2367 def SRSIB_UPD : SRSI<1, "srsib\tsp!, $mode"> {
2368 let Inst{24-23} = 0b11;
2371 def : ARMInstAlias<"srsda $mode", (SRSDA imm0_31:$mode)>;
2372 def : ARMInstAlias<"srsda $mode!", (SRSDA_UPD imm0_31:$mode)>;
2374 def : ARMInstAlias<"srsdb $mode", (SRSDB imm0_31:$mode)>;
2375 def : ARMInstAlias<"srsdb $mode!", (SRSDB_UPD imm0_31:$mode)>;
2377 def : ARMInstAlias<"srsia $mode", (SRSIA imm0_31:$mode)>;
2378 def : ARMInstAlias<"srsia $mode!", (SRSIA_UPD imm0_31:$mode)>;
2380 def : ARMInstAlias<"srsib $mode", (SRSIB imm0_31:$mode)>;
2381 def : ARMInstAlias<"srsib $mode!", (SRSIB_UPD imm0_31:$mode)>;
2383 // Return From Exception
2384 class RFEI<bit wb, string asm>
2385 : XI<(outs), (ins GPR:$Rn), AddrModeNone, 4, IndexModeNone, BrFrm,
2386 NoItinerary, asm, "", []> {
2388 let Inst{31-28} = 0b1111;
2389 let Inst{27-25} = 0b100;
2393 let Inst{19-16} = Rn;
2394 let Inst{15-0} = 0xa00;
2397 def RFEDA : RFEI<0, "rfeda\t$Rn"> {
2398 let Inst{24-23} = 0;
2400 def RFEDA_UPD : RFEI<1, "rfeda\t$Rn!"> {
2401 let Inst{24-23} = 0;
2403 def RFEDB : RFEI<0, "rfedb\t$Rn"> {
2404 let Inst{24-23} = 0b10;
2406 def RFEDB_UPD : RFEI<1, "rfedb\t$Rn!"> {
2407 let Inst{24-23} = 0b10;
2409 def RFEIA : RFEI<0, "rfeia\t$Rn"> {
2410 let Inst{24-23} = 0b01;
2412 def RFEIA_UPD : RFEI<1, "rfeia\t$Rn!"> {
2413 let Inst{24-23} = 0b01;
2415 def RFEIB : RFEI<0, "rfeib\t$Rn"> {
2416 let Inst{24-23} = 0b11;
2418 def RFEIB_UPD : RFEI<1, "rfeib\t$Rn!"> {
2419 let Inst{24-23} = 0b11;
2422 // Hypervisor Call is a system instruction
2424 def HVC : AInoP< (outs), (ins imm0_65535:$imm), BrFrm, NoItinerary,
2425 "hvc", "\t$imm", []>,
2426 Requires<[IsARM, HasVirtualization]> {
2429 // Even though HVC isn't predicable, it's encoding includes a condition field.
2430 // The instruction is undefined if the condition field is 0xf otherwise it is
2431 // unpredictable if it isn't condition AL (0xe).
2432 let Inst{31-28} = 0b1110;
2433 let Unpredictable{31-28} = 0b1111;
2434 let Inst{27-24} = 0b0001;
2435 let Inst{23-20} = 0b0100;
2436 let Inst{19-8} = imm{15-4};
2437 let Inst{7-4} = 0b0111;
2438 let Inst{3-0} = imm{3-0};
2442 // Return from exception in Hypervisor mode.
2443 let isReturn = 1, isBarrier = 1, isTerminator = 1, Defs = [PC] in
2444 def ERET : ABI<0b0001, (outs), (ins), NoItinerary, "eret", "", []>,
2445 Requires<[IsARM, HasVirtualization]> {
2446 let Inst{23-0} = 0b011000000000000001101110;
2449 //===----------------------------------------------------------------------===//
2450 // Load / Store Instructions.
2456 defm LDR : AI_ldr1<0, "ldr", IIC_iLoad_r, IIC_iLoad_si,
2457 UnOpFrag<(load node:$Src)>>;
2458 defm LDRB : AI_ldr1nopc<1, "ldrb", IIC_iLoad_bh_r, IIC_iLoad_bh_si,
2459 UnOpFrag<(zextloadi8 node:$Src)>>;
2460 defm STR : AI_str1<0, "str", IIC_iStore_r, IIC_iStore_si,
2461 BinOpFrag<(store node:$LHS, node:$RHS)>>;
2462 defm STRB : AI_str1nopc<1, "strb", IIC_iStore_bh_r, IIC_iStore_bh_si,
2463 BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
2465 // Special LDR for loads from non-pc-relative constpools.
2466 let canFoldAsLoad = 1, mayLoad = 1, hasSideEffects = 0,
2467 isReMaterializable = 1, isCodeGenOnly = 1 in
2468 def LDRcp : AI2ldst<0b010, 1, 0, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
2469 AddrMode_i12, LdFrm, IIC_iLoad_r, "ldr", "\t$Rt, $addr",
2473 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2474 let Inst{19-16} = 0b1111;
2475 let Inst{15-12} = Rt;
2476 let Inst{11-0} = addr{11-0}; // imm12
2479 // Loads with zero extension
2480 def LDRH : AI3ld<0b1011, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2481 IIC_iLoad_bh_r, "ldrh", "\t$Rt, $addr",
2482 [(set GPR:$Rt, (zextloadi16 addrmode3:$addr))]>;
2484 // Loads with sign extension
2485 def LDRSH : AI3ld<0b1111, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2486 IIC_iLoad_bh_r, "ldrsh", "\t$Rt, $addr",
2487 [(set GPR:$Rt, (sextloadi16 addrmode3:$addr))]>;
2489 def LDRSB : AI3ld<0b1101, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2490 IIC_iLoad_bh_r, "ldrsb", "\t$Rt, $addr",
2491 [(set GPR:$Rt, (sextloadi8 addrmode3:$addr))]>;
2493 let mayLoad = 1, hasSideEffects = 0, hasExtraDefRegAllocReq = 1 in {
2495 def LDRD : AI3ld<0b1101, 0, (outs GPR:$Rt, GPR:$Rt2), (ins addrmode3:$addr),
2496 LdMiscFrm, IIC_iLoad_d_r, "ldrd", "\t$Rt, $Rt2, $addr", []>,
2497 Requires<[IsARM, HasV5TE]>;
2500 def LDA : AIldracq<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2501 NoItinerary, "lda", "\t$Rt, $addr", []>;
2502 def LDAB : AIldracq<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2503 NoItinerary, "ldab", "\t$Rt, $addr", []>;
2504 def LDAH : AIldracq<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2505 NoItinerary, "ldah", "\t$Rt, $addr", []>;
2508 multiclass AI2_ldridx<bit isByte, string opc,
2509 InstrItinClass iii, InstrItinClass iir> {
2510 def _PRE_IMM : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2511 (ins addrmode_imm12_pre:$addr), IndexModePre, LdFrm, iii,
2512 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2515 let Inst{23} = addr{12};
2516 let Inst{19-16} = addr{16-13};
2517 let Inst{11-0} = addr{11-0};
2518 let DecoderMethod = "DecodeLDRPreImm";
2521 def _PRE_REG : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2522 (ins ldst_so_reg:$addr), IndexModePre, LdFrm, iir,
2523 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2526 let Inst{23} = addr{12};
2527 let Inst{19-16} = addr{16-13};
2528 let Inst{11-0} = addr{11-0};
2530 let DecoderMethod = "DecodeLDRPreReg";
2533 def _POST_REG : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2534 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2535 IndexModePost, LdFrm, iir,
2536 opc, "\t$Rt, $addr, $offset",
2537 "$addr.base = $Rn_wb", []> {
2543 let Inst{23} = offset{12};
2544 let Inst{19-16} = addr;
2545 let Inst{11-0} = offset{11-0};
2548 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2551 def _POST_IMM : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2552 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2553 IndexModePost, LdFrm, iii,
2554 opc, "\t$Rt, $addr, $offset",
2555 "$addr.base = $Rn_wb", []> {
2561 let Inst{23} = offset{12};
2562 let Inst{19-16} = addr;
2563 let Inst{11-0} = offset{11-0};
2565 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2570 let mayLoad = 1, hasSideEffects = 0 in {
2571 // FIXME: for LDR_PRE_REG etc. the itineray should be either IIC_iLoad_ru or
2572 // IIC_iLoad_siu depending on whether it the offset register is shifted.
2573 defm LDR : AI2_ldridx<0, "ldr", IIC_iLoad_iu, IIC_iLoad_ru>;
2574 defm LDRB : AI2_ldridx<1, "ldrb", IIC_iLoad_bh_iu, IIC_iLoad_bh_ru>;
2577 multiclass AI3_ldridx<bits<4> op, string opc, InstrItinClass itin> {
2578 def _PRE : AI3ldstidx<op, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2579 (ins addrmode3_pre:$addr), IndexModePre,
2581 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2583 let Inst{23} = addr{8}; // U bit
2584 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2585 let Inst{19-16} = addr{12-9}; // Rn
2586 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2587 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2588 let DecoderMethod = "DecodeAddrMode3Instruction";
2590 def _POST : AI3ldstidx<op, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2591 (ins addr_offset_none:$addr, am3offset:$offset),
2592 IndexModePost, LdMiscFrm, itin,
2593 opc, "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2597 let Inst{23} = offset{8}; // U bit
2598 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2599 let Inst{19-16} = addr;
2600 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2601 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2602 let DecoderMethod = "DecodeAddrMode3Instruction";
2606 let mayLoad = 1, hasSideEffects = 0 in {
2607 defm LDRH : AI3_ldridx<0b1011, "ldrh", IIC_iLoad_bh_ru>;
2608 defm LDRSH : AI3_ldridx<0b1111, "ldrsh", IIC_iLoad_bh_ru>;
2609 defm LDRSB : AI3_ldridx<0b1101, "ldrsb", IIC_iLoad_bh_ru>;
2610 let hasExtraDefRegAllocReq = 1 in {
2611 def LDRD_PRE : AI3ldstidx<0b1101, 0, 1, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2612 (ins addrmode3_pre:$addr), IndexModePre,
2613 LdMiscFrm, IIC_iLoad_d_ru,
2614 "ldrd", "\t$Rt, $Rt2, $addr!",
2615 "$addr.base = $Rn_wb", []> {
2617 let Inst{23} = addr{8}; // U bit
2618 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2619 let Inst{19-16} = addr{12-9}; // Rn
2620 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2621 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2622 let DecoderMethod = "DecodeAddrMode3Instruction";
2624 def LDRD_POST: AI3ldstidx<0b1101, 0, 0, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2625 (ins addr_offset_none:$addr, am3offset:$offset),
2626 IndexModePost, LdMiscFrm, IIC_iLoad_d_ru,
2627 "ldrd", "\t$Rt, $Rt2, $addr, $offset",
2628 "$addr.base = $Rn_wb", []> {
2631 let Inst{23} = offset{8}; // U bit
2632 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2633 let Inst{19-16} = addr;
2634 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2635 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2636 let DecoderMethod = "DecodeAddrMode3Instruction";
2638 } // hasExtraDefRegAllocReq = 1
2639 } // mayLoad = 1, hasSideEffects = 0
2641 // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT.
2642 let mayLoad = 1, hasSideEffects = 0 in {
2643 def LDRT_POST_REG : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2644 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2645 IndexModePost, LdFrm, IIC_iLoad_ru,
2646 "ldrt", "\t$Rt, $addr, $offset",
2647 "$addr.base = $Rn_wb", []> {
2653 let Inst{23} = offset{12};
2654 let Inst{21} = 1; // overwrite
2655 let Inst{19-16} = addr;
2656 let Inst{11-5} = offset{11-5};
2658 let Inst{3-0} = offset{3-0};
2659 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2663 : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2664 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2665 IndexModePost, LdFrm, IIC_iLoad_ru,
2666 "ldrt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2672 let Inst{23} = offset{12};
2673 let Inst{21} = 1; // overwrite
2674 let Inst{19-16} = addr;
2675 let Inst{11-0} = offset{11-0};
2676 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2679 def LDRBT_POST_REG : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2680 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2681 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2682 "ldrbt", "\t$Rt, $addr, $offset",
2683 "$addr.base = $Rn_wb", []> {
2689 let Inst{23} = offset{12};
2690 let Inst{21} = 1; // overwrite
2691 let Inst{19-16} = addr;
2692 let Inst{11-5} = offset{11-5};
2694 let Inst{3-0} = offset{3-0};
2695 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2699 : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2700 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2701 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2702 "ldrbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2708 let Inst{23} = offset{12};
2709 let Inst{21} = 1; // overwrite
2710 let Inst{19-16} = addr;
2711 let Inst{11-0} = offset{11-0};
2712 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2715 multiclass AI3ldrT<bits<4> op, string opc> {
2716 def i : AI3ldstidxT<op, 1, (outs GPR:$Rt, GPR:$base_wb),
2717 (ins addr_offset_none:$addr, postidx_imm8:$offset),
2718 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2719 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2721 let Inst{23} = offset{8};
2723 let Inst{11-8} = offset{7-4};
2724 let Inst{3-0} = offset{3-0};
2726 def r : AI3ldstidxT<op, 1, (outs GPRnopc:$Rt, GPRnopc:$base_wb),
2727 (ins addr_offset_none:$addr, postidx_reg:$Rm),
2728 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2729 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2731 let Inst{23} = Rm{4};
2734 let Unpredictable{11-8} = 0b1111;
2735 let Inst{3-0} = Rm{3-0};
2736 let DecoderMethod = "DecodeLDR";
2740 defm LDRSBT : AI3ldrT<0b1101, "ldrsbt">;
2741 defm LDRHT : AI3ldrT<0b1011, "ldrht">;
2742 defm LDRSHT : AI3ldrT<0b1111, "ldrsht">;
2746 : ARMAsmPseudo<"ldrt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q),
2750 : ARMAsmPseudo<"ldrbt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q),
2755 // Stores with truncate
2756 def STRH : AI3str<0b1011, (outs), (ins GPR:$Rt, addrmode3:$addr), StMiscFrm,
2757 IIC_iStore_bh_r, "strh", "\t$Rt, $addr",
2758 [(truncstorei16 GPR:$Rt, addrmode3:$addr)]>;
2761 let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
2762 def STRD : AI3str<0b1111, (outs), (ins GPR:$Rt, GPR:$Rt2, addrmode3:$addr),
2763 StMiscFrm, IIC_iStore_d_r, "strd", "\t$Rt, $Rt2, $addr", []>,
2764 Requires<[IsARM, HasV5TE]> {
2770 multiclass AI2_stridx<bit isByte, string opc,
2771 InstrItinClass iii, InstrItinClass iir> {
2772 def _PRE_IMM : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2773 (ins GPR:$Rt, addrmode_imm12_pre:$addr), IndexModePre,
2775 opc, "\t$Rt, $addr!",
2776 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2779 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2780 let Inst{19-16} = addr{16-13}; // Rn
2781 let Inst{11-0} = addr{11-0}; // imm12
2782 let DecoderMethod = "DecodeSTRPreImm";
2785 def _PRE_REG : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2786 (ins GPR:$Rt, ldst_so_reg:$addr),
2787 IndexModePre, StFrm, iir,
2788 opc, "\t$Rt, $addr!",
2789 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2792 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2793 let Inst{19-16} = addr{16-13}; // Rn
2794 let Inst{11-0} = addr{11-0};
2795 let Inst{4} = 0; // Inst{4} = 0
2796 let DecoderMethod = "DecodeSTRPreReg";
2798 def _POST_REG : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2799 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2800 IndexModePost, StFrm, iir,
2801 opc, "\t$Rt, $addr, $offset",
2802 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2808 let Inst{23} = offset{12};
2809 let Inst{19-16} = addr;
2810 let Inst{11-0} = offset{11-0};
2813 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2816 def _POST_IMM : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2817 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2818 IndexModePost, StFrm, iii,
2819 opc, "\t$Rt, $addr, $offset",
2820 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2826 let Inst{23} = offset{12};
2827 let Inst{19-16} = addr;
2828 let Inst{11-0} = offset{11-0};
2830 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2834 let mayStore = 1, hasSideEffects = 0 in {
2835 // FIXME: for STR_PRE_REG etc. the itineray should be either IIC_iStore_ru or
2836 // IIC_iStore_siu depending on whether it the offset register is shifted.
2837 defm STR : AI2_stridx<0, "str", IIC_iStore_iu, IIC_iStore_ru>;
2838 defm STRB : AI2_stridx<1, "strb", IIC_iStore_bh_iu, IIC_iStore_bh_ru>;
2841 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2842 am2offset_reg:$offset),
2843 (STR_POST_REG GPR:$Rt, addr_offset_none:$addr,
2844 am2offset_reg:$offset)>;
2845 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2846 am2offset_imm:$offset),
2847 (STR_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2848 am2offset_imm:$offset)>;
2849 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2850 am2offset_reg:$offset),
2851 (STRB_POST_REG GPR:$Rt, addr_offset_none:$addr,
2852 am2offset_reg:$offset)>;
2853 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2854 am2offset_imm:$offset),
2855 (STRB_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2856 am2offset_imm:$offset)>;
2858 // Pseudo-instructions for pattern matching the pre-indexed stores. We can't
2859 // put the patterns on the instruction definitions directly as ISel wants
2860 // the address base and offset to be separate operands, not a single
2861 // complex operand like we represent the instructions themselves. The
2862 // pseudos map between the two.
2863 let usesCustomInserter = 1,
2864 Constraints = "$Rn = $Rn_wb,@earlyclobber $Rn_wb" in {
2865 def STRi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2866 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2869 (pre_store GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2870 def STRr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2871 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2874 (pre_store GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2875 def STRBi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2876 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2879 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2880 def STRBr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2881 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2884 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2885 def STRH_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2886 (ins GPR:$Rt, GPR:$Rn, am3offset:$offset, pred:$p),
2889 (pre_truncsti16 GPR:$Rt, GPR:$Rn, am3offset:$offset))]>;
2894 def STRH_PRE : AI3ldstidx<0b1011, 0, 1, (outs GPR:$Rn_wb),
2895 (ins GPR:$Rt, addrmode3_pre:$addr), IndexModePre,
2896 StMiscFrm, IIC_iStore_bh_ru,
2897 "strh", "\t$Rt, $addr!",
2898 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2900 let Inst{23} = addr{8}; // U bit
2901 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2902 let Inst{19-16} = addr{12-9}; // Rn
2903 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2904 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2905 let DecoderMethod = "DecodeAddrMode3Instruction";
2908 def STRH_POST : AI3ldstidx<0b1011, 0, 0, (outs GPR:$Rn_wb),
2909 (ins GPR:$Rt, addr_offset_none:$addr, am3offset:$offset),
2910 IndexModePost, StMiscFrm, IIC_iStore_bh_ru,
2911 "strh", "\t$Rt, $addr, $offset",
2912 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb",
2913 [(set GPR:$Rn_wb, (post_truncsti16 GPR:$Rt,
2914 addr_offset_none:$addr,
2915 am3offset:$offset))]> {
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";
2926 let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
2927 def STRD_PRE : AI3ldstidx<0b1111, 0, 1, (outs GPR:$Rn_wb),
2928 (ins GPR:$Rt, GPR:$Rt2, addrmode3_pre:$addr),
2929 IndexModePre, StMiscFrm, IIC_iStore_d_ru,
2930 "strd", "\t$Rt, $Rt2, $addr!",
2931 "$addr.base = $Rn_wb", []> {
2933 let Inst{23} = addr{8}; // U bit
2934 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2935 let Inst{19-16} = addr{12-9}; // Rn
2936 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2937 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2938 let DecoderMethod = "DecodeAddrMode3Instruction";
2941 def STRD_POST: AI3ldstidx<0b1111, 0, 0, (outs GPR:$Rn_wb),
2942 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr,
2944 IndexModePost, StMiscFrm, IIC_iStore_d_ru,
2945 "strd", "\t$Rt, $Rt2, $addr, $offset",
2946 "$addr.base = $Rn_wb", []> {
2949 let Inst{23} = offset{8}; // U bit
2950 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2951 let Inst{19-16} = addr;
2952 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2953 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2954 let DecoderMethod = "DecodeAddrMode3Instruction";
2956 } // mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1
2958 // STRT, STRBT, and STRHT
2960 def STRBT_POST_REG : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2961 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2962 IndexModePost, StFrm, IIC_iStore_bh_ru,
2963 "strbt", "\t$Rt, $addr, $offset",
2964 "$addr.base = $Rn_wb", []> {
2970 let Inst{23} = offset{12};
2971 let Inst{21} = 1; // overwrite
2972 let Inst{19-16} = addr;
2973 let Inst{11-5} = offset{11-5};
2975 let Inst{3-0} = offset{3-0};
2976 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2980 : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2981 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2982 IndexModePost, StFrm, IIC_iStore_bh_ru,
2983 "strbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2989 let Inst{23} = offset{12};
2990 let Inst{21} = 1; // overwrite
2991 let Inst{19-16} = addr;
2992 let Inst{11-0} = offset{11-0};
2993 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2997 : ARMAsmPseudo<"strbt${q} $Rt, $addr",
2998 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>;
3000 let mayStore = 1, hasSideEffects = 0 in {
3001 def STRT_POST_REG : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
3002 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
3003 IndexModePost, StFrm, IIC_iStore_ru,
3004 "strt", "\t$Rt, $addr, $offset",
3005 "$addr.base = $Rn_wb", []> {
3011 let Inst{23} = offset{12};
3012 let Inst{21} = 1; // overwrite
3013 let Inst{19-16} = addr;
3014 let Inst{11-5} = offset{11-5};
3016 let Inst{3-0} = offset{3-0};
3017 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3021 : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
3022 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
3023 IndexModePost, StFrm, IIC_iStore_ru,
3024 "strt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
3030 let Inst{23} = offset{12};
3031 let Inst{21} = 1; // overwrite
3032 let Inst{19-16} = addr;
3033 let Inst{11-0} = offset{11-0};
3034 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3039 : ARMAsmPseudo<"strt${q} $Rt, $addr",
3040 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>;
3042 multiclass AI3strT<bits<4> op, string opc> {
3043 def i : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
3044 (ins GPR:$Rt, addr_offset_none:$addr, postidx_imm8:$offset),
3045 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
3046 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
3048 let Inst{23} = offset{8};
3050 let Inst{11-8} = offset{7-4};
3051 let Inst{3-0} = offset{3-0};
3053 def r : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
3054 (ins GPR:$Rt, addr_offset_none:$addr, postidx_reg:$Rm),
3055 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
3056 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
3058 let Inst{23} = Rm{4};
3061 let Inst{3-0} = Rm{3-0};
3066 defm STRHT : AI3strT<0b1011, "strht">;
3068 def STL : AIstrrel<0b00, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3069 NoItinerary, "stl", "\t$Rt, $addr", []>;
3070 def STLB : AIstrrel<0b10, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3071 NoItinerary, "stlb", "\t$Rt, $addr", []>;
3072 def STLH : AIstrrel<0b11, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3073 NoItinerary, "stlh", "\t$Rt, $addr", []>;
3075 //===----------------------------------------------------------------------===//
3076 // Load / store multiple Instructions.
3079 multiclass arm_ldst_mult<string asm, string sfx, bit L_bit, bit P_bit, Format f,
3080 InstrItinClass itin, InstrItinClass itin_upd> {
3081 // IA is the default, so no need for an explicit suffix on the
3082 // mnemonic here. Without it is the canonical spelling.
3084 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3085 IndexModeNone, f, itin,
3086 !strconcat(asm, "${p}\t$Rn, $regs", sfx), "", []> {
3087 let Inst{24-23} = 0b01; // Increment After
3088 let Inst{22} = P_bit;
3089 let Inst{21} = 0; // No writeback
3090 let Inst{20} = L_bit;
3093 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3094 IndexModeUpd, f, itin_upd,
3095 !strconcat(asm, "${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3096 let Inst{24-23} = 0b01; // Increment After
3097 let Inst{22} = P_bit;
3098 let Inst{21} = 1; // Writeback
3099 let Inst{20} = L_bit;
3101 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3104 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3105 IndexModeNone, f, itin,
3106 !strconcat(asm, "da${p}\t$Rn, $regs", sfx), "", []> {
3107 let Inst{24-23} = 0b00; // Decrement After
3108 let Inst{22} = P_bit;
3109 let Inst{21} = 0; // No writeback
3110 let Inst{20} = L_bit;
3113 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3114 IndexModeUpd, f, itin_upd,
3115 !strconcat(asm, "da${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3116 let Inst{24-23} = 0b00; // Decrement After
3117 let Inst{22} = P_bit;
3118 let Inst{21} = 1; // Writeback
3119 let Inst{20} = L_bit;
3121 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3124 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3125 IndexModeNone, f, itin,
3126 !strconcat(asm, "db${p}\t$Rn, $regs", sfx), "", []> {
3127 let Inst{24-23} = 0b10; // Decrement Before
3128 let Inst{22} = P_bit;
3129 let Inst{21} = 0; // No writeback
3130 let Inst{20} = L_bit;
3133 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3134 IndexModeUpd, f, itin_upd,
3135 !strconcat(asm, "db${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3136 let Inst{24-23} = 0b10; // Decrement Before
3137 let Inst{22} = P_bit;
3138 let Inst{21} = 1; // Writeback
3139 let Inst{20} = L_bit;
3141 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3144 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3145 IndexModeNone, f, itin,
3146 !strconcat(asm, "ib${p}\t$Rn, $regs", sfx), "", []> {
3147 let Inst{24-23} = 0b11; // Increment Before
3148 let Inst{22} = P_bit;
3149 let Inst{21} = 0; // No writeback
3150 let Inst{20} = L_bit;
3153 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3154 IndexModeUpd, f, itin_upd,
3155 !strconcat(asm, "ib${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3156 let Inst{24-23} = 0b11; // Increment Before
3157 let Inst{22} = P_bit;
3158 let Inst{21} = 1; // Writeback
3159 let Inst{20} = L_bit;
3161 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3165 let hasSideEffects = 0 in {
3167 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
3168 defm LDM : arm_ldst_mult<"ldm", "", 1, 0, LdStMulFrm, IIC_iLoad_m,
3171 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
3172 defm STM : arm_ldst_mult<"stm", "", 0, 0, LdStMulFrm, IIC_iStore_m,
3177 // FIXME: remove when we have a way to marking a MI with these properties.
3178 // FIXME: Should pc be an implicit operand like PICADD, etc?
3179 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
3180 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
3181 def LDMIA_RET : ARMPseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p,
3182 reglist:$regs, variable_ops),
3183 4, IIC_iLoad_mBr, [],
3184 (LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>,
3185 RegConstraint<"$Rn = $wb">;
3187 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
3188 defm sysLDM : arm_ldst_mult<"ldm", " ^", 1, 1, LdStMulFrm, IIC_iLoad_m,
3191 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
3192 defm sysSTM : arm_ldst_mult<"stm", " ^", 0, 1, LdStMulFrm, IIC_iStore_m,
3197 //===----------------------------------------------------------------------===//
3198 // Move Instructions.
3201 let hasSideEffects = 0 in
3202 def MOVr : AsI1<0b1101, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMOVr,
3203 "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> {
3207 let Inst{19-16} = 0b0000;
3208 let Inst{11-4} = 0b00000000;
3211 let Inst{15-12} = Rd;
3214 // A version for the smaller set of tail call registers.
3215 let hasSideEffects = 0 in
3216 def MOVr_TC : AsI1<0b1101, (outs tcGPR:$Rd), (ins tcGPR:$Rm), DPFrm,
3217 IIC_iMOVr, "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> {
3221 let Inst{11-4} = 0b00000000;
3224 let Inst{15-12} = Rd;
3227 def MOVsr : AsI1<0b1101, (outs GPRnopc:$Rd), (ins shift_so_reg_reg:$src),
3228 DPSoRegRegFrm, IIC_iMOVsr,
3229 "mov", "\t$Rd, $src",
3230 [(set GPRnopc:$Rd, shift_so_reg_reg:$src)]>, UnaryDP,
3234 let Inst{15-12} = Rd;
3235 let Inst{19-16} = 0b0000;
3236 let Inst{11-8} = src{11-8};
3238 let Inst{6-5} = src{6-5};
3240 let Inst{3-0} = src{3-0};
3244 def MOVsi : AsI1<0b1101, (outs GPR:$Rd), (ins shift_so_reg_imm:$src),
3245 DPSoRegImmFrm, IIC_iMOVsr,
3246 "mov", "\t$Rd, $src", [(set GPR:$Rd, shift_so_reg_imm:$src)]>,
3247 UnaryDP, Sched<[WriteALU]> {
3250 let Inst{15-12} = Rd;
3251 let Inst{19-16} = 0b0000;
3252 let Inst{11-5} = src{11-5};
3254 let Inst{3-0} = src{3-0};
3258 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3259 def MOVi : AsI1<0b1101, (outs GPR:$Rd), (ins mod_imm:$imm), DPFrm, IIC_iMOVi,
3260 "mov", "\t$Rd, $imm", [(set GPR:$Rd, mod_imm:$imm)]>, UnaryDP,
3265 let Inst{15-12} = Rd;
3266 let Inst{19-16} = 0b0000;
3267 let Inst{11-0} = imm;
3270 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3271 def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins imm0_65535_expr:$imm),
3273 "movw", "\t$Rd, $imm",
3274 [(set GPR:$Rd, imm0_65535:$imm)]>,
3275 Requires<[IsARM, HasV6T2]>, UnaryDP, Sched<[WriteALU]> {
3278 let Inst{15-12} = Rd;
3279 let Inst{11-0} = imm{11-0};
3280 let Inst{19-16} = imm{15-12};
3283 let DecoderMethod = "DecodeArmMOVTWInstruction";
3286 def : InstAlias<"mov${p} $Rd, $imm",
3287 (MOVi16 GPR:$Rd, imm0_65535_expr:$imm, pred:$p)>,
3290 def MOVi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
3291 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
3294 let Constraints = "$src = $Rd" in {
3295 def MOVTi16 : AI1<0b1010, (outs GPRnopc:$Rd),
3296 (ins GPR:$src, imm0_65535_expr:$imm),
3298 "movt", "\t$Rd, $imm",
3300 (or (and GPR:$src, 0xffff),
3301 lo16AllZero:$imm))]>, UnaryDP,
3302 Requires<[IsARM, HasV6T2]>, Sched<[WriteALU]> {
3305 let Inst{15-12} = Rd;
3306 let Inst{11-0} = imm{11-0};
3307 let Inst{19-16} = imm{15-12};
3310 let DecoderMethod = "DecodeArmMOVTWInstruction";
3313 def MOVTi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
3314 (ins GPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
3319 def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
3320 Requires<[IsARM, HasV6T2]>;
3322 let Uses = [CPSR] in
3323 def RRX: PseudoInst<(outs GPR:$Rd), (ins GPR:$Rm), IIC_iMOVsi,
3324 [(set GPR:$Rd, (ARMrrx GPR:$Rm))]>, UnaryDP,
3325 Requires<[IsARM]>, Sched<[WriteALU]>;
3327 // These aren't really mov instructions, but we have to define them this way
3328 // due to flag operands.
3330 let Defs = [CPSR] in {
3331 def MOVsrl_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3332 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP,
3333 Sched<[WriteALU]>, Requires<[IsARM]>;
3334 def MOVsra_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3335 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP,
3336 Sched<[WriteALU]>, Requires<[IsARM]>;
3339 //===----------------------------------------------------------------------===//
3340 // Extend Instructions.
3345 def SXTB : AI_ext_rrot<0b01101010,
3346 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
3347 def SXTH : AI_ext_rrot<0b01101011,
3348 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
3350 def SXTAB : AI_exta_rrot<0b01101010,
3351 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
3352 def SXTAH : AI_exta_rrot<0b01101011,
3353 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
3355 def SXTB16 : AI_ext_rrot_np<0b01101000, "sxtb16">;
3357 def SXTAB16 : AI_exta_rrot_np<0b01101000, "sxtab16">;
3361 let AddedComplexity = 16 in {
3362 def UXTB : AI_ext_rrot<0b01101110,
3363 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
3364 def UXTH : AI_ext_rrot<0b01101111,
3365 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
3366 def UXTB16 : AI_ext_rrot<0b01101100,
3367 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
3369 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
3370 // The transformation should probably be done as a combiner action
3371 // instead so we can include a check for masking back in the upper
3372 // eight bits of the source into the lower eight bits of the result.
3373 //def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
3374 // (UXTB16r_rot GPR:$Src, 3)>;
3375 def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
3376 (UXTB16 GPR:$Src, 1)>;
3378 def UXTAB : AI_exta_rrot<0b01101110, "uxtab",
3379 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
3380 def UXTAH : AI_exta_rrot<0b01101111, "uxtah",
3381 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
3384 // This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
3385 def UXTAB16 : AI_exta_rrot_np<0b01101100, "uxtab16">;
3388 def SBFX : I<(outs GPRnopc:$Rd),
3389 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3390 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3391 "sbfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3392 Requires<[IsARM, HasV6T2]> {
3397 let Inst{27-21} = 0b0111101;
3398 let Inst{6-4} = 0b101;
3399 let Inst{20-16} = width;
3400 let Inst{15-12} = Rd;
3401 let Inst{11-7} = lsb;
3405 def UBFX : I<(outs GPRnopc:$Rd),
3406 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3407 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3408 "ubfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3409 Requires<[IsARM, HasV6T2]> {
3414 let Inst{27-21} = 0b0111111;
3415 let Inst{6-4} = 0b101;
3416 let Inst{20-16} = width;
3417 let Inst{15-12} = Rd;
3418 let Inst{11-7} = lsb;
3422 //===----------------------------------------------------------------------===//
3423 // Arithmetic Instructions.
3426 defm ADD : AsI1_bin_irs<0b0100, "add",
3427 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3428 BinOpFrag<(add node:$LHS, node:$RHS)>, 1>;
3429 defm SUB : AsI1_bin_irs<0b0010, "sub",
3430 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3431 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
3433 // ADD and SUB with 's' bit set.
3435 // Currently, ADDS/SUBS are pseudo opcodes that exist only in the
3436 // selection DAG. They are "lowered" to real ADD/SUB opcodes by
3437 // AdjustInstrPostInstrSelection where we determine whether or not to
3438 // set the "s" bit based on CPSR liveness.
3440 // FIXME: Eliminate ADDS/SUBS pseudo opcodes after adding tablegen
3441 // support for an optional CPSR definition that corresponds to the DAG
3442 // node's second value. We can then eliminate the implicit def of CPSR.
3443 defm ADDS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3444 BinOpFrag<(ARMaddc node:$LHS, node:$RHS)>, 1>;
3445 defm SUBS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3446 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
3448 defm ADC : AI1_adde_sube_irs<0b0101, "adc",
3449 BinOpWithFlagFrag<(ARMadde node:$LHS, node:$RHS, node:$FLAG)>, 1>;
3450 defm SBC : AI1_adde_sube_irs<0b0110, "sbc",
3451 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>>;
3453 defm RSB : AsI1_rbin_irs<0b0011, "rsb",
3454 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3455 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
3457 // FIXME: Eliminate them if we can write def : Pat patterns which defines
3458 // CPSR and the implicit def of CPSR is not needed.
3459 defm RSBS : AsI1_rbin_s_is<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3460 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
3462 defm RSC : AI1_rsc_irs<0b0111, "rsc",
3463 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>>;
3465 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
3466 // The assume-no-carry-in form uses the negation of the input since add/sub
3467 // assume opposite meanings of the carry flag (i.e., carry == !borrow).
3468 // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
3470 def : ARMPat<(add GPR:$src, so_imm_neg:$imm),
3471 (SUBri GPR:$src, so_imm_neg:$imm)>;
3472 def : ARMPat<(ARMaddc GPR:$src, so_imm_neg:$imm),
3473 (SUBSri GPR:$src, so_imm_neg:$imm)>;
3475 def : ARMPat<(add GPR:$src, imm0_65535_neg:$imm),
3476 (SUBrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>,
3477 Requires<[IsARM, HasV6T2]>;
3478 def : ARMPat<(ARMaddc GPR:$src, imm0_65535_neg:$imm),
3479 (SUBSrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>,
3480 Requires<[IsARM, HasV6T2]>;
3482 // The with-carry-in form matches bitwise not instead of the negation.
3483 // Effectively, the inverse interpretation of the carry flag already accounts
3484 // for part of the negation.
3485 def : ARMPat<(ARMadde GPR:$src, so_imm_not:$imm, CPSR),
3486 (SBCri GPR:$src, so_imm_not:$imm)>;
3487 def : ARMPat<(ARMadde GPR:$src, imm0_65535_neg:$imm, CPSR),
3488 (SBCrr GPR:$src, (MOVi16 (imm_not_XFORM imm:$imm)))>,
3489 Requires<[IsARM, HasV6T2]>;
3491 // Note: These are implemented in C++ code, because they have to generate
3492 // ADD/SUBrs instructions, which use a complex pattern that a xform function
3494 // (mul X, 2^n+1) -> (add (X << n), X)
3495 // (mul X, 2^n-1) -> (rsb X, (X << n))
3497 // ARM Arithmetic Instruction
3498 // GPR:$dst = GPR:$a op GPR:$b
3499 class AAI<bits<8> op27_20, bits<8> op11_4, string opc,
3500 list<dag> pattern = [],
3501 dag iops = (ins GPRnopc:$Rn, GPRnopc:$Rm),
3502 string asm = "\t$Rd, $Rn, $Rm">
3503 : AI<(outs GPRnopc:$Rd), iops, DPFrm, IIC_iALUr, opc, asm, pattern>,
3504 Sched<[WriteALU, ReadALU, ReadALU]> {
3508 let Inst{27-20} = op27_20;
3509 let Inst{11-4} = op11_4;
3510 let Inst{19-16} = Rn;
3511 let Inst{15-12} = Rd;
3514 let Unpredictable{11-8} = 0b1111;
3517 // Saturating add/subtract
3519 let DecoderMethod = "DecodeQADDInstruction" in
3520 def QADD : AAI<0b00010000, 0b00000101, "qadd",
3521 [(set GPRnopc:$Rd, (int_arm_qadd GPRnopc:$Rm, GPRnopc:$Rn))],
3522 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3524 def QSUB : AAI<0b00010010, 0b00000101, "qsub",
3525 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm, GPRnopc:$Rn))],
3526 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3527 def QDADD : AAI<0b00010100, 0b00000101, "qdadd", [],
3528 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3530 def QDSUB : AAI<0b00010110, 0b00000101, "qdsub", [],
3531 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3534 def QADD16 : AAI<0b01100010, 0b11110001, "qadd16">;
3535 def QADD8 : AAI<0b01100010, 0b11111001, "qadd8">;
3536 def QASX : AAI<0b01100010, 0b11110011, "qasx">;
3537 def QSAX : AAI<0b01100010, 0b11110101, "qsax">;
3538 def QSUB16 : AAI<0b01100010, 0b11110111, "qsub16">;
3539 def QSUB8 : AAI<0b01100010, 0b11111111, "qsub8">;
3540 def UQADD16 : AAI<0b01100110, 0b11110001, "uqadd16">;
3541 def UQADD8 : AAI<0b01100110, 0b11111001, "uqadd8">;
3542 def UQASX : AAI<0b01100110, 0b11110011, "uqasx">;
3543 def UQSAX : AAI<0b01100110, 0b11110101, "uqsax">;
3544 def UQSUB16 : AAI<0b01100110, 0b11110111, "uqsub16">;
3545 def UQSUB8 : AAI<0b01100110, 0b11111111, "uqsub8">;
3547 // Signed/Unsigned add/subtract
3549 def SASX : AAI<0b01100001, 0b11110011, "sasx">;
3550 def SADD16 : AAI<0b01100001, 0b11110001, "sadd16">;
3551 def SADD8 : AAI<0b01100001, 0b11111001, "sadd8">;
3552 def SSAX : AAI<0b01100001, 0b11110101, "ssax">;
3553 def SSUB16 : AAI<0b01100001, 0b11110111, "ssub16">;
3554 def SSUB8 : AAI<0b01100001, 0b11111111, "ssub8">;
3555 def UASX : AAI<0b01100101, 0b11110011, "uasx">;
3556 def UADD16 : AAI<0b01100101, 0b11110001, "uadd16">;
3557 def UADD8 : AAI<0b01100101, 0b11111001, "uadd8">;
3558 def USAX : AAI<0b01100101, 0b11110101, "usax">;
3559 def USUB16 : AAI<0b01100101, 0b11110111, "usub16">;
3560 def USUB8 : AAI<0b01100101, 0b11111111, "usub8">;
3562 // Signed/Unsigned halving add/subtract
3564 def SHASX : AAI<0b01100011, 0b11110011, "shasx">;
3565 def SHADD16 : AAI<0b01100011, 0b11110001, "shadd16">;
3566 def SHADD8 : AAI<0b01100011, 0b11111001, "shadd8">;
3567 def SHSAX : AAI<0b01100011, 0b11110101, "shsax">;
3568 def SHSUB16 : AAI<0b01100011, 0b11110111, "shsub16">;
3569 def SHSUB8 : AAI<0b01100011, 0b11111111, "shsub8">;
3570 def UHASX : AAI<0b01100111, 0b11110011, "uhasx">;
3571 def UHADD16 : AAI<0b01100111, 0b11110001, "uhadd16">;
3572 def UHADD8 : AAI<0b01100111, 0b11111001, "uhadd8">;
3573 def UHSAX : AAI<0b01100111, 0b11110101, "uhsax">;
3574 def UHSUB16 : AAI<0b01100111, 0b11110111, "uhsub16">;
3575 def UHSUB8 : AAI<0b01100111, 0b11111111, "uhsub8">;
3577 // Unsigned Sum of Absolute Differences [and Accumulate].
3579 def USAD8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3580 MulFrm /* for convenience */, NoItinerary, "usad8",
3581 "\t$Rd, $Rn, $Rm", []>,
3582 Requires<[IsARM, HasV6]>, Sched<[WriteALU, ReadALU, ReadALU]> {
3586 let Inst{27-20} = 0b01111000;
3587 let Inst{15-12} = 0b1111;
3588 let Inst{7-4} = 0b0001;
3589 let Inst{19-16} = Rd;
3590 let Inst{11-8} = Rm;
3593 def USADA8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3594 MulFrm /* for convenience */, NoItinerary, "usada8",
3595 "\t$Rd, $Rn, $Rm, $Ra", []>,
3596 Requires<[IsARM, HasV6]>, Sched<[WriteALU, ReadALU, ReadALU]>{
3601 let Inst{27-20} = 0b01111000;
3602 let Inst{7-4} = 0b0001;
3603 let Inst{19-16} = Rd;
3604 let Inst{15-12} = Ra;
3605 let Inst{11-8} = Rm;
3609 // Signed/Unsigned saturate
3611 def SSAT : AI<(outs GPRnopc:$Rd),
3612 (ins imm1_32:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3613 SatFrm, NoItinerary, "ssat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3618 let Inst{27-21} = 0b0110101;
3619 let Inst{5-4} = 0b01;
3620 let Inst{20-16} = sat_imm;
3621 let Inst{15-12} = Rd;
3622 let Inst{11-7} = sh{4-0};
3623 let Inst{6} = sh{5};
3627 def SSAT16 : AI<(outs GPRnopc:$Rd),
3628 (ins imm1_16:$sat_imm, GPRnopc:$Rn), SatFrm,
3629 NoItinerary, "ssat16", "\t$Rd, $sat_imm, $Rn", []> {
3633 let Inst{27-20} = 0b01101010;
3634 let Inst{11-4} = 0b11110011;
3635 let Inst{15-12} = Rd;
3636 let Inst{19-16} = sat_imm;
3640 def USAT : AI<(outs GPRnopc:$Rd),
3641 (ins imm0_31:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3642 SatFrm, NoItinerary, "usat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3647 let Inst{27-21} = 0b0110111;
3648 let Inst{5-4} = 0b01;
3649 let Inst{15-12} = Rd;
3650 let Inst{11-7} = sh{4-0};
3651 let Inst{6} = sh{5};
3652 let Inst{20-16} = sat_imm;
3656 def USAT16 : AI<(outs GPRnopc:$Rd),
3657 (ins imm0_15:$sat_imm, GPRnopc:$Rn), SatFrm,
3658 NoItinerary, "usat16", "\t$Rd, $sat_imm, $Rn", []> {
3662 let Inst{27-20} = 0b01101110;
3663 let Inst{11-4} = 0b11110011;
3664 let Inst{15-12} = Rd;
3665 let Inst{19-16} = sat_imm;
3669 def : ARMV6Pat<(int_arm_ssat GPRnopc:$a, imm:$pos),
3670 (SSAT imm:$pos, GPRnopc:$a, 0)>;
3671 def : ARMV6Pat<(int_arm_usat GPRnopc:$a, imm:$pos),
3672 (USAT imm:$pos, GPRnopc:$a, 0)>;
3674 //===----------------------------------------------------------------------===//
3675 // Bitwise Instructions.
3678 defm AND : AsI1_bin_irs<0b0000, "and",
3679 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3680 BinOpFrag<(and node:$LHS, node:$RHS)>, 1>;
3681 defm ORR : AsI1_bin_irs<0b1100, "orr",
3682 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3683 BinOpFrag<(or node:$LHS, node:$RHS)>, 1>;
3684 defm EOR : AsI1_bin_irs<0b0001, "eor",
3685 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3686 BinOpFrag<(xor node:$LHS, node:$RHS)>, 1>;
3687 defm BIC : AsI1_bin_irs<0b1110, "bic",
3688 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3689 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
3691 // FIXME: bf_inv_mask_imm should be two operands, the lsb and the msb, just
3692 // like in the actual instruction encoding. The complexity of mapping the mask
3693 // to the lsb/msb pair should be handled by ISel, not encapsulated in the
3694 // instruction description.
3695 def BFC : I<(outs GPR:$Rd), (ins GPR:$src, bf_inv_mask_imm:$imm),
3696 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3697 "bfc", "\t$Rd, $imm", "$src = $Rd",
3698 [(set GPR:$Rd, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
3699 Requires<[IsARM, HasV6T2]> {
3702 let Inst{27-21} = 0b0111110;
3703 let Inst{6-0} = 0b0011111;
3704 let Inst{15-12} = Rd;
3705 let Inst{11-7} = imm{4-0}; // lsb
3706 let Inst{20-16} = imm{9-5}; // msb
3709 // A8.6.18 BFI - Bitfield insert (Encoding A1)
3710 def BFI:I<(outs GPRnopc:$Rd), (ins GPRnopc:$src, GPR:$Rn, bf_inv_mask_imm:$imm),
3711 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3712 "bfi", "\t$Rd, $Rn, $imm", "$src = $Rd",
3713 [(set GPRnopc:$Rd, (ARMbfi GPRnopc:$src, GPR:$Rn,
3714 bf_inv_mask_imm:$imm))]>,
3715 Requires<[IsARM, HasV6T2]> {
3719 let Inst{27-21} = 0b0111110;
3720 let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15
3721 let Inst{15-12} = Rd;
3722 let Inst{11-7} = imm{4-0}; // lsb
3723 let Inst{20-16} = imm{9-5}; // width
3727 def MVNr : AsI1<0b1111, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMVNr,
3728 "mvn", "\t$Rd, $Rm",
3729 [(set GPR:$Rd, (not GPR:$Rm))]>, UnaryDP, Sched<[WriteALU]> {
3733 let Inst{19-16} = 0b0000;
3734 let Inst{11-4} = 0b00000000;
3735 let Inst{15-12} = Rd;
3738 def MVNsi : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_imm:$shift),
3739 DPSoRegImmFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3740 [(set GPR:$Rd, (not so_reg_imm:$shift))]>, UnaryDP,
3745 let Inst{19-16} = 0b0000;
3746 let Inst{15-12} = Rd;
3747 let Inst{11-5} = shift{11-5};
3749 let Inst{3-0} = shift{3-0};
3751 def MVNsr : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_reg:$shift),
3752 DPSoRegRegFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3753 [(set GPR:$Rd, (not so_reg_reg:$shift))]>, UnaryDP,
3758 let Inst{19-16} = 0b0000;
3759 let Inst{15-12} = Rd;
3760 let Inst{11-8} = shift{11-8};
3762 let Inst{6-5} = shift{6-5};
3764 let Inst{3-0} = shift{3-0};
3766 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3767 def MVNi : AsI1<0b1111, (outs GPR:$Rd), (ins mod_imm:$imm), DPFrm,
3768 IIC_iMVNi, "mvn", "\t$Rd, $imm",
3769 [(set GPR:$Rd, mod_imm_not:$imm)]>,UnaryDP, Sched<[WriteALU]> {
3773 let Inst{19-16} = 0b0000;
3774 let Inst{15-12} = Rd;
3775 let Inst{11-0} = imm;
3778 def : ARMPat<(and GPR:$src, so_imm_not:$imm),
3779 (BICri GPR:$src, so_imm_not:$imm)>;
3781 //===----------------------------------------------------------------------===//
3782 // Multiply Instructions.
3784 class AsMul1I32<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3785 string opc, string asm, list<dag> pattern>
3786 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3790 let Inst{19-16} = Rd;
3791 let Inst{11-8} = Rm;
3794 class AsMul1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3795 string opc, string asm, list<dag> pattern>
3796 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3801 let Inst{19-16} = RdHi;
3802 let Inst{15-12} = RdLo;
3803 let Inst{11-8} = Rm;
3806 class AsMla1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3807 string opc, string asm, list<dag> pattern>
3808 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3813 let Inst{19-16} = RdHi;
3814 let Inst{15-12} = RdLo;
3815 let Inst{11-8} = Rm;
3819 // FIXME: The v5 pseudos are only necessary for the additional Constraint
3820 // property. Remove them when it's possible to add those properties
3821 // on an individual MachineInstr, not just an instruction description.
3822 let isCommutable = 1, TwoOperandAliasConstraint = "$Rn = $Rd" in {
3823 def MUL : AsMul1I32<0b0000000, (outs GPRnopc:$Rd),
3824 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3825 IIC_iMUL32, "mul", "\t$Rd, $Rn, $Rm",
3826 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))]>,
3827 Requires<[IsARM, HasV6]> {
3828 let Inst{15-12} = 0b0000;
3829 let Unpredictable{15-12} = 0b1111;
3832 let Constraints = "@earlyclobber $Rd" in
3833 def MULv5: ARMPseudoExpand<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm,
3834 pred:$p, cc_out:$s),
3836 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))],
3837 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s)>,
3838 Requires<[IsARM, NoV6, UseMulOps]>;
3841 def MLA : AsMul1I32<0b0000001, (outs GPRnopc:$Rd),
3842 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra),
3843 IIC_iMAC32, "mla", "\t$Rd, $Rn, $Rm, $Ra",
3844 [(set GPRnopc:$Rd, (add (mul GPRnopc:$Rn, GPRnopc:$Rm), GPRnopc:$Ra))]>,
3845 Requires<[IsARM, HasV6, UseMulOps]> {
3847 let Inst{15-12} = Ra;
3850 let Constraints = "@earlyclobber $Rd" in
3851 def MLAv5: ARMPseudoExpand<(outs GPRnopc:$Rd),
3852 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra,
3853 pred:$p, cc_out:$s), 4, IIC_iMAC32,
3854 [(set GPRnopc:$Rd, (add (mul GPRnopc:$Rn, GPRnopc:$Rm), GPRnopc:$Ra))],
3855 (MLA GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra, pred:$p, cc_out:$s)>,
3856 Requires<[IsARM, NoV6]>;
3858 def MLS : AMul1I<0b0000011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3859 IIC_iMAC32, "mls", "\t$Rd, $Rn, $Rm, $Ra",
3860 [(set GPR:$Rd, (sub GPR:$Ra, (mul GPR:$Rn, GPR:$Rm)))]>,
3861 Requires<[IsARM, HasV6T2, UseMulOps]> {
3866 let Inst{19-16} = Rd;
3867 let Inst{15-12} = Ra;
3868 let Inst{11-8} = Rm;
3872 // Extra precision multiplies with low / high results
3873 let hasSideEffects = 0 in {
3874 let isCommutable = 1 in {
3875 def SMULL : AsMul1I64<0b0000110, (outs GPR:$RdLo, GPR:$RdHi),
3876 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3877 "smull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3878 Requires<[IsARM, HasV6]>;
3880 def UMULL : AsMul1I64<0b0000100, (outs GPR:$RdLo, GPR:$RdHi),
3881 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3882 "umull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3883 Requires<[IsARM, HasV6]>;
3885 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
3886 def SMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3887 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3889 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3890 Requires<[IsARM, NoV6]>;
3892 def UMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3893 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3895 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3896 Requires<[IsARM, NoV6]>;
3900 // Multiply + accumulate
3901 def SMLAL : AsMla1I64<0b0000111, (outs GPR:$RdLo, GPR:$RdHi),
3902 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64,
3903 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3904 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>;
3905 def UMLAL : AsMla1I64<0b0000101, (outs GPR:$RdLo, GPR:$RdHi),
3906 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64,
3907 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3908 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>;
3910 def UMAAL : AMul1I <0b0000010, (outs GPR:$RdLo, GPR:$RdHi),
3911 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3912 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3913 Requires<[IsARM, HasV6]> {
3918 let Inst{19-16} = RdHi;
3919 let Inst{15-12} = RdLo;
3920 let Inst{11-8} = Rm;
3925 "@earlyclobber $RdLo,@earlyclobber $RdHi,$RLo = $RdLo,$RHi = $RdHi" in {
3926 def SMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3927 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s),
3929 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi,
3930 pred:$p, cc_out:$s)>,
3931 Requires<[IsARM, NoV6]>;
3932 def UMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3933 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s),
3935 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi,
3936 pred:$p, cc_out:$s)>,
3937 Requires<[IsARM, NoV6]>;
3942 // Most significant word multiply
3943 def SMMUL : AMul2I <0b0111010, 0b0001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3944 IIC_iMUL32, "smmul", "\t$Rd, $Rn, $Rm",
3945 [(set GPR:$Rd, (mulhs GPR:$Rn, GPR:$Rm))]>,
3946 Requires<[IsARM, HasV6]> {
3947 let Inst{15-12} = 0b1111;
3950 def SMMULR : AMul2I <0b0111010, 0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3951 IIC_iMUL32, "smmulr", "\t$Rd, $Rn, $Rm", []>,
3952 Requires<[IsARM, HasV6]> {
3953 let Inst{15-12} = 0b1111;
3956 def SMMLA : AMul2Ia <0b0111010, 0b0001, (outs GPR:$Rd),
3957 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3958 IIC_iMAC32, "smmla", "\t$Rd, $Rn, $Rm, $Ra",
3959 [(set GPR:$Rd, (add (mulhs GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
3960 Requires<[IsARM, HasV6, UseMulOps]>;
3962 def SMMLAR : AMul2Ia <0b0111010, 0b0011, (outs GPR:$Rd),
3963 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3964 IIC_iMAC32, "smmlar", "\t$Rd, $Rn, $Rm, $Ra", []>,
3965 Requires<[IsARM, HasV6]>;
3967 def SMMLS : AMul2Ia <0b0111010, 0b1101, (outs GPR:$Rd),
3968 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3969 IIC_iMAC32, "smmls", "\t$Rd, $Rn, $Rm, $Ra", []>,
3970 Requires<[IsARM, HasV6, UseMulOps]>;
3972 def SMMLSR : AMul2Ia <0b0111010, 0b1111, (outs GPR:$Rd),
3973 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3974 IIC_iMAC32, "smmlsr", "\t$Rd, $Rn, $Rm, $Ra", []>,
3975 Requires<[IsARM, HasV6]>;
3977 multiclass AI_smul<string opc, PatFrag opnode> {
3978 def BB : AMulxyI<0b0001011, 0b00, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3979 IIC_iMUL16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm",
3980 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3981 (sext_inreg GPR:$Rm, i16)))]>,
3982 Requires<[IsARM, HasV5TE]>;
3984 def BT : AMulxyI<0b0001011, 0b10, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3985 IIC_iMUL16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm",
3986 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3987 (sra GPR:$Rm, (i32 16))))]>,
3988 Requires<[IsARM, HasV5TE]>;
3990 def TB : AMulxyI<0b0001011, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3991 IIC_iMUL16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm",
3992 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3993 (sext_inreg GPR:$Rm, i16)))]>,
3994 Requires<[IsARM, HasV5TE]>;
3996 def TT : AMulxyI<0b0001011, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3997 IIC_iMUL16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm",
3998 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3999 (sra GPR:$Rm, (i32 16))))]>,
4000 Requires<[IsARM, HasV5TE]>;
4002 def WB : AMulxyI<0b0001001, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4003 IIC_iMUL16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm",
4005 Requires<[IsARM, HasV5TE]>;
4007 def WT : AMulxyI<0b0001001, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4008 IIC_iMUL16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm",
4010 Requires<[IsARM, HasV5TE]>;
4014 multiclass AI_smla<string opc, PatFrag opnode> {
4015 let DecoderMethod = "DecodeSMLAInstruction" in {
4016 def BB : AMulxyIa<0b0001000, 0b00, (outs GPRnopc:$Rd),
4017 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4018 IIC_iMAC16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra",
4019 [(set GPRnopc:$Rd, (add GPR:$Ra,
4020 (opnode (sext_inreg GPRnopc:$Rn, i16),
4021 (sext_inreg GPRnopc:$Rm, i16))))]>,
4022 Requires<[IsARM, HasV5TE, UseMulOps]>;
4024 def BT : AMulxyIa<0b0001000, 0b10, (outs GPRnopc:$Rd),
4025 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4026 IIC_iMAC16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra",
4028 (add GPR:$Ra, (opnode (sext_inreg GPRnopc:$Rn, i16),
4029 (sra GPRnopc:$Rm, (i32 16)))))]>,
4030 Requires<[IsARM, HasV5TE, UseMulOps]>;
4032 def TB : AMulxyIa<0b0001000, 0b01, (outs GPRnopc:$Rd),
4033 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4034 IIC_iMAC16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra",
4036 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
4037 (sext_inreg GPRnopc:$Rm, i16))))]>,
4038 Requires<[IsARM, HasV5TE, UseMulOps]>;
4040 def TT : AMulxyIa<0b0001000, 0b11, (outs GPRnopc:$Rd),
4041 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4042 IIC_iMAC16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra",
4044 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
4045 (sra GPRnopc:$Rm, (i32 16)))))]>,
4046 Requires<[IsARM, HasV5TE, UseMulOps]>;
4048 def WB : AMulxyIa<0b0001001, 0b00, (outs GPRnopc:$Rd),
4049 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4050 IIC_iMAC16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra",
4052 Requires<[IsARM, HasV5TE, UseMulOps]>;
4054 def WT : AMulxyIa<0b0001001, 0b10, (outs GPRnopc:$Rd),
4055 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4056 IIC_iMAC16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra",
4058 Requires<[IsARM, HasV5TE, UseMulOps]>;
4062 defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
4063 defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
4065 // Halfword multiply accumulate long: SMLAL<x><y>.
4066 def SMLALBB : AMulxyI64<0b0001010, 0b00, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4067 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4068 IIC_iMAC64, "smlalbb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4069 Requires<[IsARM, HasV5TE]>;
4071 def SMLALBT : AMulxyI64<0b0001010, 0b10, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4072 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4073 IIC_iMAC64, "smlalbt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4074 Requires<[IsARM, HasV5TE]>;
4076 def SMLALTB : AMulxyI64<0b0001010, 0b01, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4077 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4078 IIC_iMAC64, "smlaltb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4079 Requires<[IsARM, HasV5TE]>;
4081 def SMLALTT : AMulxyI64<0b0001010, 0b11, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4082 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4083 IIC_iMAC64, "smlaltt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4084 Requires<[IsARM, HasV5TE]>;
4086 // Helper class for AI_smld.
4087 class AMulDualIbase<bit long, bit sub, bit swap, dag oops, dag iops,
4088 InstrItinClass itin, string opc, string asm>
4089 : AI<oops, iops, MulFrm, itin, opc, asm, []>, Requires<[IsARM, HasV6]> {
4092 let Inst{27-23} = 0b01110;
4093 let Inst{22} = long;
4094 let Inst{21-20} = 0b00;
4095 let Inst{11-8} = Rm;
4102 class AMulDualI<bit long, bit sub, bit swap, dag oops, dag iops,
4103 InstrItinClass itin, string opc, string asm>
4104 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4106 let Inst{15-12} = 0b1111;
4107 let Inst{19-16} = Rd;
4109 class AMulDualIa<bit long, bit sub, bit swap, dag oops, dag iops,
4110 InstrItinClass itin, string opc, string asm>
4111 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4114 let Inst{19-16} = Rd;
4115 let Inst{15-12} = Ra;
4117 class AMulDualI64<bit long, bit sub, bit swap, dag oops, dag iops,
4118 InstrItinClass itin, string opc, string asm>
4119 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4122 let Inst{19-16} = RdHi;
4123 let Inst{15-12} = RdLo;
4126 multiclass AI_smld<bit sub, string opc> {
4128 def D : AMulDualIa<0, sub, 0, (outs GPRnopc:$Rd),
4129 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4130 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm, $Ra">;
4132 def DX: AMulDualIa<0, sub, 1, (outs GPRnopc:$Rd),
4133 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4134 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm, $Ra">;
4136 def LD: AMulDualI64<1, sub, 0, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4137 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
4138 !strconcat(opc, "ld"), "\t$RdLo, $RdHi, $Rn, $Rm">;
4140 def LDX : AMulDualI64<1, sub, 1, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4141 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
4142 !strconcat(opc, "ldx"),"\t$RdLo, $RdHi, $Rn, $Rm">;
4146 defm SMLA : AI_smld<0, "smla">;
4147 defm SMLS : AI_smld<1, "smls">;
4149 multiclass AI_sdml<bit sub, string opc> {
4151 def D:AMulDualI<0, sub, 0, (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm),
4152 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm">;
4153 def DX:AMulDualI<0, sub, 1, (outs GPRnopc:$Rd),(ins GPRnopc:$Rn, GPRnopc:$Rm),
4154 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm">;
4157 defm SMUA : AI_sdml<0, "smua">;
4158 defm SMUS : AI_sdml<1, "smus">;
4160 //===----------------------------------------------------------------------===//
4161 // Division Instructions (ARMv7-A with virtualization extension)
4163 def SDIV : ADivA1I<0b001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV,
4164 "sdiv", "\t$Rd, $Rn, $Rm",
4165 [(set GPR:$Rd, (sdiv GPR:$Rn, GPR:$Rm))]>,
4166 Requires<[IsARM, HasDivideInARM]>;
4168 def UDIV : ADivA1I<0b011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV,
4169 "udiv", "\t$Rd, $Rn, $Rm",
4170 [(set GPR:$Rd, (udiv GPR:$Rn, GPR:$Rm))]>,
4171 Requires<[IsARM, HasDivideInARM]>;
4173 //===----------------------------------------------------------------------===//
4174 // Misc. Arithmetic Instructions.
4177 def CLZ : AMiscA1I<0b00010110, 0b0001, (outs GPR:$Rd), (ins GPR:$Rm),
4178 IIC_iUNAr, "clz", "\t$Rd, $Rm",
4179 [(set GPR:$Rd, (ctlz GPR:$Rm))]>, Requires<[IsARM, HasV5T]>,
4182 def RBIT : AMiscA1I<0b01101111, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
4183 IIC_iUNAr, "rbit", "\t$Rd, $Rm",
4184 [(set GPR:$Rd, (ARMrbit GPR:$Rm))]>,
4185 Requires<[IsARM, HasV6T2]>,
4188 def REV : AMiscA1I<0b01101011, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
4189 IIC_iUNAr, "rev", "\t$Rd, $Rm",
4190 [(set GPR:$Rd, (bswap GPR:$Rm))]>, Requires<[IsARM, HasV6]>,
4193 let AddedComplexity = 5 in
4194 def REV16 : AMiscA1I<0b01101011, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
4195 IIC_iUNAr, "rev16", "\t$Rd, $Rm",
4196 [(set GPR:$Rd, (rotr (bswap GPR:$Rm), (i32 16)))]>,
4197 Requires<[IsARM, HasV6]>,
4200 def : ARMV6Pat<(srl (bswap (extloadi16 addrmode3:$addr)), (i32 16)),
4201 (REV16 (LDRH addrmode3:$addr))>;
4202 def : ARMV6Pat<(truncstorei16 (srl (bswap GPR:$Rn), (i32 16)), addrmode3:$addr),
4203 (STRH (REV16 GPR:$Rn), addrmode3:$addr)>;
4205 let AddedComplexity = 5 in
4206 def REVSH : AMiscA1I<0b01101111, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
4207 IIC_iUNAr, "revsh", "\t$Rd, $Rm",
4208 [(set GPR:$Rd, (sra (bswap GPR:$Rm), (i32 16)))]>,
4209 Requires<[IsARM, HasV6]>,
4212 def : ARMV6Pat<(or (sra (shl GPR:$Rm, (i32 24)), (i32 16)),
4213 (and (srl GPR:$Rm, (i32 8)), 0xFF)),
4216 def PKHBT : APKHI<0b01101000, 0, (outs GPRnopc:$Rd),
4217 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_lsl_amt:$sh),
4218 IIC_iALUsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh",
4219 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF),
4220 (and (shl GPRnopc:$Rm, pkh_lsl_amt:$sh),
4222 Requires<[IsARM, HasV6]>,
4223 Sched<[WriteALUsi, ReadALU]>;
4225 // Alternate cases for PKHBT where identities eliminate some nodes.
4226 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (and GPRnopc:$Rm, 0xFFFF0000)),
4227 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, 0)>;
4228 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (shl GPRnopc:$Rm, imm16_31:$sh)),
4229 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, imm16_31:$sh)>;
4231 // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
4232 // will match the pattern below.
4233 def PKHTB : APKHI<0b01101000, 1, (outs GPRnopc:$Rd),
4234 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_asr_amt:$sh),
4235 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh",
4236 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF0000),
4237 (and (sra GPRnopc:$Rm, pkh_asr_amt:$sh),
4239 Requires<[IsARM, HasV6]>,
4240 Sched<[WriteALUsi, ReadALU]>;
4242 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
4243 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
4244 // We also can not replace a srl (17..31) by an arithmetic shift we would use in
4245 // pkhtb src1, src2, asr (17..31).
4246 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4247 (srl GPRnopc:$src2, imm16:$sh)),
4248 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16:$sh)>;
4249 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4250 (sra GPRnopc:$src2, imm16_31:$sh)),
4251 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16_31:$sh)>;
4252 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4253 (and (srl GPRnopc:$src2, imm1_15:$sh), 0xFFFF)),
4254 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm1_15:$sh)>;
4256 //===----------------------------------------------------------------------===//
4260 // + CRC32{B,H,W} 0x04C11DB7
4261 // + CRC32C{B,H,W} 0x1EDC6F41
4264 class AI_crc32<bit C, bits<2> sz, string suffix, SDPatternOperator builtin>
4265 : AInoP<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm), MiscFrm, NoItinerary,
4266 !strconcat("crc32", suffix), "\t$Rd, $Rn, $Rm",
4267 [(set GPRnopc:$Rd, (builtin GPRnopc:$Rn, GPRnopc:$Rm))]>,
4268 Requires<[IsARM, HasV8, HasCRC]> {
4273 let Inst{31-28} = 0b1110;
4274 let Inst{27-23} = 0b00010;
4275 let Inst{22-21} = sz;
4277 let Inst{19-16} = Rn;
4278 let Inst{15-12} = Rd;
4279 let Inst{11-10} = 0b00;
4282 let Inst{7-4} = 0b0100;
4285 let Unpredictable{11-8} = 0b1101;
4288 def CRC32B : AI_crc32<0, 0b00, "b", int_arm_crc32b>;
4289 def CRC32CB : AI_crc32<1, 0b00, "cb", int_arm_crc32cb>;
4290 def CRC32H : AI_crc32<0, 0b01, "h", int_arm_crc32h>;
4291 def CRC32CH : AI_crc32<1, 0b01, "ch", int_arm_crc32ch>;
4292 def CRC32W : AI_crc32<0, 0b10, "w", int_arm_crc32w>;
4293 def CRC32CW : AI_crc32<1, 0b10, "cw", int_arm_crc32cw>;
4295 //===----------------------------------------------------------------------===//
4296 // Comparison Instructions...
4299 defm CMP : AI1_cmp_irs<0b1010, "cmp",
4300 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
4301 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
4303 // ARMcmpZ can re-use the above instruction definitions.
4304 def : ARMPat<(ARMcmpZ GPR:$src, so_imm:$imm),
4305 (CMPri GPR:$src, so_imm:$imm)>;
4306 def : ARMPat<(ARMcmpZ GPR:$src, GPR:$rhs),
4307 (CMPrr GPR:$src, GPR:$rhs)>;
4308 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_imm:$rhs),
4309 (CMPrsi GPR:$src, so_reg_imm:$rhs)>;
4310 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_reg:$rhs),
4311 (CMPrsr GPR:$src, so_reg_reg:$rhs)>;
4313 // CMN register-integer
4314 let isCompare = 1, Defs = [CPSR] in {
4315 def CMNri : AI1<0b1011, (outs), (ins GPR:$Rn, mod_imm:$imm), DPFrm, IIC_iCMPi,
4316 "cmn", "\t$Rn, $imm",
4317 [(ARMcmn GPR:$Rn, mod_imm:$imm)]>,
4318 Sched<[WriteCMP, ReadALU]> {
4323 let Inst{19-16} = Rn;
4324 let Inst{15-12} = 0b0000;
4325 let Inst{11-0} = imm;
4327 let Unpredictable{15-12} = 0b1111;
4330 // CMN register-register/shift
4331 def CMNzrr : AI1<0b1011, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, IIC_iCMPr,
4332 "cmn", "\t$Rn, $Rm",
4333 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4334 GPR:$Rn, GPR:$Rm)]>, Sched<[WriteCMP, ReadALU, ReadALU]> {
4337 let isCommutable = 1;
4340 let Inst{19-16} = Rn;
4341 let Inst{15-12} = 0b0000;
4342 let Inst{11-4} = 0b00000000;
4345 let Unpredictable{15-12} = 0b1111;
4348 def CMNzrsi : AI1<0b1011, (outs),
4349 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, IIC_iCMPsr,
4350 "cmn", "\t$Rn, $shift",
4351 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4352 GPR:$Rn, so_reg_imm:$shift)]>,
4353 Sched<[WriteCMPsi, ReadALU]> {
4358 let Inst{19-16} = Rn;
4359 let Inst{15-12} = 0b0000;
4360 let Inst{11-5} = shift{11-5};
4362 let Inst{3-0} = shift{3-0};
4364 let Unpredictable{15-12} = 0b1111;
4367 def CMNzrsr : AI1<0b1011, (outs),
4368 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, IIC_iCMPsr,
4369 "cmn", "\t$Rn, $shift",
4370 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4371 GPRnopc:$Rn, so_reg_reg:$shift)]>,
4372 Sched<[WriteCMPsr, ReadALU]> {
4377 let Inst{19-16} = Rn;
4378 let Inst{15-12} = 0b0000;
4379 let Inst{11-8} = shift{11-8};
4381 let Inst{6-5} = shift{6-5};
4383 let Inst{3-0} = shift{3-0};
4385 let Unpredictable{15-12} = 0b1111;
4390 def : ARMPat<(ARMcmp GPR:$src, so_imm_neg:$imm),
4391 (CMNri GPR:$src, so_imm_neg:$imm)>;
4393 def : ARMPat<(ARMcmpZ GPR:$src, so_imm_neg:$imm),
4394 (CMNri GPR:$src, so_imm_neg:$imm)>;
4396 // Note that TST/TEQ don't set all the same flags that CMP does!
4397 defm TST : AI1_cmp_irs<0b1000, "tst",
4398 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
4399 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>, 1>;
4400 defm TEQ : AI1_cmp_irs<0b1001, "teq",
4401 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
4402 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>, 1>;
4404 // Pseudo i64 compares for some floating point compares.
4405 let usesCustomInserter = 1, isBranch = 1, isTerminator = 1,
4407 def BCCi64 : PseudoInst<(outs),
4408 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, brtarget:$dst),
4410 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, bb:$dst)]>,
4413 def BCCZi64 : PseudoInst<(outs),
4414 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, brtarget:$dst), IIC_Br,
4415 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, 0, 0, bb:$dst)]>,
4417 } // usesCustomInserter
4420 // Conditional moves
4421 let hasSideEffects = 0 in {
4423 let isCommutable = 1, isSelect = 1 in
4424 def MOVCCr : ARMPseudoInst<(outs GPR:$Rd),
4425 (ins GPR:$false, GPR:$Rm, cmovpred:$p),
4427 [(set GPR:$Rd, (ARMcmov GPR:$false, GPR:$Rm,
4429 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4431 def MOVCCsi : ARMPseudoInst<(outs GPR:$Rd),
4432 (ins GPR:$false, so_reg_imm:$shift, cmovpred:$p),
4435 (ARMcmov GPR:$false, so_reg_imm:$shift,
4437 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4438 def MOVCCsr : ARMPseudoInst<(outs GPR:$Rd),
4439 (ins GPR:$false, so_reg_reg:$shift, cmovpred:$p),
4441 [(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_reg:$shift,
4443 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4446 let isMoveImm = 1 in
4448 : ARMPseudoInst<(outs GPR:$Rd),
4449 (ins GPR:$false, imm0_65535_expr:$imm, cmovpred:$p),
4451 [(set GPR:$Rd, (ARMcmov GPR:$false, imm0_65535:$imm,
4453 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>,
4456 let isMoveImm = 1 in
4457 def MOVCCi : ARMPseudoInst<(outs GPR:$Rd),
4458 (ins GPR:$false, so_imm:$imm, cmovpred:$p),
4460 [(set GPR:$Rd, (ARMcmov GPR:$false, so_imm:$imm,
4462 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4464 // Two instruction predicate mov immediate.
4465 let isMoveImm = 1 in
4467 : ARMPseudoInst<(outs GPR:$Rd),
4468 (ins GPR:$false, i32imm:$src, cmovpred:$p),
4470 [(set GPR:$Rd, (ARMcmov GPR:$false, imm:$src,
4472 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>;
4474 let isMoveImm = 1 in
4475 def MVNCCi : ARMPseudoInst<(outs GPR:$Rd),
4476 (ins GPR:$false, so_imm:$imm, cmovpred:$p),
4478 [(set GPR:$Rd, (ARMcmov GPR:$false, so_imm_not:$imm,
4480 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4485 //===----------------------------------------------------------------------===//
4486 // Atomic operations intrinsics
4489 def MemBarrierOptOperand : AsmOperandClass {
4490 let Name = "MemBarrierOpt";
4491 let ParserMethod = "parseMemBarrierOptOperand";
4493 def memb_opt : Operand<i32> {
4494 let PrintMethod = "printMemBOption";
4495 let ParserMatchClass = MemBarrierOptOperand;
4496 let DecoderMethod = "DecodeMemBarrierOption";
4499 def InstSyncBarrierOptOperand : AsmOperandClass {
4500 let Name = "InstSyncBarrierOpt";
4501 let ParserMethod = "parseInstSyncBarrierOptOperand";
4503 def instsyncb_opt : Operand<i32> {
4504 let PrintMethod = "printInstSyncBOption";
4505 let ParserMatchClass = InstSyncBarrierOptOperand;
4506 let DecoderMethod = "DecodeInstSyncBarrierOption";
4509 // Memory barriers protect the atomic sequences
4510 let hasSideEffects = 1 in {
4511 def DMB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4512 "dmb", "\t$opt", [(int_arm_dmb (i32 imm0_15:$opt))]>,
4513 Requires<[IsARM, HasDB]> {
4515 let Inst{31-4} = 0xf57ff05;
4516 let Inst{3-0} = opt;
4519 def DSB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4520 "dsb", "\t$opt", [(int_arm_dsb (i32 imm0_15:$opt))]>,
4521 Requires<[IsARM, HasDB]> {
4523 let Inst{31-4} = 0xf57ff04;
4524 let Inst{3-0} = opt;
4527 // ISB has only full system option
4528 def ISB : AInoP<(outs), (ins instsyncb_opt:$opt), MiscFrm, NoItinerary,
4529 "isb", "\t$opt", [(int_arm_isb (i32 imm0_15:$opt))]>,
4530 Requires<[IsARM, HasDB]> {
4532 let Inst{31-4} = 0xf57ff06;
4533 let Inst{3-0} = opt;
4537 let usesCustomInserter = 1, Defs = [CPSR] in {
4539 // Pseudo instruction that combines movs + predicated rsbmi
4540 // to implement integer ABS
4541 def ABS : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$src), 8, NoItinerary, []>;
4544 let usesCustomInserter = 1 in {
4545 def COPY_STRUCT_BYVAL_I32 : PseudoInst<
4546 (outs), (ins GPR:$dst, GPR:$src, i32imm:$size, i32imm:$alignment),
4548 [(ARMcopystructbyval GPR:$dst, GPR:$src, imm:$size, imm:$alignment)]>;
4551 def ldrex_1 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4552 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4555 def ldrex_2 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4556 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4559 def ldrex_4 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4560 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4563 def strex_1 : PatFrag<(ops node:$val, node:$ptr),
4564 (int_arm_strex node:$val, node:$ptr), [{
4565 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4568 def strex_2 : PatFrag<(ops node:$val, node:$ptr),
4569 (int_arm_strex node:$val, node:$ptr), [{
4570 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4573 def strex_4 : PatFrag<(ops node:$val, node:$ptr),
4574 (int_arm_strex node:$val, node:$ptr), [{
4575 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4578 def ldaex_1 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4579 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4582 def ldaex_2 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4583 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4586 def ldaex_4 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4587 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4590 def stlex_1 : PatFrag<(ops node:$val, node:$ptr),
4591 (int_arm_stlex node:$val, node:$ptr), [{
4592 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4595 def stlex_2 : PatFrag<(ops node:$val, node:$ptr),
4596 (int_arm_stlex node:$val, node:$ptr), [{
4597 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4600 def stlex_4 : PatFrag<(ops node:$val, node:$ptr),
4601 (int_arm_stlex node:$val, node:$ptr), [{
4602 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4605 let mayLoad = 1 in {
4606 def LDREXB : AIldrex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4607 NoItinerary, "ldrexb", "\t$Rt, $addr",
4608 [(set GPR:$Rt, (ldrex_1 addr_offset_none:$addr))]>;
4609 def LDREXH : AIldrex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4610 NoItinerary, "ldrexh", "\t$Rt, $addr",
4611 [(set GPR:$Rt, (ldrex_2 addr_offset_none:$addr))]>;
4612 def LDREX : AIldrex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4613 NoItinerary, "ldrex", "\t$Rt, $addr",
4614 [(set GPR:$Rt, (ldrex_4 addr_offset_none:$addr))]>;
4615 let hasExtraDefRegAllocReq = 1 in
4616 def LDREXD : AIldrex<0b01, (outs GPRPairOp:$Rt),(ins addr_offset_none:$addr),
4617 NoItinerary, "ldrexd", "\t$Rt, $addr", []> {
4618 let DecoderMethod = "DecodeDoubleRegLoad";
4621 def LDAEXB : AIldaex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4622 NoItinerary, "ldaexb", "\t$Rt, $addr",
4623 [(set GPR:$Rt, (ldaex_1 addr_offset_none:$addr))]>;
4624 def LDAEXH : AIldaex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4625 NoItinerary, "ldaexh", "\t$Rt, $addr",
4626 [(set GPR:$Rt, (ldaex_2 addr_offset_none:$addr))]>;
4627 def LDAEX : AIldaex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4628 NoItinerary, "ldaex", "\t$Rt, $addr",
4629 [(set GPR:$Rt, (ldaex_4 addr_offset_none:$addr))]>;
4630 let hasExtraDefRegAllocReq = 1 in
4631 def LDAEXD : AIldaex<0b01, (outs GPRPairOp:$Rt),(ins addr_offset_none:$addr),
4632 NoItinerary, "ldaexd", "\t$Rt, $addr", []> {
4633 let DecoderMethod = "DecodeDoubleRegLoad";
4637 let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
4638 def STREXB: AIstrex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4639 NoItinerary, "strexb", "\t$Rd, $Rt, $addr",
4640 [(set GPR:$Rd, (strex_1 GPR:$Rt,
4641 addr_offset_none:$addr))]>;
4642 def STREXH: AIstrex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4643 NoItinerary, "strexh", "\t$Rd, $Rt, $addr",
4644 [(set GPR:$Rd, (strex_2 GPR:$Rt,
4645 addr_offset_none:$addr))]>;
4646 def STREX : AIstrex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4647 NoItinerary, "strex", "\t$Rd, $Rt, $addr",
4648 [(set GPR:$Rd, (strex_4 GPR:$Rt,
4649 addr_offset_none:$addr))]>;
4650 let hasExtraSrcRegAllocReq = 1 in
4651 def STREXD : AIstrex<0b01, (outs GPR:$Rd),
4652 (ins GPRPairOp:$Rt, addr_offset_none:$addr),
4653 NoItinerary, "strexd", "\t$Rd, $Rt, $addr", []> {
4654 let DecoderMethod = "DecodeDoubleRegStore";
4656 def STLEXB: AIstlex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4657 NoItinerary, "stlexb", "\t$Rd, $Rt, $addr",
4659 (stlex_1 GPR:$Rt, addr_offset_none:$addr))]>;
4660 def STLEXH: AIstlex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4661 NoItinerary, "stlexh", "\t$Rd, $Rt, $addr",
4663 (stlex_2 GPR:$Rt, addr_offset_none:$addr))]>;
4664 def STLEX : AIstlex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4665 NoItinerary, "stlex", "\t$Rd, $Rt, $addr",
4667 (stlex_4 GPR:$Rt, addr_offset_none:$addr))]>;
4668 let hasExtraSrcRegAllocReq = 1 in
4669 def STLEXD : AIstlex<0b01, (outs GPR:$Rd),
4670 (ins GPRPairOp:$Rt, addr_offset_none:$addr),
4671 NoItinerary, "stlexd", "\t$Rd, $Rt, $addr", []> {
4672 let DecoderMethod = "DecodeDoubleRegStore";
4676 def CLREX : AXI<(outs), (ins), MiscFrm, NoItinerary, "clrex",
4678 Requires<[IsARM, HasV7]> {
4679 let Inst{31-0} = 0b11110101011111111111000000011111;
4682 def : ARMPat<(strex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr),
4683 (STREXB GPR:$Rt, addr_offset_none:$addr)>;
4684 def : ARMPat<(strex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr),
4685 (STREXH GPR:$Rt, addr_offset_none:$addr)>;
4687 def : ARMPat<(stlex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr),
4688 (STLEXB GPR:$Rt, addr_offset_none:$addr)>;
4689 def : ARMPat<(stlex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr),
4690 (STLEXH GPR:$Rt, addr_offset_none:$addr)>;
4692 class acquiring_load<PatFrag base>
4693 : PatFrag<(ops node:$ptr), (base node:$ptr), [{
4694 AtomicOrdering Ordering = cast<AtomicSDNode>(N)->getOrdering();
4695 return isAtLeastAcquire(Ordering);
4698 def atomic_load_acquire_8 : acquiring_load<atomic_load_8>;
4699 def atomic_load_acquire_16 : acquiring_load<atomic_load_16>;
4700 def atomic_load_acquire_32 : acquiring_load<atomic_load_32>;
4702 class releasing_store<PatFrag base>
4703 : PatFrag<(ops node:$ptr, node:$val), (base node:$ptr, node:$val), [{
4704 AtomicOrdering Ordering = cast<AtomicSDNode>(N)->getOrdering();
4705 return isAtLeastRelease(Ordering);
4708 def atomic_store_release_8 : releasing_store<atomic_store_8>;
4709 def atomic_store_release_16 : releasing_store<atomic_store_16>;
4710 def atomic_store_release_32 : releasing_store<atomic_store_32>;
4712 let AddedComplexity = 8 in {
4713 def : ARMPat<(atomic_load_acquire_8 addr_offset_none:$addr), (LDAB addr_offset_none:$addr)>;
4714 def : ARMPat<(atomic_load_acquire_16 addr_offset_none:$addr), (LDAH addr_offset_none:$addr)>;
4715 def : ARMPat<(atomic_load_acquire_32 addr_offset_none:$addr), (LDA addr_offset_none:$addr)>;
4716 def : ARMPat<(atomic_store_release_8 addr_offset_none:$addr, GPR:$val), (STLB GPR:$val, addr_offset_none:$addr)>;
4717 def : ARMPat<(atomic_store_release_16 addr_offset_none:$addr, GPR:$val), (STLH GPR:$val, addr_offset_none:$addr)>;
4718 def : ARMPat<(atomic_store_release_32 addr_offset_none:$addr, GPR:$val), (STL GPR:$val, addr_offset_none:$addr)>;
4721 // SWP/SWPB are deprecated in V6/V7.
4722 let mayLoad = 1, mayStore = 1 in {
4723 def SWP : AIswp<0, (outs GPRnopc:$Rt),
4724 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swp", []>,
4726 def SWPB: AIswp<1, (outs GPRnopc:$Rt),
4727 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swpb", []>,
4731 //===----------------------------------------------------------------------===//
4732 // Coprocessor Instructions.
4735 def CDP : ABI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4736 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4737 NoItinerary, "cdp", "\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4738 [(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4739 imm:$CRm, imm:$opc2)]>,
4748 let Inst{3-0} = CRm;
4750 let Inst{7-5} = opc2;
4751 let Inst{11-8} = cop;
4752 let Inst{15-12} = CRd;
4753 let Inst{19-16} = CRn;
4754 let Inst{23-20} = opc1;
4757 def CDP2 : ABXI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4758 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4759 NoItinerary, "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4760 [(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4761 imm:$CRm, imm:$opc2)]>,
4763 let Inst{31-28} = 0b1111;
4771 let Inst{3-0} = CRm;
4773 let Inst{7-5} = opc2;
4774 let Inst{11-8} = cop;
4775 let Inst{15-12} = CRd;
4776 let Inst{19-16} = CRn;
4777 let Inst{23-20} = opc1;
4780 class ACI<dag oops, dag iops, string opc, string asm,
4781 IndexMode im = IndexModeNone>
4782 : I<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
4784 let Inst{27-25} = 0b110;
4786 class ACInoP<dag oops, dag iops, string opc, string asm,
4787 IndexMode im = IndexModeNone>
4788 : InoP<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
4790 let Inst{31-28} = 0b1111;
4791 let Inst{27-25} = 0b110;
4793 multiclass LdStCop<bit load, bit Dbit, string asm> {
4794 def _OFFSET : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4795 asm, "\t$cop, $CRd, $addr"> {
4799 let Inst{24} = 1; // P = 1
4800 let Inst{23} = addr{8};
4801 let Inst{22} = Dbit;
4802 let Inst{21} = 0; // W = 0
4803 let Inst{20} = load;
4804 let Inst{19-16} = addr{12-9};
4805 let Inst{15-12} = CRd;
4806 let Inst{11-8} = cop;
4807 let Inst{7-0} = addr{7-0};
4808 let DecoderMethod = "DecodeCopMemInstruction";
4810 def _PRE : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr),
4811 asm, "\t$cop, $CRd, $addr!", IndexModePre> {
4815 let Inst{24} = 1; // P = 1
4816 let Inst{23} = addr{8};
4817 let Inst{22} = Dbit;
4818 let Inst{21} = 1; // W = 1
4819 let Inst{20} = load;
4820 let Inst{19-16} = addr{12-9};
4821 let Inst{15-12} = CRd;
4822 let Inst{11-8} = cop;
4823 let Inst{7-0} = addr{7-0};
4824 let DecoderMethod = "DecodeCopMemInstruction";
4826 def _POST: ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4827 postidx_imm8s4:$offset),
4828 asm, "\t$cop, $CRd, $addr, $offset", IndexModePost> {
4833 let Inst{24} = 0; // P = 0
4834 let Inst{23} = offset{8};
4835 let Inst{22} = Dbit;
4836 let Inst{21} = 1; // W = 1
4837 let Inst{20} = load;
4838 let Inst{19-16} = addr;
4839 let Inst{15-12} = CRd;
4840 let Inst{11-8} = cop;
4841 let Inst{7-0} = offset{7-0};
4842 let DecoderMethod = "DecodeCopMemInstruction";
4844 def _OPTION : ACI<(outs),
4845 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4846 coproc_option_imm:$option),
4847 asm, "\t$cop, $CRd, $addr, $option"> {
4852 let Inst{24} = 0; // P = 0
4853 let Inst{23} = 1; // U = 1
4854 let Inst{22} = Dbit;
4855 let Inst{21} = 0; // W = 0
4856 let Inst{20} = load;
4857 let Inst{19-16} = addr;
4858 let Inst{15-12} = CRd;
4859 let Inst{11-8} = cop;
4860 let Inst{7-0} = option;
4861 let DecoderMethod = "DecodeCopMemInstruction";
4864 multiclass LdSt2Cop<bit load, bit Dbit, string asm> {
4865 def _OFFSET : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4866 asm, "\t$cop, $CRd, $addr"> {
4870 let Inst{24} = 1; // P = 1
4871 let Inst{23} = addr{8};
4872 let Inst{22} = Dbit;
4873 let Inst{21} = 0; // W = 0
4874 let Inst{20} = load;
4875 let Inst{19-16} = addr{12-9};
4876 let Inst{15-12} = CRd;
4877 let Inst{11-8} = cop;
4878 let Inst{7-0} = addr{7-0};
4879 let DecoderMethod = "DecodeCopMemInstruction";
4881 def _PRE : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr),
4882 asm, "\t$cop, $CRd, $addr!", IndexModePre> {
4886 let Inst{24} = 1; // P = 1
4887 let Inst{23} = addr{8};
4888 let Inst{22} = Dbit;
4889 let Inst{21} = 1; // W = 1
4890 let Inst{20} = load;
4891 let Inst{19-16} = addr{12-9};
4892 let Inst{15-12} = CRd;
4893 let Inst{11-8} = cop;
4894 let Inst{7-0} = addr{7-0};
4895 let DecoderMethod = "DecodeCopMemInstruction";
4897 def _POST: ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4898 postidx_imm8s4:$offset),
4899 asm, "\t$cop, $CRd, $addr, $offset", IndexModePost> {
4904 let Inst{24} = 0; // P = 0
4905 let Inst{23} = offset{8};
4906 let Inst{22} = Dbit;
4907 let Inst{21} = 1; // W = 1
4908 let Inst{20} = load;
4909 let Inst{19-16} = addr;
4910 let Inst{15-12} = CRd;
4911 let Inst{11-8} = cop;
4912 let Inst{7-0} = offset{7-0};
4913 let DecoderMethod = "DecodeCopMemInstruction";
4915 def _OPTION : ACInoP<(outs),
4916 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4917 coproc_option_imm:$option),
4918 asm, "\t$cop, $CRd, $addr, $option"> {
4923 let Inst{24} = 0; // P = 0
4924 let Inst{23} = 1; // U = 1
4925 let Inst{22} = Dbit;
4926 let Inst{21} = 0; // W = 0
4927 let Inst{20} = load;
4928 let Inst{19-16} = addr;
4929 let Inst{15-12} = CRd;
4930 let Inst{11-8} = cop;
4931 let Inst{7-0} = option;
4932 let DecoderMethod = "DecodeCopMemInstruction";
4936 defm LDC : LdStCop <1, 0, "ldc">;
4937 defm LDCL : LdStCop <1, 1, "ldcl">;
4938 defm STC : LdStCop <0, 0, "stc">;
4939 defm STCL : LdStCop <0, 1, "stcl">;
4940 defm LDC2 : LdSt2Cop<1, 0, "ldc2">, Requires<[PreV8]>;
4941 defm LDC2L : LdSt2Cop<1, 1, "ldc2l">, Requires<[PreV8]>;
4942 defm STC2 : LdSt2Cop<0, 0, "stc2">, Requires<[PreV8]>;
4943 defm STC2L : LdSt2Cop<0, 1, "stc2l">, Requires<[PreV8]>;
4945 //===----------------------------------------------------------------------===//
4946 // Move between coprocessor and ARM core register.
4949 class MovRCopro<string opc, bit direction, dag oops, dag iops,
4951 : ABI<0b1110, oops, iops, NoItinerary, opc,
4952 "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2", pattern> {
4953 let Inst{20} = direction;
4963 let Inst{15-12} = Rt;
4964 let Inst{11-8} = cop;
4965 let Inst{23-21} = opc1;
4966 let Inst{7-5} = opc2;
4967 let Inst{3-0} = CRm;
4968 let Inst{19-16} = CRn;
4971 def MCR : MovRCopro<"mcr", 0 /* from ARM core register to coprocessor */,
4973 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4974 c_imm:$CRm, imm0_7:$opc2),
4975 [(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
4976 imm:$CRm, imm:$opc2)]>,
4977 ComplexDeprecationPredicate<"MCR">;
4978 def : ARMInstAlias<"mcr${p} $cop, $opc1, $Rt, $CRn, $CRm",
4979 (MCR p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4980 c_imm:$CRm, 0, pred:$p)>;
4981 def MRC : MovRCopro<"mrc", 1 /* from coprocessor to ARM core register */,
4982 (outs GPRwithAPSR:$Rt),
4983 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
4985 def : ARMInstAlias<"mrc${p} $cop, $opc1, $Rt, $CRn, $CRm",
4986 (MRC GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
4987 c_imm:$CRm, 0, pred:$p)>;
4989 def : ARMPat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
4990 (MRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
4992 class MovRCopro2<string opc, bit direction, dag oops, dag iops,
4994 : ABXI<0b1110, oops, iops, NoItinerary,
4995 !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), pattern> {
4996 let Inst{31-24} = 0b11111110;
4997 let Inst{20} = direction;
5007 let Inst{15-12} = Rt;
5008 let Inst{11-8} = cop;
5009 let Inst{23-21} = opc1;
5010 let Inst{7-5} = opc2;
5011 let Inst{3-0} = CRm;
5012 let Inst{19-16} = CRn;
5015 def MCR2 : MovRCopro2<"mcr2", 0 /* from ARM core register to coprocessor */,
5017 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5018 c_imm:$CRm, imm0_7:$opc2),
5019 [(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
5020 imm:$CRm, imm:$opc2)]>,
5022 def : ARMInstAlias<"mcr2 $cop, $opc1, $Rt, $CRn, $CRm",
5023 (MCR2 p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5025 def MRC2 : MovRCopro2<"mrc2", 1 /* from coprocessor to ARM core register */,
5026 (outs GPRwithAPSR:$Rt),
5027 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
5030 def : ARMInstAlias<"mrc2 $cop, $opc1, $Rt, $CRn, $CRm",
5031 (MRC2 GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
5034 def : ARMV5TPat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn,
5035 imm:$CRm, imm:$opc2),
5036 (MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
5038 class MovRRCopro<string opc, bit direction, list<dag> pattern = []>
5039 : ABI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
5040 GPRnopc:$Rt, GPRnopc:$Rt2, c_imm:$CRm),
5041 NoItinerary, opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm", pattern> {
5042 let Inst{23-21} = 0b010;
5043 let Inst{20} = direction;
5051 let Inst{15-12} = Rt;
5052 let Inst{19-16} = Rt2;
5053 let Inst{11-8} = cop;
5054 let Inst{7-4} = opc1;
5055 let Inst{3-0} = CRm;
5058 def MCRR : MovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */,
5059 [(int_arm_mcrr imm:$cop, imm:$opc1, GPRnopc:$Rt,
5060 GPRnopc:$Rt2, imm:$CRm)]>;
5061 def MRRC : MovRRCopro<"mrrc", 1 /* from coprocessor to ARM core register */>;
5063 class MovRRCopro2<string opc, bit direction, list<dag> pattern = []>
5064 : ABXI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
5065 GPRnopc:$Rt, GPRnopc:$Rt2, c_imm:$CRm), NoItinerary,
5066 !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern>,
5068 let Inst{31-28} = 0b1111;
5069 let Inst{23-21} = 0b010;
5070 let Inst{20} = direction;
5078 let Inst{15-12} = Rt;
5079 let Inst{19-16} = Rt2;
5080 let Inst{11-8} = cop;
5081 let Inst{7-4} = opc1;
5082 let Inst{3-0} = CRm;
5084 let DecoderMethod = "DecodeMRRC2";
5087 def MCRR2 : MovRRCopro2<"mcrr2", 0 /* from ARM core register to coprocessor */,
5088 [(int_arm_mcrr2 imm:$cop, imm:$opc1, GPRnopc:$Rt,
5089 GPRnopc:$Rt2, imm:$CRm)]>;
5090 def MRRC2 : MovRRCopro2<"mrrc2", 1 /* from coprocessor to ARM core register */>;
5092 //===----------------------------------------------------------------------===//
5093 // Move between special register and ARM core register
5096 // Move to ARM core register from Special Register
5097 def MRS : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
5098 "mrs", "\t$Rd, apsr", []> {
5100 let Inst{23-16} = 0b00001111;
5101 let Unpredictable{19-17} = 0b111;
5103 let Inst{15-12} = Rd;
5105 let Inst{11-0} = 0b000000000000;
5106 let Unpredictable{11-0} = 0b110100001111;
5109 def : InstAlias<"mrs${p} $Rd, cpsr", (MRS GPRnopc:$Rd, pred:$p)>,
5112 // The MRSsys instruction is the MRS instruction from the ARM ARM,
5113 // section B9.3.9, with the R bit set to 1.
5114 def MRSsys : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
5115 "mrs", "\t$Rd, spsr", []> {
5117 let Inst{23-16} = 0b01001111;
5118 let Unpredictable{19-16} = 0b1111;
5120 let Inst{15-12} = Rd;
5122 let Inst{11-0} = 0b000000000000;
5123 let Unpredictable{11-0} = 0b110100001111;
5126 // However, the MRS (banked register) system instruction (ARMv7VE) *does* have a
5127 // separate encoding (distinguished by bit 5.
5128 def MRSbanked : ABI<0b0001, (outs GPRnopc:$Rd), (ins banked_reg:$banked),
5129 NoItinerary, "mrs", "\t$Rd, $banked", []>,
5130 Requires<[IsARM, HasVirtualization]> {
5135 let Inst{22} = banked{5}; // R bit
5136 let Inst{21-20} = 0b00;
5137 let Inst{19-16} = banked{3-0};
5138 let Inst{15-12} = Rd;
5139 let Inst{11-9} = 0b001;
5140 let Inst{8} = banked{4};
5141 let Inst{7-0} = 0b00000000;
5144 // Move from ARM core register to Special Register
5146 // No need to have both system and application versions of MSR (immediate) or
5147 // MSR (register), the encodings are the same and the assembly parser has no way
5148 // to distinguish between them. The mask operand contains the special register
5149 // (R Bit) in bit 4 and bits 3-0 contains the mask with the fields to be
5150 // accessed in the special register.
5151 def MSR : ABI<0b0001, (outs), (ins msr_mask:$mask, GPR:$Rn), NoItinerary,
5152 "msr", "\t$mask, $Rn", []> {
5157 let Inst{22} = mask{4}; // R bit
5158 let Inst{21-20} = 0b10;
5159 let Inst{19-16} = mask{3-0};
5160 let Inst{15-12} = 0b1111;
5161 let Inst{11-4} = 0b00000000;
5165 def MSRi : ABI<0b0011, (outs), (ins msr_mask:$mask, mod_imm:$imm), NoItinerary,
5166 "msr", "\t$mask, $imm", []> {
5171 let Inst{22} = mask{4}; // R bit
5172 let Inst{21-20} = 0b10;
5173 let Inst{19-16} = mask{3-0};
5174 let Inst{15-12} = 0b1111;
5175 let Inst{11-0} = imm;
5178 // However, the MSR (banked register) system instruction (ARMv7VE) *does* have a
5179 // separate encoding (distinguished by bit 5.
5180 def MSRbanked : ABI<0b0001, (outs), (ins banked_reg:$banked, GPRnopc:$Rn),
5181 NoItinerary, "msr", "\t$banked, $Rn", []>,
5182 Requires<[IsARM, HasVirtualization]> {
5187 let Inst{22} = banked{5}; // R bit
5188 let Inst{21-20} = 0b10;
5189 let Inst{19-16} = banked{3-0};
5190 let Inst{15-12} = 0b1111;
5191 let Inst{11-9} = 0b001;
5192 let Inst{8} = banked{4};
5193 let Inst{7-4} = 0b0000;
5197 // Dynamic stack allocation yields a _chkstk for Windows targets. These calls
5198 // are needed to probe the stack when allocating more than
5199 // 4k bytes in one go. Touching the stack at 4K increments is necessary to
5200 // ensure that the guard pages used by the OS virtual memory manager are
5201 // allocated in correct sequence.
5202 // The main point of having separate instruction are extra unmodelled effects
5203 // (compared to ordinary calls) like stack pointer change.
5205 def win__chkstk : SDNode<"ARMISD::WIN__CHKSTK", SDTNone,
5206 [SDNPHasChain, SDNPSideEffect]>;
5207 let usesCustomInserter = 1, Uses = [R4], Defs = [R4, SP] in
5208 def WIN__CHKSTK : PseudoInst<(outs), (ins), NoItinerary, [(win__chkstk)]>;
5210 //===----------------------------------------------------------------------===//
5214 // __aeabi_read_tp preserves the registers r1-r3.
5215 // This is a pseudo inst so that we can get the encoding right,
5216 // complete with fixup for the aeabi_read_tp function.
5217 // TPsoft is valid for ARM mode only, in case of Thumb mode a tTPsoft pattern
5218 // is defined in "ARMInstrThumb.td".
5220 Defs = [R0, R12, LR, CPSR], Uses = [SP] in {
5221 def TPsoft : ARMPseudoInst<(outs), (ins), 4, IIC_Br,
5222 [(set R0, ARMthread_pointer)]>, Sched<[WriteBr]>;
5225 //===----------------------------------------------------------------------===//
5226 // SJLJ Exception handling intrinsics
5227 // eh_sjlj_setjmp() is an instruction sequence to store the return
5228 // address and save #0 in R0 for the non-longjmp case.
5229 // Since by its nature we may be coming from some other function to get
5230 // here, and we're using the stack frame for the containing function to
5231 // save/restore registers, we can't keep anything live in regs across
5232 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
5233 // when we get here from a longjmp(). We force everything out of registers
5234 // except for our own input by listing the relevant registers in Defs. By
5235 // doing so, we also cause the prologue/epilogue code to actively preserve
5236 // all of the callee-saved resgisters, which is exactly what we want.
5237 // A constant value is passed in $val, and we use the location as a scratch.
5239 // These are pseudo-instructions and are lowered to individual MC-insts, so
5240 // no encoding information is necessary.
5242 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
5243 Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15 ],
5244 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
5245 def Int_eh_sjlj_setjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
5247 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
5248 Requires<[IsARM, HasVFP2]>;
5252 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
5253 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
5254 def Int_eh_sjlj_setjmp_nofp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
5256 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
5257 Requires<[IsARM, NoVFP]>;
5260 // FIXME: Non-IOS version(s)
5261 let isBarrier = 1, hasSideEffects = 1, isTerminator = 1,
5262 Defs = [ R7, LR, SP ] in {
5263 def Int_eh_sjlj_longjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$scratch),
5265 [(ARMeh_sjlj_longjmp GPR:$src, GPR:$scratch)]>,
5266 Requires<[IsARM, IsIOS]>;
5269 // eh.sjlj.dispatchsetup pseudo-instruction.
5270 // This pseudo is used for both ARM and Thumb. Any differences are handled when
5271 // the pseudo is expanded (which happens before any passes that need the
5272 // instruction size).
5273 let isBarrier = 1 in
5274 def Int_eh_sjlj_dispatchsetup : PseudoInst<(outs), (ins), NoItinerary, []>;
5277 //===----------------------------------------------------------------------===//
5278 // Non-Instruction Patterns
5281 // ARMv4 indirect branch using (MOVr PC, dst)
5282 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in
5283 def MOVPCRX : ARMPseudoExpand<(outs), (ins GPR:$dst),
5284 4, IIC_Br, [(brind GPR:$dst)],
5285 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>,
5286 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
5288 // Large immediate handling.
5290 // 32-bit immediate using two piece so_imms or movw + movt.
5291 // This is a single pseudo instruction, the benefit is that it can be remat'd
5292 // as a single unit instead of having to handle reg inputs.
5293 // FIXME: Remove this when we can do generalized remat.
5294 let isReMaterializable = 1, isMoveImm = 1 in
5295 def MOVi32imm : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
5296 [(set GPR:$dst, (arm_i32imm:$src))]>,
5299 def LDRLIT_ga_abs : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iLoad_i,
5300 [(set GPR:$dst, (ARMWrapper tglobaladdr:$src))]>,
5301 Requires<[IsARM, DontUseMovt]>;
5303 // Pseudo instruction that combines movw + movt + add pc (if PIC).
5304 // It also makes it possible to rematerialize the instructions.
5305 // FIXME: Remove this when we can do generalized remat and when machine licm
5306 // can properly the instructions.
5307 let isReMaterializable = 1 in {
5308 def MOV_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5310 [(set GPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>,
5311 Requires<[IsARM, UseMovt]>;
5313 def LDRLIT_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5316 (ARMWrapperPIC tglobaladdr:$addr))]>,
5317 Requires<[IsARM, DontUseMovt]>;
5319 def LDRLIT_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5322 (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
5323 Requires<[IsARM, DontUseMovt]>;
5325 let AddedComplexity = 10 in
5326 def MOV_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5328 [(set GPR:$dst, (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
5329 Requires<[IsARM, UseMovt]>;
5330 } // isReMaterializable
5332 // ConstantPool, GlobalAddress, and JumpTable
5333 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
5334 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
5335 Requires<[IsARM, UseMovt]>;
5336 def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
5337 (LEApcrelJT tjumptable:$dst, imm:$id)>;
5339 // TODO: add,sub,and, 3-instr forms?
5341 // Tail calls. These patterns also apply to Thumb mode.
5342 def : Pat<(ARMtcret tcGPR:$dst), (TCRETURNri tcGPR:$dst)>;
5343 def : Pat<(ARMtcret (i32 tglobaladdr:$dst)), (TCRETURNdi texternalsym:$dst)>;
5344 def : Pat<(ARMtcret (i32 texternalsym:$dst)), (TCRETURNdi texternalsym:$dst)>;
5347 def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>;
5348 def : ARMPat<(ARMcall_nolink texternalsym:$func),
5349 (BMOVPCB_CALL texternalsym:$func)>;
5351 // zextload i1 -> zextload i8
5352 def : ARMPat<(zextloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5353 def : ARMPat<(zextloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5355 // extload -> zextload
5356 def : ARMPat<(extloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5357 def : ARMPat<(extloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5358 def : ARMPat<(extloadi8 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5359 def : ARMPat<(extloadi8 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5361 def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
5363 def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
5364 def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
5367 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
5368 (sra (shl GPR:$b, (i32 16)), (i32 16))),
5369 (SMULBB GPR:$a, GPR:$b)>;
5370 def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
5371 (SMULBB GPR:$a, GPR:$b)>;
5372 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
5373 (sra GPR:$b, (i32 16))),
5374 (SMULBT GPR:$a, GPR:$b)>;
5375 def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, (i32 16))),
5376 (SMULBT GPR:$a, GPR:$b)>;
5377 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)),
5378 (sra (shl GPR:$b, (i32 16)), (i32 16))),
5379 (SMULTB GPR:$a, GPR:$b)>;
5380 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), sext_16_node:$b),
5381 (SMULTB GPR:$a, GPR:$b)>;
5383 def : ARMV5MOPat<(add GPR:$acc,
5384 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
5385 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
5386 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5387 def : ARMV5MOPat<(add GPR:$acc,
5388 (mul sext_16_node:$a, sext_16_node:$b)),
5389 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5390 def : ARMV5MOPat<(add GPR:$acc,
5391 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
5392 (sra GPR:$b, (i32 16)))),
5393 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
5394 def : ARMV5MOPat<(add GPR:$acc,
5395 (mul sext_16_node:$a, (sra GPR:$b, (i32 16)))),
5396 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
5397 def : ARMV5MOPat<(add GPR:$acc,
5398 (mul (sra GPR:$a, (i32 16)),
5399 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
5400 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
5401 def : ARMV5MOPat<(add GPR:$acc,
5402 (mul (sra GPR:$a, (i32 16)), sext_16_node:$b)),
5403 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
5406 // Pre-v7 uses MCR for synchronization barriers.
5407 def : ARMPat<(ARMMemBarrierMCR GPR:$zero), (MCR 15, 0, GPR:$zero, 7, 10, 5)>,
5408 Requires<[IsARM, HasV6]>;
5410 // SXT/UXT with no rotate
5411 let AddedComplexity = 16 in {
5412 def : ARMV6Pat<(and GPR:$Src, 0x000000FF), (UXTB GPR:$Src, 0)>;
5413 def : ARMV6Pat<(and GPR:$Src, 0x0000FFFF), (UXTH GPR:$Src, 0)>;
5414 def : ARMV6Pat<(and GPR:$Src, 0x00FF00FF), (UXTB16 GPR:$Src, 0)>;
5415 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0x00FF)),
5416 (UXTAB GPR:$Rn, GPR:$Rm, 0)>;
5417 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0xFFFF)),
5418 (UXTAH GPR:$Rn, GPR:$Rm, 0)>;
5421 def : ARMV6Pat<(sext_inreg GPR:$Src, i8), (SXTB GPR:$Src, 0)>;
5422 def : ARMV6Pat<(sext_inreg GPR:$Src, i16), (SXTH GPR:$Src, 0)>;
5424 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i8)),
5425 (SXTAB GPR:$Rn, GPRnopc:$Rm, 0)>;
5426 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i16)),
5427 (SXTAH GPR:$Rn, GPRnopc:$Rm, 0)>;
5429 // Atomic load/store patterns
5430 def : ARMPat<(atomic_load_8 ldst_so_reg:$src),
5431 (LDRBrs ldst_so_reg:$src)>;
5432 def : ARMPat<(atomic_load_8 addrmode_imm12:$src),
5433 (LDRBi12 addrmode_imm12:$src)>;
5434 def : ARMPat<(atomic_load_16 addrmode3:$src),
5435 (LDRH addrmode3:$src)>;
5436 def : ARMPat<(atomic_load_32 ldst_so_reg:$src),
5437 (LDRrs ldst_so_reg:$src)>;
5438 def : ARMPat<(atomic_load_32 addrmode_imm12:$src),
5439 (LDRi12 addrmode_imm12:$src)>;
5440 def : ARMPat<(atomic_store_8 ldst_so_reg:$ptr, GPR:$val),
5441 (STRBrs GPR:$val, ldst_so_reg:$ptr)>;
5442 def : ARMPat<(atomic_store_8 addrmode_imm12:$ptr, GPR:$val),
5443 (STRBi12 GPR:$val, addrmode_imm12:$ptr)>;
5444 def : ARMPat<(atomic_store_16 addrmode3:$ptr, GPR:$val),
5445 (STRH GPR:$val, addrmode3:$ptr)>;
5446 def : ARMPat<(atomic_store_32 ldst_so_reg:$ptr, GPR:$val),
5447 (STRrs GPR:$val, ldst_so_reg:$ptr)>;
5448 def : ARMPat<(atomic_store_32 addrmode_imm12:$ptr, GPR:$val),
5449 (STRi12 GPR:$val, addrmode_imm12:$ptr)>;
5452 //===----------------------------------------------------------------------===//
5456 include "ARMInstrThumb.td"
5458 //===----------------------------------------------------------------------===//
5462 include "ARMInstrThumb2.td"
5464 //===----------------------------------------------------------------------===//
5465 // Floating Point Support
5468 include "ARMInstrVFP.td"
5470 //===----------------------------------------------------------------------===//
5471 // Advanced SIMD (NEON) Support
5474 include "ARMInstrNEON.td"
5476 //===----------------------------------------------------------------------===//
5477 // Assembler aliases
5481 def : InstAlias<"dmb", (DMB 0xf)>, Requires<[IsARM, HasDB]>;
5482 def : InstAlias<"dsb", (DSB 0xf)>, Requires<[IsARM, HasDB]>;
5483 def : InstAlias<"isb", (ISB 0xf)>, Requires<[IsARM, HasDB]>;
5485 // System instructions
5486 def : MnemonicAlias<"swi", "svc">;
5488 // Load / Store Multiple
5489 def : MnemonicAlias<"ldmfd", "ldm">;
5490 def : MnemonicAlias<"ldmia", "ldm">;
5491 def : MnemonicAlias<"ldmea", "ldmdb">;
5492 def : MnemonicAlias<"stmfd", "stmdb">;
5493 def : MnemonicAlias<"stmia", "stm">;
5494 def : MnemonicAlias<"stmea", "stm">;
5496 // PKHBT/PKHTB with default shift amount. PKHTB is equivalent to PKHBT when the
5497 // shift amount is zero (i.e., unspecified).
5498 def : InstAlias<"pkhbt${p} $Rd, $Rn, $Rm",
5499 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
5500 Requires<[IsARM, HasV6]>;
5501 def : InstAlias<"pkhtb${p} $Rd, $Rn, $Rm",
5502 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
5503 Requires<[IsARM, HasV6]>;
5505 // PUSH/POP aliases for STM/LDM
5506 def : ARMInstAlias<"push${p} $regs", (STMDB_UPD SP, pred:$p, reglist:$regs)>;
5507 def : ARMInstAlias<"pop${p} $regs", (LDMIA_UPD SP, pred:$p, reglist:$regs)>;
5509 // SSAT/USAT optional shift operand.
5510 def : ARMInstAlias<"ssat${p} $Rd, $sat_imm, $Rn",
5511 (SSAT GPRnopc:$Rd, imm1_32:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5512 def : ARMInstAlias<"usat${p} $Rd, $sat_imm, $Rn",
5513 (USAT GPRnopc:$Rd, imm0_31:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5516 // Extend instruction optional rotate operand.
5517 def : ARMInstAlias<"sxtab${p} $Rd, $Rn, $Rm",
5518 (SXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5519 def : ARMInstAlias<"sxtah${p} $Rd, $Rn, $Rm",
5520 (SXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5521 def : ARMInstAlias<"sxtab16${p} $Rd, $Rn, $Rm",
5522 (SXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5523 def : ARMInstAlias<"sxtb${p} $Rd, $Rm",
5524 (SXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5525 def : ARMInstAlias<"sxtb16${p} $Rd, $Rm",
5526 (SXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5527 def : ARMInstAlias<"sxth${p} $Rd, $Rm",
5528 (SXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5530 def : ARMInstAlias<"uxtab${p} $Rd, $Rn, $Rm",
5531 (UXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5532 def : ARMInstAlias<"uxtah${p} $Rd, $Rn, $Rm",
5533 (UXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5534 def : ARMInstAlias<"uxtab16${p} $Rd, $Rn, $Rm",
5535 (UXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5536 def : ARMInstAlias<"uxtb${p} $Rd, $Rm",
5537 (UXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5538 def : ARMInstAlias<"uxtb16${p} $Rd, $Rm",
5539 (UXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5540 def : ARMInstAlias<"uxth${p} $Rd, $Rm",
5541 (UXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5545 def : MnemonicAlias<"rfefa", "rfeda">;
5546 def : MnemonicAlias<"rfeea", "rfedb">;
5547 def : MnemonicAlias<"rfefd", "rfeia">;
5548 def : MnemonicAlias<"rfeed", "rfeib">;
5549 def : MnemonicAlias<"rfe", "rfeia">;
5552 def : MnemonicAlias<"srsfa", "srsib">;
5553 def : MnemonicAlias<"srsea", "srsia">;
5554 def : MnemonicAlias<"srsfd", "srsdb">;
5555 def : MnemonicAlias<"srsed", "srsda">;
5556 def : MnemonicAlias<"srs", "srsia">;
5559 def : MnemonicAlias<"qsubaddx", "qsax">;
5561 def : MnemonicAlias<"saddsubx", "sasx">;
5562 // SHASX == SHADDSUBX
5563 def : MnemonicAlias<"shaddsubx", "shasx">;
5564 // SHSAX == SHSUBADDX
5565 def : MnemonicAlias<"shsubaddx", "shsax">;
5567 def : MnemonicAlias<"ssubaddx", "ssax">;
5569 def : MnemonicAlias<"uaddsubx", "uasx">;
5570 // UHASX == UHADDSUBX
5571 def : MnemonicAlias<"uhaddsubx", "uhasx">;
5572 // UHSAX == UHSUBADDX
5573 def : MnemonicAlias<"uhsubaddx", "uhsax">;
5574 // UQASX == UQADDSUBX
5575 def : MnemonicAlias<"uqaddsubx", "uqasx">;
5576 // UQSAX == UQSUBADDX
5577 def : MnemonicAlias<"uqsubaddx", "uqsax">;
5579 def : MnemonicAlias<"usubaddx", "usax">;
5581 // "mov Rd, so_imm_not" can be handled via "mvn" in assembly, just like
5583 def : ARMInstAlias<"mov${s}${p} $Rd, $imm",
5584 (MVNi rGPR:$Rd, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
5585 def : ARMInstAlias<"mvn${s}${p} $Rd, $imm",
5586 (MOVi rGPR:$Rd, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
5587 // Same for AND <--> BIC
5588 def : ARMInstAlias<"bic${s}${p} $Rd, $Rn, $imm",
5589 (ANDri rGPR:$Rd, rGPR:$Rn, mod_imm_not:$imm,
5590 pred:$p, cc_out:$s)>;
5591 def : ARMInstAlias<"bic${s}${p} $Rdn, $imm",
5592 (ANDri rGPR:$Rdn, rGPR:$Rdn, mod_imm_not:$imm,
5593 pred:$p, cc_out:$s)>;
5594 def : ARMInstAlias<"and${s}${p} $Rd, $Rn, $imm",
5595 (BICri rGPR:$Rd, rGPR:$Rn, mod_imm_not:$imm,
5596 pred:$p, cc_out:$s)>;
5597 def : ARMInstAlias<"and${s}${p} $Rdn, $imm",
5598 (BICri rGPR:$Rdn, rGPR:$Rdn, mod_imm_not:$imm,
5599 pred:$p, cc_out:$s)>;
5601 // Likewise, "add Rd, so_imm_neg" -> sub
5602 def : ARMInstAlias<"add${s}${p} $Rd, $Rn, $imm",
5603 (SUBri GPR:$Rd, GPR:$Rn, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
5604 def : ARMInstAlias<"add${s}${p} $Rd, $imm",
5605 (SUBri GPR:$Rd, GPR:$Rd, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
5606 // Same for CMP <--> CMN via so_imm_neg
5607 def : ARMInstAlias<"cmp${p} $Rd, $imm",
5608 (CMNri rGPR:$Rd, mod_imm_neg:$imm, pred:$p)>;
5609 def : ARMInstAlias<"cmn${p} $Rd, $imm",
5610 (CMPri rGPR:$Rd, mod_imm_neg:$imm, pred:$p)>;
5612 // The shifter forms of the MOV instruction are aliased to the ASR, LSL,
5613 // LSR, ROR, and RRX instructions.
5614 // FIXME: We need C++ parser hooks to map the alias to the MOV
5615 // encoding. It seems we should be able to do that sort of thing
5616 // in tblgen, but it could get ugly.
5617 let TwoOperandAliasConstraint = "$Rm = $Rd" in {
5618 def ASRi : ARMAsmPseudo<"asr${s}${p} $Rd, $Rm, $imm",
5619 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
5621 def LSRi : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rm, $imm",
5622 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
5624 def LSLi : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rm, $imm",
5625 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
5627 def RORi : ARMAsmPseudo<"ror${s}${p} $Rd, $Rm, $imm",
5628 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
5631 def RRXi : ARMAsmPseudo<"rrx${s}${p} $Rd, $Rm",
5632 (ins GPR:$Rd, GPR:$Rm, pred:$p, cc_out:$s)>;
5633 let TwoOperandAliasConstraint = "$Rn = $Rd" in {
5634 def ASRr : ARMAsmPseudo<"asr${s}${p} $Rd, $Rn, $Rm",
5635 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5637 def LSRr : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rn, $Rm",
5638 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5640 def LSLr : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rn, $Rm",
5641 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5643 def RORr : ARMAsmPseudo<"ror${s}${p} $Rd, $Rn, $Rm",
5644 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5648 // "neg" is and alias for "rsb rd, rn, #0"
5649 def : ARMInstAlias<"neg${s}${p} $Rd, $Rm",
5650 (RSBri GPR:$Rd, GPR:$Rm, 0, pred:$p, cc_out:$s)>;
5652 // Pre-v6, 'mov r0, r0' was used as a NOP encoding.
5653 def : InstAlias<"nop${p}", (MOVr R0, R0, pred:$p, zero_reg)>,
5654 Requires<[IsARM, NoV6]>;
5656 // MUL/UMLAL/SMLAL/UMULL/SMULL are available on all arches, but
5657 // the instruction definitions need difference constraints pre-v6.
5658 // Use these aliases for the assembly parsing on pre-v6.
5659 def : InstAlias<"mul${s}${p} $Rd, $Rn, $Rm",
5660 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s)>,
5661 Requires<[IsARM, NoV6]>;
5662 def : InstAlias<"mla${s}${p} $Rd, $Rn, $Rm, $Ra",
5663 (MLA GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra,
5664 pred:$p, cc_out:$s)>,
5665 Requires<[IsARM, NoV6]>;
5666 def : InstAlias<"smlal${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5667 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5668 Requires<[IsARM, NoV6]>;
5669 def : InstAlias<"umlal${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5670 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5671 Requires<[IsARM, NoV6]>;
5672 def : InstAlias<"smull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5673 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5674 Requires<[IsARM, NoV6]>;
5675 def : InstAlias<"umull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5676 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5677 Requires<[IsARM, NoV6]>;
5679 // 'it' blocks in ARM mode just validate the predicates. The IT itself
5681 def ITasm : ARMAsmPseudo<"it$mask $cc", (ins it_pred:$cc, it_mask:$mask)>,
5682 ComplexDeprecationPredicate<"IT">;
5684 let mayLoad = 1, mayStore =1, hasSideEffects = 1 in
5685 def SPACE : PseudoInst<(outs GPR:$Rd), (ins i32imm:$size, GPR:$Rn),
5687 [(set GPR:$Rd, (int_arm_space imm:$size, GPR:$Rn))]>;