1 //===- ARMInstrInfo.td - Target Description for ARM Target -*- tablegen -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file describes the ARM instructions in TableGen format.
11 //===----------------------------------------------------------------------===//
13 //===----------------------------------------------------------------------===//
14 // ARM specific DAG Nodes.
18 def SDT_ARMCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32>,
20 def SDT_ARMCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>, SDTCisVT<1, i32> ]>;
21 def SDT_ARMStructByVal : SDTypeProfile<0, 4,
22 [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
23 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
25 def SDT_ARMSaveCallPC : SDTypeProfile<0, 1, []>;
27 def SDT_ARMcall : SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>;
29 def SDT_ARMCMov : SDTypeProfile<1, 3,
30 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
33 def SDT_ARMBrcond : SDTypeProfile<0, 2,
34 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i32>]>;
36 def SDT_ARMBrJT : SDTypeProfile<0, 2,
37 [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
39 def SDT_ARMBr2JT : SDTypeProfile<0, 3,
40 [SDTCisPtrTy<0>, SDTCisVT<1, i32>,
43 def SDT_ARMBCC_i64 : SDTypeProfile<0, 6,
45 SDTCisVT<1, i32>, SDTCisVT<2, i32>,
46 SDTCisVT<3, i32>, SDTCisVT<4, i32>,
47 SDTCisVT<5, OtherVT>]>;
49 def SDT_ARMAnd : SDTypeProfile<1, 2,
50 [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
53 def SDT_ARMCmp : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
54 def SDT_ARMFCmp : SDTypeProfile<0, 3, [SDTCisSameAs<0, 1>,
57 def SDT_ARMPICAdd : SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>,
58 SDTCisPtrTy<1>, SDTCisVT<2, i32>]>;
60 def SDT_ARMThreadPointer : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
61 def SDT_ARMEH_SJLJ_Setjmp : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisPtrTy<1>,
63 def SDT_ARMEH_SJLJ_Longjmp: SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
64 def SDT_ARMEH_SJLJ_SetupDispatch: SDTypeProfile<0, 0, []>;
66 def SDT_ARMMEMBARRIER : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
68 def SDT_ARMPREFETCH : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisSameAs<1, 2>,
71 def SDT_ARMTCRET : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
73 def SDT_ARMBFI : SDTypeProfile<1, 3, [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
74 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
76 def SDT_WIN__DBZCHK : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
78 def SDT_ARMMEMCPY : SDTypeProfile<2, 3, [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
79 SDTCisVT<2, i32>, SDTCisVT<3, i32>,
82 def SDTBinaryArithWithFlags : SDTypeProfile<2, 2,
85 SDTCisInt<0>, SDTCisVT<1, i32>]>;
87 // SDTBinaryArithWithFlagsInOut - RES1, CPSR = op LHS, RHS, CPSR
88 def SDTBinaryArithWithFlagsInOut : SDTypeProfile<2, 3,
95 def SDT_LongMac : SDTypeProfile<2, 4, [SDTCisVT<0, i32>,
100 SDTCisSameAs<0, 5>]>;
102 // ARMlsll, ARMlsrl, ARMasrl
103 def SDT_ARMIntShiftParts : SDTypeProfile<2, 3, [SDTCisSameAs<0, 1>,
109 // TODO Add another operand for 'Size' so that we can re-use this node when we
110 // start supporting *TP versions.
111 def SDT_ARMLoLoop : SDTypeProfile<0, 2, [SDTCisVT<0, i32>,
112 SDTCisVT<1, OtherVT>]>;
114 def ARMSmlald : SDNode<"ARMISD::SMLALD", SDT_LongMac>;
115 def ARMSmlaldx : SDNode<"ARMISD::SMLALDX", SDT_LongMac>;
116 def ARMSmlsld : SDNode<"ARMISD::SMLSLD", SDT_LongMac>;
117 def ARMSmlsldx : SDNode<"ARMISD::SMLSLDX", SDT_LongMac>;
119 def SDT_MulHSR : SDTypeProfile<1, 3, [SDTCisVT<0,i32>,
122 SDTCisSameAs<0, 3>]>;
124 def ARMsmmlar : SDNode<"ARMISD::SMMLAR", SDT_MulHSR>;
125 def ARMsmmlsr : SDNode<"ARMISD::SMMLSR", SDT_MulHSR>;
128 def ARMWrapper : SDNode<"ARMISD::Wrapper", SDTIntUnaryOp>;
129 def ARMWrapperPIC : SDNode<"ARMISD::WrapperPIC", SDTIntUnaryOp>;
130 def ARMWrapperJT : SDNode<"ARMISD::WrapperJT", SDTIntUnaryOp>;
132 def ARMcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_ARMCallSeqStart,
133 [SDNPHasChain, SDNPSideEffect, SDNPOutGlue]>;
134 def ARMcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_ARMCallSeqEnd,
135 [SDNPHasChain, SDNPSideEffect,
136 SDNPOptInGlue, SDNPOutGlue]>;
137 def ARMcopystructbyval : SDNode<"ARMISD::COPY_STRUCT_BYVAL" ,
139 [SDNPHasChain, SDNPInGlue, SDNPOutGlue,
140 SDNPMayStore, SDNPMayLoad]>;
142 def ARMcall : SDNode<"ARMISD::CALL", SDT_ARMcall,
143 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
145 def ARMcall_pred : SDNode<"ARMISD::CALL_PRED", SDT_ARMcall,
146 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
148 def ARMcall_nolink : SDNode<"ARMISD::CALL_NOLINK", SDT_ARMcall,
149 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
152 def ARMretflag : SDNode<"ARMISD::RET_FLAG", SDTNone,
153 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
154 def ARMintretflag : SDNode<"ARMISD::INTRET_FLAG", SDT_ARMcall,
155 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
156 def ARMcmov : SDNode<"ARMISD::CMOV", SDT_ARMCMov,
158 def ARMsubs : SDNode<"ARMISD::SUBS", SDTIntBinOp, [SDNPOutGlue]>;
160 def ARMssatnoshift : SDNode<"ARMISD::SSAT", SDTIntSatNoShOp, []>;
162 def ARMusatnoshift : SDNode<"ARMISD::USAT", SDTIntSatNoShOp, []>;
164 def ARMbrcond : SDNode<"ARMISD::BRCOND", SDT_ARMBrcond,
165 [SDNPHasChain, SDNPInGlue, SDNPOutGlue]>;
167 def ARMbrjt : SDNode<"ARMISD::BR_JT", SDT_ARMBrJT,
169 def ARMbr2jt : SDNode<"ARMISD::BR2_JT", SDT_ARMBr2JT,
172 def ARMBcci64 : SDNode<"ARMISD::BCC_i64", SDT_ARMBCC_i64,
175 def ARMcmp : SDNode<"ARMISD::CMP", SDT_ARMCmp,
178 def ARMcmn : SDNode<"ARMISD::CMN", SDT_ARMCmp,
181 def ARMcmpZ : SDNode<"ARMISD::CMPZ", SDT_ARMCmp,
182 [SDNPOutGlue, SDNPCommutative]>;
184 def ARMpic_add : SDNode<"ARMISD::PIC_ADD", SDT_ARMPICAdd>;
186 def ARMasrl : SDNode<"ARMISD::ASRL", SDT_ARMIntShiftParts, []>;
187 def ARMlsrl : SDNode<"ARMISD::LSRL", SDT_ARMIntShiftParts, []>;
188 def ARMlsll : SDNode<"ARMISD::LSLL", SDT_ARMIntShiftParts, []>;
190 def ARMsrl_flag : SDNode<"ARMISD::SRL_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
191 def ARMsra_flag : SDNode<"ARMISD::SRA_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
192 def ARMrrx : SDNode<"ARMISD::RRX" , SDTIntUnaryOp, [SDNPInGlue ]>;
194 def ARMaddc : SDNode<"ARMISD::ADDC", SDTBinaryArithWithFlags,
196 def ARMsubc : SDNode<"ARMISD::SUBC", SDTBinaryArithWithFlags>;
197 def ARMadde : SDNode<"ARMISD::ADDE", SDTBinaryArithWithFlagsInOut>;
198 def ARMsube : SDNode<"ARMISD::SUBE", SDTBinaryArithWithFlagsInOut>;
200 def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>;
201 def ARMeh_sjlj_setjmp: SDNode<"ARMISD::EH_SJLJ_SETJMP",
202 SDT_ARMEH_SJLJ_Setjmp,
203 [SDNPHasChain, SDNPSideEffect]>;
204 def ARMeh_sjlj_longjmp: SDNode<"ARMISD::EH_SJLJ_LONGJMP",
205 SDT_ARMEH_SJLJ_Longjmp,
206 [SDNPHasChain, SDNPSideEffect]>;
207 def ARMeh_sjlj_setup_dispatch: SDNode<"ARMISD::EH_SJLJ_SETUP_DISPATCH",
208 SDT_ARMEH_SJLJ_SetupDispatch,
209 [SDNPHasChain, SDNPSideEffect]>;
211 def ARMMemBarrierMCR : SDNode<"ARMISD::MEMBARRIER_MCR", SDT_ARMMEMBARRIER,
212 [SDNPHasChain, SDNPSideEffect]>;
213 def ARMPreload : SDNode<"ARMISD::PRELOAD", SDT_ARMPREFETCH,
214 [SDNPHasChain, SDNPMayLoad, SDNPMayStore]>;
216 def ARMtcret : SDNode<"ARMISD::TC_RETURN", SDT_ARMTCRET,
217 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
219 def ARMbfi : SDNode<"ARMISD::BFI", SDT_ARMBFI>;
221 def ARMmemcopy : SDNode<"ARMISD::MEMCPY", SDT_ARMMEMCPY,
222 [SDNPHasChain, SDNPInGlue, SDNPOutGlue,
223 SDNPMayStore, SDNPMayLoad]>;
225 def ARMsmulwb : SDNode<"ARMISD::SMULWB", SDTIntBinOp, []>;
226 def ARMsmulwt : SDNode<"ARMISD::SMULWT", SDTIntBinOp, []>;
227 def ARMsmlalbb : SDNode<"ARMISD::SMLALBB", SDT_LongMac, []>;
228 def ARMsmlalbt : SDNode<"ARMISD::SMLALBT", SDT_LongMac, []>;
229 def ARMsmlaltb : SDNode<"ARMISD::SMLALTB", SDT_LongMac, []>;
230 def ARMsmlaltt : SDNode<"ARMISD::SMLALTT", SDT_LongMac, []>;
232 // Vector operations shared between NEON and MVE
234 def ARMvdup : SDNode<"ARMISD::VDUP", SDTypeProfile<1, 1, [SDTCisVec<0>]>>;
236 // VDUPLANE can produce a quad-register result from a double-register source,
237 // so the result is not constrained to match the source.
238 def ARMvduplane : SDNode<"ARMISD::VDUPLANE",
239 SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisVec<1>,
242 def SDTARMVSHUF : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisSameAs<0, 1>]>;
243 def ARMvrev64 : SDNode<"ARMISD::VREV64", SDTARMVSHUF>;
244 def ARMvrev32 : SDNode<"ARMISD::VREV32", SDTARMVSHUF>;
245 def ARMvrev16 : SDNode<"ARMISD::VREV16", SDTARMVSHUF>;
247 def SDTARMVGETLN : SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisInt<1>,
249 def ARMvgetlaneu : SDNode<"ARMISD::VGETLANEu", SDTARMVGETLN>;
250 def ARMvgetlanes : SDNode<"ARMISD::VGETLANEs", SDTARMVGETLN>;
252 def SDTARMVMOVIMM : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisVT<1, i32>]>;
253 def ARMvmovImm : SDNode<"ARMISD::VMOVIMM", SDTARMVMOVIMM>;
254 def ARMvmvnImm : SDNode<"ARMISD::VMVNIMM", SDTARMVMOVIMM>;
255 def ARMvmovFPImm : SDNode<"ARMISD::VMOVFPIMM", SDTARMVMOVIMM>;
258 def SDTARMVSHIMM : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisSameAs<0, 1>,
260 def SDTARMVSH : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisSameAs<0, 1>,
261 SDTCisSameAs<0, 2>,]>;
262 def ARMvshlImm : SDNode<"ARMISD::VSHLIMM", SDTARMVSHIMM>;
263 def ARMvshrsImm : SDNode<"ARMISD::VSHRsIMM", SDTARMVSHIMM>;
264 def ARMvshruImm : SDNode<"ARMISD::VSHRuIMM", SDTARMVSHIMM>;
265 def ARMvshls : SDNode<"ARMISD::VSHLs", SDTARMVSH>;
266 def ARMvshlu : SDNode<"ARMISD::VSHLu", SDTARMVSH>;
268 def SDTARMVCMP : SDTypeProfile<1, 3, [SDTCisInt<0>, SDTCisSameAs<1, 2>,
270 def SDTARMVCMPZ : SDTypeProfile<1, 2, [SDTCisInt<2>]>;
272 def ARMvcmp : SDNode<"ARMISD::VCMP", SDTARMVCMP>;
273 def ARMvcmpz : SDNode<"ARMISD::VCMPZ", SDTARMVCMPZ>;
275 def ARMWLS : SDNode<"ARMISD::WLS", SDT_ARMLoLoop, [SDNPHasChain]>;
276 def ARMLE : SDNode<"ARMISD::LE", SDT_ARMLoLoop, [SDNPHasChain]>;
277 def ARMLoopDec : SDNode<"ARMISD::LOOP_DEC", SDTIntBinOp, [SDNPHasChain]>;
279 //===----------------------------------------------------------------------===//
280 // ARM Flag Definitions.
282 class RegConstraint<string C> {
283 string Constraints = C;
286 //===----------------------------------------------------------------------===//
287 // ARM specific transformation functions and pattern fragments.
290 // imm_neg_XFORM - Return the negation of an i32 immediate value.
291 def imm_neg_XFORM : SDNodeXForm<imm, [{
292 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), SDLoc(N), MVT::i32);
295 // imm_not_XFORM - Return the complement of a i32 immediate value.
296 def imm_not_XFORM : SDNodeXForm<imm, [{
297 return CurDAG->getTargetConstant(~(int)N->getZExtValue(), SDLoc(N), MVT::i32);
300 /// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
301 def imm16_31 : ImmLeaf<i32, [{
302 return (int32_t)Imm >= 16 && (int32_t)Imm < 32;
305 // sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
306 def sext_16_node : PatLeaf<(i32 GPR:$a), [{
307 return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17;
310 def sext_bottom_16 : PatFrag<(ops node:$a),
311 (sext_inreg node:$a, i16)>;
312 def sext_top_16 : PatFrag<(ops node:$a),
313 (i32 (sra node:$a, (i32 16)))>;
315 def bb_mul : PatFrag<(ops node:$a, node:$b),
316 (mul (sext_bottom_16 node:$a), (sext_bottom_16 node:$b))>;
317 def bt_mul : PatFrag<(ops node:$a, node:$b),
318 (mul (sext_bottom_16 node:$a), (sra node:$b, (i32 16)))>;
319 def tb_mul : PatFrag<(ops node:$a, node:$b),
320 (mul (sra node:$a, (i32 16)), (sext_bottom_16 node:$b))>;
321 def tt_mul : PatFrag<(ops node:$a, node:$b),
322 (mul (sra node:$a, (i32 16)), (sra node:$b, (i32 16)))>;
324 /// Split a 32-bit immediate into two 16 bit parts.
325 def hi16 : SDNodeXForm<imm, [{
326 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, SDLoc(N),
330 def lo16AllZero : PatLeaf<(i32 imm), [{
331 // Returns true if all low 16-bits are 0.
332 return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
335 class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
336 class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
338 // An 'and' node with a single use.
339 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
340 return N->hasOneUse();
343 // An 'xor' node with a single use.
344 def xor_su : PatFrag<(ops node:$lhs, node:$rhs), (xor node:$lhs, node:$rhs), [{
345 return N->hasOneUse();
348 // An 'fmul' node with a single use.
349 def fmul_su : PatFrag<(ops node:$lhs, node:$rhs), (fmul node:$lhs, node:$rhs),[{
350 return N->hasOneUse();
353 // An 'fadd' node which checks for single non-hazardous use.
354 def fadd_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fadd node:$lhs, node:$rhs),[{
355 return hasNoVMLxHazardUse(N);
358 // An 'fsub' node which checks for single non-hazardous use.
359 def fsub_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fsub node:$lhs, node:$rhs),[{
360 return hasNoVMLxHazardUse(N);
363 //===----------------------------------------------------------------------===//
364 // Operand Definitions.
367 // Immediate operands with a shared generic asm render method.
368 class ImmAsmOperand<int Low, int High> : AsmOperandClass {
369 let RenderMethod = "addImmOperands";
370 let PredicateMethod = "isImmediate<" # Low # "," # High # ">";
371 let DiagnosticString = "operand must be an immediate in the range [" # Low # "," # High # "]";
374 class ImmAsmOperandMinusOne<int Low, int High> : AsmOperandClass {
375 let PredicateMethod = "isImmediate<" # Low # "," # High # ">";
376 let DiagnosticType = "ImmRange" # Low # "_" # High;
377 let DiagnosticString = "operand must be an immediate in the range [" # Low # "," # High # "]";
380 // Operands that are part of a memory addressing mode.
381 class MemOperand : Operand<i32> { let OperandType = "OPERAND_MEMORY"; }
384 // FIXME: rename brtarget to t2_brtarget
385 def brtarget : Operand<OtherVT> {
386 let EncoderMethod = "getBranchTargetOpValue";
387 let OperandType = "OPERAND_PCREL";
388 let DecoderMethod = "DecodeT2BROperand";
391 // Branches targeting ARM-mode must be divisible by 4 if they're a raw
393 def ARMBranchTarget : AsmOperandClass {
394 let Name = "ARMBranchTarget";
397 // Branches targeting Thumb-mode must be divisible by 2 if they're a raw
399 def ThumbBranchTarget : AsmOperandClass {
400 let Name = "ThumbBranchTarget";
403 def arm_br_target : Operand<OtherVT> {
404 let ParserMatchClass = ARMBranchTarget;
405 let EncoderMethod = "getARMBranchTargetOpValue";
406 let OperandType = "OPERAND_PCREL";
409 // Call target for ARM. Handles conditional/unconditional
410 // FIXME: rename bl_target to t2_bltarget?
411 def arm_bl_target : Operand<i32> {
412 let ParserMatchClass = ARMBranchTarget;
413 let EncoderMethod = "getARMBLTargetOpValue";
414 let OperandType = "OPERAND_PCREL";
417 // Target for BLX *from* ARM mode.
418 def arm_blx_target : Operand<i32> {
419 let ParserMatchClass = ThumbBranchTarget;
420 let EncoderMethod = "getARMBLXTargetOpValue";
421 let OperandType = "OPERAND_PCREL";
424 // A list of registers separated by comma. Used by load/store multiple.
425 def RegListAsmOperand : AsmOperandClass { let Name = "RegList"; }
426 def reglist : Operand<i32> {
427 let EncoderMethod = "getRegisterListOpValue";
428 let ParserMatchClass = RegListAsmOperand;
429 let PrintMethod = "printRegisterList";
430 let DecoderMethod = "DecodeRegListOperand";
433 // A list of general purpose registers and APSR separated by comma.
435 def RegListWithAPSRAsmOperand : AsmOperandClass { let Name = "RegListWithAPSR"; }
436 def reglist_with_apsr : Operand<i32> {
437 let EncoderMethod = "getRegisterListOpValue";
438 let ParserMatchClass = RegListWithAPSRAsmOperand;
439 let PrintMethod = "printRegisterList";
440 let DecoderMethod = "DecodeRegListOperand";
443 def GPRPairOp : RegisterOperand<GPRPair, "printGPRPairOperand">;
445 def DPRRegListAsmOperand : AsmOperandClass {
446 let Name = "DPRRegList";
447 let DiagnosticType = "DPR_RegList";
449 def dpr_reglist : Operand<i32> {
450 let EncoderMethod = "getRegisterListOpValue";
451 let ParserMatchClass = DPRRegListAsmOperand;
452 let PrintMethod = "printRegisterList";
453 let DecoderMethod = "DecodeDPRRegListOperand";
456 def SPRRegListAsmOperand : AsmOperandClass {
457 let Name = "SPRRegList";
458 let DiagnosticString = "operand must be a list of registers in range [s0, s31]";
460 def spr_reglist : Operand<i32> {
461 let EncoderMethod = "getRegisterListOpValue";
462 let ParserMatchClass = SPRRegListAsmOperand;
463 let PrintMethod = "printRegisterList";
464 let DecoderMethod = "DecodeSPRRegListOperand";
467 def FPSRegListWithVPRAsmOperand : AsmOperandClass { let Name =
468 "FPSRegListWithVPR"; }
469 def fp_sreglist_with_vpr : Operand<i32> {
470 let EncoderMethod = "getRegisterListOpValue";
471 let ParserMatchClass = FPSRegListWithVPRAsmOperand;
472 let PrintMethod = "printRegisterList";
474 def FPDRegListWithVPRAsmOperand : AsmOperandClass { let Name =
475 "FPDRegListWithVPR"; }
476 def fp_dreglist_with_vpr : Operand<i32> {
477 let EncoderMethod = "getRegisterListOpValue";
478 let ParserMatchClass = FPDRegListWithVPRAsmOperand;
479 let PrintMethod = "printRegisterList";
482 // An operand for the CONSTPOOL_ENTRY pseudo-instruction.
483 def cpinst_operand : Operand<i32> {
484 let PrintMethod = "printCPInstOperand";
488 def pclabel : Operand<i32> {
489 let PrintMethod = "printPCLabel";
492 // ADR instruction labels.
493 def AdrLabelAsmOperand : AsmOperandClass { let Name = "AdrLabel"; }
494 def adrlabel : Operand<i32> {
495 let EncoderMethod = "getAdrLabelOpValue";
496 let ParserMatchClass = AdrLabelAsmOperand;
497 let PrintMethod = "printAdrLabelOperand<0>";
500 def neon_vcvt_imm32 : Operand<i32> {
501 let EncoderMethod = "getNEONVcvtImm32OpValue";
502 let DecoderMethod = "DecodeVCVTImmOperand";
505 // rot_imm: An integer that encodes a rotate amount. Must be 8, 16, or 24.
506 def rot_imm_XFORM: SDNodeXForm<imm, [{
507 switch (N->getZExtValue()){
508 default: llvm_unreachable(nullptr);
509 case 0: return CurDAG->getTargetConstant(0, SDLoc(N), MVT::i32);
510 case 8: return CurDAG->getTargetConstant(1, SDLoc(N), MVT::i32);
511 case 16: return CurDAG->getTargetConstant(2, SDLoc(N), MVT::i32);
512 case 24: return CurDAG->getTargetConstant(3, SDLoc(N), MVT::i32);
515 def RotImmAsmOperand : AsmOperandClass {
517 let ParserMethod = "parseRotImm";
519 def rot_imm : Operand<i32>, PatLeaf<(i32 imm), [{
520 int32_t v = N->getZExtValue();
521 return v == 8 || v == 16 || v == 24; }],
523 let PrintMethod = "printRotImmOperand";
524 let ParserMatchClass = RotImmAsmOperand;
527 // Power-of-two operand for MVE VIDUP and friends, which encode
528 // {1,2,4,8} as its log to base 2, i.e. as {0,1,2,3} respectively
529 def MVE_VIDUP_imm_asmoperand : AsmOperandClass {
530 let Name = "VIDUP_imm";
531 let PredicateMethod = "isPowerTwoInRange<1,8>";
532 let RenderMethod = "addPowerTwoOperands";
533 let DiagnosticString = "vector increment immediate must be 1, 2, 4 or 8";
535 def MVE_VIDUP_imm : Operand<i32> {
536 let EncoderMethod = "getPowerTwoOpValue";
537 let DecoderMethod = "DecodePowerTwoOperand<0,3>";
538 let ParserMatchClass = MVE_VIDUP_imm_asmoperand;
541 // Pair vector indexing
542 class MVEPairVectorIndexOperand<string start, string end> : AsmOperandClass {
543 let Name = "MVEPairVectorIndex"#start;
544 let RenderMethod = "addMVEPairVectorIndexOperands";
545 let PredicateMethod = "isMVEPairVectorIndex<"#start#", "#end#">";
548 class MVEPairVectorIndex<string opval> : Operand<i32> {
549 let PrintMethod = "printVectorIndex";
550 let EncoderMethod = "getMVEPairVectorIndexOpValue<"#opval#">";
551 let DecoderMethod = "DecodeMVEPairVectorIndexOperand<"#opval#">";
552 let MIOperandInfo = (ops i32imm);
555 def MVEPairVectorIndex0 : MVEPairVectorIndex<"0"> {
556 let ParserMatchClass = MVEPairVectorIndexOperand<"0", "1">;
559 def MVEPairVectorIndex2 : MVEPairVectorIndex<"2"> {
560 let ParserMatchClass = MVEPairVectorIndexOperand<"2", "3">;
564 class MVEVectorIndexOperand<int NumLanes> : AsmOperandClass {
565 let Name = "MVEVectorIndex"#NumLanes;
566 let RenderMethod = "addMVEVectorIndexOperands";
567 let PredicateMethod = "isVectorIndexInRange<"#NumLanes#">";
570 class MVEVectorIndex<int NumLanes> : Operand<i32> {
571 let PrintMethod = "printVectorIndex";
572 let ParserMatchClass = MVEVectorIndexOperand<NumLanes>;
573 let MIOperandInfo = (ops i32imm);
576 // shift_imm: An integer that encodes a shift amount and the type of shift
577 // (asr or lsl). The 6-bit immediate encodes as:
580 // {4-0} imm5 shift amount.
581 // asr #32 encoded as imm5 == 0.
582 def ShifterImmAsmOperand : AsmOperandClass {
583 let Name = "ShifterImm";
584 let ParserMethod = "parseShifterImm";
586 def shift_imm : Operand<i32> {
587 let PrintMethod = "printShiftImmOperand";
588 let ParserMatchClass = ShifterImmAsmOperand;
591 // shifter_operand operands: so_reg_reg, so_reg_imm, and mod_imm.
592 def ShiftedRegAsmOperand : AsmOperandClass { let Name = "RegShiftedReg"; }
593 def so_reg_reg : Operand<i32>, // reg reg imm
594 ComplexPattern<i32, 3, "SelectRegShifterOperand",
595 [shl, srl, sra, rotr]> {
596 let EncoderMethod = "getSORegRegOpValue";
597 let PrintMethod = "printSORegRegOperand";
598 let DecoderMethod = "DecodeSORegRegOperand";
599 let ParserMatchClass = ShiftedRegAsmOperand;
600 let MIOperandInfo = (ops GPRnopc, GPRnopc, i32imm);
603 def ShiftedImmAsmOperand : AsmOperandClass { let Name = "RegShiftedImm"; }
604 def so_reg_imm : Operand<i32>, // reg imm
605 ComplexPattern<i32, 2, "SelectImmShifterOperand",
606 [shl, srl, sra, rotr]> {
607 let EncoderMethod = "getSORegImmOpValue";
608 let PrintMethod = "printSORegImmOperand";
609 let DecoderMethod = "DecodeSORegImmOperand";
610 let ParserMatchClass = ShiftedImmAsmOperand;
611 let MIOperandInfo = (ops GPR, i32imm);
614 // FIXME: Does this need to be distinct from so_reg?
615 def shift_so_reg_reg : Operand<i32>, // reg reg imm
616 ComplexPattern<i32, 3, "SelectShiftRegShifterOperand",
617 [shl,srl,sra,rotr]> {
618 let EncoderMethod = "getSORegRegOpValue";
619 let PrintMethod = "printSORegRegOperand";
620 let DecoderMethod = "DecodeSORegRegOperand";
621 let ParserMatchClass = ShiftedRegAsmOperand;
622 let MIOperandInfo = (ops GPR, GPR, i32imm);
625 // FIXME: Does this need to be distinct from so_reg?
626 def shift_so_reg_imm : Operand<i32>, // reg reg imm
627 ComplexPattern<i32, 2, "SelectShiftImmShifterOperand",
628 [shl,srl,sra,rotr]> {
629 let EncoderMethod = "getSORegImmOpValue";
630 let PrintMethod = "printSORegImmOperand";
631 let DecoderMethod = "DecodeSORegImmOperand";
632 let ParserMatchClass = ShiftedImmAsmOperand;
633 let MIOperandInfo = (ops GPR, i32imm);
636 // mod_imm: match a 32-bit immediate operand, which can be encoded into
637 // a 12-bit immediate; an 8-bit integer and a 4-bit rotator (See ARMARM
638 // - "Modified Immediate Constants"). Within the MC layer we keep this
639 // immediate in its encoded form.
640 def ModImmAsmOperand: AsmOperandClass {
642 let ParserMethod = "parseModImm";
644 def mod_imm : Operand<i32>, ImmLeaf<i32, [{
645 return ARM_AM::getSOImmVal(Imm) != -1;
647 let EncoderMethod = "getModImmOpValue";
648 let PrintMethod = "printModImmOperand";
649 let ParserMatchClass = ModImmAsmOperand;
652 // Note: the patterns mod_imm_not and mod_imm_neg do not require an encoder
653 // method and such, as they are only used on aliases (Pat<> and InstAlias<>).
654 // The actual parsing, encoding, decoding are handled by the destination
655 // instructions, which use mod_imm.
657 def ModImmNotAsmOperand : AsmOperandClass { let Name = "ModImmNot"; }
658 def mod_imm_not : Operand<i32>, PatLeaf<(imm), [{
659 return ARM_AM::getSOImmVal(~(uint32_t)N->getZExtValue()) != -1;
661 let ParserMatchClass = ModImmNotAsmOperand;
664 def ModImmNegAsmOperand : AsmOperandClass { let Name = "ModImmNeg"; }
665 def mod_imm_neg : Operand<i32>, PatLeaf<(imm), [{
666 unsigned Value = -(unsigned)N->getZExtValue();
667 return Value && ARM_AM::getSOImmVal(Value) != -1;
669 let ParserMatchClass = ModImmNegAsmOperand;
672 /// arm_i32imm - True for +V6T2, or when isSOImmTwoParVal()
673 def arm_i32imm : IntImmLeaf<i32, [{
674 if (Subtarget->useMovt())
676 return ARM_AM::isSOImmTwoPartVal(Imm.getZExtValue());
679 /// imm0_1 predicate - Immediate in the range [0,1].
680 def Imm0_1AsmOperand: ImmAsmOperand<0,1> { let Name = "Imm0_1"; }
681 def imm0_1 : Operand<i32> { let ParserMatchClass = Imm0_1AsmOperand; }
683 /// imm0_3 predicate - Immediate in the range [0,3].
684 def Imm0_3AsmOperand: ImmAsmOperand<0,3> { let Name = "Imm0_3"; }
685 def imm0_3 : Operand<i32> { let ParserMatchClass = Imm0_3AsmOperand; }
687 /// imm0_7 predicate - Immediate in the range [0,7].
688 def Imm0_7AsmOperand: ImmAsmOperand<0,7> {
691 def imm0_7 : Operand<i32>, ImmLeaf<i32, [{
692 return Imm >= 0 && Imm < 8;
694 let ParserMatchClass = Imm0_7AsmOperand;
697 /// imm8_255 predicate - Immediate in the range [8,255].
698 def Imm8_255AsmOperand: ImmAsmOperand<8,255> { let Name = "Imm8_255"; }
699 def imm8_255 : Operand<i32>, ImmLeaf<i32, [{
700 return Imm >= 8 && Imm < 256;
702 let ParserMatchClass = Imm8_255AsmOperand;
705 /// imm8 predicate - Immediate is exactly 8.
706 def Imm8AsmOperand: ImmAsmOperand<8,8> { let Name = "Imm8"; }
707 def imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 8; }]> {
708 let ParserMatchClass = Imm8AsmOperand;
711 /// imm16 predicate - Immediate is exactly 16.
712 def Imm16AsmOperand: ImmAsmOperand<16,16> { let Name = "Imm16"; }
713 def imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 16; }]> {
714 let ParserMatchClass = Imm16AsmOperand;
717 /// imm32 predicate - Immediate is exactly 32.
718 def Imm32AsmOperand: ImmAsmOperand<32,32> { let Name = "Imm32"; }
719 def imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 32; }]> {
720 let ParserMatchClass = Imm32AsmOperand;
723 def imm8_or_16 : ImmLeaf<i32, [{ return Imm == 8 || Imm == 16;}]>;
725 /// imm1_7 predicate - Immediate in the range [1,7].
726 def Imm1_7AsmOperand: ImmAsmOperand<1,7> { let Name = "Imm1_7"; }
727 def imm1_7 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 8; }]> {
728 let ParserMatchClass = Imm1_7AsmOperand;
731 /// imm1_15 predicate - Immediate in the range [1,15].
732 def Imm1_15AsmOperand: ImmAsmOperand<1,15> { let Name = "Imm1_15"; }
733 def imm1_15 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 16; }]> {
734 let ParserMatchClass = Imm1_15AsmOperand;
737 /// imm1_31 predicate - Immediate in the range [1,31].
738 def Imm1_31AsmOperand: ImmAsmOperand<1,31> { let Name = "Imm1_31"; }
739 def imm1_31 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 32; }]> {
740 let ParserMatchClass = Imm1_31AsmOperand;
743 /// imm0_15 predicate - Immediate in the range [0,15].
744 def Imm0_15AsmOperand: ImmAsmOperand<0,15> {
745 let Name = "Imm0_15";
747 def imm0_15 : Operand<i32>, ImmLeaf<i32, [{
748 return Imm >= 0 && Imm < 16;
750 let ParserMatchClass = Imm0_15AsmOperand;
753 /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
754 def Imm0_31AsmOperand: ImmAsmOperand<0,31> { let Name = "Imm0_31"; }
755 def imm0_31 : Operand<i32>, ImmLeaf<i32, [{
756 return Imm >= 0 && Imm < 32;
758 let ParserMatchClass = Imm0_31AsmOperand;
761 /// imm0_32 predicate - True if the 32-bit immediate is in the range [0,32].
762 def Imm0_32AsmOperand: ImmAsmOperand<0,32> { let Name = "Imm0_32"; }
763 def imm0_32 : Operand<i32>, ImmLeaf<i32, [{
764 return Imm >= 0 && Imm < 33;
766 let ParserMatchClass = Imm0_32AsmOperand;
769 /// imm0_63 predicate - True if the 32-bit immediate is in the range [0,63].
770 def Imm0_63AsmOperand: ImmAsmOperand<0,63> { let Name = "Imm0_63"; }
771 def imm0_63 : Operand<i32>, ImmLeaf<i32, [{
772 return Imm >= 0 && Imm < 64;
774 let ParserMatchClass = Imm0_63AsmOperand;
777 /// imm0_239 predicate - Immediate in the range [0,239].
778 def Imm0_239AsmOperand : ImmAsmOperand<0,239> {
779 let Name = "Imm0_239";
781 def imm0_239 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 240; }]> {
782 let ParserMatchClass = Imm0_239AsmOperand;
785 /// imm0_255 predicate - Immediate in the range [0,255].
786 def Imm0_255AsmOperand : ImmAsmOperand<0,255> { let Name = "Imm0_255"; }
787 def imm0_255 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 256; }]> {
788 let ParserMatchClass = Imm0_255AsmOperand;
791 /// imm0_65535 - An immediate is in the range [0,65535].
792 def Imm0_65535AsmOperand: ImmAsmOperand<0,65535> { let Name = "Imm0_65535"; }
793 def imm0_65535 : Operand<i32>, ImmLeaf<i32, [{
794 return Imm >= 0 && Imm < 65536;
796 let ParserMatchClass = Imm0_65535AsmOperand;
799 // imm0_65535_neg - An immediate whose negative value is in the range [0.65535].
800 def imm0_65535_neg : Operand<i32>, ImmLeaf<i32, [{
801 return -Imm >= 0 && -Imm < 65536;
804 // imm0_65535_expr - For movt/movw - 16-bit immediate that can also reference
805 // a relocatable expression.
807 // FIXME: This really needs a Thumb version separate from the ARM version.
808 // While the range is the same, and can thus use the same match class,
809 // the encoding is different so it should have a different encoder method.
810 def Imm0_65535ExprAsmOperand: AsmOperandClass {
811 let Name = "Imm0_65535Expr";
812 let RenderMethod = "addImmOperands";
813 let DiagnosticString = "operand must be an immediate in the range [0,0xffff] or a relocatable expression";
816 def imm0_65535_expr : Operand<i32> {
817 let EncoderMethod = "getHiLo16ImmOpValue";
818 let ParserMatchClass = Imm0_65535ExprAsmOperand;
821 def Imm256_65535ExprAsmOperand: ImmAsmOperand<256,65535> { let Name = "Imm256_65535Expr"; }
822 def imm256_65535_expr : Operand<i32> {
823 let ParserMatchClass = Imm256_65535ExprAsmOperand;
826 /// imm24b - True if the 32-bit immediate is encodable in 24 bits.
827 def Imm24bitAsmOperand: ImmAsmOperand<0,0xffffff> {
828 let Name = "Imm24bit";
829 let DiagnosticString = "operand must be an immediate in the range [0,0xffffff]";
831 def imm24b : Operand<i32>, ImmLeaf<i32, [{
832 return Imm >= 0 && Imm <= 0xffffff;
834 let ParserMatchClass = Imm24bitAsmOperand;
838 /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
840 def BitfieldAsmOperand : AsmOperandClass {
841 let Name = "Bitfield";
842 let ParserMethod = "parseBitfield";
845 def bf_inv_mask_imm : Operand<i32>,
847 return ARM::isBitFieldInvertedMask(N->getZExtValue());
849 let EncoderMethod = "getBitfieldInvertedMaskOpValue";
850 let PrintMethod = "printBitfieldInvMaskImmOperand";
851 let DecoderMethod = "DecodeBitfieldMaskOperand";
852 let ParserMatchClass = BitfieldAsmOperand;
853 let GISelPredicateCode = [{
854 // There's better methods of implementing this check. IntImmLeaf<> would be
855 // equivalent and have less boilerplate but we need a test for C++
856 // predicates and this one causes new rules to be imported into GlobalISel
857 // without requiring additional features first.
858 const auto &MO = MI.getOperand(1);
861 return ARM::isBitFieldInvertedMask(MO.getCImm()->getZExtValue());
865 def imm1_32_XFORM: SDNodeXForm<imm, [{
866 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, SDLoc(N),
869 def Imm1_32AsmOperand: ImmAsmOperandMinusOne<1,32> {
870 let Name = "Imm1_32";
872 def imm1_32 : Operand<i32>, PatLeaf<(imm), [{
873 uint64_t Imm = N->getZExtValue();
874 return Imm > 0 && Imm <= 32;
877 let PrintMethod = "printImmPlusOneOperand";
878 let ParserMatchClass = Imm1_32AsmOperand;
881 def imm1_16_XFORM: SDNodeXForm<imm, [{
882 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, SDLoc(N),
885 def Imm1_16AsmOperand: ImmAsmOperandMinusOne<1,16> { let Name = "Imm1_16"; }
886 def imm1_16 : Operand<i32>, ImmLeaf<i32, [{
887 return Imm > 0 && Imm <= 16;
890 let PrintMethod = "printImmPlusOneOperand";
891 let ParserMatchClass = Imm1_16AsmOperand;
894 def MVEShiftImm1_7AsmOperand: ImmAsmOperand<1,7> {
895 let Name = "MVEShiftImm1_7";
896 // Reason we're doing this is because instruction vshll.s8 t1 encoding
897 // accepts 1,7 but the t2 encoding accepts 8. By doing this we can get a
898 // better diagnostic message if someone uses bigger immediate than the t1/t2
900 let DiagnosticString = "operand must be an immediate in the range [1,8]";
902 def mve_shift_imm1_7 : Operand<i32> {
903 let ParserMatchClass = MVEShiftImm1_7AsmOperand;
904 let EncoderMethod = "getMVEShiftImmOpValue";
907 def MVEShiftImm1_15AsmOperand: ImmAsmOperand<1,15> {
908 let Name = "MVEShiftImm1_15";
909 // Reason we're doing this is because instruction vshll.s16 t1 encoding
910 // accepts 1,15 but the t2 encoding accepts 16. By doing this we can get a
911 // better diagnostic message if someone uses bigger immediate than the t1/t2
913 let DiagnosticString = "operand must be an immediate in the range [1,16]";
915 def mve_shift_imm1_15 : Operand<i32> {
916 let ParserMatchClass = MVEShiftImm1_15AsmOperand;
917 let EncoderMethod = "getMVEShiftImmOpValue";
920 // Define ARM specific addressing modes.
921 // addrmode_imm12 := reg +/- imm12
923 def MemImm12OffsetAsmOperand : AsmOperandClass { let Name = "MemImm12Offset"; }
924 class AddrMode_Imm12 : MemOperand,
925 ComplexPattern<i32, 2, "SelectAddrModeImm12", []> {
926 // 12-bit immediate operand. Note that instructions using this encode
927 // #0 and #-0 differently. We flag #-0 as the magic value INT32_MIN. All other
928 // immediate values are as normal.
930 let EncoderMethod = "getAddrModeImm12OpValue";
931 let DecoderMethod = "DecodeAddrModeImm12Operand";
932 let ParserMatchClass = MemImm12OffsetAsmOperand;
933 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
936 def addrmode_imm12 : AddrMode_Imm12 {
937 let PrintMethod = "printAddrModeImm12Operand<false>";
940 def addrmode_imm12_pre : AddrMode_Imm12 {
941 let PrintMethod = "printAddrModeImm12Operand<true>";
944 // ldst_so_reg := reg +/- reg shop imm
946 def MemRegOffsetAsmOperand : AsmOperandClass { let Name = "MemRegOffset"; }
947 def ldst_so_reg : MemOperand,
948 ComplexPattern<i32, 3, "SelectLdStSOReg", []> {
949 let EncoderMethod = "getLdStSORegOpValue";
950 // FIXME: Simplify the printer
951 let PrintMethod = "printAddrMode2Operand";
952 let DecoderMethod = "DecodeSORegMemOperand";
953 let ParserMatchClass = MemRegOffsetAsmOperand;
954 let MIOperandInfo = (ops GPR:$base, GPRnopc:$offsreg, i32imm:$shift);
957 // postidx_imm8 := +/- [0,255]
960 // {8} 1 is imm8 is non-negative. 0 otherwise.
961 // {7-0} [0,255] imm8 value.
962 def PostIdxImm8AsmOperand : AsmOperandClass { let Name = "PostIdxImm8"; }
963 def postidx_imm8 : MemOperand {
964 let PrintMethod = "printPostIdxImm8Operand";
965 let ParserMatchClass = PostIdxImm8AsmOperand;
966 let MIOperandInfo = (ops i32imm);
969 // postidx_imm8s4 := +/- [0,1020]
972 // {8} 1 is imm8 is non-negative. 0 otherwise.
973 // {7-0} [0,255] imm8 value, scaled by 4.
974 def PostIdxImm8s4AsmOperand : AsmOperandClass { let Name = "PostIdxImm8s4"; }
975 def postidx_imm8s4 : MemOperand {
976 let PrintMethod = "printPostIdxImm8s4Operand";
977 let ParserMatchClass = PostIdxImm8s4AsmOperand;
978 let MIOperandInfo = (ops i32imm);
982 // postidx_reg := +/- reg
984 def PostIdxRegAsmOperand : AsmOperandClass {
985 let Name = "PostIdxReg";
986 let ParserMethod = "parsePostIdxReg";
988 def postidx_reg : MemOperand {
989 let EncoderMethod = "getPostIdxRegOpValue";
990 let DecoderMethod = "DecodePostIdxReg";
991 let PrintMethod = "printPostIdxRegOperand";
992 let ParserMatchClass = PostIdxRegAsmOperand;
993 let MIOperandInfo = (ops GPRnopc, i32imm);
996 def PostIdxRegShiftedAsmOperand : AsmOperandClass {
997 let Name = "PostIdxRegShifted";
998 let ParserMethod = "parsePostIdxReg";
1000 def am2offset_reg : MemOperand,
1001 ComplexPattern<i32, 2, "SelectAddrMode2OffsetReg",
1002 [], [SDNPWantRoot]> {
1003 let EncoderMethod = "getAddrMode2OffsetOpValue";
1004 let PrintMethod = "printAddrMode2OffsetOperand";
1005 // When using this for assembly, it's always as a post-index offset.
1006 let ParserMatchClass = PostIdxRegShiftedAsmOperand;
1007 let MIOperandInfo = (ops GPRnopc, i32imm);
1010 // FIXME: am2offset_imm should only need the immediate, not the GPR. Having
1011 // the GPR is purely vestigal at this point.
1012 def AM2OffsetImmAsmOperand : AsmOperandClass { let Name = "AM2OffsetImm"; }
1013 def am2offset_imm : MemOperand,
1014 ComplexPattern<i32, 2, "SelectAddrMode2OffsetImm",
1015 [], [SDNPWantRoot]> {
1016 let EncoderMethod = "getAddrMode2OffsetOpValue";
1017 let PrintMethod = "printAddrMode2OffsetOperand";
1018 let ParserMatchClass = AM2OffsetImmAsmOperand;
1019 let MIOperandInfo = (ops GPRnopc, i32imm);
1023 // addrmode3 := reg +/- reg
1024 // addrmode3 := reg +/- imm8
1026 // FIXME: split into imm vs. reg versions.
1027 def AddrMode3AsmOperand : AsmOperandClass { let Name = "AddrMode3"; }
1028 class AddrMode3 : MemOperand,
1029 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
1030 let EncoderMethod = "getAddrMode3OpValue";
1031 let ParserMatchClass = AddrMode3AsmOperand;
1032 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
1035 def addrmode3 : AddrMode3
1037 let PrintMethod = "printAddrMode3Operand<false>";
1040 def addrmode3_pre : AddrMode3
1042 let PrintMethod = "printAddrMode3Operand<true>";
1045 // FIXME: split into imm vs. reg versions.
1046 // FIXME: parser method to handle +/- register.
1047 def AM3OffsetAsmOperand : AsmOperandClass {
1048 let Name = "AM3Offset";
1049 let ParserMethod = "parseAM3Offset";
1051 def am3offset : MemOperand,
1052 ComplexPattern<i32, 2, "SelectAddrMode3Offset",
1053 [], [SDNPWantRoot]> {
1054 let EncoderMethod = "getAddrMode3OffsetOpValue";
1055 let PrintMethod = "printAddrMode3OffsetOperand";
1056 let ParserMatchClass = AM3OffsetAsmOperand;
1057 let MIOperandInfo = (ops GPR, i32imm);
1060 // ldstm_mode := {ia, ib, da, db}
1062 def ldstm_mode : OptionalDefOperand<OtherVT, (ops i32), (ops (i32 1))> {
1063 let EncoderMethod = "getLdStmModeOpValue";
1064 let PrintMethod = "printLdStmModeOperand";
1067 // addrmode5 := reg +/- imm8*4
1069 def AddrMode5AsmOperand : AsmOperandClass { let Name = "AddrMode5"; }
1070 class AddrMode5 : MemOperand,
1071 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
1072 let EncoderMethod = "getAddrMode5OpValue";
1073 let DecoderMethod = "DecodeAddrMode5Operand";
1074 let ParserMatchClass = AddrMode5AsmOperand;
1075 let MIOperandInfo = (ops GPR:$base, i32imm);
1078 def addrmode5 : AddrMode5 {
1079 let PrintMethod = "printAddrMode5Operand<false>";
1082 def addrmode5_pre : AddrMode5 {
1083 let PrintMethod = "printAddrMode5Operand<true>";
1086 // addrmode5fp16 := reg +/- imm8*2
1088 def AddrMode5FP16AsmOperand : AsmOperandClass { let Name = "AddrMode5FP16"; }
1089 class AddrMode5FP16 : Operand<i32>,
1090 ComplexPattern<i32, 2, "SelectAddrMode5FP16", []> {
1091 let EncoderMethod = "getAddrMode5FP16OpValue";
1092 let DecoderMethod = "DecodeAddrMode5FP16Operand";
1093 let ParserMatchClass = AddrMode5FP16AsmOperand;
1094 let MIOperandInfo = (ops GPR:$base, i32imm);
1097 def addrmode5fp16 : AddrMode5FP16 {
1098 let PrintMethod = "printAddrMode5FP16Operand<false>";
1101 // addrmode6 := reg with optional alignment
1103 def AddrMode6AsmOperand : AsmOperandClass { let Name = "AlignedMemory"; }
1104 def addrmode6 : MemOperand,
1105 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1106 let PrintMethod = "printAddrMode6Operand";
1107 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
1108 let EncoderMethod = "getAddrMode6AddressOpValue";
1109 let DecoderMethod = "DecodeAddrMode6Operand";
1110 let ParserMatchClass = AddrMode6AsmOperand;
1113 def am6offset : MemOperand,
1114 ComplexPattern<i32, 1, "SelectAddrMode6Offset",
1115 [], [SDNPWantRoot]> {
1116 let PrintMethod = "printAddrMode6OffsetOperand";
1117 let MIOperandInfo = (ops GPR);
1118 let EncoderMethod = "getAddrMode6OffsetOpValue";
1119 let DecoderMethod = "DecodeGPRRegisterClass";
1122 // Special version of addrmode6 to handle alignment encoding for VST1/VLD1
1123 // (single element from one lane) for size 32.
1124 def addrmode6oneL32 : MemOperand,
1125 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1126 let PrintMethod = "printAddrMode6Operand";
1127 let MIOperandInfo = (ops GPR:$addr, i32imm);
1128 let EncoderMethod = "getAddrMode6OneLane32AddressOpValue";
1131 // Base class for addrmode6 with specific alignment restrictions.
1132 class AddrMode6Align : MemOperand,
1133 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1134 let PrintMethod = "printAddrMode6Operand";
1135 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
1136 let EncoderMethod = "getAddrMode6AddressOpValue";
1137 let DecoderMethod = "DecodeAddrMode6Operand";
1140 // Special version of addrmode6 to handle no allowed alignment encoding for
1141 // VLD/VST instructions and checking the alignment is not specified.
1142 def AddrMode6AlignNoneAsmOperand : AsmOperandClass {
1143 let Name = "AlignedMemoryNone";
1144 let DiagnosticString = "alignment must be omitted";
1146 def addrmode6alignNone : AddrMode6Align {
1147 // The alignment specifier can only be omitted.
1148 let ParserMatchClass = AddrMode6AlignNoneAsmOperand;
1151 // Special version of addrmode6 to handle 16-bit alignment encoding for
1152 // VLD/VST instructions and checking the alignment value.
1153 def AddrMode6Align16AsmOperand : AsmOperandClass {
1154 let Name = "AlignedMemory16";
1155 let DiagnosticString = "alignment must be 16 or omitted";
1157 def addrmode6align16 : AddrMode6Align {
1158 // The alignment specifier can only be 16 or omitted.
1159 let ParserMatchClass = AddrMode6Align16AsmOperand;
1162 // Special version of addrmode6 to handle 32-bit alignment encoding for
1163 // VLD/VST instructions and checking the alignment value.
1164 def AddrMode6Align32AsmOperand : AsmOperandClass {
1165 let Name = "AlignedMemory32";
1166 let DiagnosticString = "alignment must be 32 or omitted";
1168 def addrmode6align32 : AddrMode6Align {
1169 // The alignment specifier can only be 32 or omitted.
1170 let ParserMatchClass = AddrMode6Align32AsmOperand;
1173 // Special version of addrmode6 to handle 64-bit alignment encoding for
1174 // VLD/VST instructions and checking the alignment value.
1175 def AddrMode6Align64AsmOperand : AsmOperandClass {
1176 let Name = "AlignedMemory64";
1177 let DiagnosticString = "alignment must be 64 or omitted";
1179 def addrmode6align64 : AddrMode6Align {
1180 // The alignment specifier can only be 64 or omitted.
1181 let ParserMatchClass = AddrMode6Align64AsmOperand;
1184 // Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding
1185 // for VLD/VST instructions and checking the alignment value.
1186 def AddrMode6Align64or128AsmOperand : AsmOperandClass {
1187 let Name = "AlignedMemory64or128";
1188 let DiagnosticString = "alignment must be 64, 128 or omitted";
1190 def addrmode6align64or128 : AddrMode6Align {
1191 // The alignment specifier can only be 64, 128 or omitted.
1192 let ParserMatchClass = AddrMode6Align64or128AsmOperand;
1195 // Special version of addrmode6 to handle 64-bit, 128-bit or 256-bit alignment
1196 // encoding for VLD/VST instructions and checking the alignment value.
1197 def AddrMode6Align64or128or256AsmOperand : AsmOperandClass {
1198 let Name = "AlignedMemory64or128or256";
1199 let DiagnosticString = "alignment must be 64, 128, 256 or omitted";
1201 def addrmode6align64or128or256 : AddrMode6Align {
1202 // The alignment specifier can only be 64, 128, 256 or omitted.
1203 let ParserMatchClass = AddrMode6Align64or128or256AsmOperand;
1206 // Special version of addrmode6 to handle alignment encoding for VLD-dup
1207 // instructions, specifically VLD4-dup.
1208 def addrmode6dup : MemOperand,
1209 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1210 let PrintMethod = "printAddrMode6Operand";
1211 let MIOperandInfo = (ops GPR:$addr, i32imm);
1212 let EncoderMethod = "getAddrMode6DupAddressOpValue";
1213 // FIXME: This is close, but not quite right. The alignment specifier is
1215 let ParserMatchClass = AddrMode6AsmOperand;
1218 // Base class for addrmode6dup with specific alignment restrictions.
1219 class AddrMode6DupAlign : MemOperand,
1220 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1221 let PrintMethod = "printAddrMode6Operand";
1222 let MIOperandInfo = (ops GPR:$addr, i32imm);
1223 let EncoderMethod = "getAddrMode6DupAddressOpValue";
1226 // Special version of addrmode6 to handle no allowed alignment encoding for
1227 // VLD-dup instruction and checking the alignment is not specified.
1228 def AddrMode6dupAlignNoneAsmOperand : AsmOperandClass {
1229 let Name = "DupAlignedMemoryNone";
1230 let DiagnosticString = "alignment must be omitted";
1232 def addrmode6dupalignNone : AddrMode6DupAlign {
1233 // The alignment specifier can only be omitted.
1234 let ParserMatchClass = AddrMode6dupAlignNoneAsmOperand;
1237 // Special version of addrmode6 to handle 16-bit alignment encoding for VLD-dup
1238 // instruction and checking the alignment value.
1239 def AddrMode6dupAlign16AsmOperand : AsmOperandClass {
1240 let Name = "DupAlignedMemory16";
1241 let DiagnosticString = "alignment must be 16 or omitted";
1243 def addrmode6dupalign16 : AddrMode6DupAlign {
1244 // The alignment specifier can only be 16 or omitted.
1245 let ParserMatchClass = AddrMode6dupAlign16AsmOperand;
1248 // Special version of addrmode6 to handle 32-bit alignment encoding for VLD-dup
1249 // instruction and checking the alignment value.
1250 def AddrMode6dupAlign32AsmOperand : AsmOperandClass {
1251 let Name = "DupAlignedMemory32";
1252 let DiagnosticString = "alignment must be 32 or omitted";
1254 def addrmode6dupalign32 : AddrMode6DupAlign {
1255 // The alignment specifier can only be 32 or omitted.
1256 let ParserMatchClass = AddrMode6dupAlign32AsmOperand;
1259 // Special version of addrmode6 to handle 64-bit alignment encoding for VLD
1260 // instructions and checking the alignment value.
1261 def AddrMode6dupAlign64AsmOperand : AsmOperandClass {
1262 let Name = "DupAlignedMemory64";
1263 let DiagnosticString = "alignment must be 64 or omitted";
1265 def addrmode6dupalign64 : AddrMode6DupAlign {
1266 // The alignment specifier can only be 64 or omitted.
1267 let ParserMatchClass = AddrMode6dupAlign64AsmOperand;
1270 // Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding
1271 // for VLD instructions and checking the alignment value.
1272 def AddrMode6dupAlign64or128AsmOperand : AsmOperandClass {
1273 let Name = "DupAlignedMemory64or128";
1274 let DiagnosticString = "alignment must be 64, 128 or omitted";
1276 def addrmode6dupalign64or128 : AddrMode6DupAlign {
1277 // The alignment specifier can only be 64, 128 or omitted.
1278 let ParserMatchClass = AddrMode6dupAlign64or128AsmOperand;
1281 // addrmodepc := pc + reg
1283 def addrmodepc : MemOperand,
1284 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
1285 let PrintMethod = "printAddrModePCOperand";
1286 let MIOperandInfo = (ops GPR, i32imm);
1289 // addr_offset_none := reg
1291 def MemNoOffsetAsmOperand : AsmOperandClass { let Name = "MemNoOffset"; }
1292 def addr_offset_none : MemOperand,
1293 ComplexPattern<i32, 1, "SelectAddrOffsetNone", []> {
1294 let PrintMethod = "printAddrMode7Operand";
1295 let DecoderMethod = "DecodeAddrMode7Operand";
1296 let ParserMatchClass = MemNoOffsetAsmOperand;
1297 let MIOperandInfo = (ops GPR:$base);
1300 // t_addr_offset_none := reg [r0-r7]
1301 def MemNoOffsetTAsmOperand : AsmOperandClass { let Name = "MemNoOffsetT"; }
1302 def t_addr_offset_none : MemOperand {
1303 let PrintMethod = "printAddrMode7Operand";
1304 let DecoderMethod = "DecodetGPRRegisterClass";
1305 let ParserMatchClass = MemNoOffsetTAsmOperand;
1306 let MIOperandInfo = (ops tGPR:$base);
1309 def nohash_imm : Operand<i32> {
1310 let PrintMethod = "printNoHashImmediate";
1313 def CoprocNumAsmOperand : AsmOperandClass {
1314 let Name = "CoprocNum";
1315 let ParserMethod = "parseCoprocNumOperand";
1317 def p_imm : Operand<i32> {
1318 let PrintMethod = "printPImmediate";
1319 let ParserMatchClass = CoprocNumAsmOperand;
1320 let DecoderMethod = "DecodeCoprocessor";
1323 def CoprocRegAsmOperand : AsmOperandClass {
1324 let Name = "CoprocReg";
1325 let ParserMethod = "parseCoprocRegOperand";
1327 def c_imm : Operand<i32> {
1328 let PrintMethod = "printCImmediate";
1329 let ParserMatchClass = CoprocRegAsmOperand;
1331 def CoprocOptionAsmOperand : AsmOperandClass {
1332 let Name = "CoprocOption";
1333 let ParserMethod = "parseCoprocOptionOperand";
1335 def coproc_option_imm : Operand<i32> {
1336 let PrintMethod = "printCoprocOptionImm";
1337 let ParserMatchClass = CoprocOptionAsmOperand;
1340 //===----------------------------------------------------------------------===//
1342 include "ARMInstrFormats.td"
1344 //===----------------------------------------------------------------------===//
1345 // Multiclass helpers...
1348 /// AsI1_bin_irs - Defines a set of (op r, {mod_imm|r|so_reg}) patterns for a
1349 /// binop that produces a value.
1350 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1351 multiclass AsI1_bin_irs<bits<4> opcod, string opc,
1352 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1353 SDPatternOperator opnode, bit Commutable = 0> {
1354 // The register-immediate version is re-materializable. This is useful
1355 // in particular for taking the address of a local.
1356 let isReMaterializable = 1 in {
1357 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm,
1358 iii, opc, "\t$Rd, $Rn, $imm",
1359 [(set GPR:$Rd, (opnode GPR:$Rn, mod_imm:$imm))]>,
1360 Sched<[WriteALU, ReadALU]> {
1365 let Inst{19-16} = Rn;
1366 let Inst{15-12} = Rd;
1367 let Inst{11-0} = imm;
1370 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1371 iir, opc, "\t$Rd, $Rn, $Rm",
1372 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]>,
1373 Sched<[WriteALU, ReadALU, ReadALU]> {
1378 let isCommutable = Commutable;
1379 let Inst{19-16} = Rn;
1380 let Inst{15-12} = Rd;
1381 let Inst{11-4} = 0b00000000;
1385 def rsi : AsI1<opcod, (outs GPR:$Rd),
1386 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1387 iis, opc, "\t$Rd, $Rn, $shift",
1388 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_imm:$shift))]>,
1389 Sched<[WriteALUsi, ReadALU]> {
1394 let Inst{19-16} = Rn;
1395 let Inst{15-12} = Rd;
1396 let Inst{11-5} = shift{11-5};
1398 let Inst{3-0} = shift{3-0};
1401 def rsr : AsI1<opcod, (outs GPR:$Rd),
1402 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1403 iis, opc, "\t$Rd, $Rn, $shift",
1404 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_reg:$shift))]>,
1405 Sched<[WriteALUsr, ReadALUsr]> {
1410 let Inst{19-16} = Rn;
1411 let Inst{15-12} = Rd;
1412 let Inst{11-8} = shift{11-8};
1414 let Inst{6-5} = shift{6-5};
1416 let Inst{3-0} = shift{3-0};
1420 /// AsI1_rbin_irs - Same as AsI1_bin_irs except the order of operands are
1421 /// reversed. The 'rr' form is only defined for the disassembler; for codegen
1422 /// it is equivalent to the AsI1_bin_irs counterpart.
1423 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1424 multiclass AsI1_rbin_irs<bits<4> opcod, string opc,
1425 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1426 SDNode opnode, bit Commutable = 0> {
1427 // The register-immediate version is re-materializable. This is useful
1428 // in particular for taking the address of a local.
1429 let isReMaterializable = 1 in {
1430 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm,
1431 iii, opc, "\t$Rd, $Rn, $imm",
1432 [(set GPR:$Rd, (opnode mod_imm:$imm, GPR:$Rn))]>,
1433 Sched<[WriteALU, ReadALU]> {
1438 let Inst{19-16} = Rn;
1439 let Inst{15-12} = Rd;
1440 let Inst{11-0} = imm;
1443 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1444 iir, opc, "\t$Rd, $Rn, $Rm",
1445 [/* pattern left blank */]>,
1446 Sched<[WriteALU, ReadALU, ReadALU]> {
1450 let Inst{11-4} = 0b00000000;
1453 let Inst{15-12} = Rd;
1454 let Inst{19-16} = Rn;
1457 def rsi : AsI1<opcod, (outs GPR:$Rd),
1458 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1459 iis, opc, "\t$Rd, $Rn, $shift",
1460 [(set GPR:$Rd, (opnode so_reg_imm:$shift, GPR:$Rn))]>,
1461 Sched<[WriteALUsi, ReadALU]> {
1466 let Inst{19-16} = Rn;
1467 let Inst{15-12} = Rd;
1468 let Inst{11-5} = shift{11-5};
1470 let Inst{3-0} = shift{3-0};
1473 def rsr : AsI1<opcod, (outs GPR:$Rd),
1474 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1475 iis, opc, "\t$Rd, $Rn, $shift",
1476 [(set GPR:$Rd, (opnode so_reg_reg:$shift, GPR:$Rn))]>,
1477 Sched<[WriteALUsr, ReadALUsr]> {
1482 let Inst{19-16} = Rn;
1483 let Inst{15-12} = Rd;
1484 let Inst{11-8} = shift{11-8};
1486 let Inst{6-5} = shift{6-5};
1488 let Inst{3-0} = shift{3-0};
1492 /// AsI1_bin_s_irs - Same as AsI1_bin_irs except it sets the 's' bit by default.
1494 /// These opcodes will be converted to the real non-S opcodes by
1495 /// AdjustInstrPostInstrSelection after giving them an optional CPSR operand.
1496 let hasPostISelHook = 1, Defs = [CPSR] in {
1497 multiclass AsI1_bin_s_irs<InstrItinClass iii, InstrItinClass iir,
1498 InstrItinClass iis, SDNode opnode,
1499 bit Commutable = 0> {
1500 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p),
1502 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm))]>,
1503 Sched<[WriteALU, ReadALU]>;
1505 def rr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, pred:$p),
1507 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm))]>,
1508 Sched<[WriteALU, ReadALU, ReadALU]> {
1509 let isCommutable = Commutable;
1511 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1512 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1514 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1515 so_reg_imm:$shift))]>,
1516 Sched<[WriteALUsi, ReadALU]>;
1518 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1519 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1521 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1522 so_reg_reg:$shift))]>,
1523 Sched<[WriteALUSsr, ReadALUsr]>;
1527 /// AsI1_rbin_s_is - Same as AsI1_bin_s_irs, except selection DAG
1528 /// operands are reversed.
1529 let hasPostISelHook = 1, Defs = [CPSR] in {
1530 multiclass AsI1_rbin_s_is<InstrItinClass iii, InstrItinClass iir,
1531 InstrItinClass iis, SDNode opnode,
1532 bit Commutable = 0> {
1533 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p),
1535 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn))]>,
1536 Sched<[WriteALU, ReadALU]>;
1538 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1539 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1541 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift,
1543 Sched<[WriteALUsi, ReadALU]>;
1545 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1546 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1548 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift,
1550 Sched<[WriteALUSsr, ReadALUsr]>;
1554 /// AI1_cmp_irs - Defines a set of (op r, {mod_imm|r|so_reg}) cmp / test
1555 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
1556 /// a explicit result, only implicitly set CPSR.
1557 let isCompare = 1, Defs = [CPSR] in {
1558 multiclass AI1_cmp_irs<bits<4> opcod, string opc,
1559 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1560 SDPatternOperator opnode, bit Commutable = 0,
1561 string rrDecoderMethod = ""> {
1562 def ri : AI1<opcod, (outs), (ins GPR:$Rn, mod_imm:$imm), DPFrm, iii,
1564 [(opnode GPR:$Rn, mod_imm:$imm)]>,
1565 Sched<[WriteCMP, ReadALU]> {
1570 let Inst{19-16} = Rn;
1571 let Inst{15-12} = 0b0000;
1572 let Inst{11-0} = imm;
1574 let Unpredictable{15-12} = 0b1111;
1576 def rr : AI1<opcod, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, iir,
1578 [(opnode GPR:$Rn, GPR:$Rm)]>,
1579 Sched<[WriteCMP, ReadALU, ReadALU]> {
1582 let isCommutable = Commutable;
1585 let Inst{19-16} = Rn;
1586 let Inst{15-12} = 0b0000;
1587 let Inst{11-4} = 0b00000000;
1589 let DecoderMethod = rrDecoderMethod;
1591 let Unpredictable{15-12} = 0b1111;
1593 def rsi : AI1<opcod, (outs),
1594 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, iis,
1595 opc, "\t$Rn, $shift",
1596 [(opnode GPR:$Rn, so_reg_imm:$shift)]>,
1597 Sched<[WriteCMPsi, ReadALU]> {
1602 let Inst{19-16} = Rn;
1603 let Inst{15-12} = 0b0000;
1604 let Inst{11-5} = shift{11-5};
1606 let Inst{3-0} = shift{3-0};
1608 let Unpredictable{15-12} = 0b1111;
1610 def rsr : AI1<opcod, (outs),
1611 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, iis,
1612 opc, "\t$Rn, $shift",
1613 [(opnode GPRnopc:$Rn, so_reg_reg:$shift)]>,
1614 Sched<[WriteCMPsr, ReadALU]> {
1619 let Inst{19-16} = Rn;
1620 let Inst{15-12} = 0b0000;
1621 let Inst{11-8} = shift{11-8};
1623 let Inst{6-5} = shift{6-5};
1625 let Inst{3-0} = shift{3-0};
1627 let Unpredictable{15-12} = 0b1111;
1633 /// AI_ext_rrot - A unary operation with two forms: one whose operand is a
1634 /// register and one whose operand is a register rotated by 8/16/24.
1635 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
1636 class AI_ext_rrot<bits<8> opcod, string opc, PatFrag opnode>
1637 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1638 IIC_iEXTr, opc, "\t$Rd, $Rm$rot",
1639 [(set GPRnopc:$Rd, (opnode (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1640 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> {
1644 let Inst{19-16} = 0b1111;
1645 let Inst{15-12} = Rd;
1646 let Inst{11-10} = rot;
1650 class AI_ext_rrot_np<bits<8> opcod, string opc>
1651 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1652 IIC_iEXTr, opc, "\t$Rd, $Rm$rot", []>,
1653 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> {
1655 let Inst{19-16} = 0b1111;
1656 let Inst{11-10} = rot;
1659 /// AI_exta_rrot - A binary operation with two forms: one whose operand is a
1660 /// register and one whose operand is a register rotated by 8/16/24.
1661 class AI_exta_rrot<bits<8> opcod, string opc, PatFrag opnode>
1662 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1663 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot",
1664 [(set GPRnopc:$Rd, (opnode GPR:$Rn,
1665 (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1666 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> {
1671 let Inst{19-16} = Rn;
1672 let Inst{15-12} = Rd;
1673 let Inst{11-10} = rot;
1674 let Inst{9-4} = 0b000111;
1678 class AI_exta_rrot_np<bits<8> opcod, string opc>
1679 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1680 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot", []>,
1681 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> {
1684 let Inst{19-16} = Rn;
1685 let Inst{11-10} = rot;
1688 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
1689 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1690 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, SDNode opnode,
1691 bit Commutable = 0> {
1692 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1693 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm),
1694 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1695 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm, CPSR))]>,
1697 Sched<[WriteALU, ReadALU]> {
1702 let Inst{15-12} = Rd;
1703 let Inst{19-16} = Rn;
1704 let Inst{11-0} = imm;
1706 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1707 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1708 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm, CPSR))]>,
1710 Sched<[WriteALU, ReadALU, ReadALU]> {
1714 let Inst{11-4} = 0b00000000;
1716 let isCommutable = Commutable;
1718 let Inst{15-12} = Rd;
1719 let Inst{19-16} = Rn;
1721 def rsi : AsI1<opcod, (outs GPR:$Rd),
1722 (ins GPR:$Rn, so_reg_imm:$shift),
1723 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1724 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_imm:$shift, CPSR))]>,
1726 Sched<[WriteALUsi, ReadALU]> {
1731 let Inst{19-16} = Rn;
1732 let Inst{15-12} = Rd;
1733 let Inst{11-5} = shift{11-5};
1735 let Inst{3-0} = shift{3-0};
1737 def rsr : AsI1<opcod, (outs GPRnopc:$Rd),
1738 (ins GPRnopc:$Rn, so_reg_reg:$shift),
1739 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1740 [(set GPRnopc:$Rd, CPSR,
1741 (opnode GPRnopc:$Rn, so_reg_reg:$shift, CPSR))]>,
1743 Sched<[WriteALUsr, ReadALUsr]> {
1748 let Inst{19-16} = Rn;
1749 let Inst{15-12} = Rd;
1750 let Inst{11-8} = shift{11-8};
1752 let Inst{6-5} = shift{6-5};
1754 let Inst{3-0} = shift{3-0};
1759 /// AI1_rsc_irs - Define instructions and patterns for rsc
1760 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1761 multiclass AI1_rsc_irs<bits<4> opcod, string opc, SDNode opnode> {
1762 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1763 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm),
1764 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1765 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn, CPSR))]>,
1767 Sched<[WriteALU, ReadALU]> {
1772 let Inst{15-12} = Rd;
1773 let Inst{19-16} = Rn;
1774 let Inst{11-0} = imm;
1776 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1777 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1778 [/* pattern left blank */]>,
1779 Sched<[WriteALU, ReadALU, ReadALU]> {
1783 let Inst{11-4} = 0b00000000;
1786 let Inst{15-12} = Rd;
1787 let Inst{19-16} = Rn;
1789 def rsi : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_imm:$shift),
1790 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1791 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift, GPR:$Rn, CPSR))]>,
1793 Sched<[WriteALUsi, ReadALU]> {
1798 let Inst{19-16} = Rn;
1799 let Inst{15-12} = Rd;
1800 let Inst{11-5} = shift{11-5};
1802 let Inst{3-0} = shift{3-0};
1804 def rsr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_reg:$shift),
1805 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1806 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift, GPR:$Rn, CPSR))]>,
1808 Sched<[WriteALUsr, ReadALUsr]> {
1813 let Inst{19-16} = Rn;
1814 let Inst{15-12} = Rd;
1815 let Inst{11-8} = shift{11-8};
1817 let Inst{6-5} = shift{6-5};
1819 let Inst{3-0} = shift{3-0};
1824 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1825 multiclass AI_ldr1<bit isByte, string opc, InstrItinClass iii,
1826 InstrItinClass iir, PatFrag opnode> {
1827 // Note: We use the complex addrmode_imm12 rather than just an input
1828 // GPR and a constrained immediate so that we can use this to match
1829 // frame index references and avoid matching constant pool references.
1830 def i12: AI2ldst<0b010, 1, isByte, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
1831 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1832 [(set GPR:$Rt, (opnode addrmode_imm12:$addr))]> {
1835 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1836 let Inst{19-16} = addr{16-13}; // Rn
1837 let Inst{15-12} = Rt;
1838 let Inst{11-0} = addr{11-0}; // imm12
1840 def rs : AI2ldst<0b011, 1, isByte, (outs GPR:$Rt), (ins ldst_so_reg:$shift),
1841 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1842 [(set GPR:$Rt, (opnode ldst_so_reg:$shift))]> {
1845 let shift{4} = 0; // Inst{4} = 0
1846 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1847 let Inst{19-16} = shift{16-13}; // Rn
1848 let Inst{15-12} = Rt;
1849 let Inst{11-0} = shift{11-0};
1854 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1855 multiclass AI_ldr1nopc<bit isByte, string opc, InstrItinClass iii,
1856 InstrItinClass iir, PatFrag opnode> {
1857 // Note: We use the complex addrmode_imm12 rather than just an input
1858 // GPR and a constrained immediate so that we can use this to match
1859 // frame index references and avoid matching constant pool references.
1860 def i12: AI2ldst<0b010, 1, isByte, (outs GPRnopc:$Rt),
1861 (ins addrmode_imm12:$addr),
1862 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1863 [(set GPRnopc:$Rt, (opnode addrmode_imm12:$addr))]> {
1866 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1867 let Inst{19-16} = addr{16-13}; // Rn
1868 let Inst{15-12} = Rt;
1869 let Inst{11-0} = addr{11-0}; // imm12
1871 def rs : AI2ldst<0b011, 1, isByte, (outs GPRnopc:$Rt),
1872 (ins ldst_so_reg:$shift),
1873 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1874 [(set GPRnopc:$Rt, (opnode ldst_so_reg:$shift))]> {
1877 let shift{4} = 0; // Inst{4} = 0
1878 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1879 let Inst{19-16} = shift{16-13}; // Rn
1880 let Inst{15-12} = Rt;
1881 let Inst{11-0} = shift{11-0};
1887 multiclass AI_str1<bit isByte, string opc, InstrItinClass iii,
1888 InstrItinClass iir, PatFrag opnode> {
1889 // Note: We use the complex addrmode_imm12 rather than just an input
1890 // GPR and a constrained immediate so that we can use this to match
1891 // frame index references and avoid matching constant pool references.
1892 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1893 (ins GPR:$Rt, addrmode_imm12:$addr),
1894 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1895 [(opnode GPR:$Rt, addrmode_imm12:$addr)]> {
1898 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1899 let Inst{19-16} = addr{16-13}; // Rn
1900 let Inst{15-12} = Rt;
1901 let Inst{11-0} = addr{11-0}; // imm12
1903 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPR:$Rt, ldst_so_reg:$shift),
1904 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1905 [(opnode GPR:$Rt, ldst_so_reg:$shift)]> {
1908 let shift{4} = 0; // Inst{4} = 0
1909 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1910 let Inst{19-16} = shift{16-13}; // Rn
1911 let Inst{15-12} = Rt;
1912 let Inst{11-0} = shift{11-0};
1916 multiclass AI_str1nopc<bit isByte, string opc, InstrItinClass iii,
1917 InstrItinClass iir, PatFrag opnode> {
1918 // Note: We use the complex addrmode_imm12 rather than just an input
1919 // GPR and a constrained immediate so that we can use this to match
1920 // frame index references and avoid matching constant pool references.
1921 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1922 (ins GPRnopc:$Rt, addrmode_imm12:$addr),
1923 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1924 [(opnode GPRnopc:$Rt, addrmode_imm12:$addr)]> {
1927 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1928 let Inst{19-16} = addr{16-13}; // Rn
1929 let Inst{15-12} = Rt;
1930 let Inst{11-0} = addr{11-0}; // imm12
1932 def rs : AI2ldst<0b011, 0, isByte, (outs),
1933 (ins GPRnopc:$Rt, ldst_so_reg:$shift),
1934 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1935 [(opnode GPRnopc:$Rt, ldst_so_reg:$shift)]> {
1938 let shift{4} = 0; // Inst{4} = 0
1939 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1940 let Inst{19-16} = shift{16-13}; // Rn
1941 let Inst{15-12} = Rt;
1942 let Inst{11-0} = shift{11-0};
1947 //===----------------------------------------------------------------------===//
1949 //===----------------------------------------------------------------------===//
1951 //===----------------------------------------------------------------------===//
1952 // Miscellaneous Instructions.
1955 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
1956 /// the function. The first operand is the ID# for this instruction, the second
1957 /// is the index into the MachineConstantPool that this is, the third is the
1958 /// size in bytes of this constant pool entry.
1959 let hasSideEffects = 0, isNotDuplicable = 1 in
1960 def CONSTPOOL_ENTRY :
1961 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1962 i32imm:$size), NoItinerary, []>;
1964 /// A jumptable consisting of direct 32-bit addresses of the destination basic
1965 /// blocks (either absolute, or relative to the start of the jump-table in PIC
1966 /// mode). Used mostly in ARM and Thumb-1 modes.
1967 def JUMPTABLE_ADDRS :
1968 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1969 i32imm:$size), NoItinerary, []>;
1971 /// A jumptable consisting of 32-bit jump instructions. Used for Thumb-2 tables
1972 /// that cannot be optimised to use TBB or TBH.
1973 def JUMPTABLE_INSTS :
1974 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1975 i32imm:$size), NoItinerary, []>;
1977 /// A jumptable consisting of 8-bit unsigned integers representing offsets from
1978 /// a TBB instruction.
1980 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1981 i32imm:$size), NoItinerary, []>;
1983 /// A jumptable consisting of 16-bit unsigned integers representing offsets from
1984 /// a TBH instruction.
1986 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1987 i32imm:$size), NoItinerary, []>;
1990 // FIXME: Marking these as hasSideEffects is necessary to prevent machine DCE
1991 // from removing one half of the matched pairs. That breaks PEI, which assumes
1992 // these will always be in pairs, and asserts if it finds otherwise. Better way?
1993 let Defs = [SP], Uses = [SP], hasSideEffects = 1 in {
1994 def ADJCALLSTACKUP :
1995 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary,
1996 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
1998 def ADJCALLSTACKDOWN :
1999 PseudoInst<(outs), (ins i32imm:$amt, i32imm:$amt2, pred:$p), NoItinerary,
2000 [(ARMcallseq_start timm:$amt, timm:$amt2)]>;
2003 def HINT : AI<(outs), (ins imm0_239:$imm), MiscFrm, NoItinerary,
2004 "hint", "\t$imm", [(int_arm_hint imm0_239:$imm)]>,
2005 Requires<[IsARM, HasV6]> {
2007 let Inst{27-8} = 0b00110010000011110000;
2008 let Inst{7-0} = imm;
2009 let DecoderMethod = "DecodeHINTInstruction";
2012 def : InstAlias<"nop$p", (HINT 0, pred:$p)>, Requires<[IsARM, HasV6K]>;
2013 def : InstAlias<"yield$p", (HINT 1, pred:$p)>, Requires<[IsARM, HasV6K]>;
2014 def : InstAlias<"wfe$p", (HINT 2, pred:$p)>, Requires<[IsARM, HasV6K]>;
2015 def : InstAlias<"wfi$p", (HINT 3, pred:$p)>, Requires<[IsARM, HasV6K]>;
2016 def : InstAlias<"sev$p", (HINT 4, pred:$p)>, Requires<[IsARM, HasV6K]>;
2017 def : InstAlias<"sevl$p", (HINT 5, pred:$p)>, Requires<[IsARM, HasV8]>;
2018 def : InstAlias<"esb$p", (HINT 16, pred:$p)>, Requires<[IsARM, HasRAS]>;
2019 def : InstAlias<"csdb$p", (HINT 20, pred:$p)>, Requires<[IsARM, HasV6K]>;
2021 def SEL : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, NoItinerary, "sel",
2023 [(set GPR:$Rd, (int_arm_sel GPR:$Rn, GPR:$Rm))]>,
2024 Requires<[IsARM, HasV6]> {
2029 let Inst{15-12} = Rd;
2030 let Inst{19-16} = Rn;
2031 let Inst{27-20} = 0b01101000;
2032 let Inst{7-4} = 0b1011;
2033 let Inst{11-8} = 0b1111;
2034 let Unpredictable{11-8} = 0b1111;
2037 // The 16-bit operand $val can be used by a debugger to store more information
2038 // about the breakpoint.
2039 def BKPT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
2040 "bkpt", "\t$val", []>, Requires<[IsARM]> {
2042 let Inst{3-0} = val{3-0};
2043 let Inst{19-8} = val{15-4};
2044 let Inst{27-20} = 0b00010010;
2045 let Inst{31-28} = 0xe; // AL
2046 let Inst{7-4} = 0b0111;
2048 // default immediate for breakpoint mnemonic
2049 def : InstAlias<"bkpt", (BKPT 0), 0>, Requires<[IsARM]>;
2051 def HLT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
2052 "hlt", "\t$val", []>, Requires<[IsARM, HasV8]> {
2054 let Inst{3-0} = val{3-0};
2055 let Inst{19-8} = val{15-4};
2056 let Inst{27-20} = 0b00010000;
2057 let Inst{31-28} = 0xe; // AL
2058 let Inst{7-4} = 0b0111;
2061 // Change Processor State
2062 // FIXME: We should use InstAlias to handle the optional operands.
2063 class CPS<dag iops, string asm_ops>
2064 : AXI<(outs), iops, MiscFrm, NoItinerary, !strconcat("cps", asm_ops),
2065 []>, Requires<[IsARM]> {
2071 let Inst{31-28} = 0b1111;
2072 let Inst{27-20} = 0b00010000;
2073 let Inst{19-18} = imod;
2074 let Inst{17} = M; // Enabled if mode is set;
2075 let Inst{16-9} = 0b00000000;
2076 let Inst{8-6} = iflags;
2078 let Inst{4-0} = mode;
2081 let DecoderMethod = "DecodeCPSInstruction" in {
2083 def CPS3p : CPS<(ins imod_op:$imod, iflags_op:$iflags, imm0_31:$mode),
2084 "$imod\t$iflags, $mode">;
2085 let mode = 0, M = 0 in
2086 def CPS2p : CPS<(ins imod_op:$imod, iflags_op:$iflags), "$imod\t$iflags">;
2088 let imod = 0, iflags = 0, M = 1 in
2089 def CPS1p : CPS<(ins imm0_31:$mode), "\t$mode">;
2092 // Preload signals the memory system of possible future data/instruction access.
2093 multiclass APreLoad<bits<1> read, bits<1> data, string opc> {
2095 def i12 : AXIM<(outs), (ins addrmode_imm12:$addr), AddrMode_i12, MiscFrm,
2096 IIC_Preload, !strconcat(opc, "\t$addr"),
2097 [(ARMPreload addrmode_imm12:$addr, (i32 read), (i32 data))]>,
2098 Sched<[WritePreLd]> {
2101 let Inst{31-26} = 0b111101;
2102 let Inst{25} = 0; // 0 for immediate form
2103 let Inst{24} = data;
2104 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2105 let Inst{22} = read;
2106 let Inst{21-20} = 0b01;
2107 let Inst{19-16} = addr{16-13}; // Rn
2108 let Inst{15-12} = 0b1111;
2109 let Inst{11-0} = addr{11-0}; // imm12
2112 def rs : AXI<(outs), (ins ldst_so_reg:$shift), MiscFrm, IIC_Preload,
2113 !strconcat(opc, "\t$shift"),
2114 [(ARMPreload ldst_so_reg:$shift, (i32 read), (i32 data))]>,
2115 Sched<[WritePreLd]> {
2117 let Inst{31-26} = 0b111101;
2118 let Inst{25} = 1; // 1 for register form
2119 let Inst{24} = data;
2120 let Inst{23} = shift{12}; // U (add = ('U' == 1))
2121 let Inst{22} = read;
2122 let Inst{21-20} = 0b01;
2123 let Inst{19-16} = shift{16-13}; // Rn
2124 let Inst{15-12} = 0b1111;
2125 let Inst{11-0} = shift{11-0};
2130 defm PLD : APreLoad<1, 1, "pld">, Requires<[IsARM]>;
2131 defm PLDW : APreLoad<0, 1, "pldw">, Requires<[IsARM,HasV7,HasMP]>;
2132 defm PLI : APreLoad<1, 0, "pli">, Requires<[IsARM,HasV7]>;
2134 def SETEND : AXI<(outs), (ins setend_op:$end), MiscFrm, NoItinerary,
2135 "setend\t$end", []>, Requires<[IsARM]>, Deprecated<HasV8Ops> {
2137 let Inst{31-10} = 0b1111000100000001000000;
2142 def DBG : AI<(outs), (ins imm0_15:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt",
2143 [(int_arm_dbg imm0_15:$opt)]>, Requires<[IsARM, HasV7]> {
2145 let Inst{27-4} = 0b001100100000111100001111;
2146 let Inst{3-0} = opt;
2149 // A8.8.247 UDF - Undefined (Encoding A1)
2150 def UDF : AInoP<(outs), (ins imm0_65535:$imm16), MiscFrm, NoItinerary,
2151 "udf", "\t$imm16", [(int_arm_undefined imm0_65535:$imm16)]> {
2153 let Inst{31-28} = 0b1110; // AL
2154 let Inst{27-25} = 0b011;
2155 let Inst{24-20} = 0b11111;
2156 let Inst{19-8} = imm16{15-4};
2157 let Inst{7-4} = 0b1111;
2158 let Inst{3-0} = imm16{3-0};
2162 * A5.4 Permanently UNDEFINED instructions.
2164 * For most targets use UDF #65006, for which the OS will generate SIGTRAP.
2165 * Other UDF encodings generate SIGILL.
2167 * NaCl's OS instead chooses an ARM UDF encoding that's also a UDF in Thumb.
2169 * 1110 0111 1111 iiii iiii iiii 1111 iiii
2171 * 1101 1110 iiii iiii
2172 * It uses the following encoding:
2173 * 1110 0111 1111 1110 1101 1110 1111 0000
2174 * - In ARM: UDF #60896;
2175 * - In Thumb: UDF #254 followed by a branch-to-self.
2177 let isBarrier = 1, isTerminator = 1 in
2178 def TRAPNaCl : AXI<(outs), (ins), MiscFrm, NoItinerary,
2180 Requires<[IsARM,UseNaClTrap]> {
2181 let Inst = 0xe7fedef0;
2183 let isBarrier = 1, isTerminator = 1 in
2184 def TRAP : AXI<(outs), (ins), MiscFrm, NoItinerary,
2186 Requires<[IsARM,DontUseNaClTrap]> {
2187 let Inst = 0xe7ffdefe;
2190 def : Pat<(debugtrap), (BKPT 0)>, Requires<[IsARM, HasV5T]>;
2191 def : Pat<(debugtrap), (UDF 254)>, Requires<[IsARM, NoV5T]>;
2193 // Address computation and loads and stores in PIC mode.
2194 let isNotDuplicable = 1 in {
2195 def PICADD : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
2197 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>,
2198 Sched<[WriteALU, ReadALU]>;
2200 let AddedComplexity = 10 in {
2201 def PICLDR : ARMPseudoInst<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
2203 [(set GPR:$dst, (load addrmodepc:$addr))]>;
2205 def PICLDRH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2207 [(set GPR:$Rt, (zextloadi16 addrmodepc:$addr))]>;
2209 def PICLDRB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2211 [(set GPR:$Rt, (zextloadi8 addrmodepc:$addr))]>;
2213 def PICLDRSH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2215 [(set GPR:$Rt, (sextloadi16 addrmodepc:$addr))]>;
2217 def PICLDRSB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2219 [(set GPR:$Rt, (sextloadi8 addrmodepc:$addr))]>;
2221 let AddedComplexity = 10 in {
2222 def PICSTR : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2223 4, IIC_iStore_r, [(store GPR:$src, addrmodepc:$addr)]>;
2225 def PICSTRH : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2226 4, IIC_iStore_bh_r, [(truncstorei16 GPR:$src,
2227 addrmodepc:$addr)]>;
2229 def PICSTRB : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2230 4, IIC_iStore_bh_r, [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
2232 } // isNotDuplicable = 1
2235 // LEApcrel - Load a pc-relative address into a register without offending the
2237 let hasSideEffects = 0, isReMaterializable = 1 in
2238 // The 'adr' mnemonic encodes differently if the label is before or after
2239 // the instruction. The {24-21} opcode bits are set by the fixup, as we don't
2240 // know until then which form of the instruction will be used.
2241 def ADR : AI1<{0,?,?,0}, (outs GPR:$Rd), (ins adrlabel:$label),
2242 MiscFrm, IIC_iALUi, "adr", "\t$Rd, $label", []>,
2243 Sched<[WriteALU, ReadALU]> {
2246 let Inst{27-25} = 0b001;
2248 let Inst{23-22} = label{13-12};
2251 let Inst{19-16} = 0b1111;
2252 let Inst{15-12} = Rd;
2253 let Inst{11-0} = label{11-0};
2256 let hasSideEffects = 1 in {
2257 def LEApcrel : ARMPseudoInst<(outs GPR:$Rd), (ins i32imm:$label, pred:$p),
2258 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
2260 def LEApcrelJT : ARMPseudoInst<(outs GPR:$Rd),
2261 (ins i32imm:$label, pred:$p),
2262 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
2265 //===----------------------------------------------------------------------===//
2266 // Control Flow Instructions.
2269 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
2271 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
2272 "bx", "\tlr", [(ARMretflag)]>,
2273 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2274 let Inst{27-0} = 0b0001001011111111111100011110;
2278 def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br,
2279 "mov", "\tpc, lr", [(ARMretflag)]>,
2280 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]> {
2281 let Inst{27-0} = 0b0001101000001111000000001110;
2284 // Exception return: N.b. doesn't set CPSR as far as we're concerned (it sets
2285 // the user-space one).
2286 def SUBS_PC_LR : ARMPseudoInst<(outs), (ins i32imm:$offset, pred:$p),
2288 [(ARMintretflag imm:$offset)]>;
2291 // Indirect branches
2292 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
2294 def BX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
2295 [(brind GPR:$dst)]>,
2296 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2298 let Inst{31-4} = 0b1110000100101111111111110001;
2299 let Inst{3-0} = dst;
2302 def BX_pred : AI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br,
2303 "bx", "\t$dst", [/* pattern left blank */]>,
2304 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2306 let Inst{27-4} = 0b000100101111111111110001;
2307 let Inst{3-0} = dst;
2311 // SP is marked as a use to prevent stack-pointer assignments that appear
2312 // immediately before calls from potentially appearing dead.
2314 // FIXME: Do we really need a non-predicated version? If so, it should
2315 // at least be a pseudo instruction expanding to the predicated version
2316 // at MC lowering time.
2317 Defs = [LR], Uses = [SP] in {
2318 def BL : ABXI<0b1011, (outs), (ins arm_bl_target:$func),
2319 IIC_Br, "bl\t$func",
2320 [(ARMcall tglobaladdr:$func)]>,
2321 Requires<[IsARM]>, Sched<[WriteBrL]> {
2322 let Inst{31-28} = 0b1110;
2324 let Inst{23-0} = func;
2325 let DecoderMethod = "DecodeBranchImmInstruction";
2328 def BL_pred : ABI<0b1011, (outs), (ins arm_bl_target:$func),
2329 IIC_Br, "bl", "\t$func",
2330 [(ARMcall_pred tglobaladdr:$func)]>,
2331 Requires<[IsARM]>, Sched<[WriteBrL]> {
2333 let Inst{23-0} = func;
2334 let DecoderMethod = "DecodeBranchImmInstruction";
2338 def BLX : AXI<(outs), (ins GPR:$func), BrMiscFrm,
2339 IIC_Br, "blx\t$func",
2340 [(ARMcall GPR:$func)]>,
2341 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2343 let Inst{31-4} = 0b1110000100101111111111110011;
2344 let Inst{3-0} = func;
2347 def BLX_pred : AI<(outs), (ins GPR:$func), BrMiscFrm,
2348 IIC_Br, "blx", "\t$func",
2349 [(ARMcall_pred GPR:$func)]>,
2350 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2352 let Inst{27-4} = 0b000100101111111111110011;
2353 let Inst{3-0} = func;
2357 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
2358 def BX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
2359 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
2360 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]>;
2363 def BMOVPCRX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
2364 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
2365 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
2367 // mov lr, pc; b if callee is marked noreturn to avoid confusing the
2368 // return stack predictor.
2369 def BMOVPCB_CALL : ARMPseudoInst<(outs), (ins arm_bl_target:$func),
2370 8, IIC_Br, [(ARMcall_nolink tglobaladdr:$func)]>,
2371 Requires<[IsARM]>, Sched<[WriteBr]>;
2374 let isBranch = 1, isTerminator = 1 in {
2375 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
2376 // a two-value operand where a dag node expects two operands. :(
2377 def Bcc : ABI<0b1010, (outs), (ins arm_br_target:$target),
2378 IIC_Br, "b", "\t$target",
2379 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>,
2382 let Inst{23-0} = target;
2383 let DecoderMethod = "DecodeBranchImmInstruction";
2386 let isBarrier = 1 in {
2387 // B is "predicable" since it's just a Bcc with an 'always' condition.
2388 let isPredicable = 1 in
2389 // FIXME: We shouldn't need this pseudo at all. Just using Bcc directly
2390 // should be sufficient.
2391 // FIXME: Is B really a Barrier? That doesn't seem right.
2392 def B : ARMPseudoExpand<(outs), (ins arm_br_target:$target), 4, IIC_Br,
2393 [(br bb:$target)], (Bcc arm_br_target:$target,
2394 (ops 14, zero_reg))>,
2397 let Size = 4, isNotDuplicable = 1, isIndirectBranch = 1 in {
2398 def BR_JTr : ARMPseudoInst<(outs),
2399 (ins GPR:$target, i32imm:$jt),
2401 [(ARMbrjt GPR:$target, tjumptable:$jt)]>,
2403 def BR_JTm_i12 : ARMPseudoInst<(outs),
2404 (ins addrmode_imm12:$target, i32imm:$jt),
2406 [(ARMbrjt (i32 (load addrmode_imm12:$target)),
2407 tjumptable:$jt)]>, Sched<[WriteBrTbl]>;
2408 def BR_JTm_rs : ARMPseudoInst<(outs),
2409 (ins ldst_so_reg:$target, i32imm:$jt),
2411 [(ARMbrjt (i32 (load ldst_so_reg:$target)),
2412 tjumptable:$jt)]>, Sched<[WriteBrTbl]>;
2413 def BR_JTadd : ARMPseudoInst<(outs),
2414 (ins GPR:$target, GPR:$idx, i32imm:$jt),
2416 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt)]>,
2417 Sched<[WriteBrTbl]>;
2418 } // isNotDuplicable = 1, isIndirectBranch = 1
2424 def BLXi : AXI<(outs), (ins arm_blx_target:$target), BrMiscFrm, NoItinerary,
2425 "blx\t$target", []>,
2426 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2427 let Inst{31-25} = 0b1111101;
2429 let Inst{23-0} = target{24-1};
2430 let Inst{24} = target{0};
2434 // Branch and Exchange Jazelle
2435 def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func",
2436 [/* pattern left blank */]>, Sched<[WriteBr]> {
2438 let Inst{23-20} = 0b0010;
2439 let Inst{19-8} = 0xfff;
2440 let Inst{7-4} = 0b0010;
2441 let Inst{3-0} = func;
2447 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in {
2448 def TCRETURNdi : PseudoInst<(outs), (ins i32imm:$dst), IIC_Br, []>,
2451 def TCRETURNri : PseudoInst<(outs), (ins tcGPR:$dst), IIC_Br, []>,
2454 def TAILJMPd : ARMPseudoExpand<(outs), (ins arm_br_target:$dst),
2456 (Bcc arm_br_target:$dst, (ops 14, zero_reg))>,
2457 Requires<[IsARM]>, Sched<[WriteBr]>;
2459 def TAILJMPr : ARMPseudoExpand<(outs), (ins tcGPR:$dst),
2461 (BX GPR:$dst)>, Sched<[WriteBr]>,
2462 Requires<[IsARM, HasV4T]>;
2465 // Secure Monitor Call is a system instruction.
2466 def SMC : ABI<0b0001, (outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt",
2467 []>, Requires<[IsARM, HasTrustZone]> {
2469 let Inst{23-4} = 0b01100000000000000111;
2470 let Inst{3-0} = opt;
2472 def : MnemonicAlias<"smi", "smc">;
2474 // Supervisor Call (Software Interrupt)
2475 let isCall = 1, Uses = [SP] in {
2476 def SVC : ABI<0b1111, (outs), (ins imm24b:$svc), IIC_Br, "svc", "\t$svc", []>,
2479 let Inst{23-0} = svc;
2483 // Store Return State
2484 class SRSI<bit wb, string asm>
2485 : XI<(outs), (ins imm0_31:$mode), AddrModeNone, 4, IndexModeNone, BrFrm,
2486 NoItinerary, asm, "", []> {
2488 let Inst{31-28} = 0b1111;
2489 let Inst{27-25} = 0b100;
2493 let Inst{19-16} = 0b1101; // SP
2494 let Inst{15-5} = 0b00000101000;
2495 let Inst{4-0} = mode;
2498 def SRSDA : SRSI<0, "srsda\tsp, $mode"> {
2499 let Inst{24-23} = 0;
2501 def SRSDA_UPD : SRSI<1, "srsda\tsp!, $mode"> {
2502 let Inst{24-23} = 0;
2504 def SRSDB : SRSI<0, "srsdb\tsp, $mode"> {
2505 let Inst{24-23} = 0b10;
2507 def SRSDB_UPD : SRSI<1, "srsdb\tsp!, $mode"> {
2508 let Inst{24-23} = 0b10;
2510 def SRSIA : SRSI<0, "srsia\tsp, $mode"> {
2511 let Inst{24-23} = 0b01;
2513 def SRSIA_UPD : SRSI<1, "srsia\tsp!, $mode"> {
2514 let Inst{24-23} = 0b01;
2516 def SRSIB : SRSI<0, "srsib\tsp, $mode"> {
2517 let Inst{24-23} = 0b11;
2519 def SRSIB_UPD : SRSI<1, "srsib\tsp!, $mode"> {
2520 let Inst{24-23} = 0b11;
2523 def : ARMInstAlias<"srsda $mode", (SRSDA imm0_31:$mode)>;
2524 def : ARMInstAlias<"srsda $mode!", (SRSDA_UPD imm0_31:$mode)>;
2526 def : ARMInstAlias<"srsdb $mode", (SRSDB imm0_31:$mode)>;
2527 def : ARMInstAlias<"srsdb $mode!", (SRSDB_UPD imm0_31:$mode)>;
2529 def : ARMInstAlias<"srsia $mode", (SRSIA imm0_31:$mode)>;
2530 def : ARMInstAlias<"srsia $mode!", (SRSIA_UPD imm0_31:$mode)>;
2532 def : ARMInstAlias<"srsib $mode", (SRSIB imm0_31:$mode)>;
2533 def : ARMInstAlias<"srsib $mode!", (SRSIB_UPD imm0_31:$mode)>;
2535 // Return From Exception
2536 class RFEI<bit wb, string asm>
2537 : XI<(outs), (ins GPR:$Rn), AddrModeNone, 4, IndexModeNone, BrFrm,
2538 NoItinerary, asm, "", []> {
2540 let Inst{31-28} = 0b1111;
2541 let Inst{27-25} = 0b100;
2545 let Inst{19-16} = Rn;
2546 let Inst{15-0} = 0xa00;
2549 def RFEDA : RFEI<0, "rfeda\t$Rn"> {
2550 let Inst{24-23} = 0;
2552 def RFEDA_UPD : RFEI<1, "rfeda\t$Rn!"> {
2553 let Inst{24-23} = 0;
2555 def RFEDB : RFEI<0, "rfedb\t$Rn"> {
2556 let Inst{24-23} = 0b10;
2558 def RFEDB_UPD : RFEI<1, "rfedb\t$Rn!"> {
2559 let Inst{24-23} = 0b10;
2561 def RFEIA : RFEI<0, "rfeia\t$Rn"> {
2562 let Inst{24-23} = 0b01;
2564 def RFEIA_UPD : RFEI<1, "rfeia\t$Rn!"> {
2565 let Inst{24-23} = 0b01;
2567 def RFEIB : RFEI<0, "rfeib\t$Rn"> {
2568 let Inst{24-23} = 0b11;
2570 def RFEIB_UPD : RFEI<1, "rfeib\t$Rn!"> {
2571 let Inst{24-23} = 0b11;
2574 // Hypervisor Call is a system instruction
2576 def HVC : AInoP< (outs), (ins imm0_65535:$imm), BrFrm, NoItinerary,
2577 "hvc", "\t$imm", []>,
2578 Requires<[IsARM, HasVirtualization]> {
2581 // Even though HVC isn't predicable, it's encoding includes a condition field.
2582 // The instruction is undefined if the condition field is 0xf otherwise it is
2583 // unpredictable if it isn't condition AL (0xe).
2584 let Inst{31-28} = 0b1110;
2585 let Unpredictable{31-28} = 0b1111;
2586 let Inst{27-24} = 0b0001;
2587 let Inst{23-20} = 0b0100;
2588 let Inst{19-8} = imm{15-4};
2589 let Inst{7-4} = 0b0111;
2590 let Inst{3-0} = imm{3-0};
2594 // Return from exception in Hypervisor mode.
2595 let isReturn = 1, isBarrier = 1, isTerminator = 1, Defs = [PC] in
2596 def ERET : ABI<0b0001, (outs), (ins), NoItinerary, "eret", "", []>,
2597 Requires<[IsARM, HasVirtualization]> {
2598 let Inst{23-0} = 0b011000000000000001101110;
2601 //===----------------------------------------------------------------------===//
2602 // Load / Store Instructions.
2608 defm LDR : AI_ldr1<0, "ldr", IIC_iLoad_r, IIC_iLoad_si, load>;
2609 defm LDRB : AI_ldr1nopc<1, "ldrb", IIC_iLoad_bh_r, IIC_iLoad_bh_si,
2611 defm STR : AI_str1<0, "str", IIC_iStore_r, IIC_iStore_si, store>;
2612 defm STRB : AI_str1nopc<1, "strb", IIC_iStore_bh_r, IIC_iStore_bh_si,
2615 // Special LDR for loads from non-pc-relative constpools.
2616 let canFoldAsLoad = 1, mayLoad = 1, hasSideEffects = 0,
2617 isReMaterializable = 1, isCodeGenOnly = 1 in
2618 def LDRcp : AI2ldst<0b010, 1, 0, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
2619 AddrMode_i12, LdFrm, IIC_iLoad_r, "ldr", "\t$Rt, $addr",
2623 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2624 let Inst{19-16} = 0b1111;
2625 let Inst{15-12} = Rt;
2626 let Inst{11-0} = addr{11-0}; // imm12
2629 // Loads with zero extension
2630 def LDRH : AI3ld<0b1011, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2631 IIC_iLoad_bh_r, "ldrh", "\t$Rt, $addr",
2632 [(set GPR:$Rt, (zextloadi16 addrmode3:$addr))]>;
2634 // Loads with sign extension
2635 def LDRSH : AI3ld<0b1111, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2636 IIC_iLoad_bh_r, "ldrsh", "\t$Rt, $addr",
2637 [(set GPR:$Rt, (sextloadi16 addrmode3:$addr))]>;
2639 def LDRSB : AI3ld<0b1101, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2640 IIC_iLoad_bh_r, "ldrsb", "\t$Rt, $addr",
2641 [(set GPR:$Rt, (sextloadi8 addrmode3:$addr))]>;
2643 let mayLoad = 1, hasSideEffects = 0, hasExtraDefRegAllocReq = 1 in {
2645 def LDRD : AI3ld<0b1101, 0, (outs GPR:$Rt, GPR:$Rt2), (ins addrmode3:$addr),
2646 LdMiscFrm, IIC_iLoad_d_r, "ldrd", "\t$Rt, $Rt2, $addr", []>,
2647 Requires<[IsARM, HasV5TE]>;
2650 def LDA : AIldracq<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2651 NoItinerary, "lda", "\t$Rt, $addr", []>;
2652 def LDAB : AIldracq<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2653 NoItinerary, "ldab", "\t$Rt, $addr", []>;
2654 def LDAH : AIldracq<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2655 NoItinerary, "ldah", "\t$Rt, $addr", []>;
2658 multiclass AI2_ldridx<bit isByte, string opc,
2659 InstrItinClass iii, InstrItinClass iir> {
2660 def _PRE_IMM : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2661 (ins addrmode_imm12_pre:$addr), IndexModePre, LdFrm, iii,
2662 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2665 let Inst{23} = addr{12};
2666 let Inst{19-16} = addr{16-13};
2667 let Inst{11-0} = addr{11-0};
2668 let DecoderMethod = "DecodeLDRPreImm";
2671 def _PRE_REG : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2672 (ins ldst_so_reg:$addr), IndexModePre, LdFrm, iir,
2673 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2676 let Inst{23} = addr{12};
2677 let Inst{19-16} = addr{16-13};
2678 let Inst{11-0} = addr{11-0};
2680 let DecoderMethod = "DecodeLDRPreReg";
2683 def _POST_REG : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2684 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2685 IndexModePost, LdFrm, iir,
2686 opc, "\t$Rt, $addr, $offset",
2687 "$addr.base = $Rn_wb", []> {
2693 let Inst{23} = offset{12};
2694 let Inst{19-16} = addr;
2695 let Inst{11-0} = offset{11-0};
2698 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2701 def _POST_IMM : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2702 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2703 IndexModePost, LdFrm, iii,
2704 opc, "\t$Rt, $addr, $offset",
2705 "$addr.base = $Rn_wb", []> {
2711 let Inst{23} = offset{12};
2712 let Inst{19-16} = addr;
2713 let Inst{11-0} = offset{11-0};
2715 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2720 let mayLoad = 1, hasSideEffects = 0 in {
2721 // FIXME: for LDR_PRE_REG etc. the itineray should be either IIC_iLoad_ru or
2722 // IIC_iLoad_siu depending on whether it the offset register is shifted.
2723 defm LDR : AI2_ldridx<0, "ldr", IIC_iLoad_iu, IIC_iLoad_ru>;
2724 defm LDRB : AI2_ldridx<1, "ldrb", IIC_iLoad_bh_iu, IIC_iLoad_bh_ru>;
2727 multiclass AI3_ldridx<bits<4> op, string opc, InstrItinClass itin> {
2728 def _PRE : AI3ldstidx<op, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2729 (ins addrmode3_pre:$addr), IndexModePre,
2731 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2733 let Inst{23} = addr{8}; // U bit
2734 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2735 let Inst{19-16} = addr{12-9}; // Rn
2736 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2737 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2738 let DecoderMethod = "DecodeAddrMode3Instruction";
2740 def _POST : AI3ldstidx<op, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2741 (ins addr_offset_none:$addr, am3offset:$offset),
2742 IndexModePost, LdMiscFrm, itin,
2743 opc, "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2747 let Inst{23} = offset{8}; // U bit
2748 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2749 let Inst{19-16} = addr;
2750 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2751 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2752 let DecoderMethod = "DecodeAddrMode3Instruction";
2756 let mayLoad = 1, hasSideEffects = 0 in {
2757 defm LDRH : AI3_ldridx<0b1011, "ldrh", IIC_iLoad_bh_ru>;
2758 defm LDRSH : AI3_ldridx<0b1111, "ldrsh", IIC_iLoad_bh_ru>;
2759 defm LDRSB : AI3_ldridx<0b1101, "ldrsb", IIC_iLoad_bh_ru>;
2760 let hasExtraDefRegAllocReq = 1 in {
2761 def LDRD_PRE : AI3ldstidx<0b1101, 0, 1, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2762 (ins addrmode3_pre:$addr), IndexModePre,
2763 LdMiscFrm, IIC_iLoad_d_ru,
2764 "ldrd", "\t$Rt, $Rt2, $addr!",
2765 "$addr.base = $Rn_wb", []> {
2767 let Inst{23} = addr{8}; // U bit
2768 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2769 let Inst{19-16} = addr{12-9}; // Rn
2770 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2771 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2772 let DecoderMethod = "DecodeAddrMode3Instruction";
2774 def LDRD_POST: AI3ldstidx<0b1101, 0, 0, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2775 (ins addr_offset_none:$addr, am3offset:$offset),
2776 IndexModePost, LdMiscFrm, IIC_iLoad_d_ru,
2777 "ldrd", "\t$Rt, $Rt2, $addr, $offset",
2778 "$addr.base = $Rn_wb", []> {
2781 let Inst{23} = offset{8}; // U bit
2782 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2783 let Inst{19-16} = addr;
2784 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2785 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2786 let DecoderMethod = "DecodeAddrMode3Instruction";
2788 } // hasExtraDefRegAllocReq = 1
2789 } // mayLoad = 1, hasSideEffects = 0
2791 // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT.
2792 let mayLoad = 1, hasSideEffects = 0 in {
2793 def LDRT_POST_REG : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2794 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2795 IndexModePost, LdFrm, IIC_iLoad_ru,
2796 "ldrt", "\t$Rt, $addr, $offset",
2797 "$addr.base = $Rn_wb", []> {
2803 let Inst{23} = offset{12};
2804 let Inst{21} = 1; // overwrite
2805 let Inst{19-16} = addr;
2806 let Inst{11-5} = offset{11-5};
2808 let Inst{3-0} = offset{3-0};
2809 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2813 : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2814 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2815 IndexModePost, LdFrm, IIC_iLoad_ru,
2816 "ldrt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2822 let Inst{23} = offset{12};
2823 let Inst{21} = 1; // overwrite
2824 let Inst{19-16} = addr;
2825 let Inst{11-0} = offset{11-0};
2826 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2829 def LDRBT_POST_REG : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2830 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2831 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2832 "ldrbt", "\t$Rt, $addr, $offset",
2833 "$addr.base = $Rn_wb", []> {
2839 let Inst{23} = offset{12};
2840 let Inst{21} = 1; // overwrite
2841 let Inst{19-16} = addr;
2842 let Inst{11-5} = offset{11-5};
2844 let Inst{3-0} = offset{3-0};
2845 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2849 : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2850 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2851 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2852 "ldrbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2858 let Inst{23} = offset{12};
2859 let Inst{21} = 1; // overwrite
2860 let Inst{19-16} = addr;
2861 let Inst{11-0} = offset{11-0};
2862 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2865 multiclass AI3ldrT<bits<4> op, string opc> {
2866 def i : AI3ldstidxT<op, 1, (outs GPR:$Rt, GPR:$base_wb),
2867 (ins addr_offset_none:$addr, postidx_imm8:$offset),
2868 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2869 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2871 let Inst{23} = offset{8};
2873 let Inst{11-8} = offset{7-4};
2874 let Inst{3-0} = offset{3-0};
2876 def r : AI3ldstidxT<op, 1, (outs GPRnopc:$Rt, GPRnopc:$base_wb),
2877 (ins addr_offset_none:$addr, postidx_reg:$Rm),
2878 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2879 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2881 let Inst{23} = Rm{4};
2884 let Unpredictable{11-8} = 0b1111;
2885 let Inst{3-0} = Rm{3-0};
2886 let DecoderMethod = "DecodeLDR";
2890 defm LDRSBT : AI3ldrT<0b1101, "ldrsbt">;
2891 defm LDRHT : AI3ldrT<0b1011, "ldrht">;
2892 defm LDRSHT : AI3ldrT<0b1111, "ldrsht">;
2896 : ARMAsmPseudo<"ldrt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q),
2900 : ARMAsmPseudo<"ldrbt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q),
2903 // Pseudo instruction ldr Rt, =immediate
2905 : ARMAsmPseudo<"ldr${q} $Rt, $immediate",
2906 (ins const_pool_asm_imm:$immediate, pred:$q),
2911 // Stores with truncate
2912 def STRH : AI3str<0b1011, (outs), (ins GPR:$Rt, addrmode3:$addr), StMiscFrm,
2913 IIC_iStore_bh_r, "strh", "\t$Rt, $addr",
2914 [(truncstorei16 GPR:$Rt, addrmode3:$addr)]>;
2917 let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
2918 def STRD : AI3str<0b1111, (outs), (ins GPR:$Rt, GPR:$Rt2, addrmode3:$addr),
2919 StMiscFrm, IIC_iStore_d_r, "strd", "\t$Rt, $Rt2, $addr", []>,
2920 Requires<[IsARM, HasV5TE]> {
2926 multiclass AI2_stridx<bit isByte, string opc,
2927 InstrItinClass iii, InstrItinClass iir> {
2928 def _PRE_IMM : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2929 (ins GPR:$Rt, addrmode_imm12_pre:$addr), IndexModePre,
2931 opc, "\t$Rt, $addr!",
2932 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2935 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2936 let Inst{19-16} = addr{16-13}; // Rn
2937 let Inst{11-0} = addr{11-0}; // imm12
2938 let DecoderMethod = "DecodeSTRPreImm";
2941 def _PRE_REG : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2942 (ins GPR:$Rt, ldst_so_reg:$addr),
2943 IndexModePre, StFrm, iir,
2944 opc, "\t$Rt, $addr!",
2945 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2948 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2949 let Inst{19-16} = addr{16-13}; // Rn
2950 let Inst{11-0} = addr{11-0};
2951 let Inst{4} = 0; // Inst{4} = 0
2952 let DecoderMethod = "DecodeSTRPreReg";
2954 def _POST_REG : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2955 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2956 IndexModePost, StFrm, iir,
2957 opc, "\t$Rt, $addr, $offset",
2958 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2964 let Inst{23} = offset{12};
2965 let Inst{19-16} = addr;
2966 let Inst{11-0} = offset{11-0};
2969 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2972 def _POST_IMM : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2973 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2974 IndexModePost, StFrm, iii,
2975 opc, "\t$Rt, $addr, $offset",
2976 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2982 let Inst{23} = offset{12};
2983 let Inst{19-16} = addr;
2984 let Inst{11-0} = offset{11-0};
2986 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2990 let mayStore = 1, hasSideEffects = 0 in {
2991 // FIXME: for STR_PRE_REG etc. the itineray should be either IIC_iStore_ru or
2992 // IIC_iStore_siu depending on whether it the offset register is shifted.
2993 defm STR : AI2_stridx<0, "str", IIC_iStore_iu, IIC_iStore_ru>;
2994 defm STRB : AI2_stridx<1, "strb", IIC_iStore_bh_iu, IIC_iStore_bh_ru>;
2997 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
2998 am2offset_reg:$offset),
2999 (STR_POST_REG GPR:$Rt, addr_offset_none:$addr,
3000 am2offset_reg:$offset)>;
3001 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
3002 am2offset_imm:$offset),
3003 (STR_POST_IMM GPR:$Rt, addr_offset_none:$addr,
3004 am2offset_imm:$offset)>;
3005 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
3006 am2offset_reg:$offset),
3007 (STRB_POST_REG GPR:$Rt, addr_offset_none:$addr,
3008 am2offset_reg:$offset)>;
3009 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
3010 am2offset_imm:$offset),
3011 (STRB_POST_IMM GPR:$Rt, addr_offset_none:$addr,
3012 am2offset_imm:$offset)>;
3014 // Pseudo-instructions for pattern matching the pre-indexed stores. We can't
3015 // put the patterns on the instruction definitions directly as ISel wants
3016 // the address base and offset to be separate operands, not a single
3017 // complex operand like we represent the instructions themselves. The
3018 // pseudos map between the two.
3019 let usesCustomInserter = 1,
3020 Constraints = "$Rn = $Rn_wb,@earlyclobber $Rn_wb" in {
3021 def STRi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3022 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
3025 (pre_store GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
3026 def STRr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3027 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
3030 (pre_store GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
3031 def STRBi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3032 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
3035 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
3036 def STRBr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3037 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
3040 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
3041 def STRH_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3042 (ins GPR:$Rt, GPR:$Rn, am3offset:$offset, pred:$p),
3045 (pre_truncsti16 GPR:$Rt, GPR:$Rn, am3offset:$offset))]>;
3050 def STRH_PRE : AI3ldstidx<0b1011, 0, 1, (outs GPR:$Rn_wb),
3051 (ins GPR:$Rt, addrmode3_pre:$addr), IndexModePre,
3052 StMiscFrm, IIC_iStore_bh_ru,
3053 "strh", "\t$Rt, $addr!",
3054 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
3056 let Inst{23} = addr{8}; // U bit
3057 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
3058 let Inst{19-16} = addr{12-9}; // Rn
3059 let Inst{11-8} = addr{7-4}; // imm7_4/zero
3060 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
3061 let DecoderMethod = "DecodeAddrMode3Instruction";
3064 def STRH_POST : AI3ldstidx<0b1011, 0, 0, (outs GPR:$Rn_wb),
3065 (ins GPR:$Rt, addr_offset_none:$addr, am3offset:$offset),
3066 IndexModePost, StMiscFrm, IIC_iStore_bh_ru,
3067 "strh", "\t$Rt, $addr, $offset",
3068 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb",
3069 [(set GPR:$Rn_wb, (post_truncsti16 GPR:$Rt,
3070 addr_offset_none:$addr,
3071 am3offset:$offset))]> {
3074 let Inst{23} = offset{8}; // U bit
3075 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
3076 let Inst{19-16} = addr;
3077 let Inst{11-8} = offset{7-4}; // imm7_4/zero
3078 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
3079 let DecoderMethod = "DecodeAddrMode3Instruction";
3082 let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
3083 def STRD_PRE : AI3ldstidx<0b1111, 0, 1, (outs GPR:$Rn_wb),
3084 (ins GPR:$Rt, GPR:$Rt2, addrmode3_pre:$addr),
3085 IndexModePre, StMiscFrm, IIC_iStore_d_ru,
3086 "strd", "\t$Rt, $Rt2, $addr!",
3087 "$addr.base = $Rn_wb", []> {
3089 let Inst{23} = addr{8}; // U bit
3090 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
3091 let Inst{19-16} = addr{12-9}; // Rn
3092 let Inst{11-8} = addr{7-4}; // imm7_4/zero
3093 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
3094 let DecoderMethod = "DecodeAddrMode3Instruction";
3097 def STRD_POST: AI3ldstidx<0b1111, 0, 0, (outs GPR:$Rn_wb),
3098 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr,
3100 IndexModePost, StMiscFrm, IIC_iStore_d_ru,
3101 "strd", "\t$Rt, $Rt2, $addr, $offset",
3102 "$addr.base = $Rn_wb", []> {
3105 let Inst{23} = offset{8}; // U bit
3106 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
3107 let Inst{19-16} = addr;
3108 let Inst{11-8} = offset{7-4}; // imm7_4/zero
3109 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
3110 let DecoderMethod = "DecodeAddrMode3Instruction";
3112 } // mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1
3114 // STRT, STRBT, and STRHT
3116 def STRBT_POST_REG : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
3117 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
3118 IndexModePost, StFrm, IIC_iStore_bh_ru,
3119 "strbt", "\t$Rt, $addr, $offset",
3120 "$addr.base = $Rn_wb", []> {
3126 let Inst{23} = offset{12};
3127 let Inst{21} = 1; // overwrite
3128 let Inst{19-16} = addr;
3129 let Inst{11-5} = offset{11-5};
3131 let Inst{3-0} = offset{3-0};
3132 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3136 : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
3137 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
3138 IndexModePost, StFrm, IIC_iStore_bh_ru,
3139 "strbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
3145 let Inst{23} = offset{12};
3146 let Inst{21} = 1; // overwrite
3147 let Inst{19-16} = addr;
3148 let Inst{11-0} = offset{11-0};
3149 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3153 : ARMAsmPseudo<"strbt${q} $Rt, $addr",
3154 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>;
3156 let mayStore = 1, hasSideEffects = 0 in {
3157 def STRT_POST_REG : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
3158 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
3159 IndexModePost, StFrm, IIC_iStore_ru,
3160 "strt", "\t$Rt, $addr, $offset",
3161 "$addr.base = $Rn_wb", []> {
3167 let Inst{23} = offset{12};
3168 let Inst{21} = 1; // overwrite
3169 let Inst{19-16} = addr;
3170 let Inst{11-5} = offset{11-5};
3172 let Inst{3-0} = offset{3-0};
3173 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3177 : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
3178 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
3179 IndexModePost, StFrm, IIC_iStore_ru,
3180 "strt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
3186 let Inst{23} = offset{12};
3187 let Inst{21} = 1; // overwrite
3188 let Inst{19-16} = addr;
3189 let Inst{11-0} = offset{11-0};
3190 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3195 : ARMAsmPseudo<"strt${q} $Rt, $addr",
3196 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>;
3198 multiclass AI3strT<bits<4> op, string opc> {
3199 def i : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
3200 (ins GPR:$Rt, addr_offset_none:$addr, postidx_imm8:$offset),
3201 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
3202 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
3204 let Inst{23} = offset{8};
3206 let Inst{11-8} = offset{7-4};
3207 let Inst{3-0} = offset{3-0};
3209 def r : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
3210 (ins GPR:$Rt, addr_offset_none:$addr, postidx_reg:$Rm),
3211 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
3212 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
3214 let Inst{23} = Rm{4};
3217 let Inst{3-0} = Rm{3-0};
3222 defm STRHT : AI3strT<0b1011, "strht">;
3224 def STL : AIstrrel<0b00, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3225 NoItinerary, "stl", "\t$Rt, $addr", []>;
3226 def STLB : AIstrrel<0b10, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3227 NoItinerary, "stlb", "\t$Rt, $addr", []>;
3228 def STLH : AIstrrel<0b11, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3229 NoItinerary, "stlh", "\t$Rt, $addr", []>;
3231 //===----------------------------------------------------------------------===//
3232 // Load / store multiple Instructions.
3235 multiclass arm_ldst_mult<string asm, string sfx, bit L_bit, bit P_bit, Format f,
3236 InstrItinClass itin, InstrItinClass itin_upd> {
3237 // IA is the default, so no need for an explicit suffix on the
3238 // mnemonic here. Without it is the canonical spelling.
3240 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3241 IndexModeNone, f, itin,
3242 !strconcat(asm, "${p}\t$Rn, $regs", sfx), "", []> {
3243 let Inst{24-23} = 0b01; // Increment After
3244 let Inst{22} = P_bit;
3245 let Inst{21} = 0; // No writeback
3246 let Inst{20} = L_bit;
3249 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3250 IndexModeUpd, f, itin_upd,
3251 !strconcat(asm, "${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3252 let Inst{24-23} = 0b01; // Increment After
3253 let Inst{22} = P_bit;
3254 let Inst{21} = 1; // Writeback
3255 let Inst{20} = L_bit;
3257 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3260 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3261 IndexModeNone, f, itin,
3262 !strconcat(asm, "da${p}\t$Rn, $regs", sfx), "", []> {
3263 let Inst{24-23} = 0b00; // Decrement After
3264 let Inst{22} = P_bit;
3265 let Inst{21} = 0; // No writeback
3266 let Inst{20} = L_bit;
3269 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3270 IndexModeUpd, f, itin_upd,
3271 !strconcat(asm, "da${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3272 let Inst{24-23} = 0b00; // Decrement After
3273 let Inst{22} = P_bit;
3274 let Inst{21} = 1; // Writeback
3275 let Inst{20} = L_bit;
3277 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3280 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3281 IndexModeNone, f, itin,
3282 !strconcat(asm, "db${p}\t$Rn, $regs", sfx), "", []> {
3283 let Inst{24-23} = 0b10; // Decrement Before
3284 let Inst{22} = P_bit;
3285 let Inst{21} = 0; // No writeback
3286 let Inst{20} = L_bit;
3289 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3290 IndexModeUpd, f, itin_upd,
3291 !strconcat(asm, "db${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3292 let Inst{24-23} = 0b10; // Decrement Before
3293 let Inst{22} = P_bit;
3294 let Inst{21} = 1; // Writeback
3295 let Inst{20} = L_bit;
3297 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3300 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3301 IndexModeNone, f, itin,
3302 !strconcat(asm, "ib${p}\t$Rn, $regs", sfx), "", []> {
3303 let Inst{24-23} = 0b11; // Increment Before
3304 let Inst{22} = P_bit;
3305 let Inst{21} = 0; // No writeback
3306 let Inst{20} = L_bit;
3309 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3310 IndexModeUpd, f, itin_upd,
3311 !strconcat(asm, "ib${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3312 let Inst{24-23} = 0b11; // Increment Before
3313 let Inst{22} = P_bit;
3314 let Inst{21} = 1; // Writeback
3315 let Inst{20} = L_bit;
3317 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3321 let hasSideEffects = 0 in {
3323 let mayLoad = 1, hasExtraDefRegAllocReq = 1, variadicOpsAreDefs = 1 in
3324 defm LDM : arm_ldst_mult<"ldm", "", 1, 0, LdStMulFrm, IIC_iLoad_m,
3325 IIC_iLoad_mu>, ComplexDeprecationPredicate<"ARMLoad">;
3327 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
3328 defm STM : arm_ldst_mult<"stm", "", 0, 0, LdStMulFrm, IIC_iStore_m,
3330 ComplexDeprecationPredicate<"ARMStore">;
3334 // FIXME: remove when we have a way to marking a MI with these properties.
3335 // FIXME: Should pc be an implicit operand like PICADD, etc?
3336 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
3337 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
3338 def LDMIA_RET : ARMPseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p,
3339 reglist:$regs, variable_ops),
3340 4, IIC_iLoad_mBr, [],
3341 (LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>,
3342 RegConstraint<"$Rn = $wb">;
3344 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
3345 defm sysLDM : arm_ldst_mult<"ldm", " ^", 1, 1, LdStMulFrm, IIC_iLoad_m,
3348 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
3349 defm sysSTM : arm_ldst_mult<"stm", " ^", 0, 1, LdStMulFrm, IIC_iStore_m,
3354 //===----------------------------------------------------------------------===//
3355 // Move Instructions.
3358 let hasSideEffects = 0, isMoveReg = 1 in
3359 def MOVr : AsI1<0b1101, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMOVr,
3360 "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> {
3364 let Inst{19-16} = 0b0000;
3365 let Inst{11-4} = 0b00000000;
3368 let Inst{15-12} = Rd;
3371 // A version for the smaller set of tail call registers.
3372 let hasSideEffects = 0 in
3373 def MOVr_TC : AsI1<0b1101, (outs tcGPR:$Rd), (ins tcGPR:$Rm), DPFrm,
3374 IIC_iMOVr, "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> {
3378 let Inst{11-4} = 0b00000000;
3381 let Inst{15-12} = Rd;
3384 def MOVsr : AsI1<0b1101, (outs GPRnopc:$Rd), (ins shift_so_reg_reg:$src),
3385 DPSoRegRegFrm, IIC_iMOVsr,
3386 "mov", "\t$Rd, $src",
3387 [(set GPRnopc:$Rd, shift_so_reg_reg:$src)]>, UnaryDP,
3391 let Inst{15-12} = Rd;
3392 let Inst{19-16} = 0b0000;
3393 let Inst{11-8} = src{11-8};
3395 let Inst{6-5} = src{6-5};
3397 let Inst{3-0} = src{3-0};
3401 def MOVsi : AsI1<0b1101, (outs GPR:$Rd), (ins shift_so_reg_imm:$src),
3402 DPSoRegImmFrm, IIC_iMOVsr,
3403 "mov", "\t$Rd, $src", [(set GPR:$Rd, shift_so_reg_imm:$src)]>,
3404 UnaryDP, Sched<[WriteALU]> {
3407 let Inst{15-12} = Rd;
3408 let Inst{19-16} = 0b0000;
3409 let Inst{11-5} = src{11-5};
3411 let Inst{3-0} = src{3-0};
3415 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3416 def MOVi : AsI1<0b1101, (outs GPR:$Rd), (ins mod_imm:$imm), DPFrm, IIC_iMOVi,
3417 "mov", "\t$Rd, $imm", [(set GPR:$Rd, mod_imm:$imm)]>, UnaryDP,
3422 let Inst{15-12} = Rd;
3423 let Inst{19-16} = 0b0000;
3424 let Inst{11-0} = imm;
3427 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3428 def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins imm0_65535_expr:$imm),
3430 "movw", "\t$Rd, $imm",
3431 [(set GPR:$Rd, imm0_65535:$imm)]>,
3432 Requires<[IsARM, HasV6T2]>, UnaryDP, Sched<[WriteALU]> {
3435 let Inst{15-12} = Rd;
3436 let Inst{11-0} = imm{11-0};
3437 let Inst{19-16} = imm{15-12};
3440 let DecoderMethod = "DecodeArmMOVTWInstruction";
3443 def : InstAlias<"mov${p} $Rd, $imm",
3444 (MOVi16 GPR:$Rd, imm0_65535_expr:$imm, pred:$p), 0>,
3445 Requires<[IsARM, HasV6T2]>;
3447 def MOVi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
3448 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
3451 let Constraints = "$src = $Rd" in {
3452 def MOVTi16 : AI1<0b1010, (outs GPRnopc:$Rd),
3453 (ins GPR:$src, imm0_65535_expr:$imm),
3455 "movt", "\t$Rd, $imm",
3457 (or (and GPR:$src, 0xffff),
3458 lo16AllZero:$imm))]>, UnaryDP,
3459 Requires<[IsARM, HasV6T2]>, Sched<[WriteALU]> {
3462 let Inst{15-12} = Rd;
3463 let Inst{11-0} = imm{11-0};
3464 let Inst{19-16} = imm{15-12};
3467 let DecoderMethod = "DecodeArmMOVTWInstruction";
3470 def MOVTi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
3471 (ins GPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
3476 def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
3477 Requires<[IsARM, HasV6T2]>;
3479 let Uses = [CPSR] in
3480 def RRX: PseudoInst<(outs GPR:$Rd), (ins GPR:$Rm), IIC_iMOVsi,
3481 [(set GPR:$Rd, (ARMrrx GPR:$Rm))]>, UnaryDP,
3482 Requires<[IsARM]>, Sched<[WriteALU]>;
3484 // These aren't really mov instructions, but we have to define them this way
3485 // due to flag operands.
3487 let Defs = [CPSR] in {
3488 def MOVsrl_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3489 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP,
3490 Sched<[WriteALU]>, Requires<[IsARM]>;
3491 def MOVsra_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3492 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP,
3493 Sched<[WriteALU]>, Requires<[IsARM]>;
3496 //===----------------------------------------------------------------------===//
3497 // Extend Instructions.
3502 def SXTB : AI_ext_rrot<0b01101010,
3503 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
3504 def SXTH : AI_ext_rrot<0b01101011,
3505 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
3507 def SXTAB : AI_exta_rrot<0b01101010,
3508 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
3509 def SXTAH : AI_exta_rrot<0b01101011,
3510 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
3512 def : ARMV6Pat<(add rGPR:$Rn, (sext_inreg (srl rGPR:$Rm, rot_imm:$rot), i8)),
3513 (SXTAB rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
3514 def : ARMV6Pat<(add rGPR:$Rn, (sext_inreg (srl rGPR:$Rm, imm8_or_16:$rot),
3516 (SXTAH rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
3518 def SXTB16 : AI_ext_rrot_np<0b01101000, "sxtb16">;
3519 def : ARMV6Pat<(int_arm_sxtb16 GPR:$Src),
3520 (SXTB16 GPR:$Src, 0)>;
3521 def : ARMV6Pat<(int_arm_sxtb16 (rotr GPR:$Src, rot_imm:$rot)),
3522 (SXTB16 GPR:$Src, rot_imm:$rot)>;
3524 def SXTAB16 : AI_exta_rrot_np<0b01101000, "sxtab16">;
3525 def : ARMV6Pat<(int_arm_sxtab16 GPR:$LHS, GPR:$RHS),
3526 (SXTAB16 GPR:$LHS, GPR:$RHS, 0)>;
3527 def : ARMV6Pat<(int_arm_sxtab16 GPR:$LHS, (rotr GPR:$RHS, rot_imm:$rot)),
3528 (SXTAB16 GPR:$LHS, GPR:$RHS, rot_imm:$rot)>;
3532 let AddedComplexity = 16 in {
3533 def UXTB : AI_ext_rrot<0b01101110,
3534 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
3535 def UXTH : AI_ext_rrot<0b01101111,
3536 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
3537 def UXTB16 : AI_ext_rrot<0b01101100,
3538 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
3540 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
3541 // The transformation should probably be done as a combiner action
3542 // instead so we can include a check for masking back in the upper
3543 // eight bits of the source into the lower eight bits of the result.
3544 //def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
3545 // (UXTB16r_rot GPR:$Src, 3)>;
3546 def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
3547 (UXTB16 GPR:$Src, 1)>;
3548 def : ARMV6Pat<(int_arm_uxtb16 GPR:$Src),
3549 (UXTB16 GPR:$Src, 0)>;
3550 def : ARMV6Pat<(int_arm_uxtb16 (rotr GPR:$Src, rot_imm:$rot)),
3551 (UXTB16 GPR:$Src, rot_imm:$rot)>;
3553 def UXTAB : AI_exta_rrot<0b01101110, "uxtab",
3554 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
3555 def UXTAH : AI_exta_rrot<0b01101111, "uxtah",
3556 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
3558 def : ARMV6Pat<(add rGPR:$Rn, (and (srl rGPR:$Rm, rot_imm:$rot), 0xFF)),
3559 (UXTAB rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
3560 def : ARMV6Pat<(add rGPR:$Rn, (and (srl rGPR:$Rm, imm8_or_16:$rot), 0xFFFF)),
3561 (UXTAH rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
3564 // This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
3565 def UXTAB16 : AI_exta_rrot_np<0b01101100, "uxtab16">;
3566 def : ARMV6Pat<(int_arm_uxtab16 GPR:$LHS, GPR:$RHS),
3567 (UXTAB16 GPR:$LHS, GPR:$RHS, 0)>;
3568 def : ARMV6Pat<(int_arm_uxtab16 GPR:$LHS, (rotr GPR:$RHS, rot_imm:$rot)),
3569 (UXTAB16 GPR:$LHS, GPR:$RHS, rot_imm:$rot)>;
3572 def SBFX : I<(outs GPRnopc:$Rd),
3573 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3574 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3575 "sbfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3576 Requires<[IsARM, HasV6T2]> {
3581 let Inst{27-21} = 0b0111101;
3582 let Inst{6-4} = 0b101;
3583 let Inst{20-16} = width;
3584 let Inst{15-12} = Rd;
3585 let Inst{11-7} = lsb;
3589 def UBFX : I<(outs GPRnopc:$Rd),
3590 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3591 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3592 "ubfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3593 Requires<[IsARM, HasV6T2]> {
3598 let Inst{27-21} = 0b0111111;
3599 let Inst{6-4} = 0b101;
3600 let Inst{20-16} = width;
3601 let Inst{15-12} = Rd;
3602 let Inst{11-7} = lsb;
3606 //===----------------------------------------------------------------------===//
3607 // Arithmetic Instructions.
3611 defm ADD : AsI1_bin_irs<0b0100, "add",
3612 IIC_iALUi, IIC_iALUr, IIC_iALUsr, add, 1>;
3613 defm SUB : AsI1_bin_irs<0b0010, "sub",
3614 IIC_iALUi, IIC_iALUr, IIC_iALUsr, sub>;
3616 // ADD and SUB with 's' bit set.
3618 // Currently, ADDS/SUBS are pseudo opcodes that exist only in the
3619 // selection DAG. They are "lowered" to real ADD/SUB opcodes by
3620 // AdjustInstrPostInstrSelection where we determine whether or not to
3621 // set the "s" bit based on CPSR liveness.
3623 // FIXME: Eliminate ADDS/SUBS pseudo opcodes after adding tablegen
3624 // support for an optional CPSR definition that corresponds to the DAG
3625 // node's second value. We can then eliminate the implicit def of CPSR.
3627 defm ADDS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr, ARMaddc, 1>;
3628 defm SUBS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr, ARMsubc>;
3630 def : ARMPat<(ARMsubs GPR:$Rn, mod_imm:$imm), (SUBSri $Rn, mod_imm:$imm)>;
3631 def : ARMPat<(ARMsubs GPR:$Rn, GPR:$Rm), (SUBSrr $Rn, $Rm)>;
3632 def : ARMPat<(ARMsubs GPR:$Rn, so_reg_imm:$shift),
3633 (SUBSrsi $Rn, so_reg_imm:$shift)>;
3634 def : ARMPat<(ARMsubs GPR:$Rn, so_reg_reg:$shift),
3635 (SUBSrsr $Rn, so_reg_reg:$shift)>;
3639 defm ADC : AI1_adde_sube_irs<0b0101, "adc", ARMadde, 1>;
3640 defm SBC : AI1_adde_sube_irs<0b0110, "sbc", ARMsube>;
3642 defm RSB : AsI1_rbin_irs<0b0011, "rsb",
3643 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3646 // FIXME: Eliminate them if we can write def : Pat patterns which defines
3647 // CPSR and the implicit def of CPSR is not needed.
3648 defm RSBS : AsI1_rbin_s_is<IIC_iALUi, IIC_iALUr, IIC_iALUsr, ARMsubc>;
3650 defm RSC : AI1_rsc_irs<0b0111, "rsc", ARMsube>;
3652 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
3653 // The assume-no-carry-in form uses the negation of the input since add/sub
3654 // assume opposite meanings of the carry flag (i.e., carry == !borrow).
3655 // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
3657 def : ARMPat<(add GPR:$src, mod_imm_neg:$imm),
3658 (SUBri GPR:$src, mod_imm_neg:$imm)>;
3659 def : ARMPat<(ARMaddc GPR:$src, mod_imm_neg:$imm),
3660 (SUBSri GPR:$src, mod_imm_neg:$imm)>;
3662 def : ARMPat<(add GPR:$src, imm0_65535_neg:$imm),
3663 (SUBrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>,
3664 Requires<[IsARM, HasV6T2]>;
3665 def : ARMPat<(ARMaddc GPR:$src, imm0_65535_neg:$imm),
3666 (SUBSrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>,
3667 Requires<[IsARM, HasV6T2]>;
3669 // The with-carry-in form matches bitwise not instead of the negation.
3670 // Effectively, the inverse interpretation of the carry flag already accounts
3671 // for part of the negation.
3672 def : ARMPat<(ARMadde GPR:$src, mod_imm_not:$imm, CPSR),
3673 (SBCri GPR:$src, mod_imm_not:$imm)>;
3674 def : ARMPat<(ARMadde GPR:$src, imm0_65535_neg:$imm, CPSR),
3675 (SBCrr GPR:$src, (MOVi16 (imm_not_XFORM imm:$imm)))>,
3676 Requires<[IsARM, HasV6T2]>;
3678 // Note: These are implemented in C++ code, because they have to generate
3679 // ADD/SUBrs instructions, which use a complex pattern that a xform function
3681 // (mul X, 2^n+1) -> (add (X << n), X)
3682 // (mul X, 2^n-1) -> (rsb X, (X << n))
3684 // ARM Arithmetic Instruction
3685 // GPR:$dst = GPR:$a op GPR:$b
3686 class AAI<bits<8> op27_20, bits<8> op11_4, string opc,
3687 list<dag> pattern = [],
3688 dag iops = (ins GPRnopc:$Rn, GPRnopc:$Rm),
3689 string asm = "\t$Rd, $Rn, $Rm">
3690 : AI<(outs GPRnopc:$Rd), iops, DPFrm, IIC_iALUr, opc, asm, pattern>,
3691 Sched<[WriteALU, ReadALU, ReadALU]> {
3695 let Inst{27-20} = op27_20;
3696 let Inst{11-4} = op11_4;
3697 let Inst{19-16} = Rn;
3698 let Inst{15-12} = Rd;
3701 let Unpredictable{11-8} = 0b1111;
3704 // Wrappers around the AAI class
3705 class AAIRevOpr<bits<8> op27_20, bits<8> op11_4, string opc,
3706 list<dag> pattern = []>
3707 : AAI<op27_20, op11_4, opc,
3709 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3712 class AAIIntrinsic<bits<8> op27_20, bits<8> op11_4, string opc,
3713 Intrinsic intrinsic>
3714 : AAI<op27_20, op11_4, opc,
3715 [(set GPRnopc:$Rd, (intrinsic GPRnopc:$Rn, GPRnopc:$Rm))]>;
3717 // Saturating add/subtract
3718 let hasSideEffects = 1 in {
3719 def QADD8 : AAIIntrinsic<0b01100010, 0b11111001, "qadd8", int_arm_qadd8>;
3720 def QADD16 : AAIIntrinsic<0b01100010, 0b11110001, "qadd16", int_arm_qadd16>;
3721 def QSUB16 : AAIIntrinsic<0b01100010, 0b11110111, "qsub16", int_arm_qsub16>;
3722 def QSUB8 : AAIIntrinsic<0b01100010, 0b11111111, "qsub8", int_arm_qsub8>;
3724 def QDADD : AAIRevOpr<0b00010100, 0b00000101, "qdadd",
3725 [(set GPRnopc:$Rd, (int_arm_qadd (int_arm_qadd GPRnopc:$Rm,
3728 def QDSUB : AAIRevOpr<0b00010110, 0b00000101, "qdsub",
3729 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm,
3730 (int_arm_qadd GPRnopc:$Rn, GPRnopc:$Rn)))]>;
3731 def QSUB : AAIRevOpr<0b00010010, 0b00000101, "qsub",
3732 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm, GPRnopc:$Rn))]>;
3733 let DecoderMethod = "DecodeQADDInstruction" in
3734 def QADD : AAIRevOpr<0b00010000, 0b00000101, "qadd",
3735 [(set GPRnopc:$Rd, (int_arm_qadd GPRnopc:$Rm, GPRnopc:$Rn))]>;
3738 def UQADD16 : AAIIntrinsic<0b01100110, 0b11110001, "uqadd16", int_arm_uqadd16>;
3739 def UQADD8 : AAIIntrinsic<0b01100110, 0b11111001, "uqadd8", int_arm_uqadd8>;
3740 def UQSUB16 : AAIIntrinsic<0b01100110, 0b11110111, "uqsub16", int_arm_uqsub16>;
3741 def UQSUB8 : AAIIntrinsic<0b01100110, 0b11111111, "uqsub8", int_arm_uqsub8>;
3742 def QASX : AAIIntrinsic<0b01100010, 0b11110011, "qasx", int_arm_qasx>;
3743 def QSAX : AAIIntrinsic<0b01100010, 0b11110101, "qsax", int_arm_qsax>;
3744 def UQASX : AAIIntrinsic<0b01100110, 0b11110011, "uqasx", int_arm_uqasx>;
3745 def UQSAX : AAIIntrinsic<0b01100110, 0b11110101, "uqsax", int_arm_uqsax>;
3747 // Signed/Unsigned add/subtract
3749 def SASX : AAIIntrinsic<0b01100001, 0b11110011, "sasx", int_arm_sasx>;
3750 def SADD16 : AAIIntrinsic<0b01100001, 0b11110001, "sadd16", int_arm_sadd16>;
3751 def SADD8 : AAIIntrinsic<0b01100001, 0b11111001, "sadd8", int_arm_sadd8>;
3752 def SSAX : AAIIntrinsic<0b01100001, 0b11110101, "ssax", int_arm_ssax>;
3753 def SSUB16 : AAIIntrinsic<0b01100001, 0b11110111, "ssub16", int_arm_ssub16>;
3754 def SSUB8 : AAIIntrinsic<0b01100001, 0b11111111, "ssub8", int_arm_ssub8>;
3755 def UASX : AAIIntrinsic<0b01100101, 0b11110011, "uasx", int_arm_uasx>;
3756 def UADD16 : AAIIntrinsic<0b01100101, 0b11110001, "uadd16", int_arm_uadd16>;
3757 def UADD8 : AAIIntrinsic<0b01100101, 0b11111001, "uadd8", int_arm_uadd8>;
3758 def USAX : AAIIntrinsic<0b01100101, 0b11110101, "usax", int_arm_usax>;
3759 def USUB16 : AAIIntrinsic<0b01100101, 0b11110111, "usub16", int_arm_usub16>;
3760 def USUB8 : AAIIntrinsic<0b01100101, 0b11111111, "usub8", int_arm_usub8>;
3762 // Signed/Unsigned halving add/subtract
3764 def SHASX : AAIIntrinsic<0b01100011, 0b11110011, "shasx", int_arm_shasx>;
3765 def SHADD16 : AAIIntrinsic<0b01100011, 0b11110001, "shadd16", int_arm_shadd16>;
3766 def SHADD8 : AAIIntrinsic<0b01100011, 0b11111001, "shadd8", int_arm_shadd8>;
3767 def SHSAX : AAIIntrinsic<0b01100011, 0b11110101, "shsax", int_arm_shsax>;
3768 def SHSUB16 : AAIIntrinsic<0b01100011, 0b11110111, "shsub16", int_arm_shsub16>;
3769 def SHSUB8 : AAIIntrinsic<0b01100011, 0b11111111, "shsub8", int_arm_shsub8>;
3770 def UHASX : AAIIntrinsic<0b01100111, 0b11110011, "uhasx", int_arm_uhasx>;
3771 def UHADD16 : AAIIntrinsic<0b01100111, 0b11110001, "uhadd16", int_arm_uhadd16>;
3772 def UHADD8 : AAIIntrinsic<0b01100111, 0b11111001, "uhadd8", int_arm_uhadd8>;
3773 def UHSAX : AAIIntrinsic<0b01100111, 0b11110101, "uhsax", int_arm_uhsax>;
3774 def UHSUB16 : AAIIntrinsic<0b01100111, 0b11110111, "uhsub16", int_arm_uhsub16>;
3775 def UHSUB8 : AAIIntrinsic<0b01100111, 0b11111111, "uhsub8", int_arm_uhsub8>;
3777 // Unsigned Sum of Absolute Differences [and Accumulate].
3779 def USAD8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3780 MulFrm /* for convenience */, NoItinerary, "usad8",
3782 [(set GPR:$Rd, (int_arm_usad8 GPR:$Rn, GPR:$Rm))]>,
3783 Requires<[IsARM, HasV6]>, Sched<[WriteALU, ReadALU, ReadALU]> {
3787 let Inst{27-20} = 0b01111000;
3788 let Inst{15-12} = 0b1111;
3789 let Inst{7-4} = 0b0001;
3790 let Inst{19-16} = Rd;
3791 let Inst{11-8} = Rm;
3794 def USADA8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3795 MulFrm /* for convenience */, NoItinerary, "usada8",
3796 "\t$Rd, $Rn, $Rm, $Ra",
3797 [(set GPR:$Rd, (int_arm_usada8 GPR:$Rn, GPR:$Rm, GPR:$Ra))]>,
3798 Requires<[IsARM, HasV6]>, Sched<[WriteALU, ReadALU, ReadALU]>{
3803 let Inst{27-20} = 0b01111000;
3804 let Inst{7-4} = 0b0001;
3805 let Inst{19-16} = Rd;
3806 let Inst{15-12} = Ra;
3807 let Inst{11-8} = Rm;
3811 // Signed/Unsigned saturate
3812 def SSAT : AI<(outs GPRnopc:$Rd),
3813 (ins imm1_32:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3814 SatFrm, NoItinerary, "ssat", "\t$Rd, $sat_imm, $Rn$sh", []>,
3815 Requires<[IsARM,HasV6]>{
3820 let Inst{27-21} = 0b0110101;
3821 let Inst{5-4} = 0b01;
3822 let Inst{20-16} = sat_imm;
3823 let Inst{15-12} = Rd;
3824 let Inst{11-7} = sh{4-0};
3825 let Inst{6} = sh{5};
3829 def SSAT16 : AI<(outs GPRnopc:$Rd),
3830 (ins imm1_16:$sat_imm, GPRnopc:$Rn), SatFrm,
3831 NoItinerary, "ssat16", "\t$Rd, $sat_imm, $Rn", []>,
3832 Requires<[IsARM,HasV6]>{
3836 let Inst{27-20} = 0b01101010;
3837 let Inst{11-4} = 0b11110011;
3838 let Inst{15-12} = Rd;
3839 let Inst{19-16} = sat_imm;
3843 def USAT : AI<(outs GPRnopc:$Rd),
3844 (ins imm0_31:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3845 SatFrm, NoItinerary, "usat", "\t$Rd, $sat_imm, $Rn$sh", []>,
3846 Requires<[IsARM,HasV6]> {
3851 let Inst{27-21} = 0b0110111;
3852 let Inst{5-4} = 0b01;
3853 let Inst{15-12} = Rd;
3854 let Inst{11-7} = sh{4-0};
3855 let Inst{6} = sh{5};
3856 let Inst{20-16} = sat_imm;
3860 def USAT16 : AI<(outs GPRnopc:$Rd),
3861 (ins imm0_15:$sat_imm, GPRnopc:$Rn), SatFrm,
3862 NoItinerary, "usat16", "\t$Rd, $sat_imm, $Rn", []>,
3863 Requires<[IsARM,HasV6]>{
3867 let Inst{27-20} = 0b01101110;
3868 let Inst{11-4} = 0b11110011;
3869 let Inst{15-12} = Rd;
3870 let Inst{19-16} = sat_imm;
3874 def : ARMV6Pat<(int_arm_ssat GPRnopc:$a, imm1_32:$pos),
3875 (SSAT imm1_32:$pos, GPRnopc:$a, 0)>;
3876 def : ARMV6Pat<(int_arm_usat GPRnopc:$a, imm0_31:$pos),
3877 (USAT imm0_31:$pos, GPRnopc:$a, 0)>;
3878 def : ARMPat<(ARMssatnoshift GPRnopc:$Rn, imm0_31:$imm),
3879 (SSAT imm0_31:$imm, GPRnopc:$Rn, 0)>;
3880 def : ARMPat<(ARMusatnoshift GPRnopc:$Rn, imm0_31:$imm),
3881 (USAT imm0_31:$imm, GPRnopc:$Rn, 0)>;
3882 def : ARMV6Pat<(int_arm_ssat16 GPRnopc:$a, imm1_16:$pos),
3883 (SSAT16 imm1_16:$pos, GPRnopc:$a)>;
3884 def : ARMV6Pat<(int_arm_usat16 GPRnopc:$a, imm0_15:$pos),
3885 (USAT16 imm0_15:$pos, GPRnopc:$a)>;
3887 //===----------------------------------------------------------------------===//
3888 // Bitwise Instructions.
3891 defm AND : AsI1_bin_irs<0b0000, "and",
3892 IIC_iBITi, IIC_iBITr, IIC_iBITsr, and, 1>;
3893 defm ORR : AsI1_bin_irs<0b1100, "orr",
3894 IIC_iBITi, IIC_iBITr, IIC_iBITsr, or, 1>;
3895 defm EOR : AsI1_bin_irs<0b0001, "eor",
3896 IIC_iBITi, IIC_iBITr, IIC_iBITsr, xor, 1>;
3897 defm BIC : AsI1_bin_irs<0b1110, "bic",
3898 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3899 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
3901 // FIXME: bf_inv_mask_imm should be two operands, the lsb and the msb, just
3902 // like in the actual instruction encoding. The complexity of mapping the mask
3903 // to the lsb/msb pair should be handled by ISel, not encapsulated in the
3904 // instruction description.
3905 def BFC : I<(outs GPR:$Rd), (ins GPR:$src, bf_inv_mask_imm:$imm),
3906 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3907 "bfc", "\t$Rd, $imm", "$src = $Rd",
3908 [(set GPR:$Rd, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
3909 Requires<[IsARM, HasV6T2]> {
3912 let Inst{27-21} = 0b0111110;
3913 let Inst{6-0} = 0b0011111;
3914 let Inst{15-12} = Rd;
3915 let Inst{11-7} = imm{4-0}; // lsb
3916 let Inst{20-16} = imm{9-5}; // msb
3919 // A8.6.18 BFI - Bitfield insert (Encoding A1)
3920 def BFI:I<(outs GPRnopc:$Rd), (ins GPRnopc:$src, GPR:$Rn, bf_inv_mask_imm:$imm),
3921 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3922 "bfi", "\t$Rd, $Rn, $imm", "$src = $Rd",
3923 [(set GPRnopc:$Rd, (ARMbfi GPRnopc:$src, GPR:$Rn,
3924 bf_inv_mask_imm:$imm))]>,
3925 Requires<[IsARM, HasV6T2]> {
3929 let Inst{27-21} = 0b0111110;
3930 let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15
3931 let Inst{15-12} = Rd;
3932 let Inst{11-7} = imm{4-0}; // lsb
3933 let Inst{20-16} = imm{9-5}; // width
3937 def MVNr : AsI1<0b1111, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMVNr,
3938 "mvn", "\t$Rd, $Rm",
3939 [(set GPR:$Rd, (not GPR:$Rm))]>, UnaryDP, Sched<[WriteALU]> {
3943 let Inst{19-16} = 0b0000;
3944 let Inst{11-4} = 0b00000000;
3945 let Inst{15-12} = Rd;
3948 let Unpredictable{19-16} = 0b1111;
3950 def MVNsi : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_imm:$shift),
3951 DPSoRegImmFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3952 [(set GPR:$Rd, (not so_reg_imm:$shift))]>, UnaryDP,
3957 let Inst{19-16} = 0b0000;
3958 let Inst{15-12} = Rd;
3959 let Inst{11-5} = shift{11-5};
3961 let Inst{3-0} = shift{3-0};
3963 let Unpredictable{19-16} = 0b1111;
3965 def MVNsr : AsI1<0b1111, (outs GPRnopc:$Rd), (ins so_reg_reg:$shift),
3966 DPSoRegRegFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3967 [(set GPRnopc:$Rd, (not so_reg_reg:$shift))]>, UnaryDP,
3972 let Inst{19-16} = 0b0000;
3973 let Inst{15-12} = Rd;
3974 let Inst{11-8} = shift{11-8};
3976 let Inst{6-5} = shift{6-5};
3978 let Inst{3-0} = shift{3-0};
3980 let Unpredictable{19-16} = 0b1111;
3982 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3983 def MVNi : AsI1<0b1111, (outs GPR:$Rd), (ins mod_imm:$imm), DPFrm,
3984 IIC_iMVNi, "mvn", "\t$Rd, $imm",
3985 [(set GPR:$Rd, mod_imm_not:$imm)]>,UnaryDP, Sched<[WriteALU]> {
3989 let Inst{19-16} = 0b0000;
3990 let Inst{15-12} = Rd;
3991 let Inst{11-0} = imm;
3994 let AddedComplexity = 1 in
3995 def : ARMPat<(and GPR:$src, mod_imm_not:$imm),
3996 (BICri GPR:$src, mod_imm_not:$imm)>;
3998 //===----------------------------------------------------------------------===//
3999 // Multiply Instructions.
4001 class AsMul1I32<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
4002 string opc, string asm, list<dag> pattern>
4003 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
4007 let Inst{19-16} = Rd;
4008 let Inst{11-8} = Rm;
4011 class AsMul1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
4012 string opc, string asm, list<dag> pattern>
4013 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
4018 let Inst{19-16} = RdHi;
4019 let Inst{15-12} = RdLo;
4020 let Inst{11-8} = Rm;
4023 class AsMla1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
4024 string opc, string asm, list<dag> pattern>
4025 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
4030 let Inst{19-16} = RdHi;
4031 let Inst{15-12} = RdLo;
4032 let Inst{11-8} = Rm;
4036 // FIXME: The v5 pseudos are only necessary for the additional Constraint
4037 // property. Remove them when it's possible to add those properties
4038 // on an individual MachineInstr, not just an instruction description.
4039 let isCommutable = 1, TwoOperandAliasConstraint = "$Rn = $Rd" in {
4040 def MUL : AsMul1I32<0b0000000, (outs GPRnopc:$Rd),
4041 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4042 IIC_iMUL32, "mul", "\t$Rd, $Rn, $Rm",
4043 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))]>,
4044 Requires<[IsARM, HasV6]>,
4045 Sched<[WriteMUL32, ReadMUL, ReadMUL]> {
4046 let Inst{15-12} = 0b0000;
4047 let Unpredictable{15-12} = 0b1111;
4050 let Constraints = "@earlyclobber $Rd" in
4051 def MULv5: ARMPseudoExpand<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm,
4052 pred:$p, cc_out:$s),
4054 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))],
4055 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s)>,
4056 Requires<[IsARM, NoV6, UseMulOps]>,
4057 Sched<[WriteMUL32, ReadMUL, ReadMUL]>;
4060 def MLA : AsMul1I32<0b0000001, (outs GPRnopc:$Rd),
4061 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra),
4062 IIC_iMAC32, "mla", "\t$Rd, $Rn, $Rm, $Ra",
4063 [(set GPRnopc:$Rd, (add (mul GPRnopc:$Rn, GPRnopc:$Rm), GPRnopc:$Ra))]>,
4064 Requires<[IsARM, HasV6, UseMulOps]>,
4065 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]> {
4067 let Inst{15-12} = Ra;
4070 let Constraints = "@earlyclobber $Rd" in
4071 def MLAv5: ARMPseudoExpand<(outs GPRnopc:$Rd),
4072 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra,
4073 pred:$p, cc_out:$s), 4, IIC_iMAC32,
4074 [(set GPRnopc:$Rd, (add (mul GPRnopc:$Rn, GPRnopc:$Rm), GPRnopc:$Ra))],
4075 (MLA GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra, pred:$p, cc_out:$s)>,
4076 Requires<[IsARM, NoV6]>,
4077 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4079 def MLS : AMul1I<0b0000011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4080 IIC_iMAC32, "mls", "\t$Rd, $Rn, $Rm, $Ra",
4081 [(set GPR:$Rd, (sub GPR:$Ra, (mul GPR:$Rn, GPR:$Rm)))]>,
4082 Requires<[IsARM, HasV6T2, UseMulOps]>,
4083 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]> {
4088 let Inst{19-16} = Rd;
4089 let Inst{15-12} = Ra;
4090 let Inst{11-8} = Rm;
4094 // Extra precision multiplies with low / high results
4095 let hasSideEffects = 0 in {
4096 let isCommutable = 1 in {
4097 def SMULL : AsMul1I64<0b0000110, (outs GPR:$RdLo, GPR:$RdHi),
4098 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
4099 "smull", "\t$RdLo, $RdHi, $Rn, $Rm",
4100 [(set GPR:$RdLo, GPR:$RdHi,
4101 (smullohi GPR:$Rn, GPR:$Rm))]>,
4102 Requires<[IsARM, HasV6]>,
4103 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>;
4105 def UMULL : AsMul1I64<0b0000100, (outs GPR:$RdLo, GPR:$RdHi),
4106 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
4107 "umull", "\t$RdLo, $RdHi, $Rn, $Rm",
4108 [(set GPR:$RdLo, GPR:$RdHi,
4109 (umullohi GPR:$Rn, GPR:$Rm))]>,
4110 Requires<[IsARM, HasV6]>,
4111 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL]>;
4113 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
4114 def SMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
4115 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
4117 [(set GPR:$RdLo, GPR:$RdHi,
4118 (smullohi GPR:$Rn, GPR:$Rm))],
4119 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
4120 Requires<[IsARM, NoV6]>,
4121 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>;
4123 def UMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
4124 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
4126 [(set GPR:$RdLo, GPR:$RdHi,
4127 (umullohi GPR:$Rn, GPR:$Rm))],
4128 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
4129 Requires<[IsARM, NoV6]>,
4130 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>;
4134 // Multiply + accumulate
4135 def SMLAL : AsMla1I64<0b0000111, (outs GPR:$RdLo, GPR:$RdHi),
4136 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64,
4137 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4138 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>,
4139 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4140 def UMLAL : AsMla1I64<0b0000101, (outs GPR:$RdLo, GPR:$RdHi),
4141 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64,
4142 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4143 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>,
4144 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4146 def UMAAL : AMul1I <0b0000010, (outs GPR:$RdLo, GPR:$RdHi),
4147 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4149 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4150 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>,
4151 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]> {
4156 let Inst{19-16} = RdHi;
4157 let Inst{15-12} = RdLo;
4158 let Inst{11-8} = Rm;
4163 "@earlyclobber $RdLo,@earlyclobber $RdHi,$RLo = $RdLo,$RHi = $RdHi" in {
4164 def SMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
4165 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s),
4167 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi,
4168 pred:$p, cc_out:$s)>,
4169 Requires<[IsARM, NoV6]>,
4170 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4171 def UMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
4172 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s),
4174 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi,
4175 pred:$p, cc_out:$s)>,
4176 Requires<[IsARM, NoV6]>,
4177 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4182 // Most significant word multiply
4183 def SMMUL : AMul2I <0b0111010, 0b0001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4184 IIC_iMUL32, "smmul", "\t$Rd, $Rn, $Rm",
4185 [(set GPR:$Rd, (mulhs GPR:$Rn, GPR:$Rm))]>,
4186 Requires<[IsARM, HasV6]>,
4187 Sched<[WriteMUL32, ReadMUL, ReadMUL]> {
4188 let Inst{15-12} = 0b1111;
4191 def SMMULR : AMul2I <0b0111010, 0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4192 IIC_iMUL32, "smmulr", "\t$Rd, $Rn, $Rm",
4193 [(set GPR:$Rd, (ARMsmmlar GPR:$Rn, GPR:$Rm, (i32 0)))]>,
4194 Requires<[IsARM, HasV6]>,
4195 Sched<[WriteMUL32, ReadMUL, ReadMUL]> {
4196 let Inst{15-12} = 0b1111;
4199 def SMMLA : AMul2Ia <0b0111010, 0b0001, (outs GPR:$Rd),
4200 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4201 IIC_iMAC32, "smmla", "\t$Rd, $Rn, $Rm, $Ra",
4202 [(set GPR:$Rd, (add (mulhs GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
4203 Requires<[IsARM, HasV6, UseMulOps]>,
4204 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4206 def SMMLAR : AMul2Ia <0b0111010, 0b0011, (outs GPR:$Rd),
4207 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4208 IIC_iMAC32, "smmlar", "\t$Rd, $Rn, $Rm, $Ra",
4209 [(set GPR:$Rd, (ARMsmmlar GPR:$Rn, GPR:$Rm, GPR:$Ra))]>,
4210 Requires<[IsARM, HasV6]>,
4211 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4213 def SMMLS : AMul2Ia <0b0111010, 0b1101, (outs GPR:$Rd),
4214 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4215 IIC_iMAC32, "smmls", "\t$Rd, $Rn, $Rm, $Ra", []>,
4216 Requires<[IsARM, HasV6, UseMulOps]>,
4217 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4219 def SMMLSR : AMul2Ia <0b0111010, 0b1111, (outs GPR:$Rd),
4220 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4221 IIC_iMAC32, "smmlsr", "\t$Rd, $Rn, $Rm, $Ra",
4222 [(set GPR:$Rd, (ARMsmmlsr GPR:$Rn, GPR:$Rm, GPR:$Ra))]>,
4223 Requires<[IsARM, HasV6]>,
4224 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4226 multiclass AI_smul<string opc> {
4227 def BB : AMulxyI<0b0001011, 0b00, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4228 IIC_iMUL16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm",
4229 [(set GPR:$Rd, (bb_mul GPR:$Rn, GPR:$Rm))]>,
4230 Requires<[IsARM, HasV5TE]>,
4231 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4233 def BT : AMulxyI<0b0001011, 0b10, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4234 IIC_iMUL16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm",
4235 [(set GPR:$Rd, (bt_mul GPR:$Rn, GPR:$Rm))]>,
4236 Requires<[IsARM, HasV5TE]>,
4237 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4239 def TB : AMulxyI<0b0001011, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4240 IIC_iMUL16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm",
4241 [(set GPR:$Rd, (tb_mul GPR:$Rn, GPR:$Rm))]>,
4242 Requires<[IsARM, HasV5TE]>,
4243 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4245 def TT : AMulxyI<0b0001011, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4246 IIC_iMUL16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm",
4247 [(set GPR:$Rd, (tt_mul GPR:$Rn, GPR:$Rm))]>,
4248 Requires<[IsARM, HasV5TE]>,
4249 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4251 def WB : AMulxyI<0b0001001, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4252 IIC_iMUL16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm",
4253 [(set GPR:$Rd, (ARMsmulwb GPR:$Rn, GPR:$Rm))]>,
4254 Requires<[IsARM, HasV5TE]>,
4255 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4257 def WT : AMulxyI<0b0001001, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4258 IIC_iMUL16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm",
4259 [(set GPR:$Rd, (ARMsmulwt GPR:$Rn, GPR:$Rm))]>,
4260 Requires<[IsARM, HasV5TE]>,
4261 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4265 multiclass AI_smla<string opc> {
4266 let DecoderMethod = "DecodeSMLAInstruction" in {
4267 def BB : AMulxyIa<0b0001000, 0b00, (outs GPRnopc:$Rd),
4268 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4269 IIC_iMAC16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra",
4270 [(set GPRnopc:$Rd, (add GPR:$Ra,
4271 (bb_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4272 Requires<[IsARM, HasV5TE, UseMulOps]>,
4273 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4275 def BT : AMulxyIa<0b0001000, 0b10, (outs GPRnopc:$Rd),
4276 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4277 IIC_iMAC16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra",
4278 [(set GPRnopc:$Rd, (add GPR:$Ra,
4279 (bt_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4280 Requires<[IsARM, HasV5TE, UseMulOps]>,
4281 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4283 def TB : AMulxyIa<0b0001000, 0b01, (outs GPRnopc:$Rd),
4284 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4285 IIC_iMAC16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra",
4286 [(set GPRnopc:$Rd, (add GPR:$Ra,
4287 (tb_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4288 Requires<[IsARM, HasV5TE, UseMulOps]>,
4289 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4291 def TT : AMulxyIa<0b0001000, 0b11, (outs GPRnopc:$Rd),
4292 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4293 IIC_iMAC16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra",
4294 [(set GPRnopc:$Rd, (add GPR:$Ra,
4295 (tt_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4296 Requires<[IsARM, HasV5TE, UseMulOps]>,
4297 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4299 def WB : AMulxyIa<0b0001001, 0b00, (outs GPRnopc:$Rd),
4300 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4301 IIC_iMAC16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra",
4303 (add GPR:$Ra, (ARMsmulwb GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4304 Requires<[IsARM, HasV5TE, UseMulOps]>,
4305 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4307 def WT : AMulxyIa<0b0001001, 0b10, (outs GPRnopc:$Rd),
4308 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4309 IIC_iMAC16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra",
4311 (add GPR:$Ra, (ARMsmulwt GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4312 Requires<[IsARM, HasV5TE, UseMulOps]>,
4313 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4317 defm SMUL : AI_smul<"smul">;
4318 defm SMLA : AI_smla<"smla">;
4320 // Halfword multiply accumulate long: SMLAL<x><y>.
4321 class SMLAL<bits<2> opc1, string asm>
4322 : AMulxyI64<0b0001010, opc1,
4323 (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4324 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4325 IIC_iMAC64, asm, "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4326 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">,
4327 Requires<[IsARM, HasV5TE]>,
4328 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4330 def SMLALBB : SMLAL<0b00, "smlalbb">;
4331 def SMLALBT : SMLAL<0b10, "smlalbt">;
4332 def SMLALTB : SMLAL<0b01, "smlaltb">;
4333 def SMLALTT : SMLAL<0b11, "smlaltt">;
4335 def : ARMV5TEPat<(ARMsmlalbb GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4336 (SMLALBB $Rn, $Rm, $RLo, $RHi)>;
4337 def : ARMV5TEPat<(ARMsmlalbt GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4338 (SMLALBT $Rn, $Rm, $RLo, $RHi)>;
4339 def : ARMV5TEPat<(ARMsmlaltb GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4340 (SMLALTB $Rn, $Rm, $RLo, $RHi)>;
4341 def : ARMV5TEPat<(ARMsmlaltt GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4342 (SMLALTT $Rn, $Rm, $RLo, $RHi)>;
4344 // Helper class for AI_smld.
4345 class AMulDualIbase<bit long, bit sub, bit swap, dag oops, dag iops,
4346 InstrItinClass itin, string opc, string asm>
4347 : AI<oops, iops, MulFrm, itin, opc, asm, []>,
4348 Requires<[IsARM, HasV6]> {
4351 let Inst{27-23} = 0b01110;
4352 let Inst{22} = long;
4353 let Inst{21-20} = 0b00;
4354 let Inst{11-8} = Rm;
4361 class AMulDualI<bit long, bit sub, bit swap, dag oops, dag iops,
4362 InstrItinClass itin, string opc, string asm>
4363 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4365 let Inst{15-12} = 0b1111;
4366 let Inst{19-16} = Rd;
4368 class AMulDualIa<bit long, bit sub, bit swap, dag oops, dag iops,
4369 InstrItinClass itin, string opc, string asm>
4370 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4373 let Inst{19-16} = Rd;
4374 let Inst{15-12} = Ra;
4376 class AMulDualI64<bit long, bit sub, bit swap, dag oops, dag iops,
4377 InstrItinClass itin, string opc, string asm>
4378 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4381 let Inst{19-16} = RdHi;
4382 let Inst{15-12} = RdLo;
4385 multiclass AI_smld<bit sub, string opc> {
4387 def D : AMulDualIa<0, sub, 0, (outs GPRnopc:$Rd),
4388 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4389 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm, $Ra">,
4390 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4392 def DX: AMulDualIa<0, sub, 1, (outs GPRnopc:$Rd),
4393 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4394 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm, $Ra">,
4395 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4397 def LD: AMulDualI64<1, sub, 0, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4398 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4400 !strconcat(opc, "ld"), "\t$RdLo, $RdHi, $Rn, $Rm">,
4401 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">,
4402 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4404 def LDX : AMulDualI64<1, sub, 1, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4405 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4407 !strconcat(opc, "ldx"),"\t$RdLo, $RdHi, $Rn, $Rm">,
4408 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">,
4409 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>;
4412 defm SMLA : AI_smld<0, "smla">;
4413 defm SMLS : AI_smld<1, "smls">;
4415 def : ARMV6Pat<(int_arm_smlad GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4416 (SMLAD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>;
4417 def : ARMV6Pat<(int_arm_smladx GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4418 (SMLADX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>;
4419 def : ARMV6Pat<(int_arm_smlsd GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4420 (SMLSD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>;
4421 def : ARMV6Pat<(int_arm_smlsdx GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4422 (SMLSDX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>;
4423 def : ARMV6Pat<(ARMSmlald GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4424 (SMLALD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>;
4425 def : ARMV6Pat<(ARMSmlaldx GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4426 (SMLALDX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>;
4427 def : ARMV6Pat<(ARMSmlsld GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4428 (SMLSLD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>;
4429 def : ARMV6Pat<(ARMSmlsldx GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4430 (SMLSLDX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>;
4432 multiclass AI_sdml<bit sub, string opc> {
4434 def D:AMulDualI<0, sub, 0, (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm),
4435 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm">,
4436 Sched<[WriteMUL32, ReadMUL, ReadMUL]>;
4437 def DX:AMulDualI<0, sub, 1, (outs GPRnopc:$Rd),(ins GPRnopc:$Rn, GPRnopc:$Rm),
4438 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm">,
4439 Sched<[WriteMUL32, ReadMUL, ReadMUL]>;
4442 defm SMUA : AI_sdml<0, "smua">;
4443 defm SMUS : AI_sdml<1, "smus">;
4445 def : ARMV6Pat<(int_arm_smuad GPRnopc:$Rn, GPRnopc:$Rm),
4446 (SMUAD GPRnopc:$Rn, GPRnopc:$Rm)>;
4447 def : ARMV6Pat<(int_arm_smuadx GPRnopc:$Rn, GPRnopc:$Rm),
4448 (SMUADX GPRnopc:$Rn, GPRnopc:$Rm)>;
4449 def : ARMV6Pat<(int_arm_smusd GPRnopc:$Rn, GPRnopc:$Rm),
4450 (SMUSD GPRnopc:$Rn, GPRnopc:$Rm)>;
4451 def : ARMV6Pat<(int_arm_smusdx GPRnopc:$Rn, GPRnopc:$Rm),
4452 (SMUSDX GPRnopc:$Rn, GPRnopc:$Rm)>;
4454 //===----------------------------------------------------------------------===//
4455 // Division Instructions (ARMv7-A with virtualization extension)
4457 def SDIV : ADivA1I<0b001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV,
4458 "sdiv", "\t$Rd, $Rn, $Rm",
4459 [(set GPR:$Rd, (sdiv GPR:$Rn, GPR:$Rm))]>,
4460 Requires<[IsARM, HasDivideInARM]>,
4463 def UDIV : ADivA1I<0b011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV,
4464 "udiv", "\t$Rd, $Rn, $Rm",
4465 [(set GPR:$Rd, (udiv GPR:$Rn, GPR:$Rm))]>,
4466 Requires<[IsARM, HasDivideInARM]>,
4469 //===----------------------------------------------------------------------===//
4470 // Misc. Arithmetic Instructions.
4473 def CLZ : AMiscA1I<0b00010110, 0b0001, (outs GPR:$Rd), (ins GPR:$Rm),
4474 IIC_iUNAr, "clz", "\t$Rd, $Rm",
4475 [(set GPR:$Rd, (ctlz GPR:$Rm))]>, Requires<[IsARM, HasV5T]>,
4478 def RBIT : AMiscA1I<0b01101111, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
4479 IIC_iUNAr, "rbit", "\t$Rd, $Rm",
4480 [(set GPR:$Rd, (bitreverse GPR:$Rm))]>,
4481 Requires<[IsARM, HasV6T2]>,
4484 def REV : AMiscA1I<0b01101011, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
4485 IIC_iUNAr, "rev", "\t$Rd, $Rm",
4486 [(set GPR:$Rd, (bswap GPR:$Rm))]>, Requires<[IsARM, HasV6]>,
4489 let AddedComplexity = 5 in
4490 def REV16 : AMiscA1I<0b01101011, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
4491 IIC_iUNAr, "rev16", "\t$Rd, $Rm",
4492 [(set GPR:$Rd, (rotr (bswap GPR:$Rm), (i32 16)))]>,
4493 Requires<[IsARM, HasV6]>,
4496 def : ARMV6Pat<(srl (bswap (extloadi16 addrmode3:$addr)), (i32 16)),
4497 (REV16 (LDRH addrmode3:$addr))>;
4498 def : ARMV6Pat<(truncstorei16 (srl (bswap GPR:$Rn), (i32 16)), addrmode3:$addr),
4499 (STRH (REV16 GPR:$Rn), addrmode3:$addr)>;
4501 let AddedComplexity = 5 in
4502 def REVSH : AMiscA1I<0b01101111, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
4503 IIC_iUNAr, "revsh", "\t$Rd, $Rm",
4504 [(set GPR:$Rd, (sra (bswap GPR:$Rm), (i32 16)))]>,
4505 Requires<[IsARM, HasV6]>,
4508 def : ARMV6Pat<(or (sra (shl GPR:$Rm, (i32 24)), (i32 16)),
4509 (and (srl GPR:$Rm, (i32 8)), 0xFF)),
4512 def PKHBT : APKHI<0b01101000, 0, (outs GPRnopc:$Rd),
4513 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_lsl_amt:$sh),
4514 IIC_iALUsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh",
4515 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF),
4516 (and (shl GPRnopc:$Rm, pkh_lsl_amt:$sh),
4518 Requires<[IsARM, HasV6]>,
4519 Sched<[WriteALUsi, ReadALU]>;
4521 // Alternate cases for PKHBT where identities eliminate some nodes.
4522 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (and GPRnopc:$Rm, 0xFFFF0000)),
4523 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, 0)>;
4524 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (shl GPRnopc:$Rm, imm16_31:$sh)),
4525 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, imm16_31:$sh)>;
4527 // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
4528 // will match the pattern below.
4529 def PKHTB : APKHI<0b01101000, 1, (outs GPRnopc:$Rd),
4530 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_asr_amt:$sh),
4531 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh",
4532 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF0000),
4533 (and (sra GPRnopc:$Rm, pkh_asr_amt:$sh),
4535 Requires<[IsARM, HasV6]>,
4536 Sched<[WriteALUsi, ReadALU]>;
4538 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
4539 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
4540 // We also can not replace a srl (17..31) by an arithmetic shift we would use in
4541 // pkhtb src1, src2, asr (17..31).
4542 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4543 (srl GPRnopc:$src2, imm16:$sh)),
4544 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16:$sh)>;
4545 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4546 (sra GPRnopc:$src2, imm16_31:$sh)),
4547 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16_31:$sh)>;
4548 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4549 (and (srl GPRnopc:$src2, imm1_15:$sh), 0xFFFF)),
4550 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm1_15:$sh)>;
4552 //===----------------------------------------------------------------------===//
4556 // + CRC32{B,H,W} 0x04C11DB7
4557 // + CRC32C{B,H,W} 0x1EDC6F41
4560 class AI_crc32<bit C, bits<2> sz, string suffix, SDPatternOperator builtin>
4561 : AInoP<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm), MiscFrm, NoItinerary,
4562 !strconcat("crc32", suffix), "\t$Rd, $Rn, $Rm",
4563 [(set GPRnopc:$Rd, (builtin GPRnopc:$Rn, GPRnopc:$Rm))]>,
4564 Requires<[IsARM, HasV8, HasCRC]> {
4569 let Inst{31-28} = 0b1110;
4570 let Inst{27-23} = 0b00010;
4571 let Inst{22-21} = sz;
4573 let Inst{19-16} = Rn;
4574 let Inst{15-12} = Rd;
4575 let Inst{11-10} = 0b00;
4578 let Inst{7-4} = 0b0100;
4581 let Unpredictable{11-8} = 0b1101;
4584 def CRC32B : AI_crc32<0, 0b00, "b", int_arm_crc32b>;
4585 def CRC32CB : AI_crc32<1, 0b00, "cb", int_arm_crc32cb>;
4586 def CRC32H : AI_crc32<0, 0b01, "h", int_arm_crc32h>;
4587 def CRC32CH : AI_crc32<1, 0b01, "ch", int_arm_crc32ch>;
4588 def CRC32W : AI_crc32<0, 0b10, "w", int_arm_crc32w>;
4589 def CRC32CW : AI_crc32<1, 0b10, "cw", int_arm_crc32cw>;
4591 //===----------------------------------------------------------------------===//
4592 // ARMv8.1a Privilege Access Never extension
4596 def SETPAN : AInoP<(outs), (ins imm0_1:$imm), MiscFrm, NoItinerary, "setpan",
4597 "\t$imm", []>, Requires<[IsARM, HasV8, HasV8_1a]> {
4600 let Inst{31-28} = 0b1111;
4601 let Inst{27-20} = 0b00010001;
4602 let Inst{19-16} = 0b0000;
4603 let Inst{15-10} = 0b000000;
4606 let Inst{7-4} = 0b0000;
4607 let Inst{3-0} = 0b0000;
4609 let Unpredictable{19-16} = 0b1111;
4610 let Unpredictable{15-10} = 0b111111;
4611 let Unpredictable{8} = 0b1;
4612 let Unpredictable{3-0} = 0b1111;
4615 //===----------------------------------------------------------------------===//
4616 // Comparison Instructions...
4619 defm CMP : AI1_cmp_irs<0b1010, "cmp",
4620 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr, ARMcmp>;
4622 // ARMcmpZ can re-use the above instruction definitions.
4623 def : ARMPat<(ARMcmpZ GPR:$src, mod_imm:$imm),
4624 (CMPri GPR:$src, mod_imm:$imm)>;
4625 def : ARMPat<(ARMcmpZ GPR:$src, GPR:$rhs),
4626 (CMPrr GPR:$src, GPR:$rhs)>;
4627 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_imm:$rhs),
4628 (CMPrsi GPR:$src, so_reg_imm:$rhs)>;
4629 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_reg:$rhs),
4630 (CMPrsr GPR:$src, so_reg_reg:$rhs)>;
4632 // CMN register-integer
4633 let isCompare = 1, Defs = [CPSR] in {
4634 def CMNri : AI1<0b1011, (outs), (ins GPR:$Rn, mod_imm:$imm), DPFrm, IIC_iCMPi,
4635 "cmn", "\t$Rn, $imm",
4636 [(ARMcmn GPR:$Rn, mod_imm:$imm)]>,
4637 Sched<[WriteCMP, ReadALU]> {
4642 let Inst{19-16} = Rn;
4643 let Inst{15-12} = 0b0000;
4644 let Inst{11-0} = imm;
4646 let Unpredictable{15-12} = 0b1111;
4649 // CMN register-register/shift
4650 def CMNzrr : AI1<0b1011, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, IIC_iCMPr,
4651 "cmn", "\t$Rn, $Rm",
4652 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4653 GPR:$Rn, GPR:$Rm)]>, Sched<[WriteCMP, ReadALU, ReadALU]> {
4656 let isCommutable = 1;
4659 let Inst{19-16} = Rn;
4660 let Inst{15-12} = 0b0000;
4661 let Inst{11-4} = 0b00000000;
4664 let Unpredictable{15-12} = 0b1111;
4667 def CMNzrsi : AI1<0b1011, (outs),
4668 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, IIC_iCMPsr,
4669 "cmn", "\t$Rn, $shift",
4670 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4671 GPR:$Rn, so_reg_imm:$shift)]>,
4672 Sched<[WriteCMPsi, ReadALU]> {
4677 let Inst{19-16} = Rn;
4678 let Inst{15-12} = 0b0000;
4679 let Inst{11-5} = shift{11-5};
4681 let Inst{3-0} = shift{3-0};
4683 let Unpredictable{15-12} = 0b1111;
4686 def CMNzrsr : AI1<0b1011, (outs),
4687 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, IIC_iCMPsr,
4688 "cmn", "\t$Rn, $shift",
4689 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4690 GPRnopc:$Rn, so_reg_reg:$shift)]>,
4691 Sched<[WriteCMPsr, ReadALU]> {
4696 let Inst{19-16} = Rn;
4697 let Inst{15-12} = 0b0000;
4698 let Inst{11-8} = shift{11-8};
4700 let Inst{6-5} = shift{6-5};
4702 let Inst{3-0} = shift{3-0};
4704 let Unpredictable{15-12} = 0b1111;
4709 def : ARMPat<(ARMcmp GPR:$src, mod_imm_neg:$imm),
4710 (CMNri GPR:$src, mod_imm_neg:$imm)>;
4712 def : ARMPat<(ARMcmpZ GPR:$src, mod_imm_neg:$imm),
4713 (CMNri GPR:$src, mod_imm_neg:$imm)>;
4715 // Note that TST/TEQ don't set all the same flags that CMP does!
4716 defm TST : AI1_cmp_irs<0b1000, "tst",
4717 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
4718 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>, 1,
4719 "DecodeTSTInstruction">;
4720 defm TEQ : AI1_cmp_irs<0b1001, "teq",
4721 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
4722 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>, 1>;
4724 // Pseudo i64 compares for some floating point compares.
4725 let usesCustomInserter = 1, isBranch = 1, isTerminator = 1,
4727 def BCCi64 : PseudoInst<(outs),
4728 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, brtarget:$dst),
4730 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, bb:$dst)]>,
4733 def BCCZi64 : PseudoInst<(outs),
4734 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, brtarget:$dst), IIC_Br,
4735 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, 0, 0, bb:$dst)]>,
4737 } // usesCustomInserter
4740 // Conditional moves
4741 let hasSideEffects = 0 in {
4743 let isCommutable = 1, isSelect = 1 in
4744 def MOVCCr : ARMPseudoInst<(outs GPR:$Rd),
4745 (ins GPR:$false, GPR:$Rm, cmovpred:$p),
4747 [(set GPR:$Rd, (ARMcmov GPR:$false, GPR:$Rm,
4749 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4751 def MOVCCsi : ARMPseudoInst<(outs GPR:$Rd),
4752 (ins GPR:$false, so_reg_imm:$shift, cmovpred:$p),
4755 (ARMcmov GPR:$false, so_reg_imm:$shift,
4757 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4758 def MOVCCsr : ARMPseudoInst<(outs GPR:$Rd),
4759 (ins GPR:$false, so_reg_reg:$shift, cmovpred:$p),
4761 [(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_reg:$shift,
4763 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4766 let isMoveImm = 1 in
4768 : ARMPseudoInst<(outs GPR:$Rd),
4769 (ins GPR:$false, imm0_65535_expr:$imm, cmovpred:$p),
4771 [(set GPR:$Rd, (ARMcmov GPR:$false, imm0_65535:$imm,
4773 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>,
4776 let isMoveImm = 1 in
4777 def MOVCCi : ARMPseudoInst<(outs GPR:$Rd),
4778 (ins GPR:$false, mod_imm:$imm, cmovpred:$p),
4780 [(set GPR:$Rd, (ARMcmov GPR:$false, mod_imm:$imm,
4782 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4784 // Two instruction predicate mov immediate.
4785 let isMoveImm = 1 in
4787 : ARMPseudoInst<(outs GPR:$Rd),
4788 (ins GPR:$false, i32imm:$src, cmovpred:$p),
4790 [(set GPR:$Rd, (ARMcmov GPR:$false, imm:$src,
4792 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>;
4794 let isMoveImm = 1 in
4795 def MVNCCi : ARMPseudoInst<(outs GPR:$Rd),
4796 (ins GPR:$false, mod_imm:$imm, cmovpred:$p),
4798 [(set GPR:$Rd, (ARMcmov GPR:$false, mod_imm_not:$imm,
4800 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4805 //===----------------------------------------------------------------------===//
4806 // Atomic operations intrinsics
4809 def MemBarrierOptOperand : AsmOperandClass {
4810 let Name = "MemBarrierOpt";
4811 let ParserMethod = "parseMemBarrierOptOperand";
4813 def memb_opt : Operand<i32> {
4814 let PrintMethod = "printMemBOption";
4815 let ParserMatchClass = MemBarrierOptOperand;
4816 let DecoderMethod = "DecodeMemBarrierOption";
4819 def InstSyncBarrierOptOperand : AsmOperandClass {
4820 let Name = "InstSyncBarrierOpt";
4821 let ParserMethod = "parseInstSyncBarrierOptOperand";
4823 def instsyncb_opt : Operand<i32> {
4824 let PrintMethod = "printInstSyncBOption";
4825 let ParserMatchClass = InstSyncBarrierOptOperand;
4826 let DecoderMethod = "DecodeInstSyncBarrierOption";
4829 def TraceSyncBarrierOptOperand : AsmOperandClass {
4830 let Name = "TraceSyncBarrierOpt";
4831 let ParserMethod = "parseTraceSyncBarrierOptOperand";
4833 def tsb_opt : Operand<i32> {
4834 let PrintMethod = "printTraceSyncBOption";
4835 let ParserMatchClass = TraceSyncBarrierOptOperand;
4838 // Memory barriers protect the atomic sequences
4839 let hasSideEffects = 1 in {
4840 def DMB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4841 "dmb", "\t$opt", [(int_arm_dmb (i32 imm0_15:$opt))]>,
4842 Requires<[IsARM, HasDB]> {
4844 let Inst{31-4} = 0xf57ff05;
4845 let Inst{3-0} = opt;
4848 def DSB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4849 "dsb", "\t$opt", [(int_arm_dsb (i32 imm0_15:$opt))]>,
4850 Requires<[IsARM, HasDB]> {
4852 let Inst{31-4} = 0xf57ff04;
4853 let Inst{3-0} = opt;
4856 // ISB has only full system option
4857 def ISB : AInoP<(outs), (ins instsyncb_opt:$opt), MiscFrm, NoItinerary,
4858 "isb", "\t$opt", [(int_arm_isb (i32 imm0_15:$opt))]>,
4859 Requires<[IsARM, HasDB]> {
4861 let Inst{31-4} = 0xf57ff06;
4862 let Inst{3-0} = opt;
4865 let hasNoSchedulingInfo = 1 in
4866 def TSB : AInoP<(outs), (ins tsb_opt:$opt), MiscFrm, NoItinerary,
4867 "tsb", "\t$opt", []>, Requires<[IsARM, HasV8_4a]> {
4868 let Inst{31-0} = 0xe320f012;
4873 // Armv8.5-A speculation barrier
4874 def SB : AInoP<(outs), (ins), MiscFrm, NoItinerary, "sb", "", []>,
4875 Requires<[IsARM, HasSB]>, Sched<[]> {
4876 let Inst{31-0} = 0xf57ff070;
4877 let Unpredictable = 0x000fff0f;
4878 let hasSideEffects = 1;
4881 let usesCustomInserter = 1, Defs = [CPSR] in {
4883 // Pseudo instruction that combines movs + predicated rsbmi
4884 // to implement integer ABS
4885 def ABS : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$src), 8, NoItinerary, []>;
4888 let usesCustomInserter = 1, Defs = [CPSR] in {
4889 def COPY_STRUCT_BYVAL_I32 : PseudoInst<
4890 (outs), (ins GPR:$dst, GPR:$src, i32imm:$size, i32imm:$alignment),
4892 [(ARMcopystructbyval GPR:$dst, GPR:$src, imm:$size, imm:$alignment)]>;
4895 let hasPostISelHook = 1, Constraints = "$newdst = $dst, $newsrc = $src" in {
4896 // %newsrc, %newdst = MEMCPY %dst, %src, N, ...N scratch regs...
4897 // Copies N registers worth of memory from address %src to address %dst
4898 // and returns the incremented addresses. N scratch register will
4899 // be attached for the copy to use.
4900 def MEMCPY : PseudoInst<
4901 (outs GPR:$newdst, GPR:$newsrc),
4902 (ins GPR:$dst, GPR:$src, i32imm:$nreg, variable_ops),
4904 [(set GPR:$newdst, GPR:$newsrc,
4905 (ARMmemcopy GPR:$dst, GPR:$src, imm:$nreg))]>;
4908 def ldrex_1 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4909 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4912 def ldrex_2 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4913 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4916 def ldrex_4 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4917 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4920 def strex_1 : PatFrag<(ops node:$val, node:$ptr),
4921 (int_arm_strex node:$val, node:$ptr), [{
4922 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4925 def strex_2 : PatFrag<(ops node:$val, node:$ptr),
4926 (int_arm_strex node:$val, node:$ptr), [{
4927 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4930 def strex_4 : PatFrag<(ops node:$val, node:$ptr),
4931 (int_arm_strex node:$val, node:$ptr), [{
4932 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4935 def ldaex_1 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4936 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4939 def ldaex_2 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4940 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4943 def ldaex_4 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4944 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4947 def stlex_1 : PatFrag<(ops node:$val, node:$ptr),
4948 (int_arm_stlex node:$val, node:$ptr), [{
4949 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4952 def stlex_2 : PatFrag<(ops node:$val, node:$ptr),
4953 (int_arm_stlex node:$val, node:$ptr), [{
4954 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4957 def stlex_4 : PatFrag<(ops node:$val, node:$ptr),
4958 (int_arm_stlex node:$val, node:$ptr), [{
4959 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4962 let mayLoad = 1 in {
4963 def LDREXB : AIldrex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4964 NoItinerary, "ldrexb", "\t$Rt, $addr",
4965 [(set GPR:$Rt, (ldrex_1 addr_offset_none:$addr))]>;
4966 def LDREXH : AIldrex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4967 NoItinerary, "ldrexh", "\t$Rt, $addr",
4968 [(set GPR:$Rt, (ldrex_2 addr_offset_none:$addr))]>;
4969 def LDREX : AIldrex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4970 NoItinerary, "ldrex", "\t$Rt, $addr",
4971 [(set GPR:$Rt, (ldrex_4 addr_offset_none:$addr))]>;
4972 let hasExtraDefRegAllocReq = 1 in
4973 def LDREXD : AIldrex<0b01, (outs GPRPairOp:$Rt),(ins addr_offset_none:$addr),
4974 NoItinerary, "ldrexd", "\t$Rt, $addr", []> {
4975 let DecoderMethod = "DecodeDoubleRegLoad";
4978 def LDAEXB : AIldaex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4979 NoItinerary, "ldaexb", "\t$Rt, $addr",
4980 [(set GPR:$Rt, (ldaex_1 addr_offset_none:$addr))]>;
4981 def LDAEXH : AIldaex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4982 NoItinerary, "ldaexh", "\t$Rt, $addr",
4983 [(set GPR:$Rt, (ldaex_2 addr_offset_none:$addr))]>;
4984 def LDAEX : AIldaex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4985 NoItinerary, "ldaex", "\t$Rt, $addr",
4986 [(set GPR:$Rt, (ldaex_4 addr_offset_none:$addr))]>;
4987 let hasExtraDefRegAllocReq = 1 in
4988 def LDAEXD : AIldaex<0b01, (outs GPRPairOp:$Rt),(ins addr_offset_none:$addr),
4989 NoItinerary, "ldaexd", "\t$Rt, $addr", []> {
4990 let DecoderMethod = "DecodeDoubleRegLoad";
4994 let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
4995 def STREXB: AIstrex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
4996 NoItinerary, "strexb", "\t$Rd, $Rt, $addr",
4997 [(set GPR:$Rd, (strex_1 GPR:$Rt,
4998 addr_offset_none:$addr))]>;
4999 def STREXH: AIstrex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5000 NoItinerary, "strexh", "\t$Rd, $Rt, $addr",
5001 [(set GPR:$Rd, (strex_2 GPR:$Rt,
5002 addr_offset_none:$addr))]>;
5003 def STREX : AIstrex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5004 NoItinerary, "strex", "\t$Rd, $Rt, $addr",
5005 [(set GPR:$Rd, (strex_4 GPR:$Rt,
5006 addr_offset_none:$addr))]>;
5007 let hasExtraSrcRegAllocReq = 1 in
5008 def STREXD : AIstrex<0b01, (outs GPR:$Rd),
5009 (ins GPRPairOp:$Rt, addr_offset_none:$addr),
5010 NoItinerary, "strexd", "\t$Rd, $Rt, $addr", []> {
5011 let DecoderMethod = "DecodeDoubleRegStore";
5013 def STLEXB: AIstlex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5014 NoItinerary, "stlexb", "\t$Rd, $Rt, $addr",
5016 (stlex_1 GPR:$Rt, addr_offset_none:$addr))]>;
5017 def STLEXH: AIstlex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5018 NoItinerary, "stlexh", "\t$Rd, $Rt, $addr",
5020 (stlex_2 GPR:$Rt, addr_offset_none:$addr))]>;
5021 def STLEX : AIstlex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5022 NoItinerary, "stlex", "\t$Rd, $Rt, $addr",
5024 (stlex_4 GPR:$Rt, addr_offset_none:$addr))]>;
5025 let hasExtraSrcRegAllocReq = 1 in
5026 def STLEXD : AIstlex<0b01, (outs GPR:$Rd),
5027 (ins GPRPairOp:$Rt, addr_offset_none:$addr),
5028 NoItinerary, "stlexd", "\t$Rd, $Rt, $addr", []> {
5029 let DecoderMethod = "DecodeDoubleRegStore";
5033 def CLREX : AXI<(outs), (ins), MiscFrm, NoItinerary, "clrex",
5035 Requires<[IsARM, HasV6K]> {
5036 let Inst{31-0} = 0b11110101011111111111000000011111;
5039 def : ARMPat<(strex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr),
5040 (STREXB GPR:$Rt, addr_offset_none:$addr)>;
5041 def : ARMPat<(strex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr),
5042 (STREXH GPR:$Rt, addr_offset_none:$addr)>;
5044 def : ARMPat<(stlex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr),
5045 (STLEXB GPR:$Rt, addr_offset_none:$addr)>;
5046 def : ARMPat<(stlex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr),
5047 (STLEXH GPR:$Rt, addr_offset_none:$addr)>;
5049 class acquiring_load<PatFrag base>
5050 : PatFrag<(ops node:$ptr), (base node:$ptr), [{
5051 AtomicOrdering Ordering = cast<AtomicSDNode>(N)->getOrdering();
5052 return isAcquireOrStronger(Ordering);
5055 def atomic_load_acquire_8 : acquiring_load<atomic_load_8>;
5056 def atomic_load_acquire_16 : acquiring_load<atomic_load_16>;
5057 def atomic_load_acquire_32 : acquiring_load<atomic_load_32>;
5059 class releasing_store<PatFrag base>
5060 : PatFrag<(ops node:$ptr, node:$val), (base node:$ptr, node:$val), [{
5061 AtomicOrdering Ordering = cast<AtomicSDNode>(N)->getOrdering();
5062 return isReleaseOrStronger(Ordering);
5065 def atomic_store_release_8 : releasing_store<atomic_store_8>;
5066 def atomic_store_release_16 : releasing_store<atomic_store_16>;
5067 def atomic_store_release_32 : releasing_store<atomic_store_32>;
5069 let AddedComplexity = 8 in {
5070 def : ARMPat<(atomic_load_acquire_8 addr_offset_none:$addr), (LDAB addr_offset_none:$addr)>;
5071 def : ARMPat<(atomic_load_acquire_16 addr_offset_none:$addr), (LDAH addr_offset_none:$addr)>;
5072 def : ARMPat<(atomic_load_acquire_32 addr_offset_none:$addr), (LDA addr_offset_none:$addr)>;
5073 def : ARMPat<(atomic_store_release_8 addr_offset_none:$addr, GPR:$val), (STLB GPR:$val, addr_offset_none:$addr)>;
5074 def : ARMPat<(atomic_store_release_16 addr_offset_none:$addr, GPR:$val), (STLH GPR:$val, addr_offset_none:$addr)>;
5075 def : ARMPat<(atomic_store_release_32 addr_offset_none:$addr, GPR:$val), (STL GPR:$val, addr_offset_none:$addr)>;
5078 // SWP/SWPB are deprecated in V6/V7 and optional in v7VE.
5079 // FIXME Use InstAlias to generate LDREX/STREX pairs instead.
5080 let mayLoad = 1, mayStore = 1 in {
5081 def SWP : AIswp<0, (outs GPRnopc:$Rt),
5082 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swp", []>,
5083 Requires<[IsARM,PreV8]>;
5084 def SWPB: AIswp<1, (outs GPRnopc:$Rt),
5085 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swpb", []>,
5086 Requires<[IsARM,PreV8]>;
5089 //===----------------------------------------------------------------------===//
5090 // Coprocessor Instructions.
5093 def CDP : ABI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
5094 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
5095 NoItinerary, "cdp", "\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
5096 [(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
5097 imm:$CRm, imm:$opc2)]>,
5098 Requires<[IsARM,PreV8]> {
5106 let Inst{3-0} = CRm;
5108 let Inst{7-5} = opc2;
5109 let Inst{11-8} = cop;
5110 let Inst{15-12} = CRd;
5111 let Inst{19-16} = CRn;
5112 let Inst{23-20} = opc1;
5114 let DecoderNamespace = "CoProc";
5117 def CDP2 : ABXI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
5118 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
5119 NoItinerary, "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
5120 [(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
5121 imm:$CRm, imm:$opc2)]>,
5122 Requires<[IsARM,PreV8]> {
5123 let Inst{31-28} = 0b1111;
5131 let Inst{3-0} = CRm;
5133 let Inst{7-5} = opc2;
5134 let Inst{11-8} = cop;
5135 let Inst{15-12} = CRd;
5136 let Inst{19-16} = CRn;
5137 let Inst{23-20} = opc1;
5139 let DecoderNamespace = "CoProc";
5142 class ACI<dag oops, dag iops, string opc, string asm,
5143 list<dag> pattern, IndexMode im = IndexModeNone>
5144 : I<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
5145 opc, asm, "", pattern> {
5146 let Inst{27-25} = 0b110;
5148 class ACInoP<dag oops, dag iops, string opc, string asm,
5149 list<dag> pattern, IndexMode im = IndexModeNone>
5150 : InoP<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
5151 opc, asm, "", pattern> {
5152 let Inst{31-28} = 0b1111;
5153 let Inst{27-25} = 0b110;
5156 let DecoderNamespace = "CoProc" in {
5157 multiclass LdStCop<bit load, bit Dbit, string asm, list<dag> pattern> {
5158 def _OFFSET : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
5159 asm, "\t$cop, $CRd, $addr", pattern> {
5163 let Inst{24} = 1; // P = 1
5164 let Inst{23} = addr{8};
5165 let Inst{22} = Dbit;
5166 let Inst{21} = 0; // W = 0
5167 let Inst{20} = load;
5168 let Inst{19-16} = addr{12-9};
5169 let Inst{15-12} = CRd;
5170 let Inst{11-8} = cop;
5171 let Inst{7-0} = addr{7-0};
5172 let DecoderMethod = "DecodeCopMemInstruction";
5174 def _PRE : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr),
5175 asm, "\t$cop, $CRd, $addr!", [], IndexModePre> {
5179 let Inst{24} = 1; // P = 1
5180 let Inst{23} = addr{8};
5181 let Inst{22} = Dbit;
5182 let Inst{21} = 1; // W = 1
5183 let Inst{20} = load;
5184 let Inst{19-16} = addr{12-9};
5185 let Inst{15-12} = CRd;
5186 let Inst{11-8} = cop;
5187 let Inst{7-0} = addr{7-0};
5188 let DecoderMethod = "DecodeCopMemInstruction";
5190 def _POST: ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
5191 postidx_imm8s4:$offset),
5192 asm, "\t$cop, $CRd, $addr, $offset", [], IndexModePost> {
5197 let Inst{24} = 0; // P = 0
5198 let Inst{23} = offset{8};
5199 let Inst{22} = Dbit;
5200 let Inst{21} = 1; // W = 1
5201 let Inst{20} = load;
5202 let Inst{19-16} = addr;
5203 let Inst{15-12} = CRd;
5204 let Inst{11-8} = cop;
5205 let Inst{7-0} = offset{7-0};
5206 let DecoderMethod = "DecodeCopMemInstruction";
5208 def _OPTION : ACI<(outs),
5209 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
5210 coproc_option_imm:$option),
5211 asm, "\t$cop, $CRd, $addr, $option", []> {
5216 let Inst{24} = 0; // P = 0
5217 let Inst{23} = 1; // U = 1
5218 let Inst{22} = Dbit;
5219 let Inst{21} = 0; // W = 0
5220 let Inst{20} = load;
5221 let Inst{19-16} = addr;
5222 let Inst{15-12} = CRd;
5223 let Inst{11-8} = cop;
5224 let Inst{7-0} = option;
5225 let DecoderMethod = "DecodeCopMemInstruction";
5228 multiclass LdSt2Cop<bit load, bit Dbit, string asm, list<dag> pattern> {
5229 def _OFFSET : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
5230 asm, "\t$cop, $CRd, $addr", pattern> {
5234 let Inst{24} = 1; // P = 1
5235 let Inst{23} = addr{8};
5236 let Inst{22} = Dbit;
5237 let Inst{21} = 0; // W = 0
5238 let Inst{20} = load;
5239 let Inst{19-16} = addr{12-9};
5240 let Inst{15-12} = CRd;
5241 let Inst{11-8} = cop;
5242 let Inst{7-0} = addr{7-0};
5243 let DecoderMethod = "DecodeCopMemInstruction";
5245 def _PRE : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr),
5246 asm, "\t$cop, $CRd, $addr!", [], IndexModePre> {
5250 let Inst{24} = 1; // P = 1
5251 let Inst{23} = addr{8};
5252 let Inst{22} = Dbit;
5253 let Inst{21} = 1; // W = 1
5254 let Inst{20} = load;
5255 let Inst{19-16} = addr{12-9};
5256 let Inst{15-12} = CRd;
5257 let Inst{11-8} = cop;
5258 let Inst{7-0} = addr{7-0};
5259 let DecoderMethod = "DecodeCopMemInstruction";
5261 def _POST: ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
5262 postidx_imm8s4:$offset),
5263 asm, "\t$cop, $CRd, $addr, $offset", [], IndexModePost> {
5268 let Inst{24} = 0; // P = 0
5269 let Inst{23} = offset{8};
5270 let Inst{22} = Dbit;
5271 let Inst{21} = 1; // W = 1
5272 let Inst{20} = load;
5273 let Inst{19-16} = addr;
5274 let Inst{15-12} = CRd;
5275 let Inst{11-8} = cop;
5276 let Inst{7-0} = offset{7-0};
5277 let DecoderMethod = "DecodeCopMemInstruction";
5279 def _OPTION : ACInoP<(outs),
5280 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
5281 coproc_option_imm:$option),
5282 asm, "\t$cop, $CRd, $addr, $option", []> {
5287 let Inst{24} = 0; // P = 0
5288 let Inst{23} = 1; // U = 1
5289 let Inst{22} = Dbit;
5290 let Inst{21} = 0; // W = 0
5291 let Inst{20} = load;
5292 let Inst{19-16} = addr;
5293 let Inst{15-12} = CRd;
5294 let Inst{11-8} = cop;
5295 let Inst{7-0} = option;
5296 let DecoderMethod = "DecodeCopMemInstruction";
5300 defm LDC : LdStCop <1, 0, "ldc", [(int_arm_ldc imm:$cop, imm:$CRd, addrmode5:$addr)]>;
5301 defm LDCL : LdStCop <1, 1, "ldcl", [(int_arm_ldcl imm:$cop, imm:$CRd, addrmode5:$addr)]>;
5302 defm LDC2 : LdSt2Cop<1, 0, "ldc2", [(int_arm_ldc2 imm:$cop, imm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>;
5303 defm LDC2L : LdSt2Cop<1, 1, "ldc2l", [(int_arm_ldc2l imm:$cop, imm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>;
5305 defm STC : LdStCop <0, 0, "stc", [(int_arm_stc imm:$cop, imm:$CRd, addrmode5:$addr)]>;
5306 defm STCL : LdStCop <0, 1, "stcl", [(int_arm_stcl imm:$cop, imm:$CRd, addrmode5:$addr)]>;
5307 defm STC2 : LdSt2Cop<0, 0, "stc2", [(int_arm_stc2 imm:$cop, imm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>;
5308 defm STC2L : LdSt2Cop<0, 1, "stc2l", [(int_arm_stc2l imm:$cop, imm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>;
5310 } // DecoderNamespace = "CoProc"
5312 //===----------------------------------------------------------------------===//
5313 // Move between coprocessor and ARM core register.
5316 class MovRCopro<string opc, bit direction, dag oops, dag iops,
5318 : ABI<0b1110, oops, iops, NoItinerary, opc,
5319 "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2", pattern> {
5320 let Inst{20} = direction;
5330 let Inst{15-12} = Rt;
5331 let Inst{11-8} = cop;
5332 let Inst{23-21} = opc1;
5333 let Inst{7-5} = opc2;
5334 let Inst{3-0} = CRm;
5335 let Inst{19-16} = CRn;
5337 let DecoderNamespace = "CoProc";
5340 def MCR : MovRCopro<"mcr", 0 /* from ARM core register to coprocessor */,
5342 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5343 c_imm:$CRm, imm0_7:$opc2),
5344 [(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
5345 imm:$CRm, imm:$opc2)]>,
5346 ComplexDeprecationPredicate<"MCR">;
5347 def : ARMInstAlias<"mcr${p} $cop, $opc1, $Rt, $CRn, $CRm",
5348 (MCR p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5349 c_imm:$CRm, 0, pred:$p)>;
5350 def MRC : MovRCopro<"mrc", 1 /* from coprocessor to ARM core register */,
5351 (outs GPRwithAPSR:$Rt),
5352 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
5354 def : ARMInstAlias<"mrc${p} $cop, $opc1, $Rt, $CRn, $CRm",
5355 (MRC GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
5356 c_imm:$CRm, 0, pred:$p)>;
5358 def : ARMPat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
5359 (MRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
5361 class MovRCopro2<string opc, bit direction, dag oops, dag iops,
5363 : ABXI<0b1110, oops, iops, NoItinerary,
5364 !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), pattern> {
5365 let Inst{31-24} = 0b11111110;
5366 let Inst{20} = direction;
5376 let Inst{15-12} = Rt;
5377 let Inst{11-8} = cop;
5378 let Inst{23-21} = opc1;
5379 let Inst{7-5} = opc2;
5380 let Inst{3-0} = CRm;
5381 let Inst{19-16} = CRn;
5383 let DecoderNamespace = "CoProc";
5386 def MCR2 : MovRCopro2<"mcr2", 0 /* from ARM core register to coprocessor */,
5388 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5389 c_imm:$CRm, imm0_7:$opc2),
5390 [(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
5391 imm:$CRm, imm:$opc2)]>,
5392 Requires<[IsARM,PreV8]>;
5393 def : ARMInstAlias<"mcr2 $cop, $opc1, $Rt, $CRn, $CRm",
5394 (MCR2 p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5396 def MRC2 : MovRCopro2<"mrc2", 1 /* from coprocessor to ARM core register */,
5397 (outs GPRwithAPSR:$Rt),
5398 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
5400 Requires<[IsARM,PreV8]>;
5401 def : ARMInstAlias<"mrc2 $cop, $opc1, $Rt, $CRn, $CRm",
5402 (MRC2 GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
5405 def : ARMV5TPat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn,
5406 imm:$CRm, imm:$opc2),
5407 (MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
5409 class MovRRCopro<string opc, bit direction, dag oops, dag iops, list<dag>
5411 : ABI<0b1100, oops, iops, NoItinerary, opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm",
5414 let Inst{23-21} = 0b010;
5415 let Inst{20} = direction;
5423 let Inst{15-12} = Rt;
5424 let Inst{19-16} = Rt2;
5425 let Inst{11-8} = cop;
5426 let Inst{7-4} = opc1;
5427 let Inst{3-0} = CRm;
5430 def MCRR : MovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */,
5431 (outs), (ins p_imm:$cop, imm0_15:$opc1, GPRnopc:$Rt,
5432 GPRnopc:$Rt2, c_imm:$CRm),
5433 [(int_arm_mcrr imm:$cop, imm:$opc1, GPRnopc:$Rt,
5434 GPRnopc:$Rt2, imm:$CRm)]>;
5435 def MRRC : MovRRCopro<"mrrc", 1 /* from coprocessor to ARM core register */,
5436 (outs GPRnopc:$Rt, GPRnopc:$Rt2),
5437 (ins p_imm:$cop, imm0_15:$opc1, c_imm:$CRm), []>;
5439 class MovRRCopro2<string opc, bit direction, dag oops, dag iops,
5440 list<dag> pattern = []>
5441 : ABXI<0b1100, oops, iops, NoItinerary,
5442 !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern>,
5443 Requires<[IsARM,PreV8]> {
5444 let Inst{31-28} = 0b1111;
5445 let Inst{23-21} = 0b010;
5446 let Inst{20} = direction;
5454 let Inst{15-12} = Rt;
5455 let Inst{19-16} = Rt2;
5456 let Inst{11-8} = cop;
5457 let Inst{7-4} = opc1;
5458 let Inst{3-0} = CRm;
5460 let DecoderMethod = "DecoderForMRRC2AndMCRR2";
5463 def MCRR2 : MovRRCopro2<"mcrr2", 0 /* from ARM core register to coprocessor */,
5464 (outs), (ins p_imm:$cop, imm0_15:$opc1, GPRnopc:$Rt,
5465 GPRnopc:$Rt2, c_imm:$CRm),
5466 [(int_arm_mcrr2 imm:$cop, imm:$opc1, GPRnopc:$Rt,
5467 GPRnopc:$Rt2, imm:$CRm)]>;
5469 def MRRC2 : MovRRCopro2<"mrrc2", 1 /* from coprocessor to ARM core register */,
5470 (outs GPRnopc:$Rt, GPRnopc:$Rt2),
5471 (ins p_imm:$cop, imm0_15:$opc1, c_imm:$CRm), []>;
5473 //===----------------------------------------------------------------------===//
5474 // Move between special register and ARM core register
5477 // Move to ARM core register from Special Register
5478 def MRS : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
5479 "mrs", "\t$Rd, apsr", []> {
5481 let Inst{23-16} = 0b00001111;
5482 let Unpredictable{19-17} = 0b111;
5484 let Inst{15-12} = Rd;
5486 let Inst{11-0} = 0b000000000000;
5487 let Unpredictable{11-0} = 0b110100001111;
5490 def : InstAlias<"mrs${p} $Rd, cpsr", (MRS GPRnopc:$Rd, pred:$p), 0>,
5493 // The MRSsys instruction is the MRS instruction from the ARM ARM,
5494 // section B9.3.9, with the R bit set to 1.
5495 def MRSsys : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
5496 "mrs", "\t$Rd, spsr", []> {
5498 let Inst{23-16} = 0b01001111;
5499 let Unpredictable{19-16} = 0b1111;
5501 let Inst{15-12} = Rd;
5503 let Inst{11-0} = 0b000000000000;
5504 let Unpredictable{11-0} = 0b110100001111;
5507 // However, the MRS (banked register) system instruction (ARMv7VE) *does* have a
5508 // separate encoding (distinguished by bit 5.
5509 def MRSbanked : ABI<0b0001, (outs GPRnopc:$Rd), (ins banked_reg:$banked),
5510 NoItinerary, "mrs", "\t$Rd, $banked", []>,
5511 Requires<[IsARM, HasVirtualization]> {
5516 let Inst{22} = banked{5}; // R bit
5517 let Inst{21-20} = 0b00;
5518 let Inst{19-16} = banked{3-0};
5519 let Inst{15-12} = Rd;
5520 let Inst{11-9} = 0b001;
5521 let Inst{8} = banked{4};
5522 let Inst{7-0} = 0b00000000;
5525 // Move from ARM core register to Special Register
5527 // No need to have both system and application versions of MSR (immediate) or
5528 // MSR (register), the encodings are the same and the assembly parser has no way
5529 // to distinguish between them. The mask operand contains the special register
5530 // (R Bit) in bit 4 and bits 3-0 contains the mask with the fields to be
5531 // accessed in the special register.
5532 let Defs = [CPSR] in
5533 def MSR : ABI<0b0001, (outs), (ins msr_mask:$mask, GPR:$Rn), NoItinerary,
5534 "msr", "\t$mask, $Rn", []> {
5539 let Inst{22} = mask{4}; // R bit
5540 let Inst{21-20} = 0b10;
5541 let Inst{19-16} = mask{3-0};
5542 let Inst{15-12} = 0b1111;
5543 let Inst{11-4} = 0b00000000;
5547 let Defs = [CPSR] in
5548 def MSRi : ABI<0b0011, (outs), (ins msr_mask:$mask, mod_imm:$imm), NoItinerary,
5549 "msr", "\t$mask, $imm", []> {
5554 let Inst{22} = mask{4}; // R bit
5555 let Inst{21-20} = 0b10;
5556 let Inst{19-16} = mask{3-0};
5557 let Inst{15-12} = 0b1111;
5558 let Inst{11-0} = imm;
5561 // However, the MSR (banked register) system instruction (ARMv7VE) *does* have a
5562 // separate encoding (distinguished by bit 5.
5563 def MSRbanked : ABI<0b0001, (outs), (ins banked_reg:$banked, GPRnopc:$Rn),
5564 NoItinerary, "msr", "\t$banked, $Rn", []>,
5565 Requires<[IsARM, HasVirtualization]> {
5570 let Inst{22} = banked{5}; // R bit
5571 let Inst{21-20} = 0b10;
5572 let Inst{19-16} = banked{3-0};
5573 let Inst{15-12} = 0b1111;
5574 let Inst{11-9} = 0b001;
5575 let Inst{8} = banked{4};
5576 let Inst{7-4} = 0b0000;
5580 // Dynamic stack allocation yields a _chkstk for Windows targets. These calls
5581 // are needed to probe the stack when allocating more than
5582 // 4k bytes in one go. Touching the stack at 4K increments is necessary to
5583 // ensure that the guard pages used by the OS virtual memory manager are
5584 // allocated in correct sequence.
5585 // The main point of having separate instruction are extra unmodelled effects
5586 // (compared to ordinary calls) like stack pointer change.
5588 def win__chkstk : SDNode<"ARMISD::WIN__CHKSTK", SDTNone,
5589 [SDNPHasChain, SDNPSideEffect]>;
5590 let usesCustomInserter = 1, Uses = [R4], Defs = [R4, SP] in
5591 def WIN__CHKSTK : PseudoInst<(outs), (ins), NoItinerary, [(win__chkstk)]>;
5593 def win__dbzchk : SDNode<"ARMISD::WIN__DBZCHK", SDT_WIN__DBZCHK,
5594 [SDNPHasChain, SDNPSideEffect, SDNPOutGlue]>;
5595 let usesCustomInserter = 1, Defs = [CPSR] in
5596 def WIN__DBZCHK : PseudoInst<(outs), (ins tGPR:$divisor), NoItinerary,
5597 [(win__dbzchk tGPR:$divisor)]>;
5599 //===----------------------------------------------------------------------===//
5603 // __aeabi_read_tp preserves the registers r1-r3.
5604 // This is a pseudo inst so that we can get the encoding right,
5605 // complete with fixup for the aeabi_read_tp function.
5606 // TPsoft is valid for ARM mode only, in case of Thumb mode a tTPsoft pattern
5607 // is defined in "ARMInstrThumb.td".
5609 Defs = [R0, R12, LR, CPSR], Uses = [SP] in {
5610 def TPsoft : ARMPseudoInst<(outs), (ins), 4, IIC_Br,
5611 [(set R0, ARMthread_pointer)]>, Sched<[WriteBr]>,
5612 Requires<[IsARM, IsReadTPSoft]>;
5615 // Reading thread pointer from coprocessor register
5616 def : ARMPat<(ARMthread_pointer), (MRC 15, 0, 13, 0, 3)>,
5617 Requires<[IsARM, IsReadTPHard]>;
5619 //===----------------------------------------------------------------------===//
5620 // SJLJ Exception handling intrinsics
5621 // eh_sjlj_setjmp() is an instruction sequence to store the return
5622 // address and save #0 in R0 for the non-longjmp case.
5623 // Since by its nature we may be coming from some other function to get
5624 // here, and we're using the stack frame for the containing function to
5625 // save/restore registers, we can't keep anything live in regs across
5626 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
5627 // when we get here from a longjmp(). We force everything out of registers
5628 // except for our own input by listing the relevant registers in Defs. By
5629 // doing so, we also cause the prologue/epilogue code to actively preserve
5630 // all of the callee-saved resgisters, which is exactly what we want.
5631 // A constant value is passed in $val, and we use the location as a scratch.
5633 // These are pseudo-instructions and are lowered to individual MC-insts, so
5634 // no encoding information is necessary.
5636 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
5637 Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15 ],
5638 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
5639 def Int_eh_sjlj_setjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
5641 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
5642 Requires<[IsARM, HasVFP2]>;
5646 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
5647 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
5648 def Int_eh_sjlj_setjmp_nofp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
5650 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
5651 Requires<[IsARM, NoVFP]>;
5654 // FIXME: Non-IOS version(s)
5655 let isBarrier = 1, hasSideEffects = 1, isTerminator = 1,
5656 Defs = [ R7, LR, SP ] in {
5657 def Int_eh_sjlj_longjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$scratch),
5659 [(ARMeh_sjlj_longjmp GPR:$src, GPR:$scratch)]>,
5663 let isBarrier = 1, hasSideEffects = 1, usesCustomInserter = 1 in
5664 def Int_eh_sjlj_setup_dispatch : PseudoInst<(outs), (ins), NoItinerary,
5665 [(ARMeh_sjlj_setup_dispatch)]>;
5667 // eh.sjlj.dispatchsetup pseudo-instruction.
5668 // This pseudo is used for both ARM and Thumb. Any differences are handled when
5669 // the pseudo is expanded (which happens before any passes that need the
5670 // instruction size).
5671 let isBarrier = 1 in
5672 def Int_eh_sjlj_dispatchsetup : PseudoInst<(outs), (ins), NoItinerary, []>;
5675 //===----------------------------------------------------------------------===//
5676 // Non-Instruction Patterns
5679 // ARMv4 indirect branch using (MOVr PC, dst)
5680 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in
5681 def MOVPCRX : ARMPseudoExpand<(outs), (ins GPR:$dst),
5682 4, IIC_Br, [(brind GPR:$dst)],
5683 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>,
5684 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
5686 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in
5687 def TAILJMPr4 : ARMPseudoExpand<(outs), (ins GPR:$dst),
5689 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>,
5690 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
5692 // Large immediate handling.
5694 // 32-bit immediate using two piece mod_imms or movw + movt.
5695 // This is a single pseudo instruction, the benefit is that it can be remat'd
5696 // as a single unit instead of having to handle reg inputs.
5697 // FIXME: Remove this when we can do generalized remat.
5698 let isReMaterializable = 1, isMoveImm = 1 in
5699 def MOVi32imm : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
5700 [(set GPR:$dst, (arm_i32imm:$src))]>,
5703 def LDRLIT_ga_abs : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iLoad_i,
5704 [(set GPR:$dst, (ARMWrapper tglobaladdr:$src))]>,
5705 Requires<[IsARM, DontUseMovt]>;
5707 // Pseudo instruction that combines movw + movt + add pc (if PIC).
5708 // It also makes it possible to rematerialize the instructions.
5709 // FIXME: Remove this when we can do generalized remat and when machine licm
5710 // can properly the instructions.
5711 let isReMaterializable = 1 in {
5712 def MOV_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5714 [(set GPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>,
5715 Requires<[IsARM, UseMovtInPic]>;
5717 def LDRLIT_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5720 (ARMWrapperPIC tglobaladdr:$addr))]>,
5721 Requires<[IsARM, DontUseMovtInPic]>;
5723 let AddedComplexity = 10 in
5724 def LDRLIT_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5727 (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
5728 Requires<[IsARM, DontUseMovtInPic]>;
5730 let AddedComplexity = 10 in
5731 def MOV_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5733 [(set GPR:$dst, (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
5734 Requires<[IsARM, UseMovtInPic]>;
5735 } // isReMaterializable
5737 // The many different faces of TLS access.
5738 def : ARMPat<(ARMWrapper tglobaltlsaddr :$dst),
5739 (MOVi32imm tglobaltlsaddr :$dst)>,
5740 Requires<[IsARM, UseMovt]>;
5742 def : Pat<(ARMWrapper tglobaltlsaddr:$src),
5743 (LDRLIT_ga_abs tglobaltlsaddr:$src)>,
5744 Requires<[IsARM, DontUseMovt]>;
5746 def : Pat<(ARMWrapperPIC tglobaltlsaddr:$addr),
5747 (MOV_ga_pcrel tglobaltlsaddr:$addr)>, Requires<[IsARM, UseMovtInPic]>;
5749 def : Pat<(ARMWrapperPIC tglobaltlsaddr:$addr),
5750 (LDRLIT_ga_pcrel tglobaltlsaddr:$addr)>,
5751 Requires<[IsARM, DontUseMovtInPic]>;
5752 let AddedComplexity = 10 in
5753 def : Pat<(load (ARMWrapperPIC tglobaltlsaddr:$addr)),
5754 (MOV_ga_pcrel_ldr tglobaltlsaddr:$addr)>,
5755 Requires<[IsARM, UseMovtInPic]>;
5758 // ConstantPool, GlobalAddress, and JumpTable
5759 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
5760 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
5761 Requires<[IsARM, UseMovt]>;
5762 def : ARMPat<(ARMWrapper texternalsym :$dst), (MOVi32imm texternalsym :$dst)>,
5763 Requires<[IsARM, UseMovt]>;
5764 def : ARMPat<(ARMWrapperJT tjumptable:$dst),
5765 (LEApcrelJT tjumptable:$dst)>;
5767 // TODO: add,sub,and, 3-instr forms?
5769 // Tail calls. These patterns also apply to Thumb mode.
5770 def : Pat<(ARMtcret tcGPR:$dst), (TCRETURNri tcGPR:$dst)>;
5771 def : Pat<(ARMtcret (i32 tglobaladdr:$dst)), (TCRETURNdi texternalsym:$dst)>;
5772 def : Pat<(ARMtcret (i32 texternalsym:$dst)), (TCRETURNdi texternalsym:$dst)>;
5775 def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>;
5776 def : ARMPat<(ARMcall_nolink texternalsym:$func),
5777 (BMOVPCB_CALL texternalsym:$func)>;
5779 // zextload i1 -> zextload i8
5780 def : ARMPat<(zextloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5781 def : ARMPat<(zextloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5783 // extload -> zextload
5784 def : ARMPat<(extloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5785 def : ARMPat<(extloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5786 def : ARMPat<(extloadi8 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5787 def : ARMPat<(extloadi8 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5789 def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
5791 def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
5792 def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
5795 def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
5796 (SMULBB GPR:$a, GPR:$b)>;
5797 def : ARMV5TEPat<(mul sext_16_node:$a, (sext_bottom_16 GPR:$b)),
5798 (SMULBB GPR:$a, GPR:$b)>;
5799 def : ARMV5TEPat<(mul sext_16_node:$a, (sext_top_16 GPR:$b)),
5800 (SMULBT GPR:$a, GPR:$b)>;
5801 def : ARMV5TEPat<(mul (sext_top_16 GPR:$a), sext_16_node:$b),
5802 (SMULTB GPR:$a, GPR:$b)>;
5803 def : ARMV5MOPat<(add GPR:$acc, (mul sext_16_node:$a, sext_16_node:$b)),
5804 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5805 def : ARMV5MOPat<(add GPR:$acc, (mul sext_16_node:$a, (sext_bottom_16 GPR:$b))),
5806 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5807 def : ARMV5MOPat<(add GPR:$acc, (mul sext_16_node:$a, (sext_top_16 GPR:$b))),
5808 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
5809 def : ARMV5MOPat<(add GPR:$acc, (mul (sext_top_16 GPR:$a), sext_16_node:$b)),
5810 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
5812 def : ARMV5TEPat<(int_arm_smulbb GPR:$a, GPR:$b),
5813 (SMULBB GPR:$a, GPR:$b)>;
5814 def : ARMV5TEPat<(int_arm_smulbt GPR:$a, GPR:$b),
5815 (SMULBT GPR:$a, GPR:$b)>;
5816 def : ARMV5TEPat<(int_arm_smultb GPR:$a, GPR:$b),
5817 (SMULTB GPR:$a, GPR:$b)>;
5818 def : ARMV5TEPat<(int_arm_smultt GPR:$a, GPR:$b),
5819 (SMULTT GPR:$a, GPR:$b)>;
5820 def : ARMV5TEPat<(int_arm_smulwb GPR:$a, GPR:$b),
5821 (SMULWB GPR:$a, GPR:$b)>;
5822 def : ARMV5TEPat<(int_arm_smulwt GPR:$a, GPR:$b),
5823 (SMULWT GPR:$a, GPR:$b)>;
5825 def : ARMV5TEPat<(int_arm_smlabb GPR:$a, GPR:$b, GPR:$acc),
5826 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5827 def : ARMV5TEPat<(int_arm_smlabt GPR:$a, GPR:$b, GPR:$acc),
5828 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
5829 def : ARMV5TEPat<(int_arm_smlatb GPR:$a, GPR:$b, GPR:$acc),
5830 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
5831 def : ARMV5TEPat<(int_arm_smlatt GPR:$a, GPR:$b, GPR:$acc),
5832 (SMLATT GPR:$a, GPR:$b, GPR:$acc)>;
5833 def : ARMV5TEPat<(int_arm_smlawb GPR:$a, GPR:$b, GPR:$acc),
5834 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
5835 def : ARMV5TEPat<(int_arm_smlawt GPR:$a, GPR:$b, GPR:$acc),
5836 (SMLAWT GPR:$a, GPR:$b, GPR:$acc)>;
5838 // Pre-v7 uses MCR for synchronization barriers.
5839 def : ARMPat<(ARMMemBarrierMCR GPR:$zero), (MCR 15, 0, GPR:$zero, 7, 10, 5)>,
5840 Requires<[IsARM, HasV6]>;
5842 // SXT/UXT with no rotate
5843 let AddedComplexity = 16 in {
5844 def : ARMV6Pat<(and GPR:$Src, 0x000000FF), (UXTB GPR:$Src, 0)>;
5845 def : ARMV6Pat<(and GPR:$Src, 0x0000FFFF), (UXTH GPR:$Src, 0)>;
5846 def : ARMV6Pat<(and GPR:$Src, 0x00FF00FF), (UXTB16 GPR:$Src, 0)>;
5847 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0x00FF)),
5848 (UXTAB GPR:$Rn, GPR:$Rm, 0)>;
5849 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0xFFFF)),
5850 (UXTAH GPR:$Rn, GPR:$Rm, 0)>;
5853 def : ARMV6Pat<(sext_inreg GPR:$Src, i8), (SXTB GPR:$Src, 0)>;
5854 def : ARMV6Pat<(sext_inreg GPR:$Src, i16), (SXTH GPR:$Src, 0)>;
5856 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i8)),
5857 (SXTAB GPR:$Rn, GPRnopc:$Rm, 0)>;
5858 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i16)),
5859 (SXTAH GPR:$Rn, GPRnopc:$Rm, 0)>;
5861 // Atomic load/store patterns
5862 def : ARMPat<(atomic_load_8 ldst_so_reg:$src),
5863 (LDRBrs ldst_so_reg:$src)>;
5864 def : ARMPat<(atomic_load_8 addrmode_imm12:$src),
5865 (LDRBi12 addrmode_imm12:$src)>;
5866 def : ARMPat<(atomic_load_16 addrmode3:$src),
5867 (LDRH addrmode3:$src)>;
5868 def : ARMPat<(atomic_load_32 ldst_so_reg:$src),
5869 (LDRrs ldst_so_reg:$src)>;
5870 def : ARMPat<(atomic_load_32 addrmode_imm12:$src),
5871 (LDRi12 addrmode_imm12:$src)>;
5872 def : ARMPat<(atomic_store_8 ldst_so_reg:$ptr, GPR:$val),
5873 (STRBrs GPR:$val, ldst_so_reg:$ptr)>;
5874 def : ARMPat<(atomic_store_8 addrmode_imm12:$ptr, GPR:$val),
5875 (STRBi12 GPR:$val, addrmode_imm12:$ptr)>;
5876 def : ARMPat<(atomic_store_16 addrmode3:$ptr, GPR:$val),
5877 (STRH GPR:$val, addrmode3:$ptr)>;
5878 def : ARMPat<(atomic_store_32 ldst_so_reg:$ptr, GPR:$val),
5879 (STRrs GPR:$val, ldst_so_reg:$ptr)>;
5880 def : ARMPat<(atomic_store_32 addrmode_imm12:$ptr, GPR:$val),
5881 (STRi12 GPR:$val, addrmode_imm12:$ptr)>;
5884 //===----------------------------------------------------------------------===//
5888 include "ARMInstrThumb.td"
5890 //===----------------------------------------------------------------------===//
5894 include "ARMInstrThumb2.td"
5896 //===----------------------------------------------------------------------===//
5897 // Floating Point Support
5900 include "ARMInstrVFP.td"
5902 //===----------------------------------------------------------------------===//
5903 // Advanced SIMD (NEON) Support
5906 include "ARMInstrNEON.td"
5908 //===----------------------------------------------------------------------===//
5912 include "ARMInstrMVE.td"
5914 //===----------------------------------------------------------------------===//
5915 // Assembler aliases
5919 def : InstAlias<"dmb", (DMB 0xf), 0>, Requires<[IsARM, HasDB]>;
5920 def : InstAlias<"dsb", (DSB 0xf), 0>, Requires<[IsARM, HasDB]>;
5921 def : InstAlias<"ssbb", (DSB 0x0), 1>, Requires<[IsARM, HasDB]>;
5922 def : InstAlias<"pssbb", (DSB 0x4), 1>, Requires<[IsARM, HasDB]>;
5923 def : InstAlias<"isb", (ISB 0xf), 0>, Requires<[IsARM, HasDB]>;
5924 // Armv8-R 'Data Full Barrier'
5925 def : InstAlias<"dfb", (DSB 0xc), 1>, Requires<[IsARM, HasDFB]>;
5927 // System instructions
5928 def : MnemonicAlias<"swi", "svc">;
5930 // Load / Store Multiple
5931 def : MnemonicAlias<"ldmfd", "ldm">;
5932 def : MnemonicAlias<"ldmia", "ldm">;
5933 def : MnemonicAlias<"ldmea", "ldmdb">;
5934 def : MnemonicAlias<"stmfd", "stmdb">;
5935 def : MnemonicAlias<"stmia", "stm">;
5936 def : MnemonicAlias<"stmea", "stm">;
5938 // PKHBT/PKHTB with default shift amount. PKHTB is equivalent to PKHBT with the
5939 // input operands swapped when the shift amount is zero (i.e., unspecified).
5940 def : InstAlias<"pkhbt${p} $Rd, $Rn, $Rm",
5941 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p), 0>,
5942 Requires<[IsARM, HasV6]>;
5943 def : InstAlias<"pkhtb${p} $Rd, $Rn, $Rm",
5944 (PKHBT GPRnopc:$Rd, GPRnopc:$Rm, GPRnopc:$Rn, 0, pred:$p), 0>,
5945 Requires<[IsARM, HasV6]>;
5947 // PUSH/POP aliases for STM/LDM
5948 def : ARMInstAlias<"push${p} $regs", (STMDB_UPD SP, pred:$p, reglist:$regs)>;
5949 def : ARMInstAlias<"pop${p} $regs", (LDMIA_UPD SP, pred:$p, reglist:$regs)>;
5951 // SSAT/USAT optional shift operand.
5952 def : ARMInstAlias<"ssat${p} $Rd, $sat_imm, $Rn",
5953 (SSAT GPRnopc:$Rd, imm1_32:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5954 def : ARMInstAlias<"usat${p} $Rd, $sat_imm, $Rn",
5955 (USAT GPRnopc:$Rd, imm0_31:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5958 // Extend instruction optional rotate operand.
5959 def : ARMInstAlias<"sxtab${p} $Rd, $Rn, $Rm",
5960 (SXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5961 def : ARMInstAlias<"sxtah${p} $Rd, $Rn, $Rm",
5962 (SXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5963 def : ARMInstAlias<"sxtab16${p} $Rd, $Rn, $Rm",
5964 (SXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5965 def : ARMInstAlias<"sxtb${p} $Rd, $Rm",
5966 (SXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5967 def : ARMInstAlias<"sxtb16${p} $Rd, $Rm",
5968 (SXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5969 def : ARMInstAlias<"sxth${p} $Rd, $Rm",
5970 (SXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5972 def : ARMInstAlias<"uxtab${p} $Rd, $Rn, $Rm",
5973 (UXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5974 def : ARMInstAlias<"uxtah${p} $Rd, $Rn, $Rm",
5975 (UXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5976 def : ARMInstAlias<"uxtab16${p} $Rd, $Rn, $Rm",
5977 (UXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5978 def : ARMInstAlias<"uxtb${p} $Rd, $Rm",
5979 (UXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5980 def : ARMInstAlias<"uxtb16${p} $Rd, $Rm",
5981 (UXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5982 def : ARMInstAlias<"uxth${p} $Rd, $Rm",
5983 (UXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5987 def : MnemonicAlias<"rfefa", "rfeda">;
5988 def : MnemonicAlias<"rfeea", "rfedb">;
5989 def : MnemonicAlias<"rfefd", "rfeia">;
5990 def : MnemonicAlias<"rfeed", "rfeib">;
5991 def : MnemonicAlias<"rfe", "rfeia">;
5994 def : MnemonicAlias<"srsfa", "srsib">;
5995 def : MnemonicAlias<"srsea", "srsia">;
5996 def : MnemonicAlias<"srsfd", "srsdb">;
5997 def : MnemonicAlias<"srsed", "srsda">;
5998 def : MnemonicAlias<"srs", "srsia">;
6001 def : MnemonicAlias<"qsubaddx", "qsax">;
6003 def : MnemonicAlias<"saddsubx", "sasx">;
6004 // SHASX == SHADDSUBX
6005 def : MnemonicAlias<"shaddsubx", "shasx">;
6006 // SHSAX == SHSUBADDX
6007 def : MnemonicAlias<"shsubaddx", "shsax">;
6009 def : MnemonicAlias<"ssubaddx", "ssax">;
6011 def : MnemonicAlias<"uaddsubx", "uasx">;
6012 // UHASX == UHADDSUBX
6013 def : MnemonicAlias<"uhaddsubx", "uhasx">;
6014 // UHSAX == UHSUBADDX
6015 def : MnemonicAlias<"uhsubaddx", "uhsax">;
6016 // UQASX == UQADDSUBX
6017 def : MnemonicAlias<"uqaddsubx", "uqasx">;
6018 // UQSAX == UQSUBADDX
6019 def : MnemonicAlias<"uqsubaddx", "uqsax">;
6021 def : MnemonicAlias<"usubaddx", "usax">;
6023 // "mov Rd, mod_imm_not" can be handled via "mvn" in assembly, just like
6025 def : ARMInstSubst<"mov${s}${p} $Rd, $imm",
6026 (MVNi rGPR:$Rd, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6027 def : ARMInstSubst<"mvn${s}${p} $Rd, $imm",
6028 (MOVi rGPR:$Rd, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6029 // Same for AND <--> BIC
6030 def : ARMInstSubst<"bic${s}${p} $Rd, $Rn, $imm",
6031 (ANDri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm,
6032 pred:$p, cc_out:$s)>;
6033 def : ARMInstSubst<"bic${s}${p} $Rdn, $imm",
6034 (ANDri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm,
6035 pred:$p, cc_out:$s)>;
6036 def : ARMInstSubst<"and${s}${p} $Rd, $Rn, $imm",
6037 (BICri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm,
6038 pred:$p, cc_out:$s)>;
6039 def : ARMInstSubst<"and${s}${p} $Rdn, $imm",
6040 (BICri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm,
6041 pred:$p, cc_out:$s)>;
6043 // Likewise, "add Rd, mod_imm_neg" -> sub
6044 def : ARMInstSubst<"add${s}${p} $Rd, $Rn, $imm",
6045 (SUBri GPR:$Rd, GPR:$Rn, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
6046 def : ARMInstSubst<"add${s}${p} $Rd, $imm",
6047 (SUBri GPR:$Rd, GPR:$Rd, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
6048 // Likewise, "sub Rd, mod_imm_neg" -> add
6049 def : ARMInstSubst<"sub${s}${p} $Rd, $Rn, $imm",
6050 (ADDri GPR:$Rd, GPR:$Rn, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
6051 def : ARMInstSubst<"sub${s}${p} $Rd, $imm",
6052 (ADDri GPR:$Rd, GPR:$Rd, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
6055 def : ARMInstSubst<"adc${s}${p} $Rd, $Rn, $imm",
6056 (SBCri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6057 def : ARMInstSubst<"adc${s}${p} $Rdn, $imm",
6058 (SBCri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6059 def : ARMInstSubst<"sbc${s}${p} $Rd, $Rn, $imm",
6060 (ADCri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6061 def : ARMInstSubst<"sbc${s}${p} $Rdn, $imm",
6062 (ADCri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6064 // Same for CMP <--> CMN via mod_imm_neg
6065 def : ARMInstSubst<"cmp${p} $Rd, $imm",
6066 (CMNri rGPR:$Rd, mod_imm_neg:$imm, pred:$p)>;
6067 def : ARMInstSubst<"cmn${p} $Rd, $imm",
6068 (CMPri rGPR:$Rd, mod_imm_neg:$imm, pred:$p)>;
6070 // The shifter forms of the MOV instruction are aliased to the ASR, LSL,
6071 // LSR, ROR, and RRX instructions.
6072 // FIXME: We need C++ parser hooks to map the alias to the MOV
6073 // encoding. It seems we should be able to do that sort of thing
6074 // in tblgen, but it could get ugly.
6075 let TwoOperandAliasConstraint = "$Rm = $Rd" in {
6076 def ASRi : ARMAsmPseudo<"asr${s}${p} $Rd, $Rm, $imm",
6077 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
6079 def LSRi : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rm, $imm",
6080 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
6082 def LSLi : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rm, $imm",
6083 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
6085 def RORi : ARMAsmPseudo<"ror${s}${p} $Rd, $Rm, $imm",
6086 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
6089 def RRXi : ARMAsmPseudo<"rrx${s}${p} $Rd, $Rm",
6090 (ins GPR:$Rd, GPR:$Rm, pred:$p, cc_out:$s)>;
6091 let TwoOperandAliasConstraint = "$Rn = $Rd" in {
6092 def ASRr : ARMAsmPseudo<"asr${s}${p} $Rd, $Rn, $Rm",
6093 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
6095 def LSRr : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rn, $Rm",
6096 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
6098 def LSLr : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rn, $Rm",
6099 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
6101 def RORr : ARMAsmPseudo<"ror${s}${p} $Rd, $Rn, $Rm",
6102 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
6106 // "neg" is and alias for "rsb rd, rn, #0"
6107 def : ARMInstAlias<"neg${s}${p} $Rd, $Rm",
6108 (RSBri GPR:$Rd, GPR:$Rm, 0, pred:$p, cc_out:$s)>;
6110 // Pre-v6, 'mov r0, r0' was used as a NOP encoding.
6111 def : InstAlias<"nop${p}", (MOVr R0, R0, pred:$p, zero_reg)>,
6112 Requires<[IsARM, NoV6]>;
6114 // MUL/UMLAL/SMLAL/UMULL/SMULL are available on all arches, but
6115 // the instruction definitions need difference constraints pre-v6.
6116 // Use these aliases for the assembly parsing on pre-v6.
6117 def : InstAlias<"mul${s}${p} $Rd, $Rn, $Rm",
6118 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s), 0>,
6119 Requires<[IsARM, NoV6]>;
6120 def : InstAlias<"mla${s}${p} $Rd, $Rn, $Rm, $Ra",
6121 (MLA GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra,
6122 pred:$p, cc_out:$s), 0>,
6123 Requires<[IsARM, NoV6]>;
6124 def : InstAlias<"smlal${s}${p} $RdLo, $RdHi, $Rn, $Rm",
6125 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>,
6126 Requires<[IsARM, NoV6]>;
6127 def : InstAlias<"umlal${s}${p} $RdLo, $RdHi, $Rn, $Rm",
6128 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>,
6129 Requires<[IsARM, NoV6]>;
6130 def : InstAlias<"smull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
6131 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>,
6132 Requires<[IsARM, NoV6]>;
6133 def : InstAlias<"umull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
6134 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>,
6135 Requires<[IsARM, NoV6]>;
6137 // 'it' blocks in ARM mode just validate the predicates. The IT itself
6139 def ITasm : ARMAsmPseudo<"it$mask $cc", (ins it_pred:$cc, it_mask:$mask)>,
6140 ComplexDeprecationPredicate<"IT">;
6142 let mayLoad = 1, mayStore =1, hasSideEffects = 1 in
6143 def SPACE : PseudoInst<(outs GPR:$Rd), (ins i32imm:$size, GPR:$Rn),
6145 [(set GPR:$Rd, (int_arm_space imm:$size, GPR:$Rn))]>;
6147 //===----------------------------------
6148 // Atomic cmpxchg for -O0
6149 //===----------------------------------
6151 // The fast register allocator used during -O0 inserts spills to cover any VRegs
6152 // live across basic block boundaries. When this happens between an LDXR and an
6153 // STXR it can clear the exclusive monitor, causing all cmpxchg attempts to
6156 // Unfortunately, this means we have to have an alternative (expanded
6157 // post-regalloc) path for -O0 compilations. Fortunately this path can be
6158 // significantly more naive than the standard expansion: we conservatively
6159 // assume seq_cst, strong cmpxchg and omit clrex on failure.
6161 let Constraints = "@earlyclobber $Rd,@earlyclobber $temp",
6162 mayLoad = 1, mayStore = 1 in {
6163 def CMP_SWAP_8 : PseudoInst<(outs GPR:$Rd, GPR:$temp),
6164 (ins GPR:$addr, GPR:$desired, GPR:$new),
6165 NoItinerary, []>, Sched<[]>;
6167 def CMP_SWAP_16 : PseudoInst<(outs GPR:$Rd, GPR:$temp),
6168 (ins GPR:$addr, GPR:$desired, GPR:$new),
6169 NoItinerary, []>, Sched<[]>;
6171 def CMP_SWAP_32 : PseudoInst<(outs GPR:$Rd, GPR:$temp),
6172 (ins GPR:$addr, GPR:$desired, GPR:$new),
6173 NoItinerary, []>, Sched<[]>;
6175 def CMP_SWAP_64 : PseudoInst<(outs GPRPair:$Rd, GPR:$temp),
6176 (ins GPR:$addr, GPRPair:$desired, GPRPair:$new),
6177 NoItinerary, []>, Sched<[]>;
6180 def CompilerBarrier : PseudoInst<(outs), (ins i32imm:$ordering), NoItinerary,
6181 [(atomic_fence imm:$ordering, 0)]> {
6182 let hasSideEffects = 1;
6184 let AsmString = "@ COMPILER BARRIER";