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_ARMEH_SJLJ_DispatchSetup: SDTypeProfile<0, 1, [SDTCisInt<0>]>;
63 def SDT_ARMMEMBARRIER : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
65 def SDT_ARMPREFETCH : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisSameAs<1, 2>,
68 def SDT_ARMTCRET : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
70 def SDT_ARMBFI : SDTypeProfile<1, 3, [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
71 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
74 def ARMWrapper : SDNode<"ARMISD::Wrapper", SDTIntUnaryOp>;
75 def ARMWrapperDYN : SDNode<"ARMISD::WrapperDYN", SDTIntUnaryOp>;
76 def ARMWrapperPIC : SDNode<"ARMISD::WrapperPIC", SDTIntUnaryOp>;
77 def ARMWrapperJT : SDNode<"ARMISD::WrapperJT", SDTIntBinOp>;
79 def ARMcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_ARMCallSeqStart,
80 [SDNPHasChain, SDNPOutGlue]>;
81 def ARMcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_ARMCallSeqEnd,
82 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
84 def ARMcall : SDNode<"ARMISD::CALL", SDT_ARMcall,
85 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
87 def ARMcall_pred : SDNode<"ARMISD::CALL_PRED", SDT_ARMcall,
88 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
90 def ARMcall_nolink : SDNode<"ARMISD::CALL_NOLINK", SDT_ARMcall,
91 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
94 def ARMretflag : SDNode<"ARMISD::RET_FLAG", SDTNone,
95 [SDNPHasChain, SDNPOptInGlue]>;
97 def ARMcmov : SDNode<"ARMISD::CMOV", SDT_ARMCMov,
100 def ARMbrcond : SDNode<"ARMISD::BRCOND", SDT_ARMBrcond,
101 [SDNPHasChain, SDNPInGlue, SDNPOutGlue]>;
103 def ARMbrjt : SDNode<"ARMISD::BR_JT", SDT_ARMBrJT,
105 def ARMbr2jt : SDNode<"ARMISD::BR2_JT", SDT_ARMBr2JT,
108 def ARMBcci64 : SDNode<"ARMISD::BCC_i64", SDT_ARMBCC_i64,
111 def ARMcmp : SDNode<"ARMISD::CMP", SDT_ARMCmp,
114 def ARMcmpZ : SDNode<"ARMISD::CMPZ", SDT_ARMCmp,
115 [SDNPOutGlue, SDNPCommutative]>;
117 def ARMpic_add : SDNode<"ARMISD::PIC_ADD", SDT_ARMPICAdd>;
119 def ARMsrl_flag : SDNode<"ARMISD::SRL_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
120 def ARMsra_flag : SDNode<"ARMISD::SRA_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
121 def ARMrrx : SDNode<"ARMISD::RRX" , SDTIntUnaryOp, [SDNPInGlue ]>;
123 def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>;
124 def ARMeh_sjlj_setjmp: SDNode<"ARMISD::EH_SJLJ_SETJMP",
125 SDT_ARMEH_SJLJ_Setjmp, [SDNPHasChain]>;
126 def ARMeh_sjlj_longjmp: SDNode<"ARMISD::EH_SJLJ_LONGJMP",
127 SDT_ARMEH_SJLJ_Longjmp, [SDNPHasChain]>;
128 def ARMeh_sjlj_dispatchsetup: SDNode<"ARMISD::EH_SJLJ_DISPATCHSETUP",
129 SDT_ARMEH_SJLJ_DispatchSetup, [SDNPHasChain]>;
132 def ARMMemBarrier : SDNode<"ARMISD::MEMBARRIER", SDT_ARMMEMBARRIER,
134 def ARMMemBarrierMCR : SDNode<"ARMISD::MEMBARRIER_MCR", SDT_ARMMEMBARRIER,
136 def ARMPreload : SDNode<"ARMISD::PRELOAD", SDT_ARMPREFETCH,
137 [SDNPHasChain, SDNPMayLoad, SDNPMayStore]>;
139 def ARMrbit : SDNode<"ARMISD::RBIT", SDTIntUnaryOp>;
141 def ARMtcret : SDNode<"ARMISD::TC_RETURN", SDT_ARMTCRET,
142 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
145 def ARMbfi : SDNode<"ARMISD::BFI", SDT_ARMBFI>;
147 //===----------------------------------------------------------------------===//
148 // ARM Instruction Predicate Definitions.
150 def HasV4T : Predicate<"Subtarget->hasV4TOps()">,
151 AssemblerPredicate<"HasV4TOps">;
152 def NoV4T : Predicate<"!Subtarget->hasV4TOps()">;
153 def HasV5T : Predicate<"Subtarget->hasV5TOps()">;
154 def HasV5TE : Predicate<"Subtarget->hasV5TEOps()">,
155 AssemblerPredicate<"HasV5TEOps">;
156 def HasV6 : Predicate<"Subtarget->hasV6Ops()">,
157 AssemblerPredicate<"HasV6Ops">;
158 def NoV6 : Predicate<"!Subtarget->hasV6Ops()">;
159 def HasV6T2 : Predicate<"Subtarget->hasV6T2Ops()">,
160 AssemblerPredicate<"HasV6T2Ops">;
161 def NoV6T2 : Predicate<"!Subtarget->hasV6T2Ops()">;
162 def HasV7 : Predicate<"Subtarget->hasV7Ops()">,
163 AssemblerPredicate<"HasV7Ops">;
164 def NoVFP : Predicate<"!Subtarget->hasVFP2()">;
165 def HasVFP2 : Predicate<"Subtarget->hasVFP2()">,
166 AssemblerPredicate<"FeatureVFP2">;
167 def HasVFP3 : Predicate<"Subtarget->hasVFP3()">,
168 AssemblerPredicate<"FeatureVFP3">;
169 def HasNEON : Predicate<"Subtarget->hasNEON()">,
170 AssemblerPredicate<"FeatureNEON">;
171 def HasFP16 : Predicate<"Subtarget->hasFP16()">,
172 AssemblerPredicate<"FeatureFP16">;
173 def HasDivide : Predicate<"Subtarget->hasDivide()">,
174 AssemblerPredicate<"FeatureHWDiv">;
175 def HasT2ExtractPack : Predicate<"Subtarget->hasT2ExtractPack()">,
176 AssemblerPredicate<"FeatureT2XtPk">;
177 def HasThumb2DSP : Predicate<"Subtarget->hasThumb2DSP()">,
178 AssemblerPredicate<"FeatureDSPThumb2">;
179 def HasDB : Predicate<"Subtarget->hasDataBarrier()">,
180 AssemblerPredicate<"FeatureDB">;
181 def HasMP : Predicate<"Subtarget->hasMPExtension()">,
182 AssemblerPredicate<"FeatureMP">;
183 def UseNEONForFP : Predicate<"Subtarget->useNEONForSinglePrecisionFP()">;
184 def DontUseNEONForFP : Predicate<"!Subtarget->useNEONForSinglePrecisionFP()">;
185 def IsThumb : Predicate<"Subtarget->isThumb()">,
186 AssemblerPredicate<"ModeThumb">;
187 def IsThumb1Only : Predicate<"Subtarget->isThumb1Only()">;
188 def IsThumb2 : Predicate<"Subtarget->isThumb2()">,
189 AssemblerPredicate<"ModeThumb,FeatureThumb2">;
190 def IsARM : Predicate<"!Subtarget->isThumb()">,
191 AssemblerPredicate<"!ModeThumb">;
192 def IsDarwin : Predicate<"Subtarget->isTargetDarwin()">;
193 def IsNotDarwin : Predicate<"!Subtarget->isTargetDarwin()">;
195 // FIXME: Eventually this will be just "hasV6T2Ops".
196 def UseMovt : Predicate<"Subtarget->useMovt()">;
197 def DontUseMovt : Predicate<"!Subtarget->useMovt()">;
198 def UseFPVMLx : Predicate<"Subtarget->useFPVMLx()">;
200 //===----------------------------------------------------------------------===//
201 // ARM Flag Definitions.
203 class RegConstraint<string C> {
204 string Constraints = C;
207 //===----------------------------------------------------------------------===//
208 // ARM specific transformation functions and pattern fragments.
211 // so_imm_neg_XFORM - Return a so_imm value packed into the format described for
212 // so_imm_neg def below.
213 def so_imm_neg_XFORM : SDNodeXForm<imm, [{
214 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), MVT::i32);
217 // so_imm_not_XFORM - Return a so_imm value packed into the format described for
218 // so_imm_not def below.
219 def so_imm_not_XFORM : SDNodeXForm<imm, [{
220 return CurDAG->getTargetConstant(~(int)N->getZExtValue(), MVT::i32);
223 /// imm1_15 predicate - True if the 32-bit immediate is in the range [1,15].
224 def imm1_15 : ImmLeaf<i32, [{
225 return (int32_t)Imm >= 1 && (int32_t)Imm < 16;
228 /// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
229 def imm16_31 : ImmLeaf<i32, [{
230 return (int32_t)Imm >= 16 && (int32_t)Imm < 32;
235 return ARM_AM::getSOImmVal(-(uint32_t)N->getZExtValue()) != -1;
236 }], so_imm_neg_XFORM>;
240 return ARM_AM::getSOImmVal(~(uint32_t)N->getZExtValue()) != -1;
241 }], so_imm_not_XFORM>;
243 // sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
244 def sext_16_node : PatLeaf<(i32 GPR:$a), [{
245 return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17;
248 /// Split a 32-bit immediate into two 16 bit parts.
249 def hi16 : SDNodeXForm<imm, [{
250 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, MVT::i32);
253 def lo16AllZero : PatLeaf<(i32 imm), [{
254 // Returns true if all low 16-bits are 0.
255 return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
258 /// imm0_65535 - An immediate is in the range [0.65535].
259 def Imm0_65535AsmOperand: AsmOperandClass { let Name = "Imm0_65535"; }
260 def imm0_65535 : Operand<i32>, ImmLeaf<i32, [{
261 return Imm >= 0 && Imm < 65536;
263 let ParserMatchClass = Imm0_65535AsmOperand;
266 class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
267 class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
269 /// adde and sube predicates - True based on whether the carry flag output
270 /// will be needed or not.
271 def adde_dead_carry :
272 PatFrag<(ops node:$LHS, node:$RHS), (adde node:$LHS, node:$RHS),
273 [{return !N->hasAnyUseOfValue(1);}]>;
274 def sube_dead_carry :
275 PatFrag<(ops node:$LHS, node:$RHS), (sube node:$LHS, node:$RHS),
276 [{return !N->hasAnyUseOfValue(1);}]>;
277 def adde_live_carry :
278 PatFrag<(ops node:$LHS, node:$RHS), (adde node:$LHS, node:$RHS),
279 [{return N->hasAnyUseOfValue(1);}]>;
280 def sube_live_carry :
281 PatFrag<(ops node:$LHS, node:$RHS), (sube node:$LHS, node:$RHS),
282 [{return N->hasAnyUseOfValue(1);}]>;
284 // An 'and' node with a single use.
285 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
286 return N->hasOneUse();
289 // An 'xor' node with a single use.
290 def xor_su : PatFrag<(ops node:$lhs, node:$rhs), (xor node:$lhs, node:$rhs), [{
291 return N->hasOneUse();
294 // An 'fmul' node with a single use.
295 def fmul_su : PatFrag<(ops node:$lhs, node:$rhs), (fmul node:$lhs, node:$rhs),[{
296 return N->hasOneUse();
299 // An 'fadd' node which checks for single non-hazardous use.
300 def fadd_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fadd node:$lhs, node:$rhs),[{
301 return hasNoVMLxHazardUse(N);
304 // An 'fsub' node which checks for single non-hazardous use.
305 def fsub_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fsub node:$lhs, node:$rhs),[{
306 return hasNoVMLxHazardUse(N);
309 //===----------------------------------------------------------------------===//
310 // Operand Definitions.
314 // FIXME: rename brtarget to t2_brtarget
315 def brtarget : Operand<OtherVT> {
316 let EncoderMethod = "getBranchTargetOpValue";
317 let OperandType = "OPERAND_PCREL";
318 let DecoderMethod = "DecodeT2BROperand";
321 // FIXME: get rid of this one?
322 def uncondbrtarget : Operand<OtherVT> {
323 let EncoderMethod = "getUnconditionalBranchTargetOpValue";
324 let OperandType = "OPERAND_PCREL";
327 // Branch target for ARM. Handles conditional/unconditional
328 def br_target : Operand<OtherVT> {
329 let EncoderMethod = "getARMBranchTargetOpValue";
330 let OperandType = "OPERAND_PCREL";
334 // FIXME: rename bltarget to t2_bl_target?
335 def bltarget : Operand<i32> {
336 // Encoded the same as branch targets.
337 let EncoderMethod = "getBranchTargetOpValue";
338 let OperandType = "OPERAND_PCREL";
341 // Call target for ARM. Handles conditional/unconditional
342 // FIXME: rename bl_target to t2_bltarget?
343 def bl_target : Operand<i32> {
344 // Encoded the same as branch targets.
345 let EncoderMethod = "getARMBranchTargetOpValue";
346 let OperandType = "OPERAND_PCREL";
347 let DecoderMethod = "DecodeBLTargetOperand";
351 // A list of registers separated by comma. Used by load/store multiple.
352 def RegListAsmOperand : AsmOperandClass { let Name = "RegList"; }
353 def reglist : Operand<i32> {
354 let EncoderMethod = "getRegisterListOpValue";
355 let ParserMatchClass = RegListAsmOperand;
356 let PrintMethod = "printRegisterList";
357 let DecoderMethod = "DecodeRegListOperand";
360 def DPRRegListAsmOperand : AsmOperandClass { let Name = "DPRRegList"; }
361 def dpr_reglist : Operand<i32> {
362 let EncoderMethod = "getRegisterListOpValue";
363 let ParserMatchClass = DPRRegListAsmOperand;
364 let PrintMethod = "printRegisterList";
365 let DecoderMethod = "DecodeDPRRegListOperand";
368 def SPRRegListAsmOperand : AsmOperandClass { let Name = "SPRRegList"; }
369 def spr_reglist : Operand<i32> {
370 let EncoderMethod = "getRegisterListOpValue";
371 let ParserMatchClass = SPRRegListAsmOperand;
372 let PrintMethod = "printRegisterList";
373 let DecoderMethod = "DecodeSPRRegListOperand";
376 // An operand for the CONSTPOOL_ENTRY pseudo-instruction.
377 def cpinst_operand : Operand<i32> {
378 let PrintMethod = "printCPInstOperand";
382 def pclabel : Operand<i32> {
383 let PrintMethod = "printPCLabel";
386 // ADR instruction labels.
387 def adrlabel : Operand<i32> {
388 let EncoderMethod = "getAdrLabelOpValue";
391 def neon_vcvt_imm32 : Operand<i32> {
392 let EncoderMethod = "getNEONVcvtImm32OpValue";
393 let DecoderMethod = "DecodeVCVTImmOperand";
396 // rot_imm: An integer that encodes a rotate amount. Must be 8, 16, or 24.
397 def rot_imm_XFORM: SDNodeXForm<imm, [{
398 switch (N->getZExtValue()){
400 case 0: return CurDAG->getTargetConstant(0, MVT::i32);
401 case 8: return CurDAG->getTargetConstant(1, MVT::i32);
402 case 16: return CurDAG->getTargetConstant(2, MVT::i32);
403 case 24: return CurDAG->getTargetConstant(3, MVT::i32);
406 def RotImmAsmOperand : AsmOperandClass {
408 let ParserMethod = "parseRotImm";
410 def rot_imm : Operand<i32>, PatLeaf<(i32 imm), [{
411 int32_t v = N->getZExtValue();
412 return v == 8 || v == 16 || v == 24; }],
414 let PrintMethod = "printRotImmOperand";
415 let ParserMatchClass = RotImmAsmOperand;
418 // shift_imm: An integer that encodes a shift amount and the type of shift
419 // (asr or lsl). The 6-bit immediate encodes as:
422 // {4-0} imm5 shift amount.
423 // asr #32 encoded as imm5 == 0.
424 def ShifterImmAsmOperand : AsmOperandClass {
425 let Name = "ShifterImm";
426 let ParserMethod = "parseShifterImm";
428 def shift_imm : Operand<i32> {
429 let PrintMethod = "printShiftImmOperand";
430 let ParserMatchClass = ShifterImmAsmOperand;
433 // shifter_operand operands: so_reg_reg, so_reg_imm, and so_imm.
434 def ShiftedRegAsmOperand : AsmOperandClass { let Name = "RegShiftedReg"; }
435 def so_reg_reg : Operand<i32>, // reg reg imm
436 ComplexPattern<i32, 3, "SelectRegShifterOperand",
437 [shl, srl, sra, rotr]> {
438 let EncoderMethod = "getSORegRegOpValue";
439 let PrintMethod = "printSORegRegOperand";
440 let DecoderMethod = "DecodeSORegRegOperand";
441 let ParserMatchClass = ShiftedRegAsmOperand;
442 let MIOperandInfo = (ops GPRnopc, GPRnopc, i32imm);
445 def ShiftedImmAsmOperand : AsmOperandClass { let Name = "RegShiftedImm"; }
446 def so_reg_imm : Operand<i32>, // reg imm
447 ComplexPattern<i32, 2, "SelectImmShifterOperand",
448 [shl, srl, sra, rotr]> {
449 let EncoderMethod = "getSORegImmOpValue";
450 let PrintMethod = "printSORegImmOperand";
451 let DecoderMethod = "DecodeSORegImmOperand";
452 let ParserMatchClass = ShiftedImmAsmOperand;
453 let MIOperandInfo = (ops GPR, i32imm);
456 // FIXME: Does this need to be distinct from so_reg?
457 def shift_so_reg_reg : Operand<i32>, // reg reg imm
458 ComplexPattern<i32, 3, "SelectShiftRegShifterOperand",
459 [shl,srl,sra,rotr]> {
460 let EncoderMethod = "getSORegRegOpValue";
461 let PrintMethod = "printSORegRegOperand";
462 let DecoderMethod = "DecodeSORegRegOperand";
463 let MIOperandInfo = (ops GPR, GPR, i32imm);
466 // FIXME: Does this need to be distinct from so_reg?
467 def shift_so_reg_imm : Operand<i32>, // reg reg imm
468 ComplexPattern<i32, 2, "SelectShiftImmShifterOperand",
469 [shl,srl,sra,rotr]> {
470 let EncoderMethod = "getSORegImmOpValue";
471 let PrintMethod = "printSORegImmOperand";
472 let DecoderMethod = "DecodeSORegImmOperand";
473 let MIOperandInfo = (ops GPR, i32imm);
477 // so_imm - Match a 32-bit shifter_operand immediate operand, which is an
478 // 8-bit immediate rotated by an arbitrary number of bits.
479 def SOImmAsmOperand: AsmOperandClass { let Name = "ARMSOImm"; }
480 def so_imm : Operand<i32>, ImmLeaf<i32, [{
481 return ARM_AM::getSOImmVal(Imm) != -1;
483 let EncoderMethod = "getSOImmOpValue";
484 let ParserMatchClass = SOImmAsmOperand;
485 let DecoderMethod = "DecodeSOImmOperand";
488 // Break so_imm's up into two pieces. This handles immediates with up to 16
489 // bits set in them. This uses so_imm2part to match and so_imm2part_[12] to
490 // get the first/second pieces.
491 def so_imm2part : PatLeaf<(imm), [{
492 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
495 /// arm_i32imm - True for +V6T2, or true only if so_imm2part is true.
497 def arm_i32imm : PatLeaf<(imm), [{
498 if (Subtarget->hasV6T2Ops())
500 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
503 /// imm0_7 predicate - Immediate in the range [0,7].
504 def Imm0_7AsmOperand: AsmOperandClass { let Name = "Imm0_7"; }
505 def imm0_7 : Operand<i32>, ImmLeaf<i32, [{
506 return Imm >= 0 && Imm < 8;
508 let ParserMatchClass = Imm0_7AsmOperand;
511 /// imm0_15 predicate - Immediate in the range [0,15].
512 def Imm0_15AsmOperand: AsmOperandClass { let Name = "Imm0_15"; }
513 def imm0_15 : Operand<i32>, ImmLeaf<i32, [{
514 return Imm >= 0 && Imm < 16;
516 let ParserMatchClass = Imm0_15AsmOperand;
519 /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
520 def Imm0_31AsmOperand: AsmOperandClass { let Name = "Imm0_31"; }
521 def imm0_31 : Operand<i32>, ImmLeaf<i32, [{
522 return Imm >= 0 && Imm < 32;
524 let ParserMatchClass = Imm0_31AsmOperand;
527 /// imm0_255 predicate - Immediate in the range [0,255].
528 def Imm0_255AsmOperand : AsmOperandClass { let Name = "Imm0_255"; }
529 def imm0_255 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 256; }]> {
530 let ParserMatchClass = Imm0_255AsmOperand;
533 // imm0_65535_expr - For movt/movw - 16-bit immediate that can also reference
534 // a relocatable expression.
536 // FIXME: This really needs a Thumb version separate from the ARM version.
537 // While the range is the same, and can thus use the same match class,
538 // the encoding is different so it should have a different encoder method.
539 def Imm0_65535ExprAsmOperand: AsmOperandClass { let Name = "Imm0_65535Expr"; }
540 def imm0_65535_expr : Operand<i32> {
541 let EncoderMethod = "getHiLo16ImmOpValue";
542 let ParserMatchClass = Imm0_65535ExprAsmOperand;
545 /// imm24b - True if the 32-bit immediate is encodable in 24 bits.
546 def Imm24bitAsmOperand: AsmOperandClass { let Name = "Imm24bit"; }
547 def imm24b : Operand<i32>, ImmLeaf<i32, [{
548 return Imm >= 0 && Imm <= 0xffffff;
550 let ParserMatchClass = Imm24bitAsmOperand;
554 /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
556 def BitfieldAsmOperand : AsmOperandClass {
557 let Name = "Bitfield";
558 let ParserMethod = "parseBitfield";
560 def bf_inv_mask_imm : Operand<i32>,
562 return ARM::isBitFieldInvertedMask(N->getZExtValue());
564 let EncoderMethod = "getBitfieldInvertedMaskOpValue";
565 let PrintMethod = "printBitfieldInvMaskImmOperand";
566 let DecoderMethod = "DecodeBitfieldMaskOperand";
567 let ParserMatchClass = BitfieldAsmOperand;
570 /// lsb_pos_imm - position of the lsb bit, used by BFI4p and t2BFI4p
571 def lsb_pos_imm : Operand<i32>, ImmLeaf<i32, [{
572 return isInt<5>(Imm);
575 /// width_imm - number of bits to be copied, used by BFI4p and t2BFI4p
576 def width_imm : Operand<i32>, ImmLeaf<i32, [{
577 return Imm > 0 && Imm <= 32;
579 let EncoderMethod = "getMsbOpValue";
582 def imm1_32_XFORM: SDNodeXForm<imm, [{
583 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, MVT::i32);
585 def Imm1_32AsmOperand: AsmOperandClass { let Name = "Imm1_32"; }
586 def imm1_32 : Operand<i32>, PatLeaf<(imm), [{ return Imm > 0 && Imm <= 32; }],
588 let PrintMethod = "printImmPlusOneOperand";
589 let ParserMatchClass = Imm1_32AsmOperand;
592 def imm1_16_XFORM: SDNodeXForm<imm, [{
593 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, MVT::i32);
595 def Imm1_16AsmOperand: AsmOperandClass { let Name = "Imm1_16"; }
596 def imm1_16 : Operand<i32>, PatLeaf<(imm), [{ return Imm > 0 && Imm <= 16; }],
598 let PrintMethod = "printImmPlusOneOperand";
599 let ParserMatchClass = Imm1_16AsmOperand;
602 // Define ARM specific addressing modes.
603 // addrmode_imm12 := reg +/- imm12
605 def MemImm12OffsetAsmOperand : AsmOperandClass { let Name = "MemImm12Offset"; }
606 def addrmode_imm12 : Operand<i32>,
607 ComplexPattern<i32, 2, "SelectAddrModeImm12", []> {
608 // 12-bit immediate operand. Note that instructions using this encode
609 // #0 and #-0 differently. We flag #-0 as the magic value INT32_MIN. All other
610 // immediate values are as normal.
612 let EncoderMethod = "getAddrModeImm12OpValue";
613 let PrintMethod = "printAddrModeImm12Operand";
614 let DecoderMethod = "DecodeAddrModeImm12Operand";
615 let ParserMatchClass = MemImm12OffsetAsmOperand;
616 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
618 // ldst_so_reg := reg +/- reg shop imm
620 def MemRegOffsetAsmOperand : AsmOperandClass { let Name = "MemRegOffset"; }
621 def ldst_so_reg : Operand<i32>,
622 ComplexPattern<i32, 3, "SelectLdStSOReg", []> {
623 let EncoderMethod = "getLdStSORegOpValue";
624 // FIXME: Simplify the printer
625 let PrintMethod = "printAddrMode2Operand";
626 let DecoderMethod = "DecodeSORegMemOperand";
627 let ParserMatchClass = MemRegOffsetAsmOperand;
628 let MIOperandInfo = (ops GPR:$base, GPRnopc:$offsreg, i32imm:$shift);
631 // postidx_imm8 := +/- [0,255]
634 // {8} 1 is imm8 is non-negative. 0 otherwise.
635 // {7-0} [0,255] imm8 value.
636 def PostIdxImm8AsmOperand : AsmOperandClass { let Name = "PostIdxImm8"; }
637 def postidx_imm8 : Operand<i32> {
638 let PrintMethod = "printPostIdxImm8Operand";
639 let ParserMatchClass = PostIdxImm8AsmOperand;
640 let MIOperandInfo = (ops i32imm);
643 // postidx_imm8s4 := +/- [0,1020]
646 // {8} 1 is imm8 is non-negative. 0 otherwise.
647 // {7-0} [0,255] imm8 value, scaled by 4.
648 def postidx_imm8s4 : Operand<i32> {
649 let PrintMethod = "printPostIdxImm8s4Operand";
650 let MIOperandInfo = (ops i32imm);
654 // postidx_reg := +/- reg
656 def PostIdxRegAsmOperand : AsmOperandClass {
657 let Name = "PostIdxReg";
658 let ParserMethod = "parsePostIdxReg";
660 def postidx_reg : Operand<i32> {
661 let EncoderMethod = "getPostIdxRegOpValue";
662 let DecoderMethod = "DecodePostIdxReg";
663 let PrintMethod = "printPostIdxRegOperand";
664 let ParserMatchClass = PostIdxRegAsmOperand;
665 let MIOperandInfo = (ops GPR, i32imm);
669 // addrmode2 := reg +/- imm12
670 // := reg +/- reg shop imm
672 // FIXME: addrmode2 should be refactored the rest of the way to always
673 // use explicit imm vs. reg versions above (addrmode_imm12 and ldst_so_reg).
674 def AddrMode2AsmOperand : AsmOperandClass { let Name = "AddrMode2"; }
675 def addrmode2 : Operand<i32>,
676 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
677 let EncoderMethod = "getAddrMode2OpValue";
678 let PrintMethod = "printAddrMode2Operand";
679 let ParserMatchClass = AddrMode2AsmOperand;
680 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
683 def PostIdxRegShiftedAsmOperand : AsmOperandClass {
684 let Name = "PostIdxRegShifted";
685 let ParserMethod = "parsePostIdxReg";
687 def am2offset_reg : Operand<i32>,
688 ComplexPattern<i32, 2, "SelectAddrMode2OffsetReg",
689 [], [SDNPWantRoot]> {
690 let EncoderMethod = "getAddrMode2OffsetOpValue";
691 let PrintMethod = "printAddrMode2OffsetOperand";
692 // When using this for assembly, it's always as a post-index offset.
693 let ParserMatchClass = PostIdxRegShiftedAsmOperand;
694 let MIOperandInfo = (ops GPR, i32imm);
697 // FIXME: am2offset_imm should only need the immediate, not the GPR. Having
698 // the GPR is purely vestigal at this point.
699 def AM2OffsetImmAsmOperand : AsmOperandClass { let Name = "AM2OffsetImm"; }
700 def am2offset_imm : Operand<i32>,
701 ComplexPattern<i32, 2, "SelectAddrMode2OffsetImm",
702 [], [SDNPWantRoot]> {
703 let EncoderMethod = "getAddrMode2OffsetOpValue";
704 let PrintMethod = "printAddrMode2OffsetOperand";
705 let ParserMatchClass = AM2OffsetImmAsmOperand;
706 let MIOperandInfo = (ops GPR, i32imm);
710 // addrmode3 := reg +/- reg
711 // addrmode3 := reg +/- imm8
713 // FIXME: split into imm vs. reg versions.
714 def AddrMode3AsmOperand : AsmOperandClass { let Name = "AddrMode3"; }
715 def addrmode3 : Operand<i32>,
716 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
717 let EncoderMethod = "getAddrMode3OpValue";
718 let PrintMethod = "printAddrMode3Operand";
719 let ParserMatchClass = AddrMode3AsmOperand;
720 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
723 // FIXME: split into imm vs. reg versions.
724 // FIXME: parser method to handle +/- register.
725 def AM3OffsetAsmOperand : AsmOperandClass {
726 let Name = "AM3Offset";
727 let ParserMethod = "parseAM3Offset";
729 def am3offset : Operand<i32>,
730 ComplexPattern<i32, 2, "SelectAddrMode3Offset",
731 [], [SDNPWantRoot]> {
732 let EncoderMethod = "getAddrMode3OffsetOpValue";
733 let DecoderMethod = "DecodeAddrMode3Offset";
734 let PrintMethod = "printAddrMode3OffsetOperand";
735 let ParserMatchClass = AM3OffsetAsmOperand;
736 let MIOperandInfo = (ops GPR, i32imm);
739 // ldstm_mode := {ia, ib, da, db}
741 def ldstm_mode : OptionalDefOperand<OtherVT, (ops i32), (ops (i32 1))> {
742 let EncoderMethod = "getLdStmModeOpValue";
743 let PrintMethod = "printLdStmModeOperand";
746 // addrmode5 := reg +/- imm8*4
748 def AddrMode5AsmOperand : AsmOperandClass { let Name = "AddrMode5"; }
749 def addrmode5 : Operand<i32>,
750 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
751 let PrintMethod = "printAddrMode5Operand";
752 let EncoderMethod = "getAddrMode5OpValue";
753 let DecoderMethod = "DecodeAddrMode5Operand";
754 let ParserMatchClass = AddrMode5AsmOperand;
755 let MIOperandInfo = (ops GPR:$base, i32imm);
758 // addrmode6 := reg with optional alignment
760 def addrmode6 : Operand<i32>,
761 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
762 let PrintMethod = "printAddrMode6Operand";
763 let MIOperandInfo = (ops GPR:$addr, i32imm);
764 let EncoderMethod = "getAddrMode6AddressOpValue";
765 let DecoderMethod = "DecodeAddrMode6Operand";
768 def am6offset : Operand<i32>,
769 ComplexPattern<i32, 1, "SelectAddrMode6Offset",
770 [], [SDNPWantRoot]> {
771 let PrintMethod = "printAddrMode6OffsetOperand";
772 let MIOperandInfo = (ops GPR);
773 let EncoderMethod = "getAddrMode6OffsetOpValue";
774 let DecoderMethod = "DecodeGPRRegisterClass";
777 // Special version of addrmode6 to handle alignment encoding for VST1/VLD1
778 // (single element from one lane) for size 32.
779 def addrmode6oneL32 : Operand<i32>,
780 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
781 let PrintMethod = "printAddrMode6Operand";
782 let MIOperandInfo = (ops GPR:$addr, i32imm);
783 let EncoderMethod = "getAddrMode6OneLane32AddressOpValue";
786 // Special version of addrmode6 to handle alignment encoding for VLD-dup
787 // instructions, specifically VLD4-dup.
788 def addrmode6dup : Operand<i32>,
789 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
790 let PrintMethod = "printAddrMode6Operand";
791 let MIOperandInfo = (ops GPR:$addr, i32imm);
792 let EncoderMethod = "getAddrMode6DupAddressOpValue";
795 // addrmodepc := pc + reg
797 def addrmodepc : Operand<i32>,
798 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
799 let PrintMethod = "printAddrModePCOperand";
800 let MIOperandInfo = (ops GPR, i32imm);
803 // addr_offset_none := reg
805 def MemNoOffsetAsmOperand : AsmOperandClass { let Name = "MemNoOffset"; }
806 def addr_offset_none : Operand<i32>,
807 ComplexPattern<i32, 1, "SelectAddrOffsetNone", []> {
808 let PrintMethod = "printAddrMode7Operand";
809 let DecoderMethod = "DecodeAddrMode7Operand";
810 let ParserMatchClass = MemNoOffsetAsmOperand;
811 let MIOperandInfo = (ops GPR:$base);
814 def nohash_imm : Operand<i32> {
815 let PrintMethod = "printNoHashImmediate";
818 def CoprocNumAsmOperand : AsmOperandClass {
819 let Name = "CoprocNum";
820 let ParserMethod = "parseCoprocNumOperand";
822 def p_imm : Operand<i32> {
823 let PrintMethod = "printPImmediate";
824 let ParserMatchClass = CoprocNumAsmOperand;
825 let DecoderMethod = "DecodeCoprocessor";
828 def CoprocRegAsmOperand : AsmOperandClass {
829 let Name = "CoprocReg";
830 let ParserMethod = "parseCoprocRegOperand";
832 def c_imm : Operand<i32> {
833 let PrintMethod = "printCImmediate";
834 let ParserMatchClass = CoprocRegAsmOperand;
837 //===----------------------------------------------------------------------===//
839 include "ARMInstrFormats.td"
841 //===----------------------------------------------------------------------===//
842 // Multiclass helpers...
845 /// AsI1_bin_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns for a
846 /// binop that produces a value.
847 multiclass AsI1_bin_irs<bits<4> opcod, string opc,
848 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
849 PatFrag opnode, string baseOpc, bit Commutable = 0> {
850 // The register-immediate version is re-materializable. This is useful
851 // in particular for taking the address of a local.
852 let isReMaterializable = 1 in {
853 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
854 iii, opc, "\t$Rd, $Rn, $imm",
855 [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]> {
860 let Inst{19-16} = Rn;
861 let Inst{15-12} = Rd;
862 let Inst{11-0} = imm;
865 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
866 iir, opc, "\t$Rd, $Rn, $Rm",
867 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]> {
872 let isCommutable = Commutable;
873 let Inst{19-16} = Rn;
874 let Inst{15-12} = Rd;
875 let Inst{11-4} = 0b00000000;
879 def rsi : AsI1<opcod, (outs GPR:$Rd),
880 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
881 iis, opc, "\t$Rd, $Rn, $shift",
882 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_imm:$shift))]> {
887 let Inst{19-16} = Rn;
888 let Inst{15-12} = Rd;
889 let Inst{11-5} = shift{11-5};
891 let Inst{3-0} = shift{3-0};
894 def rsr : AsI1<opcod, (outs GPR:$Rd),
895 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
896 iis, opc, "\t$Rd, $Rn, $shift",
897 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_reg:$shift))]> {
902 let Inst{19-16} = Rn;
903 let Inst{15-12} = Rd;
904 let Inst{11-8} = shift{11-8};
906 let Inst{6-5} = shift{6-5};
908 let Inst{3-0} = shift{3-0};
911 // Assembly aliases for optional destination operand when it's the same
912 // as the source operand.
913 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $imm"),
914 (!cast<Instruction>(!strconcat(baseOpc, "ri")) GPR:$Rdn, GPR:$Rdn,
915 so_imm:$imm, pred:$p,
918 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $Rm"),
919 (!cast<Instruction>(!strconcat(baseOpc, "rr")) GPR:$Rdn, GPR:$Rdn,
923 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
924 (!cast<Instruction>(!strconcat(baseOpc, "rsi")) GPR:$Rdn, GPR:$Rdn,
925 so_reg_imm:$shift, pred:$p,
928 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
929 (!cast<Instruction>(!strconcat(baseOpc, "rsr")) GPR:$Rdn, GPR:$Rdn,
930 so_reg_reg:$shift, pred:$p,
936 /// AI1_bin_s_irs - Similar to AsI1_bin_irs except it sets the 's' bit so the
937 /// instruction modifies the CPSR register.
938 let isCodeGenOnly = 1, Defs = [CPSR] in {
939 multiclass AI1_bin_s_irs<bits<4> opcod, string opc,
940 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
941 PatFrag opnode, bit Commutable = 0> {
942 def ri : AI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
943 iii, opc, "\t$Rd, $Rn, $imm",
944 [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]> {
950 let Inst{19-16} = Rn;
951 let Inst{15-12} = Rd;
952 let Inst{11-0} = imm;
954 def rr : AI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
955 iir, opc, "\t$Rd, $Rn, $Rm",
956 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]> {
960 let isCommutable = Commutable;
963 let Inst{19-16} = Rn;
964 let Inst{15-12} = Rd;
965 let Inst{11-4} = 0b00000000;
968 def rsi : AI1<opcod, (outs GPR:$Rd),
969 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
970 iis, opc, "\t$Rd, $Rn, $shift",
971 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_imm:$shift))]> {
977 let Inst{19-16} = Rn;
978 let Inst{15-12} = Rd;
979 let Inst{11-5} = shift{11-5};
981 let Inst{3-0} = shift{3-0};
984 def rsr : AI1<opcod, (outs GPR:$Rd),
985 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
986 iis, opc, "\t$Rd, $Rn, $shift",
987 [(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};
1004 /// AI1_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
1005 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
1006 /// a explicit result, only implicitly set CPSR.
1007 let isCompare = 1, Defs = [CPSR] in {
1008 multiclass AI1_cmp_irs<bits<4> opcod, string opc,
1009 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1010 PatFrag opnode, bit Commutable = 0> {
1011 def ri : AI1<opcod, (outs), (ins GPR:$Rn, so_imm:$imm), DPFrm, iii,
1013 [(opnode GPR:$Rn, so_imm:$imm)]> {
1018 let Inst{19-16} = Rn;
1019 let Inst{15-12} = 0b0000;
1020 let Inst{11-0} = imm;
1022 def rr : AI1<opcod, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, iir,
1024 [(opnode GPR:$Rn, GPR:$Rm)]> {
1027 let isCommutable = Commutable;
1030 let Inst{19-16} = Rn;
1031 let Inst{15-12} = 0b0000;
1032 let Inst{11-4} = 0b00000000;
1035 def rsi : AI1<opcod, (outs),
1036 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, iis,
1037 opc, "\t$Rn, $shift",
1038 [(opnode GPR:$Rn, so_reg_imm:$shift)]> {
1043 let Inst{19-16} = Rn;
1044 let Inst{15-12} = 0b0000;
1045 let Inst{11-5} = shift{11-5};
1047 let Inst{3-0} = shift{3-0};
1049 def rsr : AI1<opcod, (outs),
1050 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, iis,
1051 opc, "\t$Rn, $shift",
1052 [(opnode GPR:$Rn, so_reg_reg:$shift)]> {
1057 let Inst{19-16} = Rn;
1058 let Inst{15-12} = 0b0000;
1059 let Inst{11-8} = shift{11-8};
1061 let Inst{6-5} = shift{6-5};
1063 let Inst{3-0} = shift{3-0};
1069 /// AI_ext_rrot - A unary operation with two forms: one whose operand is a
1070 /// register and one whose operand is a register rotated by 8/16/24.
1071 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
1072 class AI_ext_rrot<bits<8> opcod, string opc, PatFrag opnode>
1073 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1074 IIC_iEXTr, opc, "\t$Rd, $Rm$rot",
1075 [(set GPRnopc:$Rd, (opnode (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1076 Requires<[IsARM, HasV6]> {
1080 let Inst{19-16} = 0b1111;
1081 let Inst{15-12} = Rd;
1082 let Inst{11-10} = rot;
1086 class AI_ext_rrot_np<bits<8> opcod, string opc>
1087 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1088 IIC_iEXTr, opc, "\t$Rd, $Rm$rot", []>,
1089 Requires<[IsARM, HasV6]> {
1091 let Inst{19-16} = 0b1111;
1092 let Inst{11-10} = rot;
1095 /// AI_exta_rrot - A binary operation with two forms: one whose operand is a
1096 /// register and one whose operand is a register rotated by 8/16/24.
1097 class AI_exta_rrot<bits<8> opcod, string opc, PatFrag opnode>
1098 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1099 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot",
1100 [(set GPRnopc:$Rd, (opnode GPR:$Rn,
1101 (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1102 Requires<[IsARM, HasV6]> {
1107 let Inst{19-16} = Rn;
1108 let Inst{15-12} = Rd;
1109 let Inst{11-10} = rot;
1110 let Inst{9-4} = 0b000111;
1114 class AI_exta_rrot_np<bits<8> opcod, string opc>
1115 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1116 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot", []>,
1117 Requires<[IsARM, HasV6]> {
1120 let Inst{19-16} = Rn;
1121 let Inst{11-10} = rot;
1124 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
1125 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
1126 string baseOpc, bit Commutable = 0> {
1127 let Uses = [CPSR] in {
1128 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
1129 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1130 [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]>,
1136 let Inst{15-12} = Rd;
1137 let Inst{19-16} = Rn;
1138 let Inst{11-0} = imm;
1140 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1141 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1142 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]>,
1147 let Inst{11-4} = 0b00000000;
1149 let isCommutable = Commutable;
1151 let Inst{15-12} = Rd;
1152 let Inst{19-16} = Rn;
1154 def rsi : AsI1<opcod, (outs GPR:$Rd),
1155 (ins GPR:$Rn, so_reg_imm:$shift),
1156 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1157 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_imm:$shift))]>,
1163 let Inst{19-16} = Rn;
1164 let Inst{15-12} = Rd;
1165 let Inst{11-5} = shift{11-5};
1167 let Inst{3-0} = shift{3-0};
1169 def rsr : AsI1<opcod, (outs GPR:$Rd),
1170 (ins GPR:$Rn, so_reg_reg:$shift),
1171 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1172 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_reg:$shift))]>,
1178 let Inst{19-16} = Rn;
1179 let Inst{15-12} = Rd;
1180 let Inst{11-8} = shift{11-8};
1182 let Inst{6-5} = shift{6-5};
1184 let Inst{3-0} = shift{3-0};
1187 // Assembly aliases for optional destination operand when it's the same
1188 // as the source operand.
1189 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $imm"),
1190 (!cast<Instruction>(!strconcat(baseOpc, "ri")) GPR:$Rdn, GPR:$Rdn,
1191 so_imm:$imm, pred:$p,
1194 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $Rm"),
1195 (!cast<Instruction>(!strconcat(baseOpc, "rr")) GPR:$Rdn, GPR:$Rdn,
1199 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1200 (!cast<Instruction>(!strconcat(baseOpc, "rsi")) GPR:$Rdn, GPR:$Rdn,
1201 so_reg_imm:$shift, pred:$p,
1204 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1205 (!cast<Instruction>(!strconcat(baseOpc, "rsr")) GPR:$Rdn, GPR:$Rdn,
1206 so_reg_reg:$shift, pred:$p,
1211 // Carry setting variants
1212 // NOTE: CPSR def omitted because it will be handled by the custom inserter.
1213 let usesCustomInserter = 1 in {
1214 multiclass AI1_adde_sube_s_irs<PatFrag opnode, bit Commutable = 0> {
1215 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
1217 [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]>;
1218 def rr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1220 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]> {
1221 let isCommutable = Commutable;
1223 def rsi : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, so_reg_imm:$shift),
1225 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_imm:$shift))]>;
1226 def rsr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, so_reg_reg:$shift),
1228 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_reg:$shift))]>;
1232 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1233 multiclass AI_ldr1<bit isByte, string opc, InstrItinClass iii,
1234 InstrItinClass iir, PatFrag opnode> {
1235 // Note: We use the complex addrmode_imm12 rather than just an input
1236 // GPR and a constrained immediate so that we can use this to match
1237 // frame index references and avoid matching constant pool references.
1238 def i12: AI2ldst<0b010, 1, isByte, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
1239 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1240 [(set GPR:$Rt, (opnode addrmode_imm12:$addr))]> {
1243 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1244 let Inst{19-16} = addr{16-13}; // Rn
1245 let Inst{15-12} = Rt;
1246 let Inst{11-0} = addr{11-0}; // imm12
1248 def rs : AI2ldst<0b011, 1, isByte, (outs GPR:$Rt), (ins ldst_so_reg:$shift),
1249 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1250 [(set GPR:$Rt, (opnode ldst_so_reg:$shift))]> {
1253 let shift{4} = 0; // Inst{4} = 0
1254 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1255 let Inst{19-16} = shift{16-13}; // Rn
1256 let Inst{15-12} = Rt;
1257 let Inst{11-0} = shift{11-0};
1262 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1263 multiclass AI_ldr1nopc<bit isByte, string opc, InstrItinClass iii,
1264 InstrItinClass iir, PatFrag opnode> {
1265 // Note: We use the complex addrmode_imm12 rather than just an input
1266 // GPR and a constrained immediate so that we can use this to match
1267 // frame index references and avoid matching constant pool references.
1268 def i12: AI2ldst<0b010, 1, isByte, (outs GPRnopc:$Rt), (ins addrmode_imm12:$addr),
1269 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1270 [(set GPRnopc:$Rt, (opnode addrmode_imm12:$addr))]> {
1273 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1274 let Inst{19-16} = addr{16-13}; // Rn
1275 let Inst{15-12} = Rt;
1276 let Inst{11-0} = addr{11-0}; // imm12
1278 def rs : AI2ldst<0b011, 1, isByte, (outs GPRnopc:$Rt), (ins ldst_so_reg:$shift),
1279 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1280 [(set GPRnopc:$Rt, (opnode ldst_so_reg:$shift))]> {
1283 let shift{4} = 0; // Inst{4} = 0
1284 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1285 let Inst{19-16} = shift{16-13}; // Rn
1286 let Inst{15-12} = Rt;
1287 let Inst{11-0} = shift{11-0};
1293 multiclass AI_str1<bit isByte, string opc, InstrItinClass iii,
1294 InstrItinClass iir, PatFrag opnode> {
1295 // Note: We use the complex addrmode_imm12 rather than just an input
1296 // GPR and a constrained immediate so that we can use this to match
1297 // frame index references and avoid matching constant pool references.
1298 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1299 (ins GPR:$Rt, addrmode_imm12:$addr),
1300 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1301 [(opnode GPR:$Rt, addrmode_imm12:$addr)]> {
1304 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1305 let Inst{19-16} = addr{16-13}; // Rn
1306 let Inst{15-12} = Rt;
1307 let Inst{11-0} = addr{11-0}; // imm12
1309 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPR:$Rt, ldst_so_reg:$shift),
1310 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1311 [(opnode GPR:$Rt, ldst_so_reg:$shift)]> {
1314 let shift{4} = 0; // Inst{4} = 0
1315 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1316 let Inst{19-16} = shift{16-13}; // Rn
1317 let Inst{15-12} = Rt;
1318 let Inst{11-0} = shift{11-0};
1322 multiclass AI_str1nopc<bit isByte, string opc, InstrItinClass iii,
1323 InstrItinClass iir, PatFrag opnode> {
1324 // Note: We use the complex addrmode_imm12 rather than just an input
1325 // GPR and a constrained immediate so that we can use this to match
1326 // frame index references and avoid matching constant pool references.
1327 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1328 (ins GPRnopc:$Rt, addrmode_imm12:$addr),
1329 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1330 [(opnode GPRnopc:$Rt, addrmode_imm12:$addr)]> {
1333 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1334 let Inst{19-16} = addr{16-13}; // Rn
1335 let Inst{15-12} = Rt;
1336 let Inst{11-0} = addr{11-0}; // imm12
1338 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPRnopc:$Rt, ldst_so_reg:$shift),
1339 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1340 [(opnode GPRnopc:$Rt, ldst_so_reg:$shift)]> {
1343 let shift{4} = 0; // Inst{4} = 0
1344 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1345 let Inst{19-16} = shift{16-13}; // Rn
1346 let Inst{15-12} = Rt;
1347 let Inst{11-0} = shift{11-0};
1352 //===----------------------------------------------------------------------===//
1354 //===----------------------------------------------------------------------===//
1356 //===----------------------------------------------------------------------===//
1357 // Miscellaneous Instructions.
1360 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
1361 /// the function. The first operand is the ID# for this instruction, the second
1362 /// is the index into the MachineConstantPool that this is, the third is the
1363 /// size in bytes of this constant pool entry.
1364 let neverHasSideEffects = 1, isNotDuplicable = 1 in
1365 def CONSTPOOL_ENTRY :
1366 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1367 i32imm:$size), NoItinerary, []>;
1369 // FIXME: Marking these as hasSideEffects is necessary to prevent machine DCE
1370 // from removing one half of the matched pairs. That breaks PEI, which assumes
1371 // these will always be in pairs, and asserts if it finds otherwise. Better way?
1372 let Defs = [SP], Uses = [SP], hasSideEffects = 1 in {
1373 def ADJCALLSTACKUP :
1374 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary,
1375 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
1377 def ADJCALLSTACKDOWN :
1378 PseudoInst<(outs), (ins i32imm:$amt, pred:$p), NoItinerary,
1379 [(ARMcallseq_start timm:$amt)]>;
1382 def NOP : AI<(outs), (ins), MiscFrm, NoItinerary, "nop", "", []>,
1383 Requires<[IsARM, HasV6T2]> {
1384 let Inst{27-16} = 0b001100100000;
1385 let Inst{15-8} = 0b11110000;
1386 let Inst{7-0} = 0b00000000;
1389 def YIELD : AI<(outs), (ins), MiscFrm, NoItinerary, "yield", "", []>,
1390 Requires<[IsARM, HasV6T2]> {
1391 let Inst{27-16} = 0b001100100000;
1392 let Inst{15-8} = 0b11110000;
1393 let Inst{7-0} = 0b00000001;
1396 def WFE : AI<(outs), (ins), MiscFrm, NoItinerary, "wfe", "", []>,
1397 Requires<[IsARM, HasV6T2]> {
1398 let Inst{27-16} = 0b001100100000;
1399 let Inst{15-8} = 0b11110000;
1400 let Inst{7-0} = 0b00000010;
1403 def WFI : AI<(outs), (ins), MiscFrm, NoItinerary, "wfi", "", []>,
1404 Requires<[IsARM, HasV6T2]> {
1405 let Inst{27-16} = 0b001100100000;
1406 let Inst{15-8} = 0b11110000;
1407 let Inst{7-0} = 0b00000011;
1410 def SEL : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, NoItinerary, "sel",
1411 "\t$Rd, $Rn, $Rm", []>, Requires<[IsARM, HasV6]> {
1416 let Inst{15-12} = Rd;
1417 let Inst{19-16} = Rn;
1418 let Inst{27-20} = 0b01101000;
1419 let Inst{7-4} = 0b1011;
1420 let Inst{11-8} = 0b1111;
1423 def SEV : AI<(outs), (ins), MiscFrm, NoItinerary, "sev", "",
1424 []>, Requires<[IsARM, HasV6T2]> {
1425 let Inst{27-16} = 0b001100100000;
1426 let Inst{15-8} = 0b11110000;
1427 let Inst{7-0} = 0b00000100;
1430 // The i32imm operand $val can be used by a debugger to store more information
1431 // about the breakpoint.
1432 def BKPT : AI<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
1433 "bkpt", "\t$val", []>, Requires<[IsARM]> {
1435 let Inst{3-0} = val{3-0};
1436 let Inst{19-8} = val{15-4};
1437 let Inst{27-20} = 0b00010010;
1438 let Inst{7-4} = 0b0111;
1441 // Change Processor State
1442 // FIXME: We should use InstAlias to handle the optional operands.
1443 class CPS<dag iops, string asm_ops>
1444 : AXI<(outs), iops, MiscFrm, NoItinerary, !strconcat("cps", asm_ops),
1445 []>, Requires<[IsARM]> {
1451 let Inst{31-28} = 0b1111;
1452 let Inst{27-20} = 0b00010000;
1453 let Inst{19-18} = imod;
1454 let Inst{17} = M; // Enabled if mode is set;
1456 let Inst{8-6} = iflags;
1458 let Inst{4-0} = mode;
1461 let DecoderMethod = "DecodeCPSInstruction" in {
1463 def CPS3p : CPS<(ins imod_op:$imod, iflags_op:$iflags, imm0_31:$mode),
1464 "$imod\t$iflags, $mode">;
1465 let mode = 0, M = 0 in
1466 def CPS2p : CPS<(ins imod_op:$imod, iflags_op:$iflags), "$imod\t$iflags">;
1468 let imod = 0, iflags = 0, M = 1 in
1469 def CPS1p : CPS<(ins imm0_31:$mode), "\t$mode">;
1472 // Preload signals the memory system of possible future data/instruction access.
1473 multiclass APreLoad<bits<1> read, bits<1> data, string opc> {
1475 def i12 : AXI<(outs), (ins addrmode_imm12:$addr), MiscFrm, IIC_Preload,
1476 !strconcat(opc, "\t$addr"),
1477 [(ARMPreload addrmode_imm12:$addr, (i32 read), (i32 data))]> {
1480 let Inst{31-26} = 0b111101;
1481 let Inst{25} = 0; // 0 for immediate form
1482 let Inst{24} = data;
1483 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1484 let Inst{22} = read;
1485 let Inst{21-20} = 0b01;
1486 let Inst{19-16} = addr{16-13}; // Rn
1487 let Inst{15-12} = 0b1111;
1488 let Inst{11-0} = addr{11-0}; // imm12
1491 def rs : AXI<(outs), (ins ldst_so_reg:$shift), MiscFrm, IIC_Preload,
1492 !strconcat(opc, "\t$shift"),
1493 [(ARMPreload ldst_so_reg:$shift, (i32 read), (i32 data))]> {
1495 let Inst{31-26} = 0b111101;
1496 let Inst{25} = 1; // 1 for register form
1497 let Inst{24} = data;
1498 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1499 let Inst{22} = read;
1500 let Inst{21-20} = 0b01;
1501 let Inst{19-16} = shift{16-13}; // Rn
1502 let Inst{15-12} = 0b1111;
1503 let Inst{11-0} = shift{11-0};
1507 defm PLD : APreLoad<1, 1, "pld">, Requires<[IsARM]>;
1508 defm PLDW : APreLoad<0, 1, "pldw">, Requires<[IsARM,HasV7,HasMP]>;
1509 defm PLI : APreLoad<1, 0, "pli">, Requires<[IsARM,HasV7]>;
1511 def SETEND : AXI<(outs), (ins setend_op:$end), MiscFrm, NoItinerary,
1512 "setend\t$end", []>, Requires<[IsARM]> {
1514 let Inst{31-10} = 0b1111000100000001000000;
1519 def DBG : AI<(outs), (ins imm0_15:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt",
1520 []>, Requires<[IsARM, HasV7]> {
1522 let Inst{27-4} = 0b001100100000111100001111;
1523 let Inst{3-0} = opt;
1526 // A5.4 Permanently UNDEFINED instructions.
1527 let isBarrier = 1, isTerminator = 1 in
1528 def TRAP : AXI<(outs), (ins), MiscFrm, NoItinerary,
1531 let Inst = 0xe7ffdefe;
1534 // Address computation and loads and stores in PIC mode.
1535 let isNotDuplicable = 1 in {
1536 def PICADD : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
1538 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>;
1540 let AddedComplexity = 10 in {
1541 def PICLDR : ARMPseudoInst<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
1543 [(set GPR:$dst, (load addrmodepc:$addr))]>;
1545 def PICLDRH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1547 [(set GPR:$Rt, (zextloadi16 addrmodepc:$addr))]>;
1549 def PICLDRB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1551 [(set GPR:$Rt, (zextloadi8 addrmodepc:$addr))]>;
1553 def PICLDRSH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1555 [(set GPR:$Rt, (sextloadi16 addrmodepc:$addr))]>;
1557 def PICLDRSB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1559 [(set GPR:$Rt, (sextloadi8 addrmodepc:$addr))]>;
1561 let AddedComplexity = 10 in {
1562 def PICSTR : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1563 4, IIC_iStore_r, [(store GPR:$src, addrmodepc:$addr)]>;
1565 def PICSTRH : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1566 4, IIC_iStore_bh_r, [(truncstorei16 GPR:$src,
1567 addrmodepc:$addr)]>;
1569 def PICSTRB : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1570 4, IIC_iStore_bh_r, [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
1572 } // isNotDuplicable = 1
1575 // LEApcrel - Load a pc-relative address into a register without offending the
1577 let neverHasSideEffects = 1, isReMaterializable = 1 in
1578 // The 'adr' mnemonic encodes differently if the label is before or after
1579 // the instruction. The {24-21} opcode bits are set by the fixup, as we don't
1580 // know until then which form of the instruction will be used.
1581 def ADR : AI1<{0,?,?,0}, (outs GPR:$Rd), (ins adrlabel:$label),
1582 MiscFrm, IIC_iALUi, "adr", "\t$Rd, $label", []> {
1585 let Inst{27-25} = 0b001;
1587 let Inst{19-16} = 0b1111;
1588 let Inst{15-12} = Rd;
1589 let Inst{11-0} = label;
1591 def LEApcrel : ARMPseudoInst<(outs GPR:$Rd), (ins i32imm:$label, pred:$p),
1594 def LEApcrelJT : ARMPseudoInst<(outs GPR:$Rd),
1595 (ins i32imm:$label, nohash_imm:$id, pred:$p),
1598 //===----------------------------------------------------------------------===//
1599 // Control Flow Instructions.
1602 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
1604 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
1605 "bx", "\tlr", [(ARMretflag)]>,
1606 Requires<[IsARM, HasV4T]> {
1607 let Inst{27-0} = 0b0001001011111111111100011110;
1611 def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br,
1612 "mov", "\tpc, lr", [(ARMretflag)]>,
1613 Requires<[IsARM, NoV4T]> {
1614 let Inst{27-0} = 0b0001101000001111000000001110;
1618 // Indirect branches
1619 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
1621 def BX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
1622 [(brind GPR:$dst)]>,
1623 Requires<[IsARM, HasV4T]> {
1625 let Inst{31-4} = 0b1110000100101111111111110001;
1626 let Inst{3-0} = dst;
1629 def BX_pred : AI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br,
1630 "bx", "\t$dst", [/* pattern left blank */]>,
1631 Requires<[IsARM, HasV4T]> {
1633 let Inst{27-4} = 0b000100101111111111110001;
1634 let Inst{3-0} = dst;
1638 // All calls clobber the non-callee saved registers. SP is marked as
1639 // a use to prevent stack-pointer assignments that appear immediately
1640 // before calls from potentially appearing dead.
1642 // On non-Darwin platforms R9 is callee-saved.
1643 // FIXME: Do we really need a non-predicated version? If so, it should
1644 // at least be a pseudo instruction expanding to the predicated version
1645 // at MC lowering time.
1646 Defs = [R0, R1, R2, R3, R12, LR, QQQQ0, QQQQ2, QQQQ3, CPSR, FPSCR],
1648 def BL : ABXI<0b1011, (outs), (ins bl_target:$func, variable_ops),
1649 IIC_Br, "bl\t$func",
1650 [(ARMcall tglobaladdr:$func)]>,
1651 Requires<[IsARM, IsNotDarwin]> {
1652 let Inst{31-28} = 0b1110;
1654 let Inst{23-0} = func;
1657 def BL_pred : ABI<0b1011, (outs), (ins bl_target:$func, variable_ops),
1658 IIC_Br, "bl", "\t$func",
1659 [(ARMcall_pred tglobaladdr:$func)]>,
1660 Requires<[IsARM, IsNotDarwin]> {
1662 let Inst{23-0} = func;
1666 def BLX : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
1667 IIC_Br, "blx\t$func",
1668 [(ARMcall GPR:$func)]>,
1669 Requires<[IsARM, HasV5T, IsNotDarwin]> {
1671 let Inst{31-4} = 0b1110000100101111111111110011;
1672 let Inst{3-0} = func;
1675 def BLX_pred : AI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
1676 IIC_Br, "blx", "\t$func",
1677 [(ARMcall_pred GPR:$func)]>,
1678 Requires<[IsARM, HasV5T, IsNotDarwin]> {
1680 let Inst{27-4} = 0b000100101111111111110011;
1681 let Inst{3-0} = func;
1685 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
1686 def BX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func, variable_ops),
1687 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
1688 Requires<[IsARM, HasV4T, IsNotDarwin]>;
1691 def BMOVPCRX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func, variable_ops),
1692 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
1693 Requires<[IsARM, NoV4T, IsNotDarwin]>;
1697 // On Darwin R9 is call-clobbered.
1698 // R7 is marked as a use to prevent frame-pointer assignments from being
1699 // moved above / below calls.
1700 Defs = [R0, R1, R2, R3, R9, R12, LR, QQQQ0, QQQQ2, QQQQ3, CPSR, FPSCR],
1701 Uses = [R7, SP] in {
1702 def BLr9 : ARMPseudoExpand<(outs), (ins bl_target:$func, variable_ops),
1704 [(ARMcall tglobaladdr:$func)], (BL bl_target:$func)>,
1705 Requires<[IsARM, IsDarwin]>;
1707 def BLr9_pred : ARMPseudoExpand<(outs),
1708 (ins bl_target:$func, pred:$p, variable_ops),
1710 [(ARMcall_pred tglobaladdr:$func)],
1711 (BL_pred bl_target:$func, pred:$p)>,
1712 Requires<[IsARM, IsDarwin]>;
1715 def BLXr9 : ARMPseudoExpand<(outs), (ins GPR:$func, variable_ops),
1717 [(ARMcall GPR:$func)],
1719 Requires<[IsARM, HasV5T, IsDarwin]>;
1721 def BLXr9_pred: ARMPseudoExpand<(outs), (ins GPR:$func, pred:$p,variable_ops),
1723 [(ARMcall_pred GPR:$func)],
1724 (BLX_pred GPR:$func, pred:$p)>,
1725 Requires<[IsARM, HasV5T, IsDarwin]>;
1728 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
1729 def BXr9_CALL : ARMPseudoInst<(outs), (ins tGPR:$func, variable_ops),
1730 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
1731 Requires<[IsARM, HasV4T, IsDarwin]>;
1734 def BMOVPCRXr9_CALL : ARMPseudoInst<(outs), (ins tGPR:$func, variable_ops),
1735 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
1736 Requires<[IsARM, NoV4T, IsDarwin]>;
1739 let isBranch = 1, isTerminator = 1 in {
1740 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
1741 // a two-value operand where a dag node expects two operands. :(
1742 def Bcc : ABI<0b1010, (outs), (ins br_target:$target),
1743 IIC_Br, "b", "\t$target",
1744 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]> {
1746 let Inst{23-0} = target;
1747 let DecoderMethod = "DecodeBranchImmInstruction";
1750 let isBarrier = 1 in {
1751 // B is "predicable" since it's just a Bcc with an 'always' condition.
1752 let isPredicable = 1 in
1753 // FIXME: We shouldn't need this pseudo at all. Just using Bcc directly
1754 // should be sufficient.
1755 // FIXME: Is B really a Barrier? That doesn't seem right.
1756 def B : ARMPseudoExpand<(outs), (ins br_target:$target), 4, IIC_Br,
1757 [(br bb:$target)], (Bcc br_target:$target, (ops 14, zero_reg))>;
1759 let isNotDuplicable = 1, isIndirectBranch = 1 in {
1760 def BR_JTr : ARMPseudoInst<(outs),
1761 (ins GPR:$target, i32imm:$jt, i32imm:$id),
1763 [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]>;
1764 // FIXME: This shouldn't use the generic "addrmode2," but rather be split
1765 // into i12 and rs suffixed versions.
1766 def BR_JTm : ARMPseudoInst<(outs),
1767 (ins addrmode2:$target, i32imm:$jt, i32imm:$id),
1769 [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
1771 def BR_JTadd : ARMPseudoInst<(outs),
1772 (ins GPR:$target, GPR:$idx, i32imm:$jt, i32imm:$id),
1774 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
1776 } // isNotDuplicable = 1, isIndirectBranch = 1
1782 def BLXi : AXI<(outs), (ins br_target:$target), BrMiscFrm, NoItinerary,
1783 "blx\t$target", []>,
1784 Requires<[IsARM, HasV5T]> {
1785 let Inst{31-25} = 0b1111101;
1787 let Inst{23-0} = target{24-1};
1788 let Inst{24} = target{0};
1791 // Branch and Exchange Jazelle
1792 def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func",
1793 [/* pattern left blank */]> {
1795 let Inst{23-20} = 0b0010;
1796 let Inst{19-8} = 0xfff;
1797 let Inst{7-4} = 0b0010;
1798 let Inst{3-0} = func;
1803 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in {
1805 let Defs = [R0, R1, R2, R3, R9, R12, QQQQ0, QQQQ2, QQQQ3, PC],
1807 def TCRETURNdi : PseudoInst<(outs), (ins i32imm:$dst, variable_ops),
1808 IIC_Br, []>, Requires<[IsDarwin]>;
1810 def TCRETURNri : PseudoInst<(outs), (ins tcGPR:$dst, variable_ops),
1811 IIC_Br, []>, Requires<[IsDarwin]>;
1813 def TAILJMPd : ARMPseudoExpand<(outs), (ins br_target:$dst, variable_ops),
1815 (Bcc br_target:$dst, (ops 14, zero_reg))>,
1816 Requires<[IsARM, IsDarwin]>;
1818 def TAILJMPr : ARMPseudoExpand<(outs), (ins tcGPR:$dst, variable_ops),
1821 Requires<[IsARM, IsDarwin]>;
1825 // Non-Darwin versions (the difference is R9).
1826 let Defs = [R0, R1, R2, R3, R12, QQQQ0, QQQQ2, QQQQ3, PC],
1828 def TCRETURNdiND : PseudoInst<(outs), (ins i32imm:$dst, variable_ops),
1829 IIC_Br, []>, Requires<[IsNotDarwin]>;
1831 def TCRETURNriND : PseudoInst<(outs), (ins tcGPR:$dst, variable_ops),
1832 IIC_Br, []>, Requires<[IsNotDarwin]>;
1834 def TAILJMPdND : ARMPseudoExpand<(outs), (ins brtarget:$dst, variable_ops),
1836 (Bcc br_target:$dst, (ops 14, zero_reg))>,
1837 Requires<[IsARM, IsNotDarwin]>;
1839 def TAILJMPrND : ARMPseudoExpand<(outs), (ins tcGPR:$dst, variable_ops),
1842 Requires<[IsARM, IsNotDarwin]>;
1846 // Secure Monitor Call is a system instruction.
1847 def SMC : ABI<0b0001, (outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt",
1850 let Inst{23-4} = 0b01100000000000000111;
1851 let Inst{3-0} = opt;
1854 // Supervisor Call (Software Interrupt)
1855 let isCall = 1, Uses = [SP] in {
1856 def SVC : ABI<0b1111, (outs), (ins imm24b:$svc), IIC_Br, "svc", "\t$svc", []> {
1858 let Inst{23-0} = svc;
1862 // Store Return State
1863 class SRSI<bit wb, string asm>
1864 : XI<(outs), (ins imm0_31:$mode), AddrModeNone, 4, IndexModeNone, BrFrm,
1865 NoItinerary, asm, "", []> {
1867 let Inst{31-28} = 0b1111;
1868 let Inst{27-25} = 0b100;
1872 let Inst{19-16} = 0b1101; // SP
1873 let Inst{15-5} = 0b00000101000;
1874 let Inst{4-0} = mode;
1877 def SRSDA : SRSI<0, "srsda\tsp, $mode"> {
1878 let Inst{24-23} = 0;
1880 def SRSDA_UPD : SRSI<1, "srsda\tsp!, $mode"> {
1881 let Inst{24-23} = 0;
1883 def SRSDB : SRSI<0, "srsdb\tsp, $mode"> {
1884 let Inst{24-23} = 0b10;
1886 def SRSDB_UPD : SRSI<1, "srsdb\tsp!, $mode"> {
1887 let Inst{24-23} = 0b10;
1889 def SRSIA : SRSI<0, "srsia\tsp, $mode"> {
1890 let Inst{24-23} = 0b01;
1892 def SRSIA_UPD : SRSI<1, "srsia\tsp!, $mode"> {
1893 let Inst{24-23} = 0b01;
1895 def SRSIB : SRSI<0, "srsib\tsp, $mode"> {
1896 let Inst{24-23} = 0b11;
1898 def SRSIB_UPD : SRSI<1, "srsib\tsp!, $mode"> {
1899 let Inst{24-23} = 0b11;
1902 // Return From Exception
1903 class RFEI<bit wb, string asm>
1904 : XI<(outs), (ins GPR:$Rn), AddrModeNone, 4, IndexModeNone, BrFrm,
1905 NoItinerary, asm, "", []> {
1907 let Inst{31-28} = 0b1111;
1908 let Inst{27-25} = 0b100;
1912 let Inst{19-16} = Rn;
1913 let Inst{15-0} = 0xa00;
1916 def RFEDA : RFEI<0, "rfeda\t$Rn"> {
1917 let Inst{24-23} = 0;
1919 def RFEDA_UPD : RFEI<1, "rfeda\t$Rn!"> {
1920 let Inst{24-23} = 0;
1922 def RFEDB : RFEI<0, "rfedb\t$Rn"> {
1923 let Inst{24-23} = 0b10;
1925 def RFEDB_UPD : RFEI<1, "rfedb\t$Rn!"> {
1926 let Inst{24-23} = 0b10;
1928 def RFEIA : RFEI<0, "rfeia\t$Rn"> {
1929 let Inst{24-23} = 0b01;
1931 def RFEIA_UPD : RFEI<1, "rfeia\t$Rn!"> {
1932 let Inst{24-23} = 0b01;
1934 def RFEIB : RFEI<0, "rfeib\t$Rn"> {
1935 let Inst{24-23} = 0b11;
1937 def RFEIB_UPD : RFEI<1, "rfeib\t$Rn!"> {
1938 let Inst{24-23} = 0b11;
1941 //===----------------------------------------------------------------------===//
1942 // Load / store Instructions.
1948 defm LDR : AI_ldr1<0, "ldr", IIC_iLoad_r, IIC_iLoad_si,
1949 UnOpFrag<(load node:$Src)>>;
1950 defm LDRB : AI_ldr1nopc<1, "ldrb", IIC_iLoad_bh_r, IIC_iLoad_bh_si,
1951 UnOpFrag<(zextloadi8 node:$Src)>>;
1952 defm STR : AI_str1<0, "str", IIC_iStore_r, IIC_iStore_si,
1953 BinOpFrag<(store node:$LHS, node:$RHS)>>;
1954 defm STRB : AI_str1nopc<1, "strb", IIC_iStore_bh_r, IIC_iStore_bh_si,
1955 BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
1957 // Special LDR for loads from non-pc-relative constpools.
1958 let canFoldAsLoad = 1, mayLoad = 1, neverHasSideEffects = 1,
1959 isReMaterializable = 1, isCodeGenOnly = 1 in
1960 def LDRcp : AI2ldst<0b010, 1, 0, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
1961 AddrMode_i12, LdFrm, IIC_iLoad_r, "ldr", "\t$Rt, $addr",
1965 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1966 let Inst{19-16} = 0b1111;
1967 let Inst{15-12} = Rt;
1968 let Inst{11-0} = addr{11-0}; // imm12
1971 // Loads with zero extension
1972 def LDRH : AI3ld<0b1011, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
1973 IIC_iLoad_bh_r, "ldrh", "\t$Rt, $addr",
1974 [(set GPR:$Rt, (zextloadi16 addrmode3:$addr))]>;
1976 // Loads with sign extension
1977 def LDRSH : AI3ld<0b1111, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
1978 IIC_iLoad_bh_r, "ldrsh", "\t$Rt, $addr",
1979 [(set GPR:$Rt, (sextloadi16 addrmode3:$addr))]>;
1981 def LDRSB : AI3ld<0b1101, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
1982 IIC_iLoad_bh_r, "ldrsb", "\t$Rt, $addr",
1983 [(set GPR:$Rt, (sextloadi8 addrmode3:$addr))]>;
1985 let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1 in {
1987 def LDRD : AI3ld<0b1101, 0, (outs GPR:$Rd, GPR:$dst2),
1988 (ins addrmode3:$addr), LdMiscFrm,
1989 IIC_iLoad_d_r, "ldrd", "\t$Rd, $dst2, $addr",
1990 []>, Requires<[IsARM, HasV5TE]>;
1994 multiclass AI2_ldridx<bit isByte, string opc, InstrItinClass itin> {
1995 def _PRE : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
1996 (ins addrmode2:$addr), IndexModePre, LdFrm, itin,
1997 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2003 let Inst{25} = addr{13};
2004 let Inst{23} = addr{12};
2005 let Inst{19-16} = addr{17-14};
2006 let Inst{11-0} = addr{11-0};
2007 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2008 let AsmMatchConverter = "cvtLdWriteBackRegAddrMode2";
2011 def _POST_REG : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2012 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2013 IndexModePost, LdFrm, itin,
2014 opc, "\t$Rt, $addr, $offset",
2015 "$addr.base = $Rn_wb", []> {
2021 let Inst{23} = offset{12};
2022 let Inst{19-16} = addr;
2023 let Inst{11-0} = offset{11-0};
2025 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2028 def _POST_IMM : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2029 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2030 IndexModePost, LdFrm, itin,
2031 opc, "\t$Rt, $addr, $offset",
2032 "$addr.base = $Rn_wb", []> {
2038 let Inst{23} = offset{12};
2039 let Inst{19-16} = addr;
2040 let Inst{11-0} = offset{11-0};
2042 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2047 let mayLoad = 1, neverHasSideEffects = 1 in {
2048 defm LDR : AI2_ldridx<0, "ldr", IIC_iLoad_ru>;
2049 defm LDRB : AI2_ldridx<1, "ldrb", IIC_iLoad_bh_ru>;
2052 multiclass AI3_ldridx<bits<4> op, string opc, InstrItinClass itin> {
2053 def _PRE : AI3ldstidx<op, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2054 (ins addrmode3:$addr), IndexModePre,
2056 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2058 let Inst{23} = addr{8}; // U bit
2059 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2060 let Inst{19-16} = addr{12-9}; // Rn
2061 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2062 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2063 let AsmMatchConverter = "cvtLdWriteBackRegAddrMode3";
2065 def _POST : AI3ldstidx<op, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2066 (ins addr_offset_none:$addr, am3offset:$offset),
2067 IndexModePost, LdMiscFrm, itin,
2068 opc, "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2072 let Inst{23} = offset{8}; // U bit
2073 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2074 let Inst{19-16} = addr;
2075 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2076 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2080 let mayLoad = 1, neverHasSideEffects = 1 in {
2081 defm LDRH : AI3_ldridx<0b1011, "ldrh", IIC_iLoad_bh_ru>;
2082 defm LDRSH : AI3_ldridx<0b1111, "ldrsh", IIC_iLoad_bh_ru>;
2083 defm LDRSB : AI3_ldridx<0b1101, "ldrsb", IIC_iLoad_bh_ru>;
2084 let hasExtraDefRegAllocReq = 1 in {
2085 def LDRD_PRE : AI3ldstidx<0b1101, 0, 1, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2086 (ins addrmode3:$addr), IndexModePre,
2087 LdMiscFrm, IIC_iLoad_d_ru,
2088 "ldrd", "\t$Rt, $Rt2, $addr!",
2089 "$addr.base = $Rn_wb", []> {
2091 let Inst{23} = addr{8}; // U bit
2092 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2093 let Inst{19-16} = addr{12-9}; // Rn
2094 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2095 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2096 let DecoderMethod = "DecodeAddrMode3Instruction";
2097 let AsmMatchConverter = "cvtLdrdPre";
2099 def LDRD_POST: AI3ldstidx<0b1101, 0, 0, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2100 (ins addr_offset_none:$addr, am3offset:$offset),
2101 IndexModePost, LdMiscFrm, IIC_iLoad_d_ru,
2102 "ldrd", "\t$Rt, $Rt2, $addr, $offset",
2103 "$addr.base = $Rn_wb", []> {
2106 let Inst{23} = offset{8}; // U bit
2107 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2108 let Inst{19-16} = addr;
2109 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2110 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2111 let DecoderMethod = "DecodeAddrMode3Instruction";
2113 } // hasExtraDefRegAllocReq = 1
2114 } // mayLoad = 1, neverHasSideEffects = 1
2116 // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT.
2117 let mayLoad = 1, neverHasSideEffects = 1 in {
2118 def LDRT_POST_REG : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2119 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2120 IndexModePost, LdFrm, IIC_iLoad_ru,
2121 "ldrt", "\t$Rt, $addr, $offset",
2122 "$addr.base = $Rn_wb", []> {
2128 let Inst{23} = offset{12};
2129 let Inst{21} = 1; // overwrite
2130 let Inst{19-16} = addr;
2131 let Inst{11-5} = offset{11-5};
2133 let Inst{3-0} = offset{3-0};
2134 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2137 def LDRT_POST_IMM : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2138 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2139 IndexModePost, LdFrm, IIC_iLoad_ru,
2140 "ldrt", "\t$Rt, $addr, $offset",
2141 "$addr.base = $Rn_wb", []> {
2147 let Inst{23} = offset{12};
2148 let Inst{21} = 1; // overwrite
2149 let Inst{19-16} = addr;
2150 let Inst{11-0} = offset{11-0};
2151 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2154 def LDRBT_POST_REG : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2155 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2156 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2157 "ldrbt", "\t$Rt, $addr, $offset",
2158 "$addr.base = $Rn_wb", []> {
2164 let Inst{23} = offset{12};
2165 let Inst{21} = 1; // overwrite
2166 let Inst{19-16} = addr;
2167 let Inst{11-0} = offset{11-0};
2168 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2171 def LDRBT_POST_IMM : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2172 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2173 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2174 "ldrbt", "\t$Rt, $addr, $offset",
2175 "$addr.base = $Rn_wb", []> {
2181 let Inst{23} = offset{12};
2182 let Inst{21} = 1; // overwrite
2183 let Inst{19-16} = addr;
2184 let Inst{11-0} = offset{11-0};
2185 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2188 multiclass AI3ldrT<bits<4> op, string opc> {
2189 def i : AI3ldstidxT<op, 1, (outs GPR:$Rt, GPR:$base_wb),
2190 (ins addr_offset_none:$addr, postidx_imm8:$offset),
2191 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2192 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2194 let Inst{23} = offset{8};
2196 let Inst{11-8} = offset{7-4};
2197 let Inst{3-0} = offset{3-0};
2198 let AsmMatchConverter = "cvtLdExtTWriteBackImm";
2200 def r : AI3ldstidxT<op, 1, (outs GPR:$Rt, GPR:$base_wb),
2201 (ins addr_offset_none:$addr, postidx_reg:$Rm),
2202 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2203 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2205 let Inst{23} = Rm{4};
2208 let Inst{3-0} = Rm{3-0};
2209 let AsmMatchConverter = "cvtLdExtTWriteBackReg";
2213 defm LDRSBT : AI3ldrT<0b1101, "ldrsbt">;
2214 defm LDRHT : AI3ldrT<0b1011, "ldrht">;
2215 defm LDRSHT : AI3ldrT<0b1111, "ldrsht">;
2220 // Stores with truncate
2221 def STRH : AI3str<0b1011, (outs), (ins GPR:$Rt, addrmode3:$addr), StMiscFrm,
2222 IIC_iStore_bh_r, "strh", "\t$Rt, $addr",
2223 [(truncstorei16 GPR:$Rt, addrmode3:$addr)]>;
2226 let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in
2227 def STRD : AI3str<0b1111, (outs), (ins GPR:$Rt, GPR:$src2, addrmode3:$addr),
2228 StMiscFrm, IIC_iStore_d_r,
2229 "strd", "\t$Rt, $src2, $addr", []>,
2230 Requires<[IsARM, HasV5TE]> {
2235 multiclass AI2_stridx<bit isByte, string opc, InstrItinClass itin> {
2236 def _PRE_IMM : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2237 (ins GPR:$Rt, addrmode_imm12:$addr), IndexModePre,
2239 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2242 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2243 let Inst{19-16} = addr{16-13}; // Rn
2244 let Inst{11-0} = addr{11-0}; // imm12
2245 let AsmMatchConverter = "cvtStWriteBackRegAddrModeImm12";
2248 def _PRE_REG : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2249 (ins GPR:$Rt, ldst_so_reg:$addr),
2250 IndexModePre, StFrm, itin,
2251 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2254 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2255 let Inst{19-16} = addr{16-13}; // Rn
2256 let Inst{11-0} = addr{11-0};
2257 let Inst{4} = 0; // Inst{4} = 0
2258 let AsmMatchConverter = "cvtStWriteBackRegAddrMode2";
2260 def _POST_REG : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2261 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2262 IndexModePost, StFrm, itin,
2263 opc, "\t$Rt, $addr, $offset",
2264 "$addr.base = $Rn_wb", []> {
2270 let Inst{23} = offset{12};
2271 let Inst{19-16} = addr;
2272 let Inst{11-0} = offset{11-0};
2274 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2277 def _POST_IMM : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2278 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2279 IndexModePost, StFrm, itin,
2280 opc, "\t$Rt, $addr, $offset",
2281 "$addr.base = $Rn_wb", []> {
2287 let Inst{23} = offset{12};
2288 let Inst{19-16} = addr;
2289 let Inst{11-0} = offset{11-0};
2291 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2295 let mayStore = 1, neverHasSideEffects = 1 in {
2296 defm STR : AI2_stridx<0, "str", IIC_iStore_ru>;
2297 defm STRB : AI2_stridx<1, "strb", IIC_iStore_bh_ru>;
2300 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2301 am2offset_reg:$offset),
2302 (STR_POST_REG GPR:$Rt, addr_offset_none:$addr,
2303 am2offset_reg:$offset)>;
2304 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2305 am2offset_imm:$offset),
2306 (STR_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2307 am2offset_imm:$offset)>;
2308 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2309 am2offset_reg:$offset),
2310 (STRB_POST_REG GPR:$Rt, addr_offset_none:$addr,
2311 am2offset_reg:$offset)>;
2312 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2313 am2offset_imm:$offset),
2314 (STRB_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2315 am2offset_imm:$offset)>;
2317 // Pseudo-instructions for pattern matching the pre-indexed stores. We can't
2318 // put the patterns on the instruction definitions directly as ISel wants
2319 // the address base and offset to be separate operands, not a single
2320 // complex operand like we represent the instructions themselves. The
2321 // pseudos map between the two.
2322 let usesCustomInserter = 1,
2323 Constraints = "$Rn = $Rn_wb,@earlyclobber $Rn_wb" in {
2324 def STRi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2325 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2328 (pre_store GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2329 def STRr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2330 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2333 (pre_store GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2334 def STRBi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2335 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2338 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2339 def STRBr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2340 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2343 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2344 def STRH_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2345 (ins GPR:$Rt, GPR:$Rn, am3offset:$offset, pred:$p),
2348 (pre_truncsti16 GPR:$Rt, GPR:$Rn, am3offset:$offset))]>;
2353 def STRH_PRE : AI3ldstidx<0b1011, 0, 1, (outs GPR:$Rn_wb),
2354 (ins GPR:$Rt, addrmode3:$addr), IndexModePre,
2355 StMiscFrm, IIC_iStore_bh_ru,
2356 "strh", "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2358 let Inst{23} = addr{8}; // U bit
2359 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2360 let Inst{19-16} = addr{12-9}; // Rn
2361 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2362 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2363 let AsmMatchConverter = "cvtStWriteBackRegAddrMode3";
2366 def STRH_POST : AI3ldstidx<0b1011, 0, 0, (outs GPR:$Rn_wb),
2367 (ins GPR:$Rt, addr_offset_none:$addr, am3offset:$offset),
2368 IndexModePost, StMiscFrm, IIC_iStore_bh_ru,
2369 "strh", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2370 [(set GPR:$Rn_wb, (post_truncsti16 GPR:$Rt,
2371 addr_offset_none:$addr,
2372 am3offset:$offset))]> {
2375 let Inst{23} = offset{8}; // U bit
2376 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2377 let Inst{19-16} = addr;
2378 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2379 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2382 let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in {
2383 def STRD_PRE : AI3ldstidx<0b1111, 0, 1, (outs GPR:$Rn_wb),
2384 (ins GPR:$Rt, GPR:$Rt2, addrmode3:$addr),
2385 IndexModePre, StMiscFrm, IIC_iStore_d_ru,
2386 "strd", "\t$Rt, $Rt2, $addr!",
2387 "$addr.base = $Rn_wb", []> {
2389 let Inst{23} = addr{8}; // U bit
2390 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2391 let Inst{19-16} = addr{12-9}; // Rn
2392 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2393 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2394 let DecoderMethod = "DecodeAddrMode3Instruction";
2395 let AsmMatchConverter = "cvtStrdPre";
2398 def STRD_POST: AI3ldstidx<0b1111, 0, 0, (outs GPR:$Rn_wb),
2399 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr,
2401 IndexModePost, StMiscFrm, IIC_iStore_d_ru,
2402 "strd", "\t$Rt, $Rt2, $addr, $offset",
2403 "$addr.base = $Rn_wb", []> {
2406 let Inst{23} = offset{8}; // U bit
2407 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2408 let Inst{19-16} = addr;
2409 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2410 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2411 let DecoderMethod = "DecodeAddrMode3Instruction";
2413 } // mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1
2415 // STRT, STRBT, and STRHT
2417 def STRBT_POST_REG : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2418 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2419 IndexModePost, StFrm, IIC_iStore_bh_ru,
2420 "strbt", "\t$Rt, $addr, $offset",
2421 "$addr.base = $Rn_wb", []> {
2427 let Inst{23} = offset{12};
2428 let Inst{21} = 1; // overwrite
2429 let Inst{19-16} = addr;
2430 let Inst{11-5} = offset{11-5};
2432 let Inst{3-0} = offset{3-0};
2433 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2436 def STRBT_POST_IMM : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2437 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2438 IndexModePost, StFrm, IIC_iStore_bh_ru,
2439 "strbt", "\t$Rt, $addr, $offset",
2440 "$addr.base = $Rn_wb", []> {
2446 let Inst{23} = offset{12};
2447 let Inst{21} = 1; // overwrite
2448 let Inst{19-16} = addr;
2449 let Inst{11-0} = offset{11-0};
2450 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2453 let mayStore = 1, neverHasSideEffects = 1 in {
2454 def STRT_POST_REG : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
2455 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2456 IndexModePost, StFrm, IIC_iStore_ru,
2457 "strt", "\t$Rt, $addr, $offset",
2458 "$addr.base = $Rn_wb", []> {
2464 let Inst{23} = offset{12};
2465 let Inst{21} = 1; // overwrite
2466 let Inst{19-16} = addr;
2467 let Inst{11-5} = offset{11-5};
2469 let Inst{3-0} = offset{3-0};
2470 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2473 def STRT_POST_IMM : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
2474 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2475 IndexModePost, StFrm, IIC_iStore_ru,
2476 "strt", "\t$Rt, $addr, $offset",
2477 "$addr.base = $Rn_wb", []> {
2483 let Inst{23} = offset{12};
2484 let Inst{21} = 1; // overwrite
2485 let Inst{19-16} = addr;
2486 let Inst{11-0} = offset{11-0};
2487 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2492 multiclass AI3strT<bits<4> op, string opc> {
2493 def i : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
2494 (ins GPR:$Rt, addr_offset_none:$addr, postidx_imm8:$offset),
2495 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
2496 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2498 let Inst{23} = offset{8};
2500 let Inst{11-8} = offset{7-4};
2501 let Inst{3-0} = offset{3-0};
2502 let AsmMatchConverter = "cvtStExtTWriteBackImm";
2504 def r : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
2505 (ins GPR:$Rt, addr_offset_none:$addr, postidx_reg:$Rm),
2506 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
2507 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2509 let Inst{23} = Rm{4};
2512 let Inst{3-0} = Rm{3-0};
2513 let AsmMatchConverter = "cvtStExtTWriteBackReg";
2518 defm STRHT : AI3strT<0b1011, "strht">;
2521 //===----------------------------------------------------------------------===//
2522 // Load / store multiple Instructions.
2525 multiclass arm_ldst_mult<string asm, bit L_bit, Format f,
2526 InstrItinClass itin, InstrItinClass itin_upd> {
2527 // IA is the default, so no need for an explicit suffix on the
2528 // mnemonic here. Without it is the cannonical spelling.
2530 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2531 IndexModeNone, f, itin,
2532 !strconcat(asm, "${p}\t$Rn, $regs"), "", []> {
2533 let Inst{24-23} = 0b01; // Increment After
2534 let Inst{21} = 0; // No writeback
2535 let Inst{20} = L_bit;
2538 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2539 IndexModeUpd, f, itin_upd,
2540 !strconcat(asm, "${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
2541 let Inst{24-23} = 0b01; // Increment After
2542 let Inst{21} = 1; // Writeback
2543 let Inst{20} = L_bit;
2545 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2548 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2549 IndexModeNone, f, itin,
2550 !strconcat(asm, "da${p}\t$Rn, $regs"), "", []> {
2551 let Inst{24-23} = 0b00; // Decrement After
2552 let Inst{21} = 0; // No writeback
2553 let Inst{20} = L_bit;
2556 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2557 IndexModeUpd, f, itin_upd,
2558 !strconcat(asm, "da${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
2559 let Inst{24-23} = 0b00; // Decrement After
2560 let Inst{21} = 1; // Writeback
2561 let Inst{20} = L_bit;
2563 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2566 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2567 IndexModeNone, f, itin,
2568 !strconcat(asm, "db${p}\t$Rn, $regs"), "", []> {
2569 let Inst{24-23} = 0b10; // Decrement Before
2570 let Inst{21} = 0; // No writeback
2571 let Inst{20} = L_bit;
2574 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2575 IndexModeUpd, f, itin_upd,
2576 !strconcat(asm, "db${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
2577 let Inst{24-23} = 0b10; // Decrement Before
2578 let Inst{21} = 1; // Writeback
2579 let Inst{20} = L_bit;
2581 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2584 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2585 IndexModeNone, f, itin,
2586 !strconcat(asm, "ib${p}\t$Rn, $regs"), "", []> {
2587 let Inst{24-23} = 0b11; // Increment Before
2588 let Inst{21} = 0; // No writeback
2589 let Inst{20} = L_bit;
2592 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2593 IndexModeUpd, f, itin_upd,
2594 !strconcat(asm, "ib${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
2595 let Inst{24-23} = 0b11; // Increment Before
2596 let Inst{21} = 1; // Writeback
2597 let Inst{20} = L_bit;
2599 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2603 let neverHasSideEffects = 1 in {
2605 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
2606 defm LDM : arm_ldst_mult<"ldm", 1, LdStMulFrm, IIC_iLoad_m, IIC_iLoad_mu>;
2608 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
2609 defm STM : arm_ldst_mult<"stm", 0, LdStMulFrm, IIC_iStore_m, IIC_iStore_mu>;
2611 } // neverHasSideEffects
2613 // FIXME: remove when we have a way to marking a MI with these properties.
2614 // FIXME: Should pc be an implicit operand like PICADD, etc?
2615 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
2616 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
2617 def LDMIA_RET : ARMPseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p,
2618 reglist:$regs, variable_ops),
2619 4, IIC_iLoad_mBr, [],
2620 (LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>,
2621 RegConstraint<"$Rn = $wb">;
2623 //===----------------------------------------------------------------------===//
2624 // Move Instructions.
2627 let neverHasSideEffects = 1 in
2628 def MOVr : AsI1<0b1101, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMOVr,
2629 "mov", "\t$Rd, $Rm", []>, UnaryDP {
2633 let Inst{19-16} = 0b0000;
2634 let Inst{11-4} = 0b00000000;
2637 let Inst{15-12} = Rd;
2640 // A version for the smaller set of tail call registers.
2641 let neverHasSideEffects = 1 in
2642 def MOVr_TC : AsI1<0b1101, (outs tcGPR:$Rd), (ins tcGPR:$Rm), DPFrm,
2643 IIC_iMOVr, "mov", "\t$Rd, $Rm", []>, UnaryDP {
2647 let Inst{11-4} = 0b00000000;
2650 let Inst{15-12} = Rd;
2653 def MOVsr : AsI1<0b1101, (outs GPRnopc:$Rd), (ins shift_so_reg_reg:$src),
2654 DPSoRegRegFrm, IIC_iMOVsr,
2655 "mov", "\t$Rd, $src",
2656 [(set GPRnopc:$Rd, shift_so_reg_reg:$src)]>, UnaryDP {
2659 let Inst{15-12} = Rd;
2660 let Inst{19-16} = 0b0000;
2661 let Inst{11-8} = src{11-8};
2663 let Inst{6-5} = src{6-5};
2665 let Inst{3-0} = src{3-0};
2669 def MOVsi : AsI1<0b1101, (outs GPR:$Rd), (ins shift_so_reg_imm:$src),
2670 DPSoRegImmFrm, IIC_iMOVsr,
2671 "mov", "\t$Rd, $src", [(set GPR:$Rd, shift_so_reg_imm:$src)]>,
2675 let Inst{15-12} = Rd;
2676 let Inst{19-16} = 0b0000;
2677 let Inst{11-5} = src{11-5};
2679 let Inst{3-0} = src{3-0};
2683 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
2684 def MOVi : AsI1<0b1101, (outs GPR:$Rd), (ins so_imm:$imm), DPFrm, IIC_iMOVi,
2685 "mov", "\t$Rd, $imm", [(set GPR:$Rd, so_imm:$imm)]>, UnaryDP {
2689 let Inst{15-12} = Rd;
2690 let Inst{19-16} = 0b0000;
2691 let Inst{11-0} = imm;
2694 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
2695 def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins imm0_65535_expr:$imm),
2697 "movw", "\t$Rd, $imm",
2698 [(set GPR:$Rd, imm0_65535:$imm)]>,
2699 Requires<[IsARM, HasV6T2]>, UnaryDP {
2702 let Inst{15-12} = Rd;
2703 let Inst{11-0} = imm{11-0};
2704 let Inst{19-16} = imm{15-12};
2709 def : InstAlias<"mov${p} $Rd, $imm",
2710 (MOVi16 GPR:$Rd, imm0_65535_expr:$imm, pred:$p)>,
2713 def MOVi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
2714 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>;
2716 let Constraints = "$src = $Rd" in {
2717 def MOVTi16 : AI1<0b1010, (outs GPRnopc:$Rd),
2718 (ins GPR:$src, imm0_65535_expr:$imm),
2720 "movt", "\t$Rd, $imm",
2722 (or (and GPR:$src, 0xffff),
2723 lo16AllZero:$imm))]>, UnaryDP,
2724 Requires<[IsARM, HasV6T2]> {
2727 let Inst{15-12} = Rd;
2728 let Inst{11-0} = imm{11-0};
2729 let Inst{19-16} = imm{15-12};
2734 def MOVTi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
2735 (ins GPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>;
2739 def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
2740 Requires<[IsARM, HasV6T2]>;
2742 let Uses = [CPSR] in
2743 def RRX: PseudoInst<(outs GPR:$Rd), (ins GPR:$Rm), IIC_iMOVsi,
2744 [(set GPR:$Rd, (ARMrrx GPR:$Rm))]>, UnaryDP,
2747 // These aren't really mov instructions, but we have to define them this way
2748 // due to flag operands.
2750 let Defs = [CPSR] in {
2751 def MOVsrl_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
2752 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP,
2754 def MOVsra_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
2755 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP,
2759 //===----------------------------------------------------------------------===//
2760 // Extend Instructions.
2765 def SXTB : AI_ext_rrot<0b01101010,
2766 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
2767 def SXTH : AI_ext_rrot<0b01101011,
2768 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
2770 def SXTAB : AI_exta_rrot<0b01101010,
2771 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
2772 def SXTAH : AI_exta_rrot<0b01101011,
2773 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
2775 def SXTB16 : AI_ext_rrot_np<0b01101000, "sxtb16">;
2777 def SXTAB16 : AI_exta_rrot_np<0b01101000, "sxtab16">;
2781 let AddedComplexity = 16 in {
2782 def UXTB : AI_ext_rrot<0b01101110,
2783 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
2784 def UXTH : AI_ext_rrot<0b01101111,
2785 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
2786 def UXTB16 : AI_ext_rrot<0b01101100,
2787 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
2789 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
2790 // The transformation should probably be done as a combiner action
2791 // instead so we can include a check for masking back in the upper
2792 // eight bits of the source into the lower eight bits of the result.
2793 //def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
2794 // (UXTB16r_rot GPR:$Src, 3)>;
2795 def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
2796 (UXTB16 GPR:$Src, 1)>;
2798 def UXTAB : AI_exta_rrot<0b01101110, "uxtab",
2799 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
2800 def UXTAH : AI_exta_rrot<0b01101111, "uxtah",
2801 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
2804 // This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
2805 def UXTAB16 : AI_exta_rrot_np<0b01101100, "uxtab16">;
2808 def SBFX : I<(outs GPRnopc:$Rd),
2809 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
2810 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
2811 "sbfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
2812 Requires<[IsARM, HasV6T2]> {
2817 let Inst{27-21} = 0b0111101;
2818 let Inst{6-4} = 0b101;
2819 let Inst{20-16} = width;
2820 let Inst{15-12} = Rd;
2821 let Inst{11-7} = lsb;
2825 def UBFX : I<(outs GPR:$Rd),
2826 (ins GPR:$Rn, imm0_31:$lsb, imm1_32:$width),
2827 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
2828 "ubfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
2829 Requires<[IsARM, HasV6T2]> {
2834 let Inst{27-21} = 0b0111111;
2835 let Inst{6-4} = 0b101;
2836 let Inst{20-16} = width;
2837 let Inst{15-12} = Rd;
2838 let Inst{11-7} = lsb;
2842 //===----------------------------------------------------------------------===//
2843 // Arithmetic Instructions.
2846 defm ADD : AsI1_bin_irs<0b0100, "add",
2847 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
2848 BinOpFrag<(add node:$LHS, node:$RHS)>, "ADD", 1>;
2849 defm SUB : AsI1_bin_irs<0b0010, "sub",
2850 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
2851 BinOpFrag<(sub node:$LHS, node:$RHS)>, "SUB">;
2853 // ADD and SUB with 's' bit set.
2854 defm ADDS : AI1_bin_s_irs<0b0100, "adds",
2855 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
2856 BinOpFrag<(addc node:$LHS, node:$RHS)>, 1>;
2857 defm SUBS : AI1_bin_s_irs<0b0010, "subs",
2858 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
2859 BinOpFrag<(subc node:$LHS, node:$RHS)>>;
2861 defm ADC : AI1_adde_sube_irs<0b0101, "adc",
2862 BinOpFrag<(adde_dead_carry node:$LHS, node:$RHS)>,
2864 defm SBC : AI1_adde_sube_irs<0b0110, "sbc",
2865 BinOpFrag<(sube_dead_carry node:$LHS, node:$RHS)>,
2868 // ADC and SUBC with 's' bit set.
2869 let usesCustomInserter = 1 in {
2870 defm ADCS : AI1_adde_sube_s_irs<
2871 BinOpFrag<(adde_live_carry node:$LHS, node:$RHS)>, 1>;
2872 defm SBCS : AI1_adde_sube_s_irs<
2873 BinOpFrag<(sube_live_carry node:$LHS, node:$RHS) >>;
2876 def RSBri : AsI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
2877 IIC_iALUi, "rsb", "\t$Rd, $Rn, $imm",
2878 [(set GPR:$Rd, (sub so_imm:$imm, GPR:$Rn))]> {
2883 let Inst{15-12} = Rd;
2884 let Inst{19-16} = Rn;
2885 let Inst{11-0} = imm;
2888 def RSBrr : AsI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
2889 IIC_iALUr, "rsb", "\t$Rd, $Rn, $Rm", []> {
2893 let Inst{11-4} = 0b00000000;
2896 let Inst{15-12} = Rd;
2897 let Inst{19-16} = Rn;
2900 def RSBrsi : AsI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_imm:$shift),
2901 DPSoRegImmFrm, IIC_iALUsr, "rsb", "\t$Rd, $Rn, $shift",
2902 [(set GPR:$Rd, (sub so_reg_imm:$shift, GPR:$Rn))]> {
2907 let Inst{19-16} = Rn;
2908 let Inst{15-12} = Rd;
2909 let Inst{11-5} = shift{11-5};
2911 let Inst{3-0} = shift{3-0};
2914 def RSBrsr : AsI1<0b0011, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_reg:$shift),
2915 DPSoRegRegFrm, IIC_iALUsr, "rsb", "\t$Rd, $Rn, $shift",
2916 [(set GPR:$Rd, (sub so_reg_reg:$shift, GPR:$Rn))]> {
2921 let Inst{19-16} = Rn;
2922 let Inst{15-12} = Rd;
2923 let Inst{11-8} = shift{11-8};
2925 let Inst{6-5} = shift{6-5};
2927 let Inst{3-0} = shift{3-0};
2930 // RSB with 's' bit set.
2931 // NOTE: CPSR def omitted because it will be handled by the custom inserter.
2932 let usesCustomInserter = 1 in {
2933 def RSBSri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
2935 [(set GPR:$Rd, (subc so_imm:$imm, GPR:$Rn))]>;
2936 def RSBSrr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2938 def RSBSrsi : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, so_reg_imm:$shift),
2940 [(set GPR:$Rd, (subc so_reg_imm:$shift, GPR:$Rn))]>;
2941 def RSBSrsr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, so_reg_reg:$shift),
2943 [(set GPR:$Rd, (subc so_reg_reg:$shift, GPR:$Rn))]>;
2946 let Uses = [CPSR] in {
2947 def RSCri : AsI1<0b0111, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
2948 DPFrm, IIC_iALUi, "rsc", "\t$Rd, $Rn, $imm",
2949 [(set GPR:$Rd, (sube_dead_carry so_imm:$imm, GPR:$Rn))]>,
2955 let Inst{15-12} = Rd;
2956 let Inst{19-16} = Rn;
2957 let Inst{11-0} = imm;
2959 def RSCrr : AsI1<0b0111, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
2960 DPFrm, IIC_iALUr, "rsc", "\t$Rd, $Rn, $Rm", []> {
2964 let Inst{11-4} = 0b00000000;
2967 let Inst{15-12} = Rd;
2968 let Inst{19-16} = Rn;
2970 def RSCrsi : AsI1<0b0111, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_imm:$shift),
2971 DPSoRegImmFrm, IIC_iALUsr, "rsc", "\t$Rd, $Rn, $shift",
2972 [(set GPR:$Rd, (sube_dead_carry so_reg_imm:$shift, GPR:$Rn))]>,
2978 let Inst{19-16} = Rn;
2979 let Inst{15-12} = Rd;
2980 let Inst{11-5} = shift{11-5};
2982 let Inst{3-0} = shift{3-0};
2984 def RSCrsr : AsI1<0b0111, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_reg:$shift),
2985 DPSoRegRegFrm, IIC_iALUsr, "rsc", "\t$Rd, $Rn, $shift",
2986 [(set GPR:$Rd, (sube_dead_carry so_reg_reg:$shift, GPR:$Rn))]>,
2992 let Inst{19-16} = Rn;
2993 let Inst{15-12} = Rd;
2994 let Inst{11-8} = shift{11-8};
2996 let Inst{6-5} = shift{6-5};
2998 let Inst{3-0} = shift{3-0};
3003 // NOTE: CPSR def omitted because it will be handled by the custom inserter.
3004 let usesCustomInserter = 1, Uses = [CPSR] in {
3005 def RSCSri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
3007 [(set GPR:$Rd, (sube_dead_carry so_imm:$imm, GPR:$Rn))]>;
3008 def RSCSrsi : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, so_reg_imm:$shift),
3010 [(set GPR:$Rd, (sube_dead_carry so_reg_imm:$shift, GPR:$Rn))]>;
3011 def RSCSrsr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, so_reg_reg:$shift),
3013 [(set GPR:$Rd, (sube_dead_carry so_reg_reg:$shift, GPR:$Rn))]>;
3016 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
3017 // The assume-no-carry-in form uses the negation of the input since add/sub
3018 // assume opposite meanings of the carry flag (i.e., carry == !borrow).
3019 // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
3021 def : ARMPat<(add GPR:$src, so_imm_neg:$imm),
3022 (SUBri GPR:$src, so_imm_neg:$imm)>;
3023 def : ARMPat<(addc GPR:$src, so_imm_neg:$imm),
3024 (SUBSri GPR:$src, so_imm_neg:$imm)>;
3025 // The with-carry-in form matches bitwise not instead of the negation.
3026 // Effectively, the inverse interpretation of the carry flag already accounts
3027 // for part of the negation.
3028 def : ARMPat<(adde_dead_carry GPR:$src, so_imm_not:$imm),
3029 (SBCri GPR:$src, so_imm_not:$imm)>;
3030 def : ARMPat<(adde_live_carry GPR:$src, so_imm_not:$imm),
3031 (SBCSri GPR:$src, so_imm_not:$imm)>;
3033 // Note: These are implemented in C++ code, because they have to generate
3034 // ADD/SUBrs instructions, which use a complex pattern that a xform function
3036 // (mul X, 2^n+1) -> (add (X << n), X)
3037 // (mul X, 2^n-1) -> (rsb X, (X << n))
3039 // ARM Arithmetic Instruction
3040 // GPR:$dst = GPR:$a op GPR:$b
3041 class AAI<bits<8> op27_20, bits<8> op11_4, string opc,
3042 list<dag> pattern = [],
3043 dag iops = (ins GPRnopc:$Rn, GPRnopc:$Rm),
3044 string asm = "\t$Rd, $Rn, $Rm">
3045 : AI<(outs GPRnopc:$Rd), iops, DPFrm, IIC_iALUr, opc, asm, pattern> {
3049 let Inst{27-20} = op27_20;
3050 let Inst{11-4} = op11_4;
3051 let Inst{19-16} = Rn;
3052 let Inst{15-12} = Rd;
3056 // Saturating add/subtract
3058 def QADD : AAI<0b00010000, 0b00000101, "qadd",
3059 [(set GPRnopc:$Rd, (int_arm_qadd GPRnopc:$Rm, GPRnopc:$Rn))],
3060 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3061 def QSUB : AAI<0b00010010, 0b00000101, "qsub",
3062 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm, GPRnopc:$Rn))],
3063 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3064 def QDADD : AAI<0b00010100, 0b00000101, "qdadd", [],
3065 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3067 def QDSUB : AAI<0b00010110, 0b00000101, "qdsub", [],
3068 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3071 def QADD16 : AAI<0b01100010, 0b11110001, "qadd16">;
3072 def QADD8 : AAI<0b01100010, 0b11111001, "qadd8">;
3073 def QASX : AAI<0b01100010, 0b11110011, "qasx">;
3074 def QSAX : AAI<0b01100010, 0b11110101, "qsax">;
3075 def QSUB16 : AAI<0b01100010, 0b11110111, "qsub16">;
3076 def QSUB8 : AAI<0b01100010, 0b11111111, "qsub8">;
3077 def UQADD16 : AAI<0b01100110, 0b11110001, "uqadd16">;
3078 def UQADD8 : AAI<0b01100110, 0b11111001, "uqadd8">;
3079 def UQASX : AAI<0b01100110, 0b11110011, "uqasx">;
3080 def UQSAX : AAI<0b01100110, 0b11110101, "uqsax">;
3081 def UQSUB16 : AAI<0b01100110, 0b11110111, "uqsub16">;
3082 def UQSUB8 : AAI<0b01100110, 0b11111111, "uqsub8">;
3084 // Signed/Unsigned add/subtract
3086 def SASX : AAI<0b01100001, 0b11110011, "sasx">;
3087 def SADD16 : AAI<0b01100001, 0b11110001, "sadd16">;
3088 def SADD8 : AAI<0b01100001, 0b11111001, "sadd8">;
3089 def SSAX : AAI<0b01100001, 0b11110101, "ssax">;
3090 def SSUB16 : AAI<0b01100001, 0b11110111, "ssub16">;
3091 def SSUB8 : AAI<0b01100001, 0b11111111, "ssub8">;
3092 def UASX : AAI<0b01100101, 0b11110011, "uasx">;
3093 def UADD16 : AAI<0b01100101, 0b11110001, "uadd16">;
3094 def UADD8 : AAI<0b01100101, 0b11111001, "uadd8">;
3095 def USAX : AAI<0b01100101, 0b11110101, "usax">;
3096 def USUB16 : AAI<0b01100101, 0b11110111, "usub16">;
3097 def USUB8 : AAI<0b01100101, 0b11111111, "usub8">;
3099 // Signed/Unsigned halving add/subtract
3101 def SHASX : AAI<0b01100011, 0b11110011, "shasx">;
3102 def SHADD16 : AAI<0b01100011, 0b11110001, "shadd16">;
3103 def SHADD8 : AAI<0b01100011, 0b11111001, "shadd8">;
3104 def SHSAX : AAI<0b01100011, 0b11110101, "shsax">;
3105 def SHSUB16 : AAI<0b01100011, 0b11110111, "shsub16">;
3106 def SHSUB8 : AAI<0b01100011, 0b11111111, "shsub8">;
3107 def UHASX : AAI<0b01100111, 0b11110011, "uhasx">;
3108 def UHADD16 : AAI<0b01100111, 0b11110001, "uhadd16">;
3109 def UHADD8 : AAI<0b01100111, 0b11111001, "uhadd8">;
3110 def UHSAX : AAI<0b01100111, 0b11110101, "uhsax">;
3111 def UHSUB16 : AAI<0b01100111, 0b11110111, "uhsub16">;
3112 def UHSUB8 : AAI<0b01100111, 0b11111111, "uhsub8">;
3114 // Unsigned Sum of Absolute Differences [and Accumulate].
3116 def USAD8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3117 MulFrm /* for convenience */, NoItinerary, "usad8",
3118 "\t$Rd, $Rn, $Rm", []>,
3119 Requires<[IsARM, HasV6]> {
3123 let Inst{27-20} = 0b01111000;
3124 let Inst{15-12} = 0b1111;
3125 let Inst{7-4} = 0b0001;
3126 let Inst{19-16} = Rd;
3127 let Inst{11-8} = Rm;
3130 def USADA8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3131 MulFrm /* for convenience */, NoItinerary, "usada8",
3132 "\t$Rd, $Rn, $Rm, $Ra", []>,
3133 Requires<[IsARM, HasV6]> {
3138 let Inst{27-20} = 0b01111000;
3139 let Inst{7-4} = 0b0001;
3140 let Inst{19-16} = Rd;
3141 let Inst{15-12} = Ra;
3142 let Inst{11-8} = Rm;
3146 // Signed/Unsigned saturate
3148 def SSAT : AI<(outs GPRnopc:$Rd),
3149 (ins imm1_32:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3150 SatFrm, NoItinerary, "ssat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3155 let Inst{27-21} = 0b0110101;
3156 let Inst{5-4} = 0b01;
3157 let Inst{20-16} = sat_imm;
3158 let Inst{15-12} = Rd;
3159 let Inst{11-7} = sh{4-0};
3160 let Inst{6} = sh{5};
3164 def SSAT16 : AI<(outs GPRnopc:$Rd),
3165 (ins imm1_16:$sat_imm, GPRnopc:$Rn), SatFrm,
3166 NoItinerary, "ssat16", "\t$Rd, $sat_imm, $Rn", []> {
3170 let Inst{27-20} = 0b01101010;
3171 let Inst{11-4} = 0b11110011;
3172 let Inst{15-12} = Rd;
3173 let Inst{19-16} = sat_imm;
3177 def USAT : AI<(outs GPRnopc:$Rd),
3178 (ins imm0_31:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3179 SatFrm, NoItinerary, "usat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3184 let Inst{27-21} = 0b0110111;
3185 let Inst{5-4} = 0b01;
3186 let Inst{15-12} = Rd;
3187 let Inst{11-7} = sh{4-0};
3188 let Inst{6} = sh{5};
3189 let Inst{20-16} = sat_imm;
3193 def USAT16 : AI<(outs GPRnopc:$Rd),
3194 (ins imm0_15:$sat_imm, GPRnopc:$Rn), SatFrm,
3195 NoItinerary, "usat16", "\t$Rd, $sat_imm, $Rn", []> {
3199 let Inst{27-20} = 0b01101110;
3200 let Inst{11-4} = 0b11110011;
3201 let Inst{15-12} = Rd;
3202 let Inst{19-16} = sat_imm;
3206 def : ARMV6Pat<(int_arm_ssat GPRnopc:$a, imm:$pos),
3207 (SSAT imm:$pos, GPRnopc:$a, 0)>;
3208 def : ARMV6Pat<(int_arm_usat GPRnopc:$a, imm:$pos),
3209 (USAT imm:$pos, GPRnopc:$a, 0)>;
3211 //===----------------------------------------------------------------------===//
3212 // Bitwise Instructions.
3215 defm AND : AsI1_bin_irs<0b0000, "and",
3216 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3217 BinOpFrag<(and node:$LHS, node:$RHS)>, "AND", 1>;
3218 defm ORR : AsI1_bin_irs<0b1100, "orr",
3219 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3220 BinOpFrag<(or node:$LHS, node:$RHS)>, "ORR", 1>;
3221 defm EOR : AsI1_bin_irs<0b0001, "eor",
3222 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3223 BinOpFrag<(xor node:$LHS, node:$RHS)>, "EOR", 1>;
3224 defm BIC : AsI1_bin_irs<0b1110, "bic",
3225 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3226 BinOpFrag<(and node:$LHS, (not node:$RHS))>, "BIC">;
3228 // FIXME: bf_inv_mask_imm should be two operands, the lsb and the msb, just
3229 // like in the actual instruction encoding. The complexity of mapping the mask
3230 // to the lsb/msb pair should be handled by ISel, not encapsulated in the
3231 // instruction description.
3232 def BFC : I<(outs GPR:$Rd), (ins GPR:$src, bf_inv_mask_imm:$imm),
3233 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3234 "bfc", "\t$Rd, $imm", "$src = $Rd",
3235 [(set GPR:$Rd, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
3236 Requires<[IsARM, HasV6T2]> {
3239 let Inst{27-21} = 0b0111110;
3240 let Inst{6-0} = 0b0011111;
3241 let Inst{15-12} = Rd;
3242 let Inst{11-7} = imm{4-0}; // lsb
3243 let Inst{20-16} = imm{9-5}; // msb
3246 // A8.6.18 BFI - Bitfield insert (Encoding A1)
3247 def BFI:I<(outs GPRnopc:$Rd), (ins GPRnopc:$src, GPR:$Rn, bf_inv_mask_imm:$imm),
3248 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3249 "bfi", "\t$Rd, $Rn, $imm", "$src = $Rd",
3250 [(set GPRnopc:$Rd, (ARMbfi GPRnopc:$src, GPR:$Rn,
3251 bf_inv_mask_imm:$imm))]>,
3252 Requires<[IsARM, HasV6T2]> {
3256 let Inst{27-21} = 0b0111110;
3257 let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15
3258 let Inst{15-12} = Rd;
3259 let Inst{11-7} = imm{4-0}; // lsb
3260 let Inst{20-16} = imm{9-5}; // width
3264 // GNU as only supports this form of bfi (w/ 4 arguments)
3265 let isAsmParserOnly = 1 in
3266 def BFI4p : I<(outs GPRnopc:$Rd), (ins GPRnopc:$src, GPR:$Rn,
3267 lsb_pos_imm:$lsb, width_imm:$width),
3268 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3269 "bfi", "\t$Rd, $Rn, $lsb, $width", "$src = $Rd",
3270 []>, Requires<[IsARM, HasV6T2]> {
3275 let Inst{27-21} = 0b0111110;
3276 let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15
3277 let Inst{15-12} = Rd;
3278 let Inst{11-7} = lsb;
3279 let Inst{20-16} = width; // Custom encoder => lsb+width-1
3283 def MVNr : AsI1<0b1111, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMVNr,
3284 "mvn", "\t$Rd, $Rm",
3285 [(set GPR:$Rd, (not GPR:$Rm))]>, UnaryDP {
3289 let Inst{19-16} = 0b0000;
3290 let Inst{11-4} = 0b00000000;
3291 let Inst{15-12} = Rd;
3294 def MVNsi : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_imm:$shift),
3295 DPSoRegImmFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3296 [(set GPR:$Rd, (not so_reg_imm:$shift))]>, UnaryDP {
3300 let Inst{19-16} = 0b0000;
3301 let Inst{15-12} = Rd;
3302 let Inst{11-5} = shift{11-5};
3304 let Inst{3-0} = shift{3-0};
3306 def MVNsr : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_reg:$shift),
3307 DPSoRegRegFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3308 [(set GPR:$Rd, (not so_reg_reg:$shift))]>, UnaryDP {
3312 let Inst{19-16} = 0b0000;
3313 let Inst{15-12} = Rd;
3314 let Inst{11-8} = shift{11-8};
3316 let Inst{6-5} = shift{6-5};
3318 let Inst{3-0} = shift{3-0};
3320 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3321 def MVNi : AsI1<0b1111, (outs GPR:$Rd), (ins so_imm:$imm), DPFrm,
3322 IIC_iMVNi, "mvn", "\t$Rd, $imm",
3323 [(set GPR:$Rd, so_imm_not:$imm)]>,UnaryDP {
3327 let Inst{19-16} = 0b0000;
3328 let Inst{15-12} = Rd;
3329 let Inst{11-0} = imm;
3332 def : ARMPat<(and GPR:$src, so_imm_not:$imm),
3333 (BICri GPR:$src, so_imm_not:$imm)>;
3335 //===----------------------------------------------------------------------===//
3336 // Multiply Instructions.
3338 class AsMul1I32<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3339 string opc, string asm, list<dag> pattern>
3340 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3344 let Inst{19-16} = Rd;
3345 let Inst{11-8} = Rm;
3348 class AsMul1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3349 string opc, string asm, list<dag> pattern>
3350 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3355 let Inst{19-16} = RdHi;
3356 let Inst{15-12} = RdLo;
3357 let Inst{11-8} = Rm;
3361 // FIXME: The v5 pseudos are only necessary for the additional Constraint
3362 // property. Remove them when it's possible to add those properties
3363 // on an individual MachineInstr, not just an instuction description.
3364 let isCommutable = 1 in {
3365 def MUL : AsMul1I32<0b0000000, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3366 IIC_iMUL32, "mul", "\t$Rd, $Rn, $Rm",
3367 [(set GPR:$Rd, (mul GPR:$Rn, GPR:$Rm))]>,
3368 Requires<[IsARM, HasV6]> {
3369 let Inst{15-12} = 0b0000;
3372 let Constraints = "@earlyclobber $Rd" in
3373 def MULv5: ARMPseudoExpand<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm,
3374 pred:$p, cc_out:$s),
3376 [(set GPR:$Rd, (mul GPR:$Rn, GPR:$Rm))],
3377 (MUL GPR:$Rd, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3378 Requires<[IsARM, NoV6]>;
3381 def MLA : AsMul1I32<0b0000001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3382 IIC_iMAC32, "mla", "\t$Rd, $Rn, $Rm, $Ra",
3383 [(set GPR:$Rd, (add (mul GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
3384 Requires<[IsARM, HasV6]> {
3386 let Inst{15-12} = Ra;
3389 let Constraints = "@earlyclobber $Rd" in
3390 def MLAv5: ARMPseudoExpand<(outs GPR:$Rd),
3391 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra, pred:$p, cc_out:$s),
3393 [(set GPR:$Rd, (add (mul GPR:$Rn, GPR:$Rm), GPR:$Ra))],
3394 (MLA GPR:$Rd, GPR:$Rn, GPR:$Rm, GPR:$Ra, pred:$p, cc_out:$s)>,
3395 Requires<[IsARM, NoV6]>;
3397 def MLS : AMul1I<0b0000011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3398 IIC_iMAC32, "mls", "\t$Rd, $Rn, $Rm, $Ra",
3399 [(set GPR:$Rd, (sub GPR:$Ra, (mul GPR:$Rn, GPR:$Rm)))]>,
3400 Requires<[IsARM, HasV6T2]> {
3405 let Inst{19-16} = Rd;
3406 let Inst{15-12} = Ra;
3407 let Inst{11-8} = Rm;
3411 // Extra precision multiplies with low / high results
3412 let neverHasSideEffects = 1 in {
3413 let isCommutable = 1 in {
3414 def SMULL : AsMul1I64<0b0000110, (outs GPR:$RdLo, GPR:$RdHi),
3415 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3416 "smull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3417 Requires<[IsARM, HasV6]>;
3419 def UMULL : AsMul1I64<0b0000100, (outs GPR:$RdLo, GPR:$RdHi),
3420 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3421 "umull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3422 Requires<[IsARM, HasV6]>;
3424 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
3425 def SMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3426 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3428 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3429 Requires<[IsARM, NoV6]>;
3431 def UMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3432 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3434 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3435 Requires<[IsARM, NoV6]>;
3439 // Multiply + accumulate
3440 def SMLAL : AsMul1I64<0b0000111, (outs GPR:$RdLo, GPR:$RdHi),
3441 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3442 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3443 Requires<[IsARM, HasV6]>;
3444 def UMLAL : AsMul1I64<0b0000101, (outs GPR:$RdLo, GPR:$RdHi),
3445 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3446 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3447 Requires<[IsARM, HasV6]>;
3449 def UMAAL : AMul1I <0b0000010, (outs GPR:$RdLo, GPR:$RdHi),
3450 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3451 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3452 Requires<[IsARM, HasV6]> {
3457 let Inst{19-16} = RdLo;
3458 let Inst{15-12} = RdHi;
3459 let Inst{11-8} = Rm;
3463 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
3464 def SMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3465 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3467 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3468 Requires<[IsARM, NoV6]>;
3469 def UMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3470 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3472 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3473 Requires<[IsARM, NoV6]>;
3474 def UMAALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3475 (ins GPR:$Rn, GPR:$Rm, pred:$p),
3477 (UMAAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p)>,
3478 Requires<[IsARM, NoV6]>;
3481 } // neverHasSideEffects
3483 // Most significant word multiply
3484 def SMMUL : AMul2I <0b0111010, 0b0001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3485 IIC_iMUL32, "smmul", "\t$Rd, $Rn, $Rm",
3486 [(set GPR:$Rd, (mulhs GPR:$Rn, GPR:$Rm))]>,
3487 Requires<[IsARM, HasV6]> {
3488 let Inst{15-12} = 0b1111;
3491 def SMMULR : AMul2I <0b0111010, 0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3492 IIC_iMUL32, "smmulr", "\t$Rd, $Rn, $Rm", []>,
3493 Requires<[IsARM, HasV6]> {
3494 let Inst{15-12} = 0b1111;
3497 def SMMLA : AMul2Ia <0b0111010, 0b0001, (outs GPR:$Rd),
3498 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3499 IIC_iMAC32, "smmla", "\t$Rd, $Rn, $Rm, $Ra",
3500 [(set GPR:$Rd, (add (mulhs GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
3501 Requires<[IsARM, HasV6]>;
3503 def SMMLAR : AMul2Ia <0b0111010, 0b0011, (outs GPR:$Rd),
3504 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3505 IIC_iMAC32, "smmlar", "\t$Rd, $Rn, $Rm, $Ra", []>,
3506 Requires<[IsARM, HasV6]>;
3508 def SMMLS : AMul2Ia <0b0111010, 0b1101, (outs GPR:$Rd),
3509 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3510 IIC_iMAC32, "smmls", "\t$Rd, $Rn, $Rm, $Ra",
3511 [(set GPR:$Rd, (sub GPR:$Ra, (mulhs GPR:$Rn, GPR:$Rm)))]>,
3512 Requires<[IsARM, HasV6]>;
3514 def SMMLSR : AMul2Ia <0b0111010, 0b1111, (outs GPR:$Rd),
3515 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3516 IIC_iMAC32, "smmlsr", "\t$Rd, $Rn, $Rm, $Ra", []>,
3517 Requires<[IsARM, HasV6]>;
3519 multiclass AI_smul<string opc, PatFrag opnode> {
3520 def BB : AMulxyI<0b0001011, 0b00, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3521 IIC_iMUL16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm",
3522 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3523 (sext_inreg GPR:$Rm, i16)))]>,
3524 Requires<[IsARM, HasV5TE]>;
3526 def BT : AMulxyI<0b0001011, 0b10, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3527 IIC_iMUL16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm",
3528 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3529 (sra GPR:$Rm, (i32 16))))]>,
3530 Requires<[IsARM, HasV5TE]>;
3532 def TB : AMulxyI<0b0001011, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3533 IIC_iMUL16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm",
3534 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3535 (sext_inreg GPR:$Rm, i16)))]>,
3536 Requires<[IsARM, HasV5TE]>;
3538 def TT : AMulxyI<0b0001011, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3539 IIC_iMUL16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm",
3540 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3541 (sra GPR:$Rm, (i32 16))))]>,
3542 Requires<[IsARM, HasV5TE]>;
3544 def WB : AMulxyI<0b0001001, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3545 IIC_iMUL16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm",
3546 [(set GPR:$Rd, (sra (opnode GPR:$Rn,
3547 (sext_inreg GPR:$Rm, i16)), (i32 16)))]>,
3548 Requires<[IsARM, HasV5TE]>;
3550 def WT : AMulxyI<0b0001001, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3551 IIC_iMUL16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm",
3552 [(set GPR:$Rd, (sra (opnode GPR:$Rn,
3553 (sra GPR:$Rm, (i32 16))), (i32 16)))]>,
3554 Requires<[IsARM, HasV5TE]>;
3558 multiclass AI_smla<string opc, PatFrag opnode> {
3559 let DecoderMethod = "DecodeSMLAInstruction" in {
3560 def BB : AMulxyIa<0b0001000, 0b00, (outs GPRnopc:$Rd),
3561 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3562 IIC_iMAC16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra",
3563 [(set GPRnopc:$Rd, (add GPR:$Ra,
3564 (opnode (sext_inreg GPRnopc:$Rn, i16),
3565 (sext_inreg GPRnopc:$Rm, i16))))]>,
3566 Requires<[IsARM, HasV5TE]>;
3568 def BT : AMulxyIa<0b0001000, 0b10, (outs GPRnopc:$Rd),
3569 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3570 IIC_iMAC16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra",
3572 (add GPR:$Ra, (opnode (sext_inreg GPRnopc:$Rn, i16),
3573 (sra GPRnopc:$Rm, (i32 16)))))]>,
3574 Requires<[IsARM, HasV5TE]>;
3576 def TB : AMulxyIa<0b0001000, 0b01, (outs GPRnopc:$Rd),
3577 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3578 IIC_iMAC16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra",
3580 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
3581 (sext_inreg GPRnopc:$Rm, i16))))]>,
3582 Requires<[IsARM, HasV5TE]>;
3584 def TT : AMulxyIa<0b0001000, 0b11, (outs GPRnopc:$Rd),
3585 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3586 IIC_iMAC16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra",
3588 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
3589 (sra GPRnopc:$Rm, (i32 16)))))]>,
3590 Requires<[IsARM, HasV5TE]>;
3592 def WB : AMulxyIa<0b0001001, 0b00, (outs GPRnopc:$Rd),
3593 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3594 IIC_iMAC16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra",
3596 (add GPR:$Ra, (sra (opnode GPRnopc:$Rn,
3597 (sext_inreg GPRnopc:$Rm, i16)), (i32 16))))]>,
3598 Requires<[IsARM, HasV5TE]>;
3600 def WT : AMulxyIa<0b0001001, 0b10, (outs GPRnopc:$Rd),
3601 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3602 IIC_iMAC16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra",
3604 (add GPR:$Ra, (sra (opnode GPRnopc:$Rn,
3605 (sra GPRnopc:$Rm, (i32 16))), (i32 16))))]>,
3606 Requires<[IsARM, HasV5TE]>;
3610 defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
3611 defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
3613 // Halfword multiply accumulate long: SMLAL<x><y>.
3614 def SMLALBB : AMulxyI64<0b0001010, 0b00, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3615 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3616 IIC_iMAC64, "smlalbb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3617 Requires<[IsARM, HasV5TE]>;
3619 def SMLALBT : AMulxyI64<0b0001010, 0b10, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3620 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3621 IIC_iMAC64, "smlalbt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3622 Requires<[IsARM, HasV5TE]>;
3624 def SMLALTB : AMulxyI64<0b0001010, 0b01, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3625 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3626 IIC_iMAC64, "smlaltb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3627 Requires<[IsARM, HasV5TE]>;
3629 def SMLALTT : AMulxyI64<0b0001010, 0b11, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3630 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3631 IIC_iMAC64, "smlaltt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3632 Requires<[IsARM, HasV5TE]>;
3634 // Helper class for AI_smld.
3635 class AMulDualIbase<bit long, bit sub, bit swap, dag oops, dag iops,
3636 InstrItinClass itin, string opc, string asm>
3637 : AI<oops, iops, MulFrm, itin, opc, asm, []>, Requires<[IsARM, HasV6]> {
3640 let Inst{27-23} = 0b01110;
3641 let Inst{22} = long;
3642 let Inst{21-20} = 0b00;
3643 let Inst{11-8} = Rm;
3650 class AMulDualI<bit long, bit sub, bit swap, dag oops, dag iops,
3651 InstrItinClass itin, string opc, string asm>
3652 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
3654 let Inst{15-12} = 0b1111;
3655 let Inst{19-16} = Rd;
3657 class AMulDualIa<bit long, bit sub, bit swap, dag oops, dag iops,
3658 InstrItinClass itin, string opc, string asm>
3659 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
3662 let Inst{19-16} = Rd;
3663 let Inst{15-12} = Ra;
3665 class AMulDualI64<bit long, bit sub, bit swap, dag oops, dag iops,
3666 InstrItinClass itin, string opc, string asm>
3667 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
3670 let Inst{19-16} = RdHi;
3671 let Inst{15-12} = RdLo;
3674 multiclass AI_smld<bit sub, string opc> {
3676 def D : AMulDualIa<0, sub, 0, (outs GPRnopc:$Rd),
3677 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3678 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm, $Ra">;
3680 def DX: AMulDualIa<0, sub, 1, (outs GPRnopc:$Rd),
3681 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3682 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm, $Ra">;
3684 def LD: AMulDualI64<1, sub, 0, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3685 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
3686 !strconcat(opc, "ld"), "\t$RdLo, $RdHi, $Rn, $Rm">;
3688 def LDX : AMulDualI64<1, sub, 1, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3689 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
3690 !strconcat(opc, "ldx"),"\t$RdLo, $RdHi, $Rn, $Rm">;
3694 defm SMLA : AI_smld<0, "smla">;
3695 defm SMLS : AI_smld<1, "smls">;
3697 multiclass AI_sdml<bit sub, string opc> {
3699 def D:AMulDualI<0, sub, 0, (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm),
3700 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm">;
3701 def DX:AMulDualI<0, sub, 1, (outs GPRnopc:$Rd),(ins GPRnopc:$Rn, GPRnopc:$Rm),
3702 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm">;
3705 defm SMUA : AI_sdml<0, "smua">;
3706 defm SMUS : AI_sdml<1, "smus">;
3708 //===----------------------------------------------------------------------===//
3709 // Misc. Arithmetic Instructions.
3712 def CLZ : AMiscA1I<0b000010110, 0b0001, (outs GPR:$Rd), (ins GPR:$Rm),
3713 IIC_iUNAr, "clz", "\t$Rd, $Rm",
3714 [(set GPR:$Rd, (ctlz GPR:$Rm))]>, Requires<[IsARM, HasV5T]>;
3716 def RBIT : AMiscA1I<0b01101111, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
3717 IIC_iUNAr, "rbit", "\t$Rd, $Rm",
3718 [(set GPR:$Rd, (ARMrbit GPR:$Rm))]>,
3719 Requires<[IsARM, HasV6T2]>;
3721 def REV : AMiscA1I<0b01101011, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
3722 IIC_iUNAr, "rev", "\t$Rd, $Rm",
3723 [(set GPR:$Rd, (bswap GPR:$Rm))]>, Requires<[IsARM, HasV6]>;
3725 let AddedComplexity = 5 in
3726 def REV16 : AMiscA1I<0b01101011, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
3727 IIC_iUNAr, "rev16", "\t$Rd, $Rm",
3728 [(set GPR:$Rd, (rotr (bswap GPR:$Rm), (i32 16)))]>,
3729 Requires<[IsARM, HasV6]>;
3731 let AddedComplexity = 5 in
3732 def REVSH : AMiscA1I<0b01101111, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
3733 IIC_iUNAr, "revsh", "\t$Rd, $Rm",
3734 [(set GPR:$Rd, (sra (bswap GPR:$Rm), (i32 16)))]>,
3735 Requires<[IsARM, HasV6]>;
3737 def : ARMV6Pat<(or (sra (shl GPR:$Rm, (i32 24)), (i32 16)),
3738 (and (srl GPR:$Rm, (i32 8)), 0xFF)),
3741 def PKHBT : APKHI<0b01101000, 0, (outs GPR:$Rd),
3742 (ins GPR:$Rn, GPR:$Rm, pkh_lsl_amt:$sh),
3743 IIC_iALUsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh",
3744 [(set GPR:$Rd, (or (and GPR:$Rn, 0xFFFF),
3745 (and (shl GPR:$Rm, pkh_lsl_amt:$sh),
3747 Requires<[IsARM, HasV6]>;
3749 // Alternate cases for PKHBT where identities eliminate some nodes.
3750 def : ARMV6Pat<(or (and GPR:$Rn, 0xFFFF), (and GPR:$Rm, 0xFFFF0000)),
3751 (PKHBT GPR:$Rn, GPR:$Rm, 0)>;
3752 def : ARMV6Pat<(or (and GPR:$Rn, 0xFFFF), (shl GPR:$Rm, imm16_31:$sh)),
3753 (PKHBT GPR:$Rn, GPR:$Rm, imm16_31:$sh)>;
3755 // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
3756 // will match the pattern below.
3757 def PKHTB : APKHI<0b01101000, 1, (outs GPR:$Rd),
3758 (ins GPR:$Rn, GPR:$Rm, pkh_asr_amt:$sh),
3759 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh",
3760 [(set GPR:$Rd, (or (and GPR:$Rn, 0xFFFF0000),
3761 (and (sra GPR:$Rm, pkh_asr_amt:$sh),
3763 Requires<[IsARM, HasV6]>;
3765 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
3766 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
3767 def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000), (srl GPR:$src2, imm16_31:$sh)),
3768 (PKHTB GPR:$src1, GPR:$src2, imm16_31:$sh)>;
3769 def : ARMV6Pat<(or (and GPR:$src1, 0xFFFF0000),
3770 (and (srl GPR:$src2, imm1_15:$sh), 0xFFFF)),
3771 (PKHTB GPR:$src1, GPR:$src2, imm1_15:$sh)>;
3773 //===----------------------------------------------------------------------===//
3774 // Comparison Instructions...
3777 defm CMP : AI1_cmp_irs<0b1010, "cmp",
3778 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
3779 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
3781 // ARMcmpZ can re-use the above instruction definitions.
3782 def : ARMPat<(ARMcmpZ GPR:$src, so_imm:$imm),
3783 (CMPri GPR:$src, so_imm:$imm)>;
3784 def : ARMPat<(ARMcmpZ GPR:$src, GPR:$rhs),
3785 (CMPrr GPR:$src, GPR:$rhs)>;
3786 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_imm:$rhs),
3787 (CMPrsi GPR:$src, so_reg_imm:$rhs)>;
3788 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_reg:$rhs),
3789 (CMPrsr GPR:$src, so_reg_reg:$rhs)>;
3791 // FIXME: We have to be careful when using the CMN instruction and comparison
3792 // with 0. One would expect these two pieces of code should give identical
3808 // However, the CMN gives the *opposite* result when r1 is 0. This is because
3809 // the carry flag is set in the CMP case but not in the CMN case. In short, the
3810 // CMP instruction doesn't perform a truncate of the (logical) NOT of 0 plus the
3811 // value of r0 and the carry bit (because the "carry bit" parameter to
3812 // AddWithCarry is defined as 1 in this case, the carry flag will always be set
3813 // when r0 >= 0). The CMN instruction doesn't perform a NOT of 0 so there is
3814 // never a "carry" when this AddWithCarry is performed (because the "carry bit"
3815 // parameter to AddWithCarry is defined as 0).
3817 // When x is 0 and unsigned:
3821 // ~x + 1 = 0x1 0000 0000
3822 // (-x = 0) != (0x1 0000 0000 = ~x + 1)
3824 // Therefore, we should disable CMN when comparing against zero, until we can
3825 // limit when the CMN instruction is used (when we know that the RHS is not 0 or
3826 // when it's a comparison which doesn't look at the 'carry' flag).
3828 // (See the ARM docs for the "AddWithCarry" pseudo-code.)
3830 // This is related to <rdar://problem/7569620>.
3832 //defm CMN : AI1_cmp_irs<0b1011, "cmn",
3833 // BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>;
3835 // Note that TST/TEQ don't set all the same flags that CMP does!
3836 defm TST : AI1_cmp_irs<0b1000, "tst",
3837 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
3838 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>, 1>;
3839 defm TEQ : AI1_cmp_irs<0b1001, "teq",
3840 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
3841 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>, 1>;
3843 defm CMNz : AI1_cmp_irs<0b1011, "cmn",
3844 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
3845 BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>>;
3847 //def : ARMPat<(ARMcmp GPR:$src, so_imm_neg:$imm),
3848 // (CMNri GPR:$src, so_imm_neg:$imm)>;
3850 def : ARMPat<(ARMcmpZ GPR:$src, so_imm_neg:$imm),
3851 (CMNzri GPR:$src, so_imm_neg:$imm)>;
3853 // Pseudo i64 compares for some floating point compares.
3854 let usesCustomInserter = 1, isBranch = 1, isTerminator = 1,
3856 def BCCi64 : PseudoInst<(outs),
3857 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, brtarget:$dst),
3859 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, bb:$dst)]>;
3861 def BCCZi64 : PseudoInst<(outs),
3862 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, brtarget:$dst), IIC_Br,
3863 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, 0, 0, bb:$dst)]>;
3864 } // usesCustomInserter
3867 // Conditional moves
3868 // FIXME: should be able to write a pattern for ARMcmov, but can't use
3869 // a two-value operand where a dag node expects two operands. :(
3870 let neverHasSideEffects = 1 in {
3871 def MOVCCr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$false, GPR:$Rm, pred:$p),
3873 [/*(set GPR:$Rd, (ARMcmov GPR:$false, GPR:$Rm, imm:$cc, CCR:$ccr))*/]>,
3874 RegConstraint<"$false = $Rd">;
3875 def MOVCCsi : ARMPseudoInst<(outs GPR:$Rd),
3876 (ins GPR:$false, so_reg_imm:$shift, pred:$p),
3878 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_imm:$shift,
3879 imm:$cc, CCR:$ccr))*/]>,
3880 RegConstraint<"$false = $Rd">;
3881 def MOVCCsr : ARMPseudoInst<(outs GPR:$Rd),
3882 (ins GPR:$false, so_reg_reg:$shift, pred:$p),
3884 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_reg:$shift,
3885 imm:$cc, CCR:$ccr))*/]>,
3886 RegConstraint<"$false = $Rd">;
3889 let isMoveImm = 1 in
3890 def MOVCCi16 : ARMPseudoInst<(outs GPR:$Rd),
3891 (ins GPR:$false, imm0_65535_expr:$imm, pred:$p),
3894 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>;
3896 let isMoveImm = 1 in
3897 def MOVCCi : ARMPseudoInst<(outs GPR:$Rd),
3898 (ins GPR:$false, so_imm:$imm, pred:$p),
3900 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_imm:$imm, imm:$cc, CCR:$ccr))*/]>,
3901 RegConstraint<"$false = $Rd">;
3903 // Two instruction predicate mov immediate.
3904 let isMoveImm = 1 in
3905 def MOVCCi32imm : ARMPseudoInst<(outs GPR:$Rd),
3906 (ins GPR:$false, i32imm:$src, pred:$p),
3907 8, IIC_iCMOVix2, []>, RegConstraint<"$false = $Rd">;
3909 let isMoveImm = 1 in
3910 def MVNCCi : ARMPseudoInst<(outs GPR:$Rd),
3911 (ins GPR:$false, so_imm:$imm, pred:$p),
3913 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_imm_not:$imm, imm:$cc, CCR:$ccr))*/]>,
3914 RegConstraint<"$false = $Rd">;
3915 } // neverHasSideEffects
3917 //===----------------------------------------------------------------------===//
3918 // Atomic operations intrinsics
3921 def MemBarrierOptOperand : AsmOperandClass {
3922 let Name = "MemBarrierOpt";
3923 let ParserMethod = "parseMemBarrierOptOperand";
3925 def memb_opt : Operand<i32> {
3926 let PrintMethod = "printMemBOption";
3927 let ParserMatchClass = MemBarrierOptOperand;
3928 let DecoderMethod = "DecodeMemBarrierOption";
3931 // memory barriers protect the atomic sequences
3932 let hasSideEffects = 1 in {
3933 def DMB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
3934 "dmb", "\t$opt", [(ARMMemBarrier (i32 imm:$opt))]>,
3935 Requires<[IsARM, HasDB]> {
3937 let Inst{31-4} = 0xf57ff05;
3938 let Inst{3-0} = opt;
3942 def DSB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
3943 "dsb", "\t$opt", []>,
3944 Requires<[IsARM, HasDB]> {
3946 let Inst{31-4} = 0xf57ff04;
3947 let Inst{3-0} = opt;
3950 // ISB has only full system option
3951 def ISB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
3952 "isb", "\t$opt", []>,
3953 Requires<[IsARM, HasDB]> {
3955 let Inst{31-4} = 0xf57ff06;
3956 let Inst{3-0} = opt;
3959 let usesCustomInserter = 1 in {
3960 let Uses = [CPSR] in {
3961 def ATOMIC_LOAD_ADD_I8 : PseudoInst<
3962 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
3963 [(set GPR:$dst, (atomic_load_add_8 GPR:$ptr, GPR:$incr))]>;
3964 def ATOMIC_LOAD_SUB_I8 : PseudoInst<
3965 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
3966 [(set GPR:$dst, (atomic_load_sub_8 GPR:$ptr, GPR:$incr))]>;
3967 def ATOMIC_LOAD_AND_I8 : PseudoInst<
3968 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
3969 [(set GPR:$dst, (atomic_load_and_8 GPR:$ptr, GPR:$incr))]>;
3970 def ATOMIC_LOAD_OR_I8 : PseudoInst<
3971 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
3972 [(set GPR:$dst, (atomic_load_or_8 GPR:$ptr, GPR:$incr))]>;
3973 def ATOMIC_LOAD_XOR_I8 : PseudoInst<
3974 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
3975 [(set GPR:$dst, (atomic_load_xor_8 GPR:$ptr, GPR:$incr))]>;
3976 def ATOMIC_LOAD_NAND_I8 : PseudoInst<
3977 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
3978 [(set GPR:$dst, (atomic_load_nand_8 GPR:$ptr, GPR:$incr))]>;
3979 def ATOMIC_LOAD_MIN_I8 : PseudoInst<
3980 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
3981 [(set GPR:$dst, (atomic_load_min_8 GPR:$ptr, GPR:$val))]>;
3982 def ATOMIC_LOAD_MAX_I8 : PseudoInst<
3983 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
3984 [(set GPR:$dst, (atomic_load_max_8 GPR:$ptr, GPR:$val))]>;
3985 def ATOMIC_LOAD_UMIN_I8 : PseudoInst<
3986 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
3987 [(set GPR:$dst, (atomic_load_min_8 GPR:$ptr, GPR:$val))]>;
3988 def ATOMIC_LOAD_UMAX_I8 : PseudoInst<
3989 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
3990 [(set GPR:$dst, (atomic_load_max_8 GPR:$ptr, GPR:$val))]>;
3991 def ATOMIC_LOAD_ADD_I16 : PseudoInst<
3992 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
3993 [(set GPR:$dst, (atomic_load_add_16 GPR:$ptr, GPR:$incr))]>;
3994 def ATOMIC_LOAD_SUB_I16 : PseudoInst<
3995 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
3996 [(set GPR:$dst, (atomic_load_sub_16 GPR:$ptr, GPR:$incr))]>;
3997 def ATOMIC_LOAD_AND_I16 : PseudoInst<
3998 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
3999 [(set GPR:$dst, (atomic_load_and_16 GPR:$ptr, GPR:$incr))]>;
4000 def ATOMIC_LOAD_OR_I16 : PseudoInst<
4001 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4002 [(set GPR:$dst, (atomic_load_or_16 GPR:$ptr, GPR:$incr))]>;
4003 def ATOMIC_LOAD_XOR_I16 : PseudoInst<
4004 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4005 [(set GPR:$dst, (atomic_load_xor_16 GPR:$ptr, GPR:$incr))]>;
4006 def ATOMIC_LOAD_NAND_I16 : PseudoInst<
4007 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4008 [(set GPR:$dst, (atomic_load_nand_16 GPR:$ptr, GPR:$incr))]>;
4009 def ATOMIC_LOAD_MIN_I16 : PseudoInst<
4010 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4011 [(set GPR:$dst, (atomic_load_min_16 GPR:$ptr, GPR:$val))]>;
4012 def ATOMIC_LOAD_MAX_I16 : PseudoInst<
4013 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4014 [(set GPR:$dst, (atomic_load_max_16 GPR:$ptr, GPR:$val))]>;
4015 def ATOMIC_LOAD_UMIN_I16 : PseudoInst<
4016 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4017 [(set GPR:$dst, (atomic_load_min_16 GPR:$ptr, GPR:$val))]>;
4018 def ATOMIC_LOAD_UMAX_I16 : PseudoInst<
4019 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4020 [(set GPR:$dst, (atomic_load_max_16 GPR:$ptr, GPR:$val))]>;
4021 def ATOMIC_LOAD_ADD_I32 : PseudoInst<
4022 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4023 [(set GPR:$dst, (atomic_load_add_32 GPR:$ptr, GPR:$incr))]>;
4024 def ATOMIC_LOAD_SUB_I32 : PseudoInst<
4025 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4026 [(set GPR:$dst, (atomic_load_sub_32 GPR:$ptr, GPR:$incr))]>;
4027 def ATOMIC_LOAD_AND_I32 : PseudoInst<
4028 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4029 [(set GPR:$dst, (atomic_load_and_32 GPR:$ptr, GPR:$incr))]>;
4030 def ATOMIC_LOAD_OR_I32 : PseudoInst<
4031 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4032 [(set GPR:$dst, (atomic_load_or_32 GPR:$ptr, GPR:$incr))]>;
4033 def ATOMIC_LOAD_XOR_I32 : PseudoInst<
4034 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4035 [(set GPR:$dst, (atomic_load_xor_32 GPR:$ptr, GPR:$incr))]>;
4036 def ATOMIC_LOAD_NAND_I32 : PseudoInst<
4037 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4038 [(set GPR:$dst, (atomic_load_nand_32 GPR:$ptr, GPR:$incr))]>;
4039 def ATOMIC_LOAD_MIN_I32 : PseudoInst<
4040 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4041 [(set GPR:$dst, (atomic_load_min_32 GPR:$ptr, GPR:$val))]>;
4042 def ATOMIC_LOAD_MAX_I32 : PseudoInst<
4043 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4044 [(set GPR:$dst, (atomic_load_max_32 GPR:$ptr, GPR:$val))]>;
4045 def ATOMIC_LOAD_UMIN_I32 : PseudoInst<
4046 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4047 [(set GPR:$dst, (atomic_load_min_32 GPR:$ptr, GPR:$val))]>;
4048 def ATOMIC_LOAD_UMAX_I32 : PseudoInst<
4049 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4050 [(set GPR:$dst, (atomic_load_max_32 GPR:$ptr, GPR:$val))]>;
4052 def ATOMIC_SWAP_I8 : PseudoInst<
4053 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
4054 [(set GPR:$dst, (atomic_swap_8 GPR:$ptr, GPR:$new))]>;
4055 def ATOMIC_SWAP_I16 : PseudoInst<
4056 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
4057 [(set GPR:$dst, (atomic_swap_16 GPR:$ptr, GPR:$new))]>;
4058 def ATOMIC_SWAP_I32 : PseudoInst<
4059 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
4060 [(set GPR:$dst, (atomic_swap_32 GPR:$ptr, GPR:$new))]>;
4062 def ATOMIC_CMP_SWAP_I8 : PseudoInst<
4063 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
4064 [(set GPR:$dst, (atomic_cmp_swap_8 GPR:$ptr, GPR:$old, GPR:$new))]>;
4065 def ATOMIC_CMP_SWAP_I16 : PseudoInst<
4066 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
4067 [(set GPR:$dst, (atomic_cmp_swap_16 GPR:$ptr, GPR:$old, GPR:$new))]>;
4068 def ATOMIC_CMP_SWAP_I32 : PseudoInst<
4069 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
4070 [(set GPR:$dst, (atomic_cmp_swap_32 GPR:$ptr, GPR:$old, GPR:$new))]>;
4074 let mayLoad = 1 in {
4075 def LDREXB : AIldrex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4077 "ldrexb", "\t$Rt, $addr", []>;
4078 def LDREXH : AIldrex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4079 NoItinerary, "ldrexh", "\t$Rt, $addr", []>;
4080 def LDREX : AIldrex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4081 NoItinerary, "ldrex", "\t$Rt, $addr", []>;
4082 let hasExtraDefRegAllocReq = 1 in
4083 def LDREXD: AIldrex<0b01, (outs GPR:$Rt, GPR:$Rt2),(ins addr_offset_none:$addr),
4084 NoItinerary, "ldrexd", "\t$Rt, $Rt2, $addr", []> {
4085 let DecoderMethod = "DecodeDoubleRegLoad";
4089 let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
4090 def STREXB: AIstrex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4091 NoItinerary, "strexb", "\t$Rd, $Rt, $addr", []>;
4092 def STREXH: AIstrex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4093 NoItinerary, "strexh", "\t$Rd, $Rt, $addr", []>;
4094 def STREX : AIstrex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4095 NoItinerary, "strex", "\t$Rd, $Rt, $addr", []>;
4098 let hasExtraSrcRegAllocReq = 1, Constraints = "@earlyclobber $Rd" in
4099 def STREXD : AIstrex<0b01, (outs GPR:$Rd),
4100 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr),
4101 NoItinerary, "strexd", "\t$Rd, $Rt, $Rt2, $addr", []> {
4102 let DecoderMethod = "DecodeDoubleRegStore";
4105 def CLREX : AXI<(outs), (ins), MiscFrm, NoItinerary, "clrex", []>,
4106 Requires<[IsARM, HasV7]> {
4107 let Inst{31-0} = 0b11110101011111111111000000011111;
4110 // SWP/SWPB are deprecated in V6/V7.
4111 let mayLoad = 1, mayStore = 1 in {
4112 def SWP : AIswp<0, (outs GPR:$Rt), (ins GPR:$Rt2, addr_offset_none:$addr),
4114 def SWPB: AIswp<1, (outs GPR:$Rt), (ins GPR:$Rt2, addr_offset_none:$addr),
4118 //===----------------------------------------------------------------------===//
4119 // Coprocessor Instructions.
4122 def CDP : ABI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4123 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4124 NoItinerary, "cdp", "\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4125 [(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4126 imm:$CRm, imm:$opc2)]> {
4134 let Inst{3-0} = CRm;
4136 let Inst{7-5} = opc2;
4137 let Inst{11-8} = cop;
4138 let Inst{15-12} = CRd;
4139 let Inst{19-16} = CRn;
4140 let Inst{23-20} = opc1;
4143 def CDP2 : ABXI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4144 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4145 NoItinerary, "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4146 [(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4147 imm:$CRm, imm:$opc2)]> {
4148 let Inst{31-28} = 0b1111;
4156 let Inst{3-0} = CRm;
4158 let Inst{7-5} = opc2;
4159 let Inst{11-8} = cop;
4160 let Inst{15-12} = CRd;
4161 let Inst{19-16} = CRn;
4162 let Inst{23-20} = opc1;
4165 class ACI<dag oops, dag iops, string opc, string asm,
4166 IndexMode im = IndexModeNone>
4167 : InoP<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
4169 let Inst{27-25} = 0b110;
4172 multiclass LdStCop<bits<4> op31_28, bit load, dag ops, string opc, string cond>{
4173 let DecoderNamespace = "Common" in {
4174 def _OFFSET : ACI<(outs),
4175 !con((ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr), ops),
4176 !strconcat(opc, cond), "\tp$cop, cr$CRd, $addr"> {
4177 let Inst{31-28} = op31_28;
4178 let Inst{24} = 1; // P = 1
4179 let Inst{21} = 0; // W = 0
4180 let Inst{22} = 0; // D = 0
4181 let Inst{20} = load;
4182 let DecoderMethod = "DecodeCopMemInstruction";
4185 def _PRE : ACI<(outs),
4186 !con((ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr), ops),
4187 !strconcat(opc, cond), "\tp$cop, cr$CRd, $addr!", IndexModePre> {
4188 let Inst{31-28} = op31_28;
4189 let Inst{24} = 1; // P = 1
4190 let Inst{21} = 1; // W = 1
4191 let Inst{22} = 0; // D = 0
4192 let Inst{20} = load;
4193 let DecoderMethod = "DecodeCopMemInstruction";
4196 def _POST : ACI<(outs),
4197 !con((ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr), ops),
4198 !strconcat(opc, cond), "\tp$cop, cr$CRd, $addr", IndexModePost> {
4199 let Inst{31-28} = op31_28;
4200 let Inst{24} = 0; // P = 0
4201 let Inst{21} = 1; // W = 1
4202 let Inst{22} = 0; // D = 0
4203 let Inst{20} = load;
4204 let DecoderMethod = "DecodeCopMemInstruction";
4207 def _OPTION : ACI<(outs),
4208 !con((ins nohash_imm:$cop,nohash_imm:$CRd,GPR:$base, nohash_imm:$option),
4210 !strconcat(opc, cond), "\tp$cop, cr$CRd, [$base], \\{$option\\}"> {
4211 let Inst{31-28} = op31_28;
4212 let Inst{24} = 0; // P = 0
4213 let Inst{23} = 1; // U = 1
4214 let Inst{21} = 0; // W = 0
4215 let Inst{22} = 0; // D = 0
4216 let Inst{20} = load;
4217 let DecoderMethod = "DecodeCopMemInstruction";
4220 def L_OFFSET : ACI<(outs),
4221 !con((ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr), ops),
4222 !strconcat(!strconcat(opc, "l"), cond), "\tp$cop, cr$CRd, $addr"> {
4223 let Inst{31-28} = op31_28;
4224 let Inst{24} = 1; // P = 1
4225 let Inst{21} = 0; // W = 0
4226 let Inst{22} = 1; // D = 1
4227 let Inst{20} = load;
4228 let DecoderMethod = "DecodeCopMemInstruction";
4231 def L_PRE : ACI<(outs),
4232 !con((ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr), ops),
4233 !strconcat(!strconcat(opc, "l"), cond), "\tp$cop, cr$CRd, $addr!",
4235 let Inst{31-28} = op31_28;
4236 let Inst{24} = 1; // P = 1
4237 let Inst{21} = 1; // W = 1
4238 let Inst{22} = 1; // D = 1
4239 let Inst{20} = load;
4240 let DecoderMethod = "DecodeCopMemInstruction";
4243 def L_POST : ACI<(outs),
4244 !con((ins nohash_imm:$cop, nohash_imm:$CRd, addr_offset_none:$addr,
4245 postidx_imm8s4:$offset), ops),
4246 !strconcat(!strconcat(opc, "l"), cond), "\tp$cop, cr$CRd, $addr, $offset",
4248 let Inst{31-28} = op31_28;
4249 let Inst{24} = 0; // P = 0
4250 let Inst{21} = 1; // W = 1
4251 let Inst{22} = 1; // D = 1
4252 let Inst{20} = load;
4253 let DecoderMethod = "DecodeCopMemInstruction";
4256 def L_OPTION : ACI<(outs),
4257 !con((ins nohash_imm:$cop, nohash_imm:$CRd,GPR:$base,nohash_imm:$option),
4259 !strconcat(!strconcat(opc, "l"), cond),
4260 "\tp$cop, cr$CRd, [$base], \\{$option\\}"> {
4261 let Inst{31-28} = op31_28;
4262 let Inst{24} = 0; // P = 0
4263 let Inst{23} = 1; // U = 1
4264 let Inst{21} = 0; // W = 0
4265 let Inst{22} = 1; // D = 1
4266 let Inst{20} = load;
4267 let DecoderMethod = "DecodeCopMemInstruction";
4272 defm LDC : LdStCop<{?,?,?,?}, 1, (ins pred:$p), "ldc", "${p}">;
4273 defm LDC2 : LdStCop<0b1111, 1, (ins), "ldc2", "">;
4274 defm STC : LdStCop<{?,?,?,?}, 0, (ins pred:$p), "stc", "${p}">;
4275 defm STC2 : LdStCop<0b1111, 0, (ins), "stc2", "">;
4277 //===----------------------------------------------------------------------===//
4278 // Move between coprocessor and ARM core register.
4281 class MovRCopro<string opc, bit direction, dag oops, dag iops,
4283 : ABI<0b1110, oops, iops, NoItinerary, opc,
4284 "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2", pattern> {
4285 let Inst{20} = direction;
4295 let Inst{15-12} = Rt;
4296 let Inst{11-8} = cop;
4297 let Inst{23-21} = opc1;
4298 let Inst{7-5} = opc2;
4299 let Inst{3-0} = CRm;
4300 let Inst{19-16} = CRn;
4303 def MCR : MovRCopro<"mcr", 0 /* from ARM core register to coprocessor */,
4305 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4306 c_imm:$CRm, imm0_7:$opc2),
4307 [(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
4308 imm:$CRm, imm:$opc2)]>;
4309 def MRC : MovRCopro<"mrc", 1 /* from coprocessor to ARM core register */,
4311 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
4314 def : ARMPat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
4315 (MRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
4317 class MovRCopro2<string opc, bit direction, dag oops, dag iops,
4319 : ABXI<0b1110, oops, iops, NoItinerary,
4320 !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), pattern> {
4321 let Inst{31-28} = 0b1111;
4322 let Inst{20} = direction;
4332 let Inst{15-12} = Rt;
4333 let Inst{11-8} = cop;
4334 let Inst{23-21} = opc1;
4335 let Inst{7-5} = opc2;
4336 let Inst{3-0} = CRm;
4337 let Inst{19-16} = CRn;
4340 def MCR2 : MovRCopro2<"mcr2", 0 /* from ARM core register to coprocessor */,
4342 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4343 c_imm:$CRm, imm0_7:$opc2),
4344 [(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
4345 imm:$CRm, imm:$opc2)]>;
4346 def MRC2 : MovRCopro2<"mrc2", 1 /* from coprocessor to ARM core register */,
4348 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
4351 def : ARMV5TPat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn,
4352 imm:$CRm, imm:$opc2),
4353 (MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
4355 class MovRRCopro<string opc, bit direction, list<dag> pattern = []>
4356 : ABI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4357 GPR:$Rt, GPR:$Rt2, c_imm:$CRm),
4358 NoItinerary, opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm", pattern> {
4359 let Inst{23-21} = 0b010;
4360 let Inst{20} = direction;
4368 let Inst{15-12} = Rt;
4369 let Inst{19-16} = Rt2;
4370 let Inst{11-8} = cop;
4371 let Inst{7-4} = opc1;
4372 let Inst{3-0} = CRm;
4375 def MCRR : MovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */,
4376 [(int_arm_mcrr imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2,
4378 def MRRC : MovRRCopro<"mrrc", 1 /* from coprocessor to ARM core register */>;
4380 class MovRRCopro2<string opc, bit direction, list<dag> pattern = []>
4381 : ABXI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4382 GPR:$Rt, GPR:$Rt2, c_imm:$CRm), NoItinerary,
4383 !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern> {
4384 let Inst{31-28} = 0b1111;
4385 let Inst{23-21} = 0b010;
4386 let Inst{20} = direction;
4394 let Inst{15-12} = Rt;
4395 let Inst{19-16} = Rt2;
4396 let Inst{11-8} = cop;
4397 let Inst{7-4} = opc1;
4398 let Inst{3-0} = CRm;
4401 def MCRR2 : MovRRCopro2<"mcrr2", 0 /* from ARM core register to coprocessor */,
4402 [(int_arm_mcrr2 imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2,
4404 def MRRC2 : MovRRCopro2<"mrrc2", 1 /* from coprocessor to ARM core register */>;
4406 //===----------------------------------------------------------------------===//
4407 // Move between special register and ARM core register
4410 // Move to ARM core register from Special Register
4411 def MRS : ABI<0b0001, (outs GPR:$Rd), (ins), NoItinerary,
4412 "mrs", "\t$Rd, apsr", []> {
4414 let Inst{23-16} = 0b00001111;
4415 let Inst{15-12} = Rd;
4416 let Inst{7-4} = 0b0000;
4419 def : InstAlias<"mrs${p} $Rd, cpsr", (MRS GPR:$Rd, pred:$p)>, Requires<[IsARM]>;
4421 def MRSsys : ABI<0b0001, (outs GPR:$Rd), (ins), NoItinerary,
4422 "mrs", "\t$Rd, spsr", []> {
4424 let Inst{23-16} = 0b01001111;
4425 let Inst{15-12} = Rd;
4426 let Inst{7-4} = 0b0000;
4429 // Move from ARM core register to Special Register
4431 // No need to have both system and application versions, the encodings are the
4432 // same and the assembly parser has no way to distinguish between them. The mask
4433 // operand contains the special register (R Bit) in bit 4 and bits 3-0 contains
4434 // the mask with the fields to be accessed in the special register.
4435 def MSR : ABI<0b0001, (outs), (ins msr_mask:$mask, GPR:$Rn), NoItinerary,
4436 "msr", "\t$mask, $Rn", []> {
4441 let Inst{22} = mask{4}; // R bit
4442 let Inst{21-20} = 0b10;
4443 let Inst{19-16} = mask{3-0};
4444 let Inst{15-12} = 0b1111;
4445 let Inst{11-4} = 0b00000000;
4449 def MSRi : ABI<0b0011, (outs), (ins msr_mask:$mask, so_imm:$a), NoItinerary,
4450 "msr", "\t$mask, $a", []> {
4455 let Inst{22} = mask{4}; // R bit
4456 let Inst{21-20} = 0b10;
4457 let Inst{19-16} = mask{3-0};
4458 let Inst{15-12} = 0b1111;
4462 //===----------------------------------------------------------------------===//
4466 // __aeabi_read_tp preserves the registers r1-r3.
4467 // This is a pseudo inst so that we can get the encoding right,
4468 // complete with fixup for the aeabi_read_tp function.
4470 Defs = [R0, R12, LR, CPSR], Uses = [SP] in {
4471 def TPsoft : PseudoInst<(outs), (ins), IIC_Br,
4472 [(set R0, ARMthread_pointer)]>;
4475 //===----------------------------------------------------------------------===//
4476 // SJLJ Exception handling intrinsics
4477 // eh_sjlj_setjmp() is an instruction sequence to store the return
4478 // address and save #0 in R0 for the non-longjmp case.
4479 // Since by its nature we may be coming from some other function to get
4480 // here, and we're using the stack frame for the containing function to
4481 // save/restore registers, we can't keep anything live in regs across
4482 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
4483 // when we get here from a longjmp(). We force everything out of registers
4484 // except for our own input by listing the relevant registers in Defs. By
4485 // doing so, we also cause the prologue/epilogue code to actively preserve
4486 // all of the callee-saved resgisters, which is exactly what we want.
4487 // A constant value is passed in $val, and we use the location as a scratch.
4489 // These are pseudo-instructions and are lowered to individual MC-insts, so
4490 // no encoding information is necessary.
4492 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
4493 QQQQ0, QQQQ1, QQQQ2, QQQQ3 ], hasSideEffects = 1, isBarrier = 1 in {
4494 def Int_eh_sjlj_setjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
4496 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
4497 Requires<[IsARM, HasVFP2]>;
4501 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
4502 hasSideEffects = 1, isBarrier = 1 in {
4503 def Int_eh_sjlj_setjmp_nofp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
4505 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
4506 Requires<[IsARM, NoVFP]>;
4509 // FIXME: Non-Darwin version(s)
4510 let isBarrier = 1, hasSideEffects = 1, isTerminator = 1,
4511 Defs = [ R7, LR, SP ] in {
4512 def Int_eh_sjlj_longjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$scratch),
4514 [(ARMeh_sjlj_longjmp GPR:$src, GPR:$scratch)]>,
4515 Requires<[IsARM, IsDarwin]>;
4518 // eh.sjlj.dispatchsetup pseudo-instruction.
4519 // This pseudo is used for ARM, Thumb1 and Thumb2. Any differences are
4520 // handled when the pseudo is expanded (which happens before any passes
4521 // that need the instruction size).
4522 let isBarrier = 1, hasSideEffects = 1 in
4523 def Int_eh_sjlj_dispatchsetup :
4524 PseudoInst<(outs), (ins GPR:$src), NoItinerary,
4525 [(ARMeh_sjlj_dispatchsetup GPR:$src)]>,
4526 Requires<[IsDarwin]>;
4528 //===----------------------------------------------------------------------===//
4529 // Non-Instruction Patterns
4532 // ARMv4 indirect branch using (MOVr PC, dst)
4533 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in
4534 def MOVPCRX : ARMPseudoExpand<(outs), (ins GPR:$dst),
4535 4, IIC_Br, [(brind GPR:$dst)],
4536 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>,
4537 Requires<[IsARM, NoV4T]>;
4539 // Large immediate handling.
4541 // 32-bit immediate using two piece so_imms or movw + movt.
4542 // This is a single pseudo instruction, the benefit is that it can be remat'd
4543 // as a single unit instead of having to handle reg inputs.
4544 // FIXME: Remove this when we can do generalized remat.
4545 let isReMaterializable = 1, isMoveImm = 1 in
4546 def MOVi32imm : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
4547 [(set GPR:$dst, (arm_i32imm:$src))]>,
4550 // Pseudo instruction that combines movw + movt + add pc (if PIC).
4551 // It also makes it possible to rematerialize the instructions.
4552 // FIXME: Remove this when we can do generalized remat and when machine licm
4553 // can properly the instructions.
4554 let isReMaterializable = 1 in {
4555 def MOV_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
4557 [(set GPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>,
4558 Requires<[IsARM, UseMovt]>;
4560 def MOV_ga_dyn : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
4562 [(set GPR:$dst, (ARMWrapperDYN tglobaladdr:$addr))]>,
4563 Requires<[IsARM, UseMovt]>;
4565 let AddedComplexity = 10 in
4566 def MOV_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
4568 [(set GPR:$dst, (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
4569 Requires<[IsARM, UseMovt]>;
4570 } // isReMaterializable
4572 // ConstantPool, GlobalAddress, and JumpTable
4573 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (LEApcrel tglobaladdr :$dst)>,
4574 Requires<[IsARM, DontUseMovt]>;
4575 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
4576 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
4577 Requires<[IsARM, UseMovt]>;
4578 def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
4579 (LEApcrelJT tjumptable:$dst, imm:$id)>;
4581 // TODO: add,sub,and, 3-instr forms?
4584 def : ARMPat<(ARMtcret tcGPR:$dst),
4585 (TCRETURNri tcGPR:$dst)>, Requires<[IsDarwin]>;
4587 def : ARMPat<(ARMtcret (i32 tglobaladdr:$dst)),
4588 (TCRETURNdi texternalsym:$dst)>, Requires<[IsDarwin]>;
4590 def : ARMPat<(ARMtcret (i32 texternalsym:$dst)),
4591 (TCRETURNdi texternalsym:$dst)>, Requires<[IsDarwin]>;
4593 def : ARMPat<(ARMtcret tcGPR:$dst),
4594 (TCRETURNriND tcGPR:$dst)>, Requires<[IsNotDarwin]>;
4596 def : ARMPat<(ARMtcret (i32 tglobaladdr:$dst)),
4597 (TCRETURNdiND texternalsym:$dst)>, Requires<[IsNotDarwin]>;
4599 def : ARMPat<(ARMtcret (i32 texternalsym:$dst)),
4600 (TCRETURNdiND texternalsym:$dst)>, Requires<[IsNotDarwin]>;
4603 def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>,
4604 Requires<[IsARM, IsNotDarwin]>;
4605 def : ARMPat<(ARMcall texternalsym:$func), (BLr9 texternalsym:$func)>,
4606 Requires<[IsARM, IsDarwin]>;
4608 // zextload i1 -> zextload i8
4609 def : ARMPat<(zextloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
4610 def : ARMPat<(zextloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
4612 // extload -> zextload
4613 def : ARMPat<(extloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
4614 def : ARMPat<(extloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
4615 def : ARMPat<(extloadi8 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
4616 def : ARMPat<(extloadi8 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
4618 def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
4620 def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
4621 def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
4624 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4625 (sra (shl GPR:$b, (i32 16)), (i32 16))),
4626 (SMULBB GPR:$a, GPR:$b)>;
4627 def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
4628 (SMULBB GPR:$a, GPR:$b)>;
4629 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4630 (sra GPR:$b, (i32 16))),
4631 (SMULBT GPR:$a, GPR:$b)>;
4632 def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, (i32 16))),
4633 (SMULBT GPR:$a, GPR:$b)>;
4634 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)),
4635 (sra (shl GPR:$b, (i32 16)), (i32 16))),
4636 (SMULTB GPR:$a, GPR:$b)>;
4637 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), sext_16_node:$b),
4638 (SMULTB GPR:$a, GPR:$b)>;
4639 def : ARMV5TEPat<(sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
4641 (SMULWB GPR:$a, GPR:$b)>;
4642 def : ARMV5TEPat<(sra (mul GPR:$a, sext_16_node:$b), (i32 16)),
4643 (SMULWB GPR:$a, GPR:$b)>;
4645 def : ARMV5TEPat<(add GPR:$acc,
4646 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4647 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
4648 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
4649 def : ARMV5TEPat<(add GPR:$acc,
4650 (mul sext_16_node:$a, sext_16_node:$b)),
4651 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
4652 def : ARMV5TEPat<(add GPR:$acc,
4653 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4654 (sra GPR:$b, (i32 16)))),
4655 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
4656 def : ARMV5TEPat<(add GPR:$acc,
4657 (mul sext_16_node:$a, (sra GPR:$b, (i32 16)))),
4658 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
4659 def : ARMV5TEPat<(add GPR:$acc,
4660 (mul (sra GPR:$a, (i32 16)),
4661 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
4662 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
4663 def : ARMV5TEPat<(add GPR:$acc,
4664 (mul (sra GPR:$a, (i32 16)), sext_16_node:$b)),
4665 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
4666 def : ARMV5TEPat<(add GPR:$acc,
4667 (sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
4669 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
4670 def : ARMV5TEPat<(add GPR:$acc,
4671 (sra (mul GPR:$a, sext_16_node:$b), (i32 16))),
4672 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
4675 // Pre-v7 uses MCR for synchronization barriers.
4676 def : ARMPat<(ARMMemBarrierMCR GPR:$zero), (MCR 15, 0, GPR:$zero, 7, 10, 5)>,
4677 Requires<[IsARM, HasV6]>;
4679 // SXT/UXT with no rotate
4680 let AddedComplexity = 16 in {
4681 def : ARMV6Pat<(and GPR:$Src, 0x000000FF), (UXTB GPR:$Src, 0)>;
4682 def : ARMV6Pat<(and GPR:$Src, 0x0000FFFF), (UXTH GPR:$Src, 0)>;
4683 def : ARMV6Pat<(and GPR:$Src, 0x00FF00FF), (UXTB16 GPR:$Src, 0)>;
4684 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0x00FF)),
4685 (UXTAB GPR:$Rn, GPR:$Rm, 0)>;
4686 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0xFFFF)),
4687 (UXTAH GPR:$Rn, GPR:$Rm, 0)>;
4690 def : ARMV6Pat<(sext_inreg GPR:$Src, i8), (SXTB GPR:$Src, 0)>;
4691 def : ARMV6Pat<(sext_inreg GPR:$Src, i16), (SXTH GPR:$Src, 0)>;
4693 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i8)),
4694 (SXTAB GPR:$Rn, GPRnopc:$Rm, 0)>;
4695 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i16)),
4696 (SXTAH GPR:$Rn, GPRnopc:$Rm, 0)>;
4698 //===----------------------------------------------------------------------===//
4702 include "ARMInstrThumb.td"
4704 //===----------------------------------------------------------------------===//
4708 include "ARMInstrThumb2.td"
4710 //===----------------------------------------------------------------------===//
4711 // Floating Point Support
4714 include "ARMInstrVFP.td"
4716 //===----------------------------------------------------------------------===//
4717 // Advanced SIMD (NEON) Support
4720 include "ARMInstrNEON.td"
4722 //===----------------------------------------------------------------------===//
4723 // Assembler aliases
4727 def : InstAlias<"dmb", (DMB 0xf)>, Requires<[IsARM, HasDB]>;
4728 def : InstAlias<"dsb", (DSB 0xf)>, Requires<[IsARM, HasDB]>;
4729 def : InstAlias<"isb", (ISB 0xf)>, Requires<[IsARM, HasDB]>;
4731 // System instructions
4732 def : MnemonicAlias<"swi", "svc">;
4734 // Load / Store Multiple
4735 def : MnemonicAlias<"ldmfd", "ldm">;
4736 def : MnemonicAlias<"ldmia", "ldm">;
4737 def : MnemonicAlias<"stmfd", "stmdb">;
4738 def : MnemonicAlias<"stmia", "stm">;
4739 def : MnemonicAlias<"stmea", "stm">;
4741 // PKHBT/PKHTB with default shift amount. PKHTB is equivalent to PKHBT when the
4742 // shift amount is zero (i.e., unspecified).
4743 def : InstAlias<"pkhbt${p} $Rd, $Rn, $Rm",
4744 (PKHBT GPR:$Rd, GPR:$Rn, GPR:$Rm, 0, pred:$p)>;
4745 def : InstAlias<"pkhtb${p} $Rd, $Rn, $Rm",
4746 (PKHBT GPR:$Rd, GPR:$Rn, GPR:$Rm, 0, pred:$p)>;
4748 // PUSH/POP aliases for STM/LDM
4749 def : InstAlias<"push${p} $regs",
4750 (STMDB_UPD SP, pred:$p, reglist:$regs)>;
4751 def : InstAlias<"pop${p} $regs",
4752 (LDMIA_UPD SP, pred:$p, reglist:$regs)>;
4754 // RSB two-operand forms (optional explicit destination operand)
4755 def : InstAlias<"rsb${s}${p} $Rdn, $imm",
4756 (RSBri GPR:$Rdn, GPR:$Rdn, so_imm:$imm, pred:$p, cc_out:$s)>,
4758 def : InstAlias<"rsb${s}${p} $Rdn, $Rm",
4759 (RSBrr GPR:$Rdn, GPR:$Rdn, GPR:$Rm, pred:$p, cc_out:$s)>,
4761 def : InstAlias<"rsb${s}${p} $Rdn, $shift",
4762 (RSBrsi GPR:$Rdn, GPR:$Rdn, so_reg_imm:$shift, pred:$p,
4763 cc_out:$s)>, Requires<[IsARM]>;
4764 def : InstAlias<"rsb${s}${p} $Rdn, $shift",
4765 (RSBrsr GPR:$Rdn, GPR:$Rdn, so_reg_reg:$shift, pred:$p,
4766 cc_out:$s)>, Requires<[IsARM]>;
4767 // RSC two-operand forms (optional explicit destination operand)
4768 def : InstAlias<"rsc${s}${p} $Rdn, $imm",
4769 (RSCri GPR:$Rdn, GPR:$Rdn, so_imm:$imm, pred:$p, cc_out:$s)>,
4771 def : InstAlias<"rsc${s}${p} $Rdn, $Rm",
4772 (RSCrr GPR:$Rdn, GPR:$Rdn, GPR:$Rm, pred:$p, cc_out:$s)>,
4774 def : InstAlias<"rsc${s}${p} $Rdn, $shift",
4775 (RSCrsi GPR:$Rdn, GPR:$Rdn, so_reg_imm:$shift, pred:$p,
4776 cc_out:$s)>, Requires<[IsARM]>;
4777 def : InstAlias<"rsc${s}${p} $Rdn, $shift",
4778 (RSCrsr GPR:$Rdn, GPR:$Rdn, so_reg_reg:$shift, pred:$p,
4779 cc_out:$s)>, Requires<[IsARM]>;
4781 // SSAT/USAT optional shift operand.
4782 def : InstAlias<"ssat${p} $Rd, $sat_imm, $Rn",
4783 (SSAT GPRnopc:$Rd, imm1_32:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
4784 def : InstAlias<"usat${p} $Rd, $sat_imm, $Rn",
4785 (USAT GPRnopc:$Rd, imm0_31:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
4788 // Extend instruction optional rotate operand.
4789 def : InstAlias<"sxtab${p} $Rd, $Rn, $Rm",
4790 (SXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4791 def : InstAlias<"sxtah${p} $Rd, $Rn, $Rm",
4792 (SXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4793 def : InstAlias<"sxtab16${p} $Rd, $Rn, $Rm",
4794 (SXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4795 def : InstAlias<"sxtb${p} $Rd, $Rm",
4796 (SXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4797 def : InstAlias<"sxtb16${p} $Rd, $Rm",
4798 (SXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4799 def : InstAlias<"sxth${p} $Rd, $Rm",
4800 (SXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4802 def : InstAlias<"uxtab${p} $Rd, $Rn, $Rm",
4803 (UXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4804 def : InstAlias<"uxtah${p} $Rd, $Rn, $Rm",
4805 (UXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4806 def : InstAlias<"uxtab16${p} $Rd, $Rn, $Rm",
4807 (UXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4808 def : InstAlias<"uxtb${p} $Rd, $Rm",
4809 (UXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4810 def : InstAlias<"uxtb16${p} $Rd, $Rm",
4811 (UXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4812 def : InstAlias<"uxth${p} $Rd, $Rm",
4813 (UXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4817 def : MnemonicAlias<"rfefa", "rfeda">;
4818 def : MnemonicAlias<"rfeea", "rfedb">;
4819 def : MnemonicAlias<"rfefd", "rfeia">;
4820 def : MnemonicAlias<"rfeed", "rfeib">;
4821 def : MnemonicAlias<"rfe", "rfeia">;
4824 def : MnemonicAlias<"srsfa", "srsda">;
4825 def : MnemonicAlias<"srsea", "srsdb">;
4826 def : MnemonicAlias<"srsfd", "srsia">;
4827 def : MnemonicAlias<"srsed", "srsib">;
4828 def : MnemonicAlias<"srs", "srsia">;
4830 // LDRSBT/LDRHT/LDRSHT post-index offset if optional.
4831 // Note that the write-back output register is a dummy operand for MC (it's
4832 // only meaningful for codegen), so we just pass zero here.
4833 // FIXME: tblgen not cooperating with argument conversions.
4834 //def : InstAlias<"ldrsbt${p} $Rt, $addr",
4835 // (LDRSBTi GPR:$Rt, GPR:$Rt, addr_offset_none:$addr, 0,pred:$p)>;
4836 //def : InstAlias<"ldrht${p} $Rt, $addr",
4837 // (LDRHTi GPR:$Rt, GPR:$Rt, addr_offset_none:$addr, 0, pred:$p)>;
4838 //def : InstAlias<"ldrsht${p} $Rt, $addr",
4839 // (LDRSHTi GPR:$Rt, GPR:$Rt, addr_offset_none:$addr, 0, pred:$p)>;