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 SDTBinaryArithWithFlags : SDTypeProfile<2, 2,
77 SDTCisInt<0>, SDTCisVT<1, i32>]>;
79 // SDTBinaryArithWithFlagsInOut - RES1, CPSR = op LHS, RHS, CPSR
80 def SDTBinaryArithWithFlagsInOut : SDTypeProfile<2, 3,
87 def SDT_ARM64bitmlal : SDTypeProfile<2,4, [ SDTCisVT<0, i32>, SDTCisVT<1, i32>,
88 SDTCisVT<2, i32>, SDTCisVT<3, i32>,
89 SDTCisVT<4, i32>, SDTCisVT<5, i32> ] >;
90 def ARMUmlal : SDNode<"ARMISD::UMLAL", SDT_ARM64bitmlal>;
91 def ARMSmlal : SDNode<"ARMISD::SMLAL", SDT_ARM64bitmlal>;
94 def ARMWrapper : SDNode<"ARMISD::Wrapper", SDTIntUnaryOp>;
95 def ARMWrapperDYN : SDNode<"ARMISD::WrapperDYN", SDTIntUnaryOp>;
96 def ARMWrapperPIC : SDNode<"ARMISD::WrapperPIC", SDTIntUnaryOp>;
97 def ARMWrapperJT : SDNode<"ARMISD::WrapperJT", SDTIntBinOp>;
99 def ARMcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_ARMCallSeqStart,
100 [SDNPHasChain, SDNPSideEffect, SDNPOutGlue]>;
101 def ARMcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_ARMCallSeqEnd,
102 [SDNPHasChain, SDNPSideEffect,
103 SDNPOptInGlue, SDNPOutGlue]>;
104 def ARMcopystructbyval : SDNode<"ARMISD::COPY_STRUCT_BYVAL" ,
106 [SDNPHasChain, SDNPInGlue, SDNPOutGlue,
107 SDNPMayStore, SDNPMayLoad]>;
109 def ARMcall : SDNode<"ARMISD::CALL", SDT_ARMcall,
110 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
112 def ARMcall_pred : SDNode<"ARMISD::CALL_PRED", SDT_ARMcall,
113 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
115 def ARMcall_nolink : SDNode<"ARMISD::CALL_NOLINK", SDT_ARMcall,
116 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
119 def ARMretflag : SDNode<"ARMISD::RET_FLAG", SDTNone,
120 [SDNPHasChain, SDNPOptInGlue]>;
122 def ARMcmov : SDNode<"ARMISD::CMOV", SDT_ARMCMov,
125 def ARMbrcond : SDNode<"ARMISD::BRCOND", SDT_ARMBrcond,
126 [SDNPHasChain, SDNPInGlue, SDNPOutGlue]>;
128 def ARMbrjt : SDNode<"ARMISD::BR_JT", SDT_ARMBrJT,
130 def ARMbr2jt : SDNode<"ARMISD::BR2_JT", SDT_ARMBr2JT,
133 def ARMBcci64 : SDNode<"ARMISD::BCC_i64", SDT_ARMBCC_i64,
136 def ARMcmp : SDNode<"ARMISD::CMP", SDT_ARMCmp,
139 def ARMcmn : SDNode<"ARMISD::CMN", SDT_ARMCmp,
142 def ARMcmpZ : SDNode<"ARMISD::CMPZ", SDT_ARMCmp,
143 [SDNPOutGlue, SDNPCommutative]>;
145 def ARMpic_add : SDNode<"ARMISD::PIC_ADD", SDT_ARMPICAdd>;
147 def ARMsrl_flag : SDNode<"ARMISD::SRL_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
148 def ARMsra_flag : SDNode<"ARMISD::SRA_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
149 def ARMrrx : SDNode<"ARMISD::RRX" , SDTIntUnaryOp, [SDNPInGlue ]>;
151 def ARMaddc : SDNode<"ARMISD::ADDC", SDTBinaryArithWithFlags,
153 def ARMsubc : SDNode<"ARMISD::SUBC", SDTBinaryArithWithFlags>;
154 def ARMadde : SDNode<"ARMISD::ADDE", SDTBinaryArithWithFlagsInOut>;
155 def ARMsube : SDNode<"ARMISD::SUBE", SDTBinaryArithWithFlagsInOut>;
157 def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>;
158 def ARMeh_sjlj_setjmp: SDNode<"ARMISD::EH_SJLJ_SETJMP",
159 SDT_ARMEH_SJLJ_Setjmp,
160 [SDNPHasChain, SDNPSideEffect]>;
161 def ARMeh_sjlj_longjmp: SDNode<"ARMISD::EH_SJLJ_LONGJMP",
162 SDT_ARMEH_SJLJ_Longjmp,
163 [SDNPHasChain, SDNPSideEffect]>;
165 def ARMMemBarrier : SDNode<"ARMISD::MEMBARRIER", SDT_ARMMEMBARRIER,
166 [SDNPHasChain, SDNPSideEffect]>;
167 def ARMMemBarrierMCR : SDNode<"ARMISD::MEMBARRIER_MCR", SDT_ARMMEMBARRIER,
168 [SDNPHasChain, SDNPSideEffect]>;
169 def ARMPreload : SDNode<"ARMISD::PRELOAD", SDT_ARMPREFETCH,
170 [SDNPHasChain, SDNPMayLoad, SDNPMayStore]>;
172 def ARMrbit : SDNode<"ARMISD::RBIT", SDTIntUnaryOp>;
174 def ARMtcret : SDNode<"ARMISD::TC_RETURN", SDT_ARMTCRET,
175 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
178 def ARMbfi : SDNode<"ARMISD::BFI", SDT_ARMBFI>;
180 //===----------------------------------------------------------------------===//
181 // ARM Instruction Predicate Definitions.
183 def HasV4T : Predicate<"Subtarget->hasV4TOps()">,
184 AssemblerPredicate<"HasV4TOps", "armv4t">;
185 def NoV4T : Predicate<"!Subtarget->hasV4TOps()">;
186 def HasV5T : Predicate<"Subtarget->hasV5TOps()">;
187 def HasV5TE : Predicate<"Subtarget->hasV5TEOps()">,
188 AssemblerPredicate<"HasV5TEOps", "armv5te">;
189 def HasV6 : Predicate<"Subtarget->hasV6Ops()">,
190 AssemblerPredicate<"HasV6Ops", "armv6">;
191 def NoV6 : Predicate<"!Subtarget->hasV6Ops()">;
192 def HasV6T2 : Predicate<"Subtarget->hasV6T2Ops()">,
193 AssemblerPredicate<"HasV6T2Ops", "armv6t2">;
194 def NoV6T2 : Predicate<"!Subtarget->hasV6T2Ops()">;
195 def HasV7 : Predicate<"Subtarget->hasV7Ops()">,
196 AssemblerPredicate<"HasV7Ops", "armv7">;
197 def NoVFP : Predicate<"!Subtarget->hasVFP2()">;
198 def HasVFP2 : Predicate<"Subtarget->hasVFP2()">,
199 AssemblerPredicate<"FeatureVFP2", "VFP2">;
200 def HasVFP3 : Predicate<"Subtarget->hasVFP3()">,
201 AssemblerPredicate<"FeatureVFP3", "VFP3">;
202 def HasVFP4 : Predicate<"Subtarget->hasVFP4()">,
203 AssemblerPredicate<"FeatureVFP4", "VFP4">;
204 def HasNEON : Predicate<"Subtarget->hasNEON()">,
205 AssemblerPredicate<"FeatureNEON", "NEON">;
206 def HasFP16 : Predicate<"Subtarget->hasFP16()">,
207 AssemblerPredicate<"FeatureFP16","half-float">;
208 def HasDivide : Predicate<"Subtarget->hasDivide()">,
209 AssemblerPredicate<"FeatureHWDiv", "divide">;
210 def HasDivideInARM : Predicate<"Subtarget->hasDivideInARMMode()">,
211 AssemblerPredicate<"FeatureHWDivARM">;
212 def HasT2ExtractPack : Predicate<"Subtarget->hasT2ExtractPack()">,
213 AssemblerPredicate<"FeatureT2XtPk",
215 def HasThumb2DSP : Predicate<"Subtarget->hasThumb2DSP()">,
216 AssemblerPredicate<"FeatureDSPThumb2",
218 def HasDB : Predicate<"Subtarget->hasDataBarrier()">,
219 AssemblerPredicate<"FeatureDB",
221 def HasMP : Predicate<"Subtarget->hasMPExtension()">,
222 AssemblerPredicate<"FeatureMP",
224 def UseNEONForFP : Predicate<"Subtarget->useNEONForSinglePrecisionFP()">;
225 def DontUseNEONForFP : Predicate<"!Subtarget->useNEONForSinglePrecisionFP()">;
226 def IsThumb : Predicate<"Subtarget->isThumb()">,
227 AssemblerPredicate<"ModeThumb", "thumb">;
228 def IsThumb1Only : Predicate<"Subtarget->isThumb1Only()">;
229 def IsThumb2 : Predicate<"Subtarget->isThumb2()">,
230 AssemblerPredicate<"ModeThumb,FeatureThumb2",
232 def IsMClass : Predicate<"Subtarget->isMClass()">,
233 AssemblerPredicate<"FeatureMClass", "armv7m">;
234 def IsARClass : Predicate<"!Subtarget->isMClass()">,
235 AssemblerPredicate<"!FeatureMClass",
237 def IsARM : Predicate<"!Subtarget->isThumb()">,
238 AssemblerPredicate<"!ModeThumb", "arm-mode">;
239 def IsIOS : Predicate<"Subtarget->isTargetIOS()">;
240 def IsNotIOS : Predicate<"!Subtarget->isTargetIOS()">;
241 def IsNaCl : Predicate<"Subtarget->isTargetNaCl()">;
243 // FIXME: Eventually this will be just "hasV6T2Ops".
244 def UseMovt : Predicate<"Subtarget->useMovt()">;
245 def DontUseMovt : Predicate<"!Subtarget->useMovt()">;
246 def UseFPVMLx : Predicate<"Subtarget->useFPVMLx()">;
247 def UseMulOps : Predicate<"Subtarget->useMulOps()">;
249 // Prefer fused MAC for fp mul + add over fp VMLA / VMLS if they are available.
250 // But only select them if more precision in FP computation is allowed.
251 // Do not use them for Darwin platforms.
252 def UseFusedMAC : Predicate<"(TM.Options.AllowFPOpFusion =="
253 " FPOpFusion::Fast) && "
254 "!Subtarget->isTargetDarwin()">;
255 def DontUseFusedMAC : Predicate<"!Subtarget->hasVFP4() || "
256 "Subtarget->isTargetDarwin()">;
258 // VGETLNi32 is microcoded on Swift - prefer VMOV.
259 def HasFastVGETLNi32 : Predicate<"!Subtarget->isSwift()">;
260 def HasSlowVGETLNi32 : Predicate<"Subtarget->isSwift()">;
262 // VDUP.32 is microcoded on Swift - prefer VMOV.
263 def HasFastVDUP32 : Predicate<"!Subtarget->isSwift()">;
264 def HasSlowVDUP32 : Predicate<"Subtarget->isSwift()">;
266 // Cortex-A9 prefers VMOVSR to VMOVDRR even when using NEON for scalar FP, as
267 // this allows more effective execution domain optimization. See
268 // setExecutionDomain().
269 def UseVMOVSR : Predicate<"Subtarget->isCortexA9() || !Subtarget->useNEONForSinglePrecisionFP()">;
270 def DontUseVMOVSR : Predicate<"!Subtarget->isCortexA9() && Subtarget->useNEONForSinglePrecisionFP()">;
272 def IsLE : Predicate<"TLI.isLittleEndian()">;
273 def IsBE : Predicate<"TLI.isBigEndian()">;
275 //===----------------------------------------------------------------------===//
276 // ARM Flag Definitions.
278 class RegConstraint<string C> {
279 string Constraints = C;
282 //===----------------------------------------------------------------------===//
283 // ARM specific transformation functions and pattern fragments.
286 // imm_neg_XFORM - Return the negation of an i32 immediate value.
287 def imm_neg_XFORM : SDNodeXForm<imm, [{
288 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), MVT::i32);
291 // imm_not_XFORM - Return the complement of a i32 immediate value.
292 def imm_not_XFORM : SDNodeXForm<imm, [{
293 return CurDAG->getTargetConstant(~(int)N->getZExtValue(), MVT::i32);
296 /// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
297 def imm16_31 : ImmLeaf<i32, [{
298 return (int32_t)Imm >= 16 && (int32_t)Imm < 32;
301 def so_imm_neg_asmoperand : AsmOperandClass { let Name = "ARMSOImmNeg"; }
302 def so_imm_neg : Operand<i32>, PatLeaf<(imm), [{
303 unsigned Value = -(unsigned)N->getZExtValue();
304 return Value && ARM_AM::getSOImmVal(Value) != -1;
306 let ParserMatchClass = so_imm_neg_asmoperand;
309 // Note: this pattern doesn't require an encoder method and such, as it's
310 // only used on aliases (Pat<> and InstAlias<>). The actual encoding
311 // is handled by the destination instructions, which use so_imm.
312 def so_imm_not_asmoperand : AsmOperandClass { let Name = "ARMSOImmNot"; }
313 def so_imm_not : Operand<i32>, PatLeaf<(imm), [{
314 return ARM_AM::getSOImmVal(~(uint32_t)N->getZExtValue()) != -1;
316 let ParserMatchClass = so_imm_not_asmoperand;
319 // sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
320 def sext_16_node : PatLeaf<(i32 GPR:$a), [{
321 return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17;
324 /// Split a 32-bit immediate into two 16 bit parts.
325 def hi16 : SDNodeXForm<imm, [{
326 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, MVT::i32);
329 def lo16AllZero : PatLeaf<(i32 imm), [{
330 // Returns true if all low 16-bits are 0.
331 return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
334 class BinOpWithFlagFrag<dag res> :
335 PatFrag<(ops node:$LHS, node:$RHS, node:$FLAG), res>;
336 class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
337 class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
339 // An 'and' node with a single use.
340 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
341 return N->hasOneUse();
344 // An 'xor' node with a single use.
345 def xor_su : PatFrag<(ops node:$lhs, node:$rhs), (xor node:$lhs, node:$rhs), [{
346 return N->hasOneUse();
349 // An 'fmul' node with a single use.
350 def fmul_su : PatFrag<(ops node:$lhs, node:$rhs), (fmul node:$lhs, node:$rhs),[{
351 return N->hasOneUse();
354 // An 'fadd' node which checks for single non-hazardous use.
355 def fadd_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fadd node:$lhs, node:$rhs),[{
356 return hasNoVMLxHazardUse(N);
359 // An 'fsub' node which checks for single non-hazardous use.
360 def fsub_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fsub node:$lhs, node:$rhs),[{
361 return hasNoVMLxHazardUse(N);
364 //===----------------------------------------------------------------------===//
365 // Operand Definitions.
368 // Immediate operands with a shared generic asm render method.
369 class ImmAsmOperand : AsmOperandClass { let RenderMethod = "addImmOperands"; }
372 // FIXME: rename brtarget to t2_brtarget
373 def brtarget : Operand<OtherVT> {
374 let EncoderMethod = "getBranchTargetOpValue";
375 let OperandType = "OPERAND_PCREL";
376 let DecoderMethod = "DecodeT2BROperand";
379 // FIXME: get rid of this one?
380 def uncondbrtarget : Operand<OtherVT> {
381 let EncoderMethod = "getUnconditionalBranchTargetOpValue";
382 let OperandType = "OPERAND_PCREL";
385 // Branch target for ARM. Handles conditional/unconditional
386 def br_target : Operand<OtherVT> {
387 let EncoderMethod = "getARMBranchTargetOpValue";
388 let OperandType = "OPERAND_PCREL";
392 // FIXME: rename bltarget to t2_bl_target?
393 def bltarget : Operand<i32> {
394 // Encoded the same as branch targets.
395 let EncoderMethod = "getBranchTargetOpValue";
396 let OperandType = "OPERAND_PCREL";
399 // Call target for ARM. Handles conditional/unconditional
400 // FIXME: rename bl_target to t2_bltarget?
401 def bl_target : Operand<i32> {
402 let EncoderMethod = "getARMBLTargetOpValue";
403 let OperandType = "OPERAND_PCREL";
406 def blx_target : Operand<i32> {
407 let EncoderMethod = "getARMBLXTargetOpValue";
408 let OperandType = "OPERAND_PCREL";
411 // A list of registers separated by comma. Used by load/store multiple.
412 def RegListAsmOperand : AsmOperandClass { let Name = "RegList"; }
413 def reglist : Operand<i32> {
414 let EncoderMethod = "getRegisterListOpValue";
415 let ParserMatchClass = RegListAsmOperand;
416 let PrintMethod = "printRegisterList";
417 let DecoderMethod = "DecodeRegListOperand";
420 def GPRPairOp : RegisterOperand<GPRPair, "printGPRPairOperand">;
422 def DPRRegListAsmOperand : AsmOperandClass { let Name = "DPRRegList"; }
423 def dpr_reglist : Operand<i32> {
424 let EncoderMethod = "getRegisterListOpValue";
425 let ParserMatchClass = DPRRegListAsmOperand;
426 let PrintMethod = "printRegisterList";
427 let DecoderMethod = "DecodeDPRRegListOperand";
430 def SPRRegListAsmOperand : AsmOperandClass { let Name = "SPRRegList"; }
431 def spr_reglist : Operand<i32> {
432 let EncoderMethod = "getRegisterListOpValue";
433 let ParserMatchClass = SPRRegListAsmOperand;
434 let PrintMethod = "printRegisterList";
435 let DecoderMethod = "DecodeSPRRegListOperand";
438 // An operand for the CONSTPOOL_ENTRY pseudo-instruction.
439 def cpinst_operand : Operand<i32> {
440 let PrintMethod = "printCPInstOperand";
444 def pclabel : Operand<i32> {
445 let PrintMethod = "printPCLabel";
448 // ADR instruction labels.
449 def AdrLabelAsmOperand : AsmOperandClass { let Name = "AdrLabel"; }
450 def adrlabel : Operand<i32> {
451 let EncoderMethod = "getAdrLabelOpValue";
452 let ParserMatchClass = AdrLabelAsmOperand;
453 let PrintMethod = "printAdrLabelOperand";
456 def neon_vcvt_imm32 : Operand<i32> {
457 let EncoderMethod = "getNEONVcvtImm32OpValue";
458 let DecoderMethod = "DecodeVCVTImmOperand";
461 // rot_imm: An integer that encodes a rotate amount. Must be 8, 16, or 24.
462 def rot_imm_XFORM: SDNodeXForm<imm, [{
463 switch (N->getZExtValue()){
465 case 0: return CurDAG->getTargetConstant(0, MVT::i32);
466 case 8: return CurDAG->getTargetConstant(1, MVT::i32);
467 case 16: return CurDAG->getTargetConstant(2, MVT::i32);
468 case 24: return CurDAG->getTargetConstant(3, MVT::i32);
471 def RotImmAsmOperand : AsmOperandClass {
473 let ParserMethod = "parseRotImm";
475 def rot_imm : Operand<i32>, PatLeaf<(i32 imm), [{
476 int32_t v = N->getZExtValue();
477 return v == 8 || v == 16 || v == 24; }],
479 let PrintMethod = "printRotImmOperand";
480 let ParserMatchClass = RotImmAsmOperand;
483 // shift_imm: An integer that encodes a shift amount and the type of shift
484 // (asr or lsl). The 6-bit immediate encodes as:
487 // {4-0} imm5 shift amount.
488 // asr #32 encoded as imm5 == 0.
489 def ShifterImmAsmOperand : AsmOperandClass {
490 let Name = "ShifterImm";
491 let ParserMethod = "parseShifterImm";
493 def shift_imm : Operand<i32> {
494 let PrintMethod = "printShiftImmOperand";
495 let ParserMatchClass = ShifterImmAsmOperand;
498 // shifter_operand operands: so_reg_reg, so_reg_imm, and so_imm.
499 def ShiftedRegAsmOperand : AsmOperandClass { let Name = "RegShiftedReg"; }
500 def so_reg_reg : Operand<i32>, // reg reg imm
501 ComplexPattern<i32, 3, "SelectRegShifterOperand",
502 [shl, srl, sra, rotr]> {
503 let EncoderMethod = "getSORegRegOpValue";
504 let PrintMethod = "printSORegRegOperand";
505 let DecoderMethod = "DecodeSORegRegOperand";
506 let ParserMatchClass = ShiftedRegAsmOperand;
507 let MIOperandInfo = (ops GPRnopc, GPRnopc, i32imm);
510 def ShiftedImmAsmOperand : AsmOperandClass { let Name = "RegShiftedImm"; }
511 def so_reg_imm : Operand<i32>, // reg imm
512 ComplexPattern<i32, 2, "SelectImmShifterOperand",
513 [shl, srl, sra, rotr]> {
514 let EncoderMethod = "getSORegImmOpValue";
515 let PrintMethod = "printSORegImmOperand";
516 let DecoderMethod = "DecodeSORegImmOperand";
517 let ParserMatchClass = ShiftedImmAsmOperand;
518 let MIOperandInfo = (ops GPR, i32imm);
521 // FIXME: Does this need to be distinct from so_reg?
522 def shift_so_reg_reg : Operand<i32>, // reg reg imm
523 ComplexPattern<i32, 3, "SelectShiftRegShifterOperand",
524 [shl,srl,sra,rotr]> {
525 let EncoderMethod = "getSORegRegOpValue";
526 let PrintMethod = "printSORegRegOperand";
527 let DecoderMethod = "DecodeSORegRegOperand";
528 let ParserMatchClass = ShiftedRegAsmOperand;
529 let MIOperandInfo = (ops GPR, GPR, i32imm);
532 // FIXME: Does this need to be distinct from so_reg?
533 def shift_so_reg_imm : Operand<i32>, // reg reg imm
534 ComplexPattern<i32, 2, "SelectShiftImmShifterOperand",
535 [shl,srl,sra,rotr]> {
536 let EncoderMethod = "getSORegImmOpValue";
537 let PrintMethod = "printSORegImmOperand";
538 let DecoderMethod = "DecodeSORegImmOperand";
539 let ParserMatchClass = ShiftedImmAsmOperand;
540 let MIOperandInfo = (ops GPR, i32imm);
544 // so_imm - Match a 32-bit shifter_operand immediate operand, which is an
545 // 8-bit immediate rotated by an arbitrary number of bits.
546 def SOImmAsmOperand: ImmAsmOperand { let Name = "ARMSOImm"; }
547 def so_imm : Operand<i32>, ImmLeaf<i32, [{
548 return ARM_AM::getSOImmVal(Imm) != -1;
550 let EncoderMethod = "getSOImmOpValue";
551 let ParserMatchClass = SOImmAsmOperand;
552 let DecoderMethod = "DecodeSOImmOperand";
555 // Break so_imm's up into two pieces. This handles immediates with up to 16
556 // bits set in them. This uses so_imm2part to match and so_imm2part_[12] to
557 // get the first/second pieces.
558 def so_imm2part : PatLeaf<(imm), [{
559 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
562 /// arm_i32imm - True for +V6T2, or true only if so_imm2part is true.
564 def arm_i32imm : PatLeaf<(imm), [{
565 if (Subtarget->hasV6T2Ops())
567 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
570 /// imm0_1 predicate - Immediate in the range [0,1].
571 def Imm0_1AsmOperand: ImmAsmOperand { let Name = "Imm0_1"; }
572 def imm0_1 : Operand<i32> { let ParserMatchClass = Imm0_1AsmOperand; }
574 /// imm0_3 predicate - Immediate in the range [0,3].
575 def Imm0_3AsmOperand: ImmAsmOperand { let Name = "Imm0_3"; }
576 def imm0_3 : Operand<i32> { let ParserMatchClass = Imm0_3AsmOperand; }
578 /// imm0_7 predicate - Immediate in the range [0,7].
579 def Imm0_7AsmOperand: ImmAsmOperand { let Name = "Imm0_7"; }
580 def imm0_7 : Operand<i32>, ImmLeaf<i32, [{
581 return Imm >= 0 && Imm < 8;
583 let ParserMatchClass = Imm0_7AsmOperand;
586 /// imm8 predicate - Immediate is exactly 8.
587 def Imm8AsmOperand: ImmAsmOperand { let Name = "Imm8"; }
588 def imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 8; }]> {
589 let ParserMatchClass = Imm8AsmOperand;
592 /// imm16 predicate - Immediate is exactly 16.
593 def Imm16AsmOperand: ImmAsmOperand { let Name = "Imm16"; }
594 def imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 16; }]> {
595 let ParserMatchClass = Imm16AsmOperand;
598 /// imm32 predicate - Immediate is exactly 32.
599 def Imm32AsmOperand: ImmAsmOperand { let Name = "Imm32"; }
600 def imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 32; }]> {
601 let ParserMatchClass = Imm32AsmOperand;
604 /// imm1_7 predicate - Immediate in the range [1,7].
605 def Imm1_7AsmOperand: ImmAsmOperand { let Name = "Imm1_7"; }
606 def imm1_7 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 8; }]> {
607 let ParserMatchClass = Imm1_7AsmOperand;
610 /// imm1_15 predicate - Immediate in the range [1,15].
611 def Imm1_15AsmOperand: ImmAsmOperand { let Name = "Imm1_15"; }
612 def imm1_15 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 16; }]> {
613 let ParserMatchClass = Imm1_15AsmOperand;
616 /// imm1_31 predicate - Immediate in the range [1,31].
617 def Imm1_31AsmOperand: ImmAsmOperand { let Name = "Imm1_31"; }
618 def imm1_31 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 32; }]> {
619 let ParserMatchClass = Imm1_31AsmOperand;
622 /// imm0_15 predicate - Immediate in the range [0,15].
623 def Imm0_15AsmOperand: ImmAsmOperand {
624 let Name = "Imm0_15";
625 let DiagnosticType = "ImmRange0_15";
627 def imm0_15 : Operand<i32>, ImmLeaf<i32, [{
628 return Imm >= 0 && Imm < 16;
630 let ParserMatchClass = Imm0_15AsmOperand;
633 /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
634 def Imm0_31AsmOperand: ImmAsmOperand { let Name = "Imm0_31"; }
635 def imm0_31 : Operand<i32>, ImmLeaf<i32, [{
636 return Imm >= 0 && Imm < 32;
638 let ParserMatchClass = Imm0_31AsmOperand;
641 /// imm0_32 predicate - True if the 32-bit immediate is in the range [0,32].
642 def Imm0_32AsmOperand: ImmAsmOperand { let Name = "Imm0_32"; }
643 def imm0_32 : Operand<i32>, ImmLeaf<i32, [{
644 return Imm >= 0 && Imm < 32;
646 let ParserMatchClass = Imm0_32AsmOperand;
649 /// imm0_63 predicate - True if the 32-bit immediate is in the range [0,63].
650 def Imm0_63AsmOperand: ImmAsmOperand { let Name = "Imm0_63"; }
651 def imm0_63 : Operand<i32>, ImmLeaf<i32, [{
652 return Imm >= 0 && Imm < 64;
654 let ParserMatchClass = Imm0_63AsmOperand;
657 /// imm0_255 predicate - Immediate in the range [0,255].
658 def Imm0_255AsmOperand : ImmAsmOperand { let Name = "Imm0_255"; }
659 def imm0_255 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 256; }]> {
660 let ParserMatchClass = Imm0_255AsmOperand;
663 /// imm0_65535 - An immediate is in the range [0.65535].
664 def Imm0_65535AsmOperand: ImmAsmOperand { let Name = "Imm0_65535"; }
665 def imm0_65535 : Operand<i32>, ImmLeaf<i32, [{
666 return Imm >= 0 && Imm < 65536;
668 let ParserMatchClass = Imm0_65535AsmOperand;
671 // imm0_65535_neg - An immediate whose negative value is in the range [0.65535].
672 def imm0_65535_neg : Operand<i32>, ImmLeaf<i32, [{
673 return -Imm >= 0 && -Imm < 65536;
676 // imm0_65535_expr - For movt/movw - 16-bit immediate that can also reference
677 // a relocatable expression.
679 // FIXME: This really needs a Thumb version separate from the ARM version.
680 // While the range is the same, and can thus use the same match class,
681 // the encoding is different so it should have a different encoder method.
682 def Imm0_65535ExprAsmOperand: ImmAsmOperand { let Name = "Imm0_65535Expr"; }
683 def imm0_65535_expr : Operand<i32> {
684 let EncoderMethod = "getHiLo16ImmOpValue";
685 let ParserMatchClass = Imm0_65535ExprAsmOperand;
688 /// imm24b - True if the 32-bit immediate is encodable in 24 bits.
689 def Imm24bitAsmOperand: ImmAsmOperand { let Name = "Imm24bit"; }
690 def imm24b : Operand<i32>, ImmLeaf<i32, [{
691 return Imm >= 0 && Imm <= 0xffffff;
693 let ParserMatchClass = Imm24bitAsmOperand;
697 /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
699 def BitfieldAsmOperand : AsmOperandClass {
700 let Name = "Bitfield";
701 let ParserMethod = "parseBitfield";
704 def bf_inv_mask_imm : Operand<i32>,
706 return ARM::isBitFieldInvertedMask(N->getZExtValue());
708 let EncoderMethod = "getBitfieldInvertedMaskOpValue";
709 let PrintMethod = "printBitfieldInvMaskImmOperand";
710 let DecoderMethod = "DecodeBitfieldMaskOperand";
711 let ParserMatchClass = BitfieldAsmOperand;
714 def imm1_32_XFORM: SDNodeXForm<imm, [{
715 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, MVT::i32);
717 def Imm1_32AsmOperand: AsmOperandClass { let Name = "Imm1_32"; }
718 def imm1_32 : Operand<i32>, PatLeaf<(imm), [{
719 uint64_t Imm = N->getZExtValue();
720 return Imm > 0 && Imm <= 32;
723 let PrintMethod = "printImmPlusOneOperand";
724 let ParserMatchClass = Imm1_32AsmOperand;
727 def imm1_16_XFORM: SDNodeXForm<imm, [{
728 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, MVT::i32);
730 def Imm1_16AsmOperand: AsmOperandClass { let Name = "Imm1_16"; }
731 def imm1_16 : Operand<i32>, PatLeaf<(imm), [{ return Imm > 0 && Imm <= 16; }],
733 let PrintMethod = "printImmPlusOneOperand";
734 let ParserMatchClass = Imm1_16AsmOperand;
737 // Define ARM specific addressing modes.
738 // addrmode_imm12 := reg +/- imm12
740 def MemImm12OffsetAsmOperand : AsmOperandClass { let Name = "MemImm12Offset"; }
741 def addrmode_imm12 : Operand<i32>,
742 ComplexPattern<i32, 2, "SelectAddrModeImm12", []> {
743 // 12-bit immediate operand. Note that instructions using this encode
744 // #0 and #-0 differently. We flag #-0 as the magic value INT32_MIN. All other
745 // immediate values are as normal.
747 let EncoderMethod = "getAddrModeImm12OpValue";
748 let PrintMethod = "printAddrModeImm12Operand";
749 let DecoderMethod = "DecodeAddrModeImm12Operand";
750 let ParserMatchClass = MemImm12OffsetAsmOperand;
751 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
753 // ldst_so_reg := reg +/- reg shop imm
755 def MemRegOffsetAsmOperand : AsmOperandClass { let Name = "MemRegOffset"; }
756 def ldst_so_reg : Operand<i32>,
757 ComplexPattern<i32, 3, "SelectLdStSOReg", []> {
758 let EncoderMethod = "getLdStSORegOpValue";
759 // FIXME: Simplify the printer
760 let PrintMethod = "printAddrMode2Operand";
761 let DecoderMethod = "DecodeSORegMemOperand";
762 let ParserMatchClass = MemRegOffsetAsmOperand;
763 let MIOperandInfo = (ops GPR:$base, GPRnopc:$offsreg, i32imm:$shift);
766 // postidx_imm8 := +/- [0,255]
769 // {8} 1 is imm8 is non-negative. 0 otherwise.
770 // {7-0} [0,255] imm8 value.
771 def PostIdxImm8AsmOperand : AsmOperandClass { let Name = "PostIdxImm8"; }
772 def postidx_imm8 : Operand<i32> {
773 let PrintMethod = "printPostIdxImm8Operand";
774 let ParserMatchClass = PostIdxImm8AsmOperand;
775 let MIOperandInfo = (ops i32imm);
778 // postidx_imm8s4 := +/- [0,1020]
781 // {8} 1 is imm8 is non-negative. 0 otherwise.
782 // {7-0} [0,255] imm8 value, scaled by 4.
783 def PostIdxImm8s4AsmOperand : AsmOperandClass { let Name = "PostIdxImm8s4"; }
784 def postidx_imm8s4 : Operand<i32> {
785 let PrintMethod = "printPostIdxImm8s4Operand";
786 let ParserMatchClass = PostIdxImm8s4AsmOperand;
787 let MIOperandInfo = (ops i32imm);
791 // postidx_reg := +/- reg
793 def PostIdxRegAsmOperand : AsmOperandClass {
794 let Name = "PostIdxReg";
795 let ParserMethod = "parsePostIdxReg";
797 def postidx_reg : Operand<i32> {
798 let EncoderMethod = "getPostIdxRegOpValue";
799 let DecoderMethod = "DecodePostIdxReg";
800 let PrintMethod = "printPostIdxRegOperand";
801 let ParserMatchClass = PostIdxRegAsmOperand;
802 let MIOperandInfo = (ops GPRnopc, i32imm);
806 // addrmode2 := reg +/- imm12
807 // := reg +/- reg shop imm
809 // FIXME: addrmode2 should be refactored the rest of the way to always
810 // use explicit imm vs. reg versions above (addrmode_imm12 and ldst_so_reg).
811 def AddrMode2AsmOperand : AsmOperandClass { let Name = "AddrMode2"; }
812 def addrmode2 : Operand<i32>,
813 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
814 let EncoderMethod = "getAddrMode2OpValue";
815 let PrintMethod = "printAddrMode2Operand";
816 let ParserMatchClass = AddrMode2AsmOperand;
817 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
820 def PostIdxRegShiftedAsmOperand : AsmOperandClass {
821 let Name = "PostIdxRegShifted";
822 let ParserMethod = "parsePostIdxReg";
824 def am2offset_reg : Operand<i32>,
825 ComplexPattern<i32, 2, "SelectAddrMode2OffsetReg",
826 [], [SDNPWantRoot]> {
827 let EncoderMethod = "getAddrMode2OffsetOpValue";
828 let PrintMethod = "printAddrMode2OffsetOperand";
829 // When using this for assembly, it's always as a post-index offset.
830 let ParserMatchClass = PostIdxRegShiftedAsmOperand;
831 let MIOperandInfo = (ops GPRnopc, i32imm);
834 // FIXME: am2offset_imm should only need the immediate, not the GPR. Having
835 // the GPR is purely vestigal at this point.
836 def AM2OffsetImmAsmOperand : AsmOperandClass { let Name = "AM2OffsetImm"; }
837 def am2offset_imm : Operand<i32>,
838 ComplexPattern<i32, 2, "SelectAddrMode2OffsetImm",
839 [], [SDNPWantRoot]> {
840 let EncoderMethod = "getAddrMode2OffsetOpValue";
841 let PrintMethod = "printAddrMode2OffsetOperand";
842 let ParserMatchClass = AM2OffsetImmAsmOperand;
843 let MIOperandInfo = (ops GPRnopc, i32imm);
847 // addrmode3 := reg +/- reg
848 // addrmode3 := reg +/- imm8
850 // FIXME: split into imm vs. reg versions.
851 def AddrMode3AsmOperand : AsmOperandClass { let Name = "AddrMode3"; }
852 def addrmode3 : Operand<i32>,
853 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
854 let EncoderMethod = "getAddrMode3OpValue";
855 let PrintMethod = "printAddrMode3Operand";
856 let ParserMatchClass = AddrMode3AsmOperand;
857 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
860 // FIXME: split into imm vs. reg versions.
861 // FIXME: parser method to handle +/- register.
862 def AM3OffsetAsmOperand : AsmOperandClass {
863 let Name = "AM3Offset";
864 let ParserMethod = "parseAM3Offset";
866 def am3offset : Operand<i32>,
867 ComplexPattern<i32, 2, "SelectAddrMode3Offset",
868 [], [SDNPWantRoot]> {
869 let EncoderMethod = "getAddrMode3OffsetOpValue";
870 let PrintMethod = "printAddrMode3OffsetOperand";
871 let ParserMatchClass = AM3OffsetAsmOperand;
872 let MIOperandInfo = (ops GPR, i32imm);
875 // ldstm_mode := {ia, ib, da, db}
877 def ldstm_mode : OptionalDefOperand<OtherVT, (ops i32), (ops (i32 1))> {
878 let EncoderMethod = "getLdStmModeOpValue";
879 let PrintMethod = "printLdStmModeOperand";
882 // addrmode5 := reg +/- imm8*4
884 def AddrMode5AsmOperand : AsmOperandClass { let Name = "AddrMode5"; }
885 def addrmode5 : Operand<i32>,
886 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
887 let PrintMethod = "printAddrMode5Operand";
888 let EncoderMethod = "getAddrMode5OpValue";
889 let DecoderMethod = "DecodeAddrMode5Operand";
890 let ParserMatchClass = AddrMode5AsmOperand;
891 let MIOperandInfo = (ops GPR:$base, i32imm);
894 // addrmode6 := reg with optional alignment
896 def AddrMode6AsmOperand : AsmOperandClass { let Name = "AlignedMemory"; }
897 def addrmode6 : Operand<i32>,
898 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
899 let PrintMethod = "printAddrMode6Operand";
900 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
901 let EncoderMethod = "getAddrMode6AddressOpValue";
902 let DecoderMethod = "DecodeAddrMode6Operand";
903 let ParserMatchClass = AddrMode6AsmOperand;
906 def am6offset : Operand<i32>,
907 ComplexPattern<i32, 1, "SelectAddrMode6Offset",
908 [], [SDNPWantRoot]> {
909 let PrintMethod = "printAddrMode6OffsetOperand";
910 let MIOperandInfo = (ops GPR);
911 let EncoderMethod = "getAddrMode6OffsetOpValue";
912 let DecoderMethod = "DecodeGPRRegisterClass";
915 // Special version of addrmode6 to handle alignment encoding for VST1/VLD1
916 // (single element from one lane) for size 32.
917 def addrmode6oneL32 : Operand<i32>,
918 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
919 let PrintMethod = "printAddrMode6Operand";
920 let MIOperandInfo = (ops GPR:$addr, i32imm);
921 let EncoderMethod = "getAddrMode6OneLane32AddressOpValue";
924 // Special version of addrmode6 to handle alignment encoding for VLD-dup
925 // instructions, specifically VLD4-dup.
926 def addrmode6dup : Operand<i32>,
927 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
928 let PrintMethod = "printAddrMode6Operand";
929 let MIOperandInfo = (ops GPR:$addr, i32imm);
930 let EncoderMethod = "getAddrMode6DupAddressOpValue";
931 // FIXME: This is close, but not quite right. The alignment specifier is
933 let ParserMatchClass = AddrMode6AsmOperand;
936 // addrmodepc := pc + reg
938 def addrmodepc : Operand<i32>,
939 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
940 let PrintMethod = "printAddrModePCOperand";
941 let MIOperandInfo = (ops GPR, i32imm);
944 // addr_offset_none := reg
946 def MemNoOffsetAsmOperand : AsmOperandClass { let Name = "MemNoOffset"; }
947 def addr_offset_none : Operand<i32>,
948 ComplexPattern<i32, 1, "SelectAddrOffsetNone", []> {
949 let PrintMethod = "printAddrMode7Operand";
950 let DecoderMethod = "DecodeAddrMode7Operand";
951 let ParserMatchClass = MemNoOffsetAsmOperand;
952 let MIOperandInfo = (ops GPR:$base);
955 def nohash_imm : Operand<i32> {
956 let PrintMethod = "printNoHashImmediate";
959 def CoprocNumAsmOperand : AsmOperandClass {
960 let Name = "CoprocNum";
961 let ParserMethod = "parseCoprocNumOperand";
963 def p_imm : Operand<i32> {
964 let PrintMethod = "printPImmediate";
965 let ParserMatchClass = CoprocNumAsmOperand;
966 let DecoderMethod = "DecodeCoprocessor";
969 def pf_imm : Operand<i32> {
970 let PrintMethod = "printPImmediate";
971 let ParserMatchClass = CoprocNumAsmOperand;
974 def CoprocRegAsmOperand : AsmOperandClass {
975 let Name = "CoprocReg";
976 let ParserMethod = "parseCoprocRegOperand";
978 def c_imm : Operand<i32> {
979 let PrintMethod = "printCImmediate";
980 let ParserMatchClass = CoprocRegAsmOperand;
982 def CoprocOptionAsmOperand : AsmOperandClass {
983 let Name = "CoprocOption";
984 let ParserMethod = "parseCoprocOptionOperand";
986 def coproc_option_imm : Operand<i32> {
987 let PrintMethod = "printCoprocOptionImm";
988 let ParserMatchClass = CoprocOptionAsmOperand;
991 //===----------------------------------------------------------------------===//
993 include "ARMInstrFormats.td"
995 //===----------------------------------------------------------------------===//
996 // Multiclass helpers...
999 /// AsI1_bin_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns for a
1000 /// binop that produces a value.
1001 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1002 multiclass AsI1_bin_irs<bits<4> opcod, string opc,
1003 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1004 PatFrag opnode, bit Commutable = 0> {
1005 // The register-immediate version is re-materializable. This is useful
1006 // in particular for taking the address of a local.
1007 let isReMaterializable = 1 in {
1008 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
1009 iii, opc, "\t$Rd, $Rn, $imm",
1010 [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]> {
1015 let Inst{19-16} = Rn;
1016 let Inst{15-12} = Rd;
1017 let Inst{11-0} = imm;
1020 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1021 iir, opc, "\t$Rd, $Rn, $Rm",
1022 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]> {
1027 let isCommutable = Commutable;
1028 let Inst{19-16} = Rn;
1029 let Inst{15-12} = Rd;
1030 let Inst{11-4} = 0b00000000;
1034 def rsi : AsI1<opcod, (outs GPR:$Rd),
1035 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1036 iis, opc, "\t$Rd, $Rn, $shift",
1037 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_imm:$shift))]> {
1042 let Inst{19-16} = Rn;
1043 let Inst{15-12} = Rd;
1044 let Inst{11-5} = shift{11-5};
1046 let Inst{3-0} = shift{3-0};
1049 def rsr : AsI1<opcod, (outs GPR:$Rd),
1050 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1051 iis, opc, "\t$Rd, $Rn, $shift",
1052 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_reg:$shift))]> {
1057 let Inst{19-16} = Rn;
1058 let Inst{15-12} = Rd;
1059 let Inst{11-8} = shift{11-8};
1061 let Inst{6-5} = shift{6-5};
1063 let Inst{3-0} = shift{3-0};
1067 /// AsI1_rbin_irs - Same as AsI1_bin_irs except the order of operands are
1068 /// reversed. The 'rr' form is only defined for the disassembler; for codegen
1069 /// it is equivalent to the AsI1_bin_irs counterpart.
1070 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1071 multiclass AsI1_rbin_irs<bits<4> opcod, string opc,
1072 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1073 PatFrag opnode, bit Commutable = 0> {
1074 // The register-immediate version is re-materializable. This is useful
1075 // in particular for taking the address of a local.
1076 let isReMaterializable = 1 in {
1077 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
1078 iii, opc, "\t$Rd, $Rn, $imm",
1079 [(set GPR:$Rd, (opnode so_imm:$imm, GPR:$Rn))]> {
1084 let Inst{19-16} = Rn;
1085 let Inst{15-12} = Rd;
1086 let Inst{11-0} = imm;
1089 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1090 iir, opc, "\t$Rd, $Rn, $Rm",
1091 [/* pattern left blank */]> {
1095 let Inst{11-4} = 0b00000000;
1098 let Inst{15-12} = Rd;
1099 let Inst{19-16} = Rn;
1102 def rsi : AsI1<opcod, (outs GPR:$Rd),
1103 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1104 iis, opc, "\t$Rd, $Rn, $shift",
1105 [(set GPR:$Rd, (opnode so_reg_imm:$shift, GPR:$Rn))]> {
1110 let Inst{19-16} = Rn;
1111 let Inst{15-12} = Rd;
1112 let Inst{11-5} = shift{11-5};
1114 let Inst{3-0} = shift{3-0};
1117 def rsr : AsI1<opcod, (outs GPR:$Rd),
1118 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1119 iis, opc, "\t$Rd, $Rn, $shift",
1120 [(set GPR:$Rd, (opnode so_reg_reg:$shift, GPR:$Rn))]> {
1125 let Inst{19-16} = Rn;
1126 let Inst{15-12} = Rd;
1127 let Inst{11-8} = shift{11-8};
1129 let Inst{6-5} = shift{6-5};
1131 let Inst{3-0} = shift{3-0};
1135 /// AsI1_bin_s_irs - Same as AsI1_bin_irs except it sets the 's' bit by default.
1137 /// These opcodes will be converted to the real non-S opcodes by
1138 /// AdjustInstrPostInstrSelection after giving them an optional CPSR operand.
1139 let hasPostISelHook = 1, Defs = [CPSR] in {
1140 multiclass AsI1_bin_s_irs<InstrItinClass iii, InstrItinClass iir,
1141 InstrItinClass iis, PatFrag opnode,
1142 bit Commutable = 0> {
1143 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm, pred:$p),
1145 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_imm:$imm))]>;
1147 def rr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, pred:$p),
1149 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm))]> {
1150 let isCommutable = Commutable;
1152 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1153 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1155 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1156 so_reg_imm:$shift))]>;
1158 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1159 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1161 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1162 so_reg_reg:$shift))]>;
1166 /// AsI1_rbin_s_is - Same as AsI1_bin_s_irs, except selection DAG
1167 /// operands are reversed.
1168 let hasPostISelHook = 1, Defs = [CPSR] in {
1169 multiclass AsI1_rbin_s_is<InstrItinClass iii, InstrItinClass iir,
1170 InstrItinClass iis, PatFrag opnode,
1171 bit Commutable = 0> {
1172 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm, pred:$p),
1174 [(set GPR:$Rd, CPSR, (opnode so_imm:$imm, GPR:$Rn))]>;
1176 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1177 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1179 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift,
1182 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1183 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1185 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift,
1190 /// AI1_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
1191 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
1192 /// a explicit result, only implicitly set CPSR.
1193 let isCompare = 1, Defs = [CPSR] in {
1194 multiclass AI1_cmp_irs<bits<4> opcod, string opc,
1195 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1196 PatFrag opnode, bit Commutable = 0> {
1197 def ri : AI1<opcod, (outs), (ins GPR:$Rn, so_imm:$imm), DPFrm, iii,
1199 [(opnode GPR:$Rn, so_imm:$imm)]> {
1204 let Inst{19-16} = Rn;
1205 let Inst{15-12} = 0b0000;
1206 let Inst{11-0} = imm;
1208 let Unpredictable{15-12} = 0b1111;
1210 def rr : AI1<opcod, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, iir,
1212 [(opnode GPR:$Rn, GPR:$Rm)]> {
1215 let isCommutable = Commutable;
1218 let Inst{19-16} = Rn;
1219 let Inst{15-12} = 0b0000;
1220 let Inst{11-4} = 0b00000000;
1223 let Unpredictable{15-12} = 0b1111;
1225 def rsi : AI1<opcod, (outs),
1226 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, iis,
1227 opc, "\t$Rn, $shift",
1228 [(opnode GPR:$Rn, so_reg_imm:$shift)]> {
1233 let Inst{19-16} = Rn;
1234 let Inst{15-12} = 0b0000;
1235 let Inst{11-5} = shift{11-5};
1237 let Inst{3-0} = shift{3-0};
1239 let Unpredictable{15-12} = 0b1111;
1241 def rsr : AI1<opcod, (outs),
1242 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, iis,
1243 opc, "\t$Rn, $shift",
1244 [(opnode GPRnopc:$Rn, so_reg_reg:$shift)]> {
1249 let Inst{19-16} = Rn;
1250 let Inst{15-12} = 0b0000;
1251 let Inst{11-8} = shift{11-8};
1253 let Inst{6-5} = shift{6-5};
1255 let Inst{3-0} = shift{3-0};
1257 let Unpredictable{15-12} = 0b1111;
1263 /// AI_ext_rrot - A unary operation with two forms: one whose operand is a
1264 /// register and one whose operand is a register rotated by 8/16/24.
1265 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
1266 class AI_ext_rrot<bits<8> opcod, string opc, PatFrag opnode>
1267 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1268 IIC_iEXTr, opc, "\t$Rd, $Rm$rot",
1269 [(set GPRnopc:$Rd, (opnode (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1270 Requires<[IsARM, HasV6]> {
1274 let Inst{19-16} = 0b1111;
1275 let Inst{15-12} = Rd;
1276 let Inst{11-10} = rot;
1280 class AI_ext_rrot_np<bits<8> opcod, string opc>
1281 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1282 IIC_iEXTr, opc, "\t$Rd, $Rm$rot", []>,
1283 Requires<[IsARM, HasV6]> {
1285 let Inst{19-16} = 0b1111;
1286 let Inst{11-10} = rot;
1289 /// AI_exta_rrot - A binary operation with two forms: one whose operand is a
1290 /// register and one whose operand is a register rotated by 8/16/24.
1291 class AI_exta_rrot<bits<8> opcod, string opc, PatFrag opnode>
1292 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1293 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot",
1294 [(set GPRnopc:$Rd, (opnode GPR:$Rn,
1295 (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1296 Requires<[IsARM, HasV6]> {
1301 let Inst{19-16} = Rn;
1302 let Inst{15-12} = Rd;
1303 let Inst{11-10} = rot;
1304 let Inst{9-4} = 0b000111;
1308 class AI_exta_rrot_np<bits<8> opcod, string opc>
1309 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1310 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot", []>,
1311 Requires<[IsARM, HasV6]> {
1314 let Inst{19-16} = Rn;
1315 let Inst{11-10} = rot;
1318 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
1319 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1320 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
1321 bit Commutable = 0> {
1322 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1323 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
1324 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1325 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_imm:$imm, CPSR))]>,
1331 let Inst{15-12} = Rd;
1332 let Inst{19-16} = Rn;
1333 let Inst{11-0} = imm;
1335 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1336 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1337 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm, CPSR))]>,
1342 let Inst{11-4} = 0b00000000;
1344 let isCommutable = Commutable;
1346 let Inst{15-12} = Rd;
1347 let Inst{19-16} = Rn;
1349 def rsi : AsI1<opcod, (outs GPR:$Rd),
1350 (ins GPR:$Rn, so_reg_imm:$shift),
1351 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1352 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_imm:$shift, CPSR))]>,
1358 let Inst{19-16} = Rn;
1359 let Inst{15-12} = Rd;
1360 let Inst{11-5} = shift{11-5};
1362 let Inst{3-0} = shift{3-0};
1364 def rsr : AsI1<opcod, (outs GPRnopc:$Rd),
1365 (ins GPRnopc:$Rn, so_reg_reg:$shift),
1366 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1367 [(set GPRnopc:$Rd, CPSR,
1368 (opnode GPRnopc:$Rn, so_reg_reg:$shift, CPSR))]>,
1374 let Inst{19-16} = Rn;
1375 let Inst{15-12} = Rd;
1376 let Inst{11-8} = shift{11-8};
1378 let Inst{6-5} = shift{6-5};
1380 let Inst{3-0} = shift{3-0};
1385 /// AI1_rsc_irs - Define instructions and patterns for rsc
1386 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1387 multiclass AI1_rsc_irs<bits<4> opcod, string opc, PatFrag opnode> {
1388 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1389 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
1390 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1391 [(set GPR:$Rd, CPSR, (opnode so_imm:$imm, GPR:$Rn, CPSR))]>,
1397 let Inst{15-12} = Rd;
1398 let Inst{19-16} = Rn;
1399 let Inst{11-0} = imm;
1401 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1402 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1403 [/* pattern left blank */]> {
1407 let Inst{11-4} = 0b00000000;
1410 let Inst{15-12} = Rd;
1411 let Inst{19-16} = Rn;
1413 def rsi : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_imm:$shift),
1414 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1415 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift, GPR:$Rn, CPSR))]>,
1421 let Inst{19-16} = Rn;
1422 let Inst{15-12} = Rd;
1423 let Inst{11-5} = shift{11-5};
1425 let Inst{3-0} = shift{3-0};
1427 def rsr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_reg:$shift),
1428 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1429 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift, GPR:$Rn, CPSR))]>,
1435 let Inst{19-16} = Rn;
1436 let Inst{15-12} = Rd;
1437 let Inst{11-8} = shift{11-8};
1439 let Inst{6-5} = shift{6-5};
1441 let Inst{3-0} = shift{3-0};
1446 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1447 multiclass AI_ldr1<bit isByte, string opc, InstrItinClass iii,
1448 InstrItinClass iir, PatFrag opnode> {
1449 // Note: We use the complex addrmode_imm12 rather than just an input
1450 // GPR and a constrained immediate so that we can use this to match
1451 // frame index references and avoid matching constant pool references.
1452 def i12: AI2ldst<0b010, 1, isByte, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
1453 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1454 [(set GPR:$Rt, (opnode addrmode_imm12:$addr))]> {
1457 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1458 let Inst{19-16} = addr{16-13}; // Rn
1459 let Inst{15-12} = Rt;
1460 let Inst{11-0} = addr{11-0}; // imm12
1462 def rs : AI2ldst<0b011, 1, isByte, (outs GPR:$Rt), (ins ldst_so_reg:$shift),
1463 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1464 [(set GPR:$Rt, (opnode ldst_so_reg:$shift))]> {
1467 let shift{4} = 0; // Inst{4} = 0
1468 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1469 let Inst{19-16} = shift{16-13}; // Rn
1470 let Inst{15-12} = Rt;
1471 let Inst{11-0} = shift{11-0};
1476 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1477 multiclass AI_ldr1nopc<bit isByte, string opc, InstrItinClass iii,
1478 InstrItinClass iir, PatFrag opnode> {
1479 // Note: We use the complex addrmode_imm12 rather than just an input
1480 // GPR and a constrained immediate so that we can use this to match
1481 // frame index references and avoid matching constant pool references.
1482 def i12: AI2ldst<0b010, 1, isByte, (outs GPRnopc:$Rt),
1483 (ins addrmode_imm12:$addr),
1484 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1485 [(set GPRnopc:$Rt, (opnode addrmode_imm12:$addr))]> {
1488 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1489 let Inst{19-16} = addr{16-13}; // Rn
1490 let Inst{15-12} = Rt;
1491 let Inst{11-0} = addr{11-0}; // imm12
1493 def rs : AI2ldst<0b011, 1, isByte, (outs GPRnopc:$Rt),
1494 (ins ldst_so_reg:$shift),
1495 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1496 [(set GPRnopc:$Rt, (opnode ldst_so_reg:$shift))]> {
1499 let shift{4} = 0; // Inst{4} = 0
1500 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1501 let Inst{19-16} = shift{16-13}; // Rn
1502 let Inst{15-12} = Rt;
1503 let Inst{11-0} = shift{11-0};
1509 multiclass AI_str1<bit isByte, string opc, InstrItinClass iii,
1510 InstrItinClass iir, PatFrag opnode> {
1511 // Note: We use the complex addrmode_imm12 rather than just an input
1512 // GPR and a constrained immediate so that we can use this to match
1513 // frame index references and avoid matching constant pool references.
1514 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1515 (ins GPR:$Rt, addrmode_imm12:$addr),
1516 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1517 [(opnode GPR:$Rt, addrmode_imm12:$addr)]> {
1520 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1521 let Inst{19-16} = addr{16-13}; // Rn
1522 let Inst{15-12} = Rt;
1523 let Inst{11-0} = addr{11-0}; // imm12
1525 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPR:$Rt, ldst_so_reg:$shift),
1526 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1527 [(opnode GPR:$Rt, ldst_so_reg:$shift)]> {
1530 let shift{4} = 0; // Inst{4} = 0
1531 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1532 let Inst{19-16} = shift{16-13}; // Rn
1533 let Inst{15-12} = Rt;
1534 let Inst{11-0} = shift{11-0};
1538 multiclass AI_str1nopc<bit isByte, string opc, InstrItinClass iii,
1539 InstrItinClass iir, PatFrag opnode> {
1540 // Note: We use the complex addrmode_imm12 rather than just an input
1541 // GPR and a constrained immediate so that we can use this to match
1542 // frame index references and avoid matching constant pool references.
1543 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1544 (ins GPRnopc:$Rt, addrmode_imm12:$addr),
1545 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1546 [(opnode GPRnopc:$Rt, addrmode_imm12:$addr)]> {
1549 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1550 let Inst{19-16} = addr{16-13}; // Rn
1551 let Inst{15-12} = Rt;
1552 let Inst{11-0} = addr{11-0}; // imm12
1554 def rs : AI2ldst<0b011, 0, isByte, (outs),
1555 (ins GPRnopc:$Rt, ldst_so_reg:$shift),
1556 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1557 [(opnode GPRnopc:$Rt, ldst_so_reg:$shift)]> {
1560 let shift{4} = 0; // Inst{4} = 0
1561 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1562 let Inst{19-16} = shift{16-13}; // Rn
1563 let Inst{15-12} = Rt;
1564 let Inst{11-0} = shift{11-0};
1569 //===----------------------------------------------------------------------===//
1571 //===----------------------------------------------------------------------===//
1573 //===----------------------------------------------------------------------===//
1574 // Miscellaneous Instructions.
1577 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
1578 /// the function. The first operand is the ID# for this instruction, the second
1579 /// is the index into the MachineConstantPool that this is, the third is the
1580 /// size in bytes of this constant pool entry.
1581 let neverHasSideEffects = 1, isNotDuplicable = 1 in
1582 def CONSTPOOL_ENTRY :
1583 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1584 i32imm:$size), NoItinerary, []>;
1586 // FIXME: Marking these as hasSideEffects is necessary to prevent machine DCE
1587 // from removing one half of the matched pairs. That breaks PEI, which assumes
1588 // these will always be in pairs, and asserts if it finds otherwise. Better way?
1589 let Defs = [SP], Uses = [SP], hasSideEffects = 1 in {
1590 def ADJCALLSTACKUP :
1591 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary,
1592 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
1594 def ADJCALLSTACKDOWN :
1595 PseudoInst<(outs), (ins i32imm:$amt, pred:$p), NoItinerary,
1596 [(ARMcallseq_start timm:$amt)]>;
1599 // Atomic pseudo-insts which will be lowered to ldrexd/strexd loops.
1600 // (These pseudos use a hand-written selection code).
1601 let usesCustomInserter = 1, Defs = [CPSR], mayLoad = 1, mayStore = 1 in {
1602 def ATOMOR6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1603 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1605 def ATOMXOR6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1606 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1608 def ATOMADD6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1609 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1611 def ATOMSUB6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1612 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1614 def ATOMNAND6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1615 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1617 def ATOMAND6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1618 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1620 def ATOMSWAP6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1621 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1623 def ATOMCMPXCHG6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1624 (ins GPR:$addr, GPR:$cmp1, GPR:$cmp2,
1625 GPR:$set1, GPR:$set2),
1627 def ATOMMIN6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1628 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1630 def ATOMUMIN6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1631 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1633 def ATOMMAX6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1634 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1636 def ATOMUMAX6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1637 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1641 def HINT : AI<(outs), (ins imm0_255:$imm), MiscFrm, NoItinerary,
1642 "hint", "\t$imm", []>, Requires<[IsARM, HasV6]> {
1644 let Inst{27-8} = 0b00110010000011110000;
1645 let Inst{7-0} = imm;
1648 def : InstAlias<"nop$p", (HINT 0, pred:$p)>, Requires<[IsARM, HasV6T2]>;
1649 def : InstAlias<"yield$p", (HINT 1, pred:$p)>, Requires<[IsARM, HasV6T2]>;
1650 def : InstAlias<"wfe$p", (HINT 2, pred:$p)>, Requires<[IsARM, HasV6T2]>;
1651 def : InstAlias<"wfi$p", (HINT 3, pred:$p)>, Requires<[IsARM, HasV6T2]>;
1652 def : InstAlias<"sev$p", (HINT 4, pred:$p)>, Requires<[IsARM, HasV6T2]>;
1654 def SEL : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, NoItinerary, "sel",
1655 "\t$Rd, $Rn, $Rm", []>, Requires<[IsARM, HasV6]> {
1660 let Inst{15-12} = Rd;
1661 let Inst{19-16} = Rn;
1662 let Inst{27-20} = 0b01101000;
1663 let Inst{7-4} = 0b1011;
1664 let Inst{11-8} = 0b1111;
1665 let Unpredictable{11-8} = 0b1111;
1668 // The 16-bit operand $val can be used by a debugger to store more information
1669 // about the breakpoint.
1670 def BKPT : AI<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
1671 "bkpt", "\t$val", []>, Requires<[IsARM]> {
1673 let Inst{3-0} = val{3-0};
1674 let Inst{19-8} = val{15-4};
1675 let Inst{27-20} = 0b00010010;
1676 let Inst{7-4} = 0b0111;
1679 // Change Processor State
1680 // FIXME: We should use InstAlias to handle the optional operands.
1681 class CPS<dag iops, string asm_ops>
1682 : AXI<(outs), iops, MiscFrm, NoItinerary, !strconcat("cps", asm_ops),
1683 []>, Requires<[IsARM]> {
1689 let Inst{31-28} = 0b1111;
1690 let Inst{27-20} = 0b00010000;
1691 let Inst{19-18} = imod;
1692 let Inst{17} = M; // Enabled if mode is set;
1693 let Inst{16-9} = 0b00000000;
1694 let Inst{8-6} = iflags;
1696 let Inst{4-0} = mode;
1699 let DecoderMethod = "DecodeCPSInstruction" in {
1701 def CPS3p : CPS<(ins imod_op:$imod, iflags_op:$iflags, imm0_31:$mode),
1702 "$imod\t$iflags, $mode">;
1703 let mode = 0, M = 0 in
1704 def CPS2p : CPS<(ins imod_op:$imod, iflags_op:$iflags), "$imod\t$iflags">;
1706 let imod = 0, iflags = 0, M = 1 in
1707 def CPS1p : CPS<(ins imm0_31:$mode), "\t$mode">;
1710 // Preload signals the memory system of possible future data/instruction access.
1711 multiclass APreLoad<bits<1> read, bits<1> data, string opc> {
1713 def i12 : AXI<(outs), (ins addrmode_imm12:$addr), MiscFrm, IIC_Preload,
1714 !strconcat(opc, "\t$addr"),
1715 [(ARMPreload addrmode_imm12:$addr, (i32 read), (i32 data))]> {
1718 let Inst{31-26} = 0b111101;
1719 let Inst{25} = 0; // 0 for immediate form
1720 let Inst{24} = data;
1721 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1722 let Inst{22} = read;
1723 let Inst{21-20} = 0b01;
1724 let Inst{19-16} = addr{16-13}; // Rn
1725 let Inst{15-12} = 0b1111;
1726 let Inst{11-0} = addr{11-0}; // imm12
1729 def rs : AXI<(outs), (ins ldst_so_reg:$shift), MiscFrm, IIC_Preload,
1730 !strconcat(opc, "\t$shift"),
1731 [(ARMPreload ldst_so_reg:$shift, (i32 read), (i32 data))]> {
1733 let Inst{31-26} = 0b111101;
1734 let Inst{25} = 1; // 1 for register form
1735 let Inst{24} = data;
1736 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1737 let Inst{22} = read;
1738 let Inst{21-20} = 0b01;
1739 let Inst{19-16} = shift{16-13}; // Rn
1740 let Inst{15-12} = 0b1111;
1741 let Inst{11-0} = shift{11-0};
1746 defm PLD : APreLoad<1, 1, "pld">, Requires<[IsARM]>;
1747 defm PLDW : APreLoad<0, 1, "pldw">, Requires<[IsARM,HasV7,HasMP]>;
1748 defm PLI : APreLoad<1, 0, "pli">, Requires<[IsARM,HasV7]>;
1750 def SETEND : AXI<(outs), (ins setend_op:$end), MiscFrm, NoItinerary,
1751 "setend\t$end", []>, Requires<[IsARM]> {
1753 let Inst{31-10} = 0b1111000100000001000000;
1758 def DBG : AI<(outs), (ins imm0_15:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt",
1759 []>, Requires<[IsARM, HasV7]> {
1761 let Inst{27-4} = 0b001100100000111100001111;
1762 let Inst{3-0} = opt;
1765 // A5.4 Permanently UNDEFINED instructions.
1766 let isBarrier = 1, isTerminator = 1 in
1767 def TRAP : AXI<(outs), (ins), MiscFrm, NoItinerary,
1770 let Inst = 0xe7ffdefe;
1773 // Address computation and loads and stores in PIC mode.
1774 let isNotDuplicable = 1 in {
1775 def PICADD : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
1777 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>;
1779 let AddedComplexity = 10 in {
1780 def PICLDR : ARMPseudoInst<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
1782 [(set GPR:$dst, (load addrmodepc:$addr))]>;
1784 def PICLDRH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1786 [(set GPR:$Rt, (zextloadi16 addrmodepc:$addr))]>;
1788 def PICLDRB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1790 [(set GPR:$Rt, (zextloadi8 addrmodepc:$addr))]>;
1792 def PICLDRSH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1794 [(set GPR:$Rt, (sextloadi16 addrmodepc:$addr))]>;
1796 def PICLDRSB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1798 [(set GPR:$Rt, (sextloadi8 addrmodepc:$addr))]>;
1800 let AddedComplexity = 10 in {
1801 def PICSTR : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1802 4, IIC_iStore_r, [(store GPR:$src, addrmodepc:$addr)]>;
1804 def PICSTRH : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1805 4, IIC_iStore_bh_r, [(truncstorei16 GPR:$src,
1806 addrmodepc:$addr)]>;
1808 def PICSTRB : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1809 4, IIC_iStore_bh_r, [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
1811 } // isNotDuplicable = 1
1814 // LEApcrel - Load a pc-relative address into a register without offending the
1816 let neverHasSideEffects = 1, isReMaterializable = 1 in
1817 // The 'adr' mnemonic encodes differently if the label is before or after
1818 // the instruction. The {24-21} opcode bits are set by the fixup, as we don't
1819 // know until then which form of the instruction will be used.
1820 def ADR : AI1<{0,?,?,0}, (outs GPR:$Rd), (ins adrlabel:$label),
1821 MiscFrm, IIC_iALUi, "adr", "\t$Rd, $label", []> {
1824 let Inst{27-25} = 0b001;
1826 let Inst{23-22} = label{13-12};
1829 let Inst{19-16} = 0b1111;
1830 let Inst{15-12} = Rd;
1831 let Inst{11-0} = label{11-0};
1834 let hasSideEffects = 1 in {
1835 def LEApcrel : ARMPseudoInst<(outs GPR:$Rd), (ins i32imm:$label, pred:$p),
1838 def LEApcrelJT : ARMPseudoInst<(outs GPR:$Rd),
1839 (ins i32imm:$label, nohash_imm:$id, pred:$p),
1843 //===----------------------------------------------------------------------===//
1844 // Control Flow Instructions.
1847 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
1849 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
1850 "bx", "\tlr", [(ARMretflag)]>,
1851 Requires<[IsARM, HasV4T]> {
1852 let Inst{27-0} = 0b0001001011111111111100011110;
1856 def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br,
1857 "mov", "\tpc, lr", [(ARMretflag)]>,
1858 Requires<[IsARM, NoV4T]> {
1859 let Inst{27-0} = 0b0001101000001111000000001110;
1863 // Indirect branches
1864 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
1866 def BX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
1867 [(brind GPR:$dst)]>,
1868 Requires<[IsARM, HasV4T]> {
1870 let Inst{31-4} = 0b1110000100101111111111110001;
1871 let Inst{3-0} = dst;
1874 def BX_pred : AI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br,
1875 "bx", "\t$dst", [/* pattern left blank */]>,
1876 Requires<[IsARM, HasV4T]> {
1878 let Inst{27-4} = 0b000100101111111111110001;
1879 let Inst{3-0} = dst;
1883 // SP is marked as a use to prevent stack-pointer assignments that appear
1884 // immediately before calls from potentially appearing dead.
1886 // FIXME: Do we really need a non-predicated version? If so, it should
1887 // at least be a pseudo instruction expanding to the predicated version
1888 // at MC lowering time.
1889 Defs = [LR], Uses = [SP] in {
1890 def BL : ABXI<0b1011, (outs), (ins bl_target:$func),
1891 IIC_Br, "bl\t$func",
1892 [(ARMcall tglobaladdr:$func)]>,
1894 let Inst{31-28} = 0b1110;
1896 let Inst{23-0} = func;
1897 let DecoderMethod = "DecodeBranchImmInstruction";
1900 def BL_pred : ABI<0b1011, (outs), (ins bl_target:$func),
1901 IIC_Br, "bl", "\t$func",
1902 [(ARMcall_pred tglobaladdr:$func)]>,
1905 let Inst{23-0} = func;
1906 let DecoderMethod = "DecodeBranchImmInstruction";
1910 def BLX : AXI<(outs), (ins GPR:$func), BrMiscFrm,
1911 IIC_Br, "blx\t$func",
1912 [(ARMcall GPR:$func)]>,
1913 Requires<[IsARM, HasV5T]> {
1915 let Inst{31-4} = 0b1110000100101111111111110011;
1916 let Inst{3-0} = func;
1919 def BLX_pred : AI<(outs), (ins GPR:$func), BrMiscFrm,
1920 IIC_Br, "blx", "\t$func",
1921 [(ARMcall_pred GPR:$func)]>,
1922 Requires<[IsARM, HasV5T]> {
1924 let Inst{27-4} = 0b000100101111111111110011;
1925 let Inst{3-0} = func;
1929 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
1930 def BX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
1931 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
1932 Requires<[IsARM, HasV4T]>;
1935 def BMOVPCRX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
1936 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
1937 Requires<[IsARM, NoV4T]>;
1939 // mov lr, pc; b if callee is marked noreturn to avoid confusing the
1940 // return stack predictor.
1941 def BMOVPCB_CALL : ARMPseudoInst<(outs), (ins bl_target:$func),
1942 8, IIC_Br, [(ARMcall_nolink tglobaladdr:$func)]>,
1946 let isBranch = 1, isTerminator = 1 in {
1947 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
1948 // a two-value operand where a dag node expects two operands. :(
1949 def Bcc : ABI<0b1010, (outs), (ins br_target:$target),
1950 IIC_Br, "b", "\t$target",
1951 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]> {
1953 let Inst{23-0} = target;
1954 let DecoderMethod = "DecodeBranchImmInstruction";
1957 let isBarrier = 1 in {
1958 // B is "predicable" since it's just a Bcc with an 'always' condition.
1959 let isPredicable = 1 in
1960 // FIXME: We shouldn't need this pseudo at all. Just using Bcc directly
1961 // should be sufficient.
1962 // FIXME: Is B really a Barrier? That doesn't seem right.
1963 def B : ARMPseudoExpand<(outs), (ins br_target:$target), 4, IIC_Br,
1964 [(br bb:$target)], (Bcc br_target:$target, (ops 14, zero_reg))>;
1966 let isNotDuplicable = 1, isIndirectBranch = 1 in {
1967 def BR_JTr : ARMPseudoInst<(outs),
1968 (ins GPR:$target, i32imm:$jt, i32imm:$id),
1970 [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]>;
1971 // FIXME: This shouldn't use the generic "addrmode2," but rather be split
1972 // into i12 and rs suffixed versions.
1973 def BR_JTm : ARMPseudoInst<(outs),
1974 (ins addrmode2:$target, i32imm:$jt, i32imm:$id),
1976 [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
1978 def BR_JTadd : ARMPseudoInst<(outs),
1979 (ins GPR:$target, GPR:$idx, i32imm:$jt, i32imm:$id),
1981 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
1983 } // isNotDuplicable = 1, isIndirectBranch = 1
1989 def BLXi : AXI<(outs), (ins blx_target:$target), BrMiscFrm, NoItinerary,
1990 "blx\t$target", []>,
1991 Requires<[IsARM, HasV5T]> {
1992 let Inst{31-25} = 0b1111101;
1994 let Inst{23-0} = target{24-1};
1995 let Inst{24} = target{0};
1998 // Branch and Exchange Jazelle
1999 def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func",
2000 [/* pattern left blank */]> {
2002 let Inst{23-20} = 0b0010;
2003 let Inst{19-8} = 0xfff;
2004 let Inst{7-4} = 0b0010;
2005 let Inst{3-0} = func;
2010 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in {
2011 def TCRETURNdi : PseudoInst<(outs), (ins i32imm:$dst), IIC_Br, []>;
2013 def TCRETURNri : PseudoInst<(outs), (ins tcGPR:$dst), IIC_Br, []>;
2015 def TAILJMPd : ARMPseudoExpand<(outs), (ins br_target:$dst),
2017 (Bcc br_target:$dst, (ops 14, zero_reg))>,
2020 def TAILJMPr : ARMPseudoExpand<(outs), (ins tcGPR:$dst),
2026 // Secure Monitor Call is a system instruction.
2027 def SMC : ABI<0b0001, (outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt",
2030 let Inst{23-4} = 0b01100000000000000111;
2031 let Inst{3-0} = opt;
2034 // Supervisor Call (Software Interrupt)
2035 let isCall = 1, Uses = [SP] in {
2036 def SVC : ABI<0b1111, (outs), (ins imm24b:$svc), IIC_Br, "svc", "\t$svc", []> {
2038 let Inst{23-0} = svc;
2042 // Store Return State
2043 class SRSI<bit wb, string asm>
2044 : XI<(outs), (ins imm0_31:$mode), AddrModeNone, 4, IndexModeNone, BrFrm,
2045 NoItinerary, asm, "", []> {
2047 let Inst{31-28} = 0b1111;
2048 let Inst{27-25} = 0b100;
2052 let Inst{19-16} = 0b1101; // SP
2053 let Inst{15-5} = 0b00000101000;
2054 let Inst{4-0} = mode;
2057 def SRSDA : SRSI<0, "srsda\tsp, $mode"> {
2058 let Inst{24-23} = 0;
2060 def SRSDA_UPD : SRSI<1, "srsda\tsp!, $mode"> {
2061 let Inst{24-23} = 0;
2063 def SRSDB : SRSI<0, "srsdb\tsp, $mode"> {
2064 let Inst{24-23} = 0b10;
2066 def SRSDB_UPD : SRSI<1, "srsdb\tsp!, $mode"> {
2067 let Inst{24-23} = 0b10;
2069 def SRSIA : SRSI<0, "srsia\tsp, $mode"> {
2070 let Inst{24-23} = 0b01;
2072 def SRSIA_UPD : SRSI<1, "srsia\tsp!, $mode"> {
2073 let Inst{24-23} = 0b01;
2075 def SRSIB : SRSI<0, "srsib\tsp, $mode"> {
2076 let Inst{24-23} = 0b11;
2078 def SRSIB_UPD : SRSI<1, "srsib\tsp!, $mode"> {
2079 let Inst{24-23} = 0b11;
2082 // Return From Exception
2083 class RFEI<bit wb, string asm>
2084 : XI<(outs), (ins GPR:$Rn), AddrModeNone, 4, IndexModeNone, BrFrm,
2085 NoItinerary, asm, "", []> {
2087 let Inst{31-28} = 0b1111;
2088 let Inst{27-25} = 0b100;
2092 let Inst{19-16} = Rn;
2093 let Inst{15-0} = 0xa00;
2096 def RFEDA : RFEI<0, "rfeda\t$Rn"> {
2097 let Inst{24-23} = 0;
2099 def RFEDA_UPD : RFEI<1, "rfeda\t$Rn!"> {
2100 let Inst{24-23} = 0;
2102 def RFEDB : RFEI<0, "rfedb\t$Rn"> {
2103 let Inst{24-23} = 0b10;
2105 def RFEDB_UPD : RFEI<1, "rfedb\t$Rn!"> {
2106 let Inst{24-23} = 0b10;
2108 def RFEIA : RFEI<0, "rfeia\t$Rn"> {
2109 let Inst{24-23} = 0b01;
2111 def RFEIA_UPD : RFEI<1, "rfeia\t$Rn!"> {
2112 let Inst{24-23} = 0b01;
2114 def RFEIB : RFEI<0, "rfeib\t$Rn"> {
2115 let Inst{24-23} = 0b11;
2117 def RFEIB_UPD : RFEI<1, "rfeib\t$Rn!"> {
2118 let Inst{24-23} = 0b11;
2121 //===----------------------------------------------------------------------===//
2122 // Load / Store Instructions.
2128 defm LDR : AI_ldr1<0, "ldr", IIC_iLoad_r, IIC_iLoad_si,
2129 UnOpFrag<(load node:$Src)>>;
2130 defm LDRB : AI_ldr1nopc<1, "ldrb", IIC_iLoad_bh_r, IIC_iLoad_bh_si,
2131 UnOpFrag<(zextloadi8 node:$Src)>>;
2132 defm STR : AI_str1<0, "str", IIC_iStore_r, IIC_iStore_si,
2133 BinOpFrag<(store node:$LHS, node:$RHS)>>;
2134 defm STRB : AI_str1nopc<1, "strb", IIC_iStore_bh_r, IIC_iStore_bh_si,
2135 BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
2137 // Special LDR for loads from non-pc-relative constpools.
2138 let canFoldAsLoad = 1, mayLoad = 1, neverHasSideEffects = 1,
2139 isReMaterializable = 1, isCodeGenOnly = 1 in
2140 def LDRcp : AI2ldst<0b010, 1, 0, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
2141 AddrMode_i12, LdFrm, IIC_iLoad_r, "ldr", "\t$Rt, $addr",
2145 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2146 let Inst{19-16} = 0b1111;
2147 let Inst{15-12} = Rt;
2148 let Inst{11-0} = addr{11-0}; // imm12
2151 // Loads with zero extension
2152 def LDRH : AI3ld<0b1011, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2153 IIC_iLoad_bh_r, "ldrh", "\t$Rt, $addr",
2154 [(set GPR:$Rt, (zextloadi16 addrmode3:$addr))]>;
2156 // Loads with sign extension
2157 def LDRSH : AI3ld<0b1111, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2158 IIC_iLoad_bh_r, "ldrsh", "\t$Rt, $addr",
2159 [(set GPR:$Rt, (sextloadi16 addrmode3:$addr))]>;
2161 def LDRSB : AI3ld<0b1101, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2162 IIC_iLoad_bh_r, "ldrsb", "\t$Rt, $addr",
2163 [(set GPR:$Rt, (sextloadi8 addrmode3:$addr))]>;
2165 let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1 in {
2167 def LDRD : AI3ld<0b1101, 0, (outs GPR:$Rd, GPR:$dst2),
2168 (ins addrmode3:$addr), LdMiscFrm,
2169 IIC_iLoad_d_r, "ldrd", "\t$Rd, $dst2, $addr",
2170 []>, Requires<[IsARM, HasV5TE]>;
2174 multiclass AI2_ldridx<bit isByte, string opc,
2175 InstrItinClass iii, InstrItinClass iir> {
2176 def _PRE_IMM : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2177 (ins addrmode_imm12:$addr), IndexModePre, LdFrm, iii,
2178 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2181 let Inst{23} = addr{12};
2182 let Inst{19-16} = addr{16-13};
2183 let Inst{11-0} = addr{11-0};
2184 let DecoderMethod = "DecodeLDRPreImm";
2185 let AsmMatchConverter = "cvtLdWriteBackRegAddrModeImm12";
2188 def _PRE_REG : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2189 (ins ldst_so_reg:$addr), IndexModePre, LdFrm, iir,
2190 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2193 let Inst{23} = addr{12};
2194 let Inst{19-16} = addr{16-13};
2195 let Inst{11-0} = addr{11-0};
2197 let DecoderMethod = "DecodeLDRPreReg";
2198 let AsmMatchConverter = "cvtLdWriteBackRegAddrMode2";
2201 def _POST_REG : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2202 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2203 IndexModePost, LdFrm, iir,
2204 opc, "\t$Rt, $addr, $offset",
2205 "$addr.base = $Rn_wb", []> {
2211 let Inst{23} = offset{12};
2212 let Inst{19-16} = addr;
2213 let Inst{11-0} = offset{11-0};
2215 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2218 def _POST_IMM : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2219 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2220 IndexModePost, LdFrm, iii,
2221 opc, "\t$Rt, $addr, $offset",
2222 "$addr.base = $Rn_wb", []> {
2228 let Inst{23} = offset{12};
2229 let Inst{19-16} = addr;
2230 let Inst{11-0} = offset{11-0};
2232 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2237 let mayLoad = 1, neverHasSideEffects = 1 in {
2238 // FIXME: for LDR_PRE_REG etc. the itineray should be either IIC_iLoad_ru or
2239 // IIC_iLoad_siu depending on whether it the offset register is shifted.
2240 defm LDR : AI2_ldridx<0, "ldr", IIC_iLoad_iu, IIC_iLoad_ru>;
2241 defm LDRB : AI2_ldridx<1, "ldrb", IIC_iLoad_bh_iu, IIC_iLoad_bh_ru>;
2244 multiclass AI3_ldridx<bits<4> op, string opc, InstrItinClass itin> {
2245 def _PRE : AI3ldstidx<op, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2246 (ins addrmode3:$addr), IndexModePre,
2248 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2250 let Inst{23} = addr{8}; // U bit
2251 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2252 let Inst{19-16} = addr{12-9}; // Rn
2253 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2254 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2255 let AsmMatchConverter = "cvtLdWriteBackRegAddrMode3";
2256 let DecoderMethod = "DecodeAddrMode3Instruction";
2258 def _POST : AI3ldstidx<op, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2259 (ins addr_offset_none:$addr, am3offset:$offset),
2260 IndexModePost, LdMiscFrm, itin,
2261 opc, "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2265 let Inst{23} = offset{8}; // U bit
2266 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2267 let Inst{19-16} = addr;
2268 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2269 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2270 let DecoderMethod = "DecodeAddrMode3Instruction";
2274 let mayLoad = 1, neverHasSideEffects = 1 in {
2275 defm LDRH : AI3_ldridx<0b1011, "ldrh", IIC_iLoad_bh_ru>;
2276 defm LDRSH : AI3_ldridx<0b1111, "ldrsh", IIC_iLoad_bh_ru>;
2277 defm LDRSB : AI3_ldridx<0b1101, "ldrsb", IIC_iLoad_bh_ru>;
2278 let hasExtraDefRegAllocReq = 1 in {
2279 def LDRD_PRE : AI3ldstidx<0b1101, 0, 1, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2280 (ins addrmode3:$addr), IndexModePre,
2281 LdMiscFrm, IIC_iLoad_d_ru,
2282 "ldrd", "\t$Rt, $Rt2, $addr!",
2283 "$addr.base = $Rn_wb", []> {
2285 let Inst{23} = addr{8}; // U bit
2286 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2287 let Inst{19-16} = addr{12-9}; // Rn
2288 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2289 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2290 let DecoderMethod = "DecodeAddrMode3Instruction";
2291 let AsmMatchConverter = "cvtLdrdPre";
2293 def LDRD_POST: AI3ldstidx<0b1101, 0, 0, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2294 (ins addr_offset_none:$addr, am3offset:$offset),
2295 IndexModePost, LdMiscFrm, IIC_iLoad_d_ru,
2296 "ldrd", "\t$Rt, $Rt2, $addr, $offset",
2297 "$addr.base = $Rn_wb", []> {
2300 let Inst{23} = offset{8}; // U bit
2301 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2302 let Inst{19-16} = addr;
2303 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2304 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2305 let DecoderMethod = "DecodeAddrMode3Instruction";
2307 } // hasExtraDefRegAllocReq = 1
2308 } // mayLoad = 1, neverHasSideEffects = 1
2310 // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT.
2311 let mayLoad = 1, neverHasSideEffects = 1 in {
2312 def LDRT_POST_REG : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2313 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2314 IndexModePost, LdFrm, IIC_iLoad_ru,
2315 "ldrt", "\t$Rt, $addr, $offset",
2316 "$addr.base = $Rn_wb", []> {
2322 let Inst{23} = offset{12};
2323 let Inst{21} = 1; // overwrite
2324 let Inst{19-16} = addr;
2325 let Inst{11-5} = offset{11-5};
2327 let Inst{3-0} = offset{3-0};
2328 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2331 def LDRT_POST_IMM : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2332 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2333 IndexModePost, LdFrm, IIC_iLoad_ru,
2334 "ldrt", "\t$Rt, $addr, $offset",
2335 "$addr.base = $Rn_wb", []> {
2341 let Inst{23} = offset{12};
2342 let Inst{21} = 1; // overwrite
2343 let Inst{19-16} = addr;
2344 let Inst{11-0} = offset{11-0};
2345 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2348 def LDRBT_POST_REG : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2349 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2350 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2351 "ldrbt", "\t$Rt, $addr, $offset",
2352 "$addr.base = $Rn_wb", []> {
2358 let Inst{23} = offset{12};
2359 let Inst{21} = 1; // overwrite
2360 let Inst{19-16} = addr;
2361 let Inst{11-5} = offset{11-5};
2363 let Inst{3-0} = offset{3-0};
2364 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2367 def LDRBT_POST_IMM : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2368 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2369 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2370 "ldrbt", "\t$Rt, $addr, $offset",
2371 "$addr.base = $Rn_wb", []> {
2377 let Inst{23} = offset{12};
2378 let Inst{21} = 1; // overwrite
2379 let Inst{19-16} = addr;
2380 let Inst{11-0} = offset{11-0};
2381 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2384 multiclass AI3ldrT<bits<4> op, string opc> {
2385 def i : AI3ldstidxT<op, 1, (outs GPR:$Rt, GPR:$base_wb),
2386 (ins addr_offset_none:$addr, postidx_imm8:$offset),
2387 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2388 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2390 let Inst{23} = offset{8};
2392 let Inst{11-8} = offset{7-4};
2393 let Inst{3-0} = offset{3-0};
2394 let AsmMatchConverter = "cvtLdExtTWriteBackImm";
2396 def r : AI3ldstidxT<op, 1, (outs GPRnopc:$Rt, GPRnopc:$base_wb),
2397 (ins addr_offset_none:$addr, postidx_reg:$Rm),
2398 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2399 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2401 let Inst{23} = Rm{4};
2404 let Unpredictable{11-8} = 0b1111;
2405 let Inst{3-0} = Rm{3-0};
2406 let AsmMatchConverter = "cvtLdExtTWriteBackReg";
2407 let DecoderMethod = "DecodeLDR";
2411 defm LDRSBT : AI3ldrT<0b1101, "ldrsbt">;
2412 defm LDRHT : AI3ldrT<0b1011, "ldrht">;
2413 defm LDRSHT : AI3ldrT<0b1111, "ldrsht">;
2418 // Stores with truncate
2419 def STRH : AI3str<0b1011, (outs), (ins GPR:$Rt, addrmode3:$addr), StMiscFrm,
2420 IIC_iStore_bh_r, "strh", "\t$Rt, $addr",
2421 [(truncstorei16 GPR:$Rt, addrmode3:$addr)]>;
2424 let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in
2425 def STRD : AI3str<0b1111, (outs), (ins GPR:$Rt, GPR:$src2, addrmode3:$addr),
2426 StMiscFrm, IIC_iStore_d_r,
2427 "strd", "\t$Rt, $src2, $addr", []>,
2428 Requires<[IsARM, HasV5TE]> {
2433 multiclass AI2_stridx<bit isByte, string opc,
2434 InstrItinClass iii, InstrItinClass iir> {
2435 def _PRE_IMM : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2436 (ins GPR:$Rt, addrmode_imm12:$addr), IndexModePre,
2438 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2441 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2442 let Inst{19-16} = addr{16-13}; // Rn
2443 let Inst{11-0} = addr{11-0}; // imm12
2444 let AsmMatchConverter = "cvtStWriteBackRegAddrModeImm12";
2445 let DecoderMethod = "DecodeSTRPreImm";
2448 def _PRE_REG : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2449 (ins GPR:$Rt, ldst_so_reg:$addr),
2450 IndexModePre, StFrm, iir,
2451 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2454 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2455 let Inst{19-16} = addr{16-13}; // Rn
2456 let Inst{11-0} = addr{11-0};
2457 let Inst{4} = 0; // Inst{4} = 0
2458 let AsmMatchConverter = "cvtStWriteBackRegAddrMode2";
2459 let DecoderMethod = "DecodeSTRPreReg";
2461 def _POST_REG : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2462 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2463 IndexModePost, StFrm, iir,
2464 opc, "\t$Rt, $addr, $offset",
2465 "$addr.base = $Rn_wb", []> {
2471 let Inst{23} = offset{12};
2472 let Inst{19-16} = addr;
2473 let Inst{11-0} = offset{11-0};
2476 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2479 def _POST_IMM : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2480 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2481 IndexModePost, StFrm, iii,
2482 opc, "\t$Rt, $addr, $offset",
2483 "$addr.base = $Rn_wb", []> {
2489 let Inst{23} = offset{12};
2490 let Inst{19-16} = addr;
2491 let Inst{11-0} = offset{11-0};
2493 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2497 let mayStore = 1, neverHasSideEffects = 1 in {
2498 // FIXME: for STR_PRE_REG etc. the itineray should be either IIC_iStore_ru or
2499 // IIC_iStore_siu depending on whether it the offset register is shifted.
2500 defm STR : AI2_stridx<0, "str", IIC_iStore_iu, IIC_iStore_ru>;
2501 defm STRB : AI2_stridx<1, "strb", IIC_iStore_bh_iu, IIC_iStore_bh_ru>;
2504 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2505 am2offset_reg:$offset),
2506 (STR_POST_REG GPR:$Rt, addr_offset_none:$addr,
2507 am2offset_reg:$offset)>;
2508 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2509 am2offset_imm:$offset),
2510 (STR_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2511 am2offset_imm:$offset)>;
2512 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2513 am2offset_reg:$offset),
2514 (STRB_POST_REG GPR:$Rt, addr_offset_none:$addr,
2515 am2offset_reg:$offset)>;
2516 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2517 am2offset_imm:$offset),
2518 (STRB_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2519 am2offset_imm:$offset)>;
2521 // Pseudo-instructions for pattern matching the pre-indexed stores. We can't
2522 // put the patterns on the instruction definitions directly as ISel wants
2523 // the address base and offset to be separate operands, not a single
2524 // complex operand like we represent the instructions themselves. The
2525 // pseudos map between the two.
2526 let usesCustomInserter = 1,
2527 Constraints = "$Rn = $Rn_wb,@earlyclobber $Rn_wb" in {
2528 def STRi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2529 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2532 (pre_store GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2533 def STRr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2534 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2537 (pre_store GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2538 def STRBi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2539 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2542 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2543 def STRBr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2544 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2547 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2548 def STRH_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2549 (ins GPR:$Rt, GPR:$Rn, am3offset:$offset, pred:$p),
2552 (pre_truncsti16 GPR:$Rt, GPR:$Rn, am3offset:$offset))]>;
2557 def STRH_PRE : AI3ldstidx<0b1011, 0, 1, (outs GPR:$Rn_wb),
2558 (ins GPR:$Rt, addrmode3:$addr), IndexModePre,
2559 StMiscFrm, IIC_iStore_bh_ru,
2560 "strh", "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2562 let Inst{23} = addr{8}; // U bit
2563 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2564 let Inst{19-16} = addr{12-9}; // Rn
2565 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2566 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2567 let AsmMatchConverter = "cvtStWriteBackRegAddrMode3";
2568 let DecoderMethod = "DecodeAddrMode3Instruction";
2571 def STRH_POST : AI3ldstidx<0b1011, 0, 0, (outs GPR:$Rn_wb),
2572 (ins GPR:$Rt, addr_offset_none:$addr, am3offset:$offset),
2573 IndexModePost, StMiscFrm, IIC_iStore_bh_ru,
2574 "strh", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2575 [(set GPR:$Rn_wb, (post_truncsti16 GPR:$Rt,
2576 addr_offset_none:$addr,
2577 am3offset:$offset))]> {
2580 let Inst{23} = offset{8}; // U bit
2581 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2582 let Inst{19-16} = addr;
2583 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2584 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2585 let DecoderMethod = "DecodeAddrMode3Instruction";
2588 let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in {
2589 def STRD_PRE : AI3ldstidx<0b1111, 0, 1, (outs GPR:$Rn_wb),
2590 (ins GPR:$Rt, GPR:$Rt2, addrmode3:$addr),
2591 IndexModePre, StMiscFrm, IIC_iStore_d_ru,
2592 "strd", "\t$Rt, $Rt2, $addr!",
2593 "$addr.base = $Rn_wb", []> {
2595 let Inst{23} = addr{8}; // U bit
2596 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2597 let Inst{19-16} = addr{12-9}; // Rn
2598 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2599 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2600 let DecoderMethod = "DecodeAddrMode3Instruction";
2601 let AsmMatchConverter = "cvtStrdPre";
2604 def STRD_POST: AI3ldstidx<0b1111, 0, 0, (outs GPR:$Rn_wb),
2605 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr,
2607 IndexModePost, StMiscFrm, IIC_iStore_d_ru,
2608 "strd", "\t$Rt, $Rt2, $addr, $offset",
2609 "$addr.base = $Rn_wb", []> {
2612 let Inst{23} = offset{8}; // U bit
2613 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2614 let Inst{19-16} = addr;
2615 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2616 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2617 let DecoderMethod = "DecodeAddrMode3Instruction";
2619 } // mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1
2621 // STRT, STRBT, and STRHT
2623 def STRBT_POST_REG : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2624 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2625 IndexModePost, StFrm, IIC_iStore_bh_ru,
2626 "strbt", "\t$Rt, $addr, $offset",
2627 "$addr.base = $Rn_wb", []> {
2633 let Inst{23} = offset{12};
2634 let Inst{21} = 1; // overwrite
2635 let Inst{19-16} = addr;
2636 let Inst{11-5} = offset{11-5};
2638 let Inst{3-0} = offset{3-0};
2639 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2642 def STRBT_POST_IMM : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2643 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2644 IndexModePost, StFrm, IIC_iStore_bh_ru,
2645 "strbt", "\t$Rt, $addr, $offset",
2646 "$addr.base = $Rn_wb", []> {
2652 let Inst{23} = offset{12};
2653 let Inst{21} = 1; // overwrite
2654 let Inst{19-16} = addr;
2655 let Inst{11-0} = offset{11-0};
2656 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2659 let mayStore = 1, neverHasSideEffects = 1 in {
2660 def STRT_POST_REG : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
2661 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2662 IndexModePost, StFrm, IIC_iStore_ru,
2663 "strt", "\t$Rt, $addr, $offset",
2664 "$addr.base = $Rn_wb", []> {
2670 let Inst{23} = offset{12};
2671 let Inst{21} = 1; // overwrite
2672 let Inst{19-16} = addr;
2673 let Inst{11-5} = offset{11-5};
2675 let Inst{3-0} = offset{3-0};
2676 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2679 def STRT_POST_IMM : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
2680 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2681 IndexModePost, StFrm, IIC_iStore_ru,
2682 "strt", "\t$Rt, $addr, $offset",
2683 "$addr.base = $Rn_wb", []> {
2689 let Inst{23} = offset{12};
2690 let Inst{21} = 1; // overwrite
2691 let Inst{19-16} = addr;
2692 let Inst{11-0} = offset{11-0};
2693 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2698 multiclass AI3strT<bits<4> op, string opc> {
2699 def i : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
2700 (ins GPR:$Rt, addr_offset_none:$addr, postidx_imm8:$offset),
2701 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
2702 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2704 let Inst{23} = offset{8};
2706 let Inst{11-8} = offset{7-4};
2707 let Inst{3-0} = offset{3-0};
2708 let AsmMatchConverter = "cvtStExtTWriteBackImm";
2710 def r : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
2711 (ins GPR:$Rt, addr_offset_none:$addr, postidx_reg:$Rm),
2712 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
2713 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2715 let Inst{23} = Rm{4};
2718 let Inst{3-0} = Rm{3-0};
2719 let AsmMatchConverter = "cvtStExtTWriteBackReg";
2724 defm STRHT : AI3strT<0b1011, "strht">;
2727 //===----------------------------------------------------------------------===//
2728 // Load / store multiple Instructions.
2731 multiclass arm_ldst_mult<string asm, string sfx, bit L_bit, bit P_bit, Format f,
2732 InstrItinClass itin, InstrItinClass itin_upd> {
2733 // IA is the default, so no need for an explicit suffix on the
2734 // mnemonic here. Without it is the canonical spelling.
2736 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2737 IndexModeNone, f, itin,
2738 !strconcat(asm, "${p}\t$Rn, $regs", sfx), "", []> {
2739 let Inst{24-23} = 0b01; // Increment After
2740 let Inst{22} = P_bit;
2741 let Inst{21} = 0; // No writeback
2742 let Inst{20} = L_bit;
2745 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2746 IndexModeUpd, f, itin_upd,
2747 !strconcat(asm, "${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
2748 let Inst{24-23} = 0b01; // Increment After
2749 let Inst{22} = P_bit;
2750 let Inst{21} = 1; // Writeback
2751 let Inst{20} = L_bit;
2753 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2756 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2757 IndexModeNone, f, itin,
2758 !strconcat(asm, "da${p}\t$Rn, $regs", sfx), "", []> {
2759 let Inst{24-23} = 0b00; // Decrement After
2760 let Inst{22} = P_bit;
2761 let Inst{21} = 0; // No writeback
2762 let Inst{20} = L_bit;
2765 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2766 IndexModeUpd, f, itin_upd,
2767 !strconcat(asm, "da${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
2768 let Inst{24-23} = 0b00; // Decrement After
2769 let Inst{22} = P_bit;
2770 let Inst{21} = 1; // Writeback
2771 let Inst{20} = L_bit;
2773 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2776 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2777 IndexModeNone, f, itin,
2778 !strconcat(asm, "db${p}\t$Rn, $regs", sfx), "", []> {
2779 let Inst{24-23} = 0b10; // Decrement Before
2780 let Inst{22} = P_bit;
2781 let Inst{21} = 0; // No writeback
2782 let Inst{20} = L_bit;
2785 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2786 IndexModeUpd, f, itin_upd,
2787 !strconcat(asm, "db${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
2788 let Inst{24-23} = 0b10; // Decrement Before
2789 let Inst{22} = P_bit;
2790 let Inst{21} = 1; // Writeback
2791 let Inst{20} = L_bit;
2793 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2796 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2797 IndexModeNone, f, itin,
2798 !strconcat(asm, "ib${p}\t$Rn, $regs", sfx), "", []> {
2799 let Inst{24-23} = 0b11; // Increment Before
2800 let Inst{22} = P_bit;
2801 let Inst{21} = 0; // No writeback
2802 let Inst{20} = L_bit;
2805 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2806 IndexModeUpd, f, itin_upd,
2807 !strconcat(asm, "ib${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
2808 let Inst{24-23} = 0b11; // Increment Before
2809 let Inst{22} = P_bit;
2810 let Inst{21} = 1; // Writeback
2811 let Inst{20} = L_bit;
2813 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2817 let neverHasSideEffects = 1 in {
2819 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
2820 defm LDM : arm_ldst_mult<"ldm", "", 1, 0, LdStMulFrm, IIC_iLoad_m,
2823 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
2824 defm STM : arm_ldst_mult<"stm", "", 0, 0, LdStMulFrm, IIC_iStore_m,
2827 } // neverHasSideEffects
2829 // FIXME: remove when we have a way to marking a MI with these properties.
2830 // FIXME: Should pc be an implicit operand like PICADD, etc?
2831 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
2832 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
2833 def LDMIA_RET : ARMPseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p,
2834 reglist:$regs, variable_ops),
2835 4, IIC_iLoad_mBr, [],
2836 (LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>,
2837 RegConstraint<"$Rn = $wb">;
2839 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
2840 defm sysLDM : arm_ldst_mult<"ldm", " ^", 1, 1, LdStMulFrm, IIC_iLoad_m,
2843 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
2844 defm sysSTM : arm_ldst_mult<"stm", " ^", 0, 1, LdStMulFrm, IIC_iStore_m,
2849 //===----------------------------------------------------------------------===//
2850 // Move Instructions.
2853 let neverHasSideEffects = 1 in
2854 def MOVr : AsI1<0b1101, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMOVr,
2855 "mov", "\t$Rd, $Rm", []>, UnaryDP {
2859 let Inst{19-16} = 0b0000;
2860 let Inst{11-4} = 0b00000000;
2863 let Inst{15-12} = Rd;
2866 // A version for the smaller set of tail call registers.
2867 let neverHasSideEffects = 1 in
2868 def MOVr_TC : AsI1<0b1101, (outs tcGPR:$Rd), (ins tcGPR:$Rm), DPFrm,
2869 IIC_iMOVr, "mov", "\t$Rd, $Rm", []>, UnaryDP {
2873 let Inst{11-4} = 0b00000000;
2876 let Inst{15-12} = Rd;
2879 def MOVsr : AsI1<0b1101, (outs GPRnopc:$Rd), (ins shift_so_reg_reg:$src),
2880 DPSoRegRegFrm, IIC_iMOVsr,
2881 "mov", "\t$Rd, $src",
2882 [(set GPRnopc:$Rd, shift_so_reg_reg:$src)]>, UnaryDP {
2885 let Inst{15-12} = Rd;
2886 let Inst{19-16} = 0b0000;
2887 let Inst{11-8} = src{11-8};
2889 let Inst{6-5} = src{6-5};
2891 let Inst{3-0} = src{3-0};
2895 def MOVsi : AsI1<0b1101, (outs GPR:$Rd), (ins shift_so_reg_imm:$src),
2896 DPSoRegImmFrm, IIC_iMOVsr,
2897 "mov", "\t$Rd, $src", [(set GPR:$Rd, shift_so_reg_imm:$src)]>,
2901 let Inst{15-12} = Rd;
2902 let Inst{19-16} = 0b0000;
2903 let Inst{11-5} = src{11-5};
2905 let Inst{3-0} = src{3-0};
2909 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
2910 def MOVi : AsI1<0b1101, (outs GPR:$Rd), (ins so_imm:$imm), DPFrm, IIC_iMOVi,
2911 "mov", "\t$Rd, $imm", [(set GPR:$Rd, so_imm:$imm)]>, UnaryDP {
2915 let Inst{15-12} = Rd;
2916 let Inst{19-16} = 0b0000;
2917 let Inst{11-0} = imm;
2920 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
2921 def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins imm0_65535_expr:$imm),
2923 "movw", "\t$Rd, $imm",
2924 [(set GPR:$Rd, imm0_65535:$imm)]>,
2925 Requires<[IsARM, HasV6T2]>, UnaryDP {
2928 let Inst{15-12} = Rd;
2929 let Inst{11-0} = imm{11-0};
2930 let Inst{19-16} = imm{15-12};
2933 let DecoderMethod = "DecodeArmMOVTWInstruction";
2936 def : InstAlias<"mov${p} $Rd, $imm",
2937 (MOVi16 GPR:$Rd, imm0_65535_expr:$imm, pred:$p)>,
2940 def MOVi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
2941 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>;
2943 let Constraints = "$src = $Rd" in {
2944 def MOVTi16 : AI1<0b1010, (outs GPRnopc:$Rd),
2945 (ins GPR:$src, imm0_65535_expr:$imm),
2947 "movt", "\t$Rd, $imm",
2949 (or (and GPR:$src, 0xffff),
2950 lo16AllZero:$imm))]>, UnaryDP,
2951 Requires<[IsARM, HasV6T2]> {
2954 let Inst{15-12} = Rd;
2955 let Inst{11-0} = imm{11-0};
2956 let Inst{19-16} = imm{15-12};
2959 let DecoderMethod = "DecodeArmMOVTWInstruction";
2962 def MOVTi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
2963 (ins GPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>;
2967 def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
2968 Requires<[IsARM, HasV6T2]>;
2970 let Uses = [CPSR] in
2971 def RRX: PseudoInst<(outs GPR:$Rd), (ins GPR:$Rm), IIC_iMOVsi,
2972 [(set GPR:$Rd, (ARMrrx GPR:$Rm))]>, UnaryDP,
2975 // These aren't really mov instructions, but we have to define them this way
2976 // due to flag operands.
2978 let Defs = [CPSR] in {
2979 def MOVsrl_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
2980 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP,
2982 def MOVsra_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
2983 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP,
2987 //===----------------------------------------------------------------------===//
2988 // Extend Instructions.
2993 def SXTB : AI_ext_rrot<0b01101010,
2994 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
2995 def SXTH : AI_ext_rrot<0b01101011,
2996 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
2998 def SXTAB : AI_exta_rrot<0b01101010,
2999 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
3000 def SXTAH : AI_exta_rrot<0b01101011,
3001 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
3003 def SXTB16 : AI_ext_rrot_np<0b01101000, "sxtb16">;
3005 def SXTAB16 : AI_exta_rrot_np<0b01101000, "sxtab16">;
3009 let AddedComplexity = 16 in {
3010 def UXTB : AI_ext_rrot<0b01101110,
3011 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
3012 def UXTH : AI_ext_rrot<0b01101111,
3013 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
3014 def UXTB16 : AI_ext_rrot<0b01101100,
3015 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
3017 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
3018 // The transformation should probably be done as a combiner action
3019 // instead so we can include a check for masking back in the upper
3020 // eight bits of the source into the lower eight bits of the result.
3021 //def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
3022 // (UXTB16r_rot GPR:$Src, 3)>;
3023 def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
3024 (UXTB16 GPR:$Src, 1)>;
3026 def UXTAB : AI_exta_rrot<0b01101110, "uxtab",
3027 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
3028 def UXTAH : AI_exta_rrot<0b01101111, "uxtah",
3029 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
3032 // This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
3033 def UXTAB16 : AI_exta_rrot_np<0b01101100, "uxtab16">;
3036 def SBFX : I<(outs GPRnopc:$Rd),
3037 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3038 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3039 "sbfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3040 Requires<[IsARM, HasV6T2]> {
3045 let Inst{27-21} = 0b0111101;
3046 let Inst{6-4} = 0b101;
3047 let Inst{20-16} = width;
3048 let Inst{15-12} = Rd;
3049 let Inst{11-7} = lsb;
3053 def UBFX : I<(outs GPR:$Rd),
3054 (ins GPR:$Rn, imm0_31:$lsb, imm1_32:$width),
3055 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3056 "ubfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3057 Requires<[IsARM, HasV6T2]> {
3062 let Inst{27-21} = 0b0111111;
3063 let Inst{6-4} = 0b101;
3064 let Inst{20-16} = width;
3065 let Inst{15-12} = Rd;
3066 let Inst{11-7} = lsb;
3070 //===----------------------------------------------------------------------===//
3071 // Arithmetic Instructions.
3074 defm ADD : AsI1_bin_irs<0b0100, "add",
3075 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3076 BinOpFrag<(add node:$LHS, node:$RHS)>, 1>;
3077 defm SUB : AsI1_bin_irs<0b0010, "sub",
3078 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3079 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
3081 // ADD and SUB with 's' bit set.
3083 // Currently, ADDS/SUBS are pseudo opcodes that exist only in the
3084 // selection DAG. They are "lowered" to real ADD/SUB opcodes by
3085 // AdjustInstrPostInstrSelection where we determine whether or not to
3086 // set the "s" bit based on CPSR liveness.
3088 // FIXME: Eliminate ADDS/SUBS pseudo opcodes after adding tablegen
3089 // support for an optional CPSR definition that corresponds to the DAG
3090 // node's second value. We can then eliminate the implicit def of CPSR.
3091 defm ADDS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3092 BinOpFrag<(ARMaddc node:$LHS, node:$RHS)>, 1>;
3093 defm SUBS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3094 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
3096 defm ADC : AI1_adde_sube_irs<0b0101, "adc",
3097 BinOpWithFlagFrag<(ARMadde node:$LHS, node:$RHS, node:$FLAG)>, 1>;
3098 defm SBC : AI1_adde_sube_irs<0b0110, "sbc",
3099 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>>;
3101 defm RSB : AsI1_rbin_irs<0b0011, "rsb",
3102 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3103 BinOpFrag<(sub node:$LHS, node:$RHS)>>;
3105 // FIXME: Eliminate them if we can write def : Pat patterns which defines
3106 // CPSR and the implicit def of CPSR is not needed.
3107 defm RSBS : AsI1_rbin_s_is<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3108 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
3110 defm RSC : AI1_rsc_irs<0b0111, "rsc",
3111 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>>;
3113 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
3114 // The assume-no-carry-in form uses the negation of the input since add/sub
3115 // assume opposite meanings of the carry flag (i.e., carry == !borrow).
3116 // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
3118 def : ARMPat<(add GPR:$src, so_imm_neg:$imm),
3119 (SUBri GPR:$src, so_imm_neg:$imm)>;
3120 def : ARMPat<(ARMaddc GPR:$src, so_imm_neg:$imm),
3121 (SUBSri GPR:$src, so_imm_neg:$imm)>;
3123 def : ARMPat<(add GPR:$src, imm0_65535_neg:$imm),
3124 (SUBrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>,
3125 Requires<[IsARM, HasV6T2]>;
3126 def : ARMPat<(ARMaddc GPR:$src, imm0_65535_neg:$imm),
3127 (SUBSrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>,
3128 Requires<[IsARM, HasV6T2]>;
3130 // The with-carry-in form matches bitwise not instead of the negation.
3131 // Effectively, the inverse interpretation of the carry flag already accounts
3132 // for part of the negation.
3133 def : ARMPat<(ARMadde GPR:$src, so_imm_not:$imm, CPSR),
3134 (SBCri GPR:$src, so_imm_not:$imm)>;
3135 def : ARMPat<(ARMadde GPR:$src, imm0_65535_neg:$imm, CPSR),
3136 (SBCrr GPR:$src, (MOVi16 (imm_not_XFORM imm:$imm)))>;
3138 // Note: These are implemented in C++ code, because they have to generate
3139 // ADD/SUBrs instructions, which use a complex pattern that a xform function
3141 // (mul X, 2^n+1) -> (add (X << n), X)
3142 // (mul X, 2^n-1) -> (rsb X, (X << n))
3144 // ARM Arithmetic Instruction
3145 // GPR:$dst = GPR:$a op GPR:$b
3146 class AAI<bits<8> op27_20, bits<8> op11_4, string opc,
3147 list<dag> pattern = [],
3148 dag iops = (ins GPRnopc:$Rn, GPRnopc:$Rm),
3149 string asm = "\t$Rd, $Rn, $Rm">
3150 : AI<(outs GPRnopc:$Rd), iops, DPFrm, IIC_iALUr, opc, asm, pattern> {
3154 let Inst{27-20} = op27_20;
3155 let Inst{11-4} = op11_4;
3156 let Inst{19-16} = Rn;
3157 let Inst{15-12} = Rd;
3160 let Unpredictable{11-8} = 0b1111;
3163 // Saturating add/subtract
3165 def QADD : AAI<0b00010000, 0b00000101, "qadd",
3166 [(set GPRnopc:$Rd, (int_arm_qadd GPRnopc:$Rm, GPRnopc:$Rn))],
3167 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3168 def QSUB : AAI<0b00010010, 0b00000101, "qsub",
3169 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm, GPRnopc:$Rn))],
3170 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3171 def QDADD : AAI<0b00010100, 0b00000101, "qdadd", [],
3172 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3174 def QDSUB : AAI<0b00010110, 0b00000101, "qdsub", [],
3175 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3178 def QADD16 : AAI<0b01100010, 0b11110001, "qadd16">;
3179 def QADD8 : AAI<0b01100010, 0b11111001, "qadd8">;
3180 def QASX : AAI<0b01100010, 0b11110011, "qasx">;
3181 def QSAX : AAI<0b01100010, 0b11110101, "qsax">;
3182 def QSUB16 : AAI<0b01100010, 0b11110111, "qsub16">;
3183 def QSUB8 : AAI<0b01100010, 0b11111111, "qsub8">;
3184 def UQADD16 : AAI<0b01100110, 0b11110001, "uqadd16">;
3185 def UQADD8 : AAI<0b01100110, 0b11111001, "uqadd8">;
3186 def UQASX : AAI<0b01100110, 0b11110011, "uqasx">;
3187 def UQSAX : AAI<0b01100110, 0b11110101, "uqsax">;
3188 def UQSUB16 : AAI<0b01100110, 0b11110111, "uqsub16">;
3189 def UQSUB8 : AAI<0b01100110, 0b11111111, "uqsub8">;
3191 // Signed/Unsigned add/subtract
3193 def SASX : AAI<0b01100001, 0b11110011, "sasx">;
3194 def SADD16 : AAI<0b01100001, 0b11110001, "sadd16">;
3195 def SADD8 : AAI<0b01100001, 0b11111001, "sadd8">;
3196 def SSAX : AAI<0b01100001, 0b11110101, "ssax">;
3197 def SSUB16 : AAI<0b01100001, 0b11110111, "ssub16">;
3198 def SSUB8 : AAI<0b01100001, 0b11111111, "ssub8">;
3199 def UASX : AAI<0b01100101, 0b11110011, "uasx">;
3200 def UADD16 : AAI<0b01100101, 0b11110001, "uadd16">;
3201 def UADD8 : AAI<0b01100101, 0b11111001, "uadd8">;
3202 def USAX : AAI<0b01100101, 0b11110101, "usax">;
3203 def USUB16 : AAI<0b01100101, 0b11110111, "usub16">;
3204 def USUB8 : AAI<0b01100101, 0b11111111, "usub8">;
3206 // Signed/Unsigned halving add/subtract
3208 def SHASX : AAI<0b01100011, 0b11110011, "shasx">;
3209 def SHADD16 : AAI<0b01100011, 0b11110001, "shadd16">;
3210 def SHADD8 : AAI<0b01100011, 0b11111001, "shadd8">;
3211 def SHSAX : AAI<0b01100011, 0b11110101, "shsax">;
3212 def SHSUB16 : AAI<0b01100011, 0b11110111, "shsub16">;
3213 def SHSUB8 : AAI<0b01100011, 0b11111111, "shsub8">;
3214 def UHASX : AAI<0b01100111, 0b11110011, "uhasx">;
3215 def UHADD16 : AAI<0b01100111, 0b11110001, "uhadd16">;
3216 def UHADD8 : AAI<0b01100111, 0b11111001, "uhadd8">;
3217 def UHSAX : AAI<0b01100111, 0b11110101, "uhsax">;
3218 def UHSUB16 : AAI<0b01100111, 0b11110111, "uhsub16">;
3219 def UHSUB8 : AAI<0b01100111, 0b11111111, "uhsub8">;
3221 // Unsigned Sum of Absolute Differences [and Accumulate].
3223 def USAD8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3224 MulFrm /* for convenience */, NoItinerary, "usad8",
3225 "\t$Rd, $Rn, $Rm", []>,
3226 Requires<[IsARM, HasV6]> {
3230 let Inst{27-20} = 0b01111000;
3231 let Inst{15-12} = 0b1111;
3232 let Inst{7-4} = 0b0001;
3233 let Inst{19-16} = Rd;
3234 let Inst{11-8} = Rm;
3237 def USADA8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3238 MulFrm /* for convenience */, NoItinerary, "usada8",
3239 "\t$Rd, $Rn, $Rm, $Ra", []>,
3240 Requires<[IsARM, HasV6]> {
3245 let Inst{27-20} = 0b01111000;
3246 let Inst{7-4} = 0b0001;
3247 let Inst{19-16} = Rd;
3248 let Inst{15-12} = Ra;
3249 let Inst{11-8} = Rm;
3253 // Signed/Unsigned saturate
3255 def SSAT : AI<(outs GPRnopc:$Rd),
3256 (ins imm1_32:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3257 SatFrm, NoItinerary, "ssat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3262 let Inst{27-21} = 0b0110101;
3263 let Inst{5-4} = 0b01;
3264 let Inst{20-16} = sat_imm;
3265 let Inst{15-12} = Rd;
3266 let Inst{11-7} = sh{4-0};
3267 let Inst{6} = sh{5};
3271 def SSAT16 : AI<(outs GPRnopc:$Rd),
3272 (ins imm1_16:$sat_imm, GPRnopc:$Rn), SatFrm,
3273 NoItinerary, "ssat16", "\t$Rd, $sat_imm, $Rn", []> {
3277 let Inst{27-20} = 0b01101010;
3278 let Inst{11-4} = 0b11110011;
3279 let Inst{15-12} = Rd;
3280 let Inst{19-16} = sat_imm;
3284 def USAT : AI<(outs GPRnopc:$Rd),
3285 (ins imm0_31:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3286 SatFrm, NoItinerary, "usat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3291 let Inst{27-21} = 0b0110111;
3292 let Inst{5-4} = 0b01;
3293 let Inst{15-12} = Rd;
3294 let Inst{11-7} = sh{4-0};
3295 let Inst{6} = sh{5};
3296 let Inst{20-16} = sat_imm;
3300 def USAT16 : AI<(outs GPRnopc:$Rd),
3301 (ins imm0_15:$sat_imm, GPRnopc:$Rn), SatFrm,
3302 NoItinerary, "usat16", "\t$Rd, $sat_imm, $Rn", []> {
3306 let Inst{27-20} = 0b01101110;
3307 let Inst{11-4} = 0b11110011;
3308 let Inst{15-12} = Rd;
3309 let Inst{19-16} = sat_imm;
3313 def : ARMV6Pat<(int_arm_ssat GPRnopc:$a, imm:$pos),
3314 (SSAT imm:$pos, GPRnopc:$a, 0)>;
3315 def : ARMV6Pat<(int_arm_usat GPRnopc:$a, imm:$pos),
3316 (USAT imm:$pos, GPRnopc:$a, 0)>;
3318 //===----------------------------------------------------------------------===//
3319 // Bitwise Instructions.
3322 defm AND : AsI1_bin_irs<0b0000, "and",
3323 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3324 BinOpFrag<(and node:$LHS, node:$RHS)>, 1>;
3325 defm ORR : AsI1_bin_irs<0b1100, "orr",
3326 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3327 BinOpFrag<(or node:$LHS, node:$RHS)>, 1>;
3328 defm EOR : AsI1_bin_irs<0b0001, "eor",
3329 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3330 BinOpFrag<(xor node:$LHS, node:$RHS)>, 1>;
3331 defm BIC : AsI1_bin_irs<0b1110, "bic",
3332 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3333 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
3335 // FIXME: bf_inv_mask_imm should be two operands, the lsb and the msb, just
3336 // like in the actual instruction encoding. The complexity of mapping the mask
3337 // to the lsb/msb pair should be handled by ISel, not encapsulated in the
3338 // instruction description.
3339 def BFC : I<(outs GPR:$Rd), (ins GPR:$src, bf_inv_mask_imm:$imm),
3340 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3341 "bfc", "\t$Rd, $imm", "$src = $Rd",
3342 [(set GPR:$Rd, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
3343 Requires<[IsARM, HasV6T2]> {
3346 let Inst{27-21} = 0b0111110;
3347 let Inst{6-0} = 0b0011111;
3348 let Inst{15-12} = Rd;
3349 let Inst{11-7} = imm{4-0}; // lsb
3350 let Inst{20-16} = imm{9-5}; // msb
3353 // A8.6.18 BFI - Bitfield insert (Encoding A1)
3354 def BFI:I<(outs GPRnopc:$Rd), (ins GPRnopc:$src, GPR:$Rn, bf_inv_mask_imm:$imm),
3355 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3356 "bfi", "\t$Rd, $Rn, $imm", "$src = $Rd",
3357 [(set GPRnopc:$Rd, (ARMbfi GPRnopc:$src, GPR:$Rn,
3358 bf_inv_mask_imm:$imm))]>,
3359 Requires<[IsARM, HasV6T2]> {
3363 let Inst{27-21} = 0b0111110;
3364 let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15
3365 let Inst{15-12} = Rd;
3366 let Inst{11-7} = imm{4-0}; // lsb
3367 let Inst{20-16} = imm{9-5}; // width
3371 def MVNr : AsI1<0b1111, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMVNr,
3372 "mvn", "\t$Rd, $Rm",
3373 [(set GPR:$Rd, (not GPR:$Rm))]>, UnaryDP {
3377 let Inst{19-16} = 0b0000;
3378 let Inst{11-4} = 0b00000000;
3379 let Inst{15-12} = Rd;
3382 def MVNsi : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_imm:$shift),
3383 DPSoRegImmFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3384 [(set GPR:$Rd, (not so_reg_imm:$shift))]>, UnaryDP {
3388 let Inst{19-16} = 0b0000;
3389 let Inst{15-12} = Rd;
3390 let Inst{11-5} = shift{11-5};
3392 let Inst{3-0} = shift{3-0};
3394 def MVNsr : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_reg:$shift),
3395 DPSoRegRegFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3396 [(set GPR:$Rd, (not so_reg_reg:$shift))]>, UnaryDP {
3400 let Inst{19-16} = 0b0000;
3401 let Inst{15-12} = Rd;
3402 let Inst{11-8} = shift{11-8};
3404 let Inst{6-5} = shift{6-5};
3406 let Inst{3-0} = shift{3-0};
3408 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3409 def MVNi : AsI1<0b1111, (outs GPR:$Rd), (ins so_imm:$imm), DPFrm,
3410 IIC_iMVNi, "mvn", "\t$Rd, $imm",
3411 [(set GPR:$Rd, so_imm_not:$imm)]>,UnaryDP {
3415 let Inst{19-16} = 0b0000;
3416 let Inst{15-12} = Rd;
3417 let Inst{11-0} = imm;
3420 def : ARMPat<(and GPR:$src, so_imm_not:$imm),
3421 (BICri GPR:$src, so_imm_not:$imm)>;
3423 //===----------------------------------------------------------------------===//
3424 // Multiply Instructions.
3426 class AsMul1I32<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3427 string opc, string asm, list<dag> pattern>
3428 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3432 let Inst{19-16} = Rd;
3433 let Inst{11-8} = Rm;
3436 class AsMul1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3437 string opc, string asm, list<dag> pattern>
3438 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3443 let Inst{19-16} = RdHi;
3444 let Inst{15-12} = RdLo;
3445 let Inst{11-8} = Rm;
3448 class AsMla1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3449 string opc, string asm, list<dag> pattern>
3450 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3455 let Inst{19-16} = RdHi;
3456 let Inst{15-12} = RdLo;
3457 let Inst{11-8} = Rm;
3461 // FIXME: The v5 pseudos are only necessary for the additional Constraint
3462 // property. Remove them when it's possible to add those properties
3463 // on an individual MachineInstr, not just an instruction description.
3464 let isCommutable = 1, TwoOperandAliasConstraint = "$Rn = $Rd" in {
3465 def MUL : AsMul1I32<0b0000000, (outs GPRnopc:$Rd),
3466 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3467 IIC_iMUL32, "mul", "\t$Rd, $Rn, $Rm",
3468 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))]>,
3469 Requires<[IsARM, HasV6]> {
3470 let Inst{15-12} = 0b0000;
3471 let Unpredictable{15-12} = 0b1111;
3474 let Constraints = "@earlyclobber $Rd" in
3475 def MULv5: ARMPseudoExpand<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm,
3476 pred:$p, cc_out:$s),
3478 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))],
3479 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s)>,
3480 Requires<[IsARM, NoV6, UseMulOps]>;
3483 def MLA : AsMul1I32<0b0000001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3484 IIC_iMAC32, "mla", "\t$Rd, $Rn, $Rm, $Ra",
3485 [(set GPR:$Rd, (add (mul GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
3486 Requires<[IsARM, HasV6, UseMulOps]> {
3488 let Inst{15-12} = Ra;
3491 let Constraints = "@earlyclobber $Rd" in
3492 def MLAv5: ARMPseudoExpand<(outs GPR:$Rd),
3493 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra, pred:$p, cc_out:$s),
3495 [(set GPR:$Rd, (add (mul GPR:$Rn, GPR:$Rm), GPR:$Ra))],
3496 (MLA GPR:$Rd, GPR:$Rn, GPR:$Rm, GPR:$Ra, pred:$p, cc_out:$s)>,
3497 Requires<[IsARM, NoV6]>;
3499 def MLS : AMul1I<0b0000011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3500 IIC_iMAC32, "mls", "\t$Rd, $Rn, $Rm, $Ra",
3501 [(set GPR:$Rd, (sub GPR:$Ra, (mul GPR:$Rn, GPR:$Rm)))]>,
3502 Requires<[IsARM, HasV6T2, UseMulOps]> {
3507 let Inst{19-16} = Rd;
3508 let Inst{15-12} = Ra;
3509 let Inst{11-8} = Rm;
3513 // Extra precision multiplies with low / high results
3514 let neverHasSideEffects = 1 in {
3515 let isCommutable = 1 in {
3516 def SMULL : AsMul1I64<0b0000110, (outs GPR:$RdLo, GPR:$RdHi),
3517 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3518 "smull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3519 Requires<[IsARM, HasV6]>;
3521 def UMULL : AsMul1I64<0b0000100, (outs GPR:$RdLo, GPR:$RdHi),
3522 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3523 "umull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3524 Requires<[IsARM, HasV6]>;
3526 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
3527 def SMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3528 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3530 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3531 Requires<[IsARM, NoV6]>;
3533 def UMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3534 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3536 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3537 Requires<[IsARM, NoV6]>;
3541 // Multiply + accumulate
3542 def SMLAL : AsMla1I64<0b0000111, (outs GPR:$RdLo, GPR:$RdHi),
3543 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64,
3544 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3545 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>;
3546 def UMLAL : AsMla1I64<0b0000101, (outs GPR:$RdLo, GPR:$RdHi),
3547 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64,
3548 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3549 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>;
3551 def UMAAL : AMul1I <0b0000010, (outs GPR:$RdLo, GPR:$RdHi),
3552 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3553 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3554 Requires<[IsARM, HasV6]> {
3559 let Inst{19-16} = RdHi;
3560 let Inst{15-12} = RdLo;
3561 let Inst{11-8} = Rm;
3565 let Constraints = "$RLo = $RdLo,$RHi = $RdHi" in {
3566 def SMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3567 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s),
3569 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi,
3570 pred:$p, cc_out:$s)>,
3571 Requires<[IsARM, NoV6]>;
3572 def UMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3573 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s),
3575 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi,
3576 pred:$p, cc_out:$s)>,
3577 Requires<[IsARM, NoV6]>;
3580 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
3581 def UMAALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3582 (ins GPR:$Rn, GPR:$Rm, pred:$p),
3584 (UMAAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p)>,
3585 Requires<[IsARM, NoV6]>;
3588 } // neverHasSideEffects
3590 // Most significant word multiply
3591 def SMMUL : AMul2I <0b0111010, 0b0001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3592 IIC_iMUL32, "smmul", "\t$Rd, $Rn, $Rm",
3593 [(set GPR:$Rd, (mulhs GPR:$Rn, GPR:$Rm))]>,
3594 Requires<[IsARM, HasV6]> {
3595 let Inst{15-12} = 0b1111;
3598 def SMMULR : AMul2I <0b0111010, 0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3599 IIC_iMUL32, "smmulr", "\t$Rd, $Rn, $Rm", []>,
3600 Requires<[IsARM, HasV6]> {
3601 let Inst{15-12} = 0b1111;
3604 def SMMLA : AMul2Ia <0b0111010, 0b0001, (outs GPR:$Rd),
3605 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3606 IIC_iMAC32, "smmla", "\t$Rd, $Rn, $Rm, $Ra",
3607 [(set GPR:$Rd, (add (mulhs GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
3608 Requires<[IsARM, HasV6, UseMulOps]>;
3610 def SMMLAR : AMul2Ia <0b0111010, 0b0011, (outs GPR:$Rd),
3611 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3612 IIC_iMAC32, "smmlar", "\t$Rd, $Rn, $Rm, $Ra", []>,
3613 Requires<[IsARM, HasV6]>;
3615 def SMMLS : AMul2Ia <0b0111010, 0b1101, (outs GPR:$Rd),
3616 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3617 IIC_iMAC32, "smmls", "\t$Rd, $Rn, $Rm, $Ra", []>,
3618 Requires<[IsARM, HasV6, UseMulOps]>;
3620 def SMMLSR : AMul2Ia <0b0111010, 0b1111, (outs GPR:$Rd),
3621 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3622 IIC_iMAC32, "smmlsr", "\t$Rd, $Rn, $Rm, $Ra", []>,
3623 Requires<[IsARM, HasV6]>;
3625 multiclass AI_smul<string opc, PatFrag opnode> {
3626 def BB : AMulxyI<0b0001011, 0b00, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3627 IIC_iMUL16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm",
3628 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3629 (sext_inreg GPR:$Rm, i16)))]>,
3630 Requires<[IsARM, HasV5TE]>;
3632 def BT : AMulxyI<0b0001011, 0b10, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3633 IIC_iMUL16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm",
3634 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3635 (sra GPR:$Rm, (i32 16))))]>,
3636 Requires<[IsARM, HasV5TE]>;
3638 def TB : AMulxyI<0b0001011, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3639 IIC_iMUL16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm",
3640 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3641 (sext_inreg GPR:$Rm, i16)))]>,
3642 Requires<[IsARM, HasV5TE]>;
3644 def TT : AMulxyI<0b0001011, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3645 IIC_iMUL16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm",
3646 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3647 (sra GPR:$Rm, (i32 16))))]>,
3648 Requires<[IsARM, HasV5TE]>;
3650 def WB : AMulxyI<0b0001001, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3651 IIC_iMUL16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm",
3652 [(set GPR:$Rd, (sra (opnode GPR:$Rn,
3653 (sext_inreg GPR:$Rm, i16)), (i32 16)))]>,
3654 Requires<[IsARM, HasV5TE]>;
3656 def WT : AMulxyI<0b0001001, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3657 IIC_iMUL16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm",
3658 [(set GPR:$Rd, (sra (opnode GPR:$Rn,
3659 (sra GPR:$Rm, (i32 16))), (i32 16)))]>,
3660 Requires<[IsARM, HasV5TE]>;
3664 multiclass AI_smla<string opc, PatFrag opnode> {
3665 let DecoderMethod = "DecodeSMLAInstruction" in {
3666 def BB : AMulxyIa<0b0001000, 0b00, (outs GPRnopc:$Rd),
3667 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3668 IIC_iMAC16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra",
3669 [(set GPRnopc:$Rd, (add GPR:$Ra,
3670 (opnode (sext_inreg GPRnopc:$Rn, i16),
3671 (sext_inreg GPRnopc:$Rm, i16))))]>,
3672 Requires<[IsARM, HasV5TE, UseMulOps]>;
3674 def BT : AMulxyIa<0b0001000, 0b10, (outs GPRnopc:$Rd),
3675 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3676 IIC_iMAC16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra",
3678 (add GPR:$Ra, (opnode (sext_inreg GPRnopc:$Rn, i16),
3679 (sra GPRnopc:$Rm, (i32 16)))))]>,
3680 Requires<[IsARM, HasV5TE, UseMulOps]>;
3682 def TB : AMulxyIa<0b0001000, 0b01, (outs GPRnopc:$Rd),
3683 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3684 IIC_iMAC16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra",
3686 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
3687 (sext_inreg GPRnopc:$Rm, i16))))]>,
3688 Requires<[IsARM, HasV5TE, UseMulOps]>;
3690 def TT : AMulxyIa<0b0001000, 0b11, (outs GPRnopc:$Rd),
3691 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3692 IIC_iMAC16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra",
3694 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
3695 (sra GPRnopc:$Rm, (i32 16)))))]>,
3696 Requires<[IsARM, HasV5TE, UseMulOps]>;
3698 def WB : AMulxyIa<0b0001001, 0b00, (outs GPRnopc:$Rd),
3699 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3700 IIC_iMAC16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra",
3702 (add GPR:$Ra, (sra (opnode GPRnopc:$Rn,
3703 (sext_inreg GPRnopc:$Rm, i16)), (i32 16))))]>,
3704 Requires<[IsARM, HasV5TE, UseMulOps]>;
3706 def WT : AMulxyIa<0b0001001, 0b10, (outs GPRnopc:$Rd),
3707 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3708 IIC_iMAC16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra",
3710 (add GPR:$Ra, (sra (opnode GPRnopc:$Rn,
3711 (sra GPRnopc:$Rm, (i32 16))), (i32 16))))]>,
3712 Requires<[IsARM, HasV5TE, UseMulOps]>;
3716 defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
3717 defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
3719 // Halfword multiply accumulate long: SMLAL<x><y>.
3720 def SMLALBB : AMulxyI64<0b0001010, 0b00, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3721 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3722 IIC_iMAC64, "smlalbb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3723 Requires<[IsARM, HasV5TE]>;
3725 def SMLALBT : AMulxyI64<0b0001010, 0b10, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3726 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3727 IIC_iMAC64, "smlalbt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3728 Requires<[IsARM, HasV5TE]>;
3730 def SMLALTB : AMulxyI64<0b0001010, 0b01, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3731 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3732 IIC_iMAC64, "smlaltb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3733 Requires<[IsARM, HasV5TE]>;
3735 def SMLALTT : AMulxyI64<0b0001010, 0b11, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3736 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3737 IIC_iMAC64, "smlaltt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3738 Requires<[IsARM, HasV5TE]>;
3740 // Helper class for AI_smld.
3741 class AMulDualIbase<bit long, bit sub, bit swap, dag oops, dag iops,
3742 InstrItinClass itin, string opc, string asm>
3743 : AI<oops, iops, MulFrm, itin, opc, asm, []>, Requires<[IsARM, HasV6]> {
3746 let Inst{27-23} = 0b01110;
3747 let Inst{22} = long;
3748 let Inst{21-20} = 0b00;
3749 let Inst{11-8} = Rm;
3756 class AMulDualI<bit long, bit sub, bit swap, dag oops, dag iops,
3757 InstrItinClass itin, string opc, string asm>
3758 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
3760 let Inst{15-12} = 0b1111;
3761 let Inst{19-16} = Rd;
3763 class AMulDualIa<bit long, bit sub, bit swap, dag oops, dag iops,
3764 InstrItinClass itin, string opc, string asm>
3765 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
3768 let Inst{19-16} = Rd;
3769 let Inst{15-12} = Ra;
3771 class AMulDualI64<bit long, bit sub, bit swap, dag oops, dag iops,
3772 InstrItinClass itin, string opc, string asm>
3773 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
3776 let Inst{19-16} = RdHi;
3777 let Inst{15-12} = RdLo;
3780 multiclass AI_smld<bit sub, string opc> {
3782 def D : AMulDualIa<0, sub, 0, (outs GPRnopc:$Rd),
3783 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3784 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm, $Ra">;
3786 def DX: AMulDualIa<0, sub, 1, (outs GPRnopc:$Rd),
3787 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3788 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm, $Ra">;
3790 def LD: AMulDualI64<1, sub, 0, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3791 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
3792 !strconcat(opc, "ld"), "\t$RdLo, $RdHi, $Rn, $Rm">;
3794 def LDX : AMulDualI64<1, sub, 1, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3795 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
3796 !strconcat(opc, "ldx"),"\t$RdLo, $RdHi, $Rn, $Rm">;
3800 defm SMLA : AI_smld<0, "smla">;
3801 defm SMLS : AI_smld<1, "smls">;
3803 multiclass AI_sdml<bit sub, string opc> {
3805 def D:AMulDualI<0, sub, 0, (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm),
3806 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm">;
3807 def DX:AMulDualI<0, sub, 1, (outs GPRnopc:$Rd),(ins GPRnopc:$Rn, GPRnopc:$Rm),
3808 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm">;
3811 defm SMUA : AI_sdml<0, "smua">;
3812 defm SMUS : AI_sdml<1, "smus">;
3814 //===----------------------------------------------------------------------===//
3815 // Division Instructions (ARMv7-A with virtualization extension)
3817 def SDIV : ADivA1I<0b001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV,
3818 "sdiv", "\t$Rd, $Rn, $Rm",
3819 [(set GPR:$Rd, (sdiv GPR:$Rn, GPR:$Rm))]>,
3820 Requires<[IsARM, HasDivideInARM]>;
3822 def UDIV : ADivA1I<0b011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV,
3823 "udiv", "\t$Rd, $Rn, $Rm",
3824 [(set GPR:$Rd, (udiv GPR:$Rn, GPR:$Rm))]>,
3825 Requires<[IsARM, HasDivideInARM]>;
3827 //===----------------------------------------------------------------------===//
3828 // Misc. Arithmetic Instructions.
3831 def CLZ : AMiscA1I<0b000010110, 0b0001, (outs GPR:$Rd), (ins GPR:$Rm),
3832 IIC_iUNAr, "clz", "\t$Rd, $Rm",
3833 [(set GPR:$Rd, (ctlz GPR:$Rm))]>, Requires<[IsARM, HasV5T]>;
3835 def RBIT : AMiscA1I<0b01101111, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
3836 IIC_iUNAr, "rbit", "\t$Rd, $Rm",
3837 [(set GPR:$Rd, (ARMrbit GPR:$Rm))]>,
3838 Requires<[IsARM, HasV6T2]>;
3840 def REV : AMiscA1I<0b01101011, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
3841 IIC_iUNAr, "rev", "\t$Rd, $Rm",
3842 [(set GPR:$Rd, (bswap GPR:$Rm))]>, Requires<[IsARM, HasV6]>;
3844 let AddedComplexity = 5 in
3845 def REV16 : AMiscA1I<0b01101011, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
3846 IIC_iUNAr, "rev16", "\t$Rd, $Rm",
3847 [(set GPR:$Rd, (rotr (bswap GPR:$Rm), (i32 16)))]>,
3848 Requires<[IsARM, HasV6]>;
3850 let AddedComplexity = 5 in
3851 def REVSH : AMiscA1I<0b01101111, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
3852 IIC_iUNAr, "revsh", "\t$Rd, $Rm",
3853 [(set GPR:$Rd, (sra (bswap GPR:$Rm), (i32 16)))]>,
3854 Requires<[IsARM, HasV6]>;
3856 def : ARMV6Pat<(or (sra (shl GPR:$Rm, (i32 24)), (i32 16)),
3857 (and (srl GPR:$Rm, (i32 8)), 0xFF)),
3860 def PKHBT : APKHI<0b01101000, 0, (outs GPRnopc:$Rd),
3861 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_lsl_amt:$sh),
3862 IIC_iALUsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh",
3863 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF),
3864 (and (shl GPRnopc:$Rm, pkh_lsl_amt:$sh),
3866 Requires<[IsARM, HasV6]>;
3868 // Alternate cases for PKHBT where identities eliminate some nodes.
3869 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (and GPRnopc:$Rm, 0xFFFF0000)),
3870 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, 0)>;
3871 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (shl GPRnopc:$Rm, imm16_31:$sh)),
3872 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, imm16_31:$sh)>;
3874 // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
3875 // will match the pattern below.
3876 def PKHTB : APKHI<0b01101000, 1, (outs GPRnopc:$Rd),
3877 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_asr_amt:$sh),
3878 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh",
3879 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF0000),
3880 (and (sra GPRnopc:$Rm, pkh_asr_amt:$sh),
3882 Requires<[IsARM, HasV6]>;
3884 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
3885 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
3886 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
3887 (srl GPRnopc:$src2, imm16_31:$sh)),
3888 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16_31:$sh)>;
3889 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
3890 (and (srl GPRnopc:$src2, imm1_15:$sh), 0xFFFF)),
3891 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm1_15:$sh)>;
3893 //===----------------------------------------------------------------------===//
3894 // Comparison Instructions...
3897 defm CMP : AI1_cmp_irs<0b1010, "cmp",
3898 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
3899 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
3901 // ARMcmpZ can re-use the above instruction definitions.
3902 def : ARMPat<(ARMcmpZ GPR:$src, so_imm:$imm),
3903 (CMPri GPR:$src, so_imm:$imm)>;
3904 def : ARMPat<(ARMcmpZ GPR:$src, GPR:$rhs),
3905 (CMPrr GPR:$src, GPR:$rhs)>;
3906 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_imm:$rhs),
3907 (CMPrsi GPR:$src, so_reg_imm:$rhs)>;
3908 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_reg:$rhs),
3909 (CMPrsr GPR:$src, so_reg_reg:$rhs)>;
3911 // CMN register-integer
3912 let isCompare = 1, Defs = [CPSR] in {
3913 def CMNri : AI1<0b1011, (outs), (ins GPR:$Rn, so_imm:$imm), DPFrm, IIC_iCMPi,
3914 "cmn", "\t$Rn, $imm",
3915 [(ARMcmn GPR:$Rn, so_imm:$imm)]> {
3920 let Inst{19-16} = Rn;
3921 let Inst{15-12} = 0b0000;
3922 let Inst{11-0} = imm;
3924 let Unpredictable{15-12} = 0b1111;
3927 // CMN register-register/shift
3928 def CMNzrr : AI1<0b1011, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, IIC_iCMPr,
3929 "cmn", "\t$Rn, $Rm",
3930 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
3931 GPR:$Rn, GPR:$Rm)]> {
3934 let isCommutable = 1;
3937 let Inst{19-16} = Rn;
3938 let Inst{15-12} = 0b0000;
3939 let Inst{11-4} = 0b00000000;
3942 let Unpredictable{15-12} = 0b1111;
3945 def CMNzrsi : AI1<0b1011, (outs),
3946 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, IIC_iCMPsr,
3947 "cmn", "\t$Rn, $shift",
3948 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
3949 GPR:$Rn, so_reg_imm:$shift)]> {
3954 let Inst{19-16} = Rn;
3955 let Inst{15-12} = 0b0000;
3956 let Inst{11-5} = shift{11-5};
3958 let Inst{3-0} = shift{3-0};
3960 let Unpredictable{15-12} = 0b1111;
3963 def CMNzrsr : AI1<0b1011, (outs),
3964 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, IIC_iCMPsr,
3965 "cmn", "\t$Rn, $shift",
3966 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
3967 GPRnopc:$Rn, so_reg_reg:$shift)]> {
3972 let Inst{19-16} = Rn;
3973 let Inst{15-12} = 0b0000;
3974 let Inst{11-8} = shift{11-8};
3976 let Inst{6-5} = shift{6-5};
3978 let Inst{3-0} = shift{3-0};
3980 let Unpredictable{15-12} = 0b1111;
3985 def : ARMPat<(ARMcmp GPR:$src, so_imm_neg:$imm),
3986 (CMNri GPR:$src, so_imm_neg:$imm)>;
3988 def : ARMPat<(ARMcmpZ GPR:$src, so_imm_neg:$imm),
3989 (CMNri GPR:$src, so_imm_neg:$imm)>;
3991 // Note that TST/TEQ don't set all the same flags that CMP does!
3992 defm TST : AI1_cmp_irs<0b1000, "tst",
3993 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
3994 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>, 1>;
3995 defm TEQ : AI1_cmp_irs<0b1001, "teq",
3996 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
3997 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>, 1>;
3999 // Pseudo i64 compares for some floating point compares.
4000 let usesCustomInserter = 1, isBranch = 1, isTerminator = 1,
4002 def BCCi64 : PseudoInst<(outs),
4003 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, brtarget:$dst),
4005 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, bb:$dst)]>;
4007 def BCCZi64 : PseudoInst<(outs),
4008 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, brtarget:$dst), IIC_Br,
4009 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, 0, 0, bb:$dst)]>;
4010 } // usesCustomInserter
4013 // Conditional moves
4014 // FIXME: should be able to write a pattern for ARMcmov, but can't use
4015 // a two-value operand where a dag node expects two operands. :(
4016 let neverHasSideEffects = 1 in {
4018 let isCommutable = 1, isSelect = 1 in
4019 def MOVCCr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$false, GPR:$Rm, pred:$p),
4021 [/*(set GPR:$Rd, (ARMcmov GPR:$false, GPR:$Rm, imm:$cc, CCR:$ccr))*/]>,
4022 RegConstraint<"$false = $Rd">;
4024 def MOVCCsi : ARMPseudoInst<(outs GPR:$Rd),
4025 (ins GPR:$false, so_reg_imm:$shift, pred:$p),
4027 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_imm:$shift,
4028 imm:$cc, CCR:$ccr))*/]>,
4029 RegConstraint<"$false = $Rd">;
4030 def MOVCCsr : ARMPseudoInst<(outs GPR:$Rd),
4031 (ins GPR:$false, so_reg_reg:$shift, pred:$p),
4033 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_reg:$shift,
4034 imm:$cc, CCR:$ccr))*/]>,
4035 RegConstraint<"$false = $Rd">;
4038 let isMoveImm = 1 in
4039 def MOVCCi16 : ARMPseudoInst<(outs GPR:$Rd),
4040 (ins GPR:$false, imm0_65535_expr:$imm, pred:$p),
4043 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>;
4045 let isMoveImm = 1 in
4046 def MOVCCi : ARMPseudoInst<(outs GPR:$Rd),
4047 (ins GPR:$false, so_imm:$imm, pred:$p),
4049 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_imm:$imm, imm:$cc, CCR:$ccr))*/]>,
4050 RegConstraint<"$false = $Rd">;
4052 // Two instruction predicate mov immediate.
4053 let isMoveImm = 1 in
4054 def MOVCCi32imm : ARMPseudoInst<(outs GPR:$Rd),
4055 (ins GPR:$false, i32imm:$src, pred:$p),
4056 8, IIC_iCMOVix2, []>, RegConstraint<"$false = $Rd">;
4058 let isMoveImm = 1 in
4059 def MVNCCi : ARMPseudoInst<(outs GPR:$Rd),
4060 (ins GPR:$false, so_imm:$imm, pred:$p),
4062 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_imm_not:$imm, imm:$cc, CCR:$ccr))*/]>,
4063 RegConstraint<"$false = $Rd">;
4065 } // neverHasSideEffects
4068 //===----------------------------------------------------------------------===//
4069 // Atomic operations intrinsics
4072 def MemBarrierOptOperand : AsmOperandClass {
4073 let Name = "MemBarrierOpt";
4074 let ParserMethod = "parseMemBarrierOptOperand";
4076 def memb_opt : Operand<i32> {
4077 let PrintMethod = "printMemBOption";
4078 let ParserMatchClass = MemBarrierOptOperand;
4079 let DecoderMethod = "DecodeMemBarrierOption";
4082 // memory barriers protect the atomic sequences
4083 let hasSideEffects = 1 in {
4084 def DMB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4085 "dmb", "\t$opt", [(ARMMemBarrier (i32 imm:$opt))]>,
4086 Requires<[IsARM, HasDB]> {
4088 let Inst{31-4} = 0xf57ff05;
4089 let Inst{3-0} = opt;
4093 def DSB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4094 "dsb", "\t$opt", []>,
4095 Requires<[IsARM, HasDB]> {
4097 let Inst{31-4} = 0xf57ff04;
4098 let Inst{3-0} = opt;
4101 // ISB has only full system option
4102 def ISB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4103 "isb", "\t$opt", []>,
4104 Requires<[IsARM, HasDB]> {
4106 let Inst{31-4} = 0xf57ff06;
4107 let Inst{3-0} = opt;
4110 // Pseudo instruction that combines movs + predicated rsbmi
4111 // to implement integer ABS
4112 let usesCustomInserter = 1, Defs = [CPSR] in
4113 def ABS : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$src), 8, NoItinerary, []>;
4115 let usesCustomInserter = 1 in {
4116 let Defs = [CPSR] in {
4117 def ATOMIC_LOAD_ADD_I8 : PseudoInst<
4118 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4119 [(set GPR:$dst, (atomic_load_add_8 GPR:$ptr, GPR:$incr))]>;
4120 def ATOMIC_LOAD_SUB_I8 : PseudoInst<
4121 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4122 [(set GPR:$dst, (atomic_load_sub_8 GPR:$ptr, GPR:$incr))]>;
4123 def ATOMIC_LOAD_AND_I8 : PseudoInst<
4124 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4125 [(set GPR:$dst, (atomic_load_and_8 GPR:$ptr, GPR:$incr))]>;
4126 def ATOMIC_LOAD_OR_I8 : PseudoInst<
4127 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4128 [(set GPR:$dst, (atomic_load_or_8 GPR:$ptr, GPR:$incr))]>;
4129 def ATOMIC_LOAD_XOR_I8 : PseudoInst<
4130 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4131 [(set GPR:$dst, (atomic_load_xor_8 GPR:$ptr, GPR:$incr))]>;
4132 def ATOMIC_LOAD_NAND_I8 : PseudoInst<
4133 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4134 [(set GPR:$dst, (atomic_load_nand_8 GPR:$ptr, GPR:$incr))]>;
4135 def ATOMIC_LOAD_MIN_I8 : PseudoInst<
4136 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4137 [(set GPR:$dst, (atomic_load_min_8 GPR:$ptr, GPR:$val))]>;
4138 def ATOMIC_LOAD_MAX_I8 : PseudoInst<
4139 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4140 [(set GPR:$dst, (atomic_load_max_8 GPR:$ptr, GPR:$val))]>;
4141 def ATOMIC_LOAD_UMIN_I8 : PseudoInst<
4142 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4143 [(set GPR:$dst, (atomic_load_umin_8 GPR:$ptr, GPR:$val))]>;
4144 def ATOMIC_LOAD_UMAX_I8 : PseudoInst<
4145 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4146 [(set GPR:$dst, (atomic_load_umax_8 GPR:$ptr, GPR:$val))]>;
4147 def ATOMIC_LOAD_ADD_I16 : PseudoInst<
4148 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4149 [(set GPR:$dst, (atomic_load_add_16 GPR:$ptr, GPR:$incr))]>;
4150 def ATOMIC_LOAD_SUB_I16 : PseudoInst<
4151 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4152 [(set GPR:$dst, (atomic_load_sub_16 GPR:$ptr, GPR:$incr))]>;
4153 def ATOMIC_LOAD_AND_I16 : PseudoInst<
4154 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4155 [(set GPR:$dst, (atomic_load_and_16 GPR:$ptr, GPR:$incr))]>;
4156 def ATOMIC_LOAD_OR_I16 : PseudoInst<
4157 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4158 [(set GPR:$dst, (atomic_load_or_16 GPR:$ptr, GPR:$incr))]>;
4159 def ATOMIC_LOAD_XOR_I16 : PseudoInst<
4160 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4161 [(set GPR:$dst, (atomic_load_xor_16 GPR:$ptr, GPR:$incr))]>;
4162 def ATOMIC_LOAD_NAND_I16 : PseudoInst<
4163 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4164 [(set GPR:$dst, (atomic_load_nand_16 GPR:$ptr, GPR:$incr))]>;
4165 def ATOMIC_LOAD_MIN_I16 : PseudoInst<
4166 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4167 [(set GPR:$dst, (atomic_load_min_16 GPR:$ptr, GPR:$val))]>;
4168 def ATOMIC_LOAD_MAX_I16 : PseudoInst<
4169 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4170 [(set GPR:$dst, (atomic_load_max_16 GPR:$ptr, GPR:$val))]>;
4171 def ATOMIC_LOAD_UMIN_I16 : PseudoInst<
4172 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4173 [(set GPR:$dst, (atomic_load_umin_16 GPR:$ptr, GPR:$val))]>;
4174 def ATOMIC_LOAD_UMAX_I16 : PseudoInst<
4175 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4176 [(set GPR:$dst, (atomic_load_umax_16 GPR:$ptr, GPR:$val))]>;
4177 def ATOMIC_LOAD_ADD_I32 : PseudoInst<
4178 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4179 [(set GPR:$dst, (atomic_load_add_32 GPR:$ptr, GPR:$incr))]>;
4180 def ATOMIC_LOAD_SUB_I32 : PseudoInst<
4181 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4182 [(set GPR:$dst, (atomic_load_sub_32 GPR:$ptr, GPR:$incr))]>;
4183 def ATOMIC_LOAD_AND_I32 : PseudoInst<
4184 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4185 [(set GPR:$dst, (atomic_load_and_32 GPR:$ptr, GPR:$incr))]>;
4186 def ATOMIC_LOAD_OR_I32 : PseudoInst<
4187 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4188 [(set GPR:$dst, (atomic_load_or_32 GPR:$ptr, GPR:$incr))]>;
4189 def ATOMIC_LOAD_XOR_I32 : PseudoInst<
4190 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4191 [(set GPR:$dst, (atomic_load_xor_32 GPR:$ptr, GPR:$incr))]>;
4192 def ATOMIC_LOAD_NAND_I32 : PseudoInst<
4193 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4194 [(set GPR:$dst, (atomic_load_nand_32 GPR:$ptr, GPR:$incr))]>;
4195 def ATOMIC_LOAD_MIN_I32 : PseudoInst<
4196 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4197 [(set GPR:$dst, (atomic_load_min_32 GPR:$ptr, GPR:$val))]>;
4198 def ATOMIC_LOAD_MAX_I32 : PseudoInst<
4199 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4200 [(set GPR:$dst, (atomic_load_max_32 GPR:$ptr, GPR:$val))]>;
4201 def ATOMIC_LOAD_UMIN_I32 : PseudoInst<
4202 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4203 [(set GPR:$dst, (atomic_load_umin_32 GPR:$ptr, GPR:$val))]>;
4204 def ATOMIC_LOAD_UMAX_I32 : PseudoInst<
4205 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4206 [(set GPR:$dst, (atomic_load_umax_32 GPR:$ptr, GPR:$val))]>;
4208 def ATOMIC_SWAP_I8 : PseudoInst<
4209 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
4210 [(set GPR:$dst, (atomic_swap_8 GPR:$ptr, GPR:$new))]>;
4211 def ATOMIC_SWAP_I16 : PseudoInst<
4212 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
4213 [(set GPR:$dst, (atomic_swap_16 GPR:$ptr, GPR:$new))]>;
4214 def ATOMIC_SWAP_I32 : PseudoInst<
4215 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
4216 [(set GPR:$dst, (atomic_swap_32 GPR:$ptr, GPR:$new))]>;
4218 def ATOMIC_CMP_SWAP_I8 : PseudoInst<
4219 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
4220 [(set GPR:$dst, (atomic_cmp_swap_8 GPR:$ptr, GPR:$old, GPR:$new))]>;
4221 def ATOMIC_CMP_SWAP_I16 : PseudoInst<
4222 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
4223 [(set GPR:$dst, (atomic_cmp_swap_16 GPR:$ptr, GPR:$old, GPR:$new))]>;
4224 def ATOMIC_CMP_SWAP_I32 : PseudoInst<
4225 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
4226 [(set GPR:$dst, (atomic_cmp_swap_32 GPR:$ptr, GPR:$old, GPR:$new))]>;
4230 let usesCustomInserter = 1 in {
4231 def COPY_STRUCT_BYVAL_I32 : PseudoInst<
4232 (outs), (ins GPR:$dst, GPR:$src, i32imm:$size, i32imm:$alignment),
4234 [(ARMcopystructbyval GPR:$dst, GPR:$src, imm:$size, imm:$alignment)]>;
4237 let mayLoad = 1 in {
4238 def LDREXB : AIldrex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4240 "ldrexb", "\t$Rt, $addr", []>;
4241 def LDREXH : AIldrex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4242 NoItinerary, "ldrexh", "\t$Rt, $addr", []>;
4243 def LDREX : AIldrex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4244 NoItinerary, "ldrex", "\t$Rt, $addr", []>;
4245 let hasExtraDefRegAllocReq = 1 in
4246 def LDREXD: AIldrex<0b01, (outs GPRPairOp:$Rt),(ins addr_offset_none:$addr),
4247 NoItinerary, "ldrexd", "\t$Rt, $addr", []> {
4248 let DecoderMethod = "DecodeDoubleRegLoad";
4252 let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
4253 def STREXB: AIstrex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4254 NoItinerary, "strexb", "\t$Rd, $Rt, $addr", []>;
4255 def STREXH: AIstrex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4256 NoItinerary, "strexh", "\t$Rd, $Rt, $addr", []>;
4257 def STREX : AIstrex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4258 NoItinerary, "strex", "\t$Rd, $Rt, $addr", []>;
4259 let hasExtraSrcRegAllocReq = 1 in
4260 def STREXD : AIstrex<0b01, (outs GPR:$Rd),
4261 (ins GPRPairOp:$Rt, addr_offset_none:$addr),
4262 NoItinerary, "strexd", "\t$Rd, $Rt, $addr", []> {
4263 let DecoderMethod = "DecodeDoubleRegStore";
4268 def CLREX : AXI<(outs), (ins), MiscFrm, NoItinerary, "clrex", []>,
4269 Requires<[IsARM, HasV7]> {
4270 let Inst{31-0} = 0b11110101011111111111000000011111;
4273 // SWP/SWPB are deprecated in V6/V7.
4274 let mayLoad = 1, mayStore = 1 in {
4275 def SWP : AIswp<0, (outs GPRnopc:$Rt),
4276 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swp", []>;
4277 def SWPB: AIswp<1, (outs GPRnopc:$Rt),
4278 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swpb", []>;
4281 //===----------------------------------------------------------------------===//
4282 // Coprocessor Instructions.
4285 def CDP : ABI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4286 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4287 NoItinerary, "cdp", "\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4288 [(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4289 imm:$CRm, imm:$opc2)]> {
4297 let Inst{3-0} = CRm;
4299 let Inst{7-5} = opc2;
4300 let Inst{11-8} = cop;
4301 let Inst{15-12} = CRd;
4302 let Inst{19-16} = CRn;
4303 let Inst{23-20} = opc1;
4306 def CDP2 : ABXI<0b1110, (outs), (ins pf_imm:$cop, imm0_15:$opc1,
4307 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4308 NoItinerary, "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4309 [(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4310 imm:$CRm, imm:$opc2)]> {
4311 let Inst{31-28} = 0b1111;
4319 let Inst{3-0} = CRm;
4321 let Inst{7-5} = opc2;
4322 let Inst{11-8} = cop;
4323 let Inst{15-12} = CRd;
4324 let Inst{19-16} = CRn;
4325 let Inst{23-20} = opc1;
4328 class ACI<dag oops, dag iops, string opc, string asm,
4329 IndexMode im = IndexModeNone>
4330 : I<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
4332 let Inst{27-25} = 0b110;
4334 class ACInoP<dag oops, dag iops, string opc, string asm,
4335 IndexMode im = IndexModeNone>
4336 : InoP<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
4338 let Inst{31-28} = 0b1111;
4339 let Inst{27-25} = 0b110;
4341 multiclass LdStCop<bit load, bit Dbit, string asm> {
4342 def _OFFSET : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4343 asm, "\t$cop, $CRd, $addr"> {
4347 let Inst{24} = 1; // P = 1
4348 let Inst{23} = addr{8};
4349 let Inst{22} = Dbit;
4350 let Inst{21} = 0; // W = 0
4351 let Inst{20} = load;
4352 let Inst{19-16} = addr{12-9};
4353 let Inst{15-12} = CRd;
4354 let Inst{11-8} = cop;
4355 let Inst{7-0} = addr{7-0};
4356 let DecoderMethod = "DecodeCopMemInstruction";
4358 def _PRE : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4359 asm, "\t$cop, $CRd, $addr!", IndexModePre> {
4363 let Inst{24} = 1; // P = 1
4364 let Inst{23} = addr{8};
4365 let Inst{22} = Dbit;
4366 let Inst{21} = 1; // W = 1
4367 let Inst{20} = load;
4368 let Inst{19-16} = addr{12-9};
4369 let Inst{15-12} = CRd;
4370 let Inst{11-8} = cop;
4371 let Inst{7-0} = addr{7-0};
4372 let DecoderMethod = "DecodeCopMemInstruction";
4374 def _POST: ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4375 postidx_imm8s4:$offset),
4376 asm, "\t$cop, $CRd, $addr, $offset", IndexModePost> {
4381 let Inst{24} = 0; // P = 0
4382 let Inst{23} = offset{8};
4383 let Inst{22} = Dbit;
4384 let Inst{21} = 1; // W = 1
4385 let Inst{20} = load;
4386 let Inst{19-16} = addr;
4387 let Inst{15-12} = CRd;
4388 let Inst{11-8} = cop;
4389 let Inst{7-0} = offset{7-0};
4390 let DecoderMethod = "DecodeCopMemInstruction";
4392 def _OPTION : ACI<(outs),
4393 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4394 coproc_option_imm:$option),
4395 asm, "\t$cop, $CRd, $addr, $option"> {
4400 let Inst{24} = 0; // P = 0
4401 let Inst{23} = 1; // U = 1
4402 let Inst{22} = Dbit;
4403 let Inst{21} = 0; // W = 0
4404 let Inst{20} = load;
4405 let Inst{19-16} = addr;
4406 let Inst{15-12} = CRd;
4407 let Inst{11-8} = cop;
4408 let Inst{7-0} = option;
4409 let DecoderMethod = "DecodeCopMemInstruction";
4412 multiclass LdSt2Cop<bit load, bit Dbit, string asm> {
4413 def _OFFSET : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4414 asm, "\t$cop, $CRd, $addr"> {
4418 let Inst{24} = 1; // P = 1
4419 let Inst{23} = addr{8};
4420 let Inst{22} = Dbit;
4421 let Inst{21} = 0; // W = 0
4422 let Inst{20} = load;
4423 let Inst{19-16} = addr{12-9};
4424 let Inst{15-12} = CRd;
4425 let Inst{11-8} = cop;
4426 let Inst{7-0} = addr{7-0};
4427 let DecoderMethod = "DecodeCopMemInstruction";
4429 def _PRE : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4430 asm, "\t$cop, $CRd, $addr!", IndexModePre> {
4434 let Inst{24} = 1; // P = 1
4435 let Inst{23} = addr{8};
4436 let Inst{22} = Dbit;
4437 let Inst{21} = 1; // W = 1
4438 let Inst{20} = load;
4439 let Inst{19-16} = addr{12-9};
4440 let Inst{15-12} = CRd;
4441 let Inst{11-8} = cop;
4442 let Inst{7-0} = addr{7-0};
4443 let DecoderMethod = "DecodeCopMemInstruction";
4445 def _POST: ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4446 postidx_imm8s4:$offset),
4447 asm, "\t$cop, $CRd, $addr, $offset", IndexModePost> {
4452 let Inst{24} = 0; // P = 0
4453 let Inst{23} = offset{8};
4454 let Inst{22} = Dbit;
4455 let Inst{21} = 1; // W = 1
4456 let Inst{20} = load;
4457 let Inst{19-16} = addr;
4458 let Inst{15-12} = CRd;
4459 let Inst{11-8} = cop;
4460 let Inst{7-0} = offset{7-0};
4461 let DecoderMethod = "DecodeCopMemInstruction";
4463 def _OPTION : ACInoP<(outs),
4464 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4465 coproc_option_imm:$option),
4466 asm, "\t$cop, $CRd, $addr, $option"> {
4471 let Inst{24} = 0; // P = 0
4472 let Inst{23} = 1; // U = 1
4473 let Inst{22} = Dbit;
4474 let Inst{21} = 0; // W = 0
4475 let Inst{20} = load;
4476 let Inst{19-16} = addr;
4477 let Inst{15-12} = CRd;
4478 let Inst{11-8} = cop;
4479 let Inst{7-0} = option;
4480 let DecoderMethod = "DecodeCopMemInstruction";
4484 defm LDC : LdStCop <1, 0, "ldc">;
4485 defm LDCL : LdStCop <1, 1, "ldcl">;
4486 defm STC : LdStCop <0, 0, "stc">;
4487 defm STCL : LdStCop <0, 1, "stcl">;
4488 defm LDC2 : LdSt2Cop<1, 0, "ldc2">;
4489 defm LDC2L : LdSt2Cop<1, 1, "ldc2l">;
4490 defm STC2 : LdSt2Cop<0, 0, "stc2">;
4491 defm STC2L : LdSt2Cop<0, 1, "stc2l">;
4493 //===----------------------------------------------------------------------===//
4494 // Move between coprocessor and ARM core register.
4497 class MovRCopro<string opc, bit direction, dag oops, dag iops,
4499 : ABI<0b1110, oops, iops, NoItinerary, opc,
4500 "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2", pattern> {
4501 let Inst{20} = direction;
4511 let Inst{15-12} = Rt;
4512 let Inst{11-8} = cop;
4513 let Inst{23-21} = opc1;
4514 let Inst{7-5} = opc2;
4515 let Inst{3-0} = CRm;
4516 let Inst{19-16} = CRn;
4519 def MCR : MovRCopro<"mcr", 0 /* from ARM core register to coprocessor */,
4521 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4522 c_imm:$CRm, imm0_7:$opc2),
4523 [(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
4524 imm:$CRm, imm:$opc2)]>;
4525 def : ARMInstAlias<"mcr${p} $cop, $opc1, $Rt, $CRn, $CRm",
4526 (MCR p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4527 c_imm:$CRm, 0, pred:$p)>;
4528 def MRC : MovRCopro<"mrc", 1 /* from coprocessor to ARM core register */,
4530 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
4532 def : ARMInstAlias<"mrc${p} $cop, $opc1, $Rt, $CRn, $CRm",
4533 (MRC GPR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
4534 c_imm:$CRm, 0, pred:$p)>;
4536 def : ARMPat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
4537 (MRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
4539 class MovRCopro2<string opc, bit direction, dag oops, dag iops,
4541 : ABXI<0b1110, oops, iops, NoItinerary,
4542 !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), pattern> {
4543 let Inst{31-28} = 0b1111;
4544 let Inst{20} = direction;
4554 let Inst{15-12} = Rt;
4555 let Inst{11-8} = cop;
4556 let Inst{23-21} = opc1;
4557 let Inst{7-5} = opc2;
4558 let Inst{3-0} = CRm;
4559 let Inst{19-16} = CRn;
4562 def MCR2 : MovRCopro2<"mcr2", 0 /* from ARM core register to coprocessor */,
4564 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4565 c_imm:$CRm, imm0_7:$opc2),
4566 [(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
4567 imm:$CRm, imm:$opc2)]>;
4568 def : ARMInstAlias<"mcr2$ $cop, $opc1, $Rt, $CRn, $CRm",
4569 (MCR2 p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4571 def MRC2 : MovRCopro2<"mrc2", 1 /* from coprocessor to ARM core register */,
4573 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
4575 def : ARMInstAlias<"mrc2$ $cop, $opc1, $Rt, $CRn, $CRm",
4576 (MRC2 GPR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
4579 def : ARMV5TPat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn,
4580 imm:$CRm, imm:$opc2),
4581 (MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
4583 class MovRRCopro<string opc, bit direction, list<dag> pattern = []>
4584 : ABI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4585 GPRnopc:$Rt, GPRnopc:$Rt2, c_imm:$CRm),
4586 NoItinerary, opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm", pattern> {
4587 let Inst{23-21} = 0b010;
4588 let Inst{20} = direction;
4596 let Inst{15-12} = Rt;
4597 let Inst{19-16} = Rt2;
4598 let Inst{11-8} = cop;
4599 let Inst{7-4} = opc1;
4600 let Inst{3-0} = CRm;
4603 def MCRR : MovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */,
4604 [(int_arm_mcrr imm:$cop, imm:$opc1, GPRnopc:$Rt,
4605 GPRnopc:$Rt2, imm:$CRm)]>;
4606 def MRRC : MovRRCopro<"mrrc", 1 /* from coprocessor to ARM core register */>;
4608 class MovRRCopro2<string opc, bit direction, list<dag> pattern = []>
4609 : ABXI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4610 GPRnopc:$Rt, GPRnopc:$Rt2, c_imm:$CRm), NoItinerary,
4611 !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern> {
4612 let Inst{31-28} = 0b1111;
4613 let Inst{23-21} = 0b010;
4614 let Inst{20} = direction;
4622 let Inst{15-12} = Rt;
4623 let Inst{19-16} = Rt2;
4624 let Inst{11-8} = cop;
4625 let Inst{7-4} = opc1;
4626 let Inst{3-0} = CRm;
4628 let DecoderMethod = "DecodeMRRC2";
4631 def MCRR2 : MovRRCopro2<"mcrr2", 0 /* from ARM core register to coprocessor */,
4632 [(int_arm_mcrr2 imm:$cop, imm:$opc1, GPRnopc:$Rt,
4633 GPRnopc:$Rt2, imm:$CRm)]>;
4634 def MRRC2 : MovRRCopro2<"mrrc2", 1 /* from coprocessor to ARM core register */>;
4636 //===----------------------------------------------------------------------===//
4637 // Move between special register and ARM core register
4640 // Move to ARM core register from Special Register
4641 def MRS : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
4642 "mrs", "\t$Rd, apsr", []> {
4644 let Inst{23-16} = 0b00001111;
4645 let Unpredictable{19-17} = 0b111;
4647 let Inst{15-12} = Rd;
4649 let Inst{11-0} = 0b000000000000;
4650 let Unpredictable{11-0} = 0b110100001111;
4653 def : InstAlias<"mrs${p} $Rd, cpsr", (MRS GPRnopc:$Rd, pred:$p)>,
4656 // The MRSsys instruction is the MRS instruction from the ARM ARM,
4657 // section B9.3.9, with the R bit set to 1.
4658 def MRSsys : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
4659 "mrs", "\t$Rd, spsr", []> {
4661 let Inst{23-16} = 0b01001111;
4662 let Unpredictable{19-16} = 0b1111;
4664 let Inst{15-12} = Rd;
4666 let Inst{11-0} = 0b000000000000;
4667 let Unpredictable{11-0} = 0b110100001111;
4670 // Move from ARM core register to Special Register
4672 // No need to have both system and application versions, the encodings are the
4673 // same and the assembly parser has no way to distinguish between them. The mask
4674 // operand contains the special register (R Bit) in bit 4 and bits 3-0 contains
4675 // the mask with the fields to be accessed in the special register.
4676 def MSR : ABI<0b0001, (outs), (ins msr_mask:$mask, GPR:$Rn), NoItinerary,
4677 "msr", "\t$mask, $Rn", []> {
4682 let Inst{22} = mask{4}; // R bit
4683 let Inst{21-20} = 0b10;
4684 let Inst{19-16} = mask{3-0};
4685 let Inst{15-12} = 0b1111;
4686 let Inst{11-4} = 0b00000000;
4690 def MSRi : ABI<0b0011, (outs), (ins msr_mask:$mask, so_imm:$a), NoItinerary,
4691 "msr", "\t$mask, $a", []> {
4696 let Inst{22} = mask{4}; // R bit
4697 let Inst{21-20} = 0b10;
4698 let Inst{19-16} = mask{3-0};
4699 let Inst{15-12} = 0b1111;
4703 //===----------------------------------------------------------------------===//
4707 // __aeabi_read_tp preserves the registers r1-r3.
4708 // This is a pseudo inst so that we can get the encoding right,
4709 // complete with fixup for the aeabi_read_tp function.
4711 Defs = [R0, R12, LR, CPSR], Uses = [SP] in {
4712 def TPsoft : PseudoInst<(outs), (ins), IIC_Br,
4713 [(set R0, ARMthread_pointer)]>;
4716 //===----------------------------------------------------------------------===//
4717 // SJLJ Exception handling intrinsics
4718 // eh_sjlj_setjmp() is an instruction sequence to store the return
4719 // address and save #0 in R0 for the non-longjmp case.
4720 // Since by its nature we may be coming from some other function to get
4721 // here, and we're using the stack frame for the containing function to
4722 // save/restore registers, we can't keep anything live in regs across
4723 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
4724 // when we get here from a longjmp(). We force everything out of registers
4725 // except for our own input by listing the relevant registers in Defs. By
4726 // doing so, we also cause the prologue/epilogue code to actively preserve
4727 // all of the callee-saved resgisters, which is exactly what we want.
4728 // A constant value is passed in $val, and we use the location as a scratch.
4730 // These are pseudo-instructions and are lowered to individual MC-insts, so
4731 // no encoding information is necessary.
4733 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
4734 Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15 ],
4735 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
4736 def Int_eh_sjlj_setjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
4738 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
4739 Requires<[IsARM, HasVFP2]>;
4743 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
4744 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
4745 def Int_eh_sjlj_setjmp_nofp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
4747 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
4748 Requires<[IsARM, NoVFP]>;
4751 // FIXME: Non-IOS version(s)
4752 let isBarrier = 1, hasSideEffects = 1, isTerminator = 1,
4753 Defs = [ R7, LR, SP ] in {
4754 def Int_eh_sjlj_longjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$scratch),
4756 [(ARMeh_sjlj_longjmp GPR:$src, GPR:$scratch)]>,
4757 Requires<[IsARM, IsIOS]>;
4760 // eh.sjlj.dispatchsetup pseudo-instruction.
4761 // This pseudo is used for both ARM and Thumb. Any differences are handled when
4762 // the pseudo is expanded (which happens before any passes that need the
4763 // instruction size).
4764 let isBarrier = 1 in
4765 def Int_eh_sjlj_dispatchsetup : PseudoInst<(outs), (ins), NoItinerary, []>;
4768 //===----------------------------------------------------------------------===//
4769 // Non-Instruction Patterns
4772 // ARMv4 indirect branch using (MOVr PC, dst)
4773 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in
4774 def MOVPCRX : ARMPseudoExpand<(outs), (ins GPR:$dst),
4775 4, IIC_Br, [(brind GPR:$dst)],
4776 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>,
4777 Requires<[IsARM, NoV4T]>;
4779 // Large immediate handling.
4781 // 32-bit immediate using two piece so_imms or movw + movt.
4782 // This is a single pseudo instruction, the benefit is that it can be remat'd
4783 // as a single unit instead of having to handle reg inputs.
4784 // FIXME: Remove this when we can do generalized remat.
4785 let isReMaterializable = 1, isMoveImm = 1 in
4786 def MOVi32imm : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
4787 [(set GPR:$dst, (arm_i32imm:$src))]>,
4790 // Pseudo instruction that combines movw + movt + add pc (if PIC).
4791 // It also makes it possible to rematerialize the instructions.
4792 // FIXME: Remove this when we can do generalized remat and when machine licm
4793 // can properly the instructions.
4794 let isReMaterializable = 1 in {
4795 def MOV_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
4797 [(set GPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>,
4798 Requires<[IsARM, UseMovt]>;
4800 def MOV_ga_dyn : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
4802 [(set GPR:$dst, (ARMWrapperDYN tglobaladdr:$addr))]>,
4803 Requires<[IsARM, UseMovt]>;
4805 let AddedComplexity = 10 in
4806 def MOV_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
4808 [(set GPR:$dst, (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
4809 Requires<[IsARM, UseMovt]>;
4810 } // isReMaterializable
4812 // ConstantPool, GlobalAddress, and JumpTable
4813 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (LEApcrel tglobaladdr :$dst)>,
4814 Requires<[IsARM, DontUseMovt]>;
4815 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
4816 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
4817 Requires<[IsARM, UseMovt]>;
4818 def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
4819 (LEApcrelJT tjumptable:$dst, imm:$id)>;
4821 // TODO: add,sub,and, 3-instr forms?
4823 // Tail calls. These patterns also apply to Thumb mode.
4824 def : Pat<(ARMtcret tcGPR:$dst), (TCRETURNri tcGPR:$dst)>;
4825 def : Pat<(ARMtcret (i32 tglobaladdr:$dst)), (TCRETURNdi texternalsym:$dst)>;
4826 def : Pat<(ARMtcret (i32 texternalsym:$dst)), (TCRETURNdi texternalsym:$dst)>;
4829 def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>;
4830 def : ARMPat<(ARMcall_nolink texternalsym:$func),
4831 (BMOVPCB_CALL texternalsym:$func)>;
4833 // zextload i1 -> zextload i8
4834 def : ARMPat<(zextloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
4835 def : ARMPat<(zextloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
4837 // extload -> zextload
4838 def : ARMPat<(extloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
4839 def : ARMPat<(extloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
4840 def : ARMPat<(extloadi8 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
4841 def : ARMPat<(extloadi8 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
4843 def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
4845 def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
4846 def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
4849 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4850 (sra (shl GPR:$b, (i32 16)), (i32 16))),
4851 (SMULBB GPR:$a, GPR:$b)>;
4852 def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
4853 (SMULBB GPR:$a, GPR:$b)>;
4854 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4855 (sra GPR:$b, (i32 16))),
4856 (SMULBT GPR:$a, GPR:$b)>;
4857 def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, (i32 16))),
4858 (SMULBT GPR:$a, GPR:$b)>;
4859 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)),
4860 (sra (shl GPR:$b, (i32 16)), (i32 16))),
4861 (SMULTB GPR:$a, GPR:$b)>;
4862 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), sext_16_node:$b),
4863 (SMULTB GPR:$a, GPR:$b)>;
4864 def : ARMV5TEPat<(sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
4866 (SMULWB GPR:$a, GPR:$b)>;
4867 def : ARMV5TEPat<(sra (mul GPR:$a, sext_16_node:$b), (i32 16)),
4868 (SMULWB GPR:$a, GPR:$b)>;
4870 def : ARMV5MOPat<(add GPR:$acc,
4871 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4872 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
4873 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
4874 def : ARMV5MOPat<(add GPR:$acc,
4875 (mul sext_16_node:$a, sext_16_node:$b)),
4876 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
4877 def : ARMV5MOPat<(add GPR:$acc,
4878 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4879 (sra GPR:$b, (i32 16)))),
4880 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
4881 def : ARMV5MOPat<(add GPR:$acc,
4882 (mul sext_16_node:$a, (sra GPR:$b, (i32 16)))),
4883 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
4884 def : ARMV5MOPat<(add GPR:$acc,
4885 (mul (sra GPR:$a, (i32 16)),
4886 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
4887 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
4888 def : ARMV5MOPat<(add GPR:$acc,
4889 (mul (sra GPR:$a, (i32 16)), sext_16_node:$b)),
4890 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
4891 def : ARMV5MOPat<(add GPR:$acc,
4892 (sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
4894 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
4895 def : ARMV5MOPat<(add GPR:$acc,
4896 (sra (mul GPR:$a, sext_16_node:$b), (i32 16))),
4897 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
4900 // Pre-v7 uses MCR for synchronization barriers.
4901 def : ARMPat<(ARMMemBarrierMCR GPR:$zero), (MCR 15, 0, GPR:$zero, 7, 10, 5)>,
4902 Requires<[IsARM, HasV6]>;
4904 // SXT/UXT with no rotate
4905 let AddedComplexity = 16 in {
4906 def : ARMV6Pat<(and GPR:$Src, 0x000000FF), (UXTB GPR:$Src, 0)>;
4907 def : ARMV6Pat<(and GPR:$Src, 0x0000FFFF), (UXTH GPR:$Src, 0)>;
4908 def : ARMV6Pat<(and GPR:$Src, 0x00FF00FF), (UXTB16 GPR:$Src, 0)>;
4909 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0x00FF)),
4910 (UXTAB GPR:$Rn, GPR:$Rm, 0)>;
4911 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0xFFFF)),
4912 (UXTAH GPR:$Rn, GPR:$Rm, 0)>;
4915 def : ARMV6Pat<(sext_inreg GPR:$Src, i8), (SXTB GPR:$Src, 0)>;
4916 def : ARMV6Pat<(sext_inreg GPR:$Src, i16), (SXTH GPR:$Src, 0)>;
4918 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i8)),
4919 (SXTAB GPR:$Rn, GPRnopc:$Rm, 0)>;
4920 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i16)),
4921 (SXTAH GPR:$Rn, GPRnopc:$Rm, 0)>;
4923 // Atomic load/store patterns
4924 def : ARMPat<(atomic_load_8 ldst_so_reg:$src),
4925 (LDRBrs ldst_so_reg:$src)>;
4926 def : ARMPat<(atomic_load_8 addrmode_imm12:$src),
4927 (LDRBi12 addrmode_imm12:$src)>;
4928 def : ARMPat<(atomic_load_16 addrmode3:$src),
4929 (LDRH addrmode3:$src)>;
4930 def : ARMPat<(atomic_load_32 ldst_so_reg:$src),
4931 (LDRrs ldst_so_reg:$src)>;
4932 def : ARMPat<(atomic_load_32 addrmode_imm12:$src),
4933 (LDRi12 addrmode_imm12:$src)>;
4934 def : ARMPat<(atomic_store_8 ldst_so_reg:$ptr, GPR:$val),
4935 (STRBrs GPR:$val, ldst_so_reg:$ptr)>;
4936 def : ARMPat<(atomic_store_8 addrmode_imm12:$ptr, GPR:$val),
4937 (STRBi12 GPR:$val, addrmode_imm12:$ptr)>;
4938 def : ARMPat<(atomic_store_16 addrmode3:$ptr, GPR:$val),
4939 (STRH GPR:$val, addrmode3:$ptr)>;
4940 def : ARMPat<(atomic_store_32 ldst_so_reg:$ptr, GPR:$val),
4941 (STRrs GPR:$val, ldst_so_reg:$ptr)>;
4942 def : ARMPat<(atomic_store_32 addrmode_imm12:$ptr, GPR:$val),
4943 (STRi12 GPR:$val, addrmode_imm12:$ptr)>;
4946 //===----------------------------------------------------------------------===//
4950 include "ARMInstrThumb.td"
4952 //===----------------------------------------------------------------------===//
4956 include "ARMInstrThumb2.td"
4958 //===----------------------------------------------------------------------===//
4959 // Floating Point Support
4962 include "ARMInstrVFP.td"
4964 //===----------------------------------------------------------------------===//
4965 // Advanced SIMD (NEON) Support
4968 include "ARMInstrNEON.td"
4970 //===----------------------------------------------------------------------===//
4971 // Assembler aliases
4975 def : InstAlias<"dmb", (DMB 0xf)>, Requires<[IsARM, HasDB]>;
4976 def : InstAlias<"dsb", (DSB 0xf)>, Requires<[IsARM, HasDB]>;
4977 def : InstAlias<"isb", (ISB 0xf)>, Requires<[IsARM, HasDB]>;
4979 // System instructions
4980 def : MnemonicAlias<"swi", "svc">;
4982 // Load / Store Multiple
4983 def : MnemonicAlias<"ldmfd", "ldm">;
4984 def : MnemonicAlias<"ldmia", "ldm">;
4985 def : MnemonicAlias<"ldmea", "ldmdb">;
4986 def : MnemonicAlias<"stmfd", "stmdb">;
4987 def : MnemonicAlias<"stmia", "stm">;
4988 def : MnemonicAlias<"stmea", "stm">;
4990 // PKHBT/PKHTB with default shift amount. PKHTB is equivalent to PKHBT when the
4991 // shift amount is zero (i.e., unspecified).
4992 def : InstAlias<"pkhbt${p} $Rd, $Rn, $Rm",
4993 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
4994 Requires<[IsARM, HasV6]>;
4995 def : InstAlias<"pkhtb${p} $Rd, $Rn, $Rm",
4996 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
4997 Requires<[IsARM, HasV6]>;
4999 // PUSH/POP aliases for STM/LDM
5000 def : ARMInstAlias<"push${p} $regs", (STMDB_UPD SP, pred:$p, reglist:$regs)>;
5001 def : ARMInstAlias<"pop${p} $regs", (LDMIA_UPD SP, pred:$p, reglist:$regs)>;
5003 // SSAT/USAT optional shift operand.
5004 def : ARMInstAlias<"ssat${p} $Rd, $sat_imm, $Rn",
5005 (SSAT GPRnopc:$Rd, imm1_32:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5006 def : ARMInstAlias<"usat${p} $Rd, $sat_imm, $Rn",
5007 (USAT GPRnopc:$Rd, imm0_31:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5010 // Extend instruction optional rotate operand.
5011 def : ARMInstAlias<"sxtab${p} $Rd, $Rn, $Rm",
5012 (SXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5013 def : ARMInstAlias<"sxtah${p} $Rd, $Rn, $Rm",
5014 (SXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5015 def : ARMInstAlias<"sxtab16${p} $Rd, $Rn, $Rm",
5016 (SXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5017 def : ARMInstAlias<"sxtb${p} $Rd, $Rm",
5018 (SXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5019 def : ARMInstAlias<"sxtb16${p} $Rd, $Rm",
5020 (SXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5021 def : ARMInstAlias<"sxth${p} $Rd, $Rm",
5022 (SXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5024 def : ARMInstAlias<"uxtab${p} $Rd, $Rn, $Rm",
5025 (UXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5026 def : ARMInstAlias<"uxtah${p} $Rd, $Rn, $Rm",
5027 (UXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5028 def : ARMInstAlias<"uxtab16${p} $Rd, $Rn, $Rm",
5029 (UXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5030 def : ARMInstAlias<"uxtb${p} $Rd, $Rm",
5031 (UXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5032 def : ARMInstAlias<"uxtb16${p} $Rd, $Rm",
5033 (UXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5034 def : ARMInstAlias<"uxth${p} $Rd, $Rm",
5035 (UXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5039 def : MnemonicAlias<"rfefa", "rfeda">;
5040 def : MnemonicAlias<"rfeea", "rfedb">;
5041 def : MnemonicAlias<"rfefd", "rfeia">;
5042 def : MnemonicAlias<"rfeed", "rfeib">;
5043 def : MnemonicAlias<"rfe", "rfeia">;
5046 def : MnemonicAlias<"srsfa", "srsda">;
5047 def : MnemonicAlias<"srsea", "srsdb">;
5048 def : MnemonicAlias<"srsfd", "srsia">;
5049 def : MnemonicAlias<"srsed", "srsib">;
5050 def : MnemonicAlias<"srs", "srsia">;
5053 def : MnemonicAlias<"qsubaddx", "qsax">;
5055 def : MnemonicAlias<"saddsubx", "sasx">;
5056 // SHASX == SHADDSUBX
5057 def : MnemonicAlias<"shaddsubx", "shasx">;
5058 // SHSAX == SHSUBADDX
5059 def : MnemonicAlias<"shsubaddx", "shsax">;
5061 def : MnemonicAlias<"ssubaddx", "ssax">;
5063 def : MnemonicAlias<"uaddsubx", "uasx">;
5064 // UHASX == UHADDSUBX
5065 def : MnemonicAlias<"uhaddsubx", "uhasx">;
5066 // UHSAX == UHSUBADDX
5067 def : MnemonicAlias<"uhsubaddx", "uhsax">;
5068 // UQASX == UQADDSUBX
5069 def : MnemonicAlias<"uqaddsubx", "uqasx">;
5070 // UQSAX == UQSUBADDX
5071 def : MnemonicAlias<"uqsubaddx", "uqsax">;
5073 def : MnemonicAlias<"usubaddx", "usax">;
5075 // "mov Rd, so_imm_not" can be handled via "mvn" in assembly, just like
5077 def : ARMInstAlias<"mov${s}${p} $Rd, $imm",
5078 (MVNi rGPR:$Rd, so_imm_not:$imm, pred:$p, cc_out:$s)>;
5079 def : ARMInstAlias<"mvn${s}${p} $Rd, $imm",
5080 (MOVi rGPR:$Rd, so_imm_not:$imm, pred:$p, cc_out:$s)>;
5081 // Same for AND <--> BIC
5082 def : ARMInstAlias<"bic${s}${p} $Rd, $Rn, $imm",
5083 (ANDri rGPR:$Rd, rGPR:$Rn, so_imm_not:$imm,
5084 pred:$p, cc_out:$s)>;
5085 def : ARMInstAlias<"bic${s}${p} $Rdn, $imm",
5086 (ANDri rGPR:$Rdn, rGPR:$Rdn, so_imm_not:$imm,
5087 pred:$p, cc_out:$s)>;
5088 def : ARMInstAlias<"and${s}${p} $Rd, $Rn, $imm",
5089 (BICri rGPR:$Rd, rGPR:$Rn, so_imm_not:$imm,
5090 pred:$p, cc_out:$s)>;
5091 def : ARMInstAlias<"and${s}${p} $Rdn, $imm",
5092 (BICri rGPR:$Rdn, rGPR:$Rdn, so_imm_not:$imm,
5093 pred:$p, cc_out:$s)>;
5095 // Likewise, "add Rd, so_imm_neg" -> sub
5096 def : ARMInstAlias<"add${s}${p} $Rd, $Rn, $imm",
5097 (SUBri GPR:$Rd, GPR:$Rn, so_imm_neg:$imm, pred:$p, cc_out:$s)>;
5098 def : ARMInstAlias<"add${s}${p} $Rd, $imm",
5099 (SUBri GPR:$Rd, GPR:$Rd, so_imm_neg:$imm, pred:$p, cc_out:$s)>;
5100 // Same for CMP <--> CMN via so_imm_neg
5101 def : ARMInstAlias<"cmp${p} $Rd, $imm",
5102 (CMNri rGPR:$Rd, so_imm_neg:$imm, pred:$p)>;
5103 def : ARMInstAlias<"cmn${p} $Rd, $imm",
5104 (CMPri rGPR:$Rd, so_imm_neg:$imm, pred:$p)>;
5106 // The shifter forms of the MOV instruction are aliased to the ASR, LSL,
5107 // LSR, ROR, and RRX instructions.
5108 // FIXME: We need C++ parser hooks to map the alias to the MOV
5109 // encoding. It seems we should be able to do that sort of thing
5110 // in tblgen, but it could get ugly.
5111 let TwoOperandAliasConstraint = "$Rm = $Rd" in {
5112 def ASRi : ARMAsmPseudo<"asr${s}${p} $Rd, $Rm, $imm",
5113 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
5115 def LSRi : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rm, $imm",
5116 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
5118 def LSLi : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rm, $imm",
5119 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
5121 def RORi : ARMAsmPseudo<"ror${s}${p} $Rd, $Rm, $imm",
5122 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
5125 def RRXi : ARMAsmPseudo<"rrx${s}${p} $Rd, $Rm",
5126 (ins GPRnopc:$Rd, GPRnopc:$Rm, pred:$p, cc_out:$s)>;
5127 let TwoOperandAliasConstraint = "$Rn = $Rd" in {
5128 def ASRr : ARMAsmPseudo<"asr${s}${p} $Rd, $Rn, $Rm",
5129 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5131 def LSRr : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rn, $Rm",
5132 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5134 def LSLr : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rn, $Rm",
5135 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5137 def RORr : ARMAsmPseudo<"ror${s}${p} $Rd, $Rn, $Rm",
5138 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5142 // "neg" is and alias for "rsb rd, rn, #0"
5143 def : ARMInstAlias<"neg${s}${p} $Rd, $Rm",
5144 (RSBri GPR:$Rd, GPR:$Rm, 0, pred:$p, cc_out:$s)>;
5146 // Pre-v6, 'mov r0, r0' was used as a NOP encoding.
5147 def : InstAlias<"nop${p}", (MOVr R0, R0, pred:$p, zero_reg)>,
5148 Requires<[IsARM, NoV6]>;
5150 // UMULL/SMULL are available on all arches, but the instruction definitions
5151 // need difference constraints pre-v6. Use these aliases for the assembly
5152 // parsing on pre-v6.
5153 def : InstAlias<"smull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5154 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5155 Requires<[IsARM, NoV6]>;
5156 def : InstAlias<"umull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5157 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5158 Requires<[IsARM, NoV6]>;
5160 // 'it' blocks in ARM mode just validate the predicates. The IT itself
5162 def ITasm : ARMAsmPseudo<"it$mask $cc", (ins it_pred:$cc, it_mask:$mask)>;