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 IsMachO : Predicate<"Subtarget->isTargetMachO()">;
267 def IsNotMachO : Predicate<"!Subtarget->isTargetMachO()">;
268 def IsNaCl : Predicate<"Subtarget->isTargetNaCl()">;
269 def UseNaClTrap : Predicate<"Subtarget->useNaClTrap()">,
270 AssemblerPredicate<"FeatureNaClTrap", "NaCl">;
271 def DontUseNaClTrap : Predicate<"!Subtarget->useNaClTrap()">;
273 // FIXME: Eventually this will be just "hasV6T2Ops".
274 def UseMovt : Predicate<"Subtarget->useMovt(*MF)">;
275 def DontUseMovt : Predicate<"!Subtarget->useMovt(*MF)">;
276 def UseFPVMLx : Predicate<"Subtarget->useFPVMLx()">;
277 def UseMulOps : Predicate<"Subtarget->useMulOps()">;
279 // Prefer fused MAC for fp mul + add over fp VMLA / VMLS if they are available.
280 // But only select them if more precision in FP computation is allowed.
281 // Do not use them for Darwin platforms.
282 def UseFusedMAC : Predicate<"(TM.Options.AllowFPOpFusion =="
283 " FPOpFusion::Fast && "
284 " Subtarget->hasVFP4()) && "
285 "!Subtarget->isTargetDarwin()">;
286 def DontUseFusedMAC : Predicate<"!(TM.Options.AllowFPOpFusion =="
287 " FPOpFusion::Fast &&"
288 " Subtarget->hasVFP4()) || "
289 "Subtarget->isTargetDarwin()">;
291 // VGETLNi32 is microcoded on Swift - prefer VMOV.
292 def HasFastVGETLNi32 : Predicate<"!Subtarget->isSwift()">;
293 def HasSlowVGETLNi32 : Predicate<"Subtarget->isSwift()">;
295 // VDUP.32 is microcoded on Swift - prefer VMOV.
296 def HasFastVDUP32 : Predicate<"!Subtarget->isSwift()">;
297 def HasSlowVDUP32 : Predicate<"Subtarget->isSwift()">;
299 // Cortex-A9 prefers VMOVSR to VMOVDRR even when using NEON for scalar FP, as
300 // this allows more effective execution domain optimization. See
301 // setExecutionDomain().
302 def UseVMOVSR : Predicate<"Subtarget->isCortexA9() || !Subtarget->useNEONForSinglePrecisionFP()">;
303 def DontUseVMOVSR : Predicate<"!Subtarget->isCortexA9() && Subtarget->useNEONForSinglePrecisionFP()">;
305 def IsLE : Predicate<"getTargetLowering()->isLittleEndian()">;
306 def IsBE : Predicate<"getTargetLowering()->isBigEndian()">;
308 //===----------------------------------------------------------------------===//
309 // ARM Flag Definitions.
311 class RegConstraint<string C> {
312 string Constraints = C;
315 //===----------------------------------------------------------------------===//
316 // ARM specific transformation functions and pattern fragments.
319 // imm_neg_XFORM - Return the negation of an i32 immediate value.
320 def imm_neg_XFORM : SDNodeXForm<imm, [{
321 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), MVT::i32);
324 // imm_not_XFORM - Return the complement of a i32 immediate value.
325 def imm_not_XFORM : SDNodeXForm<imm, [{
326 return CurDAG->getTargetConstant(~(int)N->getZExtValue(), MVT::i32);
329 /// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
330 def imm16_31 : ImmLeaf<i32, [{
331 return (int32_t)Imm >= 16 && (int32_t)Imm < 32;
334 def so_imm_neg_asmoperand : AsmOperandClass { let Name = "ARMSOImmNeg"; }
335 def so_imm_neg : Operand<i32>, PatLeaf<(imm), [{
336 unsigned Value = -(unsigned)N->getZExtValue();
337 return Value && ARM_AM::getSOImmVal(Value) != -1;
339 let ParserMatchClass = so_imm_neg_asmoperand;
342 // Note: this pattern doesn't require an encoder method and such, as it's
343 // only used on aliases (Pat<> and InstAlias<>). The actual encoding
344 // is handled by the destination instructions, which use so_imm.
345 def so_imm_not_asmoperand : AsmOperandClass { let Name = "ARMSOImmNot"; }
346 def so_imm_not : Operand<i32>, PatLeaf<(imm), [{
347 return ARM_AM::getSOImmVal(~(uint32_t)N->getZExtValue()) != -1;
349 let ParserMatchClass = so_imm_not_asmoperand;
352 // sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
353 def sext_16_node : PatLeaf<(i32 GPR:$a), [{
354 return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17;
357 /// Split a 32-bit immediate into two 16 bit parts.
358 def hi16 : SDNodeXForm<imm, [{
359 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, MVT::i32);
362 def lo16AllZero : PatLeaf<(i32 imm), [{
363 // Returns true if all low 16-bits are 0.
364 return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
367 class BinOpWithFlagFrag<dag res> :
368 PatFrag<(ops node:$LHS, node:$RHS, node:$FLAG), res>;
369 class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
370 class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
372 // An 'and' node with a single use.
373 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
374 return N->hasOneUse();
377 // An 'xor' node with a single use.
378 def xor_su : PatFrag<(ops node:$lhs, node:$rhs), (xor node:$lhs, node:$rhs), [{
379 return N->hasOneUse();
382 // An 'fmul' node with a single use.
383 def fmul_su : PatFrag<(ops node:$lhs, node:$rhs), (fmul node:$lhs, node:$rhs),[{
384 return N->hasOneUse();
387 // An 'fadd' node which checks for single non-hazardous use.
388 def fadd_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fadd node:$lhs, node:$rhs),[{
389 return hasNoVMLxHazardUse(N);
392 // An 'fsub' node which checks for single non-hazardous use.
393 def fsub_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fsub node:$lhs, node:$rhs),[{
394 return hasNoVMLxHazardUse(N);
397 //===----------------------------------------------------------------------===//
398 // Operand Definitions.
401 // Immediate operands with a shared generic asm render method.
402 class ImmAsmOperand : AsmOperandClass { let RenderMethod = "addImmOperands"; }
405 // FIXME: rename brtarget to t2_brtarget
406 def brtarget : Operand<OtherVT> {
407 let EncoderMethod = "getBranchTargetOpValue";
408 let OperandType = "OPERAND_PCREL";
409 let DecoderMethod = "DecodeT2BROperand";
412 // FIXME: get rid of this one?
413 def uncondbrtarget : Operand<OtherVT> {
414 let EncoderMethod = "getUnconditionalBranchTargetOpValue";
415 let OperandType = "OPERAND_PCREL";
418 // Branch target for ARM. Handles conditional/unconditional
419 def br_target : Operand<OtherVT> {
420 let EncoderMethod = "getARMBranchTargetOpValue";
421 let OperandType = "OPERAND_PCREL";
425 // FIXME: rename bltarget to t2_bl_target?
426 def bltarget : Operand<i32> {
427 // Encoded the same as branch targets.
428 let EncoderMethod = "getBranchTargetOpValue";
429 let OperandType = "OPERAND_PCREL";
432 // Call target for ARM. Handles conditional/unconditional
433 // FIXME: rename bl_target to t2_bltarget?
434 def bl_target : Operand<i32> {
435 let EncoderMethod = "getARMBLTargetOpValue";
436 let OperandType = "OPERAND_PCREL";
439 def blx_target : Operand<i32> {
440 let EncoderMethod = "getARMBLXTargetOpValue";
441 let OperandType = "OPERAND_PCREL";
444 // A list of registers separated by comma. Used by load/store multiple.
445 def RegListAsmOperand : AsmOperandClass { let Name = "RegList"; }
446 def reglist : Operand<i32> {
447 let EncoderMethod = "getRegisterListOpValue";
448 let ParserMatchClass = RegListAsmOperand;
449 let PrintMethod = "printRegisterList";
450 let DecoderMethod = "DecodeRegListOperand";
453 def GPRPairOp : RegisterOperand<GPRPair, "printGPRPairOperand">;
455 def DPRRegListAsmOperand : AsmOperandClass { let Name = "DPRRegList"; }
456 def dpr_reglist : Operand<i32> {
457 let EncoderMethod = "getRegisterListOpValue";
458 let ParserMatchClass = DPRRegListAsmOperand;
459 let PrintMethod = "printRegisterList";
460 let DecoderMethod = "DecodeDPRRegListOperand";
463 def SPRRegListAsmOperand : AsmOperandClass { let Name = "SPRRegList"; }
464 def spr_reglist : Operand<i32> {
465 let EncoderMethod = "getRegisterListOpValue";
466 let ParserMatchClass = SPRRegListAsmOperand;
467 let PrintMethod = "printRegisterList";
468 let DecoderMethod = "DecodeSPRRegListOperand";
471 // An operand for the CONSTPOOL_ENTRY pseudo-instruction.
472 def cpinst_operand : Operand<i32> {
473 let PrintMethod = "printCPInstOperand";
477 def pclabel : Operand<i32> {
478 let PrintMethod = "printPCLabel";
481 // ADR instruction labels.
482 def AdrLabelAsmOperand : AsmOperandClass { let Name = "AdrLabel"; }
483 def adrlabel : Operand<i32> {
484 let EncoderMethod = "getAdrLabelOpValue";
485 let ParserMatchClass = AdrLabelAsmOperand;
486 let PrintMethod = "printAdrLabelOperand<0>";
489 def neon_vcvt_imm32 : Operand<i32> {
490 let EncoderMethod = "getNEONVcvtImm32OpValue";
491 let DecoderMethod = "DecodeVCVTImmOperand";
494 // rot_imm: An integer that encodes a rotate amount. Must be 8, 16, or 24.
495 def rot_imm_XFORM: SDNodeXForm<imm, [{
496 switch (N->getZExtValue()){
497 default: llvm_unreachable(nullptr);
498 case 0: return CurDAG->getTargetConstant(0, MVT::i32);
499 case 8: return CurDAG->getTargetConstant(1, MVT::i32);
500 case 16: return CurDAG->getTargetConstant(2, MVT::i32);
501 case 24: return CurDAG->getTargetConstant(3, MVT::i32);
504 def RotImmAsmOperand : AsmOperandClass {
506 let ParserMethod = "parseRotImm";
508 def rot_imm : Operand<i32>, PatLeaf<(i32 imm), [{
509 int32_t v = N->getZExtValue();
510 return v == 8 || v == 16 || v == 24; }],
512 let PrintMethod = "printRotImmOperand";
513 let ParserMatchClass = RotImmAsmOperand;
516 // shift_imm: An integer that encodes a shift amount and the type of shift
517 // (asr or lsl). The 6-bit immediate encodes as:
520 // {4-0} imm5 shift amount.
521 // asr #32 encoded as imm5 == 0.
522 def ShifterImmAsmOperand : AsmOperandClass {
523 let Name = "ShifterImm";
524 let ParserMethod = "parseShifterImm";
526 def shift_imm : Operand<i32> {
527 let PrintMethod = "printShiftImmOperand";
528 let ParserMatchClass = ShifterImmAsmOperand;
531 // shifter_operand operands: so_reg_reg, so_reg_imm, and so_imm.
532 def ShiftedRegAsmOperand : AsmOperandClass { let Name = "RegShiftedReg"; }
533 def so_reg_reg : Operand<i32>, // reg reg imm
534 ComplexPattern<i32, 3, "SelectRegShifterOperand",
535 [shl, srl, sra, rotr]> {
536 let EncoderMethod = "getSORegRegOpValue";
537 let PrintMethod = "printSORegRegOperand";
538 let DecoderMethod = "DecodeSORegRegOperand";
539 let ParserMatchClass = ShiftedRegAsmOperand;
540 let MIOperandInfo = (ops GPRnopc, GPRnopc, i32imm);
543 def ShiftedImmAsmOperand : AsmOperandClass { let Name = "RegShiftedImm"; }
544 def so_reg_imm : Operand<i32>, // reg imm
545 ComplexPattern<i32, 2, "SelectImmShifterOperand",
546 [shl, srl, sra, rotr]> {
547 let EncoderMethod = "getSORegImmOpValue";
548 let PrintMethod = "printSORegImmOperand";
549 let DecoderMethod = "DecodeSORegImmOperand";
550 let ParserMatchClass = ShiftedImmAsmOperand;
551 let MIOperandInfo = (ops GPR, i32imm);
554 // FIXME: Does this need to be distinct from so_reg?
555 def shift_so_reg_reg : Operand<i32>, // reg reg imm
556 ComplexPattern<i32, 3, "SelectShiftRegShifterOperand",
557 [shl,srl,sra,rotr]> {
558 let EncoderMethod = "getSORegRegOpValue";
559 let PrintMethod = "printSORegRegOperand";
560 let DecoderMethod = "DecodeSORegRegOperand";
561 let ParserMatchClass = ShiftedRegAsmOperand;
562 let MIOperandInfo = (ops GPR, GPR, i32imm);
565 // FIXME: Does this need to be distinct from so_reg?
566 def shift_so_reg_imm : Operand<i32>, // reg reg imm
567 ComplexPattern<i32, 2, "SelectShiftImmShifterOperand",
568 [shl,srl,sra,rotr]> {
569 let EncoderMethod = "getSORegImmOpValue";
570 let PrintMethod = "printSORegImmOperand";
571 let DecoderMethod = "DecodeSORegImmOperand";
572 let ParserMatchClass = ShiftedImmAsmOperand;
573 let MIOperandInfo = (ops GPR, i32imm);
577 // so_imm - Match a 32-bit shifter_operand immediate operand, which is an
578 // 8-bit immediate rotated by an arbitrary number of bits.
579 def SOImmAsmOperand: ImmAsmOperand { let Name = "ARMSOImm"; }
580 def so_imm : Operand<i32>, ImmLeaf<i32, [{
581 return ARM_AM::getSOImmVal(Imm) != -1;
583 let EncoderMethod = "getSOImmOpValue";
584 let ParserMatchClass = SOImmAsmOperand;
587 // mod_imm: match a 32-bit immediate operand, which is encoded as a 12-bit
588 // immediate (See ARMARM - "Modified Immediate Constants"). Unlike so_imm,
589 // mod_imm keeps the immediate in its encoded form (within the MC layer).
590 def ModImmAsmOperand: AsmOperandClass {
592 let ParserMethod = "parseModImm";
594 def mod_imm : Operand<i32>, ImmLeaf<i32, [{
595 return ARM_AM::getSOImmVal(Imm) != -1;
597 let EncoderMethod = "getModImmOpValue";
598 let PrintMethod = "printModImmOperand";
599 let ParserMatchClass = ModImmAsmOperand;
602 // similar to so_imm_not, but keeps the immediate in its encoded form
603 def ModImmNotAsmOperand : AsmOperandClass { let Name = "ModImmNot"; }
604 def mod_imm_not : Operand<i32>, PatLeaf<(imm), [{
605 return ARM_AM::getSOImmVal(~(uint32_t)N->getZExtValue()) != -1;
607 let ParserMatchClass = ModImmNotAsmOperand;
610 // similar to so_imm_neg, but keeps the immediate in its encoded form
611 def ModImmNegAsmOperand : AsmOperandClass { let Name = "ModImmNeg"; }
612 def mod_imm_neg : Operand<i32>, PatLeaf<(imm), [{
613 unsigned Value = -(unsigned)N->getZExtValue();
614 return Value && ARM_AM::getSOImmVal(Value) != -1;
616 let ParserMatchClass = ModImmNegAsmOperand;
619 // Break so_imm's up into two pieces. This handles immediates with up to 16
620 // bits set in them. This uses so_imm2part to match and so_imm2part_[12] to
621 // get the first/second pieces.
622 def so_imm2part : PatLeaf<(imm), [{
623 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
626 /// arm_i32imm - True for +V6T2, or true only if so_imm2part is true.
628 def arm_i32imm : PatLeaf<(imm), [{
629 if (Subtarget->useMovt(*MF))
631 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
634 /// imm0_1 predicate - Immediate in the range [0,1].
635 def Imm0_1AsmOperand: ImmAsmOperand { let Name = "Imm0_1"; }
636 def imm0_1 : Operand<i32> { let ParserMatchClass = Imm0_1AsmOperand; }
638 /// imm0_3 predicate - Immediate in the range [0,3].
639 def Imm0_3AsmOperand: ImmAsmOperand { let Name = "Imm0_3"; }
640 def imm0_3 : Operand<i32> { let ParserMatchClass = Imm0_3AsmOperand; }
642 /// imm0_7 predicate - Immediate in the range [0,7].
643 def Imm0_7AsmOperand: ImmAsmOperand { let Name = "Imm0_7"; }
644 def imm0_7 : Operand<i32>, ImmLeaf<i32, [{
645 return Imm >= 0 && Imm < 8;
647 let ParserMatchClass = Imm0_7AsmOperand;
650 /// imm8 predicate - Immediate is exactly 8.
651 def Imm8AsmOperand: ImmAsmOperand { let Name = "Imm8"; }
652 def imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 8; }]> {
653 let ParserMatchClass = Imm8AsmOperand;
656 /// imm16 predicate - Immediate is exactly 16.
657 def Imm16AsmOperand: ImmAsmOperand { let Name = "Imm16"; }
658 def imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 16; }]> {
659 let ParserMatchClass = Imm16AsmOperand;
662 /// imm32 predicate - Immediate is exactly 32.
663 def Imm32AsmOperand: ImmAsmOperand { let Name = "Imm32"; }
664 def imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 32; }]> {
665 let ParserMatchClass = Imm32AsmOperand;
668 def imm8_or_16 : ImmLeaf<i32, [{ return Imm == 8 || Imm == 16;}]>;
670 /// imm1_7 predicate - Immediate in the range [1,7].
671 def Imm1_7AsmOperand: ImmAsmOperand { let Name = "Imm1_7"; }
672 def imm1_7 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 8; }]> {
673 let ParserMatchClass = Imm1_7AsmOperand;
676 /// imm1_15 predicate - Immediate in the range [1,15].
677 def Imm1_15AsmOperand: ImmAsmOperand { let Name = "Imm1_15"; }
678 def imm1_15 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 16; }]> {
679 let ParserMatchClass = Imm1_15AsmOperand;
682 /// imm1_31 predicate - Immediate in the range [1,31].
683 def Imm1_31AsmOperand: ImmAsmOperand { let Name = "Imm1_31"; }
684 def imm1_31 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 32; }]> {
685 let ParserMatchClass = Imm1_31AsmOperand;
688 /// imm0_15 predicate - Immediate in the range [0,15].
689 def Imm0_15AsmOperand: ImmAsmOperand {
690 let Name = "Imm0_15";
691 let DiagnosticType = "ImmRange0_15";
693 def imm0_15 : Operand<i32>, ImmLeaf<i32, [{
694 return Imm >= 0 && Imm < 16;
696 let ParserMatchClass = Imm0_15AsmOperand;
699 /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
700 def Imm0_31AsmOperand: ImmAsmOperand { let Name = "Imm0_31"; }
701 def imm0_31 : Operand<i32>, ImmLeaf<i32, [{
702 return Imm >= 0 && Imm < 32;
704 let ParserMatchClass = Imm0_31AsmOperand;
707 /// imm0_32 predicate - True if the 32-bit immediate is in the range [0,32].
708 def Imm0_32AsmOperand: ImmAsmOperand { let Name = "Imm0_32"; }
709 def imm0_32 : Operand<i32>, ImmLeaf<i32, [{
710 return Imm >= 0 && Imm < 32;
712 let ParserMatchClass = Imm0_32AsmOperand;
715 /// imm0_63 predicate - True if the 32-bit immediate is in the range [0,63].
716 def Imm0_63AsmOperand: ImmAsmOperand { let Name = "Imm0_63"; }
717 def imm0_63 : Operand<i32>, ImmLeaf<i32, [{
718 return Imm >= 0 && Imm < 64;
720 let ParserMatchClass = Imm0_63AsmOperand;
723 /// imm0_239 predicate - Immediate in the range [0,239].
724 def Imm0_239AsmOperand : ImmAsmOperand {
725 let Name = "Imm0_239";
726 let DiagnosticType = "ImmRange0_239";
728 def imm0_239 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 240; }]> {
729 let ParserMatchClass = Imm0_239AsmOperand;
732 /// imm0_255 predicate - Immediate in the range [0,255].
733 def Imm0_255AsmOperand : ImmAsmOperand { let Name = "Imm0_255"; }
734 def imm0_255 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 256; }]> {
735 let ParserMatchClass = Imm0_255AsmOperand;
738 /// imm0_65535 - An immediate is in the range [0.65535].
739 def Imm0_65535AsmOperand: ImmAsmOperand { let Name = "Imm0_65535"; }
740 def imm0_65535 : Operand<i32>, ImmLeaf<i32, [{
741 return Imm >= 0 && Imm < 65536;
743 let ParserMatchClass = Imm0_65535AsmOperand;
746 // imm0_65535_neg - An immediate whose negative value is in the range [0.65535].
747 def imm0_65535_neg : Operand<i32>, ImmLeaf<i32, [{
748 return -Imm >= 0 && -Imm < 65536;
751 // imm0_65535_expr - For movt/movw - 16-bit immediate that can also reference
752 // a relocatable expression.
754 // FIXME: This really needs a Thumb version separate from the ARM version.
755 // While the range is the same, and can thus use the same match class,
756 // the encoding is different so it should have a different encoder method.
757 def Imm0_65535ExprAsmOperand: ImmAsmOperand { let Name = "Imm0_65535Expr"; }
758 def imm0_65535_expr : Operand<i32> {
759 let EncoderMethod = "getHiLo16ImmOpValue";
760 let ParserMatchClass = Imm0_65535ExprAsmOperand;
763 def Imm256_65535ExprAsmOperand: ImmAsmOperand { let Name = "Imm256_65535Expr"; }
764 def imm256_65535_expr : Operand<i32> {
765 let ParserMatchClass = Imm256_65535ExprAsmOperand;
768 /// imm24b - True if the 32-bit immediate is encodable in 24 bits.
769 def Imm24bitAsmOperand: ImmAsmOperand { let Name = "Imm24bit"; }
770 def imm24b : Operand<i32>, ImmLeaf<i32, [{
771 return Imm >= 0 && Imm <= 0xffffff;
773 let ParserMatchClass = Imm24bitAsmOperand;
777 /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
779 def BitfieldAsmOperand : AsmOperandClass {
780 let Name = "Bitfield";
781 let ParserMethod = "parseBitfield";
784 def bf_inv_mask_imm : Operand<i32>,
786 return ARM::isBitFieldInvertedMask(N->getZExtValue());
788 let EncoderMethod = "getBitfieldInvertedMaskOpValue";
789 let PrintMethod = "printBitfieldInvMaskImmOperand";
790 let DecoderMethod = "DecodeBitfieldMaskOperand";
791 let ParserMatchClass = BitfieldAsmOperand;
794 def imm1_32_XFORM: SDNodeXForm<imm, [{
795 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, MVT::i32);
797 def Imm1_32AsmOperand: AsmOperandClass { let Name = "Imm1_32"; }
798 def imm1_32 : Operand<i32>, PatLeaf<(imm), [{
799 uint64_t Imm = N->getZExtValue();
800 return Imm > 0 && Imm <= 32;
803 let PrintMethod = "printImmPlusOneOperand";
804 let ParserMatchClass = Imm1_32AsmOperand;
807 def imm1_16_XFORM: SDNodeXForm<imm, [{
808 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, MVT::i32);
810 def Imm1_16AsmOperand: AsmOperandClass { let Name = "Imm1_16"; }
811 def imm1_16 : Operand<i32>, PatLeaf<(imm), [{ return Imm > 0 && Imm <= 16; }],
813 let PrintMethod = "printImmPlusOneOperand";
814 let ParserMatchClass = Imm1_16AsmOperand;
817 // Define ARM specific addressing modes.
818 // addrmode_imm12 := reg +/- imm12
820 def MemImm12OffsetAsmOperand : AsmOperandClass { let Name = "MemImm12Offset"; }
821 class AddrMode_Imm12 : Operand<i32>,
822 ComplexPattern<i32, 2, "SelectAddrModeImm12", []> {
823 // 12-bit immediate operand. Note that instructions using this encode
824 // #0 and #-0 differently. We flag #-0 as the magic value INT32_MIN. All other
825 // immediate values are as normal.
827 let EncoderMethod = "getAddrModeImm12OpValue";
828 let DecoderMethod = "DecodeAddrModeImm12Operand";
829 let ParserMatchClass = MemImm12OffsetAsmOperand;
830 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
833 def addrmode_imm12 : AddrMode_Imm12 {
834 let PrintMethod = "printAddrModeImm12Operand<false>";
837 def addrmode_imm12_pre : AddrMode_Imm12 {
838 let PrintMethod = "printAddrModeImm12Operand<true>";
841 // ldst_so_reg := reg +/- reg shop imm
843 def MemRegOffsetAsmOperand : AsmOperandClass { let Name = "MemRegOffset"; }
844 def ldst_so_reg : Operand<i32>,
845 ComplexPattern<i32, 3, "SelectLdStSOReg", []> {
846 let EncoderMethod = "getLdStSORegOpValue";
847 // FIXME: Simplify the printer
848 let PrintMethod = "printAddrMode2Operand";
849 let DecoderMethod = "DecodeSORegMemOperand";
850 let ParserMatchClass = MemRegOffsetAsmOperand;
851 let MIOperandInfo = (ops GPR:$base, GPRnopc:$offsreg, i32imm:$shift);
854 // postidx_imm8 := +/- [0,255]
857 // {8} 1 is imm8 is non-negative. 0 otherwise.
858 // {7-0} [0,255] imm8 value.
859 def PostIdxImm8AsmOperand : AsmOperandClass { let Name = "PostIdxImm8"; }
860 def postidx_imm8 : Operand<i32> {
861 let PrintMethod = "printPostIdxImm8Operand";
862 let ParserMatchClass = PostIdxImm8AsmOperand;
863 let MIOperandInfo = (ops i32imm);
866 // postidx_imm8s4 := +/- [0,1020]
869 // {8} 1 is imm8 is non-negative. 0 otherwise.
870 // {7-0} [0,255] imm8 value, scaled by 4.
871 def PostIdxImm8s4AsmOperand : AsmOperandClass { let Name = "PostIdxImm8s4"; }
872 def postidx_imm8s4 : Operand<i32> {
873 let PrintMethod = "printPostIdxImm8s4Operand";
874 let ParserMatchClass = PostIdxImm8s4AsmOperand;
875 let MIOperandInfo = (ops i32imm);
879 // postidx_reg := +/- reg
881 def PostIdxRegAsmOperand : AsmOperandClass {
882 let Name = "PostIdxReg";
883 let ParserMethod = "parsePostIdxReg";
885 def postidx_reg : Operand<i32> {
886 let EncoderMethod = "getPostIdxRegOpValue";
887 let DecoderMethod = "DecodePostIdxReg";
888 let PrintMethod = "printPostIdxRegOperand";
889 let ParserMatchClass = PostIdxRegAsmOperand;
890 let MIOperandInfo = (ops GPRnopc, i32imm);
894 // addrmode2 := reg +/- imm12
895 // := reg +/- reg shop imm
897 // FIXME: addrmode2 should be refactored the rest of the way to always
898 // use explicit imm vs. reg versions above (addrmode_imm12 and ldst_so_reg).
899 def AddrMode2AsmOperand : AsmOperandClass { let Name = "AddrMode2"; }
900 def addrmode2 : Operand<i32>,
901 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
902 let EncoderMethod = "getAddrMode2OpValue";
903 let PrintMethod = "printAddrMode2Operand";
904 let ParserMatchClass = AddrMode2AsmOperand;
905 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
908 def PostIdxRegShiftedAsmOperand : AsmOperandClass {
909 let Name = "PostIdxRegShifted";
910 let ParserMethod = "parsePostIdxReg";
912 def am2offset_reg : Operand<i32>,
913 ComplexPattern<i32, 2, "SelectAddrMode2OffsetReg",
914 [], [SDNPWantRoot]> {
915 let EncoderMethod = "getAddrMode2OffsetOpValue";
916 let PrintMethod = "printAddrMode2OffsetOperand";
917 // When using this for assembly, it's always as a post-index offset.
918 let ParserMatchClass = PostIdxRegShiftedAsmOperand;
919 let MIOperandInfo = (ops GPRnopc, i32imm);
922 // FIXME: am2offset_imm should only need the immediate, not the GPR. Having
923 // the GPR is purely vestigal at this point.
924 def AM2OffsetImmAsmOperand : AsmOperandClass { let Name = "AM2OffsetImm"; }
925 def am2offset_imm : Operand<i32>,
926 ComplexPattern<i32, 2, "SelectAddrMode2OffsetImm",
927 [], [SDNPWantRoot]> {
928 let EncoderMethod = "getAddrMode2OffsetOpValue";
929 let PrintMethod = "printAddrMode2OffsetOperand";
930 let ParserMatchClass = AM2OffsetImmAsmOperand;
931 let MIOperandInfo = (ops GPRnopc, i32imm);
935 // addrmode3 := reg +/- reg
936 // addrmode3 := reg +/- imm8
938 // FIXME: split into imm vs. reg versions.
939 def AddrMode3AsmOperand : AsmOperandClass { let Name = "AddrMode3"; }
940 class AddrMode3 : Operand<i32>,
941 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
942 let EncoderMethod = "getAddrMode3OpValue";
943 let ParserMatchClass = AddrMode3AsmOperand;
944 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
947 def addrmode3 : AddrMode3
949 let PrintMethod = "printAddrMode3Operand<false>";
952 def addrmode3_pre : AddrMode3
954 let PrintMethod = "printAddrMode3Operand<true>";
957 // FIXME: split into imm vs. reg versions.
958 // FIXME: parser method to handle +/- register.
959 def AM3OffsetAsmOperand : AsmOperandClass {
960 let Name = "AM3Offset";
961 let ParserMethod = "parseAM3Offset";
963 def am3offset : Operand<i32>,
964 ComplexPattern<i32, 2, "SelectAddrMode3Offset",
965 [], [SDNPWantRoot]> {
966 let EncoderMethod = "getAddrMode3OffsetOpValue";
967 let PrintMethod = "printAddrMode3OffsetOperand";
968 let ParserMatchClass = AM3OffsetAsmOperand;
969 let MIOperandInfo = (ops GPR, i32imm);
972 // ldstm_mode := {ia, ib, da, db}
974 def ldstm_mode : OptionalDefOperand<OtherVT, (ops i32), (ops (i32 1))> {
975 let EncoderMethod = "getLdStmModeOpValue";
976 let PrintMethod = "printLdStmModeOperand";
979 // addrmode5 := reg +/- imm8*4
981 def AddrMode5AsmOperand : AsmOperandClass { let Name = "AddrMode5"; }
982 class AddrMode5 : Operand<i32>,
983 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
984 let EncoderMethod = "getAddrMode5OpValue";
985 let DecoderMethod = "DecodeAddrMode5Operand";
986 let ParserMatchClass = AddrMode5AsmOperand;
987 let MIOperandInfo = (ops GPR:$base, i32imm);
990 def addrmode5 : AddrMode5 {
991 let PrintMethod = "printAddrMode5Operand<false>";
994 def addrmode5_pre : AddrMode5 {
995 let PrintMethod = "printAddrMode5Operand<true>";
998 // addrmode6 := reg with optional alignment
1000 def AddrMode6AsmOperand : AsmOperandClass { let Name = "AlignedMemory"; }
1001 def addrmode6 : Operand<i32>,
1002 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1003 let PrintMethod = "printAddrMode6Operand";
1004 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
1005 let EncoderMethod = "getAddrMode6AddressOpValue";
1006 let DecoderMethod = "DecodeAddrMode6Operand";
1007 let ParserMatchClass = AddrMode6AsmOperand;
1010 def am6offset : Operand<i32>,
1011 ComplexPattern<i32, 1, "SelectAddrMode6Offset",
1012 [], [SDNPWantRoot]> {
1013 let PrintMethod = "printAddrMode6OffsetOperand";
1014 let MIOperandInfo = (ops GPR);
1015 let EncoderMethod = "getAddrMode6OffsetOpValue";
1016 let DecoderMethod = "DecodeGPRRegisterClass";
1019 // Special version of addrmode6 to handle alignment encoding for VST1/VLD1
1020 // (single element from one lane) for size 32.
1021 def addrmode6oneL32 : Operand<i32>,
1022 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1023 let PrintMethod = "printAddrMode6Operand";
1024 let MIOperandInfo = (ops GPR:$addr, i32imm);
1025 let EncoderMethod = "getAddrMode6OneLane32AddressOpValue";
1028 // Base class for addrmode6 with specific alignment restrictions.
1029 class AddrMode6Align : Operand<i32>,
1030 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1031 let PrintMethod = "printAddrMode6Operand";
1032 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
1033 let EncoderMethod = "getAddrMode6AddressOpValue";
1034 let DecoderMethod = "DecodeAddrMode6Operand";
1037 // Special version of addrmode6 to handle no allowed alignment encoding for
1038 // VLD/VST instructions and checking the alignment is not specified.
1039 def AddrMode6AlignNoneAsmOperand : AsmOperandClass {
1040 let Name = "AlignedMemoryNone";
1041 let DiagnosticType = "AlignedMemoryRequiresNone";
1043 def addrmode6alignNone : AddrMode6Align {
1044 // The alignment specifier can only be omitted.
1045 let ParserMatchClass = AddrMode6AlignNoneAsmOperand;
1048 // Special version of addrmode6 to handle 16-bit alignment encoding for
1049 // VLD/VST instructions and checking the alignment value.
1050 def AddrMode6Align16AsmOperand : AsmOperandClass {
1051 let Name = "AlignedMemory16";
1052 let DiagnosticType = "AlignedMemoryRequires16";
1054 def addrmode6align16 : AddrMode6Align {
1055 // The alignment specifier can only be 16 or omitted.
1056 let ParserMatchClass = AddrMode6Align16AsmOperand;
1059 // Special version of addrmode6 to handle 32-bit alignment encoding for
1060 // VLD/VST instructions and checking the alignment value.
1061 def AddrMode6Align32AsmOperand : AsmOperandClass {
1062 let Name = "AlignedMemory32";
1063 let DiagnosticType = "AlignedMemoryRequires32";
1065 def addrmode6align32 : AddrMode6Align {
1066 // The alignment specifier can only be 32 or omitted.
1067 let ParserMatchClass = AddrMode6Align32AsmOperand;
1070 // Special version of addrmode6 to handle 64-bit alignment encoding for
1071 // VLD/VST instructions and checking the alignment value.
1072 def AddrMode6Align64AsmOperand : AsmOperandClass {
1073 let Name = "AlignedMemory64";
1074 let DiagnosticType = "AlignedMemoryRequires64";
1076 def addrmode6align64 : AddrMode6Align {
1077 // The alignment specifier can only be 64 or omitted.
1078 let ParserMatchClass = AddrMode6Align64AsmOperand;
1081 // Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding
1082 // for VLD/VST instructions and checking the alignment value.
1083 def AddrMode6Align64or128AsmOperand : AsmOperandClass {
1084 let Name = "AlignedMemory64or128";
1085 let DiagnosticType = "AlignedMemoryRequires64or128";
1087 def addrmode6align64or128 : AddrMode6Align {
1088 // The alignment specifier can only be 64, 128 or omitted.
1089 let ParserMatchClass = AddrMode6Align64or128AsmOperand;
1092 // Special version of addrmode6 to handle 64-bit, 128-bit or 256-bit alignment
1093 // encoding for VLD/VST instructions and checking the alignment value.
1094 def AddrMode6Align64or128or256AsmOperand : AsmOperandClass {
1095 let Name = "AlignedMemory64or128or256";
1096 let DiagnosticType = "AlignedMemoryRequires64or128or256";
1098 def addrmode6align64or128or256 : AddrMode6Align {
1099 // The alignment specifier can only be 64, 128, 256 or omitted.
1100 let ParserMatchClass = AddrMode6Align64or128or256AsmOperand;
1103 // Special version of addrmode6 to handle alignment encoding for VLD-dup
1104 // instructions, specifically VLD4-dup.
1105 def addrmode6dup : Operand<i32>,
1106 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1107 let PrintMethod = "printAddrMode6Operand";
1108 let MIOperandInfo = (ops GPR:$addr, i32imm);
1109 let EncoderMethod = "getAddrMode6DupAddressOpValue";
1110 // FIXME: This is close, but not quite right. The alignment specifier is
1112 let ParserMatchClass = AddrMode6AsmOperand;
1115 // Base class for addrmode6dup with specific alignment restrictions.
1116 class AddrMode6DupAlign : Operand<i32>,
1117 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1118 let PrintMethod = "printAddrMode6Operand";
1119 let MIOperandInfo = (ops GPR:$addr, i32imm);
1120 let EncoderMethod = "getAddrMode6DupAddressOpValue";
1123 // Special version of addrmode6 to handle no allowed alignment encoding for
1124 // VLD-dup instruction and checking the alignment is not specified.
1125 def AddrMode6dupAlignNoneAsmOperand : AsmOperandClass {
1126 let Name = "DupAlignedMemoryNone";
1127 let DiagnosticType = "DupAlignedMemoryRequiresNone";
1129 def addrmode6dupalignNone : AddrMode6DupAlign {
1130 // The alignment specifier can only be omitted.
1131 let ParserMatchClass = AddrMode6dupAlignNoneAsmOperand;
1134 // Special version of addrmode6 to handle 16-bit alignment encoding for VLD-dup
1135 // instruction and checking the alignment value.
1136 def AddrMode6dupAlign16AsmOperand : AsmOperandClass {
1137 let Name = "DupAlignedMemory16";
1138 let DiagnosticType = "DupAlignedMemoryRequires16";
1140 def addrmode6dupalign16 : AddrMode6DupAlign {
1141 // The alignment specifier can only be 16 or omitted.
1142 let ParserMatchClass = AddrMode6dupAlign16AsmOperand;
1145 // Special version of addrmode6 to handle 32-bit alignment encoding for VLD-dup
1146 // instruction and checking the alignment value.
1147 def AddrMode6dupAlign32AsmOperand : AsmOperandClass {
1148 let Name = "DupAlignedMemory32";
1149 let DiagnosticType = "DupAlignedMemoryRequires32";
1151 def addrmode6dupalign32 : AddrMode6DupAlign {
1152 // The alignment specifier can only be 32 or omitted.
1153 let ParserMatchClass = AddrMode6dupAlign32AsmOperand;
1156 // Special version of addrmode6 to handle 64-bit alignment encoding for VLD
1157 // instructions and checking the alignment value.
1158 def AddrMode6dupAlign64AsmOperand : AsmOperandClass {
1159 let Name = "DupAlignedMemory64";
1160 let DiagnosticType = "DupAlignedMemoryRequires64";
1162 def addrmode6dupalign64 : AddrMode6DupAlign {
1163 // The alignment specifier can only be 64 or omitted.
1164 let ParserMatchClass = AddrMode6dupAlign64AsmOperand;
1167 // Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding
1168 // for VLD instructions and checking the alignment value.
1169 def AddrMode6dupAlign64or128AsmOperand : AsmOperandClass {
1170 let Name = "DupAlignedMemory64or128";
1171 let DiagnosticType = "DupAlignedMemoryRequires64or128";
1173 def addrmode6dupalign64or128 : AddrMode6DupAlign {
1174 // The alignment specifier can only be 64, 128 or omitted.
1175 let ParserMatchClass = AddrMode6dupAlign64or128AsmOperand;
1178 // addrmodepc := pc + reg
1180 def addrmodepc : Operand<i32>,
1181 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
1182 let PrintMethod = "printAddrModePCOperand";
1183 let MIOperandInfo = (ops GPR, i32imm);
1186 // addr_offset_none := reg
1188 def MemNoOffsetAsmOperand : AsmOperandClass { let Name = "MemNoOffset"; }
1189 def addr_offset_none : Operand<i32>,
1190 ComplexPattern<i32, 1, "SelectAddrOffsetNone", []> {
1191 let PrintMethod = "printAddrMode7Operand";
1192 let DecoderMethod = "DecodeAddrMode7Operand";
1193 let ParserMatchClass = MemNoOffsetAsmOperand;
1194 let MIOperandInfo = (ops GPR:$base);
1197 def nohash_imm : Operand<i32> {
1198 let PrintMethod = "printNoHashImmediate";
1201 def CoprocNumAsmOperand : AsmOperandClass {
1202 let Name = "CoprocNum";
1203 let ParserMethod = "parseCoprocNumOperand";
1205 def p_imm : Operand<i32> {
1206 let PrintMethod = "printPImmediate";
1207 let ParserMatchClass = CoprocNumAsmOperand;
1208 let DecoderMethod = "DecodeCoprocessor";
1211 def CoprocRegAsmOperand : AsmOperandClass {
1212 let Name = "CoprocReg";
1213 let ParserMethod = "parseCoprocRegOperand";
1215 def c_imm : Operand<i32> {
1216 let PrintMethod = "printCImmediate";
1217 let ParserMatchClass = CoprocRegAsmOperand;
1219 def CoprocOptionAsmOperand : AsmOperandClass {
1220 let Name = "CoprocOption";
1221 let ParserMethod = "parseCoprocOptionOperand";
1223 def coproc_option_imm : Operand<i32> {
1224 let PrintMethod = "printCoprocOptionImm";
1225 let ParserMatchClass = CoprocOptionAsmOperand;
1228 //===----------------------------------------------------------------------===//
1230 include "ARMInstrFormats.td"
1232 //===----------------------------------------------------------------------===//
1233 // Multiclass helpers...
1236 /// AsI1_bin_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns for a
1237 /// binop that produces a value.
1238 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1239 multiclass AsI1_bin_irs<bits<4> opcod, string opc,
1240 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1241 PatFrag opnode, bit Commutable = 0> {
1242 // The register-immediate version is re-materializable. This is useful
1243 // in particular for taking the address of a local.
1244 let isReMaterializable = 1 in {
1245 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm,
1246 iii, opc, "\t$Rd, $Rn, $imm",
1247 [(set GPR:$Rd, (opnode GPR:$Rn, mod_imm:$imm))]>,
1248 Sched<[WriteALU, ReadALU]> {
1253 let Inst{19-16} = Rn;
1254 let Inst{15-12} = Rd;
1255 let Inst{11-0} = imm;
1258 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1259 iir, opc, "\t$Rd, $Rn, $Rm",
1260 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]>,
1261 Sched<[WriteALU, ReadALU, ReadALU]> {
1266 let isCommutable = Commutable;
1267 let Inst{19-16} = Rn;
1268 let Inst{15-12} = Rd;
1269 let Inst{11-4} = 0b00000000;
1273 def rsi : AsI1<opcod, (outs GPR:$Rd),
1274 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1275 iis, opc, "\t$Rd, $Rn, $shift",
1276 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_imm:$shift))]>,
1277 Sched<[WriteALUsi, ReadALU]> {
1282 let Inst{19-16} = Rn;
1283 let Inst{15-12} = Rd;
1284 let Inst{11-5} = shift{11-5};
1286 let Inst{3-0} = shift{3-0};
1289 def rsr : AsI1<opcod, (outs GPR:$Rd),
1290 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1291 iis, opc, "\t$Rd, $Rn, $shift",
1292 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_reg:$shift))]>,
1293 Sched<[WriteALUsr, ReadALUsr]> {
1298 let Inst{19-16} = Rn;
1299 let Inst{15-12} = Rd;
1300 let Inst{11-8} = shift{11-8};
1302 let Inst{6-5} = shift{6-5};
1304 let Inst{3-0} = shift{3-0};
1308 /// AsI1_rbin_irs - Same as AsI1_bin_irs except the order of operands are
1309 /// reversed. The 'rr' form is only defined for the disassembler; for codegen
1310 /// it is equivalent to the AsI1_bin_irs counterpart.
1311 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1312 multiclass AsI1_rbin_irs<bits<4> opcod, string opc,
1313 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1314 PatFrag opnode, bit Commutable = 0> {
1315 // The register-immediate version is re-materializable. This is useful
1316 // in particular for taking the address of a local.
1317 let isReMaterializable = 1 in {
1318 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm,
1319 iii, opc, "\t$Rd, $Rn, $imm",
1320 [(set GPR:$Rd, (opnode mod_imm:$imm, GPR:$Rn))]>,
1321 Sched<[WriteALU, ReadALU]> {
1326 let Inst{19-16} = Rn;
1327 let Inst{15-12} = Rd;
1328 let Inst{11-0} = imm;
1331 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1332 iir, opc, "\t$Rd, $Rn, $Rm",
1333 [/* pattern left blank */]>,
1334 Sched<[WriteALU, ReadALU, ReadALU]> {
1338 let Inst{11-4} = 0b00000000;
1341 let Inst{15-12} = Rd;
1342 let Inst{19-16} = Rn;
1345 def rsi : AsI1<opcod, (outs GPR:$Rd),
1346 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1347 iis, opc, "\t$Rd, $Rn, $shift",
1348 [(set GPR:$Rd, (opnode so_reg_imm:$shift, GPR:$Rn))]>,
1349 Sched<[WriteALUsi, ReadALU]> {
1354 let Inst{19-16} = Rn;
1355 let Inst{15-12} = Rd;
1356 let Inst{11-5} = shift{11-5};
1358 let Inst{3-0} = shift{3-0};
1361 def rsr : AsI1<opcod, (outs GPR:$Rd),
1362 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1363 iis, opc, "\t$Rd, $Rn, $shift",
1364 [(set GPR:$Rd, (opnode so_reg_reg:$shift, GPR:$Rn))]>,
1365 Sched<[WriteALUsr, ReadALUsr]> {
1370 let Inst{19-16} = Rn;
1371 let Inst{15-12} = Rd;
1372 let Inst{11-8} = shift{11-8};
1374 let Inst{6-5} = shift{6-5};
1376 let Inst{3-0} = shift{3-0};
1380 /// AsI1_bin_s_irs - Same as AsI1_bin_irs except it sets the 's' bit by default.
1382 /// These opcodes will be converted to the real non-S opcodes by
1383 /// AdjustInstrPostInstrSelection after giving them an optional CPSR operand.
1384 let hasPostISelHook = 1, Defs = [CPSR] in {
1385 multiclass AsI1_bin_s_irs<InstrItinClass iii, InstrItinClass iir,
1386 InstrItinClass iis, PatFrag opnode,
1387 bit Commutable = 0> {
1388 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p),
1390 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm))]>,
1391 Sched<[WriteALU, ReadALU]>;
1393 def rr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, pred:$p),
1395 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm))]>,
1396 Sched<[WriteALU, ReadALU, ReadALU]> {
1397 let isCommutable = Commutable;
1399 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1400 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1402 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1403 so_reg_imm:$shift))]>,
1404 Sched<[WriteALUsi, ReadALU]>;
1406 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1407 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1409 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1410 so_reg_reg:$shift))]>,
1411 Sched<[WriteALUSsr, ReadALUsr]>;
1415 /// AsI1_rbin_s_is - Same as AsI1_bin_s_irs, except selection DAG
1416 /// operands are reversed.
1417 let hasPostISelHook = 1, Defs = [CPSR] in {
1418 multiclass AsI1_rbin_s_is<InstrItinClass iii, InstrItinClass iir,
1419 InstrItinClass iis, PatFrag opnode,
1420 bit Commutable = 0> {
1421 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p),
1423 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn))]>,
1424 Sched<[WriteALU, ReadALU]>;
1426 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1427 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1429 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift,
1431 Sched<[WriteALUsi, ReadALU]>;
1433 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1434 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1436 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift,
1438 Sched<[WriteALUSsr, ReadALUsr]>;
1442 /// AI1_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
1443 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
1444 /// a explicit result, only implicitly set CPSR.
1445 let isCompare = 1, Defs = [CPSR] in {
1446 multiclass AI1_cmp_irs<bits<4> opcod, string opc,
1447 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1448 PatFrag opnode, bit Commutable = 0> {
1449 def ri : AI1<opcod, (outs), (ins GPR:$Rn, mod_imm:$imm), DPFrm, iii,
1451 [(opnode GPR:$Rn, mod_imm:$imm)]>,
1452 Sched<[WriteCMP, ReadALU]> {
1457 let Inst{19-16} = Rn;
1458 let Inst{15-12} = 0b0000;
1459 let Inst{11-0} = imm;
1461 let Unpredictable{15-12} = 0b1111;
1463 def rr : AI1<opcod, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, iir,
1465 [(opnode GPR:$Rn, GPR:$Rm)]>,
1466 Sched<[WriteCMP, ReadALU, ReadALU]> {
1469 let isCommutable = Commutable;
1472 let Inst{19-16} = Rn;
1473 let Inst{15-12} = 0b0000;
1474 let Inst{11-4} = 0b00000000;
1477 let Unpredictable{15-12} = 0b1111;
1479 def rsi : AI1<opcod, (outs),
1480 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, iis,
1481 opc, "\t$Rn, $shift",
1482 [(opnode GPR:$Rn, so_reg_imm:$shift)]>,
1483 Sched<[WriteCMPsi, ReadALU]> {
1488 let Inst{19-16} = Rn;
1489 let Inst{15-12} = 0b0000;
1490 let Inst{11-5} = shift{11-5};
1492 let Inst{3-0} = shift{3-0};
1494 let Unpredictable{15-12} = 0b1111;
1496 def rsr : AI1<opcod, (outs),
1497 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, iis,
1498 opc, "\t$Rn, $shift",
1499 [(opnode GPRnopc:$Rn, so_reg_reg:$shift)]>,
1500 Sched<[WriteCMPsr, ReadALU]> {
1505 let Inst{19-16} = Rn;
1506 let Inst{15-12} = 0b0000;
1507 let Inst{11-8} = shift{11-8};
1509 let Inst{6-5} = shift{6-5};
1511 let Inst{3-0} = shift{3-0};
1513 let Unpredictable{15-12} = 0b1111;
1519 /// AI_ext_rrot - A unary operation with two forms: one whose operand is a
1520 /// register and one whose operand is a register rotated by 8/16/24.
1521 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
1522 class AI_ext_rrot<bits<8> opcod, string opc, PatFrag opnode>
1523 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1524 IIC_iEXTr, opc, "\t$Rd, $Rm$rot",
1525 [(set GPRnopc:$Rd, (opnode (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1526 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> {
1530 let Inst{19-16} = 0b1111;
1531 let Inst{15-12} = Rd;
1532 let Inst{11-10} = rot;
1536 class AI_ext_rrot_np<bits<8> opcod, string opc>
1537 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1538 IIC_iEXTr, opc, "\t$Rd, $Rm$rot", []>,
1539 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> {
1541 let Inst{19-16} = 0b1111;
1542 let Inst{11-10} = rot;
1545 /// AI_exta_rrot - A binary operation with two forms: one whose operand is a
1546 /// register and one whose operand is a register rotated by 8/16/24.
1547 class AI_exta_rrot<bits<8> opcod, string opc, PatFrag opnode>
1548 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1549 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot",
1550 [(set GPRnopc:$Rd, (opnode GPR:$Rn,
1551 (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1552 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> {
1557 let Inst{19-16} = Rn;
1558 let Inst{15-12} = Rd;
1559 let Inst{11-10} = rot;
1560 let Inst{9-4} = 0b000111;
1564 class AI_exta_rrot_np<bits<8> opcod, string opc>
1565 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1566 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot", []>,
1567 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> {
1570 let Inst{19-16} = Rn;
1571 let Inst{11-10} = rot;
1574 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
1575 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1576 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
1577 bit Commutable = 0> {
1578 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1579 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm),
1580 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1581 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm, CPSR))]>,
1583 Sched<[WriteALU, ReadALU]> {
1588 let Inst{15-12} = Rd;
1589 let Inst{19-16} = Rn;
1590 let Inst{11-0} = imm;
1592 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1593 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1594 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm, CPSR))]>,
1596 Sched<[WriteALU, ReadALU, ReadALU]> {
1600 let Inst{11-4} = 0b00000000;
1602 let isCommutable = Commutable;
1604 let Inst{15-12} = Rd;
1605 let Inst{19-16} = Rn;
1607 def rsi : AsI1<opcod, (outs GPR:$Rd),
1608 (ins GPR:$Rn, so_reg_imm:$shift),
1609 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1610 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_imm:$shift, CPSR))]>,
1612 Sched<[WriteALUsi, ReadALU]> {
1617 let Inst{19-16} = Rn;
1618 let Inst{15-12} = Rd;
1619 let Inst{11-5} = shift{11-5};
1621 let Inst{3-0} = shift{3-0};
1623 def rsr : AsI1<opcod, (outs GPRnopc:$Rd),
1624 (ins GPRnopc:$Rn, so_reg_reg:$shift),
1625 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1626 [(set GPRnopc:$Rd, CPSR,
1627 (opnode GPRnopc:$Rn, so_reg_reg:$shift, CPSR))]>,
1629 Sched<[WriteALUsr, ReadALUsr]> {
1634 let Inst{19-16} = Rn;
1635 let Inst{15-12} = Rd;
1636 let Inst{11-8} = shift{11-8};
1638 let Inst{6-5} = shift{6-5};
1640 let Inst{3-0} = shift{3-0};
1645 /// AI1_rsc_irs - Define instructions and patterns for rsc
1646 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1647 multiclass AI1_rsc_irs<bits<4> opcod, string opc, PatFrag opnode> {
1648 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1649 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm),
1650 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1651 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn, CPSR))]>,
1653 Sched<[WriteALU, ReadALU]> {
1658 let Inst{15-12} = Rd;
1659 let Inst{19-16} = Rn;
1660 let Inst{11-0} = imm;
1662 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1663 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1664 [/* pattern left blank */]>,
1665 Sched<[WriteALU, ReadALU, ReadALU]> {
1669 let Inst{11-4} = 0b00000000;
1672 let Inst{15-12} = Rd;
1673 let Inst{19-16} = Rn;
1675 def rsi : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_imm:$shift),
1676 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1677 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift, GPR:$Rn, CPSR))]>,
1679 Sched<[WriteALUsi, ReadALU]> {
1684 let Inst{19-16} = Rn;
1685 let Inst{15-12} = Rd;
1686 let Inst{11-5} = shift{11-5};
1688 let Inst{3-0} = shift{3-0};
1690 def rsr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_reg:$shift),
1691 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1692 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift, GPR:$Rn, CPSR))]>,
1694 Sched<[WriteALUsr, ReadALUsr]> {
1699 let Inst{19-16} = Rn;
1700 let Inst{15-12} = Rd;
1701 let Inst{11-8} = shift{11-8};
1703 let Inst{6-5} = shift{6-5};
1705 let Inst{3-0} = shift{3-0};
1710 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1711 multiclass AI_ldr1<bit isByte, string opc, InstrItinClass iii,
1712 InstrItinClass iir, PatFrag opnode> {
1713 // Note: We use the complex addrmode_imm12 rather than just an input
1714 // GPR and a constrained immediate so that we can use this to match
1715 // frame index references and avoid matching constant pool references.
1716 def i12: AI2ldst<0b010, 1, isByte, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
1717 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1718 [(set GPR:$Rt, (opnode addrmode_imm12:$addr))]> {
1721 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1722 let Inst{19-16} = addr{16-13}; // Rn
1723 let Inst{15-12} = Rt;
1724 let Inst{11-0} = addr{11-0}; // imm12
1726 def rs : AI2ldst<0b011, 1, isByte, (outs GPR:$Rt), (ins ldst_so_reg:$shift),
1727 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1728 [(set GPR:$Rt, (opnode ldst_so_reg:$shift))]> {
1731 let shift{4} = 0; // Inst{4} = 0
1732 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1733 let Inst{19-16} = shift{16-13}; // Rn
1734 let Inst{15-12} = Rt;
1735 let Inst{11-0} = shift{11-0};
1740 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1741 multiclass AI_ldr1nopc<bit isByte, string opc, InstrItinClass iii,
1742 InstrItinClass iir, PatFrag opnode> {
1743 // Note: We use the complex addrmode_imm12 rather than just an input
1744 // GPR and a constrained immediate so that we can use this to match
1745 // frame index references and avoid matching constant pool references.
1746 def i12: AI2ldst<0b010, 1, isByte, (outs GPRnopc:$Rt),
1747 (ins addrmode_imm12:$addr),
1748 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1749 [(set GPRnopc:$Rt, (opnode addrmode_imm12:$addr))]> {
1752 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1753 let Inst{19-16} = addr{16-13}; // Rn
1754 let Inst{15-12} = Rt;
1755 let Inst{11-0} = addr{11-0}; // imm12
1757 def rs : AI2ldst<0b011, 1, isByte, (outs GPRnopc:$Rt),
1758 (ins ldst_so_reg:$shift),
1759 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1760 [(set GPRnopc:$Rt, (opnode ldst_so_reg:$shift))]> {
1763 let shift{4} = 0; // Inst{4} = 0
1764 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1765 let Inst{19-16} = shift{16-13}; // Rn
1766 let Inst{15-12} = Rt;
1767 let Inst{11-0} = shift{11-0};
1773 multiclass AI_str1<bit isByte, string opc, InstrItinClass iii,
1774 InstrItinClass iir, PatFrag opnode> {
1775 // Note: We use the complex addrmode_imm12 rather than just an input
1776 // GPR and a constrained immediate so that we can use this to match
1777 // frame index references and avoid matching constant pool references.
1778 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1779 (ins GPR:$Rt, addrmode_imm12:$addr),
1780 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1781 [(opnode GPR:$Rt, addrmode_imm12:$addr)]> {
1784 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1785 let Inst{19-16} = addr{16-13}; // Rn
1786 let Inst{15-12} = Rt;
1787 let Inst{11-0} = addr{11-0}; // imm12
1789 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPR:$Rt, ldst_so_reg:$shift),
1790 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1791 [(opnode GPR:$Rt, ldst_so_reg:$shift)]> {
1794 let shift{4} = 0; // Inst{4} = 0
1795 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1796 let Inst{19-16} = shift{16-13}; // Rn
1797 let Inst{15-12} = Rt;
1798 let Inst{11-0} = shift{11-0};
1802 multiclass AI_str1nopc<bit isByte, string opc, InstrItinClass iii,
1803 InstrItinClass iir, PatFrag opnode> {
1804 // Note: We use the complex addrmode_imm12 rather than just an input
1805 // GPR and a constrained immediate so that we can use this to match
1806 // frame index references and avoid matching constant pool references.
1807 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1808 (ins GPRnopc:$Rt, addrmode_imm12:$addr),
1809 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1810 [(opnode GPRnopc:$Rt, addrmode_imm12:$addr)]> {
1813 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1814 let Inst{19-16} = addr{16-13}; // Rn
1815 let Inst{15-12} = Rt;
1816 let Inst{11-0} = addr{11-0}; // imm12
1818 def rs : AI2ldst<0b011, 0, isByte, (outs),
1819 (ins GPRnopc:$Rt, ldst_so_reg:$shift),
1820 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1821 [(opnode GPRnopc:$Rt, ldst_so_reg:$shift)]> {
1824 let shift{4} = 0; // Inst{4} = 0
1825 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1826 let Inst{19-16} = shift{16-13}; // Rn
1827 let Inst{15-12} = Rt;
1828 let Inst{11-0} = shift{11-0};
1833 //===----------------------------------------------------------------------===//
1835 //===----------------------------------------------------------------------===//
1837 //===----------------------------------------------------------------------===//
1838 // Miscellaneous Instructions.
1841 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
1842 /// the function. The first operand is the ID# for this instruction, the second
1843 /// is the index into the MachineConstantPool that this is, the third is the
1844 /// size in bytes of this constant pool entry.
1845 let hasSideEffects = 0, isNotDuplicable = 1 in
1846 def CONSTPOOL_ENTRY :
1847 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1848 i32imm:$size), NoItinerary, []>;
1850 // FIXME: Marking these as hasSideEffects is necessary to prevent machine DCE
1851 // from removing one half of the matched pairs. That breaks PEI, which assumes
1852 // these will always be in pairs, and asserts if it finds otherwise. Better way?
1853 let Defs = [SP], Uses = [SP], hasSideEffects = 1 in {
1854 def ADJCALLSTACKUP :
1855 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary,
1856 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
1858 def ADJCALLSTACKDOWN :
1859 PseudoInst<(outs), (ins i32imm:$amt, pred:$p), NoItinerary,
1860 [(ARMcallseq_start timm:$amt)]>;
1863 def HINT : AI<(outs), (ins imm0_239:$imm), MiscFrm, NoItinerary,
1864 "hint", "\t$imm", [(int_arm_hint imm0_239:$imm)]>,
1865 Requires<[IsARM, HasV6]> {
1867 let Inst{27-8} = 0b00110010000011110000;
1868 let Inst{7-0} = imm;
1871 def : InstAlias<"nop$p", (HINT 0, pred:$p)>, Requires<[IsARM, HasV6T2]>;
1872 def : InstAlias<"yield$p", (HINT 1, pred:$p)>, Requires<[IsARM, HasV6T2]>;
1873 def : InstAlias<"wfe$p", (HINT 2, pred:$p)>, Requires<[IsARM, HasV6T2]>;
1874 def : InstAlias<"wfi$p", (HINT 3, pred:$p)>, Requires<[IsARM, HasV6T2]>;
1875 def : InstAlias<"sev$p", (HINT 4, pred:$p)>, Requires<[IsARM, HasV6T2]>;
1876 def : InstAlias<"sevl$p", (HINT 5, pred:$p)>, Requires<[IsARM, HasV8]>;
1878 def SEL : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, NoItinerary, "sel",
1879 "\t$Rd, $Rn, $Rm", []>, Requires<[IsARM, HasV6]> {
1884 let Inst{15-12} = Rd;
1885 let Inst{19-16} = Rn;
1886 let Inst{27-20} = 0b01101000;
1887 let Inst{7-4} = 0b1011;
1888 let Inst{11-8} = 0b1111;
1889 let Unpredictable{11-8} = 0b1111;
1892 // The 16-bit operand $val can be used by a debugger to store more information
1893 // about the breakpoint.
1894 def BKPT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
1895 "bkpt", "\t$val", []>, Requires<[IsARM]> {
1897 let Inst{3-0} = val{3-0};
1898 let Inst{19-8} = val{15-4};
1899 let Inst{27-20} = 0b00010010;
1900 let Inst{31-28} = 0xe; // AL
1901 let Inst{7-4} = 0b0111;
1903 // default immediate for breakpoint mnemonic
1904 def : InstAlias<"bkpt", (BKPT 0)>, Requires<[IsARM]>;
1906 def HLT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
1907 "hlt", "\t$val", []>, Requires<[IsARM, HasV8]> {
1909 let Inst{3-0} = val{3-0};
1910 let Inst{19-8} = val{15-4};
1911 let Inst{27-20} = 0b00010000;
1912 let Inst{31-28} = 0xe; // AL
1913 let Inst{7-4} = 0b0111;
1916 // Change Processor State
1917 // FIXME: We should use InstAlias to handle the optional operands.
1918 class CPS<dag iops, string asm_ops>
1919 : AXI<(outs), iops, MiscFrm, NoItinerary, !strconcat("cps", asm_ops),
1920 []>, Requires<[IsARM]> {
1926 let Inst{31-28} = 0b1111;
1927 let Inst{27-20} = 0b00010000;
1928 let Inst{19-18} = imod;
1929 let Inst{17} = M; // Enabled if mode is set;
1930 let Inst{16-9} = 0b00000000;
1931 let Inst{8-6} = iflags;
1933 let Inst{4-0} = mode;
1936 let DecoderMethod = "DecodeCPSInstruction" in {
1938 def CPS3p : CPS<(ins imod_op:$imod, iflags_op:$iflags, imm0_31:$mode),
1939 "$imod\t$iflags, $mode">;
1940 let mode = 0, M = 0 in
1941 def CPS2p : CPS<(ins imod_op:$imod, iflags_op:$iflags), "$imod\t$iflags">;
1943 let imod = 0, iflags = 0, M = 1 in
1944 def CPS1p : CPS<(ins imm0_31:$mode), "\t$mode">;
1947 // Preload signals the memory system of possible future data/instruction access.
1948 multiclass APreLoad<bits<1> read, bits<1> data, string opc> {
1950 def i12 : AXIM<(outs), (ins addrmode_imm12:$addr), AddrMode_i12, MiscFrm,
1951 IIC_Preload, !strconcat(opc, "\t$addr"),
1952 [(ARMPreload addrmode_imm12:$addr, (i32 read), (i32 data))]>,
1953 Sched<[WritePreLd]> {
1956 let Inst{31-26} = 0b111101;
1957 let Inst{25} = 0; // 0 for immediate form
1958 let Inst{24} = data;
1959 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1960 let Inst{22} = read;
1961 let Inst{21-20} = 0b01;
1962 let Inst{19-16} = addr{16-13}; // Rn
1963 let Inst{15-12} = 0b1111;
1964 let Inst{11-0} = addr{11-0}; // imm12
1967 def rs : AXI<(outs), (ins ldst_so_reg:$shift), MiscFrm, IIC_Preload,
1968 !strconcat(opc, "\t$shift"),
1969 [(ARMPreload ldst_so_reg:$shift, (i32 read), (i32 data))]>,
1970 Sched<[WritePreLd]> {
1972 let Inst{31-26} = 0b111101;
1973 let Inst{25} = 1; // 1 for register form
1974 let Inst{24} = data;
1975 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1976 let Inst{22} = read;
1977 let Inst{21-20} = 0b01;
1978 let Inst{19-16} = shift{16-13}; // Rn
1979 let Inst{15-12} = 0b1111;
1980 let Inst{11-0} = shift{11-0};
1985 defm PLD : APreLoad<1, 1, "pld">, Requires<[IsARM]>;
1986 defm PLDW : APreLoad<0, 1, "pldw">, Requires<[IsARM,HasV7,HasMP]>;
1987 defm PLI : APreLoad<1, 0, "pli">, Requires<[IsARM,HasV7]>;
1989 def SETEND : AXI<(outs), (ins setend_op:$end), MiscFrm, NoItinerary,
1990 "setend\t$end", []>, Requires<[IsARM]>, Deprecated<HasV8Ops> {
1992 let Inst{31-10} = 0b1111000100000001000000;
1997 def DBG : AI<(outs), (ins imm0_15:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt",
1998 [(int_arm_dbg imm0_15:$opt)]>, Requires<[IsARM, HasV7]> {
2000 let Inst{27-4} = 0b001100100000111100001111;
2001 let Inst{3-0} = opt;
2004 // A8.8.247 UDF - Undefined (Encoding A1)
2005 def UDF : AInoP<(outs), (ins imm0_65535:$imm16), MiscFrm, NoItinerary,
2006 "udf", "\t$imm16", [(int_arm_undefined imm0_65535:$imm16)]> {
2008 let Inst{31-28} = 0b1110; // AL
2009 let Inst{27-25} = 0b011;
2010 let Inst{24-20} = 0b11111;
2011 let Inst{19-8} = imm16{15-4};
2012 let Inst{7-4} = 0b1111;
2013 let Inst{3-0} = imm16{3-0};
2017 * A5.4 Permanently UNDEFINED instructions.
2019 * For most targets use UDF #65006, for which the OS will generate SIGTRAP.
2020 * Other UDF encodings generate SIGILL.
2022 * NaCl's OS instead chooses an ARM UDF encoding that's also a UDF in Thumb.
2024 * 1110 0111 1111 iiii iiii iiii 1111 iiii
2026 * 1101 1110 iiii iiii
2027 * It uses the following encoding:
2028 * 1110 0111 1111 1110 1101 1110 1111 0000
2029 * - In ARM: UDF #60896;
2030 * - In Thumb: UDF #254 followed by a branch-to-self.
2032 let isBarrier = 1, isTerminator = 1 in
2033 def TRAPNaCl : AXI<(outs), (ins), MiscFrm, NoItinerary,
2035 Requires<[IsARM,UseNaClTrap]> {
2036 let Inst = 0xe7fedef0;
2038 let isBarrier = 1, isTerminator = 1 in
2039 def TRAP : AXI<(outs), (ins), MiscFrm, NoItinerary,
2041 Requires<[IsARM,DontUseNaClTrap]> {
2042 let Inst = 0xe7ffdefe;
2045 // Address computation and loads and stores in PIC mode.
2046 let isNotDuplicable = 1 in {
2047 def PICADD : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
2049 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>,
2050 Sched<[WriteALU, ReadALU]>;
2052 let AddedComplexity = 10 in {
2053 def PICLDR : ARMPseudoInst<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
2055 [(set GPR:$dst, (load addrmodepc:$addr))]>;
2057 def PICLDRH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2059 [(set GPR:$Rt, (zextloadi16 addrmodepc:$addr))]>;
2061 def PICLDRB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2063 [(set GPR:$Rt, (zextloadi8 addrmodepc:$addr))]>;
2065 def PICLDRSH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2067 [(set GPR:$Rt, (sextloadi16 addrmodepc:$addr))]>;
2069 def PICLDRSB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2071 [(set GPR:$Rt, (sextloadi8 addrmodepc:$addr))]>;
2073 let AddedComplexity = 10 in {
2074 def PICSTR : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2075 4, IIC_iStore_r, [(store GPR:$src, addrmodepc:$addr)]>;
2077 def PICSTRH : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2078 4, IIC_iStore_bh_r, [(truncstorei16 GPR:$src,
2079 addrmodepc:$addr)]>;
2081 def PICSTRB : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2082 4, IIC_iStore_bh_r, [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
2084 } // isNotDuplicable = 1
2087 // LEApcrel - Load a pc-relative address into a register without offending the
2089 let hasSideEffects = 0, isReMaterializable = 1 in
2090 // The 'adr' mnemonic encodes differently if the label is before or after
2091 // the instruction. The {24-21} opcode bits are set by the fixup, as we don't
2092 // know until then which form of the instruction will be used.
2093 def ADR : AI1<{0,?,?,0}, (outs GPR:$Rd), (ins adrlabel:$label),
2094 MiscFrm, IIC_iALUi, "adr", "\t$Rd, $label", []>,
2095 Sched<[WriteALU, ReadALU]> {
2098 let Inst{27-25} = 0b001;
2100 let Inst{23-22} = label{13-12};
2103 let Inst{19-16} = 0b1111;
2104 let Inst{15-12} = Rd;
2105 let Inst{11-0} = label{11-0};
2108 let hasSideEffects = 1 in {
2109 def LEApcrel : ARMPseudoInst<(outs GPR:$Rd), (ins i32imm:$label, pred:$p),
2110 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
2112 def LEApcrelJT : ARMPseudoInst<(outs GPR:$Rd),
2113 (ins i32imm:$label, nohash_imm:$id, pred:$p),
2114 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
2117 //===----------------------------------------------------------------------===//
2118 // Control Flow Instructions.
2121 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
2123 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
2124 "bx", "\tlr", [(ARMretflag)]>,
2125 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2126 let Inst{27-0} = 0b0001001011111111111100011110;
2130 def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br,
2131 "mov", "\tpc, lr", [(ARMretflag)]>,
2132 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]> {
2133 let Inst{27-0} = 0b0001101000001111000000001110;
2136 // Exception return: N.b. doesn't set CPSR as far as we're concerned (it sets
2137 // the user-space one).
2138 def SUBS_PC_LR : ARMPseudoInst<(outs), (ins i32imm:$offset, pred:$p),
2140 [(ARMintretflag imm:$offset)]>;
2143 // Indirect branches
2144 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
2146 def BX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
2147 [(brind GPR:$dst)]>,
2148 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2150 let Inst{31-4} = 0b1110000100101111111111110001;
2151 let Inst{3-0} = dst;
2154 def BX_pred : AI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br,
2155 "bx", "\t$dst", [/* pattern left blank */]>,
2156 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2158 let Inst{27-4} = 0b000100101111111111110001;
2159 let Inst{3-0} = dst;
2163 // SP is marked as a use to prevent stack-pointer assignments that appear
2164 // immediately before calls from potentially appearing dead.
2166 // FIXME: Do we really need a non-predicated version? If so, it should
2167 // at least be a pseudo instruction expanding to the predicated version
2168 // at MC lowering time.
2169 Defs = [LR], Uses = [SP] in {
2170 def BL : ABXI<0b1011, (outs), (ins bl_target:$func),
2171 IIC_Br, "bl\t$func",
2172 [(ARMcall tglobaladdr:$func)]>,
2173 Requires<[IsARM]>, Sched<[WriteBrL]> {
2174 let Inst{31-28} = 0b1110;
2176 let Inst{23-0} = func;
2177 let DecoderMethod = "DecodeBranchImmInstruction";
2180 def BL_pred : ABI<0b1011, (outs), (ins bl_target:$func),
2181 IIC_Br, "bl", "\t$func",
2182 [(ARMcall_pred tglobaladdr:$func)]>,
2183 Requires<[IsARM]>, Sched<[WriteBrL]> {
2185 let Inst{23-0} = func;
2186 let DecoderMethod = "DecodeBranchImmInstruction";
2190 def BLX : AXI<(outs), (ins GPR:$func), BrMiscFrm,
2191 IIC_Br, "blx\t$func",
2192 [(ARMcall GPR:$func)]>,
2193 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2195 let Inst{31-4} = 0b1110000100101111111111110011;
2196 let Inst{3-0} = func;
2199 def BLX_pred : AI<(outs), (ins GPR:$func), BrMiscFrm,
2200 IIC_Br, "blx", "\t$func",
2201 [(ARMcall_pred GPR:$func)]>,
2202 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2204 let Inst{27-4} = 0b000100101111111111110011;
2205 let Inst{3-0} = func;
2209 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
2210 def BX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
2211 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
2212 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]>;
2215 def BMOVPCRX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
2216 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
2217 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
2219 // mov lr, pc; b if callee is marked noreturn to avoid confusing the
2220 // return stack predictor.
2221 def BMOVPCB_CALL : ARMPseudoInst<(outs), (ins bl_target:$func),
2222 8, IIC_Br, [(ARMcall_nolink tglobaladdr:$func)]>,
2223 Requires<[IsARM]>, Sched<[WriteBr]>;
2226 let isBranch = 1, isTerminator = 1 in {
2227 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
2228 // a two-value operand where a dag node expects two operands. :(
2229 def Bcc : ABI<0b1010, (outs), (ins br_target:$target),
2230 IIC_Br, "b", "\t$target",
2231 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>,
2234 let Inst{23-0} = target;
2235 let DecoderMethod = "DecodeBranchImmInstruction";
2238 let isBarrier = 1 in {
2239 // B is "predicable" since it's just a Bcc with an 'always' condition.
2240 let isPredicable = 1 in
2241 // FIXME: We shouldn't need this pseudo at all. Just using Bcc directly
2242 // should be sufficient.
2243 // FIXME: Is B really a Barrier? That doesn't seem right.
2244 def B : ARMPseudoExpand<(outs), (ins br_target:$target), 4, IIC_Br,
2245 [(br bb:$target)], (Bcc br_target:$target, (ops 14, zero_reg))>,
2248 let isNotDuplicable = 1, isIndirectBranch = 1 in {
2249 def BR_JTr : ARMPseudoInst<(outs),
2250 (ins GPR:$target, i32imm:$jt, i32imm:$id),
2252 [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]>,
2254 // FIXME: This shouldn't use the generic "addrmode2," but rather be split
2255 // into i12 and rs suffixed versions.
2256 def BR_JTm : ARMPseudoInst<(outs),
2257 (ins addrmode2:$target, i32imm:$jt, i32imm:$id),
2259 [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
2260 imm:$id)]>, Sched<[WriteBrTbl]>;
2261 def BR_JTadd : ARMPseudoInst<(outs),
2262 (ins GPR:$target, GPR:$idx, i32imm:$jt, i32imm:$id),
2264 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
2265 imm:$id)]>, Sched<[WriteBrTbl]>;
2266 } // isNotDuplicable = 1, isIndirectBranch = 1
2272 def BLXi : AXI<(outs), (ins blx_target:$target), BrMiscFrm, NoItinerary,
2273 "blx\t$target", []>,
2274 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2275 let Inst{31-25} = 0b1111101;
2277 let Inst{23-0} = target{24-1};
2278 let Inst{24} = target{0};
2281 // Branch and Exchange Jazelle
2282 def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func",
2283 [/* pattern left blank */]>, Sched<[WriteBr]> {
2285 let Inst{23-20} = 0b0010;
2286 let Inst{19-8} = 0xfff;
2287 let Inst{7-4} = 0b0010;
2288 let Inst{3-0} = func;
2293 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in {
2294 def TCRETURNdi : PseudoInst<(outs), (ins i32imm:$dst), IIC_Br, []>,
2297 def TCRETURNri : PseudoInst<(outs), (ins tcGPR:$dst), IIC_Br, []>,
2300 def TAILJMPd : ARMPseudoExpand<(outs), (ins br_target:$dst),
2302 (Bcc br_target:$dst, (ops 14, zero_reg))>,
2303 Requires<[IsARM]>, Sched<[WriteBr]>;
2305 def TAILJMPr : ARMPseudoExpand<(outs), (ins tcGPR:$dst),
2307 (BX GPR:$dst)>, Sched<[WriteBr]>,
2311 // Secure Monitor Call is a system instruction.
2312 def SMC : ABI<0b0001, (outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt",
2313 []>, Requires<[IsARM, HasTrustZone]> {
2315 let Inst{23-4} = 0b01100000000000000111;
2316 let Inst{3-0} = opt;
2319 // Supervisor Call (Software Interrupt)
2320 let isCall = 1, Uses = [SP] in {
2321 def SVC : ABI<0b1111, (outs), (ins imm24b:$svc), IIC_Br, "svc", "\t$svc", []>,
2324 let Inst{23-0} = svc;
2328 // Store Return State
2329 class SRSI<bit wb, string asm>
2330 : XI<(outs), (ins imm0_31:$mode), AddrModeNone, 4, IndexModeNone, BrFrm,
2331 NoItinerary, asm, "", []> {
2333 let Inst{31-28} = 0b1111;
2334 let Inst{27-25} = 0b100;
2338 let Inst{19-16} = 0b1101; // SP
2339 let Inst{15-5} = 0b00000101000;
2340 let Inst{4-0} = mode;
2343 def SRSDA : SRSI<0, "srsda\tsp, $mode"> {
2344 let Inst{24-23} = 0;
2346 def SRSDA_UPD : SRSI<1, "srsda\tsp!, $mode"> {
2347 let Inst{24-23} = 0;
2349 def SRSDB : SRSI<0, "srsdb\tsp, $mode"> {
2350 let Inst{24-23} = 0b10;
2352 def SRSDB_UPD : SRSI<1, "srsdb\tsp!, $mode"> {
2353 let Inst{24-23} = 0b10;
2355 def SRSIA : SRSI<0, "srsia\tsp, $mode"> {
2356 let Inst{24-23} = 0b01;
2358 def SRSIA_UPD : SRSI<1, "srsia\tsp!, $mode"> {
2359 let Inst{24-23} = 0b01;
2361 def SRSIB : SRSI<0, "srsib\tsp, $mode"> {
2362 let Inst{24-23} = 0b11;
2364 def SRSIB_UPD : SRSI<1, "srsib\tsp!, $mode"> {
2365 let Inst{24-23} = 0b11;
2368 def : ARMInstAlias<"srsda $mode", (SRSDA imm0_31:$mode)>;
2369 def : ARMInstAlias<"srsda $mode!", (SRSDA_UPD imm0_31:$mode)>;
2371 def : ARMInstAlias<"srsdb $mode", (SRSDB imm0_31:$mode)>;
2372 def : ARMInstAlias<"srsdb $mode!", (SRSDB_UPD imm0_31:$mode)>;
2374 def : ARMInstAlias<"srsia $mode", (SRSIA imm0_31:$mode)>;
2375 def : ARMInstAlias<"srsia $mode!", (SRSIA_UPD imm0_31:$mode)>;
2377 def : ARMInstAlias<"srsib $mode", (SRSIB imm0_31:$mode)>;
2378 def : ARMInstAlias<"srsib $mode!", (SRSIB_UPD imm0_31:$mode)>;
2380 // Return From Exception
2381 class RFEI<bit wb, string asm>
2382 : XI<(outs), (ins GPR:$Rn), AddrModeNone, 4, IndexModeNone, BrFrm,
2383 NoItinerary, asm, "", []> {
2385 let Inst{31-28} = 0b1111;
2386 let Inst{27-25} = 0b100;
2390 let Inst{19-16} = Rn;
2391 let Inst{15-0} = 0xa00;
2394 def RFEDA : RFEI<0, "rfeda\t$Rn"> {
2395 let Inst{24-23} = 0;
2397 def RFEDA_UPD : RFEI<1, "rfeda\t$Rn!"> {
2398 let Inst{24-23} = 0;
2400 def RFEDB : RFEI<0, "rfedb\t$Rn"> {
2401 let Inst{24-23} = 0b10;
2403 def RFEDB_UPD : RFEI<1, "rfedb\t$Rn!"> {
2404 let Inst{24-23} = 0b10;
2406 def RFEIA : RFEI<0, "rfeia\t$Rn"> {
2407 let Inst{24-23} = 0b01;
2409 def RFEIA_UPD : RFEI<1, "rfeia\t$Rn!"> {
2410 let Inst{24-23} = 0b01;
2412 def RFEIB : RFEI<0, "rfeib\t$Rn"> {
2413 let Inst{24-23} = 0b11;
2415 def RFEIB_UPD : RFEI<1, "rfeib\t$Rn!"> {
2416 let Inst{24-23} = 0b11;
2419 // Hypervisor Call is a system instruction
2421 def HVC : AInoP< (outs), (ins imm0_65535:$imm), BrFrm, NoItinerary,
2422 "hvc", "\t$imm", []>,
2423 Requires<[IsARM, HasVirtualization]> {
2426 // Even though HVC isn't predicable, it's encoding includes a condition field.
2427 // The instruction is undefined if the condition field is 0xf otherwise it is
2428 // unpredictable if it isn't condition AL (0xe).
2429 let Inst{31-28} = 0b1110;
2430 let Unpredictable{31-28} = 0b1111;
2431 let Inst{27-24} = 0b0001;
2432 let Inst{23-20} = 0b0100;
2433 let Inst{19-8} = imm{15-4};
2434 let Inst{7-4} = 0b0111;
2435 let Inst{3-0} = imm{3-0};
2439 // Return from exception in Hypervisor mode.
2440 let isReturn = 1, isBarrier = 1, isTerminator = 1, Defs = [PC] in
2441 def ERET : ABI<0b0001, (outs), (ins), NoItinerary, "eret", "", []>,
2442 Requires<[IsARM, HasVirtualization]> {
2443 let Inst{23-0} = 0b011000000000000001101110;
2446 //===----------------------------------------------------------------------===//
2447 // Load / Store Instructions.
2453 defm LDR : AI_ldr1<0, "ldr", IIC_iLoad_r, IIC_iLoad_si,
2454 UnOpFrag<(load node:$Src)>>;
2455 defm LDRB : AI_ldr1nopc<1, "ldrb", IIC_iLoad_bh_r, IIC_iLoad_bh_si,
2456 UnOpFrag<(zextloadi8 node:$Src)>>;
2457 defm STR : AI_str1<0, "str", IIC_iStore_r, IIC_iStore_si,
2458 BinOpFrag<(store node:$LHS, node:$RHS)>>;
2459 defm STRB : AI_str1nopc<1, "strb", IIC_iStore_bh_r, IIC_iStore_bh_si,
2460 BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
2462 // Special LDR for loads from non-pc-relative constpools.
2463 let canFoldAsLoad = 1, mayLoad = 1, hasSideEffects = 0,
2464 isReMaterializable = 1, isCodeGenOnly = 1 in
2465 def LDRcp : AI2ldst<0b010, 1, 0, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
2466 AddrMode_i12, LdFrm, IIC_iLoad_r, "ldr", "\t$Rt, $addr",
2470 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2471 let Inst{19-16} = 0b1111;
2472 let Inst{15-12} = Rt;
2473 let Inst{11-0} = addr{11-0}; // imm12
2476 // Loads with zero extension
2477 def LDRH : AI3ld<0b1011, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2478 IIC_iLoad_bh_r, "ldrh", "\t$Rt, $addr",
2479 [(set GPR:$Rt, (zextloadi16 addrmode3:$addr))]>;
2481 // Loads with sign extension
2482 def LDRSH : AI3ld<0b1111, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2483 IIC_iLoad_bh_r, "ldrsh", "\t$Rt, $addr",
2484 [(set GPR:$Rt, (sextloadi16 addrmode3:$addr))]>;
2486 def LDRSB : AI3ld<0b1101, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2487 IIC_iLoad_bh_r, "ldrsb", "\t$Rt, $addr",
2488 [(set GPR:$Rt, (sextloadi8 addrmode3:$addr))]>;
2490 let mayLoad = 1, hasSideEffects = 0, hasExtraDefRegAllocReq = 1 in {
2492 def LDRD : AI3ld<0b1101, 0, (outs GPR:$Rt, GPR:$Rt2), (ins addrmode3:$addr),
2493 LdMiscFrm, IIC_iLoad_d_r, "ldrd", "\t$Rt, $Rt2, $addr", []>,
2494 Requires<[IsARM, HasV5TE]>;
2497 def LDA : AIldracq<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2498 NoItinerary, "lda", "\t$Rt, $addr", []>;
2499 def LDAB : AIldracq<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2500 NoItinerary, "ldab", "\t$Rt, $addr", []>;
2501 def LDAH : AIldracq<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2502 NoItinerary, "ldah", "\t$Rt, $addr", []>;
2505 multiclass AI2_ldridx<bit isByte, string opc,
2506 InstrItinClass iii, InstrItinClass iir> {
2507 def _PRE_IMM : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2508 (ins addrmode_imm12_pre:$addr), IndexModePre, LdFrm, iii,
2509 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2512 let Inst{23} = addr{12};
2513 let Inst{19-16} = addr{16-13};
2514 let Inst{11-0} = addr{11-0};
2515 let DecoderMethod = "DecodeLDRPreImm";
2518 def _PRE_REG : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2519 (ins ldst_so_reg:$addr), IndexModePre, LdFrm, iir,
2520 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2523 let Inst{23} = addr{12};
2524 let Inst{19-16} = addr{16-13};
2525 let Inst{11-0} = addr{11-0};
2527 let DecoderMethod = "DecodeLDRPreReg";
2530 def _POST_REG : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2531 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2532 IndexModePost, LdFrm, iir,
2533 opc, "\t$Rt, $addr, $offset",
2534 "$addr.base = $Rn_wb", []> {
2540 let Inst{23} = offset{12};
2541 let Inst{19-16} = addr;
2542 let Inst{11-0} = offset{11-0};
2545 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2548 def _POST_IMM : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2549 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2550 IndexModePost, LdFrm, iii,
2551 opc, "\t$Rt, $addr, $offset",
2552 "$addr.base = $Rn_wb", []> {
2558 let Inst{23} = offset{12};
2559 let Inst{19-16} = addr;
2560 let Inst{11-0} = offset{11-0};
2562 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2567 let mayLoad = 1, hasSideEffects = 0 in {
2568 // FIXME: for LDR_PRE_REG etc. the itineray should be either IIC_iLoad_ru or
2569 // IIC_iLoad_siu depending on whether it the offset register is shifted.
2570 defm LDR : AI2_ldridx<0, "ldr", IIC_iLoad_iu, IIC_iLoad_ru>;
2571 defm LDRB : AI2_ldridx<1, "ldrb", IIC_iLoad_bh_iu, IIC_iLoad_bh_ru>;
2574 multiclass AI3_ldridx<bits<4> op, string opc, InstrItinClass itin> {
2575 def _PRE : AI3ldstidx<op, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2576 (ins addrmode3_pre:$addr), IndexModePre,
2578 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2580 let Inst{23} = addr{8}; // U bit
2581 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2582 let Inst{19-16} = addr{12-9}; // Rn
2583 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2584 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2585 let DecoderMethod = "DecodeAddrMode3Instruction";
2587 def _POST : AI3ldstidx<op, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2588 (ins addr_offset_none:$addr, am3offset:$offset),
2589 IndexModePost, LdMiscFrm, itin,
2590 opc, "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2594 let Inst{23} = offset{8}; // U bit
2595 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2596 let Inst{19-16} = addr;
2597 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2598 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2599 let DecoderMethod = "DecodeAddrMode3Instruction";
2603 let mayLoad = 1, hasSideEffects = 0 in {
2604 defm LDRH : AI3_ldridx<0b1011, "ldrh", IIC_iLoad_bh_ru>;
2605 defm LDRSH : AI3_ldridx<0b1111, "ldrsh", IIC_iLoad_bh_ru>;
2606 defm LDRSB : AI3_ldridx<0b1101, "ldrsb", IIC_iLoad_bh_ru>;
2607 let hasExtraDefRegAllocReq = 1 in {
2608 def LDRD_PRE : AI3ldstidx<0b1101, 0, 1, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2609 (ins addrmode3_pre:$addr), IndexModePre,
2610 LdMiscFrm, IIC_iLoad_d_ru,
2611 "ldrd", "\t$Rt, $Rt2, $addr!",
2612 "$addr.base = $Rn_wb", []> {
2614 let Inst{23} = addr{8}; // U bit
2615 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2616 let Inst{19-16} = addr{12-9}; // Rn
2617 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2618 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2619 let DecoderMethod = "DecodeAddrMode3Instruction";
2621 def LDRD_POST: AI3ldstidx<0b1101, 0, 0, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2622 (ins addr_offset_none:$addr, am3offset:$offset),
2623 IndexModePost, LdMiscFrm, IIC_iLoad_d_ru,
2624 "ldrd", "\t$Rt, $Rt2, $addr, $offset",
2625 "$addr.base = $Rn_wb", []> {
2628 let Inst{23} = offset{8}; // U bit
2629 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2630 let Inst{19-16} = addr;
2631 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2632 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2633 let DecoderMethod = "DecodeAddrMode3Instruction";
2635 } // hasExtraDefRegAllocReq = 1
2636 } // mayLoad = 1, hasSideEffects = 0
2638 // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT.
2639 let mayLoad = 1, hasSideEffects = 0 in {
2640 def LDRT_POST_REG : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2641 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2642 IndexModePost, LdFrm, IIC_iLoad_ru,
2643 "ldrt", "\t$Rt, $addr, $offset",
2644 "$addr.base = $Rn_wb", []> {
2650 let Inst{23} = offset{12};
2651 let Inst{21} = 1; // overwrite
2652 let Inst{19-16} = addr;
2653 let Inst{11-5} = offset{11-5};
2655 let Inst{3-0} = offset{3-0};
2656 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2660 : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2661 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2662 IndexModePost, LdFrm, IIC_iLoad_ru,
2663 "ldrt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2669 let Inst{23} = offset{12};
2670 let Inst{21} = 1; // overwrite
2671 let Inst{19-16} = addr;
2672 let Inst{11-0} = offset{11-0};
2673 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2676 def LDRBT_POST_REG : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2677 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2678 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2679 "ldrbt", "\t$Rt, $addr, $offset",
2680 "$addr.base = $Rn_wb", []> {
2686 let Inst{23} = offset{12};
2687 let Inst{21} = 1; // overwrite
2688 let Inst{19-16} = addr;
2689 let Inst{11-5} = offset{11-5};
2691 let Inst{3-0} = offset{3-0};
2692 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2696 : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2697 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2698 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2699 "ldrbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2705 let Inst{23} = offset{12};
2706 let Inst{21} = 1; // overwrite
2707 let Inst{19-16} = addr;
2708 let Inst{11-0} = offset{11-0};
2709 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2712 multiclass AI3ldrT<bits<4> op, string opc> {
2713 def i : AI3ldstidxT<op, 1, (outs GPR:$Rt, GPR:$base_wb),
2714 (ins addr_offset_none:$addr, postidx_imm8:$offset),
2715 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2716 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2718 let Inst{23} = offset{8};
2720 let Inst{11-8} = offset{7-4};
2721 let Inst{3-0} = offset{3-0};
2723 def r : AI3ldstidxT<op, 1, (outs GPRnopc:$Rt, GPRnopc:$base_wb),
2724 (ins addr_offset_none:$addr, postidx_reg:$Rm),
2725 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2726 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2728 let Inst{23} = Rm{4};
2731 let Unpredictable{11-8} = 0b1111;
2732 let Inst{3-0} = Rm{3-0};
2733 let DecoderMethod = "DecodeLDR";
2737 defm LDRSBT : AI3ldrT<0b1101, "ldrsbt">;
2738 defm LDRHT : AI3ldrT<0b1011, "ldrht">;
2739 defm LDRSHT : AI3ldrT<0b1111, "ldrsht">;
2743 : ARMAsmPseudo<"ldrt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q),
2747 : ARMAsmPseudo<"ldrbt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q),
2752 // Stores with truncate
2753 def STRH : AI3str<0b1011, (outs), (ins GPR:$Rt, addrmode3:$addr), StMiscFrm,
2754 IIC_iStore_bh_r, "strh", "\t$Rt, $addr",
2755 [(truncstorei16 GPR:$Rt, addrmode3:$addr)]>;
2758 let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
2759 def STRD : AI3str<0b1111, (outs), (ins GPR:$Rt, GPR:$Rt2, addrmode3:$addr),
2760 StMiscFrm, IIC_iStore_d_r, "strd", "\t$Rt, $Rt2, $addr", []>,
2761 Requires<[IsARM, HasV5TE]> {
2767 multiclass AI2_stridx<bit isByte, string opc,
2768 InstrItinClass iii, InstrItinClass iir> {
2769 def _PRE_IMM : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2770 (ins GPR:$Rt, addrmode_imm12_pre:$addr), IndexModePre,
2772 opc, "\t$Rt, $addr!",
2773 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2776 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2777 let Inst{19-16} = addr{16-13}; // Rn
2778 let Inst{11-0} = addr{11-0}; // imm12
2779 let DecoderMethod = "DecodeSTRPreImm";
2782 def _PRE_REG : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2783 (ins GPR:$Rt, ldst_so_reg:$addr),
2784 IndexModePre, StFrm, iir,
2785 opc, "\t$Rt, $addr!",
2786 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2789 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2790 let Inst{19-16} = addr{16-13}; // Rn
2791 let Inst{11-0} = addr{11-0};
2792 let Inst{4} = 0; // Inst{4} = 0
2793 let DecoderMethod = "DecodeSTRPreReg";
2795 def _POST_REG : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2796 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2797 IndexModePost, StFrm, iir,
2798 opc, "\t$Rt, $addr, $offset",
2799 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2805 let Inst{23} = offset{12};
2806 let Inst{19-16} = addr;
2807 let Inst{11-0} = offset{11-0};
2810 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2813 def _POST_IMM : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2814 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2815 IndexModePost, StFrm, iii,
2816 opc, "\t$Rt, $addr, $offset",
2817 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2823 let Inst{23} = offset{12};
2824 let Inst{19-16} = addr;
2825 let Inst{11-0} = offset{11-0};
2827 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2831 let mayStore = 1, hasSideEffects = 0 in {
2832 // FIXME: for STR_PRE_REG etc. the itineray should be either IIC_iStore_ru or
2833 // IIC_iStore_siu depending on whether it the offset register is shifted.
2834 defm STR : AI2_stridx<0, "str", IIC_iStore_iu, IIC_iStore_ru>;
2835 defm STRB : AI2_stridx<1, "strb", IIC_iStore_bh_iu, IIC_iStore_bh_ru>;
2838 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2839 am2offset_reg:$offset),
2840 (STR_POST_REG GPR:$Rt, addr_offset_none:$addr,
2841 am2offset_reg:$offset)>;
2842 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2843 am2offset_imm:$offset),
2844 (STR_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2845 am2offset_imm:$offset)>;
2846 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2847 am2offset_reg:$offset),
2848 (STRB_POST_REG GPR:$Rt, addr_offset_none:$addr,
2849 am2offset_reg:$offset)>;
2850 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2851 am2offset_imm:$offset),
2852 (STRB_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2853 am2offset_imm:$offset)>;
2855 // Pseudo-instructions for pattern matching the pre-indexed stores. We can't
2856 // put the patterns on the instruction definitions directly as ISel wants
2857 // the address base and offset to be separate operands, not a single
2858 // complex operand like we represent the instructions themselves. The
2859 // pseudos map between the two.
2860 let usesCustomInserter = 1,
2861 Constraints = "$Rn = $Rn_wb,@earlyclobber $Rn_wb" in {
2862 def STRi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2863 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2866 (pre_store GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2867 def STRr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2868 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2871 (pre_store GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2872 def STRBi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2873 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2876 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2877 def STRBr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2878 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2881 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2882 def STRH_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2883 (ins GPR:$Rt, GPR:$Rn, am3offset:$offset, pred:$p),
2886 (pre_truncsti16 GPR:$Rt, GPR:$Rn, am3offset:$offset))]>;
2891 def STRH_PRE : AI3ldstidx<0b1011, 0, 1, (outs GPR:$Rn_wb),
2892 (ins GPR:$Rt, addrmode3_pre:$addr), IndexModePre,
2893 StMiscFrm, IIC_iStore_bh_ru,
2894 "strh", "\t$Rt, $addr!",
2895 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2897 let Inst{23} = addr{8}; // U bit
2898 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2899 let Inst{19-16} = addr{12-9}; // Rn
2900 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2901 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2902 let DecoderMethod = "DecodeAddrMode3Instruction";
2905 def STRH_POST : AI3ldstidx<0b1011, 0, 0, (outs GPR:$Rn_wb),
2906 (ins GPR:$Rt, addr_offset_none:$addr, am3offset:$offset),
2907 IndexModePost, StMiscFrm, IIC_iStore_bh_ru,
2908 "strh", "\t$Rt, $addr, $offset",
2909 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb",
2910 [(set GPR:$Rn_wb, (post_truncsti16 GPR:$Rt,
2911 addr_offset_none:$addr,
2912 am3offset:$offset))]> {
2915 let Inst{23} = offset{8}; // U bit
2916 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2917 let Inst{19-16} = addr;
2918 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2919 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2920 let DecoderMethod = "DecodeAddrMode3Instruction";
2923 let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
2924 def STRD_PRE : AI3ldstidx<0b1111, 0, 1, (outs GPR:$Rn_wb),
2925 (ins GPR:$Rt, GPR:$Rt2, addrmode3_pre:$addr),
2926 IndexModePre, StMiscFrm, IIC_iStore_d_ru,
2927 "strd", "\t$Rt, $Rt2, $addr!",
2928 "$addr.base = $Rn_wb", []> {
2930 let Inst{23} = addr{8}; // U bit
2931 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2932 let Inst{19-16} = addr{12-9}; // Rn
2933 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2934 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2935 let DecoderMethod = "DecodeAddrMode3Instruction";
2938 def STRD_POST: AI3ldstidx<0b1111, 0, 0, (outs GPR:$Rn_wb),
2939 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr,
2941 IndexModePost, StMiscFrm, IIC_iStore_d_ru,
2942 "strd", "\t$Rt, $Rt2, $addr, $offset",
2943 "$addr.base = $Rn_wb", []> {
2946 let Inst{23} = offset{8}; // U bit
2947 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2948 let Inst{19-16} = addr;
2949 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2950 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2951 let DecoderMethod = "DecodeAddrMode3Instruction";
2953 } // mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1
2955 // STRT, STRBT, and STRHT
2957 def STRBT_POST_REG : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2958 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2959 IndexModePost, StFrm, IIC_iStore_bh_ru,
2960 "strbt", "\t$Rt, $addr, $offset",
2961 "$addr.base = $Rn_wb", []> {
2967 let Inst{23} = offset{12};
2968 let Inst{21} = 1; // overwrite
2969 let Inst{19-16} = addr;
2970 let Inst{11-5} = offset{11-5};
2972 let Inst{3-0} = offset{3-0};
2973 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2977 : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2978 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2979 IndexModePost, StFrm, IIC_iStore_bh_ru,
2980 "strbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2986 let Inst{23} = offset{12};
2987 let Inst{21} = 1; // overwrite
2988 let Inst{19-16} = addr;
2989 let Inst{11-0} = offset{11-0};
2990 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2994 : ARMAsmPseudo<"strbt${q} $Rt, $addr",
2995 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>;
2997 let mayStore = 1, hasSideEffects = 0 in {
2998 def STRT_POST_REG : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
2999 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
3000 IndexModePost, StFrm, IIC_iStore_ru,
3001 "strt", "\t$Rt, $addr, $offset",
3002 "$addr.base = $Rn_wb", []> {
3008 let Inst{23} = offset{12};
3009 let Inst{21} = 1; // overwrite
3010 let Inst{19-16} = addr;
3011 let Inst{11-5} = offset{11-5};
3013 let Inst{3-0} = offset{3-0};
3014 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3018 : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
3019 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
3020 IndexModePost, StFrm, IIC_iStore_ru,
3021 "strt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
3027 let Inst{23} = offset{12};
3028 let Inst{21} = 1; // overwrite
3029 let Inst{19-16} = addr;
3030 let Inst{11-0} = offset{11-0};
3031 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3036 : ARMAsmPseudo<"strt${q} $Rt, $addr",
3037 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>;
3039 multiclass AI3strT<bits<4> op, string opc> {
3040 def i : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
3041 (ins GPR:$Rt, addr_offset_none:$addr, postidx_imm8:$offset),
3042 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
3043 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
3045 let Inst{23} = offset{8};
3047 let Inst{11-8} = offset{7-4};
3048 let Inst{3-0} = offset{3-0};
3050 def r : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
3051 (ins GPR:$Rt, addr_offset_none:$addr, postidx_reg:$Rm),
3052 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
3053 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
3055 let Inst{23} = Rm{4};
3058 let Inst{3-0} = Rm{3-0};
3063 defm STRHT : AI3strT<0b1011, "strht">;
3065 def STL : AIstrrel<0b00, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3066 NoItinerary, "stl", "\t$Rt, $addr", []>;
3067 def STLB : AIstrrel<0b10, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3068 NoItinerary, "stlb", "\t$Rt, $addr", []>;
3069 def STLH : AIstrrel<0b11, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3070 NoItinerary, "stlh", "\t$Rt, $addr", []>;
3072 //===----------------------------------------------------------------------===//
3073 // Load / store multiple Instructions.
3076 multiclass arm_ldst_mult<string asm, string sfx, bit L_bit, bit P_bit, Format f,
3077 InstrItinClass itin, InstrItinClass itin_upd> {
3078 // IA is the default, so no need for an explicit suffix on the
3079 // mnemonic here. Without it is the canonical spelling.
3081 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3082 IndexModeNone, f, itin,
3083 !strconcat(asm, "${p}\t$Rn, $regs", sfx), "", []> {
3084 let Inst{24-23} = 0b01; // Increment After
3085 let Inst{22} = P_bit;
3086 let Inst{21} = 0; // No writeback
3087 let Inst{20} = L_bit;
3090 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3091 IndexModeUpd, f, itin_upd,
3092 !strconcat(asm, "${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3093 let Inst{24-23} = 0b01; // Increment After
3094 let Inst{22} = P_bit;
3095 let Inst{21} = 1; // Writeback
3096 let Inst{20} = L_bit;
3098 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3101 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3102 IndexModeNone, f, itin,
3103 !strconcat(asm, "da${p}\t$Rn, $regs", sfx), "", []> {
3104 let Inst{24-23} = 0b00; // Decrement After
3105 let Inst{22} = P_bit;
3106 let Inst{21} = 0; // No writeback
3107 let Inst{20} = L_bit;
3110 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3111 IndexModeUpd, f, itin_upd,
3112 !strconcat(asm, "da${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3113 let Inst{24-23} = 0b00; // Decrement After
3114 let Inst{22} = P_bit;
3115 let Inst{21} = 1; // Writeback
3116 let Inst{20} = L_bit;
3118 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3121 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3122 IndexModeNone, f, itin,
3123 !strconcat(asm, "db${p}\t$Rn, $regs", sfx), "", []> {
3124 let Inst{24-23} = 0b10; // Decrement Before
3125 let Inst{22} = P_bit;
3126 let Inst{21} = 0; // No writeback
3127 let Inst{20} = L_bit;
3130 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3131 IndexModeUpd, f, itin_upd,
3132 !strconcat(asm, "db${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3133 let Inst{24-23} = 0b10; // Decrement Before
3134 let Inst{22} = P_bit;
3135 let Inst{21} = 1; // Writeback
3136 let Inst{20} = L_bit;
3138 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3141 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3142 IndexModeNone, f, itin,
3143 !strconcat(asm, "ib${p}\t$Rn, $regs", sfx), "", []> {
3144 let Inst{24-23} = 0b11; // Increment Before
3145 let Inst{22} = P_bit;
3146 let Inst{21} = 0; // No writeback
3147 let Inst{20} = L_bit;
3150 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3151 IndexModeUpd, f, itin_upd,
3152 !strconcat(asm, "ib${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3153 let Inst{24-23} = 0b11; // Increment Before
3154 let Inst{22} = P_bit;
3155 let Inst{21} = 1; // Writeback
3156 let Inst{20} = L_bit;
3158 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3162 let hasSideEffects = 0 in {
3164 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
3165 defm LDM : arm_ldst_mult<"ldm", "", 1, 0, LdStMulFrm, IIC_iLoad_m,
3166 IIC_iLoad_mu>, ComplexDeprecationPredicate<"ARMLoad">;
3168 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
3169 defm STM : arm_ldst_mult<"stm", "", 0, 0, LdStMulFrm, IIC_iStore_m,
3171 ComplexDeprecationPredicate<"ARMStore">;
3175 // FIXME: remove when we have a way to marking a MI with these properties.
3176 // FIXME: Should pc be an implicit operand like PICADD, etc?
3177 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
3178 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
3179 def LDMIA_RET : ARMPseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p,
3180 reglist:$regs, variable_ops),
3181 4, IIC_iLoad_mBr, [],
3182 (LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>,
3183 RegConstraint<"$Rn = $wb">;
3185 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
3186 defm sysLDM : arm_ldst_mult<"ldm", " ^", 1, 1, LdStMulFrm, IIC_iLoad_m,
3189 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
3190 defm sysSTM : arm_ldst_mult<"stm", " ^", 0, 1, LdStMulFrm, IIC_iStore_m,
3195 //===----------------------------------------------------------------------===//
3196 // Move Instructions.
3199 let hasSideEffects = 0 in
3200 def MOVr : AsI1<0b1101, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMOVr,
3201 "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> {
3205 let Inst{19-16} = 0b0000;
3206 let Inst{11-4} = 0b00000000;
3209 let Inst{15-12} = Rd;
3212 // A version for the smaller set of tail call registers.
3213 let hasSideEffects = 0 in
3214 def MOVr_TC : AsI1<0b1101, (outs tcGPR:$Rd), (ins tcGPR:$Rm), DPFrm,
3215 IIC_iMOVr, "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> {
3219 let Inst{11-4} = 0b00000000;
3222 let Inst{15-12} = Rd;
3225 def MOVsr : AsI1<0b1101, (outs GPRnopc:$Rd), (ins shift_so_reg_reg:$src),
3226 DPSoRegRegFrm, IIC_iMOVsr,
3227 "mov", "\t$Rd, $src",
3228 [(set GPRnopc:$Rd, shift_so_reg_reg:$src)]>, UnaryDP,
3232 let Inst{15-12} = Rd;
3233 let Inst{19-16} = 0b0000;
3234 let Inst{11-8} = src{11-8};
3236 let Inst{6-5} = src{6-5};
3238 let Inst{3-0} = src{3-0};
3242 def MOVsi : AsI1<0b1101, (outs GPR:$Rd), (ins shift_so_reg_imm:$src),
3243 DPSoRegImmFrm, IIC_iMOVsr,
3244 "mov", "\t$Rd, $src", [(set GPR:$Rd, shift_so_reg_imm:$src)]>,
3245 UnaryDP, Sched<[WriteALU]> {
3248 let Inst{15-12} = Rd;
3249 let Inst{19-16} = 0b0000;
3250 let Inst{11-5} = src{11-5};
3252 let Inst{3-0} = src{3-0};
3256 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3257 def MOVi : AsI1<0b1101, (outs GPR:$Rd), (ins mod_imm:$imm), DPFrm, IIC_iMOVi,
3258 "mov", "\t$Rd, $imm", [(set GPR:$Rd, mod_imm:$imm)]>, UnaryDP,
3263 let Inst{15-12} = Rd;
3264 let Inst{19-16} = 0b0000;
3265 let Inst{11-0} = imm;
3268 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3269 def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins imm0_65535_expr:$imm),
3271 "movw", "\t$Rd, $imm",
3272 [(set GPR:$Rd, imm0_65535:$imm)]>,
3273 Requires<[IsARM, HasV6T2]>, UnaryDP, Sched<[WriteALU]> {
3276 let Inst{15-12} = Rd;
3277 let Inst{11-0} = imm{11-0};
3278 let Inst{19-16} = imm{15-12};
3281 let DecoderMethod = "DecodeArmMOVTWInstruction";
3284 def : InstAlias<"mov${p} $Rd, $imm",
3285 (MOVi16 GPR:$Rd, imm0_65535_expr:$imm, pred:$p)>,
3288 def MOVi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
3289 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
3292 let Constraints = "$src = $Rd" in {
3293 def MOVTi16 : AI1<0b1010, (outs GPRnopc:$Rd),
3294 (ins GPR:$src, imm0_65535_expr:$imm),
3296 "movt", "\t$Rd, $imm",
3298 (or (and GPR:$src, 0xffff),
3299 lo16AllZero:$imm))]>, UnaryDP,
3300 Requires<[IsARM, HasV6T2]>, Sched<[WriteALU]> {
3303 let Inst{15-12} = Rd;
3304 let Inst{11-0} = imm{11-0};
3305 let Inst{19-16} = imm{15-12};
3308 let DecoderMethod = "DecodeArmMOVTWInstruction";
3311 def MOVTi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
3312 (ins GPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
3317 def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
3318 Requires<[IsARM, HasV6T2]>;
3320 let Uses = [CPSR] in
3321 def RRX: PseudoInst<(outs GPR:$Rd), (ins GPR:$Rm), IIC_iMOVsi,
3322 [(set GPR:$Rd, (ARMrrx GPR:$Rm))]>, UnaryDP,
3323 Requires<[IsARM]>, Sched<[WriteALU]>;
3325 // These aren't really mov instructions, but we have to define them this way
3326 // due to flag operands.
3328 let Defs = [CPSR] in {
3329 def MOVsrl_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3330 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP,
3331 Sched<[WriteALU]>, Requires<[IsARM]>;
3332 def MOVsra_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3333 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP,
3334 Sched<[WriteALU]>, Requires<[IsARM]>;
3337 //===----------------------------------------------------------------------===//
3338 // Extend Instructions.
3343 def SXTB : AI_ext_rrot<0b01101010,
3344 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
3345 def SXTH : AI_ext_rrot<0b01101011,
3346 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
3348 def SXTAB : AI_exta_rrot<0b01101010,
3349 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
3350 def SXTAH : AI_exta_rrot<0b01101011,
3351 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
3353 def SXTB16 : AI_ext_rrot_np<0b01101000, "sxtb16">;
3355 def SXTAB16 : AI_exta_rrot_np<0b01101000, "sxtab16">;
3359 let AddedComplexity = 16 in {
3360 def UXTB : AI_ext_rrot<0b01101110,
3361 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
3362 def UXTH : AI_ext_rrot<0b01101111,
3363 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
3364 def UXTB16 : AI_ext_rrot<0b01101100,
3365 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
3367 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
3368 // The transformation should probably be done as a combiner action
3369 // instead so we can include a check for masking back in the upper
3370 // eight bits of the source into the lower eight bits of the result.
3371 //def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
3372 // (UXTB16r_rot GPR:$Src, 3)>;
3373 def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
3374 (UXTB16 GPR:$Src, 1)>;
3376 def UXTAB : AI_exta_rrot<0b01101110, "uxtab",
3377 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
3378 def UXTAH : AI_exta_rrot<0b01101111, "uxtah",
3379 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;