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 ARMWrapper : SDNode<"ARMISD::Wrapper", SDTIntUnaryOp>;
88 def ARMWrapperDYN : SDNode<"ARMISD::WrapperDYN", SDTIntUnaryOp>;
89 def ARMWrapperPIC : SDNode<"ARMISD::WrapperPIC", SDTIntUnaryOp>;
90 def ARMWrapperJT : SDNode<"ARMISD::WrapperJT", SDTIntBinOp>;
92 def ARMcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_ARMCallSeqStart,
93 [SDNPHasChain, SDNPOutGlue]>;
94 def ARMcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_ARMCallSeqEnd,
95 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
96 def ARMcopystructbyval : SDNode<"ARMISD::COPY_STRUCT_BYVAL" ,
98 [SDNPHasChain, SDNPInGlue, SDNPOutGlue,
99 SDNPMayStore, SDNPMayLoad]>;
101 def ARMcall : SDNode<"ARMISD::CALL", SDT_ARMcall,
102 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
104 def ARMcall_pred : SDNode<"ARMISD::CALL_PRED", SDT_ARMcall,
105 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
107 def ARMcall_nolink : SDNode<"ARMISD::CALL_NOLINK", SDT_ARMcall,
108 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
111 def ARMretflag : SDNode<"ARMISD::RET_FLAG", SDTNone,
112 [SDNPHasChain, SDNPOptInGlue]>;
114 def ARMcmov : SDNode<"ARMISD::CMOV", SDT_ARMCMov,
117 def ARMbrcond : SDNode<"ARMISD::BRCOND", SDT_ARMBrcond,
118 [SDNPHasChain, SDNPInGlue, SDNPOutGlue]>;
120 def ARMbrjt : SDNode<"ARMISD::BR_JT", SDT_ARMBrJT,
122 def ARMbr2jt : SDNode<"ARMISD::BR2_JT", SDT_ARMBr2JT,
125 def ARMBcci64 : SDNode<"ARMISD::BCC_i64", SDT_ARMBCC_i64,
128 def ARMcmp : SDNode<"ARMISD::CMP", SDT_ARMCmp,
131 def ARMcmn : SDNode<"ARMISD::CMN", SDT_ARMCmp,
134 def ARMcmpZ : SDNode<"ARMISD::CMPZ", SDT_ARMCmp,
135 [SDNPOutGlue, SDNPCommutative]>;
137 def ARMpic_add : SDNode<"ARMISD::PIC_ADD", SDT_ARMPICAdd>;
139 def ARMsrl_flag : SDNode<"ARMISD::SRL_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
140 def ARMsra_flag : SDNode<"ARMISD::SRA_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
141 def ARMrrx : SDNode<"ARMISD::RRX" , SDTIntUnaryOp, [SDNPInGlue ]>;
143 def ARMaddc : SDNode<"ARMISD::ADDC", SDTBinaryArithWithFlags,
145 def ARMsubc : SDNode<"ARMISD::SUBC", SDTBinaryArithWithFlags>;
146 def ARMadde : SDNode<"ARMISD::ADDE", SDTBinaryArithWithFlagsInOut>;
147 def ARMsube : SDNode<"ARMISD::SUBE", SDTBinaryArithWithFlagsInOut>;
149 def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>;
150 def ARMeh_sjlj_setjmp: SDNode<"ARMISD::EH_SJLJ_SETJMP",
151 SDT_ARMEH_SJLJ_Setjmp, [SDNPHasChain]>;
152 def ARMeh_sjlj_longjmp: SDNode<"ARMISD::EH_SJLJ_LONGJMP",
153 SDT_ARMEH_SJLJ_Longjmp, [SDNPHasChain]>;
155 def ARMMemBarrier : SDNode<"ARMISD::MEMBARRIER", SDT_ARMMEMBARRIER,
157 def ARMMemBarrierMCR : SDNode<"ARMISD::MEMBARRIER_MCR", SDT_ARMMEMBARRIER,
159 def ARMPreload : SDNode<"ARMISD::PRELOAD", SDT_ARMPREFETCH,
160 [SDNPHasChain, SDNPMayLoad, SDNPMayStore]>;
162 def ARMrbit : SDNode<"ARMISD::RBIT", SDTIntUnaryOp>;
164 def ARMtcret : SDNode<"ARMISD::TC_RETURN", SDT_ARMTCRET,
165 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
168 def ARMbfi : SDNode<"ARMISD::BFI", SDT_ARMBFI>;
170 //===----------------------------------------------------------------------===//
171 // ARM Instruction Predicate Definitions.
173 def HasV4T : Predicate<"Subtarget->hasV4TOps()">,
174 AssemblerPredicate<"HasV4TOps", "armv4t">;
175 def NoV4T : Predicate<"!Subtarget->hasV4TOps()">;
176 def HasV5T : Predicate<"Subtarget->hasV5TOps()">;
177 def HasV5TE : Predicate<"Subtarget->hasV5TEOps()">,
178 AssemblerPredicate<"HasV5TEOps", "armv5te">;
179 def HasV6 : Predicate<"Subtarget->hasV6Ops()">,
180 AssemblerPredicate<"HasV6Ops", "armv6">;
181 def NoV6 : Predicate<"!Subtarget->hasV6Ops()">;
182 def HasV6T2 : Predicate<"Subtarget->hasV6T2Ops()">,
183 AssemblerPredicate<"HasV6T2Ops", "armv6t2">;
184 def NoV6T2 : Predicate<"!Subtarget->hasV6T2Ops()">;
185 def HasV7 : Predicate<"Subtarget->hasV7Ops()">,
186 AssemblerPredicate<"HasV7Ops", "armv7">;
187 def NoVFP : Predicate<"!Subtarget->hasVFP2()">;
188 def HasVFP2 : Predicate<"Subtarget->hasVFP2()">,
189 AssemblerPredicate<"FeatureVFP2", "VFP2">;
190 def HasVFP3 : Predicate<"Subtarget->hasVFP3()">,
191 AssemblerPredicate<"FeatureVFP3", "VFP3">;
192 def HasVFP4 : Predicate<"Subtarget->hasVFP4()">,
193 AssemblerPredicate<"FeatureVFP4", "VFP4">;
194 def HasNEON : Predicate<"Subtarget->hasNEON()">,
195 AssemblerPredicate<"FeatureNEON", "NEON">;
196 def HasFP16 : Predicate<"Subtarget->hasFP16()">,
197 AssemblerPredicate<"FeatureFP16","half-float">;
198 def HasDivide : Predicate<"Subtarget->hasDivide()">,
199 AssemblerPredicate<"FeatureHWDiv", "divide">;
200 def HasT2ExtractPack : Predicate<"Subtarget->hasT2ExtractPack()">,
201 AssemblerPredicate<"FeatureT2XtPk",
203 def HasThumb2DSP : Predicate<"Subtarget->hasThumb2DSP()">,
204 AssemblerPredicate<"FeatureDSPThumb2",
206 def HasDB : Predicate<"Subtarget->hasDataBarrier()">,
207 AssemblerPredicate<"FeatureDB",
209 def HasMP : Predicate<"Subtarget->hasMPExtension()">,
210 AssemblerPredicate<"FeatureMP",
212 def UseNEONForFP : Predicate<"Subtarget->useNEONForSinglePrecisionFP()">;
213 def DontUseNEONForFP : Predicate<"!Subtarget->useNEONForSinglePrecisionFP()">;
214 def IsThumb : Predicate<"Subtarget->isThumb()">,
215 AssemblerPredicate<"ModeThumb", "thumb">;
216 def IsThumb1Only : Predicate<"Subtarget->isThumb1Only()">;
217 def IsThumb2 : Predicate<"Subtarget->isThumb2()">,
218 AssemblerPredicate<"ModeThumb,FeatureThumb2",
220 def IsMClass : Predicate<"Subtarget->isMClass()">,
221 AssemblerPredicate<"FeatureMClass", "armv7m">;
222 def IsARClass : Predicate<"!Subtarget->isMClass()">,
223 AssemblerPredicate<"!FeatureMClass",
225 def IsARM : Predicate<"!Subtarget->isThumb()">,
226 AssemblerPredicate<"!ModeThumb", "arm-mode">;
227 def IsIOS : Predicate<"Subtarget->isTargetIOS()">;
228 def IsNotIOS : Predicate<"!Subtarget->isTargetIOS()">;
229 def IsNaCl : Predicate<"Subtarget->isTargetNaCl()">;
231 // FIXME: Eventually this will be just "hasV6T2Ops".
232 def UseMovt : Predicate<"Subtarget->useMovt()">;
233 def DontUseMovt : Predicate<"!Subtarget->useMovt()">;
234 def UseFPVMLx : Predicate<"Subtarget->useFPVMLx()">;
236 // Prefer fused MAC for fp mul + add over fp VMLA / VMLS if they are available.
237 // But only select them if more precision in FP computation is allowed.
238 // Do not use them for Darwin platforms.
239 def UseFusedMAC : Predicate<"!TM.Options.NoExcessFPPrecision && "
240 "!Subtarget->isTargetDarwin()">;
241 def DontUseFusedMAC : Predicate<"!Subtarget->hasVFP4() || "
242 "Subtarget->isTargetDarwin()">;
244 //===----------------------------------------------------------------------===//
245 // ARM Flag Definitions.
247 class RegConstraint<string C> {
248 string Constraints = C;
251 //===----------------------------------------------------------------------===//
252 // ARM specific transformation functions and pattern fragments.
255 // so_imm_neg_XFORM - Return a so_imm value packed into the format described for
256 // so_imm_neg def below.
257 def so_imm_neg_XFORM : SDNodeXForm<imm, [{
258 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), MVT::i32);
261 // so_imm_not_XFORM - Return a so_imm value packed into the format described for
262 // so_imm_not def below.
263 def so_imm_not_XFORM : SDNodeXForm<imm, [{
264 return CurDAG->getTargetConstant(~(int)N->getZExtValue(), MVT::i32);
267 /// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
268 def imm16_31 : ImmLeaf<i32, [{
269 return (int32_t)Imm >= 16 && (int32_t)Imm < 32;
272 def so_imm_neg_asmoperand : AsmOperandClass { let Name = "ARMSOImmNeg"; }
273 def so_imm_neg : Operand<i32>, PatLeaf<(imm), [{
274 int64_t Value = -(int)N->getZExtValue();
275 return Value && ARM_AM::getSOImmVal(Value) != -1;
276 }], so_imm_neg_XFORM> {
277 let ParserMatchClass = so_imm_neg_asmoperand;
280 // Note: this pattern doesn't require an encoder method and such, as it's
281 // only used on aliases (Pat<> and InstAlias<>). The actual encoding
282 // is handled by the destination instructions, which use so_imm.
283 def so_imm_not_asmoperand : AsmOperandClass { let Name = "ARMSOImmNot"; }
284 def so_imm_not : Operand<i32>, PatLeaf<(imm), [{
285 return ARM_AM::getSOImmVal(~(uint32_t)N->getZExtValue()) != -1;
286 }], so_imm_not_XFORM> {
287 let ParserMatchClass = so_imm_not_asmoperand;
290 // sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
291 def sext_16_node : PatLeaf<(i32 GPR:$a), [{
292 return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17;
295 /// Split a 32-bit immediate into two 16 bit parts.
296 def hi16 : SDNodeXForm<imm, [{
297 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, MVT::i32);
300 def lo16AllZero : PatLeaf<(i32 imm), [{
301 // Returns true if all low 16-bits are 0.
302 return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
305 class BinOpWithFlagFrag<dag res> :
306 PatFrag<(ops node:$LHS, node:$RHS, node:$FLAG), res>;
307 class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
308 class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
310 // An 'and' node with a single use.
311 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
312 return N->hasOneUse();
315 // An 'xor' node with a single use.
316 def xor_su : PatFrag<(ops node:$lhs, node:$rhs), (xor node:$lhs, node:$rhs), [{
317 return N->hasOneUse();
320 // An 'fmul' node with a single use.
321 def fmul_su : PatFrag<(ops node:$lhs, node:$rhs), (fmul node:$lhs, node:$rhs),[{
322 return N->hasOneUse();
325 // An 'fadd' node which checks for single non-hazardous use.
326 def fadd_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fadd node:$lhs, node:$rhs),[{
327 return hasNoVMLxHazardUse(N);
330 // An 'fsub' node which checks for single non-hazardous use.
331 def fsub_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fsub node:$lhs, node:$rhs),[{
332 return hasNoVMLxHazardUse(N);
335 //===----------------------------------------------------------------------===//
336 // Operand Definitions.
339 // Immediate operands with a shared generic asm render method.
340 class ImmAsmOperand : AsmOperandClass { let RenderMethod = "addImmOperands"; }
343 // FIXME: rename brtarget to t2_brtarget
344 def brtarget : Operand<OtherVT> {
345 let EncoderMethod = "getBranchTargetOpValue";
346 let OperandType = "OPERAND_PCREL";
347 let DecoderMethod = "DecodeT2BROperand";
350 // FIXME: get rid of this one?
351 def uncondbrtarget : Operand<OtherVT> {
352 let EncoderMethod = "getUnconditionalBranchTargetOpValue";
353 let OperandType = "OPERAND_PCREL";
356 // Branch target for ARM. Handles conditional/unconditional
357 def br_target : Operand<OtherVT> {
358 let EncoderMethod = "getARMBranchTargetOpValue";
359 let OperandType = "OPERAND_PCREL";
363 // FIXME: rename bltarget to t2_bl_target?
364 def bltarget : Operand<i32> {
365 // Encoded the same as branch targets.
366 let EncoderMethod = "getBranchTargetOpValue";
367 let OperandType = "OPERAND_PCREL";
370 // Call target for ARM. Handles conditional/unconditional
371 // FIXME: rename bl_target to t2_bltarget?
372 def bl_target : Operand<i32> {
373 let EncoderMethod = "getARMBLTargetOpValue";
374 let OperandType = "OPERAND_PCREL";
377 def blx_target : Operand<i32> {
378 let EncoderMethod = "getARMBLXTargetOpValue";
379 let OperandType = "OPERAND_PCREL";
382 // A list of registers separated by comma. Used by load/store multiple.
383 def RegListAsmOperand : AsmOperandClass { let Name = "RegList"; }
384 def reglist : Operand<i32> {
385 let EncoderMethod = "getRegisterListOpValue";
386 let ParserMatchClass = RegListAsmOperand;
387 let PrintMethod = "printRegisterList";
388 let DecoderMethod = "DecodeRegListOperand";
391 def DPRRegListAsmOperand : AsmOperandClass { let Name = "DPRRegList"; }
392 def dpr_reglist : Operand<i32> {
393 let EncoderMethod = "getRegisterListOpValue";
394 let ParserMatchClass = DPRRegListAsmOperand;
395 let PrintMethod = "printRegisterList";
396 let DecoderMethod = "DecodeDPRRegListOperand";
399 def SPRRegListAsmOperand : AsmOperandClass { let Name = "SPRRegList"; }
400 def spr_reglist : Operand<i32> {
401 let EncoderMethod = "getRegisterListOpValue";
402 let ParserMatchClass = SPRRegListAsmOperand;
403 let PrintMethod = "printRegisterList";
404 let DecoderMethod = "DecodeSPRRegListOperand";
407 // An operand for the CONSTPOOL_ENTRY pseudo-instruction.
408 def cpinst_operand : Operand<i32> {
409 let PrintMethod = "printCPInstOperand";
413 def pclabel : Operand<i32> {
414 let PrintMethod = "printPCLabel";
417 // ADR instruction labels.
418 def adrlabel : Operand<i32> {
419 let EncoderMethod = "getAdrLabelOpValue";
422 def neon_vcvt_imm32 : Operand<i32> {
423 let EncoderMethod = "getNEONVcvtImm32OpValue";
424 let DecoderMethod = "DecodeVCVTImmOperand";
427 // rot_imm: An integer that encodes a rotate amount. Must be 8, 16, or 24.
428 def rot_imm_XFORM: SDNodeXForm<imm, [{
429 switch (N->getZExtValue()){
431 case 0: return CurDAG->getTargetConstant(0, MVT::i32);
432 case 8: return CurDAG->getTargetConstant(1, MVT::i32);
433 case 16: return CurDAG->getTargetConstant(2, MVT::i32);
434 case 24: return CurDAG->getTargetConstant(3, MVT::i32);
437 def RotImmAsmOperand : AsmOperandClass {
439 let ParserMethod = "parseRotImm";
441 def rot_imm : Operand<i32>, PatLeaf<(i32 imm), [{
442 int32_t v = N->getZExtValue();
443 return v == 8 || v == 16 || v == 24; }],
445 let PrintMethod = "printRotImmOperand";
446 let ParserMatchClass = RotImmAsmOperand;
449 // shift_imm: An integer that encodes a shift amount and the type of shift
450 // (asr or lsl). The 6-bit immediate encodes as:
453 // {4-0} imm5 shift amount.
454 // asr #32 encoded as imm5 == 0.
455 def ShifterImmAsmOperand : AsmOperandClass {
456 let Name = "ShifterImm";
457 let ParserMethod = "parseShifterImm";
459 def shift_imm : Operand<i32> {
460 let PrintMethod = "printShiftImmOperand";
461 let ParserMatchClass = ShifterImmAsmOperand;
464 // shifter_operand operands: so_reg_reg, so_reg_imm, and so_imm.
465 def ShiftedRegAsmOperand : AsmOperandClass { let Name = "RegShiftedReg"; }
466 def so_reg_reg : Operand<i32>, // reg reg imm
467 ComplexPattern<i32, 3, "SelectRegShifterOperand",
468 [shl, srl, sra, rotr]> {
469 let EncoderMethod = "getSORegRegOpValue";
470 let PrintMethod = "printSORegRegOperand";
471 let DecoderMethod = "DecodeSORegRegOperand";
472 let ParserMatchClass = ShiftedRegAsmOperand;
473 let MIOperandInfo = (ops GPRnopc, GPRnopc, i32imm);
476 def ShiftedImmAsmOperand : AsmOperandClass { let Name = "RegShiftedImm"; }
477 def so_reg_imm : Operand<i32>, // reg imm
478 ComplexPattern<i32, 2, "SelectImmShifterOperand",
479 [shl, srl, sra, rotr]> {
480 let EncoderMethod = "getSORegImmOpValue";
481 let PrintMethod = "printSORegImmOperand";
482 let DecoderMethod = "DecodeSORegImmOperand";
483 let ParserMatchClass = ShiftedImmAsmOperand;
484 let MIOperandInfo = (ops GPR, i32imm);
487 // FIXME: Does this need to be distinct from so_reg?
488 def shift_so_reg_reg : Operand<i32>, // reg reg imm
489 ComplexPattern<i32, 3, "SelectShiftRegShifterOperand",
490 [shl,srl,sra,rotr]> {
491 let EncoderMethod = "getSORegRegOpValue";
492 let PrintMethod = "printSORegRegOperand";
493 let DecoderMethod = "DecodeSORegRegOperand";
494 let ParserMatchClass = ShiftedRegAsmOperand;
495 let MIOperandInfo = (ops GPR, GPR, i32imm);
498 // FIXME: Does this need to be distinct from so_reg?
499 def shift_so_reg_imm : Operand<i32>, // reg reg imm
500 ComplexPattern<i32, 2, "SelectShiftImmShifterOperand",
501 [shl,srl,sra,rotr]> {
502 let EncoderMethod = "getSORegImmOpValue";
503 let PrintMethod = "printSORegImmOperand";
504 let DecoderMethod = "DecodeSORegImmOperand";
505 let ParserMatchClass = ShiftedImmAsmOperand;
506 let MIOperandInfo = (ops GPR, i32imm);
510 // so_imm - Match a 32-bit shifter_operand immediate operand, which is an
511 // 8-bit immediate rotated by an arbitrary number of bits.
512 def SOImmAsmOperand: ImmAsmOperand { let Name = "ARMSOImm"; }
513 def so_imm : Operand<i32>, ImmLeaf<i32, [{
514 return ARM_AM::getSOImmVal(Imm) != -1;
516 let EncoderMethod = "getSOImmOpValue";
517 let ParserMatchClass = SOImmAsmOperand;
518 let DecoderMethod = "DecodeSOImmOperand";
521 // Break so_imm's up into two pieces. This handles immediates with up to 16
522 // bits set in them. This uses so_imm2part to match and so_imm2part_[12] to
523 // get the first/second pieces.
524 def so_imm2part : PatLeaf<(imm), [{
525 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
528 /// arm_i32imm - True for +V6T2, or true only if so_imm2part is true.
530 def arm_i32imm : PatLeaf<(imm), [{
531 if (Subtarget->hasV6T2Ops())
533 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
536 /// imm0_1 predicate - Immediate in the range [0,1].
537 def Imm0_1AsmOperand: ImmAsmOperand { let Name = "Imm0_1"; }
538 def imm0_1 : Operand<i32> { let ParserMatchClass = Imm0_1AsmOperand; }
540 /// imm0_3 predicate - Immediate in the range [0,3].
541 def Imm0_3AsmOperand: ImmAsmOperand { let Name = "Imm0_3"; }
542 def imm0_3 : Operand<i32> { let ParserMatchClass = Imm0_3AsmOperand; }
544 /// imm0_7 predicate - Immediate in the range [0,7].
545 def Imm0_7AsmOperand: ImmAsmOperand { let Name = "Imm0_7"; }
546 def imm0_7 : Operand<i32>, ImmLeaf<i32, [{
547 return Imm >= 0 && Imm < 8;
549 let ParserMatchClass = Imm0_7AsmOperand;
552 /// imm8 predicate - Immediate is exactly 8.
553 def Imm8AsmOperand: ImmAsmOperand { let Name = "Imm8"; }
554 def imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 8; }]> {
555 let ParserMatchClass = Imm8AsmOperand;
558 /// imm16 predicate - Immediate is exactly 16.
559 def Imm16AsmOperand: ImmAsmOperand { let Name = "Imm16"; }
560 def imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 16; }]> {
561 let ParserMatchClass = Imm16AsmOperand;
564 /// imm32 predicate - Immediate is exactly 32.
565 def Imm32AsmOperand: ImmAsmOperand { let Name = "Imm32"; }
566 def imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 32; }]> {
567 let ParserMatchClass = Imm32AsmOperand;
570 /// imm1_7 predicate - Immediate in the range [1,7].
571 def Imm1_7AsmOperand: ImmAsmOperand { let Name = "Imm1_7"; }
572 def imm1_7 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 8; }]> {
573 let ParserMatchClass = Imm1_7AsmOperand;
576 /// imm1_15 predicate - Immediate in the range [1,15].
577 def Imm1_15AsmOperand: ImmAsmOperand { let Name = "Imm1_15"; }
578 def imm1_15 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 16; }]> {
579 let ParserMatchClass = Imm1_15AsmOperand;
582 /// imm1_31 predicate - Immediate in the range [1,31].
583 def Imm1_31AsmOperand: ImmAsmOperand { let Name = "Imm1_31"; }
584 def imm1_31 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 32; }]> {
585 let ParserMatchClass = Imm1_31AsmOperand;
588 /// imm0_15 predicate - Immediate in the range [0,15].
589 def Imm0_15AsmOperand: ImmAsmOperand { let Name = "Imm0_15"; }
590 def imm0_15 : Operand<i32>, ImmLeaf<i32, [{
591 return Imm >= 0 && Imm < 16;
593 let ParserMatchClass = Imm0_15AsmOperand;
596 /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
597 def Imm0_31AsmOperand: ImmAsmOperand { let Name = "Imm0_31"; }
598 def imm0_31 : Operand<i32>, ImmLeaf<i32, [{
599 return Imm >= 0 && Imm < 32;
601 let ParserMatchClass = Imm0_31AsmOperand;
604 /// imm0_32 predicate - True if the 32-bit immediate is in the range [0,32].
605 def Imm0_32AsmOperand: ImmAsmOperand { let Name = "Imm0_32"; }
606 def imm0_32 : Operand<i32>, ImmLeaf<i32, [{
607 return Imm >= 0 && Imm < 32;
609 let ParserMatchClass = Imm0_32AsmOperand;
612 /// imm0_63 predicate - True if the 32-bit immediate is in the range [0,63].
613 def Imm0_63AsmOperand: ImmAsmOperand { let Name = "Imm0_63"; }
614 def imm0_63 : Operand<i32>, ImmLeaf<i32, [{
615 return Imm >= 0 && Imm < 64;
617 let ParserMatchClass = Imm0_63AsmOperand;
620 /// imm0_255 predicate - Immediate in the range [0,255].
621 def Imm0_255AsmOperand : ImmAsmOperand { let Name = "Imm0_255"; }
622 def imm0_255 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 256; }]> {
623 let ParserMatchClass = Imm0_255AsmOperand;
626 /// imm0_65535 - An immediate is in the range [0.65535].
627 def Imm0_65535AsmOperand: ImmAsmOperand { let Name = "Imm0_65535"; }
628 def imm0_65535 : Operand<i32>, ImmLeaf<i32, [{
629 return Imm >= 0 && Imm < 65536;
631 let ParserMatchClass = Imm0_65535AsmOperand;
634 // imm0_65535_expr - For movt/movw - 16-bit immediate that can also reference
635 // a relocatable expression.
637 // FIXME: This really needs a Thumb version separate from the ARM version.
638 // While the range is the same, and can thus use the same match class,
639 // the encoding is different so it should have a different encoder method.
640 def Imm0_65535ExprAsmOperand: ImmAsmOperand { let Name = "Imm0_65535Expr"; }
641 def imm0_65535_expr : Operand<i32> {
642 let EncoderMethod = "getHiLo16ImmOpValue";
643 let ParserMatchClass = Imm0_65535ExprAsmOperand;
646 /// imm24b - True if the 32-bit immediate is encodable in 24 bits.
647 def Imm24bitAsmOperand: ImmAsmOperand { let Name = "Imm24bit"; }
648 def imm24b : Operand<i32>, ImmLeaf<i32, [{
649 return Imm >= 0 && Imm <= 0xffffff;
651 let ParserMatchClass = Imm24bitAsmOperand;
655 /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
657 def BitfieldAsmOperand : AsmOperandClass {
658 let Name = "Bitfield";
659 let ParserMethod = "parseBitfield";
662 def bf_inv_mask_imm : Operand<i32>,
664 return ARM::isBitFieldInvertedMask(N->getZExtValue());
666 let EncoderMethod = "getBitfieldInvertedMaskOpValue";
667 let PrintMethod = "printBitfieldInvMaskImmOperand";
668 let DecoderMethod = "DecodeBitfieldMaskOperand";
669 let ParserMatchClass = BitfieldAsmOperand;
672 def imm1_32_XFORM: SDNodeXForm<imm, [{
673 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, MVT::i32);
675 def Imm1_32AsmOperand: AsmOperandClass { let Name = "Imm1_32"; }
676 def imm1_32 : Operand<i32>, PatLeaf<(imm), [{
677 uint64_t Imm = N->getZExtValue();
678 return Imm > 0 && Imm <= 32;
681 let PrintMethod = "printImmPlusOneOperand";
682 let ParserMatchClass = Imm1_32AsmOperand;
685 def imm1_16_XFORM: SDNodeXForm<imm, [{
686 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, MVT::i32);
688 def Imm1_16AsmOperand: AsmOperandClass { let Name = "Imm1_16"; }
689 def imm1_16 : Operand<i32>, PatLeaf<(imm), [{ return Imm > 0 && Imm <= 16; }],
691 let PrintMethod = "printImmPlusOneOperand";
692 let ParserMatchClass = Imm1_16AsmOperand;
695 // Define ARM specific addressing modes.
696 // addrmode_imm12 := reg +/- imm12
698 def MemImm12OffsetAsmOperand : AsmOperandClass { let Name = "MemImm12Offset"; }
699 def addrmode_imm12 : Operand<i32>,
700 ComplexPattern<i32, 2, "SelectAddrModeImm12", []> {
701 // 12-bit immediate operand. Note that instructions using this encode
702 // #0 and #-0 differently. We flag #-0 as the magic value INT32_MIN. All other
703 // immediate values are as normal.
705 let EncoderMethod = "getAddrModeImm12OpValue";
706 let PrintMethod = "printAddrModeImm12Operand";
707 let DecoderMethod = "DecodeAddrModeImm12Operand";
708 let ParserMatchClass = MemImm12OffsetAsmOperand;
709 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
711 // ldst_so_reg := reg +/- reg shop imm
713 def MemRegOffsetAsmOperand : AsmOperandClass { let Name = "MemRegOffset"; }
714 def ldst_so_reg : Operand<i32>,
715 ComplexPattern<i32, 3, "SelectLdStSOReg", []> {
716 let EncoderMethod = "getLdStSORegOpValue";
717 // FIXME: Simplify the printer
718 let PrintMethod = "printAddrMode2Operand";
719 let DecoderMethod = "DecodeSORegMemOperand";
720 let ParserMatchClass = MemRegOffsetAsmOperand;
721 let MIOperandInfo = (ops GPR:$base, GPRnopc:$offsreg, i32imm:$shift);
724 // postidx_imm8 := +/- [0,255]
727 // {8} 1 is imm8 is non-negative. 0 otherwise.
728 // {7-0} [0,255] imm8 value.
729 def PostIdxImm8AsmOperand : AsmOperandClass { let Name = "PostIdxImm8"; }
730 def postidx_imm8 : Operand<i32> {
731 let PrintMethod = "printPostIdxImm8Operand";
732 let ParserMatchClass = PostIdxImm8AsmOperand;
733 let MIOperandInfo = (ops i32imm);
736 // postidx_imm8s4 := +/- [0,1020]
739 // {8} 1 is imm8 is non-negative. 0 otherwise.
740 // {7-0} [0,255] imm8 value, scaled by 4.
741 def PostIdxImm8s4AsmOperand : AsmOperandClass { let Name = "PostIdxImm8s4"; }
742 def postidx_imm8s4 : Operand<i32> {
743 let PrintMethod = "printPostIdxImm8s4Operand";
744 let ParserMatchClass = PostIdxImm8s4AsmOperand;
745 let MIOperandInfo = (ops i32imm);
749 // postidx_reg := +/- reg
751 def PostIdxRegAsmOperand : AsmOperandClass {
752 let Name = "PostIdxReg";
753 let ParserMethod = "parsePostIdxReg";
755 def postidx_reg : Operand<i32> {
756 let EncoderMethod = "getPostIdxRegOpValue";
757 let DecoderMethod = "DecodePostIdxReg";
758 let PrintMethod = "printPostIdxRegOperand";
759 let ParserMatchClass = PostIdxRegAsmOperand;
760 let MIOperandInfo = (ops GPRnopc, i32imm);
764 // addrmode2 := reg +/- imm12
765 // := reg +/- reg shop imm
767 // FIXME: addrmode2 should be refactored the rest of the way to always
768 // use explicit imm vs. reg versions above (addrmode_imm12 and ldst_so_reg).
769 def AddrMode2AsmOperand : AsmOperandClass { let Name = "AddrMode2"; }
770 def addrmode2 : Operand<i32>,
771 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
772 let EncoderMethod = "getAddrMode2OpValue";
773 let PrintMethod = "printAddrMode2Operand";
774 let ParserMatchClass = AddrMode2AsmOperand;
775 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
778 def PostIdxRegShiftedAsmOperand : AsmOperandClass {
779 let Name = "PostIdxRegShifted";
780 let ParserMethod = "parsePostIdxReg";
782 def am2offset_reg : Operand<i32>,
783 ComplexPattern<i32, 2, "SelectAddrMode2OffsetReg",
784 [], [SDNPWantRoot]> {
785 let EncoderMethod = "getAddrMode2OffsetOpValue";
786 let PrintMethod = "printAddrMode2OffsetOperand";
787 // When using this for assembly, it's always as a post-index offset.
788 let ParserMatchClass = PostIdxRegShiftedAsmOperand;
789 let MIOperandInfo = (ops GPRnopc, i32imm);
792 // FIXME: am2offset_imm should only need the immediate, not the GPR. Having
793 // the GPR is purely vestigal at this point.
794 def AM2OffsetImmAsmOperand : AsmOperandClass { let Name = "AM2OffsetImm"; }
795 def am2offset_imm : Operand<i32>,
796 ComplexPattern<i32, 2, "SelectAddrMode2OffsetImm",
797 [], [SDNPWantRoot]> {
798 let EncoderMethod = "getAddrMode2OffsetOpValue";
799 let PrintMethod = "printAddrMode2OffsetOperand";
800 let ParserMatchClass = AM2OffsetImmAsmOperand;
801 let MIOperandInfo = (ops GPRnopc, i32imm);
805 // addrmode3 := reg +/- reg
806 // addrmode3 := reg +/- imm8
808 // FIXME: split into imm vs. reg versions.
809 def AddrMode3AsmOperand : AsmOperandClass { let Name = "AddrMode3"; }
810 def addrmode3 : Operand<i32>,
811 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
812 let EncoderMethod = "getAddrMode3OpValue";
813 let PrintMethod = "printAddrMode3Operand";
814 let ParserMatchClass = AddrMode3AsmOperand;
815 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
818 // FIXME: split into imm vs. reg versions.
819 // FIXME: parser method to handle +/- register.
820 def AM3OffsetAsmOperand : AsmOperandClass {
821 let Name = "AM3Offset";
822 let ParserMethod = "parseAM3Offset";
824 def am3offset : Operand<i32>,
825 ComplexPattern<i32, 2, "SelectAddrMode3Offset",
826 [], [SDNPWantRoot]> {
827 let EncoderMethod = "getAddrMode3OffsetOpValue";
828 let PrintMethod = "printAddrMode3OffsetOperand";
829 let ParserMatchClass = AM3OffsetAsmOperand;
830 let MIOperandInfo = (ops GPR, i32imm);
833 // ldstm_mode := {ia, ib, da, db}
835 def ldstm_mode : OptionalDefOperand<OtherVT, (ops i32), (ops (i32 1))> {
836 let EncoderMethod = "getLdStmModeOpValue";
837 let PrintMethod = "printLdStmModeOperand";
840 // addrmode5 := reg +/- imm8*4
842 def AddrMode5AsmOperand : AsmOperandClass { let Name = "AddrMode5"; }
843 def addrmode5 : Operand<i32>,
844 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
845 let PrintMethod = "printAddrMode5Operand";
846 let EncoderMethod = "getAddrMode5OpValue";
847 let DecoderMethod = "DecodeAddrMode5Operand";
848 let ParserMatchClass = AddrMode5AsmOperand;
849 let MIOperandInfo = (ops GPR:$base, i32imm);
852 // addrmode6 := reg with optional alignment
854 def AddrMode6AsmOperand : AsmOperandClass { let Name = "AlignedMemory"; }
855 def addrmode6 : Operand<i32>,
856 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
857 let PrintMethod = "printAddrMode6Operand";
858 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
859 let EncoderMethod = "getAddrMode6AddressOpValue";
860 let DecoderMethod = "DecodeAddrMode6Operand";
861 let ParserMatchClass = AddrMode6AsmOperand;
864 def am6offset : Operand<i32>,
865 ComplexPattern<i32, 1, "SelectAddrMode6Offset",
866 [], [SDNPWantRoot]> {
867 let PrintMethod = "printAddrMode6OffsetOperand";
868 let MIOperandInfo = (ops GPR);
869 let EncoderMethod = "getAddrMode6OffsetOpValue";
870 let DecoderMethod = "DecodeGPRRegisterClass";
873 // Special version of addrmode6 to handle alignment encoding for VST1/VLD1
874 // (single element from one lane) for size 32.
875 def addrmode6oneL32 : Operand<i32>,
876 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
877 let PrintMethod = "printAddrMode6Operand";
878 let MIOperandInfo = (ops GPR:$addr, i32imm);
879 let EncoderMethod = "getAddrMode6OneLane32AddressOpValue";
882 // Special version of addrmode6 to handle alignment encoding for VLD-dup
883 // instructions, specifically VLD4-dup.
884 def addrmode6dup : Operand<i32>,
885 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
886 let PrintMethod = "printAddrMode6Operand";
887 let MIOperandInfo = (ops GPR:$addr, i32imm);
888 let EncoderMethod = "getAddrMode6DupAddressOpValue";
889 // FIXME: This is close, but not quite right. The alignment specifier is
891 let ParserMatchClass = AddrMode6AsmOperand;
894 // addrmodepc := pc + reg
896 def addrmodepc : Operand<i32>,
897 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
898 let PrintMethod = "printAddrModePCOperand";
899 let MIOperandInfo = (ops GPR, i32imm);
902 // addr_offset_none := reg
904 def MemNoOffsetAsmOperand : AsmOperandClass { let Name = "MemNoOffset"; }
905 def addr_offset_none : Operand<i32>,
906 ComplexPattern<i32, 1, "SelectAddrOffsetNone", []> {
907 let PrintMethod = "printAddrMode7Operand";
908 let DecoderMethod = "DecodeAddrMode7Operand";
909 let ParserMatchClass = MemNoOffsetAsmOperand;
910 let MIOperandInfo = (ops GPR:$base);
913 def nohash_imm : Operand<i32> {
914 let PrintMethod = "printNoHashImmediate";
917 def CoprocNumAsmOperand : AsmOperandClass {
918 let Name = "CoprocNum";
919 let ParserMethod = "parseCoprocNumOperand";
921 def p_imm : Operand<i32> {
922 let PrintMethod = "printPImmediate";
923 let ParserMatchClass = CoprocNumAsmOperand;
924 let DecoderMethod = "DecodeCoprocessor";
927 def pf_imm : Operand<i32> {
928 let PrintMethod = "printPImmediate";
929 let ParserMatchClass = CoprocNumAsmOperand;
932 def CoprocRegAsmOperand : AsmOperandClass {
933 let Name = "CoprocReg";
934 let ParserMethod = "parseCoprocRegOperand";
936 def c_imm : Operand<i32> {
937 let PrintMethod = "printCImmediate";
938 let ParserMatchClass = CoprocRegAsmOperand;
940 def CoprocOptionAsmOperand : AsmOperandClass {
941 let Name = "CoprocOption";
942 let ParserMethod = "parseCoprocOptionOperand";
944 def coproc_option_imm : Operand<i32> {
945 let PrintMethod = "printCoprocOptionImm";
946 let ParserMatchClass = CoprocOptionAsmOperand;
949 //===----------------------------------------------------------------------===//
951 include "ARMInstrFormats.td"
953 //===----------------------------------------------------------------------===//
954 // Multiclass helpers...
957 /// AsI1_bin_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns for a
958 /// binop that produces a value.
959 let TwoOperandAliasConstraint = "$Rn = $Rd" in
960 multiclass AsI1_bin_irs<bits<4> opcod, string opc,
961 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
962 PatFrag opnode, string baseOpc, bit Commutable = 0> {
963 // The register-immediate version is re-materializable. This is useful
964 // in particular for taking the address of a local.
965 let isReMaterializable = 1 in {
966 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
967 iii, opc, "\t$Rd, $Rn, $imm",
968 [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]> {
973 let Inst{19-16} = Rn;
974 let Inst{15-12} = Rd;
975 let Inst{11-0} = imm;
978 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
979 iir, opc, "\t$Rd, $Rn, $Rm",
980 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]> {
985 let isCommutable = Commutable;
986 let Inst{19-16} = Rn;
987 let Inst{15-12} = Rd;
988 let Inst{11-4} = 0b00000000;
992 def rsi : AsI1<opcod, (outs GPR:$Rd),
993 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
994 iis, opc, "\t$Rd, $Rn, $shift",
995 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_imm:$shift))]> {
1000 let Inst{19-16} = Rn;
1001 let Inst{15-12} = Rd;
1002 let Inst{11-5} = shift{11-5};
1004 let Inst{3-0} = shift{3-0};
1007 def rsr : AsI1<opcod, (outs GPR:$Rd),
1008 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1009 iis, opc, "\t$Rd, $Rn, $shift",
1010 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_reg:$shift))]> {
1015 let Inst{19-16} = Rn;
1016 let Inst{15-12} = Rd;
1017 let Inst{11-8} = shift{11-8};
1019 let Inst{6-5} = shift{6-5};
1021 let Inst{3-0} = shift{3-0};
1025 /// AsI1_rbin_irs - Same as AsI1_bin_irs except the order of operands are
1026 /// reversed. The 'rr' form is only defined for the disassembler; for codegen
1027 /// it is equivalent to the AsI1_bin_irs counterpart.
1028 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1029 multiclass AsI1_rbin_irs<bits<4> opcod, string opc,
1030 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1031 PatFrag opnode, string baseOpc, bit Commutable = 0> {
1032 // The register-immediate version is re-materializable. This is useful
1033 // in particular for taking the address of a local.
1034 let isReMaterializable = 1 in {
1035 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
1036 iii, opc, "\t$Rd, $Rn, $imm",
1037 [(set GPR:$Rd, (opnode so_imm:$imm, GPR:$Rn))]> {
1042 let Inst{19-16} = Rn;
1043 let Inst{15-12} = Rd;
1044 let Inst{11-0} = imm;
1047 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1048 iir, opc, "\t$Rd, $Rn, $Rm",
1049 [/* pattern left blank */]> {
1053 let Inst{11-4} = 0b00000000;
1056 let Inst{15-12} = Rd;
1057 let Inst{19-16} = Rn;
1060 def rsi : AsI1<opcod, (outs GPR:$Rd),
1061 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1062 iis, opc, "\t$Rd, $Rn, $shift",
1063 [(set GPR:$Rd, (opnode so_reg_imm:$shift, GPR:$Rn))]> {
1068 let Inst{19-16} = Rn;
1069 let Inst{15-12} = Rd;
1070 let Inst{11-5} = shift{11-5};
1072 let Inst{3-0} = shift{3-0};
1075 def rsr : AsI1<opcod, (outs GPR:$Rd),
1076 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1077 iis, opc, "\t$Rd, $Rn, $shift",
1078 [(set GPR:$Rd, (opnode so_reg_reg:$shift, GPR:$Rn))]> {
1083 let Inst{19-16} = Rn;
1084 let Inst{15-12} = Rd;
1085 let Inst{11-8} = shift{11-8};
1087 let Inst{6-5} = shift{6-5};
1089 let Inst{3-0} = shift{3-0};
1093 /// AsI1_bin_s_irs - Same as AsI1_bin_irs except it sets the 's' bit by default.
1095 /// These opcodes will be converted to the real non-S opcodes by
1096 /// AdjustInstrPostInstrSelection after giving them an optional CPSR operand.
1097 let hasPostISelHook = 1, Defs = [CPSR] in {
1098 multiclass AsI1_bin_s_irs<InstrItinClass iii, InstrItinClass iir,
1099 InstrItinClass iis, PatFrag opnode,
1100 bit Commutable = 0> {
1101 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm, pred:$p),
1103 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_imm:$imm))]>;
1105 def rr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, pred:$p),
1107 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm))]> {
1108 let isCommutable = Commutable;
1110 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1111 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1113 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1114 so_reg_imm:$shift))]>;
1116 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1117 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1119 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1120 so_reg_reg:$shift))]>;
1124 /// AsI1_rbin_s_is - Same as AsI1_bin_s_irs, except selection DAG
1125 /// operands are reversed.
1126 let hasPostISelHook = 1, Defs = [CPSR] in {
1127 multiclass AsI1_rbin_s_is<InstrItinClass iii, InstrItinClass iir,
1128 InstrItinClass iis, PatFrag opnode,
1129 bit Commutable = 0> {
1130 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm, pred:$p),
1132 [(set GPR:$Rd, CPSR, (opnode so_imm:$imm, GPR:$Rn))]>;
1134 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1135 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1137 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift,
1140 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1141 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1143 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift,
1148 /// AI1_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
1149 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
1150 /// a explicit result, only implicitly set CPSR.
1151 let isCompare = 1, Defs = [CPSR] in {
1152 multiclass AI1_cmp_irs<bits<4> opcod, string opc,
1153 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1154 PatFrag opnode, bit Commutable = 0> {
1155 def ri : AI1<opcod, (outs), (ins GPR:$Rn, so_imm:$imm), DPFrm, iii,
1157 [(opnode GPR:$Rn, so_imm:$imm)]> {
1162 let Inst{19-16} = Rn;
1163 let Inst{15-12} = 0b0000;
1164 let Inst{11-0} = imm;
1166 let Unpredictable{15-12} = 0b1111;
1168 def rr : AI1<opcod, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, iir,
1170 [(opnode GPR:$Rn, GPR:$Rm)]> {
1173 let isCommutable = Commutable;
1176 let Inst{19-16} = Rn;
1177 let Inst{15-12} = 0b0000;
1178 let Inst{11-4} = 0b00000000;
1181 let Unpredictable{15-12} = 0b1111;
1183 def rsi : AI1<opcod, (outs),
1184 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, iis,
1185 opc, "\t$Rn, $shift",
1186 [(opnode GPR:$Rn, so_reg_imm:$shift)]> {
1191 let Inst{19-16} = Rn;
1192 let Inst{15-12} = 0b0000;
1193 let Inst{11-5} = shift{11-5};
1195 let Inst{3-0} = shift{3-0};
1197 let Unpredictable{15-12} = 0b1111;
1199 def rsr : AI1<opcod, (outs),
1200 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, iis,
1201 opc, "\t$Rn, $shift",
1202 [(opnode GPRnopc:$Rn, so_reg_reg:$shift)]> {
1207 let Inst{19-16} = Rn;
1208 let Inst{15-12} = 0b0000;
1209 let Inst{11-8} = shift{11-8};
1211 let Inst{6-5} = shift{6-5};
1213 let Inst{3-0} = shift{3-0};
1215 let Unpredictable{15-12} = 0b1111;
1221 /// AI_ext_rrot - A unary operation with two forms: one whose operand is a
1222 /// register and one whose operand is a register rotated by 8/16/24.
1223 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
1224 class AI_ext_rrot<bits<8> opcod, string opc, PatFrag opnode>
1225 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1226 IIC_iEXTr, opc, "\t$Rd, $Rm$rot",
1227 [(set GPRnopc:$Rd, (opnode (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1228 Requires<[IsARM, HasV6]> {
1232 let Inst{19-16} = 0b1111;
1233 let Inst{15-12} = Rd;
1234 let Inst{11-10} = rot;
1238 class AI_ext_rrot_np<bits<8> opcod, string opc>
1239 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1240 IIC_iEXTr, opc, "\t$Rd, $Rm$rot", []>,
1241 Requires<[IsARM, HasV6]> {
1243 let Inst{19-16} = 0b1111;
1244 let Inst{11-10} = rot;
1247 /// AI_exta_rrot - A binary operation with two forms: one whose operand is a
1248 /// register and one whose operand is a register rotated by 8/16/24.
1249 class AI_exta_rrot<bits<8> opcod, string opc, PatFrag opnode>
1250 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1251 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot",
1252 [(set GPRnopc:$Rd, (opnode GPR:$Rn,
1253 (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1254 Requires<[IsARM, HasV6]> {
1259 let Inst{19-16} = Rn;
1260 let Inst{15-12} = Rd;
1261 let Inst{11-10} = rot;
1262 let Inst{9-4} = 0b000111;
1266 class AI_exta_rrot_np<bits<8> opcod, string opc>
1267 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1268 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot", []>,
1269 Requires<[IsARM, HasV6]> {
1272 let Inst{19-16} = Rn;
1273 let Inst{11-10} = rot;
1276 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
1277 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1278 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
1279 string baseOpc, bit Commutable = 0> {
1280 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1281 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
1282 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1283 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_imm:$imm, CPSR))]>,
1289 let Inst{15-12} = Rd;
1290 let Inst{19-16} = Rn;
1291 let Inst{11-0} = imm;
1293 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1294 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1295 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm, CPSR))]>,
1300 let Inst{11-4} = 0b00000000;
1302 let isCommutable = Commutable;
1304 let Inst{15-12} = Rd;
1305 let Inst{19-16} = Rn;
1307 def rsi : AsI1<opcod, (outs GPR:$Rd),
1308 (ins GPR:$Rn, so_reg_imm:$shift),
1309 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1310 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_imm:$shift, CPSR))]>,
1316 let Inst{19-16} = Rn;
1317 let Inst{15-12} = Rd;
1318 let Inst{11-5} = shift{11-5};
1320 let Inst{3-0} = shift{3-0};
1322 def rsr : AsI1<opcod, (outs GPRnopc:$Rd),
1323 (ins GPRnopc:$Rn, so_reg_reg:$shift),
1324 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1325 [(set GPRnopc:$Rd, CPSR,
1326 (opnode GPRnopc:$Rn, so_reg_reg:$shift, CPSR))]>,
1332 let Inst{19-16} = Rn;
1333 let Inst{15-12} = Rd;
1334 let Inst{11-8} = shift{11-8};
1336 let Inst{6-5} = shift{6-5};
1338 let Inst{3-0} = shift{3-0};
1343 /// AI1_rsc_irs - Define instructions and patterns for rsc
1344 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1345 multiclass AI1_rsc_irs<bits<4> opcod, string opc, PatFrag opnode,
1347 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1348 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
1349 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1350 [(set GPR:$Rd, CPSR, (opnode so_imm:$imm, GPR:$Rn, CPSR))]>,
1356 let Inst{15-12} = Rd;
1357 let Inst{19-16} = Rn;
1358 let Inst{11-0} = imm;
1360 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1361 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1362 [/* pattern left blank */]> {
1366 let Inst{11-4} = 0b00000000;
1369 let Inst{15-12} = Rd;
1370 let Inst{19-16} = Rn;
1372 def rsi : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_imm:$shift),
1373 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1374 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift, GPR:$Rn, CPSR))]>,
1380 let Inst{19-16} = Rn;
1381 let Inst{15-12} = Rd;
1382 let Inst{11-5} = shift{11-5};
1384 let Inst{3-0} = shift{3-0};
1386 def rsr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_reg:$shift),
1387 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1388 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift, GPR:$Rn, CPSR))]>,
1394 let Inst{19-16} = Rn;
1395 let Inst{15-12} = Rd;
1396 let Inst{11-8} = shift{11-8};
1398 let Inst{6-5} = shift{6-5};
1400 let Inst{3-0} = shift{3-0};
1405 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1406 multiclass AI_ldr1<bit isByte, string opc, InstrItinClass iii,
1407 InstrItinClass iir, PatFrag opnode> {
1408 // Note: We use the complex addrmode_imm12 rather than just an input
1409 // GPR and a constrained immediate so that we can use this to match
1410 // frame index references and avoid matching constant pool references.
1411 def i12: AI2ldst<0b010, 1, isByte, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
1412 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1413 [(set GPR:$Rt, (opnode addrmode_imm12:$addr))]> {
1416 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1417 let Inst{19-16} = addr{16-13}; // Rn
1418 let Inst{15-12} = Rt;
1419 let Inst{11-0} = addr{11-0}; // imm12
1421 def rs : AI2ldst<0b011, 1, isByte, (outs GPR:$Rt), (ins ldst_so_reg:$shift),
1422 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1423 [(set GPR:$Rt, (opnode ldst_so_reg:$shift))]> {
1426 let shift{4} = 0; // Inst{4} = 0
1427 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1428 let Inst{19-16} = shift{16-13}; // Rn
1429 let Inst{15-12} = Rt;
1430 let Inst{11-0} = shift{11-0};
1435 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1436 multiclass AI_ldr1nopc<bit isByte, string opc, InstrItinClass iii,
1437 InstrItinClass iir, PatFrag opnode> {
1438 // Note: We use the complex addrmode_imm12 rather than just an input
1439 // GPR and a constrained immediate so that we can use this to match
1440 // frame index references and avoid matching constant pool references.
1441 def i12: AI2ldst<0b010, 1, isByte, (outs GPRnopc:$Rt),
1442 (ins addrmode_imm12:$addr),
1443 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1444 [(set GPRnopc:$Rt, (opnode addrmode_imm12:$addr))]> {
1447 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1448 let Inst{19-16} = addr{16-13}; // Rn
1449 let Inst{15-12} = Rt;
1450 let Inst{11-0} = addr{11-0}; // imm12
1452 def rs : AI2ldst<0b011, 1, isByte, (outs GPRnopc:$Rt),
1453 (ins ldst_so_reg:$shift),
1454 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1455 [(set GPRnopc:$Rt, (opnode ldst_so_reg:$shift))]> {
1458 let shift{4} = 0; // Inst{4} = 0
1459 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1460 let Inst{19-16} = shift{16-13}; // Rn
1461 let Inst{15-12} = Rt;
1462 let Inst{11-0} = shift{11-0};
1468 multiclass AI_str1<bit isByte, string opc, InstrItinClass iii,
1469 InstrItinClass iir, PatFrag opnode> {
1470 // Note: We use the complex addrmode_imm12 rather than just an input
1471 // GPR and a constrained immediate so that we can use this to match
1472 // frame index references and avoid matching constant pool references.
1473 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1474 (ins GPR:$Rt, addrmode_imm12:$addr),
1475 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1476 [(opnode GPR:$Rt, addrmode_imm12:$addr)]> {
1479 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1480 let Inst{19-16} = addr{16-13}; // Rn
1481 let Inst{15-12} = Rt;
1482 let Inst{11-0} = addr{11-0}; // imm12
1484 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPR:$Rt, ldst_so_reg:$shift),
1485 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1486 [(opnode GPR:$Rt, ldst_so_reg:$shift)]> {
1489 let shift{4} = 0; // Inst{4} = 0
1490 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1491 let Inst{19-16} = shift{16-13}; // Rn
1492 let Inst{15-12} = Rt;
1493 let Inst{11-0} = shift{11-0};
1497 multiclass AI_str1nopc<bit isByte, string opc, InstrItinClass iii,
1498 InstrItinClass iir, PatFrag opnode> {
1499 // Note: We use the complex addrmode_imm12 rather than just an input
1500 // GPR and a constrained immediate so that we can use this to match
1501 // frame index references and avoid matching constant pool references.
1502 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1503 (ins GPRnopc:$Rt, addrmode_imm12:$addr),
1504 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1505 [(opnode GPRnopc:$Rt, addrmode_imm12:$addr)]> {
1508 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1509 let Inst{19-16} = addr{16-13}; // Rn
1510 let Inst{15-12} = Rt;
1511 let Inst{11-0} = addr{11-0}; // imm12
1513 def rs : AI2ldst<0b011, 0, isByte, (outs),
1514 (ins GPRnopc:$Rt, ldst_so_reg:$shift),
1515 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1516 [(opnode GPRnopc:$Rt, ldst_so_reg:$shift)]> {
1519 let shift{4} = 0; // Inst{4} = 0
1520 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1521 let Inst{19-16} = shift{16-13}; // Rn
1522 let Inst{15-12} = Rt;
1523 let Inst{11-0} = shift{11-0};
1528 //===----------------------------------------------------------------------===//
1530 //===----------------------------------------------------------------------===//
1532 //===----------------------------------------------------------------------===//
1533 // Miscellaneous Instructions.
1536 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
1537 /// the function. The first operand is the ID# for this instruction, the second
1538 /// is the index into the MachineConstantPool that this is, the third is the
1539 /// size in bytes of this constant pool entry.
1540 let neverHasSideEffects = 1, isNotDuplicable = 1 in
1541 def CONSTPOOL_ENTRY :
1542 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1543 i32imm:$size), NoItinerary, []>;
1545 // FIXME: Marking these as hasSideEffects is necessary to prevent machine DCE
1546 // from removing one half of the matched pairs. That breaks PEI, which assumes
1547 // these will always be in pairs, and asserts if it finds otherwise. Better way?
1548 let Defs = [SP], Uses = [SP], hasSideEffects = 1 in {
1549 def ADJCALLSTACKUP :
1550 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary,
1551 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
1553 def ADJCALLSTACKDOWN :
1554 PseudoInst<(outs), (ins i32imm:$amt, pred:$p), NoItinerary,
1555 [(ARMcallseq_start timm:$amt)]>;
1558 // Atomic pseudo-insts which will be lowered to ldrexd/strexd loops.
1559 // (These pseudos use a hand-written selection code).
1560 let usesCustomInserter = 1, Defs = [CPSR], mayLoad = 1, mayStore = 1 in {
1561 def ATOMOR6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1562 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1564 def ATOMXOR6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1565 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1567 def ATOMADD6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1568 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1570 def ATOMSUB6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1571 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1573 def ATOMNAND6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1574 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1576 def ATOMAND6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1577 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1579 def ATOMSWAP6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1580 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1582 def ATOMCMPXCHG6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1583 (ins GPR:$addr, GPR:$cmp1, GPR:$cmp2,
1584 GPR:$set1, GPR:$set2),
1588 def NOP : AI<(outs), (ins), MiscFrm, NoItinerary, "nop", "", []>,
1589 Requires<[IsARM, HasV6T2]> {
1590 let Inst{27-16} = 0b001100100000;
1591 let Inst{15-8} = 0b11110000;
1592 let Inst{7-0} = 0b00000000;
1595 def YIELD : AI<(outs), (ins), MiscFrm, NoItinerary, "yield", "", []>,
1596 Requires<[IsARM, HasV6T2]> {
1597 let Inst{27-16} = 0b001100100000;
1598 let Inst{15-8} = 0b11110000;
1599 let Inst{7-0} = 0b00000001;
1602 def WFE : AI<(outs), (ins), MiscFrm, NoItinerary, "wfe", "", []>,
1603 Requires<[IsARM, HasV6T2]> {
1604 let Inst{27-16} = 0b001100100000;
1605 let Inst{15-8} = 0b11110000;
1606 let Inst{7-0} = 0b00000010;
1609 def WFI : AI<(outs), (ins), MiscFrm, NoItinerary, "wfi", "", []>,
1610 Requires<[IsARM, HasV6T2]> {
1611 let Inst{27-16} = 0b001100100000;
1612 let Inst{15-8} = 0b11110000;
1613 let Inst{7-0} = 0b00000011;
1616 def SEL : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, NoItinerary, "sel",
1617 "\t$Rd, $Rn, $Rm", []>, Requires<[IsARM, HasV6]> {
1622 let Inst{15-12} = Rd;
1623 let Inst{19-16} = Rn;
1624 let Inst{27-20} = 0b01101000;
1625 let Inst{7-4} = 0b1011;
1626 let Inst{11-8} = 0b1111;
1628 let Unpredictable{11-8} = 0b1111;
1631 def SEV : AI<(outs), (ins), MiscFrm, NoItinerary, "sev", "",
1632 []>, Requires<[IsARM, HasV6T2]> {
1633 let Inst{27-16} = 0b001100100000;
1634 let Inst{15-8} = 0b11110000;
1635 let Inst{7-0} = 0b00000100;
1638 // The i32imm operand $val can be used by a debugger to store more information
1639 // about the breakpoint.
1640 def BKPT : AI<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
1641 "bkpt", "\t$val", []>, Requires<[IsARM]> {
1643 let Inst{3-0} = val{3-0};
1644 let Inst{19-8} = val{15-4};
1645 let Inst{27-20} = 0b00010010;
1646 let Inst{7-4} = 0b0111;
1649 // Change Processor State
1650 // FIXME: We should use InstAlias to handle the optional operands.
1651 class CPS<dag iops, string asm_ops>
1652 : AXI<(outs), iops, MiscFrm, NoItinerary, !strconcat("cps", asm_ops),
1653 []>, Requires<[IsARM]> {
1659 let Inst{31-28} = 0b1111;
1660 let Inst{27-20} = 0b00010000;
1661 let Inst{19-18} = imod;
1662 let Inst{17} = M; // Enabled if mode is set;
1663 let Inst{16-9} = 0b00000000;
1664 let Inst{8-6} = iflags;
1666 let Inst{4-0} = mode;
1669 let DecoderMethod = "DecodeCPSInstruction" in {
1671 def CPS3p : CPS<(ins imod_op:$imod, iflags_op:$iflags, imm0_31:$mode),
1672 "$imod\t$iflags, $mode">;
1673 let mode = 0, M = 0 in
1674 def CPS2p : CPS<(ins imod_op:$imod, iflags_op:$iflags), "$imod\t$iflags">;
1676 let imod = 0, iflags = 0, M = 1 in
1677 def CPS1p : CPS<(ins imm0_31:$mode), "\t$mode">;
1680 // Preload signals the memory system of possible future data/instruction access.
1681 multiclass APreLoad<bits<1> read, bits<1> data, string opc> {
1683 def i12 : AXI<(outs), (ins addrmode_imm12:$addr), MiscFrm, IIC_Preload,
1684 !strconcat(opc, "\t$addr"),
1685 [(ARMPreload addrmode_imm12:$addr, (i32 read), (i32 data))]> {
1688 let Inst{31-26} = 0b111101;
1689 let Inst{25} = 0; // 0 for immediate form
1690 let Inst{24} = data;
1691 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1692 let Inst{22} = read;
1693 let Inst{21-20} = 0b01;
1694 let Inst{19-16} = addr{16-13}; // Rn
1695 let Inst{15-12} = 0b1111;
1696 let Inst{11-0} = addr{11-0}; // imm12
1699 def rs : AXI<(outs), (ins ldst_so_reg:$shift), MiscFrm, IIC_Preload,
1700 !strconcat(opc, "\t$shift"),
1701 [(ARMPreload ldst_so_reg:$shift, (i32 read), (i32 data))]> {
1703 let Inst{31-26} = 0b111101;
1704 let Inst{25} = 1; // 1 for register form
1705 let Inst{24} = data;
1706 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1707 let Inst{22} = read;
1708 let Inst{21-20} = 0b01;
1709 let Inst{19-16} = shift{16-13}; // Rn
1710 let Inst{15-12} = 0b1111;
1711 let Inst{11-0} = shift{11-0};
1716 defm PLD : APreLoad<1, 1, "pld">, Requires<[IsARM]>;
1717 defm PLDW : APreLoad<0, 1, "pldw">, Requires<[IsARM,HasV7,HasMP]>;
1718 defm PLI : APreLoad<1, 0, "pli">, Requires<[IsARM,HasV7]>;
1720 def SETEND : AXI<(outs), (ins setend_op:$end), MiscFrm, NoItinerary,
1721 "setend\t$end", []>, Requires<[IsARM]> {
1723 let Inst{31-10} = 0b1111000100000001000000;
1728 def DBG : AI<(outs), (ins imm0_15:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt",
1729 []>, Requires<[IsARM, HasV7]> {
1731 let Inst{27-4} = 0b001100100000111100001111;
1732 let Inst{3-0} = opt;
1735 // A5.4 Permanently UNDEFINED instructions.
1736 let isBarrier = 1, isTerminator = 1 in
1737 def TRAP : AXI<(outs), (ins), MiscFrm, NoItinerary,
1740 let Inst = 0xe7ffdefe;
1743 // Address computation and loads and stores in PIC mode.
1744 let isNotDuplicable = 1 in {
1745 def PICADD : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
1747 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>;
1749 let AddedComplexity = 10 in {
1750 def PICLDR : ARMPseudoInst<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
1752 [(set GPR:$dst, (load addrmodepc:$addr))]>;
1754 def PICLDRH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1756 [(set GPR:$Rt, (zextloadi16 addrmodepc:$addr))]>;
1758 def PICLDRB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1760 [(set GPR:$Rt, (zextloadi8 addrmodepc:$addr))]>;
1762 def PICLDRSH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1764 [(set GPR:$Rt, (sextloadi16 addrmodepc:$addr))]>;
1766 def PICLDRSB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1768 [(set GPR:$Rt, (sextloadi8 addrmodepc:$addr))]>;
1770 let AddedComplexity = 10 in {
1771 def PICSTR : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1772 4, IIC_iStore_r, [(store GPR:$src, addrmodepc:$addr)]>;
1774 def PICSTRH : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1775 4, IIC_iStore_bh_r, [(truncstorei16 GPR:$src,
1776 addrmodepc:$addr)]>;
1778 def PICSTRB : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1779 4, IIC_iStore_bh_r, [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
1781 } // isNotDuplicable = 1
1784 // LEApcrel - Load a pc-relative address into a register without offending the
1786 let neverHasSideEffects = 1, isReMaterializable = 1 in
1787 // The 'adr' mnemonic encodes differently if the label is before or after
1788 // the instruction. The {24-21} opcode bits are set by the fixup, as we don't
1789 // know until then which form of the instruction will be used.
1790 def ADR : AI1<{0,?,?,0}, (outs GPR:$Rd), (ins adrlabel:$label),
1791 MiscFrm, IIC_iALUi, "adr", "\t$Rd, $label", []> {
1794 let Inst{27-25} = 0b001;
1796 let Inst{23-22} = label{13-12};
1799 let Inst{19-16} = 0b1111;
1800 let Inst{15-12} = Rd;
1801 let Inst{11-0} = label{11-0};
1803 def LEApcrel : ARMPseudoInst<(outs GPR:$Rd), (ins i32imm:$label, pred:$p),
1806 def LEApcrelJT : ARMPseudoInst<(outs GPR:$Rd),
1807 (ins i32imm:$label, nohash_imm:$id, pred:$p),
1810 //===----------------------------------------------------------------------===//
1811 // Control Flow Instructions.
1814 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
1816 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
1817 "bx", "\tlr", [(ARMretflag)]>,
1818 Requires<[IsARM, HasV4T]> {
1819 let Inst{27-0} = 0b0001001011111111111100011110;
1823 def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br,
1824 "mov", "\tpc, lr", [(ARMretflag)]>,
1825 Requires<[IsARM, NoV4T]> {
1826 let Inst{27-0} = 0b0001101000001111000000001110;
1830 // Indirect branches
1831 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
1833 def BX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
1834 [(brind GPR:$dst)]>,
1835 Requires<[IsARM, HasV4T]> {
1837 let Inst{31-4} = 0b1110000100101111111111110001;
1838 let Inst{3-0} = dst;
1841 def BX_pred : AI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br,
1842 "bx", "\t$dst", [/* pattern left blank */]>,
1843 Requires<[IsARM, HasV4T]> {
1845 let Inst{27-4} = 0b000100101111111111110001;
1846 let Inst{3-0} = dst;
1850 // SP is marked as a use to prevent stack-pointer assignments that appear
1851 // immediately before calls from potentially appearing dead.
1853 // FIXME: Do we really need a non-predicated version? If so, it should
1854 // at least be a pseudo instruction expanding to the predicated version
1855 // at MC lowering time.
1856 Defs = [LR], Uses = [SP] in {
1857 def BL : ABXI<0b1011, (outs), (ins bl_target:$func, variable_ops),
1858 IIC_Br, "bl\t$func",
1859 [(ARMcall tglobaladdr:$func)]>,
1861 let Inst{31-28} = 0b1110;
1863 let Inst{23-0} = func;
1864 let DecoderMethod = "DecodeBranchImmInstruction";
1867 def BL_pred : ABI<0b1011, (outs), (ins bl_target:$func, variable_ops),
1868 IIC_Br, "bl", "\t$func",
1869 [(ARMcall_pred tglobaladdr:$func)]>,
1872 let Inst{23-0} = func;
1873 let DecoderMethod = "DecodeBranchImmInstruction";
1877 def BLX : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
1878 IIC_Br, "blx\t$func",
1879 [(ARMcall GPR:$func)]>,
1880 Requires<[IsARM, HasV5T]> {
1882 let Inst{31-4} = 0b1110000100101111111111110011;
1883 let Inst{3-0} = func;
1886 def BLX_pred : AI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
1887 IIC_Br, "blx", "\t$func",
1888 [(ARMcall_pred GPR:$func)]>,
1889 Requires<[IsARM, HasV5T]> {
1891 let Inst{27-4} = 0b000100101111111111110011;
1892 let Inst{3-0} = func;
1896 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
1897 def BX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func, variable_ops),
1898 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
1899 Requires<[IsARM, HasV4T]>;
1902 def BMOVPCRX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func, variable_ops),
1903 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
1904 Requires<[IsARM, NoV4T]>;
1906 // mov lr, pc; b if callee is marked noreturn to avoid confusing the
1907 // return stack predictor.
1908 def BMOVPCB_CALL : ARMPseudoInst<(outs),
1909 (ins bl_target:$func, variable_ops),
1910 8, IIC_Br, [(ARMcall_nolink tglobaladdr:$func)]>,
1914 let isBranch = 1, isTerminator = 1 in {
1915 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
1916 // a two-value operand where a dag node expects two operands. :(
1917 def Bcc : ABI<0b1010, (outs), (ins br_target:$target),
1918 IIC_Br, "b", "\t$target",
1919 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]> {
1921 let Inst{23-0} = target;
1922 let DecoderMethod = "DecodeBranchImmInstruction";
1925 let isBarrier = 1 in {
1926 // B is "predicable" since it's just a Bcc with an 'always' condition.
1927 let isPredicable = 1 in
1928 // FIXME: We shouldn't need this pseudo at all. Just using Bcc directly
1929 // should be sufficient.
1930 // FIXME: Is B really a Barrier? That doesn't seem right.
1931 def B : ARMPseudoExpand<(outs), (ins br_target:$target), 4, IIC_Br,
1932 [(br bb:$target)], (Bcc br_target:$target, (ops 14, zero_reg))>;
1934 let isNotDuplicable = 1, isIndirectBranch = 1 in {
1935 def BR_JTr : ARMPseudoInst<(outs),
1936 (ins GPR:$target, i32imm:$jt, i32imm:$id),
1938 [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]>;
1939 // FIXME: This shouldn't use the generic "addrmode2," but rather be split
1940 // into i12 and rs suffixed versions.
1941 def BR_JTm : ARMPseudoInst<(outs),
1942 (ins addrmode2:$target, i32imm:$jt, i32imm:$id),
1944 [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
1946 def BR_JTadd : ARMPseudoInst<(outs),
1947 (ins GPR:$target, GPR:$idx, i32imm:$jt, i32imm:$id),
1949 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
1951 } // isNotDuplicable = 1, isIndirectBranch = 1
1957 def BLXi : AXI<(outs), (ins blx_target:$target), BrMiscFrm, NoItinerary,
1958 "blx\t$target", []>,
1959 Requires<[IsARM, HasV5T]> {
1960 let Inst{31-25} = 0b1111101;
1962 let Inst{23-0} = target{24-1};
1963 let Inst{24} = target{0};
1966 // Branch and Exchange Jazelle
1967 def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func",
1968 [/* pattern left blank */]> {
1970 let Inst{23-20} = 0b0010;
1971 let Inst{19-8} = 0xfff;
1972 let Inst{7-4} = 0b0010;
1973 let Inst{3-0} = func;
1978 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in {
1979 def TCRETURNdi : PseudoInst<(outs), (ins i32imm:$dst, variable_ops),
1982 def TCRETURNri : PseudoInst<(outs), (ins tcGPR:$dst, variable_ops),
1985 def TAILJMPd : ARMPseudoExpand<(outs), (ins br_target:$dst, variable_ops),
1987 (Bcc br_target:$dst, (ops 14, zero_reg))>,
1990 def TAILJMPr : ARMPseudoExpand<(outs), (ins tcGPR:$dst, variable_ops),
1996 // Secure Monitor Call is a system instruction.
1997 def SMC : ABI<0b0001, (outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt",
2000 let Inst{23-4} = 0b01100000000000000111;
2001 let Inst{3-0} = opt;
2004 // Supervisor Call (Software Interrupt)
2005 let isCall = 1, Uses = [SP] in {
2006 def SVC : ABI<0b1111, (outs), (ins imm24b:$svc), IIC_Br, "svc", "\t$svc", []> {
2008 let Inst{23-0} = svc;
2012 // Store Return State
2013 class SRSI<bit wb, string asm>
2014 : XI<(outs), (ins imm0_31:$mode), AddrModeNone, 4, IndexModeNone, BrFrm,
2015 NoItinerary, asm, "", []> {
2017 let Inst{31-28} = 0b1111;
2018 let Inst{27-25} = 0b100;
2022 let Inst{19-16} = 0b1101; // SP
2023 let Inst{15-5} = 0b00000101000;
2024 let Inst{4-0} = mode;
2027 def SRSDA : SRSI<0, "srsda\tsp, $mode"> {
2028 let Inst{24-23} = 0;
2030 def SRSDA_UPD : SRSI<1, "srsda\tsp!, $mode"> {
2031 let Inst{24-23} = 0;
2033 def SRSDB : SRSI<0, "srsdb\tsp, $mode"> {
2034 let Inst{24-23} = 0b10;
2036 def SRSDB_UPD : SRSI<1, "srsdb\tsp!, $mode"> {
2037 let Inst{24-23} = 0b10;
2039 def SRSIA : SRSI<0, "srsia\tsp, $mode"> {
2040 let Inst{24-23} = 0b01;
2042 def SRSIA_UPD : SRSI<1, "srsia\tsp!, $mode"> {
2043 let Inst{24-23} = 0b01;
2045 def SRSIB : SRSI<0, "srsib\tsp, $mode"> {
2046 let Inst{24-23} = 0b11;
2048 def SRSIB_UPD : SRSI<1, "srsib\tsp!, $mode"> {
2049 let Inst{24-23} = 0b11;
2052 // Return From Exception
2053 class RFEI<bit wb, string asm>
2054 : XI<(outs), (ins GPR:$Rn), AddrModeNone, 4, IndexModeNone, BrFrm,
2055 NoItinerary, asm, "", []> {
2057 let Inst{31-28} = 0b1111;
2058 let Inst{27-25} = 0b100;
2062 let Inst{19-16} = Rn;
2063 let Inst{15-0} = 0xa00;
2066 def RFEDA : RFEI<0, "rfeda\t$Rn"> {
2067 let Inst{24-23} = 0;
2069 def RFEDA_UPD : RFEI<1, "rfeda\t$Rn!"> {
2070 let Inst{24-23} = 0;
2072 def RFEDB : RFEI<0, "rfedb\t$Rn"> {
2073 let Inst{24-23} = 0b10;
2075 def RFEDB_UPD : RFEI<1, "rfedb\t$Rn!"> {
2076 let Inst{24-23} = 0b10;
2078 def RFEIA : RFEI<0, "rfeia\t$Rn"> {
2079 let Inst{24-23} = 0b01;
2081 def RFEIA_UPD : RFEI<1, "rfeia\t$Rn!"> {
2082 let Inst{24-23} = 0b01;
2084 def RFEIB : RFEI<0, "rfeib\t$Rn"> {
2085 let Inst{24-23} = 0b11;
2087 def RFEIB_UPD : RFEI<1, "rfeib\t$Rn!"> {
2088 let Inst{24-23} = 0b11;
2091 //===----------------------------------------------------------------------===//
2092 // Load / Store Instructions.
2098 defm LDR : AI_ldr1<0, "ldr", IIC_iLoad_r, IIC_iLoad_si,
2099 UnOpFrag<(load node:$Src)>>;
2100 defm LDRB : AI_ldr1nopc<1, "ldrb", IIC_iLoad_bh_r, IIC_iLoad_bh_si,
2101 UnOpFrag<(zextloadi8 node:$Src)>>;
2102 defm STR : AI_str1<0, "str", IIC_iStore_r, IIC_iStore_si,
2103 BinOpFrag<(store node:$LHS, node:$RHS)>>;
2104 defm STRB : AI_str1nopc<1, "strb", IIC_iStore_bh_r, IIC_iStore_bh_si,
2105 BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
2107 // Special LDR for loads from non-pc-relative constpools.
2108 let canFoldAsLoad = 1, mayLoad = 1, neverHasSideEffects = 1,
2109 isReMaterializable = 1, isCodeGenOnly = 1 in
2110 def LDRcp : AI2ldst<0b010, 1, 0, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
2111 AddrMode_i12, LdFrm, IIC_iLoad_r, "ldr", "\t$Rt, $addr",
2115 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2116 let Inst{19-16} = 0b1111;
2117 let Inst{15-12} = Rt;
2118 let Inst{11-0} = addr{11-0}; // imm12
2121 // Loads with zero extension
2122 def LDRH : AI3ld<0b1011, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2123 IIC_iLoad_bh_r, "ldrh", "\t$Rt, $addr",
2124 [(set GPR:$Rt, (zextloadi16 addrmode3:$addr))]>;
2126 // Loads with sign extension
2127 def LDRSH : AI3ld<0b1111, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2128 IIC_iLoad_bh_r, "ldrsh", "\t$Rt, $addr",
2129 [(set GPR:$Rt, (sextloadi16 addrmode3:$addr))]>;
2131 def LDRSB : AI3ld<0b1101, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2132 IIC_iLoad_bh_r, "ldrsb", "\t$Rt, $addr",
2133 [(set GPR:$Rt, (sextloadi8 addrmode3:$addr))]>;
2135 let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1 in {
2137 def LDRD : AI3ld<0b1101, 0, (outs GPR:$Rd, GPR:$dst2),
2138 (ins addrmode3:$addr), LdMiscFrm,
2139 IIC_iLoad_d_r, "ldrd", "\t$Rd, $dst2, $addr",
2140 []>, Requires<[IsARM, HasV5TE]>;
2144 multiclass AI2_ldridx<bit isByte, string opc,
2145 InstrItinClass iii, InstrItinClass iir> {
2146 def _PRE_IMM : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2147 (ins addrmode_imm12:$addr), IndexModePre, LdFrm, iii,
2148 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2151 let Inst{23} = addr{12};
2152 let Inst{19-16} = addr{16-13};
2153 let Inst{11-0} = addr{11-0};
2154 let DecoderMethod = "DecodeLDRPreImm";
2155 let AsmMatchConverter = "cvtLdWriteBackRegAddrModeImm12";
2158 def _PRE_REG : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2159 (ins ldst_so_reg:$addr), IndexModePre, LdFrm, iir,
2160 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2163 let Inst{23} = addr{12};
2164 let Inst{19-16} = addr{16-13};
2165 let Inst{11-0} = addr{11-0};
2167 let DecoderMethod = "DecodeLDRPreReg";
2168 let AsmMatchConverter = "cvtLdWriteBackRegAddrMode2";
2171 def _POST_REG : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2172 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2173 IndexModePost, LdFrm, iir,
2174 opc, "\t$Rt, $addr, $offset",
2175 "$addr.base = $Rn_wb", []> {
2181 let Inst{23} = offset{12};
2182 let Inst{19-16} = addr;
2183 let Inst{11-0} = offset{11-0};
2185 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2188 def _POST_IMM : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2189 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2190 IndexModePost, LdFrm, iii,
2191 opc, "\t$Rt, $addr, $offset",
2192 "$addr.base = $Rn_wb", []> {
2198 let Inst{23} = offset{12};
2199 let Inst{19-16} = addr;
2200 let Inst{11-0} = offset{11-0};
2202 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2207 let mayLoad = 1, neverHasSideEffects = 1 in {
2208 // FIXME: for LDR_PRE_REG etc. the itineray should be either IIC_iLoad_ru or
2209 // IIC_iLoad_siu depending on whether it the offset register is shifted.
2210 defm LDR : AI2_ldridx<0, "ldr", IIC_iLoad_iu, IIC_iLoad_ru>;
2211 defm LDRB : AI2_ldridx<1, "ldrb", IIC_iLoad_bh_iu, IIC_iLoad_bh_ru>;
2214 multiclass AI3_ldridx<bits<4> op, string opc, InstrItinClass itin> {
2215 def _PRE : AI3ldstidx<op, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2216 (ins addrmode3:$addr), IndexModePre,
2218 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2220 let Inst{23} = addr{8}; // U bit
2221 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2222 let Inst{19-16} = addr{12-9}; // Rn
2223 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2224 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2225 let AsmMatchConverter = "cvtLdWriteBackRegAddrMode3";
2226 let DecoderMethod = "DecodeAddrMode3Instruction";
2228 def _POST : AI3ldstidx<op, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2229 (ins addr_offset_none:$addr, am3offset:$offset),
2230 IndexModePost, LdMiscFrm, itin,
2231 opc, "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2235 let Inst{23} = offset{8}; // U bit
2236 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2237 let Inst{19-16} = addr;
2238 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2239 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2240 let DecoderMethod = "DecodeAddrMode3Instruction";
2244 let mayLoad = 1, neverHasSideEffects = 1 in {
2245 defm LDRH : AI3_ldridx<0b1011, "ldrh", IIC_iLoad_bh_ru>;
2246 defm LDRSH : AI3_ldridx<0b1111, "ldrsh", IIC_iLoad_bh_ru>;
2247 defm LDRSB : AI3_ldridx<0b1101, "ldrsb", IIC_iLoad_bh_ru>;
2248 let hasExtraDefRegAllocReq = 1 in {
2249 def LDRD_PRE : AI3ldstidx<0b1101, 0, 1, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2250 (ins addrmode3:$addr), IndexModePre,
2251 LdMiscFrm, IIC_iLoad_d_ru,
2252 "ldrd", "\t$Rt, $Rt2, $addr!",
2253 "$addr.base = $Rn_wb", []> {
2255 let Inst{23} = addr{8}; // U bit
2256 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2257 let Inst{19-16} = addr{12-9}; // Rn
2258 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2259 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2260 let DecoderMethod = "DecodeAddrMode3Instruction";
2261 let AsmMatchConverter = "cvtLdrdPre";
2263 def LDRD_POST: AI3ldstidx<0b1101, 0, 0, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2264 (ins addr_offset_none:$addr, am3offset:$offset),
2265 IndexModePost, LdMiscFrm, IIC_iLoad_d_ru,
2266 "ldrd", "\t$Rt, $Rt2, $addr, $offset",
2267 "$addr.base = $Rn_wb", []> {
2270 let Inst{23} = offset{8}; // U bit
2271 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2272 let Inst{19-16} = addr;
2273 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2274 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2275 let DecoderMethod = "DecodeAddrMode3Instruction";
2277 } // hasExtraDefRegAllocReq = 1
2278 } // mayLoad = 1, neverHasSideEffects = 1
2280 // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT.
2281 let mayLoad = 1, neverHasSideEffects = 1 in {
2282 def LDRT_POST_REG : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2283 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2284 IndexModePost, LdFrm, IIC_iLoad_ru,
2285 "ldrt", "\t$Rt, $addr, $offset",
2286 "$addr.base = $Rn_wb", []> {
2292 let Inst{23} = offset{12};
2293 let Inst{21} = 1; // overwrite
2294 let Inst{19-16} = addr;
2295 let Inst{11-5} = offset{11-5};
2297 let Inst{3-0} = offset{3-0};
2298 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2301 def LDRT_POST_IMM : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2302 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2303 IndexModePost, LdFrm, IIC_iLoad_ru,
2304 "ldrt", "\t$Rt, $addr, $offset",
2305 "$addr.base = $Rn_wb", []> {
2311 let Inst{23} = offset{12};
2312 let Inst{21} = 1; // overwrite
2313 let Inst{19-16} = addr;
2314 let Inst{11-0} = offset{11-0};
2315 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2318 def LDRBT_POST_REG : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2319 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2320 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2321 "ldrbt", "\t$Rt, $addr, $offset",
2322 "$addr.base = $Rn_wb", []> {
2328 let Inst{23} = offset{12};
2329 let Inst{21} = 1; // overwrite
2330 let Inst{19-16} = addr;
2331 let Inst{11-5} = offset{11-5};
2333 let Inst{3-0} = offset{3-0};
2334 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2337 def LDRBT_POST_IMM : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2338 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2339 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2340 "ldrbt", "\t$Rt, $addr, $offset",
2341 "$addr.base = $Rn_wb", []> {
2347 let Inst{23} = offset{12};
2348 let Inst{21} = 1; // overwrite
2349 let Inst{19-16} = addr;
2350 let Inst{11-0} = offset{11-0};
2351 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2354 multiclass AI3ldrT<bits<4> op, string opc> {
2355 def i : AI3ldstidxT<op, 1, (outs GPR:$Rt, GPR:$base_wb),
2356 (ins addr_offset_none:$addr, postidx_imm8:$offset),
2357 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2358 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2360 let Inst{23} = offset{8};
2362 let Inst{11-8} = offset{7-4};
2363 let Inst{3-0} = offset{3-0};
2364 let AsmMatchConverter = "cvtLdExtTWriteBackImm";
2366 def r : AI3ldstidxT<op, 1, (outs GPRnopc:$Rt, GPRnopc:$base_wb),
2367 (ins addr_offset_none:$addr, postidx_reg:$Rm),
2368 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2369 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2371 let Inst{23} = Rm{4};
2374 let Unpredictable{11-8} = 0b1111;
2375 let Inst{3-0} = Rm{3-0};
2376 let AsmMatchConverter = "cvtLdExtTWriteBackReg";
2377 let DecoderMethod = "DecodeLDR";
2381 defm LDRSBT : AI3ldrT<0b1101, "ldrsbt">;
2382 defm LDRHT : AI3ldrT<0b1011, "ldrht">;
2383 defm LDRSHT : AI3ldrT<0b1111, "ldrsht">;
2388 // Stores with truncate
2389 def STRH : AI3str<0b1011, (outs), (ins GPR:$Rt, addrmode3:$addr), StMiscFrm,
2390 IIC_iStore_bh_r, "strh", "\t$Rt, $addr",
2391 [(truncstorei16 GPR:$Rt, addrmode3:$addr)]>;
2394 let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in
2395 def STRD : AI3str<0b1111, (outs), (ins GPR:$Rt, GPR:$src2, addrmode3:$addr),
2396 StMiscFrm, IIC_iStore_d_r,
2397 "strd", "\t$Rt, $src2, $addr", []>,
2398 Requires<[IsARM, HasV5TE]> {
2403 multiclass AI2_stridx<bit isByte, string opc,
2404 InstrItinClass iii, InstrItinClass iir> {
2405 def _PRE_IMM : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2406 (ins GPR:$Rt, addrmode_imm12:$addr), IndexModePre,
2408 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2411 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2412 let Inst{19-16} = addr{16-13}; // Rn
2413 let Inst{11-0} = addr{11-0}; // imm12
2414 let AsmMatchConverter = "cvtStWriteBackRegAddrModeImm12";
2415 let DecoderMethod = "DecodeSTRPreImm";
2418 def _PRE_REG : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2419 (ins GPR:$Rt, ldst_so_reg:$addr),
2420 IndexModePre, StFrm, iir,
2421 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2424 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2425 let Inst{19-16} = addr{16-13}; // Rn
2426 let Inst{11-0} = addr{11-0};
2427 let Inst{4} = 0; // Inst{4} = 0
2428 let AsmMatchConverter = "cvtStWriteBackRegAddrMode2";
2429 let DecoderMethod = "DecodeSTRPreReg";
2431 def _POST_REG : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2432 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2433 IndexModePost, StFrm, iir,
2434 opc, "\t$Rt, $addr, $offset",
2435 "$addr.base = $Rn_wb", []> {
2441 let Inst{23} = offset{12};
2442 let Inst{19-16} = addr;
2443 let Inst{11-0} = offset{11-0};
2446 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2449 def _POST_IMM : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2450 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2451 IndexModePost, StFrm, iii,
2452 opc, "\t$Rt, $addr, $offset",
2453 "$addr.base = $Rn_wb", []> {
2459 let Inst{23} = offset{12};
2460 let Inst{19-16} = addr;
2461 let Inst{11-0} = offset{11-0};
2463 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2467 let mayStore = 1, neverHasSideEffects = 1 in {
2468 // FIXME: for STR_PRE_REG etc. the itineray should be either IIC_iStore_ru or
2469 // IIC_iStore_siu depending on whether it the offset register is shifted.
2470 defm STR : AI2_stridx<0, "str", IIC_iStore_iu, IIC_iStore_ru>;
2471 defm STRB : AI2_stridx<1, "strb", IIC_iStore_bh_iu, IIC_iStore_bh_ru>;
2474 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2475 am2offset_reg:$offset),
2476 (STR_POST_REG GPR:$Rt, addr_offset_none:$addr,
2477 am2offset_reg:$offset)>;
2478 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2479 am2offset_imm:$offset),
2480 (STR_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2481 am2offset_imm:$offset)>;
2482 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2483 am2offset_reg:$offset),
2484 (STRB_POST_REG GPR:$Rt, addr_offset_none:$addr,
2485 am2offset_reg:$offset)>;
2486 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2487 am2offset_imm:$offset),
2488 (STRB_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2489 am2offset_imm:$offset)>;
2491 // Pseudo-instructions for pattern matching the pre-indexed stores. We can't
2492 // put the patterns on the instruction definitions directly as ISel wants
2493 // the address base and offset to be separate operands, not a single
2494 // complex operand like we represent the instructions themselves. The
2495 // pseudos map between the two.
2496 let usesCustomInserter = 1,
2497 Constraints = "$Rn = $Rn_wb,@earlyclobber $Rn_wb" in {
2498 def STRi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2499 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2502 (pre_store GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2503 def STRr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2504 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2507 (pre_store GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2508 def STRBi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2509 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2512 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2513 def STRBr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2514 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2517 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2518 def STRH_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2519 (ins GPR:$Rt, GPR:$Rn, am3offset:$offset, pred:$p),
2522 (pre_truncsti16 GPR:$Rt, GPR:$Rn, am3offset:$offset))]>;
2527 def STRH_PRE : AI3ldstidx<0b1011, 0, 1, (outs GPR:$Rn_wb),
2528 (ins GPR:$Rt, addrmode3:$addr), IndexModePre,
2529 StMiscFrm, IIC_iStore_bh_ru,
2530 "strh", "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2532 let Inst{23} = addr{8}; // U bit
2533 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2534 let Inst{19-16} = addr{12-9}; // Rn
2535 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2536 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2537 let AsmMatchConverter = "cvtStWriteBackRegAddrMode3";
2538 let DecoderMethod = "DecodeAddrMode3Instruction";
2541 def STRH_POST : AI3ldstidx<0b1011, 0, 0, (outs GPR:$Rn_wb),
2542 (ins GPR:$Rt, addr_offset_none:$addr, am3offset:$offset),
2543 IndexModePost, StMiscFrm, IIC_iStore_bh_ru,
2544 "strh", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2545 [(set GPR:$Rn_wb, (post_truncsti16 GPR:$Rt,
2546 addr_offset_none:$addr,
2547 am3offset:$offset))]> {
2550 let Inst{23} = offset{8}; // U bit
2551 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2552 let Inst{19-16} = addr;
2553 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2554 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2555 let DecoderMethod = "DecodeAddrMode3Instruction";
2558 let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in {
2559 def STRD_PRE : AI3ldstidx<0b1111, 0, 1, (outs GPR:$Rn_wb),
2560 (ins GPR:$Rt, GPR:$Rt2, addrmode3:$addr),
2561 IndexModePre, StMiscFrm, IIC_iStore_d_ru,
2562 "strd", "\t$Rt, $Rt2, $addr!",
2563 "$addr.base = $Rn_wb", []> {
2565 let Inst{23} = addr{8}; // U bit
2566 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2567 let Inst{19-16} = addr{12-9}; // Rn
2568 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2569 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2570 let DecoderMethod = "DecodeAddrMode3Instruction";
2571 let AsmMatchConverter = "cvtStrdPre";
2574 def STRD_POST: AI3ldstidx<0b1111, 0, 0, (outs GPR:$Rn_wb),
2575 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr,
2577 IndexModePost, StMiscFrm, IIC_iStore_d_ru,
2578 "strd", "\t$Rt, $Rt2, $addr, $offset",
2579 "$addr.base = $Rn_wb", []> {
2582 let Inst{23} = offset{8}; // U bit
2583 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2584 let Inst{19-16} = addr;
2585 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2586 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2587 let DecoderMethod = "DecodeAddrMode3Instruction";
2589 } // mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1
2591 // STRT, STRBT, and STRHT
2593 def STRBT_POST_REG : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2594 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2595 IndexModePost, StFrm, IIC_iStore_bh_ru,
2596 "strbt", "\t$Rt, $addr, $offset",
2597 "$addr.base = $Rn_wb", []> {
2603 let Inst{23} = offset{12};
2604 let Inst{21} = 1; // overwrite
2605 let Inst{19-16} = addr;
2606 let Inst{11-5} = offset{11-5};
2608 let Inst{3-0} = offset{3-0};
2609 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2612 def STRBT_POST_IMM : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2613 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2614 IndexModePost, StFrm, IIC_iStore_bh_ru,
2615 "strbt", "\t$Rt, $addr, $offset",
2616 "$addr.base = $Rn_wb", []> {
2622 let Inst{23} = offset{12};
2623 let Inst{21} = 1; // overwrite
2624 let Inst{19-16} = addr;
2625 let Inst{11-0} = offset{11-0};
2626 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2629 let mayStore = 1, neverHasSideEffects = 1 in {
2630 def STRT_POST_REG : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
2631 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2632 IndexModePost, StFrm, IIC_iStore_ru,
2633 "strt", "\t$Rt, $addr, $offset",
2634 "$addr.base = $Rn_wb", []> {
2640 let Inst{23} = offset{12};
2641 let Inst{21} = 1; // overwrite
2642 let Inst{19-16} = addr;
2643 let Inst{11-5} = offset{11-5};
2645 let Inst{3-0} = offset{3-0};
2646 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2649 def STRT_POST_IMM : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
2650 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2651 IndexModePost, StFrm, IIC_iStore_ru,
2652 "strt", "\t$Rt, $addr, $offset",
2653 "$addr.base = $Rn_wb", []> {
2659 let Inst{23} = offset{12};
2660 let Inst{21} = 1; // overwrite
2661 let Inst{19-16} = addr;
2662 let Inst{11-0} = offset{11-0};
2663 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2668 multiclass AI3strT<bits<4> op, string opc> {
2669 def i : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
2670 (ins GPR:$Rt, addr_offset_none:$addr, postidx_imm8:$offset),
2671 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
2672 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2674 let Inst{23} = offset{8};
2676 let Inst{11-8} = offset{7-4};
2677 let Inst{3-0} = offset{3-0};
2678 let AsmMatchConverter = "cvtStExtTWriteBackImm";
2680 def r : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
2681 (ins GPR:$Rt, addr_offset_none:$addr, postidx_reg:$Rm),
2682 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
2683 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2685 let Inst{23} = Rm{4};
2688 let Inst{3-0} = Rm{3-0};
2689 let AsmMatchConverter = "cvtStExtTWriteBackReg";
2694 defm STRHT : AI3strT<0b1011, "strht">;
2697 //===----------------------------------------------------------------------===//
2698 // Load / store multiple Instructions.
2701 multiclass arm_ldst_mult<string asm, string sfx, bit L_bit, bit P_bit, Format f,
2702 InstrItinClass itin, InstrItinClass itin_upd> {
2703 // IA is the default, so no need for an explicit suffix on the
2704 // mnemonic here. Without it is the canonical spelling.
2706 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2707 IndexModeNone, f, itin,
2708 !strconcat(asm, "${p}\t$Rn, $regs", sfx), "", []> {
2709 let Inst{24-23} = 0b01; // Increment After
2710 let Inst{22} = P_bit;
2711 let Inst{21} = 0; // No writeback
2712 let Inst{20} = L_bit;
2715 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2716 IndexModeUpd, f, itin_upd,
2717 !strconcat(asm, "${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
2718 let Inst{24-23} = 0b01; // Increment After
2719 let Inst{22} = P_bit;
2720 let Inst{21} = 1; // Writeback
2721 let Inst{20} = L_bit;
2723 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2726 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2727 IndexModeNone, f, itin,
2728 !strconcat(asm, "da${p}\t$Rn, $regs", sfx), "", []> {
2729 let Inst{24-23} = 0b00; // Decrement After
2730 let Inst{22} = P_bit;
2731 let Inst{21} = 0; // No writeback
2732 let Inst{20} = L_bit;
2735 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2736 IndexModeUpd, f, itin_upd,
2737 !strconcat(asm, "da${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
2738 let Inst{24-23} = 0b00; // Decrement After
2739 let Inst{22} = P_bit;
2740 let Inst{21} = 1; // Writeback
2741 let Inst{20} = L_bit;
2743 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2746 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2747 IndexModeNone, f, itin,
2748 !strconcat(asm, "db${p}\t$Rn, $regs", sfx), "", []> {
2749 let Inst{24-23} = 0b10; // Decrement Before
2750 let Inst{22} = P_bit;
2751 let Inst{21} = 0; // No writeback
2752 let Inst{20} = L_bit;
2755 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2756 IndexModeUpd, f, itin_upd,
2757 !strconcat(asm, "db${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
2758 let Inst{24-23} = 0b10; // Decrement Before
2759 let Inst{22} = P_bit;
2760 let Inst{21} = 1; // Writeback
2761 let Inst{20} = L_bit;
2763 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2766 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2767 IndexModeNone, f, itin,
2768 !strconcat(asm, "ib${p}\t$Rn, $regs", sfx), "", []> {
2769 let Inst{24-23} = 0b11; // Increment Before
2770 let Inst{22} = P_bit;
2771 let Inst{21} = 0; // No writeback
2772 let Inst{20} = L_bit;
2775 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2776 IndexModeUpd, f, itin_upd,
2777 !strconcat(asm, "ib${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
2778 let Inst{24-23} = 0b11; // Increment Before
2779 let Inst{22} = P_bit;
2780 let Inst{21} = 1; // Writeback
2781 let Inst{20} = L_bit;
2783 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2787 let neverHasSideEffects = 1 in {
2789 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
2790 defm LDM : arm_ldst_mult<"ldm", "", 1, 0, LdStMulFrm, IIC_iLoad_m,
2793 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
2794 defm STM : arm_ldst_mult<"stm", "", 0, 0, LdStMulFrm, IIC_iStore_m,
2797 } // neverHasSideEffects
2799 // FIXME: remove when we have a way to marking a MI with these properties.
2800 // FIXME: Should pc be an implicit operand like PICADD, etc?
2801 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
2802 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
2803 def LDMIA_RET : ARMPseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p,
2804 reglist:$regs, variable_ops),
2805 4, IIC_iLoad_mBr, [],
2806 (LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>,
2807 RegConstraint<"$Rn = $wb">;
2809 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
2810 defm sysLDM : arm_ldst_mult<"ldm", " ^", 1, 1, LdStMulFrm, IIC_iLoad_m,
2813 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
2814 defm sysSTM : arm_ldst_mult<"stm", " ^", 0, 1, LdStMulFrm, IIC_iStore_m,
2819 //===----------------------------------------------------------------------===//
2820 // Move Instructions.
2823 let neverHasSideEffects = 1 in
2824 def MOVr : AsI1<0b1101, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMOVr,
2825 "mov", "\t$Rd, $Rm", []>, UnaryDP {
2829 let Inst{19-16} = 0b0000;
2830 let Inst{11-4} = 0b00000000;
2833 let Inst{15-12} = Rd;
2836 def : ARMInstAlias<"movs${p} $Rd, $Rm",
2837 (MOVr GPR:$Rd, GPR:$Rm, pred:$p, CPSR)>;
2839 // A version for the smaller set of tail call registers.
2840 let neverHasSideEffects = 1 in
2841 def MOVr_TC : AsI1<0b1101, (outs tcGPR:$Rd), (ins tcGPR:$Rm), DPFrm,
2842 IIC_iMOVr, "mov", "\t$Rd, $Rm", []>, UnaryDP {
2846 let Inst{11-4} = 0b00000000;
2849 let Inst{15-12} = Rd;
2852 def MOVsr : AsI1<0b1101, (outs GPRnopc:$Rd), (ins shift_so_reg_reg:$src),
2853 DPSoRegRegFrm, IIC_iMOVsr,
2854 "mov", "\t$Rd, $src",
2855 [(set GPRnopc:$Rd, shift_so_reg_reg:$src)]>, UnaryDP {
2858 let Inst{15-12} = Rd;
2859 let Inst{19-16} = 0b0000;
2860 let Inst{11-8} = src{11-8};
2862 let Inst{6-5} = src{6-5};
2864 let Inst{3-0} = src{3-0};
2868 def MOVsi : AsI1<0b1101, (outs GPR:$Rd), (ins shift_so_reg_imm:$src),
2869 DPSoRegImmFrm, IIC_iMOVsr,
2870 "mov", "\t$Rd, $src", [(set GPR:$Rd, shift_so_reg_imm:$src)]>,
2874 let Inst{15-12} = Rd;
2875 let Inst{19-16} = 0b0000;
2876 let Inst{11-5} = src{11-5};
2878 let Inst{3-0} = src{3-0};
2882 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
2883 def MOVi : AsI1<0b1101, (outs GPR:$Rd), (ins so_imm:$imm), DPFrm, IIC_iMOVi,
2884 "mov", "\t$Rd, $imm", [(set GPR:$Rd, so_imm:$imm)]>, UnaryDP {
2888 let Inst{15-12} = Rd;
2889 let Inst{19-16} = 0b0000;
2890 let Inst{11-0} = imm;
2893 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
2894 def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins imm0_65535_expr:$imm),
2896 "movw", "\t$Rd, $imm",
2897 [(set GPR:$Rd, imm0_65535:$imm)]>,
2898 Requires<[IsARM, HasV6T2]>, UnaryDP {
2901 let Inst{15-12} = Rd;
2902 let Inst{11-0} = imm{11-0};
2903 let Inst{19-16} = imm{15-12};
2906 let DecoderMethod = "DecodeArmMOVTWInstruction";
2909 def : InstAlias<"mov${p} $Rd, $imm",
2910 (MOVi16 GPR:$Rd, imm0_65535_expr:$imm, pred:$p)>,
2913 def MOVi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
2914 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>;
2916 let Constraints = "$src = $Rd" in {
2917 def MOVTi16 : AI1<0b1010, (outs GPRnopc:$Rd),
2918 (ins GPR:$src, imm0_65535_expr:$imm),
2920 "movt", "\t$Rd, $imm",
2922 (or (and GPR:$src, 0xffff),
2923 lo16AllZero:$imm))]>, UnaryDP,
2924 Requires<[IsARM, HasV6T2]> {
2927 let Inst{15-12} = Rd;
2928 let Inst{11-0} = imm{11-0};
2929 let Inst{19-16} = imm{15-12};
2932 let DecoderMethod = "DecodeArmMOVTWInstruction";
2935 def MOVTi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
2936 (ins GPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>;
2940 def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
2941 Requires<[IsARM, HasV6T2]>;
2943 let Uses = [CPSR] in
2944 def RRX: PseudoInst<(outs GPR:$Rd), (ins GPR:$Rm), IIC_iMOVsi,
2945 [(set GPR:$Rd, (ARMrrx GPR:$Rm))]>, UnaryDP,
2948 // These aren't really mov instructions, but we have to define them this way
2949 // due to flag operands.
2951 let Defs = [CPSR] in {
2952 def MOVsrl_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
2953 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP,
2955 def MOVsra_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
2956 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP,
2960 //===----------------------------------------------------------------------===//
2961 // Extend Instructions.
2966 def SXTB : AI_ext_rrot<0b01101010,
2967 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
2968 def SXTH : AI_ext_rrot<0b01101011,
2969 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
2971 def SXTAB : AI_exta_rrot<0b01101010,
2972 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
2973 def SXTAH : AI_exta_rrot<0b01101011,
2974 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
2976 def SXTB16 : AI_ext_rrot_np<0b01101000, "sxtb16">;
2978 def SXTAB16 : AI_exta_rrot_np<0b01101000, "sxtab16">;
2982 let AddedComplexity = 16 in {
2983 def UXTB : AI_ext_rrot<0b01101110,
2984 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
2985 def UXTH : AI_ext_rrot<0b01101111,
2986 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
2987 def UXTB16 : AI_ext_rrot<0b01101100,
2988 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
2990 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
2991 // The transformation should probably be done as a combiner action
2992 // instead so we can include a check for masking back in the upper
2993 // eight bits of the source into the lower eight bits of the result.
2994 //def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
2995 // (UXTB16r_rot GPR:$Src, 3)>;
2996 def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
2997 (UXTB16 GPR:$Src, 1)>;
2999 def UXTAB : AI_exta_rrot<0b01101110, "uxtab",
3000 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
3001 def UXTAH : AI_exta_rrot<0b01101111, "uxtah",
3002 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
3005 // This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
3006 def UXTAB16 : AI_exta_rrot_np<0b01101100, "uxtab16">;
3009 def SBFX : I<(outs GPRnopc:$Rd),
3010 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3011 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3012 "sbfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3013 Requires<[IsARM, HasV6T2]> {
3018 let Inst{27-21} = 0b0111101;
3019 let Inst{6-4} = 0b101;
3020 let Inst{20-16} = width;
3021 let Inst{15-12} = Rd;
3022 let Inst{11-7} = lsb;
3026 def UBFX : I<(outs GPR:$Rd),
3027 (ins GPR:$Rn, imm0_31:$lsb, imm1_32:$width),
3028 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3029 "ubfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3030 Requires<[IsARM, HasV6T2]> {
3035 let Inst{27-21} = 0b0111111;
3036 let Inst{6-4} = 0b101;
3037 let Inst{20-16} = width;
3038 let Inst{15-12} = Rd;
3039 let Inst{11-7} = lsb;
3043 //===----------------------------------------------------------------------===//
3044 // Arithmetic Instructions.
3047 defm ADD : AsI1_bin_irs<0b0100, "add",
3048 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3049 BinOpFrag<(add node:$LHS, node:$RHS)>, "ADD", 1>;
3050 defm SUB : AsI1_bin_irs<0b0010, "sub",
3051 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3052 BinOpFrag<(sub node:$LHS, node:$RHS)>, "SUB">;
3054 // ADD and SUB with 's' bit set.
3056 // Currently, ADDS/SUBS are pseudo opcodes that exist only in the
3057 // selection DAG. They are "lowered" to real ADD/SUB opcodes by
3058 // AdjustInstrPostInstrSelection where we determine whether or not to
3059 // set the "s" bit based on CPSR liveness.
3061 // FIXME: Eliminate ADDS/SUBS pseudo opcodes after adding tablegen
3062 // support for an optional CPSR definition that corresponds to the DAG
3063 // node's second value. We can then eliminate the implicit def of CPSR.
3064 defm ADDS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3065 BinOpFrag<(ARMaddc node:$LHS, node:$RHS)>, 1>;
3066 defm SUBS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3067 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
3069 defm ADC : AI1_adde_sube_irs<0b0101, "adc",
3070 BinOpWithFlagFrag<(ARMadde node:$LHS, node:$RHS, node:$FLAG)>,
3072 defm SBC : AI1_adde_sube_irs<0b0110, "sbc",
3073 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>,
3076 defm RSB : AsI1_rbin_irs <0b0011, "rsb",
3077 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3078 BinOpFrag<(sub node:$LHS, node:$RHS)>, "RSB">;
3080 // FIXME: Eliminate them if we can write def : Pat patterns which defines
3081 // CPSR and the implicit def of CPSR is not needed.
3082 defm RSBS : AsI1_rbin_s_is<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3083 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
3085 defm RSC : AI1_rsc_irs<0b0111, "rsc",
3086 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>,
3089 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
3090 // The assume-no-carry-in form uses the negation of the input since add/sub
3091 // assume opposite meanings of the carry flag (i.e., carry == !borrow).
3092 // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
3094 def : ARMPat<(add GPR:$src, so_imm_neg:$imm),
3095 (SUBri GPR:$src, so_imm_neg:$imm)>;
3096 def : ARMPat<(ARMaddc GPR:$src, so_imm_neg:$imm),
3097 (SUBSri GPR:$src, so_imm_neg:$imm)>;
3099 // The with-carry-in form matches bitwise not instead of the negation.
3100 // Effectively, the inverse interpretation of the carry flag already accounts
3101 // for part of the negation.
3102 def : ARMPat<(ARMadde GPR:$src, so_imm_not:$imm, CPSR),
3103 (SBCri GPR:$src, so_imm_not:$imm)>;
3105 // Note: These are implemented in C++ code, because they have to generate
3106 // ADD/SUBrs instructions, which use a complex pattern that a xform function
3108 // (mul X, 2^n+1) -> (add (X << n), X)
3109 // (mul X, 2^n-1) -> (rsb X, (X << n))
3111 // ARM Arithmetic Instruction
3112 // GPR:$dst = GPR:$a op GPR:$b
3113 class AAI<bits<8> op27_20, bits<8> op11_4, string opc,
3114 list<dag> pattern = [],
3115 dag iops = (ins GPRnopc:$Rn, GPRnopc:$Rm),
3116 string asm = "\t$Rd, $Rn, $Rm">
3117 : AI<(outs GPRnopc:$Rd), iops, DPFrm, IIC_iALUr, opc, asm, pattern> {
3121 let Inst{27-20} = op27_20;
3122 let Inst{11-4} = op11_4;
3123 let Inst{19-16} = Rn;
3124 let Inst{15-12} = Rd;
3127 let Unpredictable{11-8} = 0b1111;
3130 // Saturating add/subtract
3132 def QADD : AAI<0b00010000, 0b00000101, "qadd",
3133 [(set GPRnopc:$Rd, (int_arm_qadd GPRnopc:$Rm, GPRnopc:$Rn))],
3134 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3135 def QSUB : AAI<0b00010010, 0b00000101, "qsub",
3136 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm, GPRnopc:$Rn))],
3137 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3138 def QDADD : AAI<0b00010100, 0b00000101, "qdadd", [],
3139 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3141 def QDSUB : AAI<0b00010110, 0b00000101, "qdsub", [],
3142 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3145 def QADD16 : AAI<0b01100010, 0b11110001, "qadd16">;
3146 def QADD8 : AAI<0b01100010, 0b11111001, "qadd8">;
3147 def QASX : AAI<0b01100010, 0b11110011, "qasx">;
3148 def QSAX : AAI<0b01100010, 0b11110101, "qsax">;
3149 def QSUB16 : AAI<0b01100010, 0b11110111, "qsub16">;
3150 def QSUB8 : AAI<0b01100010, 0b11111111, "qsub8">;
3151 def UQADD16 : AAI<0b01100110, 0b11110001, "uqadd16">;
3152 def UQADD8 : AAI<0b01100110, 0b11111001, "uqadd8">;
3153 def UQASX : AAI<0b01100110, 0b11110011, "uqasx">;
3154 def UQSAX : AAI<0b01100110, 0b11110101, "uqsax">;
3155 def UQSUB16 : AAI<0b01100110, 0b11110111, "uqsub16">;
3156 def UQSUB8 : AAI<0b01100110, 0b11111111, "uqsub8">;
3158 // Signed/Unsigned add/subtract
3160 def SASX : AAI<0b01100001, 0b11110011, "sasx">;
3161 def SADD16 : AAI<0b01100001, 0b11110001, "sadd16">;
3162 def SADD8 : AAI<0b01100001, 0b11111001, "sadd8">;
3163 def SSAX : AAI<0b01100001, 0b11110101, "ssax">;
3164 def SSUB16 : AAI<0b01100001, 0b11110111, "ssub16">;
3165 def SSUB8 : AAI<0b01100001, 0b11111111, "ssub8">;
3166 def UASX : AAI<0b01100101, 0b11110011, "uasx">;
3167 def UADD16 : AAI<0b01100101, 0b11110001, "uadd16">;
3168 def UADD8 : AAI<0b01100101, 0b11111001, "uadd8">;
3169 def USAX : AAI<0b01100101, 0b11110101, "usax">;
3170 def USUB16 : AAI<0b01100101, 0b11110111, "usub16">;
3171 def USUB8 : AAI<0b01100101, 0b11111111, "usub8">;
3173 // Signed/Unsigned halving add/subtract
3175 def SHASX : AAI<0b01100011, 0b11110011, "shasx">;
3176 def SHADD16 : AAI<0b01100011, 0b11110001, "shadd16">;
3177 def SHADD8 : AAI<0b01100011, 0b11111001, "shadd8">;
3178 def SHSAX : AAI<0b01100011, 0b11110101, "shsax">;
3179 def SHSUB16 : AAI<0b01100011, 0b11110111, "shsub16">;
3180 def SHSUB8 : AAI<0b01100011, 0b11111111, "shsub8">;
3181 def UHASX : AAI<0b01100111, 0b11110011, "uhasx">;
3182 def UHADD16 : AAI<0b01100111, 0b11110001, "uhadd16">;
3183 def UHADD8 : AAI<0b01100111, 0b11111001, "uhadd8">;
3184 def UHSAX : AAI<0b01100111, 0b11110101, "uhsax">;
3185 def UHSUB16 : AAI<0b01100111, 0b11110111, "uhsub16">;
3186 def UHSUB8 : AAI<0b01100111, 0b11111111, "uhsub8">;
3188 // Unsigned Sum of Absolute Differences [and Accumulate].
3190 def USAD8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3191 MulFrm /* for convenience */, NoItinerary, "usad8",
3192 "\t$Rd, $Rn, $Rm", []>,
3193 Requires<[IsARM, HasV6]> {
3197 let Inst{27-20} = 0b01111000;
3198 let Inst{15-12} = 0b1111;
3199 let Inst{7-4} = 0b0001;
3200 let Inst{19-16} = Rd;
3201 let Inst{11-8} = Rm;
3204 def USADA8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3205 MulFrm /* for convenience */, NoItinerary, "usada8",
3206 "\t$Rd, $Rn, $Rm, $Ra", []>,
3207 Requires<[IsARM, HasV6]> {
3212 let Inst{27-20} = 0b01111000;
3213 let Inst{7-4} = 0b0001;
3214 let Inst{19-16} = Rd;
3215 let Inst{15-12} = Ra;
3216 let Inst{11-8} = Rm;
3220 // Signed/Unsigned saturate
3222 def SSAT : AI<(outs GPRnopc:$Rd),
3223 (ins imm1_32:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3224 SatFrm, NoItinerary, "ssat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3229 let Inst{27-21} = 0b0110101;
3230 let Inst{5-4} = 0b01;
3231 let Inst{20-16} = sat_imm;
3232 let Inst{15-12} = Rd;
3233 let Inst{11-7} = sh{4-0};
3234 let Inst{6} = sh{5};
3238 def SSAT16 : AI<(outs GPRnopc:$Rd),
3239 (ins imm1_16:$sat_imm, GPRnopc:$Rn), SatFrm,
3240 NoItinerary, "ssat16", "\t$Rd, $sat_imm, $Rn", []> {
3244 let Inst{27-20} = 0b01101010;
3245 let Inst{11-4} = 0b11110011;
3246 let Inst{15-12} = Rd;
3247 let Inst{19-16} = sat_imm;
3251 def USAT : AI<(outs GPRnopc:$Rd),
3252 (ins imm0_31:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3253 SatFrm, NoItinerary, "usat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3258 let Inst{27-21} = 0b0110111;
3259 let Inst{5-4} = 0b01;
3260 let Inst{15-12} = Rd;
3261 let Inst{11-7} = sh{4-0};
3262 let Inst{6} = sh{5};
3263 let Inst{20-16} = sat_imm;
3267 def USAT16 : AI<(outs GPRnopc:$Rd),
3268 (ins imm0_15:$sat_imm, GPRnopc:$Rn), SatFrm,
3269 NoItinerary, "usat16", "\t$Rd, $sat_imm, $Rn", []> {
3273 let Inst{27-20} = 0b01101110;
3274 let Inst{11-4} = 0b11110011;
3275 let Inst{15-12} = Rd;
3276 let Inst{19-16} = sat_imm;
3280 def : ARMV6Pat<(int_arm_ssat GPRnopc:$a, imm:$pos),
3281 (SSAT imm:$pos, GPRnopc:$a, 0)>;
3282 def : ARMV6Pat<(int_arm_usat GPRnopc:$a, imm:$pos),
3283 (USAT imm:$pos, GPRnopc:$a, 0)>;
3285 //===----------------------------------------------------------------------===//
3286 // Bitwise Instructions.
3289 defm AND : AsI1_bin_irs<0b0000, "and",
3290 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3291 BinOpFrag<(and node:$LHS, node:$RHS)>, "AND", 1>;
3292 defm ORR : AsI1_bin_irs<0b1100, "orr",
3293 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3294 BinOpFrag<(or node:$LHS, node:$RHS)>, "ORR", 1>;
3295 defm EOR : AsI1_bin_irs<0b0001, "eor",
3296 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3297 BinOpFrag<(xor node:$LHS, node:$RHS)>, "EOR", 1>;
3298 defm BIC : AsI1_bin_irs<0b1110, "bic",
3299 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3300 BinOpFrag<(and node:$LHS, (not node:$RHS))>, "BIC">;
3302 // FIXME: bf_inv_mask_imm should be two operands, the lsb and the msb, just
3303 // like in the actual instruction encoding. The complexity of mapping the mask
3304 // to the lsb/msb pair should be handled by ISel, not encapsulated in the
3305 // instruction description.
3306 def BFC : I<(outs GPR:$Rd), (ins GPR:$src, bf_inv_mask_imm:$imm),
3307 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3308 "bfc", "\t$Rd, $imm", "$src = $Rd",
3309 [(set GPR:$Rd, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
3310 Requires<[IsARM, HasV6T2]> {
3313 let Inst{27-21} = 0b0111110;
3314 let Inst{6-0} = 0b0011111;
3315 let Inst{15-12} = Rd;
3316 let Inst{11-7} = imm{4-0}; // lsb
3317 let Inst{20-16} = imm{9-5}; // msb
3320 // A8.6.18 BFI - Bitfield insert (Encoding A1)
3321 def BFI:I<(outs GPRnopc:$Rd), (ins GPRnopc:$src, GPR:$Rn, bf_inv_mask_imm:$imm),
3322 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3323 "bfi", "\t$Rd, $Rn, $imm", "$src = $Rd",
3324 [(set GPRnopc:$Rd, (ARMbfi GPRnopc:$src, GPR:$Rn,
3325 bf_inv_mask_imm:$imm))]>,
3326 Requires<[IsARM, HasV6T2]> {
3330 let Inst{27-21} = 0b0111110;
3331 let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15
3332 let Inst{15-12} = Rd;
3333 let Inst{11-7} = imm{4-0}; // lsb
3334 let Inst{20-16} = imm{9-5}; // width
3338 def MVNr : AsI1<0b1111, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMVNr,
3339 "mvn", "\t$Rd, $Rm",
3340 [(set GPR:$Rd, (not GPR:$Rm))]>, UnaryDP {
3344 let Inst{19-16} = 0b0000;
3345 let Inst{11-4} = 0b00000000;
3346 let Inst{15-12} = Rd;
3349 def MVNsi : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_imm:$shift),
3350 DPSoRegImmFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3351 [(set GPR:$Rd, (not so_reg_imm:$shift))]>, UnaryDP {
3355 let Inst{19-16} = 0b0000;
3356 let Inst{15-12} = Rd;
3357 let Inst{11-5} = shift{11-5};
3359 let Inst{3-0} = shift{3-0};
3361 def MVNsr : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_reg:$shift),
3362 DPSoRegRegFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3363 [(set GPR:$Rd, (not so_reg_reg:$shift))]>, UnaryDP {
3367 let Inst{19-16} = 0b0000;
3368 let Inst{15-12} = Rd;
3369 let Inst{11-8} = shift{11-8};
3371 let Inst{6-5} = shift{6-5};
3373 let Inst{3-0} = shift{3-0};
3375 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3376 def MVNi : AsI1<0b1111, (outs GPR:$Rd), (ins so_imm:$imm), DPFrm,
3377 IIC_iMVNi, "mvn", "\t$Rd, $imm",
3378 [(set GPR:$Rd, so_imm_not:$imm)]>,UnaryDP {
3382 let Inst{19-16} = 0b0000;
3383 let Inst{15-12} = Rd;
3384 let Inst{11-0} = imm;
3387 def : ARMPat<(and GPR:$src, so_imm_not:$imm),
3388 (BICri GPR:$src, so_imm_not:$imm)>;
3390 //===----------------------------------------------------------------------===//
3391 // Multiply Instructions.
3393 class AsMul1I32<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3394 string opc, string asm, list<dag> pattern>
3395 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3399 let Inst{19-16} = Rd;
3400 let Inst{11-8} = Rm;
3403 class AsMul1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3404 string opc, string asm, list<dag> pattern>
3405 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3410 let Inst{19-16} = RdHi;
3411 let Inst{15-12} = RdLo;
3412 let Inst{11-8} = Rm;
3416 // FIXME: The v5 pseudos are only necessary for the additional Constraint
3417 // property. Remove them when it's possible to add those properties
3418 // on an individual MachineInstr, not just an instruction description.
3419 let isCommutable = 1, TwoOperandAliasConstraint = "$Rn = $Rd" in {
3420 def MUL : AsMul1I32<0b0000000, (outs GPRnopc:$Rd),
3421 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3422 IIC_iMUL32, "mul", "\t$Rd, $Rn, $Rm",
3423 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))]>,
3424 Requires<[IsARM, HasV6]> {
3425 let Inst{15-12} = 0b0000;
3426 let Unpredictable{15-12} = 0b1111;
3429 let Constraints = "@earlyclobber $Rd" in
3430 def MULv5: ARMPseudoExpand<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm,
3431 pred:$p, cc_out:$s),
3433 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))],
3434 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s)>,
3435 Requires<[IsARM, NoV6]>;
3438 def MLA : AsMul1I32<0b0000001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3439 IIC_iMAC32, "mla", "\t$Rd, $Rn, $Rm, $Ra",
3440 [(set GPR:$Rd, (add (mul GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
3441 Requires<[IsARM, HasV6]> {
3443 let Inst{15-12} = Ra;
3446 let Constraints = "@earlyclobber $Rd" in
3447 def MLAv5: ARMPseudoExpand<(outs GPR:$Rd),
3448 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra, pred:$p, cc_out:$s),
3450 [(set GPR:$Rd, (add (mul GPR:$Rn, GPR:$Rm), GPR:$Ra))],
3451 (MLA GPR:$Rd, GPR:$Rn, GPR:$Rm, GPR:$Ra, pred:$p, cc_out:$s)>,
3452 Requires<[IsARM, NoV6]>;
3454 def MLS : AMul1I<0b0000011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3455 IIC_iMAC32, "mls", "\t$Rd, $Rn, $Rm, $Ra",
3456 [(set GPR:$Rd, (sub GPR:$Ra, (mul GPR:$Rn, GPR:$Rm)))]>,
3457 Requires<[IsARM, HasV6T2]> {
3462 let Inst{19-16} = Rd;
3463 let Inst{15-12} = Ra;
3464 let Inst{11-8} = Rm;
3468 // Extra precision multiplies with low / high results
3469 let neverHasSideEffects = 1 in {
3470 let isCommutable = 1 in {
3471 def SMULL : AsMul1I64<0b0000110, (outs GPR:$RdLo, GPR:$RdHi),
3472 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3473 "smull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3474 Requires<[IsARM, HasV6]>;
3476 def UMULL : AsMul1I64<0b0000100, (outs GPR:$RdLo, GPR:$RdHi),
3477 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3478 "umull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3479 Requires<[IsARM, HasV6]>;
3481 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
3482 def SMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3483 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3485 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3486 Requires<[IsARM, NoV6]>;
3488 def UMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3489 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3491 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3492 Requires<[IsARM, NoV6]>;
3496 // Multiply + accumulate
3497 def SMLAL : AsMul1I64<0b0000111, (outs GPR:$RdLo, GPR:$RdHi),
3498 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3499 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3500 Requires<[IsARM, HasV6]>;
3501 def UMLAL : AsMul1I64<0b0000101, (outs GPR:$RdLo, GPR:$RdHi),
3502 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3503 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3504 Requires<[IsARM, HasV6]>;
3506 def UMAAL : AMul1I <0b0000010, (outs GPR:$RdLo, GPR:$RdHi),
3507 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3508 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3509 Requires<[IsARM, HasV6]> {
3514 let Inst{19-16} = RdHi;
3515 let Inst{15-12} = RdLo;
3516 let Inst{11-8} = Rm;
3520 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
3521 def SMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3522 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3524 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3525 Requires<[IsARM, NoV6]>;
3526 def UMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3527 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3529 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3530 Requires<[IsARM, NoV6]>;
3531 def UMAALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3532 (ins GPR:$Rn, GPR:$Rm, pred:$p),
3534 (UMAAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p)>,
3535 Requires<[IsARM, NoV6]>;
3538 } // neverHasSideEffects
3540 // Most significant word multiply
3541 def SMMUL : AMul2I <0b0111010, 0b0001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3542 IIC_iMUL32, "smmul", "\t$Rd, $Rn, $Rm",
3543 [(set GPR:$Rd, (mulhs GPR:$Rn, GPR:$Rm))]>,
3544 Requires<[IsARM, HasV6]> {
3545 let Inst{15-12} = 0b1111;
3548 def SMMULR : AMul2I <0b0111010, 0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3549 IIC_iMUL32, "smmulr", "\t$Rd, $Rn, $Rm", []>,
3550 Requires<[IsARM, HasV6]> {
3551 let Inst{15-12} = 0b1111;
3554 def SMMLA : AMul2Ia <0b0111010, 0b0001, (outs GPR:$Rd),
3555 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3556 IIC_iMAC32, "smmla", "\t$Rd, $Rn, $Rm, $Ra",
3557 [(set GPR:$Rd, (add (mulhs GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
3558 Requires<[IsARM, HasV6]>;
3560 def SMMLAR : AMul2Ia <0b0111010, 0b0011, (outs GPR:$Rd),
3561 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3562 IIC_iMAC32, "smmlar", "\t$Rd, $Rn, $Rm, $Ra", []>,
3563 Requires<[IsARM, HasV6]>;
3565 def SMMLS : AMul2Ia <0b0111010, 0b1101, (outs GPR:$Rd),
3566 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3567 IIC_iMAC32, "smmls", "\t$Rd, $Rn, $Rm, $Ra", []>,
3568 Requires<[IsARM, HasV6]>;
3570 def SMMLSR : AMul2Ia <0b0111010, 0b1111, (outs GPR:$Rd),
3571 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3572 IIC_iMAC32, "smmlsr", "\t$Rd, $Rn, $Rm, $Ra", []>,
3573 Requires<[IsARM, HasV6]>;
3575 multiclass AI_smul<string opc, PatFrag opnode> {
3576 def BB : AMulxyI<0b0001011, 0b00, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3577 IIC_iMUL16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm",
3578 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3579 (sext_inreg GPR:$Rm, i16)))]>,
3580 Requires<[IsARM, HasV5TE]>;
3582 def BT : AMulxyI<0b0001011, 0b10, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3583 IIC_iMUL16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm",
3584 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3585 (sra GPR:$Rm, (i32 16))))]>,
3586 Requires<[IsARM, HasV5TE]>;
3588 def TB : AMulxyI<0b0001011, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3589 IIC_iMUL16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm",
3590 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3591 (sext_inreg GPR:$Rm, i16)))]>,
3592 Requires<[IsARM, HasV5TE]>;
3594 def TT : AMulxyI<0b0001011, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3595 IIC_iMUL16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm",
3596 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3597 (sra GPR:$Rm, (i32 16))))]>,
3598 Requires<[IsARM, HasV5TE]>;
3600 def WB : AMulxyI<0b0001001, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3601 IIC_iMUL16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm",
3602 [(set GPR:$Rd, (sra (opnode GPR:$Rn,
3603 (sext_inreg GPR:$Rm, i16)), (i32 16)))]>,
3604 Requires<[IsARM, HasV5TE]>;
3606 def WT : AMulxyI<0b0001001, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3607 IIC_iMUL16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm",
3608 [(set GPR:$Rd, (sra (opnode GPR:$Rn,
3609 (sra GPR:$Rm, (i32 16))), (i32 16)))]>,
3610 Requires<[IsARM, HasV5TE]>;
3614 multiclass AI_smla<string opc, PatFrag opnode> {
3615 let DecoderMethod = "DecodeSMLAInstruction" in {
3616 def BB : AMulxyIa<0b0001000, 0b00, (outs GPRnopc:$Rd),
3617 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3618 IIC_iMAC16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra",
3619 [(set GPRnopc:$Rd, (add GPR:$Ra,
3620 (opnode (sext_inreg GPRnopc:$Rn, i16),
3621 (sext_inreg GPRnopc:$Rm, i16))))]>,
3622 Requires<[IsARM, HasV5TE]>;
3624 def BT : AMulxyIa<0b0001000, 0b10, (outs GPRnopc:$Rd),
3625 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3626 IIC_iMAC16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra",
3628 (add GPR:$Ra, (opnode (sext_inreg GPRnopc:$Rn, i16),
3629 (sra GPRnopc:$Rm, (i32 16)))))]>,
3630 Requires<[IsARM, HasV5TE]>;
3632 def TB : AMulxyIa<0b0001000, 0b01, (outs GPRnopc:$Rd),
3633 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3634 IIC_iMAC16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra",
3636 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
3637 (sext_inreg GPRnopc:$Rm, i16))))]>,
3638 Requires<[IsARM, HasV5TE]>;
3640 def TT : AMulxyIa<0b0001000, 0b11, (outs GPRnopc:$Rd),
3641 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3642 IIC_iMAC16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra",
3644 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
3645 (sra GPRnopc:$Rm, (i32 16)))))]>,
3646 Requires<[IsARM, HasV5TE]>;
3648 def WB : AMulxyIa<0b0001001, 0b00, (outs GPRnopc:$Rd),
3649 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3650 IIC_iMAC16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra",
3652 (add GPR:$Ra, (sra (opnode GPRnopc:$Rn,
3653 (sext_inreg GPRnopc:$Rm, i16)), (i32 16))))]>,
3654 Requires<[IsARM, HasV5TE]>;
3656 def WT : AMulxyIa<0b0001001, 0b10, (outs GPRnopc:$Rd),
3657 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3658 IIC_iMAC16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra",
3660 (add GPR:$Ra, (sra (opnode GPRnopc:$Rn,
3661 (sra GPRnopc:$Rm, (i32 16))), (i32 16))))]>,
3662 Requires<[IsARM, HasV5TE]>;
3666 defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
3667 defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
3669 // Halfword multiply accumulate long: SMLAL<x><y>.
3670 def SMLALBB : AMulxyI64<0b0001010, 0b00, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3671 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3672 IIC_iMAC64, "smlalbb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3673 Requires<[IsARM, HasV5TE]>;
3675 def SMLALBT : AMulxyI64<0b0001010, 0b10, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3676 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3677 IIC_iMAC64, "smlalbt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3678 Requires<[IsARM, HasV5TE]>;
3680 def SMLALTB : AMulxyI64<0b0001010, 0b01, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3681 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3682 IIC_iMAC64, "smlaltb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3683 Requires<[IsARM, HasV5TE]>;
3685 def SMLALTT : AMulxyI64<0b0001010, 0b11, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3686 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3687 IIC_iMAC64, "smlaltt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3688 Requires<[IsARM, HasV5TE]>;
3690 // Helper class for AI_smld.
3691 class AMulDualIbase<bit long, bit sub, bit swap, dag oops, dag iops,
3692 InstrItinClass itin, string opc, string asm>
3693 : AI<oops, iops, MulFrm, itin, opc, asm, []>, Requires<[IsARM, HasV6]> {
3696 let Inst{27-23} = 0b01110;
3697 let Inst{22} = long;
3698 let Inst{21-20} = 0b00;
3699 let Inst{11-8} = Rm;
3706 class AMulDualI<bit long, bit sub, bit swap, dag oops, dag iops,
3707 InstrItinClass itin, string opc, string asm>
3708 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
3710 let Inst{15-12} = 0b1111;
3711 let Inst{19-16} = Rd;
3713 class AMulDualIa<bit long, bit sub, bit swap, dag oops, dag iops,
3714 InstrItinClass itin, string opc, string asm>
3715 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
3718 let Inst{19-16} = Rd;
3719 let Inst{15-12} = Ra;
3721 class AMulDualI64<bit long, bit sub, bit swap, dag oops, dag iops,
3722 InstrItinClass itin, string opc, string asm>
3723 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
3726 let Inst{19-16} = RdHi;
3727 let Inst{15-12} = RdLo;
3730 multiclass AI_smld<bit sub, string opc> {
3732 def D : AMulDualIa<0, sub, 0, (outs GPRnopc:$Rd),
3733 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3734 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm, $Ra">;
3736 def DX: AMulDualIa<0, sub, 1, (outs GPRnopc:$Rd),
3737 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3738 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm, $Ra">;
3740 def LD: AMulDualI64<1, sub, 0, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3741 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
3742 !strconcat(opc, "ld"), "\t$RdLo, $RdHi, $Rn, $Rm">;
3744 def LDX : AMulDualI64<1, sub, 1, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3745 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
3746 !strconcat(opc, "ldx"),"\t$RdLo, $RdHi, $Rn, $Rm">;
3750 defm SMLA : AI_smld<0, "smla">;
3751 defm SMLS : AI_smld<1, "smls">;
3753 multiclass AI_sdml<bit sub, string opc> {
3755 def D:AMulDualI<0, sub, 0, (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm),
3756 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm">;
3757 def DX:AMulDualI<0, sub, 1, (outs GPRnopc:$Rd),(ins GPRnopc:$Rn, GPRnopc:$Rm),
3758 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm">;
3761 defm SMUA : AI_sdml<0, "smua">;
3762 defm SMUS : AI_sdml<1, "smus">;
3764 //===----------------------------------------------------------------------===//
3765 // Misc. Arithmetic Instructions.
3768 def CLZ : AMiscA1I<0b000010110, 0b0001, (outs GPR:$Rd), (ins GPR:$Rm),
3769 IIC_iUNAr, "clz", "\t$Rd, $Rm",
3770 [(set GPR:$Rd, (ctlz GPR:$Rm))]>, Requires<[IsARM, HasV5T]>;
3772 def RBIT : AMiscA1I<0b01101111, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
3773 IIC_iUNAr, "rbit", "\t$Rd, $Rm",
3774 [(set GPR:$Rd, (ARMrbit GPR:$Rm))]>,
3775 Requires<[IsARM, HasV6T2]>;
3777 def REV : AMiscA1I<0b01101011, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
3778 IIC_iUNAr, "rev", "\t$Rd, $Rm",
3779 [(set GPR:$Rd, (bswap GPR:$Rm))]>, Requires<[IsARM, HasV6]>;
3781 let AddedComplexity = 5 in
3782 def REV16 : AMiscA1I<0b01101011, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
3783 IIC_iUNAr, "rev16", "\t$Rd, $Rm",
3784 [(set GPR:$Rd, (rotr (bswap GPR:$Rm), (i32 16)))]>,
3785 Requires<[IsARM, HasV6]>;
3787 let AddedComplexity = 5 in
3788 def REVSH : AMiscA1I<0b01101111, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
3789 IIC_iUNAr, "revsh", "\t$Rd, $Rm",
3790 [(set GPR:$Rd, (sra (bswap GPR:$Rm), (i32 16)))]>,
3791 Requires<[IsARM, HasV6]>;
3793 def : ARMV6Pat<(or (sra (shl GPR:$Rm, (i32 24)), (i32 16)),
3794 (and (srl GPR:$Rm, (i32 8)), 0xFF)),
3797 def PKHBT : APKHI<0b01101000, 0, (outs GPRnopc:$Rd),
3798 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_lsl_amt:$sh),
3799 IIC_iALUsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh",
3800 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF),
3801 (and (shl GPRnopc:$Rm, pkh_lsl_amt:$sh),
3803 Requires<[IsARM, HasV6]>;
3805 // Alternate cases for PKHBT where identities eliminate some nodes.
3806 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (and GPRnopc:$Rm, 0xFFFF0000)),
3807 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, 0)>;
3808 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (shl GPRnopc:$Rm, imm16_31:$sh)),
3809 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, imm16_31:$sh)>;
3811 // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
3812 // will match the pattern below.
3813 def PKHTB : APKHI<0b01101000, 1, (outs GPRnopc:$Rd),
3814 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_asr_amt:$sh),
3815 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh",
3816 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF0000),
3817 (and (sra GPRnopc:$Rm, pkh_asr_amt:$sh),
3819 Requires<[IsARM, HasV6]>;
3821 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
3822 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
3823 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
3824 (srl GPRnopc:$src2, imm16_31:$sh)),
3825 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16_31:$sh)>;
3826 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
3827 (and (srl GPRnopc:$src2, imm1_15:$sh), 0xFFFF)),
3828 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm1_15:$sh)>;
3830 //===----------------------------------------------------------------------===//
3831 // Comparison Instructions...
3834 defm CMP : AI1_cmp_irs<0b1010, "cmp",
3835 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
3836 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
3838 // ARMcmpZ can re-use the above instruction definitions.
3839 def : ARMPat<(ARMcmpZ GPR:$src, so_imm:$imm),
3840 (CMPri GPR:$src, so_imm:$imm)>;
3841 def : ARMPat<(ARMcmpZ GPR:$src, GPR:$rhs),
3842 (CMPrr GPR:$src, GPR:$rhs)>;
3843 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_imm:$rhs),
3844 (CMPrsi GPR:$src, so_reg_imm:$rhs)>;
3845 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_reg:$rhs),
3846 (CMPrsr GPR:$src, so_reg_reg:$rhs)>;
3848 // CMN register-integer
3849 let isCompare = 1, Defs = [CPSR] in {
3850 def CMNri : AI1<0b1011, (outs), (ins GPR:$Rn, so_imm:$imm), DPFrm, IIC_iCMPi,
3851 "cmn", "\t$Rn, $imm",
3852 [(ARMcmn GPR:$Rn, so_imm:$imm)]> {
3857 let Inst{19-16} = Rn;
3858 let Inst{15-12} = 0b0000;
3859 let Inst{11-0} = imm;
3861 let Unpredictable{15-12} = 0b1111;
3864 // CMN register-register/shift
3865 def CMNzrr : AI1<0b1011, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, IIC_iCMPr,
3866 "cmn", "\t$Rn, $Rm",
3867 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
3868 GPR:$Rn, GPR:$Rm)]> {
3871 let isCommutable = 1;
3874 let Inst{19-16} = Rn;
3875 let Inst{15-12} = 0b0000;
3876 let Inst{11-4} = 0b00000000;
3879 let Unpredictable{15-12} = 0b1111;
3882 def CMNzrsi : AI1<0b1011, (outs),
3883 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, IIC_iCMPsr,
3884 "cmn", "\t$Rn, $shift",
3885 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
3886 GPR:$Rn, so_reg_imm:$shift)]> {
3891 let Inst{19-16} = Rn;
3892 let Inst{15-12} = 0b0000;
3893 let Inst{11-5} = shift{11-5};
3895 let Inst{3-0} = shift{3-0};
3897 let Unpredictable{15-12} = 0b1111;
3900 def CMNzrsr : AI1<0b1011, (outs),
3901 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, IIC_iCMPsr,
3902 "cmn", "\t$Rn, $shift",
3903 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
3904 GPRnopc:$Rn, so_reg_reg:$shift)]> {
3909 let Inst{19-16} = Rn;
3910 let Inst{15-12} = 0b0000;
3911 let Inst{11-8} = shift{11-8};
3913 let Inst{6-5} = shift{6-5};
3915 let Inst{3-0} = shift{3-0};
3917 let Unpredictable{15-12} = 0b1111;
3922 def : ARMPat<(ARMcmp GPR:$src, so_imm_neg:$imm),
3923 (CMNri GPR:$src, so_imm_neg:$imm)>;
3925 def : ARMPat<(ARMcmpZ GPR:$src, so_imm_neg:$imm),
3926 (CMNri GPR:$src, so_imm_neg:$imm)>;
3928 // Note that TST/TEQ don't set all the same flags that CMP does!
3929 defm TST : AI1_cmp_irs<0b1000, "tst",
3930 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
3931 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>, 1>;
3932 defm TEQ : AI1_cmp_irs<0b1001, "teq",
3933 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
3934 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>, 1>;
3936 // Pseudo i64 compares for some floating point compares.
3937 let usesCustomInserter = 1, isBranch = 1, isTerminator = 1,
3939 def BCCi64 : PseudoInst<(outs),
3940 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, brtarget:$dst),
3942 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, bb:$dst)]>;
3944 def BCCZi64 : PseudoInst<(outs),
3945 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, brtarget:$dst), IIC_Br,
3946 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, 0, 0, bb:$dst)]>;
3947 } // usesCustomInserter
3950 // Conditional moves
3951 // FIXME: should be able to write a pattern for ARMcmov, but can't use
3952 // a two-value operand where a dag node expects two operands. :(
3953 let neverHasSideEffects = 1 in {
3955 let isCommutable = 1 in
3956 def MOVCCr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$false, GPR:$Rm, pred:$p),
3958 [/*(set GPR:$Rd, (ARMcmov GPR:$false, GPR:$Rm, imm:$cc, CCR:$ccr))*/]>,
3959 RegConstraint<"$false = $Rd">;
3961 def MOVCCsi : ARMPseudoInst<(outs GPR:$Rd),
3962 (ins GPR:$false, so_reg_imm:$shift, pred:$p),
3964 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_imm:$shift,
3965 imm:$cc, CCR:$ccr))*/]>,
3966 RegConstraint<"$false = $Rd">;
3967 def MOVCCsr : ARMPseudoInst<(outs GPR:$Rd),
3968 (ins GPR:$false, so_reg_reg:$shift, pred:$p),
3970 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_reg:$shift,
3971 imm:$cc, CCR:$ccr))*/]>,
3972 RegConstraint<"$false = $Rd">;
3975 let isMoveImm = 1 in
3976 def MOVCCi16 : ARMPseudoInst<(outs GPR:$Rd),
3977 (ins GPR:$false, imm0_65535_expr:$imm, pred:$p),
3980 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>;
3982 let isMoveImm = 1 in
3983 def MOVCCi : ARMPseudoInst<(outs GPR:$Rd),
3984 (ins GPR:$false, so_imm:$imm, pred:$p),
3986 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_imm:$imm, imm:$cc, CCR:$ccr))*/]>,
3987 RegConstraint<"$false = $Rd">;
3989 // Two instruction predicate mov immediate.
3990 let isMoveImm = 1 in
3991 def MOVCCi32imm : ARMPseudoInst<(outs GPR:$Rd),
3992 (ins GPR:$false, i32imm:$src, pred:$p),
3993 8, IIC_iCMOVix2, []>, RegConstraint<"$false = $Rd">;
3995 let isMoveImm = 1 in
3996 def MVNCCi : ARMPseudoInst<(outs GPR:$Rd),
3997 (ins GPR:$false, so_imm:$imm, pred:$p),
3999 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_imm_not:$imm, imm:$cc, CCR:$ccr))*/]>,
4000 RegConstraint<"$false = $Rd">;
4002 // Conditional instructions
4003 multiclass AsI1_bincc_irs<Instruction iri, Instruction irr, Instruction irsi,
4005 InstrItinClass iii, InstrItinClass iir,
4006 InstrItinClass iis> {
4007 def ri : ARMPseudoExpand<(outs GPR:$Rd),
4008 (ins GPR:$Rn, so_imm:$imm, pred:$p, cc_out:$s),
4010 (iri GPR:$Rd, GPR:$Rn, so_imm:$imm, pred:$p, cc_out:$s)>,
4011 RegConstraint<"$Rn = $Rd">;
4012 def rr : ARMPseudoExpand<(outs GPR:$Rd),
4013 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
4015 (irr GPR:$Rd, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
4016 RegConstraint<"$Rn = $Rd">;
4017 def rsi : ARMPseudoExpand<(outs GPR:$Rd),
4018 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p, cc_out:$s),
4020 (irsi GPR:$Rd, GPR:$Rn, so_reg_imm:$shift, pred:$p, cc_out:$s)>,
4021 RegConstraint<"$Rn = $Rd">;
4022 def rsr : ARMPseudoExpand<(outs GPRnopc:$Rd),
4023 (ins GPRnopc:$Rn, so_reg_reg:$shift, pred:$p, cc_out:$s),
4025 (irsr GPR:$Rd, GPR:$Rn, so_reg_reg:$shift, pred:$p, cc_out:$s)>,
4026 RegConstraint<"$Rn = $Rd">;
4029 defm ANDCC : AsI1_bincc_irs<ANDri, ANDrr, ANDrsi, ANDrsr,
4030 IIC_iBITi, IIC_iBITr, IIC_iBITsr>;
4031 defm ORRCC : AsI1_bincc_irs<ORRri, ORRrr, ORRrsi, ORRrsr,
4032 IIC_iBITi, IIC_iBITr, IIC_iBITsr>;
4033 defm EORCC : AsI1_bincc_irs<EORri, EORrr, EORrsi, EORrsr,
4034 IIC_iBITi, IIC_iBITr, IIC_iBITsr>;
4036 } // neverHasSideEffects
4039 //===----------------------------------------------------------------------===//
4040 // Atomic operations intrinsics
4043 def MemBarrierOptOperand : AsmOperandClass {
4044 let Name = "MemBarrierOpt";
4045 let ParserMethod = "parseMemBarrierOptOperand";
4047 def memb_opt : Operand<i32> {
4048 let PrintMethod = "printMemBOption";
4049 let ParserMatchClass = MemBarrierOptOperand;
4050 let DecoderMethod = "DecodeMemBarrierOption";
4053 // memory barriers protect the atomic sequences
4054 let hasSideEffects = 1 in {
4055 def DMB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4056 "dmb", "\t$opt", [(ARMMemBarrier (i32 imm:$opt))]>,
4057 Requires<[IsARM, HasDB]> {
4059 let Inst{31-4} = 0xf57ff05;
4060 let Inst{3-0} = opt;
4064 def DSB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4065 "dsb", "\t$opt", []>,
4066 Requires<[IsARM, HasDB]> {
4068 let Inst{31-4} = 0xf57ff04;
4069 let Inst{3-0} = opt;
4072 // ISB has only full system option
4073 def ISB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4074 "isb", "\t$opt", []>,
4075 Requires<[IsARM, HasDB]> {
4077 let Inst{31-4} = 0xf57ff06;
4078 let Inst{3-0} = opt;
4081 // Pseudo instruction that combines movs + predicated rsbmi
4082 // to implement integer ABS
4083 let usesCustomInserter = 1, Defs = [CPSR] in {
4084 def ABS : ARMPseudoInst<
4085 (outs GPR:$dst), (ins GPR:$src),
4086 8, NoItinerary, []>;
4089 let usesCustomInserter = 1 in {
4090 let Defs = [CPSR] in {
4091 def ATOMIC_LOAD_ADD_I8 : PseudoInst<
4092 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4093 [(set GPR:$dst, (atomic_load_add_8 GPR:$ptr, GPR:$incr))]>;
4094 def ATOMIC_LOAD_SUB_I8 : PseudoInst<
4095 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4096 [(set GPR:$dst, (atomic_load_sub_8 GPR:$ptr, GPR:$incr))]>;
4097 def ATOMIC_LOAD_AND_I8 : PseudoInst<
4098 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4099 [(set GPR:$dst, (atomic_load_and_8 GPR:$ptr, GPR:$incr))]>;
4100 def ATOMIC_LOAD_OR_I8 : PseudoInst<
4101 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4102 [(set GPR:$dst, (atomic_load_or_8 GPR:$ptr, GPR:$incr))]>;
4103 def ATOMIC_LOAD_XOR_I8 : PseudoInst<
4104 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4105 [(set GPR:$dst, (atomic_load_xor_8 GPR:$ptr, GPR:$incr))]>;
4106 def ATOMIC_LOAD_NAND_I8 : PseudoInst<
4107 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4108 [(set GPR:$dst, (atomic_load_nand_8 GPR:$ptr, GPR:$incr))]>;
4109 def ATOMIC_LOAD_MIN_I8 : PseudoInst<
4110 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4111 [(set GPR:$dst, (atomic_load_min_8 GPR:$ptr, GPR:$val))]>;
4112 def ATOMIC_LOAD_MAX_I8 : PseudoInst<
4113 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4114 [(set GPR:$dst, (atomic_load_max_8 GPR:$ptr, GPR:$val))]>;
4115 def ATOMIC_LOAD_UMIN_I8 : PseudoInst<
4116 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4117 [(set GPR:$dst, (atomic_load_umin_8 GPR:$ptr, GPR:$val))]>;
4118 def ATOMIC_LOAD_UMAX_I8 : PseudoInst<
4119 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4120 [(set GPR:$dst, (atomic_load_umax_8 GPR:$ptr, GPR:$val))]>;
4121 def ATOMIC_LOAD_ADD_I16 : PseudoInst<
4122 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4123 [(set GPR:$dst, (atomic_load_add_16 GPR:$ptr, GPR:$incr))]>;
4124 def ATOMIC_LOAD_SUB_I16 : PseudoInst<
4125 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4126 [(set GPR:$dst, (atomic_load_sub_16 GPR:$ptr, GPR:$incr))]>;
4127 def ATOMIC_LOAD_AND_I16 : PseudoInst<
4128 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4129 [(set GPR:$dst, (atomic_load_and_16 GPR:$ptr, GPR:$incr))]>;
4130 def ATOMIC_LOAD_OR_I16 : PseudoInst<
4131 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4132 [(set GPR:$dst, (atomic_load_or_16 GPR:$ptr, GPR:$incr))]>;
4133 def ATOMIC_LOAD_XOR_I16 : PseudoInst<
4134 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4135 [(set GPR:$dst, (atomic_load_xor_16 GPR:$ptr, GPR:$incr))]>;
4136 def ATOMIC_LOAD_NAND_I16 : PseudoInst<
4137 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4138 [(set GPR:$dst, (atomic_load_nand_16 GPR:$ptr, GPR:$incr))]>;
4139 def ATOMIC_LOAD_MIN_I16 : PseudoInst<
4140 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4141 [(set GPR:$dst, (atomic_load_min_16 GPR:$ptr, GPR:$val))]>;
4142 def ATOMIC_LOAD_MAX_I16 : PseudoInst<
4143 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4144 [(set GPR:$dst, (atomic_load_max_16 GPR:$ptr, GPR:$val))]>;
4145 def ATOMIC_LOAD_UMIN_I16 : PseudoInst<
4146 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4147 [(set GPR:$dst, (atomic_load_umin_16 GPR:$ptr, GPR:$val))]>;
4148 def ATOMIC_LOAD_UMAX_I16 : PseudoInst<
4149 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4150 [(set GPR:$dst, (atomic_load_umax_16 GPR:$ptr, GPR:$val))]>;
4151 def ATOMIC_LOAD_ADD_I32 : PseudoInst<
4152 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4153 [(set GPR:$dst, (atomic_load_add_32 GPR:$ptr, GPR:$incr))]>;
4154 def ATOMIC_LOAD_SUB_I32 : PseudoInst<
4155 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4156 [(set GPR:$dst, (atomic_load_sub_32 GPR:$ptr, GPR:$incr))]>;
4157 def ATOMIC_LOAD_AND_I32 : PseudoInst<
4158 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4159 [(set GPR:$dst, (atomic_load_and_32 GPR:$ptr, GPR:$incr))]>;
4160 def ATOMIC_LOAD_OR_I32 : PseudoInst<
4161 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4162 [(set GPR:$dst, (atomic_load_or_32 GPR:$ptr, GPR:$incr))]>;
4163 def ATOMIC_LOAD_XOR_I32 : PseudoInst<
4164 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4165 [(set GPR:$dst, (atomic_load_xor_32 GPR:$ptr, GPR:$incr))]>;
4166 def ATOMIC_LOAD_NAND_I32 : PseudoInst<
4167 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4168 [(set GPR:$dst, (atomic_load_nand_32 GPR:$ptr, GPR:$incr))]>;
4169 def ATOMIC_LOAD_MIN_I32 : PseudoInst<
4170 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4171 [(set GPR:$dst, (atomic_load_min_32 GPR:$ptr, GPR:$val))]>;
4172 def ATOMIC_LOAD_MAX_I32 : PseudoInst<
4173 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4174 [(set GPR:$dst, (atomic_load_max_32 GPR:$ptr, GPR:$val))]>;
4175 def ATOMIC_LOAD_UMIN_I32 : PseudoInst<
4176 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4177 [(set GPR:$dst, (atomic_load_umin_32 GPR:$ptr, GPR:$val))]>;
4178 def ATOMIC_LOAD_UMAX_I32 : PseudoInst<
4179 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4180 [(set GPR:$dst, (atomic_load_umax_32 GPR:$ptr, GPR:$val))]>;
4182 def ATOMIC_SWAP_I8 : PseudoInst<
4183 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
4184 [(set GPR:$dst, (atomic_swap_8 GPR:$ptr, GPR:$new))]>;
4185 def ATOMIC_SWAP_I16 : PseudoInst<
4186 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
4187 [(set GPR:$dst, (atomic_swap_16 GPR:$ptr, GPR:$new))]>;
4188 def ATOMIC_SWAP_I32 : PseudoInst<
4189 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
4190 [(set GPR:$dst, (atomic_swap_32 GPR:$ptr, GPR:$new))]>;
4192 def ATOMIC_CMP_SWAP_I8 : PseudoInst<
4193 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
4194 [(set GPR:$dst, (atomic_cmp_swap_8 GPR:$ptr, GPR:$old, GPR:$new))]>;
4195 def ATOMIC_CMP_SWAP_I16 : PseudoInst<
4196 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
4197 [(set GPR:$dst, (atomic_cmp_swap_16 GPR:$ptr, GPR:$old, GPR:$new))]>;
4198 def ATOMIC_CMP_SWAP_I32 : PseudoInst<
4199 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
4200 [(set GPR:$dst, (atomic_cmp_swap_32 GPR:$ptr, GPR:$old, GPR:$new))]>;
4204 let usesCustomInserter = 1 in {
4205 def COPY_STRUCT_BYVAL_I32 : PseudoInst<
4206 (outs), (ins GPR:$dst, GPR:$src, i32imm:$size, i32imm:$alignment),
4208 [(ARMcopystructbyval GPR:$dst, GPR:$src, imm:$size, imm:$alignment)]>;
4211 let mayLoad = 1 in {
4212 def LDREXB : AIldrex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4214 "ldrexb", "\t$Rt, $addr", []>;
4215 def LDREXH : AIldrex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4216 NoItinerary, "ldrexh", "\t$Rt, $addr", []>;
4217 def LDREX : AIldrex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4218 NoItinerary, "ldrex", "\t$Rt, $addr", []>;
4219 let hasExtraDefRegAllocReq = 1 in
4220 def LDREXD: AIldrex<0b01, (outs GPR:$Rt, GPR:$Rt2),(ins addr_offset_none:$addr),
4221 NoItinerary, "ldrexd", "\t$Rt, $Rt2, $addr", []> {
4222 let DecoderMethod = "DecodeDoubleRegLoad";
4226 let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
4227 def STREXB: AIstrex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4228 NoItinerary, "strexb", "\t$Rd, $Rt, $addr", []>;
4229 def STREXH: AIstrex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4230 NoItinerary, "strexh", "\t$Rd, $Rt, $addr", []>;
4231 def STREX : AIstrex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4232 NoItinerary, "strex", "\t$Rd, $Rt, $addr", []>;
4233 let hasExtraSrcRegAllocReq = 1 in
4234 def STREXD : AIstrex<0b01, (outs GPR:$Rd),
4235 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr),
4236 NoItinerary, "strexd", "\t$Rd, $Rt, $Rt2, $addr", []> {
4237 let DecoderMethod = "DecodeDoubleRegStore";
4242 def CLREX : AXI<(outs), (ins), MiscFrm, NoItinerary, "clrex", []>,
4243 Requires<[IsARM, HasV7]> {
4244 let Inst{31-0} = 0b11110101011111111111000000011111;
4247 // SWP/SWPB are deprecated in V6/V7.
4248 let mayLoad = 1, mayStore = 1 in {
4249 def SWP : AIswp<0, (outs GPRnopc:$Rt),
4250 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swp", []>;
4251 def SWPB: AIswp<1, (outs GPRnopc:$Rt),
4252 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swpb", []>;
4255 //===----------------------------------------------------------------------===//
4256 // Coprocessor Instructions.
4259 def CDP : ABI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4260 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4261 NoItinerary, "cdp", "\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4262 [(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4263 imm:$CRm, imm:$opc2)]> {
4271 let Inst{3-0} = CRm;
4273 let Inst{7-5} = opc2;
4274 let Inst{11-8} = cop;
4275 let Inst{15-12} = CRd;
4276 let Inst{19-16} = CRn;
4277 let Inst{23-20} = opc1;
4280 def CDP2 : ABXI<0b1110, (outs), (ins pf_imm:$cop, imm0_15:$opc1,
4281 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4282 NoItinerary, "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4283 [(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4284 imm:$CRm, imm:$opc2)]> {
4285 let Inst{31-28} = 0b1111;
4293 let Inst{3-0} = CRm;
4295 let Inst{7-5} = opc2;
4296 let Inst{11-8} = cop;
4297 let Inst{15-12} = CRd;
4298 let Inst{19-16} = CRn;
4299 let Inst{23-20} = opc1;
4302 class ACI<dag oops, dag iops, string opc, string asm,
4303 IndexMode im = IndexModeNone>
4304 : I<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
4306 let Inst{27-25} = 0b110;
4308 class ACInoP<dag oops, dag iops, string opc, string asm,
4309 IndexMode im = IndexModeNone>
4310 : InoP<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
4312 let Inst{31-28} = 0b1111;
4313 let Inst{27-25} = 0b110;
4315 multiclass LdStCop<bit load, bit Dbit, string asm> {
4316 def _OFFSET : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4317 asm, "\t$cop, $CRd, $addr"> {
4321 let Inst{24} = 1; // P = 1
4322 let Inst{23} = addr{8};
4323 let Inst{22} = Dbit;
4324 let Inst{21} = 0; // W = 0
4325 let Inst{20} = load;
4326 let Inst{19-16} = addr{12-9};
4327 let Inst{15-12} = CRd;
4328 let Inst{11-8} = cop;
4329 let Inst{7-0} = addr{7-0};
4330 let DecoderMethod = "DecodeCopMemInstruction";
4332 def _PRE : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4333 asm, "\t$cop, $CRd, $addr!", IndexModePre> {
4337 let Inst{24} = 1; // P = 1
4338 let Inst{23} = addr{8};
4339 let Inst{22} = Dbit;
4340 let Inst{21} = 1; // W = 1
4341 let Inst{20} = load;
4342 let Inst{19-16} = addr{12-9};
4343 let Inst{15-12} = CRd;
4344 let Inst{11-8} = cop;
4345 let Inst{7-0} = addr{7-0};
4346 let DecoderMethod = "DecodeCopMemInstruction";
4348 def _POST: ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4349 postidx_imm8s4:$offset),
4350 asm, "\t$cop, $CRd, $addr, $offset", IndexModePost> {
4355 let Inst{24} = 0; // P = 0
4356 let Inst{23} = offset{8};
4357 let Inst{22} = Dbit;
4358 let Inst{21} = 1; // W = 1
4359 let Inst{20} = load;
4360 let Inst{19-16} = addr;
4361 let Inst{15-12} = CRd;
4362 let Inst{11-8} = cop;
4363 let Inst{7-0} = offset{7-0};
4364 let DecoderMethod = "DecodeCopMemInstruction";
4366 def _OPTION : ACI<(outs),
4367 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4368 coproc_option_imm:$option),
4369 asm, "\t$cop, $CRd, $addr, $option"> {
4374 let Inst{24} = 0; // P = 0
4375 let Inst{23} = 1; // U = 1
4376 let Inst{22} = Dbit;
4377 let Inst{21} = 0; // W = 0
4378 let Inst{20} = load;
4379 let Inst{19-16} = addr;
4380 let Inst{15-12} = CRd;
4381 let Inst{11-8} = cop;
4382 let Inst{7-0} = option;
4383 let DecoderMethod = "DecodeCopMemInstruction";
4386 multiclass LdSt2Cop<bit load, bit Dbit, string asm> {
4387 def _OFFSET : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4388 asm, "\t$cop, $CRd, $addr"> {
4392 let Inst{24} = 1; // P = 1
4393 let Inst{23} = addr{8};
4394 let Inst{22} = Dbit;
4395 let Inst{21} = 0; // W = 0
4396 let Inst{20} = load;
4397 let Inst{19-16} = addr{12-9};
4398 let Inst{15-12} = CRd;
4399 let Inst{11-8} = cop;
4400 let Inst{7-0} = addr{7-0};
4401 let DecoderMethod = "DecodeCopMemInstruction";
4403 def _PRE : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4404 asm, "\t$cop, $CRd, $addr!", IndexModePre> {
4408 let Inst{24} = 1; // P = 1
4409 let Inst{23} = addr{8};
4410 let Inst{22} = Dbit;
4411 let Inst{21} = 1; // W = 1
4412 let Inst{20} = load;
4413 let Inst{19-16} = addr{12-9};
4414 let Inst{15-12} = CRd;
4415 let Inst{11-8} = cop;
4416 let Inst{7-0} = addr{7-0};
4417 let DecoderMethod = "DecodeCopMemInstruction";
4419 def _POST: ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4420 postidx_imm8s4:$offset),
4421 asm, "\t$cop, $CRd, $addr, $offset", IndexModePost> {
4426 let Inst{24} = 0; // P = 0
4427 let Inst{23} = offset{8};
4428 let Inst{22} = Dbit;
4429 let Inst{21} = 1; // W = 1
4430 let Inst{20} = load;
4431 let Inst{19-16} = addr;
4432 let Inst{15-12} = CRd;
4433 let Inst{11-8} = cop;
4434 let Inst{7-0} = offset{7-0};
4435 let DecoderMethod = "DecodeCopMemInstruction";
4437 def _OPTION : ACInoP<(outs),
4438 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4439 coproc_option_imm:$option),
4440 asm, "\t$cop, $CRd, $addr, $option"> {
4445 let Inst{24} = 0; // P = 0
4446 let Inst{23} = 1; // U = 1
4447 let Inst{22} = Dbit;
4448 let Inst{21} = 0; // W = 0
4449 let Inst{20} = load;
4450 let Inst{19-16} = addr;
4451 let Inst{15-12} = CRd;
4452 let Inst{11-8} = cop;
4453 let Inst{7-0} = option;
4454 let DecoderMethod = "DecodeCopMemInstruction";
4458 defm LDC : LdStCop <1, 0, "ldc">;
4459 defm LDCL : LdStCop <1, 1, "ldcl">;
4460 defm STC : LdStCop <0, 0, "stc">;
4461 defm STCL : LdStCop <0, 1, "stcl">;
4462 defm LDC2 : LdSt2Cop<1, 0, "ldc2">;
4463 defm LDC2L : LdSt2Cop<1, 1, "ldc2l">;
4464 defm STC2 : LdSt2Cop<0, 0, "stc2">;
4465 defm STC2L : LdSt2Cop<0, 1, "stc2l">;
4467 //===----------------------------------------------------------------------===//
4468 // Move between coprocessor and ARM core register.
4471 class MovRCopro<string opc, bit direction, dag oops, dag iops,
4473 : ABI<0b1110, oops, iops, NoItinerary, opc,
4474 "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2", pattern> {
4475 let Inst{20} = direction;
4485 let Inst{15-12} = Rt;
4486 let Inst{11-8} = cop;
4487 let Inst{23-21} = opc1;
4488 let Inst{7-5} = opc2;
4489 let Inst{3-0} = CRm;
4490 let Inst{19-16} = CRn;
4493 def MCR : MovRCopro<"mcr", 0 /* from ARM core register to coprocessor */,
4495 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4496 c_imm:$CRm, imm0_7:$opc2),
4497 [(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
4498 imm:$CRm, imm:$opc2)]>;
4499 def : ARMInstAlias<"mcr${p} $cop, $opc1, $Rt, $CRn, $CRm",
4500 (MCR p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4501 c_imm:$CRm, 0, pred:$p)>;
4502 def MRC : MovRCopro<"mrc", 1 /* from coprocessor to ARM core register */,
4504 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
4506 def : ARMInstAlias<"mrc${p} $cop, $opc1, $Rt, $CRn, $CRm",
4507 (MRC GPR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
4508 c_imm:$CRm, 0, pred:$p)>;
4510 def : ARMPat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
4511 (MRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
4513 class MovRCopro2<string opc, bit direction, dag oops, dag iops,
4515 : ABXI<0b1110, oops, iops, NoItinerary,
4516 !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), pattern> {
4517 let Inst{31-28} = 0b1111;
4518 let Inst{20} = direction;
4528 let Inst{15-12} = Rt;
4529 let Inst{11-8} = cop;
4530 let Inst{23-21} = opc1;
4531 let Inst{7-5} = opc2;
4532 let Inst{3-0} = CRm;
4533 let Inst{19-16} = CRn;
4536 def MCR2 : MovRCopro2<"mcr2", 0 /* from ARM core register to coprocessor */,
4538 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4539 c_imm:$CRm, imm0_7:$opc2),
4540 [(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
4541 imm:$CRm, imm:$opc2)]>;
4542 def : ARMInstAlias<"mcr2$ $cop, $opc1, $Rt, $CRn, $CRm",
4543 (MCR2 p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4545 def MRC2 : MovRCopro2<"mrc2", 1 /* from coprocessor to ARM core register */,
4547 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
4549 def : ARMInstAlias<"mrc2$ $cop, $opc1, $Rt, $CRn, $CRm",
4550 (MRC2 GPR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
4553 def : ARMV5TPat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn,
4554 imm:$CRm, imm:$opc2),
4555 (MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
4557 class MovRRCopro<string opc, bit direction, list<dag> pattern = []>
4558 : ABI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4559 GPRnopc:$Rt, GPRnopc:$Rt2, c_imm:$CRm),
4560 NoItinerary, opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm", pattern> {
4561 let Inst{23-21} = 0b010;
4562 let Inst{20} = direction;
4570 let Inst{15-12} = Rt;
4571 let Inst{19-16} = Rt2;
4572 let Inst{11-8} = cop;
4573 let Inst{7-4} = opc1;
4574 let Inst{3-0} = CRm;
4577 def MCRR : MovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */,
4578 [(int_arm_mcrr imm:$cop, imm:$opc1, GPRnopc:$Rt,
4579 GPRnopc:$Rt2, imm:$CRm)]>;
4580 def MRRC : MovRRCopro<"mrrc", 1 /* from coprocessor to ARM core register */>;
4582 class MovRRCopro2<string opc, bit direction, list<dag> pattern = []>
4583 : ABXI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4584 GPRnopc:$Rt, GPRnopc:$Rt2, c_imm:$CRm), NoItinerary,
4585 !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern> {
4586 let Inst{31-28} = 0b1111;
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;
4602 let DecoderMethod = "DecodeMRRC2";
4605 def MCRR2 : MovRRCopro2<"mcrr2", 0 /* from ARM core register to coprocessor */,
4606 [(int_arm_mcrr2 imm:$cop, imm:$opc1, GPRnopc:$Rt,
4607 GPRnopc:$Rt2, imm:$CRm)]>;
4608 def MRRC2 : MovRRCopro2<"mrrc2", 1 /* from coprocessor to ARM core register */>;
4610 //===----------------------------------------------------------------------===//
4611 // Move between special register and ARM core register
4614 // Move to ARM core register from Special Register
4615 def MRS : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
4616 "mrs", "\t$Rd, apsr", []> {
4618 let Inst{23-16} = 0b00001111;
4619 let Unpredictable{19-17} = 0b111;
4621 let Inst{15-12} = Rd;
4623 let Inst{11-0} = 0b000000000000;
4624 let Unpredictable{11-0} = 0b110100001111;
4627 def : InstAlias<"mrs${p} $Rd, cpsr", (MRS GPRnopc:$Rd, pred:$p)>,
4630 // The MRSsys instruction is the MRS instruction from the ARM ARM,
4631 // section B9.3.9, with the R bit set to 1.
4632 def MRSsys : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
4633 "mrs", "\t$Rd, spsr", []> {
4635 let Inst{23-16} = 0b01001111;
4636 let Unpredictable{19-16} = 0b1111;
4638 let Inst{15-12} = Rd;
4640 let Inst{11-0} = 0b000000000000;
4641 let Unpredictable{11-0} = 0b110100001111;
4644 // Move from ARM core register to Special Register
4646 // No need to have both system and application versions, the encodings are the
4647 // same and the assembly parser has no way to distinguish between them. The mask
4648 // operand contains the special register (R Bit) in bit 4 and bits 3-0 contains
4649 // the mask with the fields to be accessed in the special register.
4650 def MSR : ABI<0b0001, (outs), (ins msr_mask:$mask, GPR:$Rn), NoItinerary,
4651 "msr", "\t$mask, $Rn", []> {
4656 let Inst{22} = mask{4}; // R bit
4657 let Inst{21-20} = 0b10;
4658 let Inst{19-16} = mask{3-0};
4659 let Inst{15-12} = 0b1111;
4660 let Inst{11-4} = 0b00000000;
4664 def MSRi : ABI<0b0011, (outs), (ins msr_mask:$mask, so_imm:$a), NoItinerary,
4665 "msr", "\t$mask, $a", []> {
4670 let Inst{22} = mask{4}; // R bit
4671 let Inst{21-20} = 0b10;
4672 let Inst{19-16} = mask{3-0};
4673 let Inst{15-12} = 0b1111;
4677 //===----------------------------------------------------------------------===//
4681 // __aeabi_read_tp preserves the registers r1-r3.
4682 // This is a pseudo inst so that we can get the encoding right,
4683 // complete with fixup for the aeabi_read_tp function.
4685 Defs = [R0, R12, LR, CPSR], Uses = [SP] in {
4686 def TPsoft : PseudoInst<(outs), (ins), IIC_Br,
4687 [(set R0, ARMthread_pointer)]>;
4690 //===----------------------------------------------------------------------===//
4691 // SJLJ Exception handling intrinsics
4692 // eh_sjlj_setjmp() is an instruction sequence to store the return
4693 // address and save #0 in R0 for the non-longjmp case.
4694 // Since by its nature we may be coming from some other function to get
4695 // here, and we're using the stack frame for the containing function to
4696 // save/restore registers, we can't keep anything live in regs across
4697 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
4698 // when we get here from a longjmp(). We force everything out of registers
4699 // except for our own input by listing the relevant registers in Defs. By
4700 // doing so, we also cause the prologue/epilogue code to actively preserve
4701 // all of the callee-saved resgisters, which is exactly what we want.
4702 // A constant value is passed in $val, and we use the location as a scratch.
4704 // These are pseudo-instructions and are lowered to individual MC-insts, so
4705 // no encoding information is necessary.
4707 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
4708 Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15 ],
4709 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
4710 def Int_eh_sjlj_setjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
4712 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
4713 Requires<[IsARM, HasVFP2]>;
4717 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
4718 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
4719 def Int_eh_sjlj_setjmp_nofp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
4721 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
4722 Requires<[IsARM, NoVFP]>;
4725 // FIXME: Non-IOS version(s)
4726 let isBarrier = 1, hasSideEffects = 1, isTerminator = 1,
4727 Defs = [ R7, LR, SP ] in {
4728 def Int_eh_sjlj_longjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$scratch),
4730 [(ARMeh_sjlj_longjmp GPR:$src, GPR:$scratch)]>,
4731 Requires<[IsARM, IsIOS]>;
4734 // eh.sjlj.dispatchsetup pseudo-instructions.
4735 // These pseudos are used for both ARM and Thumb2. Any differences are
4736 // handled when the pseudo is expanded (which happens before any passes
4737 // that need the instruction size).
4739 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
4740 Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15 ],
4742 def Int_eh_sjlj_dispatchsetup : PseudoInst<(outs), (ins), NoItinerary, []>;
4745 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
4747 def Int_eh_sjlj_dispatchsetup_nofp : PseudoInst<(outs), (ins), NoItinerary, []>;
4750 //===----------------------------------------------------------------------===//
4751 // Non-Instruction Patterns
4754 // ARMv4 indirect branch using (MOVr PC, dst)
4755 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in
4756 def MOVPCRX : ARMPseudoExpand<(outs), (ins GPR:$dst),
4757 4, IIC_Br, [(brind GPR:$dst)],
4758 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>,
4759 Requires<[IsARM, NoV4T]>;
4761 // Large immediate handling.
4763 // 32-bit immediate using two piece so_imms or movw + movt.
4764 // This is a single pseudo instruction, the benefit is that it can be remat'd
4765 // as a single unit instead of having to handle reg inputs.
4766 // FIXME: Remove this when we can do generalized remat.
4767 let isReMaterializable = 1, isMoveImm = 1 in
4768 def MOVi32imm : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
4769 [(set GPR:$dst, (arm_i32imm:$src))]>,
4772 // Pseudo instruction that combines movw + movt + add pc (if PIC).
4773 // It also makes it possible to rematerialize the instructions.
4774 // FIXME: Remove this when we can do generalized remat and when machine licm
4775 // can properly the instructions.
4776 let isReMaterializable = 1 in {
4777 def MOV_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
4779 [(set GPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>,
4780 Requires<[IsARM, UseMovt]>;
4782 def MOV_ga_dyn : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
4784 [(set GPR:$dst, (ARMWrapperDYN tglobaladdr:$addr))]>,
4785 Requires<[IsARM, UseMovt]>;
4787 let AddedComplexity = 10 in
4788 def MOV_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
4790 [(set GPR:$dst, (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
4791 Requires<[IsARM, UseMovt]>;
4792 } // isReMaterializable
4794 // ConstantPool, GlobalAddress, and JumpTable
4795 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (LEApcrel tglobaladdr :$dst)>,
4796 Requires<[IsARM, DontUseMovt]>;
4797 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
4798 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
4799 Requires<[IsARM, UseMovt]>;
4800 def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
4801 (LEApcrelJT tjumptable:$dst, imm:$id)>;
4803 // TODO: add,sub,and, 3-instr forms?
4805 // Tail calls. These patterns also apply to Thumb mode.
4806 def : Pat<(ARMtcret tcGPR:$dst), (TCRETURNri tcGPR:$dst)>;
4807 def : Pat<(ARMtcret (i32 tglobaladdr:$dst)), (TCRETURNdi texternalsym:$dst)>;
4808 def : Pat<(ARMtcret (i32 texternalsym:$dst)), (TCRETURNdi texternalsym:$dst)>;
4811 def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>;
4812 def : ARMPat<(ARMcall_nolink texternalsym:$func),
4813 (BMOVPCB_CALL texternalsym:$func)>;
4815 // zextload i1 -> zextload i8
4816 def : ARMPat<(zextloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
4817 def : ARMPat<(zextloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
4819 // extload -> zextload
4820 def : ARMPat<(extloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
4821 def : ARMPat<(extloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
4822 def : ARMPat<(extloadi8 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
4823 def : ARMPat<(extloadi8 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
4825 def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
4827 def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
4828 def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
4831 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4832 (sra (shl GPR:$b, (i32 16)), (i32 16))),
4833 (SMULBB GPR:$a, GPR:$b)>;
4834 def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
4835 (SMULBB GPR:$a, GPR:$b)>;
4836 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4837 (sra GPR:$b, (i32 16))),
4838 (SMULBT GPR:$a, GPR:$b)>;
4839 def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, (i32 16))),
4840 (SMULBT GPR:$a, GPR:$b)>;
4841 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)),
4842 (sra (shl GPR:$b, (i32 16)), (i32 16))),
4843 (SMULTB GPR:$a, GPR:$b)>;
4844 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), sext_16_node:$b),
4845 (SMULTB GPR:$a, GPR:$b)>;
4846 def : ARMV5TEPat<(sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
4848 (SMULWB GPR:$a, GPR:$b)>;
4849 def : ARMV5TEPat<(sra (mul GPR:$a, sext_16_node:$b), (i32 16)),
4850 (SMULWB GPR:$a, GPR:$b)>;
4852 def : ARMV5TEPat<(add GPR:$acc,
4853 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4854 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
4855 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
4856 def : ARMV5TEPat<(add GPR:$acc,
4857 (mul sext_16_node:$a, sext_16_node:$b)),
4858 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
4859 def : ARMV5TEPat<(add GPR:$acc,
4860 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4861 (sra GPR:$b, (i32 16)))),
4862 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
4863 def : ARMV5TEPat<(add GPR:$acc,
4864 (mul sext_16_node:$a, (sra GPR:$b, (i32 16)))),
4865 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
4866 def : ARMV5TEPat<(add GPR:$acc,
4867 (mul (sra GPR:$a, (i32 16)),
4868 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
4869 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
4870 def : ARMV5TEPat<(add GPR:$acc,
4871 (mul (sra GPR:$a, (i32 16)), sext_16_node:$b)),
4872 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
4873 def : ARMV5TEPat<(add GPR:$acc,
4874 (sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
4876 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
4877 def : ARMV5TEPat<(add GPR:$acc,
4878 (sra (mul GPR:$a, sext_16_node:$b), (i32 16))),
4879 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
4882 // Pre-v7 uses MCR for synchronization barriers.
4883 def : ARMPat<(ARMMemBarrierMCR GPR:$zero), (MCR 15, 0, GPR:$zero, 7, 10, 5)>,
4884 Requires<[IsARM, HasV6]>;
4886 // SXT/UXT with no rotate
4887 let AddedComplexity = 16 in {
4888 def : ARMV6Pat<(and GPR:$Src, 0x000000FF), (UXTB GPR:$Src, 0)>;
4889 def : ARMV6Pat<(and GPR:$Src, 0x0000FFFF), (UXTH GPR:$Src, 0)>;
4890 def : ARMV6Pat<(and GPR:$Src, 0x00FF00FF), (UXTB16 GPR:$Src, 0)>;
4891 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0x00FF)),
4892 (UXTAB GPR:$Rn, GPR:$Rm, 0)>;
4893 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0xFFFF)),
4894 (UXTAH GPR:$Rn, GPR:$Rm, 0)>;
4897 def : ARMV6Pat<(sext_inreg GPR:$Src, i8), (SXTB GPR:$Src, 0)>;
4898 def : ARMV6Pat<(sext_inreg GPR:$Src, i16), (SXTH GPR:$Src, 0)>;
4900 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i8)),
4901 (SXTAB GPR:$Rn, GPRnopc:$Rm, 0)>;
4902 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i16)),
4903 (SXTAH GPR:$Rn, GPRnopc:$Rm, 0)>;
4905 // Atomic load/store patterns
4906 def : ARMPat<(atomic_load_8 ldst_so_reg:$src),
4907 (LDRBrs ldst_so_reg:$src)>;
4908 def : ARMPat<(atomic_load_8 addrmode_imm12:$src),
4909 (LDRBi12 addrmode_imm12:$src)>;
4910 def : ARMPat<(atomic_load_16 addrmode3:$src),
4911 (LDRH addrmode3:$src)>;
4912 def : ARMPat<(atomic_load_32 ldst_so_reg:$src),
4913 (LDRrs ldst_so_reg:$src)>;
4914 def : ARMPat<(atomic_load_32 addrmode_imm12:$src),
4915 (LDRi12 addrmode_imm12:$src)>;
4916 def : ARMPat<(atomic_store_8 ldst_so_reg:$ptr, GPR:$val),
4917 (STRBrs GPR:$val, ldst_so_reg:$ptr)>;
4918 def : ARMPat<(atomic_store_8 addrmode_imm12:$ptr, GPR:$val),
4919 (STRBi12 GPR:$val, addrmode_imm12:$ptr)>;
4920 def : ARMPat<(atomic_store_16 addrmode3:$ptr, GPR:$val),
4921 (STRH GPR:$val, addrmode3:$ptr)>;
4922 def : ARMPat<(atomic_store_32 ldst_so_reg:$ptr, GPR:$val),
4923 (STRrs GPR:$val, ldst_so_reg:$ptr)>;
4924 def : ARMPat<(atomic_store_32 addrmode_imm12:$ptr, GPR:$val),
4925 (STRi12 GPR:$val, addrmode_imm12:$ptr)>;
4928 //===----------------------------------------------------------------------===//
4932 include "ARMInstrThumb.td"
4934 //===----------------------------------------------------------------------===//
4938 include "ARMInstrThumb2.td"
4940 //===----------------------------------------------------------------------===//
4941 // Floating Point Support
4944 include "ARMInstrVFP.td"
4946 //===----------------------------------------------------------------------===//
4947 // Advanced SIMD (NEON) Support
4950 include "ARMInstrNEON.td"
4952 //===----------------------------------------------------------------------===//
4953 // Assembler aliases
4957 def : InstAlias<"dmb", (DMB 0xf)>, Requires<[IsARM, HasDB]>;
4958 def : InstAlias<"dsb", (DSB 0xf)>, Requires<[IsARM, HasDB]>;
4959 def : InstAlias<"isb", (ISB 0xf)>, Requires<[IsARM, HasDB]>;
4961 // System instructions
4962 def : MnemonicAlias<"swi", "svc">;
4964 // Load / Store Multiple
4965 def : MnemonicAlias<"ldmfd", "ldm">;
4966 def : MnemonicAlias<"ldmia", "ldm">;
4967 def : MnemonicAlias<"ldmea", "ldmdb">;
4968 def : MnemonicAlias<"stmfd", "stmdb">;
4969 def : MnemonicAlias<"stmia", "stm">;
4970 def : MnemonicAlias<"stmea", "stm">;
4972 // PKHBT/PKHTB with default shift amount. PKHTB is equivalent to PKHBT when the
4973 // shift amount is zero (i.e., unspecified).
4974 def : InstAlias<"pkhbt${p} $Rd, $Rn, $Rm",
4975 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
4976 Requires<[IsARM, HasV6]>;
4977 def : InstAlias<"pkhtb${p} $Rd, $Rn, $Rm",
4978 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
4979 Requires<[IsARM, HasV6]>;
4981 // PUSH/POP aliases for STM/LDM
4982 def : ARMInstAlias<"push${p} $regs", (STMDB_UPD SP, pred:$p, reglist:$regs)>;
4983 def : ARMInstAlias<"pop${p} $regs", (LDMIA_UPD SP, pred:$p, reglist:$regs)>;
4985 // SSAT/USAT optional shift operand.
4986 def : ARMInstAlias<"ssat${p} $Rd, $sat_imm, $Rn",
4987 (SSAT GPRnopc:$Rd, imm1_32:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
4988 def : ARMInstAlias<"usat${p} $Rd, $sat_imm, $Rn",
4989 (USAT GPRnopc:$Rd, imm0_31:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
4992 // Extend instruction optional rotate operand.
4993 def : ARMInstAlias<"sxtab${p} $Rd, $Rn, $Rm",
4994 (SXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4995 def : ARMInstAlias<"sxtah${p} $Rd, $Rn, $Rm",
4996 (SXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4997 def : ARMInstAlias<"sxtab16${p} $Rd, $Rn, $Rm",
4998 (SXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4999 def : ARMInstAlias<"sxtb${p} $Rd, $Rm",
5000 (SXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5001 def : ARMInstAlias<"sxtb16${p} $Rd, $Rm",
5002 (SXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5003 def : ARMInstAlias<"sxth${p} $Rd, $Rm",
5004 (SXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5006 def : ARMInstAlias<"uxtab${p} $Rd, $Rn, $Rm",
5007 (UXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5008 def : ARMInstAlias<"uxtah${p} $Rd, $Rn, $Rm",
5009 (UXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5010 def : ARMInstAlias<"uxtab16${p} $Rd, $Rn, $Rm",
5011 (UXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5012 def : ARMInstAlias<"uxtb${p} $Rd, $Rm",
5013 (UXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5014 def : ARMInstAlias<"uxtb16${p} $Rd, $Rm",
5015 (UXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5016 def : ARMInstAlias<"uxth${p} $Rd, $Rm",
5017 (UXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5021 def : MnemonicAlias<"rfefa", "rfeda">;
5022 def : MnemonicAlias<"rfeea", "rfedb">;
5023 def : MnemonicAlias<"rfefd", "rfeia">;
5024 def : MnemonicAlias<"rfeed", "rfeib">;
5025 def : MnemonicAlias<"rfe", "rfeia">;
5028 def : MnemonicAlias<"srsfa", "srsda">;
5029 def : MnemonicAlias<"srsea", "srsdb">;
5030 def : MnemonicAlias<"srsfd", "srsia">;
5031 def : MnemonicAlias<"srsed", "srsib">;
5032 def : MnemonicAlias<"srs", "srsia">;
5035 def : MnemonicAlias<"qsubaddx", "qsax">;
5037 def : MnemonicAlias<"saddsubx", "sasx">;
5038 // SHASX == SHADDSUBX
5039 def : MnemonicAlias<"shaddsubx", "shasx">;
5040 // SHSAX == SHSUBADDX
5041 def : MnemonicAlias<"shsubaddx", "shsax">;
5043 def : MnemonicAlias<"ssubaddx", "ssax">;
5045 def : MnemonicAlias<"uaddsubx", "uasx">;
5046 // UHASX == UHADDSUBX
5047 def : MnemonicAlias<"uhaddsubx", "uhasx">;
5048 // UHSAX == UHSUBADDX
5049 def : MnemonicAlias<"uhsubaddx", "uhsax">;
5050 // UQASX == UQADDSUBX
5051 def : MnemonicAlias<"uqaddsubx", "uqasx">;
5052 // UQSAX == UQSUBADDX
5053 def : MnemonicAlias<"uqsubaddx", "uqsax">;
5055 def : MnemonicAlias<"usubaddx", "usax">;
5057 // "mov Rd, so_imm_not" can be handled via "mvn" in assembly, just like
5059 def : ARMInstAlias<"mov${s}${p} $Rd, $imm",
5060 (MVNi rGPR:$Rd, so_imm_not:$imm, pred:$p, cc_out:$s)>;
5061 def : ARMInstAlias<"mvn${s}${p} $Rd, $imm",
5062 (MOVi rGPR:$Rd, so_imm_not:$imm, pred:$p, cc_out:$s)>;
5063 // Same for AND <--> BIC
5064 def : ARMInstAlias<"bic${s}${p} $Rd, $Rn, $imm",
5065 (ANDri rGPR:$Rd, rGPR:$Rn, so_imm_not:$imm,
5066 pred:$p, cc_out:$s)>;
5067 def : ARMInstAlias<"bic${s}${p} $Rdn, $imm",
5068 (ANDri rGPR:$Rdn, rGPR:$Rdn, so_imm_not:$imm,
5069 pred:$p, cc_out:$s)>;
5070 def : ARMInstAlias<"and${s}${p} $Rd, $Rn, $imm",
5071 (BICri rGPR:$Rd, rGPR:$Rn, so_imm_not:$imm,
5072 pred:$p, cc_out:$s)>;
5073 def : ARMInstAlias<"and${s}${p} $Rdn, $imm",
5074 (BICri rGPR:$Rdn, rGPR:$Rdn, so_imm_not:$imm,
5075 pred:$p, cc_out:$s)>;
5077 // Likewise, "add Rd, so_imm_neg" -> sub
5078 def : ARMInstAlias<"add${s}${p} $Rd, $Rn, $imm",
5079 (SUBri GPR:$Rd, GPR:$Rn, so_imm_neg:$imm, pred:$p, cc_out:$s)>;
5080 def : ARMInstAlias<"add${s}${p} $Rd, $imm",
5081 (SUBri GPR:$Rd, GPR:$Rd, so_imm_neg:$imm, pred:$p, cc_out:$s)>;
5082 // Same for CMP <--> CMN via so_imm_neg
5083 def : ARMInstAlias<"cmp${p} $Rd, $imm",
5084 (CMNri rGPR:$Rd, so_imm_neg:$imm, pred:$p)>;
5085 def : ARMInstAlias<"cmn${p} $Rd, $imm",
5086 (CMPri rGPR:$Rd, so_imm_neg:$imm, pred:$p)>;
5088 // The shifter forms of the MOV instruction are aliased to the ASR, LSL,
5089 // LSR, ROR, and RRX instructions.
5090 // FIXME: We need C++ parser hooks to map the alias to the MOV
5091 // encoding. It seems we should be able to do that sort of thing
5092 // in tblgen, but it could get ugly.
5093 let TwoOperandAliasConstraint = "$Rm = $Rd" in {
5094 def ASRi : ARMAsmPseudo<"asr${s}${p} $Rd, $Rm, $imm",
5095 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
5097 def LSRi : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rm, $imm",
5098 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
5100 def LSLi : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rm, $imm",
5101 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
5103 def RORi : ARMAsmPseudo<"ror${s}${p} $Rd, $Rm, $imm",
5104 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
5107 def RRXi : ARMAsmPseudo<"rrx${s}${p} $Rd, $Rm",
5108 (ins GPRnopc:$Rd, GPRnopc:$Rm, pred:$p, cc_out:$s)>;
5109 let TwoOperandAliasConstraint = "$Rn = $Rd" in {
5110 def ASRr : ARMAsmPseudo<"asr${s}${p} $Rd, $Rn, $Rm",
5111 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5113 def LSRr : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rn, $Rm",
5114 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5116 def LSLr : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rn, $Rm",
5117 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5119 def RORr : ARMAsmPseudo<"ror${s}${p} $Rd, $Rn, $Rm",
5120 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5124 // "neg" is and alias for "rsb rd, rn, #0"
5125 def : ARMInstAlias<"neg${s}${p} $Rd, $Rm",
5126 (RSBri GPR:$Rd, GPR:$Rm, 0, pred:$p, cc_out:$s)>;
5128 // Pre-v6, 'mov r0, r0' was used as a NOP encoding.
5129 def : InstAlias<"nop${p}", (MOVr R0, R0, pred:$p, zero_reg)>,
5130 Requires<[IsARM, NoV6]>;
5132 // UMULL/SMULL are available on all arches, but the instruction definitions
5133 // need difference constraints pre-v6. Use these aliases for the assembly
5134 // parsing on pre-v6.
5135 def : InstAlias<"smull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5136 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5137 Requires<[IsARM, NoV6]>;
5138 def : InstAlias<"umull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5139 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5140 Requires<[IsARM, NoV6]>;
5142 // 'it' blocks in ARM mode just validate the predicates. The IT itself
5144 def ITasm : ARMAsmPseudo<"it$mask $cc", (ins it_pred:$cc, it_mask:$mask)>;