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> ]>;
22 def SDT_ARMSaveCallPC : SDTypeProfile<0, 1, []>;
24 def SDT_ARMcall : SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>;
26 def SDT_ARMCMov : SDTypeProfile<1, 3,
27 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
30 def SDT_ARMBrcond : SDTypeProfile<0, 2,
31 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i32>]>;
33 def SDT_ARMBrJT : SDTypeProfile<0, 3,
34 [SDTCisPtrTy<0>, SDTCisVT<1, i32>,
37 def SDT_ARMBr2JT : SDTypeProfile<0, 4,
38 [SDTCisPtrTy<0>, SDTCisVT<1, i32>,
39 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
41 def SDT_ARMBCC_i64 : SDTypeProfile<0, 6,
43 SDTCisVT<1, i32>, SDTCisVT<2, i32>,
44 SDTCisVT<3, i32>, SDTCisVT<4, i32>,
45 SDTCisVT<5, OtherVT>]>;
47 def SDT_ARMAnd : SDTypeProfile<1, 2,
48 [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
51 def SDT_ARMCmp : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
53 def SDT_ARMPICAdd : SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>,
54 SDTCisPtrTy<1>, SDTCisVT<2, i32>]>;
56 def SDT_ARMThreadPointer : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
57 def SDT_ARMEH_SJLJ_Setjmp : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisPtrTy<1>,
59 def SDT_ARMEH_SJLJ_Longjmp: SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
61 def SDT_ARMMEMBARRIER : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
63 def SDT_ARMPREFETCH : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisSameAs<1, 2>,
66 def SDT_ARMTCRET : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
68 def SDT_ARMBFI : SDTypeProfile<1, 3, [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
69 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
71 def SDTBinaryArithWithFlags : SDTypeProfile<2, 2,
74 SDTCisInt<0>, SDTCisVT<1, i32>]>;
76 // SDTBinaryArithWithFlagsInOut - RES1, CPSR = op LHS, RHS, CPSR
77 def SDTBinaryArithWithFlagsInOut : SDTypeProfile<2, 3,
84 def ARMWrapper : SDNode<"ARMISD::Wrapper", SDTIntUnaryOp>;
85 def ARMWrapperDYN : SDNode<"ARMISD::WrapperDYN", SDTIntUnaryOp>;
86 def ARMWrapperPIC : SDNode<"ARMISD::WrapperPIC", SDTIntUnaryOp>;
87 def ARMWrapperJT : SDNode<"ARMISD::WrapperJT", SDTIntBinOp>;
89 def ARMcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_ARMCallSeqStart,
90 [SDNPHasChain, SDNPOutGlue]>;
91 def ARMcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_ARMCallSeqEnd,
92 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
94 def ARMcall : SDNode<"ARMISD::CALL", SDT_ARMcall,
95 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
97 def ARMcall_pred : SDNode<"ARMISD::CALL_PRED", SDT_ARMcall,
98 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
100 def ARMcall_nolink : SDNode<"ARMISD::CALL_NOLINK", SDT_ARMcall,
101 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
104 def ARMretflag : SDNode<"ARMISD::RET_FLAG", SDTNone,
105 [SDNPHasChain, SDNPOptInGlue]>;
107 def ARMcmov : SDNode<"ARMISD::CMOV", SDT_ARMCMov,
110 def ARMbrcond : SDNode<"ARMISD::BRCOND", SDT_ARMBrcond,
111 [SDNPHasChain, SDNPInGlue, SDNPOutGlue]>;
113 def ARMbrjt : SDNode<"ARMISD::BR_JT", SDT_ARMBrJT,
115 def ARMbr2jt : SDNode<"ARMISD::BR2_JT", SDT_ARMBr2JT,
118 def ARMBcci64 : SDNode<"ARMISD::BCC_i64", SDT_ARMBCC_i64,
121 def ARMcmp : SDNode<"ARMISD::CMP", SDT_ARMCmp,
124 def ARMcmpZ : SDNode<"ARMISD::CMPZ", SDT_ARMCmp,
125 [SDNPOutGlue, SDNPCommutative]>;
127 def ARMpic_add : SDNode<"ARMISD::PIC_ADD", SDT_ARMPICAdd>;
129 def ARMsrl_flag : SDNode<"ARMISD::SRL_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
130 def ARMsra_flag : SDNode<"ARMISD::SRA_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
131 def ARMrrx : SDNode<"ARMISD::RRX" , SDTIntUnaryOp, [SDNPInGlue ]>;
133 def ARMaddc : SDNode<"ARMISD::ADDC", SDTBinaryArithWithFlags,
135 def ARMsubc : SDNode<"ARMISD::SUBC", SDTBinaryArithWithFlags>;
136 def ARMadde : SDNode<"ARMISD::ADDE", SDTBinaryArithWithFlagsInOut>;
137 def ARMsube : SDNode<"ARMISD::SUBE", SDTBinaryArithWithFlagsInOut>;
139 def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>;
140 def ARMeh_sjlj_setjmp: SDNode<"ARMISD::EH_SJLJ_SETJMP",
141 SDT_ARMEH_SJLJ_Setjmp, [SDNPHasChain]>;
142 def ARMeh_sjlj_longjmp: SDNode<"ARMISD::EH_SJLJ_LONGJMP",
143 SDT_ARMEH_SJLJ_Longjmp, [SDNPHasChain]>;
145 def ARMMemBarrier : SDNode<"ARMISD::MEMBARRIER", SDT_ARMMEMBARRIER,
147 def ARMMemBarrierMCR : SDNode<"ARMISD::MEMBARRIER_MCR", SDT_ARMMEMBARRIER,
149 def ARMPreload : SDNode<"ARMISD::PRELOAD", SDT_ARMPREFETCH,
150 [SDNPHasChain, SDNPMayLoad, SDNPMayStore]>;
152 def ARMrbit : SDNode<"ARMISD::RBIT", SDTIntUnaryOp>;
154 def ARMtcret : SDNode<"ARMISD::TC_RETURN", SDT_ARMTCRET,
155 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
158 def ARMbfi : SDNode<"ARMISD::BFI", SDT_ARMBFI>;
160 //===----------------------------------------------------------------------===//
161 // ARM Instruction Predicate Definitions.
163 def HasV4T : Predicate<"Subtarget->hasV4TOps()">,
164 AssemblerPredicate<"HasV4TOps">;
165 def NoV4T : Predicate<"!Subtarget->hasV4TOps()">;
166 def HasV5T : Predicate<"Subtarget->hasV5TOps()">;
167 def HasV5TE : Predicate<"Subtarget->hasV5TEOps()">,
168 AssemblerPredicate<"HasV5TEOps">;
169 def HasV6 : Predicate<"Subtarget->hasV6Ops()">,
170 AssemblerPredicate<"HasV6Ops">;
171 def NoV6 : Predicate<"!Subtarget->hasV6Ops()">;
172 def HasV6T2 : Predicate<"Subtarget->hasV6T2Ops()">,
173 AssemblerPredicate<"HasV6T2Ops">;
174 def NoV6T2 : Predicate<"!Subtarget->hasV6T2Ops()">;
175 def HasV7 : Predicate<"Subtarget->hasV7Ops()">,
176 AssemblerPredicate<"HasV7Ops">;
177 def NoVFP : Predicate<"!Subtarget->hasVFP2()">;
178 def HasVFP2 : Predicate<"Subtarget->hasVFP2()">,
179 AssemblerPredicate<"FeatureVFP2">;
180 def HasVFP3 : Predicate<"Subtarget->hasVFP3()">,
181 AssemblerPredicate<"FeatureVFP3">;
182 def HasVFP4 : Predicate<"Subtarget->hasVFP4()">,
183 AssemblerPredicate<"FeatureVFP4">;
184 def HasNEON : Predicate<"Subtarget->hasNEON()">,
185 AssemblerPredicate<"FeatureNEON">;
186 def HasFP16 : Predicate<"Subtarget->hasFP16()">,
187 AssemblerPredicate<"FeatureFP16">;
188 def HasDivide : Predicate<"Subtarget->hasDivide()">,
189 AssemblerPredicate<"FeatureHWDiv">;
190 def HasT2ExtractPack : Predicate<"Subtarget->hasT2ExtractPack()">,
191 AssemblerPredicate<"FeatureT2XtPk">;
192 def HasThumb2DSP : Predicate<"Subtarget->hasThumb2DSP()">,
193 AssemblerPredicate<"FeatureDSPThumb2">;
194 def HasDB : Predicate<"Subtarget->hasDataBarrier()">,
195 AssemblerPredicate<"FeatureDB">;
196 def HasMP : Predicate<"Subtarget->hasMPExtension()">,
197 AssemblerPredicate<"FeatureMP">;
198 def UseNEONForFP : Predicate<"Subtarget->useNEONForSinglePrecisionFP()">;
199 def DontUseNEONForFP : Predicate<"!Subtarget->useNEONForSinglePrecisionFP()">;
200 def IsThumb : Predicate<"Subtarget->isThumb()">,
201 AssemblerPredicate<"ModeThumb">;
202 def IsThumb1Only : Predicate<"Subtarget->isThumb1Only()">;
203 def IsThumb2 : Predicate<"Subtarget->isThumb2()">,
204 AssemblerPredicate<"ModeThumb,FeatureThumb2">;
205 def IsMClass : Predicate<"Subtarget->isMClass()">,
206 AssemblerPredicate<"FeatureMClass">;
207 def IsARClass : Predicate<"!Subtarget->isMClass()">,
208 AssemblerPredicate<"!FeatureMClass">;
209 def IsARM : Predicate<"!Subtarget->isThumb()">,
210 AssemblerPredicate<"!ModeThumb">;
211 def IsIOS : Predicate<"Subtarget->isTargetIOS()">;
212 def IsNotIOS : Predicate<"!Subtarget->isTargetIOS()">;
213 def IsNaCl : Predicate<"Subtarget->isTargetNaCl()">;
215 // FIXME: Eventually this will be just "hasV6T2Ops".
216 def UseMovt : Predicate<"Subtarget->useMovt()">;
217 def DontUseMovt : Predicate<"!Subtarget->useMovt()">;
218 def UseFPVMLx : Predicate<"Subtarget->useFPVMLx()">;
220 // Prefer fused MAC for fp mul + add over fp VMLA / VMLS if they are available.
221 // But only select them if more precision in FP computation is allowed.
222 // Do not use them for Darwin platforms.
223 def UseFusedMAC : Predicate<"!TM.Options.NoExcessFPPrecision && "
224 "!Subtarget->isTargetDarwin()">;
225 def DontUseFusedMAC : Predicate<"!Subtarget->hasVFP4() || "
226 "Subtarget->isTargetDarwin()">;
228 //===----------------------------------------------------------------------===//
229 // ARM Flag Definitions.
231 class RegConstraint<string C> {
232 string Constraints = C;
235 //===----------------------------------------------------------------------===//
236 // ARM specific transformation functions and pattern fragments.
239 // so_imm_neg_XFORM - Return a so_imm value packed into the format described for
240 // so_imm_neg def below.
241 def so_imm_neg_XFORM : SDNodeXForm<imm, [{
242 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), MVT::i32);
245 // so_imm_not_XFORM - Return a so_imm value packed into the format described for
246 // so_imm_not def below.
247 def so_imm_not_XFORM : SDNodeXForm<imm, [{
248 return CurDAG->getTargetConstant(~(int)N->getZExtValue(), MVT::i32);
251 /// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
252 def imm16_31 : ImmLeaf<i32, [{
253 return (int32_t)Imm >= 16 && (int32_t)Imm < 32;
256 def so_imm_neg_asmoperand : AsmOperandClass { let Name = "ARMSOImmNeg"; }
257 def so_imm_neg : Operand<i32>, PatLeaf<(imm), [{
258 int64_t Value = -(int)N->getZExtValue();
259 return Value && ARM_AM::getSOImmVal(Value) != -1;
260 }], so_imm_neg_XFORM> {
261 let ParserMatchClass = so_imm_neg_asmoperand;
264 // Note: this pattern doesn't require an encoder method and such, as it's
265 // only used on aliases (Pat<> and InstAlias<>). The actual encoding
266 // is handled by the destination instructions, which use so_imm.
267 def so_imm_not_asmoperand : AsmOperandClass { let Name = "ARMSOImmNot"; }
268 def so_imm_not : Operand<i32>, PatLeaf<(imm), [{
269 return ARM_AM::getSOImmVal(~(uint32_t)N->getZExtValue()) != -1;
270 }], so_imm_not_XFORM> {
271 let ParserMatchClass = so_imm_not_asmoperand;
274 // sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
275 def sext_16_node : PatLeaf<(i32 GPR:$a), [{
276 return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17;
279 /// Split a 32-bit immediate into two 16 bit parts.
280 def hi16 : SDNodeXForm<imm, [{
281 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, MVT::i32);
284 def lo16AllZero : PatLeaf<(i32 imm), [{
285 // Returns true if all low 16-bits are 0.
286 return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
289 class BinOpWithFlagFrag<dag res> :
290 PatFrag<(ops node:$LHS, node:$RHS, node:$FLAG), res>;
291 class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
292 class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
294 // An 'and' node with a single use.
295 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
296 return N->hasOneUse();
299 // An 'xor' node with a single use.
300 def xor_su : PatFrag<(ops node:$lhs, node:$rhs), (xor node:$lhs, node:$rhs), [{
301 return N->hasOneUse();
304 // An 'fmul' node with a single use.
305 def fmul_su : PatFrag<(ops node:$lhs, node:$rhs), (fmul node:$lhs, node:$rhs),[{
306 return N->hasOneUse();
309 // An 'fadd' node which checks for single non-hazardous use.
310 def fadd_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fadd node:$lhs, node:$rhs),[{
311 return hasNoVMLxHazardUse(N);
314 // An 'fsub' node which checks for single non-hazardous use.
315 def fsub_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fsub node:$lhs, node:$rhs),[{
316 return hasNoVMLxHazardUse(N);
319 //===----------------------------------------------------------------------===//
320 // Operand Definitions.
323 // Immediate operands with a shared generic asm render method.
324 class ImmAsmOperand : AsmOperandClass { let RenderMethod = "addImmOperands"; }
327 // FIXME: rename brtarget to t2_brtarget
328 def brtarget : Operand<OtherVT> {
329 let EncoderMethod = "getBranchTargetOpValue";
330 let OperandType = "OPERAND_PCREL";
331 let DecoderMethod = "DecodeT2BROperand";
334 // FIXME: get rid of this one?
335 def uncondbrtarget : Operand<OtherVT> {
336 let EncoderMethod = "getUnconditionalBranchTargetOpValue";
337 let OperandType = "OPERAND_PCREL";
340 // Branch target for ARM. Handles conditional/unconditional
341 def br_target : Operand<OtherVT> {
342 let EncoderMethod = "getARMBranchTargetOpValue";
343 let OperandType = "OPERAND_PCREL";
347 // FIXME: rename bltarget to t2_bl_target?
348 def bltarget : Operand<i32> {
349 // Encoded the same as branch targets.
350 let EncoderMethod = "getBranchTargetOpValue";
351 let OperandType = "OPERAND_PCREL";
354 // Call target for ARM. Handles conditional/unconditional
355 // FIXME: rename bl_target to t2_bltarget?
356 def bl_target : Operand<i32> {
357 let EncoderMethod = "getARMBLTargetOpValue";
358 let OperandType = "OPERAND_PCREL";
361 def blx_target : Operand<i32> {
362 let EncoderMethod = "getARMBLXTargetOpValue";
363 let OperandType = "OPERAND_PCREL";
366 // A list of registers separated by comma. Used by load/store multiple.
367 def RegListAsmOperand : AsmOperandClass { let Name = "RegList"; }
368 def reglist : Operand<i32> {
369 let EncoderMethod = "getRegisterListOpValue";
370 let ParserMatchClass = RegListAsmOperand;
371 let PrintMethod = "printRegisterList";
372 let DecoderMethod = "DecodeRegListOperand";
375 def DPRRegListAsmOperand : AsmOperandClass { let Name = "DPRRegList"; }
376 def dpr_reglist : Operand<i32> {
377 let EncoderMethod = "getRegisterListOpValue";
378 let ParserMatchClass = DPRRegListAsmOperand;
379 let PrintMethod = "printRegisterList";
380 let DecoderMethod = "DecodeDPRRegListOperand";
383 def SPRRegListAsmOperand : AsmOperandClass { let Name = "SPRRegList"; }
384 def spr_reglist : Operand<i32> {
385 let EncoderMethod = "getRegisterListOpValue";
386 let ParserMatchClass = SPRRegListAsmOperand;
387 let PrintMethod = "printRegisterList";
388 let DecoderMethod = "DecodeSPRRegListOperand";
391 // An operand for the CONSTPOOL_ENTRY pseudo-instruction.
392 def cpinst_operand : Operand<i32> {
393 let PrintMethod = "printCPInstOperand";
397 def pclabel : Operand<i32> {
398 let PrintMethod = "printPCLabel";
401 // ADR instruction labels.
402 def adrlabel : Operand<i32> {
403 let EncoderMethod = "getAdrLabelOpValue";
406 def neon_vcvt_imm32 : Operand<i32> {
407 let EncoderMethod = "getNEONVcvtImm32OpValue";
408 let DecoderMethod = "DecodeVCVTImmOperand";
411 // rot_imm: An integer that encodes a rotate amount. Must be 8, 16, or 24.
412 def rot_imm_XFORM: SDNodeXForm<imm, [{
413 switch (N->getZExtValue()){
415 case 0: return CurDAG->getTargetConstant(0, MVT::i32);
416 case 8: return CurDAG->getTargetConstant(1, MVT::i32);
417 case 16: return CurDAG->getTargetConstant(2, MVT::i32);
418 case 24: return CurDAG->getTargetConstant(3, MVT::i32);
421 def RotImmAsmOperand : AsmOperandClass {
423 let ParserMethod = "parseRotImm";
425 def rot_imm : Operand<i32>, PatLeaf<(i32 imm), [{
426 int32_t v = N->getZExtValue();
427 return v == 8 || v == 16 || v == 24; }],
429 let PrintMethod = "printRotImmOperand";
430 let ParserMatchClass = RotImmAsmOperand;
433 // shift_imm: An integer that encodes a shift amount and the type of shift
434 // (asr or lsl). The 6-bit immediate encodes as:
437 // {4-0} imm5 shift amount.
438 // asr #32 encoded as imm5 == 0.
439 def ShifterImmAsmOperand : AsmOperandClass {
440 let Name = "ShifterImm";
441 let ParserMethod = "parseShifterImm";
443 def shift_imm : Operand<i32> {
444 let PrintMethod = "printShiftImmOperand";
445 let ParserMatchClass = ShifterImmAsmOperand;
448 // shifter_operand operands: so_reg_reg, so_reg_imm, and so_imm.
449 def ShiftedRegAsmOperand : AsmOperandClass { let Name = "RegShiftedReg"; }
450 def so_reg_reg : Operand<i32>, // reg reg imm
451 ComplexPattern<i32, 3, "SelectRegShifterOperand",
452 [shl, srl, sra, rotr]> {
453 let EncoderMethod = "getSORegRegOpValue";
454 let PrintMethod = "printSORegRegOperand";
455 let DecoderMethod = "DecodeSORegRegOperand";
456 let ParserMatchClass = ShiftedRegAsmOperand;
457 let MIOperandInfo = (ops GPRnopc, GPRnopc, i32imm);
460 def ShiftedImmAsmOperand : AsmOperandClass { let Name = "RegShiftedImm"; }
461 def so_reg_imm : Operand<i32>, // reg imm
462 ComplexPattern<i32, 2, "SelectImmShifterOperand",
463 [shl, srl, sra, rotr]> {
464 let EncoderMethod = "getSORegImmOpValue";
465 let PrintMethod = "printSORegImmOperand";
466 let DecoderMethod = "DecodeSORegImmOperand";
467 let ParserMatchClass = ShiftedImmAsmOperand;
468 let MIOperandInfo = (ops GPR, i32imm);
471 // FIXME: Does this need to be distinct from so_reg?
472 def shift_so_reg_reg : Operand<i32>, // reg reg imm
473 ComplexPattern<i32, 3, "SelectShiftRegShifterOperand",
474 [shl,srl,sra,rotr]> {
475 let EncoderMethod = "getSORegRegOpValue";
476 let PrintMethod = "printSORegRegOperand";
477 let DecoderMethod = "DecodeSORegRegOperand";
478 let ParserMatchClass = ShiftedRegAsmOperand;
479 let MIOperandInfo = (ops GPR, GPR, i32imm);
482 // FIXME: Does this need to be distinct from so_reg?
483 def shift_so_reg_imm : Operand<i32>, // reg reg imm
484 ComplexPattern<i32, 2, "SelectShiftImmShifterOperand",
485 [shl,srl,sra,rotr]> {
486 let EncoderMethod = "getSORegImmOpValue";
487 let PrintMethod = "printSORegImmOperand";
488 let DecoderMethod = "DecodeSORegImmOperand";
489 let ParserMatchClass = ShiftedImmAsmOperand;
490 let MIOperandInfo = (ops GPR, i32imm);
494 // so_imm - Match a 32-bit shifter_operand immediate operand, which is an
495 // 8-bit immediate rotated by an arbitrary number of bits.
496 def SOImmAsmOperand: ImmAsmOperand { let Name = "ARMSOImm"; }
497 def so_imm : Operand<i32>, ImmLeaf<i32, [{
498 return ARM_AM::getSOImmVal(Imm) != -1;
500 let EncoderMethod = "getSOImmOpValue";
501 let ParserMatchClass = SOImmAsmOperand;
502 let DecoderMethod = "DecodeSOImmOperand";
505 // Break so_imm's up into two pieces. This handles immediates with up to 16
506 // bits set in them. This uses so_imm2part to match and so_imm2part_[12] to
507 // get the first/second pieces.
508 def so_imm2part : PatLeaf<(imm), [{
509 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
512 /// arm_i32imm - True for +V6T2, or true only if so_imm2part is true.
514 def arm_i32imm : PatLeaf<(imm), [{
515 if (Subtarget->hasV6T2Ops())
517 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
520 /// imm0_1 predicate - Immediate in the range [0,1].
521 def Imm0_1AsmOperand: ImmAsmOperand { let Name = "Imm0_1"; }
522 def imm0_1 : Operand<i32> { let ParserMatchClass = Imm0_1AsmOperand; }
524 /// imm0_3 predicate - Immediate in the range [0,3].
525 def Imm0_3AsmOperand: ImmAsmOperand { let Name = "Imm0_3"; }
526 def imm0_3 : Operand<i32> { let ParserMatchClass = Imm0_3AsmOperand; }
528 /// imm0_7 predicate - Immediate in the range [0,7].
529 def Imm0_7AsmOperand: ImmAsmOperand { let Name = "Imm0_7"; }
530 def imm0_7 : Operand<i32>, ImmLeaf<i32, [{
531 return Imm >= 0 && Imm < 8;
533 let ParserMatchClass = Imm0_7AsmOperand;
536 /// imm8 predicate - Immediate is exactly 8.
537 def Imm8AsmOperand: ImmAsmOperand { let Name = "Imm8"; }
538 def imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 8; }]> {
539 let ParserMatchClass = Imm8AsmOperand;
542 /// imm16 predicate - Immediate is exactly 16.
543 def Imm16AsmOperand: ImmAsmOperand { let Name = "Imm16"; }
544 def imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 16; }]> {
545 let ParserMatchClass = Imm16AsmOperand;
548 /// imm32 predicate - Immediate is exactly 32.
549 def Imm32AsmOperand: ImmAsmOperand { let Name = "Imm32"; }
550 def imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 32; }]> {
551 let ParserMatchClass = Imm32AsmOperand;
554 /// imm1_7 predicate - Immediate in the range [1,7].
555 def Imm1_7AsmOperand: ImmAsmOperand { let Name = "Imm1_7"; }
556 def imm1_7 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 8; }]> {
557 let ParserMatchClass = Imm1_7AsmOperand;
560 /// imm1_15 predicate - Immediate in the range [1,15].
561 def Imm1_15AsmOperand: ImmAsmOperand { let Name = "Imm1_15"; }
562 def imm1_15 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 16; }]> {
563 let ParserMatchClass = Imm1_15AsmOperand;
566 /// imm1_31 predicate - Immediate in the range [1,31].
567 def Imm1_31AsmOperand: ImmAsmOperand { let Name = "Imm1_31"; }
568 def imm1_31 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 32; }]> {
569 let ParserMatchClass = Imm1_31AsmOperand;
572 /// imm0_15 predicate - Immediate in the range [0,15].
573 def Imm0_15AsmOperand: ImmAsmOperand { let Name = "Imm0_15"; }
574 def imm0_15 : Operand<i32>, ImmLeaf<i32, [{
575 return Imm >= 0 && Imm < 16;
577 let ParserMatchClass = Imm0_15AsmOperand;
580 /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
581 def Imm0_31AsmOperand: ImmAsmOperand { let Name = "Imm0_31"; }
582 def imm0_31 : Operand<i32>, ImmLeaf<i32, [{
583 return Imm >= 0 && Imm < 32;
585 let ParserMatchClass = Imm0_31AsmOperand;
588 /// imm0_32 predicate - True if the 32-bit immediate is in the range [0,32].
589 def Imm0_32AsmOperand: ImmAsmOperand { let Name = "Imm0_32"; }
590 def imm0_32 : Operand<i32>, ImmLeaf<i32, [{
591 return Imm >= 0 && Imm < 32;
593 let ParserMatchClass = Imm0_32AsmOperand;
596 /// imm0_63 predicate - True if the 32-bit immediate is in the range [0,63].
597 def Imm0_63AsmOperand: ImmAsmOperand { let Name = "Imm0_63"; }
598 def imm0_63 : Operand<i32>, ImmLeaf<i32, [{
599 return Imm >= 0 && Imm < 64;
601 let ParserMatchClass = Imm0_63AsmOperand;
604 /// imm0_255 predicate - Immediate in the range [0,255].
605 def Imm0_255AsmOperand : ImmAsmOperand { let Name = "Imm0_255"; }
606 def imm0_255 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 256; }]> {
607 let ParserMatchClass = Imm0_255AsmOperand;
610 /// imm0_65535 - An immediate is in the range [0.65535].
611 def Imm0_65535AsmOperand: ImmAsmOperand { let Name = "Imm0_65535"; }
612 def imm0_65535 : Operand<i32>, ImmLeaf<i32, [{
613 return Imm >= 0 && Imm < 65536;
615 let ParserMatchClass = Imm0_65535AsmOperand;
618 // imm0_65535_expr - For movt/movw - 16-bit immediate that can also reference
619 // a relocatable expression.
621 // FIXME: This really needs a Thumb version separate from the ARM version.
622 // While the range is the same, and can thus use the same match class,
623 // the encoding is different so it should have a different encoder method.
624 def Imm0_65535ExprAsmOperand: ImmAsmOperand { let Name = "Imm0_65535Expr"; }
625 def imm0_65535_expr : Operand<i32> {
626 let EncoderMethod = "getHiLo16ImmOpValue";
627 let ParserMatchClass = Imm0_65535ExprAsmOperand;
630 /// imm24b - True if the 32-bit immediate is encodable in 24 bits.
631 def Imm24bitAsmOperand: ImmAsmOperand { let Name = "Imm24bit"; }
632 def imm24b : Operand<i32>, ImmLeaf<i32, [{
633 return Imm >= 0 && Imm <= 0xffffff;
635 let ParserMatchClass = Imm24bitAsmOperand;
639 /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
641 def BitfieldAsmOperand : AsmOperandClass {
642 let Name = "Bitfield";
643 let ParserMethod = "parseBitfield";
646 def bf_inv_mask_imm : Operand<i32>,
648 return ARM::isBitFieldInvertedMask(N->getZExtValue());
650 let EncoderMethod = "getBitfieldInvertedMaskOpValue";
651 let PrintMethod = "printBitfieldInvMaskImmOperand";
652 let DecoderMethod = "DecodeBitfieldMaskOperand";
653 let ParserMatchClass = BitfieldAsmOperand;
656 def imm1_32_XFORM: SDNodeXForm<imm, [{
657 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, MVT::i32);
659 def Imm1_32AsmOperand: AsmOperandClass { let Name = "Imm1_32"; }
660 def imm1_32 : Operand<i32>, PatLeaf<(imm), [{
661 uint64_t Imm = N->getZExtValue();
662 return Imm > 0 && Imm <= 32;
665 let PrintMethod = "printImmPlusOneOperand";
666 let ParserMatchClass = Imm1_32AsmOperand;
669 def imm1_16_XFORM: SDNodeXForm<imm, [{
670 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, MVT::i32);
672 def Imm1_16AsmOperand: AsmOperandClass { let Name = "Imm1_16"; }
673 def imm1_16 : Operand<i32>, PatLeaf<(imm), [{ return Imm > 0 && Imm <= 16; }],
675 let PrintMethod = "printImmPlusOneOperand";
676 let ParserMatchClass = Imm1_16AsmOperand;
679 // Define ARM specific addressing modes.
680 // addrmode_imm12 := reg +/- imm12
682 def MemImm12OffsetAsmOperand : AsmOperandClass { let Name = "MemImm12Offset"; }
683 def addrmode_imm12 : Operand<i32>,
684 ComplexPattern<i32, 2, "SelectAddrModeImm12", []> {
685 // 12-bit immediate operand. Note that instructions using this encode
686 // #0 and #-0 differently. We flag #-0 as the magic value INT32_MIN. All other
687 // immediate values are as normal.
689 let EncoderMethod = "getAddrModeImm12OpValue";
690 let PrintMethod = "printAddrModeImm12Operand";
691 let DecoderMethod = "DecodeAddrModeImm12Operand";
692 let ParserMatchClass = MemImm12OffsetAsmOperand;
693 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
695 // ldst_so_reg := reg +/- reg shop imm
697 def MemRegOffsetAsmOperand : AsmOperandClass { let Name = "MemRegOffset"; }
698 def ldst_so_reg : Operand<i32>,
699 ComplexPattern<i32, 3, "SelectLdStSOReg", []> {
700 let EncoderMethod = "getLdStSORegOpValue";
701 // FIXME: Simplify the printer
702 let PrintMethod = "printAddrMode2Operand";
703 let DecoderMethod = "DecodeSORegMemOperand";
704 let ParserMatchClass = MemRegOffsetAsmOperand;
705 let MIOperandInfo = (ops GPR:$base, GPRnopc:$offsreg, i32imm:$shift);
708 // postidx_imm8 := +/- [0,255]
711 // {8} 1 is imm8 is non-negative. 0 otherwise.
712 // {7-0} [0,255] imm8 value.
713 def PostIdxImm8AsmOperand : AsmOperandClass { let Name = "PostIdxImm8"; }
714 def postidx_imm8 : Operand<i32> {
715 let PrintMethod = "printPostIdxImm8Operand";
716 let ParserMatchClass = PostIdxImm8AsmOperand;
717 let MIOperandInfo = (ops i32imm);
720 // postidx_imm8s4 := +/- [0,1020]
723 // {8} 1 is imm8 is non-negative. 0 otherwise.
724 // {7-0} [0,255] imm8 value, scaled by 4.
725 def PostIdxImm8s4AsmOperand : AsmOperandClass { let Name = "PostIdxImm8s4"; }
726 def postidx_imm8s4 : Operand<i32> {
727 let PrintMethod = "printPostIdxImm8s4Operand";
728 let ParserMatchClass = PostIdxImm8s4AsmOperand;
729 let MIOperandInfo = (ops i32imm);
733 // postidx_reg := +/- reg
735 def PostIdxRegAsmOperand : AsmOperandClass {
736 let Name = "PostIdxReg";
737 let ParserMethod = "parsePostIdxReg";
739 def postidx_reg : Operand<i32> {
740 let EncoderMethod = "getPostIdxRegOpValue";
741 let DecoderMethod = "DecodePostIdxReg";
742 let PrintMethod = "printPostIdxRegOperand";
743 let ParserMatchClass = PostIdxRegAsmOperand;
744 let MIOperandInfo = (ops GPRnopc, i32imm);
748 // addrmode2 := reg +/- imm12
749 // := reg +/- reg shop imm
751 // FIXME: addrmode2 should be refactored the rest of the way to always
752 // use explicit imm vs. reg versions above (addrmode_imm12 and ldst_so_reg).
753 def AddrMode2AsmOperand : AsmOperandClass { let Name = "AddrMode2"; }
754 def addrmode2 : Operand<i32>,
755 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
756 let EncoderMethod = "getAddrMode2OpValue";
757 let PrintMethod = "printAddrMode2Operand";
758 let ParserMatchClass = AddrMode2AsmOperand;
759 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
762 def PostIdxRegShiftedAsmOperand : AsmOperandClass {
763 let Name = "PostIdxRegShifted";
764 let ParserMethod = "parsePostIdxReg";
766 def am2offset_reg : Operand<i32>,
767 ComplexPattern<i32, 2, "SelectAddrMode2OffsetReg",
768 [], [SDNPWantRoot]> {
769 let EncoderMethod = "getAddrMode2OffsetOpValue";
770 let PrintMethod = "printAddrMode2OffsetOperand";
771 // When using this for assembly, it's always as a post-index offset.
772 let ParserMatchClass = PostIdxRegShiftedAsmOperand;
773 let MIOperandInfo = (ops GPRnopc, i32imm);
776 // FIXME: am2offset_imm should only need the immediate, not the GPR. Having
777 // the GPR is purely vestigal at this point.
778 def AM2OffsetImmAsmOperand : AsmOperandClass { let Name = "AM2OffsetImm"; }
779 def am2offset_imm : Operand<i32>,
780 ComplexPattern<i32, 2, "SelectAddrMode2OffsetImm",
781 [], [SDNPWantRoot]> {
782 let EncoderMethod = "getAddrMode2OffsetOpValue";
783 let PrintMethod = "printAddrMode2OffsetOperand";
784 let ParserMatchClass = AM2OffsetImmAsmOperand;
785 let MIOperandInfo = (ops GPRnopc, i32imm);
789 // addrmode3 := reg +/- reg
790 // addrmode3 := reg +/- imm8
792 // FIXME: split into imm vs. reg versions.
793 def AddrMode3AsmOperand : AsmOperandClass { let Name = "AddrMode3"; }
794 def addrmode3 : Operand<i32>,
795 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
796 let EncoderMethod = "getAddrMode3OpValue";
797 let PrintMethod = "printAddrMode3Operand";
798 let ParserMatchClass = AddrMode3AsmOperand;
799 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
802 // FIXME: split into imm vs. reg versions.
803 // FIXME: parser method to handle +/- register.
804 def AM3OffsetAsmOperand : AsmOperandClass {
805 let Name = "AM3Offset";
806 let ParserMethod = "parseAM3Offset";
808 def am3offset : Operand<i32>,
809 ComplexPattern<i32, 2, "SelectAddrMode3Offset",
810 [], [SDNPWantRoot]> {
811 let EncoderMethod = "getAddrMode3OffsetOpValue";
812 let PrintMethod = "printAddrMode3OffsetOperand";
813 let ParserMatchClass = AM3OffsetAsmOperand;
814 let MIOperandInfo = (ops GPR, i32imm);
817 // ldstm_mode := {ia, ib, da, db}
819 def ldstm_mode : OptionalDefOperand<OtherVT, (ops i32), (ops (i32 1))> {
820 let EncoderMethod = "getLdStmModeOpValue";
821 let PrintMethod = "printLdStmModeOperand";
824 // addrmode5 := reg +/- imm8*4
826 def AddrMode5AsmOperand : AsmOperandClass { let Name = "AddrMode5"; }
827 def addrmode5 : Operand<i32>,
828 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
829 let PrintMethod = "printAddrMode5Operand";
830 let EncoderMethod = "getAddrMode5OpValue";
831 let DecoderMethod = "DecodeAddrMode5Operand";
832 let ParserMatchClass = AddrMode5AsmOperand;
833 let MIOperandInfo = (ops GPR:$base, i32imm);
836 // addrmode6 := reg with optional alignment
838 def AddrMode6AsmOperand : AsmOperandClass { let Name = "AlignedMemory"; }
839 def addrmode6 : Operand<i32>,
840 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
841 let PrintMethod = "printAddrMode6Operand";
842 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
843 let EncoderMethod = "getAddrMode6AddressOpValue";
844 let DecoderMethod = "DecodeAddrMode6Operand";
845 let ParserMatchClass = AddrMode6AsmOperand;
848 def am6offset : Operand<i32>,
849 ComplexPattern<i32, 1, "SelectAddrMode6Offset",
850 [], [SDNPWantRoot]> {
851 let PrintMethod = "printAddrMode6OffsetOperand";
852 let MIOperandInfo = (ops GPR);
853 let EncoderMethod = "getAddrMode6OffsetOpValue";
854 let DecoderMethod = "DecodeGPRRegisterClass";
857 // Special version of addrmode6 to handle alignment encoding for VST1/VLD1
858 // (single element from one lane) for size 32.
859 def addrmode6oneL32 : Operand<i32>,
860 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
861 let PrintMethod = "printAddrMode6Operand";
862 let MIOperandInfo = (ops GPR:$addr, i32imm);
863 let EncoderMethod = "getAddrMode6OneLane32AddressOpValue";
866 // Special version of addrmode6 to handle alignment encoding for VLD-dup
867 // instructions, specifically VLD4-dup.
868 def addrmode6dup : Operand<i32>,
869 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
870 let PrintMethod = "printAddrMode6Operand";
871 let MIOperandInfo = (ops GPR:$addr, i32imm);
872 let EncoderMethod = "getAddrMode6DupAddressOpValue";
873 // FIXME: This is close, but not quite right. The alignment specifier is
875 let ParserMatchClass = AddrMode6AsmOperand;
878 // addrmodepc := pc + reg
880 def addrmodepc : Operand<i32>,
881 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
882 let PrintMethod = "printAddrModePCOperand";
883 let MIOperandInfo = (ops GPR, i32imm);
886 // addr_offset_none := reg
888 def MemNoOffsetAsmOperand : AsmOperandClass { let Name = "MemNoOffset"; }
889 def addr_offset_none : Operand<i32>,
890 ComplexPattern<i32, 1, "SelectAddrOffsetNone", []> {
891 let PrintMethod = "printAddrMode7Operand";
892 let DecoderMethod = "DecodeAddrMode7Operand";
893 let ParserMatchClass = MemNoOffsetAsmOperand;
894 let MIOperandInfo = (ops GPR:$base);
897 def nohash_imm : Operand<i32> {
898 let PrintMethod = "printNoHashImmediate";
901 def CoprocNumAsmOperand : AsmOperandClass {
902 let Name = "CoprocNum";
903 let ParserMethod = "parseCoprocNumOperand";
905 def p_imm : Operand<i32> {
906 let PrintMethod = "printPImmediate";
907 let ParserMatchClass = CoprocNumAsmOperand;
908 let DecoderMethod = "DecodeCoprocessor";
911 def CoprocRegAsmOperand : AsmOperandClass {
912 let Name = "CoprocReg";
913 let ParserMethod = "parseCoprocRegOperand";
915 def c_imm : Operand<i32> {
916 let PrintMethod = "printCImmediate";
917 let ParserMatchClass = CoprocRegAsmOperand;
919 def CoprocOptionAsmOperand : AsmOperandClass {
920 let Name = "CoprocOption";
921 let ParserMethod = "parseCoprocOptionOperand";
923 def coproc_option_imm : Operand<i32> {
924 let PrintMethod = "printCoprocOptionImm";
925 let ParserMatchClass = CoprocOptionAsmOperand;
928 //===----------------------------------------------------------------------===//
930 include "ARMInstrFormats.td"
932 //===----------------------------------------------------------------------===//
933 // Multiclass helpers...
936 /// AsI1_bin_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns for a
937 /// binop that produces a value.
938 multiclass AsI1_bin_irs<bits<4> opcod, string opc,
939 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
940 PatFrag opnode, string baseOpc, bit Commutable = 0> {
941 // The register-immediate version is re-materializable. This is useful
942 // in particular for taking the address of a local.
943 let isReMaterializable = 1 in {
944 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
945 iii, opc, "\t$Rd, $Rn, $imm",
946 [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]> {
951 let Inst{19-16} = Rn;
952 let Inst{15-12} = Rd;
953 let Inst{11-0} = imm;
956 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
957 iir, opc, "\t$Rd, $Rn, $Rm",
958 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]> {
963 let isCommutable = Commutable;
964 let Inst{19-16} = Rn;
965 let Inst{15-12} = Rd;
966 let Inst{11-4} = 0b00000000;
970 def rsi : AsI1<opcod, (outs GPR:$Rd),
971 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
972 iis, opc, "\t$Rd, $Rn, $shift",
973 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_imm:$shift))]> {
978 let Inst{19-16} = Rn;
979 let Inst{15-12} = Rd;
980 let Inst{11-5} = shift{11-5};
982 let Inst{3-0} = shift{3-0};
985 def rsr : AsI1<opcod, (outs GPR:$Rd),
986 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
987 iis, opc, "\t$Rd, $Rn, $shift",
988 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_reg:$shift))]> {
993 let Inst{19-16} = Rn;
994 let Inst{15-12} = Rd;
995 let Inst{11-8} = shift{11-8};
997 let Inst{6-5} = shift{6-5};
999 let Inst{3-0} = shift{3-0};
1002 // Assembly aliases for optional destination operand when it's the same
1003 // as the source operand.
1004 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $imm"),
1005 (!cast<Instruction>(!strconcat(baseOpc, "ri")) GPR:$Rdn, GPR:$Rdn,
1006 so_imm:$imm, pred:$p,
1009 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $Rm"),
1010 (!cast<Instruction>(!strconcat(baseOpc, "rr")) GPR:$Rdn, GPR:$Rdn,
1014 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1015 (!cast<Instruction>(!strconcat(baseOpc, "rsi")) GPR:$Rdn, GPR:$Rdn,
1016 so_reg_imm:$shift, pred:$p,
1019 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1020 (!cast<Instruction>(!strconcat(baseOpc, "rsr")) GPR:$Rdn, GPR:$Rdn,
1021 so_reg_reg:$shift, pred:$p,
1027 /// AsI1_rbin_irs - Same as AsI1_bin_irs except the order of operands are
1028 /// reversed. The 'rr' form is only defined for the disassembler; for codegen
1029 /// it is equivalent to the AsI1_bin_irs counterpart.
1030 multiclass AsI1_rbin_irs<bits<4> opcod, string opc,
1031 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1032 PatFrag opnode, string baseOpc, bit Commutable = 0> {
1033 // The register-immediate version is re-materializable. This is useful
1034 // in particular for taking the address of a local.
1035 let isReMaterializable = 1 in {
1036 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
1037 iii, opc, "\t$Rd, $Rn, $imm",
1038 [(set GPR:$Rd, (opnode so_imm:$imm, GPR:$Rn))]> {
1043 let Inst{19-16} = Rn;
1044 let Inst{15-12} = Rd;
1045 let Inst{11-0} = imm;
1048 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1049 iir, opc, "\t$Rd, $Rn, $Rm",
1050 [/* pattern left blank */]> {
1054 let Inst{11-4} = 0b00000000;
1057 let Inst{15-12} = Rd;
1058 let Inst{19-16} = Rn;
1061 def rsi : AsI1<opcod, (outs GPR:$Rd),
1062 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1063 iis, opc, "\t$Rd, $Rn, $shift",
1064 [(set GPR:$Rd, (opnode so_reg_imm:$shift, GPR:$Rn))]> {
1069 let Inst{19-16} = Rn;
1070 let Inst{15-12} = Rd;
1071 let Inst{11-5} = shift{11-5};
1073 let Inst{3-0} = shift{3-0};
1076 def rsr : AsI1<opcod, (outs GPR:$Rd),
1077 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1078 iis, opc, "\t$Rd, $Rn, $shift",
1079 [(set GPR:$Rd, (opnode so_reg_reg:$shift, GPR:$Rn))]> {
1084 let Inst{19-16} = Rn;
1085 let Inst{15-12} = Rd;
1086 let Inst{11-8} = shift{11-8};
1088 let Inst{6-5} = shift{6-5};
1090 let Inst{3-0} = shift{3-0};
1093 // Assembly aliases for optional destination operand when it's the same
1094 // as the source operand.
1095 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $imm"),
1096 (!cast<Instruction>(!strconcat(baseOpc, "ri")) GPR:$Rdn, GPR:$Rdn,
1097 so_imm:$imm, pred:$p,
1100 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $Rm"),
1101 (!cast<Instruction>(!strconcat(baseOpc, "rr")) GPR:$Rdn, GPR:$Rdn,
1105 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1106 (!cast<Instruction>(!strconcat(baseOpc, "rsi")) GPR:$Rdn, GPR:$Rdn,
1107 so_reg_imm:$shift, pred:$p,
1110 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1111 (!cast<Instruction>(!strconcat(baseOpc, "rsr")) GPR:$Rdn, GPR:$Rdn,
1112 so_reg_reg:$shift, pred:$p,
1118 /// AsI1_bin_s_irs - Same as AsI1_bin_irs except it sets the 's' bit by default.
1120 /// These opcodes will be converted to the real non-S opcodes by
1121 /// AdjustInstrPostInstrSelection after giving them an optional CPSR operand.
1122 let hasPostISelHook = 1, Defs = [CPSR] in {
1123 multiclass AsI1_bin_s_irs<InstrItinClass iii, InstrItinClass iir,
1124 InstrItinClass iis, PatFrag opnode,
1125 bit Commutable = 0> {
1126 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm, pred:$p),
1128 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_imm:$imm))]>;
1130 def rr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, pred:$p),
1132 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm))]> {
1133 let isCommutable = Commutable;
1135 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1136 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1138 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1139 so_reg_imm:$shift))]>;
1141 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1142 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1144 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1145 so_reg_reg:$shift))]>;
1149 /// AsI1_rbin_s_is - Same as AsI1_bin_s_irs, except selection DAG
1150 /// operands are reversed.
1151 let hasPostISelHook = 1, Defs = [CPSR] in {
1152 multiclass AsI1_rbin_s_is<InstrItinClass iii, InstrItinClass iir,
1153 InstrItinClass iis, PatFrag opnode,
1154 bit Commutable = 0> {
1155 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm, pred:$p),
1157 [(set GPR:$Rd, CPSR, (opnode so_imm:$imm, GPR:$Rn))]>;
1159 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1160 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1162 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift,
1165 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1166 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1168 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift,
1173 /// AI1_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
1174 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
1175 /// a explicit result, only implicitly set CPSR.
1176 let isCompare = 1, Defs = [CPSR] in {
1177 multiclass AI1_cmp_irs<bits<4> opcod, string opc,
1178 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1179 PatFrag opnode, bit Commutable = 0> {
1180 def ri : AI1<opcod, (outs), (ins GPR:$Rn, so_imm:$imm), DPFrm, iii,
1182 [(opnode GPR:$Rn, so_imm:$imm)]> {
1187 let Inst{19-16} = Rn;
1188 let Inst{15-12} = 0b0000;
1189 let Inst{11-0} = imm;
1191 let Unpredictable{15-12} = 0b1111;
1193 def rr : AI1<opcod, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, iir,
1195 [(opnode GPR:$Rn, GPR:$Rm)]> {
1198 let isCommutable = Commutable;
1201 let Inst{19-16} = Rn;
1202 let Inst{15-12} = 0b0000;
1203 let Inst{11-4} = 0b00000000;
1206 let Unpredictable{15-12} = 0b1111;
1208 def rsi : AI1<opcod, (outs),
1209 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, iis,
1210 opc, "\t$Rn, $shift",
1211 [(opnode GPR:$Rn, so_reg_imm:$shift)]> {
1216 let Inst{19-16} = Rn;
1217 let Inst{15-12} = 0b0000;
1218 let Inst{11-5} = shift{11-5};
1220 let Inst{3-0} = shift{3-0};
1222 let Unpredictable{15-12} = 0b1111;
1224 def rsr : AI1<opcod, (outs),
1225 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, iis,
1226 opc, "\t$Rn, $shift",
1227 [(opnode GPRnopc:$Rn, so_reg_reg:$shift)]> {
1232 let Inst{19-16} = Rn;
1233 let Inst{15-12} = 0b0000;
1234 let Inst{11-8} = shift{11-8};
1236 let Inst{6-5} = shift{6-5};
1238 let Inst{3-0} = shift{3-0};
1240 let Unpredictable{15-12} = 0b1111;
1246 /// AI_ext_rrot - A unary operation with two forms: one whose operand is a
1247 /// register and one whose operand is a register rotated by 8/16/24.
1248 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
1249 class AI_ext_rrot<bits<8> opcod, string opc, PatFrag opnode>
1250 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1251 IIC_iEXTr, opc, "\t$Rd, $Rm$rot",
1252 [(set GPRnopc:$Rd, (opnode (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1253 Requires<[IsARM, HasV6]> {
1257 let Inst{19-16} = 0b1111;
1258 let Inst{15-12} = Rd;
1259 let Inst{11-10} = rot;
1263 class AI_ext_rrot_np<bits<8> opcod, string opc>
1264 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1265 IIC_iEXTr, opc, "\t$Rd, $Rm$rot", []>,
1266 Requires<[IsARM, HasV6]> {
1268 let Inst{19-16} = 0b1111;
1269 let Inst{11-10} = rot;
1272 /// AI_exta_rrot - A binary operation with two forms: one whose operand is a
1273 /// register and one whose operand is a register rotated by 8/16/24.
1274 class AI_exta_rrot<bits<8> opcod, string opc, PatFrag opnode>
1275 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1276 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot",
1277 [(set GPRnopc:$Rd, (opnode GPR:$Rn,
1278 (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1279 Requires<[IsARM, HasV6]> {
1284 let Inst{19-16} = Rn;
1285 let Inst{15-12} = Rd;
1286 let Inst{11-10} = rot;
1287 let Inst{9-4} = 0b000111;
1291 class AI_exta_rrot_np<bits<8> opcod, string opc>
1292 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1293 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot", []>,
1294 Requires<[IsARM, HasV6]> {
1297 let Inst{19-16} = Rn;
1298 let Inst{11-10} = rot;
1301 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
1302 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
1303 string baseOpc, bit Commutable = 0> {
1304 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1305 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
1306 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1307 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_imm:$imm, CPSR))]>,
1313 let Inst{15-12} = Rd;
1314 let Inst{19-16} = Rn;
1315 let Inst{11-0} = imm;
1317 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1318 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1319 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm, CPSR))]>,
1324 let Inst{11-4} = 0b00000000;
1326 let isCommutable = Commutable;
1328 let Inst{15-12} = Rd;
1329 let Inst{19-16} = Rn;
1331 def rsi : AsI1<opcod, (outs GPR:$Rd),
1332 (ins GPR:$Rn, so_reg_imm:$shift),
1333 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1334 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_imm:$shift, CPSR))]>,
1340 let Inst{19-16} = Rn;
1341 let Inst{15-12} = Rd;
1342 let Inst{11-5} = shift{11-5};
1344 let Inst{3-0} = shift{3-0};
1346 def rsr : AsI1<opcod, (outs GPRnopc:$Rd),
1347 (ins GPRnopc:$Rn, so_reg_reg:$shift),
1348 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1349 [(set GPRnopc:$Rd, CPSR, (opnode GPRnopc:$Rn, so_reg_reg:$shift, CPSR))]>,
1355 let Inst{19-16} = Rn;
1356 let Inst{15-12} = Rd;
1357 let Inst{11-8} = shift{11-8};
1359 let Inst{6-5} = shift{6-5};
1361 let Inst{3-0} = shift{3-0};
1365 // Assembly aliases for optional destination operand when it's the same
1366 // as the source operand.
1367 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $imm"),
1368 (!cast<Instruction>(!strconcat(baseOpc, "ri")) GPR:$Rdn, GPR:$Rdn,
1369 so_imm:$imm, pred:$p,
1372 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $Rm"),
1373 (!cast<Instruction>(!strconcat(baseOpc, "rr")) GPR:$Rdn, GPR:$Rdn,
1377 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1378 (!cast<Instruction>(!strconcat(baseOpc, "rsi")) GPR:$Rdn, GPR:$Rdn,
1379 so_reg_imm:$shift, pred:$p,
1382 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1383 (!cast<Instruction>(!strconcat(baseOpc, "rsr")) GPRnopc:$Rdn, GPRnopc:$Rdn,
1384 so_reg_reg:$shift, pred:$p,
1389 /// AI1_rsc_irs - Define instructions and patterns for rsc
1390 multiclass AI1_rsc_irs<bits<4> opcod, string opc, PatFrag opnode,
1392 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1393 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
1394 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1395 [(set GPR:$Rd, CPSR, (opnode so_imm:$imm, GPR:$Rn, CPSR))]>,
1401 let Inst{15-12} = Rd;
1402 let Inst{19-16} = Rn;
1403 let Inst{11-0} = imm;
1405 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1406 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1407 [/* pattern left blank */]> {
1411 let Inst{11-4} = 0b00000000;
1414 let Inst{15-12} = Rd;
1415 let Inst{19-16} = Rn;
1417 def rsi : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_imm:$shift),
1418 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1419 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift, GPR:$Rn, CPSR))]>,
1425 let Inst{19-16} = Rn;
1426 let Inst{15-12} = Rd;
1427 let Inst{11-5} = shift{11-5};
1429 let Inst{3-0} = shift{3-0};
1431 def rsr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_reg:$shift),
1432 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1433 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift, GPR:$Rn, CPSR))]>,
1439 let Inst{19-16} = Rn;
1440 let Inst{15-12} = Rd;
1441 let Inst{11-8} = shift{11-8};
1443 let Inst{6-5} = shift{6-5};
1445 let Inst{3-0} = shift{3-0};
1449 // Assembly aliases for optional destination operand when it's the same
1450 // as the source operand.
1451 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $imm"),
1452 (!cast<Instruction>(!strconcat(baseOpc, "ri")) GPR:$Rdn, GPR:$Rdn,
1453 so_imm:$imm, pred:$p,
1456 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $Rm"),
1457 (!cast<Instruction>(!strconcat(baseOpc, "rr")) GPR:$Rdn, GPR:$Rdn,
1461 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1462 (!cast<Instruction>(!strconcat(baseOpc, "rsi")) GPR:$Rdn, GPR:$Rdn,
1463 so_reg_imm:$shift, pred:$p,
1466 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1467 (!cast<Instruction>(!strconcat(baseOpc, "rsr")) GPR:$Rdn, GPR:$Rdn,
1468 so_reg_reg:$shift, pred:$p,
1473 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1474 multiclass AI_ldr1<bit isByte, string opc, InstrItinClass iii,
1475 InstrItinClass iir, PatFrag opnode> {
1476 // Note: We use the complex addrmode_imm12 rather than just an input
1477 // GPR and a constrained immediate so that we can use this to match
1478 // frame index references and avoid matching constant pool references.
1479 def i12: AI2ldst<0b010, 1, isByte, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
1480 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1481 [(set GPR:$Rt, (opnode addrmode_imm12:$addr))]> {
1484 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1485 let Inst{19-16} = addr{16-13}; // Rn
1486 let Inst{15-12} = Rt;
1487 let Inst{11-0} = addr{11-0}; // imm12
1489 def rs : AI2ldst<0b011, 1, isByte, (outs GPR:$Rt), (ins ldst_so_reg:$shift),
1490 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1491 [(set GPR:$Rt, (opnode ldst_so_reg:$shift))]> {
1494 let shift{4} = 0; // Inst{4} = 0
1495 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1496 let Inst{19-16} = shift{16-13}; // Rn
1497 let Inst{15-12} = Rt;
1498 let Inst{11-0} = shift{11-0};
1503 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1504 multiclass AI_ldr1nopc<bit isByte, string opc, InstrItinClass iii,
1505 InstrItinClass iir, PatFrag opnode> {
1506 // Note: We use the complex addrmode_imm12 rather than just an input
1507 // GPR and a constrained immediate so that we can use this to match
1508 // frame index references and avoid matching constant pool references.
1509 def i12: AI2ldst<0b010, 1, isByte, (outs GPRnopc:$Rt), (ins addrmode_imm12:$addr),
1510 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1511 [(set GPRnopc:$Rt, (opnode addrmode_imm12:$addr))]> {
1514 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1515 let Inst{19-16} = addr{16-13}; // Rn
1516 let Inst{15-12} = Rt;
1517 let Inst{11-0} = addr{11-0}; // imm12
1519 def rs : AI2ldst<0b011, 1, isByte, (outs GPRnopc:$Rt), (ins ldst_so_reg:$shift),
1520 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1521 [(set GPRnopc:$Rt, (opnode ldst_so_reg:$shift))]> {
1524 let shift{4} = 0; // Inst{4} = 0
1525 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1526 let Inst{19-16} = shift{16-13}; // Rn
1527 let Inst{15-12} = Rt;
1528 let Inst{11-0} = shift{11-0};
1534 multiclass AI_str1<bit isByte, string opc, InstrItinClass iii,
1535 InstrItinClass iir, PatFrag opnode> {
1536 // Note: We use the complex addrmode_imm12 rather than just an input
1537 // GPR and a constrained immediate so that we can use this to match
1538 // frame index references and avoid matching constant pool references.
1539 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1540 (ins GPR:$Rt, addrmode_imm12:$addr),
1541 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1542 [(opnode GPR:$Rt, addrmode_imm12:$addr)]> {
1545 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1546 let Inst{19-16} = addr{16-13}; // Rn
1547 let Inst{15-12} = Rt;
1548 let Inst{11-0} = addr{11-0}; // imm12
1550 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPR:$Rt, ldst_so_reg:$shift),
1551 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1552 [(opnode GPR:$Rt, ldst_so_reg:$shift)]> {
1555 let shift{4} = 0; // Inst{4} = 0
1556 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1557 let Inst{19-16} = shift{16-13}; // Rn
1558 let Inst{15-12} = Rt;
1559 let Inst{11-0} = shift{11-0};
1563 multiclass AI_str1nopc<bit isByte, string opc, InstrItinClass iii,
1564 InstrItinClass iir, PatFrag opnode> {
1565 // Note: We use the complex addrmode_imm12 rather than just an input
1566 // GPR and a constrained immediate so that we can use this to match
1567 // frame index references and avoid matching constant pool references.
1568 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1569 (ins GPRnopc:$Rt, addrmode_imm12:$addr),
1570 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1571 [(opnode GPRnopc:$Rt, addrmode_imm12:$addr)]> {
1574 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1575 let Inst{19-16} = addr{16-13}; // Rn
1576 let Inst{15-12} = Rt;
1577 let Inst{11-0} = addr{11-0}; // imm12
1579 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPRnopc:$Rt, ldst_so_reg:$shift),
1580 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1581 [(opnode GPRnopc:$Rt, ldst_so_reg:$shift)]> {
1584 let shift{4} = 0; // Inst{4} = 0
1585 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1586 let Inst{19-16} = shift{16-13}; // Rn
1587 let Inst{15-12} = Rt;
1588 let Inst{11-0} = shift{11-0};
1593 //===----------------------------------------------------------------------===//
1595 //===----------------------------------------------------------------------===//
1597 //===----------------------------------------------------------------------===//
1598 // Miscellaneous Instructions.
1601 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
1602 /// the function. The first operand is the ID# for this instruction, the second
1603 /// is the index into the MachineConstantPool that this is, the third is the
1604 /// size in bytes of this constant pool entry.
1605 let neverHasSideEffects = 1, isNotDuplicable = 1 in
1606 def CONSTPOOL_ENTRY :
1607 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1608 i32imm:$size), NoItinerary, []>;
1610 // FIXME: Marking these as hasSideEffects is necessary to prevent machine DCE
1611 // from removing one half of the matched pairs. That breaks PEI, which assumes
1612 // these will always be in pairs, and asserts if it finds otherwise. Better way?
1613 let Defs = [SP], Uses = [SP], hasSideEffects = 1 in {
1614 def ADJCALLSTACKUP :
1615 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary,
1616 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
1618 def ADJCALLSTACKDOWN :
1619 PseudoInst<(outs), (ins i32imm:$amt, pred:$p), NoItinerary,
1620 [(ARMcallseq_start timm:$amt)]>;
1623 // Atomic pseudo-insts which will be lowered to ldrexd/strexd loops.
1624 // (These pseudos use a hand-written selection code).
1625 let usesCustomInserter = 1, Defs = [CPSR], mayLoad = 1, mayStore = 1 in {
1626 def ATOMOR6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1627 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1629 def ATOMXOR6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1630 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1632 def ATOMADD6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1633 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1635 def ATOMSUB6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1636 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1638 def ATOMNAND6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1639 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1641 def ATOMAND6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1642 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1644 def ATOMSWAP6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1645 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1647 def ATOMCMPXCHG6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1648 (ins GPR:$addr, GPR:$cmp1, GPR:$cmp2,
1649 GPR:$set1, GPR:$set2),
1653 def NOP : AI<(outs), (ins), MiscFrm, NoItinerary, "nop", "", []>,
1654 Requires<[IsARM, HasV6T2]> {
1655 let Inst{27-16} = 0b001100100000;
1656 let Inst{15-8} = 0b11110000;
1657 let Inst{7-0} = 0b00000000;
1660 def YIELD : AI<(outs), (ins), MiscFrm, NoItinerary, "yield", "", []>,
1661 Requires<[IsARM, HasV6T2]> {
1662 let Inst{27-16} = 0b001100100000;
1663 let Inst{15-8} = 0b11110000;
1664 let Inst{7-0} = 0b00000001;
1667 def WFE : AI<(outs), (ins), MiscFrm, NoItinerary, "wfe", "", []>,
1668 Requires<[IsARM, HasV6T2]> {
1669 let Inst{27-16} = 0b001100100000;
1670 let Inst{15-8} = 0b11110000;
1671 let Inst{7-0} = 0b00000010;
1674 def WFI : AI<(outs), (ins), MiscFrm, NoItinerary, "wfi", "", []>,
1675 Requires<[IsARM, HasV6T2]> {
1676 let Inst{27-16} = 0b001100100000;
1677 let Inst{15-8} = 0b11110000;
1678 let Inst{7-0} = 0b00000011;
1681 def SEL : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, NoItinerary, "sel",
1682 "\t$Rd, $Rn, $Rm", []>, Requires<[IsARM, HasV6]> {
1687 let Inst{15-12} = Rd;
1688 let Inst{19-16} = Rn;
1689 let Inst{27-20} = 0b01101000;
1690 let Inst{7-4} = 0b1011;
1691 let Inst{11-8} = 0b1111;
1694 def SEV : AI<(outs), (ins), MiscFrm, NoItinerary, "sev", "",
1695 []>, Requires<[IsARM, HasV6T2]> {
1696 let Inst{27-16} = 0b001100100000;
1697 let Inst{15-8} = 0b11110000;
1698 let Inst{7-0} = 0b00000100;
1701 // The i32imm operand $val can be used by a debugger to store more information
1702 // about the breakpoint.
1703 def BKPT : AI<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
1704 "bkpt", "\t$val", []>, Requires<[IsARM]> {
1706 let Inst{3-0} = val{3-0};
1707 let Inst{19-8} = val{15-4};
1708 let Inst{27-20} = 0b00010010;
1709 let Inst{7-4} = 0b0111;
1712 // Change Processor State
1713 // FIXME: We should use InstAlias to handle the optional operands.
1714 class CPS<dag iops, string asm_ops>
1715 : AXI<(outs), iops, MiscFrm, NoItinerary, !strconcat("cps", asm_ops),
1716 []>, Requires<[IsARM]> {
1722 let Inst{31-28} = 0b1111;
1723 let Inst{27-20} = 0b00010000;
1724 let Inst{19-18} = imod;
1725 let Inst{17} = M; // Enabled if mode is set;
1726 let Inst{16-9} = 0b00000000;
1727 let Inst{8-6} = iflags;
1729 let Inst{4-0} = mode;
1732 let DecoderMethod = "DecodeCPSInstruction" in {
1734 def CPS3p : CPS<(ins imod_op:$imod, iflags_op:$iflags, imm0_31:$mode),
1735 "$imod\t$iflags, $mode">;
1736 let mode = 0, M = 0 in
1737 def CPS2p : CPS<(ins imod_op:$imod, iflags_op:$iflags), "$imod\t$iflags">;
1739 let imod = 0, iflags = 0, M = 1 in
1740 def CPS1p : CPS<(ins imm0_31:$mode), "\t$mode">;
1743 // Preload signals the memory system of possible future data/instruction access.
1744 multiclass APreLoad<bits<1> read, bits<1> data, string opc> {
1746 def i12 : AXI<(outs), (ins addrmode_imm12:$addr), MiscFrm, IIC_Preload,
1747 !strconcat(opc, "\t$addr"),
1748 [(ARMPreload addrmode_imm12:$addr, (i32 read), (i32 data))]> {
1751 let Inst{31-26} = 0b111101;
1752 let Inst{25} = 0; // 0 for immediate form
1753 let Inst{24} = data;
1754 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1755 let Inst{22} = read;
1756 let Inst{21-20} = 0b01;
1757 let Inst{19-16} = addr{16-13}; // Rn
1758 let Inst{15-12} = 0b1111;
1759 let Inst{11-0} = addr{11-0}; // imm12
1762 def rs : AXI<(outs), (ins ldst_so_reg:$shift), MiscFrm, IIC_Preload,
1763 !strconcat(opc, "\t$shift"),
1764 [(ARMPreload ldst_so_reg:$shift, (i32 read), (i32 data))]> {
1766 let Inst{31-26} = 0b111101;
1767 let Inst{25} = 1; // 1 for register form
1768 let Inst{24} = data;
1769 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1770 let Inst{22} = read;
1771 let Inst{21-20} = 0b01;
1772 let Inst{19-16} = shift{16-13}; // Rn
1773 let Inst{15-12} = 0b1111;
1774 let Inst{11-0} = shift{11-0};
1779 defm PLD : APreLoad<1, 1, "pld">, Requires<[IsARM]>;
1780 defm PLDW : APreLoad<0, 1, "pldw">, Requires<[IsARM,HasV7,HasMP]>;
1781 defm PLI : APreLoad<1, 0, "pli">, Requires<[IsARM,HasV7]>;
1783 def SETEND : AXI<(outs), (ins setend_op:$end), MiscFrm, NoItinerary,
1784 "setend\t$end", []>, Requires<[IsARM]> {
1786 let Inst{31-10} = 0b1111000100000001000000;
1791 def DBG : AI<(outs), (ins imm0_15:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt",
1792 []>, Requires<[IsARM, HasV7]> {
1794 let Inst{27-4} = 0b001100100000111100001111;
1795 let Inst{3-0} = opt;
1798 // A5.4 Permanently UNDEFINED instructions.
1799 let isBarrier = 1, isTerminator = 1 in
1800 def TRAP : AXI<(outs), (ins), MiscFrm, NoItinerary,
1803 let Inst = 0xe7ffdefe;
1806 // Address computation and loads and stores in PIC mode.
1807 let isNotDuplicable = 1 in {
1808 def PICADD : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
1810 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>;
1812 let AddedComplexity = 10 in {
1813 def PICLDR : ARMPseudoInst<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
1815 [(set GPR:$dst, (load addrmodepc:$addr))]>;
1817 def PICLDRH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1819 [(set GPR:$Rt, (zextloadi16 addrmodepc:$addr))]>;
1821 def PICLDRB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1823 [(set GPR:$Rt, (zextloadi8 addrmodepc:$addr))]>;
1825 def PICLDRSH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1827 [(set GPR:$Rt, (sextloadi16 addrmodepc:$addr))]>;
1829 def PICLDRSB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1831 [(set GPR:$Rt, (sextloadi8 addrmodepc:$addr))]>;
1833 let AddedComplexity = 10 in {
1834 def PICSTR : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1835 4, IIC_iStore_r, [(store GPR:$src, addrmodepc:$addr)]>;
1837 def PICSTRH : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1838 4, IIC_iStore_bh_r, [(truncstorei16 GPR:$src,
1839 addrmodepc:$addr)]>;
1841 def PICSTRB : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1842 4, IIC_iStore_bh_r, [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
1844 } // isNotDuplicable = 1
1847 // LEApcrel - Load a pc-relative address into a register without offending the
1849 let neverHasSideEffects = 1, isReMaterializable = 1 in
1850 // The 'adr' mnemonic encodes differently if the label is before or after
1851 // the instruction. The {24-21} opcode bits are set by the fixup, as we don't
1852 // know until then which form of the instruction will be used.
1853 def ADR : AI1<{0,?,?,0}, (outs GPR:$Rd), (ins adrlabel:$label),
1854 MiscFrm, IIC_iALUi, "adr", "\t$Rd, $label", []> {
1857 let Inst{27-25} = 0b001;
1859 let Inst{23-22} = label{13-12};
1862 let Inst{19-16} = 0b1111;
1863 let Inst{15-12} = Rd;
1864 let Inst{11-0} = label{11-0};
1866 def LEApcrel : ARMPseudoInst<(outs GPR:$Rd), (ins i32imm:$label, pred:$p),
1869 def LEApcrelJT : ARMPseudoInst<(outs GPR:$Rd),
1870 (ins i32imm:$label, nohash_imm:$id, pred:$p),
1873 //===----------------------------------------------------------------------===//
1874 // Control Flow Instructions.
1877 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
1879 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
1880 "bx", "\tlr", [(ARMretflag)]>,
1881 Requires<[IsARM, HasV4T]> {
1882 let Inst{27-0} = 0b0001001011111111111100011110;
1886 def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br,
1887 "mov", "\tpc, lr", [(ARMretflag)]>,
1888 Requires<[IsARM, NoV4T]> {
1889 let Inst{27-0} = 0b0001101000001111000000001110;
1893 // Indirect branches
1894 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
1896 def BX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
1897 [(brind GPR:$dst)]>,
1898 Requires<[IsARM, HasV4T]> {
1900 let Inst{31-4} = 0b1110000100101111111111110001;
1901 let Inst{3-0} = dst;
1904 def BX_pred : AI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br,
1905 "bx", "\t$dst", [/* pattern left blank */]>,
1906 Requires<[IsARM, HasV4T]> {
1908 let Inst{27-4} = 0b000100101111111111110001;
1909 let Inst{3-0} = dst;
1913 // SP is marked as a use to prevent stack-pointer assignments that appear
1914 // immediately before calls from potentially appearing dead.
1916 // FIXME: Do we really need a non-predicated version? If so, it should
1917 // at least be a pseudo instruction expanding to the predicated version
1918 // at MC lowering time.
1919 Defs = [LR], Uses = [SP] in {
1920 def BL : ABXI<0b1011, (outs), (ins bl_target:$func, variable_ops),
1921 IIC_Br, "bl\t$func",
1922 [(ARMcall tglobaladdr:$func)]>,
1924 let Inst{31-28} = 0b1110;
1926 let Inst{23-0} = func;
1927 let DecoderMethod = "DecodeBranchImmInstruction";
1930 def BL_pred : ABI<0b1011, (outs), (ins bl_target:$func, variable_ops),
1931 IIC_Br, "bl", "\t$func",
1932 [(ARMcall_pred tglobaladdr:$func)]>,
1935 let Inst{23-0} = func;
1936 let DecoderMethod = "DecodeBranchImmInstruction";
1940 def BLX : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
1941 IIC_Br, "blx\t$func",
1942 [(ARMcall GPR:$func)]>,
1943 Requires<[IsARM, HasV5T]> {
1945 let Inst{31-4} = 0b1110000100101111111111110011;
1946 let Inst{3-0} = func;
1949 def BLX_pred : AI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
1950 IIC_Br, "blx", "\t$func",
1951 [(ARMcall_pred GPR:$func)]>,
1952 Requires<[IsARM, HasV5T]> {
1954 let Inst{27-4} = 0b000100101111111111110011;
1955 let Inst{3-0} = func;
1959 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
1960 def BX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func, variable_ops),
1961 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
1962 Requires<[IsARM, HasV4T]>;
1965 def BMOVPCRX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func, variable_ops),
1966 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
1967 Requires<[IsARM, NoV4T]>;
1969 // mov lr, pc; b if callee is marked noreturn to avoid confusing the
1970 // return stack predictor.
1971 def BMOVPCB_CALL : ARMPseudoInst<(outs),
1972 (ins bl_target:$func, variable_ops),
1973 8, IIC_Br, [(ARMcall_nolink tglobaladdr:$func)]>,
1977 let isBranch = 1, isTerminator = 1 in {
1978 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
1979 // a two-value operand where a dag node expects two operands. :(
1980 def Bcc : ABI<0b1010, (outs), (ins br_target:$target),
1981 IIC_Br, "b", "\t$target",
1982 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]> {
1984 let Inst{23-0} = target;
1985 let DecoderMethod = "DecodeBranchImmInstruction";
1988 let isBarrier = 1 in {
1989 // B is "predicable" since it's just a Bcc with an 'always' condition.
1990 let isPredicable = 1 in
1991 // FIXME: We shouldn't need this pseudo at all. Just using Bcc directly
1992 // should be sufficient.
1993 // FIXME: Is B really a Barrier? That doesn't seem right.
1994 def B : ARMPseudoExpand<(outs), (ins br_target:$target), 4, IIC_Br,
1995 [(br bb:$target)], (Bcc br_target:$target, (ops 14, zero_reg))>;
1997 let isNotDuplicable = 1, isIndirectBranch = 1 in {
1998 def BR_JTr : ARMPseudoInst<(outs),
1999 (ins GPR:$target, i32imm:$jt, i32imm:$id),
2001 [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]>;
2002 // FIXME: This shouldn't use the generic "addrmode2," but rather be split
2003 // into i12 and rs suffixed versions.
2004 def BR_JTm : ARMPseudoInst<(outs),
2005 (ins addrmode2:$target, i32imm:$jt, i32imm:$id),
2007 [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
2009 def BR_JTadd : ARMPseudoInst<(outs),
2010 (ins GPR:$target, GPR:$idx, i32imm:$jt, i32imm:$id),
2012 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
2014 } // isNotDuplicable = 1, isIndirectBranch = 1
2020 def BLXi : AXI<(outs), (ins blx_target:$target), BrMiscFrm, NoItinerary,
2021 "blx\t$target", []>,
2022 Requires<[IsARM, HasV5T]> {
2023 let Inst{31-25} = 0b1111101;
2025 let Inst{23-0} = target{24-1};
2026 let Inst{24} = target{0};
2029 // Branch and Exchange Jazelle
2030 def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func",
2031 [/* pattern left blank */]> {
2033 let Inst{23-20} = 0b0010;
2034 let Inst{19-8} = 0xfff;
2035 let Inst{7-4} = 0b0010;
2036 let Inst{3-0} = func;
2041 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in {
2042 def TCRETURNdi : PseudoInst<(outs), (ins i32imm:$dst, variable_ops),
2045 def TCRETURNri : PseudoInst<(outs), (ins tcGPR:$dst, variable_ops),
2048 def TAILJMPd : ARMPseudoExpand<(outs), (ins br_target:$dst, variable_ops),
2050 (Bcc br_target:$dst, (ops 14, zero_reg))>,
2053 def TAILJMPr : ARMPseudoExpand<(outs), (ins tcGPR:$dst, variable_ops),
2059 // Secure Monitor Call is a system instruction.
2060 def SMC : ABI<0b0001, (outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt",
2063 let Inst{23-4} = 0b01100000000000000111;
2064 let Inst{3-0} = opt;
2067 // Supervisor Call (Software Interrupt)
2068 let isCall = 1, Uses = [SP] in {
2069 def SVC : ABI<0b1111, (outs), (ins imm24b:$svc), IIC_Br, "svc", "\t$svc", []> {
2071 let Inst{23-0} = svc;
2075 // Store Return State
2076 class SRSI<bit wb, string asm>
2077 : XI<(outs), (ins imm0_31:$mode), AddrModeNone, 4, IndexModeNone, BrFrm,
2078 NoItinerary, asm, "", []> {
2080 let Inst{31-28} = 0b1111;
2081 let Inst{27-25} = 0b100;
2085 let Inst{19-16} = 0b1101; // SP
2086 let Inst{15-5} = 0b00000101000;
2087 let Inst{4-0} = mode;
2090 def SRSDA : SRSI<0, "srsda\tsp, $mode"> {
2091 let Inst{24-23} = 0;
2093 def SRSDA_UPD : SRSI<1, "srsda\tsp!, $mode"> {
2094 let Inst{24-23} = 0;
2096 def SRSDB : SRSI<0, "srsdb\tsp, $mode"> {
2097 let Inst{24-23} = 0b10;
2099 def SRSDB_UPD : SRSI<1, "srsdb\tsp!, $mode"> {
2100 let Inst{24-23} = 0b10;
2102 def SRSIA : SRSI<0, "srsia\tsp, $mode"> {
2103 let Inst{24-23} = 0b01;
2105 def SRSIA_UPD : SRSI<1, "srsia\tsp!, $mode"> {
2106 let Inst{24-23} = 0b01;
2108 def SRSIB : SRSI<0, "srsib\tsp, $mode"> {
2109 let Inst{24-23} = 0b11;
2111 def SRSIB_UPD : SRSI<1, "srsib\tsp!, $mode"> {
2112 let Inst{24-23} = 0b11;
2115 // Return From Exception
2116 class RFEI<bit wb, string asm>
2117 : XI<(outs), (ins GPR:$Rn), AddrModeNone, 4, IndexModeNone, BrFrm,
2118 NoItinerary, asm, "", []> {
2120 let Inst{31-28} = 0b1111;
2121 let Inst{27-25} = 0b100;
2125 let Inst{19-16} = Rn;
2126 let Inst{15-0} = 0xa00;
2129 def RFEDA : RFEI<0, "rfeda\t$Rn"> {
2130 let Inst{24-23} = 0;
2132 def RFEDA_UPD : RFEI<1, "rfeda\t$Rn!"> {
2133 let Inst{24-23} = 0;
2135 def RFEDB : RFEI<0, "rfedb\t$Rn"> {
2136 let Inst{24-23} = 0b10;
2138 def RFEDB_UPD : RFEI<1, "rfedb\t$Rn!"> {
2139 let Inst{24-23} = 0b10;
2141 def RFEIA : RFEI<0, "rfeia\t$Rn"> {
2142 let Inst{24-23} = 0b01;
2144 def RFEIA_UPD : RFEI<1, "rfeia\t$Rn!"> {
2145 let Inst{24-23} = 0b01;
2147 def RFEIB : RFEI<0, "rfeib\t$Rn"> {
2148 let Inst{24-23} = 0b11;
2150 def RFEIB_UPD : RFEI<1, "rfeib\t$Rn!"> {
2151 let Inst{24-23} = 0b11;
2154 //===----------------------------------------------------------------------===//
2155 // Load / Store Instructions.
2161 defm LDR : AI_ldr1<0, "ldr", IIC_iLoad_r, IIC_iLoad_si,
2162 UnOpFrag<(load node:$Src)>>;
2163 defm LDRB : AI_ldr1nopc<1, "ldrb", IIC_iLoad_bh_r, IIC_iLoad_bh_si,
2164 UnOpFrag<(zextloadi8 node:$Src)>>;
2165 defm STR : AI_str1<0, "str", IIC_iStore_r, IIC_iStore_si,
2166 BinOpFrag<(store node:$LHS, node:$RHS)>>;
2167 defm STRB : AI_str1nopc<1, "strb", IIC_iStore_bh_r, IIC_iStore_bh_si,
2168 BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
2170 // Special LDR for loads from non-pc-relative constpools.
2171 let canFoldAsLoad = 1, mayLoad = 1, neverHasSideEffects = 1,
2172 isReMaterializable = 1, isCodeGenOnly = 1 in
2173 def LDRcp : AI2ldst<0b010, 1, 0, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
2174 AddrMode_i12, LdFrm, IIC_iLoad_r, "ldr", "\t$Rt, $addr",
2178 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2179 let Inst{19-16} = 0b1111;
2180 let Inst{15-12} = Rt;
2181 let Inst{11-0} = addr{11-0}; // imm12
2184 // Loads with zero extension
2185 def LDRH : AI3ld<0b1011, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2186 IIC_iLoad_bh_r, "ldrh", "\t$Rt, $addr",
2187 [(set GPR:$Rt, (zextloadi16 addrmode3:$addr))]>;
2189 // Loads with sign extension
2190 def LDRSH : AI3ld<0b1111, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2191 IIC_iLoad_bh_r, "ldrsh", "\t$Rt, $addr",
2192 [(set GPR:$Rt, (sextloadi16 addrmode3:$addr))]>;
2194 def LDRSB : AI3ld<0b1101, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2195 IIC_iLoad_bh_r, "ldrsb", "\t$Rt, $addr",
2196 [(set GPR:$Rt, (sextloadi8 addrmode3:$addr))]>;
2198 let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1 in {
2200 def LDRD : AI3ld<0b1101, 0, (outs GPR:$Rd, GPR:$dst2),
2201 (ins addrmode3:$addr), LdMiscFrm,
2202 IIC_iLoad_d_r, "ldrd", "\t$Rd, $dst2, $addr",
2203 []>, Requires<[IsARM, HasV5TE]>;
2207 multiclass AI2_ldridx<bit isByte, string opc,
2208 InstrItinClass iii, InstrItinClass iir> {
2209 def _PRE_IMM : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2210 (ins addrmode_imm12:$addr), IndexModePre, LdFrm, iii,
2211 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2214 let Inst{23} = addr{12};
2215 let Inst{19-16} = addr{16-13};
2216 let Inst{11-0} = addr{11-0};
2217 let DecoderMethod = "DecodeLDRPreImm";
2218 let AsmMatchConverter = "cvtLdWriteBackRegAddrModeImm12";
2221 def _PRE_REG : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2222 (ins ldst_so_reg:$addr), IndexModePre, LdFrm, iir,
2223 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2226 let Inst{23} = addr{12};
2227 let Inst{19-16} = addr{16-13};
2228 let Inst{11-0} = addr{11-0};
2230 let DecoderMethod = "DecodeLDRPreReg";
2231 let AsmMatchConverter = "cvtLdWriteBackRegAddrMode2";
2234 def _POST_REG : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2235 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2236 IndexModePost, LdFrm, iir,
2237 opc, "\t$Rt, $addr, $offset",
2238 "$addr.base = $Rn_wb", []> {
2244 let Inst{23} = offset{12};
2245 let Inst{19-16} = addr;
2246 let Inst{11-0} = offset{11-0};
2248 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2251 def _POST_IMM : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2252 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2253 IndexModePost, LdFrm, iii,
2254 opc, "\t$Rt, $addr, $offset",
2255 "$addr.base = $Rn_wb", []> {
2261 let Inst{23} = offset{12};
2262 let Inst{19-16} = addr;
2263 let Inst{11-0} = offset{11-0};
2265 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2270 let mayLoad = 1, neverHasSideEffects = 1 in {
2271 // FIXME: for LDR_PRE_REG etc. the itineray should be either IIC_iLoad_ru or
2272 // IIC_iLoad_siu depending on whether it the offset register is shifted.
2273 defm LDR : AI2_ldridx<0, "ldr", IIC_iLoad_iu, IIC_iLoad_ru>;
2274 defm LDRB : AI2_ldridx<1, "ldrb", IIC_iLoad_bh_iu, IIC_iLoad_bh_ru>;
2277 multiclass AI3_ldridx<bits<4> op, string opc, InstrItinClass itin> {
2278 def _PRE : AI3ldstidx<op, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2279 (ins addrmode3:$addr), IndexModePre,
2281 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2283 let Inst{23} = addr{8}; // U bit
2284 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2285 let Inst{19-16} = addr{12-9}; // Rn
2286 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2287 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2288 let AsmMatchConverter = "cvtLdWriteBackRegAddrMode3";
2289 let DecoderMethod = "DecodeAddrMode3Instruction";
2291 def _POST : AI3ldstidx<op, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2292 (ins addr_offset_none:$addr, am3offset:$offset),
2293 IndexModePost, LdMiscFrm, itin,
2294 opc, "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2298 let Inst{23} = offset{8}; // U bit
2299 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2300 let Inst{19-16} = addr;
2301 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2302 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2303 let DecoderMethod = "DecodeAddrMode3Instruction";
2307 let mayLoad = 1, neverHasSideEffects = 1 in {
2308 defm LDRH : AI3_ldridx<0b1011, "ldrh", IIC_iLoad_bh_ru>;
2309 defm LDRSH : AI3_ldridx<0b1111, "ldrsh", IIC_iLoad_bh_ru>;
2310 defm LDRSB : AI3_ldridx<0b1101, "ldrsb", IIC_iLoad_bh_ru>;
2311 let hasExtraDefRegAllocReq = 1 in {
2312 def LDRD_PRE : AI3ldstidx<0b1101, 0, 1, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2313 (ins addrmode3:$addr), IndexModePre,
2314 LdMiscFrm, IIC_iLoad_d_ru,
2315 "ldrd", "\t$Rt, $Rt2, $addr!",
2316 "$addr.base = $Rn_wb", []> {
2318 let Inst{23} = addr{8}; // U bit
2319 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2320 let Inst{19-16} = addr{12-9}; // Rn
2321 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2322 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2323 let DecoderMethod = "DecodeAddrMode3Instruction";
2324 let AsmMatchConverter = "cvtLdrdPre";
2326 def LDRD_POST: AI3ldstidx<0b1101, 0, 0, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2327 (ins addr_offset_none:$addr, am3offset:$offset),
2328 IndexModePost, LdMiscFrm, IIC_iLoad_d_ru,
2329 "ldrd", "\t$Rt, $Rt2, $addr, $offset",
2330 "$addr.base = $Rn_wb", []> {
2333 let Inst{23} = offset{8}; // U bit
2334 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2335 let Inst{19-16} = addr;
2336 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2337 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2338 let DecoderMethod = "DecodeAddrMode3Instruction";
2340 } // hasExtraDefRegAllocReq = 1
2341 } // mayLoad = 1, neverHasSideEffects = 1
2343 // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT.
2344 let mayLoad = 1, neverHasSideEffects = 1 in {
2345 def LDRT_POST_REG : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2346 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2347 IndexModePost, LdFrm, IIC_iLoad_ru,
2348 "ldrt", "\t$Rt, $addr, $offset",
2349 "$addr.base = $Rn_wb", []> {
2355 let Inst{23} = offset{12};
2356 let Inst{21} = 1; // overwrite
2357 let Inst{19-16} = addr;
2358 let Inst{11-5} = offset{11-5};
2360 let Inst{3-0} = offset{3-0};
2361 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2364 def LDRT_POST_IMM : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2365 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2366 IndexModePost, LdFrm, IIC_iLoad_ru,
2367 "ldrt", "\t$Rt, $addr, $offset",
2368 "$addr.base = $Rn_wb", []> {
2374 let Inst{23} = offset{12};
2375 let Inst{21} = 1; // overwrite
2376 let Inst{19-16} = addr;
2377 let Inst{11-0} = offset{11-0};
2378 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2381 def LDRBT_POST_REG : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2382 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2383 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2384 "ldrbt", "\t$Rt, $addr, $offset",
2385 "$addr.base = $Rn_wb", []> {
2391 let Inst{23} = offset{12};
2392 let Inst{21} = 1; // overwrite
2393 let Inst{19-16} = addr;
2394 let Inst{11-5} = offset{11-5};
2396 let Inst{3-0} = offset{3-0};
2397 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2400 def LDRBT_POST_IMM : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2401 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2402 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2403 "ldrbt", "\t$Rt, $addr, $offset",
2404 "$addr.base = $Rn_wb", []> {
2410 let Inst{23} = offset{12};
2411 let Inst{21} = 1; // overwrite
2412 let Inst{19-16} = addr;
2413 let Inst{11-0} = offset{11-0};
2414 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2417 multiclass AI3ldrT<bits<4> op, string opc> {
2418 def i : AI3ldstidxT<op, 1, (outs GPR:$Rt, GPR:$base_wb),
2419 (ins addr_offset_none:$addr, postidx_imm8:$offset),
2420 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2421 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2423 let Inst{23} = offset{8};
2425 let Inst{11-8} = offset{7-4};
2426 let Inst{3-0} = offset{3-0};
2427 let AsmMatchConverter = "cvtLdExtTWriteBackImm";
2429 def r : AI3ldstidxT<op, 1, (outs GPRnopc:$Rt, GPRnopc:$base_wb),
2430 (ins addr_offset_none:$addr, postidx_reg:$Rm),
2431 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2432 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2434 let Inst{23} = Rm{4};
2437 let Unpredictable{11-8} = 0b1111;
2438 let Inst{3-0} = Rm{3-0};
2439 let AsmMatchConverter = "cvtLdExtTWriteBackReg";
2440 let DecoderMethod = "DecodeLDR";
2444 defm LDRSBT : AI3ldrT<0b1101, "ldrsbt">;
2445 defm LDRHT : AI3ldrT<0b1011, "ldrht">;
2446 defm LDRSHT : AI3ldrT<0b1111, "ldrsht">;
2451 // Stores with truncate
2452 def STRH : AI3str<0b1011, (outs), (ins GPR:$Rt, addrmode3:$addr), StMiscFrm,
2453 IIC_iStore_bh_r, "strh", "\t$Rt, $addr",
2454 [(truncstorei16 GPR:$Rt, addrmode3:$addr)]>;
2457 let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in
2458 def STRD : AI3str<0b1111, (outs), (ins GPR:$Rt, GPR:$src2, addrmode3:$addr),
2459 StMiscFrm, IIC_iStore_d_r,
2460 "strd", "\t$Rt, $src2, $addr", []>,
2461 Requires<[IsARM, HasV5TE]> {
2466 multiclass AI2_stridx<bit isByte, string opc,
2467 InstrItinClass iii, InstrItinClass iir> {
2468 def _PRE_IMM : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2469 (ins GPR:$Rt, addrmode_imm12:$addr), IndexModePre,
2471 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2474 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2475 let Inst{19-16} = addr{16-13}; // Rn
2476 let Inst{11-0} = addr{11-0}; // imm12
2477 let AsmMatchConverter = "cvtStWriteBackRegAddrModeImm12";
2478 let DecoderMethod = "DecodeSTRPreImm";
2481 def _PRE_REG : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2482 (ins GPR:$Rt, ldst_so_reg:$addr),
2483 IndexModePre, StFrm, iir,
2484 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2487 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2488 let Inst{19-16} = addr{16-13}; // Rn
2489 let Inst{11-0} = addr{11-0};
2490 let Inst{4} = 0; // Inst{4} = 0
2491 let AsmMatchConverter = "cvtStWriteBackRegAddrMode2";
2492 let DecoderMethod = "DecodeSTRPreReg";
2494 def _POST_REG : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2495 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2496 IndexModePost, StFrm, iir,
2497 opc, "\t$Rt, $addr, $offset",
2498 "$addr.base = $Rn_wb", []> {
2504 let Inst{23} = offset{12};
2505 let Inst{19-16} = addr;
2506 let Inst{11-0} = offset{11-0};
2508 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2511 def _POST_IMM : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2512 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2513 IndexModePost, StFrm, iii,
2514 opc, "\t$Rt, $addr, $offset",
2515 "$addr.base = $Rn_wb", []> {
2521 let Inst{23} = offset{12};
2522 let Inst{19-16} = addr;
2523 let Inst{11-0} = offset{11-0};
2525 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2529 let mayStore = 1, neverHasSideEffects = 1 in {
2530 // FIXME: for STR_PRE_REG etc. the itineray should be either IIC_iStore_ru or
2531 // IIC_iStore_siu depending on whether it the offset register is shifted.
2532 defm STR : AI2_stridx<0, "str", IIC_iStore_iu, IIC_iStore_ru>;
2533 defm STRB : AI2_stridx<1, "strb", IIC_iStore_bh_iu, IIC_iStore_bh_ru>;
2536 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2537 am2offset_reg:$offset),
2538 (STR_POST_REG GPR:$Rt, addr_offset_none:$addr,
2539 am2offset_reg:$offset)>;
2540 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2541 am2offset_imm:$offset),
2542 (STR_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2543 am2offset_imm:$offset)>;
2544 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2545 am2offset_reg:$offset),
2546 (STRB_POST_REG GPR:$Rt, addr_offset_none:$addr,
2547 am2offset_reg:$offset)>;
2548 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2549 am2offset_imm:$offset),
2550 (STRB_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2551 am2offset_imm:$offset)>;
2553 // Pseudo-instructions for pattern matching the pre-indexed stores. We can't
2554 // put the patterns on the instruction definitions directly as ISel wants
2555 // the address base and offset to be separate operands, not a single
2556 // complex operand like we represent the instructions themselves. The
2557 // pseudos map between the two.
2558 let usesCustomInserter = 1,
2559 Constraints = "$Rn = $Rn_wb,@earlyclobber $Rn_wb" in {
2560 def STRi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2561 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2564 (pre_store GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2565 def STRr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2566 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2569 (pre_store GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2570 def STRBi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2571 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2574 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2575 def STRBr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2576 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2579 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2580 def STRH_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2581 (ins GPR:$Rt, GPR:$Rn, am3offset:$offset, pred:$p),
2584 (pre_truncsti16 GPR:$Rt, GPR:$Rn, am3offset:$offset))]>;
2589 def STRH_PRE : AI3ldstidx<0b1011, 0, 1, (outs GPR:$Rn_wb),
2590 (ins GPR:$Rt, addrmode3:$addr), IndexModePre,
2591 StMiscFrm, IIC_iStore_bh_ru,
2592 "strh", "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2594 let Inst{23} = addr{8}; // U bit
2595 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2596 let Inst{19-16} = addr{12-9}; // Rn
2597 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2598 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2599 let AsmMatchConverter = "cvtStWriteBackRegAddrMode3";
2600 let DecoderMethod = "DecodeAddrMode3Instruction";
2603 def STRH_POST : AI3ldstidx<0b1011, 0, 0, (outs GPR:$Rn_wb),
2604 (ins GPR:$Rt, addr_offset_none:$addr, am3offset:$offset),
2605 IndexModePost, StMiscFrm, IIC_iStore_bh_ru,
2606 "strh", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2607 [(set GPR:$Rn_wb, (post_truncsti16 GPR:$Rt,
2608 addr_offset_none:$addr,
2609 am3offset:$offset))]> {
2612 let Inst{23} = offset{8}; // U bit
2613 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2614 let Inst{19-16} = addr;
2615 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2616 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2617 let DecoderMethod = "DecodeAddrMode3Instruction";
2620 let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in {
2621 def STRD_PRE : AI3ldstidx<0b1111, 0, 1, (outs GPR:$Rn_wb),
2622 (ins GPR:$Rt, GPR:$Rt2, addrmode3:$addr),
2623 IndexModePre, StMiscFrm, IIC_iStore_d_ru,
2624 "strd", "\t$Rt, $Rt2, $addr!",
2625 "$addr.base = $Rn_wb", []> {
2627 let Inst{23} = addr{8}; // U bit
2628 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2629 let Inst{19-16} = addr{12-9}; // Rn
2630 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2631 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2632 let DecoderMethod = "DecodeAddrMode3Instruction";
2633 let AsmMatchConverter = "cvtStrdPre";
2636 def STRD_POST: AI3ldstidx<0b1111, 0, 0, (outs GPR:$Rn_wb),
2637 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr,
2639 IndexModePost, StMiscFrm, IIC_iStore_d_ru,
2640 "strd", "\t$Rt, $Rt2, $addr, $offset",
2641 "$addr.base = $Rn_wb", []> {
2644 let Inst{23} = offset{8}; // U bit
2645 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2646 let Inst{19-16} = addr;
2647 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2648 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2649 let DecoderMethod = "DecodeAddrMode3Instruction";
2651 } // mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1
2653 // STRT, STRBT, and STRHT
2655 def STRBT_POST_REG : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2656 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2657 IndexModePost, StFrm, IIC_iStore_bh_ru,
2658 "strbt", "\t$Rt, $addr, $offset",
2659 "$addr.base = $Rn_wb", []> {
2665 let Inst{23} = offset{12};
2666 let Inst{21} = 1; // overwrite
2667 let Inst{19-16} = addr;
2668 let Inst{11-5} = offset{11-5};
2670 let Inst{3-0} = offset{3-0};
2671 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2674 def STRBT_POST_IMM : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2675 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2676 IndexModePost, StFrm, IIC_iStore_bh_ru,
2677 "strbt", "\t$Rt, $addr, $offset",
2678 "$addr.base = $Rn_wb", []> {
2684 let Inst{23} = offset{12};
2685 let Inst{21} = 1; // overwrite
2686 let Inst{19-16} = addr;
2687 let Inst{11-0} = offset{11-0};
2688 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2691 let mayStore = 1, neverHasSideEffects = 1 in {
2692 def STRT_POST_REG : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
2693 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2694 IndexModePost, StFrm, IIC_iStore_ru,
2695 "strt", "\t$Rt, $addr, $offset",
2696 "$addr.base = $Rn_wb", []> {
2702 let Inst{23} = offset{12};
2703 let Inst{21} = 1; // overwrite
2704 let Inst{19-16} = addr;
2705 let Inst{11-5} = offset{11-5};
2707 let Inst{3-0} = offset{3-0};
2708 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2711 def STRT_POST_IMM : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
2712 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2713 IndexModePost, StFrm, IIC_iStore_ru,
2714 "strt", "\t$Rt, $addr, $offset",
2715 "$addr.base = $Rn_wb", []> {
2721 let Inst{23} = offset{12};
2722 let Inst{21} = 1; // overwrite
2723 let Inst{19-16} = addr;
2724 let Inst{11-0} = offset{11-0};
2725 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2730 multiclass AI3strT<bits<4> op, string opc> {
2731 def i : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
2732 (ins GPR:$Rt, addr_offset_none:$addr, postidx_imm8:$offset),
2733 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
2734 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2736 let Inst{23} = offset{8};
2738 let Inst{11-8} = offset{7-4};
2739 let Inst{3-0} = offset{3-0};
2740 let AsmMatchConverter = "cvtStExtTWriteBackImm";
2742 def r : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
2743 (ins GPR:$Rt, addr_offset_none:$addr, postidx_reg:$Rm),
2744 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
2745 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2747 let Inst{23} = Rm{4};
2750 let Inst{3-0} = Rm{3-0};
2751 let AsmMatchConverter = "cvtStExtTWriteBackReg";
2756 defm STRHT : AI3strT<0b1011, "strht">;
2759 //===----------------------------------------------------------------------===//
2760 // Load / store multiple Instructions.
2763 multiclass arm_ldst_mult<string asm, string sfx, bit L_bit, bit P_bit, Format f,
2764 InstrItinClass itin, InstrItinClass itin_upd> {
2765 // IA is the default, so no need for an explicit suffix on the
2766 // mnemonic here. Without it is the cannonical spelling.
2768 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2769 IndexModeNone, f, itin,
2770 !strconcat(asm, "${p}\t$Rn, $regs", sfx), "", []> {
2771 let Inst{24-23} = 0b01; // Increment After
2772 let Inst{22} = P_bit;
2773 let Inst{21} = 0; // No writeback
2774 let Inst{20} = L_bit;
2777 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2778 IndexModeUpd, f, itin_upd,
2779 !strconcat(asm, "${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
2780 let Inst{24-23} = 0b01; // Increment After
2781 let Inst{22} = P_bit;
2782 let Inst{21} = 1; // Writeback
2783 let Inst{20} = L_bit;
2785 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2788 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2789 IndexModeNone, f, itin,
2790 !strconcat(asm, "da${p}\t$Rn, $regs", sfx), "", []> {
2791 let Inst{24-23} = 0b00; // Decrement After
2792 let Inst{22} = P_bit;
2793 let Inst{21} = 0; // No writeback
2794 let Inst{20} = L_bit;
2797 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2798 IndexModeUpd, f, itin_upd,
2799 !strconcat(asm, "da${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
2800 let Inst{24-23} = 0b00; // Decrement After
2801 let Inst{22} = P_bit;
2802 let Inst{21} = 1; // Writeback
2803 let Inst{20} = L_bit;
2805 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2808 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2809 IndexModeNone, f, itin,
2810 !strconcat(asm, "db${p}\t$Rn, $regs", sfx), "", []> {
2811 let Inst{24-23} = 0b10; // Decrement Before
2812 let Inst{22} = P_bit;
2813 let Inst{21} = 0; // No writeback
2814 let Inst{20} = L_bit;
2817 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2818 IndexModeUpd, f, itin_upd,
2819 !strconcat(asm, "db${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
2820 let Inst{24-23} = 0b10; // Decrement Before
2821 let Inst{22} = P_bit;
2822 let Inst{21} = 1; // Writeback
2823 let Inst{20} = L_bit;
2825 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2828 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2829 IndexModeNone, f, itin,
2830 !strconcat(asm, "ib${p}\t$Rn, $regs", sfx), "", []> {
2831 let Inst{24-23} = 0b11; // Increment Before
2832 let Inst{22} = P_bit;
2833 let Inst{21} = 0; // No writeback
2834 let Inst{20} = L_bit;
2837 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2838 IndexModeUpd, f, itin_upd,
2839 !strconcat(asm, "ib${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
2840 let Inst{24-23} = 0b11; // Increment Before
2841 let Inst{22} = P_bit;
2842 let Inst{21} = 1; // Writeback
2843 let Inst{20} = L_bit;
2845 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2849 let neverHasSideEffects = 1 in {
2851 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
2852 defm LDM : arm_ldst_mult<"ldm", "", 1, 0, LdStMulFrm, IIC_iLoad_m,
2855 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
2856 defm STM : arm_ldst_mult<"stm", "", 0, 0, LdStMulFrm, IIC_iStore_m,
2859 } // neverHasSideEffects
2861 // FIXME: remove when we have a way to marking a MI with these properties.
2862 // FIXME: Should pc be an implicit operand like PICADD, etc?
2863 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
2864 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
2865 def LDMIA_RET : ARMPseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p,
2866 reglist:$regs, variable_ops),
2867 4, IIC_iLoad_mBr, [],
2868 (LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>,
2869 RegConstraint<"$Rn = $wb">;
2871 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
2872 defm sysLDM : arm_ldst_mult<"ldm", " ^", 1, 1, LdStMulFrm, IIC_iLoad_m,
2875 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
2876 defm sysSTM : arm_ldst_mult<"stm", " ^", 0, 1, LdStMulFrm, IIC_iStore_m,
2881 //===----------------------------------------------------------------------===//
2882 // Move Instructions.
2885 let neverHasSideEffects = 1 in
2886 def MOVr : AsI1<0b1101, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMOVr,
2887 "mov", "\t$Rd, $Rm", []>, UnaryDP {
2891 let Inst{19-16} = 0b0000;
2892 let Inst{11-4} = 0b00000000;
2895 let Inst{15-12} = Rd;
2898 def : ARMInstAlias<"movs${p} $Rd, $Rm",
2899 (MOVr GPR:$Rd, GPR:$Rm, pred:$p, CPSR)>;
2901 // A version for the smaller set of tail call registers.
2902 let neverHasSideEffects = 1 in
2903 def MOVr_TC : AsI1<0b1101, (outs tcGPR:$Rd), (ins tcGPR:$Rm), DPFrm,
2904 IIC_iMOVr, "mov", "\t$Rd, $Rm", []>, UnaryDP {
2908 let Inst{11-4} = 0b00000000;
2911 let Inst{15-12} = Rd;
2914 def MOVsr : AsI1<0b1101, (outs GPRnopc:$Rd), (ins shift_so_reg_reg:$src),
2915 DPSoRegRegFrm, IIC_iMOVsr,
2916 "mov", "\t$Rd, $src",
2917 [(set GPRnopc:$Rd, shift_so_reg_reg:$src)]>, UnaryDP {
2920 let Inst{15-12} = Rd;
2921 let Inst{19-16} = 0b0000;
2922 let Inst{11-8} = src{11-8};
2924 let Inst{6-5} = src{6-5};
2926 let Inst{3-0} = src{3-0};
2930 def MOVsi : AsI1<0b1101, (outs GPR:$Rd), (ins shift_so_reg_imm:$src),
2931 DPSoRegImmFrm, IIC_iMOVsr,
2932 "mov", "\t$Rd, $src", [(set GPR:$Rd, shift_so_reg_imm:$src)]>,
2936 let Inst{15-12} = Rd;
2937 let Inst{19-16} = 0b0000;
2938 let Inst{11-5} = src{11-5};
2940 let Inst{3-0} = src{3-0};
2944 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
2945 def MOVi : AsI1<0b1101, (outs GPR:$Rd), (ins so_imm:$imm), DPFrm, IIC_iMOVi,
2946 "mov", "\t$Rd, $imm", [(set GPR:$Rd, so_imm:$imm)]>, UnaryDP {
2950 let Inst{15-12} = Rd;
2951 let Inst{19-16} = 0b0000;
2952 let Inst{11-0} = imm;
2955 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
2956 def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins imm0_65535_expr:$imm),
2958 "movw", "\t$Rd, $imm",
2959 [(set GPR:$Rd, imm0_65535:$imm)]>,
2960 Requires<[IsARM, HasV6T2]>, UnaryDP {
2963 let Inst{15-12} = Rd;
2964 let Inst{11-0} = imm{11-0};
2965 let Inst{19-16} = imm{15-12};
2968 let DecoderMethod = "DecodeArmMOVTWInstruction";
2971 def : InstAlias<"mov${p} $Rd, $imm",
2972 (MOVi16 GPR:$Rd, imm0_65535_expr:$imm, pred:$p)>,
2975 def MOVi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
2976 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>;
2978 let Constraints = "$src = $Rd" in {
2979 def MOVTi16 : AI1<0b1010, (outs GPRnopc:$Rd),
2980 (ins GPR:$src, imm0_65535_expr:$imm),
2982 "movt", "\t$Rd, $imm",
2984 (or (and GPR:$src, 0xffff),
2985 lo16AllZero:$imm))]>, UnaryDP,
2986 Requires<[IsARM, HasV6T2]> {
2989 let Inst{15-12} = Rd;
2990 let Inst{11-0} = imm{11-0};
2991 let Inst{19-16} = imm{15-12};
2994 let DecoderMethod = "DecodeArmMOVTWInstruction";
2997 def MOVTi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
2998 (ins GPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>;
3002 def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
3003 Requires<[IsARM, HasV6T2]>;
3005 let Uses = [CPSR] in
3006 def RRX: PseudoInst<(outs GPR:$Rd), (ins GPR:$Rm), IIC_iMOVsi,
3007 [(set GPR:$Rd, (ARMrrx GPR:$Rm))]>, UnaryDP,
3010 // These aren't really mov instructions, but we have to define them this way
3011 // due to flag operands.
3013 let Defs = [CPSR] in {
3014 def MOVsrl_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3015 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP,
3017 def MOVsra_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3018 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP,
3022 //===----------------------------------------------------------------------===//
3023 // Extend Instructions.
3028 def SXTB : AI_ext_rrot<0b01101010,
3029 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
3030 def SXTH : AI_ext_rrot<0b01101011,
3031 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
3033 def SXTAB : AI_exta_rrot<0b01101010,
3034 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
3035 def SXTAH : AI_exta_rrot<0b01101011,
3036 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
3038 def SXTB16 : AI_ext_rrot_np<0b01101000, "sxtb16">;
3040 def SXTAB16 : AI_exta_rrot_np<0b01101000, "sxtab16">;
3044 let AddedComplexity = 16 in {
3045 def UXTB : AI_ext_rrot<0b01101110,
3046 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
3047 def UXTH : AI_ext_rrot<0b01101111,
3048 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
3049 def UXTB16 : AI_ext_rrot<0b01101100,
3050 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
3052 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
3053 // The transformation should probably be done as a combiner action
3054 // instead so we can include a check for masking back in the upper
3055 // eight bits of the source into the lower eight bits of the result.
3056 //def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
3057 // (UXTB16r_rot GPR:$Src, 3)>;
3058 def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
3059 (UXTB16 GPR:$Src, 1)>;
3061 def UXTAB : AI_exta_rrot<0b01101110, "uxtab",
3062 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
3063 def UXTAH : AI_exta_rrot<0b01101111, "uxtah",
3064 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
3067 // This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
3068 def UXTAB16 : AI_exta_rrot_np<0b01101100, "uxtab16">;
3071 def SBFX : I<(outs GPRnopc:$Rd),
3072 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3073 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3074 "sbfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3075 Requires<[IsARM, HasV6T2]> {
3080 let Inst{27-21} = 0b0111101;
3081 let Inst{6-4} = 0b101;
3082 let Inst{20-16} = width;
3083 let Inst{15-12} = Rd;
3084 let Inst{11-7} = lsb;
3088 def UBFX : I<(outs GPR:$Rd),
3089 (ins GPR:$Rn, imm0_31:$lsb, imm1_32:$width),
3090 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3091 "ubfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3092 Requires<[IsARM, HasV6T2]> {
3097 let Inst{27-21} = 0b0111111;
3098 let Inst{6-4} = 0b101;
3099 let Inst{20-16} = width;
3100 let Inst{15-12} = Rd;
3101 let Inst{11-7} = lsb;
3105 //===----------------------------------------------------------------------===//
3106 // Arithmetic Instructions.
3109 defm ADD : AsI1_bin_irs<0b0100, "add",
3110 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3111 BinOpFrag<(add node:$LHS, node:$RHS)>, "ADD", 1>;
3112 defm SUB : AsI1_bin_irs<0b0010, "sub",
3113 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3114 BinOpFrag<(sub node:$LHS, node:$RHS)>, "SUB">;
3116 // ADD and SUB with 's' bit set.
3118 // Currently, ADDS/SUBS are pseudo opcodes that exist only in the
3119 // selection DAG. They are "lowered" to real ADD/SUB opcodes by
3120 // AdjustInstrPostInstrSelection where we determine whether or not to
3121 // set the "s" bit based on CPSR liveness.
3123 // FIXME: Eliminate ADDS/SUBS pseudo opcodes after adding tablegen
3124 // support for an optional CPSR definition that corresponds to the DAG
3125 // node's second value. We can then eliminate the implicit def of CPSR.
3126 defm ADDS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3127 BinOpFrag<(ARMaddc node:$LHS, node:$RHS)>, 1>;
3128 defm SUBS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3129 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
3131 defm ADC : AI1_adde_sube_irs<0b0101, "adc",
3132 BinOpWithFlagFrag<(ARMadde node:$LHS, node:$RHS, node:$FLAG)>,
3134 defm SBC : AI1_adde_sube_irs<0b0110, "sbc",
3135 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>,
3138 defm RSB : AsI1_rbin_irs <0b0011, "rsb",
3139 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3140 BinOpFrag<(sub node:$LHS, node:$RHS)>, "RSB">;
3142 // FIXME: Eliminate them if we can write def : Pat patterns which defines
3143 // CPSR and the implicit def of CPSR is not needed.
3144 defm RSBS : AsI1_rbin_s_is<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3145 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
3147 defm RSC : AI1_rsc_irs<0b0111, "rsc",
3148 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>,
3151 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
3152 // The assume-no-carry-in form uses the negation of the input since add/sub
3153 // assume opposite meanings of the carry flag (i.e., carry == !borrow).
3154 // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
3156 def : ARMPat<(add GPR:$src, so_imm_neg:$imm),
3157 (SUBri GPR:$src, so_imm_neg:$imm)>;
3158 def : ARMPat<(ARMaddc GPR:$src, so_imm_neg:$imm),
3159 (SUBSri GPR:$src, so_imm_neg:$imm)>;
3161 // The with-carry-in form matches bitwise not instead of the negation.
3162 // Effectively, the inverse interpretation of the carry flag already accounts
3163 // for part of the negation.
3164 def : ARMPat<(ARMadde GPR:$src, so_imm_not:$imm, CPSR),
3165 (SBCri GPR:$src, so_imm_not:$imm)>;
3167 // Note: These are implemented in C++ code, because they have to generate
3168 // ADD/SUBrs instructions, which use a complex pattern that a xform function
3170 // (mul X, 2^n+1) -> (add (X << n), X)
3171 // (mul X, 2^n-1) -> (rsb X, (X << n))
3173 // ARM Arithmetic Instruction
3174 // GPR:$dst = GPR:$a op GPR:$b
3175 class AAI<bits<8> op27_20, bits<8> op11_4, string opc,
3176 list<dag> pattern = [],
3177 dag iops = (ins GPRnopc:$Rn, GPRnopc:$Rm),
3178 string asm = "\t$Rd, $Rn, $Rm">
3179 : AI<(outs GPRnopc:$Rd), iops, DPFrm, IIC_iALUr, opc, asm, pattern> {
3183 let Inst{27-20} = op27_20;
3184 let Inst{11-4} = op11_4;
3185 let Inst{19-16} = Rn;
3186 let Inst{15-12} = Rd;
3189 let Unpredictable{11-8} = 0b1111;
3192 // Saturating add/subtract
3194 def QADD : AAI<0b00010000, 0b00000101, "qadd",
3195 [(set GPRnopc:$Rd, (int_arm_qadd GPRnopc:$Rm, GPRnopc:$Rn))],
3196 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3197 def QSUB : AAI<0b00010010, 0b00000101, "qsub",
3198 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm, GPRnopc:$Rn))],
3199 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3200 def QDADD : AAI<0b00010100, 0b00000101, "qdadd", [],
3201 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3203 def QDSUB : AAI<0b00010110, 0b00000101, "qdsub", [],
3204 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3207 def QADD16 : AAI<0b01100010, 0b11110001, "qadd16">;
3208 def QADD8 : AAI<0b01100010, 0b11111001, "qadd8">;
3209 def QASX : AAI<0b01100010, 0b11110011, "qasx">;
3210 def QSAX : AAI<0b01100010, 0b11110101, "qsax">;
3211 def QSUB16 : AAI<0b01100010, 0b11110111, "qsub16">;
3212 def QSUB8 : AAI<0b01100010, 0b11111111, "qsub8">;
3213 def UQADD16 : AAI<0b01100110, 0b11110001, "uqadd16">;
3214 def UQADD8 : AAI<0b01100110, 0b11111001, "uqadd8">;
3215 def UQASX : AAI<0b01100110, 0b11110011, "uqasx">;
3216 def UQSAX : AAI<0b01100110, 0b11110101, "uqsax">;
3217 def UQSUB16 : AAI<0b01100110, 0b11110111, "uqsub16">;
3218 def UQSUB8 : AAI<0b01100110, 0b11111111, "uqsub8">;
3220 // Signed/Unsigned add/subtract
3222 def SASX : AAI<0b01100001, 0b11110011, "sasx">;
3223 def SADD16 : AAI<0b01100001, 0b11110001, "sadd16">;
3224 def SADD8 : AAI<0b01100001, 0b11111001, "sadd8">;
3225 def SSAX : AAI<0b01100001, 0b11110101, "ssax">;
3226 def SSUB16 : AAI<0b01100001, 0b11110111, "ssub16">;
3227 def SSUB8 : AAI<0b01100001, 0b11111111, "ssub8">;
3228 def UASX : AAI<0b01100101, 0b11110011, "uasx">;
3229 def UADD16 : AAI<0b01100101, 0b11110001, "uadd16">;
3230 def UADD8 : AAI<0b01100101, 0b11111001, "uadd8">;
3231 def USAX : AAI<0b01100101, 0b11110101, "usax">;
3232 def USUB16 : AAI<0b01100101, 0b11110111, "usub16">;
3233 def USUB8 : AAI<0b01100101, 0b11111111, "usub8">;
3235 // Signed/Unsigned halving add/subtract
3237 def SHASX : AAI<0b01100011, 0b11110011, "shasx">;
3238 def SHADD16 : AAI<0b01100011, 0b11110001, "shadd16">;
3239 def SHADD8 : AAI<0b01100011, 0b11111001, "shadd8">;
3240 def SHSAX : AAI<0b01100011, 0b11110101, "shsax">;
3241 def SHSUB16 : AAI<0b01100011, 0b11110111, "shsub16">;
3242 def SHSUB8 : AAI<0b01100011, 0b11111111, "shsub8">;
3243 def UHASX : AAI<0b01100111, 0b11110011, "uhasx">;
3244 def UHADD16 : AAI<0b01100111, 0b11110001, "uhadd16">;
3245 def UHADD8 : AAI<0b01100111, 0b11111001, "uhadd8">;
3246 def UHSAX : AAI<0b01100111, 0b11110101, "uhsax">;
3247 def UHSUB16 : AAI<0b01100111, 0b11110111, "uhsub16">;
3248 def UHSUB8 : AAI<0b01100111, 0b11111111, "uhsub8">;
3250 // Unsigned Sum of Absolute Differences [and Accumulate].
3252 def USAD8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3253 MulFrm /* for convenience */, NoItinerary, "usad8",
3254 "\t$Rd, $Rn, $Rm", []>,
3255 Requires<[IsARM, HasV6]> {
3259 let Inst{27-20} = 0b01111000;
3260 let Inst{15-12} = 0b1111;
3261 let Inst{7-4} = 0b0001;
3262 let Inst{19-16} = Rd;
3263 let Inst{11-8} = Rm;
3266 def USADA8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3267 MulFrm /* for convenience */, NoItinerary, "usada8",
3268 "\t$Rd, $Rn, $Rm, $Ra", []>,
3269 Requires<[IsARM, HasV6]> {
3274 let Inst{27-20} = 0b01111000;
3275 let Inst{7-4} = 0b0001;
3276 let Inst{19-16} = Rd;
3277 let Inst{15-12} = Ra;
3278 let Inst{11-8} = Rm;
3282 // Signed/Unsigned saturate
3284 def SSAT : AI<(outs GPRnopc:$Rd),
3285 (ins imm1_32:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3286 SatFrm, NoItinerary, "ssat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3291 let Inst{27-21} = 0b0110101;
3292 let Inst{5-4} = 0b01;
3293 let Inst{20-16} = sat_imm;
3294 let Inst{15-12} = Rd;
3295 let Inst{11-7} = sh{4-0};
3296 let Inst{6} = sh{5};
3300 def SSAT16 : AI<(outs GPRnopc:$Rd),
3301 (ins imm1_16:$sat_imm, GPRnopc:$Rn), SatFrm,
3302 NoItinerary, "ssat16", "\t$Rd, $sat_imm, $Rn", []> {
3306 let Inst{27-20} = 0b01101010;
3307 let Inst{11-4} = 0b11110011;
3308 let Inst{15-12} = Rd;
3309 let Inst{19-16} = sat_imm;
3313 def USAT : AI<(outs GPRnopc:$Rd),
3314 (ins imm0_31:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3315 SatFrm, NoItinerary, "usat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3320 let Inst{27-21} = 0b0110111;
3321 let Inst{5-4} = 0b01;
3322 let Inst{15-12} = Rd;
3323 let Inst{11-7} = sh{4-0};
3324 let Inst{6} = sh{5};
3325 let Inst{20-16} = sat_imm;
3329 def USAT16 : AI<(outs GPRnopc:$Rd),
3330 (ins imm0_15:$sat_imm, GPRnopc:$Rn), SatFrm,
3331 NoItinerary, "usat16", "\t$Rd, $sat_imm, $Rn", []> {
3335 let Inst{27-20} = 0b01101110;
3336 let Inst{11-4} = 0b11110011;
3337 let Inst{15-12} = Rd;
3338 let Inst{19-16} = sat_imm;
3342 def : ARMV6Pat<(int_arm_ssat GPRnopc:$a, imm:$pos),
3343 (SSAT imm:$pos, GPRnopc:$a, 0)>;
3344 def : ARMV6Pat<(int_arm_usat GPRnopc:$a, imm:$pos),
3345 (USAT imm:$pos, GPRnopc:$a, 0)>;
3347 //===----------------------------------------------------------------------===//
3348 // Bitwise Instructions.
3351 defm AND : AsI1_bin_irs<0b0000, "and",
3352 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3353 BinOpFrag<(and node:$LHS, node:$RHS)>, "AND", 1>;
3354 defm ORR : AsI1_bin_irs<0b1100, "orr",
3355 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3356 BinOpFrag<(or node:$LHS, node:$RHS)>, "ORR", 1>;
3357 defm EOR : AsI1_bin_irs<0b0001, "eor",
3358 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3359 BinOpFrag<(xor node:$LHS, node:$RHS)>, "EOR", 1>;
3360 defm BIC : AsI1_bin_irs<0b1110, "bic",
3361 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3362 BinOpFrag<(and node:$LHS, (not node:$RHS))>, "BIC">;
3364 // FIXME: bf_inv_mask_imm should be two operands, the lsb and the msb, just
3365 // like in the actual instruction encoding. The complexity of mapping the mask
3366 // to the lsb/msb pair should be handled by ISel, not encapsulated in the
3367 // instruction description.
3368 def BFC : I<(outs GPR:$Rd), (ins GPR:$src, bf_inv_mask_imm:$imm),
3369 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3370 "bfc", "\t$Rd, $imm", "$src = $Rd",
3371 [(set GPR:$Rd, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
3372 Requires<[IsARM, HasV6T2]> {
3375 let Inst{27-21} = 0b0111110;
3376 let Inst{6-0} = 0b0011111;
3377 let Inst{15-12} = Rd;
3378 let Inst{11-7} = imm{4-0}; // lsb
3379 let Inst{20-16} = imm{9-5}; // msb
3382 // A8.6.18 BFI - Bitfield insert (Encoding A1)
3383 def BFI:I<(outs GPRnopc:$Rd), (ins GPRnopc:$src, GPR:$Rn, bf_inv_mask_imm:$imm),
3384 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3385 "bfi", "\t$Rd, $Rn, $imm", "$src = $Rd",
3386 [(set GPRnopc:$Rd, (ARMbfi GPRnopc:$src, GPR:$Rn,
3387 bf_inv_mask_imm:$imm))]>,
3388 Requires<[IsARM, HasV6T2]> {
3392 let Inst{27-21} = 0b0111110;
3393 let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15
3394 let Inst{15-12} = Rd;
3395 let Inst{11-7} = imm{4-0}; // lsb
3396 let Inst{20-16} = imm{9-5}; // width
3400 def MVNr : AsI1<0b1111, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMVNr,
3401 "mvn", "\t$Rd, $Rm",
3402 [(set GPR:$Rd, (not GPR:$Rm))]>, UnaryDP {
3406 let Inst{19-16} = 0b0000;
3407 let Inst{11-4} = 0b00000000;
3408 let Inst{15-12} = Rd;
3411 def MVNsi : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_imm:$shift),
3412 DPSoRegImmFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3413 [(set GPR:$Rd, (not so_reg_imm:$shift))]>, UnaryDP {
3417 let Inst{19-16} = 0b0000;
3418 let Inst{15-12} = Rd;
3419 let Inst{11-5} = shift{11-5};
3421 let Inst{3-0} = shift{3-0};
3423 def MVNsr : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_reg:$shift),
3424 DPSoRegRegFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3425 [(set GPR:$Rd, (not so_reg_reg:$shift))]>, UnaryDP {
3429 let Inst{19-16} = 0b0000;
3430 let Inst{15-12} = Rd;
3431 let Inst{11-8} = shift{11-8};
3433 let Inst{6-5} = shift{6-5};
3435 let Inst{3-0} = shift{3-0};
3437 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3438 def MVNi : AsI1<0b1111, (outs GPR:$Rd), (ins so_imm:$imm), DPFrm,
3439 IIC_iMVNi, "mvn", "\t$Rd, $imm",
3440 [(set GPR:$Rd, so_imm_not:$imm)]>,UnaryDP {
3444 let Inst{19-16} = 0b0000;
3445 let Inst{15-12} = Rd;
3446 let Inst{11-0} = imm;
3449 def : ARMPat<(and GPR:$src, so_imm_not:$imm),
3450 (BICri GPR:$src, so_imm_not:$imm)>;
3452 //===----------------------------------------------------------------------===//
3453 // Multiply Instructions.
3455 class AsMul1I32<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3456 string opc, string asm, list<dag> pattern>
3457 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3461 let Inst{19-16} = Rd;
3462 let Inst{11-8} = Rm;
3465 class AsMul1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3466 string opc, string asm, list<dag> pattern>
3467 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3472 let Inst{19-16} = RdHi;
3473 let Inst{15-12} = RdLo;
3474 let Inst{11-8} = Rm;
3478 // FIXME: The v5 pseudos are only necessary for the additional Constraint
3479 // property. Remove them when it's possible to add those properties
3480 // on an individual MachineInstr, not just an instuction description.
3481 let isCommutable = 1 in {
3482 def MUL : AsMul1I32<0b0000000, (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm),
3483 IIC_iMUL32, "mul", "\t$Rd, $Rn, $Rm",
3484 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))]>,
3485 Requires<[IsARM, HasV6]> {
3486 let Inst{15-12} = 0b0000;
3487 let Unpredictable{15-12} = 0b1111;
3490 let Constraints = "@earlyclobber $Rd" in
3491 def MULv5: ARMPseudoExpand<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm,
3492 pred:$p, cc_out:$s),
3494 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))],
3495 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s)>,
3496 Requires<[IsARM, NoV6]>;
3499 def MLA : AsMul1I32<0b0000001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3500 IIC_iMAC32, "mla", "\t$Rd, $Rn, $Rm, $Ra",
3501 [(set GPR:$Rd, (add (mul GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
3502 Requires<[IsARM, HasV6]> {
3504 let Inst{15-12} = Ra;
3507 let Constraints = "@earlyclobber $Rd" in
3508 def MLAv5: ARMPseudoExpand<(outs GPR:$Rd),
3509 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra, pred:$p, cc_out:$s),
3511 [(set GPR:$Rd, (add (mul GPR:$Rn, GPR:$Rm), GPR:$Ra))],
3512 (MLA GPR:$Rd, GPR:$Rn, GPR:$Rm, GPR:$Ra, pred:$p, cc_out:$s)>,
3513 Requires<[IsARM, NoV6]>;
3515 def MLS : AMul1I<0b0000011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3516 IIC_iMAC32, "mls", "\t$Rd, $Rn, $Rm, $Ra",
3517 [(set GPR:$Rd, (sub GPR:$Ra, (mul GPR:$Rn, GPR:$Rm)))]>,
3518 Requires<[IsARM, HasV6T2]> {
3523 let Inst{19-16} = Rd;
3524 let Inst{15-12} = Ra;
3525 let Inst{11-8} = Rm;
3529 // Extra precision multiplies with low / high results
3530 let neverHasSideEffects = 1 in {
3531 let isCommutable = 1 in {
3532 def SMULL : AsMul1I64<0b0000110, (outs GPR:$RdLo, GPR:$RdHi),
3533 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3534 "smull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3535 Requires<[IsARM, HasV6]>;
3537 def UMULL : AsMul1I64<0b0000100, (outs GPR:$RdLo, GPR:$RdHi),
3538 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3539 "umull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3540 Requires<[IsARM, HasV6]>;
3542 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
3543 def SMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3544 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3546 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3547 Requires<[IsARM, NoV6]>;
3549 def UMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3550 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3552 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3553 Requires<[IsARM, NoV6]>;
3557 // Multiply + accumulate
3558 def SMLAL : AsMul1I64<0b0000111, (outs GPR:$RdLo, GPR:$RdHi),
3559 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3560 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3561 Requires<[IsARM, HasV6]>;
3562 def UMLAL : AsMul1I64<0b0000101, (outs GPR:$RdLo, GPR:$RdHi),
3563 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3564 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3565 Requires<[IsARM, HasV6]>;
3567 def UMAAL : AMul1I <0b0000010, (outs GPR:$RdLo, GPR:$RdHi),
3568 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3569 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3570 Requires<[IsARM, HasV6]> {
3575 let Inst{19-16} = RdHi;
3576 let Inst{15-12} = RdLo;
3577 let Inst{11-8} = Rm;
3581 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
3582 def SMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3583 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3585 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3586 Requires<[IsARM, NoV6]>;
3587 def UMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3588 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3590 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3591 Requires<[IsARM, NoV6]>;
3592 def UMAALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3593 (ins GPR:$Rn, GPR:$Rm, pred:$p),
3595 (UMAAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p)>,
3596 Requires<[IsARM, NoV6]>;
3599 } // neverHasSideEffects
3601 // Most significant word multiply
3602 def SMMUL : AMul2I <0b0111010, 0b0001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3603 IIC_iMUL32, "smmul", "\t$Rd, $Rn, $Rm",
3604 [(set GPR:$Rd, (mulhs GPR:$Rn, GPR:$Rm))]>,
3605 Requires<[IsARM, HasV6]> {
3606 let Inst{15-12} = 0b1111;
3609 def SMMULR : AMul2I <0b0111010, 0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3610 IIC_iMUL32, "smmulr", "\t$Rd, $Rn, $Rm", []>,
3611 Requires<[IsARM, HasV6]> {
3612 let Inst{15-12} = 0b1111;
3615 def SMMLA : AMul2Ia <0b0111010, 0b0001, (outs GPR:$Rd),
3616 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3617 IIC_iMAC32, "smmla", "\t$Rd, $Rn, $Rm, $Ra",
3618 [(set GPR:$Rd, (add (mulhs GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
3619 Requires<[IsARM, HasV6]>;
3621 def SMMLAR : AMul2Ia <0b0111010, 0b0011, (outs GPR:$Rd),
3622 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3623 IIC_iMAC32, "smmlar", "\t$Rd, $Rn, $Rm, $Ra", []>,
3624 Requires<[IsARM, HasV6]>;
3626 def SMMLS : AMul2Ia <0b0111010, 0b1101, (outs GPR:$Rd),
3627 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3628 IIC_iMAC32, "smmls", "\t$Rd, $Rn, $Rm, $Ra",
3629 [(set GPR:$Rd, (sub GPR:$Ra, (mulhs GPR:$Rn, GPR:$Rm)))]>,
3630 Requires<[IsARM, HasV6]>;
3632 def SMMLSR : AMul2Ia <0b0111010, 0b1111, (outs GPR:$Rd),
3633 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3634 IIC_iMAC32, "smmlsr", "\t$Rd, $Rn, $Rm, $Ra", []>,
3635 Requires<[IsARM, HasV6]>;
3637 multiclass AI_smul<string opc, PatFrag opnode> {
3638 def BB : AMulxyI<0b0001011, 0b00, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3639 IIC_iMUL16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm",
3640 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3641 (sext_inreg GPR:$Rm, i16)))]>,
3642 Requires<[IsARM, HasV5TE]>;
3644 def BT : AMulxyI<0b0001011, 0b10, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3645 IIC_iMUL16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm",
3646 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3647 (sra GPR:$Rm, (i32 16))))]>,
3648 Requires<[IsARM, HasV5TE]>;
3650 def TB : AMulxyI<0b0001011, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3651 IIC_iMUL16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm",
3652 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3653 (sext_inreg GPR:$Rm, i16)))]>,
3654 Requires<[IsARM, HasV5TE]>;
3656 def TT : AMulxyI<0b0001011, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3657 IIC_iMUL16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm",
3658 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3659 (sra GPR:$Rm, (i32 16))))]>,
3660 Requires<[IsARM, HasV5TE]>;
3662 def WB : AMulxyI<0b0001001, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3663 IIC_iMUL16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm",
3664 [(set GPR:$Rd, (sra (opnode GPR:$Rn,
3665 (sext_inreg GPR:$Rm, i16)), (i32 16)))]>,
3666 Requires<[IsARM, HasV5TE]>;
3668 def WT : AMulxyI<0b0001001, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3669 IIC_iMUL16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm",
3670 [(set GPR:$Rd, (sra (opnode GPR:$Rn,
3671 (sra GPR:$Rm, (i32 16))), (i32 16)))]>,
3672 Requires<[IsARM, HasV5TE]>;
3676 multiclass AI_smla<string opc, PatFrag opnode> {
3677 let DecoderMethod = "DecodeSMLAInstruction" in {
3678 def BB : AMulxyIa<0b0001000, 0b00, (outs GPRnopc:$Rd),
3679 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3680 IIC_iMAC16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra",
3681 [(set GPRnopc:$Rd, (add GPR:$Ra,
3682 (opnode (sext_inreg GPRnopc:$Rn, i16),
3683 (sext_inreg GPRnopc:$Rm, i16))))]>,
3684 Requires<[IsARM, HasV5TE]>;
3686 def BT : AMulxyIa<0b0001000, 0b10, (outs GPRnopc:$Rd),
3687 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3688 IIC_iMAC16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra",
3690 (add GPR:$Ra, (opnode (sext_inreg GPRnopc:$Rn, i16),
3691 (sra GPRnopc:$Rm, (i32 16)))))]>,
3692 Requires<[IsARM, HasV5TE]>;
3694 def TB : AMulxyIa<0b0001000, 0b01, (outs GPRnopc:$Rd),
3695 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3696 IIC_iMAC16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra",
3698 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
3699 (sext_inreg GPRnopc:$Rm, i16))))]>,
3700 Requires<[IsARM, HasV5TE]>;
3702 def TT : AMulxyIa<0b0001000, 0b11, (outs GPRnopc:$Rd),
3703 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3704 IIC_iMAC16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra",
3706 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
3707 (sra GPRnopc:$Rm, (i32 16)))))]>,
3708 Requires<[IsARM, HasV5TE]>;
3710 def WB : AMulxyIa<0b0001001, 0b00, (outs GPRnopc:$Rd),
3711 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3712 IIC_iMAC16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra",
3714 (add GPR:$Ra, (sra (opnode GPRnopc:$Rn,
3715 (sext_inreg GPRnopc:$Rm, i16)), (i32 16))))]>,
3716 Requires<[IsARM, HasV5TE]>;
3718 def WT : AMulxyIa<0b0001001, 0b10, (outs GPRnopc:$Rd),
3719 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3720 IIC_iMAC16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra",
3722 (add GPR:$Ra, (sra (opnode GPRnopc:$Rn,
3723 (sra GPRnopc:$Rm, (i32 16))), (i32 16))))]>,
3724 Requires<[IsARM, HasV5TE]>;
3728 defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
3729 defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
3731 // Halfword multiply accumulate long: SMLAL<x><y>.
3732 def SMLALBB : AMulxyI64<0b0001010, 0b00, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3733 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3734 IIC_iMAC64, "smlalbb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3735 Requires<[IsARM, HasV5TE]>;
3737 def SMLALBT : AMulxyI64<0b0001010, 0b10, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3738 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3739 IIC_iMAC64, "smlalbt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3740 Requires<[IsARM, HasV5TE]>;
3742 def SMLALTB : AMulxyI64<0b0001010, 0b01, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3743 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3744 IIC_iMAC64, "smlaltb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3745 Requires<[IsARM, HasV5TE]>;
3747 def SMLALTT : AMulxyI64<0b0001010, 0b11, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3748 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3749 IIC_iMAC64, "smlaltt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3750 Requires<[IsARM, HasV5TE]>;
3752 // Helper class for AI_smld.
3753 class AMulDualIbase<bit long, bit sub, bit swap, dag oops, dag iops,
3754 InstrItinClass itin, string opc, string asm>
3755 : AI<oops, iops, MulFrm, itin, opc, asm, []>, Requires<[IsARM, HasV6]> {
3758 let Inst{27-23} = 0b01110;
3759 let Inst{22} = long;
3760 let Inst{21-20} = 0b00;
3761 let Inst{11-8} = Rm;
3768 class AMulDualI<bit long, bit sub, bit swap, dag oops, dag iops,
3769 InstrItinClass itin, string opc, string asm>
3770 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
3772 let Inst{15-12} = 0b1111;
3773 let Inst{19-16} = Rd;
3775 class AMulDualIa<bit long, bit sub, bit swap, dag oops, dag iops,
3776 InstrItinClass itin, string opc, string asm>
3777 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
3780 let Inst{19-16} = Rd;
3781 let Inst{15-12} = Ra;
3783 class AMulDualI64<bit long, bit sub, bit swap, dag oops, dag iops,
3784 InstrItinClass itin, string opc, string asm>
3785 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
3788 let Inst{19-16} = RdHi;
3789 let Inst{15-12} = RdLo;
3792 multiclass AI_smld<bit sub, string opc> {
3794 def D : AMulDualIa<0, sub, 0, (outs GPRnopc:$Rd),
3795 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3796 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm, $Ra">;
3798 def DX: AMulDualIa<0, sub, 1, (outs GPRnopc:$Rd),
3799 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3800 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm, $Ra">;
3802 def LD: AMulDualI64<1, sub, 0, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3803 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
3804 !strconcat(opc, "ld"), "\t$RdLo, $RdHi, $Rn, $Rm">;
3806 def LDX : AMulDualI64<1, sub, 1, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3807 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
3808 !strconcat(opc, "ldx"),"\t$RdLo, $RdHi, $Rn, $Rm">;
3812 defm SMLA : AI_smld<0, "smla">;
3813 defm SMLS : AI_smld<1, "smls">;
3815 multiclass AI_sdml<bit sub, string opc> {
3817 def D:AMulDualI<0, sub, 0, (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm),
3818 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm">;
3819 def DX:AMulDualI<0, sub, 1, (outs GPRnopc:$Rd),(ins GPRnopc:$Rn, GPRnopc:$Rm),
3820 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm">;
3823 defm SMUA : AI_sdml<0, "smua">;
3824 defm SMUS : AI_sdml<1, "smus">;
3826 //===----------------------------------------------------------------------===//
3827 // Misc. Arithmetic Instructions.
3830 def CLZ : AMiscA1I<0b000010110, 0b0001, (outs GPR:$Rd), (ins GPR:$Rm),
3831 IIC_iUNAr, "clz", "\t$Rd, $Rm",
3832 [(set GPR:$Rd, (ctlz GPR:$Rm))]>, Requires<[IsARM, HasV5T]>;
3834 def RBIT : AMiscA1I<0b01101111, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
3835 IIC_iUNAr, "rbit", "\t$Rd, $Rm",
3836 [(set GPR:$Rd, (ARMrbit GPR:$Rm))]>,
3837 Requires<[IsARM, HasV6T2]>;
3839 def REV : AMiscA1I<0b01101011, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
3840 IIC_iUNAr, "rev", "\t$Rd, $Rm",
3841 [(set GPR:$Rd, (bswap GPR:$Rm))]>, Requires<[IsARM, HasV6]>;
3843 let AddedComplexity = 5 in
3844 def REV16 : AMiscA1I<0b01101011, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
3845 IIC_iUNAr, "rev16", "\t$Rd, $Rm",
3846 [(set GPR:$Rd, (rotr (bswap GPR:$Rm), (i32 16)))]>,
3847 Requires<[IsARM, HasV6]>;
3849 let AddedComplexity = 5 in
3850 def REVSH : AMiscA1I<0b01101111, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
3851 IIC_iUNAr, "revsh", "\t$Rd, $Rm",
3852 [(set GPR:$Rd, (sra (bswap GPR:$Rm), (i32 16)))]>,
3853 Requires<[IsARM, HasV6]>;
3855 def : ARMV6Pat<(or (sra (shl GPR:$Rm, (i32 24)), (i32 16)),
3856 (and (srl GPR:$Rm, (i32 8)), 0xFF)),
3859 def PKHBT : APKHI<0b01101000, 0, (outs GPRnopc:$Rd),
3860 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_lsl_amt:$sh),
3861 IIC_iALUsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh",
3862 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF),
3863 (and (shl GPRnopc:$Rm, pkh_lsl_amt:$sh),
3865 Requires<[IsARM, HasV6]>;
3867 // Alternate cases for PKHBT where identities eliminate some nodes.
3868 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (and GPRnopc:$Rm, 0xFFFF0000)),
3869 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, 0)>;
3870 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (shl GPRnopc:$Rm, imm16_31:$sh)),
3871 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, imm16_31:$sh)>;
3873 // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
3874 // will match the pattern below.
3875 def PKHTB : APKHI<0b01101000, 1, (outs GPRnopc:$Rd),
3876 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_asr_amt:$sh),
3877 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh",
3878 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF0000),
3879 (and (sra GPRnopc:$Rm, pkh_asr_amt:$sh),
3881 Requires<[IsARM, HasV6]>;
3883 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
3884 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
3885 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
3886 (srl GPRnopc:$src2, imm16_31:$sh)),
3887 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16_31:$sh)>;
3888 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
3889 (and (srl GPRnopc:$src2, imm1_15:$sh), 0xFFFF)),
3890 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm1_15:$sh)>;
3892 //===----------------------------------------------------------------------===//
3893 // Comparison Instructions...
3896 defm CMP : AI1_cmp_irs<0b1010, "cmp",
3897 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
3898 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
3900 // ARMcmpZ can re-use the above instruction definitions.
3901 def : ARMPat<(ARMcmpZ GPR:$src, so_imm:$imm),
3902 (CMPri GPR:$src, so_imm:$imm)>;
3903 def : ARMPat<(ARMcmpZ GPR:$src, GPR:$rhs),
3904 (CMPrr GPR:$src, GPR:$rhs)>;
3905 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_imm:$rhs),
3906 (CMPrsi GPR:$src, so_reg_imm:$rhs)>;
3907 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_reg:$rhs),
3908 (CMPrsr GPR:$src, so_reg_reg:$rhs)>;
3910 // FIXME: We have to be careful when using the CMN instruction and comparison
3911 // with 0. One would expect these two pieces of code should give identical
3927 // However, the CMN gives the *opposite* result when r1 is 0. This is because
3928 // the carry flag is set in the CMP case but not in the CMN case. In short, the
3929 // CMP instruction doesn't perform a truncate of the (logical) NOT of 0 plus the
3930 // value of r0 and the carry bit (because the "carry bit" parameter to
3931 // AddWithCarry is defined as 1 in this case, the carry flag will always be set
3932 // when r0 >= 0). The CMN instruction doesn't perform a NOT of 0 so there is
3933 // never a "carry" when this AddWithCarry is performed (because the "carry bit"
3934 // parameter to AddWithCarry is defined as 0).
3936 // When x is 0 and unsigned:
3940 // ~x + 1 = 0x1 0000 0000
3941 // (-x = 0) != (0x1 0000 0000 = ~x + 1)
3943 // Therefore, we should disable CMN when comparing against zero, until we can
3944 // limit when the CMN instruction is used (when we know that the RHS is not 0 or
3945 // when it's a comparison which doesn't look at the 'carry' flag).
3947 // (See the ARM docs for the "AddWithCarry" pseudo-code.)
3949 // This is related to <rdar://problem/7569620>.
3951 //defm CMN : AI1_cmp_irs<0b1011, "cmn",
3952 // BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>;
3954 // Note that TST/TEQ don't set all the same flags that CMP does!
3955 defm TST : AI1_cmp_irs<0b1000, "tst",
3956 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
3957 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>, 1>;
3958 defm TEQ : AI1_cmp_irs<0b1001, "teq",
3959 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
3960 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>, 1>;
3962 defm CMNz : AI1_cmp_irs<0b1011, "cmn",
3963 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
3964 BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>>;
3966 //def : ARMPat<(ARMcmp GPR:$src, so_imm_neg:$imm),
3967 // (CMNri GPR:$src, so_imm_neg:$imm)>;
3969 def : ARMPat<(ARMcmpZ GPR:$src, so_imm_neg:$imm),
3970 (CMNzri GPR:$src, so_imm_neg:$imm)>;
3972 // Pseudo i64 compares for some floating point compares.
3973 let usesCustomInserter = 1, isBranch = 1, isTerminator = 1,
3975 def BCCi64 : PseudoInst<(outs),
3976 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, brtarget:$dst),
3978 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, bb:$dst)]>;
3980 def BCCZi64 : PseudoInst<(outs),
3981 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, brtarget:$dst), IIC_Br,
3982 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, 0, 0, bb:$dst)]>;
3983 } // usesCustomInserter
3986 // Conditional moves
3987 // FIXME: should be able to write a pattern for ARMcmov, but can't use
3988 // a two-value operand where a dag node expects two operands. :(
3989 let neverHasSideEffects = 1 in {
3991 let isCommutable = 1 in
3992 def MOVCCr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$false, GPR:$Rm, pred:$p),
3994 [/*(set GPR:$Rd, (ARMcmov GPR:$false, GPR:$Rm, imm:$cc, CCR:$ccr))*/]>,
3995 RegConstraint<"$false = $Rd">;
3997 def MOVCCsi : ARMPseudoInst<(outs GPR:$Rd),
3998 (ins GPR:$false, so_reg_imm:$shift, pred:$p),
4000 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_imm:$shift,
4001 imm:$cc, CCR:$ccr))*/]>,
4002 RegConstraint<"$false = $Rd">;
4003 def MOVCCsr : ARMPseudoInst<(outs GPR:$Rd),
4004 (ins GPR:$false, so_reg_reg:$shift, pred:$p),
4006 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_reg:$shift,
4007 imm:$cc, CCR:$ccr))*/]>,
4008 RegConstraint<"$false = $Rd">;
4011 let isMoveImm = 1 in
4012 def MOVCCi16 : ARMPseudoInst<(outs GPR:$Rd),
4013 (ins GPR:$false, imm0_65535_expr:$imm, pred:$p),
4016 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>;
4018 let isMoveImm = 1 in
4019 def MOVCCi : ARMPseudoInst<(outs GPR:$Rd),
4020 (ins GPR:$false, so_imm:$imm, pred:$p),
4022 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_imm:$imm, imm:$cc, CCR:$ccr))*/]>,
4023 RegConstraint<"$false = $Rd">;
4025 // Two instruction predicate mov immediate.
4026 let isMoveImm = 1 in
4027 def MOVCCi32imm : ARMPseudoInst<(outs GPR:$Rd),
4028 (ins GPR:$false, i32imm:$src, pred:$p),
4029 8, IIC_iCMOVix2, []>, RegConstraint<"$false = $Rd">;
4031 let isMoveImm = 1 in
4032 def MVNCCi : ARMPseudoInst<(outs GPR:$Rd),
4033 (ins GPR:$false, so_imm:$imm, pred:$p),
4035 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_imm_not:$imm, imm:$cc, CCR:$ccr))*/]>,
4036 RegConstraint<"$false = $Rd">;
4038 // Conditional instructions
4039 multiclass AsI1_bincc_irs<Instruction iri, Instruction irr, Instruction irsi,
4041 InstrItinClass iii, InstrItinClass iir,
4042 InstrItinClass iis> {
4043 def ri : ARMPseudoExpand<(outs GPR:$Rd),
4044 (ins GPR:$Rn, so_imm:$imm, pred:$p, cc_out:$s),
4046 (iri GPR:$Rd, GPR:$Rn, so_imm:$imm, pred:$p, cc_out:$s)>,
4047 RegConstraint<"$Rn = $Rd">;
4048 def rr : ARMPseudoExpand<(outs GPR:$Rd),
4049 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
4051 (irr GPR:$Rd, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
4052 RegConstraint<"$Rn = $Rd">;
4053 def rsi : ARMPseudoExpand<(outs GPR:$Rd),
4054 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p, cc_out:$s),
4056 (irsi GPR:$Rd, GPR:$Rn, so_reg_imm:$shift, pred:$p, cc_out:$s)>,
4057 RegConstraint<"$Rn = $Rd">;
4058 def rsr : ARMPseudoExpand<(outs GPRnopc:$Rd),
4059 (ins GPRnopc:$Rn, so_reg_reg:$shift, pred:$p, cc_out:$s),
4061 (irsr GPR:$Rd, GPR:$Rn, so_reg_reg:$shift, pred:$p, cc_out:$s)>,
4062 RegConstraint<"$Rn = $Rd">;
4065 defm ANDCC : AsI1_bincc_irs<ANDri, ANDrr, ANDrsi, ANDrsr,
4066 IIC_iBITi, IIC_iBITr, IIC_iBITsr>;
4067 defm ORRCC : AsI1_bincc_irs<ORRri, ORRrr, ORRrsi, ORRrsr,
4068 IIC_iBITi, IIC_iBITr, IIC_iBITsr>;
4069 defm EORCC : AsI1_bincc_irs<EORri, EORrr, EORrsi, EORrsr,
4070 IIC_iBITi, IIC_iBITr, IIC_iBITsr>;
4072 } // neverHasSideEffects
4075 //===----------------------------------------------------------------------===//
4076 // Atomic operations intrinsics
4079 def MemBarrierOptOperand : AsmOperandClass {
4080 let Name = "MemBarrierOpt";
4081 let ParserMethod = "parseMemBarrierOptOperand";
4083 def memb_opt : Operand<i32> {
4084 let PrintMethod = "printMemBOption";
4085 let ParserMatchClass = MemBarrierOptOperand;
4086 let DecoderMethod = "DecodeMemBarrierOption";
4089 // memory barriers protect the atomic sequences
4090 let hasSideEffects = 1 in {
4091 def DMB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4092 "dmb", "\t$opt", [(ARMMemBarrier (i32 imm:$opt))]>,
4093 Requires<[IsARM, HasDB]> {
4095 let Inst{31-4} = 0xf57ff05;
4096 let Inst{3-0} = opt;
4100 def DSB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4101 "dsb", "\t$opt", []>,
4102 Requires<[IsARM, HasDB]> {
4104 let Inst{31-4} = 0xf57ff04;
4105 let Inst{3-0} = opt;
4108 // ISB has only full system option
4109 def ISB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4110 "isb", "\t$opt", []>,
4111 Requires<[IsARM, HasDB]> {
4113 let Inst{31-4} = 0xf57ff06;
4114 let Inst{3-0} = opt;
4117 // Pseudo instruction that combines movs + predicated rsbmi
4118 // to implement integer ABS
4119 let usesCustomInserter = 1, Defs = [CPSR] in {
4120 def ABS : ARMPseudoInst<
4121 (outs GPR:$dst), (ins GPR:$src),
4122 8, NoItinerary, []>;
4125 let usesCustomInserter = 1 in {
4126 let Defs = [CPSR] in {
4127 def ATOMIC_LOAD_ADD_I8 : PseudoInst<
4128 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4129 [(set GPR:$dst, (atomic_load_add_8 GPR:$ptr, GPR:$incr))]>;
4130 def ATOMIC_LOAD_SUB_I8 : PseudoInst<
4131 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4132 [(set GPR:$dst, (atomic_load_sub_8 GPR:$ptr, GPR:$incr))]>;
4133 def ATOMIC_LOAD_AND_I8 : PseudoInst<
4134 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4135 [(set GPR:$dst, (atomic_load_and_8 GPR:$ptr, GPR:$incr))]>;
4136 def ATOMIC_LOAD_OR_I8 : PseudoInst<
4137 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4138 [(set GPR:$dst, (atomic_load_or_8 GPR:$ptr, GPR:$incr))]>;
4139 def ATOMIC_LOAD_XOR_I8 : PseudoInst<
4140 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4141 [(set GPR:$dst, (atomic_load_xor_8 GPR:$ptr, GPR:$incr))]>;
4142 def ATOMIC_LOAD_NAND_I8 : PseudoInst<
4143 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4144 [(set GPR:$dst, (atomic_load_nand_8 GPR:$ptr, GPR:$incr))]>;
4145 def ATOMIC_LOAD_MIN_I8 : PseudoInst<
4146 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4147 [(set GPR:$dst, (atomic_load_min_8 GPR:$ptr, GPR:$val))]>;
4148 def ATOMIC_LOAD_MAX_I8 : PseudoInst<
4149 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4150 [(set GPR:$dst, (atomic_load_max_8 GPR:$ptr, GPR:$val))]>;
4151 def ATOMIC_LOAD_UMIN_I8 : PseudoInst<
4152 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4153 [(set GPR:$dst, (atomic_load_umin_8 GPR:$ptr, GPR:$val))]>;
4154 def ATOMIC_LOAD_UMAX_I8 : PseudoInst<
4155 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4156 [(set GPR:$dst, (atomic_load_umax_8 GPR:$ptr, GPR:$val))]>;
4157 def ATOMIC_LOAD_ADD_I16 : PseudoInst<
4158 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4159 [(set GPR:$dst, (atomic_load_add_16 GPR:$ptr, GPR:$incr))]>;
4160 def ATOMIC_LOAD_SUB_I16 : PseudoInst<
4161 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4162 [(set GPR:$dst, (atomic_load_sub_16 GPR:$ptr, GPR:$incr))]>;
4163 def ATOMIC_LOAD_AND_I16 : PseudoInst<
4164 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4165 [(set GPR:$dst, (atomic_load_and_16 GPR:$ptr, GPR:$incr))]>;
4166 def ATOMIC_LOAD_OR_I16 : PseudoInst<
4167 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4168 [(set GPR:$dst, (atomic_load_or_16 GPR:$ptr, GPR:$incr))]>;
4169 def ATOMIC_LOAD_XOR_I16 : PseudoInst<
4170 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4171 [(set GPR:$dst, (atomic_load_xor_16 GPR:$ptr, GPR:$incr))]>;
4172 def ATOMIC_LOAD_NAND_I16 : PseudoInst<
4173 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4174 [(set GPR:$dst, (atomic_load_nand_16 GPR:$ptr, GPR:$incr))]>;
4175 def ATOMIC_LOAD_MIN_I16 : PseudoInst<
4176 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4177 [(set GPR:$dst, (atomic_load_min_16 GPR:$ptr, GPR:$val))]>;
4178 def ATOMIC_LOAD_MAX_I16 : PseudoInst<
4179 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4180 [(set GPR:$dst, (atomic_load_max_16 GPR:$ptr, GPR:$val))]>;
4181 def ATOMIC_LOAD_UMIN_I16 : PseudoInst<
4182 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4183 [(set GPR:$dst, (atomic_load_umin_16 GPR:$ptr, GPR:$val))]>;
4184 def ATOMIC_LOAD_UMAX_I16 : PseudoInst<
4185 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4186 [(set GPR:$dst, (atomic_load_umax_16 GPR:$ptr, GPR:$val))]>;
4187 def ATOMIC_LOAD_ADD_I32 : PseudoInst<
4188 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4189 [(set GPR:$dst, (atomic_load_add_32 GPR:$ptr, GPR:$incr))]>;
4190 def ATOMIC_LOAD_SUB_I32 : PseudoInst<
4191 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4192 [(set GPR:$dst, (atomic_load_sub_32 GPR:$ptr, GPR:$incr))]>;
4193 def ATOMIC_LOAD_AND_I32 : PseudoInst<
4194 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4195 [(set GPR:$dst, (atomic_load_and_32 GPR:$ptr, GPR:$incr))]>;
4196 def ATOMIC_LOAD_OR_I32 : PseudoInst<
4197 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4198 [(set GPR:$dst, (atomic_load_or_32 GPR:$ptr, GPR:$incr))]>;
4199 def ATOMIC_LOAD_XOR_I32 : PseudoInst<
4200 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4201 [(set GPR:$dst, (atomic_load_xor_32 GPR:$ptr, GPR:$incr))]>;
4202 def ATOMIC_LOAD_NAND_I32 : PseudoInst<
4203 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4204 [(set GPR:$dst, (atomic_load_nand_32 GPR:$ptr, GPR:$incr))]>;
4205 def ATOMIC_LOAD_MIN_I32 : PseudoInst<
4206 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4207 [(set GPR:$dst, (atomic_load_min_32 GPR:$ptr, GPR:$val))]>;
4208 def ATOMIC_LOAD_MAX_I32 : PseudoInst<
4209 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4210 [(set GPR:$dst, (atomic_load_max_32 GPR:$ptr, GPR:$val))]>;
4211 def ATOMIC_LOAD_UMIN_I32 : PseudoInst<
4212 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4213 [(set GPR:$dst, (atomic_load_umin_32 GPR:$ptr, GPR:$val))]>;
4214 def ATOMIC_LOAD_UMAX_I32 : PseudoInst<
4215 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4216 [(set GPR:$dst, (atomic_load_umax_32 GPR:$ptr, GPR:$val))]>;
4218 def ATOMIC_SWAP_I8 : PseudoInst<
4219 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
4220 [(set GPR:$dst, (atomic_swap_8 GPR:$ptr, GPR:$new))]>;
4221 def ATOMIC_SWAP_I16 : PseudoInst<
4222 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
4223 [(set GPR:$dst, (atomic_swap_16 GPR:$ptr, GPR:$new))]>;
4224 def ATOMIC_SWAP_I32 : PseudoInst<
4225 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
4226 [(set GPR:$dst, (atomic_swap_32 GPR:$ptr, GPR:$new))]>;
4228 def ATOMIC_CMP_SWAP_I8 : PseudoInst<
4229 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
4230 [(set GPR:$dst, (atomic_cmp_swap_8 GPR:$ptr, GPR:$old, GPR:$new))]>;
4231 def ATOMIC_CMP_SWAP_I16 : PseudoInst<
4232 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
4233 [(set GPR:$dst, (atomic_cmp_swap_16 GPR:$ptr, GPR:$old, GPR:$new))]>;
4234 def ATOMIC_CMP_SWAP_I32 : PseudoInst<
4235 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
4236 [(set GPR:$dst, (atomic_cmp_swap_32 GPR:$ptr, GPR:$old, GPR:$new))]>;
4240 let mayLoad = 1 in {
4241 def LDREXB : AIldrex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4243 "ldrexb", "\t$Rt, $addr", []>;
4244 def LDREXH : AIldrex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4245 NoItinerary, "ldrexh", "\t$Rt, $addr", []>;
4246 def LDREX : AIldrex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4247 NoItinerary, "ldrex", "\t$Rt, $addr", []>;
4248 let hasExtraDefRegAllocReq = 1 in
4249 def LDREXD: AIldrex<0b01, (outs GPR:$Rt, GPR:$Rt2),(ins addr_offset_none:$addr),
4250 NoItinerary, "ldrexd", "\t$Rt, $Rt2, $addr", []> {
4251 let DecoderMethod = "DecodeDoubleRegLoad";
4255 let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
4256 def STREXB: AIstrex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4257 NoItinerary, "strexb", "\t$Rd, $Rt, $addr", []>;
4258 def STREXH: AIstrex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4259 NoItinerary, "strexh", "\t$Rd, $Rt, $addr", []>;
4260 def STREX : AIstrex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4261 NoItinerary, "strex", "\t$Rd, $Rt, $addr", []>;
4262 let hasExtraSrcRegAllocReq = 1 in
4263 def STREXD : AIstrex<0b01, (outs GPR:$Rd),
4264 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr),
4265 NoItinerary, "strexd", "\t$Rd, $Rt, $Rt2, $addr", []> {
4266 let DecoderMethod = "DecodeDoubleRegStore";
4271 def CLREX : AXI<(outs), (ins), MiscFrm, NoItinerary, "clrex", []>,
4272 Requires<[IsARM, HasV7]> {
4273 let Inst{31-0} = 0b11110101011111111111000000011111;
4276 // SWP/SWPB are deprecated in V6/V7.
4277 let mayLoad = 1, mayStore = 1 in {
4278 def SWP : AIswp<0, (outs GPR:$Rt), (ins GPR:$Rt2, addr_offset_none:$addr),
4280 def SWPB: AIswp<1, (outs GPR:$Rt), (ins GPR:$Rt2, addr_offset_none:$addr),
4284 //===----------------------------------------------------------------------===//
4285 // Coprocessor Instructions.
4288 def CDP : ABI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4289 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4290 NoItinerary, "cdp", "\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4291 [(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4292 imm:$CRm, imm:$opc2)]> {
4300 let Inst{3-0} = CRm;
4302 let Inst{7-5} = opc2;
4303 let Inst{11-8} = cop;
4304 let Inst{15-12} = CRd;
4305 let Inst{19-16} = CRn;
4306 let Inst{23-20} = opc1;
4309 def CDP2 : ABXI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4310 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4311 NoItinerary, "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4312 [(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4313 imm:$CRm, imm:$opc2)]> {
4314 let Inst{31-28} = 0b1111;
4322 let Inst{3-0} = CRm;
4324 let Inst{7-5} = opc2;
4325 let Inst{11-8} = cop;
4326 let Inst{15-12} = CRd;
4327 let Inst{19-16} = CRn;
4328 let Inst{23-20} = opc1;
4331 class ACI<dag oops, dag iops, string opc, string asm,
4332 IndexMode im = IndexModeNone>
4333 : I<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
4335 let Inst{27-25} = 0b110;
4337 class ACInoP<dag oops, dag iops, string opc, string asm,
4338 IndexMode im = IndexModeNone>
4339 : InoP<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
4341 let Inst{31-28} = 0b1111;
4342 let Inst{27-25} = 0b110;
4344 multiclass LdStCop<bit load, bit Dbit, string asm> {
4345 def _OFFSET : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4346 asm, "\t$cop, $CRd, $addr"> {
4350 let Inst{24} = 1; // P = 1
4351 let Inst{23} = addr{8};
4352 let Inst{22} = Dbit;
4353 let Inst{21} = 0; // W = 0
4354 let Inst{20} = load;
4355 let Inst{19-16} = addr{12-9};
4356 let Inst{15-12} = CRd;
4357 let Inst{11-8} = cop;
4358 let Inst{7-0} = addr{7-0};
4359 let DecoderMethod = "DecodeCopMemInstruction";
4361 def _PRE : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4362 asm, "\t$cop, $CRd, $addr!", IndexModePre> {
4366 let Inst{24} = 1; // P = 1
4367 let Inst{23} = addr{8};
4368 let Inst{22} = Dbit;
4369 let Inst{21} = 1; // W = 1
4370 let Inst{20} = load;
4371 let Inst{19-16} = addr{12-9};
4372 let Inst{15-12} = CRd;
4373 let Inst{11-8} = cop;
4374 let Inst{7-0} = addr{7-0};
4375 let DecoderMethod = "DecodeCopMemInstruction";
4377 def _POST: ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4378 postidx_imm8s4:$offset),
4379 asm, "\t$cop, $CRd, $addr, $offset", IndexModePost> {
4384 let Inst{24} = 0; // P = 0
4385 let Inst{23} = offset{8};
4386 let Inst{22} = Dbit;
4387 let Inst{21} = 1; // W = 1
4388 let Inst{20} = load;
4389 let Inst{19-16} = addr;
4390 let Inst{15-12} = CRd;
4391 let Inst{11-8} = cop;
4392 let Inst{7-0} = offset{7-0};
4393 let DecoderMethod = "DecodeCopMemInstruction";
4395 def _OPTION : ACI<(outs),
4396 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4397 coproc_option_imm:$option),
4398 asm, "\t$cop, $CRd, $addr, $option"> {
4403 let Inst{24} = 0; // P = 0
4404 let Inst{23} = 1; // U = 1
4405 let Inst{22} = Dbit;
4406 let Inst{21} = 0; // W = 0
4407 let Inst{20} = load;
4408 let Inst{19-16} = addr;
4409 let Inst{15-12} = CRd;
4410 let Inst{11-8} = cop;
4411 let Inst{7-0} = option;
4412 let DecoderMethod = "DecodeCopMemInstruction";
4415 multiclass LdSt2Cop<bit load, bit Dbit, string asm> {
4416 def _OFFSET : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4417 asm, "\t$cop, $CRd, $addr"> {
4421 let Inst{24} = 1; // P = 1
4422 let Inst{23} = addr{8};
4423 let Inst{22} = Dbit;
4424 let Inst{21} = 0; // W = 0
4425 let Inst{20} = load;
4426 let Inst{19-16} = addr{12-9};
4427 let Inst{15-12} = CRd;
4428 let Inst{11-8} = cop;
4429 let Inst{7-0} = addr{7-0};
4430 let DecoderMethod = "DecodeCopMemInstruction";
4432 def _PRE : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4433 asm, "\t$cop, $CRd, $addr!", IndexModePre> {
4437 let Inst{24} = 1; // P = 1
4438 let Inst{23} = addr{8};
4439 let Inst{22} = Dbit;
4440 let Inst{21} = 1; // W = 1
4441 let Inst{20} = load;
4442 let Inst{19-16} = addr{12-9};
4443 let Inst{15-12} = CRd;
4444 let Inst{11-8} = cop;
4445 let Inst{7-0} = addr{7-0};
4446 let DecoderMethod = "DecodeCopMemInstruction";
4448 def _POST: ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4449 postidx_imm8s4:$offset),
4450 asm, "\t$cop, $CRd, $addr, $offset", IndexModePost> {
4455 let Inst{24} = 0; // P = 0
4456 let Inst{23} = offset{8};
4457 let Inst{22} = Dbit;
4458 let Inst{21} = 1; // W = 1
4459 let Inst{20} = load;
4460 let Inst{19-16} = addr;
4461 let Inst{15-12} = CRd;
4462 let Inst{11-8} = cop;
4463 let Inst{7-0} = offset{7-0};
4464 let DecoderMethod = "DecodeCopMemInstruction";
4466 def _OPTION : ACInoP<(outs),
4467 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4468 coproc_option_imm:$option),
4469 asm, "\t$cop, $CRd, $addr, $option"> {
4474 let Inst{24} = 0; // P = 0
4475 let Inst{23} = 1; // U = 1
4476 let Inst{22} = Dbit;
4477 let Inst{21} = 0; // W = 0
4478 let Inst{20} = load;
4479 let Inst{19-16} = addr;
4480 let Inst{15-12} = CRd;
4481 let Inst{11-8} = cop;
4482 let Inst{7-0} = option;
4483 let DecoderMethod = "DecodeCopMemInstruction";
4487 defm LDC : LdStCop <1, 0, "ldc">;
4488 defm LDCL : LdStCop <1, 1, "ldcl">;
4489 defm STC : LdStCop <0, 0, "stc">;
4490 defm STCL : LdStCop <0, 1, "stcl">;
4491 defm LDC2 : LdSt2Cop<1, 0, "ldc2">;
4492 defm LDC2L : LdSt2Cop<1, 1, "ldc2l">;
4493 defm STC2 : LdSt2Cop<0, 0, "stc2">;
4494 defm STC2L : LdSt2Cop<0, 1, "stc2l">;
4496 //===----------------------------------------------------------------------===//
4497 // Move between coprocessor and ARM core register.
4500 class MovRCopro<string opc, bit direction, dag oops, dag iops,
4502 : ABI<0b1110, oops, iops, NoItinerary, opc,
4503 "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2", pattern> {
4504 let Inst{20} = direction;
4514 let Inst{15-12} = Rt;
4515 let Inst{11-8} = cop;
4516 let Inst{23-21} = opc1;
4517 let Inst{7-5} = opc2;
4518 let Inst{3-0} = CRm;
4519 let Inst{19-16} = CRn;
4522 def MCR : MovRCopro<"mcr", 0 /* from ARM core register to coprocessor */,
4524 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4525 c_imm:$CRm, imm0_7:$opc2),
4526 [(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
4527 imm:$CRm, imm:$opc2)]>;
4528 def : ARMInstAlias<"mcr${p} $cop, $opc1, $Rt, $CRn, $CRm",
4529 (MCR p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4530 c_imm:$CRm, 0, pred:$p)>;
4531 def MRC : MovRCopro<"mrc", 1 /* from coprocessor to ARM core register */,
4533 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
4535 def : ARMInstAlias<"mrc${p} $cop, $opc1, $Rt, $CRn, $CRm",
4536 (MRC GPR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
4537 c_imm:$CRm, 0, pred:$p)>;
4539 def : ARMPat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
4540 (MRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
4542 class MovRCopro2<string opc, bit direction, dag oops, dag iops,
4544 : ABXI<0b1110, oops, iops, NoItinerary,
4545 !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), pattern> {
4546 let Inst{31-28} = 0b1111;
4547 let Inst{20} = direction;
4557 let Inst{15-12} = Rt;
4558 let Inst{11-8} = cop;
4559 let Inst{23-21} = opc1;
4560 let Inst{7-5} = opc2;
4561 let Inst{3-0} = CRm;
4562 let Inst{19-16} = CRn;
4565 def MCR2 : MovRCopro2<"mcr2", 0 /* from ARM core register to coprocessor */,
4567 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4568 c_imm:$CRm, imm0_7:$opc2),
4569 [(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
4570 imm:$CRm, imm:$opc2)]>;
4571 def : ARMInstAlias<"mcr2$ $cop, $opc1, $Rt, $CRn, $CRm",
4572 (MCR2 p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4574 def MRC2 : MovRCopro2<"mrc2", 1 /* from coprocessor to ARM core register */,
4576 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
4578 def : ARMInstAlias<"mrc2$ $cop, $opc1, $Rt, $CRn, $CRm",
4579 (MRC2 GPR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
4582 def : ARMV5TPat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn,
4583 imm:$CRm, imm:$opc2),
4584 (MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
4586 class MovRRCopro<string opc, bit direction, list<dag> pattern = []>
4587 : ABI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4588 GPR:$Rt, GPR:$Rt2, c_imm:$CRm),
4589 NoItinerary, opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm", pattern> {
4590 let Inst{23-21} = 0b010;
4591 let Inst{20} = direction;
4599 let Inst{15-12} = Rt;
4600 let Inst{19-16} = Rt2;
4601 let Inst{11-8} = cop;
4602 let Inst{7-4} = opc1;
4603 let Inst{3-0} = CRm;
4606 def MCRR : MovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */,
4607 [(int_arm_mcrr imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2,
4609 def MRRC : MovRRCopro<"mrrc", 1 /* from coprocessor to ARM core register */>;
4611 class MovRRCopro2<string opc, bit direction, list<dag> pattern = []>
4612 : ABXI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4613 GPR:$Rt, GPR:$Rt2, c_imm:$CRm), NoItinerary,
4614 !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern> {
4615 let Inst{31-28} = 0b1111;
4616 let Inst{23-21} = 0b010;
4617 let Inst{20} = direction;
4625 let Inst{15-12} = Rt;
4626 let Inst{19-16} = Rt2;
4627 let Inst{11-8} = cop;
4628 let Inst{7-4} = opc1;
4629 let Inst{3-0} = CRm;
4632 def MCRR2 : MovRRCopro2<"mcrr2", 0 /* from ARM core register to coprocessor */,
4633 [(int_arm_mcrr2 imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2,
4635 def MRRC2 : MovRRCopro2<"mrrc2", 1 /* from coprocessor to ARM core register */>;
4637 //===----------------------------------------------------------------------===//
4638 // Move between special register and ARM core register
4641 // Move to ARM core register from Special Register
4642 def MRS : ABI<0b0001, (outs GPR:$Rd), (ins), NoItinerary,
4643 "mrs", "\t$Rd, apsr", []> {
4645 let Inst{23-16} = 0b00001111;
4646 let Inst{15-12} = Rd;
4647 let Inst{7-4} = 0b0000;
4650 def : InstAlias<"mrs${p} $Rd, cpsr", (MRS GPR:$Rd, pred:$p)>, Requires<[IsARM]>;
4652 def MRSsys : ABI<0b0001, (outs GPR:$Rd), (ins), NoItinerary,
4653 "mrs", "\t$Rd, spsr", []> {
4655 let Inst{23-16} = 0b01001111;
4656 let Inst{15-12} = Rd;
4657 let Inst{7-4} = 0b0000;
4660 // Move from ARM core register to Special Register
4662 // No need to have both system and application versions, the encodings are the
4663 // same and the assembly parser has no way to distinguish between them. The mask
4664 // operand contains the special register (R Bit) in bit 4 and bits 3-0 contains
4665 // the mask with the fields to be accessed in the special register.
4666 def MSR : ABI<0b0001, (outs), (ins msr_mask:$mask, GPR:$Rn), NoItinerary,
4667 "msr", "\t$mask, $Rn", []> {
4672 let Inst{22} = mask{4}; // R bit
4673 let Inst{21-20} = 0b10;
4674 let Inst{19-16} = mask{3-0};
4675 let Inst{15-12} = 0b1111;
4676 let Inst{11-4} = 0b00000000;
4680 def MSRi : ABI<0b0011, (outs), (ins msr_mask:$mask, so_imm:$a), NoItinerary,
4681 "msr", "\t$mask, $a", []> {
4686 let Inst{22} = mask{4}; // R bit
4687 let Inst{21-20} = 0b10;
4688 let Inst{19-16} = mask{3-0};
4689 let Inst{15-12} = 0b1111;
4693 //===----------------------------------------------------------------------===//
4697 // __aeabi_read_tp preserves the registers r1-r3.
4698 // This is a pseudo inst so that we can get the encoding right,
4699 // complete with fixup for the aeabi_read_tp function.
4701 Defs = [R0, R12, LR, CPSR], Uses = [SP] in {
4702 def TPsoft : PseudoInst<(outs), (ins), IIC_Br,
4703 [(set R0, ARMthread_pointer)]>;
4706 //===----------------------------------------------------------------------===//
4707 // SJLJ Exception handling intrinsics
4708 // eh_sjlj_setjmp() is an instruction sequence to store the return
4709 // address and save #0 in R0 for the non-longjmp case.
4710 // Since by its nature we may be coming from some other function to get
4711 // here, and we're using the stack frame for the containing function to
4712 // save/restore registers, we can't keep anything live in regs across
4713 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
4714 // when we get here from a longjmp(). We force everything out of registers
4715 // except for our own input by listing the relevant registers in Defs. By
4716 // doing so, we also cause the prologue/epilogue code to actively preserve
4717 // all of the callee-saved resgisters, which is exactly what we want.
4718 // A constant value is passed in $val, and we use the location as a scratch.
4720 // These are pseudo-instructions and are lowered to individual MC-insts, so
4721 // no encoding information is necessary.
4723 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
4724 Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15 ],
4725 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
4726 def Int_eh_sjlj_setjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
4728 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
4729 Requires<[IsARM, HasVFP2]>;
4733 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
4734 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
4735 def Int_eh_sjlj_setjmp_nofp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
4737 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
4738 Requires<[IsARM, NoVFP]>;
4741 // FIXME: Non-IOS version(s)
4742 let isBarrier = 1, hasSideEffects = 1, isTerminator = 1,
4743 Defs = [ R7, LR, SP ] in {
4744 def Int_eh_sjlj_longjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$scratch),
4746 [(ARMeh_sjlj_longjmp GPR:$src, GPR:$scratch)]>,
4747 Requires<[IsARM, IsIOS]>;
4750 // eh.sjlj.dispatchsetup pseudo-instructions.
4751 // These pseudos are used for both ARM and Thumb2. Any differences are
4752 // handled when the pseudo is expanded (which happens before any passes
4753 // that need the instruction size).
4755 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
4756 Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15 ],
4758 def Int_eh_sjlj_dispatchsetup : PseudoInst<(outs), (ins), NoItinerary, []>;
4761 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
4763 def Int_eh_sjlj_dispatchsetup_nofp : PseudoInst<(outs), (ins), NoItinerary, []>;
4766 //===----------------------------------------------------------------------===//
4767 // Non-Instruction Patterns
4770 // ARMv4 indirect branch using (MOVr PC, dst)
4771 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in
4772 def MOVPCRX : ARMPseudoExpand<(outs), (ins GPR:$dst),
4773 4, IIC_Br, [(brind GPR:$dst)],
4774 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>,
4775 Requires<[IsARM, NoV4T]>;
4777 // Large immediate handling.
4779 // 32-bit immediate using two piece so_imms or movw + movt.
4780 // This is a single pseudo instruction, the benefit is that it can be remat'd
4781 // as a single unit instead of having to handle reg inputs.
4782 // FIXME: Remove this when we can do generalized remat.
4783 let isReMaterializable = 1, isMoveImm = 1 in
4784 def MOVi32imm : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
4785 [(set GPR:$dst, (arm_i32imm:$src))]>,
4788 // Pseudo instruction that combines movw + movt + add pc (if PIC).
4789 // It also makes it possible to rematerialize the instructions.
4790 // FIXME: Remove this when we can do generalized remat and when machine licm
4791 // can properly the instructions.
4792 let isReMaterializable = 1 in {
4793 def MOV_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
4795 [(set GPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>,
4796 Requires<[IsARM, UseMovt]>;
4798 def MOV_ga_dyn : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
4800 [(set GPR:$dst, (ARMWrapperDYN tglobaladdr:$addr))]>,
4801 Requires<[IsARM, UseMovt]>;
4803 let AddedComplexity = 10 in
4804 def MOV_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
4806 [(set GPR:$dst, (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
4807 Requires<[IsARM, UseMovt]>;
4808 } // isReMaterializable
4810 // ConstantPool, GlobalAddress, and JumpTable
4811 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (LEApcrel tglobaladdr :$dst)>,
4812 Requires<[IsARM, DontUseMovt]>;
4813 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
4814 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
4815 Requires<[IsARM, UseMovt]>;
4816 def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
4817 (LEApcrelJT tjumptable:$dst, imm:$id)>;
4819 // TODO: add,sub,and, 3-instr forms?
4821 // Tail calls. These patterns also apply to Thumb mode.
4822 def : Pat<(ARMtcret tcGPR:$dst), (TCRETURNri tcGPR:$dst)>;
4823 def : Pat<(ARMtcret (i32 tglobaladdr:$dst)), (TCRETURNdi texternalsym:$dst)>;
4824 def : Pat<(ARMtcret (i32 texternalsym:$dst)), (TCRETURNdi texternalsym:$dst)>;
4827 def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>;
4828 def : ARMPat<(ARMcall_nolink texternalsym:$func),
4829 (BMOVPCB_CALL texternalsym:$func)>;
4831 // zextload i1 -> zextload i8
4832 def : ARMPat<(zextloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
4833 def : ARMPat<(zextloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
4835 // extload -> zextload
4836 def : ARMPat<(extloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
4837 def : ARMPat<(extloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
4838 def : ARMPat<(extloadi8 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
4839 def : ARMPat<(extloadi8 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
4841 def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
4843 def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
4844 def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
4847 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4848 (sra (shl GPR:$b, (i32 16)), (i32 16))),
4849 (SMULBB GPR:$a, GPR:$b)>;
4850 def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
4851 (SMULBB GPR:$a, GPR:$b)>;
4852 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4853 (sra GPR:$b, (i32 16))),
4854 (SMULBT GPR:$a, GPR:$b)>;
4855 def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, (i32 16))),
4856 (SMULBT GPR:$a, GPR:$b)>;
4857 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)),
4858 (sra (shl GPR:$b, (i32 16)), (i32 16))),
4859 (SMULTB GPR:$a, GPR:$b)>;
4860 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), sext_16_node:$b),
4861 (SMULTB GPR:$a, GPR:$b)>;
4862 def : ARMV5TEPat<(sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
4864 (SMULWB GPR:$a, GPR:$b)>;
4865 def : ARMV5TEPat<(sra (mul GPR:$a, sext_16_node:$b), (i32 16)),
4866 (SMULWB GPR:$a, GPR:$b)>;
4868 def : ARMV5TEPat<(add GPR:$acc,
4869 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4870 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
4871 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
4872 def : ARMV5TEPat<(add GPR:$acc,
4873 (mul sext_16_node:$a, sext_16_node:$b)),
4874 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
4875 def : ARMV5TEPat<(add GPR:$acc,
4876 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4877 (sra GPR:$b, (i32 16)))),
4878 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
4879 def : ARMV5TEPat<(add GPR:$acc,
4880 (mul sext_16_node:$a, (sra GPR:$b, (i32 16)))),
4881 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
4882 def : ARMV5TEPat<(add GPR:$acc,
4883 (mul (sra GPR:$a, (i32 16)),
4884 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
4885 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
4886 def : ARMV5TEPat<(add GPR:$acc,
4887 (mul (sra GPR:$a, (i32 16)), sext_16_node:$b)),
4888 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
4889 def : ARMV5TEPat<(add GPR:$acc,
4890 (sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
4892 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
4893 def : ARMV5TEPat<(add GPR:$acc,
4894 (sra (mul GPR:$a, sext_16_node:$b), (i32 16))),
4895 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
4898 // Pre-v7 uses MCR for synchronization barriers.
4899 def : ARMPat<(ARMMemBarrierMCR GPR:$zero), (MCR 15, 0, GPR:$zero, 7, 10, 5)>,
4900 Requires<[IsARM, HasV6]>;
4902 // SXT/UXT with no rotate
4903 let AddedComplexity = 16 in {
4904 def : ARMV6Pat<(and GPR:$Src, 0x000000FF), (UXTB GPR:$Src, 0)>;
4905 def : ARMV6Pat<(and GPR:$Src, 0x0000FFFF), (UXTH GPR:$Src, 0)>;
4906 def : ARMV6Pat<(and GPR:$Src, 0x00FF00FF), (UXTB16 GPR:$Src, 0)>;
4907 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0x00FF)),
4908 (UXTAB GPR:$Rn, GPR:$Rm, 0)>;
4909 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0xFFFF)),
4910 (UXTAH GPR:$Rn, GPR:$Rm, 0)>;
4913 def : ARMV6Pat<(sext_inreg GPR:$Src, i8), (SXTB GPR:$Src, 0)>;
4914 def : ARMV6Pat<(sext_inreg GPR:$Src, i16), (SXTH GPR:$Src, 0)>;
4916 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i8)),
4917 (SXTAB GPR:$Rn, GPRnopc:$Rm, 0)>;
4918 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i16)),
4919 (SXTAH GPR:$Rn, GPRnopc:$Rm, 0)>;
4921 // Atomic load/store patterns
4922 def : ARMPat<(atomic_load_8 ldst_so_reg:$src),
4923 (LDRBrs ldst_so_reg:$src)>;
4924 def : ARMPat<(atomic_load_8 addrmode_imm12:$src),
4925 (LDRBi12 addrmode_imm12:$src)>;
4926 def : ARMPat<(atomic_load_16 addrmode3:$src),
4927 (LDRH addrmode3:$src)>;
4928 def : ARMPat<(atomic_load_32 ldst_so_reg:$src),
4929 (LDRrs ldst_so_reg:$src)>;
4930 def : ARMPat<(atomic_load_32 addrmode_imm12:$src),
4931 (LDRi12 addrmode_imm12:$src)>;
4932 def : ARMPat<(atomic_store_8 ldst_so_reg:$ptr, GPR:$val),
4933 (STRBrs GPR:$val, ldst_so_reg:$ptr)>;
4934 def : ARMPat<(atomic_store_8 addrmode_imm12:$ptr, GPR:$val),
4935 (STRBi12 GPR:$val, addrmode_imm12:$ptr)>;
4936 def : ARMPat<(atomic_store_16 addrmode3:$ptr, GPR:$val),
4937 (STRH GPR:$val, addrmode3:$ptr)>;
4938 def : ARMPat<(atomic_store_32 ldst_so_reg:$ptr, GPR:$val),
4939 (STRrs GPR:$val, ldst_so_reg:$ptr)>;
4940 def : ARMPat<(atomic_store_32 addrmode_imm12:$ptr, GPR:$val),
4941 (STRi12 GPR:$val, addrmode_imm12:$ptr)>;
4944 //===----------------------------------------------------------------------===//
4948 include "ARMInstrThumb.td"
4950 //===----------------------------------------------------------------------===//
4954 include "ARMInstrThumb2.td"
4956 //===----------------------------------------------------------------------===//
4957 // Floating Point Support
4960 include "ARMInstrVFP.td"
4962 //===----------------------------------------------------------------------===//
4963 // Advanced SIMD (NEON) Support
4966 include "ARMInstrNEON.td"
4968 //===----------------------------------------------------------------------===//
4969 // Assembler aliases
4973 def : InstAlias<"dmb", (DMB 0xf)>, Requires<[IsARM, HasDB]>;
4974 def : InstAlias<"dsb", (DSB 0xf)>, Requires<[IsARM, HasDB]>;
4975 def : InstAlias<"isb", (ISB 0xf)>, Requires<[IsARM, HasDB]>;
4977 // System instructions
4978 def : MnemonicAlias<"swi", "svc">;
4980 // Load / Store Multiple
4981 def : MnemonicAlias<"ldmfd", "ldm">;
4982 def : MnemonicAlias<"ldmia", "ldm">;
4983 def : MnemonicAlias<"ldmea", "ldmdb">;
4984 def : MnemonicAlias<"stmfd", "stmdb">;
4985 def : MnemonicAlias<"stmia", "stm">;
4986 def : MnemonicAlias<"stmea", "stm">;
4988 // PKHBT/PKHTB with default shift amount. PKHTB is equivalent to PKHBT when the
4989 // shift amount is zero (i.e., unspecified).
4990 def : InstAlias<"pkhbt${p} $Rd, $Rn, $Rm",
4991 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
4992 Requires<[IsARM, HasV6]>;
4993 def : InstAlias<"pkhtb${p} $Rd, $Rn, $Rm",
4994 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
4995 Requires<[IsARM, HasV6]>;
4997 // PUSH/POP aliases for STM/LDM
4998 def : ARMInstAlias<"push${p} $regs", (STMDB_UPD SP, pred:$p, reglist:$regs)>;
4999 def : ARMInstAlias<"pop${p} $regs", (LDMIA_UPD SP, pred:$p, reglist:$regs)>;
5001 // SSAT/USAT optional shift operand.
5002 def : ARMInstAlias<"ssat${p} $Rd, $sat_imm, $Rn",
5003 (SSAT GPRnopc:$Rd, imm1_32:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5004 def : ARMInstAlias<"usat${p} $Rd, $sat_imm, $Rn",
5005 (USAT GPRnopc:$Rd, imm0_31:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5008 // Extend instruction optional rotate operand.
5009 def : ARMInstAlias<"sxtab${p} $Rd, $Rn, $Rm",
5010 (SXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5011 def : ARMInstAlias<"sxtah${p} $Rd, $Rn, $Rm",
5012 (SXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5013 def : ARMInstAlias<"sxtab16${p} $Rd, $Rn, $Rm",
5014 (SXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5015 def : ARMInstAlias<"sxtb${p} $Rd, $Rm",
5016 (SXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5017 def : ARMInstAlias<"sxtb16${p} $Rd, $Rm",
5018 (SXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5019 def : ARMInstAlias<"sxth${p} $Rd, $Rm",
5020 (SXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5022 def : ARMInstAlias<"uxtab${p} $Rd, $Rn, $Rm",
5023 (UXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5024 def : ARMInstAlias<"uxtah${p} $Rd, $Rn, $Rm",
5025 (UXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5026 def : ARMInstAlias<"uxtab16${p} $Rd, $Rn, $Rm",
5027 (UXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5028 def : ARMInstAlias<"uxtb${p} $Rd, $Rm",
5029 (UXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5030 def : ARMInstAlias<"uxtb16${p} $Rd, $Rm",
5031 (UXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5032 def : ARMInstAlias<"uxth${p} $Rd, $Rm",
5033 (UXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5037 def : MnemonicAlias<"rfefa", "rfeda">;
5038 def : MnemonicAlias<"rfeea", "rfedb">;
5039 def : MnemonicAlias<"rfefd", "rfeia">;
5040 def : MnemonicAlias<"rfeed", "rfeib">;
5041 def : MnemonicAlias<"rfe", "rfeia">;
5044 def : MnemonicAlias<"srsfa", "srsda">;
5045 def : MnemonicAlias<"srsea", "srsdb">;
5046 def : MnemonicAlias<"srsfd", "srsia">;
5047 def : MnemonicAlias<"srsed", "srsib">;
5048 def : MnemonicAlias<"srs", "srsia">;
5051 def : MnemonicAlias<"qsubaddx", "qsax">;
5053 def : MnemonicAlias<"saddsubx", "sasx">;
5054 // SHASX == SHADDSUBX
5055 def : MnemonicAlias<"shaddsubx", "shasx">;
5056 // SHSAX == SHSUBADDX
5057 def : MnemonicAlias<"shsubaddx", "shsax">;
5059 def : MnemonicAlias<"ssubaddx", "ssax">;
5061 def : MnemonicAlias<"uaddsubx", "uasx">;
5062 // UHASX == UHADDSUBX
5063 def : MnemonicAlias<"uhaddsubx", "uhasx">;
5064 // UHSAX == UHSUBADDX
5065 def : MnemonicAlias<"uhsubaddx", "uhsax">;
5066 // UQASX == UQADDSUBX
5067 def : MnemonicAlias<"uqaddsubx", "uqasx">;
5068 // UQSAX == UQSUBADDX
5069 def : MnemonicAlias<"uqsubaddx", "uqsax">;
5071 def : MnemonicAlias<"usubaddx", "usax">;
5073 // "mov Rd, so_imm_not" can be handled via "mvn" in assembly, just like
5075 def : ARMInstAlias<"mov${s}${p} $Rd, $imm",
5076 (MVNi rGPR:$Rd, so_imm_not:$imm, pred:$p, cc_out:$s)>;
5077 def : ARMInstAlias<"mvn${s}${p} $Rd, $imm",
5078 (MOVi rGPR:$Rd, so_imm_not:$imm, pred:$p, cc_out:$s)>;
5079 // Same for AND <--> BIC
5080 def : ARMInstAlias<"bic${s}${p} $Rd, $Rn, $imm",
5081 (ANDri rGPR:$Rd, rGPR:$Rn, so_imm_not:$imm,
5082 pred:$p, cc_out:$s)>;
5083 def : ARMInstAlias<"bic${s}${p} $Rdn, $imm",
5084 (ANDri rGPR:$Rdn, rGPR:$Rdn, so_imm_not:$imm,
5085 pred:$p, cc_out:$s)>;
5086 def : ARMInstAlias<"and${s}${p} $Rd, $Rn, $imm",
5087 (BICri rGPR:$Rd, rGPR:$Rn, so_imm_not:$imm,
5088 pred:$p, cc_out:$s)>;
5089 def : ARMInstAlias<"and${s}${p} $Rdn, $imm",
5090 (BICri rGPR:$Rdn, rGPR:$Rdn, so_imm_not:$imm,
5091 pred:$p, cc_out:$s)>;
5093 // Likewise, "add Rd, so_imm_neg" -> sub
5094 def : ARMInstAlias<"add${s}${p} $Rd, $Rn, $imm",
5095 (SUBri GPR:$Rd, GPR:$Rn, so_imm_neg:$imm, pred:$p, cc_out:$s)>;
5096 def : ARMInstAlias<"add${s}${p} $Rd, $imm",
5097 (SUBri GPR:$Rd, GPR:$Rd, so_imm_neg:$imm, pred:$p, cc_out:$s)>;
5098 // Same for CMP <--> CMN via so_imm_neg
5099 def : ARMInstAlias<"cmp${p} $Rd, $imm",
5100 (CMNzri rGPR:$Rd, so_imm_neg:$imm, pred:$p)>;
5101 def : ARMInstAlias<"cmn${p} $Rd, $imm",
5102 (CMPri rGPR:$Rd, so_imm_neg:$imm, pred:$p)>;
5104 // The shifter forms of the MOV instruction are aliased to the ASR, LSL,
5105 // LSR, ROR, and RRX instructions.
5106 // FIXME: We need C++ parser hooks to map the alias to the MOV
5107 // encoding. It seems we should be able to do that sort of thing
5108 // in tblgen, but it could get ugly.
5109 def ASRi : ARMAsmPseudo<"asr${s}${p} $Rd, $Rm, $imm",
5110 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
5112 def LSRi : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rm, $imm",
5113 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
5115 def LSLi : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rm, $imm",
5116 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
5118 def RORi : ARMAsmPseudo<"ror${s}${p} $Rd, $Rm, $imm",
5119 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
5121 def RRXi : ARMAsmPseudo<"rrx${s}${p} $Rd, $Rm",
5122 (ins GPRnopc:$Rd, GPRnopc:$Rm, pred:$p, cc_out:$s)>;
5123 def ASRr : ARMAsmPseudo<"asr${s}${p} $Rd, $Rn, $Rm",
5124 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5126 def LSRr : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rn, $Rm",
5127 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5129 def LSLr : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rn, $Rm",
5130 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5132 def RORr : ARMAsmPseudo<"ror${s}${p} $Rd, $Rn, $Rm",
5133 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5135 // shifter instructions also support a two-operand form.
5136 def : ARMInstAlias<"asr${s}${p} $Rm, $imm",
5137 (ASRi GPR:$Rm, GPR:$Rm, imm0_32:$imm, pred:$p, cc_out:$s)>;
5138 def : ARMInstAlias<"lsr${s}${p} $Rm, $imm",
5139 (LSRi GPR:$Rm, GPR:$Rm, imm0_32:$imm, pred:$p, cc_out:$s)>;
5140 def : ARMInstAlias<"lsl${s}${p} $Rm, $imm",
5141 (LSLi GPR:$Rm, GPR:$Rm, imm0_31:$imm, pred:$p, cc_out:$s)>;
5142 def : ARMInstAlias<"ror${s}${p} $Rm, $imm",
5143 (RORi GPR:$Rm, GPR:$Rm, imm0_31:$imm, pred:$p, cc_out:$s)>;
5144 def : ARMInstAlias<"asr${s}${p} $Rn, $Rm",
5145 (ASRr GPRnopc:$Rn, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5147 def : ARMInstAlias<"lsr${s}${p} $Rn, $Rm",
5148 (LSRr GPRnopc:$Rn, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5150 def : ARMInstAlias<"lsl${s}${p} $Rn, $Rm",
5151 (LSLr GPRnopc:$Rn, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5153 def : ARMInstAlias<"ror${s}${p} $Rn, $Rm",
5154 (RORr GPRnopc:$Rn, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5158 // 'mul' instruction can be specified with only two operands.
5159 def : ARMInstAlias<"mul${s}${p} $Rn, $Rm",
5160 (MUL rGPR:$Rn, rGPR:$Rm, rGPR:$Rn, pred:$p, cc_out:$s)>;
5162 // "neg" is and alias for "rsb rd, rn, #0"
5163 def : ARMInstAlias<"neg${s}${p} $Rd, $Rm",
5164 (RSBri GPR:$Rd, GPR:$Rm, 0, pred:$p, cc_out:$s)>;
5166 // Pre-v6, 'mov r0, r0' was used as a NOP encoding.
5167 def : InstAlias<"nop${p}", (MOVr R0, R0, pred:$p, zero_reg)>,
5168 Requires<[IsARM, NoV6]>;
5170 // UMULL/SMULL are available on all arches, but the instruction definitions
5171 // need difference constraints pre-v6. Use these aliases for the assembly
5172 // parsing on pre-v6.
5173 def : InstAlias<"smull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5174 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5175 Requires<[IsARM, NoV6]>;
5176 def : InstAlias<"umull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5177 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5178 Requires<[IsARM, NoV6]>;
5180 // 'it' blocks in ARM mode just validate the predicates. The IT itself
5182 def ITasm : ARMAsmPseudo<"it$mask $cc", (ins it_pred:$cc, it_mask:$mask)>;