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 AddrMode6AsmOperand : AsmOperandClass { let Name = "AlignedMemory"; }
766 def addrmode6 : Operand<i32>,
767 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
768 let PrintMethod = "printAddrMode6Operand";
769 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
770 let EncoderMethod = "getAddrMode6AddressOpValue";
771 let DecoderMethod = "DecodeAddrMode6Operand";
772 let ParserMatchClass = AddrMode6AsmOperand;
775 def am6offset : Operand<i32>,
776 ComplexPattern<i32, 1, "SelectAddrMode6Offset",
777 [], [SDNPWantRoot]> {
778 let PrintMethod = "printAddrMode6OffsetOperand";
779 let MIOperandInfo = (ops GPR);
780 let EncoderMethod = "getAddrMode6OffsetOpValue";
781 let DecoderMethod = "DecodeGPRRegisterClass";
784 // Special version of addrmode6 to handle alignment encoding for VST1/VLD1
785 // (single element from one lane) for size 32.
786 def addrmode6oneL32 : Operand<i32>,
787 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
788 let PrintMethod = "printAddrMode6Operand";
789 let MIOperandInfo = (ops GPR:$addr, i32imm);
790 let EncoderMethod = "getAddrMode6OneLane32AddressOpValue";
793 // Special version of addrmode6 to handle alignment encoding for VLD-dup
794 // instructions, specifically VLD4-dup.
795 def addrmode6dup : Operand<i32>,
796 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
797 let PrintMethod = "printAddrMode6Operand";
798 let MIOperandInfo = (ops GPR:$addr, i32imm);
799 let EncoderMethod = "getAddrMode6DupAddressOpValue";
802 // addrmodepc := pc + reg
804 def addrmodepc : Operand<i32>,
805 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
806 let PrintMethod = "printAddrModePCOperand";
807 let MIOperandInfo = (ops GPR, i32imm);
810 // addr_offset_none := reg
812 def MemNoOffsetAsmOperand : AsmOperandClass { let Name = "MemNoOffset"; }
813 def addr_offset_none : Operand<i32>,
814 ComplexPattern<i32, 1, "SelectAddrOffsetNone", []> {
815 let PrintMethod = "printAddrMode7Operand";
816 let DecoderMethod = "DecodeAddrMode7Operand";
817 let ParserMatchClass = MemNoOffsetAsmOperand;
818 let MIOperandInfo = (ops GPR:$base);
821 def nohash_imm : Operand<i32> {
822 let PrintMethod = "printNoHashImmediate";
825 def CoprocNumAsmOperand : AsmOperandClass {
826 let Name = "CoprocNum";
827 let ParserMethod = "parseCoprocNumOperand";
829 def p_imm : Operand<i32> {
830 let PrintMethod = "printPImmediate";
831 let ParserMatchClass = CoprocNumAsmOperand;
832 let DecoderMethod = "DecodeCoprocessor";
835 def CoprocRegAsmOperand : AsmOperandClass {
836 let Name = "CoprocReg";
837 let ParserMethod = "parseCoprocRegOperand";
839 def c_imm : Operand<i32> {
840 let PrintMethod = "printCImmediate";
841 let ParserMatchClass = CoprocRegAsmOperand;
844 //===----------------------------------------------------------------------===//
846 include "ARMInstrFormats.td"
848 //===----------------------------------------------------------------------===//
849 // Multiclass helpers...
852 /// AsI1_bin_irs - Defines a set of (op r, {so_imm|r|so_reg}) patterns for a
853 /// binop that produces a value.
854 multiclass AsI1_bin_irs<bits<4> opcod, string opc,
855 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
856 PatFrag opnode, string baseOpc, bit Commutable = 0> {
857 // The register-immediate version is re-materializable. This is useful
858 // in particular for taking the address of a local.
859 let isReMaterializable = 1 in {
860 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
861 iii, opc, "\t$Rd, $Rn, $imm",
862 [(set GPR:$Rd, (opnode GPR:$Rn, so_imm:$imm))]> {
867 let Inst{19-16} = Rn;
868 let Inst{15-12} = Rd;
869 let Inst{11-0} = imm;
872 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
873 iir, opc, "\t$Rd, $Rn, $Rm",
874 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]> {
879 let isCommutable = Commutable;
880 let Inst{19-16} = Rn;
881 let Inst{15-12} = Rd;
882 let Inst{11-4} = 0b00000000;
886 def rsi : AsI1<opcod, (outs GPR:$Rd),
887 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
888 iis, opc, "\t$Rd, $Rn, $shift",
889 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_imm:$shift))]> {
894 let Inst{19-16} = Rn;
895 let Inst{15-12} = Rd;
896 let Inst{11-5} = shift{11-5};
898 let Inst{3-0} = shift{3-0};
901 def rsr : AsI1<opcod, (outs GPR:$Rd),
902 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
903 iis, opc, "\t$Rd, $Rn, $shift",
904 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_reg:$shift))]> {
909 let Inst{19-16} = Rn;
910 let Inst{15-12} = Rd;
911 let Inst{11-8} = shift{11-8};
913 let Inst{6-5} = shift{6-5};
915 let Inst{3-0} = shift{3-0};
918 // Assembly aliases for optional destination operand when it's the same
919 // as the source operand.
920 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $imm"),
921 (!cast<Instruction>(!strconcat(baseOpc, "ri")) GPR:$Rdn, GPR:$Rdn,
922 so_imm:$imm, pred:$p,
925 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $Rm"),
926 (!cast<Instruction>(!strconcat(baseOpc, "rr")) GPR:$Rdn, GPR:$Rdn,
930 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
931 (!cast<Instruction>(!strconcat(baseOpc, "rsi")) GPR:$Rdn, GPR:$Rdn,
932 so_reg_imm:$shift, pred:$p,
935 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
936 (!cast<Instruction>(!strconcat(baseOpc, "rsr")) GPR:$Rdn, GPR:$Rdn,
937 so_reg_reg:$shift, pred:$p,
943 /// AsI1_rbin_irs - Same as AsI1_bin_irs except the order of operands are
944 /// reversed. The 'rr' form is only defined for the disassembler; for codegen
945 /// it is equivalent to the AsI1_bin_irs counterpart.
946 multiclass AsI1_rbin_irs<bits<4> opcod, string opc,
947 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
948 PatFrag opnode, string baseOpc, bit Commutable = 0> {
949 // The register-immediate version is re-materializable. This is useful
950 // in particular for taking the address of a local.
951 let isReMaterializable = 1 in {
952 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
953 iii, opc, "\t$Rd, $Rn, $imm",
954 [(set GPR:$Rd, (opnode so_imm:$imm, GPR:$Rn))]> {
959 let Inst{19-16} = Rn;
960 let Inst{15-12} = Rd;
961 let Inst{11-0} = imm;
964 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
965 iir, opc, "\t$Rd, $Rn, $Rm",
966 [/* pattern left blank */]> {
970 let Inst{11-4} = 0b00000000;
973 let Inst{15-12} = Rd;
974 let Inst{19-16} = Rn;
977 def rsi : AsI1<opcod, (outs GPR:$Rd),
978 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
979 iis, opc, "\t$Rd, $Rn, $shift",
980 [(set GPR:$Rd, (opnode so_reg_imm:$shift, GPR:$Rn))]> {
985 let Inst{19-16} = Rn;
986 let Inst{15-12} = Rd;
987 let Inst{11-5} = shift{11-5};
989 let Inst{3-0} = shift{3-0};
992 def rsr : AsI1<opcod, (outs GPR:$Rd),
993 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
994 iis, opc, "\t$Rd, $Rn, $shift",
995 [(set GPR:$Rd, (opnode so_reg_reg:$shift, GPR:$Rn))]> {
1000 let Inst{19-16} = Rn;
1001 let Inst{15-12} = Rd;
1002 let Inst{11-8} = shift{11-8};
1004 let Inst{6-5} = shift{6-5};
1006 let Inst{3-0} = shift{3-0};
1009 // Assembly aliases for optional destination operand when it's the same
1010 // as the source operand.
1011 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $imm"),
1012 (!cast<Instruction>(!strconcat(baseOpc, "ri")) GPR:$Rdn, GPR:$Rdn,
1013 so_imm:$imm, pred:$p,
1016 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $Rm"),
1017 (!cast<Instruction>(!strconcat(baseOpc, "rr")) GPR:$Rdn, GPR:$Rdn,
1021 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1022 (!cast<Instruction>(!strconcat(baseOpc, "rsi")) GPR:$Rdn, GPR:$Rdn,
1023 so_reg_imm:$shift, pred:$p,
1026 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1027 (!cast<Instruction>(!strconcat(baseOpc, "rsr")) GPR:$Rdn, GPR:$Rdn,
1028 so_reg_reg:$shift, pred:$p,
1034 /// AsI1_rbin_s_is - Same as AsI1_rbin_s_is except it sets 's' bit by default.
1036 /// These opcodes will be converted to the real non-S opcodes by
1037 /// AdjustInstrPostInstrSelection after giving then an optional CPSR operand.
1038 let hasPostISelHook = 1, isCodeGenOnly = 1, isPseudo = 1, Defs = [CPSR] in {
1039 multiclass AsI1_rbin_s_is<bits<4> opcod, string opc,
1040 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1041 PatFrag opnode, bit Commutable = 0> {
1042 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
1043 iii, opc, "\t$Rd, $Rn, $imm",
1044 [(set GPR:$Rd, CPSR, (opnode so_imm:$imm, GPR:$Rn))]>;
1046 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1047 iir, opc, "\t$Rd, $Rn, $Rm",
1048 [/* pattern left blank */]>;
1050 def rsi : AsI1<opcod, (outs GPR:$Rd),
1051 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1052 iis, opc, "\t$Rd, $Rn, $shift",
1053 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift, GPR:$Rn))]>;
1055 def rsr : AsI1<opcod, (outs GPR:$Rd),
1056 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1057 iis, opc, "\t$Rd, $Rn, $shift",
1058 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift, GPR:$Rn))]> {
1063 let Inst{19-16} = Rn;
1064 let Inst{15-12} = Rd;
1065 let Inst{11-8} = shift{11-8};
1067 let Inst{6-5} = shift{6-5};
1069 let Inst{3-0} = shift{3-0};
1074 /// AsI1_bin_s_irs - Same as AsI1_bin_irs except it sets the 's' bit by default.
1076 /// These opcodes will be converted to the real non-S opcodes by
1077 /// AdjustInstrPostInstrSelection after giving then an optional CPSR operand.
1078 let hasPostISelHook = 1, isCodeGenOnly = 1, isPseudo = 1, Defs = [CPSR] in {
1079 multiclass AsI1_bin_s_irs<bits<4> opcod, string opc,
1080 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1081 PatFrag opnode, bit Commutable = 0> {
1082 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm), DPFrm,
1083 iii, opc, "\t$Rd, $Rn, $imm",
1084 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_imm:$imm))]>;
1085 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1086 iir, opc, "\t$Rd, $Rn, $Rm",
1087 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm))]>;
1088 def rsi : AsI1<opcod, (outs GPR:$Rd),
1089 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1090 iis, opc, "\t$Rd, $Rn, $shift",
1091 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_imm:$shift))]>;
1093 def rsr : AsI1<opcod, (outs GPR:$Rd),
1094 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1095 iis, opc, "\t$Rd, $Rn, $shift",
1096 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_reg:$shift))]>;
1100 /// AI1_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test
1101 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
1102 /// a explicit result, only implicitly set CPSR.
1103 let isCompare = 1, Defs = [CPSR] in {
1104 multiclass AI1_cmp_irs<bits<4> opcod, string opc,
1105 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1106 PatFrag opnode, bit Commutable = 0> {
1107 def ri : AI1<opcod, (outs), (ins GPR:$Rn, so_imm:$imm), DPFrm, iii,
1109 [(opnode GPR:$Rn, so_imm:$imm)]> {
1114 let Inst{19-16} = Rn;
1115 let Inst{15-12} = 0b0000;
1116 let Inst{11-0} = imm;
1118 def rr : AI1<opcod, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, iir,
1120 [(opnode GPR:$Rn, GPR:$Rm)]> {
1123 let isCommutable = Commutable;
1126 let Inst{19-16} = Rn;
1127 let Inst{15-12} = 0b0000;
1128 let Inst{11-4} = 0b00000000;
1131 def rsi : AI1<opcod, (outs),
1132 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, iis,
1133 opc, "\t$Rn, $shift",
1134 [(opnode GPR:$Rn, so_reg_imm:$shift)]> {
1139 let Inst{19-16} = Rn;
1140 let Inst{15-12} = 0b0000;
1141 let Inst{11-5} = shift{11-5};
1143 let Inst{3-0} = shift{3-0};
1145 def rsr : AI1<opcod, (outs),
1146 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, iis,
1147 opc, "\t$Rn, $shift",
1148 [(opnode GPR:$Rn, so_reg_reg:$shift)]> {
1153 let Inst{19-16} = Rn;
1154 let Inst{15-12} = 0b0000;
1155 let Inst{11-8} = shift{11-8};
1157 let Inst{6-5} = shift{6-5};
1159 let Inst{3-0} = shift{3-0};
1165 /// AI_ext_rrot - A unary operation with two forms: one whose operand is a
1166 /// register and one whose operand is a register rotated by 8/16/24.
1167 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
1168 class AI_ext_rrot<bits<8> opcod, string opc, PatFrag opnode>
1169 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1170 IIC_iEXTr, opc, "\t$Rd, $Rm$rot",
1171 [(set GPRnopc:$Rd, (opnode (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1172 Requires<[IsARM, HasV6]> {
1176 let Inst{19-16} = 0b1111;
1177 let Inst{15-12} = Rd;
1178 let Inst{11-10} = rot;
1182 class AI_ext_rrot_np<bits<8> opcod, string opc>
1183 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1184 IIC_iEXTr, opc, "\t$Rd, $Rm$rot", []>,
1185 Requires<[IsARM, HasV6]> {
1187 let Inst{19-16} = 0b1111;
1188 let Inst{11-10} = rot;
1191 /// AI_exta_rrot - A binary operation with two forms: one whose operand is a
1192 /// register and one whose operand is a register rotated by 8/16/24.
1193 class AI_exta_rrot<bits<8> opcod, string opc, PatFrag opnode>
1194 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1195 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot",
1196 [(set GPRnopc:$Rd, (opnode GPR:$Rn,
1197 (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1198 Requires<[IsARM, HasV6]> {
1203 let Inst{19-16} = Rn;
1204 let Inst{15-12} = Rd;
1205 let Inst{11-10} = rot;
1206 let Inst{9-4} = 0b000111;
1210 class AI_exta_rrot_np<bits<8> opcod, string opc>
1211 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1212 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot", []>,
1213 Requires<[IsARM, HasV6]> {
1216 let Inst{19-16} = Rn;
1217 let Inst{11-10} = rot;
1220 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
1221 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, PatFrag opnode,
1222 string baseOpc, bit Commutable = 0> {
1223 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1224 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
1225 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1226 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_imm:$imm, CPSR))]>,
1232 let Inst{15-12} = Rd;
1233 let Inst{19-16} = Rn;
1234 let Inst{11-0} = imm;
1236 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1237 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1238 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm, CPSR))]>,
1243 let Inst{11-4} = 0b00000000;
1245 let isCommutable = Commutable;
1247 let Inst{15-12} = Rd;
1248 let Inst{19-16} = Rn;
1250 def rsi : AsI1<opcod, (outs GPR:$Rd),
1251 (ins GPR:$Rn, so_reg_imm:$shift),
1252 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1253 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_imm:$shift, CPSR))]>,
1259 let Inst{19-16} = Rn;
1260 let Inst{15-12} = Rd;
1261 let Inst{11-5} = shift{11-5};
1263 let Inst{3-0} = shift{3-0};
1265 def rsr : AsI1<opcod, (outs GPR:$Rd),
1266 (ins GPR:$Rn, so_reg_reg:$shift),
1267 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1268 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_reg:$shift, CPSR))]>,
1274 let Inst{19-16} = Rn;
1275 let Inst{15-12} = Rd;
1276 let Inst{11-8} = shift{11-8};
1278 let Inst{6-5} = shift{6-5};
1280 let Inst{3-0} = shift{3-0};
1284 // Assembly aliases for optional destination operand when it's the same
1285 // as the source operand.
1286 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $imm"),
1287 (!cast<Instruction>(!strconcat(baseOpc, "ri")) GPR:$Rdn, GPR:$Rdn,
1288 so_imm:$imm, pred:$p,
1291 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $Rm"),
1292 (!cast<Instruction>(!strconcat(baseOpc, "rr")) GPR:$Rdn, GPR:$Rdn,
1296 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1297 (!cast<Instruction>(!strconcat(baseOpc, "rsi")) GPR:$Rdn, GPR:$Rdn,
1298 so_reg_imm:$shift, pred:$p,
1301 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1302 (!cast<Instruction>(!strconcat(baseOpc, "rsr")) GPR:$Rdn, GPR:$Rdn,
1303 so_reg_reg:$shift, pred:$p,
1308 /// AI1_rsc_irs - Define instructions and patterns for rsc
1309 multiclass AI1_rsc_irs<bits<4> opcod, string opc, PatFrag opnode,
1311 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1312 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_imm:$imm),
1313 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1314 [(set GPR:$Rd, CPSR, (opnode so_imm:$imm, GPR:$Rn, CPSR))]>,
1320 let Inst{15-12} = Rd;
1321 let Inst{19-16} = Rn;
1322 let Inst{11-0} = imm;
1324 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1325 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1326 [/* pattern left blank */]> {
1330 let Inst{11-4} = 0b00000000;
1333 let Inst{15-12} = Rd;
1334 let Inst{19-16} = Rn;
1336 def rsi : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_imm:$shift),
1337 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1338 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift, GPR:$Rn, CPSR))]>,
1344 let Inst{19-16} = Rn;
1345 let Inst{15-12} = Rd;
1346 let Inst{11-5} = shift{11-5};
1348 let Inst{3-0} = shift{3-0};
1350 def rsr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_reg:$shift),
1351 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1352 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift, GPR:$Rn, CPSR))]>,
1358 let Inst{19-16} = Rn;
1359 let Inst{15-12} = Rd;
1360 let Inst{11-8} = shift{11-8};
1362 let Inst{6-5} = shift{6-5};
1364 let Inst{3-0} = shift{3-0};
1368 // Assembly aliases for optional destination operand when it's the same
1369 // as the source operand.
1370 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $imm"),
1371 (!cast<Instruction>(!strconcat(baseOpc, "ri")) GPR:$Rdn, GPR:$Rdn,
1372 so_imm:$imm, pred:$p,
1375 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $Rm"),
1376 (!cast<Instruction>(!strconcat(baseOpc, "rr")) GPR:$Rdn, GPR:$Rdn,
1380 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1381 (!cast<Instruction>(!strconcat(baseOpc, "rsi")) GPR:$Rdn, GPR:$Rdn,
1382 so_reg_imm:$shift, pred:$p,
1385 def : InstAlias<!strconcat(opc, "${s}${p} $Rdn, $shift"),
1386 (!cast<Instruction>(!strconcat(baseOpc, "rsr")) GPR:$Rdn, GPR:$Rdn,
1387 so_reg_reg:$shift, pred:$p,
1392 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1393 multiclass AI_ldr1<bit isByte, string opc, InstrItinClass iii,
1394 InstrItinClass iir, PatFrag opnode> {
1395 // Note: We use the complex addrmode_imm12 rather than just an input
1396 // GPR and a constrained immediate so that we can use this to match
1397 // frame index references and avoid matching constant pool references.
1398 def i12: AI2ldst<0b010, 1, isByte, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
1399 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1400 [(set GPR:$Rt, (opnode addrmode_imm12:$addr))]> {
1403 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1404 let Inst{19-16} = addr{16-13}; // Rn
1405 let Inst{15-12} = Rt;
1406 let Inst{11-0} = addr{11-0}; // imm12
1408 def rs : AI2ldst<0b011, 1, isByte, (outs GPR:$Rt), (ins ldst_so_reg:$shift),
1409 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1410 [(set GPR:$Rt, (opnode ldst_so_reg:$shift))]> {
1413 let shift{4} = 0; // Inst{4} = 0
1414 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1415 let Inst{19-16} = shift{16-13}; // Rn
1416 let Inst{15-12} = Rt;
1417 let Inst{11-0} = shift{11-0};
1422 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1423 multiclass AI_ldr1nopc<bit isByte, string opc, InstrItinClass iii,
1424 InstrItinClass iir, PatFrag opnode> {
1425 // Note: We use the complex addrmode_imm12 rather than just an input
1426 // GPR and a constrained immediate so that we can use this to match
1427 // frame index references and avoid matching constant pool references.
1428 def i12: AI2ldst<0b010, 1, isByte, (outs GPRnopc:$Rt), (ins addrmode_imm12:$addr),
1429 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1430 [(set GPRnopc:$Rt, (opnode addrmode_imm12:$addr))]> {
1433 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1434 let Inst{19-16} = addr{16-13}; // Rn
1435 let Inst{15-12} = Rt;
1436 let Inst{11-0} = addr{11-0}; // imm12
1438 def rs : AI2ldst<0b011, 1, isByte, (outs GPRnopc:$Rt), (ins ldst_so_reg:$shift),
1439 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1440 [(set GPRnopc:$Rt, (opnode ldst_so_reg:$shift))]> {
1443 let shift{4} = 0; // Inst{4} = 0
1444 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1445 let Inst{19-16} = shift{16-13}; // Rn
1446 let Inst{15-12} = Rt;
1447 let Inst{11-0} = shift{11-0};
1453 multiclass AI_str1<bit isByte, string opc, InstrItinClass iii,
1454 InstrItinClass iir, PatFrag opnode> {
1455 // Note: We use the complex addrmode_imm12 rather than just an input
1456 // GPR and a constrained immediate so that we can use this to match
1457 // frame index references and avoid matching constant pool references.
1458 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1459 (ins GPR:$Rt, addrmode_imm12:$addr),
1460 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1461 [(opnode GPR:$Rt, addrmode_imm12:$addr)]> {
1464 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1465 let Inst{19-16} = addr{16-13}; // Rn
1466 let Inst{15-12} = Rt;
1467 let Inst{11-0} = addr{11-0}; // imm12
1469 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPR:$Rt, ldst_so_reg:$shift),
1470 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1471 [(opnode GPR:$Rt, ldst_so_reg:$shift)]> {
1474 let shift{4} = 0; // Inst{4} = 0
1475 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1476 let Inst{19-16} = shift{16-13}; // Rn
1477 let Inst{15-12} = Rt;
1478 let Inst{11-0} = shift{11-0};
1482 multiclass AI_str1nopc<bit isByte, string opc, InstrItinClass iii,
1483 InstrItinClass iir, PatFrag opnode> {
1484 // Note: We use the complex addrmode_imm12 rather than just an input
1485 // GPR and a constrained immediate so that we can use this to match
1486 // frame index references and avoid matching constant pool references.
1487 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1488 (ins GPRnopc:$Rt, addrmode_imm12:$addr),
1489 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1490 [(opnode GPRnopc:$Rt, addrmode_imm12:$addr)]> {
1493 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1494 let Inst{19-16} = addr{16-13}; // Rn
1495 let Inst{15-12} = Rt;
1496 let Inst{11-0} = addr{11-0}; // imm12
1498 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPRnopc:$Rt, ldst_so_reg:$shift),
1499 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1500 [(opnode GPRnopc:$Rt, ldst_so_reg:$shift)]> {
1503 let shift{4} = 0; // Inst{4} = 0
1504 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1505 let Inst{19-16} = shift{16-13}; // Rn
1506 let Inst{15-12} = Rt;
1507 let Inst{11-0} = shift{11-0};
1512 //===----------------------------------------------------------------------===//
1514 //===----------------------------------------------------------------------===//
1516 //===----------------------------------------------------------------------===//
1517 // Miscellaneous Instructions.
1520 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
1521 /// the function. The first operand is the ID# for this instruction, the second
1522 /// is the index into the MachineConstantPool that this is, the third is the
1523 /// size in bytes of this constant pool entry.
1524 let neverHasSideEffects = 1, isNotDuplicable = 1 in
1525 def CONSTPOOL_ENTRY :
1526 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1527 i32imm:$size), NoItinerary, []>;
1529 // FIXME: Marking these as hasSideEffects is necessary to prevent machine DCE
1530 // from removing one half of the matched pairs. That breaks PEI, which assumes
1531 // these will always be in pairs, and asserts if it finds otherwise. Better way?
1532 let Defs = [SP], Uses = [SP], hasSideEffects = 1 in {
1533 def ADJCALLSTACKUP :
1534 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary,
1535 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
1537 def ADJCALLSTACKDOWN :
1538 PseudoInst<(outs), (ins i32imm:$amt, pred:$p), NoItinerary,
1539 [(ARMcallseq_start timm:$amt)]>;
1542 // Atomic pseudo-insts which will be lowered to ldrexd/strexd loops.
1543 // (These psuedos use a hand-written selection code).
1544 let usesCustomInserter = 1, Defs = [CPSR], mayLoad = 1, mayStore = 1 in {
1545 def ATOMOR6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1546 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1548 def ATOMXOR6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1549 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1551 def ATOMADD6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1552 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1554 def ATOMSUB6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1555 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1557 def ATOMNAND6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1558 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1560 def ATOMAND6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1561 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1563 def ATOMSWAP6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1564 (ins GPR:$addr, GPR:$src1, GPR:$src2),
1566 def ATOMCMPXCHG6432 : PseudoInst<(outs GPR:$dst1, GPR:$dst2),
1567 (ins GPR:$addr, GPR:$cmp1, GPR:$cmp2,
1568 GPR:$set1, GPR:$set2),
1572 def NOP : AI<(outs), (ins), MiscFrm, NoItinerary, "nop", "", []>,
1573 Requires<[IsARM, HasV6T2]> {
1574 let Inst{27-16} = 0b001100100000;
1575 let Inst{15-8} = 0b11110000;
1576 let Inst{7-0} = 0b00000000;
1579 def YIELD : AI<(outs), (ins), MiscFrm, NoItinerary, "yield", "", []>,
1580 Requires<[IsARM, HasV6T2]> {
1581 let Inst{27-16} = 0b001100100000;
1582 let Inst{15-8} = 0b11110000;
1583 let Inst{7-0} = 0b00000001;
1586 def WFE : AI<(outs), (ins), MiscFrm, NoItinerary, "wfe", "", []>,
1587 Requires<[IsARM, HasV6T2]> {
1588 let Inst{27-16} = 0b001100100000;
1589 let Inst{15-8} = 0b11110000;
1590 let Inst{7-0} = 0b00000010;
1593 def WFI : AI<(outs), (ins), MiscFrm, NoItinerary, "wfi", "", []>,
1594 Requires<[IsARM, HasV6T2]> {
1595 let Inst{27-16} = 0b001100100000;
1596 let Inst{15-8} = 0b11110000;
1597 let Inst{7-0} = 0b00000011;
1600 def SEL : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, NoItinerary, "sel",
1601 "\t$Rd, $Rn, $Rm", []>, Requires<[IsARM, HasV6]> {
1606 let Inst{15-12} = Rd;
1607 let Inst{19-16} = Rn;
1608 let Inst{27-20} = 0b01101000;
1609 let Inst{7-4} = 0b1011;
1610 let Inst{11-8} = 0b1111;
1613 def SEV : AI<(outs), (ins), MiscFrm, NoItinerary, "sev", "",
1614 []>, Requires<[IsARM, HasV6T2]> {
1615 let Inst{27-16} = 0b001100100000;
1616 let Inst{15-8} = 0b11110000;
1617 let Inst{7-0} = 0b00000100;
1620 // The i32imm operand $val can be used by a debugger to store more information
1621 // about the breakpoint.
1622 def BKPT : AI<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
1623 "bkpt", "\t$val", []>, Requires<[IsARM]> {
1625 let Inst{3-0} = val{3-0};
1626 let Inst{19-8} = val{15-4};
1627 let Inst{27-20} = 0b00010010;
1628 let Inst{7-4} = 0b0111;
1631 // Change Processor State
1632 // FIXME: We should use InstAlias to handle the optional operands.
1633 class CPS<dag iops, string asm_ops>
1634 : AXI<(outs), iops, MiscFrm, NoItinerary, !strconcat("cps", asm_ops),
1635 []>, Requires<[IsARM]> {
1641 let Inst{31-28} = 0b1111;
1642 let Inst{27-20} = 0b00010000;
1643 let Inst{19-18} = imod;
1644 let Inst{17} = M; // Enabled if mode is set;
1646 let Inst{8-6} = iflags;
1648 let Inst{4-0} = mode;
1651 let DecoderMethod = "DecodeCPSInstruction" in {
1653 def CPS3p : CPS<(ins imod_op:$imod, iflags_op:$iflags, imm0_31:$mode),
1654 "$imod\t$iflags, $mode">;
1655 let mode = 0, M = 0 in
1656 def CPS2p : CPS<(ins imod_op:$imod, iflags_op:$iflags), "$imod\t$iflags">;
1658 let imod = 0, iflags = 0, M = 1 in
1659 def CPS1p : CPS<(ins imm0_31:$mode), "\t$mode">;
1662 // Preload signals the memory system of possible future data/instruction access.
1663 multiclass APreLoad<bits<1> read, bits<1> data, string opc> {
1665 def i12 : AXI<(outs), (ins addrmode_imm12:$addr), MiscFrm, IIC_Preload,
1666 !strconcat(opc, "\t$addr"),
1667 [(ARMPreload addrmode_imm12:$addr, (i32 read), (i32 data))]> {
1670 let Inst{31-26} = 0b111101;
1671 let Inst{25} = 0; // 0 for immediate form
1672 let Inst{24} = data;
1673 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1674 let Inst{22} = read;
1675 let Inst{21-20} = 0b01;
1676 let Inst{19-16} = addr{16-13}; // Rn
1677 let Inst{15-12} = 0b1111;
1678 let Inst{11-0} = addr{11-0}; // imm12
1681 def rs : AXI<(outs), (ins ldst_so_reg:$shift), MiscFrm, IIC_Preload,
1682 !strconcat(opc, "\t$shift"),
1683 [(ARMPreload ldst_so_reg:$shift, (i32 read), (i32 data))]> {
1685 let Inst{31-26} = 0b111101;
1686 let Inst{25} = 1; // 1 for register form
1687 let Inst{24} = data;
1688 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1689 let Inst{22} = read;
1690 let Inst{21-20} = 0b01;
1691 let Inst{19-16} = shift{16-13}; // Rn
1692 let Inst{15-12} = 0b1111;
1693 let Inst{11-0} = shift{11-0};
1698 defm PLD : APreLoad<1, 1, "pld">, Requires<[IsARM]>;
1699 defm PLDW : APreLoad<0, 1, "pldw">, Requires<[IsARM,HasV7,HasMP]>;
1700 defm PLI : APreLoad<1, 0, "pli">, Requires<[IsARM,HasV7]>;
1702 def SETEND : AXI<(outs), (ins setend_op:$end), MiscFrm, NoItinerary,
1703 "setend\t$end", []>, Requires<[IsARM]> {
1705 let Inst{31-10} = 0b1111000100000001000000;
1710 def DBG : AI<(outs), (ins imm0_15:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt",
1711 []>, Requires<[IsARM, HasV7]> {
1713 let Inst{27-4} = 0b001100100000111100001111;
1714 let Inst{3-0} = opt;
1717 // A5.4 Permanently UNDEFINED instructions.
1718 let isBarrier = 1, isTerminator = 1 in
1719 def TRAP : AXI<(outs), (ins), MiscFrm, NoItinerary,
1722 let Inst = 0xe7ffdefe;
1725 // Address computation and loads and stores in PIC mode.
1726 let isNotDuplicable = 1 in {
1727 def PICADD : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
1729 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>;
1731 let AddedComplexity = 10 in {
1732 def PICLDR : ARMPseudoInst<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
1734 [(set GPR:$dst, (load addrmodepc:$addr))]>;
1736 def PICLDRH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1738 [(set GPR:$Rt, (zextloadi16 addrmodepc:$addr))]>;
1740 def PICLDRB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1742 [(set GPR:$Rt, (zextloadi8 addrmodepc:$addr))]>;
1744 def PICLDRSH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1746 [(set GPR:$Rt, (sextloadi16 addrmodepc:$addr))]>;
1748 def PICLDRSB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
1750 [(set GPR:$Rt, (sextloadi8 addrmodepc:$addr))]>;
1752 let AddedComplexity = 10 in {
1753 def PICSTR : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1754 4, IIC_iStore_r, [(store GPR:$src, addrmodepc:$addr)]>;
1756 def PICSTRH : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1757 4, IIC_iStore_bh_r, [(truncstorei16 GPR:$src,
1758 addrmodepc:$addr)]>;
1760 def PICSTRB : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
1761 4, IIC_iStore_bh_r, [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
1763 } // isNotDuplicable = 1
1766 // LEApcrel - Load a pc-relative address into a register without offending the
1768 let neverHasSideEffects = 1, isReMaterializable = 1 in
1769 // The 'adr' mnemonic encodes differently if the label is before or after
1770 // the instruction. The {24-21} opcode bits are set by the fixup, as we don't
1771 // know until then which form of the instruction will be used.
1772 def ADR : AI1<{0,?,?,0}, (outs GPR:$Rd), (ins adrlabel:$label),
1773 MiscFrm, IIC_iALUi, "adr", "\t$Rd, $label", []> {
1776 let Inst{27-25} = 0b001;
1778 let Inst{23-22} = label{13-12};
1781 let Inst{19-16} = 0b1111;
1782 let Inst{15-12} = Rd;
1783 let Inst{11-0} = label{11-0};
1785 def LEApcrel : ARMPseudoInst<(outs GPR:$Rd), (ins i32imm:$label, pred:$p),
1788 def LEApcrelJT : ARMPseudoInst<(outs GPR:$Rd),
1789 (ins i32imm:$label, nohash_imm:$id, pred:$p),
1792 //===----------------------------------------------------------------------===//
1793 // Control Flow Instructions.
1796 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
1798 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
1799 "bx", "\tlr", [(ARMretflag)]>,
1800 Requires<[IsARM, HasV4T]> {
1801 let Inst{27-0} = 0b0001001011111111111100011110;
1805 def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br,
1806 "mov", "\tpc, lr", [(ARMretflag)]>,
1807 Requires<[IsARM, NoV4T]> {
1808 let Inst{27-0} = 0b0001101000001111000000001110;
1812 // Indirect branches
1813 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
1815 def BX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
1816 [(brind GPR:$dst)]>,
1817 Requires<[IsARM, HasV4T]> {
1819 let Inst{31-4} = 0b1110000100101111111111110001;
1820 let Inst{3-0} = dst;
1823 def BX_pred : AI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br,
1824 "bx", "\t$dst", [/* pattern left blank */]>,
1825 Requires<[IsARM, HasV4T]> {
1827 let Inst{27-4} = 0b000100101111111111110001;
1828 let Inst{3-0} = dst;
1832 // All calls clobber the non-callee saved registers. SP is marked as
1833 // a use to prevent stack-pointer assignments that appear immediately
1834 // before calls from potentially appearing dead.
1836 // On non-Darwin platforms R9 is callee-saved.
1837 // FIXME: Do we really need a non-predicated version? If so, it should
1838 // at least be a pseudo instruction expanding to the predicated version
1839 // at MC lowering time.
1840 Defs = [R0, R1, R2, R3, R12, LR, QQQQ0, QQQQ2, QQQQ3, CPSR, FPSCR],
1842 def BL : ABXI<0b1011, (outs), (ins bl_target:$func, variable_ops),
1843 IIC_Br, "bl\t$func",
1844 [(ARMcall tglobaladdr:$func)]>,
1845 Requires<[IsARM, IsNotDarwin]> {
1846 let Inst{31-28} = 0b1110;
1848 let Inst{23-0} = func;
1849 let DecoderMethod = "DecodeBranchImmInstruction";
1852 def BL_pred : ABI<0b1011, (outs), (ins bl_target:$func, variable_ops),
1853 IIC_Br, "bl", "\t$func",
1854 [(ARMcall_pred tglobaladdr:$func)]>,
1855 Requires<[IsARM, IsNotDarwin]> {
1857 let Inst{23-0} = func;
1858 let DecoderMethod = "DecodeBranchImmInstruction";
1862 def BLX : AXI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
1863 IIC_Br, "blx\t$func",
1864 [(ARMcall GPR:$func)]>,
1865 Requires<[IsARM, HasV5T, IsNotDarwin]> {
1867 let Inst{31-4} = 0b1110000100101111111111110011;
1868 let Inst{3-0} = func;
1871 def BLX_pred : AI<(outs), (ins GPR:$func, variable_ops), BrMiscFrm,
1872 IIC_Br, "blx", "\t$func",
1873 [(ARMcall_pred GPR:$func)]>,
1874 Requires<[IsARM, HasV5T, IsNotDarwin]> {
1876 let Inst{27-4} = 0b000100101111111111110011;
1877 let Inst{3-0} = func;
1881 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
1882 def BX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func, variable_ops),
1883 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
1884 Requires<[IsARM, HasV4T, IsNotDarwin]>;
1887 def BMOVPCRX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func, variable_ops),
1888 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
1889 Requires<[IsARM, NoV4T, IsNotDarwin]>;
1893 // On Darwin R9 is call-clobbered.
1894 // R7 is marked as a use to prevent frame-pointer assignments from being
1895 // moved above / below calls.
1896 Defs = [R0, R1, R2, R3, R9, R12, LR, QQQQ0, QQQQ2, QQQQ3, CPSR, FPSCR],
1897 Uses = [R7, SP] in {
1898 def BLr9 : ARMPseudoExpand<(outs), (ins bl_target:$func, variable_ops),
1900 [(ARMcall tglobaladdr:$func)], (BL bl_target:$func)>,
1901 Requires<[IsARM, IsDarwin]>;
1903 def BLr9_pred : ARMPseudoExpand<(outs),
1904 (ins bl_target:$func, pred:$p, variable_ops),
1906 [(ARMcall_pred tglobaladdr:$func)],
1907 (BL_pred bl_target:$func, pred:$p)>,
1908 Requires<[IsARM, IsDarwin]>;
1911 def BLXr9 : ARMPseudoExpand<(outs), (ins GPR:$func, variable_ops),
1913 [(ARMcall GPR:$func)],
1915 Requires<[IsARM, HasV5T, IsDarwin]>;
1917 def BLXr9_pred: ARMPseudoExpand<(outs), (ins GPR:$func, pred:$p,variable_ops),
1919 [(ARMcall_pred GPR:$func)],
1920 (BLX_pred GPR:$func, pred:$p)>,
1921 Requires<[IsARM, HasV5T, IsDarwin]>;
1924 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
1925 def BXr9_CALL : ARMPseudoInst<(outs), (ins tGPR:$func, variable_ops),
1926 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
1927 Requires<[IsARM, HasV4T, IsDarwin]>;
1930 def BMOVPCRXr9_CALL : ARMPseudoInst<(outs), (ins tGPR:$func, variable_ops),
1931 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
1932 Requires<[IsARM, NoV4T, IsDarwin]>;
1935 let isBranch = 1, isTerminator = 1 in {
1936 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
1937 // a two-value operand where a dag node expects two operands. :(
1938 def Bcc : ABI<0b1010, (outs), (ins br_target:$target),
1939 IIC_Br, "b", "\t$target",
1940 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]> {
1942 let Inst{23-0} = target;
1943 let DecoderMethod = "DecodeBranchImmInstruction";
1946 let isBarrier = 1 in {
1947 // B is "predicable" since it's just a Bcc with an 'always' condition.
1948 let isPredicable = 1 in
1949 // FIXME: We shouldn't need this pseudo at all. Just using Bcc directly
1950 // should be sufficient.
1951 // FIXME: Is B really a Barrier? That doesn't seem right.
1952 def B : ARMPseudoExpand<(outs), (ins br_target:$target), 4, IIC_Br,
1953 [(br bb:$target)], (Bcc br_target:$target, (ops 14, zero_reg))>;
1955 let isNotDuplicable = 1, isIndirectBranch = 1 in {
1956 def BR_JTr : ARMPseudoInst<(outs),
1957 (ins GPR:$target, i32imm:$jt, i32imm:$id),
1959 [(ARMbrjt GPR:$target, tjumptable:$jt, imm:$id)]>;
1960 // FIXME: This shouldn't use the generic "addrmode2," but rather be split
1961 // into i12 and rs suffixed versions.
1962 def BR_JTm : ARMPseudoInst<(outs),
1963 (ins addrmode2:$target, i32imm:$jt, i32imm:$id),
1965 [(ARMbrjt (i32 (load addrmode2:$target)), tjumptable:$jt,
1967 def BR_JTadd : ARMPseudoInst<(outs),
1968 (ins GPR:$target, GPR:$idx, i32imm:$jt, i32imm:$id),
1970 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt,
1972 } // isNotDuplicable = 1, isIndirectBranch = 1
1978 def BLXi : AXI<(outs), (ins blx_target:$target), BrMiscFrm, NoItinerary,
1979 "blx\t$target", []>,
1980 Requires<[IsARM, HasV5T]> {
1981 let Inst{31-25} = 0b1111101;
1983 let Inst{23-0} = target{24-1};
1984 let Inst{24} = target{0};
1987 // Branch and Exchange Jazelle
1988 def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func",
1989 [/* pattern left blank */]> {
1991 let Inst{23-20} = 0b0010;
1992 let Inst{19-8} = 0xfff;
1993 let Inst{7-4} = 0b0010;
1994 let Inst{3-0} = func;
1999 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1 in {
2001 let Defs = [R0, R1, R2, R3, R9, R12, QQQQ0, QQQQ2, QQQQ3, PC],
2003 def TCRETURNdi : PseudoInst<(outs), (ins i32imm:$dst, variable_ops),
2004 IIC_Br, []>, Requires<[IsDarwin]>;
2006 def TCRETURNri : PseudoInst<(outs), (ins tcGPR:$dst, variable_ops),
2007 IIC_Br, []>, Requires<[IsDarwin]>;
2009 def TAILJMPd : ARMPseudoExpand<(outs), (ins br_target:$dst, variable_ops),
2011 (Bcc br_target:$dst, (ops 14, zero_reg))>,
2012 Requires<[IsARM, IsDarwin]>;
2014 def TAILJMPr : ARMPseudoExpand<(outs), (ins tcGPR:$dst, variable_ops),
2017 Requires<[IsARM, IsDarwin]>;
2021 // Non-Darwin versions (the difference is R9).
2022 let Defs = [R0, R1, R2, R3, R12, QQQQ0, QQQQ2, QQQQ3, PC],
2024 def TCRETURNdiND : PseudoInst<(outs), (ins i32imm:$dst, variable_ops),
2025 IIC_Br, []>, Requires<[IsNotDarwin]>;
2027 def TCRETURNriND : PseudoInst<(outs), (ins tcGPR:$dst, variable_ops),
2028 IIC_Br, []>, Requires<[IsNotDarwin]>;
2030 def TAILJMPdND : ARMPseudoExpand<(outs), (ins brtarget:$dst, variable_ops),
2032 (Bcc br_target:$dst, (ops 14, zero_reg))>,
2033 Requires<[IsARM, IsNotDarwin]>;
2035 def TAILJMPrND : ARMPseudoExpand<(outs), (ins tcGPR:$dst, variable_ops),
2038 Requires<[IsARM, IsNotDarwin]>;
2042 // Secure Monitor Call is a system instruction.
2043 def SMC : ABI<0b0001, (outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt",
2046 let Inst{23-4} = 0b01100000000000000111;
2047 let Inst{3-0} = opt;
2050 // Supervisor Call (Software Interrupt)
2051 let isCall = 1, Uses = [SP] in {
2052 def SVC : ABI<0b1111, (outs), (ins imm24b:$svc), IIC_Br, "svc", "\t$svc", []> {
2054 let Inst{23-0} = svc;
2058 // Store Return State
2059 class SRSI<bit wb, string asm>
2060 : XI<(outs), (ins imm0_31:$mode), AddrModeNone, 4, IndexModeNone, BrFrm,
2061 NoItinerary, asm, "", []> {
2063 let Inst{31-28} = 0b1111;
2064 let Inst{27-25} = 0b100;
2068 let Inst{19-16} = 0b1101; // SP
2069 let Inst{15-5} = 0b00000101000;
2070 let Inst{4-0} = mode;
2073 def SRSDA : SRSI<0, "srsda\tsp, $mode"> {
2074 let Inst{24-23} = 0;
2076 def SRSDA_UPD : SRSI<1, "srsda\tsp!, $mode"> {
2077 let Inst{24-23} = 0;
2079 def SRSDB : SRSI<0, "srsdb\tsp, $mode"> {
2080 let Inst{24-23} = 0b10;
2082 def SRSDB_UPD : SRSI<1, "srsdb\tsp!, $mode"> {
2083 let Inst{24-23} = 0b10;
2085 def SRSIA : SRSI<0, "srsia\tsp, $mode"> {
2086 let Inst{24-23} = 0b01;
2088 def SRSIA_UPD : SRSI<1, "srsia\tsp!, $mode"> {
2089 let Inst{24-23} = 0b01;
2091 def SRSIB : SRSI<0, "srsib\tsp, $mode"> {
2092 let Inst{24-23} = 0b11;
2094 def SRSIB_UPD : SRSI<1, "srsib\tsp!, $mode"> {
2095 let Inst{24-23} = 0b11;
2098 // Return From Exception
2099 class RFEI<bit wb, string asm>
2100 : XI<(outs), (ins GPR:$Rn), AddrModeNone, 4, IndexModeNone, BrFrm,
2101 NoItinerary, asm, "", []> {
2103 let Inst{31-28} = 0b1111;
2104 let Inst{27-25} = 0b100;
2108 let Inst{19-16} = Rn;
2109 let Inst{15-0} = 0xa00;
2112 def RFEDA : RFEI<0, "rfeda\t$Rn"> {
2113 let Inst{24-23} = 0;
2115 def RFEDA_UPD : RFEI<1, "rfeda\t$Rn!"> {
2116 let Inst{24-23} = 0;
2118 def RFEDB : RFEI<0, "rfedb\t$Rn"> {
2119 let Inst{24-23} = 0b10;
2121 def RFEDB_UPD : RFEI<1, "rfedb\t$Rn!"> {
2122 let Inst{24-23} = 0b10;
2124 def RFEIA : RFEI<0, "rfeia\t$Rn"> {
2125 let Inst{24-23} = 0b01;
2127 def RFEIA_UPD : RFEI<1, "rfeia\t$Rn!"> {
2128 let Inst{24-23} = 0b01;
2130 def RFEIB : RFEI<0, "rfeib\t$Rn"> {
2131 let Inst{24-23} = 0b11;
2133 def RFEIB_UPD : RFEI<1, "rfeib\t$Rn!"> {
2134 let Inst{24-23} = 0b11;
2137 //===----------------------------------------------------------------------===//
2138 // Load / store Instructions.
2144 defm LDR : AI_ldr1<0, "ldr", IIC_iLoad_r, IIC_iLoad_si,
2145 UnOpFrag<(load node:$Src)>>;
2146 defm LDRB : AI_ldr1nopc<1, "ldrb", IIC_iLoad_bh_r, IIC_iLoad_bh_si,
2147 UnOpFrag<(zextloadi8 node:$Src)>>;
2148 defm STR : AI_str1<0, "str", IIC_iStore_r, IIC_iStore_si,
2149 BinOpFrag<(store node:$LHS, node:$RHS)>>;
2150 defm STRB : AI_str1nopc<1, "strb", IIC_iStore_bh_r, IIC_iStore_bh_si,
2151 BinOpFrag<(truncstorei8 node:$LHS, node:$RHS)>>;
2153 // Special LDR for loads from non-pc-relative constpools.
2154 let canFoldAsLoad = 1, mayLoad = 1, neverHasSideEffects = 1,
2155 isReMaterializable = 1, isCodeGenOnly = 1 in
2156 def LDRcp : AI2ldst<0b010, 1, 0, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
2157 AddrMode_i12, LdFrm, IIC_iLoad_r, "ldr", "\t$Rt, $addr",
2161 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2162 let Inst{19-16} = 0b1111;
2163 let Inst{15-12} = Rt;
2164 let Inst{11-0} = addr{11-0}; // imm12
2167 // Loads with zero extension
2168 def LDRH : AI3ld<0b1011, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2169 IIC_iLoad_bh_r, "ldrh", "\t$Rt, $addr",
2170 [(set GPR:$Rt, (zextloadi16 addrmode3:$addr))]>;
2172 // Loads with sign extension
2173 def LDRSH : AI3ld<0b1111, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2174 IIC_iLoad_bh_r, "ldrsh", "\t$Rt, $addr",
2175 [(set GPR:$Rt, (sextloadi16 addrmode3:$addr))]>;
2177 def LDRSB : AI3ld<0b1101, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2178 IIC_iLoad_bh_r, "ldrsb", "\t$Rt, $addr",
2179 [(set GPR:$Rt, (sextloadi8 addrmode3:$addr))]>;
2181 let mayLoad = 1, neverHasSideEffects = 1, hasExtraDefRegAllocReq = 1 in {
2183 def LDRD : AI3ld<0b1101, 0, (outs GPR:$Rd, GPR:$dst2),
2184 (ins addrmode3:$addr), LdMiscFrm,
2185 IIC_iLoad_d_r, "ldrd", "\t$Rd, $dst2, $addr",
2186 []>, Requires<[IsARM, HasV5TE]>;
2190 multiclass AI2_ldridx<bit isByte, string opc, InstrItinClass itin> {
2191 def _PRE_IMM : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2192 (ins addrmode_imm12:$addr), IndexModePre, LdFrm, itin,
2193 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2196 let Inst{23} = addr{12};
2197 let Inst{19-16} = addr{16-13};
2198 let Inst{11-0} = addr{11-0};
2199 let DecoderMethod = "DecodeLDRPreImm";
2200 let AsmMatchConverter = "cvtLdWriteBackRegAddrModeImm12";
2203 def _PRE_REG : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2204 (ins ldst_so_reg:$addr), IndexModePre, LdFrm, itin,
2205 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2208 let Inst{23} = addr{12};
2209 let Inst{19-16} = addr{16-13};
2210 let Inst{11-0} = addr{11-0};
2212 let DecoderMethod = "DecodeLDRPreReg";
2213 let AsmMatchConverter = "cvtLdWriteBackRegAddrMode2";
2216 def _POST_REG : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2217 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2218 IndexModePost, LdFrm, itin,
2219 opc, "\t$Rt, $addr, $offset",
2220 "$addr.base = $Rn_wb", []> {
2226 let Inst{23} = offset{12};
2227 let Inst{19-16} = addr;
2228 let Inst{11-0} = offset{11-0};
2230 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2233 def _POST_IMM : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2234 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2235 IndexModePost, LdFrm, itin,
2236 opc, "\t$Rt, $addr, $offset",
2237 "$addr.base = $Rn_wb", []> {
2243 let Inst{23} = offset{12};
2244 let Inst{19-16} = addr;
2245 let Inst{11-0} = offset{11-0};
2247 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2252 let mayLoad = 1, neverHasSideEffects = 1 in {
2253 defm LDR : AI2_ldridx<0, "ldr", IIC_iLoad_ru>;
2254 defm LDRB : AI2_ldridx<1, "ldrb", IIC_iLoad_bh_ru>;
2257 multiclass AI3_ldridx<bits<4> op, string opc, InstrItinClass itin> {
2258 def _PRE : AI3ldstidx<op, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2259 (ins addrmode3:$addr), IndexModePre,
2261 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2263 let Inst{23} = addr{8}; // U bit
2264 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2265 let Inst{19-16} = addr{12-9}; // Rn
2266 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2267 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2268 let AsmMatchConverter = "cvtLdWriteBackRegAddrMode3";
2269 let DecoderMethod = "DecodeAddrMode3Instruction";
2271 def _POST : AI3ldstidx<op, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2272 (ins addr_offset_none:$addr, am3offset:$offset),
2273 IndexModePost, LdMiscFrm, itin,
2274 opc, "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2278 let Inst{23} = offset{8}; // U bit
2279 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2280 let Inst{19-16} = addr;
2281 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2282 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2283 let DecoderMethod = "DecodeAddrMode3Instruction";
2287 let mayLoad = 1, neverHasSideEffects = 1 in {
2288 defm LDRH : AI3_ldridx<0b1011, "ldrh", IIC_iLoad_bh_ru>;
2289 defm LDRSH : AI3_ldridx<0b1111, "ldrsh", IIC_iLoad_bh_ru>;
2290 defm LDRSB : AI3_ldridx<0b1101, "ldrsb", IIC_iLoad_bh_ru>;
2291 let hasExtraDefRegAllocReq = 1 in {
2292 def LDRD_PRE : AI3ldstidx<0b1101, 0, 1, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2293 (ins addrmode3:$addr), IndexModePre,
2294 LdMiscFrm, IIC_iLoad_d_ru,
2295 "ldrd", "\t$Rt, $Rt2, $addr!",
2296 "$addr.base = $Rn_wb", []> {
2298 let Inst{23} = addr{8}; // U bit
2299 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2300 let Inst{19-16} = addr{12-9}; // Rn
2301 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2302 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2303 let DecoderMethod = "DecodeAddrMode3Instruction";
2304 let AsmMatchConverter = "cvtLdrdPre";
2306 def LDRD_POST: AI3ldstidx<0b1101, 0, 0, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2307 (ins addr_offset_none:$addr, am3offset:$offset),
2308 IndexModePost, LdMiscFrm, IIC_iLoad_d_ru,
2309 "ldrd", "\t$Rt, $Rt2, $addr, $offset",
2310 "$addr.base = $Rn_wb", []> {
2313 let Inst{23} = offset{8}; // U bit
2314 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2315 let Inst{19-16} = addr;
2316 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2317 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2318 let DecoderMethod = "DecodeAddrMode3Instruction";
2320 } // hasExtraDefRegAllocReq = 1
2321 } // mayLoad = 1, neverHasSideEffects = 1
2323 // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT.
2324 let mayLoad = 1, neverHasSideEffects = 1 in {
2325 def LDRT_POST_REG : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2326 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2327 IndexModePost, LdFrm, IIC_iLoad_ru,
2328 "ldrt", "\t$Rt, $addr, $offset",
2329 "$addr.base = $Rn_wb", []> {
2335 let Inst{23} = offset{12};
2336 let Inst{21} = 1; // overwrite
2337 let Inst{19-16} = addr;
2338 let Inst{11-5} = offset{11-5};
2340 let Inst{3-0} = offset{3-0};
2341 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2344 def LDRT_POST_IMM : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2345 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2346 IndexModePost, LdFrm, IIC_iLoad_ru,
2347 "ldrt", "\t$Rt, $addr, $offset",
2348 "$addr.base = $Rn_wb", []> {
2354 let Inst{23} = offset{12};
2355 let Inst{21} = 1; // overwrite
2356 let Inst{19-16} = addr;
2357 let Inst{11-0} = offset{11-0};
2358 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2361 def LDRBT_POST_REG : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2362 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2363 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2364 "ldrbt", "\t$Rt, $addr, $offset",
2365 "$addr.base = $Rn_wb", []> {
2371 let Inst{23} = offset{12};
2372 let Inst{21} = 1; // overwrite
2373 let Inst{19-16} = addr;
2374 let Inst{11-5} = offset{11-5};
2376 let Inst{3-0} = offset{3-0};
2377 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2380 def LDRBT_POST_IMM : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2381 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2382 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2383 "ldrbt", "\t$Rt, $addr, $offset",
2384 "$addr.base = $Rn_wb", []> {
2390 let Inst{23} = offset{12};
2391 let Inst{21} = 1; // overwrite
2392 let Inst{19-16} = addr;
2393 let Inst{11-0} = offset{11-0};
2394 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2397 multiclass AI3ldrT<bits<4> op, string opc> {
2398 def i : AI3ldstidxT<op, 1, (outs GPR:$Rt, GPR:$base_wb),
2399 (ins addr_offset_none:$addr, postidx_imm8:$offset),
2400 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2401 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2403 let Inst{23} = offset{8};
2405 let Inst{11-8} = offset{7-4};
2406 let Inst{3-0} = offset{3-0};
2407 let AsmMatchConverter = "cvtLdExtTWriteBackImm";
2409 def r : AI3ldstidxT<op, 1, (outs GPR:$Rt, GPR:$base_wb),
2410 (ins addr_offset_none:$addr, postidx_reg:$Rm),
2411 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2412 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2414 let Inst{23} = Rm{4};
2417 let Inst{3-0} = Rm{3-0};
2418 let AsmMatchConverter = "cvtLdExtTWriteBackReg";
2422 defm LDRSBT : AI3ldrT<0b1101, "ldrsbt">;
2423 defm LDRHT : AI3ldrT<0b1011, "ldrht">;
2424 defm LDRSHT : AI3ldrT<0b1111, "ldrsht">;
2429 // Stores with truncate
2430 def STRH : AI3str<0b1011, (outs), (ins GPR:$Rt, addrmode3:$addr), StMiscFrm,
2431 IIC_iStore_bh_r, "strh", "\t$Rt, $addr",
2432 [(truncstorei16 GPR:$Rt, addrmode3:$addr)]>;
2435 let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in
2436 def STRD : AI3str<0b1111, (outs), (ins GPR:$Rt, GPR:$src2, addrmode3:$addr),
2437 StMiscFrm, IIC_iStore_d_r,
2438 "strd", "\t$Rt, $src2, $addr", []>,
2439 Requires<[IsARM, HasV5TE]> {
2444 multiclass AI2_stridx<bit isByte, string opc, InstrItinClass itin> {
2445 def _PRE_IMM : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2446 (ins GPR:$Rt, addrmode_imm12:$addr), IndexModePre,
2448 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2451 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2452 let Inst{19-16} = addr{16-13}; // Rn
2453 let Inst{11-0} = addr{11-0}; // imm12
2454 let AsmMatchConverter = "cvtStWriteBackRegAddrModeImm12";
2455 let DecoderMethod = "DecodeSTRPreImm";
2458 def _PRE_REG : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2459 (ins GPR:$Rt, ldst_so_reg:$addr),
2460 IndexModePre, StFrm, itin,
2461 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2464 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2465 let Inst{19-16} = addr{16-13}; // Rn
2466 let Inst{11-0} = addr{11-0};
2467 let Inst{4} = 0; // Inst{4} = 0
2468 let AsmMatchConverter = "cvtStWriteBackRegAddrMode2";
2469 let DecoderMethod = "DecodeSTRPreReg";
2471 def _POST_REG : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2472 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2473 IndexModePost, StFrm, itin,
2474 opc, "\t$Rt, $addr, $offset",
2475 "$addr.base = $Rn_wb", []> {
2481 let Inst{23} = offset{12};
2482 let Inst{19-16} = addr;
2483 let Inst{11-0} = offset{11-0};
2485 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2488 def _POST_IMM : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2489 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2490 IndexModePost, StFrm, itin,
2491 opc, "\t$Rt, $addr, $offset",
2492 "$addr.base = $Rn_wb", []> {
2498 let Inst{23} = offset{12};
2499 let Inst{19-16} = addr;
2500 let Inst{11-0} = offset{11-0};
2502 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2506 let mayStore = 1, neverHasSideEffects = 1 in {
2507 defm STR : AI2_stridx<0, "str", IIC_iStore_ru>;
2508 defm STRB : AI2_stridx<1, "strb", IIC_iStore_bh_ru>;
2511 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2512 am2offset_reg:$offset),
2513 (STR_POST_REG GPR:$Rt, addr_offset_none:$addr,
2514 am2offset_reg:$offset)>;
2515 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2516 am2offset_imm:$offset),
2517 (STR_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2518 am2offset_imm:$offset)>;
2519 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2520 am2offset_reg:$offset),
2521 (STRB_POST_REG GPR:$Rt, addr_offset_none:$addr,
2522 am2offset_reg:$offset)>;
2523 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
2524 am2offset_imm:$offset),
2525 (STRB_POST_IMM GPR:$Rt, addr_offset_none:$addr,
2526 am2offset_imm:$offset)>;
2528 // Pseudo-instructions for pattern matching the pre-indexed stores. We can't
2529 // put the patterns on the instruction definitions directly as ISel wants
2530 // the address base and offset to be separate operands, not a single
2531 // complex operand like we represent the instructions themselves. The
2532 // pseudos map between the two.
2533 let usesCustomInserter = 1,
2534 Constraints = "$Rn = $Rn_wb,@earlyclobber $Rn_wb" in {
2535 def STRi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2536 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2539 (pre_store GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2540 def STRr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2541 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2544 (pre_store GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2545 def STRBi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2546 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
2549 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
2550 def STRBr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2551 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
2554 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
2555 def STRH_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
2556 (ins GPR:$Rt, GPR:$Rn, am3offset:$offset, pred:$p),
2559 (pre_truncsti16 GPR:$Rt, GPR:$Rn, am3offset:$offset))]>;
2564 def STRH_PRE : AI3ldstidx<0b1011, 0, 1, (outs GPR:$Rn_wb),
2565 (ins GPR:$Rt, addrmode3:$addr), IndexModePre,
2566 StMiscFrm, IIC_iStore_bh_ru,
2567 "strh", "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2569 let Inst{23} = addr{8}; // U bit
2570 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2571 let Inst{19-16} = addr{12-9}; // Rn
2572 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2573 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2574 let AsmMatchConverter = "cvtStWriteBackRegAddrMode3";
2575 let DecoderMethod = "DecodeAddrMode3Instruction";
2578 def STRH_POST : AI3ldstidx<0b1011, 0, 0, (outs GPR:$Rn_wb),
2579 (ins GPR:$Rt, addr_offset_none:$addr, am3offset:$offset),
2580 IndexModePost, StMiscFrm, IIC_iStore_bh_ru,
2581 "strh", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2582 [(set GPR:$Rn_wb, (post_truncsti16 GPR:$Rt,
2583 addr_offset_none:$addr,
2584 am3offset:$offset))]> {
2587 let Inst{23} = offset{8}; // U bit
2588 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2589 let Inst{19-16} = addr;
2590 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2591 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2592 let DecoderMethod = "DecodeAddrMode3Instruction";
2595 let mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1 in {
2596 def STRD_PRE : AI3ldstidx<0b1111, 0, 1, (outs GPR:$Rn_wb),
2597 (ins GPR:$Rt, GPR:$Rt2, addrmode3:$addr),
2598 IndexModePre, StMiscFrm, IIC_iStore_d_ru,
2599 "strd", "\t$Rt, $Rt2, $addr!",
2600 "$addr.base = $Rn_wb", []> {
2602 let Inst{23} = addr{8}; // U bit
2603 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2604 let Inst{19-16} = addr{12-9}; // Rn
2605 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2606 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2607 let DecoderMethod = "DecodeAddrMode3Instruction";
2608 let AsmMatchConverter = "cvtStrdPre";
2611 def STRD_POST: AI3ldstidx<0b1111, 0, 0, (outs GPR:$Rn_wb),
2612 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr,
2614 IndexModePost, StMiscFrm, IIC_iStore_d_ru,
2615 "strd", "\t$Rt, $Rt2, $addr, $offset",
2616 "$addr.base = $Rn_wb", []> {
2619 let Inst{23} = offset{8}; // U bit
2620 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2621 let Inst{19-16} = addr;
2622 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2623 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2624 let DecoderMethod = "DecodeAddrMode3Instruction";
2626 } // mayStore = 1, neverHasSideEffects = 1, hasExtraSrcRegAllocReq = 1
2628 // STRT, STRBT, and STRHT
2630 def STRBT_POST_REG : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2631 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2632 IndexModePost, StFrm, IIC_iStore_bh_ru,
2633 "strbt", "\t$Rt, $addr, $offset",
2634 "$addr.base = $Rn_wb", []> {
2640 let Inst{23} = offset{12};
2641 let Inst{21} = 1; // overwrite
2642 let Inst{19-16} = addr;
2643 let Inst{11-5} = offset{11-5};
2645 let Inst{3-0} = offset{3-0};
2646 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2649 def STRBT_POST_IMM : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
2650 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2651 IndexModePost, StFrm, IIC_iStore_bh_ru,
2652 "strbt", "\t$Rt, $addr, $offset",
2653 "$addr.base = $Rn_wb", []> {
2659 let Inst{23} = offset{12};
2660 let Inst{21} = 1; // overwrite
2661 let Inst{19-16} = addr;
2662 let Inst{11-0} = offset{11-0};
2663 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2666 let mayStore = 1, neverHasSideEffects = 1 in {
2667 def STRT_POST_REG : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
2668 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2669 IndexModePost, StFrm, IIC_iStore_ru,
2670 "strt", "\t$Rt, $addr, $offset",
2671 "$addr.base = $Rn_wb", []> {
2677 let Inst{23} = offset{12};
2678 let Inst{21} = 1; // overwrite
2679 let Inst{19-16} = addr;
2680 let Inst{11-5} = offset{11-5};
2682 let Inst{3-0} = offset{3-0};
2683 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2686 def STRT_POST_IMM : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
2687 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2688 IndexModePost, StFrm, IIC_iStore_ru,
2689 "strt", "\t$Rt, $addr, $offset",
2690 "$addr.base = $Rn_wb", []> {
2696 let Inst{23} = offset{12};
2697 let Inst{21} = 1; // overwrite
2698 let Inst{19-16} = addr;
2699 let Inst{11-0} = offset{11-0};
2700 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2705 multiclass AI3strT<bits<4> op, string opc> {
2706 def i : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
2707 (ins GPR:$Rt, addr_offset_none:$addr, postidx_imm8:$offset),
2708 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
2709 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2711 let Inst{23} = offset{8};
2713 let Inst{11-8} = offset{7-4};
2714 let Inst{3-0} = offset{3-0};
2715 let AsmMatchConverter = "cvtStExtTWriteBackImm";
2717 def r : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
2718 (ins GPR:$Rt, addr_offset_none:$addr, postidx_reg:$Rm),
2719 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
2720 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2722 let Inst{23} = Rm{4};
2725 let Inst{3-0} = Rm{3-0};
2726 let AsmMatchConverter = "cvtStExtTWriteBackReg";
2731 defm STRHT : AI3strT<0b1011, "strht">;
2734 //===----------------------------------------------------------------------===//
2735 // Load / store multiple Instructions.
2738 multiclass arm_ldst_mult<string asm, bit L_bit, Format f,
2739 InstrItinClass itin, InstrItinClass itin_upd> {
2740 // IA is the default, so no need for an explicit suffix on the
2741 // mnemonic here. Without it is the cannonical spelling.
2743 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2744 IndexModeNone, f, itin,
2745 !strconcat(asm, "${p}\t$Rn, $regs"), "", []> {
2746 let Inst{24-23} = 0b01; // Increment After
2747 let Inst{21} = 0; // No writeback
2748 let Inst{20} = L_bit;
2751 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2752 IndexModeUpd, f, itin_upd,
2753 !strconcat(asm, "${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
2754 let Inst{24-23} = 0b01; // Increment After
2755 let Inst{21} = 1; // Writeback
2756 let Inst{20} = L_bit;
2758 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2761 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2762 IndexModeNone, f, itin,
2763 !strconcat(asm, "da${p}\t$Rn, $regs"), "", []> {
2764 let Inst{24-23} = 0b00; // Decrement After
2765 let Inst{21} = 0; // No writeback
2766 let Inst{20} = L_bit;
2769 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2770 IndexModeUpd, f, itin_upd,
2771 !strconcat(asm, "da${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
2772 let Inst{24-23} = 0b00; // Decrement After
2773 let Inst{21} = 1; // Writeback
2774 let Inst{20} = L_bit;
2776 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2779 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2780 IndexModeNone, f, itin,
2781 !strconcat(asm, "db${p}\t$Rn, $regs"), "", []> {
2782 let Inst{24-23} = 0b10; // Decrement Before
2783 let Inst{21} = 0; // No writeback
2784 let Inst{20} = L_bit;
2787 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2788 IndexModeUpd, f, itin_upd,
2789 !strconcat(asm, "db${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
2790 let Inst{24-23} = 0b10; // Decrement Before
2791 let Inst{21} = 1; // Writeback
2792 let Inst{20} = L_bit;
2794 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2797 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2798 IndexModeNone, f, itin,
2799 !strconcat(asm, "ib${p}\t$Rn, $regs"), "", []> {
2800 let Inst{24-23} = 0b11; // Increment Before
2801 let Inst{21} = 0; // No writeback
2802 let Inst{20} = L_bit;
2805 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
2806 IndexModeUpd, f, itin_upd,
2807 !strconcat(asm, "ib${p}\t$Rn!, $regs"), "$Rn = $wb", []> {
2808 let Inst{24-23} = 0b11; // Increment Before
2809 let Inst{21} = 1; // Writeback
2810 let Inst{20} = L_bit;
2812 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
2816 let neverHasSideEffects = 1 in {
2818 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
2819 defm LDM : arm_ldst_mult<"ldm", 1, LdStMulFrm, IIC_iLoad_m, IIC_iLoad_mu>;
2821 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
2822 defm STM : arm_ldst_mult<"stm", 0, LdStMulFrm, IIC_iStore_m, IIC_iStore_mu>;
2824 } // neverHasSideEffects
2826 // FIXME: remove when we have a way to marking a MI with these properties.
2827 // FIXME: Should pc be an implicit operand like PICADD, etc?
2828 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
2829 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
2830 def LDMIA_RET : ARMPseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p,
2831 reglist:$regs, variable_ops),
2832 4, IIC_iLoad_mBr, [],
2833 (LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>,
2834 RegConstraint<"$Rn = $wb">;
2836 //===----------------------------------------------------------------------===//
2837 // Move Instructions.
2840 let neverHasSideEffects = 1 in
2841 def MOVr : AsI1<0b1101, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMOVr,
2842 "mov", "\t$Rd, $Rm", []>, UnaryDP {
2846 let Inst{19-16} = 0b0000;
2847 let Inst{11-4} = 0b00000000;
2850 let Inst{15-12} = Rd;
2853 def : ARMInstAlias<"movs${p} $Rd, $Rm",
2854 (MOVr GPR:$Rd, GPR:$Rm, pred:$p, CPSR)>;
2856 // A version for the smaller set of tail call registers.
2857 let neverHasSideEffects = 1 in
2858 def MOVr_TC : AsI1<0b1101, (outs tcGPR:$Rd), (ins tcGPR:$Rm), DPFrm,
2859 IIC_iMOVr, "mov", "\t$Rd, $Rm", []>, UnaryDP {
2863 let Inst{11-4} = 0b00000000;
2866 let Inst{15-12} = Rd;
2869 def MOVsr : AsI1<0b1101, (outs GPRnopc:$Rd), (ins shift_so_reg_reg:$src),
2870 DPSoRegRegFrm, IIC_iMOVsr,
2871 "mov", "\t$Rd, $src",
2872 [(set GPRnopc:$Rd, shift_so_reg_reg:$src)]>, UnaryDP {
2875 let Inst{15-12} = Rd;
2876 let Inst{19-16} = 0b0000;
2877 let Inst{11-8} = src{11-8};
2879 let Inst{6-5} = src{6-5};
2881 let Inst{3-0} = src{3-0};
2885 def MOVsi : AsI1<0b1101, (outs GPR:$Rd), (ins shift_so_reg_imm:$src),
2886 DPSoRegImmFrm, IIC_iMOVsr,
2887 "mov", "\t$Rd, $src", [(set GPR:$Rd, shift_so_reg_imm:$src)]>,
2891 let Inst{15-12} = Rd;
2892 let Inst{19-16} = 0b0000;
2893 let Inst{11-5} = src{11-5};
2895 let Inst{3-0} = src{3-0};
2899 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
2900 def MOVi : AsI1<0b1101, (outs GPR:$Rd), (ins so_imm:$imm), DPFrm, IIC_iMOVi,
2901 "mov", "\t$Rd, $imm", [(set GPR:$Rd, so_imm:$imm)]>, UnaryDP {
2905 let Inst{15-12} = Rd;
2906 let Inst{19-16} = 0b0000;
2907 let Inst{11-0} = imm;
2910 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
2911 def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins imm0_65535_expr:$imm),
2913 "movw", "\t$Rd, $imm",
2914 [(set GPR:$Rd, imm0_65535:$imm)]>,
2915 Requires<[IsARM, HasV6T2]>, UnaryDP {
2918 let Inst{15-12} = Rd;
2919 let Inst{11-0} = imm{11-0};
2920 let Inst{19-16} = imm{15-12};
2923 let DecoderMethod = "DecodeArmMOVTWInstruction";
2926 def : InstAlias<"mov${p} $Rd, $imm",
2927 (MOVi16 GPR:$Rd, imm0_65535_expr:$imm, pred:$p)>,
2930 def MOVi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
2931 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>;
2933 let Constraints = "$src = $Rd" in {
2934 def MOVTi16 : AI1<0b1010, (outs GPRnopc:$Rd),
2935 (ins GPR:$src, imm0_65535_expr:$imm),
2937 "movt", "\t$Rd, $imm",
2939 (or (and GPR:$src, 0xffff),
2940 lo16AllZero:$imm))]>, UnaryDP,
2941 Requires<[IsARM, HasV6T2]> {
2944 let Inst{15-12} = Rd;
2945 let Inst{11-0} = imm{11-0};
2946 let Inst{19-16} = imm{15-12};
2949 let DecoderMethod = "DecodeArmMOVTWInstruction";
2952 def MOVTi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
2953 (ins GPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>;
2957 def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
2958 Requires<[IsARM, HasV6T2]>;
2960 let Uses = [CPSR] in
2961 def RRX: PseudoInst<(outs GPR:$Rd), (ins GPR:$Rm), IIC_iMOVsi,
2962 [(set GPR:$Rd, (ARMrrx GPR:$Rm))]>, UnaryDP,
2965 // These aren't really mov instructions, but we have to define them this way
2966 // due to flag operands.
2968 let Defs = [CPSR] in {
2969 def MOVsrl_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
2970 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP,
2972 def MOVsra_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
2973 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP,
2977 //===----------------------------------------------------------------------===//
2978 // Extend Instructions.
2983 def SXTB : AI_ext_rrot<0b01101010,
2984 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
2985 def SXTH : AI_ext_rrot<0b01101011,
2986 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
2988 def SXTAB : AI_exta_rrot<0b01101010,
2989 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
2990 def SXTAH : AI_exta_rrot<0b01101011,
2991 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
2993 def SXTB16 : AI_ext_rrot_np<0b01101000, "sxtb16">;
2995 def SXTAB16 : AI_exta_rrot_np<0b01101000, "sxtab16">;
2999 let AddedComplexity = 16 in {
3000 def UXTB : AI_ext_rrot<0b01101110,
3001 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
3002 def UXTH : AI_ext_rrot<0b01101111,
3003 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
3004 def UXTB16 : AI_ext_rrot<0b01101100,
3005 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
3007 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
3008 // The transformation should probably be done as a combiner action
3009 // instead so we can include a check for masking back in the upper
3010 // eight bits of the source into the lower eight bits of the result.
3011 //def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
3012 // (UXTB16r_rot GPR:$Src, 3)>;
3013 def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
3014 (UXTB16 GPR:$Src, 1)>;
3016 def UXTAB : AI_exta_rrot<0b01101110, "uxtab",
3017 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
3018 def UXTAH : AI_exta_rrot<0b01101111, "uxtah",
3019 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
3022 // This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
3023 def UXTAB16 : AI_exta_rrot_np<0b01101100, "uxtab16">;
3026 def SBFX : I<(outs GPRnopc:$Rd),
3027 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3028 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3029 "sbfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3030 Requires<[IsARM, HasV6T2]> {
3035 let Inst{27-21} = 0b0111101;
3036 let Inst{6-4} = 0b101;
3037 let Inst{20-16} = width;
3038 let Inst{15-12} = Rd;
3039 let Inst{11-7} = lsb;
3043 def UBFX : I<(outs GPR:$Rd),
3044 (ins GPR:$Rn, imm0_31:$lsb, imm1_32:$width),
3045 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3046 "ubfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3047 Requires<[IsARM, HasV6T2]> {
3052 let Inst{27-21} = 0b0111111;
3053 let Inst{6-4} = 0b101;
3054 let Inst{20-16} = width;
3055 let Inst{15-12} = Rd;
3056 let Inst{11-7} = lsb;
3060 //===----------------------------------------------------------------------===//
3061 // Arithmetic Instructions.
3064 defm ADD : AsI1_bin_irs<0b0100, "add",
3065 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3066 BinOpFrag<(add node:$LHS, node:$RHS)>, "ADD", 1>;
3067 defm SUB : AsI1_bin_irs<0b0010, "sub",
3068 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3069 BinOpFrag<(sub node:$LHS, node:$RHS)>, "SUB">;
3071 // ADD and SUB with 's' bit set.
3073 // Currently, t2ADDS/t2SUBS are pseudo opcodes that exist only in the
3074 // selection DAG. They are "lowered" to real t2ADD/t2SUB opcodes by
3075 // AdjustInstrPostInstrSelection where we determine whether or not to
3076 // set the "s" bit based on CPSR liveness.
3078 // FIXME: Eliminate t2ADDS/t2SUBS pseudo opcodes after adding tablegen
3079 // support for an optional CPSR definition that corresponds to the DAG
3080 // node's second value. We can then eliminate the implicit def of CPSR.
3081 defm ADDS : AsI1_bin_s_irs<0b0100, "add",
3082 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3083 BinOpFrag<(ARMaddc node:$LHS, node:$RHS)>, 1>;
3084 defm SUBS : AsI1_bin_s_irs<0b0010, "sub",
3085 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3086 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
3088 defm ADC : AI1_adde_sube_irs<0b0101, "adc",
3089 BinOpWithFlagFrag<(ARMadde node:$LHS, node:$RHS, node:$FLAG)>,
3091 defm SBC : AI1_adde_sube_irs<0b0110, "sbc",
3092 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>,
3095 defm RSB : AsI1_rbin_irs <0b0011, "rsb",
3096 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3097 BinOpFrag<(sub node:$LHS, node:$RHS)>, "RSB">;
3099 // FIXME: Eliminate them if we can write def : Pat patterns which defines
3100 // CPSR and the implicit def of CPSR is not needed.
3101 defm RSBS : AsI1_rbin_s_is<0b0011, "rsb",
3102 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3103 BinOpFrag<(ARMsubc node:$LHS, node:$RHS)>>;
3105 defm RSC : AI1_rsc_irs<0b0111, "rsc",
3106 BinOpWithFlagFrag<(ARMsube node:$LHS, node:$RHS, node:$FLAG)>,
3109 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
3110 // The assume-no-carry-in form uses the negation of the input since add/sub
3111 // assume opposite meanings of the carry flag (i.e., carry == !borrow).
3112 // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
3114 def : ARMPat<(add GPR:$src, so_imm_neg:$imm),
3115 (SUBri GPR:$src, so_imm_neg:$imm)>;
3116 def : ARMPat<(ARMaddc GPR:$src, so_imm_neg:$imm),
3117 (SUBSri GPR:$src, so_imm_neg:$imm)>;
3119 // The with-carry-in form matches bitwise not instead of the negation.
3120 // Effectively, the inverse interpretation of the carry flag already accounts
3121 // for part of the negation.
3122 def : ARMPat<(ARMadde GPR:$src, so_imm_not:$imm, CPSR),
3123 (SBCri GPR:$src, so_imm_not:$imm)>;
3125 // Note: These are implemented in C++ code, because they have to generate
3126 // ADD/SUBrs instructions, which use a complex pattern that a xform function
3128 // (mul X, 2^n+1) -> (add (X << n), X)
3129 // (mul X, 2^n-1) -> (rsb X, (X << n))
3131 // ARM Arithmetic Instruction
3132 // GPR:$dst = GPR:$a op GPR:$b
3133 class AAI<bits<8> op27_20, bits<8> op11_4, string opc,
3134 list<dag> pattern = [],
3135 dag iops = (ins GPRnopc:$Rn, GPRnopc:$Rm),
3136 string asm = "\t$Rd, $Rn, $Rm">
3137 : AI<(outs GPRnopc:$Rd), iops, DPFrm, IIC_iALUr, opc, asm, pattern> {
3141 let Inst{27-20} = op27_20;
3142 let Inst{11-4} = op11_4;
3143 let Inst{19-16} = Rn;
3144 let Inst{15-12} = Rd;
3148 // Saturating add/subtract
3150 def QADD : AAI<0b00010000, 0b00000101, "qadd",
3151 [(set GPRnopc:$Rd, (int_arm_qadd GPRnopc:$Rm, GPRnopc:$Rn))],
3152 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3153 def QSUB : AAI<0b00010010, 0b00000101, "qsub",
3154 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm, GPRnopc:$Rn))],
3155 (ins GPRnopc:$Rm, GPRnopc:$Rn), "\t$Rd, $Rm, $Rn">;
3156 def QDADD : AAI<0b00010100, 0b00000101, "qdadd", [],
3157 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3159 def QDSUB : AAI<0b00010110, 0b00000101, "qdsub", [],
3160 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3163 def QADD16 : AAI<0b01100010, 0b11110001, "qadd16">;
3164 def QADD8 : AAI<0b01100010, 0b11111001, "qadd8">;
3165 def QASX : AAI<0b01100010, 0b11110011, "qasx">;
3166 def QSAX : AAI<0b01100010, 0b11110101, "qsax">;
3167 def QSUB16 : AAI<0b01100010, 0b11110111, "qsub16">;
3168 def QSUB8 : AAI<0b01100010, 0b11111111, "qsub8">;
3169 def UQADD16 : AAI<0b01100110, 0b11110001, "uqadd16">;
3170 def UQADD8 : AAI<0b01100110, 0b11111001, "uqadd8">;
3171 def UQASX : AAI<0b01100110, 0b11110011, "uqasx">;
3172 def UQSAX : AAI<0b01100110, 0b11110101, "uqsax">;
3173 def UQSUB16 : AAI<0b01100110, 0b11110111, "uqsub16">;
3174 def UQSUB8 : AAI<0b01100110, 0b11111111, "uqsub8">;
3176 // Signed/Unsigned add/subtract
3178 def SASX : AAI<0b01100001, 0b11110011, "sasx">;
3179 def SADD16 : AAI<0b01100001, 0b11110001, "sadd16">;
3180 def SADD8 : AAI<0b01100001, 0b11111001, "sadd8">;
3181 def SSAX : AAI<0b01100001, 0b11110101, "ssax">;
3182 def SSUB16 : AAI<0b01100001, 0b11110111, "ssub16">;
3183 def SSUB8 : AAI<0b01100001, 0b11111111, "ssub8">;
3184 def UASX : AAI<0b01100101, 0b11110011, "uasx">;
3185 def UADD16 : AAI<0b01100101, 0b11110001, "uadd16">;
3186 def UADD8 : AAI<0b01100101, 0b11111001, "uadd8">;
3187 def USAX : AAI<0b01100101, 0b11110101, "usax">;
3188 def USUB16 : AAI<0b01100101, 0b11110111, "usub16">;
3189 def USUB8 : AAI<0b01100101, 0b11111111, "usub8">;
3191 // Signed/Unsigned halving add/subtract
3193 def SHASX : AAI<0b01100011, 0b11110011, "shasx">;
3194 def SHADD16 : AAI<0b01100011, 0b11110001, "shadd16">;
3195 def SHADD8 : AAI<0b01100011, 0b11111001, "shadd8">;
3196 def SHSAX : AAI<0b01100011, 0b11110101, "shsax">;
3197 def SHSUB16 : AAI<0b01100011, 0b11110111, "shsub16">;
3198 def SHSUB8 : AAI<0b01100011, 0b11111111, "shsub8">;
3199 def UHASX : AAI<0b01100111, 0b11110011, "uhasx">;
3200 def UHADD16 : AAI<0b01100111, 0b11110001, "uhadd16">;
3201 def UHADD8 : AAI<0b01100111, 0b11111001, "uhadd8">;
3202 def UHSAX : AAI<0b01100111, 0b11110101, "uhsax">;
3203 def UHSUB16 : AAI<0b01100111, 0b11110111, "uhsub16">;
3204 def UHSUB8 : AAI<0b01100111, 0b11111111, "uhsub8">;
3206 // Unsigned Sum of Absolute Differences [and Accumulate].
3208 def USAD8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3209 MulFrm /* for convenience */, NoItinerary, "usad8",
3210 "\t$Rd, $Rn, $Rm", []>,
3211 Requires<[IsARM, HasV6]> {
3215 let Inst{27-20} = 0b01111000;
3216 let Inst{15-12} = 0b1111;
3217 let Inst{7-4} = 0b0001;
3218 let Inst{19-16} = Rd;
3219 let Inst{11-8} = Rm;
3222 def USADA8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3223 MulFrm /* for convenience */, NoItinerary, "usada8",
3224 "\t$Rd, $Rn, $Rm, $Ra", []>,
3225 Requires<[IsARM, HasV6]> {
3230 let Inst{27-20} = 0b01111000;
3231 let Inst{7-4} = 0b0001;
3232 let Inst{19-16} = Rd;
3233 let Inst{15-12} = Ra;
3234 let Inst{11-8} = Rm;
3238 // Signed/Unsigned saturate
3240 def SSAT : AI<(outs GPRnopc:$Rd),
3241 (ins imm1_32:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3242 SatFrm, NoItinerary, "ssat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3247 let Inst{27-21} = 0b0110101;
3248 let Inst{5-4} = 0b01;
3249 let Inst{20-16} = sat_imm;
3250 let Inst{15-12} = Rd;
3251 let Inst{11-7} = sh{4-0};
3252 let Inst{6} = sh{5};
3256 def SSAT16 : AI<(outs GPRnopc:$Rd),
3257 (ins imm1_16:$sat_imm, GPRnopc:$Rn), SatFrm,
3258 NoItinerary, "ssat16", "\t$Rd, $sat_imm, $Rn", []> {
3262 let Inst{27-20} = 0b01101010;
3263 let Inst{11-4} = 0b11110011;
3264 let Inst{15-12} = Rd;
3265 let Inst{19-16} = sat_imm;
3269 def USAT : AI<(outs GPRnopc:$Rd),
3270 (ins imm0_31:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3271 SatFrm, NoItinerary, "usat", "\t$Rd, $sat_imm, $Rn$sh", []> {
3276 let Inst{27-21} = 0b0110111;
3277 let Inst{5-4} = 0b01;
3278 let Inst{15-12} = Rd;
3279 let Inst{11-7} = sh{4-0};
3280 let Inst{6} = sh{5};
3281 let Inst{20-16} = sat_imm;
3285 def USAT16 : AI<(outs GPRnopc:$Rd),
3286 (ins imm0_15:$sat_imm, GPRnopc:$Rn), SatFrm,
3287 NoItinerary, "usat16", "\t$Rd, $sat_imm, $Rn", []> {
3291 let Inst{27-20} = 0b01101110;
3292 let Inst{11-4} = 0b11110011;
3293 let Inst{15-12} = Rd;
3294 let Inst{19-16} = sat_imm;
3298 def : ARMV6Pat<(int_arm_ssat GPRnopc:$a, imm:$pos),
3299 (SSAT imm:$pos, GPRnopc:$a, 0)>;
3300 def : ARMV6Pat<(int_arm_usat GPRnopc:$a, imm:$pos),
3301 (USAT imm:$pos, GPRnopc:$a, 0)>;
3303 //===----------------------------------------------------------------------===//
3304 // Bitwise Instructions.
3307 defm AND : AsI1_bin_irs<0b0000, "and",
3308 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3309 BinOpFrag<(and node:$LHS, node:$RHS)>, "AND", 1>;
3310 defm ORR : AsI1_bin_irs<0b1100, "orr",
3311 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3312 BinOpFrag<(or node:$LHS, node:$RHS)>, "ORR", 1>;
3313 defm EOR : AsI1_bin_irs<0b0001, "eor",
3314 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3315 BinOpFrag<(xor node:$LHS, node:$RHS)>, "EOR", 1>;
3316 defm BIC : AsI1_bin_irs<0b1110, "bic",
3317 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3318 BinOpFrag<(and node:$LHS, (not node:$RHS))>, "BIC">;
3320 // FIXME: bf_inv_mask_imm should be two operands, the lsb and the msb, just
3321 // like in the actual instruction encoding. The complexity of mapping the mask
3322 // to the lsb/msb pair should be handled by ISel, not encapsulated in the
3323 // instruction description.
3324 def BFC : I<(outs GPR:$Rd), (ins GPR:$src, bf_inv_mask_imm:$imm),
3325 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3326 "bfc", "\t$Rd, $imm", "$src = $Rd",
3327 [(set GPR:$Rd, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
3328 Requires<[IsARM, HasV6T2]> {
3331 let Inst{27-21} = 0b0111110;
3332 let Inst{6-0} = 0b0011111;
3333 let Inst{15-12} = Rd;
3334 let Inst{11-7} = imm{4-0}; // lsb
3335 let Inst{20-16} = imm{9-5}; // msb
3338 // A8.6.18 BFI - Bitfield insert (Encoding A1)
3339 def BFI:I<(outs GPRnopc:$Rd), (ins GPRnopc:$src, GPR:$Rn, bf_inv_mask_imm:$imm),
3340 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3341 "bfi", "\t$Rd, $Rn, $imm", "$src = $Rd",
3342 [(set GPRnopc:$Rd, (ARMbfi GPRnopc:$src, GPR:$Rn,
3343 bf_inv_mask_imm:$imm))]>,
3344 Requires<[IsARM, HasV6T2]> {
3348 let Inst{27-21} = 0b0111110;
3349 let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15
3350 let Inst{15-12} = Rd;
3351 let Inst{11-7} = imm{4-0}; // lsb
3352 let Inst{20-16} = imm{9-5}; // width
3356 def MVNr : AsI1<0b1111, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMVNr,
3357 "mvn", "\t$Rd, $Rm",
3358 [(set GPR:$Rd, (not GPR:$Rm))]>, UnaryDP {
3362 let Inst{19-16} = 0b0000;
3363 let Inst{11-4} = 0b00000000;
3364 let Inst{15-12} = Rd;
3367 def MVNsi : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_imm:$shift),
3368 DPSoRegImmFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3369 [(set GPR:$Rd, (not so_reg_imm:$shift))]>, UnaryDP {
3373 let Inst{19-16} = 0b0000;
3374 let Inst{15-12} = Rd;
3375 let Inst{11-5} = shift{11-5};
3377 let Inst{3-0} = shift{3-0};
3379 def MVNsr : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_reg:$shift),
3380 DPSoRegRegFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3381 [(set GPR:$Rd, (not so_reg_reg:$shift))]>, UnaryDP {
3385 let Inst{19-16} = 0b0000;
3386 let Inst{15-12} = Rd;
3387 let Inst{11-8} = shift{11-8};
3389 let Inst{6-5} = shift{6-5};
3391 let Inst{3-0} = shift{3-0};
3393 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3394 def MVNi : AsI1<0b1111, (outs GPR:$Rd), (ins so_imm:$imm), DPFrm,
3395 IIC_iMVNi, "mvn", "\t$Rd, $imm",
3396 [(set GPR:$Rd, so_imm_not:$imm)]>,UnaryDP {
3400 let Inst{19-16} = 0b0000;
3401 let Inst{15-12} = Rd;
3402 let Inst{11-0} = imm;
3405 def : ARMPat<(and GPR:$src, so_imm_not:$imm),
3406 (BICri GPR:$src, so_imm_not:$imm)>;
3408 //===----------------------------------------------------------------------===//
3409 // Multiply Instructions.
3411 class AsMul1I32<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3412 string opc, string asm, list<dag> pattern>
3413 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3417 let Inst{19-16} = Rd;
3418 let Inst{11-8} = Rm;
3421 class AsMul1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
3422 string opc, string asm, list<dag> pattern>
3423 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
3428 let Inst{19-16} = RdHi;
3429 let Inst{15-12} = RdLo;
3430 let Inst{11-8} = Rm;
3434 // FIXME: The v5 pseudos are only necessary for the additional Constraint
3435 // property. Remove them when it's possible to add those properties
3436 // on an individual MachineInstr, not just an instuction description.
3437 let isCommutable = 1 in {
3438 def MUL : AsMul1I32<0b0000000, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3439 IIC_iMUL32, "mul", "\t$Rd, $Rn, $Rm",
3440 [(set GPR:$Rd, (mul GPR:$Rn, GPR:$Rm))]>,
3441 Requires<[IsARM, HasV6]> {
3442 let Inst{15-12} = 0b0000;
3445 let Constraints = "@earlyclobber $Rd" in
3446 def MULv5: ARMPseudoExpand<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm,
3447 pred:$p, cc_out:$s),
3449 [(set GPR:$Rd, (mul GPR:$Rn, GPR:$Rm))],
3450 (MUL GPR:$Rd, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3451 Requires<[IsARM, NoV6]>;
3454 def MLA : AsMul1I32<0b0000001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3455 IIC_iMAC32, "mla", "\t$Rd, $Rn, $Rm, $Ra",
3456 [(set GPR:$Rd, (add (mul GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
3457 Requires<[IsARM, HasV6]> {
3459 let Inst{15-12} = Ra;
3462 let Constraints = "@earlyclobber $Rd" in
3463 def MLAv5: ARMPseudoExpand<(outs GPR:$Rd),
3464 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra, pred:$p, cc_out:$s),
3466 [(set GPR:$Rd, (add (mul GPR:$Rn, GPR:$Rm), GPR:$Ra))],
3467 (MLA GPR:$Rd, GPR:$Rn, GPR:$Rm, GPR:$Ra, pred:$p, cc_out:$s)>,
3468 Requires<[IsARM, NoV6]>;
3470 def MLS : AMul1I<0b0000011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3471 IIC_iMAC32, "mls", "\t$Rd, $Rn, $Rm, $Ra",
3472 [(set GPR:$Rd, (sub GPR:$Ra, (mul GPR:$Rn, GPR:$Rm)))]>,
3473 Requires<[IsARM, HasV6T2]> {
3478 let Inst{19-16} = Rd;
3479 let Inst{15-12} = Ra;
3480 let Inst{11-8} = Rm;
3484 // Extra precision multiplies with low / high results
3485 let neverHasSideEffects = 1 in {
3486 let isCommutable = 1 in {
3487 def SMULL : AsMul1I64<0b0000110, (outs GPR:$RdLo, GPR:$RdHi),
3488 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3489 "smull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3490 Requires<[IsARM, HasV6]>;
3492 def UMULL : AsMul1I64<0b0000100, (outs GPR:$RdLo, GPR:$RdHi),
3493 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
3494 "umull", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3495 Requires<[IsARM, HasV6]>;
3497 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
3498 def SMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3499 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3501 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3502 Requires<[IsARM, NoV6]>;
3504 def UMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3505 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3507 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3508 Requires<[IsARM, NoV6]>;
3512 // Multiply + accumulate
3513 def SMLAL : AsMul1I64<0b0000111, (outs GPR:$RdLo, GPR:$RdHi),
3514 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3515 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3516 Requires<[IsARM, HasV6]>;
3517 def UMLAL : AsMul1I64<0b0000101, (outs GPR:$RdLo, GPR:$RdHi),
3518 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3519 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3520 Requires<[IsARM, HasV6]>;
3522 def UMAAL : AMul1I <0b0000010, (outs GPR:$RdLo, GPR:$RdHi),
3523 (ins GPR:$Rn, GPR:$Rm), IIC_iMAC64,
3524 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3525 Requires<[IsARM, HasV6]> {
3530 let Inst{19-16} = RdHi;
3531 let Inst{15-12} = RdLo;
3532 let Inst{11-8} = Rm;
3536 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
3537 def SMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3538 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3540 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3541 Requires<[IsARM, NoV6]>;
3542 def UMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3543 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
3545 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
3546 Requires<[IsARM, NoV6]>;
3547 def UMAALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
3548 (ins GPR:$Rn, GPR:$Rm, pred:$p),
3550 (UMAAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p)>,
3551 Requires<[IsARM, NoV6]>;
3554 } // neverHasSideEffects
3556 // Most significant word multiply
3557 def SMMUL : AMul2I <0b0111010, 0b0001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3558 IIC_iMUL32, "smmul", "\t$Rd, $Rn, $Rm",
3559 [(set GPR:$Rd, (mulhs GPR:$Rn, GPR:$Rm))]>,
3560 Requires<[IsARM, HasV6]> {
3561 let Inst{15-12} = 0b1111;
3564 def SMMULR : AMul2I <0b0111010, 0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3565 IIC_iMUL32, "smmulr", "\t$Rd, $Rn, $Rm", []>,
3566 Requires<[IsARM, HasV6]> {
3567 let Inst{15-12} = 0b1111;
3570 def SMMLA : AMul2Ia <0b0111010, 0b0001, (outs GPR:$Rd),
3571 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3572 IIC_iMAC32, "smmla", "\t$Rd, $Rn, $Rm, $Ra",
3573 [(set GPR:$Rd, (add (mulhs GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
3574 Requires<[IsARM, HasV6]>;
3576 def SMMLAR : AMul2Ia <0b0111010, 0b0011, (outs GPR:$Rd),
3577 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3578 IIC_iMAC32, "smmlar", "\t$Rd, $Rn, $Rm, $Ra", []>,
3579 Requires<[IsARM, HasV6]>;
3581 def SMMLS : AMul2Ia <0b0111010, 0b1101, (outs GPR:$Rd),
3582 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3583 IIC_iMAC32, "smmls", "\t$Rd, $Rn, $Rm, $Ra",
3584 [(set GPR:$Rd, (sub GPR:$Ra, (mulhs GPR:$Rn, GPR:$Rm)))]>,
3585 Requires<[IsARM, HasV6]>;
3587 def SMMLSR : AMul2Ia <0b0111010, 0b1111, (outs GPR:$Rd),
3588 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3589 IIC_iMAC32, "smmlsr", "\t$Rd, $Rn, $Rm, $Ra", []>,
3590 Requires<[IsARM, HasV6]>;
3592 multiclass AI_smul<string opc, PatFrag opnode> {
3593 def BB : AMulxyI<0b0001011, 0b00, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3594 IIC_iMUL16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm",
3595 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3596 (sext_inreg GPR:$Rm, i16)))]>,
3597 Requires<[IsARM, HasV5TE]>;
3599 def BT : AMulxyI<0b0001011, 0b10, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3600 IIC_iMUL16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm",
3601 [(set GPR:$Rd, (opnode (sext_inreg GPR:$Rn, i16),
3602 (sra GPR:$Rm, (i32 16))))]>,
3603 Requires<[IsARM, HasV5TE]>;
3605 def TB : AMulxyI<0b0001011, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3606 IIC_iMUL16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm",
3607 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3608 (sext_inreg GPR:$Rm, i16)))]>,
3609 Requires<[IsARM, HasV5TE]>;
3611 def TT : AMulxyI<0b0001011, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3612 IIC_iMUL16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm",
3613 [(set GPR:$Rd, (opnode (sra GPR:$Rn, (i32 16)),
3614 (sra GPR:$Rm, (i32 16))))]>,
3615 Requires<[IsARM, HasV5TE]>;
3617 def WB : AMulxyI<0b0001001, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3618 IIC_iMUL16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm",
3619 [(set GPR:$Rd, (sra (opnode GPR:$Rn,
3620 (sext_inreg GPR:$Rm, i16)), (i32 16)))]>,
3621 Requires<[IsARM, HasV5TE]>;
3623 def WT : AMulxyI<0b0001001, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3624 IIC_iMUL16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm",
3625 [(set GPR:$Rd, (sra (opnode GPR:$Rn,
3626 (sra GPR:$Rm, (i32 16))), (i32 16)))]>,
3627 Requires<[IsARM, HasV5TE]>;
3631 multiclass AI_smla<string opc, PatFrag opnode> {
3632 let DecoderMethod = "DecodeSMLAInstruction" in {
3633 def BB : AMulxyIa<0b0001000, 0b00, (outs GPRnopc:$Rd),
3634 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3635 IIC_iMAC16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra",
3636 [(set GPRnopc:$Rd, (add GPR:$Ra,
3637 (opnode (sext_inreg GPRnopc:$Rn, i16),
3638 (sext_inreg GPRnopc:$Rm, i16))))]>,
3639 Requires<[IsARM, HasV5TE]>;
3641 def BT : AMulxyIa<0b0001000, 0b10, (outs GPRnopc:$Rd),
3642 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3643 IIC_iMAC16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra",
3645 (add GPR:$Ra, (opnode (sext_inreg GPRnopc:$Rn, i16),
3646 (sra GPRnopc:$Rm, (i32 16)))))]>,
3647 Requires<[IsARM, HasV5TE]>;
3649 def TB : AMulxyIa<0b0001000, 0b01, (outs GPRnopc:$Rd),
3650 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3651 IIC_iMAC16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra",
3653 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
3654 (sext_inreg GPRnopc:$Rm, i16))))]>,
3655 Requires<[IsARM, HasV5TE]>;
3657 def TT : AMulxyIa<0b0001000, 0b11, (outs GPRnopc:$Rd),
3658 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3659 IIC_iMAC16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra",
3661 (add GPR:$Ra, (opnode (sra GPRnopc:$Rn, (i32 16)),
3662 (sra GPRnopc:$Rm, (i32 16)))))]>,
3663 Requires<[IsARM, HasV5TE]>;
3665 def WB : AMulxyIa<0b0001001, 0b00, (outs GPRnopc:$Rd),
3666 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3667 IIC_iMAC16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra",
3669 (add GPR:$Ra, (sra (opnode GPRnopc:$Rn,
3670 (sext_inreg GPRnopc:$Rm, i16)), (i32 16))))]>,
3671 Requires<[IsARM, HasV5TE]>;
3673 def WT : AMulxyIa<0b0001001, 0b10, (outs GPRnopc:$Rd),
3674 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3675 IIC_iMAC16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra",
3677 (add GPR:$Ra, (sra (opnode GPRnopc:$Rn,
3678 (sra GPRnopc:$Rm, (i32 16))), (i32 16))))]>,
3679 Requires<[IsARM, HasV5TE]>;
3683 defm SMUL : AI_smul<"smul", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
3684 defm SMLA : AI_smla<"smla", BinOpFrag<(mul node:$LHS, node:$RHS)>>;
3686 // Halfword multiply accumulate long: SMLAL<x><y>.
3687 def SMLALBB : AMulxyI64<0b0001010, 0b00, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3688 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3689 IIC_iMAC64, "smlalbb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3690 Requires<[IsARM, HasV5TE]>;
3692 def SMLALBT : AMulxyI64<0b0001010, 0b10, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3693 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3694 IIC_iMAC64, "smlalbt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3695 Requires<[IsARM, HasV5TE]>;
3697 def SMLALTB : AMulxyI64<0b0001010, 0b01, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3698 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3699 IIC_iMAC64, "smlaltb", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3700 Requires<[IsARM, HasV5TE]>;
3702 def SMLALTT : AMulxyI64<0b0001010, 0b11, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3703 (ins GPRnopc:$Rn, GPRnopc:$Rm),
3704 IIC_iMAC64, "smlaltt", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
3705 Requires<[IsARM, HasV5TE]>;
3707 // Helper class for AI_smld.
3708 class AMulDualIbase<bit long, bit sub, bit swap, dag oops, dag iops,
3709 InstrItinClass itin, string opc, string asm>
3710 : AI<oops, iops, MulFrm, itin, opc, asm, []>, Requires<[IsARM, HasV6]> {
3713 let Inst{27-23} = 0b01110;
3714 let Inst{22} = long;
3715 let Inst{21-20} = 0b00;
3716 let Inst{11-8} = Rm;
3723 class AMulDualI<bit long, bit sub, bit swap, dag oops, dag iops,
3724 InstrItinClass itin, string opc, string asm>
3725 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
3727 let Inst{15-12} = 0b1111;
3728 let Inst{19-16} = Rd;
3730 class AMulDualIa<bit long, bit sub, bit swap, dag oops, dag iops,
3731 InstrItinClass itin, string opc, string asm>
3732 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
3735 let Inst{19-16} = Rd;
3736 let Inst{15-12} = Ra;
3738 class AMulDualI64<bit long, bit sub, bit swap, dag oops, dag iops,
3739 InstrItinClass itin, string opc, string asm>
3740 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
3743 let Inst{19-16} = RdHi;
3744 let Inst{15-12} = RdLo;
3747 multiclass AI_smld<bit sub, string opc> {
3749 def D : AMulDualIa<0, sub, 0, (outs GPRnopc:$Rd),
3750 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3751 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm, $Ra">;
3753 def DX: AMulDualIa<0, sub, 1, (outs GPRnopc:$Rd),
3754 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
3755 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm, $Ra">;
3757 def LD: AMulDualI64<1, sub, 0, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3758 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
3759 !strconcat(opc, "ld"), "\t$RdLo, $RdHi, $Rn, $Rm">;
3761 def LDX : AMulDualI64<1, sub, 1, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
3762 (ins GPRnopc:$Rn, GPRnopc:$Rm), NoItinerary,
3763 !strconcat(opc, "ldx"),"\t$RdLo, $RdHi, $Rn, $Rm">;
3767 defm SMLA : AI_smld<0, "smla">;
3768 defm SMLS : AI_smld<1, "smls">;
3770 multiclass AI_sdml<bit sub, string opc> {
3772 def D:AMulDualI<0, sub, 0, (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm),
3773 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm">;
3774 def DX:AMulDualI<0, sub, 1, (outs GPRnopc:$Rd),(ins GPRnopc:$Rn, GPRnopc:$Rm),
3775 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm">;
3778 defm SMUA : AI_sdml<0, "smua">;
3779 defm SMUS : AI_sdml<1, "smus">;
3781 //===----------------------------------------------------------------------===//
3782 // Misc. Arithmetic Instructions.
3785 def CLZ : AMiscA1I<0b000010110, 0b0001, (outs GPR:$Rd), (ins GPR:$Rm),
3786 IIC_iUNAr, "clz", "\t$Rd, $Rm",
3787 [(set GPR:$Rd, (ctlz GPR:$Rm))]>, Requires<[IsARM, HasV5T]>;
3789 def RBIT : AMiscA1I<0b01101111, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
3790 IIC_iUNAr, "rbit", "\t$Rd, $Rm",
3791 [(set GPR:$Rd, (ARMrbit GPR:$Rm))]>,
3792 Requires<[IsARM, HasV6T2]>;
3794 def REV : AMiscA1I<0b01101011, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
3795 IIC_iUNAr, "rev", "\t$Rd, $Rm",
3796 [(set GPR:$Rd, (bswap GPR:$Rm))]>, Requires<[IsARM, HasV6]>;
3798 let AddedComplexity = 5 in
3799 def REV16 : AMiscA1I<0b01101011, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
3800 IIC_iUNAr, "rev16", "\t$Rd, $Rm",
3801 [(set GPR:$Rd, (rotr (bswap GPR:$Rm), (i32 16)))]>,
3802 Requires<[IsARM, HasV6]>;
3804 let AddedComplexity = 5 in
3805 def REVSH : AMiscA1I<0b01101111, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
3806 IIC_iUNAr, "revsh", "\t$Rd, $Rm",
3807 [(set GPR:$Rd, (sra (bswap GPR:$Rm), (i32 16)))]>,
3808 Requires<[IsARM, HasV6]>;
3810 def : ARMV6Pat<(or (sra (shl GPR:$Rm, (i32 24)), (i32 16)),
3811 (and (srl GPR:$Rm, (i32 8)), 0xFF)),
3814 def PKHBT : APKHI<0b01101000, 0, (outs GPRnopc:$Rd),
3815 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_lsl_amt:$sh),
3816 IIC_iALUsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh",
3817 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF),
3818 (and (shl GPRnopc:$Rm, pkh_lsl_amt:$sh),
3820 Requires<[IsARM, HasV6]>;
3822 // Alternate cases for PKHBT where identities eliminate some nodes.
3823 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (and GPRnopc:$Rm, 0xFFFF0000)),
3824 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, 0)>;
3825 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (shl GPRnopc:$Rm, imm16_31:$sh)),
3826 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, imm16_31:$sh)>;
3828 // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
3829 // will match the pattern below.
3830 def PKHTB : APKHI<0b01101000, 1, (outs GPRnopc:$Rd),
3831 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_asr_amt:$sh),
3832 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh",
3833 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF0000),
3834 (and (sra GPRnopc:$Rm, pkh_asr_amt:$sh),
3836 Requires<[IsARM, HasV6]>;
3838 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
3839 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
3840 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
3841 (srl GPRnopc:$src2, imm16_31:$sh)),
3842 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16_31:$sh)>;
3843 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
3844 (and (srl GPRnopc:$src2, imm1_15:$sh), 0xFFFF)),
3845 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm1_15:$sh)>;
3847 //===----------------------------------------------------------------------===//
3848 // Comparison Instructions...
3851 defm CMP : AI1_cmp_irs<0b1010, "cmp",
3852 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
3853 BinOpFrag<(ARMcmp node:$LHS, node:$RHS)>>;
3855 // ARMcmpZ can re-use the above instruction definitions.
3856 def : ARMPat<(ARMcmpZ GPR:$src, so_imm:$imm),
3857 (CMPri GPR:$src, so_imm:$imm)>;
3858 def : ARMPat<(ARMcmpZ GPR:$src, GPR:$rhs),
3859 (CMPrr GPR:$src, GPR:$rhs)>;
3860 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_imm:$rhs),
3861 (CMPrsi GPR:$src, so_reg_imm:$rhs)>;
3862 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_reg:$rhs),
3863 (CMPrsr GPR:$src, so_reg_reg:$rhs)>;
3865 // FIXME: We have to be careful when using the CMN instruction and comparison
3866 // with 0. One would expect these two pieces of code should give identical
3882 // However, the CMN gives the *opposite* result when r1 is 0. This is because
3883 // the carry flag is set in the CMP case but not in the CMN case. In short, the
3884 // CMP instruction doesn't perform a truncate of the (logical) NOT of 0 plus the
3885 // value of r0 and the carry bit (because the "carry bit" parameter to
3886 // AddWithCarry is defined as 1 in this case, the carry flag will always be set
3887 // when r0 >= 0). The CMN instruction doesn't perform a NOT of 0 so there is
3888 // never a "carry" when this AddWithCarry is performed (because the "carry bit"
3889 // parameter to AddWithCarry is defined as 0).
3891 // When x is 0 and unsigned:
3895 // ~x + 1 = 0x1 0000 0000
3896 // (-x = 0) != (0x1 0000 0000 = ~x + 1)
3898 // Therefore, we should disable CMN when comparing against zero, until we can
3899 // limit when the CMN instruction is used (when we know that the RHS is not 0 or
3900 // when it's a comparison which doesn't look at the 'carry' flag).
3902 // (See the ARM docs for the "AddWithCarry" pseudo-code.)
3904 // This is related to <rdar://problem/7569620>.
3906 //defm CMN : AI1_cmp_irs<0b1011, "cmn",
3907 // BinOpFrag<(ARMcmp node:$LHS,(ineg node:$RHS))>>;
3909 // Note that TST/TEQ don't set all the same flags that CMP does!
3910 defm TST : AI1_cmp_irs<0b1000, "tst",
3911 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
3912 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>, 1>;
3913 defm TEQ : AI1_cmp_irs<0b1001, "teq",
3914 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
3915 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>, 1>;
3917 defm CMNz : AI1_cmp_irs<0b1011, "cmn",
3918 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr,
3919 BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>>;
3921 //def : ARMPat<(ARMcmp GPR:$src, so_imm_neg:$imm),
3922 // (CMNri GPR:$src, so_imm_neg:$imm)>;
3924 def : ARMPat<(ARMcmpZ GPR:$src, so_imm_neg:$imm),
3925 (CMNzri GPR:$src, so_imm_neg:$imm)>;
3927 // Pseudo i64 compares for some floating point compares.
3928 let usesCustomInserter = 1, isBranch = 1, isTerminator = 1,
3930 def BCCi64 : PseudoInst<(outs),
3931 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, brtarget:$dst),
3933 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, bb:$dst)]>;
3935 def BCCZi64 : PseudoInst<(outs),
3936 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, brtarget:$dst), IIC_Br,
3937 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, 0, 0, bb:$dst)]>;
3938 } // usesCustomInserter
3941 // Conditional moves
3942 // FIXME: should be able to write a pattern for ARMcmov, but can't use
3943 // a two-value operand where a dag node expects two operands. :(
3944 let neverHasSideEffects = 1 in {
3945 def MOVCCr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$false, GPR:$Rm, pred:$p),
3947 [/*(set GPR:$Rd, (ARMcmov GPR:$false, GPR:$Rm, imm:$cc, CCR:$ccr))*/]>,
3948 RegConstraint<"$false = $Rd">;
3949 def MOVCCsi : ARMPseudoInst<(outs GPR:$Rd),
3950 (ins GPR:$false, so_reg_imm:$shift, pred:$p),
3952 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_imm:$shift,
3953 imm:$cc, CCR:$ccr))*/]>,
3954 RegConstraint<"$false = $Rd">;
3955 def MOVCCsr : ARMPseudoInst<(outs GPR:$Rd),
3956 (ins GPR:$false, so_reg_reg:$shift, pred:$p),
3958 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_reg:$shift,
3959 imm:$cc, CCR:$ccr))*/]>,
3960 RegConstraint<"$false = $Rd">;
3963 let isMoveImm = 1 in
3964 def MOVCCi16 : ARMPseudoInst<(outs GPR:$Rd),
3965 (ins GPR:$false, imm0_65535_expr:$imm, pred:$p),
3968 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>;
3970 let isMoveImm = 1 in
3971 def MOVCCi : ARMPseudoInst<(outs GPR:$Rd),
3972 (ins GPR:$false, so_imm:$imm, pred:$p),
3974 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_imm:$imm, imm:$cc, CCR:$ccr))*/]>,
3975 RegConstraint<"$false = $Rd">;
3977 // Two instruction predicate mov immediate.
3978 let isMoveImm = 1 in
3979 def MOVCCi32imm : ARMPseudoInst<(outs GPR:$Rd),
3980 (ins GPR:$false, i32imm:$src, pred:$p),
3981 8, IIC_iCMOVix2, []>, RegConstraint<"$false = $Rd">;
3983 let isMoveImm = 1 in
3984 def MVNCCi : ARMPseudoInst<(outs GPR:$Rd),
3985 (ins GPR:$false, so_imm:$imm, pred:$p),
3987 [/*(set GPR:$Rd, (ARMcmov GPR:$false, so_imm_not:$imm, imm:$cc, CCR:$ccr))*/]>,
3988 RegConstraint<"$false = $Rd">;
3989 } // neverHasSideEffects
3991 //===----------------------------------------------------------------------===//
3992 // Atomic operations intrinsics
3995 def MemBarrierOptOperand : AsmOperandClass {
3996 let Name = "MemBarrierOpt";
3997 let ParserMethod = "parseMemBarrierOptOperand";
3999 def memb_opt : Operand<i32> {
4000 let PrintMethod = "printMemBOption";
4001 let ParserMatchClass = MemBarrierOptOperand;
4002 let DecoderMethod = "DecodeMemBarrierOption";
4005 // memory barriers protect the atomic sequences
4006 let hasSideEffects = 1 in {
4007 def DMB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4008 "dmb", "\t$opt", [(ARMMemBarrier (i32 imm:$opt))]>,
4009 Requires<[IsARM, HasDB]> {
4011 let Inst{31-4} = 0xf57ff05;
4012 let Inst{3-0} = opt;
4016 def DSB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4017 "dsb", "\t$opt", []>,
4018 Requires<[IsARM, HasDB]> {
4020 let Inst{31-4} = 0xf57ff04;
4021 let Inst{3-0} = opt;
4024 // ISB has only full system option
4025 def ISB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4026 "isb", "\t$opt", []>,
4027 Requires<[IsARM, HasDB]> {
4029 let Inst{31-4} = 0xf57ff06;
4030 let Inst{3-0} = opt;
4033 // Pseudo isntruction that combines movs + predicated rsbmi
4034 // to implement integer ABS
4035 let usesCustomInserter = 1, Defs = [CPSR] in {
4036 def ABS : ARMPseudoInst<
4037 (outs GPR:$dst), (ins GPR:$src),
4038 8, NoItinerary, []>;
4041 let usesCustomInserter = 1 in {
4042 let Defs = [CPSR] in {
4043 def ATOMIC_LOAD_ADD_I8 : PseudoInst<
4044 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4045 [(set GPR:$dst, (atomic_load_add_8 GPR:$ptr, GPR:$incr))]>;
4046 def ATOMIC_LOAD_SUB_I8 : PseudoInst<
4047 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4048 [(set GPR:$dst, (atomic_load_sub_8 GPR:$ptr, GPR:$incr))]>;
4049 def ATOMIC_LOAD_AND_I8 : PseudoInst<
4050 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4051 [(set GPR:$dst, (atomic_load_and_8 GPR:$ptr, GPR:$incr))]>;
4052 def ATOMIC_LOAD_OR_I8 : PseudoInst<
4053 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4054 [(set GPR:$dst, (atomic_load_or_8 GPR:$ptr, GPR:$incr))]>;
4055 def ATOMIC_LOAD_XOR_I8 : PseudoInst<
4056 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4057 [(set GPR:$dst, (atomic_load_xor_8 GPR:$ptr, GPR:$incr))]>;
4058 def ATOMIC_LOAD_NAND_I8 : PseudoInst<
4059 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4060 [(set GPR:$dst, (atomic_load_nand_8 GPR:$ptr, GPR:$incr))]>;
4061 def ATOMIC_LOAD_MIN_I8 : PseudoInst<
4062 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4063 [(set GPR:$dst, (atomic_load_min_8 GPR:$ptr, GPR:$val))]>;
4064 def ATOMIC_LOAD_MAX_I8 : PseudoInst<
4065 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4066 [(set GPR:$dst, (atomic_load_max_8 GPR:$ptr, GPR:$val))]>;
4067 def ATOMIC_LOAD_UMIN_I8 : PseudoInst<
4068 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4069 [(set GPR:$dst, (atomic_load_min_8 GPR:$ptr, GPR:$val))]>;
4070 def ATOMIC_LOAD_UMAX_I8 : PseudoInst<
4071 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4072 [(set GPR:$dst, (atomic_load_max_8 GPR:$ptr, GPR:$val))]>;
4073 def ATOMIC_LOAD_ADD_I16 : PseudoInst<
4074 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4075 [(set GPR:$dst, (atomic_load_add_16 GPR:$ptr, GPR:$incr))]>;
4076 def ATOMIC_LOAD_SUB_I16 : PseudoInst<
4077 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4078 [(set GPR:$dst, (atomic_load_sub_16 GPR:$ptr, GPR:$incr))]>;
4079 def ATOMIC_LOAD_AND_I16 : PseudoInst<
4080 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4081 [(set GPR:$dst, (atomic_load_and_16 GPR:$ptr, GPR:$incr))]>;
4082 def ATOMIC_LOAD_OR_I16 : PseudoInst<
4083 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4084 [(set GPR:$dst, (atomic_load_or_16 GPR:$ptr, GPR:$incr))]>;
4085 def ATOMIC_LOAD_XOR_I16 : PseudoInst<
4086 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4087 [(set GPR:$dst, (atomic_load_xor_16 GPR:$ptr, GPR:$incr))]>;
4088 def ATOMIC_LOAD_NAND_I16 : PseudoInst<
4089 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4090 [(set GPR:$dst, (atomic_load_nand_16 GPR:$ptr, GPR:$incr))]>;
4091 def ATOMIC_LOAD_MIN_I16 : PseudoInst<
4092 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4093 [(set GPR:$dst, (atomic_load_min_16 GPR:$ptr, GPR:$val))]>;
4094 def ATOMIC_LOAD_MAX_I16 : PseudoInst<
4095 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4096 [(set GPR:$dst, (atomic_load_max_16 GPR:$ptr, GPR:$val))]>;
4097 def ATOMIC_LOAD_UMIN_I16 : PseudoInst<
4098 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4099 [(set GPR:$dst, (atomic_load_min_16 GPR:$ptr, GPR:$val))]>;
4100 def ATOMIC_LOAD_UMAX_I16 : PseudoInst<
4101 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4102 [(set GPR:$dst, (atomic_load_max_16 GPR:$ptr, GPR:$val))]>;
4103 def ATOMIC_LOAD_ADD_I32 : PseudoInst<
4104 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4105 [(set GPR:$dst, (atomic_load_add_32 GPR:$ptr, GPR:$incr))]>;
4106 def ATOMIC_LOAD_SUB_I32 : PseudoInst<
4107 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4108 [(set GPR:$dst, (atomic_load_sub_32 GPR:$ptr, GPR:$incr))]>;
4109 def ATOMIC_LOAD_AND_I32 : PseudoInst<
4110 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4111 [(set GPR:$dst, (atomic_load_and_32 GPR:$ptr, GPR:$incr))]>;
4112 def ATOMIC_LOAD_OR_I32 : PseudoInst<
4113 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4114 [(set GPR:$dst, (atomic_load_or_32 GPR:$ptr, GPR:$incr))]>;
4115 def ATOMIC_LOAD_XOR_I32 : PseudoInst<
4116 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4117 [(set GPR:$dst, (atomic_load_xor_32 GPR:$ptr, GPR:$incr))]>;
4118 def ATOMIC_LOAD_NAND_I32 : PseudoInst<
4119 (outs GPR:$dst), (ins GPR:$ptr, GPR:$incr), NoItinerary,
4120 [(set GPR:$dst, (atomic_load_nand_32 GPR:$ptr, GPR:$incr))]>;
4121 def ATOMIC_LOAD_MIN_I32 : PseudoInst<
4122 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4123 [(set GPR:$dst, (atomic_load_min_32 GPR:$ptr, GPR:$val))]>;
4124 def ATOMIC_LOAD_MAX_I32 : PseudoInst<
4125 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4126 [(set GPR:$dst, (atomic_load_max_32 GPR:$ptr, GPR:$val))]>;
4127 def ATOMIC_LOAD_UMIN_I32 : PseudoInst<
4128 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4129 [(set GPR:$dst, (atomic_load_min_32 GPR:$ptr, GPR:$val))]>;
4130 def ATOMIC_LOAD_UMAX_I32 : PseudoInst<
4131 (outs GPR:$dst), (ins GPR:$ptr, GPR:$val), NoItinerary,
4132 [(set GPR:$dst, (atomic_load_max_32 GPR:$ptr, GPR:$val))]>;
4134 def ATOMIC_SWAP_I8 : PseudoInst<
4135 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
4136 [(set GPR:$dst, (atomic_swap_8 GPR:$ptr, GPR:$new))]>;
4137 def ATOMIC_SWAP_I16 : PseudoInst<
4138 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
4139 [(set GPR:$dst, (atomic_swap_16 GPR:$ptr, GPR:$new))]>;
4140 def ATOMIC_SWAP_I32 : PseudoInst<
4141 (outs GPR:$dst), (ins GPR:$ptr, GPR:$new), NoItinerary,
4142 [(set GPR:$dst, (atomic_swap_32 GPR:$ptr, GPR:$new))]>;
4144 def ATOMIC_CMP_SWAP_I8 : PseudoInst<
4145 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
4146 [(set GPR:$dst, (atomic_cmp_swap_8 GPR:$ptr, GPR:$old, GPR:$new))]>;
4147 def ATOMIC_CMP_SWAP_I16 : PseudoInst<
4148 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
4149 [(set GPR:$dst, (atomic_cmp_swap_16 GPR:$ptr, GPR:$old, GPR:$new))]>;
4150 def ATOMIC_CMP_SWAP_I32 : PseudoInst<
4151 (outs GPR:$dst), (ins GPR:$ptr, GPR:$old, GPR:$new), NoItinerary,
4152 [(set GPR:$dst, (atomic_cmp_swap_32 GPR:$ptr, GPR:$old, GPR:$new))]>;
4156 let mayLoad = 1 in {
4157 def LDREXB : AIldrex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4159 "ldrexb", "\t$Rt, $addr", []>;
4160 def LDREXH : AIldrex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4161 NoItinerary, "ldrexh", "\t$Rt, $addr", []>;
4162 def LDREX : AIldrex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4163 NoItinerary, "ldrex", "\t$Rt, $addr", []>;
4164 let hasExtraDefRegAllocReq = 1 in
4165 def LDREXD: AIldrex<0b01, (outs GPR:$Rt, GPR:$Rt2),(ins addr_offset_none:$addr),
4166 NoItinerary, "ldrexd", "\t$Rt, $Rt2, $addr", []> {
4167 let DecoderMethod = "DecodeDoubleRegLoad";
4171 let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
4172 def STREXB: AIstrex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4173 NoItinerary, "strexb", "\t$Rd, $Rt, $addr", []>;
4174 def STREXH: AIstrex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4175 NoItinerary, "strexh", "\t$Rd, $Rt, $addr", []>;
4176 def STREX : AIstrex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4177 NoItinerary, "strex", "\t$Rd, $Rt, $addr", []>;
4180 let hasExtraSrcRegAllocReq = 1, Constraints = "@earlyclobber $Rd" in
4181 def STREXD : AIstrex<0b01, (outs GPR:$Rd),
4182 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr),
4183 NoItinerary, "strexd", "\t$Rd, $Rt, $Rt2, $addr", []> {
4184 let DecoderMethod = "DecodeDoubleRegStore";
4187 def CLREX : AXI<(outs), (ins), MiscFrm, NoItinerary, "clrex", []>,
4188 Requires<[IsARM, HasV7]> {
4189 let Inst{31-0} = 0b11110101011111111111000000011111;
4192 // SWP/SWPB are deprecated in V6/V7.
4193 let mayLoad = 1, mayStore = 1 in {
4194 def SWP : AIswp<0, (outs GPR:$Rt), (ins GPR:$Rt2, addr_offset_none:$addr),
4196 def SWPB: AIswp<1, (outs GPR:$Rt), (ins GPR:$Rt2, addr_offset_none:$addr),
4200 //===----------------------------------------------------------------------===//
4201 // Coprocessor Instructions.
4204 def CDP : ABI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4205 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4206 NoItinerary, "cdp", "\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4207 [(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4208 imm:$CRm, imm:$opc2)]> {
4216 let Inst{3-0} = CRm;
4218 let Inst{7-5} = opc2;
4219 let Inst{11-8} = cop;
4220 let Inst{15-12} = CRd;
4221 let Inst{19-16} = CRn;
4222 let Inst{23-20} = opc1;
4225 def CDP2 : ABXI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4226 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
4227 NoItinerary, "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
4228 [(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
4229 imm:$CRm, imm:$opc2)]> {
4230 let Inst{31-28} = 0b1111;
4238 let Inst{3-0} = CRm;
4240 let Inst{7-5} = opc2;
4241 let Inst{11-8} = cop;
4242 let Inst{15-12} = CRd;
4243 let Inst{19-16} = CRn;
4244 let Inst{23-20} = opc1;
4247 class ACI<dag oops, dag iops, string opc, string asm,
4248 IndexMode im = IndexModeNone>
4249 : InoP<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
4251 let Inst{27-25} = 0b110;
4254 multiclass LdStCop<bits<4> op31_28, bit load, dag ops, string opc, string cond>{
4255 def _OFFSET : ACI<(outs),
4256 !con((ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr), ops),
4257 !strconcat(opc, cond), "\t$cop, $CRd, $addr"> {
4258 let Inst{31-28} = op31_28;
4259 let Inst{24} = 1; // P = 1
4260 let Inst{21} = 0; // W = 0
4261 let Inst{22} = 0; // D = 0
4262 let Inst{20} = load;
4263 let DecoderMethod = "DecodeCopMemInstruction";
4266 def _PRE : ACI<(outs),
4267 !con((ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr), ops),
4268 !strconcat(opc, cond), "\t$cop, $CRd, $addr!", IndexModePre> {
4269 let Inst{31-28} = op31_28;
4270 let Inst{24} = 1; // P = 1
4271 let Inst{21} = 1; // W = 1
4272 let Inst{22} = 0; // D = 0
4273 let Inst{20} = load;
4274 let DecoderMethod = "DecodeCopMemInstruction";
4277 def _POST : ACI<(outs),
4278 !con((ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4279 postidx_imm8s4:$offset), ops),
4280 !strconcat(opc, cond), "\t$cop, $CRd, $addr, $offset",
4282 let Inst{31-28} = op31_28;
4283 let Inst{24} = 0; // P = 0
4284 let Inst{21} = 1; // W = 1
4285 let Inst{22} = 0; // D = 0
4286 let Inst{20} = load;
4287 let DecoderMethod = "DecodeCopMemInstruction";
4290 def _OPTION : ACI<(outs),
4291 !con((ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$base,
4292 nohash_imm:$option),
4294 !strconcat(opc, cond), "\t$cop, $CRd, $base, \\{$option\\}"> {
4295 let Inst{31-28} = op31_28;
4296 let Inst{24} = 0; // P = 0
4297 let Inst{23} = 1; // U = 1
4298 let Inst{21} = 0; // W = 0
4299 let Inst{22} = 0; // D = 0
4300 let Inst{20} = load;
4301 let DecoderMethod = "DecodeCopMemInstruction";
4304 def L_OFFSET : ACI<(outs),
4305 !con((ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr), ops),
4306 !strconcat(!strconcat(opc, "l"), cond), "\t$cop, $CRd, $addr"> {
4307 let Inst{31-28} = op31_28;
4308 let Inst{24} = 1; // P = 1
4309 let Inst{21} = 0; // W = 0
4310 let Inst{22} = 1; // D = 1
4311 let Inst{20} = load;
4312 let DecoderMethod = "DecodeCopMemInstruction";
4315 def L_PRE : ACI<(outs),
4316 !con((ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr), ops),
4317 !strconcat(!strconcat(opc, "l"), cond), "\t$cop, $CRd, $addr!",
4319 let Inst{31-28} = op31_28;
4320 let Inst{24} = 1; // P = 1
4321 let Inst{21} = 1; // W = 1
4322 let Inst{22} = 1; // D = 1
4323 let Inst{20} = load;
4324 let DecoderMethod = "DecodeCopMemInstruction";
4327 def L_POST : ACI<(outs),
4328 !con((ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
4329 postidx_imm8s4:$offset), ops),
4330 !strconcat(!strconcat(opc, "l"), cond), "\t$cop, $CRd, $addr, $offset",
4332 let Inst{31-28} = op31_28;
4333 let Inst{24} = 0; // P = 0
4334 let Inst{21} = 1; // W = 1
4335 let Inst{22} = 1; // D = 1
4336 let Inst{20} = load;
4337 let DecoderMethod = "DecodeCopMemInstruction";
4340 def L_OPTION : ACI<(outs),
4341 !con((ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$base,
4342 nohash_imm:$option),
4344 !strconcat(!strconcat(opc, "l"), cond),
4345 "\t$cop, $CRd, $base, \\{$option\\}"> {
4346 let Inst{31-28} = op31_28;
4347 let Inst{24} = 0; // P = 0
4348 let Inst{23} = 1; // U = 1
4349 let Inst{21} = 0; // W = 0
4350 let Inst{22} = 1; // D = 1
4351 let Inst{20} = load;
4352 let DecoderMethod = "DecodeCopMemInstruction";
4356 defm LDC : LdStCop<{?,?,?,?}, 1, (ins pred:$p), "ldc", "${p}">;
4357 defm LDC2 : LdStCop<0b1111, 1, (ins), "ldc2", "">;
4358 defm STC : LdStCop<{?,?,?,?}, 0, (ins pred:$p), "stc", "${p}">;
4359 defm STC2 : LdStCop<0b1111, 0, (ins), "stc2", "">;
4361 //===----------------------------------------------------------------------===//
4362 // Move between coprocessor and ARM core register.
4365 class MovRCopro<string opc, bit direction, dag oops, dag iops,
4367 : ABI<0b1110, oops, iops, NoItinerary, opc,
4368 "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2", pattern> {
4369 let Inst{20} = direction;
4379 let Inst{15-12} = Rt;
4380 let Inst{11-8} = cop;
4381 let Inst{23-21} = opc1;
4382 let Inst{7-5} = opc2;
4383 let Inst{3-0} = CRm;
4384 let Inst{19-16} = CRn;
4387 def MCR : MovRCopro<"mcr", 0 /* from ARM core register to coprocessor */,
4389 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4390 c_imm:$CRm, imm0_7:$opc2),
4391 [(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
4392 imm:$CRm, imm:$opc2)]>;
4393 def MRC : MovRCopro<"mrc", 1 /* from coprocessor to ARM core register */,
4395 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
4398 def : ARMPat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
4399 (MRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
4401 class MovRCopro2<string opc, bit direction, dag oops, dag iops,
4403 : ABXI<0b1110, oops, iops, NoItinerary,
4404 !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), pattern> {
4405 let Inst{31-28} = 0b1111;
4406 let Inst{20} = direction;
4416 let Inst{15-12} = Rt;
4417 let Inst{11-8} = cop;
4418 let Inst{23-21} = opc1;
4419 let Inst{7-5} = opc2;
4420 let Inst{3-0} = CRm;
4421 let Inst{19-16} = CRn;
4424 def MCR2 : MovRCopro2<"mcr2", 0 /* from ARM core register to coprocessor */,
4426 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
4427 c_imm:$CRm, imm0_7:$opc2),
4428 [(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
4429 imm:$CRm, imm:$opc2)]>;
4430 def MRC2 : MovRCopro2<"mrc2", 1 /* from coprocessor to ARM core register */,
4432 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
4435 def : ARMV5TPat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn,
4436 imm:$CRm, imm:$opc2),
4437 (MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
4439 class MovRRCopro<string opc, bit direction, list<dag> pattern = []>
4440 : ABI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4441 GPR:$Rt, GPR:$Rt2, c_imm:$CRm),
4442 NoItinerary, opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm", pattern> {
4443 let Inst{23-21} = 0b010;
4444 let Inst{20} = direction;
4452 let Inst{15-12} = Rt;
4453 let Inst{19-16} = Rt2;
4454 let Inst{11-8} = cop;
4455 let Inst{7-4} = opc1;
4456 let Inst{3-0} = CRm;
4459 def MCRR : MovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */,
4460 [(int_arm_mcrr imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2,
4462 def MRRC : MovRRCopro<"mrrc", 1 /* from coprocessor to ARM core register */>;
4464 class MovRRCopro2<string opc, bit direction, list<dag> pattern = []>
4465 : ABXI<0b1100, (outs), (ins p_imm:$cop, imm0_15:$opc1,
4466 GPR:$Rt, GPR:$Rt2, c_imm:$CRm), NoItinerary,
4467 !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern> {
4468 let Inst{31-28} = 0b1111;
4469 let Inst{23-21} = 0b010;
4470 let Inst{20} = direction;
4478 let Inst{15-12} = Rt;
4479 let Inst{19-16} = Rt2;
4480 let Inst{11-8} = cop;
4481 let Inst{7-4} = opc1;
4482 let Inst{3-0} = CRm;
4485 def MCRR2 : MovRRCopro2<"mcrr2", 0 /* from ARM core register to coprocessor */,
4486 [(int_arm_mcrr2 imm:$cop, imm:$opc1, GPR:$Rt, GPR:$Rt2,
4488 def MRRC2 : MovRRCopro2<"mrrc2", 1 /* from coprocessor to ARM core register */>;
4490 //===----------------------------------------------------------------------===//
4491 // Move between special register and ARM core register
4494 // Move to ARM core register from Special Register
4495 def MRS : ABI<0b0001, (outs GPR:$Rd), (ins), NoItinerary,
4496 "mrs", "\t$Rd, apsr", []> {
4498 let Inst{23-16} = 0b00001111;
4499 let Inst{15-12} = Rd;
4500 let Inst{7-4} = 0b0000;
4503 def : InstAlias<"mrs${p} $Rd, cpsr", (MRS GPR:$Rd, pred:$p)>, Requires<[IsARM]>;
4505 def MRSsys : ABI<0b0001, (outs GPR:$Rd), (ins), NoItinerary,
4506 "mrs", "\t$Rd, spsr", []> {
4508 let Inst{23-16} = 0b01001111;
4509 let Inst{15-12} = Rd;
4510 let Inst{7-4} = 0b0000;
4513 // Move from ARM core register to Special Register
4515 // No need to have both system and application versions, the encodings are the
4516 // same and the assembly parser has no way to distinguish between them. The mask
4517 // operand contains the special register (R Bit) in bit 4 and bits 3-0 contains
4518 // the mask with the fields to be accessed in the special register.
4519 def MSR : ABI<0b0001, (outs), (ins msr_mask:$mask, GPR:$Rn), NoItinerary,
4520 "msr", "\t$mask, $Rn", []> {
4525 let Inst{22} = mask{4}; // R bit
4526 let Inst{21-20} = 0b10;
4527 let Inst{19-16} = mask{3-0};
4528 let Inst{15-12} = 0b1111;
4529 let Inst{11-4} = 0b00000000;
4533 def MSRi : ABI<0b0011, (outs), (ins msr_mask:$mask, so_imm:$a), NoItinerary,
4534 "msr", "\t$mask, $a", []> {
4539 let Inst{22} = mask{4}; // R bit
4540 let Inst{21-20} = 0b10;
4541 let Inst{19-16} = mask{3-0};
4542 let Inst{15-12} = 0b1111;
4546 //===----------------------------------------------------------------------===//
4550 // __aeabi_read_tp preserves the registers r1-r3.
4551 // This is a pseudo inst so that we can get the encoding right,
4552 // complete with fixup for the aeabi_read_tp function.
4554 Defs = [R0, R12, LR, CPSR], Uses = [SP] in {
4555 def TPsoft : PseudoInst<(outs), (ins), IIC_Br,
4556 [(set R0, ARMthread_pointer)]>;
4559 //===----------------------------------------------------------------------===//
4560 // SJLJ Exception handling intrinsics
4561 // eh_sjlj_setjmp() is an instruction sequence to store the return
4562 // address and save #0 in R0 for the non-longjmp case.
4563 // Since by its nature we may be coming from some other function to get
4564 // here, and we're using the stack frame for the containing function to
4565 // save/restore registers, we can't keep anything live in regs across
4566 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
4567 // when we get here from a longjmp(). We force everything out of registers
4568 // except for our own input by listing the relevant registers in Defs. By
4569 // doing so, we also cause the prologue/epilogue code to actively preserve
4570 // all of the callee-saved resgisters, which is exactly what we want.
4571 // A constant value is passed in $val, and we use the location as a scratch.
4573 // These are pseudo-instructions and are lowered to individual MC-insts, so
4574 // no encoding information is necessary.
4576 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
4577 QQQQ0, QQQQ1, QQQQ2, QQQQ3 ], hasSideEffects = 1, isBarrier = 1 in {
4578 def Int_eh_sjlj_setjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
4580 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
4581 Requires<[IsARM, HasVFP2]>;
4585 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
4586 hasSideEffects = 1, isBarrier = 1 in {
4587 def Int_eh_sjlj_setjmp_nofp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
4589 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
4590 Requires<[IsARM, NoVFP]>;
4593 // FIXME: Non-Darwin version(s)
4594 let isBarrier = 1, hasSideEffects = 1, isTerminator = 1,
4595 Defs = [ R7, LR, SP ] in {
4596 def Int_eh_sjlj_longjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$scratch),
4598 [(ARMeh_sjlj_longjmp GPR:$src, GPR:$scratch)]>,
4599 Requires<[IsARM, IsDarwin]>;
4602 // eh.sjlj.dispatchsetup pseudo-instruction.
4603 // This pseudo is used for ARM, Thumb1 and Thumb2. Any differences are
4604 // handled when the pseudo is expanded (which happens before any passes
4605 // that need the instruction size).
4606 let isBarrier = 1, hasSideEffects = 1 in
4607 def Int_eh_sjlj_dispatchsetup :
4608 PseudoInst<(outs), (ins GPR:$src), NoItinerary,
4609 [(ARMeh_sjlj_dispatchsetup GPR:$src)]>,
4610 Requires<[IsDarwin]>;
4612 //===----------------------------------------------------------------------===//
4613 // Non-Instruction Patterns
4616 // ARMv4 indirect branch using (MOVr PC, dst)
4617 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in
4618 def MOVPCRX : ARMPseudoExpand<(outs), (ins GPR:$dst),
4619 4, IIC_Br, [(brind GPR:$dst)],
4620 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>,
4621 Requires<[IsARM, NoV4T]>;
4623 // Large immediate handling.
4625 // 32-bit immediate using two piece so_imms or movw + movt.
4626 // This is a single pseudo instruction, the benefit is that it can be remat'd
4627 // as a single unit instead of having to handle reg inputs.
4628 // FIXME: Remove this when we can do generalized remat.
4629 let isReMaterializable = 1, isMoveImm = 1 in
4630 def MOVi32imm : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
4631 [(set GPR:$dst, (arm_i32imm:$src))]>,
4634 // Pseudo instruction that combines movw + movt + add pc (if PIC).
4635 // It also makes it possible to rematerialize the instructions.
4636 // FIXME: Remove this when we can do generalized remat and when machine licm
4637 // can properly the instructions.
4638 let isReMaterializable = 1 in {
4639 def MOV_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
4641 [(set GPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>,
4642 Requires<[IsARM, UseMovt]>;
4644 def MOV_ga_dyn : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
4646 [(set GPR:$dst, (ARMWrapperDYN tglobaladdr:$addr))]>,
4647 Requires<[IsARM, UseMovt]>;
4649 let AddedComplexity = 10 in
4650 def MOV_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
4652 [(set GPR:$dst, (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
4653 Requires<[IsARM, UseMovt]>;
4654 } // isReMaterializable
4656 // ConstantPool, GlobalAddress, and JumpTable
4657 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (LEApcrel tglobaladdr :$dst)>,
4658 Requires<[IsARM, DontUseMovt]>;
4659 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
4660 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
4661 Requires<[IsARM, UseMovt]>;
4662 def : ARMPat<(ARMWrapperJT tjumptable:$dst, imm:$id),
4663 (LEApcrelJT tjumptable:$dst, imm:$id)>;
4665 // TODO: add,sub,and, 3-instr forms?
4668 def : ARMPat<(ARMtcret tcGPR:$dst),
4669 (TCRETURNri tcGPR:$dst)>, Requires<[IsDarwin]>;
4671 def : ARMPat<(ARMtcret (i32 tglobaladdr:$dst)),
4672 (TCRETURNdi texternalsym:$dst)>, Requires<[IsDarwin]>;
4674 def : ARMPat<(ARMtcret (i32 texternalsym:$dst)),
4675 (TCRETURNdi texternalsym:$dst)>, Requires<[IsDarwin]>;
4677 def : ARMPat<(ARMtcret tcGPR:$dst),
4678 (TCRETURNriND tcGPR:$dst)>, Requires<[IsNotDarwin]>;
4680 def : ARMPat<(ARMtcret (i32 tglobaladdr:$dst)),
4681 (TCRETURNdiND texternalsym:$dst)>, Requires<[IsNotDarwin]>;
4683 def : ARMPat<(ARMtcret (i32 texternalsym:$dst)),
4684 (TCRETURNdiND texternalsym:$dst)>, Requires<[IsNotDarwin]>;
4687 def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>,
4688 Requires<[IsARM, IsNotDarwin]>;
4689 def : ARMPat<(ARMcall texternalsym:$func), (BLr9 texternalsym:$func)>,
4690 Requires<[IsARM, IsDarwin]>;
4692 // zextload i1 -> zextload i8
4693 def : ARMPat<(zextloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
4694 def : ARMPat<(zextloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
4696 // extload -> zextload
4697 def : ARMPat<(extloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
4698 def : ARMPat<(extloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
4699 def : ARMPat<(extloadi8 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
4700 def : ARMPat<(extloadi8 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
4702 def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
4704 def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
4705 def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
4708 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4709 (sra (shl GPR:$b, (i32 16)), (i32 16))),
4710 (SMULBB GPR:$a, GPR:$b)>;
4711 def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
4712 (SMULBB GPR:$a, GPR:$b)>;
4713 def : ARMV5TEPat<(mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4714 (sra GPR:$b, (i32 16))),
4715 (SMULBT GPR:$a, GPR:$b)>;
4716 def : ARMV5TEPat<(mul sext_16_node:$a, (sra GPR:$b, (i32 16))),
4717 (SMULBT GPR:$a, GPR:$b)>;
4718 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)),
4719 (sra (shl GPR:$b, (i32 16)), (i32 16))),
4720 (SMULTB GPR:$a, GPR:$b)>;
4721 def : ARMV5TEPat<(mul (sra GPR:$a, (i32 16)), sext_16_node:$b),
4722 (SMULTB GPR:$a, GPR:$b)>;
4723 def : ARMV5TEPat<(sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
4725 (SMULWB GPR:$a, GPR:$b)>;
4726 def : ARMV5TEPat<(sra (mul GPR:$a, sext_16_node:$b), (i32 16)),
4727 (SMULWB GPR:$a, GPR:$b)>;
4729 def : ARMV5TEPat<(add GPR:$acc,
4730 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4731 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
4732 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
4733 def : ARMV5TEPat<(add GPR:$acc,
4734 (mul sext_16_node:$a, sext_16_node:$b)),
4735 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
4736 def : ARMV5TEPat<(add GPR:$acc,
4737 (mul (sra (shl GPR:$a, (i32 16)), (i32 16)),
4738 (sra GPR:$b, (i32 16)))),
4739 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
4740 def : ARMV5TEPat<(add GPR:$acc,
4741 (mul sext_16_node:$a, (sra GPR:$b, (i32 16)))),
4742 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
4743 def : ARMV5TEPat<(add GPR:$acc,
4744 (mul (sra GPR:$a, (i32 16)),
4745 (sra (shl GPR:$b, (i32 16)), (i32 16)))),
4746 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
4747 def : ARMV5TEPat<(add GPR:$acc,
4748 (mul (sra GPR:$a, (i32 16)), sext_16_node:$b)),
4749 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
4750 def : ARMV5TEPat<(add GPR:$acc,
4751 (sra (mul GPR:$a, (sra (shl GPR:$b, (i32 16)), (i32 16))),
4753 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
4754 def : ARMV5TEPat<(add GPR:$acc,
4755 (sra (mul GPR:$a, sext_16_node:$b), (i32 16))),
4756 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
4759 // Pre-v7 uses MCR for synchronization barriers.
4760 def : ARMPat<(ARMMemBarrierMCR GPR:$zero), (MCR 15, 0, GPR:$zero, 7, 10, 5)>,
4761 Requires<[IsARM, HasV6]>;
4763 // SXT/UXT with no rotate
4764 let AddedComplexity = 16 in {
4765 def : ARMV6Pat<(and GPR:$Src, 0x000000FF), (UXTB GPR:$Src, 0)>;
4766 def : ARMV6Pat<(and GPR:$Src, 0x0000FFFF), (UXTH GPR:$Src, 0)>;
4767 def : ARMV6Pat<(and GPR:$Src, 0x00FF00FF), (UXTB16 GPR:$Src, 0)>;
4768 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0x00FF)),
4769 (UXTAB GPR:$Rn, GPR:$Rm, 0)>;
4770 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0xFFFF)),
4771 (UXTAH GPR:$Rn, GPR:$Rm, 0)>;
4774 def : ARMV6Pat<(sext_inreg GPR:$Src, i8), (SXTB GPR:$Src, 0)>;
4775 def : ARMV6Pat<(sext_inreg GPR:$Src, i16), (SXTH GPR:$Src, 0)>;
4777 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i8)),
4778 (SXTAB GPR:$Rn, GPRnopc:$Rm, 0)>;
4779 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i16)),
4780 (SXTAH GPR:$Rn, GPRnopc:$Rm, 0)>;
4782 // Atomic load/store patterns
4783 def : ARMPat<(atomic_load_8 ldst_so_reg:$src),
4784 (LDRBrs ldst_so_reg:$src)>;
4785 def : ARMPat<(atomic_load_8 addrmode_imm12:$src),
4786 (LDRBi12 addrmode_imm12:$src)>;
4787 def : ARMPat<(atomic_load_16 addrmode3:$src),
4788 (LDRH addrmode3:$src)>;
4789 def : ARMPat<(atomic_load_32 ldst_so_reg:$src),
4790 (LDRrs ldst_so_reg:$src)>;
4791 def : ARMPat<(atomic_load_32 addrmode_imm12:$src),
4792 (LDRi12 addrmode_imm12:$src)>;
4793 def : ARMPat<(atomic_store_8 ldst_so_reg:$ptr, GPR:$val),
4794 (STRBrs GPR:$val, ldst_so_reg:$ptr)>;
4795 def : ARMPat<(atomic_store_8 addrmode_imm12:$ptr, GPR:$val),
4796 (STRBi12 GPR:$val, addrmode_imm12:$ptr)>;
4797 def : ARMPat<(atomic_store_16 addrmode3:$ptr, GPR:$val),
4798 (STRH GPR:$val, addrmode3:$ptr)>;
4799 def : ARMPat<(atomic_store_32 ldst_so_reg:$ptr, GPR:$val),
4800 (STRrs GPR:$val, ldst_so_reg:$ptr)>;
4801 def : ARMPat<(atomic_store_32 addrmode_imm12:$ptr, GPR:$val),
4802 (STRi12 GPR:$val, addrmode_imm12:$ptr)>;
4805 //===----------------------------------------------------------------------===//
4809 include "ARMInstrThumb.td"
4811 //===----------------------------------------------------------------------===//
4815 include "ARMInstrThumb2.td"
4817 //===----------------------------------------------------------------------===//
4818 // Floating Point Support
4821 include "ARMInstrVFP.td"
4823 //===----------------------------------------------------------------------===//
4824 // Advanced SIMD (NEON) Support
4827 include "ARMInstrNEON.td"
4829 //===----------------------------------------------------------------------===//
4830 // Assembler aliases
4834 def : InstAlias<"dmb", (DMB 0xf)>, Requires<[IsARM, HasDB]>;
4835 def : InstAlias<"dsb", (DSB 0xf)>, Requires<[IsARM, HasDB]>;
4836 def : InstAlias<"isb", (ISB 0xf)>, Requires<[IsARM, HasDB]>;
4838 // System instructions
4839 def : MnemonicAlias<"swi", "svc">;
4841 // Load / Store Multiple
4842 def : MnemonicAlias<"ldmfd", "ldm">;
4843 def : MnemonicAlias<"ldmia", "ldm">;
4844 def : MnemonicAlias<"ldmea", "ldmdb">;
4845 def : MnemonicAlias<"stmfd", "stmdb">;
4846 def : MnemonicAlias<"stmia", "stm">;
4847 def : MnemonicAlias<"stmea", "stm">;
4849 // PKHBT/PKHTB with default shift amount. PKHTB is equivalent to PKHBT when the
4850 // shift amount is zero (i.e., unspecified).
4851 def : InstAlias<"pkhbt${p} $Rd, $Rn, $Rm",
4852 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
4853 Requires<[IsARM, HasV6]>;
4854 def : InstAlias<"pkhtb${p} $Rd, $Rn, $Rm",
4855 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p)>,
4856 Requires<[IsARM, HasV6]>;
4858 // PUSH/POP aliases for STM/LDM
4859 def : ARMInstAlias<"push${p} $regs", (STMDB_UPD SP, pred:$p, reglist:$regs)>;
4860 def : ARMInstAlias<"pop${p} $regs", (LDMIA_UPD SP, pred:$p, reglist:$regs)>;
4862 // SSAT/USAT optional shift operand.
4863 def : ARMInstAlias<"ssat${p} $Rd, $sat_imm, $Rn",
4864 (SSAT GPRnopc:$Rd, imm1_32:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
4865 def : ARMInstAlias<"usat${p} $Rd, $sat_imm, $Rn",
4866 (USAT GPRnopc:$Rd, imm0_31:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
4869 // Extend instruction optional rotate operand.
4870 def : ARMInstAlias<"sxtab${p} $Rd, $Rn, $Rm",
4871 (SXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4872 def : ARMInstAlias<"sxtah${p} $Rd, $Rn, $Rm",
4873 (SXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4874 def : ARMInstAlias<"sxtab16${p} $Rd, $Rn, $Rm",
4875 (SXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4876 def : ARMInstAlias<"sxtb${p} $Rd, $Rm",
4877 (SXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4878 def : ARMInstAlias<"sxtb16${p} $Rd, $Rm",
4879 (SXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4880 def : ARMInstAlias<"sxth${p} $Rd, $Rm",
4881 (SXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4883 def : ARMInstAlias<"uxtab${p} $Rd, $Rn, $Rm",
4884 (UXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4885 def : ARMInstAlias<"uxtah${p} $Rd, $Rn, $Rm",
4886 (UXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4887 def : ARMInstAlias<"uxtab16${p} $Rd, $Rn, $Rm",
4888 (UXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
4889 def : ARMInstAlias<"uxtb${p} $Rd, $Rm",
4890 (UXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4891 def : ARMInstAlias<"uxtb16${p} $Rd, $Rm",
4892 (UXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4893 def : ARMInstAlias<"uxth${p} $Rd, $Rm",
4894 (UXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
4898 def : MnemonicAlias<"rfefa", "rfeda">;
4899 def : MnemonicAlias<"rfeea", "rfedb">;
4900 def : MnemonicAlias<"rfefd", "rfeia">;
4901 def : MnemonicAlias<"rfeed", "rfeib">;
4902 def : MnemonicAlias<"rfe", "rfeia">;
4905 def : MnemonicAlias<"srsfa", "srsda">;
4906 def : MnemonicAlias<"srsea", "srsdb">;
4907 def : MnemonicAlias<"srsfd", "srsia">;
4908 def : MnemonicAlias<"srsed", "srsib">;
4909 def : MnemonicAlias<"srs", "srsia">;
4912 def : MnemonicAlias<"qsubaddx", "qsax">;
4914 def : MnemonicAlias<"saddsubx", "sasx">;
4915 // SHASX == SHADDSUBX
4916 def : MnemonicAlias<"shaddsubx", "shasx">;
4917 // SHSAX == SHSUBADDX
4918 def : MnemonicAlias<"shsubaddx", "shsax">;
4920 def : MnemonicAlias<"ssubaddx", "ssax">;
4922 def : MnemonicAlias<"uaddsubx", "uasx">;
4923 // UHASX == UHADDSUBX
4924 def : MnemonicAlias<"uhaddsubx", "uhasx">;
4925 // UHSAX == UHSUBADDX
4926 def : MnemonicAlias<"uhsubaddx", "uhsax">;
4927 // UQASX == UQADDSUBX
4928 def : MnemonicAlias<"uqaddsubx", "uqasx">;
4929 // UQSAX == UQSUBADDX
4930 def : MnemonicAlias<"uqsubaddx", "uqsax">;
4932 def : MnemonicAlias<"usubaddx", "usax">;
4934 // LDRSBT/LDRHT/LDRSHT post-index offset if optional.
4935 // Note that the write-back output register is a dummy operand for MC (it's
4936 // only meaningful for codegen), so we just pass zero here.
4937 // FIXME: tblgen not cooperating with argument conversions.
4938 //def : InstAlias<"ldrsbt${p} $Rt, $addr",
4939 // (LDRSBTi GPR:$Rt, GPR:$Rt, addr_offset_none:$addr, 0,pred:$p)>;
4940 //def : InstAlias<"ldrht${p} $Rt, $addr",
4941 // (LDRHTi GPR:$Rt, GPR:$Rt, addr_offset_none:$addr, 0, pred:$p)>;
4942 //def : InstAlias<"ldrsht${p} $Rt, $addr",
4943 // (LDRSHTi GPR:$Rt, GPR:$Rt, addr_offset_none:$addr, 0, pred:$p)>;