1 //===- ARMInstrInfo.td - Target Description for ARM Target -*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the ARM instructions in TableGen format.
12 //===----------------------------------------------------------------------===//
14 //===----------------------------------------------------------------------===//
15 // ARM specific DAG Nodes.
19 def SDT_ARMCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
20 def SDT_ARMCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>, SDTCisVT<1, i32> ]>;
22 def SDT_ARMSaveCallPC : SDTypeProfile<0, 1, []>;
24 def SDT_ARMcall : SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>;
26 def SDT_ARMCMov : SDTypeProfile<1, 3,
27 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
30 def SDT_ARMBrcond : SDTypeProfile<0, 2,
31 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i32>]>;
33 def SDT_ARMBrJT : SDTypeProfile<0, 3,
34 [SDTCisPtrTy<0>, SDTCisVT<1, i32>,
37 def SDT_ARMBr2JT : SDTypeProfile<0, 4,
38 [SDTCisPtrTy<0>, SDTCisVT<1, i32>,
39 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
41 def SDT_ARMBCC_i64 : SDTypeProfile<0, 6,
43 SDTCisVT<1, i32>, SDTCisVT<2, i32>,
44 SDTCisVT<3, i32>, SDTCisVT<4, i32>,
45 SDTCisVT<5, OtherVT>]>;
47 def SDT_ARMAnd : SDTypeProfile<1, 2,
48 [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
51 def SDT_ARMCmp : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
53 def SDT_ARMPICAdd : SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>,
54 SDTCisPtrTy<1>, SDTCisVT<2, i32>]>;
56 def SDT_ARMThreadPointer : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
57 def SDT_ARMEH_SJLJ_Setjmp : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisPtrTy<1>,
59 def SDT_ARMEH_SJLJ_Longjmp: SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
61 def SDT_ARMMEMBARRIER : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
63 def SDT_ARMPREFETCH : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisSameAs<1, 2>,
66 def SDT_ARMTCRET : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
68 def SDT_ARMBFI : SDTypeProfile<1, 3, [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
69 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
71 def SDTBinaryArithWithFlags : SDTypeProfile<2, 2,
74 SDTCisInt<0>, SDTCisVT<1, i32>]>;
76 // SDTBinaryArithWithFlagsInOut - RES1, CPSR = op LHS, RHS, CPSR
77 def SDTBinaryArithWithFlagsInOut : SDTypeProfile<2, 3,
84 def ARMWrapper : SDNode<"ARMISD::Wrapper", SDTIntUnaryOp>;
85 def ARMWrapperDYN : SDNode<"ARMISD::WrapperDYN", SDTIntUnaryOp>;
86 def ARMWrapperPIC : SDNode<"ARMISD::WrapperPIC", SDTIntUnaryOp>;
87 def ARMWrapperJT : SDNode<"ARMISD::WrapperJT", SDTIntBinOp>;
89 def ARMcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_ARMCallSeqStart,
90 [SDNPHasChain, SDNPOutGlue]>;
91 def ARMcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_ARMCallSeqEnd,
92 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
94 def ARMcall : SDNode<"ARMISD::CALL", SDT_ARMcall,
95 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
97 def ARMcall_pred : SDNode<"ARMISD::CALL_PRED", SDT_ARMcall,
98 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
100 def ARMcall_nolink : SDNode<"ARMISD::CALL_NOLINK", SDT_ARMcall,
101 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
104 def ARMretflag : SDNode<"ARMISD::RET_FLAG", SDTNone,
105 [SDNPHasChain, SDNPOptInGlue]>;
107 def ARMcmov : SDNode<"ARMISD::CMOV", SDT_ARMCMov,
110 def ARMbrcond : SDNode<"ARMISD::BRCOND", SDT_ARMBrcond,
111 [SDNPHasChain, SDNPInGlue, SDNPOutGlue]>;
113 def ARMbrjt : SDNode<"ARMISD::BR_JT", SDT_ARMBrJT,
115 def ARMbr2jt : SDNode<"ARMISD::BR2_JT", SDT_ARMBr2JT,
118 def ARMBcci64 : SDNode<"ARMISD::BCC_i64", SDT_ARMBCC_i64,
121 def ARMcmp : SDNode<"ARMISD::CMP", SDT_ARMCmp,
124 def ARMcmpZ : SDNode<"ARMISD::CMPZ", SDT_ARMCmp,
125 [SDNPOutGlue, SDNPCommutative]>;
127 def ARMpic_add : SDNode<"ARMISD::PIC_ADD", SDT_ARMPICAdd>;
129 def ARMsrl_flag : SDNode<"ARMISD::SRL_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
130 def ARMsra_flag : SDNode<"ARMISD::SRA_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
131 def ARMrrx : SDNode<"ARMISD::RRX" , SDTIntUnaryOp, [SDNPInGlue ]>;
133 def ARMaddc : SDNode<"ARMISD::ADDC", SDTBinaryArithWithFlags,
135 def ARMsubc : SDNode<"ARMISD::SUBC", SDTBinaryArithWithFlags>;
136 def ARMadde : SDNode<"ARMISD::ADDE", SDTBinaryArithWithFlagsInOut>;
137 def ARMsube : SDNode<"ARMISD::SUBE", SDTBinaryArithWithFlagsInOut>;
139 def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>;
140 def ARMeh_sjlj_setjmp: SDNode<"ARMISD::EH_SJLJ_SETJMP",
141 SDT_ARMEH_SJLJ_Setjmp, [SDNPHasChain]>;
142 def ARMeh_sjlj_longjmp: SDNode<"ARMISD::EH_SJLJ_LONGJMP",
143 SDT_ARMEH_SJLJ_Longjmp, [SDNPHasChain]>;
145 def ARMMemBarrier : SDNode<"ARMISD::MEMBARRIER", SDT_ARMMEMBARRIER,
147 def ARMMemBarrierMCR : SDNode<"ARMISD::MEMBARRIER_MCR", SDT_ARMMEMBARRIER,
149 def ARMPreload : SDNode<"ARMISD::PRELOAD", SDT_ARMPREFETCH,
150 [SDNPHasChain, SDNPMayLoad, SDNPMayStore]>;
152 def ARMrbit : SDNode<"ARMISD::RBIT", SDTIntUnaryOp>;
154 def ARMtcret : SDNode<"ARMISD::TC_RETURN", SDT_ARMTCRET,
155 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
158 def ARMbfi : SDNode<"ARMISD::BFI", SDT_ARMBFI>;
160 //===----------------------------------------------------------------------===//
161 // ARM Instruction Predicate Definitions.
163 def HasV4T : Predicate<"Subtarget->hasV4TOps()">,
164 AssemblerPredicate<"HasV4TOps">;
165 def NoV4T : Predicate<"!Subtarget->hasV4TOps()">;
166 def HasV5T : Predicate<"Subtarget->hasV5TOps()">;
167 def HasV5TE : Predicate<"Subtarget->hasV5TEOps()">,
168 AssemblerPredicate<"HasV5TEOps">;
169 def HasV6 : Predicate<"Subtarget->hasV6Ops()">,
170 AssemblerPredicate<"HasV6Ops">;
171 def NoV6 : Predicate<"!Subtarget->hasV6Ops()">;
172 def HasV6T2 : Predicate<"Subtarget->hasV6T2Ops()">,
173 AssemblerPredicate<"HasV6T2Ops">;
174 def NoV6T2 : Predicate<"!Subtarget->hasV6T2Ops()">;
175 def HasV7 : Predicate<"Subtarget->hasV7Ops()">,
176 AssemblerPredicate<"HasV7Ops">;
177 def NoVFP : Predicate<"!Subtarget->hasVFP2()">;
178 def HasVFP2 : Predicate<"Subtarget->hasVFP2()">,
179 AssemblerPredicate<"FeatureVFP2">;
180 def HasVFP3 : Predicate<"Subtarget->hasVFP3()">,
181 AssemblerPredicate<"FeatureVFP3">;
182 def HasVFP4 : Predicate<"Subtarget->hasVFP4()">,
183 AssemblerPredicate<"FeatureVFP4">;
184 def HasNEON : Predicate<"Subtarget->hasNEON()">,
185 AssemblerPredicate<"FeatureNEON">;
186 def HasFP16 : Predicate<"Subtarget->hasFP16()">,
187 AssemblerPredicate<"FeatureFP16">;
188 def HasDivide : Predicate<"Subtarget->hasDivide()">,
189 AssemblerPredicate<"FeatureHWDiv">;
190 def HasT2ExtractPack : Predicate<"Subtarget->hasT2ExtractPack()">,
191 AssemblerPredicate<"FeatureT2XtPk">;
192 def HasThumb2DSP : Predicate<"Subtarget->hasThumb2DSP()">,
193 AssemblerPredicate<"FeatureDSPThumb2">;
194 def HasDB : Predicate<"Subtarget->hasDataBarrier()">,
195 AssemblerPredicate<"FeatureDB">;
196 def HasMP : Predicate<"Subtarget->hasMPExtension()">,
197 AssemblerPredicate<"FeatureMP">;
198 def UseNEONForFP : Predicate<"Subtarget->useNEONForSinglePrecisionFP()">;
199 def DontUseNEONForFP : Predicate<"!Subtarget->useNEONForSinglePrecisionFP()">;
200 def IsThumb : Predicate<"Subtarget->isThumb()">,
201 AssemblerPredicate<"ModeThumb">;
202 def IsThumb1Only : Predicate<"Subtarget->isThumb1Only()">;
203 def IsThumb2 : Predicate<"Subtarget->isThumb2()">,
204 AssemblerPredicate<"ModeThumb,FeatureThumb2">;
205 def IsMClass : Predicate<"Subtarget->isMClass()">,
206 AssemblerPredicate<"FeatureMClass">;
207 def IsARClass : Predicate<"!Subtarget->isMClass()">,
208 AssemblerPredicate<"!FeatureMClass">;
209 def IsARM : Predicate<"!Subtarget->isThumb()">,
210 AssemblerPredicate<"!ModeThumb">;
211 def IsIOS : Predicate<"Subtarget->isTargetIOS()">;
212 def IsNotIOS : Predicate<"!Subtarget->isTargetIOS()">;
213 def IsNaCl : Predicate<"Subtarget->isTargetNaCl()">;
215 // FIXME: Eventually this will be just "hasV6T2Ops".
216 def UseMovt : Predicate<"Subtarget->useMovt()">;
217 def DontUseMovt : Predicate<"!Subtarget->useMovt()">;
218 def UseFPVMLx : Predicate<"Subtarget->useFPVMLx()">;
220 // Prefer fused MAC for fp mul + add over fp VMLA / VMLS if they are available.
221 // But only select them if more precision in FP computation is allowed.
222 // Do not use them for Darwin platforms.
223 def UseFusedMAC : Predicate<"!TM.Options.NoExcessFPPrecision && "
224 "!Subtarget->isTargetDarwin()">;
225 def DontUseFusedMAC : Predicate<"!Subtarget->hasVFP4() || "
226 "Subtarget->isTargetDarwin()">;
228 //===----------------------------------------------------------------------===//
229 // ARM Flag Definitions.
231 class RegConstraint<string C> {
232 string Constraints = C;
235 //===----------------------------------------------------------------------===//
236 // ARM specific transformation functions and pattern fragments.
239 // so_imm_neg_XFORM - Return a so_imm value packed into the format described for
240 // so_imm_neg def below.
241 def so_imm_neg_XFORM : SDNodeXForm<imm, [{
242 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), MVT::i32);
245 // so_imm_not_XFORM - Return a so_imm value packed into the format described for
246 // so_imm_not def below.
247 def so_imm_not_XFORM : SDNodeXForm<imm, [{
248 return CurDAG->getTargetConstant(~(int)N->getZExtValue(), MVT::i32);
251 /// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
252 def imm16_31 : ImmLeaf<i32, [{
253 return (int32_t)Imm >= 16 && (int32_t)Imm < 32;
256 def so_imm_neg_asmoperand : AsmOperandClass { let Name = "ARMSOImmNeg"; }
257 def so_imm_neg : Operand<i32>, PatLeaf<(imm), [{
258 int64_t Value = -(int)N->getZExtValue();
259 return Value && ARM_AM::getSOImmVal(Value) != -1;
260 }], so_imm_neg_XFORM> {
261 let ParserMatchClass = so_imm_neg_asmoperand;
264 // Note: this pattern doesn't require an encoder method and such, as it's
265 // only used on aliases (Pat<> and InstAlias<>). The actual encoding
266 // is handled by the destination instructions, which use so_imm.
267 def so_imm_not_asmoperand : AsmOperandClass { let Name = "ARMSOImmNot"; }
268 def so_imm_not : Operand<i32>, PatLeaf<(imm), [{
269 return ARM_AM::getSOImmVal(~(uint32_t)N->getZExtValue()) != -1;
270 }], so_imm_not_XFORM> {
271 let ParserMatchClass = so_imm_not_asmoperand;
274 // sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
275 def sext_16_node : PatLeaf<(i32 GPR:$a), [{
276 return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17;
279 /// Split a 32-bit immediate into two 16 bit parts.
280 def hi16 : SDNodeXForm<imm, [{
281 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, MVT::i32);
284 def lo16AllZero : PatLeaf<(i32 imm), [{
285 // Returns true if all low 16-bits are 0.
286 return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
289 class BinOpWithFlagFrag<dag res> :
290 PatFrag<(ops node:$LHS, node:$RHS, node:$FLAG), res>;
291 class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
292 class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
294 // An 'and' node with a single use.
295 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
296 return N->hasOneUse();
299 // An 'xor' node with a single use.
300 def xor_su : PatFrag<(ops node:$lhs, node:$rhs), (xor node:$lhs, node:$rhs), [{
301 return N->hasOneUse();
304 // An 'fmul' node with a single use.
305 def fmul_su : PatFrag<(ops node:$lhs, node:$rhs), (fmul node:$lhs, node:$rhs),[{
306 return N->hasOneUse();
309 // An 'fadd' node which checks for single non-hazardous use.
310 def fadd_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fadd node:$lhs, node:$rhs),[{
311 return hasNoVMLxHazardUse(N);
314 // An 'fsub' node which checks for single non-hazardous use.
315 def fsub_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fsub node:$lhs, node:$rhs),[{
316 return hasNoVMLxHazardUse(N);
319 //===----------------------------------------------------------------------===//
320 // Operand Definitions.
323 // Immediate operands with a shared generic asm render method.
324 class ImmAsmOperand : AsmOperandClass { let RenderMethod = "addImmOperands"; }
327 // FIXME: rename brtarget to t2_brtarget
328 def brtarget : Operand<OtherVT> {
329 let EncoderMethod = "getBranchTargetOpValue";
330 let OperandType = "OPERAND_PCREL";
331 let DecoderMethod = "DecodeT2BROperand";
334 // FIXME: get rid of this one?
335 def uncondbrtarget : Operand<OtherVT> {
336 let EncoderMethod = "getUnconditionalBranchTargetOpValue";
337 let OperandType = "OPERAND_PCREL";
340 // Branch target for ARM. Handles conditional/unconditional
341 def br_target : Operand<OtherVT> {
342 let EncoderMethod = "getARMBranchTargetOpValue";
343 let OperandType = "OPERAND_PCREL";
347 // FIXME: rename bltarget to t2_bl_target?
348 def bltarget : Operand<i32> {
349 // Encoded the same as branch targets.
350 let EncoderMethod = "getBranchTargetOpValue";
351 let OperandType = "OPERAND_PCREL";
354 // Call target for ARM. Handles conditional/unconditional
355 // FIXME: rename bl_target to t2_bltarget?
356 def bl_target : Operand<i32> {
357 let EncoderMethod = "getARMBLTargetOpValue";
358 let OperandType = "OPERAND_PCREL";
361 def blx_target : Operand<i32> {
362 let EncoderMethod = "getARMBLXTargetOpValue";
363 let OperandType = "OPERAND_PCREL";
366 // A list of registers separated by comma. Used by load/store multiple.
367 def RegListAsmOperand : AsmOperandClass { let Name = "RegList"; }
368 def reglist : Operand<i32> {
369 let EncoderMethod = "getRegisterListOpValue";
370 let ParserMatchClass = RegListAsmOperand;
371 let PrintMethod = "printRegisterList";
372 let DecoderMethod = "DecodeRegListOperand";
375 def DPRRegListAsmOperand : AsmOperandClass { let Name = "DPRRegList"; }
376 def dpr_reglist : Operand<i32> {
377 let EncoderMethod = "getRegisterListOpValue";
378 let ParserMatchClass = DPRRegListAsmOperand;
379 let PrintMethod = "printRegisterList";
380 let DecoderMethod = "DecodeDPRRegListOperand";
383 def SPRRegListAsmOperand : AsmOperandClass { let Name = "SPRRegList"; }
384 def spr_reglist : Operand<i32> {
385 let EncoderMethod = "getRegisterListOpValue";
386 let ParserMatchClass = SPRRegListAsmOperand;
387 let PrintMethod = "printRegisterList";
388 let DecoderMethod = "DecodeSPRRegListOperand";
391 // An operand for the CONSTPOOL_ENTRY pseudo-instruction.
392 def cpinst_operand : Operand<i32> {
393 let PrintMethod = "printCPInstOperand";
397 def pclabel : Operand<i32> {
398 let PrintMethod = "printPCLabel";
401 // ADR instruction labels.
402 def adrlabel : Operand<i32> {
403 let EncoderMethod = "getAdrLabelOpValue";
406 def neon_vcvt_imm32 : Operand<i32> {
407 let EncoderMethod = "getNEONVcvtImm32OpValue";
408 let DecoderMethod = "DecodeVCVTImmOperand";
411 // rot_imm: An integer that encodes a rotate amount. Must be 8, 16, or 24.
412 def rot_imm_XFORM: SDNodeXForm<imm, [{
413 switch (N->getZExtValue()){
415 case 0: return CurDAG->getTargetConstant(0, MVT::i32);
416 case 8: return CurDAG->getTargetConstant(1, MVT::i32);
417 case 16: return CurDAG->getTargetConstant(2, MVT::i32);
418 case 24: return CurDAG->getTargetConstant(3, MVT::i32);
421 def RotImmAsmOperand : AsmOperandClass {
423 let ParserMethod = "parseRotImm";
425 def rot_imm : Operand<i32>, PatLeaf<(i32 imm), [{
426 int32_t v = N->getZExtValue();
427 return v == 8 || v == 16 || v == 24; }],
429 let PrintMethod = "printRotImmOperand";
430 let ParserMatchClass = RotImmAsmOperand;
433 // shift_imm: An integer that encodes a shift amount and the type of shift
434 // (asr or lsl). The 6-bit immediate encodes as:
437 // {4-0} imm5 shift amount.
438 // asr #32 encoded as imm5 == 0.
439 def ShifterImmAsmOperand : AsmOperandClass {
440 let Name = "ShifterImm";
441 let ParserMethod = "parseShifterImm";
443 def shift_imm : Operand<i32> {
444 let PrintMethod = "printShiftImmOperand";
445 let ParserMatchClass = ShifterImmAsmOperand;
448 // shifter_operand operands: so_reg_reg, so_reg_imm, and so_imm.
449 def ShiftedRegAsmOperand : AsmOperandClass { let Name = "RegShiftedReg"; }
450 def so_reg_reg : Operand<i32>, // reg reg imm
451 ComplexPattern<i32, 3, "SelectRegShifterOperand",
452 [shl, srl, sra, rotr]> {
453 let EncoderMethod = "getSORegRegOpValue";
454 let PrintMethod = "printSORegRegOperand";
455 let DecoderMethod = "DecodeSORegRegOperand";
456 let ParserMatchClass = ShiftedRegAsmOperand;
457 let MIOperandInfo = (ops GPRnopc, GPRnopc, i32imm);
460 def ShiftedImmAsmOperand : AsmOperandClass { let Name = "RegShiftedImm"; }
461 def so_reg_imm : Operand<i32>, // reg imm
462 ComplexPattern<i32, 2, "SelectImmShifterOperand",
463 [shl, srl, sra, rotr]> {
464 let EncoderMethod = "getSORegImmOpValue";
465 let PrintMethod = "printSORegImmOperand";
466 let DecoderMethod = "DecodeSORegImmOperand";
467 let ParserMatchClass = ShiftedImmAsmOperand;
468 let MIOperandInfo = (ops GPR, i32imm);
471 // FIXME: Does this need to be distinct from so_reg?
472 def shift_so_reg_reg : Operand<i32>, // reg reg imm
473 ComplexPattern<i32, 3, "SelectShiftRegShifterOperand",
474 [shl,srl,sra,rotr]> {
475 let EncoderMethod = "getSORegRegOpValue";
476 let PrintMethod = "printSORegRegOperand";
477 let DecoderMethod = "DecodeSORegRegOperand";
478 let ParserMatchClass = ShiftedRegAsmOperand;
479 let MIOperandInfo = (ops GPR, GPR, i32imm);
482 // FIXME: Does this need to be distinct from so_reg?
483 def shift_so_reg_imm : Operand<i32>, // reg reg imm
484 ComplexPattern<i32, 2, "SelectShiftImmShifterOperand",
485 [shl,srl,sra,rotr]> {
486 let EncoderMethod = "getSORegImmOpValue";
487 let PrintMethod = "printSORegImmOperand";
488 let DecoderMethod = "DecodeSORegImmOperand";
489 let ParserMatchClass = ShiftedImmAsmOperand;
490 let MIOperandInfo = (ops GPR, i32imm);
494 // so_imm - Match a 32-bit shifter_operand immediate operand, which is an
495 // 8-bit immediate rotated by an arbitrary number of bits.
496 def SOImmAsmOperand: ImmAsmOperand { let Name = "ARMSOImm"; }
497 def so_imm : Operand<i32>, ImmLeaf<i32, [{
498 return ARM_AM::getSOImmVal(Imm) != -1;
500 let EncoderMethod = "getSOImmOpValue";
501 let ParserMatchClass = SOImmAsmOperand;
502 let DecoderMethod = "DecodeSOImmOperand";
505 // Break so_imm's up into two pieces. This handles immediates with up to 16
506 // bits set in them. This uses so_imm2part to match and so_imm2part_[12] to
507 // get the first/second pieces.
508 def so_imm2part : PatLeaf<(imm), [{
509 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
512 /// arm_i32imm - True for +V6T2, or true only if so_imm2part is true.
514 def arm_i32imm : PatLeaf<(imm), [{
515 if (Subtarget->hasV6T2Ops())
517 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
520 /// imm0_1 predicate - Immediate in the range [0,1].
521 def Imm0_1AsmOperand: ImmAsmOperand { let Name = "Imm0_1"; }
522 def imm0_1 : Operand<i32> { let ParserMatchClass = Imm0_1AsmOperand; }
524 /// imm0_3 predicate - Immediate in the range [0,3].
525 def Imm0_3AsmOperand: ImmAsmOperand { let Name = "Imm0_3"; }
526 def imm0_3 : Operand<i32> { let ParserMatchClass = Imm0_3AsmOperand; }
528 /// imm0_7 predicate - Immediate in the range [0,7].
529 def Imm0_7AsmOperand: ImmAsmOperand { let Name = "Imm0_7"; }
530 def imm0_7 : Operand<i32>, ImmLeaf<i32, [{
531 return Imm >= 0 && Imm < 8;
533 let ParserMatchClass = Imm0_7AsmOperand;
536 /// imm8 predicate - Immediate is exactly 8.
537 def Imm8AsmOperand: ImmAsmOperand { let Name = "Imm8"; }
538 def imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 8; }]> {
539 let ParserMatchClass = Imm8AsmOperand;
542 /// imm16 predicate - Immediate is exactly 16.
543 def Imm16AsmOperand: ImmAsmOperand { let Name = "Imm16"; }
544 def imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 16; }]> {
545 let ParserMatchClass = Imm16AsmOperand;
548 /// imm32 predicate - Immediate is exactly 32.
549 def Imm32AsmOperand: ImmAsmOperand { let Name = "Imm32"; }
550 def imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 32; }]> {
551 let ParserMatchClass = Imm32AsmOperand;
554 /// imm1_7 predicate - Immediate in the range [1,7].
555 def Imm1_7AsmOperand: ImmAsmOperand { let Name = "Imm1_7"; }
556 def imm1_7 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 8; }]> {
557 let ParserMatchClass = Imm1_7AsmOperand;
560 /// imm1_15 predicate - Immediate in the range [1,15].
561 def Imm1_15AsmOperand: ImmAsmOperand { let Name = "Imm1_15"; }
562 def imm1_15 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 16; }]> {
563 let ParserMatchClass = Imm1_15AsmOperand;
566 /// imm1_31 predicate - Immediate in the range [1,31].
567 def Imm1_31AsmOperand: ImmAsmOperand { let Name = "Imm1_31"; }
568 def imm1_31 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 32; }]> {
569 let ParserMatchClass = Imm1_31AsmOperand;
572 /// imm0_15 predicate - Immediate in the range [0,15].
573 def Imm0_15AsmOperand: ImmAsmOperand { let Name = "Imm0_15"; }
574 def imm0_15 : Operand<i32>, ImmLeaf<i32, [{
575 return Imm >= 0 && Imm < 16;
577 let ParserMatchClass = Imm0_15AsmOperand;
580 /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
581 def Imm0_31AsmOperand: ImmAsmOperand { let Name = "Imm0_31"; }
582 def imm0_31 : Operand<i32>, ImmLeaf<i32, [{
583 return Imm >= 0 && Imm < 32;
585 let ParserMatchClass = Imm0_31AsmOperand;
588 /// imm0_32 predicate - True if the 32-bit immediate is in the range [0,32].
589 def Imm0_32AsmOperand: ImmAsmOperand { let Name = "Imm0_32"; }
590 def imm0_32 : Operand<i32>, ImmLeaf<i32, [{
591 return Imm >= 0 && Imm < 32;
593 let ParserMatchClass = Imm0_32AsmOperand;
596 /// imm0_63 predicate - True if the 32-bit immediate is in the range [0,63].
597 def Imm0_63AsmOperand: ImmAsmOperand { let Name = "Imm0_63"; }
598 def imm0_63 : Operand<i32>, ImmLeaf<i32, [{
599 return Imm >= 0 && Imm < 64;
601 let ParserMatchClass = Imm0_63AsmOperand;
604 /// imm0_255 predicate - Immediate in the range [0,255].
605 def Imm0_255AsmOperand : ImmAsmOperand { let Name = "Imm0_255"; }
606 def imm0_255 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 256; }]> {
607 let ParserMatchClass = Imm0_255AsmOperand;
610 /// imm0_65535 - An immediate is in the range [0.65535].
611 def Imm0_65535AsmOperand: ImmAsmOperand { let Name = "Imm0_65535"; }
612 def imm0_65535 : Operand<i32>, ImmLeaf<i32, [{
613 return Imm >= 0 && Imm < 65536;
615 let ParserMatchClass = Imm0_65535AsmOperand;
618 // imm0_65535_expr - For movt/movw - 16-bit immediate that can also reference
619 // a relocatable expression.
621 // FIXME: This really needs a Thumb version separate from the ARM version.
622 // While the range is the same, and can thus use the same match class,
623 // the encoding is different so it should have a different encoder method.
624 def Imm0_65535ExprAsmOperand: ImmAsmOperand { let Name = "Imm0_65535Expr"; }
625 def imm0_65535_expr : Operand<i32> {
626 let EncoderMethod = "getHiLo16ImmOpValue";
627 let ParserMatchClass = Imm0_65535ExprAsmOperand;
630 /// imm24b - True if the 32-bit immediate is encodable in 24 bits.
631 def Imm24bitAsmOperand: ImmAsmOperand { let Name = "Imm24bit"; }
632 def imm24b : Operand<i32>, ImmLeaf<i32, [{
633 return Imm >= 0 && Imm <= 0xffffff;
635 let ParserMatchClass = Imm24bitAsmOperand;
639 /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
641 def BitfieldAsmOperand : AsmOperandClass {
642 let Name = "Bitfield";
643 let ParserMethod = "parseBitfield";
646 def bf_inv_mask_imm : Operand<i32>,
648 return ARM::isBitFieldInvertedMask(N->getZExtValue());
650 let EncoderMethod = "getBitfieldInvertedMaskOpValue";
651 let PrintMethod = "printBitfieldInvMaskImmOperand";
652 let DecoderMethod = "DecodeBitfieldMaskOperand";
653 let ParserMatchClass = BitfieldAsmOperand;
656 def imm1_32_XFORM: SDNodeXForm<imm, [{
657 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, MVT::i32);
659 def Imm1_32AsmOperand: AsmOperandClass { let Name = "Imm1_32"; }
660 def imm1_32 : Operand<i32>, PatLeaf<(imm), [{
661 uint64_t Imm = N->getZExtValue();
662 return Imm > 0 && Imm <= 32;
665 let PrintMethod = "printImmPlusOneOperand";
666 let ParserMatchClass = Imm1_32AsmOperand;
669 def imm1_16_XFORM: SDNodeXForm<imm, [{
670 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, MVT::i32);
672 def Imm1_16AsmOperand: AsmOperandClass { let Name = "Imm1_16"; }
673 def imm1_16 : Operand<i32>, PatLeaf<(imm), [{ return Imm > 0 && Imm <= 16; }],
675 let PrintMethod = "printImmPlusOneOperand";
676 let ParserMatchClass = Imm1_16AsmOperand;
679 // Define ARM specific addressing modes.
680 // addrmode_imm12 := reg +/- imm12
682 def MemImm12OffsetAsmOperand : AsmOperandClass { let Name = "MemImm12Offset"; }
683 def addrmode_imm12 : Operand<i32>,
684 ComplexPattern<i32, 2, "SelectAddrModeImm12", []> {
685 // 12-bit immediate operand. Note that instructions using this encode
686 // #0 and #-0 differently. We flag #-0 as the magic value INT32_MIN. All other
687 // immediate values are as normal.
689 let EncoderMethod = "getAddrModeImm12OpValue";
690 let PrintMethod = "printAddrModeImm12Operand";
691 let DecoderMethod = "DecodeAddrModeImm12Operand";
692 let ParserMatchClass = MemImm12OffsetAsmOperand;
693 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
695 // ldst_so_reg := reg +/- reg shop imm
697 def MemRegOffsetAsmOperand : AsmOperandClass { let Name = "MemRegOffset"; }
698 def ldst_so_reg : Operand<i32>,
699 ComplexPattern<i32, 3, "SelectLdStSOReg", []> {
700 let EncoderMethod = "getLdStSORegOpValue";
701 // FIXME: Simplify the printer
702 let PrintMethod = "printAddrMode2Operand";
703 let DecoderMethod = "DecodeSORegMemOperand";
704 let ParserMatchClass = MemRegOffsetAsmOperand;
705 let MIOperandInfo = (ops GPR:$base, GPRnopc:$offsreg, i32imm:$shift);
708 // postidx_imm8 := +/- [0,255]
711 // {8} 1 is imm8 is non-negative. 0 otherwise.
712 // {7-0} [0,255] imm8 value.
713 def PostIdxImm8AsmOperand : AsmOperandClass { let Name = "PostIdxImm8"; }
714 def postidx_imm8 : Operand<i32> {
715 let PrintMethod = "printPostIdxImm8Operand";
716 let ParserMatchClass = PostIdxImm8AsmOperand;
717 let MIOperandInfo = (ops i32imm);
720 // postidx_imm8s4 := +/- [0,1020]
723 // {8} 1 is imm8 is non-negative. 0 otherwise.
724 // {7-0} [0,255] imm8 value, scaled by 4.
725 def PostIdxImm8s4AsmOperand : AsmOperandClass { let Name = "PostIdxImm8s4"; }
726 def postidx_imm8s4 : Operand<i32> {
727 let PrintMethod = "printPostIdxImm8s4Operand";
728 let ParserMatchClass = PostIdxImm8s4AsmOperand;
729 let MIOperandInfo = (ops i32imm);
733 // postidx_reg := +/- reg
735 def PostIdxRegAsmOperand : AsmOperandClass {
736 let Name = "PostIdxReg";
737 let ParserMethod = "parsePostIdxReg";
739 def postidx_reg : Operand<i32> {
740 let EncoderMethod = "getPostIdxRegOpValue";
741 let DecoderMethod = "DecodePostIdxReg";
742 let PrintMethod = "printPostIdxRegOperand";
743 let ParserMatchClass = PostIdxRegAsmOperand;
744 let MIOperandInfo = (ops GPRnopc, i32imm);
748 // addrmode2 := reg +/- imm12
749 // := reg +/- reg shop imm
751 // FIXME: addrmode2 should be refactored the rest of the way to always
752 // use explicit imm vs. reg versions above (addrmode_imm12 and ldst_so_reg).
753 def AddrMode2AsmOperand : AsmOperandClass { let Name = "AddrMode2"; }
754 def addrmode2 : Operand<i32>,
755 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
756 let EncoderMethod = "getAddrMode2OpValue";
757 let PrintMethod = "printAddrMode2Operand";
758 let ParserMatchClass = AddrMode2AsmOperand;
759 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
762 def PostIdxRegShiftedAsmOperand : AsmOperandClass {
763 let Name = "PostIdxRegShifted";
764 let ParserMethod = "parsePostIdxReg";
766 def am2offset_reg : Operand<i32>,
767 ComplexPattern<i32, 2, "SelectAddrMode2OffsetReg",
768 [], [SDNPWantRoot]> {
769 let EncoderMethod = "getAddrMode2OffsetOpValue";
770 let PrintMethod = "printAddrMode2OffsetOperand";
771 // When using this for assembly, it's always as a post-index offset.
772 let ParserMatchClass = PostIdxRegShiftedAsmOperand;
773 let MIOperandInfo = (ops GPRnopc, i32imm);
776 // FIXME: am2offset_imm should only need the immediate, not the GPR. Having
777 // the GPR is purely vestigal at this point.
778 def AM2OffsetImmAsmOperand : AsmOperandClass { let Name = "AM2OffsetImm"; }
779 def am2offset_imm : Operand<i32>,
780 ComplexPattern<i32, 2, "SelectAddrMode2OffsetImm",
781 [], [SDNPWantRoot]> {
782 let EncoderMethod = "getAddrMode2OffsetOpValue";
783 let PrintMethod = "printAddrMode2OffsetOperand";
784 let ParserMatchClass = AM2OffsetImmAsmOperand;
785 let MIOperandInfo = (ops GPRnopc, i32imm);
789 // addrmode3 := reg +/- reg
790 // addrmode3 := reg +/- imm8
792 // FIXME: split into imm vs. reg versions.
793 def AddrMode3AsmOperand : AsmOperandClass { let Name = "AddrMode3"; }
794 def addrmode3 : Operand<i32>,
795 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
796 let EncoderMethod = "getAddrMode3OpValue";
797 let PrintMethod = "printAddrMode3Operand";
798 let ParserMatchClass = AddrMode3AsmOperand;
799 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
802 // FIXME: split into imm vs. reg versions.
803 // FIXME: parser method to handle +/- register.
804 def AM3OffsetAsmOperand : AsmOperandClass {
805 let Name = "AM3Offset";
806 let ParserMethod = "parseAM3Offset";
808 def am3offset : Operand<i32>,
809 ComplexPattern<i32, 2, "SelectAddrMode3Offset",
810 [], [SDNPWantRoot]> {
811 let EncoderMethod = "getAddrMode3OffsetOpValue";
812 let PrintMethod = "printAddrMode3OffsetOperand";
813 let ParserMatchClass = AM3OffsetAsmOperand;
814 let MIOperandInfo = (ops GPR, i32imm);
817 // ldstm_mode := {ia, ib, da, db}
819 def ldstm_mode : OptionalDefOperand<OtherVT, (ops i32), (ops (i32 1))> {
820 let EncoderMethod = "getLdStmModeOpValue";
821 let PrintMethod = "printLdStmModeOperand";
824 // addrmode5 := reg +/- imm8*4
826 def AddrMode5AsmOperand : AsmOperandClass { let Name = "AddrMode5"; }
827 def addrmode5 : Operand<i32>,
828 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
829 let PrintMethod = "printAddrMode5Operand";
830 let EncoderMethod = "getAddrMode5OpValue";
831 let DecoderMethod = "DecodeAddrMode5Operand";
832 let ParserMatchClass = AddrMode5AsmOperand;
833 let MIOperandInfo = (ops GPR:$base, i32imm);
836 // addrmode6 := reg with optional alignment
838 def AddrMode6AsmOperand : AsmOperandClass { let Name = "AlignedMemory"; }
839 def addrmode6 : Operand<i32>,
840 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
841 let PrintMethod = "printAddrMode6Operand";
842 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
843 let EncoderMethod = "getAddrMode6AddressOpValue";
844 let DecoderMethod = "DecodeAddrMode6Operand";
845 let ParserMatchClass = AddrMode6AsmOperand;
848 def am6offset : Operand<i32>,
849 ComplexPattern<i32, 1, "SelectAddrMode6Offset",
850 [], [SDNPWantRoot]> {
851 let PrintMethod = "printAddrMode6OffsetOperand";
852 let MIOperandInfo = (ops GPR);
853 let EncoderMethod = "getAddrMode6OffsetOpValue";
854 let DecoderMethod = "DecodeGPRRegisterClass";
857 // Special version of addrmode6 to handle alignment encoding for VST1/VLD1
858 // (single element from one lane) for size 32.
859 def addrmode6oneL32 : Operand<i32>,
860 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
861 let PrintMethod = "printAddrMode6Operand";
862 let MIOperandInfo = (ops GPR:$addr, i32imm);
863 let EncoderMethod = "getAddrMode6OneLane32AddressOpValue";
866 // Special version of addrmode6 to handle alignment encoding for VLD-dup
867 // instructions, specifically VLD4-dup.
868 def addrmode6dup : Operand<i32>,
869 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
870 let PrintMethod = "printAddrMode6Operand";
871 let MIOperandInfo = (ops GPR:$addr, i32imm);
872 let EncoderMethod = "getAddrMode6DupAddressOpValue";
873 // FIXME: This is close, but not quite right. The alignment specifier is
875 let ParserMatchClass = AddrMode6AsmOperand;
878 // addrmodepc := pc + reg
880 def addrmodepc : Operand<i32>,
881 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
882 let PrintMethod = "printAddrModePCOperand";
883 let MIOperandInfo = (ops GPR, i32imm);
886 // addr_offset_none := reg
888 def MemNoOffsetAsmOperand : AsmOperandClass { let Name = "MemNoOffset"; }
889 def addr_offset_none : Operand<i32>,
890 ComplexPattern<i32, 1, "SelectAddrOffsetNone", []> {
891 let PrintMethod = "printAddrMode7Operand";
892 let DecoderMethod = "DecodeAddrMode7Operand";
893 let ParserMatchClass = MemNoOffsetAsmOperand;
894 let MIOperandInfo = (ops GPR:$base);
897 def nohash_imm : Operand<i32> {
898 let PrintMethod = "printNoHashImmediate";
901 def CoprocNumAsmOperand : AsmOperandClass {
902 let Name = "CoprocNum";
903 let ParserMethod = "parseCoprocNumOperand";
905 def p_imm : Operand<i32> {
906 let PrintMethod = "printPImmediate";
907 let ParserMatchClass = CoprocNumAsmOperand;
908 let DecoderMethod = "DecodeCoprocessor";
911 def pf_imm : Operand<i32> {
912 let PrintMethod = "printPImmediate";
913 let ParserMatchClass = CoprocNumAsmOperand;
916 def CoprocRegAsmOperand : AsmOperandClass {
917 let Name = "CoprocReg";
918 let ParserMethod = "parseCoprocRegOperand";
920 def c_imm : Operand<i32> {
921 let PrintMethod = "printCImmediate";
922 let ParserMatchClass = CoprocRegAsmOperand;
924 def CoprocOptionAsmOperand : AsmOperandClass {
925 let Name = "CoprocOption";
926 let ParserMethod = "parseCoprocOptionOperand";
928 def coproc_option_imm : Operand<i32> {
929 let PrintMethod = "printCoprocOptionImm";
930 let ParserMatchClass = CoprocOptionAsmOperand;
933 //===----------------------------------------------------------------------===//
935 include "ARMInstrFormats.td"
937 //===----------------------------------------------------------------------===//
938 // Multiclass helpers...
941 /// AsI1_bin_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns for a
942 /// binop that produces a value.
943 let TwoOperandAliasConstraint = "$Rn = $Rd" in
944 multiclass AsI1_bin_irs<bits<4> opcod, string opc,
945 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
946 PatFrag opnode, string baseOpc, bit Commutable = 0> {
947 // The register-immediate version is re-materializable. This is useful
948 // in particular for taking the address of a local.
949 let isReMaterializable = 1 in {
950 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
951 iii, opc, "\t$Rd, $Rn, $imm",
952 [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]> {
957 let Inst{19-16} = Rn;
958 let Inst{15-12} = Rd;
959 let Inst{11-0} = imm;
962 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
963 iir, opc, "\t$Rd, $Rn, $Rm",
964 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]> {
969 let isCommutable = Commutable;
970 let Inst{19-16} = Rn;
971 let Inst{15-12} = Rd;
972 let Inst{11-4} = 0b00000000;
976 def rsi : AsI1<opcod, (outs GPR:$Rd),
977 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
978 iis, opc, "\t$Rd, $Rn, $shift",
979 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_imm:$shift))]> {
984 let Inst{19-16} = Rn;
985 let Inst{15-12} = Rd;
986 let Inst{11-5} = shift{11-5};
988 let Inst{3-0} = shift{3-0};
991 def rsr : AsI1<opcod, (outs GPR:$Rd),
992 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
993 iis, opc, "\t$Rd, $Rn, $shift",
994 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_reg:$shift))]> {
999 let Inst{19-16} = Rn;
1000 let Inst{15-12} = Rd;
1001 let Inst{11-8} = shift{11-8};
1003 let Inst{6-5} = shift{6-5};
1005 let Inst{3-0} = shift{3-0};
1009 /// AsI1_rbin_irs - Same as AsI1_bin_irs except the order of operands are
1010 /// reversed. The 'rr' form is only defined for the disassembler; for codegen
1011 /// it is equivalent to the AsI1_bin_irs counterpart.
1012 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1013 multiclass AsI1_rbin_irs<bits<4> opcod, string opc,
1014 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1015 PatFrag opnode, string baseOpc, bit Commutable = 0> {
1016 // The register-immediate version is re-materializable. This is useful
1017 // in particular for taking the address of a local.
1018 let isReMaterializable = 1 in {
1019 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
1020 iii, opc, "\t$Rd, $Rn, $imm",
1021 [(set GPR:$Rd, (opnode so_imm:$imm, GPR:$Rn))]> {
1026 let Inst{19-16} = Rn;
1027 let Inst{15-12} = Rd;
1028 let Inst{11-0} = imm;
1031 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1032 iir, opc, "\t$Rd, $Rn, $Rm",
1033 [/* pattern left blank */]> {
1037 let Inst{11-4} = 0b00000000;
1040 let Inst{15-12} = Rd;
1041 let Inst{19-16} = Rn;
1044 def rsi : AsI1<opcod, (outs GPR:$Rd),
1045 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1046 iis, opc, "\t$Rd, $Rn, $shift",
1047 [(set GPR:$Rd, (opnode so_reg_imm:$shift, GPR:$Rn))]> {
1052 let Inst{19-16} = Rn;
1053 let Inst{15-12} = Rd;
1054 let Inst{11-5} = shift{11-5};
1056 let Inst{3-0} = shift{3-0};
1059 def rsr : AsI1<opcod, (outs GPR:$Rd),
1060 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1061 iis, opc, "\t$Rd, $Rn, $shift",
1062 [(set GPR:$Rd, (opnode so_reg_reg:$shift, GPR:$Rn))]> {
1067 let Inst{19-16} = Rn;
1068 let Inst{15-12} = Rd;
1069 let Inst{11-8} = shift{11-8};
1071 let Inst{6-5} = shift{6-5};
1073 let Inst{3-0} = shift{3-0};
1077 /// AsI1_bin_s_irs - Same as AsI1_bin_irs except it sets the 's' bit by default.
1079 /// These opcodes will be converted to the real non-S opcodes by
1080 /// AdjustInstrPostInstrSelection after giving them an optional CPSR operand.
1081 let hasPostISelHook = 1, Defs = [CPSR] in {
1082 multiclass AsI1_bin_s_irs<InstrItinClass iii, InstrItinClass iir,
1083 InstrItinClass iis, PatFrag opnode,
1084 bit Commutable = 0> {
1085 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm, pred:$p),
1087 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_imm:$imm))]>;
1089 def rr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, pred:$p),
1091 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm))]> {
1092 let isCommutable = Commutable;
1094 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1095 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1097 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1098 so_reg_imm:$shift))]>;
1100 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1101 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1103 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1104 so_reg_reg:$shift))]>;
1108 /// AsI1_rbin_s_is - Same as AsI1_bin_s_irs, except selection DAG
1109 /// operands are reversed.
1110 let hasPostISelHook = 1, Defs = [CPSR] in {
1111 multiclass AsI1_rbin_s_is<InstrItinClass iii, InstrItinClass iir,
1112 InstrItinClass iis, PatFrag opnode,
1113 bit Commutable = 0> {
1114 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm, pred:$p),
1116 [(set GPR:$Rd, CPSR, (opnode so_imm:$imm, GPR:$Rn))]>;
1118 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1119 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1121 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift,
1124 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1125 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1127 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift,
1132 /// AI1_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
1133 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
1134 /// a explicit result, only implicitly set CPSR.
1135 let isCompare = 1, Defs = [CPSR] in {
1136 multiclass AI1_cmp_irs<bits<4> opcod, string opc,
1137 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1138 PatFrag opnode, bit Commutable = 0> {
1139 def ri : AI1<opcod, (outs), (ins GPR:$Rn, so_imm:$imm), DPFrm, iii,
1141 [(opnode GPR:$Rn, so_imm:$imm)]> {
1146 let Inst{19-16} = Rn;
1147 let Inst{15-12} = 0b0000;
1148 let Inst{11-0} = imm;
1150 let Unpredictable{15-12} = 0b1111;
1152 def rr : AI1<opcod, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, iir,
1154 [(opnode GPR:$Rn, GPR:$Rm)]> {
1157 let isCommutable = Commutable;
1160 let Inst{19-16} = Rn;
1161 let Inst{15-12} = 0b0000;
1162 let Inst{11-4} = 0b00000000;
1165 let Unpredictable{15-12} = 0b1111;
1167 def rsi : AI1<opcod, (outs),
1168 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, iis,
1169 opc, "\t$Rn, $shift",
1170 [(opnode GPR:$Rn, so_reg_imm:$shift)]> {
1175 let Inst{19-16} = Rn;
1176 let Inst{15-12} = 0b0000;
1177 let Inst{11-5} = shift{11-5};
1179 let Inst{3-0} = shift{3-0};
1181 let Unpredictable{15-12} = 0b1111;
1183 def rsr : AI1<opcod, (outs),
1184 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, iis,
1185 opc, "\t$Rn, $shift",
1186 [(opnode GPRnopc:$Rn, so_reg_reg:$shift)]> {
1191 let Inst{19-16} = Rn;
1192 let Inst{15-12} = 0b0000;
1193 let Inst{11-8} = shift{11-8};
1195 let Inst{6-5} = shift{6-5};
1197 let Inst{3-0} = shift{3-0};
1199 let Unpredictable{15-12} = 0b1111;
1205 /// AI_ext_rrot - A unary operation with two forms: one whose operand is a
1206 /// register and one whose operand is a register rotated by 8/16/24.
1207 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
1208 class AI_ext_rrot<bits<8> opcod, string opc, PatFrag opnode>
1209 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1210 IIC_iEXTr, opc, "\t$Rd, $Rm$rot",
1211 [(set GPRnopc:$Rd, (opnode (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1212 Requires<[IsARM, HasV6]> {
1216 let Inst{19-16} = 0b1111;
1217 let Inst{15-12} = Rd;
1218 let Inst{11-10} = rot;
1222 class AI_ext_rrot_np<bits<8> opcod, string opc>
1223 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1224 IIC_iEXTr, opc, "\t$Rd, $Rm$rot", []>,
1225 Requires<[IsARM, HasV6]> {
1227 let Inst{19-16} = 0b1111;
1228 let Inst{11-10} = rot;
1231 /// AI_exta_rrot - A binary operation with two forms: one whose operand is a
1232 /// register and one whose operand is a register rotated by 8/16/24.
1233 class AI_exta_rrot<bits<8> opcod, string opc, PatFrag opnode>
1234 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1235 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot",
1236 [(set GPRnopc:$Rd, (opnode GPR:$Rn,
1237 (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1238 Requires<[IsARM, HasV6]> {
1243 let Inst{19-16} = Rn;
1244 let Inst{15-12} = Rd;
1245 let Inst{11-10} = rot;
1246 let Inst{9-4} = 0b000111;
1250 class AI_exta_rrot_np<bits<8> opcod, string opc>
1251 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1252 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot", []>,
1253 Requires<[IsARM, HasV6]> {
1256 let Inst{19-16} = Rn;
1257 let Inst{11-10} = rot;
1260 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
1261 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1262 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
1263 string baseOpc, bit Commutable = 0> {
1264 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1265 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
1266 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1267 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_imm:$imm, CPSR))]>,
1273 let Inst{15-12} = Rd;
1274 let Inst{19-16} = Rn;
1275 let Inst{11-0} = imm;
1277 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1278 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1279 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm, CPSR))]>,
1284 let Inst{11-4} = 0b00000000;
1286 let isCommutable = Commutable;
1288 let Inst{15-12} = Rd;
1289 let Inst{19-16} = Rn;
1291 def rsi : AsI1<opcod, (outs GPR:$Rd),
1292 (ins GPR:$Rn, so_reg_imm:$shift),
1293 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1294 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_imm:$shift, CPSR))]>,
1300 let Inst{19-16} = Rn;
1301 let Inst{15-12} = Rd;
1302 let Inst{11-5} = shift{11-5};
1304 let Inst{3-0} = shift{3-0};
1306 def rsr : AsI1<opcod, (outs GPRnopc:$Rd),
1307 (ins GPRnopc:$Rn, so_reg_reg:$shift),
1308 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1309 [(set GPRnopc:$Rd, CPSR, (opnode GPRnopc:$Rn, so_reg_reg:$shift, CPSR))]>,
1315 let Inst{19-16} = Rn;
1316 let Inst{15-12} = Rd;
1317 let Inst{11-8} = shift{11-8};
1319 let Inst{6-5} = shift{6-5};
1321 let Inst{3-0} = shift{3-0};
1326 /// AI1_rsc_irs - Define instructions and patterns for rsc
1327 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1328 multiclass AI1_rsc_irs<bits<4> opcod, string opc, PatFrag opnode,
1330 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1331 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
1332 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1333 [(set GPR:$Rd, CPSR, (opnode so_imm:$imm, GPR:$Rn, CPSR))]>,
1339 let Inst{15-12} = Rd;
1340 let Inst{19-16} = Rn;
1341 let Inst{11-0} = imm;
1343 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1344 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1345 [/* pattern left blank */]> {
1349 let Inst{11-4} = 0b00000000;
1352 let Inst{15-12} = Rd;
1353 let Inst{19-16} = Rn;
1355 def rsi : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_imm:$shift),
1356 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1357 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift, GPR:$Rn, CPSR))]>,
1363 let Inst{19-16} = Rn;
1364 let Inst{15-12} = Rd;
1365 let Inst{11-5} = shift{11-5};
1367 let Inst{3-0} = shift{3-0};
1369 def rsr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_reg:$shift),
1370 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1371 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift, GPR:$Rn, CPSR))]>,
1377 let Inst{19-16} = Rn;
1378 let Inst{15-12} = Rd;
1379 let Inst{11-8} = shift{11-8};
1381 let Inst{6-5} = shift{6-5};
1383 let Inst{3-0} = shift{3-0};
1388 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1389 multiclass AI_ldr1<bit isByte, string opc, InstrItinClass iii,
1390 InstrItinClass iir, PatFrag opnode> {
1391 // Note: We use the complex addrmode_imm12 rather than just an input
1392 // GPR and a constrained immediate so that we can use this to match
1393 // frame index references and avoid matching constant pool references.
1394 def i12: AI2ldst<0b010, 1, isByte, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
1395 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1396 [(set GPR:$Rt, (opnode addrmode_imm12:$addr))]> {
1399 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1400 let Inst{19-16} = addr{16-13}; // Rn
1401 let Inst{15-12} = Rt;
1402 let Inst{11-0} = addr{11-0}; // imm12
1404 def rs : AI2ldst<0b011, 1, isByte, (outs GPR:$Rt), (ins ldst_so_reg:$shift),
1405 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1406 [(set GPR:$Rt, (opnode ldst_so_reg:$shift))]> {
1409 let shift{4} = 0; // Inst{4} = 0
1410 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1411 let Inst{19-16} = shift{16-13}; // Rn
1412 let Inst{15-12} = Rt;
1413 let Inst{11-0} = shift{11-0};
1418 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1419 multiclass AI_ldr1nopc<bit isByte, string opc, InstrItinClass iii,
1420 InstrItinClass iir, PatFrag opnode> {
1421 // Note: We use the complex addrmode_imm12 rather than just an input
1422 // GPR and a constrained immediate so that we can use this to match
1423 // frame index references and avoid matching constant pool references.
1424 def i12: AI2ldst<0b010, 1, isByte, (outs GPRnopc:$Rt), (ins addrmode_imm12:$addr),
1425 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1426 [(set GPRnopc:$Rt, (opnode addrmode_imm12:$addr))]> {
1429 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1430 let Inst{19-16} = addr{16-13}; // Rn
1431 let Inst{15-12} = Rt;
1432 let Inst{11-0} = addr{11-0}; // imm12
1434 def rs : AI2ldst<0b011, 1, isByte, (outs GPRnopc:$Rt), (ins ldst_so_reg:$shift),
1435 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1436 [(set GPRnopc:$Rt, (opnode ldst_so_reg:$shift))]> {
1439 let shift{4} = 0; // Inst{4} = 0
1440 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1441 let Inst{19-16} = shift{16-13}; // Rn
1442 let Inst{15-12} = Rt;
1443 let Inst{11-0} = shift{11-0};
1449 multiclass AI_str1<bit isByte, string opc, InstrItinClass iii,
1450 InstrItinClass iir, PatFrag opnode> {
1451 // Note: We use the complex addrmode_imm12 rather than just an input
1452 // GPR and a constrained immediate so that we can use this to match
1453 // frame index references and avoid matching constant pool references.
1454 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1455 (ins GPR:$Rt, addrmode_imm12:$addr),
1456 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1457 [(opnode GPR:$Rt, addrmode_imm12:$addr)]> {
1460 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1461 let Inst{19-16} = addr{16-13}; // Rn
1462 let Inst{15-12} = Rt;
1463 let Inst{11-0} = addr{11-0}; // imm12
1465 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPR:$Rt, ldst_so_reg:$shift),
1466 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1467 [(opnode GPR:$Rt, ldst_so_reg:$shift)]> {
1470 let shift{4} = 0; // Inst{4} = 0
1471 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1472 let Inst{19-16} = shift{16-13}; // Rn
1473 let Inst{15-12} = Rt;
1474 let Inst{11-0} = shift{11-0};
1478 multiclass AI_str1nopc<bit isByte, string opc, InstrItinClass iii,
1479 InstrItinClass iir, PatFrag opnode> {
1480 // Note: We use the complex addrmode_imm12 rather than just an input
1481 // GPR and a constrained immediate so that we can use this to match
1482 // frame index references and avoid matching constant pool references.
1483 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1484 (ins GPRnopc:$Rt, addrmode_imm12:$addr),
1485 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1486 [(opnode GPRnopc:$Rt, addrmode_imm12:$addr)]> {
1489 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1490 let Inst{19-16} = addr{16-13}; // Rn
1491 let Inst{15-12} = Rt;
1492 let Inst{11-0} = addr{11-0}; // imm12
1494 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPRnopc:$Rt, ldst_so_reg:$shift),
1495 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1496 [(opnode GPRnopc:$Rt, ldst_so_reg:$shift)]> {
1499 let shift{4} = 0; // Inst{4} = 0
1500 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1501 let Inst{19-16} = shift{16-13}; // Rn
1502 let Inst{15-12} = Rt;
1503 let Inst{11-0} = shift{11-0};
1508 //===----------------------------------------------------------------------===//
1510 //===----------------------------------------------------------------------===//
1512 //===----------------------------------------------------------------------===//
1513 // Miscellaneous Instructions.
1516 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
1517 /// the function. The first operand is the ID# for this instruction, the second
1518 /// is the index into the MachineConstantPool that this is, the third is the
1519 /// size in bytes of this constant pool entry.
1520 let neverHasSideEffects = 1, isNotDuplicable = 1 in
1521 def CONSTPOOL_ENTRY :
1522 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1523 i32imm:$size), NoItinerary, []>;
1525 // FIXME: Marking these as hasSideEffects is necessary to prevent machine DCE
1526 // from removing one half of the matched pairs. That breaks PEI, which assumes
1527 // these will always be in pairs, and asserts if it finds otherwise. Better way?
1528 let Defs = [SP], Uses = [SP], hasSideEffects = 1 in {
1529 def ADJCALLSTACKUP :
1530 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary,
1531 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
1533 def ADJCALLSTACKDOWN :
1534 PseudoInst<(outs), (ins i32imm:$amt, pred:$p), NoItinerary,
1535 [(ARMcallseq_start timm:$amt)]>;
1538 // Atomic pseudo-insts which will be lowered to ldrexd/strexd loops.
1539 // (These pseudos use a hand-written selection code).
1540 let usesCustomInserter = 1, Defs = [CPSR], mayLoad = 1, mayStore = 1 in {
1541 def ATOMOR6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1542 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1544 def ATOMXOR6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1545 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1547 def ATOMADD6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1548 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1550 def ATOMSUB6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1551 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1553 def ATOMNAND6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1554 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1556 def ATOMAND6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1557 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1559 def ATOMSWAP6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1560 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1562 def ATOMCMPXCHG6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1563 (ins GPR:$addr, GPR:$cmp1, GPR:$cmp2,
1564 GPR:$set1, GPR:$set2),
1568 def NOP : AI<(outs), (ins), MiscFrm, NoItinerary, "nop", "", []>,
1569 Requires<[IsARM, HasV6T2]> {
1570 let Inst{27-16} = 0b001100100000;
1571 let Inst{15-8} = 0b11110000;
1572 let Inst{7-0} = 0b00000000;
1575 def YIELD : AI<(outs), (ins), MiscFrm, NoItinerary, "yield", "", []>,
1576 Requires<[IsARM, HasV6T2]> {
1577 let Inst{27-16} = 0b001100100000;
1578 let Inst{15-8} = 0b11110000;
1579 let Inst{7-0} = 0b00000001;
1582 def WFE : AI<(outs), (ins), MiscFrm, NoItinerary, "wfe", "", []>,
1583 Requires<[IsARM, HasV6T2]> {
1584 let Inst{27-16} = 0b001100100000;
1585 let Inst{15-8} = 0b11110000;
1586 let Inst{7-0} = 0b00000010;
1589 def WFI : AI<(outs), (ins), MiscFrm, NoItinerary, "wfi", "", []>,
1590 Requires<[IsARM, HasV6T2]> {
1591 let Inst{27-16} = 0b001100100000;
1592 let Inst{15-8} = 0b11110000;
1593 let Inst{7-0} = 0b00000011;
1596 def SEL : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, NoItinerary, "sel",
1597 "\t$Rd, $Rn, $Rm", []>, Requires<[IsARM, HasV6]> {
1602 let Inst{15-12} = Rd;
1603 let Inst{19-16} = Rn;
1604 let Inst{27-20} = 0b01101000;
1605 let Inst{7-4} = 0b1011;
1606 let Inst{11-8} = 0b1111;
1609 def SEV : AI<(outs), (ins), MiscFrm, NoItinerary, "sev", "",
1610 []>, Requires<[IsARM, HasV6T2]> {
1611 let Inst{27-16} = 0b001100100000;
1612 let Inst{15-8} = 0b11110000;
1613 let Inst{7-0} = 0b00000100;
1616 // The i32imm operand $val can be used by a debugger to store more information
1617 // about the breakpoint.
1618 def BKPT : AI<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
1619 "bkpt", "\t$val", []>, Requires<[IsARM]> {
1621 let Inst{3-0} = val{3-0};
1622 let Inst{19-8} = val{15-4};
1623 let Inst{27-20} = 0b00010010;
1624 let Inst{7-4} = 0b0111;
1627 // Change Processor State
1628 // FIXME: We should use InstAlias to handle the optional operands.
1629 class CPS<dag iops, string asm_ops>
1630 : AXI<(outs), iops, MiscFrm, NoItinerary, !strconcat("cps", asm_ops),
1631 []>, Requires<[IsARM]> {
1637 let Inst{31-28} = 0b1111;
1638 let Inst{27-20} = 0b00010000;
1639 let Inst{19-18} = imod;
1640 let Inst{17} = M; // Enabled if mode is set;
1641 let Inst{16-9} = 0b00000000;
1642 let Inst{8-6} = iflags;
1644 let Inst{4-0} = mode;
1647 let DecoderMethod = "DecodeCPSInstruction" in {
1649 def CPS3p : CPS<(ins imod_op:$imod, iflags_op:$iflags, imm0_31:$mode),
1650 "$imod\t$iflags, $mode">;
1651 let mode = 0, M = 0 in
1652 def CPS2p : CPS<(ins imod_op:$imod, iflags_op:$iflags), "$imod\t$iflags">;
1654 let imod = 0, iflags = 0, M = 1 in
1655 def CPS1p : CPS<(ins imm0_31:$mode), "\t$mode">;
1658 // Preload signals the memory system of possible future data/instruction access.
1659 multiclass APreLoad<bits<1> read, bits<1> data, string opc> {
1661 def i12 : AXI<(outs), (ins addrmode_imm12:$addr), MiscFrm, IIC_Preload,
1662 !strconcat(opc, "\t$addr"),
1663 [(ARMPreload addrmode_imm12:$addr, (i32 read), (i32 data))]> {
1666 let Inst{31-26} = 0b111101;
1667 let Inst{25} = 0; // 0 for immediate form
1668 let Inst{24} = data;
1669 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1670 let Inst{22} = read;
1671 let Inst{21-20} = 0b01;
1672 let Inst{19-16} = addr{16-13}; // Rn
1673 let Inst{15-12} = 0b1111;
1674 let Inst{11-0} = addr{11-0}; // imm12
1677 def rs : AXI<(outs), (ins ldst_so_reg:$shift), MiscFrm, IIC_Preload,
1678 !strconcat(opc, "\t$shift"),
1679 [(ARMPreload ldst_so_reg:$shift, (i32 read), (i32 data))]> {
1681 let Inst{31-26} = 0b111101;
1682 let Inst{25} = 1; // 1 for register form
1683 let Inst{24} = data;
1684 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1685 let Inst{22} = read;
1686 let Inst{21-20} = 0b01;
1687 let Inst{19-16} = shift{16-13}; // Rn
1688 let Inst{15-12} = 0b1111;
1689 let Inst{11-0} = shift{11-0};
1694 defm PLD : APreLoad<1, 1, "pld">, Requires<[IsARM]>;
1695 defm PLDW : APreLoad<0, 1, "pldw">, Requires<[IsARM,HasV7,HasMP]>;
1696 defm PLI : APreLoad<1, 0, "pli">, Requires<[IsARM,HasV7]>;
1698 def SETEND : AXI<(outs), (ins setend_op:$end), MiscFrm, NoItinerary,
1699 "setend\t$end", []>, Requires<[IsARM]> {
1701 let Inst{31-10} = 0b1111000100000001000000;
1706 def DBG : AI<(outs), (ins imm0_15:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt",
1707 []>, Requires<[IsARM, HasV7]> {
1709 let Inst{27-4} = 0b001100100000111100001111;
1710 let Inst{3-0} = opt;
1713 // A5.4 Permanently UNDEFINED instructions.
1714 let isBarrier = 1, isTerminator = 1 in
1715 def TRAP : AXI<(outs), (ins), MiscFrm, NoItinerary,
1718 let Inst = 0xe7ffdefe;
1721 // Address computation and loads and stores in PIC mode.
1722 let isNotDuplicable = 1 in {
1723 def PICADD : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
1725 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>;
1727 let AddedComplexity = 10 in {
1728 def PICLDR : ARMPseudoInst<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
1730 [(set GPR:$dst, (load addrmodepc:$addr))]>;
1732 def PICLDRH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1734 [(set GPR:$Rt, (zextloadi16 addrmodepc:$addr))]>;
1736 def PICLDRB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1738 [(set GPR:$Rt, (zextloadi8 addrmodepc:$addr))]>;
1740 def PICLDRSH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1742 [(set GPR:$Rt, (sextloadi16 addrmodepc:$addr))]>;
1744 def PICLDRSB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1746 [(set GPR:$Rt, (sextloadi8 addrmodepc:$addr))]>;
1748 let AddedComplexity = 10 in {
1749 def PICSTR : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1750 4, IIC_iStore_r, [(store GPR:$src, addrmodepc:$addr)]>;
1752 def PICSTRH : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1753 4, IIC_iStore_bh_r, [(truncstorei16 GPR:$src,
1754 addrmodepc:$addr)]>;
1756 def PICSTRB : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1757 4, IIC_iStore_bh_r, [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
1759 } // isNotDuplicable = 1
1762 // LEApcrel - Load a pc-relative address into a register without offending the
1764 let neverHasSideEffects = 1, isReMaterializable = 1 in
1765 // The 'adr' mnemonic encodes differently if the label is before or after
1766 // the instruction. The {24-21} opcode bits are set by the fixup, as we don't
1767 // know until then which form of the instruction will be used.
1768 def ADR : AI1<{0,?,?,0}, (outs GPR:$Rd), (ins adrlabel:$label),
1769 MiscFrm, IIC_iALUi, "adr", "\t$Rd, $label", []> {
1772 let Inst{27-25} = 0b001;
1774 let Inst{23-22} = label{13-12};
1777 let Inst{19-16} = 0b1111;
1778 let Inst{15-12} = Rd;
1779 let Inst{11-0} = label{11-0};
1781 def LEApcrel : ARMPseudoInst<(outs GPR:$Rd), (ins i32imm:$label, pred:$p),
1784 def LEApcrelJT : ARMPseudoInst<(outs GPR:$Rd),
1785 (ins i32imm:$label, nohash_imm:$id, pred:$p),
1788 //===----------------------------------------------------------------------===//
1789 // Control Flow Instructions.
1792 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
1794 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
1795 "bx", "\tlr", [(ARMretflag)]>,
1796 Requires<[IsARM, HasV4T]> {
1797 let Inst{27-0} = 0b0001001011111111111100011110;
1801 def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br,
1802 "mov", "\tpc, lr", [(ARMretflag)]>,
1803 Requires<[IsARM, NoV4T]> {
1804 let Inst{27-0} = 0b0001101000001111000000001110;
1808 // Indirect branches
1809 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
1811 def BX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
1812 [(brind GPR:$dst)]>,
1813 Requires<[IsARM, HasV4T]> {
1815 let Inst{31-4} = 0b1110000100101111111111110001;
1816 let Inst{3-0} = dst;
1819 def BX_pred : AI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br,
1820 "bx", "\t$dst", [/* pattern left blank */]>,
1821 Requires<[IsARM, HasV4T]> {
1823 let Inst{27-4} = 0b000100101111111111110001;
1824 let Inst{3-0} = dst;
1828 // SP is marked as a use to prevent stack-pointer assignments that appear
1829 // immediately before calls from potentially appearing dead.
1831 // FIXME: Do we really need a non-predicated version? If so, it should
1832 // at least be a pseudo instruction expanding to the predicated version
1833 // at MC lowering time.
1834 Defs = [LR], Uses = [SP] in {
1835 def BL : ABXI<0b1011, (outs), (ins bl_target:$func, variable_ops),
1836 IIC_Br, "bl\t$func",
1837 [(ARMcall tglobaladdr:$func)]>,
1839 let Inst{31-28} = 0b1110;
1841 let Inst{23-0} = func;
1842 let DecoderMethod = "DecodeBranchImmInstruction";
1845 def BL_pred : ABI<0b1011, (outs), (ins bl_target:$func, variable_ops),
1846 IIC_Br, "bl", "\t$func",
1847 [(ARMcall_pred tglobaladdr:$func)]>,
1850 let Inst{23-0} = func;
1851 let DecoderMethod = "DecodeBranchImmInstruction";
1855 def BLX : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
1856 IIC_Br, "blx\t$func",
1857 [(ARMcall GPR:$func)]>,
1858 Requires<[IsARM, HasV5T]> {
1860 let Inst{31-4} = 0b1110000100101111111111110011;
1861 let Inst{3-0} = func;
1864 def BLX_pred : AI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
1865 IIC_Br, "blx", "\t$func",
1866 [(ARMcall_pred GPR:$func)]>,
1867 Requires<[IsARM, HasV5T]> {
1869 let Inst{27-4} = 0b000100101111111111110011;
1870 let Inst{3-0} = func;
1874 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
1875 def BX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func, variable_ops),
1876 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
1877 Requires<[IsARM, HasV4T]>;
1880 def BMOVPCRX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func, variable_ops),
1881 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
1882 Requires<[IsARM, NoV4T]>;
1884 // mov lr, pc; b if callee is marked noreturn to avoid confusing the
1885 // return stack predictor.
1886 def BMOVPCB_CALL : ARMPseudoInst<(outs),
1887 (ins bl_target:$func, variable_ops),
1888 8, IIC_Br, [(ARMcall_nolink tglobaladdr:$func)]>,
1892 let isBranch = 1, isTerminator = 1 in {
1893 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
1894 // a two-value operand where a dag node expects two operands. :(
1895 def Bcc : ABI<0b1010, (outs), (ins br_target:$target),
1896 IIC_Br, "b", "\t$target",
1897 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]> {
1899 let Inst{23-0} = target;
1900 let DecoderMethod = "DecodeBranchImmInstruction";
1903 let isBarrier = 1 in {
1904 // B is "predicable" since it's just a Bcc with an 'always' condition.
1905 let isPredicable = 1 in
1906 // FIXME: We shouldn't need this pseudo at all. Just using Bcc directly
1907 // should be sufficient.
1908 // FIXME: Is B really a Barrier? That doesn't seem right.
1909 def B : ARMPseudoExpand<(outs), (ins br_target:$target), 4, IIC_Br,
1910 [(br bb:$target)], (Bcc br_target:$target, (ops 14, zero_reg))>;
1912 let isNotDuplicable = 1, isIndirectBranch = 1 in {
1913 def BR_JTr : ARMPseudoInst<(outs),
1914 (ins GPR:$target, i32imm:$jt, i32imm:$id),
1916 [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]>;
1917 // FIXME: This shouldn't use the generic "addrmode2," but rather be split
1918 // into i12 and rs suffixed versions.
1919 def BR_JTm : ARMPseudoInst<(outs),
1920 (ins addrmode2:$target, i32imm:$jt, i32imm:$id),
1922 [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
1924 def BR_JTadd : ARMPseudoInst<(outs),
1925 (ins GPR:$target, GPR:$idx, i32imm:$jt, i32imm:$id),
1927 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
1929 } // isNotDuplicable = 1, isIndirectBranch = 1
1935 def BLXi : AXI<(outs), (ins blx_target:$target), BrMiscFrm, NoItinerary,
1936 "blx\t$target", []>,
1937 Requires<[IsARM, HasV5T]> {
1938 let Inst{31-25} = 0b1111101;
1940 let Inst{23-0} = target{24-1};
1941 let Inst{24} = target{0};
1944 // Branch and Exchange Jazelle
1945 def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func",
1946 [/* pattern left blank */]> {
1948 let Inst{23-20} = 0b0010;
1949 let Inst{19-8} = 0xfff;
1950 let Inst{7-4} = 0b0010;
1951 let Inst{3-0} = func;
1956 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in {
1957 def TCRETURNdi : PseudoInst<(outs), (ins i32imm:$dst, variable_ops),
1960 def TCRETURNri : PseudoInst<(outs), (ins tcGPR:$dst, variable_ops),
1963 def TAILJMPd : ARMPseudoExpand<(outs), (ins br_target:$dst, variable_ops),
1965 (Bcc br_target:$dst, (ops 14, zero_reg))>,
1968 def TAILJMPr : ARMPseudoExpand<(outs), (ins tcGPR:$dst, variable_ops),
1974 // Secure Monitor Call is a system instruction.
1975 def SMC : ABI<0b0001, (outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt",
1978 let Inst{23-4} = 0b01100000000000000111;
1979 let Inst{3-0} = opt;
1982 // Supervisor Call (Software Interrupt)
1983 let isCall = 1, Uses = [SP] in {
1984 def SVC : ABI<0b1111, (outs), (ins imm24b:$svc), IIC_Br, "svc", "\t$svc", []> {
1986 let Inst{23-0} = svc;
1990 // Store Return State
1991 class SRSI<bit wb, string asm>
1992 : XI<(outs), (ins imm0_31:$mode), AddrModeNone, 4, IndexModeNone, BrFrm,
1993 NoItinerary, asm, "", []> {
1995 let Inst{31-28} = 0b1111;
1996 let Inst{27-25} = 0b100;
2000 let Inst{19-16} = 0b1101; // SP
2001 let Inst{15-5} = 0b00000101000;
2002 let Inst{4-0} = mode;
2005 def SRSDA : SRSI<0, "srsda\tsp, $mode"> {
2006 let Inst{24-23} = 0;
2008 def SRSDA_UPD : SRSI<1, "srsda\tsp!, $mode"> {
2009 let Inst{24-23} = 0;
2011 def SRSDB : SRSI<0, "srsdb\tsp, $mode"> {
2012 let Inst{24-23} = 0b10;
2014 def SRSDB_UPD : SRSI<1, "srsdb\tsp!, $mode"> {
2015 let Inst{24-23} = 0b10;
2017 def SRSIA : SRSI<0, "srsia\tsp, $mode"> {
2018 let Inst{24-23} = 0b01;
2020 def SRSIA_UPD : SRSI<1, "srsia\tsp!, $mode"> {
2021 let Inst{24-23} = 0b01;
2023 def SRSIB : SRSI<0, "srsib\tsp, $mode"> {
2024 let Inst{24-23} = 0b11;
2026 def SRSIB_UPD : SRSI<1, "srsib\tsp!, $mode"> {
2027 let Inst{24-23} = 0b11;
2030 // Return From Exception
2031 class RFEI<bit wb, string asm>
2032 : XI<(outs), (ins GPR:$Rn), AddrModeNone, 4, IndexModeNone, BrFrm,
2033 NoItinerary, asm, "", []> {
2035 let Inst{31-28} = 0b1111;
2036 let Inst{27-25} = 0b100;
2040 let Inst{19-16} = Rn;
2041 let Inst{15-0} = 0xa00;
2044 def RFEDA : RFEI<0, "rfeda\t$Rn"> {
2045 let Inst{24-23} = 0;
2047 def RFEDA_UPD : RFEI<1, "rfeda\t$Rn!"> {
2048 let Inst{24-23} = 0;
2050 def RFEDB : RFEI<0, "rfedb\t$Rn"> {
2051 let Inst{24-23} = 0b10;
2053 def RFEDB_UPD : RFEI<1, "rfedb\t$Rn!"> {
2054 let Inst{24-23} = 0b10;
2056 def RFEIA : RFEI<0, "rfeia\t$Rn"> {
2057 let Inst{24-23} = 0b01;
2059 def RFEIA_UPD : RFEI<1, "rfeia\t$Rn!"> {
2060 let Inst{24-23} = 0b01;
2062 def RFEIB : RFEI<0, "rfeib\t$Rn"> {
2063 let Inst{24-23} = 0b11;
2065 def RFEIB_UPD : RFEI<1, "rfeib\t$Rn!"> {
2066 let Inst{24-23} = 0b11;
2069 //===----------------------------------------------------------------------===//
2070 // Load / Store Instructions.
2076 defm LDR : AI_ldr1<0, "ldr", IIC_iLoad_r, IIC_iLoad_si,
2077 UnOpFrag<(load node:$Src)>>;
2078 defm LDRB : AI_ldr1nopc<1, "ldrb", IIC_iLoad_bh_r, IIC_iLoad_bh_si,
2079 UnOpFrag<(zextloadi8 node:$Src)>>;
2080 defm STR : AI_str1<0, "str", IIC_iStore_r, IIC_iStore_si,
2081 BinOpFrag<(store node:$LHS, node:$RHS)>>;
2082 defm STRB : AI_str1nopc<1, "strb", IIC_iStore_bh_r, IIC_iStore_bh_si,
2083 BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
2085 // Special LDR for loads from non-pc-relative constpools.
2086 let canFoldAsLoad = 1, mayLoad = 1, neverHasSideEffects = 1,
2087 isReMaterializable = 1, isCodeGenOnly = 1 in
2088 def LDRcp : AI2ldst<0b010, 1, 0, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
2089 AddrMode_i12, LdFrm, IIC_iLoad_r, "ldr", "\t$Rt, $addr",
2093 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2094 let Inst{19-16} = 0b1111;
2095 let Inst{15-12} = Rt;
2096 let Inst{11-0} = addr{11-0}; // imm12
2099 // Loads with zero extension
2100 def LDRH : AI3ld<0b1011, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2101 IIC_iLoad_bh_r, "ldrh", "\t$Rt, $addr",
2102 [(set GPR:$Rt, (zextloadi16 addrmode3:$addr))]>;
2104 // Loads with sign extension
2105 def LDRSH : AI3ld<0b1111, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2106 IIC_iLoad_bh_r, "ldrsh", "\t$Rt, $addr",
2107 [(set GPR:$Rt, (sextloadi16 addrmode3:$addr))]>;
2109 def LDRSB : AI3ld<0b1101, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2110 IIC_iLoad_bh_r, "ldrsb", "\t$Rt, $addr",
2111 [(set GPR:$Rt, (sextloadi8 addrmode3:$addr))]>;
2113 let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1 in {
2115 def LDRD : AI3ld<0b1101, 0, (outs GPR:$Rd, GPR:$dst2),
2116 (ins addrmode3:$addr), LdMiscFrm,
2117 IIC_iLoad_d_r, "ldrd", "\t$Rd, $dst2, $addr",
2118 []>, Requires<[IsARM, HasV5TE]>;
2122 multiclass AI2_ldridx<bit isByte, string opc,
2123 InstrItinClass iii, InstrItinClass iir> {
2124 def _PRE_IMM : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2125 (ins addrmode_imm12:$addr), IndexModePre, LdFrm, iii,
2126 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2129 let Inst{23} = addr{12};
2130 let Inst{19-16} = addr{16-13};
2131 let Inst{11-0} = addr{11-0};
2132 let DecoderMethod = "DecodeLDRPreImm";
2133 let AsmMatchConverter = "cvtLdWriteBackRegAddrModeImm12";
2136 def _PRE_REG : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2137 (ins ldst_so_reg:$addr), IndexModePre, LdFrm, iir,
2138 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2141 let Inst{23} = addr{12};
2142 let Inst{19-16} = addr{16-13};
2143 let Inst{11-0} = addr{11-0};
2145 let DecoderMethod = "DecodeLDRPreReg";
2146 let AsmMatchConverter = "cvtLdWriteBackRegAddrMode2";
2149 def _POST_REG : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2150 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2151 IndexModePost, LdFrm, iir,
2152 opc, "\t$Rt, $addr, $offset",
2153 "$addr.base = $Rn_wb", []> {
2159 let Inst{23} = offset{12};
2160 let Inst{19-16} = addr;
2161 let Inst{11-0} = offset{11-0};
2163 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2166 def _POST_IMM : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2167 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2168 IndexModePost, LdFrm, iii,
2169 opc, "\t$Rt, $addr, $offset",
2170 "$addr.base = $Rn_wb", []> {
2176 let Inst{23} = offset{12};
2177 let Inst{19-16} = addr;
2178 let Inst{11-0} = offset{11-0};
2180 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2185 let mayLoad = 1, neverHasSideEffects = 1 in {
2186 // FIXME: for LDR_PRE_REG etc. the itineray should be either IIC_iLoad_ru or
2187 // IIC_iLoad_siu depending on whether it the offset register is shifted.
2188 defm LDR : AI2_ldridx<0, "ldr", IIC_iLoad_iu, IIC_iLoad_ru>;
2189 defm LDRB : AI2_ldridx<1, "ldrb", IIC_iLoad_bh_iu, IIC_iLoad_bh_ru>;
2192 multiclass AI3_ldridx<bits<4> op, string opc, InstrItinClass itin> {
2193 def _PRE : AI3ldstidx<op, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2194 (ins addrmode3:$addr), IndexModePre,
2196 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2198 let Inst{23} = addr{8}; // U bit
2199 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2200 let Inst{19-16} = addr{12-9}; // Rn
2201 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2202 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2203 let AsmMatchConverter = "cvtLdWriteBackRegAddrMode3";
2204 let DecoderMethod = "DecodeAddrMode3Instruction";
2206 def _POST : AI3ldstidx<op, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2207 (ins addr_offset_none:$addr, am3offset:$offset),
2208 IndexModePost, LdMiscFrm, itin,
2209 opc, "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2213 let Inst{23} = offset{8}; // U bit
2214 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2215 let Inst{19-16} = addr;
2216 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2217 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2218 let DecoderMethod = "DecodeAddrMode3Instruction";
2222 let mayLoad = 1, neverHasSideEffects = 1 in {
2223 defm LDRH : AI3_ldridx<0b1011, "ldrh", IIC_iLoad_bh_ru>;
2224 defm LDRSH : AI3_ldridx<0b1111, "ldrsh", IIC_iLoad_bh_ru>;
2225 defm LDRSB : AI3_ldridx<0b1101, "ldrsb", IIC_iLoad_bh_ru>;
2226 let hasExtraDefRegAllocReq = 1 in {
2227 def LDRD_PRE : AI3ldstidx<0b1101, 0, 1, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2228 (ins addrmode3:$addr), IndexModePre,
2229 LdMiscFrm, IIC_iLoad_d_ru,
2230 "ldrd", "\t$Rt, $Rt2, $addr!",
2231 "$addr.base = $Rn_wb", []> {
2233 let Inst{23} = addr{8}; // U bit
2234 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2235 let Inst{19-16} = addr{12-9}; // Rn
2236 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2237 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2238 let DecoderMethod = "DecodeAddrMode3Instruction";
2239 let AsmMatchConverter = "cvtLdrdPre";
2241 def LDRD_POST: AI3ldstidx<0b1101, 0, 0, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2242 (ins addr_offset_none:$addr, am3offset:$offset),
2243 IndexModePost, LdMiscFrm, IIC_iLoad_d_ru,
2244 "ldrd", "\t$Rt, $Rt2, $addr, $offset",
2245 "$addr.base = $Rn_wb", []> {
2248 let Inst{23} = offset{8}; // U bit
2249 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2250 let Inst{19-16} = addr;
2251 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2252 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2253 let DecoderMethod = "DecodeAddrMode3Instruction";
2255 } // hasExtraDefRegAllocReq = 1
2256 } // mayLoad = 1, neverHasSideEffects = 1
2258 // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT.
2259 let mayLoad = 1, neverHasSideEffects = 1 in {
2260 def LDRT_POST_REG : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2261 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2262 IndexModePost, LdFrm, IIC_iLoad_ru,
2263 "ldrt", "\t$Rt, $addr, $offset",
2264 "$addr.base = $Rn_wb", []> {
2270 let Inst{23} = offset{12};
2271 let Inst{21} = 1; // overwrite
2272 let Inst{19-16} = addr;
2273 let Inst{11-5} = offset{11-5};
2275 let Inst{3-0} = offset{3-0};
2276 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2279 def LDRT_POST_IMM : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2280 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2281 IndexModePost, LdFrm, IIC_iLoad_ru,
2282 "ldrt", "\t$Rt, $addr, $offset",
2283 "$addr.base = $Rn_wb", []> {
2289 let Inst{23} = offset{12};
2290 let Inst{21} = 1; // overwrite
2291 let Inst{19-16} = addr;
2292 let Inst{11-0} = offset{11-0};
2293 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2296 def LDRBT_POST_REG : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2297 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2298 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2299 "ldrbt", "\t$Rt, $addr, $offset",
2300 "$addr.base = $Rn_wb", []> {
2306 let Inst{23} = offset{12};
2307 let Inst{21} = 1; // overwrite
2308 let Inst{19-16} = addr;
2309 let Inst{11-5} = offset{11-5};
2311 let Inst{3-0} = offset{3-0};
2312 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2315 def LDRBT_POST_IMM : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2316 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2317 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2318 "ldrbt", "\t$Rt, $addr, $offset",
2319 "$addr.base = $Rn_wb", []> {
2325 let Inst{23} = offset{12};
2326 let Inst{21} = 1; // overwrite
2327 let Inst{19-16} = addr;
2328 let Inst{11-0} = offset{11-0};
2329 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2332 multiclass AI3ldrT<bits<4> op, string opc> {
2333 def i : AI3ldstidxT<op, 1, (outs GPR:$Rt, GPR:$base_wb),
2334 (ins addr_offset_none:$addr, postidx_imm8:$offset),
2335 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2336 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2338 let Inst{23} = offset{8};
2340 let Inst{11-8} = offset{7-4};
2341 let Inst{3-0} = offset{3-0};
2342 let AsmMatchConverter = "cvtLdExtTWriteBackImm";
2344 def r : AI3ldstidxT<op, 1, (outs GPRnopc:$Rt, GPRnopc:$base_wb),
2345 (ins addr_offset_none:$addr, postidx_reg:$Rm),
2346 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2347 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2349 let Inst{23} = Rm{4};
2352 let Unpredictable{11-8} = 0b1111;
2353 let Inst{3-0} = Rm{3-0};
2354 let AsmMatchConverter = "cvtLdExtTWriteBackReg";
2355 let DecoderMethod = "DecodeLDR";
2359 defm LDRSBT : AI3ldrT<0b1101, "ldrsbt">;
2360 defm LDRHT : AI3ldrT<0b1011, "ldrht">;
2361 defm LDRSHT : AI3ldrT<0b1111, "ldrsht">;
2366 // Stores with truncate
2367 def STRH : AI3str<0b1011, (outs), (ins GPR:$Rt, addrmode3:$addr), StMiscFrm,
2368 IIC_iStore_bh_r, "strh", "\t$Rt, $addr",
2369 [(truncstorei16 GPR:$Rt, addrmode3:$addr)]>;
2372 let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in
2373 def STRD : AI3str<0b1111, (outs), (ins GPR:$Rt, GPR:$src2, addrmode3:$addr),
2374 StMiscFrm, IIC_iStore_d_r,
2375 "strd", "\t$Rt, $src2, $addr", []>,
2376 Requires<[IsARM, HasV5TE]> {
2381 multiclass AI2_stridx<bit isByte, string opc,
2382 InstrItinClass iii, InstrItinClass iir> {
2383 def _PRE_IMM : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2384 (ins GPR:$Rt, addrmode_imm12:$addr), IndexModePre,
2386 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2389 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2390 let Inst{19-16} = addr{16-13}; // Rn
2391 let Inst{11-0} = addr{11-0}; // imm12
2392 let AsmMatchConverter = "cvtStWriteBackRegAddrModeImm12";
2393 let DecoderMethod = "DecodeSTRPreImm";
2396 def _PRE_REG : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2397 (ins GPR:$Rt, ldst_so_reg:$addr),
2398 IndexModePre, StFrm, iir,
2399 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2402 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2403 let Inst{19-16} = addr{16-13}; // Rn
2404 let Inst{11-0} = addr{11-0};
2405 let Inst{4} = 0; // Inst{4} = 0
2406 let AsmMatchConverter = "cvtStWriteBackRegAddrMode2";
2407 let DecoderMethod = "DecodeSTRPreReg";
2409 def _POST_REG : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2410 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2411 IndexModePost, StFrm, iir,
2412 opc, "\t$Rt, $addr, $offset",
2413 "$addr.base = $Rn_wb", []> {
2419 let Inst{23} = offset{12};
2420 let Inst{19-16} = addr;
2421 let Inst{11-0} = offset{11-0};
2423 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2426 def _POST_IMM : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2427 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2428 IndexModePost, StFrm, iii,
2429 opc, "\t$Rt, $addr, $offset",
2430 "$addr.base = $Rn_wb", []> {
2436 let Inst{23} = offset{12};
2437 let Inst{19-16} = addr;
2438 let Inst{11-0} = offset{11-0};
2440 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2444 let mayStore = 1, neverHasSideEffects = 1 in {
2445 // FIXME: for STR_PRE_REG etc. the itineray should be either IIC_iStore_ru or
2446 // IIC_iStore_siu depending on whether it the offset register is shifted.
2447 defm STR : AI2_stridx<0, "str", IIC_iStore_iu, IIC_iStore_ru>;
2448 defm STRB : AI2_stridx<1, "strb", IIC_iStore_bh_iu, IIC_iStore_bh_ru>;
2451 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2452 am2offset_reg:$offset),
2453 (STR_POST_REG GPR:$Rt, addr_offset_none:$addr,
2454 am2offset_reg:$offset)>;
2455 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2456 am2offset_imm:$offset),
2457 (STR_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2458 am2offset_imm:$offset)>;
2459 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2460 am2offset_reg:$offset),
2461 (STRB_POST_REG GPR:$Rt, addr_offset_none:$addr,
2462 am2offset_reg:$offset)>;
2463 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2464 am2offset_imm:$offset),
2465 (STRB_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2466 am2offset_imm:$offset)>;
2468 // Pseudo-instructions for pattern matching the pre-indexed stores. We can't
2469 // put the patterns on the instruction definitions directly as ISel wants
2470 // the address base and offset to be separate operands, not a single
2471 // complex operand like we represent the instructions themselves. The
2472 // pseudos map between the two.
2473 let usesCustomInserter = 1,
2474 Constraints = "$Rn = $Rn_wb,@earlyclobber $Rn_wb" in {
2475 def STRi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2476 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2479 (pre_store GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2480 def STRr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2481 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2484 (pre_store GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2485 def STRBi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2486 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2489 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2490 def STRBr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2491 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2494 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2495 def STRH_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2496 (ins GPR:$Rt, GPR:$Rn, am3offset:$offset, pred:$p),
2499 (pre_truncsti16 GPR:$Rt, GPR:$Rn, am3offset:$offset))]>;
2504 def STRH_PRE : AI3ldstidx<0b1011, 0, 1, (outs GPR:$Rn_wb),
2505 (ins GPR:$Rt, addrmode3:$addr), IndexModePre,
2506 StMiscFrm, IIC_iStore_bh_ru,
2507 "strh", "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2509 let Inst{23} = addr{8}; // U bit
2510 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2511 let Inst{19-16} = addr{12-9}; // Rn
2512 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2513 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2514 let AsmMatchConverter = "cvtStWriteBackRegAddrMode3";
2515 let DecoderMethod = "DecodeAddrMode3Instruction";
2518 def STRH_POST : AI3ldstidx<0b1011, 0, 0, (outs GPR:$Rn_wb),
2519 (ins GPR:$Rt, addr_offset_none:$addr, am3offset:$offset),
2520 IndexModePost, StMiscFrm, IIC_iStore_bh_ru,
2521 "strh", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2522 [(set GPR:$Rn_wb, (post_truncsti16 GPR:$Rt,
2523 addr_offset_none:$addr,
2524 am3offset:$offset))]> {
2527 let Inst{23} = offset{8}; // U bit
2528 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2529 let Inst{19-16} = addr;
2530 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2531 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2532 let DecoderMethod = "DecodeAddrMode3Instruction";
2535 let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in {
2536 def STRD_PRE : AI3ldstidx<0b1111, 0, 1, (outs GPR:$Rn_wb),
2537 (ins GPR:$Rt, GPR:$Rt2, addrmode3:$addr),
2538 IndexModePre, StMiscFrm, IIC_iStore_d_ru,
2539 "strd", "\t$Rt, $Rt2, $addr!",
2540 "$addr.base = $Rn_wb", []> {
2542 let Inst{23} = addr{8}; // U bit
2543 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2544 let Inst{19-16} = addr{12-9}; // Rn
2545 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2546 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2547 let DecoderMethod = "DecodeAddrMode3Instruction";
2548 let AsmMatchConverter = "cvtStrdPre";
2551 def STRD_POST: AI3ldstidx<0b1111, 0, 0, (outs GPR:$Rn_wb),
2552 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr,
2554 IndexModePost, StMiscFrm, IIC_iStore_d_ru,
2555 "strd", "\t$Rt, $Rt2, $addr, $offset",
2556 "$addr.base = $Rn_wb", []> {
2559 let Inst{23} = offset{8}; // U bit
2560 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2561 let Inst{19-16} = addr;
2562 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2563 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2564 let DecoderMethod = "DecodeAddrMode3Instruction";
2566 } // mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1
2568 // STRT, STRBT, and STRHT
2570 def STRBT_POST_REG : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2571 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2572 IndexModePost, StFrm, IIC_iStore_bh_ru,
2573 "strbt", "\t$Rt, $addr, $offset",
2574 "$addr.base = $Rn_wb", []> {
2580 let Inst{23} = offset{12};
2581 let Inst{21} = 1; // overwrite
2582 let Inst{19-16} = addr;
2583 let Inst{11-5} = offset{11-5};
2585 let Inst{3-0} = offset{3-0};
2586 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2589 def STRBT_POST_IMM : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2590 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2591 IndexModePost, StFrm, IIC_iStore_bh_ru,
2592 "strbt", "\t$Rt, $addr, $offset",
2593 "$addr.base = $Rn_wb", []> {
2599 let Inst{23} = offset{12};
2600 let Inst{21} = 1; // overwrite
2601 let Inst{19-16} = addr;
2602 let Inst{11-0} = offset{11-0};
2603 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2606 let mayStore = 1, neverHasSideEffects = 1 in {
2607 def STRT_POST_REG : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
2608 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2609 IndexModePost, StFrm, IIC_iStore_ru,
2610 "strt", "\t$Rt, $addr, $offset",
2611 "$addr.base = $Rn_wb", []> {
2617 let Inst{23} = offset{12};
2618 let Inst{21} = 1; // overwrite
2619 let Inst{19-16} = addr;
2620 let Inst{11-5} = offset{11-5};
2622 let Inst{3-0} = offset{3-0};
2623 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2626 def STRT_POST_IMM : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
2627 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2628 IndexModePost, StFrm, IIC_iStore_ru,
2629 "strt", "\t$Rt, $addr, $offset",
2630 "$addr.base = $Rn_wb", []> {
2636 let Inst{23} = offset{12};
2637 let Inst{21} = 1; // overwrite
2638 let Inst{19-16} = addr;
2639 let Inst{11-0} = offset{11-0};
2640 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2645 multiclass AI3strT<bits<4> op, string opc> {
2646 def i : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
2647 (ins GPR:$Rt, addr_offset_none:$addr, postidx_imm8:$offset),
2648 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
2649 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2651 let Inst{23} = offset{8};
2653 let Inst{11-8} = offset{7-4};
2654 let Inst{3-0} = offset{3-0};
2655 let AsmMatchConverter = "cvtStExtTWriteBackImm";
2657 def r : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
2658 (ins GPR:$Rt, addr_offset_none:$addr, postidx_reg:$Rm),
2659 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
2660 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2662 let Inst{23} = Rm{4};
2665 let Inst{3-0} = Rm{3-0};
2666 let AsmMatchConverter = "cvtStExtTWriteBackReg";
2671 defm STRHT : AI3strT<0b1011, "strht">;
2674 //===----------------------------------------------------------------------===//
2675 // Load / store multiple Instructions.
2678 multiclass arm_ldst_mult<string asm, string sfx, bit L_bit, bit P_bit, Format f,
2679 InstrItinClass itin, InstrItinClass itin_upd> {
2680 // IA is the default, so no need for an explicit suffix on the
2681 // mnemonic here. Without it is the cannonical spelling.
2683 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2684 IndexModeNone, f, itin,
2685 !strconcat(asm, "${p}\t$Rn, $regs", sfx), "", []> {
2686 let Inst{24-23} = 0b01; // Increment After
2687 let Inst{22} = P_bit;
2688 let Inst{21} = 0; // No writeback
2689 let Inst{20} = L_bit;
2692 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2693 IndexModeUpd, f, itin_upd,
2694 !strconcat(asm, "${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
2695 let Inst{24-23} = 0b01; // Increment After
2696 let Inst{22} = P_bit;
2697 let Inst{21} = 1; // Writeback
2698 let Inst{20} = L_bit;
2700 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2703 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2704 IndexModeNone, f, itin,
2705 !strconcat(asm, "da${p}\t$Rn, $regs", sfx), "", []> {
2706 let Inst{24-23} = 0b00; // Decrement After
2707 let Inst{22} = P_bit;
2708 let Inst{21} = 0; // No writeback
2709 let Inst{20} = L_bit;
2712 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2713 IndexModeUpd, f, itin_upd,
2714 !strconcat(asm, "da${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
2715 let Inst{24-23} = 0b00; // Decrement After
2716 let Inst{22} = P_bit;
2717 let Inst{21} = 1; // Writeback
2718 let Inst{20} = L_bit;
2720 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2723 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2724 IndexModeNone, f, itin,
2725 !strconcat(asm, "db${p}\t$Rn, $regs", sfx), "", []> {
2726 let Inst{24-23} = 0b10; // Decrement Before
2727 let Inst{22} = P_bit;
2728 let Inst{21} = 0; // No writeback
2729 let Inst{20} = L_bit;
2732 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2733 IndexModeUpd, f, itin_upd,
2734 !strconcat(asm, "db${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
2735 let Inst{24-23} = 0b10; // Decrement Before
2736 let Inst{22} = P_bit;
2737 let Inst{21} = 1; // Writeback
2738 let Inst{20} = L_bit;
2740 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2743 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2744 IndexModeNone, f, itin,
2745 !strconcat(asm, "ib${p}\t$Rn, $regs", sfx), "", []> {
2746 let Inst{24-23} = 0b11; // Increment Before
2747 let Inst{22} = P_bit;
2748 let Inst{21} = 0; // No writeback
2749 let Inst{20} = L_bit;
2752 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2753 IndexModeUpd, f, itin_upd,
2754 !strconcat(asm, "ib${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
2755 let Inst{24-23} = 0b11; // Increment Before
2756 let Inst{22} = P_bit;
2757 let Inst{21} = 1; // Writeback
2758 let Inst{20} = L_bit;
2760 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2764 let neverHasSideEffects = 1 in {
2766 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
2767 defm LDM : arm_ldst_mult<"ldm", "", 1, 0, LdStMulFrm, IIC_iLoad_m,
2770 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
2771 defm STM : arm_ldst_mult<"stm", "", 0, 0, LdStMulFrm, IIC_iStore_m,
2774 } // neverHasSideEffects
2776 // FIXME: remove when we have a way to marking a MI with these properties.
2777 // FIXME: Should pc be an implicit operand like PICADD, etc?
2778 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
2779 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
2780 def LDMIA_RET : ARMPseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p,
2781 reglist:$regs, variable_ops),
2782 4, IIC_iLoad_mBr, [],
2783 (LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>,
2784 RegConstraint<"$Rn = $wb">;
2786 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
2787 defm sysLDM : arm_ldst_mult<"ldm", " ^", 1, 1, LdStMulFrm, IIC_iLoad_m,
2790 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
2791 defm sysSTM : arm_ldst_mult<"stm", " ^", 0, 1, LdStMulFrm, IIC_iStore_m,
2796 //===----------------------------------------------------------------------===//
2797 // Move Instructions.
2800 let neverHasSideEffects = 1 in
2801 def MOVr : AsI1<0b1101, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMOVr,
2802 "mov", "\t$Rd, $Rm", []>, UnaryDP {
2806 let Inst{19-16} = 0b0000;
2807 let Inst{11-4} = 0b00000000;
2810 let Inst{15-12} = Rd;
2813 def : ARMInstAlias<"movs${p} $Rd, $Rm",
2814 (MOVr GPR:$Rd, GPR:$Rm, pred:$p, CPSR)>;
2816 // A version for the smaller set of tail call registers.
2817 let neverHasSideEffects = 1 in
2818 def MOVr_TC : AsI1<0b1101, (outs tcGPR:$Rd), (ins tcGPR:$Rm), DPFrm,
2819 IIC_iMOVr, "mov", "\t$Rd, $Rm", []>, UnaryDP {
2823 let Inst{11-4} = 0b00000000;
2826 let Inst{15-12} = Rd;
2829 def MOVsr : AsI1<0b1101, (outs GPRnopc:$Rd), (ins shift_so_reg_reg:$src),
2830 DPSoRegRegFrm, IIC_iMOVsr,
2831 "mov", "\t$Rd, $src",
2832 [(set GPRnopc:$Rd, shift_so_reg_reg:$src)]>, UnaryDP {
2835 let Inst{15-12} = Rd;
2836 let Inst{19-16} = 0b0000;
2837 let Inst{11-8} = src{11-8};
2839 let Inst{6-5} = src{6-5};
2841 let Inst{3-0} = src{3-0};
2845 def MOVsi : AsI1<0b1101, (outs GPR:$Rd), (ins shift_so_reg_imm:$src),
2846 DPSoRegImmFrm, IIC_iMOVsr,
2847 "mov", "\t$Rd, $src", [(set GPR:$Rd, shift_so_reg_imm:$src)]>,
2851 let Inst{15-12} = Rd;
2852 let Inst{19-16} = 0b0000;
2853 let Inst{11-5} = src{11-5};
2855 let Inst{3-0} = src{3-0};
2859 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
2860 def MOVi : AsI1<0b1101, (outs GPR:$Rd), (ins so_imm:$imm), DPFrm, IIC_iMOVi,
2861 "mov", "\t$Rd, $imm", [(set GPR:$Rd, so_imm:$imm)]>, UnaryDP {
2865 let Inst{15-12} = Rd;
2866 let Inst{19-16} = 0b0000;
2867 let Inst{11-0} = imm;
2870 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
2871 def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins imm0_65535_expr:$imm),
2873 "movw", "\t$Rd, $imm",
2874 [(set GPR:$Rd, imm0_65535:$imm)]>,
2875 Requires<[IsARM, HasV6T2]>, UnaryDP {
2878 let Inst{15-12} = Rd;
2879 let Inst{11-0} = imm{11-0};
2880 let Inst{19-16} = imm{15-12};
2883 let DecoderMethod = "DecodeArmMOVTWInstruction";
2886 def : InstAlias<"mov${p} $Rd, $imm",
2887 (MOVi16 GPR:$Rd, imm0_65535_expr:$imm, pred:$p)>,
2890 def MOVi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
2891 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>;
2893 let Constraints = "$src = $Rd" in {
2894 def MOVTi16 : AI1<0b1010, (outs GPRnopc:$Rd),
2895 (ins GPR:$src, imm0_65535_expr:$imm),
2897 "movt", "\t$Rd, $imm",
2899 (or (and GPR:$src, 0xffff),
2900 lo16AllZero:$imm))]>, UnaryDP,
2901 Requires<[IsARM, HasV6T2]> {
2904 let Inst{15-12} = Rd;
2905 let Inst{11-0} = imm{11-0};
2906 let Inst{19-16} = imm{15-12};
2909 let DecoderMethod = "DecodeArmMOVTWInstruction";
2912 def MOVTi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
2913 (ins GPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>;
2917 def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
2918 Requires<[IsARM, HasV6T2]>;
2920 let Uses = [CPSR] in
2921 def RRX: PseudoInst<(outs GPR:$Rd), (ins GPR:$Rm), IIC_iMOVsi,
2922 [(set GPR:$Rd, (ARMrrx GPR:$Rm))]>, UnaryDP,
2925 // These aren't really mov instructions, but we have to define them this way
2926 // due to flag operands.
2928 let Defs = [CPSR] in {
2929 def MOVsrl_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
2930 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP,
2932 def MOVsra_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
2933 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP,
2937 //===----------------------------------------------------------------------===//
2938 // Extend Instructions.
2943 def SXTB : AI_ext_rrot<0b01101010,
2944 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
2945 def SXTH : AI_ext_rrot<0b01101011,
2946 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
2948 def SXTAB : AI_exta_rrot<0b01101010,
2949 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
2950 def SXTAH : AI_exta_rrot<0b01101011,
2951 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
2953 def SXTB16 : AI_ext_rrot_np<0b01101000, "sxtb16">;
2955 def SXTAB16 : AI_exta_rrot_np<0b01101000, "sxtab16">;
2959 let AddedComplexity = 16 in {
2960 def UXTB : AI_ext_rrot<0b01101110,
2961 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
2962 def UXTH : AI_ext_rrot<0b01101111,
2963 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
2964 def UXTB16 : AI_ext_rrot<0b01101100,
2965 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
2967 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
2968 // The transformation should probably be done as a combiner action
2969 // instead so we can include a check for masking back in the upper
2970 // eight bits of the source into the lower eight bits of the result.
2971 //def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
2972 // (UXTB16r_rot GPR:$Src, 3)>;
2973 def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
2974 (UXTB16 GPR:$Src, 1)>;
2976 def UXTAB : AI_exta_rrot<0b01101110, "uxtab",
2977 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
2978 def UXTAH : AI_exta_rrot<0b01101111, "uxtah",
2979 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
2982 // This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
2983 def UXTAB16 : AI_exta_rrot_np<0b01101100, "uxtab16">;
2986 def SBFX : I<(outs GPRnopc:$Rd),
2987 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
2988 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
2989 "sbfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
2990 Requires<[IsARM, HasV6T2]> {
2995 let Inst{27-21} = 0b0111101;
2996 let Inst{6-4} = 0b101;
2997 let Inst{20-16} = width;
2998 let Inst{15-12} = Rd;
2999 let Inst{11-7} = lsb;
3003 def UBFX : I<(outs GPR:$Rd),
3004 (ins GPR:$Rn, imm0_31:$lsb, imm1_32:$width),
3005 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3006 "ubfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3007 Requires<[IsARM, HasV6T2]> {
3012 let Inst{27-21} = 0b0111111;
3013 let Inst{6-4} = 0b101;
3014 let Inst{20-16} = width;
3015 let Inst{15-12} = Rd;
3016 let Inst{11-7} = lsb;
3020 //===----------------------------------------------------------------------===//
3021 // Arithmetic Instructions.
3024 defm ADD : AsI1_bin_irs<0b0100, "add",
3025 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3026 BinOpFrag<(add node:$LHS, node:$RHS)>, "ADD", 1>;
3027 defm SUB : AsI1_bin_irs<0b0010, "sub",
3028 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3029 BinOpFrag<(sub node:$LHS, node:$RHS)>, "SUB">;
3031 // ADD and SUB with 's' bit set.
3033 // Currently, ADDS/SUBS are pseudo opcodes that exist only in the
3034 // selection DAG. They are "lowered" to real ADD/SUB opcodes by
3035 // AdjustInstrPostInstrSelection where we determine whether or not to
3036 // set the "s" bit based on CPSR liveness.
3038 // FIXME: Eliminate ADDS/SUBS pseudo opcodes after adding tablegen
3039 // support for an optional CPSR definition that corresponds to the DAG
3040 // node's second value. We can then eliminate the implicit def of CPSR.
3041 defm ADDS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3042 BinOpFrag<(ARMaddc node:$LHS, node:$RHS)>, 1>;
3043 defm SUBS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3044 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
3046 defm ADC : AI1_adde_sube_irs<0b0101, "adc",
3047 BinOpWithFlagFrag<(ARMadde node:$LHS, node:$RHS, node:$FLAG)>,
3049 defm SBC : AI1_adde_sube_irs<0b0110, "sbc",
3050 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>,
3053 defm RSB : AsI1_rbin_irs <0b0011, "rsb",
3054 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3055 BinOpFrag<(sub node:$LHS, node:$RHS)>, "RSB">;
3057 // FIXME: Eliminate them if we can write def : Pat patterns which defines
3058 // CPSR and the implicit def of CPSR is not needed.
3059 defm RSBS : AsI1_rbin_s_is<IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3060 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
3062 defm RSC : AI1_rsc_irs<0b0111, "rsc",
3063 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>,
3066 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
3067 // The assume-no-carry-in form uses the negation of the input since add/sub
3068 // assume opposite meanings of the carry flag (i.e., carry == !borrow).
3069 // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
3071 def : ARMPat<(add GPR:$src, so_imm_neg:$imm),
3072 (SUBri GPR:$src, so_imm_neg:$imm)>;
3073 def : ARMPat<(ARMaddc GPR:$src, so_imm_neg:$imm),
3074 (SUBSri GPR:$src, so_imm_neg:$imm)>;
3076 // The with-carry-in form matches bitwise not instead of the negation.
3077 // Effectively, the inverse interpretation of the carry flag already accounts
3078 // for part of the negation.
3079 def : ARMPat<(ARMadde GPR:$src, so_imm_not:$imm, CPSR),
3080 (SBCri GPR:$src, so_imm_not:$imm)>;
3082 // Note: These are implemented in C++ code, because they have to generate
3083 // ADD/SUBrs instructions, which use a complex pattern that a xform function
3085 // (mul X, 2^n+1) -> (add (X << n), X)
3086 // (mul X, 2^n-1) -> (rsb X, (X << n))
3088 // ARM Arithmetic Instruction
3089 // GPR:$dst = GPR:$a op GPR:$b
3090 class AAI<bits<8> op27_20, bits<8> op11_4, string opc,
3091 list<dag> pattern = [],
3092 dag iops = (ins GPRnopc:$Rn, GPRnopc:$Rm),
3093 string asm = "\t$Rd, $Rn, $Rm">
3094 : AI<(outs GPRnopc:$Rd), iops, DPFrm, IIC_iALUr, opc, asm, pattern> {
3098 let Inst{27-20} = op27_20;
3099 let Inst{11-4} = op11_4;
3100 let Inst{19-16} = Rn;
3101 let Inst{15-12} = Rd;
3104 let Unpredictable{11-8} = 0b1111;
3107 // Saturating add/subtract
3109 def QADD : AAI<0b00010000, 0b00000101, "qadd",
3110 [(set GPRnopc:$Rd, (int_arm_qadd GPRnopc:$Rm, GPRnopc:$Rn))],
3111 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3112 def QSUB : AAI<0b00010010, 0b00000101, "qsub",
3113 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm, GPRnopc:$Rn))],
3114 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3115 def QDADD : AAI<0b00010100, 0b00000101, "qdadd", [],
3116 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3118 def QDSUB : AAI<0b00010110, 0b00000101, "qdsub", [],
3119 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3122 def QADD16 : AAI<0b01100010, 0b11110001, "qadd16">;
3123 def QADD8 : AAI<0b01100010, 0b11111001, "qadd8">;
3124 def QASX : AAI<0b01100010, 0b11110011, "qasx">;
3125 def QSAX : AAI<0b01100010, 0b11110101, "qsax">;
3126 def QSUB16 : AAI<0b01100010, 0b11110111, "qsub16">;
3127 def QSUB8 : AAI<0b01100010, 0b11111111, "qsub8">;
3128 def UQADD16 : AAI<0b01100110, 0b11110001, "uqadd16">;
3129 def UQADD8 : AAI<0b01100110, 0b11111001, "uqadd8">;
3130 def UQASX : AAI<0b01100110, 0b11110011, "uqasx">;
3131 def UQSAX : AAI<0b01100110, 0b11110101, "uqsax">;
3132 def UQSUB16 : AAI<0b01100110, 0b11110111, "uqsub16">;
3133 def UQSUB8 : AAI<0b01100110, 0b11111111, "uqsub8">;
3135 // Signed/Unsigned add/subtract
3137 def SASX : AAI<0b01100001, 0b11110011, "sasx">;
3138 def SADD16 : AAI<0b01100001, 0b11110001, "sadd16">;
3139 def SADD8 : AAI<0b01100001, 0b11111001, "sadd8">;
3140 def SSAX : AAI<0b01100001, 0b11110101, "ssax">;
3141 def SSUB16 : AAI<0b01100001, 0b11110111, "ssub16">;
3142 def SSUB8 : AAI<0b01100001, 0b11111111, "ssub8">;
3143 def UASX : AAI<0b01100101, 0b11110011, "uasx">;
3144 def UADD16 : AAI<0b01100101, 0b11110001, "uadd16">;
3145 def UADD8 : AAI<0b01100101, 0b11111001, "uadd8">;
3146 def USAX : AAI<0b01100101, 0b11110101, "usax">;
3147 def USUB16 : AAI<0b01100101, 0b11110111, "usub16">;
3148 def USUB8 : AAI<0b01100101, 0b11111111, "usub8">;
3150 // Signed/Unsigned halving add/subtract
3152 def SHASX : AAI<0b01100011, 0b11110011, "shasx">;
3153 def SHADD16 : AAI<0b01100011, 0b11110001, "shadd16">;
3154 def SHADD8 : AAI<0b01100011, 0b11111001, "shadd8">;
3155 def SHSAX : AAI<0b01100011, 0b11110101, "shsax">;
3156 def SHSUB16 : AAI<0b01100011, 0b11110111, "shsub16">;
3157 def SHSUB8 : AAI<0b01100011, 0b11111111, "shsub8">;
3158 def UHASX : AAI<0b01100111, 0b11110011, "uhasx">;
3159 def UHADD16 : AAI<0b01100111, 0b11110001, "uhadd16">;
3160 def UHADD8 : AAI<0b01100111, 0b11111001, "uhadd8">;
3161 def UHSAX : AAI<0b01100111, 0b11110101, "uhsax">;
3162 def UHSUB16 : AAI<0b01100111, 0b11110111, "uhsub16">;
3163 def UHSUB8 : AAI<0b01100111, 0b11111111, "uhsub8">;
3165 // Unsigned Sum of Absolute Differences [and Accumulate].
3167 def USAD8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3168 MulFrm /* for convenience */, NoItinerary, "usad8",
3169 "\t$Rd, $Rn, $Rm", []>,
3170 Requires<[IsARM, HasV6]> {
3174 let Inst{27-20} = 0b01111000;
3175 let Inst{15-12} = 0b1111;
3176 let Inst{7-4} = 0b0001;
3177 let Inst{19-16} = Rd;
3178 let Inst{11-8} = Rm;
3181 def USADA8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3182 MulFrm /* for convenience */, NoItinerary, "usada8",
3183 "\t$Rd, $Rn, $Rm, $Ra", []>,
3184 Requires<[IsARM, HasV6]> {
3189 let Inst{27-20} = 0b01111000;
3190 let Inst{7-4} = 0b0001;
3191 let Inst{19-16} = Rd;
3192 let Inst{15-12} = Ra;
3193 let Inst{11-8} = Rm;
3197 // Signed/Unsigned saturate
3199 def SSAT : AI<(outs GPRnopc:$Rd),
3200 (ins imm1_32:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3201 SatFrm, NoItinerary, "ssat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3206 let Inst{27-21} = 0b0110101;
3207 let Inst{5-4} = 0b01;
3208 let Inst{20-16} = sat_imm;
3209 let Inst{15-12} = Rd;
3210 let Inst{11-7} = sh{4-0};
3211 let Inst{6} = sh{5};
3215 def SSAT16 : AI<(outs GPRnopc:$Rd),
3216 (ins imm1_16:$sat_imm, GPRnopc:$Rn), SatFrm,
3217 NoItinerary, "ssat16", "\t$Rd, $sat_imm, $Rn", []> {
3221 let Inst{27-20} = 0b01101010;
3222 let Inst{11-4} = 0b11110011;
3223 let Inst{15-12} = Rd;
3224 let Inst{19-16} = sat_imm;
3228 def USAT : AI<(outs GPRnopc:$Rd),
3229 (ins imm0_31:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3230 SatFrm, NoItinerary, "usat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3235 let Inst{27-21} = 0b0110111;
3236 let Inst{5-4} = 0b01;
3237 let Inst{15-12} = Rd;
3238 let Inst{11-7} = sh{4-0};
3239 let Inst{6} = sh{5};
3240 let Inst{20-16} = sat_imm;
3244 def USAT16 : AI<(outs GPRnopc:$Rd),
3245 (ins imm0_15:$sat_imm, GPRnopc:$Rn), SatFrm,
3246 NoItinerary, "usat16", "\t$Rd, $sat_imm, $Rn", []> {
3250 let Inst{27-20} = 0b01101110;
3251 let Inst{11-4} = 0b11110011;
3252 let Inst{15-12} = Rd;
3253 let Inst{19-16} = sat_imm;
3257 def : ARMV6Pat<(int_arm_ssat GPRnopc:$a, imm:$pos),
3258 (SSAT imm:$pos, GPRnopc:$a, 0)>;
3259 def : ARMV6Pat<(int_arm_usat GPRnopc:$a, imm:$pos),
3260 (USAT imm:$pos, GPRnopc:$a, 0)>;
3262 //===----------------------------------------------------------------------===//
3263 // Bitwise Instructions.
3266 defm AND : AsI1_bin_irs<0b0000, "and",
3267 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3268 BinOpFrag<(and node:$LHS, node:$RHS)>, "AND", 1>;
3269 defm ORR : AsI1_bin_irs<0b1100, "orr",
3270 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3271 BinOpFrag<(or node:$LHS, node:$RHS)>, "ORR", 1>;
3272 defm EOR : AsI1_bin_irs<0b0001, "eor",
3273 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3274 BinOpFrag<(xor node:$LHS, node:$RHS)>, "EOR", 1>;
3275 defm BIC : AsI1_bin_irs<0b1110, "bic",
3276 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3277 BinOpFrag<(and node:$LHS, (not node:$RHS))>, "BIC">;
3279 // FIXME: bf_inv_mask_imm should be two operands, the lsb and the msb, just
3280 // like in the actual instruction encoding. The complexity of mapping the mask
3281 // to the lsb/msb pair should be handled by ISel, not encapsulated in the
3282 // instruction description.
3283 def BFC : I<(outs GPR:$Rd), (ins GPR:$src, bf_inv_mask_imm:$imm),
3284 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3285 "bfc", "\t$Rd, $imm", "$src = $Rd",
3286 [(set GPR:$Rd, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
3287 Requires<[IsARM, HasV6T2]> {
3290 let Inst{27-21} = 0b0111110;
3291 let Inst{6-0} = 0b0011111;
3292 let Inst{15-12} = Rd;
3293 let Inst{11-7} = imm{4-0}; // lsb
3294 let Inst{20-16} = imm{9-5}; // msb
3297 // A8.6.18 BFI - Bitfield insert (Encoding A1)
3298 def BFI:I<(outs GPRnopc:$Rd), (ins GPRnopc:$src, GPR:$Rn, bf_inv_mask_imm:$imm),
3299 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3300 "bfi", "\t$Rd, $Rn, $imm", "$src = $Rd",
3301 [(set GPRnopc:$Rd, (ARMbfi GPRnopc:$src, GPR:$Rn,
3302 bf_inv_mask_imm:$imm))]>,
3303 Requires<[IsARM, HasV6T2]> {
3307 let Inst{27-21} = 0b0111110;
3308 let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15
3309 let Inst{15-12} = Rd;
3310 let Inst{11-7} = imm{4-0}; // lsb
3311 let Inst{20-16} = imm{9-5}; // width
3315 def MVNr : AsI1<0b1111, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMVNr,
3316 "mvn", "\t$Rd, $Rm",
3317 [(set GPR:$Rd, (not GPR:$Rm))]>, UnaryDP {
3321 let Inst{19-16} = 0b0000;
3322 let Inst{11-4} = 0b00000000;
3323 let Inst{15-12} = Rd;
3326 def MVNsi : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_imm:$shift),
3327 DPSoRegImmFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3328 [(set GPR:$Rd, (not so_reg_imm:$shift))]>, UnaryDP {
3332 let Inst{19-16} = 0b0000;
3333 let Inst{15-12} = Rd;
3334 let Inst{11-5} = shift{11-5};
3336 let Inst{3-0} = shift{3-0};
3338 def MVNsr : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_reg:$shift),
3339 DPSoRegRegFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3340 [(set GPR:$Rd, (not so_reg_reg:$shift))]>, UnaryDP {
3344 let Inst{19-16} = 0b0000;
3345 let Inst{15-12} = Rd;
3346 let Inst{11-8} = shift{11-8};
3348 let Inst{6-5} = shift{6-5};
3350 let Inst{3-0} = shift{3-0};
3352 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3353 def MVNi : AsI1<0b1111, (outs GPR:$Rd), (ins so_imm:$imm), DPFrm,
3354 IIC_iMVNi, "mvn", "\t$Rd, $imm",
3355 [(set GPR:$Rd, so_imm_not:$imm)]>,UnaryDP {
3359 let Inst{19-16} = 0b0000;
3360 let Inst{15-12} = Rd;
3361 let Inst{11-0} = imm;
3364 def : ARMPat<(and GPR:$src, so_imm_not:$imm),
3365 (BICri GPR:$src, so_imm_not:$imm)>;
3367 //===----------------------------------------------------------------------===//
3368 // Multiply Instructions.
3370 class AsMul1I32<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3371 string opc, string asm, list<dag> pattern>
3372 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3376 let Inst{19-16} = Rd;
3377 let Inst{11-8} = Rm;
3380 class AsMul1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3381 string opc, string asm, list<dag> pattern>
3382 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3387 let Inst{19-16} = RdHi;
3388 let Inst{15-12} = RdLo;
3389 let Inst{11-8} = Rm;
3393 // FIXME: The v5 pseudos are only necessary for the additional Constraint
3394 // property. Remove them when it's possible to add those properties
3395 // on an individual MachineInstr, not just an instuction description.
3396 let isCommutable = 1, TwoOperandAliasConstraint = "$Rn = $Rd" in {
3397 def MUL : AsMul1I32<0b0000000, (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm),
3398 IIC_iMUL32, "mul", "\t$Rd, $Rn, $Rm",
3399 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))]>,
3400 Requires<[IsARM, HasV6]> {
3401 let Inst{15-12} = 0b0000;
3402 let Unpredictable{15-12} = 0b1111;
3405 let Constraints = "@earlyclobber $Rd" in
3406 def MULv5: ARMPseudoExpand<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm,
3407 pred:$p, cc_out:$s),
3409 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))],
3410 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s)>,
3411 Requires<[IsARM, NoV6]>;
3414 def MLA : AsMul1I32<0b0000001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3415 IIC_iMAC32, "mla", "\t$Rd, $Rn, $Rm, $Ra",
3416 [(set GPR:$Rd, (add (mul GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
3417 Requires<[IsARM, HasV6]> {
3419 let Inst{15-12} = Ra;
3422 let Constraints = "@earlyclobber $Rd" in
3423 def MLAv5: ARMPseudoExpand<(outs GPR:$Rd),
3424 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra, pred:$p, cc_out:$s),
3426 [(set GPR:$Rd, (add (mul GPR:$Rn, GPR:$Rm), GPR:$Ra))],
3427 (MLA GPR:$Rd, GPR:$Rn, GPR:$Rm, GPR:$Ra, pred:$p, cc_out:$s)>,
3428 Requires<[IsARM, NoV6]>;
3430 def MLS : AMul1I<0b0000011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3431 IIC_iMAC32, "mls", "\t$Rd, $Rn, $Rm, $Ra",
3432 [(set GPR:$Rd, (sub GPR:$Ra, (mul GPR:$Rn, GPR:$Rm)))]>,
3433 Requires<[IsARM, HasV6T2]> {
3438 let Inst{19-16} = Rd;
3439 let Inst{15-12} = Ra;
3440 let Inst{11-8} = Rm;
3444 // Extra precision multiplies with low / high results
3445 let neverHasSideEffects = 1 in {
3446 let isCommutable = 1 in {
3447 def SMULL : AsMul1I64<0b0000110, (outs GPR:$RdLo, GPR:$RdHi),
3448 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3449 "smull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3450 Requires<[IsARM, HasV6]>;
3452 def UMULL : AsMul1I64<0b0000100, (outs GPR:$RdLo, GPR:$RdHi),
3453 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3454 "umull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3455 Requires<[IsARM, HasV6]>;
3457 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
3458 def SMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3459 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3461 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3462 Requires<[IsARM, NoV6]>;
3464 def UMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3465 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3467 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3468 Requires<[IsARM, NoV6]>;
3472 // Multiply + accumulate
3473 def SMLAL : AsMul1I64<0b0000111, (outs GPR:$RdLo, GPR:$RdHi),
3474 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3475 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3476 Requires<[IsARM, HasV6]>;
3477 def UMLAL : AsMul1I64<0b0000101, (outs GPR:$RdLo, GPR:$RdHi),
3478 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3479 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3480 Requires<[IsARM, HasV6]>;
3482 def UMAAL : AMul1I <0b0000010, (outs GPR:$RdLo, GPR:$RdHi),
3483 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3484 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3485 Requires<[IsARM, HasV6]> {
3490 let Inst{19-16} = RdHi;
3491 let Inst{15-12} = RdLo;
3492 let Inst{11-8} = Rm;
3496 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
3497 def SMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3498 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3500 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3501 Requires<[IsARM, NoV6]>;
3502 def UMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3503 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3505 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3506 Requires<[IsARM, NoV6]>;
3507 def UMAALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3508 (ins GPR:$Rn, GPR:$Rm, pred:$p),
3510 (UMAAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p)>,
3511 Requires<[IsARM, NoV6]>;
3514 } // neverHasSideEffects
3516 // Most significant word multiply
3517 def SMMUL : AMul2I <0b0111010, 0b0001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3518 IIC_iMUL32, "smmul", "\t$Rd, $Rn, $Rm",
3519 [(set GPR:$Rd, (mulhs GPR:$Rn, GPR:$Rm))]>,
3520 Requires<[IsARM, HasV6]> {
3521 let Inst{15-12} = 0b1111;
3524 def SMMULR : AMul2I <0b0111010, 0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3525 IIC_iMUL32, "smmulr", "\t$Rd, $Rn, $Rm", []>,
3526 Requires<[IsARM, HasV6]> {
3527 let Inst{15-12} = 0b1111;
3530 def SMMLA : AMul2Ia <0b0111010, 0b0001, (outs GPR:$Rd),
3531 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3532 IIC_iMAC32, "smmla", "\t$Rd, $Rn, $Rm, $Ra",
3533 [(set GPR:$Rd, (add (mulhs GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
3534 Requires<[IsARM, HasV6]>;
3536 def SMMLAR : AMul2Ia <0b0111010, 0b0011, (outs GPR:$Rd),
3537 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3538 IIC_iMAC32, "smmlar", "\t$Rd, $Rn, $Rm, $Ra", []>,
3539 Requires<[IsARM, HasV6]>;
3541 def SMMLS : AMul2Ia <0b0111010, 0b1101, (outs GPR:$Rd),
3542 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3543 IIC_iMAC32, "smmls", "\t$Rd, $Rn, $Rm, $Ra",
3544 [(set GPR:$Rd, (sub GPR:$Ra, (mulhs GPR:$Rn, GPR:$Rm)))]>,
3545 Requires<[IsARM, HasV6]>;
3547 def SMMLSR : AMul2Ia <0b0111010, 0b1111, (outs GPR:$Rd),
3548 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3549 IIC_iMAC32, "smmlsr", "\t$Rd, $Rn, $Rm, $Ra", []>,
3550 Requires<[IsARM, HasV6]>;
3552 multiclass AI_smul<string opc, PatFrag opnode> {
3553 def BB : AMulxyI<0b0001011, 0b00, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3554 IIC_iMUL16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm",
3555 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3556 (sext_inreg GPR:$Rm, i16)))]>,
3557 Requires<[IsARM, HasV5TE]>;
3559 def BT : AMulxyI<0b0001011, 0b10, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3560 IIC_iMUL16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm",
3561 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3562 (sra GPR:$Rm, (i32 16))))]>,
3563 Requires<[IsARM, HasV5TE]>;
3565 def TB : AMulxyI<0b0001011, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3566 IIC_iMUL16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm",
3567 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3568 (sext_inreg GPR:$Rm, i16)))]>,
3569 Requires<[IsARM, HasV5TE]>;
3571 def TT : AMulxyI<0b0001011, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3572 IIC_iMUL16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm",
3573 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3574 (sra GPR:$Rm, (i32 16))))]>,
3575 Requires<[IsARM, HasV5TE]>;
3577 def WB : AMulxyI<0b0001001, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3578 IIC_iMUL16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm",
3579 [(set GPR:$Rd, (sra (opnode GPR:$Rn,
3580 (sext_inreg GPR:$Rm, i16)), (i32 16)))]>,
3581 Requires<[IsARM, HasV5TE]>;
3583 def WT : AMulxyI<0b0001001, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3584 IIC_iMUL16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm",
3585 [(set GPR:$Rd, (sra (opnode GPR:$Rn,
3586 (sra GPR:$Rm, (i32 16))), (i32 16)))]>,
3587 Requires<[IsARM, HasV5TE]>;
3591 multiclass AI_smla<string opc, PatFrag opnode> {
3592 let DecoderMethod = "DecodeSMLAInstruction" in {
3593 def BB : AMulxyIa<0b0001000, 0b00, (outs GPRnopc:$Rd),
3594 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3595 IIC_iMAC16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra",
3596 [(set GPRnopc:$Rd, (add GPR:$Ra,
3597 (opnode (sext_inreg GPRnopc:$Rn, i16),
3598 (sext_inreg GPRnopc:$Rm, i16))))]>,
3599 Requires<[IsARM, HasV5TE]>;
3601 def BT : AMulxyIa<0b0001000, 0b10, (outs GPRnopc:$Rd),
3602 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3603 IIC_iMAC16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra",
3605 (add GPR:$Ra, (opnode (sext_inreg GPRnopc:$Rn, i16),
3606 (sra GPRnopc:$Rm, (i32 16)))))]>,
3607 Requires<[IsARM, HasV5TE]>;
3609 def TB : AMulxyIa<0b0001000, 0b01, (outs GPRnopc:$Rd),
3610 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3611 IIC_iMAC16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra",
3613 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
3614 (sext_inreg GPRnopc:$Rm, i16))))]>,
3615 Requires<[IsARM, HasV5TE]>;
3617 def TT : AMulxyIa<0b0001000, 0b11, (outs GPRnopc:$Rd),
3618 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3619 IIC_iMAC16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra",
3621 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
3622 (sra GPRnopc:$Rm, (i32 16)))))]>,
3623 Requires<[IsARM, HasV5TE]>;
3625 def WB : AMulxyIa<0b0001001, 0b00, (outs GPRnopc:$Rd),
3626 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3627 IIC_iMAC16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra",
3629 (add GPR:$Ra, (sra (opnode GPRnopc:$Rn,
3630 (sext_inreg GPRnopc:$Rm, i16)), (i32 16))))]>,
3631 Requires<[IsARM, HasV5TE]>;
3633 def WT : AMulxyIa<0b0001001, 0b10, (outs GPRnopc:$Rd),
3634 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3635 IIC_iMAC16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra",
3637 (add GPR:$Ra, (sra (opnode GPRnopc:$Rn,
3638 (sra GPRnopc:$Rm, (i32 16))), (i32 16))))]>,
3639 Requires<[IsARM, HasV5TE]>;
3643 defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
3644 defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
3646 // Halfword multiply accumulate long: SMLAL<x><y>.
3647 def SMLALBB : AMulxyI64<0b0001010, 0b00, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3648 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3649 IIC_iMAC64, "smlalbb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3650 Requires<[IsARM, HasV5TE]>;
3652 def SMLALBT : AMulxyI64<0b0001010, 0b10, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3653 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3654 IIC_iMAC64, "smlalbt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3655 Requires<[IsARM, HasV5TE]>;
3657 def SMLALTB : AMulxyI64<0b0001010, 0b01, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3658 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3659 IIC_iMAC64, "smlaltb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3660 Requires<[IsARM, HasV5TE]>;
3662 def SMLALTT : AMulxyI64<0b0001010, 0b11, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3663 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3664 IIC_iMAC64, "smlaltt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3665 Requires<[IsARM, HasV5TE]>;
3667 // Helper class for AI_smld.
3668 class AMulDualIbase<bit long, bit sub, bit swap, dag oops, dag iops,
3669 InstrItinClass itin, string opc, string asm>
3670 : AI<oops, iops, MulFrm, itin, opc, asm, []>, Requires<[IsARM, HasV6]> {
3673 let Inst{27-23} = 0b01110;
3674 let Inst{22} = long;
3675 let Inst{21-20} = 0b00;
3676 let Inst{11-8} = Rm;
3683 class AMulDualI<bit long, bit sub, bit swap, dag oops, dag iops,
3684 InstrItinClass itin, string opc, string asm>
3685 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
3687 let Inst{15-12} = 0b1111;
3688 let Inst{19-16} = Rd;
3690 class AMulDualIa<bit long, bit sub, bit swap, dag oops, dag iops,
3691 InstrItinClass itin, string opc, string asm>
3692 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
3695 let Inst{19-16} = Rd;
3696 let Inst{15-12} = Ra;
3698 class AMulDualI64<bit long, bit sub, bit swap, dag oops, dag iops,
3699 InstrItinClass itin, string opc, string asm>
3700 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
3703 let Inst{19-16} = RdHi;
3704 let Inst{15-12} = RdLo;
3707 multiclass AI_smld<bit sub, string opc> {
3709 def D : AMulDualIa<0, sub, 0, (outs GPRnopc:$Rd),
3710 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3711 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm, $Ra">;
3713 def DX: AMulDualIa<0, sub, 1, (outs GPRnopc:$Rd),
3714 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3715 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm, $Ra">;
3717 def LD: AMulDualI64<1, sub, 0, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3718 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
3719 !strconcat(opc, "ld"), "\t$RdLo, $RdHi, $Rn, $Rm">;
3721 def LDX : AMulDualI64<1, sub, 1, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3722 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
3723 !strconcat(opc, "ldx"),"\t$RdLo, $RdHi, $Rn, $Rm">;
3727 defm SMLA : AI_smld<0, "smla">;
3728 defm SMLS : AI_smld<1, "smls">;
3730 multiclass AI_sdml<bit sub, string opc> {
3732 def D:AMulDualI<0, sub, 0, (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm),
3733 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm">;
3734 def DX:AMulDualI<0, sub, 1, (outs GPRnopc:$Rd),(ins GPRnopc:$Rn, GPRnopc:$Rm),
3735 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm">;
3738 defm SMUA : AI_sdml<0, "smua">;
3739 defm SMUS : AI_sdml<1, "smus">;
3741 //===----------------------------------------------------------------------===//
3742 // Misc. Arithmetic Instructions.
3745 def CLZ : AMiscA1I<0b000010110, 0b0001, (outs GPR:$Rd), (ins GPR:$Rm),
3746 IIC_iUNAr, "clz", "\t$Rd, $Rm",
3747 [(set GPR:$Rd, (ctlz GPR:$Rm))]>, Requires<[IsARM, HasV5T]>;
3749 def RBIT : AMiscA1I<0b01101111, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
3750 IIC_iUNAr, "rbit", "\t$Rd, $Rm",
3751 [(set GPR:$Rd, (ARMrbit GPR:$Rm))]>,
3752 Requires<[IsARM, HasV6T2]>;
3754 def REV : AMiscA1I<0b01101011, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
3755 IIC_iUNAr, "rev", "\t$Rd, $Rm",
3756 [(set GPR:$Rd, (bswap GPR:$Rm))]>, Requires<[IsARM, HasV6]>;
3758 let AddedComplexity = 5 in
3759 def REV16 : AMiscA1I<0b01101011, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
3760 IIC_iUNAr, "rev16", "\t$Rd, $Rm",
3761 [(set GPR:$Rd, (rotr (bswap GPR:$Rm), (i32 16)))]>,
3762 Requires<[IsARM, HasV6]>;
3764 let AddedComplexity = 5 in
3765 def REVSH : AMiscA1I<0b01101111, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
3766 IIC_iUNAr, "revsh", "\t$Rd, $Rm",
3767 [(set GPR:$Rd, (sra (bswap GPR:$Rm), (i32 16)))]>,
3768 Requires<[IsARM, HasV6]>;
3770 def : ARMV6Pat<(or (sra (shl GPR:$Rm, (i32 24)), (i32 16)),
3771 (and (srl GPR:$Rm, (i32 8)), 0xFF)),
3774 def PKHBT : APKHI<0b01101000, 0, (outs GPRnopc:$Rd),
3775 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_lsl_amt:$sh),
3776 IIC_iALUsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh",
3777 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF),
3778 (and (shl GPRnopc:$Rm, pkh_lsl_amt:$sh),
3780 Requires<[IsARM, HasV6]>;
3782 // Alternate cases for PKHBT where identities eliminate some nodes.
3783 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (and GPRnopc:$Rm, 0xFFFF0000)),
3784 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, 0)>;
3785 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (shl GPRnopc:$Rm, imm16_31:$sh)),
3786 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, imm16_31:$sh)>;
3788 // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
3789 // will match the pattern below.
3790 def PKHTB : APKHI<0b01101000, 1, (outs GPRnopc:$Rd),
3791 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_asr_amt:$sh),
3792 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh",
3793 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF0000),
3794 (and (sra GPRnopc:$Rm, pkh_asr_amt:$sh),
3796 Requires<[IsARM, HasV6]>;
3798 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
3799 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
3800 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
3801 (srl GPRnopc:$src2, imm16_31:$sh)),
3802 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16_31:$sh)>;
3803 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
3804 (and (srl GPRnopc:$src2, imm1_15:$sh), 0xFFFF)),
3805 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm1_15:$sh)>;
3807 //===----------------------------------------------------------------------===//
3808 // Comparison Instructions...
3811 defm CMP : AI1_cmp_irs<0b1010, "cmp",
3812 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
3813 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
3815 // ARMcmpZ can re-use the above instruction definitions.
3816 def : ARMPat<(ARMcmpZ GPR:$src, so_imm:$imm),
3817 (CMPri GPR:$src, so_imm:$imm)>;
3818 def : ARMPat<(ARMcmpZ GPR:$src, GPR:$rhs),
3819 (CMPrr GPR:$src, GPR:$rhs)>;
3820 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_imm:$rhs),
3821 (CMPrsi GPR:$src, so_reg_imm:$rhs)>;
3822 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_reg:$rhs),
3823 (CMPrsr GPR:$src, so_reg_reg:$rhs)>;
3825 // FIXME: We have to be careful when using the CMN instruction and comparison
3826 // with 0. One would expect these two pieces of code should give identical
3842 // However, the CMN gives the *opposite* result when r1 is 0. This is because
3843 // the carry flag is set in the CMP case but not in the CMN case. In short, the
3844 // CMP instruction doesn't perform a truncate of the (logical) NOT of 0 plus the
3845 // value of r0 and the carry bit (because the "carry bit" parameter to
3846 // AddWithCarry is defined as 1 in this case, the carry flag will always be set
3847 // when r0 >= 0). The CMN instruction doesn't perform a NOT of 0 so there is
3848 // never a "carry" when this AddWithCarry is performed (because the "carry bit"
3849 // parameter to AddWithCarry is defined as 0).
3851 // When x is 0 and unsigned:
3855 // ~x + 1 = 0x1 0000 0000
3856 // (-x = 0) != (0x1 0000 0000 = ~x + 1)
3858 // Therefore, we should disable CMN when comparing against zero, until we can
3859 // limit when the CMN instruction is used (when we know that the RHS is not 0 or
3860 // when it's a comparison which doesn't look at the 'carry' flag).
3862 // (See the ARM docs for the "AddWithCarry" pseudo-code.)
3864 // This is related to <rdar://problem/7569620>.
3866 //defm CMN : AI1_cmp_irs<0b1011, "cmn",
3867 // BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>;
3869 // Note that TST/TEQ don't set all the same flags that CMP does!
3870 defm TST : AI1_cmp_irs<0b1000, "tst",
3871 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
3872 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>, 1>;
3873 defm TEQ : AI1_cmp_irs<0b1001, "teq",
3874 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
3875 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>, 1>;
3877 defm CMNz : AI1_cmp_irs<0b1011, "cmn",
3878 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
3879 BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>>;
3881 //def : ARMPat<(ARMcmp GPR:$src, so_imm_neg:$imm),
3882 // (CMNri GPR:$src, so_imm_neg:$imm)>;
3884 def : ARMPat<(ARMcmpZ GPR:$src, so_imm_neg:$imm),
3885 (CMNzri GPR:$src, so_imm_neg:$imm)>;
3887 // Pseudo i64 compares for some floating point compares.
3888 let usesCustomInserter = 1, isBranch = 1, isTerminator = 1,
3890 def BCCi64 : PseudoInst<(outs),
3891 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, brtarget:$dst),
3893 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, bb:$dst)]>;
3895 def BCCZi64 : PseudoInst<(outs),
3896 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, brtarget:$dst), IIC_Br,
3897 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, 0, 0, bb:$dst)]>;
3898 } // usesCustomInserter
3901 // Conditional moves
3902 // FIXME: should be able to write a pattern for ARMcmov, but can't use
3903 // a two-value operand where a dag node expects two operands. :(
3904 let neverHasSideEffects = 1 in {
3906 let isCommutable = 1 in
3907 def MOVCCr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$false, GPR:$Rm, pred:$p),
3909 [/*(set GPR:$Rd, (ARMcmov GPR:$false, GPR:$Rm, imm:$cc, CCR:$ccr))*/]>,
3910 RegConstraint<"$false = $Rd">;
3912 def MOVCCsi : ARMPseudoInst<(outs GPR:$Rd),
3913 (ins GPR:$false, so_reg_imm:$shift, pred:$p),
3915 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_imm:$shift,
3916 imm:$cc, CCR:$ccr))*/]>,
3917 RegConstraint<"$false = $Rd">;
3918 def MOVCCsr : ARMPseudoInst<(outs GPR:$Rd),
3919 (ins GPR:$false, so_reg_reg:$shift, pred:$p),
3921 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_reg:$shift,
3922 imm:$cc, CCR:$ccr))*/]>,
3923 RegConstraint<"$false = $Rd">;
3926 let isMoveImm = 1 in
3927 def MOVCCi16 : ARMPseudoInst<(outs GPR:$Rd),
3928 (ins GPR:$false, imm0_65535_expr:$imm, pred:$p),
3931 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>;
3933 let isMoveImm = 1 in
3934 def MOVCCi : ARMPseudoInst<(outs GPR:$Rd),
3935 (ins GPR:$false, so_imm:$imm, pred:$p),
3937 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_imm:$imm, imm:$cc, CCR:$ccr))*/]>,
3938 RegConstraint<"$false = $Rd">;
3940 // Two instruction predicate mov immediate.
3941 let isMoveImm = 1 in
3942 def MOVCCi32imm : ARMPseudoInst<(outs GPR:$Rd),
3943 (ins GPR:$false, i32imm:$src, pred:$p),
3944 8, IIC_iCMOVix2, []>, RegConstraint<"$false = $Rd">;
3946 let isMoveImm = 1 in
3947 def MVNCCi : ARMPseudoInst<(outs GPR:$Rd),
3948 (ins GPR:$false, so_imm:$imm, pred:$p),
3950 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_imm_not:$imm, imm:$cc, CCR:$ccr))*/]>,
3951 RegConstraint<"$false = $Rd">;
3953 // Conditional instructions
3954 multiclass AsI1_bincc_irs<Instruction iri, Instruction irr, Instruction irsi,
3956 InstrItinClass iii, InstrItinClass iir,
3957 InstrItinClass iis> {
3958 def ri : ARMPseudoExpand<(outs GPR:$Rd),
3959 (ins GPR:$Rn, so_imm:$imm, pred:$p, cc_out:$s),
3961 (iri GPR:$Rd, GPR:$Rn, so_imm:$imm, pred:$p, cc_out:$s)>,
3962 RegConstraint<"$Rn = $Rd">;
3963 def rr : ARMPseudoExpand<(outs GPR:$Rd),
3964 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3966 (irr GPR:$Rd, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3967 RegConstraint<"$Rn = $Rd">;
3968 def rsi : ARMPseudoExpand<(outs GPR:$Rd),
3969 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p, cc_out:$s),
3971 (irsi GPR:$Rd, GPR:$Rn, so_reg_imm:$shift, pred:$p, cc_out:$s)>,
3972 RegConstraint<"$Rn = $Rd">;
3973 def rsr : ARMPseudoExpand<(outs GPRnopc:$Rd),
3974 (ins GPRnopc:$Rn, so_reg_reg:$shift, pred:$p, cc_out:$s),
3976 (irsr GPR:$Rd, GPR:$Rn, so_reg_reg:$shift, pred:$p, cc_out:$s)>,
3977 RegConstraint<"$Rn = $Rd">;
3980 defm ANDCC : AsI1_bincc_irs<ANDri, ANDrr, ANDrsi, ANDrsr,
3981 IIC_iBITi, IIC_iBITr, IIC_iBITsr>;
3982 defm ORRCC : AsI1_bincc_irs<ORRri, ORRrr, ORRrsi, ORRrsr,
3983 IIC_iBITi, IIC_iBITr, IIC_iBITsr>;
3984 defm EORCC : AsI1_bincc_irs<EORri, EORrr, EORrsi, EORrsr,
3985 IIC_iBITi, IIC_iBITr, IIC_iBITsr>;
3987 } // neverHasSideEffects
3990 //===----------------------------------------------------------------------===//
3991 // Atomic operations intrinsics
3994 def MemBarrierOptOperand : AsmOperandClass {
3995 let Name = "MemBarrierOpt";
3996 let ParserMethod = "parseMemBarrierOptOperand";
3998 def memb_opt : Operand<i32> {
3999 let PrintMethod = "printMemBOption";
4000 let ParserMatchClass = MemBarrierOptOperand;
4001 let DecoderMethod = "DecodeMemBarrierOption";
4004 // memory barriers protect the atomic sequences
4005 let hasSideEffects = 1 in {
4006 def DMB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4007 "dmb", "\t$opt", [(ARMMemBarrier (i32 imm:$opt))]>,
4008 Requires<[IsARM, HasDB]> {
4010 let Inst{31-4} = 0xf57ff05;
4011 let Inst{3-0} = opt;
4015 def DSB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4016 "dsb", "\t$opt", []>,
4017 Requires<[IsARM, HasDB]> {
4019 let Inst{31-4} = 0xf57ff04;
4020 let Inst{3-0} = opt;
4023 // ISB has only full system option
4024 def ISB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4025 "isb", "\t$opt", []>,
4026 Requires<[IsARM, HasDB]> {
4028 let Inst{31-4} = 0xf57ff06;
4029 let Inst{3-0} = opt;
4032 // Pseudo instruction that combines movs + predicated rsbmi
4033 // to implement integer ABS
4034 let usesCustomInserter = 1, Defs = [CPSR] in {
4035 def ABS : ARMPseudoInst<
4036 (outs GPR:$dst), (ins GPR:$src),
4037 8, NoItinerary, []>;
4040 let usesCustomInserter = 1 in {
4041 let Defs = [CPSR] in {
4042 def ATOMIC_LOAD_ADD_I8 : PseudoInst<
4043 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4044 [(set GPR:$dst, (atomic_load_add_8 GPR:$ptr, GPR:$incr))]>;
4045 def ATOMIC_LOAD_SUB_I8 : PseudoInst<
4046 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4047 [(set GPR:$dst, (atomic_load_sub_8 GPR:$ptr, GPR:$incr))]>;
4048 def ATOMIC_LOAD_AND_I8 : PseudoInst<
4049 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4050 [(set GPR:$dst, (atomic_load_and_8 GPR:$ptr, GPR:$incr))]>;
4051 def ATOMIC_LOAD_OR_I8 : PseudoInst<
4052 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4053 [(set GPR:$dst, (atomic_load_or_8 GPR:$ptr, GPR:$incr))]>;
4054 def ATOMIC_LOAD_XOR_I8 : PseudoInst<
4055 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4056 [(set GPR:$dst, (atomic_load_xor_8 GPR:$ptr, GPR:$incr))]>;
4057 def ATOMIC_LOAD_NAND_I8 : PseudoInst<
4058 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4059 [(set GPR:$dst, (atomic_load_nand_8 GPR:$ptr, GPR:$incr))]>;
4060 def ATOMIC_LOAD_MIN_I8 : PseudoInst<
4061 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4062 [(set GPR:$dst, (atomic_load_min_8 GPR:$ptr, GPR:$val))]>;
4063 def ATOMIC_LOAD_MAX_I8 : PseudoInst<
4064 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4065 [(set GPR:$dst, (atomic_load_max_8 GPR:$ptr, GPR:$val))]>;
4066 def ATOMIC_LOAD_UMIN_I8 : PseudoInst<
4067 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4068 [(set GPR:$dst, (atomic_load_umin_8 GPR:$ptr, GPR:$val))]>;
4069 def ATOMIC_LOAD_UMAX_I8 : PseudoInst<
4070 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4071 [(set GPR:$dst, (atomic_load_umax_8 GPR:$ptr, GPR:$val))]>;
4072 def ATOMIC_LOAD_ADD_I16 : PseudoInst<
4073 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4074 [(set GPR:$dst, (atomic_load_add_16 GPR:$ptr, GPR:$incr))]>;
4075 def ATOMIC_LOAD_SUB_I16 : PseudoInst<
4076 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4077 [(set GPR:$dst, (atomic_load_sub_16 GPR:$ptr, GPR:$incr))]>;
4078 def ATOMIC_LOAD_AND_I16 : PseudoInst<
4079 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4080 [(set GPR:$dst, (atomic_load_and_16 GPR:$ptr, GPR:$incr))]>;
4081 def ATOMIC_LOAD_OR_I16 : PseudoInst<
4082 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4083 [(set GPR:$dst, (atomic_load_or_16 GPR:$ptr, GPR:$incr))]>;
4084 def ATOMIC_LOAD_XOR_I16 : PseudoInst<
4085 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4086 [(set GPR:$dst, (atomic_load_xor_16 GPR:$ptr, GPR:$incr))]>;
4087 def ATOMIC_LOAD_NAND_I16 : PseudoInst<
4088 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4089 [(set GPR:$dst, (atomic_load_nand_16 GPR:$ptr, GPR:$incr))]>;
4090 def ATOMIC_LOAD_MIN_I16 : PseudoInst<
4091 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4092 [(set GPR:$dst, (atomic_load_min_16 GPR:$ptr, GPR:$val))]>;
4093 def ATOMIC_LOAD_MAX_I16 : PseudoInst<
4094 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4095 [(set GPR:$dst, (atomic_load_max_16 GPR:$ptr, GPR:$val))]>;
4096 def ATOMIC_LOAD_UMIN_I16 : PseudoInst<
4097 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4098 [(set GPR:$dst, (atomic_load_umin_16 GPR:$ptr, GPR:$val))]>;
4099 def ATOMIC_LOAD_UMAX_I16 : PseudoInst<
4100 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4101 [(set GPR:$dst, (atomic_load_umax_16 GPR:$ptr, GPR:$val))]>;
4102 def ATOMIC_LOAD_ADD_I32 : PseudoInst<
4103 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4104 [(set GPR:$dst, (atomic_load_add_32 GPR:$ptr, GPR:$incr))]>;
4105 def ATOMIC_LOAD_SUB_I32 : PseudoInst<
4106 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4107 [(set GPR:$dst, (atomic_load_sub_32 GPR:$ptr, GPR:$incr))]>;
4108 def ATOMIC_LOAD_AND_I32 : PseudoInst<
4109 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4110 [(set GPR:$dst, (atomic_load_and_32 GPR:$ptr, GPR:$incr))]>;
4111 def ATOMIC_LOAD_OR_I32 : PseudoInst<
4112 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4113 [(set GPR:$dst, (atomic_load_or_32 GPR:$ptr, GPR:$incr))]>;
4114 def ATOMIC_LOAD_XOR_I32 : PseudoInst<
4115 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4116 [(set GPR:$dst, (atomic_load_xor_32 GPR:$ptr, GPR:$incr))]>;
4117 def ATOMIC_LOAD_NAND_I32 : PseudoInst<
4118 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4119 [(set GPR:$dst, (atomic_load_nand_32 GPR:$ptr, GPR:$incr))]>;
4120 def ATOMIC_LOAD_MIN_I32 : PseudoInst<
4121 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4122 [(set GPR:$dst, (atomic_load_min_32 GPR:$ptr, GPR:$val))]>;
4123 def ATOMIC_LOAD_MAX_I32 : PseudoInst<
4124 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4125 [(set GPR:$dst, (atomic_load_max_32 GPR:$ptr, GPR:$val))]>;
4126 def ATOMIC_LOAD_UMIN_I32 : PseudoInst<
4127 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4128 [(set GPR:$dst, (atomic_load_umin_32 GPR:$ptr, GPR:$val))]>;
4129 def ATOMIC_LOAD_UMAX_I32 : PseudoInst<
4130 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4131 [(set GPR:$dst, (atomic_load_umax_32 GPR:$ptr, GPR:$val))]>;
4133 def ATOMIC_SWAP_I8 : PseudoInst<
4134 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
4135 [(set GPR:$dst, (atomic_swap_8 GPR:$ptr, GPR:$new))]>;
4136 def ATOMIC_SWAP_I16 : PseudoInst<
4137 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
4138 [(set GPR:$dst, (atomic_swap_16 GPR:$ptr, GPR:$new))]>;
4139 def ATOMIC_SWAP_I32 : PseudoInst<
4140 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
4141 [(set GPR:$dst, (atomic_swap_32 GPR:$ptr, GPR:$new))]>;
4143 def ATOMIC_CMP_SWAP_I8 : PseudoInst<
4144 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
4145 [(set GPR:$dst, (atomic_cmp_swap_8 GPR:$ptr, GPR:$old, GPR:$new))]>;
4146 def ATOMIC_CMP_SWAP_I16 : PseudoInst<
4147 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
4148 [(set GPR:$dst, (atomic_cmp_swap_16 GPR:$ptr, GPR:$old, GPR:$new))]>;
4149 def ATOMIC_CMP_SWAP_I32 : PseudoInst<
4150 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
4151 [(set GPR:$dst, (atomic_cmp_swap_32 GPR:$ptr, GPR:$old, GPR:$new))]>;
4155 let mayLoad = 1 in {
4156 def LDREXB : AIldrex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4158 "ldrexb", "\t$Rt, $addr", []>;
4159 def LDREXH : AIldrex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4160 NoItinerary, "ldrexh", "\t$Rt, $addr", []>;
4161 def LDREX : AIldrex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4162 NoItinerary, "ldrex", "\t$Rt, $addr", []>;
4163 let hasExtraDefRegAllocReq = 1 in
4164 def LDREXD: AIldrex<0b01, (outs GPR:$Rt, GPR:$Rt2),(ins addr_offset_none:$addr),
4165 NoItinerary, "ldrexd", "\t$Rt, $Rt2, $addr", []> {
4166 let DecoderMethod = "DecodeDoubleRegLoad";
4170 let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
4171 def STREXB: AIstrex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4172 NoItinerary, "strexb", "\t$Rd, $Rt, $addr", []>;
4173 def STREXH: AIstrex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4174 NoItinerary, "strexh", "\t$Rd, $Rt, $addr", []>;
4175 def STREX : AIstrex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4176 NoItinerary, "strex", "\t$Rd, $Rt, $addr", []>;
4177 let hasExtraSrcRegAllocReq = 1 in
4178 def STREXD : AIstrex<0b01, (outs GPR:$Rd),
4179 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr),
4180 NoItinerary, "strexd", "\t$Rd, $Rt, $Rt2, $addr", []> {
4181 let DecoderMethod = "DecodeDoubleRegStore";
4186 def CLREX : AXI<(outs), (ins), MiscFrm, NoItinerary, "clrex", []>,
4187 Requires<[IsARM, HasV7]> {
4188 let Inst{31-0} = 0b11110101011111111111000000011111;
4191 // SWP/SWPB are deprecated in V6/V7.
4192 let mayLoad = 1, mayStore = 1 in {
4193 def SWP : AIswp<0, (outs GPRnopc:$Rt), (ins GPRnopc:$Rt2, addr_offset_none:$addr),
4195 def SWPB: AIswp<1, (outs GPRnopc:$Rt), (ins GPRnopc:$Rt2, addr_offset_none:$addr),
4199 //===----------------------------------------------------------------------===//
4200 // Coprocessor Instructions.
4203 def CDP : ABI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4204 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4205 NoItinerary, "cdp", "\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4206 [(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4207 imm:$CRm, imm:$opc2)]> {
4215 let Inst{3-0} = CRm;
4217 let Inst{7-5} = opc2;
4218 let Inst{11-8} = cop;
4219 let Inst{15-12} = CRd;
4220 let Inst{19-16} = CRn;
4221 let Inst{23-20} = opc1;
4224 def CDP2 : ABXI<0b1110, (outs), (ins pf_imm:$cop, imm0_15:$opc1,
4225 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4226 NoItinerary, "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4227 [(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4228 imm:$CRm, imm:$opc2)]> {
4229 let Inst{31-28} = 0b1111;
4237 let Inst{3-0} = CRm;
4239 let Inst{7-5} = opc2;
4240 let Inst{11-8} = cop;
4241 let Inst{15-12} = CRd;
4242 let Inst{19-16} = CRn;
4243 let Inst{23-20} = opc1;
4246 class ACI<dag oops, dag iops, string opc, string asm,
4247 IndexMode im = IndexModeNone>
4248 : I<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
4250 let Inst{27-25} = 0b110;
4252 class ACInoP<dag oops, dag iops, string opc, string asm,
4253 IndexMode im = IndexModeNone>
4254 : InoP<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
4256 let Inst{31-28} = 0b1111;
4257 let Inst{27-25} = 0b110;
4259 multiclass LdStCop<bit load, bit Dbit, string asm> {
4260 def _OFFSET : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4261 asm, "\t$cop, $CRd, $addr"> {
4265 let Inst{24} = 1; // P = 1
4266 let Inst{23} = addr{8};
4267 let Inst{22} = Dbit;
4268 let Inst{21} = 0; // W = 0
4269 let Inst{20} = load;
4270 let Inst{19-16} = addr{12-9};
4271 let Inst{15-12} = CRd;
4272 let Inst{11-8} = cop;
4273 let Inst{7-0} = addr{7-0};
4274 let DecoderMethod = "DecodeCopMemInstruction";
4276 def _PRE : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4277 asm, "\t$cop, $CRd, $addr!", IndexModePre> {
4281 let Inst{24} = 1; // P = 1
4282 let Inst{23} = addr{8};
4283 let Inst{22} = Dbit;
4284 let Inst{21} = 1; // W = 1
4285 let Inst{20} = load;
4286 let Inst{19-16} = addr{12-9};
4287 let Inst{15-12} = CRd;
4288 let Inst{11-8} = cop;
4289 let Inst{7-0} = addr{7-0};
4290 let DecoderMethod = "DecodeCopMemInstruction";
4292 def _POST: ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4293 postidx_imm8s4:$offset),
4294 asm, "\t$cop, $CRd, $addr, $offset", IndexModePost> {
4299 let Inst{24} = 0; // P = 0
4300 let Inst{23} = offset{8};
4301 let Inst{22} = Dbit;
4302 let Inst{21} = 1; // W = 1
4303 let Inst{20} = load;
4304 let Inst{19-16} = addr;
4305 let Inst{15-12} = CRd;
4306 let Inst{11-8} = cop;
4307 let Inst{7-0} = offset{7-0};
4308 let DecoderMethod = "DecodeCopMemInstruction";
4310 def _OPTION : ACI<(outs),
4311 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4312 coproc_option_imm:$option),
4313 asm, "\t$cop, $CRd, $addr, $option"> {
4318 let Inst{24} = 0; // P = 0
4319 let Inst{23} = 1; // U = 1
4320 let Inst{22} = Dbit;
4321 let Inst{21} = 0; // W = 0
4322 let Inst{20} = load;
4323 let Inst{19-16} = addr;
4324 let Inst{15-12} = CRd;
4325 let Inst{11-8} = cop;
4326 let Inst{7-0} = option;
4327 let DecoderMethod = "DecodeCopMemInstruction";
4330 multiclass LdSt2Cop<bit load, bit Dbit, string asm> {
4331 def _OFFSET : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4332 asm, "\t$cop, $CRd, $addr"> {
4336 let Inst{24} = 1; // P = 1
4337 let Inst{23} = addr{8};
4338 let Inst{22} = Dbit;
4339 let Inst{21} = 0; // W = 0
4340 let Inst{20} = load;
4341 let Inst{19-16} = addr{12-9};
4342 let Inst{15-12} = CRd;
4343 let Inst{11-8} = cop;
4344 let Inst{7-0} = addr{7-0};
4345 let DecoderMethod = "DecodeCopMemInstruction";
4347 def _PRE : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4348 asm, "\t$cop, $CRd, $addr!", IndexModePre> {
4352 let Inst{24} = 1; // P = 1
4353 let Inst{23} = addr{8};
4354 let Inst{22} = Dbit;
4355 let Inst{21} = 1; // W = 1
4356 let Inst{20} = load;
4357 let Inst{19-16} = addr{12-9};
4358 let Inst{15-12} = CRd;
4359 let Inst{11-8} = cop;
4360 let Inst{7-0} = addr{7-0};
4361 let DecoderMethod = "DecodeCopMemInstruction";
4363 def _POST: ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4364 postidx_imm8s4:$offset),
4365 asm, "\t$cop, $CRd, $addr, $offset", IndexModePost> {
4370 let Inst{24} = 0; // P = 0
4371 let Inst{23} = offset{8};
4372 let Inst{22} = Dbit;
4373 let Inst{21} = 1; // W = 1
4374 let Inst{20} = load;
4375 let Inst{19-16} = addr;
4376 let Inst{15-12} = CRd;
4377 let Inst{11-8} = cop;
4378 let Inst{7-0} = offset{7-0};
4379 let DecoderMethod = "DecodeCopMemInstruction";
4381 def _OPTION : ACInoP<(outs),
4382 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4383 coproc_option_imm:$option),
4384 asm, "\t$cop, $CRd, $addr, $option"> {
4389 let Inst{24} = 0; // P = 0
4390 let Inst{23} = 1; // U = 1
4391 let Inst{22} = Dbit;
4392 let Inst{21} = 0; // W = 0
4393 let Inst{20} = load;
4394 let Inst{19-16} = addr;
4395 let Inst{15-12} = CRd;
4396 let Inst{11-8} = cop;
4397 let Inst{7-0} = option;
4398 let DecoderMethod = "DecodeCopMemInstruction";
4402 defm LDC : LdStCop <1, 0, "ldc">;
4403 defm LDCL : LdStCop <1, 1, "ldcl">;
4404 defm STC : LdStCop <0, 0, "stc">;
4405 defm STCL : LdStCop <0, 1, "stcl">;
4406 defm LDC2 : LdSt2Cop<1, 0, "ldc2">;
4407 defm LDC2L : LdSt2Cop<1, 1, "ldc2l">;
4408 defm STC2 : LdSt2Cop<0, 0, "stc2">;
4409 defm STC2L : LdSt2Cop<0, 1, "stc2l">;
4411 //===----------------------------------------------------------------------===//
4412 // Move between coprocessor and ARM core register.
4415 class MovRCopro<string opc, bit direction, dag oops, dag iops,
4417 : ABI<0b1110, oops, iops, NoItinerary, opc,
4418 "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2", pattern> {
4419 let Inst{20} = direction;
4429 let Inst{15-12} = Rt;
4430 let Inst{11-8} = cop;
4431 let Inst{23-21} = opc1;
4432 let Inst{7-5} = opc2;
4433 let Inst{3-0} = CRm;
4434 let Inst{19-16} = CRn;
4437 def MCR : MovRCopro<"mcr", 0 /* from ARM core register to coprocessor */,
4439 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4440 c_imm:$CRm, imm0_7:$opc2),
4441 [(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
4442 imm:$CRm, imm:$opc2)]>;
4443 def : ARMInstAlias<"mcr${p} $cop, $opc1, $Rt, $CRn, $CRm",
4444 (MCR p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4445 c_imm:$CRm, 0, pred:$p)>;
4446 def MRC : MovRCopro<"mrc", 1 /* from coprocessor to ARM core register */,
4448 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
4450 def : ARMInstAlias<"mrc${p} $cop, $opc1, $Rt, $CRn, $CRm",
4451 (MRC GPR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
4452 c_imm:$CRm, 0, pred:$p)>;
4454 def : ARMPat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
4455 (MRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
4457 class MovRCopro2<string opc, bit direction, dag oops, dag iops,
4459 : ABXI<0b1110, oops, iops, NoItinerary,
4460 !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), pattern> {
4461 let Inst{31-28} = 0b1111;
4462 let Inst{20} = direction;
4472 let Inst{15-12} = Rt;
4473 let Inst{11-8} = cop;
4474 let Inst{23-21} = opc1;
4475 let Inst{7-5} = opc2;
4476 let Inst{3-0} = CRm;
4477 let Inst{19-16} = CRn;
4480 def MCR2 : MovRCopro2<"mcr2", 0 /* from ARM core register to coprocessor */,
4482 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4483 c_imm:$CRm, imm0_7:$opc2),
4484 [(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
4485 imm:$CRm, imm:$opc2)]>;
4486 def : ARMInstAlias<"mcr2$ $cop, $opc1, $Rt, $CRn, $CRm",
4487 (MCR2 p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4489 def MRC2 : MovRCopro2<"mrc2", 1 /* from coprocessor to ARM core register */,
4491 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
4493 def : ARMInstAlias<"mrc2$ $cop, $opc1, $Rt, $CRn, $CRm",
4494 (MRC2 GPR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
4497 def : ARMV5TPat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn,
4498 imm:$CRm, imm:$opc2),
4499 (MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
4501 class MovRRCopro<string opc, bit direction, list<dag> pattern = []>
4502 : ABI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4503 GPRnopc:$Rt, GPRnopc:$Rt2, c_imm:$CRm),
4504 NoItinerary, opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm", pattern> {
4505 let Inst{23-21} = 0b010;
4506 let Inst{20} = direction;
4514 let Inst{15-12} = Rt;
4515 let Inst{19-16} = Rt2;
4516 let Inst{11-8} = cop;
4517 let Inst{7-4} = opc1;
4518 let Inst{3-0} = CRm;
4521 def MCRR : MovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */,
4522 [(int_arm_mcrr imm:$cop, imm:$opc1, GPRnopc:$Rt, GPRnopc:$Rt2,
4524 def MRRC : MovRRCopro<"mrrc", 1 /* from coprocessor to ARM core register */>;
4526 class MovRRCopro2<string opc, bit direction, list<dag> pattern = []>
4527 : ABXI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4528 GPRnopc:$Rt, GPRnopc:$Rt2, c_imm:$CRm), NoItinerary,
4529 !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern> {
4530 let Inst{31-28} = 0b1111;
4531 let Inst{23-21} = 0b010;
4532 let Inst{20} = direction;
4540 let Inst{15-12} = Rt;
4541 let Inst{19-16} = Rt2;
4542 let Inst{11-8} = cop;
4543 let Inst{7-4} = opc1;
4544 let Inst{3-0} = CRm;
4546 let DecoderMethod = "DecodeMRRC2";
4549 def MCRR2 : MovRRCopro2<"mcrr2", 0 /* from ARM core register to coprocessor */,
4550 [(int_arm_mcrr2 imm:$cop, imm:$opc1, GPRnopc:$Rt, GPRnopc:$Rt2,
4552 def MRRC2 : MovRRCopro2<"mrrc2", 1 /* from coprocessor to ARM core register */>;
4554 //===----------------------------------------------------------------------===//
4555 // Move between special register and ARM core register
4558 // Move to ARM core register from Special Register
4559 def MRS : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
4560 "mrs", "\t$Rd, apsr", []> {
4562 let Inst{23-16} = 0b00001111;
4563 let Unpredictable{19-17} = 0b111;
4565 let Inst{15-12} = Rd;
4567 let Inst{11-0} = 0b000000000000;
4568 let Unpredictable{11-0} = 0b110100001111;
4571 def : InstAlias<"mrs${p} $Rd, cpsr", (MRS GPRnopc:$Rd, pred:$p)>, Requires<[IsARM]>;
4573 // The MRSsys instruction is the MRS instruction from the ARM ARM,
4574 // section B9.3.9, with the R bit set to 1.
4575 def MRSsys : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
4576 "mrs", "\t$Rd, spsr", []> {
4578 let Inst{23-16} = 0b01001111;
4579 let Unpredictable{19-16} = 0b1111;
4581 let Inst{15-12} = Rd;
4583 let Inst{11-0} = 0b000000000000;
4584 let Unpredictable{11-0} = 0b110100001111;
4587 // Move from ARM core register to Special Register
4589 // No need to have both system and application versions, the encodings are the
4590 // same and the assembly parser has no way to distinguish between them. The mask
4591 // operand contains the special register (R Bit) in bit 4 and bits 3-0 contains
4592 // the mask with the fields to be accessed in the special register.
4593 def MSR : ABI<0b0001, (outs), (ins msr_mask:$mask, GPR:$Rn), NoItinerary,
4594 "msr", "\t$mask, $Rn", []> {
4599 let Inst{22} = mask{4}; // R bit
4600 let Inst{21-20} = 0b10;
4601 let Inst{19-16} = mask{3-0};
4602 let Inst{15-12} = 0b1111;
4603 let Inst{11-4} = 0b00000000;
4607 def MSRi : ABI<0b0011, (outs), (ins msr_mask:$mask, so_imm:$a), NoItinerary,
4608 "msr", "\t$mask, $a", []> {
4613 let Inst{22} = mask{4}; // R bit
4614 let Inst{21-20} = 0b10;
4615 let Inst{19-16} = mask{3-0};
4616 let Inst{15-12} = 0b1111;
4620 //===----------------------------------------------------------------------===//
4624 // __aeabi_read_tp preserves the registers r1-r3.
4625 // This is a pseudo inst so that we can get the encoding right,
4626 // complete with fixup for the aeabi_read_tp function.
4628 Defs = [R0, R12, LR, CPSR], Uses = [SP] in {
4629 def TPsoft : PseudoInst<(outs), (ins), IIC_Br,
4630 [(set R0, ARMthread_pointer)]>;
4633 //===----------------------------------------------------------------------===//
4634 // SJLJ Exception handling intrinsics
4635 // eh_sjlj_setjmp() is an instruction sequence to store the return
4636 // address and save #0 in R0 for the non-longjmp case.
4637 // Since by its nature we may be coming from some other function to get
4638 // here, and we're using the stack frame for the containing function to
4639 // save/restore registers, we can't keep anything live in regs across
4640 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
4641 // when we get here from a longjmp(). We force everything out of registers
4642 // except for our own input by listing the relevant registers in Defs. By
4643 // doing so, we also cause the prologue/epilogue code to actively preserve
4644 // all of the callee-saved resgisters, which is exactly what we want.
4645 // A constant value is passed in $val, and we use the location as a scratch.
4647 // These are pseudo-instructions and are lowered to individual MC-insts, so
4648 // no encoding information is necessary.
4650 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
4651 Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15 ],
4652 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
4653 def Int_eh_sjlj_setjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
4655 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
4656 Requires<[IsARM, HasVFP2]>;
4660 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
4661 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
4662 def Int_eh_sjlj_setjmp_nofp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
4664 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
4665 Requires<[IsARM, NoVFP]>;
4668 // FIXME: Non-IOS version(s)
4669 let isBarrier = 1, hasSideEffects = 1, isTerminator = 1,
4670 Defs = [ R7, LR, SP ] in {
4671 def Int_eh_sjlj_longjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$scratch),
4673 [(ARMeh_sjlj_longjmp GPR:$src, GPR:$scratch)]>,
4674 Requires<[IsARM, IsIOS]>;
4677 // eh.sjlj.dispatchsetup pseudo-instructions.
4678 // These pseudos are used for both ARM and Thumb2. Any differences are
4679 // handled when the pseudo is expanded (which happens before any passes
4680 // that need the instruction size).
4682 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
4683 Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15 ],
4685 def Int_eh_sjlj_dispatchsetup : PseudoInst<(outs), (ins), NoItinerary, []>;
4688 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
4690 def Int_eh_sjlj_dispatchsetup_nofp : PseudoInst<(outs), (ins), NoItinerary, []>;
4693 //===----------------------------------------------------------------------===//
4694 // Non-Instruction Patterns
4697 // ARMv4 indirect branch using (MOVr PC, dst)
4698 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in
4699 def MOVPCRX : ARMPseudoExpand<(outs), (ins GPR:$dst),
4700 4, IIC_Br, [(brind GPR:$dst)],
4701 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>,
4702 Requires<[IsARM, NoV4T]>;
4704 // Large immediate handling.
4706 // 32-bit immediate using two piece so_imms or movw + movt.
4707 // This is a single pseudo instruction, the benefit is that it can be remat'd
4708 // as a single unit instead of having to handle reg inputs.
4709 // FIXME: Remove this when we can do generalized remat.
4710 let isReMaterializable = 1, isMoveImm = 1 in
4711 def MOVi32imm : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
4712 [(set GPR:$dst, (arm_i32imm:$src))]>,
4715 // Pseudo instruction that combines movw + movt + add pc (if PIC).
4716 // It also makes it possible to rematerialize the instructions.
4717 // FIXME: Remove this when we can do generalized remat and when machine licm
4718 // can properly the instructions.
4719 let isReMaterializable = 1 in {
4720 def MOV_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
4722 [(set GPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>,
4723 Requires<[IsARM, UseMovt]>;
4725 def MOV_ga_dyn : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
4727 [(set GPR:$dst, (ARMWrapperDYN tglobaladdr:$addr))]>,
4728 Requires<[IsARM, UseMovt]>;
4730 let AddedComplexity = 10 in
4731 def MOV_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
4733 [(set GPR:$dst, (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
4734 Requires<[IsARM, UseMovt]>;
4735 } // isReMaterializable
4737 // ConstantPool, GlobalAddress, and JumpTable
4738 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (LEApcrel tglobaladdr :$dst)>,
4739 Requires<[IsARM, DontUseMovt]>;
4740 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
4741 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
4742 Requires<[IsARM, UseMovt]>;
4743 def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
4744 (LEApcrelJT tjumptable:$dst, imm:$id)>;
4746 // TODO: add,sub,and, 3-instr forms?
4748 // Tail calls. These patterns also apply to Thumb mode.
4749 def : Pat<(ARMtcret tcGPR:$dst), (TCRETURNri tcGPR:$dst)>;
4750 def : Pat<(ARMtcret (i32 tglobaladdr:$dst)), (TCRETURNdi texternalsym:$dst)>;
4751 def : Pat<(ARMtcret (i32 texternalsym:$dst)), (TCRETURNdi texternalsym:$dst)>;
4754 def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>;
4755 def : ARMPat<(ARMcall_nolink texternalsym:$func),
4756 (BMOVPCB_CALL texternalsym:$func)>;
4758 // zextload i1 -> zextload i8
4759 def : ARMPat<(zextloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
4760 def : ARMPat<(zextloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
4762 // extload -> zextload
4763 def : ARMPat<(extloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
4764 def : ARMPat<(extloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
4765 def : ARMPat<(extloadi8 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
4766 def : ARMPat<(extloadi8 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
4768 def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
4770 def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
4771 def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
4774 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4775 (sra (shl GPR:$b, (i32 16)), (i32 16))),
4776 (SMULBB GPR:$a, GPR:$b)>;
4777 def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
4778 (SMULBB GPR:$a, GPR:$b)>;
4779 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4780 (sra GPR:$b, (i32 16))),
4781 (SMULBT GPR:$a, GPR:$b)>;
4782 def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, (i32 16))),
4783 (SMULBT GPR:$a, GPR:$b)>;
4784 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)),
4785 (sra (shl GPR:$b, (i32 16)), (i32 16))),
4786 (SMULTB GPR:$a, GPR:$b)>;
4787 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), sext_16_node:$b),
4788 (SMULTB GPR:$a, GPR:$b)>;
4789 def : ARMV5TEPat<(sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
4791 (SMULWB GPR:$a, GPR:$b)>;
4792 def : ARMV5TEPat<(sra (mul GPR:$a, sext_16_node:$b), (i32 16)),
4793 (SMULWB GPR:$a, GPR:$b)>;
4795 def : ARMV5TEPat<(add GPR:$acc,
4796 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4797 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
4798 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
4799 def : ARMV5TEPat<(add GPR:$acc,
4800 (mul sext_16_node:$a, sext_16_node:$b)),
4801 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
4802 def : ARMV5TEPat<(add GPR:$acc,
4803 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4804 (sra GPR:$b, (i32 16)))),
4805 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
4806 def : ARMV5TEPat<(add GPR:$acc,
4807 (mul sext_16_node:$a, (sra GPR:$b, (i32 16)))),
4808 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
4809 def : ARMV5TEPat<(add GPR:$acc,
4810 (mul (sra GPR:$a, (i32 16)),
4811 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
4812 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
4813 def : ARMV5TEPat<(add GPR:$acc,
4814 (mul (sra GPR:$a, (i32 16)), sext_16_node:$b)),
4815 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
4816 def : ARMV5TEPat<(add GPR:$acc,
4817 (sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
4819 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
4820 def : ARMV5TEPat<(add GPR:$acc,
4821 (sra (mul GPR:$a, sext_16_node:$b), (i32 16))),
4822 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
4825 // Pre-v7 uses MCR for synchronization barriers.
4826 def : ARMPat<(ARMMemBarrierMCR GPR:$zero), (MCR 15, 0, GPR:$zero, 7, 10, 5)>,
4827 Requires<[IsARM, HasV6]>;
4829 // SXT/UXT with no rotate
4830 let AddedComplexity = 16 in {
4831 def : ARMV6Pat<(and GPR:$Src, 0x000000FF), (UXTB GPR:$Src, 0)>;
4832 def : ARMV6Pat<(and GPR:$Src, 0x0000FFFF), (UXTH GPR:$Src, 0)>;
4833 def : ARMV6Pat<(and GPR:$Src, 0x00FF00FF), (UXTB16 GPR:$Src, 0)>;
4834 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0x00FF)),
4835 (UXTAB GPR:$Rn, GPR:$Rm, 0)>;
4836 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0xFFFF)),
4837 (UXTAH GPR:$Rn, GPR:$Rm, 0)>;
4840 def : ARMV6Pat<(sext_inreg GPR:$Src, i8), (SXTB GPR:$Src, 0)>;
4841 def : ARMV6Pat<(sext_inreg GPR:$Src, i16), (SXTH GPR:$Src, 0)>;
4843 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i8)),
4844 (SXTAB GPR:$Rn, GPRnopc:$Rm, 0)>;
4845 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i16)),
4846 (SXTAH GPR:$Rn, GPRnopc:$Rm, 0)>;
4848 // Atomic load/store patterns
4849 def : ARMPat<(atomic_load_8 ldst_so_reg:$src),
4850 (LDRBrs ldst_so_reg:$src)>;
4851 def : ARMPat<(atomic_load_8 addrmode_imm12:$src),
4852 (LDRBi12 addrmode_imm12:$src)>;
4853 def : ARMPat<(atomic_load_16 addrmode3:$src),
4854 (LDRH addrmode3:$src)>;
4855 def : ARMPat<(atomic_load_32 ldst_so_reg:$src),
4856 (LDRrs ldst_so_reg:$src)>;
4857 def : ARMPat<(atomic_load_32 addrmode_imm12:$src),
4858 (LDRi12 addrmode_imm12:$src)>;
4859 def : ARMPat<(atomic_store_8 ldst_so_reg:$ptr, GPR:$val),
4860 (STRBrs GPR:$val, ldst_so_reg:$ptr)>;
4861 def : ARMPat<(atomic_store_8 addrmode_imm12:$ptr, GPR:$val),
4862 (STRBi12 GPR:$val, addrmode_imm12:$ptr)>;
4863 def : ARMPat<(atomic_store_16 addrmode3:$ptr, GPR:$val),
4864 (STRH GPR:$val, addrmode3:$ptr)>;
4865 def : ARMPat<(atomic_store_32 ldst_so_reg:$ptr, GPR:$val),
4866 (STRrs GPR:$val, ldst_so_reg:$ptr)>;
4867 def : ARMPat<(atomic_store_32 addrmode_imm12:$ptr, GPR:$val),
4868 (STRi12 GPR:$val, addrmode_imm12:$ptr)>;
4871 //===----------------------------------------------------------------------===//
4875 include "ARMInstrThumb.td"
4877 //===----------------------------------------------------------------------===//
4881 include "ARMInstrThumb2.td"
4883 //===----------------------------------------------------------------------===//
4884 // Floating Point Support
4887 include "ARMInstrVFP.td"
4889 //===----------------------------------------------------------------------===//
4890 // Advanced SIMD (NEON) Support
4893 include "ARMInstrNEON.td"
4895 //===----------------------------------------------------------------------===//
4896 // Assembler aliases
4900 def : InstAlias<"dmb", (DMB 0xf)>, Requires<[IsARM, HasDB]>;
4901 def : InstAlias<"dsb", (DSB 0xf)>, Requires<[IsARM, HasDB]>;
4902 def : InstAlias<"isb", (ISB 0xf)>, Requires<[IsARM, HasDB]>;
4904 // System instructions
4905 def : MnemonicAlias<"swi", "svc">;
4907 // Load / Store Multiple
4908 def : MnemonicAlias<"ldmfd", "ldm">;
4909 def : MnemonicAlias<"ldmia", "ldm">;
4910 def : MnemonicAlias<"ldmea", "ldmdb">;
4911 def : MnemonicAlias<"stmfd", "stmdb">;
4912 def : MnemonicAlias<"stmia", "stm">;
4913 def : MnemonicAlias<"stmea", "stm">;
4915 // PKHBT/PKHTB with default shift amount. PKHTB is equivalent to PKHBT when the
4916 // shift amount is zero (i.e., unspecified).
4917 def : InstAlias<"pkhbt${p} $Rd, $Rn, $Rm",
4918 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
4919 Requires<[IsARM, HasV6]>;
4920 def : InstAlias<"pkhtb${p} $Rd, $Rn, $Rm",
4921 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
4922 Requires<[IsARM, HasV6]>;
4924 // PUSH/POP aliases for STM/LDM
4925 def : ARMInstAlias<"push${p} $regs", (STMDB_UPD SP, pred:$p, reglist:$regs)>;
4926 def : ARMInstAlias<"pop${p} $regs", (LDMIA_UPD SP, pred:$p, reglist:$regs)>;
4928 // SSAT/USAT optional shift operand.
4929 def : ARMInstAlias<"ssat${p} $Rd, $sat_imm, $Rn",
4930 (SSAT GPRnopc:$Rd, imm1_32:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
4931 def : ARMInstAlias<"usat${p} $Rd, $sat_imm, $Rn",
4932 (USAT GPRnopc:$Rd, imm0_31:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
4935 // Extend instruction optional rotate operand.
4936 def : ARMInstAlias<"sxtab${p} $Rd, $Rn, $Rm",
4937 (SXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4938 def : ARMInstAlias<"sxtah${p} $Rd, $Rn, $Rm",
4939 (SXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4940 def : ARMInstAlias<"sxtab16${p} $Rd, $Rn, $Rm",
4941 (SXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4942 def : ARMInstAlias<"sxtb${p} $Rd, $Rm",
4943 (SXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4944 def : ARMInstAlias<"sxtb16${p} $Rd, $Rm",
4945 (SXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4946 def : ARMInstAlias<"sxth${p} $Rd, $Rm",
4947 (SXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4949 def : ARMInstAlias<"uxtab${p} $Rd, $Rn, $Rm",
4950 (UXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4951 def : ARMInstAlias<"uxtah${p} $Rd, $Rn, $Rm",
4952 (UXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4953 def : ARMInstAlias<"uxtab16${p} $Rd, $Rn, $Rm",
4954 (UXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4955 def : ARMInstAlias<"uxtb${p} $Rd, $Rm",
4956 (UXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4957 def : ARMInstAlias<"uxtb16${p} $Rd, $Rm",
4958 (UXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4959 def : ARMInstAlias<"uxth${p} $Rd, $Rm",
4960 (UXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4964 def : MnemonicAlias<"rfefa", "rfeda">;
4965 def : MnemonicAlias<"rfeea", "rfedb">;
4966 def : MnemonicAlias<"rfefd", "rfeia">;
4967 def : MnemonicAlias<"rfeed", "rfeib">;
4968 def : MnemonicAlias<"rfe", "rfeia">;
4971 def : MnemonicAlias<"srsfa", "srsda">;
4972 def : MnemonicAlias<"srsea", "srsdb">;
4973 def : MnemonicAlias<"srsfd", "srsia">;
4974 def : MnemonicAlias<"srsed", "srsib">;
4975 def : MnemonicAlias<"srs", "srsia">;
4978 def : MnemonicAlias<"qsubaddx", "qsax">;
4980 def : MnemonicAlias<"saddsubx", "sasx">;
4981 // SHASX == SHADDSUBX
4982 def : MnemonicAlias<"shaddsubx", "shasx">;
4983 // SHSAX == SHSUBADDX
4984 def : MnemonicAlias<"shsubaddx", "shsax">;
4986 def : MnemonicAlias<"ssubaddx", "ssax">;
4988 def : MnemonicAlias<"uaddsubx", "uasx">;
4989 // UHASX == UHADDSUBX
4990 def : MnemonicAlias<"uhaddsubx", "uhasx">;
4991 // UHSAX == UHSUBADDX
4992 def : MnemonicAlias<"uhsubaddx", "uhsax">;
4993 // UQASX == UQADDSUBX
4994 def : MnemonicAlias<"uqaddsubx", "uqasx">;
4995 // UQSAX == UQSUBADDX
4996 def : MnemonicAlias<"uqsubaddx", "uqsax">;
4998 def : MnemonicAlias<"usubaddx", "usax">;
5000 // "mov Rd, so_imm_not" can be handled via "mvn" in assembly, just like
5002 def : ARMInstAlias<"mov${s}${p} $Rd, $imm",
5003 (MVNi rGPR:$Rd, so_imm_not:$imm, pred:$p, cc_out:$s)>;
5004 def : ARMInstAlias<"mvn${s}${p} $Rd, $imm",
5005 (MOVi rGPR:$Rd, so_imm_not:$imm, pred:$p, cc_out:$s)>;
5006 // Same for AND <--> BIC
5007 def : ARMInstAlias<"bic${s}${p} $Rd, $Rn, $imm",
5008 (ANDri rGPR:$Rd, rGPR:$Rn, so_imm_not:$imm,
5009 pred:$p, cc_out:$s)>;
5010 def : ARMInstAlias<"bic${s}${p} $Rdn, $imm",
5011 (ANDri rGPR:$Rdn, rGPR:$Rdn, so_imm_not:$imm,
5012 pred:$p, cc_out:$s)>;
5013 def : ARMInstAlias<"and${s}${p} $Rd, $Rn, $imm",
5014 (BICri rGPR:$Rd, rGPR:$Rn, so_imm_not:$imm,
5015 pred:$p, cc_out:$s)>;
5016 def : ARMInstAlias<"and${s}${p} $Rdn, $imm",
5017 (BICri rGPR:$Rdn, rGPR:$Rdn, so_imm_not:$imm,
5018 pred:$p, cc_out:$s)>;
5020 // Likewise, "add Rd, so_imm_neg" -> sub
5021 def : ARMInstAlias<"add${s}${p} $Rd, $Rn, $imm",
5022 (SUBri GPR:$Rd, GPR:$Rn, so_imm_neg:$imm, pred:$p, cc_out:$s)>;
5023 def : ARMInstAlias<"add${s}${p} $Rd, $imm",
5024 (SUBri GPR:$Rd, GPR:$Rd, so_imm_neg:$imm, pred:$p, cc_out:$s)>;
5025 // Same for CMP <--> CMN via so_imm_neg
5026 def : ARMInstAlias<"cmp${p} $Rd, $imm",
5027 (CMNzri rGPR:$Rd, so_imm_neg:$imm, pred:$p)>;
5028 def : ARMInstAlias<"cmn${p} $Rd, $imm",
5029 (CMPri rGPR:$Rd, so_imm_neg:$imm, pred:$p)>;
5031 // The shifter forms of the MOV instruction are aliased to the ASR, LSL,
5032 // LSR, ROR, and RRX instructions.
5033 // FIXME: We need C++ parser hooks to map the alias to the MOV
5034 // encoding. It seems we should be able to do that sort of thing
5035 // in tblgen, but it could get ugly.
5036 let TwoOperandAliasConstraint = "$Rm = $Rd" in {
5037 def ASRi : ARMAsmPseudo<"asr${s}${p} $Rd, $Rm, $imm",
5038 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
5040 def LSRi : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rm, $imm",
5041 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
5043 def LSLi : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rm, $imm",
5044 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
5046 def RORi : ARMAsmPseudo<"ror${s}${p} $Rd, $Rm, $imm",
5047 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
5050 def RRXi : ARMAsmPseudo<"rrx${s}${p} $Rd, $Rm",
5051 (ins GPRnopc:$Rd, GPRnopc:$Rm, pred:$p, cc_out:$s)>;
5052 let TwoOperandAliasConstraint = "$Rn = $Rd" in {
5053 def ASRr : ARMAsmPseudo<"asr${s}${p} $Rd, $Rn, $Rm",
5054 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5056 def LSRr : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rn, $Rm",
5057 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5059 def LSLr : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rn, $Rm",
5060 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5062 def RORr : ARMAsmPseudo<"ror${s}${p} $Rd, $Rn, $Rm",
5063 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5067 // "neg" is and alias for "rsb rd, rn, #0"
5068 def : ARMInstAlias<"neg${s}${p} $Rd, $Rm",
5069 (RSBri GPR:$Rd, GPR:$Rm, 0, pred:$p, cc_out:$s)>;
5071 // Pre-v6, 'mov r0, r0' was used as a NOP encoding.
5072 def : InstAlias<"nop${p}", (MOVr R0, R0, pred:$p, zero_reg)>,
5073 Requires<[IsARM, NoV6]>;
5075 // UMULL/SMULL are available on all arches, but the instruction definitions
5076 // need difference constraints pre-v6. Use these aliases for the assembly
5077 // parsing on pre-v6.
5078 def : InstAlias<"smull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5079 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5080 Requires<[IsARM, NoV6]>;
5081 def : InstAlias<"umull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5082 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5083 Requires<[IsARM, NoV6]>;
5085 // 'it' blocks in ARM mode just validate the predicates. The IT itself
5087 def ITasm : ARMAsmPseudo<"it$mask $cc", (ins it_pred:$cc, it_mask:$mask)>;