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;
589 // mod_imm: match a 32-bit immediate operand, which is encoded as a 12-bit
590 // immediate (See ARMARM - "Modified Immediate Constants"). Unlike so_imm,
591 // mod_imm keeps the immediate in its encoded form (within the MC layer).
592 def ModImmAsmOperand: AsmOperandClass {
594 let ParserMethod = "parseModImm";
596 def mod_imm : Operand<i32>, ImmLeaf<i32, [{
597 return ARM_AM::getSOImmVal(Imm) != -1;
599 let EncoderMethod = "getModImmOpValue";
600 let PrintMethod = "printModImmOperand";
601 let ParserMatchClass = ModImmAsmOperand;
604 // similar to so_imm_not, but keeps the immediate in its encoded form
605 def ModImmNotAsmOperand : AsmOperandClass { let Name = "ModImmNot"; }
606 def mod_imm_not : Operand<i32>, PatLeaf<(imm), [{
607 return ARM_AM::getSOImmVal(~(uint32_t)N->getZExtValue()) != -1;
609 let ParserMatchClass = ModImmNotAsmOperand;
612 // similar to so_imm_neg, but keeps the immediate in its encoded form
613 def ModImmNegAsmOperand : AsmOperandClass { let Name = "ModImmNeg"; }
614 def mod_imm_neg : Operand<i32>, PatLeaf<(imm), [{
615 unsigned Value = -(unsigned)N->getZExtValue();
616 return Value && ARM_AM::getSOImmVal(Value) != -1;
618 let ParserMatchClass = ModImmNegAsmOperand;
621 // Break so_imm's up into two pieces. This handles immediates with up to 16
622 // bits set in them. This uses so_imm2part to match and so_imm2part_[12] to
623 // get the first/second pieces.
624 def so_imm2part : PatLeaf<(imm), [{
625 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
628 /// arm_i32imm - True for +V6T2, or true only if so_imm2part is true.
630 def arm_i32imm : PatLeaf<(imm), [{
631 if (Subtarget->useMovt(*MF))
633 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
636 /// imm0_1 predicate - Immediate in the range [0,1].
637 def Imm0_1AsmOperand: ImmAsmOperand { let Name = "Imm0_1"; }
638 def imm0_1 : Operand<i32> { let ParserMatchClass = Imm0_1AsmOperand; }
640 /// imm0_3 predicate - Immediate in the range [0,3].
641 def Imm0_3AsmOperand: ImmAsmOperand { let Name = "Imm0_3"; }
642 def imm0_3 : Operand<i32> { let ParserMatchClass = Imm0_3AsmOperand; }
644 /// imm0_7 predicate - Immediate in the range [0,7].
645 def Imm0_7AsmOperand: ImmAsmOperand { let Name = "Imm0_7"; }
646 def imm0_7 : Operand<i32>, ImmLeaf<i32, [{
647 return Imm >= 0 && Imm < 8;
649 let ParserMatchClass = Imm0_7AsmOperand;
652 /// imm8 predicate - Immediate is exactly 8.
653 def Imm8AsmOperand: ImmAsmOperand { let Name = "Imm8"; }
654 def imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 8; }]> {
655 let ParserMatchClass = Imm8AsmOperand;
658 /// imm16 predicate - Immediate is exactly 16.
659 def Imm16AsmOperand: ImmAsmOperand { let Name = "Imm16"; }
660 def imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 16; }]> {
661 let ParserMatchClass = Imm16AsmOperand;
664 /// imm32 predicate - Immediate is exactly 32.
665 def Imm32AsmOperand: ImmAsmOperand { let Name = "Imm32"; }
666 def imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 32; }]> {
667 let ParserMatchClass = Imm32AsmOperand;
670 def imm8_or_16 : ImmLeaf<i32, [{ return Imm == 8 || Imm == 16;}]>;
672 /// imm1_7 predicate - Immediate in the range [1,7].
673 def Imm1_7AsmOperand: ImmAsmOperand { let Name = "Imm1_7"; }
674 def imm1_7 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 8; }]> {
675 let ParserMatchClass = Imm1_7AsmOperand;
678 /// imm1_15 predicate - Immediate in the range [1,15].
679 def Imm1_15AsmOperand: ImmAsmOperand { let Name = "Imm1_15"; }
680 def imm1_15 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 16; }]> {
681 let ParserMatchClass = Imm1_15AsmOperand;
684 /// imm1_31 predicate - Immediate in the range [1,31].
685 def Imm1_31AsmOperand: ImmAsmOperand { let Name = "Imm1_31"; }
686 def imm1_31 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 32; }]> {
687 let ParserMatchClass = Imm1_31AsmOperand;
690 /// imm0_15 predicate - Immediate in the range [0,15].
691 def Imm0_15AsmOperand: ImmAsmOperand {
692 let Name = "Imm0_15";
693 let DiagnosticType = "ImmRange0_15";
695 def imm0_15 : Operand<i32>, ImmLeaf<i32, [{
696 return Imm >= 0 && Imm < 16;
698 let ParserMatchClass = Imm0_15AsmOperand;
701 /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
702 def Imm0_31AsmOperand: ImmAsmOperand { let Name = "Imm0_31"; }
703 def imm0_31 : Operand<i32>, ImmLeaf<i32, [{
704 return Imm >= 0 && Imm < 32;
706 let ParserMatchClass = Imm0_31AsmOperand;
709 /// imm0_32 predicate - True if the 32-bit immediate is in the range [0,32].
710 def Imm0_32AsmOperand: ImmAsmOperand { let Name = "Imm0_32"; }
711 def imm0_32 : Operand<i32>, ImmLeaf<i32, [{
712 return Imm >= 0 && Imm < 32;
714 let ParserMatchClass = Imm0_32AsmOperand;
717 /// imm0_63 predicate - True if the 32-bit immediate is in the range [0,63].
718 def Imm0_63AsmOperand: ImmAsmOperand { let Name = "Imm0_63"; }
719 def imm0_63 : Operand<i32>, ImmLeaf<i32, [{
720 return Imm >= 0 && Imm < 64;
722 let ParserMatchClass = Imm0_63AsmOperand;
725 /// imm0_239 predicate - Immediate in the range [0,239].
726 def Imm0_239AsmOperand : ImmAsmOperand {
727 let Name = "Imm0_239";
728 let DiagnosticType = "ImmRange0_239";
730 def imm0_239 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 240; }]> {
731 let ParserMatchClass = Imm0_239AsmOperand;
734 /// imm0_255 predicate - Immediate in the range [0,255].
735 def Imm0_255AsmOperand : ImmAsmOperand { let Name = "Imm0_255"; }
736 def imm0_255 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 256; }]> {
737 let ParserMatchClass = Imm0_255AsmOperand;
740 /// imm0_65535 - An immediate is in the range [0.65535].
741 def Imm0_65535AsmOperand: ImmAsmOperand { let Name = "Imm0_65535"; }
742 def imm0_65535 : Operand<i32>, ImmLeaf<i32, [{
743 return Imm >= 0 && Imm < 65536;
745 let ParserMatchClass = Imm0_65535AsmOperand;
748 // imm0_65535_neg - An immediate whose negative value is in the range [0.65535].
749 def imm0_65535_neg : Operand<i32>, ImmLeaf<i32, [{
750 return -Imm >= 0 && -Imm < 65536;
753 // imm0_65535_expr - For movt/movw - 16-bit immediate that can also reference
754 // a relocatable expression.
756 // FIXME: This really needs a Thumb version separate from the ARM version.
757 // While the range is the same, and can thus use the same match class,
758 // the encoding is different so it should have a different encoder method.
759 def Imm0_65535ExprAsmOperand: ImmAsmOperand { let Name = "Imm0_65535Expr"; }
760 def imm0_65535_expr : Operand<i32> {
761 let EncoderMethod = "getHiLo16ImmOpValue";
762 let ParserMatchClass = Imm0_65535ExprAsmOperand;
765 def Imm256_65535ExprAsmOperand: ImmAsmOperand { let Name = "Imm256_65535Expr"; }
766 def imm256_65535_expr : Operand<i32> {
767 let ParserMatchClass = Imm256_65535ExprAsmOperand;
770 /// imm24b - True if the 32-bit immediate is encodable in 24 bits.
771 def Imm24bitAsmOperand: ImmAsmOperand { let Name = "Imm24bit"; }
772 def imm24b : Operand<i32>, ImmLeaf<i32, [{
773 return Imm >= 0 && Imm <= 0xffffff;
775 let ParserMatchClass = Imm24bitAsmOperand;
779 /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
781 def BitfieldAsmOperand : AsmOperandClass {
782 let Name = "Bitfield";
783 let ParserMethod = "parseBitfield";
786 def bf_inv_mask_imm : Operand<i32>,
788 return ARM::isBitFieldInvertedMask(N->getZExtValue());
790 let EncoderMethod = "getBitfieldInvertedMaskOpValue";
791 let PrintMethod = "printBitfieldInvMaskImmOperand";
792 let DecoderMethod = "DecodeBitfieldMaskOperand";
793 let ParserMatchClass = BitfieldAsmOperand;
796 def imm1_32_XFORM: SDNodeXForm<imm, [{
797 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, MVT::i32);
799 def Imm1_32AsmOperand: AsmOperandClass { let Name = "Imm1_32"; }
800 def imm1_32 : Operand<i32>, PatLeaf<(imm), [{
801 uint64_t Imm = N->getZExtValue();
802 return Imm > 0 && Imm <= 32;
805 let PrintMethod = "printImmPlusOneOperand";
806 let ParserMatchClass = Imm1_32AsmOperand;
809 def imm1_16_XFORM: SDNodeXForm<imm, [{
810 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, MVT::i32);
812 def Imm1_16AsmOperand: AsmOperandClass { let Name = "Imm1_16"; }
813 def imm1_16 : Operand<i32>, PatLeaf<(imm), [{ return Imm > 0 && Imm <= 16; }],
815 let PrintMethod = "printImmPlusOneOperand";
816 let ParserMatchClass = Imm1_16AsmOperand;
819 // Define ARM specific addressing modes.
820 // addrmode_imm12 := reg +/- imm12
822 def MemImm12OffsetAsmOperand : AsmOperandClass { let Name = "MemImm12Offset"; }
823 class AddrMode_Imm12 : Operand<i32>,
824 ComplexPattern<i32, 2, "SelectAddrModeImm12", []> {
825 // 12-bit immediate operand. Note that instructions using this encode
826 // #0 and #-0 differently. We flag #-0 as the magic value INT32_MIN. All other
827 // immediate values are as normal.
829 let EncoderMethod = "getAddrModeImm12OpValue";
830 let DecoderMethod = "DecodeAddrModeImm12Operand";
831 let ParserMatchClass = MemImm12OffsetAsmOperand;
832 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
835 def addrmode_imm12 : AddrMode_Imm12 {
836 let PrintMethod = "printAddrModeImm12Operand<false>";
839 def addrmode_imm12_pre : AddrMode_Imm12 {
840 let PrintMethod = "printAddrModeImm12Operand<true>";
843 // ldst_so_reg := reg +/- reg shop imm
845 def MemRegOffsetAsmOperand : AsmOperandClass { let Name = "MemRegOffset"; }
846 def ldst_so_reg : Operand<i32>,
847 ComplexPattern<i32, 3, "SelectLdStSOReg", []> {
848 let EncoderMethod = "getLdStSORegOpValue";
849 // FIXME: Simplify the printer
850 let PrintMethod = "printAddrMode2Operand";
851 let DecoderMethod = "DecodeSORegMemOperand";
852 let ParserMatchClass = MemRegOffsetAsmOperand;
853 let MIOperandInfo = (ops GPR:$base, GPRnopc:$offsreg, i32imm:$shift);
856 // postidx_imm8 := +/- [0,255]
859 // {8} 1 is imm8 is non-negative. 0 otherwise.
860 // {7-0} [0,255] imm8 value.
861 def PostIdxImm8AsmOperand : AsmOperandClass { let Name = "PostIdxImm8"; }
862 def postidx_imm8 : Operand<i32> {
863 let PrintMethod = "printPostIdxImm8Operand";
864 let ParserMatchClass = PostIdxImm8AsmOperand;
865 let MIOperandInfo = (ops i32imm);
868 // postidx_imm8s4 := +/- [0,1020]
871 // {8} 1 is imm8 is non-negative. 0 otherwise.
872 // {7-0} [0,255] imm8 value, scaled by 4.
873 def PostIdxImm8s4AsmOperand : AsmOperandClass { let Name = "PostIdxImm8s4"; }
874 def postidx_imm8s4 : Operand<i32> {
875 let PrintMethod = "printPostIdxImm8s4Operand";
876 let ParserMatchClass = PostIdxImm8s4AsmOperand;
877 let MIOperandInfo = (ops i32imm);
881 // postidx_reg := +/- reg
883 def PostIdxRegAsmOperand : AsmOperandClass {
884 let Name = "PostIdxReg";
885 let ParserMethod = "parsePostIdxReg";
887 def postidx_reg : Operand<i32> {
888 let EncoderMethod = "getPostIdxRegOpValue";
889 let DecoderMethod = "DecodePostIdxReg";
890 let PrintMethod = "printPostIdxRegOperand";
891 let ParserMatchClass = PostIdxRegAsmOperand;
892 let MIOperandInfo = (ops GPRnopc, i32imm);
896 // addrmode2 := reg +/- imm12
897 // := reg +/- reg shop imm
899 // FIXME: addrmode2 should be refactored the rest of the way to always
900 // use explicit imm vs. reg versions above (addrmode_imm12 and ldst_so_reg).
901 def AddrMode2AsmOperand : AsmOperandClass { let Name = "AddrMode2"; }
902 def addrmode2 : Operand<i32>,
903 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
904 let EncoderMethod = "getAddrMode2OpValue";
905 let PrintMethod = "printAddrMode2Operand";
906 let ParserMatchClass = AddrMode2AsmOperand;
907 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
910 def PostIdxRegShiftedAsmOperand : AsmOperandClass {
911 let Name = "PostIdxRegShifted";
912 let ParserMethod = "parsePostIdxReg";
914 def am2offset_reg : Operand<i32>,
915 ComplexPattern<i32, 2, "SelectAddrMode2OffsetReg",
916 [], [SDNPWantRoot]> {
917 let EncoderMethod = "getAddrMode2OffsetOpValue";
918 let PrintMethod = "printAddrMode2OffsetOperand";
919 // When using this for assembly, it's always as a post-index offset.
920 let ParserMatchClass = PostIdxRegShiftedAsmOperand;
921 let MIOperandInfo = (ops GPRnopc, i32imm);
924 // FIXME: am2offset_imm should only need the immediate, not the GPR. Having
925 // the GPR is purely vestigal at this point.
926 def AM2OffsetImmAsmOperand : AsmOperandClass { let Name = "AM2OffsetImm"; }
927 def am2offset_imm : Operand<i32>,
928 ComplexPattern<i32, 2, "SelectAddrMode2OffsetImm",
929 [], [SDNPWantRoot]> {
930 let EncoderMethod = "getAddrMode2OffsetOpValue";
931 let PrintMethod = "printAddrMode2OffsetOperand";
932 let ParserMatchClass = AM2OffsetImmAsmOperand;
933 let MIOperandInfo = (ops GPRnopc, i32imm);
937 // addrmode3 := reg +/- reg
938 // addrmode3 := reg +/- imm8
940 // FIXME: split into imm vs. reg versions.
941 def AddrMode3AsmOperand : AsmOperandClass { let Name = "AddrMode3"; }
942 class AddrMode3 : Operand<i32>,
943 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
944 let EncoderMethod = "getAddrMode3OpValue";
945 let ParserMatchClass = AddrMode3AsmOperand;
946 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
949 def addrmode3 : AddrMode3
951 let PrintMethod = "printAddrMode3Operand<false>";
954 def addrmode3_pre : AddrMode3
956 let PrintMethod = "printAddrMode3Operand<true>";
959 // FIXME: split into imm vs. reg versions.
960 // FIXME: parser method to handle +/- register.
961 def AM3OffsetAsmOperand : AsmOperandClass {
962 let Name = "AM3Offset";
963 let ParserMethod = "parseAM3Offset";
965 def am3offset : Operand<i32>,
966 ComplexPattern<i32, 2, "SelectAddrMode3Offset",
967 [], [SDNPWantRoot]> {
968 let EncoderMethod = "getAddrMode3OffsetOpValue";
969 let PrintMethod = "printAddrMode3OffsetOperand";
970 let ParserMatchClass = AM3OffsetAsmOperand;
971 let MIOperandInfo = (ops GPR, i32imm);
974 // ldstm_mode := {ia, ib, da, db}
976 def ldstm_mode : OptionalDefOperand<OtherVT, (ops i32), (ops (i32 1))> {
977 let EncoderMethod = "getLdStmModeOpValue";
978 let PrintMethod = "printLdStmModeOperand";
981 // addrmode5 := reg +/- imm8*4
983 def AddrMode5AsmOperand : AsmOperandClass { let Name = "AddrMode5"; }
984 class AddrMode5 : Operand<i32>,
985 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
986 let EncoderMethod = "getAddrMode5OpValue";
987 let DecoderMethod = "DecodeAddrMode5Operand";
988 let ParserMatchClass = AddrMode5AsmOperand;
989 let MIOperandInfo = (ops GPR:$base, i32imm);
992 def addrmode5 : AddrMode5 {
993 let PrintMethod = "printAddrMode5Operand<false>";
996 def addrmode5_pre : AddrMode5 {
997 let PrintMethod = "printAddrMode5Operand<true>";
1000 // addrmode6 := reg with optional alignment
1002 def AddrMode6AsmOperand : AsmOperandClass { let Name = "AlignedMemory"; }
1003 def addrmode6 : Operand<i32>,
1004 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1005 let PrintMethod = "printAddrMode6Operand";
1006 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
1007 let EncoderMethod = "getAddrMode6AddressOpValue";
1008 let DecoderMethod = "DecodeAddrMode6Operand";
1009 let ParserMatchClass = AddrMode6AsmOperand;
1012 def am6offset : Operand<i32>,
1013 ComplexPattern<i32, 1, "SelectAddrMode6Offset",
1014 [], [SDNPWantRoot]> {
1015 let PrintMethod = "printAddrMode6OffsetOperand";
1016 let MIOperandInfo = (ops GPR);
1017 let EncoderMethod = "getAddrMode6OffsetOpValue";
1018 let DecoderMethod = "DecodeGPRRegisterClass";
1021 // Special version of addrmode6 to handle alignment encoding for VST1/VLD1
1022 // (single element from one lane) for size 32.
1023 def addrmode6oneL32 : Operand<i32>,
1024 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1025 let PrintMethod = "printAddrMode6Operand";
1026 let MIOperandInfo = (ops GPR:$addr, i32imm);
1027 let EncoderMethod = "getAddrMode6OneLane32AddressOpValue";
1030 // Base class for addrmode6 with specific alignment restrictions.
1031 class AddrMode6Align : Operand<i32>,
1032 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1033 let PrintMethod = "printAddrMode6Operand";
1034 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
1035 let EncoderMethod = "getAddrMode6AddressOpValue";
1036 let DecoderMethod = "DecodeAddrMode6Operand";
1039 // Special version of addrmode6 to handle no allowed alignment encoding for
1040 // VLD/VST instructions and checking the alignment is not specified.
1041 def AddrMode6AlignNoneAsmOperand : AsmOperandClass {
1042 let Name = "AlignedMemoryNone";
1043 let DiagnosticType = "AlignedMemoryRequiresNone";
1045 def addrmode6alignNone : AddrMode6Align {
1046 // The alignment specifier can only be omitted.
1047 let ParserMatchClass = AddrMode6AlignNoneAsmOperand;
1050 // Special version of addrmode6 to handle 16-bit alignment encoding for
1051 // VLD/VST instructions and checking the alignment value.
1052 def AddrMode6Align16AsmOperand : AsmOperandClass {
1053 let Name = "AlignedMemory16";
1054 let DiagnosticType = "AlignedMemoryRequires16";
1056 def addrmode6align16 : AddrMode6Align {
1057 // The alignment specifier can only be 16 or omitted.
1058 let ParserMatchClass = AddrMode6Align16AsmOperand;
1061 // Special version of addrmode6 to handle 32-bit alignment encoding for
1062 // VLD/VST instructions and checking the alignment value.
1063 def AddrMode6Align32AsmOperand : AsmOperandClass {
1064 let Name = "AlignedMemory32";
1065 let DiagnosticType = "AlignedMemoryRequires32";
1067 def addrmode6align32 : AddrMode6Align {
1068 // The alignment specifier can only be 32 or omitted.
1069 let ParserMatchClass = AddrMode6Align32AsmOperand;
1072 // Special version of addrmode6 to handle 64-bit alignment encoding for
1073 // VLD/VST instructions and checking the alignment value.
1074 def AddrMode6Align64AsmOperand : AsmOperandClass {
1075 let Name = "AlignedMemory64";
1076 let DiagnosticType = "AlignedMemoryRequires64";
1078 def addrmode6align64 : AddrMode6Align {
1079 // The alignment specifier can only be 64 or omitted.
1080 let ParserMatchClass = AddrMode6Align64AsmOperand;
1083 // Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding
1084 // for VLD/VST instructions and checking the alignment value.
1085 def AddrMode6Align64or128AsmOperand : AsmOperandClass {
1086 let Name = "AlignedMemory64or128";
1087 let DiagnosticType = "AlignedMemoryRequires64or128";
1089 def addrmode6align64or128 : AddrMode6Align {
1090 // The alignment specifier can only be 64, 128 or omitted.
1091 let ParserMatchClass = AddrMode6Align64or128AsmOperand;
1094 // Special version of addrmode6 to handle 64-bit, 128-bit or 256-bit alignment
1095 // encoding for VLD/VST instructions and checking the alignment value.
1096 def AddrMode6Align64or128or256AsmOperand : AsmOperandClass {
1097 let Name = "AlignedMemory64or128or256";
1098 let DiagnosticType = "AlignedMemoryRequires64or128or256";
1100 def addrmode6align64or128or256 : AddrMode6Align {
1101 // The alignment specifier can only be 64, 128, 256 or omitted.
1102 let ParserMatchClass = AddrMode6Align64or128or256AsmOperand;
1105 // Special version of addrmode6 to handle alignment encoding for VLD-dup
1106 // instructions, specifically VLD4-dup.
1107 def addrmode6dup : Operand<i32>,
1108 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1109 let PrintMethod = "printAddrMode6Operand";
1110 let MIOperandInfo = (ops GPR:$addr, i32imm);
1111 let EncoderMethod = "getAddrMode6DupAddressOpValue";
1112 // FIXME: This is close, but not quite right. The alignment specifier is
1114 let ParserMatchClass = AddrMode6AsmOperand;
1117 // Base class for addrmode6dup with specific alignment restrictions.
1118 class AddrMode6DupAlign : Operand<i32>,
1119 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1120 let PrintMethod = "printAddrMode6Operand";
1121 let MIOperandInfo = (ops GPR:$addr, i32imm);
1122 let EncoderMethod = "getAddrMode6DupAddressOpValue";
1125 // Special version of addrmode6 to handle no allowed alignment encoding for
1126 // VLD-dup instruction and checking the alignment is not specified.
1127 def AddrMode6dupAlignNoneAsmOperand : AsmOperandClass {
1128 let Name = "DupAlignedMemoryNone";
1129 let DiagnosticType = "DupAlignedMemoryRequiresNone";
1131 def addrmode6dupalignNone : AddrMode6DupAlign {
1132 // The alignment specifier can only be omitted.
1133 let ParserMatchClass = AddrMode6dupAlignNoneAsmOperand;
1136 // Special version of addrmode6 to handle 16-bit alignment encoding for VLD-dup
1137 // instruction and checking the alignment value.
1138 def AddrMode6dupAlign16AsmOperand : AsmOperandClass {
1139 let Name = "DupAlignedMemory16";
1140 let DiagnosticType = "DupAlignedMemoryRequires16";
1142 def addrmode6dupalign16 : AddrMode6DupAlign {
1143 // The alignment specifier can only be 16 or omitted.
1144 let ParserMatchClass = AddrMode6dupAlign16AsmOperand;
1147 // Special version of addrmode6 to handle 32-bit alignment encoding for VLD-dup
1148 // instruction and checking the alignment value.
1149 def AddrMode6dupAlign32AsmOperand : AsmOperandClass {
1150 let Name = "DupAlignedMemory32";
1151 let DiagnosticType = "DupAlignedMemoryRequires32";
1153 def addrmode6dupalign32 : AddrMode6DupAlign {
1154 // The alignment specifier can only be 32 or omitted.
1155 let ParserMatchClass = AddrMode6dupAlign32AsmOperand;
1158 // Special version of addrmode6 to handle 64-bit alignment encoding for VLD
1159 // instructions and checking the alignment value.
1160 def AddrMode6dupAlign64AsmOperand : AsmOperandClass {
1161 let Name = "DupAlignedMemory64";
1162 let DiagnosticType = "DupAlignedMemoryRequires64";
1164 def addrmode6dupalign64 : AddrMode6DupAlign {
1165 // The alignment specifier can only be 64 or omitted.
1166 let ParserMatchClass = AddrMode6dupAlign64AsmOperand;
1169 // Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding
1170 // for VLD instructions and checking the alignment value.
1171 def AddrMode6dupAlign64or128AsmOperand : AsmOperandClass {
1172 let Name = "DupAlignedMemory64or128";
1173 let DiagnosticType = "DupAlignedMemoryRequires64or128";
1175 def addrmode6dupalign64or128 : AddrMode6DupAlign {
1176 // The alignment specifier can only be 64, 128 or omitted.
1177 let ParserMatchClass = AddrMode6dupAlign64or128AsmOperand;
1180 // addrmodepc := pc + reg
1182 def addrmodepc : Operand<i32>,
1183 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
1184 let PrintMethod = "printAddrModePCOperand";
1185 let MIOperandInfo = (ops GPR, i32imm);
1188 // addr_offset_none := reg
1190 def MemNoOffsetAsmOperand : AsmOperandClass { let Name = "MemNoOffset"; }
1191 def addr_offset_none : Operand<i32>,
1192 ComplexPattern<i32, 1, "SelectAddrOffsetNone", []> {
1193 let PrintMethod = "printAddrMode7Operand";
1194 let DecoderMethod = "DecodeAddrMode7Operand";
1195 let ParserMatchClass = MemNoOffsetAsmOperand;
1196 let MIOperandInfo = (ops GPR:$base);
1199 def nohash_imm : Operand<i32> {
1200 let PrintMethod = "printNoHashImmediate";
1203 def CoprocNumAsmOperand : AsmOperandClass {
1204 let Name = "CoprocNum";
1205 let ParserMethod = "parseCoprocNumOperand";
1207 def p_imm : Operand<i32> {
1208 let PrintMethod = "printPImmediate";
1209 let ParserMatchClass = CoprocNumAsmOperand;
1210 let DecoderMethod = "DecodeCoprocessor";
1213 def CoprocRegAsmOperand : AsmOperandClass {
1214 let Name = "CoprocReg";
1215 let ParserMethod = "parseCoprocRegOperand";
1217 def c_imm : Operand<i32> {
1218 let PrintMethod = "printCImmediate";
1219 let ParserMatchClass = CoprocRegAsmOperand;
1221 def CoprocOptionAsmOperand : AsmOperandClass {
1222 let Name = "CoprocOption";
1223 let ParserMethod = "parseCoprocOptionOperand";
1225 def coproc_option_imm : Operand<i32> {
1226 let PrintMethod = "printCoprocOptionImm";
1227 let ParserMatchClass = CoprocOptionAsmOperand;
1230 //===----------------------------------------------------------------------===//
1232 include "ARMInstrFormats.td"
1234 //===----------------------------------------------------------------------===//
1235 // Multiclass helpers...
1238 /// AsI1_bin_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns for a
1239 /// binop that produces a value.
1240 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1241 multiclass AsI1_bin_irs<bits<4> opcod, string opc,
1242 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1243 PatFrag opnode, bit Commutable = 0> {
1244 // The register-immediate version is re-materializable. This is useful
1245 // in particular for taking the address of a local.
1246 let isReMaterializable = 1 in {
1247 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm,
1248 iii, opc, "\t$Rd, $Rn, $imm",
1249 [(set GPR:$Rd, (opnode GPR:$Rn, mod_imm:$imm))]>,
1250 Sched<[WriteALU, ReadALU]> {
1255 let Inst{19-16} = Rn;
1256 let Inst{15-12} = Rd;
1257 let Inst{11-0} = imm;
1260 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1261 iir, opc, "\t$Rd, $Rn, $Rm",
1262 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]>,
1263 Sched<[WriteALU, ReadALU, ReadALU]> {
1268 let isCommutable = Commutable;
1269 let Inst{19-16} = Rn;
1270 let Inst{15-12} = Rd;
1271 let Inst{11-4} = 0b00000000;
1275 def rsi : AsI1<opcod, (outs GPR:$Rd),
1276 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1277 iis, opc, "\t$Rd, $Rn, $shift",
1278 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_imm:$shift))]>,
1279 Sched<[WriteALUsi, ReadALU]> {
1284 let Inst{19-16} = Rn;
1285 let Inst{15-12} = Rd;
1286 let Inst{11-5} = shift{11-5};
1288 let Inst{3-0} = shift{3-0};
1291 def rsr : AsI1<opcod, (outs GPR:$Rd),
1292 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1293 iis, opc, "\t$Rd, $Rn, $shift",
1294 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_reg:$shift))]>,
1295 Sched<[WriteALUsr, ReadALUsr]> {
1300 let Inst{19-16} = Rn;
1301 let Inst{15-12} = Rd;
1302 let Inst{11-8} = shift{11-8};
1304 let Inst{6-5} = shift{6-5};
1306 let Inst{3-0} = shift{3-0};
1310 /// AsI1_rbin_irs - Same as AsI1_bin_irs except the order of operands are
1311 /// reversed. The 'rr' form is only defined for the disassembler; for codegen
1312 /// it is equivalent to the AsI1_bin_irs counterpart.
1313 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1314 multiclass AsI1_rbin_irs<bits<4> opcod, string opc,
1315 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1316 PatFrag opnode, bit Commutable = 0> {
1317 // The register-immediate version is re-materializable. This is useful
1318 // in particular for taking the address of a local.
1319 let isReMaterializable = 1 in {
1320 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm,
1321 iii, opc, "\t$Rd, $Rn, $imm",
1322 [(set GPR:$Rd, (opnode mod_imm:$imm, GPR:$Rn))]>,
1323 Sched<[WriteALU, ReadALU]> {
1328 let Inst{19-16} = Rn;
1329 let Inst{15-12} = Rd;
1330 let Inst{11-0} = imm;
1333 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1334 iir, opc, "\t$Rd, $Rn, $Rm",
1335 [/* pattern left blank */]>,
1336 Sched<[WriteALU, ReadALU, ReadALU]> {
1340 let Inst{11-4} = 0b00000000;
1343 let Inst{15-12} = Rd;
1344 let Inst{19-16} = Rn;
1347 def rsi : AsI1<opcod, (outs GPR:$Rd),
1348 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1349 iis, opc, "\t$Rd, $Rn, $shift",
1350 [(set GPR:$Rd, (opnode so_reg_imm:$shift, GPR:$Rn))]>,
1351 Sched<[WriteALUsi, ReadALU]> {
1356 let Inst{19-16} = Rn;
1357 let Inst{15-12} = Rd;
1358 let Inst{11-5} = shift{11-5};
1360 let Inst{3-0} = shift{3-0};
1363 def rsr : AsI1<opcod, (outs GPR:$Rd),
1364 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1365 iis, opc, "\t$Rd, $Rn, $shift",
1366 [(set GPR:$Rd, (opnode so_reg_reg:$shift, GPR:$Rn))]>,
1367 Sched<[WriteALUsr, ReadALUsr]> {
1372 let Inst{19-16} = Rn;
1373 let Inst{15-12} = Rd;
1374 let Inst{11-8} = shift{11-8};
1376 let Inst{6-5} = shift{6-5};
1378 let Inst{3-0} = shift{3-0};
1382 /// AsI1_bin_s_irs - Same as AsI1_bin_irs except it sets the 's' bit by default.
1384 /// These opcodes will be converted to the real non-S opcodes by
1385 /// AdjustInstrPostInstrSelection after giving them an optional CPSR operand.
1386 let hasPostISelHook = 1, Defs = [CPSR] in {
1387 multiclass AsI1_bin_s_irs<InstrItinClass iii, InstrItinClass iir,
1388 InstrItinClass iis, PatFrag opnode,
1389 bit Commutable = 0> {
1390 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p),
1392 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm))]>,
1393 Sched<[WriteALU, ReadALU]>;
1395 def rr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, pred:$p),
1397 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm))]>,
1398 Sched<[WriteALU, ReadALU, ReadALU]> {
1399 let isCommutable = Commutable;
1401 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1402 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1404 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1405 so_reg_imm:$shift))]>,
1406 Sched<[WriteALUsi, ReadALU]>;
1408 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1409 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1411 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1412 so_reg_reg:$shift))]>,
1413 Sched<[WriteALUSsr, ReadALUsr]>;
1417 /// AsI1_rbin_s_is - Same as AsI1_bin_s_irs, except selection DAG
1418 /// operands are reversed.
1419 let hasPostISelHook = 1, Defs = [CPSR] in {
1420 multiclass AsI1_rbin_s_is<InstrItinClass iii, InstrItinClass iir,
1421 InstrItinClass iis, PatFrag opnode,
1422 bit Commutable = 0> {
1423 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p),
1425 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn))]>,
1426 Sched<[WriteALU, ReadALU]>;
1428 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1429 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1431 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift,
1433 Sched<[WriteALUsi, ReadALU]>;
1435 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1436 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1438 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift,
1440 Sched<[WriteALUSsr, ReadALUsr]>;
1444 /// AI1_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
1445 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
1446 /// a explicit result, only implicitly set CPSR.
1447 let isCompare = 1, Defs = [CPSR] in {
1448 multiclass AI1_cmp_irs<bits<4> opcod, string opc,
1449 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1450 PatFrag opnode, bit Commutable = 0> {
1451 def ri : AI1<opcod, (outs), (ins GPR:$Rn, mod_imm:$imm), DPFrm, iii,
1453 [(opnode GPR:$Rn, mod_imm:$imm)]>,
1454 Sched<[WriteCMP, ReadALU]> {
1459 let Inst{19-16} = Rn;
1460 let Inst{15-12} = 0b0000;
1461 let Inst{11-0} = imm;
1463 let Unpredictable{15-12} = 0b1111;
1465 def rr : AI1<opcod, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, iir,
1467 [(opnode GPR:$Rn, GPR:$Rm)]>,
1468 Sched<[WriteCMP, ReadALU, ReadALU]> {
1471 let isCommutable = Commutable;
1474 let Inst{19-16} = Rn;
1475 let Inst{15-12} = 0b0000;
1476 let Inst{11-4} = 0b00000000;
1479 let Unpredictable{15-12} = 0b1111;
1481 def rsi : AI1<opcod, (outs),
1482 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, iis,
1483 opc, "\t$Rn, $shift",
1484 [(opnode GPR:$Rn, so_reg_imm:$shift)]>,
1485 Sched<[WriteCMPsi, ReadALU]> {
1490 let Inst{19-16} = Rn;
1491 let Inst{15-12} = 0b0000;
1492 let Inst{11-5} = shift{11-5};
1494 let Inst{3-0} = shift{3-0};
1496 let Unpredictable{15-12} = 0b1111;
1498 def rsr : AI1<opcod, (outs),
1499 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, iis,
1500 opc, "\t$Rn, $shift",
1501 [(opnode GPRnopc:$Rn, so_reg_reg:$shift)]>,
1502 Sched<[WriteCMPsr, ReadALU]> {
1507 let Inst{19-16} = Rn;
1508 let Inst{15-12} = 0b0000;
1509 let Inst{11-8} = shift{11-8};
1511 let Inst{6-5} = shift{6-5};
1513 let Inst{3-0} = shift{3-0};
1515 let Unpredictable{15-12} = 0b1111;
1521 /// AI_ext_rrot - A unary operation with two forms: one whose operand is a
1522 /// register and one whose operand is a register rotated by 8/16/24.
1523 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
1524 class AI_ext_rrot<bits<8> opcod, string opc, PatFrag opnode>
1525 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1526 IIC_iEXTr, opc, "\t$Rd, $Rm$rot",
1527 [(set GPRnopc:$Rd, (opnode (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1528 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> {
1532 let Inst{19-16} = 0b1111;
1533 let Inst{15-12} = Rd;
1534 let Inst{11-10} = rot;
1538 class AI_ext_rrot_np<bits<8> opcod, string opc>
1539 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1540 IIC_iEXTr, opc, "\t$Rd, $Rm$rot", []>,
1541 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> {
1543 let Inst{19-16} = 0b1111;
1544 let Inst{11-10} = rot;
1547 /// AI_exta_rrot - A binary operation with two forms: one whose operand is a
1548 /// register and one whose operand is a register rotated by 8/16/24.
1549 class AI_exta_rrot<bits<8> opcod, string opc, PatFrag opnode>
1550 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1551 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot",
1552 [(set GPRnopc:$Rd, (opnode GPR:$Rn,
1553 (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1554 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> {
1559 let Inst{19-16} = Rn;
1560 let Inst{15-12} = Rd;
1561 let Inst{11-10} = rot;
1562 let Inst{9-4} = 0b000111;
1566 class AI_exta_rrot_np<bits<8> opcod, string opc>
1567 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1568 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot", []>,
1569 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> {
1572 let Inst{19-16} = Rn;
1573 let Inst{11-10} = rot;
1576 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
1577 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1578 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
1579 bit Commutable = 0> {
1580 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1581 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm),
1582 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1583 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm, CPSR))]>,
1585 Sched<[WriteALU, ReadALU]> {
1590 let Inst{15-12} = Rd;
1591 let Inst{19-16} = Rn;
1592 let Inst{11-0} = imm;
1594 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1595 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1596 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm, CPSR))]>,
1598 Sched<[WriteALU, ReadALU, ReadALU]> {
1602 let Inst{11-4} = 0b00000000;
1604 let isCommutable = Commutable;
1606 let Inst{15-12} = Rd;
1607 let Inst{19-16} = Rn;
1609 def rsi : AsI1<opcod, (outs GPR:$Rd),
1610 (ins GPR:$Rn, so_reg_imm:$shift),
1611 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1612 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_imm:$shift, CPSR))]>,
1614 Sched<[WriteALUsi, ReadALU]> {
1619 let Inst{19-16} = Rn;
1620 let Inst{15-12} = Rd;
1621 let Inst{11-5} = shift{11-5};
1623 let Inst{3-0} = shift{3-0};
1625 def rsr : AsI1<opcod, (outs GPRnopc:$Rd),
1626 (ins GPRnopc:$Rn, so_reg_reg:$shift),
1627 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1628 [(set GPRnopc:$Rd, CPSR,
1629 (opnode GPRnopc:$Rn, so_reg_reg:$shift, CPSR))]>,
1631 Sched<[WriteALUsr, ReadALUsr]> {
1636 let Inst{19-16} = Rn;
1637 let Inst{15-12} = Rd;
1638 let Inst{11-8} = shift{11-8};
1640 let Inst{6-5} = shift{6-5};
1642 let Inst{3-0} = shift{3-0};
1647 /// AI1_rsc_irs - Define instructions and patterns for rsc
1648 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1649 multiclass AI1_rsc_irs<bits<4> opcod, string opc, PatFrag opnode> {
1650 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1651 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm),
1652 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1653 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn, CPSR))]>,
1655 Sched<[WriteALU, ReadALU]> {
1660 let Inst{15-12} = Rd;
1661 let Inst{19-16} = Rn;
1662 let Inst{11-0} = imm;
1664 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1665 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1666 [/* pattern left blank */]>,
1667 Sched<[WriteALU, ReadALU, ReadALU]> {
1671 let Inst{11-4} = 0b00000000;
1674 let Inst{15-12} = Rd;
1675 let Inst{19-16} = Rn;
1677 def rsi : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_imm:$shift),
1678 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1679 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift, GPR:$Rn, CPSR))]>,
1681 Sched<[WriteALUsi, ReadALU]> {
1686 let Inst{19-16} = Rn;
1687 let Inst{15-12} = Rd;
1688 let Inst{11-5} = shift{11-5};
1690 let Inst{3-0} = shift{3-0};
1692 def rsr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_reg:$shift),
1693 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1694 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift, GPR:$Rn, CPSR))]>,
1696 Sched<[WriteALUsr, ReadALUsr]> {
1701 let Inst{19-16} = Rn;
1702 let Inst{15-12} = Rd;
1703 let Inst{11-8} = shift{11-8};
1705 let Inst{6-5} = shift{6-5};
1707 let Inst{3-0} = shift{3-0};
1712 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1713 multiclass AI_ldr1<bit isByte, string opc, InstrItinClass iii,
1714 InstrItinClass iir, PatFrag opnode> {
1715 // Note: We use the complex addrmode_imm12 rather than just an input
1716 // GPR and a constrained immediate so that we can use this to match
1717 // frame index references and avoid matching constant pool references.
1718 def i12: AI2ldst<0b010, 1, isByte, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
1719 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1720 [(set GPR:$Rt, (opnode addrmode_imm12:$addr))]> {
1723 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1724 let Inst{19-16} = addr{16-13}; // Rn
1725 let Inst{15-12} = Rt;
1726 let Inst{11-0} = addr{11-0}; // imm12
1728 def rs : AI2ldst<0b011, 1, isByte, (outs GPR:$Rt), (ins ldst_so_reg:$shift),
1729 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1730 [(set GPR:$Rt, (opnode ldst_so_reg:$shift))]> {
1733 let shift{4} = 0; // Inst{4} = 0
1734 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1735 let Inst{19-16} = shift{16-13}; // Rn
1736 let Inst{15-12} = Rt;
1737 let Inst{11-0} = shift{11-0};
1742 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1743 multiclass AI_ldr1nopc<bit isByte, string opc, InstrItinClass iii,
1744 InstrItinClass iir, PatFrag opnode> {
1745 // Note: We use the complex addrmode_imm12 rather than just an input
1746 // GPR and a constrained immediate so that we can use this to match
1747 // frame index references and avoid matching constant pool references.
1748 def i12: AI2ldst<0b010, 1, isByte, (outs GPRnopc:$Rt),
1749 (ins addrmode_imm12:$addr),
1750 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1751 [(set GPRnopc:$Rt, (opnode addrmode_imm12:$addr))]> {
1754 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1755 let Inst{19-16} = addr{16-13}; // Rn
1756 let Inst{15-12} = Rt;
1757 let Inst{11-0} = addr{11-0}; // imm12
1759 def rs : AI2ldst<0b011, 1, isByte, (outs GPRnopc:$Rt),
1760 (ins ldst_so_reg:$shift),
1761 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1762 [(set GPRnopc:$Rt, (opnode ldst_so_reg:$shift))]> {
1765 let shift{4} = 0; // Inst{4} = 0
1766 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1767 let Inst{19-16} = shift{16-13}; // Rn
1768 let Inst{15-12} = Rt;
1769 let Inst{11-0} = shift{11-0};
1775 multiclass AI_str1<bit isByte, string opc, InstrItinClass iii,
1776 InstrItinClass iir, PatFrag opnode> {
1777 // Note: We use the complex addrmode_imm12 rather than just an input
1778 // GPR and a constrained immediate so that we can use this to match
1779 // frame index references and avoid matching constant pool references.
1780 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1781 (ins GPR:$Rt, addrmode_imm12:$addr),
1782 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1783 [(opnode GPR:$Rt, addrmode_imm12:$addr)]> {
1786 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1787 let Inst{19-16} = addr{16-13}; // Rn
1788 let Inst{15-12} = Rt;
1789 let Inst{11-0} = addr{11-0}; // imm12
1791 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPR:$Rt, ldst_so_reg:$shift),
1792 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1793 [(opnode GPR:$Rt, ldst_so_reg:$shift)]> {
1796 let shift{4} = 0; // Inst{4} = 0
1797 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1798 let Inst{19-16} = shift{16-13}; // Rn
1799 let Inst{15-12} = Rt;
1800 let Inst{11-0} = shift{11-0};
1804 multiclass AI_str1nopc<bit isByte, string opc, InstrItinClass iii,
1805 InstrItinClass iir, PatFrag opnode> {
1806 // Note: We use the complex addrmode_imm12 rather than just an input
1807 // GPR and a constrained immediate so that we can use this to match
1808 // frame index references and avoid matching constant pool references.
1809 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1810 (ins GPRnopc:$Rt, addrmode_imm12:$addr),
1811 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1812 [(opnode GPRnopc:$Rt, addrmode_imm12:$addr)]> {
1815 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1816 let Inst{19-16} = addr{16-13}; // Rn
1817 let Inst{15-12} = Rt;
1818 let Inst{11-0} = addr{11-0}; // imm12
1820 def rs : AI2ldst<0b011, 0, isByte, (outs),
1821 (ins GPRnopc:$Rt, ldst_so_reg:$shift),
1822 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1823 [(opnode GPRnopc:$Rt, ldst_so_reg:$shift)]> {
1826 let shift{4} = 0; // Inst{4} = 0
1827 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1828 let Inst{19-16} = shift{16-13}; // Rn
1829 let Inst{15-12} = Rt;
1830 let Inst{11-0} = shift{11-0};
1835 //===----------------------------------------------------------------------===//
1837 //===----------------------------------------------------------------------===//
1839 //===----------------------------------------------------------------------===//
1840 // Miscellaneous Instructions.
1843 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
1844 /// the function. The first operand is the ID# for this instruction, the second
1845 /// is the index into the MachineConstantPool that this is, the third is the
1846 /// size in bytes of this constant pool entry.
1847 let hasSideEffects = 0, isNotDuplicable = 1 in
1848 def CONSTPOOL_ENTRY :
1849 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1850 i32imm:$size), NoItinerary, []>;
1852 // FIXME: Marking these as hasSideEffects is necessary to prevent machine DCE
1853 // from removing one half of the matched pairs. That breaks PEI, which assumes
1854 // these will always be in pairs, and asserts if it finds otherwise. Better way?
1855 let Defs = [SP], Uses = [SP], hasSideEffects = 1 in {
1856 def ADJCALLSTACKUP :
1857 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary,
1858 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
1860 def ADJCALLSTACKDOWN :
1861 PseudoInst<(outs), (ins i32imm:$amt, pred:$p), NoItinerary,
1862 [(ARMcallseq_start timm:$amt)]>;
1865 def HINT : AI<(outs), (ins imm0_239:$imm), MiscFrm, NoItinerary,
1866 "hint", "\t$imm", [(int_arm_hint imm0_239:$imm)]>,
1867 Requires<[IsARM, HasV6]> {
1869 let Inst{27-8} = 0b00110010000011110000;
1870 let Inst{7-0} = imm;
1873 def : InstAlias<"nop$p", (HINT 0, pred:$p)>, Requires<[IsARM, HasV6T2]>;
1874 def : InstAlias<"yield$p", (HINT 1, pred:$p)>, Requires<[IsARM, HasV6T2]>;
1875 def : InstAlias<"wfe$p", (HINT 2, pred:$p)>, Requires<[IsARM, HasV6T2]>;
1876 def : InstAlias<"wfi$p", (HINT 3, pred:$p)>, Requires<[IsARM, HasV6T2]>;
1877 def : InstAlias<"sev$p", (HINT 4, pred:$p)>, Requires<[IsARM, HasV6T2]>;
1878 def : InstAlias<"sevl$p", (HINT 5, pred:$p)>, Requires<[IsARM, HasV8]>;
1880 def SEL : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, NoItinerary, "sel",
1881 "\t$Rd, $Rn, $Rm", []>, Requires<[IsARM, HasV6]> {
1886 let Inst{15-12} = Rd;
1887 let Inst{19-16} = Rn;
1888 let Inst{27-20} = 0b01101000;
1889 let Inst{7-4} = 0b1011;
1890 let Inst{11-8} = 0b1111;
1891 let Unpredictable{11-8} = 0b1111;
1894 // The 16-bit operand $val can be used by a debugger to store more information
1895 // about the breakpoint.
1896 def BKPT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
1897 "bkpt", "\t$val", []>, Requires<[IsARM]> {
1899 let Inst{3-0} = val{3-0};
1900 let Inst{19-8} = val{15-4};
1901 let Inst{27-20} = 0b00010010;
1902 let Inst{31-28} = 0xe; // AL
1903 let Inst{7-4} = 0b0111;
1905 // default immediate for breakpoint mnemonic
1906 def : InstAlias<"bkpt", (BKPT 0)>, Requires<[IsARM]>;
1908 def HLT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
1909 "hlt", "\t$val", []>, Requires<[IsARM, HasV8]> {
1911 let Inst{3-0} = val{3-0};
1912 let Inst{19-8} = val{15-4};
1913 let Inst{27-20} = 0b00010000;
1914 let Inst{31-28} = 0xe; // AL
1915 let Inst{7-4} = 0b0111;
1918 // Change Processor State
1919 // FIXME: We should use InstAlias to handle the optional operands.
1920 class CPS<dag iops, string asm_ops>
1921 : AXI<(outs), iops, MiscFrm, NoItinerary, !strconcat("cps", asm_ops),
1922 []>, Requires<[IsARM]> {
1928 let Inst{31-28} = 0b1111;
1929 let Inst{27-20} = 0b00010000;
1930 let Inst{19-18} = imod;
1931 let Inst{17} = M; // Enabled if mode is set;
1932 let Inst{16-9} = 0b00000000;
1933 let Inst{8-6} = iflags;
1935 let Inst{4-0} = mode;
1938 let DecoderMethod = "DecodeCPSInstruction" in {
1940 def CPS3p : CPS<(ins imod_op:$imod, iflags_op:$iflags, imm0_31:$mode),
1941 "$imod\t$iflags, $mode">;
1942 let mode = 0, M = 0 in
1943 def CPS2p : CPS<(ins imod_op:$imod, iflags_op:$iflags), "$imod\t$iflags">;
1945 let imod = 0, iflags = 0, M = 1 in
1946 def CPS1p : CPS<(ins imm0_31:$mode), "\t$mode">;
1949 // Preload signals the memory system of possible future data/instruction access.
1950 multiclass APreLoad<bits<1> read, bits<1> data, string opc> {
1952 def i12 : AXIM<(outs), (ins addrmode_imm12:$addr), AddrMode_i12, MiscFrm,
1953 IIC_Preload, !strconcat(opc, "\t$addr"),
1954 [(ARMPreload addrmode_imm12:$addr, (i32 read), (i32 data))]>,
1955 Sched<[WritePreLd]> {
1958 let Inst{31-26} = 0b111101;
1959 let Inst{25} = 0; // 0 for immediate form
1960 let Inst{24} = data;
1961 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1962 let Inst{22} = read;
1963 let Inst{21-20} = 0b01;
1964 let Inst{19-16} = addr{16-13}; // Rn
1965 let Inst{15-12} = 0b1111;
1966 let Inst{11-0} = addr{11-0}; // imm12
1969 def rs : AXI<(outs), (ins ldst_so_reg:$shift), MiscFrm, IIC_Preload,
1970 !strconcat(opc, "\t$shift"),
1971 [(ARMPreload ldst_so_reg:$shift, (i32 read), (i32 data))]>,
1972 Sched<[WritePreLd]> {
1974 let Inst{31-26} = 0b111101;
1975 let Inst{25} = 1; // 1 for register form
1976 let Inst{24} = data;
1977 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1978 let Inst{22} = read;
1979 let Inst{21-20} = 0b01;
1980 let Inst{19-16} = shift{16-13}; // Rn
1981 let Inst{15-12} = 0b1111;
1982 let Inst{11-0} = shift{11-0};
1987 defm PLD : APreLoad<1, 1, "pld">, Requires<[IsARM]>;
1988 defm PLDW : APreLoad<0, 1, "pldw">, Requires<[IsARM,HasV7,HasMP]>;
1989 defm PLI : APreLoad<1, 0, "pli">, Requires<[IsARM,HasV7]>;
1991 def SETEND : AXI<(outs), (ins setend_op:$end), MiscFrm, NoItinerary,
1992 "setend\t$end", []>, Requires<[IsARM]>, Deprecated<HasV8Ops> {
1994 let Inst{31-10} = 0b1111000100000001000000;
1999 def DBG : AI<(outs), (ins imm0_15:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt",
2000 [(int_arm_dbg imm0_15:$opt)]>, Requires<[IsARM, HasV7]> {
2002 let Inst{27-4} = 0b001100100000111100001111;
2003 let Inst{3-0} = opt;
2006 // A8.8.247 UDF - Undefined (Encoding A1)
2007 def UDF : AInoP<(outs), (ins imm0_65535:$imm16), MiscFrm, NoItinerary,
2008 "udf", "\t$imm16", [(int_arm_undefined imm0_65535:$imm16)]> {
2010 let Inst{31-28} = 0b1110; // AL
2011 let Inst{27-25} = 0b011;
2012 let Inst{24-20} = 0b11111;
2013 let Inst{19-8} = imm16{15-4};
2014 let Inst{7-4} = 0b1111;
2015 let Inst{3-0} = imm16{3-0};
2019 * A5.4 Permanently UNDEFINED instructions.
2021 * For most targets use UDF #65006, for which the OS will generate SIGTRAP.
2022 * Other UDF encodings generate SIGILL.
2024 * NaCl's OS instead chooses an ARM UDF encoding that's also a UDF in Thumb.
2026 * 1110 0111 1111 iiii iiii iiii 1111 iiii
2028 * 1101 1110 iiii iiii
2029 * It uses the following encoding:
2030 * 1110 0111 1111 1110 1101 1110 1111 0000
2031 * - In ARM: UDF #60896;
2032 * - In Thumb: UDF #254 followed by a branch-to-self.
2034 let isBarrier = 1, isTerminator = 1 in
2035 def TRAPNaCl : AXI<(outs), (ins), MiscFrm, NoItinerary,
2037 Requires<[IsARM,UseNaClTrap]> {
2038 let Inst = 0xe7fedef0;
2040 let isBarrier = 1, isTerminator = 1 in
2041 def TRAP : AXI<(outs), (ins), MiscFrm, NoItinerary,
2043 Requires<[IsARM,DontUseNaClTrap]> {
2044 let Inst = 0xe7ffdefe;
2047 // Address computation and loads and stores in PIC mode.
2048 let isNotDuplicable = 1 in {
2049 def PICADD : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
2051 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>,
2052 Sched<[WriteALU, ReadALU]>;
2054 let AddedComplexity = 10 in {
2055 def PICLDR : ARMPseudoInst<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
2057 [(set GPR:$dst, (load addrmodepc:$addr))]>;
2059 def PICLDRH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2061 [(set GPR:$Rt, (zextloadi16 addrmodepc:$addr))]>;
2063 def PICLDRB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2065 [(set GPR:$Rt, (zextloadi8 addrmodepc:$addr))]>;
2067 def PICLDRSH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2069 [(set GPR:$Rt, (sextloadi16 addrmodepc:$addr))]>;
2071 def PICLDRSB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2073 [(set GPR:$Rt, (sextloadi8 addrmodepc:$addr))]>;
2075 let AddedComplexity = 10 in {
2076 def PICSTR : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2077 4, IIC_iStore_r, [(store GPR:$src, addrmodepc:$addr)]>;
2079 def PICSTRH : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2080 4, IIC_iStore_bh_r, [(truncstorei16 GPR:$src,
2081 addrmodepc:$addr)]>;
2083 def PICSTRB : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2084 4, IIC_iStore_bh_r, [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
2086 } // isNotDuplicable = 1
2089 // LEApcrel - Load a pc-relative address into a register without offending the
2091 let hasSideEffects = 0, isReMaterializable = 1 in
2092 // The 'adr' mnemonic encodes differently if the label is before or after
2093 // the instruction. The {24-21} opcode bits are set by the fixup, as we don't
2094 // know until then which form of the instruction will be used.
2095 def ADR : AI1<{0,?,?,0}, (outs GPR:$Rd), (ins adrlabel:$label),
2096 MiscFrm, IIC_iALUi, "adr", "\t$Rd, $label", []>,
2097 Sched<[WriteALU, ReadALU]> {
2100 let Inst{27-25} = 0b001;
2102 let Inst{23-22} = label{13-12};
2105 let Inst{19-16} = 0b1111;
2106 let Inst{15-12} = Rd;
2107 let Inst{11-0} = label{11-0};
2110 let hasSideEffects = 1 in {
2111 def LEApcrel : ARMPseudoInst<(outs GPR:$Rd), (ins i32imm:$label, pred:$p),
2112 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
2114 def LEApcrelJT : ARMPseudoInst<(outs GPR:$Rd),
2115 (ins i32imm:$label, nohash_imm:$id, pred:$p),
2116 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
2119 //===----------------------------------------------------------------------===//
2120 // Control Flow Instructions.
2123 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
2125 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
2126 "bx", "\tlr", [(ARMretflag)]>,
2127 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2128 let Inst{27-0} = 0b0001001011111111111100011110;
2132 def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br,
2133 "mov", "\tpc, lr", [(ARMretflag)]>,
2134 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]> {
2135 let Inst{27-0} = 0b0001101000001111000000001110;
2138 // Exception return: N.b. doesn't set CPSR as far as we're concerned (it sets
2139 // the user-space one).
2140 def SUBS_PC_LR : ARMPseudoInst<(outs), (ins i32imm:$offset, pred:$p),
2142 [(ARMintretflag imm:$offset)]>;
2145 // Indirect branches
2146 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
2148 def BX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
2149 [(brind GPR:$dst)]>,
2150 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2152 let Inst{31-4} = 0b1110000100101111111111110001;
2153 let Inst{3-0} = dst;
2156 def BX_pred : AI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br,
2157 "bx", "\t$dst", [/* pattern left blank */]>,
2158 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2160 let Inst{27-4} = 0b000100101111111111110001;
2161 let Inst{3-0} = dst;
2165 // SP is marked as a use to prevent stack-pointer assignments that appear
2166 // immediately before calls from potentially appearing dead.
2168 // FIXME: Do we really need a non-predicated version? If so, it should
2169 // at least be a pseudo instruction expanding to the predicated version
2170 // at MC lowering time.
2171 Defs = [LR], Uses = [SP] in {
2172 def BL : ABXI<0b1011, (outs), (ins bl_target:$func),
2173 IIC_Br, "bl\t$func",
2174 [(ARMcall tglobaladdr:$func)]>,
2175 Requires<[IsARM]>, Sched<[WriteBrL]> {
2176 let Inst{31-28} = 0b1110;
2178 let Inst{23-0} = func;
2179 let DecoderMethod = "DecodeBranchImmInstruction";
2182 def BL_pred : ABI<0b1011, (outs), (ins bl_target:$func),
2183 IIC_Br, "bl", "\t$func",
2184 [(ARMcall_pred tglobaladdr:$func)]>,
2185 Requires<[IsARM]>, Sched<[WriteBrL]> {
2187 let Inst{23-0} = func;
2188 let DecoderMethod = "DecodeBranchImmInstruction";
2192 def BLX : AXI<(outs), (ins GPR:$func), BrMiscFrm,
2193 IIC_Br, "blx\t$func",
2194 [(ARMcall GPR:$func)]>,
2195 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2197 let Inst{31-4} = 0b1110000100101111111111110011;
2198 let Inst{3-0} = func;
2201 def BLX_pred : AI<(outs), (ins GPR:$func), BrMiscFrm,
2202 IIC_Br, "blx", "\t$func",
2203 [(ARMcall_pred GPR:$func)]>,
2204 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2206 let Inst{27-4} = 0b000100101111111111110011;
2207 let Inst{3-0} = func;
2211 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
2212 def BX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
2213 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
2214 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]>;
2217 def BMOVPCRX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
2218 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
2219 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
2221 // mov lr, pc; b if callee is marked noreturn to avoid confusing the
2222 // return stack predictor.
2223 def BMOVPCB_CALL : ARMPseudoInst<(outs), (ins bl_target:$func),
2224 8, IIC_Br, [(ARMcall_nolink tglobaladdr:$func)]>,
2225 Requires<[IsARM]>, Sched<[WriteBr]>;
2228 let isBranch = 1, isTerminator = 1 in {
2229 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
2230 // a two-value operand where a dag node expects two operands. :(
2231 def Bcc : ABI<0b1010, (outs), (ins br_target:$target),
2232 IIC_Br, "b", "\t$target",
2233 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>,
2236 let Inst{23-0} = target;
2237 let DecoderMethod = "DecodeBranchImmInstruction";
2240 let isBarrier = 1 in {
2241 // B is "predicable" since it's just a Bcc with an 'always' condition.
2242 let isPredicable = 1 in
2243 // FIXME: We shouldn't need this pseudo at all. Just using Bcc directly
2244 // should be sufficient.
2245 // FIXME: Is B really a Barrier? That doesn't seem right.
2246 def B : ARMPseudoExpand<(outs), (ins br_target:$target), 4, IIC_Br,
2247 [(br bb:$target)], (Bcc br_target:$target, (ops 14, zero_reg))>,
2250 let isNotDuplicable = 1, isIndirectBranch = 1 in {
2251 def BR_JTr : ARMPseudoInst<(outs),
2252 (ins GPR:$target, i32imm:$jt, i32imm:$id),
2254 [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]>,
2256 // FIXME: This shouldn't use the generic "addrmode2," but rather be split
2257 // into i12 and rs suffixed versions.
2258 def BR_JTm : ARMPseudoInst<(outs),
2259 (ins addrmode2:$target, i32imm:$jt, i32imm:$id),
2261 [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
2262 imm:$id)]>, Sched<[WriteBrTbl]>;
2263 def BR_JTadd : ARMPseudoInst<(outs),
2264 (ins GPR:$target, GPR:$idx, i32imm:$jt, i32imm:$id),
2266 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
2267 imm:$id)]>, Sched<[WriteBrTbl]>;
2268 } // isNotDuplicable = 1, isIndirectBranch = 1
2274 def BLXi : AXI<(outs), (ins blx_target:$target), BrMiscFrm, NoItinerary,
2275 "blx\t$target", []>,
2276 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2277 let Inst{31-25} = 0b1111101;
2279 let Inst{23-0} = target{24-1};
2280 let Inst{24} = target{0};
2283 // Branch and Exchange Jazelle
2284 def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func",
2285 [/* pattern left blank */]>, Sched<[WriteBr]> {
2287 let Inst{23-20} = 0b0010;
2288 let Inst{19-8} = 0xfff;
2289 let Inst{7-4} = 0b0010;
2290 let Inst{3-0} = func;
2295 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in {
2296 def TCRETURNdi : PseudoInst<(outs), (ins i32imm:$dst), IIC_Br, []>,
2299 def TCRETURNri : PseudoInst<(outs), (ins tcGPR:$dst), IIC_Br, []>,
2302 def TAILJMPd : ARMPseudoExpand<(outs), (ins br_target:$dst),
2304 (Bcc br_target:$dst, (ops 14, zero_reg))>,
2305 Requires<[IsARM]>, Sched<[WriteBr]>;
2307 def TAILJMPr : ARMPseudoExpand<(outs), (ins tcGPR:$dst),
2309 (BX GPR:$dst)>, Sched<[WriteBr]>,
2313 // Secure Monitor Call is a system instruction.
2314 def SMC : ABI<0b0001, (outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt",
2315 []>, Requires<[IsARM, HasTrustZone]> {
2317 let Inst{23-4} = 0b01100000000000000111;
2318 let Inst{3-0} = opt;
2321 // Supervisor Call (Software Interrupt)
2322 let isCall = 1, Uses = [SP] in {
2323 def SVC : ABI<0b1111, (outs), (ins imm24b:$svc), IIC_Br, "svc", "\t$svc", []>,
2326 let Inst{23-0} = svc;
2330 // Store Return State
2331 class SRSI<bit wb, string asm>
2332 : XI<(outs), (ins imm0_31:$mode), AddrModeNone, 4, IndexModeNone, BrFrm,
2333 NoItinerary, asm, "", []> {
2335 let Inst{31-28} = 0b1111;
2336 let Inst{27-25} = 0b100;
2340 let Inst{19-16} = 0b1101; // SP
2341 let Inst{15-5} = 0b00000101000;
2342 let Inst{4-0} = mode;
2345 def SRSDA : SRSI<0, "srsda\tsp, $mode"> {
2346 let Inst{24-23} = 0;
2348 def SRSDA_UPD : SRSI<1, "srsda\tsp!, $mode"> {
2349 let Inst{24-23} = 0;
2351 def SRSDB : SRSI<0, "srsdb\tsp, $mode"> {
2352 let Inst{24-23} = 0b10;
2354 def SRSDB_UPD : SRSI<1, "srsdb\tsp!, $mode"> {
2355 let Inst{24-23} = 0b10;
2357 def SRSIA : SRSI<0, "srsia\tsp, $mode"> {
2358 let Inst{24-23} = 0b01;
2360 def SRSIA_UPD : SRSI<1, "srsia\tsp!, $mode"> {
2361 let Inst{24-23} = 0b01;
2363 def SRSIB : SRSI<0, "srsib\tsp, $mode"> {
2364 let Inst{24-23} = 0b11;
2366 def SRSIB_UPD : SRSI<1, "srsib\tsp!, $mode"> {
2367 let Inst{24-23} = 0b11;
2370 def : ARMInstAlias<"srsda $mode", (SRSDA imm0_31:$mode)>;
2371 def : ARMInstAlias<"srsda $mode!", (SRSDA_UPD imm0_31:$mode)>;
2373 def : ARMInstAlias<"srsdb $mode", (SRSDB imm0_31:$mode)>;
2374 def : ARMInstAlias<"srsdb $mode!", (SRSDB_UPD imm0_31:$mode)>;
2376 def : ARMInstAlias<"srsia $mode", (SRSIA imm0_31:$mode)>;
2377 def : ARMInstAlias<"srsia $mode!", (SRSIA_UPD imm0_31:$mode)>;
2379 def : ARMInstAlias<"srsib $mode", (SRSIB imm0_31:$mode)>;
2380 def : ARMInstAlias<"srsib $mode!", (SRSIB_UPD imm0_31:$mode)>;
2382 // Return From Exception
2383 class RFEI<bit wb, string asm>
2384 : XI<(outs), (ins GPR:$Rn), AddrModeNone, 4, IndexModeNone, BrFrm,
2385 NoItinerary, asm, "", []> {
2387 let Inst{31-28} = 0b1111;
2388 let Inst{27-25} = 0b100;
2392 let Inst{19-16} = Rn;
2393 let Inst{15-0} = 0xa00;
2396 def RFEDA : RFEI<0, "rfeda\t$Rn"> {
2397 let Inst{24-23} = 0;
2399 def RFEDA_UPD : RFEI<1, "rfeda\t$Rn!"> {
2400 let Inst{24-23} = 0;
2402 def RFEDB : RFEI<0, "rfedb\t$Rn"> {
2403 let Inst{24-23} = 0b10;
2405 def RFEDB_UPD : RFEI<1, "rfedb\t$Rn!"> {
2406 let Inst{24-23} = 0b10;
2408 def RFEIA : RFEI<0, "rfeia\t$Rn"> {
2409 let Inst{24-23} = 0b01;
2411 def RFEIA_UPD : RFEI<1, "rfeia\t$Rn!"> {
2412 let Inst{24-23} = 0b01;
2414 def RFEIB : RFEI<0, "rfeib\t$Rn"> {
2415 let Inst{24-23} = 0b11;
2417 def RFEIB_UPD : RFEI<1, "rfeib\t$Rn!"> {
2418 let Inst{24-23} = 0b11;
2421 // Hypervisor Call is a system instruction
2423 def HVC : AInoP< (outs), (ins imm0_65535:$imm), BrFrm, NoItinerary,
2424 "hvc", "\t$imm", []>,
2425 Requires<[IsARM, HasVirtualization]> {
2428 // Even though HVC isn't predicable, it's encoding includes a condition field.
2429 // The instruction is undefined if the condition field is 0xf otherwise it is
2430 // unpredictable if it isn't condition AL (0xe).
2431 let Inst{31-28} = 0b1110;
2432 let Unpredictable{31-28} = 0b1111;
2433 let Inst{27-24} = 0b0001;
2434 let Inst{23-20} = 0b0100;
2435 let Inst{19-8} = imm{15-4};
2436 let Inst{7-4} = 0b0111;
2437 let Inst{3-0} = imm{3-0};
2441 // Return from exception in Hypervisor mode.
2442 let isReturn = 1, isBarrier = 1, isTerminator = 1, Defs = [PC] in
2443 def ERET : ABI<0b0001, (outs), (ins), NoItinerary, "eret", "", []>,
2444 Requires<[IsARM, HasVirtualization]> {
2445 let Inst{23-0} = 0b011000000000000001101110;
2448 //===----------------------------------------------------------------------===//
2449 // Load / Store Instructions.
2455 defm LDR : AI_ldr1<0, "ldr", IIC_iLoad_r, IIC_iLoad_si,
2456 UnOpFrag<(load node:$Src)>>;
2457 defm LDRB : AI_ldr1nopc<1, "ldrb", IIC_iLoad_bh_r, IIC_iLoad_bh_si,
2458 UnOpFrag<(zextloadi8 node:$Src)>>;
2459 defm STR : AI_str1<0, "str", IIC_iStore_r, IIC_iStore_si,
2460 BinOpFrag<(store node:$LHS, node:$RHS)>>;
2461 defm STRB : AI_str1nopc<1, "strb", IIC_iStore_bh_r, IIC_iStore_bh_si,
2462 BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
2464 // Special LDR for loads from non-pc-relative constpools.
2465 let canFoldAsLoad = 1, mayLoad = 1, hasSideEffects = 0,
2466 isReMaterializable = 1, isCodeGenOnly = 1 in
2467 def LDRcp : AI2ldst<0b010, 1, 0, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
2468 AddrMode_i12, LdFrm, IIC_iLoad_r, "ldr", "\t$Rt, $addr",
2472 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2473 let Inst{19-16} = 0b1111;
2474 let Inst{15-12} = Rt;
2475 let Inst{11-0} = addr{11-0}; // imm12
2478 // Loads with zero extension
2479 def LDRH : AI3ld<0b1011, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2480 IIC_iLoad_bh_r, "ldrh", "\t$Rt, $addr",
2481 [(set GPR:$Rt, (zextloadi16 addrmode3:$addr))]>;
2483 // Loads with sign extension
2484 def LDRSH : AI3ld<0b1111, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2485 IIC_iLoad_bh_r, "ldrsh", "\t$Rt, $addr",
2486 [(set GPR:$Rt, (sextloadi16 addrmode3:$addr))]>;
2488 def LDRSB : AI3ld<0b1101, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2489 IIC_iLoad_bh_r, "ldrsb", "\t$Rt, $addr",
2490 [(set GPR:$Rt, (sextloadi8 addrmode3:$addr))]>;
2492 let mayLoad = 1, hasSideEffects = 0, hasExtraDefRegAllocReq = 1 in {
2494 def LDRD : AI3ld<0b1101, 0, (outs GPR:$Rt, GPR:$Rt2), (ins addrmode3:$addr),
2495 LdMiscFrm, IIC_iLoad_d_r, "ldrd", "\t$Rt, $Rt2, $addr", []>,
2496 Requires<[IsARM, HasV5TE]>;
2499 def LDA : AIldracq<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2500 NoItinerary, "lda", "\t$Rt, $addr", []>;
2501 def LDAB : AIldracq<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2502 NoItinerary, "ldab", "\t$Rt, $addr", []>;
2503 def LDAH : AIldracq<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2504 NoItinerary, "ldah", "\t$Rt, $addr", []>;
2507 multiclass AI2_ldridx<bit isByte, string opc,
2508 InstrItinClass iii, InstrItinClass iir> {
2509 def _PRE_IMM : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2510 (ins addrmode_imm12_pre:$addr), IndexModePre, LdFrm, iii,
2511 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2514 let Inst{23} = addr{12};
2515 let Inst{19-16} = addr{16-13};
2516 let Inst{11-0} = addr{11-0};
2517 let DecoderMethod = "DecodeLDRPreImm";
2520 def _PRE_REG : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2521 (ins ldst_so_reg:$addr), IndexModePre, LdFrm, iir,
2522 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2525 let Inst{23} = addr{12};
2526 let Inst{19-16} = addr{16-13};
2527 let Inst{11-0} = addr{11-0};
2529 let DecoderMethod = "DecodeLDRPreReg";
2532 def _POST_REG : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2533 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2534 IndexModePost, LdFrm, iir,
2535 opc, "\t$Rt, $addr, $offset",
2536 "$addr.base = $Rn_wb", []> {
2542 let Inst{23} = offset{12};
2543 let Inst{19-16} = addr;
2544 let Inst{11-0} = offset{11-0};
2547 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2550 def _POST_IMM : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2551 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2552 IndexModePost, LdFrm, iii,
2553 opc, "\t$Rt, $addr, $offset",
2554 "$addr.base = $Rn_wb", []> {
2560 let Inst{23} = offset{12};
2561 let Inst{19-16} = addr;
2562 let Inst{11-0} = offset{11-0};
2564 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2569 let mayLoad = 1, hasSideEffects = 0 in {
2570 // FIXME: for LDR_PRE_REG etc. the itineray should be either IIC_iLoad_ru or
2571 // IIC_iLoad_siu depending on whether it the offset register is shifted.
2572 defm LDR : AI2_ldridx<0, "ldr", IIC_iLoad_iu, IIC_iLoad_ru>;
2573 defm LDRB : AI2_ldridx<1, "ldrb", IIC_iLoad_bh_iu, IIC_iLoad_bh_ru>;
2576 multiclass AI3_ldridx<bits<4> op, string opc, InstrItinClass itin> {
2577 def _PRE : AI3ldstidx<op, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2578 (ins addrmode3_pre:$addr), IndexModePre,
2580 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2582 let Inst{23} = addr{8}; // U bit
2583 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2584 let Inst{19-16} = addr{12-9}; // Rn
2585 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2586 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2587 let DecoderMethod = "DecodeAddrMode3Instruction";
2589 def _POST : AI3ldstidx<op, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2590 (ins addr_offset_none:$addr, am3offset:$offset),
2591 IndexModePost, LdMiscFrm, itin,
2592 opc, "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2596 let Inst{23} = offset{8}; // U bit
2597 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2598 let Inst{19-16} = addr;
2599 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2600 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2601 let DecoderMethod = "DecodeAddrMode3Instruction";
2605 let mayLoad = 1, hasSideEffects = 0 in {
2606 defm LDRH : AI3_ldridx<0b1011, "ldrh", IIC_iLoad_bh_ru>;
2607 defm LDRSH : AI3_ldridx<0b1111, "ldrsh", IIC_iLoad_bh_ru>;
2608 defm LDRSB : AI3_ldridx<0b1101, "ldrsb", IIC_iLoad_bh_ru>;
2609 let hasExtraDefRegAllocReq = 1 in {
2610 def LDRD_PRE : AI3ldstidx<0b1101, 0, 1, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2611 (ins addrmode3_pre:$addr), IndexModePre,
2612 LdMiscFrm, IIC_iLoad_d_ru,
2613 "ldrd", "\t$Rt, $Rt2, $addr!",
2614 "$addr.base = $Rn_wb", []> {
2616 let Inst{23} = addr{8}; // U bit
2617 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2618 let Inst{19-16} = addr{12-9}; // Rn
2619 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2620 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2621 let DecoderMethod = "DecodeAddrMode3Instruction";
2623 def LDRD_POST: AI3ldstidx<0b1101, 0, 0, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2624 (ins addr_offset_none:$addr, am3offset:$offset),
2625 IndexModePost, LdMiscFrm, IIC_iLoad_d_ru,
2626 "ldrd", "\t$Rt, $Rt2, $addr, $offset",
2627 "$addr.base = $Rn_wb", []> {
2630 let Inst{23} = offset{8}; // U bit
2631 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2632 let Inst{19-16} = addr;
2633 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2634 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2635 let DecoderMethod = "DecodeAddrMode3Instruction";
2637 } // hasExtraDefRegAllocReq = 1
2638 } // mayLoad = 1, hasSideEffects = 0
2640 // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT.
2641 let mayLoad = 1, hasSideEffects = 0 in {
2642 def LDRT_POST_REG : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2643 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2644 IndexModePost, LdFrm, IIC_iLoad_ru,
2645 "ldrt", "\t$Rt, $addr, $offset",
2646 "$addr.base = $Rn_wb", []> {
2652 let Inst{23} = offset{12};
2653 let Inst{21} = 1; // overwrite
2654 let Inst{19-16} = addr;
2655 let Inst{11-5} = offset{11-5};
2657 let Inst{3-0} = offset{3-0};
2658 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2662 : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2663 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2664 IndexModePost, LdFrm, IIC_iLoad_ru,
2665 "ldrt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2671 let Inst{23} = offset{12};
2672 let Inst{21} = 1; // overwrite
2673 let Inst{19-16} = addr;
2674 let Inst{11-0} = offset{11-0};
2675 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2678 def LDRBT_POST_REG : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2679 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2680 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2681 "ldrbt", "\t$Rt, $addr, $offset",
2682 "$addr.base = $Rn_wb", []> {
2688 let Inst{23} = offset{12};
2689 let Inst{21} = 1; // overwrite
2690 let Inst{19-16} = addr;
2691 let Inst{11-5} = offset{11-5};
2693 let Inst{3-0} = offset{3-0};
2694 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2698 : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2699 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2700 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2701 "ldrbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2707 let Inst{23} = offset{12};
2708 let Inst{21} = 1; // overwrite
2709 let Inst{19-16} = addr;
2710 let Inst{11-0} = offset{11-0};
2711 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2714 multiclass AI3ldrT<bits<4> op, string opc> {
2715 def i : AI3ldstidxT<op, 1, (outs GPR:$Rt, GPR:$base_wb),
2716 (ins addr_offset_none:$addr, postidx_imm8:$offset),
2717 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2718 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2720 let Inst{23} = offset{8};
2722 let Inst{11-8} = offset{7-4};
2723 let Inst{3-0} = offset{3-0};
2725 def r : AI3ldstidxT<op, 1, (outs GPRnopc:$Rt, GPRnopc:$base_wb),
2726 (ins addr_offset_none:$addr, postidx_reg:$Rm),
2727 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2728 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2730 let Inst{23} = Rm{4};
2733 let Unpredictable{11-8} = 0b1111;
2734 let Inst{3-0} = Rm{3-0};
2735 let DecoderMethod = "DecodeLDR";
2739 defm LDRSBT : AI3ldrT<0b1101, "ldrsbt">;
2740 defm LDRHT : AI3ldrT<0b1011, "ldrht">;
2741 defm LDRSHT : AI3ldrT<0b1111, "ldrsht">;
2745 : ARMAsmPseudo<"ldrt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q),
2749 : ARMAsmPseudo<"ldrbt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q),
2754 // Stores with truncate
2755 def STRH : AI3str<0b1011, (outs), (ins GPR:$Rt, addrmode3:$addr), StMiscFrm,
2756 IIC_iStore_bh_r, "strh", "\t$Rt, $addr",
2757 [(truncstorei16 GPR:$Rt, addrmode3:$addr)]>;
2760 let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
2761 def STRD : AI3str<0b1111, (outs), (ins GPR:$Rt, GPR:$Rt2, addrmode3:$addr),
2762 StMiscFrm, IIC_iStore_d_r, "strd", "\t$Rt, $Rt2, $addr", []>,
2763 Requires<[IsARM, HasV5TE]> {
2769 multiclass AI2_stridx<bit isByte, string opc,
2770 InstrItinClass iii, InstrItinClass iir> {
2771 def _PRE_IMM : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2772 (ins GPR:$Rt, addrmode_imm12_pre:$addr), IndexModePre,
2774 opc, "\t$Rt, $addr!",
2775 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2778 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2779 let Inst{19-16} = addr{16-13}; // Rn
2780 let Inst{11-0} = addr{11-0}; // imm12
2781 let DecoderMethod = "DecodeSTRPreImm";
2784 def _PRE_REG : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2785 (ins GPR:$Rt, ldst_so_reg:$addr),
2786 IndexModePre, StFrm, iir,
2787 opc, "\t$Rt, $addr!",
2788 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2791 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2792 let Inst{19-16} = addr{16-13}; // Rn
2793 let Inst{11-0} = addr{11-0};
2794 let Inst{4} = 0; // Inst{4} = 0
2795 let DecoderMethod = "DecodeSTRPreReg";
2797 def _POST_REG : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2798 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2799 IndexModePost, StFrm, iir,
2800 opc, "\t$Rt, $addr, $offset",
2801 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2807 let Inst{23} = offset{12};
2808 let Inst{19-16} = addr;
2809 let Inst{11-0} = offset{11-0};
2812 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2815 def _POST_IMM : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2816 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2817 IndexModePost, StFrm, iii,
2818 opc, "\t$Rt, $addr, $offset",
2819 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2825 let Inst{23} = offset{12};
2826 let Inst{19-16} = addr;
2827 let Inst{11-0} = offset{11-0};
2829 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2833 let mayStore = 1, hasSideEffects = 0 in {
2834 // FIXME: for STR_PRE_REG etc. the itineray should be either IIC_iStore_ru or
2835 // IIC_iStore_siu depending on whether it the offset register is shifted.
2836 defm STR : AI2_stridx<0, "str", IIC_iStore_iu, IIC_iStore_ru>;
2837 defm STRB : AI2_stridx<1, "strb", IIC_iStore_bh_iu, IIC_iStore_bh_ru>;
2840 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2841 am2offset_reg:$offset),
2842 (STR_POST_REG GPR:$Rt, addr_offset_none:$addr,
2843 am2offset_reg:$offset)>;
2844 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2845 am2offset_imm:$offset),
2846 (STR_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2847 am2offset_imm:$offset)>;
2848 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2849 am2offset_reg:$offset),
2850 (STRB_POST_REG GPR:$Rt, addr_offset_none:$addr,
2851 am2offset_reg:$offset)>;
2852 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2853 am2offset_imm:$offset),
2854 (STRB_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2855 am2offset_imm:$offset)>;
2857 // Pseudo-instructions for pattern matching the pre-indexed stores. We can't
2858 // put the patterns on the instruction definitions directly as ISel wants
2859 // the address base and offset to be separate operands, not a single
2860 // complex operand like we represent the instructions themselves. The
2861 // pseudos map between the two.
2862 let usesCustomInserter = 1,
2863 Constraints = "$Rn = $Rn_wb,@earlyclobber $Rn_wb" in {
2864 def STRi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2865 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2868 (pre_store GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2869 def STRr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2870 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2873 (pre_store GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2874 def STRBi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2875 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2878 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2879 def STRBr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2880 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2883 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2884 def STRH_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2885 (ins GPR:$Rt, GPR:$Rn, am3offset:$offset, pred:$p),
2888 (pre_truncsti16 GPR:$Rt, GPR:$Rn, am3offset:$offset))]>;
2893 def STRH_PRE : AI3ldstidx<0b1011, 0, 1, (outs GPR:$Rn_wb),
2894 (ins GPR:$Rt, addrmode3_pre:$addr), IndexModePre,
2895 StMiscFrm, IIC_iStore_bh_ru,
2896 "strh", "\t$Rt, $addr!",
2897 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2899 let Inst{23} = addr{8}; // U bit
2900 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2901 let Inst{19-16} = addr{12-9}; // Rn
2902 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2903 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2904 let DecoderMethod = "DecodeAddrMode3Instruction";
2907 def STRH_POST : AI3ldstidx<0b1011, 0, 0, (outs GPR:$Rn_wb),
2908 (ins GPR:$Rt, addr_offset_none:$addr, am3offset:$offset),
2909 IndexModePost, StMiscFrm, IIC_iStore_bh_ru,
2910 "strh", "\t$Rt, $addr, $offset",
2911 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb",
2912 [(set GPR:$Rn_wb, (post_truncsti16 GPR:$Rt,
2913 addr_offset_none:$addr,
2914 am3offset:$offset))]> {
2917 let Inst{23} = offset{8}; // U bit
2918 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2919 let Inst{19-16} = addr;
2920 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2921 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2922 let DecoderMethod = "DecodeAddrMode3Instruction";
2925 let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
2926 def STRD_PRE : AI3ldstidx<0b1111, 0, 1, (outs GPR:$Rn_wb),
2927 (ins GPR:$Rt, GPR:$Rt2, addrmode3_pre:$addr),
2928 IndexModePre, StMiscFrm, IIC_iStore_d_ru,
2929 "strd", "\t$Rt, $Rt2, $addr!",
2930 "$addr.base = $Rn_wb", []> {
2932 let Inst{23} = addr{8}; // U bit
2933 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2934 let Inst{19-16} = addr{12-9}; // Rn
2935 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2936 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2937 let DecoderMethod = "DecodeAddrMode3Instruction";
2940 def STRD_POST: AI3ldstidx<0b1111, 0, 0, (outs GPR:$Rn_wb),
2941 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr,
2943 IndexModePost, StMiscFrm, IIC_iStore_d_ru,
2944 "strd", "\t$Rt, $Rt2, $addr, $offset",
2945 "$addr.base = $Rn_wb", []> {
2948 let Inst{23} = offset{8}; // U bit
2949 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2950 let Inst{19-16} = addr;
2951 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2952 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2953 let DecoderMethod = "DecodeAddrMode3Instruction";
2955 } // mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1
2957 // STRT, STRBT, and STRHT
2959 def STRBT_POST_REG : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2960 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2961 IndexModePost, StFrm, IIC_iStore_bh_ru,
2962 "strbt", "\t$Rt, $addr, $offset",
2963 "$addr.base = $Rn_wb", []> {
2969 let Inst{23} = offset{12};
2970 let Inst{21} = 1; // overwrite
2971 let Inst{19-16} = addr;
2972 let Inst{11-5} = offset{11-5};
2974 let Inst{3-0} = offset{3-0};
2975 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2979 : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2980 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2981 IndexModePost, StFrm, IIC_iStore_bh_ru,
2982 "strbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2988 let Inst{23} = offset{12};
2989 let Inst{21} = 1; // overwrite
2990 let Inst{19-16} = addr;
2991 let Inst{11-0} = offset{11-0};
2992 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2996 : ARMAsmPseudo<"strbt${q} $Rt, $addr",
2997 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>;
2999 let mayStore = 1, hasSideEffects = 0 in {
3000 def STRT_POST_REG : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
3001 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
3002 IndexModePost, StFrm, IIC_iStore_ru,
3003 "strt", "\t$Rt, $addr, $offset",
3004 "$addr.base = $Rn_wb", []> {
3010 let Inst{23} = offset{12};
3011 let Inst{21} = 1; // overwrite
3012 let Inst{19-16} = addr;
3013 let Inst{11-5} = offset{11-5};
3015 let Inst{3-0} = offset{3-0};
3016 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3020 : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
3021 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
3022 IndexModePost, StFrm, IIC_iStore_ru,
3023 "strt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
3029 let Inst{23} = offset{12};
3030 let Inst{21} = 1; // overwrite
3031 let Inst{19-16} = addr;
3032 let Inst{11-0} = offset{11-0};
3033 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3038 : ARMAsmPseudo<"strt${q} $Rt, $addr",
3039 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>;
3041 multiclass AI3strT<bits<4> op, string opc> {
3042 def i : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
3043 (ins GPR:$Rt, addr_offset_none:$addr, postidx_imm8:$offset),
3044 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
3045 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
3047 let Inst{23} = offset{8};
3049 let Inst{11-8} = offset{7-4};
3050 let Inst{3-0} = offset{3-0};
3052 def r : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
3053 (ins GPR:$Rt, addr_offset_none:$addr, postidx_reg:$Rm),
3054 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
3055 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
3057 let Inst{23} = Rm{4};
3060 let Inst{3-0} = Rm{3-0};
3065 defm STRHT : AI3strT<0b1011, "strht">;
3067 def STL : AIstrrel<0b00, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3068 NoItinerary, "stl", "\t$Rt, $addr", []>;
3069 def STLB : AIstrrel<0b10, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3070 NoItinerary, "stlb", "\t$Rt, $addr", []>;
3071 def STLH : AIstrrel<0b11, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3072 NoItinerary, "stlh", "\t$Rt, $addr", []>;
3074 //===----------------------------------------------------------------------===//
3075 // Load / store multiple Instructions.
3078 multiclass arm_ldst_mult<string asm, string sfx, bit L_bit, bit P_bit, Format f,
3079 InstrItinClass itin, InstrItinClass itin_upd> {
3080 // IA is the default, so no need for an explicit suffix on the
3081 // mnemonic here. Without it is the canonical spelling.
3083 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3084 IndexModeNone, f, itin,
3085 !strconcat(asm, "${p}\t$Rn, $regs", sfx), "", []> {
3086 let Inst{24-23} = 0b01; // Increment After
3087 let Inst{22} = P_bit;
3088 let Inst{21} = 0; // No writeback
3089 let Inst{20} = L_bit;
3092 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3093 IndexModeUpd, f, itin_upd,
3094 !strconcat(asm, "${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3095 let Inst{24-23} = 0b01; // Increment After
3096 let Inst{22} = P_bit;
3097 let Inst{21} = 1; // Writeback
3098 let Inst{20} = L_bit;
3100 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3103 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3104 IndexModeNone, f, itin,
3105 !strconcat(asm, "da${p}\t$Rn, $regs", sfx), "", []> {
3106 let Inst{24-23} = 0b00; // Decrement After
3107 let Inst{22} = P_bit;
3108 let Inst{21} = 0; // No writeback
3109 let Inst{20} = L_bit;
3112 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3113 IndexModeUpd, f, itin_upd,
3114 !strconcat(asm, "da${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3115 let Inst{24-23} = 0b00; // Decrement After
3116 let Inst{22} = P_bit;
3117 let Inst{21} = 1; // Writeback
3118 let Inst{20} = L_bit;
3120 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3123 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3124 IndexModeNone, f, itin,
3125 !strconcat(asm, "db${p}\t$Rn, $regs", sfx), "", []> {
3126 let Inst{24-23} = 0b10; // Decrement Before
3127 let Inst{22} = P_bit;
3128 let Inst{21} = 0; // No writeback
3129 let Inst{20} = L_bit;
3132 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3133 IndexModeUpd, f, itin_upd,
3134 !strconcat(asm, "db${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3135 let Inst{24-23} = 0b10; // Decrement Before
3136 let Inst{22} = P_bit;
3137 let Inst{21} = 1; // Writeback
3138 let Inst{20} = L_bit;
3140 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3143 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3144 IndexModeNone, f, itin,
3145 !strconcat(asm, "ib${p}\t$Rn, $regs", sfx), "", []> {
3146 let Inst{24-23} = 0b11; // Increment Before
3147 let Inst{22} = P_bit;
3148 let Inst{21} = 0; // No writeback
3149 let Inst{20} = L_bit;
3152 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3153 IndexModeUpd, f, itin_upd,
3154 !strconcat(asm, "ib${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3155 let Inst{24-23} = 0b11; // Increment Before
3156 let Inst{22} = P_bit;
3157 let Inst{21} = 1; // Writeback
3158 let Inst{20} = L_bit;
3160 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3164 let hasSideEffects = 0 in {
3166 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
3167 defm LDM : arm_ldst_mult<"ldm", "", 1, 0, LdStMulFrm, IIC_iLoad_m,
3170 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
3171 defm STM : arm_ldst_mult<"stm", "", 0, 0, LdStMulFrm, IIC_iStore_m,
3176 // FIXME: remove when we have a way to marking a MI with these properties.
3177 // FIXME: Should pc be an implicit operand like PICADD, etc?
3178 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
3179 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
3180 def LDMIA_RET : ARMPseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p,
3181 reglist:$regs, variable_ops),
3182 4, IIC_iLoad_mBr, [],
3183 (LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>,
3184 RegConstraint<"$Rn = $wb">;
3186 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
3187 defm sysLDM : arm_ldst_mult<"ldm", " ^", 1, 1, LdStMulFrm, IIC_iLoad_m,
3190 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
3191 defm sysSTM : arm_ldst_mult<"stm", " ^", 0, 1, LdStMulFrm, IIC_iStore_m,
3196 //===----------------------------------------------------------------------===//
3197 // Move Instructions.
3200 let hasSideEffects = 0 in
3201 def MOVr : AsI1<0b1101, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMOVr,
3202 "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> {
3206 let Inst{19-16} = 0b0000;
3207 let Inst{11-4} = 0b00000000;
3210 let Inst{15-12} = Rd;
3213 // A version for the smaller set of tail call registers.
3214 let hasSideEffects = 0 in
3215 def MOVr_TC : AsI1<0b1101, (outs tcGPR:$Rd), (ins tcGPR:$Rm), DPFrm,
3216 IIC_iMOVr, "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> {
3220 let Inst{11-4} = 0b00000000;
3223 let Inst{15-12} = Rd;
3226 def MOVsr : AsI1<0b1101, (outs GPRnopc:$Rd), (ins shift_so_reg_reg:$src),
3227 DPSoRegRegFrm, IIC_iMOVsr,
3228 "mov", "\t$Rd, $src",
3229 [(set GPRnopc:$Rd, shift_so_reg_reg:$src)]>, UnaryDP,
3233 let Inst{15-12} = Rd;
3234 let Inst{19-16} = 0b0000;
3235 let Inst{11-8} = src{11-8};
3237 let Inst{6-5} = src{6-5};
3239 let Inst{3-0} = src{3-0};
3243 def MOVsi : AsI1<0b1101, (outs GPR:$Rd), (ins shift_so_reg_imm:$src),
3244 DPSoRegImmFrm, IIC_iMOVsr,
3245 "mov", "\t$Rd, $src", [(set GPR:$Rd, shift_so_reg_imm:$src)]>,
3246 UnaryDP, Sched<[WriteALU]> {
3249 let Inst{15-12} = Rd;
3250 let Inst{19-16} = 0b0000;
3251 let Inst{11-5} = src{11-5};
3253 let Inst{3-0} = src{3-0};
3257 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3258 def MOVi : AsI1<0b1101, (outs GPR:$Rd), (ins mod_imm:$imm), DPFrm, IIC_iMOVi,
3259 "mov", "\t$Rd, $imm", [(set GPR:$Rd, mod_imm:$imm)]>, UnaryDP,
3264 let Inst{15-12} = Rd;
3265 let Inst{19-16} = 0b0000;
3266 let Inst{11-0} = imm;
3269 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3270 def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins imm0_65535_expr:$imm),
3272 "movw", "\t$Rd, $imm",
3273 [(set GPR:$Rd, imm0_65535:$imm)]>,
3274 Requires<[IsARM, HasV6T2]>, UnaryDP, Sched<[WriteALU]> {
3277 let Inst{15-12} = Rd;
3278 let Inst{11-0} = imm{11-0};
3279 let Inst{19-16} = imm{15-12};
3282 let DecoderMethod = "DecodeArmMOVTWInstruction";
3285 def : InstAlias<"mov${p} $Rd, $imm",
3286 (MOVi16 GPR:$Rd, imm0_65535_expr:$imm, pred:$p)>,
3289 def MOVi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
3290 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
3293 let Constraints = "$src = $Rd" in {
3294 def MOVTi16 : AI1<0b1010, (outs GPRnopc:$Rd),
3295 (ins GPR:$src, imm0_65535_expr:$imm),
3297 "movt", "\t$Rd, $imm",
3299 (or (and GPR:$src, 0xffff),
3300 lo16AllZero:$imm))]>, UnaryDP,
3301 Requires<[IsARM, HasV6T2]>, Sched<[WriteALU]> {
3304 let Inst{15-12} = Rd;
3305 let Inst{11-0} = imm{11-0};
3306 let Inst{19-16} = imm{15-12};
3309 let DecoderMethod = "DecodeArmMOVTWInstruction";
3312 def MOVTi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
3313 (ins GPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
3318 def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
3319 Requires<[IsARM, HasV6T2]>;
3321 let Uses = [CPSR] in
3322 def RRX: PseudoInst<(outs GPR:$Rd), (ins GPR:$Rm), IIC_iMOVsi,
3323 [(set GPR:$Rd, (ARMrrx GPR:$Rm))]>, UnaryDP,
3324 Requires<[IsARM]>, Sched<[WriteALU]>;
3326 // These aren't really mov instructions, but we have to define them this way
3327 // due to flag operands.
3329 let Defs = [CPSR] in {
3330 def MOVsrl_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3331 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP,
3332 Sched<[WriteALU]>, Requires<[IsARM]>;
3333 def MOVsra_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3334 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP,
3335 Sched<[WriteALU]>, Requires<[IsARM]>;
3338 //===----------------------------------------------------------------------===//
3339 // Extend Instructions.
3344 def SXTB : AI_ext_rrot<0b01101010,
3345 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
3346 def SXTH : AI_ext_rrot<0b01101011,
3347 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
3349 def SXTAB : AI_exta_rrot<0b01101010,
3350 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
3351 def SXTAH : AI_exta_rrot<0b01101011,
3352 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
3354 def SXTB16 : AI_ext_rrot_np<0b01101000, "sxtb16">;
3356 def SXTAB16 : AI_exta_rrot_np<0b01101000, "sxtab16">;
3360 let AddedComplexity = 16 in {
3361 def UXTB : AI_ext_rrot<0b01101110,
3362 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
3363 def UXTH : AI_ext_rrot<0b01101111,
3364 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
3365 def UXTB16 : AI_ext_rrot<0b01101100,
3366 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
3368 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
3369 // The transformation should probably be done as a combiner action
3370 // instead so we can include a check for masking back in the upper
3371 // eight bits of the source into the lower eight bits of the result.
3372 //def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
3373 // (UXTB16r_rot GPR:$Src, 3)>;
3374 def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
3375 (UXTB16 GPR:$Src, 1)>;
3377 def UXTAB : AI_exta_rrot<0b01101110, "uxtab",
3378 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
3379 def UXTAH : AI_exta_rrot<0b01101111, "uxtah",
3380 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
3383 // This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
3384 def UXTAB16 : AI_exta_rrot_np<0b01101100, "uxtab16">;
3387 def SBFX : I<(outs GPRnopc:$Rd),
3388 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3389 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3390 "sbfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3391 Requires<[IsARM, HasV6T2]> {
3396 let Inst{27-21} = 0b0111101;
3397 let Inst{6-4} = 0b101;
3398 let Inst{20-16} = width;
3399 let Inst{15-12} = Rd;
3400 let Inst{11-7} = lsb;
3404 def UBFX : I<(outs GPRnopc:$Rd),
3405 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3406 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3407 "ubfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3408 Requires<[IsARM, HasV6T2]> {
3413 let Inst{27-21} = 0b0111111;
3414 let Inst{6-4} = 0b101;
3415 let Inst{20-16} = width;
3416 let Inst{15-12} = Rd;
3417 let Inst{11-7} = lsb;
3421 //===----------------------------------------------------------------------===//
3422 // Arithmetic Instructions.
3425 defm ADD : AsI1_bin_irs<0b0100, "add",
3426 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3427 BinOpFrag<(add node:$LHS, node:$RHS)>, 1>;
3428 defm SUB : AsI1_bin_irs<0b0010, "sub",
3429 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3430 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
3432 // ADD and SUB with 's' bit set.
3434 // Currently, ADDS/SUBS are pseudo opcodes that exist only in the
3435 // selection DAG. They are "lowered" to real ADD/SUB opcodes by
3436 // AdjustInstrPostInstrSelection where we determine whether or not to
3437 // set the "s" bit based on CPSR liveness.
3439 // FIXME: Eliminate ADDS/SUBS pseudo opcodes after adding tablegen
3440 // support for an optional CPSR definition that corresponds to the DAG
3441 // node's second value. We can then eliminate the implicit def of CPSR.
3442 defm ADDS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3443 BinOpFrag<(ARMaddc node:$LHS, node:$RHS)>, 1>;
3444 defm SUBS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3445 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
3447 defm ADC : AI1_adde_sube_irs<0b0101, "adc",
3448 BinOpWithFlagFrag<(ARMadde node:$LHS, node:$RHS, node:$FLAG)>, 1>;
3449 defm SBC : AI1_adde_sube_irs<0b0110, "sbc",
3450 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>>;
3452 defm RSB : AsI1_rbin_irs<0b0011, "rsb",
3453 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3454 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
3456 // FIXME: Eliminate them if we can write def : Pat patterns which defines
3457 // CPSR and the implicit def of CPSR is not needed.
3458 defm RSBS : AsI1_rbin_s_is<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3459 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
3461 defm RSC : AI1_rsc_irs<0b0111, "rsc",
3462 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>>;
3464 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
3465 // The assume-no-carry-in form uses the negation of the input since add/sub
3466 // assume opposite meanings of the carry flag (i.e., carry == !borrow).
3467 // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
3469 def : ARMPat<(add GPR:$src, so_imm_neg:$imm),
3470 (SUBri GPR:$src, so_imm_neg:$imm)>;
3471 def : ARMPat<(ARMaddc GPR:$src, so_imm_neg:$imm),
3472 (SUBSri GPR:$src, so_imm_neg:$imm)>;
3474 def : ARMPat<(add GPR:$src, imm0_65535_neg:$imm),
3475 (SUBrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>,
3476 Requires<[IsARM, HasV6T2]>;
3477 def : ARMPat<(ARMaddc GPR:$src, imm0_65535_neg:$imm),
3478 (SUBSrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>,
3479 Requires<[IsARM, HasV6T2]>;
3481 // The with-carry-in form matches bitwise not instead of the negation.
3482 // Effectively, the inverse interpretation of the carry flag already accounts
3483 // for part of the negation.
3484 def : ARMPat<(ARMadde GPR:$src, so_imm_not:$imm, CPSR),
3485 (SBCri GPR:$src, so_imm_not:$imm)>;
3486 def : ARMPat<(ARMadde GPR:$src, imm0_65535_neg:$imm, CPSR),
3487 (SBCrr GPR:$src, (MOVi16 (imm_not_XFORM imm:$imm)))>,
3488 Requires<[IsARM, HasV6T2]>;
3490 // Note: These are implemented in C++ code, because they have to generate
3491 // ADD/SUBrs instructions, which use a complex pattern that a xform function
3493 // (mul X, 2^n+1) -> (add (X << n), X)
3494 // (mul X, 2^n-1) -> (rsb X, (X << n))
3496 // ARM Arithmetic Instruction
3497 // GPR:$dst = GPR:$a op GPR:$b
3498 class AAI<bits<8> op27_20, bits<8> op11_4, string opc,
3499 list<dag> pattern = [],
3500 dag iops = (ins GPRnopc:$Rn, GPRnopc:$Rm),
3501 string asm = "\t$Rd, $Rn, $Rm">
3502 : AI<(outs GPRnopc:$Rd), iops, DPFrm, IIC_iALUr, opc, asm, pattern>,
3503 Sched<[WriteALU, ReadALU, ReadALU]> {
3507 let Inst{27-20} = op27_20;
3508 let Inst{11-4} = op11_4;
3509 let Inst{19-16} = Rn;
3510 let Inst{15-12} = Rd;
3513 let Unpredictable{11-8} = 0b1111;
3516 // Saturating add/subtract
3518 let DecoderMethod = "DecodeQADDInstruction" in
3519 def QADD : AAI<0b00010000, 0b00000101, "qadd",
3520 [(set GPRnopc:$Rd, (int_arm_qadd GPRnopc:$Rm, GPRnopc:$Rn))],
3521 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3523 def QSUB : AAI<0b00010010, 0b00000101, "qsub",
3524 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm, GPRnopc:$Rn))],
3525 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3526 def QDADD : AAI<0b00010100, 0b00000101, "qdadd", [],
3527 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3529 def QDSUB : AAI<0b00010110, 0b00000101, "qdsub", [],
3530 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3533 def QADD16 : AAI<0b01100010, 0b11110001, "qadd16">;
3534 def QADD8 : AAI<0b01100010, 0b11111001, "qadd8">;
3535 def QASX : AAI<0b01100010, 0b11110011, "qasx">;
3536 def QSAX : AAI<0b01100010, 0b11110101, "qsax">;
3537 def QSUB16 : AAI<0b01100010, 0b11110111, "qsub16">;
3538 def QSUB8 : AAI<0b01100010, 0b11111111, "qsub8">;
3539 def UQADD16 : AAI<0b01100110, 0b11110001, "uqadd16">;
3540 def UQADD8 : AAI<0b01100110, 0b11111001, "uqadd8">;
3541 def UQASX : AAI<0b01100110, 0b11110011, "uqasx">;
3542 def UQSAX : AAI<0b01100110, 0b11110101, "uqsax">;
3543 def UQSUB16 : AAI<0b01100110, 0b11110111, "uqsub16">;
3544 def UQSUB8 : AAI<0b01100110, 0b11111111, "uqsub8">;
3546 // Signed/Unsigned add/subtract
3548 def SASX : AAI<0b01100001, 0b11110011, "sasx">;
3549 def SADD16 : AAI<0b01100001, 0b11110001, "sadd16">;
3550 def SADD8 : AAI<0b01100001, 0b11111001, "sadd8">;
3551 def SSAX : AAI<0b01100001, 0b11110101, "ssax">;
3552 def SSUB16 : AAI<0b01100001, 0b11110111, "ssub16">;
3553 def SSUB8 : AAI<0b01100001, 0b11111111, "ssub8">;
3554 def UASX : AAI<0b01100101, 0b11110011, "uasx">;
3555 def UADD16 : AAI<0b01100101, 0b11110001, "uadd16">;
3556 def UADD8 : AAI<0b01100101, 0b11111001, "uadd8">;
3557 def USAX : AAI<0b01100101, 0b11110101, "usax">;
3558 def USUB16 : AAI<0b01100101, 0b11110111, "usub16">;
3559 def USUB8 : AAI<0b01100101, 0b11111111, "usub8">;
3561 // Signed/Unsigned halving add/subtract
3563 def SHASX : AAI<0b01100011, 0b11110011, "shasx">;
3564 def SHADD16 : AAI<0b01100011, 0b11110001, "shadd16">;
3565 def SHADD8 : AAI<0b01100011, 0b11111001, "shadd8">;
3566 def SHSAX : AAI<0b01100011, 0b11110101, "shsax">;
3567 def SHSUB16 : AAI<0b01100011, 0b11110111, "shsub16">;
3568 def SHSUB8 : AAI<0b01100011, 0b11111111, "shsub8">;
3569 def UHASX : AAI<0b01100111, 0b11110011, "uhasx">;
3570 def UHADD16 : AAI<0b01100111, 0b11110001, "uhadd16">;
3571 def UHADD8 : AAI<0b01100111, 0b11111001, "uhadd8">;
3572 def UHSAX : AAI<0b01100111, 0b11110101, "uhsax">;
3573 def UHSUB16 : AAI<0b01100111, 0b11110111, "uhsub16">;
3574 def UHSUB8 : AAI<0b01100111, 0b11111111, "uhsub8">;
3576 // Unsigned Sum of Absolute Differences [and Accumulate].
3578 def USAD8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3579 MulFrm /* for convenience */, NoItinerary, "usad8",
3580 "\t$Rd, $Rn, $Rm", []>,
3581 Requires<[IsARM, HasV6]>, Sched<[WriteALU, ReadALU, ReadALU]> {
3585 let Inst{27-20} = 0b01111000;
3586 let Inst{15-12} = 0b1111;
3587 let Inst{7-4} = 0b0001;
3588 let Inst{19-16} = Rd;
3589 let Inst{11-8} = Rm;
3592 def USADA8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3593 MulFrm /* for convenience */, NoItinerary, "usada8",
3594 "\t$Rd, $Rn, $Rm, $Ra", []>,
3595 Requires<[IsARM, HasV6]>, Sched<[WriteALU, ReadALU, ReadALU]>{
3600 let Inst{27-20} = 0b01111000;
3601 let Inst{7-4} = 0b0001;
3602 let Inst{19-16} = Rd;
3603 let Inst{15-12} = Ra;
3604 let Inst{11-8} = Rm;
3608 // Signed/Unsigned saturate
3610 def SSAT : AI<(outs GPRnopc:$Rd),
3611 (ins imm1_32:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3612 SatFrm, NoItinerary, "ssat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3617 let Inst{27-21} = 0b0110101;
3618 let Inst{5-4} = 0b01;
3619 let Inst{20-16} = sat_imm;
3620 let Inst{15-12} = Rd;
3621 let Inst{11-7} = sh{4-0};
3622 let Inst{6} = sh{5};
3626 def SSAT16 : AI<(outs GPRnopc:$Rd),
3627 (ins imm1_16:$sat_imm, GPRnopc:$Rn), SatFrm,
3628 NoItinerary, "ssat16", "\t$Rd, $sat_imm, $Rn", []> {
3632 let Inst{27-20} = 0b01101010;
3633 let Inst{11-4} = 0b11110011;
3634 let Inst{15-12} = Rd;
3635 let Inst{19-16} = sat_imm;
3639 def USAT : AI<(outs GPRnopc:$Rd),
3640 (ins imm0_31:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3641 SatFrm, NoItinerary, "usat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3646 let Inst{27-21} = 0b0110111;
3647 let Inst{5-4} = 0b01;
3648 let Inst{15-12} = Rd;
3649 let Inst{11-7} = sh{4-0};
3650 let Inst{6} = sh{5};
3651 let Inst{20-16} = sat_imm;
3655 def USAT16 : AI<(outs GPRnopc:$Rd),
3656 (ins imm0_15:$sat_imm, GPRnopc:$Rn), SatFrm,
3657 NoItinerary, "usat16", "\t$Rd, $sat_imm, $Rn", []> {
3661 let Inst{27-20} = 0b01101110;
3662 let Inst{11-4} = 0b11110011;
3663 let Inst{15-12} = Rd;
3664 let Inst{19-16} = sat_imm;
3668 def : ARMV6Pat<(int_arm_ssat GPRnopc:$a, imm:$pos),
3669 (SSAT imm:$pos, GPRnopc:$a, 0)>;
3670 def : ARMV6Pat<(int_arm_usat GPRnopc:$a, imm:$pos),
3671 (USAT imm:$pos, GPRnopc:$a, 0)>;
3673 //===----------------------------------------------------------------------===//
3674 // Bitwise Instructions.
3677 defm AND : AsI1_bin_irs<0b0000, "and",
3678 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3679 BinOpFrag<(and node:$LHS, node:$RHS)>, 1>;
3680 defm ORR : AsI1_bin_irs<0b1100, "orr",
3681 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3682 BinOpFrag<(or node:$LHS, node:$RHS)>, 1>;
3683 defm EOR : AsI1_bin_irs<0b0001, "eor",
3684 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3685 BinOpFrag<(xor node:$LHS, node:$RHS)>, 1>;
3686 defm BIC : AsI1_bin_irs<0b1110, "bic",
3687 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3688 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
3690 // FIXME: bf_inv_mask_imm should be two operands, the lsb and the msb, just
3691 // like in the actual instruction encoding. The complexity of mapping the mask
3692 // to the lsb/msb pair should be handled by ISel, not encapsulated in the
3693 // instruction description.
3694 def BFC : I<(outs GPR:$Rd), (ins GPR:$src, bf_inv_mask_imm:$imm),
3695 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3696 "bfc", "\t$Rd, $imm", "$src = $Rd",
3697 [(set GPR:$Rd, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
3698 Requires<[IsARM, HasV6T2]> {
3701 let Inst{27-21} = 0b0111110;
3702 let Inst{6-0} = 0b0011111;
3703 let Inst{15-12} = Rd;
3704 let Inst{11-7} = imm{4-0}; // lsb
3705 let Inst{20-16} = imm{9-5}; // msb
3708 // A8.6.18 BFI - Bitfield insert (Encoding A1)
3709 def BFI:I<(outs GPRnopc:$Rd), (ins GPRnopc:$src, GPR:$Rn, bf_inv_mask_imm:$imm),
3710 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3711 "bfi", "\t$Rd, $Rn, $imm", "$src = $Rd",
3712 [(set GPRnopc:$Rd, (ARMbfi GPRnopc:$src, GPR:$Rn,
3713 bf_inv_mask_imm:$imm))]>,
3714 Requires<[IsARM, HasV6T2]> {
3718 let Inst{27-21} = 0b0111110;
3719 let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15
3720 let Inst{15-12} = Rd;
3721 let Inst{11-7} = imm{4-0}; // lsb
3722 let Inst{20-16} = imm{9-5}; // width
3726 def MVNr : AsI1<0b1111, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMVNr,
3727 "mvn", "\t$Rd, $Rm",
3728 [(set GPR:$Rd, (not GPR:$Rm))]>, UnaryDP, Sched<[WriteALU]> {
3732 let Inst{19-16} = 0b0000;
3733 let Inst{11-4} = 0b00000000;
3734 let Inst{15-12} = Rd;
3737 def MVNsi : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_imm:$shift),
3738 DPSoRegImmFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3739 [(set GPR:$Rd, (not so_reg_imm:$shift))]>, UnaryDP,
3744 let Inst{19-16} = 0b0000;
3745 let Inst{15-12} = Rd;
3746 let Inst{11-5} = shift{11-5};
3748 let Inst{3-0} = shift{3-0};
3750 def MVNsr : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_reg:$shift),
3751 DPSoRegRegFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3752 [(set GPR:$Rd, (not so_reg_reg:$shift))]>, UnaryDP,
3757 let Inst{19-16} = 0b0000;
3758 let Inst{15-12} = Rd;
3759 let Inst{11-8} = shift{11-8};
3761 let Inst{6-5} = shift{6-5};
3763 let Inst{3-0} = shift{3-0};
3765 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3766 def MVNi : AsI1<0b1111, (outs GPR:$Rd), (ins mod_imm:$imm), DPFrm,
3767 IIC_iMVNi, "mvn", "\t$Rd, $imm",
3768 [(set GPR:$Rd, mod_imm_not:$imm)]>,UnaryDP, Sched<[WriteALU]> {
3772 let Inst{19-16} = 0b0000;
3773 let Inst{15-12} = Rd;
3774 let Inst{11-0} = imm;
3777 def : ARMPat<(and GPR:$src, so_imm_not:$imm),
3778 (BICri GPR:$src, so_imm_not:$imm)>;
3780 //===----------------------------------------------------------------------===//
3781 // Multiply Instructions.
3783 class AsMul1I32<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3784 string opc, string asm, list<dag> pattern>
3785 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3789 let Inst{19-16} = Rd;
3790 let Inst{11-8} = Rm;
3793 class AsMul1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3794 string opc, string asm, list<dag> pattern>
3795 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3800 let Inst{19-16} = RdHi;
3801 let Inst{15-12} = RdLo;
3802 let Inst{11-8} = Rm;
3805 class AsMla1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3806 string opc, string asm, list<dag> pattern>
3807 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3812 let Inst{19-16} = RdHi;
3813 let Inst{15-12} = RdLo;
3814 let Inst{11-8} = Rm;
3818 // FIXME: The v5 pseudos are only necessary for the additional Constraint
3819 // property. Remove them when it's possible to add those properties
3820 // on an individual MachineInstr, not just an instruction description.
3821 let isCommutable = 1, TwoOperandAliasConstraint = "$Rn = $Rd" in {
3822 def MUL : AsMul1I32<0b0000000, (outs GPRnopc:$Rd),
3823 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3824 IIC_iMUL32, "mul", "\t$Rd, $Rn, $Rm",
3825 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))]>,
3826 Requires<[IsARM, HasV6]> {
3827 let Inst{15-12} = 0b0000;
3828 let Unpredictable{15-12} = 0b1111;
3831 let Constraints = "@earlyclobber $Rd" in
3832 def MULv5: ARMPseudoExpand<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm,
3833 pred:$p, cc_out:$s),
3835 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))],
3836 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s)>,
3837 Requires<[IsARM, NoV6, UseMulOps]>;
3840 def MLA : AsMul1I32<0b0000001, (outs GPRnopc:$Rd),
3841 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra),
3842 IIC_iMAC32, "mla", "\t$Rd, $Rn, $Rm, $Ra",
3843 [(set GPRnopc:$Rd, (add (mul GPRnopc:$Rn, GPRnopc:$Rm), GPRnopc:$Ra))]>,
3844 Requires<[IsARM, HasV6, UseMulOps]> {
3846 let Inst{15-12} = Ra;
3849 let Constraints = "@earlyclobber $Rd" in
3850 def MLAv5: ARMPseudoExpand<(outs GPRnopc:$Rd),
3851 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra,
3852 pred:$p, cc_out:$s), 4, IIC_iMAC32,
3853 [(set GPRnopc:$Rd, (add (mul GPRnopc:$Rn, GPRnopc:$Rm), GPRnopc:$Ra))],
3854 (MLA GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra, pred:$p, cc_out:$s)>,
3855 Requires<[IsARM, NoV6]>;
3857 def MLS : AMul1I<0b0000011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3858 IIC_iMAC32, "mls", "\t$Rd, $Rn, $Rm, $Ra",
3859 [(set GPR:$Rd, (sub GPR:$Ra, (mul GPR:$Rn, GPR:$Rm)))]>,
3860 Requires<[IsARM, HasV6T2, UseMulOps]> {
3865 let Inst{19-16} = Rd;
3866 let Inst{15-12} = Ra;
3867 let Inst{11-8} = Rm;
3871 // Extra precision multiplies with low / high results
3872 let hasSideEffects = 0 in {
3873 let isCommutable = 1 in {
3874 def SMULL : AsMul1I64<0b0000110, (outs GPR:$RdLo, GPR:$RdHi),
3875 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3876 "smull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3877 Requires<[IsARM, HasV6]>;
3879 def UMULL : AsMul1I64<0b0000100, (outs GPR:$RdLo, GPR:$RdHi),
3880 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3881 "umull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3882 Requires<[IsARM, HasV6]>;
3884 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
3885 def SMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3886 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3888 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3889 Requires<[IsARM, NoV6]>;
3891 def UMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3892 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3894 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3895 Requires<[IsARM, NoV6]>;
3899 // Multiply + accumulate
3900 def SMLAL : AsMla1I64<0b0000111, (outs GPR:$RdLo, GPR:$RdHi),
3901 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64,
3902 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3903 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>;
3904 def UMLAL : AsMla1I64<0b0000101, (outs GPR:$RdLo, GPR:$RdHi),
3905 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64,
3906 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3907 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>;
3909 def UMAAL : AMul1I <0b0000010, (outs GPR:$RdLo, GPR:$RdHi),
3910 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3911 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3912 Requires<[IsARM, HasV6]> {
3917 let Inst{19-16} = RdHi;
3918 let Inst{15-12} = RdLo;
3919 let Inst{11-8} = Rm;
3924 "@earlyclobber $RdLo,@earlyclobber $RdHi,$RLo = $RdLo,$RHi = $RdHi" in {
3925 def SMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3926 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s),
3928 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi,
3929 pred:$p, cc_out:$s)>,
3930 Requires<[IsARM, NoV6]>;
3931 def UMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3932 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s),
3934 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi,
3935 pred:$p, cc_out:$s)>,
3936 Requires<[IsARM, NoV6]>;
3941 // Most significant word multiply
3942 def SMMUL : AMul2I <0b0111010, 0b0001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3943 IIC_iMUL32, "smmul", "\t$Rd, $Rn, $Rm",
3944 [(set GPR:$Rd, (mulhs GPR:$Rn, GPR:$Rm))]>,
3945 Requires<[IsARM, HasV6]> {
3946 let Inst{15-12} = 0b1111;
3949 def SMMULR : AMul2I <0b0111010, 0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3950 IIC_iMUL32, "smmulr", "\t$Rd, $Rn, $Rm", []>,
3951 Requires<[IsARM, HasV6]> {
3952 let Inst{15-12} = 0b1111;
3955 def SMMLA : AMul2Ia <0b0111010, 0b0001, (outs GPR:$Rd),
3956 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3957 IIC_iMAC32, "smmla", "\t$Rd, $Rn, $Rm, $Ra",
3958 [(set GPR:$Rd, (add (mulhs GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
3959 Requires<[IsARM, HasV6, UseMulOps]>;
3961 def SMMLAR : AMul2Ia <0b0111010, 0b0011, (outs GPR:$Rd),
3962 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3963 IIC_iMAC32, "smmlar", "\t$Rd, $Rn, $Rm, $Ra", []>,
3964 Requires<[IsARM, HasV6]>;
3966 def SMMLS : AMul2Ia <0b0111010, 0b1101, (outs GPR:$Rd),
3967 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3968 IIC_iMAC32, "smmls", "\t$Rd, $Rn, $Rm, $Ra", []>,
3969 Requires<[IsARM, HasV6, UseMulOps]>;
3971 def SMMLSR : AMul2Ia <0b0111010, 0b1111, (outs GPR:$Rd),
3972 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3973 IIC_iMAC32, "smmlsr", "\t$Rd, $Rn, $Rm, $Ra", []>,
3974 Requires<[IsARM, HasV6]>;
3976 multiclass AI_smul<string opc, PatFrag opnode> {
3977 def BB : AMulxyI<0b0001011, 0b00, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3978 IIC_iMUL16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm",
3979 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3980 (sext_inreg GPR:$Rm, i16)))]>,
3981 Requires<[IsARM, HasV5TE]>;
3983 def BT : AMulxyI<0b0001011, 0b10, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3984 IIC_iMUL16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm",
3985 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3986 (sra GPR:$Rm, (i32 16))))]>,
3987 Requires<[IsARM, HasV5TE]>;
3989 def TB : AMulxyI<0b0001011, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3990 IIC_iMUL16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm",
3991 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3992 (sext_inreg GPR:$Rm, i16)))]>,
3993 Requires<[IsARM, HasV5TE]>;
3995 def TT : AMulxyI<0b0001011, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3996 IIC_iMUL16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm",
3997 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3998 (sra GPR:$Rm, (i32 16))))]>,
3999 Requires<[IsARM, HasV5TE]>;
4001 def WB : AMulxyI<0b0001001, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4002 IIC_iMUL16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm",
4004 Requires<[IsARM, HasV5TE]>;
4006 def WT : AMulxyI<0b0001001, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4007 IIC_iMUL16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm",
4009 Requires<[IsARM, HasV5TE]>;
4013 multiclass AI_smla<string opc, PatFrag opnode> {
4014 let DecoderMethod = "DecodeSMLAInstruction" in {
4015 def BB : AMulxyIa<0b0001000, 0b00, (outs GPRnopc:$Rd),
4016 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4017 IIC_iMAC16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra",
4018 [(set GPRnopc:$Rd, (add GPR:$Ra,
4019 (opnode (sext_inreg GPRnopc:$Rn, i16),
4020 (sext_inreg GPRnopc:$Rm, i16))))]>,
4021 Requires<[IsARM, HasV5TE, UseMulOps]>;
4023 def BT : AMulxyIa<0b0001000, 0b10, (outs GPRnopc:$Rd),
4024 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4025 IIC_iMAC16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra",
4027 (add GPR:$Ra, (opnode (sext_inreg GPRnopc:$Rn, i16),
4028 (sra GPRnopc:$Rm, (i32 16)))))]>,
4029 Requires<[IsARM, HasV5TE, UseMulOps]>;
4031 def TB : AMulxyIa<0b0001000, 0b01, (outs GPRnopc:$Rd),
4032 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4033 IIC_iMAC16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra",
4035 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
4036 (sext_inreg GPRnopc:$Rm, i16))))]>,
4037 Requires<[IsARM, HasV5TE, UseMulOps]>;
4039 def TT : AMulxyIa<0b0001000, 0b11, (outs GPRnopc:$Rd),
4040 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4041 IIC_iMAC16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra",
4043 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
4044 (sra GPRnopc:$Rm, (i32 16)))))]>,
4045 Requires<[IsARM, HasV5TE, UseMulOps]>;
4047 def WB : AMulxyIa<0b0001001, 0b00, (outs GPRnopc:$Rd),
4048 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4049 IIC_iMAC16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra",
4051 Requires<[IsARM, HasV5TE, UseMulOps]>;
4053 def WT : AMulxyIa<0b0001001, 0b10, (outs GPRnopc:$Rd),
4054 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4055 IIC_iMAC16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra",
4057 Requires<[IsARM, HasV5TE, UseMulOps]>;
4061 defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
4062 defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
4064 // Halfword multiply accumulate long: SMLAL<x><y>.
4065 def SMLALBB : AMulxyI64<0b0001010, 0b00, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4066 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4067 IIC_iMAC64, "smlalbb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4068 Requires<[IsARM, HasV5TE]>;
4070 def SMLALBT : AMulxyI64<0b0001010, 0b10, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4071 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4072 IIC_iMAC64, "smlalbt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4073 Requires<[IsARM, HasV5TE]>;
4075 def SMLALTB : AMulxyI64<0b0001010, 0b01, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4076 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4077 IIC_iMAC64, "smlaltb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4078 Requires<[IsARM, HasV5TE]>;
4080 def SMLALTT : AMulxyI64<0b0001010, 0b11, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4081 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4082 IIC_iMAC64, "smlaltt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4083 Requires<[IsARM, HasV5TE]>;
4085 // Helper class for AI_smld.
4086 class AMulDualIbase<bit long, bit sub, bit swap, dag oops, dag iops,
4087 InstrItinClass itin, string opc, string asm>
4088 : AI<oops, iops, MulFrm, itin, opc, asm, []>, Requires<[IsARM, HasV6]> {
4091 let Inst{27-23} = 0b01110;
4092 let Inst{22} = long;
4093 let Inst{21-20} = 0b00;
4094 let Inst{11-8} = Rm;
4101 class AMulDualI<bit long, bit sub, bit swap, dag oops, dag iops,
4102 InstrItinClass itin, string opc, string asm>
4103 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4105 let Inst{15-12} = 0b1111;
4106 let Inst{19-16} = Rd;
4108 class AMulDualIa<bit long, bit sub, bit swap, dag oops, dag iops,
4109 InstrItinClass itin, string opc, string asm>
4110 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4113 let Inst{19-16} = Rd;
4114 let Inst{15-12} = Ra;
4116 class AMulDualI64<bit long, bit sub, bit swap, dag oops, dag iops,
4117 InstrItinClass itin, string opc, string asm>
4118 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4121 let Inst{19-16} = RdHi;
4122 let Inst{15-12} = RdLo;
4125 multiclass AI_smld<bit sub, string opc> {
4127 def D : AMulDualIa<0, sub, 0, (outs GPRnopc:$Rd),
4128 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4129 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm, $Ra">;
4131 def DX: AMulDualIa<0, sub, 1, (outs GPRnopc:$Rd),
4132 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4133 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm, $Ra">;
4135 def LD: AMulDualI64<1, sub, 0, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4136 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
4137 !strconcat(opc, "ld"), "\t$RdLo, $RdHi, $Rn, $Rm">;
4139 def LDX : AMulDualI64<1, sub, 1, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4140 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
4141 !strconcat(opc, "ldx"),"\t$RdLo, $RdHi, $Rn, $Rm">;
4145 defm SMLA : AI_smld<0, "smla">;
4146 defm SMLS : AI_smld<1, "smls">;
4148 multiclass AI_sdml<bit sub, string opc> {
4150 def D:AMulDualI<0, sub, 0, (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm),
4151 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm">;
4152 def DX:AMulDualI<0, sub, 1, (outs GPRnopc:$Rd),(ins GPRnopc:$Rn, GPRnopc:$Rm),
4153 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm">;
4156 defm SMUA : AI_sdml<0, "smua">;
4157 defm SMUS : AI_sdml<1, "smus">;
4159 //===----------------------------------------------------------------------===//
4160 // Division Instructions (ARMv7-A with virtualization extension)
4162 def SDIV : ADivA1I<0b001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV,
4163 "sdiv", "\t$Rd, $Rn, $Rm",
4164 [(set GPR:$Rd, (sdiv GPR:$Rn, GPR:$Rm))]>,
4165 Requires<[IsARM, HasDivideInARM]>;
4167 def UDIV : ADivA1I<0b011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV,
4168 "udiv", "\t$Rd, $Rn, $Rm",
4169 [(set GPR:$Rd, (udiv GPR:$Rn, GPR:$Rm))]>,
4170 Requires<[IsARM, HasDivideInARM]>;
4172 //===----------------------------------------------------------------------===//
4173 // Misc. Arithmetic Instructions.
4176 def CLZ : AMiscA1I<0b00010110, 0b0001, (outs GPR:$Rd), (ins GPR:$Rm),
4177 IIC_iUNAr, "clz", "\t$Rd, $Rm",
4178 [(set GPR:$Rd, (ctlz GPR:$Rm))]>, Requires<[IsARM, HasV5T]>,
4181 def RBIT : AMiscA1I<0b01101111, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
4182 IIC_iUNAr, "rbit", "\t$Rd, $Rm",
4183 [(set GPR:$Rd, (ARMrbit GPR:$Rm))]>,
4184 Requires<[IsARM, HasV6T2]>,
4187 def REV : AMiscA1I<0b01101011, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
4188 IIC_iUNAr, "rev", "\t$Rd, $Rm",
4189 [(set GPR:$Rd, (bswap GPR:$Rm))]>, Requires<[IsARM, HasV6]>,
4192 let AddedComplexity = 5 in
4193 def REV16 : AMiscA1I<0b01101011, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
4194 IIC_iUNAr, "rev16", "\t$Rd, $Rm",
4195 [(set GPR:$Rd, (rotr (bswap GPR:$Rm), (i32 16)))]>,
4196 Requires<[IsARM, HasV6]>,
4199 def : ARMV6Pat<(srl (bswap (extloadi16 addrmode3:$addr)), (i32 16)),
4200 (REV16 (LDRH addrmode3:$addr))>;
4201 def : ARMV6Pat<(truncstorei16 (srl (bswap GPR:$Rn), (i32 16)), addrmode3:$addr),
4202 (STRH (REV16 GPR:$Rn), addrmode3:$addr)>;
4204 let AddedComplexity = 5 in
4205 def REVSH : AMiscA1I<0b01101111, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
4206 IIC_iUNAr, "revsh", "\t$Rd, $Rm",
4207 [(set GPR:$Rd, (sra (bswap GPR:$Rm), (i32 16)))]>,
4208 Requires<[IsARM, HasV6]>,
4211 def : ARMV6Pat<(or (sra (shl GPR:$Rm, (i32 24)), (i32 16)),
4212 (and (srl GPR:$Rm, (i32 8)), 0xFF)),
4215 def PKHBT : APKHI<0b01101000, 0, (outs GPRnopc:$Rd),
4216 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_lsl_amt:$sh),
4217 IIC_iALUsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh",
4218 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF),
4219 (and (shl GPRnopc:$Rm, pkh_lsl_amt:$sh),
4221 Requires<[IsARM, HasV6]>,
4222 Sched<[WriteALUsi, ReadALU]>;
4224 // Alternate cases for PKHBT where identities eliminate some nodes.
4225 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (and GPRnopc:$Rm, 0xFFFF0000)),
4226 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, 0)>;
4227 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (shl GPRnopc:$Rm, imm16_31:$sh)),
4228 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, imm16_31:$sh)>;
4230 // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
4231 // will match the pattern below.
4232 def PKHTB : APKHI<0b01101000, 1, (outs GPRnopc:$Rd),
4233 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_asr_amt:$sh),
4234 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh",
4235 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF0000),
4236 (and (sra GPRnopc:$Rm, pkh_asr_amt:$sh),
4238 Requires<[IsARM, HasV6]>,
4239 Sched<[WriteALUsi, ReadALU]>;
4241 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
4242 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
4243 // We also can not replace a srl (17..31) by an arithmetic shift we would use in
4244 // pkhtb src1, src2, asr (17..31).
4245 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4246 (srl GPRnopc:$src2, imm16:$sh)),
4247 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16:$sh)>;
4248 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4249 (sra GPRnopc:$src2, imm16_31:$sh)),
4250 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16_31:$sh)>;
4251 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4252 (and (srl GPRnopc:$src2, imm1_15:$sh), 0xFFFF)),
4253 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm1_15:$sh)>;
4255 //===----------------------------------------------------------------------===//
4259 // + CRC32{B,H,W} 0x04C11DB7
4260 // + CRC32C{B,H,W} 0x1EDC6F41
4263 class AI_crc32<bit C, bits<2> sz, string suffix, SDPatternOperator builtin>
4264 : AInoP<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm), MiscFrm, NoItinerary,
4265 !strconcat("crc32", suffix), "\t$Rd, $Rn, $Rm",
4266 [(set GPRnopc:$Rd, (builtin GPRnopc:$Rn, GPRnopc:$Rm))]>,
4267 Requires<[IsARM, HasV8, HasCRC]> {
4272 let Inst{31-28} = 0b1110;
4273 let Inst{27-23} = 0b00010;
4274 let Inst{22-21} = sz;
4276 let Inst{19-16} = Rn;
4277 let Inst{15-12} = Rd;
4278 let Inst{11-10} = 0b00;
4281 let Inst{7-4} = 0b0100;
4284 let Unpredictable{11-8} = 0b1101;
4287 def CRC32B : AI_crc32<0, 0b00, "b", int_arm_crc32b>;
4288 def CRC32CB : AI_crc32<1, 0b00, "cb", int_arm_crc32cb>;
4289 def CRC32H : AI_crc32<0, 0b01, "h", int_arm_crc32h>;
4290 def CRC32CH : AI_crc32<1, 0b01, "ch", int_arm_crc32ch>;
4291 def CRC32W : AI_crc32<0, 0b10, "w", int_arm_crc32w>;
4292 def CRC32CW : AI_crc32<1, 0b10, "cw", int_arm_crc32cw>;
4294 //===----------------------------------------------------------------------===//
4295 // Comparison Instructions...
4298 defm CMP : AI1_cmp_irs<0b1010, "cmp",
4299 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
4300 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
4302 // ARMcmpZ can re-use the above instruction definitions.
4303 def : ARMPat<(ARMcmpZ GPR:$src, so_imm:$imm),
4304 (CMPri GPR:$src, so_imm:$imm)>;
4305 def : ARMPat<(ARMcmpZ GPR:$src, GPR:$rhs),
4306 (CMPrr GPR:$src, GPR:$rhs)>;
4307 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_imm:$rhs),
4308 (CMPrsi GPR:$src, so_reg_imm:$rhs)>;
4309 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_reg:$rhs),
4310 (CMPrsr GPR:$src, so_reg_reg:$rhs)>;
4312 // CMN register-integer
4313 let isCompare = 1, Defs = [CPSR] in {
4314 def CMNri : AI1<0b1011, (outs), (ins GPR:$Rn, mod_imm:$imm), DPFrm, IIC_iCMPi,
4315 "cmn", "\t$Rn, $imm",
4316 [(ARMcmn GPR:$Rn, mod_imm:$imm)]>,
4317 Sched<[WriteCMP, ReadALU]> {
4322 let Inst{19-16} = Rn;
4323 let Inst{15-12} = 0b0000;
4324 let Inst{11-0} = imm;
4326 let Unpredictable{15-12} = 0b1111;
4329 // CMN register-register/shift
4330 def CMNzrr : AI1<0b1011, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, IIC_iCMPr,
4331 "cmn", "\t$Rn, $Rm",
4332 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4333 GPR:$Rn, GPR:$Rm)]>, Sched<[WriteCMP, ReadALU, ReadALU]> {
4336 let isCommutable = 1;
4339 let Inst{19-16} = Rn;
4340 let Inst{15-12} = 0b0000;
4341 let Inst{11-4} = 0b00000000;
4344 let Unpredictable{15-12} = 0b1111;
4347 def CMNzrsi : AI1<0b1011, (outs),
4348 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, IIC_iCMPsr,
4349 "cmn", "\t$Rn, $shift",
4350 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4351 GPR:$Rn, so_reg_imm:$shift)]>,
4352 Sched<[WriteCMPsi, ReadALU]> {
4357 let Inst{19-16} = Rn;
4358 let Inst{15-12} = 0b0000;
4359 let Inst{11-5} = shift{11-5};
4361 let Inst{3-0} = shift{3-0};
4363 let Unpredictable{15-12} = 0b1111;
4366 def CMNzrsr : AI1<0b1011, (outs),
4367 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, IIC_iCMPsr,
4368 "cmn", "\t$Rn, $shift",
4369 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4370 GPRnopc:$Rn, so_reg_reg:$shift)]>,
4371 Sched<[WriteCMPsr, ReadALU]> {
4376 let Inst{19-16} = Rn;
4377 let Inst{15-12} = 0b0000;
4378 let Inst{11-8} = shift{11-8};
4380 let Inst{6-5} = shift{6-5};
4382 let Inst{3-0} = shift{3-0};
4384 let Unpredictable{15-12} = 0b1111;
4389 def : ARMPat<(ARMcmp GPR:$src, so_imm_neg:$imm),
4390 (CMNri GPR:$src, so_imm_neg:$imm)>;
4392 def : ARMPat<(ARMcmpZ GPR:$src, so_imm_neg:$imm),
4393 (CMNri GPR:$src, so_imm_neg:$imm)>;
4395 // Note that TST/TEQ don't set all the same flags that CMP does!
4396 defm TST : AI1_cmp_irs<0b1000, "tst",
4397 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
4398 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>, 1>;
4399 defm TEQ : AI1_cmp_irs<0b1001, "teq",
4400 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
4401 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>, 1>;
4403 // Pseudo i64 compares for some floating point compares.
4404 let usesCustomInserter = 1, isBranch = 1, isTerminator = 1,
4406 def BCCi64 : PseudoInst<(outs),
4407 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, brtarget:$dst),
4409 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, bb:$dst)]>,
4412 def BCCZi64 : PseudoInst<(outs),
4413 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, brtarget:$dst), IIC_Br,
4414 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, 0, 0, bb:$dst)]>,
4416 } // usesCustomInserter
4419 // Conditional moves
4420 let hasSideEffects = 0 in {
4422 let isCommutable = 1, isSelect = 1 in
4423 def MOVCCr : ARMPseudoInst<(outs GPR:$Rd),
4424 (ins GPR:$false, GPR:$Rm, cmovpred:$p),
4426 [(set GPR:$Rd, (ARMcmov GPR:$false, GPR:$Rm,
4428 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4430 def MOVCCsi : ARMPseudoInst<(outs GPR:$Rd),
4431 (ins GPR:$false, so_reg_imm:$shift, cmovpred:$p),
4434 (ARMcmov GPR:$false, so_reg_imm:$shift,
4436 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4437 def MOVCCsr : ARMPseudoInst<(outs GPR:$Rd),
4438 (ins GPR:$false, so_reg_reg:$shift, cmovpred:$p),
4440 [(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_reg:$shift,
4442 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4445 let isMoveImm = 1 in
4447 : ARMPseudoInst<(outs GPR:$Rd),
4448 (ins GPR:$false, imm0_65535_expr:$imm, cmovpred:$p),
4450 [(set GPR:$Rd, (ARMcmov GPR:$false, imm0_65535:$imm,
4452 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>,
4455 let isMoveImm = 1 in
4456 def MOVCCi : ARMPseudoInst<(outs GPR:$Rd),
4457 (ins GPR:$false, so_imm:$imm, cmovpred:$p),
4459 [(set GPR:$Rd, (ARMcmov GPR:$false, so_imm:$imm,
4461 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4463 // Two instruction predicate mov immediate.
4464 let isMoveImm = 1 in
4466 : ARMPseudoInst<(outs GPR:$Rd),
4467 (ins GPR:$false, i32imm:$src, cmovpred:$p),
4469 [(set GPR:$Rd, (ARMcmov GPR:$false, imm:$src,
4471 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>;
4473 let isMoveImm = 1 in
4474 def MVNCCi : ARMPseudoInst<(outs GPR:$Rd),
4475 (ins GPR:$false, so_imm:$imm, cmovpred:$p),
4477 [(set GPR:$Rd, (ARMcmov GPR:$false, so_imm_not:$imm,
4479 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4484 //===----------------------------------------------------------------------===//
4485 // Atomic operations intrinsics
4488 def MemBarrierOptOperand : AsmOperandClass {
4489 let Name = "MemBarrierOpt";
4490 let ParserMethod = "parseMemBarrierOptOperand";
4492 def memb_opt : Operand<i32> {
4493 let PrintMethod = "printMemBOption";
4494 let ParserMatchClass = MemBarrierOptOperand;
4495 let DecoderMethod = "DecodeMemBarrierOption";
4498 def InstSyncBarrierOptOperand : AsmOperandClass {
4499 let Name = "InstSyncBarrierOpt";
4500 let ParserMethod = "parseInstSyncBarrierOptOperand";
4502 def instsyncb_opt : Operand<i32> {
4503 let PrintMethod = "printInstSyncBOption";
4504 let ParserMatchClass = InstSyncBarrierOptOperand;
4505 let DecoderMethod = "DecodeInstSyncBarrierOption";
4508 // Memory barriers protect the atomic sequences
4509 let hasSideEffects = 1 in {
4510 def DMB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4511 "dmb", "\t$opt", [(int_arm_dmb (i32 imm0_15:$opt))]>,
4512 Requires<[IsARM, HasDB]> {
4514 let Inst{31-4} = 0xf57ff05;
4515 let Inst{3-0} = opt;
4518 def DSB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4519 "dsb", "\t$opt", [(int_arm_dsb (i32 imm0_15:$opt))]>,
4520 Requires<[IsARM, HasDB]> {
4522 let Inst{31-4} = 0xf57ff04;
4523 let Inst{3-0} = opt;
4526 // ISB has only full system option
4527 def ISB : AInoP<(outs), (ins instsyncb_opt:$opt), MiscFrm, NoItinerary,
4528 "isb", "\t$opt", [(int_arm_isb (i32 imm0_15:$opt))]>,
4529 Requires<[IsARM, HasDB]> {
4531 let Inst{31-4} = 0xf57ff06;
4532 let Inst{3-0} = opt;
4536 let usesCustomInserter = 1, Defs = [CPSR] in {
4538 // Pseudo instruction that combines movs + predicated rsbmi
4539 // to implement integer ABS
4540 def ABS : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$src), 8, NoItinerary, []>;
4543 let usesCustomInserter = 1 in {
4544 def COPY_STRUCT_BYVAL_I32 : PseudoInst<
4545 (outs), (ins GPR:$dst, GPR:$src, i32imm:$size, i32imm:$alignment),
4547 [(ARMcopystructbyval GPR:$dst, GPR:$src, imm:$size, imm:$alignment)]>;
4550 def ldrex_1 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4551 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4554 def ldrex_2 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4555 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4558 def ldrex_4 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4559 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4562 def strex_1 : PatFrag<(ops node:$val, node:$ptr),
4563 (int_arm_strex node:$val, node:$ptr), [{
4564 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4567 def strex_2 : PatFrag<(ops node:$val, node:$ptr),
4568 (int_arm_strex node:$val, node:$ptr), [{
4569 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4572 def strex_4 : PatFrag<(ops node:$val, node:$ptr),
4573 (int_arm_strex node:$val, node:$ptr), [{
4574 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4577 def ldaex_1 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4578 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4581 def ldaex_2 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4582 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4585 def ldaex_4 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4586 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4589 def stlex_1 : PatFrag<(ops node:$val, node:$ptr),
4590 (int_arm_stlex node:$val, node:$ptr), [{
4591 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4594 def stlex_2 : PatFrag<(ops node:$val, node:$ptr),
4595 (int_arm_stlex node:$val, node:$ptr), [{
4596 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4599 def stlex_4 : PatFrag<(ops node:$val, node:$ptr),
4600 (int_arm_stlex node:$val, node:$ptr), [{
4601 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4604 let mayLoad = 1 in {
4605 def LDREXB : AIldrex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4606 NoItinerary, "ldrexb", "\t$Rt, $addr",
4607 [(set GPR:$Rt, (ldrex_1 addr_offset_none:$addr))]>;
4608 def LDREXH : AIldrex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4609 NoItinerary, "ldrexh", "\t$Rt, $addr",
4610 [(set GPR:$Rt, (ldrex_2 addr_offset_none:$addr))]>;
4611 def LDREX : AIldrex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4612 NoItinerary, "ldrex", "\t$Rt, $addr",
4613 [(set GPR:$Rt, (ldrex_4 addr_offset_none:$addr))]>;
4614 let hasExtraDefRegAllocReq = 1 in
4615 def LDREXD : AIldrex<0b01, (outs GPRPairOp:$Rt),(ins addr_offset_none:$addr),
4616 NoItinerary, "ldrexd", "\t$Rt, $addr", []> {
4617 let DecoderMethod = "DecodeDoubleRegLoad";
4620 def LDAEXB : AIldaex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4621 NoItinerary, "ldaexb", "\t$Rt, $addr",
4622 [(set GPR:$Rt, (ldaex_1 addr_offset_none:$addr))]>;
4623 def LDAEXH : AIldaex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4624 NoItinerary, "ldaexh", "\t$Rt, $addr",
4625 [(set GPR:$Rt, (ldaex_2 addr_offset_none:$addr))]>;
4626 def LDAEX : AIldaex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4627 NoItinerary, "ldaex", "\t$Rt, $addr",
4628 [(set GPR:$Rt, (ldaex_4 addr_offset_none:$addr))]>;
4629 let hasExtraDefRegAllocReq = 1 in
4630 def LDAEXD : AIldaex<0b01, (outs GPRPairOp:$Rt),(ins addr_offset_none:$addr),
4631 NoItinerary, "ldaexd", "\t$Rt, $addr", []> {
4632 let DecoderMethod = "DecodeDoubleRegLoad";
4636 let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
4637 def STREXB: AIstrex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4638 NoItinerary, "strexb", "\t$Rd, $Rt, $addr",
4639 [(set GPR:$Rd, (strex_1 GPR:$Rt,
4640 addr_offset_none:$addr))]>;
4641 def STREXH: AIstrex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4642 NoItinerary, "strexh", "\t$Rd, $Rt, $addr",
4643 [(set GPR:$Rd, (strex_2 GPR:$Rt,
4644 addr_offset_none:$addr))]>;
4645 def STREX : AIstrex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4646 NoItinerary, "strex", "\t$Rd, $Rt, $addr",
4647 [(set GPR:$Rd, (strex_4 GPR:$Rt,
4648 addr_offset_none:$addr))]>;
4649 let hasExtraSrcRegAllocReq = 1 in
4650 def STREXD : AIstrex<0b01, (outs GPR:$Rd),
4651 (ins GPRPairOp:$Rt, addr_offset_none:$addr),
4652 NoItinerary, "strexd", "\t$Rd, $Rt, $addr", []> {
4653 let DecoderMethod = "DecodeDoubleRegStore";
4655 def STLEXB: AIstlex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4656 NoItinerary, "stlexb", "\t$Rd, $Rt, $addr",
4658 (stlex_1 GPR:$Rt, addr_offset_none:$addr))]>;
4659 def STLEXH: AIstlex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4660 NoItinerary, "stlexh", "\t$Rd, $Rt, $addr",
4662 (stlex_2 GPR:$Rt, addr_offset_none:$addr))]>;
4663 def STLEX : AIstlex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4664 NoItinerary, "stlex", "\t$Rd, $Rt, $addr",
4666 (stlex_4 GPR:$Rt, addr_offset_none:$addr))]>;
4667 let hasExtraSrcRegAllocReq = 1 in
4668 def STLEXD : AIstlex<0b01, (outs GPR:$Rd),
4669 (ins GPRPairOp:$Rt, addr_offset_none:$addr),
4670 NoItinerary, "stlexd", "\t$Rd, $Rt, $addr", []> {
4671 let DecoderMethod = "DecodeDoubleRegStore";
4675 def CLREX : AXI<(outs), (ins), MiscFrm, NoItinerary, "clrex",
4677 Requires<[IsARM, HasV7]> {
4678 let Inst{31-0} = 0b11110101011111111111000000011111;
4681 def : ARMPat<(strex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr),
4682 (STREXB GPR:$Rt, addr_offset_none:$addr)>;
4683 def : ARMPat<(strex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr),
4684 (STREXH GPR:$Rt, addr_offset_none:$addr)>;
4686 def : ARMPat<(stlex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr),
4687 (STLEXB GPR:$Rt, addr_offset_none:$addr)>;
4688 def : ARMPat<(stlex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr),
4689 (STLEXH GPR:$Rt, addr_offset_none:$addr)>;
4691 class acquiring_load<PatFrag base>
4692 : PatFrag<(ops node:$ptr), (base node:$ptr), [{
4693 AtomicOrdering Ordering = cast<AtomicSDNode>(N)->getOrdering();
4694 return isAtLeastAcquire(Ordering);
4697 def atomic_load_acquire_8 : acquiring_load<atomic_load_8>;
4698 def atomic_load_acquire_16 : acquiring_load<atomic_load_16>;
4699 def atomic_load_acquire_32 : acquiring_load<atomic_load_32>;
4701 class releasing_store<PatFrag base>
4702 : PatFrag<(ops node:$ptr, node:$val), (base node:$ptr, node:$val), [{
4703 AtomicOrdering Ordering = cast<AtomicSDNode>(N)->getOrdering();
4704 return isAtLeastRelease(Ordering);
4707 def atomic_store_release_8 : releasing_store<atomic_store_8>;
4708 def atomic_store_release_16 : releasing_store<atomic_store_16>;
4709 def atomic_store_release_32 : releasing_store<atomic_store_32>;
4711 let AddedComplexity = 8 in {
4712 def : ARMPat<(atomic_load_acquire_8 addr_offset_none:$addr), (LDAB addr_offset_none:$addr)>;
4713 def : ARMPat<(atomic_load_acquire_16 addr_offset_none:$addr), (LDAH addr_offset_none:$addr)>;
4714 def : ARMPat<(atomic_load_acquire_32 addr_offset_none:$addr), (LDA addr_offset_none:$addr)>;
4715 def : ARMPat<(atomic_store_release_8 addr_offset_none:$addr, GPR:$val), (STLB GPR:$val, addr_offset_none:$addr)>;
4716 def : ARMPat<(atomic_store_release_16 addr_offset_none:$addr, GPR:$val), (STLH GPR:$val, addr_offset_none:$addr)>;
4717 def : ARMPat<(atomic_store_release_32 addr_offset_none:$addr, GPR:$val), (STL GPR:$val, addr_offset_none:$addr)>;
4720 // SWP/SWPB are deprecated in V6/V7.
4721 let mayLoad = 1, mayStore = 1 in {
4722 def SWP : AIswp<0, (outs GPRnopc:$Rt),
4723 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swp", []>,
4725 def SWPB: AIswp<1, (outs GPRnopc:$Rt),
4726 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swpb", []>,
4730 //===----------------------------------------------------------------------===//
4731 // Coprocessor Instructions.
4734 def CDP : ABI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4735 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4736 NoItinerary, "cdp", "\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4737 [(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4738 imm:$CRm, imm:$opc2)]>,
4747 let Inst{3-0} = CRm;
4749 let Inst{7-5} = opc2;
4750 let Inst{11-8} = cop;
4751 let Inst{15-12} = CRd;
4752 let Inst{19-16} = CRn;
4753 let Inst{23-20} = opc1;
4756 def CDP2 : ABXI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4757 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4758 NoItinerary, "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4759 [(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4760 imm:$CRm, imm:$opc2)]>,
4762 let Inst{31-28} = 0b1111;
4770 let Inst{3-0} = CRm;
4772 let Inst{7-5} = opc2;
4773 let Inst{11-8} = cop;
4774 let Inst{15-12} = CRd;
4775 let Inst{19-16} = CRn;
4776 let Inst{23-20} = opc1;
4779 class ACI<dag oops, dag iops, string opc, string asm,
4780 IndexMode im = IndexModeNone>
4781 : I<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
4783 let Inst{27-25} = 0b110;
4785 class ACInoP<dag oops, dag iops, string opc, string asm,
4786 IndexMode im = IndexModeNone>
4787 : InoP<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
4789 let Inst{31-28} = 0b1111;
4790 let Inst{27-25} = 0b110;
4792 multiclass LdStCop<bit load, bit Dbit, string asm> {
4793 def _OFFSET : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4794 asm, "\t$cop, $CRd, $addr"> {
4798 let Inst{24} = 1; // P = 1
4799 let Inst{23} = addr{8};
4800 let Inst{22} = Dbit;
4801 let Inst{21} = 0; // W = 0
4802 let Inst{20} = load;
4803 let Inst{19-16} = addr{12-9};
4804 let Inst{15-12} = CRd;
4805 let Inst{11-8} = cop;
4806 let Inst{7-0} = addr{7-0};
4807 let DecoderMethod = "DecodeCopMemInstruction";
4809 def _PRE : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr),
4810 asm, "\t$cop, $CRd, $addr!", IndexModePre> {
4814 let Inst{24} = 1; // P = 1
4815 let Inst{23} = addr{8};
4816 let Inst{22} = Dbit;
4817 let Inst{21} = 1; // W = 1
4818 let Inst{20} = load;
4819 let Inst{19-16} = addr{12-9};
4820 let Inst{15-12} = CRd;
4821 let Inst{11-8} = cop;
4822 let Inst{7-0} = addr{7-0};
4823 let DecoderMethod = "DecodeCopMemInstruction";
4825 def _POST: ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4826 postidx_imm8s4:$offset),
4827 asm, "\t$cop, $CRd, $addr, $offset", IndexModePost> {
4832 let Inst{24} = 0; // P = 0
4833 let Inst{23} = offset{8};
4834 let Inst{22} = Dbit;
4835 let Inst{21} = 1; // W = 1
4836 let Inst{20} = load;
4837 let Inst{19-16} = addr;
4838 let Inst{15-12} = CRd;
4839 let Inst{11-8} = cop;
4840 let Inst{7-0} = offset{7-0};
4841 let DecoderMethod = "DecodeCopMemInstruction";
4843 def _OPTION : ACI<(outs),
4844 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4845 coproc_option_imm:$option),
4846 asm, "\t$cop, $CRd, $addr, $option"> {
4851 let Inst{24} = 0; // P = 0
4852 let Inst{23} = 1; // U = 1
4853 let Inst{22} = Dbit;
4854 let Inst{21} = 0; // W = 0
4855 let Inst{20} = load;
4856 let Inst{19-16} = addr;
4857 let Inst{15-12} = CRd;
4858 let Inst{11-8} = cop;
4859 let Inst{7-0} = option;
4860 let DecoderMethod = "DecodeCopMemInstruction";
4863 multiclass LdSt2Cop<bit load, bit Dbit, string asm> {
4864 def _OFFSET : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4865 asm, "\t$cop, $CRd, $addr"> {
4869 let Inst{24} = 1; // P = 1
4870 let Inst{23} = addr{8};
4871 let Inst{22} = Dbit;
4872 let Inst{21} = 0; // W = 0
4873 let Inst{20} = load;
4874 let Inst{19-16} = addr{12-9};
4875 let Inst{15-12} = CRd;
4876 let Inst{11-8} = cop;
4877 let Inst{7-0} = addr{7-0};
4878 let DecoderMethod = "DecodeCopMemInstruction";
4880 def _PRE : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr),
4881 asm, "\t$cop, $CRd, $addr!", IndexModePre> {
4885 let Inst{24} = 1; // P = 1
4886 let Inst{23} = addr{8};
4887 let Inst{22} = Dbit;
4888 let Inst{21} = 1; // W = 1
4889 let Inst{20} = load;
4890 let Inst{19-16} = addr{12-9};
4891 let Inst{15-12} = CRd;
4892 let Inst{11-8} = cop;
4893 let Inst{7-0} = addr{7-0};
4894 let DecoderMethod = "DecodeCopMemInstruction";
4896 def _POST: ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4897 postidx_imm8s4:$offset),
4898 asm, "\t$cop, $CRd, $addr, $offset", IndexModePost> {
4903 let Inst{24} = 0; // P = 0
4904 let Inst{23} = offset{8};
4905 let Inst{22} = Dbit;
4906 let Inst{21} = 1; // W = 1
4907 let Inst{20} = load;
4908 let Inst{19-16} = addr;
4909 let Inst{15-12} = CRd;
4910 let Inst{11-8} = cop;
4911 let Inst{7-0} = offset{7-0};
4912 let DecoderMethod = "DecodeCopMemInstruction";
4914 def _OPTION : ACInoP<(outs),
4915 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4916 coproc_option_imm:$option),
4917 asm, "\t$cop, $CRd, $addr, $option"> {
4922 let Inst{24} = 0; // P = 0
4923 let Inst{23} = 1; // U = 1
4924 let Inst{22} = Dbit;
4925 let Inst{21} = 0; // W = 0
4926 let Inst{20} = load;
4927 let Inst{19-16} = addr;
4928 let Inst{15-12} = CRd;
4929 let Inst{11-8} = cop;
4930 let Inst{7-0} = option;
4931 let DecoderMethod = "DecodeCopMemInstruction";
4935 defm LDC : LdStCop <1, 0, "ldc">;
4936 defm LDCL : LdStCop <1, 1, "ldcl">;
4937 defm STC : LdStCop <0, 0, "stc">;
4938 defm STCL : LdStCop <0, 1, "stcl">;
4939 defm LDC2 : LdSt2Cop<1, 0, "ldc2">, Requires<[PreV8]>;
4940 defm LDC2L : LdSt2Cop<1, 1, "ldc2l">, Requires<[PreV8]>;
4941 defm STC2 : LdSt2Cop<0, 0, "stc2">, Requires<[PreV8]>;
4942 defm STC2L : LdSt2Cop<0, 1, "stc2l">, Requires<[PreV8]>;
4944 //===----------------------------------------------------------------------===//
4945 // Move between coprocessor and ARM core register.
4948 class MovRCopro<string opc, bit direction, dag oops, dag iops,
4950 : ABI<0b1110, oops, iops, NoItinerary, opc,
4951 "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2", pattern> {
4952 let Inst{20} = direction;
4962 let Inst{15-12} = Rt;
4963 let Inst{11-8} = cop;
4964 let Inst{23-21} = opc1;
4965 let Inst{7-5} = opc2;
4966 let Inst{3-0} = CRm;
4967 let Inst{19-16} = CRn;
4970 def MCR : MovRCopro<"mcr", 0 /* from ARM core register to coprocessor */,
4972 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4973 c_imm:$CRm, imm0_7:$opc2),
4974 [(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
4975 imm:$CRm, imm:$opc2)]>,
4976 ComplexDeprecationPredicate<"MCR">;
4977 def : ARMInstAlias<"mcr${p} $cop, $opc1, $Rt, $CRn, $CRm",
4978 (MCR p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4979 c_imm:$CRm, 0, pred:$p)>;
4980 def MRC : MovRCopro<"mrc", 1 /* from coprocessor to ARM core register */,
4981 (outs GPRwithAPSR:$Rt),
4982 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
4984 def : ARMInstAlias<"mrc${p} $cop, $opc1, $Rt, $CRn, $CRm",
4985 (MRC GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
4986 c_imm:$CRm, 0, pred:$p)>;
4988 def : ARMPat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
4989 (MRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
4991 class MovRCopro2<string opc, bit direction, dag oops, dag iops,
4993 : ABXI<0b1110, oops, iops, NoItinerary,
4994 !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), pattern> {
4995 let Inst{31-24} = 0b11111110;
4996 let Inst{20} = direction;
5006 let Inst{15-12} = Rt;
5007 let Inst{11-8} = cop;
5008 let Inst{23-21} = opc1;
5009 let Inst{7-5} = opc2;
5010 let Inst{3-0} = CRm;
5011 let Inst{19-16} = CRn;
5014 def MCR2 : MovRCopro2<"mcr2", 0 /* from ARM core register to coprocessor */,
5016 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5017 c_imm:$CRm, imm0_7:$opc2),
5018 [(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
5019 imm:$CRm, imm:$opc2)]>,
5021 def : ARMInstAlias<"mcr2 $cop, $opc1, $Rt, $CRn, $CRm",
5022 (MCR2 p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5024 def MRC2 : MovRCopro2<"mrc2", 1 /* from coprocessor to ARM core register */,
5025 (outs GPRwithAPSR:$Rt),
5026 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
5029 def : ARMInstAlias<"mrc2 $cop, $opc1, $Rt, $CRn, $CRm",
5030 (MRC2 GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
5033 def : ARMV5TPat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn,
5034 imm:$CRm, imm:$opc2),
5035 (MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
5037 class MovRRCopro<string opc, bit direction, list<dag> pattern = []>
5038 : ABI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
5039 GPRnopc:$Rt, GPRnopc:$Rt2, c_imm:$CRm),
5040 NoItinerary, opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm", pattern> {
5041 let Inst{23-21} = 0b010;
5042 let Inst{20} = direction;
5050 let Inst{15-12} = Rt;
5051 let Inst{19-16} = Rt2;
5052 let Inst{11-8} = cop;
5053 let Inst{7-4} = opc1;
5054 let Inst{3-0} = CRm;
5057 def MCRR : MovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */,
5058 [(int_arm_mcrr imm:$cop, imm:$opc1, GPRnopc:$Rt,
5059 GPRnopc:$Rt2, imm:$CRm)]>;
5060 def MRRC : MovRRCopro<"mrrc", 1 /* from coprocessor to ARM core register */>;
5062 class MovRRCopro2<string opc, bit direction, list<dag> pattern = []>
5063 : ABXI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
5064 GPRnopc:$Rt, GPRnopc:$Rt2, c_imm:$CRm), NoItinerary,
5065 !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern>,
5067 let Inst{31-28} = 0b1111;
5068 let Inst{23-21} = 0b010;
5069 let Inst{20} = direction;
5077 let Inst{15-12} = Rt;
5078 let Inst{19-16} = Rt2;
5079 let Inst{11-8} = cop;
5080 let Inst{7-4} = opc1;
5081 let Inst{3-0} = CRm;
5083 let DecoderMethod = "DecodeMRRC2";
5086 def MCRR2 : MovRRCopro2<"mcrr2", 0 /* from ARM core register to coprocessor */,
5087 [(int_arm_mcrr2 imm:$cop, imm:$opc1, GPRnopc:$Rt,
5088 GPRnopc:$Rt2, imm:$CRm)]>;
5089 def MRRC2 : MovRRCopro2<"mrrc2", 1 /* from coprocessor to ARM core register */>;
5091 //===----------------------------------------------------------------------===//
5092 // Move between special register and ARM core register
5095 // Move to ARM core register from Special Register
5096 def MRS : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
5097 "mrs", "\t$Rd, apsr", []> {
5099 let Inst{23-16} = 0b00001111;
5100 let Unpredictable{19-17} = 0b111;
5102 let Inst{15-12} = Rd;
5104 let Inst{11-0} = 0b000000000000;
5105 let Unpredictable{11-0} = 0b110100001111;
5108 def : InstAlias<"mrs${p} $Rd, cpsr", (MRS GPRnopc:$Rd, pred:$p)>,
5111 // The MRSsys instruction is the MRS instruction from the ARM ARM,
5112 // section B9.3.9, with the R bit set to 1.
5113 def MRSsys : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
5114 "mrs", "\t$Rd, spsr", []> {
5116 let Inst{23-16} = 0b01001111;
5117 let Unpredictable{19-16} = 0b1111;
5119 let Inst{15-12} = Rd;
5121 let Inst{11-0} = 0b000000000000;
5122 let Unpredictable{11-0} = 0b110100001111;
5125 // However, the MRS (banked register) system instruction (ARMv7VE) *does* have a
5126 // separate encoding (distinguished by bit 5.
5127 def MRSbanked : ABI<0b0001, (outs GPRnopc:$Rd), (ins banked_reg:$banked),
5128 NoItinerary, "mrs", "\t$Rd, $banked", []>,
5129 Requires<[IsARM, HasVirtualization]> {
5134 let Inst{22} = banked{5}; // R bit
5135 let Inst{21-20} = 0b00;
5136 let Inst{19-16} = banked{3-0};
5137 let Inst{15-12} = Rd;
5138 let Inst{11-9} = 0b001;
5139 let Inst{8} = banked{4};
5140 let Inst{7-0} = 0b00000000;
5143 // Move from ARM core register to Special Register
5145 // No need to have both system and application versions of MSR (immediate) or
5146 // MSR (register), the encodings are the same and the assembly parser has no way
5147 // to distinguish between them. The mask operand contains the special register
5148 // (R Bit) in bit 4 and bits 3-0 contains the mask with the fields to be
5149 // accessed in the special register.
5150 def MSR : ABI<0b0001, (outs), (ins msr_mask:$mask, GPR:$Rn), NoItinerary,
5151 "msr", "\t$mask, $Rn", []> {
5156 let Inst{22} = mask{4}; // R bit
5157 let Inst{21-20} = 0b10;
5158 let Inst{19-16} = mask{3-0};
5159 let Inst{15-12} = 0b1111;
5160 let Inst{11-4} = 0b00000000;
5164 def MSRi : ABI<0b0011, (outs), (ins msr_mask:$mask, mod_imm:$imm), NoItinerary,
5165 "msr", "\t$mask, $imm", []> {
5170 let Inst{22} = mask{4}; // R bit
5171 let Inst{21-20} = 0b10;
5172 let Inst{19-16} = mask{3-0};
5173 let Inst{15-12} = 0b1111;
5174 let Inst{11-0} = imm;
5177 // However, the MSR (banked register) system instruction (ARMv7VE) *does* have a
5178 // separate encoding (distinguished by bit 5.
5179 def MSRbanked : ABI<0b0001, (outs), (ins banked_reg:$banked, GPRnopc:$Rn),
5180 NoItinerary, "msr", "\t$banked, $Rn", []>,
5181 Requires<[IsARM, HasVirtualization]> {
5186 let Inst{22} = banked{5}; // R bit
5187 let Inst{21-20} = 0b10;
5188 let Inst{19-16} = banked{3-0};
5189 let Inst{15-12} = 0b1111;
5190 let Inst{11-9} = 0b001;
5191 let Inst{8} = banked{4};
5192 let Inst{7-4} = 0b0000;
5196 // Dynamic stack allocation yields a _chkstk for Windows targets. These calls
5197 // are needed to probe the stack when allocating more than
5198 // 4k bytes in one go. Touching the stack at 4K increments is necessary to
5199 // ensure that the guard pages used by the OS virtual memory manager are
5200 // allocated in correct sequence.
5201 // The main point of having separate instruction are extra unmodelled effects
5202 // (compared to ordinary calls) like stack pointer change.
5204 def win__chkstk : SDNode<"ARMISD::WIN__CHKSTK", SDTNone,
5205 [SDNPHasChain, SDNPSideEffect]>;
5206 let usesCustomInserter = 1, Uses = [R4], Defs = [R4, SP] in
5207 def WIN__CHKSTK : PseudoInst<(outs), (ins), NoItinerary, [(win__chkstk)]>;
5209 //===----------------------------------------------------------------------===//
5213 // __aeabi_read_tp preserves the registers r1-r3.
5214 // This is a pseudo inst so that we can get the encoding right,
5215 // complete with fixup for the aeabi_read_tp function.
5216 // TPsoft is valid for ARM mode only, in case of Thumb mode a tTPsoft pattern
5217 // is defined in "ARMInstrThumb.td".
5219 Defs = [R0, R12, LR, CPSR], Uses = [SP] in {
5220 def TPsoft : ARMPseudoInst<(outs), (ins), 4, IIC_Br,
5221 [(set R0, ARMthread_pointer)]>, Sched<[WriteBr]>;
5224 //===----------------------------------------------------------------------===//
5225 // SJLJ Exception handling intrinsics
5226 // eh_sjlj_setjmp() is an instruction sequence to store the return
5227 // address and save #0 in R0 for the non-longjmp case.
5228 // Since by its nature we may be coming from some other function to get
5229 // here, and we're using the stack frame for the containing function to
5230 // save/restore registers, we can't keep anything live in regs across
5231 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
5232 // when we get here from a longjmp(). We force everything out of registers
5233 // except for our own input by listing the relevant registers in Defs. By
5234 // doing so, we also cause the prologue/epilogue code to actively preserve
5235 // all of the callee-saved resgisters, which is exactly what we want.
5236 // A constant value is passed in $val, and we use the location as a scratch.
5238 // These are pseudo-instructions and are lowered to individual MC-insts, so
5239 // no encoding information is necessary.
5241 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
5242 Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15 ],
5243 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
5244 def Int_eh_sjlj_setjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
5246 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
5247 Requires<[IsARM, HasVFP2]>;
5251 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
5252 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
5253 def Int_eh_sjlj_setjmp_nofp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
5255 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
5256 Requires<[IsARM, NoVFP]>;
5259 // FIXME: Non-IOS version(s)
5260 let isBarrier = 1, hasSideEffects = 1, isTerminator = 1,
5261 Defs = [ R7, LR, SP ] in {
5262 def Int_eh_sjlj_longjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$scratch),
5264 [(ARMeh_sjlj_longjmp GPR:$src, GPR:$scratch)]>,
5265 Requires<[IsARM, IsIOS]>;
5268 // eh.sjlj.dispatchsetup pseudo-instruction.
5269 // This pseudo is used for both ARM and Thumb. Any differences are handled when
5270 // the pseudo is expanded (which happens before any passes that need the
5271 // instruction size).
5272 let isBarrier = 1 in
5273 def Int_eh_sjlj_dispatchsetup : PseudoInst<(outs), (ins), NoItinerary, []>;
5276 //===----------------------------------------------------------------------===//
5277 // Non-Instruction Patterns
5280 // ARMv4 indirect branch using (MOVr PC, dst)
5281 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in
5282 def MOVPCRX : ARMPseudoExpand<(outs), (ins GPR:$dst),
5283 4, IIC_Br, [(brind GPR:$dst)],
5284 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>,
5285 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
5287 // Large immediate handling.
5289 // 32-bit immediate using two piece so_imms or movw + movt.
5290 // This is a single pseudo instruction, the benefit is that it can be remat'd
5291 // as a single unit instead of having to handle reg inputs.
5292 // FIXME: Remove this when we can do generalized remat.
5293 let isReMaterializable = 1, isMoveImm = 1 in
5294 def MOVi32imm : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
5295 [(set GPR:$dst, (arm_i32imm:$src))]>,
5298 def LDRLIT_ga_abs : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iLoad_i,
5299 [(set GPR:$dst, (ARMWrapper tglobaladdr:$src))]>,
5300 Requires<[IsARM, DontUseMovt]>;
5302 // Pseudo instruction that combines movw + movt + add pc (if PIC).
5303 // It also makes it possible to rematerialize the instructions.
5304 // FIXME: Remove this when we can do generalized remat and when machine licm
5305 // can properly the instructions.
5306 let isReMaterializable = 1 in {
5307 def MOV_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5309 [(set GPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>,
5310 Requires<[IsARM, UseMovt]>;
5312 def LDRLIT_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5315 (ARMWrapperPIC tglobaladdr:$addr))]>,
5316 Requires<[IsARM, DontUseMovt]>;
5318 def LDRLIT_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5321 (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
5322 Requires<[IsARM, DontUseMovt]>;
5324 let AddedComplexity = 10 in
5325 def MOV_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5327 [(set GPR:$dst, (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
5328 Requires<[IsARM, UseMovt]>;
5329 } // isReMaterializable
5331 // ConstantPool, GlobalAddress, and JumpTable
5332 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
5333 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
5334 Requires<[IsARM, UseMovt]>;
5335 def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
5336 (LEApcrelJT tjumptable:$dst, imm:$id)>;
5338 // TODO: add,sub,and, 3-instr forms?
5340 // Tail calls. These patterns also apply to Thumb mode.
5341 def : Pat<(ARMtcret tcGPR:$dst), (TCRETURNri tcGPR:$dst)>;
5342 def : Pat<(ARMtcret (i32 tglobaladdr:$dst)), (TCRETURNdi texternalsym:$dst)>;
5343 def : Pat<(ARMtcret (i32 texternalsym:$dst)), (TCRETURNdi texternalsym:$dst)>;
5346 def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>;
5347 def : ARMPat<(ARMcall_nolink texternalsym:$func),
5348 (BMOVPCB_CALL texternalsym:$func)>;
5350 // zextload i1 -> zextload i8
5351 def : ARMPat<(zextloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5352 def : ARMPat<(zextloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5354 // extload -> zextload
5355 def : ARMPat<(extloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5356 def : ARMPat<(extloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5357 def : ARMPat<(extloadi8 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5358 def : ARMPat<(extloadi8 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5360 def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
5362 def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
5363 def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
5366 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
5367 (sra (shl GPR:$b, (i32 16)), (i32 16))),
5368 (SMULBB GPR:$a, GPR:$b)>;
5369 def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
5370 (SMULBB GPR:$a, GPR:$b)>;
5371 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
5372 (sra GPR:$b, (i32 16))),
5373 (SMULBT GPR:$a, GPR:$b)>;
5374 def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, (i32 16))),
5375 (SMULBT GPR:$a, GPR:$b)>;
5376 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)),
5377 (sra (shl GPR:$b, (i32 16)), (i32 16))),
5378 (SMULTB GPR:$a, GPR:$b)>;
5379 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), sext_16_node:$b),
5380 (SMULTB GPR:$a, GPR:$b)>;
5382 def : ARMV5MOPat<(add GPR:$acc,
5383 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
5384 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
5385 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5386 def : ARMV5MOPat<(add GPR:$acc,
5387 (mul sext_16_node:$a, sext_16_node:$b)),
5388 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5389 def : ARMV5MOPat<(add GPR:$acc,
5390 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
5391 (sra GPR:$b, (i32 16)))),
5392 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
5393 def : ARMV5MOPat<(add GPR:$acc,
5394 (mul sext_16_node:$a, (sra GPR:$b, (i32 16)))),
5395 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
5396 def : ARMV5MOPat<(add GPR:$acc,
5397 (mul (sra GPR:$a, (i32 16)),
5398 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
5399 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
5400 def : ARMV5MOPat<(add GPR:$acc,
5401 (mul (sra GPR:$a, (i32 16)), sext_16_node:$b)),
5402 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
5405 // Pre-v7 uses MCR for synchronization barriers.
5406 def : ARMPat<(ARMMemBarrierMCR GPR:$zero), (MCR 15, 0, GPR:$zero, 7, 10, 5)>,
5407 Requires<[IsARM, HasV6]>;
5409 // SXT/UXT with no rotate
5410 let AddedComplexity = 16 in {
5411 def : ARMV6Pat<(and GPR:$Src, 0x000000FF), (UXTB GPR:$Src, 0)>;
5412 def : ARMV6Pat<(and GPR:$Src, 0x0000FFFF), (UXTH GPR:$Src, 0)>;
5413 def : ARMV6Pat<(and GPR:$Src, 0x00FF00FF), (UXTB16 GPR:$Src, 0)>;
5414 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0x00FF)),
5415 (UXTAB GPR:$Rn, GPR:$Rm, 0)>;
5416 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0xFFFF)),
5417 (UXTAH GPR:$Rn, GPR:$Rm, 0)>;
5420 def : ARMV6Pat<(sext_inreg GPR:$Src, i8), (SXTB GPR:$Src, 0)>;
5421 def : ARMV6Pat<(sext_inreg GPR:$Src, i16), (SXTH GPR:$Src, 0)>;
5423 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i8)),
5424 (SXTAB GPR:$Rn, GPRnopc:$Rm, 0)>;
5425 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i16)),
5426 (SXTAH GPR:$Rn, GPRnopc:$Rm, 0)>;
5428 // Atomic load/store patterns
5429 def : ARMPat<(atomic_load_8 ldst_so_reg:$src),
5430 (LDRBrs ldst_so_reg:$src)>;
5431 def : ARMPat<(atomic_load_8 addrmode_imm12:$src),
5432 (LDRBi12 addrmode_imm12:$src)>;
5433 def : ARMPat<(atomic_load_16 addrmode3:$src),
5434 (LDRH addrmode3:$src)>;
5435 def : ARMPat<(atomic_load_32 ldst_so_reg:$src),
5436 (LDRrs ldst_so_reg:$src)>;
5437 def : ARMPat<(atomic_load_32 addrmode_imm12:$src),
5438 (LDRi12 addrmode_imm12:$src)>;
5439 def : ARMPat<(atomic_store_8 ldst_so_reg:$ptr, GPR:$val),
5440 (STRBrs GPR:$val, ldst_so_reg:$ptr)>;
5441 def : ARMPat<(atomic_store_8 addrmode_imm12:$ptr, GPR:$val),
5442 (STRBi12 GPR:$val, addrmode_imm12:$ptr)>;
5443 def : ARMPat<(atomic_store_16 addrmode3:$ptr, GPR:$val),
5444 (STRH GPR:$val, addrmode3:$ptr)>;
5445 def : ARMPat<(atomic_store_32 ldst_so_reg:$ptr, GPR:$val),
5446 (STRrs GPR:$val, ldst_so_reg:$ptr)>;
5447 def : ARMPat<(atomic_store_32 addrmode_imm12:$ptr, GPR:$val),
5448 (STRi12 GPR:$val, addrmode_imm12:$ptr)>;
5451 //===----------------------------------------------------------------------===//
5455 include "ARMInstrThumb.td"
5457 //===----------------------------------------------------------------------===//
5461 include "ARMInstrThumb2.td"
5463 //===----------------------------------------------------------------------===//
5464 // Floating Point Support
5467 include "ARMInstrVFP.td"
5469 //===----------------------------------------------------------------------===//
5470 // Advanced SIMD (NEON) Support
5473 include "ARMInstrNEON.td"
5475 //===----------------------------------------------------------------------===//
5476 // Assembler aliases
5480 def : InstAlias<"dmb", (DMB 0xf)>, Requires<[IsARM, HasDB]>;
5481 def : InstAlias<"dsb", (DSB 0xf)>, Requires<[IsARM, HasDB]>;
5482 def : InstAlias<"isb", (ISB 0xf)>, Requires<[IsARM, HasDB]>;
5484 // System instructions
5485 def : MnemonicAlias<"swi", "svc">;
5487 // Load / Store Multiple
5488 def : MnemonicAlias<"ldmfd", "ldm">;
5489 def : MnemonicAlias<"ldmia", "ldm">;
5490 def : MnemonicAlias<"ldmea", "ldmdb">;
5491 def : MnemonicAlias<"stmfd", "stmdb">;
5492 def : MnemonicAlias<"stmia", "stm">;
5493 def : MnemonicAlias<"stmea", "stm">;
5495 // PKHBT/PKHTB with default shift amount. PKHTB is equivalent to PKHBT when the
5496 // shift amount is zero (i.e., unspecified).
5497 def : InstAlias<"pkhbt${p} $Rd, $Rn, $Rm",
5498 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
5499 Requires<[IsARM, HasV6]>;
5500 def : InstAlias<"pkhtb${p} $Rd, $Rn, $Rm",
5501 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
5502 Requires<[IsARM, HasV6]>;
5504 // PUSH/POP aliases for STM/LDM
5505 def : ARMInstAlias<"push${p} $regs", (STMDB_UPD SP, pred:$p, reglist:$regs)>;
5506 def : ARMInstAlias<"pop${p} $regs", (LDMIA_UPD SP, pred:$p, reglist:$regs)>;
5508 // SSAT/USAT optional shift operand.
5509 def : ARMInstAlias<"ssat${p} $Rd, $sat_imm, $Rn",
5510 (SSAT GPRnopc:$Rd, imm1_32:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5511 def : ARMInstAlias<"usat${p} $Rd, $sat_imm, $Rn",
5512 (USAT GPRnopc:$Rd, imm0_31:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5515 // Extend instruction optional rotate operand.
5516 def : ARMInstAlias<"sxtab${p} $Rd, $Rn, $Rm",
5517 (SXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5518 def : ARMInstAlias<"sxtah${p} $Rd, $Rn, $Rm",
5519 (SXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5520 def : ARMInstAlias<"sxtab16${p} $Rd, $Rn, $Rm",
5521 (SXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5522 def : ARMInstAlias<"sxtb${p} $Rd, $Rm",
5523 (SXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5524 def : ARMInstAlias<"sxtb16${p} $Rd, $Rm",
5525 (SXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5526 def : ARMInstAlias<"sxth${p} $Rd, $Rm",
5527 (SXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5529 def : ARMInstAlias<"uxtab${p} $Rd, $Rn, $Rm",
5530 (UXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5531 def : ARMInstAlias<"uxtah${p} $Rd, $Rn, $Rm",
5532 (UXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5533 def : ARMInstAlias<"uxtab16${p} $Rd, $Rn, $Rm",
5534 (UXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5535 def : ARMInstAlias<"uxtb${p} $Rd, $Rm",
5536 (UXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5537 def : ARMInstAlias<"uxtb16${p} $Rd, $Rm",
5538 (UXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5539 def : ARMInstAlias<"uxth${p} $Rd, $Rm",
5540 (UXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5544 def : MnemonicAlias<"rfefa", "rfeda">;
5545 def : MnemonicAlias<"rfeea", "rfedb">;
5546 def : MnemonicAlias<"rfefd", "rfeia">;
5547 def : MnemonicAlias<"rfeed", "rfeib">;
5548 def : MnemonicAlias<"rfe", "rfeia">;
5551 def : MnemonicAlias<"srsfa", "srsib">;
5552 def : MnemonicAlias<"srsea", "srsia">;
5553 def : MnemonicAlias<"srsfd", "srsdb">;
5554 def : MnemonicAlias<"srsed", "srsda">;
5555 def : MnemonicAlias<"srs", "srsia">;
5558 def : MnemonicAlias<"qsubaddx", "qsax">;
5560 def : MnemonicAlias<"saddsubx", "sasx">;
5561 // SHASX == SHADDSUBX
5562 def : MnemonicAlias<"shaddsubx", "shasx">;
5563 // SHSAX == SHSUBADDX
5564 def : MnemonicAlias<"shsubaddx", "shsax">;
5566 def : MnemonicAlias<"ssubaddx", "ssax">;
5568 def : MnemonicAlias<"uaddsubx", "uasx">;
5569 // UHASX == UHADDSUBX
5570 def : MnemonicAlias<"uhaddsubx", "uhasx">;
5571 // UHSAX == UHSUBADDX
5572 def : MnemonicAlias<"uhsubaddx", "uhsax">;
5573 // UQASX == UQADDSUBX
5574 def : MnemonicAlias<"uqaddsubx", "uqasx">;
5575 // UQSAX == UQSUBADDX
5576 def : MnemonicAlias<"uqsubaddx", "uqsax">;
5578 def : MnemonicAlias<"usubaddx", "usax">;
5580 // "mov Rd, so_imm_not" can be handled via "mvn" in assembly, just like
5582 def : ARMInstAlias<"mov${s}${p} $Rd, $imm",
5583 (MVNi rGPR:$Rd, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
5584 def : ARMInstAlias<"mvn${s}${p} $Rd, $imm",
5585 (MOVi rGPR:$Rd, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
5586 // Same for AND <--> BIC
5587 def : ARMInstAlias<"bic${s}${p} $Rd, $Rn, $imm",
5588 (ANDri rGPR:$Rd, rGPR:$Rn, mod_imm_not:$imm,
5589 pred:$p, cc_out:$s)>;
5590 def : ARMInstAlias<"bic${s}${p} $Rdn, $imm",
5591 (ANDri rGPR:$Rdn, rGPR:$Rdn, mod_imm_not:$imm,
5592 pred:$p, cc_out:$s)>;
5593 def : ARMInstAlias<"and${s}${p} $Rd, $Rn, $imm",
5594 (BICri rGPR:$Rd, rGPR:$Rn, mod_imm_not:$imm,
5595 pred:$p, cc_out:$s)>;
5596 def : ARMInstAlias<"and${s}${p} $Rdn, $imm",
5597 (BICri rGPR:$Rdn, rGPR:$Rdn, mod_imm_not:$imm,
5598 pred:$p, cc_out:$s)>;
5600 // Likewise, "add Rd, so_imm_neg" -> sub
5601 def : ARMInstAlias<"add${s}${p} $Rd, $Rn, $imm",
5602 (SUBri GPR:$Rd, GPR:$Rn, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
5603 def : ARMInstAlias<"add${s}${p} $Rd, $imm",
5604 (SUBri GPR:$Rd, GPR:$Rd, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
5605 // Same for CMP <--> CMN via so_imm_neg
5606 def : ARMInstAlias<"cmp${p} $Rd, $imm",
5607 (CMNri rGPR:$Rd, mod_imm_neg:$imm, pred:$p)>;
5608 def : ARMInstAlias<"cmn${p} $Rd, $imm",
5609 (CMPri rGPR:$Rd, mod_imm_neg:$imm, pred:$p)>;
5611 // The shifter forms of the MOV instruction are aliased to the ASR, LSL,
5612 // LSR, ROR, and RRX instructions.
5613 // FIXME: We need C++ parser hooks to map the alias to the MOV
5614 // encoding. It seems we should be able to do that sort of thing
5615 // in tblgen, but it could get ugly.
5616 let TwoOperandAliasConstraint = "$Rm = $Rd" in {
5617 def ASRi : ARMAsmPseudo<"asr${s}${p} $Rd, $Rm, $imm",
5618 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
5620 def LSRi : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rm, $imm",
5621 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
5623 def LSLi : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rm, $imm",
5624 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
5626 def RORi : ARMAsmPseudo<"ror${s}${p} $Rd, $Rm, $imm",
5627 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
5630 def RRXi : ARMAsmPseudo<"rrx${s}${p} $Rd, $Rm",
5631 (ins GPR:$Rd, GPR:$Rm, pred:$p, cc_out:$s)>;
5632 let TwoOperandAliasConstraint = "$Rn = $Rd" in {
5633 def ASRr : ARMAsmPseudo<"asr${s}${p} $Rd, $Rn, $Rm",
5634 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5636 def LSRr : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rn, $Rm",
5637 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5639 def LSLr : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rn, $Rm",
5640 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5642 def RORr : ARMAsmPseudo<"ror${s}${p} $Rd, $Rn, $Rm",
5643 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5647 // "neg" is and alias for "rsb rd, rn, #0"
5648 def : ARMInstAlias<"neg${s}${p} $Rd, $Rm",
5649 (RSBri GPR:$Rd, GPR:$Rm, 0, pred:$p, cc_out:$s)>;
5651 // Pre-v6, 'mov r0, r0' was used as a NOP encoding.
5652 def : InstAlias<"nop${p}", (MOVr R0, R0, pred:$p, zero_reg)>,
5653 Requires<[IsARM, NoV6]>;
5655 // MUL/UMLAL/SMLAL/UMULL/SMULL are available on all arches, but
5656 // the instruction definitions need difference constraints pre-v6.
5657 // Use these aliases for the assembly parsing on pre-v6.
5658 def : InstAlias<"mul${s}${p} $Rd, $Rn, $Rm",
5659 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s)>,
5660 Requires<[IsARM, NoV6]>;
5661 def : InstAlias<"mla${s}${p} $Rd, $Rn, $Rm, $Ra",
5662 (MLA GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra,
5663 pred:$p, cc_out:$s)>,
5664 Requires<[IsARM, NoV6]>;
5665 def : InstAlias<"smlal${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5666 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5667 Requires<[IsARM, NoV6]>;
5668 def : InstAlias<"umlal${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5669 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5670 Requires<[IsARM, NoV6]>;
5671 def : InstAlias<"smull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5672 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5673 Requires<[IsARM, NoV6]>;
5674 def : InstAlias<"umull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5675 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5676 Requires<[IsARM, NoV6]>;
5678 // 'it' blocks in ARM mode just validate the predicates. The IT itself
5680 def ITasm : ARMAsmPseudo<"it$mask $cc", (ins it_pred:$cc, it_mask:$mask)>,
5681 ComplexDeprecationPredicate<"IT">;
5683 let mayLoad = 1, mayStore =1, hasSideEffects = 1 in
5684 def SPACE : PseudoInst<(outs GPR:$Rd), (ins i32imm:$size, GPR:$Rn),
5686 [(set GPR:$Rd, (int_arm_space imm:$size, GPR:$Rn))]>;