1 //===- ARMInstrInfo.td - Target Description for ARM Target -*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the ARM instructions in TableGen format.
12 //===----------------------------------------------------------------------===//
14 //===----------------------------------------------------------------------===//
15 // ARM specific DAG Nodes.
19 def SDT_ARMCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
20 def SDT_ARMCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>, SDTCisVT<1, i32> ]>;
21 def SDT_ARMStructByVal : SDTypeProfile<0, 4,
22 [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
23 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
25 def SDT_ARMSaveCallPC : SDTypeProfile<0, 1, []>;
27 def SDT_ARMcall : SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>;
29 def SDT_ARMCMov : SDTypeProfile<1, 3,
30 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
33 def SDT_ARMBrcond : SDTypeProfile<0, 2,
34 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i32>]>;
36 def SDT_ARMBrJT : SDTypeProfile<0, 3,
37 [SDTCisPtrTy<0>, SDTCisVT<1, i32>,
40 def SDT_ARMBr2JT : SDTypeProfile<0, 4,
41 [SDTCisPtrTy<0>, SDTCisVT<1, i32>,
42 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
44 def SDT_ARMBCC_i64 : SDTypeProfile<0, 6,
46 SDTCisVT<1, i32>, SDTCisVT<2, i32>,
47 SDTCisVT<3, i32>, SDTCisVT<4, i32>,
48 SDTCisVT<5, OtherVT>]>;
50 def SDT_ARMAnd : SDTypeProfile<1, 2,
51 [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
54 def SDT_ARMCmp : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
56 def SDT_ARMPICAdd : SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>,
57 SDTCisPtrTy<1>, SDTCisVT<2, i32>]>;
59 def SDT_ARMThreadPointer : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
60 def SDT_ARMEH_SJLJ_Setjmp : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisPtrTy<1>,
62 def SDT_ARMEH_SJLJ_Longjmp: SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
64 def SDT_ARMMEMBARRIER : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
66 def SDT_ARMPREFETCH : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisSameAs<1, 2>,
69 def SDT_ARMTCRET : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
71 def SDT_ARMBFI : SDTypeProfile<1, 3, [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
72 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
74 def SDT_ARMVMAXNM : SDTypeProfile<1, 2, [SDTCisFP<0>, SDTCisFP<1>, SDTCisFP<2>]>;
75 def SDT_ARMVMINNM : SDTypeProfile<1, 2, [SDTCisFP<0>, SDTCisFP<1>, SDTCisFP<2>]>;
77 def SDTBinaryArithWithFlags : SDTypeProfile<2, 2,
80 SDTCisInt<0>, SDTCisVT<1, i32>]>;
82 // SDTBinaryArithWithFlagsInOut - RES1, CPSR = op LHS, RHS, CPSR
83 def SDTBinaryArithWithFlagsInOut : SDTypeProfile<2, 3,
90 def SDT_ARM64bitmlal : SDTypeProfile<2,4, [ SDTCisVT<0, i32>, SDTCisVT<1, i32>,
91 SDTCisVT<2, i32>, SDTCisVT<3, i32>,
92 SDTCisVT<4, i32>, SDTCisVT<5, i32> ] >;
93 def ARMUmlal : SDNode<"ARMISD::UMLAL", SDT_ARM64bitmlal>;
94 def ARMSmlal : SDNode<"ARMISD::SMLAL", SDT_ARM64bitmlal>;
97 def ARMWrapper : SDNode<"ARMISD::Wrapper", SDTIntUnaryOp>;
98 def ARMWrapperPIC : SDNode<"ARMISD::WrapperPIC", SDTIntUnaryOp>;
99 def ARMWrapperJT : SDNode<"ARMISD::WrapperJT", SDTIntBinOp>;
101 def ARMcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_ARMCallSeqStart,
102 [SDNPHasChain, SDNPSideEffect, SDNPOutGlue]>;
103 def ARMcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_ARMCallSeqEnd,
104 [SDNPHasChain, SDNPSideEffect,
105 SDNPOptInGlue, SDNPOutGlue]>;
106 def ARMcopystructbyval : SDNode<"ARMISD::COPY_STRUCT_BYVAL" ,
108 [SDNPHasChain, SDNPInGlue, SDNPOutGlue,
109 SDNPMayStore, SDNPMayLoad]>;
111 def ARMcall : SDNode<"ARMISD::CALL", SDT_ARMcall,
112 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
114 def ARMcall_pred : SDNode<"ARMISD::CALL_PRED", SDT_ARMcall,
115 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
117 def ARMcall_nolink : SDNode<"ARMISD::CALL_NOLINK", SDT_ARMcall,
118 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
121 def ARMretflag : SDNode<"ARMISD::RET_FLAG", SDTNone,
122 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
123 def ARMintretflag : SDNode<"ARMISD::INTRET_FLAG", SDT_ARMcall,
124 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
125 def ARMcmov : SDNode<"ARMISD::CMOV", SDT_ARMCMov,
128 def ARMbrcond : SDNode<"ARMISD::BRCOND", SDT_ARMBrcond,
129 [SDNPHasChain, SDNPInGlue, SDNPOutGlue]>;
131 def ARMbrjt : SDNode<"ARMISD::BR_JT", SDT_ARMBrJT,
133 def ARMbr2jt : SDNode<"ARMISD::BR2_JT", SDT_ARMBr2JT,
136 def ARMBcci64 : SDNode<"ARMISD::BCC_i64", SDT_ARMBCC_i64,
139 def ARMcmp : SDNode<"ARMISD::CMP", SDT_ARMCmp,
142 def ARMcmn : SDNode<"ARMISD::CMN", SDT_ARMCmp,
145 def ARMcmpZ : SDNode<"ARMISD::CMPZ", SDT_ARMCmp,
146 [SDNPOutGlue, SDNPCommutative]>;
148 def ARMpic_add : SDNode<"ARMISD::PIC_ADD", SDT_ARMPICAdd>;
150 def ARMsrl_flag : SDNode<"ARMISD::SRL_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
151 def ARMsra_flag : SDNode<"ARMISD::SRA_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
152 def ARMrrx : SDNode<"ARMISD::RRX" , SDTIntUnaryOp, [SDNPInGlue ]>;
154 def ARMaddc : SDNode<"ARMISD::ADDC", SDTBinaryArithWithFlags,
156 def ARMsubc : SDNode<"ARMISD::SUBC", SDTBinaryArithWithFlags>;
157 def ARMadde : SDNode<"ARMISD::ADDE", SDTBinaryArithWithFlagsInOut>;
158 def ARMsube : SDNode<"ARMISD::SUBE", SDTBinaryArithWithFlagsInOut>;
160 def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>;
161 def ARMeh_sjlj_setjmp: SDNode<"ARMISD::EH_SJLJ_SETJMP",
162 SDT_ARMEH_SJLJ_Setjmp,
163 [SDNPHasChain, SDNPSideEffect]>;
164 def ARMeh_sjlj_longjmp: SDNode<"ARMISD::EH_SJLJ_LONGJMP",
165 SDT_ARMEH_SJLJ_Longjmp,
166 [SDNPHasChain, SDNPSideEffect]>;
168 def ARMMemBarrierMCR : SDNode<"ARMISD::MEMBARRIER_MCR", SDT_ARMMEMBARRIER,
169 [SDNPHasChain, SDNPSideEffect]>;
170 def ARMPreload : SDNode<"ARMISD::PRELOAD", SDT_ARMPREFETCH,
171 [SDNPHasChain, SDNPMayLoad, SDNPMayStore]>;
173 def ARMrbit : SDNode<"ARMISD::RBIT", SDTIntUnaryOp>;
175 def ARMtcret : SDNode<"ARMISD::TC_RETURN", SDT_ARMTCRET,
176 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
178 def ARMbfi : SDNode<"ARMISD::BFI", SDT_ARMBFI>;
180 def ARMvmaxnm : SDNode<"ARMISD::VMAXNM", SDT_ARMVMAXNM, []>;
181 def ARMvminnm : SDNode<"ARMISD::VMINNM", SDT_ARMVMINNM, []>;
183 //===----------------------------------------------------------------------===//
184 // ARM Instruction Predicate Definitions.
186 def HasV4T : Predicate<"Subtarget->hasV4TOps()">,
187 AssemblerPredicate<"HasV4TOps", "armv4t">;
188 def NoV4T : Predicate<"!Subtarget->hasV4TOps()">;
189 def HasV5T : Predicate<"Subtarget->hasV5TOps()">,
190 AssemblerPredicate<"HasV5TOps", "armv5t">;
191 def HasV5TE : Predicate<"Subtarget->hasV5TEOps()">,
192 AssemblerPredicate<"HasV5TEOps", "armv5te">;
193 def HasV6 : Predicate<"Subtarget->hasV6Ops()">,
194 AssemblerPredicate<"HasV6Ops", "armv6">;
195 def NoV6 : Predicate<"!Subtarget->hasV6Ops()">;
196 def HasV6M : Predicate<"Subtarget->hasV6MOps()">,
197 AssemblerPredicate<"HasV6MOps",
198 "armv6m or armv6t2">;
199 def HasV6T2 : Predicate<"Subtarget->hasV6T2Ops()">,
200 AssemblerPredicate<"HasV6T2Ops", "armv6t2">;
201 def NoV6T2 : Predicate<"!Subtarget->hasV6T2Ops()">;
202 def HasV6K : Predicate<"Subtarget->hasV6KOps()">,
203 AssemblerPredicate<"HasV6KOps", "armv6k">;
204 def NoV6K : Predicate<"!Subtarget->hasV6KOps()">;
205 def HasV7 : Predicate<"Subtarget->hasV7Ops()">,
206 AssemblerPredicate<"HasV7Ops", "armv7">;
207 def HasV8 : Predicate<"Subtarget->hasV8Ops()">,
208 AssemblerPredicate<"HasV8Ops", "armv8">;
209 def PreV8 : Predicate<"!Subtarget->hasV8Ops()">,
210 AssemblerPredicate<"!HasV8Ops", "armv7 or earlier">;
211 def HasV8_1a : Predicate<"Subtarget->hasV8_1aOps()">,
212 AssemblerPredicate<"HasV8_1aOps", "armv8.1a">;
213 def NoVFP : Predicate<"!Subtarget->hasVFP2()">;
214 def HasVFP2 : Predicate<"Subtarget->hasVFP2()">,
215 AssemblerPredicate<"FeatureVFP2", "VFP2">;
216 def HasVFP3 : Predicate<"Subtarget->hasVFP3()">,
217 AssemblerPredicate<"FeatureVFP3", "VFP3">;
218 def HasVFP4 : Predicate<"Subtarget->hasVFP4()">,
219 AssemblerPredicate<"FeatureVFP4", "VFP4">;
220 def HasDPVFP : Predicate<"!Subtarget->isFPOnlySP()">,
221 AssemblerPredicate<"!FeatureVFPOnlySP",
222 "double precision VFP">;
223 def HasFPARMv8 : Predicate<"Subtarget->hasFPARMv8()">,
224 AssemblerPredicate<"FeatureFPARMv8", "FPARMv8">;
225 def HasNEON : Predicate<"Subtarget->hasNEON()">,
226 AssemblerPredicate<"FeatureNEON", "NEON">;
227 def HasCrypto : Predicate<"Subtarget->hasCrypto()">,
228 AssemblerPredicate<"FeatureCrypto", "crypto">;
229 def HasCRC : Predicate<"Subtarget->hasCRC()">,
230 AssemblerPredicate<"FeatureCRC", "crc">;
231 def HasFP16 : Predicate<"Subtarget->hasFP16()">,
232 AssemblerPredicate<"FeatureFP16","half-float">;
233 def HasDivide : Predicate<"Subtarget->hasDivide()">,
234 AssemblerPredicate<"FeatureHWDiv", "divide in THUMB">;
235 def HasDivideInARM : Predicate<"Subtarget->hasDivideInARMMode()">,
236 AssemblerPredicate<"FeatureHWDivARM", "divide in ARM">;
237 def HasT2ExtractPack : Predicate<"Subtarget->hasT2ExtractPack()">,
238 AssemblerPredicate<"FeatureT2XtPk",
240 def HasThumb2DSP : Predicate<"Subtarget->hasThumb2DSP()">,
241 AssemblerPredicate<"FeatureDSPThumb2",
243 def HasDB : Predicate<"Subtarget->hasDataBarrier()">,
244 AssemblerPredicate<"FeatureDB",
246 def HasMP : Predicate<"Subtarget->hasMPExtension()">,
247 AssemblerPredicate<"FeatureMP",
249 def HasVirtualization: Predicate<"false">,
250 AssemblerPredicate<"FeatureVirtualization",
251 "virtualization-extensions">;
252 def HasTrustZone : Predicate<"Subtarget->hasTrustZone()">,
253 AssemblerPredicate<"FeatureTrustZone",
255 def HasZCZ : Predicate<"Subtarget->hasZeroCycleZeroing()">;
256 def UseNEONForFP : Predicate<"Subtarget->useNEONForSinglePrecisionFP()">;
257 def DontUseNEONForFP : Predicate<"!Subtarget->useNEONForSinglePrecisionFP()">;
258 def IsThumb : Predicate<"Subtarget->isThumb()">,
259 AssemblerPredicate<"ModeThumb", "thumb">;
260 def IsThumb1Only : Predicate<"Subtarget->isThumb1Only()">;
261 def IsThumb2 : Predicate<"Subtarget->isThumb2()">,
262 AssemblerPredicate<"ModeThumb,FeatureThumb2",
264 def IsMClass : Predicate<"Subtarget->isMClass()">,
265 AssemblerPredicate<"FeatureMClass", "armv*m">;
266 def IsNotMClass : Predicate<"!Subtarget->isMClass()">,
267 AssemblerPredicate<"!FeatureMClass",
269 def IsARM : Predicate<"!Subtarget->isThumb()">,
270 AssemblerPredicate<"!ModeThumb", "arm-mode">;
271 def IsMachO : Predicate<"Subtarget->isTargetMachO()">;
272 def IsNotMachO : Predicate<"!Subtarget->isTargetMachO()">;
273 def IsNaCl : Predicate<"Subtarget->isTargetNaCl()">;
274 def UseNaClTrap : Predicate<"Subtarget->useNaClTrap()">,
275 AssemblerPredicate<"FeatureNaClTrap", "NaCl">;
276 def DontUseNaClTrap : Predicate<"!Subtarget->useNaClTrap()">;
278 // FIXME: Eventually this will be just "hasV6T2Ops".
279 def UseMovt : Predicate<"Subtarget->useMovt(*MF)">;
280 def DontUseMovt : Predicate<"!Subtarget->useMovt(*MF)">;
281 def UseFPVMLx : Predicate<"Subtarget->useFPVMLx()">;
282 def UseMulOps : Predicate<"Subtarget->useMulOps()">;
284 // Prefer fused MAC for fp mul + add over fp VMLA / VMLS if they are available.
285 // But only select them if more precision in FP computation is allowed.
286 // Do not use them for Darwin platforms.
287 def UseFusedMAC : Predicate<"(TM.Options.AllowFPOpFusion =="
288 " FPOpFusion::Fast && "
289 " Subtarget->hasVFP4()) && "
290 "!Subtarget->isTargetDarwin()">;
291 def DontUseFusedMAC : Predicate<"!(TM.Options.AllowFPOpFusion =="
292 " FPOpFusion::Fast &&"
293 " Subtarget->hasVFP4()) || "
294 "Subtarget->isTargetDarwin()">;
296 // VGETLNi32 is microcoded on Swift - prefer VMOV.
297 def HasFastVGETLNi32 : Predicate<"!Subtarget->isSwift()">;
298 def HasSlowVGETLNi32 : Predicate<"Subtarget->isSwift()">;
300 // VDUP.32 is microcoded on Swift - prefer VMOV.
301 def HasFastVDUP32 : Predicate<"!Subtarget->isSwift()">;
302 def HasSlowVDUP32 : Predicate<"Subtarget->isSwift()">;
304 // Cortex-A9 prefers VMOVSR to VMOVDRR even when using NEON for scalar FP, as
305 // this allows more effective execution domain optimization. See
306 // setExecutionDomain().
307 def UseVMOVSR : Predicate<"Subtarget->isCortexA9() || !Subtarget->useNEONForSinglePrecisionFP()">;
308 def DontUseVMOVSR : Predicate<"!Subtarget->isCortexA9() && Subtarget->useNEONForSinglePrecisionFP()">;
310 def IsLE : Predicate<"getTargetLowering()->isLittleEndian()">;
311 def IsBE : Predicate<"getTargetLowering()->isBigEndian()">;
313 //===----------------------------------------------------------------------===//
314 // ARM Flag Definitions.
316 class RegConstraint<string C> {
317 string Constraints = C;
320 //===----------------------------------------------------------------------===//
321 // ARM specific transformation functions and pattern fragments.
324 // imm_neg_XFORM - Return the negation of an i32 immediate value.
325 def imm_neg_XFORM : SDNodeXForm<imm, [{
326 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), SDLoc(N), MVT::i32);
329 // imm_not_XFORM - Return the complement of a i32 immediate value.
330 def imm_not_XFORM : SDNodeXForm<imm, [{
331 return CurDAG->getTargetConstant(~(int)N->getZExtValue(), SDLoc(N), MVT::i32);
334 /// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
335 def imm16_31 : ImmLeaf<i32, [{
336 return (int32_t)Imm >= 16 && (int32_t)Imm < 32;
339 // sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
340 def sext_16_node : PatLeaf<(i32 GPR:$a), [{
341 return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17;
344 /// Split a 32-bit immediate into two 16 bit parts.
345 def hi16 : SDNodeXForm<imm, [{
346 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, SDLoc(N),
350 def lo16AllZero : PatLeaf<(i32 imm), [{
351 // Returns true if all low 16-bits are 0.
352 return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
355 class BinOpWithFlagFrag<dag res> :
356 PatFrag<(ops node:$LHS, node:$RHS, node:$FLAG), res>;
357 class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
358 class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
360 // An 'and' node with a single use.
361 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
362 return N->hasOneUse();
365 // An 'xor' node with a single use.
366 def xor_su : PatFrag<(ops node:$lhs, node:$rhs), (xor node:$lhs, node:$rhs), [{
367 return N->hasOneUse();
370 // An 'fmul' node with a single use.
371 def fmul_su : PatFrag<(ops node:$lhs, node:$rhs), (fmul node:$lhs, node:$rhs),[{
372 return N->hasOneUse();
375 // An 'fadd' node which checks for single non-hazardous use.
376 def fadd_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fadd node:$lhs, node:$rhs),[{
377 return hasNoVMLxHazardUse(N);
380 // An 'fsub' node which checks for single non-hazardous use.
381 def fsub_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fsub node:$lhs, node:$rhs),[{
382 return hasNoVMLxHazardUse(N);
385 //===----------------------------------------------------------------------===//
386 // Operand Definitions.
389 // Immediate operands with a shared generic asm render method.
390 class ImmAsmOperand : AsmOperandClass { let RenderMethod = "addImmOperands"; }
392 // Operands that are part of a memory addressing mode.
393 class MemOperand : Operand<i32> { let OperandType = "OPERAND_MEMORY"; }
396 // FIXME: rename brtarget to t2_brtarget
397 def brtarget : Operand<OtherVT> {
398 let EncoderMethod = "getBranchTargetOpValue";
399 let OperandType = "OPERAND_PCREL";
400 let DecoderMethod = "DecodeT2BROperand";
403 // FIXME: get rid of this one?
404 def uncondbrtarget : Operand<OtherVT> {
405 let EncoderMethod = "getUnconditionalBranchTargetOpValue";
406 let OperandType = "OPERAND_PCREL";
409 // Branch target for ARM. Handles conditional/unconditional
410 def br_target : Operand<OtherVT> {
411 let EncoderMethod = "getARMBranchTargetOpValue";
412 let OperandType = "OPERAND_PCREL";
416 // FIXME: rename bltarget to t2_bl_target?
417 def bltarget : Operand<i32> {
418 // Encoded the same as branch targets.
419 let EncoderMethod = "getBranchTargetOpValue";
420 let OperandType = "OPERAND_PCREL";
423 // Call target for ARM. Handles conditional/unconditional
424 // FIXME: rename bl_target to t2_bltarget?
425 def bl_target : Operand<i32> {
426 let EncoderMethod = "getARMBLTargetOpValue";
427 let OperandType = "OPERAND_PCREL";
430 def blx_target : Operand<i32> {
431 let EncoderMethod = "getARMBLXTargetOpValue";
432 let OperandType = "OPERAND_PCREL";
435 // A list of registers separated by comma. Used by load/store multiple.
436 def RegListAsmOperand : AsmOperandClass { let Name = "RegList"; }
437 def reglist : Operand<i32> {
438 let EncoderMethod = "getRegisterListOpValue";
439 let ParserMatchClass = RegListAsmOperand;
440 let PrintMethod = "printRegisterList";
441 let DecoderMethod = "DecodeRegListOperand";
444 def GPRPairOp : RegisterOperand<GPRPair, "printGPRPairOperand">;
446 def DPRRegListAsmOperand : AsmOperandClass { let Name = "DPRRegList"; }
447 def dpr_reglist : Operand<i32> {
448 let EncoderMethod = "getRegisterListOpValue";
449 let ParserMatchClass = DPRRegListAsmOperand;
450 let PrintMethod = "printRegisterList";
451 let DecoderMethod = "DecodeDPRRegListOperand";
454 def SPRRegListAsmOperand : AsmOperandClass { let Name = "SPRRegList"; }
455 def spr_reglist : Operand<i32> {
456 let EncoderMethod = "getRegisterListOpValue";
457 let ParserMatchClass = SPRRegListAsmOperand;
458 let PrintMethod = "printRegisterList";
459 let DecoderMethod = "DecodeSPRRegListOperand";
462 // An operand for the CONSTPOOL_ENTRY pseudo-instruction.
463 def cpinst_operand : Operand<i32> {
464 let PrintMethod = "printCPInstOperand";
468 def pclabel : Operand<i32> {
469 let PrintMethod = "printPCLabel";
472 // ADR instruction labels.
473 def AdrLabelAsmOperand : AsmOperandClass { let Name = "AdrLabel"; }
474 def adrlabel : Operand<i32> {
475 let EncoderMethod = "getAdrLabelOpValue";
476 let ParserMatchClass = AdrLabelAsmOperand;
477 let PrintMethod = "printAdrLabelOperand<0>";
480 def neon_vcvt_imm32 : Operand<i32> {
481 let EncoderMethod = "getNEONVcvtImm32OpValue";
482 let DecoderMethod = "DecodeVCVTImmOperand";
485 // rot_imm: An integer that encodes a rotate amount. Must be 8, 16, or 24.
486 def rot_imm_XFORM: SDNodeXForm<imm, [{
487 switch (N->getZExtValue()){
488 default: llvm_unreachable(nullptr);
489 case 0: return CurDAG->getTargetConstant(0, SDLoc(N), MVT::i32);
490 case 8: return CurDAG->getTargetConstant(1, SDLoc(N), MVT::i32);
491 case 16: return CurDAG->getTargetConstant(2, SDLoc(N), MVT::i32);
492 case 24: return CurDAG->getTargetConstant(3, SDLoc(N), MVT::i32);
495 def RotImmAsmOperand : AsmOperandClass {
497 let ParserMethod = "parseRotImm";
499 def rot_imm : Operand<i32>, PatLeaf<(i32 imm), [{
500 int32_t v = N->getZExtValue();
501 return v == 8 || v == 16 || v == 24; }],
503 let PrintMethod = "printRotImmOperand";
504 let ParserMatchClass = RotImmAsmOperand;
507 // shift_imm: An integer that encodes a shift amount and the type of shift
508 // (asr or lsl). The 6-bit immediate encodes as:
511 // {4-0} imm5 shift amount.
512 // asr #32 encoded as imm5 == 0.
513 def ShifterImmAsmOperand : AsmOperandClass {
514 let Name = "ShifterImm";
515 let ParserMethod = "parseShifterImm";
517 def shift_imm : Operand<i32> {
518 let PrintMethod = "printShiftImmOperand";
519 let ParserMatchClass = ShifterImmAsmOperand;
522 // shifter_operand operands: so_reg_reg, so_reg_imm, and mod_imm.
523 def ShiftedRegAsmOperand : AsmOperandClass { let Name = "RegShiftedReg"; }
524 def so_reg_reg : Operand<i32>, // reg reg imm
525 ComplexPattern<i32, 3, "SelectRegShifterOperand",
526 [shl, srl, sra, rotr]> {
527 let EncoderMethod = "getSORegRegOpValue";
528 let PrintMethod = "printSORegRegOperand";
529 let DecoderMethod = "DecodeSORegRegOperand";
530 let ParserMatchClass = ShiftedRegAsmOperand;
531 let MIOperandInfo = (ops GPRnopc, GPRnopc, i32imm);
534 def ShiftedImmAsmOperand : AsmOperandClass { let Name = "RegShiftedImm"; }
535 def so_reg_imm : Operand<i32>, // reg imm
536 ComplexPattern<i32, 2, "SelectImmShifterOperand",
537 [shl, srl, sra, rotr]> {
538 let EncoderMethod = "getSORegImmOpValue";
539 let PrintMethod = "printSORegImmOperand";
540 let DecoderMethod = "DecodeSORegImmOperand";
541 let ParserMatchClass = ShiftedImmAsmOperand;
542 let MIOperandInfo = (ops GPR, i32imm);
545 // FIXME: Does this need to be distinct from so_reg?
546 def shift_so_reg_reg : Operand<i32>, // reg reg imm
547 ComplexPattern<i32, 3, "SelectShiftRegShifterOperand",
548 [shl,srl,sra,rotr]> {
549 let EncoderMethod = "getSORegRegOpValue";
550 let PrintMethod = "printSORegRegOperand";
551 let DecoderMethod = "DecodeSORegRegOperand";
552 let ParserMatchClass = ShiftedRegAsmOperand;
553 let MIOperandInfo = (ops GPR, GPR, i32imm);
556 // FIXME: Does this need to be distinct from so_reg?
557 def shift_so_reg_imm : Operand<i32>, // reg reg imm
558 ComplexPattern<i32, 2, "SelectShiftImmShifterOperand",
559 [shl,srl,sra,rotr]> {
560 let EncoderMethod = "getSORegImmOpValue";
561 let PrintMethod = "printSORegImmOperand";
562 let DecoderMethod = "DecodeSORegImmOperand";
563 let ParserMatchClass = ShiftedImmAsmOperand;
564 let MIOperandInfo = (ops GPR, i32imm);
567 // mod_imm: match a 32-bit immediate operand, which can be encoded into
568 // a 12-bit immediate; an 8-bit integer and a 4-bit rotator (See ARMARM
569 // - "Modified Immediate Constants"). Within the MC layer we keep this
570 // immediate in its encoded form.
571 def ModImmAsmOperand: AsmOperandClass {
573 let ParserMethod = "parseModImm";
575 def mod_imm : Operand<i32>, ImmLeaf<i32, [{
576 return ARM_AM::getSOImmVal(Imm) != -1;
578 let EncoderMethod = "getModImmOpValue";
579 let PrintMethod = "printModImmOperand";
580 let ParserMatchClass = ModImmAsmOperand;
583 // Note: the patterns mod_imm_not and mod_imm_neg do not require an encoder
584 // method and such, as they are only used on aliases (Pat<> and InstAlias<>).
585 // The actual parsing, encoding, decoding are handled by the destination
586 // instructions, which use mod_imm.
588 def ModImmNotAsmOperand : AsmOperandClass { let Name = "ModImmNot"; }
589 def mod_imm_not : Operand<i32>, PatLeaf<(imm), [{
590 return ARM_AM::getSOImmVal(~(uint32_t)N->getZExtValue()) != -1;
592 let ParserMatchClass = ModImmNotAsmOperand;
595 def ModImmNegAsmOperand : AsmOperandClass { let Name = "ModImmNeg"; }
596 def mod_imm_neg : Operand<i32>, PatLeaf<(imm), [{
597 unsigned Value = -(unsigned)N->getZExtValue();
598 return Value && ARM_AM::getSOImmVal(Value) != -1;
600 let ParserMatchClass = ModImmNegAsmOperand;
603 /// arm_i32imm - True for +V6T2, or when isSOImmTwoParVal()
604 def arm_i32imm : PatLeaf<(imm), [{
605 if (Subtarget->useMovt(*MF))
607 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
610 /// imm0_1 predicate - Immediate in the range [0,1].
611 def Imm0_1AsmOperand: ImmAsmOperand { let Name = "Imm0_1"; }
612 def imm0_1 : Operand<i32> { let ParserMatchClass = Imm0_1AsmOperand; }
614 /// imm0_3 predicate - Immediate in the range [0,3].
615 def Imm0_3AsmOperand: ImmAsmOperand { let Name = "Imm0_3"; }
616 def imm0_3 : Operand<i32> { let ParserMatchClass = Imm0_3AsmOperand; }
618 /// imm0_7 predicate - Immediate in the range [0,7].
619 def Imm0_7AsmOperand: ImmAsmOperand { let Name = "Imm0_7"; }
620 def imm0_7 : Operand<i32>, ImmLeaf<i32, [{
621 return Imm >= 0 && Imm < 8;
623 let ParserMatchClass = Imm0_7AsmOperand;
626 /// imm8 predicate - Immediate is exactly 8.
627 def Imm8AsmOperand: ImmAsmOperand { let Name = "Imm8"; }
628 def imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 8; }]> {
629 let ParserMatchClass = Imm8AsmOperand;
632 /// imm16 predicate - Immediate is exactly 16.
633 def Imm16AsmOperand: ImmAsmOperand { let Name = "Imm16"; }
634 def imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 16; }]> {
635 let ParserMatchClass = Imm16AsmOperand;
638 /// imm32 predicate - Immediate is exactly 32.
639 def Imm32AsmOperand: ImmAsmOperand { let Name = "Imm32"; }
640 def imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 32; }]> {
641 let ParserMatchClass = Imm32AsmOperand;
644 def imm8_or_16 : ImmLeaf<i32, [{ return Imm == 8 || Imm == 16;}]>;
646 /// imm1_7 predicate - Immediate in the range [1,7].
647 def Imm1_7AsmOperand: ImmAsmOperand { let Name = "Imm1_7"; }
648 def imm1_7 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 8; }]> {
649 let ParserMatchClass = Imm1_7AsmOperand;
652 /// imm1_15 predicate - Immediate in the range [1,15].
653 def Imm1_15AsmOperand: ImmAsmOperand { let Name = "Imm1_15"; }
654 def imm1_15 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 16; }]> {
655 let ParserMatchClass = Imm1_15AsmOperand;
658 /// imm1_31 predicate - Immediate in the range [1,31].
659 def Imm1_31AsmOperand: ImmAsmOperand { let Name = "Imm1_31"; }
660 def imm1_31 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 32; }]> {
661 let ParserMatchClass = Imm1_31AsmOperand;
664 /// imm0_15 predicate - Immediate in the range [0,15].
665 def Imm0_15AsmOperand: ImmAsmOperand {
666 let Name = "Imm0_15";
667 let DiagnosticType = "ImmRange0_15";
669 def imm0_15 : Operand<i32>, ImmLeaf<i32, [{
670 return Imm >= 0 && Imm < 16;
672 let ParserMatchClass = Imm0_15AsmOperand;
675 /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
676 def Imm0_31AsmOperand: ImmAsmOperand { let Name = "Imm0_31"; }
677 def imm0_31 : Operand<i32>, ImmLeaf<i32, [{
678 return Imm >= 0 && Imm < 32;
680 let ParserMatchClass = Imm0_31AsmOperand;
683 /// imm0_32 predicate - True if the 32-bit immediate is in the range [0,32].
684 def Imm0_32AsmOperand: ImmAsmOperand { let Name = "Imm0_32"; }
685 def imm0_32 : Operand<i32>, ImmLeaf<i32, [{
686 return Imm >= 0 && Imm < 32;
688 let ParserMatchClass = Imm0_32AsmOperand;
691 /// imm0_63 predicate - True if the 32-bit immediate is in the range [0,63].
692 def Imm0_63AsmOperand: ImmAsmOperand { let Name = "Imm0_63"; }
693 def imm0_63 : Operand<i32>, ImmLeaf<i32, [{
694 return Imm >= 0 && Imm < 64;
696 let ParserMatchClass = Imm0_63AsmOperand;
699 /// imm0_239 predicate - Immediate in the range [0,239].
700 def Imm0_239AsmOperand : ImmAsmOperand {
701 let Name = "Imm0_239";
702 let DiagnosticType = "ImmRange0_239";
704 def imm0_239 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 240; }]> {
705 let ParserMatchClass = Imm0_239AsmOperand;
708 /// imm0_255 predicate - Immediate in the range [0,255].
709 def Imm0_255AsmOperand : ImmAsmOperand { let Name = "Imm0_255"; }
710 def imm0_255 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 256; }]> {
711 let ParserMatchClass = Imm0_255AsmOperand;
714 /// imm0_65535 - An immediate is in the range [0.65535].
715 def Imm0_65535AsmOperand: ImmAsmOperand { let Name = "Imm0_65535"; }
716 def imm0_65535 : Operand<i32>, ImmLeaf<i32, [{
717 return Imm >= 0 && Imm < 65536;
719 let ParserMatchClass = Imm0_65535AsmOperand;
722 // imm0_65535_neg - An immediate whose negative value is in the range [0.65535].
723 def imm0_65535_neg : Operand<i32>, ImmLeaf<i32, [{
724 return -Imm >= 0 && -Imm < 65536;
727 // imm0_65535_expr - For movt/movw - 16-bit immediate that can also reference
728 // a relocatable expression.
730 // FIXME: This really needs a Thumb version separate from the ARM version.
731 // While the range is the same, and can thus use the same match class,
732 // the encoding is different so it should have a different encoder method.
733 def Imm0_65535ExprAsmOperand: ImmAsmOperand { let Name = "Imm0_65535Expr"; }
734 def imm0_65535_expr : Operand<i32> {
735 let EncoderMethod = "getHiLo16ImmOpValue";
736 let ParserMatchClass = Imm0_65535ExprAsmOperand;
739 def Imm256_65535ExprAsmOperand: ImmAsmOperand { let Name = "Imm256_65535Expr"; }
740 def imm256_65535_expr : Operand<i32> {
741 let ParserMatchClass = Imm256_65535ExprAsmOperand;
744 /// imm24b - True if the 32-bit immediate is encodable in 24 bits.
745 def Imm24bitAsmOperand: ImmAsmOperand { let Name = "Imm24bit"; }
746 def imm24b : Operand<i32>, ImmLeaf<i32, [{
747 return Imm >= 0 && Imm <= 0xffffff;
749 let ParserMatchClass = Imm24bitAsmOperand;
753 /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
755 def BitfieldAsmOperand : AsmOperandClass {
756 let Name = "Bitfield";
757 let ParserMethod = "parseBitfield";
760 def bf_inv_mask_imm : Operand<i32>,
762 return ARM::isBitFieldInvertedMask(N->getZExtValue());
764 let EncoderMethod = "getBitfieldInvertedMaskOpValue";
765 let PrintMethod = "printBitfieldInvMaskImmOperand";
766 let DecoderMethod = "DecodeBitfieldMaskOperand";
767 let ParserMatchClass = BitfieldAsmOperand;
770 def imm1_32_XFORM: SDNodeXForm<imm, [{
771 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, SDLoc(N),
774 def Imm1_32AsmOperand: AsmOperandClass { let Name = "Imm1_32"; }
775 def imm1_32 : Operand<i32>, PatLeaf<(imm), [{
776 uint64_t Imm = N->getZExtValue();
777 return Imm > 0 && Imm <= 32;
780 let PrintMethod = "printImmPlusOneOperand";
781 let ParserMatchClass = Imm1_32AsmOperand;
784 def imm1_16_XFORM: SDNodeXForm<imm, [{
785 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, SDLoc(N),
788 def Imm1_16AsmOperand: AsmOperandClass { let Name = "Imm1_16"; }
789 def imm1_16 : Operand<i32>, PatLeaf<(imm), [{ return Imm > 0 && Imm <= 16; }],
791 let PrintMethod = "printImmPlusOneOperand";
792 let ParserMatchClass = Imm1_16AsmOperand;
795 // Define ARM specific addressing modes.
796 // addrmode_imm12 := reg +/- imm12
798 def MemImm12OffsetAsmOperand : AsmOperandClass { let Name = "MemImm12Offset"; }
799 class AddrMode_Imm12 : MemOperand,
800 ComplexPattern<i32, 2, "SelectAddrModeImm12", []> {
801 // 12-bit immediate operand. Note that instructions using this encode
802 // #0 and #-0 differently. We flag #-0 as the magic value INT32_MIN. All other
803 // immediate values are as normal.
805 let EncoderMethod = "getAddrModeImm12OpValue";
806 let DecoderMethod = "DecodeAddrModeImm12Operand";
807 let ParserMatchClass = MemImm12OffsetAsmOperand;
808 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
811 def addrmode_imm12 : AddrMode_Imm12 {
812 let PrintMethod = "printAddrModeImm12Operand<false>";
815 def addrmode_imm12_pre : AddrMode_Imm12 {
816 let PrintMethod = "printAddrModeImm12Operand<true>";
819 // ldst_so_reg := reg +/- reg shop imm
821 def MemRegOffsetAsmOperand : AsmOperandClass { let Name = "MemRegOffset"; }
822 def ldst_so_reg : MemOperand,
823 ComplexPattern<i32, 3, "SelectLdStSOReg", []> {
824 let EncoderMethod = "getLdStSORegOpValue";
825 // FIXME: Simplify the printer
826 let PrintMethod = "printAddrMode2Operand";
827 let DecoderMethod = "DecodeSORegMemOperand";
828 let ParserMatchClass = MemRegOffsetAsmOperand;
829 let MIOperandInfo = (ops GPR:$base, GPRnopc:$offsreg, i32imm:$shift);
832 // postidx_imm8 := +/- [0,255]
835 // {8} 1 is imm8 is non-negative. 0 otherwise.
836 // {7-0} [0,255] imm8 value.
837 def PostIdxImm8AsmOperand : AsmOperandClass { let Name = "PostIdxImm8"; }
838 def postidx_imm8 : MemOperand {
839 let PrintMethod = "printPostIdxImm8Operand";
840 let ParserMatchClass = PostIdxImm8AsmOperand;
841 let MIOperandInfo = (ops i32imm);
844 // postidx_imm8s4 := +/- [0,1020]
847 // {8} 1 is imm8 is non-negative. 0 otherwise.
848 // {7-0} [0,255] imm8 value, scaled by 4.
849 def PostIdxImm8s4AsmOperand : AsmOperandClass { let Name = "PostIdxImm8s4"; }
850 def postidx_imm8s4 : MemOperand {
851 let PrintMethod = "printPostIdxImm8s4Operand";
852 let ParserMatchClass = PostIdxImm8s4AsmOperand;
853 let MIOperandInfo = (ops i32imm);
857 // postidx_reg := +/- reg
859 def PostIdxRegAsmOperand : AsmOperandClass {
860 let Name = "PostIdxReg";
861 let ParserMethod = "parsePostIdxReg";
863 def postidx_reg : MemOperand {
864 let EncoderMethod = "getPostIdxRegOpValue";
865 let DecoderMethod = "DecodePostIdxReg";
866 let PrintMethod = "printPostIdxRegOperand";
867 let ParserMatchClass = PostIdxRegAsmOperand;
868 let MIOperandInfo = (ops GPRnopc, i32imm);
872 // addrmode2 := reg +/- imm12
873 // := reg +/- reg shop imm
875 // FIXME: addrmode2 should be refactored the rest of the way to always
876 // use explicit imm vs. reg versions above (addrmode_imm12 and ldst_so_reg).
877 def AddrMode2AsmOperand : AsmOperandClass { let Name = "AddrMode2"; }
878 def addrmode2 : MemOperand,
879 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
880 let EncoderMethod = "getAddrMode2OpValue";
881 let PrintMethod = "printAddrMode2Operand";
882 let ParserMatchClass = AddrMode2AsmOperand;
883 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
886 def PostIdxRegShiftedAsmOperand : AsmOperandClass {
887 let Name = "PostIdxRegShifted";
888 let ParserMethod = "parsePostIdxReg";
890 def am2offset_reg : MemOperand,
891 ComplexPattern<i32, 2, "SelectAddrMode2OffsetReg",
892 [], [SDNPWantRoot]> {
893 let EncoderMethod = "getAddrMode2OffsetOpValue";
894 let PrintMethod = "printAddrMode2OffsetOperand";
895 // When using this for assembly, it's always as a post-index offset.
896 let ParserMatchClass = PostIdxRegShiftedAsmOperand;
897 let MIOperandInfo = (ops GPRnopc, i32imm);
900 // FIXME: am2offset_imm should only need the immediate, not the GPR. Having
901 // the GPR is purely vestigal at this point.
902 def AM2OffsetImmAsmOperand : AsmOperandClass { let Name = "AM2OffsetImm"; }
903 def am2offset_imm : MemOperand,
904 ComplexPattern<i32, 2, "SelectAddrMode2OffsetImm",
905 [], [SDNPWantRoot]> {
906 let EncoderMethod = "getAddrMode2OffsetOpValue";
907 let PrintMethod = "printAddrMode2OffsetOperand";
908 let ParserMatchClass = AM2OffsetImmAsmOperand;
909 let MIOperandInfo = (ops GPRnopc, i32imm);
913 // addrmode3 := reg +/- reg
914 // addrmode3 := reg +/- imm8
916 // FIXME: split into imm vs. reg versions.
917 def AddrMode3AsmOperand : AsmOperandClass { let Name = "AddrMode3"; }
918 class AddrMode3 : MemOperand,
919 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
920 let EncoderMethod = "getAddrMode3OpValue";
921 let ParserMatchClass = AddrMode3AsmOperand;
922 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
925 def addrmode3 : AddrMode3
927 let PrintMethod = "printAddrMode3Operand<false>";
930 def addrmode3_pre : AddrMode3
932 let PrintMethod = "printAddrMode3Operand<true>";
935 // FIXME: split into imm vs. reg versions.
936 // FIXME: parser method to handle +/- register.
937 def AM3OffsetAsmOperand : AsmOperandClass {
938 let Name = "AM3Offset";
939 let ParserMethod = "parseAM3Offset";
941 def am3offset : MemOperand,
942 ComplexPattern<i32, 2, "SelectAddrMode3Offset",
943 [], [SDNPWantRoot]> {
944 let EncoderMethod = "getAddrMode3OffsetOpValue";
945 let PrintMethod = "printAddrMode3OffsetOperand";
946 let ParserMatchClass = AM3OffsetAsmOperand;
947 let MIOperandInfo = (ops GPR, i32imm);
950 // ldstm_mode := {ia, ib, da, db}
952 def ldstm_mode : OptionalDefOperand<OtherVT, (ops i32), (ops (i32 1))> {
953 let EncoderMethod = "getLdStmModeOpValue";
954 let PrintMethod = "printLdStmModeOperand";
957 // addrmode5 := reg +/- imm8*4
959 def AddrMode5AsmOperand : AsmOperandClass { let Name = "AddrMode5"; }
960 class AddrMode5 : MemOperand,
961 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
962 let EncoderMethod = "getAddrMode5OpValue";
963 let DecoderMethod = "DecodeAddrMode5Operand";
964 let ParserMatchClass = AddrMode5AsmOperand;
965 let MIOperandInfo = (ops GPR:$base, i32imm);
968 def addrmode5 : AddrMode5 {
969 let PrintMethod = "printAddrMode5Operand<false>";
972 def addrmode5_pre : AddrMode5 {
973 let PrintMethod = "printAddrMode5Operand<true>";
976 // addrmode6 := reg with optional alignment
978 def AddrMode6AsmOperand : AsmOperandClass { let Name = "AlignedMemory"; }
979 def addrmode6 : MemOperand,
980 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
981 let PrintMethod = "printAddrMode6Operand";
982 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
983 let EncoderMethod = "getAddrMode6AddressOpValue";
984 let DecoderMethod = "DecodeAddrMode6Operand";
985 let ParserMatchClass = AddrMode6AsmOperand;
988 def am6offset : MemOperand,
989 ComplexPattern<i32, 1, "SelectAddrMode6Offset",
990 [], [SDNPWantRoot]> {
991 let PrintMethod = "printAddrMode6OffsetOperand";
992 let MIOperandInfo = (ops GPR);
993 let EncoderMethod = "getAddrMode6OffsetOpValue";
994 let DecoderMethod = "DecodeGPRRegisterClass";
997 // Special version of addrmode6 to handle alignment encoding for VST1/VLD1
998 // (single element from one lane) for size 32.
999 def addrmode6oneL32 : MemOperand,
1000 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1001 let PrintMethod = "printAddrMode6Operand";
1002 let MIOperandInfo = (ops GPR:$addr, i32imm);
1003 let EncoderMethod = "getAddrMode6OneLane32AddressOpValue";
1006 // Base class for addrmode6 with specific alignment restrictions.
1007 class AddrMode6Align : MemOperand,
1008 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1009 let PrintMethod = "printAddrMode6Operand";
1010 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
1011 let EncoderMethod = "getAddrMode6AddressOpValue";
1012 let DecoderMethod = "DecodeAddrMode6Operand";
1015 // Special version of addrmode6 to handle no allowed alignment encoding for
1016 // VLD/VST instructions and checking the alignment is not specified.
1017 def AddrMode6AlignNoneAsmOperand : AsmOperandClass {
1018 let Name = "AlignedMemoryNone";
1019 let DiagnosticType = "AlignedMemoryRequiresNone";
1021 def addrmode6alignNone : AddrMode6Align {
1022 // The alignment specifier can only be omitted.
1023 let ParserMatchClass = AddrMode6AlignNoneAsmOperand;
1026 // Special version of addrmode6 to handle 16-bit alignment encoding for
1027 // VLD/VST instructions and checking the alignment value.
1028 def AddrMode6Align16AsmOperand : AsmOperandClass {
1029 let Name = "AlignedMemory16";
1030 let DiagnosticType = "AlignedMemoryRequires16";
1032 def addrmode6align16 : AddrMode6Align {
1033 // The alignment specifier can only be 16 or omitted.
1034 let ParserMatchClass = AddrMode6Align16AsmOperand;
1037 // Special version of addrmode6 to handle 32-bit alignment encoding for
1038 // VLD/VST instructions and checking the alignment value.
1039 def AddrMode6Align32AsmOperand : AsmOperandClass {
1040 let Name = "AlignedMemory32";
1041 let DiagnosticType = "AlignedMemoryRequires32";
1043 def addrmode6align32 : AddrMode6Align {
1044 // The alignment specifier can only be 32 or omitted.
1045 let ParserMatchClass = AddrMode6Align32AsmOperand;
1048 // Special version of addrmode6 to handle 64-bit alignment encoding for
1049 // VLD/VST instructions and checking the alignment value.
1050 def AddrMode6Align64AsmOperand : AsmOperandClass {
1051 let Name = "AlignedMemory64";
1052 let DiagnosticType = "AlignedMemoryRequires64";
1054 def addrmode6align64 : AddrMode6Align {
1055 // The alignment specifier can only be 64 or omitted.
1056 let ParserMatchClass = AddrMode6Align64AsmOperand;
1059 // Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding
1060 // for VLD/VST instructions and checking the alignment value.
1061 def AddrMode6Align64or128AsmOperand : AsmOperandClass {
1062 let Name = "AlignedMemory64or128";
1063 let DiagnosticType = "AlignedMemoryRequires64or128";
1065 def addrmode6align64or128 : AddrMode6Align {
1066 // The alignment specifier can only be 64, 128 or omitted.
1067 let ParserMatchClass = AddrMode6Align64or128AsmOperand;
1070 // Special version of addrmode6 to handle 64-bit, 128-bit or 256-bit alignment
1071 // encoding for VLD/VST instructions and checking the alignment value.
1072 def AddrMode6Align64or128or256AsmOperand : AsmOperandClass {
1073 let Name = "AlignedMemory64or128or256";
1074 let DiagnosticType = "AlignedMemoryRequires64or128or256";
1076 def addrmode6align64or128or256 : AddrMode6Align {
1077 // The alignment specifier can only be 64, 128, 256 or omitted.
1078 let ParserMatchClass = AddrMode6Align64or128or256AsmOperand;
1081 // Special version of addrmode6 to handle alignment encoding for VLD-dup
1082 // instructions, specifically VLD4-dup.
1083 def addrmode6dup : MemOperand,
1084 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1085 let PrintMethod = "printAddrMode6Operand";
1086 let MIOperandInfo = (ops GPR:$addr, i32imm);
1087 let EncoderMethod = "getAddrMode6DupAddressOpValue";
1088 // FIXME: This is close, but not quite right. The alignment specifier is
1090 let ParserMatchClass = AddrMode6AsmOperand;
1093 // Base class for addrmode6dup with specific alignment restrictions.
1094 class AddrMode6DupAlign : MemOperand,
1095 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1096 let PrintMethod = "printAddrMode6Operand";
1097 let MIOperandInfo = (ops GPR:$addr, i32imm);
1098 let EncoderMethod = "getAddrMode6DupAddressOpValue";
1101 // Special version of addrmode6 to handle no allowed alignment encoding for
1102 // VLD-dup instruction and checking the alignment is not specified.
1103 def AddrMode6dupAlignNoneAsmOperand : AsmOperandClass {
1104 let Name = "DupAlignedMemoryNone";
1105 let DiagnosticType = "DupAlignedMemoryRequiresNone";
1107 def addrmode6dupalignNone : AddrMode6DupAlign {
1108 // The alignment specifier can only be omitted.
1109 let ParserMatchClass = AddrMode6dupAlignNoneAsmOperand;
1112 // Special version of addrmode6 to handle 16-bit alignment encoding for VLD-dup
1113 // instruction and checking the alignment value.
1114 def AddrMode6dupAlign16AsmOperand : AsmOperandClass {
1115 let Name = "DupAlignedMemory16";
1116 let DiagnosticType = "DupAlignedMemoryRequires16";
1118 def addrmode6dupalign16 : AddrMode6DupAlign {
1119 // The alignment specifier can only be 16 or omitted.
1120 let ParserMatchClass = AddrMode6dupAlign16AsmOperand;
1123 // Special version of addrmode6 to handle 32-bit alignment encoding for VLD-dup
1124 // instruction and checking the alignment value.
1125 def AddrMode6dupAlign32AsmOperand : AsmOperandClass {
1126 let Name = "DupAlignedMemory32";
1127 let DiagnosticType = "DupAlignedMemoryRequires32";
1129 def addrmode6dupalign32 : AddrMode6DupAlign {
1130 // The alignment specifier can only be 32 or omitted.
1131 let ParserMatchClass = AddrMode6dupAlign32AsmOperand;
1134 // Special version of addrmode6 to handle 64-bit alignment encoding for VLD
1135 // instructions and checking the alignment value.
1136 def AddrMode6dupAlign64AsmOperand : AsmOperandClass {
1137 let Name = "DupAlignedMemory64";
1138 let DiagnosticType = "DupAlignedMemoryRequires64";
1140 def addrmode6dupalign64 : AddrMode6DupAlign {
1141 // The alignment specifier can only be 64 or omitted.
1142 let ParserMatchClass = AddrMode6dupAlign64AsmOperand;
1145 // Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding
1146 // for VLD instructions and checking the alignment value.
1147 def AddrMode6dupAlign64or128AsmOperand : AsmOperandClass {
1148 let Name = "DupAlignedMemory64or128";
1149 let DiagnosticType = "DupAlignedMemoryRequires64or128";
1151 def addrmode6dupalign64or128 : AddrMode6DupAlign {
1152 // The alignment specifier can only be 64, 128 or omitted.
1153 let ParserMatchClass = AddrMode6dupAlign64or128AsmOperand;
1156 // addrmodepc := pc + reg
1158 def addrmodepc : MemOperand,
1159 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
1160 let PrintMethod = "printAddrModePCOperand";
1161 let MIOperandInfo = (ops GPR, i32imm);
1164 // addr_offset_none := reg
1166 def MemNoOffsetAsmOperand : AsmOperandClass { let Name = "MemNoOffset"; }
1167 def addr_offset_none : MemOperand,
1168 ComplexPattern<i32, 1, "SelectAddrOffsetNone", []> {
1169 let PrintMethod = "printAddrMode7Operand";
1170 let DecoderMethod = "DecodeAddrMode7Operand";
1171 let ParserMatchClass = MemNoOffsetAsmOperand;
1172 let MIOperandInfo = (ops GPR:$base);
1175 def nohash_imm : Operand<i32> {
1176 let PrintMethod = "printNoHashImmediate";
1179 def CoprocNumAsmOperand : AsmOperandClass {
1180 let Name = "CoprocNum";
1181 let ParserMethod = "parseCoprocNumOperand";
1183 def p_imm : Operand<i32> {
1184 let PrintMethod = "printPImmediate";
1185 let ParserMatchClass = CoprocNumAsmOperand;
1186 let DecoderMethod = "DecodeCoprocessor";
1189 def CoprocRegAsmOperand : AsmOperandClass {
1190 let Name = "CoprocReg";
1191 let ParserMethod = "parseCoprocRegOperand";
1193 def c_imm : Operand<i32> {
1194 let PrintMethod = "printCImmediate";
1195 let ParserMatchClass = CoprocRegAsmOperand;
1197 def CoprocOptionAsmOperand : AsmOperandClass {
1198 let Name = "CoprocOption";
1199 let ParserMethod = "parseCoprocOptionOperand";
1201 def coproc_option_imm : Operand<i32> {
1202 let PrintMethod = "printCoprocOptionImm";
1203 let ParserMatchClass = CoprocOptionAsmOperand;
1206 //===----------------------------------------------------------------------===//
1208 include "ARMInstrFormats.td"
1210 //===----------------------------------------------------------------------===//
1211 // Multiclass helpers...
1214 /// AsI1_bin_irs - Defines a set of (op r, {mod_imm|r|so_reg}) patterns for a
1215 /// binop that produces a value.
1216 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1217 multiclass AsI1_bin_irs<bits<4> opcod, string opc,
1218 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1219 PatFrag opnode, bit Commutable = 0> {
1220 // The register-immediate version is re-materializable. This is useful
1221 // in particular for taking the address of a local.
1222 let isReMaterializable = 1 in {
1223 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm,
1224 iii, opc, "\t$Rd, $Rn, $imm",
1225 [(set GPR:$Rd, (opnode GPR:$Rn, mod_imm:$imm))]>,
1226 Sched<[WriteALU, ReadALU]> {
1231 let Inst{19-16} = Rn;
1232 let Inst{15-12} = Rd;
1233 let Inst{11-0} = imm;
1236 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1237 iir, opc, "\t$Rd, $Rn, $Rm",
1238 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]>,
1239 Sched<[WriteALU, ReadALU, ReadALU]> {
1244 let isCommutable = Commutable;
1245 let Inst{19-16} = Rn;
1246 let Inst{15-12} = Rd;
1247 let Inst{11-4} = 0b00000000;
1251 def rsi : AsI1<opcod, (outs GPR:$Rd),
1252 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1253 iis, opc, "\t$Rd, $Rn, $shift",
1254 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_imm:$shift))]>,
1255 Sched<[WriteALUsi, ReadALU]> {
1260 let Inst{19-16} = Rn;
1261 let Inst{15-12} = Rd;
1262 let Inst{11-5} = shift{11-5};
1264 let Inst{3-0} = shift{3-0};
1267 def rsr : AsI1<opcod, (outs GPR:$Rd),
1268 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1269 iis, opc, "\t$Rd, $Rn, $shift",
1270 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_reg:$shift))]>,
1271 Sched<[WriteALUsr, ReadALUsr]> {
1276 let Inst{19-16} = Rn;
1277 let Inst{15-12} = Rd;
1278 let Inst{11-8} = shift{11-8};
1280 let Inst{6-5} = shift{6-5};
1282 let Inst{3-0} = shift{3-0};
1286 /// AsI1_rbin_irs - Same as AsI1_bin_irs except the order of operands are
1287 /// reversed. The 'rr' form is only defined for the disassembler; for codegen
1288 /// it is equivalent to the AsI1_bin_irs counterpart.
1289 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1290 multiclass AsI1_rbin_irs<bits<4> opcod, string opc,
1291 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1292 PatFrag opnode, bit Commutable = 0> {
1293 // The register-immediate version is re-materializable. This is useful
1294 // in particular for taking the address of a local.
1295 let isReMaterializable = 1 in {
1296 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm,
1297 iii, opc, "\t$Rd, $Rn, $imm",
1298 [(set GPR:$Rd, (opnode mod_imm:$imm, GPR:$Rn))]>,
1299 Sched<[WriteALU, ReadALU]> {
1304 let Inst{19-16} = Rn;
1305 let Inst{15-12} = Rd;
1306 let Inst{11-0} = imm;
1309 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1310 iir, opc, "\t$Rd, $Rn, $Rm",
1311 [/* pattern left blank */]>,
1312 Sched<[WriteALU, ReadALU, ReadALU]> {
1316 let Inst{11-4} = 0b00000000;
1319 let Inst{15-12} = Rd;
1320 let Inst{19-16} = Rn;
1323 def rsi : AsI1<opcod, (outs GPR:$Rd),
1324 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1325 iis, opc, "\t$Rd, $Rn, $shift",
1326 [(set GPR:$Rd, (opnode so_reg_imm:$shift, GPR:$Rn))]>,
1327 Sched<[WriteALUsi, ReadALU]> {
1332 let Inst{19-16} = Rn;
1333 let Inst{15-12} = Rd;
1334 let Inst{11-5} = shift{11-5};
1336 let Inst{3-0} = shift{3-0};
1339 def rsr : AsI1<opcod, (outs GPR:$Rd),
1340 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1341 iis, opc, "\t$Rd, $Rn, $shift",
1342 [(set GPR:$Rd, (opnode so_reg_reg:$shift, GPR:$Rn))]>,
1343 Sched<[WriteALUsr, ReadALUsr]> {
1348 let Inst{19-16} = Rn;
1349 let Inst{15-12} = Rd;
1350 let Inst{11-8} = shift{11-8};
1352 let Inst{6-5} = shift{6-5};
1354 let Inst{3-0} = shift{3-0};
1358 /// AsI1_bin_s_irs - Same as AsI1_bin_irs except it sets the 's' bit by default.
1360 /// These opcodes will be converted to the real non-S opcodes by
1361 /// AdjustInstrPostInstrSelection after giving them an optional CPSR operand.
1362 let hasPostISelHook = 1, Defs = [CPSR] in {
1363 multiclass AsI1_bin_s_irs<InstrItinClass iii, InstrItinClass iir,
1364 InstrItinClass iis, PatFrag opnode,
1365 bit Commutable = 0> {
1366 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p),
1368 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm))]>,
1369 Sched<[WriteALU, ReadALU]>;
1371 def rr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, pred:$p),
1373 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm))]>,
1374 Sched<[WriteALU, ReadALU, ReadALU]> {
1375 let isCommutable = Commutable;
1377 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1378 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1380 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1381 so_reg_imm:$shift))]>,
1382 Sched<[WriteALUsi, ReadALU]>;
1384 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1385 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1387 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1388 so_reg_reg:$shift))]>,
1389 Sched<[WriteALUSsr, ReadALUsr]>;
1393 /// AsI1_rbin_s_is - Same as AsI1_bin_s_irs, except selection DAG
1394 /// operands are reversed.
1395 let hasPostISelHook = 1, Defs = [CPSR] in {
1396 multiclass AsI1_rbin_s_is<InstrItinClass iii, InstrItinClass iir,
1397 InstrItinClass iis, PatFrag opnode,
1398 bit Commutable = 0> {
1399 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p),
1401 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn))]>,
1402 Sched<[WriteALU, ReadALU]>;
1404 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1405 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1407 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift,
1409 Sched<[WriteALUsi, ReadALU]>;
1411 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1412 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1414 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift,
1416 Sched<[WriteALUSsr, ReadALUsr]>;
1420 /// AI1_cmp_irs - Defines a set of (op r, {mod_imm|r|so_reg}) cmp / test
1421 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
1422 /// a explicit result, only implicitly set CPSR.
1423 let isCompare = 1, Defs = [CPSR] in {
1424 multiclass AI1_cmp_irs<bits<4> opcod, string opc,
1425 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1426 PatFrag opnode, bit Commutable = 0,
1427 string rrDecoderMethod = ""> {
1428 def ri : AI1<opcod, (outs), (ins GPR:$Rn, mod_imm:$imm), DPFrm, iii,
1430 [(opnode GPR:$Rn, mod_imm:$imm)]>,
1431 Sched<[WriteCMP, ReadALU]> {
1436 let Inst{19-16} = Rn;
1437 let Inst{15-12} = 0b0000;
1438 let Inst{11-0} = imm;
1440 let Unpredictable{15-12} = 0b1111;
1442 def rr : AI1<opcod, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, iir,
1444 [(opnode GPR:$Rn, GPR:$Rm)]>,
1445 Sched<[WriteCMP, ReadALU, ReadALU]> {
1448 let isCommutable = Commutable;
1451 let Inst{19-16} = Rn;
1452 let Inst{15-12} = 0b0000;
1453 let Inst{11-4} = 0b00000000;
1455 let DecoderMethod = rrDecoderMethod;
1457 let Unpredictable{15-12} = 0b1111;
1459 def rsi : AI1<opcod, (outs),
1460 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, iis,
1461 opc, "\t$Rn, $shift",
1462 [(opnode GPR:$Rn, so_reg_imm:$shift)]>,
1463 Sched<[WriteCMPsi, ReadALU]> {
1468 let Inst{19-16} = Rn;
1469 let Inst{15-12} = 0b0000;
1470 let Inst{11-5} = shift{11-5};
1472 let Inst{3-0} = shift{3-0};
1474 let Unpredictable{15-12} = 0b1111;
1476 def rsr : AI1<opcod, (outs),
1477 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, iis,
1478 opc, "\t$Rn, $shift",
1479 [(opnode GPRnopc:$Rn, so_reg_reg:$shift)]>,
1480 Sched<[WriteCMPsr, ReadALU]> {
1485 let Inst{19-16} = Rn;
1486 let Inst{15-12} = 0b0000;
1487 let Inst{11-8} = shift{11-8};
1489 let Inst{6-5} = shift{6-5};
1491 let Inst{3-0} = shift{3-0};
1493 let Unpredictable{15-12} = 0b1111;
1499 /// AI_ext_rrot - A unary operation with two forms: one whose operand is a
1500 /// register and one whose operand is a register rotated by 8/16/24.
1501 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
1502 class AI_ext_rrot<bits<8> opcod, string opc, PatFrag opnode>
1503 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1504 IIC_iEXTr, opc, "\t$Rd, $Rm$rot",
1505 [(set GPRnopc:$Rd, (opnode (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1506 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> {
1510 let Inst{19-16} = 0b1111;
1511 let Inst{15-12} = Rd;
1512 let Inst{11-10} = rot;
1516 class AI_ext_rrot_np<bits<8> opcod, string opc>
1517 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1518 IIC_iEXTr, opc, "\t$Rd, $Rm$rot", []>,
1519 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> {
1521 let Inst{19-16} = 0b1111;
1522 let Inst{11-10} = rot;
1525 /// AI_exta_rrot - A binary operation with two forms: one whose operand is a
1526 /// register and one whose operand is a register rotated by 8/16/24.
1527 class AI_exta_rrot<bits<8> opcod, string opc, PatFrag opnode>
1528 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1529 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot",
1530 [(set GPRnopc:$Rd, (opnode GPR:$Rn,
1531 (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1532 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> {
1537 let Inst{19-16} = Rn;
1538 let Inst{15-12} = Rd;
1539 let Inst{11-10} = rot;
1540 let Inst{9-4} = 0b000111;
1544 class AI_exta_rrot_np<bits<8> opcod, string opc>
1545 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1546 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot", []>,
1547 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> {
1550 let Inst{19-16} = Rn;
1551 let Inst{11-10} = rot;
1554 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
1555 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1556 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
1557 bit Commutable = 0> {
1558 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1559 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm),
1560 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1561 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm, CPSR))]>,
1563 Sched<[WriteALU, ReadALU]> {
1568 let Inst{15-12} = Rd;
1569 let Inst{19-16} = Rn;
1570 let Inst{11-0} = imm;
1572 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1573 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1574 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm, CPSR))]>,
1576 Sched<[WriteALU, ReadALU, ReadALU]> {
1580 let Inst{11-4} = 0b00000000;
1582 let isCommutable = Commutable;
1584 let Inst{15-12} = Rd;
1585 let Inst{19-16} = Rn;
1587 def rsi : AsI1<opcod, (outs GPR:$Rd),
1588 (ins GPR:$Rn, so_reg_imm:$shift),
1589 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1590 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_imm:$shift, CPSR))]>,
1592 Sched<[WriteALUsi, ReadALU]> {
1597 let Inst{19-16} = Rn;
1598 let Inst{15-12} = Rd;
1599 let Inst{11-5} = shift{11-5};
1601 let Inst{3-0} = shift{3-0};
1603 def rsr : AsI1<opcod, (outs GPRnopc:$Rd),
1604 (ins GPRnopc:$Rn, so_reg_reg:$shift),
1605 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1606 [(set GPRnopc:$Rd, CPSR,
1607 (opnode GPRnopc:$Rn, so_reg_reg:$shift, CPSR))]>,
1609 Sched<[WriteALUsr, ReadALUsr]> {
1614 let Inst{19-16} = Rn;
1615 let Inst{15-12} = Rd;
1616 let Inst{11-8} = shift{11-8};
1618 let Inst{6-5} = shift{6-5};
1620 let Inst{3-0} = shift{3-0};
1625 /// AI1_rsc_irs - Define instructions and patterns for rsc
1626 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1627 multiclass AI1_rsc_irs<bits<4> opcod, string opc, PatFrag opnode> {
1628 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1629 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm),
1630 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1631 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn, CPSR))]>,
1633 Sched<[WriteALU, ReadALU]> {
1638 let Inst{15-12} = Rd;
1639 let Inst{19-16} = Rn;
1640 let Inst{11-0} = imm;
1642 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1643 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1644 [/* pattern left blank */]>,
1645 Sched<[WriteALU, ReadALU, ReadALU]> {
1649 let Inst{11-4} = 0b00000000;
1652 let Inst{15-12} = Rd;
1653 let Inst{19-16} = Rn;
1655 def rsi : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_imm:$shift),
1656 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1657 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift, GPR:$Rn, CPSR))]>,
1659 Sched<[WriteALUsi, ReadALU]> {
1664 let Inst{19-16} = Rn;
1665 let Inst{15-12} = Rd;
1666 let Inst{11-5} = shift{11-5};
1668 let Inst{3-0} = shift{3-0};
1670 def rsr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_reg:$shift),
1671 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1672 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift, GPR:$Rn, CPSR))]>,
1674 Sched<[WriteALUsr, ReadALUsr]> {
1679 let Inst{19-16} = Rn;
1680 let Inst{15-12} = Rd;
1681 let Inst{11-8} = shift{11-8};
1683 let Inst{6-5} = shift{6-5};
1685 let Inst{3-0} = shift{3-0};
1690 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1691 multiclass AI_ldr1<bit isByte, string opc, InstrItinClass iii,
1692 InstrItinClass iir, PatFrag opnode> {
1693 // Note: We use the complex addrmode_imm12 rather than just an input
1694 // GPR and a constrained immediate so that we can use this to match
1695 // frame index references and avoid matching constant pool references.
1696 def i12: AI2ldst<0b010, 1, isByte, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
1697 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1698 [(set GPR:$Rt, (opnode addrmode_imm12:$addr))]> {
1701 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1702 let Inst{19-16} = addr{16-13}; // Rn
1703 let Inst{15-12} = Rt;
1704 let Inst{11-0} = addr{11-0}; // imm12
1706 def rs : AI2ldst<0b011, 1, isByte, (outs GPR:$Rt), (ins ldst_so_reg:$shift),
1707 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1708 [(set GPR:$Rt, (opnode ldst_so_reg:$shift))]> {
1711 let shift{4} = 0; // Inst{4} = 0
1712 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1713 let Inst{19-16} = shift{16-13}; // Rn
1714 let Inst{15-12} = Rt;
1715 let Inst{11-0} = shift{11-0};
1720 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1721 multiclass AI_ldr1nopc<bit isByte, string opc, InstrItinClass iii,
1722 InstrItinClass iir, PatFrag opnode> {
1723 // Note: We use the complex addrmode_imm12 rather than just an input
1724 // GPR and a constrained immediate so that we can use this to match
1725 // frame index references and avoid matching constant pool references.
1726 def i12: AI2ldst<0b010, 1, isByte, (outs GPRnopc:$Rt),
1727 (ins addrmode_imm12:$addr),
1728 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1729 [(set GPRnopc:$Rt, (opnode addrmode_imm12:$addr))]> {
1732 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1733 let Inst{19-16} = addr{16-13}; // Rn
1734 let Inst{15-12} = Rt;
1735 let Inst{11-0} = addr{11-0}; // imm12
1737 def rs : AI2ldst<0b011, 1, isByte, (outs GPRnopc:$Rt),
1738 (ins ldst_so_reg:$shift),
1739 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1740 [(set GPRnopc:$Rt, (opnode ldst_so_reg:$shift))]> {
1743 let shift{4} = 0; // Inst{4} = 0
1744 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1745 let Inst{19-16} = shift{16-13}; // Rn
1746 let Inst{15-12} = Rt;
1747 let Inst{11-0} = shift{11-0};
1753 multiclass AI_str1<bit isByte, string opc, InstrItinClass iii,
1754 InstrItinClass iir, PatFrag opnode> {
1755 // Note: We use the complex addrmode_imm12 rather than just an input
1756 // GPR and a constrained immediate so that we can use this to match
1757 // frame index references and avoid matching constant pool references.
1758 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1759 (ins GPR:$Rt, addrmode_imm12:$addr),
1760 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1761 [(opnode GPR:$Rt, addrmode_imm12:$addr)]> {
1764 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1765 let Inst{19-16} = addr{16-13}; // Rn
1766 let Inst{15-12} = Rt;
1767 let Inst{11-0} = addr{11-0}; // imm12
1769 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPR:$Rt, ldst_so_reg:$shift),
1770 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1771 [(opnode GPR:$Rt, ldst_so_reg:$shift)]> {
1774 let shift{4} = 0; // Inst{4} = 0
1775 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1776 let Inst{19-16} = shift{16-13}; // Rn
1777 let Inst{15-12} = Rt;
1778 let Inst{11-0} = shift{11-0};
1782 multiclass AI_str1nopc<bit isByte, string opc, InstrItinClass iii,
1783 InstrItinClass iir, PatFrag opnode> {
1784 // Note: We use the complex addrmode_imm12 rather than just an input
1785 // GPR and a constrained immediate so that we can use this to match
1786 // frame index references and avoid matching constant pool references.
1787 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1788 (ins GPRnopc:$Rt, addrmode_imm12:$addr),
1789 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1790 [(opnode GPRnopc:$Rt, addrmode_imm12:$addr)]> {
1793 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1794 let Inst{19-16} = addr{16-13}; // Rn
1795 let Inst{15-12} = Rt;
1796 let Inst{11-0} = addr{11-0}; // imm12
1798 def rs : AI2ldst<0b011, 0, isByte, (outs),
1799 (ins GPRnopc:$Rt, ldst_so_reg:$shift),
1800 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1801 [(opnode GPRnopc:$Rt, ldst_so_reg:$shift)]> {
1804 let shift{4} = 0; // Inst{4} = 0
1805 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1806 let Inst{19-16} = shift{16-13}; // Rn
1807 let Inst{15-12} = Rt;
1808 let Inst{11-0} = shift{11-0};
1813 //===----------------------------------------------------------------------===//
1815 //===----------------------------------------------------------------------===//
1817 //===----------------------------------------------------------------------===//
1818 // Miscellaneous Instructions.
1821 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
1822 /// the function. The first operand is the ID# for this instruction, the second
1823 /// is the index into the MachineConstantPool that this is, the third is the
1824 /// size in bytes of this constant pool entry.
1825 let hasSideEffects = 0, isNotDuplicable = 1 in
1826 def CONSTPOOL_ENTRY :
1827 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1828 i32imm:$size), NoItinerary, []>;
1830 // FIXME: Marking these as hasSideEffects is necessary to prevent machine DCE
1831 // from removing one half of the matched pairs. That breaks PEI, which assumes
1832 // these will always be in pairs, and asserts if it finds otherwise. Better way?
1833 let Defs = [SP], Uses = [SP], hasSideEffects = 1 in {
1834 def ADJCALLSTACKUP :
1835 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary,
1836 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
1838 def ADJCALLSTACKDOWN :
1839 PseudoInst<(outs), (ins i32imm:$amt, pred:$p), NoItinerary,
1840 [(ARMcallseq_start timm:$amt)]>;
1843 def HINT : AI<(outs), (ins imm0_239:$imm), MiscFrm, NoItinerary,
1844 "hint", "\t$imm", [(int_arm_hint imm0_239:$imm)]>,
1845 Requires<[IsARM, HasV6]> {
1847 let Inst{27-8} = 0b00110010000011110000;
1848 let Inst{7-0} = imm;
1851 def : InstAlias<"nop$p", (HINT 0, pred:$p)>, Requires<[IsARM, HasV6K]>;
1852 def : InstAlias<"yield$p", (HINT 1, pred:$p)>, Requires<[IsARM, HasV6K]>;
1853 def : InstAlias<"wfe$p", (HINT 2, pred:$p)>, Requires<[IsARM, HasV6K]>;
1854 def : InstAlias<"wfi$p", (HINT 3, pred:$p)>, Requires<[IsARM, HasV6K]>;
1855 def : InstAlias<"sev$p", (HINT 4, pred:$p)>, Requires<[IsARM, HasV6K]>;
1856 def : InstAlias<"sevl$p", (HINT 5, pred:$p)>, Requires<[IsARM, HasV8]>;
1858 def SEL : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, NoItinerary, "sel",
1859 "\t$Rd, $Rn, $Rm", []>, Requires<[IsARM, HasV6]> {
1864 let Inst{15-12} = Rd;
1865 let Inst{19-16} = Rn;
1866 let Inst{27-20} = 0b01101000;
1867 let Inst{7-4} = 0b1011;
1868 let Inst{11-8} = 0b1111;
1869 let Unpredictable{11-8} = 0b1111;
1872 // The 16-bit operand $val can be used by a debugger to store more information
1873 // about the breakpoint.
1874 def BKPT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
1875 "bkpt", "\t$val", []>, Requires<[IsARM]> {
1877 let Inst{3-0} = val{3-0};
1878 let Inst{19-8} = val{15-4};
1879 let Inst{27-20} = 0b00010010;
1880 let Inst{31-28} = 0xe; // AL
1881 let Inst{7-4} = 0b0111;
1883 // default immediate for breakpoint mnemonic
1884 def : InstAlias<"bkpt", (BKPT 0)>, Requires<[IsARM]>;
1886 def HLT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
1887 "hlt", "\t$val", []>, Requires<[IsARM, HasV8]> {
1889 let Inst{3-0} = val{3-0};
1890 let Inst{19-8} = val{15-4};
1891 let Inst{27-20} = 0b00010000;
1892 let Inst{31-28} = 0xe; // AL
1893 let Inst{7-4} = 0b0111;
1896 // Change Processor State
1897 // FIXME: We should use InstAlias to handle the optional operands.
1898 class CPS<dag iops, string asm_ops>
1899 : AXI<(outs), iops, MiscFrm, NoItinerary, !strconcat("cps", asm_ops),
1900 []>, Requires<[IsARM]> {
1906 let Inst{31-28} = 0b1111;
1907 let Inst{27-20} = 0b00010000;
1908 let Inst{19-18} = imod;
1909 let Inst{17} = M; // Enabled if mode is set;
1910 let Inst{16-9} = 0b00000000;
1911 let Inst{8-6} = iflags;
1913 let Inst{4-0} = mode;
1916 let DecoderMethod = "DecodeCPSInstruction" in {
1918 def CPS3p : CPS<(ins imod_op:$imod, iflags_op:$iflags, imm0_31:$mode),
1919 "$imod\t$iflags, $mode">;
1920 let mode = 0, M = 0 in
1921 def CPS2p : CPS<(ins imod_op:$imod, iflags_op:$iflags), "$imod\t$iflags">;
1923 let imod = 0, iflags = 0, M = 1 in
1924 def CPS1p : CPS<(ins imm0_31:$mode), "\t$mode">;
1927 // Preload signals the memory system of possible future data/instruction access.
1928 multiclass APreLoad<bits<1> read, bits<1> data, string opc> {
1930 def i12 : AXIM<(outs), (ins addrmode_imm12:$addr), AddrMode_i12, MiscFrm,
1931 IIC_Preload, !strconcat(opc, "\t$addr"),
1932 [(ARMPreload addrmode_imm12:$addr, (i32 read), (i32 data))]>,
1933 Sched<[WritePreLd]> {
1936 let Inst{31-26} = 0b111101;
1937 let Inst{25} = 0; // 0 for immediate form
1938 let Inst{24} = data;
1939 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1940 let Inst{22} = read;
1941 let Inst{21-20} = 0b01;
1942 let Inst{19-16} = addr{16-13}; // Rn
1943 let Inst{15-12} = 0b1111;
1944 let Inst{11-0} = addr{11-0}; // imm12
1947 def rs : AXI<(outs), (ins ldst_so_reg:$shift), MiscFrm, IIC_Preload,
1948 !strconcat(opc, "\t$shift"),
1949 [(ARMPreload ldst_so_reg:$shift, (i32 read), (i32 data))]>,
1950 Sched<[WritePreLd]> {
1952 let Inst{31-26} = 0b111101;
1953 let Inst{25} = 1; // 1 for register form
1954 let Inst{24} = data;
1955 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1956 let Inst{22} = read;
1957 let Inst{21-20} = 0b01;
1958 let Inst{19-16} = shift{16-13}; // Rn
1959 let Inst{15-12} = 0b1111;
1960 let Inst{11-0} = shift{11-0};
1965 defm PLD : APreLoad<1, 1, "pld">, Requires<[IsARM]>;
1966 defm PLDW : APreLoad<0, 1, "pldw">, Requires<[IsARM,HasV7,HasMP]>;
1967 defm PLI : APreLoad<1, 0, "pli">, Requires<[IsARM,HasV7]>;
1969 def SETEND : AXI<(outs), (ins setend_op:$end), MiscFrm, NoItinerary,
1970 "setend\t$end", []>, Requires<[IsARM]>, Deprecated<HasV8Ops> {
1972 let Inst{31-10} = 0b1111000100000001000000;
1977 def DBG : AI<(outs), (ins imm0_15:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt",
1978 [(int_arm_dbg imm0_15:$opt)]>, Requires<[IsARM, HasV7]> {
1980 let Inst{27-4} = 0b001100100000111100001111;
1981 let Inst{3-0} = opt;
1984 // A8.8.247 UDF - Undefined (Encoding A1)
1985 def UDF : AInoP<(outs), (ins imm0_65535:$imm16), MiscFrm, NoItinerary,
1986 "udf", "\t$imm16", [(int_arm_undefined imm0_65535:$imm16)]> {
1988 let Inst{31-28} = 0b1110; // AL
1989 let Inst{27-25} = 0b011;
1990 let Inst{24-20} = 0b11111;
1991 let Inst{19-8} = imm16{15-4};
1992 let Inst{7-4} = 0b1111;
1993 let Inst{3-0} = imm16{3-0};
1997 * A5.4 Permanently UNDEFINED instructions.
1999 * For most targets use UDF #65006, for which the OS will generate SIGTRAP.
2000 * Other UDF encodings generate SIGILL.
2002 * NaCl's OS instead chooses an ARM UDF encoding that's also a UDF in Thumb.
2004 * 1110 0111 1111 iiii iiii iiii 1111 iiii
2006 * 1101 1110 iiii iiii
2007 * It uses the following encoding:
2008 * 1110 0111 1111 1110 1101 1110 1111 0000
2009 * - In ARM: UDF #60896;
2010 * - In Thumb: UDF #254 followed by a branch-to-self.
2012 let isBarrier = 1, isTerminator = 1 in
2013 def TRAPNaCl : AXI<(outs), (ins), MiscFrm, NoItinerary,
2015 Requires<[IsARM,UseNaClTrap]> {
2016 let Inst = 0xe7fedef0;
2018 let isBarrier = 1, isTerminator = 1 in
2019 def TRAP : AXI<(outs), (ins), MiscFrm, NoItinerary,
2021 Requires<[IsARM,DontUseNaClTrap]> {
2022 let Inst = 0xe7ffdefe;
2025 // Address computation and loads and stores in PIC mode.
2026 let isNotDuplicable = 1 in {
2027 def PICADD : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
2029 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>,
2030 Sched<[WriteALU, ReadALU]>;
2032 let AddedComplexity = 10 in {
2033 def PICLDR : ARMPseudoInst<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
2035 [(set GPR:$dst, (load addrmodepc:$addr))]>;
2037 def PICLDRH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2039 [(set GPR:$Rt, (zextloadi16 addrmodepc:$addr))]>;
2041 def PICLDRB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2043 [(set GPR:$Rt, (zextloadi8 addrmodepc:$addr))]>;
2045 def PICLDRSH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2047 [(set GPR:$Rt, (sextloadi16 addrmodepc:$addr))]>;
2049 def PICLDRSB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2051 [(set GPR:$Rt, (sextloadi8 addrmodepc:$addr))]>;
2053 let AddedComplexity = 10 in {
2054 def PICSTR : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2055 4, IIC_iStore_r, [(store GPR:$src, addrmodepc:$addr)]>;
2057 def PICSTRH : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2058 4, IIC_iStore_bh_r, [(truncstorei16 GPR:$src,
2059 addrmodepc:$addr)]>;
2061 def PICSTRB : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2062 4, IIC_iStore_bh_r, [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
2064 } // isNotDuplicable = 1
2067 // LEApcrel - Load a pc-relative address into a register without offending the
2069 let hasSideEffects = 0, isReMaterializable = 1 in
2070 // The 'adr' mnemonic encodes differently if the label is before or after
2071 // the instruction. The {24-21} opcode bits are set by the fixup, as we don't
2072 // know until then which form of the instruction will be used.
2073 def ADR : AI1<{0,?,?,0}, (outs GPR:$Rd), (ins adrlabel:$label),
2074 MiscFrm, IIC_iALUi, "adr", "\t$Rd, $label", []>,
2075 Sched<[WriteALU, ReadALU]> {
2078 let Inst{27-25} = 0b001;
2080 let Inst{23-22} = label{13-12};
2083 let Inst{19-16} = 0b1111;
2084 let Inst{15-12} = Rd;
2085 let Inst{11-0} = label{11-0};
2088 let hasSideEffects = 1 in {
2089 def LEApcrel : ARMPseudoInst<(outs GPR:$Rd), (ins i32imm:$label, pred:$p),
2090 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
2092 def LEApcrelJT : ARMPseudoInst<(outs GPR:$Rd),
2093 (ins i32imm:$label, nohash_imm:$id, pred:$p),
2094 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
2097 //===----------------------------------------------------------------------===//
2098 // Control Flow Instructions.
2101 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
2103 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
2104 "bx", "\tlr", [(ARMretflag)]>,
2105 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2106 let Inst{27-0} = 0b0001001011111111111100011110;
2110 def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br,
2111 "mov", "\tpc, lr", [(ARMretflag)]>,
2112 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]> {
2113 let Inst{27-0} = 0b0001101000001111000000001110;
2116 // Exception return: N.b. doesn't set CPSR as far as we're concerned (it sets
2117 // the user-space one).
2118 def SUBS_PC_LR : ARMPseudoInst<(outs), (ins i32imm:$offset, pred:$p),
2120 [(ARMintretflag imm:$offset)]>;
2123 // Indirect branches
2124 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
2126 def BX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
2127 [(brind GPR:$dst)]>,
2128 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2130 let Inst{31-4} = 0b1110000100101111111111110001;
2131 let Inst{3-0} = dst;
2134 def BX_pred : AI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br,
2135 "bx", "\t$dst", [/* pattern left blank */]>,
2136 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2138 let Inst{27-4} = 0b000100101111111111110001;
2139 let Inst{3-0} = dst;
2143 // SP is marked as a use to prevent stack-pointer assignments that appear
2144 // immediately before calls from potentially appearing dead.
2146 // FIXME: Do we really need a non-predicated version? If so, it should
2147 // at least be a pseudo instruction expanding to the predicated version
2148 // at MC lowering time.
2149 Defs = [LR], Uses = [SP] in {
2150 def BL : ABXI<0b1011, (outs), (ins bl_target:$func),
2151 IIC_Br, "bl\t$func",
2152 [(ARMcall tglobaladdr:$func)]>,
2153 Requires<[IsARM]>, Sched<[WriteBrL]> {
2154 let Inst{31-28} = 0b1110;
2156 let Inst{23-0} = func;
2157 let DecoderMethod = "DecodeBranchImmInstruction";
2160 def BL_pred : ABI<0b1011, (outs), (ins bl_target:$func),
2161 IIC_Br, "bl", "\t$func",
2162 [(ARMcall_pred tglobaladdr:$func)]>,
2163 Requires<[IsARM]>, Sched<[WriteBrL]> {
2165 let Inst{23-0} = func;
2166 let DecoderMethod = "DecodeBranchImmInstruction";
2170 def BLX : AXI<(outs), (ins GPR:$func), BrMiscFrm,
2171 IIC_Br, "blx\t$func",
2172 [(ARMcall GPR:$func)]>,
2173 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2175 let Inst{31-4} = 0b1110000100101111111111110011;
2176 let Inst{3-0} = func;
2179 def BLX_pred : AI<(outs), (ins GPR:$func), BrMiscFrm,
2180 IIC_Br, "blx", "\t$func",
2181 [(ARMcall_pred GPR:$func)]>,
2182 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2184 let Inst{27-4} = 0b000100101111111111110011;
2185 let Inst{3-0} = func;
2189 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
2190 def BX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
2191 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
2192 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]>;
2195 def BMOVPCRX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
2196 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
2197 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
2199 // mov lr, pc; b if callee is marked noreturn to avoid confusing the
2200 // return stack predictor.
2201 def BMOVPCB_CALL : ARMPseudoInst<(outs), (ins bl_target:$func),
2202 8, IIC_Br, [(ARMcall_nolink tglobaladdr:$func)]>,
2203 Requires<[IsARM]>, Sched<[WriteBr]>;
2206 let isBranch = 1, isTerminator = 1 in {
2207 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
2208 // a two-value operand where a dag node expects two operands. :(
2209 def Bcc : ABI<0b1010, (outs), (ins br_target:$target),
2210 IIC_Br, "b", "\t$target",
2211 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>,
2214 let Inst{23-0} = target;
2215 let DecoderMethod = "DecodeBranchImmInstruction";
2218 let isBarrier = 1 in {
2219 // B is "predicable" since it's just a Bcc with an 'always' condition.
2220 let isPredicable = 1 in
2221 // FIXME: We shouldn't need this pseudo at all. Just using Bcc directly
2222 // should be sufficient.
2223 // FIXME: Is B really a Barrier? That doesn't seem right.
2224 def B : ARMPseudoExpand<(outs), (ins br_target:$target), 4, IIC_Br,
2225 [(br bb:$target)], (Bcc br_target:$target, (ops 14, zero_reg))>,
2228 let isNotDuplicable = 1, isIndirectBranch = 1 in {
2229 def BR_JTr : ARMPseudoInst<(outs),
2230 (ins GPR:$target, i32imm:$jt, i32imm:$id),
2232 [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]>,
2234 // FIXME: This shouldn't use the generic "addrmode2," but rather be split
2235 // into i12 and rs suffixed versions.
2236 def BR_JTm : ARMPseudoInst<(outs),
2237 (ins addrmode2:$target, i32imm:$jt, i32imm:$id),
2239 [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
2240 imm:$id)]>, Sched<[WriteBrTbl]>;
2241 def BR_JTadd : ARMPseudoInst<(outs),
2242 (ins GPR:$target, GPR:$idx, i32imm:$jt, i32imm:$id),
2244 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
2245 imm:$id)]>, Sched<[WriteBrTbl]>;
2246 } // isNotDuplicable = 1, isIndirectBranch = 1
2252 def BLXi : AXI<(outs), (ins blx_target:$target), BrMiscFrm, NoItinerary,
2253 "blx\t$target", []>,
2254 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2255 let Inst{31-25} = 0b1111101;
2257 let Inst{23-0} = target{24-1};
2258 let Inst{24} = target{0};
2261 // Branch and Exchange Jazelle
2262 def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func",
2263 [/* pattern left blank */]>, Sched<[WriteBr]> {
2265 let Inst{23-20} = 0b0010;
2266 let Inst{19-8} = 0xfff;
2267 let Inst{7-4} = 0b0010;
2268 let Inst{3-0} = func;
2273 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in {
2274 def TCRETURNdi : PseudoInst<(outs), (ins i32imm:$dst), IIC_Br, []>,
2277 def TCRETURNri : PseudoInst<(outs), (ins tcGPR:$dst), IIC_Br, []>,
2280 def TAILJMPd : ARMPseudoExpand<(outs), (ins br_target:$dst),
2282 (Bcc br_target:$dst, (ops 14, zero_reg))>,
2283 Requires<[IsARM]>, Sched<[WriteBr]>;
2285 def TAILJMPr : ARMPseudoExpand<(outs), (ins tcGPR:$dst),
2287 (BX GPR:$dst)>, Sched<[WriteBr]>,
2291 // Secure Monitor Call is a system instruction.
2292 def SMC : ABI<0b0001, (outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt",
2293 []>, Requires<[IsARM, HasTrustZone]> {
2295 let Inst{23-4} = 0b01100000000000000111;
2296 let Inst{3-0} = opt;
2299 // Supervisor Call (Software Interrupt)
2300 let isCall = 1, Uses = [SP] in {
2301 def SVC : ABI<0b1111, (outs), (ins imm24b:$svc), IIC_Br, "svc", "\t$svc", []>,
2304 let Inst{23-0} = svc;
2308 // Store Return State
2309 class SRSI<bit wb, string asm>
2310 : XI<(outs), (ins imm0_31:$mode), AddrModeNone, 4, IndexModeNone, BrFrm,
2311 NoItinerary, asm, "", []> {
2313 let Inst{31-28} = 0b1111;
2314 let Inst{27-25} = 0b100;
2318 let Inst{19-16} = 0b1101; // SP
2319 let Inst{15-5} = 0b00000101000;
2320 let Inst{4-0} = mode;
2323 def SRSDA : SRSI<0, "srsda\tsp, $mode"> {
2324 let Inst{24-23} = 0;
2326 def SRSDA_UPD : SRSI<1, "srsda\tsp!, $mode"> {
2327 let Inst{24-23} = 0;
2329 def SRSDB : SRSI<0, "srsdb\tsp, $mode"> {
2330 let Inst{24-23} = 0b10;
2332 def SRSDB_UPD : SRSI<1, "srsdb\tsp!, $mode"> {
2333 let Inst{24-23} = 0b10;
2335 def SRSIA : SRSI<0, "srsia\tsp, $mode"> {
2336 let Inst{24-23} = 0b01;
2338 def SRSIA_UPD : SRSI<1, "srsia\tsp!, $mode"> {
2339 let Inst{24-23} = 0b01;
2341 def SRSIB : SRSI<0, "srsib\tsp, $mode"> {
2342 let Inst{24-23} = 0b11;
2344 def SRSIB_UPD : SRSI<1, "srsib\tsp!, $mode"> {
2345 let Inst{24-23} = 0b11;
2348 def : ARMInstAlias<"srsda $mode", (SRSDA imm0_31:$mode)>;
2349 def : ARMInstAlias<"srsda $mode!", (SRSDA_UPD imm0_31:$mode)>;
2351 def : ARMInstAlias<"srsdb $mode", (SRSDB imm0_31:$mode)>;
2352 def : ARMInstAlias<"srsdb $mode!", (SRSDB_UPD imm0_31:$mode)>;
2354 def : ARMInstAlias<"srsia $mode", (SRSIA imm0_31:$mode)>;
2355 def : ARMInstAlias<"srsia $mode!", (SRSIA_UPD imm0_31:$mode)>;
2357 def : ARMInstAlias<"srsib $mode", (SRSIB imm0_31:$mode)>;
2358 def : ARMInstAlias<"srsib $mode!", (SRSIB_UPD imm0_31:$mode)>;
2360 // Return From Exception
2361 class RFEI<bit wb, string asm>
2362 : XI<(outs), (ins GPR:$Rn), AddrModeNone, 4, IndexModeNone, BrFrm,
2363 NoItinerary, asm, "", []> {
2365 let Inst{31-28} = 0b1111;
2366 let Inst{27-25} = 0b100;
2370 let Inst{19-16} = Rn;
2371 let Inst{15-0} = 0xa00;
2374 def RFEDA : RFEI<0, "rfeda\t$Rn"> {
2375 let Inst{24-23} = 0;
2377 def RFEDA_UPD : RFEI<1, "rfeda\t$Rn!"> {
2378 let Inst{24-23} = 0;
2380 def RFEDB : RFEI<0, "rfedb\t$Rn"> {
2381 let Inst{24-23} = 0b10;
2383 def RFEDB_UPD : RFEI<1, "rfedb\t$Rn!"> {
2384 let Inst{24-23} = 0b10;
2386 def RFEIA : RFEI<0, "rfeia\t$Rn"> {
2387 let Inst{24-23} = 0b01;
2389 def RFEIA_UPD : RFEI<1, "rfeia\t$Rn!"> {
2390 let Inst{24-23} = 0b01;
2392 def RFEIB : RFEI<0, "rfeib\t$Rn"> {
2393 let Inst{24-23} = 0b11;
2395 def RFEIB_UPD : RFEI<1, "rfeib\t$Rn!"> {
2396 let Inst{24-23} = 0b11;
2399 // Hypervisor Call is a system instruction
2401 def HVC : AInoP< (outs), (ins imm0_65535:$imm), BrFrm, NoItinerary,
2402 "hvc", "\t$imm", []>,
2403 Requires<[IsARM, HasVirtualization]> {
2406 // Even though HVC isn't predicable, it's encoding includes a condition field.
2407 // The instruction is undefined if the condition field is 0xf otherwise it is
2408 // unpredictable if it isn't condition AL (0xe).
2409 let Inst{31-28} = 0b1110;
2410 let Unpredictable{31-28} = 0b1111;
2411 let Inst{27-24} = 0b0001;
2412 let Inst{23-20} = 0b0100;
2413 let Inst{19-8} = imm{15-4};
2414 let Inst{7-4} = 0b0111;
2415 let Inst{3-0} = imm{3-0};
2419 // Return from exception in Hypervisor mode.
2420 let isReturn = 1, isBarrier = 1, isTerminator = 1, Defs = [PC] in
2421 def ERET : ABI<0b0001, (outs), (ins), NoItinerary, "eret", "", []>,
2422 Requires<[IsARM, HasVirtualization]> {
2423 let Inst{23-0} = 0b011000000000000001101110;
2426 //===----------------------------------------------------------------------===//
2427 // Load / Store Instructions.
2433 defm LDR : AI_ldr1<0, "ldr", IIC_iLoad_r, IIC_iLoad_si,
2434 UnOpFrag<(load node:$Src)>>;
2435 defm LDRB : AI_ldr1nopc<1, "ldrb", IIC_iLoad_bh_r, IIC_iLoad_bh_si,
2436 UnOpFrag<(zextloadi8 node:$Src)>>;
2437 defm STR : AI_str1<0, "str", IIC_iStore_r, IIC_iStore_si,
2438 BinOpFrag<(store node:$LHS, node:$RHS)>>;
2439 defm STRB : AI_str1nopc<1, "strb", IIC_iStore_bh_r, IIC_iStore_bh_si,
2440 BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
2442 // Special LDR for loads from non-pc-relative constpools.
2443 let canFoldAsLoad = 1, mayLoad = 1, hasSideEffects = 0,
2444 isReMaterializable = 1, isCodeGenOnly = 1 in
2445 def LDRcp : AI2ldst<0b010, 1, 0, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
2446 AddrMode_i12, LdFrm, IIC_iLoad_r, "ldr", "\t$Rt, $addr",
2450 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2451 let Inst{19-16} = 0b1111;
2452 let Inst{15-12} = Rt;
2453 let Inst{11-0} = addr{11-0}; // imm12
2456 // Loads with zero extension
2457 def LDRH : AI3ld<0b1011, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2458 IIC_iLoad_bh_r, "ldrh", "\t$Rt, $addr",
2459 [(set GPR:$Rt, (zextloadi16 addrmode3:$addr))]>;
2461 // Loads with sign extension
2462 def LDRSH : AI3ld<0b1111, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2463 IIC_iLoad_bh_r, "ldrsh", "\t$Rt, $addr",
2464 [(set GPR:$Rt, (sextloadi16 addrmode3:$addr))]>;
2466 def LDRSB : AI3ld<0b1101, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2467 IIC_iLoad_bh_r, "ldrsb", "\t$Rt, $addr",
2468 [(set GPR:$Rt, (sextloadi8 addrmode3:$addr))]>;
2470 let mayLoad = 1, hasSideEffects = 0, hasExtraDefRegAllocReq = 1 in {
2472 def LDRD : AI3ld<0b1101, 0, (outs GPR:$Rt, GPR:$Rt2), (ins addrmode3:$addr),
2473 LdMiscFrm, IIC_iLoad_d_r, "ldrd", "\t$Rt, $Rt2, $addr", []>,
2474 Requires<[IsARM, HasV5TE]>;
2477 def LDA : AIldracq<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2478 NoItinerary, "lda", "\t$Rt, $addr", []>;
2479 def LDAB : AIldracq<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2480 NoItinerary, "ldab", "\t$Rt, $addr", []>;
2481 def LDAH : AIldracq<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2482 NoItinerary, "ldah", "\t$Rt, $addr", []>;
2485 multiclass AI2_ldridx<bit isByte, string opc,
2486 InstrItinClass iii, InstrItinClass iir> {
2487 def _PRE_IMM : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2488 (ins addrmode_imm12_pre:$addr), IndexModePre, LdFrm, iii,
2489 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2492 let Inst{23} = addr{12};
2493 let Inst{19-16} = addr{16-13};
2494 let Inst{11-0} = addr{11-0};
2495 let DecoderMethod = "DecodeLDRPreImm";
2498 def _PRE_REG : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2499 (ins ldst_so_reg:$addr), IndexModePre, LdFrm, iir,
2500 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2503 let Inst{23} = addr{12};
2504 let Inst{19-16} = addr{16-13};
2505 let Inst{11-0} = addr{11-0};
2507 let DecoderMethod = "DecodeLDRPreReg";
2510 def _POST_REG : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2511 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2512 IndexModePost, LdFrm, iir,
2513 opc, "\t$Rt, $addr, $offset",
2514 "$addr.base = $Rn_wb", []> {
2520 let Inst{23} = offset{12};
2521 let Inst{19-16} = addr;
2522 let Inst{11-0} = offset{11-0};
2525 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2528 def _POST_IMM : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2529 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2530 IndexModePost, LdFrm, iii,
2531 opc, "\t$Rt, $addr, $offset",
2532 "$addr.base = $Rn_wb", []> {
2538 let Inst{23} = offset{12};
2539 let Inst{19-16} = addr;
2540 let Inst{11-0} = offset{11-0};
2542 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2547 let mayLoad = 1, hasSideEffects = 0 in {
2548 // FIXME: for LDR_PRE_REG etc. the itineray should be either IIC_iLoad_ru or
2549 // IIC_iLoad_siu depending on whether it the offset register is shifted.
2550 defm LDR : AI2_ldridx<0, "ldr", IIC_iLoad_iu, IIC_iLoad_ru>;
2551 defm LDRB : AI2_ldridx<1, "ldrb", IIC_iLoad_bh_iu, IIC_iLoad_bh_ru>;
2554 multiclass AI3_ldridx<bits<4> op, string opc, InstrItinClass itin> {
2555 def _PRE : AI3ldstidx<op, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2556 (ins addrmode3_pre:$addr), IndexModePre,
2558 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2560 let Inst{23} = addr{8}; // U bit
2561 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2562 let Inst{19-16} = addr{12-9}; // Rn
2563 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2564 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2565 let DecoderMethod = "DecodeAddrMode3Instruction";
2567 def _POST : AI3ldstidx<op, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2568 (ins addr_offset_none:$addr, am3offset:$offset),
2569 IndexModePost, LdMiscFrm, itin,
2570 opc, "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2574 let Inst{23} = offset{8}; // U bit
2575 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2576 let Inst{19-16} = addr;
2577 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2578 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2579 let DecoderMethod = "DecodeAddrMode3Instruction";
2583 let mayLoad = 1, hasSideEffects = 0 in {
2584 defm LDRH : AI3_ldridx<0b1011, "ldrh", IIC_iLoad_bh_ru>;
2585 defm LDRSH : AI3_ldridx<0b1111, "ldrsh", IIC_iLoad_bh_ru>;
2586 defm LDRSB : AI3_ldridx<0b1101, "ldrsb", IIC_iLoad_bh_ru>;
2587 let hasExtraDefRegAllocReq = 1 in {
2588 def LDRD_PRE : AI3ldstidx<0b1101, 0, 1, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2589 (ins addrmode3_pre:$addr), IndexModePre,
2590 LdMiscFrm, IIC_iLoad_d_ru,
2591 "ldrd", "\t$Rt, $Rt2, $addr!",
2592 "$addr.base = $Rn_wb", []> {
2594 let Inst{23} = addr{8}; // U bit
2595 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2596 let Inst{19-16} = addr{12-9}; // Rn
2597 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2598 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2599 let DecoderMethod = "DecodeAddrMode3Instruction";
2601 def LDRD_POST: AI3ldstidx<0b1101, 0, 0, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2602 (ins addr_offset_none:$addr, am3offset:$offset),
2603 IndexModePost, LdMiscFrm, IIC_iLoad_d_ru,
2604 "ldrd", "\t$Rt, $Rt2, $addr, $offset",
2605 "$addr.base = $Rn_wb", []> {
2608 let Inst{23} = offset{8}; // U bit
2609 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2610 let Inst{19-16} = addr;
2611 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2612 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2613 let DecoderMethod = "DecodeAddrMode3Instruction";
2615 } // hasExtraDefRegAllocReq = 1
2616 } // mayLoad = 1, hasSideEffects = 0
2618 // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT.
2619 let mayLoad = 1, hasSideEffects = 0 in {
2620 def LDRT_POST_REG : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2621 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2622 IndexModePost, LdFrm, IIC_iLoad_ru,
2623 "ldrt", "\t$Rt, $addr, $offset",
2624 "$addr.base = $Rn_wb", []> {
2630 let Inst{23} = offset{12};
2631 let Inst{21} = 1; // overwrite
2632 let Inst{19-16} = addr;
2633 let Inst{11-5} = offset{11-5};
2635 let Inst{3-0} = offset{3-0};
2636 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2640 : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2641 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2642 IndexModePost, LdFrm, IIC_iLoad_ru,
2643 "ldrt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2649 let Inst{23} = offset{12};
2650 let Inst{21} = 1; // overwrite
2651 let Inst{19-16} = addr;
2652 let Inst{11-0} = offset{11-0};
2653 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2656 def LDRBT_POST_REG : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2657 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2658 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2659 "ldrbt", "\t$Rt, $addr, $offset",
2660 "$addr.base = $Rn_wb", []> {
2666 let Inst{23} = offset{12};
2667 let Inst{21} = 1; // overwrite
2668 let Inst{19-16} = addr;
2669 let Inst{11-5} = offset{11-5};
2671 let Inst{3-0} = offset{3-0};
2672 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2676 : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2677 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2678 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2679 "ldrbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2685 let Inst{23} = offset{12};
2686 let Inst{21} = 1; // overwrite
2687 let Inst{19-16} = addr;
2688 let Inst{11-0} = offset{11-0};
2689 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2692 multiclass AI3ldrT<bits<4> op, string opc> {
2693 def i : AI3ldstidxT<op, 1, (outs GPR:$Rt, GPR:$base_wb),
2694 (ins addr_offset_none:$addr, postidx_imm8:$offset),
2695 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2696 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2698 let Inst{23} = offset{8};
2700 let Inst{11-8} = offset{7-4};
2701 let Inst{3-0} = offset{3-0};
2703 def r : AI3ldstidxT<op, 1, (outs GPRnopc:$Rt, GPRnopc:$base_wb),
2704 (ins addr_offset_none:$addr, postidx_reg:$Rm),
2705 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2706 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2708 let Inst{23} = Rm{4};
2711 let Unpredictable{11-8} = 0b1111;
2712 let Inst{3-0} = Rm{3-0};
2713 let DecoderMethod = "DecodeLDR";
2717 defm LDRSBT : AI3ldrT<0b1101, "ldrsbt">;
2718 defm LDRHT : AI3ldrT<0b1011, "ldrht">;
2719 defm LDRSHT : AI3ldrT<0b1111, "ldrsht">;
2723 : ARMAsmPseudo<"ldrt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q),
2727 : ARMAsmPseudo<"ldrbt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q),
2732 // Stores with truncate
2733 def STRH : AI3str<0b1011, (outs), (ins GPR:$Rt, addrmode3:$addr), StMiscFrm,
2734 IIC_iStore_bh_r, "strh", "\t$Rt, $addr",
2735 [(truncstorei16 GPR:$Rt, addrmode3:$addr)]>;
2738 let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
2739 def STRD : AI3str<0b1111, (outs), (ins GPR:$Rt, GPR:$Rt2, addrmode3:$addr),
2740 StMiscFrm, IIC_iStore_d_r, "strd", "\t$Rt, $Rt2, $addr", []>,
2741 Requires<[IsARM, HasV5TE]> {
2747 multiclass AI2_stridx<bit isByte, string opc,
2748 InstrItinClass iii, InstrItinClass iir> {
2749 def _PRE_IMM : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2750 (ins GPR:$Rt, addrmode_imm12_pre:$addr), IndexModePre,
2752 opc, "\t$Rt, $addr!",
2753 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2756 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2757 let Inst{19-16} = addr{16-13}; // Rn
2758 let Inst{11-0} = addr{11-0}; // imm12
2759 let DecoderMethod = "DecodeSTRPreImm";
2762 def _PRE_REG : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2763 (ins GPR:$Rt, ldst_so_reg:$addr),
2764 IndexModePre, StFrm, iir,
2765 opc, "\t$Rt, $addr!",
2766 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2769 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2770 let Inst{19-16} = addr{16-13}; // Rn
2771 let Inst{11-0} = addr{11-0};
2772 let Inst{4} = 0; // Inst{4} = 0
2773 let DecoderMethod = "DecodeSTRPreReg";
2775 def _POST_REG : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2776 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2777 IndexModePost, StFrm, iir,
2778 opc, "\t$Rt, $addr, $offset",
2779 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2785 let Inst{23} = offset{12};
2786 let Inst{19-16} = addr;
2787 let Inst{11-0} = offset{11-0};
2790 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2793 def _POST_IMM : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2794 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2795 IndexModePost, StFrm, iii,
2796 opc, "\t$Rt, $addr, $offset",
2797 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2803 let Inst{23} = offset{12};
2804 let Inst{19-16} = addr;
2805 let Inst{11-0} = offset{11-0};
2807 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2811 let mayStore = 1, hasSideEffects = 0 in {
2812 // FIXME: for STR_PRE_REG etc. the itineray should be either IIC_iStore_ru or
2813 // IIC_iStore_siu depending on whether it the offset register is shifted.
2814 defm STR : AI2_stridx<0, "str", IIC_iStore_iu, IIC_iStore_ru>;
2815 defm STRB : AI2_stridx<1, "strb", IIC_iStore_bh_iu, IIC_iStore_bh_ru>;
2818 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2819 am2offset_reg:$offset),
2820 (STR_POST_REG GPR:$Rt, addr_offset_none:$addr,
2821 am2offset_reg:$offset)>;
2822 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2823 am2offset_imm:$offset),
2824 (STR_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2825 am2offset_imm:$offset)>;
2826 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2827 am2offset_reg:$offset),
2828 (STRB_POST_REG GPR:$Rt, addr_offset_none:$addr,
2829 am2offset_reg:$offset)>;
2830 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2831 am2offset_imm:$offset),
2832 (STRB_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2833 am2offset_imm:$offset)>;
2835 // Pseudo-instructions for pattern matching the pre-indexed stores. We can't
2836 // put the patterns on the instruction definitions directly as ISel wants
2837 // the address base and offset to be separate operands, not a single
2838 // complex operand like we represent the instructions themselves. The
2839 // pseudos map between the two.
2840 let usesCustomInserter = 1,
2841 Constraints = "$Rn = $Rn_wb,@earlyclobber $Rn_wb" in {
2842 def STRi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2843 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2846 (pre_store GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2847 def STRr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2848 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2851 (pre_store GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2852 def STRBi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2853 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2856 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2857 def STRBr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2858 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2861 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2862 def STRH_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2863 (ins GPR:$Rt, GPR:$Rn, am3offset:$offset, pred:$p),
2866 (pre_truncsti16 GPR:$Rt, GPR:$Rn, am3offset:$offset))]>;
2871 def STRH_PRE : AI3ldstidx<0b1011, 0, 1, (outs GPR:$Rn_wb),
2872 (ins GPR:$Rt, addrmode3_pre:$addr), IndexModePre,
2873 StMiscFrm, IIC_iStore_bh_ru,
2874 "strh", "\t$Rt, $addr!",
2875 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2877 let Inst{23} = addr{8}; // U bit
2878 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2879 let Inst{19-16} = addr{12-9}; // Rn
2880 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2881 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2882 let DecoderMethod = "DecodeAddrMode3Instruction";
2885 def STRH_POST : AI3ldstidx<0b1011, 0, 0, (outs GPR:$Rn_wb),
2886 (ins GPR:$Rt, addr_offset_none:$addr, am3offset:$offset),
2887 IndexModePost, StMiscFrm, IIC_iStore_bh_ru,
2888 "strh", "\t$Rt, $addr, $offset",
2889 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb",
2890 [(set GPR:$Rn_wb, (post_truncsti16 GPR:$Rt,
2891 addr_offset_none:$addr,
2892 am3offset:$offset))]> {
2895 let Inst{23} = offset{8}; // U bit
2896 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2897 let Inst{19-16} = addr;
2898 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2899 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2900 let DecoderMethod = "DecodeAddrMode3Instruction";
2903 let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
2904 def STRD_PRE : AI3ldstidx<0b1111, 0, 1, (outs GPR:$Rn_wb),
2905 (ins GPR:$Rt, GPR:$Rt2, addrmode3_pre:$addr),
2906 IndexModePre, StMiscFrm, IIC_iStore_d_ru,
2907 "strd", "\t$Rt, $Rt2, $addr!",
2908 "$addr.base = $Rn_wb", []> {
2910 let Inst{23} = addr{8}; // U bit
2911 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2912 let Inst{19-16} = addr{12-9}; // Rn
2913 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2914 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2915 let DecoderMethod = "DecodeAddrMode3Instruction";
2918 def STRD_POST: AI3ldstidx<0b1111, 0, 0, (outs GPR:$Rn_wb),
2919 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr,
2921 IndexModePost, StMiscFrm, IIC_iStore_d_ru,
2922 "strd", "\t$Rt, $Rt2, $addr, $offset",
2923 "$addr.base = $Rn_wb", []> {
2926 let Inst{23} = offset{8}; // U bit
2927 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2928 let Inst{19-16} = addr;
2929 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2930 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2931 let DecoderMethod = "DecodeAddrMode3Instruction";
2933 } // mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1
2935 // STRT, STRBT, and STRHT
2937 def STRBT_POST_REG : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2938 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2939 IndexModePost, StFrm, IIC_iStore_bh_ru,
2940 "strbt", "\t$Rt, $addr, $offset",
2941 "$addr.base = $Rn_wb", []> {
2947 let Inst{23} = offset{12};
2948 let Inst{21} = 1; // overwrite
2949 let Inst{19-16} = addr;
2950 let Inst{11-5} = offset{11-5};
2952 let Inst{3-0} = offset{3-0};
2953 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2957 : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2958 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2959 IndexModePost, StFrm, IIC_iStore_bh_ru,
2960 "strbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2966 let Inst{23} = offset{12};
2967 let Inst{21} = 1; // overwrite
2968 let Inst{19-16} = addr;
2969 let Inst{11-0} = offset{11-0};
2970 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2974 : ARMAsmPseudo<"strbt${q} $Rt, $addr",
2975 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>;
2977 let mayStore = 1, hasSideEffects = 0 in {
2978 def STRT_POST_REG : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
2979 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2980 IndexModePost, StFrm, IIC_iStore_ru,
2981 "strt", "\t$Rt, $addr, $offset",
2982 "$addr.base = $Rn_wb", []> {
2988 let Inst{23} = offset{12};
2989 let Inst{21} = 1; // overwrite
2990 let Inst{19-16} = addr;
2991 let Inst{11-5} = offset{11-5};
2993 let Inst{3-0} = offset{3-0};
2994 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2998 : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
2999 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
3000 IndexModePost, StFrm, IIC_iStore_ru,
3001 "strt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
3007 let Inst{23} = offset{12};
3008 let Inst{21} = 1; // overwrite
3009 let Inst{19-16} = addr;
3010 let Inst{11-0} = offset{11-0};
3011 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3016 : ARMAsmPseudo<"strt${q} $Rt, $addr",
3017 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>;
3019 multiclass AI3strT<bits<4> op, string opc> {
3020 def i : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
3021 (ins GPR:$Rt, addr_offset_none:$addr, postidx_imm8:$offset),
3022 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
3023 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
3025 let Inst{23} = offset{8};
3027 let Inst{11-8} = offset{7-4};
3028 let Inst{3-0} = offset{3-0};
3030 def r : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
3031 (ins GPR:$Rt, addr_offset_none:$addr, postidx_reg:$Rm),
3032 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
3033 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
3035 let Inst{23} = Rm{4};
3038 let Inst{3-0} = Rm{3-0};
3043 defm STRHT : AI3strT<0b1011, "strht">;
3045 def STL : AIstrrel<0b00, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3046 NoItinerary, "stl", "\t$Rt, $addr", []>;
3047 def STLB : AIstrrel<0b10, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3048 NoItinerary, "stlb", "\t$Rt, $addr", []>;
3049 def STLH : AIstrrel<0b11, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3050 NoItinerary, "stlh", "\t$Rt, $addr", []>;
3052 //===----------------------------------------------------------------------===//
3053 // Load / store multiple Instructions.
3056 multiclass arm_ldst_mult<string asm, string sfx, bit L_bit, bit P_bit, Format f,
3057 InstrItinClass itin, InstrItinClass itin_upd> {
3058 // IA is the default, so no need for an explicit suffix on the
3059 // mnemonic here. Without it is the canonical spelling.
3061 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3062 IndexModeNone, f, itin,
3063 !strconcat(asm, "${p}\t$Rn, $regs", sfx), "", []> {
3064 let Inst{24-23} = 0b01; // Increment After
3065 let Inst{22} = P_bit;
3066 let Inst{21} = 0; // No writeback
3067 let Inst{20} = L_bit;
3070 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3071 IndexModeUpd, f, itin_upd,
3072 !strconcat(asm, "${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3073 let Inst{24-23} = 0b01; // Increment After
3074 let Inst{22} = P_bit;
3075 let Inst{21} = 1; // Writeback
3076 let Inst{20} = L_bit;
3078 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3081 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3082 IndexModeNone, f, itin,
3083 !strconcat(asm, "da${p}\t$Rn, $regs", sfx), "", []> {
3084 let Inst{24-23} = 0b00; // Decrement 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, "da${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3093 let Inst{24-23} = 0b00; // Decrement 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, "db${p}\t$Rn, $regs", sfx), "", []> {
3104 let Inst{24-23} = 0b10; // Decrement Before
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, "db${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3113 let Inst{24-23} = 0b10; // Decrement Before
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, "ib${p}\t$Rn, $regs", sfx), "", []> {
3124 let Inst{24-23} = 0b11; // Increment 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, "ib${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3133 let Inst{24-23} = 0b11; // Increment Before
3134 let Inst{22} = P_bit;
3135 let Inst{21} = 1; // Writeback
3136 let Inst{20} = L_bit;
3138 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3142 let hasSideEffects = 0 in {
3144 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
3145 defm LDM : arm_ldst_mult<"ldm", "", 1, 0, LdStMulFrm, IIC_iLoad_m,
3146 IIC_iLoad_mu>, ComplexDeprecationPredicate<"ARMLoad">;
3148 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
3149 defm STM : arm_ldst_mult<"stm", "", 0, 0, LdStMulFrm, IIC_iStore_m,
3151 ComplexDeprecationPredicate<"ARMStore">;
3155 // FIXME: remove when we have a way to marking a MI with these properties.
3156 // FIXME: Should pc be an implicit operand like PICADD, etc?
3157 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
3158 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
3159 def LDMIA_RET : ARMPseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p,
3160 reglist:$regs, variable_ops),
3161 4, IIC_iLoad_mBr, [],
3162 (LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>,
3163 RegConstraint<"$Rn = $wb">;
3165 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
3166 defm sysLDM : arm_ldst_mult<"ldm", " ^", 1, 1, LdStMulFrm, IIC_iLoad_m,
3169 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
3170 defm sysSTM : arm_ldst_mult<"stm", " ^", 0, 1, LdStMulFrm, IIC_iStore_m,
3175 //===----------------------------------------------------------------------===//
3176 // Move Instructions.
3179 let hasSideEffects = 0 in
3180 def MOVr : AsI1<0b1101, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMOVr,
3181 "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> {
3185 let Inst{19-16} = 0b0000;
3186 let Inst{11-4} = 0b00000000;
3189 let Inst{15-12} = Rd;
3192 // A version for the smaller set of tail call registers.
3193 let hasSideEffects = 0 in
3194 def MOVr_TC : AsI1<0b1101, (outs tcGPR:$Rd), (ins tcGPR:$Rm), DPFrm,
3195 IIC_iMOVr, "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> {
3199 let Inst{11-4} = 0b00000000;
3202 let Inst{15-12} = Rd;
3205 def MOVsr : AsI1<0b1101, (outs GPRnopc:$Rd), (ins shift_so_reg_reg:$src),
3206 DPSoRegRegFrm, IIC_iMOVsr,
3207 "mov", "\t$Rd, $src",
3208 [(set GPRnopc:$Rd, shift_so_reg_reg:$src)]>, UnaryDP,
3212 let Inst{15-12} = Rd;
3213 let Inst{19-16} = 0b0000;
3214 let Inst{11-8} = src{11-8};
3216 let Inst{6-5} = src{6-5};
3218 let Inst{3-0} = src{3-0};
3222 def MOVsi : AsI1<0b1101, (outs GPR:$Rd), (ins shift_so_reg_imm:$src),
3223 DPSoRegImmFrm, IIC_iMOVsr,
3224 "mov", "\t$Rd, $src", [(set GPR:$Rd, shift_so_reg_imm:$src)]>,
3225 UnaryDP, Sched<[WriteALU]> {
3228 let Inst{15-12} = Rd;
3229 let Inst{19-16} = 0b0000;
3230 let Inst{11-5} = src{11-5};
3232 let Inst{3-0} = src{3-0};
3236 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3237 def MOVi : AsI1<0b1101, (outs GPR:$Rd), (ins mod_imm:$imm), DPFrm, IIC_iMOVi,
3238 "mov", "\t$Rd, $imm", [(set GPR:$Rd, mod_imm:$imm)]>, UnaryDP,
3243 let Inst{15-12} = Rd;
3244 let Inst{19-16} = 0b0000;
3245 let Inst{11-0} = imm;
3248 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3249 def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins imm0_65535_expr:$imm),
3251 "movw", "\t$Rd, $imm",
3252 [(set GPR:$Rd, imm0_65535:$imm)]>,
3253 Requires<[IsARM, HasV6T2]>, UnaryDP, Sched<[WriteALU]> {
3256 let Inst{15-12} = Rd;
3257 let Inst{11-0} = imm{11-0};
3258 let Inst{19-16} = imm{15-12};
3261 let DecoderMethod = "DecodeArmMOVTWInstruction";
3264 def : InstAlias<"mov${p} $Rd, $imm",
3265 (MOVi16 GPR:$Rd, imm0_65535_expr:$imm, pred:$p)>,
3268 def MOVi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
3269 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
3272 let Constraints = "$src = $Rd" in {
3273 def MOVTi16 : AI1<0b1010, (outs GPRnopc:$Rd),
3274 (ins GPR:$src, imm0_65535_expr:$imm),
3276 "movt", "\t$Rd, $imm",
3278 (or (and GPR:$src, 0xffff),
3279 lo16AllZero:$imm))]>, UnaryDP,
3280 Requires<[IsARM, HasV6T2]>, Sched<[WriteALU]> {
3283 let Inst{15-12} = Rd;
3284 let Inst{11-0} = imm{11-0};
3285 let Inst{19-16} = imm{15-12};
3288 let DecoderMethod = "DecodeArmMOVTWInstruction";
3291 def MOVTi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
3292 (ins GPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
3297 def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
3298 Requires<[IsARM, HasV6T2]>;
3300 let Uses = [CPSR] in
3301 def RRX: PseudoInst<(outs GPR:$Rd), (ins GPR:$Rm), IIC_iMOVsi,
3302 [(set GPR:$Rd, (ARMrrx GPR:$Rm))]>, UnaryDP,
3303 Requires<[IsARM]>, Sched<[WriteALU]>;
3305 // These aren't really mov instructions, but we have to define them this way
3306 // due to flag operands.
3308 let Defs = [CPSR] in {
3309 def MOVsrl_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3310 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP,
3311 Sched<[WriteALU]>, Requires<[IsARM]>;
3312 def MOVsra_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3313 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP,
3314 Sched<[WriteALU]>, Requires<[IsARM]>;
3317 //===----------------------------------------------------------------------===//
3318 // Extend Instructions.
3323 def SXTB : AI_ext_rrot<0b01101010,
3324 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
3325 def SXTH : AI_ext_rrot<0b01101011,
3326 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
3328 def SXTAB : AI_exta_rrot<0b01101010,
3329 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
3330 def SXTAH : AI_exta_rrot<0b01101011,
3331 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
3333 def SXTB16 : AI_ext_rrot_np<0b01101000, "sxtb16">;
3335 def SXTAB16 : AI_exta_rrot_np<0b01101000, "sxtab16">;
3339 let AddedComplexity = 16 in {
3340 def UXTB : AI_ext_rrot<0b01101110,
3341 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
3342 def UXTH : AI_ext_rrot<0b01101111,
3343 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
3344 def UXTB16 : AI_ext_rrot<0b01101100,
3345 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
3347 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
3348 // The transformation should probably be done as a combiner action
3349 // instead so we can include a check for masking back in the upper
3350 // eight bits of the source into the lower eight bits of the result.
3351 //def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
3352 // (UXTB16r_rot GPR:$Src, 3)>;
3353 def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
3354 (UXTB16 GPR:$Src, 1)>;
3356 def UXTAB : AI_exta_rrot<0b01101110, "uxtab",
3357 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
3358 def UXTAH : AI_exta_rrot<0b01101111, "uxtah",
3359 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
3362 // This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
3363 def UXTAB16 : AI_exta_rrot_np<0b01101100, "uxtab16">;
3366 def SBFX : I<(outs GPRnopc:$Rd),
3367 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3368 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3369 "sbfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3370 Requires<[IsARM, HasV6T2]> {
3375 let Inst{27-21} = 0b0111101;
3376 let Inst{6-4} = 0b101;
3377 let Inst{20-16} = width;
3378 let Inst{15-12} = Rd;
3379 let Inst{11-7} = lsb;
3383 def UBFX : I<(outs GPRnopc:$Rd),
3384 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3385 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3386 "ubfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3387 Requires<[IsARM, HasV6T2]> {
3392 let Inst{27-21} = 0b0111111;
3393 let Inst{6-4} = 0b101;
3394 let Inst{20-16} = width;
3395 let Inst{15-12} = Rd;
3396 let Inst{11-7} = lsb;
3400 //===----------------------------------------------------------------------===//
3401 // Arithmetic Instructions.
3404 defm ADD : AsI1_bin_irs<0b0100, "add",
3405 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3406 BinOpFrag<(add node:$LHS, node:$RHS)>, 1>;
3407 defm SUB : AsI1_bin_irs<0b0010, "sub",
3408 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3409 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
3411 // ADD and SUB with 's' bit set.
3413 // Currently, ADDS/SUBS are pseudo opcodes that exist only in the
3414 // selection DAG. They are "lowered" to real ADD/SUB opcodes by
3415 // AdjustInstrPostInstrSelection where we determine whether or not to
3416 // set the "s" bit based on CPSR liveness.
3418 // FIXME: Eliminate ADDS/SUBS pseudo opcodes after adding tablegen
3419 // support for an optional CPSR definition that corresponds to the DAG
3420 // node's second value. We can then eliminate the implicit def of CPSR.
3421 defm ADDS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3422 BinOpFrag<(ARMaddc node:$LHS, node:$RHS)>, 1>;
3423 defm SUBS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3424 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
3426 defm ADC : AI1_adde_sube_irs<0b0101, "adc",
3427 BinOpWithFlagFrag<(ARMadde node:$LHS, node:$RHS, node:$FLAG)>, 1>;
3428 defm SBC : AI1_adde_sube_irs<0b0110, "sbc",
3429 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>>;
3431 defm RSB : AsI1_rbin_irs<0b0011, "rsb",
3432 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3433 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
3435 // FIXME: Eliminate them if we can write def : Pat patterns which defines
3436 // CPSR and the implicit def of CPSR is not needed.
3437 defm RSBS : AsI1_rbin_s_is<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3438 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
3440 defm RSC : AI1_rsc_irs<0b0111, "rsc",
3441 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>>;
3443 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
3444 // The assume-no-carry-in form uses the negation of the input since add/sub
3445 // assume opposite meanings of the carry flag (i.e., carry == !borrow).
3446 // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
3448 def : ARMPat<(add GPR:$src, mod_imm_neg:$imm),
3449 (SUBri GPR:$src, mod_imm_neg:$imm)>;
3450 def : ARMPat<(ARMaddc GPR:$src, mod_imm_neg:$imm),
3451 (SUBSri GPR:$src, mod_imm_neg:$imm)>;
3453 def : ARMPat<(add GPR:$src, imm0_65535_neg:$imm),
3454 (SUBrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>,
3455 Requires<[IsARM, HasV6T2]>;
3456 def : ARMPat<(ARMaddc GPR:$src, imm0_65535_neg:$imm),
3457 (SUBSrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>,
3458 Requires<[IsARM, HasV6T2]>;
3460 // The with-carry-in form matches bitwise not instead of the negation.
3461 // Effectively, the inverse interpretation of the carry flag already accounts
3462 // for part of the negation.
3463 def : ARMPat<(ARMadde GPR:$src, mod_imm_not:$imm, CPSR),
3464 (SBCri GPR:$src, mod_imm_not:$imm)>;
3465 def : ARMPat<(ARMadde GPR:$src, imm0_65535_neg:$imm, CPSR),
3466 (SBCrr GPR:$src, (MOVi16 (imm_not_XFORM imm:$imm)))>,
3467 Requires<[IsARM, HasV6T2]>;
3469 // Note: These are implemented in C++ code, because they have to generate
3470 // ADD/SUBrs instructions, which use a complex pattern that a xform function
3472 // (mul X, 2^n+1) -> (add (X << n), X)
3473 // (mul X, 2^n-1) -> (rsb X, (X << n))
3475 // ARM Arithmetic Instruction
3476 // GPR:$dst = GPR:$a op GPR:$b
3477 class AAI<bits<8> op27_20, bits<8> op11_4, string opc,
3478 list<dag> pattern = [],
3479 dag iops = (ins GPRnopc:$Rn, GPRnopc:$Rm),
3480 string asm = "\t$Rd, $Rn, $Rm">
3481 : AI<(outs GPRnopc:$Rd), iops, DPFrm, IIC_iALUr, opc, asm, pattern>,
3482 Sched<[WriteALU, ReadALU, ReadALU]> {
3486 let Inst{27-20} = op27_20;
3487 let Inst{11-4} = op11_4;
3488 let Inst{19-16} = Rn;
3489 let Inst{15-12} = Rd;
3492 let Unpredictable{11-8} = 0b1111;
3495 // Saturating add/subtract
3497 let DecoderMethod = "DecodeQADDInstruction" in
3498 def QADD : AAI<0b00010000, 0b00000101, "qadd",
3499 [(set GPRnopc:$Rd, (int_arm_qadd GPRnopc:$Rm, GPRnopc:$Rn))],
3500 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3502 def QSUB : AAI<0b00010010, 0b00000101, "qsub",
3503 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm, GPRnopc:$Rn))],
3504 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3505 def QDADD : AAI<0b00010100, 0b00000101, "qdadd", [],
3506 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3508 def QDSUB : AAI<0b00010110, 0b00000101, "qdsub", [],
3509 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3512 def QADD16 : AAI<0b01100010, 0b11110001, "qadd16">;
3513 def QADD8 : AAI<0b01100010, 0b11111001, "qadd8">;
3514 def QASX : AAI<0b01100010, 0b11110011, "qasx">;
3515 def QSAX : AAI<0b01100010, 0b11110101, "qsax">;
3516 def QSUB16 : AAI<0b01100010, 0b11110111, "qsub16">;
3517 def QSUB8 : AAI<0b01100010, 0b11111111, "qsub8">;
3518 def UQADD16 : AAI<0b01100110, 0b11110001, "uqadd16">;
3519 def UQADD8 : AAI<0b01100110, 0b11111001, "uqadd8">;
3520 def UQASX : AAI<0b01100110, 0b11110011, "uqasx">;
3521 def UQSAX : AAI<0b01100110, 0b11110101, "uqsax">;
3522 def UQSUB16 : AAI<0b01100110, 0b11110111, "uqsub16">;
3523 def UQSUB8 : AAI<0b01100110, 0b11111111, "uqsub8">;
3525 // Signed/Unsigned add/subtract
3527 def SASX : AAI<0b01100001, 0b11110011, "sasx">;
3528 def SADD16 : AAI<0b01100001, 0b11110001, "sadd16">;
3529 def SADD8 : AAI<0b01100001, 0b11111001, "sadd8">;
3530 def SSAX : AAI<0b01100001, 0b11110101, "ssax">;
3531 def SSUB16 : AAI<0b01100001, 0b11110111, "ssub16">;
3532 def SSUB8 : AAI<0b01100001, 0b11111111, "ssub8">;
3533 def UASX : AAI<0b01100101, 0b11110011, "uasx">;
3534 def UADD16 : AAI<0b01100101, 0b11110001, "uadd16">;
3535 def UADD8 : AAI<0b01100101, 0b11111001, "uadd8">;
3536 def USAX : AAI<0b01100101, 0b11110101, "usax">;
3537 def USUB16 : AAI<0b01100101, 0b11110111, "usub16">;
3538 def USUB8 : AAI<0b01100101, 0b11111111, "usub8">;
3540 // Signed/Unsigned halving add/subtract
3542 def SHASX : AAI<0b01100011, 0b11110011, "shasx">;
3543 def SHADD16 : AAI<0b01100011, 0b11110001, "shadd16">;
3544 def SHADD8 : AAI<0b01100011, 0b11111001, "shadd8">;
3545 def SHSAX : AAI<0b01100011, 0b11110101, "shsax">;
3546 def SHSUB16 : AAI<0b01100011, 0b11110111, "shsub16">;
3547 def SHSUB8 : AAI<0b01100011, 0b11111111, "shsub8">;
3548 def UHASX : AAI<0b01100111, 0b11110011, "uhasx">;
3549 def UHADD16 : AAI<0b01100111, 0b11110001, "uhadd16">;
3550 def UHADD8 : AAI<0b01100111, 0b11111001, "uhadd8">;
3551 def UHSAX : AAI<0b01100111, 0b11110101, "uhsax">;
3552 def UHSUB16 : AAI<0b01100111, 0b11110111, "uhsub16">;
3553 def UHSUB8 : AAI<0b01100111, 0b11111111, "uhsub8">;
3555 // Unsigned Sum of Absolute Differences [and Accumulate].
3557 def USAD8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3558 MulFrm /* for convenience */, NoItinerary, "usad8",
3559 "\t$Rd, $Rn, $Rm", []>,
3560 Requires<[IsARM, HasV6]>, Sched<[WriteALU, ReadALU, ReadALU]> {
3564 let Inst{27-20} = 0b01111000;
3565 let Inst{15-12} = 0b1111;
3566 let Inst{7-4} = 0b0001;
3567 let Inst{19-16} = Rd;
3568 let Inst{11-8} = Rm;
3571 def USADA8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3572 MulFrm /* for convenience */, NoItinerary, "usada8",
3573 "\t$Rd, $Rn, $Rm, $Ra", []>,
3574 Requires<[IsARM, HasV6]>, Sched<[WriteALU, ReadALU, ReadALU]>{
3579 let Inst{27-20} = 0b01111000;
3580 let Inst{7-4} = 0b0001;
3581 let Inst{19-16} = Rd;
3582 let Inst{15-12} = Ra;
3583 let Inst{11-8} = Rm;
3587 // Signed/Unsigned saturate
3589 def SSAT : AI<(outs GPRnopc:$Rd),
3590 (ins imm1_32:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3591 SatFrm, NoItinerary, "ssat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3596 let Inst{27-21} = 0b0110101;
3597 let Inst{5-4} = 0b01;
3598 let Inst{20-16} = sat_imm;
3599 let Inst{15-12} = Rd;
3600 let Inst{11-7} = sh{4-0};
3601 let Inst{6} = sh{5};
3605 def SSAT16 : AI<(outs GPRnopc:$Rd),
3606 (ins imm1_16:$sat_imm, GPRnopc:$Rn), SatFrm,
3607 NoItinerary, "ssat16", "\t$Rd, $sat_imm, $Rn", []> {
3611 let Inst{27-20} = 0b01101010;
3612 let Inst{11-4} = 0b11110011;
3613 let Inst{15-12} = Rd;
3614 let Inst{19-16} = sat_imm;
3618 def USAT : AI<(outs GPRnopc:$Rd),
3619 (ins imm0_31:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3620 SatFrm, NoItinerary, "usat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3625 let Inst{27-21} = 0b0110111;
3626 let Inst{5-4} = 0b01;
3627 let Inst{15-12} = Rd;
3628 let Inst{11-7} = sh{4-0};
3629 let Inst{6} = sh{5};
3630 let Inst{20-16} = sat_imm;
3634 def USAT16 : AI<(outs GPRnopc:$Rd),
3635 (ins imm0_15:$sat_imm, GPRnopc:$Rn), SatFrm,
3636 NoItinerary, "usat16", "\t$Rd, $sat_imm, $Rn", []> {
3640 let Inst{27-20} = 0b01101110;
3641 let Inst{11-4} = 0b11110011;
3642 let Inst{15-12} = Rd;
3643 let Inst{19-16} = sat_imm;
3647 def : ARMV6Pat<(int_arm_ssat GPRnopc:$a, imm:$pos),
3648 (SSAT imm:$pos, GPRnopc:$a, 0)>;
3649 def : ARMV6Pat<(int_arm_usat GPRnopc:$a, imm:$pos),
3650 (USAT imm:$pos, GPRnopc:$a, 0)>;
3652 //===----------------------------------------------------------------------===//
3653 // Bitwise Instructions.
3656 defm AND : AsI1_bin_irs<0b0000, "and",
3657 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3658 BinOpFrag<(and node:$LHS, node:$RHS)>, 1>;
3659 defm ORR : AsI1_bin_irs<0b1100, "orr",
3660 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3661 BinOpFrag<(or node:$LHS, node:$RHS)>, 1>;
3662 defm EOR : AsI1_bin_irs<0b0001, "eor",
3663 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3664 BinOpFrag<(xor node:$LHS, node:$RHS)>, 1>;
3665 defm BIC : AsI1_bin_irs<0b1110, "bic",
3666 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3667 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
3669 // FIXME: bf_inv_mask_imm should be two operands, the lsb and the msb, just
3670 // like in the actual instruction encoding. The complexity of mapping the mask
3671 // to the lsb/msb pair should be handled by ISel, not encapsulated in the
3672 // instruction description.
3673 def BFC : I<(outs GPR:$Rd), (ins GPR:$src, bf_inv_mask_imm:$imm),
3674 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3675 "bfc", "\t$Rd, $imm", "$src = $Rd",
3676 [(set GPR:$Rd, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
3677 Requires<[IsARM, HasV6T2]> {
3680 let Inst{27-21} = 0b0111110;
3681 let Inst{6-0} = 0b0011111;
3682 let Inst{15-12} = Rd;
3683 let Inst{11-7} = imm{4-0}; // lsb
3684 let Inst{20-16} = imm{9-5}; // msb
3687 // A8.6.18 BFI - Bitfield insert (Encoding A1)
3688 def BFI:I<(outs GPRnopc:$Rd), (ins GPRnopc:$src, GPR:$Rn, bf_inv_mask_imm:$imm),
3689 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3690 "bfi", "\t$Rd, $Rn, $imm", "$src = $Rd",
3691 [(set GPRnopc:$Rd, (ARMbfi GPRnopc:$src, GPR:$Rn,
3692 bf_inv_mask_imm:$imm))]>,
3693 Requires<[IsARM, HasV6T2]> {
3697 let Inst{27-21} = 0b0111110;
3698 let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15
3699 let Inst{15-12} = Rd;
3700 let Inst{11-7} = imm{4-0}; // lsb
3701 let Inst{20-16} = imm{9-5}; // width
3705 def MVNr : AsI1<0b1111, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMVNr,
3706 "mvn", "\t$Rd, $Rm",
3707 [(set GPR:$Rd, (not GPR:$Rm))]>, UnaryDP, Sched<[WriteALU]> {
3711 let Inst{19-16} = 0b0000;
3712 let Inst{11-4} = 0b00000000;
3713 let Inst{15-12} = Rd;
3716 def MVNsi : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_imm:$shift),
3717 DPSoRegImmFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3718 [(set GPR:$Rd, (not so_reg_imm:$shift))]>, UnaryDP,
3723 let Inst{19-16} = 0b0000;
3724 let Inst{15-12} = Rd;
3725 let Inst{11-5} = shift{11-5};
3727 let Inst{3-0} = shift{3-0};
3729 def MVNsr : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_reg:$shift),
3730 DPSoRegRegFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3731 [(set GPR:$Rd, (not so_reg_reg:$shift))]>, UnaryDP,
3736 let Inst{19-16} = 0b0000;
3737 let Inst{15-12} = Rd;
3738 let Inst{11-8} = shift{11-8};
3740 let Inst{6-5} = shift{6-5};
3742 let Inst{3-0} = shift{3-0};
3744 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3745 def MVNi : AsI1<0b1111, (outs GPR:$Rd), (ins mod_imm:$imm), DPFrm,
3746 IIC_iMVNi, "mvn", "\t$Rd, $imm",
3747 [(set GPR:$Rd, mod_imm_not:$imm)]>,UnaryDP, Sched<[WriteALU]> {
3751 let Inst{19-16} = 0b0000;
3752 let Inst{15-12} = Rd;
3753 let Inst{11-0} = imm;
3756 def : ARMPat<(and GPR:$src, mod_imm_not:$imm),
3757 (BICri GPR:$src, mod_imm_not:$imm)>;
3759 //===----------------------------------------------------------------------===//
3760 // Multiply Instructions.
3762 class AsMul1I32<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3763 string opc, string asm, list<dag> pattern>
3764 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3768 let Inst{19-16} = Rd;
3769 let Inst{11-8} = Rm;
3772 class AsMul1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3773 string opc, string asm, list<dag> pattern>
3774 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3779 let Inst{19-16} = RdHi;
3780 let Inst{15-12} = RdLo;
3781 let Inst{11-8} = Rm;
3784 class AsMla1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3785 string opc, string asm, list<dag> pattern>
3786 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3791 let Inst{19-16} = RdHi;
3792 let Inst{15-12} = RdLo;
3793 let Inst{11-8} = Rm;
3797 // FIXME: The v5 pseudos are only necessary for the additional Constraint
3798 // property. Remove them when it's possible to add those properties
3799 // on an individual MachineInstr, not just an instruction description.
3800 let isCommutable = 1, TwoOperandAliasConstraint = "$Rn = $Rd" in {
3801 def MUL : AsMul1I32<0b0000000, (outs GPRnopc:$Rd),
3802 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3803 IIC_iMUL32, "mul", "\t$Rd, $Rn, $Rm",
3804 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))]>,
3805 Requires<[IsARM, HasV6]> {
3806 let Inst{15-12} = 0b0000;
3807 let Unpredictable{15-12} = 0b1111;
3810 let Constraints = "@earlyclobber $Rd" in
3811 def MULv5: ARMPseudoExpand<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm,
3812 pred:$p, cc_out:$s),
3814 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))],
3815 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s)>,
3816 Requires<[IsARM, NoV6, UseMulOps]>;
3819 def MLA : AsMul1I32<0b0000001, (outs GPRnopc:$Rd),
3820 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra),
3821 IIC_iMAC32, "mla", "\t$Rd, $Rn, $Rm, $Ra",
3822 [(set GPRnopc:$Rd, (add (mul GPRnopc:$Rn, GPRnopc:$Rm), GPRnopc:$Ra))]>,
3823 Requires<[IsARM, HasV6, UseMulOps]> {
3825 let Inst{15-12} = Ra;
3828 let Constraints = "@earlyclobber $Rd" in
3829 def MLAv5: ARMPseudoExpand<(outs GPRnopc:$Rd),
3830 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra,
3831 pred:$p, cc_out:$s), 4, IIC_iMAC32,
3832 [(set GPRnopc:$Rd, (add (mul GPRnopc:$Rn, GPRnopc:$Rm), GPRnopc:$Ra))],
3833 (MLA GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra, pred:$p, cc_out:$s)>,
3834 Requires<[IsARM, NoV6]>;
3836 def MLS : AMul1I<0b0000011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3837 IIC_iMAC32, "mls", "\t$Rd, $Rn, $Rm, $Ra",
3838 [(set GPR:$Rd, (sub GPR:$Ra, (mul GPR:$Rn, GPR:$Rm)))]>,
3839 Requires<[IsARM, HasV6T2, UseMulOps]> {
3844 let Inst{19-16} = Rd;
3845 let Inst{15-12} = Ra;
3846 let Inst{11-8} = Rm;
3850 // Extra precision multiplies with low / high results
3851 let hasSideEffects = 0 in {
3852 let isCommutable = 1 in {
3853 def SMULL : AsMul1I64<0b0000110, (outs GPR:$RdLo, GPR:$RdHi),
3854 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3855 "smull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3856 Requires<[IsARM, HasV6]>;
3858 def UMULL : AsMul1I64<0b0000100, (outs GPR:$RdLo, GPR:$RdHi),
3859 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3860 "umull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3861 Requires<[IsARM, HasV6]>;
3863 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
3864 def SMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3865 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3867 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3868 Requires<[IsARM, NoV6]>;
3870 def UMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3871 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3873 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3874 Requires<[IsARM, NoV6]>;
3878 // Multiply + accumulate
3879 def SMLAL : AsMla1I64<0b0000111, (outs GPR:$RdLo, GPR:$RdHi),
3880 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64,
3881 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3882 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>;
3883 def UMLAL : AsMla1I64<0b0000101, (outs GPR:$RdLo, GPR:$RdHi),
3884 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64,
3885 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3886 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>;
3888 def UMAAL : AMul1I <0b0000010, (outs GPR:$RdLo, GPR:$RdHi),
3889 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3890 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3891 Requires<[IsARM, HasV6]> {
3896 let Inst{19-16} = RdHi;
3897 let Inst{15-12} = RdLo;
3898 let Inst{11-8} = Rm;
3903 "@earlyclobber $RdLo,@earlyclobber $RdHi,$RLo = $RdLo,$RHi = $RdHi" in {
3904 def SMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3905 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s),
3907 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi,
3908 pred:$p, cc_out:$s)>,
3909 Requires<[IsARM, NoV6]>;
3910 def UMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3911 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s),
3913 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi,
3914 pred:$p, cc_out:$s)>,
3915 Requires<[IsARM, NoV6]>;
3920 // Most significant word multiply
3921 def SMMUL : AMul2I <0b0111010, 0b0001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3922 IIC_iMUL32, "smmul", "\t$Rd, $Rn, $Rm",
3923 [(set GPR:$Rd, (mulhs GPR:$Rn, GPR:$Rm))]>,
3924 Requires<[IsARM, HasV6]> {
3925 let Inst{15-12} = 0b1111;
3928 def SMMULR : AMul2I <0b0111010, 0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3929 IIC_iMUL32, "smmulr", "\t$Rd, $Rn, $Rm", []>,
3930 Requires<[IsARM, HasV6]> {
3931 let Inst{15-12} = 0b1111;
3934 def SMMLA : AMul2Ia <0b0111010, 0b0001, (outs GPR:$Rd),
3935 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3936 IIC_iMAC32, "smmla", "\t$Rd, $Rn, $Rm, $Ra",
3937 [(set GPR:$Rd, (add (mulhs GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
3938 Requires<[IsARM, HasV6, UseMulOps]>;
3940 def SMMLAR : AMul2Ia <0b0111010, 0b0011, (outs GPR:$Rd),
3941 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3942 IIC_iMAC32, "smmlar", "\t$Rd, $Rn, $Rm, $Ra", []>,
3943 Requires<[IsARM, HasV6]>;
3945 def SMMLS : AMul2Ia <0b0111010, 0b1101, (outs GPR:$Rd),
3946 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3947 IIC_iMAC32, "smmls", "\t$Rd, $Rn, $Rm, $Ra", []>,
3948 Requires<[IsARM, HasV6, UseMulOps]>;
3950 def SMMLSR : AMul2Ia <0b0111010, 0b1111, (outs GPR:$Rd),
3951 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3952 IIC_iMAC32, "smmlsr", "\t$Rd, $Rn, $Rm, $Ra", []>,
3953 Requires<[IsARM, HasV6]>;
3955 multiclass AI_smul<string opc, PatFrag opnode> {
3956 def BB : AMulxyI<0b0001011, 0b00, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3957 IIC_iMUL16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm",
3958 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3959 (sext_inreg GPR:$Rm, i16)))]>,
3960 Requires<[IsARM, HasV5TE]>;
3962 def BT : AMulxyI<0b0001011, 0b10, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3963 IIC_iMUL16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm",
3964 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3965 (sra GPR:$Rm, (i32 16))))]>,
3966 Requires<[IsARM, HasV5TE]>;
3968 def TB : AMulxyI<0b0001011, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3969 IIC_iMUL16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm",
3970 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3971 (sext_inreg GPR:$Rm, i16)))]>,
3972 Requires<[IsARM, HasV5TE]>;
3974 def TT : AMulxyI<0b0001011, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3975 IIC_iMUL16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm",
3976 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3977 (sra GPR:$Rm, (i32 16))))]>,
3978 Requires<[IsARM, HasV5TE]>;
3980 def WB : AMulxyI<0b0001001, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3981 IIC_iMUL16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm",
3983 Requires<[IsARM, HasV5TE]>;
3985 def WT : AMulxyI<0b0001001, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3986 IIC_iMUL16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm",
3988 Requires<[IsARM, HasV5TE]>;
3992 multiclass AI_smla<string opc, PatFrag opnode> {
3993 let DecoderMethod = "DecodeSMLAInstruction" in {
3994 def BB : AMulxyIa<0b0001000, 0b00, (outs GPRnopc:$Rd),
3995 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3996 IIC_iMAC16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra",
3997 [(set GPRnopc:$Rd, (add GPR:$Ra,
3998 (opnode (sext_inreg GPRnopc:$Rn, i16),
3999 (sext_inreg GPRnopc:$Rm, i16))))]>,
4000 Requires<[IsARM, HasV5TE, UseMulOps]>;
4002 def BT : AMulxyIa<0b0001000, 0b10, (outs GPRnopc:$Rd),
4003 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4004 IIC_iMAC16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra",
4006 (add GPR:$Ra, (opnode (sext_inreg GPRnopc:$Rn, i16),
4007 (sra GPRnopc:$Rm, (i32 16)))))]>,
4008 Requires<[IsARM, HasV5TE, UseMulOps]>;
4010 def TB : AMulxyIa<0b0001000, 0b01, (outs GPRnopc:$Rd),
4011 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4012 IIC_iMAC16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra",
4014 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
4015 (sext_inreg GPRnopc:$Rm, i16))))]>,
4016 Requires<[IsARM, HasV5TE, UseMulOps]>;
4018 def TT : AMulxyIa<0b0001000, 0b11, (outs GPRnopc:$Rd),
4019 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4020 IIC_iMAC16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra",
4022 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
4023 (sra GPRnopc:$Rm, (i32 16)))))]>,
4024 Requires<[IsARM, HasV5TE, UseMulOps]>;
4026 def WB : AMulxyIa<0b0001001, 0b00, (outs GPRnopc:$Rd),
4027 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4028 IIC_iMAC16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra",
4030 Requires<[IsARM, HasV5TE, UseMulOps]>;
4032 def WT : AMulxyIa<0b0001001, 0b10, (outs GPRnopc:$Rd),
4033 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4034 IIC_iMAC16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra",
4036 Requires<[IsARM, HasV5TE, UseMulOps]>;
4040 defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
4041 defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
4043 // Halfword multiply accumulate long: SMLAL<x><y>.
4044 def SMLALBB : AMulxyI64<0b0001010, 0b00, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4045 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4046 IIC_iMAC64, "smlalbb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4047 Requires<[IsARM, HasV5TE]>;
4049 def SMLALBT : AMulxyI64<0b0001010, 0b10, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4050 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4051 IIC_iMAC64, "smlalbt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4052 Requires<[IsARM, HasV5TE]>;
4054 def SMLALTB : AMulxyI64<0b0001010, 0b01, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4055 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4056 IIC_iMAC64, "smlaltb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4057 Requires<[IsARM, HasV5TE]>;
4059 def SMLALTT : AMulxyI64<0b0001010, 0b11, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4060 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4061 IIC_iMAC64, "smlaltt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4062 Requires<[IsARM, HasV5TE]>;
4064 // Helper class for AI_smld.
4065 class AMulDualIbase<bit long, bit sub, bit swap, dag oops, dag iops,
4066 InstrItinClass itin, string opc, string asm>
4067 : AI<oops, iops, MulFrm, itin, opc, asm, []>, Requires<[IsARM, HasV6]> {
4070 let Inst{27-23} = 0b01110;
4071 let Inst{22} = long;
4072 let Inst{21-20} = 0b00;
4073 let Inst{11-8} = Rm;
4080 class AMulDualI<bit long, bit sub, bit swap, dag oops, dag iops,
4081 InstrItinClass itin, string opc, string asm>
4082 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4084 let Inst{15-12} = 0b1111;
4085 let Inst{19-16} = Rd;
4087 class AMulDualIa<bit long, bit sub, bit swap, dag oops, dag iops,
4088 InstrItinClass itin, string opc, string asm>
4089 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4092 let Inst{19-16} = Rd;
4093 let Inst{15-12} = Ra;
4095 class AMulDualI64<bit long, bit sub, bit swap, dag oops, dag iops,
4096 InstrItinClass itin, string opc, string asm>
4097 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4100 let Inst{19-16} = RdHi;
4101 let Inst{15-12} = RdLo;
4104 multiclass AI_smld<bit sub, string opc> {
4106 def D : AMulDualIa<0, sub, 0, (outs GPRnopc:$Rd),
4107 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4108 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm, $Ra">;
4110 def DX: AMulDualIa<0, sub, 1, (outs GPRnopc:$Rd),
4111 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4112 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm, $Ra">;
4114 def LD: AMulDualI64<1, sub, 0, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4115 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
4116 !strconcat(opc, "ld"), "\t$RdLo, $RdHi, $Rn, $Rm">;
4118 def LDX : AMulDualI64<1, sub, 1, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4119 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
4120 !strconcat(opc, "ldx"),"\t$RdLo, $RdHi, $Rn, $Rm">;
4124 defm SMLA : AI_smld<0, "smla">;
4125 defm SMLS : AI_smld<1, "smls">;
4127 multiclass AI_sdml<bit sub, string opc> {
4129 def D:AMulDualI<0, sub, 0, (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm),
4130 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm">;
4131 def DX:AMulDualI<0, sub, 1, (outs GPRnopc:$Rd),(ins GPRnopc:$Rn, GPRnopc:$Rm),
4132 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm">;
4135 defm SMUA : AI_sdml<0, "smua">;
4136 defm SMUS : AI_sdml<1, "smus">;
4138 //===----------------------------------------------------------------------===//
4139 // Division Instructions (ARMv7-A with virtualization extension)
4141 def SDIV : ADivA1I<0b001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV,
4142 "sdiv", "\t$Rd, $Rn, $Rm",
4143 [(set GPR:$Rd, (sdiv GPR:$Rn, GPR:$Rm))]>,
4144 Requires<[IsARM, HasDivideInARM]>;
4146 def UDIV : ADivA1I<0b011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV,
4147 "udiv", "\t$Rd, $Rn, $Rm",
4148 [(set GPR:$Rd, (udiv GPR:$Rn, GPR:$Rm))]>,
4149 Requires<[IsARM, HasDivideInARM]>;
4151 //===----------------------------------------------------------------------===//
4152 // Misc. Arithmetic Instructions.
4155 def CLZ : AMiscA1I<0b00010110, 0b0001, (outs GPR:$Rd), (ins GPR:$Rm),
4156 IIC_iUNAr, "clz", "\t$Rd, $Rm",
4157 [(set GPR:$Rd, (ctlz GPR:$Rm))]>, Requires<[IsARM, HasV5T]>,
4160 def RBIT : AMiscA1I<0b01101111, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
4161 IIC_iUNAr, "rbit", "\t$Rd, $Rm",
4162 [(set GPR:$Rd, (ARMrbit GPR:$Rm))]>,
4163 Requires<[IsARM, HasV6T2]>,
4166 def REV : AMiscA1I<0b01101011, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
4167 IIC_iUNAr, "rev", "\t$Rd, $Rm",
4168 [(set GPR:$Rd, (bswap GPR:$Rm))]>, Requires<[IsARM, HasV6]>,
4171 let AddedComplexity = 5 in
4172 def REV16 : AMiscA1I<0b01101011, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
4173 IIC_iUNAr, "rev16", "\t$Rd, $Rm",
4174 [(set GPR:$Rd, (rotr (bswap GPR:$Rm), (i32 16)))]>,
4175 Requires<[IsARM, HasV6]>,
4178 def : ARMV6Pat<(srl (bswap (extloadi16 addrmode3:$addr)), (i32 16)),
4179 (REV16 (LDRH addrmode3:$addr))>;
4180 def : ARMV6Pat<(truncstorei16 (srl (bswap GPR:$Rn), (i32 16)), addrmode3:$addr),
4181 (STRH (REV16 GPR:$Rn), addrmode3:$addr)>;
4183 let AddedComplexity = 5 in
4184 def REVSH : AMiscA1I<0b01101111, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
4185 IIC_iUNAr, "revsh", "\t$Rd, $Rm",
4186 [(set GPR:$Rd, (sra (bswap GPR:$Rm), (i32 16)))]>,
4187 Requires<[IsARM, HasV6]>,
4190 def : ARMV6Pat<(or (sra (shl GPR:$Rm, (i32 24)), (i32 16)),
4191 (and (srl GPR:$Rm, (i32 8)), 0xFF)),
4194 def PKHBT : APKHI<0b01101000, 0, (outs GPRnopc:$Rd),
4195 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_lsl_amt:$sh),
4196 IIC_iALUsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh",
4197 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF),
4198 (and (shl GPRnopc:$Rm, pkh_lsl_amt:$sh),
4200 Requires<[IsARM, HasV6]>,
4201 Sched<[WriteALUsi, ReadALU]>;
4203 // Alternate cases for PKHBT where identities eliminate some nodes.
4204 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (and GPRnopc:$Rm, 0xFFFF0000)),
4205 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, 0)>;
4206 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (shl GPRnopc:$Rm, imm16_31:$sh)),
4207 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, imm16_31:$sh)>;
4209 // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
4210 // will match the pattern below.
4211 def PKHTB : APKHI<0b01101000, 1, (outs GPRnopc:$Rd),
4212 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_asr_amt:$sh),
4213 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh",
4214 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF0000),
4215 (and (sra GPRnopc:$Rm, pkh_asr_amt:$sh),
4217 Requires<[IsARM, HasV6]>,
4218 Sched<[WriteALUsi, ReadALU]>;
4220 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
4221 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
4222 // We also can not replace a srl (17..31) by an arithmetic shift we would use in
4223 // pkhtb src1, src2, asr (17..31).
4224 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4225 (srl GPRnopc:$src2, imm16:$sh)),
4226 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16:$sh)>;
4227 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4228 (sra GPRnopc:$src2, imm16_31:$sh)),
4229 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16_31:$sh)>;
4230 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4231 (and (srl GPRnopc:$src2, imm1_15:$sh), 0xFFFF)),
4232 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm1_15:$sh)>;
4234 //===----------------------------------------------------------------------===//
4238 // + CRC32{B,H,W} 0x04C11DB7
4239 // + CRC32C{B,H,W} 0x1EDC6F41
4242 class AI_crc32<bit C, bits<2> sz, string suffix, SDPatternOperator builtin>
4243 : AInoP<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm), MiscFrm, NoItinerary,
4244 !strconcat("crc32", suffix), "\t$Rd, $Rn, $Rm",
4245 [(set GPRnopc:$Rd, (builtin GPRnopc:$Rn, GPRnopc:$Rm))]>,
4246 Requires<[IsARM, HasV8, HasCRC]> {
4251 let Inst{31-28} = 0b1110;
4252 let Inst{27-23} = 0b00010;
4253 let Inst{22-21} = sz;
4255 let Inst{19-16} = Rn;
4256 let Inst{15-12} = Rd;
4257 let Inst{11-10} = 0b00;
4260 let Inst{7-4} = 0b0100;
4263 let Unpredictable{11-8} = 0b1101;
4266 def CRC32B : AI_crc32<0, 0b00, "b", int_arm_crc32b>;
4267 def CRC32CB : AI_crc32<1, 0b00, "cb", int_arm_crc32cb>;
4268 def CRC32H : AI_crc32<0, 0b01, "h", int_arm_crc32h>;
4269 def CRC32CH : AI_crc32<1, 0b01, "ch", int_arm_crc32ch>;
4270 def CRC32W : AI_crc32<0, 0b10, "w", int_arm_crc32w>;
4271 def CRC32CW : AI_crc32<1, 0b10, "cw", int_arm_crc32cw>;
4273 //===----------------------------------------------------------------------===//
4274 // ARMv8.1a Privilege Access Never extension
4278 def SETPAN : AInoP<(outs), (ins imm0_1:$imm), MiscFrm, NoItinerary, "setpan",
4279 "\t$imm", []>, Requires<[IsARM, HasV8, HasV8_1a]> {
4282 let Inst{31-28} = 0b1111;
4283 let Inst{27-20} = 0b00010001;
4284 let Inst{19-16} = 0b0000;
4285 let Inst{15-10} = 0b000000;
4288 let Inst{7-4} = 0b0000;
4289 let Inst{3-0} = 0b0000;
4291 let Unpredictable{19-16} = 0b1111;
4292 let Unpredictable{15-10} = 0b111111;
4293 let Unpredictable{8} = 0b1;
4294 let Unpredictable{3-0} = 0b1111;
4297 //===----------------------------------------------------------------------===//
4298 // Comparison Instructions...
4301 defm CMP : AI1_cmp_irs<0b1010, "cmp",
4302 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
4303 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
4305 // ARMcmpZ can re-use the above instruction definitions.
4306 def : ARMPat<(ARMcmpZ GPR:$src, mod_imm:$imm),
4307 (CMPri GPR:$src, mod_imm:$imm)>;
4308 def : ARMPat<(ARMcmpZ GPR:$src, GPR:$rhs),
4309 (CMPrr GPR:$src, GPR:$rhs)>;
4310 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_imm:$rhs),
4311 (CMPrsi GPR:$src, so_reg_imm:$rhs)>;
4312 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_reg:$rhs),
4313 (CMPrsr GPR:$src, so_reg_reg:$rhs)>;
4315 // CMN register-integer
4316 let isCompare = 1, Defs = [CPSR] in {
4317 def CMNri : AI1<0b1011, (outs), (ins GPR:$Rn, mod_imm:$imm), DPFrm, IIC_iCMPi,
4318 "cmn", "\t$Rn, $imm",
4319 [(ARMcmn GPR:$Rn, mod_imm:$imm)]>,
4320 Sched<[WriteCMP, ReadALU]> {
4325 let Inst{19-16} = Rn;
4326 let Inst{15-12} = 0b0000;
4327 let Inst{11-0} = imm;
4329 let Unpredictable{15-12} = 0b1111;
4332 // CMN register-register/shift
4333 def CMNzrr : AI1<0b1011, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, IIC_iCMPr,
4334 "cmn", "\t$Rn, $Rm",
4335 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4336 GPR:$Rn, GPR:$Rm)]>, Sched<[WriteCMP, ReadALU, ReadALU]> {
4339 let isCommutable = 1;
4342 let Inst{19-16} = Rn;
4343 let Inst{15-12} = 0b0000;
4344 let Inst{11-4} = 0b00000000;
4347 let Unpredictable{15-12} = 0b1111;
4350 def CMNzrsi : AI1<0b1011, (outs),
4351 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, IIC_iCMPsr,
4352 "cmn", "\t$Rn, $shift",
4353 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4354 GPR:$Rn, so_reg_imm:$shift)]>,
4355 Sched<[WriteCMPsi, ReadALU]> {
4360 let Inst{19-16} = Rn;
4361 let Inst{15-12} = 0b0000;
4362 let Inst{11-5} = shift{11-5};
4364 let Inst{3-0} = shift{3-0};
4366 let Unpredictable{15-12} = 0b1111;
4369 def CMNzrsr : AI1<0b1011, (outs),
4370 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, IIC_iCMPsr,
4371 "cmn", "\t$Rn, $shift",
4372 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4373 GPRnopc:$Rn, so_reg_reg:$shift)]>,
4374 Sched<[WriteCMPsr, ReadALU]> {
4379 let Inst{19-16} = Rn;
4380 let Inst{15-12} = 0b0000;
4381 let Inst{11-8} = shift{11-8};
4383 let Inst{6-5} = shift{6-5};
4385 let Inst{3-0} = shift{3-0};
4387 let Unpredictable{15-12} = 0b1111;
4392 def : ARMPat<(ARMcmp GPR:$src, mod_imm_neg:$imm),
4393 (CMNri GPR:$src, mod_imm_neg:$imm)>;
4395 def : ARMPat<(ARMcmpZ GPR:$src, mod_imm_neg:$imm),
4396 (CMNri GPR:$src, mod_imm_neg:$imm)>;
4398 // Note that TST/TEQ don't set all the same flags that CMP does!
4399 defm TST : AI1_cmp_irs<0b1000, "tst",
4400 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
4401 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>, 1,
4402 "DecodeTSTInstruction">;
4403 defm TEQ : AI1_cmp_irs<0b1001, "teq",
4404 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
4405 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>, 1>;
4407 // Pseudo i64 compares for some floating point compares.
4408 let usesCustomInserter = 1, isBranch = 1, isTerminator = 1,
4410 def BCCi64 : PseudoInst<(outs),
4411 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, brtarget:$dst),
4413 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, bb:$dst)]>,
4416 def BCCZi64 : PseudoInst<(outs),
4417 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, brtarget:$dst), IIC_Br,
4418 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, 0, 0, bb:$dst)]>,
4420 } // usesCustomInserter
4423 // Conditional moves
4424 let hasSideEffects = 0 in {
4426 let isCommutable = 1, isSelect = 1 in
4427 def MOVCCr : ARMPseudoInst<(outs GPR:$Rd),
4428 (ins GPR:$false, GPR:$Rm, cmovpred:$p),
4430 [(set GPR:$Rd, (ARMcmov GPR:$false, GPR:$Rm,
4432 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4434 def MOVCCsi : ARMPseudoInst<(outs GPR:$Rd),
4435 (ins GPR:$false, so_reg_imm:$shift, cmovpred:$p),
4438 (ARMcmov GPR:$false, so_reg_imm:$shift,
4440 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4441 def MOVCCsr : ARMPseudoInst<(outs GPR:$Rd),
4442 (ins GPR:$false, so_reg_reg:$shift, cmovpred:$p),
4444 [(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_reg:$shift,
4446 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4449 let isMoveImm = 1 in
4451 : ARMPseudoInst<(outs GPR:$Rd),
4452 (ins GPR:$false, imm0_65535_expr:$imm, cmovpred:$p),
4454 [(set GPR:$Rd, (ARMcmov GPR:$false, imm0_65535:$imm,
4456 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>,
4459 let isMoveImm = 1 in
4460 def MOVCCi : ARMPseudoInst<(outs GPR:$Rd),
4461 (ins GPR:$false, mod_imm:$imm, cmovpred:$p),
4463 [(set GPR:$Rd, (ARMcmov GPR:$false, mod_imm:$imm,
4465 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4467 // Two instruction predicate mov immediate.
4468 let isMoveImm = 1 in
4470 : ARMPseudoInst<(outs GPR:$Rd),
4471 (ins GPR:$false, i32imm:$src, cmovpred:$p),
4473 [(set GPR:$Rd, (ARMcmov GPR:$false, imm:$src,
4475 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>;
4477 let isMoveImm = 1 in
4478 def MVNCCi : ARMPseudoInst<(outs GPR:$Rd),
4479 (ins GPR:$false, mod_imm:$imm, cmovpred:$p),
4481 [(set GPR:$Rd, (ARMcmov GPR:$false, mod_imm_not:$imm,
4483 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4488 //===----------------------------------------------------------------------===//
4489 // Atomic operations intrinsics
4492 def MemBarrierOptOperand : AsmOperandClass {
4493 let Name = "MemBarrierOpt";
4494 let ParserMethod = "parseMemBarrierOptOperand";
4496 def memb_opt : Operand<i32> {
4497 let PrintMethod = "printMemBOption";
4498 let ParserMatchClass = MemBarrierOptOperand;
4499 let DecoderMethod = "DecodeMemBarrierOption";
4502 def InstSyncBarrierOptOperand : AsmOperandClass {
4503 let Name = "InstSyncBarrierOpt";
4504 let ParserMethod = "parseInstSyncBarrierOptOperand";
4506 def instsyncb_opt : Operand<i32> {
4507 let PrintMethod = "printInstSyncBOption";
4508 let ParserMatchClass = InstSyncBarrierOptOperand;
4509 let DecoderMethod = "DecodeInstSyncBarrierOption";
4512 // Memory barriers protect the atomic sequences
4513 let hasSideEffects = 1 in {
4514 def DMB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4515 "dmb", "\t$opt", [(int_arm_dmb (i32 imm0_15:$opt))]>,
4516 Requires<[IsARM, HasDB]> {
4518 let Inst{31-4} = 0xf57ff05;
4519 let Inst{3-0} = opt;
4522 def DSB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4523 "dsb", "\t$opt", [(int_arm_dsb (i32 imm0_15:$opt))]>,
4524 Requires<[IsARM, HasDB]> {
4526 let Inst{31-4} = 0xf57ff04;
4527 let Inst{3-0} = opt;
4530 // ISB has only full system option
4531 def ISB : AInoP<(outs), (ins instsyncb_opt:$opt), MiscFrm, NoItinerary,
4532 "isb", "\t$opt", [(int_arm_isb (i32 imm0_15:$opt))]>,
4533 Requires<[IsARM, HasDB]> {
4535 let Inst{31-4} = 0xf57ff06;
4536 let Inst{3-0} = opt;
4540 let usesCustomInserter = 1, Defs = [CPSR] in {
4542 // Pseudo instruction that combines movs + predicated rsbmi
4543 // to implement integer ABS
4544 def ABS : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$src), 8, NoItinerary, []>;
4547 let usesCustomInserter = 1 in {
4548 def COPY_STRUCT_BYVAL_I32 : PseudoInst<
4549 (outs), (ins GPR:$dst, GPR:$src, i32imm:$size, i32imm:$alignment),
4551 [(ARMcopystructbyval GPR:$dst, GPR:$src, imm:$size, imm:$alignment)]>;
4554 def ldrex_1 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4555 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4558 def ldrex_2 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4559 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4562 def ldrex_4 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4563 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4566 def strex_1 : PatFrag<(ops node:$val, node:$ptr),
4567 (int_arm_strex node:$val, node:$ptr), [{
4568 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4571 def strex_2 : PatFrag<(ops node:$val, node:$ptr),
4572 (int_arm_strex node:$val, node:$ptr), [{
4573 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4576 def strex_4 : PatFrag<(ops node:$val, node:$ptr),
4577 (int_arm_strex node:$val, node:$ptr), [{
4578 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4581 def ldaex_1 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4582 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4585 def ldaex_2 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4586 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4589 def ldaex_4 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4590 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4593 def stlex_1 : PatFrag<(ops node:$val, node:$ptr),
4594 (int_arm_stlex node:$val, node:$ptr), [{
4595 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4598 def stlex_2 : PatFrag<(ops node:$val, node:$ptr),
4599 (int_arm_stlex node:$val, node:$ptr), [{
4600 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4603 def stlex_4 : PatFrag<(ops node:$val, node:$ptr),
4604 (int_arm_stlex node:$val, node:$ptr), [{
4605 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4608 let mayLoad = 1 in {
4609 def LDREXB : AIldrex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4610 NoItinerary, "ldrexb", "\t$Rt, $addr",
4611 [(set GPR:$Rt, (ldrex_1 addr_offset_none:$addr))]>;
4612 def LDREXH : AIldrex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4613 NoItinerary, "ldrexh", "\t$Rt, $addr",
4614 [(set GPR:$Rt, (ldrex_2 addr_offset_none:$addr))]>;
4615 def LDREX : AIldrex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4616 NoItinerary, "ldrex", "\t$Rt, $addr",
4617 [(set GPR:$Rt, (ldrex_4 addr_offset_none:$addr))]>;
4618 let hasExtraDefRegAllocReq = 1 in
4619 def LDREXD : AIldrex<0b01, (outs GPRPairOp:$Rt),(ins addr_offset_none:$addr),
4620 NoItinerary, "ldrexd", "\t$Rt, $addr", []> {
4621 let DecoderMethod = "DecodeDoubleRegLoad";
4624 def LDAEXB : AIldaex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4625 NoItinerary, "ldaexb", "\t$Rt, $addr",
4626 [(set GPR:$Rt, (ldaex_1 addr_offset_none:$addr))]>;
4627 def LDAEXH : AIldaex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4628 NoItinerary, "ldaexh", "\t$Rt, $addr",
4629 [(set GPR:$Rt, (ldaex_2 addr_offset_none:$addr))]>;
4630 def LDAEX : AIldaex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4631 NoItinerary, "ldaex", "\t$Rt, $addr",
4632 [(set GPR:$Rt, (ldaex_4 addr_offset_none:$addr))]>;
4633 let hasExtraDefRegAllocReq = 1 in
4634 def LDAEXD : AIldaex<0b01, (outs GPRPairOp:$Rt),(ins addr_offset_none:$addr),
4635 NoItinerary, "ldaexd", "\t$Rt, $addr", []> {
4636 let DecoderMethod = "DecodeDoubleRegLoad";
4640 let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
4641 def STREXB: AIstrex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4642 NoItinerary, "strexb", "\t$Rd, $Rt, $addr",
4643 [(set GPR:$Rd, (strex_1 GPR:$Rt,
4644 addr_offset_none:$addr))]>;
4645 def STREXH: AIstrex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4646 NoItinerary, "strexh", "\t$Rd, $Rt, $addr",
4647 [(set GPR:$Rd, (strex_2 GPR:$Rt,
4648 addr_offset_none:$addr))]>;
4649 def STREX : AIstrex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4650 NoItinerary, "strex", "\t$Rd, $Rt, $addr",
4651 [(set GPR:$Rd, (strex_4 GPR:$Rt,
4652 addr_offset_none:$addr))]>;
4653 let hasExtraSrcRegAllocReq = 1 in
4654 def STREXD : AIstrex<0b01, (outs GPR:$Rd),
4655 (ins GPRPairOp:$Rt, addr_offset_none:$addr),
4656 NoItinerary, "strexd", "\t$Rd, $Rt, $addr", []> {
4657 let DecoderMethod = "DecodeDoubleRegStore";
4659 def STLEXB: AIstlex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4660 NoItinerary, "stlexb", "\t$Rd, $Rt, $addr",
4662 (stlex_1 GPR:$Rt, addr_offset_none:$addr))]>;
4663 def STLEXH: AIstlex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4664 NoItinerary, "stlexh", "\t$Rd, $Rt, $addr",
4666 (stlex_2 GPR:$Rt, addr_offset_none:$addr))]>;
4667 def STLEX : AIstlex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4668 NoItinerary, "stlex", "\t$Rd, $Rt, $addr",
4670 (stlex_4 GPR:$Rt, addr_offset_none:$addr))]>;
4671 let hasExtraSrcRegAllocReq = 1 in
4672 def STLEXD : AIstlex<0b01, (outs GPR:$Rd),
4673 (ins GPRPairOp:$Rt, addr_offset_none:$addr),
4674 NoItinerary, "stlexd", "\t$Rd, $Rt, $addr", []> {
4675 let DecoderMethod = "DecodeDoubleRegStore";
4679 def CLREX : AXI<(outs), (ins), MiscFrm, NoItinerary, "clrex",
4681 Requires<[IsARM, HasV7]> {
4682 let Inst{31-0} = 0b11110101011111111111000000011111;
4685 def : ARMPat<(strex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr),
4686 (STREXB GPR:$Rt, addr_offset_none:$addr)>;
4687 def : ARMPat<(strex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr),
4688 (STREXH GPR:$Rt, addr_offset_none:$addr)>;
4690 def : ARMPat<(stlex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr),
4691 (STLEXB GPR:$Rt, addr_offset_none:$addr)>;
4692 def : ARMPat<(stlex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr),
4693 (STLEXH GPR:$Rt, addr_offset_none:$addr)>;
4695 class acquiring_load<PatFrag base>
4696 : PatFrag<(ops node:$ptr), (base node:$ptr), [{
4697 AtomicOrdering Ordering = cast<AtomicSDNode>(N)->getOrdering();
4698 return isAtLeastAcquire(Ordering);
4701 def atomic_load_acquire_8 : acquiring_load<atomic_load_8>;
4702 def atomic_load_acquire_16 : acquiring_load<atomic_load_16>;
4703 def atomic_load_acquire_32 : acquiring_load<atomic_load_32>;
4705 class releasing_store<PatFrag base>
4706 : PatFrag<(ops node:$ptr, node:$val), (base node:$ptr, node:$val), [{
4707 AtomicOrdering Ordering = cast<AtomicSDNode>(N)->getOrdering();
4708 return isAtLeastRelease(Ordering);
4711 def atomic_store_release_8 : releasing_store<atomic_store_8>;
4712 def atomic_store_release_16 : releasing_store<atomic_store_16>;
4713 def atomic_store_release_32 : releasing_store<atomic_store_32>;
4715 let AddedComplexity = 8 in {
4716 def : ARMPat<(atomic_load_acquire_8 addr_offset_none:$addr), (LDAB addr_offset_none:$addr)>;
4717 def : ARMPat<(atomic_load_acquire_16 addr_offset_none:$addr), (LDAH addr_offset_none:$addr)>;
4718 def : ARMPat<(atomic_load_acquire_32 addr_offset_none:$addr), (LDA addr_offset_none:$addr)>;
4719 def : ARMPat<(atomic_store_release_8 addr_offset_none:$addr, GPR:$val), (STLB GPR:$val, addr_offset_none:$addr)>;
4720 def : ARMPat<(atomic_store_release_16 addr_offset_none:$addr, GPR:$val), (STLH GPR:$val, addr_offset_none:$addr)>;
4721 def : ARMPat<(atomic_store_release_32 addr_offset_none:$addr, GPR:$val), (STL GPR:$val, addr_offset_none:$addr)>;
4724 // SWP/SWPB are deprecated in V6/V7.
4725 let mayLoad = 1, mayStore = 1 in {
4726 def SWP : AIswp<0, (outs GPRnopc:$Rt),
4727 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swp", []>,
4729 def SWPB: AIswp<1, (outs GPRnopc:$Rt),
4730 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swpb", []>,
4734 //===----------------------------------------------------------------------===//
4735 // Coprocessor Instructions.
4738 def CDP : ABI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4739 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4740 NoItinerary, "cdp", "\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4741 [(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4742 imm:$CRm, imm:$opc2)]>,
4751 let Inst{3-0} = CRm;
4753 let Inst{7-5} = opc2;
4754 let Inst{11-8} = cop;
4755 let Inst{15-12} = CRd;
4756 let Inst{19-16} = CRn;
4757 let Inst{23-20} = opc1;
4760 def CDP2 : ABXI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4761 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4762 NoItinerary, "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4763 [(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4764 imm:$CRm, imm:$opc2)]>,
4766 let Inst{31-28} = 0b1111;
4774 let Inst{3-0} = CRm;
4776 let Inst{7-5} = opc2;
4777 let Inst{11-8} = cop;
4778 let Inst{15-12} = CRd;
4779 let Inst{19-16} = CRn;
4780 let Inst{23-20} = opc1;
4783 class ACI<dag oops, dag iops, string opc, string asm,
4784 IndexMode im = IndexModeNone>
4785 : I<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
4787 let Inst{27-25} = 0b110;
4789 class ACInoP<dag oops, dag iops, string opc, string asm,
4790 IndexMode im = IndexModeNone>
4791 : InoP<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
4793 let Inst{31-28} = 0b1111;
4794 let Inst{27-25} = 0b110;
4796 multiclass LdStCop<bit load, bit Dbit, string asm> {
4797 def _OFFSET : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4798 asm, "\t$cop, $CRd, $addr"> {
4802 let Inst{24} = 1; // P = 1
4803 let Inst{23} = addr{8};
4804 let Inst{22} = Dbit;
4805 let Inst{21} = 0; // W = 0
4806 let Inst{20} = load;
4807 let Inst{19-16} = addr{12-9};
4808 let Inst{15-12} = CRd;
4809 let Inst{11-8} = cop;
4810 let Inst{7-0} = addr{7-0};
4811 let DecoderMethod = "DecodeCopMemInstruction";
4813 def _PRE : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr),
4814 asm, "\t$cop, $CRd, $addr!", IndexModePre> {
4818 let Inst{24} = 1; // P = 1
4819 let Inst{23} = addr{8};
4820 let Inst{22} = Dbit;
4821 let Inst{21} = 1; // W = 1
4822 let Inst{20} = load;
4823 let Inst{19-16} = addr{12-9};
4824 let Inst{15-12} = CRd;
4825 let Inst{11-8} = cop;
4826 let Inst{7-0} = addr{7-0};
4827 let DecoderMethod = "DecodeCopMemInstruction";
4829 def _POST: ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4830 postidx_imm8s4:$offset),
4831 asm, "\t$cop, $CRd, $addr, $offset", IndexModePost> {
4836 let Inst{24} = 0; // P = 0
4837 let Inst{23} = offset{8};
4838 let Inst{22} = Dbit;
4839 let Inst{21} = 1; // W = 1
4840 let Inst{20} = load;
4841 let Inst{19-16} = addr;
4842 let Inst{15-12} = CRd;
4843 let Inst{11-8} = cop;
4844 let Inst{7-0} = offset{7-0};
4845 let DecoderMethod = "DecodeCopMemInstruction";
4847 def _OPTION : ACI<(outs),
4848 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4849 coproc_option_imm:$option),
4850 asm, "\t$cop, $CRd, $addr, $option"> {
4855 let Inst{24} = 0; // P = 0
4856 let Inst{23} = 1; // U = 1
4857 let Inst{22} = Dbit;
4858 let Inst{21} = 0; // W = 0
4859 let Inst{20} = load;
4860 let Inst{19-16} = addr;
4861 let Inst{15-12} = CRd;
4862 let Inst{11-8} = cop;
4863 let Inst{7-0} = option;
4864 let DecoderMethod = "DecodeCopMemInstruction";
4867 multiclass LdSt2Cop<bit load, bit Dbit, string asm> {
4868 def _OFFSET : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4869 asm, "\t$cop, $CRd, $addr"> {
4873 let Inst{24} = 1; // P = 1
4874 let Inst{23} = addr{8};
4875 let Inst{22} = Dbit;
4876 let Inst{21} = 0; // W = 0
4877 let Inst{20} = load;
4878 let Inst{19-16} = addr{12-9};
4879 let Inst{15-12} = CRd;
4880 let Inst{11-8} = cop;
4881 let Inst{7-0} = addr{7-0};
4882 let DecoderMethod = "DecodeCopMemInstruction";
4884 def _PRE : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr),
4885 asm, "\t$cop, $CRd, $addr!", IndexModePre> {
4889 let Inst{24} = 1; // P = 1
4890 let Inst{23} = addr{8};
4891 let Inst{22} = Dbit;
4892 let Inst{21} = 1; // W = 1
4893 let Inst{20} = load;
4894 let Inst{19-16} = addr{12-9};
4895 let Inst{15-12} = CRd;
4896 let Inst{11-8} = cop;
4897 let Inst{7-0} = addr{7-0};
4898 let DecoderMethod = "DecodeCopMemInstruction";
4900 def _POST: ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4901 postidx_imm8s4:$offset),
4902 asm, "\t$cop, $CRd, $addr, $offset", IndexModePost> {
4907 let Inst{24} = 0; // P = 0
4908 let Inst{23} = offset{8};
4909 let Inst{22} = Dbit;
4910 let Inst{21} = 1; // W = 1
4911 let Inst{20} = load;
4912 let Inst{19-16} = addr;
4913 let Inst{15-12} = CRd;
4914 let Inst{11-8} = cop;
4915 let Inst{7-0} = offset{7-0};
4916 let DecoderMethod = "DecodeCopMemInstruction";
4918 def _OPTION : ACInoP<(outs),
4919 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4920 coproc_option_imm:$option),
4921 asm, "\t$cop, $CRd, $addr, $option"> {
4926 let Inst{24} = 0; // P = 0
4927 let Inst{23} = 1; // U = 1
4928 let Inst{22} = Dbit;
4929 let Inst{21} = 0; // W = 0
4930 let Inst{20} = load;
4931 let Inst{19-16} = addr;
4932 let Inst{15-12} = CRd;
4933 let Inst{11-8} = cop;
4934 let Inst{7-0} = option;
4935 let DecoderMethod = "DecodeCopMemInstruction";
4939 defm LDC : LdStCop <1, 0, "ldc">;
4940 defm LDCL : LdStCop <1, 1, "ldcl">;
4941 defm STC : LdStCop <0, 0, "stc">;
4942 defm STCL : LdStCop <0, 1, "stcl">;
4943 defm LDC2 : LdSt2Cop<1, 0, "ldc2">, Requires<[PreV8]>;
4944 defm LDC2L : LdSt2Cop<1, 1, "ldc2l">, Requires<[PreV8]>;
4945 defm STC2 : LdSt2Cop<0, 0, "stc2">, Requires<[PreV8]>;
4946 defm STC2L : LdSt2Cop<0, 1, "stc2l">, Requires<[PreV8]>;
4948 //===----------------------------------------------------------------------===//
4949 // Move between coprocessor and ARM core register.
4952 class MovRCopro<string opc, bit direction, dag oops, dag iops,
4954 : ABI<0b1110, oops, iops, NoItinerary, opc,
4955 "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2", pattern> {
4956 let Inst{20} = direction;
4966 let Inst{15-12} = Rt;
4967 let Inst{11-8} = cop;
4968 let Inst{23-21} = opc1;
4969 let Inst{7-5} = opc2;
4970 let Inst{3-0} = CRm;
4971 let Inst{19-16} = CRn;
4974 def MCR : MovRCopro<"mcr", 0 /* from ARM core register to coprocessor */,
4976 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4977 c_imm:$CRm, imm0_7:$opc2),
4978 [(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
4979 imm:$CRm, imm:$opc2)]>,
4980 ComplexDeprecationPredicate<"MCR">;
4981 def : ARMInstAlias<"mcr${p} $cop, $opc1, $Rt, $CRn, $CRm",
4982 (MCR p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4983 c_imm:$CRm, 0, pred:$p)>;
4984 def MRC : MovRCopro<"mrc", 1 /* from coprocessor to ARM core register */,
4985 (outs GPRwithAPSR:$Rt),
4986 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
4988 def : ARMInstAlias<"mrc${p} $cop, $opc1, $Rt, $CRn, $CRm",
4989 (MRC GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
4990 c_imm:$CRm, 0, pred:$p)>;
4992 def : ARMPat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
4993 (MRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
4995 class MovRCopro2<string opc, bit direction, dag oops, dag iops,
4997 : ABXI<0b1110, oops, iops, NoItinerary,
4998 !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), pattern> {
4999 let Inst{31-24} = 0b11111110;
5000 let Inst{20} = direction;
5010 let Inst{15-12} = Rt;
5011 let Inst{11-8} = cop;
5012 let Inst{23-21} = opc1;
5013 let Inst{7-5} = opc2;
5014 let Inst{3-0} = CRm;
5015 let Inst{19-16} = CRn;
5018 def MCR2 : MovRCopro2<"mcr2", 0 /* from ARM core register to coprocessor */,
5020 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5021 c_imm:$CRm, imm0_7:$opc2),
5022 [(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
5023 imm:$CRm, imm:$opc2)]>,
5025 def : ARMInstAlias<"mcr2 $cop, $opc1, $Rt, $CRn, $CRm",
5026 (MCR2 p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5028 def MRC2 : MovRCopro2<"mrc2", 1 /* from coprocessor to ARM core register */,
5029 (outs GPRwithAPSR:$Rt),
5030 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
5033 def : ARMInstAlias<"mrc2 $cop, $opc1, $Rt, $CRn, $CRm",
5034 (MRC2 GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
5037 def : ARMV5TPat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn,
5038 imm:$CRm, imm:$opc2),
5039 (MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
5041 class MovRRCopro<string opc, bit direction, list<dag> pattern = []>
5042 : ABI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
5043 GPRnopc:$Rt, GPRnopc:$Rt2, c_imm:$CRm),
5044 NoItinerary, opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm", pattern> {
5045 let Inst{23-21} = 0b010;
5046 let Inst{20} = direction;
5054 let Inst{15-12} = Rt;
5055 let Inst{19-16} = Rt2;
5056 let Inst{11-8} = cop;
5057 let Inst{7-4} = opc1;
5058 let Inst{3-0} = CRm;
5061 def MCRR : MovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */,
5062 [(int_arm_mcrr imm:$cop, imm:$opc1, GPRnopc:$Rt,
5063 GPRnopc:$Rt2, imm:$CRm)]>;
5064 def MRRC : MovRRCopro<"mrrc", 1 /* from coprocessor to ARM core register */>;
5066 class MovRRCopro2<string opc, bit direction, list<dag> pattern = []>
5067 : ABXI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
5068 GPRnopc:$Rt, GPRnopc:$Rt2, c_imm:$CRm), NoItinerary,
5069 !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern>,
5071 let Inst{31-28} = 0b1111;
5072 let Inst{23-21} = 0b010;
5073 let Inst{20} = direction;
5081 let Inst{15-12} = Rt;
5082 let Inst{19-16} = Rt2;
5083 let Inst{11-8} = cop;
5084 let Inst{7-4} = opc1;
5085 let Inst{3-0} = CRm;
5087 let DecoderMethod = "DecodeMRRC2";
5090 def MCRR2 : MovRRCopro2<"mcrr2", 0 /* from ARM core register to coprocessor */,
5091 [(int_arm_mcrr2 imm:$cop, imm:$opc1, GPRnopc:$Rt,
5092 GPRnopc:$Rt2, imm:$CRm)]>;
5093 def MRRC2 : MovRRCopro2<"mrrc2", 1 /* from coprocessor to ARM core register */>;
5095 //===----------------------------------------------------------------------===//
5096 // Move between special register and ARM core register
5099 // Move to ARM core register from Special Register
5100 def MRS : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
5101 "mrs", "\t$Rd, apsr", []> {
5103 let Inst{23-16} = 0b00001111;
5104 let Unpredictable{19-17} = 0b111;
5106 let Inst{15-12} = Rd;
5108 let Inst{11-0} = 0b000000000000;
5109 let Unpredictable{11-0} = 0b110100001111;
5112 def : InstAlias<"mrs${p} $Rd, cpsr", (MRS GPRnopc:$Rd, pred:$p)>,
5115 // The MRSsys instruction is the MRS instruction from the ARM ARM,
5116 // section B9.3.9, with the R bit set to 1.
5117 def MRSsys : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
5118 "mrs", "\t$Rd, spsr", []> {
5120 let Inst{23-16} = 0b01001111;
5121 let Unpredictable{19-16} = 0b1111;
5123 let Inst{15-12} = Rd;
5125 let Inst{11-0} = 0b000000000000;
5126 let Unpredictable{11-0} = 0b110100001111;
5129 // However, the MRS (banked register) system instruction (ARMv7VE) *does* have a
5130 // separate encoding (distinguished by bit 5.
5131 def MRSbanked : ABI<0b0001, (outs GPRnopc:$Rd), (ins banked_reg:$banked),
5132 NoItinerary, "mrs", "\t$Rd, $banked", []>,
5133 Requires<[IsARM, HasVirtualization]> {
5138 let Inst{22} = banked{5}; // R bit
5139 let Inst{21-20} = 0b00;
5140 let Inst{19-16} = banked{3-0};
5141 let Inst{15-12} = Rd;
5142 let Inst{11-9} = 0b001;
5143 let Inst{8} = banked{4};
5144 let Inst{7-0} = 0b00000000;
5147 // Move from ARM core register to Special Register
5149 // No need to have both system and application versions of MSR (immediate) or
5150 // MSR (register), the encodings are the same and the assembly parser has no way
5151 // to distinguish between them. The mask operand contains the special register
5152 // (R Bit) in bit 4 and bits 3-0 contains the mask with the fields to be
5153 // accessed in the special register.
5154 def MSR : ABI<0b0001, (outs), (ins msr_mask:$mask, GPR:$Rn), NoItinerary,
5155 "msr", "\t$mask, $Rn", []> {
5160 let Inst{22} = mask{4}; // R bit
5161 let Inst{21-20} = 0b10;
5162 let Inst{19-16} = mask{3-0};
5163 let Inst{15-12} = 0b1111;
5164 let Inst{11-4} = 0b00000000;
5168 def MSRi : ABI<0b0011, (outs), (ins msr_mask:$mask, mod_imm:$imm), NoItinerary,
5169 "msr", "\t$mask, $imm", []> {
5174 let Inst{22} = mask{4}; // R bit
5175 let Inst{21-20} = 0b10;
5176 let Inst{19-16} = mask{3-0};
5177 let Inst{15-12} = 0b1111;
5178 let Inst{11-0} = imm;
5181 // However, the MSR (banked register) system instruction (ARMv7VE) *does* have a
5182 // separate encoding (distinguished by bit 5.
5183 def MSRbanked : ABI<0b0001, (outs), (ins banked_reg:$banked, GPRnopc:$Rn),
5184 NoItinerary, "msr", "\t$banked, $Rn", []>,
5185 Requires<[IsARM, HasVirtualization]> {
5190 let Inst{22} = banked{5}; // R bit
5191 let Inst{21-20} = 0b10;
5192 let Inst{19-16} = banked{3-0};
5193 let Inst{15-12} = 0b1111;
5194 let Inst{11-9} = 0b001;
5195 let Inst{8} = banked{4};
5196 let Inst{7-4} = 0b0000;
5200 // Dynamic stack allocation yields a _chkstk for Windows targets. These calls
5201 // are needed to probe the stack when allocating more than
5202 // 4k bytes in one go. Touching the stack at 4K increments is necessary to
5203 // ensure that the guard pages used by the OS virtual memory manager are
5204 // allocated in correct sequence.
5205 // The main point of having separate instruction are extra unmodelled effects
5206 // (compared to ordinary calls) like stack pointer change.
5208 def win__chkstk : SDNode<"ARMISD::WIN__CHKSTK", SDTNone,
5209 [SDNPHasChain, SDNPSideEffect]>;
5210 let usesCustomInserter = 1, Uses = [R4], Defs = [R4, SP] in
5211 def WIN__CHKSTK : PseudoInst<(outs), (ins), NoItinerary, [(win__chkstk)]>;
5213 //===----------------------------------------------------------------------===//
5217 // __aeabi_read_tp preserves the registers r1-r3.
5218 // This is a pseudo inst so that we can get the encoding right,
5219 // complete with fixup for the aeabi_read_tp function.
5220 // TPsoft is valid for ARM mode only, in case of Thumb mode a tTPsoft pattern
5221 // is defined in "ARMInstrThumb.td".
5223 Defs = [R0, R12, LR, CPSR], Uses = [SP] in {
5224 def TPsoft : ARMPseudoInst<(outs), (ins), 4, IIC_Br,
5225 [(set R0, ARMthread_pointer)]>, Sched<[WriteBr]>;
5228 //===----------------------------------------------------------------------===//
5229 // SJLJ Exception handling intrinsics
5230 // eh_sjlj_setjmp() is an instruction sequence to store the return
5231 // address and save #0 in R0 for the non-longjmp case.
5232 // Since by its nature we may be coming from some other function to get
5233 // here, and we're using the stack frame for the containing function to
5234 // save/restore registers, we can't keep anything live in regs across
5235 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
5236 // when we get here from a longjmp(). We force everything out of registers
5237 // except for our own input by listing the relevant registers in Defs. By
5238 // doing so, we also cause the prologue/epilogue code to actively preserve
5239 // all of the callee-saved resgisters, which is exactly what we want.
5240 // A constant value is passed in $val, and we use the location as a scratch.
5242 // These are pseudo-instructions and are lowered to individual MC-insts, so
5243 // no encoding information is necessary.
5245 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
5246 Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15 ],
5247 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
5248 def Int_eh_sjlj_setjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
5250 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
5251 Requires<[IsARM, HasVFP2]>;
5255 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
5256 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
5257 def Int_eh_sjlj_setjmp_nofp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
5259 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
5260 Requires<[IsARM, NoVFP]>;
5263 // FIXME: Non-IOS version(s)
5264 let isBarrier = 1, hasSideEffects = 1, isTerminator = 1,
5265 Defs = [ R7, LR, SP ] in {
5266 def Int_eh_sjlj_longjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$scratch),
5268 [(ARMeh_sjlj_longjmp GPR:$src, GPR:$scratch)]>,
5272 // eh.sjlj.dispatchsetup pseudo-instruction.
5273 // This pseudo is used for both ARM and Thumb. Any differences are handled when
5274 // the pseudo is expanded (which happens before any passes that need the
5275 // instruction size).
5276 let isBarrier = 1 in
5277 def Int_eh_sjlj_dispatchsetup : PseudoInst<(outs), (ins), NoItinerary, []>;
5280 //===----------------------------------------------------------------------===//
5281 // Non-Instruction Patterns
5284 // ARMv4 indirect branch using (MOVr PC, dst)
5285 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in
5286 def MOVPCRX : ARMPseudoExpand<(outs), (ins GPR:$dst),
5287 4, IIC_Br, [(brind GPR:$dst)],
5288 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>,
5289 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
5291 // Large immediate handling.
5293 // 32-bit immediate using two piece mod_imms or movw + movt.
5294 // This is a single pseudo instruction, the benefit is that it can be remat'd
5295 // as a single unit instead of having to handle reg inputs.
5296 // FIXME: Remove this when we can do generalized remat.
5297 let isReMaterializable = 1, isMoveImm = 1 in
5298 def MOVi32imm : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
5299 [(set GPR:$dst, (arm_i32imm:$src))]>,
5302 def LDRLIT_ga_abs : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iLoad_i,
5303 [(set GPR:$dst, (ARMWrapper tglobaladdr:$src))]>,
5304 Requires<[IsARM, DontUseMovt]>;
5306 // Pseudo instruction that combines movw + movt + add pc (if PIC).
5307 // It also makes it possible to rematerialize the instructions.
5308 // FIXME: Remove this when we can do generalized remat and when machine licm
5309 // can properly the instructions.
5310 let isReMaterializable = 1 in {
5311 def MOV_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5313 [(set GPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>,
5314 Requires<[IsARM, UseMovt]>;
5316 def LDRLIT_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5319 (ARMWrapperPIC tglobaladdr:$addr))]>,
5320 Requires<[IsARM, DontUseMovt]>;
5322 let AddedComplexity = 10 in
5323 def LDRLIT_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5326 (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
5327 Requires<[IsARM, DontUseMovt]>;
5329 let AddedComplexity = 10 in
5330 def MOV_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5332 [(set GPR:$dst, (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
5333 Requires<[IsARM, UseMovt]>;
5334 } // isReMaterializable
5336 // ConstantPool, GlobalAddress, and JumpTable
5337 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
5338 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
5339 Requires<[IsARM, UseMovt]>;
5340 def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
5341 (LEApcrelJT tjumptable:$dst, imm:$id)>;
5343 // TODO: add,sub,and, 3-instr forms?
5345 // Tail calls. These patterns also apply to Thumb mode.
5346 def : Pat<(ARMtcret tcGPR:$dst), (TCRETURNri tcGPR:$dst)>;
5347 def : Pat<(ARMtcret (i32 tglobaladdr:$dst)), (TCRETURNdi texternalsym:$dst)>;
5348 def : Pat<(ARMtcret (i32 texternalsym:$dst)), (TCRETURNdi texternalsym:$dst)>;
5351 def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>;
5352 def : ARMPat<(ARMcall_nolink texternalsym:$func),
5353 (BMOVPCB_CALL texternalsym:$func)>;
5355 // zextload i1 -> zextload i8
5356 def : ARMPat<(zextloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5357 def : ARMPat<(zextloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5359 // extload -> zextload
5360 def : ARMPat<(extloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5361 def : ARMPat<(extloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5362 def : ARMPat<(extloadi8 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5363 def : ARMPat<(extloadi8 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5365 def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
5367 def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
5368 def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
5371 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
5372 (sra (shl GPR:$b, (i32 16)), (i32 16))),
5373 (SMULBB GPR:$a, GPR:$b)>;
5374 def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
5375 (SMULBB GPR:$a, GPR:$b)>;
5376 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
5377 (sra GPR:$b, (i32 16))),
5378 (SMULBT GPR:$a, GPR:$b)>;
5379 def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, (i32 16))),
5380 (SMULBT GPR:$a, GPR:$b)>;
5381 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)),
5382 (sra (shl GPR:$b, (i32 16)), (i32 16))),
5383 (SMULTB GPR:$a, GPR:$b)>;
5384 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), sext_16_node:$b),
5385 (SMULTB GPR:$a, GPR:$b)>;
5387 def : ARMV5MOPat<(add GPR:$acc,
5388 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
5389 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
5390 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5391 def : ARMV5MOPat<(add GPR:$acc,
5392 (mul sext_16_node:$a, sext_16_node:$b)),
5393 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5394 def : ARMV5MOPat<(add GPR:$acc,
5395 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
5396 (sra GPR:$b, (i32 16)))),
5397 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
5398 def : ARMV5MOPat<(add GPR:$acc,
5399 (mul sext_16_node:$a, (sra GPR:$b, (i32 16)))),
5400 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
5401 def : ARMV5MOPat<(add GPR:$acc,
5402 (mul (sra GPR:$a, (i32 16)),
5403 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
5404 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
5405 def : ARMV5MOPat<(add GPR:$acc,
5406 (mul (sra GPR:$a, (i32 16)), sext_16_node:$b)),
5407 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
5410 // Pre-v7 uses MCR for synchronization barriers.
5411 def : ARMPat<(ARMMemBarrierMCR GPR:$zero), (MCR 15, 0, GPR:$zero, 7, 10, 5)>,
5412 Requires<[IsARM, HasV6]>;
5414 // SXT/UXT with no rotate
5415 let AddedComplexity = 16 in {
5416 def : ARMV6Pat<(and GPR:$Src, 0x000000FF), (UXTB GPR:$Src, 0)>;
5417 def : ARMV6Pat<(and GPR:$Src, 0x0000FFFF), (UXTH GPR:$Src, 0)>;
5418 def : ARMV6Pat<(and GPR:$Src, 0x00FF00FF), (UXTB16 GPR:$Src, 0)>;
5419 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0x00FF)),
5420 (UXTAB GPR:$Rn, GPR:$Rm, 0)>;
5421 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0xFFFF)),
5422 (UXTAH GPR:$Rn, GPR:$Rm, 0)>;
5425 def : ARMV6Pat<(sext_inreg GPR:$Src, i8), (SXTB GPR:$Src, 0)>;
5426 def : ARMV6Pat<(sext_inreg GPR:$Src, i16), (SXTH GPR:$Src, 0)>;
5428 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i8)),
5429 (SXTAB GPR:$Rn, GPRnopc:$Rm, 0)>;
5430 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i16)),
5431 (SXTAH GPR:$Rn, GPRnopc:$Rm, 0)>;
5433 // Atomic load/store patterns
5434 def : ARMPat<(atomic_load_8 ldst_so_reg:$src),
5435 (LDRBrs ldst_so_reg:$src)>;
5436 def : ARMPat<(atomic_load_8 addrmode_imm12:$src),
5437 (LDRBi12 addrmode_imm12:$src)>;
5438 def : ARMPat<(atomic_load_16 addrmode3:$src),
5439 (LDRH addrmode3:$src)>;
5440 def : ARMPat<(atomic_load_32 ldst_so_reg:$src),
5441 (LDRrs ldst_so_reg:$src)>;
5442 def : ARMPat<(atomic_load_32 addrmode_imm12:$src),
5443 (LDRi12 addrmode_imm12:$src)>;
5444 def : ARMPat<(atomic_store_8 ldst_so_reg:$ptr, GPR:$val),
5445 (STRBrs GPR:$val, ldst_so_reg:$ptr)>;
5446 def : ARMPat<(atomic_store_8 addrmode_imm12:$ptr, GPR:$val),
5447 (STRBi12 GPR:$val, addrmode_imm12:$ptr)>;
5448 def : ARMPat<(atomic_store_16 addrmode3:$ptr, GPR:$val),
5449 (STRH GPR:$val, addrmode3:$ptr)>;
5450 def : ARMPat<(atomic_store_32 ldst_so_reg:$ptr, GPR:$val),
5451 (STRrs GPR:$val, ldst_so_reg:$ptr)>;
5452 def : ARMPat<(atomic_store_32 addrmode_imm12:$ptr, GPR:$val),
5453 (STRi12 GPR:$val, addrmode_imm12:$ptr)>;
5456 //===----------------------------------------------------------------------===//
5460 include "ARMInstrThumb.td"
5462 //===----------------------------------------------------------------------===//
5466 include "ARMInstrThumb2.td"
5468 //===----------------------------------------------------------------------===//
5469 // Floating Point Support
5472 include "ARMInstrVFP.td"
5474 //===----------------------------------------------------------------------===//
5475 // Advanced SIMD (NEON) Support
5478 include "ARMInstrNEON.td"
5480 //===----------------------------------------------------------------------===//
5481 // Assembler aliases
5485 def : InstAlias<"dmb", (DMB 0xf)>, Requires<[IsARM, HasDB]>;
5486 def : InstAlias<"dsb", (DSB 0xf)>, Requires<[IsARM, HasDB]>;
5487 def : InstAlias<"isb", (ISB 0xf)>, Requires<[IsARM, HasDB]>;
5489 // System instructions
5490 def : MnemonicAlias<"swi", "svc">;
5492 // Load / Store Multiple
5493 def : MnemonicAlias<"ldmfd", "ldm">;
5494 def : MnemonicAlias<"ldmia", "ldm">;
5495 def : MnemonicAlias<"ldmea", "ldmdb">;
5496 def : MnemonicAlias<"stmfd", "stmdb">;
5497 def : MnemonicAlias<"stmia", "stm">;
5498 def : MnemonicAlias<"stmea", "stm">;
5500 // PKHBT/PKHTB with default shift amount. PKHTB is equivalent to PKHBT when the
5501 // shift amount is zero (i.e., unspecified).
5502 def : InstAlias<"pkhbt${p} $Rd, $Rn, $Rm",
5503 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
5504 Requires<[IsARM, HasV6]>;
5505 def : InstAlias<"pkhtb${p} $Rd, $Rn, $Rm",
5506 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
5507 Requires<[IsARM, HasV6]>;
5509 // PUSH/POP aliases for STM/LDM
5510 def : ARMInstAlias<"push${p} $regs", (STMDB_UPD SP, pred:$p, reglist:$regs)>;
5511 def : ARMInstAlias<"pop${p} $regs", (LDMIA_UPD SP, pred:$p, reglist:$regs)>;
5513 // SSAT/USAT optional shift operand.
5514 def : ARMInstAlias<"ssat${p} $Rd, $sat_imm, $Rn",
5515 (SSAT GPRnopc:$Rd, imm1_32:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5516 def : ARMInstAlias<"usat${p} $Rd, $sat_imm, $Rn",
5517 (USAT GPRnopc:$Rd, imm0_31:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5520 // Extend instruction optional rotate operand.
5521 def : ARMInstAlias<"sxtab${p} $Rd, $Rn, $Rm",
5522 (SXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5523 def : ARMInstAlias<"sxtah${p} $Rd, $Rn, $Rm",
5524 (SXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5525 def : ARMInstAlias<"sxtab16${p} $Rd, $Rn, $Rm",
5526 (SXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5527 def : ARMInstAlias<"sxtb${p} $Rd, $Rm",
5528 (SXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5529 def : ARMInstAlias<"sxtb16${p} $Rd, $Rm",
5530 (SXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5531 def : ARMInstAlias<"sxth${p} $Rd, $Rm",
5532 (SXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5534 def : ARMInstAlias<"uxtab${p} $Rd, $Rn, $Rm",
5535 (UXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5536 def : ARMInstAlias<"uxtah${p} $Rd, $Rn, $Rm",
5537 (UXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5538 def : ARMInstAlias<"uxtab16${p} $Rd, $Rn, $Rm",
5539 (UXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5540 def : ARMInstAlias<"uxtb${p} $Rd, $Rm",
5541 (UXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5542 def : ARMInstAlias<"uxtb16${p} $Rd, $Rm",
5543 (UXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5544 def : ARMInstAlias<"uxth${p} $Rd, $Rm",
5545 (UXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5549 def : MnemonicAlias<"rfefa", "rfeda">;
5550 def : MnemonicAlias<"rfeea", "rfedb">;
5551 def : MnemonicAlias<"rfefd", "rfeia">;
5552 def : MnemonicAlias<"rfeed", "rfeib">;
5553 def : MnemonicAlias<"rfe", "rfeia">;
5556 def : MnemonicAlias<"srsfa", "srsib">;
5557 def : MnemonicAlias<"srsea", "srsia">;
5558 def : MnemonicAlias<"srsfd", "srsdb">;
5559 def : MnemonicAlias<"srsed", "srsda">;
5560 def : MnemonicAlias<"srs", "srsia">;
5563 def : MnemonicAlias<"qsubaddx", "qsax">;
5565 def : MnemonicAlias<"saddsubx", "sasx">;
5566 // SHASX == SHADDSUBX
5567 def : MnemonicAlias<"shaddsubx", "shasx">;
5568 // SHSAX == SHSUBADDX
5569 def : MnemonicAlias<"shsubaddx", "shsax">;
5571 def : MnemonicAlias<"ssubaddx", "ssax">;
5573 def : MnemonicAlias<"uaddsubx", "uasx">;
5574 // UHASX == UHADDSUBX
5575 def : MnemonicAlias<"uhaddsubx", "uhasx">;
5576 // UHSAX == UHSUBADDX
5577 def : MnemonicAlias<"uhsubaddx", "uhsax">;
5578 // UQASX == UQADDSUBX
5579 def : MnemonicAlias<"uqaddsubx", "uqasx">;
5580 // UQSAX == UQSUBADDX
5581 def : MnemonicAlias<"uqsubaddx", "uqsax">;
5583 def : MnemonicAlias<"usubaddx", "usax">;
5585 // "mov Rd, mod_imm_not" can be handled via "mvn" in assembly, just like
5587 def : ARMInstAlias<"mov${s}${p} $Rd, $imm",
5588 (MVNi rGPR:$Rd, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
5589 def : ARMInstAlias<"mvn${s}${p} $Rd, $imm",
5590 (MOVi rGPR:$Rd, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
5591 // Same for AND <--> BIC
5592 def : ARMInstAlias<"bic${s}${p} $Rd, $Rn, $imm",
5593 (ANDri rGPR:$Rd, rGPR:$Rn, mod_imm_not:$imm,
5594 pred:$p, cc_out:$s)>;
5595 def : ARMInstAlias<"bic${s}${p} $Rdn, $imm",
5596 (ANDri rGPR:$Rdn, rGPR:$Rdn, mod_imm_not:$imm,
5597 pred:$p, cc_out:$s)>;
5598 def : ARMInstAlias<"and${s}${p} $Rd, $Rn, $imm",
5599 (BICri rGPR:$Rd, rGPR:$Rn, mod_imm_not:$imm,
5600 pred:$p, cc_out:$s)>;
5601 def : ARMInstAlias<"and${s}${p} $Rdn, $imm",
5602 (BICri rGPR:$Rdn, rGPR:$Rdn, mod_imm_not:$imm,
5603 pred:$p, cc_out:$s)>;
5605 // Likewise, "add Rd, mod_imm_neg" -> sub
5606 def : ARMInstAlias<"add${s}${p} $Rd, $Rn, $imm",
5607 (SUBri GPR:$Rd, GPR:$Rn, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
5608 def : ARMInstAlias<"add${s}${p} $Rd, $imm",
5609 (SUBri GPR:$Rd, GPR:$Rd, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
5610 // Same for CMP <--> CMN via mod_imm_neg
5611 def : ARMInstAlias<"cmp${p} $Rd, $imm",
5612 (CMNri rGPR:$Rd, mod_imm_neg:$imm, pred:$p)>;
5613 def : ARMInstAlias<"cmn${p} $Rd, $imm",
5614 (CMPri rGPR:$Rd, mod_imm_neg:$imm, pred:$p)>;
5616 // The shifter forms of the MOV instruction are aliased to the ASR, LSL,
5617 // LSR, ROR, and RRX instructions.
5618 // FIXME: We need C++ parser hooks to map the alias to the MOV
5619 // encoding. It seems we should be able to do that sort of thing
5620 // in tblgen, but it could get ugly.
5621 let TwoOperandAliasConstraint = "$Rm = $Rd" in {
5622 def ASRi : ARMAsmPseudo<"asr${s}${p} $Rd, $Rm, $imm",
5623 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
5625 def LSRi : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rm, $imm",
5626 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
5628 def LSLi : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rm, $imm",
5629 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
5631 def RORi : ARMAsmPseudo<"ror${s}${p} $Rd, $Rm, $imm",
5632 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
5635 def RRXi : ARMAsmPseudo<"rrx${s}${p} $Rd, $Rm",
5636 (ins GPR:$Rd, GPR:$Rm, pred:$p, cc_out:$s)>;
5637 let TwoOperandAliasConstraint = "$Rn = $Rd" in {
5638 def ASRr : ARMAsmPseudo<"asr${s}${p} $Rd, $Rn, $Rm",
5639 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5641 def LSRr : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rn, $Rm",
5642 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5644 def LSLr : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rn, $Rm",
5645 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5647 def RORr : ARMAsmPseudo<"ror${s}${p} $Rd, $Rn, $Rm",
5648 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5652 // "neg" is and alias for "rsb rd, rn, #0"
5653 def : ARMInstAlias<"neg${s}${p} $Rd, $Rm",
5654 (RSBri GPR:$Rd, GPR:$Rm, 0, pred:$p, cc_out:$s)>;
5656 // Pre-v6, 'mov r0, r0' was used as a NOP encoding.
5657 def : InstAlias<"nop${p}", (MOVr R0, R0, pred:$p, zero_reg)>,
5658 Requires<[IsARM, NoV6]>;
5660 // MUL/UMLAL/SMLAL/UMULL/SMULL are available on all arches, but
5661 // the instruction definitions need difference constraints pre-v6.
5662 // Use these aliases for the assembly parsing on pre-v6.
5663 def : InstAlias<"mul${s}${p} $Rd, $Rn, $Rm",
5664 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s)>,
5665 Requires<[IsARM, NoV6]>;
5666 def : InstAlias<"mla${s}${p} $Rd, $Rn, $Rm, $Ra",
5667 (MLA GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra,
5668 pred:$p, cc_out:$s)>,
5669 Requires<[IsARM, NoV6]>;
5670 def : InstAlias<"smlal${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5671 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5672 Requires<[IsARM, NoV6]>;
5673 def : InstAlias<"umlal${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5674 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5675 Requires<[IsARM, NoV6]>;
5676 def : InstAlias<"smull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5677 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5678 Requires<[IsARM, NoV6]>;
5679 def : InstAlias<"umull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5680 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5681 Requires<[IsARM, NoV6]>;
5683 // 'it' blocks in ARM mode just validate the predicates. The IT itself
5685 def ITasm : ARMAsmPseudo<"it$mask $cc", (ins it_pred:$cc, it_mask:$mask)>,
5686 ComplexDeprecationPredicate<"IT">;
5688 let mayLoad = 1, mayStore =1, hasSideEffects = 1 in
5689 def SPACE : PseudoInst<(outs GPR:$Rd), (ins i32imm:$size, GPR:$Rn),
5691 [(set GPR:$Rd, (int_arm_space imm:$size, GPR:$Rn))]>;