1 //===- ARMInstrInfo.td - Target Description for ARM Target -*- tablegen -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the ARM instructions in TableGen format.
12 //===----------------------------------------------------------------------===//
14 //===----------------------------------------------------------------------===//
15 // ARM specific DAG Nodes.
19 def SDT_ARMCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32> ]>;
20 def SDT_ARMCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>, SDTCisVT<1, i32> ]>;
22 def SDT_ARMSaveCallPC : SDTypeProfile<0, 1, []>;
24 def SDT_ARMcall : SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>;
26 def SDT_ARMCMov : SDTypeProfile<1, 3,
27 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
30 def SDT_ARMBrcond : SDTypeProfile<0, 2,
31 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i32>]>;
33 def SDT_ARMBrJT : SDTypeProfile<0, 3,
34 [SDTCisPtrTy<0>, SDTCisVT<1, i32>,
37 def SDT_ARMBr2JT : SDTypeProfile<0, 4,
38 [SDTCisPtrTy<0>, SDTCisVT<1, i32>,
39 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
41 def SDT_ARMBCC_i64 : SDTypeProfile<0, 6,
43 SDTCisVT<1, i32>, SDTCisVT<2, i32>,
44 SDTCisVT<3, i32>, SDTCisVT<4, i32>,
45 SDTCisVT<5, OtherVT>]>;
47 def SDT_ARMAnd : SDTypeProfile<1, 2,
48 [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
51 def SDT_ARMCmp : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
53 def SDT_ARMPICAdd : SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>,
54 SDTCisPtrTy<1>, SDTCisVT<2, i32>]>;
56 def SDT_ARMThreadPointer : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
57 def SDT_ARMEH_SJLJ_Setjmp : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisPtrTy<1>,
59 def SDT_ARMEH_SJLJ_Longjmp: SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
61 def SDT_ARMEH_SJLJ_DispatchSetup: SDTypeProfile<0, 1, [SDTCisInt<0>]>;
63 def SDT_ARMMEMBARRIER : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
65 def SDT_ARMPREFETCH : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisSameAs<1, 2>,
68 def SDT_ARMTCRET : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
70 def SDT_ARMBFI : SDTypeProfile<1, 3, [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
71 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
73 def SDTBinaryArithWithFlags : SDTypeProfile<2, 2,
76 SDTCisInt<0>, SDTCisVT<1, i32>]>;
78 // SDTBinaryArithWithFlagsInOut - RES1, CPSR = op LHS, RHS, CPSR
79 def SDTBinaryArithWithFlagsInOut : SDTypeProfile<2, 3,
86 def ARMWrapper : SDNode<"ARMISD::Wrapper", SDTIntUnaryOp>;
87 def ARMWrapperDYN : SDNode<"ARMISD::WrapperDYN", SDTIntUnaryOp>;
88 def ARMWrapperPIC : SDNode<"ARMISD::WrapperPIC", SDTIntUnaryOp>;
89 def ARMWrapperJT : SDNode<"ARMISD::WrapperJT", SDTIntBinOp>;
91 def ARMcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_ARMCallSeqStart,
92 [SDNPHasChain, SDNPOutGlue]>;
93 def ARMcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_ARMCallSeqEnd,
94 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
96 def ARMcall : SDNode<"ARMISD::CALL", SDT_ARMcall,
97 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
99 def ARMcall_pred : SDNode<"ARMISD::CALL_PRED", SDT_ARMcall,
100 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
102 def ARMcall_nolink : SDNode<"ARMISD::CALL_NOLINK", SDT_ARMcall,
103 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
106 def ARMretflag : SDNode<"ARMISD::RET_FLAG", SDTNone,
107 [SDNPHasChain, SDNPOptInGlue]>;
109 def ARMcmov : SDNode<"ARMISD::CMOV", SDT_ARMCMov,
112 def ARMbrcond : SDNode<"ARMISD::BRCOND", SDT_ARMBrcond,
113 [SDNPHasChain, SDNPInGlue, SDNPOutGlue]>;
115 def ARMbrjt : SDNode<"ARMISD::BR_JT", SDT_ARMBrJT,
117 def ARMbr2jt : SDNode<"ARMISD::BR2_JT", SDT_ARMBr2JT,
120 def ARMBcci64 : SDNode<"ARMISD::BCC_i64", SDT_ARMBCC_i64,
123 def ARMcmp : SDNode<"ARMISD::CMP", SDT_ARMCmp,
126 def ARMcmpZ : SDNode<"ARMISD::CMPZ", SDT_ARMCmp,
127 [SDNPOutGlue, SDNPCommutative]>;
129 def ARMpic_add : SDNode<"ARMISD::PIC_ADD", SDT_ARMPICAdd>;
131 def ARMsrl_flag : SDNode<"ARMISD::SRL_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
132 def ARMsra_flag : SDNode<"ARMISD::SRA_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
133 def ARMrrx : SDNode<"ARMISD::RRX" , SDTIntUnaryOp, [SDNPInGlue ]>;
135 def ARMaddc : SDNode<"ARMISD::ADDC", SDTBinaryArithWithFlags,
137 def ARMsubc : SDNode<"ARMISD::SUBC", SDTBinaryArithWithFlags>;
138 def ARMadde : SDNode<"ARMISD::ADDE", SDTBinaryArithWithFlagsInOut>;
139 def ARMsube : SDNode<"ARMISD::SUBE", SDTBinaryArithWithFlagsInOut>;
141 def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>;
142 def ARMeh_sjlj_setjmp: SDNode<"ARMISD::EH_SJLJ_SETJMP",
143 SDT_ARMEH_SJLJ_Setjmp, [SDNPHasChain]>;
144 def ARMeh_sjlj_longjmp: SDNode<"ARMISD::EH_SJLJ_LONGJMP",
145 SDT_ARMEH_SJLJ_Longjmp, [SDNPHasChain]>;
146 def ARMeh_sjlj_dispatchsetup: SDNode<"ARMISD::EH_SJLJ_DISPATCHSETUP",
147 SDT_ARMEH_SJLJ_DispatchSetup, [SDNPHasChain]>;
150 def ARMMemBarrier : SDNode<"ARMISD::MEMBARRIER", SDT_ARMMEMBARRIER,
152 def ARMMemBarrierMCR : SDNode<"ARMISD::MEMBARRIER_MCR", SDT_ARMMEMBARRIER,
154 def ARMPreload : SDNode<"ARMISD::PRELOAD", SDT_ARMPREFETCH,
155 [SDNPHasChain, SDNPMayLoad, SDNPMayStore]>;
157 def ARMrbit : SDNode<"ARMISD::RBIT", SDTIntUnaryOp>;
159 def ARMtcret : SDNode<"ARMISD::TC_RETURN", SDT_ARMTCRET,
160 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
163 def ARMbfi : SDNode<"ARMISD::BFI", SDT_ARMBFI>;
165 //===----------------------------------------------------------------------===//
166 // ARM Instruction Predicate Definitions.
168 def HasV4T : Predicate<"Subtarget->hasV4TOps()">,
169 AssemblerPredicate<"HasV4TOps">;
170 def NoV4T : Predicate<"!Subtarget->hasV4TOps()">;
171 def HasV5T : Predicate<"Subtarget->hasV5TOps()">;
172 def HasV5TE : Predicate<"Subtarget->hasV5TEOps()">,
173 AssemblerPredicate<"HasV5TEOps">;
174 def HasV6 : Predicate<"Subtarget->hasV6Ops()">,
175 AssemblerPredicate<"HasV6Ops">;
176 def NoV6 : Predicate<"!Subtarget->hasV6Ops()">;
177 def HasV6T2 : Predicate<"Subtarget->hasV6T2Ops()">,
178 AssemblerPredicate<"HasV6T2Ops">;
179 def NoV6T2 : Predicate<"!Subtarget->hasV6T2Ops()">;
180 def HasV7 : Predicate<"Subtarget->hasV7Ops()">,
181 AssemblerPredicate<"HasV7Ops">;
182 def NoVFP : Predicate<"!Subtarget->hasVFP2()">;
183 def HasVFP2 : Predicate<"Subtarget->hasVFP2()">,
184 AssemblerPredicate<"FeatureVFP2">;
185 def HasVFP3 : Predicate<"Subtarget->hasVFP3()">,
186 AssemblerPredicate<"FeatureVFP3">;
187 def HasNEON : Predicate<"Subtarget->hasNEON()">,
188 AssemblerPredicate<"FeatureNEON">;
189 def HasFP16 : Predicate<"Subtarget->hasFP16()">,
190 AssemblerPredicate<"FeatureFP16">;
191 def HasDivide : Predicate<"Subtarget->hasDivide()">,
192 AssemblerPredicate<"FeatureHWDiv">;
193 def HasT2ExtractPack : Predicate<"Subtarget->hasT2ExtractPack()">,
194 AssemblerPredicate<"FeatureT2XtPk">;
195 def HasThumb2DSP : Predicate<"Subtarget->hasThumb2DSP()">,
196 AssemblerPredicate<"FeatureDSPThumb2">;
197 def HasDB : Predicate<"Subtarget->hasDataBarrier()">,
198 AssemblerPredicate<"FeatureDB">;
199 def HasMP : Predicate<"Subtarget->hasMPExtension()">,
200 AssemblerPredicate<"FeatureMP">;
201 def UseNEONForFP : Predicate<"Subtarget->useNEONForSinglePrecisionFP()">;
202 def DontUseNEONForFP : Predicate<"!Subtarget->useNEONForSinglePrecisionFP()">;
203 def IsThumb : Predicate<"Subtarget->isThumb()">,
204 AssemblerPredicate<"ModeThumb">;
205 def IsThumb1Only : Predicate<"Subtarget->isThumb1Only()">;
206 def IsThumb2 : Predicate<"Subtarget->isThumb2()">,
207 AssemblerPredicate<"ModeThumb,FeatureThumb2">;
208 def IsMClass : Predicate<"Subtarget->isMClass()">,
209 AssemblerPredicate<"FeatureMClass">;
210 def IsARClass : Predicate<"!Subtarget->isMClass()">,
211 AssemblerPredicate<"!FeatureMClass">;
212 def IsARM : Predicate<"!Subtarget->isThumb()">,
213 AssemblerPredicate<"!ModeThumb">;
214 def IsDarwin : Predicate<"Subtarget->isTargetDarwin()">;
215 def IsNotDarwin : Predicate<"!Subtarget->isTargetDarwin()">;
216 def IsNaCl : Predicate<"Subtarget->isTargetNaCl()">,
217 AssemblerPredicate<"ModeNaCl">;
219 // FIXME: Eventually this will be just "hasV6T2Ops".
220 def UseMovt : Predicate<"Subtarget->useMovt()">;
221 def DontUseMovt : Predicate<"!Subtarget->useMovt()">;
222 def UseFPVMLx : Predicate<"Subtarget->useFPVMLx()">;
224 //===----------------------------------------------------------------------===//
225 // ARM Flag Definitions.
227 class RegConstraint<string C> {
228 string Constraints = C;
231 //===----------------------------------------------------------------------===//
232 // ARM specific transformation functions and pattern fragments.
235 // so_imm_neg_XFORM - Return a so_imm value packed into the format described for
236 // so_imm_neg def below.
237 def so_imm_neg_XFORM : SDNodeXForm<imm, [{
238 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), MVT::i32);
241 // so_imm_not_XFORM - Return a so_imm value packed into the format described for
242 // so_imm_not def below.
243 def so_imm_not_XFORM : SDNodeXForm<imm, [{
244 return CurDAG->getTargetConstant(~(int)N->getZExtValue(), MVT::i32);
247 /// imm1_15 predicate - True if the 32-bit immediate is in the range [1,15].
248 def imm1_15 : ImmLeaf<i32, [{
249 return (int32_t)Imm >= 1 && (int32_t)Imm < 16;
252 /// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
253 def imm16_31 : ImmLeaf<i32, [{
254 return (int32_t)Imm >= 16 && (int32_t)Imm < 32;
259 return ARM_AM::getSOImmVal(-(uint32_t)N->getZExtValue()) != -1;
260 }], so_imm_neg_XFORM>;
264 return ARM_AM::getSOImmVal(~(uint32_t)N->getZExtValue()) != -1;
265 }], so_imm_not_XFORM>;
267 // sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
268 def sext_16_node : PatLeaf<(i32 GPR:$a), [{
269 return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17;
272 /// Split a 32-bit immediate into two 16 bit parts.
273 def hi16 : SDNodeXForm<imm, [{
274 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, MVT::i32);
277 def lo16AllZero : PatLeaf<(i32 imm), [{
278 // Returns true if all low 16-bits are 0.
279 return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
282 /// imm0_65535 - An immediate is in the range [0.65535].
283 def Imm0_65535AsmOperand: AsmOperandClass { let Name = "Imm0_65535"; }
284 def imm0_65535 : Operand<i32>, ImmLeaf<i32, [{
285 return Imm >= 0 && Imm < 65536;
287 let ParserMatchClass = Imm0_65535AsmOperand;
290 class BinOpWithFlagFrag<dag res> :
291 PatFrag<(ops node:$LHS, node:$RHS, node:$FLAG), res>;
292 class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
293 class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
295 // An 'and' node with a single use.
296 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
297 return N->hasOneUse();
300 // An 'xor' node with a single use.
301 def xor_su : PatFrag<(ops node:$lhs, node:$rhs), (xor node:$lhs, node:$rhs), [{
302 return N->hasOneUse();
305 // An 'fmul' node with a single use.
306 def fmul_su : PatFrag<(ops node:$lhs, node:$rhs), (fmul node:$lhs, node:$rhs),[{
307 return N->hasOneUse();
310 // An 'fadd' node which checks for single non-hazardous use.
311 def fadd_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fadd node:$lhs, node:$rhs),[{
312 return hasNoVMLxHazardUse(N);
315 // An 'fsub' node which checks for single non-hazardous use.
316 def fsub_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fsub node:$lhs, node:$rhs),[{
317 return hasNoVMLxHazardUse(N);
320 //===----------------------------------------------------------------------===//
321 // Operand Definitions.
325 // FIXME: rename brtarget to t2_brtarget
326 def brtarget : Operand<OtherVT> {
327 let EncoderMethod = "getBranchTargetOpValue";
328 let OperandType = "OPERAND_PCREL";
329 let DecoderMethod = "DecodeT2BROperand";
332 // FIXME: get rid of this one?
333 def uncondbrtarget : Operand<OtherVT> {
334 let EncoderMethod = "getUnconditionalBranchTargetOpValue";
335 let OperandType = "OPERAND_PCREL";
338 // Branch target for ARM. Handles conditional/unconditional
339 def br_target : Operand<OtherVT> {
340 let EncoderMethod = "getARMBranchTargetOpValue";
341 let OperandType = "OPERAND_PCREL";
345 // FIXME: rename bltarget to t2_bl_target?
346 def bltarget : Operand<i32> {
347 // Encoded the same as branch targets.
348 let EncoderMethod = "getBranchTargetOpValue";
349 let OperandType = "OPERAND_PCREL";
352 // Call target for ARM. Handles conditional/unconditional
353 // FIXME: rename bl_target to t2_bltarget?
354 def bl_target : Operand<i32> {
355 // Encoded the same as branch targets.
356 let EncoderMethod = "getARMBranchTargetOpValue";
357 let OperandType = "OPERAND_PCREL";
360 def blx_target : Operand<i32> {
361 // Encoded the same as branch targets.
362 let EncoderMethod = "getARMBLXTargetOpValue";
363 let OperandType = "OPERAND_PCREL";
366 // A list of registers separated by comma. Used by load/store multiple.
367 def RegListAsmOperand : AsmOperandClass { let Name = "RegList"; }
368 def reglist : Operand<i32> {
369 let EncoderMethod = "getRegisterListOpValue";
370 let ParserMatchClass = RegListAsmOperand;
371 let PrintMethod = "printRegisterList";
372 let DecoderMethod = "DecodeRegListOperand";
375 def DPRRegListAsmOperand : AsmOperandClass { let Name = "DPRRegList"; }
376 def dpr_reglist : Operand<i32> {
377 let EncoderMethod = "getRegisterListOpValue";
378 let ParserMatchClass = DPRRegListAsmOperand;
379 let PrintMethod = "printRegisterList";
380 let DecoderMethod = "DecodeDPRRegListOperand";
383 def SPRRegListAsmOperand : AsmOperandClass { let Name = "SPRRegList"; }
384 def spr_reglist : Operand<i32> {
385 let EncoderMethod = "getRegisterListOpValue";
386 let ParserMatchClass = SPRRegListAsmOperand;
387 let PrintMethod = "printRegisterList";
388 let DecoderMethod = "DecodeSPRRegListOperand";
391 // An operand for the CONSTPOOL_ENTRY pseudo-instruction.
392 def cpinst_operand : Operand<i32> {
393 let PrintMethod = "printCPInstOperand";
397 def pclabel : Operand<i32> {
398 let PrintMethod = "printPCLabel";
401 // ADR instruction labels.
402 def adrlabel : Operand<i32> {
403 let EncoderMethod = "getAdrLabelOpValue";
406 def neon_vcvt_imm32 : Operand<i32> {
407 let EncoderMethod = "getNEONVcvtImm32OpValue";
408 let DecoderMethod = "DecodeVCVTImmOperand";
411 // rot_imm: An integer that encodes a rotate amount. Must be 8, 16, or 24.
412 def rot_imm_XFORM: SDNodeXForm<imm, [{
413 switch (N->getZExtValue()){
415 case 0: return CurDAG->getTargetConstant(0, MVT::i32);
416 case 8: return CurDAG->getTargetConstant(1, MVT::i32);
417 case 16: return CurDAG->getTargetConstant(2, MVT::i32);
418 case 24: return CurDAG->getTargetConstant(3, MVT::i32);
421 def RotImmAsmOperand : AsmOperandClass {
423 let ParserMethod = "parseRotImm";
425 def rot_imm : Operand<i32>, PatLeaf<(i32 imm), [{
426 int32_t v = N->getZExtValue();
427 return v == 8 || v == 16 || v == 24; }],
429 let PrintMethod = "printRotImmOperand";
430 let ParserMatchClass = RotImmAsmOperand;
433 // shift_imm: An integer that encodes a shift amount and the type of shift
434 // (asr or lsl). The 6-bit immediate encodes as:
437 // {4-0} imm5 shift amount.
438 // asr #32 encoded as imm5 == 0.
439 def ShifterImmAsmOperand : AsmOperandClass {
440 let Name = "ShifterImm";
441 let ParserMethod = "parseShifterImm";
443 def shift_imm : Operand<i32> {
444 let PrintMethod = "printShiftImmOperand";
445 let ParserMatchClass = ShifterImmAsmOperand;
448 // shifter_operand operands: so_reg_reg, so_reg_imm, and so_imm.
449 def ShiftedRegAsmOperand : AsmOperandClass { let Name = "RegShiftedReg"; }
450 def so_reg_reg : Operand<i32>, // reg reg imm
451 ComplexPattern<i32, 3, "SelectRegShifterOperand",
452 [shl, srl, sra, rotr]> {
453 let EncoderMethod = "getSORegRegOpValue";
454 let PrintMethod = "printSORegRegOperand";
455 let DecoderMethod = "DecodeSORegRegOperand";
456 let ParserMatchClass = ShiftedRegAsmOperand;
457 let MIOperandInfo = (ops GPRnopc, GPRnopc, i32imm);
460 def ShiftedImmAsmOperand : AsmOperandClass { let Name = "RegShiftedImm"; }
461 def so_reg_imm : Operand<i32>, // reg imm
462 ComplexPattern<i32, 2, "SelectImmShifterOperand",
463 [shl, srl, sra, rotr]> {
464 let EncoderMethod = "getSORegImmOpValue";
465 let PrintMethod = "printSORegImmOperand";
466 let DecoderMethod = "DecodeSORegImmOperand";
467 let ParserMatchClass = ShiftedImmAsmOperand;
468 let MIOperandInfo = (ops GPR, i32imm);
471 // FIXME: Does this need to be distinct from so_reg?
472 def shift_so_reg_reg : Operand<i32>, // reg reg imm
473 ComplexPattern<i32, 3, "SelectShiftRegShifterOperand",
474 [shl,srl,sra,rotr]> {
475 let EncoderMethod = "getSORegRegOpValue";
476 let PrintMethod = "printSORegRegOperand";
477 let DecoderMethod = "DecodeSORegRegOperand";
478 let MIOperandInfo = (ops GPR, GPR, i32imm);
481 // FIXME: Does this need to be distinct from so_reg?
482 def shift_so_reg_imm : Operand<i32>, // reg reg imm
483 ComplexPattern<i32, 2, "SelectShiftImmShifterOperand",
484 [shl,srl,sra,rotr]> {
485 let EncoderMethod = "getSORegImmOpValue";
486 let PrintMethod = "printSORegImmOperand";
487 let DecoderMethod = "DecodeSORegImmOperand";
488 let MIOperandInfo = (ops GPR, i32imm);
492 // so_imm - Match a 32-bit shifter_operand immediate operand, which is an
493 // 8-bit immediate rotated by an arbitrary number of bits.
494 def SOImmAsmOperand: AsmOperandClass { let Name = "ARMSOImm"; }
495 def so_imm : Operand<i32>, ImmLeaf<i32, [{
496 return ARM_AM::getSOImmVal(Imm) != -1;
498 let EncoderMethod = "getSOImmOpValue";
499 let ParserMatchClass = SOImmAsmOperand;
500 let DecoderMethod = "DecodeSOImmOperand";
503 // Break so_imm's up into two pieces. This handles immediates with up to 16
504 // bits set in them. This uses so_imm2part to match and so_imm2part_[12] to
505 // get the first/second pieces.
506 def so_imm2part : PatLeaf<(imm), [{
507 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
510 /// arm_i32imm - True for +V6T2, or true only if so_imm2part is true.
512 def arm_i32imm : PatLeaf<(imm), [{
513 if (Subtarget->hasV6T2Ops())
515 return ARM_AM::isSOImmTwoPartVal((unsigned)N->getZExtValue());
518 /// imm0_7 predicate - Immediate in the range [0,7].
519 def Imm0_7AsmOperand: AsmOperandClass { let Name = "Imm0_7"; }
520 def imm0_7 : Operand<i32>, ImmLeaf<i32, [{
521 return Imm >= 0 && Imm < 8;
523 let ParserMatchClass = Imm0_7AsmOperand;
526 /// imm0_15 predicate - Immediate in the range [0,15].
527 def Imm0_15AsmOperand: AsmOperandClass { let Name = "Imm0_15"; }
528 def imm0_15 : Operand<i32>, ImmLeaf<i32, [{
529 return Imm >= 0 && Imm < 16;
531 let ParserMatchClass = Imm0_15AsmOperand;
534 /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
535 def Imm0_31AsmOperand: AsmOperandClass { let Name = "Imm0_31"; }
536 def imm0_31 : Operand<i32>, ImmLeaf<i32, [{
537 return Imm >= 0 && Imm < 32;
539 let ParserMatchClass = Imm0_31AsmOperand;
542 /// imm0_255 predicate - Immediate in the range [0,255].
543 def Imm0_255AsmOperand : AsmOperandClass { let Name = "Imm0_255"; }
544 def imm0_255 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 256; }]> {
545 let ParserMatchClass = Imm0_255AsmOperand;
548 // imm0_65535_expr - For movt/movw - 16-bit immediate that can also reference
549 // a relocatable expression.
551 // FIXME: This really needs a Thumb version separate from the ARM version.
552 // While the range is the same, and can thus use the same match class,
553 // the encoding is different so it should have a different encoder method.
554 def Imm0_65535ExprAsmOperand: AsmOperandClass { let Name = "Imm0_65535Expr"; }
555 def imm0_65535_expr : Operand<i32> {
556 let EncoderMethod = "getHiLo16ImmOpValue";
557 let ParserMatchClass = Imm0_65535ExprAsmOperand;
560 /// imm24b - True if the 32-bit immediate is encodable in 24 bits.
561 def Imm24bitAsmOperand: AsmOperandClass { let Name = "Imm24bit"; }
562 def imm24b : Operand<i32>, ImmLeaf<i32, [{
563 return Imm >= 0 && Imm <= 0xffffff;
565 let ParserMatchClass = Imm24bitAsmOperand;
569 /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
571 def BitfieldAsmOperand : AsmOperandClass {
572 let Name = "Bitfield";
573 let ParserMethod = "parseBitfield";
575 def bf_inv_mask_imm : Operand<i32>,
577 return ARM::isBitFieldInvertedMask(N->getZExtValue());
579 let EncoderMethod = "getBitfieldInvertedMaskOpValue";
580 let PrintMethod = "printBitfieldInvMaskImmOperand";
581 let DecoderMethod = "DecodeBitfieldMaskOperand";
582 let ParserMatchClass = BitfieldAsmOperand;
585 def imm1_32_XFORM: SDNodeXForm<imm, [{
586 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, MVT::i32);
588 def Imm1_32AsmOperand: AsmOperandClass { let Name = "Imm1_32"; }
589 def imm1_32 : Operand<i32>, PatLeaf<(imm), [{
590 uint64_t Imm = N->getZExtValue();
591 return Imm > 0 && Imm <= 32;
594 let PrintMethod = "printImmPlusOneOperand";
595 let ParserMatchClass = Imm1_32AsmOperand;
598 def imm1_16_XFORM: SDNodeXForm<imm, [{
599 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, MVT::i32);
601 def Imm1_16AsmOperand: AsmOperandClass { let Name = "Imm1_16"; }
602 def imm1_16 : Operand<i32>, PatLeaf<(imm), [{ return Imm > 0 && Imm <= 16; }],
604 let PrintMethod = "printImmPlusOneOperand";
605 let ParserMatchClass = Imm1_16AsmOperand;
608 // Define ARM specific addressing modes.
609 // addrmode_imm12 := reg +/- imm12
611 def MemImm12OffsetAsmOperand : AsmOperandClass { let Name = "MemImm12Offset"; }
612 def addrmode_imm12 : Operand<i32>,
613 ComplexPattern<i32, 2, "SelectAddrModeImm12", []> {
614 // 12-bit immediate operand. Note that instructions using this encode
615 // #0 and #-0 differently. We flag #-0 as the magic value INT32_MIN. All other
616 // immediate values are as normal.
618 let EncoderMethod = "getAddrModeImm12OpValue";
619 let PrintMethod = "printAddrModeImm12Operand";
620 let DecoderMethod = "DecodeAddrModeImm12Operand";
621 let ParserMatchClass = MemImm12OffsetAsmOperand;
622 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
624 // ldst_so_reg := reg +/- reg shop imm
626 def MemRegOffsetAsmOperand : AsmOperandClass { let Name = "MemRegOffset"; }
627 def ldst_so_reg : Operand<i32>,
628 ComplexPattern<i32, 3, "SelectLdStSOReg", []> {
629 let EncoderMethod = "getLdStSORegOpValue";
630 // FIXME: Simplify the printer
631 let PrintMethod = "printAddrMode2Operand";
632 let DecoderMethod = "DecodeSORegMemOperand";
633 let ParserMatchClass = MemRegOffsetAsmOperand;
634 let MIOperandInfo = (ops GPR:$base, GPRnopc:$offsreg, i32imm:$shift);
637 // postidx_imm8 := +/- [0,255]
640 // {8} 1 is imm8 is non-negative. 0 otherwise.
641 // {7-0} [0,255] imm8 value.
642 def PostIdxImm8AsmOperand : AsmOperandClass { let Name = "PostIdxImm8"; }
643 def postidx_imm8 : Operand<i32> {
644 let PrintMethod = "printPostIdxImm8Operand";
645 let ParserMatchClass = PostIdxImm8AsmOperand;
646 let MIOperandInfo = (ops i32imm);
649 // postidx_imm8s4 := +/- [0,1020]
652 // {8} 1 is imm8 is non-negative. 0 otherwise.
653 // {7-0} [0,255] imm8 value, scaled by 4.
654 def postidx_imm8s4 : Operand<i32> {
655 let PrintMethod = "printPostIdxImm8s4Operand";
656 let MIOperandInfo = (ops i32imm);
660 // postidx_reg := +/- reg
662 def PostIdxRegAsmOperand : AsmOperandClass {
663 let Name = "PostIdxReg";
664 let ParserMethod = "parsePostIdxReg";
666 def postidx_reg : Operand<i32> {
667 let EncoderMethod = "getPostIdxRegOpValue";
668 let DecoderMethod = "DecodePostIdxReg";
669 let PrintMethod = "printPostIdxRegOperand";
670 let ParserMatchClass = PostIdxRegAsmOperand;
671 let MIOperandInfo = (ops GPR, i32imm);
675 // addrmode2 := reg +/- imm12
676 // := reg +/- reg shop imm
678 // FIXME: addrmode2 should be refactored the rest of the way to always
679 // use explicit imm vs. reg versions above (addrmode_imm12 and ldst_so_reg).
680 def AddrMode2AsmOperand : AsmOperandClass { let Name = "AddrMode2"; }
681 def addrmode2 : Operand<i32>,
682 ComplexPattern<i32, 3, "SelectAddrMode2", []> {
683 let EncoderMethod = "getAddrMode2OpValue";
684 let PrintMethod = "printAddrMode2Operand";
685 let ParserMatchClass = AddrMode2AsmOperand;
686 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
689 def PostIdxRegShiftedAsmOperand : AsmOperandClass {
690 let Name = "PostIdxRegShifted";
691 let ParserMethod = "parsePostIdxReg";
693 def am2offset_reg : Operand<i32>,
694 ComplexPattern<i32, 2, "SelectAddrMode2OffsetReg",
695 [], [SDNPWantRoot]> {
696 let EncoderMethod = "getAddrMode2OffsetOpValue";
697 let PrintMethod = "printAddrMode2OffsetOperand";
698 // When using this for assembly, it's always as a post-index offset.
699 let ParserMatchClass = PostIdxRegShiftedAsmOperand;
700 let MIOperandInfo = (ops GPR, i32imm);
703 // FIXME: am2offset_imm should only need the immediate, not the GPR. Having
704 // the GPR is purely vestigal at this point.
705 def AM2OffsetImmAsmOperand : AsmOperandClass { let Name = "AM2OffsetImm"; }
706 def am2offset_imm : Operand<i32>,
707 ComplexPattern<i32, 2, "SelectAddrMode2OffsetImm",
708 [], [SDNPWantRoot]> {
709 let EncoderMethod = "getAddrMode2OffsetOpValue";
710 let PrintMethod = "printAddrMode2OffsetOperand";
711 let ParserMatchClass = AM2OffsetImmAsmOperand;
712 let MIOperandInfo = (ops GPR, i32imm);
716 // addrmode3 := reg +/- reg
717 // addrmode3 := reg +/- imm8
719 // FIXME: split into imm vs. reg versions.
720 def AddrMode3AsmOperand : AsmOperandClass { let Name = "AddrMode3"; }
721 def addrmode3 : Operand<i32>,
722 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
723 let EncoderMethod = "getAddrMode3OpValue";
724 let PrintMethod = "printAddrMode3Operand";
725 let ParserMatchClass = AddrMode3AsmOperand;
726 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
729 // FIXME: split into imm vs. reg versions.
730 // FIXME: parser method to handle +/- register.
731 def AM3OffsetAsmOperand : AsmOperandClass {
732 let Name = "AM3Offset";
733 let ParserMethod = "parseAM3Offset";
735 def am3offset : Operand<i32>,
736 ComplexPattern<i32, 2, "SelectAddrMode3Offset",
737 [], [SDNPWantRoot]> {
738 let EncoderMethod = "getAddrMode3OffsetOpValue";
739 let PrintMethod = "printAddrMode3OffsetOperand";
740 let ParserMatchClass = AM3OffsetAsmOperand;
741 let MIOperandInfo = (ops GPR, i32imm);
744 // ldstm_mode := {ia, ib, da, db}
746 def ldstm_mode : OptionalDefOperand<OtherVT, (ops i32), (ops (i32 1))> {
747 let EncoderMethod = "getLdStmModeOpValue";
748 let PrintMethod = "printLdStmModeOperand";
751 // addrmode5 := reg +/- imm8*4
753 def AddrMode5AsmOperand : AsmOperandClass { let Name = "AddrMode5"; }
754 def addrmode5 : Operand<i32>,
755 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
756 let PrintMethod = "printAddrMode5Operand";
757 let EncoderMethod = "getAddrMode5OpValue";
758 let DecoderMethod = "DecodeAddrMode5Operand";
759 let ParserMatchClass = AddrMode5AsmOperand;
760 let MIOperandInfo = (ops GPR:$base, i32imm);
763 // addrmode6 := reg with optional alignment
765 def addrmode6 : Operand<i32>,
766 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
767 let PrintMethod = "printAddrMode6Operand";
768 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
769 let EncoderMethod = "getAddrMode6AddressOpValue";
770 let DecoderMethod = "DecodeAddrMode6Operand";
773 def am6offset : Operand<i32>,
774 ComplexPattern<i32, 1, "SelectAddrMode6Offset",
775 [], [SDNPWantRoot]> {
776 let PrintMethod = "printAddrMode6OffsetOperand";
777 let MIOperandInfo = (ops GPR);
778 let EncoderMethod = "getAddrMode6OffsetOpValue";
779 let DecoderMethod = "DecodeGPRRegisterClass";
782 // Special version of addrmode6 to handle alignment encoding for VST1/VLD1
783 // (single element from one lane) for size 32.
784 def addrmode6oneL32 : Operand<i32>,
785 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
786 let PrintMethod = "printAddrMode6Operand";
787 let MIOperandInfo = (ops GPR:$addr, i32imm);
788 let EncoderMethod = "getAddrMode6OneLane32AddressOpValue";
791 // Special version of addrmode6 to handle alignment encoding for VLD-dup
792 // instructions, specifically VLD4-dup.
793 def addrmode6dup : Operand<i32>,
794 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
795 let PrintMethod = "printAddrMode6Operand";
796 let MIOperandInfo = (ops GPR:$addr, i32imm);
797 let EncoderMethod = "getAddrMode6DupAddressOpValue";
800 // addrmodepc := pc + reg
802 def addrmodepc : Operand<i32>,
803 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
804 let PrintMethod = "printAddrModePCOperand";
805 let MIOperandInfo = (ops GPR, i32imm);
808 // addr_offset_none := reg
810 def MemNoOffsetAsmOperand : AsmOperandClass { let Name = "MemNoOffset"; }
811 def addr_offset_none : Operand<i32>,
812 ComplexPattern<i32, 1, "SelectAddrOffsetNone", []> {
813 let PrintMethod = "printAddrMode7Operand";
814 let DecoderMethod = "DecodeAddrMode7Operand";
815 let ParserMatchClass = MemNoOffsetAsmOperand;
816 let MIOperandInfo = (ops GPR:$base);
819 def nohash_imm : Operand<i32> {
820 let PrintMethod = "printNoHashImmediate";
823 def CoprocNumAsmOperand : AsmOperandClass {
824 let Name = "CoprocNum";
825 let ParserMethod = "parseCoprocNumOperand";
827 def p_imm : Operand<i32> {
828 let PrintMethod = "printPImmediate";
829 let ParserMatchClass = CoprocNumAsmOperand;
830 let DecoderMethod = "DecodeCoprocessor";
833 def CoprocRegAsmOperand : AsmOperandClass {
834 let Name = "CoprocReg";
835 let ParserMethod = "parseCoprocRegOperand";
837 def c_imm : Operand<i32> {
838 let PrintMethod = "printCImmediate";
839 let ParserMatchClass = CoprocRegAsmOperand;
842 //===----------------------------------------------------------------------===//
844 include "ARMInstrFormats.td"
846 //===----------------------------------------------------------------------===//
847 // Multiclass helpers...
850 /// AsI1_bin_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns for a
851 /// binop that produces a value.
852 multiclass AsI1_bin_irs<bits<4> opcod, string opc,
853 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
854 PatFrag opnode, string baseOpc, bit Commutable = 0> {
855 // The register-immediate version is re-materializable. This is useful
856 // in particular for taking the address of a local.
857 let isReMaterializable = 1 in {
858 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
859 iii, opc, "\t$Rd, $Rn, $imm",
860 [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]> {
865 let Inst{19-16} = Rn;
866 let Inst{15-12} = Rd;
867 let Inst{11-0} = imm;
870 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
871 iir, opc, "\t$Rd, $Rn, $Rm",
872 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]> {
877 let isCommutable = Commutable;
878 let Inst{19-16} = Rn;
879 let Inst{15-12} = Rd;
880 let Inst{11-4} = 0b00000000;
884 def rsi : AsI1<opcod, (outs GPR:$Rd),
885 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
886 iis, opc, "\t$Rd, $Rn, $shift",
887 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_imm:$shift))]> {
892 let Inst{19-16} = Rn;
893 let Inst{15-12} = Rd;
894 let Inst{11-5} = shift{11-5};
896 let Inst{3-0} = shift{3-0};
899 def rsr : AsI1<opcod, (outs GPR:$Rd),
900 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
901 iis, opc, "\t$Rd, $Rn, $shift",
902 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_reg:$shift))]> {
907 let Inst{19-16} = Rn;
908 let Inst{15-12} = Rd;
909 let Inst{11-8} = shift{11-8};
911 let Inst{6-5} = shift{6-5};
913 let Inst{3-0} = shift{3-0};
916 // Assembly aliases for optional destination operand when it's the same
917 // as the source operand.
918 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $imm"),
919 (!cast<Instruction>(!strconcat(baseOpc, "ri")) GPR:$Rdn, GPR:$Rdn,
920 so_imm:$imm, pred:$p,
923 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $Rm"),
924 (!cast<Instruction>(!strconcat(baseOpc, "rr")) GPR:$Rdn, GPR:$Rdn,
928 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
929 (!cast<Instruction>(!strconcat(baseOpc, "rsi")) GPR:$Rdn, GPR:$Rdn,
930 so_reg_imm:$shift, pred:$p,
933 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
934 (!cast<Instruction>(!strconcat(baseOpc, "rsr")) GPR:$Rdn, GPR:$Rdn,
935 so_reg_reg:$shift, pred:$p,
941 /// AsI1_rbin_irs - Same as AsI1_bin_irs except the order of operands are
942 /// reversed. The 'rr' form is only defined for the disassembler; for codegen
943 /// it is equivalent to the AsI1_bin_irs counterpart.
944 multiclass AsI1_rbin_irs<bits<4> opcod, string opc,
945 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
946 PatFrag opnode, string baseOpc, bit Commutable = 0> {
947 // The register-immediate version is re-materializable. This is useful
948 // in particular for taking the address of a local.
949 let isReMaterializable = 1 in {
950 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
951 iii, opc, "\t$Rd, $Rn, $imm",
952 [(set GPR:$Rd, (opnode so_imm:$imm, GPR:$Rn))]> {
957 let Inst{19-16} = Rn;
958 let Inst{15-12} = Rd;
959 let Inst{11-0} = imm;
962 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
963 iir, opc, "\t$Rd, $Rn, $Rm",
964 [/* pattern left blank */]> {
968 let Inst{11-4} = 0b00000000;
971 let Inst{15-12} = Rd;
972 let Inst{19-16} = Rn;
975 def rsi : AsI1<opcod, (outs GPR:$Rd),
976 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
977 iis, opc, "\t$Rd, $Rn, $shift",
978 [(set GPR:$Rd, (opnode so_reg_imm:$shift, GPR:$Rn))]> {
983 let Inst{19-16} = Rn;
984 let Inst{15-12} = Rd;
985 let Inst{11-5} = shift{11-5};
987 let Inst{3-0} = shift{3-0};
990 def rsr : AsI1<opcod, (outs GPR:$Rd),
991 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
992 iis, opc, "\t$Rd, $Rn, $shift",
993 [(set GPR:$Rd, (opnode so_reg_reg:$shift, GPR:$Rn))]> {
998 let Inst{19-16} = Rn;
999 let Inst{15-12} = Rd;
1000 let Inst{11-8} = shift{11-8};
1002 let Inst{6-5} = shift{6-5};
1004 let Inst{3-0} = shift{3-0};
1007 // Assembly aliases for optional destination operand when it's the same
1008 // as the source operand.
1009 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $imm"),
1010 (!cast<Instruction>(!strconcat(baseOpc, "ri")) GPR:$Rdn, GPR:$Rdn,
1011 so_imm:$imm, pred:$p,
1014 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $Rm"),
1015 (!cast<Instruction>(!strconcat(baseOpc, "rr")) GPR:$Rdn, GPR:$Rdn,
1019 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1020 (!cast<Instruction>(!strconcat(baseOpc, "rsi")) GPR:$Rdn, GPR:$Rdn,
1021 so_reg_imm:$shift, pred:$p,
1024 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1025 (!cast<Instruction>(!strconcat(baseOpc, "rsr")) GPR:$Rdn, GPR:$Rdn,
1026 so_reg_reg:$shift, pred:$p,
1032 /// AsI1_rbin_s_is - Same as AsI1_rbin_s_is except it sets 's' bit by default.
1034 /// These opcodes will be converted to the real non-S opcodes by
1035 /// AdjustInstrPostInstrSelection after giving then an optional CPSR operand.
1036 let hasPostISelHook = 1, isCodeGenOnly = 1, isPseudo = 1, Defs = [CPSR] in {
1037 multiclass AsI1_rbin_s_is<bits<4> opcod, string opc,
1038 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1039 PatFrag opnode, bit Commutable = 0> {
1040 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
1041 iii, opc, "\t$Rd, $Rn, $imm",
1042 [(set GPR:$Rd, CPSR, (opnode so_imm:$imm, GPR:$Rn))]>;
1044 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1045 iir, opc, "\t$Rd, $Rn, $Rm",
1046 [/* pattern left blank */]>;
1048 def rsi : AsI1<opcod, (outs GPR:$Rd),
1049 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1050 iis, opc, "\t$Rd, $Rn, $shift",
1051 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift, GPR:$Rn))]>;
1053 def rsr : AsI1<opcod, (outs GPR:$Rd),
1054 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1055 iis, opc, "\t$Rd, $Rn, $shift",
1056 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift, GPR:$Rn))]> {
1061 let Inst{19-16} = Rn;
1062 let Inst{15-12} = Rd;
1063 let Inst{11-8} = shift{11-8};
1065 let Inst{6-5} = shift{6-5};
1067 let Inst{3-0} = shift{3-0};
1072 /// AsI1_bin_s_irs - Same as AsI1_bin_irs except it sets the 's' bit by default.
1074 /// These opcodes will be converted to the real non-S opcodes by
1075 /// AdjustInstrPostInstrSelection after giving then an optional CPSR operand.
1076 let hasPostISelHook = 1, isCodeGenOnly = 1, isPseudo = 1, Defs = [CPSR] in {
1077 multiclass AsI1_bin_s_irs<bits<4> opcod, string opc,
1078 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1079 PatFrag opnode, bit Commutable = 0> {
1080 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
1081 iii, opc, "\t$Rd, $Rn, $imm",
1082 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_imm:$imm))]>;
1083 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1084 iir, opc, "\t$Rd, $Rn, $Rm",
1085 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm))]>;
1086 def rsi : AsI1<opcod, (outs GPR:$Rd),
1087 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1088 iis, opc, "\t$Rd, $Rn, $shift",
1089 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_imm:$shift))]>;
1091 def rsr : AsI1<opcod, (outs GPR:$Rd),
1092 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1093 iis, opc, "\t$Rd, $Rn, $shift",
1094 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_reg:$shift))]>;
1098 /// AI1_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
1099 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
1100 /// a explicit result, only implicitly set CPSR.
1101 let isCompare = 1, Defs = [CPSR] in {
1102 multiclass AI1_cmp_irs<bits<4> opcod, string opc,
1103 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1104 PatFrag opnode, bit Commutable = 0> {
1105 def ri : AI1<opcod, (outs), (ins GPR:$Rn, so_imm:$imm), DPFrm, iii,
1107 [(opnode GPR:$Rn, so_imm:$imm)]> {
1112 let Inst{19-16} = Rn;
1113 let Inst{15-12} = 0b0000;
1114 let Inst{11-0} = imm;
1116 def rr : AI1<opcod, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, iir,
1118 [(opnode GPR:$Rn, GPR:$Rm)]> {
1121 let isCommutable = Commutable;
1124 let Inst{19-16} = Rn;
1125 let Inst{15-12} = 0b0000;
1126 let Inst{11-4} = 0b00000000;
1129 def rsi : AI1<opcod, (outs),
1130 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, iis,
1131 opc, "\t$Rn, $shift",
1132 [(opnode GPR:$Rn, so_reg_imm:$shift)]> {
1137 let Inst{19-16} = Rn;
1138 let Inst{15-12} = 0b0000;
1139 let Inst{11-5} = shift{11-5};
1141 let Inst{3-0} = shift{3-0};
1143 def rsr : AI1<opcod, (outs),
1144 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, iis,
1145 opc, "\t$Rn, $shift",
1146 [(opnode GPR:$Rn, so_reg_reg:$shift)]> {
1151 let Inst{19-16} = Rn;
1152 let Inst{15-12} = 0b0000;
1153 let Inst{11-8} = shift{11-8};
1155 let Inst{6-5} = shift{6-5};
1157 let Inst{3-0} = shift{3-0};
1163 /// AI_ext_rrot - A unary operation with two forms: one whose operand is a
1164 /// register and one whose operand is a register rotated by 8/16/24.
1165 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
1166 class AI_ext_rrot<bits<8> opcod, string opc, PatFrag opnode>
1167 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1168 IIC_iEXTr, opc, "\t$Rd, $Rm$rot",
1169 [(set GPRnopc:$Rd, (opnode (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1170 Requires<[IsARM, HasV6]> {
1174 let Inst{19-16} = 0b1111;
1175 let Inst{15-12} = Rd;
1176 let Inst{11-10} = rot;
1180 class AI_ext_rrot_np<bits<8> opcod, string opc>
1181 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1182 IIC_iEXTr, opc, "\t$Rd, $Rm$rot", []>,
1183 Requires<[IsARM, HasV6]> {
1185 let Inst{19-16} = 0b1111;
1186 let Inst{11-10} = rot;
1189 /// AI_exta_rrot - A binary operation with two forms: one whose operand is a
1190 /// register and one whose operand is a register rotated by 8/16/24.
1191 class AI_exta_rrot<bits<8> opcod, string opc, PatFrag opnode>
1192 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1193 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot",
1194 [(set GPRnopc:$Rd, (opnode GPR:$Rn,
1195 (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1196 Requires<[IsARM, HasV6]> {
1201 let Inst{19-16} = Rn;
1202 let Inst{15-12} = Rd;
1203 let Inst{11-10} = rot;
1204 let Inst{9-4} = 0b000111;
1208 class AI_exta_rrot_np<bits<8> opcod, string opc>
1209 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1210 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot", []>,
1211 Requires<[IsARM, HasV6]> {
1214 let Inst{19-16} = Rn;
1215 let Inst{11-10} = rot;
1218 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
1219 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
1220 string baseOpc, bit Commutable = 0> {
1221 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1222 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
1223 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1224 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_imm:$imm, CPSR))]>,
1230 let Inst{15-12} = Rd;
1231 let Inst{19-16} = Rn;
1232 let Inst{11-0} = imm;
1234 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1235 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1236 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm, CPSR))]>,
1241 let Inst{11-4} = 0b00000000;
1243 let isCommutable = Commutable;
1245 let Inst{15-12} = Rd;
1246 let Inst{19-16} = Rn;
1248 def rsi : AsI1<opcod, (outs GPR:$Rd),
1249 (ins GPR:$Rn, so_reg_imm:$shift),
1250 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1251 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_imm:$shift, CPSR))]>,
1257 let Inst{19-16} = Rn;
1258 let Inst{15-12} = Rd;
1259 let Inst{11-5} = shift{11-5};
1261 let Inst{3-0} = shift{3-0};
1263 def rsr : AsI1<opcod, (outs GPR:$Rd),
1264 (ins GPR:$Rn, so_reg_reg:$shift),
1265 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1266 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_reg:$shift, CPSR))]>,
1272 let Inst{19-16} = Rn;
1273 let Inst{15-12} = Rd;
1274 let Inst{11-8} = shift{11-8};
1276 let Inst{6-5} = shift{6-5};
1278 let Inst{3-0} = shift{3-0};
1282 // Assembly aliases for optional destination operand when it's the same
1283 // as the source operand.
1284 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $imm"),
1285 (!cast<Instruction>(!strconcat(baseOpc, "ri")) GPR:$Rdn, GPR:$Rdn,
1286 so_imm:$imm, pred:$p,
1289 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $Rm"),
1290 (!cast<Instruction>(!strconcat(baseOpc, "rr")) GPR:$Rdn, GPR:$Rdn,
1294 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1295 (!cast<Instruction>(!strconcat(baseOpc, "rsi")) GPR:$Rdn, GPR:$Rdn,
1296 so_reg_imm:$shift, pred:$p,
1299 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1300 (!cast<Instruction>(!strconcat(baseOpc, "rsr")) GPR:$Rdn, GPR:$Rdn,
1301 so_reg_reg:$shift, pred:$p,
1306 /// AI1_rsc_irs - Define instructions and patterns for rsc
1307 multiclass AI1_rsc_irs<bits<4> opcod, string opc, PatFrag opnode,
1309 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1310 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
1311 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1312 [(set GPR:$Rd, CPSR, (opnode so_imm:$imm, GPR:$Rn, CPSR))]>,
1318 let Inst{15-12} = Rd;
1319 let Inst{19-16} = Rn;
1320 let Inst{11-0} = imm;
1322 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1323 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1324 [/* pattern left blank */]> {
1328 let Inst{11-4} = 0b00000000;
1331 let Inst{15-12} = Rd;
1332 let Inst{19-16} = Rn;
1334 def rsi : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_imm:$shift),
1335 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1336 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift, GPR:$Rn, CPSR))]>,
1342 let Inst{19-16} = Rn;
1343 let Inst{15-12} = Rd;
1344 let Inst{11-5} = shift{11-5};
1346 let Inst{3-0} = shift{3-0};
1348 def rsr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_reg:$shift),
1349 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1350 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift, GPR:$Rn, CPSR))]>,
1356 let Inst{19-16} = Rn;
1357 let Inst{15-12} = Rd;
1358 let Inst{11-8} = shift{11-8};
1360 let Inst{6-5} = shift{6-5};
1362 let Inst{3-0} = shift{3-0};
1366 // Assembly aliases for optional destination operand when it's the same
1367 // as the source operand.
1368 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $imm"),
1369 (!cast<Instruction>(!strconcat(baseOpc, "ri")) GPR:$Rdn, GPR:$Rdn,
1370 so_imm:$imm, pred:$p,
1373 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $Rm"),
1374 (!cast<Instruction>(!strconcat(baseOpc, "rr")) GPR:$Rdn, GPR:$Rdn,
1378 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1379 (!cast<Instruction>(!strconcat(baseOpc, "rsi")) GPR:$Rdn, GPR:$Rdn,
1380 so_reg_imm:$shift, pred:$p,
1383 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1384 (!cast<Instruction>(!strconcat(baseOpc, "rsr")) GPR:$Rdn, GPR:$Rdn,
1385 so_reg_reg:$shift, pred:$p,
1390 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1391 multiclass AI_ldr1<bit isByte, string opc, InstrItinClass iii,
1392 InstrItinClass iir, PatFrag opnode> {
1393 // Note: We use the complex addrmode_imm12 rather than just an input
1394 // GPR and a constrained immediate so that we can use this to match
1395 // frame index references and avoid matching constant pool references.
1396 def i12: AI2ldst<0b010, 1, isByte, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
1397 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1398 [(set GPR:$Rt, (opnode addrmode_imm12:$addr))]> {
1401 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1402 let Inst{19-16} = addr{16-13}; // Rn
1403 let Inst{15-12} = Rt;
1404 let Inst{11-0} = addr{11-0}; // imm12
1406 def rs : AI2ldst<0b011, 1, isByte, (outs GPR:$Rt), (ins ldst_so_reg:$shift),
1407 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1408 [(set GPR:$Rt, (opnode ldst_so_reg:$shift))]> {
1411 let shift{4} = 0; // Inst{4} = 0
1412 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1413 let Inst{19-16} = shift{16-13}; // Rn
1414 let Inst{15-12} = Rt;
1415 let Inst{11-0} = shift{11-0};
1420 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1421 multiclass AI_ldr1nopc<bit isByte, string opc, InstrItinClass iii,
1422 InstrItinClass iir, PatFrag opnode> {
1423 // Note: We use the complex addrmode_imm12 rather than just an input
1424 // GPR and a constrained immediate so that we can use this to match
1425 // frame index references and avoid matching constant pool references.
1426 def i12: AI2ldst<0b010, 1, isByte, (outs GPRnopc:$Rt), (ins addrmode_imm12:$addr),
1427 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1428 [(set GPRnopc:$Rt, (opnode addrmode_imm12:$addr))]> {
1431 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1432 let Inst{19-16} = addr{16-13}; // Rn
1433 let Inst{15-12} = Rt;
1434 let Inst{11-0} = addr{11-0}; // imm12
1436 def rs : AI2ldst<0b011, 1, isByte, (outs GPRnopc:$Rt), (ins ldst_so_reg:$shift),
1437 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1438 [(set GPRnopc:$Rt, (opnode ldst_so_reg:$shift))]> {
1441 let shift{4} = 0; // Inst{4} = 0
1442 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1443 let Inst{19-16} = shift{16-13}; // Rn
1444 let Inst{15-12} = Rt;
1445 let Inst{11-0} = shift{11-0};
1451 multiclass AI_str1<bit isByte, string opc, InstrItinClass iii,
1452 InstrItinClass iir, PatFrag opnode> {
1453 // Note: We use the complex addrmode_imm12 rather than just an input
1454 // GPR and a constrained immediate so that we can use this to match
1455 // frame index references and avoid matching constant pool references.
1456 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1457 (ins GPR:$Rt, addrmode_imm12:$addr),
1458 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1459 [(opnode GPR:$Rt, addrmode_imm12:$addr)]> {
1462 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1463 let Inst{19-16} = addr{16-13}; // Rn
1464 let Inst{15-12} = Rt;
1465 let Inst{11-0} = addr{11-0}; // imm12
1467 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPR:$Rt, ldst_so_reg:$shift),
1468 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1469 [(opnode GPR:$Rt, ldst_so_reg:$shift)]> {
1472 let shift{4} = 0; // Inst{4} = 0
1473 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1474 let Inst{19-16} = shift{16-13}; // Rn
1475 let Inst{15-12} = Rt;
1476 let Inst{11-0} = shift{11-0};
1480 multiclass AI_str1nopc<bit isByte, string opc, InstrItinClass iii,
1481 InstrItinClass iir, PatFrag opnode> {
1482 // Note: We use the complex addrmode_imm12 rather than just an input
1483 // GPR and a constrained immediate so that we can use this to match
1484 // frame index references and avoid matching constant pool references.
1485 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1486 (ins GPRnopc:$Rt, addrmode_imm12:$addr),
1487 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1488 [(opnode GPRnopc:$Rt, addrmode_imm12:$addr)]> {
1491 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1492 let Inst{19-16} = addr{16-13}; // Rn
1493 let Inst{15-12} = Rt;
1494 let Inst{11-0} = addr{11-0}; // imm12
1496 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPRnopc:$Rt, ldst_so_reg:$shift),
1497 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1498 [(opnode GPRnopc:$Rt, ldst_so_reg:$shift)]> {
1501 let shift{4} = 0; // Inst{4} = 0
1502 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1503 let Inst{19-16} = shift{16-13}; // Rn
1504 let Inst{15-12} = Rt;
1505 let Inst{11-0} = shift{11-0};
1510 //===----------------------------------------------------------------------===//
1512 //===----------------------------------------------------------------------===//
1514 //===----------------------------------------------------------------------===//
1515 // Miscellaneous Instructions.
1518 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
1519 /// the function. The first operand is the ID# for this instruction, the second
1520 /// is the index into the MachineConstantPool that this is, the third is the
1521 /// size in bytes of this constant pool entry.
1522 let neverHasSideEffects = 1, isNotDuplicable = 1 in
1523 def CONSTPOOL_ENTRY :
1524 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1525 i32imm:$size), NoItinerary, []>;
1527 // FIXME: Marking these as hasSideEffects is necessary to prevent machine DCE
1528 // from removing one half of the matched pairs. That breaks PEI, which assumes
1529 // these will always be in pairs, and asserts if it finds otherwise. Better way?
1530 let Defs = [SP], Uses = [SP], hasSideEffects = 1 in {
1531 def ADJCALLSTACKUP :
1532 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary,
1533 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
1535 def ADJCALLSTACKDOWN :
1536 PseudoInst<(outs), (ins i32imm:$amt, pred:$p), NoItinerary,
1537 [(ARMcallseq_start timm:$amt)]>;
1540 // Atomic pseudo-insts which will be lowered to ldrexd/strexd loops.
1541 // (These psuedos use a hand-written selection code).
1542 let usesCustomInserter = 1, Defs = [CPSR], mayLoad = 1, mayStore = 1 in {
1543 def ATOMOR6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1544 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1546 def ATOMXOR6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1547 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1549 def ATOMADD6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1550 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1552 def ATOMSUB6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1553 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1555 def ATOMNAND6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1556 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1558 def ATOMAND6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1559 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1561 def ATOMSWAP6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1562 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1564 def ATOMCMPXCHG6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1565 (ins GPR:$addr, GPR:$cmp1, GPR:$cmp2,
1566 GPR:$set1, GPR:$set2),
1570 def NOP : AI<(outs), (ins), MiscFrm, NoItinerary, "nop", "", []>,
1571 Requires<[IsARM, HasV6T2]> {
1572 let Inst{27-16} = 0b001100100000;
1573 let Inst{15-8} = 0b11110000;
1574 let Inst{7-0} = 0b00000000;
1577 def YIELD : AI<(outs), (ins), MiscFrm, NoItinerary, "yield", "", []>,
1578 Requires<[IsARM, HasV6T2]> {
1579 let Inst{27-16} = 0b001100100000;
1580 let Inst{15-8} = 0b11110000;
1581 let Inst{7-0} = 0b00000001;
1584 def WFE : AI<(outs), (ins), MiscFrm, NoItinerary, "wfe", "", []>,
1585 Requires<[IsARM, HasV6T2]> {
1586 let Inst{27-16} = 0b001100100000;
1587 let Inst{15-8} = 0b11110000;
1588 let Inst{7-0} = 0b00000010;
1591 def WFI : AI<(outs), (ins), MiscFrm, NoItinerary, "wfi", "", []>,
1592 Requires<[IsARM, HasV6T2]> {
1593 let Inst{27-16} = 0b001100100000;
1594 let Inst{15-8} = 0b11110000;
1595 let Inst{7-0} = 0b00000011;
1598 def SEL : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, NoItinerary, "sel",
1599 "\t$Rd, $Rn, $Rm", []>, Requires<[IsARM, HasV6]> {
1604 let Inst{15-12} = Rd;
1605 let Inst{19-16} = Rn;
1606 let Inst{27-20} = 0b01101000;
1607 let Inst{7-4} = 0b1011;
1608 let Inst{11-8} = 0b1111;
1611 def SEV : AI<(outs), (ins), MiscFrm, NoItinerary, "sev", "",
1612 []>, Requires<[IsARM, HasV6T2]> {
1613 let Inst{27-16} = 0b001100100000;
1614 let Inst{15-8} = 0b11110000;
1615 let Inst{7-0} = 0b00000100;
1618 // The i32imm operand $val can be used by a debugger to store more information
1619 // about the breakpoint.
1620 def BKPT : AI<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
1621 "bkpt", "\t$val", []>, Requires<[IsARM]> {
1623 let Inst{3-0} = val{3-0};
1624 let Inst{19-8} = val{15-4};
1625 let Inst{27-20} = 0b00010010;
1626 let Inst{7-4} = 0b0111;
1629 // Change Processor State
1630 // FIXME: We should use InstAlias to handle the optional operands.
1631 class CPS<dag iops, string asm_ops>
1632 : AXI<(outs), iops, MiscFrm, NoItinerary, !strconcat("cps", asm_ops),
1633 []>, Requires<[IsARM]> {
1639 let Inst{31-28} = 0b1111;
1640 let Inst{27-20} = 0b00010000;
1641 let Inst{19-18} = imod;
1642 let Inst{17} = M; // Enabled if mode is set;
1644 let Inst{8-6} = iflags;
1646 let Inst{4-0} = mode;
1649 let DecoderMethod = "DecodeCPSInstruction" in {
1651 def CPS3p : CPS<(ins imod_op:$imod, iflags_op:$iflags, imm0_31:$mode),
1652 "$imod\t$iflags, $mode">;
1653 let mode = 0, M = 0 in
1654 def CPS2p : CPS<(ins imod_op:$imod, iflags_op:$iflags), "$imod\t$iflags">;
1656 let imod = 0, iflags = 0, M = 1 in
1657 def CPS1p : CPS<(ins imm0_31:$mode), "\t$mode">;
1660 // Preload signals the memory system of possible future data/instruction access.
1661 multiclass APreLoad<bits<1> read, bits<1> data, string opc> {
1663 def i12 : AXI<(outs), (ins addrmode_imm12:$addr), MiscFrm, IIC_Preload,
1664 !strconcat(opc, "\t$addr"),
1665 [(ARMPreload addrmode_imm12:$addr, (i32 read), (i32 data))]> {
1668 let Inst{31-26} = 0b111101;
1669 let Inst{25} = 0; // 0 for immediate form
1670 let Inst{24} = data;
1671 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1672 let Inst{22} = read;
1673 let Inst{21-20} = 0b01;
1674 let Inst{19-16} = addr{16-13}; // Rn
1675 let Inst{15-12} = 0b1111;
1676 let Inst{11-0} = addr{11-0}; // imm12
1679 def rs : AXI<(outs), (ins ldst_so_reg:$shift), MiscFrm, IIC_Preload,
1680 !strconcat(opc, "\t$shift"),
1681 [(ARMPreload ldst_so_reg:$shift, (i32 read), (i32 data))]> {
1683 let Inst{31-26} = 0b111101;
1684 let Inst{25} = 1; // 1 for register form
1685 let Inst{24} = data;
1686 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1687 let Inst{22} = read;
1688 let Inst{21-20} = 0b01;
1689 let Inst{19-16} = shift{16-13}; // Rn
1690 let Inst{15-12} = 0b1111;
1691 let Inst{11-0} = shift{11-0};
1696 defm PLD : APreLoad<1, 1, "pld">, Requires<[IsARM]>;
1697 defm PLDW : APreLoad<0, 1, "pldw">, Requires<[IsARM,HasV7,HasMP]>;
1698 defm PLI : APreLoad<1, 0, "pli">, Requires<[IsARM,HasV7]>;
1700 def SETEND : AXI<(outs), (ins setend_op:$end), MiscFrm, NoItinerary,
1701 "setend\t$end", []>, Requires<[IsARM]> {
1703 let Inst{31-10} = 0b1111000100000001000000;
1708 def DBG : AI<(outs), (ins imm0_15:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt",
1709 []>, Requires<[IsARM, HasV7]> {
1711 let Inst{27-4} = 0b001100100000111100001111;
1712 let Inst{3-0} = opt;
1715 // A5.4 Permanently UNDEFINED instructions.
1716 let isBarrier = 1, isTerminator = 1 in
1717 def TRAP : AXI<(outs), (ins), MiscFrm, NoItinerary,
1720 let Inst = 0xe7ffdefe;
1723 // Address computation and loads and stores in PIC mode.
1724 let isNotDuplicable = 1 in {
1725 def PICADD : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
1727 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>;
1729 let AddedComplexity = 10 in {
1730 def PICLDR : ARMPseudoInst<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
1732 [(set GPR:$dst, (load addrmodepc:$addr))]>;
1734 def PICLDRH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1736 [(set GPR:$Rt, (zextloadi16 addrmodepc:$addr))]>;
1738 def PICLDRB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1740 [(set GPR:$Rt, (zextloadi8 addrmodepc:$addr))]>;
1742 def PICLDRSH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1744 [(set GPR:$Rt, (sextloadi16 addrmodepc:$addr))]>;
1746 def PICLDRSB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1748 [(set GPR:$Rt, (sextloadi8 addrmodepc:$addr))]>;
1750 let AddedComplexity = 10 in {
1751 def PICSTR : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1752 4, IIC_iStore_r, [(store GPR:$src, addrmodepc:$addr)]>;
1754 def PICSTRH : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1755 4, IIC_iStore_bh_r, [(truncstorei16 GPR:$src,
1756 addrmodepc:$addr)]>;
1758 def PICSTRB : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1759 4, IIC_iStore_bh_r, [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
1761 } // isNotDuplicable = 1
1764 // LEApcrel - Load a pc-relative address into a register without offending the
1766 let neverHasSideEffects = 1, isReMaterializable = 1 in
1767 // The 'adr' mnemonic encodes differently if the label is before or after
1768 // the instruction. The {24-21} opcode bits are set by the fixup, as we don't
1769 // know until then which form of the instruction will be used.
1770 def ADR : AI1<{0,?,?,0}, (outs GPR:$Rd), (ins adrlabel:$label),
1771 MiscFrm, IIC_iALUi, "adr", "\t$Rd, $label", []> {
1774 let Inst{27-25} = 0b001;
1776 let Inst{23-22} = label{13-12};
1779 let Inst{19-16} = 0b1111;
1780 let Inst{15-12} = Rd;
1781 let Inst{11-0} = label{11-0};
1783 def LEApcrel : ARMPseudoInst<(outs GPR:$Rd), (ins i32imm:$label, pred:$p),
1786 def LEApcrelJT : ARMPseudoInst<(outs GPR:$Rd),
1787 (ins i32imm:$label, nohash_imm:$id, pred:$p),
1790 //===----------------------------------------------------------------------===//
1791 // Control Flow Instructions.
1794 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
1796 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
1797 "bx", "\tlr", [(ARMretflag)]>,
1798 Requires<[IsARM, HasV4T]> {
1799 let Inst{27-0} = 0b0001001011111111111100011110;
1803 def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br,
1804 "mov", "\tpc, lr", [(ARMretflag)]>,
1805 Requires<[IsARM, NoV4T]> {
1806 let Inst{27-0} = 0b0001101000001111000000001110;
1810 // Indirect branches
1811 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
1813 def BX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
1814 [(brind GPR:$dst)]>,
1815 Requires<[IsARM, HasV4T]> {
1817 let Inst{31-4} = 0b1110000100101111111111110001;
1818 let Inst{3-0} = dst;
1821 def BX_pred : AI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br,
1822 "bx", "\t$dst", [/* pattern left blank */]>,
1823 Requires<[IsARM, HasV4T]> {
1825 let Inst{27-4} = 0b000100101111111111110001;
1826 let Inst{3-0} = dst;
1830 // All calls clobber the non-callee saved registers. SP is marked as
1831 // a use to prevent stack-pointer assignments that appear immediately
1832 // before calls from potentially appearing dead.
1834 // On non-Darwin platforms R9 is callee-saved.
1835 // FIXME: Do we really need a non-predicated version? If so, it should
1836 // at least be a pseudo instruction expanding to the predicated version
1837 // at MC lowering time.
1838 Defs = [R0, R1, R2, R3, R12, LR, QQQQ0, QQQQ2, QQQQ3, CPSR, FPSCR],
1840 def BL : ABXI<0b1011, (outs), (ins bl_target:$func, variable_ops),
1841 IIC_Br, "bl\t$func",
1842 [(ARMcall tglobaladdr:$func)]>,
1843 Requires<[IsARM, IsNotDarwin]> {
1844 let Inst{31-28} = 0b1110;
1846 let Inst{23-0} = func;
1847 let DecoderMethod = "DecodeBranchImmInstruction";
1850 def BL_pred : ABI<0b1011, (outs), (ins bl_target:$func, variable_ops),
1851 IIC_Br, "bl", "\t$func",
1852 [(ARMcall_pred tglobaladdr:$func)]>,
1853 Requires<[IsARM, IsNotDarwin]> {
1855 let Inst{23-0} = func;
1856 let DecoderMethod = "DecodeBranchImmInstruction";
1860 def BLX : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
1861 IIC_Br, "blx\t$func",
1862 [(ARMcall GPR:$func)]>,
1863 Requires<[IsARM, HasV5T, IsNotDarwin]> {
1865 let Inst{31-4} = 0b1110000100101111111111110011;
1866 let Inst{3-0} = func;
1869 def BLX_pred : AI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
1870 IIC_Br, "blx", "\t$func",
1871 [(ARMcall_pred GPR:$func)]>,
1872 Requires<[IsARM, HasV5T, IsNotDarwin]> {
1874 let Inst{27-4} = 0b000100101111111111110011;
1875 let Inst{3-0} = func;
1879 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
1880 def BX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func, variable_ops),
1881 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
1882 Requires<[IsARM, HasV4T, IsNotDarwin]>;
1885 def BMOVPCRX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func, variable_ops),
1886 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
1887 Requires<[IsARM, NoV4T, IsNotDarwin]>;
1891 // On Darwin R9 is call-clobbered.
1892 // R7 is marked as a use to prevent frame-pointer assignments from being
1893 // moved above / below calls.
1894 Defs = [R0, R1, R2, R3, R9, R12, LR, QQQQ0, QQQQ2, QQQQ3, CPSR, FPSCR],
1895 Uses = [R7, SP] in {
1896 def BLr9 : ARMPseudoExpand<(outs), (ins bl_target:$func, variable_ops),
1898 [(ARMcall tglobaladdr:$func)], (BL bl_target:$func)>,
1899 Requires<[IsARM, IsDarwin]>;
1901 def BLr9_pred : ARMPseudoExpand<(outs),
1902 (ins bl_target:$func, pred:$p, variable_ops),
1904 [(ARMcall_pred tglobaladdr:$func)],
1905 (BL_pred bl_target:$func, pred:$p)>,
1906 Requires<[IsARM, IsDarwin]>;
1909 def BLXr9 : ARMPseudoExpand<(outs), (ins GPR:$func, variable_ops),
1911 [(ARMcall GPR:$func)],
1913 Requires<[IsARM, HasV5T, IsDarwin]>;
1915 def BLXr9_pred: ARMPseudoExpand<(outs), (ins GPR:$func, pred:$p,variable_ops),
1917 [(ARMcall_pred GPR:$func)],
1918 (BLX_pred GPR:$func, pred:$p)>,
1919 Requires<[IsARM, HasV5T, IsDarwin]>;
1922 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
1923 def BXr9_CALL : ARMPseudoInst<(outs), (ins tGPR:$func, variable_ops),
1924 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
1925 Requires<[IsARM, HasV4T, IsDarwin]>;
1928 def BMOVPCRXr9_CALL : ARMPseudoInst<(outs), (ins tGPR:$func, variable_ops),
1929 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
1930 Requires<[IsARM, NoV4T, IsDarwin]>;
1933 let isBranch = 1, isTerminator = 1 in {
1934 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
1935 // a two-value operand where a dag node expects two operands. :(
1936 def Bcc : ABI<0b1010, (outs), (ins br_target:$target),
1937 IIC_Br, "b", "\t$target",
1938 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]> {
1940 let Inst{23-0} = target;
1941 let DecoderMethod = "DecodeBranchImmInstruction";
1944 let isBarrier = 1 in {
1945 // B is "predicable" since it's just a Bcc with an 'always' condition.
1946 let isPredicable = 1 in
1947 // FIXME: We shouldn't need this pseudo at all. Just using Bcc directly
1948 // should be sufficient.
1949 // FIXME: Is B really a Barrier? That doesn't seem right.
1950 def B : ARMPseudoExpand<(outs), (ins br_target:$target), 4, IIC_Br,
1951 [(br bb:$target)], (Bcc br_target:$target, (ops 14, zero_reg))>;
1953 let isNotDuplicable = 1, isIndirectBranch = 1 in {
1954 def BR_JTr : ARMPseudoInst<(outs),
1955 (ins GPR:$target, i32imm:$jt, i32imm:$id),
1957 [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]>;
1958 // FIXME: This shouldn't use the generic "addrmode2," but rather be split
1959 // into i12 and rs suffixed versions.
1960 def BR_JTm : ARMPseudoInst<(outs),
1961 (ins addrmode2:$target, i32imm:$jt, i32imm:$id),
1963 [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
1965 def BR_JTadd : ARMPseudoInst<(outs),
1966 (ins GPR:$target, GPR:$idx, i32imm:$jt, i32imm:$id),
1968 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
1970 } // isNotDuplicable = 1, isIndirectBranch = 1
1976 def BLXi : AXI<(outs), (ins blx_target:$target), BrMiscFrm, NoItinerary,
1977 "blx\t$target", []>,
1978 Requires<[IsARM, HasV5T]> {
1979 let Inst{31-25} = 0b1111101;
1981 let Inst{23-0} = target{24-1};
1982 let Inst{24} = target{0};
1985 // Branch and Exchange Jazelle
1986 def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func",
1987 [/* pattern left blank */]> {
1989 let Inst{23-20} = 0b0010;
1990 let Inst{19-8} = 0xfff;
1991 let Inst{7-4} = 0b0010;
1992 let Inst{3-0} = func;
1997 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in {
1999 let Defs = [R0, R1, R2, R3, R9, R12, QQQQ0, QQQQ2, QQQQ3, PC],
2001 def TCRETURNdi : PseudoInst<(outs), (ins i32imm:$dst, variable_ops),
2002 IIC_Br, []>, Requires<[IsDarwin]>;
2004 def TCRETURNri : PseudoInst<(outs), (ins tcGPR:$dst, variable_ops),
2005 IIC_Br, []>, Requires<[IsDarwin]>;
2007 def TAILJMPd : ARMPseudoExpand<(outs), (ins br_target:$dst, variable_ops),
2009 (Bcc br_target:$dst, (ops 14, zero_reg))>,
2010 Requires<[IsARM, IsDarwin]>;
2012 def TAILJMPr : ARMPseudoExpand<(outs), (ins tcGPR:$dst, variable_ops),
2015 Requires<[IsARM, IsDarwin]>;
2019 // Non-Darwin versions (the difference is R9).
2020 let Defs = [R0, R1, R2, R3, R12, QQQQ0, QQQQ2, QQQQ3, PC],
2022 def TCRETURNdiND : PseudoInst<(outs), (ins i32imm:$dst, variable_ops),
2023 IIC_Br, []>, Requires<[IsNotDarwin]>;
2025 def TCRETURNriND : PseudoInst<(outs), (ins tcGPR:$dst, variable_ops),
2026 IIC_Br, []>, Requires<[IsNotDarwin]>;
2028 def TAILJMPdND : ARMPseudoExpand<(outs), (ins brtarget:$dst, variable_ops),
2030 (Bcc br_target:$dst, (ops 14, zero_reg))>,
2031 Requires<[IsARM, IsNotDarwin]>;
2033 def TAILJMPrND : ARMPseudoExpand<(outs), (ins tcGPR:$dst, variable_ops),
2036 Requires<[IsARM, IsNotDarwin]>;
2040 // Secure Monitor Call is a system instruction.
2041 def SMC : ABI<0b0001, (outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt",
2044 let Inst{23-4} = 0b01100000000000000111;
2045 let Inst{3-0} = opt;
2048 // Supervisor Call (Software Interrupt)
2049 let isCall = 1, Uses = [SP] in {
2050 def SVC : ABI<0b1111, (outs), (ins imm24b:$svc), IIC_Br, "svc", "\t$svc", []> {
2052 let Inst{23-0} = svc;
2056 // Store Return State
2057 class SRSI<bit wb, string asm>
2058 : XI<(outs), (ins imm0_31:$mode), AddrModeNone, 4, IndexModeNone, BrFrm,
2059 NoItinerary, asm, "", []> {
2061 let Inst{31-28} = 0b1111;
2062 let Inst{27-25} = 0b100;
2066 let Inst{19-16} = 0b1101; // SP
2067 let Inst{15-5} = 0b00000101000;
2068 let Inst{4-0} = mode;
2071 def SRSDA : SRSI<0, "srsda\tsp, $mode"> {
2072 let Inst{24-23} = 0;
2074 def SRSDA_UPD : SRSI<1, "srsda\tsp!, $mode"> {
2075 let Inst{24-23} = 0;
2077 def SRSDB : SRSI<0, "srsdb\tsp, $mode"> {
2078 let Inst{24-23} = 0b10;
2080 def SRSDB_UPD : SRSI<1, "srsdb\tsp!, $mode"> {
2081 let Inst{24-23} = 0b10;
2083 def SRSIA : SRSI<0, "srsia\tsp, $mode"> {
2084 let Inst{24-23} = 0b01;
2086 def SRSIA_UPD : SRSI<1, "srsia\tsp!, $mode"> {
2087 let Inst{24-23} = 0b01;
2089 def SRSIB : SRSI<0, "srsib\tsp, $mode"> {
2090 let Inst{24-23} = 0b11;
2092 def SRSIB_UPD : SRSI<1, "srsib\tsp!, $mode"> {
2093 let Inst{24-23} = 0b11;
2096 // Return From Exception
2097 class RFEI<bit wb, string asm>
2098 : XI<(outs), (ins GPR:$Rn), AddrModeNone, 4, IndexModeNone, BrFrm,
2099 NoItinerary, asm, "", []> {
2101 let Inst{31-28} = 0b1111;
2102 let Inst{27-25} = 0b100;
2106 let Inst{19-16} = Rn;
2107 let Inst{15-0} = 0xa00;
2110 def RFEDA : RFEI<0, "rfeda\t$Rn"> {
2111 let Inst{24-23} = 0;
2113 def RFEDA_UPD : RFEI<1, "rfeda\t$Rn!"> {
2114 let Inst{24-23} = 0;
2116 def RFEDB : RFEI<0, "rfedb\t$Rn"> {
2117 let Inst{24-23} = 0b10;
2119 def RFEDB_UPD : RFEI<1, "rfedb\t$Rn!"> {
2120 let Inst{24-23} = 0b10;
2122 def RFEIA : RFEI<0, "rfeia\t$Rn"> {
2123 let Inst{24-23} = 0b01;
2125 def RFEIA_UPD : RFEI<1, "rfeia\t$Rn!"> {
2126 let Inst{24-23} = 0b01;
2128 def RFEIB : RFEI<0, "rfeib\t$Rn"> {
2129 let Inst{24-23} = 0b11;
2131 def RFEIB_UPD : RFEI<1, "rfeib\t$Rn!"> {
2132 let Inst{24-23} = 0b11;
2135 //===----------------------------------------------------------------------===//
2136 // Load / store Instructions.
2142 defm LDR : AI_ldr1<0, "ldr", IIC_iLoad_r, IIC_iLoad_si,
2143 UnOpFrag<(load node:$Src)>>;
2144 defm LDRB : AI_ldr1nopc<1, "ldrb", IIC_iLoad_bh_r, IIC_iLoad_bh_si,
2145 UnOpFrag<(zextloadi8 node:$Src)>>;
2146 defm STR : AI_str1<0, "str", IIC_iStore_r, IIC_iStore_si,
2147 BinOpFrag<(store node:$LHS, node:$RHS)>>;
2148 defm STRB : AI_str1nopc<1, "strb", IIC_iStore_bh_r, IIC_iStore_bh_si,
2149 BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
2151 // Special LDR for loads from non-pc-relative constpools.
2152 let canFoldAsLoad = 1, mayLoad = 1, neverHasSideEffects = 1,
2153 isReMaterializable = 1, isCodeGenOnly = 1 in
2154 def LDRcp : AI2ldst<0b010, 1, 0, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
2155 AddrMode_i12, LdFrm, IIC_iLoad_r, "ldr", "\t$Rt, $addr",
2159 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2160 let Inst{19-16} = 0b1111;
2161 let Inst{15-12} = Rt;
2162 let Inst{11-0} = addr{11-0}; // imm12
2165 // Loads with zero extension
2166 def LDRH : AI3ld<0b1011, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2167 IIC_iLoad_bh_r, "ldrh", "\t$Rt, $addr",
2168 [(set GPR:$Rt, (zextloadi16 addrmode3:$addr))]>;
2170 // Loads with sign extension
2171 def LDRSH : AI3ld<0b1111, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2172 IIC_iLoad_bh_r, "ldrsh", "\t$Rt, $addr",
2173 [(set GPR:$Rt, (sextloadi16 addrmode3:$addr))]>;
2175 def LDRSB : AI3ld<0b1101, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2176 IIC_iLoad_bh_r, "ldrsb", "\t$Rt, $addr",
2177 [(set GPR:$Rt, (sextloadi8 addrmode3:$addr))]>;
2179 let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1 in {
2181 def LDRD : AI3ld<0b1101, 0, (outs GPR:$Rd, GPR:$dst2),
2182 (ins addrmode3:$addr), LdMiscFrm,
2183 IIC_iLoad_d_r, "ldrd", "\t$Rd, $dst2, $addr",
2184 []>, Requires<[IsARM, HasV5TE]>;
2188 multiclass AI2_ldridx<bit isByte, string opc, InstrItinClass itin> {
2189 def _PRE_IMM : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2190 (ins addrmode_imm12:$addr), IndexModePre, LdFrm, itin,
2191 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2194 let Inst{23} = addr{12};
2195 let Inst{19-16} = addr{16-13};
2196 let Inst{11-0} = addr{11-0};
2197 let DecoderMethod = "DecodeLDRPreImm";
2198 let AsmMatchConverter = "cvtLdWriteBackRegAddrModeImm12";
2201 def _PRE_REG : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2202 (ins ldst_so_reg:$addr), IndexModePre, LdFrm, itin,
2203 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2206 let Inst{23} = addr{12};
2207 let Inst{19-16} = addr{16-13};
2208 let Inst{11-0} = addr{11-0};
2210 let DecoderMethod = "DecodeLDRPreReg";
2211 let AsmMatchConverter = "cvtLdWriteBackRegAddrMode2";
2214 def _POST_REG : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2215 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2216 IndexModePost, LdFrm, itin,
2217 opc, "\t$Rt, $addr, $offset",
2218 "$addr.base = $Rn_wb", []> {
2224 let Inst{23} = offset{12};
2225 let Inst{19-16} = addr;
2226 let Inst{11-0} = offset{11-0};
2228 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2231 def _POST_IMM : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2232 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2233 IndexModePost, LdFrm, itin,
2234 opc, "\t$Rt, $addr, $offset",
2235 "$addr.base = $Rn_wb", []> {
2241 let Inst{23} = offset{12};
2242 let Inst{19-16} = addr;
2243 let Inst{11-0} = offset{11-0};
2245 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2250 let mayLoad = 1, neverHasSideEffects = 1 in {
2251 defm LDR : AI2_ldridx<0, "ldr", IIC_iLoad_ru>;
2252 defm LDRB : AI2_ldridx<1, "ldrb", IIC_iLoad_bh_ru>;
2255 multiclass AI3_ldridx<bits<4> op, string opc, InstrItinClass itin> {
2256 def _PRE : AI3ldstidx<op, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2257 (ins addrmode3:$addr), IndexModePre,
2259 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2261 let Inst{23} = addr{8}; // U bit
2262 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2263 let Inst{19-16} = addr{12-9}; // Rn
2264 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2265 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2266 let AsmMatchConverter = "cvtLdWriteBackRegAddrMode3";
2267 let DecoderMethod = "DecodeAddrMode3Instruction";
2269 def _POST : AI3ldstidx<op, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2270 (ins addr_offset_none:$addr, am3offset:$offset),
2271 IndexModePost, LdMiscFrm, itin,
2272 opc, "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2276 let Inst{23} = offset{8}; // U bit
2277 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2278 let Inst{19-16} = addr;
2279 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2280 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2281 let DecoderMethod = "DecodeAddrMode3Instruction";
2285 let mayLoad = 1, neverHasSideEffects = 1 in {
2286 defm LDRH : AI3_ldridx<0b1011, "ldrh", IIC_iLoad_bh_ru>;
2287 defm LDRSH : AI3_ldridx<0b1111, "ldrsh", IIC_iLoad_bh_ru>;
2288 defm LDRSB : AI3_ldridx<0b1101, "ldrsb", IIC_iLoad_bh_ru>;
2289 let hasExtraDefRegAllocReq = 1 in {
2290 def LDRD_PRE : AI3ldstidx<0b1101, 0, 1, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2291 (ins addrmode3:$addr), IndexModePre,
2292 LdMiscFrm, IIC_iLoad_d_ru,
2293 "ldrd", "\t$Rt, $Rt2, $addr!",
2294 "$addr.base = $Rn_wb", []> {
2296 let Inst{23} = addr{8}; // U bit
2297 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2298 let Inst{19-16} = addr{12-9}; // Rn
2299 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2300 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2301 let DecoderMethod = "DecodeAddrMode3Instruction";
2302 let AsmMatchConverter = "cvtLdrdPre";
2304 def LDRD_POST: AI3ldstidx<0b1101, 0, 0, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2305 (ins addr_offset_none:$addr, am3offset:$offset),
2306 IndexModePost, LdMiscFrm, IIC_iLoad_d_ru,
2307 "ldrd", "\t$Rt, $Rt2, $addr, $offset",
2308 "$addr.base = $Rn_wb", []> {
2311 let Inst{23} = offset{8}; // U bit
2312 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2313 let Inst{19-16} = addr;
2314 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2315 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2316 let DecoderMethod = "DecodeAddrMode3Instruction";
2318 } // hasExtraDefRegAllocReq = 1
2319 } // mayLoad = 1, neverHasSideEffects = 1
2321 // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT.
2322 let mayLoad = 1, neverHasSideEffects = 1 in {
2323 def LDRT_POST_REG : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2324 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2325 IndexModePost, LdFrm, IIC_iLoad_ru,
2326 "ldrt", "\t$Rt, $addr, $offset",
2327 "$addr.base = $Rn_wb", []> {
2333 let Inst{23} = offset{12};
2334 let Inst{21} = 1; // overwrite
2335 let Inst{19-16} = addr;
2336 let Inst{11-5} = offset{11-5};
2338 let Inst{3-0} = offset{3-0};
2339 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2342 def LDRT_POST_IMM : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2343 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2344 IndexModePost, LdFrm, IIC_iLoad_ru,
2345 "ldrt", "\t$Rt, $addr, $offset",
2346 "$addr.base = $Rn_wb", []> {
2352 let Inst{23} = offset{12};
2353 let Inst{21} = 1; // overwrite
2354 let Inst{19-16} = addr;
2355 let Inst{11-0} = offset{11-0};
2356 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2359 def LDRBT_POST_REG : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2360 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2361 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2362 "ldrbt", "\t$Rt, $addr, $offset",
2363 "$addr.base = $Rn_wb", []> {
2369 let Inst{23} = offset{12};
2370 let Inst{21} = 1; // overwrite
2371 let Inst{19-16} = addr;
2372 let Inst{11-5} = offset{11-5};
2374 let Inst{3-0} = offset{3-0};
2375 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2378 def LDRBT_POST_IMM : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2379 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2380 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2381 "ldrbt", "\t$Rt, $addr, $offset",
2382 "$addr.base = $Rn_wb", []> {
2388 let Inst{23} = offset{12};
2389 let Inst{21} = 1; // overwrite
2390 let Inst{19-16} = addr;
2391 let Inst{11-0} = offset{11-0};
2392 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2395 multiclass AI3ldrT<bits<4> op, string opc> {
2396 def i : AI3ldstidxT<op, 1, (outs GPR:$Rt, GPR:$base_wb),
2397 (ins addr_offset_none:$addr, postidx_imm8:$offset),
2398 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2399 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2401 let Inst{23} = offset{8};
2403 let Inst{11-8} = offset{7-4};
2404 let Inst{3-0} = offset{3-0};
2405 let AsmMatchConverter = "cvtLdExtTWriteBackImm";
2407 def r : AI3ldstidxT<op, 1, (outs GPR:$Rt, GPR:$base_wb),
2408 (ins addr_offset_none:$addr, postidx_reg:$Rm),
2409 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2410 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2412 let Inst{23} = Rm{4};
2415 let Inst{3-0} = Rm{3-0};
2416 let AsmMatchConverter = "cvtLdExtTWriteBackReg";
2420 defm LDRSBT : AI3ldrT<0b1101, "ldrsbt">;
2421 defm LDRHT : AI3ldrT<0b1011, "ldrht">;
2422 defm LDRSHT : AI3ldrT<0b1111, "ldrsht">;
2427 // Stores with truncate
2428 def STRH : AI3str<0b1011, (outs), (ins GPR:$Rt, addrmode3:$addr), StMiscFrm,
2429 IIC_iStore_bh_r, "strh", "\t$Rt, $addr",
2430 [(truncstorei16 GPR:$Rt, addrmode3:$addr)]>;
2433 let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in
2434 def STRD : AI3str<0b1111, (outs), (ins GPR:$Rt, GPR:$src2, addrmode3:$addr),
2435 StMiscFrm, IIC_iStore_d_r,
2436 "strd", "\t$Rt, $src2, $addr", []>,
2437 Requires<[IsARM, HasV5TE]> {
2442 multiclass AI2_stridx<bit isByte, string opc, InstrItinClass itin> {
2443 def _PRE_IMM : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2444 (ins GPR:$Rt, addrmode_imm12:$addr), IndexModePre,
2446 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2449 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2450 let Inst{19-16} = addr{16-13}; // Rn
2451 let Inst{11-0} = addr{11-0}; // imm12
2452 let AsmMatchConverter = "cvtStWriteBackRegAddrModeImm12";
2453 let DecoderMethod = "DecodeSTRPreImm";
2456 def _PRE_REG : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2457 (ins GPR:$Rt, ldst_so_reg:$addr),
2458 IndexModePre, StFrm, itin,
2459 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2462 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2463 let Inst{19-16} = addr{16-13}; // Rn
2464 let Inst{11-0} = addr{11-0};
2465 let Inst{4} = 0; // Inst{4} = 0
2466 let AsmMatchConverter = "cvtStWriteBackRegAddrMode2";
2467 let DecoderMethod = "DecodeSTRPreReg";
2469 def _POST_REG : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2470 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2471 IndexModePost, StFrm, itin,
2472 opc, "\t$Rt, $addr, $offset",
2473 "$addr.base = $Rn_wb", []> {
2479 let Inst{23} = offset{12};
2480 let Inst{19-16} = addr;
2481 let Inst{11-0} = offset{11-0};
2483 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2486 def _POST_IMM : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2487 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2488 IndexModePost, StFrm, itin,
2489 opc, "\t$Rt, $addr, $offset",
2490 "$addr.base = $Rn_wb", []> {
2496 let Inst{23} = offset{12};
2497 let Inst{19-16} = addr;
2498 let Inst{11-0} = offset{11-0};
2500 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2504 let mayStore = 1, neverHasSideEffects = 1 in {
2505 defm STR : AI2_stridx<0, "str", IIC_iStore_ru>;
2506 defm STRB : AI2_stridx<1, "strb", IIC_iStore_bh_ru>;
2509 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2510 am2offset_reg:$offset),
2511 (STR_POST_REG GPR:$Rt, addr_offset_none:$addr,
2512 am2offset_reg:$offset)>;
2513 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2514 am2offset_imm:$offset),
2515 (STR_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2516 am2offset_imm:$offset)>;
2517 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2518 am2offset_reg:$offset),
2519 (STRB_POST_REG GPR:$Rt, addr_offset_none:$addr,
2520 am2offset_reg:$offset)>;
2521 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2522 am2offset_imm:$offset),
2523 (STRB_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2524 am2offset_imm:$offset)>;
2526 // Pseudo-instructions for pattern matching the pre-indexed stores. We can't
2527 // put the patterns on the instruction definitions directly as ISel wants
2528 // the address base and offset to be separate operands, not a single
2529 // complex operand like we represent the instructions themselves. The
2530 // pseudos map between the two.
2531 let usesCustomInserter = 1,
2532 Constraints = "$Rn = $Rn_wb,@earlyclobber $Rn_wb" in {
2533 def STRi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2534 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2537 (pre_store GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2538 def STRr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2539 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2542 (pre_store GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2543 def STRBi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2544 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2547 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2548 def STRBr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2549 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2552 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2553 def STRH_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2554 (ins GPR:$Rt, GPR:$Rn, am3offset:$offset, pred:$p),
2557 (pre_truncsti16 GPR:$Rt, GPR:$Rn, am3offset:$offset))]>;
2562 def STRH_PRE : AI3ldstidx<0b1011, 0, 1, (outs GPR:$Rn_wb),
2563 (ins GPR:$Rt, addrmode3:$addr), IndexModePre,
2564 StMiscFrm, IIC_iStore_bh_ru,
2565 "strh", "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2567 let Inst{23} = addr{8}; // U bit
2568 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2569 let Inst{19-16} = addr{12-9}; // Rn
2570 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2571 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2572 let AsmMatchConverter = "cvtStWriteBackRegAddrMode3";
2573 let DecoderMethod = "DecodeAddrMode3Instruction";
2576 def STRH_POST : AI3ldstidx<0b1011, 0, 0, (outs GPR:$Rn_wb),
2577 (ins GPR:$Rt, addr_offset_none:$addr, am3offset:$offset),
2578 IndexModePost, StMiscFrm, IIC_iStore_bh_ru,
2579 "strh", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2580 [(set GPR:$Rn_wb, (post_truncsti16 GPR:$Rt,
2581 addr_offset_none:$addr,
2582 am3offset:$offset))]> {
2585 let Inst{23} = offset{8}; // U bit
2586 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2587 let Inst{19-16} = addr;
2588 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2589 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2590 let DecoderMethod = "DecodeAddrMode3Instruction";
2593 let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in {
2594 def STRD_PRE : AI3ldstidx<0b1111, 0, 1, (outs GPR:$Rn_wb),
2595 (ins GPR:$Rt, GPR:$Rt2, addrmode3:$addr),
2596 IndexModePre, StMiscFrm, IIC_iStore_d_ru,
2597 "strd", "\t$Rt, $Rt2, $addr!",
2598 "$addr.base = $Rn_wb", []> {
2600 let Inst{23} = addr{8}; // U bit
2601 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2602 let Inst{19-16} = addr{12-9}; // Rn
2603 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2604 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2605 let DecoderMethod = "DecodeAddrMode3Instruction";
2606 let AsmMatchConverter = "cvtStrdPre";
2609 def STRD_POST: AI3ldstidx<0b1111, 0, 0, (outs GPR:$Rn_wb),
2610 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr,
2612 IndexModePost, StMiscFrm, IIC_iStore_d_ru,
2613 "strd", "\t$Rt, $Rt2, $addr, $offset",
2614 "$addr.base = $Rn_wb", []> {
2617 let Inst{23} = offset{8}; // U bit
2618 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2619 let Inst{19-16} = addr;
2620 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2621 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2622 let DecoderMethod = "DecodeAddrMode3Instruction";
2624 } // mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1
2626 // STRT, STRBT, and STRHT
2628 def STRBT_POST_REG : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2629 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2630 IndexModePost, StFrm, IIC_iStore_bh_ru,
2631 "strbt", "\t$Rt, $addr, $offset",
2632 "$addr.base = $Rn_wb", []> {
2638 let Inst{23} = offset{12};
2639 let Inst{21} = 1; // overwrite
2640 let Inst{19-16} = addr;
2641 let Inst{11-5} = offset{11-5};
2643 let Inst{3-0} = offset{3-0};
2644 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2647 def STRBT_POST_IMM : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2648 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2649 IndexModePost, StFrm, IIC_iStore_bh_ru,
2650 "strbt", "\t$Rt, $addr, $offset",
2651 "$addr.base = $Rn_wb", []> {
2657 let Inst{23} = offset{12};
2658 let Inst{21} = 1; // overwrite
2659 let Inst{19-16} = addr;
2660 let Inst{11-0} = offset{11-0};
2661 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2664 let mayStore = 1, neverHasSideEffects = 1 in {
2665 def STRT_POST_REG : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
2666 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2667 IndexModePost, StFrm, IIC_iStore_ru,
2668 "strt", "\t$Rt, $addr, $offset",
2669 "$addr.base = $Rn_wb", []> {
2675 let Inst{23} = offset{12};
2676 let Inst{21} = 1; // overwrite
2677 let Inst{19-16} = addr;
2678 let Inst{11-5} = offset{11-5};
2680 let Inst{3-0} = offset{3-0};
2681 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2684 def STRT_POST_IMM : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
2685 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2686 IndexModePost, StFrm, IIC_iStore_ru,
2687 "strt", "\t$Rt, $addr, $offset",
2688 "$addr.base = $Rn_wb", []> {
2694 let Inst{23} = offset{12};
2695 let Inst{21} = 1; // overwrite
2696 let Inst{19-16} = addr;
2697 let Inst{11-0} = offset{11-0};
2698 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2703 multiclass AI3strT<bits<4> op, string opc> {
2704 def i : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
2705 (ins GPR:$Rt, addr_offset_none:$addr, postidx_imm8:$offset),
2706 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
2707 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2709 let Inst{23} = offset{8};
2711 let Inst{11-8} = offset{7-4};
2712 let Inst{3-0} = offset{3-0};
2713 let AsmMatchConverter = "cvtStExtTWriteBackImm";
2715 def r : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
2716 (ins GPR:$Rt, addr_offset_none:$addr, postidx_reg:$Rm),
2717 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
2718 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2720 let Inst{23} = Rm{4};
2723 let Inst{3-0} = Rm{3-0};
2724 let AsmMatchConverter = "cvtStExtTWriteBackReg";
2729 defm STRHT : AI3strT<0b1011, "strht">;
2732 //===----------------------------------------------------------------------===//
2733 // Load / store multiple Instructions.
2736 multiclass arm_ldst_mult<string asm, bit L_bit, Format f,
2737 InstrItinClass itin, InstrItinClass itin_upd> {
2738 // IA is the default, so no need for an explicit suffix on the
2739 // mnemonic here. Without it is the cannonical spelling.
2741 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2742 IndexModeNone, f, itin,
2743 !strconcat(asm, "${p}\t$Rn, $regs"), "", []> {
2744 let Inst{24-23} = 0b01; // Increment After
2745 let Inst{21} = 0; // No writeback
2746 let Inst{20} = L_bit;
2749 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2750 IndexModeUpd, f, itin_upd,
2751 !strconcat(asm, "${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
2752 let Inst{24-23} = 0b01; // Increment After
2753 let Inst{21} = 1; // Writeback
2754 let Inst{20} = L_bit;
2756 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2759 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2760 IndexModeNone, f, itin,
2761 !strconcat(asm, "da${p}\t$Rn, $regs"), "", []> {
2762 let Inst{24-23} = 0b00; // Decrement After
2763 let Inst{21} = 0; // No writeback
2764 let Inst{20} = L_bit;
2767 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2768 IndexModeUpd, f, itin_upd,
2769 !strconcat(asm, "da${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
2770 let Inst{24-23} = 0b00; // Decrement After
2771 let Inst{21} = 1; // Writeback
2772 let Inst{20} = L_bit;
2774 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2777 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2778 IndexModeNone, f, itin,
2779 !strconcat(asm, "db${p}\t$Rn, $regs"), "", []> {
2780 let Inst{24-23} = 0b10; // Decrement Before
2781 let Inst{21} = 0; // No writeback
2782 let Inst{20} = L_bit;
2785 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2786 IndexModeUpd, f, itin_upd,
2787 !strconcat(asm, "db${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
2788 let Inst{24-23} = 0b10; // Decrement Before
2789 let Inst{21} = 1; // Writeback
2790 let Inst{20} = L_bit;
2792 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2795 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2796 IndexModeNone, f, itin,
2797 !strconcat(asm, "ib${p}\t$Rn, $regs"), "", []> {
2798 let Inst{24-23} = 0b11; // Increment Before
2799 let Inst{21} = 0; // No writeback
2800 let Inst{20} = L_bit;
2803 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2804 IndexModeUpd, f, itin_upd,
2805 !strconcat(asm, "ib${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
2806 let Inst{24-23} = 0b11; // Increment Before
2807 let Inst{21} = 1; // Writeback
2808 let Inst{20} = L_bit;
2810 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2814 let neverHasSideEffects = 1 in {
2816 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
2817 defm LDM : arm_ldst_mult<"ldm", 1, LdStMulFrm, IIC_iLoad_m, IIC_iLoad_mu>;
2819 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
2820 defm STM : arm_ldst_mult<"stm", 0, LdStMulFrm, IIC_iStore_m, IIC_iStore_mu>;
2822 } // neverHasSideEffects
2824 // FIXME: remove when we have a way to marking a MI with these properties.
2825 // FIXME: Should pc be an implicit operand like PICADD, etc?
2826 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
2827 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
2828 def LDMIA_RET : ARMPseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p,
2829 reglist:$regs, variable_ops),
2830 4, IIC_iLoad_mBr, [],
2831 (LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>,
2832 RegConstraint<"$Rn = $wb">;
2834 //===----------------------------------------------------------------------===//
2835 // Move Instructions.
2838 let neverHasSideEffects = 1 in
2839 def MOVr : AsI1<0b1101, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMOVr,
2840 "mov", "\t$Rd, $Rm", []>, UnaryDP {
2844 let Inst{19-16} = 0b0000;
2845 let Inst{11-4} = 0b00000000;
2848 let Inst{15-12} = Rd;
2851 // A version for the smaller set of tail call registers.
2852 let neverHasSideEffects = 1 in
2853 def MOVr_TC : AsI1<0b1101, (outs tcGPR:$Rd), (ins tcGPR:$Rm), DPFrm,
2854 IIC_iMOVr, "mov", "\t$Rd, $Rm", []>, UnaryDP {
2858 let Inst{11-4} = 0b00000000;
2861 let Inst{15-12} = Rd;
2864 def MOVsr : AsI1<0b1101, (outs GPRnopc:$Rd), (ins shift_so_reg_reg:$src),
2865 DPSoRegRegFrm, IIC_iMOVsr,
2866 "mov", "\t$Rd, $src",
2867 [(set GPRnopc:$Rd, shift_so_reg_reg:$src)]>, UnaryDP {
2870 let Inst{15-12} = Rd;
2871 let Inst{19-16} = 0b0000;
2872 let Inst{11-8} = src{11-8};
2874 let Inst{6-5} = src{6-5};
2876 let Inst{3-0} = src{3-0};
2880 def MOVsi : AsI1<0b1101, (outs GPR:$Rd), (ins shift_so_reg_imm:$src),
2881 DPSoRegImmFrm, IIC_iMOVsr,
2882 "mov", "\t$Rd, $src", [(set GPR:$Rd, shift_so_reg_imm:$src)]>,
2886 let Inst{15-12} = Rd;
2887 let Inst{19-16} = 0b0000;
2888 let Inst{11-5} = src{11-5};
2890 let Inst{3-0} = src{3-0};
2894 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
2895 def MOVi : AsI1<0b1101, (outs GPR:$Rd), (ins so_imm:$imm), DPFrm, IIC_iMOVi,
2896 "mov", "\t$Rd, $imm", [(set GPR:$Rd, so_imm:$imm)]>, UnaryDP {
2900 let Inst{15-12} = Rd;
2901 let Inst{19-16} = 0b0000;
2902 let Inst{11-0} = imm;
2905 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
2906 def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins imm0_65535_expr:$imm),
2908 "movw", "\t$Rd, $imm",
2909 [(set GPR:$Rd, imm0_65535:$imm)]>,
2910 Requires<[IsARM, HasV6T2]>, UnaryDP {
2913 let Inst{15-12} = Rd;
2914 let Inst{11-0} = imm{11-0};
2915 let Inst{19-16} = imm{15-12};
2918 let DecoderMethod = "DecodeArmMOVTWInstruction";
2921 def : InstAlias<"mov${p} $Rd, $imm",
2922 (MOVi16 GPR:$Rd, imm0_65535_expr:$imm, pred:$p)>,
2925 def MOVi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
2926 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>;
2928 let Constraints = "$src = $Rd" in {
2929 def MOVTi16 : AI1<0b1010, (outs GPRnopc:$Rd),
2930 (ins GPR:$src, imm0_65535_expr:$imm),
2932 "movt", "\t$Rd, $imm",
2934 (or (and GPR:$src, 0xffff),
2935 lo16AllZero:$imm))]>, UnaryDP,
2936 Requires<[IsARM, HasV6T2]> {
2939 let Inst{15-12} = Rd;
2940 let Inst{11-0} = imm{11-0};
2941 let Inst{19-16} = imm{15-12};
2944 let DecoderMethod = "DecodeArmMOVTWInstruction";
2947 def MOVTi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
2948 (ins GPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>;
2952 def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
2953 Requires<[IsARM, HasV6T2]>;
2955 let Uses = [CPSR] in
2956 def RRX: PseudoInst<(outs GPR:$Rd), (ins GPR:$Rm), IIC_iMOVsi,
2957 [(set GPR:$Rd, (ARMrrx GPR:$Rm))]>, UnaryDP,
2960 // These aren't really mov instructions, but we have to define them this way
2961 // due to flag operands.
2963 let Defs = [CPSR] in {
2964 def MOVsrl_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
2965 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP,
2967 def MOVsra_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
2968 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP,
2972 //===----------------------------------------------------------------------===//
2973 // Extend Instructions.
2978 def SXTB : AI_ext_rrot<0b01101010,
2979 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
2980 def SXTH : AI_ext_rrot<0b01101011,
2981 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
2983 def SXTAB : AI_exta_rrot<0b01101010,
2984 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
2985 def SXTAH : AI_exta_rrot<0b01101011,
2986 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
2988 def SXTB16 : AI_ext_rrot_np<0b01101000, "sxtb16">;
2990 def SXTAB16 : AI_exta_rrot_np<0b01101000, "sxtab16">;
2994 let AddedComplexity = 16 in {
2995 def UXTB : AI_ext_rrot<0b01101110,
2996 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
2997 def UXTH : AI_ext_rrot<0b01101111,
2998 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
2999 def UXTB16 : AI_ext_rrot<0b01101100,
3000 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
3002 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
3003 // The transformation should probably be done as a combiner action
3004 // instead so we can include a check for masking back in the upper
3005 // eight bits of the source into the lower eight bits of the result.
3006 //def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
3007 // (UXTB16r_rot GPR:$Src, 3)>;
3008 def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
3009 (UXTB16 GPR:$Src, 1)>;
3011 def UXTAB : AI_exta_rrot<0b01101110, "uxtab",
3012 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
3013 def UXTAH : AI_exta_rrot<0b01101111, "uxtah",
3014 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
3017 // This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
3018 def UXTAB16 : AI_exta_rrot_np<0b01101100, "uxtab16">;
3021 def SBFX : I<(outs GPRnopc:$Rd),
3022 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3023 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3024 "sbfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3025 Requires<[IsARM, HasV6T2]> {
3030 let Inst{27-21} = 0b0111101;
3031 let Inst{6-4} = 0b101;
3032 let Inst{20-16} = width;
3033 let Inst{15-12} = Rd;
3034 let Inst{11-7} = lsb;
3038 def UBFX : I<(outs GPR:$Rd),
3039 (ins GPR:$Rn, imm0_31:$lsb, imm1_32:$width),
3040 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3041 "ubfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3042 Requires<[IsARM, HasV6T2]> {
3047 let Inst{27-21} = 0b0111111;
3048 let Inst{6-4} = 0b101;
3049 let Inst{20-16} = width;
3050 let Inst{15-12} = Rd;
3051 let Inst{11-7} = lsb;
3055 //===----------------------------------------------------------------------===//
3056 // Arithmetic Instructions.
3059 defm ADD : AsI1_bin_irs<0b0100, "add",
3060 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3061 BinOpFrag<(add node:$LHS, node:$RHS)>, "ADD", 1>;
3062 defm SUB : AsI1_bin_irs<0b0010, "sub",
3063 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3064 BinOpFrag<(sub node:$LHS, node:$RHS)>, "SUB">;
3066 // ADD and SUB with 's' bit set.
3068 // Currently, t2ADDS/t2SUBS are pseudo opcodes that exist only in the
3069 // selection DAG. They are "lowered" to real t2ADD/t2SUB opcodes by
3070 // AdjustInstrPostInstrSelection where we determine whether or not to
3071 // set the "s" bit based on CPSR liveness.
3073 // FIXME: Eliminate t2ADDS/t2SUBS pseudo opcodes after adding tablegen
3074 // support for an optional CPSR definition that corresponds to the DAG
3075 // node's second value. We can then eliminate the implicit def of CPSR.
3076 defm ADDS : AsI1_bin_s_irs<0b0100, "add",
3077 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3078 BinOpFrag<(ARMaddc node:$LHS, node:$RHS)>, 1>;
3079 defm SUBS : AsI1_bin_s_irs<0b0010, "sub",
3080 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3081 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
3083 defm ADC : AI1_adde_sube_irs<0b0101, "adc",
3084 BinOpWithFlagFrag<(ARMadde node:$LHS, node:$RHS, node:$FLAG)>,
3086 defm SBC : AI1_adde_sube_irs<0b0110, "sbc",
3087 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>,
3090 defm RSB : AsI1_rbin_irs <0b0011, "rsb",
3091 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3092 BinOpFrag<(sub node:$LHS, node:$RHS)>, "RSB">;
3094 // FIXME: Eliminate them if we can write def : Pat patterns which defines
3095 // CPSR and the implicit def of CPSR is not needed.
3096 defm RSBS : AsI1_rbin_s_is<0b0011, "rsb",
3097 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3098 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
3100 defm RSC : AI1_rsc_irs<0b0111, "rsc",
3101 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>,
3104 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
3105 // The assume-no-carry-in form uses the negation of the input since add/sub
3106 // assume opposite meanings of the carry flag (i.e., carry == !borrow).
3107 // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
3109 def : ARMPat<(add GPR:$src, so_imm_neg:$imm),
3110 (SUBri GPR:$src, so_imm_neg:$imm)>;
3111 def : ARMPat<(ARMaddc GPR:$src, so_imm_neg:$imm),
3112 (SUBSri GPR:$src, so_imm_neg:$imm)>;
3114 // The with-carry-in form matches bitwise not instead of the negation.
3115 // Effectively, the inverse interpretation of the carry flag already accounts
3116 // for part of the negation.
3117 def : ARMPat<(ARMadde GPR:$src, so_imm_not:$imm, CPSR),
3118 (SBCri GPR:$src, so_imm_not:$imm)>;
3120 // Note: These are implemented in C++ code, because they have to generate
3121 // ADD/SUBrs instructions, which use a complex pattern that a xform function
3123 // (mul X, 2^n+1) -> (add (X << n), X)
3124 // (mul X, 2^n-1) -> (rsb X, (X << n))
3126 // ARM Arithmetic Instruction
3127 // GPR:$dst = GPR:$a op GPR:$b
3128 class AAI<bits<8> op27_20, bits<8> op11_4, string opc,
3129 list<dag> pattern = [],
3130 dag iops = (ins GPRnopc:$Rn, GPRnopc:$Rm),
3131 string asm = "\t$Rd, $Rn, $Rm">
3132 : AI<(outs GPRnopc:$Rd), iops, DPFrm, IIC_iALUr, opc, asm, pattern> {
3136 let Inst{27-20} = op27_20;
3137 let Inst{11-4} = op11_4;
3138 let Inst{19-16} = Rn;
3139 let Inst{15-12} = Rd;
3143 // Saturating add/subtract
3145 def QADD : AAI<0b00010000, 0b00000101, "qadd",
3146 [(set GPRnopc:$Rd, (int_arm_qadd GPRnopc:$Rm, GPRnopc:$Rn))],
3147 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3148 def QSUB : AAI<0b00010010, 0b00000101, "qsub",
3149 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm, GPRnopc:$Rn))],
3150 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3151 def QDADD : AAI<0b00010100, 0b00000101, "qdadd", [],
3152 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3154 def QDSUB : AAI<0b00010110, 0b00000101, "qdsub", [],
3155 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3158 def QADD16 : AAI<0b01100010, 0b11110001, "qadd16">;
3159 def QADD8 : AAI<0b01100010, 0b11111001, "qadd8">;
3160 def QASX : AAI<0b01100010, 0b11110011, "qasx">;
3161 def QSAX : AAI<0b01100010, 0b11110101, "qsax">;
3162 def QSUB16 : AAI<0b01100010, 0b11110111, "qsub16">;
3163 def QSUB8 : AAI<0b01100010, 0b11111111, "qsub8">;
3164 def UQADD16 : AAI<0b01100110, 0b11110001, "uqadd16">;
3165 def UQADD8 : AAI<0b01100110, 0b11111001, "uqadd8">;
3166 def UQASX : AAI<0b01100110, 0b11110011, "uqasx">;
3167 def UQSAX : AAI<0b01100110, 0b11110101, "uqsax">;
3168 def UQSUB16 : AAI<0b01100110, 0b11110111, "uqsub16">;
3169 def UQSUB8 : AAI<0b01100110, 0b11111111, "uqsub8">;
3171 // Signed/Unsigned add/subtract
3173 def SASX : AAI<0b01100001, 0b11110011, "sasx">;
3174 def SADD16 : AAI<0b01100001, 0b11110001, "sadd16">;
3175 def SADD8 : AAI<0b01100001, 0b11111001, "sadd8">;
3176 def SSAX : AAI<0b01100001, 0b11110101, "ssax">;
3177 def SSUB16 : AAI<0b01100001, 0b11110111, "ssub16">;
3178 def SSUB8 : AAI<0b01100001, 0b11111111, "ssub8">;
3179 def UASX : AAI<0b01100101, 0b11110011, "uasx">;
3180 def UADD16 : AAI<0b01100101, 0b11110001, "uadd16">;
3181 def UADD8 : AAI<0b01100101, 0b11111001, "uadd8">;
3182 def USAX : AAI<0b01100101, 0b11110101, "usax">;
3183 def USUB16 : AAI<0b01100101, 0b11110111, "usub16">;
3184 def USUB8 : AAI<0b01100101, 0b11111111, "usub8">;
3186 // Signed/Unsigned halving add/subtract
3188 def SHASX : AAI<0b01100011, 0b11110011, "shasx">;
3189 def SHADD16 : AAI<0b01100011, 0b11110001, "shadd16">;
3190 def SHADD8 : AAI<0b01100011, 0b11111001, "shadd8">;
3191 def SHSAX : AAI<0b01100011, 0b11110101, "shsax">;
3192 def SHSUB16 : AAI<0b01100011, 0b11110111, "shsub16">;
3193 def SHSUB8 : AAI<0b01100011, 0b11111111, "shsub8">;
3194 def UHASX : AAI<0b01100111, 0b11110011, "uhasx">;
3195 def UHADD16 : AAI<0b01100111, 0b11110001, "uhadd16">;
3196 def UHADD8 : AAI<0b01100111, 0b11111001, "uhadd8">;
3197 def UHSAX : AAI<0b01100111, 0b11110101, "uhsax">;
3198 def UHSUB16 : AAI<0b01100111, 0b11110111, "uhsub16">;
3199 def UHSUB8 : AAI<0b01100111, 0b11111111, "uhsub8">;
3201 // Unsigned Sum of Absolute Differences [and Accumulate].
3203 def USAD8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3204 MulFrm /* for convenience */, NoItinerary, "usad8",
3205 "\t$Rd, $Rn, $Rm", []>,
3206 Requires<[IsARM, HasV6]> {
3210 let Inst{27-20} = 0b01111000;
3211 let Inst{15-12} = 0b1111;
3212 let Inst{7-4} = 0b0001;
3213 let Inst{19-16} = Rd;
3214 let Inst{11-8} = Rm;
3217 def USADA8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3218 MulFrm /* for convenience */, NoItinerary, "usada8",
3219 "\t$Rd, $Rn, $Rm, $Ra", []>,
3220 Requires<[IsARM, HasV6]> {
3225 let Inst{27-20} = 0b01111000;
3226 let Inst{7-4} = 0b0001;
3227 let Inst{19-16} = Rd;
3228 let Inst{15-12} = Ra;
3229 let Inst{11-8} = Rm;
3233 // Signed/Unsigned saturate
3235 def SSAT : AI<(outs GPRnopc:$Rd),
3236 (ins imm1_32:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3237 SatFrm, NoItinerary, "ssat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3242 let Inst{27-21} = 0b0110101;
3243 let Inst{5-4} = 0b01;
3244 let Inst{20-16} = sat_imm;
3245 let Inst{15-12} = Rd;
3246 let Inst{11-7} = sh{4-0};
3247 let Inst{6} = sh{5};
3251 def SSAT16 : AI<(outs GPRnopc:$Rd),
3252 (ins imm1_16:$sat_imm, GPRnopc:$Rn), SatFrm,
3253 NoItinerary, "ssat16", "\t$Rd, $sat_imm, $Rn", []> {
3257 let Inst{27-20} = 0b01101010;
3258 let Inst{11-4} = 0b11110011;
3259 let Inst{15-12} = Rd;
3260 let Inst{19-16} = sat_imm;
3264 def USAT : AI<(outs GPRnopc:$Rd),
3265 (ins imm0_31:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3266 SatFrm, NoItinerary, "usat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3271 let Inst{27-21} = 0b0110111;
3272 let Inst{5-4} = 0b01;
3273 let Inst{15-12} = Rd;
3274 let Inst{11-7} = sh{4-0};
3275 let Inst{6} = sh{5};
3276 let Inst{20-16} = sat_imm;
3280 def USAT16 : AI<(outs GPRnopc:$Rd),
3281 (ins imm0_15:$sat_imm, GPRnopc:$Rn), SatFrm,
3282 NoItinerary, "usat16", "\t$Rd, $sat_imm, $Rn", []> {
3286 let Inst{27-20} = 0b01101110;
3287 let Inst{11-4} = 0b11110011;
3288 let Inst{15-12} = Rd;
3289 let Inst{19-16} = sat_imm;
3293 def : ARMV6Pat<(int_arm_ssat GPRnopc:$a, imm:$pos),
3294 (SSAT imm:$pos, GPRnopc:$a, 0)>;
3295 def : ARMV6Pat<(int_arm_usat GPRnopc:$a, imm:$pos),
3296 (USAT imm:$pos, GPRnopc:$a, 0)>;
3298 //===----------------------------------------------------------------------===//
3299 // Bitwise Instructions.
3302 defm AND : AsI1_bin_irs<0b0000, "and",
3303 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3304 BinOpFrag<(and node:$LHS, node:$RHS)>, "AND", 1>;
3305 defm ORR : AsI1_bin_irs<0b1100, "orr",
3306 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3307 BinOpFrag<(or node:$LHS, node:$RHS)>, "ORR", 1>;
3308 defm EOR : AsI1_bin_irs<0b0001, "eor",
3309 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3310 BinOpFrag<(xor node:$LHS, node:$RHS)>, "EOR", 1>;
3311 defm BIC : AsI1_bin_irs<0b1110, "bic",
3312 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3313 BinOpFrag<(and node:$LHS, (not node:$RHS))>, "BIC">;
3315 // FIXME: bf_inv_mask_imm should be two operands, the lsb and the msb, just
3316 // like in the actual instruction encoding. The complexity of mapping the mask
3317 // to the lsb/msb pair should be handled by ISel, not encapsulated in the
3318 // instruction description.
3319 def BFC : I<(outs GPR:$Rd), (ins GPR:$src, bf_inv_mask_imm:$imm),
3320 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3321 "bfc", "\t$Rd, $imm", "$src = $Rd",
3322 [(set GPR:$Rd, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
3323 Requires<[IsARM, HasV6T2]> {
3326 let Inst{27-21} = 0b0111110;
3327 let Inst{6-0} = 0b0011111;
3328 let Inst{15-12} = Rd;
3329 let Inst{11-7} = imm{4-0}; // lsb
3330 let Inst{20-16} = imm{9-5}; // msb
3333 // A8.6.18 BFI - Bitfield insert (Encoding A1)
3334 def BFI:I<(outs GPRnopc:$Rd), (ins GPRnopc:$src, GPR:$Rn, bf_inv_mask_imm:$imm),
3335 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3336 "bfi", "\t$Rd, $Rn, $imm", "$src = $Rd",
3337 [(set GPRnopc:$Rd, (ARMbfi GPRnopc:$src, GPR:$Rn,
3338 bf_inv_mask_imm:$imm))]>,
3339 Requires<[IsARM, HasV6T2]> {
3343 let Inst{27-21} = 0b0111110;
3344 let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15
3345 let Inst{15-12} = Rd;
3346 let Inst{11-7} = imm{4-0}; // lsb
3347 let Inst{20-16} = imm{9-5}; // width
3351 def MVNr : AsI1<0b1111, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMVNr,
3352 "mvn", "\t$Rd, $Rm",
3353 [(set GPR:$Rd, (not GPR:$Rm))]>, UnaryDP {
3357 let Inst{19-16} = 0b0000;
3358 let Inst{11-4} = 0b00000000;
3359 let Inst{15-12} = Rd;
3362 def MVNsi : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_imm:$shift),
3363 DPSoRegImmFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3364 [(set GPR:$Rd, (not so_reg_imm:$shift))]>, UnaryDP {
3368 let Inst{19-16} = 0b0000;
3369 let Inst{15-12} = Rd;
3370 let Inst{11-5} = shift{11-5};
3372 let Inst{3-0} = shift{3-0};
3374 def MVNsr : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_reg:$shift),
3375 DPSoRegRegFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3376 [(set GPR:$Rd, (not so_reg_reg:$shift))]>, UnaryDP {
3380 let Inst{19-16} = 0b0000;
3381 let Inst{15-12} = Rd;
3382 let Inst{11-8} = shift{11-8};
3384 let Inst{6-5} = shift{6-5};
3386 let Inst{3-0} = shift{3-0};
3388 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3389 def MVNi : AsI1<0b1111, (outs GPR:$Rd), (ins so_imm:$imm), DPFrm,
3390 IIC_iMVNi, "mvn", "\t$Rd, $imm",
3391 [(set GPR:$Rd, so_imm_not:$imm)]>,UnaryDP {
3395 let Inst{19-16} = 0b0000;
3396 let Inst{15-12} = Rd;
3397 let Inst{11-0} = imm;
3400 def : ARMPat<(and GPR:$src, so_imm_not:$imm),
3401 (BICri GPR:$src, so_imm_not:$imm)>;
3403 //===----------------------------------------------------------------------===//
3404 // Multiply Instructions.
3406 class AsMul1I32<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3407 string opc, string asm, list<dag> pattern>
3408 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3412 let Inst{19-16} = Rd;
3413 let Inst{11-8} = Rm;
3416 class AsMul1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3417 string opc, string asm, list<dag> pattern>
3418 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3423 let Inst{19-16} = RdHi;
3424 let Inst{15-12} = RdLo;
3425 let Inst{11-8} = Rm;
3429 // FIXME: The v5 pseudos are only necessary for the additional Constraint
3430 // property. Remove them when it's possible to add those properties
3431 // on an individual MachineInstr, not just an instuction description.
3432 let isCommutable = 1 in {
3433 def MUL : AsMul1I32<0b0000000, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3434 IIC_iMUL32, "mul", "\t$Rd, $Rn, $Rm",
3435 [(set GPR:$Rd, (mul GPR:$Rn, GPR:$Rm))]>,
3436 Requires<[IsARM, HasV6]> {
3437 let Inst{15-12} = 0b0000;
3440 let Constraints = "@earlyclobber $Rd" in
3441 def MULv5: ARMPseudoExpand<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm,
3442 pred:$p, cc_out:$s),
3444 [(set GPR:$Rd, (mul GPR:$Rn, GPR:$Rm))],
3445 (MUL GPR:$Rd, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3446 Requires<[IsARM, NoV6]>;
3449 def MLA : AsMul1I32<0b0000001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3450 IIC_iMAC32, "mla", "\t$Rd, $Rn, $Rm, $Ra",
3451 [(set GPR:$Rd, (add (mul GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
3452 Requires<[IsARM, HasV6]> {
3454 let Inst{15-12} = Ra;
3457 let Constraints = "@earlyclobber $Rd" in
3458 def MLAv5: ARMPseudoExpand<(outs GPR:$Rd),
3459 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra, pred:$p, cc_out:$s),
3461 [(set GPR:$Rd, (add (mul GPR:$Rn, GPR:$Rm), GPR:$Ra))],
3462 (MLA GPR:$Rd, GPR:$Rn, GPR:$Rm, GPR:$Ra, pred:$p, cc_out:$s)>,
3463 Requires<[IsARM, NoV6]>;
3465 def MLS : AMul1I<0b0000011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3466 IIC_iMAC32, "mls", "\t$Rd, $Rn, $Rm, $Ra",
3467 [(set GPR:$Rd, (sub GPR:$Ra, (mul GPR:$Rn, GPR:$Rm)))]>,
3468 Requires<[IsARM, HasV6T2]> {
3473 let Inst{19-16} = Rd;
3474 let Inst{15-12} = Ra;
3475 let Inst{11-8} = Rm;
3479 // Extra precision multiplies with low / high results
3480 let neverHasSideEffects = 1 in {
3481 let isCommutable = 1 in {
3482 def SMULL : AsMul1I64<0b0000110, (outs GPR:$RdLo, GPR:$RdHi),
3483 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3484 "smull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3485 Requires<[IsARM, HasV6]>;
3487 def UMULL : AsMul1I64<0b0000100, (outs GPR:$RdLo, GPR:$RdHi),
3488 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3489 "umull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3490 Requires<[IsARM, HasV6]>;
3492 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
3493 def SMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3494 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3496 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3497 Requires<[IsARM, NoV6]>;
3499 def UMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3500 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3502 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3503 Requires<[IsARM, NoV6]>;
3507 // Multiply + accumulate
3508 def SMLAL : AsMul1I64<0b0000111, (outs GPR:$RdLo, GPR:$RdHi),
3509 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3510 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3511 Requires<[IsARM, HasV6]>;
3512 def UMLAL : AsMul1I64<0b0000101, (outs GPR:$RdLo, GPR:$RdHi),
3513 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3514 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3515 Requires<[IsARM, HasV6]>;
3517 def UMAAL : AMul1I <0b0000010, (outs GPR:$RdLo, GPR:$RdHi),
3518 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3519 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3520 Requires<[IsARM, HasV6]> {
3525 let Inst{19-16} = RdHi;
3526 let Inst{15-12} = RdLo;
3527 let Inst{11-8} = Rm;
3531 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
3532 def SMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3533 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3535 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3536 Requires<[IsARM, NoV6]>;
3537 def UMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3538 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3540 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3541 Requires<[IsARM, NoV6]>;
3542 def UMAALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3543 (ins GPR:$Rn, GPR:$Rm, pred:$p),
3545 (UMAAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p)>,
3546 Requires<[IsARM, NoV6]>;
3549 } // neverHasSideEffects
3551 // Most significant word multiply
3552 def SMMUL : AMul2I <0b0111010, 0b0001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3553 IIC_iMUL32, "smmul", "\t$Rd, $Rn, $Rm",
3554 [(set GPR:$Rd, (mulhs GPR:$Rn, GPR:$Rm))]>,
3555 Requires<[IsARM, HasV6]> {
3556 let Inst{15-12} = 0b1111;
3559 def SMMULR : AMul2I <0b0111010, 0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3560 IIC_iMUL32, "smmulr", "\t$Rd, $Rn, $Rm", []>,
3561 Requires<[IsARM, HasV6]> {
3562 let Inst{15-12} = 0b1111;
3565 def SMMLA : AMul2Ia <0b0111010, 0b0001, (outs GPR:$Rd),
3566 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3567 IIC_iMAC32, "smmla", "\t$Rd, $Rn, $Rm, $Ra",
3568 [(set GPR:$Rd, (add (mulhs GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
3569 Requires<[IsARM, HasV6]>;
3571 def SMMLAR : AMul2Ia <0b0111010, 0b0011, (outs GPR:$Rd),
3572 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3573 IIC_iMAC32, "smmlar", "\t$Rd, $Rn, $Rm, $Ra", []>,
3574 Requires<[IsARM, HasV6]>;
3576 def SMMLS : AMul2Ia <0b0111010, 0b1101, (outs GPR:$Rd),
3577 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3578 IIC_iMAC32, "smmls", "\t$Rd, $Rn, $Rm, $Ra",
3579 [(set GPR:$Rd, (sub GPR:$Ra, (mulhs GPR:$Rn, GPR:$Rm)))]>,
3580 Requires<[IsARM, HasV6]>;
3582 def SMMLSR : AMul2Ia <0b0111010, 0b1111, (outs GPR:$Rd),
3583 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3584 IIC_iMAC32, "smmlsr", "\t$Rd, $Rn, $Rm, $Ra", []>,
3585 Requires<[IsARM, HasV6]>;
3587 multiclass AI_smul<string opc, PatFrag opnode> {
3588 def BB : AMulxyI<0b0001011, 0b00, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3589 IIC_iMUL16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm",
3590 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3591 (sext_inreg GPR:$Rm, i16)))]>,
3592 Requires<[IsARM, HasV5TE]>;
3594 def BT : AMulxyI<0b0001011, 0b10, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3595 IIC_iMUL16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm",
3596 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3597 (sra GPR:$Rm, (i32 16))))]>,
3598 Requires<[IsARM, HasV5TE]>;
3600 def TB : AMulxyI<0b0001011, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3601 IIC_iMUL16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm",
3602 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3603 (sext_inreg GPR:$Rm, i16)))]>,
3604 Requires<[IsARM, HasV5TE]>;
3606 def TT : AMulxyI<0b0001011, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3607 IIC_iMUL16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm",
3608 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3609 (sra GPR:$Rm, (i32 16))))]>,
3610 Requires<[IsARM, HasV5TE]>;
3612 def WB : AMulxyI<0b0001001, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3613 IIC_iMUL16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm",
3614 [(set GPR:$Rd, (sra (opnode GPR:$Rn,
3615 (sext_inreg GPR:$Rm, i16)), (i32 16)))]>,
3616 Requires<[IsARM, HasV5TE]>;
3618 def WT : AMulxyI<0b0001001, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3619 IIC_iMUL16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm",
3620 [(set GPR:$Rd, (sra (opnode GPR:$Rn,
3621 (sra GPR:$Rm, (i32 16))), (i32 16)))]>,
3622 Requires<[IsARM, HasV5TE]>;
3626 multiclass AI_smla<string opc, PatFrag opnode> {
3627 let DecoderMethod = "DecodeSMLAInstruction" in {
3628 def BB : AMulxyIa<0b0001000, 0b00, (outs GPRnopc:$Rd),
3629 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3630 IIC_iMAC16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra",
3631 [(set GPRnopc:$Rd, (add GPR:$Ra,
3632 (opnode (sext_inreg GPRnopc:$Rn, i16),
3633 (sext_inreg GPRnopc:$Rm, i16))))]>,
3634 Requires<[IsARM, HasV5TE]>;
3636 def BT : AMulxyIa<0b0001000, 0b10, (outs GPRnopc:$Rd),
3637 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3638 IIC_iMAC16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra",
3640 (add GPR:$Ra, (opnode (sext_inreg GPRnopc:$Rn, i16),
3641 (sra GPRnopc:$Rm, (i32 16)))))]>,
3642 Requires<[IsARM, HasV5TE]>;
3644 def TB : AMulxyIa<0b0001000, 0b01, (outs GPRnopc:$Rd),
3645 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3646 IIC_iMAC16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra",
3648 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
3649 (sext_inreg GPRnopc:$Rm, i16))))]>,
3650 Requires<[IsARM, HasV5TE]>;
3652 def TT : AMulxyIa<0b0001000, 0b11, (outs GPRnopc:$Rd),
3653 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3654 IIC_iMAC16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra",
3656 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
3657 (sra GPRnopc:$Rm, (i32 16)))))]>,
3658 Requires<[IsARM, HasV5TE]>;
3660 def WB : AMulxyIa<0b0001001, 0b00, (outs GPRnopc:$Rd),
3661 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3662 IIC_iMAC16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra",
3664 (add GPR:$Ra, (sra (opnode GPRnopc:$Rn,
3665 (sext_inreg GPRnopc:$Rm, i16)), (i32 16))))]>,
3666 Requires<[IsARM, HasV5TE]>;
3668 def WT : AMulxyIa<0b0001001, 0b10, (outs GPRnopc:$Rd),
3669 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3670 IIC_iMAC16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra",
3672 (add GPR:$Ra, (sra (opnode GPRnopc:$Rn,
3673 (sra GPRnopc:$Rm, (i32 16))), (i32 16))))]>,
3674 Requires<[IsARM, HasV5TE]>;
3678 defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
3679 defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
3681 // Halfword multiply accumulate long: SMLAL<x><y>.
3682 def SMLALBB : AMulxyI64<0b0001010, 0b00, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3683 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3684 IIC_iMAC64, "smlalbb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3685 Requires<[IsARM, HasV5TE]>;
3687 def SMLALBT : AMulxyI64<0b0001010, 0b10, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3688 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3689 IIC_iMAC64, "smlalbt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3690 Requires<[IsARM, HasV5TE]>;
3692 def SMLALTB : AMulxyI64<0b0001010, 0b01, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3693 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3694 IIC_iMAC64, "smlaltb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3695 Requires<[IsARM, HasV5TE]>;
3697 def SMLALTT : AMulxyI64<0b0001010, 0b11, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3698 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3699 IIC_iMAC64, "smlaltt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3700 Requires<[IsARM, HasV5TE]>;
3702 // Helper class for AI_smld.
3703 class AMulDualIbase<bit long, bit sub, bit swap, dag oops, dag iops,
3704 InstrItinClass itin, string opc, string asm>
3705 : AI<oops, iops, MulFrm, itin, opc, asm, []>, Requires<[IsARM, HasV6]> {
3708 let Inst{27-23} = 0b01110;
3709 let Inst{22} = long;
3710 let Inst{21-20} = 0b00;
3711 let Inst{11-8} = Rm;
3718 class AMulDualI<bit long, bit sub, bit swap, dag oops, dag iops,
3719 InstrItinClass itin, string opc, string asm>
3720 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
3722 let Inst{15-12} = 0b1111;
3723 let Inst{19-16} = Rd;
3725 class AMulDualIa<bit long, bit sub, bit swap, dag oops, dag iops,
3726 InstrItinClass itin, string opc, string asm>
3727 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
3730 let Inst{19-16} = Rd;
3731 let Inst{15-12} = Ra;
3733 class AMulDualI64<bit long, bit sub, bit swap, dag oops, dag iops,
3734 InstrItinClass itin, string opc, string asm>
3735 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
3738 let Inst{19-16} = RdHi;
3739 let Inst{15-12} = RdLo;
3742 multiclass AI_smld<bit sub, string opc> {
3744 def D : AMulDualIa<0, sub, 0, (outs GPRnopc:$Rd),
3745 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3746 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm, $Ra">;
3748 def DX: AMulDualIa<0, sub, 1, (outs GPRnopc:$Rd),
3749 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3750 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm, $Ra">;
3752 def LD: AMulDualI64<1, sub, 0, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3753 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
3754 !strconcat(opc, "ld"), "\t$RdLo, $RdHi, $Rn, $Rm">;
3756 def LDX : AMulDualI64<1, sub, 1, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3757 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
3758 !strconcat(opc, "ldx"),"\t$RdLo, $RdHi, $Rn, $Rm">;
3762 defm SMLA : AI_smld<0, "smla">;
3763 defm SMLS : AI_smld<1, "smls">;
3765 multiclass AI_sdml<bit sub, string opc> {
3767 def D:AMulDualI<0, sub, 0, (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm),
3768 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm">;
3769 def DX:AMulDualI<0, sub, 1, (outs GPRnopc:$Rd),(ins GPRnopc:$Rn, GPRnopc:$Rm),
3770 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm">;
3773 defm SMUA : AI_sdml<0, "smua">;
3774 defm SMUS : AI_sdml<1, "smus">;
3776 //===----------------------------------------------------------------------===//
3777 // Misc. Arithmetic Instructions.
3780 def CLZ : AMiscA1I<0b000010110, 0b0001, (outs GPR:$Rd), (ins GPR:$Rm),
3781 IIC_iUNAr, "clz", "\t$Rd, $Rm",
3782 [(set GPR:$Rd, (ctlz GPR:$Rm))]>, Requires<[IsARM, HasV5T]>;
3784 def RBIT : AMiscA1I<0b01101111, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
3785 IIC_iUNAr, "rbit", "\t$Rd, $Rm",
3786 [(set GPR:$Rd, (ARMrbit GPR:$Rm))]>,
3787 Requires<[IsARM, HasV6T2]>;
3789 def REV : AMiscA1I<0b01101011, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
3790 IIC_iUNAr, "rev", "\t$Rd, $Rm",
3791 [(set GPR:$Rd, (bswap GPR:$Rm))]>, Requires<[IsARM, HasV6]>;
3793 let AddedComplexity = 5 in
3794 def REV16 : AMiscA1I<0b01101011, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
3795 IIC_iUNAr, "rev16", "\t$Rd, $Rm",
3796 [(set GPR:$Rd, (rotr (bswap GPR:$Rm), (i32 16)))]>,
3797 Requires<[IsARM, HasV6]>;
3799 let AddedComplexity = 5 in
3800 def REVSH : AMiscA1I<0b01101111, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
3801 IIC_iUNAr, "revsh", "\t$Rd, $Rm",
3802 [(set GPR:$Rd, (sra (bswap GPR:$Rm), (i32 16)))]>,
3803 Requires<[IsARM, HasV6]>;
3805 def : ARMV6Pat<(or (sra (shl GPR:$Rm, (i32 24)), (i32 16)),
3806 (and (srl GPR:$Rm, (i32 8)), 0xFF)),
3809 def PKHBT : APKHI<0b01101000, 0, (outs GPRnopc:$Rd),
3810 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_lsl_amt:$sh),
3811 IIC_iALUsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh",
3812 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF),
3813 (and (shl GPRnopc:$Rm, pkh_lsl_amt:$sh),
3815 Requires<[IsARM, HasV6]>;
3817 // Alternate cases for PKHBT where identities eliminate some nodes.
3818 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (and GPRnopc:$Rm, 0xFFFF0000)),
3819 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, 0)>;
3820 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (shl GPRnopc:$Rm, imm16_31:$sh)),
3821 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, imm16_31:$sh)>;
3823 // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
3824 // will match the pattern below.
3825 def PKHTB : APKHI<0b01101000, 1, (outs GPRnopc:$Rd),
3826 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_asr_amt:$sh),
3827 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh",
3828 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF0000),
3829 (and (sra GPRnopc:$Rm, pkh_asr_amt:$sh),
3831 Requires<[IsARM, HasV6]>;
3833 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
3834 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
3835 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
3836 (srl GPRnopc:$src2, imm16_31:$sh)),
3837 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16_31:$sh)>;
3838 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
3839 (and (srl GPRnopc:$src2, imm1_15:$sh), 0xFFFF)),
3840 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm1_15:$sh)>;
3842 //===----------------------------------------------------------------------===//
3843 // Comparison Instructions...
3846 defm CMP : AI1_cmp_irs<0b1010, "cmp",
3847 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
3848 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
3850 // ARMcmpZ can re-use the above instruction definitions.
3851 def : ARMPat<(ARMcmpZ GPR:$src, so_imm:$imm),
3852 (CMPri GPR:$src, so_imm:$imm)>;
3853 def : ARMPat<(ARMcmpZ GPR:$src, GPR:$rhs),
3854 (CMPrr GPR:$src, GPR:$rhs)>;
3855 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_imm:$rhs),
3856 (CMPrsi GPR:$src, so_reg_imm:$rhs)>;
3857 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_reg:$rhs),
3858 (CMPrsr GPR:$src, so_reg_reg:$rhs)>;
3860 // FIXME: We have to be careful when using the CMN instruction and comparison
3861 // with 0. One would expect these two pieces of code should give identical
3877 // However, the CMN gives the *opposite* result when r1 is 0. This is because
3878 // the carry flag is set in the CMP case but not in the CMN case. In short, the
3879 // CMP instruction doesn't perform a truncate of the (logical) NOT of 0 plus the
3880 // value of r0 and the carry bit (because the "carry bit" parameter to
3881 // AddWithCarry is defined as 1 in this case, the carry flag will always be set
3882 // when r0 >= 0). The CMN instruction doesn't perform a NOT of 0 so there is
3883 // never a "carry" when this AddWithCarry is performed (because the "carry bit"
3884 // parameter to AddWithCarry is defined as 0).
3886 // When x is 0 and unsigned:
3890 // ~x + 1 = 0x1 0000 0000
3891 // (-x = 0) != (0x1 0000 0000 = ~x + 1)
3893 // Therefore, we should disable CMN when comparing against zero, until we can
3894 // limit when the CMN instruction is used (when we know that the RHS is not 0 or
3895 // when it's a comparison which doesn't look at the 'carry' flag).
3897 // (See the ARM docs for the "AddWithCarry" pseudo-code.)
3899 // This is related to <rdar://problem/7569620>.
3901 //defm CMN : AI1_cmp_irs<0b1011, "cmn",
3902 // BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>;
3904 // Note that TST/TEQ don't set all the same flags that CMP does!
3905 defm TST : AI1_cmp_irs<0b1000, "tst",
3906 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
3907 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>, 1>;
3908 defm TEQ : AI1_cmp_irs<0b1001, "teq",
3909 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
3910 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>, 1>;
3912 defm CMNz : AI1_cmp_irs<0b1011, "cmn",
3913 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
3914 BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>>;
3916 //def : ARMPat<(ARMcmp GPR:$src, so_imm_neg:$imm),
3917 // (CMNri GPR:$src, so_imm_neg:$imm)>;
3919 def : ARMPat<(ARMcmpZ GPR:$src, so_imm_neg:$imm),
3920 (CMNzri GPR:$src, so_imm_neg:$imm)>;
3922 // Pseudo i64 compares for some floating point compares.
3923 let usesCustomInserter = 1, isBranch = 1, isTerminator = 1,
3925 def BCCi64 : PseudoInst<(outs),
3926 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, brtarget:$dst),
3928 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, bb:$dst)]>;
3930 def BCCZi64 : PseudoInst<(outs),
3931 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, brtarget:$dst), IIC_Br,
3932 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, 0, 0, bb:$dst)]>;
3933 } // usesCustomInserter
3936 // Conditional moves
3937 // FIXME: should be able to write a pattern for ARMcmov, but can't use
3938 // a two-value operand where a dag node expects two operands. :(
3939 let neverHasSideEffects = 1 in {
3940 def MOVCCr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$false, GPR:$Rm, pred:$p),
3942 [/*(set GPR:$Rd, (ARMcmov GPR:$false, GPR:$Rm, imm:$cc, CCR:$ccr))*/]>,
3943 RegConstraint<"$false = $Rd">;
3944 def MOVCCsi : ARMPseudoInst<(outs GPR:$Rd),
3945 (ins GPR:$false, so_reg_imm:$shift, pred:$p),
3947 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_imm:$shift,
3948 imm:$cc, CCR:$ccr))*/]>,
3949 RegConstraint<"$false = $Rd">;
3950 def MOVCCsr : ARMPseudoInst<(outs GPR:$Rd),
3951 (ins GPR:$false, so_reg_reg:$shift, pred:$p),
3953 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_reg:$shift,
3954 imm:$cc, CCR:$ccr))*/]>,
3955 RegConstraint<"$false = $Rd">;
3958 let isMoveImm = 1 in
3959 def MOVCCi16 : ARMPseudoInst<(outs GPR:$Rd),
3960 (ins GPR:$false, imm0_65535_expr:$imm, pred:$p),
3963 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>;
3965 let isMoveImm = 1 in
3966 def MOVCCi : ARMPseudoInst<(outs GPR:$Rd),
3967 (ins GPR:$false, so_imm:$imm, pred:$p),
3969 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_imm:$imm, imm:$cc, CCR:$ccr))*/]>,
3970 RegConstraint<"$false = $Rd">;
3972 // Two instruction predicate mov immediate.
3973 let isMoveImm = 1 in
3974 def MOVCCi32imm : ARMPseudoInst<(outs GPR:$Rd),
3975 (ins GPR:$false, i32imm:$src, pred:$p),
3976 8, IIC_iCMOVix2, []>, RegConstraint<"$false = $Rd">;
3978 let isMoveImm = 1 in
3979 def MVNCCi : ARMPseudoInst<(outs GPR:$Rd),
3980 (ins GPR:$false, so_imm:$imm, pred:$p),
3982 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_imm_not:$imm, imm:$cc, CCR:$ccr))*/]>,
3983 RegConstraint<"$false = $Rd">;
3984 } // neverHasSideEffects
3986 //===----------------------------------------------------------------------===//
3987 // Atomic operations intrinsics
3990 def MemBarrierOptOperand : AsmOperandClass {
3991 let Name = "MemBarrierOpt";
3992 let ParserMethod = "parseMemBarrierOptOperand";
3994 def memb_opt : Operand<i32> {
3995 let PrintMethod = "printMemBOption";
3996 let ParserMatchClass = MemBarrierOptOperand;
3997 let DecoderMethod = "DecodeMemBarrierOption";
4000 // memory barriers protect the atomic sequences
4001 let hasSideEffects = 1 in {
4002 def DMB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4003 "dmb", "\t$opt", [(ARMMemBarrier (i32 imm:$opt))]>,
4004 Requires<[IsARM, HasDB]> {
4006 let Inst{31-4} = 0xf57ff05;
4007 let Inst{3-0} = opt;
4011 def DSB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4012 "dsb", "\t$opt", []>,
4013 Requires<[IsARM, HasDB]> {
4015 let Inst{31-4} = 0xf57ff04;
4016 let Inst{3-0} = opt;
4019 // ISB has only full system option
4020 def ISB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4021 "isb", "\t$opt", []>,
4022 Requires<[IsARM, HasDB]> {
4024 let Inst{31-4} = 0xf57ff06;
4025 let Inst{3-0} = opt;
4028 let usesCustomInserter = 1 in {
4029 let Defs = [CPSR] in {
4030 def ATOMIC_LOAD_ADD_I8 : PseudoInst<
4031 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4032 [(set GPR:$dst, (atomic_load_add_8 GPR:$ptr, GPR:$incr))]>;
4033 def ATOMIC_LOAD_SUB_I8 : PseudoInst<
4034 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4035 [(set GPR:$dst, (atomic_load_sub_8 GPR:$ptr, GPR:$incr))]>;
4036 def ATOMIC_LOAD_AND_I8 : PseudoInst<
4037 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4038 [(set GPR:$dst, (atomic_load_and_8 GPR:$ptr, GPR:$incr))]>;
4039 def ATOMIC_LOAD_OR_I8 : PseudoInst<
4040 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4041 [(set GPR:$dst, (atomic_load_or_8 GPR:$ptr, GPR:$incr))]>;
4042 def ATOMIC_LOAD_XOR_I8 : PseudoInst<
4043 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4044 [(set GPR:$dst, (atomic_load_xor_8 GPR:$ptr, GPR:$incr))]>;
4045 def ATOMIC_LOAD_NAND_I8 : PseudoInst<
4046 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4047 [(set GPR:$dst, (atomic_load_nand_8 GPR:$ptr, GPR:$incr))]>;
4048 def ATOMIC_LOAD_MIN_I8 : PseudoInst<
4049 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4050 [(set GPR:$dst, (atomic_load_min_8 GPR:$ptr, GPR:$val))]>;
4051 def ATOMIC_LOAD_MAX_I8 : PseudoInst<
4052 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4053 [(set GPR:$dst, (atomic_load_max_8 GPR:$ptr, GPR:$val))]>;
4054 def ATOMIC_LOAD_UMIN_I8 : PseudoInst<
4055 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4056 [(set GPR:$dst, (atomic_load_min_8 GPR:$ptr, GPR:$val))]>;
4057 def ATOMIC_LOAD_UMAX_I8 : PseudoInst<
4058 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4059 [(set GPR:$dst, (atomic_load_max_8 GPR:$ptr, GPR:$val))]>;
4060 def ATOMIC_LOAD_ADD_I16 : PseudoInst<
4061 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4062 [(set GPR:$dst, (atomic_load_add_16 GPR:$ptr, GPR:$incr))]>;
4063 def ATOMIC_LOAD_SUB_I16 : PseudoInst<
4064 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4065 [(set GPR:$dst, (atomic_load_sub_16 GPR:$ptr, GPR:$incr))]>;
4066 def ATOMIC_LOAD_AND_I16 : PseudoInst<
4067 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4068 [(set GPR:$dst, (atomic_load_and_16 GPR:$ptr, GPR:$incr))]>;
4069 def ATOMIC_LOAD_OR_I16 : PseudoInst<
4070 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4071 [(set GPR:$dst, (atomic_load_or_16 GPR:$ptr, GPR:$incr))]>;
4072 def ATOMIC_LOAD_XOR_I16 : PseudoInst<
4073 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4074 [(set GPR:$dst, (atomic_load_xor_16 GPR:$ptr, GPR:$incr))]>;
4075 def ATOMIC_LOAD_NAND_I16 : PseudoInst<
4076 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4077 [(set GPR:$dst, (atomic_load_nand_16 GPR:$ptr, GPR:$incr))]>;
4078 def ATOMIC_LOAD_MIN_I16 : PseudoInst<
4079 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4080 [(set GPR:$dst, (atomic_load_min_16 GPR:$ptr, GPR:$val))]>;
4081 def ATOMIC_LOAD_MAX_I16 : PseudoInst<
4082 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4083 [(set GPR:$dst, (atomic_load_max_16 GPR:$ptr, GPR:$val))]>;
4084 def ATOMIC_LOAD_UMIN_I16 : PseudoInst<
4085 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4086 [(set GPR:$dst, (atomic_load_min_16 GPR:$ptr, GPR:$val))]>;
4087 def ATOMIC_LOAD_UMAX_I16 : PseudoInst<
4088 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4089 [(set GPR:$dst, (atomic_load_max_16 GPR:$ptr, GPR:$val))]>;
4090 def ATOMIC_LOAD_ADD_I32 : PseudoInst<
4091 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4092 [(set GPR:$dst, (atomic_load_add_32 GPR:$ptr, GPR:$incr))]>;
4093 def ATOMIC_LOAD_SUB_I32 : PseudoInst<
4094 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4095 [(set GPR:$dst, (atomic_load_sub_32 GPR:$ptr, GPR:$incr))]>;
4096 def ATOMIC_LOAD_AND_I32 : PseudoInst<
4097 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4098 [(set GPR:$dst, (atomic_load_and_32 GPR:$ptr, GPR:$incr))]>;
4099 def ATOMIC_LOAD_OR_I32 : PseudoInst<
4100 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4101 [(set GPR:$dst, (atomic_load_or_32 GPR:$ptr, GPR:$incr))]>;
4102 def ATOMIC_LOAD_XOR_I32 : PseudoInst<
4103 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4104 [(set GPR:$dst, (atomic_load_xor_32 GPR:$ptr, GPR:$incr))]>;
4105 def ATOMIC_LOAD_NAND_I32 : PseudoInst<
4106 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4107 [(set GPR:$dst, (atomic_load_nand_32 GPR:$ptr, GPR:$incr))]>;
4108 def ATOMIC_LOAD_MIN_I32 : PseudoInst<
4109 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4110 [(set GPR:$dst, (atomic_load_min_32 GPR:$ptr, GPR:$val))]>;
4111 def ATOMIC_LOAD_MAX_I32 : PseudoInst<
4112 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4113 [(set GPR:$dst, (atomic_load_max_32 GPR:$ptr, GPR:$val))]>;
4114 def ATOMIC_LOAD_UMIN_I32 : PseudoInst<
4115 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4116 [(set GPR:$dst, (atomic_load_min_32 GPR:$ptr, GPR:$val))]>;
4117 def ATOMIC_LOAD_UMAX_I32 : PseudoInst<
4118 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4119 [(set GPR:$dst, (atomic_load_max_32 GPR:$ptr, GPR:$val))]>;
4121 def ATOMIC_SWAP_I8 : PseudoInst<
4122 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
4123 [(set GPR:$dst, (atomic_swap_8 GPR:$ptr, GPR:$new))]>;
4124 def ATOMIC_SWAP_I16 : PseudoInst<
4125 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
4126 [(set GPR:$dst, (atomic_swap_16 GPR:$ptr, GPR:$new))]>;
4127 def ATOMIC_SWAP_I32 : PseudoInst<
4128 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
4129 [(set GPR:$dst, (atomic_swap_32 GPR:$ptr, GPR:$new))]>;
4131 def ATOMIC_CMP_SWAP_I8 : PseudoInst<
4132 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
4133 [(set GPR:$dst, (atomic_cmp_swap_8 GPR:$ptr, GPR:$old, GPR:$new))]>;
4134 def ATOMIC_CMP_SWAP_I16 : PseudoInst<
4135 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
4136 [(set GPR:$dst, (atomic_cmp_swap_16 GPR:$ptr, GPR:$old, GPR:$new))]>;
4137 def ATOMIC_CMP_SWAP_I32 : PseudoInst<
4138 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
4139 [(set GPR:$dst, (atomic_cmp_swap_32 GPR:$ptr, GPR:$old, GPR:$new))]>;
4143 let mayLoad = 1 in {
4144 def LDREXB : AIldrex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4146 "ldrexb", "\t$Rt, $addr", []>;
4147 def LDREXH : AIldrex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4148 NoItinerary, "ldrexh", "\t$Rt, $addr", []>;
4149 def LDREX : AIldrex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4150 NoItinerary, "ldrex", "\t$Rt, $addr", []>;
4151 let hasExtraDefRegAllocReq = 1 in
4152 def LDREXD: AIldrex<0b01, (outs GPR:$Rt, GPR:$Rt2),(ins addr_offset_none:$addr),
4153 NoItinerary, "ldrexd", "\t$Rt, $Rt2, $addr", []> {
4154 let DecoderMethod = "DecodeDoubleRegLoad";
4158 let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
4159 def STREXB: AIstrex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4160 NoItinerary, "strexb", "\t$Rd, $Rt, $addr", []>;
4161 def STREXH: AIstrex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4162 NoItinerary, "strexh", "\t$Rd, $Rt, $addr", []>;
4163 def STREX : AIstrex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4164 NoItinerary, "strex", "\t$Rd, $Rt, $addr", []>;
4167 let hasExtraSrcRegAllocReq = 1, Constraints = "@earlyclobber $Rd" in
4168 def STREXD : AIstrex<0b01, (outs GPR:$Rd),
4169 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr),
4170 NoItinerary, "strexd", "\t$Rd, $Rt, $Rt2, $addr", []> {
4171 let DecoderMethod = "DecodeDoubleRegStore";
4174 def CLREX : AXI<(outs), (ins), MiscFrm, NoItinerary, "clrex", []>,
4175 Requires<[IsARM, HasV7]> {
4176 let Inst{31-0} = 0b11110101011111111111000000011111;
4179 // SWP/SWPB are deprecated in V6/V7.
4180 let mayLoad = 1, mayStore = 1 in {
4181 def SWP : AIswp<0, (outs GPR:$Rt), (ins GPR:$Rt2, addr_offset_none:$addr),
4183 def SWPB: AIswp<1, (outs GPR:$Rt), (ins GPR:$Rt2, addr_offset_none:$addr),
4187 //===----------------------------------------------------------------------===//
4188 // Coprocessor Instructions.
4191 def CDP : ABI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4192 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4193 NoItinerary, "cdp", "\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4194 [(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4195 imm:$CRm, imm:$opc2)]> {
4203 let Inst{3-0} = CRm;
4205 let Inst{7-5} = opc2;
4206 let Inst{11-8} = cop;
4207 let Inst{15-12} = CRd;
4208 let Inst{19-16} = CRn;
4209 let Inst{23-20} = opc1;
4212 def CDP2 : ABXI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4213 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4214 NoItinerary, "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4215 [(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4216 imm:$CRm, imm:$opc2)]> {
4217 let Inst{31-28} = 0b1111;
4225 let Inst{3-0} = CRm;
4227 let Inst{7-5} = opc2;
4228 let Inst{11-8} = cop;
4229 let Inst{15-12} = CRd;
4230 let Inst{19-16} = CRn;
4231 let Inst{23-20} = opc1;
4234 class ACI<dag oops, dag iops, string opc, string asm,
4235 IndexMode im = IndexModeNone>
4236 : InoP<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
4238 let Inst{27-25} = 0b110;
4241 multiclass LdStCop<bits<4> op31_28, bit load, dag ops, string opc, string cond>{
4242 def _OFFSET : ACI<(outs),
4243 !con((ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr), ops),
4244 !strconcat(opc, cond), "\tp$cop, cr$CRd, $addr"> {
4245 let Inst{31-28} = op31_28;
4246 let Inst{24} = 1; // P = 1
4247 let Inst{21} = 0; // W = 0
4248 let Inst{22} = 0; // D = 0
4249 let Inst{20} = load;
4250 let DecoderMethod = "DecodeCopMemInstruction";
4253 def _PRE : ACI<(outs),
4254 !con((ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr), ops),
4255 !strconcat(opc, cond), "\tp$cop, cr$CRd, $addr!", IndexModePre> {
4256 let Inst{31-28} = op31_28;
4257 let Inst{24} = 1; // P = 1
4258 let Inst{21} = 1; // W = 1
4259 let Inst{22} = 0; // D = 0
4260 let Inst{20} = load;
4261 let DecoderMethod = "DecodeCopMemInstruction";
4264 def _POST : ACI<(outs),
4265 !con((ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr), ops),
4266 !strconcat(opc, cond), "\tp$cop, cr$CRd, $addr", IndexModePost> {
4267 let Inst{31-28} = op31_28;
4268 let Inst{24} = 0; // P = 0
4269 let Inst{21} = 1; // W = 1
4270 let Inst{22} = 0; // D = 0
4271 let Inst{20} = load;
4272 let DecoderMethod = "DecodeCopMemInstruction";
4275 def _OPTION : ACI<(outs),
4276 !con((ins nohash_imm:$cop,nohash_imm:$CRd,GPR:$base, nohash_imm:$option),
4278 !strconcat(opc, cond), "\tp$cop, cr$CRd, [$base], \\{$option\\}"> {
4279 let Inst{31-28} = op31_28;
4280 let Inst{24} = 0; // P = 0
4281 let Inst{23} = 1; // U = 1
4282 let Inst{21} = 0; // W = 0
4283 let Inst{22} = 0; // D = 0
4284 let Inst{20} = load;
4285 let DecoderMethod = "DecodeCopMemInstruction";
4288 def L_OFFSET : ACI<(outs),
4289 !con((ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr), ops),
4290 !strconcat(!strconcat(opc, "l"), cond), "\tp$cop, cr$CRd, $addr"> {
4291 let Inst{31-28} = op31_28;
4292 let Inst{24} = 1; // P = 1
4293 let Inst{21} = 0; // W = 0
4294 let Inst{22} = 1; // D = 1
4295 let Inst{20} = load;
4296 let DecoderMethod = "DecodeCopMemInstruction";
4299 def L_PRE : ACI<(outs),
4300 !con((ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr), ops),
4301 !strconcat(!strconcat(opc, "l"), cond), "\tp$cop, cr$CRd, $addr!",
4303 let Inst{31-28} = op31_28;
4304 let Inst{24} = 1; // P = 1
4305 let Inst{21} = 1; // W = 1
4306 let Inst{22} = 1; // D = 1
4307 let Inst{20} = load;
4308 let DecoderMethod = "DecodeCopMemInstruction";
4311 def L_POST : ACI<(outs),
4312 !con((ins nohash_imm:$cop, nohash_imm:$CRd, addr_offset_none:$addr,
4313 postidx_imm8s4:$offset), ops),
4314 !strconcat(!strconcat(opc, "l"), cond), "\tp$cop, cr$CRd, $addr, $offset",
4316 let Inst{31-28} = op31_28;
4317 let Inst{24} = 0; // P = 0
4318 let Inst{21} = 1; // W = 1
4319 let Inst{22} = 1; // D = 1
4320 let Inst{20} = load;
4321 let DecoderMethod = "DecodeCopMemInstruction";
4324 def L_OPTION : ACI<(outs),
4325 !con((ins nohash_imm:$cop, nohash_imm:$CRd,GPR:$base,nohash_imm:$option),
4327 !strconcat(!strconcat(opc, "l"), cond),
4328 "\tp$cop, cr$CRd, [$base], \\{$option\\}"> {
4329 let Inst{31-28} = op31_28;
4330 let Inst{24} = 0; // P = 0
4331 let Inst{23} = 1; // U = 1
4332 let Inst{21} = 0; // W = 0
4333 let Inst{22} = 1; // D = 1
4334 let Inst{20} = load;
4335 let DecoderMethod = "DecodeCopMemInstruction";
4339 defm LDC : LdStCop<{?,?,?,?}, 1, (ins pred:$p), "ldc", "${p}">;
4340 defm LDC2 : LdStCop<0b1111, 1, (ins), "ldc2", "">;
4341 defm STC : LdStCop<{?,?,?,?}, 0, (ins pred:$p), "stc", "${p}">;
4342 defm STC2 : LdStCop<0b1111, 0, (ins), "stc2", "">;
4344 //===----------------------------------------------------------------------===//
4345 // Move between coprocessor and ARM core register.
4348 class MovRCopro<string opc, bit direction, dag oops, dag iops,
4350 : ABI<0b1110, oops, iops, NoItinerary, opc,
4351 "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2", pattern> {
4352 let Inst{20} = direction;
4362 let Inst{15-12} = Rt;
4363 let Inst{11-8} = cop;
4364 let Inst{23-21} = opc1;
4365 let Inst{7-5} = opc2;
4366 let Inst{3-0} = CRm;
4367 let Inst{19-16} = CRn;
4370 def MCR : MovRCopro<"mcr", 0 /* from ARM core register to coprocessor */,
4372 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4373 c_imm:$CRm, imm0_7:$opc2),
4374 [(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
4375 imm:$CRm, imm:$opc2)]>;
4376 def MRC : MovRCopro<"mrc", 1 /* from coprocessor to ARM core register */,
4378 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
4381 def : ARMPat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
4382 (MRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
4384 class MovRCopro2<string opc, bit direction, dag oops, dag iops,
4386 : ABXI<0b1110, oops, iops, NoItinerary,
4387 !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), pattern> {
4388 let Inst{31-28} = 0b1111;
4389 let Inst{20} = direction;
4399 let Inst{15-12} = Rt;
4400 let Inst{11-8} = cop;
4401 let Inst{23-21} = opc1;
4402 let Inst{7-5} = opc2;
4403 let Inst{3-0} = CRm;
4404 let Inst{19-16} = CRn;
4407 def MCR2 : MovRCopro2<"mcr2", 0 /* from ARM core register to coprocessor */,
4409 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4410 c_imm:$CRm, imm0_7:$opc2),
4411 [(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
4412 imm:$CRm, imm:$opc2)]>;
4413 def MRC2 : MovRCopro2<"mrc2", 1 /* from coprocessor to ARM core register */,
4415 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
4418 def : ARMV5TPat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn,
4419 imm:$CRm, imm:$opc2),
4420 (MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
4422 class MovRRCopro<string opc, bit direction, list<dag> pattern = []>
4423 : ABI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4424 GPR:$Rt, GPR:$Rt2, c_imm:$CRm),
4425 NoItinerary, opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm", pattern> {
4426 let Inst{23-21} = 0b010;
4427 let Inst{20} = direction;
4435 let Inst{15-12} = Rt;
4436 let Inst{19-16} = Rt2;
4437 let Inst{11-8} = cop;
4438 let Inst{7-4} = opc1;
4439 let Inst{3-0} = CRm;
4442 def MCRR : MovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */,
4443 [(int_arm_mcrr imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2,
4445 def MRRC : MovRRCopro<"mrrc", 1 /* from coprocessor to ARM core register */>;
4447 class MovRRCopro2<string opc, bit direction, list<dag> pattern = []>
4448 : ABXI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4449 GPR:$Rt, GPR:$Rt2, c_imm:$CRm), NoItinerary,
4450 !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern> {
4451 let Inst{31-28} = 0b1111;
4452 let Inst{23-21} = 0b010;
4453 let Inst{20} = direction;
4461 let Inst{15-12} = Rt;
4462 let Inst{19-16} = Rt2;
4463 let Inst{11-8} = cop;
4464 let Inst{7-4} = opc1;
4465 let Inst{3-0} = CRm;
4468 def MCRR2 : MovRRCopro2<"mcrr2", 0 /* from ARM core register to coprocessor */,
4469 [(int_arm_mcrr2 imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2,
4471 def MRRC2 : MovRRCopro2<"mrrc2", 1 /* from coprocessor to ARM core register */>;
4473 //===----------------------------------------------------------------------===//
4474 // Move between special register and ARM core register
4477 // Move to ARM core register from Special Register
4478 def MRS : ABI<0b0001, (outs GPR:$Rd), (ins), NoItinerary,
4479 "mrs", "\t$Rd, apsr", []> {
4481 let Inst{23-16} = 0b00001111;
4482 let Inst{15-12} = Rd;
4483 let Inst{7-4} = 0b0000;
4486 def : InstAlias<"mrs${p} $Rd, cpsr", (MRS GPR:$Rd, pred:$p)>, Requires<[IsARM]>;
4488 def MRSsys : ABI<0b0001, (outs GPR:$Rd), (ins), NoItinerary,
4489 "mrs", "\t$Rd, spsr", []> {
4491 let Inst{23-16} = 0b01001111;
4492 let Inst{15-12} = Rd;
4493 let Inst{7-4} = 0b0000;
4496 // Move from ARM core register to Special Register
4498 // No need to have both system and application versions, the encodings are the
4499 // same and the assembly parser has no way to distinguish between them. The mask
4500 // operand contains the special register (R Bit) in bit 4 and bits 3-0 contains
4501 // the mask with the fields to be accessed in the special register.
4502 def MSR : ABI<0b0001, (outs), (ins msr_mask:$mask, GPR:$Rn), NoItinerary,
4503 "msr", "\t$mask, $Rn", []> {
4508 let Inst{22} = mask{4}; // R bit
4509 let Inst{21-20} = 0b10;
4510 let Inst{19-16} = mask{3-0};
4511 let Inst{15-12} = 0b1111;
4512 let Inst{11-4} = 0b00000000;
4516 def MSRi : ABI<0b0011, (outs), (ins msr_mask:$mask, so_imm:$a), NoItinerary,
4517 "msr", "\t$mask, $a", []> {
4522 let Inst{22} = mask{4}; // R bit
4523 let Inst{21-20} = 0b10;
4524 let Inst{19-16} = mask{3-0};
4525 let Inst{15-12} = 0b1111;
4529 //===----------------------------------------------------------------------===//
4533 // __aeabi_read_tp preserves the registers r1-r3.
4534 // This is a pseudo inst so that we can get the encoding right,
4535 // complete with fixup for the aeabi_read_tp function.
4537 Defs = [R0, R12, LR, CPSR], Uses = [SP] in {
4538 def TPsoft : PseudoInst<(outs), (ins), IIC_Br,
4539 [(set R0, ARMthread_pointer)]>;
4542 //===----------------------------------------------------------------------===//
4543 // SJLJ Exception handling intrinsics
4544 // eh_sjlj_setjmp() is an instruction sequence to store the return
4545 // address and save #0 in R0 for the non-longjmp case.
4546 // Since by its nature we may be coming from some other function to get
4547 // here, and we're using the stack frame for the containing function to
4548 // save/restore registers, we can't keep anything live in regs across
4549 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
4550 // when we get here from a longjmp(). We force everything out of registers
4551 // except for our own input by listing the relevant registers in Defs. By
4552 // doing so, we also cause the prologue/epilogue code to actively preserve
4553 // all of the callee-saved resgisters, which is exactly what we want.
4554 // A constant value is passed in $val, and we use the location as a scratch.
4556 // These are pseudo-instructions and are lowered to individual MC-insts, so
4557 // no encoding information is necessary.
4559 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
4560 QQQQ0, QQQQ1, QQQQ2, QQQQ3 ], hasSideEffects = 1, isBarrier = 1 in {
4561 def Int_eh_sjlj_setjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
4563 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
4564 Requires<[IsARM, HasVFP2]>;
4568 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
4569 hasSideEffects = 1, isBarrier = 1 in {
4570 def Int_eh_sjlj_setjmp_nofp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
4572 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
4573 Requires<[IsARM, NoVFP]>;
4576 // FIXME: Non-Darwin version(s)
4577 let isBarrier = 1, hasSideEffects = 1, isTerminator = 1,
4578 Defs = [ R7, LR, SP ] in {
4579 def Int_eh_sjlj_longjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$scratch),
4581 [(ARMeh_sjlj_longjmp GPR:$src, GPR:$scratch)]>,
4582 Requires<[IsARM, IsDarwin]>;
4585 // eh.sjlj.dispatchsetup pseudo-instruction.
4586 // This pseudo is used for ARM, Thumb1 and Thumb2. Any differences are
4587 // handled when the pseudo is expanded (which happens before any passes
4588 // that need the instruction size).
4589 let isBarrier = 1, hasSideEffects = 1 in
4590 def Int_eh_sjlj_dispatchsetup :
4591 PseudoInst<(outs), (ins GPR:$src), NoItinerary,
4592 [(ARMeh_sjlj_dispatchsetup GPR:$src)]>,
4593 Requires<[IsDarwin]>;
4595 //===----------------------------------------------------------------------===//
4596 // Non-Instruction Patterns
4599 // ARMv4 indirect branch using (MOVr PC, dst)
4600 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in
4601 def MOVPCRX : ARMPseudoExpand<(outs), (ins GPR:$dst),
4602 4, IIC_Br, [(brind GPR:$dst)],
4603 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>,
4604 Requires<[IsARM, NoV4T]>;
4606 // Large immediate handling.
4608 // 32-bit immediate using two piece so_imms or movw + movt.
4609 // This is a single pseudo instruction, the benefit is that it can be remat'd
4610 // as a single unit instead of having to handle reg inputs.
4611 // FIXME: Remove this when we can do generalized remat.
4612 let isReMaterializable = 1, isMoveImm = 1 in
4613 def MOVi32imm : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
4614 [(set GPR:$dst, (arm_i32imm:$src))]>,
4617 // Pseudo instruction that combines movw + movt + add pc (if PIC).
4618 // It also makes it possible to rematerialize the instructions.
4619 // FIXME: Remove this when we can do generalized remat and when machine licm
4620 // can properly the instructions.
4621 let isReMaterializable = 1 in {
4622 def MOV_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
4624 [(set GPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>,
4625 Requires<[IsARM, UseMovt]>;
4627 def MOV_ga_dyn : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
4629 [(set GPR:$dst, (ARMWrapperDYN tglobaladdr:$addr))]>,
4630 Requires<[IsARM, UseMovt]>;
4632 let AddedComplexity = 10 in
4633 def MOV_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
4635 [(set GPR:$dst, (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
4636 Requires<[IsARM, UseMovt]>;
4637 } // isReMaterializable
4639 // ConstantPool, GlobalAddress, and JumpTable
4640 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (LEApcrel tglobaladdr :$dst)>,
4641 Requires<[IsARM, DontUseMovt]>;
4642 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
4643 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
4644 Requires<[IsARM, UseMovt]>;
4645 def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
4646 (LEApcrelJT tjumptable:$dst, imm:$id)>;
4648 // TODO: add,sub,and, 3-instr forms?
4651 def : ARMPat<(ARMtcret tcGPR:$dst),
4652 (TCRETURNri tcGPR:$dst)>, Requires<[IsDarwin]>;
4654 def : ARMPat<(ARMtcret (i32 tglobaladdr:$dst)),
4655 (TCRETURNdi texternalsym:$dst)>, Requires<[IsDarwin]>;
4657 def : ARMPat<(ARMtcret (i32 texternalsym:$dst)),
4658 (TCRETURNdi texternalsym:$dst)>, Requires<[IsDarwin]>;
4660 def : ARMPat<(ARMtcret tcGPR:$dst),
4661 (TCRETURNriND tcGPR:$dst)>, Requires<[IsNotDarwin]>;
4663 def : ARMPat<(ARMtcret (i32 tglobaladdr:$dst)),
4664 (TCRETURNdiND texternalsym:$dst)>, Requires<[IsNotDarwin]>;
4666 def : ARMPat<(ARMtcret (i32 texternalsym:$dst)),
4667 (TCRETURNdiND texternalsym:$dst)>, Requires<[IsNotDarwin]>;
4670 def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>,
4671 Requires<[IsARM, IsNotDarwin]>;
4672 def : ARMPat<(ARMcall texternalsym:$func), (BLr9 texternalsym:$func)>,
4673 Requires<[IsARM, IsDarwin]>;
4675 // zextload i1 -> zextload i8
4676 def : ARMPat<(zextloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
4677 def : ARMPat<(zextloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
4679 // extload -> zextload
4680 def : ARMPat<(extloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
4681 def : ARMPat<(extloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
4682 def : ARMPat<(extloadi8 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
4683 def : ARMPat<(extloadi8 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
4685 def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
4687 def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
4688 def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
4691 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4692 (sra (shl GPR:$b, (i32 16)), (i32 16))),
4693 (SMULBB GPR:$a, GPR:$b)>;
4694 def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
4695 (SMULBB GPR:$a, GPR:$b)>;
4696 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4697 (sra GPR:$b, (i32 16))),
4698 (SMULBT GPR:$a, GPR:$b)>;
4699 def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, (i32 16))),
4700 (SMULBT GPR:$a, GPR:$b)>;
4701 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)),
4702 (sra (shl GPR:$b, (i32 16)), (i32 16))),
4703 (SMULTB GPR:$a, GPR:$b)>;
4704 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), sext_16_node:$b),
4705 (SMULTB GPR:$a, GPR:$b)>;
4706 def : ARMV5TEPat<(sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
4708 (SMULWB GPR:$a, GPR:$b)>;
4709 def : ARMV5TEPat<(sra (mul GPR:$a, sext_16_node:$b), (i32 16)),
4710 (SMULWB GPR:$a, GPR:$b)>;
4712 def : ARMV5TEPat<(add GPR:$acc,
4713 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4714 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
4715 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
4716 def : ARMV5TEPat<(add GPR:$acc,
4717 (mul sext_16_node:$a, sext_16_node:$b)),
4718 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
4719 def : ARMV5TEPat<(add GPR:$acc,
4720 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4721 (sra GPR:$b, (i32 16)))),
4722 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
4723 def : ARMV5TEPat<(add GPR:$acc,
4724 (mul sext_16_node:$a, (sra GPR:$b, (i32 16)))),
4725 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
4726 def : ARMV5TEPat<(add GPR:$acc,
4727 (mul (sra GPR:$a, (i32 16)),
4728 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
4729 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
4730 def : ARMV5TEPat<(add GPR:$acc,
4731 (mul (sra GPR:$a, (i32 16)), sext_16_node:$b)),
4732 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
4733 def : ARMV5TEPat<(add GPR:$acc,
4734 (sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
4736 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
4737 def : ARMV5TEPat<(add GPR:$acc,
4738 (sra (mul GPR:$a, sext_16_node:$b), (i32 16))),
4739 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
4742 // Pre-v7 uses MCR for synchronization barriers.
4743 def : ARMPat<(ARMMemBarrierMCR GPR:$zero), (MCR 15, 0, GPR:$zero, 7, 10, 5)>,
4744 Requires<[IsARM, HasV6]>;
4746 // SXT/UXT with no rotate
4747 let AddedComplexity = 16 in {
4748 def : ARMV6Pat<(and GPR:$Src, 0x000000FF), (UXTB GPR:$Src, 0)>;
4749 def : ARMV6Pat<(and GPR:$Src, 0x0000FFFF), (UXTH GPR:$Src, 0)>;
4750 def : ARMV6Pat<(and GPR:$Src, 0x00FF00FF), (UXTB16 GPR:$Src, 0)>;
4751 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0x00FF)),
4752 (UXTAB GPR:$Rn, GPR:$Rm, 0)>;
4753 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0xFFFF)),
4754 (UXTAH GPR:$Rn, GPR:$Rm, 0)>;
4757 def : ARMV6Pat<(sext_inreg GPR:$Src, i8), (SXTB GPR:$Src, 0)>;
4758 def : ARMV6Pat<(sext_inreg GPR:$Src, i16), (SXTH GPR:$Src, 0)>;
4760 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i8)),
4761 (SXTAB GPR:$Rn, GPRnopc:$Rm, 0)>;
4762 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i16)),
4763 (SXTAH GPR:$Rn, GPRnopc:$Rm, 0)>;
4765 // Atomic load/store patterns
4766 def : ARMPat<(atomic_load_8 ldst_so_reg:$src),
4767 (LDRBrs ldst_so_reg:$src)>;
4768 def : ARMPat<(atomic_load_8 addrmode_imm12:$src),
4769 (LDRBi12 addrmode_imm12:$src)>;
4770 def : ARMPat<(atomic_load_16 addrmode3:$src),
4771 (LDRH addrmode3:$src)>;
4772 def : ARMPat<(atomic_load_32 ldst_so_reg:$src),
4773 (LDRrs ldst_so_reg:$src)>;
4774 def : ARMPat<(atomic_load_32 addrmode_imm12:$src),
4775 (LDRi12 addrmode_imm12:$src)>;
4776 def : ARMPat<(atomic_store_8 ldst_so_reg:$ptr, GPR:$val),
4777 (STRBrs GPR:$val, ldst_so_reg:$ptr)>;
4778 def : ARMPat<(atomic_store_8 addrmode_imm12:$ptr, GPR:$val),
4779 (STRBi12 GPR:$val, addrmode_imm12:$ptr)>;
4780 def : ARMPat<(atomic_store_16 addrmode3:$ptr, GPR:$val),
4781 (STRH GPR:$val, addrmode3:$ptr)>;
4782 def : ARMPat<(atomic_store_32 ldst_so_reg:$ptr, GPR:$val),
4783 (STRrs GPR:$val, ldst_so_reg:$ptr)>;
4784 def : ARMPat<(atomic_store_32 addrmode_imm12:$ptr, GPR:$val),
4785 (STRi12 GPR:$val, addrmode_imm12:$ptr)>;
4788 //===----------------------------------------------------------------------===//
4792 include "ARMInstrThumb.td"
4794 //===----------------------------------------------------------------------===//
4798 include "ARMInstrThumb2.td"
4800 //===----------------------------------------------------------------------===//
4801 // Floating Point Support
4804 include "ARMInstrVFP.td"
4806 //===----------------------------------------------------------------------===//
4807 // Advanced SIMD (NEON) Support
4810 include "ARMInstrNEON.td"
4812 //===----------------------------------------------------------------------===//
4813 // Assembler aliases
4817 def : InstAlias<"dmb", (DMB 0xf)>, Requires<[IsARM, HasDB]>;
4818 def : InstAlias<"dsb", (DSB 0xf)>, Requires<[IsARM, HasDB]>;
4819 def : InstAlias<"isb", (ISB 0xf)>, Requires<[IsARM, HasDB]>;
4821 // System instructions
4822 def : MnemonicAlias<"swi", "svc">;
4824 // Load / Store Multiple
4825 def : MnemonicAlias<"ldmfd", "ldm">;
4826 def : MnemonicAlias<"ldmia", "ldm">;
4827 def : MnemonicAlias<"ldmea", "ldmdb">;
4828 def : MnemonicAlias<"stmfd", "stmdb">;
4829 def : MnemonicAlias<"stmia", "stm">;
4830 def : MnemonicAlias<"stmea", "stm">;
4832 // PKHBT/PKHTB with default shift amount. PKHTB is equivalent to PKHBT when the
4833 // shift amount is zero (i.e., unspecified).
4834 def : InstAlias<"pkhbt${p} $Rd, $Rn, $Rm",
4835 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
4836 Requires<[IsARM, HasV6]>;
4837 def : InstAlias<"pkhtb${p} $Rd, $Rn, $Rm",
4838 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
4839 Requires<[IsARM, HasV6]>;
4841 // PUSH/POP aliases for STM/LDM
4842 def : ARMInstAlias<"push${p} $regs", (STMDB_UPD SP, pred:$p, reglist:$regs)>;
4843 def : ARMInstAlias<"pop${p} $regs", (LDMIA_UPD SP, pred:$p, reglist:$regs)>;
4845 // SSAT/USAT optional shift operand.
4846 def : ARMInstAlias<"ssat${p} $Rd, $sat_imm, $Rn",
4847 (SSAT GPRnopc:$Rd, imm1_32:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
4848 def : ARMInstAlias<"usat${p} $Rd, $sat_imm, $Rn",
4849 (USAT GPRnopc:$Rd, imm0_31:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
4852 // Extend instruction optional rotate operand.
4853 def : ARMInstAlias<"sxtab${p} $Rd, $Rn, $Rm",
4854 (SXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4855 def : ARMInstAlias<"sxtah${p} $Rd, $Rn, $Rm",
4856 (SXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4857 def : ARMInstAlias<"sxtab16${p} $Rd, $Rn, $Rm",
4858 (SXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4859 def : ARMInstAlias<"sxtb${p} $Rd, $Rm",
4860 (SXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4861 def : ARMInstAlias<"sxtb16${p} $Rd, $Rm",
4862 (SXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4863 def : ARMInstAlias<"sxth${p} $Rd, $Rm",
4864 (SXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4866 def : ARMInstAlias<"uxtab${p} $Rd, $Rn, $Rm",
4867 (UXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4868 def : ARMInstAlias<"uxtah${p} $Rd, $Rn, $Rm",
4869 (UXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4870 def : ARMInstAlias<"uxtab16${p} $Rd, $Rn, $Rm",
4871 (UXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4872 def : ARMInstAlias<"uxtb${p} $Rd, $Rm",
4873 (UXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4874 def : ARMInstAlias<"uxtb16${p} $Rd, $Rm",
4875 (UXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4876 def : ARMInstAlias<"uxth${p} $Rd, $Rm",
4877 (UXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4881 def : MnemonicAlias<"rfefa", "rfeda">;
4882 def : MnemonicAlias<"rfeea", "rfedb">;
4883 def : MnemonicAlias<"rfefd", "rfeia">;
4884 def : MnemonicAlias<"rfeed", "rfeib">;
4885 def : MnemonicAlias<"rfe", "rfeia">;
4888 def : MnemonicAlias<"srsfa", "srsda">;
4889 def : MnemonicAlias<"srsea", "srsdb">;
4890 def : MnemonicAlias<"srsfd", "srsia">;
4891 def : MnemonicAlias<"srsed", "srsib">;
4892 def : MnemonicAlias<"srs", "srsia">;
4895 def : MnemonicAlias<"qsubaddx", "qsax">;
4897 def : MnemonicAlias<"saddsubx", "sasx">;
4898 // SHASX == SHADDSUBX
4899 def : MnemonicAlias<"shaddsubx", "shasx">;
4900 // SHSAX == SHSUBADDX
4901 def : MnemonicAlias<"shsubaddx", "shsax">;
4903 def : MnemonicAlias<"ssubaddx", "ssax">;
4905 def : MnemonicAlias<"uaddsubx", "uasx">;
4906 // UHASX == UHADDSUBX
4907 def : MnemonicAlias<"uhaddsubx", "uhasx">;
4908 // UHSAX == UHSUBADDX
4909 def : MnemonicAlias<"uhsubaddx", "uhsax">;
4910 // UQASX == UQADDSUBX
4911 def : MnemonicAlias<"uqaddsubx", "uqasx">;
4912 // UQSAX == UQSUBADDX
4913 def : MnemonicAlias<"uqsubaddx", "uqsax">;
4915 def : MnemonicAlias<"usubaddx", "usax">;
4917 // LDRSBT/LDRHT/LDRSHT post-index offset if optional.
4918 // Note that the write-back output register is a dummy operand for MC (it's
4919 // only meaningful for codegen), so we just pass zero here.
4920 // FIXME: tblgen not cooperating with argument conversions.
4921 //def : InstAlias<"ldrsbt${p} $Rt, $addr",
4922 // (LDRSBTi GPR:$Rt, GPR:$Rt, addr_offset_none:$addr, 0,pred:$p)>;
4923 //def : InstAlias<"ldrht${p} $Rt, $addr",
4924 // (LDRHTi GPR:$Rt, GPR:$Rt, addr_offset_none:$addr, 0, pred:$p)>;
4925 //def : InstAlias<"ldrsht${p} $Rt, $addr",
4926 // (LDRSHTi GPR:$Rt, GPR:$Rt, addr_offset_none:$addr, 0, pred:$p)>;