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 ARMlsls : SDNode<"ARMISD::LSLS", SDTBinaryArithWithFlags>;
198 def ARMadde : SDNode<"ARMISD::ADDE", SDTBinaryArithWithFlagsInOut>;
199 def ARMsube : SDNode<"ARMISD::SUBE", SDTBinaryArithWithFlagsInOut>;
201 def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>;
202 def ARMeh_sjlj_setjmp: SDNode<"ARMISD::EH_SJLJ_SETJMP",
203 SDT_ARMEH_SJLJ_Setjmp,
204 [SDNPHasChain, SDNPSideEffect]>;
205 def ARMeh_sjlj_longjmp: SDNode<"ARMISD::EH_SJLJ_LONGJMP",
206 SDT_ARMEH_SJLJ_Longjmp,
207 [SDNPHasChain, SDNPSideEffect]>;
208 def ARMeh_sjlj_setup_dispatch: SDNode<"ARMISD::EH_SJLJ_SETUP_DISPATCH",
209 SDT_ARMEH_SJLJ_SetupDispatch,
210 [SDNPHasChain, SDNPSideEffect]>;
212 def ARMMemBarrierMCR : SDNode<"ARMISD::MEMBARRIER_MCR", SDT_ARMMEMBARRIER,
213 [SDNPHasChain, SDNPSideEffect]>;
214 def ARMPreload : SDNode<"ARMISD::PRELOAD", SDT_ARMPREFETCH,
215 [SDNPHasChain, SDNPMayLoad, SDNPMayStore]>;
217 def ARMtcret : SDNode<"ARMISD::TC_RETURN", SDT_ARMTCRET,
218 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
220 def ARMbfi : SDNode<"ARMISD::BFI", SDT_ARMBFI>;
222 def ARMmemcopy : SDNode<"ARMISD::MEMCPY", SDT_ARMMEMCPY,
223 [SDNPHasChain, SDNPInGlue, SDNPOutGlue,
224 SDNPMayStore, SDNPMayLoad]>;
226 def ARMsmulwb : SDNode<"ARMISD::SMULWB", SDTIntBinOp, []>;
227 def ARMsmulwt : SDNode<"ARMISD::SMULWT", SDTIntBinOp, []>;
228 def ARMsmlalbb : SDNode<"ARMISD::SMLALBB", SDT_LongMac, []>;
229 def ARMsmlalbt : SDNode<"ARMISD::SMLALBT", SDT_LongMac, []>;
230 def ARMsmlaltb : SDNode<"ARMISD::SMLALTB", SDT_LongMac, []>;
231 def ARMsmlaltt : SDNode<"ARMISD::SMLALTT", SDT_LongMac, []>;
233 // Vector operations shared between NEON and MVE
235 def ARMvdup : SDNode<"ARMISD::VDUP", SDTypeProfile<1, 1, [SDTCisVec<0>]>>;
237 // VDUPLANE can produce a quad-register result from a double-register source,
238 // so the result is not constrained to match the source.
239 def ARMvduplane : SDNode<"ARMISD::VDUPLANE",
240 SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisVec<1>,
243 def SDTARMVSHUF : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisSameAs<0, 1>]>;
244 def ARMvrev64 : SDNode<"ARMISD::VREV64", SDTARMVSHUF>;
245 def ARMvrev32 : SDNode<"ARMISD::VREV32", SDTARMVSHUF>;
246 def ARMvrev16 : SDNode<"ARMISD::VREV16", SDTARMVSHUF>;
248 def SDTARMVGETLN : SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisInt<1>,
250 def ARMvgetlaneu : SDNode<"ARMISD::VGETLANEu", SDTARMVGETLN>;
251 def ARMvgetlanes : SDNode<"ARMISD::VGETLANEs", SDTARMVGETLN>;
253 def SDTARMVMOVIMM : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisVT<1, i32>]>;
254 def ARMvmovImm : SDNode<"ARMISD::VMOVIMM", SDTARMVMOVIMM>;
255 def ARMvmvnImm : SDNode<"ARMISD::VMVNIMM", SDTARMVMOVIMM>;
256 def ARMvmovFPImm : SDNode<"ARMISD::VMOVFPIMM", SDTARMVMOVIMM>;
259 def SDTARMVSHIMM : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisSameAs<0, 1>,
261 def SDTARMVSH : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisSameAs<0, 1>,
262 SDTCisSameAs<0, 2>,]>;
263 def ARMvshlImm : SDNode<"ARMISD::VSHLIMM", SDTARMVSHIMM>;
264 def ARMvshrsImm : SDNode<"ARMISD::VSHRsIMM", SDTARMVSHIMM>;
265 def ARMvshruImm : SDNode<"ARMISD::VSHRuIMM", SDTARMVSHIMM>;
266 def ARMvshls : SDNode<"ARMISD::VSHLs", SDTARMVSH>;
267 def ARMvshlu : SDNode<"ARMISD::VSHLu", SDTARMVSH>;
269 def SDTARMVCMP : SDTypeProfile<1, 3, [SDTCisInt<0>, SDTCisSameAs<1, 2>,
271 def SDTARMVCMPZ : SDTypeProfile<1, 2, [SDTCisInt<2>]>;
273 def ARMvcmp : SDNode<"ARMISD::VCMP", SDTARMVCMP>;
274 def ARMvcmpz : SDNode<"ARMISD::VCMPZ", SDTARMVCMPZ>;
276 def ARMWLS : SDNode<"ARMISD::WLS", SDT_ARMLoLoop, [SDNPHasChain]>;
277 def ARMLE : SDNode<"ARMISD::LE", SDT_ARMLoLoop, [SDNPHasChain]>;
278 def ARMLoopDec : SDNode<"ARMISD::LOOP_DEC", SDTIntBinOp, [SDNPHasChain]>;
280 //===----------------------------------------------------------------------===//
281 // ARM Flag Definitions.
283 class RegConstraint<string C> {
284 string Constraints = C;
287 //===----------------------------------------------------------------------===//
288 // ARM specific transformation functions and pattern fragments.
291 // imm_neg_XFORM - Return the negation of an i32 immediate value.
292 def imm_neg_XFORM : SDNodeXForm<imm, [{
293 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), SDLoc(N), MVT::i32);
296 // imm_not_XFORM - Return the complement of a i32 immediate value.
297 def imm_not_XFORM : SDNodeXForm<imm, [{
298 return CurDAG->getTargetConstant(~(int)N->getZExtValue(), SDLoc(N), MVT::i32);
301 /// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
302 def imm16_31 : ImmLeaf<i32, [{
303 return (int32_t)Imm >= 16 && (int32_t)Imm < 32;
306 // sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
307 def sext_16_node : PatLeaf<(i32 GPR:$a), [{
308 return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17;
311 def sext_bottom_16 : PatFrag<(ops node:$a),
312 (sext_inreg node:$a, i16)>;
313 def sext_top_16 : PatFrag<(ops node:$a),
314 (i32 (sra node:$a, (i32 16)))>;
316 def bb_mul : PatFrag<(ops node:$a, node:$b),
317 (mul (sext_bottom_16 node:$a), (sext_bottom_16 node:$b))>;
318 def bt_mul : PatFrag<(ops node:$a, node:$b),
319 (mul (sext_bottom_16 node:$a), (sra node:$b, (i32 16)))>;
320 def tb_mul : PatFrag<(ops node:$a, node:$b),
321 (mul (sra node:$a, (i32 16)), (sext_bottom_16 node:$b))>;
322 def tt_mul : PatFrag<(ops node:$a, node:$b),
323 (mul (sra node:$a, (i32 16)), (sra node:$b, (i32 16)))>;
325 /// Split a 32-bit immediate into two 16 bit parts.
326 def hi16 : SDNodeXForm<imm, [{
327 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, SDLoc(N),
331 def lo16AllZero : PatLeaf<(i32 imm), [{
332 // Returns true if all low 16-bits are 0.
333 return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
336 class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
337 class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
339 // An 'and' node with a single use.
340 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
341 return N->hasOneUse();
344 // An 'xor' node with a single use.
345 def xor_su : PatFrag<(ops node:$lhs, node:$rhs), (xor node:$lhs, node:$rhs), [{
346 return N->hasOneUse();
349 // An 'fmul' node with a single use.
350 def fmul_su : PatFrag<(ops node:$lhs, node:$rhs), (fmul node:$lhs, node:$rhs),[{
351 return N->hasOneUse();
354 // An 'fadd' node which checks for single non-hazardous use.
355 def fadd_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fadd node:$lhs, node:$rhs),[{
356 return hasNoVMLxHazardUse(N);
359 // An 'fsub' node which checks for single non-hazardous use.
360 def fsub_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fsub node:$lhs, node:$rhs),[{
361 return hasNoVMLxHazardUse(N);
364 //===----------------------------------------------------------------------===//
365 // Operand Definitions.
368 // Immediate operands with a shared generic asm render method.
369 class ImmAsmOperand<int Low, int High> : AsmOperandClass {
370 let RenderMethod = "addImmOperands";
371 let PredicateMethod = "isImmediate<" # Low # "," # High # ">";
372 let DiagnosticString = "operand must be an immediate in the range [" # Low # "," # High # "]";
375 class ImmAsmOperandMinusOne<int Low, int High> : AsmOperandClass {
376 let PredicateMethod = "isImmediate<" # Low # "," # High # ">";
377 let DiagnosticType = "ImmRange" # Low # "_" # High;
378 let DiagnosticString = "operand must be an immediate in the range [" # Low # "," # High # "]";
381 // Operands that are part of a memory addressing mode.
382 class MemOperand : Operand<i32> { let OperandType = "OPERAND_MEMORY"; }
385 // FIXME: rename brtarget to t2_brtarget
386 def brtarget : Operand<OtherVT> {
387 let EncoderMethod = "getBranchTargetOpValue";
388 let OperandType = "OPERAND_PCREL";
389 let DecoderMethod = "DecodeT2BROperand";
392 // Branches targeting ARM-mode must be divisible by 4 if they're a raw
394 def ARMBranchTarget : AsmOperandClass {
395 let Name = "ARMBranchTarget";
398 // Branches targeting Thumb-mode must be divisible by 2 if they're a raw
400 def ThumbBranchTarget : AsmOperandClass {
401 let Name = "ThumbBranchTarget";
404 def arm_br_target : Operand<OtherVT> {
405 let ParserMatchClass = ARMBranchTarget;
406 let EncoderMethod = "getARMBranchTargetOpValue";
407 let OperandType = "OPERAND_PCREL";
410 // Call target for ARM. Handles conditional/unconditional
411 // FIXME: rename bl_target to t2_bltarget?
412 def arm_bl_target : Operand<i32> {
413 let ParserMatchClass = ARMBranchTarget;
414 let EncoderMethod = "getARMBLTargetOpValue";
415 let OperandType = "OPERAND_PCREL";
418 // Target for BLX *from* ARM mode.
419 def arm_blx_target : Operand<i32> {
420 let ParserMatchClass = ThumbBranchTarget;
421 let EncoderMethod = "getARMBLXTargetOpValue";
422 let OperandType = "OPERAND_PCREL";
425 // A list of registers separated by comma. Used by load/store multiple.
426 def RegListAsmOperand : AsmOperandClass { let Name = "RegList"; }
427 def reglist : Operand<i32> {
428 let EncoderMethod = "getRegisterListOpValue";
429 let ParserMatchClass = RegListAsmOperand;
430 let PrintMethod = "printRegisterList";
431 let DecoderMethod = "DecodeRegListOperand";
434 // A list of general purpose registers and APSR separated by comma.
436 def RegListWithAPSRAsmOperand : AsmOperandClass { let Name = "RegListWithAPSR"; }
437 def reglist_with_apsr : Operand<i32> {
438 let EncoderMethod = "getRegisterListOpValue";
439 let ParserMatchClass = RegListWithAPSRAsmOperand;
440 let PrintMethod = "printRegisterList";
441 let DecoderMethod = "DecodeRegListOperand";
444 def GPRPairOp : RegisterOperand<GPRPair, "printGPRPairOperand">;
446 def DPRRegListAsmOperand : AsmOperandClass {
447 let Name = "DPRRegList";
448 let DiagnosticType = "DPR_RegList";
450 def dpr_reglist : Operand<i32> {
451 let EncoderMethod = "getRegisterListOpValue";
452 let ParserMatchClass = DPRRegListAsmOperand;
453 let PrintMethod = "printRegisterList";
454 let DecoderMethod = "DecodeDPRRegListOperand";
457 def SPRRegListAsmOperand : AsmOperandClass {
458 let Name = "SPRRegList";
459 let DiagnosticString = "operand must be a list of registers in range [s0, s31]";
461 def spr_reglist : Operand<i32> {
462 let EncoderMethod = "getRegisterListOpValue";
463 let ParserMatchClass = SPRRegListAsmOperand;
464 let PrintMethod = "printRegisterList";
465 let DecoderMethod = "DecodeSPRRegListOperand";
468 def FPSRegListWithVPRAsmOperand : AsmOperandClass { let Name =
469 "FPSRegListWithVPR"; }
470 def fp_sreglist_with_vpr : Operand<i32> {
471 let EncoderMethod = "getRegisterListOpValue";
472 let ParserMatchClass = FPSRegListWithVPRAsmOperand;
473 let PrintMethod = "printRegisterList";
475 def FPDRegListWithVPRAsmOperand : AsmOperandClass { let Name =
476 "FPDRegListWithVPR"; }
477 def fp_dreglist_with_vpr : Operand<i32> {
478 let EncoderMethod = "getRegisterListOpValue";
479 let ParserMatchClass = FPDRegListWithVPRAsmOperand;
480 let PrintMethod = "printRegisterList";
483 // An operand for the CONSTPOOL_ENTRY pseudo-instruction.
484 def cpinst_operand : Operand<i32> {
485 let PrintMethod = "printCPInstOperand";
489 def pclabel : Operand<i32> {
490 let PrintMethod = "printPCLabel";
493 // ADR instruction labels.
494 def AdrLabelAsmOperand : AsmOperandClass { let Name = "AdrLabel"; }
495 def adrlabel : Operand<i32> {
496 let EncoderMethod = "getAdrLabelOpValue";
497 let ParserMatchClass = AdrLabelAsmOperand;
498 let PrintMethod = "printAdrLabelOperand<0>";
501 def neon_vcvt_imm32 : Operand<i32> {
502 let EncoderMethod = "getNEONVcvtImm32OpValue";
503 let DecoderMethod = "DecodeVCVTImmOperand";
506 // rot_imm: An integer that encodes a rotate amount. Must be 8, 16, or 24.
507 def rot_imm_XFORM: SDNodeXForm<imm, [{
508 switch (N->getZExtValue()){
509 default: llvm_unreachable(nullptr);
510 case 0: return CurDAG->getTargetConstant(0, SDLoc(N), MVT::i32);
511 case 8: return CurDAG->getTargetConstant(1, SDLoc(N), MVT::i32);
512 case 16: return CurDAG->getTargetConstant(2, SDLoc(N), MVT::i32);
513 case 24: return CurDAG->getTargetConstant(3, SDLoc(N), MVT::i32);
516 def RotImmAsmOperand : AsmOperandClass {
518 let ParserMethod = "parseRotImm";
520 def rot_imm : Operand<i32>, PatLeaf<(i32 imm), [{
521 int32_t v = N->getZExtValue();
522 return v == 8 || v == 16 || v == 24; }],
524 let PrintMethod = "printRotImmOperand";
525 let ParserMatchClass = RotImmAsmOperand;
528 // Power-of-two operand for MVE VIDUP and friends, which encode
529 // {1,2,4,8} as its log to base 2, i.e. as {0,1,2,3} respectively
530 def MVE_VIDUP_imm_asmoperand : AsmOperandClass {
531 let Name = "VIDUP_imm";
532 let PredicateMethod = "isPowerTwoInRange<1,8>";
533 let RenderMethod = "addPowerTwoOperands";
534 let DiagnosticString = "vector increment immediate must be 1, 2, 4 or 8";
536 def MVE_VIDUP_imm : Operand<i32> {
537 let EncoderMethod = "getPowerTwoOpValue";
538 let DecoderMethod = "DecodePowerTwoOperand<0,3>";
539 let ParserMatchClass = MVE_VIDUP_imm_asmoperand;
542 // Pair vector indexing
543 class MVEPairVectorIndexOperand<string start, string end> : AsmOperandClass {
544 let Name = "MVEPairVectorIndex"#start;
545 let RenderMethod = "addMVEPairVectorIndexOperands";
546 let PredicateMethod = "isMVEPairVectorIndex<"#start#", "#end#">";
549 class MVEPairVectorIndex<string opval> : Operand<i32> {
550 let PrintMethod = "printVectorIndex";
551 let EncoderMethod = "getMVEPairVectorIndexOpValue<"#opval#">";
552 let DecoderMethod = "DecodeMVEPairVectorIndexOperand<"#opval#">";
553 let MIOperandInfo = (ops i32imm);
556 def MVEPairVectorIndex0 : MVEPairVectorIndex<"0"> {
557 let ParserMatchClass = MVEPairVectorIndexOperand<"0", "1">;
560 def MVEPairVectorIndex2 : MVEPairVectorIndex<"2"> {
561 let ParserMatchClass = MVEPairVectorIndexOperand<"2", "3">;
565 class MVEVectorIndexOperand<int NumLanes> : AsmOperandClass {
566 let Name = "MVEVectorIndex"#NumLanes;
567 let RenderMethod = "addMVEVectorIndexOperands";
568 let PredicateMethod = "isVectorIndexInRange<"#NumLanes#">";
571 class MVEVectorIndex<int NumLanes> : Operand<i32> {
572 let PrintMethod = "printVectorIndex";
573 let ParserMatchClass = MVEVectorIndexOperand<NumLanes>;
574 let MIOperandInfo = (ops i32imm);
577 // shift_imm: An integer that encodes a shift amount and the type of shift
578 // (asr or lsl). The 6-bit immediate encodes as:
581 // {4-0} imm5 shift amount.
582 // asr #32 encoded as imm5 == 0.
583 def ShifterImmAsmOperand : AsmOperandClass {
584 let Name = "ShifterImm";
585 let ParserMethod = "parseShifterImm";
587 def shift_imm : Operand<i32> {
588 let PrintMethod = "printShiftImmOperand";
589 let ParserMatchClass = ShifterImmAsmOperand;
592 // shifter_operand operands: so_reg_reg, so_reg_imm, and mod_imm.
593 def ShiftedRegAsmOperand : AsmOperandClass { let Name = "RegShiftedReg"; }
594 def so_reg_reg : Operand<i32>, // reg reg imm
595 ComplexPattern<i32, 3, "SelectRegShifterOperand",
596 [shl, srl, sra, rotr]> {
597 let EncoderMethod = "getSORegRegOpValue";
598 let PrintMethod = "printSORegRegOperand";
599 let DecoderMethod = "DecodeSORegRegOperand";
600 let ParserMatchClass = ShiftedRegAsmOperand;
601 let MIOperandInfo = (ops GPRnopc, GPRnopc, i32imm);
604 def ShiftedImmAsmOperand : AsmOperandClass { let Name = "RegShiftedImm"; }
605 def so_reg_imm : Operand<i32>, // reg imm
606 ComplexPattern<i32, 2, "SelectImmShifterOperand",
607 [shl, srl, sra, rotr]> {
608 let EncoderMethod = "getSORegImmOpValue";
609 let PrintMethod = "printSORegImmOperand";
610 let DecoderMethod = "DecodeSORegImmOperand";
611 let ParserMatchClass = ShiftedImmAsmOperand;
612 let MIOperandInfo = (ops GPR, i32imm);
615 // FIXME: Does this need to be distinct from so_reg?
616 def shift_so_reg_reg : Operand<i32>, // reg reg imm
617 ComplexPattern<i32, 3, "SelectShiftRegShifterOperand",
618 [shl,srl,sra,rotr]> {
619 let EncoderMethod = "getSORegRegOpValue";
620 let PrintMethod = "printSORegRegOperand";
621 let DecoderMethod = "DecodeSORegRegOperand";
622 let ParserMatchClass = ShiftedRegAsmOperand;
623 let MIOperandInfo = (ops GPR, GPR, i32imm);
626 // FIXME: Does this need to be distinct from so_reg?
627 def shift_so_reg_imm : Operand<i32>, // reg reg imm
628 ComplexPattern<i32, 2, "SelectShiftImmShifterOperand",
629 [shl,srl,sra,rotr]> {
630 let EncoderMethod = "getSORegImmOpValue";
631 let PrintMethod = "printSORegImmOperand";
632 let DecoderMethod = "DecodeSORegImmOperand";
633 let ParserMatchClass = ShiftedImmAsmOperand;
634 let MIOperandInfo = (ops GPR, i32imm);
637 // mod_imm: match a 32-bit immediate operand, which can be encoded into
638 // a 12-bit immediate; an 8-bit integer and a 4-bit rotator (See ARMARM
639 // - "Modified Immediate Constants"). Within the MC layer we keep this
640 // immediate in its encoded form.
641 def ModImmAsmOperand: AsmOperandClass {
643 let ParserMethod = "parseModImm";
645 def mod_imm : Operand<i32>, ImmLeaf<i32, [{
646 return ARM_AM::getSOImmVal(Imm) != -1;
648 let EncoderMethod = "getModImmOpValue";
649 let PrintMethod = "printModImmOperand";
650 let ParserMatchClass = ModImmAsmOperand;
653 // Note: the patterns mod_imm_not and mod_imm_neg do not require an encoder
654 // method and such, as they are only used on aliases (Pat<> and InstAlias<>).
655 // The actual parsing, encoding, decoding are handled by the destination
656 // instructions, which use mod_imm.
658 def ModImmNotAsmOperand : AsmOperandClass { let Name = "ModImmNot"; }
659 def mod_imm_not : Operand<i32>, PatLeaf<(imm), [{
660 return ARM_AM::getSOImmVal(~(uint32_t)N->getZExtValue()) != -1;
662 let ParserMatchClass = ModImmNotAsmOperand;
665 def ModImmNegAsmOperand : AsmOperandClass { let Name = "ModImmNeg"; }
666 def mod_imm_neg : Operand<i32>, PatLeaf<(imm), [{
667 unsigned Value = -(unsigned)N->getZExtValue();
668 return Value && ARM_AM::getSOImmVal(Value) != -1;
670 let ParserMatchClass = ModImmNegAsmOperand;
673 /// arm_i32imm - True for +V6T2, or when isSOImmTwoParVal()
674 def arm_i32imm : IntImmLeaf<i32, [{
675 if (Subtarget->useMovt())
677 return ARM_AM::isSOImmTwoPartVal(Imm.getZExtValue());
680 /// imm0_1 predicate - Immediate in the range [0,1].
681 def Imm0_1AsmOperand: ImmAsmOperand<0,1> { let Name = "Imm0_1"; }
682 def imm0_1 : Operand<i32> { let ParserMatchClass = Imm0_1AsmOperand; }
684 /// imm0_3 predicate - Immediate in the range [0,3].
685 def Imm0_3AsmOperand: ImmAsmOperand<0,3> { let Name = "Imm0_3"; }
686 def imm0_3 : Operand<i32> { let ParserMatchClass = Imm0_3AsmOperand; }
688 /// imm0_7 predicate - Immediate in the range [0,7].
689 def Imm0_7AsmOperand: ImmAsmOperand<0,7> {
692 def imm0_7 : Operand<i32>, ImmLeaf<i32, [{
693 return Imm >= 0 && Imm < 8;
695 let ParserMatchClass = Imm0_7AsmOperand;
698 /// imm8_255 predicate - Immediate in the range [8,255].
699 def Imm8_255AsmOperand: ImmAsmOperand<8,255> { let Name = "Imm8_255"; }
700 def imm8_255 : Operand<i32>, ImmLeaf<i32, [{
701 return Imm >= 8 && Imm < 256;
703 let ParserMatchClass = Imm8_255AsmOperand;
706 /// imm8 predicate - Immediate is exactly 8.
707 def Imm8AsmOperand: ImmAsmOperand<8,8> { let Name = "Imm8"; }
708 def imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 8; }]> {
709 let ParserMatchClass = Imm8AsmOperand;
712 /// imm16 predicate - Immediate is exactly 16.
713 def Imm16AsmOperand: ImmAsmOperand<16,16> { let Name = "Imm16"; }
714 def imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 16; }]> {
715 let ParserMatchClass = Imm16AsmOperand;
718 /// imm32 predicate - Immediate is exactly 32.
719 def Imm32AsmOperand: ImmAsmOperand<32,32> { let Name = "Imm32"; }
720 def imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 32; }]> {
721 let ParserMatchClass = Imm32AsmOperand;
724 def imm8_or_16 : ImmLeaf<i32, [{ return Imm == 8 || Imm == 16;}]>;
726 /// imm1_7 predicate - Immediate in the range [1,7].
727 def Imm1_7AsmOperand: ImmAsmOperand<1,7> { let Name = "Imm1_7"; }
728 def imm1_7 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 8; }]> {
729 let ParserMatchClass = Imm1_7AsmOperand;
732 /// imm1_15 predicate - Immediate in the range [1,15].
733 def Imm1_15AsmOperand: ImmAsmOperand<1,15> { let Name = "Imm1_15"; }
734 def imm1_15 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 16; }]> {
735 let ParserMatchClass = Imm1_15AsmOperand;
738 /// imm1_31 predicate - Immediate in the range [1,31].
739 def Imm1_31AsmOperand: ImmAsmOperand<1,31> { let Name = "Imm1_31"; }
740 def imm1_31 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 32; }]> {
741 let ParserMatchClass = Imm1_31AsmOperand;
744 /// imm0_15 predicate - Immediate in the range [0,15].
745 def Imm0_15AsmOperand: ImmAsmOperand<0,15> {
746 let Name = "Imm0_15";
748 def imm0_15 : Operand<i32>, ImmLeaf<i32, [{
749 return Imm >= 0 && Imm < 16;
751 let ParserMatchClass = Imm0_15AsmOperand;
754 /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
755 def Imm0_31AsmOperand: ImmAsmOperand<0,31> { let Name = "Imm0_31"; }
756 def imm0_31 : Operand<i32>, ImmLeaf<i32, [{
757 return Imm >= 0 && Imm < 32;
759 let ParserMatchClass = Imm0_31AsmOperand;
762 /// imm0_32 predicate - True if the 32-bit immediate is in the range [0,32].
763 def Imm0_32AsmOperand: ImmAsmOperand<0,32> { let Name = "Imm0_32"; }
764 def imm0_32 : Operand<i32>, ImmLeaf<i32, [{
765 return Imm >= 0 && Imm < 33;
767 let ParserMatchClass = Imm0_32AsmOperand;
770 /// imm0_63 predicate - True if the 32-bit immediate is in the range [0,63].
771 def Imm0_63AsmOperand: ImmAsmOperand<0,63> { let Name = "Imm0_63"; }
772 def imm0_63 : Operand<i32>, ImmLeaf<i32, [{
773 return Imm >= 0 && Imm < 64;
775 let ParserMatchClass = Imm0_63AsmOperand;
778 /// imm0_239 predicate - Immediate in the range [0,239].
779 def Imm0_239AsmOperand : ImmAsmOperand<0,239> {
780 let Name = "Imm0_239";
782 def imm0_239 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 240; }]> {
783 let ParserMatchClass = Imm0_239AsmOperand;
786 /// imm0_255 predicate - Immediate in the range [0,255].
787 def Imm0_255AsmOperand : ImmAsmOperand<0,255> { let Name = "Imm0_255"; }
788 def imm0_255 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 256; }]> {
789 let ParserMatchClass = Imm0_255AsmOperand;
792 /// imm0_65535 - An immediate is in the range [0,65535].
793 def Imm0_65535AsmOperand: ImmAsmOperand<0,65535> { let Name = "Imm0_65535"; }
794 def imm0_65535 : Operand<i32>, ImmLeaf<i32, [{
795 return Imm >= 0 && Imm < 65536;
797 let ParserMatchClass = Imm0_65535AsmOperand;
800 // imm0_65535_neg - An immediate whose negative value is in the range [0.65535].
801 def imm0_65535_neg : Operand<i32>, ImmLeaf<i32, [{
802 return -Imm >= 0 && -Imm < 65536;
805 // imm0_65535_expr - For movt/movw - 16-bit immediate that can also reference
806 // a relocatable expression.
808 // FIXME: This really needs a Thumb version separate from the ARM version.
809 // While the range is the same, and can thus use the same match class,
810 // the encoding is different so it should have a different encoder method.
811 def Imm0_65535ExprAsmOperand: AsmOperandClass {
812 let Name = "Imm0_65535Expr";
813 let RenderMethod = "addImmOperands";
814 let DiagnosticString = "operand must be an immediate in the range [0,0xffff] or a relocatable expression";
817 def imm0_65535_expr : Operand<i32> {
818 let EncoderMethod = "getHiLo16ImmOpValue";
819 let ParserMatchClass = Imm0_65535ExprAsmOperand;
822 def Imm256_65535ExprAsmOperand: ImmAsmOperand<256,65535> { let Name = "Imm256_65535Expr"; }
823 def imm256_65535_expr : Operand<i32> {
824 let ParserMatchClass = Imm256_65535ExprAsmOperand;
827 /// imm24b - True if the 32-bit immediate is encodable in 24 bits.
828 def Imm24bitAsmOperand: ImmAsmOperand<0,0xffffff> {
829 let Name = "Imm24bit";
830 let DiagnosticString = "operand must be an immediate in the range [0,0xffffff]";
832 def imm24b : Operand<i32>, ImmLeaf<i32, [{
833 return Imm >= 0 && Imm <= 0xffffff;
835 let ParserMatchClass = Imm24bitAsmOperand;
839 /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
841 def BitfieldAsmOperand : AsmOperandClass {
842 let Name = "Bitfield";
843 let ParserMethod = "parseBitfield";
846 def bf_inv_mask_imm : Operand<i32>,
848 return ARM::isBitFieldInvertedMask(N->getZExtValue());
850 let EncoderMethod = "getBitfieldInvertedMaskOpValue";
851 let PrintMethod = "printBitfieldInvMaskImmOperand";
852 let DecoderMethod = "DecodeBitfieldMaskOperand";
853 let ParserMatchClass = BitfieldAsmOperand;
854 let GISelPredicateCode = [{
855 // There's better methods of implementing this check. IntImmLeaf<> would be
856 // equivalent and have less boilerplate but we need a test for C++
857 // predicates and this one causes new rules to be imported into GlobalISel
858 // without requiring additional features first.
859 const auto &MO = MI.getOperand(1);
862 return ARM::isBitFieldInvertedMask(MO.getCImm()->getZExtValue());
866 def imm1_32_XFORM: SDNodeXForm<imm, [{
867 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, SDLoc(N),
870 def Imm1_32AsmOperand: ImmAsmOperandMinusOne<1,32> {
871 let Name = "Imm1_32";
873 def imm1_32 : Operand<i32>, PatLeaf<(imm), [{
874 uint64_t Imm = N->getZExtValue();
875 return Imm > 0 && Imm <= 32;
878 let PrintMethod = "printImmPlusOneOperand";
879 let ParserMatchClass = Imm1_32AsmOperand;
882 def imm1_16_XFORM: SDNodeXForm<imm, [{
883 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, SDLoc(N),
886 def Imm1_16AsmOperand: ImmAsmOperandMinusOne<1,16> { let Name = "Imm1_16"; }
887 def imm1_16 : Operand<i32>, ImmLeaf<i32, [{
888 return Imm > 0 && Imm <= 16;
891 let PrintMethod = "printImmPlusOneOperand";
892 let ParserMatchClass = Imm1_16AsmOperand;
895 def MVEShiftImm1_7AsmOperand: ImmAsmOperand<1,7> {
896 let Name = "MVEShiftImm1_7";
897 // Reason we're doing this is because instruction vshll.s8 t1 encoding
898 // accepts 1,7 but the t2 encoding accepts 8. By doing this we can get a
899 // better diagnostic message if someone uses bigger immediate than the t1/t2
901 let DiagnosticString = "operand must be an immediate in the range [1,8]";
903 def mve_shift_imm1_7 : Operand<i32> {
904 let ParserMatchClass = MVEShiftImm1_7AsmOperand;
905 let EncoderMethod = "getMVEShiftImmOpValue";
908 def MVEShiftImm1_15AsmOperand: ImmAsmOperand<1,15> {
909 let Name = "MVEShiftImm1_15";
910 // Reason we're doing this is because instruction vshll.s16 t1 encoding
911 // accepts 1,15 but the t2 encoding accepts 16. By doing this we can get a
912 // better diagnostic message if someone uses bigger immediate than the t1/t2
914 let DiagnosticString = "operand must be an immediate in the range [1,16]";
916 def mve_shift_imm1_15 : Operand<i32> {
917 let ParserMatchClass = MVEShiftImm1_15AsmOperand;
918 let EncoderMethod = "getMVEShiftImmOpValue";
921 // Define ARM specific addressing modes.
922 // addrmode_imm12 := reg +/- imm12
924 def MemImm12OffsetAsmOperand : AsmOperandClass { let Name = "MemImm12Offset"; }
925 class AddrMode_Imm12 : MemOperand,
926 ComplexPattern<i32, 2, "SelectAddrModeImm12", []> {
927 // 12-bit immediate operand. Note that instructions using this encode
928 // #0 and #-0 differently. We flag #-0 as the magic value INT32_MIN. All other
929 // immediate values are as normal.
931 let EncoderMethod = "getAddrModeImm12OpValue";
932 let DecoderMethod = "DecodeAddrModeImm12Operand";
933 let ParserMatchClass = MemImm12OffsetAsmOperand;
934 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
937 def addrmode_imm12 : AddrMode_Imm12 {
938 let PrintMethod = "printAddrModeImm12Operand<false>";
941 def addrmode_imm12_pre : AddrMode_Imm12 {
942 let PrintMethod = "printAddrModeImm12Operand<true>";
945 // ldst_so_reg := reg +/- reg shop imm
947 def MemRegOffsetAsmOperand : AsmOperandClass { let Name = "MemRegOffset"; }
948 def ldst_so_reg : MemOperand,
949 ComplexPattern<i32, 3, "SelectLdStSOReg", []> {
950 let EncoderMethod = "getLdStSORegOpValue";
951 // FIXME: Simplify the printer
952 let PrintMethod = "printAddrMode2Operand";
953 let DecoderMethod = "DecodeSORegMemOperand";
954 let ParserMatchClass = MemRegOffsetAsmOperand;
955 let MIOperandInfo = (ops GPR:$base, GPRnopc:$offsreg, i32imm:$shift);
958 // postidx_imm8 := +/- [0,255]
961 // {8} 1 is imm8 is non-negative. 0 otherwise.
962 // {7-0} [0,255] imm8 value.
963 def PostIdxImm8AsmOperand : AsmOperandClass { let Name = "PostIdxImm8"; }
964 def postidx_imm8 : MemOperand {
965 let PrintMethod = "printPostIdxImm8Operand";
966 let ParserMatchClass = PostIdxImm8AsmOperand;
967 let MIOperandInfo = (ops i32imm);
970 // postidx_imm8s4 := +/- [0,1020]
973 // {8} 1 is imm8 is non-negative. 0 otherwise.
974 // {7-0} [0,255] imm8 value, scaled by 4.
975 def PostIdxImm8s4AsmOperand : AsmOperandClass { let Name = "PostIdxImm8s4"; }
976 def postidx_imm8s4 : MemOperand {
977 let PrintMethod = "printPostIdxImm8s4Operand";
978 let ParserMatchClass = PostIdxImm8s4AsmOperand;
979 let MIOperandInfo = (ops i32imm);
983 // postidx_reg := +/- reg
985 def PostIdxRegAsmOperand : AsmOperandClass {
986 let Name = "PostIdxReg";
987 let ParserMethod = "parsePostIdxReg";
989 def postidx_reg : MemOperand {
990 let EncoderMethod = "getPostIdxRegOpValue";
991 let DecoderMethod = "DecodePostIdxReg";
992 let PrintMethod = "printPostIdxRegOperand";
993 let ParserMatchClass = PostIdxRegAsmOperand;
994 let MIOperandInfo = (ops GPRnopc, i32imm);
997 def PostIdxRegShiftedAsmOperand : AsmOperandClass {
998 let Name = "PostIdxRegShifted";
999 let ParserMethod = "parsePostIdxReg";
1001 def am2offset_reg : MemOperand,
1002 ComplexPattern<i32, 2, "SelectAddrMode2OffsetReg",
1003 [], [SDNPWantRoot]> {
1004 let EncoderMethod = "getAddrMode2OffsetOpValue";
1005 let PrintMethod = "printAddrMode2OffsetOperand";
1006 // When using this for assembly, it's always as a post-index offset.
1007 let ParserMatchClass = PostIdxRegShiftedAsmOperand;
1008 let MIOperandInfo = (ops GPRnopc, i32imm);
1011 // FIXME: am2offset_imm should only need the immediate, not the GPR. Having
1012 // the GPR is purely vestigal at this point.
1013 def AM2OffsetImmAsmOperand : AsmOperandClass { let Name = "AM2OffsetImm"; }
1014 def am2offset_imm : MemOperand,
1015 ComplexPattern<i32, 2, "SelectAddrMode2OffsetImm",
1016 [], [SDNPWantRoot]> {
1017 let EncoderMethod = "getAddrMode2OffsetOpValue";
1018 let PrintMethod = "printAddrMode2OffsetOperand";
1019 let ParserMatchClass = AM2OffsetImmAsmOperand;
1020 let MIOperandInfo = (ops GPRnopc, i32imm);
1024 // addrmode3 := reg +/- reg
1025 // addrmode3 := reg +/- imm8
1027 // FIXME: split into imm vs. reg versions.
1028 def AddrMode3AsmOperand : AsmOperandClass { let Name = "AddrMode3"; }
1029 class AddrMode3 : MemOperand,
1030 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
1031 let EncoderMethod = "getAddrMode3OpValue";
1032 let ParserMatchClass = AddrMode3AsmOperand;
1033 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
1036 def addrmode3 : AddrMode3
1038 let PrintMethod = "printAddrMode3Operand<false>";
1041 def addrmode3_pre : AddrMode3
1043 let PrintMethod = "printAddrMode3Operand<true>";
1046 // FIXME: split into imm vs. reg versions.
1047 // FIXME: parser method to handle +/- register.
1048 def AM3OffsetAsmOperand : AsmOperandClass {
1049 let Name = "AM3Offset";
1050 let ParserMethod = "parseAM3Offset";
1052 def am3offset : MemOperand,
1053 ComplexPattern<i32, 2, "SelectAddrMode3Offset",
1054 [], [SDNPWantRoot]> {
1055 let EncoderMethod = "getAddrMode3OffsetOpValue";
1056 let PrintMethod = "printAddrMode3OffsetOperand";
1057 let ParserMatchClass = AM3OffsetAsmOperand;
1058 let MIOperandInfo = (ops GPR, i32imm);
1061 // ldstm_mode := {ia, ib, da, db}
1063 def ldstm_mode : OptionalDefOperand<OtherVT, (ops i32), (ops (i32 1))> {
1064 let EncoderMethod = "getLdStmModeOpValue";
1065 let PrintMethod = "printLdStmModeOperand";
1068 // addrmode5 := reg +/- imm8*4
1070 def AddrMode5AsmOperand : AsmOperandClass { let Name = "AddrMode5"; }
1071 class AddrMode5 : MemOperand,
1072 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
1073 let EncoderMethod = "getAddrMode5OpValue";
1074 let DecoderMethod = "DecodeAddrMode5Operand";
1075 let ParserMatchClass = AddrMode5AsmOperand;
1076 let MIOperandInfo = (ops GPR:$base, i32imm);
1079 def addrmode5 : AddrMode5 {
1080 let PrintMethod = "printAddrMode5Operand<false>";
1083 def addrmode5_pre : AddrMode5 {
1084 let PrintMethod = "printAddrMode5Operand<true>";
1087 // addrmode5fp16 := reg +/- imm8*2
1089 def AddrMode5FP16AsmOperand : AsmOperandClass { let Name = "AddrMode5FP16"; }
1090 class AddrMode5FP16 : Operand<i32>,
1091 ComplexPattern<i32, 2, "SelectAddrMode5FP16", []> {
1092 let EncoderMethod = "getAddrMode5FP16OpValue";
1093 let DecoderMethod = "DecodeAddrMode5FP16Operand";
1094 let ParserMatchClass = AddrMode5FP16AsmOperand;
1095 let MIOperandInfo = (ops GPR:$base, i32imm);
1098 def addrmode5fp16 : AddrMode5FP16 {
1099 let PrintMethod = "printAddrMode5FP16Operand<false>";
1102 // addrmode6 := reg with optional alignment
1104 def AddrMode6AsmOperand : AsmOperandClass { let Name = "AlignedMemory"; }
1105 def addrmode6 : MemOperand,
1106 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1107 let PrintMethod = "printAddrMode6Operand";
1108 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
1109 let EncoderMethod = "getAddrMode6AddressOpValue";
1110 let DecoderMethod = "DecodeAddrMode6Operand";
1111 let ParserMatchClass = AddrMode6AsmOperand;
1114 def am6offset : MemOperand,
1115 ComplexPattern<i32, 1, "SelectAddrMode6Offset",
1116 [], [SDNPWantRoot]> {
1117 let PrintMethod = "printAddrMode6OffsetOperand";
1118 let MIOperandInfo = (ops GPR);
1119 let EncoderMethod = "getAddrMode6OffsetOpValue";
1120 let DecoderMethod = "DecodeGPRRegisterClass";
1123 // Special version of addrmode6 to handle alignment encoding for VST1/VLD1
1124 // (single element from one lane) for size 32.
1125 def addrmode6oneL32 : MemOperand,
1126 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1127 let PrintMethod = "printAddrMode6Operand";
1128 let MIOperandInfo = (ops GPR:$addr, i32imm);
1129 let EncoderMethod = "getAddrMode6OneLane32AddressOpValue";
1132 // Base class for addrmode6 with specific alignment restrictions.
1133 class AddrMode6Align : MemOperand,
1134 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1135 let PrintMethod = "printAddrMode6Operand";
1136 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
1137 let EncoderMethod = "getAddrMode6AddressOpValue";
1138 let DecoderMethod = "DecodeAddrMode6Operand";
1141 // Special version of addrmode6 to handle no allowed alignment encoding for
1142 // VLD/VST instructions and checking the alignment is not specified.
1143 def AddrMode6AlignNoneAsmOperand : AsmOperandClass {
1144 let Name = "AlignedMemoryNone";
1145 let DiagnosticString = "alignment must be omitted";
1147 def addrmode6alignNone : AddrMode6Align {
1148 // The alignment specifier can only be omitted.
1149 let ParserMatchClass = AddrMode6AlignNoneAsmOperand;
1152 // Special version of addrmode6 to handle 16-bit alignment encoding for
1153 // VLD/VST instructions and checking the alignment value.
1154 def AddrMode6Align16AsmOperand : AsmOperandClass {
1155 let Name = "AlignedMemory16";
1156 let DiagnosticString = "alignment must be 16 or omitted";
1158 def addrmode6align16 : AddrMode6Align {
1159 // The alignment specifier can only be 16 or omitted.
1160 let ParserMatchClass = AddrMode6Align16AsmOperand;
1163 // Special version of addrmode6 to handle 32-bit alignment encoding for
1164 // VLD/VST instructions and checking the alignment value.
1165 def AddrMode6Align32AsmOperand : AsmOperandClass {
1166 let Name = "AlignedMemory32";
1167 let DiagnosticString = "alignment must be 32 or omitted";
1169 def addrmode6align32 : AddrMode6Align {
1170 // The alignment specifier can only be 32 or omitted.
1171 let ParserMatchClass = AddrMode6Align32AsmOperand;
1174 // Special version of addrmode6 to handle 64-bit alignment encoding for
1175 // VLD/VST instructions and checking the alignment value.
1176 def AddrMode6Align64AsmOperand : AsmOperandClass {
1177 let Name = "AlignedMemory64";
1178 let DiagnosticString = "alignment must be 64 or omitted";
1180 def addrmode6align64 : AddrMode6Align {
1181 // The alignment specifier can only be 64 or omitted.
1182 let ParserMatchClass = AddrMode6Align64AsmOperand;
1185 // Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding
1186 // for VLD/VST instructions and checking the alignment value.
1187 def AddrMode6Align64or128AsmOperand : AsmOperandClass {
1188 let Name = "AlignedMemory64or128";
1189 let DiagnosticString = "alignment must be 64, 128 or omitted";
1191 def addrmode6align64or128 : AddrMode6Align {
1192 // The alignment specifier can only be 64, 128 or omitted.
1193 let ParserMatchClass = AddrMode6Align64or128AsmOperand;
1196 // Special version of addrmode6 to handle 64-bit, 128-bit or 256-bit alignment
1197 // encoding for VLD/VST instructions and checking the alignment value.
1198 def AddrMode6Align64or128or256AsmOperand : AsmOperandClass {
1199 let Name = "AlignedMemory64or128or256";
1200 let DiagnosticString = "alignment must be 64, 128, 256 or omitted";
1202 def addrmode6align64or128or256 : AddrMode6Align {
1203 // The alignment specifier can only be 64, 128, 256 or omitted.
1204 let ParserMatchClass = AddrMode6Align64or128or256AsmOperand;
1207 // Special version of addrmode6 to handle alignment encoding for VLD-dup
1208 // instructions, specifically VLD4-dup.
1209 def addrmode6dup : MemOperand,
1210 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1211 let PrintMethod = "printAddrMode6Operand";
1212 let MIOperandInfo = (ops GPR:$addr, i32imm);
1213 let EncoderMethod = "getAddrMode6DupAddressOpValue";
1214 // FIXME: This is close, but not quite right. The alignment specifier is
1216 let ParserMatchClass = AddrMode6AsmOperand;
1219 // Base class for addrmode6dup with specific alignment restrictions.
1220 class AddrMode6DupAlign : MemOperand,
1221 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1222 let PrintMethod = "printAddrMode6Operand";
1223 let MIOperandInfo = (ops GPR:$addr, i32imm);
1224 let EncoderMethod = "getAddrMode6DupAddressOpValue";
1227 // Special version of addrmode6 to handle no allowed alignment encoding for
1228 // VLD-dup instruction and checking the alignment is not specified.
1229 def AddrMode6dupAlignNoneAsmOperand : AsmOperandClass {
1230 let Name = "DupAlignedMemoryNone";
1231 let DiagnosticString = "alignment must be omitted";
1233 def addrmode6dupalignNone : AddrMode6DupAlign {
1234 // The alignment specifier can only be omitted.
1235 let ParserMatchClass = AddrMode6dupAlignNoneAsmOperand;
1238 // Special version of addrmode6 to handle 16-bit alignment encoding for VLD-dup
1239 // instruction and checking the alignment value.
1240 def AddrMode6dupAlign16AsmOperand : AsmOperandClass {
1241 let Name = "DupAlignedMemory16";
1242 let DiagnosticString = "alignment must be 16 or omitted";
1244 def addrmode6dupalign16 : AddrMode6DupAlign {
1245 // The alignment specifier can only be 16 or omitted.
1246 let ParserMatchClass = AddrMode6dupAlign16AsmOperand;
1249 // Special version of addrmode6 to handle 32-bit alignment encoding for VLD-dup
1250 // instruction and checking the alignment value.
1251 def AddrMode6dupAlign32AsmOperand : AsmOperandClass {
1252 let Name = "DupAlignedMemory32";
1253 let DiagnosticString = "alignment must be 32 or omitted";
1255 def addrmode6dupalign32 : AddrMode6DupAlign {
1256 // The alignment specifier can only be 32 or omitted.
1257 let ParserMatchClass = AddrMode6dupAlign32AsmOperand;
1260 // Special version of addrmode6 to handle 64-bit alignment encoding for VLD
1261 // instructions and checking the alignment value.
1262 def AddrMode6dupAlign64AsmOperand : AsmOperandClass {
1263 let Name = "DupAlignedMemory64";
1264 let DiagnosticString = "alignment must be 64 or omitted";
1266 def addrmode6dupalign64 : AddrMode6DupAlign {
1267 // The alignment specifier can only be 64 or omitted.
1268 let ParserMatchClass = AddrMode6dupAlign64AsmOperand;
1271 // Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding
1272 // for VLD instructions and checking the alignment value.
1273 def AddrMode6dupAlign64or128AsmOperand : AsmOperandClass {
1274 let Name = "DupAlignedMemory64or128";
1275 let DiagnosticString = "alignment must be 64, 128 or omitted";
1277 def addrmode6dupalign64or128 : AddrMode6DupAlign {
1278 // The alignment specifier can only be 64, 128 or omitted.
1279 let ParserMatchClass = AddrMode6dupAlign64or128AsmOperand;
1282 // addrmodepc := pc + reg
1284 def addrmodepc : MemOperand,
1285 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
1286 let PrintMethod = "printAddrModePCOperand";
1287 let MIOperandInfo = (ops GPR, i32imm);
1290 // addr_offset_none := reg
1292 def MemNoOffsetAsmOperand : AsmOperandClass { let Name = "MemNoOffset"; }
1293 def addr_offset_none : MemOperand,
1294 ComplexPattern<i32, 1, "SelectAddrOffsetNone", []> {
1295 let PrintMethod = "printAddrMode7Operand";
1296 let DecoderMethod = "DecodeAddrMode7Operand";
1297 let ParserMatchClass = MemNoOffsetAsmOperand;
1298 let MIOperandInfo = (ops GPR:$base);
1301 // t_addr_offset_none := reg [r0-r7]
1302 def MemNoOffsetTAsmOperand : AsmOperandClass { let Name = "MemNoOffsetT"; }
1303 def t_addr_offset_none : MemOperand {
1304 let PrintMethod = "printAddrMode7Operand";
1305 let DecoderMethod = "DecodetGPRRegisterClass";
1306 let ParserMatchClass = MemNoOffsetTAsmOperand;
1307 let MIOperandInfo = (ops tGPR:$base);
1310 def nohash_imm : Operand<i32> {
1311 let PrintMethod = "printNoHashImmediate";
1314 def CoprocNumAsmOperand : AsmOperandClass {
1315 let Name = "CoprocNum";
1316 let ParserMethod = "parseCoprocNumOperand";
1318 def p_imm : Operand<i32> {
1319 let PrintMethod = "printPImmediate";
1320 let ParserMatchClass = CoprocNumAsmOperand;
1321 let DecoderMethod = "DecodeCoprocessor";
1324 def CoprocRegAsmOperand : AsmOperandClass {
1325 let Name = "CoprocReg";
1326 let ParserMethod = "parseCoprocRegOperand";
1328 def c_imm : Operand<i32> {
1329 let PrintMethod = "printCImmediate";
1330 let ParserMatchClass = CoprocRegAsmOperand;
1332 def CoprocOptionAsmOperand : AsmOperandClass {
1333 let Name = "CoprocOption";
1334 let ParserMethod = "parseCoprocOptionOperand";
1336 def coproc_option_imm : Operand<i32> {
1337 let PrintMethod = "printCoprocOptionImm";
1338 let ParserMatchClass = CoprocOptionAsmOperand;
1341 //===----------------------------------------------------------------------===//
1343 include "ARMInstrFormats.td"
1345 //===----------------------------------------------------------------------===//
1346 // Multiclass helpers...
1349 /// AsI1_bin_irs - Defines a set of (op r, {mod_imm|r|so_reg}) patterns for a
1350 /// binop that produces a value.
1351 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1352 multiclass AsI1_bin_irs<bits<4> opcod, string opc,
1353 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1354 SDPatternOperator opnode, bit Commutable = 0> {
1355 // The register-immediate version is re-materializable. This is useful
1356 // in particular for taking the address of a local.
1357 let isReMaterializable = 1 in {
1358 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm,
1359 iii, opc, "\t$Rd, $Rn, $imm",
1360 [(set GPR:$Rd, (opnode GPR:$Rn, mod_imm:$imm))]>,
1361 Sched<[WriteALU, ReadALU]> {
1366 let Inst{19-16} = Rn;
1367 let Inst{15-12} = Rd;
1368 let Inst{11-0} = imm;
1371 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1372 iir, opc, "\t$Rd, $Rn, $Rm",
1373 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]>,
1374 Sched<[WriteALU, ReadALU, ReadALU]> {
1379 let isCommutable = Commutable;
1380 let Inst{19-16} = Rn;
1381 let Inst{15-12} = Rd;
1382 let Inst{11-4} = 0b00000000;
1386 def rsi : AsI1<opcod, (outs GPR:$Rd),
1387 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1388 iis, opc, "\t$Rd, $Rn, $shift",
1389 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_imm:$shift))]>,
1390 Sched<[WriteALUsi, ReadALU]> {
1395 let Inst{19-16} = Rn;
1396 let Inst{15-12} = Rd;
1397 let Inst{11-5} = shift{11-5};
1399 let Inst{3-0} = shift{3-0};
1402 def rsr : AsI1<opcod, (outs GPR:$Rd),
1403 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1404 iis, opc, "\t$Rd, $Rn, $shift",
1405 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_reg:$shift))]>,
1406 Sched<[WriteALUsr, ReadALUsr]> {
1411 let Inst{19-16} = Rn;
1412 let Inst{15-12} = Rd;
1413 let Inst{11-8} = shift{11-8};
1415 let Inst{6-5} = shift{6-5};
1417 let Inst{3-0} = shift{3-0};
1421 /// AsI1_rbin_irs - Same as AsI1_bin_irs except the order of operands are
1422 /// reversed. The 'rr' form is only defined for the disassembler; for codegen
1423 /// it is equivalent to the AsI1_bin_irs counterpart.
1424 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1425 multiclass AsI1_rbin_irs<bits<4> opcod, string opc,
1426 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1427 SDNode opnode, bit Commutable = 0> {
1428 // The register-immediate version is re-materializable. This is useful
1429 // in particular for taking the address of a local.
1430 let isReMaterializable = 1 in {
1431 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm,
1432 iii, opc, "\t$Rd, $Rn, $imm",
1433 [(set GPR:$Rd, (opnode mod_imm:$imm, GPR:$Rn))]>,
1434 Sched<[WriteALU, ReadALU]> {
1439 let Inst{19-16} = Rn;
1440 let Inst{15-12} = Rd;
1441 let Inst{11-0} = imm;
1444 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1445 iir, opc, "\t$Rd, $Rn, $Rm",
1446 [/* pattern left blank */]>,
1447 Sched<[WriteALU, ReadALU, ReadALU]> {
1451 let Inst{11-4} = 0b00000000;
1454 let Inst{15-12} = Rd;
1455 let Inst{19-16} = Rn;
1458 def rsi : AsI1<opcod, (outs GPR:$Rd),
1459 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1460 iis, opc, "\t$Rd, $Rn, $shift",
1461 [(set GPR:$Rd, (opnode so_reg_imm:$shift, GPR:$Rn))]>,
1462 Sched<[WriteALUsi, ReadALU]> {
1467 let Inst{19-16} = Rn;
1468 let Inst{15-12} = Rd;
1469 let Inst{11-5} = shift{11-5};
1471 let Inst{3-0} = shift{3-0};
1474 def rsr : AsI1<opcod, (outs GPR:$Rd),
1475 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1476 iis, opc, "\t$Rd, $Rn, $shift",
1477 [(set GPR:$Rd, (opnode so_reg_reg:$shift, GPR:$Rn))]>,
1478 Sched<[WriteALUsr, ReadALUsr]> {
1483 let Inst{19-16} = Rn;
1484 let Inst{15-12} = Rd;
1485 let Inst{11-8} = shift{11-8};
1487 let Inst{6-5} = shift{6-5};
1489 let Inst{3-0} = shift{3-0};
1493 /// AsI1_bin_s_irs - Same as AsI1_bin_irs except it sets the 's' bit by default.
1495 /// These opcodes will be converted to the real non-S opcodes by
1496 /// AdjustInstrPostInstrSelection after giving them an optional CPSR operand.
1497 let hasPostISelHook = 1, Defs = [CPSR] in {
1498 multiclass AsI1_bin_s_irs<InstrItinClass iii, InstrItinClass iir,
1499 InstrItinClass iis, SDNode opnode,
1500 bit Commutable = 0> {
1501 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p),
1503 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm))]>,
1504 Sched<[WriteALU, ReadALU]>;
1506 def rr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, pred:$p),
1508 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm))]>,
1509 Sched<[WriteALU, ReadALU, ReadALU]> {
1510 let isCommutable = Commutable;
1512 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1513 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1515 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1516 so_reg_imm:$shift))]>,
1517 Sched<[WriteALUsi, ReadALU]>;
1519 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1520 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1522 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1523 so_reg_reg:$shift))]>,
1524 Sched<[WriteALUSsr, ReadALUsr]>;
1528 /// AsI1_rbin_s_is - Same as AsI1_bin_s_irs, except selection DAG
1529 /// operands are reversed.
1530 let hasPostISelHook = 1, Defs = [CPSR] in {
1531 multiclass AsI1_rbin_s_is<InstrItinClass iii, InstrItinClass iir,
1532 InstrItinClass iis, SDNode opnode,
1533 bit Commutable = 0> {
1534 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p),
1536 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn))]>,
1537 Sched<[WriteALU, ReadALU]>;
1539 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1540 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1542 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift,
1544 Sched<[WriteALUsi, ReadALU]>;
1546 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1547 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1549 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift,
1551 Sched<[WriteALUSsr, ReadALUsr]>;
1555 /// AI1_cmp_irs - Defines a set of (op r, {mod_imm|r|so_reg}) cmp / test
1556 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
1557 /// a explicit result, only implicitly set CPSR.
1558 let isCompare = 1, Defs = [CPSR] in {
1559 multiclass AI1_cmp_irs<bits<4> opcod, string opc,
1560 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1561 SDPatternOperator opnode, bit Commutable = 0,
1562 string rrDecoderMethod = ""> {
1563 def ri : AI1<opcod, (outs), (ins GPR:$Rn, mod_imm:$imm), DPFrm, iii,
1565 [(opnode GPR:$Rn, mod_imm:$imm)]>,
1566 Sched<[WriteCMP, ReadALU]> {
1571 let Inst{19-16} = Rn;
1572 let Inst{15-12} = 0b0000;
1573 let Inst{11-0} = imm;
1575 let Unpredictable{15-12} = 0b1111;
1577 def rr : AI1<opcod, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, iir,
1579 [(opnode GPR:$Rn, GPR:$Rm)]>,
1580 Sched<[WriteCMP, ReadALU, ReadALU]> {
1583 let isCommutable = Commutable;
1586 let Inst{19-16} = Rn;
1587 let Inst{15-12} = 0b0000;
1588 let Inst{11-4} = 0b00000000;
1590 let DecoderMethod = rrDecoderMethod;
1592 let Unpredictable{15-12} = 0b1111;
1594 def rsi : AI1<opcod, (outs),
1595 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, iis,
1596 opc, "\t$Rn, $shift",
1597 [(opnode GPR:$Rn, so_reg_imm:$shift)]>,
1598 Sched<[WriteCMPsi, ReadALU]> {
1603 let Inst{19-16} = Rn;
1604 let Inst{15-12} = 0b0000;
1605 let Inst{11-5} = shift{11-5};
1607 let Inst{3-0} = shift{3-0};
1609 let Unpredictable{15-12} = 0b1111;
1611 def rsr : AI1<opcod, (outs),
1612 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, iis,
1613 opc, "\t$Rn, $shift",
1614 [(opnode GPRnopc:$Rn, so_reg_reg:$shift)]>,
1615 Sched<[WriteCMPsr, ReadALU]> {
1620 let Inst{19-16} = Rn;
1621 let Inst{15-12} = 0b0000;
1622 let Inst{11-8} = shift{11-8};
1624 let Inst{6-5} = shift{6-5};
1626 let Inst{3-0} = shift{3-0};
1628 let Unpredictable{15-12} = 0b1111;
1634 /// AI_ext_rrot - A unary operation with two forms: one whose operand is a
1635 /// register and one whose operand is a register rotated by 8/16/24.
1636 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
1637 class AI_ext_rrot<bits<8> opcod, string opc, PatFrag opnode>
1638 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1639 IIC_iEXTr, opc, "\t$Rd, $Rm$rot",
1640 [(set GPRnopc:$Rd, (opnode (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1641 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> {
1645 let Inst{19-16} = 0b1111;
1646 let Inst{15-12} = Rd;
1647 let Inst{11-10} = rot;
1651 class AI_ext_rrot_np<bits<8> opcod, string opc>
1652 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1653 IIC_iEXTr, opc, "\t$Rd, $Rm$rot", []>,
1654 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> {
1656 let Inst{19-16} = 0b1111;
1657 let Inst{11-10} = rot;
1660 /// AI_exta_rrot - A binary operation with two forms: one whose operand is a
1661 /// register and one whose operand is a register rotated by 8/16/24.
1662 class AI_exta_rrot<bits<8> opcod, string opc, PatFrag opnode>
1663 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1664 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot",
1665 [(set GPRnopc:$Rd, (opnode GPR:$Rn,
1666 (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1667 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> {
1672 let Inst{19-16} = Rn;
1673 let Inst{15-12} = Rd;
1674 let Inst{11-10} = rot;
1675 let Inst{9-4} = 0b000111;
1679 class AI_exta_rrot_np<bits<8> opcod, string opc>
1680 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1681 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot", []>,
1682 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> {
1685 let Inst{19-16} = Rn;
1686 let Inst{11-10} = rot;
1689 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
1690 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1691 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, SDNode opnode,
1692 bit Commutable = 0> {
1693 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1694 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm),
1695 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1696 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm, CPSR))]>,
1698 Sched<[WriteALU, ReadALU]> {
1703 let Inst{15-12} = Rd;
1704 let Inst{19-16} = Rn;
1705 let Inst{11-0} = imm;
1707 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1708 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1709 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm, CPSR))]>,
1711 Sched<[WriteALU, ReadALU, ReadALU]> {
1715 let Inst{11-4} = 0b00000000;
1717 let isCommutable = Commutable;
1719 let Inst{15-12} = Rd;
1720 let Inst{19-16} = Rn;
1722 def rsi : AsI1<opcod, (outs GPR:$Rd),
1723 (ins GPR:$Rn, so_reg_imm:$shift),
1724 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1725 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_imm:$shift, CPSR))]>,
1727 Sched<[WriteALUsi, ReadALU]> {
1732 let Inst{19-16} = Rn;
1733 let Inst{15-12} = Rd;
1734 let Inst{11-5} = shift{11-5};
1736 let Inst{3-0} = shift{3-0};
1738 def rsr : AsI1<opcod, (outs GPRnopc:$Rd),
1739 (ins GPRnopc:$Rn, so_reg_reg:$shift),
1740 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1741 [(set GPRnopc:$Rd, CPSR,
1742 (opnode GPRnopc:$Rn, so_reg_reg:$shift, CPSR))]>,
1744 Sched<[WriteALUsr, ReadALUsr]> {
1749 let Inst{19-16} = Rn;
1750 let Inst{15-12} = Rd;
1751 let Inst{11-8} = shift{11-8};
1753 let Inst{6-5} = shift{6-5};
1755 let Inst{3-0} = shift{3-0};
1760 /// AI1_rsc_irs - Define instructions and patterns for rsc
1761 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1762 multiclass AI1_rsc_irs<bits<4> opcod, string opc, SDNode opnode> {
1763 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1764 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm),
1765 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1766 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn, CPSR))]>,
1768 Sched<[WriteALU, ReadALU]> {
1773 let Inst{15-12} = Rd;
1774 let Inst{19-16} = Rn;
1775 let Inst{11-0} = imm;
1777 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1778 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1779 [/* pattern left blank */]>,
1780 Sched<[WriteALU, ReadALU, ReadALU]> {
1784 let Inst{11-4} = 0b00000000;
1787 let Inst{15-12} = Rd;
1788 let Inst{19-16} = Rn;
1790 def rsi : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_imm:$shift),
1791 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1792 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift, GPR:$Rn, CPSR))]>,
1794 Sched<[WriteALUsi, ReadALU]> {
1799 let Inst{19-16} = Rn;
1800 let Inst{15-12} = Rd;
1801 let Inst{11-5} = shift{11-5};
1803 let Inst{3-0} = shift{3-0};
1805 def rsr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_reg:$shift),
1806 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1807 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift, GPR:$Rn, CPSR))]>,
1809 Sched<[WriteALUsr, ReadALUsr]> {
1814 let Inst{19-16} = Rn;
1815 let Inst{15-12} = Rd;
1816 let Inst{11-8} = shift{11-8};
1818 let Inst{6-5} = shift{6-5};
1820 let Inst{3-0} = shift{3-0};
1825 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1826 multiclass AI_ldr1<bit isByte, string opc, InstrItinClass iii,
1827 InstrItinClass iir, PatFrag opnode> {
1828 // Note: We use the complex addrmode_imm12 rather than just an input
1829 // GPR and a constrained immediate so that we can use this to match
1830 // frame index references and avoid matching constant pool references.
1831 def i12: AI2ldst<0b010, 1, isByte, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
1832 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1833 [(set GPR:$Rt, (opnode addrmode_imm12:$addr))]> {
1836 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1837 let Inst{19-16} = addr{16-13}; // Rn
1838 let Inst{15-12} = Rt;
1839 let Inst{11-0} = addr{11-0}; // imm12
1841 def rs : AI2ldst<0b011, 1, isByte, (outs GPR:$Rt), (ins ldst_so_reg:$shift),
1842 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1843 [(set GPR:$Rt, (opnode ldst_so_reg:$shift))]> {
1846 let shift{4} = 0; // Inst{4} = 0
1847 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1848 let Inst{19-16} = shift{16-13}; // Rn
1849 let Inst{15-12} = Rt;
1850 let Inst{11-0} = shift{11-0};
1855 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1856 multiclass AI_ldr1nopc<bit isByte, string opc, InstrItinClass iii,
1857 InstrItinClass iir, PatFrag opnode> {
1858 // Note: We use the complex addrmode_imm12 rather than just an input
1859 // GPR and a constrained immediate so that we can use this to match
1860 // frame index references and avoid matching constant pool references.
1861 def i12: AI2ldst<0b010, 1, isByte, (outs GPRnopc:$Rt),
1862 (ins addrmode_imm12:$addr),
1863 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1864 [(set GPRnopc:$Rt, (opnode addrmode_imm12:$addr))]> {
1867 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1868 let Inst{19-16} = addr{16-13}; // Rn
1869 let Inst{15-12} = Rt;
1870 let Inst{11-0} = addr{11-0}; // imm12
1872 def rs : AI2ldst<0b011, 1, isByte, (outs GPRnopc:$Rt),
1873 (ins ldst_so_reg:$shift),
1874 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1875 [(set GPRnopc:$Rt, (opnode ldst_so_reg:$shift))]> {
1878 let shift{4} = 0; // Inst{4} = 0
1879 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1880 let Inst{19-16} = shift{16-13}; // Rn
1881 let Inst{15-12} = Rt;
1882 let Inst{11-0} = shift{11-0};
1888 multiclass AI_str1<bit isByte, string opc, InstrItinClass iii,
1889 InstrItinClass iir, PatFrag opnode> {
1890 // Note: We use the complex addrmode_imm12 rather than just an input
1891 // GPR and a constrained immediate so that we can use this to match
1892 // frame index references and avoid matching constant pool references.
1893 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1894 (ins GPR:$Rt, addrmode_imm12:$addr),
1895 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1896 [(opnode GPR:$Rt, addrmode_imm12:$addr)]> {
1899 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1900 let Inst{19-16} = addr{16-13}; // Rn
1901 let Inst{15-12} = Rt;
1902 let Inst{11-0} = addr{11-0}; // imm12
1904 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPR:$Rt, ldst_so_reg:$shift),
1905 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1906 [(opnode GPR:$Rt, ldst_so_reg:$shift)]> {
1909 let shift{4} = 0; // Inst{4} = 0
1910 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1911 let Inst{19-16} = shift{16-13}; // Rn
1912 let Inst{15-12} = Rt;
1913 let Inst{11-0} = shift{11-0};
1917 multiclass AI_str1nopc<bit isByte, string opc, InstrItinClass iii,
1918 InstrItinClass iir, PatFrag opnode> {
1919 // Note: We use the complex addrmode_imm12 rather than just an input
1920 // GPR and a constrained immediate so that we can use this to match
1921 // frame index references and avoid matching constant pool references.
1922 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1923 (ins GPRnopc:$Rt, addrmode_imm12:$addr),
1924 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1925 [(opnode GPRnopc:$Rt, addrmode_imm12:$addr)]> {
1928 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1929 let Inst{19-16} = addr{16-13}; // Rn
1930 let Inst{15-12} = Rt;
1931 let Inst{11-0} = addr{11-0}; // imm12
1933 def rs : AI2ldst<0b011, 0, isByte, (outs),
1934 (ins GPRnopc:$Rt, ldst_so_reg:$shift),
1935 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1936 [(opnode GPRnopc:$Rt, ldst_so_reg:$shift)]> {
1939 let shift{4} = 0; // Inst{4} = 0
1940 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1941 let Inst{19-16} = shift{16-13}; // Rn
1942 let Inst{15-12} = Rt;
1943 let Inst{11-0} = shift{11-0};
1948 //===----------------------------------------------------------------------===//
1950 //===----------------------------------------------------------------------===//
1952 //===----------------------------------------------------------------------===//
1953 // Miscellaneous Instructions.
1956 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
1957 /// the function. The first operand is the ID# for this instruction, the second
1958 /// is the index into the MachineConstantPool that this is, the third is the
1959 /// size in bytes of this constant pool entry.
1960 let hasSideEffects = 0, isNotDuplicable = 1 in
1961 def CONSTPOOL_ENTRY :
1962 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1963 i32imm:$size), NoItinerary, []>;
1965 /// A jumptable consisting of direct 32-bit addresses of the destination basic
1966 /// blocks (either absolute, or relative to the start of the jump-table in PIC
1967 /// mode). Used mostly in ARM and Thumb-1 modes.
1968 def JUMPTABLE_ADDRS :
1969 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1970 i32imm:$size), NoItinerary, []>;
1972 /// A jumptable consisting of 32-bit jump instructions. Used for Thumb-2 tables
1973 /// that cannot be optimised to use TBB or TBH.
1974 def JUMPTABLE_INSTS :
1975 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1976 i32imm:$size), NoItinerary, []>;
1978 /// A jumptable consisting of 8-bit unsigned integers representing offsets from
1979 /// a TBB instruction.
1981 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1982 i32imm:$size), NoItinerary, []>;
1984 /// A jumptable consisting of 16-bit unsigned integers representing offsets from
1985 /// a TBH instruction.
1987 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1988 i32imm:$size), NoItinerary, []>;
1991 // FIXME: Marking these as hasSideEffects is necessary to prevent machine DCE
1992 // from removing one half of the matched pairs. That breaks PEI, which assumes
1993 // these will always be in pairs, and asserts if it finds otherwise. Better way?
1994 let Defs = [SP], Uses = [SP], hasSideEffects = 1 in {
1995 def ADJCALLSTACKUP :
1996 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary,
1997 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
1999 def ADJCALLSTACKDOWN :
2000 PseudoInst<(outs), (ins i32imm:$amt, i32imm:$amt2, pred:$p), NoItinerary,
2001 [(ARMcallseq_start timm:$amt, timm:$amt2)]>;
2004 def HINT : AI<(outs), (ins imm0_239:$imm), MiscFrm, NoItinerary,
2005 "hint", "\t$imm", [(int_arm_hint imm0_239:$imm)]>,
2006 Requires<[IsARM, HasV6]> {
2008 let Inst{27-8} = 0b00110010000011110000;
2009 let Inst{7-0} = imm;
2010 let DecoderMethod = "DecodeHINTInstruction";
2013 def : InstAlias<"nop$p", (HINT 0, pred:$p)>, Requires<[IsARM, HasV6K]>;
2014 def : InstAlias<"yield$p", (HINT 1, pred:$p)>, Requires<[IsARM, HasV6K]>;
2015 def : InstAlias<"wfe$p", (HINT 2, pred:$p)>, Requires<[IsARM, HasV6K]>;
2016 def : InstAlias<"wfi$p", (HINT 3, pred:$p)>, Requires<[IsARM, HasV6K]>;
2017 def : InstAlias<"sev$p", (HINT 4, pred:$p)>, Requires<[IsARM, HasV6K]>;
2018 def : InstAlias<"sevl$p", (HINT 5, pred:$p)>, Requires<[IsARM, HasV8]>;
2019 def : InstAlias<"esb$p", (HINT 16, pred:$p)>, Requires<[IsARM, HasRAS]>;
2020 def : InstAlias<"csdb$p", (HINT 20, pred:$p)>, Requires<[IsARM, HasV6K]>;
2022 def SEL : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, NoItinerary, "sel",
2024 [(set GPR:$Rd, (int_arm_sel GPR:$Rn, GPR:$Rm))]>,
2025 Requires<[IsARM, HasV6]> {
2030 let Inst{15-12} = Rd;
2031 let Inst{19-16} = Rn;
2032 let Inst{27-20} = 0b01101000;
2033 let Inst{7-4} = 0b1011;
2034 let Inst{11-8} = 0b1111;
2035 let Unpredictable{11-8} = 0b1111;
2038 // The 16-bit operand $val can be used by a debugger to store more information
2039 // about the breakpoint.
2040 def BKPT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
2041 "bkpt", "\t$val", []>, Requires<[IsARM]> {
2043 let Inst{3-0} = val{3-0};
2044 let Inst{19-8} = val{15-4};
2045 let Inst{27-20} = 0b00010010;
2046 let Inst{31-28} = 0xe; // AL
2047 let Inst{7-4} = 0b0111;
2049 // default immediate for breakpoint mnemonic
2050 def : InstAlias<"bkpt", (BKPT 0), 0>, Requires<[IsARM]>;
2052 def HLT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
2053 "hlt", "\t$val", []>, Requires<[IsARM, HasV8]> {
2055 let Inst{3-0} = val{3-0};
2056 let Inst{19-8} = val{15-4};
2057 let Inst{27-20} = 0b00010000;
2058 let Inst{31-28} = 0xe; // AL
2059 let Inst{7-4} = 0b0111;
2062 // Change Processor State
2063 // FIXME: We should use InstAlias to handle the optional operands.
2064 class CPS<dag iops, string asm_ops>
2065 : AXI<(outs), iops, MiscFrm, NoItinerary, !strconcat("cps", asm_ops),
2066 []>, Requires<[IsARM]> {
2072 let Inst{31-28} = 0b1111;
2073 let Inst{27-20} = 0b00010000;
2074 let Inst{19-18} = imod;
2075 let Inst{17} = M; // Enabled if mode is set;
2076 let Inst{16-9} = 0b00000000;
2077 let Inst{8-6} = iflags;
2079 let Inst{4-0} = mode;
2082 let DecoderMethod = "DecodeCPSInstruction" in {
2084 def CPS3p : CPS<(ins imod_op:$imod, iflags_op:$iflags, imm0_31:$mode),
2085 "$imod\t$iflags, $mode">;
2086 let mode = 0, M = 0 in
2087 def CPS2p : CPS<(ins imod_op:$imod, iflags_op:$iflags), "$imod\t$iflags">;
2089 let imod = 0, iflags = 0, M = 1 in
2090 def CPS1p : CPS<(ins imm0_31:$mode), "\t$mode">;
2093 // Preload signals the memory system of possible future data/instruction access.
2094 multiclass APreLoad<bits<1> read, bits<1> data, string opc> {
2096 def i12 : AXIM<(outs), (ins addrmode_imm12:$addr), AddrMode_i12, MiscFrm,
2097 IIC_Preload, !strconcat(opc, "\t$addr"),
2098 [(ARMPreload addrmode_imm12:$addr, (i32 read), (i32 data))]>,
2099 Sched<[WritePreLd]> {
2102 let Inst{31-26} = 0b111101;
2103 let Inst{25} = 0; // 0 for immediate form
2104 let Inst{24} = data;
2105 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2106 let Inst{22} = read;
2107 let Inst{21-20} = 0b01;
2108 let Inst{19-16} = addr{16-13}; // Rn
2109 let Inst{15-12} = 0b1111;
2110 let Inst{11-0} = addr{11-0}; // imm12
2113 def rs : AXI<(outs), (ins ldst_so_reg:$shift), MiscFrm, IIC_Preload,
2114 !strconcat(opc, "\t$shift"),
2115 [(ARMPreload ldst_so_reg:$shift, (i32 read), (i32 data))]>,
2116 Sched<[WritePreLd]> {
2118 let Inst{31-26} = 0b111101;
2119 let Inst{25} = 1; // 1 for register form
2120 let Inst{24} = data;
2121 let Inst{23} = shift{12}; // U (add = ('U' == 1))
2122 let Inst{22} = read;
2123 let Inst{21-20} = 0b01;
2124 let Inst{19-16} = shift{16-13}; // Rn
2125 let Inst{15-12} = 0b1111;
2126 let Inst{11-0} = shift{11-0};
2131 defm PLD : APreLoad<1, 1, "pld">, Requires<[IsARM]>;
2132 defm PLDW : APreLoad<0, 1, "pldw">, Requires<[IsARM,HasV7,HasMP]>;
2133 defm PLI : APreLoad<1, 0, "pli">, Requires<[IsARM,HasV7]>;
2135 def SETEND : AXI<(outs), (ins setend_op:$end), MiscFrm, NoItinerary,
2136 "setend\t$end", []>, Requires<[IsARM]>, Deprecated<HasV8Ops> {
2138 let Inst{31-10} = 0b1111000100000001000000;
2143 def DBG : AI<(outs), (ins imm0_15:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt",
2144 [(int_arm_dbg imm0_15:$opt)]>, Requires<[IsARM, HasV7]> {
2146 let Inst{27-4} = 0b001100100000111100001111;
2147 let Inst{3-0} = opt;
2150 // A8.8.247 UDF - Undefined (Encoding A1)
2151 def UDF : AInoP<(outs), (ins imm0_65535:$imm16), MiscFrm, NoItinerary,
2152 "udf", "\t$imm16", [(int_arm_undefined imm0_65535:$imm16)]> {
2154 let Inst{31-28} = 0b1110; // AL
2155 let Inst{27-25} = 0b011;
2156 let Inst{24-20} = 0b11111;
2157 let Inst{19-8} = imm16{15-4};
2158 let Inst{7-4} = 0b1111;
2159 let Inst{3-0} = imm16{3-0};
2163 * A5.4 Permanently UNDEFINED instructions.
2165 * For most targets use UDF #65006, for which the OS will generate SIGTRAP.
2166 * Other UDF encodings generate SIGILL.
2168 * NaCl's OS instead chooses an ARM UDF encoding that's also a UDF in Thumb.
2170 * 1110 0111 1111 iiii iiii iiii 1111 iiii
2172 * 1101 1110 iiii iiii
2173 * It uses the following encoding:
2174 * 1110 0111 1111 1110 1101 1110 1111 0000
2175 * - In ARM: UDF #60896;
2176 * - In Thumb: UDF #254 followed by a branch-to-self.
2178 let isBarrier = 1, isTerminator = 1 in
2179 def TRAPNaCl : AXI<(outs), (ins), MiscFrm, NoItinerary,
2181 Requires<[IsARM,UseNaClTrap]> {
2182 let Inst = 0xe7fedef0;
2184 let isBarrier = 1, isTerminator = 1 in
2185 def TRAP : AXI<(outs), (ins), MiscFrm, NoItinerary,
2187 Requires<[IsARM,DontUseNaClTrap]> {
2188 let Inst = 0xe7ffdefe;
2191 def : Pat<(debugtrap), (BKPT 0)>, Requires<[IsARM, HasV5T]>;
2192 def : Pat<(debugtrap), (UDF 254)>, Requires<[IsARM, NoV5T]>;
2194 // Address computation and loads and stores in PIC mode.
2195 let isNotDuplicable = 1 in {
2196 def PICADD : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
2198 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>,
2199 Sched<[WriteALU, ReadALU]>;
2201 let AddedComplexity = 10 in {
2202 def PICLDR : ARMPseudoInst<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
2204 [(set GPR:$dst, (load addrmodepc:$addr))]>;
2206 def PICLDRH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2208 [(set GPR:$Rt, (zextloadi16 addrmodepc:$addr))]>;
2210 def PICLDRB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2212 [(set GPR:$Rt, (zextloadi8 addrmodepc:$addr))]>;
2214 def PICLDRSH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2216 [(set GPR:$Rt, (sextloadi16 addrmodepc:$addr))]>;
2218 def PICLDRSB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2220 [(set GPR:$Rt, (sextloadi8 addrmodepc:$addr))]>;
2222 let AddedComplexity = 10 in {
2223 def PICSTR : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2224 4, IIC_iStore_r, [(store GPR:$src, addrmodepc:$addr)]>;
2226 def PICSTRH : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2227 4, IIC_iStore_bh_r, [(truncstorei16 GPR:$src,
2228 addrmodepc:$addr)]>;
2230 def PICSTRB : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2231 4, IIC_iStore_bh_r, [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
2233 } // isNotDuplicable = 1
2236 // LEApcrel - Load a pc-relative address into a register without offending the
2238 let hasSideEffects = 0, isReMaterializable = 1 in
2239 // The 'adr' mnemonic encodes differently if the label is before or after
2240 // the instruction. The {24-21} opcode bits are set by the fixup, as we don't
2241 // know until then which form of the instruction will be used.
2242 def ADR : AI1<{0,?,?,0}, (outs GPR:$Rd), (ins adrlabel:$label),
2243 MiscFrm, IIC_iALUi, "adr", "\t$Rd, $label", []>,
2244 Sched<[WriteALU, ReadALU]> {
2247 let Inst{27-25} = 0b001;
2249 let Inst{23-22} = label{13-12};
2252 let Inst{19-16} = 0b1111;
2253 let Inst{15-12} = Rd;
2254 let Inst{11-0} = label{11-0};
2257 let hasSideEffects = 1 in {
2258 def LEApcrel : ARMPseudoInst<(outs GPR:$Rd), (ins i32imm:$label, pred:$p),
2259 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
2261 def LEApcrelJT : ARMPseudoInst<(outs GPR:$Rd),
2262 (ins i32imm:$label, pred:$p),
2263 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
2266 //===----------------------------------------------------------------------===//
2267 // Control Flow Instructions.
2270 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
2272 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
2273 "bx", "\tlr", [(ARMretflag)]>,
2274 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2275 let Inst{27-0} = 0b0001001011111111111100011110;
2279 def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br,
2280 "mov", "\tpc, lr", [(ARMretflag)]>,
2281 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]> {
2282 let Inst{27-0} = 0b0001101000001111000000001110;
2285 // Exception return: N.b. doesn't set CPSR as far as we're concerned (it sets
2286 // the user-space one).
2287 def SUBS_PC_LR : ARMPseudoInst<(outs), (ins i32imm:$offset, pred:$p),
2289 [(ARMintretflag imm:$offset)]>;
2292 // Indirect branches
2293 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
2295 def BX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
2296 [(brind GPR:$dst)]>,
2297 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2299 let Inst{31-4} = 0b1110000100101111111111110001;
2300 let Inst{3-0} = dst;
2303 def BX_pred : AI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br,
2304 "bx", "\t$dst", [/* pattern left blank */]>,
2305 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2307 let Inst{27-4} = 0b000100101111111111110001;
2308 let Inst{3-0} = dst;
2312 // SP is marked as a use to prevent stack-pointer assignments that appear
2313 // immediately before calls from potentially appearing dead.
2315 // FIXME: Do we really need a non-predicated version? If so, it should
2316 // at least be a pseudo instruction expanding to the predicated version
2317 // at MC lowering time.
2318 Defs = [LR], Uses = [SP] in {
2319 def BL : ABXI<0b1011, (outs), (ins arm_bl_target:$func),
2320 IIC_Br, "bl\t$func",
2321 [(ARMcall tglobaladdr:$func)]>,
2322 Requires<[IsARM]>, Sched<[WriteBrL]> {
2323 let Inst{31-28} = 0b1110;
2325 let Inst{23-0} = func;
2326 let DecoderMethod = "DecodeBranchImmInstruction";
2329 def BL_pred : ABI<0b1011, (outs), (ins arm_bl_target:$func),
2330 IIC_Br, "bl", "\t$func",
2331 [(ARMcall_pred tglobaladdr:$func)]>,
2332 Requires<[IsARM]>, Sched<[WriteBrL]> {
2334 let Inst{23-0} = func;
2335 let DecoderMethod = "DecodeBranchImmInstruction";
2339 def BLX : AXI<(outs), (ins GPR:$func), BrMiscFrm,
2340 IIC_Br, "blx\t$func",
2341 [(ARMcall GPR:$func)]>,
2342 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2344 let Inst{31-4} = 0b1110000100101111111111110011;
2345 let Inst{3-0} = func;
2348 def BLX_pred : AI<(outs), (ins GPR:$func), BrMiscFrm,
2349 IIC_Br, "blx", "\t$func",
2350 [(ARMcall_pred GPR:$func)]>,
2351 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2353 let Inst{27-4} = 0b000100101111111111110011;
2354 let Inst{3-0} = func;
2358 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
2359 def BX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
2360 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
2361 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]>;
2364 def BMOVPCRX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
2365 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
2366 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
2368 // mov lr, pc; b if callee is marked noreturn to avoid confusing the
2369 // return stack predictor.
2370 def BMOVPCB_CALL : ARMPseudoInst<(outs), (ins arm_bl_target:$func),
2371 8, IIC_Br, [(ARMcall_nolink tglobaladdr:$func)]>,
2372 Requires<[IsARM]>, Sched<[WriteBr]>;
2374 // push lr before the call
2375 def BL_PUSHLR : ARMPseudoInst<(outs), (ins GPRlr:$ra, arm_bl_target:$func),
2378 Requires<[IsARM]>, Sched<[WriteBr]>;
2381 let isBranch = 1, isTerminator = 1 in {
2382 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
2383 // a two-value operand where a dag node expects two operands. :(
2384 def Bcc : ABI<0b1010, (outs), (ins arm_br_target:$target),
2385 IIC_Br, "b", "\t$target",
2386 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>,
2389 let Inst{23-0} = target;
2390 let DecoderMethod = "DecodeBranchImmInstruction";
2393 let isBarrier = 1 in {
2394 // B is "predicable" since it's just a Bcc with an 'always' condition.
2395 let isPredicable = 1 in
2396 // FIXME: We shouldn't need this pseudo at all. Just using Bcc directly
2397 // should be sufficient.
2398 // FIXME: Is B really a Barrier? That doesn't seem right.
2399 def B : ARMPseudoExpand<(outs), (ins arm_br_target:$target), 4, IIC_Br,
2400 [(br bb:$target)], (Bcc arm_br_target:$target,
2401 (ops 14, zero_reg))>,
2404 let Size = 4, isNotDuplicable = 1, isIndirectBranch = 1 in {
2405 def BR_JTr : ARMPseudoInst<(outs),
2406 (ins GPR:$target, i32imm:$jt),
2408 [(ARMbrjt GPR:$target, tjumptable:$jt)]>,
2410 def BR_JTm_i12 : ARMPseudoInst<(outs),
2411 (ins addrmode_imm12:$target, i32imm:$jt),
2413 [(ARMbrjt (i32 (load addrmode_imm12:$target)),
2414 tjumptable:$jt)]>, Sched<[WriteBrTbl]>;
2415 def BR_JTm_rs : ARMPseudoInst<(outs),
2416 (ins ldst_so_reg:$target, i32imm:$jt),
2418 [(ARMbrjt (i32 (load ldst_so_reg:$target)),
2419 tjumptable:$jt)]>, Sched<[WriteBrTbl]>;
2420 def BR_JTadd : ARMPseudoInst<(outs),
2421 (ins GPR:$target, GPR:$idx, i32imm:$jt),
2423 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt)]>,
2424 Sched<[WriteBrTbl]>;
2425 } // isNotDuplicable = 1, isIndirectBranch = 1
2431 def BLXi : AXI<(outs), (ins arm_blx_target:$target), BrMiscFrm, NoItinerary,
2432 "blx\t$target", []>,
2433 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2434 let Inst{31-25} = 0b1111101;
2436 let Inst{23-0} = target{24-1};
2437 let Inst{24} = target{0};
2441 // Branch and Exchange Jazelle
2442 def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func",
2443 [/* pattern left blank */]>, Sched<[WriteBr]> {
2445 let Inst{23-20} = 0b0010;
2446 let Inst{19-8} = 0xfff;
2447 let Inst{7-4} = 0b0010;
2448 let Inst{3-0} = func;
2454 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in {
2455 def TCRETURNdi : PseudoInst<(outs), (ins i32imm:$dst), IIC_Br, []>,
2458 def TCRETURNri : PseudoInst<(outs), (ins tcGPR:$dst), IIC_Br, []>,
2461 def TAILJMPd : ARMPseudoExpand<(outs), (ins arm_br_target:$dst),
2463 (Bcc arm_br_target:$dst, (ops 14, zero_reg))>,
2464 Requires<[IsARM]>, Sched<[WriteBr]>;
2466 def TAILJMPr : ARMPseudoExpand<(outs), (ins tcGPR:$dst),
2468 (BX GPR:$dst)>, Sched<[WriteBr]>,
2469 Requires<[IsARM, HasV4T]>;
2472 // Secure Monitor Call is a system instruction.
2473 def SMC : ABI<0b0001, (outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt",
2474 []>, Requires<[IsARM, HasTrustZone]> {
2476 let Inst{23-4} = 0b01100000000000000111;
2477 let Inst{3-0} = opt;
2479 def : MnemonicAlias<"smi", "smc">;
2481 // Supervisor Call (Software Interrupt)
2482 let isCall = 1, Uses = [SP] in {
2483 def SVC : ABI<0b1111, (outs), (ins imm24b:$svc), IIC_Br, "svc", "\t$svc", []>,
2486 let Inst{23-0} = svc;
2490 // Store Return State
2491 class SRSI<bit wb, string asm>
2492 : XI<(outs), (ins imm0_31:$mode), AddrModeNone, 4, IndexModeNone, BrFrm,
2493 NoItinerary, asm, "", []> {
2495 let Inst{31-28} = 0b1111;
2496 let Inst{27-25} = 0b100;
2500 let Inst{19-16} = 0b1101; // SP
2501 let Inst{15-5} = 0b00000101000;
2502 let Inst{4-0} = mode;
2505 def SRSDA : SRSI<0, "srsda\tsp, $mode"> {
2506 let Inst{24-23} = 0;
2508 def SRSDA_UPD : SRSI<1, "srsda\tsp!, $mode"> {
2509 let Inst{24-23} = 0;
2511 def SRSDB : SRSI<0, "srsdb\tsp, $mode"> {
2512 let Inst{24-23} = 0b10;
2514 def SRSDB_UPD : SRSI<1, "srsdb\tsp!, $mode"> {
2515 let Inst{24-23} = 0b10;
2517 def SRSIA : SRSI<0, "srsia\tsp, $mode"> {
2518 let Inst{24-23} = 0b01;
2520 def SRSIA_UPD : SRSI<1, "srsia\tsp!, $mode"> {
2521 let Inst{24-23} = 0b01;
2523 def SRSIB : SRSI<0, "srsib\tsp, $mode"> {
2524 let Inst{24-23} = 0b11;
2526 def SRSIB_UPD : SRSI<1, "srsib\tsp!, $mode"> {
2527 let Inst{24-23} = 0b11;
2530 def : ARMInstAlias<"srsda $mode", (SRSDA imm0_31:$mode)>;
2531 def : ARMInstAlias<"srsda $mode!", (SRSDA_UPD imm0_31:$mode)>;
2533 def : ARMInstAlias<"srsdb $mode", (SRSDB imm0_31:$mode)>;
2534 def : ARMInstAlias<"srsdb $mode!", (SRSDB_UPD imm0_31:$mode)>;
2536 def : ARMInstAlias<"srsia $mode", (SRSIA imm0_31:$mode)>;
2537 def : ARMInstAlias<"srsia $mode!", (SRSIA_UPD imm0_31:$mode)>;
2539 def : ARMInstAlias<"srsib $mode", (SRSIB imm0_31:$mode)>;
2540 def : ARMInstAlias<"srsib $mode!", (SRSIB_UPD imm0_31:$mode)>;
2542 // Return From Exception
2543 class RFEI<bit wb, string asm>
2544 : XI<(outs), (ins GPR:$Rn), AddrModeNone, 4, IndexModeNone, BrFrm,
2545 NoItinerary, asm, "", []> {
2547 let Inst{31-28} = 0b1111;
2548 let Inst{27-25} = 0b100;
2552 let Inst{19-16} = Rn;
2553 let Inst{15-0} = 0xa00;
2556 def RFEDA : RFEI<0, "rfeda\t$Rn"> {
2557 let Inst{24-23} = 0;
2559 def RFEDA_UPD : RFEI<1, "rfeda\t$Rn!"> {
2560 let Inst{24-23} = 0;
2562 def RFEDB : RFEI<0, "rfedb\t$Rn"> {
2563 let Inst{24-23} = 0b10;
2565 def RFEDB_UPD : RFEI<1, "rfedb\t$Rn!"> {
2566 let Inst{24-23} = 0b10;
2568 def RFEIA : RFEI<0, "rfeia\t$Rn"> {
2569 let Inst{24-23} = 0b01;
2571 def RFEIA_UPD : RFEI<1, "rfeia\t$Rn!"> {
2572 let Inst{24-23} = 0b01;
2574 def RFEIB : RFEI<0, "rfeib\t$Rn"> {
2575 let Inst{24-23} = 0b11;
2577 def RFEIB_UPD : RFEI<1, "rfeib\t$Rn!"> {
2578 let Inst{24-23} = 0b11;
2581 // Hypervisor Call is a system instruction
2583 def HVC : AInoP< (outs), (ins imm0_65535:$imm), BrFrm, NoItinerary,
2584 "hvc", "\t$imm", []>,
2585 Requires<[IsARM, HasVirtualization]> {
2588 // Even though HVC isn't predicable, it's encoding includes a condition field.
2589 // The instruction is undefined if the condition field is 0xf otherwise it is
2590 // unpredictable if it isn't condition AL (0xe).
2591 let Inst{31-28} = 0b1110;
2592 let Unpredictable{31-28} = 0b1111;
2593 let Inst{27-24} = 0b0001;
2594 let Inst{23-20} = 0b0100;
2595 let Inst{19-8} = imm{15-4};
2596 let Inst{7-4} = 0b0111;
2597 let Inst{3-0} = imm{3-0};
2601 // Return from exception in Hypervisor mode.
2602 let isReturn = 1, isBarrier = 1, isTerminator = 1, Defs = [PC] in
2603 def ERET : ABI<0b0001, (outs), (ins), NoItinerary, "eret", "", []>,
2604 Requires<[IsARM, HasVirtualization]> {
2605 let Inst{23-0} = 0b011000000000000001101110;
2608 //===----------------------------------------------------------------------===//
2609 // Load / Store Instructions.
2615 defm LDR : AI_ldr1<0, "ldr", IIC_iLoad_r, IIC_iLoad_si, load>;
2616 defm LDRB : AI_ldr1nopc<1, "ldrb", IIC_iLoad_bh_r, IIC_iLoad_bh_si,
2618 defm STR : AI_str1<0, "str", IIC_iStore_r, IIC_iStore_si, store>;
2619 defm STRB : AI_str1nopc<1, "strb", IIC_iStore_bh_r, IIC_iStore_bh_si,
2622 // Special LDR for loads from non-pc-relative constpools.
2623 let canFoldAsLoad = 1, mayLoad = 1, hasSideEffects = 0,
2624 isReMaterializable = 1, isCodeGenOnly = 1 in
2625 def LDRcp : AI2ldst<0b010, 1, 0, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
2626 AddrMode_i12, LdFrm, IIC_iLoad_r, "ldr", "\t$Rt, $addr",
2630 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2631 let Inst{19-16} = 0b1111;
2632 let Inst{15-12} = Rt;
2633 let Inst{11-0} = addr{11-0}; // imm12
2636 // Loads with zero extension
2637 def LDRH : AI3ld<0b1011, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2638 IIC_iLoad_bh_r, "ldrh", "\t$Rt, $addr",
2639 [(set GPR:$Rt, (zextloadi16 addrmode3:$addr))]>;
2641 // Loads with sign extension
2642 def LDRSH : AI3ld<0b1111, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2643 IIC_iLoad_bh_r, "ldrsh", "\t$Rt, $addr",
2644 [(set GPR:$Rt, (sextloadi16 addrmode3:$addr))]>;
2646 def LDRSB : AI3ld<0b1101, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2647 IIC_iLoad_bh_r, "ldrsb", "\t$Rt, $addr",
2648 [(set GPR:$Rt, (sextloadi8 addrmode3:$addr))]>;
2650 let mayLoad = 1, hasSideEffects = 0, hasExtraDefRegAllocReq = 1 in {
2652 def LDRD : AI3ld<0b1101, 0, (outs GPR:$Rt, GPR:$Rt2), (ins addrmode3:$addr),
2653 LdMiscFrm, IIC_iLoad_d_r, "ldrd", "\t$Rt, $Rt2, $addr", []>,
2654 Requires<[IsARM, HasV5TE]>;
2657 def LDA : AIldracq<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2658 NoItinerary, "lda", "\t$Rt, $addr", []>;
2659 def LDAB : AIldracq<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2660 NoItinerary, "ldab", "\t$Rt, $addr", []>;
2661 def LDAH : AIldracq<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2662 NoItinerary, "ldah", "\t$Rt, $addr", []>;
2665 multiclass AI2_ldridx<bit isByte, string opc,
2666 InstrItinClass iii, InstrItinClass iir> {
2667 def _PRE_IMM : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2668 (ins addrmode_imm12_pre:$addr), IndexModePre, LdFrm, iii,
2669 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2672 let Inst{23} = addr{12};
2673 let Inst{19-16} = addr{16-13};
2674 let Inst{11-0} = addr{11-0};
2675 let DecoderMethod = "DecodeLDRPreImm";
2678 def _PRE_REG : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2679 (ins ldst_so_reg:$addr), IndexModePre, LdFrm, iir,
2680 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2683 let Inst{23} = addr{12};
2684 let Inst{19-16} = addr{16-13};
2685 let Inst{11-0} = addr{11-0};
2687 let DecoderMethod = "DecodeLDRPreReg";
2690 def _POST_REG : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2691 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2692 IndexModePost, LdFrm, iir,
2693 opc, "\t$Rt, $addr, $offset",
2694 "$addr.base = $Rn_wb", []> {
2700 let Inst{23} = offset{12};
2701 let Inst{19-16} = addr;
2702 let Inst{11-0} = offset{11-0};
2705 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2708 def _POST_IMM : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2709 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2710 IndexModePost, LdFrm, iii,
2711 opc, "\t$Rt, $addr, $offset",
2712 "$addr.base = $Rn_wb", []> {
2718 let Inst{23} = offset{12};
2719 let Inst{19-16} = addr;
2720 let Inst{11-0} = offset{11-0};
2722 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2727 let mayLoad = 1, hasSideEffects = 0 in {
2728 // FIXME: for LDR_PRE_REG etc. the itineray should be either IIC_iLoad_ru or
2729 // IIC_iLoad_siu depending on whether it the offset register is shifted.
2730 defm LDR : AI2_ldridx<0, "ldr", IIC_iLoad_iu, IIC_iLoad_ru>;
2731 defm LDRB : AI2_ldridx<1, "ldrb", IIC_iLoad_bh_iu, IIC_iLoad_bh_ru>;
2734 multiclass AI3_ldridx<bits<4> op, string opc, InstrItinClass itin> {
2735 def _PRE : AI3ldstidx<op, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2736 (ins addrmode3_pre:$addr), IndexModePre,
2738 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2740 let Inst{23} = addr{8}; // U bit
2741 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2742 let Inst{19-16} = addr{12-9}; // Rn
2743 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2744 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2745 let DecoderMethod = "DecodeAddrMode3Instruction";
2747 def _POST : AI3ldstidx<op, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2748 (ins addr_offset_none:$addr, am3offset:$offset),
2749 IndexModePost, LdMiscFrm, itin,
2750 opc, "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2754 let Inst{23} = offset{8}; // U bit
2755 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2756 let Inst{19-16} = addr;
2757 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2758 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2759 let DecoderMethod = "DecodeAddrMode3Instruction";
2763 let mayLoad = 1, hasSideEffects = 0 in {
2764 defm LDRH : AI3_ldridx<0b1011, "ldrh", IIC_iLoad_bh_ru>;
2765 defm LDRSH : AI3_ldridx<0b1111, "ldrsh", IIC_iLoad_bh_ru>;
2766 defm LDRSB : AI3_ldridx<0b1101, "ldrsb", IIC_iLoad_bh_ru>;
2767 let hasExtraDefRegAllocReq = 1 in {
2768 def LDRD_PRE : AI3ldstidx<0b1101, 0, 1, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2769 (ins addrmode3_pre:$addr), IndexModePre,
2770 LdMiscFrm, IIC_iLoad_d_ru,
2771 "ldrd", "\t$Rt, $Rt2, $addr!",
2772 "$addr.base = $Rn_wb", []> {
2774 let Inst{23} = addr{8}; // U bit
2775 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2776 let Inst{19-16} = addr{12-9}; // Rn
2777 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2778 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2779 let DecoderMethod = "DecodeAddrMode3Instruction";
2781 def LDRD_POST: AI3ldstidx<0b1101, 0, 0, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2782 (ins addr_offset_none:$addr, am3offset:$offset),
2783 IndexModePost, LdMiscFrm, IIC_iLoad_d_ru,
2784 "ldrd", "\t$Rt, $Rt2, $addr, $offset",
2785 "$addr.base = $Rn_wb", []> {
2788 let Inst{23} = offset{8}; // U bit
2789 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2790 let Inst{19-16} = addr;
2791 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2792 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2793 let DecoderMethod = "DecodeAddrMode3Instruction";
2795 } // hasExtraDefRegAllocReq = 1
2796 } // mayLoad = 1, hasSideEffects = 0
2798 // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT.
2799 let mayLoad = 1, hasSideEffects = 0 in {
2800 def LDRT_POST_REG : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2801 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2802 IndexModePost, LdFrm, IIC_iLoad_ru,
2803 "ldrt", "\t$Rt, $addr, $offset",
2804 "$addr.base = $Rn_wb", []> {
2810 let Inst{23} = offset{12};
2811 let Inst{21} = 1; // overwrite
2812 let Inst{19-16} = addr;
2813 let Inst{11-5} = offset{11-5};
2815 let Inst{3-0} = offset{3-0};
2816 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2820 : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2821 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2822 IndexModePost, LdFrm, IIC_iLoad_ru,
2823 "ldrt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2829 let Inst{23} = offset{12};
2830 let Inst{21} = 1; // overwrite
2831 let Inst{19-16} = addr;
2832 let Inst{11-0} = offset{11-0};
2833 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2836 def LDRBT_POST_REG : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2837 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2838 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2839 "ldrbt", "\t$Rt, $addr, $offset",
2840 "$addr.base = $Rn_wb", []> {
2846 let Inst{23} = offset{12};
2847 let Inst{21} = 1; // overwrite
2848 let Inst{19-16} = addr;
2849 let Inst{11-5} = offset{11-5};
2851 let Inst{3-0} = offset{3-0};
2852 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2856 : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2857 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2858 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2859 "ldrbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2865 let Inst{23} = offset{12};
2866 let Inst{21} = 1; // overwrite
2867 let Inst{19-16} = addr;
2868 let Inst{11-0} = offset{11-0};
2869 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2872 multiclass AI3ldrT<bits<4> op, string opc> {
2873 def i : AI3ldstidxT<op, 1, (outs GPR:$Rt, GPR:$base_wb),
2874 (ins addr_offset_none:$addr, postidx_imm8:$offset),
2875 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2876 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2878 let Inst{23} = offset{8};
2880 let Inst{11-8} = offset{7-4};
2881 let Inst{3-0} = offset{3-0};
2883 def r : AI3ldstidxT<op, 1, (outs GPRnopc:$Rt, GPRnopc:$base_wb),
2884 (ins addr_offset_none:$addr, postidx_reg:$Rm),
2885 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2886 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2888 let Inst{23} = Rm{4};
2891 let Unpredictable{11-8} = 0b1111;
2892 let Inst{3-0} = Rm{3-0};
2893 let DecoderMethod = "DecodeLDR";
2897 defm LDRSBT : AI3ldrT<0b1101, "ldrsbt">;
2898 defm LDRHT : AI3ldrT<0b1011, "ldrht">;
2899 defm LDRSHT : AI3ldrT<0b1111, "ldrsht">;
2903 : ARMAsmPseudo<"ldrt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q),
2907 : ARMAsmPseudo<"ldrbt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q),
2910 // Pseudo instruction ldr Rt, =immediate
2912 : ARMAsmPseudo<"ldr${q} $Rt, $immediate",
2913 (ins const_pool_asm_imm:$immediate, pred:$q),
2918 // Stores with truncate
2919 def STRH : AI3str<0b1011, (outs), (ins GPR:$Rt, addrmode3:$addr), StMiscFrm,
2920 IIC_iStore_bh_r, "strh", "\t$Rt, $addr",
2921 [(truncstorei16 GPR:$Rt, addrmode3:$addr)]>;
2924 let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
2925 def STRD : AI3str<0b1111, (outs), (ins GPR:$Rt, GPR:$Rt2, addrmode3:$addr),
2926 StMiscFrm, IIC_iStore_d_r, "strd", "\t$Rt, $Rt2, $addr", []>,
2927 Requires<[IsARM, HasV5TE]> {
2933 multiclass AI2_stridx<bit isByte, string opc,
2934 InstrItinClass iii, InstrItinClass iir> {
2935 def _PRE_IMM : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2936 (ins GPR:$Rt, addrmode_imm12_pre:$addr), IndexModePre,
2938 opc, "\t$Rt, $addr!",
2939 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2942 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2943 let Inst{19-16} = addr{16-13}; // Rn
2944 let Inst{11-0} = addr{11-0}; // imm12
2945 let DecoderMethod = "DecodeSTRPreImm";
2948 def _PRE_REG : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2949 (ins GPR:$Rt, ldst_so_reg:$addr),
2950 IndexModePre, StFrm, iir,
2951 opc, "\t$Rt, $addr!",
2952 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2955 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2956 let Inst{19-16} = addr{16-13}; // Rn
2957 let Inst{11-0} = addr{11-0};
2958 let Inst{4} = 0; // Inst{4} = 0
2959 let DecoderMethod = "DecodeSTRPreReg";
2961 def _POST_REG : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2962 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2963 IndexModePost, StFrm, iir,
2964 opc, "\t$Rt, $addr, $offset",
2965 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2971 let Inst{23} = offset{12};
2972 let Inst{19-16} = addr;
2973 let Inst{11-0} = offset{11-0};
2976 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2979 def _POST_IMM : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2980 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2981 IndexModePost, StFrm, iii,
2982 opc, "\t$Rt, $addr, $offset",
2983 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2989 let Inst{23} = offset{12};
2990 let Inst{19-16} = addr;
2991 let Inst{11-0} = offset{11-0};
2993 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2997 let mayStore = 1, hasSideEffects = 0 in {
2998 // FIXME: for STR_PRE_REG etc. the itineray should be either IIC_iStore_ru or
2999 // IIC_iStore_siu depending on whether it the offset register is shifted.
3000 defm STR : AI2_stridx<0, "str", IIC_iStore_iu, IIC_iStore_ru>;
3001 defm STRB : AI2_stridx<1, "strb", IIC_iStore_bh_iu, IIC_iStore_bh_ru>;
3004 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
3005 am2offset_reg:$offset),
3006 (STR_POST_REG GPR:$Rt, addr_offset_none:$addr,
3007 am2offset_reg:$offset)>;
3008 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
3009 am2offset_imm:$offset),
3010 (STR_POST_IMM GPR:$Rt, addr_offset_none:$addr,
3011 am2offset_imm:$offset)>;
3012 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
3013 am2offset_reg:$offset),
3014 (STRB_POST_REG GPR:$Rt, addr_offset_none:$addr,
3015 am2offset_reg:$offset)>;
3016 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
3017 am2offset_imm:$offset),
3018 (STRB_POST_IMM GPR:$Rt, addr_offset_none:$addr,
3019 am2offset_imm:$offset)>;
3021 // Pseudo-instructions for pattern matching the pre-indexed stores. We can't
3022 // put the patterns on the instruction definitions directly as ISel wants
3023 // the address base and offset to be separate operands, not a single
3024 // complex operand like we represent the instructions themselves. The
3025 // pseudos map between the two.
3026 let usesCustomInserter = 1,
3027 Constraints = "$Rn = $Rn_wb,@earlyclobber $Rn_wb" in {
3028 def STRi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3029 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
3032 (pre_store GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
3033 def STRr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3034 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
3037 (pre_store GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
3038 def STRBi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3039 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
3042 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
3043 def STRBr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3044 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
3047 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
3048 def STRH_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3049 (ins GPR:$Rt, GPR:$Rn, am3offset:$offset, pred:$p),
3052 (pre_truncsti16 GPR:$Rt, GPR:$Rn, am3offset:$offset))]>;
3057 def STRH_PRE : AI3ldstidx<0b1011, 0, 1, (outs GPR:$Rn_wb),
3058 (ins GPR:$Rt, addrmode3_pre:$addr), IndexModePre,
3059 StMiscFrm, IIC_iStore_bh_ru,
3060 "strh", "\t$Rt, $addr!",
3061 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
3063 let Inst{23} = addr{8}; // U bit
3064 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
3065 let Inst{19-16} = addr{12-9}; // Rn
3066 let Inst{11-8} = addr{7-4}; // imm7_4/zero
3067 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
3068 let DecoderMethod = "DecodeAddrMode3Instruction";
3071 def STRH_POST : AI3ldstidx<0b1011, 0, 0, (outs GPR:$Rn_wb),
3072 (ins GPR:$Rt, addr_offset_none:$addr, am3offset:$offset),
3073 IndexModePost, StMiscFrm, IIC_iStore_bh_ru,
3074 "strh", "\t$Rt, $addr, $offset",
3075 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb",
3076 [(set GPR:$Rn_wb, (post_truncsti16 GPR:$Rt,
3077 addr_offset_none:$addr,
3078 am3offset:$offset))]> {
3081 let Inst{23} = offset{8}; // U bit
3082 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
3083 let Inst{19-16} = addr;
3084 let Inst{11-8} = offset{7-4}; // imm7_4/zero
3085 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
3086 let DecoderMethod = "DecodeAddrMode3Instruction";
3089 let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
3090 def STRD_PRE : AI3ldstidx<0b1111, 0, 1, (outs GPR:$Rn_wb),
3091 (ins GPR:$Rt, GPR:$Rt2, addrmode3_pre:$addr),
3092 IndexModePre, StMiscFrm, IIC_iStore_d_ru,
3093 "strd", "\t$Rt, $Rt2, $addr!",
3094 "$addr.base = $Rn_wb", []> {
3096 let Inst{23} = addr{8}; // U bit
3097 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
3098 let Inst{19-16} = addr{12-9}; // Rn
3099 let Inst{11-8} = addr{7-4}; // imm7_4/zero
3100 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
3101 let DecoderMethod = "DecodeAddrMode3Instruction";
3104 def STRD_POST: AI3ldstidx<0b1111, 0, 0, (outs GPR:$Rn_wb),
3105 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr,
3107 IndexModePost, StMiscFrm, IIC_iStore_d_ru,
3108 "strd", "\t$Rt, $Rt2, $addr, $offset",
3109 "$addr.base = $Rn_wb", []> {
3112 let Inst{23} = offset{8}; // U bit
3113 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
3114 let Inst{19-16} = addr;
3115 let Inst{11-8} = offset{7-4}; // imm7_4/zero
3116 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
3117 let DecoderMethod = "DecodeAddrMode3Instruction";
3119 } // mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1
3121 // STRT, STRBT, and STRHT
3123 def STRBT_POST_REG : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
3124 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
3125 IndexModePost, StFrm, IIC_iStore_bh_ru,
3126 "strbt", "\t$Rt, $addr, $offset",
3127 "$addr.base = $Rn_wb", []> {
3133 let Inst{23} = offset{12};
3134 let Inst{21} = 1; // overwrite
3135 let Inst{19-16} = addr;
3136 let Inst{11-5} = offset{11-5};
3138 let Inst{3-0} = offset{3-0};
3139 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3143 : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
3144 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
3145 IndexModePost, StFrm, IIC_iStore_bh_ru,
3146 "strbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
3152 let Inst{23} = offset{12};
3153 let Inst{21} = 1; // overwrite
3154 let Inst{19-16} = addr;
3155 let Inst{11-0} = offset{11-0};
3156 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3160 : ARMAsmPseudo<"strbt${q} $Rt, $addr",
3161 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>;
3163 let mayStore = 1, hasSideEffects = 0 in {
3164 def STRT_POST_REG : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
3165 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
3166 IndexModePost, StFrm, IIC_iStore_ru,
3167 "strt", "\t$Rt, $addr, $offset",
3168 "$addr.base = $Rn_wb", []> {
3174 let Inst{23} = offset{12};
3175 let Inst{21} = 1; // overwrite
3176 let Inst{19-16} = addr;
3177 let Inst{11-5} = offset{11-5};
3179 let Inst{3-0} = offset{3-0};
3180 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3184 : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
3185 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
3186 IndexModePost, StFrm, IIC_iStore_ru,
3187 "strt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
3193 let Inst{23} = offset{12};
3194 let Inst{21} = 1; // overwrite
3195 let Inst{19-16} = addr;
3196 let Inst{11-0} = offset{11-0};
3197 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3202 : ARMAsmPseudo<"strt${q} $Rt, $addr",
3203 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>;
3205 multiclass AI3strT<bits<4> op, string opc> {
3206 def i : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
3207 (ins GPR:$Rt, addr_offset_none:$addr, postidx_imm8:$offset),
3208 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
3209 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
3211 let Inst{23} = offset{8};
3213 let Inst{11-8} = offset{7-4};
3214 let Inst{3-0} = offset{3-0};
3216 def r : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
3217 (ins GPR:$Rt, addr_offset_none:$addr, postidx_reg:$Rm),
3218 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
3219 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
3221 let Inst{23} = Rm{4};
3224 let Inst{3-0} = Rm{3-0};
3229 defm STRHT : AI3strT<0b1011, "strht">;
3231 def STL : AIstrrel<0b00, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3232 NoItinerary, "stl", "\t$Rt, $addr", []>;
3233 def STLB : AIstrrel<0b10, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3234 NoItinerary, "stlb", "\t$Rt, $addr", []>;
3235 def STLH : AIstrrel<0b11, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3236 NoItinerary, "stlh", "\t$Rt, $addr", []>;
3238 //===----------------------------------------------------------------------===//
3239 // Load / store multiple Instructions.
3242 multiclass arm_ldst_mult<string asm, string sfx, bit L_bit, bit P_bit, Format f,
3243 InstrItinClass itin, InstrItinClass itin_upd> {
3244 // IA is the default, so no need for an explicit suffix on the
3245 // mnemonic here. Without it is the canonical spelling.
3247 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3248 IndexModeNone, f, itin,
3249 !strconcat(asm, "${p}\t$Rn, $regs", sfx), "", []> {
3250 let Inst{24-23} = 0b01; // Increment After
3251 let Inst{22} = P_bit;
3252 let Inst{21} = 0; // No writeback
3253 let Inst{20} = L_bit;
3256 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3257 IndexModeUpd, f, itin_upd,
3258 !strconcat(asm, "${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3259 let Inst{24-23} = 0b01; // Increment After
3260 let Inst{22} = P_bit;
3261 let Inst{21} = 1; // Writeback
3262 let Inst{20} = L_bit;
3264 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3267 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3268 IndexModeNone, f, itin,
3269 !strconcat(asm, "da${p}\t$Rn, $regs", sfx), "", []> {
3270 let Inst{24-23} = 0b00; // Decrement After
3271 let Inst{22} = P_bit;
3272 let Inst{21} = 0; // No writeback
3273 let Inst{20} = L_bit;
3276 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3277 IndexModeUpd, f, itin_upd,
3278 !strconcat(asm, "da${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3279 let Inst{24-23} = 0b00; // Decrement After
3280 let Inst{22} = P_bit;
3281 let Inst{21} = 1; // Writeback
3282 let Inst{20} = L_bit;
3284 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3287 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3288 IndexModeNone, f, itin,
3289 !strconcat(asm, "db${p}\t$Rn, $regs", sfx), "", []> {
3290 let Inst{24-23} = 0b10; // Decrement Before
3291 let Inst{22} = P_bit;
3292 let Inst{21} = 0; // No writeback
3293 let Inst{20} = L_bit;
3296 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3297 IndexModeUpd, f, itin_upd,
3298 !strconcat(asm, "db${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3299 let Inst{24-23} = 0b10; // Decrement Before
3300 let Inst{22} = P_bit;
3301 let Inst{21} = 1; // Writeback
3302 let Inst{20} = L_bit;
3304 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3307 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3308 IndexModeNone, f, itin,
3309 !strconcat(asm, "ib${p}\t$Rn, $regs", sfx), "", []> {
3310 let Inst{24-23} = 0b11; // Increment Before
3311 let Inst{22} = P_bit;
3312 let Inst{21} = 0; // No writeback
3313 let Inst{20} = L_bit;
3316 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3317 IndexModeUpd, f, itin_upd,
3318 !strconcat(asm, "ib${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3319 let Inst{24-23} = 0b11; // Increment Before
3320 let Inst{22} = P_bit;
3321 let Inst{21} = 1; // Writeback
3322 let Inst{20} = L_bit;
3324 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3328 let hasSideEffects = 0 in {
3330 let mayLoad = 1, hasExtraDefRegAllocReq = 1, variadicOpsAreDefs = 1 in
3331 defm LDM : arm_ldst_mult<"ldm", "", 1, 0, LdStMulFrm, IIC_iLoad_m,
3332 IIC_iLoad_mu>, ComplexDeprecationPredicate<"ARMLoad">;
3334 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
3335 defm STM : arm_ldst_mult<"stm", "", 0, 0, LdStMulFrm, IIC_iStore_m,
3337 ComplexDeprecationPredicate<"ARMStore">;
3341 // FIXME: remove when we have a way to marking a MI with these properties.
3342 // FIXME: Should pc be an implicit operand like PICADD, etc?
3343 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
3344 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
3345 def LDMIA_RET : ARMPseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p,
3346 reglist:$regs, variable_ops),
3347 4, IIC_iLoad_mBr, [],
3348 (LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>,
3349 RegConstraint<"$Rn = $wb">;
3351 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
3352 defm sysLDM : arm_ldst_mult<"ldm", " ^", 1, 1, LdStMulFrm, IIC_iLoad_m,
3355 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
3356 defm sysSTM : arm_ldst_mult<"stm", " ^", 0, 1, LdStMulFrm, IIC_iStore_m,
3361 //===----------------------------------------------------------------------===//
3362 // Move Instructions.
3365 let hasSideEffects = 0, isMoveReg = 1 in
3366 def MOVr : AsI1<0b1101, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMOVr,
3367 "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> {
3371 let Inst{19-16} = 0b0000;
3372 let Inst{11-4} = 0b00000000;
3375 let Inst{15-12} = Rd;
3378 // A version for the smaller set of tail call registers.
3379 let hasSideEffects = 0 in
3380 def MOVr_TC : AsI1<0b1101, (outs tcGPR:$Rd), (ins tcGPR:$Rm), DPFrm,
3381 IIC_iMOVr, "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> {
3385 let Inst{11-4} = 0b00000000;
3388 let Inst{15-12} = Rd;
3391 def MOVsr : AsI1<0b1101, (outs GPRnopc:$Rd), (ins shift_so_reg_reg:$src),
3392 DPSoRegRegFrm, IIC_iMOVsr,
3393 "mov", "\t$Rd, $src",
3394 [(set GPRnopc:$Rd, shift_so_reg_reg:$src)]>, UnaryDP,
3398 let Inst{15-12} = Rd;
3399 let Inst{19-16} = 0b0000;
3400 let Inst{11-8} = src{11-8};
3402 let Inst{6-5} = src{6-5};
3404 let Inst{3-0} = src{3-0};
3408 def MOVsi : AsI1<0b1101, (outs GPR:$Rd), (ins shift_so_reg_imm:$src),
3409 DPSoRegImmFrm, IIC_iMOVsr,
3410 "mov", "\t$Rd, $src", [(set GPR:$Rd, shift_so_reg_imm:$src)]>,
3411 UnaryDP, Sched<[WriteALU]> {
3414 let Inst{15-12} = Rd;
3415 let Inst{19-16} = 0b0000;
3416 let Inst{11-5} = src{11-5};
3418 let Inst{3-0} = src{3-0};
3422 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3423 def MOVi : AsI1<0b1101, (outs GPR:$Rd), (ins mod_imm:$imm), DPFrm, IIC_iMOVi,
3424 "mov", "\t$Rd, $imm", [(set GPR:$Rd, mod_imm:$imm)]>, UnaryDP,
3429 let Inst{15-12} = Rd;
3430 let Inst{19-16} = 0b0000;
3431 let Inst{11-0} = imm;
3434 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3435 def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins imm0_65535_expr:$imm),
3437 "movw", "\t$Rd, $imm",
3438 [(set GPR:$Rd, imm0_65535:$imm)]>,
3439 Requires<[IsARM, HasV6T2]>, UnaryDP, Sched<[WriteALU]> {
3442 let Inst{15-12} = Rd;
3443 let Inst{11-0} = imm{11-0};
3444 let Inst{19-16} = imm{15-12};
3447 let DecoderMethod = "DecodeArmMOVTWInstruction";
3450 def : InstAlias<"mov${p} $Rd, $imm",
3451 (MOVi16 GPR:$Rd, imm0_65535_expr:$imm, pred:$p), 0>,
3452 Requires<[IsARM, HasV6T2]>;
3454 def MOVi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
3455 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
3458 let Constraints = "$src = $Rd" in {
3459 def MOVTi16 : AI1<0b1010, (outs GPRnopc:$Rd),
3460 (ins GPR:$src, imm0_65535_expr:$imm),
3462 "movt", "\t$Rd, $imm",
3464 (or (and GPR:$src, 0xffff),
3465 lo16AllZero:$imm))]>, UnaryDP,
3466 Requires<[IsARM, HasV6T2]>, Sched<[WriteALU]> {
3469 let Inst{15-12} = Rd;
3470 let Inst{11-0} = imm{11-0};
3471 let Inst{19-16} = imm{15-12};
3474 let DecoderMethod = "DecodeArmMOVTWInstruction";
3477 def MOVTi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
3478 (ins GPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
3483 def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
3484 Requires<[IsARM, HasV6T2]>;
3486 let Uses = [CPSR] in
3487 def RRX: PseudoInst<(outs GPR:$Rd), (ins GPR:$Rm), IIC_iMOVsi,
3488 [(set GPR:$Rd, (ARMrrx GPR:$Rm))]>, UnaryDP,
3489 Requires<[IsARM]>, Sched<[WriteALU]>;
3491 // These aren't really mov instructions, but we have to define them this way
3492 // due to flag operands.
3494 let Defs = [CPSR] in {
3495 def MOVsrl_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3496 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP,
3497 Sched<[WriteALU]>, Requires<[IsARM]>;
3498 def MOVsra_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3499 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP,
3500 Sched<[WriteALU]>, Requires<[IsARM]>;
3503 //===----------------------------------------------------------------------===//
3504 // Extend Instructions.
3509 def SXTB : AI_ext_rrot<0b01101010,
3510 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
3511 def SXTH : AI_ext_rrot<0b01101011,
3512 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
3514 def SXTAB : AI_exta_rrot<0b01101010,
3515 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
3516 def SXTAH : AI_exta_rrot<0b01101011,
3517 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
3519 def : ARMV6Pat<(add rGPR:$Rn, (sext_inreg (srl rGPR:$Rm, rot_imm:$rot), i8)),
3520 (SXTAB rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
3521 def : ARMV6Pat<(add rGPR:$Rn, (sext_inreg (srl rGPR:$Rm, imm8_or_16:$rot),
3523 (SXTAH rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
3525 def SXTB16 : AI_ext_rrot_np<0b01101000, "sxtb16">;
3526 def : ARMV6Pat<(int_arm_sxtb16 GPR:$Src),
3527 (SXTB16 GPR:$Src, 0)>;
3528 def : ARMV6Pat<(int_arm_sxtb16 (rotr GPR:$Src, rot_imm:$rot)),
3529 (SXTB16 GPR:$Src, rot_imm:$rot)>;
3531 def SXTAB16 : AI_exta_rrot_np<0b01101000, "sxtab16">;
3532 def : ARMV6Pat<(int_arm_sxtab16 GPR:$LHS, GPR:$RHS),
3533 (SXTAB16 GPR:$LHS, GPR:$RHS, 0)>;
3534 def : ARMV6Pat<(int_arm_sxtab16 GPR:$LHS, (rotr GPR:$RHS, rot_imm:$rot)),
3535 (SXTAB16 GPR:$LHS, GPR:$RHS, rot_imm:$rot)>;
3539 let AddedComplexity = 16 in {
3540 def UXTB : AI_ext_rrot<0b01101110,
3541 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
3542 def UXTH : AI_ext_rrot<0b01101111,
3543 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
3544 def UXTB16 : AI_ext_rrot<0b01101100,
3545 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
3547 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
3548 // The transformation should probably be done as a combiner action
3549 // instead so we can include a check for masking back in the upper
3550 // eight bits of the source into the lower eight bits of the result.
3551 //def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
3552 // (UXTB16r_rot GPR:$Src, 3)>;
3553 def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
3554 (UXTB16 GPR:$Src, 1)>;
3555 def : ARMV6Pat<(int_arm_uxtb16 GPR:$Src),
3556 (UXTB16 GPR:$Src, 0)>;
3557 def : ARMV6Pat<(int_arm_uxtb16 (rotr GPR:$Src, rot_imm:$rot)),
3558 (UXTB16 GPR:$Src, rot_imm:$rot)>;
3560 def UXTAB : AI_exta_rrot<0b01101110, "uxtab",
3561 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
3562 def UXTAH : AI_exta_rrot<0b01101111, "uxtah",
3563 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
3565 def : ARMV6Pat<(add rGPR:$Rn, (and (srl rGPR:$Rm, rot_imm:$rot), 0xFF)),
3566 (UXTAB rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
3567 def : ARMV6Pat<(add rGPR:$Rn, (and (srl rGPR:$Rm, imm8_or_16:$rot), 0xFFFF)),
3568 (UXTAH rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
3571 // This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
3572 def UXTAB16 : AI_exta_rrot_np<0b01101100, "uxtab16">;
3573 def : ARMV6Pat<(int_arm_uxtab16 GPR:$LHS, GPR:$RHS),
3574 (UXTAB16 GPR:$LHS, GPR:$RHS, 0)>;
3575 def : ARMV6Pat<(int_arm_uxtab16 GPR:$LHS, (rotr GPR:$RHS, rot_imm:$rot)),
3576 (UXTAB16 GPR:$LHS, GPR:$RHS, rot_imm:$rot)>;
3579 def SBFX : I<(outs GPRnopc:$Rd),
3580 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3581 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3582 "sbfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3583 Requires<[IsARM, HasV6T2]> {
3588 let Inst{27-21} = 0b0111101;
3589 let Inst{6-4} = 0b101;
3590 let Inst{20-16} = width;
3591 let Inst{15-12} = Rd;
3592 let Inst{11-7} = lsb;
3596 def UBFX : I<(outs GPRnopc:$Rd),
3597 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3598 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3599 "ubfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3600 Requires<[IsARM, HasV6T2]> {
3605 let Inst{27-21} = 0b0111111;
3606 let Inst{6-4} = 0b101;
3607 let Inst{20-16} = width;
3608 let Inst{15-12} = Rd;
3609 let Inst{11-7} = lsb;
3613 //===----------------------------------------------------------------------===//
3614 // Arithmetic Instructions.
3618 defm ADD : AsI1_bin_irs<0b0100, "add",
3619 IIC_iALUi, IIC_iALUr, IIC_iALUsr, add, 1>;
3620 defm SUB : AsI1_bin_irs<0b0010, "sub",
3621 IIC_iALUi, IIC_iALUr, IIC_iALUsr, sub>;
3623 // ADD and SUB with 's' bit set.
3625 // Currently, ADDS/SUBS are pseudo opcodes that exist only in the
3626 // selection DAG. They are "lowered" to real ADD/SUB opcodes by
3627 // AdjustInstrPostInstrSelection where we determine whether or not to
3628 // set the "s" bit based on CPSR liveness.
3630 // FIXME: Eliminate ADDS/SUBS pseudo opcodes after adding tablegen
3631 // support for an optional CPSR definition that corresponds to the DAG
3632 // node's second value. We can then eliminate the implicit def of CPSR.
3634 defm ADDS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr, ARMaddc, 1>;
3635 defm SUBS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr, ARMsubc>;
3637 def : ARMPat<(ARMsubs GPR:$Rn, mod_imm:$imm), (SUBSri $Rn, mod_imm:$imm)>;
3638 def : ARMPat<(ARMsubs GPR:$Rn, GPR:$Rm), (SUBSrr $Rn, $Rm)>;
3639 def : ARMPat<(ARMsubs GPR:$Rn, so_reg_imm:$shift),
3640 (SUBSrsi $Rn, so_reg_imm:$shift)>;
3641 def : ARMPat<(ARMsubs GPR:$Rn, so_reg_reg:$shift),
3642 (SUBSrsr $Rn, so_reg_reg:$shift)>;
3646 defm ADC : AI1_adde_sube_irs<0b0101, "adc", ARMadde, 1>;
3647 defm SBC : AI1_adde_sube_irs<0b0110, "sbc", ARMsube>;
3649 defm RSB : AsI1_rbin_irs<0b0011, "rsb",
3650 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3653 // FIXME: Eliminate them if we can write def : Pat patterns which defines
3654 // CPSR and the implicit def of CPSR is not needed.
3655 defm RSBS : AsI1_rbin_s_is<IIC_iALUi, IIC_iALUr, IIC_iALUsr, ARMsubc>;
3657 defm RSC : AI1_rsc_irs<0b0111, "rsc", ARMsube>;
3659 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
3660 // The assume-no-carry-in form uses the negation of the input since add/sub
3661 // assume opposite meanings of the carry flag (i.e., carry == !borrow).
3662 // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
3664 def : ARMPat<(add GPR:$src, mod_imm_neg:$imm),
3665 (SUBri GPR:$src, mod_imm_neg:$imm)>;
3666 def : ARMPat<(ARMaddc GPR:$src, mod_imm_neg:$imm),
3667 (SUBSri GPR:$src, mod_imm_neg:$imm)>;
3669 def : ARMPat<(add GPR:$src, imm0_65535_neg:$imm),
3670 (SUBrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>,
3671 Requires<[IsARM, HasV6T2]>;
3672 def : ARMPat<(ARMaddc GPR:$src, imm0_65535_neg:$imm),
3673 (SUBSrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>,
3674 Requires<[IsARM, HasV6T2]>;
3676 // The with-carry-in form matches bitwise not instead of the negation.
3677 // Effectively, the inverse interpretation of the carry flag already accounts
3678 // for part of the negation.
3679 def : ARMPat<(ARMadde GPR:$src, mod_imm_not:$imm, CPSR),
3680 (SBCri GPR:$src, mod_imm_not:$imm)>;
3681 def : ARMPat<(ARMadde GPR:$src, imm0_65535_neg:$imm, CPSR),
3682 (SBCrr GPR:$src, (MOVi16 (imm_not_XFORM imm:$imm)))>,
3683 Requires<[IsARM, HasV6T2]>;
3685 // Note: These are implemented in C++ code, because they have to generate
3686 // ADD/SUBrs instructions, which use a complex pattern that a xform function
3688 // (mul X, 2^n+1) -> (add (X << n), X)
3689 // (mul X, 2^n-1) -> (rsb X, (X << n))
3691 // ARM Arithmetic Instruction
3692 // GPR:$dst = GPR:$a op GPR:$b
3693 class AAI<bits<8> op27_20, bits<8> op11_4, string opc,
3694 list<dag> pattern = [],
3695 dag iops = (ins GPRnopc:$Rn, GPRnopc:$Rm),
3696 string asm = "\t$Rd, $Rn, $Rm">
3697 : AI<(outs GPRnopc:$Rd), iops, DPFrm, IIC_iALUr, opc, asm, pattern>,
3698 Sched<[WriteALU, ReadALU, ReadALU]> {
3702 let Inst{27-20} = op27_20;
3703 let Inst{11-4} = op11_4;
3704 let Inst{19-16} = Rn;
3705 let Inst{15-12} = Rd;
3708 let Unpredictable{11-8} = 0b1111;
3711 // Wrappers around the AAI class
3712 class AAIRevOpr<bits<8> op27_20, bits<8> op11_4, string opc,
3713 list<dag> pattern = []>
3714 : AAI<op27_20, op11_4, opc,
3716 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3719 class AAIIntrinsic<bits<8> op27_20, bits<8> op11_4, string opc,
3720 Intrinsic intrinsic>
3721 : AAI<op27_20, op11_4, opc,
3722 [(set GPRnopc:$Rd, (intrinsic GPRnopc:$Rn, GPRnopc:$Rm))]>;
3724 // Saturating add/subtract
3725 let hasSideEffects = 1 in {
3726 def QADD8 : AAIIntrinsic<0b01100010, 0b11111001, "qadd8", int_arm_qadd8>;
3727 def QADD16 : AAIIntrinsic<0b01100010, 0b11110001, "qadd16", int_arm_qadd16>;
3728 def QSUB16 : AAIIntrinsic<0b01100010, 0b11110111, "qsub16", int_arm_qsub16>;
3729 def QSUB8 : AAIIntrinsic<0b01100010, 0b11111111, "qsub8", int_arm_qsub8>;
3731 def QDADD : AAIRevOpr<0b00010100, 0b00000101, "qdadd",
3732 [(set GPRnopc:$Rd, (int_arm_qadd (int_arm_qadd GPRnopc:$Rm,
3735 def QDSUB : AAIRevOpr<0b00010110, 0b00000101, "qdsub",
3736 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm,
3737 (int_arm_qadd GPRnopc:$Rn, GPRnopc:$Rn)))]>;
3738 def QSUB : AAIRevOpr<0b00010010, 0b00000101, "qsub",
3739 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm, GPRnopc:$Rn))]>;
3740 let DecoderMethod = "DecodeQADDInstruction" in
3741 def QADD : AAIRevOpr<0b00010000, 0b00000101, "qadd",
3742 [(set GPRnopc:$Rd, (int_arm_qadd GPRnopc:$Rm, GPRnopc:$Rn))]>;
3745 def UQADD16 : AAIIntrinsic<0b01100110, 0b11110001, "uqadd16", int_arm_uqadd16>;
3746 def UQADD8 : AAIIntrinsic<0b01100110, 0b11111001, "uqadd8", int_arm_uqadd8>;
3747 def UQSUB16 : AAIIntrinsic<0b01100110, 0b11110111, "uqsub16", int_arm_uqsub16>;
3748 def UQSUB8 : AAIIntrinsic<0b01100110, 0b11111111, "uqsub8", int_arm_uqsub8>;
3749 def QASX : AAIIntrinsic<0b01100010, 0b11110011, "qasx", int_arm_qasx>;
3750 def QSAX : AAIIntrinsic<0b01100010, 0b11110101, "qsax", int_arm_qsax>;
3751 def UQASX : AAIIntrinsic<0b01100110, 0b11110011, "uqasx", int_arm_uqasx>;
3752 def UQSAX : AAIIntrinsic<0b01100110, 0b11110101, "uqsax", int_arm_uqsax>;
3754 // Signed/Unsigned add/subtract
3756 def SASX : AAIIntrinsic<0b01100001, 0b11110011, "sasx", int_arm_sasx>;
3757 def SADD16 : AAIIntrinsic<0b01100001, 0b11110001, "sadd16", int_arm_sadd16>;
3758 def SADD8 : AAIIntrinsic<0b01100001, 0b11111001, "sadd8", int_arm_sadd8>;
3759 def SSAX : AAIIntrinsic<0b01100001, 0b11110101, "ssax", int_arm_ssax>;
3760 def SSUB16 : AAIIntrinsic<0b01100001, 0b11110111, "ssub16", int_arm_ssub16>;
3761 def SSUB8 : AAIIntrinsic<0b01100001, 0b11111111, "ssub8", int_arm_ssub8>;
3762 def UASX : AAIIntrinsic<0b01100101, 0b11110011, "uasx", int_arm_uasx>;
3763 def UADD16 : AAIIntrinsic<0b01100101, 0b11110001, "uadd16", int_arm_uadd16>;
3764 def UADD8 : AAIIntrinsic<0b01100101, 0b11111001, "uadd8", int_arm_uadd8>;
3765 def USAX : AAIIntrinsic<0b01100101, 0b11110101, "usax", int_arm_usax>;
3766 def USUB16 : AAIIntrinsic<0b01100101, 0b11110111, "usub16", int_arm_usub16>;
3767 def USUB8 : AAIIntrinsic<0b01100101, 0b11111111, "usub8", int_arm_usub8>;
3769 // Signed/Unsigned halving add/subtract
3771 def SHASX : AAIIntrinsic<0b01100011, 0b11110011, "shasx", int_arm_shasx>;
3772 def SHADD16 : AAIIntrinsic<0b01100011, 0b11110001, "shadd16", int_arm_shadd16>;
3773 def SHADD8 : AAIIntrinsic<0b01100011, 0b11111001, "shadd8", int_arm_shadd8>;
3774 def SHSAX : AAIIntrinsic<0b01100011, 0b11110101, "shsax", int_arm_shsax>;
3775 def SHSUB16 : AAIIntrinsic<0b01100011, 0b11110111, "shsub16", int_arm_shsub16>;
3776 def SHSUB8 : AAIIntrinsic<0b01100011, 0b11111111, "shsub8", int_arm_shsub8>;
3777 def UHASX : AAIIntrinsic<0b01100111, 0b11110011, "uhasx", int_arm_uhasx>;
3778 def UHADD16 : AAIIntrinsic<0b01100111, 0b11110001, "uhadd16", int_arm_uhadd16>;
3779 def UHADD8 : AAIIntrinsic<0b01100111, 0b11111001, "uhadd8", int_arm_uhadd8>;
3780 def UHSAX : AAIIntrinsic<0b01100111, 0b11110101, "uhsax", int_arm_uhsax>;
3781 def UHSUB16 : AAIIntrinsic<0b01100111, 0b11110111, "uhsub16", int_arm_uhsub16>;
3782 def UHSUB8 : AAIIntrinsic<0b01100111, 0b11111111, "uhsub8", int_arm_uhsub8>;
3784 // Unsigned Sum of Absolute Differences [and Accumulate].
3786 def USAD8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3787 MulFrm /* for convenience */, NoItinerary, "usad8",
3789 [(set GPR:$Rd, (int_arm_usad8 GPR:$Rn, GPR:$Rm))]>,
3790 Requires<[IsARM, HasV6]>, Sched<[WriteALU, ReadALU, ReadALU]> {
3794 let Inst{27-20} = 0b01111000;
3795 let Inst{15-12} = 0b1111;
3796 let Inst{7-4} = 0b0001;
3797 let Inst{19-16} = Rd;
3798 let Inst{11-8} = Rm;
3801 def USADA8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3802 MulFrm /* for convenience */, NoItinerary, "usada8",
3803 "\t$Rd, $Rn, $Rm, $Ra",
3804 [(set GPR:$Rd, (int_arm_usada8 GPR:$Rn, GPR:$Rm, GPR:$Ra))]>,
3805 Requires<[IsARM, HasV6]>, Sched<[WriteALU, ReadALU, ReadALU]>{
3810 let Inst{27-20} = 0b01111000;
3811 let Inst{7-4} = 0b0001;
3812 let Inst{19-16} = Rd;
3813 let Inst{15-12} = Ra;
3814 let Inst{11-8} = Rm;
3818 // Signed/Unsigned saturate
3819 def SSAT : AI<(outs GPRnopc:$Rd),
3820 (ins imm1_32:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3821 SatFrm, NoItinerary, "ssat", "\t$Rd, $sat_imm, $Rn$sh", []>,
3822 Requires<[IsARM,HasV6]>{
3827 let Inst{27-21} = 0b0110101;
3828 let Inst{5-4} = 0b01;
3829 let Inst{20-16} = sat_imm;
3830 let Inst{15-12} = Rd;
3831 let Inst{11-7} = sh{4-0};
3832 let Inst{6} = sh{5};
3836 def SSAT16 : AI<(outs GPRnopc:$Rd),
3837 (ins imm1_16:$sat_imm, GPRnopc:$Rn), SatFrm,
3838 NoItinerary, "ssat16", "\t$Rd, $sat_imm, $Rn", []>,
3839 Requires<[IsARM,HasV6]>{
3843 let Inst{27-20} = 0b01101010;
3844 let Inst{11-4} = 0b11110011;
3845 let Inst{15-12} = Rd;
3846 let Inst{19-16} = sat_imm;
3850 def USAT : AI<(outs GPRnopc:$Rd),
3851 (ins imm0_31:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3852 SatFrm, NoItinerary, "usat", "\t$Rd, $sat_imm, $Rn$sh", []>,
3853 Requires<[IsARM,HasV6]> {
3858 let Inst{27-21} = 0b0110111;
3859 let Inst{5-4} = 0b01;
3860 let Inst{15-12} = Rd;
3861 let Inst{11-7} = sh{4-0};
3862 let Inst{6} = sh{5};
3863 let Inst{20-16} = sat_imm;
3867 def USAT16 : AI<(outs GPRnopc:$Rd),
3868 (ins imm0_15:$sat_imm, GPRnopc:$Rn), SatFrm,
3869 NoItinerary, "usat16", "\t$Rd, $sat_imm, $Rn", []>,
3870 Requires<[IsARM,HasV6]>{
3874 let Inst{27-20} = 0b01101110;
3875 let Inst{11-4} = 0b11110011;
3876 let Inst{15-12} = Rd;
3877 let Inst{19-16} = sat_imm;
3881 def : ARMV6Pat<(int_arm_ssat GPRnopc:$a, imm1_32:$pos),
3882 (SSAT imm1_32:$pos, GPRnopc:$a, 0)>;
3883 def : ARMV6Pat<(int_arm_usat GPRnopc:$a, imm0_31:$pos),
3884 (USAT imm0_31:$pos, GPRnopc:$a, 0)>;
3885 def : ARMPat<(ARMssatnoshift GPRnopc:$Rn, imm0_31:$imm),
3886 (SSAT imm0_31:$imm, GPRnopc:$Rn, 0)>;
3887 def : ARMPat<(ARMusatnoshift GPRnopc:$Rn, imm0_31:$imm),
3888 (USAT imm0_31:$imm, GPRnopc:$Rn, 0)>;
3889 def : ARMV6Pat<(int_arm_ssat16 GPRnopc:$a, imm1_16:$pos),
3890 (SSAT16 imm1_16:$pos, GPRnopc:$a)>;
3891 def : ARMV6Pat<(int_arm_usat16 GPRnopc:$a, imm0_15:$pos),
3892 (USAT16 imm0_15:$pos, GPRnopc:$a)>;
3894 //===----------------------------------------------------------------------===//
3895 // Bitwise Instructions.
3898 defm AND : AsI1_bin_irs<0b0000, "and",
3899 IIC_iBITi, IIC_iBITr, IIC_iBITsr, and, 1>;
3900 defm ORR : AsI1_bin_irs<0b1100, "orr",
3901 IIC_iBITi, IIC_iBITr, IIC_iBITsr, or, 1>;
3902 defm EOR : AsI1_bin_irs<0b0001, "eor",
3903 IIC_iBITi, IIC_iBITr, IIC_iBITsr, xor, 1>;
3904 defm BIC : AsI1_bin_irs<0b1110, "bic",
3905 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3906 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
3908 // FIXME: bf_inv_mask_imm should be two operands, the lsb and the msb, just
3909 // like in the actual instruction encoding. The complexity of mapping the mask
3910 // to the lsb/msb pair should be handled by ISel, not encapsulated in the
3911 // instruction description.
3912 def BFC : I<(outs GPR:$Rd), (ins GPR:$src, bf_inv_mask_imm:$imm),
3913 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3914 "bfc", "\t$Rd, $imm", "$src = $Rd",
3915 [(set GPR:$Rd, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
3916 Requires<[IsARM, HasV6T2]> {
3919 let Inst{27-21} = 0b0111110;
3920 let Inst{6-0} = 0b0011111;
3921 let Inst{15-12} = Rd;
3922 let Inst{11-7} = imm{4-0}; // lsb
3923 let Inst{20-16} = imm{9-5}; // msb
3926 // A8.6.18 BFI - Bitfield insert (Encoding A1)
3927 def BFI:I<(outs GPRnopc:$Rd), (ins GPRnopc:$src, GPR:$Rn, bf_inv_mask_imm:$imm),
3928 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3929 "bfi", "\t$Rd, $Rn, $imm", "$src = $Rd",
3930 [(set GPRnopc:$Rd, (ARMbfi GPRnopc:$src, GPR:$Rn,
3931 bf_inv_mask_imm:$imm))]>,
3932 Requires<[IsARM, HasV6T2]> {
3936 let Inst{27-21} = 0b0111110;
3937 let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15
3938 let Inst{15-12} = Rd;
3939 let Inst{11-7} = imm{4-0}; // lsb
3940 let Inst{20-16} = imm{9-5}; // width
3944 def MVNr : AsI1<0b1111, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMVNr,
3945 "mvn", "\t$Rd, $Rm",
3946 [(set GPR:$Rd, (not GPR:$Rm))]>, UnaryDP, Sched<[WriteALU]> {
3950 let Inst{19-16} = 0b0000;
3951 let Inst{11-4} = 0b00000000;
3952 let Inst{15-12} = Rd;
3955 let Unpredictable{19-16} = 0b1111;
3957 def MVNsi : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_imm:$shift),
3958 DPSoRegImmFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3959 [(set GPR:$Rd, (not so_reg_imm:$shift))]>, UnaryDP,
3964 let Inst{19-16} = 0b0000;
3965 let Inst{15-12} = Rd;
3966 let Inst{11-5} = shift{11-5};
3968 let Inst{3-0} = shift{3-0};
3970 let Unpredictable{19-16} = 0b1111;
3972 def MVNsr : AsI1<0b1111, (outs GPRnopc:$Rd), (ins so_reg_reg:$shift),
3973 DPSoRegRegFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3974 [(set GPRnopc:$Rd, (not so_reg_reg:$shift))]>, UnaryDP,
3979 let Inst{19-16} = 0b0000;
3980 let Inst{15-12} = Rd;
3981 let Inst{11-8} = shift{11-8};
3983 let Inst{6-5} = shift{6-5};
3985 let Inst{3-0} = shift{3-0};
3987 let Unpredictable{19-16} = 0b1111;
3989 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3990 def MVNi : AsI1<0b1111, (outs GPR:$Rd), (ins mod_imm:$imm), DPFrm,
3991 IIC_iMVNi, "mvn", "\t$Rd, $imm",
3992 [(set GPR:$Rd, mod_imm_not:$imm)]>,UnaryDP, Sched<[WriteALU]> {
3996 let Inst{19-16} = 0b0000;
3997 let Inst{15-12} = Rd;
3998 let Inst{11-0} = imm;
4001 let AddedComplexity = 1 in
4002 def : ARMPat<(and GPR:$src, mod_imm_not:$imm),
4003 (BICri GPR:$src, mod_imm_not:$imm)>;
4005 //===----------------------------------------------------------------------===//
4006 // Multiply Instructions.
4008 class AsMul1I32<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
4009 string opc, string asm, list<dag> pattern>
4010 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
4014 let Inst{19-16} = Rd;
4015 let Inst{11-8} = Rm;
4018 class AsMul1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
4019 string opc, string asm, list<dag> pattern>
4020 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
4025 let Inst{19-16} = RdHi;
4026 let Inst{15-12} = RdLo;
4027 let Inst{11-8} = Rm;
4030 class AsMla1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
4031 string opc, string asm, list<dag> pattern>
4032 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
4037 let Inst{19-16} = RdHi;
4038 let Inst{15-12} = RdLo;
4039 let Inst{11-8} = Rm;
4043 // FIXME: The v5 pseudos are only necessary for the additional Constraint
4044 // property. Remove them when it's possible to add those properties
4045 // on an individual MachineInstr, not just an instruction description.
4046 let isCommutable = 1, TwoOperandAliasConstraint = "$Rn = $Rd" in {
4047 def MUL : AsMul1I32<0b0000000, (outs GPRnopc:$Rd),
4048 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4049 IIC_iMUL32, "mul", "\t$Rd, $Rn, $Rm",
4050 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))]>,
4051 Requires<[IsARM, HasV6]>,
4052 Sched<[WriteMUL32, ReadMUL, ReadMUL]> {
4053 let Inst{15-12} = 0b0000;
4054 let Unpredictable{15-12} = 0b1111;
4057 let Constraints = "@earlyclobber $Rd" in
4058 def MULv5: ARMPseudoExpand<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm,
4059 pred:$p, cc_out:$s),
4061 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))],
4062 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s)>,
4063 Requires<[IsARM, NoV6, UseMulOps]>,
4064 Sched<[WriteMUL32, ReadMUL, ReadMUL]>;
4067 def MLA : AsMul1I32<0b0000001, (outs GPRnopc:$Rd),
4068 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra),
4069 IIC_iMAC32, "mla", "\t$Rd, $Rn, $Rm, $Ra",
4070 [(set GPRnopc:$Rd, (add (mul GPRnopc:$Rn, GPRnopc:$Rm), GPRnopc:$Ra))]>,
4071 Requires<[IsARM, HasV6, UseMulOps]>,
4072 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]> {
4074 let Inst{15-12} = Ra;
4077 let Constraints = "@earlyclobber $Rd" in
4078 def MLAv5: ARMPseudoExpand<(outs GPRnopc:$Rd),
4079 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra,
4080 pred:$p, cc_out:$s), 4, IIC_iMAC32,
4081 [(set GPRnopc:$Rd, (add (mul GPRnopc:$Rn, GPRnopc:$Rm), GPRnopc:$Ra))],
4082 (MLA GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra, pred:$p, cc_out:$s)>,
4083 Requires<[IsARM, NoV6]>,
4084 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4086 def MLS : AMul1I<0b0000011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4087 IIC_iMAC32, "mls", "\t$Rd, $Rn, $Rm, $Ra",
4088 [(set GPR:$Rd, (sub GPR:$Ra, (mul GPR:$Rn, GPR:$Rm)))]>,
4089 Requires<[IsARM, HasV6T2, UseMulOps]>,
4090 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]> {
4095 let Inst{19-16} = Rd;
4096 let Inst{15-12} = Ra;
4097 let Inst{11-8} = Rm;
4101 // Extra precision multiplies with low / high results
4102 let hasSideEffects = 0 in {
4103 let isCommutable = 1 in {
4104 def SMULL : AsMul1I64<0b0000110, (outs GPR:$RdLo, GPR:$RdHi),
4105 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
4106 "smull", "\t$RdLo, $RdHi, $Rn, $Rm",
4107 [(set GPR:$RdLo, GPR:$RdHi,
4108 (smullohi GPR:$Rn, GPR:$Rm))]>,
4109 Requires<[IsARM, HasV6]>,
4110 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>;
4112 def UMULL : AsMul1I64<0b0000100, (outs GPR:$RdLo, GPR:$RdHi),
4113 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
4114 "umull", "\t$RdLo, $RdHi, $Rn, $Rm",
4115 [(set GPR:$RdLo, GPR:$RdHi,
4116 (umullohi GPR:$Rn, GPR:$Rm))]>,
4117 Requires<[IsARM, HasV6]>,
4118 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL]>;
4120 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
4121 def SMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
4122 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
4124 [(set GPR:$RdLo, GPR:$RdHi,
4125 (smullohi GPR:$Rn, GPR:$Rm))],
4126 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
4127 Requires<[IsARM, NoV6]>,
4128 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>;
4130 def UMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
4131 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
4133 [(set GPR:$RdLo, GPR:$RdHi,
4134 (umullohi GPR:$Rn, GPR:$Rm))],
4135 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
4136 Requires<[IsARM, NoV6]>,
4137 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>;
4141 // Multiply + accumulate
4142 def SMLAL : AsMla1I64<0b0000111, (outs GPR:$RdLo, GPR:$RdHi),
4143 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64,
4144 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4145 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>,
4146 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4147 def UMLAL : AsMla1I64<0b0000101, (outs GPR:$RdLo, GPR:$RdHi),
4148 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64,
4149 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4150 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>,
4151 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4153 def UMAAL : AMul1I <0b0000010, (outs GPR:$RdLo, GPR:$RdHi),
4154 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4156 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4157 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>,
4158 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]> {
4163 let Inst{19-16} = RdHi;
4164 let Inst{15-12} = RdLo;
4165 let Inst{11-8} = Rm;
4170 "@earlyclobber $RdLo,@earlyclobber $RdHi,$RLo = $RdLo,$RHi = $RdHi" in {
4171 def SMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
4172 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s),
4174 (SMLAL 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]>;
4178 def UMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
4179 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s),
4181 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi,
4182 pred:$p, cc_out:$s)>,
4183 Requires<[IsARM, NoV6]>,
4184 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4189 // Most significant word multiply
4190 def SMMUL : AMul2I <0b0111010, 0b0001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4191 IIC_iMUL32, "smmul", "\t$Rd, $Rn, $Rm",
4192 [(set GPR:$Rd, (mulhs GPR:$Rn, GPR:$Rm))]>,
4193 Requires<[IsARM, HasV6]>,
4194 Sched<[WriteMUL32, ReadMUL, ReadMUL]> {
4195 let Inst{15-12} = 0b1111;
4198 def SMMULR : AMul2I <0b0111010, 0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4199 IIC_iMUL32, "smmulr", "\t$Rd, $Rn, $Rm",
4200 [(set GPR:$Rd, (ARMsmmlar GPR:$Rn, GPR:$Rm, (i32 0)))]>,
4201 Requires<[IsARM, HasV6]>,
4202 Sched<[WriteMUL32, ReadMUL, ReadMUL]> {
4203 let Inst{15-12} = 0b1111;
4206 def SMMLA : AMul2Ia <0b0111010, 0b0001, (outs GPR:$Rd),
4207 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4208 IIC_iMAC32, "smmla", "\t$Rd, $Rn, $Rm, $Ra",
4209 [(set GPR:$Rd, (add (mulhs GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
4210 Requires<[IsARM, HasV6, UseMulOps]>,
4211 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4213 def SMMLAR : AMul2Ia <0b0111010, 0b0011, (outs GPR:$Rd),
4214 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4215 IIC_iMAC32, "smmlar", "\t$Rd, $Rn, $Rm, $Ra",
4216 [(set GPR:$Rd, (ARMsmmlar GPR:$Rn, GPR:$Rm, GPR:$Ra))]>,
4217 Requires<[IsARM, HasV6]>,
4218 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4220 def SMMLS : AMul2Ia <0b0111010, 0b1101, (outs GPR:$Rd),
4221 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4222 IIC_iMAC32, "smmls", "\t$Rd, $Rn, $Rm, $Ra", []>,
4223 Requires<[IsARM, HasV6, UseMulOps]>,
4224 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4226 def SMMLSR : AMul2Ia <0b0111010, 0b1111, (outs GPR:$Rd),
4227 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4228 IIC_iMAC32, "smmlsr", "\t$Rd, $Rn, $Rm, $Ra",
4229 [(set GPR:$Rd, (ARMsmmlsr GPR:$Rn, GPR:$Rm, GPR:$Ra))]>,
4230 Requires<[IsARM, HasV6]>,
4231 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4233 multiclass AI_smul<string opc> {
4234 def BB : AMulxyI<0b0001011, 0b00, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4235 IIC_iMUL16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm",
4236 [(set GPR:$Rd, (bb_mul GPR:$Rn, GPR:$Rm))]>,
4237 Requires<[IsARM, HasV5TE]>,
4238 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4240 def BT : AMulxyI<0b0001011, 0b10, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4241 IIC_iMUL16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm",
4242 [(set GPR:$Rd, (bt_mul GPR:$Rn, GPR:$Rm))]>,
4243 Requires<[IsARM, HasV5TE]>,
4244 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4246 def TB : AMulxyI<0b0001011, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4247 IIC_iMUL16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm",
4248 [(set GPR:$Rd, (tb_mul GPR:$Rn, GPR:$Rm))]>,
4249 Requires<[IsARM, HasV5TE]>,
4250 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4252 def TT : AMulxyI<0b0001011, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4253 IIC_iMUL16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm",
4254 [(set GPR:$Rd, (tt_mul GPR:$Rn, GPR:$Rm))]>,
4255 Requires<[IsARM, HasV5TE]>,
4256 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4258 def WB : AMulxyI<0b0001001, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4259 IIC_iMUL16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm",
4260 [(set GPR:$Rd, (ARMsmulwb GPR:$Rn, GPR:$Rm))]>,
4261 Requires<[IsARM, HasV5TE]>,
4262 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4264 def WT : AMulxyI<0b0001001, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4265 IIC_iMUL16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm",
4266 [(set GPR:$Rd, (ARMsmulwt GPR:$Rn, GPR:$Rm))]>,
4267 Requires<[IsARM, HasV5TE]>,
4268 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4272 multiclass AI_smla<string opc> {
4273 let DecoderMethod = "DecodeSMLAInstruction" in {
4274 def BB : AMulxyIa<0b0001000, 0b00, (outs GPRnopc:$Rd),
4275 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4276 IIC_iMAC16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra",
4277 [(set GPRnopc:$Rd, (add GPR:$Ra,
4278 (bb_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4279 Requires<[IsARM, HasV5TE, UseMulOps]>,
4280 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4282 def BT : AMulxyIa<0b0001000, 0b10, (outs GPRnopc:$Rd),
4283 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4284 IIC_iMAC16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra",
4285 [(set GPRnopc:$Rd, (add GPR:$Ra,
4286 (bt_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4287 Requires<[IsARM, HasV5TE, UseMulOps]>,
4288 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4290 def TB : AMulxyIa<0b0001000, 0b01, (outs GPRnopc:$Rd),
4291 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4292 IIC_iMAC16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra",
4293 [(set GPRnopc:$Rd, (add GPR:$Ra,
4294 (tb_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4295 Requires<[IsARM, HasV5TE, UseMulOps]>,
4296 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4298 def TT : AMulxyIa<0b0001000, 0b11, (outs GPRnopc:$Rd),
4299 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4300 IIC_iMAC16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra",
4301 [(set GPRnopc:$Rd, (add GPR:$Ra,
4302 (tt_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4303 Requires<[IsARM, HasV5TE, UseMulOps]>,
4304 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4306 def WB : AMulxyIa<0b0001001, 0b00, (outs GPRnopc:$Rd),
4307 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4308 IIC_iMAC16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra",
4310 (add GPR:$Ra, (ARMsmulwb GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4311 Requires<[IsARM, HasV5TE, UseMulOps]>,
4312 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4314 def WT : AMulxyIa<0b0001001, 0b10, (outs GPRnopc:$Rd),
4315 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4316 IIC_iMAC16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra",
4318 (add GPR:$Ra, (ARMsmulwt GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4319 Requires<[IsARM, HasV5TE, UseMulOps]>,
4320 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4324 defm SMUL : AI_smul<"smul">;
4325 defm SMLA : AI_smla<"smla">;
4327 // Halfword multiply accumulate long: SMLAL<x><y>.
4328 class SMLAL<bits<2> opc1, string asm>
4329 : AMulxyI64<0b0001010, opc1,
4330 (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4331 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4332 IIC_iMAC64, asm, "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4333 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">,
4334 Requires<[IsARM, HasV5TE]>,
4335 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4337 def SMLALBB : SMLAL<0b00, "smlalbb">;
4338 def SMLALBT : SMLAL<0b10, "smlalbt">;
4339 def SMLALTB : SMLAL<0b01, "smlaltb">;
4340 def SMLALTT : SMLAL<0b11, "smlaltt">;
4342 def : ARMV5TEPat<(ARMsmlalbb GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4343 (SMLALBB $Rn, $Rm, $RLo, $RHi)>;
4344 def : ARMV5TEPat<(ARMsmlalbt GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4345 (SMLALBT $Rn, $Rm, $RLo, $RHi)>;
4346 def : ARMV5TEPat<(ARMsmlaltb GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4347 (SMLALTB $Rn, $Rm, $RLo, $RHi)>;
4348 def : ARMV5TEPat<(ARMsmlaltt GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4349 (SMLALTT $Rn, $Rm, $RLo, $RHi)>;
4351 // Helper class for AI_smld.
4352 class AMulDualIbase<bit long, bit sub, bit swap, dag oops, dag iops,
4353 InstrItinClass itin, string opc, string asm>
4354 : AI<oops, iops, MulFrm, itin, opc, asm, []>,
4355 Requires<[IsARM, HasV6]> {
4358 let Inst{27-23} = 0b01110;
4359 let Inst{22} = long;
4360 let Inst{21-20} = 0b00;
4361 let Inst{11-8} = Rm;
4368 class AMulDualI<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> {
4372 let Inst{15-12} = 0b1111;
4373 let Inst{19-16} = Rd;
4375 class AMulDualIa<bit long, bit sub, bit swap, dag oops, dag iops,
4376 InstrItinClass itin, string opc, string asm>
4377 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4380 let Inst{19-16} = Rd;
4381 let Inst{15-12} = Ra;
4383 class AMulDualI64<bit long, bit sub, bit swap, dag oops, dag iops,
4384 InstrItinClass itin, string opc, string asm>
4385 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4388 let Inst{19-16} = RdHi;
4389 let Inst{15-12} = RdLo;
4392 multiclass AI_smld<bit sub, string opc> {
4394 def D : AMulDualIa<0, sub, 0, (outs GPRnopc:$Rd),
4395 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4396 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm, $Ra">,
4397 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4399 def DX: AMulDualIa<0, sub, 1, (outs GPRnopc:$Rd),
4400 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4401 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm, $Ra">,
4402 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4404 def LD: AMulDualI64<1, sub, 0, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4405 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4407 !strconcat(opc, "ld"), "\t$RdLo, $RdHi, $Rn, $Rm">,
4408 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">,
4409 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4411 def LDX : AMulDualI64<1, sub, 1, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4412 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4414 !strconcat(opc, "ldx"),"\t$RdLo, $RdHi, $Rn, $Rm">,
4415 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">,
4416 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>;
4419 defm SMLA : AI_smld<0, "smla">;
4420 defm SMLS : AI_smld<1, "smls">;
4422 def : ARMV6Pat<(int_arm_smlad GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4423 (SMLAD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>;
4424 def : ARMV6Pat<(int_arm_smladx GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4425 (SMLADX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>;
4426 def : ARMV6Pat<(int_arm_smlsd GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4427 (SMLSD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>;
4428 def : ARMV6Pat<(int_arm_smlsdx GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4429 (SMLSDX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>;
4430 def : ARMV6Pat<(ARMSmlald GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4431 (SMLALD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>;
4432 def : ARMV6Pat<(ARMSmlaldx GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4433 (SMLALDX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>;
4434 def : ARMV6Pat<(ARMSmlsld GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4435 (SMLSLD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>;
4436 def : ARMV6Pat<(ARMSmlsldx GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4437 (SMLSLDX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>;
4439 multiclass AI_sdml<bit sub, string opc> {
4441 def D:AMulDualI<0, sub, 0, (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm),
4442 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm">,
4443 Sched<[WriteMUL32, ReadMUL, ReadMUL]>;
4444 def DX:AMulDualI<0, sub, 1, (outs GPRnopc:$Rd),(ins GPRnopc:$Rn, GPRnopc:$Rm),
4445 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm">,
4446 Sched<[WriteMUL32, ReadMUL, ReadMUL]>;
4449 defm SMUA : AI_sdml<0, "smua">;
4450 defm SMUS : AI_sdml<1, "smus">;
4452 def : ARMV6Pat<(int_arm_smuad GPRnopc:$Rn, GPRnopc:$Rm),
4453 (SMUAD GPRnopc:$Rn, GPRnopc:$Rm)>;
4454 def : ARMV6Pat<(int_arm_smuadx GPRnopc:$Rn, GPRnopc:$Rm),
4455 (SMUADX GPRnopc:$Rn, GPRnopc:$Rm)>;
4456 def : ARMV6Pat<(int_arm_smusd GPRnopc:$Rn, GPRnopc:$Rm),
4457 (SMUSD GPRnopc:$Rn, GPRnopc:$Rm)>;
4458 def : ARMV6Pat<(int_arm_smusdx GPRnopc:$Rn, GPRnopc:$Rm),
4459 (SMUSDX GPRnopc:$Rn, GPRnopc:$Rm)>;
4461 //===----------------------------------------------------------------------===//
4462 // Division Instructions (ARMv7-A with virtualization extension)
4464 def SDIV : ADivA1I<0b001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV,
4465 "sdiv", "\t$Rd, $Rn, $Rm",
4466 [(set GPR:$Rd, (sdiv GPR:$Rn, GPR:$Rm))]>,
4467 Requires<[IsARM, HasDivideInARM]>,
4470 def UDIV : ADivA1I<0b011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV,
4471 "udiv", "\t$Rd, $Rn, $Rm",
4472 [(set GPR:$Rd, (udiv GPR:$Rn, GPR:$Rm))]>,
4473 Requires<[IsARM, HasDivideInARM]>,
4476 //===----------------------------------------------------------------------===//
4477 // Misc. Arithmetic Instructions.
4480 def CLZ : AMiscA1I<0b00010110, 0b0001, (outs GPR:$Rd), (ins GPR:$Rm),
4481 IIC_iUNAr, "clz", "\t$Rd, $Rm",
4482 [(set GPR:$Rd, (ctlz GPR:$Rm))]>, Requires<[IsARM, HasV5T]>,
4485 def RBIT : AMiscA1I<0b01101111, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
4486 IIC_iUNAr, "rbit", "\t$Rd, $Rm",
4487 [(set GPR:$Rd, (bitreverse GPR:$Rm))]>,
4488 Requires<[IsARM, HasV6T2]>,
4491 def REV : AMiscA1I<0b01101011, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
4492 IIC_iUNAr, "rev", "\t$Rd, $Rm",
4493 [(set GPR:$Rd, (bswap GPR:$Rm))]>, Requires<[IsARM, HasV6]>,
4496 let AddedComplexity = 5 in
4497 def REV16 : AMiscA1I<0b01101011, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
4498 IIC_iUNAr, "rev16", "\t$Rd, $Rm",
4499 [(set GPR:$Rd, (rotr (bswap GPR:$Rm), (i32 16)))]>,
4500 Requires<[IsARM, HasV6]>,
4503 def : ARMV6Pat<(srl (bswap (extloadi16 addrmode3:$addr)), (i32 16)),
4504 (REV16 (LDRH addrmode3:$addr))>;
4505 def : ARMV6Pat<(truncstorei16 (srl (bswap GPR:$Rn), (i32 16)), addrmode3:$addr),
4506 (STRH (REV16 GPR:$Rn), addrmode3:$addr)>;
4508 let AddedComplexity = 5 in
4509 def REVSH : AMiscA1I<0b01101111, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
4510 IIC_iUNAr, "revsh", "\t$Rd, $Rm",
4511 [(set GPR:$Rd, (sra (bswap GPR:$Rm), (i32 16)))]>,
4512 Requires<[IsARM, HasV6]>,
4515 def : ARMV6Pat<(or (sra (shl GPR:$Rm, (i32 24)), (i32 16)),
4516 (and (srl GPR:$Rm, (i32 8)), 0xFF)),
4519 def PKHBT : APKHI<0b01101000, 0, (outs GPRnopc:$Rd),
4520 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_lsl_amt:$sh),
4521 IIC_iALUsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh",
4522 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF),
4523 (and (shl GPRnopc:$Rm, pkh_lsl_amt:$sh),
4525 Requires<[IsARM, HasV6]>,
4526 Sched<[WriteALUsi, ReadALU]>;
4528 // Alternate cases for PKHBT where identities eliminate some nodes.
4529 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (and GPRnopc:$Rm, 0xFFFF0000)),
4530 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, 0)>;
4531 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (shl GPRnopc:$Rm, imm16_31:$sh)),
4532 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, imm16_31:$sh)>;
4534 // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
4535 // will match the pattern below.
4536 def PKHTB : APKHI<0b01101000, 1, (outs GPRnopc:$Rd),
4537 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_asr_amt:$sh),
4538 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh",
4539 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF0000),
4540 (and (sra GPRnopc:$Rm, pkh_asr_amt:$sh),
4542 Requires<[IsARM, HasV6]>,
4543 Sched<[WriteALUsi, ReadALU]>;
4545 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
4546 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
4547 // We also can not replace a srl (17..31) by an arithmetic shift we would use in
4548 // pkhtb src1, src2, asr (17..31).
4549 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4550 (srl GPRnopc:$src2, imm16:$sh)),
4551 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16:$sh)>;
4552 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4553 (sra GPRnopc:$src2, imm16_31:$sh)),
4554 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16_31:$sh)>;
4555 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4556 (and (srl GPRnopc:$src2, imm1_15:$sh), 0xFFFF)),
4557 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm1_15:$sh)>;
4559 //===----------------------------------------------------------------------===//
4563 // + CRC32{B,H,W} 0x04C11DB7
4564 // + CRC32C{B,H,W} 0x1EDC6F41
4567 class AI_crc32<bit C, bits<2> sz, string suffix, SDPatternOperator builtin>
4568 : AInoP<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm), MiscFrm, NoItinerary,
4569 !strconcat("crc32", suffix), "\t$Rd, $Rn, $Rm",
4570 [(set GPRnopc:$Rd, (builtin GPRnopc:$Rn, GPRnopc:$Rm))]>,
4571 Requires<[IsARM, HasV8, HasCRC]> {
4576 let Inst{31-28} = 0b1110;
4577 let Inst{27-23} = 0b00010;
4578 let Inst{22-21} = sz;
4580 let Inst{19-16} = Rn;
4581 let Inst{15-12} = Rd;
4582 let Inst{11-10} = 0b00;
4585 let Inst{7-4} = 0b0100;
4588 let Unpredictable{11-8} = 0b1101;
4591 def CRC32B : AI_crc32<0, 0b00, "b", int_arm_crc32b>;
4592 def CRC32CB : AI_crc32<1, 0b00, "cb", int_arm_crc32cb>;
4593 def CRC32H : AI_crc32<0, 0b01, "h", int_arm_crc32h>;
4594 def CRC32CH : AI_crc32<1, 0b01, "ch", int_arm_crc32ch>;
4595 def CRC32W : AI_crc32<0, 0b10, "w", int_arm_crc32w>;
4596 def CRC32CW : AI_crc32<1, 0b10, "cw", int_arm_crc32cw>;
4598 //===----------------------------------------------------------------------===//
4599 // ARMv8.1a Privilege Access Never extension
4603 def SETPAN : AInoP<(outs), (ins imm0_1:$imm), MiscFrm, NoItinerary, "setpan",
4604 "\t$imm", []>, Requires<[IsARM, HasV8, HasV8_1a]> {
4607 let Inst{31-28} = 0b1111;
4608 let Inst{27-20} = 0b00010001;
4609 let Inst{19-16} = 0b0000;
4610 let Inst{15-10} = 0b000000;
4613 let Inst{7-4} = 0b0000;
4614 let Inst{3-0} = 0b0000;
4616 let Unpredictable{19-16} = 0b1111;
4617 let Unpredictable{15-10} = 0b111111;
4618 let Unpredictable{8} = 0b1;
4619 let Unpredictable{3-0} = 0b1111;
4622 //===----------------------------------------------------------------------===//
4623 // Comparison Instructions...
4626 defm CMP : AI1_cmp_irs<0b1010, "cmp",
4627 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr, ARMcmp>;
4629 // ARMcmpZ can re-use the above instruction definitions.
4630 def : ARMPat<(ARMcmpZ GPR:$src, mod_imm:$imm),
4631 (CMPri GPR:$src, mod_imm:$imm)>;
4632 def : ARMPat<(ARMcmpZ GPR:$src, GPR:$rhs),
4633 (CMPrr GPR:$src, GPR:$rhs)>;
4634 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_imm:$rhs),
4635 (CMPrsi GPR:$src, so_reg_imm:$rhs)>;
4636 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_reg:$rhs),
4637 (CMPrsr GPR:$src, so_reg_reg:$rhs)>;
4639 // CMN register-integer
4640 let isCompare = 1, Defs = [CPSR] in {
4641 def CMNri : AI1<0b1011, (outs), (ins GPR:$Rn, mod_imm:$imm), DPFrm, IIC_iCMPi,
4642 "cmn", "\t$Rn, $imm",
4643 [(ARMcmn GPR:$Rn, mod_imm:$imm)]>,
4644 Sched<[WriteCMP, ReadALU]> {
4649 let Inst{19-16} = Rn;
4650 let Inst{15-12} = 0b0000;
4651 let Inst{11-0} = imm;
4653 let Unpredictable{15-12} = 0b1111;
4656 // CMN register-register/shift
4657 def CMNzrr : AI1<0b1011, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, IIC_iCMPr,
4658 "cmn", "\t$Rn, $Rm",
4659 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4660 GPR:$Rn, GPR:$Rm)]>, Sched<[WriteCMP, ReadALU, ReadALU]> {
4663 let isCommutable = 1;
4666 let Inst{19-16} = Rn;
4667 let Inst{15-12} = 0b0000;
4668 let Inst{11-4} = 0b00000000;
4671 let Unpredictable{15-12} = 0b1111;
4674 def CMNzrsi : AI1<0b1011, (outs),
4675 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, IIC_iCMPsr,
4676 "cmn", "\t$Rn, $shift",
4677 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4678 GPR:$Rn, so_reg_imm:$shift)]>,
4679 Sched<[WriteCMPsi, ReadALU]> {
4684 let Inst{19-16} = Rn;
4685 let Inst{15-12} = 0b0000;
4686 let Inst{11-5} = shift{11-5};
4688 let Inst{3-0} = shift{3-0};
4690 let Unpredictable{15-12} = 0b1111;
4693 def CMNzrsr : AI1<0b1011, (outs),
4694 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, IIC_iCMPsr,
4695 "cmn", "\t$Rn, $shift",
4696 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4697 GPRnopc:$Rn, so_reg_reg:$shift)]>,
4698 Sched<[WriteCMPsr, ReadALU]> {
4703 let Inst{19-16} = Rn;
4704 let Inst{15-12} = 0b0000;
4705 let Inst{11-8} = shift{11-8};
4707 let Inst{6-5} = shift{6-5};
4709 let Inst{3-0} = shift{3-0};
4711 let Unpredictable{15-12} = 0b1111;
4716 def : ARMPat<(ARMcmp GPR:$src, mod_imm_neg:$imm),
4717 (CMNri GPR:$src, mod_imm_neg:$imm)>;
4719 def : ARMPat<(ARMcmpZ GPR:$src, mod_imm_neg:$imm),
4720 (CMNri GPR:$src, mod_imm_neg:$imm)>;
4722 // Note that TST/TEQ don't set all the same flags that CMP does!
4723 defm TST : AI1_cmp_irs<0b1000, "tst",
4724 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
4725 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>, 1,
4726 "DecodeTSTInstruction">;
4727 defm TEQ : AI1_cmp_irs<0b1001, "teq",
4728 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
4729 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>, 1>;
4731 // Pseudo i64 compares for some floating point compares.
4732 let usesCustomInserter = 1, isBranch = 1, isTerminator = 1,
4734 def BCCi64 : PseudoInst<(outs),
4735 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, brtarget:$dst),
4737 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, bb:$dst)]>,
4740 def BCCZi64 : PseudoInst<(outs),
4741 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, brtarget:$dst), IIC_Br,
4742 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, 0, 0, bb:$dst)]>,
4744 } // usesCustomInserter
4747 // Conditional moves
4748 let hasSideEffects = 0 in {
4750 let isCommutable = 1, isSelect = 1 in
4751 def MOVCCr : ARMPseudoInst<(outs GPR:$Rd),
4752 (ins GPR:$false, GPR:$Rm, cmovpred:$p),
4754 [(set GPR:$Rd, (ARMcmov GPR:$false, GPR:$Rm,
4756 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4758 def MOVCCsi : ARMPseudoInst<(outs GPR:$Rd),
4759 (ins GPR:$false, so_reg_imm:$shift, cmovpred:$p),
4762 (ARMcmov GPR:$false, so_reg_imm:$shift,
4764 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4765 def MOVCCsr : ARMPseudoInst<(outs GPR:$Rd),
4766 (ins GPR:$false, so_reg_reg:$shift, cmovpred:$p),
4768 [(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_reg:$shift,
4770 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4773 let isMoveImm = 1 in
4775 : ARMPseudoInst<(outs GPR:$Rd),
4776 (ins GPR:$false, imm0_65535_expr:$imm, cmovpred:$p),
4778 [(set GPR:$Rd, (ARMcmov GPR:$false, imm0_65535:$imm,
4780 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>,
4783 let isMoveImm = 1 in
4784 def MOVCCi : ARMPseudoInst<(outs GPR:$Rd),
4785 (ins GPR:$false, mod_imm:$imm, cmovpred:$p),
4787 [(set GPR:$Rd, (ARMcmov GPR:$false, mod_imm:$imm,
4789 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4791 // Two instruction predicate mov immediate.
4792 let isMoveImm = 1 in
4794 : ARMPseudoInst<(outs GPR:$Rd),
4795 (ins GPR:$false, i32imm:$src, cmovpred:$p),
4797 [(set GPR:$Rd, (ARMcmov GPR:$false, imm:$src,
4799 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>;
4801 let isMoveImm = 1 in
4802 def MVNCCi : ARMPseudoInst<(outs GPR:$Rd),
4803 (ins GPR:$false, mod_imm:$imm, cmovpred:$p),
4805 [(set GPR:$Rd, (ARMcmov GPR:$false, mod_imm_not:$imm,
4807 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4812 //===----------------------------------------------------------------------===//
4813 // Atomic operations intrinsics
4816 def MemBarrierOptOperand : AsmOperandClass {
4817 let Name = "MemBarrierOpt";
4818 let ParserMethod = "parseMemBarrierOptOperand";
4820 def memb_opt : Operand<i32> {
4821 let PrintMethod = "printMemBOption";
4822 let ParserMatchClass = MemBarrierOptOperand;
4823 let DecoderMethod = "DecodeMemBarrierOption";
4826 def InstSyncBarrierOptOperand : AsmOperandClass {
4827 let Name = "InstSyncBarrierOpt";
4828 let ParserMethod = "parseInstSyncBarrierOptOperand";
4830 def instsyncb_opt : Operand<i32> {
4831 let PrintMethod = "printInstSyncBOption";
4832 let ParserMatchClass = InstSyncBarrierOptOperand;
4833 let DecoderMethod = "DecodeInstSyncBarrierOption";
4836 def TraceSyncBarrierOptOperand : AsmOperandClass {
4837 let Name = "TraceSyncBarrierOpt";
4838 let ParserMethod = "parseTraceSyncBarrierOptOperand";
4840 def tsb_opt : Operand<i32> {
4841 let PrintMethod = "printTraceSyncBOption";
4842 let ParserMatchClass = TraceSyncBarrierOptOperand;
4845 // Memory barriers protect the atomic sequences
4846 let hasSideEffects = 1 in {
4847 def DMB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4848 "dmb", "\t$opt", [(int_arm_dmb (i32 imm0_15:$opt))]>,
4849 Requires<[IsARM, HasDB]> {
4851 let Inst{31-4} = 0xf57ff05;
4852 let Inst{3-0} = opt;
4855 def DSB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4856 "dsb", "\t$opt", [(int_arm_dsb (i32 imm0_15:$opt))]>,
4857 Requires<[IsARM, HasDB]> {
4859 let Inst{31-4} = 0xf57ff04;
4860 let Inst{3-0} = opt;
4863 // ISB has only full system option
4864 def ISB : AInoP<(outs), (ins instsyncb_opt:$opt), MiscFrm, NoItinerary,
4865 "isb", "\t$opt", [(int_arm_isb (i32 imm0_15:$opt))]>,
4866 Requires<[IsARM, HasDB]> {
4868 let Inst{31-4} = 0xf57ff06;
4869 let Inst{3-0} = opt;
4872 let hasNoSchedulingInfo = 1 in
4873 def TSB : AInoP<(outs), (ins tsb_opt:$opt), MiscFrm, NoItinerary,
4874 "tsb", "\t$opt", []>, Requires<[IsARM, HasV8_4a]> {
4875 let Inst{31-0} = 0xe320f012;
4880 // Armv8.5-A speculation barrier
4881 def SB : AInoP<(outs), (ins), MiscFrm, NoItinerary, "sb", "", []>,
4882 Requires<[IsARM, HasSB]>, Sched<[]> {
4883 let Inst{31-0} = 0xf57ff070;
4884 let Unpredictable = 0x000fff0f;
4885 let hasSideEffects = 1;
4888 let usesCustomInserter = 1, Defs = [CPSR] in {
4890 // Pseudo instruction that combines movs + predicated rsbmi
4891 // to implement integer ABS
4892 def ABS : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$src), 8, NoItinerary, []>;
4895 let usesCustomInserter = 1, Defs = [CPSR] in {
4896 def COPY_STRUCT_BYVAL_I32 : PseudoInst<
4897 (outs), (ins GPR:$dst, GPR:$src, i32imm:$size, i32imm:$alignment),
4899 [(ARMcopystructbyval GPR:$dst, GPR:$src, imm:$size, imm:$alignment)]>;
4902 let hasPostISelHook = 1, Constraints = "$newdst = $dst, $newsrc = $src" in {
4903 // %newsrc, %newdst = MEMCPY %dst, %src, N, ...N scratch regs...
4904 // Copies N registers worth of memory from address %src to address %dst
4905 // and returns the incremented addresses. N scratch register will
4906 // be attached for the copy to use.
4907 def MEMCPY : PseudoInst<
4908 (outs GPR:$newdst, GPR:$newsrc),
4909 (ins GPR:$dst, GPR:$src, i32imm:$nreg, variable_ops),
4911 [(set GPR:$newdst, GPR:$newsrc,
4912 (ARMmemcopy GPR:$dst, GPR:$src, imm:$nreg))]>;
4915 def ldrex_1 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4916 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4919 def ldrex_2 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4920 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4923 def ldrex_4 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4924 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4927 def strex_1 : PatFrag<(ops node:$val, node:$ptr),
4928 (int_arm_strex node:$val, node:$ptr), [{
4929 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4932 def strex_2 : PatFrag<(ops node:$val, node:$ptr),
4933 (int_arm_strex node:$val, node:$ptr), [{
4934 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4937 def strex_4 : PatFrag<(ops node:$val, node:$ptr),
4938 (int_arm_strex node:$val, node:$ptr), [{
4939 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4942 def ldaex_1 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4943 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4946 def ldaex_2 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4947 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4950 def ldaex_4 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4951 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4954 def stlex_1 : PatFrag<(ops node:$val, node:$ptr),
4955 (int_arm_stlex node:$val, node:$ptr), [{
4956 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4959 def stlex_2 : PatFrag<(ops node:$val, node:$ptr),
4960 (int_arm_stlex node:$val, node:$ptr), [{
4961 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4964 def stlex_4 : PatFrag<(ops node:$val, node:$ptr),
4965 (int_arm_stlex node:$val, node:$ptr), [{
4966 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4969 let mayLoad = 1 in {
4970 def LDREXB : AIldrex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4971 NoItinerary, "ldrexb", "\t$Rt, $addr",
4972 [(set GPR:$Rt, (ldrex_1 addr_offset_none:$addr))]>;
4973 def LDREXH : AIldrex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4974 NoItinerary, "ldrexh", "\t$Rt, $addr",
4975 [(set GPR:$Rt, (ldrex_2 addr_offset_none:$addr))]>;
4976 def LDREX : AIldrex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4977 NoItinerary, "ldrex", "\t$Rt, $addr",
4978 [(set GPR:$Rt, (ldrex_4 addr_offset_none:$addr))]>;
4979 let hasExtraDefRegAllocReq = 1 in
4980 def LDREXD : AIldrex<0b01, (outs GPRPairOp:$Rt),(ins addr_offset_none:$addr),
4981 NoItinerary, "ldrexd", "\t$Rt, $addr", []> {
4982 let DecoderMethod = "DecodeDoubleRegLoad";
4985 def LDAEXB : AIldaex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4986 NoItinerary, "ldaexb", "\t$Rt, $addr",
4987 [(set GPR:$Rt, (ldaex_1 addr_offset_none:$addr))]>;
4988 def LDAEXH : AIldaex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4989 NoItinerary, "ldaexh", "\t$Rt, $addr",
4990 [(set GPR:$Rt, (ldaex_2 addr_offset_none:$addr))]>;
4991 def LDAEX : AIldaex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4992 NoItinerary, "ldaex", "\t$Rt, $addr",
4993 [(set GPR:$Rt, (ldaex_4 addr_offset_none:$addr))]>;
4994 let hasExtraDefRegAllocReq = 1 in
4995 def LDAEXD : AIldaex<0b01, (outs GPRPairOp:$Rt),(ins addr_offset_none:$addr),
4996 NoItinerary, "ldaexd", "\t$Rt, $addr", []> {
4997 let DecoderMethod = "DecodeDoubleRegLoad";
5001 let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
5002 def STREXB: AIstrex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5003 NoItinerary, "strexb", "\t$Rd, $Rt, $addr",
5004 [(set GPR:$Rd, (strex_1 GPR:$Rt,
5005 addr_offset_none:$addr))]>;
5006 def STREXH: AIstrex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5007 NoItinerary, "strexh", "\t$Rd, $Rt, $addr",
5008 [(set GPR:$Rd, (strex_2 GPR:$Rt,
5009 addr_offset_none:$addr))]>;
5010 def STREX : AIstrex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5011 NoItinerary, "strex", "\t$Rd, $Rt, $addr",
5012 [(set GPR:$Rd, (strex_4 GPR:$Rt,
5013 addr_offset_none:$addr))]>;
5014 let hasExtraSrcRegAllocReq = 1 in
5015 def STREXD : AIstrex<0b01, (outs GPR:$Rd),
5016 (ins GPRPairOp:$Rt, addr_offset_none:$addr),
5017 NoItinerary, "strexd", "\t$Rd, $Rt, $addr", []> {
5018 let DecoderMethod = "DecodeDoubleRegStore";
5020 def STLEXB: AIstlex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5021 NoItinerary, "stlexb", "\t$Rd, $Rt, $addr",
5023 (stlex_1 GPR:$Rt, addr_offset_none:$addr))]>;
5024 def STLEXH: AIstlex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5025 NoItinerary, "stlexh", "\t$Rd, $Rt, $addr",
5027 (stlex_2 GPR:$Rt, addr_offset_none:$addr))]>;
5028 def STLEX : AIstlex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5029 NoItinerary, "stlex", "\t$Rd, $Rt, $addr",
5031 (stlex_4 GPR:$Rt, addr_offset_none:$addr))]>;
5032 let hasExtraSrcRegAllocReq = 1 in
5033 def STLEXD : AIstlex<0b01, (outs GPR:$Rd),
5034 (ins GPRPairOp:$Rt, addr_offset_none:$addr),
5035 NoItinerary, "stlexd", "\t$Rd, $Rt, $addr", []> {
5036 let DecoderMethod = "DecodeDoubleRegStore";
5040 def CLREX : AXI<(outs), (ins), MiscFrm, NoItinerary, "clrex",
5042 Requires<[IsARM, HasV6K]> {
5043 let Inst{31-0} = 0b11110101011111111111000000011111;
5046 def : ARMPat<(strex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr),
5047 (STREXB GPR:$Rt, addr_offset_none:$addr)>;
5048 def : ARMPat<(strex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr),
5049 (STREXH GPR:$Rt, addr_offset_none:$addr)>;
5051 def : ARMPat<(stlex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr),
5052 (STLEXB GPR:$Rt, addr_offset_none:$addr)>;
5053 def : ARMPat<(stlex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr),
5054 (STLEXH GPR:$Rt, addr_offset_none:$addr)>;
5056 class acquiring_load<PatFrag base>
5057 : PatFrag<(ops node:$ptr), (base node:$ptr), [{
5058 AtomicOrdering Ordering = cast<AtomicSDNode>(N)->getOrdering();
5059 return isAcquireOrStronger(Ordering);
5062 def atomic_load_acquire_8 : acquiring_load<atomic_load_8>;
5063 def atomic_load_acquire_16 : acquiring_load<atomic_load_16>;
5064 def atomic_load_acquire_32 : acquiring_load<atomic_load_32>;
5066 class releasing_store<PatFrag base>
5067 : PatFrag<(ops node:$ptr, node:$val), (base node:$ptr, node:$val), [{
5068 AtomicOrdering Ordering = cast<AtomicSDNode>(N)->getOrdering();
5069 return isReleaseOrStronger(Ordering);
5072 def atomic_store_release_8 : releasing_store<atomic_store_8>;
5073 def atomic_store_release_16 : releasing_store<atomic_store_16>;
5074 def atomic_store_release_32 : releasing_store<atomic_store_32>;
5076 let AddedComplexity = 8 in {
5077 def : ARMPat<(atomic_load_acquire_8 addr_offset_none:$addr), (LDAB addr_offset_none:$addr)>;
5078 def : ARMPat<(atomic_load_acquire_16 addr_offset_none:$addr), (LDAH addr_offset_none:$addr)>;
5079 def : ARMPat<(atomic_load_acquire_32 addr_offset_none:$addr), (LDA addr_offset_none:$addr)>;
5080 def : ARMPat<(atomic_store_release_8 addr_offset_none:$addr, GPR:$val), (STLB GPR:$val, addr_offset_none:$addr)>;
5081 def : ARMPat<(atomic_store_release_16 addr_offset_none:$addr, GPR:$val), (STLH GPR:$val, addr_offset_none:$addr)>;
5082 def : ARMPat<(atomic_store_release_32 addr_offset_none:$addr, GPR:$val), (STL GPR:$val, addr_offset_none:$addr)>;
5085 // SWP/SWPB are deprecated in V6/V7 and optional in v7VE.
5086 // FIXME Use InstAlias to generate LDREX/STREX pairs instead.
5087 let mayLoad = 1, mayStore = 1 in {
5088 def SWP : AIswp<0, (outs GPRnopc:$Rt),
5089 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swp", []>,
5090 Requires<[IsARM,PreV8]>;
5091 def SWPB: AIswp<1, (outs GPRnopc:$Rt),
5092 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swpb", []>,
5093 Requires<[IsARM,PreV8]>;
5096 //===----------------------------------------------------------------------===//
5097 // Coprocessor Instructions.
5100 def CDP : ABI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
5101 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
5102 NoItinerary, "cdp", "\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
5103 [(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
5104 imm:$CRm, imm:$opc2)]>,
5105 Requires<[IsARM,PreV8]> {
5113 let Inst{3-0} = CRm;
5115 let Inst{7-5} = opc2;
5116 let Inst{11-8} = cop;
5117 let Inst{15-12} = CRd;
5118 let Inst{19-16} = CRn;
5119 let Inst{23-20} = opc1;
5121 let DecoderNamespace = "CoProc";
5124 def CDP2 : ABXI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
5125 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
5126 NoItinerary, "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
5127 [(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
5128 imm:$CRm, imm:$opc2)]>,
5129 Requires<[IsARM,PreV8]> {
5130 let Inst{31-28} = 0b1111;
5138 let Inst{3-0} = CRm;
5140 let Inst{7-5} = opc2;
5141 let Inst{11-8} = cop;
5142 let Inst{15-12} = CRd;
5143 let Inst{19-16} = CRn;
5144 let Inst{23-20} = opc1;
5146 let DecoderNamespace = "CoProc";
5149 class ACI<dag oops, dag iops, string opc, string asm,
5150 list<dag> pattern, IndexMode im = IndexModeNone>
5151 : I<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
5152 opc, asm, "", pattern> {
5153 let Inst{27-25} = 0b110;
5155 class ACInoP<dag oops, dag iops, string opc, string asm,
5156 list<dag> pattern, IndexMode im = IndexModeNone>
5157 : InoP<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
5158 opc, asm, "", pattern> {
5159 let Inst{31-28} = 0b1111;
5160 let Inst{27-25} = 0b110;
5163 let DecoderNamespace = "CoProc" in {
5164 multiclass LdStCop<bit load, bit Dbit, string asm, list<dag> pattern> {
5165 def _OFFSET : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
5166 asm, "\t$cop, $CRd, $addr", pattern> {
5170 let Inst{24} = 1; // P = 1
5171 let Inst{23} = addr{8};
5172 let Inst{22} = Dbit;
5173 let Inst{21} = 0; // W = 0
5174 let Inst{20} = load;
5175 let Inst{19-16} = addr{12-9};
5176 let Inst{15-12} = CRd;
5177 let Inst{11-8} = cop;
5178 let Inst{7-0} = addr{7-0};
5179 let DecoderMethod = "DecodeCopMemInstruction";
5181 def _PRE : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr),
5182 asm, "\t$cop, $CRd, $addr!", [], IndexModePre> {
5186 let Inst{24} = 1; // P = 1
5187 let Inst{23} = addr{8};
5188 let Inst{22} = Dbit;
5189 let Inst{21} = 1; // W = 1
5190 let Inst{20} = load;
5191 let Inst{19-16} = addr{12-9};
5192 let Inst{15-12} = CRd;
5193 let Inst{11-8} = cop;
5194 let Inst{7-0} = addr{7-0};
5195 let DecoderMethod = "DecodeCopMemInstruction";
5197 def _POST: ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
5198 postidx_imm8s4:$offset),
5199 asm, "\t$cop, $CRd, $addr, $offset", [], IndexModePost> {
5204 let Inst{24} = 0; // P = 0
5205 let Inst{23} = offset{8};
5206 let Inst{22} = Dbit;
5207 let Inst{21} = 1; // W = 1
5208 let Inst{20} = load;
5209 let Inst{19-16} = addr;
5210 let Inst{15-12} = CRd;
5211 let Inst{11-8} = cop;
5212 let Inst{7-0} = offset{7-0};
5213 let DecoderMethod = "DecodeCopMemInstruction";
5215 def _OPTION : ACI<(outs),
5216 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
5217 coproc_option_imm:$option),
5218 asm, "\t$cop, $CRd, $addr, $option", []> {
5223 let Inst{24} = 0; // P = 0
5224 let Inst{23} = 1; // U = 1
5225 let Inst{22} = Dbit;
5226 let Inst{21} = 0; // W = 0
5227 let Inst{20} = load;
5228 let Inst{19-16} = addr;
5229 let Inst{15-12} = CRd;
5230 let Inst{11-8} = cop;
5231 let Inst{7-0} = option;
5232 let DecoderMethod = "DecodeCopMemInstruction";
5235 multiclass LdSt2Cop<bit load, bit Dbit, string asm, list<dag> pattern> {
5236 def _OFFSET : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
5237 asm, "\t$cop, $CRd, $addr", pattern> {
5241 let Inst{24} = 1; // P = 1
5242 let Inst{23} = addr{8};
5243 let Inst{22} = Dbit;
5244 let Inst{21} = 0; // W = 0
5245 let Inst{20} = load;
5246 let Inst{19-16} = addr{12-9};
5247 let Inst{15-12} = CRd;
5248 let Inst{11-8} = cop;
5249 let Inst{7-0} = addr{7-0};
5250 let DecoderMethod = "DecodeCopMemInstruction";
5252 def _PRE : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr),
5253 asm, "\t$cop, $CRd, $addr!", [], IndexModePre> {
5257 let Inst{24} = 1; // P = 1
5258 let Inst{23} = addr{8};
5259 let Inst{22} = Dbit;
5260 let Inst{21} = 1; // W = 1
5261 let Inst{20} = load;
5262 let Inst{19-16} = addr{12-9};
5263 let Inst{15-12} = CRd;
5264 let Inst{11-8} = cop;
5265 let Inst{7-0} = addr{7-0};
5266 let DecoderMethod = "DecodeCopMemInstruction";
5268 def _POST: ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
5269 postidx_imm8s4:$offset),
5270 asm, "\t$cop, $CRd, $addr, $offset", [], IndexModePost> {
5275 let Inst{24} = 0; // P = 0
5276 let Inst{23} = offset{8};
5277 let Inst{22} = Dbit;
5278 let Inst{21} = 1; // W = 1
5279 let Inst{20} = load;
5280 let Inst{19-16} = addr;
5281 let Inst{15-12} = CRd;
5282 let Inst{11-8} = cop;
5283 let Inst{7-0} = offset{7-0};
5284 let DecoderMethod = "DecodeCopMemInstruction";
5286 def _OPTION : ACInoP<(outs),
5287 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
5288 coproc_option_imm:$option),
5289 asm, "\t$cop, $CRd, $addr, $option", []> {
5294 let Inst{24} = 0; // P = 0
5295 let Inst{23} = 1; // U = 1
5296 let Inst{22} = Dbit;
5297 let Inst{21} = 0; // W = 0
5298 let Inst{20} = load;
5299 let Inst{19-16} = addr;
5300 let Inst{15-12} = CRd;
5301 let Inst{11-8} = cop;
5302 let Inst{7-0} = option;
5303 let DecoderMethod = "DecodeCopMemInstruction";
5307 defm LDC : LdStCop <1, 0, "ldc", [(int_arm_ldc imm:$cop, imm:$CRd, addrmode5:$addr)]>;
5308 defm LDCL : LdStCop <1, 1, "ldcl", [(int_arm_ldcl imm:$cop, imm:$CRd, addrmode5:$addr)]>;
5309 defm LDC2 : LdSt2Cop<1, 0, "ldc2", [(int_arm_ldc2 imm:$cop, imm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>;
5310 defm LDC2L : LdSt2Cop<1, 1, "ldc2l", [(int_arm_ldc2l imm:$cop, imm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>;
5312 defm STC : LdStCop <0, 0, "stc", [(int_arm_stc imm:$cop, imm:$CRd, addrmode5:$addr)]>;
5313 defm STCL : LdStCop <0, 1, "stcl", [(int_arm_stcl imm:$cop, imm:$CRd, addrmode5:$addr)]>;
5314 defm STC2 : LdSt2Cop<0, 0, "stc2", [(int_arm_stc2 imm:$cop, imm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>;
5315 defm STC2L : LdSt2Cop<0, 1, "stc2l", [(int_arm_stc2l imm:$cop, imm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>;
5317 } // DecoderNamespace = "CoProc"
5319 //===----------------------------------------------------------------------===//
5320 // Move between coprocessor and ARM core register.
5323 class MovRCopro<string opc, bit direction, dag oops, dag iops,
5325 : ABI<0b1110, oops, iops, NoItinerary, opc,
5326 "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2", pattern> {
5327 let Inst{20} = direction;
5337 let Inst{15-12} = Rt;
5338 let Inst{11-8} = cop;
5339 let Inst{23-21} = opc1;
5340 let Inst{7-5} = opc2;
5341 let Inst{3-0} = CRm;
5342 let Inst{19-16} = CRn;
5344 let DecoderNamespace = "CoProc";
5347 def MCR : MovRCopro<"mcr", 0 /* from ARM core register to coprocessor */,
5349 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5350 c_imm:$CRm, imm0_7:$opc2),
5351 [(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
5352 imm:$CRm, imm:$opc2)]>,
5353 ComplexDeprecationPredicate<"MCR">;
5354 def : ARMInstAlias<"mcr${p} $cop, $opc1, $Rt, $CRn, $CRm",
5355 (MCR p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5356 c_imm:$CRm, 0, pred:$p)>;
5357 def MRC : MovRCopro<"mrc", 1 /* from coprocessor to ARM core register */,
5358 (outs GPRwithAPSR:$Rt),
5359 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
5361 def : ARMInstAlias<"mrc${p} $cop, $opc1, $Rt, $CRn, $CRm",
5362 (MRC GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
5363 c_imm:$CRm, 0, pred:$p)>;
5365 def : ARMPat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
5366 (MRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
5368 class MovRCopro2<string opc, bit direction, dag oops, dag iops,
5370 : ABXI<0b1110, oops, iops, NoItinerary,
5371 !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), pattern> {
5372 let Inst{31-24} = 0b11111110;
5373 let Inst{20} = direction;
5383 let Inst{15-12} = Rt;
5384 let Inst{11-8} = cop;
5385 let Inst{23-21} = opc1;
5386 let Inst{7-5} = opc2;
5387 let Inst{3-0} = CRm;
5388 let Inst{19-16} = CRn;
5390 let DecoderNamespace = "CoProc";
5393 def MCR2 : MovRCopro2<"mcr2", 0 /* from ARM core register to coprocessor */,
5395 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5396 c_imm:$CRm, imm0_7:$opc2),
5397 [(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
5398 imm:$CRm, imm:$opc2)]>,
5399 Requires<[IsARM,PreV8]>;
5400 def : ARMInstAlias<"mcr2 $cop, $opc1, $Rt, $CRn, $CRm",
5401 (MCR2 p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5403 def MRC2 : MovRCopro2<"mrc2", 1 /* from coprocessor to ARM core register */,
5404 (outs GPRwithAPSR:$Rt),
5405 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
5407 Requires<[IsARM,PreV8]>;
5408 def : ARMInstAlias<"mrc2 $cop, $opc1, $Rt, $CRn, $CRm",
5409 (MRC2 GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
5412 def : ARMV5TPat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn,
5413 imm:$CRm, imm:$opc2),
5414 (MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
5416 class MovRRCopro<string opc, bit direction, dag oops, dag iops, list<dag>
5418 : ABI<0b1100, oops, iops, NoItinerary, opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm",
5421 let Inst{23-21} = 0b010;
5422 let Inst{20} = direction;
5430 let Inst{15-12} = Rt;
5431 let Inst{19-16} = Rt2;
5432 let Inst{11-8} = cop;
5433 let Inst{7-4} = opc1;
5434 let Inst{3-0} = CRm;
5437 def MCRR : MovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */,
5438 (outs), (ins p_imm:$cop, imm0_15:$opc1, GPRnopc:$Rt,
5439 GPRnopc:$Rt2, c_imm:$CRm),
5440 [(int_arm_mcrr imm:$cop, imm:$opc1, GPRnopc:$Rt,
5441 GPRnopc:$Rt2, imm:$CRm)]>;
5442 def MRRC : MovRRCopro<"mrrc", 1 /* from coprocessor to ARM core register */,
5443 (outs GPRnopc:$Rt, GPRnopc:$Rt2),
5444 (ins p_imm:$cop, imm0_15:$opc1, c_imm:$CRm), []>;
5446 class MovRRCopro2<string opc, bit direction, dag oops, dag iops,
5447 list<dag> pattern = []>
5448 : ABXI<0b1100, oops, iops, NoItinerary,
5449 !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern>,
5450 Requires<[IsARM,PreV8]> {
5451 let Inst{31-28} = 0b1111;
5452 let Inst{23-21} = 0b010;
5453 let Inst{20} = direction;
5461 let Inst{15-12} = Rt;
5462 let Inst{19-16} = Rt2;
5463 let Inst{11-8} = cop;
5464 let Inst{7-4} = opc1;
5465 let Inst{3-0} = CRm;
5467 let DecoderMethod = "DecoderForMRRC2AndMCRR2";
5470 def MCRR2 : MovRRCopro2<"mcrr2", 0 /* from ARM core register to coprocessor */,
5471 (outs), (ins p_imm:$cop, imm0_15:$opc1, GPRnopc:$Rt,
5472 GPRnopc:$Rt2, c_imm:$CRm),
5473 [(int_arm_mcrr2 imm:$cop, imm:$opc1, GPRnopc:$Rt,
5474 GPRnopc:$Rt2, imm:$CRm)]>;
5476 def MRRC2 : MovRRCopro2<"mrrc2", 1 /* from coprocessor to ARM core register */,
5477 (outs GPRnopc:$Rt, GPRnopc:$Rt2),
5478 (ins p_imm:$cop, imm0_15:$opc1, c_imm:$CRm), []>;
5480 //===----------------------------------------------------------------------===//
5481 // Move between special register and ARM core register
5484 // Move to ARM core register from Special Register
5485 def MRS : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
5486 "mrs", "\t$Rd, apsr", []> {
5488 let Inst{23-16} = 0b00001111;
5489 let Unpredictable{19-17} = 0b111;
5491 let Inst{15-12} = Rd;
5493 let Inst{11-0} = 0b000000000000;
5494 let Unpredictable{11-0} = 0b110100001111;
5497 def : InstAlias<"mrs${p} $Rd, cpsr", (MRS GPRnopc:$Rd, pred:$p), 0>,
5500 // The MRSsys instruction is the MRS instruction from the ARM ARM,
5501 // section B9.3.9, with the R bit set to 1.
5502 def MRSsys : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
5503 "mrs", "\t$Rd, spsr", []> {
5505 let Inst{23-16} = 0b01001111;
5506 let Unpredictable{19-16} = 0b1111;
5508 let Inst{15-12} = Rd;
5510 let Inst{11-0} = 0b000000000000;
5511 let Unpredictable{11-0} = 0b110100001111;
5514 // However, the MRS (banked register) system instruction (ARMv7VE) *does* have a
5515 // separate encoding (distinguished by bit 5.
5516 def MRSbanked : ABI<0b0001, (outs GPRnopc:$Rd), (ins banked_reg:$banked),
5517 NoItinerary, "mrs", "\t$Rd, $banked", []>,
5518 Requires<[IsARM, HasVirtualization]> {
5523 let Inst{22} = banked{5}; // R bit
5524 let Inst{21-20} = 0b00;
5525 let Inst{19-16} = banked{3-0};
5526 let Inst{15-12} = Rd;
5527 let Inst{11-9} = 0b001;
5528 let Inst{8} = banked{4};
5529 let Inst{7-0} = 0b00000000;
5532 // Move from ARM core register to Special Register
5534 // No need to have both system and application versions of MSR (immediate) or
5535 // MSR (register), the encodings are the same and the assembly parser has no way
5536 // to distinguish between them. The mask operand contains the special register
5537 // (R Bit) in bit 4 and bits 3-0 contains the mask with the fields to be
5538 // accessed in the special register.
5539 let Defs = [CPSR] in
5540 def MSR : ABI<0b0001, (outs), (ins msr_mask:$mask, GPR:$Rn), NoItinerary,
5541 "msr", "\t$mask, $Rn", []> {
5546 let Inst{22} = mask{4}; // R bit
5547 let Inst{21-20} = 0b10;
5548 let Inst{19-16} = mask{3-0};
5549 let Inst{15-12} = 0b1111;
5550 let Inst{11-4} = 0b00000000;
5554 let Defs = [CPSR] in
5555 def MSRi : ABI<0b0011, (outs), (ins msr_mask:$mask, mod_imm:$imm), NoItinerary,
5556 "msr", "\t$mask, $imm", []> {
5561 let Inst{22} = mask{4}; // R bit
5562 let Inst{21-20} = 0b10;
5563 let Inst{19-16} = mask{3-0};
5564 let Inst{15-12} = 0b1111;
5565 let Inst{11-0} = imm;
5568 // However, the MSR (banked register) system instruction (ARMv7VE) *does* have a
5569 // separate encoding (distinguished by bit 5.
5570 def MSRbanked : ABI<0b0001, (outs), (ins banked_reg:$banked, GPRnopc:$Rn),
5571 NoItinerary, "msr", "\t$banked, $Rn", []>,
5572 Requires<[IsARM, HasVirtualization]> {
5577 let Inst{22} = banked{5}; // R bit
5578 let Inst{21-20} = 0b10;
5579 let Inst{19-16} = banked{3-0};
5580 let Inst{15-12} = 0b1111;
5581 let Inst{11-9} = 0b001;
5582 let Inst{8} = banked{4};
5583 let Inst{7-4} = 0b0000;
5587 // Dynamic stack allocation yields a _chkstk for Windows targets. These calls
5588 // are needed to probe the stack when allocating more than
5589 // 4k bytes in one go. Touching the stack at 4K increments is necessary to
5590 // ensure that the guard pages used by the OS virtual memory manager are
5591 // allocated in correct sequence.
5592 // The main point of having separate instruction are extra unmodelled effects
5593 // (compared to ordinary calls) like stack pointer change.
5595 def win__chkstk : SDNode<"ARMISD::WIN__CHKSTK", SDTNone,
5596 [SDNPHasChain, SDNPSideEffect]>;
5597 let usesCustomInserter = 1, Uses = [R4], Defs = [R4, SP] in
5598 def WIN__CHKSTK : PseudoInst<(outs), (ins), NoItinerary, [(win__chkstk)]>;
5600 def win__dbzchk : SDNode<"ARMISD::WIN__DBZCHK", SDT_WIN__DBZCHK,
5601 [SDNPHasChain, SDNPSideEffect, SDNPOutGlue]>;
5602 let usesCustomInserter = 1, Defs = [CPSR] in
5603 def WIN__DBZCHK : PseudoInst<(outs), (ins tGPR:$divisor), NoItinerary,
5604 [(win__dbzchk tGPR:$divisor)]>;
5606 //===----------------------------------------------------------------------===//
5610 // __aeabi_read_tp preserves the registers r1-r3.
5611 // This is a pseudo inst so that we can get the encoding right,
5612 // complete with fixup for the aeabi_read_tp function.
5613 // TPsoft is valid for ARM mode only, in case of Thumb mode a tTPsoft pattern
5614 // is defined in "ARMInstrThumb.td".
5616 Defs = [R0, R12, LR, CPSR], Uses = [SP] in {
5617 def TPsoft : ARMPseudoInst<(outs), (ins), 4, IIC_Br,
5618 [(set R0, ARMthread_pointer)]>, Sched<[WriteBr]>,
5619 Requires<[IsARM, IsReadTPSoft]>;
5622 // Reading thread pointer from coprocessor register
5623 def : ARMPat<(ARMthread_pointer), (MRC 15, 0, 13, 0, 3)>,
5624 Requires<[IsARM, IsReadTPHard]>;
5626 //===----------------------------------------------------------------------===//
5627 // SJLJ Exception handling intrinsics
5628 // eh_sjlj_setjmp() is an instruction sequence to store the return
5629 // address and save #0 in R0 for the non-longjmp case.
5630 // Since by its nature we may be coming from some other function to get
5631 // here, and we're using the stack frame for the containing function to
5632 // save/restore registers, we can't keep anything live in regs across
5633 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
5634 // when we get here from a longjmp(). We force everything out of registers
5635 // except for our own input by listing the relevant registers in Defs. By
5636 // doing so, we also cause the prologue/epilogue code to actively preserve
5637 // all of the callee-saved resgisters, which is exactly what we want.
5638 // A constant value is passed in $val, and we use the location as a scratch.
5640 // These are pseudo-instructions and are lowered to individual MC-insts, so
5641 // no encoding information is necessary.
5643 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
5644 Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15 ],
5645 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
5646 def Int_eh_sjlj_setjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
5648 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
5649 Requires<[IsARM, HasVFP2]>;
5653 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
5654 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
5655 def Int_eh_sjlj_setjmp_nofp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
5657 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
5658 Requires<[IsARM, NoVFP]>;
5661 // FIXME: Non-IOS version(s)
5662 let isBarrier = 1, hasSideEffects = 1, isTerminator = 1,
5663 Defs = [ R7, LR, SP ] in {
5664 def Int_eh_sjlj_longjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$scratch),
5666 [(ARMeh_sjlj_longjmp GPR:$src, GPR:$scratch)]>,
5670 let isBarrier = 1, hasSideEffects = 1, usesCustomInserter = 1 in
5671 def Int_eh_sjlj_setup_dispatch : PseudoInst<(outs), (ins), NoItinerary,
5672 [(ARMeh_sjlj_setup_dispatch)]>;
5674 // eh.sjlj.dispatchsetup pseudo-instruction.
5675 // This pseudo is used for both ARM and Thumb. Any differences are handled when
5676 // the pseudo is expanded (which happens before any passes that need the
5677 // instruction size).
5678 let isBarrier = 1 in
5679 def Int_eh_sjlj_dispatchsetup : PseudoInst<(outs), (ins), NoItinerary, []>;
5682 //===----------------------------------------------------------------------===//
5683 // Non-Instruction Patterns
5686 // ARMv4 indirect branch using (MOVr PC, dst)
5687 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in
5688 def MOVPCRX : ARMPseudoExpand<(outs), (ins GPR:$dst),
5689 4, IIC_Br, [(brind GPR:$dst)],
5690 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>,
5691 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
5693 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in
5694 def TAILJMPr4 : ARMPseudoExpand<(outs), (ins GPR:$dst),
5696 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>,
5697 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
5699 // Large immediate handling.
5701 // 32-bit immediate using two piece mod_imms or movw + movt.
5702 // This is a single pseudo instruction, the benefit is that it can be remat'd
5703 // as a single unit instead of having to handle reg inputs.
5704 // FIXME: Remove this when we can do generalized remat.
5705 let isReMaterializable = 1, isMoveImm = 1 in
5706 def MOVi32imm : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
5707 [(set GPR:$dst, (arm_i32imm:$src))]>,
5710 def LDRLIT_ga_abs : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iLoad_i,
5711 [(set GPR:$dst, (ARMWrapper tglobaladdr:$src))]>,
5712 Requires<[IsARM, DontUseMovt]>;
5714 // Pseudo instruction that combines movw + movt + add pc (if PIC).
5715 // It also makes it possible to rematerialize the instructions.
5716 // FIXME: Remove this when we can do generalized remat and when machine licm
5717 // can properly the instructions.
5718 let isReMaterializable = 1 in {
5719 def MOV_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5721 [(set GPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>,
5722 Requires<[IsARM, UseMovtInPic]>;
5724 def LDRLIT_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5727 (ARMWrapperPIC tglobaladdr:$addr))]>,
5728 Requires<[IsARM, DontUseMovtInPic]>;
5730 let AddedComplexity = 10 in
5731 def LDRLIT_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5734 (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
5735 Requires<[IsARM, DontUseMovtInPic]>;
5737 let AddedComplexity = 10 in
5738 def MOV_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5740 [(set GPR:$dst, (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
5741 Requires<[IsARM, UseMovtInPic]>;
5742 } // isReMaterializable
5744 // The many different faces of TLS access.
5745 def : ARMPat<(ARMWrapper tglobaltlsaddr :$dst),
5746 (MOVi32imm tglobaltlsaddr :$dst)>,
5747 Requires<[IsARM, UseMovt]>;
5749 def : Pat<(ARMWrapper tglobaltlsaddr:$src),
5750 (LDRLIT_ga_abs tglobaltlsaddr:$src)>,
5751 Requires<[IsARM, DontUseMovt]>;
5753 def : Pat<(ARMWrapperPIC tglobaltlsaddr:$addr),
5754 (MOV_ga_pcrel tglobaltlsaddr:$addr)>, Requires<[IsARM, UseMovtInPic]>;
5756 def : Pat<(ARMWrapperPIC tglobaltlsaddr:$addr),
5757 (LDRLIT_ga_pcrel tglobaltlsaddr:$addr)>,
5758 Requires<[IsARM, DontUseMovtInPic]>;
5759 let AddedComplexity = 10 in
5760 def : Pat<(load (ARMWrapperPIC tglobaltlsaddr:$addr)),
5761 (MOV_ga_pcrel_ldr tglobaltlsaddr:$addr)>,
5762 Requires<[IsARM, UseMovtInPic]>;
5765 // ConstantPool, GlobalAddress, and JumpTable
5766 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
5767 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
5768 Requires<[IsARM, UseMovt]>;
5769 def : ARMPat<(ARMWrapper texternalsym :$dst), (MOVi32imm texternalsym :$dst)>,
5770 Requires<[IsARM, UseMovt]>;
5771 def : ARMPat<(ARMWrapperJT tjumptable:$dst),
5772 (LEApcrelJT tjumptable:$dst)>;
5774 // TODO: add,sub,and, 3-instr forms?
5776 // Tail calls. These patterns also apply to Thumb mode.
5777 def : Pat<(ARMtcret tcGPR:$dst), (TCRETURNri tcGPR:$dst)>;
5778 def : Pat<(ARMtcret (i32 tglobaladdr:$dst)), (TCRETURNdi texternalsym:$dst)>;
5779 def : Pat<(ARMtcret (i32 texternalsym:$dst)), (TCRETURNdi texternalsym:$dst)>;
5782 def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>;
5783 def : ARMPat<(ARMcall_nolink texternalsym:$func),
5784 (BMOVPCB_CALL texternalsym:$func)>;
5786 // zextload i1 -> zextload i8
5787 def : ARMPat<(zextloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5788 def : ARMPat<(zextloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5790 // extload -> zextload
5791 def : ARMPat<(extloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5792 def : ARMPat<(extloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5793 def : ARMPat<(extloadi8 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5794 def : ARMPat<(extloadi8 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5796 def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
5798 def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
5799 def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
5802 def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
5803 (SMULBB GPR:$a, GPR:$b)>;
5804 def : ARMV5TEPat<(mul sext_16_node:$a, (sext_bottom_16 GPR:$b)),
5805 (SMULBB GPR:$a, GPR:$b)>;
5806 def : ARMV5TEPat<(mul sext_16_node:$a, (sext_top_16 GPR:$b)),
5807 (SMULBT GPR:$a, GPR:$b)>;
5808 def : ARMV5TEPat<(mul (sext_top_16 GPR:$a), sext_16_node:$b),
5809 (SMULTB GPR:$a, GPR:$b)>;
5810 def : ARMV5MOPat<(add GPR:$acc, (mul sext_16_node:$a, sext_16_node:$b)),
5811 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5812 def : ARMV5MOPat<(add GPR:$acc, (mul sext_16_node:$a, (sext_bottom_16 GPR:$b))),
5813 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5814 def : ARMV5MOPat<(add GPR:$acc, (mul sext_16_node:$a, (sext_top_16 GPR:$b))),
5815 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
5816 def : ARMV5MOPat<(add GPR:$acc, (mul (sext_top_16 GPR:$a), sext_16_node:$b)),
5817 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
5819 def : ARMV5TEPat<(int_arm_smulbb GPR:$a, GPR:$b),
5820 (SMULBB GPR:$a, GPR:$b)>;
5821 def : ARMV5TEPat<(int_arm_smulbt GPR:$a, GPR:$b),
5822 (SMULBT GPR:$a, GPR:$b)>;
5823 def : ARMV5TEPat<(int_arm_smultb GPR:$a, GPR:$b),
5824 (SMULTB GPR:$a, GPR:$b)>;
5825 def : ARMV5TEPat<(int_arm_smultt GPR:$a, GPR:$b),
5826 (SMULTT GPR:$a, GPR:$b)>;
5827 def : ARMV5TEPat<(int_arm_smulwb GPR:$a, GPR:$b),
5828 (SMULWB GPR:$a, GPR:$b)>;
5829 def : ARMV5TEPat<(int_arm_smulwt GPR:$a, GPR:$b),
5830 (SMULWT GPR:$a, GPR:$b)>;
5832 def : ARMV5TEPat<(int_arm_smlabb GPR:$a, GPR:$b, GPR:$acc),
5833 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5834 def : ARMV5TEPat<(int_arm_smlabt GPR:$a, GPR:$b, GPR:$acc),
5835 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
5836 def : ARMV5TEPat<(int_arm_smlatb GPR:$a, GPR:$b, GPR:$acc),
5837 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
5838 def : ARMV5TEPat<(int_arm_smlatt GPR:$a, GPR:$b, GPR:$acc),
5839 (SMLATT GPR:$a, GPR:$b, GPR:$acc)>;
5840 def : ARMV5TEPat<(int_arm_smlawb GPR:$a, GPR:$b, GPR:$acc),
5841 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
5842 def : ARMV5TEPat<(int_arm_smlawt GPR:$a, GPR:$b, GPR:$acc),
5843 (SMLAWT GPR:$a, GPR:$b, GPR:$acc)>;
5845 // Pre-v7 uses MCR for synchronization barriers.
5846 def : ARMPat<(ARMMemBarrierMCR GPR:$zero), (MCR 15, 0, GPR:$zero, 7, 10, 5)>,
5847 Requires<[IsARM, HasV6]>;
5849 // SXT/UXT with no rotate
5850 let AddedComplexity = 16 in {
5851 def : ARMV6Pat<(and GPR:$Src, 0x000000FF), (UXTB GPR:$Src, 0)>;
5852 def : ARMV6Pat<(and GPR:$Src, 0x0000FFFF), (UXTH GPR:$Src, 0)>;
5853 def : ARMV6Pat<(and GPR:$Src, 0x00FF00FF), (UXTB16 GPR:$Src, 0)>;
5854 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0x00FF)),
5855 (UXTAB GPR:$Rn, GPR:$Rm, 0)>;
5856 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0xFFFF)),
5857 (UXTAH GPR:$Rn, GPR:$Rm, 0)>;
5860 def : ARMV6Pat<(sext_inreg GPR:$Src, i8), (SXTB GPR:$Src, 0)>;
5861 def : ARMV6Pat<(sext_inreg GPR:$Src, i16), (SXTH GPR:$Src, 0)>;
5863 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i8)),
5864 (SXTAB GPR:$Rn, GPRnopc:$Rm, 0)>;
5865 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i16)),
5866 (SXTAH GPR:$Rn, GPRnopc:$Rm, 0)>;
5868 // Atomic load/store patterns
5869 def : ARMPat<(atomic_load_8 ldst_so_reg:$src),
5870 (LDRBrs ldst_so_reg:$src)>;
5871 def : ARMPat<(atomic_load_8 addrmode_imm12:$src),
5872 (LDRBi12 addrmode_imm12:$src)>;
5873 def : ARMPat<(atomic_load_16 addrmode3:$src),
5874 (LDRH addrmode3:$src)>;
5875 def : ARMPat<(atomic_load_32 ldst_so_reg:$src),
5876 (LDRrs ldst_so_reg:$src)>;
5877 def : ARMPat<(atomic_load_32 addrmode_imm12:$src),
5878 (LDRi12 addrmode_imm12:$src)>;
5879 def : ARMPat<(atomic_store_8 ldst_so_reg:$ptr, GPR:$val),
5880 (STRBrs GPR:$val, ldst_so_reg:$ptr)>;
5881 def : ARMPat<(atomic_store_8 addrmode_imm12:$ptr, GPR:$val),
5882 (STRBi12 GPR:$val, addrmode_imm12:$ptr)>;
5883 def : ARMPat<(atomic_store_16 addrmode3:$ptr, GPR:$val),
5884 (STRH GPR:$val, addrmode3:$ptr)>;
5885 def : ARMPat<(atomic_store_32 ldst_so_reg:$ptr, GPR:$val),
5886 (STRrs GPR:$val, ldst_so_reg:$ptr)>;
5887 def : ARMPat<(atomic_store_32 addrmode_imm12:$ptr, GPR:$val),
5888 (STRi12 GPR:$val, addrmode_imm12:$ptr)>;
5891 //===----------------------------------------------------------------------===//
5895 include "ARMInstrThumb.td"
5897 //===----------------------------------------------------------------------===//
5901 include "ARMInstrThumb2.td"
5903 //===----------------------------------------------------------------------===//
5904 // Floating Point Support
5907 include "ARMInstrVFP.td"
5909 //===----------------------------------------------------------------------===//
5910 // Advanced SIMD (NEON) Support
5913 include "ARMInstrNEON.td"
5915 //===----------------------------------------------------------------------===//
5919 include "ARMInstrMVE.td"
5921 //===----------------------------------------------------------------------===//
5922 // Assembler aliases
5926 def : InstAlias<"dmb", (DMB 0xf), 0>, Requires<[IsARM, HasDB]>;
5927 def : InstAlias<"dsb", (DSB 0xf), 0>, Requires<[IsARM, HasDB]>;
5928 def : InstAlias<"ssbb", (DSB 0x0), 1>, Requires<[IsARM, HasDB]>;
5929 def : InstAlias<"pssbb", (DSB 0x4), 1>, Requires<[IsARM, HasDB]>;
5930 def : InstAlias<"isb", (ISB 0xf), 0>, Requires<[IsARM, HasDB]>;
5931 // Armv8-R 'Data Full Barrier'
5932 def : InstAlias<"dfb", (DSB 0xc), 1>, Requires<[IsARM, HasDFB]>;
5934 // System instructions
5935 def : MnemonicAlias<"swi", "svc">;
5937 // Load / Store Multiple
5938 def : MnemonicAlias<"ldmfd", "ldm">;
5939 def : MnemonicAlias<"ldmia", "ldm">;
5940 def : MnemonicAlias<"ldmea", "ldmdb">;
5941 def : MnemonicAlias<"stmfd", "stmdb">;
5942 def : MnemonicAlias<"stmia", "stm">;
5943 def : MnemonicAlias<"stmea", "stm">;
5945 // PKHBT/PKHTB with default shift amount. PKHTB is equivalent to PKHBT with the
5946 // input operands swapped when the shift amount is zero (i.e., unspecified).
5947 def : InstAlias<"pkhbt${p} $Rd, $Rn, $Rm",
5948 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p), 0>,
5949 Requires<[IsARM, HasV6]>;
5950 def : InstAlias<"pkhtb${p} $Rd, $Rn, $Rm",
5951 (PKHBT GPRnopc:$Rd, GPRnopc:$Rm, GPRnopc:$Rn, 0, pred:$p), 0>,
5952 Requires<[IsARM, HasV6]>;
5954 // PUSH/POP aliases for STM/LDM
5955 def : ARMInstAlias<"push${p} $regs", (STMDB_UPD SP, pred:$p, reglist:$regs)>;
5956 def : ARMInstAlias<"pop${p} $regs", (LDMIA_UPD SP, pred:$p, reglist:$regs)>;
5958 // SSAT/USAT optional shift operand.
5959 def : ARMInstAlias<"ssat${p} $Rd, $sat_imm, $Rn",
5960 (SSAT GPRnopc:$Rd, imm1_32:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5961 def : ARMInstAlias<"usat${p} $Rd, $sat_imm, $Rn",
5962 (USAT GPRnopc:$Rd, imm0_31:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5965 // Extend instruction optional rotate operand.
5966 def : ARMInstAlias<"sxtab${p} $Rd, $Rn, $Rm",
5967 (SXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5968 def : ARMInstAlias<"sxtah${p} $Rd, $Rn, $Rm",
5969 (SXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5970 def : ARMInstAlias<"sxtab16${p} $Rd, $Rn, $Rm",
5971 (SXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5972 def : ARMInstAlias<"sxtb${p} $Rd, $Rm",
5973 (SXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5974 def : ARMInstAlias<"sxtb16${p} $Rd, $Rm",
5975 (SXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5976 def : ARMInstAlias<"sxth${p} $Rd, $Rm",
5977 (SXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5979 def : ARMInstAlias<"uxtab${p} $Rd, $Rn, $Rm",
5980 (UXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5981 def : ARMInstAlias<"uxtah${p} $Rd, $Rn, $Rm",
5982 (UXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5983 def : ARMInstAlias<"uxtab16${p} $Rd, $Rn, $Rm",
5984 (UXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5985 def : ARMInstAlias<"uxtb${p} $Rd, $Rm",
5986 (UXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5987 def : ARMInstAlias<"uxtb16${p} $Rd, $Rm",
5988 (UXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5989 def : ARMInstAlias<"uxth${p} $Rd, $Rm",
5990 (UXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5994 def : MnemonicAlias<"rfefa", "rfeda">;
5995 def : MnemonicAlias<"rfeea", "rfedb">;
5996 def : MnemonicAlias<"rfefd", "rfeia">;
5997 def : MnemonicAlias<"rfeed", "rfeib">;
5998 def : MnemonicAlias<"rfe", "rfeia">;
6001 def : MnemonicAlias<"srsfa", "srsib">;
6002 def : MnemonicAlias<"srsea", "srsia">;
6003 def : MnemonicAlias<"srsfd", "srsdb">;
6004 def : MnemonicAlias<"srsed", "srsda">;
6005 def : MnemonicAlias<"srs", "srsia">;
6008 def : MnemonicAlias<"qsubaddx", "qsax">;
6010 def : MnemonicAlias<"saddsubx", "sasx">;
6011 // SHASX == SHADDSUBX
6012 def : MnemonicAlias<"shaddsubx", "shasx">;
6013 // SHSAX == SHSUBADDX
6014 def : MnemonicAlias<"shsubaddx", "shsax">;
6016 def : MnemonicAlias<"ssubaddx", "ssax">;
6018 def : MnemonicAlias<"uaddsubx", "uasx">;
6019 // UHASX == UHADDSUBX
6020 def : MnemonicAlias<"uhaddsubx", "uhasx">;
6021 // UHSAX == UHSUBADDX
6022 def : MnemonicAlias<"uhsubaddx", "uhsax">;
6023 // UQASX == UQADDSUBX
6024 def : MnemonicAlias<"uqaddsubx", "uqasx">;
6025 // UQSAX == UQSUBADDX
6026 def : MnemonicAlias<"uqsubaddx", "uqsax">;
6028 def : MnemonicAlias<"usubaddx", "usax">;
6030 // "mov Rd, mod_imm_not" can be handled via "mvn" in assembly, just like
6032 def : ARMInstSubst<"mov${s}${p} $Rd, $imm",
6033 (MVNi rGPR:$Rd, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6034 def : ARMInstSubst<"mvn${s}${p} $Rd, $imm",
6035 (MOVi rGPR:$Rd, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6036 // Same for AND <--> BIC
6037 def : ARMInstSubst<"bic${s}${p} $Rd, $Rn, $imm",
6038 (ANDri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm,
6039 pred:$p, cc_out:$s)>;
6040 def : ARMInstSubst<"bic${s}${p} $Rdn, $imm",
6041 (ANDri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm,
6042 pred:$p, cc_out:$s)>;
6043 def : ARMInstSubst<"and${s}${p} $Rd, $Rn, $imm",
6044 (BICri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm,
6045 pred:$p, cc_out:$s)>;
6046 def : ARMInstSubst<"and${s}${p} $Rdn, $imm",
6047 (BICri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm,
6048 pred:$p, cc_out:$s)>;
6050 // Likewise, "add Rd, mod_imm_neg" -> sub
6051 def : ARMInstSubst<"add${s}${p} $Rd, $Rn, $imm",
6052 (SUBri GPR:$Rd, GPR:$Rn, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
6053 def : ARMInstSubst<"add${s}${p} $Rd, $imm",
6054 (SUBri GPR:$Rd, GPR:$Rd, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
6055 // Likewise, "sub Rd, mod_imm_neg" -> add
6056 def : ARMInstSubst<"sub${s}${p} $Rd, $Rn, $imm",
6057 (ADDri GPR:$Rd, GPR:$Rn, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
6058 def : ARMInstSubst<"sub${s}${p} $Rd, $imm",
6059 (ADDri GPR:$Rd, GPR:$Rd, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
6062 def : ARMInstSubst<"adc${s}${p} $Rd, $Rn, $imm",
6063 (SBCri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6064 def : ARMInstSubst<"adc${s}${p} $Rdn, $imm",
6065 (SBCri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6066 def : ARMInstSubst<"sbc${s}${p} $Rd, $Rn, $imm",
6067 (ADCri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6068 def : ARMInstSubst<"sbc${s}${p} $Rdn, $imm",
6069 (ADCri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6071 // Same for CMP <--> CMN via mod_imm_neg
6072 def : ARMInstSubst<"cmp${p} $Rd, $imm",
6073 (CMNri rGPR:$Rd, mod_imm_neg:$imm, pred:$p)>;
6074 def : ARMInstSubst<"cmn${p} $Rd, $imm",
6075 (CMPri rGPR:$Rd, mod_imm_neg:$imm, pred:$p)>;
6077 // The shifter forms of the MOV instruction are aliased to the ASR, LSL,
6078 // LSR, ROR, and RRX instructions.
6079 // FIXME: We need C++ parser hooks to map the alias to the MOV
6080 // encoding. It seems we should be able to do that sort of thing
6081 // in tblgen, but it could get ugly.
6082 let TwoOperandAliasConstraint = "$Rm = $Rd" in {
6083 def ASRi : ARMAsmPseudo<"asr${s}${p} $Rd, $Rm, $imm",
6084 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
6086 def LSRi : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rm, $imm",
6087 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
6089 def LSLi : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rm, $imm",
6090 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
6092 def RORi : ARMAsmPseudo<"ror${s}${p} $Rd, $Rm, $imm",
6093 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
6096 def RRXi : ARMAsmPseudo<"rrx${s}${p} $Rd, $Rm",
6097 (ins GPR:$Rd, GPR:$Rm, pred:$p, cc_out:$s)>;
6098 let TwoOperandAliasConstraint = "$Rn = $Rd" in {
6099 def ASRr : ARMAsmPseudo<"asr${s}${p} $Rd, $Rn, $Rm",
6100 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
6102 def LSRr : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rn, $Rm",
6103 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
6105 def LSLr : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rn, $Rm",
6106 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
6108 def RORr : ARMAsmPseudo<"ror${s}${p} $Rd, $Rn, $Rm",
6109 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
6113 // "neg" is and alias for "rsb rd, rn, #0"
6114 def : ARMInstAlias<"neg${s}${p} $Rd, $Rm",
6115 (RSBri GPR:$Rd, GPR:$Rm, 0, pred:$p, cc_out:$s)>;
6117 // Pre-v6, 'mov r0, r0' was used as a NOP encoding.
6118 def : InstAlias<"nop${p}", (MOVr R0, R0, pred:$p, zero_reg)>,
6119 Requires<[IsARM, NoV6]>;
6121 // MUL/UMLAL/SMLAL/UMULL/SMULL are available on all arches, but
6122 // the instruction definitions need difference constraints pre-v6.
6123 // Use these aliases for the assembly parsing on pre-v6.
6124 def : InstAlias<"mul${s}${p} $Rd, $Rn, $Rm",
6125 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s), 0>,
6126 Requires<[IsARM, NoV6]>;
6127 def : InstAlias<"mla${s}${p} $Rd, $Rn, $Rm, $Ra",
6128 (MLA GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra,
6129 pred:$p, cc_out:$s), 0>,
6130 Requires<[IsARM, NoV6]>;
6131 def : InstAlias<"smlal${s}${p} $RdLo, $RdHi, $Rn, $Rm",
6132 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>,
6133 Requires<[IsARM, NoV6]>;
6134 def : InstAlias<"umlal${s}${p} $RdLo, $RdHi, $Rn, $Rm",
6135 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>,
6136 Requires<[IsARM, NoV6]>;
6137 def : InstAlias<"smull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
6138 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>,
6139 Requires<[IsARM, NoV6]>;
6140 def : InstAlias<"umull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
6141 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>,
6142 Requires<[IsARM, NoV6]>;
6144 // 'it' blocks in ARM mode just validate the predicates. The IT itself
6146 def ITasm : ARMAsmPseudo<"it$mask $cc", (ins it_pred:$cc, it_mask:$mask)>,
6147 ComplexDeprecationPredicate<"IT">;
6149 let mayLoad = 1, mayStore =1, hasSideEffects = 1 in
6150 def SPACE : PseudoInst<(outs GPR:$Rd), (ins i32imm:$size, GPR:$Rn),
6152 [(set GPR:$Rd, (int_arm_space imm:$size, GPR:$Rn))]>;
6154 //===----------------------------------
6155 // Atomic cmpxchg for -O0
6156 //===----------------------------------
6158 // The fast register allocator used during -O0 inserts spills to cover any VRegs
6159 // live across basic block boundaries. When this happens between an LDXR and an
6160 // STXR it can clear the exclusive monitor, causing all cmpxchg attempts to
6163 // Unfortunately, this means we have to have an alternative (expanded
6164 // post-regalloc) path for -O0 compilations. Fortunately this path can be
6165 // significantly more naive than the standard expansion: we conservatively
6166 // assume seq_cst, strong cmpxchg and omit clrex on failure.
6168 let Constraints = "@earlyclobber $Rd,@earlyclobber $temp",
6169 mayLoad = 1, mayStore = 1 in {
6170 def CMP_SWAP_8 : PseudoInst<(outs GPR:$Rd, GPR:$temp),
6171 (ins GPR:$addr, GPR:$desired, GPR:$new),
6172 NoItinerary, []>, Sched<[]>;
6174 def CMP_SWAP_16 : PseudoInst<(outs GPR:$Rd, GPR:$temp),
6175 (ins GPR:$addr, GPR:$desired, GPR:$new),
6176 NoItinerary, []>, Sched<[]>;
6178 def CMP_SWAP_32 : PseudoInst<(outs GPR:$Rd, GPR:$temp),
6179 (ins GPR:$addr, GPR:$desired, GPR:$new),
6180 NoItinerary, []>, Sched<[]>;
6182 def CMP_SWAP_64 : PseudoInst<(outs GPRPair:$Rd, GPR:$temp),
6183 (ins GPR:$addr, GPRPair:$desired, GPRPair:$new),
6184 NoItinerary, []>, Sched<[]>;
6187 def CompilerBarrier : PseudoInst<(outs), (ins i32imm:$ordering), NoItinerary,
6188 [(atomic_fence imm:$ordering, 0)]> {
6189 let hasSideEffects = 1;
6191 let AsmString = "@ COMPILER BARRIER";