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>]>;
55 def SDT_ARMPICAdd : SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>,
56 SDTCisPtrTy<1>, SDTCisVT<2, i32>]>;
58 def SDT_ARMThreadPointer : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
59 def SDT_ARMEH_SJLJ_Setjmp : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisPtrTy<1>,
61 def SDT_ARMEH_SJLJ_Longjmp: SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
62 def SDT_ARMEH_SJLJ_SetupDispatch: SDTypeProfile<0, 0, []>;
64 def SDT_ARMMEMBARRIER : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
66 def SDT_ARMPREFETCH : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisSameAs<1, 2>,
69 def SDT_ARMTCRET : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
71 def SDT_ARMBFI : SDTypeProfile<1, 3, [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
72 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
74 def SDT_WIN__DBZCHK : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
76 def SDT_ARMMEMCPY : SDTypeProfile<2, 3, [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
77 SDTCisVT<2, i32>, SDTCisVT<3, i32>,
80 def SDTBinaryArithWithFlags : SDTypeProfile<2, 2,
83 SDTCisInt<0>, SDTCisVT<1, i32>]>;
85 // SDTBinaryArithWithFlagsInOut - RES1, CPSR = op LHS, RHS, CPSR
86 def SDTBinaryArithWithFlagsInOut : SDTypeProfile<2, 3,
93 def SDT_LongMac : SDTypeProfile<2, 4, [SDTCisVT<0, i32>,
100 // ARMlsll, ARMlsrl, ARMasrl
101 def SDT_ARMIntShiftParts : SDTypeProfile<2, 3, [SDTCisSameAs<0, 1>,
107 // TODO Add another operand for 'Size' so that we can re-use this node when we
108 // start supporting *TP versions.
109 def SDT_ARMLoLoop : SDTypeProfile<0, 2, [SDTCisVT<0, i32>,
110 SDTCisVT<1, OtherVT>]>;
112 def ARMSmlald : SDNode<"ARMISD::SMLALD", SDT_LongMac>;
113 def ARMSmlaldx : SDNode<"ARMISD::SMLALDX", SDT_LongMac>;
114 def ARMSmlsld : SDNode<"ARMISD::SMLSLD", SDT_LongMac>;
115 def ARMSmlsldx : SDNode<"ARMISD::SMLSLDX", SDT_LongMac>;
117 def SDT_ARMCSel : SDTypeProfile<1, 3,
123 def ARMcsinv : SDNode<"ARMISD::CSINV", SDT_ARMCSel, [SDNPOptInGlue]>;
124 def ARMcsneg : SDNode<"ARMISD::CSNEG", SDT_ARMCSel, [SDNPOptInGlue]>;
125 def ARMcsinc : SDNode<"ARMISD::CSINC", SDT_ARMCSel, [SDNPOptInGlue]>;
127 def SDT_MulHSR : SDTypeProfile<1, 3, [SDTCisVT<0,i32>,
130 SDTCisSameAs<0, 3>]>;
132 def ARMsmmlar : SDNode<"ARMISD::SMMLAR", SDT_MulHSR>;
133 def ARMsmmlsr : SDNode<"ARMISD::SMMLSR", SDT_MulHSR>;
136 def ARMWrapper : SDNode<"ARMISD::Wrapper", SDTIntUnaryOp>;
137 def ARMWrapperPIC : SDNode<"ARMISD::WrapperPIC", SDTIntUnaryOp>;
138 def ARMWrapperJT : SDNode<"ARMISD::WrapperJT", SDTIntUnaryOp>;
140 def ARMcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_ARMCallSeqStart,
141 [SDNPHasChain, SDNPSideEffect, SDNPOutGlue]>;
142 def ARMcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_ARMCallSeqEnd,
143 [SDNPHasChain, SDNPSideEffect,
144 SDNPOptInGlue, SDNPOutGlue]>;
145 def ARMcopystructbyval : SDNode<"ARMISD::COPY_STRUCT_BYVAL" ,
147 [SDNPHasChain, SDNPInGlue, SDNPOutGlue,
148 SDNPMayStore, SDNPMayLoad]>;
150 def ARMcall : SDNode<"ARMISD::CALL", SDT_ARMcall,
151 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
153 def ARMcall_pred : SDNode<"ARMISD::CALL_PRED", SDT_ARMcall,
154 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
156 def ARMcall_nolink : SDNode<"ARMISD::CALL_NOLINK", SDT_ARMcall,
157 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
160 def ARMretflag : SDNode<"ARMISD::RET_FLAG", SDTNone,
161 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
162 def ARMintretflag : SDNode<"ARMISD::INTRET_FLAG", SDT_ARMcall,
163 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
164 def ARMcmov : SDNode<"ARMISD::CMOV", SDT_ARMCMov,
166 def ARMsubs : SDNode<"ARMISD::SUBS", SDTIntBinOp, [SDNPOutGlue]>;
168 def ARMssatnoshift : SDNode<"ARMISD::SSAT", SDTIntSatNoShOp, []>;
170 def ARMusatnoshift : SDNode<"ARMISD::USAT", SDTIntSatNoShOp, []>;
172 def ARMbrcond : SDNode<"ARMISD::BRCOND", SDT_ARMBrcond,
173 [SDNPHasChain, SDNPInGlue, SDNPOutGlue]>;
175 def ARMbrjt : SDNode<"ARMISD::BR_JT", SDT_ARMBrJT,
177 def ARMbr2jt : SDNode<"ARMISD::BR2_JT", SDT_ARMBr2JT,
180 def ARMBcci64 : SDNode<"ARMISD::BCC_i64", SDT_ARMBCC_i64,
183 def ARMcmp : SDNode<"ARMISD::CMP", SDT_ARMCmp,
186 def ARMcmn : SDNode<"ARMISD::CMN", SDT_ARMCmp,
189 def ARMcmpZ : SDNode<"ARMISD::CMPZ", SDT_ARMCmp,
190 [SDNPOutGlue, SDNPCommutative]>;
192 def ARMpic_add : SDNode<"ARMISD::PIC_ADD", SDT_ARMPICAdd>;
194 def ARMasrl : SDNode<"ARMISD::ASRL", SDT_ARMIntShiftParts, []>;
195 def ARMlsrl : SDNode<"ARMISD::LSRL", SDT_ARMIntShiftParts, []>;
196 def ARMlsll : SDNode<"ARMISD::LSLL", SDT_ARMIntShiftParts, []>;
198 def ARMsrl_flag : SDNode<"ARMISD::SRL_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
199 def ARMsra_flag : SDNode<"ARMISD::SRA_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
200 def ARMrrx : SDNode<"ARMISD::RRX" , SDTIntUnaryOp, [SDNPInGlue ]>;
202 def ARMaddc : SDNode<"ARMISD::ADDC", SDTBinaryArithWithFlags,
204 def ARMsubc : SDNode<"ARMISD::SUBC", SDTBinaryArithWithFlags>;
205 def ARMlsls : SDNode<"ARMISD::LSLS", SDTBinaryArithWithFlags>;
206 def ARMadde : SDNode<"ARMISD::ADDE", SDTBinaryArithWithFlagsInOut>;
207 def ARMsube : SDNode<"ARMISD::SUBE", SDTBinaryArithWithFlagsInOut>;
209 def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>;
210 def ARMeh_sjlj_setjmp: SDNode<"ARMISD::EH_SJLJ_SETJMP",
211 SDT_ARMEH_SJLJ_Setjmp,
212 [SDNPHasChain, SDNPSideEffect]>;
213 def ARMeh_sjlj_longjmp: SDNode<"ARMISD::EH_SJLJ_LONGJMP",
214 SDT_ARMEH_SJLJ_Longjmp,
215 [SDNPHasChain, SDNPSideEffect]>;
216 def ARMeh_sjlj_setup_dispatch: SDNode<"ARMISD::EH_SJLJ_SETUP_DISPATCH",
217 SDT_ARMEH_SJLJ_SetupDispatch,
218 [SDNPHasChain, SDNPSideEffect]>;
220 def ARMMemBarrierMCR : SDNode<"ARMISD::MEMBARRIER_MCR", SDT_ARMMEMBARRIER,
221 [SDNPHasChain, SDNPSideEffect]>;
222 def ARMPreload : SDNode<"ARMISD::PRELOAD", SDT_ARMPREFETCH,
223 [SDNPHasChain, SDNPMayLoad, SDNPMayStore]>;
225 def ARMtcret : SDNode<"ARMISD::TC_RETURN", SDT_ARMTCRET,
226 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
228 def ARMbfi : SDNode<"ARMISD::BFI", SDT_ARMBFI>;
230 def ARMmemcopy : SDNode<"ARMISD::MEMCPY", SDT_ARMMEMCPY,
231 [SDNPHasChain, SDNPInGlue, SDNPOutGlue,
232 SDNPMayStore, SDNPMayLoad]>;
234 def ARMsmulwb : SDNode<"ARMISD::SMULWB", SDTIntBinOp, []>;
235 def ARMsmulwt : SDNode<"ARMISD::SMULWT", SDTIntBinOp, []>;
236 def ARMsmlalbb : SDNode<"ARMISD::SMLALBB", SDT_LongMac, []>;
237 def ARMsmlalbt : SDNode<"ARMISD::SMLALBT", SDT_LongMac, []>;
238 def ARMsmlaltb : SDNode<"ARMISD::SMLALTB", SDT_LongMac, []>;
239 def ARMsmlaltt : SDNode<"ARMISD::SMLALTT", SDT_LongMac, []>;
241 def ARMqadd8b : SDNode<"ARMISD::QADD8b", SDT_ARMAnd, []>;
242 def ARMqsub8b : SDNode<"ARMISD::QSUB8b", SDT_ARMAnd, []>;
243 def ARMqadd16b : SDNode<"ARMISD::QADD16b", SDT_ARMAnd, []>;
244 def ARMqsub16b : SDNode<"ARMISD::QSUB16b", SDT_ARMAnd, []>;
246 // Vector operations shared between NEON and MVE
248 def ARMvdup : SDNode<"ARMISD::VDUP", SDTypeProfile<1, 1, [SDTCisVec<0>]>>;
250 // VDUPLANE can produce a quad-register result from a double-register source,
251 // so the result is not constrained to match the source.
252 def ARMvduplane : SDNode<"ARMISD::VDUPLANE",
253 SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisVec<1>,
256 def SDTARMVSHUF : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisSameAs<0, 1>]>;
257 def ARMvrev64 : SDNode<"ARMISD::VREV64", SDTARMVSHUF>;
258 def ARMvrev32 : SDNode<"ARMISD::VREV32", SDTARMVSHUF>;
259 def ARMvrev16 : SDNode<"ARMISD::VREV16", SDTARMVSHUF>;
261 def SDTARMVGETLN : SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisInt<1>,
263 def ARMvgetlaneu : SDNode<"ARMISD::VGETLANEu", SDTARMVGETLN>;
264 def ARMvgetlanes : SDNode<"ARMISD::VGETLANEs", SDTARMVGETLN>;
266 def SDTARMVMOVIMM : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisVT<1, i32>]>;
267 def ARMvmovImm : SDNode<"ARMISD::VMOVIMM", SDTARMVMOVIMM>;
268 def ARMvmvnImm : SDNode<"ARMISD::VMVNIMM", SDTARMVMOVIMM>;
269 def ARMvmovFPImm : SDNode<"ARMISD::VMOVFPIMM", SDTARMVMOVIMM>;
272 def SDTARMVSHIMM : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisSameAs<0, 1>,
274 def SDTARMVSH : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisSameAs<0, 1>,
275 SDTCisSameAs<0, 2>,]>;
276 def ARMvshlImm : SDNode<"ARMISD::VSHLIMM", SDTARMVSHIMM>;
277 def ARMvshrsImm : SDNode<"ARMISD::VSHRsIMM", SDTARMVSHIMM>;
278 def ARMvshruImm : SDNode<"ARMISD::VSHRuIMM", SDTARMVSHIMM>;
279 def ARMvshls : SDNode<"ARMISD::VSHLs", SDTARMVSH>;
280 def ARMvshlu : SDNode<"ARMISD::VSHLu", SDTARMVSH>;
282 def SDTARMVCMP : SDTypeProfile<1, 3, [SDTCisInt<0>, SDTCisSameAs<1, 2>,
284 def SDTARMVCMPZ : SDTypeProfile<1, 2, [SDTCisInt<2>]>;
286 def ARMvcmp : SDNode<"ARMISD::VCMP", SDTARMVCMP>;
287 def ARMvcmpz : SDNode<"ARMISD::VCMPZ", SDTARMVCMPZ>;
289 def ARMWLS : SDNode<"ARMISD::WLS", SDT_ARMLoLoop, [SDNPHasChain]>;
290 def ARMLE : SDNode<"ARMISD::LE", SDT_ARMLoLoop, [SDNPHasChain]>;
291 def ARMLoopDec : SDNode<"ARMISD::LOOP_DEC", SDTIntBinOp, [SDNPHasChain]>;
293 //===----------------------------------------------------------------------===//
294 // ARM Flag Definitions.
296 class RegConstraint<string C> {
297 string Constraints = C;
300 //===----------------------------------------------------------------------===//
301 // ARM specific transformation functions and pattern fragments.
304 // imm_neg_XFORM - Return the negation of an i32 immediate value.
305 def imm_neg_XFORM : SDNodeXForm<imm, [{
306 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), SDLoc(N), MVT::i32);
309 // imm_not_XFORM - Return the complement of a i32 immediate value.
310 def imm_not_XFORM : SDNodeXForm<imm, [{
311 return CurDAG->getTargetConstant(~(int)N->getZExtValue(), SDLoc(N), MVT::i32);
314 /// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
315 def imm16_31 : ImmLeaf<i32, [{
316 return (int32_t)Imm >= 16 && (int32_t)Imm < 32;
319 // sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
320 def sext_16_node : PatLeaf<(i32 GPR:$a), [{
321 return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17;
324 def sext_bottom_16 : PatFrag<(ops node:$a),
325 (sext_inreg node:$a, i16)>;
326 def sext_top_16 : PatFrag<(ops node:$a),
327 (i32 (sra node:$a, (i32 16)))>;
329 def bb_mul : PatFrag<(ops node:$a, node:$b),
330 (mul (sext_bottom_16 node:$a), (sext_bottom_16 node:$b))>;
331 def bt_mul : PatFrag<(ops node:$a, node:$b),
332 (mul (sext_bottom_16 node:$a), (sra node:$b, (i32 16)))>;
333 def tb_mul : PatFrag<(ops node:$a, node:$b),
334 (mul (sra node:$a, (i32 16)), (sext_bottom_16 node:$b))>;
335 def tt_mul : PatFrag<(ops node:$a, node:$b),
336 (mul (sra node:$a, (i32 16)), (sra node:$b, (i32 16)))>;
338 /// Split a 32-bit immediate into two 16 bit parts.
339 def hi16 : SDNodeXForm<imm, [{
340 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, SDLoc(N),
344 def lo16AllZero : PatLeaf<(i32 imm), [{
345 // Returns true if all low 16-bits are 0.
346 return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
349 class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
350 class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
352 // An 'and' node with a single use.
353 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
354 return N->hasOneUse();
357 // An 'xor' node with a single use.
358 def xor_su : PatFrag<(ops node:$lhs, node:$rhs), (xor node:$lhs, node:$rhs), [{
359 return N->hasOneUse();
362 // An 'fmul' node with a single use.
363 def fmul_su : PatFrag<(ops node:$lhs, node:$rhs), (fmul node:$lhs, node:$rhs),[{
364 return N->hasOneUse();
367 // An 'fadd' node which checks for single non-hazardous use.
368 def fadd_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fadd node:$lhs, node:$rhs),[{
369 return hasNoVMLxHazardUse(N);
372 // An 'fsub' node which checks for single non-hazardous use.
373 def fsub_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fsub node:$lhs, node:$rhs),[{
374 return hasNoVMLxHazardUse(N);
377 //===----------------------------------------------------------------------===//
378 // Operand Definitions.
381 // Immediate operands with a shared generic asm render method.
382 class ImmAsmOperand<int Low, int High> : AsmOperandClass {
383 let RenderMethod = "addImmOperands";
384 let PredicateMethod = "isImmediate<" # Low # "," # High # ">";
385 let DiagnosticString = "operand must be an immediate in the range [" # Low # "," # High # "]";
388 class ImmAsmOperandMinusOne<int Low, int High> : AsmOperandClass {
389 let PredicateMethod = "isImmediate<" # Low # "," # High # ">";
390 let DiagnosticType = "ImmRange" # Low # "_" # High;
391 let DiagnosticString = "operand must be an immediate in the range [" # Low # "," # High # "]";
394 // Operands that are part of a memory addressing mode.
395 class MemOperand : Operand<i32> { let OperandType = "OPERAND_MEMORY"; }
398 // FIXME: rename brtarget to t2_brtarget
399 def brtarget : Operand<OtherVT> {
400 let EncoderMethod = "getBranchTargetOpValue";
401 let OperandType = "OPERAND_PCREL";
402 let DecoderMethod = "DecodeT2BROperand";
405 // Branches targeting ARM-mode must be divisible by 4 if they're a raw
407 def ARMBranchTarget : AsmOperandClass {
408 let Name = "ARMBranchTarget";
411 // Branches targeting Thumb-mode must be divisible by 2 if they're a raw
413 def ThumbBranchTarget : AsmOperandClass {
414 let Name = "ThumbBranchTarget";
417 def arm_br_target : Operand<OtherVT> {
418 let ParserMatchClass = ARMBranchTarget;
419 let EncoderMethod = "getARMBranchTargetOpValue";
420 let OperandType = "OPERAND_PCREL";
423 // Call target for ARM. Handles conditional/unconditional
424 // FIXME: rename bl_target to t2_bltarget?
425 def arm_bl_target : Operand<i32> {
426 let ParserMatchClass = ARMBranchTarget;
427 let EncoderMethod = "getARMBLTargetOpValue";
428 let OperandType = "OPERAND_PCREL";
431 // Target for BLX *from* ARM mode.
432 def arm_blx_target : Operand<i32> {
433 let ParserMatchClass = ThumbBranchTarget;
434 let EncoderMethod = "getARMBLXTargetOpValue";
435 let OperandType = "OPERAND_PCREL";
438 // A list of registers separated by comma. Used by load/store multiple.
439 def RegListAsmOperand : AsmOperandClass { let Name = "RegList"; }
440 def reglist : Operand<i32> {
441 let EncoderMethod = "getRegisterListOpValue";
442 let ParserMatchClass = RegListAsmOperand;
443 let PrintMethod = "printRegisterList";
444 let DecoderMethod = "DecodeRegListOperand";
447 // A list of general purpose registers and APSR separated by comma.
449 def RegListWithAPSRAsmOperand : AsmOperandClass { let Name = "RegListWithAPSR"; }
450 def reglist_with_apsr : Operand<i32> {
451 let EncoderMethod = "getRegisterListOpValue";
452 let ParserMatchClass = RegListWithAPSRAsmOperand;
453 let PrintMethod = "printRegisterList";
454 let DecoderMethod = "DecodeRegListOperand";
457 def GPRPairOp : RegisterOperand<GPRPair, "printGPRPairOperand">;
459 def DPRRegListAsmOperand : AsmOperandClass {
460 let Name = "DPRRegList";
461 let DiagnosticType = "DPR_RegList";
463 def dpr_reglist : Operand<i32> {
464 let EncoderMethod = "getRegisterListOpValue";
465 let ParserMatchClass = DPRRegListAsmOperand;
466 let PrintMethod = "printRegisterList";
467 let DecoderMethod = "DecodeDPRRegListOperand";
470 def SPRRegListAsmOperand : AsmOperandClass {
471 let Name = "SPRRegList";
472 let DiagnosticString = "operand must be a list of registers in range [s0, s31]";
474 def spr_reglist : Operand<i32> {
475 let EncoderMethod = "getRegisterListOpValue";
476 let ParserMatchClass = SPRRegListAsmOperand;
477 let PrintMethod = "printRegisterList";
478 let DecoderMethod = "DecodeSPRRegListOperand";
481 def FPSRegListWithVPRAsmOperand : AsmOperandClass { let Name =
482 "FPSRegListWithVPR"; }
483 def fp_sreglist_with_vpr : Operand<i32> {
484 let EncoderMethod = "getRegisterListOpValue";
485 let ParserMatchClass = FPSRegListWithVPRAsmOperand;
486 let PrintMethod = "printRegisterList";
488 def FPDRegListWithVPRAsmOperand : AsmOperandClass { let Name =
489 "FPDRegListWithVPR"; }
490 def fp_dreglist_with_vpr : Operand<i32> {
491 let EncoderMethod = "getRegisterListOpValue";
492 let ParserMatchClass = FPDRegListWithVPRAsmOperand;
493 let PrintMethod = "printRegisterList";
496 // An operand for the CONSTPOOL_ENTRY pseudo-instruction.
497 def cpinst_operand : Operand<i32> {
498 let PrintMethod = "printCPInstOperand";
502 def pclabel : Operand<i32> {
503 let PrintMethod = "printPCLabel";
506 // ADR instruction labels.
507 def AdrLabelAsmOperand : AsmOperandClass { let Name = "AdrLabel"; }
508 def adrlabel : Operand<i32> {
509 let EncoderMethod = "getAdrLabelOpValue";
510 let ParserMatchClass = AdrLabelAsmOperand;
511 let PrintMethod = "printAdrLabelOperand<0>";
514 def neon_vcvt_imm32 : Operand<i32> {
515 let EncoderMethod = "getNEONVcvtImm32OpValue";
516 let DecoderMethod = "DecodeVCVTImmOperand";
519 // rot_imm: An integer that encodes a rotate amount. Must be 8, 16, or 24.
520 def rot_imm_XFORM: SDNodeXForm<imm, [{
521 switch (N->getZExtValue()){
522 default: llvm_unreachable(nullptr);
523 case 0: return CurDAG->getTargetConstant(0, SDLoc(N), MVT::i32);
524 case 8: return CurDAG->getTargetConstant(1, SDLoc(N), MVT::i32);
525 case 16: return CurDAG->getTargetConstant(2, SDLoc(N), MVT::i32);
526 case 24: return CurDAG->getTargetConstant(3, SDLoc(N), MVT::i32);
529 def RotImmAsmOperand : AsmOperandClass {
531 let ParserMethod = "parseRotImm";
533 def rot_imm : Operand<i32>, PatLeaf<(i32 imm), [{
534 int32_t v = N->getZExtValue();
535 return v == 8 || v == 16 || v == 24; }],
537 let PrintMethod = "printRotImmOperand";
538 let ParserMatchClass = RotImmAsmOperand;
541 // Power-of-two operand for MVE VIDUP and friends, which encode
542 // {1,2,4,8} as its log to base 2, i.e. as {0,1,2,3} respectively
543 def MVE_VIDUP_imm_asmoperand : AsmOperandClass {
544 let Name = "VIDUP_imm";
545 let PredicateMethod = "isPowerTwoInRange<1,8>";
546 let RenderMethod = "addPowerTwoOperands";
547 let DiagnosticString = "vector increment immediate must be 1, 2, 4 or 8";
549 def MVE_VIDUP_imm : Operand<i32> {
550 let EncoderMethod = "getPowerTwoOpValue";
551 let DecoderMethod = "DecodePowerTwoOperand<0,3>";
552 let ParserMatchClass = MVE_VIDUP_imm_asmoperand;
555 // Pair vector indexing
556 class MVEPairVectorIndexOperand<string start, string end> : AsmOperandClass {
557 let Name = "MVEPairVectorIndex"#start;
558 let RenderMethod = "addMVEPairVectorIndexOperands";
559 let PredicateMethod = "isMVEPairVectorIndex<"#start#", "#end#">";
562 class MVEPairVectorIndex<string opval> : Operand<i32> {
563 let PrintMethod = "printVectorIndex";
564 let EncoderMethod = "getMVEPairVectorIndexOpValue<"#opval#">";
565 let DecoderMethod = "DecodeMVEPairVectorIndexOperand<"#opval#">";
566 let MIOperandInfo = (ops i32imm);
569 def MVEPairVectorIndex0 : MVEPairVectorIndex<"0"> {
570 let ParserMatchClass = MVEPairVectorIndexOperand<"0", "1">;
573 def MVEPairVectorIndex2 : MVEPairVectorIndex<"2"> {
574 let ParserMatchClass = MVEPairVectorIndexOperand<"2", "3">;
578 class MVEVectorIndexOperand<int NumLanes> : AsmOperandClass {
579 let Name = "MVEVectorIndex"#NumLanes;
580 let RenderMethod = "addMVEVectorIndexOperands";
581 let PredicateMethod = "isVectorIndexInRange<"#NumLanes#">";
584 class MVEVectorIndex<int NumLanes> : Operand<i32> {
585 let PrintMethod = "printVectorIndex";
586 let ParserMatchClass = MVEVectorIndexOperand<NumLanes>;
587 let MIOperandInfo = (ops i32imm);
590 // shift_imm: An integer that encodes a shift amount and the type of shift
591 // (asr or lsl). The 6-bit immediate encodes as:
594 // {4-0} imm5 shift amount.
595 // asr #32 encoded as imm5 == 0.
596 def ShifterImmAsmOperand : AsmOperandClass {
597 let Name = "ShifterImm";
598 let ParserMethod = "parseShifterImm";
600 def shift_imm : Operand<i32> {
601 let PrintMethod = "printShiftImmOperand";
602 let ParserMatchClass = ShifterImmAsmOperand;
605 // shifter_operand operands: so_reg_reg, so_reg_imm, and mod_imm.
606 def ShiftedRegAsmOperand : AsmOperandClass { let Name = "RegShiftedReg"; }
607 def so_reg_reg : Operand<i32>, // reg reg imm
608 ComplexPattern<i32, 3, "SelectRegShifterOperand",
609 [shl, srl, sra, rotr]> {
610 let EncoderMethod = "getSORegRegOpValue";
611 let PrintMethod = "printSORegRegOperand";
612 let DecoderMethod = "DecodeSORegRegOperand";
613 let ParserMatchClass = ShiftedRegAsmOperand;
614 let MIOperandInfo = (ops GPRnopc, GPRnopc, i32imm);
617 def ShiftedImmAsmOperand : AsmOperandClass { let Name = "RegShiftedImm"; }
618 def so_reg_imm : Operand<i32>, // reg imm
619 ComplexPattern<i32, 2, "SelectImmShifterOperand",
620 [shl, srl, sra, rotr]> {
621 let EncoderMethod = "getSORegImmOpValue";
622 let PrintMethod = "printSORegImmOperand";
623 let DecoderMethod = "DecodeSORegImmOperand";
624 let ParserMatchClass = ShiftedImmAsmOperand;
625 let MIOperandInfo = (ops GPR, i32imm);
628 // FIXME: Does this need to be distinct from so_reg?
629 def shift_so_reg_reg : Operand<i32>, // reg reg imm
630 ComplexPattern<i32, 3, "SelectShiftRegShifterOperand",
631 [shl,srl,sra,rotr]> {
632 let EncoderMethod = "getSORegRegOpValue";
633 let PrintMethod = "printSORegRegOperand";
634 let DecoderMethod = "DecodeSORegRegOperand";
635 let ParserMatchClass = ShiftedRegAsmOperand;
636 let MIOperandInfo = (ops GPR, GPR, i32imm);
639 // FIXME: Does this need to be distinct from so_reg?
640 def shift_so_reg_imm : Operand<i32>, // reg reg imm
641 ComplexPattern<i32, 2, "SelectShiftImmShifterOperand",
642 [shl,srl,sra,rotr]> {
643 let EncoderMethod = "getSORegImmOpValue";
644 let PrintMethod = "printSORegImmOperand";
645 let DecoderMethod = "DecodeSORegImmOperand";
646 let ParserMatchClass = ShiftedImmAsmOperand;
647 let MIOperandInfo = (ops GPR, i32imm);
650 // mod_imm: match a 32-bit immediate operand, which can be encoded into
651 // a 12-bit immediate; an 8-bit integer and a 4-bit rotator (See ARMARM
652 // - "Modified Immediate Constants"). Within the MC layer we keep this
653 // immediate in its encoded form.
654 def ModImmAsmOperand: AsmOperandClass {
656 let ParserMethod = "parseModImm";
658 def mod_imm : Operand<i32>, ImmLeaf<i32, [{
659 return ARM_AM::getSOImmVal(Imm) != -1;
661 let EncoderMethod = "getModImmOpValue";
662 let PrintMethod = "printModImmOperand";
663 let ParserMatchClass = ModImmAsmOperand;
666 // Note: the patterns mod_imm_not and mod_imm_neg do not require an encoder
667 // method and such, as they are only used on aliases (Pat<> and InstAlias<>).
668 // The actual parsing, encoding, decoding are handled by the destination
669 // instructions, which use mod_imm.
671 def ModImmNotAsmOperand : AsmOperandClass { let Name = "ModImmNot"; }
672 def mod_imm_not : Operand<i32>, PatLeaf<(imm), [{
673 return ARM_AM::getSOImmVal(~(uint32_t)N->getZExtValue()) != -1;
675 let ParserMatchClass = ModImmNotAsmOperand;
678 def ModImmNegAsmOperand : AsmOperandClass { let Name = "ModImmNeg"; }
679 def mod_imm_neg : Operand<i32>, PatLeaf<(imm), [{
680 unsigned Value = -(unsigned)N->getZExtValue();
681 return Value && ARM_AM::getSOImmVal(Value) != -1;
683 let ParserMatchClass = ModImmNegAsmOperand;
686 /// arm_i32imm - True for +V6T2, or when isSOImmTwoParVal()
687 def arm_i32imm : IntImmLeaf<i32, [{
688 if (Subtarget->useMovt())
690 return ARM_AM::isSOImmTwoPartVal(Imm.getZExtValue());
693 /// imm0_1 predicate - Immediate in the range [0,1].
694 def Imm0_1AsmOperand: ImmAsmOperand<0,1> { let Name = "Imm0_1"; }
695 def imm0_1 : Operand<i32> { let ParserMatchClass = Imm0_1AsmOperand; }
697 /// imm0_3 predicate - Immediate in the range [0,3].
698 def Imm0_3AsmOperand: ImmAsmOperand<0,3> { let Name = "Imm0_3"; }
699 def imm0_3 : Operand<i32> { let ParserMatchClass = Imm0_3AsmOperand; }
701 /// imm0_7 predicate - Immediate in the range [0,7].
702 def Imm0_7AsmOperand: ImmAsmOperand<0,7> {
705 def imm0_7 : Operand<i32>, ImmLeaf<i32, [{
706 return Imm >= 0 && Imm < 8;
708 let ParserMatchClass = Imm0_7AsmOperand;
711 /// imm8_255 predicate - Immediate in the range [8,255].
712 def Imm8_255AsmOperand: ImmAsmOperand<8,255> { let Name = "Imm8_255"; }
713 def imm8_255 : Operand<i32>, ImmLeaf<i32, [{
714 return Imm >= 8 && Imm < 256;
716 let ParserMatchClass = Imm8_255AsmOperand;
719 /// imm8 predicate - Immediate is exactly 8.
720 def Imm8AsmOperand: ImmAsmOperand<8,8> { let Name = "Imm8"; }
721 def imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 8; }]> {
722 let ParserMatchClass = Imm8AsmOperand;
725 /// imm16 predicate - Immediate is exactly 16.
726 def Imm16AsmOperand: ImmAsmOperand<16,16> { let Name = "Imm16"; }
727 def imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 16; }]> {
728 let ParserMatchClass = Imm16AsmOperand;
731 /// imm32 predicate - Immediate is exactly 32.
732 def Imm32AsmOperand: ImmAsmOperand<32,32> { let Name = "Imm32"; }
733 def imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 32; }]> {
734 let ParserMatchClass = Imm32AsmOperand;
737 def imm8_or_16 : ImmLeaf<i32, [{ return Imm == 8 || Imm == 16;}]>;
739 /// imm1_7 predicate - Immediate in the range [1,7].
740 def Imm1_7AsmOperand: ImmAsmOperand<1,7> { let Name = "Imm1_7"; }
741 def imm1_7 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 8; }]> {
742 let ParserMatchClass = Imm1_7AsmOperand;
745 /// imm1_15 predicate - Immediate in the range [1,15].
746 def Imm1_15AsmOperand: ImmAsmOperand<1,15> { let Name = "Imm1_15"; }
747 def imm1_15 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 16; }]> {
748 let ParserMatchClass = Imm1_15AsmOperand;
751 /// imm1_31 predicate - Immediate in the range [1,31].
752 def Imm1_31AsmOperand: ImmAsmOperand<1,31> { let Name = "Imm1_31"; }
753 def imm1_31 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 32; }]> {
754 let ParserMatchClass = Imm1_31AsmOperand;
757 /// imm0_15 predicate - Immediate in the range [0,15].
758 def Imm0_15AsmOperand: ImmAsmOperand<0,15> {
759 let Name = "Imm0_15";
761 def imm0_15 : Operand<i32>, ImmLeaf<i32, [{
762 return Imm >= 0 && Imm < 16;
764 let ParserMatchClass = Imm0_15AsmOperand;
767 /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
768 def Imm0_31AsmOperand: ImmAsmOperand<0,31> { let Name = "Imm0_31"; }
769 def imm0_31 : Operand<i32>, ImmLeaf<i32, [{
770 return Imm >= 0 && Imm < 32;
772 let ParserMatchClass = Imm0_31AsmOperand;
775 /// imm0_32 predicate - True if the 32-bit immediate is in the range [0,32].
776 def Imm0_32AsmOperand: ImmAsmOperand<0,32> { let Name = "Imm0_32"; }
777 def imm0_32 : Operand<i32>, ImmLeaf<i32, [{
778 return Imm >= 0 && Imm < 33;
780 let ParserMatchClass = Imm0_32AsmOperand;
783 /// imm0_63 predicate - True if the 32-bit immediate is in the range [0,63].
784 def Imm0_63AsmOperand: ImmAsmOperand<0,63> { let Name = "Imm0_63"; }
785 def imm0_63 : Operand<i32>, ImmLeaf<i32, [{
786 return Imm >= 0 && Imm < 64;
788 let ParserMatchClass = Imm0_63AsmOperand;
791 /// imm0_239 predicate - Immediate in the range [0,239].
792 def Imm0_239AsmOperand : ImmAsmOperand<0,239> {
793 let Name = "Imm0_239";
795 def imm0_239 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 240; }]> {
796 let ParserMatchClass = Imm0_239AsmOperand;
799 /// imm0_255 predicate - Immediate in the range [0,255].
800 def Imm0_255AsmOperand : ImmAsmOperand<0,255> { let Name = "Imm0_255"; }
801 def imm0_255 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 256; }]> {
802 let ParserMatchClass = Imm0_255AsmOperand;
805 /// imm0_65535 - An immediate is in the range [0,65535].
806 def Imm0_65535AsmOperand: ImmAsmOperand<0,65535> { let Name = "Imm0_65535"; }
807 def imm0_65535 : Operand<i32>, ImmLeaf<i32, [{
808 return Imm >= 0 && Imm < 65536;
810 let ParserMatchClass = Imm0_65535AsmOperand;
813 // imm0_65535_neg - An immediate whose negative value is in the range [0.65535].
814 def imm0_65535_neg : Operand<i32>, ImmLeaf<i32, [{
815 return -Imm >= 0 && -Imm < 65536;
818 // imm0_65535_expr - For movt/movw - 16-bit immediate that can also reference
819 // a relocatable expression.
821 // FIXME: This really needs a Thumb version separate from the ARM version.
822 // While the range is the same, and can thus use the same match class,
823 // the encoding is different so it should have a different encoder method.
824 def Imm0_65535ExprAsmOperand: AsmOperandClass {
825 let Name = "Imm0_65535Expr";
826 let RenderMethod = "addImmOperands";
827 let DiagnosticString = "operand must be an immediate in the range [0,0xffff] or a relocatable expression";
830 def imm0_65535_expr : Operand<i32> {
831 let EncoderMethod = "getHiLo16ImmOpValue";
832 let ParserMatchClass = Imm0_65535ExprAsmOperand;
835 def Imm256_65535ExprAsmOperand: ImmAsmOperand<256,65535> { let Name = "Imm256_65535Expr"; }
836 def imm256_65535_expr : Operand<i32> {
837 let ParserMatchClass = Imm256_65535ExprAsmOperand;
840 /// imm24b - True if the 32-bit immediate is encodable in 24 bits.
841 def Imm24bitAsmOperand: ImmAsmOperand<0,0xffffff> {
842 let Name = "Imm24bit";
843 let DiagnosticString = "operand must be an immediate in the range [0,0xffffff]";
845 def imm24b : Operand<i32>, ImmLeaf<i32, [{
846 return Imm >= 0 && Imm <= 0xffffff;
848 let ParserMatchClass = Imm24bitAsmOperand;
852 /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
854 def BitfieldAsmOperand : AsmOperandClass {
855 let Name = "Bitfield";
856 let ParserMethod = "parseBitfield";
859 def bf_inv_mask_imm : Operand<i32>,
861 return ARM::isBitFieldInvertedMask(N->getZExtValue());
863 let EncoderMethod = "getBitfieldInvertedMaskOpValue";
864 let PrintMethod = "printBitfieldInvMaskImmOperand";
865 let DecoderMethod = "DecodeBitfieldMaskOperand";
866 let ParserMatchClass = BitfieldAsmOperand;
867 let GISelPredicateCode = [{
868 // There's better methods of implementing this check. IntImmLeaf<> would be
869 // equivalent and have less boilerplate but we need a test for C++
870 // predicates and this one causes new rules to be imported into GlobalISel
871 // without requiring additional features first.
872 const auto &MO = MI.getOperand(1);
875 return ARM::isBitFieldInvertedMask(MO.getCImm()->getZExtValue());
879 def imm1_32_XFORM: SDNodeXForm<imm, [{
880 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, SDLoc(N),
883 def Imm1_32AsmOperand: ImmAsmOperandMinusOne<1,32> {
884 let Name = "Imm1_32";
886 def imm1_32 : Operand<i32>, PatLeaf<(imm), [{
887 uint64_t Imm = N->getZExtValue();
888 return Imm > 0 && Imm <= 32;
891 let PrintMethod = "printImmPlusOneOperand";
892 let ParserMatchClass = Imm1_32AsmOperand;
895 def imm1_16_XFORM: SDNodeXForm<imm, [{
896 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, SDLoc(N),
899 def Imm1_16AsmOperand: ImmAsmOperandMinusOne<1,16> { let Name = "Imm1_16"; }
900 def imm1_16 : Operand<i32>, ImmLeaf<i32, [{
901 return Imm > 0 && Imm <= 16;
904 let PrintMethod = "printImmPlusOneOperand";
905 let ParserMatchClass = Imm1_16AsmOperand;
908 def MVEShiftImm1_7AsmOperand: ImmAsmOperand<1,7> {
909 let Name = "MVEShiftImm1_7";
910 // Reason we're doing this is because instruction vshll.s8 t1 encoding
911 // accepts 1,7 but the t2 encoding accepts 8. 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,8]";
916 def mve_shift_imm1_7 : Operand<i32> {
917 let ParserMatchClass = MVEShiftImm1_7AsmOperand;
918 let EncoderMethod = "getMVEShiftImmOpValue";
921 def MVEShiftImm1_15AsmOperand: ImmAsmOperand<1,15> {
922 let Name = "MVEShiftImm1_15";
923 // Reason we're doing this is because instruction vshll.s16 t1 encoding
924 // accepts 1,15 but the t2 encoding accepts 16. By doing this we can get a
925 // better diagnostic message if someone uses bigger immediate than the t1/t2
927 let DiagnosticString = "operand must be an immediate in the range [1,16]";
929 def mve_shift_imm1_15 : Operand<i32> {
930 let ParserMatchClass = MVEShiftImm1_15AsmOperand;
931 let EncoderMethod = "getMVEShiftImmOpValue";
934 // Define ARM specific addressing modes.
935 // addrmode_imm12 := reg +/- imm12
937 def MemImm12OffsetAsmOperand : AsmOperandClass { let Name = "MemImm12Offset"; }
938 class AddrMode_Imm12 : MemOperand,
939 ComplexPattern<i32, 2, "SelectAddrModeImm12", []> {
940 // 12-bit immediate operand. Note that instructions using this encode
941 // #0 and #-0 differently. We flag #-0 as the magic value INT32_MIN. All other
942 // immediate values are as normal.
944 let EncoderMethod = "getAddrModeImm12OpValue";
945 let DecoderMethod = "DecodeAddrModeImm12Operand";
946 let ParserMatchClass = MemImm12OffsetAsmOperand;
947 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
950 def addrmode_imm12 : AddrMode_Imm12 {
951 let PrintMethod = "printAddrModeImm12Operand<false>";
954 def addrmode_imm12_pre : AddrMode_Imm12 {
955 let PrintMethod = "printAddrModeImm12Operand<true>";
958 // ldst_so_reg := reg +/- reg shop imm
960 def MemRegOffsetAsmOperand : AsmOperandClass { let Name = "MemRegOffset"; }
961 def ldst_so_reg : MemOperand,
962 ComplexPattern<i32, 3, "SelectLdStSOReg", []> {
963 let EncoderMethod = "getLdStSORegOpValue";
964 // FIXME: Simplify the printer
965 let PrintMethod = "printAddrMode2Operand";
966 let DecoderMethod = "DecodeSORegMemOperand";
967 let ParserMatchClass = MemRegOffsetAsmOperand;
968 let MIOperandInfo = (ops GPR:$base, GPRnopc:$offsreg, i32imm:$shift);
971 // postidx_imm8 := +/- [0,255]
974 // {8} 1 is imm8 is non-negative. 0 otherwise.
975 // {7-0} [0,255] imm8 value.
976 def PostIdxImm8AsmOperand : AsmOperandClass { let Name = "PostIdxImm8"; }
977 def postidx_imm8 : MemOperand {
978 let PrintMethod = "printPostIdxImm8Operand";
979 let ParserMatchClass = PostIdxImm8AsmOperand;
980 let MIOperandInfo = (ops i32imm);
983 // postidx_imm8s4 := +/- [0,1020]
986 // {8} 1 is imm8 is non-negative. 0 otherwise.
987 // {7-0} [0,255] imm8 value, scaled by 4.
988 def PostIdxImm8s4AsmOperand : AsmOperandClass { let Name = "PostIdxImm8s4"; }
989 def postidx_imm8s4 : MemOperand {
990 let PrintMethod = "printPostIdxImm8s4Operand";
991 let ParserMatchClass = PostIdxImm8s4AsmOperand;
992 let MIOperandInfo = (ops i32imm);
996 // postidx_reg := +/- reg
998 def PostIdxRegAsmOperand : AsmOperandClass {
999 let Name = "PostIdxReg";
1000 let ParserMethod = "parsePostIdxReg";
1002 def postidx_reg : MemOperand {
1003 let EncoderMethod = "getPostIdxRegOpValue";
1004 let DecoderMethod = "DecodePostIdxReg";
1005 let PrintMethod = "printPostIdxRegOperand";
1006 let ParserMatchClass = PostIdxRegAsmOperand;
1007 let MIOperandInfo = (ops GPRnopc, i32imm);
1010 def PostIdxRegShiftedAsmOperand : AsmOperandClass {
1011 let Name = "PostIdxRegShifted";
1012 let ParserMethod = "parsePostIdxReg";
1014 def am2offset_reg : MemOperand,
1015 ComplexPattern<i32, 2, "SelectAddrMode2OffsetReg",
1016 [], [SDNPWantRoot]> {
1017 let EncoderMethod = "getAddrMode2OffsetOpValue";
1018 let PrintMethod = "printAddrMode2OffsetOperand";
1019 // When using this for assembly, it's always as a post-index offset.
1020 let ParserMatchClass = PostIdxRegShiftedAsmOperand;
1021 let MIOperandInfo = (ops GPRnopc, i32imm);
1024 // FIXME: am2offset_imm should only need the immediate, not the GPR. Having
1025 // the GPR is purely vestigal at this point.
1026 def AM2OffsetImmAsmOperand : AsmOperandClass { let Name = "AM2OffsetImm"; }
1027 def am2offset_imm : MemOperand,
1028 ComplexPattern<i32, 2, "SelectAddrMode2OffsetImm",
1029 [], [SDNPWantRoot]> {
1030 let EncoderMethod = "getAddrMode2OffsetOpValue";
1031 let PrintMethod = "printAddrMode2OffsetOperand";
1032 let ParserMatchClass = AM2OffsetImmAsmOperand;
1033 let MIOperandInfo = (ops GPRnopc, i32imm);
1037 // addrmode3 := reg +/- reg
1038 // addrmode3 := reg +/- imm8
1040 // FIXME: split into imm vs. reg versions.
1041 def AddrMode3AsmOperand : AsmOperandClass { let Name = "AddrMode3"; }
1042 class AddrMode3 : MemOperand,
1043 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
1044 let EncoderMethod = "getAddrMode3OpValue";
1045 let ParserMatchClass = AddrMode3AsmOperand;
1046 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
1049 def addrmode3 : AddrMode3
1051 let PrintMethod = "printAddrMode3Operand<false>";
1054 def addrmode3_pre : AddrMode3
1056 let PrintMethod = "printAddrMode3Operand<true>";
1059 // FIXME: split into imm vs. reg versions.
1060 // FIXME: parser method to handle +/- register.
1061 def AM3OffsetAsmOperand : AsmOperandClass {
1062 let Name = "AM3Offset";
1063 let ParserMethod = "parseAM3Offset";
1065 def am3offset : MemOperand,
1066 ComplexPattern<i32, 2, "SelectAddrMode3Offset",
1067 [], [SDNPWantRoot]> {
1068 let EncoderMethod = "getAddrMode3OffsetOpValue";
1069 let PrintMethod = "printAddrMode3OffsetOperand";
1070 let ParserMatchClass = AM3OffsetAsmOperand;
1071 let MIOperandInfo = (ops GPR, i32imm);
1074 // ldstm_mode := {ia, ib, da, db}
1076 def ldstm_mode : OptionalDefOperand<OtherVT, (ops i32), (ops (i32 1))> {
1077 let EncoderMethod = "getLdStmModeOpValue";
1078 let PrintMethod = "printLdStmModeOperand";
1081 // addrmode5 := reg +/- imm8*4
1083 def AddrMode5AsmOperand : AsmOperandClass { let Name = "AddrMode5"; }
1084 class AddrMode5 : MemOperand,
1085 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
1086 let EncoderMethod = "getAddrMode5OpValue";
1087 let DecoderMethod = "DecodeAddrMode5Operand";
1088 let ParserMatchClass = AddrMode5AsmOperand;
1089 let MIOperandInfo = (ops GPR:$base, i32imm);
1092 def addrmode5 : AddrMode5 {
1093 let PrintMethod = "printAddrMode5Operand<false>";
1096 def addrmode5_pre : AddrMode5 {
1097 let PrintMethod = "printAddrMode5Operand<true>";
1100 // addrmode5fp16 := reg +/- imm8*2
1102 def AddrMode5FP16AsmOperand : AsmOperandClass { let Name = "AddrMode5FP16"; }
1103 class AddrMode5FP16 : Operand<i32>,
1104 ComplexPattern<i32, 2, "SelectAddrMode5FP16", []> {
1105 let EncoderMethod = "getAddrMode5FP16OpValue";
1106 let DecoderMethod = "DecodeAddrMode5FP16Operand";
1107 let ParserMatchClass = AddrMode5FP16AsmOperand;
1108 let MIOperandInfo = (ops GPR:$base, i32imm);
1111 def addrmode5fp16 : AddrMode5FP16 {
1112 let PrintMethod = "printAddrMode5FP16Operand<false>";
1115 // addrmode6 := reg with optional alignment
1117 def AddrMode6AsmOperand : AsmOperandClass { let Name = "AlignedMemory"; }
1118 def addrmode6 : MemOperand,
1119 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1120 let PrintMethod = "printAddrMode6Operand";
1121 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
1122 let EncoderMethod = "getAddrMode6AddressOpValue";
1123 let DecoderMethod = "DecodeAddrMode6Operand";
1124 let ParserMatchClass = AddrMode6AsmOperand;
1127 def am6offset : MemOperand,
1128 ComplexPattern<i32, 1, "SelectAddrMode6Offset",
1129 [], [SDNPWantRoot]> {
1130 let PrintMethod = "printAddrMode6OffsetOperand";
1131 let MIOperandInfo = (ops GPR);
1132 let EncoderMethod = "getAddrMode6OffsetOpValue";
1133 let DecoderMethod = "DecodeGPRRegisterClass";
1136 // Special version of addrmode6 to handle alignment encoding for VST1/VLD1
1137 // (single element from one lane) for size 32.
1138 def addrmode6oneL32 : MemOperand,
1139 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1140 let PrintMethod = "printAddrMode6Operand";
1141 let MIOperandInfo = (ops GPR:$addr, i32imm);
1142 let EncoderMethod = "getAddrMode6OneLane32AddressOpValue";
1145 // Base class for addrmode6 with specific alignment restrictions.
1146 class AddrMode6Align : MemOperand,
1147 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1148 let PrintMethod = "printAddrMode6Operand";
1149 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
1150 let EncoderMethod = "getAddrMode6AddressOpValue";
1151 let DecoderMethod = "DecodeAddrMode6Operand";
1154 // Special version of addrmode6 to handle no allowed alignment encoding for
1155 // VLD/VST instructions and checking the alignment is not specified.
1156 def AddrMode6AlignNoneAsmOperand : AsmOperandClass {
1157 let Name = "AlignedMemoryNone";
1158 let DiagnosticString = "alignment must be omitted";
1160 def addrmode6alignNone : AddrMode6Align {
1161 // The alignment specifier can only be omitted.
1162 let ParserMatchClass = AddrMode6AlignNoneAsmOperand;
1165 // Special version of addrmode6 to handle 16-bit alignment encoding for
1166 // VLD/VST instructions and checking the alignment value.
1167 def AddrMode6Align16AsmOperand : AsmOperandClass {
1168 let Name = "AlignedMemory16";
1169 let DiagnosticString = "alignment must be 16 or omitted";
1171 def addrmode6align16 : AddrMode6Align {
1172 // The alignment specifier can only be 16 or omitted.
1173 let ParserMatchClass = AddrMode6Align16AsmOperand;
1176 // Special version of addrmode6 to handle 32-bit alignment encoding for
1177 // VLD/VST instructions and checking the alignment value.
1178 def AddrMode6Align32AsmOperand : AsmOperandClass {
1179 let Name = "AlignedMemory32";
1180 let DiagnosticString = "alignment must be 32 or omitted";
1182 def addrmode6align32 : AddrMode6Align {
1183 // The alignment specifier can only be 32 or omitted.
1184 let ParserMatchClass = AddrMode6Align32AsmOperand;
1187 // Special version of addrmode6 to handle 64-bit alignment encoding for
1188 // VLD/VST instructions and checking the alignment value.
1189 def AddrMode6Align64AsmOperand : AsmOperandClass {
1190 let Name = "AlignedMemory64";
1191 let DiagnosticString = "alignment must be 64 or omitted";
1193 def addrmode6align64 : AddrMode6Align {
1194 // The alignment specifier can only be 64 or omitted.
1195 let ParserMatchClass = AddrMode6Align64AsmOperand;
1198 // Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding
1199 // for VLD/VST instructions and checking the alignment value.
1200 def AddrMode6Align64or128AsmOperand : AsmOperandClass {
1201 let Name = "AlignedMemory64or128";
1202 let DiagnosticString = "alignment must be 64, 128 or omitted";
1204 def addrmode6align64or128 : AddrMode6Align {
1205 // The alignment specifier can only be 64, 128 or omitted.
1206 let ParserMatchClass = AddrMode6Align64or128AsmOperand;
1209 // Special version of addrmode6 to handle 64-bit, 128-bit or 256-bit alignment
1210 // encoding for VLD/VST instructions and checking the alignment value.
1211 def AddrMode6Align64or128or256AsmOperand : AsmOperandClass {
1212 let Name = "AlignedMemory64or128or256";
1213 let DiagnosticString = "alignment must be 64, 128, 256 or omitted";
1215 def addrmode6align64or128or256 : AddrMode6Align {
1216 // The alignment specifier can only be 64, 128, 256 or omitted.
1217 let ParserMatchClass = AddrMode6Align64or128or256AsmOperand;
1220 // Special version of addrmode6 to handle alignment encoding for VLD-dup
1221 // instructions, specifically VLD4-dup.
1222 def addrmode6dup : MemOperand,
1223 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1224 let PrintMethod = "printAddrMode6Operand";
1225 let MIOperandInfo = (ops GPR:$addr, i32imm);
1226 let EncoderMethod = "getAddrMode6DupAddressOpValue";
1227 // FIXME: This is close, but not quite right. The alignment specifier is
1229 let ParserMatchClass = AddrMode6AsmOperand;
1232 // Base class for addrmode6dup with specific alignment restrictions.
1233 class AddrMode6DupAlign : MemOperand,
1234 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1235 let PrintMethod = "printAddrMode6Operand";
1236 let MIOperandInfo = (ops GPR:$addr, i32imm);
1237 let EncoderMethod = "getAddrMode6DupAddressOpValue";
1240 // Special version of addrmode6 to handle no allowed alignment encoding for
1241 // VLD-dup instruction and checking the alignment is not specified.
1242 def AddrMode6dupAlignNoneAsmOperand : AsmOperandClass {
1243 let Name = "DupAlignedMemoryNone";
1244 let DiagnosticString = "alignment must be omitted";
1246 def addrmode6dupalignNone : AddrMode6DupAlign {
1247 // The alignment specifier can only be omitted.
1248 let ParserMatchClass = AddrMode6dupAlignNoneAsmOperand;
1251 // Special version of addrmode6 to handle 16-bit alignment encoding for VLD-dup
1252 // instruction and checking the alignment value.
1253 def AddrMode6dupAlign16AsmOperand : AsmOperandClass {
1254 let Name = "DupAlignedMemory16";
1255 let DiagnosticString = "alignment must be 16 or omitted";
1257 def addrmode6dupalign16 : AddrMode6DupAlign {
1258 // The alignment specifier can only be 16 or omitted.
1259 let ParserMatchClass = AddrMode6dupAlign16AsmOperand;
1262 // Special version of addrmode6 to handle 32-bit alignment encoding for VLD-dup
1263 // instruction and checking the alignment value.
1264 def AddrMode6dupAlign32AsmOperand : AsmOperandClass {
1265 let Name = "DupAlignedMemory32";
1266 let DiagnosticString = "alignment must be 32 or omitted";
1268 def addrmode6dupalign32 : AddrMode6DupAlign {
1269 // The alignment specifier can only be 32 or omitted.
1270 let ParserMatchClass = AddrMode6dupAlign32AsmOperand;
1273 // Special version of addrmode6 to handle 64-bit alignment encoding for VLD
1274 // instructions and checking the alignment value.
1275 def AddrMode6dupAlign64AsmOperand : AsmOperandClass {
1276 let Name = "DupAlignedMemory64";
1277 let DiagnosticString = "alignment must be 64 or omitted";
1279 def addrmode6dupalign64 : AddrMode6DupAlign {
1280 // The alignment specifier can only be 64 or omitted.
1281 let ParserMatchClass = AddrMode6dupAlign64AsmOperand;
1284 // Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding
1285 // for VLD instructions and checking the alignment value.
1286 def AddrMode6dupAlign64or128AsmOperand : AsmOperandClass {
1287 let Name = "DupAlignedMemory64or128";
1288 let DiagnosticString = "alignment must be 64, 128 or omitted";
1290 def addrmode6dupalign64or128 : AddrMode6DupAlign {
1291 // The alignment specifier can only be 64, 128 or omitted.
1292 let ParserMatchClass = AddrMode6dupAlign64or128AsmOperand;
1295 // addrmodepc := pc + reg
1297 def addrmodepc : MemOperand,
1298 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
1299 let PrintMethod = "printAddrModePCOperand";
1300 let MIOperandInfo = (ops GPR, i32imm);
1303 // addr_offset_none := reg
1305 def MemNoOffsetAsmOperand : AsmOperandClass { let Name = "MemNoOffset"; }
1306 def addr_offset_none : MemOperand,
1307 ComplexPattern<i32, 1, "SelectAddrOffsetNone", []> {
1308 let PrintMethod = "printAddrMode7Operand";
1309 let DecoderMethod = "DecodeAddrMode7Operand";
1310 let ParserMatchClass = MemNoOffsetAsmOperand;
1311 let MIOperandInfo = (ops GPR:$base);
1314 // t_addr_offset_none := reg [r0-r7]
1315 def MemNoOffsetTAsmOperand : AsmOperandClass { let Name = "MemNoOffsetT"; }
1316 def t_addr_offset_none : MemOperand {
1317 let PrintMethod = "printAddrMode7Operand";
1318 let DecoderMethod = "DecodetGPRRegisterClass";
1319 let ParserMatchClass = MemNoOffsetTAsmOperand;
1320 let MIOperandInfo = (ops tGPR:$base);
1323 def nohash_imm : Operand<i32> {
1324 let PrintMethod = "printNoHashImmediate";
1327 def CoprocNumAsmOperand : AsmOperandClass {
1328 let Name = "CoprocNum";
1329 let ParserMethod = "parseCoprocNumOperand";
1331 def p_imm : Operand<i32> {
1332 let PrintMethod = "printPImmediate";
1333 let ParserMatchClass = CoprocNumAsmOperand;
1334 let DecoderMethod = "DecodeCoprocessor";
1337 def CoprocRegAsmOperand : AsmOperandClass {
1338 let Name = "CoprocReg";
1339 let ParserMethod = "parseCoprocRegOperand";
1341 def c_imm : Operand<i32> {
1342 let PrintMethod = "printCImmediate";
1343 let ParserMatchClass = CoprocRegAsmOperand;
1345 def CoprocOptionAsmOperand : AsmOperandClass {
1346 let Name = "CoprocOption";
1347 let ParserMethod = "parseCoprocOptionOperand";
1349 def coproc_option_imm : Operand<i32> {
1350 let PrintMethod = "printCoprocOptionImm";
1351 let ParserMatchClass = CoprocOptionAsmOperand;
1354 //===----------------------------------------------------------------------===//
1356 include "ARMInstrFormats.td"
1358 //===----------------------------------------------------------------------===//
1359 // Multiclass helpers...
1362 /// AsI1_bin_irs - Defines a set of (op r, {mod_imm|r|so_reg}) patterns for a
1363 /// binop that produces a value.
1364 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1365 multiclass AsI1_bin_irs<bits<4> opcod, string opc,
1366 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1367 SDPatternOperator opnode, bit Commutable = 0> {
1368 // The register-immediate version is re-materializable. This is useful
1369 // in particular for taking the address of a local.
1370 let isReMaterializable = 1 in {
1371 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm,
1372 iii, opc, "\t$Rd, $Rn, $imm",
1373 [(set GPR:$Rd, (opnode GPR:$Rn, mod_imm:$imm))]>,
1374 Sched<[WriteALU, ReadALU]> {
1379 let Inst{19-16} = Rn;
1380 let Inst{15-12} = Rd;
1381 let Inst{11-0} = imm;
1384 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1385 iir, opc, "\t$Rd, $Rn, $Rm",
1386 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]>,
1387 Sched<[WriteALU, ReadALU, ReadALU]> {
1392 let isCommutable = Commutable;
1393 let Inst{19-16} = Rn;
1394 let Inst{15-12} = Rd;
1395 let Inst{11-4} = 0b00000000;
1399 def rsi : AsI1<opcod, (outs GPR:$Rd),
1400 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1401 iis, opc, "\t$Rd, $Rn, $shift",
1402 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_imm:$shift))]>,
1403 Sched<[WriteALUsi, ReadALU]> {
1408 let Inst{19-16} = Rn;
1409 let Inst{15-12} = Rd;
1410 let Inst{11-5} = shift{11-5};
1412 let Inst{3-0} = shift{3-0};
1415 def rsr : AsI1<opcod, (outs GPR:$Rd),
1416 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1417 iis, opc, "\t$Rd, $Rn, $shift",
1418 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_reg:$shift))]>,
1419 Sched<[WriteALUsr, ReadALUsr]> {
1424 let Inst{19-16} = Rn;
1425 let Inst{15-12} = Rd;
1426 let Inst{11-8} = shift{11-8};
1428 let Inst{6-5} = shift{6-5};
1430 let Inst{3-0} = shift{3-0};
1434 /// AsI1_rbin_irs - Same as AsI1_bin_irs except the order of operands are
1435 /// reversed. The 'rr' form is only defined for the disassembler; for codegen
1436 /// it is equivalent to the AsI1_bin_irs counterpart.
1437 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1438 multiclass AsI1_rbin_irs<bits<4> opcod, string opc,
1439 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1440 SDNode opnode, bit Commutable = 0> {
1441 // The register-immediate version is re-materializable. This is useful
1442 // in particular for taking the address of a local.
1443 let isReMaterializable = 1 in {
1444 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm,
1445 iii, opc, "\t$Rd, $Rn, $imm",
1446 [(set GPR:$Rd, (opnode mod_imm:$imm, GPR:$Rn))]>,
1447 Sched<[WriteALU, ReadALU]> {
1452 let Inst{19-16} = Rn;
1453 let Inst{15-12} = Rd;
1454 let Inst{11-0} = imm;
1457 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1458 iir, opc, "\t$Rd, $Rn, $Rm",
1459 [/* pattern left blank */]>,
1460 Sched<[WriteALU, ReadALU, ReadALU]> {
1464 let Inst{11-4} = 0b00000000;
1467 let Inst{15-12} = Rd;
1468 let Inst{19-16} = Rn;
1471 def rsi : AsI1<opcod, (outs GPR:$Rd),
1472 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1473 iis, opc, "\t$Rd, $Rn, $shift",
1474 [(set GPR:$Rd, (opnode so_reg_imm:$shift, GPR:$Rn))]>,
1475 Sched<[WriteALUsi, ReadALU]> {
1480 let Inst{19-16} = Rn;
1481 let Inst{15-12} = Rd;
1482 let Inst{11-5} = shift{11-5};
1484 let Inst{3-0} = shift{3-0};
1487 def rsr : AsI1<opcod, (outs GPR:$Rd),
1488 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1489 iis, opc, "\t$Rd, $Rn, $shift",
1490 [(set GPR:$Rd, (opnode so_reg_reg:$shift, GPR:$Rn))]>,
1491 Sched<[WriteALUsr, ReadALUsr]> {
1496 let Inst{19-16} = Rn;
1497 let Inst{15-12} = Rd;
1498 let Inst{11-8} = shift{11-8};
1500 let Inst{6-5} = shift{6-5};
1502 let Inst{3-0} = shift{3-0};
1506 /// AsI1_bin_s_irs - Same as AsI1_bin_irs except it sets the 's' bit by default.
1508 /// These opcodes will be converted to the real non-S opcodes by
1509 /// AdjustInstrPostInstrSelection after giving them an optional CPSR operand.
1510 let hasPostISelHook = 1, Defs = [CPSR] in {
1511 multiclass AsI1_bin_s_irs<InstrItinClass iii, InstrItinClass iir,
1512 InstrItinClass iis, SDNode opnode,
1513 bit Commutable = 0> {
1514 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p),
1516 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm))]>,
1517 Sched<[WriteALU, ReadALU]>;
1519 def rr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, pred:$p),
1521 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm))]>,
1522 Sched<[WriteALU, ReadALU, ReadALU]> {
1523 let isCommutable = Commutable;
1525 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1526 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1528 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1529 so_reg_imm:$shift))]>,
1530 Sched<[WriteALUsi, ReadALU]>;
1532 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1533 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1535 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1536 so_reg_reg:$shift))]>,
1537 Sched<[WriteALUSsr, ReadALUsr]>;
1541 /// AsI1_rbin_s_is - Same as AsI1_bin_s_irs, except selection DAG
1542 /// operands are reversed.
1543 let hasPostISelHook = 1, Defs = [CPSR] in {
1544 multiclass AsI1_rbin_s_is<InstrItinClass iii, InstrItinClass iir,
1545 InstrItinClass iis, SDNode opnode,
1546 bit Commutable = 0> {
1547 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p),
1549 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn))]>,
1550 Sched<[WriteALU, ReadALU]>;
1552 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1553 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1555 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift,
1557 Sched<[WriteALUsi, ReadALU]>;
1559 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1560 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1562 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift,
1564 Sched<[WriteALUSsr, ReadALUsr]>;
1568 /// AI1_cmp_irs - Defines a set of (op r, {mod_imm|r|so_reg}) cmp / test
1569 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
1570 /// a explicit result, only implicitly set CPSR.
1571 let isCompare = 1, Defs = [CPSR] in {
1572 multiclass AI1_cmp_irs<bits<4> opcod, string opc,
1573 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1574 SDPatternOperator opnode, bit Commutable = 0,
1575 string rrDecoderMethod = ""> {
1576 def ri : AI1<opcod, (outs), (ins GPR:$Rn, mod_imm:$imm), DPFrm, iii,
1578 [(opnode GPR:$Rn, mod_imm:$imm)]>,
1579 Sched<[WriteCMP, ReadALU]> {
1584 let Inst{19-16} = Rn;
1585 let Inst{15-12} = 0b0000;
1586 let Inst{11-0} = imm;
1588 let Unpredictable{15-12} = 0b1111;
1590 def rr : AI1<opcod, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, iir,
1592 [(opnode GPR:$Rn, GPR:$Rm)]>,
1593 Sched<[WriteCMP, ReadALU, ReadALU]> {
1596 let isCommutable = Commutable;
1599 let Inst{19-16} = Rn;
1600 let Inst{15-12} = 0b0000;
1601 let Inst{11-4} = 0b00000000;
1603 let DecoderMethod = rrDecoderMethod;
1605 let Unpredictable{15-12} = 0b1111;
1607 def rsi : AI1<opcod, (outs),
1608 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, iis,
1609 opc, "\t$Rn, $shift",
1610 [(opnode GPR:$Rn, so_reg_imm:$shift)]>,
1611 Sched<[WriteCMPsi, ReadALU]> {
1616 let Inst{19-16} = Rn;
1617 let Inst{15-12} = 0b0000;
1618 let Inst{11-5} = shift{11-5};
1620 let Inst{3-0} = shift{3-0};
1622 let Unpredictable{15-12} = 0b1111;
1624 def rsr : AI1<opcod, (outs),
1625 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, iis,
1626 opc, "\t$Rn, $shift",
1627 [(opnode GPRnopc:$Rn, so_reg_reg:$shift)]>,
1628 Sched<[WriteCMPsr, ReadALU]> {
1633 let Inst{19-16} = Rn;
1634 let Inst{15-12} = 0b0000;
1635 let Inst{11-8} = shift{11-8};
1637 let Inst{6-5} = shift{6-5};
1639 let Inst{3-0} = shift{3-0};
1641 let Unpredictable{15-12} = 0b1111;
1647 /// AI_ext_rrot - A unary operation with two forms: one whose operand is a
1648 /// register and one whose operand is a register rotated by 8/16/24.
1649 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
1650 class AI_ext_rrot<bits<8> opcod, string opc, PatFrag opnode>
1651 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1652 IIC_iEXTr, opc, "\t$Rd, $Rm$rot",
1653 [(set GPRnopc:$Rd, (opnode (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1654 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> {
1658 let Inst{19-16} = 0b1111;
1659 let Inst{15-12} = Rd;
1660 let Inst{11-10} = rot;
1664 class AI_ext_rrot_np<bits<8> opcod, string opc>
1665 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1666 IIC_iEXTr, opc, "\t$Rd, $Rm$rot", []>,
1667 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> {
1669 let Inst{19-16} = 0b1111;
1670 let Inst{11-10} = rot;
1673 /// AI_exta_rrot - A binary operation with two forms: one whose operand is a
1674 /// register and one whose operand is a register rotated by 8/16/24.
1675 class AI_exta_rrot<bits<8> opcod, string opc, PatFrag opnode>
1676 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1677 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot",
1678 [(set GPRnopc:$Rd, (opnode GPR:$Rn,
1679 (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1680 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> {
1685 let Inst{19-16} = Rn;
1686 let Inst{15-12} = Rd;
1687 let Inst{11-10} = rot;
1688 let Inst{9-4} = 0b000111;
1692 class AI_exta_rrot_np<bits<8> opcod, string opc>
1693 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1694 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot", []>,
1695 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> {
1698 let Inst{19-16} = Rn;
1699 let Inst{11-10} = rot;
1702 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
1703 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1704 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, SDNode opnode,
1705 bit Commutable = 0> {
1706 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1707 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm),
1708 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1709 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm, CPSR))]>,
1711 Sched<[WriteALU, ReadALU]> {
1716 let Inst{15-12} = Rd;
1717 let Inst{19-16} = Rn;
1718 let Inst{11-0} = imm;
1720 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1721 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1722 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm, CPSR))]>,
1724 Sched<[WriteALU, ReadALU, ReadALU]> {
1728 let Inst{11-4} = 0b00000000;
1730 let isCommutable = Commutable;
1732 let Inst{15-12} = Rd;
1733 let Inst{19-16} = Rn;
1735 def rsi : AsI1<opcod, (outs GPR:$Rd),
1736 (ins GPR:$Rn, so_reg_imm:$shift),
1737 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1738 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_imm:$shift, CPSR))]>,
1740 Sched<[WriteALUsi, ReadALU]> {
1745 let Inst{19-16} = Rn;
1746 let Inst{15-12} = Rd;
1747 let Inst{11-5} = shift{11-5};
1749 let Inst{3-0} = shift{3-0};
1751 def rsr : AsI1<opcod, (outs GPRnopc:$Rd),
1752 (ins GPRnopc:$Rn, so_reg_reg:$shift),
1753 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1754 [(set GPRnopc:$Rd, CPSR,
1755 (opnode GPRnopc:$Rn, so_reg_reg:$shift, CPSR))]>,
1757 Sched<[WriteALUsr, ReadALUsr]> {
1762 let Inst{19-16} = Rn;
1763 let Inst{15-12} = Rd;
1764 let Inst{11-8} = shift{11-8};
1766 let Inst{6-5} = shift{6-5};
1768 let Inst{3-0} = shift{3-0};
1773 /// AI1_rsc_irs - Define instructions and patterns for rsc
1774 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1775 multiclass AI1_rsc_irs<bits<4> opcod, string opc, SDNode opnode> {
1776 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1777 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm),
1778 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1779 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn, CPSR))]>,
1781 Sched<[WriteALU, ReadALU]> {
1786 let Inst{15-12} = Rd;
1787 let Inst{19-16} = Rn;
1788 let Inst{11-0} = imm;
1790 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1791 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1792 [/* pattern left blank */]>,
1793 Sched<[WriteALU, ReadALU, ReadALU]> {
1797 let Inst{11-4} = 0b00000000;
1800 let Inst{15-12} = Rd;
1801 let Inst{19-16} = Rn;
1803 def rsi : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_imm:$shift),
1804 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1805 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift, GPR:$Rn, CPSR))]>,
1807 Sched<[WriteALUsi, ReadALU]> {
1812 let Inst{19-16} = Rn;
1813 let Inst{15-12} = Rd;
1814 let Inst{11-5} = shift{11-5};
1816 let Inst{3-0} = shift{3-0};
1818 def rsr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_reg:$shift),
1819 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1820 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift, GPR:$Rn, CPSR))]>,
1822 Sched<[WriteALUsr, ReadALUsr]> {
1827 let Inst{19-16} = Rn;
1828 let Inst{15-12} = Rd;
1829 let Inst{11-8} = shift{11-8};
1831 let Inst{6-5} = shift{6-5};
1833 let Inst{3-0} = shift{3-0};
1838 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1839 multiclass AI_ldr1<bit isByte, string opc, InstrItinClass iii,
1840 InstrItinClass iir, PatFrag opnode> {
1841 // Note: We use the complex addrmode_imm12 rather than just an input
1842 // GPR and a constrained immediate so that we can use this to match
1843 // frame index references and avoid matching constant pool references.
1844 def i12: AI2ldst<0b010, 1, isByte, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
1845 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1846 [(set GPR:$Rt, (opnode addrmode_imm12:$addr))]> {
1849 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1850 let Inst{19-16} = addr{16-13}; // Rn
1851 let Inst{15-12} = Rt;
1852 let Inst{11-0} = addr{11-0}; // imm12
1854 def rs : AI2ldst<0b011, 1, isByte, (outs GPR:$Rt), (ins ldst_so_reg:$shift),
1855 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1856 [(set GPR:$Rt, (opnode ldst_so_reg:$shift))]> {
1859 let shift{4} = 0; // Inst{4} = 0
1860 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1861 let Inst{19-16} = shift{16-13}; // Rn
1862 let Inst{15-12} = Rt;
1863 let Inst{11-0} = shift{11-0};
1868 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1869 multiclass AI_ldr1nopc<bit isByte, string opc, InstrItinClass iii,
1870 InstrItinClass iir, PatFrag opnode> {
1871 // Note: We use the complex addrmode_imm12 rather than just an input
1872 // GPR and a constrained immediate so that we can use this to match
1873 // frame index references and avoid matching constant pool references.
1874 def i12: AI2ldst<0b010, 1, isByte, (outs GPRnopc:$Rt),
1875 (ins addrmode_imm12:$addr),
1876 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1877 [(set GPRnopc:$Rt, (opnode addrmode_imm12:$addr))]> {
1880 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1881 let Inst{19-16} = addr{16-13}; // Rn
1882 let Inst{15-12} = Rt;
1883 let Inst{11-0} = addr{11-0}; // imm12
1885 def rs : AI2ldst<0b011, 1, isByte, (outs GPRnopc:$Rt),
1886 (ins ldst_so_reg:$shift),
1887 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1888 [(set GPRnopc:$Rt, (opnode ldst_so_reg:$shift))]> {
1891 let shift{4} = 0; // Inst{4} = 0
1892 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1893 let Inst{19-16} = shift{16-13}; // Rn
1894 let Inst{15-12} = Rt;
1895 let Inst{11-0} = shift{11-0};
1901 multiclass AI_str1<bit isByte, string opc, InstrItinClass iii,
1902 InstrItinClass iir, PatFrag opnode> {
1903 // Note: We use the complex addrmode_imm12 rather than just an input
1904 // GPR and a constrained immediate so that we can use this to match
1905 // frame index references and avoid matching constant pool references.
1906 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1907 (ins GPR:$Rt, addrmode_imm12:$addr),
1908 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1909 [(opnode GPR:$Rt, addrmode_imm12:$addr)]> {
1912 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1913 let Inst{19-16} = addr{16-13}; // Rn
1914 let Inst{15-12} = Rt;
1915 let Inst{11-0} = addr{11-0}; // imm12
1917 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPR:$Rt, ldst_so_reg:$shift),
1918 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1919 [(opnode GPR:$Rt, ldst_so_reg:$shift)]> {
1922 let shift{4} = 0; // Inst{4} = 0
1923 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1924 let Inst{19-16} = shift{16-13}; // Rn
1925 let Inst{15-12} = Rt;
1926 let Inst{11-0} = shift{11-0};
1930 multiclass AI_str1nopc<bit isByte, string opc, InstrItinClass iii,
1931 InstrItinClass iir, PatFrag opnode> {
1932 // Note: We use the complex addrmode_imm12 rather than just an input
1933 // GPR and a constrained immediate so that we can use this to match
1934 // frame index references and avoid matching constant pool references.
1935 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1936 (ins GPRnopc:$Rt, addrmode_imm12:$addr),
1937 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1938 [(opnode GPRnopc:$Rt, addrmode_imm12:$addr)]> {
1941 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1942 let Inst{19-16} = addr{16-13}; // Rn
1943 let Inst{15-12} = Rt;
1944 let Inst{11-0} = addr{11-0}; // imm12
1946 def rs : AI2ldst<0b011, 0, isByte, (outs),
1947 (ins GPRnopc:$Rt, ldst_so_reg:$shift),
1948 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1949 [(opnode GPRnopc:$Rt, ldst_so_reg:$shift)]> {
1952 let shift{4} = 0; // Inst{4} = 0
1953 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1954 let Inst{19-16} = shift{16-13}; // Rn
1955 let Inst{15-12} = Rt;
1956 let Inst{11-0} = shift{11-0};
1961 //===----------------------------------------------------------------------===//
1963 //===----------------------------------------------------------------------===//
1965 //===----------------------------------------------------------------------===//
1966 // Miscellaneous Instructions.
1969 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
1970 /// the function. The first operand is the ID# for this instruction, the second
1971 /// is the index into the MachineConstantPool that this is, the third is the
1972 /// size in bytes of this constant pool entry.
1973 let hasSideEffects = 0, isNotDuplicable = 1, hasNoSchedulingInfo = 1 in
1974 def CONSTPOOL_ENTRY :
1975 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1976 i32imm:$size), NoItinerary, []>;
1978 /// A jumptable consisting of direct 32-bit addresses of the destination basic
1979 /// blocks (either absolute, or relative to the start of the jump-table in PIC
1980 /// mode). Used mostly in ARM and Thumb-1 modes.
1981 def JUMPTABLE_ADDRS :
1982 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1983 i32imm:$size), NoItinerary, []>;
1985 /// A jumptable consisting of 32-bit jump instructions. Used for Thumb-2 tables
1986 /// that cannot be optimised to use TBB or TBH.
1987 def JUMPTABLE_INSTS :
1988 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1989 i32imm:$size), NoItinerary, []>;
1991 /// A jumptable consisting of 8-bit unsigned integers representing offsets from
1992 /// a TBB instruction.
1994 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1995 i32imm:$size), NoItinerary, []>;
1997 /// A jumptable consisting of 16-bit unsigned integers representing offsets from
1998 /// a TBH instruction.
2000 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
2001 i32imm:$size), NoItinerary, []>;
2004 // FIXME: Marking these as hasSideEffects is necessary to prevent machine DCE
2005 // from removing one half of the matched pairs. That breaks PEI, which assumes
2006 // these will always be in pairs, and asserts if it finds otherwise. Better way?
2007 let Defs = [SP], Uses = [SP], hasSideEffects = 1 in {
2008 def ADJCALLSTACKUP :
2009 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary,
2010 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
2012 def ADJCALLSTACKDOWN :
2013 PseudoInst<(outs), (ins i32imm:$amt, i32imm:$amt2, pred:$p), NoItinerary,
2014 [(ARMcallseq_start timm:$amt, timm:$amt2)]>;
2017 def HINT : AI<(outs), (ins imm0_239:$imm), MiscFrm, NoItinerary,
2018 "hint", "\t$imm", [(int_arm_hint imm0_239:$imm)]>,
2019 Requires<[IsARM, HasV6]> {
2021 let Inst{27-8} = 0b00110010000011110000;
2022 let Inst{7-0} = imm;
2023 let DecoderMethod = "DecodeHINTInstruction";
2026 def : InstAlias<"nop$p", (HINT 0, pred:$p)>, Requires<[IsARM, HasV6K]>;
2027 def : InstAlias<"yield$p", (HINT 1, pred:$p)>, Requires<[IsARM, HasV6K]>;
2028 def : InstAlias<"wfe$p", (HINT 2, pred:$p)>, Requires<[IsARM, HasV6K]>;
2029 def : InstAlias<"wfi$p", (HINT 3, pred:$p)>, Requires<[IsARM, HasV6K]>;
2030 def : InstAlias<"sev$p", (HINT 4, pred:$p)>, Requires<[IsARM, HasV6K]>;
2031 def : InstAlias<"sevl$p", (HINT 5, pred:$p)>, Requires<[IsARM, HasV8]>;
2032 def : InstAlias<"esb$p", (HINT 16, pred:$p)>, Requires<[IsARM, HasRAS]>;
2033 def : InstAlias<"csdb$p", (HINT 20, pred:$p)>, Requires<[IsARM, HasV6K]>;
2035 def SEL : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, NoItinerary, "sel",
2037 [(set GPR:$Rd, (int_arm_sel GPR:$Rn, GPR:$Rm))]>,
2038 Requires<[IsARM, HasV6]> {
2043 let Inst{15-12} = Rd;
2044 let Inst{19-16} = Rn;
2045 let Inst{27-20} = 0b01101000;
2046 let Inst{7-4} = 0b1011;
2047 let Inst{11-8} = 0b1111;
2048 let Unpredictable{11-8} = 0b1111;
2051 // The 16-bit operand $val can be used by a debugger to store more information
2052 // about the breakpoint.
2053 def BKPT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
2054 "bkpt", "\t$val", []>, Requires<[IsARM]> {
2056 let Inst{3-0} = val{3-0};
2057 let Inst{19-8} = val{15-4};
2058 let Inst{27-20} = 0b00010010;
2059 let Inst{31-28} = 0xe; // AL
2060 let Inst{7-4} = 0b0111;
2062 // default immediate for breakpoint mnemonic
2063 def : InstAlias<"bkpt", (BKPT 0), 0>, Requires<[IsARM]>;
2065 def HLT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
2066 "hlt", "\t$val", []>, Requires<[IsARM, HasV8]> {
2068 let Inst{3-0} = val{3-0};
2069 let Inst{19-8} = val{15-4};
2070 let Inst{27-20} = 0b00010000;
2071 let Inst{31-28} = 0xe; // AL
2072 let Inst{7-4} = 0b0111;
2075 // Change Processor State
2076 // FIXME: We should use InstAlias to handle the optional operands.
2077 class CPS<dag iops, string asm_ops>
2078 : AXI<(outs), iops, MiscFrm, NoItinerary, !strconcat("cps", asm_ops),
2079 []>, Requires<[IsARM]> {
2085 let Inst{31-28} = 0b1111;
2086 let Inst{27-20} = 0b00010000;
2087 let Inst{19-18} = imod;
2088 let Inst{17} = M; // Enabled if mode is set;
2089 let Inst{16-9} = 0b00000000;
2090 let Inst{8-6} = iflags;
2092 let Inst{4-0} = mode;
2095 let DecoderMethod = "DecodeCPSInstruction" in {
2097 def CPS3p : CPS<(ins imod_op:$imod, iflags_op:$iflags, imm0_31:$mode),
2098 "$imod\t$iflags, $mode">;
2099 let mode = 0, M = 0 in
2100 def CPS2p : CPS<(ins imod_op:$imod, iflags_op:$iflags), "$imod\t$iflags">;
2102 let imod = 0, iflags = 0, M = 1 in
2103 def CPS1p : CPS<(ins imm0_31:$mode), "\t$mode">;
2106 // Preload signals the memory system of possible future data/instruction access.
2107 multiclass APreLoad<bits<1> read, bits<1> data, string opc> {
2109 def i12 : AXIM<(outs), (ins addrmode_imm12:$addr), AddrMode_i12, MiscFrm,
2110 IIC_Preload, !strconcat(opc, "\t$addr"),
2111 [(ARMPreload addrmode_imm12:$addr, (i32 read), (i32 data))]>,
2112 Sched<[WritePreLd]> {
2115 let Inst{31-26} = 0b111101;
2116 let Inst{25} = 0; // 0 for immediate form
2117 let Inst{24} = data;
2118 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2119 let Inst{22} = read;
2120 let Inst{21-20} = 0b01;
2121 let Inst{19-16} = addr{16-13}; // Rn
2122 let Inst{15-12} = 0b1111;
2123 let Inst{11-0} = addr{11-0}; // imm12
2126 def rs : AXI<(outs), (ins ldst_so_reg:$shift), MiscFrm, IIC_Preload,
2127 !strconcat(opc, "\t$shift"),
2128 [(ARMPreload ldst_so_reg:$shift, (i32 read), (i32 data))]>,
2129 Sched<[WritePreLd]> {
2131 let Inst{31-26} = 0b111101;
2132 let Inst{25} = 1; // 1 for register form
2133 let Inst{24} = data;
2134 let Inst{23} = shift{12}; // U (add = ('U' == 1))
2135 let Inst{22} = read;
2136 let Inst{21-20} = 0b01;
2137 let Inst{19-16} = shift{16-13}; // Rn
2138 let Inst{15-12} = 0b1111;
2139 let Inst{11-0} = shift{11-0};
2144 defm PLD : APreLoad<1, 1, "pld">, Requires<[IsARM]>;
2145 defm PLDW : APreLoad<0, 1, "pldw">, Requires<[IsARM,HasV7,HasMP]>;
2146 defm PLI : APreLoad<1, 0, "pli">, Requires<[IsARM,HasV7]>;
2148 def SETEND : AXI<(outs), (ins setend_op:$end), MiscFrm, NoItinerary,
2149 "setend\t$end", []>, Requires<[IsARM]>, Deprecated<HasV8Ops> {
2151 let Inst{31-10} = 0b1111000100000001000000;
2156 def DBG : AI<(outs), (ins imm0_15:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt",
2157 [(int_arm_dbg imm0_15:$opt)]>, Requires<[IsARM, HasV7]> {
2159 let Inst{27-4} = 0b001100100000111100001111;
2160 let Inst{3-0} = opt;
2163 // A8.8.247 UDF - Undefined (Encoding A1)
2164 def UDF : AInoP<(outs), (ins imm0_65535:$imm16), MiscFrm, NoItinerary,
2165 "udf", "\t$imm16", [(int_arm_undefined imm0_65535:$imm16)]> {
2167 let Inst{31-28} = 0b1110; // AL
2168 let Inst{27-25} = 0b011;
2169 let Inst{24-20} = 0b11111;
2170 let Inst{19-8} = imm16{15-4};
2171 let Inst{7-4} = 0b1111;
2172 let Inst{3-0} = imm16{3-0};
2176 * A5.4 Permanently UNDEFINED instructions.
2178 * For most targets use UDF #65006, for which the OS will generate SIGTRAP.
2179 * Other UDF encodings generate SIGILL.
2181 * NaCl's OS instead chooses an ARM UDF encoding that's also a UDF in Thumb.
2183 * 1110 0111 1111 iiii iiii iiii 1111 iiii
2185 * 1101 1110 iiii iiii
2186 * It uses the following encoding:
2187 * 1110 0111 1111 1110 1101 1110 1111 0000
2188 * - In ARM: UDF #60896;
2189 * - In Thumb: UDF #254 followed by a branch-to-self.
2191 let isBarrier = 1, isTerminator = 1 in
2192 def TRAPNaCl : AXI<(outs), (ins), MiscFrm, NoItinerary,
2194 Requires<[IsARM,UseNaClTrap]> {
2195 let Inst = 0xe7fedef0;
2197 let isBarrier = 1, isTerminator = 1 in
2198 def TRAP : AXI<(outs), (ins), MiscFrm, NoItinerary,
2200 Requires<[IsARM,DontUseNaClTrap]> {
2201 let Inst = 0xe7ffdefe;
2204 def : Pat<(debugtrap), (BKPT 0)>, Requires<[IsARM, HasV5T]>;
2205 def : Pat<(debugtrap), (UDF 254)>, Requires<[IsARM, NoV5T]>;
2207 // Address computation and loads and stores in PIC mode.
2208 let isNotDuplicable = 1 in {
2209 def PICADD : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
2211 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>,
2212 Sched<[WriteALU, ReadALU]>;
2214 let AddedComplexity = 10 in {
2215 def PICLDR : ARMPseudoInst<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
2217 [(set GPR:$dst, (load addrmodepc:$addr))]>;
2219 def PICLDRH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2221 [(set GPR:$Rt, (zextloadi16 addrmodepc:$addr))]>;
2223 def PICLDRB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2225 [(set GPR:$Rt, (zextloadi8 addrmodepc:$addr))]>;
2227 def PICLDRSH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2229 [(set GPR:$Rt, (sextloadi16 addrmodepc:$addr))]>;
2231 def PICLDRSB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2233 [(set GPR:$Rt, (sextloadi8 addrmodepc:$addr))]>;
2235 let AddedComplexity = 10 in {
2236 def PICSTR : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2237 4, IIC_iStore_r, [(store GPR:$src, addrmodepc:$addr)]>;
2239 def PICSTRH : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2240 4, IIC_iStore_bh_r, [(truncstorei16 GPR:$src,
2241 addrmodepc:$addr)]>;
2243 def PICSTRB : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2244 4, IIC_iStore_bh_r, [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
2246 } // isNotDuplicable = 1
2249 // LEApcrel - Load a pc-relative address into a register without offending the
2251 let hasSideEffects = 0, isReMaterializable = 1 in
2252 // The 'adr' mnemonic encodes differently if the label is before or after
2253 // the instruction. The {24-21} opcode bits are set by the fixup, as we don't
2254 // know until then which form of the instruction will be used.
2255 def ADR : AI1<{0,?,?,0}, (outs GPR:$Rd), (ins adrlabel:$label),
2256 MiscFrm, IIC_iALUi, "adr", "\t$Rd, $label", []>,
2257 Sched<[WriteALU, ReadALU]> {
2260 let Inst{27-25} = 0b001;
2262 let Inst{23-22} = label{13-12};
2265 let Inst{19-16} = 0b1111;
2266 let Inst{15-12} = Rd;
2267 let Inst{11-0} = label{11-0};
2270 let hasSideEffects = 1 in {
2271 def LEApcrel : ARMPseudoInst<(outs GPR:$Rd), (ins i32imm:$label, pred:$p),
2272 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
2274 def LEApcrelJT : ARMPseudoInst<(outs GPR:$Rd),
2275 (ins i32imm:$label, pred:$p),
2276 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
2279 //===----------------------------------------------------------------------===//
2280 // Control Flow Instructions.
2283 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
2285 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
2286 "bx", "\tlr", [(ARMretflag)]>,
2287 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2288 let Inst{27-0} = 0b0001001011111111111100011110;
2292 def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br,
2293 "mov", "\tpc, lr", [(ARMretflag)]>,
2294 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]> {
2295 let Inst{27-0} = 0b0001101000001111000000001110;
2298 // Exception return: N.b. doesn't set CPSR as far as we're concerned (it sets
2299 // the user-space one).
2300 def SUBS_PC_LR : ARMPseudoInst<(outs), (ins i32imm:$offset, pred:$p),
2302 [(ARMintretflag imm:$offset)]>;
2305 // Indirect branches
2306 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
2308 def BX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
2309 [(brind GPR:$dst)]>,
2310 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2312 let Inst{31-4} = 0b1110000100101111111111110001;
2313 let Inst{3-0} = dst;
2316 def BX_pred : AI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br,
2317 "bx", "\t$dst", [/* pattern left blank */]>,
2318 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2320 let Inst{27-4} = 0b000100101111111111110001;
2321 let Inst{3-0} = dst;
2325 // SP is marked as a use to prevent stack-pointer assignments that appear
2326 // immediately before calls from potentially appearing dead.
2328 // FIXME: Do we really need a non-predicated version? If so, it should
2329 // at least be a pseudo instruction expanding to the predicated version
2330 // at MC lowering time.
2331 Defs = [LR], Uses = [SP] in {
2332 def BL : ABXI<0b1011, (outs), (ins arm_bl_target:$func),
2333 IIC_Br, "bl\t$func",
2334 [(ARMcall tglobaladdr:$func)]>,
2335 Requires<[IsARM]>, Sched<[WriteBrL]> {
2336 let Inst{31-28} = 0b1110;
2338 let Inst{23-0} = func;
2339 let DecoderMethod = "DecodeBranchImmInstruction";
2342 def BL_pred : ABI<0b1011, (outs), (ins arm_bl_target:$func),
2343 IIC_Br, "bl", "\t$func",
2344 [(ARMcall_pred tglobaladdr:$func)]>,
2345 Requires<[IsARM]>, Sched<[WriteBrL]> {
2347 let Inst{23-0} = func;
2348 let DecoderMethod = "DecodeBranchImmInstruction";
2352 def BLX : AXI<(outs), (ins GPR:$func), BrMiscFrm,
2353 IIC_Br, "blx\t$func",
2354 [(ARMcall GPR:$func)]>,
2355 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2357 let Inst{31-4} = 0b1110000100101111111111110011;
2358 let Inst{3-0} = func;
2361 def BLX_pred : AI<(outs), (ins GPR:$func), BrMiscFrm,
2362 IIC_Br, "blx", "\t$func",
2363 [(ARMcall_pred GPR:$func)]>,
2364 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2366 let Inst{27-4} = 0b000100101111111111110011;
2367 let Inst{3-0} = func;
2371 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
2372 def BX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
2373 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
2374 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]>;
2377 def BMOVPCRX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
2378 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
2379 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
2381 // mov lr, pc; b if callee is marked noreturn to avoid confusing the
2382 // return stack predictor.
2383 def BMOVPCB_CALL : ARMPseudoInst<(outs), (ins arm_bl_target:$func),
2384 8, IIC_Br, [(ARMcall_nolink tglobaladdr:$func)]>,
2385 Requires<[IsARM]>, Sched<[WriteBr]>;
2387 // push lr before the call
2388 def BL_PUSHLR : ARMPseudoInst<(outs), (ins GPRlr:$ra, arm_bl_target:$func),
2391 Requires<[IsARM]>, Sched<[WriteBr]>;
2394 let isBranch = 1, isTerminator = 1 in {
2395 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
2396 // a two-value operand where a dag node expects two operands. :(
2397 def Bcc : ABI<0b1010, (outs), (ins arm_br_target:$target),
2398 IIC_Br, "b", "\t$target",
2399 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>,
2402 let Inst{23-0} = target;
2403 let DecoderMethod = "DecodeBranchImmInstruction";
2406 let isBarrier = 1 in {
2407 // B is "predicable" since it's just a Bcc with an 'always' condition.
2408 let isPredicable = 1 in
2409 // FIXME: We shouldn't need this pseudo at all. Just using Bcc directly
2410 // should be sufficient.
2411 // FIXME: Is B really a Barrier? That doesn't seem right.
2412 def B : ARMPseudoExpand<(outs), (ins arm_br_target:$target), 4, IIC_Br,
2413 [(br bb:$target)], (Bcc arm_br_target:$target,
2414 (ops 14, zero_reg))>,
2417 let Size = 4, isNotDuplicable = 1, isIndirectBranch = 1 in {
2418 def BR_JTr : ARMPseudoInst<(outs),
2419 (ins GPR:$target, i32imm:$jt),
2421 [(ARMbrjt GPR:$target, tjumptable:$jt)]>,
2423 def BR_JTm_i12 : ARMPseudoInst<(outs),
2424 (ins addrmode_imm12:$target, i32imm:$jt),
2426 [(ARMbrjt (i32 (load addrmode_imm12:$target)),
2427 tjumptable:$jt)]>, Sched<[WriteBrTbl]>;
2428 def BR_JTm_rs : ARMPseudoInst<(outs),
2429 (ins ldst_so_reg:$target, i32imm:$jt),
2431 [(ARMbrjt (i32 (load ldst_so_reg:$target)),
2432 tjumptable:$jt)]>, Sched<[WriteBrTbl]>;
2433 def BR_JTadd : ARMPseudoInst<(outs),
2434 (ins GPR:$target, GPR:$idx, i32imm:$jt),
2436 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt)]>,
2437 Sched<[WriteBrTbl]>;
2438 } // isNotDuplicable = 1, isIndirectBranch = 1
2444 def BLXi : AXI<(outs), (ins arm_blx_target:$target), BrMiscFrm, NoItinerary,
2445 "blx\t$target", []>,
2446 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2447 let Inst{31-25} = 0b1111101;
2449 let Inst{23-0} = target{24-1};
2450 let Inst{24} = target{0};
2454 // Branch and Exchange Jazelle
2455 def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func",
2456 [/* pattern left blank */]>, Sched<[WriteBr]> {
2458 let Inst{23-20} = 0b0010;
2459 let Inst{19-8} = 0xfff;
2460 let Inst{7-4} = 0b0010;
2461 let Inst{3-0} = func;
2467 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in {
2468 def TCRETURNdi : PseudoInst<(outs), (ins i32imm:$dst), IIC_Br, []>,
2471 def TCRETURNri : PseudoInst<(outs), (ins tcGPR:$dst), IIC_Br, []>,
2474 def TAILJMPd : ARMPseudoExpand<(outs), (ins arm_br_target:$dst),
2476 (Bcc arm_br_target:$dst, (ops 14, zero_reg))>,
2477 Requires<[IsARM]>, Sched<[WriteBr]>;
2479 def TAILJMPr : ARMPseudoExpand<(outs), (ins tcGPR:$dst),
2481 (BX GPR:$dst)>, Sched<[WriteBr]>,
2482 Requires<[IsARM, HasV4T]>;
2485 // Secure Monitor Call is a system instruction.
2486 def SMC : ABI<0b0001, (outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt",
2487 []>, Requires<[IsARM, HasTrustZone]> {
2489 let Inst{23-4} = 0b01100000000000000111;
2490 let Inst{3-0} = opt;
2492 def : MnemonicAlias<"smi", "smc">;
2494 // Supervisor Call (Software Interrupt)
2495 let isCall = 1, Uses = [SP] in {
2496 def SVC : ABI<0b1111, (outs), (ins imm24b:$svc), IIC_Br, "svc", "\t$svc", []>,
2499 let Inst{23-0} = svc;
2503 // Store Return State
2504 class SRSI<bit wb, string asm>
2505 : XI<(outs), (ins imm0_31:$mode), AddrModeNone, 4, IndexModeNone, BrFrm,
2506 NoItinerary, asm, "", []> {
2508 let Inst{31-28} = 0b1111;
2509 let Inst{27-25} = 0b100;
2513 let Inst{19-16} = 0b1101; // SP
2514 let Inst{15-5} = 0b00000101000;
2515 let Inst{4-0} = mode;
2518 def SRSDA : SRSI<0, "srsda\tsp, $mode"> {
2519 let Inst{24-23} = 0;
2521 def SRSDA_UPD : SRSI<1, "srsda\tsp!, $mode"> {
2522 let Inst{24-23} = 0;
2524 def SRSDB : SRSI<0, "srsdb\tsp, $mode"> {
2525 let Inst{24-23} = 0b10;
2527 def SRSDB_UPD : SRSI<1, "srsdb\tsp!, $mode"> {
2528 let Inst{24-23} = 0b10;
2530 def SRSIA : SRSI<0, "srsia\tsp, $mode"> {
2531 let Inst{24-23} = 0b01;
2533 def SRSIA_UPD : SRSI<1, "srsia\tsp!, $mode"> {
2534 let Inst{24-23} = 0b01;
2536 def SRSIB : SRSI<0, "srsib\tsp, $mode"> {
2537 let Inst{24-23} = 0b11;
2539 def SRSIB_UPD : SRSI<1, "srsib\tsp!, $mode"> {
2540 let Inst{24-23} = 0b11;
2543 def : ARMInstAlias<"srsda $mode", (SRSDA imm0_31:$mode)>;
2544 def : ARMInstAlias<"srsda $mode!", (SRSDA_UPD imm0_31:$mode)>;
2546 def : ARMInstAlias<"srsdb $mode", (SRSDB imm0_31:$mode)>;
2547 def : ARMInstAlias<"srsdb $mode!", (SRSDB_UPD imm0_31:$mode)>;
2549 def : ARMInstAlias<"srsia $mode", (SRSIA imm0_31:$mode)>;
2550 def : ARMInstAlias<"srsia $mode!", (SRSIA_UPD imm0_31:$mode)>;
2552 def : ARMInstAlias<"srsib $mode", (SRSIB imm0_31:$mode)>;
2553 def : ARMInstAlias<"srsib $mode!", (SRSIB_UPD imm0_31:$mode)>;
2555 // Return From Exception
2556 class RFEI<bit wb, string asm>
2557 : XI<(outs), (ins GPR:$Rn), AddrModeNone, 4, IndexModeNone, BrFrm,
2558 NoItinerary, asm, "", []> {
2560 let Inst{31-28} = 0b1111;
2561 let Inst{27-25} = 0b100;
2565 let Inst{19-16} = Rn;
2566 let Inst{15-0} = 0xa00;
2569 def RFEDA : RFEI<0, "rfeda\t$Rn"> {
2570 let Inst{24-23} = 0;
2572 def RFEDA_UPD : RFEI<1, "rfeda\t$Rn!"> {
2573 let Inst{24-23} = 0;
2575 def RFEDB : RFEI<0, "rfedb\t$Rn"> {
2576 let Inst{24-23} = 0b10;
2578 def RFEDB_UPD : RFEI<1, "rfedb\t$Rn!"> {
2579 let Inst{24-23} = 0b10;
2581 def RFEIA : RFEI<0, "rfeia\t$Rn"> {
2582 let Inst{24-23} = 0b01;
2584 def RFEIA_UPD : RFEI<1, "rfeia\t$Rn!"> {
2585 let Inst{24-23} = 0b01;
2587 def RFEIB : RFEI<0, "rfeib\t$Rn"> {
2588 let Inst{24-23} = 0b11;
2590 def RFEIB_UPD : RFEI<1, "rfeib\t$Rn!"> {
2591 let Inst{24-23} = 0b11;
2594 // Hypervisor Call is a system instruction
2596 def HVC : AInoP< (outs), (ins imm0_65535:$imm), BrFrm, NoItinerary,
2597 "hvc", "\t$imm", []>,
2598 Requires<[IsARM, HasVirtualization]> {
2601 // Even though HVC isn't predicable, it's encoding includes a condition field.
2602 // The instruction is undefined if the condition field is 0xf otherwise it is
2603 // unpredictable if it isn't condition AL (0xe).
2604 let Inst{31-28} = 0b1110;
2605 let Unpredictable{31-28} = 0b1111;
2606 let Inst{27-24} = 0b0001;
2607 let Inst{23-20} = 0b0100;
2608 let Inst{19-8} = imm{15-4};
2609 let Inst{7-4} = 0b0111;
2610 let Inst{3-0} = imm{3-0};
2614 // Return from exception in Hypervisor mode.
2615 let isReturn = 1, isBarrier = 1, isTerminator = 1, Defs = [PC] in
2616 def ERET : ABI<0b0001, (outs), (ins), NoItinerary, "eret", "", []>,
2617 Requires<[IsARM, HasVirtualization]> {
2618 let Inst{23-0} = 0b011000000000000001101110;
2621 //===----------------------------------------------------------------------===//
2622 // Load / Store Instructions.
2628 defm LDR : AI_ldr1<0, "ldr", IIC_iLoad_r, IIC_iLoad_si, load>;
2629 defm LDRB : AI_ldr1nopc<1, "ldrb", IIC_iLoad_bh_r, IIC_iLoad_bh_si,
2631 defm STR : AI_str1<0, "str", IIC_iStore_r, IIC_iStore_si, store>;
2632 defm STRB : AI_str1nopc<1, "strb", IIC_iStore_bh_r, IIC_iStore_bh_si,
2635 // Special LDR for loads from non-pc-relative constpools.
2636 let canFoldAsLoad = 1, mayLoad = 1, hasSideEffects = 0,
2637 isReMaterializable = 1, isCodeGenOnly = 1 in
2638 def LDRcp : AI2ldst<0b010, 1, 0, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
2639 AddrMode_i12, LdFrm, IIC_iLoad_r, "ldr", "\t$Rt, $addr",
2643 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2644 let Inst{19-16} = 0b1111;
2645 let Inst{15-12} = Rt;
2646 let Inst{11-0} = addr{11-0}; // imm12
2649 // Loads with zero extension
2650 def LDRH : AI3ld<0b1011, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2651 IIC_iLoad_bh_r, "ldrh", "\t$Rt, $addr",
2652 [(set GPR:$Rt, (zextloadi16 addrmode3:$addr))]>;
2654 // Loads with sign extension
2655 def LDRSH : AI3ld<0b1111, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2656 IIC_iLoad_bh_r, "ldrsh", "\t$Rt, $addr",
2657 [(set GPR:$Rt, (sextloadi16 addrmode3:$addr))]>;
2659 def LDRSB : AI3ld<0b1101, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2660 IIC_iLoad_bh_r, "ldrsb", "\t$Rt, $addr",
2661 [(set GPR:$Rt, (sextloadi8 addrmode3:$addr))]>;
2663 let mayLoad = 1, hasSideEffects = 0, hasExtraDefRegAllocReq = 1 in {
2665 def LDRD : AI3ld<0b1101, 0, (outs GPR:$Rt, GPR:$Rt2), (ins addrmode3:$addr),
2666 LdMiscFrm, IIC_iLoad_d_r, "ldrd", "\t$Rt, $Rt2, $addr", []>,
2667 Requires<[IsARM, HasV5TE]>;
2670 def LDA : AIldracq<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2671 NoItinerary, "lda", "\t$Rt, $addr", []>;
2672 def LDAB : AIldracq<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2673 NoItinerary, "ldab", "\t$Rt, $addr", []>;
2674 def LDAH : AIldracq<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2675 NoItinerary, "ldah", "\t$Rt, $addr", []>;
2678 multiclass AI2_ldridx<bit isByte, string opc,
2679 InstrItinClass iii, InstrItinClass iir> {
2680 def _PRE_IMM : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2681 (ins addrmode_imm12_pre:$addr), IndexModePre, LdFrm, iii,
2682 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2685 let Inst{23} = addr{12};
2686 let Inst{19-16} = addr{16-13};
2687 let Inst{11-0} = addr{11-0};
2688 let DecoderMethod = "DecodeLDRPreImm";
2691 def _PRE_REG : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2692 (ins ldst_so_reg:$addr), IndexModePre, LdFrm, iir,
2693 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2696 let Inst{23} = addr{12};
2697 let Inst{19-16} = addr{16-13};
2698 let Inst{11-0} = addr{11-0};
2700 let DecoderMethod = "DecodeLDRPreReg";
2703 def _POST_REG : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2704 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2705 IndexModePost, LdFrm, iir,
2706 opc, "\t$Rt, $addr, $offset",
2707 "$addr.base = $Rn_wb", []> {
2713 let Inst{23} = offset{12};
2714 let Inst{19-16} = addr;
2715 let Inst{11-0} = offset{11-0};
2718 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2721 def _POST_IMM : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2722 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2723 IndexModePost, LdFrm, iii,
2724 opc, "\t$Rt, $addr, $offset",
2725 "$addr.base = $Rn_wb", []> {
2731 let Inst{23} = offset{12};
2732 let Inst{19-16} = addr;
2733 let Inst{11-0} = offset{11-0};
2735 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2740 let mayLoad = 1, hasSideEffects = 0 in {
2741 // FIXME: for LDR_PRE_REG etc. the itineray should be either IIC_iLoad_ru or
2742 // IIC_iLoad_siu depending on whether it the offset register is shifted.
2743 defm LDR : AI2_ldridx<0, "ldr", IIC_iLoad_iu, IIC_iLoad_ru>;
2744 defm LDRB : AI2_ldridx<1, "ldrb", IIC_iLoad_bh_iu, IIC_iLoad_bh_ru>;
2747 multiclass AI3_ldridx<bits<4> op, string opc, InstrItinClass itin> {
2748 def _PRE : AI3ldstidx<op, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2749 (ins addrmode3_pre:$addr), IndexModePre,
2751 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2753 let Inst{23} = addr{8}; // U bit
2754 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2755 let Inst{19-16} = addr{12-9}; // Rn
2756 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2757 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2758 let DecoderMethod = "DecodeAddrMode3Instruction";
2760 def _POST : AI3ldstidx<op, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2761 (ins addr_offset_none:$addr, am3offset:$offset),
2762 IndexModePost, LdMiscFrm, itin,
2763 opc, "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2767 let Inst{23} = offset{8}; // U bit
2768 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2769 let Inst{19-16} = addr;
2770 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2771 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2772 let DecoderMethod = "DecodeAddrMode3Instruction";
2776 let mayLoad = 1, hasSideEffects = 0 in {
2777 defm LDRH : AI3_ldridx<0b1011, "ldrh", IIC_iLoad_bh_ru>;
2778 defm LDRSH : AI3_ldridx<0b1111, "ldrsh", IIC_iLoad_bh_ru>;
2779 defm LDRSB : AI3_ldridx<0b1101, "ldrsb", IIC_iLoad_bh_ru>;
2780 let hasExtraDefRegAllocReq = 1 in {
2781 def LDRD_PRE : AI3ldstidx<0b1101, 0, 1, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2782 (ins addrmode3_pre:$addr), IndexModePre,
2783 LdMiscFrm, IIC_iLoad_d_ru,
2784 "ldrd", "\t$Rt, $Rt2, $addr!",
2785 "$addr.base = $Rn_wb", []> {
2787 let Inst{23} = addr{8}; // U bit
2788 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2789 let Inst{19-16} = addr{12-9}; // Rn
2790 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2791 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2792 let DecoderMethod = "DecodeAddrMode3Instruction";
2794 def LDRD_POST: AI3ldstidx<0b1101, 0, 0, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2795 (ins addr_offset_none:$addr, am3offset:$offset),
2796 IndexModePost, LdMiscFrm, IIC_iLoad_d_ru,
2797 "ldrd", "\t$Rt, $Rt2, $addr, $offset",
2798 "$addr.base = $Rn_wb", []> {
2801 let Inst{23} = offset{8}; // U bit
2802 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2803 let Inst{19-16} = addr;
2804 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2805 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2806 let DecoderMethod = "DecodeAddrMode3Instruction";
2808 } // hasExtraDefRegAllocReq = 1
2809 } // mayLoad = 1, hasSideEffects = 0
2811 // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT.
2812 let mayLoad = 1, hasSideEffects = 0 in {
2813 def LDRT_POST_REG : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2814 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2815 IndexModePost, LdFrm, IIC_iLoad_ru,
2816 "ldrt", "\t$Rt, $addr, $offset",
2817 "$addr.base = $Rn_wb", []> {
2823 let Inst{23} = offset{12};
2824 let Inst{21} = 1; // overwrite
2825 let Inst{19-16} = addr;
2826 let Inst{11-5} = offset{11-5};
2828 let Inst{3-0} = offset{3-0};
2829 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2833 : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2834 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2835 IndexModePost, LdFrm, IIC_iLoad_ru,
2836 "ldrt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2842 let Inst{23} = offset{12};
2843 let Inst{21} = 1; // overwrite
2844 let Inst{19-16} = addr;
2845 let Inst{11-0} = offset{11-0};
2846 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2849 def LDRBT_POST_REG : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2850 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2851 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2852 "ldrbt", "\t$Rt, $addr, $offset",
2853 "$addr.base = $Rn_wb", []> {
2859 let Inst{23} = offset{12};
2860 let Inst{21} = 1; // overwrite
2861 let Inst{19-16} = addr;
2862 let Inst{11-5} = offset{11-5};
2864 let Inst{3-0} = offset{3-0};
2865 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2869 : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2870 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2871 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2872 "ldrbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2878 let Inst{23} = offset{12};
2879 let Inst{21} = 1; // overwrite
2880 let Inst{19-16} = addr;
2881 let Inst{11-0} = offset{11-0};
2882 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2885 multiclass AI3ldrT<bits<4> op, string opc> {
2886 def i : AI3ldstidxT<op, 1, (outs GPR:$Rt, GPR:$base_wb),
2887 (ins addr_offset_none:$addr, postidx_imm8:$offset),
2888 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2889 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2891 let Inst{23} = offset{8};
2893 let Inst{11-8} = offset{7-4};
2894 let Inst{3-0} = offset{3-0};
2896 def r : AI3ldstidxT<op, 1, (outs GPRnopc:$Rt, GPRnopc:$base_wb),
2897 (ins addr_offset_none:$addr, postidx_reg:$Rm),
2898 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2899 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2901 let Inst{23} = Rm{4};
2904 let Unpredictable{11-8} = 0b1111;
2905 let Inst{3-0} = Rm{3-0};
2906 let DecoderMethod = "DecodeLDR";
2910 defm LDRSBT : AI3ldrT<0b1101, "ldrsbt">;
2911 defm LDRHT : AI3ldrT<0b1011, "ldrht">;
2912 defm LDRSHT : AI3ldrT<0b1111, "ldrsht">;
2916 : ARMAsmPseudo<"ldrt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q),
2920 : ARMAsmPseudo<"ldrbt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q),
2923 // Pseudo instruction ldr Rt, =immediate
2925 : ARMAsmPseudo<"ldr${q} $Rt, $immediate",
2926 (ins const_pool_asm_imm:$immediate, pred:$q),
2931 // Stores with truncate
2932 def STRH : AI3str<0b1011, (outs), (ins GPR:$Rt, addrmode3:$addr), StMiscFrm,
2933 IIC_iStore_bh_r, "strh", "\t$Rt, $addr",
2934 [(truncstorei16 GPR:$Rt, addrmode3:$addr)]>;
2937 let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
2938 def STRD : AI3str<0b1111, (outs), (ins GPR:$Rt, GPR:$Rt2, addrmode3:$addr),
2939 StMiscFrm, IIC_iStore_d_r, "strd", "\t$Rt, $Rt2, $addr", []>,
2940 Requires<[IsARM, HasV5TE]> {
2946 multiclass AI2_stridx<bit isByte, string opc,
2947 InstrItinClass iii, InstrItinClass iir> {
2948 def _PRE_IMM : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2949 (ins GPR:$Rt, addrmode_imm12_pre:$addr), IndexModePre,
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}; // imm12
2958 let DecoderMethod = "DecodeSTRPreImm";
2961 def _PRE_REG : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2962 (ins GPR:$Rt, ldst_so_reg:$addr),
2963 IndexModePre, StFrm, iir,
2964 opc, "\t$Rt, $addr!",
2965 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2968 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2969 let Inst{19-16} = addr{16-13}; // Rn
2970 let Inst{11-0} = addr{11-0};
2971 let Inst{4} = 0; // Inst{4} = 0
2972 let DecoderMethod = "DecodeSTRPreReg";
2974 def _POST_REG : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2975 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2976 IndexModePost, StFrm, iir,
2977 opc, "\t$Rt, $addr, $offset",
2978 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2984 let Inst{23} = offset{12};
2985 let Inst{19-16} = addr;
2986 let Inst{11-0} = offset{11-0};
2989 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2992 def _POST_IMM : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2993 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2994 IndexModePost, StFrm, iii,
2995 opc, "\t$Rt, $addr, $offset",
2996 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
3002 let Inst{23} = offset{12};
3003 let Inst{19-16} = addr;
3004 let Inst{11-0} = offset{11-0};
3006 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3010 let mayStore = 1, hasSideEffects = 0 in {
3011 // FIXME: for STR_PRE_REG etc. the itineray should be either IIC_iStore_ru or
3012 // IIC_iStore_siu depending on whether it the offset register is shifted.
3013 defm STR : AI2_stridx<0, "str", IIC_iStore_iu, IIC_iStore_ru>;
3014 defm STRB : AI2_stridx<1, "strb", IIC_iStore_bh_iu, IIC_iStore_bh_ru>;
3017 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
3018 am2offset_reg:$offset),
3019 (STR_POST_REG GPR:$Rt, addr_offset_none:$addr,
3020 am2offset_reg:$offset)>;
3021 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
3022 am2offset_imm:$offset),
3023 (STR_POST_IMM GPR:$Rt, addr_offset_none:$addr,
3024 am2offset_imm:$offset)>;
3025 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
3026 am2offset_reg:$offset),
3027 (STRB_POST_REG GPR:$Rt, addr_offset_none:$addr,
3028 am2offset_reg:$offset)>;
3029 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
3030 am2offset_imm:$offset),
3031 (STRB_POST_IMM GPR:$Rt, addr_offset_none:$addr,
3032 am2offset_imm:$offset)>;
3034 // Pseudo-instructions for pattern matching the pre-indexed stores. We can't
3035 // put the patterns on the instruction definitions directly as ISel wants
3036 // the address base and offset to be separate operands, not a single
3037 // complex operand like we represent the instructions themselves. The
3038 // pseudos map between the two.
3039 let usesCustomInserter = 1,
3040 Constraints = "$Rn = $Rn_wb,@earlyclobber $Rn_wb" in {
3041 def STRi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3042 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
3045 (pre_store GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
3046 def STRr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3047 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
3050 (pre_store GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
3051 def STRBi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3052 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
3055 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
3056 def STRBr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3057 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
3060 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
3061 def STRH_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3062 (ins GPR:$Rt, GPR:$Rn, am3offset:$offset, pred:$p),
3065 (pre_truncsti16 GPR:$Rt, GPR:$Rn, am3offset:$offset))]>;
3070 def STRH_PRE : AI3ldstidx<0b1011, 0, 1, (outs GPR:$Rn_wb),
3071 (ins GPR:$Rt, addrmode3_pre:$addr), IndexModePre,
3072 StMiscFrm, IIC_iStore_bh_ru,
3073 "strh", "\t$Rt, $addr!",
3074 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
3076 let Inst{23} = addr{8}; // U bit
3077 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
3078 let Inst{19-16} = addr{12-9}; // Rn
3079 let Inst{11-8} = addr{7-4}; // imm7_4/zero
3080 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
3081 let DecoderMethod = "DecodeAddrMode3Instruction";
3084 def STRH_POST : AI3ldstidx<0b1011, 0, 0, (outs GPR:$Rn_wb),
3085 (ins GPR:$Rt, addr_offset_none:$addr, am3offset:$offset),
3086 IndexModePost, StMiscFrm, IIC_iStore_bh_ru,
3087 "strh", "\t$Rt, $addr, $offset",
3088 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb",
3089 [(set GPR:$Rn_wb, (post_truncsti16 GPR:$Rt,
3090 addr_offset_none:$addr,
3091 am3offset:$offset))]> {
3094 let Inst{23} = offset{8}; // U bit
3095 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
3096 let Inst{19-16} = addr;
3097 let Inst{11-8} = offset{7-4}; // imm7_4/zero
3098 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
3099 let DecoderMethod = "DecodeAddrMode3Instruction";
3102 let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
3103 def STRD_PRE : AI3ldstidx<0b1111, 0, 1, (outs GPR:$Rn_wb),
3104 (ins GPR:$Rt, GPR:$Rt2, addrmode3_pre:$addr),
3105 IndexModePre, StMiscFrm, IIC_iStore_d_ru,
3106 "strd", "\t$Rt, $Rt2, $addr!",
3107 "$addr.base = $Rn_wb", []> {
3109 let Inst{23} = addr{8}; // U bit
3110 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
3111 let Inst{19-16} = addr{12-9}; // Rn
3112 let Inst{11-8} = addr{7-4}; // imm7_4/zero
3113 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
3114 let DecoderMethod = "DecodeAddrMode3Instruction";
3117 def STRD_POST: AI3ldstidx<0b1111, 0, 0, (outs GPR:$Rn_wb),
3118 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr,
3120 IndexModePost, StMiscFrm, IIC_iStore_d_ru,
3121 "strd", "\t$Rt, $Rt2, $addr, $offset",
3122 "$addr.base = $Rn_wb", []> {
3125 let Inst{23} = offset{8}; // U bit
3126 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
3127 let Inst{19-16} = addr;
3128 let Inst{11-8} = offset{7-4}; // imm7_4/zero
3129 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
3130 let DecoderMethod = "DecodeAddrMode3Instruction";
3132 } // mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1
3134 // STRT, STRBT, and STRHT
3136 def STRBT_POST_REG : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
3137 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
3138 IndexModePost, StFrm, IIC_iStore_bh_ru,
3139 "strbt", "\t$Rt, $addr, $offset",
3140 "$addr.base = $Rn_wb", []> {
3146 let Inst{23} = offset{12};
3147 let Inst{21} = 1; // overwrite
3148 let Inst{19-16} = addr;
3149 let Inst{11-5} = offset{11-5};
3151 let Inst{3-0} = offset{3-0};
3152 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3156 : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
3157 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
3158 IndexModePost, StFrm, IIC_iStore_bh_ru,
3159 "strbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
3165 let Inst{23} = offset{12};
3166 let Inst{21} = 1; // overwrite
3167 let Inst{19-16} = addr;
3168 let Inst{11-0} = offset{11-0};
3169 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3173 : ARMAsmPseudo<"strbt${q} $Rt, $addr",
3174 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>;
3176 let mayStore = 1, hasSideEffects = 0 in {
3177 def STRT_POST_REG : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
3178 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
3179 IndexModePost, StFrm, IIC_iStore_ru,
3180 "strt", "\t$Rt, $addr, $offset",
3181 "$addr.base = $Rn_wb", []> {
3187 let Inst{23} = offset{12};
3188 let Inst{21} = 1; // overwrite
3189 let Inst{19-16} = addr;
3190 let Inst{11-5} = offset{11-5};
3192 let Inst{3-0} = offset{3-0};
3193 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3197 : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
3198 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
3199 IndexModePost, StFrm, IIC_iStore_ru,
3200 "strt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
3206 let Inst{23} = offset{12};
3207 let Inst{21} = 1; // overwrite
3208 let Inst{19-16} = addr;
3209 let Inst{11-0} = offset{11-0};
3210 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3215 : ARMAsmPseudo<"strt${q} $Rt, $addr",
3216 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>;
3218 multiclass AI3strT<bits<4> op, string opc> {
3219 def i : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
3220 (ins GPR:$Rt, addr_offset_none:$addr, postidx_imm8:$offset),
3221 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
3222 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
3224 let Inst{23} = offset{8};
3226 let Inst{11-8} = offset{7-4};
3227 let Inst{3-0} = offset{3-0};
3229 def r : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
3230 (ins GPR:$Rt, addr_offset_none:$addr, postidx_reg:$Rm),
3231 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
3232 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
3234 let Inst{23} = Rm{4};
3237 let Inst{3-0} = Rm{3-0};
3242 defm STRHT : AI3strT<0b1011, "strht">;
3244 def STL : AIstrrel<0b00, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3245 NoItinerary, "stl", "\t$Rt, $addr", []>;
3246 def STLB : AIstrrel<0b10, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3247 NoItinerary, "stlb", "\t$Rt, $addr", []>;
3248 def STLH : AIstrrel<0b11, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3249 NoItinerary, "stlh", "\t$Rt, $addr", []>;
3251 //===----------------------------------------------------------------------===//
3252 // Load / store multiple Instructions.
3255 multiclass arm_ldst_mult<string asm, string sfx, bit L_bit, bit P_bit, Format f,
3256 InstrItinClass itin, InstrItinClass itin_upd> {
3257 // IA is the default, so no need for an explicit suffix on the
3258 // mnemonic here. Without it is the canonical spelling.
3260 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3261 IndexModeNone, f, itin,
3262 !strconcat(asm, "${p}\t$Rn, $regs", sfx), "", []> {
3263 let Inst{24-23} = 0b01; // Increment After
3264 let Inst{22} = P_bit;
3265 let Inst{21} = 0; // No writeback
3266 let Inst{20} = L_bit;
3269 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3270 IndexModeUpd, f, itin_upd,
3271 !strconcat(asm, "${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3272 let Inst{24-23} = 0b01; // Increment After
3273 let Inst{22} = P_bit;
3274 let Inst{21} = 1; // Writeback
3275 let Inst{20} = L_bit;
3277 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3280 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3281 IndexModeNone, f, itin,
3282 !strconcat(asm, "da${p}\t$Rn, $regs", sfx), "", []> {
3283 let Inst{24-23} = 0b00; // Decrement After
3284 let Inst{22} = P_bit;
3285 let Inst{21} = 0; // No writeback
3286 let Inst{20} = L_bit;
3289 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3290 IndexModeUpd, f, itin_upd,
3291 !strconcat(asm, "da${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3292 let Inst{24-23} = 0b00; // Decrement After
3293 let Inst{22} = P_bit;
3294 let Inst{21} = 1; // Writeback
3295 let Inst{20} = L_bit;
3297 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3300 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3301 IndexModeNone, f, itin,
3302 !strconcat(asm, "db${p}\t$Rn, $regs", sfx), "", []> {
3303 let Inst{24-23} = 0b10; // Decrement Before
3304 let Inst{22} = P_bit;
3305 let Inst{21} = 0; // No writeback
3306 let Inst{20} = L_bit;
3309 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3310 IndexModeUpd, f, itin_upd,
3311 !strconcat(asm, "db${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3312 let Inst{24-23} = 0b10; // Decrement Before
3313 let Inst{22} = P_bit;
3314 let Inst{21} = 1; // Writeback
3315 let Inst{20} = L_bit;
3317 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3320 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3321 IndexModeNone, f, itin,
3322 !strconcat(asm, "ib${p}\t$Rn, $regs", sfx), "", []> {
3323 let Inst{24-23} = 0b11; // Increment Before
3324 let Inst{22} = P_bit;
3325 let Inst{21} = 0; // No writeback
3326 let Inst{20} = L_bit;
3329 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3330 IndexModeUpd, f, itin_upd,
3331 !strconcat(asm, "ib${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3332 let Inst{24-23} = 0b11; // Increment Before
3333 let Inst{22} = P_bit;
3334 let Inst{21} = 1; // Writeback
3335 let Inst{20} = L_bit;
3337 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3341 let hasSideEffects = 0 in {
3343 let mayLoad = 1, hasExtraDefRegAllocReq = 1, variadicOpsAreDefs = 1 in
3344 defm LDM : arm_ldst_mult<"ldm", "", 1, 0, LdStMulFrm, IIC_iLoad_m,
3345 IIC_iLoad_mu>, ComplexDeprecationPredicate<"ARMLoad">;
3347 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
3348 defm STM : arm_ldst_mult<"stm", "", 0, 0, LdStMulFrm, IIC_iStore_m,
3350 ComplexDeprecationPredicate<"ARMStore">;
3354 // FIXME: remove when we have a way to marking a MI with these properties.
3355 // FIXME: Should pc be an implicit operand like PICADD, etc?
3356 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
3357 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
3358 def LDMIA_RET : ARMPseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p,
3359 reglist:$regs, variable_ops),
3360 4, IIC_iLoad_mBr, [],
3361 (LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>,
3362 RegConstraint<"$Rn = $wb">;
3364 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
3365 defm sysLDM : arm_ldst_mult<"ldm", " ^", 1, 1, LdStMulFrm, IIC_iLoad_m,
3368 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
3369 defm sysSTM : arm_ldst_mult<"stm", " ^", 0, 1, LdStMulFrm, IIC_iStore_m,
3374 //===----------------------------------------------------------------------===//
3375 // Move Instructions.
3378 let hasSideEffects = 0, isMoveReg = 1 in
3379 def MOVr : AsI1<0b1101, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMOVr,
3380 "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> {
3384 let Inst{19-16} = 0b0000;
3385 let Inst{11-4} = 0b00000000;
3388 let Inst{15-12} = Rd;
3391 // A version for the smaller set of tail call registers.
3392 let hasSideEffects = 0 in
3393 def MOVr_TC : AsI1<0b1101, (outs tcGPR:$Rd), (ins tcGPR:$Rm), DPFrm,
3394 IIC_iMOVr, "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> {
3398 let Inst{11-4} = 0b00000000;
3401 let Inst{15-12} = Rd;
3404 def MOVsr : AsI1<0b1101, (outs GPRnopc:$Rd), (ins shift_so_reg_reg:$src),
3405 DPSoRegRegFrm, IIC_iMOVsr,
3406 "mov", "\t$Rd, $src",
3407 [(set GPRnopc:$Rd, shift_so_reg_reg:$src)]>, UnaryDP,
3411 let Inst{15-12} = Rd;
3412 let Inst{19-16} = 0b0000;
3413 let Inst{11-8} = src{11-8};
3415 let Inst{6-5} = src{6-5};
3417 let Inst{3-0} = src{3-0};
3421 def MOVsi : AsI1<0b1101, (outs GPR:$Rd), (ins shift_so_reg_imm:$src),
3422 DPSoRegImmFrm, IIC_iMOVsr,
3423 "mov", "\t$Rd, $src", [(set GPR:$Rd, shift_so_reg_imm:$src)]>,
3424 UnaryDP, Sched<[WriteALU]> {
3427 let Inst{15-12} = Rd;
3428 let Inst{19-16} = 0b0000;
3429 let Inst{11-5} = src{11-5};
3431 let Inst{3-0} = src{3-0};
3435 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3436 def MOVi : AsI1<0b1101, (outs GPR:$Rd), (ins mod_imm:$imm), DPFrm, IIC_iMOVi,
3437 "mov", "\t$Rd, $imm", [(set GPR:$Rd, mod_imm:$imm)]>, UnaryDP,
3442 let Inst{15-12} = Rd;
3443 let Inst{19-16} = 0b0000;
3444 let Inst{11-0} = imm;
3447 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3448 def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins imm0_65535_expr:$imm),
3450 "movw", "\t$Rd, $imm",
3451 [(set GPR:$Rd, imm0_65535:$imm)]>,
3452 Requires<[IsARM, HasV6T2]>, UnaryDP, Sched<[WriteALU]> {
3455 let Inst{15-12} = Rd;
3456 let Inst{11-0} = imm{11-0};
3457 let Inst{19-16} = imm{15-12};
3460 let DecoderMethod = "DecodeArmMOVTWInstruction";
3463 def : InstAlias<"mov${p} $Rd, $imm",
3464 (MOVi16 GPR:$Rd, imm0_65535_expr:$imm, pred:$p), 0>,
3465 Requires<[IsARM, HasV6T2]>;
3467 def MOVi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
3468 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
3471 let Constraints = "$src = $Rd" in {
3472 def MOVTi16 : AI1<0b1010, (outs GPRnopc:$Rd),
3473 (ins GPR:$src, imm0_65535_expr:$imm),
3475 "movt", "\t$Rd, $imm",
3477 (or (and GPR:$src, 0xffff),
3478 lo16AllZero:$imm))]>, UnaryDP,
3479 Requires<[IsARM, HasV6T2]>, Sched<[WriteALU]> {
3482 let Inst{15-12} = Rd;
3483 let Inst{11-0} = imm{11-0};
3484 let Inst{19-16} = imm{15-12};
3487 let DecoderMethod = "DecodeArmMOVTWInstruction";
3490 def MOVTi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
3491 (ins GPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
3496 def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
3497 Requires<[IsARM, HasV6T2]>;
3499 let Uses = [CPSR] in
3500 def RRX: PseudoInst<(outs GPR:$Rd), (ins GPR:$Rm), IIC_iMOVsi,
3501 [(set GPR:$Rd, (ARMrrx GPR:$Rm))]>, UnaryDP,
3502 Requires<[IsARM]>, Sched<[WriteALU]>;
3504 // These aren't really mov instructions, but we have to define them this way
3505 // due to flag operands.
3507 let Defs = [CPSR] in {
3508 def MOVsrl_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3509 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP,
3510 Sched<[WriteALU]>, Requires<[IsARM]>;
3511 def MOVsra_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3512 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP,
3513 Sched<[WriteALU]>, Requires<[IsARM]>;
3516 //===----------------------------------------------------------------------===//
3517 // Extend Instructions.
3522 def SXTB : AI_ext_rrot<0b01101010,
3523 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
3524 def SXTH : AI_ext_rrot<0b01101011,
3525 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
3527 def SXTAB : AI_exta_rrot<0b01101010,
3528 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
3529 def SXTAH : AI_exta_rrot<0b01101011,
3530 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
3532 def : ARMV6Pat<(add rGPR:$Rn, (sext_inreg (srl rGPR:$Rm, rot_imm:$rot), i8)),
3533 (SXTAB rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
3534 def : ARMV6Pat<(add rGPR:$Rn, (sext_inreg (srl rGPR:$Rm, imm8_or_16:$rot),
3536 (SXTAH rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
3538 def SXTB16 : AI_ext_rrot_np<0b01101000, "sxtb16">;
3539 def : ARMV6Pat<(int_arm_sxtb16 GPR:$Src),
3540 (SXTB16 GPR:$Src, 0)>;
3541 def : ARMV6Pat<(int_arm_sxtb16 (rotr GPR:$Src, rot_imm:$rot)),
3542 (SXTB16 GPR:$Src, rot_imm:$rot)>;
3544 def SXTAB16 : AI_exta_rrot_np<0b01101000, "sxtab16">;
3545 def : ARMV6Pat<(int_arm_sxtab16 GPR:$LHS, GPR:$RHS),
3546 (SXTAB16 GPR:$LHS, GPR:$RHS, 0)>;
3547 def : ARMV6Pat<(int_arm_sxtab16 GPR:$LHS, (rotr GPR:$RHS, rot_imm:$rot)),
3548 (SXTAB16 GPR:$LHS, GPR:$RHS, rot_imm:$rot)>;
3552 let AddedComplexity = 16 in {
3553 def UXTB : AI_ext_rrot<0b01101110,
3554 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
3555 def UXTH : AI_ext_rrot<0b01101111,
3556 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
3557 def UXTB16 : AI_ext_rrot<0b01101100,
3558 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
3560 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
3561 // The transformation should probably be done as a combiner action
3562 // instead so we can include a check for masking back in the upper
3563 // eight bits of the source into the lower eight bits of the result.
3564 //def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
3565 // (UXTB16r_rot GPR:$Src, 3)>;
3566 def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
3567 (UXTB16 GPR:$Src, 1)>;
3568 def : ARMV6Pat<(int_arm_uxtb16 GPR:$Src),
3569 (UXTB16 GPR:$Src, 0)>;
3570 def : ARMV6Pat<(int_arm_uxtb16 (rotr GPR:$Src, rot_imm:$rot)),
3571 (UXTB16 GPR:$Src, rot_imm:$rot)>;
3573 def UXTAB : AI_exta_rrot<0b01101110, "uxtab",
3574 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
3575 def UXTAH : AI_exta_rrot<0b01101111, "uxtah",
3576 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
3578 def : ARMV6Pat<(add rGPR:$Rn, (and (srl rGPR:$Rm, rot_imm:$rot), 0xFF)),
3579 (UXTAB rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
3580 def : ARMV6Pat<(add rGPR:$Rn, (and (srl rGPR:$Rm, imm8_or_16:$rot), 0xFFFF)),
3581 (UXTAH rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
3584 // This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
3585 def UXTAB16 : AI_exta_rrot_np<0b01101100, "uxtab16">;
3586 def : ARMV6Pat<(int_arm_uxtab16 GPR:$LHS, GPR:$RHS),
3587 (UXTAB16 GPR:$LHS, GPR:$RHS, 0)>;
3588 def : ARMV6Pat<(int_arm_uxtab16 GPR:$LHS, (rotr GPR:$RHS, rot_imm:$rot)),
3589 (UXTAB16 GPR:$LHS, GPR:$RHS, rot_imm:$rot)>;
3592 def SBFX : I<(outs GPRnopc:$Rd),
3593 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3594 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3595 "sbfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3596 Requires<[IsARM, HasV6T2]> {
3601 let Inst{27-21} = 0b0111101;
3602 let Inst{6-4} = 0b101;
3603 let Inst{20-16} = width;
3604 let Inst{15-12} = Rd;
3605 let Inst{11-7} = lsb;
3609 def UBFX : I<(outs GPRnopc:$Rd),
3610 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3611 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3612 "ubfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3613 Requires<[IsARM, HasV6T2]> {
3618 let Inst{27-21} = 0b0111111;
3619 let Inst{6-4} = 0b101;
3620 let Inst{20-16} = width;
3621 let Inst{15-12} = Rd;
3622 let Inst{11-7} = lsb;
3626 //===----------------------------------------------------------------------===//
3627 // Arithmetic Instructions.
3631 defm ADD : AsI1_bin_irs<0b0100, "add",
3632 IIC_iALUi, IIC_iALUr, IIC_iALUsr, add, 1>;
3633 defm SUB : AsI1_bin_irs<0b0010, "sub",
3634 IIC_iALUi, IIC_iALUr, IIC_iALUsr, sub>;
3636 // ADD and SUB with 's' bit set.
3638 // Currently, ADDS/SUBS are pseudo opcodes that exist only in the
3639 // selection DAG. They are "lowered" to real ADD/SUB opcodes by
3640 // AdjustInstrPostInstrSelection where we determine whether or not to
3641 // set the "s" bit based on CPSR liveness.
3643 // FIXME: Eliminate ADDS/SUBS pseudo opcodes after adding tablegen
3644 // support for an optional CPSR definition that corresponds to the DAG
3645 // node's second value. We can then eliminate the implicit def of CPSR.
3647 defm ADDS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr, ARMaddc, 1>;
3648 defm SUBS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr, ARMsubc>;
3650 def : ARMPat<(ARMsubs GPR:$Rn, mod_imm:$imm), (SUBSri $Rn, mod_imm:$imm)>;
3651 def : ARMPat<(ARMsubs GPR:$Rn, GPR:$Rm), (SUBSrr $Rn, $Rm)>;
3652 def : ARMPat<(ARMsubs GPR:$Rn, so_reg_imm:$shift),
3653 (SUBSrsi $Rn, so_reg_imm:$shift)>;
3654 def : ARMPat<(ARMsubs GPR:$Rn, so_reg_reg:$shift),
3655 (SUBSrsr $Rn, so_reg_reg:$shift)>;
3659 defm ADC : AI1_adde_sube_irs<0b0101, "adc", ARMadde, 1>;
3660 defm SBC : AI1_adde_sube_irs<0b0110, "sbc", ARMsube>;
3662 defm RSB : AsI1_rbin_irs<0b0011, "rsb",
3663 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3666 // FIXME: Eliminate them if we can write def : Pat patterns which defines
3667 // CPSR and the implicit def of CPSR is not needed.
3668 defm RSBS : AsI1_rbin_s_is<IIC_iALUi, IIC_iALUr, IIC_iALUsr, ARMsubc>;
3670 defm RSC : AI1_rsc_irs<0b0111, "rsc", ARMsube>;
3672 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
3673 // The assume-no-carry-in form uses the negation of the input since add/sub
3674 // assume opposite meanings of the carry flag (i.e., carry == !borrow).
3675 // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
3677 def : ARMPat<(add GPR:$src, mod_imm_neg:$imm),
3678 (SUBri GPR:$src, mod_imm_neg:$imm)>;
3679 def : ARMPat<(ARMaddc GPR:$src, mod_imm_neg:$imm),
3680 (SUBSri GPR:$src, mod_imm_neg:$imm)>;
3682 def : ARMPat<(add GPR:$src, imm0_65535_neg:$imm),
3683 (SUBrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>,
3684 Requires<[IsARM, HasV6T2]>;
3685 def : ARMPat<(ARMaddc GPR:$src, imm0_65535_neg:$imm),
3686 (SUBSrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>,
3687 Requires<[IsARM, HasV6T2]>;
3689 // The with-carry-in form matches bitwise not instead of the negation.
3690 // Effectively, the inverse interpretation of the carry flag already accounts
3691 // for part of the negation.
3692 def : ARMPat<(ARMadde GPR:$src, mod_imm_not:$imm, CPSR),
3693 (SBCri GPR:$src, mod_imm_not:$imm)>;
3694 def : ARMPat<(ARMadde GPR:$src, imm0_65535_neg:$imm, CPSR),
3695 (SBCrr GPR:$src, (MOVi16 (imm_not_XFORM imm:$imm)))>,
3696 Requires<[IsARM, HasV6T2]>;
3698 // Note: These are implemented in C++ code, because they have to generate
3699 // ADD/SUBrs instructions, which use a complex pattern that a xform function
3701 // (mul X, 2^n+1) -> (add (X << n), X)
3702 // (mul X, 2^n-1) -> (rsb X, (X << n))
3704 // ARM Arithmetic Instruction
3705 // GPR:$dst = GPR:$a op GPR:$b
3706 class AAI<bits<8> op27_20, bits<8> op11_4, string opc,
3707 list<dag> pattern = [],
3708 dag iops = (ins GPRnopc:$Rn, GPRnopc:$Rm),
3709 string asm = "\t$Rd, $Rn, $Rm">
3710 : AI<(outs GPRnopc:$Rd), iops, DPFrm, IIC_iALUr, opc, asm, pattern>,
3711 Sched<[WriteALU, ReadALU, ReadALU]> {
3715 let Inst{27-20} = op27_20;
3716 let Inst{11-4} = op11_4;
3717 let Inst{19-16} = Rn;
3718 let Inst{15-12} = Rd;
3721 let Unpredictable{11-8} = 0b1111;
3724 // Wrappers around the AAI class
3725 class AAIRevOpr<bits<8> op27_20, bits<8> op11_4, string opc,
3726 list<dag> pattern = []>
3727 : AAI<op27_20, op11_4, opc,
3729 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3732 class AAIIntrinsic<bits<8> op27_20, bits<8> op11_4, string opc,
3733 Intrinsic intrinsic>
3734 : AAI<op27_20, op11_4, opc,
3735 [(set GPRnopc:$Rd, (intrinsic GPRnopc:$Rn, GPRnopc:$Rm))]>;
3737 // Saturating add/subtract
3738 let hasSideEffects = 1 in {
3739 def QADD8 : AAIIntrinsic<0b01100010, 0b11111001, "qadd8", int_arm_qadd8>;
3740 def QADD16 : AAIIntrinsic<0b01100010, 0b11110001, "qadd16", int_arm_qadd16>;
3741 def QSUB16 : AAIIntrinsic<0b01100010, 0b11110111, "qsub16", int_arm_qsub16>;
3742 def QSUB8 : AAIIntrinsic<0b01100010, 0b11111111, "qsub8", int_arm_qsub8>;
3744 def QDADD : AAIRevOpr<0b00010100, 0b00000101, "qdadd",
3745 [(set GPRnopc:$Rd, (int_arm_qadd (int_arm_qadd GPRnopc:$Rm,
3748 def QDSUB : AAIRevOpr<0b00010110, 0b00000101, "qdsub",
3749 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm,
3750 (int_arm_qadd GPRnopc:$Rn, GPRnopc:$Rn)))]>;
3751 def QSUB : AAIRevOpr<0b00010010, 0b00000101, "qsub",
3752 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm, GPRnopc:$Rn))]>;
3753 let DecoderMethod = "DecodeQADDInstruction" in
3754 def QADD : AAIRevOpr<0b00010000, 0b00000101, "qadd",
3755 [(set GPRnopc:$Rd, (int_arm_qadd GPRnopc:$Rm, GPRnopc:$Rn))]>;
3758 def : ARMV5TEPat<(saddsat GPR:$a, GPR:$b),
3759 (QADD GPR:$a, GPR:$b)>;
3760 def : ARMV5TEPat<(ssubsat GPR:$a, GPR:$b),
3761 (QSUB GPR:$a, GPR:$b)>;
3762 def : ARMV5TEPat<(saddsat(saddsat rGPR:$Rm, rGPR:$Rm), rGPR:$Rn),
3763 (QDADD rGPR:$Rm, rGPR:$Rn)>;
3764 def : ARMV5TEPat<(ssubsat rGPR:$Rm, (saddsat rGPR:$Rn, rGPR:$Rn)),
3765 (QDSUB rGPR:$Rm, rGPR:$Rn)>;
3766 def : ARMV6Pat<(ARMqadd8b rGPR:$Rm, rGPR:$Rn),
3767 (QADD8 rGPR:$Rm, rGPR:$Rn)>;
3768 def : ARMV6Pat<(ARMqsub8b rGPR:$Rm, rGPR:$Rn),
3769 (QSUB8 rGPR:$Rm, rGPR:$Rn)>;
3770 def : ARMV6Pat<(ARMqadd16b rGPR:$Rm, rGPR:$Rn),
3771 (QADD16 rGPR:$Rm, rGPR:$Rn)>;
3772 def : ARMV6Pat<(ARMqsub16b rGPR:$Rm, rGPR:$Rn),
3773 (QSUB16 rGPR:$Rm, rGPR:$Rn)>;
3775 def UQADD16 : AAIIntrinsic<0b01100110, 0b11110001, "uqadd16", int_arm_uqadd16>;
3776 def UQADD8 : AAIIntrinsic<0b01100110, 0b11111001, "uqadd8", int_arm_uqadd8>;
3777 def UQSUB16 : AAIIntrinsic<0b01100110, 0b11110111, "uqsub16", int_arm_uqsub16>;
3778 def UQSUB8 : AAIIntrinsic<0b01100110, 0b11111111, "uqsub8", int_arm_uqsub8>;
3779 def QASX : AAIIntrinsic<0b01100010, 0b11110011, "qasx", int_arm_qasx>;
3780 def QSAX : AAIIntrinsic<0b01100010, 0b11110101, "qsax", int_arm_qsax>;
3781 def UQASX : AAIIntrinsic<0b01100110, 0b11110011, "uqasx", int_arm_uqasx>;
3782 def UQSAX : AAIIntrinsic<0b01100110, 0b11110101, "uqsax", int_arm_uqsax>;
3784 // Signed/Unsigned add/subtract
3786 def SASX : AAIIntrinsic<0b01100001, 0b11110011, "sasx", int_arm_sasx>;
3787 def SADD16 : AAIIntrinsic<0b01100001, 0b11110001, "sadd16", int_arm_sadd16>;
3788 def SADD8 : AAIIntrinsic<0b01100001, 0b11111001, "sadd8", int_arm_sadd8>;
3789 def SSAX : AAIIntrinsic<0b01100001, 0b11110101, "ssax", int_arm_ssax>;
3790 def SSUB16 : AAIIntrinsic<0b01100001, 0b11110111, "ssub16", int_arm_ssub16>;
3791 def SSUB8 : AAIIntrinsic<0b01100001, 0b11111111, "ssub8", int_arm_ssub8>;
3792 def UASX : AAIIntrinsic<0b01100101, 0b11110011, "uasx", int_arm_uasx>;
3793 def UADD16 : AAIIntrinsic<0b01100101, 0b11110001, "uadd16", int_arm_uadd16>;
3794 def UADD8 : AAIIntrinsic<0b01100101, 0b11111001, "uadd8", int_arm_uadd8>;
3795 def USAX : AAIIntrinsic<0b01100101, 0b11110101, "usax", int_arm_usax>;
3796 def USUB16 : AAIIntrinsic<0b01100101, 0b11110111, "usub16", int_arm_usub16>;
3797 def USUB8 : AAIIntrinsic<0b01100101, 0b11111111, "usub8", int_arm_usub8>;
3799 // Signed/Unsigned halving add/subtract
3801 def SHASX : AAIIntrinsic<0b01100011, 0b11110011, "shasx", int_arm_shasx>;
3802 def SHADD16 : AAIIntrinsic<0b01100011, 0b11110001, "shadd16", int_arm_shadd16>;
3803 def SHADD8 : AAIIntrinsic<0b01100011, 0b11111001, "shadd8", int_arm_shadd8>;
3804 def SHSAX : AAIIntrinsic<0b01100011, 0b11110101, "shsax", int_arm_shsax>;
3805 def SHSUB16 : AAIIntrinsic<0b01100011, 0b11110111, "shsub16", int_arm_shsub16>;
3806 def SHSUB8 : AAIIntrinsic<0b01100011, 0b11111111, "shsub8", int_arm_shsub8>;
3807 def UHASX : AAIIntrinsic<0b01100111, 0b11110011, "uhasx", int_arm_uhasx>;
3808 def UHADD16 : AAIIntrinsic<0b01100111, 0b11110001, "uhadd16", int_arm_uhadd16>;
3809 def UHADD8 : AAIIntrinsic<0b01100111, 0b11111001, "uhadd8", int_arm_uhadd8>;
3810 def UHSAX : AAIIntrinsic<0b01100111, 0b11110101, "uhsax", int_arm_uhsax>;
3811 def UHSUB16 : AAIIntrinsic<0b01100111, 0b11110111, "uhsub16", int_arm_uhsub16>;
3812 def UHSUB8 : AAIIntrinsic<0b01100111, 0b11111111, "uhsub8", int_arm_uhsub8>;
3814 // Unsigned Sum of Absolute Differences [and Accumulate].
3816 def USAD8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3817 MulFrm /* for convenience */, NoItinerary, "usad8",
3819 [(set GPR:$Rd, (int_arm_usad8 GPR:$Rn, GPR:$Rm))]>,
3820 Requires<[IsARM, HasV6]>, Sched<[WriteALU, ReadALU, ReadALU]> {
3824 let Inst{27-20} = 0b01111000;
3825 let Inst{15-12} = 0b1111;
3826 let Inst{7-4} = 0b0001;
3827 let Inst{19-16} = Rd;
3828 let Inst{11-8} = Rm;
3831 def USADA8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3832 MulFrm /* for convenience */, NoItinerary, "usada8",
3833 "\t$Rd, $Rn, $Rm, $Ra",
3834 [(set GPR:$Rd, (int_arm_usada8 GPR:$Rn, GPR:$Rm, GPR:$Ra))]>,
3835 Requires<[IsARM, HasV6]>, Sched<[WriteALU, ReadALU, ReadALU]>{
3840 let Inst{27-20} = 0b01111000;
3841 let Inst{7-4} = 0b0001;
3842 let Inst{19-16} = Rd;
3843 let Inst{15-12} = Ra;
3844 let Inst{11-8} = Rm;
3848 // Signed/Unsigned saturate
3849 def SSAT : AI<(outs GPRnopc:$Rd),
3850 (ins imm1_32:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3851 SatFrm, NoItinerary, "ssat", "\t$Rd, $sat_imm, $Rn$sh", []>,
3852 Requires<[IsARM,HasV6]>{
3857 let Inst{27-21} = 0b0110101;
3858 let Inst{5-4} = 0b01;
3859 let Inst{20-16} = sat_imm;
3860 let Inst{15-12} = Rd;
3861 let Inst{11-7} = sh{4-0};
3862 let Inst{6} = sh{5};
3866 def SSAT16 : AI<(outs GPRnopc:$Rd),
3867 (ins imm1_16:$sat_imm, GPRnopc:$Rn), SatFrm,
3868 NoItinerary, "ssat16", "\t$Rd, $sat_imm, $Rn", []>,
3869 Requires<[IsARM,HasV6]>{
3873 let Inst{27-20} = 0b01101010;
3874 let Inst{11-4} = 0b11110011;
3875 let Inst{15-12} = Rd;
3876 let Inst{19-16} = sat_imm;
3880 def USAT : AI<(outs GPRnopc:$Rd),
3881 (ins imm0_31:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3882 SatFrm, NoItinerary, "usat", "\t$Rd, $sat_imm, $Rn$sh", []>,
3883 Requires<[IsARM,HasV6]> {
3888 let Inst{27-21} = 0b0110111;
3889 let Inst{5-4} = 0b01;
3890 let Inst{15-12} = Rd;
3891 let Inst{11-7} = sh{4-0};
3892 let Inst{6} = sh{5};
3893 let Inst{20-16} = sat_imm;
3897 def USAT16 : AI<(outs GPRnopc:$Rd),
3898 (ins imm0_15:$sat_imm, GPRnopc:$Rn), SatFrm,
3899 NoItinerary, "usat16", "\t$Rd, $sat_imm, $Rn", []>,
3900 Requires<[IsARM,HasV6]>{
3904 let Inst{27-20} = 0b01101110;
3905 let Inst{11-4} = 0b11110011;
3906 let Inst{15-12} = Rd;
3907 let Inst{19-16} = sat_imm;
3911 def : ARMV6Pat<(int_arm_ssat GPRnopc:$a, imm1_32:$pos),
3912 (SSAT imm1_32:$pos, GPRnopc:$a, 0)>;
3913 def : ARMV6Pat<(int_arm_usat GPRnopc:$a, imm0_31:$pos),
3914 (USAT imm0_31:$pos, GPRnopc:$a, 0)>;
3915 def : ARMPat<(ARMssatnoshift GPRnopc:$Rn, imm0_31:$imm),
3916 (SSAT imm0_31:$imm, GPRnopc:$Rn, 0)>;
3917 def : ARMPat<(ARMusatnoshift GPRnopc:$Rn, imm0_31:$imm),
3918 (USAT imm0_31:$imm, GPRnopc:$Rn, 0)>;
3919 def : ARMV6Pat<(int_arm_ssat16 GPRnopc:$a, imm1_16:$pos),
3920 (SSAT16 imm1_16:$pos, GPRnopc:$a)>;
3921 def : ARMV6Pat<(int_arm_usat16 GPRnopc:$a, imm0_15:$pos),
3922 (USAT16 imm0_15:$pos, GPRnopc:$a)>;
3924 //===----------------------------------------------------------------------===//
3925 // Bitwise Instructions.
3928 defm AND : AsI1_bin_irs<0b0000, "and",
3929 IIC_iBITi, IIC_iBITr, IIC_iBITsr, and, 1>;
3930 defm ORR : AsI1_bin_irs<0b1100, "orr",
3931 IIC_iBITi, IIC_iBITr, IIC_iBITsr, or, 1>;
3932 defm EOR : AsI1_bin_irs<0b0001, "eor",
3933 IIC_iBITi, IIC_iBITr, IIC_iBITsr, xor, 1>;
3934 defm BIC : AsI1_bin_irs<0b1110, "bic",
3935 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3936 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
3938 // FIXME: bf_inv_mask_imm should be two operands, the lsb and the msb, just
3939 // like in the actual instruction encoding. The complexity of mapping the mask
3940 // to the lsb/msb pair should be handled by ISel, not encapsulated in the
3941 // instruction description.
3942 def BFC : I<(outs GPR:$Rd), (ins GPR:$src, bf_inv_mask_imm:$imm),
3943 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3944 "bfc", "\t$Rd, $imm", "$src = $Rd",
3945 [(set GPR:$Rd, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
3946 Requires<[IsARM, HasV6T2]> {
3949 let Inst{27-21} = 0b0111110;
3950 let Inst{6-0} = 0b0011111;
3951 let Inst{15-12} = Rd;
3952 let Inst{11-7} = imm{4-0}; // lsb
3953 let Inst{20-16} = imm{9-5}; // msb
3956 // A8.6.18 BFI - Bitfield insert (Encoding A1)
3957 def BFI:I<(outs GPRnopc:$Rd), (ins GPRnopc:$src, GPR:$Rn, bf_inv_mask_imm:$imm),
3958 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3959 "bfi", "\t$Rd, $Rn, $imm", "$src = $Rd",
3960 [(set GPRnopc:$Rd, (ARMbfi GPRnopc:$src, GPR:$Rn,
3961 bf_inv_mask_imm:$imm))]>,
3962 Requires<[IsARM, HasV6T2]> {
3966 let Inst{27-21} = 0b0111110;
3967 let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15
3968 let Inst{15-12} = Rd;
3969 let Inst{11-7} = imm{4-0}; // lsb
3970 let Inst{20-16} = imm{9-5}; // width
3974 def MVNr : AsI1<0b1111, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMVNr,
3975 "mvn", "\t$Rd, $Rm",
3976 [(set GPR:$Rd, (not GPR:$Rm))]>, UnaryDP, Sched<[WriteALU]> {
3980 let Inst{19-16} = 0b0000;
3981 let Inst{11-4} = 0b00000000;
3982 let Inst{15-12} = Rd;
3985 let Unpredictable{19-16} = 0b1111;
3987 def MVNsi : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_imm:$shift),
3988 DPSoRegImmFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3989 [(set GPR:$Rd, (not so_reg_imm:$shift))]>, UnaryDP,
3994 let Inst{19-16} = 0b0000;
3995 let Inst{15-12} = Rd;
3996 let Inst{11-5} = shift{11-5};
3998 let Inst{3-0} = shift{3-0};
4000 let Unpredictable{19-16} = 0b1111;
4002 def MVNsr : AsI1<0b1111, (outs GPRnopc:$Rd), (ins so_reg_reg:$shift),
4003 DPSoRegRegFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
4004 [(set GPRnopc:$Rd, (not so_reg_reg:$shift))]>, UnaryDP,
4009 let Inst{19-16} = 0b0000;
4010 let Inst{15-12} = Rd;
4011 let Inst{11-8} = shift{11-8};
4013 let Inst{6-5} = shift{6-5};
4015 let Inst{3-0} = shift{3-0};
4017 let Unpredictable{19-16} = 0b1111;
4019 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
4020 def MVNi : AsI1<0b1111, (outs GPR:$Rd), (ins mod_imm:$imm), DPFrm,
4021 IIC_iMVNi, "mvn", "\t$Rd, $imm",
4022 [(set GPR:$Rd, mod_imm_not:$imm)]>,UnaryDP, Sched<[WriteALU]> {
4026 let Inst{19-16} = 0b0000;
4027 let Inst{15-12} = Rd;
4028 let Inst{11-0} = imm;
4031 let AddedComplexity = 1 in
4032 def : ARMPat<(and GPR:$src, mod_imm_not:$imm),
4033 (BICri GPR:$src, mod_imm_not:$imm)>;
4035 //===----------------------------------------------------------------------===//
4036 // Multiply Instructions.
4038 class AsMul1I32<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
4039 string opc, string asm, list<dag> pattern>
4040 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
4044 let Inst{19-16} = Rd;
4045 let Inst{11-8} = Rm;
4048 class AsMul1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
4049 string opc, string asm, list<dag> pattern>
4050 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
4055 let Inst{19-16} = RdHi;
4056 let Inst{15-12} = RdLo;
4057 let Inst{11-8} = Rm;
4060 class AsMla1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
4061 string opc, string asm, list<dag> pattern>
4062 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
4067 let Inst{19-16} = RdHi;
4068 let Inst{15-12} = RdLo;
4069 let Inst{11-8} = Rm;
4073 // FIXME: The v5 pseudos are only necessary for the additional Constraint
4074 // property. Remove them when it's possible to add those properties
4075 // on an individual MachineInstr, not just an instruction description.
4076 let isCommutable = 1, TwoOperandAliasConstraint = "$Rn = $Rd" in {
4077 def MUL : AsMul1I32<0b0000000, (outs GPRnopc:$Rd),
4078 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4079 IIC_iMUL32, "mul", "\t$Rd, $Rn, $Rm",
4080 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))]>,
4081 Requires<[IsARM, HasV6]>,
4082 Sched<[WriteMUL32, ReadMUL, ReadMUL]> {
4083 let Inst{15-12} = 0b0000;
4084 let Unpredictable{15-12} = 0b1111;
4087 let Constraints = "@earlyclobber $Rd" in
4088 def MULv5: ARMPseudoExpand<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm,
4089 pred:$p, cc_out:$s),
4091 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))],
4092 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s)>,
4093 Requires<[IsARM, NoV6, UseMulOps]>,
4094 Sched<[WriteMUL32, ReadMUL, ReadMUL]>;
4097 def MLA : AsMul1I32<0b0000001, (outs GPRnopc:$Rd),
4098 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra),
4099 IIC_iMAC32, "mla", "\t$Rd, $Rn, $Rm, $Ra",
4100 [(set GPRnopc:$Rd, (add (mul GPRnopc:$Rn, GPRnopc:$Rm), GPRnopc:$Ra))]>,
4101 Requires<[IsARM, HasV6, UseMulOps]>,
4102 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]> {
4104 let Inst{15-12} = Ra;
4107 let Constraints = "@earlyclobber $Rd" in
4108 def MLAv5: ARMPseudoExpand<(outs GPRnopc:$Rd),
4109 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra,
4110 pred:$p, cc_out:$s), 4, IIC_iMAC32,
4111 [(set GPRnopc:$Rd, (add (mul GPRnopc:$Rn, GPRnopc:$Rm), GPRnopc:$Ra))],
4112 (MLA GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra, pred:$p, cc_out:$s)>,
4113 Requires<[IsARM, NoV6]>,
4114 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4116 def MLS : AMul1I<0b0000011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4117 IIC_iMAC32, "mls", "\t$Rd, $Rn, $Rm, $Ra",
4118 [(set GPR:$Rd, (sub GPR:$Ra, (mul GPR:$Rn, GPR:$Rm)))]>,
4119 Requires<[IsARM, HasV6T2, UseMulOps]>,
4120 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]> {
4125 let Inst{19-16} = Rd;
4126 let Inst{15-12} = Ra;
4127 let Inst{11-8} = Rm;
4131 // Extra precision multiplies with low / high results
4132 let hasSideEffects = 0 in {
4133 let isCommutable = 1 in {
4134 def SMULL : AsMul1I64<0b0000110, (outs GPR:$RdLo, GPR:$RdHi),
4135 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
4136 "smull", "\t$RdLo, $RdHi, $Rn, $Rm",
4137 [(set GPR:$RdLo, GPR:$RdHi,
4138 (smullohi GPR:$Rn, GPR:$Rm))]>,
4139 Requires<[IsARM, HasV6]>,
4140 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>;
4142 def UMULL : AsMul1I64<0b0000100, (outs GPR:$RdLo, GPR:$RdHi),
4143 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
4144 "umull", "\t$RdLo, $RdHi, $Rn, $Rm",
4145 [(set GPR:$RdLo, GPR:$RdHi,
4146 (umullohi GPR:$Rn, GPR:$Rm))]>,
4147 Requires<[IsARM, HasV6]>,
4148 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL]>;
4150 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
4151 def SMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
4152 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
4154 [(set GPR:$RdLo, GPR:$RdHi,
4155 (smullohi GPR:$Rn, GPR:$Rm))],
4156 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
4157 Requires<[IsARM, NoV6]>,
4158 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>;
4160 def UMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
4161 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
4163 [(set GPR:$RdLo, GPR:$RdHi,
4164 (umullohi GPR:$Rn, GPR:$Rm))],
4165 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
4166 Requires<[IsARM, NoV6]>,
4167 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>;
4171 // Multiply + accumulate
4172 def SMLAL : AsMla1I64<0b0000111, (outs GPR:$RdLo, GPR:$RdHi),
4173 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64,
4174 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4175 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>,
4176 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4177 def UMLAL : AsMla1I64<0b0000101, (outs GPR:$RdLo, GPR:$RdHi),
4178 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64,
4179 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4180 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>,
4181 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4183 def UMAAL : AMul1I <0b0000010, (outs GPR:$RdLo, GPR:$RdHi),
4184 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4186 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4187 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>,
4188 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]> {
4193 let Inst{19-16} = RdHi;
4194 let Inst{15-12} = RdLo;
4195 let Inst{11-8} = Rm;
4200 "@earlyclobber $RdLo,@earlyclobber $RdHi,$RLo = $RdLo,$RHi = $RdHi" in {
4201 def SMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
4202 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s),
4204 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi,
4205 pred:$p, cc_out:$s)>,
4206 Requires<[IsARM, NoV6]>,
4207 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4208 def UMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
4209 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s),
4211 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi,
4212 pred:$p, cc_out:$s)>,
4213 Requires<[IsARM, NoV6]>,
4214 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4219 // Most significant word multiply
4220 def SMMUL : AMul2I <0b0111010, 0b0001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4221 IIC_iMUL32, "smmul", "\t$Rd, $Rn, $Rm",
4222 [(set GPR:$Rd, (mulhs GPR:$Rn, GPR:$Rm))]>,
4223 Requires<[IsARM, HasV6]>,
4224 Sched<[WriteMUL32, ReadMUL, ReadMUL]> {
4225 let Inst{15-12} = 0b1111;
4228 def SMMULR : AMul2I <0b0111010, 0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4229 IIC_iMUL32, "smmulr", "\t$Rd, $Rn, $Rm",
4230 [(set GPR:$Rd, (ARMsmmlar GPR:$Rn, GPR:$Rm, (i32 0)))]>,
4231 Requires<[IsARM, HasV6]>,
4232 Sched<[WriteMUL32, ReadMUL, ReadMUL]> {
4233 let Inst{15-12} = 0b1111;
4236 def SMMLA : AMul2Ia <0b0111010, 0b0001, (outs GPR:$Rd),
4237 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4238 IIC_iMAC32, "smmla", "\t$Rd, $Rn, $Rm, $Ra",
4239 [(set GPR:$Rd, (add (mulhs GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
4240 Requires<[IsARM, HasV6, UseMulOps]>,
4241 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4243 def SMMLAR : AMul2Ia <0b0111010, 0b0011, (outs GPR:$Rd),
4244 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4245 IIC_iMAC32, "smmlar", "\t$Rd, $Rn, $Rm, $Ra",
4246 [(set GPR:$Rd, (ARMsmmlar GPR:$Rn, GPR:$Rm, GPR:$Ra))]>,
4247 Requires<[IsARM, HasV6]>,
4248 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4250 def SMMLS : AMul2Ia <0b0111010, 0b1101, (outs GPR:$Rd),
4251 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4252 IIC_iMAC32, "smmls", "\t$Rd, $Rn, $Rm, $Ra", []>,
4253 Requires<[IsARM, HasV6, UseMulOps]>,
4254 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4256 def SMMLSR : AMul2Ia <0b0111010, 0b1111, (outs GPR:$Rd),
4257 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4258 IIC_iMAC32, "smmlsr", "\t$Rd, $Rn, $Rm, $Ra",
4259 [(set GPR:$Rd, (ARMsmmlsr GPR:$Rn, GPR:$Rm, GPR:$Ra))]>,
4260 Requires<[IsARM, HasV6]>,
4261 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4263 multiclass AI_smul<string opc> {
4264 def BB : AMulxyI<0b0001011, 0b00, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4265 IIC_iMUL16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm",
4266 [(set GPR:$Rd, (bb_mul GPR:$Rn, GPR:$Rm))]>,
4267 Requires<[IsARM, HasV5TE]>,
4268 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4270 def BT : AMulxyI<0b0001011, 0b10, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4271 IIC_iMUL16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm",
4272 [(set GPR:$Rd, (bt_mul GPR:$Rn, GPR:$Rm))]>,
4273 Requires<[IsARM, HasV5TE]>,
4274 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4276 def TB : AMulxyI<0b0001011, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4277 IIC_iMUL16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm",
4278 [(set GPR:$Rd, (tb_mul GPR:$Rn, GPR:$Rm))]>,
4279 Requires<[IsARM, HasV5TE]>,
4280 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4282 def TT : AMulxyI<0b0001011, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4283 IIC_iMUL16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm",
4284 [(set GPR:$Rd, (tt_mul GPR:$Rn, GPR:$Rm))]>,
4285 Requires<[IsARM, HasV5TE]>,
4286 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4288 def WB : AMulxyI<0b0001001, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4289 IIC_iMUL16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm",
4290 [(set GPR:$Rd, (ARMsmulwb GPR:$Rn, GPR:$Rm))]>,
4291 Requires<[IsARM, HasV5TE]>,
4292 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4294 def WT : AMulxyI<0b0001001, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4295 IIC_iMUL16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm",
4296 [(set GPR:$Rd, (ARMsmulwt GPR:$Rn, GPR:$Rm))]>,
4297 Requires<[IsARM, HasV5TE]>,
4298 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4302 multiclass AI_smla<string opc> {
4303 let DecoderMethod = "DecodeSMLAInstruction" in {
4304 def BB : AMulxyIa<0b0001000, 0b00, (outs GPRnopc:$Rd),
4305 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4306 IIC_iMAC16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra",
4307 [(set GPRnopc:$Rd, (add GPR:$Ra,
4308 (bb_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4309 Requires<[IsARM, HasV5TE, UseMulOps]>,
4310 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4312 def BT : AMulxyIa<0b0001000, 0b10, (outs GPRnopc:$Rd),
4313 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4314 IIC_iMAC16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra",
4315 [(set GPRnopc:$Rd, (add GPR:$Ra,
4316 (bt_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4317 Requires<[IsARM, HasV5TE, UseMulOps]>,
4318 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4320 def TB : AMulxyIa<0b0001000, 0b01, (outs GPRnopc:$Rd),
4321 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4322 IIC_iMAC16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra",
4323 [(set GPRnopc:$Rd, (add GPR:$Ra,
4324 (tb_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4325 Requires<[IsARM, HasV5TE, UseMulOps]>,
4326 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4328 def TT : AMulxyIa<0b0001000, 0b11, (outs GPRnopc:$Rd),
4329 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4330 IIC_iMAC16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra",
4331 [(set GPRnopc:$Rd, (add GPR:$Ra,
4332 (tt_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4333 Requires<[IsARM, HasV5TE, UseMulOps]>,
4334 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4336 def WB : AMulxyIa<0b0001001, 0b00, (outs GPRnopc:$Rd),
4337 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4338 IIC_iMAC16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra",
4340 (add GPR:$Ra, (ARMsmulwb GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4341 Requires<[IsARM, HasV5TE, UseMulOps]>,
4342 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4344 def WT : AMulxyIa<0b0001001, 0b10, (outs GPRnopc:$Rd),
4345 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4346 IIC_iMAC16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra",
4348 (add GPR:$Ra, (ARMsmulwt GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4349 Requires<[IsARM, HasV5TE, UseMulOps]>,
4350 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4354 defm SMUL : AI_smul<"smul">;
4355 defm SMLA : AI_smla<"smla">;
4357 // Halfword multiply accumulate long: SMLAL<x><y>.
4358 class SMLAL<bits<2> opc1, string asm>
4359 : AMulxyI64<0b0001010, opc1,
4360 (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4361 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4362 IIC_iMAC64, asm, "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4363 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">,
4364 Requires<[IsARM, HasV5TE]>,
4365 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4367 def SMLALBB : SMLAL<0b00, "smlalbb">;
4368 def SMLALBT : SMLAL<0b10, "smlalbt">;
4369 def SMLALTB : SMLAL<0b01, "smlaltb">;
4370 def SMLALTT : SMLAL<0b11, "smlaltt">;
4372 def : ARMV5TEPat<(ARMsmlalbb GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4373 (SMLALBB $Rn, $Rm, $RLo, $RHi)>;
4374 def : ARMV5TEPat<(ARMsmlalbt GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4375 (SMLALBT $Rn, $Rm, $RLo, $RHi)>;
4376 def : ARMV5TEPat<(ARMsmlaltb GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4377 (SMLALTB $Rn, $Rm, $RLo, $RHi)>;
4378 def : ARMV5TEPat<(ARMsmlaltt GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4379 (SMLALTT $Rn, $Rm, $RLo, $RHi)>;
4381 // Helper class for AI_smld.
4382 class AMulDualIbase<bit long, bit sub, bit swap, dag oops, dag iops,
4383 InstrItinClass itin, string opc, string asm>
4384 : AI<oops, iops, MulFrm, itin, opc, asm, []>,
4385 Requires<[IsARM, HasV6]> {
4388 let Inst{27-23} = 0b01110;
4389 let Inst{22} = long;
4390 let Inst{21-20} = 0b00;
4391 let Inst{11-8} = Rm;
4398 class AMulDualI<bit long, bit sub, bit swap, dag oops, dag iops,
4399 InstrItinClass itin, string opc, string asm>
4400 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4402 let Inst{15-12} = 0b1111;
4403 let Inst{19-16} = Rd;
4405 class AMulDualIa<bit long, bit sub, bit swap, dag oops, dag iops,
4406 InstrItinClass itin, string opc, string asm>
4407 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4410 let Inst{19-16} = Rd;
4411 let Inst{15-12} = Ra;
4413 class AMulDualI64<bit long, bit sub, bit swap, dag oops, dag iops,
4414 InstrItinClass itin, string opc, string asm>
4415 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4418 let Inst{19-16} = RdHi;
4419 let Inst{15-12} = RdLo;
4422 multiclass AI_smld<bit sub, string opc> {
4424 def D : AMulDualIa<0, sub, 0, (outs GPRnopc:$Rd),
4425 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4426 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm, $Ra">,
4427 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4429 def DX: AMulDualIa<0, sub, 1, (outs GPRnopc:$Rd),
4430 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4431 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm, $Ra">,
4432 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4434 def LD: AMulDualI64<1, sub, 0, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4435 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4437 !strconcat(opc, "ld"), "\t$RdLo, $RdHi, $Rn, $Rm">,
4438 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">,
4439 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4441 def LDX : AMulDualI64<1, sub, 1, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4442 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4444 !strconcat(opc, "ldx"),"\t$RdLo, $RdHi, $Rn, $Rm">,
4445 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">,
4446 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>;
4449 defm SMLA : AI_smld<0, "smla">;
4450 defm SMLS : AI_smld<1, "smls">;
4452 def : ARMV6Pat<(int_arm_smlad GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4453 (SMLAD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>;
4454 def : ARMV6Pat<(int_arm_smladx GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4455 (SMLADX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>;
4456 def : ARMV6Pat<(int_arm_smlsd GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4457 (SMLSD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>;
4458 def : ARMV6Pat<(int_arm_smlsdx GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4459 (SMLSDX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>;
4460 def : ARMV6Pat<(ARMSmlald GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4461 (SMLALD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>;
4462 def : ARMV6Pat<(ARMSmlaldx GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4463 (SMLALDX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>;
4464 def : ARMV6Pat<(ARMSmlsld GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4465 (SMLSLD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>;
4466 def : ARMV6Pat<(ARMSmlsldx GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4467 (SMLSLDX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>;
4469 multiclass AI_sdml<bit sub, string opc> {
4471 def D:AMulDualI<0, sub, 0, (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm),
4472 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm">,
4473 Sched<[WriteMUL32, ReadMUL, ReadMUL]>;
4474 def DX:AMulDualI<0, sub, 1, (outs GPRnopc:$Rd),(ins GPRnopc:$Rn, GPRnopc:$Rm),
4475 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm">,
4476 Sched<[WriteMUL32, ReadMUL, ReadMUL]>;
4479 defm SMUA : AI_sdml<0, "smua">;
4480 defm SMUS : AI_sdml<1, "smus">;
4482 def : ARMV6Pat<(int_arm_smuad GPRnopc:$Rn, GPRnopc:$Rm),
4483 (SMUAD GPRnopc:$Rn, GPRnopc:$Rm)>;
4484 def : ARMV6Pat<(int_arm_smuadx GPRnopc:$Rn, GPRnopc:$Rm),
4485 (SMUADX GPRnopc:$Rn, GPRnopc:$Rm)>;
4486 def : ARMV6Pat<(int_arm_smusd GPRnopc:$Rn, GPRnopc:$Rm),
4487 (SMUSD GPRnopc:$Rn, GPRnopc:$Rm)>;
4488 def : ARMV6Pat<(int_arm_smusdx GPRnopc:$Rn, GPRnopc:$Rm),
4489 (SMUSDX GPRnopc:$Rn, GPRnopc:$Rm)>;
4491 //===----------------------------------------------------------------------===//
4492 // Division Instructions (ARMv7-A with virtualization extension)
4494 def SDIV : ADivA1I<0b001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV,
4495 "sdiv", "\t$Rd, $Rn, $Rm",
4496 [(set GPR:$Rd, (sdiv GPR:$Rn, GPR:$Rm))]>,
4497 Requires<[IsARM, HasDivideInARM]>,
4500 def UDIV : ADivA1I<0b011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV,
4501 "udiv", "\t$Rd, $Rn, $Rm",
4502 [(set GPR:$Rd, (udiv GPR:$Rn, GPR:$Rm))]>,
4503 Requires<[IsARM, HasDivideInARM]>,
4506 //===----------------------------------------------------------------------===//
4507 // Misc. Arithmetic Instructions.
4510 def CLZ : AMiscA1I<0b00010110, 0b0001, (outs GPR:$Rd), (ins GPR:$Rm),
4511 IIC_iUNAr, "clz", "\t$Rd, $Rm",
4512 [(set GPR:$Rd, (ctlz GPR:$Rm))]>, Requires<[IsARM, HasV5T]>,
4515 def RBIT : AMiscA1I<0b01101111, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
4516 IIC_iUNAr, "rbit", "\t$Rd, $Rm",
4517 [(set GPR:$Rd, (bitreverse GPR:$Rm))]>,
4518 Requires<[IsARM, HasV6T2]>,
4521 def REV : AMiscA1I<0b01101011, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
4522 IIC_iUNAr, "rev", "\t$Rd, $Rm",
4523 [(set GPR:$Rd, (bswap GPR:$Rm))]>, Requires<[IsARM, HasV6]>,
4526 let AddedComplexity = 5 in
4527 def REV16 : AMiscA1I<0b01101011, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
4528 IIC_iUNAr, "rev16", "\t$Rd, $Rm",
4529 [(set GPR:$Rd, (rotr (bswap GPR:$Rm), (i32 16)))]>,
4530 Requires<[IsARM, HasV6]>,
4533 def : ARMV6Pat<(srl (bswap (extloadi16 addrmode3:$addr)), (i32 16)),
4534 (REV16 (LDRH addrmode3:$addr))>;
4535 def : ARMV6Pat<(truncstorei16 (srl (bswap GPR:$Rn), (i32 16)), addrmode3:$addr),
4536 (STRH (REV16 GPR:$Rn), addrmode3:$addr)>;
4538 let AddedComplexity = 5 in
4539 def REVSH : AMiscA1I<0b01101111, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
4540 IIC_iUNAr, "revsh", "\t$Rd, $Rm",
4541 [(set GPR:$Rd, (sra (bswap GPR:$Rm), (i32 16)))]>,
4542 Requires<[IsARM, HasV6]>,
4545 def : ARMV6Pat<(or (sra (shl GPR:$Rm, (i32 24)), (i32 16)),
4546 (and (srl GPR:$Rm, (i32 8)), 0xFF)),
4549 def PKHBT : APKHI<0b01101000, 0, (outs GPRnopc:$Rd),
4550 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_lsl_amt:$sh),
4551 IIC_iALUsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh",
4552 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF),
4553 (and (shl GPRnopc:$Rm, pkh_lsl_amt:$sh),
4555 Requires<[IsARM, HasV6]>,
4556 Sched<[WriteALUsi, ReadALU]>;
4558 // Alternate cases for PKHBT where identities eliminate some nodes.
4559 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (and GPRnopc:$Rm, 0xFFFF0000)),
4560 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, 0)>;
4561 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (shl GPRnopc:$Rm, imm16_31:$sh)),
4562 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, imm16_31:$sh)>;
4564 // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
4565 // will match the pattern below.
4566 def PKHTB : APKHI<0b01101000, 1, (outs GPRnopc:$Rd),
4567 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_asr_amt:$sh),
4568 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh",
4569 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF0000),
4570 (and (sra GPRnopc:$Rm, pkh_asr_amt:$sh),
4572 Requires<[IsARM, HasV6]>,
4573 Sched<[WriteALUsi, ReadALU]>;
4575 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
4576 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
4577 // We also can not replace a srl (17..31) by an arithmetic shift we would use in
4578 // pkhtb src1, src2, asr (17..31).
4579 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4580 (srl GPRnopc:$src2, imm16:$sh)),
4581 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16:$sh)>;
4582 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4583 (sra GPRnopc:$src2, imm16_31:$sh)),
4584 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16_31:$sh)>;
4585 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4586 (and (srl GPRnopc:$src2, imm1_15:$sh), 0xFFFF)),
4587 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm1_15:$sh)>;
4589 //===----------------------------------------------------------------------===//
4593 // + CRC32{B,H,W} 0x04C11DB7
4594 // + CRC32C{B,H,W} 0x1EDC6F41
4597 class AI_crc32<bit C, bits<2> sz, string suffix, SDPatternOperator builtin>
4598 : AInoP<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm), MiscFrm, NoItinerary,
4599 !strconcat("crc32", suffix), "\t$Rd, $Rn, $Rm",
4600 [(set GPRnopc:$Rd, (builtin GPRnopc:$Rn, GPRnopc:$Rm))]>,
4601 Requires<[IsARM, HasV8, HasCRC]> {
4606 let Inst{31-28} = 0b1110;
4607 let Inst{27-23} = 0b00010;
4608 let Inst{22-21} = sz;
4610 let Inst{19-16} = Rn;
4611 let Inst{15-12} = Rd;
4612 let Inst{11-10} = 0b00;
4615 let Inst{7-4} = 0b0100;
4618 let Unpredictable{11-8} = 0b1101;
4621 def CRC32B : AI_crc32<0, 0b00, "b", int_arm_crc32b>;
4622 def CRC32CB : AI_crc32<1, 0b00, "cb", int_arm_crc32cb>;
4623 def CRC32H : AI_crc32<0, 0b01, "h", int_arm_crc32h>;
4624 def CRC32CH : AI_crc32<1, 0b01, "ch", int_arm_crc32ch>;
4625 def CRC32W : AI_crc32<0, 0b10, "w", int_arm_crc32w>;
4626 def CRC32CW : AI_crc32<1, 0b10, "cw", int_arm_crc32cw>;
4628 //===----------------------------------------------------------------------===//
4629 // ARMv8.1a Privilege Access Never extension
4633 def SETPAN : AInoP<(outs), (ins imm0_1:$imm), MiscFrm, NoItinerary, "setpan",
4634 "\t$imm", []>, Requires<[IsARM, HasV8, HasV8_1a]> {
4637 let Inst{31-28} = 0b1111;
4638 let Inst{27-20} = 0b00010001;
4639 let Inst{19-16} = 0b0000;
4640 let Inst{15-10} = 0b000000;
4643 let Inst{7-4} = 0b0000;
4644 let Inst{3-0} = 0b0000;
4646 let Unpredictable{19-16} = 0b1111;
4647 let Unpredictable{15-10} = 0b111111;
4648 let Unpredictable{8} = 0b1;
4649 let Unpredictable{3-0} = 0b1111;
4652 //===----------------------------------------------------------------------===//
4653 // Comparison Instructions...
4656 defm CMP : AI1_cmp_irs<0b1010, "cmp",
4657 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr, ARMcmp>;
4659 // ARMcmpZ can re-use the above instruction definitions.
4660 def : ARMPat<(ARMcmpZ GPR:$src, mod_imm:$imm),
4661 (CMPri GPR:$src, mod_imm:$imm)>;
4662 def : ARMPat<(ARMcmpZ GPR:$src, GPR:$rhs),
4663 (CMPrr GPR:$src, GPR:$rhs)>;
4664 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_imm:$rhs),
4665 (CMPrsi GPR:$src, so_reg_imm:$rhs)>;
4666 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_reg:$rhs),
4667 (CMPrsr GPR:$src, so_reg_reg:$rhs)>;
4669 // CMN register-integer
4670 let isCompare = 1, Defs = [CPSR] in {
4671 def CMNri : AI1<0b1011, (outs), (ins GPR:$Rn, mod_imm:$imm), DPFrm, IIC_iCMPi,
4672 "cmn", "\t$Rn, $imm",
4673 [(ARMcmn GPR:$Rn, mod_imm:$imm)]>,
4674 Sched<[WriteCMP, ReadALU]> {
4679 let Inst{19-16} = Rn;
4680 let Inst{15-12} = 0b0000;
4681 let Inst{11-0} = imm;
4683 let Unpredictable{15-12} = 0b1111;
4686 // CMN register-register/shift
4687 def CMNzrr : AI1<0b1011, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, IIC_iCMPr,
4688 "cmn", "\t$Rn, $Rm",
4689 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4690 GPR:$Rn, GPR:$Rm)]>, Sched<[WriteCMP, ReadALU, ReadALU]> {
4693 let isCommutable = 1;
4696 let Inst{19-16} = Rn;
4697 let Inst{15-12} = 0b0000;
4698 let Inst{11-4} = 0b00000000;
4701 let Unpredictable{15-12} = 0b1111;
4704 def CMNzrsi : AI1<0b1011, (outs),
4705 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, IIC_iCMPsr,
4706 "cmn", "\t$Rn, $shift",
4707 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4708 GPR:$Rn, so_reg_imm:$shift)]>,
4709 Sched<[WriteCMPsi, ReadALU]> {
4714 let Inst{19-16} = Rn;
4715 let Inst{15-12} = 0b0000;
4716 let Inst{11-5} = shift{11-5};
4718 let Inst{3-0} = shift{3-0};
4720 let Unpredictable{15-12} = 0b1111;
4723 def CMNzrsr : AI1<0b1011, (outs),
4724 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, IIC_iCMPsr,
4725 "cmn", "\t$Rn, $shift",
4726 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4727 GPRnopc:$Rn, so_reg_reg:$shift)]>,
4728 Sched<[WriteCMPsr, ReadALU]> {
4733 let Inst{19-16} = Rn;
4734 let Inst{15-12} = 0b0000;
4735 let Inst{11-8} = shift{11-8};
4737 let Inst{6-5} = shift{6-5};
4739 let Inst{3-0} = shift{3-0};
4741 let Unpredictable{15-12} = 0b1111;
4746 def : ARMPat<(ARMcmp GPR:$src, mod_imm_neg:$imm),
4747 (CMNri GPR:$src, mod_imm_neg:$imm)>;
4749 def : ARMPat<(ARMcmpZ GPR:$src, mod_imm_neg:$imm),
4750 (CMNri GPR:$src, mod_imm_neg:$imm)>;
4752 // Note that TST/TEQ don't set all the same flags that CMP does!
4753 defm TST : AI1_cmp_irs<0b1000, "tst",
4754 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
4755 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>, 1,
4756 "DecodeTSTInstruction">;
4757 defm TEQ : AI1_cmp_irs<0b1001, "teq",
4758 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
4759 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>, 1>;
4761 // Pseudo i64 compares for some floating point compares.
4762 let usesCustomInserter = 1, isBranch = 1, isTerminator = 1,
4764 def BCCi64 : PseudoInst<(outs),
4765 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, brtarget:$dst),
4767 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, bb:$dst)]>,
4770 def BCCZi64 : PseudoInst<(outs),
4771 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, brtarget:$dst), IIC_Br,
4772 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, 0, 0, bb:$dst)]>,
4774 } // usesCustomInserter
4777 // Conditional moves
4778 let hasSideEffects = 0 in {
4780 let isCommutable = 1, isSelect = 1 in
4781 def MOVCCr : ARMPseudoInst<(outs GPR:$Rd),
4782 (ins GPR:$false, GPR:$Rm, cmovpred:$p),
4784 [(set GPR:$Rd, (ARMcmov GPR:$false, GPR:$Rm,
4786 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4788 def MOVCCsi : ARMPseudoInst<(outs GPR:$Rd),
4789 (ins GPR:$false, so_reg_imm:$shift, cmovpred:$p),
4792 (ARMcmov GPR:$false, so_reg_imm:$shift,
4794 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4795 def MOVCCsr : ARMPseudoInst<(outs GPR:$Rd),
4796 (ins GPR:$false, so_reg_reg:$shift, cmovpred:$p),
4798 [(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_reg:$shift,
4800 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4803 let isMoveImm = 1 in
4805 : ARMPseudoInst<(outs GPR:$Rd),
4806 (ins GPR:$false, imm0_65535_expr:$imm, cmovpred:$p),
4808 [(set GPR:$Rd, (ARMcmov GPR:$false, imm0_65535:$imm,
4810 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>,
4813 let isMoveImm = 1 in
4814 def MOVCCi : ARMPseudoInst<(outs GPR:$Rd),
4815 (ins GPR:$false, mod_imm:$imm, cmovpred:$p),
4817 [(set GPR:$Rd, (ARMcmov GPR:$false, mod_imm:$imm,
4819 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4821 // Two instruction predicate mov immediate.
4822 let isMoveImm = 1 in
4824 : ARMPseudoInst<(outs GPR:$Rd),
4825 (ins GPR:$false, i32imm:$src, cmovpred:$p),
4827 [(set GPR:$Rd, (ARMcmov GPR:$false, imm:$src,
4829 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>;
4831 let isMoveImm = 1 in
4832 def MVNCCi : ARMPseudoInst<(outs GPR:$Rd),
4833 (ins GPR:$false, mod_imm:$imm, cmovpred:$p),
4835 [(set GPR:$Rd, (ARMcmov GPR:$false, mod_imm_not:$imm,
4837 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4842 //===----------------------------------------------------------------------===//
4843 // Atomic operations intrinsics
4846 def MemBarrierOptOperand : AsmOperandClass {
4847 let Name = "MemBarrierOpt";
4848 let ParserMethod = "parseMemBarrierOptOperand";
4850 def memb_opt : Operand<i32> {
4851 let PrintMethod = "printMemBOption";
4852 let ParserMatchClass = MemBarrierOptOperand;
4853 let DecoderMethod = "DecodeMemBarrierOption";
4856 def InstSyncBarrierOptOperand : AsmOperandClass {
4857 let Name = "InstSyncBarrierOpt";
4858 let ParserMethod = "parseInstSyncBarrierOptOperand";
4860 def instsyncb_opt : Operand<i32> {
4861 let PrintMethod = "printInstSyncBOption";
4862 let ParserMatchClass = InstSyncBarrierOptOperand;
4863 let DecoderMethod = "DecodeInstSyncBarrierOption";
4866 def TraceSyncBarrierOptOperand : AsmOperandClass {
4867 let Name = "TraceSyncBarrierOpt";
4868 let ParserMethod = "parseTraceSyncBarrierOptOperand";
4870 def tsb_opt : Operand<i32> {
4871 let PrintMethod = "printTraceSyncBOption";
4872 let ParserMatchClass = TraceSyncBarrierOptOperand;
4875 // Memory barriers protect the atomic sequences
4876 let hasSideEffects = 1 in {
4877 def DMB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4878 "dmb", "\t$opt", [(int_arm_dmb (i32 imm0_15:$opt))]>,
4879 Requires<[IsARM, HasDB]> {
4881 let Inst{31-4} = 0xf57ff05;
4882 let Inst{3-0} = opt;
4885 def DSB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4886 "dsb", "\t$opt", [(int_arm_dsb (i32 imm0_15:$opt))]>,
4887 Requires<[IsARM, HasDB]> {
4889 let Inst{31-4} = 0xf57ff04;
4890 let Inst{3-0} = opt;
4893 // ISB has only full system option
4894 def ISB : AInoP<(outs), (ins instsyncb_opt:$opt), MiscFrm, NoItinerary,
4895 "isb", "\t$opt", [(int_arm_isb (i32 imm0_15:$opt))]>,
4896 Requires<[IsARM, HasDB]> {
4898 let Inst{31-4} = 0xf57ff06;
4899 let Inst{3-0} = opt;
4902 let hasNoSchedulingInfo = 1 in
4903 def TSB : AInoP<(outs), (ins tsb_opt:$opt), MiscFrm, NoItinerary,
4904 "tsb", "\t$opt", []>, Requires<[IsARM, HasV8_4a]> {
4905 let Inst{31-0} = 0xe320f012;
4910 // Armv8.5-A speculation barrier
4911 def SB : AInoP<(outs), (ins), MiscFrm, NoItinerary, "sb", "", []>,
4912 Requires<[IsARM, HasSB]>, Sched<[]> {
4913 let Inst{31-0} = 0xf57ff070;
4914 let Unpredictable = 0x000fff0f;
4915 let hasSideEffects = 1;
4918 let usesCustomInserter = 1, Defs = [CPSR], hasNoSchedulingInfo = 1 in {
4919 // Pseudo instruction that combines movs + predicated rsbmi
4920 // to implement integer ABS
4921 def ABS : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$src), 8, NoItinerary, []>;
4924 let usesCustomInserter = 1, Defs = [CPSR], hasNoSchedulingInfo = 1 in {
4925 def COPY_STRUCT_BYVAL_I32 : PseudoInst<
4926 (outs), (ins GPR:$dst, GPR:$src, i32imm:$size, i32imm:$alignment),
4928 [(ARMcopystructbyval GPR:$dst, GPR:$src, imm:$size, imm:$alignment)]>;
4931 let hasPostISelHook = 1, Constraints = "$newdst = $dst, $newsrc = $src" in {
4932 // %newsrc, %newdst = MEMCPY %dst, %src, N, ...N scratch regs...
4933 // Copies N registers worth of memory from address %src to address %dst
4934 // and returns the incremented addresses. N scratch register will
4935 // be attached for the copy to use.
4936 def MEMCPY : PseudoInst<
4937 (outs GPR:$newdst, GPR:$newsrc),
4938 (ins GPR:$dst, GPR:$src, i32imm:$nreg, variable_ops),
4940 [(set GPR:$newdst, GPR:$newsrc,
4941 (ARMmemcopy GPR:$dst, GPR:$src, imm:$nreg))]>;
4944 def ldrex_1 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4945 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4948 def ldrex_2 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4949 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4952 def ldrex_4 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4953 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4956 def strex_1 : PatFrag<(ops node:$val, node:$ptr),
4957 (int_arm_strex node:$val, node:$ptr), [{
4958 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4961 def strex_2 : PatFrag<(ops node:$val, node:$ptr),
4962 (int_arm_strex node:$val, node:$ptr), [{
4963 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4966 def strex_4 : PatFrag<(ops node:$val, node:$ptr),
4967 (int_arm_strex node:$val, node:$ptr), [{
4968 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4971 def ldaex_1 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4972 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4975 def ldaex_2 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4976 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4979 def ldaex_4 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4980 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4983 def stlex_1 : PatFrag<(ops node:$val, node:$ptr),
4984 (int_arm_stlex node:$val, node:$ptr), [{
4985 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4988 def stlex_2 : PatFrag<(ops node:$val, node:$ptr),
4989 (int_arm_stlex node:$val, node:$ptr), [{
4990 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4993 def stlex_4 : PatFrag<(ops node:$val, node:$ptr),
4994 (int_arm_stlex node:$val, node:$ptr), [{
4995 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4998 let mayLoad = 1 in {
4999 def LDREXB : AIldrex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
5000 NoItinerary, "ldrexb", "\t$Rt, $addr",
5001 [(set GPR:$Rt, (ldrex_1 addr_offset_none:$addr))]>;
5002 def LDREXH : AIldrex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
5003 NoItinerary, "ldrexh", "\t$Rt, $addr",
5004 [(set GPR:$Rt, (ldrex_2 addr_offset_none:$addr))]>;
5005 def LDREX : AIldrex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
5006 NoItinerary, "ldrex", "\t$Rt, $addr",
5007 [(set GPR:$Rt, (ldrex_4 addr_offset_none:$addr))]>;
5008 let hasExtraDefRegAllocReq = 1 in
5009 def LDREXD : AIldrex<0b01, (outs GPRPairOp:$Rt),(ins addr_offset_none:$addr),
5010 NoItinerary, "ldrexd", "\t$Rt, $addr", []> {
5011 let DecoderMethod = "DecodeDoubleRegLoad";
5014 def LDAEXB : AIldaex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
5015 NoItinerary, "ldaexb", "\t$Rt, $addr",
5016 [(set GPR:$Rt, (ldaex_1 addr_offset_none:$addr))]>;
5017 def LDAEXH : AIldaex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
5018 NoItinerary, "ldaexh", "\t$Rt, $addr",
5019 [(set GPR:$Rt, (ldaex_2 addr_offset_none:$addr))]>;
5020 def LDAEX : AIldaex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
5021 NoItinerary, "ldaex", "\t$Rt, $addr",
5022 [(set GPR:$Rt, (ldaex_4 addr_offset_none:$addr))]>;
5023 let hasExtraDefRegAllocReq = 1 in
5024 def LDAEXD : AIldaex<0b01, (outs GPRPairOp:$Rt),(ins addr_offset_none:$addr),
5025 NoItinerary, "ldaexd", "\t$Rt, $addr", []> {
5026 let DecoderMethod = "DecodeDoubleRegLoad";
5030 let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
5031 def STREXB: AIstrex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5032 NoItinerary, "strexb", "\t$Rd, $Rt, $addr",
5033 [(set GPR:$Rd, (strex_1 GPR:$Rt,
5034 addr_offset_none:$addr))]>;
5035 def STREXH: AIstrex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5036 NoItinerary, "strexh", "\t$Rd, $Rt, $addr",
5037 [(set GPR:$Rd, (strex_2 GPR:$Rt,
5038 addr_offset_none:$addr))]>;
5039 def STREX : AIstrex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5040 NoItinerary, "strex", "\t$Rd, $Rt, $addr",
5041 [(set GPR:$Rd, (strex_4 GPR:$Rt,
5042 addr_offset_none:$addr))]>;
5043 let hasExtraSrcRegAllocReq = 1 in
5044 def STREXD : AIstrex<0b01, (outs GPR:$Rd),
5045 (ins GPRPairOp:$Rt, addr_offset_none:$addr),
5046 NoItinerary, "strexd", "\t$Rd, $Rt, $addr", []> {
5047 let DecoderMethod = "DecodeDoubleRegStore";
5049 def STLEXB: AIstlex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5050 NoItinerary, "stlexb", "\t$Rd, $Rt, $addr",
5052 (stlex_1 GPR:$Rt, addr_offset_none:$addr))]>;
5053 def STLEXH: AIstlex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5054 NoItinerary, "stlexh", "\t$Rd, $Rt, $addr",
5056 (stlex_2 GPR:$Rt, addr_offset_none:$addr))]>;
5057 def STLEX : AIstlex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5058 NoItinerary, "stlex", "\t$Rd, $Rt, $addr",
5060 (stlex_4 GPR:$Rt, addr_offset_none:$addr))]>;
5061 let hasExtraSrcRegAllocReq = 1 in
5062 def STLEXD : AIstlex<0b01, (outs GPR:$Rd),
5063 (ins GPRPairOp:$Rt, addr_offset_none:$addr),
5064 NoItinerary, "stlexd", "\t$Rd, $Rt, $addr", []> {
5065 let DecoderMethod = "DecodeDoubleRegStore";
5069 def CLREX : AXI<(outs), (ins), MiscFrm, NoItinerary, "clrex",
5071 Requires<[IsARM, HasV6K]> {
5072 let Inst{31-0} = 0b11110101011111111111000000011111;
5075 def : ARMPat<(strex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr),
5076 (STREXB GPR:$Rt, addr_offset_none:$addr)>;
5077 def : ARMPat<(strex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr),
5078 (STREXH GPR:$Rt, addr_offset_none:$addr)>;
5080 def : ARMPat<(stlex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr),
5081 (STLEXB GPR:$Rt, addr_offset_none:$addr)>;
5082 def : ARMPat<(stlex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr),
5083 (STLEXH GPR:$Rt, addr_offset_none:$addr)>;
5085 class acquiring_load<PatFrag base>
5086 : PatFrag<(ops node:$ptr), (base node:$ptr), [{
5087 AtomicOrdering Ordering = cast<AtomicSDNode>(N)->getOrdering();
5088 return isAcquireOrStronger(Ordering);
5091 def atomic_load_acquire_8 : acquiring_load<atomic_load_8>;
5092 def atomic_load_acquire_16 : acquiring_load<atomic_load_16>;
5093 def atomic_load_acquire_32 : acquiring_load<atomic_load_32>;
5095 class releasing_store<PatFrag base>
5096 : PatFrag<(ops node:$ptr, node:$val), (base node:$ptr, node:$val), [{
5097 AtomicOrdering Ordering = cast<AtomicSDNode>(N)->getOrdering();
5098 return isReleaseOrStronger(Ordering);
5101 def atomic_store_release_8 : releasing_store<atomic_store_8>;
5102 def atomic_store_release_16 : releasing_store<atomic_store_16>;
5103 def atomic_store_release_32 : releasing_store<atomic_store_32>;
5105 let AddedComplexity = 8 in {
5106 def : ARMPat<(atomic_load_acquire_8 addr_offset_none:$addr), (LDAB addr_offset_none:$addr)>;
5107 def : ARMPat<(atomic_load_acquire_16 addr_offset_none:$addr), (LDAH addr_offset_none:$addr)>;
5108 def : ARMPat<(atomic_load_acquire_32 addr_offset_none:$addr), (LDA addr_offset_none:$addr)>;
5109 def : ARMPat<(atomic_store_release_8 addr_offset_none:$addr, GPR:$val), (STLB GPR:$val, addr_offset_none:$addr)>;
5110 def : ARMPat<(atomic_store_release_16 addr_offset_none:$addr, GPR:$val), (STLH GPR:$val, addr_offset_none:$addr)>;
5111 def : ARMPat<(atomic_store_release_32 addr_offset_none:$addr, GPR:$val), (STL GPR:$val, addr_offset_none:$addr)>;
5114 // SWP/SWPB are deprecated in V6/V7 and optional in v7VE.
5115 // FIXME Use InstAlias to generate LDREX/STREX pairs instead.
5116 let mayLoad = 1, mayStore = 1 in {
5117 def SWP : AIswp<0, (outs GPRnopc:$Rt),
5118 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swp", []>,
5119 Requires<[IsARM,PreV8]>;
5120 def SWPB: AIswp<1, (outs GPRnopc:$Rt),
5121 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swpb", []>,
5122 Requires<[IsARM,PreV8]>;
5125 //===----------------------------------------------------------------------===//
5126 // Coprocessor Instructions.
5129 def CDP : ABI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
5130 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
5131 NoItinerary, "cdp", "\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
5132 [(int_arm_cdp timm:$cop, timm:$opc1, timm:$CRd, timm:$CRn,
5133 timm:$CRm, timm:$opc2)]>,
5134 Requires<[IsARM,PreV8]> {
5142 let Inst{3-0} = CRm;
5144 let Inst{7-5} = opc2;
5145 let Inst{11-8} = cop;
5146 let Inst{15-12} = CRd;
5147 let Inst{19-16} = CRn;
5148 let Inst{23-20} = opc1;
5150 let DecoderNamespace = "CoProc";
5153 def CDP2 : ABXI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
5154 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
5155 NoItinerary, "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
5156 [(int_arm_cdp2 timm:$cop, timm:$opc1, timm:$CRd, timm:$CRn,
5157 timm:$CRm, timm:$opc2)]>,
5158 Requires<[IsARM,PreV8]> {
5159 let Inst{31-28} = 0b1111;
5167 let Inst{3-0} = CRm;
5169 let Inst{7-5} = opc2;
5170 let Inst{11-8} = cop;
5171 let Inst{15-12} = CRd;
5172 let Inst{19-16} = CRn;
5173 let Inst{23-20} = opc1;
5175 let DecoderNamespace = "CoProc";
5178 class ACI<dag oops, dag iops, string opc, string asm,
5179 list<dag> pattern, IndexMode im = IndexModeNone>
5180 : I<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
5181 opc, asm, "", pattern> {
5182 let Inst{27-25} = 0b110;
5184 class ACInoP<dag oops, dag iops, string opc, string asm,
5185 list<dag> pattern, IndexMode im = IndexModeNone>
5186 : InoP<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
5187 opc, asm, "", pattern> {
5188 let Inst{31-28} = 0b1111;
5189 let Inst{27-25} = 0b110;
5192 let DecoderNamespace = "CoProc" in {
5193 multiclass LdStCop<bit load, bit Dbit, string asm, list<dag> pattern> {
5194 def _OFFSET : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
5195 asm, "\t$cop, $CRd, $addr", pattern> {
5199 let Inst{24} = 1; // P = 1
5200 let Inst{23} = addr{8};
5201 let Inst{22} = Dbit;
5202 let Inst{21} = 0; // W = 0
5203 let Inst{20} = load;
5204 let Inst{19-16} = addr{12-9};
5205 let Inst{15-12} = CRd;
5206 let Inst{11-8} = cop;
5207 let Inst{7-0} = addr{7-0};
5208 let DecoderMethod = "DecodeCopMemInstruction";
5210 def _PRE : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr),
5211 asm, "\t$cop, $CRd, $addr!", [], IndexModePre> {
5215 let Inst{24} = 1; // P = 1
5216 let Inst{23} = addr{8};
5217 let Inst{22} = Dbit;
5218 let Inst{21} = 1; // W = 1
5219 let Inst{20} = load;
5220 let Inst{19-16} = addr{12-9};
5221 let Inst{15-12} = CRd;
5222 let Inst{11-8} = cop;
5223 let Inst{7-0} = addr{7-0};
5224 let DecoderMethod = "DecodeCopMemInstruction";
5226 def _POST: ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
5227 postidx_imm8s4:$offset),
5228 asm, "\t$cop, $CRd, $addr, $offset", [], IndexModePost> {
5233 let Inst{24} = 0; // P = 0
5234 let Inst{23} = offset{8};
5235 let Inst{22} = Dbit;
5236 let Inst{21} = 1; // W = 1
5237 let Inst{20} = load;
5238 let Inst{19-16} = addr;
5239 let Inst{15-12} = CRd;
5240 let Inst{11-8} = cop;
5241 let Inst{7-0} = offset{7-0};
5242 let DecoderMethod = "DecodeCopMemInstruction";
5244 def _OPTION : ACI<(outs),
5245 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
5246 coproc_option_imm:$option),
5247 asm, "\t$cop, $CRd, $addr, $option", []> {
5252 let Inst{24} = 0; // P = 0
5253 let Inst{23} = 1; // U = 1
5254 let Inst{22} = Dbit;
5255 let Inst{21} = 0; // W = 0
5256 let Inst{20} = load;
5257 let Inst{19-16} = addr;
5258 let Inst{15-12} = CRd;
5259 let Inst{11-8} = cop;
5260 let Inst{7-0} = option;
5261 let DecoderMethod = "DecodeCopMemInstruction";
5264 multiclass LdSt2Cop<bit load, bit Dbit, string asm, list<dag> pattern> {
5265 def _OFFSET : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
5266 asm, "\t$cop, $CRd, $addr", pattern> {
5270 let Inst{24} = 1; // P = 1
5271 let Inst{23} = addr{8};
5272 let Inst{22} = Dbit;
5273 let Inst{21} = 0; // W = 0
5274 let Inst{20} = load;
5275 let Inst{19-16} = addr{12-9};
5276 let Inst{15-12} = CRd;
5277 let Inst{11-8} = cop;
5278 let Inst{7-0} = addr{7-0};
5279 let DecoderMethod = "DecodeCopMemInstruction";
5281 def _PRE : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr),
5282 asm, "\t$cop, $CRd, $addr!", [], IndexModePre> {
5286 let Inst{24} = 1; // P = 1
5287 let Inst{23} = addr{8};
5288 let Inst{22} = Dbit;
5289 let Inst{21} = 1; // W = 1
5290 let Inst{20} = load;
5291 let Inst{19-16} = addr{12-9};
5292 let Inst{15-12} = CRd;
5293 let Inst{11-8} = cop;
5294 let Inst{7-0} = addr{7-0};
5295 let DecoderMethod = "DecodeCopMemInstruction";
5297 def _POST: ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
5298 postidx_imm8s4:$offset),
5299 asm, "\t$cop, $CRd, $addr, $offset", [], IndexModePost> {
5304 let Inst{24} = 0; // P = 0
5305 let Inst{23} = offset{8};
5306 let Inst{22} = Dbit;
5307 let Inst{21} = 1; // W = 1
5308 let Inst{20} = load;
5309 let Inst{19-16} = addr;
5310 let Inst{15-12} = CRd;
5311 let Inst{11-8} = cop;
5312 let Inst{7-0} = offset{7-0};
5313 let DecoderMethod = "DecodeCopMemInstruction";
5315 def _OPTION : ACInoP<(outs),
5316 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
5317 coproc_option_imm:$option),
5318 asm, "\t$cop, $CRd, $addr, $option", []> {
5323 let Inst{24} = 0; // P = 0
5324 let Inst{23} = 1; // U = 1
5325 let Inst{22} = Dbit;
5326 let Inst{21} = 0; // W = 0
5327 let Inst{20} = load;
5328 let Inst{19-16} = addr;
5329 let Inst{15-12} = CRd;
5330 let Inst{11-8} = cop;
5331 let Inst{7-0} = option;
5332 let DecoderMethod = "DecodeCopMemInstruction";
5336 defm LDC : LdStCop <1, 0, "ldc", [(int_arm_ldc timm:$cop, timm:$CRd, addrmode5:$addr)]>;
5337 defm LDCL : LdStCop <1, 1, "ldcl", [(int_arm_ldcl timm:$cop, timm:$CRd, addrmode5:$addr)]>;
5338 defm LDC2 : LdSt2Cop<1, 0, "ldc2", [(int_arm_ldc2 timm:$cop, timm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>;
5339 defm LDC2L : LdSt2Cop<1, 1, "ldc2l", [(int_arm_ldc2l timm:$cop, timm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>;
5341 defm STC : LdStCop <0, 0, "stc", [(int_arm_stc timm:$cop, timm:$CRd, addrmode5:$addr)]>;
5342 defm STCL : LdStCop <0, 1, "stcl", [(int_arm_stcl timm:$cop, timm:$CRd, addrmode5:$addr)]>;
5343 defm STC2 : LdSt2Cop<0, 0, "stc2", [(int_arm_stc2 timm:$cop, timm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>;
5344 defm STC2L : LdSt2Cop<0, 1, "stc2l", [(int_arm_stc2l timm:$cop, timm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>;
5346 } // DecoderNamespace = "CoProc"
5348 //===----------------------------------------------------------------------===//
5349 // Move between coprocessor and ARM core register.
5352 class MovRCopro<string opc, bit direction, dag oops, dag iops,
5354 : ABI<0b1110, oops, iops, NoItinerary, opc,
5355 "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2", pattern> {
5356 let Inst{20} = direction;
5366 let Inst{15-12} = Rt;
5367 let Inst{11-8} = cop;
5368 let Inst{23-21} = opc1;
5369 let Inst{7-5} = opc2;
5370 let Inst{3-0} = CRm;
5371 let Inst{19-16} = CRn;
5373 let DecoderNamespace = "CoProc";
5376 def MCR : MovRCopro<"mcr", 0 /* from ARM core register to coprocessor */,
5378 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5379 c_imm:$CRm, imm0_7:$opc2),
5380 [(int_arm_mcr timm:$cop, timm:$opc1, GPR:$Rt, timm:$CRn,
5381 timm:$CRm, timm:$opc2)]>,
5382 ComplexDeprecationPredicate<"MCR">;
5383 def : ARMInstAlias<"mcr${p} $cop, $opc1, $Rt, $CRn, $CRm",
5384 (MCR p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5385 c_imm:$CRm, 0, pred:$p)>;
5386 def MRC : MovRCopro<"mrc", 1 /* from coprocessor to ARM core register */,
5387 (outs GPRwithAPSR:$Rt),
5388 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
5390 def : ARMInstAlias<"mrc${p} $cop, $opc1, $Rt, $CRn, $CRm",
5391 (MRC GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
5392 c_imm:$CRm, 0, pred:$p)>;
5394 def : ARMPat<(int_arm_mrc timm:$cop, timm:$opc1, timm:$CRn, timm:$CRm, timm:$opc2),
5395 (MRC p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2)>;
5397 class MovRCopro2<string opc, bit direction, dag oops, dag iops,
5399 : ABXI<0b1110, oops, iops, NoItinerary,
5400 !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), pattern> {
5401 let Inst{31-24} = 0b11111110;
5402 let Inst{20} = direction;
5412 let Inst{15-12} = Rt;
5413 let Inst{11-8} = cop;
5414 let Inst{23-21} = opc1;
5415 let Inst{7-5} = opc2;
5416 let Inst{3-0} = CRm;
5417 let Inst{19-16} = CRn;
5419 let DecoderNamespace = "CoProc";
5422 def MCR2 : MovRCopro2<"mcr2", 0 /* from ARM core register to coprocessor */,
5424 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5425 c_imm:$CRm, imm0_7:$opc2),
5426 [(int_arm_mcr2 timm:$cop, timm:$opc1, GPR:$Rt, timm:$CRn,
5427 timm:$CRm, timm:$opc2)]>,
5428 Requires<[IsARM,PreV8]>;
5429 def : ARMInstAlias<"mcr2 $cop, $opc1, $Rt, $CRn, $CRm",
5430 (MCR2 p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5432 def MRC2 : MovRCopro2<"mrc2", 1 /* from coprocessor to ARM core register */,
5433 (outs GPRwithAPSR:$Rt),
5434 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
5436 Requires<[IsARM,PreV8]>;
5437 def : ARMInstAlias<"mrc2 $cop, $opc1, $Rt, $CRn, $CRm",
5438 (MRC2 GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
5441 def : ARMV5TPat<(int_arm_mrc2 timm:$cop, timm:$opc1, timm:$CRn,
5442 timm:$CRm, timm:$opc2),
5443 (MRC2 p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2)>;
5445 class MovRRCopro<string opc, bit direction, dag oops, dag iops, list<dag>
5447 : ABI<0b1100, oops, iops, NoItinerary, opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm",
5450 let Inst{23-21} = 0b010;
5451 let Inst{20} = direction;
5459 let Inst{15-12} = Rt;
5460 let Inst{19-16} = Rt2;
5461 let Inst{11-8} = cop;
5462 let Inst{7-4} = opc1;
5463 let Inst{3-0} = CRm;
5466 def MCRR : MovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */,
5467 (outs), (ins p_imm:$cop, imm0_15:$opc1, GPRnopc:$Rt,
5468 GPRnopc:$Rt2, c_imm:$CRm),
5469 [(int_arm_mcrr timm:$cop, timm:$opc1, GPRnopc:$Rt,
5470 GPRnopc:$Rt2, timm:$CRm)]>;
5471 def MRRC : MovRRCopro<"mrrc", 1 /* from coprocessor to ARM core register */,
5472 (outs GPRnopc:$Rt, GPRnopc:$Rt2),
5473 (ins p_imm:$cop, imm0_15:$opc1, c_imm:$CRm), []>;
5475 class MovRRCopro2<string opc, bit direction, dag oops, dag iops,
5476 list<dag> pattern = []>
5477 : ABXI<0b1100, oops, iops, NoItinerary,
5478 !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern>,
5479 Requires<[IsARM,PreV8]> {
5480 let Inst{31-28} = 0b1111;
5481 let Inst{23-21} = 0b010;
5482 let Inst{20} = direction;
5490 let Inst{15-12} = Rt;
5491 let Inst{19-16} = Rt2;
5492 let Inst{11-8} = cop;
5493 let Inst{7-4} = opc1;
5494 let Inst{3-0} = CRm;
5496 let DecoderMethod = "DecoderForMRRC2AndMCRR2";
5499 def MCRR2 : MovRRCopro2<"mcrr2", 0 /* from ARM core register to coprocessor */,
5500 (outs), (ins p_imm:$cop, imm0_15:$opc1, GPRnopc:$Rt,
5501 GPRnopc:$Rt2, c_imm:$CRm),
5502 [(int_arm_mcrr2 timm:$cop, timm:$opc1, GPRnopc:$Rt,
5503 GPRnopc:$Rt2, timm:$CRm)]>;
5505 def MRRC2 : MovRRCopro2<"mrrc2", 1 /* from coprocessor to ARM core register */,
5506 (outs GPRnopc:$Rt, GPRnopc:$Rt2),
5507 (ins p_imm:$cop, imm0_15:$opc1, c_imm:$CRm), []>;
5509 //===----------------------------------------------------------------------===//
5510 // Move between special register and ARM core register
5513 // Move to ARM core register from Special Register
5514 def MRS : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
5515 "mrs", "\t$Rd, apsr", []> {
5517 let Inst{23-16} = 0b00001111;
5518 let Unpredictable{19-17} = 0b111;
5520 let Inst{15-12} = Rd;
5522 let Inst{11-0} = 0b000000000000;
5523 let Unpredictable{11-0} = 0b110100001111;
5526 def : InstAlias<"mrs${p} $Rd, cpsr", (MRS GPRnopc:$Rd, pred:$p), 0>,
5529 // The MRSsys instruction is the MRS instruction from the ARM ARM,
5530 // section B9.3.9, with the R bit set to 1.
5531 def MRSsys : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
5532 "mrs", "\t$Rd, spsr", []> {
5534 let Inst{23-16} = 0b01001111;
5535 let Unpredictable{19-16} = 0b1111;
5537 let Inst{15-12} = Rd;
5539 let Inst{11-0} = 0b000000000000;
5540 let Unpredictable{11-0} = 0b110100001111;
5543 // However, the MRS (banked register) system instruction (ARMv7VE) *does* have a
5544 // separate encoding (distinguished by bit 5.
5545 def MRSbanked : ABI<0b0001, (outs GPRnopc:$Rd), (ins banked_reg:$banked),
5546 NoItinerary, "mrs", "\t$Rd, $banked", []>,
5547 Requires<[IsARM, HasVirtualization]> {
5552 let Inst{22} = banked{5}; // R bit
5553 let Inst{21-20} = 0b00;
5554 let Inst{19-16} = banked{3-0};
5555 let Inst{15-12} = Rd;
5556 let Inst{11-9} = 0b001;
5557 let Inst{8} = banked{4};
5558 let Inst{7-0} = 0b00000000;
5561 // Move from ARM core register to Special Register
5563 // No need to have both system and application versions of MSR (immediate) or
5564 // MSR (register), the encodings are the same and the assembly parser has no way
5565 // to distinguish between them. The mask operand contains the special register
5566 // (R Bit) in bit 4 and bits 3-0 contains the mask with the fields to be
5567 // accessed in the special register.
5568 let Defs = [CPSR] in
5569 def MSR : ABI<0b0001, (outs), (ins msr_mask:$mask, GPR:$Rn), NoItinerary,
5570 "msr", "\t$mask, $Rn", []> {
5575 let Inst{22} = mask{4}; // R bit
5576 let Inst{21-20} = 0b10;
5577 let Inst{19-16} = mask{3-0};
5578 let Inst{15-12} = 0b1111;
5579 let Inst{11-4} = 0b00000000;
5583 let Defs = [CPSR] in
5584 def MSRi : ABI<0b0011, (outs), (ins msr_mask:$mask, mod_imm:$imm), NoItinerary,
5585 "msr", "\t$mask, $imm", []> {
5590 let Inst{22} = mask{4}; // R bit
5591 let Inst{21-20} = 0b10;
5592 let Inst{19-16} = mask{3-0};
5593 let Inst{15-12} = 0b1111;
5594 let Inst{11-0} = imm;
5597 // However, the MSR (banked register) system instruction (ARMv7VE) *does* have a
5598 // separate encoding (distinguished by bit 5.
5599 def MSRbanked : ABI<0b0001, (outs), (ins banked_reg:$banked, GPRnopc:$Rn),
5600 NoItinerary, "msr", "\t$banked, $Rn", []>,
5601 Requires<[IsARM, HasVirtualization]> {
5606 let Inst{22} = banked{5}; // R bit
5607 let Inst{21-20} = 0b10;
5608 let Inst{19-16} = banked{3-0};
5609 let Inst{15-12} = 0b1111;
5610 let Inst{11-9} = 0b001;
5611 let Inst{8} = banked{4};
5612 let Inst{7-4} = 0b0000;
5616 // Dynamic stack allocation yields a _chkstk for Windows targets. These calls
5617 // are needed to probe the stack when allocating more than
5618 // 4k bytes in one go. Touching the stack at 4K increments is necessary to
5619 // ensure that the guard pages used by the OS virtual memory manager are
5620 // allocated in correct sequence.
5621 // The main point of having separate instruction are extra unmodelled effects
5622 // (compared to ordinary calls) like stack pointer change.
5624 def win__chkstk : SDNode<"ARMISD::WIN__CHKSTK", SDTNone,
5625 [SDNPHasChain, SDNPSideEffect]>;
5626 let usesCustomInserter = 1, Uses = [R4], Defs = [R4, SP], hasNoSchedulingInfo = 1 in
5627 def WIN__CHKSTK : PseudoInst<(outs), (ins), NoItinerary, [(win__chkstk)]>;
5629 def win__dbzchk : SDNode<"ARMISD::WIN__DBZCHK", SDT_WIN__DBZCHK,
5630 [SDNPHasChain, SDNPSideEffect, SDNPOutGlue]>;
5631 let usesCustomInserter = 1, Defs = [CPSR], hasNoSchedulingInfo = 1 in
5632 def WIN__DBZCHK : PseudoInst<(outs), (ins tGPR:$divisor), NoItinerary,
5633 [(win__dbzchk tGPR:$divisor)]>;
5635 //===----------------------------------------------------------------------===//
5639 // __aeabi_read_tp preserves the registers r1-r3.
5640 // This is a pseudo inst so that we can get the encoding right,
5641 // complete with fixup for the aeabi_read_tp function.
5642 // TPsoft is valid for ARM mode only, in case of Thumb mode a tTPsoft pattern
5643 // is defined in "ARMInstrThumb.td".
5645 Defs = [R0, R12, LR, CPSR], Uses = [SP] in {
5646 def TPsoft : ARMPseudoInst<(outs), (ins), 4, IIC_Br,
5647 [(set R0, ARMthread_pointer)]>, Sched<[WriteBr]>,
5648 Requires<[IsARM, IsReadTPSoft]>;
5651 // Reading thread pointer from coprocessor register
5652 def : ARMPat<(ARMthread_pointer), (MRC 15, 0, 13, 0, 3)>,
5653 Requires<[IsARM, IsReadTPHard]>;
5655 //===----------------------------------------------------------------------===//
5656 // SJLJ Exception handling intrinsics
5657 // eh_sjlj_setjmp() is an instruction sequence to store the return
5658 // address and save #0 in R0 for the non-longjmp case.
5659 // Since by its nature we may be coming from some other function to get
5660 // here, and we're using the stack frame for the containing function to
5661 // save/restore registers, we can't keep anything live in regs across
5662 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
5663 // when we get here from a longjmp(). We force everything out of registers
5664 // except for our own input by listing the relevant registers in Defs. By
5665 // doing so, we also cause the prologue/epilogue code to actively preserve
5666 // all of the callee-saved resgisters, which is exactly what we want.
5667 // A constant value is passed in $val, and we use the location as a scratch.
5669 // These are pseudo-instructions and are lowered to individual MC-insts, so
5670 // no encoding information is necessary.
5672 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
5673 Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15 ],
5674 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
5675 def Int_eh_sjlj_setjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
5677 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
5678 Requires<[IsARM, HasVFP2]>;
5682 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
5683 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
5684 def Int_eh_sjlj_setjmp_nofp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
5686 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
5687 Requires<[IsARM, NoVFP]>;
5690 // FIXME: Non-IOS version(s)
5691 let isBarrier = 1, hasSideEffects = 1, isTerminator = 1,
5692 Defs = [ R7, LR, SP ] in {
5693 def Int_eh_sjlj_longjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$scratch),
5695 [(ARMeh_sjlj_longjmp GPR:$src, GPR:$scratch)]>,
5699 let isBarrier = 1, hasSideEffects = 1, usesCustomInserter = 1 in
5700 def Int_eh_sjlj_setup_dispatch : PseudoInst<(outs), (ins), NoItinerary,
5701 [(ARMeh_sjlj_setup_dispatch)]>;
5703 // eh.sjlj.dispatchsetup pseudo-instruction.
5704 // This pseudo is used for both ARM and Thumb. Any differences are handled when
5705 // the pseudo is expanded (which happens before any passes that need the
5706 // instruction size).
5707 let isBarrier = 1 in
5708 def Int_eh_sjlj_dispatchsetup : PseudoInst<(outs), (ins), NoItinerary, []>;
5711 //===----------------------------------------------------------------------===//
5712 // Non-Instruction Patterns
5715 // ARMv4 indirect branch using (MOVr PC, dst)
5716 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in
5717 def MOVPCRX : ARMPseudoExpand<(outs), (ins GPR:$dst),
5718 4, IIC_Br, [(brind GPR:$dst)],
5719 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>,
5720 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
5722 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in
5723 def TAILJMPr4 : ARMPseudoExpand<(outs), (ins GPR:$dst),
5725 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>,
5726 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
5728 // Large immediate handling.
5730 // 32-bit immediate using two piece mod_imms or movw + movt.
5731 // This is a single pseudo instruction, the benefit is that it can be remat'd
5732 // as a single unit instead of having to handle reg inputs.
5733 // FIXME: Remove this when we can do generalized remat.
5734 let isReMaterializable = 1, isMoveImm = 1 in
5735 def MOVi32imm : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
5736 [(set GPR:$dst, (arm_i32imm:$src))]>,
5739 def LDRLIT_ga_abs : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iLoad_i,
5740 [(set GPR:$dst, (ARMWrapper tglobaladdr:$src))]>,
5741 Requires<[IsARM, DontUseMovt]>;
5743 // Pseudo instruction that combines movw + movt + add pc (if PIC).
5744 // It also makes it possible to rematerialize the instructions.
5745 // FIXME: Remove this when we can do generalized remat and when machine licm
5746 // can properly the instructions.
5747 let isReMaterializable = 1 in {
5748 def MOV_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5750 [(set GPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>,
5751 Requires<[IsARM, UseMovtInPic]>;
5753 def LDRLIT_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5756 (ARMWrapperPIC tglobaladdr:$addr))]>,
5757 Requires<[IsARM, DontUseMovtInPic]>;
5759 let AddedComplexity = 10 in
5760 def LDRLIT_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5763 (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
5764 Requires<[IsARM, DontUseMovtInPic]>;
5766 let AddedComplexity = 10 in
5767 def MOV_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5769 [(set GPR:$dst, (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
5770 Requires<[IsARM, UseMovtInPic]>;
5771 } // isReMaterializable
5773 // The many different faces of TLS access.
5774 def : ARMPat<(ARMWrapper tglobaltlsaddr :$dst),
5775 (MOVi32imm tglobaltlsaddr :$dst)>,
5776 Requires<[IsARM, UseMovt]>;
5778 def : Pat<(ARMWrapper tglobaltlsaddr:$src),
5779 (LDRLIT_ga_abs tglobaltlsaddr:$src)>,
5780 Requires<[IsARM, DontUseMovt]>;
5782 def : Pat<(ARMWrapperPIC tglobaltlsaddr:$addr),
5783 (MOV_ga_pcrel tglobaltlsaddr:$addr)>, Requires<[IsARM, UseMovtInPic]>;
5785 def : Pat<(ARMWrapperPIC tglobaltlsaddr:$addr),
5786 (LDRLIT_ga_pcrel tglobaltlsaddr:$addr)>,
5787 Requires<[IsARM, DontUseMovtInPic]>;
5788 let AddedComplexity = 10 in
5789 def : Pat<(load (ARMWrapperPIC tglobaltlsaddr:$addr)),
5790 (MOV_ga_pcrel_ldr tglobaltlsaddr:$addr)>,
5791 Requires<[IsARM, UseMovtInPic]>;
5794 // ConstantPool, GlobalAddress, and JumpTable
5795 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
5796 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
5797 Requires<[IsARM, UseMovt]>;
5798 def : ARMPat<(ARMWrapper texternalsym :$dst), (MOVi32imm texternalsym :$dst)>,
5799 Requires<[IsARM, UseMovt]>;
5800 def : ARMPat<(ARMWrapperJT tjumptable:$dst),
5801 (LEApcrelJT tjumptable:$dst)>;
5803 // TODO: add,sub,and, 3-instr forms?
5805 // Tail calls. These patterns also apply to Thumb mode.
5806 def : Pat<(ARMtcret tcGPR:$dst), (TCRETURNri tcGPR:$dst)>;
5807 def : Pat<(ARMtcret (i32 tglobaladdr:$dst)), (TCRETURNdi texternalsym:$dst)>;
5808 def : Pat<(ARMtcret (i32 texternalsym:$dst)), (TCRETURNdi texternalsym:$dst)>;
5811 def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>;
5812 def : ARMPat<(ARMcall_nolink texternalsym:$func),
5813 (BMOVPCB_CALL texternalsym:$func)>;
5815 // zextload i1 -> zextload i8
5816 def : ARMPat<(zextloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5817 def : ARMPat<(zextloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5819 // extload -> zextload
5820 def : ARMPat<(extloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5821 def : ARMPat<(extloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5822 def : ARMPat<(extloadi8 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5823 def : ARMPat<(extloadi8 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5825 def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
5827 def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
5828 def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
5831 def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
5832 (SMULBB GPR:$a, GPR:$b)>;
5833 def : ARMV5TEPat<(mul sext_16_node:$a, (sext_bottom_16 GPR:$b)),
5834 (SMULBB GPR:$a, GPR:$b)>;
5835 def : ARMV5TEPat<(mul sext_16_node:$a, (sext_top_16 GPR:$b)),
5836 (SMULBT GPR:$a, GPR:$b)>;
5837 def : ARMV5TEPat<(mul (sext_top_16 GPR:$a), sext_16_node:$b),
5838 (SMULTB GPR:$a, GPR:$b)>;
5839 def : ARMV5MOPat<(add GPR:$acc, (mul sext_16_node:$a, sext_16_node:$b)),
5840 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5841 def : ARMV5MOPat<(add GPR:$acc, (mul sext_16_node:$a, (sext_bottom_16 GPR:$b))),
5842 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5843 def : ARMV5MOPat<(add GPR:$acc, (mul sext_16_node:$a, (sext_top_16 GPR:$b))),
5844 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
5845 def : ARMV5MOPat<(add GPR:$acc, (mul (sext_top_16 GPR:$a), sext_16_node:$b)),
5846 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
5848 def : ARMV5TEPat<(int_arm_smulbb GPR:$a, GPR:$b),
5849 (SMULBB GPR:$a, GPR:$b)>;
5850 def : ARMV5TEPat<(int_arm_smulbt GPR:$a, GPR:$b),
5851 (SMULBT GPR:$a, GPR:$b)>;
5852 def : ARMV5TEPat<(int_arm_smultb GPR:$a, GPR:$b),
5853 (SMULTB GPR:$a, GPR:$b)>;
5854 def : ARMV5TEPat<(int_arm_smultt GPR:$a, GPR:$b),
5855 (SMULTT GPR:$a, GPR:$b)>;
5856 def : ARMV5TEPat<(int_arm_smulwb GPR:$a, GPR:$b),
5857 (SMULWB GPR:$a, GPR:$b)>;
5858 def : ARMV5TEPat<(int_arm_smulwt GPR:$a, GPR:$b),
5859 (SMULWT GPR:$a, GPR:$b)>;
5861 def : ARMV5TEPat<(int_arm_smlabb GPR:$a, GPR:$b, GPR:$acc),
5862 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5863 def : ARMV5TEPat<(int_arm_smlabt GPR:$a, GPR:$b, GPR:$acc),
5864 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
5865 def : ARMV5TEPat<(int_arm_smlatb GPR:$a, GPR:$b, GPR:$acc),
5866 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
5867 def : ARMV5TEPat<(int_arm_smlatt GPR:$a, GPR:$b, GPR:$acc),
5868 (SMLATT GPR:$a, GPR:$b, GPR:$acc)>;
5869 def : ARMV5TEPat<(int_arm_smlawb GPR:$a, GPR:$b, GPR:$acc),
5870 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
5871 def : ARMV5TEPat<(int_arm_smlawt GPR:$a, GPR:$b, GPR:$acc),
5872 (SMLAWT GPR:$a, GPR:$b, GPR:$acc)>;
5874 // Pre-v7 uses MCR for synchronization barriers.
5875 def : ARMPat<(ARMMemBarrierMCR GPR:$zero), (MCR 15, 0, GPR:$zero, 7, 10, 5)>,
5876 Requires<[IsARM, HasV6]>;
5878 // SXT/UXT with no rotate
5879 let AddedComplexity = 16 in {
5880 def : ARMV6Pat<(and GPR:$Src, 0x000000FF), (UXTB GPR:$Src, 0)>;
5881 def : ARMV6Pat<(and GPR:$Src, 0x0000FFFF), (UXTH GPR:$Src, 0)>;
5882 def : ARMV6Pat<(and GPR:$Src, 0x00FF00FF), (UXTB16 GPR:$Src, 0)>;
5883 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0x00FF)),
5884 (UXTAB GPR:$Rn, GPR:$Rm, 0)>;
5885 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0xFFFF)),
5886 (UXTAH GPR:$Rn, GPR:$Rm, 0)>;
5889 def : ARMV6Pat<(sext_inreg GPR:$Src, i8), (SXTB GPR:$Src, 0)>;
5890 def : ARMV6Pat<(sext_inreg GPR:$Src, i16), (SXTH GPR:$Src, 0)>;
5892 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i8)),
5893 (SXTAB GPR:$Rn, GPRnopc:$Rm, 0)>;
5894 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i16)),
5895 (SXTAH GPR:$Rn, GPRnopc:$Rm, 0)>;
5897 // Atomic load/store patterns
5898 def : ARMPat<(atomic_load_8 ldst_so_reg:$src),
5899 (LDRBrs ldst_so_reg:$src)>;
5900 def : ARMPat<(atomic_load_8 addrmode_imm12:$src),
5901 (LDRBi12 addrmode_imm12:$src)>;
5902 def : ARMPat<(atomic_load_16 addrmode3:$src),
5903 (LDRH addrmode3:$src)>;
5904 def : ARMPat<(atomic_load_32 ldst_so_reg:$src),
5905 (LDRrs ldst_so_reg:$src)>;
5906 def : ARMPat<(atomic_load_32 addrmode_imm12:$src),
5907 (LDRi12 addrmode_imm12:$src)>;
5908 def : ARMPat<(atomic_store_8 ldst_so_reg:$ptr, GPR:$val),
5909 (STRBrs GPR:$val, ldst_so_reg:$ptr)>;
5910 def : ARMPat<(atomic_store_8 addrmode_imm12:$ptr, GPR:$val),
5911 (STRBi12 GPR:$val, addrmode_imm12:$ptr)>;
5912 def : ARMPat<(atomic_store_16 addrmode3:$ptr, GPR:$val),
5913 (STRH GPR:$val, addrmode3:$ptr)>;
5914 def : ARMPat<(atomic_store_32 ldst_so_reg:$ptr, GPR:$val),
5915 (STRrs GPR:$val, ldst_so_reg:$ptr)>;
5916 def : ARMPat<(atomic_store_32 addrmode_imm12:$ptr, GPR:$val),
5917 (STRi12 GPR:$val, addrmode_imm12:$ptr)>;
5920 //===----------------------------------------------------------------------===//
5924 include "ARMInstrThumb.td"
5926 //===----------------------------------------------------------------------===//
5930 include "ARMInstrThumb2.td"
5932 //===----------------------------------------------------------------------===//
5933 // Floating Point Support
5936 include "ARMInstrVFP.td"
5938 //===----------------------------------------------------------------------===//
5939 // Advanced SIMD (NEON) Support
5942 include "ARMInstrNEON.td"
5944 //===----------------------------------------------------------------------===//
5948 include "ARMInstrMVE.td"
5950 //===----------------------------------------------------------------------===//
5951 // Assembler aliases
5955 def : InstAlias<"dmb", (DMB 0xf), 0>, Requires<[IsARM, HasDB]>;
5956 def : InstAlias<"dsb", (DSB 0xf), 0>, Requires<[IsARM, HasDB]>;
5957 def : InstAlias<"ssbb", (DSB 0x0), 1>, Requires<[IsARM, HasDB]>;
5958 def : InstAlias<"pssbb", (DSB 0x4), 1>, Requires<[IsARM, HasDB]>;
5959 def : InstAlias<"isb", (ISB 0xf), 0>, Requires<[IsARM, HasDB]>;
5960 // Armv8-R 'Data Full Barrier'
5961 def : InstAlias<"dfb", (DSB 0xc), 1>, Requires<[IsARM, HasDFB]>;
5963 // System instructions
5964 def : MnemonicAlias<"swi", "svc">;
5966 // Load / Store Multiple
5967 def : MnemonicAlias<"ldmfd", "ldm">;
5968 def : MnemonicAlias<"ldmia", "ldm">;
5969 def : MnemonicAlias<"ldmea", "ldmdb">;
5970 def : MnemonicAlias<"stmfd", "stmdb">;
5971 def : MnemonicAlias<"stmia", "stm">;
5972 def : MnemonicAlias<"stmea", "stm">;
5974 // PKHBT/PKHTB with default shift amount. PKHTB is equivalent to PKHBT with the
5975 // input operands swapped when the shift amount is zero (i.e., unspecified).
5976 def : InstAlias<"pkhbt${p} $Rd, $Rn, $Rm",
5977 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p), 0>,
5978 Requires<[IsARM, HasV6]>;
5979 def : InstAlias<"pkhtb${p} $Rd, $Rn, $Rm",
5980 (PKHBT GPRnopc:$Rd, GPRnopc:$Rm, GPRnopc:$Rn, 0, pred:$p), 0>,
5981 Requires<[IsARM, HasV6]>;
5983 // PUSH/POP aliases for STM/LDM
5984 def : ARMInstAlias<"push${p} $regs", (STMDB_UPD SP, pred:$p, reglist:$regs)>;
5985 def : ARMInstAlias<"pop${p} $regs", (LDMIA_UPD SP, pred:$p, reglist:$regs)>;
5987 // SSAT/USAT optional shift operand.
5988 def : ARMInstAlias<"ssat${p} $Rd, $sat_imm, $Rn",
5989 (SSAT GPRnopc:$Rd, imm1_32:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5990 def : ARMInstAlias<"usat${p} $Rd, $sat_imm, $Rn",
5991 (USAT GPRnopc:$Rd, imm0_31:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5994 // Extend instruction optional rotate operand.
5995 def : ARMInstAlias<"sxtab${p} $Rd, $Rn, $Rm",
5996 (SXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5997 def : ARMInstAlias<"sxtah${p} $Rd, $Rn, $Rm",
5998 (SXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5999 def : ARMInstAlias<"sxtab16${p} $Rd, $Rn, $Rm",
6000 (SXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
6001 def : ARMInstAlias<"sxtb${p} $Rd, $Rm",
6002 (SXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
6003 def : ARMInstAlias<"sxtb16${p} $Rd, $Rm",
6004 (SXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
6005 def : ARMInstAlias<"sxth${p} $Rd, $Rm",
6006 (SXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
6008 def : ARMInstAlias<"uxtab${p} $Rd, $Rn, $Rm",
6009 (UXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
6010 def : ARMInstAlias<"uxtah${p} $Rd, $Rn, $Rm",
6011 (UXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
6012 def : ARMInstAlias<"uxtab16${p} $Rd, $Rn, $Rm",
6013 (UXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
6014 def : ARMInstAlias<"uxtb${p} $Rd, $Rm",
6015 (UXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
6016 def : ARMInstAlias<"uxtb16${p} $Rd, $Rm",
6017 (UXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
6018 def : ARMInstAlias<"uxth${p} $Rd, $Rm",
6019 (UXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
6023 def : MnemonicAlias<"rfefa", "rfeda">;
6024 def : MnemonicAlias<"rfeea", "rfedb">;
6025 def : MnemonicAlias<"rfefd", "rfeia">;
6026 def : MnemonicAlias<"rfeed", "rfeib">;
6027 def : MnemonicAlias<"rfe", "rfeia">;
6030 def : MnemonicAlias<"srsfa", "srsib">;
6031 def : MnemonicAlias<"srsea", "srsia">;
6032 def : MnemonicAlias<"srsfd", "srsdb">;
6033 def : MnemonicAlias<"srsed", "srsda">;
6034 def : MnemonicAlias<"srs", "srsia">;
6037 def : MnemonicAlias<"qsubaddx", "qsax">;
6039 def : MnemonicAlias<"saddsubx", "sasx">;
6040 // SHASX == SHADDSUBX
6041 def : MnemonicAlias<"shaddsubx", "shasx">;
6042 // SHSAX == SHSUBADDX
6043 def : MnemonicAlias<"shsubaddx", "shsax">;
6045 def : MnemonicAlias<"ssubaddx", "ssax">;
6047 def : MnemonicAlias<"uaddsubx", "uasx">;
6048 // UHASX == UHADDSUBX
6049 def : MnemonicAlias<"uhaddsubx", "uhasx">;
6050 // UHSAX == UHSUBADDX
6051 def : MnemonicAlias<"uhsubaddx", "uhsax">;
6052 // UQASX == UQADDSUBX
6053 def : MnemonicAlias<"uqaddsubx", "uqasx">;
6054 // UQSAX == UQSUBADDX
6055 def : MnemonicAlias<"uqsubaddx", "uqsax">;
6057 def : MnemonicAlias<"usubaddx", "usax">;
6059 // "mov Rd, mod_imm_not" can be handled via "mvn" in assembly, just like
6061 def : ARMInstSubst<"mov${s}${p} $Rd, $imm",
6062 (MVNi rGPR:$Rd, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6063 def : ARMInstSubst<"mvn${s}${p} $Rd, $imm",
6064 (MOVi rGPR:$Rd, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6065 // Same for AND <--> BIC
6066 def : ARMInstSubst<"bic${s}${p} $Rd, $Rn, $imm",
6067 (ANDri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm,
6068 pred:$p, cc_out:$s)>;
6069 def : ARMInstSubst<"bic${s}${p} $Rdn, $imm",
6070 (ANDri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm,
6071 pred:$p, cc_out:$s)>;
6072 def : ARMInstSubst<"and${s}${p} $Rd, $Rn, $imm",
6073 (BICri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm,
6074 pred:$p, cc_out:$s)>;
6075 def : ARMInstSubst<"and${s}${p} $Rdn, $imm",
6076 (BICri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm,
6077 pred:$p, cc_out:$s)>;
6079 // Likewise, "add Rd, mod_imm_neg" -> sub
6080 def : ARMInstSubst<"add${s}${p} $Rd, $Rn, $imm",
6081 (SUBri GPR:$Rd, GPR:$Rn, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
6082 def : ARMInstSubst<"add${s}${p} $Rd, $imm",
6083 (SUBri GPR:$Rd, GPR:$Rd, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
6084 // Likewise, "sub Rd, mod_imm_neg" -> add
6085 def : ARMInstSubst<"sub${s}${p} $Rd, $Rn, $imm",
6086 (ADDri GPR:$Rd, GPR:$Rn, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
6087 def : ARMInstSubst<"sub${s}${p} $Rd, $imm",
6088 (ADDri GPR:$Rd, GPR:$Rd, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
6091 def : ARMInstSubst<"adc${s}${p} $Rd, $Rn, $imm",
6092 (SBCri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6093 def : ARMInstSubst<"adc${s}${p} $Rdn, $imm",
6094 (SBCri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6095 def : ARMInstSubst<"sbc${s}${p} $Rd, $Rn, $imm",
6096 (ADCri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6097 def : ARMInstSubst<"sbc${s}${p} $Rdn, $imm",
6098 (ADCri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6100 // Same for CMP <--> CMN via mod_imm_neg
6101 def : ARMInstSubst<"cmp${p} $Rd, $imm",
6102 (CMNri rGPR:$Rd, mod_imm_neg:$imm, pred:$p)>;
6103 def : ARMInstSubst<"cmn${p} $Rd, $imm",
6104 (CMPri rGPR:$Rd, mod_imm_neg:$imm, pred:$p)>;
6106 // The shifter forms of the MOV instruction are aliased to the ASR, LSL,
6107 // LSR, ROR, and RRX instructions.
6108 // FIXME: We need C++ parser hooks to map the alias to the MOV
6109 // encoding. It seems we should be able to do that sort of thing
6110 // in tblgen, but it could get ugly.
6111 let TwoOperandAliasConstraint = "$Rm = $Rd" in {
6112 def ASRi : ARMAsmPseudo<"asr${s}${p} $Rd, $Rm, $imm",
6113 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
6115 def LSRi : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rm, $imm",
6116 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
6118 def LSLi : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rm, $imm",
6119 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
6121 def RORi : ARMAsmPseudo<"ror${s}${p} $Rd, $Rm, $imm",
6122 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
6125 def RRXi : ARMAsmPseudo<"rrx${s}${p} $Rd, $Rm",
6126 (ins GPR:$Rd, GPR:$Rm, pred:$p, cc_out:$s)>;
6127 let TwoOperandAliasConstraint = "$Rn = $Rd" in {
6128 def ASRr : ARMAsmPseudo<"asr${s}${p} $Rd, $Rn, $Rm",
6129 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
6131 def LSRr : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rn, $Rm",
6132 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
6134 def LSLr : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rn, $Rm",
6135 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
6137 def RORr : ARMAsmPseudo<"ror${s}${p} $Rd, $Rn, $Rm",
6138 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
6142 // "neg" is and alias for "rsb rd, rn, #0"
6143 def : ARMInstAlias<"neg${s}${p} $Rd, $Rm",
6144 (RSBri GPR:$Rd, GPR:$Rm, 0, pred:$p, cc_out:$s)>;
6146 // Pre-v6, 'mov r0, r0' was used as a NOP encoding.
6147 def : InstAlias<"nop${p}", (MOVr R0, R0, pred:$p, zero_reg)>,
6148 Requires<[IsARM, NoV6]>;
6150 // MUL/UMLAL/SMLAL/UMULL/SMULL are available on all arches, but
6151 // the instruction definitions need difference constraints pre-v6.
6152 // Use these aliases for the assembly parsing on pre-v6.
6153 def : InstAlias<"mul${s}${p} $Rd, $Rn, $Rm",
6154 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s), 0>,
6155 Requires<[IsARM, NoV6]>;
6156 def : InstAlias<"mla${s}${p} $Rd, $Rn, $Rm, $Ra",
6157 (MLA GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra,
6158 pred:$p, cc_out:$s), 0>,
6159 Requires<[IsARM, NoV6]>;
6160 def : InstAlias<"smlal${s}${p} $RdLo, $RdHi, $Rn, $Rm",
6161 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>,
6162 Requires<[IsARM, NoV6]>;
6163 def : InstAlias<"umlal${s}${p} $RdLo, $RdHi, $Rn, $Rm",
6164 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>,
6165 Requires<[IsARM, NoV6]>;
6166 def : InstAlias<"smull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
6167 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>,
6168 Requires<[IsARM, NoV6]>;
6169 def : InstAlias<"umull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
6170 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>,
6171 Requires<[IsARM, NoV6]>;
6173 // 'it' blocks in ARM mode just validate the predicates. The IT itself
6175 def ITasm : ARMAsmPseudo<"it$mask $cc", (ins it_pred:$cc, it_mask:$mask)>,
6176 ComplexDeprecationPredicate<"IT">;
6178 let mayLoad = 1, mayStore =1, hasSideEffects = 1, hasNoSchedulingInfo = 1 in
6179 def SPACE : PseudoInst<(outs GPR:$Rd), (ins i32imm:$size, GPR:$Rn),
6181 [(set GPR:$Rd, (int_arm_space timm:$size, GPR:$Rn))]>;
6183 //===----------------------------------
6184 // Atomic cmpxchg for -O0
6185 //===----------------------------------
6187 // The fast register allocator used during -O0 inserts spills to cover any VRegs
6188 // live across basic block boundaries. When this happens between an LDXR and an
6189 // STXR it can clear the exclusive monitor, causing all cmpxchg attempts to
6192 // Unfortunately, this means we have to have an alternative (expanded
6193 // post-regalloc) path for -O0 compilations. Fortunately this path can be
6194 // significantly more naive than the standard expansion: we conservatively
6195 // assume seq_cst, strong cmpxchg and omit clrex on failure.
6197 let Constraints = "@earlyclobber $Rd,@earlyclobber $temp",
6198 mayLoad = 1, mayStore = 1 in {
6199 def CMP_SWAP_8 : PseudoInst<(outs GPR:$Rd, GPR:$temp),
6200 (ins GPR:$addr, GPR:$desired, GPR:$new),
6201 NoItinerary, []>, Sched<[]>;
6203 def CMP_SWAP_16 : PseudoInst<(outs GPR:$Rd, GPR:$temp),
6204 (ins GPR:$addr, GPR:$desired, GPR:$new),
6205 NoItinerary, []>, Sched<[]>;
6207 def CMP_SWAP_32 : PseudoInst<(outs GPR:$Rd, GPR:$temp),
6208 (ins GPR:$addr, GPR:$desired, GPR:$new),
6209 NoItinerary, []>, Sched<[]>;
6211 def CMP_SWAP_64 : PseudoInst<(outs GPRPair:$Rd, GPR:$temp),
6212 (ins GPR:$addr, GPRPair:$desired, GPRPair:$new),
6213 NoItinerary, []>, Sched<[]>;
6216 def CompilerBarrier : PseudoInst<(outs), (ins i32imm:$ordering), NoItinerary,
6217 [(atomic_fence imm:$ordering, 0)]> {
6218 let hasSideEffects = 1;
6220 let AsmString = "@ COMPILER BARRIER";
6221 let hasNoSchedulingInfo = 1;