1 //===- ARMInstrInfo.td - Target Description for ARM Target -*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the ARM instructions in TableGen format.
12 //===----------------------------------------------------------------------===//
14 //===----------------------------------------------------------------------===//
15 // ARM specific DAG Nodes.
19 def SDT_ARMCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
20 def SDT_ARMCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>, SDTCisVT<1, i32> ]>;
21 def SDT_ARMStructByVal : SDTypeProfile<0, 4,
22 [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
23 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
25 def SDT_ARMSaveCallPC : SDTypeProfile<0, 1, []>;
27 def SDT_ARMcall : SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>;
29 def SDT_ARMCMov : SDTypeProfile<1, 3,
30 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
33 def SDT_ARMBrcond : SDTypeProfile<0, 2,
34 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i32>]>;
36 def SDT_ARMBrJT : SDTypeProfile<0, 3,
37 [SDTCisPtrTy<0>, SDTCisVT<1, i32>,
40 def SDT_ARMBr2JT : SDTypeProfile<0, 4,
41 [SDTCisPtrTy<0>, SDTCisVT<1, i32>,
42 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
44 def SDT_ARMBCC_i64 : SDTypeProfile<0, 6,
46 SDTCisVT<1, i32>, SDTCisVT<2, i32>,
47 SDTCisVT<3, i32>, SDTCisVT<4, i32>,
48 SDTCisVT<5, OtherVT>]>;
50 def SDT_ARMAnd : SDTypeProfile<1, 2,
51 [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
54 def SDT_ARMCmp : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
56 def SDT_ARMPICAdd : SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>,
57 SDTCisPtrTy<1>, SDTCisVT<2, i32>]>;
59 def SDT_ARMThreadPointer : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
60 def SDT_ARMEH_SJLJ_Setjmp : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisPtrTy<1>,
62 def SDT_ARMEH_SJLJ_Longjmp: SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
64 def SDT_ARMMEMBARRIER : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
66 def SDT_ARMPREFETCH : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisSameAs<1, 2>,
69 def SDT_ARMTCRET : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
71 def SDT_ARMBFI : SDTypeProfile<1, 3, [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
72 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
74 def SDTBinaryArithWithFlags : SDTypeProfile<2, 2,
77 SDTCisInt<0>, SDTCisVT<1, i32>]>;
79 // SDTBinaryArithWithFlagsInOut - RES1, CPSR = op LHS, RHS, CPSR
80 def SDTBinaryArithWithFlagsInOut : SDTypeProfile<2, 3,
87 def ARMWrapper : SDNode<"ARMISD::Wrapper", SDTIntUnaryOp>;
88 def ARMWrapperDYN : SDNode<"ARMISD::WrapperDYN", SDTIntUnaryOp>;
89 def ARMWrapperPIC : SDNode<"ARMISD::WrapperPIC", SDTIntUnaryOp>;
90 def ARMWrapperJT : SDNode<"ARMISD::WrapperJT", SDTIntBinOp>;
92 def ARMcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_ARMCallSeqStart,
93 [SDNPHasChain, SDNPOutGlue]>;
94 def ARMcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_ARMCallSeqEnd,
95 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
96 def ARMcopystructbyval : SDNode<"ARMISD::COPY_STRUCT_BYVAL" ,
98 [SDNPHasChain, SDNPInGlue, SDNPOutGlue,
99 SDNPMayStore, SDNPMayLoad]>;
101 def ARMcall : SDNode<"ARMISD::CALL", SDT_ARMcall,
102 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
104 def ARMcall_pred : SDNode<"ARMISD::CALL_PRED", SDT_ARMcall,
105 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
107 def ARMcall_nolink : SDNode<"ARMISD::CALL_NOLINK", SDT_ARMcall,
108 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
111 def ARMretflag : SDNode<"ARMISD::RET_FLAG", SDTNone,
112 [SDNPHasChain, SDNPOptInGlue]>;
114 def ARMcmov : SDNode<"ARMISD::CMOV", SDT_ARMCMov,
117 def ARMbrcond : SDNode<"ARMISD::BRCOND", SDT_ARMBrcond,
118 [SDNPHasChain, SDNPInGlue, SDNPOutGlue]>;
120 def ARMbrjt : SDNode<"ARMISD::BR_JT", SDT_ARMBrJT,
122 def ARMbr2jt : SDNode<"ARMISD::BR2_JT", SDT_ARMBr2JT,
125 def ARMBcci64 : SDNode<"ARMISD::BCC_i64", SDT_ARMBCC_i64,
128 def ARMcmp : SDNode<"ARMISD::CMP", SDT_ARMCmp,
131 def ARMcmn : SDNode<"ARMISD::CMN", SDT_ARMCmp,
134 def ARMcmpZ : SDNode<"ARMISD::CMPZ", SDT_ARMCmp,
135 [SDNPOutGlue, SDNPCommutative]>;
137 def ARMpic_add : SDNode<"ARMISD::PIC_ADD", SDT_ARMPICAdd>;
139 def ARMsrl_flag : SDNode<"ARMISD::SRL_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
140 def ARMsra_flag : SDNode<"ARMISD::SRA_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
141 def ARMrrx : SDNode<"ARMISD::RRX" , SDTIntUnaryOp, [SDNPInGlue ]>;
143 def ARMaddc : SDNode<"ARMISD::ADDC", SDTBinaryArithWithFlags,
145 def ARMsubc : SDNode<"ARMISD::SUBC", SDTBinaryArithWithFlags>;
146 def ARMadde : SDNode<"ARMISD::ADDE", SDTBinaryArithWithFlagsInOut>;
147 def ARMsube : SDNode<"ARMISD::SUBE", SDTBinaryArithWithFlagsInOut>;
149 def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>;
150 def ARMeh_sjlj_setjmp: SDNode<"ARMISD::EH_SJLJ_SETJMP",
151 SDT_ARMEH_SJLJ_Setjmp, [SDNPHasChain]>;
152 def ARMeh_sjlj_longjmp: SDNode<"ARMISD::EH_SJLJ_LONGJMP",
153 SDT_ARMEH_SJLJ_Longjmp, [SDNPHasChain]>;
155 def ARMMemBarrier : SDNode<"ARMISD::MEMBARRIER", SDT_ARMMEMBARRIER,
157 def ARMMemBarrierMCR : SDNode<"ARMISD::MEMBARRIER_MCR", SDT_ARMMEMBARRIER,
159 def ARMPreload : SDNode<"ARMISD::PRELOAD", SDT_ARMPREFETCH,
160 [SDNPHasChain, SDNPMayLoad, SDNPMayStore]>;
162 def ARMrbit : SDNode<"ARMISD::RBIT", SDTIntUnaryOp>;
164 def ARMtcret : SDNode<"ARMISD::TC_RETURN", SDT_ARMTCRET,
165 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
168 def ARMbfi : SDNode<"ARMISD::BFI", SDT_ARMBFI>;
170 //===----------------------------------------------------------------------===//
171 // ARM Instruction Predicate Definitions.
173 def HasV4T : Predicate<"Subtarget->hasV4TOps()">,
174 AssemblerPredicate<"HasV4TOps", "armv4t">;
175 def NoV4T : Predicate<"!Subtarget->hasV4TOps()">;
176 def HasV5T : Predicate<"Subtarget->hasV5TOps()">;
177 def HasV5TE : Predicate<"Subtarget->hasV5TEOps()">,
178 AssemblerPredicate<"HasV5TEOps", "armv5te">;
179 def HasV6 : Predicate<"Subtarget->hasV6Ops()">,
180 AssemblerPredicate<"HasV6Ops", "armv6">;
181 def NoV6 : Predicate<"!Subtarget->hasV6Ops()">;
182 def HasV6T2 : Predicate<"Subtarget->hasV6T2Ops()">,
183 AssemblerPredicate<"HasV6T2Ops", "armv6t2">;
184 def NoV6T2 : Predicate<"!Subtarget->hasV6T2Ops()">;
185 def HasV7 : Predicate<"Subtarget->hasV7Ops()">,
186 AssemblerPredicate<"HasV7Ops", "armv7">;
187 def NoVFP : Predicate<"!Subtarget->hasVFP2()">;
188 def HasVFP2 : Predicate<"Subtarget->hasVFP2()">,
189 AssemblerPredicate<"FeatureVFP2", "VFP2">;
190 def HasVFP3 : Predicate<"Subtarget->hasVFP3()">,
191 AssemblerPredicate<"FeatureVFP3", "VFP3">;
192 def HasVFP4 : Predicate<"Subtarget->hasVFP4()">,
193 AssemblerPredicate<"FeatureVFP4", "VFP4">;
194 def HasNEON : Predicate<"Subtarget->hasNEON()">,
195 AssemblerPredicate<"FeatureNEON", "NEON">;
196 def HasFP16 : Predicate<"Subtarget->hasFP16()">,
197 AssemblerPredicate<"FeatureFP16","half-float">;
198 def HasDivide : Predicate<"Subtarget->hasDivide()">,
199 AssemblerPredicate<"FeatureHWDiv", "divide">;
200 def HasT2ExtractPack : Predicate<"Subtarget->hasT2ExtractPack()">,
201 AssemblerPredicate<"FeatureT2XtPk",
203 def HasThumb2DSP : Predicate<"Subtarget->hasThumb2DSP()">,
204 AssemblerPredicate<"FeatureDSPThumb2",
206 def HasDB : Predicate<"Subtarget->hasDataBarrier()">,
207 AssemblerPredicate<"FeatureDB",
209 def HasMP : Predicate<"Subtarget->hasMPExtension()">,
210 AssemblerPredicate<"FeatureMP",
212 def UseNEONForFP : Predicate<"Subtarget->useNEONForSinglePrecisionFP()">;
213 def DontUseNEONForFP : Predicate<"!Subtarget->useNEONForSinglePrecisionFP()">;
214 def IsThumb : Predicate<"Subtarget->isThumb()">,
215 AssemblerPredicate<"ModeThumb", "thumb">;
216 def IsThumb1Only : Predicate<"Subtarget->isThumb1Only()">;
217 def IsThumb2 : Predicate<"Subtarget->isThumb2()">,
218 AssemblerPredicate<"ModeThumb,FeatureThumb2",
220 def IsMClass : Predicate<"Subtarget->isMClass()">,
221 AssemblerPredicate<"FeatureMClass", "armv7m">;
222 def IsARClass : Predicate<"!Subtarget->isMClass()">,
223 AssemblerPredicate<"!FeatureMClass",
225 def IsARM : Predicate<"!Subtarget->isThumb()">,
226 AssemblerPredicate<"!ModeThumb", "arm-mode">;
227 def IsIOS : Predicate<"Subtarget->isTargetIOS()">;
228 def IsNotIOS : Predicate<"!Subtarget->isTargetIOS()">;
229 def IsNaCl : Predicate<"Subtarget->isTargetNaCl()">;
231 // FIXME: Eventually this will be just "hasV6T2Ops".
232 def UseMovt : Predicate<"Subtarget->useMovt()">;
233 def DontUseMovt : Predicate<"!Subtarget->useMovt()">;
234 def UseFPVMLx : Predicate<"Subtarget->useFPVMLx()">;
236 // Prefer fused MAC for fp mul + add over fp VMLA / VMLS if they are available.
237 // But only select them if more precision in FP computation is allowed.
238 // Do not use them for Darwin platforms.
239 def UseFusedMAC : Predicate<"!TM.Options.NoExcessFPPrecision && "
240 "!Subtarget->isTargetDarwin()">;
241 def DontUseFusedMAC : Predicate<"!Subtarget->hasVFP4() || "
242 "Subtarget->isTargetDarwin()">;
244 //===----------------------------------------------------------------------===//
245 // ARM Flag Definitions.
247 class RegConstraint<string C> {
248 string Constraints = C;
251 //===----------------------------------------------------------------------===//
252 // ARM specific transformation functions and pattern fragments.
255 // so_imm_neg_XFORM - Return a so_imm value packed into the format described for
256 // so_imm_neg def below.
257 def so_imm_neg_XFORM : SDNodeXForm<imm, [{
258 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), MVT::i32);
261 // so_imm_not_XFORM - Return a so_imm value packed into the format described for
262 // so_imm_not def below.
263 def so_imm_not_XFORM : SDNodeXForm<imm, [{
264 return CurDAG->getTargetConstant(~(int)N->getZExtValue(), MVT::i32);
267 /// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
268 def imm16_31 : ImmLeaf<i32, [{
269 return (int32_t)Imm >= 16 && (int32_t)Imm < 32;
272 def so_imm_neg_asmoperand : AsmOperandClass { let Name = "ARMSOImmNeg"; }
273 def so_imm_neg : Operand<i32>, PatLeaf<(imm), [{
274 int64_t Value = -(int)N->getZExtValue();
275 return Value && ARM_AM::getSOImmVal(Value) != -1;
276 }], so_imm_neg_XFORM> {
277 let ParserMatchClass = so_imm_neg_asmoperand;
280 // Note: this pattern doesn't require an encoder method and such, as it's
281 // only used on aliases (Pat<> and InstAlias<>). The actual encoding
282 // is handled by the destination instructions, which use so_imm.
283 def so_imm_not_asmoperand : AsmOperandClass { let Name = "ARMSOImmNot"; }
284 def so_imm_not : Operand<i32>, PatLeaf<(imm), [{
285 return ARM_AM::getSOImmVal(~(uint32_t)N->getZExtValue()) != -1;
286 }], so_imm_not_XFORM> {
287 let ParserMatchClass = so_imm_not_asmoperand;
290 // sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
291 def sext_16_node : PatLeaf<(i32 GPR:$a), [{
292 return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17;
295 /// Split a 32-bit immediate into two 16 bit parts.
296 def hi16 : SDNodeXForm<imm, [{
297 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, MVT::i32);
300 def lo16AllZero : PatLeaf<(i32 imm), [{
301 // Returns true if all low 16-bits are 0.
302 return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
305 class BinOpWithFlagFrag<dag res> :
306 PatFrag<(ops node:$LHS, node:$RHS, node:$FLAG), res>;
307 class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
308 class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
310 // An 'and' node with a single use.
311 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
312 return N->hasOneUse();
315 // An 'xor' node with a single use.
316 def xor_su : PatFrag<(ops node:$lhs, node:$rhs), (xor node:$lhs, node:$rhs), [{
317 return N->hasOneUse();
320 // An 'fmul' node with a single use.
321 def fmul_su : PatFrag<(ops node:$lhs, node:$rhs), (fmul node:$lhs, node:$rhs),[{
322 return N->hasOneUse();
325 // An 'fadd' node which checks for single non-hazardous use.
326 def fadd_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fadd node:$lhs, node:$rhs),[{
327 return hasNoVMLxHazardUse(N);
330 // An 'fsub' node which checks for single non-hazardous use.
331 def fsub_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fsub node:$lhs, node:$rhs),[{
332 return hasNoVMLxHazardUse(N);
335 //===----------------------------------------------------------------------===//
336 // Operand Definitions.
339 // Immediate operands with a shared generic asm render method.
340 class ImmAsmOperand : AsmOperandClass { let RenderMethod = "addImmOperands"; }
343 // FIXME: rename brtarget to t2_brtarget
344 def brtarget : Operand<OtherVT> {
345 let EncoderMethod = "getBranchTargetOpValue";
346 let OperandType = "OPERAND_PCREL";
347 let DecoderMethod = "DecodeT2BROperand";
350 // FIXME: get rid of this one?
351 def uncondbrtarget : Operand<OtherVT> {
352 let EncoderMethod = "getUnconditionalBranchTargetOpValue";
353 let OperandType = "OPERAND_PCREL";
356 // Branch target for ARM. Handles conditional/unconditional
357 def br_target : Operand<OtherVT> {
358 let EncoderMethod = "getARMBranchTargetOpValue";
359 let OperandType = "OPERAND_PCREL";
363 // FIXME: rename bltarget to t2_bl_target?
364 def bltarget : Operand<i32> {
365 // Encoded the same as branch targets.
366 let EncoderMethod = "getBranchTargetOpValue";
367 let OperandType = "OPERAND_PCREL";
370 // Call target for ARM. Handles conditional/unconditional
371 // FIXME: rename bl_target to t2_bltarget?
372 def bl_target : Operand<i32> {
373 let EncoderMethod = "getARMBLTargetOpValue";
374 let OperandType = "OPERAND_PCREL";
377 def blx_target : Operand<i32> {
378 let EncoderMethod = "getARMBLXTargetOpValue";
379 let OperandType = "OPERAND_PCREL";
382 // A list of registers separated by comma. Used by load/store multiple.
383 def RegListAsmOperand : AsmOperandClass { let Name = "RegList"; }
384 def reglist : Operand<i32> {
385 let EncoderMethod = "getRegisterListOpValue";
386 let ParserMatchClass = RegListAsmOperand;
387 let PrintMethod = "printRegisterList";
388 let DecoderMethod = "DecodeRegListOperand";
391 def DPRRegListAsmOperand : AsmOperandClass { let Name = "DPRRegList"; }
392 def dpr_reglist : Operand<i32> {
393 let EncoderMethod = "getRegisterListOpValue";
394 let ParserMatchClass = DPRRegListAsmOperand;
395 let PrintMethod = "printRegisterList";
396 let DecoderMethod = "DecodeDPRRegListOperand";
399 def SPRRegListAsmOperand : AsmOperandClass { let Name = "SPRRegList"; }
400 def spr_reglist : Operand<i32> {
401 let EncoderMethod = "getRegisterListOpValue";
402 let ParserMatchClass = SPRRegListAsmOperand;
403 let PrintMethod = "printRegisterList";
404 let DecoderMethod = "DecodeSPRRegListOperand";
407 // An operand for the CONSTPOOL_ENTRY pseudo-instruction.
408 def cpinst_operand : Operand<i32> {
409 let PrintMethod = "printCPInstOperand";
413 def pclabel : Operand<i32> {
414 let PrintMethod = "printPCLabel";
417 // ADR instruction labels.
418 def adrlabel : Operand<i32> {
419 let EncoderMethod = "getAdrLabelOpValue";
422 def neon_vcvt_imm32 : Operand<i32> {
423 let EncoderMethod = "getNEONVcvtImm32OpValue";
424 let DecoderMethod = "DecodeVCVTImmOperand";
427 // rot_imm: An integer that encodes a rotate amount. Must be 8, 16, or 24.
428 def rot_imm_XFORM: SDNodeXForm<imm, [{
429 switch (N->getZExtValue()){
431 case 0: return CurDAG->getTargetConstant(0, MVT::i32);
432 case 8: return CurDAG->getTargetConstant(1, MVT::i32);
433 case 16: return CurDAG->getTargetConstant(2, MVT::i32);
434 case 24: return CurDAG->getTargetConstant(3, MVT::i32);
437 def RotImmAsmOperand : AsmOperandClass {
439 let ParserMethod = "parseRotImm";
441 def rot_imm : Operand<i32>, PatLeaf<(i32 imm), [{
442 int32_t v = N->getZExtValue();
443 return v == 8 || v == 16 || v == 24; }],
445 let PrintMethod = "printRotImmOperand";
446 let ParserMatchClass = RotImmAsmOperand;
449 // shift_imm: An integer that encodes a shift amount and the type of shift
450 // (asr or lsl). The 6-bit immediate encodes as:
453 // {4-0} imm5 shift amount.
454 // asr #32 encoded as imm5 == 0.
455 def ShifterImmAsmOperand : AsmOperandClass {
456 let Name = "ShifterImm";
457 let ParserMethod = "parseShifterImm";
459 def shift_imm : Operand<i32> {
460 let PrintMethod = "printShiftImmOperand";
461 let ParserMatchClass = ShifterImmAsmOperand;
464 // shifter_operand operands: so_reg_reg, so_reg_imm, and so_imm.
465 def ShiftedRegAsmOperand : AsmOperandClass { let Name = "RegShiftedReg"; }
466 def so_reg_reg : Operand<i32>, // reg reg imm
467 ComplexPattern<i32, 3, "SelectRegShifterOperand",
468 [shl, srl, sra, rotr]> {
469 let EncoderMethod = "getSORegRegOpValue";
470 let PrintMethod = "printSORegRegOperand";
471 let DecoderMethod = "DecodeSORegRegOperand";
472 let ParserMatchClass = ShiftedRegAsmOperand;
473 let MIOperandInfo = (ops GPRnopc, GPRnopc, i32imm);
476 def ShiftedImmAsmOperand : AsmOperandClass { let Name = "RegShiftedImm"; }
477 def so_reg_imm : Operand<i32>, // reg imm
478 ComplexPattern<i32, 2, "SelectImmShifterOperand",
479 [shl, srl, sra, rotr]> {
480 let EncoderMethod = "getSORegImmOpValue";
481 let PrintMethod = "printSORegImmOperand";
482 let DecoderMethod = "DecodeSORegImmOperand";
483 let ParserMatchClass = ShiftedImmAsmOperand;
484 let MIOperandInfo = (ops GPR, i32imm);
487 // FIXME: Does this need to be distinct from so_reg?
488 def shift_so_reg_reg : Operand<i32>, // reg reg imm
489 ComplexPattern<i32, 3, "SelectShiftRegShifterOperand",
490 [shl,srl,sra,rotr]> {
491 let EncoderMethod = "getSORegRegOpValue";
492 let PrintMethod = "printSORegRegOperand";
493 let DecoderMethod = "DecodeSORegRegOperand";
494 let ParserMatchClass = ShiftedRegAsmOperand;
495 let MIOperandInfo = (ops GPR, GPR, i32imm);
498 // FIXME: Does this need to be distinct from so_reg?
499 def shift_so_reg_imm : Operand<i32>, // reg reg imm
500 ComplexPattern<i32, 2, "SelectShiftImmShifterOperand",
501 [shl,srl,sra,rotr]> {
502 let EncoderMethod = "getSORegImmOpValue";
503 let PrintMethod = "printSORegImmOperand";
504 let DecoderMethod = "DecodeSORegImmOperand";
505 let ParserMatchClass = ShiftedImmAsmOperand;
506 let MIOperandInfo = (ops GPR, i32imm);
510 // so_imm - Match a 32-bit shifter_operand immediate operand, which is an
511 // 8-bit immediate rotated by an arbitrary number of bits.
512 def SOImmAsmOperand: ImmAsmOperand { let Name = "ARMSOImm"; }
513 def so_imm : Operand<i32>, ImmLeaf<i32, [{
514 return ARM_AM::getSOImmVal(Imm) != -1;
516 let EncoderMethod = "getSOImmOpValue";
517 let ParserMatchClass = SOImmAsmOperand;
518 let DecoderMethod = "DecodeSOImmOperand";
521 // Break so_imm's up into two pieces. This handles immediates with up to 16
522 // bits set in them. This uses so_imm2part to match and so_imm2part_[12] to
523 // get the first/second pieces.
524 def so_imm2part : PatLeaf<(imm), [{
525 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
528 /// arm_i32imm - True for +V6T2, or true only if so_imm2part is true.
530 def arm_i32imm : PatLeaf<(imm), [{
531 if (Subtarget->hasV6T2Ops())
533 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
536 /// imm0_1 predicate - Immediate in the range [0,1].
537 def Imm0_1AsmOperand: ImmAsmOperand { let Name = "Imm0_1"; }
538 def imm0_1 : Operand<i32> { let ParserMatchClass = Imm0_1AsmOperand; }
540 /// imm0_3 predicate - Immediate in the range [0,3].
541 def Imm0_3AsmOperand: ImmAsmOperand { let Name = "Imm0_3"; }
542 def imm0_3 : Operand<i32> { let ParserMatchClass = Imm0_3AsmOperand; }
544 /// imm0_7 predicate - Immediate in the range [0,7].
545 def Imm0_7AsmOperand: ImmAsmOperand { let Name = "Imm0_7"; }
546 def imm0_7 : Operand<i32>, ImmLeaf<i32, [{
547 return Imm >= 0 && Imm < 8;
549 let ParserMatchClass = Imm0_7AsmOperand;
552 /// imm8 predicate - Immediate is exactly 8.
553 def Imm8AsmOperand: ImmAsmOperand { let Name = "Imm8"; }
554 def imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 8; }]> {
555 let ParserMatchClass = Imm8AsmOperand;
558 /// imm16 predicate - Immediate is exactly 16.
559 def Imm16AsmOperand: ImmAsmOperand { let Name = "Imm16"; }
560 def imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 16; }]> {
561 let ParserMatchClass = Imm16AsmOperand;
564 /// imm32 predicate - Immediate is exactly 32.
565 def Imm32AsmOperand: ImmAsmOperand { let Name = "Imm32"; }
566 def imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 32; }]> {
567 let ParserMatchClass = Imm32AsmOperand;
570 /// imm1_7 predicate - Immediate in the range [1,7].
571 def Imm1_7AsmOperand: ImmAsmOperand { let Name = "Imm1_7"; }
572 def imm1_7 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 8; }]> {
573 let ParserMatchClass = Imm1_7AsmOperand;
576 /// imm1_15 predicate - Immediate in the range [1,15].
577 def Imm1_15AsmOperand: ImmAsmOperand { let Name = "Imm1_15"; }
578 def imm1_15 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 16; }]> {
579 let ParserMatchClass = Imm1_15AsmOperand;
582 /// imm1_31 predicate - Immediate in the range [1,31].
583 def Imm1_31AsmOperand: ImmAsmOperand { let Name = "Imm1_31"; }
584 def imm1_31 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 32; }]> {
585 let ParserMatchClass = Imm1_31AsmOperand;
588 /// imm0_15 predicate - Immediate in the range [0,15].
589 def Imm0_15AsmOperand: ImmAsmOperand { let Name = "Imm0_15"; }
590 def imm0_15 : Operand<i32>, ImmLeaf<i32, [{
591 return Imm >= 0 && Imm < 16;
593 let ParserMatchClass = Imm0_15AsmOperand;
596 /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
597 def Imm0_31AsmOperand: ImmAsmOperand { let Name = "Imm0_31"; }
598 def imm0_31 : Operand<i32>, ImmLeaf<i32, [{
599 return Imm >= 0 && Imm < 32;
601 let ParserMatchClass = Imm0_31AsmOperand;
604 /// imm0_32 predicate - True if the 32-bit immediate is in the range [0,32].
605 def Imm0_32AsmOperand: ImmAsmOperand { let Name = "Imm0_32"; }
606 def imm0_32 : Operand<i32>, ImmLeaf<i32, [{
607 return Imm >= 0 && Imm < 32;
609 let ParserMatchClass = Imm0_32AsmOperand;
612 /// imm0_63 predicate - True if the 32-bit immediate is in the range [0,63].
613 def Imm0_63AsmOperand: ImmAsmOperand { let Name = "Imm0_63"; }
614 def imm0_63 : Operand<i32>, ImmLeaf<i32, [{
615 return Imm >= 0 && Imm < 64;
617 let ParserMatchClass = Imm0_63AsmOperand;
620 /// imm0_255 predicate - Immediate in the range [0,255].
621 def Imm0_255AsmOperand : ImmAsmOperand { let Name = "Imm0_255"; }
622 def imm0_255 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 256; }]> {
623 let ParserMatchClass = Imm0_255AsmOperand;
626 /// imm0_65535 - An immediate is in the range [0.65535].
627 def Imm0_65535AsmOperand: ImmAsmOperand { let Name = "Imm0_65535"; }
628 def imm0_65535 : Operand<i32>, ImmLeaf<i32, [{
629 return Imm >= 0 && Imm < 65536;
631 let ParserMatchClass = Imm0_65535AsmOperand;
634 // imm0_65535_expr - For movt/movw - 16-bit immediate that can also reference
635 // a relocatable expression.
637 // FIXME: This really needs a Thumb version separate from the ARM version.
638 // While the range is the same, and can thus use the same match class,
639 // the encoding is different so it should have a different encoder method.
640 def Imm0_65535ExprAsmOperand: ImmAsmOperand { let Name = "Imm0_65535Expr"; }
641 def imm0_65535_expr : Operand<i32> {
642 let EncoderMethod = "getHiLo16ImmOpValue";
643 let ParserMatchClass = Imm0_65535ExprAsmOperand;
646 /// imm24b - True if the 32-bit immediate is encodable in 24 bits.
647 def Imm24bitAsmOperand: ImmAsmOperand { let Name = "Imm24bit"; }
648 def imm24b : Operand<i32>, ImmLeaf<i32, [{
649 return Imm >= 0 && Imm <= 0xffffff;
651 let ParserMatchClass = Imm24bitAsmOperand;
655 /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
657 def BitfieldAsmOperand : AsmOperandClass {
658 let Name = "Bitfield";
659 let ParserMethod = "parseBitfield";
662 def bf_inv_mask_imm : Operand<i32>,
664 return ARM::isBitFieldInvertedMask(N->getZExtValue());
666 let EncoderMethod = "getBitfieldInvertedMaskOpValue";
667 let PrintMethod = "printBitfieldInvMaskImmOperand";
668 let DecoderMethod = "DecodeBitfieldMaskOperand";
669 let ParserMatchClass = BitfieldAsmOperand;
672 def imm1_32_XFORM: SDNodeXForm<imm, [{
673 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, MVT::i32);
675 def Imm1_32AsmOperand: AsmOperandClass { let Name = "Imm1_32"; }
676 def imm1_32 : Operand<i32>, PatLeaf<(imm), [{
677 uint64_t Imm = N->getZExtValue();
678 return Imm > 0 && Imm <= 32;
681 let PrintMethod = "printImmPlusOneOperand";
682 let ParserMatchClass = Imm1_32AsmOperand;
685 def imm1_16_XFORM: SDNodeXForm<imm, [{
686 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, MVT::i32);
688 def Imm1_16AsmOperand: AsmOperandClass { let Name = "Imm1_16"; }
689 def imm1_16 : Operand<i32>, PatLeaf<(imm), [{ return Imm > 0 && Imm <= 16; }],
691 let PrintMethod = "printImmPlusOneOperand";
692 let ParserMatchClass = Imm1_16AsmOperand;
695 // Define ARM specific addressing modes.
696 // addrmode_imm12 := reg +/- imm12
698 def MemImm12OffsetAsmOperand : AsmOperandClass { let Name = "MemImm12Offset"; }
699 def addrmode_imm12 : Operand<i32>,
700 ComplexPattern<i32, 2, "SelectAddrModeImm12", []> {
701 // 12-bit immediate operand. Note that instructions using this encode
702 // #0 and #-0 differently. We flag #-0 as the magic value INT32_MIN. All other
703 // immediate values are as normal.
705 let EncoderMethod = "getAddrModeImm12OpValue";
706 let PrintMethod = "printAddrModeImm12Operand";
707 let DecoderMethod = "DecodeAddrModeImm12Operand";
708 let ParserMatchClass = MemImm12OffsetAsmOperand;
709 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
711 // ldst_so_reg := reg +/- reg shop imm
713 def MemRegOffsetAsmOperand : AsmOperandClass { let Name = "MemRegOffset"; }
714 def ldst_so_reg : Operand<i32>,
715 ComplexPattern<i32, 3, "SelectLdStSOReg", []> {
716 let EncoderMethod = "getLdStSORegOpValue";
717 // FIXME: Simplify the printer
718 let PrintMethod = "printAddrMode2Operand";
719 let DecoderMethod = "DecodeSORegMemOperand";
720 let ParserMatchClass = MemRegOffsetAsmOperand;
721 let MIOperandInfo = (ops GPR:$base, GPRnopc:$offsreg, i32imm:$shift);
724 // postidx_imm8 := +/- [0,255]
727 // {8} 1 is imm8 is non-negative. 0 otherwise.
728 // {7-0} [0,255] imm8 value.
729 def PostIdxImm8AsmOperand : AsmOperandClass { let Name = "PostIdxImm8"; }
730 def postidx_imm8 : Operand<i32> {
731 let PrintMethod = "printPostIdxImm8Operand";
732 let ParserMatchClass = PostIdxImm8AsmOperand;
733 let MIOperandInfo = (ops i32imm);
736 // postidx_imm8s4 := +/- [0,1020]
739 // {8} 1 is imm8 is non-negative. 0 otherwise.
740 // {7-0} [0,255] imm8 value, scaled by 4.
741 def PostIdxImm8s4AsmOperand : AsmOperandClass { let Name = "PostIdxImm8s4"; }
742 def postidx_imm8s4 : Operand<i32> {
743 let PrintMethod = "printPostIdxImm8s4Operand";
744 let ParserMatchClass = PostIdxImm8s4AsmOperand;
745 let MIOperandInfo = (ops i32imm);
749 // postidx_reg := +/- reg
751 def PostIdxRegAsmOperand : AsmOperandClass {
752 let Name = "PostIdxReg";
753 let ParserMethod = "parsePostIdxReg";
755 def postidx_reg : Operand<i32> {
756 let EncoderMethod = "getPostIdxRegOpValue";
757 let DecoderMethod = "DecodePostIdxReg";
758 let PrintMethod = "printPostIdxRegOperand";
759 let ParserMatchClass = PostIdxRegAsmOperand;
760 let MIOperandInfo = (ops GPRnopc, i32imm);
764 // addrmode2 := reg +/- imm12
765 // := reg +/- reg shop imm
767 // FIXME: addrmode2 should be refactored the rest of the way to always
768 // use explicit imm vs. reg versions above (addrmode_imm12 and ldst_so_reg).
769 def AddrMode2AsmOperand : AsmOperandClass { let Name = "AddrMode2"; }
770 def addrmode2 : Operand<i32>,
771 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
772 let EncoderMethod = "getAddrMode2OpValue";
773 let PrintMethod = "printAddrMode2Operand";
774 let ParserMatchClass = AddrMode2AsmOperand;
775 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
778 def PostIdxRegShiftedAsmOperand : AsmOperandClass {
779 let Name = "PostIdxRegShifted";
780 let ParserMethod = "parsePostIdxReg";
782 def am2offset_reg : Operand<i32>,
783 ComplexPattern<i32, 2, "SelectAddrMode2OffsetReg",
784 [], [SDNPWantRoot]> {
785 let EncoderMethod = "getAddrMode2OffsetOpValue";
786 let PrintMethod = "printAddrMode2OffsetOperand";
787 // When using this for assembly, it's always as a post-index offset.
788 let ParserMatchClass = PostIdxRegShiftedAsmOperand;
789 let MIOperandInfo = (ops GPRnopc, i32imm);
792 // FIXME: am2offset_imm should only need the immediate, not the GPR. Having
793 // the GPR is purely vestigal at this point.
794 def AM2OffsetImmAsmOperand : AsmOperandClass { let Name = "AM2OffsetImm"; }
795 def am2offset_imm : Operand<i32>,
796 ComplexPattern<i32, 2, "SelectAddrMode2OffsetImm",
797 [], [SDNPWantRoot]> {
798 let EncoderMethod = "getAddrMode2OffsetOpValue";
799 let PrintMethod = "printAddrMode2OffsetOperand";
800 let ParserMatchClass = AM2OffsetImmAsmOperand;
801 let MIOperandInfo = (ops GPRnopc, i32imm);
805 // addrmode3 := reg +/- reg
806 // addrmode3 := reg +/- imm8
808 // FIXME: split into imm vs. reg versions.
809 def AddrMode3AsmOperand : AsmOperandClass { let Name = "AddrMode3"; }
810 def addrmode3 : Operand<i32>,
811 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
812 let EncoderMethod = "getAddrMode3OpValue";
813 let PrintMethod = "printAddrMode3Operand";
814 let ParserMatchClass = AddrMode3AsmOperand;
815 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
818 // FIXME: split into imm vs. reg versions.
819 // FIXME: parser method to handle +/- register.
820 def AM3OffsetAsmOperand : AsmOperandClass {
821 let Name = "AM3Offset";
822 let ParserMethod = "parseAM3Offset";
824 def am3offset : Operand<i32>,
825 ComplexPattern<i32, 2, "SelectAddrMode3Offset",
826 [], [SDNPWantRoot]> {
827 let EncoderMethod = "getAddrMode3OffsetOpValue";
828 let PrintMethod = "printAddrMode3OffsetOperand";
829 let ParserMatchClass = AM3OffsetAsmOperand;
830 let MIOperandInfo = (ops GPR, i32imm);
833 // ldstm_mode := {ia, ib, da, db}
835 def ldstm_mode : OptionalDefOperand<OtherVT, (ops i32), (ops (i32 1))> {
836 let EncoderMethod = "getLdStmModeOpValue";
837 let PrintMethod = "printLdStmModeOperand";
840 // addrmode5 := reg +/- imm8*4
842 def AddrMode5AsmOperand : AsmOperandClass { let Name = "AddrMode5"; }
843 def addrmode5 : Operand<i32>,
844 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
845 let PrintMethod = "printAddrMode5Operand";
846 let EncoderMethod = "getAddrMode5OpValue";
847 let DecoderMethod = "DecodeAddrMode5Operand";
848 let ParserMatchClass = AddrMode5AsmOperand;
849 let MIOperandInfo = (ops GPR:$base, i32imm);
852 // addrmode6 := reg with optional alignment
854 def AddrMode6AsmOperand : AsmOperandClass { let Name = "AlignedMemory"; }
855 def addrmode6 : Operand<i32>,
856 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
857 let PrintMethod = "printAddrMode6Operand";
858 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
859 let EncoderMethod = "getAddrMode6AddressOpValue";
860 let DecoderMethod = "DecodeAddrMode6Operand";
861 let ParserMatchClass = AddrMode6AsmOperand;
864 def am6offset : Operand<i32>,
865 ComplexPattern<i32, 1, "SelectAddrMode6Offset",
866 [], [SDNPWantRoot]> {
867 let PrintMethod = "printAddrMode6OffsetOperand";
868 let MIOperandInfo = (ops GPR);
869 let EncoderMethod = "getAddrMode6OffsetOpValue";
870 let DecoderMethod = "DecodeGPRRegisterClass";
873 // Special version of addrmode6 to handle alignment encoding for VST1/VLD1
874 // (single element from one lane) for size 32.
875 def addrmode6oneL32 : Operand<i32>,
876 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
877 let PrintMethod = "printAddrMode6Operand";
878 let MIOperandInfo = (ops GPR:$addr, i32imm);
879 let EncoderMethod = "getAddrMode6OneLane32AddressOpValue";
882 // Special version of addrmode6 to handle alignment encoding for VLD-dup
883 // instructions, specifically VLD4-dup.
884 def addrmode6dup : Operand<i32>,
885 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
886 let PrintMethod = "printAddrMode6Operand";
887 let MIOperandInfo = (ops GPR:$addr, i32imm);
888 let EncoderMethod = "getAddrMode6DupAddressOpValue";
889 // FIXME: This is close, but not quite right. The alignment specifier is
891 let ParserMatchClass = AddrMode6AsmOperand;
894 // addrmodepc := pc + reg
896 def addrmodepc : Operand<i32>,
897 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
898 let PrintMethod = "printAddrModePCOperand";
899 let MIOperandInfo = (ops GPR, i32imm);
902 // addr_offset_none := reg
904 def MemNoOffsetAsmOperand : AsmOperandClass { let Name = "MemNoOffset"; }
905 def addr_offset_none : Operand<i32>,
906 ComplexPattern<i32, 1, "SelectAddrOffsetNone", []> {
907 let PrintMethod = "printAddrMode7Operand";
908 let DecoderMethod = "DecodeAddrMode7Operand";
909 let ParserMatchClass = MemNoOffsetAsmOperand;
910 let MIOperandInfo = (ops GPR:$base);
913 def nohash_imm : Operand<i32> {
914 let PrintMethod = "printNoHashImmediate";
917 def CoprocNumAsmOperand : AsmOperandClass {
918 let Name = "CoprocNum";
919 let ParserMethod = "parseCoprocNumOperand";
921 def p_imm : Operand<i32> {
922 let PrintMethod = "printPImmediate";
923 let ParserMatchClass = CoprocNumAsmOperand;
924 let DecoderMethod = "DecodeCoprocessor";
927 def pf_imm : Operand<i32> {
928 let PrintMethod = "printPImmediate";
929 let ParserMatchClass = CoprocNumAsmOperand;
932 def CoprocRegAsmOperand : AsmOperandClass {
933 let Name = "CoprocReg";
934 let ParserMethod = "parseCoprocRegOperand";
936 def c_imm : Operand<i32> {
937 let PrintMethod = "printCImmediate";
938 let ParserMatchClass = CoprocRegAsmOperand;
940 def CoprocOptionAsmOperand : AsmOperandClass {
941 let Name = "CoprocOption";
942 let ParserMethod = "parseCoprocOptionOperand";
944 def coproc_option_imm : Operand<i32> {
945 let PrintMethod = "printCoprocOptionImm";
946 let ParserMatchClass = CoprocOptionAsmOperand;
949 //===----------------------------------------------------------------------===//
951 include "ARMInstrFormats.td"
953 //===----------------------------------------------------------------------===//
954 // Multiclass helpers...
957 /// AsI1_bin_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns for a
958 /// binop that produces a value.
959 let TwoOperandAliasConstraint = "$Rn = $Rd" in
960 multiclass AsI1_bin_irs<bits<4> opcod, string opc,
961 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
962 PatFrag opnode, string baseOpc, bit Commutable = 0> {
963 // The register-immediate version is re-materializable. This is useful
964 // in particular for taking the address of a local.
965 let isReMaterializable = 1 in {
966 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
967 iii, opc, "\t$Rd, $Rn, $imm",
968 [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]> {
973 let Inst{19-16} = Rn;
974 let Inst{15-12} = Rd;
975 let Inst{11-0} = imm;
978 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
979 iir, opc, "\t$Rd, $Rn, $Rm",
980 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]> {
985 let isCommutable = Commutable;
986 let Inst{19-16} = Rn;
987 let Inst{15-12} = Rd;
988 let Inst{11-4} = 0b00000000;
992 def rsi : AsI1<opcod, (outs GPR:$Rd),
993 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
994 iis, opc, "\t$Rd, $Rn, $shift",
995 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_imm:$shift))]> {
1000 let Inst{19-16} = Rn;
1001 let Inst{15-12} = Rd;
1002 let Inst{11-5} = shift{11-5};
1004 let Inst{3-0} = shift{3-0};
1007 def rsr : AsI1<opcod, (outs GPR:$Rd),
1008 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1009 iis, opc, "\t$Rd, $Rn, $shift",
1010 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_reg:$shift))]> {
1015 let Inst{19-16} = Rn;
1016 let Inst{15-12} = Rd;
1017 let Inst{11-8} = shift{11-8};
1019 let Inst{6-5} = shift{6-5};
1021 let Inst{3-0} = shift{3-0};
1025 /// AsI1_rbin_irs - Same as AsI1_bin_irs except the order of operands are
1026 /// reversed. The 'rr' form is only defined for the disassembler; for codegen
1027 /// it is equivalent to the AsI1_bin_irs counterpart.
1028 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1029 multiclass AsI1_rbin_irs<bits<4> opcod, string opc,
1030 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1031 PatFrag opnode, string baseOpc, bit Commutable = 0> {
1032 // The register-immediate version is re-materializable. This is useful
1033 // in particular for taking the address of a local.
1034 let isReMaterializable = 1 in {
1035 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
1036 iii, opc, "\t$Rd, $Rn, $imm",
1037 [(set GPR:$Rd, (opnode so_imm:$imm, GPR:$Rn))]> {
1042 let Inst{19-16} = Rn;
1043 let Inst{15-12} = Rd;
1044 let Inst{11-0} = imm;
1047 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1048 iir, opc, "\t$Rd, $Rn, $Rm",
1049 [/* pattern left blank */]> {
1053 let Inst{11-4} = 0b00000000;
1056 let Inst{15-12} = Rd;
1057 let Inst{19-16} = Rn;
1060 def rsi : AsI1<opcod, (outs GPR:$Rd),
1061 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1062 iis, opc, "\t$Rd, $Rn, $shift",
1063 [(set GPR:$Rd, (opnode so_reg_imm:$shift, GPR:$Rn))]> {
1068 let Inst{19-16} = Rn;
1069 let Inst{15-12} = Rd;
1070 let Inst{11-5} = shift{11-5};
1072 let Inst{3-0} = shift{3-0};
1075 def rsr : AsI1<opcod, (outs GPR:$Rd),
1076 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1077 iis, opc, "\t$Rd, $Rn, $shift",
1078 [(set GPR:$Rd, (opnode so_reg_reg:$shift, GPR:$Rn))]> {
1083 let Inst{19-16} = Rn;
1084 let Inst{15-12} = Rd;
1085 let Inst{11-8} = shift{11-8};
1087 let Inst{6-5} = shift{6-5};
1089 let Inst{3-0} = shift{3-0};
1093 /// AsI1_bin_s_irs - Same as AsI1_bin_irs except it sets the 's' bit by default.
1095 /// These opcodes will be converted to the real non-S opcodes by
1096 /// AdjustInstrPostInstrSelection after giving them an optional CPSR operand.
1097 let hasPostISelHook = 1, Defs = [CPSR] in {
1098 multiclass AsI1_bin_s_irs<InstrItinClass iii, InstrItinClass iir,
1099 InstrItinClass iis, PatFrag opnode,
1100 bit Commutable = 0> {
1101 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm, pred:$p),
1103 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_imm:$imm))]>;
1105 def rr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, pred:$p),
1107 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm))]> {
1108 let isCommutable = Commutable;
1110 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1111 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1113 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1114 so_reg_imm:$shift))]>;
1116 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1117 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1119 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1120 so_reg_reg:$shift))]>;
1124 /// AsI1_rbin_s_is - Same as AsI1_bin_s_irs, except selection DAG
1125 /// operands are reversed.
1126 let hasPostISelHook = 1, Defs = [CPSR] in {
1127 multiclass AsI1_rbin_s_is<InstrItinClass iii, InstrItinClass iir,
1128 InstrItinClass iis, PatFrag opnode,
1129 bit Commutable = 0> {
1130 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm, pred:$p),
1132 [(set GPR:$Rd, CPSR, (opnode so_imm:$imm, GPR:$Rn))]>;
1134 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1135 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1137 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift,
1140 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1141 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1143 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift,
1148 /// AI1_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
1149 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
1150 /// a explicit result, only implicitly set CPSR.
1151 let isCompare = 1, Defs = [CPSR] in {
1152 multiclass AI1_cmp_irs<bits<4> opcod, string opc,
1153 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1154 PatFrag opnode, bit Commutable = 0> {
1155 def ri : AI1<opcod, (outs), (ins GPR:$Rn, so_imm:$imm), DPFrm, iii,
1157 [(opnode GPR:$Rn, so_imm:$imm)]> {
1162 let Inst{19-16} = Rn;
1163 let Inst{15-12} = 0b0000;
1164 let Inst{11-0} = imm;
1166 let Unpredictable{15-12} = 0b1111;
1168 def rr : AI1<opcod, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, iir,
1170 [(opnode GPR:$Rn, GPR:$Rm)]> {
1173 let isCommutable = Commutable;
1176 let Inst{19-16} = Rn;
1177 let Inst{15-12} = 0b0000;
1178 let Inst{11-4} = 0b00000000;
1181 let Unpredictable{15-12} = 0b1111;
1183 def rsi : AI1<opcod, (outs),
1184 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, iis,
1185 opc, "\t$Rn, $shift",
1186 [(opnode GPR:$Rn, so_reg_imm:$shift)]> {
1191 let Inst{19-16} = Rn;
1192 let Inst{15-12} = 0b0000;
1193 let Inst{11-5} = shift{11-5};
1195 let Inst{3-0} = shift{3-0};
1197 let Unpredictable{15-12} = 0b1111;
1199 def rsr : AI1<opcod, (outs),
1200 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, iis,
1201 opc, "\t$Rn, $shift",
1202 [(opnode GPRnopc:$Rn, so_reg_reg:$shift)]> {
1207 let Inst{19-16} = Rn;
1208 let Inst{15-12} = 0b0000;
1209 let Inst{11-8} = shift{11-8};
1211 let Inst{6-5} = shift{6-5};
1213 let Inst{3-0} = shift{3-0};
1215 let Unpredictable{15-12} = 0b1111;
1221 /// AI_ext_rrot - A unary operation with two forms: one whose operand is a
1222 /// register and one whose operand is a register rotated by 8/16/24.
1223 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
1224 class AI_ext_rrot<bits<8> opcod, string opc, PatFrag opnode>
1225 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1226 IIC_iEXTr, opc, "\t$Rd, $Rm$rot",
1227 [(set GPRnopc:$Rd, (opnode (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1228 Requires<[IsARM, HasV6]> {
1232 let Inst{19-16} = 0b1111;
1233 let Inst{15-12} = Rd;
1234 let Inst{11-10} = rot;
1238 class AI_ext_rrot_np<bits<8> opcod, string opc>
1239 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1240 IIC_iEXTr, opc, "\t$Rd, $Rm$rot", []>,
1241 Requires<[IsARM, HasV6]> {
1243 let Inst{19-16} = 0b1111;
1244 let Inst{11-10} = rot;
1247 /// AI_exta_rrot - A binary operation with two forms: one whose operand is a
1248 /// register and one whose operand is a register rotated by 8/16/24.
1249 class AI_exta_rrot<bits<8> opcod, string opc, PatFrag opnode>
1250 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1251 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot",
1252 [(set GPRnopc:$Rd, (opnode GPR:$Rn,
1253 (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1254 Requires<[IsARM, HasV6]> {
1259 let Inst{19-16} = Rn;
1260 let Inst{15-12} = Rd;
1261 let Inst{11-10} = rot;
1262 let Inst{9-4} = 0b000111;
1266 class AI_exta_rrot_np<bits<8> opcod, string opc>
1267 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1268 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot", []>,
1269 Requires<[IsARM, HasV6]> {
1272 let Inst{19-16} = Rn;
1273 let Inst{11-10} = rot;
1276 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
1277 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1278 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
1279 string baseOpc, bit Commutable = 0> {
1280 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1281 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
1282 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1283 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_imm:$imm, CPSR))]>,
1289 let Inst{15-12} = Rd;
1290 let Inst{19-16} = Rn;
1291 let Inst{11-0} = imm;
1293 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1294 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1295 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm, CPSR))]>,
1300 let Inst{11-4} = 0b00000000;
1302 let isCommutable = Commutable;
1304 let Inst{15-12} = Rd;
1305 let Inst{19-16} = Rn;
1307 def rsi : AsI1<opcod, (outs GPR:$Rd),
1308 (ins GPR:$Rn, so_reg_imm:$shift),
1309 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1310 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_imm:$shift, CPSR))]>,
1316 let Inst{19-16} = Rn;
1317 let Inst{15-12} = Rd;
1318 let Inst{11-5} = shift{11-5};
1320 let Inst{3-0} = shift{3-0};
1322 def rsr : AsI1<opcod, (outs GPRnopc:$Rd),
1323 (ins GPRnopc:$Rn, so_reg_reg:$shift),
1324 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1325 [(set GPRnopc:$Rd, CPSR,
1326 (opnode GPRnopc:$Rn, so_reg_reg:$shift, CPSR))]>,
1332 let Inst{19-16} = Rn;
1333 let Inst{15-12} = Rd;
1334 let Inst{11-8} = shift{11-8};
1336 let Inst{6-5} = shift{6-5};
1338 let Inst{3-0} = shift{3-0};
1343 /// AI1_rsc_irs - Define instructions and patterns for rsc
1344 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1345 multiclass AI1_rsc_irs<bits<4> opcod, string opc, PatFrag opnode,
1347 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1348 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
1349 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1350 [(set GPR:$Rd, CPSR, (opnode so_imm:$imm, GPR:$Rn, CPSR))]>,
1356 let Inst{15-12} = Rd;
1357 let Inst{19-16} = Rn;
1358 let Inst{11-0} = imm;
1360 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1361 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1362 [/* pattern left blank */]> {
1366 let Inst{11-4} = 0b00000000;
1369 let Inst{15-12} = Rd;
1370 let Inst{19-16} = Rn;
1372 def rsi : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_imm:$shift),
1373 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1374 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift, GPR:$Rn, CPSR))]>,
1380 let Inst{19-16} = Rn;
1381 let Inst{15-12} = Rd;
1382 let Inst{11-5} = shift{11-5};
1384 let Inst{3-0} = shift{3-0};
1386 def rsr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_reg:$shift),
1387 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1388 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift, GPR:$Rn, CPSR))]>,
1394 let Inst{19-16} = Rn;
1395 let Inst{15-12} = Rd;
1396 let Inst{11-8} = shift{11-8};
1398 let Inst{6-5} = shift{6-5};
1400 let Inst{3-0} = shift{3-0};
1405 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1406 multiclass AI_ldr1<bit isByte, string opc, InstrItinClass iii,
1407 InstrItinClass iir, PatFrag opnode> {
1408 // Note: We use the complex addrmode_imm12 rather than just an input
1409 // GPR and a constrained immediate so that we can use this to match
1410 // frame index references and avoid matching constant pool references.
1411 def i12: AI2ldst<0b010, 1, isByte, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
1412 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1413 [(set GPR:$Rt, (opnode addrmode_imm12:$addr))]> {
1416 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1417 let Inst{19-16} = addr{16-13}; // Rn
1418 let Inst{15-12} = Rt;
1419 let Inst{11-0} = addr{11-0}; // imm12
1421 def rs : AI2ldst<0b011, 1, isByte, (outs GPR:$Rt), (ins ldst_so_reg:$shift),
1422 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1423 [(set GPR:$Rt, (opnode ldst_so_reg:$shift))]> {
1426 let shift{4} = 0; // Inst{4} = 0
1427 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1428 let Inst{19-16} = shift{16-13}; // Rn
1429 let Inst{15-12} = Rt;
1430 let Inst{11-0} = shift{11-0};
1435 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1436 multiclass AI_ldr1nopc<bit isByte, string opc, InstrItinClass iii,
1437 InstrItinClass iir, PatFrag opnode> {
1438 // Note: We use the complex addrmode_imm12 rather than just an input
1439 // GPR and a constrained immediate so that we can use this to match
1440 // frame index references and avoid matching constant pool references.
1441 def i12: AI2ldst<0b010, 1, isByte, (outs GPRnopc:$Rt),
1442 (ins addrmode_imm12:$addr),
1443 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1444 [(set GPRnopc:$Rt, (opnode addrmode_imm12:$addr))]> {
1447 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1448 let Inst{19-16} = addr{16-13}; // Rn
1449 let Inst{15-12} = Rt;
1450 let Inst{11-0} = addr{11-0}; // imm12
1452 def rs : AI2ldst<0b011, 1, isByte, (outs GPRnopc:$Rt),
1453 (ins ldst_so_reg:$shift),
1454 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1455 [(set GPRnopc:$Rt, (opnode ldst_so_reg:$shift))]> {
1458 let shift{4} = 0; // Inst{4} = 0
1459 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1460 let Inst{19-16} = shift{16-13}; // Rn
1461 let Inst{15-12} = Rt;
1462 let Inst{11-0} = shift{11-0};
1468 multiclass AI_str1<bit isByte, string opc, InstrItinClass iii,
1469 InstrItinClass iir, PatFrag opnode> {
1470 // Note: We use the complex addrmode_imm12 rather than just an input
1471 // GPR and a constrained immediate so that we can use this to match
1472 // frame index references and avoid matching constant pool references.
1473 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1474 (ins GPR:$Rt, addrmode_imm12:$addr),
1475 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1476 [(opnode GPR:$Rt, addrmode_imm12:$addr)]> {
1479 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1480 let Inst{19-16} = addr{16-13}; // Rn
1481 let Inst{15-12} = Rt;
1482 let Inst{11-0} = addr{11-0}; // imm12
1484 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPR:$Rt, ldst_so_reg:$shift),
1485 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1486 [(opnode GPR:$Rt, ldst_so_reg:$shift)]> {
1489 let shift{4} = 0; // Inst{4} = 0
1490 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1491 let Inst{19-16} = shift{16-13}; // Rn
1492 let Inst{15-12} = Rt;
1493 let Inst{11-0} = shift{11-0};
1497 multiclass AI_str1nopc<bit isByte, string opc, InstrItinClass iii,
1498 InstrItinClass iir, PatFrag opnode> {
1499 // Note: We use the complex addrmode_imm12 rather than just an input
1500 // GPR and a constrained immediate so that we can use this to match
1501 // frame index references and avoid matching constant pool references.
1502 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1503 (ins GPRnopc:$Rt, addrmode_imm12:$addr),
1504 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1505 [(opnode GPRnopc:$Rt, addrmode_imm12:$addr)]> {
1508 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1509 let Inst{19-16} = addr{16-13}; // Rn
1510 let Inst{15-12} = Rt;
1511 let Inst{11-0} = addr{11-0}; // imm12
1513 def rs : AI2ldst<0b011, 0, isByte, (outs),
1514 (ins GPRnopc:$Rt, ldst_so_reg:$shift),
1515 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1516 [(opnode GPRnopc:$Rt, ldst_so_reg:$shift)]> {
1519 let shift{4} = 0; // Inst{4} = 0
1520 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1521 let Inst{19-16} = shift{16-13}; // Rn
1522 let Inst{15-12} = Rt;
1523 let Inst{11-0} = shift{11-0};
1528 //===----------------------------------------------------------------------===//
1530 //===----------------------------------------------------------------------===//
1532 //===----------------------------------------------------------------------===//
1533 // Miscellaneous Instructions.
1536 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
1537 /// the function. The first operand is the ID# for this instruction, the second
1538 /// is the index into the MachineConstantPool that this is, the third is the
1539 /// size in bytes of this constant pool entry.
1540 let neverHasSideEffects = 1, isNotDuplicable = 1 in
1541 def CONSTPOOL_ENTRY :
1542 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1543 i32imm:$size), NoItinerary, []>;
1545 // FIXME: Marking these as hasSideEffects is necessary to prevent machine DCE
1546 // from removing one half of the matched pairs. That breaks PEI, which assumes
1547 // these will always be in pairs, and asserts if it finds otherwise. Better way?
1548 let Defs = [SP], Uses = [SP], hasSideEffects = 1 in {
1549 def ADJCALLSTACKUP :
1550 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary,
1551 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
1553 def ADJCALLSTACKDOWN :
1554 PseudoInst<(outs), (ins i32imm:$amt, pred:$p), NoItinerary,
1555 [(ARMcallseq_start timm:$amt)]>;
1558 // Atomic pseudo-insts which will be lowered to ldrexd/strexd loops.
1559 // (These pseudos use a hand-written selection code).
1560 let usesCustomInserter = 1, Defs = [CPSR], mayLoad = 1, mayStore = 1 in {
1561 def ATOMOR6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1562 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1564 def ATOMXOR6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1565 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1567 def ATOMADD6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1568 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1570 def ATOMSUB6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1571 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1573 def ATOMNAND6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1574 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1576 def ATOMAND6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1577 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1579 def ATOMSWAP6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1580 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1582 def ATOMCMPXCHG6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1583 (ins GPR:$addr, GPR:$cmp1, GPR:$cmp2,
1584 GPR:$set1, GPR:$set2),
1588 def HINT : AI<(outs), (ins imm0_255:$imm), MiscFrm, NoItinerary,
1589 "hint", "\t$imm", []>, Requires<[IsARM, HasV6]> {
1591 let Inst{27-8} = 0b00110010000011110000;
1592 let Inst{7-0} = imm;
1595 def : InstAlias<"nop$p", (HINT 0, pred:$p)>, Requires<[IsARM, HasV6T2]>;
1596 def : InstAlias<"yield$p", (HINT 1, pred:$p)>, Requires<[IsARM, HasV6T2]>;
1597 def : InstAlias<"wfe$p", (HINT 2, pred:$p)>, Requires<[IsARM, HasV6T2]>;
1598 def : InstAlias<"wfi$p", (HINT 3, pred:$p)>, Requires<[IsARM, HasV6T2]>;
1599 def : InstAlias<"sev$p", (HINT 4, pred:$p)>, Requires<[IsARM, HasV6T2]>;
1601 def SEL : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, NoItinerary, "sel",
1602 "\t$Rd, $Rn, $Rm", []>, Requires<[IsARM, HasV6]> {
1607 let Inst{15-12} = Rd;
1608 let Inst{19-16} = Rn;
1609 let Inst{27-20} = 0b01101000;
1610 let Inst{7-4} = 0b1011;
1611 let Inst{11-8} = 0b1111;
1612 let Unpredictable{11-8} = 0b1111;
1615 // The 16-bit operand $val can be used by a debugger to store more information
1616 // about the breakpoint.
1617 def BKPT : AI<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
1618 "bkpt", "\t$val", []>, Requires<[IsARM]> {
1620 let Inst{3-0} = val{3-0};
1621 let Inst{19-8} = val{15-4};
1622 let Inst{27-20} = 0b00010010;
1623 let Inst{7-4} = 0b0111;
1626 // Change Processor State
1627 // FIXME: We should use InstAlias to handle the optional operands.
1628 class CPS<dag iops, string asm_ops>
1629 : AXI<(outs), iops, MiscFrm, NoItinerary, !strconcat("cps", asm_ops),
1630 []>, Requires<[IsARM]> {
1636 let Inst{31-28} = 0b1111;
1637 let Inst{27-20} = 0b00010000;
1638 let Inst{19-18} = imod;
1639 let Inst{17} = M; // Enabled if mode is set;
1640 let Inst{16-9} = 0b00000000;
1641 let Inst{8-6} = iflags;
1643 let Inst{4-0} = mode;
1646 let DecoderMethod = "DecodeCPSInstruction" in {
1648 def CPS3p : CPS<(ins imod_op:$imod, iflags_op:$iflags, imm0_31:$mode),
1649 "$imod\t$iflags, $mode">;
1650 let mode = 0, M = 0 in
1651 def CPS2p : CPS<(ins imod_op:$imod, iflags_op:$iflags), "$imod\t$iflags">;
1653 let imod = 0, iflags = 0, M = 1 in
1654 def CPS1p : CPS<(ins imm0_31:$mode), "\t$mode">;
1657 // Preload signals the memory system of possible future data/instruction access.
1658 multiclass APreLoad<bits<1> read, bits<1> data, string opc> {
1660 def i12 : AXI<(outs), (ins addrmode_imm12:$addr), MiscFrm, IIC_Preload,
1661 !strconcat(opc, "\t$addr"),
1662 [(ARMPreload addrmode_imm12:$addr, (i32 read), (i32 data))]> {
1665 let Inst{31-26} = 0b111101;
1666 let Inst{25} = 0; // 0 for immediate form
1667 let Inst{24} = data;
1668 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1669 let Inst{22} = read;
1670 let Inst{21-20} = 0b01;
1671 let Inst{19-16} = addr{16-13}; // Rn
1672 let Inst{15-12} = 0b1111;
1673 let Inst{11-0} = addr{11-0}; // imm12
1676 def rs : AXI<(outs), (ins ldst_so_reg:$shift), MiscFrm, IIC_Preload,
1677 !strconcat(opc, "\t$shift"),
1678 [(ARMPreload ldst_so_reg:$shift, (i32 read), (i32 data))]> {
1680 let Inst{31-26} = 0b111101;
1681 let Inst{25} = 1; // 1 for register form
1682 let Inst{24} = data;
1683 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1684 let Inst{22} = read;
1685 let Inst{21-20} = 0b01;
1686 let Inst{19-16} = shift{16-13}; // Rn
1687 let Inst{15-12} = 0b1111;
1688 let Inst{11-0} = shift{11-0};
1693 defm PLD : APreLoad<1, 1, "pld">, Requires<[IsARM]>;
1694 defm PLDW : APreLoad<0, 1, "pldw">, Requires<[IsARM,HasV7,HasMP]>;
1695 defm PLI : APreLoad<1, 0, "pli">, Requires<[IsARM,HasV7]>;
1697 def SETEND : AXI<(outs), (ins setend_op:$end), MiscFrm, NoItinerary,
1698 "setend\t$end", []>, Requires<[IsARM]> {
1700 let Inst{31-10} = 0b1111000100000001000000;
1705 def DBG : AI<(outs), (ins imm0_15:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt",
1706 []>, Requires<[IsARM, HasV7]> {
1708 let Inst{27-4} = 0b001100100000111100001111;
1709 let Inst{3-0} = opt;
1712 // A5.4 Permanently UNDEFINED instructions.
1713 let isBarrier = 1, isTerminator = 1 in
1714 def TRAP : AXI<(outs), (ins), MiscFrm, NoItinerary,
1717 let Inst = 0xe7ffdefe;
1720 // Address computation and loads and stores in PIC mode.
1721 let isNotDuplicable = 1 in {
1722 def PICADD : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
1724 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>;
1726 let AddedComplexity = 10 in {
1727 def PICLDR : ARMPseudoInst<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
1729 [(set GPR:$dst, (load addrmodepc:$addr))]>;
1731 def PICLDRH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1733 [(set GPR:$Rt, (zextloadi16 addrmodepc:$addr))]>;
1735 def PICLDRB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1737 [(set GPR:$Rt, (zextloadi8 addrmodepc:$addr))]>;
1739 def PICLDRSH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1741 [(set GPR:$Rt, (sextloadi16 addrmodepc:$addr))]>;
1743 def PICLDRSB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1745 [(set GPR:$Rt, (sextloadi8 addrmodepc:$addr))]>;
1747 let AddedComplexity = 10 in {
1748 def PICSTR : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1749 4, IIC_iStore_r, [(store GPR:$src, addrmodepc:$addr)]>;
1751 def PICSTRH : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1752 4, IIC_iStore_bh_r, [(truncstorei16 GPR:$src,
1753 addrmodepc:$addr)]>;
1755 def PICSTRB : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1756 4, IIC_iStore_bh_r, [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
1758 } // isNotDuplicable = 1
1761 // LEApcrel - Load a pc-relative address into a register without offending the
1763 let neverHasSideEffects = 1, isReMaterializable = 1 in
1764 // The 'adr' mnemonic encodes differently if the label is before or after
1765 // the instruction. The {24-21} opcode bits are set by the fixup, as we don't
1766 // know until then which form of the instruction will be used.
1767 def ADR : AI1<{0,?,?,0}, (outs GPR:$Rd), (ins adrlabel:$label),
1768 MiscFrm, IIC_iALUi, "adr", "\t$Rd, $label", []> {
1771 let Inst{27-25} = 0b001;
1773 let Inst{23-22} = label{13-12};
1776 let Inst{19-16} = 0b1111;
1777 let Inst{15-12} = Rd;
1778 let Inst{11-0} = label{11-0};
1780 def LEApcrel : ARMPseudoInst<(outs GPR:$Rd), (ins i32imm:$label, pred:$p),
1783 def LEApcrelJT : ARMPseudoInst<(outs GPR:$Rd),
1784 (ins i32imm:$label, nohash_imm:$id, pred:$p),
1787 //===----------------------------------------------------------------------===//
1788 // Control Flow Instructions.
1791 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
1793 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
1794 "bx", "\tlr", [(ARMretflag)]>,
1795 Requires<[IsARM, HasV4T]> {
1796 let Inst{27-0} = 0b0001001011111111111100011110;
1800 def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br,
1801 "mov", "\tpc, lr", [(ARMretflag)]>,
1802 Requires<[IsARM, NoV4T]> {
1803 let Inst{27-0} = 0b0001101000001111000000001110;
1807 // Indirect branches
1808 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
1810 def BX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
1811 [(brind GPR:$dst)]>,
1812 Requires<[IsARM, HasV4T]> {
1814 let Inst{31-4} = 0b1110000100101111111111110001;
1815 let Inst{3-0} = dst;
1818 def BX_pred : AI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br,
1819 "bx", "\t$dst", [/* pattern left blank */]>,
1820 Requires<[IsARM, HasV4T]> {
1822 let Inst{27-4} = 0b000100101111111111110001;
1823 let Inst{3-0} = dst;
1827 // SP is marked as a use to prevent stack-pointer assignments that appear
1828 // immediately before calls from potentially appearing dead.
1830 // FIXME: Do we really need a non-predicated version? If so, it should
1831 // at least be a pseudo instruction expanding to the predicated version
1832 // at MC lowering time.
1833 Defs = [LR], Uses = [SP] in {
1834 def BL : ABXI<0b1011, (outs), (ins bl_target:$func, variable_ops),
1835 IIC_Br, "bl\t$func",
1836 [(ARMcall tglobaladdr:$func)]>,
1838 let Inst{31-28} = 0b1110;
1840 let Inst{23-0} = func;
1841 let DecoderMethod = "DecodeBranchImmInstruction";
1844 def BL_pred : ABI<0b1011, (outs), (ins bl_target:$func, variable_ops),
1845 IIC_Br, "bl", "\t$func",
1846 [(ARMcall_pred tglobaladdr:$func)]>,
1849 let Inst{23-0} = func;
1850 let DecoderMethod = "DecodeBranchImmInstruction";
1854 def BLX : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
1855 IIC_Br, "blx\t$func",
1856 [(ARMcall GPR:$func)]>,
1857 Requires<[IsARM, HasV5T]> {
1859 let Inst{31-4} = 0b1110000100101111111111110011;
1860 let Inst{3-0} = func;
1863 def BLX_pred : AI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
1864 IIC_Br, "blx", "\t$func",
1865 [(ARMcall_pred GPR:$func)]>,
1866 Requires<[IsARM, HasV5T]> {
1868 let Inst{27-4} = 0b000100101111111111110011;
1869 let Inst{3-0} = func;
1873 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
1874 def BX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func, variable_ops),
1875 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
1876 Requires<[IsARM, HasV4T]>;
1879 def BMOVPCRX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func, variable_ops),
1880 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
1881 Requires<[IsARM, NoV4T]>;
1883 // mov lr, pc; b if callee is marked noreturn to avoid confusing the
1884 // return stack predictor.
1885 def BMOVPCB_CALL : ARMPseudoInst<(outs),
1886 (ins bl_target:$func, variable_ops),
1887 8, IIC_Br, [(ARMcall_nolink tglobaladdr:$func)]>,
1891 let isBranch = 1, isTerminator = 1 in {
1892 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
1893 // a two-value operand where a dag node expects two operands. :(
1894 def Bcc : ABI<0b1010, (outs), (ins br_target:$target),
1895 IIC_Br, "b", "\t$target",
1896 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]> {
1898 let Inst{23-0} = target;
1899 let DecoderMethod = "DecodeBranchImmInstruction";
1902 let isBarrier = 1 in {
1903 // B is "predicable" since it's just a Bcc with an 'always' condition.
1904 let isPredicable = 1 in
1905 // FIXME: We shouldn't need this pseudo at all. Just using Bcc directly
1906 // should be sufficient.
1907 // FIXME: Is B really a Barrier? That doesn't seem right.
1908 def B : ARMPseudoExpand<(outs), (ins br_target:$target), 4, IIC_Br,
1909 [(br bb:$target)], (Bcc br_target:$target, (ops 14, zero_reg))>;
1911 let isNotDuplicable = 1, isIndirectBranch = 1 in {
1912 def BR_JTr : ARMPseudoInst<(outs),
1913 (ins GPR:$target, i32imm:$jt, i32imm:$id),
1915 [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]>;
1916 // FIXME: This shouldn't use the generic "addrmode2," but rather be split
1917 // into i12 and rs suffixed versions.
1918 def BR_JTm : ARMPseudoInst<(outs),
1919 (ins addrmode2:$target, i32imm:$jt, i32imm:$id),
1921 [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
1923 def BR_JTadd : ARMPseudoInst<(outs),
1924 (ins GPR:$target, GPR:$idx, i32imm:$jt, i32imm:$id),
1926 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
1928 } // isNotDuplicable = 1, isIndirectBranch = 1
1934 def BLXi : AXI<(outs), (ins blx_target:$target), BrMiscFrm, NoItinerary,
1935 "blx\t$target", []>,
1936 Requires<[IsARM, HasV5T]> {
1937 let Inst{31-25} = 0b1111101;
1939 let Inst{23-0} = target{24-1};
1940 let Inst{24} = target{0};
1943 // Branch and Exchange Jazelle
1944 def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func",
1945 [/* pattern left blank */]> {
1947 let Inst{23-20} = 0b0010;
1948 let Inst{19-8} = 0xfff;
1949 let Inst{7-4} = 0b0010;
1950 let Inst{3-0} = func;
1955 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in {
1956 def TCRETURNdi : PseudoInst<(outs), (ins i32imm:$dst, variable_ops),
1959 def TCRETURNri : PseudoInst<(outs), (ins tcGPR:$dst, variable_ops),
1962 def TAILJMPd : ARMPseudoExpand<(outs), (ins br_target:$dst, variable_ops),
1964 (Bcc br_target:$dst, (ops 14, zero_reg))>,
1967 def TAILJMPr : ARMPseudoExpand<(outs), (ins tcGPR:$dst, variable_ops),
1973 // Secure Monitor Call is a system instruction.
1974 def SMC : ABI<0b0001, (outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt",
1977 let Inst{23-4} = 0b01100000000000000111;
1978 let Inst{3-0} = opt;
1981 // Supervisor Call (Software Interrupt)
1982 let isCall = 1, Uses = [SP] in {
1983 def SVC : ABI<0b1111, (outs), (ins imm24b:$svc), IIC_Br, "svc", "\t$svc", []> {
1985 let Inst{23-0} = svc;
1989 // Store Return State
1990 class SRSI<bit wb, string asm>
1991 : XI<(outs), (ins imm0_31:$mode), AddrModeNone, 4, IndexModeNone, BrFrm,
1992 NoItinerary, asm, "", []> {
1994 let Inst{31-28} = 0b1111;
1995 let Inst{27-25} = 0b100;
1999 let Inst{19-16} = 0b1101; // SP
2000 let Inst{15-5} = 0b00000101000;
2001 let Inst{4-0} = mode;
2004 def SRSDA : SRSI<0, "srsda\tsp, $mode"> {
2005 let Inst{24-23} = 0;
2007 def SRSDA_UPD : SRSI<1, "srsda\tsp!, $mode"> {
2008 let Inst{24-23} = 0;
2010 def SRSDB : SRSI<0, "srsdb\tsp, $mode"> {
2011 let Inst{24-23} = 0b10;
2013 def SRSDB_UPD : SRSI<1, "srsdb\tsp!, $mode"> {
2014 let Inst{24-23} = 0b10;
2016 def SRSIA : SRSI<0, "srsia\tsp, $mode"> {
2017 let Inst{24-23} = 0b01;
2019 def SRSIA_UPD : SRSI<1, "srsia\tsp!, $mode"> {
2020 let Inst{24-23} = 0b01;
2022 def SRSIB : SRSI<0, "srsib\tsp, $mode"> {
2023 let Inst{24-23} = 0b11;
2025 def SRSIB_UPD : SRSI<1, "srsib\tsp!, $mode"> {
2026 let Inst{24-23} = 0b11;
2029 // Return From Exception
2030 class RFEI<bit wb, string asm>
2031 : XI<(outs), (ins GPR:$Rn), AddrModeNone, 4, IndexModeNone, BrFrm,
2032 NoItinerary, asm, "", []> {
2034 let Inst{31-28} = 0b1111;
2035 let Inst{27-25} = 0b100;
2039 let Inst{19-16} = Rn;
2040 let Inst{15-0} = 0xa00;
2043 def RFEDA : RFEI<0, "rfeda\t$Rn"> {
2044 let Inst{24-23} = 0;
2046 def RFEDA_UPD : RFEI<1, "rfeda\t$Rn!"> {
2047 let Inst{24-23} = 0;
2049 def RFEDB : RFEI<0, "rfedb\t$Rn"> {
2050 let Inst{24-23} = 0b10;
2052 def RFEDB_UPD : RFEI<1, "rfedb\t$Rn!"> {
2053 let Inst{24-23} = 0b10;
2055 def RFEIA : RFEI<0, "rfeia\t$Rn"> {
2056 let Inst{24-23} = 0b01;
2058 def RFEIA_UPD : RFEI<1, "rfeia\t$Rn!"> {
2059 let Inst{24-23} = 0b01;
2061 def RFEIB : RFEI<0, "rfeib\t$Rn"> {
2062 let Inst{24-23} = 0b11;
2064 def RFEIB_UPD : RFEI<1, "rfeib\t$Rn!"> {
2065 let Inst{24-23} = 0b11;
2068 //===----------------------------------------------------------------------===//
2069 // Load / Store Instructions.
2075 defm LDR : AI_ldr1<0, "ldr", IIC_iLoad_r, IIC_iLoad_si,
2076 UnOpFrag<(load node:$Src)>>;
2077 defm LDRB : AI_ldr1nopc<1, "ldrb", IIC_iLoad_bh_r, IIC_iLoad_bh_si,
2078 UnOpFrag<(zextloadi8 node:$Src)>>;
2079 defm STR : AI_str1<0, "str", IIC_iStore_r, IIC_iStore_si,
2080 BinOpFrag<(store node:$LHS, node:$RHS)>>;
2081 defm STRB : AI_str1nopc<1, "strb", IIC_iStore_bh_r, IIC_iStore_bh_si,
2082 BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
2084 // Special LDR for loads from non-pc-relative constpools.
2085 let canFoldAsLoad = 1, mayLoad = 1, neverHasSideEffects = 1,
2086 isReMaterializable = 1, isCodeGenOnly = 1 in
2087 def LDRcp : AI2ldst<0b010, 1, 0, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
2088 AddrMode_i12, LdFrm, IIC_iLoad_r, "ldr", "\t$Rt, $addr",
2092 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2093 let Inst{19-16} = 0b1111;
2094 let Inst{15-12} = Rt;
2095 let Inst{11-0} = addr{11-0}; // imm12
2098 // Loads with zero extension
2099 def LDRH : AI3ld<0b1011, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2100 IIC_iLoad_bh_r, "ldrh", "\t$Rt, $addr",
2101 [(set GPR:$Rt, (zextloadi16 addrmode3:$addr))]>;
2103 // Loads with sign extension
2104 def LDRSH : AI3ld<0b1111, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2105 IIC_iLoad_bh_r, "ldrsh", "\t$Rt, $addr",
2106 [(set GPR:$Rt, (sextloadi16 addrmode3:$addr))]>;
2108 def LDRSB : AI3ld<0b1101, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2109 IIC_iLoad_bh_r, "ldrsb", "\t$Rt, $addr",
2110 [(set GPR:$Rt, (sextloadi8 addrmode3:$addr))]>;
2112 let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1 in {
2114 def LDRD : AI3ld<0b1101, 0, (outs GPR:$Rd, GPR:$dst2),
2115 (ins addrmode3:$addr), LdMiscFrm,
2116 IIC_iLoad_d_r, "ldrd", "\t$Rd, $dst2, $addr",
2117 []>, Requires<[IsARM, HasV5TE]>;
2121 multiclass AI2_ldridx<bit isByte, string opc,
2122 InstrItinClass iii, InstrItinClass iir> {
2123 def _PRE_IMM : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2124 (ins addrmode_imm12:$addr), IndexModePre, LdFrm, iii,
2125 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2128 let Inst{23} = addr{12};
2129 let Inst{19-16} = addr{16-13};
2130 let Inst{11-0} = addr{11-0};
2131 let DecoderMethod = "DecodeLDRPreImm";
2132 let AsmMatchConverter = "cvtLdWriteBackRegAddrModeImm12";
2135 def _PRE_REG : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2136 (ins ldst_so_reg:$addr), IndexModePre, LdFrm, iir,
2137 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2140 let Inst{23} = addr{12};
2141 let Inst{19-16} = addr{16-13};
2142 let Inst{11-0} = addr{11-0};
2144 let DecoderMethod = "DecodeLDRPreReg";
2145 let AsmMatchConverter = "cvtLdWriteBackRegAddrMode2";
2148 def _POST_REG : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2149 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2150 IndexModePost, LdFrm, iir,
2151 opc, "\t$Rt, $addr, $offset",
2152 "$addr.base = $Rn_wb", []> {
2158 let Inst{23} = offset{12};
2159 let Inst{19-16} = addr;
2160 let Inst{11-0} = offset{11-0};
2162 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2165 def _POST_IMM : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2166 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2167 IndexModePost, LdFrm, iii,
2168 opc, "\t$Rt, $addr, $offset",
2169 "$addr.base = $Rn_wb", []> {
2175 let Inst{23} = offset{12};
2176 let Inst{19-16} = addr;
2177 let Inst{11-0} = offset{11-0};
2179 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2184 let mayLoad = 1, neverHasSideEffects = 1 in {
2185 // FIXME: for LDR_PRE_REG etc. the itineray should be either IIC_iLoad_ru or
2186 // IIC_iLoad_siu depending on whether it the offset register is shifted.
2187 defm LDR : AI2_ldridx<0, "ldr", IIC_iLoad_iu, IIC_iLoad_ru>;
2188 defm LDRB : AI2_ldridx<1, "ldrb", IIC_iLoad_bh_iu, IIC_iLoad_bh_ru>;
2191 multiclass AI3_ldridx<bits<4> op, string opc, InstrItinClass itin> {
2192 def _PRE : AI3ldstidx<op, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2193 (ins addrmode3:$addr), IndexModePre,
2195 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2197 let Inst{23} = addr{8}; // U bit
2198 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2199 let Inst{19-16} = addr{12-9}; // Rn
2200 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2201 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2202 let AsmMatchConverter = "cvtLdWriteBackRegAddrMode3";
2203 let DecoderMethod = "DecodeAddrMode3Instruction";
2205 def _POST : AI3ldstidx<op, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2206 (ins addr_offset_none:$addr, am3offset:$offset),
2207 IndexModePost, LdMiscFrm, itin,
2208 opc, "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2212 let Inst{23} = offset{8}; // U bit
2213 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2214 let Inst{19-16} = addr;
2215 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2216 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2217 let DecoderMethod = "DecodeAddrMode3Instruction";
2221 let mayLoad = 1, neverHasSideEffects = 1 in {
2222 defm LDRH : AI3_ldridx<0b1011, "ldrh", IIC_iLoad_bh_ru>;
2223 defm LDRSH : AI3_ldridx<0b1111, "ldrsh", IIC_iLoad_bh_ru>;
2224 defm LDRSB : AI3_ldridx<0b1101, "ldrsb", IIC_iLoad_bh_ru>;
2225 let hasExtraDefRegAllocReq = 1 in {
2226 def LDRD_PRE : AI3ldstidx<0b1101, 0, 1, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2227 (ins addrmode3:$addr), IndexModePre,
2228 LdMiscFrm, IIC_iLoad_d_ru,
2229 "ldrd", "\t$Rt, $Rt2, $addr!",
2230 "$addr.base = $Rn_wb", []> {
2232 let Inst{23} = addr{8}; // U bit
2233 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2234 let Inst{19-16} = addr{12-9}; // Rn
2235 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2236 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2237 let DecoderMethod = "DecodeAddrMode3Instruction";
2238 let AsmMatchConverter = "cvtLdrdPre";
2240 def LDRD_POST: AI3ldstidx<0b1101, 0, 0, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2241 (ins addr_offset_none:$addr, am3offset:$offset),
2242 IndexModePost, LdMiscFrm, IIC_iLoad_d_ru,
2243 "ldrd", "\t$Rt, $Rt2, $addr, $offset",
2244 "$addr.base = $Rn_wb", []> {
2247 let Inst{23} = offset{8}; // U bit
2248 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2249 let Inst{19-16} = addr;
2250 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2251 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2252 let DecoderMethod = "DecodeAddrMode3Instruction";
2254 } // hasExtraDefRegAllocReq = 1
2255 } // mayLoad = 1, neverHasSideEffects = 1
2257 // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT.
2258 let mayLoad = 1, neverHasSideEffects = 1 in {
2259 def LDRT_POST_REG : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2260 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2261 IndexModePost, LdFrm, IIC_iLoad_ru,
2262 "ldrt", "\t$Rt, $addr, $offset",
2263 "$addr.base = $Rn_wb", []> {
2269 let Inst{23} = offset{12};
2270 let Inst{21} = 1; // overwrite
2271 let Inst{19-16} = addr;
2272 let Inst{11-5} = offset{11-5};
2274 let Inst{3-0} = offset{3-0};
2275 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2278 def LDRT_POST_IMM : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2279 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2280 IndexModePost, LdFrm, IIC_iLoad_ru,
2281 "ldrt", "\t$Rt, $addr, $offset",
2282 "$addr.base = $Rn_wb", []> {
2288 let Inst{23} = offset{12};
2289 let Inst{21} = 1; // overwrite
2290 let Inst{19-16} = addr;
2291 let Inst{11-0} = offset{11-0};
2292 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2295 def LDRBT_POST_REG : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2296 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2297 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2298 "ldrbt", "\t$Rt, $addr, $offset",
2299 "$addr.base = $Rn_wb", []> {
2305 let Inst{23} = offset{12};
2306 let Inst{21} = 1; // overwrite
2307 let Inst{19-16} = addr;
2308 let Inst{11-5} = offset{11-5};
2310 let Inst{3-0} = offset{3-0};
2311 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2314 def LDRBT_POST_IMM : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2315 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2316 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2317 "ldrbt", "\t$Rt, $addr, $offset",
2318 "$addr.base = $Rn_wb", []> {
2324 let Inst{23} = offset{12};
2325 let Inst{21} = 1; // overwrite
2326 let Inst{19-16} = addr;
2327 let Inst{11-0} = offset{11-0};
2328 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2331 multiclass AI3ldrT<bits<4> op, string opc> {
2332 def i : AI3ldstidxT<op, 1, (outs GPR:$Rt, GPR:$base_wb),
2333 (ins addr_offset_none:$addr, postidx_imm8:$offset),
2334 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2335 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2337 let Inst{23} = offset{8};
2339 let Inst{11-8} = offset{7-4};
2340 let Inst{3-0} = offset{3-0};
2341 let AsmMatchConverter = "cvtLdExtTWriteBackImm";
2343 def r : AI3ldstidxT<op, 1, (outs GPRnopc:$Rt, GPRnopc:$base_wb),
2344 (ins addr_offset_none:$addr, postidx_reg:$Rm),
2345 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2346 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2348 let Inst{23} = Rm{4};
2351 let Unpredictable{11-8} = 0b1111;
2352 let Inst{3-0} = Rm{3-0};
2353 let AsmMatchConverter = "cvtLdExtTWriteBackReg";
2354 let DecoderMethod = "DecodeLDR";
2358 defm LDRSBT : AI3ldrT<0b1101, "ldrsbt">;
2359 defm LDRHT : AI3ldrT<0b1011, "ldrht">;
2360 defm LDRSHT : AI3ldrT<0b1111, "ldrsht">;
2365 // Stores with truncate
2366 def STRH : AI3str<0b1011, (outs), (ins GPR:$Rt, addrmode3:$addr), StMiscFrm,
2367 IIC_iStore_bh_r, "strh", "\t$Rt, $addr",
2368 [(truncstorei16 GPR:$Rt, addrmode3:$addr)]>;
2371 let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in
2372 def STRD : AI3str<0b1111, (outs), (ins GPR:$Rt, GPR:$src2, addrmode3:$addr),
2373 StMiscFrm, IIC_iStore_d_r,
2374 "strd", "\t$Rt, $src2, $addr", []>,
2375 Requires<[IsARM, HasV5TE]> {
2380 multiclass AI2_stridx<bit isByte, string opc,
2381 InstrItinClass iii, InstrItinClass iir> {
2382 def _PRE_IMM : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2383 (ins GPR:$Rt, addrmode_imm12:$addr), IndexModePre,
2385 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2388 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2389 let Inst{19-16} = addr{16-13}; // Rn
2390 let Inst{11-0} = addr{11-0}; // imm12
2391 let AsmMatchConverter = "cvtStWriteBackRegAddrModeImm12";
2392 let DecoderMethod = "DecodeSTRPreImm";
2395 def _PRE_REG : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2396 (ins GPR:$Rt, ldst_so_reg:$addr),
2397 IndexModePre, StFrm, iir,
2398 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2401 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2402 let Inst{19-16} = addr{16-13}; // Rn
2403 let Inst{11-0} = addr{11-0};
2404 let Inst{4} = 0; // Inst{4} = 0
2405 let AsmMatchConverter = "cvtStWriteBackRegAddrMode2";
2406 let DecoderMethod = "DecodeSTRPreReg";
2408 def _POST_REG : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2409 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2410 IndexModePost, StFrm, iir,
2411 opc, "\t$Rt, $addr, $offset",
2412 "$addr.base = $Rn_wb", []> {
2418 let Inst{23} = offset{12};
2419 let Inst{19-16} = addr;
2420 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 canonical 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 instruction description.
3396 let isCommutable = 1, TwoOperandAliasConstraint = "$Rn = $Rd" in {
3397 def MUL : AsMul1I32<0b0000000, (outs GPRnopc:$Rd),
3398 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3399 IIC_iMUL32, "mul", "\t$Rd, $Rn, $Rm",
3400 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))]>,
3401 Requires<[IsARM, HasV6]> {
3402 let Inst{15-12} = 0b0000;
3403 let Unpredictable{15-12} = 0b1111;
3406 let Constraints = "@earlyclobber $Rd" in
3407 def MULv5: ARMPseudoExpand<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm,
3408 pred:$p, cc_out:$s),
3410 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))],
3411 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s)>,
3412 Requires<[IsARM, NoV6]>;
3415 def MLA : AsMul1I32<0b0000001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3416 IIC_iMAC32, "mla", "\t$Rd, $Rn, $Rm, $Ra",
3417 [(set GPR:$Rd, (add (mul GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
3418 Requires<[IsARM, HasV6]> {
3420 let Inst{15-12} = Ra;
3423 let Constraints = "@earlyclobber $Rd" in
3424 def MLAv5: ARMPseudoExpand<(outs GPR:$Rd),
3425 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra, pred:$p, cc_out:$s),
3427 [(set GPR:$Rd, (add (mul GPR:$Rn, GPR:$Rm), GPR:$Ra))],
3428 (MLA GPR:$Rd, GPR:$Rn, GPR:$Rm, GPR:$Ra, pred:$p, cc_out:$s)>,
3429 Requires<[IsARM, NoV6]>;
3431 def MLS : AMul1I<0b0000011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3432 IIC_iMAC32, "mls", "\t$Rd, $Rn, $Rm, $Ra",
3433 [(set GPR:$Rd, (sub GPR:$Ra, (mul GPR:$Rn, GPR:$Rm)))]>,
3434 Requires<[IsARM, HasV6T2]> {
3439 let Inst{19-16} = Rd;
3440 let Inst{15-12} = Ra;
3441 let Inst{11-8} = Rm;
3445 // Extra precision multiplies with low / high results
3446 let neverHasSideEffects = 1 in {
3447 let isCommutable = 1 in {
3448 def SMULL : AsMul1I64<0b0000110, (outs GPR:$RdLo, GPR:$RdHi),
3449 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3450 "smull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3451 Requires<[IsARM, HasV6]>;
3453 def UMULL : AsMul1I64<0b0000100, (outs GPR:$RdLo, GPR:$RdHi),
3454 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3455 "umull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3456 Requires<[IsARM, HasV6]>;
3458 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
3459 def SMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3460 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3462 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3463 Requires<[IsARM, NoV6]>;
3465 def UMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3466 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3468 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3469 Requires<[IsARM, NoV6]>;
3473 // Multiply + accumulate
3474 def SMLAL : AsMul1I64<0b0000111, (outs GPR:$RdLo, GPR:$RdHi),
3475 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3476 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3477 Requires<[IsARM, HasV6]>;
3478 def UMLAL : AsMul1I64<0b0000101, (outs GPR:$RdLo, GPR:$RdHi),
3479 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3480 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3481 Requires<[IsARM, HasV6]>;
3483 def UMAAL : AMul1I <0b0000010, (outs GPR:$RdLo, GPR:$RdHi),
3484 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3485 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3486 Requires<[IsARM, HasV6]> {
3491 let Inst{19-16} = RdHi;
3492 let Inst{15-12} = RdLo;
3493 let Inst{11-8} = Rm;
3497 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
3498 def SMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3499 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3501 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3502 Requires<[IsARM, NoV6]>;
3503 def UMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3504 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3506 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3507 Requires<[IsARM, NoV6]>;
3508 def UMAALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3509 (ins GPR:$Rn, GPR:$Rm, pred:$p),
3511 (UMAAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p)>,
3512 Requires<[IsARM, NoV6]>;
3515 } // neverHasSideEffects
3517 // Most significant word multiply
3518 def SMMUL : AMul2I <0b0111010, 0b0001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3519 IIC_iMUL32, "smmul", "\t$Rd, $Rn, $Rm",
3520 [(set GPR:$Rd, (mulhs GPR:$Rn, GPR:$Rm))]>,
3521 Requires<[IsARM, HasV6]> {
3522 let Inst{15-12} = 0b1111;
3525 def SMMULR : AMul2I <0b0111010, 0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3526 IIC_iMUL32, "smmulr", "\t$Rd, $Rn, $Rm", []>,
3527 Requires<[IsARM, HasV6]> {
3528 let Inst{15-12} = 0b1111;
3531 def SMMLA : AMul2Ia <0b0111010, 0b0001, (outs GPR:$Rd),
3532 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3533 IIC_iMAC32, "smmla", "\t$Rd, $Rn, $Rm, $Ra",
3534 [(set GPR:$Rd, (add (mulhs GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
3535 Requires<[IsARM, HasV6]>;
3537 def SMMLAR : AMul2Ia <0b0111010, 0b0011, (outs GPR:$Rd),
3538 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3539 IIC_iMAC32, "smmlar", "\t$Rd, $Rn, $Rm, $Ra", []>,
3540 Requires<[IsARM, HasV6]>;
3542 def SMMLS : AMul2Ia <0b0111010, 0b1101, (outs GPR:$Rd),
3543 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3544 IIC_iMAC32, "smmls", "\t$Rd, $Rn, $Rm, $Ra", []>,
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 // CMN register-integer
3826 let isCompare = 1, Defs = [CPSR] in {
3827 def CMNri : AI1<0b1011, (outs), (ins GPR:$Rn, so_imm:$imm), DPFrm, IIC_iCMPi,
3828 "cmn", "\t$Rn, $imm",
3829 [(ARMcmn GPR:$Rn, so_imm:$imm)]> {
3834 let Inst{19-16} = Rn;
3835 let Inst{15-12} = 0b0000;
3836 let Inst{11-0} = imm;
3838 let Unpredictable{15-12} = 0b1111;
3841 // CMN register-register/shift
3842 def CMNzrr : AI1<0b1011, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, IIC_iCMPr,
3843 "cmn", "\t$Rn, $Rm",
3844 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
3845 GPR:$Rn, GPR:$Rm)]> {
3848 let isCommutable = 1;
3851 let Inst{19-16} = Rn;
3852 let Inst{15-12} = 0b0000;
3853 let Inst{11-4} = 0b00000000;
3856 let Unpredictable{15-12} = 0b1111;
3859 def CMNzrsi : AI1<0b1011, (outs),
3860 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, IIC_iCMPsr,
3861 "cmn", "\t$Rn, $shift",
3862 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
3863 GPR:$Rn, so_reg_imm:$shift)]> {
3868 let Inst{19-16} = Rn;
3869 let Inst{15-12} = 0b0000;
3870 let Inst{11-5} = shift{11-5};
3872 let Inst{3-0} = shift{3-0};
3874 let Unpredictable{15-12} = 0b1111;
3877 def CMNzrsr : AI1<0b1011, (outs),
3878 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, IIC_iCMPsr,
3879 "cmn", "\t$Rn, $shift",
3880 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
3881 GPRnopc:$Rn, so_reg_reg:$shift)]> {
3886 let Inst{19-16} = Rn;
3887 let Inst{15-12} = 0b0000;
3888 let Inst{11-8} = shift{11-8};
3890 let Inst{6-5} = shift{6-5};
3892 let Inst{3-0} = shift{3-0};
3894 let Unpredictable{15-12} = 0b1111;
3899 def : ARMPat<(ARMcmp GPR:$src, so_imm_neg:$imm),
3900 (CMNri GPR:$src, so_imm_neg:$imm)>;
3902 def : ARMPat<(ARMcmpZ GPR:$src, so_imm_neg:$imm),
3903 (CMNri GPR:$src, so_imm_neg:$imm)>;
3905 // Note that TST/TEQ don't set all the same flags that CMP does!
3906 defm TST : AI1_cmp_irs<0b1000, "tst",
3907 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
3908 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>, 1>;
3909 defm TEQ : AI1_cmp_irs<0b1001, "teq",
3910 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
3911 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>, 1>;
3913 // Pseudo i64 compares for some floating point compares.
3914 let usesCustomInserter = 1, isBranch = 1, isTerminator = 1,
3916 def BCCi64 : PseudoInst<(outs),
3917 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, brtarget:$dst),
3919 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, bb:$dst)]>;
3921 def BCCZi64 : PseudoInst<(outs),
3922 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, brtarget:$dst), IIC_Br,
3923 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, 0, 0, bb:$dst)]>;
3924 } // usesCustomInserter
3927 // Conditional moves
3928 // FIXME: should be able to write a pattern for ARMcmov, but can't use
3929 // a two-value operand where a dag node expects two operands. :(
3930 let neverHasSideEffects = 1 in {
3932 let isCommutable = 1 in
3933 def MOVCCr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$false, GPR:$Rm, pred:$p),
3935 [/*(set GPR:$Rd, (ARMcmov GPR:$false, GPR:$Rm, imm:$cc, CCR:$ccr))*/]>,
3936 RegConstraint<"$false = $Rd">;
3938 def MOVCCsi : ARMPseudoInst<(outs GPR:$Rd),
3939 (ins GPR:$false, so_reg_imm:$shift, pred:$p),
3941 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_imm:$shift,
3942 imm:$cc, CCR:$ccr))*/]>,
3943 RegConstraint<"$false = $Rd">;
3944 def MOVCCsr : ARMPseudoInst<(outs GPR:$Rd),
3945 (ins GPR:$false, so_reg_reg:$shift, pred:$p),
3947 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_reg:$shift,
3948 imm:$cc, CCR:$ccr))*/]>,
3949 RegConstraint<"$false = $Rd">;
3952 let isMoveImm = 1 in
3953 def MOVCCi16 : ARMPseudoInst<(outs GPR:$Rd),
3954 (ins GPR:$false, imm0_65535_expr:$imm, pred:$p),
3957 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>;
3959 let isMoveImm = 1 in
3960 def MOVCCi : ARMPseudoInst<(outs GPR:$Rd),
3961 (ins GPR:$false, so_imm:$imm, pred:$p),
3963 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_imm:$imm, imm:$cc, CCR:$ccr))*/]>,
3964 RegConstraint<"$false = $Rd">;
3966 // Two instruction predicate mov immediate.
3967 let isMoveImm = 1 in
3968 def MOVCCi32imm : ARMPseudoInst<(outs GPR:$Rd),
3969 (ins GPR:$false, i32imm:$src, pred:$p),
3970 8, IIC_iCMOVix2, []>, RegConstraint<"$false = $Rd">;
3972 let isMoveImm = 1 in
3973 def MVNCCi : ARMPseudoInst<(outs GPR:$Rd),
3974 (ins GPR:$false, so_imm:$imm, pred:$p),
3976 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_imm_not:$imm, imm:$cc, CCR:$ccr))*/]>,
3977 RegConstraint<"$false = $Rd">;
3979 // Conditional instructions
3980 multiclass AsI1_bincc_irs<Instruction iri, Instruction irr, Instruction irsi,
3982 InstrItinClass iii, InstrItinClass iir,
3983 InstrItinClass iis> {
3984 def ri : ARMPseudoExpand<(outs GPR:$Rd),
3985 (ins GPR:$Rn, so_imm:$imm, pred:$p, cc_out:$s),
3987 (iri GPR:$Rd, GPR:$Rn, so_imm:$imm, pred:$p, cc_out:$s)>,
3988 RegConstraint<"$Rn = $Rd">;
3989 def rr : ARMPseudoExpand<(outs GPR:$Rd),
3990 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3992 (irr GPR:$Rd, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3993 RegConstraint<"$Rn = $Rd">;
3994 def rsi : ARMPseudoExpand<(outs GPR:$Rd),
3995 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p, cc_out:$s),
3997 (irsi GPR:$Rd, GPR:$Rn, so_reg_imm:$shift, pred:$p, cc_out:$s)>,
3998 RegConstraint<"$Rn = $Rd">;
3999 def rsr : ARMPseudoExpand<(outs GPRnopc:$Rd),
4000 (ins GPRnopc:$Rn, so_reg_reg:$shift, pred:$p, cc_out:$s),
4002 (irsr GPR:$Rd, GPR:$Rn, so_reg_reg:$shift, pred:$p, cc_out:$s)>,
4003 RegConstraint<"$Rn = $Rd">;
4006 defm ANDCC : AsI1_bincc_irs<ANDri, ANDrr, ANDrsi, ANDrsr,
4007 IIC_iBITi, IIC_iBITr, IIC_iBITsr>;
4008 defm ORRCC : AsI1_bincc_irs<ORRri, ORRrr, ORRrsi, ORRrsr,
4009 IIC_iBITi, IIC_iBITr, IIC_iBITsr>;
4010 defm EORCC : AsI1_bincc_irs<EORri, EORrr, EORrsi, EORrsr,
4011 IIC_iBITi, IIC_iBITr, IIC_iBITsr>;
4013 } // neverHasSideEffects
4016 //===----------------------------------------------------------------------===//
4017 // Atomic operations intrinsics
4020 def MemBarrierOptOperand : AsmOperandClass {
4021 let Name = "MemBarrierOpt";
4022 let ParserMethod = "parseMemBarrierOptOperand";
4024 def memb_opt : Operand<i32> {
4025 let PrintMethod = "printMemBOption";
4026 let ParserMatchClass = MemBarrierOptOperand;
4027 let DecoderMethod = "DecodeMemBarrierOption";
4030 // memory barriers protect the atomic sequences
4031 let hasSideEffects = 1 in {
4032 def DMB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4033 "dmb", "\t$opt", [(ARMMemBarrier (i32 imm:$opt))]>,
4034 Requires<[IsARM, HasDB]> {
4036 let Inst{31-4} = 0xf57ff05;
4037 let Inst{3-0} = opt;
4041 def DSB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4042 "dsb", "\t$opt", []>,
4043 Requires<[IsARM, HasDB]> {
4045 let Inst{31-4} = 0xf57ff04;
4046 let Inst{3-0} = opt;
4049 // ISB has only full system option
4050 def ISB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4051 "isb", "\t$opt", []>,
4052 Requires<[IsARM, HasDB]> {
4054 let Inst{31-4} = 0xf57ff06;
4055 let Inst{3-0} = opt;
4058 // Pseudo instruction that combines movs + predicated rsbmi
4059 // to implement integer ABS
4060 let usesCustomInserter = 1, Defs = [CPSR] in {
4061 def ABS : ARMPseudoInst<
4062 (outs GPR:$dst), (ins GPR:$src),
4063 8, NoItinerary, []>;
4066 let usesCustomInserter = 1 in {
4067 let Defs = [CPSR] in {
4068 def ATOMIC_LOAD_ADD_I8 : PseudoInst<
4069 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4070 [(set GPR:$dst, (atomic_load_add_8 GPR:$ptr, GPR:$incr))]>;
4071 def ATOMIC_LOAD_SUB_I8 : PseudoInst<
4072 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4073 [(set GPR:$dst, (atomic_load_sub_8 GPR:$ptr, GPR:$incr))]>;
4074 def ATOMIC_LOAD_AND_I8 : PseudoInst<
4075 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4076 [(set GPR:$dst, (atomic_load_and_8 GPR:$ptr, GPR:$incr))]>;
4077 def ATOMIC_LOAD_OR_I8 : PseudoInst<
4078 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4079 [(set GPR:$dst, (atomic_load_or_8 GPR:$ptr, GPR:$incr))]>;
4080 def ATOMIC_LOAD_XOR_I8 : PseudoInst<
4081 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4082 [(set GPR:$dst, (atomic_load_xor_8 GPR:$ptr, GPR:$incr))]>;
4083 def ATOMIC_LOAD_NAND_I8 : PseudoInst<
4084 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4085 [(set GPR:$dst, (atomic_load_nand_8 GPR:$ptr, GPR:$incr))]>;
4086 def ATOMIC_LOAD_MIN_I8 : PseudoInst<
4087 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4088 [(set GPR:$dst, (atomic_load_min_8 GPR:$ptr, GPR:$val))]>;
4089 def ATOMIC_LOAD_MAX_I8 : PseudoInst<
4090 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4091 [(set GPR:$dst, (atomic_load_max_8 GPR:$ptr, GPR:$val))]>;
4092 def ATOMIC_LOAD_UMIN_I8 : PseudoInst<
4093 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4094 [(set GPR:$dst, (atomic_load_umin_8 GPR:$ptr, GPR:$val))]>;
4095 def ATOMIC_LOAD_UMAX_I8 : PseudoInst<
4096 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4097 [(set GPR:$dst, (atomic_load_umax_8 GPR:$ptr, GPR:$val))]>;
4098 def ATOMIC_LOAD_ADD_I16 : PseudoInst<
4099 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4100 [(set GPR:$dst, (atomic_load_add_16 GPR:$ptr, GPR:$incr))]>;
4101 def ATOMIC_LOAD_SUB_I16 : PseudoInst<
4102 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4103 [(set GPR:$dst, (atomic_load_sub_16 GPR:$ptr, GPR:$incr))]>;
4104 def ATOMIC_LOAD_AND_I16 : PseudoInst<
4105 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4106 [(set GPR:$dst, (atomic_load_and_16 GPR:$ptr, GPR:$incr))]>;
4107 def ATOMIC_LOAD_OR_I16 : PseudoInst<
4108 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4109 [(set GPR:$dst, (atomic_load_or_16 GPR:$ptr, GPR:$incr))]>;
4110 def ATOMIC_LOAD_XOR_I16 : PseudoInst<
4111 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4112 [(set GPR:$dst, (atomic_load_xor_16 GPR:$ptr, GPR:$incr))]>;
4113 def ATOMIC_LOAD_NAND_I16 : PseudoInst<
4114 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4115 [(set GPR:$dst, (atomic_load_nand_16 GPR:$ptr, GPR:$incr))]>;
4116 def ATOMIC_LOAD_MIN_I16 : PseudoInst<
4117 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4118 [(set GPR:$dst, (atomic_load_min_16 GPR:$ptr, GPR:$val))]>;
4119 def ATOMIC_LOAD_MAX_I16 : PseudoInst<
4120 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4121 [(set GPR:$dst, (atomic_load_max_16 GPR:$ptr, GPR:$val))]>;
4122 def ATOMIC_LOAD_UMIN_I16 : PseudoInst<
4123 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4124 [(set GPR:$dst, (atomic_load_umin_16 GPR:$ptr, GPR:$val))]>;
4125 def ATOMIC_LOAD_UMAX_I16 : PseudoInst<
4126 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4127 [(set GPR:$dst, (atomic_load_umax_16 GPR:$ptr, GPR:$val))]>;
4128 def ATOMIC_LOAD_ADD_I32 : PseudoInst<
4129 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4130 [(set GPR:$dst, (atomic_load_add_32 GPR:$ptr, GPR:$incr))]>;
4131 def ATOMIC_LOAD_SUB_I32 : PseudoInst<
4132 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4133 [(set GPR:$dst, (atomic_load_sub_32 GPR:$ptr, GPR:$incr))]>;
4134 def ATOMIC_LOAD_AND_I32 : PseudoInst<
4135 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4136 [(set GPR:$dst, (atomic_load_and_32 GPR:$ptr, GPR:$incr))]>;
4137 def ATOMIC_LOAD_OR_I32 : PseudoInst<
4138 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4139 [(set GPR:$dst, (atomic_load_or_32 GPR:$ptr, GPR:$incr))]>;
4140 def ATOMIC_LOAD_XOR_I32 : PseudoInst<
4141 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4142 [(set GPR:$dst, (atomic_load_xor_32 GPR:$ptr, GPR:$incr))]>;
4143 def ATOMIC_LOAD_NAND_I32 : PseudoInst<
4144 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4145 [(set GPR:$dst, (atomic_load_nand_32 GPR:$ptr, GPR:$incr))]>;
4146 def ATOMIC_LOAD_MIN_I32 : PseudoInst<
4147 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4148 [(set GPR:$dst, (atomic_load_min_32 GPR:$ptr, GPR:$val))]>;
4149 def ATOMIC_LOAD_MAX_I32 : PseudoInst<
4150 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4151 [(set GPR:$dst, (atomic_load_max_32 GPR:$ptr, GPR:$val))]>;
4152 def ATOMIC_LOAD_UMIN_I32 : PseudoInst<
4153 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4154 [(set GPR:$dst, (atomic_load_umin_32 GPR:$ptr, GPR:$val))]>;
4155 def ATOMIC_LOAD_UMAX_I32 : PseudoInst<
4156 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4157 [(set GPR:$dst, (atomic_load_umax_32 GPR:$ptr, GPR:$val))]>;
4159 def ATOMIC_SWAP_I8 : PseudoInst<
4160 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
4161 [(set GPR:$dst, (atomic_swap_8 GPR:$ptr, GPR:$new))]>;
4162 def ATOMIC_SWAP_I16 : PseudoInst<
4163 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
4164 [(set GPR:$dst, (atomic_swap_16 GPR:$ptr, GPR:$new))]>;
4165 def ATOMIC_SWAP_I32 : PseudoInst<
4166 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
4167 [(set GPR:$dst, (atomic_swap_32 GPR:$ptr, GPR:$new))]>;
4169 def ATOMIC_CMP_SWAP_I8 : PseudoInst<
4170 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
4171 [(set GPR:$dst, (atomic_cmp_swap_8 GPR:$ptr, GPR:$old, GPR:$new))]>;
4172 def ATOMIC_CMP_SWAP_I16 : PseudoInst<
4173 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
4174 [(set GPR:$dst, (atomic_cmp_swap_16 GPR:$ptr, GPR:$old, GPR:$new))]>;
4175 def ATOMIC_CMP_SWAP_I32 : PseudoInst<
4176 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
4177 [(set GPR:$dst, (atomic_cmp_swap_32 GPR:$ptr, GPR:$old, GPR:$new))]>;
4181 let usesCustomInserter = 1 in {
4182 def COPY_STRUCT_BYVAL_I32 : PseudoInst<
4183 (outs), (ins GPR:$dst, GPR:$src, i32imm:$size, i32imm:$alignment),
4185 [(ARMcopystructbyval GPR:$dst, GPR:$src, imm:$size, imm:$alignment)]>;
4188 let mayLoad = 1 in {
4189 def LDREXB : AIldrex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4191 "ldrexb", "\t$Rt, $addr", []>;
4192 def LDREXH : AIldrex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4193 NoItinerary, "ldrexh", "\t$Rt, $addr", []>;
4194 def LDREX : AIldrex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4195 NoItinerary, "ldrex", "\t$Rt, $addr", []>;
4196 let hasExtraDefRegAllocReq = 1 in
4197 def LDREXD: AIldrex<0b01, (outs GPR:$Rt, GPR:$Rt2),(ins addr_offset_none:$addr),
4198 NoItinerary, "ldrexd", "\t$Rt, $Rt2, $addr", []> {
4199 let DecoderMethod = "DecodeDoubleRegLoad";
4203 let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
4204 def STREXB: AIstrex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4205 NoItinerary, "strexb", "\t$Rd, $Rt, $addr", []>;
4206 def STREXH: AIstrex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4207 NoItinerary, "strexh", "\t$Rd, $Rt, $addr", []>;
4208 def STREX : AIstrex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4209 NoItinerary, "strex", "\t$Rd, $Rt, $addr", []>;
4210 let hasExtraSrcRegAllocReq = 1 in
4211 def STREXD : AIstrex<0b01, (outs GPR:$Rd),
4212 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr),
4213 NoItinerary, "strexd", "\t$Rd, $Rt, $Rt2, $addr", []> {
4214 let DecoderMethod = "DecodeDoubleRegStore";
4219 def CLREX : AXI<(outs), (ins), MiscFrm, NoItinerary, "clrex", []>,
4220 Requires<[IsARM, HasV7]> {
4221 let Inst{31-0} = 0b11110101011111111111000000011111;
4224 // SWP/SWPB are deprecated in V6/V7.
4225 let mayLoad = 1, mayStore = 1 in {
4226 def SWP : AIswp<0, (outs GPRnopc:$Rt),
4227 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swp", []>;
4228 def SWPB: AIswp<1, (outs GPRnopc:$Rt),
4229 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swpb", []>;
4232 //===----------------------------------------------------------------------===//
4233 // Coprocessor Instructions.
4236 def CDP : ABI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4237 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4238 NoItinerary, "cdp", "\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4239 [(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4240 imm:$CRm, imm:$opc2)]> {
4248 let Inst{3-0} = CRm;
4250 let Inst{7-5} = opc2;
4251 let Inst{11-8} = cop;
4252 let Inst{15-12} = CRd;
4253 let Inst{19-16} = CRn;
4254 let Inst{23-20} = opc1;
4257 def CDP2 : ABXI<0b1110, (outs), (ins pf_imm:$cop, imm0_15:$opc1,
4258 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4259 NoItinerary, "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4260 [(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4261 imm:$CRm, imm:$opc2)]> {
4262 let Inst{31-28} = 0b1111;
4270 let Inst{3-0} = CRm;
4272 let Inst{7-5} = opc2;
4273 let Inst{11-8} = cop;
4274 let Inst{15-12} = CRd;
4275 let Inst{19-16} = CRn;
4276 let Inst{23-20} = opc1;
4279 class ACI<dag oops, dag iops, string opc, string asm,
4280 IndexMode im = IndexModeNone>
4281 : I<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
4283 let Inst{27-25} = 0b110;
4285 class ACInoP<dag oops, dag iops, string opc, string asm,
4286 IndexMode im = IndexModeNone>
4287 : InoP<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
4289 let Inst{31-28} = 0b1111;
4290 let Inst{27-25} = 0b110;
4292 multiclass LdStCop<bit load, bit Dbit, string asm> {
4293 def _OFFSET : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4294 asm, "\t$cop, $CRd, $addr"> {
4298 let Inst{24} = 1; // P = 1
4299 let Inst{23} = addr{8};
4300 let Inst{22} = Dbit;
4301 let Inst{21} = 0; // W = 0
4302 let Inst{20} = load;
4303 let Inst{19-16} = addr{12-9};
4304 let Inst{15-12} = CRd;
4305 let Inst{11-8} = cop;
4306 let Inst{7-0} = addr{7-0};
4307 let DecoderMethod = "DecodeCopMemInstruction";
4309 def _PRE : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4310 asm, "\t$cop, $CRd, $addr!", IndexModePre> {
4314 let Inst{24} = 1; // P = 1
4315 let Inst{23} = addr{8};
4316 let Inst{22} = Dbit;
4317 let Inst{21} = 1; // W = 1
4318 let Inst{20} = load;
4319 let Inst{19-16} = addr{12-9};
4320 let Inst{15-12} = CRd;
4321 let Inst{11-8} = cop;
4322 let Inst{7-0} = addr{7-0};
4323 let DecoderMethod = "DecodeCopMemInstruction";
4325 def _POST: ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4326 postidx_imm8s4:$offset),
4327 asm, "\t$cop, $CRd, $addr, $offset", IndexModePost> {
4332 let Inst{24} = 0; // P = 0
4333 let Inst{23} = offset{8};
4334 let Inst{22} = Dbit;
4335 let Inst{21} = 1; // W = 1
4336 let Inst{20} = load;
4337 let Inst{19-16} = addr;
4338 let Inst{15-12} = CRd;
4339 let Inst{11-8} = cop;
4340 let Inst{7-0} = offset{7-0};
4341 let DecoderMethod = "DecodeCopMemInstruction";
4343 def _OPTION : ACI<(outs),
4344 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4345 coproc_option_imm:$option),
4346 asm, "\t$cop, $CRd, $addr, $option"> {
4351 let Inst{24} = 0; // P = 0
4352 let Inst{23} = 1; // U = 1
4353 let Inst{22} = Dbit;
4354 let Inst{21} = 0; // W = 0
4355 let Inst{20} = load;
4356 let Inst{19-16} = addr;
4357 let Inst{15-12} = CRd;
4358 let Inst{11-8} = cop;
4359 let Inst{7-0} = option;
4360 let DecoderMethod = "DecodeCopMemInstruction";
4363 multiclass LdSt2Cop<bit load, bit Dbit, string asm> {
4364 def _OFFSET : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4365 asm, "\t$cop, $CRd, $addr"> {
4369 let Inst{24} = 1; // P = 1
4370 let Inst{23} = addr{8};
4371 let Inst{22} = Dbit;
4372 let Inst{21} = 0; // W = 0
4373 let Inst{20} = load;
4374 let Inst{19-16} = addr{12-9};
4375 let Inst{15-12} = CRd;
4376 let Inst{11-8} = cop;
4377 let Inst{7-0} = addr{7-0};
4378 let DecoderMethod = "DecodeCopMemInstruction";
4380 def _PRE : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
4381 asm, "\t$cop, $CRd, $addr!", IndexModePre> {
4385 let Inst{24} = 1; // P = 1
4386 let Inst{23} = addr{8};
4387 let Inst{22} = Dbit;
4388 let Inst{21} = 1; // W = 1
4389 let Inst{20} = load;
4390 let Inst{19-16} = addr{12-9};
4391 let Inst{15-12} = CRd;
4392 let Inst{11-8} = cop;
4393 let Inst{7-0} = addr{7-0};
4394 let DecoderMethod = "DecodeCopMemInstruction";
4396 def _POST: ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4397 postidx_imm8s4:$offset),
4398 asm, "\t$cop, $CRd, $addr, $offset", IndexModePost> {
4403 let Inst{24} = 0; // P = 0
4404 let Inst{23} = offset{8};
4405 let Inst{22} = Dbit;
4406 let Inst{21} = 1; // W = 1
4407 let Inst{20} = load;
4408 let Inst{19-16} = addr;
4409 let Inst{15-12} = CRd;
4410 let Inst{11-8} = cop;
4411 let Inst{7-0} = offset{7-0};
4412 let DecoderMethod = "DecodeCopMemInstruction";
4414 def _OPTION : ACInoP<(outs),
4415 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4416 coproc_option_imm:$option),
4417 asm, "\t$cop, $CRd, $addr, $option"> {
4422 let Inst{24} = 0; // P = 0
4423 let Inst{23} = 1; // U = 1
4424 let Inst{22} = Dbit;
4425 let Inst{21} = 0; // W = 0
4426 let Inst{20} = load;
4427 let Inst{19-16} = addr;
4428 let Inst{15-12} = CRd;
4429 let Inst{11-8} = cop;
4430 let Inst{7-0} = option;
4431 let DecoderMethod = "DecodeCopMemInstruction";
4435 defm LDC : LdStCop <1, 0, "ldc">;
4436 defm LDCL : LdStCop <1, 1, "ldcl">;
4437 defm STC : LdStCop <0, 0, "stc">;
4438 defm STCL : LdStCop <0, 1, "stcl">;
4439 defm LDC2 : LdSt2Cop<1, 0, "ldc2">;
4440 defm LDC2L : LdSt2Cop<1, 1, "ldc2l">;
4441 defm STC2 : LdSt2Cop<0, 0, "stc2">;
4442 defm STC2L : LdSt2Cop<0, 1, "stc2l">;
4444 //===----------------------------------------------------------------------===//
4445 // Move between coprocessor and ARM core register.
4448 class MovRCopro<string opc, bit direction, dag oops, dag iops,
4450 : ABI<0b1110, oops, iops, NoItinerary, opc,
4451 "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2", pattern> {
4452 let Inst{20} = direction;
4462 let Inst{15-12} = Rt;
4463 let Inst{11-8} = cop;
4464 let Inst{23-21} = opc1;
4465 let Inst{7-5} = opc2;
4466 let Inst{3-0} = CRm;
4467 let Inst{19-16} = CRn;
4470 def MCR : MovRCopro<"mcr", 0 /* from ARM core register to coprocessor */,
4472 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4473 c_imm:$CRm, imm0_7:$opc2),
4474 [(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
4475 imm:$CRm, imm:$opc2)]>;
4476 def : ARMInstAlias<"mcr${p} $cop, $opc1, $Rt, $CRn, $CRm",
4477 (MCR p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4478 c_imm:$CRm, 0, pred:$p)>;
4479 def MRC : MovRCopro<"mrc", 1 /* from coprocessor to ARM core register */,
4481 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
4483 def : ARMInstAlias<"mrc${p} $cop, $opc1, $Rt, $CRn, $CRm",
4484 (MRC GPR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
4485 c_imm:$CRm, 0, pred:$p)>;
4487 def : ARMPat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
4488 (MRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
4490 class MovRCopro2<string opc, bit direction, dag oops, dag iops,
4492 : ABXI<0b1110, oops, iops, NoItinerary,
4493 !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), pattern> {
4494 let Inst{31-28} = 0b1111;
4495 let Inst{20} = direction;
4505 let Inst{15-12} = Rt;
4506 let Inst{11-8} = cop;
4507 let Inst{23-21} = opc1;
4508 let Inst{7-5} = opc2;
4509 let Inst{3-0} = CRm;
4510 let Inst{19-16} = CRn;
4513 def MCR2 : MovRCopro2<"mcr2", 0 /* from ARM core register to coprocessor */,
4515 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4516 c_imm:$CRm, imm0_7:$opc2),
4517 [(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
4518 imm:$CRm, imm:$opc2)]>;
4519 def : ARMInstAlias<"mcr2$ $cop, $opc1, $Rt, $CRn, $CRm",
4520 (MCR2 p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4522 def MRC2 : MovRCopro2<"mrc2", 1 /* from coprocessor to ARM core register */,
4524 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
4526 def : ARMInstAlias<"mrc2$ $cop, $opc1, $Rt, $CRn, $CRm",
4527 (MRC2 GPR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
4530 def : ARMV5TPat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn,
4531 imm:$CRm, imm:$opc2),
4532 (MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
4534 class MovRRCopro<string opc, bit direction, list<dag> pattern = []>
4535 : ABI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4536 GPRnopc:$Rt, GPRnopc:$Rt2, c_imm:$CRm),
4537 NoItinerary, opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm", pattern> {
4538 let Inst{23-21} = 0b010;
4539 let Inst{20} = direction;
4547 let Inst{15-12} = Rt;
4548 let Inst{19-16} = Rt2;
4549 let Inst{11-8} = cop;
4550 let Inst{7-4} = opc1;
4551 let Inst{3-0} = CRm;
4554 def MCRR : MovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */,
4555 [(int_arm_mcrr imm:$cop, imm:$opc1, GPRnopc:$Rt,
4556 GPRnopc:$Rt2, imm:$CRm)]>;
4557 def MRRC : MovRRCopro<"mrrc", 1 /* from coprocessor to ARM core register */>;
4559 class MovRRCopro2<string opc, bit direction, list<dag> pattern = []>
4560 : ABXI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4561 GPRnopc:$Rt, GPRnopc:$Rt2, c_imm:$CRm), NoItinerary,
4562 !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern> {
4563 let Inst{31-28} = 0b1111;
4564 let Inst{23-21} = 0b010;
4565 let Inst{20} = direction;
4573 let Inst{15-12} = Rt;
4574 let Inst{19-16} = Rt2;
4575 let Inst{11-8} = cop;
4576 let Inst{7-4} = opc1;
4577 let Inst{3-0} = CRm;
4579 let DecoderMethod = "DecodeMRRC2";
4582 def MCRR2 : MovRRCopro2<"mcrr2", 0 /* from ARM core register to coprocessor */,
4583 [(int_arm_mcrr2 imm:$cop, imm:$opc1, GPRnopc:$Rt,
4584 GPRnopc:$Rt2, imm:$CRm)]>;
4585 def MRRC2 : MovRRCopro2<"mrrc2", 1 /* from coprocessor to ARM core register */>;
4587 //===----------------------------------------------------------------------===//
4588 // Move between special register and ARM core register
4591 // Move to ARM core register from Special Register
4592 def MRS : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
4593 "mrs", "\t$Rd, apsr", []> {
4595 let Inst{23-16} = 0b00001111;
4596 let Unpredictable{19-17} = 0b111;
4598 let Inst{15-12} = Rd;
4600 let Inst{11-0} = 0b000000000000;
4601 let Unpredictable{11-0} = 0b110100001111;
4604 def : InstAlias<"mrs${p} $Rd, cpsr", (MRS GPRnopc:$Rd, pred:$p)>,
4607 // The MRSsys instruction is the MRS instruction from the ARM ARM,
4608 // section B9.3.9, with the R bit set to 1.
4609 def MRSsys : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
4610 "mrs", "\t$Rd, spsr", []> {
4612 let Inst{23-16} = 0b01001111;
4613 let Unpredictable{19-16} = 0b1111;
4615 let Inst{15-12} = Rd;
4617 let Inst{11-0} = 0b000000000000;
4618 let Unpredictable{11-0} = 0b110100001111;
4621 // Move from ARM core register to Special Register
4623 // No need to have both system and application versions, the encodings are the
4624 // same and the assembly parser has no way to distinguish between them. The mask
4625 // operand contains the special register (R Bit) in bit 4 and bits 3-0 contains
4626 // the mask with the fields to be accessed in the special register.
4627 def MSR : ABI<0b0001, (outs), (ins msr_mask:$mask, GPR:$Rn), NoItinerary,
4628 "msr", "\t$mask, $Rn", []> {
4633 let Inst{22} = mask{4}; // R bit
4634 let Inst{21-20} = 0b10;
4635 let Inst{19-16} = mask{3-0};
4636 let Inst{15-12} = 0b1111;
4637 let Inst{11-4} = 0b00000000;
4641 def MSRi : ABI<0b0011, (outs), (ins msr_mask:$mask, so_imm:$a), NoItinerary,
4642 "msr", "\t$mask, $a", []> {
4647 let Inst{22} = mask{4}; // R bit
4648 let Inst{21-20} = 0b10;
4649 let Inst{19-16} = mask{3-0};
4650 let Inst{15-12} = 0b1111;
4654 //===----------------------------------------------------------------------===//
4658 // __aeabi_read_tp preserves the registers r1-r3.
4659 // This is a pseudo inst so that we can get the encoding right,
4660 // complete with fixup for the aeabi_read_tp function.
4662 Defs = [R0, R12, LR, CPSR], Uses = [SP] in {
4663 def TPsoft : PseudoInst<(outs), (ins), IIC_Br,
4664 [(set R0, ARMthread_pointer)]>;
4667 //===----------------------------------------------------------------------===//
4668 // SJLJ Exception handling intrinsics
4669 // eh_sjlj_setjmp() is an instruction sequence to store the return
4670 // address and save #0 in R0 for the non-longjmp case.
4671 // Since by its nature we may be coming from some other function to get
4672 // here, and we're using the stack frame for the containing function to
4673 // save/restore registers, we can't keep anything live in regs across
4674 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
4675 // when we get here from a longjmp(). We force everything out of registers
4676 // except for our own input by listing the relevant registers in Defs. By
4677 // doing so, we also cause the prologue/epilogue code to actively preserve
4678 // all of the callee-saved resgisters, which is exactly what we want.
4679 // A constant value is passed in $val, and we use the location as a scratch.
4681 // These are pseudo-instructions and are lowered to individual MC-insts, so
4682 // no encoding information is necessary.
4684 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
4685 Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15 ],
4686 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
4687 def Int_eh_sjlj_setjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
4689 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
4690 Requires<[IsARM, HasVFP2]>;
4694 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
4695 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
4696 def Int_eh_sjlj_setjmp_nofp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
4698 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
4699 Requires<[IsARM, NoVFP]>;
4702 // FIXME: Non-IOS version(s)
4703 let isBarrier = 1, hasSideEffects = 1, isTerminator = 1,
4704 Defs = [ R7, LR, SP ] in {
4705 def Int_eh_sjlj_longjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$scratch),
4707 [(ARMeh_sjlj_longjmp GPR:$src, GPR:$scratch)]>,
4708 Requires<[IsARM, IsIOS]>;
4711 // eh.sjlj.dispatchsetup pseudo-instructions.
4712 // These pseudos are used for both ARM and Thumb2. Any differences are
4713 // handled when the pseudo is expanded (which happens before any passes
4714 // that need the instruction size).
4716 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
4717 Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15 ],
4719 def Int_eh_sjlj_dispatchsetup : PseudoInst<(outs), (ins), NoItinerary, []>;
4722 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
4724 def Int_eh_sjlj_dispatchsetup_nofp : PseudoInst<(outs), (ins), NoItinerary, []>;
4727 //===----------------------------------------------------------------------===//
4728 // Non-Instruction Patterns
4731 // ARMv4 indirect branch using (MOVr PC, dst)
4732 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in
4733 def MOVPCRX : ARMPseudoExpand<(outs), (ins GPR:$dst),
4734 4, IIC_Br, [(brind GPR:$dst)],
4735 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>,
4736 Requires<[IsARM, NoV4T]>;
4738 // Large immediate handling.
4740 // 32-bit immediate using two piece so_imms or movw + movt.
4741 // This is a single pseudo instruction, the benefit is that it can be remat'd
4742 // as a single unit instead of having to handle reg inputs.
4743 // FIXME: Remove this when we can do generalized remat.
4744 let isReMaterializable = 1, isMoveImm = 1 in
4745 def MOVi32imm : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
4746 [(set GPR:$dst, (arm_i32imm:$src))]>,
4749 // Pseudo instruction that combines movw + movt + add pc (if PIC).
4750 // It also makes it possible to rematerialize the instructions.
4751 // FIXME: Remove this when we can do generalized remat and when machine licm
4752 // can properly the instructions.
4753 let isReMaterializable = 1 in {
4754 def MOV_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
4756 [(set GPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>,
4757 Requires<[IsARM, UseMovt]>;
4759 def MOV_ga_dyn : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
4761 [(set GPR:$dst, (ARMWrapperDYN tglobaladdr:$addr))]>,
4762 Requires<[IsARM, UseMovt]>;
4764 let AddedComplexity = 10 in
4765 def MOV_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
4767 [(set GPR:$dst, (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
4768 Requires<[IsARM, UseMovt]>;
4769 } // isReMaterializable
4771 // ConstantPool, GlobalAddress, and JumpTable
4772 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (LEApcrel tglobaladdr :$dst)>,
4773 Requires<[IsARM, DontUseMovt]>;
4774 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
4775 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
4776 Requires<[IsARM, UseMovt]>;
4777 def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
4778 (LEApcrelJT tjumptable:$dst, imm:$id)>;
4780 // TODO: add,sub,and, 3-instr forms?
4782 // Tail calls. These patterns also apply to Thumb mode.
4783 def : Pat<(ARMtcret tcGPR:$dst), (TCRETURNri tcGPR:$dst)>;
4784 def : Pat<(ARMtcret (i32 tglobaladdr:$dst)), (TCRETURNdi texternalsym:$dst)>;
4785 def : Pat<(ARMtcret (i32 texternalsym:$dst)), (TCRETURNdi texternalsym:$dst)>;
4788 def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>;
4789 def : ARMPat<(ARMcall_nolink texternalsym:$func),
4790 (BMOVPCB_CALL texternalsym:$func)>;
4792 // zextload i1 -> zextload i8
4793 def : ARMPat<(zextloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
4794 def : ARMPat<(zextloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
4796 // extload -> zextload
4797 def : ARMPat<(extloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
4798 def : ARMPat<(extloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
4799 def : ARMPat<(extloadi8 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
4800 def : ARMPat<(extloadi8 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
4802 def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
4804 def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
4805 def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
4808 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4809 (sra (shl GPR:$b, (i32 16)), (i32 16))),
4810 (SMULBB GPR:$a, GPR:$b)>;
4811 def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
4812 (SMULBB GPR:$a, GPR:$b)>;
4813 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4814 (sra GPR:$b, (i32 16))),
4815 (SMULBT GPR:$a, GPR:$b)>;
4816 def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, (i32 16))),
4817 (SMULBT GPR:$a, GPR:$b)>;
4818 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)),
4819 (sra (shl GPR:$b, (i32 16)), (i32 16))),
4820 (SMULTB GPR:$a, GPR:$b)>;
4821 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), sext_16_node:$b),
4822 (SMULTB GPR:$a, GPR:$b)>;
4823 def : ARMV5TEPat<(sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
4825 (SMULWB GPR:$a, GPR:$b)>;
4826 def : ARMV5TEPat<(sra (mul GPR:$a, sext_16_node:$b), (i32 16)),
4827 (SMULWB GPR:$a, GPR:$b)>;
4829 def : ARMV5TEPat<(add GPR:$acc,
4830 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4831 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
4832 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
4833 def : ARMV5TEPat<(add GPR:$acc,
4834 (mul sext_16_node:$a, sext_16_node:$b)),
4835 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
4836 def : ARMV5TEPat<(add GPR:$acc,
4837 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4838 (sra GPR:$b, (i32 16)))),
4839 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
4840 def : ARMV5TEPat<(add GPR:$acc,
4841 (mul sext_16_node:$a, (sra GPR:$b, (i32 16)))),
4842 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
4843 def : ARMV5TEPat<(add GPR:$acc,
4844 (mul (sra GPR:$a, (i32 16)),
4845 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
4846 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
4847 def : ARMV5TEPat<(add GPR:$acc,
4848 (mul (sra GPR:$a, (i32 16)), sext_16_node:$b)),
4849 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
4850 def : ARMV5TEPat<(add GPR:$acc,
4851 (sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
4853 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
4854 def : ARMV5TEPat<(add GPR:$acc,
4855 (sra (mul GPR:$a, sext_16_node:$b), (i32 16))),
4856 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
4859 // Pre-v7 uses MCR for synchronization barriers.
4860 def : ARMPat<(ARMMemBarrierMCR GPR:$zero), (MCR 15, 0, GPR:$zero, 7, 10, 5)>,
4861 Requires<[IsARM, HasV6]>;
4863 // SXT/UXT with no rotate
4864 let AddedComplexity = 16 in {
4865 def : ARMV6Pat<(and GPR:$Src, 0x000000FF), (UXTB GPR:$Src, 0)>;
4866 def : ARMV6Pat<(and GPR:$Src, 0x0000FFFF), (UXTH GPR:$Src, 0)>;
4867 def : ARMV6Pat<(and GPR:$Src, 0x00FF00FF), (UXTB16 GPR:$Src, 0)>;
4868 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0x00FF)),
4869 (UXTAB GPR:$Rn, GPR:$Rm, 0)>;
4870 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0xFFFF)),
4871 (UXTAH GPR:$Rn, GPR:$Rm, 0)>;
4874 def : ARMV6Pat<(sext_inreg GPR:$Src, i8), (SXTB GPR:$Src, 0)>;
4875 def : ARMV6Pat<(sext_inreg GPR:$Src, i16), (SXTH GPR:$Src, 0)>;
4877 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i8)),
4878 (SXTAB GPR:$Rn, GPRnopc:$Rm, 0)>;
4879 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i16)),
4880 (SXTAH GPR:$Rn, GPRnopc:$Rm, 0)>;
4882 // Atomic load/store patterns
4883 def : ARMPat<(atomic_load_8 ldst_so_reg:$src),
4884 (LDRBrs ldst_so_reg:$src)>;
4885 def : ARMPat<(atomic_load_8 addrmode_imm12:$src),
4886 (LDRBi12 addrmode_imm12:$src)>;
4887 def : ARMPat<(atomic_load_16 addrmode3:$src),
4888 (LDRH addrmode3:$src)>;
4889 def : ARMPat<(atomic_load_32 ldst_so_reg:$src),
4890 (LDRrs ldst_so_reg:$src)>;
4891 def : ARMPat<(atomic_load_32 addrmode_imm12:$src),
4892 (LDRi12 addrmode_imm12:$src)>;
4893 def : ARMPat<(atomic_store_8 ldst_so_reg:$ptr, GPR:$val),
4894 (STRBrs GPR:$val, ldst_so_reg:$ptr)>;
4895 def : ARMPat<(atomic_store_8 addrmode_imm12:$ptr, GPR:$val),
4896 (STRBi12 GPR:$val, addrmode_imm12:$ptr)>;
4897 def : ARMPat<(atomic_store_16 addrmode3:$ptr, GPR:$val),
4898 (STRH GPR:$val, addrmode3:$ptr)>;
4899 def : ARMPat<(atomic_store_32 ldst_so_reg:$ptr, GPR:$val),
4900 (STRrs GPR:$val, ldst_so_reg:$ptr)>;
4901 def : ARMPat<(atomic_store_32 addrmode_imm12:$ptr, GPR:$val),
4902 (STRi12 GPR:$val, addrmode_imm12:$ptr)>;
4905 //===----------------------------------------------------------------------===//
4909 include "ARMInstrThumb.td"
4911 //===----------------------------------------------------------------------===//
4915 include "ARMInstrThumb2.td"
4917 //===----------------------------------------------------------------------===//
4918 // Floating Point Support
4921 include "ARMInstrVFP.td"
4923 //===----------------------------------------------------------------------===//
4924 // Advanced SIMD (NEON) Support
4927 include "ARMInstrNEON.td"
4929 //===----------------------------------------------------------------------===//
4930 // Assembler aliases
4934 def : InstAlias<"dmb", (DMB 0xf)>, Requires<[IsARM, HasDB]>;
4935 def : InstAlias<"dsb", (DSB 0xf)>, Requires<[IsARM, HasDB]>;
4936 def : InstAlias<"isb", (ISB 0xf)>, Requires<[IsARM, HasDB]>;
4938 // System instructions
4939 def : MnemonicAlias<"swi", "svc">;
4941 // Load / Store Multiple
4942 def : MnemonicAlias<"ldmfd", "ldm">;
4943 def : MnemonicAlias<"ldmia", "ldm">;
4944 def : MnemonicAlias<"ldmea", "ldmdb">;
4945 def : MnemonicAlias<"stmfd", "stmdb">;
4946 def : MnemonicAlias<"stmia", "stm">;
4947 def : MnemonicAlias<"stmea", "stm">;
4949 // PKHBT/PKHTB with default shift amount. PKHTB is equivalent to PKHBT when the
4950 // shift amount is zero (i.e., unspecified).
4951 def : InstAlias<"pkhbt${p} $Rd, $Rn, $Rm",
4952 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
4953 Requires<[IsARM, HasV6]>;
4954 def : InstAlias<"pkhtb${p} $Rd, $Rn, $Rm",
4955 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
4956 Requires<[IsARM, HasV6]>;
4958 // PUSH/POP aliases for STM/LDM
4959 def : ARMInstAlias<"push${p} $regs", (STMDB_UPD SP, pred:$p, reglist:$regs)>;
4960 def : ARMInstAlias<"pop${p} $regs", (LDMIA_UPD SP, pred:$p, reglist:$regs)>;
4962 // SSAT/USAT optional shift operand.
4963 def : ARMInstAlias<"ssat${p} $Rd, $sat_imm, $Rn",
4964 (SSAT GPRnopc:$Rd, imm1_32:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
4965 def : ARMInstAlias<"usat${p} $Rd, $sat_imm, $Rn",
4966 (USAT GPRnopc:$Rd, imm0_31:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
4969 // Extend instruction optional rotate operand.
4970 def : ARMInstAlias<"sxtab${p} $Rd, $Rn, $Rm",
4971 (SXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4972 def : ARMInstAlias<"sxtah${p} $Rd, $Rn, $Rm",
4973 (SXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4974 def : ARMInstAlias<"sxtab16${p} $Rd, $Rn, $Rm",
4975 (SXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4976 def : ARMInstAlias<"sxtb${p} $Rd, $Rm",
4977 (SXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4978 def : ARMInstAlias<"sxtb16${p} $Rd, $Rm",
4979 (SXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4980 def : ARMInstAlias<"sxth${p} $Rd, $Rm",
4981 (SXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4983 def : ARMInstAlias<"uxtab${p} $Rd, $Rn, $Rm",
4984 (UXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4985 def : ARMInstAlias<"uxtah${p} $Rd, $Rn, $Rm",
4986 (UXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4987 def : ARMInstAlias<"uxtab16${p} $Rd, $Rn, $Rm",
4988 (UXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4989 def : ARMInstAlias<"uxtb${p} $Rd, $Rm",
4990 (UXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4991 def : ARMInstAlias<"uxtb16${p} $Rd, $Rm",
4992 (UXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4993 def : ARMInstAlias<"uxth${p} $Rd, $Rm",
4994 (UXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4998 def : MnemonicAlias<"rfefa", "rfeda">;
4999 def : MnemonicAlias<"rfeea", "rfedb">;
5000 def : MnemonicAlias<"rfefd", "rfeia">;
5001 def : MnemonicAlias<"rfeed", "rfeib">;
5002 def : MnemonicAlias<"rfe", "rfeia">;
5005 def : MnemonicAlias<"srsfa", "srsda">;
5006 def : MnemonicAlias<"srsea", "srsdb">;
5007 def : MnemonicAlias<"srsfd", "srsia">;
5008 def : MnemonicAlias<"srsed", "srsib">;
5009 def : MnemonicAlias<"srs", "srsia">;
5012 def : MnemonicAlias<"qsubaddx", "qsax">;
5014 def : MnemonicAlias<"saddsubx", "sasx">;
5015 // SHASX == SHADDSUBX
5016 def : MnemonicAlias<"shaddsubx", "shasx">;
5017 // SHSAX == SHSUBADDX
5018 def : MnemonicAlias<"shsubaddx", "shsax">;
5020 def : MnemonicAlias<"ssubaddx", "ssax">;
5022 def : MnemonicAlias<"uaddsubx", "uasx">;
5023 // UHASX == UHADDSUBX
5024 def : MnemonicAlias<"uhaddsubx", "uhasx">;
5025 // UHSAX == UHSUBADDX
5026 def : MnemonicAlias<"uhsubaddx", "uhsax">;
5027 // UQASX == UQADDSUBX
5028 def : MnemonicAlias<"uqaddsubx", "uqasx">;
5029 // UQSAX == UQSUBADDX
5030 def : MnemonicAlias<"uqsubaddx", "uqsax">;
5032 def : MnemonicAlias<"usubaddx", "usax">;
5034 // "mov Rd, so_imm_not" can be handled via "mvn" in assembly, just like
5036 def : ARMInstAlias<"mov${s}${p} $Rd, $imm",
5037 (MVNi rGPR:$Rd, so_imm_not:$imm, pred:$p, cc_out:$s)>;
5038 def : ARMInstAlias<"mvn${s}${p} $Rd, $imm",
5039 (MOVi rGPR:$Rd, so_imm_not:$imm, pred:$p, cc_out:$s)>;
5040 // Same for AND <--> BIC
5041 def : ARMInstAlias<"bic${s}${p} $Rd, $Rn, $imm",
5042 (ANDri rGPR:$Rd, rGPR:$Rn, so_imm_not:$imm,
5043 pred:$p, cc_out:$s)>;
5044 def : ARMInstAlias<"bic${s}${p} $Rdn, $imm",
5045 (ANDri rGPR:$Rdn, rGPR:$Rdn, so_imm_not:$imm,
5046 pred:$p, cc_out:$s)>;
5047 def : ARMInstAlias<"and${s}${p} $Rd, $Rn, $imm",
5048 (BICri rGPR:$Rd, rGPR:$Rn, so_imm_not:$imm,
5049 pred:$p, cc_out:$s)>;
5050 def : ARMInstAlias<"and${s}${p} $Rdn, $imm",
5051 (BICri rGPR:$Rdn, rGPR:$Rdn, so_imm_not:$imm,
5052 pred:$p, cc_out:$s)>;
5054 // Likewise, "add Rd, so_imm_neg" -> sub
5055 def : ARMInstAlias<"add${s}${p} $Rd, $Rn, $imm",
5056 (SUBri GPR:$Rd, GPR:$Rn, so_imm_neg:$imm, pred:$p, cc_out:$s)>;
5057 def : ARMInstAlias<"add${s}${p} $Rd, $imm",
5058 (SUBri GPR:$Rd, GPR:$Rd, so_imm_neg:$imm, pred:$p, cc_out:$s)>;
5059 // Same for CMP <--> CMN via so_imm_neg
5060 def : ARMInstAlias<"cmp${p} $Rd, $imm",
5061 (CMNri rGPR:$Rd, so_imm_neg:$imm, pred:$p)>;
5062 def : ARMInstAlias<"cmn${p} $Rd, $imm",
5063 (CMPri rGPR:$Rd, so_imm_neg:$imm, pred:$p)>;
5065 // The shifter forms of the MOV instruction are aliased to the ASR, LSL,
5066 // LSR, ROR, and RRX instructions.
5067 // FIXME: We need C++ parser hooks to map the alias to the MOV
5068 // encoding. It seems we should be able to do that sort of thing
5069 // in tblgen, but it could get ugly.
5070 let TwoOperandAliasConstraint = "$Rm = $Rd" in {
5071 def ASRi : ARMAsmPseudo<"asr${s}${p} $Rd, $Rm, $imm",
5072 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
5074 def LSRi : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rm, $imm",
5075 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
5077 def LSLi : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rm, $imm",
5078 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
5080 def RORi : ARMAsmPseudo<"ror${s}${p} $Rd, $Rm, $imm",
5081 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
5084 def RRXi : ARMAsmPseudo<"rrx${s}${p} $Rd, $Rm",
5085 (ins GPRnopc:$Rd, GPRnopc:$Rm, pred:$p, cc_out:$s)>;
5086 let TwoOperandAliasConstraint = "$Rn = $Rd" in {
5087 def ASRr : ARMAsmPseudo<"asr${s}${p} $Rd, $Rn, $Rm",
5088 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5090 def LSRr : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rn, $Rm",
5091 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5093 def LSLr : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rn, $Rm",
5094 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5096 def RORr : ARMAsmPseudo<"ror${s}${p} $Rd, $Rn, $Rm",
5097 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
5101 // "neg" is and alias for "rsb rd, rn, #0"
5102 def : ARMInstAlias<"neg${s}${p} $Rd, $Rm",
5103 (RSBri GPR:$Rd, GPR:$Rm, 0, pred:$p, cc_out:$s)>;
5105 // Pre-v6, 'mov r0, r0' was used as a NOP encoding.
5106 def : InstAlias<"nop${p}", (MOVr R0, R0, pred:$p, zero_reg)>,
5107 Requires<[IsARM, NoV6]>;
5109 // UMULL/SMULL are available on all arches, but the instruction definitions
5110 // need difference constraints pre-v6. Use these aliases for the assembly
5111 // parsing on pre-v6.
5112 def : InstAlias<"smull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5113 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5114 Requires<[IsARM, NoV6]>;
5115 def : InstAlias<"umull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
5116 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
5117 Requires<[IsARM, NoV6]>;
5119 // 'it' blocks in ARM mode just validate the predicates. The IT itself
5121 def ITasm : ARMAsmPseudo<"it$mask $cc", (ins it_pred:$cc, it_mask:$mask)>;