1 //===- ARMInstrInfo.td - Target Description for ARM Target -*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the ARM instructions in TableGen format.
12 //===----------------------------------------------------------------------===//
14 //===----------------------------------------------------------------------===//
15 // ARM specific DAG Nodes.
19 def SDT_ARMCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
20 def SDT_ARMCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>, SDTCisVT<1, i32> ]>;
22 def SDT_ARMSaveCallPC : SDTypeProfile<0, 1, []>;
24 def SDT_ARMcall : SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>;
26 def SDT_ARMCMov : SDTypeProfile<1, 3,
27 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
30 def SDT_ARMBrcond : SDTypeProfile<0, 2,
31 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i32>]>;
33 def SDT_ARMBrJT : SDTypeProfile<0, 3,
34 [SDTCisPtrTy<0>, SDTCisVT<1, i32>,
37 def SDT_ARMBr2JT : SDTypeProfile<0, 4,
38 [SDTCisPtrTy<0>, SDTCisVT<1, i32>,
39 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
41 def SDT_ARMBCC_i64 : SDTypeProfile<0, 6,
43 SDTCisVT<1, i32>, SDTCisVT<2, i32>,
44 SDTCisVT<3, i32>, SDTCisVT<4, i32>,
45 SDTCisVT<5, OtherVT>]>;
47 def SDT_ARMAnd : SDTypeProfile<1, 2,
48 [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
51 def SDT_ARMCmp : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
53 def SDT_ARMPICAdd : SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>,
54 SDTCisPtrTy<1>, SDTCisVT<2, i32>]>;
56 def SDT_ARMThreadPointer : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
57 def SDT_ARMEH_SJLJ_Setjmp : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisPtrTy<1>,
59 def SDT_ARMEH_SJLJ_Longjmp: SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
61 def SDT_ARMMEMBARRIER : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
63 def SDT_ARMPREFETCH : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisSameAs<1, 2>,
66 def SDT_ARMTCRET : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
68 def SDT_ARMBFI : SDTypeProfile<1, 3, [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
69 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
71 def SDTBinaryArithWithFlags : SDTypeProfile<2, 2,
74 SDTCisInt<0>, SDTCisVT<1, i32>]>;
76 // SDTBinaryArithWithFlagsInOut - RES1, CPSR = op LHS, RHS, CPSR
77 def SDTBinaryArithWithFlagsInOut : SDTypeProfile<2, 3,
84 def ARMWrapper : SDNode<"ARMISD::Wrapper", SDTIntUnaryOp>;
85 def ARMWrapperDYN : SDNode<"ARMISD::WrapperDYN", SDTIntUnaryOp>;
86 def ARMWrapperPIC : SDNode<"ARMISD::WrapperPIC", SDTIntUnaryOp>;
87 def ARMWrapperJT : SDNode<"ARMISD::WrapperJT", SDTIntBinOp>;
89 def ARMcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_ARMCallSeqStart,
90 [SDNPHasChain, SDNPOutGlue]>;
91 def ARMcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_ARMCallSeqEnd,
92 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
94 def ARMcall : SDNode<"ARMISD::CALL", SDT_ARMcall,
95 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
97 def ARMcall_pred : SDNode<"ARMISD::CALL_PRED", SDT_ARMcall,
98 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
100 def ARMcall_nolink : SDNode<"ARMISD::CALL_NOLINK", SDT_ARMcall,
101 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
104 def ARMretflag : SDNode<"ARMISD::RET_FLAG", SDTNone,
105 [SDNPHasChain, SDNPOptInGlue]>;
107 def ARMcmov : SDNode<"ARMISD::CMOV", SDT_ARMCMov,
110 def ARMbrcond : SDNode<"ARMISD::BRCOND", SDT_ARMBrcond,
111 [SDNPHasChain, SDNPInGlue, SDNPOutGlue]>;
113 def ARMbrjt : SDNode<"ARMISD::BR_JT", SDT_ARMBrJT,
115 def ARMbr2jt : SDNode<"ARMISD::BR2_JT", SDT_ARMBr2JT,
118 def ARMBcci64 : SDNode<"ARMISD::BCC_i64", SDT_ARMBCC_i64,
121 def ARMcmp : SDNode<"ARMISD::CMP", SDT_ARMCmp,
124 def ARMcmpZ : SDNode<"ARMISD::CMPZ", SDT_ARMCmp,
125 [SDNPOutGlue, SDNPCommutative]>;
127 def ARMpic_add : SDNode<"ARMISD::PIC_ADD", SDT_ARMPICAdd>;
129 def ARMsrl_flag : SDNode<"ARMISD::SRL_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
130 def ARMsra_flag : SDNode<"ARMISD::SRA_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
131 def ARMrrx : SDNode<"ARMISD::RRX" , SDTIntUnaryOp, [SDNPInGlue ]>;
133 def ARMaddc : SDNode<"ARMISD::ADDC", SDTBinaryArithWithFlags,
135 def ARMsubc : SDNode<"ARMISD::SUBC", SDTBinaryArithWithFlags>;
136 def ARMadde : SDNode<"ARMISD::ADDE", SDTBinaryArithWithFlagsInOut>;
137 def ARMsube : SDNode<"ARMISD::SUBE", SDTBinaryArithWithFlagsInOut>;
139 def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>;
140 def ARMeh_sjlj_setjmp: SDNode<"ARMISD::EH_SJLJ_SETJMP",
141 SDT_ARMEH_SJLJ_Setjmp, [SDNPHasChain]>;
142 def ARMeh_sjlj_longjmp: SDNode<"ARMISD::EH_SJLJ_LONGJMP",
143 SDT_ARMEH_SJLJ_Longjmp, [SDNPHasChain]>;
145 def ARMMemBarrier : SDNode<"ARMISD::MEMBARRIER", SDT_ARMMEMBARRIER,
147 def ARMMemBarrierMCR : SDNode<"ARMISD::MEMBARRIER_MCR", SDT_ARMMEMBARRIER,
149 def ARMPreload : SDNode<"ARMISD::PRELOAD", SDT_ARMPREFETCH,
150 [SDNPHasChain, SDNPMayLoad, SDNPMayStore]>;
152 def ARMrbit : SDNode<"ARMISD::RBIT", SDTIntUnaryOp>;
154 def ARMtcret : SDNode<"ARMISD::TC_RETURN", SDT_ARMTCRET,
155 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
158 def ARMbfi : SDNode<"ARMISD::BFI", SDT_ARMBFI>;
160 //===----------------------------------------------------------------------===//
161 // ARM Instruction Predicate Definitions.
163 def HasV4T : Predicate<"Subtarget->hasV4TOps()">,
164 AssemblerPredicate<"HasV4TOps">;
165 def NoV4T : Predicate<"!Subtarget->hasV4TOps()">;
166 def HasV5T : Predicate<"Subtarget->hasV5TOps()">;
167 def HasV5TE : Predicate<"Subtarget->hasV5TEOps()">,
168 AssemblerPredicate<"HasV5TEOps">;
169 def HasV6 : Predicate<"Subtarget->hasV6Ops()">,
170 AssemblerPredicate<"HasV6Ops">;
171 def NoV6 : Predicate<"!Subtarget->hasV6Ops()">;
172 def HasV6T2 : Predicate<"Subtarget->hasV6T2Ops()">,
173 AssemblerPredicate<"HasV6T2Ops">;
174 def NoV6T2 : Predicate<"!Subtarget->hasV6T2Ops()">;
175 def HasV7 : Predicate<"Subtarget->hasV7Ops()">,
176 AssemblerPredicate<"HasV7Ops">;
177 def NoVFP : Predicate<"!Subtarget->hasVFP2()">;
178 def HasVFP2 : Predicate<"Subtarget->hasVFP2()">,
179 AssemblerPredicate<"FeatureVFP2">;
180 def HasVFP3 : Predicate<"Subtarget->hasVFP3()">,
181 AssemblerPredicate<"FeatureVFP3">;
182 def HasNEON : Predicate<"Subtarget->hasNEON()">,
183 AssemblerPredicate<"FeatureNEON">;
184 def HasFP16 : Predicate<"Subtarget->hasFP16()">,
185 AssemblerPredicate<"FeatureFP16">;
186 def HasDivide : Predicate<"Subtarget->hasDivide()">,
187 AssemblerPredicate<"FeatureHWDiv">;
188 def HasT2ExtractPack : Predicate<"Subtarget->hasT2ExtractPack()">,
189 AssemblerPredicate<"FeatureT2XtPk">;
190 def HasThumb2DSP : Predicate<"Subtarget->hasThumb2DSP()">,
191 AssemblerPredicate<"FeatureDSPThumb2">;
192 def HasDB : Predicate<"Subtarget->hasDataBarrier()">,
193 AssemblerPredicate<"FeatureDB">;
194 def HasMP : Predicate<"Subtarget->hasMPExtension()">,
195 AssemblerPredicate<"FeatureMP">;
196 def UseNEONForFP : Predicate<"Subtarget->useNEONForSinglePrecisionFP()">;
197 def DontUseNEONForFP : Predicate<"!Subtarget->useNEONForSinglePrecisionFP()">;
198 def IsThumb : Predicate<"Subtarget->isThumb()">,
199 AssemblerPredicate<"ModeThumb">;
200 def IsThumb1Only : Predicate<"Subtarget->isThumb1Only()">;
201 def IsThumb2 : Predicate<"Subtarget->isThumb2()">,
202 AssemblerPredicate<"ModeThumb,FeatureThumb2">;
203 def IsMClass : Predicate<"Subtarget->isMClass()">,
204 AssemblerPredicate<"FeatureMClass">;
205 def IsARClass : Predicate<"!Subtarget->isMClass()">,
206 AssemblerPredicate<"!FeatureMClass">;
207 def IsARM : Predicate<"!Subtarget->isThumb()">,
208 AssemblerPredicate<"!ModeThumb">;
209 def IsDarwin : Predicate<"Subtarget->isTargetDarwin()">;
210 def IsNotDarwin : Predicate<"!Subtarget->isTargetDarwin()">;
211 def IsNaCl : Predicate<"Subtarget->isTargetNaCl()">;
213 // FIXME: Eventually this will be just "hasV6T2Ops".
214 def UseMovt : Predicate<"Subtarget->useMovt()">;
215 def DontUseMovt : Predicate<"!Subtarget->useMovt()">;
216 def UseFPVMLx : Predicate<"Subtarget->useFPVMLx()">;
218 //===----------------------------------------------------------------------===//
219 // ARM Flag Definitions.
221 class RegConstraint<string C> {
222 string Constraints = C;
225 //===----------------------------------------------------------------------===//
226 // ARM specific transformation functions and pattern fragments.
229 // so_imm_neg_XFORM - Return a so_imm value packed into the format described for
230 // so_imm_neg def below.
231 def so_imm_neg_XFORM : SDNodeXForm<imm, [{
232 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), MVT::i32);
235 // so_imm_not_XFORM - Return a so_imm value packed into the format described for
236 // so_imm_not def below.
237 def so_imm_not_XFORM : SDNodeXForm<imm, [{
238 return CurDAG->getTargetConstant(~(int)N->getZExtValue(), MVT::i32);
241 /// imm1_15 predicate - True if the 32-bit immediate is in the range [1,15].
242 def imm1_15 : ImmLeaf<i32, [{
243 return (int32_t)Imm >= 1 && (int32_t)Imm < 16;
246 /// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
247 def imm16_31 : ImmLeaf<i32, [{
248 return (int32_t)Imm >= 16 && (int32_t)Imm < 32;
253 return ARM_AM::getSOImmVal(-(uint32_t)N->getZExtValue()) != -1;
254 }], so_imm_neg_XFORM>;
256 // Note: this pattern doesn't require an encoder method and such, as it's
257 // only used on aliases (Pat<> and InstAlias<>). The actual encoding
258 // is handled by the destination instructions, which use t2_so_imm.
259 def so_imm_not_asmoperand : AsmOperandClass { let Name = "ARMSOImmNot"; }
261 Operand<i32>, PatLeaf<(imm), [{
262 return ARM_AM::getSOImmVal(~(uint32_t)N->getZExtValue()) != -1;
263 }], so_imm_not_XFORM> {
264 let ParserMatchClass = so_imm_not_asmoperand;
267 // sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
268 def sext_16_node : PatLeaf<(i32 GPR:$a), [{
269 return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17;
272 /// Split a 32-bit immediate into two 16 bit parts.
273 def hi16 : SDNodeXForm<imm, [{
274 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, MVT::i32);
277 def lo16AllZero : PatLeaf<(i32 imm), [{
278 // Returns true if all low 16-bits are 0.
279 return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
282 class BinOpWithFlagFrag<dag res> :
283 PatFrag<(ops node:$LHS, node:$RHS, node:$FLAG), res>;
284 class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
285 class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
287 // An 'and' node with a single use.
288 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
289 return N->hasOneUse();
292 // An 'xor' node with a single use.
293 def xor_su : PatFrag<(ops node:$lhs, node:$rhs), (xor node:$lhs, node:$rhs), [{
294 return N->hasOneUse();
297 // An 'fmul' node with a single use.
298 def fmul_su : PatFrag<(ops node:$lhs, node:$rhs), (fmul node:$lhs, node:$rhs),[{
299 return N->hasOneUse();
302 // An 'fadd' node which checks for single non-hazardous use.
303 def fadd_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fadd node:$lhs, node:$rhs),[{
304 return hasNoVMLxHazardUse(N);
307 // An 'fsub' node which checks for single non-hazardous use.
308 def fsub_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fsub node:$lhs, node:$rhs),[{
309 return hasNoVMLxHazardUse(N);
312 //===----------------------------------------------------------------------===//
313 // Operand Definitions.
316 // Immediate operands with a shared generic asm render method.
317 class ImmAsmOperand : AsmOperandClass { let RenderMethod = "addImmOperands"; }
320 // FIXME: rename brtarget to t2_brtarget
321 def brtarget : Operand<OtherVT> {
322 let EncoderMethod = "getBranchTargetOpValue";
323 let OperandType = "OPERAND_PCREL";
324 let DecoderMethod = "DecodeT2BROperand";
327 // FIXME: get rid of this one?
328 def uncondbrtarget : Operand<OtherVT> {
329 let EncoderMethod = "getUnconditionalBranchTargetOpValue";
330 let OperandType = "OPERAND_PCREL";
333 // Branch target for ARM. Handles conditional/unconditional
334 def br_target : Operand<OtherVT> {
335 let EncoderMethod = "getARMBranchTargetOpValue";
336 let OperandType = "OPERAND_PCREL";
340 // FIXME: rename bltarget to t2_bl_target?
341 def bltarget : Operand<i32> {
342 // Encoded the same as branch targets.
343 let EncoderMethod = "getBranchTargetOpValue";
344 let OperandType = "OPERAND_PCREL";
347 // Call target for ARM. Handles conditional/unconditional
348 // FIXME: rename bl_target to t2_bltarget?
349 def bl_target : Operand<i32> {
350 // Encoded the same as branch targets.
351 let EncoderMethod = "getARMBranchTargetOpValue";
352 let OperandType = "OPERAND_PCREL";
355 def blx_target : Operand<i32> {
356 // Encoded the same as branch targets.
357 let EncoderMethod = "getARMBLXTargetOpValue";
358 let OperandType = "OPERAND_PCREL";
361 // A list of registers separated by comma. Used by load/store multiple.
362 def RegListAsmOperand : AsmOperandClass { let Name = "RegList"; }
363 def reglist : Operand<i32> {
364 let EncoderMethod = "getRegisterListOpValue";
365 let ParserMatchClass = RegListAsmOperand;
366 let PrintMethod = "printRegisterList";
367 let DecoderMethod = "DecodeRegListOperand";
370 def DPRRegListAsmOperand : AsmOperandClass { let Name = "DPRRegList"; }
371 def dpr_reglist : Operand<i32> {
372 let EncoderMethod = "getRegisterListOpValue";
373 let ParserMatchClass = DPRRegListAsmOperand;
374 let PrintMethod = "printRegisterList";
375 let DecoderMethod = "DecodeDPRRegListOperand";
378 def SPRRegListAsmOperand : AsmOperandClass { let Name = "SPRRegList"; }
379 def spr_reglist : Operand<i32> {
380 let EncoderMethod = "getRegisterListOpValue";
381 let ParserMatchClass = SPRRegListAsmOperand;
382 let PrintMethod = "printRegisterList";
383 let DecoderMethod = "DecodeSPRRegListOperand";
386 // An operand for the CONSTPOOL_ENTRY pseudo-instruction.
387 def cpinst_operand : Operand<i32> {
388 let PrintMethod = "printCPInstOperand";
392 def pclabel : Operand<i32> {
393 let PrintMethod = "printPCLabel";
396 // ADR instruction labels.
397 def adrlabel : Operand<i32> {
398 let EncoderMethod = "getAdrLabelOpValue";
401 def neon_vcvt_imm32 : Operand<i32> {
402 let EncoderMethod = "getNEONVcvtImm32OpValue";
403 let DecoderMethod = "DecodeVCVTImmOperand";
406 // rot_imm: An integer that encodes a rotate amount. Must be 8, 16, or 24.
407 def rot_imm_XFORM: SDNodeXForm<imm, [{
408 switch (N->getZExtValue()){
410 case 0: return CurDAG->getTargetConstant(0, MVT::i32);
411 case 8: return CurDAG->getTargetConstant(1, MVT::i32);
412 case 16: return CurDAG->getTargetConstant(2, MVT::i32);
413 case 24: return CurDAG->getTargetConstant(3, MVT::i32);
416 def RotImmAsmOperand : AsmOperandClass {
418 let ParserMethod = "parseRotImm";
420 def rot_imm : Operand<i32>, PatLeaf<(i32 imm), [{
421 int32_t v = N->getZExtValue();
422 return v == 8 || v == 16 || v == 24; }],
424 let PrintMethod = "printRotImmOperand";
425 let ParserMatchClass = RotImmAsmOperand;
428 // shift_imm: An integer that encodes a shift amount and the type of shift
429 // (asr or lsl). The 6-bit immediate encodes as:
432 // {4-0} imm5 shift amount.
433 // asr #32 encoded as imm5 == 0.
434 def ShifterImmAsmOperand : AsmOperandClass {
435 let Name = "ShifterImm";
436 let ParserMethod = "parseShifterImm";
438 def shift_imm : Operand<i32> {
439 let PrintMethod = "printShiftImmOperand";
440 let ParserMatchClass = ShifterImmAsmOperand;
443 // shifter_operand operands: so_reg_reg, so_reg_imm, and so_imm.
444 def ShiftedRegAsmOperand : AsmOperandClass { let Name = "RegShiftedReg"; }
445 def so_reg_reg : Operand<i32>, // reg reg imm
446 ComplexPattern<i32, 3, "SelectRegShifterOperand",
447 [shl, srl, sra, rotr]> {
448 let EncoderMethod = "getSORegRegOpValue";
449 let PrintMethod = "printSORegRegOperand";
450 let DecoderMethod = "DecodeSORegRegOperand";
451 let ParserMatchClass = ShiftedRegAsmOperand;
452 let MIOperandInfo = (ops GPRnopc, GPRnopc, i32imm);
455 def ShiftedImmAsmOperand : AsmOperandClass { let Name = "RegShiftedImm"; }
456 def so_reg_imm : Operand<i32>, // reg imm
457 ComplexPattern<i32, 2, "SelectImmShifterOperand",
458 [shl, srl, sra, rotr]> {
459 let EncoderMethod = "getSORegImmOpValue";
460 let PrintMethod = "printSORegImmOperand";
461 let DecoderMethod = "DecodeSORegImmOperand";
462 let ParserMatchClass = ShiftedImmAsmOperand;
463 let MIOperandInfo = (ops GPR, i32imm);
466 // FIXME: Does this need to be distinct from so_reg?
467 def shift_so_reg_reg : Operand<i32>, // reg reg imm
468 ComplexPattern<i32, 3, "SelectShiftRegShifterOperand",
469 [shl,srl,sra,rotr]> {
470 let EncoderMethod = "getSORegRegOpValue";
471 let PrintMethod = "printSORegRegOperand";
472 let DecoderMethod = "DecodeSORegRegOperand";
473 let ParserMatchClass = ShiftedRegAsmOperand;
474 let MIOperandInfo = (ops GPR, GPR, i32imm);
477 // FIXME: Does this need to be distinct from so_reg?
478 def shift_so_reg_imm : Operand<i32>, // reg reg imm
479 ComplexPattern<i32, 2, "SelectShiftImmShifterOperand",
480 [shl,srl,sra,rotr]> {
481 let EncoderMethod = "getSORegImmOpValue";
482 let PrintMethod = "printSORegImmOperand";
483 let DecoderMethod = "DecodeSORegImmOperand";
484 let ParserMatchClass = ShiftedImmAsmOperand;
485 let MIOperandInfo = (ops GPR, i32imm);
489 // so_imm - Match a 32-bit shifter_operand immediate operand, which is an
490 // 8-bit immediate rotated by an arbitrary number of bits.
491 def SOImmAsmOperand: ImmAsmOperand { let Name = "ARMSOImm"; }
492 def so_imm : Operand<i32>, ImmLeaf<i32, [{
493 return ARM_AM::getSOImmVal(Imm) != -1;
495 let EncoderMethod = "getSOImmOpValue";
496 let ParserMatchClass = SOImmAsmOperand;
497 let DecoderMethod = "DecodeSOImmOperand";
500 // Break so_imm's up into two pieces. This handles immediates with up to 16
501 // bits set in them. This uses so_imm2part to match and so_imm2part_[12] to
502 // get the first/second pieces.
503 def so_imm2part : PatLeaf<(imm), [{
504 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
507 /// arm_i32imm - True for +V6T2, or true only if so_imm2part is true.
509 def arm_i32imm : PatLeaf<(imm), [{
510 if (Subtarget->hasV6T2Ops())
512 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
515 /// imm0_1 predicate - Immediate in the range [0,1].
516 def Imm0_1AsmOperand: ImmAsmOperand { let Name = "Imm0_1"; }
517 def imm0_1 : Operand<i32> { let ParserMatchClass = Imm0_1AsmOperand; }
519 /// imm0_3 predicate - Immediate in the range [0,3].
520 def Imm0_3AsmOperand: ImmAsmOperand { let Name = "Imm0_3"; }
521 def imm0_3 : Operand<i32> { let ParserMatchClass = Imm0_3AsmOperand; }
523 /// imm0_7 predicate - Immediate in the range [0,7].
524 def Imm0_7AsmOperand: ImmAsmOperand { let Name = "Imm0_7"; }
525 def imm0_7 : Operand<i32>, ImmLeaf<i32, [{
526 return Imm >= 0 && Imm < 8;
528 let ParserMatchClass = Imm0_7AsmOperand;
531 /// imm0_15 predicate - Immediate in the range [0,15].
532 def Imm0_15AsmOperand: ImmAsmOperand { let Name = "Imm0_15"; }
533 def imm0_15 : Operand<i32>, ImmLeaf<i32, [{
534 return Imm >= 0 && Imm < 16;
536 let ParserMatchClass = Imm0_15AsmOperand;
539 /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
540 def Imm0_31AsmOperand: ImmAsmOperand { let Name = "Imm0_31"; }
541 def imm0_31 : Operand<i32>, ImmLeaf<i32, [{
542 return Imm >= 0 && Imm < 32;
544 let ParserMatchClass = Imm0_31AsmOperand;
547 /// imm0_32 predicate - True if the 32-bit immediate is in the range [0,32].
548 def Imm0_32AsmOperand: ImmAsmOperand { let Name = "Imm0_32"; }
549 def imm0_32 : Operand<i32>, ImmLeaf<i32, [{
550 return Imm >= 0 && Imm < 32;
552 let ParserMatchClass = Imm0_32AsmOperand;
555 /// imm0_255 predicate - Immediate in the range [0,255].
556 def Imm0_255AsmOperand : ImmAsmOperand { let Name = "Imm0_255"; }
557 def imm0_255 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 256; }]> {
558 let ParserMatchClass = Imm0_255AsmOperand;
561 /// imm0_65535 - An immediate is in the range [0.65535].
562 def Imm0_65535AsmOperand: ImmAsmOperand { let Name = "Imm0_65535"; }
563 def imm0_65535 : Operand<i32>, ImmLeaf<i32, [{
564 return Imm >= 0 && Imm < 65536;
566 let ParserMatchClass = Imm0_65535AsmOperand;
569 // imm0_65535_expr - For movt/movw - 16-bit immediate that can also reference
570 // a relocatable expression.
572 // FIXME: This really needs a Thumb version separate from the ARM version.
573 // While the range is the same, and can thus use the same match class,
574 // the encoding is different so it should have a different encoder method.
575 def Imm0_65535ExprAsmOperand: ImmAsmOperand { let Name = "Imm0_65535Expr"; }
576 def imm0_65535_expr : Operand<i32> {
577 let EncoderMethod = "getHiLo16ImmOpValue";
578 let ParserMatchClass = Imm0_65535ExprAsmOperand;
581 /// imm24b - True if the 32-bit immediate is encodable in 24 bits.
582 def Imm24bitAsmOperand: ImmAsmOperand { let Name = "Imm24bit"; }
583 def imm24b : Operand<i32>, ImmLeaf<i32, [{
584 return Imm >= 0 && Imm <= 0xffffff;
586 let ParserMatchClass = Imm24bitAsmOperand;
590 /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
592 def BitfieldAsmOperand : AsmOperandClass {
593 let Name = "Bitfield";
594 let ParserMethod = "parseBitfield";
596 def bf_inv_mask_imm : Operand<i32>,
598 return ARM::isBitFieldInvertedMask(N->getZExtValue());
600 let EncoderMethod = "getBitfieldInvertedMaskOpValue";
601 let PrintMethod = "printBitfieldInvMaskImmOperand";
602 let DecoderMethod = "DecodeBitfieldMaskOperand";
603 let ParserMatchClass = BitfieldAsmOperand;
606 def imm1_32_XFORM: SDNodeXForm<imm, [{
607 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, MVT::i32);
609 def Imm1_32AsmOperand: AsmOperandClass { let Name = "Imm1_32"; }
610 def imm1_32 : Operand<i32>, PatLeaf<(imm), [{
611 uint64_t Imm = N->getZExtValue();
612 return Imm > 0 && Imm <= 32;
615 let PrintMethod = "printImmPlusOneOperand";
616 let ParserMatchClass = Imm1_32AsmOperand;
619 def imm1_16_XFORM: SDNodeXForm<imm, [{
620 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, MVT::i32);
622 def Imm1_16AsmOperand: AsmOperandClass { let Name = "Imm1_16"; }
623 def imm1_16 : Operand<i32>, PatLeaf<(imm), [{ return Imm > 0 && Imm <= 16; }],
625 let PrintMethod = "printImmPlusOneOperand";
626 let ParserMatchClass = Imm1_16AsmOperand;
629 // Define ARM specific addressing modes.
630 // addrmode_imm12 := reg +/- imm12
632 def MemImm12OffsetAsmOperand : AsmOperandClass { let Name = "MemImm12Offset"; }
633 def addrmode_imm12 : Operand<i32>,
634 ComplexPattern<i32, 2, "SelectAddrModeImm12", []> {
635 // 12-bit immediate operand. Note that instructions using this encode
636 // #0 and #-0 differently. We flag #-0 as the magic value INT32_MIN. All other
637 // immediate values are as normal.
639 let EncoderMethod = "getAddrModeImm12OpValue";
640 let PrintMethod = "printAddrModeImm12Operand";
641 let DecoderMethod = "DecodeAddrModeImm12Operand";
642 let ParserMatchClass = MemImm12OffsetAsmOperand;
643 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
645 // ldst_so_reg := reg +/- reg shop imm
647 def MemRegOffsetAsmOperand : AsmOperandClass { let Name = "MemRegOffset"; }
648 def ldst_so_reg : Operand<i32>,
649 ComplexPattern<i32, 3, "SelectLdStSOReg", []> {
650 let EncoderMethod = "getLdStSORegOpValue";
651 // FIXME: Simplify the printer
652 let PrintMethod = "printAddrMode2Operand";
653 let DecoderMethod = "DecodeSORegMemOperand";
654 let ParserMatchClass = MemRegOffsetAsmOperand;
655 let MIOperandInfo = (ops GPR:$base, GPRnopc:$offsreg, i32imm:$shift);
658 // postidx_imm8 := +/- [0,255]
661 // {8} 1 is imm8 is non-negative. 0 otherwise.
662 // {7-0} [0,255] imm8 value.
663 def PostIdxImm8AsmOperand : AsmOperandClass { let Name = "PostIdxImm8"; }
664 def postidx_imm8 : Operand<i32> {
665 let PrintMethod = "printPostIdxImm8Operand";
666 let ParserMatchClass = PostIdxImm8AsmOperand;
667 let MIOperandInfo = (ops i32imm);
670 // postidx_imm8s4 := +/- [0,1020]
673 // {8} 1 is imm8 is non-negative. 0 otherwise.
674 // {7-0} [0,255] imm8 value, scaled by 4.
675 def PostIdxImm8s4AsmOperand : AsmOperandClass { let Name = "PostIdxImm8s4"; }
676 def postidx_imm8s4 : Operand<i32> {
677 let PrintMethod = "printPostIdxImm8s4Operand";
678 let ParserMatchClass = PostIdxImm8s4AsmOperand;
679 let MIOperandInfo = (ops i32imm);
683 // postidx_reg := +/- reg
685 def PostIdxRegAsmOperand : AsmOperandClass {
686 let Name = "PostIdxReg";
687 let ParserMethod = "parsePostIdxReg";
689 def postidx_reg : Operand<i32> {
690 let EncoderMethod = "getPostIdxRegOpValue";
691 let DecoderMethod = "DecodePostIdxReg";
692 let PrintMethod = "printPostIdxRegOperand";
693 let ParserMatchClass = PostIdxRegAsmOperand;
694 let MIOperandInfo = (ops GPR, i32imm);
698 // addrmode2 := reg +/- imm12
699 // := reg +/- reg shop imm
701 // FIXME: addrmode2 should be refactored the rest of the way to always
702 // use explicit imm vs. reg versions above (addrmode_imm12 and ldst_so_reg).
703 def AddrMode2AsmOperand : AsmOperandClass { let Name = "AddrMode2"; }
704 def addrmode2 : Operand<i32>,
705 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
706 let EncoderMethod = "getAddrMode2OpValue";
707 let PrintMethod = "printAddrMode2Operand";
708 let ParserMatchClass = AddrMode2AsmOperand;
709 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
712 def PostIdxRegShiftedAsmOperand : AsmOperandClass {
713 let Name = "PostIdxRegShifted";
714 let ParserMethod = "parsePostIdxReg";
716 def am2offset_reg : Operand<i32>,
717 ComplexPattern<i32, 2, "SelectAddrMode2OffsetReg",
718 [], [SDNPWantRoot]> {
719 let EncoderMethod = "getAddrMode2OffsetOpValue";
720 let PrintMethod = "printAddrMode2OffsetOperand";
721 // When using this for assembly, it's always as a post-index offset.
722 let ParserMatchClass = PostIdxRegShiftedAsmOperand;
723 let MIOperandInfo = (ops GPR, i32imm);
726 // FIXME: am2offset_imm should only need the immediate, not the GPR. Having
727 // the GPR is purely vestigal at this point.
728 def AM2OffsetImmAsmOperand : AsmOperandClass { let Name = "AM2OffsetImm"; }
729 def am2offset_imm : Operand<i32>,
730 ComplexPattern<i32, 2, "SelectAddrMode2OffsetImm",
731 [], [SDNPWantRoot]> {
732 let EncoderMethod = "getAddrMode2OffsetOpValue";
733 let PrintMethod = "printAddrMode2OffsetOperand";
734 let ParserMatchClass = AM2OffsetImmAsmOperand;
735 let MIOperandInfo = (ops GPR, i32imm);
739 // addrmode3 := reg +/- reg
740 // addrmode3 := reg +/- imm8
742 // FIXME: split into imm vs. reg versions.
743 def AddrMode3AsmOperand : AsmOperandClass { let Name = "AddrMode3"; }
744 def addrmode3 : Operand<i32>,
745 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
746 let EncoderMethod = "getAddrMode3OpValue";
747 let PrintMethod = "printAddrMode3Operand";
748 let ParserMatchClass = AddrMode3AsmOperand;
749 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
752 // FIXME: split into imm vs. reg versions.
753 // FIXME: parser method to handle +/- register.
754 def AM3OffsetAsmOperand : AsmOperandClass {
755 let Name = "AM3Offset";
756 let ParserMethod = "parseAM3Offset";
758 def am3offset : Operand<i32>,
759 ComplexPattern<i32, 2, "SelectAddrMode3Offset",
760 [], [SDNPWantRoot]> {
761 let EncoderMethod = "getAddrMode3OffsetOpValue";
762 let PrintMethod = "printAddrMode3OffsetOperand";
763 let ParserMatchClass = AM3OffsetAsmOperand;
764 let MIOperandInfo = (ops GPR, i32imm);
767 // ldstm_mode := {ia, ib, da, db}
769 def ldstm_mode : OptionalDefOperand<OtherVT, (ops i32), (ops (i32 1))> {
770 let EncoderMethod = "getLdStmModeOpValue";
771 let PrintMethod = "printLdStmModeOperand";
774 // addrmode5 := reg +/- imm8*4
776 def AddrMode5AsmOperand : AsmOperandClass { let Name = "AddrMode5"; }
777 def addrmode5 : Operand<i32>,
778 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
779 let PrintMethod = "printAddrMode5Operand";
780 let EncoderMethod = "getAddrMode5OpValue";
781 let DecoderMethod = "DecodeAddrMode5Operand";
782 let ParserMatchClass = AddrMode5AsmOperand;
783 let MIOperandInfo = (ops GPR:$base, i32imm);
786 // addrmode6 := reg with optional alignment
788 def AddrMode6AsmOperand : AsmOperandClass { let Name = "AlignedMemory"; }
789 def addrmode6 : Operand<i32>,
790 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
791 let PrintMethod = "printAddrMode6Operand";
792 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
793 let EncoderMethod = "getAddrMode6AddressOpValue";
794 let DecoderMethod = "DecodeAddrMode6Operand";
795 let ParserMatchClass = AddrMode6AsmOperand;
798 def am6offset : Operand<i32>,
799 ComplexPattern<i32, 1, "SelectAddrMode6Offset",
800 [], [SDNPWantRoot]> {
801 let PrintMethod = "printAddrMode6OffsetOperand";
802 let MIOperandInfo = (ops GPR);
803 let EncoderMethod = "getAddrMode6OffsetOpValue";
804 let DecoderMethod = "DecodeGPRRegisterClass";
807 // Special version of addrmode6 to handle alignment encoding for VST1/VLD1
808 // (single element from one lane) for size 32.
809 def addrmode6oneL32 : Operand<i32>,
810 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
811 let PrintMethod = "printAddrMode6Operand";
812 let MIOperandInfo = (ops GPR:$addr, i32imm);
813 let EncoderMethod = "getAddrMode6OneLane32AddressOpValue";
816 // Special version of addrmode6 to handle alignment encoding for VLD-dup
817 // instructions, specifically VLD4-dup.
818 def addrmode6dup : Operand<i32>,
819 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
820 let PrintMethod = "printAddrMode6Operand";
821 let MIOperandInfo = (ops GPR:$addr, i32imm);
822 let EncoderMethod = "getAddrMode6DupAddressOpValue";
823 // FIXME: This is close, but not quite right. The alignment specifier is
825 let ParserMatchClass = AddrMode6AsmOperand;
828 // addrmodepc := pc + reg
830 def addrmodepc : Operand<i32>,
831 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
832 let PrintMethod = "printAddrModePCOperand";
833 let MIOperandInfo = (ops GPR, i32imm);
836 // addr_offset_none := reg
838 def MemNoOffsetAsmOperand : AsmOperandClass { let Name = "MemNoOffset"; }
839 def addr_offset_none : Operand<i32>,
840 ComplexPattern<i32, 1, "SelectAddrOffsetNone", []> {
841 let PrintMethod = "printAddrMode7Operand";
842 let DecoderMethod = "DecodeAddrMode7Operand";
843 let ParserMatchClass = MemNoOffsetAsmOperand;
844 let MIOperandInfo = (ops GPR:$base);
847 def nohash_imm : Operand<i32> {
848 let PrintMethod = "printNoHashImmediate";
851 def CoprocNumAsmOperand : AsmOperandClass {
852 let Name = "CoprocNum";
853 let ParserMethod = "parseCoprocNumOperand";
855 def p_imm : Operand<i32> {
856 let PrintMethod = "printPImmediate";
857 let ParserMatchClass = CoprocNumAsmOperand;
858 let DecoderMethod = "DecodeCoprocessor";
861 def CoprocRegAsmOperand : AsmOperandClass {
862 let Name = "CoprocReg";
863 let ParserMethod = "parseCoprocRegOperand";
865 def c_imm : Operand<i32> {
866 let PrintMethod = "printCImmediate";
867 let ParserMatchClass = CoprocRegAsmOperand;
869 def CoprocOptionAsmOperand : AsmOperandClass {
870 let Name = "CoprocOption";
871 let ParserMethod = "parseCoprocOptionOperand";
873 def coproc_option_imm : Operand<i32> {
874 let PrintMethod = "printCoprocOptionImm";
875 let ParserMatchClass = CoprocOptionAsmOperand;
878 //===----------------------------------------------------------------------===//
880 include "ARMInstrFormats.td"
882 //===----------------------------------------------------------------------===//
883 // Multiclass helpers...
886 /// AsI1_bin_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns for a
887 /// binop that produces a value.
888 multiclass AsI1_bin_irs<bits<4> opcod, string opc,
889 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
890 PatFrag opnode, string baseOpc, bit Commutable = 0> {
891 // The register-immediate version is re-materializable. This is useful
892 // in particular for taking the address of a local.
893 let isReMaterializable = 1 in {
894 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
895 iii, opc, "\t$Rd, $Rn, $imm",
896 [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]> {
901 let Inst{19-16} = Rn;
902 let Inst{15-12} = Rd;
903 let Inst{11-0} = imm;
906 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
907 iir, opc, "\t$Rd, $Rn, $Rm",
908 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]> {
913 let isCommutable = Commutable;
914 let Inst{19-16} = Rn;
915 let Inst{15-12} = Rd;
916 let Inst{11-4} = 0b00000000;
920 def rsi : AsI1<opcod, (outs GPR:$Rd),
921 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
922 iis, opc, "\t$Rd, $Rn, $shift",
923 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_imm:$shift))]> {
928 let Inst{19-16} = Rn;
929 let Inst{15-12} = Rd;
930 let Inst{11-5} = shift{11-5};
932 let Inst{3-0} = shift{3-0};
935 def rsr : AsI1<opcod, (outs GPR:$Rd),
936 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
937 iis, opc, "\t$Rd, $Rn, $shift",
938 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_reg:$shift))]> {
943 let Inst{19-16} = Rn;
944 let Inst{15-12} = Rd;
945 let Inst{11-8} = shift{11-8};
947 let Inst{6-5} = shift{6-5};
949 let Inst{3-0} = shift{3-0};
952 // Assembly aliases for optional destination operand when it's the same
953 // as the source operand.
954 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $imm"),
955 (!cast<Instruction>(!strconcat(baseOpc, "ri")) GPR:$Rdn, GPR:$Rdn,
956 so_imm:$imm, pred:$p,
959 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $Rm"),
960 (!cast<Instruction>(!strconcat(baseOpc, "rr")) GPR:$Rdn, GPR:$Rdn,
964 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
965 (!cast<Instruction>(!strconcat(baseOpc, "rsi")) GPR:$Rdn, GPR:$Rdn,
966 so_reg_imm:$shift, pred:$p,
969 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
970 (!cast<Instruction>(!strconcat(baseOpc, "rsr")) GPR:$Rdn, GPR:$Rdn,
971 so_reg_reg:$shift, pred:$p,
977 /// AsI1_rbin_irs - Same as AsI1_bin_irs except the order of operands are
978 /// reversed. The 'rr' form is only defined for the disassembler; for codegen
979 /// it is equivalent to the AsI1_bin_irs counterpart.
980 multiclass AsI1_rbin_irs<bits<4> opcod, string opc,
981 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
982 PatFrag opnode, string baseOpc, bit Commutable = 0> {
983 // The register-immediate version is re-materializable. This is useful
984 // in particular for taking the address of a local.
985 let isReMaterializable = 1 in {
986 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
987 iii, opc, "\t$Rd, $Rn, $imm",
988 [(set GPR:$Rd, (opnode so_imm:$imm, GPR:$Rn))]> {
993 let Inst{19-16} = Rn;
994 let Inst{15-12} = Rd;
995 let Inst{11-0} = imm;
998 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
999 iir, opc, "\t$Rd, $Rn, $Rm",
1000 [/* pattern left blank */]> {
1004 let Inst{11-4} = 0b00000000;
1007 let Inst{15-12} = Rd;
1008 let Inst{19-16} = Rn;
1011 def rsi : AsI1<opcod, (outs GPR:$Rd),
1012 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1013 iis, opc, "\t$Rd, $Rn, $shift",
1014 [(set GPR:$Rd, (opnode so_reg_imm:$shift, GPR:$Rn))]> {
1019 let Inst{19-16} = Rn;
1020 let Inst{15-12} = Rd;
1021 let Inst{11-5} = shift{11-5};
1023 let Inst{3-0} = shift{3-0};
1026 def rsr : AsI1<opcod, (outs GPR:$Rd),
1027 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1028 iis, opc, "\t$Rd, $Rn, $shift",
1029 [(set GPR:$Rd, (opnode so_reg_reg:$shift, GPR:$Rn))]> {
1034 let Inst{19-16} = Rn;
1035 let Inst{15-12} = Rd;
1036 let Inst{11-8} = shift{11-8};
1038 let Inst{6-5} = shift{6-5};
1040 let Inst{3-0} = shift{3-0};
1043 // Assembly aliases for optional destination operand when it's the same
1044 // as the source operand.
1045 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $imm"),
1046 (!cast<Instruction>(!strconcat(baseOpc, "ri")) GPR:$Rdn, GPR:$Rdn,
1047 so_imm:$imm, pred:$p,
1050 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $Rm"),
1051 (!cast<Instruction>(!strconcat(baseOpc, "rr")) GPR:$Rdn, GPR:$Rdn,
1055 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1056 (!cast<Instruction>(!strconcat(baseOpc, "rsi")) GPR:$Rdn, GPR:$Rdn,
1057 so_reg_imm:$shift, pred:$p,
1060 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1061 (!cast<Instruction>(!strconcat(baseOpc, "rsr")) GPR:$Rdn, GPR:$Rdn,
1062 so_reg_reg:$shift, pred:$p,
1068 /// AsI1_bin_s_irs - Same as AsI1_bin_irs except it sets the 's' bit by default.
1070 /// These opcodes will be converted to the real non-S opcodes by
1071 /// AdjustInstrPostInstrSelection after giving them an optional CPSR operand.
1072 let hasPostISelHook = 1, Defs = [CPSR] in {
1073 multiclass AsI1_bin_s_irs<InstrItinClass iii, InstrItinClass iir,
1074 InstrItinClass iis, PatFrag opnode,
1075 bit Commutable = 0> {
1076 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm, pred:$p),
1078 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_imm:$imm))]>;
1080 def rr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, pred:$p),
1082 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm))]> {
1083 let isCommutable = Commutable;
1085 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1086 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1088 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1089 so_reg_imm:$shift))]>;
1091 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1092 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1094 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1095 so_reg_reg:$shift))]>;
1099 /// AsI1_rbin_s_is - Same as AsI1_bin_s_irs, except selection DAG
1100 /// operands are reversed.
1101 let hasPostISelHook = 1, Defs = [CPSR] in {
1102 multiclass AsI1_rbin_s_is<InstrItinClass iii, InstrItinClass iir,
1103 InstrItinClass iis, PatFrag opnode,
1104 bit Commutable = 0> {
1105 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm, pred:$p),
1107 [(set GPR:$Rd, CPSR, (opnode so_imm:$imm, GPR:$Rn))]>;
1109 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1110 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1112 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift,
1115 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1116 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1118 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift,
1123 /// AI1_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
1124 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
1125 /// a explicit result, only implicitly set CPSR.
1126 let isCompare = 1, Defs = [CPSR] in {
1127 multiclass AI1_cmp_irs<bits<4> opcod, string opc,
1128 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1129 PatFrag opnode, bit Commutable = 0> {
1130 def ri : AI1<opcod, (outs), (ins GPR:$Rn, so_imm:$imm), DPFrm, iii,
1132 [(opnode GPR:$Rn, so_imm:$imm)]> {
1137 let Inst{19-16} = Rn;
1138 let Inst{15-12} = 0b0000;
1139 let Inst{11-0} = imm;
1141 def rr : AI1<opcod, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, iir,
1143 [(opnode GPR:$Rn, GPR:$Rm)]> {
1146 let isCommutable = Commutable;
1149 let Inst{19-16} = Rn;
1150 let Inst{15-12} = 0b0000;
1151 let Inst{11-4} = 0b00000000;
1154 def rsi : AI1<opcod, (outs),
1155 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, iis,
1156 opc, "\t$Rn, $shift",
1157 [(opnode GPR:$Rn, so_reg_imm:$shift)]> {
1162 let Inst{19-16} = Rn;
1163 let Inst{15-12} = 0b0000;
1164 let Inst{11-5} = shift{11-5};
1166 let Inst{3-0} = shift{3-0};
1168 def rsr : AI1<opcod, (outs),
1169 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, iis,
1170 opc, "\t$Rn, $shift",
1171 [(opnode GPR:$Rn, so_reg_reg:$shift)]> {
1176 let Inst{19-16} = Rn;
1177 let Inst{15-12} = 0b0000;
1178 let Inst{11-8} = shift{11-8};
1180 let Inst{6-5} = shift{6-5};
1182 let Inst{3-0} = shift{3-0};
1188 /// AI_ext_rrot - A unary operation with two forms: one whose operand is a
1189 /// register and one whose operand is a register rotated by 8/16/24.
1190 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
1191 class AI_ext_rrot<bits<8> opcod, string opc, PatFrag opnode>
1192 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1193 IIC_iEXTr, opc, "\t$Rd, $Rm$rot",
1194 [(set GPRnopc:$Rd, (opnode (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1195 Requires<[IsARM, HasV6]> {
1199 let Inst{19-16} = 0b1111;
1200 let Inst{15-12} = Rd;
1201 let Inst{11-10} = rot;
1205 class AI_ext_rrot_np<bits<8> opcod, string opc>
1206 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1207 IIC_iEXTr, opc, "\t$Rd, $Rm$rot", []>,
1208 Requires<[IsARM, HasV6]> {
1210 let Inst{19-16} = 0b1111;
1211 let Inst{11-10} = rot;
1214 /// AI_exta_rrot - A binary operation with two forms: one whose operand is a
1215 /// register and one whose operand is a register rotated by 8/16/24.
1216 class AI_exta_rrot<bits<8> opcod, string opc, PatFrag opnode>
1217 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1218 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot",
1219 [(set GPRnopc:$Rd, (opnode GPR:$Rn,
1220 (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1221 Requires<[IsARM, HasV6]> {
1226 let Inst{19-16} = Rn;
1227 let Inst{15-12} = Rd;
1228 let Inst{11-10} = rot;
1229 let Inst{9-4} = 0b000111;
1233 class AI_exta_rrot_np<bits<8> opcod, string opc>
1234 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1235 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot", []>,
1236 Requires<[IsARM, HasV6]> {
1239 let Inst{19-16} = Rn;
1240 let Inst{11-10} = rot;
1243 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
1244 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
1245 string baseOpc, bit Commutable = 0> {
1246 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1247 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
1248 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1249 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_imm:$imm, CPSR))]>,
1255 let Inst{15-12} = Rd;
1256 let Inst{19-16} = Rn;
1257 let Inst{11-0} = imm;
1259 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1260 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1261 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm, CPSR))]>,
1266 let Inst{11-4} = 0b00000000;
1268 let isCommutable = Commutable;
1270 let Inst{15-12} = Rd;
1271 let Inst{19-16} = Rn;
1273 def rsi : AsI1<opcod, (outs GPR:$Rd),
1274 (ins GPR:$Rn, so_reg_imm:$shift),
1275 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1276 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_imm:$shift, CPSR))]>,
1282 let Inst{19-16} = Rn;
1283 let Inst{15-12} = Rd;
1284 let Inst{11-5} = shift{11-5};
1286 let Inst{3-0} = shift{3-0};
1288 def rsr : AsI1<opcod, (outs GPR:$Rd),
1289 (ins GPR:$Rn, so_reg_reg:$shift),
1290 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1291 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_reg:$shift, CPSR))]>,
1297 let Inst{19-16} = Rn;
1298 let Inst{15-12} = Rd;
1299 let Inst{11-8} = shift{11-8};
1301 let Inst{6-5} = shift{6-5};
1303 let Inst{3-0} = shift{3-0};
1307 // Assembly aliases for optional destination operand when it's the same
1308 // as the source operand.
1309 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $imm"),
1310 (!cast<Instruction>(!strconcat(baseOpc, "ri")) GPR:$Rdn, GPR:$Rdn,
1311 so_imm:$imm, pred:$p,
1314 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $Rm"),
1315 (!cast<Instruction>(!strconcat(baseOpc, "rr")) GPR:$Rdn, GPR:$Rdn,
1319 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1320 (!cast<Instruction>(!strconcat(baseOpc, "rsi")) GPR:$Rdn, GPR:$Rdn,
1321 so_reg_imm:$shift, pred:$p,
1324 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1325 (!cast<Instruction>(!strconcat(baseOpc, "rsr")) GPR:$Rdn, GPR:$Rdn,
1326 so_reg_reg:$shift, pred:$p,
1331 /// AI1_rsc_irs - Define instructions and patterns for rsc
1332 multiclass AI1_rsc_irs<bits<4> opcod, string opc, PatFrag opnode,
1334 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1335 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
1336 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1337 [(set GPR:$Rd, CPSR, (opnode so_imm:$imm, GPR:$Rn, CPSR))]>,
1343 let Inst{15-12} = Rd;
1344 let Inst{19-16} = Rn;
1345 let Inst{11-0} = imm;
1347 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1348 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1349 [/* pattern left blank */]> {
1353 let Inst{11-4} = 0b00000000;
1356 let Inst{15-12} = Rd;
1357 let Inst{19-16} = Rn;
1359 def rsi : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_imm:$shift),
1360 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1361 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift, GPR:$Rn, CPSR))]>,
1367 let Inst{19-16} = Rn;
1368 let Inst{15-12} = Rd;
1369 let Inst{11-5} = shift{11-5};
1371 let Inst{3-0} = shift{3-0};
1373 def rsr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_reg:$shift),
1374 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1375 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift, GPR:$Rn, CPSR))]>,
1381 let Inst{19-16} = Rn;
1382 let Inst{15-12} = Rd;
1383 let Inst{11-8} = shift{11-8};
1385 let Inst{6-5} = shift{6-5};
1387 let Inst{3-0} = shift{3-0};
1391 // Assembly aliases for optional destination operand when it's the same
1392 // as the source operand.
1393 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $imm"),
1394 (!cast<Instruction>(!strconcat(baseOpc, "ri")) GPR:$Rdn, GPR:$Rdn,
1395 so_imm:$imm, pred:$p,
1398 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $Rm"),
1399 (!cast<Instruction>(!strconcat(baseOpc, "rr")) GPR:$Rdn, GPR:$Rdn,
1403 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1404 (!cast<Instruction>(!strconcat(baseOpc, "rsi")) GPR:$Rdn, GPR:$Rdn,
1405 so_reg_imm:$shift, pred:$p,
1408 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1409 (!cast<Instruction>(!strconcat(baseOpc, "rsr")) GPR:$Rdn, GPR:$Rdn,
1410 so_reg_reg:$shift, pred:$p,
1415 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1416 multiclass AI_ldr1<bit isByte, string opc, InstrItinClass iii,
1417 InstrItinClass iir, PatFrag opnode> {
1418 // Note: We use the complex addrmode_imm12 rather than just an input
1419 // GPR and a constrained immediate so that we can use this to match
1420 // frame index references and avoid matching constant pool references.
1421 def i12: AI2ldst<0b010, 1, isByte, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
1422 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1423 [(set GPR:$Rt, (opnode addrmode_imm12:$addr))]> {
1426 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1427 let Inst{19-16} = addr{16-13}; // Rn
1428 let Inst{15-12} = Rt;
1429 let Inst{11-0} = addr{11-0}; // imm12
1431 def rs : AI2ldst<0b011, 1, isByte, (outs GPR:$Rt), (ins ldst_so_reg:$shift),
1432 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1433 [(set GPR:$Rt, (opnode ldst_so_reg:$shift))]> {
1436 let shift{4} = 0; // Inst{4} = 0
1437 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1438 let Inst{19-16} = shift{16-13}; // Rn
1439 let Inst{15-12} = Rt;
1440 let Inst{11-0} = shift{11-0};
1445 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1446 multiclass AI_ldr1nopc<bit isByte, string opc, InstrItinClass iii,
1447 InstrItinClass iir, PatFrag opnode> {
1448 // Note: We use the complex addrmode_imm12 rather than just an input
1449 // GPR and a constrained immediate so that we can use this to match
1450 // frame index references and avoid matching constant pool references.
1451 def i12: AI2ldst<0b010, 1, isByte, (outs GPRnopc:$Rt), (ins addrmode_imm12:$addr),
1452 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1453 [(set GPRnopc:$Rt, (opnode addrmode_imm12:$addr))]> {
1456 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1457 let Inst{19-16} = addr{16-13}; // Rn
1458 let Inst{15-12} = Rt;
1459 let Inst{11-0} = addr{11-0}; // imm12
1461 def rs : AI2ldst<0b011, 1, isByte, (outs GPRnopc:$Rt), (ins ldst_so_reg:$shift),
1462 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1463 [(set GPRnopc:$Rt, (opnode ldst_so_reg:$shift))]> {
1466 let shift{4} = 0; // Inst{4} = 0
1467 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1468 let Inst{19-16} = shift{16-13}; // Rn
1469 let Inst{15-12} = Rt;
1470 let Inst{11-0} = shift{11-0};
1476 multiclass AI_str1<bit isByte, string opc, InstrItinClass iii,
1477 InstrItinClass iir, PatFrag opnode> {
1478 // Note: We use the complex addrmode_imm12 rather than just an input
1479 // GPR and a constrained immediate so that we can use this to match
1480 // frame index references and avoid matching constant pool references.
1481 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1482 (ins GPR:$Rt, addrmode_imm12:$addr),
1483 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1484 [(opnode GPR:$Rt, addrmode_imm12:$addr)]> {
1487 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1488 let Inst{19-16} = addr{16-13}; // Rn
1489 let Inst{15-12} = Rt;
1490 let Inst{11-0} = addr{11-0}; // imm12
1492 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPR:$Rt, ldst_so_reg:$shift),
1493 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1494 [(opnode GPR:$Rt, ldst_so_reg:$shift)]> {
1497 let shift{4} = 0; // Inst{4} = 0
1498 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1499 let Inst{19-16} = shift{16-13}; // Rn
1500 let Inst{15-12} = Rt;
1501 let Inst{11-0} = shift{11-0};
1505 multiclass AI_str1nopc<bit isByte, string opc, InstrItinClass iii,
1506 InstrItinClass iir, PatFrag opnode> {
1507 // Note: We use the complex addrmode_imm12 rather than just an input
1508 // GPR and a constrained immediate so that we can use this to match
1509 // frame index references and avoid matching constant pool references.
1510 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1511 (ins GPRnopc:$Rt, addrmode_imm12:$addr),
1512 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1513 [(opnode GPRnopc:$Rt, addrmode_imm12:$addr)]> {
1516 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1517 let Inst{19-16} = addr{16-13}; // Rn
1518 let Inst{15-12} = Rt;
1519 let Inst{11-0} = addr{11-0}; // imm12
1521 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPRnopc:$Rt, ldst_so_reg:$shift),
1522 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1523 [(opnode GPRnopc:$Rt, ldst_so_reg:$shift)]> {
1526 let shift{4} = 0; // Inst{4} = 0
1527 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1528 let Inst{19-16} = shift{16-13}; // Rn
1529 let Inst{15-12} = Rt;
1530 let Inst{11-0} = shift{11-0};
1535 //===----------------------------------------------------------------------===//
1537 //===----------------------------------------------------------------------===//
1539 //===----------------------------------------------------------------------===//
1540 // Miscellaneous Instructions.
1543 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
1544 /// the function. The first operand is the ID# for this instruction, the second
1545 /// is the index into the MachineConstantPool that this is, the third is the
1546 /// size in bytes of this constant pool entry.
1547 let neverHasSideEffects = 1, isNotDuplicable = 1 in
1548 def CONSTPOOL_ENTRY :
1549 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1550 i32imm:$size), NoItinerary, []>;
1552 // FIXME: Marking these as hasSideEffects is necessary to prevent machine DCE
1553 // from removing one half of the matched pairs. That breaks PEI, which assumes
1554 // these will always be in pairs, and asserts if it finds otherwise. Better way?
1555 let Defs = [SP], Uses = [SP], hasSideEffects = 1 in {
1556 def ADJCALLSTACKUP :
1557 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary,
1558 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
1560 def ADJCALLSTACKDOWN :
1561 PseudoInst<(outs), (ins i32imm:$amt, pred:$p), NoItinerary,
1562 [(ARMcallseq_start timm:$amt)]>;
1565 // Atomic pseudo-insts which will be lowered to ldrexd/strexd loops.
1566 // (These pseudos use a hand-written selection code).
1567 let usesCustomInserter = 1, Defs = [CPSR], mayLoad = 1, mayStore = 1 in {
1568 def ATOMOR6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1569 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1571 def ATOMXOR6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1572 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1574 def ATOMADD6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1575 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1577 def ATOMSUB6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1578 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1580 def ATOMNAND6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1581 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1583 def ATOMAND6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1584 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1586 def ATOMSWAP6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1587 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1589 def ATOMCMPXCHG6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1590 (ins GPR:$addr, GPR:$cmp1, GPR:$cmp2,
1591 GPR:$set1, GPR:$set2),
1595 def NOP : AI<(outs), (ins), MiscFrm, NoItinerary, "nop", "", []>,
1596 Requires<[IsARM, HasV6T2]> {
1597 let Inst{27-16} = 0b001100100000;
1598 let Inst{15-8} = 0b11110000;
1599 let Inst{7-0} = 0b00000000;
1602 def YIELD : AI<(outs), (ins), MiscFrm, NoItinerary, "yield", "", []>,
1603 Requires<[IsARM, HasV6T2]> {
1604 let Inst{27-16} = 0b001100100000;
1605 let Inst{15-8} = 0b11110000;
1606 let Inst{7-0} = 0b00000001;
1609 def WFE : AI<(outs), (ins), MiscFrm, NoItinerary, "wfe", "", []>,
1610 Requires<[IsARM, HasV6T2]> {
1611 let Inst{27-16} = 0b001100100000;
1612 let Inst{15-8} = 0b11110000;
1613 let Inst{7-0} = 0b00000010;
1616 def WFI : AI<(outs), (ins), MiscFrm, NoItinerary, "wfi", "", []>,
1617 Requires<[IsARM, HasV6T2]> {
1618 let Inst{27-16} = 0b001100100000;
1619 let Inst{15-8} = 0b11110000;
1620 let Inst{7-0} = 0b00000011;
1623 def SEL : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, NoItinerary, "sel",
1624 "\t$Rd, $Rn, $Rm", []>, Requires<[IsARM, HasV6]> {
1629 let Inst{15-12} = Rd;
1630 let Inst{19-16} = Rn;
1631 let Inst{27-20} = 0b01101000;
1632 let Inst{7-4} = 0b1011;
1633 let Inst{11-8} = 0b1111;
1636 def SEV : AI<(outs), (ins), MiscFrm, NoItinerary, "sev", "",
1637 []>, Requires<[IsARM, HasV6T2]> {
1638 let Inst{27-16} = 0b001100100000;
1639 let Inst{15-8} = 0b11110000;
1640 let Inst{7-0} = 0b00000100;
1643 // The i32imm operand $val can be used by a debugger to store more information
1644 // about the breakpoint.
1645 def BKPT : AI<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
1646 "bkpt", "\t$val", []>, Requires<[IsARM]> {
1648 let Inst{3-0} = val{3-0};
1649 let Inst{19-8} = val{15-4};
1650 let Inst{27-20} = 0b00010010;
1651 let Inst{7-4} = 0b0111;
1654 // Change Processor State
1655 // FIXME: We should use InstAlias to handle the optional operands.
1656 class CPS<dag iops, string asm_ops>
1657 : AXI<(outs), iops, MiscFrm, NoItinerary, !strconcat("cps", asm_ops),
1658 []>, Requires<[IsARM]> {
1664 let Inst{31-28} = 0b1111;
1665 let Inst{27-20} = 0b00010000;
1666 let Inst{19-18} = imod;
1667 let Inst{17} = M; // Enabled if mode is set;
1668 let Inst{16-9} = 0b00000000;
1669 let Inst{8-6} = iflags;
1671 let Inst{4-0} = mode;
1674 let DecoderMethod = "DecodeCPSInstruction" in {
1676 def CPS3p : CPS<(ins imod_op:$imod, iflags_op:$iflags, imm0_31:$mode),
1677 "$imod\t$iflags, $mode">;
1678 let mode = 0, M = 0 in
1679 def CPS2p : CPS<(ins imod_op:$imod, iflags_op:$iflags), "$imod\t$iflags">;
1681 let imod = 0, iflags = 0, M = 1 in
1682 def CPS1p : CPS<(ins imm0_31:$mode), "\t$mode">;
1685 // Preload signals the memory system of possible future data/instruction access.
1686 multiclass APreLoad<bits<1> read, bits<1> data, string opc> {
1688 def i12 : AXI<(outs), (ins addrmode_imm12:$addr), MiscFrm, IIC_Preload,
1689 !strconcat(opc, "\t$addr"),
1690 [(ARMPreload addrmode_imm12:$addr, (i32 read), (i32 data))]> {
1693 let Inst{31-26} = 0b111101;
1694 let Inst{25} = 0; // 0 for immediate form
1695 let Inst{24} = data;
1696 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1697 let Inst{22} = read;
1698 let Inst{21-20} = 0b01;
1699 let Inst{19-16} = addr{16-13}; // Rn
1700 let Inst{15-12} = 0b1111;
1701 let Inst{11-0} = addr{11-0}; // imm12
1704 def rs : AXI<(outs), (ins ldst_so_reg:$shift), MiscFrm, IIC_Preload,
1705 !strconcat(opc, "\t$shift"),
1706 [(ARMPreload ldst_so_reg:$shift, (i32 read), (i32 data))]> {
1708 let Inst{31-26} = 0b111101;
1709 let Inst{25} = 1; // 1 for register form
1710 let Inst{24} = data;
1711 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1712 let Inst{22} = read;
1713 let Inst{21-20} = 0b01;
1714 let Inst{19-16} = shift{16-13}; // Rn
1715 let Inst{15-12} = 0b1111;
1716 let Inst{11-0} = shift{11-0};
1721 defm PLD : APreLoad<1, 1, "pld">, Requires<[IsARM]>;
1722 defm PLDW : APreLoad<0, 1, "pldw">, Requires<[IsARM,HasV7,HasMP]>;
1723 defm PLI : APreLoad<1, 0, "pli">, Requires<[IsARM,HasV7]>;
1725 def SETEND : AXI<(outs), (ins setend_op:$end), MiscFrm, NoItinerary,
1726 "setend\t$end", []>, Requires<[IsARM]> {
1728 let Inst{31-10} = 0b1111000100000001000000;
1733 def DBG : AI<(outs), (ins imm0_15:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt",
1734 []>, Requires<[IsARM, HasV7]> {
1736 let Inst{27-4} = 0b001100100000111100001111;
1737 let Inst{3-0} = opt;
1740 // A5.4 Permanently UNDEFINED instructions.
1741 let isBarrier = 1, isTerminator = 1 in
1742 def TRAP : AXI<(outs), (ins), MiscFrm, NoItinerary,
1745 let Inst = 0xe7ffdefe;
1748 // Address computation and loads and stores in PIC mode.
1749 let isNotDuplicable = 1 in {
1750 def PICADD : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
1752 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>;
1754 let AddedComplexity = 10 in {
1755 def PICLDR : ARMPseudoInst<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
1757 [(set GPR:$dst, (load addrmodepc:$addr))]>;
1759 def PICLDRH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1761 [(set GPR:$Rt, (zextloadi16 addrmodepc:$addr))]>;
1763 def PICLDRB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1765 [(set GPR:$Rt, (zextloadi8 addrmodepc:$addr))]>;
1767 def PICLDRSH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1769 [(set GPR:$Rt, (sextloadi16 addrmodepc:$addr))]>;
1771 def PICLDRSB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1773 [(set GPR:$Rt, (sextloadi8 addrmodepc:$addr))]>;
1775 let AddedComplexity = 10 in {
1776 def PICSTR : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1777 4, IIC_iStore_r, [(store GPR:$src, addrmodepc:$addr)]>;
1779 def PICSTRH : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1780 4, IIC_iStore_bh_r, [(truncstorei16 GPR:$src,
1781 addrmodepc:$addr)]>;
1783 def PICSTRB : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1784 4, IIC_iStore_bh_r, [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
1786 } // isNotDuplicable = 1
1789 // LEApcrel - Load a pc-relative address into a register without offending the
1791 let neverHasSideEffects = 1, isReMaterializable = 1 in
1792 // The 'adr' mnemonic encodes differently if the label is before or after
1793 // the instruction. The {24-21} opcode bits are set by the fixup, as we don't
1794 // know until then which form of the instruction will be used.
1795 def ADR : AI1<{0,?,?,0}, (outs GPR:$Rd), (ins adrlabel:$label),
1796 MiscFrm, IIC_iALUi, "adr", "\t$Rd, $label", []> {
1799 let Inst{27-25} = 0b001;
1801 let Inst{23-22} = label{13-12};
1804 let Inst{19-16} = 0b1111;
1805 let Inst{15-12} = Rd;
1806 let Inst{11-0} = label{11-0};
1808 def LEApcrel : ARMPseudoInst<(outs GPR:$Rd), (ins i32imm:$label, pred:$p),
1811 def LEApcrelJT : ARMPseudoInst<(outs GPR:$Rd),
1812 (ins i32imm:$label, nohash_imm:$id, pred:$p),
1815 //===----------------------------------------------------------------------===//
1816 // Control Flow Instructions.
1819 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
1821 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
1822 "bx", "\tlr", [(ARMretflag)]>,
1823 Requires<[IsARM, HasV4T]> {
1824 let Inst{27-0} = 0b0001001011111111111100011110;
1828 def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br,
1829 "mov", "\tpc, lr", [(ARMretflag)]>,
1830 Requires<[IsARM, NoV4T]> {
1831 let Inst{27-0} = 0b0001101000001111000000001110;
1835 // Indirect branches
1836 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
1838 def BX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
1839 [(brind GPR:$dst)]>,
1840 Requires<[IsARM, HasV4T]> {
1842 let Inst{31-4} = 0b1110000100101111111111110001;
1843 let Inst{3-0} = dst;
1846 def BX_pred : AI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br,
1847 "bx", "\t$dst", [/* pattern left blank */]>,
1848 Requires<[IsARM, HasV4T]> {
1850 let Inst{27-4} = 0b000100101111111111110001;
1851 let Inst{3-0} = dst;
1855 // All calls clobber the non-callee saved registers. SP is marked as
1856 // a use to prevent stack-pointer assignments that appear immediately
1857 // before calls from potentially appearing dead.
1859 // On non-Darwin platforms R9 is callee-saved.
1860 // FIXME: Do we really need a non-predicated version? If so, it should
1861 // at least be a pseudo instruction expanding to the predicated version
1862 // at MC lowering time.
1863 Defs = [R0, R1, R2, R3, R12, LR, QQQQ0, QQQQ2, QQQQ3, CPSR, FPSCR],
1865 def BL : ABXI<0b1011, (outs), (ins bl_target:$func, variable_ops),
1866 IIC_Br, "bl\t$func",
1867 [(ARMcall tglobaladdr:$func)]>,
1868 Requires<[IsARM, IsNotDarwin]> {
1869 let Inst{31-28} = 0b1110;
1871 let Inst{23-0} = func;
1872 let DecoderMethod = "DecodeBranchImmInstruction";
1875 def BL_pred : ABI<0b1011, (outs), (ins bl_target:$func, variable_ops),
1876 IIC_Br, "bl", "\t$func",
1877 [(ARMcall_pred tglobaladdr:$func)]>,
1878 Requires<[IsARM, IsNotDarwin]> {
1880 let Inst{23-0} = func;
1881 let DecoderMethod = "DecodeBranchImmInstruction";
1885 def BLX : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
1886 IIC_Br, "blx\t$func",
1887 [(ARMcall GPR:$func)]>,
1888 Requires<[IsARM, HasV5T, IsNotDarwin]> {
1890 let Inst{31-4} = 0b1110000100101111111111110011;
1891 let Inst{3-0} = func;
1894 def BLX_pred : AI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
1895 IIC_Br, "blx", "\t$func",
1896 [(ARMcall_pred GPR:$func)]>,
1897 Requires<[IsARM, HasV5T, IsNotDarwin]> {
1899 let Inst{27-4} = 0b000100101111111111110011;
1900 let Inst{3-0} = func;
1904 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
1905 def BX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func, variable_ops),
1906 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
1907 Requires<[IsARM, HasV4T, IsNotDarwin]>;
1910 def BMOVPCRX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func, variable_ops),
1911 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
1912 Requires<[IsARM, NoV4T, IsNotDarwin]>;
1916 // On Darwin R9 is call-clobbered.
1917 // R7 is marked as a use to prevent frame-pointer assignments from being
1918 // moved above / below calls.
1919 Defs = [R0, R1, R2, R3, R9, R12, LR, QQQQ0, QQQQ2, QQQQ3, CPSR, FPSCR],
1920 Uses = [R7, SP] in {
1921 def BLr9 : ARMPseudoExpand<(outs), (ins bl_target:$func, variable_ops),
1923 [(ARMcall tglobaladdr:$func)], (BL bl_target:$func)>,
1924 Requires<[IsARM, IsDarwin]>;
1926 def BLr9_pred : ARMPseudoExpand<(outs),
1927 (ins bl_target:$func, pred:$p, variable_ops),
1929 [(ARMcall_pred tglobaladdr:$func)],
1930 (BL_pred bl_target:$func, pred:$p)>,
1931 Requires<[IsARM, IsDarwin]>;
1934 def BLXr9 : ARMPseudoExpand<(outs), (ins GPR:$func, variable_ops),
1936 [(ARMcall GPR:$func)],
1938 Requires<[IsARM, HasV5T, IsDarwin]>;
1940 def BLXr9_pred: ARMPseudoExpand<(outs), (ins GPR:$func, pred:$p,variable_ops),
1942 [(ARMcall_pred GPR:$func)],
1943 (BLX_pred GPR:$func, pred:$p)>,
1944 Requires<[IsARM, HasV5T, IsDarwin]>;
1947 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
1948 def BXr9_CALL : ARMPseudoInst<(outs), (ins tGPR:$func, variable_ops),
1949 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
1950 Requires<[IsARM, HasV4T, IsDarwin]>;
1953 def BMOVPCRXr9_CALL : ARMPseudoInst<(outs), (ins tGPR:$func, variable_ops),
1954 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
1955 Requires<[IsARM, NoV4T, IsDarwin]>;
1958 let isBranch = 1, isTerminator = 1 in {
1959 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
1960 // a two-value operand where a dag node expects two operands. :(
1961 def Bcc : ABI<0b1010, (outs), (ins br_target:$target),
1962 IIC_Br, "b", "\t$target",
1963 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]> {
1965 let Inst{23-0} = target;
1966 let DecoderMethod = "DecodeBranchImmInstruction";
1969 let isBarrier = 1 in {
1970 // B is "predicable" since it's just a Bcc with an 'always' condition.
1971 let isPredicable = 1 in
1972 // FIXME: We shouldn't need this pseudo at all. Just using Bcc directly
1973 // should be sufficient.
1974 // FIXME: Is B really a Barrier? That doesn't seem right.
1975 def B : ARMPseudoExpand<(outs), (ins br_target:$target), 4, IIC_Br,
1976 [(br bb:$target)], (Bcc br_target:$target, (ops 14, zero_reg))>;
1978 let isNotDuplicable = 1, isIndirectBranch = 1 in {
1979 def BR_JTr : ARMPseudoInst<(outs),
1980 (ins GPR:$target, i32imm:$jt, i32imm:$id),
1982 [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]>;
1983 // FIXME: This shouldn't use the generic "addrmode2," but rather be split
1984 // into i12 and rs suffixed versions.
1985 def BR_JTm : ARMPseudoInst<(outs),
1986 (ins addrmode2:$target, i32imm:$jt, i32imm:$id),
1988 [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
1990 def BR_JTadd : ARMPseudoInst<(outs),
1991 (ins GPR:$target, GPR:$idx, i32imm:$jt, i32imm:$id),
1993 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
1995 } // isNotDuplicable = 1, isIndirectBranch = 1
2001 def BLXi : AXI<(outs), (ins blx_target:$target), BrMiscFrm, NoItinerary,
2002 "blx\t$target", []>,
2003 Requires<[IsARM, HasV5T]> {
2004 let Inst{31-25} = 0b1111101;
2006 let Inst{23-0} = target{24-1};
2007 let Inst{24} = target{0};
2010 // Branch and Exchange Jazelle
2011 def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func",
2012 [/* pattern left blank */]> {
2014 let Inst{23-20} = 0b0010;
2015 let Inst{19-8} = 0xfff;
2016 let Inst{7-4} = 0b0010;
2017 let Inst{3-0} = func;
2022 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in {
2024 let Defs = [R0, R1, R2, R3, R9, R12, QQQQ0, QQQQ2, QQQQ3, PC],
2026 def TCRETURNdi : PseudoInst<(outs), (ins i32imm:$dst, variable_ops),
2027 IIC_Br, []>, Requires<[IsDarwin]>;
2029 def TCRETURNri : PseudoInst<(outs), (ins tcGPR:$dst, variable_ops),
2030 IIC_Br, []>, Requires<[IsDarwin]>;
2032 def TAILJMPd : ARMPseudoExpand<(outs), (ins br_target:$dst, variable_ops),
2034 (Bcc br_target:$dst, (ops 14, zero_reg))>,
2035 Requires<[IsARM, IsDarwin]>;
2037 def TAILJMPr : ARMPseudoExpand<(outs), (ins tcGPR:$dst, variable_ops),
2040 Requires<[IsARM, IsDarwin]>;
2044 // Non-Darwin versions (the difference is R9).
2045 let Defs = [R0, R1, R2, R3, R12, QQQQ0, QQQQ2, QQQQ3, PC],
2047 def TCRETURNdiND : PseudoInst<(outs), (ins i32imm:$dst, variable_ops),
2048 IIC_Br, []>, Requires<[IsNotDarwin]>;
2050 def TCRETURNriND : PseudoInst<(outs), (ins tcGPR:$dst, variable_ops),
2051 IIC_Br, []>, Requires<[IsNotDarwin]>;
2053 def TAILJMPdND : ARMPseudoExpand<(outs), (ins brtarget:$dst, variable_ops),
2055 (Bcc br_target:$dst, (ops 14, zero_reg))>,
2056 Requires<[IsARM, IsNotDarwin]>;
2058 def TAILJMPrND : ARMPseudoExpand<(outs), (ins tcGPR:$dst, variable_ops),
2061 Requires<[IsARM, IsNotDarwin]>;
2065 // Secure Monitor Call is a system instruction.
2066 def SMC : ABI<0b0001, (outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt",
2069 let Inst{23-4} = 0b01100000000000000111;
2070 let Inst{3-0} = opt;
2073 // Supervisor Call (Software Interrupt)
2074 let isCall = 1, Uses = [SP] in {
2075 def SVC : ABI<0b1111, (outs), (ins imm24b:$svc), IIC_Br, "svc", "\t$svc", []> {
2077 let Inst{23-0} = svc;
2081 // Store Return State
2082 class SRSI<bit wb, string asm>
2083 : XI<(outs), (ins imm0_31:$mode), AddrModeNone, 4, IndexModeNone, BrFrm,
2084 NoItinerary, asm, "", []> {
2086 let Inst{31-28} = 0b1111;
2087 let Inst{27-25} = 0b100;
2091 let Inst{19-16} = 0b1101; // SP
2092 let Inst{15-5} = 0b00000101000;
2093 let Inst{4-0} = mode;
2096 def SRSDA : SRSI<0, "srsda\tsp, $mode"> {
2097 let Inst{24-23} = 0;
2099 def SRSDA_UPD : SRSI<1, "srsda\tsp!, $mode"> {
2100 let Inst{24-23} = 0;
2102 def SRSDB : SRSI<0, "srsdb\tsp, $mode"> {
2103 let Inst{24-23} = 0b10;
2105 def SRSDB_UPD : SRSI<1, "srsdb\tsp!, $mode"> {
2106 let Inst{24-23} = 0b10;
2108 def SRSIA : SRSI<0, "srsia\tsp, $mode"> {
2109 let Inst{24-23} = 0b01;
2111 def SRSIA_UPD : SRSI<1, "srsia\tsp!, $mode"> {
2112 let Inst{24-23} = 0b01;
2114 def SRSIB : SRSI<0, "srsib\tsp, $mode"> {
2115 let Inst{24-23} = 0b11;
2117 def SRSIB_UPD : SRSI<1, "srsib\tsp!, $mode"> {
2118 let Inst{24-23} = 0b11;
2121 // Return From Exception
2122 class RFEI<bit wb, string asm>
2123 : XI<(outs), (ins GPR:$Rn), AddrModeNone, 4, IndexModeNone, BrFrm,
2124 NoItinerary, asm, "", []> {
2126 let Inst{31-28} = 0b1111;
2127 let Inst{27-25} = 0b100;
2131 let Inst{19-16} = Rn;
2132 let Inst{15-0} = 0xa00;
2135 def RFEDA : RFEI<0, "rfeda\t$Rn"> {
2136 let Inst{24-23} = 0;
2138 def RFEDA_UPD : RFEI<1, "rfeda\t$Rn!"> {
2139 let Inst{24-23} = 0;
2141 def RFEDB : RFEI<0, "rfedb\t$Rn"> {
2142 let Inst{24-23} = 0b10;
2144 def RFEDB_UPD : RFEI<1, "rfedb\t$Rn!"> {
2145 let Inst{24-23} = 0b10;
2147 def RFEIA : RFEI<0, "rfeia\t$Rn"> {
2148 let Inst{24-23} = 0b01;
2150 def RFEIA_UPD : RFEI<1, "rfeia\t$Rn!"> {
2151 let Inst{24-23} = 0b01;
2153 def RFEIB : RFEI<0, "rfeib\t$Rn"> {
2154 let Inst{24-23} = 0b11;
2156 def RFEIB_UPD : RFEI<1, "rfeib\t$Rn!"> {
2157 let Inst{24-23} = 0b11;
2160 //===----------------------------------------------------------------------===//
2161 // Load / Store Instructions.
2167 defm LDR : AI_ldr1<0, "ldr", IIC_iLoad_r, IIC_iLoad_si,
2168 UnOpFrag<(load node:$Src)>>;
2169 defm LDRB : AI_ldr1nopc<1, "ldrb", IIC_iLoad_bh_r, IIC_iLoad_bh_si,
2170 UnOpFrag<(zextloadi8 node:$Src)>>;
2171 defm STR : AI_str1<0, "str", IIC_iStore_r, IIC_iStore_si,
2172 BinOpFrag<(store node:$LHS, node:$RHS)>>;
2173 defm STRB : AI_str1nopc<1, "strb", IIC_iStore_bh_r, IIC_iStore_bh_si,
2174 BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
2176 // Special LDR for loads from non-pc-relative constpools.
2177 let canFoldAsLoad = 1, mayLoad = 1, neverHasSideEffects = 1,
2178 isReMaterializable = 1, isCodeGenOnly = 1 in
2179 def LDRcp : AI2ldst<0b010, 1, 0, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
2180 AddrMode_i12, LdFrm, IIC_iLoad_r, "ldr", "\t$Rt, $addr",
2184 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2185 let Inst{19-16} = 0b1111;
2186 let Inst{15-12} = Rt;
2187 let Inst{11-0} = addr{11-0}; // imm12
2190 // Loads with zero extension
2191 def LDRH : AI3ld<0b1011, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2192 IIC_iLoad_bh_r, "ldrh", "\t$Rt, $addr",
2193 [(set GPR:$Rt, (zextloadi16 addrmode3:$addr))]>;
2195 // Loads with sign extension
2196 def LDRSH : AI3ld<0b1111, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2197 IIC_iLoad_bh_r, "ldrsh", "\t$Rt, $addr",
2198 [(set GPR:$Rt, (sextloadi16 addrmode3:$addr))]>;
2200 def LDRSB : AI3ld<0b1101, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2201 IIC_iLoad_bh_r, "ldrsb", "\t$Rt, $addr",
2202 [(set GPR:$Rt, (sextloadi8 addrmode3:$addr))]>;
2204 let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1 in {
2206 def LDRD : AI3ld<0b1101, 0, (outs GPR:$Rd, GPR:$dst2),
2207 (ins addrmode3:$addr), LdMiscFrm,
2208 IIC_iLoad_d_r, "ldrd", "\t$Rd, $dst2, $addr",
2209 []>, Requires<[IsARM, HasV5TE]>;
2213 multiclass AI2_ldridx<bit isByte, string opc,
2214 InstrItinClass iii, InstrItinClass iir> {
2215 def _PRE_IMM : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2216 (ins addrmode_imm12:$addr), IndexModePre, LdFrm, iii,
2217 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2220 let Inst{23} = addr{12};
2221 let Inst{19-16} = addr{16-13};
2222 let Inst{11-0} = addr{11-0};
2223 let DecoderMethod = "DecodeLDRPreImm";
2224 let AsmMatchConverter = "cvtLdWriteBackRegAddrModeImm12";
2227 def _PRE_REG : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2228 (ins ldst_so_reg:$addr), IndexModePre, LdFrm, iir,
2229 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2232 let Inst{23} = addr{12};
2233 let Inst{19-16} = addr{16-13};
2234 let Inst{11-0} = addr{11-0};
2236 let DecoderMethod = "DecodeLDRPreReg";
2237 let AsmMatchConverter = "cvtLdWriteBackRegAddrMode2";
2240 def _POST_REG : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2241 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2242 IndexModePost, LdFrm, iir,
2243 opc, "\t$Rt, $addr, $offset",
2244 "$addr.base = $Rn_wb", []> {
2250 let Inst{23} = offset{12};
2251 let Inst{19-16} = addr;
2252 let Inst{11-0} = offset{11-0};
2254 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2257 def _POST_IMM : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2258 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2259 IndexModePost, LdFrm, iii,
2260 opc, "\t$Rt, $addr, $offset",
2261 "$addr.base = $Rn_wb", []> {
2267 let Inst{23} = offset{12};
2268 let Inst{19-16} = addr;
2269 let Inst{11-0} = offset{11-0};
2271 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2276 let mayLoad = 1, neverHasSideEffects = 1 in {
2277 // FIXME: for LDR_PRE_REG etc. the itineray should be either IIC_iLoad_ru or
2278 // IIC_iLoad_siu depending on whether it the offset register is shifted.
2279 defm LDR : AI2_ldridx<0, "ldr", IIC_iLoad_iu, IIC_iLoad_ru>;
2280 defm LDRB : AI2_ldridx<1, "ldrb", IIC_iLoad_bh_iu, IIC_iLoad_bh_ru>;
2283 multiclass AI3_ldridx<bits<4> op, string opc, InstrItinClass itin> {
2284 def _PRE : AI3ldstidx<op, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2285 (ins addrmode3:$addr), IndexModePre,
2287 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2289 let Inst{23} = addr{8}; // U bit
2290 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2291 let Inst{19-16} = addr{12-9}; // Rn
2292 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2293 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2294 let AsmMatchConverter = "cvtLdWriteBackRegAddrMode3";
2295 let DecoderMethod = "DecodeAddrMode3Instruction";
2297 def _POST : AI3ldstidx<op, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2298 (ins addr_offset_none:$addr, am3offset:$offset),
2299 IndexModePost, LdMiscFrm, itin,
2300 opc, "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2304 let Inst{23} = offset{8}; // U bit
2305 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2306 let Inst{19-16} = addr;
2307 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2308 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2309 let DecoderMethod = "DecodeAddrMode3Instruction";
2313 let mayLoad = 1, neverHasSideEffects = 1 in {
2314 defm LDRH : AI3_ldridx<0b1011, "ldrh", IIC_iLoad_bh_ru>;
2315 defm LDRSH : AI3_ldridx<0b1111, "ldrsh", IIC_iLoad_bh_ru>;
2316 defm LDRSB : AI3_ldridx<0b1101, "ldrsb", IIC_iLoad_bh_ru>;
2317 let hasExtraDefRegAllocReq = 1 in {
2318 def LDRD_PRE : AI3ldstidx<0b1101, 0, 1, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2319 (ins addrmode3:$addr), IndexModePre,
2320 LdMiscFrm, IIC_iLoad_d_ru,
2321 "ldrd", "\t$Rt, $Rt2, $addr!",
2322 "$addr.base = $Rn_wb", []> {
2324 let Inst{23} = addr{8}; // U bit
2325 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2326 let Inst{19-16} = addr{12-9}; // Rn
2327 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2328 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2329 let DecoderMethod = "DecodeAddrMode3Instruction";
2330 let AsmMatchConverter = "cvtLdrdPre";
2332 def LDRD_POST: AI3ldstidx<0b1101, 0, 0, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2333 (ins addr_offset_none:$addr, am3offset:$offset),
2334 IndexModePost, LdMiscFrm, IIC_iLoad_d_ru,
2335 "ldrd", "\t$Rt, $Rt2, $addr, $offset",
2336 "$addr.base = $Rn_wb", []> {
2339 let Inst{23} = offset{8}; // U bit
2340 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2341 let Inst{19-16} = addr;
2342 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2343 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2344 let DecoderMethod = "DecodeAddrMode3Instruction";
2346 } // hasExtraDefRegAllocReq = 1
2347 } // mayLoad = 1, neverHasSideEffects = 1
2349 // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT.
2350 let mayLoad = 1, neverHasSideEffects = 1 in {
2351 def LDRT_POST_REG : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2352 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2353 IndexModePost, LdFrm, IIC_iLoad_ru,
2354 "ldrt", "\t$Rt, $addr, $offset",
2355 "$addr.base = $Rn_wb", []> {
2361 let Inst{23} = offset{12};
2362 let Inst{21} = 1; // overwrite
2363 let Inst{19-16} = addr;
2364 let Inst{11-5} = offset{11-5};
2366 let Inst{3-0} = offset{3-0};
2367 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2370 def LDRT_POST_IMM : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2371 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2372 IndexModePost, LdFrm, IIC_iLoad_ru,
2373 "ldrt", "\t$Rt, $addr, $offset",
2374 "$addr.base = $Rn_wb", []> {
2380 let Inst{23} = offset{12};
2381 let Inst{21} = 1; // overwrite
2382 let Inst{19-16} = addr;
2383 let Inst{11-0} = offset{11-0};
2384 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2387 def LDRBT_POST_REG : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2388 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2389 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2390 "ldrbt", "\t$Rt, $addr, $offset",
2391 "$addr.base = $Rn_wb", []> {
2397 let Inst{23} = offset{12};
2398 let Inst{21} = 1; // overwrite
2399 let Inst{19-16} = addr;
2400 let Inst{11-5} = offset{11-5};
2402 let Inst{3-0} = offset{3-0};
2403 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2406 def LDRBT_POST_IMM : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2407 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2408 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2409 "ldrbt", "\t$Rt, $addr, $offset",
2410 "$addr.base = $Rn_wb", []> {
2416 let Inst{23} = offset{12};
2417 let Inst{21} = 1; // overwrite
2418 let Inst{19-16} = addr;
2419 let Inst{11-0} = offset{11-0};
2420 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2423 multiclass AI3ldrT<bits<4> op, string opc> {
2424 def i : AI3ldstidxT<op, 1, (outs GPR:$Rt, GPR:$base_wb),
2425 (ins addr_offset_none:$addr, postidx_imm8:$offset),
2426 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2427 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2429 let Inst{23} = offset{8};
2431 let Inst{11-8} = offset{7-4};
2432 let Inst{3-0} = offset{3-0};
2433 let AsmMatchConverter = "cvtLdExtTWriteBackImm";
2435 def r : AI3ldstidxT<op, 1, (outs GPR:$Rt, GPR:$base_wb),
2436 (ins addr_offset_none:$addr, postidx_reg:$Rm),
2437 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2438 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2440 let Inst{23} = Rm{4};
2443 let Inst{3-0} = Rm{3-0};
2444 let AsmMatchConverter = "cvtLdExtTWriteBackReg";
2448 defm LDRSBT : AI3ldrT<0b1101, "ldrsbt">;
2449 defm LDRHT : AI3ldrT<0b1011, "ldrht">;
2450 defm LDRSHT : AI3ldrT<0b1111, "ldrsht">;
2455 // Stores with truncate
2456 def STRH : AI3str<0b1011, (outs), (ins GPR:$Rt, addrmode3:$addr), StMiscFrm,
2457 IIC_iStore_bh_r, "strh", "\t$Rt, $addr",
2458 [(truncstorei16 GPR:$Rt, addrmode3:$addr)]>;
2461 let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in
2462 def STRD : AI3str<0b1111, (outs), (ins GPR:$Rt, GPR:$src2, addrmode3:$addr),
2463 StMiscFrm, IIC_iStore_d_r,
2464 "strd", "\t$Rt, $src2, $addr", []>,
2465 Requires<[IsARM, HasV5TE]> {
2470 multiclass AI2_stridx<bit isByte, string opc,
2471 InstrItinClass iii, InstrItinClass iir> {
2472 def _PRE_IMM : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2473 (ins GPR:$Rt, addrmode_imm12:$addr), IndexModePre,
2475 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2478 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2479 let Inst{19-16} = addr{16-13}; // Rn
2480 let Inst{11-0} = addr{11-0}; // imm12
2481 let AsmMatchConverter = "cvtStWriteBackRegAddrModeImm12";
2482 let DecoderMethod = "DecodeSTRPreImm";
2485 def _PRE_REG : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2486 (ins GPR:$Rt, ldst_so_reg:$addr),
2487 IndexModePre, StFrm, iir,
2488 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2491 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2492 let Inst{19-16} = addr{16-13}; // Rn
2493 let Inst{11-0} = addr{11-0};
2494 let Inst{4} = 0; // Inst{4} = 0
2495 let AsmMatchConverter = "cvtStWriteBackRegAddrMode2";
2496 let DecoderMethod = "DecodeSTRPreReg";
2498 def _POST_REG : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2499 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2500 IndexModePost, StFrm, iir,
2501 opc, "\t$Rt, $addr, $offset",
2502 "$addr.base = $Rn_wb", []> {
2508 let Inst{23} = offset{12};
2509 let Inst{19-16} = addr;
2510 let Inst{11-0} = offset{11-0};
2512 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2515 def _POST_IMM : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2516 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2517 IndexModePost, StFrm, iii,
2518 opc, "\t$Rt, $addr, $offset",
2519 "$addr.base = $Rn_wb", []> {
2525 let Inst{23} = offset{12};
2526 let Inst{19-16} = addr;
2527 let Inst{11-0} = offset{11-0};
2529 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2533 let mayStore = 1, neverHasSideEffects = 1 in {
2534 // FIXME: for STR_PRE_REG etc. the itineray should be either IIC_iStore_ru or
2535 // IIC_iStore_siu depending on whether it the offset register is shifted.
2536 defm STR : AI2_stridx<0, "str", IIC_iStore_iu, IIC_iStore_ru>;
2537 defm STRB : AI2_stridx<1, "strb", IIC_iStore_bh_iu, IIC_iStore_bh_ru>;
2540 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2541 am2offset_reg:$offset),
2542 (STR_POST_REG GPR:$Rt, addr_offset_none:$addr,
2543 am2offset_reg:$offset)>;
2544 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2545 am2offset_imm:$offset),
2546 (STR_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2547 am2offset_imm:$offset)>;
2548 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2549 am2offset_reg:$offset),
2550 (STRB_POST_REG GPR:$Rt, addr_offset_none:$addr,
2551 am2offset_reg:$offset)>;
2552 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2553 am2offset_imm:$offset),
2554 (STRB_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2555 am2offset_imm:$offset)>;
2557 // Pseudo-instructions for pattern matching the pre-indexed stores. We can't
2558 // put the patterns on the instruction definitions directly as ISel wants
2559 // the address base and offset to be separate operands, not a single
2560 // complex operand like we represent the instructions themselves. The
2561 // pseudos map between the two.
2562 let usesCustomInserter = 1,
2563 Constraints = "$Rn = $Rn_wb,@earlyclobber $Rn_wb" in {
2564 def STRi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2565 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2568 (pre_store GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2569 def STRr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2570 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2573 (pre_store GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2574 def STRBi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2575 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2578 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2579 def STRBr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2580 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2583 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2584 def STRH_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2585 (ins GPR:$Rt, GPR:$Rn, am3offset:$offset, pred:$p),
2588 (pre_truncsti16 GPR:$Rt, GPR:$Rn, am3offset:$offset))]>;
2593 def STRH_PRE : AI3ldstidx<0b1011, 0, 1, (outs GPR:$Rn_wb),
2594 (ins GPR:$Rt, addrmode3:$addr), IndexModePre,
2595 StMiscFrm, IIC_iStore_bh_ru,
2596 "strh", "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2598 let Inst{23} = addr{8}; // U bit
2599 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2600 let Inst{19-16} = addr{12-9}; // Rn
2601 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2602 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2603 let AsmMatchConverter = "cvtStWriteBackRegAddrMode3";
2604 let DecoderMethod = "DecodeAddrMode3Instruction";
2607 def STRH_POST : AI3ldstidx<0b1011, 0, 0, (outs GPR:$Rn_wb),
2608 (ins GPR:$Rt, addr_offset_none:$addr, am3offset:$offset),
2609 IndexModePost, StMiscFrm, IIC_iStore_bh_ru,
2610 "strh", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2611 [(set GPR:$Rn_wb, (post_truncsti16 GPR:$Rt,
2612 addr_offset_none:$addr,
2613 am3offset:$offset))]> {
2616 let Inst{23} = offset{8}; // U bit
2617 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2618 let Inst{19-16} = addr;
2619 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2620 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2621 let DecoderMethod = "DecodeAddrMode3Instruction";
2624 let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in {
2625 def STRD_PRE : AI3ldstidx<0b1111, 0, 1, (outs GPR:$Rn_wb),
2626 (ins GPR:$Rt, GPR:$Rt2, addrmode3:$addr),
2627 IndexModePre, StMiscFrm, IIC_iStore_d_ru,
2628 "strd", "\t$Rt, $Rt2, $addr!",
2629 "$addr.base = $Rn_wb", []> {
2631 let Inst{23} = addr{8}; // U bit
2632 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2633 let Inst{19-16} = addr{12-9}; // Rn
2634 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2635 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2636 let DecoderMethod = "DecodeAddrMode3Instruction";
2637 let AsmMatchConverter = "cvtStrdPre";
2640 def STRD_POST: AI3ldstidx<0b1111, 0, 0, (outs GPR:$Rn_wb),
2641 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr,
2643 IndexModePost, StMiscFrm, IIC_iStore_d_ru,
2644 "strd", "\t$Rt, $Rt2, $addr, $offset",
2645 "$addr.base = $Rn_wb", []> {
2648 let Inst{23} = offset{8}; // U bit
2649 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2650 let Inst{19-16} = addr;
2651 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2652 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2653 let DecoderMethod = "DecodeAddrMode3Instruction";
2655 } // mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1
2657 // STRT, STRBT, and STRHT
2659 def STRBT_POST_REG : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2660 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2661 IndexModePost, StFrm, IIC_iStore_bh_ru,
2662 "strbt", "\t$Rt, $addr, $offset",
2663 "$addr.base = $Rn_wb", []> {
2669 let Inst{23} = offset{12};
2670 let Inst{21} = 1; // overwrite
2671 let Inst{19-16} = addr;
2672 let Inst{11-5} = offset{11-5};
2674 let Inst{3-0} = offset{3-0};
2675 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2678 def STRBT_POST_IMM : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2679 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2680 IndexModePost, StFrm, IIC_iStore_bh_ru,
2681 "strbt", "\t$Rt, $addr, $offset",
2682 "$addr.base = $Rn_wb", []> {
2688 let Inst{23} = offset{12};
2689 let Inst{21} = 1; // overwrite
2690 let Inst{19-16} = addr;
2691 let Inst{11-0} = offset{11-0};
2692 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2695 let mayStore = 1, neverHasSideEffects = 1 in {
2696 def STRT_POST_REG : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
2697 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2698 IndexModePost, StFrm, IIC_iStore_ru,
2699 "strt", "\t$Rt, $addr, $offset",
2700 "$addr.base = $Rn_wb", []> {
2706 let Inst{23} = offset{12};
2707 let Inst{21} = 1; // overwrite
2708 let Inst{19-16} = addr;
2709 let Inst{11-5} = offset{11-5};
2711 let Inst{3-0} = offset{3-0};
2712 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2715 def STRT_POST_IMM : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
2716 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2717 IndexModePost, StFrm, IIC_iStore_ru,
2718 "strt", "\t$Rt, $addr, $offset",
2719 "$addr.base = $Rn_wb", []> {
2725 let Inst{23} = offset{12};
2726 let Inst{21} = 1; // overwrite
2727 let Inst{19-16} = addr;
2728 let Inst{11-0} = offset{11-0};
2729 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2734 multiclass AI3strT<bits<4> op, string opc> {
2735 def i : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
2736 (ins GPR:$Rt, addr_offset_none:$addr, postidx_imm8:$offset),
2737 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
2738 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2740 let Inst{23} = offset{8};
2742 let Inst{11-8} = offset{7-4};
2743 let Inst{3-0} = offset{3-0};
2744 let AsmMatchConverter = "cvtStExtTWriteBackImm";
2746 def r : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
2747 (ins GPR:$Rt, addr_offset_none:$addr, postidx_reg:$Rm),
2748 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
2749 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2751 let Inst{23} = Rm{4};
2754 let Inst{3-0} = Rm{3-0};
2755 let AsmMatchConverter = "cvtStExtTWriteBackReg";
2760 defm STRHT : AI3strT<0b1011, "strht">;
2763 //===----------------------------------------------------------------------===//
2764 // Load / store multiple Instructions.
2767 multiclass arm_ldst_mult<string asm, bit L_bit, Format f,
2768 InstrItinClass itin, InstrItinClass itin_upd> {
2769 // IA is the default, so no need for an explicit suffix on the
2770 // mnemonic here. Without it is the cannonical spelling.
2772 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2773 IndexModeNone, f, itin,
2774 !strconcat(asm, "${p}\t$Rn, $regs"), "", []> {
2775 let Inst{24-23} = 0b01; // Increment After
2776 let Inst{21} = 0; // No writeback
2777 let Inst{20} = L_bit;
2780 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2781 IndexModeUpd, f, itin_upd,
2782 !strconcat(asm, "${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
2783 let Inst{24-23} = 0b01; // Increment After
2784 let Inst{21} = 1; // Writeback
2785 let Inst{20} = L_bit;
2787 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2790 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2791 IndexModeNone, f, itin,
2792 !strconcat(asm, "da${p}\t$Rn, $regs"), "", []> {
2793 let Inst{24-23} = 0b00; // Decrement After
2794 let Inst{21} = 0; // No writeback
2795 let Inst{20} = L_bit;
2798 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2799 IndexModeUpd, f, itin_upd,
2800 !strconcat(asm, "da${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
2801 let Inst{24-23} = 0b00; // Decrement After
2802 let Inst{21} = 1; // Writeback
2803 let Inst{20} = L_bit;
2805 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2808 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2809 IndexModeNone, f, itin,
2810 !strconcat(asm, "db${p}\t$Rn, $regs"), "", []> {
2811 let Inst{24-23} = 0b10; // Decrement Before
2812 let Inst{21} = 0; // No writeback
2813 let Inst{20} = L_bit;
2816 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2817 IndexModeUpd, f, itin_upd,
2818 !strconcat(asm, "db${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
2819 let Inst{24-23} = 0b10; // Decrement Before
2820 let Inst{21} = 1; // Writeback
2821 let Inst{20} = L_bit;
2823 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2826 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2827 IndexModeNone, f, itin,
2828 !strconcat(asm, "ib${p}\t$Rn, $regs"), "", []> {
2829 let Inst{24-23} = 0b11; // Increment Before
2830 let Inst{21} = 0; // No writeback
2831 let Inst{20} = L_bit;
2834 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2835 IndexModeUpd, f, itin_upd,
2836 !strconcat(asm, "ib${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
2837 let Inst{24-23} = 0b11; // Increment Before
2838 let Inst{21} = 1; // Writeback
2839 let Inst{20} = L_bit;
2841 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2845 let neverHasSideEffects = 1 in {
2847 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
2848 defm LDM : arm_ldst_mult<"ldm", 1, LdStMulFrm, IIC_iLoad_m, IIC_iLoad_mu>;
2850 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
2851 defm STM : arm_ldst_mult<"stm", 0, LdStMulFrm, IIC_iStore_m, IIC_iStore_mu>;
2853 } // neverHasSideEffects
2855 // FIXME: remove when we have a way to marking a MI with these properties.
2856 // FIXME: Should pc be an implicit operand like PICADD, etc?
2857 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
2858 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
2859 def LDMIA_RET : ARMPseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p,
2860 reglist:$regs, variable_ops),
2861 4, IIC_iLoad_mBr, [],
2862 (LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>,
2863 RegConstraint<"$Rn = $wb">;
2865 //===----------------------------------------------------------------------===//
2866 // Move Instructions.
2869 let neverHasSideEffects = 1 in
2870 def MOVr : AsI1<0b1101, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMOVr,
2871 "mov", "\t$Rd, $Rm", []>, UnaryDP {
2875 let Inst{19-16} = 0b0000;
2876 let Inst{11-4} = 0b00000000;
2879 let Inst{15-12} = Rd;
2882 def : ARMInstAlias<"movs${p} $Rd, $Rm",
2883 (MOVr GPR:$Rd, GPR:$Rm, pred:$p, CPSR)>;
2885 // A version for the smaller set of tail call registers.
2886 let neverHasSideEffects = 1 in
2887 def MOVr_TC : AsI1<0b1101, (outs tcGPR:$Rd), (ins tcGPR:$Rm), DPFrm,
2888 IIC_iMOVr, "mov", "\t$Rd, $Rm", []>, UnaryDP {
2892 let Inst{11-4} = 0b00000000;
2895 let Inst{15-12} = Rd;
2898 def MOVsr : AsI1<0b1101, (outs GPRnopc:$Rd), (ins shift_so_reg_reg:$src),
2899 DPSoRegRegFrm, IIC_iMOVsr,
2900 "mov", "\t$Rd, $src",
2901 [(set GPRnopc:$Rd, shift_so_reg_reg:$src)]>, UnaryDP {
2904 let Inst{15-12} = Rd;
2905 let Inst{19-16} = 0b0000;
2906 let Inst{11-8} = src{11-8};
2908 let Inst{6-5} = src{6-5};
2910 let Inst{3-0} = src{3-0};
2914 def MOVsi : AsI1<0b1101, (outs GPR:$Rd), (ins shift_so_reg_imm:$src),
2915 DPSoRegImmFrm, IIC_iMOVsr,
2916 "mov", "\t$Rd, $src", [(set GPR:$Rd, shift_so_reg_imm:$src)]>,
2920 let Inst{15-12} = Rd;
2921 let Inst{19-16} = 0b0000;
2922 let Inst{11-5} = src{11-5};
2924 let Inst{3-0} = src{3-0};
2928 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
2929 def MOVi : AsI1<0b1101, (outs GPR:$Rd), (ins so_imm:$imm), DPFrm, IIC_iMOVi,
2930 "mov", "\t$Rd, $imm", [(set GPR:$Rd, so_imm:$imm)]>, UnaryDP {
2934 let Inst{15-12} = Rd;
2935 let Inst{19-16} = 0b0000;
2936 let Inst{11-0} = imm;
2939 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
2940 def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins imm0_65535_expr:$imm),
2942 "movw", "\t$Rd, $imm",
2943 [(set GPR:$Rd, imm0_65535:$imm)]>,
2944 Requires<[IsARM, HasV6T2]>, UnaryDP {
2947 let Inst{15-12} = Rd;
2948 let Inst{11-0} = imm{11-0};
2949 let Inst{19-16} = imm{15-12};
2952 let DecoderMethod = "DecodeArmMOVTWInstruction";
2955 def : InstAlias<"mov${p} $Rd, $imm",
2956 (MOVi16 GPR:$Rd, imm0_65535_expr:$imm, pred:$p)>,
2959 def MOVi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
2960 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>;
2962 let Constraints = "$src = $Rd" in {
2963 def MOVTi16 : AI1<0b1010, (outs GPRnopc:$Rd),
2964 (ins GPR:$src, imm0_65535_expr:$imm),
2966 "movt", "\t$Rd, $imm",
2968 (or (and GPR:$src, 0xffff),
2969 lo16AllZero:$imm))]>, UnaryDP,
2970 Requires<[IsARM, HasV6T2]> {
2973 let Inst{15-12} = Rd;
2974 let Inst{11-0} = imm{11-0};
2975 let Inst{19-16} = imm{15-12};
2978 let DecoderMethod = "DecodeArmMOVTWInstruction";
2981 def MOVTi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
2982 (ins GPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>;
2986 def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
2987 Requires<[IsARM, HasV6T2]>;
2989 let Uses = [CPSR] in
2990 def RRX: PseudoInst<(outs GPR:$Rd), (ins GPR:$Rm), IIC_iMOVsi,
2991 [(set GPR:$Rd, (ARMrrx GPR:$Rm))]>, UnaryDP,
2994 // These aren't really mov instructions, but we have to define them this way
2995 // due to flag operands.
2997 let Defs = [CPSR] in {
2998 def MOVsrl_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
2999 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP,
3001 def MOVsra_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3002 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP,
3006 //===----------------------------------------------------------------------===//
3007 // Extend Instructions.
3012 def SXTB : AI_ext_rrot<0b01101010,
3013 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
3014 def SXTH : AI_ext_rrot<0b01101011,
3015 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
3017 def SXTAB : AI_exta_rrot<0b01101010,
3018 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
3019 def SXTAH : AI_exta_rrot<0b01101011,
3020 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
3022 def SXTB16 : AI_ext_rrot_np<0b01101000, "sxtb16">;
3024 def SXTAB16 : AI_exta_rrot_np<0b01101000, "sxtab16">;
3028 let AddedComplexity = 16 in {
3029 def UXTB : AI_ext_rrot<0b01101110,
3030 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
3031 def UXTH : AI_ext_rrot<0b01101111,
3032 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
3033 def UXTB16 : AI_ext_rrot<0b01101100,
3034 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
3036 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
3037 // The transformation should probably be done as a combiner action
3038 // instead so we can include a check for masking back in the upper
3039 // eight bits of the source into the lower eight bits of the result.
3040 //def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
3041 // (UXTB16r_rot GPR:$Src, 3)>;
3042 def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
3043 (UXTB16 GPR:$Src, 1)>;
3045 def UXTAB : AI_exta_rrot<0b01101110, "uxtab",
3046 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
3047 def UXTAH : AI_exta_rrot<0b01101111, "uxtah",
3048 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
3051 // This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
3052 def UXTAB16 : AI_exta_rrot_np<0b01101100, "uxtab16">;
3055 def SBFX : I<(outs GPRnopc:$Rd),
3056 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3057 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3058 "sbfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3059 Requires<[IsARM, HasV6T2]> {
3064 let Inst{27-21} = 0b0111101;
3065 let Inst{6-4} = 0b101;
3066 let Inst{20-16} = width;
3067 let Inst{15-12} = Rd;
3068 let Inst{11-7} = lsb;
3072 def UBFX : I<(outs GPR:$Rd),
3073 (ins GPR:$Rn, imm0_31:$lsb, imm1_32:$width),
3074 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3075 "ubfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3076 Requires<[IsARM, HasV6T2]> {
3081 let Inst{27-21} = 0b0111111;
3082 let Inst{6-4} = 0b101;
3083 let Inst{20-16} = width;
3084 let Inst{15-12} = Rd;
3085 let Inst{11-7} = lsb;
3089 //===----------------------------------------------------------------------===//
3090 // Arithmetic Instructions.
3093 defm ADD : AsI1_bin_irs<0b0100, "add",
3094 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3095 BinOpFrag<(add node:$LHS, node:$RHS)>, "ADD", 1>;
3096 defm SUB : AsI1_bin_irs<0b0010, "sub",
3097 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3098 BinOpFrag<(sub node:$LHS, node:$RHS)>, "SUB">;
3100 // ADD and SUB with 's' bit set.
3102 // Currently, ADDS/SUBS are pseudo opcodes that exist only in the
3103 // selection DAG. They are "lowered" to real ADD/SUB opcodes by
3104 // AdjustInstrPostInstrSelection where we determine whether or not to
3105 // set the "s" bit based on CPSR liveness.
3107 // FIXME: Eliminate ADDS/SUBS pseudo opcodes after adding tablegen
3108 // support for an optional CPSR definition that corresponds to the DAG
3109 // node's second value. We can then eliminate the implicit def of CPSR.
3110 defm ADDS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3111 BinOpFrag<(ARMaddc node:$LHS, node:$RHS)>, 1>;
3112 defm SUBS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3113 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
3115 defm ADC : AI1_adde_sube_irs<0b0101, "adc",
3116 BinOpWithFlagFrag<(ARMadde node:$LHS, node:$RHS, node:$FLAG)>,
3118 defm SBC : AI1_adde_sube_irs<0b0110, "sbc",
3119 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>,
3122 defm RSB : AsI1_rbin_irs <0b0011, "rsb",
3123 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3124 BinOpFrag<(sub node:$LHS, node:$RHS)>, "RSB">;
3126 // FIXME: Eliminate them if we can write def : Pat patterns which defines
3127 // CPSR and the implicit def of CPSR is not needed.
3128 defm RSBS : AsI1_rbin_s_is<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3129 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
3131 defm RSC : AI1_rsc_irs<0b0111, "rsc",
3132 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>,
3135 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
3136 // The assume-no-carry-in form uses the negation of the input since add/sub
3137 // assume opposite meanings of the carry flag (i.e., carry == !borrow).
3138 // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
3140 def : ARMPat<(add GPR:$src, so_imm_neg:$imm),
3141 (SUBri GPR:$src, so_imm_neg:$imm)>;
3142 def : ARMPat<(ARMaddc GPR:$src, so_imm_neg:$imm),
3143 (SUBSri GPR:$src, so_imm_neg:$imm)>;
3145 // The with-carry-in form matches bitwise not instead of the negation.
3146 // Effectively, the inverse interpretation of the carry flag already accounts
3147 // for part of the negation.
3148 def : ARMPat<(ARMadde GPR:$src, so_imm_not:$imm, CPSR),
3149 (SBCri GPR:$src, so_imm_not:$imm)>;
3151 // Note: These are implemented in C++ code, because they have to generate
3152 // ADD/SUBrs instructions, which use a complex pattern that a xform function
3154 // (mul X, 2^n+1) -> (add (X << n), X)
3155 // (mul X, 2^n-1) -> (rsb X, (X << n))
3157 // ARM Arithmetic Instruction
3158 // GPR:$dst = GPR:$a op GPR:$b
3159 class AAI<bits<8> op27_20, bits<8> op11_4, string opc,
3160 list<dag> pattern = [],
3161 dag iops = (ins GPRnopc:$Rn, GPRnopc:$Rm),
3162 string asm = "\t$Rd, $Rn, $Rm">
3163 : AI<(outs GPRnopc:$Rd), iops, DPFrm, IIC_iALUr, opc, asm, pattern> {
3167 let Inst{27-20} = op27_20;
3168 let Inst{11-4} = op11_4;
3169 let Inst{19-16} = Rn;
3170 let Inst{15-12} = Rd;
3174 // Saturating add/subtract
3176 def QADD : AAI<0b00010000, 0b00000101, "qadd",
3177 [(set GPRnopc:$Rd, (int_arm_qadd GPRnopc:$Rm, GPRnopc:$Rn))],
3178 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3179 def QSUB : AAI<0b00010010, 0b00000101, "qsub",
3180 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm, GPRnopc:$Rn))],
3181 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3182 def QDADD : AAI<0b00010100, 0b00000101, "qdadd", [],
3183 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3185 def QDSUB : AAI<0b00010110, 0b00000101, "qdsub", [],
3186 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3189 def QADD16 : AAI<0b01100010, 0b11110001, "qadd16">;
3190 def QADD8 : AAI<0b01100010, 0b11111001, "qadd8">;
3191 def QASX : AAI<0b01100010, 0b11110011, "qasx">;
3192 def QSAX : AAI<0b01100010, 0b11110101, "qsax">;
3193 def QSUB16 : AAI<0b01100010, 0b11110111, "qsub16">;
3194 def QSUB8 : AAI<0b01100010, 0b11111111, "qsub8">;
3195 def UQADD16 : AAI<0b01100110, 0b11110001, "uqadd16">;
3196 def UQADD8 : AAI<0b01100110, 0b11111001, "uqadd8">;
3197 def UQASX : AAI<0b01100110, 0b11110011, "uqasx">;
3198 def UQSAX : AAI<0b01100110, 0b11110101, "uqsax">;
3199 def UQSUB16 : AAI<0b01100110, 0b11110111, "uqsub16">;
3200 def UQSUB8 : AAI<0b01100110, 0b11111111, "uqsub8">;
3202 // Signed/Unsigned add/subtract
3204 def SASX : AAI<0b01100001, 0b11110011, "sasx">;
3205 def SADD16 : AAI<0b01100001, 0b11110001, "sadd16">;
3206 def SADD8 : AAI<0b01100001, 0b11111001, "sadd8">;
3207 def SSAX : AAI<0b01100001, 0b11110101, "ssax">;
3208 def SSUB16 : AAI<0b01100001, 0b11110111, "ssub16">;
3209 def SSUB8 : AAI<0b01100001, 0b11111111, "ssub8">;
3210 def UASX : AAI<0b01100101, 0b11110011, "uasx">;
3211 def UADD16 : AAI<0b01100101, 0b11110001, "uadd16">;
3212 def UADD8 : AAI<0b01100101, 0b11111001, "uadd8">;
3213 def USAX : AAI<0b01100101, 0b11110101, "usax">;
3214 def USUB16 : AAI<0b01100101, 0b11110111, "usub16">;
3215 def USUB8 : AAI<0b01100101, 0b11111111, "usub8">;
3217 // Signed/Unsigned halving add/subtract
3219 def SHASX : AAI<0b01100011, 0b11110011, "shasx">;
3220 def SHADD16 : AAI<0b01100011, 0b11110001, "shadd16">;
3221 def SHADD8 : AAI<0b01100011, 0b11111001, "shadd8">;
3222 def SHSAX : AAI<0b01100011, 0b11110101, "shsax">;
3223 def SHSUB16 : AAI<0b01100011, 0b11110111, "shsub16">;
3224 def SHSUB8 : AAI<0b01100011, 0b11111111, "shsub8">;
3225 def UHASX : AAI<0b01100111, 0b11110011, "uhasx">;
3226 def UHADD16 : AAI<0b01100111, 0b11110001, "uhadd16">;
3227 def UHADD8 : AAI<0b01100111, 0b11111001, "uhadd8">;
3228 def UHSAX : AAI<0b01100111, 0b11110101, "uhsax">;
3229 def UHSUB16 : AAI<0b01100111, 0b11110111, "uhsub16">;
3230 def UHSUB8 : AAI<0b01100111, 0b11111111, "uhsub8">;
3232 // Unsigned Sum of Absolute Differences [and Accumulate].
3234 def USAD8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3235 MulFrm /* for convenience */, NoItinerary, "usad8",
3236 "\t$Rd, $Rn, $Rm", []>,
3237 Requires<[IsARM, HasV6]> {
3241 let Inst{27-20} = 0b01111000;
3242 let Inst{15-12} = 0b1111;
3243 let Inst{7-4} = 0b0001;
3244 let Inst{19-16} = Rd;
3245 let Inst{11-8} = Rm;
3248 def USADA8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3249 MulFrm /* for convenience */, NoItinerary, "usada8",
3250 "\t$Rd, $Rn, $Rm, $Ra", []>,
3251 Requires<[IsARM, HasV6]> {
3256 let Inst{27-20} = 0b01111000;
3257 let Inst{7-4} = 0b0001;
3258 let Inst{19-16} = Rd;
3259 let Inst{15-12} = Ra;
3260 let Inst{11-8} = Rm;
3264 // Signed/Unsigned saturate
3266 def SSAT : AI<(outs GPRnopc:$Rd),
3267 (ins imm1_32:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3268 SatFrm, NoItinerary, "ssat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3273 let Inst{27-21} = 0b0110101;
3274 let Inst{5-4} = 0b01;
3275 let Inst{20-16} = sat_imm;
3276 let Inst{15-12} = Rd;
3277 let Inst{11-7} = sh{4-0};
3278 let Inst{6} = sh{5};
3282 def SSAT16 : AI<(outs GPRnopc:$Rd),
3283 (ins imm1_16:$sat_imm, GPRnopc:$Rn), SatFrm,
3284 NoItinerary, "ssat16", "\t$Rd, $sat_imm, $Rn", []> {
3288 let Inst{27-20} = 0b01101010;
3289 let Inst{11-4} = 0b11110011;
3290 let Inst{15-12} = Rd;
3291 let Inst{19-16} = sat_imm;
3295 def USAT : AI<(outs GPRnopc:$Rd),
3296 (ins imm0_31:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3297 SatFrm, NoItinerary, "usat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3302 let Inst{27-21} = 0b0110111;
3303 let Inst{5-4} = 0b01;
3304 let Inst{15-12} = Rd;
3305 let Inst{11-7} = sh{4-0};
3306 let Inst{6} = sh{5};
3307 let Inst{20-16} = sat_imm;
3311 def USAT16 : AI<(outs GPRnopc:$Rd),
3312 (ins imm0_15:$sat_imm, GPRnopc:$Rn), SatFrm,
3313 NoItinerary, "usat16", "\t$Rd, $sat_imm, $Rn", []> {
3317 let Inst{27-20} = 0b01101110;
3318 let Inst{11-4} = 0b11110011;
3319 let Inst{15-12} = Rd;
3320 let Inst{19-16} = sat_imm;
3324 def : ARMV6Pat<(int_arm_ssat GPRnopc:$a, imm:$pos),
3325 (SSAT imm:$pos, GPRnopc:$a, 0)>;
3326 def : ARMV6Pat<(int_arm_usat GPRnopc:$a, imm:$pos),
3327 (USAT imm:$pos, GPRnopc:$a, 0)>;
3329 //===----------------------------------------------------------------------===//
3330 // Bitwise Instructions.
3333 defm AND : AsI1_bin_irs<0b0000, "and",
3334 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3335 BinOpFrag<(and node:$LHS, node:$RHS)>, "AND", 1>;
3336 defm ORR : AsI1_bin_irs<0b1100, "orr",
3337 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3338 BinOpFrag<(or node:$LHS, node:$RHS)>, "ORR", 1>;
3339 defm EOR : AsI1_bin_irs<0b0001, "eor",
3340 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3341 BinOpFrag<(xor node:$LHS, node:$RHS)>, "EOR", 1>;
3342 defm BIC : AsI1_bin_irs<0b1110, "bic",
3343 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3344 BinOpFrag<(and node:$LHS, (not node:$RHS))>, "BIC">;
3346 // FIXME: bf_inv_mask_imm should be two operands, the lsb and the msb, just
3347 // like in the actual instruction encoding. The complexity of mapping the mask
3348 // to the lsb/msb pair should be handled by ISel, not encapsulated in the
3349 // instruction description.
3350 def BFC : I<(outs GPR:$Rd), (ins GPR:$src, bf_inv_mask_imm:$imm),
3351 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3352 "bfc", "\t$Rd, $imm", "$src = $Rd",
3353 [(set GPR:$Rd, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
3354 Requires<[IsARM, HasV6T2]> {
3357 let Inst{27-21} = 0b0111110;
3358 let Inst{6-0} = 0b0011111;
3359 let Inst{15-12} = Rd;
3360 let Inst{11-7} = imm{4-0}; // lsb
3361 let Inst{20-16} = imm{9-5}; // msb
3364 // A8.6.18 BFI - Bitfield insert (Encoding A1)
3365 def BFI:I<(outs GPRnopc:$Rd), (ins GPRnopc:$src, GPR:$Rn, bf_inv_mask_imm:$imm),
3366 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3367 "bfi", "\t$Rd, $Rn, $imm", "$src = $Rd",
3368 [(set GPRnopc:$Rd, (ARMbfi GPRnopc:$src, GPR:$Rn,
3369 bf_inv_mask_imm:$imm))]>,
3370 Requires<[IsARM, HasV6T2]> {
3374 let Inst{27-21} = 0b0111110;
3375 let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15
3376 let Inst{15-12} = Rd;
3377 let Inst{11-7} = imm{4-0}; // lsb
3378 let Inst{20-16} = imm{9-5}; // width
3382 def MVNr : AsI1<0b1111, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMVNr,
3383 "mvn", "\t$Rd, $Rm",
3384 [(set GPR:$Rd, (not GPR:$Rm))]>, UnaryDP {
3388 let Inst{19-16} = 0b0000;
3389 let Inst{11-4} = 0b00000000;
3390 let Inst{15-12} = Rd;
3393 def MVNsi : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_imm:$shift),
3394 DPSoRegImmFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3395 [(set GPR:$Rd, (not so_reg_imm:$shift))]>, UnaryDP {
3399 let Inst{19-16} = 0b0000;
3400 let Inst{15-12} = Rd;
3401 let Inst{11-5} = shift{11-5};
3403 let Inst{3-0} = shift{3-0};
3405 def MVNsr : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_reg:$shift),
3406 DPSoRegRegFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3407 [(set GPR:$Rd, (not so_reg_reg:$shift))]>, UnaryDP {
3411 let Inst{19-16} = 0b0000;
3412 let Inst{15-12} = Rd;
3413 let Inst{11-8} = shift{11-8};
3415 let Inst{6-5} = shift{6-5};
3417 let Inst{3-0} = shift{3-0};
3419 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3420 def MVNi : AsI1<0b1111, (outs GPR:$Rd), (ins so_imm:$imm), DPFrm,
3421 IIC_iMVNi, "mvn", "\t$Rd, $imm",
3422 [(set GPR:$Rd, so_imm_not:$imm)]>,UnaryDP {
3426 let Inst{19-16} = 0b0000;
3427 let Inst{15-12} = Rd;
3428 let Inst{11-0} = imm;
3431 def : ARMPat<(and GPR:$src, so_imm_not:$imm),
3432 (BICri GPR:$src, so_imm_not:$imm)>;
3434 //===----------------------------------------------------------------------===//
3435 // Multiply Instructions.
3437 class AsMul1I32<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3438 string opc, string asm, list<dag> pattern>
3439 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3443 let Inst{19-16} = Rd;
3444 let Inst{11-8} = Rm;
3447 class AsMul1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3448 string opc, string asm, list<dag> pattern>
3449 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3454 let Inst{19-16} = RdHi;
3455 let Inst{15-12} = RdLo;
3456 let Inst{11-8} = Rm;
3460 // FIXME: The v5 pseudos are only necessary for the additional Constraint
3461 // property. Remove them when it's possible to add those properties
3462 // on an individual MachineInstr, not just an instuction description.
3463 let isCommutable = 1 in {
3464 def MUL : AsMul1I32<0b0000000, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3465 IIC_iMUL32, "mul", "\t$Rd, $Rn, $Rm",
3466 [(set GPR:$Rd, (mul GPR:$Rn, GPR:$Rm))]>,
3467 Requires<[IsARM, HasV6]> {
3468 let Inst{15-12} = 0b0000;
3471 let Constraints = "@earlyclobber $Rd" in
3472 def MULv5: ARMPseudoExpand<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm,
3473 pred:$p, cc_out:$s),
3475 [(set GPR:$Rd, (mul GPR:$Rn, GPR:$Rm))],
3476 (MUL GPR:$Rd, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3477 Requires<[IsARM, NoV6]>;
3480 def MLA : AsMul1I32<0b0000001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3481 IIC_iMAC32, "mla", "\t$Rd, $Rn, $Rm, $Ra",
3482 [(set GPR:$Rd, (add (mul GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
3483 Requires<[IsARM, HasV6]> {
3485 let Inst{15-12} = Ra;
3488 let Constraints = "@earlyclobber $Rd" in
3489 def MLAv5: ARMPseudoExpand<(outs GPR:$Rd),
3490 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra, pred:$p, cc_out:$s),
3492 [(set GPR:$Rd, (add (mul GPR:$Rn, GPR:$Rm), GPR:$Ra))],
3493 (MLA GPR:$Rd, GPR:$Rn, GPR:$Rm, GPR:$Ra, pred:$p, cc_out:$s)>,
3494 Requires<[IsARM, NoV6]>;
3496 def MLS : AMul1I<0b0000011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3497 IIC_iMAC32, "mls", "\t$Rd, $Rn, $Rm, $Ra",
3498 [(set GPR:$Rd, (sub GPR:$Ra, (mul GPR:$Rn, GPR:$Rm)))]>,
3499 Requires<[IsARM, HasV6T2]> {
3504 let Inst{19-16} = Rd;
3505 let Inst{15-12} = Ra;
3506 let Inst{11-8} = Rm;
3510 // Extra precision multiplies with low / high results
3511 let neverHasSideEffects = 1 in {
3512 let isCommutable = 1 in {
3513 def SMULL : AsMul1I64<0b0000110, (outs GPR:$RdLo, GPR:$RdHi),
3514 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3515 "smull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3516 Requires<[IsARM, HasV6]>;
3518 def UMULL : AsMul1I64<0b0000100, (outs GPR:$RdLo, GPR:$RdHi),
3519 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3520 "umull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3521 Requires<[IsARM, HasV6]>;
3523 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
3524 def SMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3525 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3527 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3528 Requires<[IsARM, NoV6]>;
3530 def UMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3531 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3533 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3534 Requires<[IsARM, NoV6]>;
3538 // Multiply + accumulate
3539 def SMLAL : AsMul1I64<0b0000111, (outs GPR:$RdLo, GPR:$RdHi),
3540 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3541 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3542 Requires<[IsARM, HasV6]>;
3543 def UMLAL : AsMul1I64<0b0000101, (outs GPR:$RdLo, GPR:$RdHi),
3544 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3545 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3546 Requires<[IsARM, HasV6]>;
3548 def UMAAL : AMul1I <0b0000010, (outs GPR:$RdLo, GPR:$RdHi),
3549 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3550 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3551 Requires<[IsARM, HasV6]> {
3556 let Inst{19-16} = RdHi;
3557 let Inst{15-12} = RdLo;
3558 let Inst{11-8} = Rm;
3562 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
3563 def SMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3564 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3566 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3567 Requires<[IsARM, NoV6]>;
3568 def UMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3569 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3571 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3572 Requires<[IsARM, NoV6]>;
3573 def UMAALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3574 (ins GPR:$Rn, GPR:$Rm, pred:$p),
3576 (UMAAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p)>,
3577 Requires<[IsARM, NoV6]>;
3580 } // neverHasSideEffects
3582 // Most significant word multiply
3583 def SMMUL : AMul2I <0b0111010, 0b0001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3584 IIC_iMUL32, "smmul", "\t$Rd, $Rn, $Rm",
3585 [(set GPR:$Rd, (mulhs GPR:$Rn, GPR:$Rm))]>,
3586 Requires<[IsARM, HasV6]> {
3587 let Inst{15-12} = 0b1111;
3590 def SMMULR : AMul2I <0b0111010, 0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3591 IIC_iMUL32, "smmulr", "\t$Rd, $Rn, $Rm", []>,
3592 Requires<[IsARM, HasV6]> {
3593 let Inst{15-12} = 0b1111;
3596 def SMMLA : AMul2Ia <0b0111010, 0b0001, (outs GPR:$Rd),
3597 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3598 IIC_iMAC32, "smmla", "\t$Rd, $Rn, $Rm, $Ra",
3599 [(set GPR:$Rd, (add (mulhs GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
3600 Requires<[IsARM, HasV6]>;
3602 def SMMLAR : AMul2Ia <0b0111010, 0b0011, (outs GPR:$Rd),
3603 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3604 IIC_iMAC32, "smmlar", "\t$Rd, $Rn, $Rm, $Ra", []>,
3605 Requires<[IsARM, HasV6]>;
3607 def SMMLS : AMul2Ia <0b0111010, 0b1101, (outs GPR:$Rd),
3608 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3609 IIC_iMAC32, "smmls", "\t$Rd, $Rn, $Rm, $Ra",
3610 [(set GPR:$Rd, (sub GPR:$Ra, (mulhs GPR:$Rn, GPR:$Rm)))]>,
3611 Requires<[IsARM, HasV6]>;
3613 def SMMLSR : AMul2Ia <0b0111010, 0b1111, (outs GPR:$Rd),
3614 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3615 IIC_iMAC32, "smmlsr", "\t$Rd, $Rn, $Rm, $Ra", []>,
3616 Requires<[IsARM, HasV6]>;
3618 multiclass AI_smul<string opc, PatFrag opnode> {
3619 def BB : AMulxyI<0b0001011, 0b00, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3620 IIC_iMUL16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm",
3621 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3622 (sext_inreg GPR:$Rm, i16)))]>,
3623 Requires<[IsARM, HasV5TE]>;
3625 def BT : AMulxyI<0b0001011, 0b10, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3626 IIC_iMUL16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm",
3627 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3628 (sra GPR:$Rm, (i32 16))))]>,
3629 Requires<[IsARM, HasV5TE]>;
3631 def TB : AMulxyI<0b0001011, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3632 IIC_iMUL16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm",
3633 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3634 (sext_inreg GPR:$Rm, i16)))]>,
3635 Requires<[IsARM, HasV5TE]>;
3637 def TT : AMulxyI<0b0001011, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3638 IIC_iMUL16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm",
3639 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3640 (sra GPR:$Rm, (i32 16))))]>,
3641 Requires<[IsARM, HasV5TE]>;
3643 def WB : AMulxyI<0b0001001, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3644 IIC_iMUL16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm",
3645 [(set GPR:$Rd, (sra (opnode GPR:$Rn,
3646 (sext_inreg GPR:$Rm, i16)), (i32 16)))]>,
3647 Requires<[IsARM, HasV5TE]>;
3649 def WT : AMulxyI<0b0001001, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3650 IIC_iMUL16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm",
3651 [(set GPR:$Rd, (sra (opnode GPR:$Rn,
3652 (sra GPR:$Rm, (i32 16))), (i32 16)))]>,
3653 Requires<[IsARM, HasV5TE]>;
3657 multiclass AI_smla<string opc, PatFrag opnode> {
3658 let DecoderMethod = "DecodeSMLAInstruction" in {
3659 def BB : AMulxyIa<0b0001000, 0b00, (outs GPRnopc:$Rd),
3660 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3661 IIC_iMAC16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra",
3662 [(set GPRnopc:$Rd, (add GPR:$Ra,
3663 (opnode (sext_inreg GPRnopc:$Rn, i16),
3664 (sext_inreg GPRnopc:$Rm, i16))))]>,
3665 Requires<[IsARM, HasV5TE]>;
3667 def BT : AMulxyIa<0b0001000, 0b10, (outs GPRnopc:$Rd),
3668 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3669 IIC_iMAC16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra",
3671 (add GPR:$Ra, (opnode (sext_inreg GPRnopc:$Rn, i16),
3672 (sra GPRnopc:$Rm, (i32 16)))))]>,
3673 Requires<[IsARM, HasV5TE]>;
3675 def TB : AMulxyIa<0b0001000, 0b01, (outs GPRnopc:$Rd),
3676 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3677 IIC_iMAC16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra",
3679 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
3680 (sext_inreg GPRnopc:$Rm, i16))))]>,
3681 Requires<[IsARM, HasV5TE]>;
3683 def TT : AMulxyIa<0b0001000, 0b11, (outs GPRnopc:$Rd),
3684 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3685 IIC_iMAC16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra",
3687 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
3688 (sra GPRnopc:$Rm, (i32 16)))))]>,
3689 Requires<[IsARM, HasV5TE]>;
3691 def WB : AMulxyIa<0b0001001, 0b00, (outs GPRnopc:$Rd),
3692 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3693 IIC_iMAC16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra",
3695 (add GPR:$Ra, (sra (opnode GPRnopc:$Rn,
3696 (sext_inreg GPRnopc:$Rm, i16)), (i32 16))))]>,
3697 Requires<[IsARM, HasV5TE]>;
3699 def WT : AMulxyIa<0b0001001, 0b10, (outs GPRnopc:$Rd),
3700 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3701 IIC_iMAC16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra",
3703 (add GPR:$Ra, (sra (opnode GPRnopc:$Rn,
3704 (sra GPRnopc:$Rm, (i32 16))), (i32 16))))]>,
3705 Requires<[IsARM, HasV5TE]>;
3709 defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
3710 defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
3712 // Halfword multiply accumulate long: SMLAL<x><y>.
3713 def SMLALBB : AMulxyI64<0b0001010, 0b00, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3714 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3715 IIC_iMAC64, "smlalbb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3716 Requires<[IsARM, HasV5TE]>;
3718 def SMLALBT : AMulxyI64<0b0001010, 0b10, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3719 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3720 IIC_iMAC64, "smlalbt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3721 Requires<[IsARM, HasV5TE]>;
3723 def SMLALTB : AMulxyI64<0b0001010, 0b01, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3724 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3725 IIC_iMAC64, "smlaltb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3726 Requires<[IsARM, HasV5TE]>;
3728 def SMLALTT : AMulxyI64<0b0001010, 0b11, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3729 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3730 IIC_iMAC64, "smlaltt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3731 Requires<[IsARM, HasV5TE]>;
3733 // Helper class for AI_smld.
3734 class AMulDualIbase<bit long, bit sub, bit swap, dag oops, dag iops,
3735 InstrItinClass itin, string opc, string asm>
3736 : AI<oops, iops, MulFrm, itin, opc, asm, []>, Requires<[IsARM, HasV6]> {
3739 let Inst{27-23} = 0b01110;
3740 let Inst{22} = long;
3741 let Inst{21-20} = 0b00;
3742 let Inst{11-8} = Rm;
3749 class AMulDualI<bit long, bit sub, bit swap, dag oops, dag iops,
3750 InstrItinClass itin, string opc, string asm>
3751 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
3753 let Inst{15-12} = 0b1111;
3754 let Inst{19-16} = Rd;
3756 class AMulDualIa<bit long, bit sub, bit swap, dag oops, dag iops,
3757 InstrItinClass itin, string opc, string asm>
3758 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
3761 let Inst{19-16} = Rd;
3762 let Inst{15-12} = Ra;
3764 class AMulDualI64<bit long, bit sub, bit swap, dag oops, dag iops,
3765 InstrItinClass itin, string opc, string asm>
3766 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
3769 let Inst{19-16} = RdHi;
3770 let Inst{15-12} = RdLo;
3773 multiclass AI_smld<bit sub, string opc> {
3775 def D : AMulDualIa<0, sub, 0, (outs GPRnopc:$Rd),
3776 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3777 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm, $Ra">;
3779 def DX: AMulDualIa<0, sub, 1, (outs GPRnopc:$Rd),
3780 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3781 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm, $Ra">;
3783 def LD: AMulDualI64<1, sub, 0, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3784 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
3785 !strconcat(opc, "ld"), "\t$RdLo, $RdHi, $Rn, $Rm">;
3787 def LDX : AMulDualI64<1, sub, 1, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3788 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
3789 !strconcat(opc, "ldx"),"\t$RdLo, $RdHi, $Rn, $Rm">;
3793 defm SMLA : AI_smld<0, "smla">;
3794 defm SMLS : AI_smld<1, "smls">;
3796 multiclass AI_sdml<bit sub, string opc> {
3798 def D:AMulDualI<0, sub, 0, (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm),
3799 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm">;
3800 def DX:AMulDualI<0, sub, 1, (outs GPRnopc:$Rd),(ins GPRnopc:$Rn, GPRnopc:$Rm),
3801 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm">;
3804 defm SMUA : AI_sdml<0, "smua">;
3805 defm SMUS : AI_sdml<1, "smus">;
3807 //===----------------------------------------------------------------------===//
3808 // Misc. Arithmetic Instructions.
3811 def CLZ : AMiscA1I<0b000010110, 0b0001, (outs GPR:$Rd), (ins GPR:$Rm),
3812 IIC_iUNAr, "clz", "\t$Rd, $Rm",
3813 [(set GPR:$Rd, (ctlz GPR:$Rm))]>, Requires<[IsARM, HasV5T]>;
3815 def RBIT : AMiscA1I<0b01101111, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
3816 IIC_iUNAr, "rbit", "\t$Rd, $Rm",
3817 [(set GPR:$Rd, (ARMrbit GPR:$Rm))]>,
3818 Requires<[IsARM, HasV6T2]>;
3820 def REV : AMiscA1I<0b01101011, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
3821 IIC_iUNAr, "rev", "\t$Rd, $Rm",
3822 [(set GPR:$Rd, (bswap GPR:$Rm))]>, Requires<[IsARM, HasV6]>;
3824 let AddedComplexity = 5 in
3825 def REV16 : AMiscA1I<0b01101011, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
3826 IIC_iUNAr, "rev16", "\t$Rd, $Rm",
3827 [(set GPR:$Rd, (rotr (bswap GPR:$Rm), (i32 16)))]>,
3828 Requires<[IsARM, HasV6]>;
3830 let AddedComplexity = 5 in
3831 def REVSH : AMiscA1I<0b01101111, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
3832 IIC_iUNAr, "revsh", "\t$Rd, $Rm",
3833 [(set GPR:$Rd, (sra (bswap GPR:$Rm), (i32 16)))]>,
3834 Requires<[IsARM, HasV6]>;
3836 def : ARMV6Pat<(or (sra (shl GPR:$Rm, (i32 24)), (i32 16)),
3837 (and (srl GPR:$Rm, (i32 8)), 0xFF)),
3840 def PKHBT : APKHI<0b01101000, 0, (outs GPRnopc:$Rd),
3841 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_lsl_amt:$sh),
3842 IIC_iALUsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh",
3843 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF),
3844 (and (shl GPRnopc:$Rm, pkh_lsl_amt:$sh),
3846 Requires<[IsARM, HasV6]>;
3848 // Alternate cases for PKHBT where identities eliminate some nodes.
3849 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (and GPRnopc:$Rm, 0xFFFF0000)),
3850 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, 0)>;
3851 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (shl GPRnopc:$Rm, imm16_31:$sh)),
3852 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, imm16_31:$sh)>;
3854 // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
3855 // will match the pattern below.
3856 def PKHTB : APKHI<0b01101000, 1, (outs GPRnopc:$Rd),
3857 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_asr_amt:$sh),
3858 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh",
3859 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF0000),
3860 (and (sra GPRnopc:$Rm, pkh_asr_amt:$sh),
3862 Requires<[IsARM, HasV6]>;
3864 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
3865 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
3866 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
3867 (srl GPRnopc:$src2, imm16_31:$sh)),
3868 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16_31:$sh)>;
3869 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
3870 (and (srl GPRnopc:$src2, imm1_15:$sh), 0xFFFF)),
3871 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm1_15:$sh)>;
3873 //===----------------------------------------------------------------------===//
3874 // Comparison Instructions...
3877 defm CMP : AI1_cmp_irs<0b1010, "cmp",
3878 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
3879 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
3881 // ARMcmpZ can re-use the above instruction definitions.
3882 def : ARMPat<(ARMcmpZ GPR:$src, so_imm:$imm),
3883 (CMPri GPR:$src, so_imm:$imm)>;
3884 def : ARMPat<(ARMcmpZ GPR:$src, GPR:$rhs),
3885 (CMPrr GPR:$src, GPR:$rhs)>;
3886 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_imm:$rhs),
3887 (CMPrsi GPR:$src, so_reg_imm:$rhs)>;
3888 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_reg:$rhs),
3889 (CMPrsr GPR:$src, so_reg_reg:$rhs)>;
3891 // FIXME: We have to be careful when using the CMN instruction and comparison
3892 // with 0. One would expect these two pieces of code should give identical
3908 // However, the CMN gives the *opposite* result when r1 is 0. This is because
3909 // the carry flag is set in the CMP case but not in the CMN case. In short, the
3910 // CMP instruction doesn't perform a truncate of the (logical) NOT of 0 plus the
3911 // value of r0 and the carry bit (because the "carry bit" parameter to
3912 // AddWithCarry is defined as 1 in this case, the carry flag will always be set
3913 // when r0 >= 0). The CMN instruction doesn't perform a NOT of 0 so there is
3914 // never a "carry" when this AddWithCarry is performed (because the "carry bit"
3915 // parameter to AddWithCarry is defined as 0).
3917 // When x is 0 and unsigned:
3921 // ~x + 1 = 0x1 0000 0000
3922 // (-x = 0) != (0x1 0000 0000 = ~x + 1)
3924 // Therefore, we should disable CMN when comparing against zero, until we can
3925 // limit when the CMN instruction is used (when we know that the RHS is not 0 or
3926 // when it's a comparison which doesn't look at the 'carry' flag).
3928 // (See the ARM docs for the "AddWithCarry" pseudo-code.)
3930 // This is related to <rdar://problem/7569620>.
3932 //defm CMN : AI1_cmp_irs<0b1011, "cmn",
3933 // BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>;
3935 // Note that TST/TEQ don't set all the same flags that CMP does!
3936 defm TST : AI1_cmp_irs<0b1000, "tst",
3937 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
3938 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>, 1>;
3939 defm TEQ : AI1_cmp_irs<0b1001, "teq",
3940 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
3941 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>, 1>;
3943 defm CMNz : AI1_cmp_irs<0b1011, "cmn",
3944 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
3945 BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>>;
3947 //def : ARMPat<(ARMcmp GPR:$src, so_imm_neg:$imm),
3948 // (CMNri GPR:$src, so_imm_neg:$imm)>;
3950 def : ARMPat<(ARMcmpZ GPR:$src, so_imm_neg:$imm),
3951 (CMNzri GPR:$src, so_imm_neg:$imm)>;
3953 // Pseudo i64 compares for some floating point compares.
3954 let usesCustomInserter = 1, isBranch = 1, isTerminator = 1,
3956 def BCCi64 : PseudoInst<(outs),
3957 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, brtarget:$dst),
3959 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, bb:$dst)]>;
3961 def BCCZi64 : PseudoInst<(outs),
3962 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, brtarget:$dst), IIC_Br,
3963 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, 0, 0, bb:$dst)]>;
3964 } // usesCustomInserter
3967 // Conditional moves
3968 // FIXME: should be able to write a pattern for ARMcmov, but can't use
3969 // a two-value operand where a dag node expects two operands. :(
3970 let neverHasSideEffects = 1 in {
3971 def MOVCCr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$false, GPR:$Rm, pred:$p),
3973 [/*(set GPR:$Rd, (ARMcmov GPR:$false, GPR:$Rm, imm:$cc, CCR:$ccr))*/]>,
3974 RegConstraint<"$false = $Rd">;
3975 def MOVCCsi : ARMPseudoInst<(outs GPR:$Rd),
3976 (ins GPR:$false, so_reg_imm:$shift, pred:$p),
3978 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_imm:$shift,
3979 imm:$cc, CCR:$ccr))*/]>,
3980 RegConstraint<"$false = $Rd">;
3981 def MOVCCsr : ARMPseudoInst<(outs GPR:$Rd),
3982 (ins GPR:$false, so_reg_reg:$shift, pred:$p),
3984 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_reg:$shift,
3985 imm:$cc, CCR:$ccr))*/]>,
3986 RegConstraint<"$false = $Rd">;
3989 let isMoveImm = 1 in
3990 def MOVCCi16 : ARMPseudoInst<(outs GPR:$Rd),
3991 (ins GPR:$false, imm0_65535_expr:$imm, pred:$p),
3994 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>;
3996 let isMoveImm = 1 in
3997 def MOVCCi : ARMPseudoInst<(outs GPR:$Rd),
3998 (ins GPR:$false, so_imm:$imm, pred:$p),
4000 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_imm:$imm, imm:$cc, CCR:$ccr))*/]>,
4001 RegConstraint<"$false = $Rd">;
4003 // Two instruction predicate mov immediate.
4004 let isMoveImm = 1 in
4005 def MOVCCi32imm : ARMPseudoInst<(outs GPR:$Rd),
4006 (ins GPR:$false, i32imm:$src, pred:$p),
4007 8, IIC_iCMOVix2, []>, RegConstraint<"$false = $Rd">;
4009 let isMoveImm = 1 in
4010 def MVNCCi : ARMPseudoInst<(outs GPR:$Rd),
4011 (ins GPR:$false, so_imm:$imm, pred:$p),
4013 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_imm_not:$imm, imm:$cc, CCR:$ccr))*/]>,
4014 RegConstraint<"$false = $Rd">;
4015 } // neverHasSideEffects
4017 //===----------------------------------------------------------------------===//
4018 // Atomic operations intrinsics
4021 def MemBarrierOptOperand : AsmOperandClass {
4022 let Name = "MemBarrierOpt";
4023 let ParserMethod = "parseMemBarrierOptOperand";
4025 def memb_opt : Operand<i32> {
4026 let PrintMethod = "printMemBOption";
4027 let ParserMatchClass = MemBarrierOptOperand;
4028 let DecoderMethod = "DecodeMemBarrierOption";
4031 // memory barriers protect the atomic sequences
4032 let hasSideEffects = 1 in {
4033 def DMB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4034 "dmb", "\t$opt", [(ARMMemBarrier (i32 imm:$opt))]>,
4035 Requires<[IsARM, HasDB]> {
4037 let Inst{31-4} = 0xf57ff05;
4038 let Inst{3-0} = opt;
4042 def DSB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4043 "dsb", "\t$opt", []>,
4044 Requires<[IsARM, HasDB]> {
4046 let Inst{31-4} = 0xf57ff04;
4047 let Inst{3-0} = opt;
4050 // ISB has only full system option
4051 def ISB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4052 "isb", "\t$opt", []>,
4053 Requires<[IsARM, HasDB]> {
4055 let Inst{31-4} = 0xf57ff06;
4056 let Inst{3-0} = opt;
4059 // Pseudo isntruction that combines movs + predicated rsbmi
4060 // to implement integer ABS
4061 let usesCustomInserter = 1, Defs = [CPSR] in {
4062 def ABS : ARMPseudoInst<
4063 (outs GPR:$dst), (ins GPR:$src),
4064 8, NoItinerary, []>;
4067 let usesCustomInserter = 1 in {
4068 let Defs = [CPSR] in {
4069 def ATOMIC_LOAD_ADD_I8 : PseudoInst<
4070 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4071 [(set GPR:$dst, (atomic_load_add_8 GPR:$ptr, GPR:$incr))]>;
4072 def ATOMIC_LOAD_SUB_I8 : PseudoInst<
4073 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4074 [(set GPR:$dst, (atomic_load_sub_8 GPR:$ptr, GPR:$incr))]>;
4075 def ATOMIC_LOAD_AND_I8 : PseudoInst<
4076 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4077 [(set GPR:$dst, (atomic_load_and_8 GPR:$ptr, GPR:$incr))]>;
4078 def ATOMIC_LOAD_OR_I8 : PseudoInst<
4079 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4080 [(set GPR:$dst, (atomic_load_or_8 GPR:$ptr, GPR:$incr))]>;
4081 def ATOMIC_LOAD_XOR_I8 : PseudoInst<
4082 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4083 [(set GPR:$dst, (atomic_load_xor_8 GPR:$ptr, GPR:$incr))]>;
4084 def ATOMIC_LOAD_NAND_I8 : PseudoInst<
4085 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4086 [(set GPR:$dst, (atomic_load_nand_8 GPR:$ptr, GPR:$incr))]>;
4087 def ATOMIC_LOAD_MIN_I8 : PseudoInst<
4088 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4089 [(set GPR:$dst, (atomic_load_min_8 GPR:$ptr, GPR:$val))]>;
4090 def ATOMIC_LOAD_MAX_I8 : PseudoInst<
4091 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4092 [(set GPR:$dst, (atomic_load_max_8 GPR:$ptr, GPR:$val))]>;
4093 def ATOMIC_LOAD_UMIN_I8 : PseudoInst<
4094 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4095 [(set GPR:$dst, (atomic_load_min_8 GPR:$ptr, GPR:$val))]>;
4096 def ATOMIC_LOAD_UMAX_I8 : PseudoInst<
4097 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4098 [(set GPR:$dst, (atomic_load_max_8 GPR:$ptr, GPR:$val))]>;
4099 def ATOMIC_LOAD_ADD_I16 : PseudoInst<
4100 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4101 [(set GPR:$dst, (atomic_load_add_16 GPR:$ptr, GPR:$incr))]>;
4102 def ATOMIC_LOAD_SUB_I16 : PseudoInst<
4103 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4104 [(set GPR:$dst, (atomic_load_sub_16 GPR:$ptr, GPR:$incr))]>;
4105 def ATOMIC_LOAD_AND_I16 : PseudoInst<
4106 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4107 [(set GPR:$dst, (atomic_load_and_16 GPR:$ptr, GPR:$incr))]>;
4108 def ATOMIC_LOAD_OR_I16 : PseudoInst<
4109 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4110 [(set GPR:$dst, (atomic_load_or_16 GPR:$ptr, GPR:$incr))]>;
4111 def ATOMIC_LOAD_XOR_I16 : PseudoInst<
4112 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4113 [(set GPR:$dst, (atomic_load_xor_16 GPR:$ptr, GPR:$incr))]>;
4114 def ATOMIC_LOAD_NAND_I16 : PseudoInst<
4115 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4116 [(set GPR:$dst, (atomic_load_nand_16 GPR:$ptr, GPR:$incr))]>;
4117 def ATOMIC_LOAD_MIN_I16 : PseudoInst<
4118 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4119 [(set GPR:$dst, (atomic_load_min_16 GPR:$ptr, GPR:$val))]>;
4120 def ATOMIC_LOAD_MAX_I16 : PseudoInst<
4121 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4122 [(set GPR:$dst, (atomic_load_max_16 GPR:$ptr, GPR:$val))]>;
4123 def ATOMIC_LOAD_UMIN_I16 : PseudoInst<
4124 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4125 [(set GPR:$dst, (atomic_load_min_16 GPR:$ptr, GPR:$val))]>;
4126 def ATOMIC_LOAD_UMAX_I16 : PseudoInst<
4127 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4128 [(set GPR:$dst, (atomic_load_max_16 GPR:$ptr, GPR:$val))]>;
4129 def ATOMIC_LOAD_ADD_I32 : PseudoInst<
4130 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4131 [(set GPR:$dst, (atomic_load_add_32 GPR:$ptr, GPR:$incr))]>;
4132 def ATOMIC_LOAD_SUB_I32 : PseudoInst<
4133 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4134 [(set GPR:$dst, (atomic_load_sub_32 GPR:$ptr, GPR:$incr))]>;
4135 def ATOMIC_LOAD_AND_I32 : PseudoInst<
4136 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4137 [(set GPR:$dst, (atomic_load_and_32 GPR:$ptr, GPR:$incr))]>;
4138 def ATOMIC_LOAD_OR_I32 : PseudoInst<
4139 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4140 [(set GPR:$dst, (atomic_load_or_32 GPR:$ptr, GPR:$incr))]>;
4141 def ATOMIC_LOAD_XOR_I32 : PseudoInst<
4142 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4143 [(set GPR:$dst, (atomic_load_xor_32 GPR:$ptr, GPR:$incr))]>;
4144 def ATOMIC_LOAD_NAND_I32 : PseudoInst<
4145 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4146 [(set GPR:$dst, (atomic_load_nand_32 GPR:$ptr, GPR:$incr))]>;
4147 def ATOMIC_LOAD_MIN_I32 : PseudoInst<
4148 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4149 [(set GPR:$dst, (atomic_load_min_32 GPR:$ptr, GPR:$val))]>;
4150 def ATOMIC_LOAD_MAX_I32 : PseudoInst<
4151 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4152 [(set GPR:$dst, (atomic_load_max_32 GPR:$ptr, GPR:$val))]>;
4153 def ATOMIC_LOAD_UMIN_I32 : PseudoInst<
4154 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4155 [(set GPR:$dst, (atomic_load_min_32 GPR:$ptr, GPR:$val))]>;
4156 def ATOMIC_LOAD_UMAX_I32 : PseudoInst<
4157 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4158 [(set GPR:$dst, (atomic_load_max_32 GPR:$ptr, GPR:$val))]>;
4160 def ATOMIC_SWAP_I8 : PseudoInst<
4161 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
4162 [(set GPR:$dst, (atomic_swap_8 GPR:$ptr, GPR:$new))]>;
4163 def ATOMIC_SWAP_I16 : PseudoInst<
4164 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
4165 [(set GPR:$dst, (atomic_swap_16 GPR:$ptr, GPR:$new))]>;
4166 def ATOMIC_SWAP_I32 : PseudoInst<
4167 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
4168 [(set GPR:$dst, (atomic_swap_32 GPR:$ptr, GPR:$new))]>;
4170 def ATOMIC_CMP_SWAP_I8 : PseudoInst<
4171 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
4172 [(set GPR:$dst, (atomic_cmp_swap_8 GPR:$ptr, GPR:$old, GPR:$new))]>;
4173 def ATOMIC_CMP_SWAP_I16 : PseudoInst<
4174 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
4175 [(set GPR:$dst, (atomic_cmp_swap_16 GPR:$ptr, GPR:$old, GPR:$new))]>;
4176 def ATOMIC_CMP_SWAP_I32 : PseudoInst<
4177 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
4178 [(set GPR:$dst, (atomic_cmp_swap_32 GPR:$ptr, GPR:$old, GPR:$new))]>;
4182 let mayLoad = 1 in {
4183 def LDREXB : AIldrex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4185 "ldrexb", "\t$Rt, $addr", []>;
4186 def LDREXH : AIldrex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4187 NoItinerary, "ldrexh", "\t$Rt, $addr", []>;
4188 def LDREX : AIldrex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4189 NoItinerary, "ldrex", "\t$Rt, $addr", []>;
4190 let hasExtraDefRegAllocReq = 1 in
4191 def LDREXD: AIldrex<0b01, (outs GPR:$Rt, GPR:$Rt2),(ins addr_offset_none:$addr),
4192 NoItinerary, "ldrexd", "\t$Rt, $Rt2, $addr", []> {
4193 let DecoderMethod = "DecodeDoubleRegLoad";
4197 let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
4198 def STREXB: AIstrex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4199 NoItinerary, "strexb", "\t$Rd, $Rt, $addr", []>;
4200 def STREXH: AIstrex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4201 NoItinerary, "strexh", "\t$Rd, $Rt, $addr", []>;
4202 def STREX : AIstrex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4203 NoItinerary, "strex", "\t$Rd, $Rt, $addr", []>;
4206 let hasExtraSrcRegAllocReq = 1, Constraints = "@earlyclobber $Rd" in
4207 def STREXD : AIstrex<0b01, (outs GPR:$Rd),
4208 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr),
4209 NoItinerary, "strexd", "\t$Rd, $Rt, $Rt2, $addr", []> {
4210 let DecoderMethod = "DecodeDoubleRegStore";
4213 def CLREX : AXI<(outs), (ins), MiscFrm, NoItinerary, "clrex", []>,
4214 Requires<[IsARM, HasV7]> {
4215 let Inst{31-0} = 0b11110101011111111111000000011111;
4218 // SWP/SWPB are deprecated in V6/V7.
4219 let mayLoad = 1, mayStore = 1 in {
4220 def SWP : AIswp<0, (outs GPR:$Rt), (ins GPR:$Rt2, addr_offset_none:$addr),
4222 def SWPB: AIswp<1, (outs GPR:$Rt), (ins GPR:$Rt2, addr_offset_none:$addr),
4226 //===----------------------------------------------------------------------===//
4227 // Coprocessor Instructions.
4230 def CDP : ABI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4231 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4232 NoItinerary, "cdp", "\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4233 [(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4234 imm:$CRm, imm:$opc2)]> {
4242 let Inst{3-0} = CRm;
4244 let Inst{7-5} = opc2;
4245 let Inst{11-8} = cop;
4246 let Inst{15-12} = CRd;
4247 let Inst{19-16} = CRn;
4248 let Inst{23-20} = opc1;
4251 def CDP2 : ABXI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4252 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4253 NoItinerary, "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4254 [(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4255 imm:$CRm, imm:$opc2)]> {
4256 let Inst{31-28} = 0b1111;
4264 let Inst{3-0} = CRm;
4266 let Inst{7-5} = opc2;
4267 let Inst{11-8} = cop;
4268 let Inst{15-12} = CRd;
4269 let Inst{19-16} = CRn;
4270 let Inst{23-20} = opc1;
4273 class ACI<dag oops, dag iops, string opc, string asm,
4274 IndexMode im = IndexModeNone>
4275 : I<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
4277 let Inst{27-25} = 0b110;
4279 class ACInoP<dag oops, dag iops, string opc, string asm,
4280 IndexMode im = IndexModeNone>
4281 : InoP<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
4283 let Inst{31-28} = 0b1111;
4284 let Inst{27-25} = 0b110;
4286 multiclass LdStCop<bit load, bit Dbit, string asm> {
4287 def _OFFSET : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4288 asm, "\t$cop, $CRd, $addr"> {
4292 let Inst{24} = 1; // P = 1
4293 let Inst{23} = addr{8};
4294 let Inst{22} = Dbit;
4295 let Inst{21} = 0; // W = 0
4296 let Inst{20} = load;
4297 let Inst{19-16} = addr{12-9};
4298 let Inst{15-12} = CRd;
4299 let Inst{11-8} = cop;
4300 let Inst{7-0} = addr{7-0};
4301 let DecoderMethod = "DecodeCopMemInstruction";
4303 def _PRE : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4304 asm, "\t$cop, $CRd, $addr!", IndexModePre> {
4308 let Inst{24} = 1; // P = 1
4309 let Inst{23} = addr{8};
4310 let Inst{22} = Dbit;
4311 let Inst{21} = 1; // W = 1
4312 let Inst{20} = load;
4313 let Inst{19-16} = addr{12-9};
4314 let Inst{15-12} = CRd;
4315 let Inst{11-8} = cop;
4316 let Inst{7-0} = addr{7-0};
4317 let DecoderMethod = "DecodeCopMemInstruction";
4319 def _POST: ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4320 postidx_imm8s4:$offset),
4321 asm, "\t$cop, $CRd, $addr, $offset", IndexModePost> {
4326 let Inst{24} = 0; // P = 0
4327 let Inst{23} = offset{8};
4328 let Inst{22} = Dbit;
4329 let Inst{21} = 1; // W = 1
4330 let Inst{20} = load;
4331 let Inst{19-16} = addr;
4332 let Inst{15-12} = CRd;
4333 let Inst{11-8} = cop;
4334 let Inst{7-0} = offset{7-0};
4335 let DecoderMethod = "DecodeCopMemInstruction";
4337 def _OPTION : ACI<(outs),
4338 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4339 coproc_option_imm:$option),
4340 asm, "\t$cop, $CRd, $addr, $option"> {
4345 let Inst{24} = 0; // P = 0
4346 let Inst{23} = 1; // U = 1
4347 let Inst{22} = Dbit;
4348 let Inst{21} = 0; // W = 0
4349 let Inst{20} = load;
4350 let Inst{19-16} = addr;
4351 let Inst{15-12} = CRd;
4352 let Inst{11-8} = cop;
4353 let Inst{7-0} = option;
4354 let DecoderMethod = "DecodeCopMemInstruction";
4357 multiclass LdSt2Cop<bit load, bit Dbit, string asm> {
4358 def _OFFSET : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4359 asm, "\t$cop, $CRd, $addr"> {
4363 let Inst{24} = 1; // P = 1
4364 let Inst{23} = addr{8};
4365 let Inst{22} = Dbit;
4366 let Inst{21} = 0; // W = 0
4367 let Inst{20} = load;
4368 let Inst{19-16} = addr{12-9};
4369 let Inst{15-12} = CRd;
4370 let Inst{11-8} = cop;
4371 let Inst{7-0} = addr{7-0};
4372 let DecoderMethod = "DecodeCopMemInstruction";
4374 def _PRE : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4375 asm, "\t$cop, $CRd, $addr!", IndexModePre> {
4379 let Inst{24} = 1; // P = 1
4380 let Inst{23} = addr{8};
4381 let Inst{22} = Dbit;
4382 let Inst{21} = 1; // W = 1
4383 let Inst{20} = load;
4384 let Inst{19-16} = addr{12-9};
4385 let Inst{15-12} = CRd;
4386 let Inst{11-8} = cop;
4387 let Inst{7-0} = addr{7-0};
4388 let DecoderMethod = "DecodeCopMemInstruction";
4390 def _POST: ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4391 postidx_imm8s4:$offset),
4392 asm, "\t$cop, $CRd, $addr, $offset", IndexModePost> {
4397 let Inst{24} = 0; // P = 0
4398 let Inst{23} = offset{8};
4399 let Inst{22} = Dbit;
4400 let Inst{21} = 1; // W = 1
4401 let Inst{20} = load;
4402 let Inst{19-16} = addr;
4403 let Inst{15-12} = CRd;
4404 let Inst{11-8} = cop;
4405 let Inst{7-0} = offset{7-0};
4406 let DecoderMethod = "DecodeCopMemInstruction";
4408 def _OPTION : ACInoP<(outs),
4409 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4410 coproc_option_imm:$option),
4411 asm, "\t$cop, $CRd, $addr, $option"> {
4416 let Inst{24} = 0; // P = 0
4417 let Inst{23} = 1; // U = 1
4418 let Inst{22} = Dbit;
4419 let Inst{21} = 0; // W = 0
4420 let Inst{20} = load;
4421 let Inst{19-16} = addr;
4422 let Inst{15-12} = CRd;
4423 let Inst{11-8} = cop;
4424 let Inst{7-0} = option;
4425 let DecoderMethod = "DecodeCopMemInstruction";
4429 defm LDC : LdStCop <1, 0, "ldc">;
4430 defm LDCL : LdStCop <1, 1, "ldcl">;
4431 defm STC : LdStCop <0, 0, "stc">;
4432 defm STCL : LdStCop <0, 1, "stcl">;
4433 defm LDC2 : LdSt2Cop<1, 0, "ldc2">;
4434 defm LDC2L : LdSt2Cop<1, 1, "ldc2l">;
4435 defm STC2 : LdSt2Cop<0, 0, "stc2">;
4436 defm STC2L : LdSt2Cop<0, 1, "stc2l">;
4438 //===----------------------------------------------------------------------===//
4439 // Move between coprocessor and ARM core register.
4442 class MovRCopro<string opc, bit direction, dag oops, dag iops,
4444 : ABI<0b1110, oops, iops, NoItinerary, opc,
4445 "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2", pattern> {
4446 let Inst{20} = direction;
4456 let Inst{15-12} = Rt;
4457 let Inst{11-8} = cop;
4458 let Inst{23-21} = opc1;
4459 let Inst{7-5} = opc2;
4460 let Inst{3-0} = CRm;
4461 let Inst{19-16} = CRn;
4464 def MCR : MovRCopro<"mcr", 0 /* from ARM core register to coprocessor */,
4466 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4467 c_imm:$CRm, imm0_7:$opc2),
4468 [(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
4469 imm:$CRm, imm:$opc2)]>;
4470 def MRC : MovRCopro<"mrc", 1 /* from coprocessor to ARM core register */,
4472 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
4475 def : ARMPat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
4476 (MRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
4478 class MovRCopro2<string opc, bit direction, dag oops, dag iops,
4480 : ABXI<0b1110, oops, iops, NoItinerary,
4481 !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), pattern> {
4482 let Inst{31-28} = 0b1111;
4483 let Inst{20} = direction;
4493 let Inst{15-12} = Rt;
4494 let Inst{11-8} = cop;
4495 let Inst{23-21} = opc1;
4496 let Inst{7-5} = opc2;
4497 let Inst{3-0} = CRm;
4498 let Inst{19-16} = CRn;
4501 def MCR2 : MovRCopro2<"mcr2", 0 /* from ARM core register to coprocessor */,
4503 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4504 c_imm:$CRm, imm0_7:$opc2),
4505 [(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
4506 imm:$CRm, imm:$opc2)]>;
4507 def MRC2 : MovRCopro2<"mrc2", 1 /* from coprocessor to ARM core register */,
4509 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
4512 def : ARMV5TPat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn,
4513 imm:$CRm, imm:$opc2),
4514 (MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
4516 class MovRRCopro<string opc, bit direction, list<dag> pattern = []>
4517 : ABI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4518 GPR:$Rt, GPR:$Rt2, c_imm:$CRm),
4519 NoItinerary, opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm", pattern> {
4520 let Inst{23-21} = 0b010;
4521 let Inst{20} = direction;
4529 let Inst{15-12} = Rt;
4530 let Inst{19-16} = Rt2;
4531 let Inst{11-8} = cop;
4532 let Inst{7-4} = opc1;
4533 let Inst{3-0} = CRm;
4536 def MCRR : MovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */,
4537 [(int_arm_mcrr imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2,
4539 def MRRC : MovRRCopro<"mrrc", 1 /* from coprocessor to ARM core register */>;
4541 class MovRRCopro2<string opc, bit direction, list<dag> pattern = []>
4542 : ABXI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4543 GPR:$Rt, GPR:$Rt2, c_imm:$CRm), NoItinerary,
4544 !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern> {
4545 let Inst{31-28} = 0b1111;
4546 let Inst{23-21} = 0b010;
4547 let Inst{20} = direction;
4555 let Inst{15-12} = Rt;
4556 let Inst{19-16} = Rt2;
4557 let Inst{11-8} = cop;
4558 let Inst{7-4} = opc1;
4559 let Inst{3-0} = CRm;
4562 def MCRR2 : MovRRCopro2<"mcrr2", 0 /* from ARM core register to coprocessor */,
4563 [(int_arm_mcrr2 imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2,
4565 def MRRC2 : MovRRCopro2<"mrrc2", 1 /* from coprocessor to ARM core register */>;
4567 //===----------------------------------------------------------------------===//
4568 // Move between special register and ARM core register
4571 // Move to ARM core register from Special Register
4572 def MRS : ABI<0b0001, (outs GPR:$Rd), (ins), NoItinerary,
4573 "mrs", "\t$Rd, apsr", []> {
4575 let Inst{23-16} = 0b00001111;
4576 let Inst{15-12} = Rd;
4577 let Inst{7-4} = 0b0000;
4580 def : InstAlias<"mrs${p} $Rd, cpsr", (MRS GPR:$Rd, pred:$p)>, Requires<[IsARM]>;
4582 def MRSsys : ABI<0b0001, (outs GPR:$Rd), (ins), NoItinerary,
4583 "mrs", "\t$Rd, spsr", []> {
4585 let Inst{23-16} = 0b01001111;
4586 let Inst{15-12} = Rd;
4587 let Inst{7-4} = 0b0000;
4590 // Move from ARM core register to Special Register
4592 // No need to have both system and application versions, the encodings are the
4593 // same and the assembly parser has no way to distinguish between them. The mask
4594 // operand contains the special register (R Bit) in bit 4 and bits 3-0 contains
4595 // the mask with the fields to be accessed in the special register.
4596 def MSR : ABI<0b0001, (outs), (ins msr_mask:$mask, GPR:$Rn), NoItinerary,
4597 "msr", "\t$mask, $Rn", []> {
4602 let Inst{22} = mask{4}; // R bit
4603 let Inst{21-20} = 0b10;
4604 let Inst{19-16} = mask{3-0};
4605 let Inst{15-12} = 0b1111;
4606 let Inst{11-4} = 0b00000000;
4610 def MSRi : ABI<0b0011, (outs), (ins msr_mask:$mask, so_imm:$a), NoItinerary,
4611 "msr", "\t$mask, $a", []> {
4616 let Inst{22} = mask{4}; // R bit
4617 let Inst{21-20} = 0b10;
4618 let Inst{19-16} = mask{3-0};
4619 let Inst{15-12} = 0b1111;
4623 //===----------------------------------------------------------------------===//
4627 // __aeabi_read_tp preserves the registers r1-r3.
4628 // This is a pseudo inst so that we can get the encoding right,
4629 // complete with fixup for the aeabi_read_tp function.
4631 Defs = [R0, R12, LR, CPSR], Uses = [SP] in {
4632 def TPsoft : PseudoInst<(outs), (ins), IIC_Br,
4633 [(set R0, ARMthread_pointer)]>;
4636 //===----------------------------------------------------------------------===//
4637 // SJLJ Exception handling intrinsics
4638 // eh_sjlj_setjmp() is an instruction sequence to store the return
4639 // address and save #0 in R0 for the non-longjmp case.
4640 // Since by its nature we may be coming from some other function to get
4641 // here, and we're using the stack frame for the containing function to
4642 // save/restore registers, we can't keep anything live in regs across
4643 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
4644 // when we get here from a longjmp(). We force everything out of registers
4645 // except for our own input by listing the relevant registers in Defs. By
4646 // doing so, we also cause the prologue/epilogue code to actively preserve
4647 // all of the callee-saved resgisters, which is exactly what we want.
4648 // A constant value is passed in $val, and we use the location as a scratch.
4650 // These are pseudo-instructions and are lowered to individual MC-insts, so
4651 // no encoding information is necessary.
4653 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
4654 QQQQ0, QQQQ1, QQQQ2, QQQQ3 ], hasSideEffects = 1, isBarrier = 1,
4655 usesCustomInserter = 1 in {
4656 def Int_eh_sjlj_setjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
4658 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
4659 Requires<[IsARM, HasVFP2]>;
4663 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
4664 hasSideEffects = 1, isBarrier = 1 in {
4665 def Int_eh_sjlj_setjmp_nofp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
4667 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
4668 Requires<[IsARM, NoVFP]>;
4671 // FIXME: Non-Darwin version(s)
4672 let isBarrier = 1, hasSideEffects = 1, isTerminator = 1,
4673 Defs = [ R7, LR, SP ] in {
4674 def Int_eh_sjlj_longjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$scratch),
4676 [(ARMeh_sjlj_longjmp GPR:$src, GPR:$scratch)]>,
4677 Requires<[IsARM, IsDarwin]>;
4680 // eh.sjlj.dispatchsetup pseudo-instruction.
4681 // This pseudo is used for ARM, Thumb1 and Thumb2. Any differences are
4682 // handled when the pseudo is expanded (which happens before any passes
4683 // that need the instruction size).
4684 let isBarrier = 1 in
4685 def eh_sjlj_dispatchsetup : PseudoInst<(outs), (ins), NoItinerary, []>;
4687 //===----------------------------------------------------------------------===//
4688 // Non-Instruction Patterns
4691 // ARMv4 indirect branch using (MOVr PC, dst)
4692 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in
4693 def MOVPCRX : ARMPseudoExpand<(outs), (ins GPR:$dst),
4694 4, IIC_Br, [(brind GPR:$dst)],
4695 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>,
4696 Requires<[IsARM, NoV4T]>;
4698 // Large immediate handling.
4700 // 32-bit immediate using two piece so_imms or movw + movt.
4701 // This is a single pseudo instruction, the benefit is that it can be remat'd
4702 // as a single unit instead of having to handle reg inputs.
4703 // FIXME: Remove this when we can do generalized remat.
4704 let isReMaterializable = 1, isMoveImm = 1 in
4705 def MOVi32imm : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
4706 [(set GPR:$dst, (arm_i32imm:$src))]>,
4709 // Pseudo instruction that combines movw + movt + add pc (if PIC).
4710 // It also makes it possible to rematerialize the instructions.
4711 // FIXME: Remove this when we can do generalized remat and when machine licm
4712 // can properly the instructions.
4713 let isReMaterializable = 1 in {
4714 def MOV_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
4716 [(set GPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>,
4717 Requires<[IsARM, UseMovt]>;
4719 def MOV_ga_dyn : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
4721 [(set GPR:$dst, (ARMWrapperDYN tglobaladdr:$addr))]>,
4722 Requires<[IsARM, UseMovt]>;
4724 let AddedComplexity = 10 in
4725 def MOV_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
4727 [(set GPR:$dst, (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
4728 Requires<[IsARM, UseMovt]>;
4729 } // isReMaterializable
4731 // ConstantPool, GlobalAddress, and JumpTable
4732 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (LEApcrel tglobaladdr :$dst)>,
4733 Requires<[IsARM, DontUseMovt]>;
4734 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
4735 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
4736 Requires<[IsARM, UseMovt]>;
4737 def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
4738 (LEApcrelJT tjumptable:$dst, imm:$id)>;
4740 // TODO: add,sub,and, 3-instr forms?
4743 def : ARMPat<(ARMtcret tcGPR:$dst),
4744 (TCRETURNri tcGPR:$dst)>, Requires<[IsDarwin]>;
4746 def : ARMPat<(ARMtcret (i32 tglobaladdr:$dst)),
4747 (TCRETURNdi texternalsym:$dst)>, Requires<[IsDarwin]>;
4749 def : ARMPat<(ARMtcret (i32 texternalsym:$dst)),
4750 (TCRETURNdi texternalsym:$dst)>, Requires<[IsDarwin]>;
4752 def : ARMPat<(ARMtcret tcGPR:$dst),
4753 (TCRETURNriND tcGPR:$dst)>, Requires<[IsNotDarwin]>;
4755 def : ARMPat<(ARMtcret (i32 tglobaladdr:$dst)),
4756 (TCRETURNdiND texternalsym:$dst)>, Requires<[IsNotDarwin]>;
4758 def : ARMPat<(ARMtcret (i32 texternalsym:$dst)),
4759 (TCRETURNdiND texternalsym:$dst)>, Requires<[IsNotDarwin]>;
4762 def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>,
4763 Requires<[IsARM, IsNotDarwin]>;
4764 def : ARMPat<(ARMcall texternalsym:$func), (BLr9 texternalsym:$func)>,
4765 Requires<[IsARM, IsDarwin]>;
4767 // zextload i1 -> zextload i8
4768 def : ARMPat<(zextloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
4769 def : ARMPat<(zextloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
4771 // extload -> zextload
4772 def : ARMPat<(extloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
4773 def : ARMPat<(extloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
4774 def : ARMPat<(extloadi8 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
4775 def : ARMPat<(extloadi8 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
4777 def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
4779 def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
4780 def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
4783 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4784 (sra (shl GPR:$b, (i32 16)), (i32 16))),
4785 (SMULBB GPR:$a, GPR:$b)>;
4786 def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
4787 (SMULBB GPR:$a, GPR:$b)>;
4788 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4789 (sra GPR:$b, (i32 16))),
4790 (SMULBT GPR:$a, GPR:$b)>;
4791 def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, (i32 16))),
4792 (SMULBT GPR:$a, GPR:$b)>;
4793 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)),
4794 (sra (shl GPR:$b, (i32 16)), (i32 16))),
4795 (SMULTB GPR:$a, GPR:$b)>;
4796 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), sext_16_node:$b),
4797 (SMULTB GPR:$a, GPR:$b)>;
4798 def : ARMV5TEPat<(sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
4800 (SMULWB GPR:$a, GPR:$b)>;
4801 def : ARMV5TEPat<(sra (mul GPR:$a, sext_16_node:$b), (i32 16)),
4802 (SMULWB GPR:$a, GPR:$b)>;
4804 def : ARMV5TEPat<(add GPR:$acc,
4805 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4806 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
4807 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
4808 def : ARMV5TEPat<(add GPR:$acc,
4809 (mul sext_16_node:$a, sext_16_node:$b)),
4810 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
4811 def : ARMV5TEPat<(add GPR:$acc,
4812 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4813 (sra GPR:$b, (i32 16)))),
4814 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
4815 def : ARMV5TEPat<(add GPR:$acc,
4816 (mul sext_16_node:$a, (sra GPR:$b, (i32 16)))),
4817 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
4818 def : ARMV5TEPat<(add GPR:$acc,
4819 (mul (sra GPR:$a, (i32 16)),
4820 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
4821 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
4822 def : ARMV5TEPat<(add GPR:$acc,
4823 (mul (sra GPR:$a, (i32 16)), sext_16_node:$b)),
4824 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
4825 def : ARMV5TEPat<(add GPR:$acc,
4826 (sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
4828 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
4829 def : ARMV5TEPat<(add GPR:$acc,
4830 (sra (mul GPR:$a, sext_16_node:$b), (i32 16))),
4831 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
4834 // Pre-v7 uses MCR for synchronization barriers.
4835 def : ARMPat<(ARMMemBarrierMCR GPR:$zero), (MCR 15, 0, GPR:$zero, 7, 10, 5)>,
4836 Requires<[IsARM, HasV6]>;
4838 // SXT/UXT with no rotate
4839 let AddedComplexity = 16 in {
4840 def : ARMV6Pat<(and GPR:$Src, 0x000000FF), (UXTB GPR:$Src, 0)>;
4841 def : ARMV6Pat<(and GPR:$Src, 0x0000FFFF), (UXTH GPR:$Src, 0)>;
4842 def : ARMV6Pat<(and GPR:$Src, 0x00FF00FF), (UXTB16 GPR:$Src, 0)>;
4843 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0x00FF)),
4844 (UXTAB GPR:$Rn, GPR:$Rm, 0)>;
4845 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0xFFFF)),
4846 (UXTAH GPR:$Rn, GPR:$Rm, 0)>;
4849 def : ARMV6Pat<(sext_inreg GPR:$Src, i8), (SXTB GPR:$Src, 0)>;
4850 def : ARMV6Pat<(sext_inreg GPR:$Src, i16), (SXTH GPR:$Src, 0)>;
4852 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i8)),
4853 (SXTAB GPR:$Rn, GPRnopc:$Rm, 0)>;
4854 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i16)),
4855 (SXTAH GPR:$Rn, GPRnopc:$Rm, 0)>;
4857 // Atomic load/store patterns
4858 def : ARMPat<(atomic_load_8 ldst_so_reg:$src),
4859 (LDRBrs ldst_so_reg:$src)>;
4860 def : ARMPat<(atomic_load_8 addrmode_imm12:$src),
4861 (LDRBi12 addrmode_imm12:$src)>;
4862 def : ARMPat<(atomic_load_16 addrmode3:$src),
4863 (LDRH addrmode3:$src)>;
4864 def : ARMPat<(atomic_load_32 ldst_so_reg:$src),
4865 (LDRrs ldst_so_reg:$src)>;
4866 def : ARMPat<(atomic_load_32 addrmode_imm12:$src),
4867 (LDRi12 addrmode_imm12:$src)>;
4868 def : ARMPat<(atomic_store_8 ldst_so_reg:$ptr, GPR:$val),
4869 (STRBrs GPR:$val, ldst_so_reg:$ptr)>;
4870 def : ARMPat<(atomic_store_8 addrmode_imm12:$ptr, GPR:$val),
4871 (STRBi12 GPR:$val, addrmode_imm12:$ptr)>;
4872 def : ARMPat<(atomic_store_16 addrmode3:$ptr, GPR:$val),
4873 (STRH GPR:$val, addrmode3:$ptr)>;
4874 def : ARMPat<(atomic_store_32 ldst_so_reg:$ptr, GPR:$val),
4875 (STRrs GPR:$val, ldst_so_reg:$ptr)>;
4876 def : ARMPat<(atomic_store_32 addrmode_imm12:$ptr, GPR:$val),
4877 (STRi12 GPR:$val, addrmode_imm12:$ptr)>;
4880 //===----------------------------------------------------------------------===//
4884 include "ARMInstrThumb.td"
4886 //===----------------------------------------------------------------------===//
4890 include "ARMInstrThumb2.td"
4892 //===----------------------------------------------------------------------===//
4893 // Floating Point Support
4896 include "ARMInstrVFP.td"
4898 //===----------------------------------------------------------------------===//
4899 // Advanced SIMD (NEON) Support
4902 include "ARMInstrNEON.td"
4904 //===----------------------------------------------------------------------===//
4905 // Assembler aliases
4909 def : InstAlias<"dmb", (DMB 0xf)>, Requires<[IsARM, HasDB]>;
4910 def : InstAlias<"dsb", (DSB 0xf)>, Requires<[IsARM, HasDB]>;
4911 def : InstAlias<"isb", (ISB 0xf)>, Requires<[IsARM, HasDB]>;
4913 // System instructions
4914 def : MnemonicAlias<"swi", "svc">;
4916 // Load / Store Multiple
4917 def : MnemonicAlias<"ldmfd", "ldm">;
4918 def : MnemonicAlias<"ldmia", "ldm">;
4919 def : MnemonicAlias<"ldmea", "ldmdb">;
4920 def : MnemonicAlias<"stmfd", "stmdb">;
4921 def : MnemonicAlias<"stmia", "stm">;
4922 def : MnemonicAlias<"stmea", "stm">;
4924 // PKHBT/PKHTB with default shift amount. PKHTB is equivalent to PKHBT when the
4925 // shift amount is zero (i.e., unspecified).
4926 def : InstAlias<"pkhbt${p} $Rd, $Rn, $Rm",
4927 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
4928 Requires<[IsARM, HasV6]>;
4929 def : InstAlias<"pkhtb${p} $Rd, $Rn, $Rm",
4930 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
4931 Requires<[IsARM, HasV6]>;
4933 // PUSH/POP aliases for STM/LDM
4934 def : ARMInstAlias<"push${p} $regs", (STMDB_UPD SP, pred:$p, reglist:$regs)>;
4935 def : ARMInstAlias<"pop${p} $regs", (LDMIA_UPD SP, pred:$p, reglist:$regs)>;
4937 // SSAT/USAT optional shift operand.
4938 def : ARMInstAlias<"ssat${p} $Rd, $sat_imm, $Rn",
4939 (SSAT GPRnopc:$Rd, imm1_32:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
4940 def : ARMInstAlias<"usat${p} $Rd, $sat_imm, $Rn",
4941 (USAT GPRnopc:$Rd, imm0_31:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
4944 // Extend instruction optional rotate operand.
4945 def : ARMInstAlias<"sxtab${p} $Rd, $Rn, $Rm",
4946 (SXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4947 def : ARMInstAlias<"sxtah${p} $Rd, $Rn, $Rm",
4948 (SXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4949 def : ARMInstAlias<"sxtab16${p} $Rd, $Rn, $Rm",
4950 (SXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4951 def : ARMInstAlias<"sxtb${p} $Rd, $Rm",
4952 (SXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4953 def : ARMInstAlias<"sxtb16${p} $Rd, $Rm",
4954 (SXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4955 def : ARMInstAlias<"sxth${p} $Rd, $Rm",
4956 (SXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4958 def : ARMInstAlias<"uxtab${p} $Rd, $Rn, $Rm",
4959 (UXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4960 def : ARMInstAlias<"uxtah${p} $Rd, $Rn, $Rm",
4961 (UXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4962 def : ARMInstAlias<"uxtab16${p} $Rd, $Rn, $Rm",
4963 (UXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4964 def : ARMInstAlias<"uxtb${p} $Rd, $Rm",
4965 (UXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4966 def : ARMInstAlias<"uxtb16${p} $Rd, $Rm",
4967 (UXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4968 def : ARMInstAlias<"uxth${p} $Rd, $Rm",
4969 (UXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4973 def : MnemonicAlias<"rfefa", "rfeda">;
4974 def : MnemonicAlias<"rfeea", "rfedb">;
4975 def : MnemonicAlias<"rfefd", "rfeia">;
4976 def : MnemonicAlias<"rfeed", "rfeib">;
4977 def : MnemonicAlias<"rfe", "rfeia">;
4980 def : MnemonicAlias<"srsfa", "srsda">;
4981 def : MnemonicAlias<"srsea", "srsdb">;
4982 def : MnemonicAlias<"srsfd", "srsia">;
4983 def : MnemonicAlias<"srsed", "srsib">;
4984 def : MnemonicAlias<"srs", "srsia">;
4987 def : MnemonicAlias<"qsubaddx", "qsax">;
4989 def : MnemonicAlias<"saddsubx", "sasx">;
4990 // SHASX == SHADDSUBX
4991 def : MnemonicAlias<"shaddsubx", "shasx">;
4992 // SHSAX == SHSUBADDX
4993 def : MnemonicAlias<"shsubaddx", "shsax">;
4995 def : MnemonicAlias<"ssubaddx", "ssax">;
4997 def : MnemonicAlias<"uaddsubx", "uasx">;
4998 // UHASX == UHADDSUBX
4999 def : MnemonicAlias<"uhaddsubx", "uhasx">;
5000 // UHSAX == UHSUBADDX
5001 def : MnemonicAlias<"uhsubaddx", "uhsax">;
5002 // UQASX == UQADDSUBX
5003 def : MnemonicAlias<"uqaddsubx", "uqasx">;
5004 // UQSAX == UQSUBADDX
5005 def : MnemonicAlias<"uqsubaddx", "uqsax">;
5007 def : MnemonicAlias<"usubaddx", "usax">;
5009 // "mov Rd, so_imm_not" can be handled via "mvn" in assembly, just like
5011 def : ARMInstAlias<"mov${s}${p} $Rd, $imm",
5012 (MVNi rGPR:$Rd, so_imm_not:$imm, pred:$p, cc_out:$s)>;
5014 // The shifter forms of the MOV instruction are aliased to the ASR, LSL,
5015 // LSR, ROR, and RRX instructions.
5016 // FIXME: We need C++ parser hooks to map the alias to the MOV
5017 // encoding. It seems we should be able to do that sort of thing
5018 // in tblgen, but it could get ugly.
5019 def ASRi : ARMAsmPseudo<"asr${s}${p} $Rd, $Rm, $imm",
5020 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
5022 def LSRi : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rm, $imm",
5023 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
5025 def LSLi : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rm, $imm",
5026 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
5028 def RORi : ARMAsmPseudo<"ror${s}${p} $Rd, $Rm, $imm",
5029 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
5031 def RRXi : ARMAsmPseudo<"rrx${s}${p} $Rd, $Rm",
5032 (ins GPRnopc:$Rd, GPRnopc:$Rm, pred:$p, cc_out:$s)>;
5033 def ASRr : ARMAsmPseudo<"asr${s}${p} $Rd, $Rn, $Rm",
5034 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5036 def LSRr : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rn, $Rm",
5037 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5039 def LSLr : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rn, $Rm",
5040 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5042 def RORr : ARMAsmPseudo<"ror${s}${p} $Rd, $Rn, $Rm",
5043 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5045 // shifter instructions also support a two-operand form.
5046 def : ARMInstAlias<"asr${s}${p} $Rm, $imm",
5047 (ASRi GPR:$Rm, GPR:$Rm, imm0_32:$imm, pred:$p, cc_out:$s)>;
5048 def : ARMInstAlias<"lsr${s}${p} $Rm, $imm",
5049 (LSRi GPR:$Rm, GPR:$Rm, imm0_32:$imm, pred:$p, cc_out:$s)>;
5050 def : ARMInstAlias<"lsl${s}${p} $Rm, $imm",
5051 (LSLi GPR:$Rm, GPR:$Rm, imm0_31:$imm, pred:$p, cc_out:$s)>;
5052 def : ARMInstAlias<"ror${s}${p} $Rm, $imm",
5053 (RORi GPR:$Rm, GPR:$Rm, imm0_31:$imm, pred:$p, cc_out:$s)>;
5054 def : ARMInstAlias<"asr${s}${p} $Rn, $Rm",
5055 (ASRr GPRnopc:$Rn, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5057 def : ARMInstAlias<"lsr${s}${p} $Rn, $Rm",
5058 (LSRr GPRnopc:$Rn, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5060 def : ARMInstAlias<"lsl${s}${p} $Rn, $Rm",
5061 (LSLr GPRnopc:$Rn, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5063 def : ARMInstAlias<"ror${s}${p} $Rn, $Rm",
5064 (RORr GPRnopc:$Rn, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5068 // 'mul' instruction can be specified with only two operands.
5069 def : ARMInstAlias<"mul${s}${p} $Rn, $Rm",
5070 (MUL rGPR:$Rn, rGPR:$Rm, rGPR:$Rn, pred:$p, cc_out:$s)>;