1 //===- ARMInstrInfo.td - Target Description for ARM Target -*- tablegen -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file describes the ARM instructions in TableGen format.
11 //===----------------------------------------------------------------------===//
13 //===----------------------------------------------------------------------===//
14 // ARM specific DAG Nodes.
18 def SDT_ARMCallSeqStart : SDCallSeqStart<[ SDTCisVT<0, i32>,
20 def SDT_ARMCallSeqEnd : SDCallSeqEnd<[ SDTCisVT<0, i32>, SDTCisVT<1, i32> ]>;
21 def SDT_ARMStructByVal : SDTypeProfile<0, 4,
22 [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
23 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
25 def SDT_ARMSaveCallPC : SDTypeProfile<0, 1, []>;
27 def SDT_ARMcall : SDTypeProfile<0, -1, [SDTCisPtrTy<0>]>;
29 def SDT_ARMCMov : SDTypeProfile<1, 3,
30 [SDTCisSameAs<0, 1>, SDTCisSameAs<0, 2>,
33 def SDT_ARMBrcond : SDTypeProfile<0, 2,
34 [SDTCisVT<0, OtherVT>, SDTCisVT<1, i32>]>;
36 def SDT_ARMBrJT : SDTypeProfile<0, 2,
37 [SDTCisPtrTy<0>, SDTCisVT<1, i32>]>;
39 def SDT_ARMBr2JT : SDTypeProfile<0, 3,
40 [SDTCisPtrTy<0>, SDTCisVT<1, i32>,
43 def SDT_ARMBCC_i64 : SDTypeProfile<0, 6,
45 SDTCisVT<1, i32>, SDTCisVT<2, i32>,
46 SDTCisVT<3, i32>, SDTCisVT<4, i32>,
47 SDTCisVT<5, OtherVT>]>;
49 def SDT_ARMAnd : SDTypeProfile<1, 2,
50 [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
53 def SDT_ARMCmp : SDTypeProfile<0, 2, [SDTCisSameAs<0, 1>]>;
54 def SDT_ARMFCmp : SDTypeProfile<0, 3, [SDTCisSameAs<0, 1>,
57 def SDT_ARMPICAdd : SDTypeProfile<1, 2, [SDTCisSameAs<0, 1>,
58 SDTCisPtrTy<1>, SDTCisVT<2, i32>]>;
60 def SDT_ARMThreadPointer : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>;
61 def SDT_ARMEH_SJLJ_Setjmp : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisPtrTy<1>,
63 def SDT_ARMEH_SJLJ_Longjmp: SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisInt<1>]>;
64 def SDT_ARMEH_SJLJ_SetupDispatch: SDTypeProfile<0, 0, []>;
66 def SDT_ARMMEMBARRIER : SDTypeProfile<0, 1, [SDTCisInt<0>]>;
68 def SDT_ARMPREFETCH : SDTypeProfile<0, 3, [SDTCisPtrTy<0>, SDTCisSameAs<1, 2>,
71 def SDT_ARMTCRET : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>;
73 def SDT_ARMBFI : SDTypeProfile<1, 3, [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
74 SDTCisVT<2, i32>, SDTCisVT<3, i32>]>;
76 def SDT_WIN__DBZCHK : SDTypeProfile<0, 1, [SDTCisVT<0, i32>]>;
78 def SDT_ARMMEMCPY : SDTypeProfile<2, 3, [SDTCisVT<0, i32>, SDTCisVT<1, i32>,
79 SDTCisVT<2, i32>, SDTCisVT<3, i32>,
82 def SDTBinaryArithWithFlags : SDTypeProfile<2, 2,
85 SDTCisInt<0>, SDTCisVT<1, i32>]>;
87 // SDTBinaryArithWithFlagsInOut - RES1, CPSR = op LHS, RHS, CPSR
88 def SDTBinaryArithWithFlagsInOut : SDTypeProfile<2, 3,
95 def SDT_LongMac : SDTypeProfile<2, 4, [SDTCisVT<0, i32>,
100 SDTCisSameAs<0, 5>]>;
102 // ARMlsll, ARMlsrl, ARMasrl
103 def SDT_ARMIntShiftParts : SDTypeProfile<2, 3, [SDTCisSameAs<0, 1>,
109 // TODO Add another operand for 'Size' so that we can re-use this node when we
110 // start supporting *TP versions.
111 def SDT_ARMLoLoop : SDTypeProfile<0, 2, [SDTCisVT<0, i32>,
112 SDTCisVT<1, OtherVT>]>;
114 def ARMSmlald : SDNode<"ARMISD::SMLALD", SDT_LongMac>;
115 def ARMSmlaldx : SDNode<"ARMISD::SMLALDX", SDT_LongMac>;
116 def ARMSmlsld : SDNode<"ARMISD::SMLSLD", SDT_LongMac>;
117 def ARMSmlsldx : SDNode<"ARMISD::SMLSLDX", SDT_LongMac>;
119 def SDT_ARMCSel : SDTypeProfile<1, 3,
125 def ARMcsinv : SDNode<"ARMISD::CSINV", SDT_ARMCSel, [SDNPOptInGlue]>;
126 def ARMcsneg : SDNode<"ARMISD::CSNEG", SDT_ARMCSel, [SDNPOptInGlue]>;
127 def ARMcsinc : SDNode<"ARMISD::CSINC", SDT_ARMCSel, [SDNPOptInGlue]>;
129 def SDT_MulHSR : SDTypeProfile<1, 3, [SDTCisVT<0,i32>,
132 SDTCisSameAs<0, 3>]>;
134 def ARMsmmlar : SDNode<"ARMISD::SMMLAR", SDT_MulHSR>;
135 def ARMsmmlsr : SDNode<"ARMISD::SMMLSR", SDT_MulHSR>;
138 def ARMWrapper : SDNode<"ARMISD::Wrapper", SDTIntUnaryOp>;
139 def ARMWrapperPIC : SDNode<"ARMISD::WrapperPIC", SDTIntUnaryOp>;
140 def ARMWrapperJT : SDNode<"ARMISD::WrapperJT", SDTIntUnaryOp>;
142 def ARMcallseq_start : SDNode<"ISD::CALLSEQ_START", SDT_ARMCallSeqStart,
143 [SDNPHasChain, SDNPSideEffect, SDNPOutGlue]>;
144 def ARMcallseq_end : SDNode<"ISD::CALLSEQ_END", SDT_ARMCallSeqEnd,
145 [SDNPHasChain, SDNPSideEffect,
146 SDNPOptInGlue, SDNPOutGlue]>;
147 def ARMcopystructbyval : SDNode<"ARMISD::COPY_STRUCT_BYVAL" ,
149 [SDNPHasChain, SDNPInGlue, SDNPOutGlue,
150 SDNPMayStore, SDNPMayLoad]>;
152 def ARMcall : SDNode<"ARMISD::CALL", SDT_ARMcall,
153 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
155 def ARMcall_pred : SDNode<"ARMISD::CALL_PRED", SDT_ARMcall,
156 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
158 def ARMcall_nolink : SDNode<"ARMISD::CALL_NOLINK", SDT_ARMcall,
159 [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue,
162 def ARMretflag : SDNode<"ARMISD::RET_FLAG", SDTNone,
163 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
164 def ARMintretflag : SDNode<"ARMISD::INTRET_FLAG", SDT_ARMcall,
165 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
166 def ARMcmov : SDNode<"ARMISD::CMOV", SDT_ARMCMov,
168 def ARMsubs : SDNode<"ARMISD::SUBS", SDTIntBinOp, [SDNPOutGlue]>;
170 def ARMssatnoshift : SDNode<"ARMISD::SSAT", SDTIntSatNoShOp, []>;
172 def ARMusatnoshift : SDNode<"ARMISD::USAT", SDTIntSatNoShOp, []>;
174 def ARMbrcond : SDNode<"ARMISD::BRCOND", SDT_ARMBrcond,
175 [SDNPHasChain, SDNPInGlue, SDNPOutGlue]>;
177 def ARMbrjt : SDNode<"ARMISD::BR_JT", SDT_ARMBrJT,
179 def ARMbr2jt : SDNode<"ARMISD::BR2_JT", SDT_ARMBr2JT,
182 def ARMBcci64 : SDNode<"ARMISD::BCC_i64", SDT_ARMBCC_i64,
185 def ARMcmp : SDNode<"ARMISD::CMP", SDT_ARMCmp,
188 def ARMcmn : SDNode<"ARMISD::CMN", SDT_ARMCmp,
191 def ARMcmpZ : SDNode<"ARMISD::CMPZ", SDT_ARMCmp,
192 [SDNPOutGlue, SDNPCommutative]>;
194 def ARMpic_add : SDNode<"ARMISD::PIC_ADD", SDT_ARMPICAdd>;
196 def ARMasrl : SDNode<"ARMISD::ASRL", SDT_ARMIntShiftParts, []>;
197 def ARMlsrl : SDNode<"ARMISD::LSRL", SDT_ARMIntShiftParts, []>;
198 def ARMlsll : SDNode<"ARMISD::LSLL", SDT_ARMIntShiftParts, []>;
200 def ARMsrl_flag : SDNode<"ARMISD::SRL_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
201 def ARMsra_flag : SDNode<"ARMISD::SRA_FLAG", SDTIntUnaryOp, [SDNPOutGlue]>;
202 def ARMrrx : SDNode<"ARMISD::RRX" , SDTIntUnaryOp, [SDNPInGlue ]>;
204 def ARMaddc : SDNode<"ARMISD::ADDC", SDTBinaryArithWithFlags,
206 def ARMsubc : SDNode<"ARMISD::SUBC", SDTBinaryArithWithFlags>;
207 def ARMlsls : SDNode<"ARMISD::LSLS", SDTBinaryArithWithFlags>;
208 def ARMadde : SDNode<"ARMISD::ADDE", SDTBinaryArithWithFlagsInOut>;
209 def ARMsube : SDNode<"ARMISD::SUBE", SDTBinaryArithWithFlagsInOut>;
211 def ARMthread_pointer: SDNode<"ARMISD::THREAD_POINTER", SDT_ARMThreadPointer>;
212 def ARMeh_sjlj_setjmp: SDNode<"ARMISD::EH_SJLJ_SETJMP",
213 SDT_ARMEH_SJLJ_Setjmp,
214 [SDNPHasChain, SDNPSideEffect]>;
215 def ARMeh_sjlj_longjmp: SDNode<"ARMISD::EH_SJLJ_LONGJMP",
216 SDT_ARMEH_SJLJ_Longjmp,
217 [SDNPHasChain, SDNPSideEffect]>;
218 def ARMeh_sjlj_setup_dispatch: SDNode<"ARMISD::EH_SJLJ_SETUP_DISPATCH",
219 SDT_ARMEH_SJLJ_SetupDispatch,
220 [SDNPHasChain, SDNPSideEffect]>;
222 def ARMMemBarrierMCR : SDNode<"ARMISD::MEMBARRIER_MCR", SDT_ARMMEMBARRIER,
223 [SDNPHasChain, SDNPSideEffect]>;
224 def ARMPreload : SDNode<"ARMISD::PRELOAD", SDT_ARMPREFETCH,
225 [SDNPHasChain, SDNPMayLoad, SDNPMayStore]>;
227 def ARMtcret : SDNode<"ARMISD::TC_RETURN", SDT_ARMTCRET,
228 [SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
230 def ARMbfi : SDNode<"ARMISD::BFI", SDT_ARMBFI>;
232 def ARMmemcopy : SDNode<"ARMISD::MEMCPY", SDT_ARMMEMCPY,
233 [SDNPHasChain, SDNPInGlue, SDNPOutGlue,
234 SDNPMayStore, SDNPMayLoad]>;
236 def ARMsmulwb : SDNode<"ARMISD::SMULWB", SDTIntBinOp, []>;
237 def ARMsmulwt : SDNode<"ARMISD::SMULWT", SDTIntBinOp, []>;
238 def ARMsmlalbb : SDNode<"ARMISD::SMLALBB", SDT_LongMac, []>;
239 def ARMsmlalbt : SDNode<"ARMISD::SMLALBT", SDT_LongMac, []>;
240 def ARMsmlaltb : SDNode<"ARMISD::SMLALTB", SDT_LongMac, []>;
241 def ARMsmlaltt : SDNode<"ARMISD::SMLALTT", SDT_LongMac, []>;
243 // Vector operations shared between NEON and MVE
245 def ARMvdup : SDNode<"ARMISD::VDUP", SDTypeProfile<1, 1, [SDTCisVec<0>]>>;
247 // VDUPLANE can produce a quad-register result from a double-register source,
248 // so the result is not constrained to match the source.
249 def ARMvduplane : SDNode<"ARMISD::VDUPLANE",
250 SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisVec<1>,
253 def SDTARMVSHUF : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisSameAs<0, 1>]>;
254 def ARMvrev64 : SDNode<"ARMISD::VREV64", SDTARMVSHUF>;
255 def ARMvrev32 : SDNode<"ARMISD::VREV32", SDTARMVSHUF>;
256 def ARMvrev16 : SDNode<"ARMISD::VREV16", SDTARMVSHUF>;
258 def SDTARMVGETLN : SDTypeProfile<1, 2, [SDTCisVT<0, i32>, SDTCisInt<1>,
260 def ARMvgetlaneu : SDNode<"ARMISD::VGETLANEu", SDTARMVGETLN>;
261 def ARMvgetlanes : SDNode<"ARMISD::VGETLANEs", SDTARMVGETLN>;
263 def SDTARMVMOVIMM : SDTypeProfile<1, 1, [SDTCisVec<0>, SDTCisVT<1, i32>]>;
264 def ARMvmovImm : SDNode<"ARMISD::VMOVIMM", SDTARMVMOVIMM>;
265 def ARMvmvnImm : SDNode<"ARMISD::VMVNIMM", SDTARMVMOVIMM>;
266 def ARMvmovFPImm : SDNode<"ARMISD::VMOVFPIMM", SDTARMVMOVIMM>;
269 def SDTARMVSHIMM : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisSameAs<0, 1>,
271 def SDTARMVSH : SDTypeProfile<1, 2, [SDTCisInt<0>, SDTCisSameAs<0, 1>,
272 SDTCisSameAs<0, 2>,]>;
273 def ARMvshlImm : SDNode<"ARMISD::VSHLIMM", SDTARMVSHIMM>;
274 def ARMvshrsImm : SDNode<"ARMISD::VSHRsIMM", SDTARMVSHIMM>;
275 def ARMvshruImm : SDNode<"ARMISD::VSHRuIMM", SDTARMVSHIMM>;
276 def ARMvshls : SDNode<"ARMISD::VSHLs", SDTARMVSH>;
277 def ARMvshlu : SDNode<"ARMISD::VSHLu", SDTARMVSH>;
279 def SDTARMVCMP : SDTypeProfile<1, 3, [SDTCisInt<0>, SDTCisSameAs<1, 2>,
281 def SDTARMVCMPZ : SDTypeProfile<1, 2, [SDTCisInt<2>]>;
283 def ARMvcmp : SDNode<"ARMISD::VCMP", SDTARMVCMP>;
284 def ARMvcmpz : SDNode<"ARMISD::VCMPZ", SDTARMVCMPZ>;
286 def ARMWLS : SDNode<"ARMISD::WLS", SDT_ARMLoLoop, [SDNPHasChain]>;
287 def ARMLE : SDNode<"ARMISD::LE", SDT_ARMLoLoop, [SDNPHasChain]>;
288 def ARMLoopDec : SDNode<"ARMISD::LOOP_DEC", SDTIntBinOp, [SDNPHasChain]>;
290 //===----------------------------------------------------------------------===//
291 // ARM Flag Definitions.
293 class RegConstraint<string C> {
294 string Constraints = C;
297 //===----------------------------------------------------------------------===//
298 // ARM specific transformation functions and pattern fragments.
301 // imm_neg_XFORM - Return the negation of an i32 immediate value.
302 def imm_neg_XFORM : SDNodeXForm<imm, [{
303 return CurDAG->getTargetConstant(-(int)N->getZExtValue(), SDLoc(N), MVT::i32);
306 // imm_not_XFORM - Return the complement of a i32 immediate value.
307 def imm_not_XFORM : SDNodeXForm<imm, [{
308 return CurDAG->getTargetConstant(~(int)N->getZExtValue(), SDLoc(N), MVT::i32);
311 /// imm16_31 predicate - True if the 32-bit immediate is in the range [16,31].
312 def imm16_31 : ImmLeaf<i32, [{
313 return (int32_t)Imm >= 16 && (int32_t)Imm < 32;
316 // sext_16_node predicate - True if the SDNode is sign-extended 16 or more bits.
317 def sext_16_node : PatLeaf<(i32 GPR:$a), [{
318 return CurDAG->ComputeNumSignBits(SDValue(N,0)) >= 17;
321 def sext_bottom_16 : PatFrag<(ops node:$a),
322 (sext_inreg node:$a, i16)>;
323 def sext_top_16 : PatFrag<(ops node:$a),
324 (i32 (sra node:$a, (i32 16)))>;
326 def bb_mul : PatFrag<(ops node:$a, node:$b),
327 (mul (sext_bottom_16 node:$a), (sext_bottom_16 node:$b))>;
328 def bt_mul : PatFrag<(ops node:$a, node:$b),
329 (mul (sext_bottom_16 node:$a), (sra node:$b, (i32 16)))>;
330 def tb_mul : PatFrag<(ops node:$a, node:$b),
331 (mul (sra node:$a, (i32 16)), (sext_bottom_16 node:$b))>;
332 def tt_mul : PatFrag<(ops node:$a, node:$b),
333 (mul (sra node:$a, (i32 16)), (sra node:$b, (i32 16)))>;
335 /// Split a 32-bit immediate into two 16 bit parts.
336 def hi16 : SDNodeXForm<imm, [{
337 return CurDAG->getTargetConstant((uint32_t)N->getZExtValue() >> 16, SDLoc(N),
341 def lo16AllZero : PatLeaf<(i32 imm), [{
342 // Returns true if all low 16-bits are 0.
343 return (((uint32_t)N->getZExtValue()) & 0xFFFFUL) == 0;
346 class BinOpFrag<dag res> : PatFrag<(ops node:$LHS, node:$RHS), res>;
347 class UnOpFrag <dag res> : PatFrag<(ops node:$Src), res>;
349 // An 'and' node with a single use.
350 def and_su : PatFrag<(ops node:$lhs, node:$rhs), (and node:$lhs, node:$rhs), [{
351 return N->hasOneUse();
354 // An 'xor' node with a single use.
355 def xor_su : PatFrag<(ops node:$lhs, node:$rhs), (xor node:$lhs, node:$rhs), [{
356 return N->hasOneUse();
359 // An 'fmul' node with a single use.
360 def fmul_su : PatFrag<(ops node:$lhs, node:$rhs), (fmul node:$lhs, node:$rhs),[{
361 return N->hasOneUse();
364 // An 'fadd' node which checks for single non-hazardous use.
365 def fadd_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fadd node:$lhs, node:$rhs),[{
366 return hasNoVMLxHazardUse(N);
369 // An 'fsub' node which checks for single non-hazardous use.
370 def fsub_mlx : PatFrag<(ops node:$lhs, node:$rhs),(fsub node:$lhs, node:$rhs),[{
371 return hasNoVMLxHazardUse(N);
374 //===----------------------------------------------------------------------===//
375 // Operand Definitions.
378 // Immediate operands with a shared generic asm render method.
379 class ImmAsmOperand<int Low, int High> : AsmOperandClass {
380 let RenderMethod = "addImmOperands";
381 let PredicateMethod = "isImmediate<" # Low # "," # High # ">";
382 let DiagnosticString = "operand must be an immediate in the range [" # Low # "," # High # "]";
385 class ImmAsmOperandMinusOne<int Low, int High> : AsmOperandClass {
386 let PredicateMethod = "isImmediate<" # Low # "," # High # ">";
387 let DiagnosticType = "ImmRange" # Low # "_" # High;
388 let DiagnosticString = "operand must be an immediate in the range [" # Low # "," # High # "]";
391 // Operands that are part of a memory addressing mode.
392 class MemOperand : Operand<i32> { let OperandType = "OPERAND_MEMORY"; }
395 // FIXME: rename brtarget to t2_brtarget
396 def brtarget : Operand<OtherVT> {
397 let EncoderMethod = "getBranchTargetOpValue";
398 let OperandType = "OPERAND_PCREL";
399 let DecoderMethod = "DecodeT2BROperand";
402 // Branches targeting ARM-mode must be divisible by 4 if they're a raw
404 def ARMBranchTarget : AsmOperandClass {
405 let Name = "ARMBranchTarget";
408 // Branches targeting Thumb-mode must be divisible by 2 if they're a raw
410 def ThumbBranchTarget : AsmOperandClass {
411 let Name = "ThumbBranchTarget";
414 def arm_br_target : Operand<OtherVT> {
415 let ParserMatchClass = ARMBranchTarget;
416 let EncoderMethod = "getARMBranchTargetOpValue";
417 let OperandType = "OPERAND_PCREL";
420 // Call target for ARM. Handles conditional/unconditional
421 // FIXME: rename bl_target to t2_bltarget?
422 def arm_bl_target : Operand<i32> {
423 let ParserMatchClass = ARMBranchTarget;
424 let EncoderMethod = "getARMBLTargetOpValue";
425 let OperandType = "OPERAND_PCREL";
428 // Target for BLX *from* ARM mode.
429 def arm_blx_target : Operand<i32> {
430 let ParserMatchClass = ThumbBranchTarget;
431 let EncoderMethod = "getARMBLXTargetOpValue";
432 let OperandType = "OPERAND_PCREL";
435 // A list of registers separated by comma. Used by load/store multiple.
436 def RegListAsmOperand : AsmOperandClass { let Name = "RegList"; }
437 def reglist : Operand<i32> {
438 let EncoderMethod = "getRegisterListOpValue";
439 let ParserMatchClass = RegListAsmOperand;
440 let PrintMethod = "printRegisterList";
441 let DecoderMethod = "DecodeRegListOperand";
444 // A list of general purpose registers and APSR separated by comma.
446 def RegListWithAPSRAsmOperand : AsmOperandClass { let Name = "RegListWithAPSR"; }
447 def reglist_with_apsr : Operand<i32> {
448 let EncoderMethod = "getRegisterListOpValue";
449 let ParserMatchClass = RegListWithAPSRAsmOperand;
450 let PrintMethod = "printRegisterList";
451 let DecoderMethod = "DecodeRegListOperand";
454 def GPRPairOp : RegisterOperand<GPRPair, "printGPRPairOperand">;
456 def DPRRegListAsmOperand : AsmOperandClass {
457 let Name = "DPRRegList";
458 let DiagnosticType = "DPR_RegList";
460 def dpr_reglist : Operand<i32> {
461 let EncoderMethod = "getRegisterListOpValue";
462 let ParserMatchClass = DPRRegListAsmOperand;
463 let PrintMethod = "printRegisterList";
464 let DecoderMethod = "DecodeDPRRegListOperand";
467 def SPRRegListAsmOperand : AsmOperandClass {
468 let Name = "SPRRegList";
469 let DiagnosticString = "operand must be a list of registers in range [s0, s31]";
471 def spr_reglist : Operand<i32> {
472 let EncoderMethod = "getRegisterListOpValue";
473 let ParserMatchClass = SPRRegListAsmOperand;
474 let PrintMethod = "printRegisterList";
475 let DecoderMethod = "DecodeSPRRegListOperand";
478 def FPSRegListWithVPRAsmOperand : AsmOperandClass { let Name =
479 "FPSRegListWithVPR"; }
480 def fp_sreglist_with_vpr : Operand<i32> {
481 let EncoderMethod = "getRegisterListOpValue";
482 let ParserMatchClass = FPSRegListWithVPRAsmOperand;
483 let PrintMethod = "printRegisterList";
485 def FPDRegListWithVPRAsmOperand : AsmOperandClass { let Name =
486 "FPDRegListWithVPR"; }
487 def fp_dreglist_with_vpr : Operand<i32> {
488 let EncoderMethod = "getRegisterListOpValue";
489 let ParserMatchClass = FPDRegListWithVPRAsmOperand;
490 let PrintMethod = "printRegisterList";
493 // An operand for the CONSTPOOL_ENTRY pseudo-instruction.
494 def cpinst_operand : Operand<i32> {
495 let PrintMethod = "printCPInstOperand";
499 def pclabel : Operand<i32> {
500 let PrintMethod = "printPCLabel";
503 // ADR instruction labels.
504 def AdrLabelAsmOperand : AsmOperandClass { let Name = "AdrLabel"; }
505 def adrlabel : Operand<i32> {
506 let EncoderMethod = "getAdrLabelOpValue";
507 let ParserMatchClass = AdrLabelAsmOperand;
508 let PrintMethod = "printAdrLabelOperand<0>";
511 def neon_vcvt_imm32 : Operand<i32> {
512 let EncoderMethod = "getNEONVcvtImm32OpValue";
513 let DecoderMethod = "DecodeVCVTImmOperand";
516 // rot_imm: An integer that encodes a rotate amount. Must be 8, 16, or 24.
517 def rot_imm_XFORM: SDNodeXForm<imm, [{
518 switch (N->getZExtValue()){
519 default: llvm_unreachable(nullptr);
520 case 0: return CurDAG->getTargetConstant(0, SDLoc(N), MVT::i32);
521 case 8: return CurDAG->getTargetConstant(1, SDLoc(N), MVT::i32);
522 case 16: return CurDAG->getTargetConstant(2, SDLoc(N), MVT::i32);
523 case 24: return CurDAG->getTargetConstant(3, SDLoc(N), MVT::i32);
526 def RotImmAsmOperand : AsmOperandClass {
528 let ParserMethod = "parseRotImm";
530 def rot_imm : Operand<i32>, PatLeaf<(i32 imm), [{
531 int32_t v = N->getZExtValue();
532 return v == 8 || v == 16 || v == 24; }],
534 let PrintMethod = "printRotImmOperand";
535 let ParserMatchClass = RotImmAsmOperand;
538 // Power-of-two operand for MVE VIDUP and friends, which encode
539 // {1,2,4,8} as its log to base 2, i.e. as {0,1,2,3} respectively
540 def MVE_VIDUP_imm_asmoperand : AsmOperandClass {
541 let Name = "VIDUP_imm";
542 let PredicateMethod = "isPowerTwoInRange<1,8>";
543 let RenderMethod = "addPowerTwoOperands";
544 let DiagnosticString = "vector increment immediate must be 1, 2, 4 or 8";
546 def MVE_VIDUP_imm : Operand<i32> {
547 let EncoderMethod = "getPowerTwoOpValue";
548 let DecoderMethod = "DecodePowerTwoOperand<0,3>";
549 let ParserMatchClass = MVE_VIDUP_imm_asmoperand;
552 // Pair vector indexing
553 class MVEPairVectorIndexOperand<string start, string end> : AsmOperandClass {
554 let Name = "MVEPairVectorIndex"#start;
555 let RenderMethod = "addMVEPairVectorIndexOperands";
556 let PredicateMethod = "isMVEPairVectorIndex<"#start#", "#end#">";
559 class MVEPairVectorIndex<string opval> : Operand<i32> {
560 let PrintMethod = "printVectorIndex";
561 let EncoderMethod = "getMVEPairVectorIndexOpValue<"#opval#">";
562 let DecoderMethod = "DecodeMVEPairVectorIndexOperand<"#opval#">";
563 let MIOperandInfo = (ops i32imm);
566 def MVEPairVectorIndex0 : MVEPairVectorIndex<"0"> {
567 let ParserMatchClass = MVEPairVectorIndexOperand<"0", "1">;
570 def MVEPairVectorIndex2 : MVEPairVectorIndex<"2"> {
571 let ParserMatchClass = MVEPairVectorIndexOperand<"2", "3">;
575 class MVEVectorIndexOperand<int NumLanes> : AsmOperandClass {
576 let Name = "MVEVectorIndex"#NumLanes;
577 let RenderMethod = "addMVEVectorIndexOperands";
578 let PredicateMethod = "isVectorIndexInRange<"#NumLanes#">";
581 class MVEVectorIndex<int NumLanes> : Operand<i32> {
582 let PrintMethod = "printVectorIndex";
583 let ParserMatchClass = MVEVectorIndexOperand<NumLanes>;
584 let MIOperandInfo = (ops i32imm);
587 // shift_imm: An integer that encodes a shift amount and the type of shift
588 // (asr or lsl). The 6-bit immediate encodes as:
591 // {4-0} imm5 shift amount.
592 // asr #32 encoded as imm5 == 0.
593 def ShifterImmAsmOperand : AsmOperandClass {
594 let Name = "ShifterImm";
595 let ParserMethod = "parseShifterImm";
597 def shift_imm : Operand<i32> {
598 let PrintMethod = "printShiftImmOperand";
599 let ParserMatchClass = ShifterImmAsmOperand;
602 // shifter_operand operands: so_reg_reg, so_reg_imm, and mod_imm.
603 def ShiftedRegAsmOperand : AsmOperandClass { let Name = "RegShiftedReg"; }
604 def so_reg_reg : Operand<i32>, // reg reg imm
605 ComplexPattern<i32, 3, "SelectRegShifterOperand",
606 [shl, srl, sra, rotr]> {
607 let EncoderMethod = "getSORegRegOpValue";
608 let PrintMethod = "printSORegRegOperand";
609 let DecoderMethod = "DecodeSORegRegOperand";
610 let ParserMatchClass = ShiftedRegAsmOperand;
611 let MIOperandInfo = (ops GPRnopc, GPRnopc, i32imm);
614 def ShiftedImmAsmOperand : AsmOperandClass { let Name = "RegShiftedImm"; }
615 def so_reg_imm : Operand<i32>, // reg imm
616 ComplexPattern<i32, 2, "SelectImmShifterOperand",
617 [shl, srl, sra, rotr]> {
618 let EncoderMethod = "getSORegImmOpValue";
619 let PrintMethod = "printSORegImmOperand";
620 let DecoderMethod = "DecodeSORegImmOperand";
621 let ParserMatchClass = ShiftedImmAsmOperand;
622 let MIOperandInfo = (ops GPR, i32imm);
625 // FIXME: Does this need to be distinct from so_reg?
626 def shift_so_reg_reg : Operand<i32>, // reg reg imm
627 ComplexPattern<i32, 3, "SelectShiftRegShifterOperand",
628 [shl,srl,sra,rotr]> {
629 let EncoderMethod = "getSORegRegOpValue";
630 let PrintMethod = "printSORegRegOperand";
631 let DecoderMethod = "DecodeSORegRegOperand";
632 let ParserMatchClass = ShiftedRegAsmOperand;
633 let MIOperandInfo = (ops GPR, GPR, i32imm);
636 // FIXME: Does this need to be distinct from so_reg?
637 def shift_so_reg_imm : Operand<i32>, // reg reg imm
638 ComplexPattern<i32, 2, "SelectShiftImmShifterOperand",
639 [shl,srl,sra,rotr]> {
640 let EncoderMethod = "getSORegImmOpValue";
641 let PrintMethod = "printSORegImmOperand";
642 let DecoderMethod = "DecodeSORegImmOperand";
643 let ParserMatchClass = ShiftedImmAsmOperand;
644 let MIOperandInfo = (ops GPR, i32imm);
647 // mod_imm: match a 32-bit immediate operand, which can be encoded into
648 // a 12-bit immediate; an 8-bit integer and a 4-bit rotator (See ARMARM
649 // - "Modified Immediate Constants"). Within the MC layer we keep this
650 // immediate in its encoded form.
651 def ModImmAsmOperand: AsmOperandClass {
653 let ParserMethod = "parseModImm";
655 def mod_imm : Operand<i32>, ImmLeaf<i32, [{
656 return ARM_AM::getSOImmVal(Imm) != -1;
658 let EncoderMethod = "getModImmOpValue";
659 let PrintMethod = "printModImmOperand";
660 let ParserMatchClass = ModImmAsmOperand;
663 // Note: the patterns mod_imm_not and mod_imm_neg do not require an encoder
664 // method and such, as they are only used on aliases (Pat<> and InstAlias<>).
665 // The actual parsing, encoding, decoding are handled by the destination
666 // instructions, which use mod_imm.
668 def ModImmNotAsmOperand : AsmOperandClass { let Name = "ModImmNot"; }
669 def mod_imm_not : Operand<i32>, PatLeaf<(imm), [{
670 return ARM_AM::getSOImmVal(~(uint32_t)N->getZExtValue()) != -1;
672 let ParserMatchClass = ModImmNotAsmOperand;
675 def ModImmNegAsmOperand : AsmOperandClass { let Name = "ModImmNeg"; }
676 def mod_imm_neg : Operand<i32>, PatLeaf<(imm), [{
677 unsigned Value = -(unsigned)N->getZExtValue();
678 return Value && ARM_AM::getSOImmVal(Value) != -1;
680 let ParserMatchClass = ModImmNegAsmOperand;
683 /// arm_i32imm - True for +V6T2, or when isSOImmTwoParVal()
684 def arm_i32imm : IntImmLeaf<i32, [{
685 if (Subtarget->useMovt())
687 return ARM_AM::isSOImmTwoPartVal(Imm.getZExtValue());
690 /// imm0_1 predicate - Immediate in the range [0,1].
691 def Imm0_1AsmOperand: ImmAsmOperand<0,1> { let Name = "Imm0_1"; }
692 def imm0_1 : Operand<i32> { let ParserMatchClass = Imm0_1AsmOperand; }
694 /// imm0_3 predicate - Immediate in the range [0,3].
695 def Imm0_3AsmOperand: ImmAsmOperand<0,3> { let Name = "Imm0_3"; }
696 def imm0_3 : Operand<i32> { let ParserMatchClass = Imm0_3AsmOperand; }
698 /// imm0_7 predicate - Immediate in the range [0,7].
699 def Imm0_7AsmOperand: ImmAsmOperand<0,7> {
702 def imm0_7 : Operand<i32>, ImmLeaf<i32, [{
703 return Imm >= 0 && Imm < 8;
705 let ParserMatchClass = Imm0_7AsmOperand;
708 /// imm8_255 predicate - Immediate in the range [8,255].
709 def Imm8_255AsmOperand: ImmAsmOperand<8,255> { let Name = "Imm8_255"; }
710 def imm8_255 : Operand<i32>, ImmLeaf<i32, [{
711 return Imm >= 8 && Imm < 256;
713 let ParserMatchClass = Imm8_255AsmOperand;
716 /// imm8 predicate - Immediate is exactly 8.
717 def Imm8AsmOperand: ImmAsmOperand<8,8> { let Name = "Imm8"; }
718 def imm8 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 8; }]> {
719 let ParserMatchClass = Imm8AsmOperand;
722 /// imm16 predicate - Immediate is exactly 16.
723 def Imm16AsmOperand: ImmAsmOperand<16,16> { let Name = "Imm16"; }
724 def imm16 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 16; }]> {
725 let ParserMatchClass = Imm16AsmOperand;
728 /// imm32 predicate - Immediate is exactly 32.
729 def Imm32AsmOperand: ImmAsmOperand<32,32> { let Name = "Imm32"; }
730 def imm32 : Operand<i32>, ImmLeaf<i32, [{ return Imm == 32; }]> {
731 let ParserMatchClass = Imm32AsmOperand;
734 def imm8_or_16 : ImmLeaf<i32, [{ return Imm == 8 || Imm == 16;}]>;
736 /// imm1_7 predicate - Immediate in the range [1,7].
737 def Imm1_7AsmOperand: ImmAsmOperand<1,7> { let Name = "Imm1_7"; }
738 def imm1_7 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 8; }]> {
739 let ParserMatchClass = Imm1_7AsmOperand;
742 /// imm1_15 predicate - Immediate in the range [1,15].
743 def Imm1_15AsmOperand: ImmAsmOperand<1,15> { let Name = "Imm1_15"; }
744 def imm1_15 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 16; }]> {
745 let ParserMatchClass = Imm1_15AsmOperand;
748 /// imm1_31 predicate - Immediate in the range [1,31].
749 def Imm1_31AsmOperand: ImmAsmOperand<1,31> { let Name = "Imm1_31"; }
750 def imm1_31 : Operand<i32>, ImmLeaf<i32, [{ return Imm > 0 && Imm < 32; }]> {
751 let ParserMatchClass = Imm1_31AsmOperand;
754 /// imm0_15 predicate - Immediate in the range [0,15].
755 def Imm0_15AsmOperand: ImmAsmOperand<0,15> {
756 let Name = "Imm0_15";
758 def imm0_15 : Operand<i32>, ImmLeaf<i32, [{
759 return Imm >= 0 && Imm < 16;
761 let ParserMatchClass = Imm0_15AsmOperand;
764 /// imm0_31 predicate - True if the 32-bit immediate is in the range [0,31].
765 def Imm0_31AsmOperand: ImmAsmOperand<0,31> { let Name = "Imm0_31"; }
766 def imm0_31 : Operand<i32>, ImmLeaf<i32, [{
767 return Imm >= 0 && Imm < 32;
769 let ParserMatchClass = Imm0_31AsmOperand;
772 /// imm0_32 predicate - True if the 32-bit immediate is in the range [0,32].
773 def Imm0_32AsmOperand: ImmAsmOperand<0,32> { let Name = "Imm0_32"; }
774 def imm0_32 : Operand<i32>, ImmLeaf<i32, [{
775 return Imm >= 0 && Imm < 33;
777 let ParserMatchClass = Imm0_32AsmOperand;
780 /// imm0_63 predicate - True if the 32-bit immediate is in the range [0,63].
781 def Imm0_63AsmOperand: ImmAsmOperand<0,63> { let Name = "Imm0_63"; }
782 def imm0_63 : Operand<i32>, ImmLeaf<i32, [{
783 return Imm >= 0 && Imm < 64;
785 let ParserMatchClass = Imm0_63AsmOperand;
788 /// imm0_239 predicate - Immediate in the range [0,239].
789 def Imm0_239AsmOperand : ImmAsmOperand<0,239> {
790 let Name = "Imm0_239";
792 def imm0_239 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 240; }]> {
793 let ParserMatchClass = Imm0_239AsmOperand;
796 /// imm0_255 predicate - Immediate in the range [0,255].
797 def Imm0_255AsmOperand : ImmAsmOperand<0,255> { let Name = "Imm0_255"; }
798 def imm0_255 : Operand<i32>, ImmLeaf<i32, [{ return Imm >= 0 && Imm < 256; }]> {
799 let ParserMatchClass = Imm0_255AsmOperand;
802 /// imm0_65535 - An immediate is in the range [0,65535].
803 def Imm0_65535AsmOperand: ImmAsmOperand<0,65535> { let Name = "Imm0_65535"; }
804 def imm0_65535 : Operand<i32>, ImmLeaf<i32, [{
805 return Imm >= 0 && Imm < 65536;
807 let ParserMatchClass = Imm0_65535AsmOperand;
810 // imm0_65535_neg - An immediate whose negative value is in the range [0.65535].
811 def imm0_65535_neg : Operand<i32>, ImmLeaf<i32, [{
812 return -Imm >= 0 && -Imm < 65536;
815 // imm0_65535_expr - For movt/movw - 16-bit immediate that can also reference
816 // a relocatable expression.
818 // FIXME: This really needs a Thumb version separate from the ARM version.
819 // While the range is the same, and can thus use the same match class,
820 // the encoding is different so it should have a different encoder method.
821 def Imm0_65535ExprAsmOperand: AsmOperandClass {
822 let Name = "Imm0_65535Expr";
823 let RenderMethod = "addImmOperands";
824 let DiagnosticString = "operand must be an immediate in the range [0,0xffff] or a relocatable expression";
827 def imm0_65535_expr : Operand<i32> {
828 let EncoderMethod = "getHiLo16ImmOpValue";
829 let ParserMatchClass = Imm0_65535ExprAsmOperand;
832 def Imm256_65535ExprAsmOperand: ImmAsmOperand<256,65535> { let Name = "Imm256_65535Expr"; }
833 def imm256_65535_expr : Operand<i32> {
834 let ParserMatchClass = Imm256_65535ExprAsmOperand;
837 /// imm24b - True if the 32-bit immediate is encodable in 24 bits.
838 def Imm24bitAsmOperand: ImmAsmOperand<0,0xffffff> {
839 let Name = "Imm24bit";
840 let DiagnosticString = "operand must be an immediate in the range [0,0xffffff]";
842 def imm24b : Operand<i32>, ImmLeaf<i32, [{
843 return Imm >= 0 && Imm <= 0xffffff;
845 let ParserMatchClass = Imm24bitAsmOperand;
849 /// bf_inv_mask_imm predicate - An AND mask to clear an arbitrary width bitfield
851 def BitfieldAsmOperand : AsmOperandClass {
852 let Name = "Bitfield";
853 let ParserMethod = "parseBitfield";
856 def bf_inv_mask_imm : Operand<i32>,
858 return ARM::isBitFieldInvertedMask(N->getZExtValue());
860 let EncoderMethod = "getBitfieldInvertedMaskOpValue";
861 let PrintMethod = "printBitfieldInvMaskImmOperand";
862 let DecoderMethod = "DecodeBitfieldMaskOperand";
863 let ParserMatchClass = BitfieldAsmOperand;
864 let GISelPredicateCode = [{
865 // There's better methods of implementing this check. IntImmLeaf<> would be
866 // equivalent and have less boilerplate but we need a test for C++
867 // predicates and this one causes new rules to be imported into GlobalISel
868 // without requiring additional features first.
869 const auto &MO = MI.getOperand(1);
872 return ARM::isBitFieldInvertedMask(MO.getCImm()->getZExtValue());
876 def imm1_32_XFORM: SDNodeXForm<imm, [{
877 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, SDLoc(N),
880 def Imm1_32AsmOperand: ImmAsmOperandMinusOne<1,32> {
881 let Name = "Imm1_32";
883 def imm1_32 : Operand<i32>, PatLeaf<(imm), [{
884 uint64_t Imm = N->getZExtValue();
885 return Imm > 0 && Imm <= 32;
888 let PrintMethod = "printImmPlusOneOperand";
889 let ParserMatchClass = Imm1_32AsmOperand;
892 def imm1_16_XFORM: SDNodeXForm<imm, [{
893 return CurDAG->getTargetConstant((int)N->getZExtValue() - 1, SDLoc(N),
896 def Imm1_16AsmOperand: ImmAsmOperandMinusOne<1,16> { let Name = "Imm1_16"; }
897 def imm1_16 : Operand<i32>, ImmLeaf<i32, [{
898 return Imm > 0 && Imm <= 16;
901 let PrintMethod = "printImmPlusOneOperand";
902 let ParserMatchClass = Imm1_16AsmOperand;
905 def MVEShiftImm1_7AsmOperand: ImmAsmOperand<1,7> {
906 let Name = "MVEShiftImm1_7";
907 // Reason we're doing this is because instruction vshll.s8 t1 encoding
908 // accepts 1,7 but the t2 encoding accepts 8. By doing this we can get a
909 // better diagnostic message if someone uses bigger immediate than the t1/t2
911 let DiagnosticString = "operand must be an immediate in the range [1,8]";
913 def mve_shift_imm1_7 : Operand<i32> {
914 let ParserMatchClass = MVEShiftImm1_7AsmOperand;
915 let EncoderMethod = "getMVEShiftImmOpValue";
918 def MVEShiftImm1_15AsmOperand: ImmAsmOperand<1,15> {
919 let Name = "MVEShiftImm1_15";
920 // Reason we're doing this is because instruction vshll.s16 t1 encoding
921 // accepts 1,15 but the t2 encoding accepts 16. By doing this we can get a
922 // better diagnostic message if someone uses bigger immediate than the t1/t2
924 let DiagnosticString = "operand must be an immediate in the range [1,16]";
926 def mve_shift_imm1_15 : Operand<i32> {
927 let ParserMatchClass = MVEShiftImm1_15AsmOperand;
928 let EncoderMethod = "getMVEShiftImmOpValue";
931 // Define ARM specific addressing modes.
932 // addrmode_imm12 := reg +/- imm12
934 def MemImm12OffsetAsmOperand : AsmOperandClass { let Name = "MemImm12Offset"; }
935 class AddrMode_Imm12 : MemOperand,
936 ComplexPattern<i32, 2, "SelectAddrModeImm12", []> {
937 // 12-bit immediate operand. Note that instructions using this encode
938 // #0 and #-0 differently. We flag #-0 as the magic value INT32_MIN. All other
939 // immediate values are as normal.
941 let EncoderMethod = "getAddrModeImm12OpValue";
942 let DecoderMethod = "DecodeAddrModeImm12Operand";
943 let ParserMatchClass = MemImm12OffsetAsmOperand;
944 let MIOperandInfo = (ops GPR:$base, i32imm:$offsimm);
947 def addrmode_imm12 : AddrMode_Imm12 {
948 let PrintMethod = "printAddrModeImm12Operand<false>";
951 def addrmode_imm12_pre : AddrMode_Imm12 {
952 let PrintMethod = "printAddrModeImm12Operand<true>";
955 // ldst_so_reg := reg +/- reg shop imm
957 def MemRegOffsetAsmOperand : AsmOperandClass { let Name = "MemRegOffset"; }
958 def ldst_so_reg : MemOperand,
959 ComplexPattern<i32, 3, "SelectLdStSOReg", []> {
960 let EncoderMethod = "getLdStSORegOpValue";
961 // FIXME: Simplify the printer
962 let PrintMethod = "printAddrMode2Operand";
963 let DecoderMethod = "DecodeSORegMemOperand";
964 let ParserMatchClass = MemRegOffsetAsmOperand;
965 let MIOperandInfo = (ops GPR:$base, GPRnopc:$offsreg, i32imm:$shift);
968 // postidx_imm8 := +/- [0,255]
971 // {8} 1 is imm8 is non-negative. 0 otherwise.
972 // {7-0} [0,255] imm8 value.
973 def PostIdxImm8AsmOperand : AsmOperandClass { let Name = "PostIdxImm8"; }
974 def postidx_imm8 : MemOperand {
975 let PrintMethod = "printPostIdxImm8Operand";
976 let ParserMatchClass = PostIdxImm8AsmOperand;
977 let MIOperandInfo = (ops i32imm);
980 // postidx_imm8s4 := +/- [0,1020]
983 // {8} 1 is imm8 is non-negative. 0 otherwise.
984 // {7-0} [0,255] imm8 value, scaled by 4.
985 def PostIdxImm8s4AsmOperand : AsmOperandClass { let Name = "PostIdxImm8s4"; }
986 def postidx_imm8s4 : MemOperand {
987 let PrintMethod = "printPostIdxImm8s4Operand";
988 let ParserMatchClass = PostIdxImm8s4AsmOperand;
989 let MIOperandInfo = (ops i32imm);
993 // postidx_reg := +/- reg
995 def PostIdxRegAsmOperand : AsmOperandClass {
996 let Name = "PostIdxReg";
997 let ParserMethod = "parsePostIdxReg";
999 def postidx_reg : MemOperand {
1000 let EncoderMethod = "getPostIdxRegOpValue";
1001 let DecoderMethod = "DecodePostIdxReg";
1002 let PrintMethod = "printPostIdxRegOperand";
1003 let ParserMatchClass = PostIdxRegAsmOperand;
1004 let MIOperandInfo = (ops GPRnopc, i32imm);
1007 def PostIdxRegShiftedAsmOperand : AsmOperandClass {
1008 let Name = "PostIdxRegShifted";
1009 let ParserMethod = "parsePostIdxReg";
1011 def am2offset_reg : MemOperand,
1012 ComplexPattern<i32, 2, "SelectAddrMode2OffsetReg",
1013 [], [SDNPWantRoot]> {
1014 let EncoderMethod = "getAddrMode2OffsetOpValue";
1015 let PrintMethod = "printAddrMode2OffsetOperand";
1016 // When using this for assembly, it's always as a post-index offset.
1017 let ParserMatchClass = PostIdxRegShiftedAsmOperand;
1018 let MIOperandInfo = (ops GPRnopc, i32imm);
1021 // FIXME: am2offset_imm should only need the immediate, not the GPR. Having
1022 // the GPR is purely vestigal at this point.
1023 def AM2OffsetImmAsmOperand : AsmOperandClass { let Name = "AM2OffsetImm"; }
1024 def am2offset_imm : MemOperand,
1025 ComplexPattern<i32, 2, "SelectAddrMode2OffsetImm",
1026 [], [SDNPWantRoot]> {
1027 let EncoderMethod = "getAddrMode2OffsetOpValue";
1028 let PrintMethod = "printAddrMode2OffsetOperand";
1029 let ParserMatchClass = AM2OffsetImmAsmOperand;
1030 let MIOperandInfo = (ops GPRnopc, i32imm);
1034 // addrmode3 := reg +/- reg
1035 // addrmode3 := reg +/- imm8
1037 // FIXME: split into imm vs. reg versions.
1038 def AddrMode3AsmOperand : AsmOperandClass { let Name = "AddrMode3"; }
1039 class AddrMode3 : MemOperand,
1040 ComplexPattern<i32, 3, "SelectAddrMode3", []> {
1041 let EncoderMethod = "getAddrMode3OpValue";
1042 let ParserMatchClass = AddrMode3AsmOperand;
1043 let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
1046 def addrmode3 : AddrMode3
1048 let PrintMethod = "printAddrMode3Operand<false>";
1051 def addrmode3_pre : AddrMode3
1053 let PrintMethod = "printAddrMode3Operand<true>";
1056 // FIXME: split into imm vs. reg versions.
1057 // FIXME: parser method to handle +/- register.
1058 def AM3OffsetAsmOperand : AsmOperandClass {
1059 let Name = "AM3Offset";
1060 let ParserMethod = "parseAM3Offset";
1062 def am3offset : MemOperand,
1063 ComplexPattern<i32, 2, "SelectAddrMode3Offset",
1064 [], [SDNPWantRoot]> {
1065 let EncoderMethod = "getAddrMode3OffsetOpValue";
1066 let PrintMethod = "printAddrMode3OffsetOperand";
1067 let ParserMatchClass = AM3OffsetAsmOperand;
1068 let MIOperandInfo = (ops GPR, i32imm);
1071 // ldstm_mode := {ia, ib, da, db}
1073 def ldstm_mode : OptionalDefOperand<OtherVT, (ops i32), (ops (i32 1))> {
1074 let EncoderMethod = "getLdStmModeOpValue";
1075 let PrintMethod = "printLdStmModeOperand";
1078 // addrmode5 := reg +/- imm8*4
1080 def AddrMode5AsmOperand : AsmOperandClass { let Name = "AddrMode5"; }
1081 class AddrMode5 : MemOperand,
1082 ComplexPattern<i32, 2, "SelectAddrMode5", []> {
1083 let EncoderMethod = "getAddrMode5OpValue";
1084 let DecoderMethod = "DecodeAddrMode5Operand";
1085 let ParserMatchClass = AddrMode5AsmOperand;
1086 let MIOperandInfo = (ops GPR:$base, i32imm);
1089 def addrmode5 : AddrMode5 {
1090 let PrintMethod = "printAddrMode5Operand<false>";
1093 def addrmode5_pre : AddrMode5 {
1094 let PrintMethod = "printAddrMode5Operand<true>";
1097 // addrmode5fp16 := reg +/- imm8*2
1099 def AddrMode5FP16AsmOperand : AsmOperandClass { let Name = "AddrMode5FP16"; }
1100 class AddrMode5FP16 : Operand<i32>,
1101 ComplexPattern<i32, 2, "SelectAddrMode5FP16", []> {
1102 let EncoderMethod = "getAddrMode5FP16OpValue";
1103 let DecoderMethod = "DecodeAddrMode5FP16Operand";
1104 let ParserMatchClass = AddrMode5FP16AsmOperand;
1105 let MIOperandInfo = (ops GPR:$base, i32imm);
1108 def addrmode5fp16 : AddrMode5FP16 {
1109 let PrintMethod = "printAddrMode5FP16Operand<false>";
1112 // addrmode6 := reg with optional alignment
1114 def AddrMode6AsmOperand : AsmOperandClass { let Name = "AlignedMemory"; }
1115 def addrmode6 : MemOperand,
1116 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1117 let PrintMethod = "printAddrMode6Operand";
1118 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
1119 let EncoderMethod = "getAddrMode6AddressOpValue";
1120 let DecoderMethod = "DecodeAddrMode6Operand";
1121 let ParserMatchClass = AddrMode6AsmOperand;
1124 def am6offset : MemOperand,
1125 ComplexPattern<i32, 1, "SelectAddrMode6Offset",
1126 [], [SDNPWantRoot]> {
1127 let PrintMethod = "printAddrMode6OffsetOperand";
1128 let MIOperandInfo = (ops GPR);
1129 let EncoderMethod = "getAddrMode6OffsetOpValue";
1130 let DecoderMethod = "DecodeGPRRegisterClass";
1133 // Special version of addrmode6 to handle alignment encoding for VST1/VLD1
1134 // (single element from one lane) for size 32.
1135 def addrmode6oneL32 : MemOperand,
1136 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1137 let PrintMethod = "printAddrMode6Operand";
1138 let MIOperandInfo = (ops GPR:$addr, i32imm);
1139 let EncoderMethod = "getAddrMode6OneLane32AddressOpValue";
1142 // Base class for addrmode6 with specific alignment restrictions.
1143 class AddrMode6Align : MemOperand,
1144 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1145 let PrintMethod = "printAddrMode6Operand";
1146 let MIOperandInfo = (ops GPR:$addr, i32imm:$align);
1147 let EncoderMethod = "getAddrMode6AddressOpValue";
1148 let DecoderMethod = "DecodeAddrMode6Operand";
1151 // Special version of addrmode6 to handle no allowed alignment encoding for
1152 // VLD/VST instructions and checking the alignment is not specified.
1153 def AddrMode6AlignNoneAsmOperand : AsmOperandClass {
1154 let Name = "AlignedMemoryNone";
1155 let DiagnosticString = "alignment must be omitted";
1157 def addrmode6alignNone : AddrMode6Align {
1158 // The alignment specifier can only be omitted.
1159 let ParserMatchClass = AddrMode6AlignNoneAsmOperand;
1162 // Special version of addrmode6 to handle 16-bit alignment encoding for
1163 // VLD/VST instructions and checking the alignment value.
1164 def AddrMode6Align16AsmOperand : AsmOperandClass {
1165 let Name = "AlignedMemory16";
1166 let DiagnosticString = "alignment must be 16 or omitted";
1168 def addrmode6align16 : AddrMode6Align {
1169 // The alignment specifier can only be 16 or omitted.
1170 let ParserMatchClass = AddrMode6Align16AsmOperand;
1173 // Special version of addrmode6 to handle 32-bit alignment encoding for
1174 // VLD/VST instructions and checking the alignment value.
1175 def AddrMode6Align32AsmOperand : AsmOperandClass {
1176 let Name = "AlignedMemory32";
1177 let DiagnosticString = "alignment must be 32 or omitted";
1179 def addrmode6align32 : AddrMode6Align {
1180 // The alignment specifier can only be 32 or omitted.
1181 let ParserMatchClass = AddrMode6Align32AsmOperand;
1184 // Special version of addrmode6 to handle 64-bit alignment encoding for
1185 // VLD/VST instructions and checking the alignment value.
1186 def AddrMode6Align64AsmOperand : AsmOperandClass {
1187 let Name = "AlignedMemory64";
1188 let DiagnosticString = "alignment must be 64 or omitted";
1190 def addrmode6align64 : AddrMode6Align {
1191 // The alignment specifier can only be 64 or omitted.
1192 let ParserMatchClass = AddrMode6Align64AsmOperand;
1195 // Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding
1196 // for VLD/VST instructions and checking the alignment value.
1197 def AddrMode6Align64or128AsmOperand : AsmOperandClass {
1198 let Name = "AlignedMemory64or128";
1199 let DiagnosticString = "alignment must be 64, 128 or omitted";
1201 def addrmode6align64or128 : AddrMode6Align {
1202 // The alignment specifier can only be 64, 128 or omitted.
1203 let ParserMatchClass = AddrMode6Align64or128AsmOperand;
1206 // Special version of addrmode6 to handle 64-bit, 128-bit or 256-bit alignment
1207 // encoding for VLD/VST instructions and checking the alignment value.
1208 def AddrMode6Align64or128or256AsmOperand : AsmOperandClass {
1209 let Name = "AlignedMemory64or128or256";
1210 let DiagnosticString = "alignment must be 64, 128, 256 or omitted";
1212 def addrmode6align64or128or256 : AddrMode6Align {
1213 // The alignment specifier can only be 64, 128, 256 or omitted.
1214 let ParserMatchClass = AddrMode6Align64or128or256AsmOperand;
1217 // Special version of addrmode6 to handle alignment encoding for VLD-dup
1218 // instructions, specifically VLD4-dup.
1219 def addrmode6dup : MemOperand,
1220 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1221 let PrintMethod = "printAddrMode6Operand";
1222 let MIOperandInfo = (ops GPR:$addr, i32imm);
1223 let EncoderMethod = "getAddrMode6DupAddressOpValue";
1224 // FIXME: This is close, but not quite right. The alignment specifier is
1226 let ParserMatchClass = AddrMode6AsmOperand;
1229 // Base class for addrmode6dup with specific alignment restrictions.
1230 class AddrMode6DupAlign : MemOperand,
1231 ComplexPattern<i32, 2, "SelectAddrMode6", [], [SDNPWantParent]>{
1232 let PrintMethod = "printAddrMode6Operand";
1233 let MIOperandInfo = (ops GPR:$addr, i32imm);
1234 let EncoderMethod = "getAddrMode6DupAddressOpValue";
1237 // Special version of addrmode6 to handle no allowed alignment encoding for
1238 // VLD-dup instruction and checking the alignment is not specified.
1239 def AddrMode6dupAlignNoneAsmOperand : AsmOperandClass {
1240 let Name = "DupAlignedMemoryNone";
1241 let DiagnosticString = "alignment must be omitted";
1243 def addrmode6dupalignNone : AddrMode6DupAlign {
1244 // The alignment specifier can only be omitted.
1245 let ParserMatchClass = AddrMode6dupAlignNoneAsmOperand;
1248 // Special version of addrmode6 to handle 16-bit alignment encoding for VLD-dup
1249 // instruction and checking the alignment value.
1250 def AddrMode6dupAlign16AsmOperand : AsmOperandClass {
1251 let Name = "DupAlignedMemory16";
1252 let DiagnosticString = "alignment must be 16 or omitted";
1254 def addrmode6dupalign16 : AddrMode6DupAlign {
1255 // The alignment specifier can only be 16 or omitted.
1256 let ParserMatchClass = AddrMode6dupAlign16AsmOperand;
1259 // Special version of addrmode6 to handle 32-bit alignment encoding for VLD-dup
1260 // instruction and checking the alignment value.
1261 def AddrMode6dupAlign32AsmOperand : AsmOperandClass {
1262 let Name = "DupAlignedMemory32";
1263 let DiagnosticString = "alignment must be 32 or omitted";
1265 def addrmode6dupalign32 : AddrMode6DupAlign {
1266 // The alignment specifier can only be 32 or omitted.
1267 let ParserMatchClass = AddrMode6dupAlign32AsmOperand;
1270 // Special version of addrmode6 to handle 64-bit alignment encoding for VLD
1271 // instructions and checking the alignment value.
1272 def AddrMode6dupAlign64AsmOperand : AsmOperandClass {
1273 let Name = "DupAlignedMemory64";
1274 let DiagnosticString = "alignment must be 64 or omitted";
1276 def addrmode6dupalign64 : AddrMode6DupAlign {
1277 // The alignment specifier can only be 64 or omitted.
1278 let ParserMatchClass = AddrMode6dupAlign64AsmOperand;
1281 // Special version of addrmode6 to handle 64-bit or 128-bit alignment encoding
1282 // for VLD instructions and checking the alignment value.
1283 def AddrMode6dupAlign64or128AsmOperand : AsmOperandClass {
1284 let Name = "DupAlignedMemory64or128";
1285 let DiagnosticString = "alignment must be 64, 128 or omitted";
1287 def addrmode6dupalign64or128 : AddrMode6DupAlign {
1288 // The alignment specifier can only be 64, 128 or omitted.
1289 let ParserMatchClass = AddrMode6dupAlign64or128AsmOperand;
1292 // addrmodepc := pc + reg
1294 def addrmodepc : MemOperand,
1295 ComplexPattern<i32, 2, "SelectAddrModePC", []> {
1296 let PrintMethod = "printAddrModePCOperand";
1297 let MIOperandInfo = (ops GPR, i32imm);
1300 // addr_offset_none := reg
1302 def MemNoOffsetAsmOperand : AsmOperandClass { let Name = "MemNoOffset"; }
1303 def addr_offset_none : MemOperand,
1304 ComplexPattern<i32, 1, "SelectAddrOffsetNone", []> {
1305 let PrintMethod = "printAddrMode7Operand";
1306 let DecoderMethod = "DecodeAddrMode7Operand";
1307 let ParserMatchClass = MemNoOffsetAsmOperand;
1308 let MIOperandInfo = (ops GPR:$base);
1311 // t_addr_offset_none := reg [r0-r7]
1312 def MemNoOffsetTAsmOperand : AsmOperandClass { let Name = "MemNoOffsetT"; }
1313 def t_addr_offset_none : MemOperand {
1314 let PrintMethod = "printAddrMode7Operand";
1315 let DecoderMethod = "DecodetGPRRegisterClass";
1316 let ParserMatchClass = MemNoOffsetTAsmOperand;
1317 let MIOperandInfo = (ops tGPR:$base);
1320 def nohash_imm : Operand<i32> {
1321 let PrintMethod = "printNoHashImmediate";
1324 def CoprocNumAsmOperand : AsmOperandClass {
1325 let Name = "CoprocNum";
1326 let ParserMethod = "parseCoprocNumOperand";
1328 def p_imm : Operand<i32> {
1329 let PrintMethod = "printPImmediate";
1330 let ParserMatchClass = CoprocNumAsmOperand;
1331 let DecoderMethod = "DecodeCoprocessor";
1334 def CoprocRegAsmOperand : AsmOperandClass {
1335 let Name = "CoprocReg";
1336 let ParserMethod = "parseCoprocRegOperand";
1338 def c_imm : Operand<i32> {
1339 let PrintMethod = "printCImmediate";
1340 let ParserMatchClass = CoprocRegAsmOperand;
1342 def CoprocOptionAsmOperand : AsmOperandClass {
1343 let Name = "CoprocOption";
1344 let ParserMethod = "parseCoprocOptionOperand";
1346 def coproc_option_imm : Operand<i32> {
1347 let PrintMethod = "printCoprocOptionImm";
1348 let ParserMatchClass = CoprocOptionAsmOperand;
1351 //===----------------------------------------------------------------------===//
1353 include "ARMInstrFormats.td"
1355 //===----------------------------------------------------------------------===//
1356 // Multiclass helpers...
1359 /// AsI1_bin_irs - Defines a set of (op r, {mod_imm|r|so_reg}) patterns for a
1360 /// binop that produces a value.
1361 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1362 multiclass AsI1_bin_irs<bits<4> opcod, string opc,
1363 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1364 SDPatternOperator opnode, bit Commutable = 0> {
1365 // The register-immediate version is re-materializable. This is useful
1366 // in particular for taking the address of a local.
1367 let isReMaterializable = 1 in {
1368 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm,
1369 iii, opc, "\t$Rd, $Rn, $imm",
1370 [(set GPR:$Rd, (opnode GPR:$Rn, mod_imm:$imm))]>,
1371 Sched<[WriteALU, ReadALU]> {
1376 let Inst{19-16} = Rn;
1377 let Inst{15-12} = Rd;
1378 let Inst{11-0} = imm;
1381 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1382 iir, opc, "\t$Rd, $Rn, $Rm",
1383 [(set GPR:$Rd, (opnode GPR:$Rn, GPR:$Rm))]>,
1384 Sched<[WriteALU, ReadALU, ReadALU]> {
1389 let isCommutable = Commutable;
1390 let Inst{19-16} = Rn;
1391 let Inst{15-12} = Rd;
1392 let Inst{11-4} = 0b00000000;
1396 def rsi : AsI1<opcod, (outs GPR:$Rd),
1397 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1398 iis, opc, "\t$Rd, $Rn, $shift",
1399 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_imm:$shift))]>,
1400 Sched<[WriteALUsi, ReadALU]> {
1405 let Inst{19-16} = Rn;
1406 let Inst{15-12} = Rd;
1407 let Inst{11-5} = shift{11-5};
1409 let Inst{3-0} = shift{3-0};
1412 def rsr : AsI1<opcod, (outs GPR:$Rd),
1413 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1414 iis, opc, "\t$Rd, $Rn, $shift",
1415 [(set GPR:$Rd, (opnode GPR:$Rn, so_reg_reg:$shift))]>,
1416 Sched<[WriteALUsr, ReadALUsr]> {
1421 let Inst{19-16} = Rn;
1422 let Inst{15-12} = Rd;
1423 let Inst{11-8} = shift{11-8};
1425 let Inst{6-5} = shift{6-5};
1427 let Inst{3-0} = shift{3-0};
1431 /// AsI1_rbin_irs - Same as AsI1_bin_irs except the order of operands are
1432 /// reversed. The 'rr' form is only defined for the disassembler; for codegen
1433 /// it is equivalent to the AsI1_bin_irs counterpart.
1434 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1435 multiclass AsI1_rbin_irs<bits<4> opcod, string opc,
1436 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1437 SDNode opnode, bit Commutable = 0> {
1438 // The register-immediate version is re-materializable. This is useful
1439 // in particular for taking the address of a local.
1440 let isReMaterializable = 1 in {
1441 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm), DPFrm,
1442 iii, opc, "\t$Rd, $Rn, $imm",
1443 [(set GPR:$Rd, (opnode mod_imm:$imm, GPR:$Rn))]>,
1444 Sched<[WriteALU, ReadALU]> {
1449 let Inst{19-16} = Rn;
1450 let Inst{15-12} = Rd;
1451 let Inst{11-0} = imm;
1454 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm,
1455 iir, opc, "\t$Rd, $Rn, $Rm",
1456 [/* pattern left blank */]>,
1457 Sched<[WriteALU, ReadALU, ReadALU]> {
1461 let Inst{11-4} = 0b00000000;
1464 let Inst{15-12} = Rd;
1465 let Inst{19-16} = Rn;
1468 def rsi : AsI1<opcod, (outs GPR:$Rd),
1469 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm,
1470 iis, opc, "\t$Rd, $Rn, $shift",
1471 [(set GPR:$Rd, (opnode so_reg_imm:$shift, GPR:$Rn))]>,
1472 Sched<[WriteALUsi, ReadALU]> {
1477 let Inst{19-16} = Rn;
1478 let Inst{15-12} = Rd;
1479 let Inst{11-5} = shift{11-5};
1481 let Inst{3-0} = shift{3-0};
1484 def rsr : AsI1<opcod, (outs GPR:$Rd),
1485 (ins GPR:$Rn, so_reg_reg:$shift), DPSoRegRegFrm,
1486 iis, opc, "\t$Rd, $Rn, $shift",
1487 [(set GPR:$Rd, (opnode so_reg_reg:$shift, GPR:$Rn))]>,
1488 Sched<[WriteALUsr, ReadALUsr]> {
1493 let Inst{19-16} = Rn;
1494 let Inst{15-12} = Rd;
1495 let Inst{11-8} = shift{11-8};
1497 let Inst{6-5} = shift{6-5};
1499 let Inst{3-0} = shift{3-0};
1503 /// AsI1_bin_s_irs - Same as AsI1_bin_irs except it sets the 's' bit by default.
1505 /// These opcodes will be converted to the real non-S opcodes by
1506 /// AdjustInstrPostInstrSelection after giving them an optional CPSR operand.
1507 let hasPostISelHook = 1, Defs = [CPSR] in {
1508 multiclass AsI1_bin_s_irs<InstrItinClass iii, InstrItinClass iir,
1509 InstrItinClass iis, SDNode opnode,
1510 bit Commutable = 0> {
1511 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p),
1513 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm))]>,
1514 Sched<[WriteALU, ReadALU]>;
1516 def rr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, pred:$p),
1518 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm))]>,
1519 Sched<[WriteALU, ReadALU, ReadALU]> {
1520 let isCommutable = Commutable;
1522 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1523 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1525 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1526 so_reg_imm:$shift))]>,
1527 Sched<[WriteALUsi, ReadALU]>;
1529 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1530 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1532 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn,
1533 so_reg_reg:$shift))]>,
1534 Sched<[WriteALUSsr, ReadALUsr]>;
1538 /// AsI1_rbin_s_is - Same as AsI1_bin_s_irs, except selection DAG
1539 /// operands are reversed.
1540 let hasPostISelHook = 1, Defs = [CPSR] in {
1541 multiclass AsI1_rbin_s_is<InstrItinClass iii, InstrItinClass iir,
1542 InstrItinClass iis, SDNode opnode,
1543 bit Commutable = 0> {
1544 def ri : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm, pred:$p),
1546 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn))]>,
1547 Sched<[WriteALU, ReadALU]>;
1549 def rsi : ARMPseudoInst<(outs GPR:$Rd),
1550 (ins GPR:$Rn, so_reg_imm:$shift, pred:$p),
1552 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift,
1554 Sched<[WriteALUsi, ReadALU]>;
1556 def rsr : ARMPseudoInst<(outs GPR:$Rd),
1557 (ins GPR:$Rn, so_reg_reg:$shift, pred:$p),
1559 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift,
1561 Sched<[WriteALUSsr, ReadALUsr]>;
1565 /// AI1_cmp_irs - Defines a set of (op r, {mod_imm|r|so_reg}) cmp / test
1566 /// patterns. Similar to AsI1_bin_irs except the instruction does not produce
1567 /// a explicit result, only implicitly set CPSR.
1568 let isCompare = 1, Defs = [CPSR] in {
1569 multiclass AI1_cmp_irs<bits<4> opcod, string opc,
1570 InstrItinClass iii, InstrItinClass iir, InstrItinClass iis,
1571 SDPatternOperator opnode, bit Commutable = 0,
1572 string rrDecoderMethod = ""> {
1573 def ri : AI1<opcod, (outs), (ins GPR:$Rn, mod_imm:$imm), DPFrm, iii,
1575 [(opnode GPR:$Rn, mod_imm:$imm)]>,
1576 Sched<[WriteCMP, ReadALU]> {
1581 let Inst{19-16} = Rn;
1582 let Inst{15-12} = 0b0000;
1583 let Inst{11-0} = imm;
1585 let Unpredictable{15-12} = 0b1111;
1587 def rr : AI1<opcod, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, iir,
1589 [(opnode GPR:$Rn, GPR:$Rm)]>,
1590 Sched<[WriteCMP, ReadALU, ReadALU]> {
1593 let isCommutable = Commutable;
1596 let Inst{19-16} = Rn;
1597 let Inst{15-12} = 0b0000;
1598 let Inst{11-4} = 0b00000000;
1600 let DecoderMethod = rrDecoderMethod;
1602 let Unpredictable{15-12} = 0b1111;
1604 def rsi : AI1<opcod, (outs),
1605 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, iis,
1606 opc, "\t$Rn, $shift",
1607 [(opnode GPR:$Rn, so_reg_imm:$shift)]>,
1608 Sched<[WriteCMPsi, ReadALU]> {
1613 let Inst{19-16} = Rn;
1614 let Inst{15-12} = 0b0000;
1615 let Inst{11-5} = shift{11-5};
1617 let Inst{3-0} = shift{3-0};
1619 let Unpredictable{15-12} = 0b1111;
1621 def rsr : AI1<opcod, (outs),
1622 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, iis,
1623 opc, "\t$Rn, $shift",
1624 [(opnode GPRnopc:$Rn, so_reg_reg:$shift)]>,
1625 Sched<[WriteCMPsr, ReadALU]> {
1630 let Inst{19-16} = Rn;
1631 let Inst{15-12} = 0b0000;
1632 let Inst{11-8} = shift{11-8};
1634 let Inst{6-5} = shift{6-5};
1636 let Inst{3-0} = shift{3-0};
1638 let Unpredictable{15-12} = 0b1111;
1644 /// AI_ext_rrot - A unary operation with two forms: one whose operand is a
1645 /// register and one whose operand is a register rotated by 8/16/24.
1646 /// FIXME: Remove the 'r' variant. Its rot_imm is zero.
1647 class AI_ext_rrot<bits<8> opcod, string opc, PatFrag opnode>
1648 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1649 IIC_iEXTr, opc, "\t$Rd, $Rm$rot",
1650 [(set GPRnopc:$Rd, (opnode (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1651 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> {
1655 let Inst{19-16} = 0b1111;
1656 let Inst{15-12} = Rd;
1657 let Inst{11-10} = rot;
1661 class AI_ext_rrot_np<bits<8> opcod, string opc>
1662 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPRnopc:$Rm, rot_imm:$rot),
1663 IIC_iEXTr, opc, "\t$Rd, $Rm$rot", []>,
1664 Requires<[IsARM, HasV6]>, Sched<[WriteALUsi]> {
1666 let Inst{19-16} = 0b1111;
1667 let Inst{11-10} = rot;
1670 /// AI_exta_rrot - A binary operation with two forms: one whose operand is a
1671 /// register and one whose operand is a register rotated by 8/16/24.
1672 class AI_exta_rrot<bits<8> opcod, string opc, PatFrag opnode>
1673 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1674 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot",
1675 [(set GPRnopc:$Rd, (opnode GPR:$Rn,
1676 (rotr GPRnopc:$Rm, rot_imm:$rot)))]>,
1677 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> {
1682 let Inst{19-16} = Rn;
1683 let Inst{15-12} = Rd;
1684 let Inst{11-10} = rot;
1685 let Inst{9-4} = 0b000111;
1689 class AI_exta_rrot_np<bits<8> opcod, string opc>
1690 : AExtI<opcod, (outs GPRnopc:$Rd), (ins GPR:$Rn, GPRnopc:$Rm, rot_imm:$rot),
1691 IIC_iEXTAr, opc, "\t$Rd, $Rn, $Rm$rot", []>,
1692 Requires<[IsARM, HasV6]>, Sched<[WriteALUsr]> {
1695 let Inst{19-16} = Rn;
1696 let Inst{11-10} = rot;
1699 /// AI1_adde_sube_irs - Define instructions and patterns for adde and sube.
1700 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1701 multiclass AI1_adde_sube_irs<bits<4> opcod, string opc, SDNode opnode,
1702 bit Commutable = 0> {
1703 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1704 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm),
1705 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1706 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, mod_imm:$imm, CPSR))]>,
1708 Sched<[WriteALU, ReadALU]> {
1713 let Inst{15-12} = Rd;
1714 let Inst{19-16} = Rn;
1715 let Inst{11-0} = imm;
1717 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1718 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1719 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, GPR:$Rm, CPSR))]>,
1721 Sched<[WriteALU, ReadALU, ReadALU]> {
1725 let Inst{11-4} = 0b00000000;
1727 let isCommutable = Commutable;
1729 let Inst{15-12} = Rd;
1730 let Inst{19-16} = Rn;
1732 def rsi : AsI1<opcod, (outs GPR:$Rd),
1733 (ins GPR:$Rn, so_reg_imm:$shift),
1734 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1735 [(set GPR:$Rd, CPSR, (opnode GPR:$Rn, so_reg_imm:$shift, CPSR))]>,
1737 Sched<[WriteALUsi, ReadALU]> {
1742 let Inst{19-16} = Rn;
1743 let Inst{15-12} = Rd;
1744 let Inst{11-5} = shift{11-5};
1746 let Inst{3-0} = shift{3-0};
1748 def rsr : AsI1<opcod, (outs GPRnopc:$Rd),
1749 (ins GPRnopc:$Rn, so_reg_reg:$shift),
1750 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1751 [(set GPRnopc:$Rd, CPSR,
1752 (opnode GPRnopc:$Rn, so_reg_reg:$shift, CPSR))]>,
1754 Sched<[WriteALUsr, ReadALUsr]> {
1759 let Inst{19-16} = Rn;
1760 let Inst{15-12} = Rd;
1761 let Inst{11-8} = shift{11-8};
1763 let Inst{6-5} = shift{6-5};
1765 let Inst{3-0} = shift{3-0};
1770 /// AI1_rsc_irs - Define instructions and patterns for rsc
1771 let TwoOperandAliasConstraint = "$Rn = $Rd" in
1772 multiclass AI1_rsc_irs<bits<4> opcod, string opc, SDNode opnode> {
1773 let hasPostISelHook = 1, Defs = [CPSR], Uses = [CPSR] in {
1774 def ri : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, mod_imm:$imm),
1775 DPFrm, IIC_iALUi, opc, "\t$Rd, $Rn, $imm",
1776 [(set GPR:$Rd, CPSR, (opnode mod_imm:$imm, GPR:$Rn, CPSR))]>,
1778 Sched<[WriteALU, ReadALU]> {
1783 let Inst{15-12} = Rd;
1784 let Inst{19-16} = Rn;
1785 let Inst{11-0} = imm;
1787 def rr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
1788 DPFrm, IIC_iALUr, opc, "\t$Rd, $Rn, $Rm",
1789 [/* pattern left blank */]>,
1790 Sched<[WriteALU, ReadALU, ReadALU]> {
1794 let Inst{11-4} = 0b00000000;
1797 let Inst{15-12} = Rd;
1798 let Inst{19-16} = Rn;
1800 def rsi : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_imm:$shift),
1801 DPSoRegImmFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1802 [(set GPR:$Rd, CPSR, (opnode so_reg_imm:$shift, GPR:$Rn, CPSR))]>,
1804 Sched<[WriteALUsi, ReadALU]> {
1809 let Inst{19-16} = Rn;
1810 let Inst{15-12} = Rd;
1811 let Inst{11-5} = shift{11-5};
1813 let Inst{3-0} = shift{3-0};
1815 def rsr : AsI1<opcod, (outs GPR:$Rd), (ins GPR:$Rn, so_reg_reg:$shift),
1816 DPSoRegRegFrm, IIC_iALUsr, opc, "\t$Rd, $Rn, $shift",
1817 [(set GPR:$Rd, CPSR, (opnode so_reg_reg:$shift, GPR:$Rn, CPSR))]>,
1819 Sched<[WriteALUsr, ReadALUsr]> {
1824 let Inst{19-16} = Rn;
1825 let Inst{15-12} = Rd;
1826 let Inst{11-8} = shift{11-8};
1828 let Inst{6-5} = shift{6-5};
1830 let Inst{3-0} = shift{3-0};
1835 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1836 multiclass AI_ldr1<bit isByte, string opc, InstrItinClass iii,
1837 InstrItinClass iir, PatFrag opnode> {
1838 // Note: We use the complex addrmode_imm12 rather than just an input
1839 // GPR and a constrained immediate so that we can use this to match
1840 // frame index references and avoid matching constant pool references.
1841 def i12: AI2ldst<0b010, 1, isByte, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
1842 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1843 [(set GPR:$Rt, (opnode addrmode_imm12:$addr))]> {
1846 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1847 let Inst{19-16} = addr{16-13}; // Rn
1848 let Inst{15-12} = Rt;
1849 let Inst{11-0} = addr{11-0}; // imm12
1851 def rs : AI2ldst<0b011, 1, isByte, (outs GPR:$Rt), (ins ldst_so_reg:$shift),
1852 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1853 [(set GPR:$Rt, (opnode ldst_so_reg:$shift))]> {
1856 let shift{4} = 0; // Inst{4} = 0
1857 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1858 let Inst{19-16} = shift{16-13}; // Rn
1859 let Inst{15-12} = Rt;
1860 let Inst{11-0} = shift{11-0};
1865 let canFoldAsLoad = 1, isReMaterializable = 1 in {
1866 multiclass AI_ldr1nopc<bit isByte, string opc, InstrItinClass iii,
1867 InstrItinClass iir, PatFrag opnode> {
1868 // Note: We use the complex addrmode_imm12 rather than just an input
1869 // GPR and a constrained immediate so that we can use this to match
1870 // frame index references and avoid matching constant pool references.
1871 def i12: AI2ldst<0b010, 1, isByte, (outs GPRnopc:$Rt),
1872 (ins addrmode_imm12:$addr),
1873 AddrMode_i12, LdFrm, iii, opc, "\t$Rt, $addr",
1874 [(set GPRnopc:$Rt, (opnode addrmode_imm12:$addr))]> {
1877 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1878 let Inst{19-16} = addr{16-13}; // Rn
1879 let Inst{15-12} = Rt;
1880 let Inst{11-0} = addr{11-0}; // imm12
1882 def rs : AI2ldst<0b011, 1, isByte, (outs GPRnopc:$Rt),
1883 (ins ldst_so_reg:$shift),
1884 AddrModeNone, LdFrm, iir, opc, "\t$Rt, $shift",
1885 [(set GPRnopc:$Rt, (opnode ldst_so_reg:$shift))]> {
1888 let shift{4} = 0; // Inst{4} = 0
1889 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1890 let Inst{19-16} = shift{16-13}; // Rn
1891 let Inst{15-12} = Rt;
1892 let Inst{11-0} = shift{11-0};
1898 multiclass AI_str1<bit isByte, string opc, InstrItinClass iii,
1899 InstrItinClass iir, PatFrag opnode> {
1900 // Note: We use the complex addrmode_imm12 rather than just an input
1901 // GPR and a constrained immediate so that we can use this to match
1902 // frame index references and avoid matching constant pool references.
1903 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1904 (ins GPR:$Rt, addrmode_imm12:$addr),
1905 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1906 [(opnode GPR:$Rt, addrmode_imm12:$addr)]> {
1909 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1910 let Inst{19-16} = addr{16-13}; // Rn
1911 let Inst{15-12} = Rt;
1912 let Inst{11-0} = addr{11-0}; // imm12
1914 def rs : AI2ldst<0b011, 0, isByte, (outs), (ins GPR:$Rt, ldst_so_reg:$shift),
1915 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1916 [(opnode GPR:$Rt, ldst_so_reg:$shift)]> {
1919 let shift{4} = 0; // Inst{4} = 0
1920 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1921 let Inst{19-16} = shift{16-13}; // Rn
1922 let Inst{15-12} = Rt;
1923 let Inst{11-0} = shift{11-0};
1927 multiclass AI_str1nopc<bit isByte, string opc, InstrItinClass iii,
1928 InstrItinClass iir, PatFrag opnode> {
1929 // Note: We use the complex addrmode_imm12 rather than just an input
1930 // GPR and a constrained immediate so that we can use this to match
1931 // frame index references and avoid matching constant pool references.
1932 def i12 : AI2ldst<0b010, 0, isByte, (outs),
1933 (ins GPRnopc:$Rt, addrmode_imm12:$addr),
1934 AddrMode_i12, StFrm, iii, opc, "\t$Rt, $addr",
1935 [(opnode GPRnopc:$Rt, addrmode_imm12:$addr)]> {
1938 let Inst{23} = addr{12}; // U (add = ('U' == 1))
1939 let Inst{19-16} = addr{16-13}; // Rn
1940 let Inst{15-12} = Rt;
1941 let Inst{11-0} = addr{11-0}; // imm12
1943 def rs : AI2ldst<0b011, 0, isByte, (outs),
1944 (ins GPRnopc:$Rt, ldst_so_reg:$shift),
1945 AddrModeNone, StFrm, iir, opc, "\t$Rt, $shift",
1946 [(opnode GPRnopc:$Rt, ldst_so_reg:$shift)]> {
1949 let shift{4} = 0; // Inst{4} = 0
1950 let Inst{23} = shift{12}; // U (add = ('U' == 1))
1951 let Inst{19-16} = shift{16-13}; // Rn
1952 let Inst{15-12} = Rt;
1953 let Inst{11-0} = shift{11-0};
1958 //===----------------------------------------------------------------------===//
1960 //===----------------------------------------------------------------------===//
1962 //===----------------------------------------------------------------------===//
1963 // Miscellaneous Instructions.
1966 /// CONSTPOOL_ENTRY - This instruction represents a floating constant pool in
1967 /// the function. The first operand is the ID# for this instruction, the second
1968 /// is the index into the MachineConstantPool that this is, the third is the
1969 /// size in bytes of this constant pool entry.
1970 let hasSideEffects = 0, isNotDuplicable = 1 in
1971 def CONSTPOOL_ENTRY :
1972 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1973 i32imm:$size), NoItinerary, []>;
1975 /// A jumptable consisting of direct 32-bit addresses of the destination basic
1976 /// blocks (either absolute, or relative to the start of the jump-table in PIC
1977 /// mode). Used mostly in ARM and Thumb-1 modes.
1978 def JUMPTABLE_ADDRS :
1979 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1980 i32imm:$size), NoItinerary, []>;
1982 /// A jumptable consisting of 32-bit jump instructions. Used for Thumb-2 tables
1983 /// that cannot be optimised to use TBB or TBH.
1984 def JUMPTABLE_INSTS :
1985 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1986 i32imm:$size), NoItinerary, []>;
1988 /// A jumptable consisting of 8-bit unsigned integers representing offsets from
1989 /// a TBB instruction.
1991 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1992 i32imm:$size), NoItinerary, []>;
1994 /// A jumptable consisting of 16-bit unsigned integers representing offsets from
1995 /// a TBH instruction.
1997 PseudoInst<(outs), (ins cpinst_operand:$instid, cpinst_operand:$cpidx,
1998 i32imm:$size), NoItinerary, []>;
2001 // FIXME: Marking these as hasSideEffects is necessary to prevent machine DCE
2002 // from removing one half of the matched pairs. That breaks PEI, which assumes
2003 // these will always be in pairs, and asserts if it finds otherwise. Better way?
2004 let Defs = [SP], Uses = [SP], hasSideEffects = 1 in {
2005 def ADJCALLSTACKUP :
2006 PseudoInst<(outs), (ins i32imm:$amt1, i32imm:$amt2, pred:$p), NoItinerary,
2007 [(ARMcallseq_end timm:$amt1, timm:$amt2)]>;
2009 def ADJCALLSTACKDOWN :
2010 PseudoInst<(outs), (ins i32imm:$amt, i32imm:$amt2, pred:$p), NoItinerary,
2011 [(ARMcallseq_start timm:$amt, timm:$amt2)]>;
2014 def HINT : AI<(outs), (ins imm0_239:$imm), MiscFrm, NoItinerary,
2015 "hint", "\t$imm", [(int_arm_hint imm0_239:$imm)]>,
2016 Requires<[IsARM, HasV6]> {
2018 let Inst{27-8} = 0b00110010000011110000;
2019 let Inst{7-0} = imm;
2020 let DecoderMethod = "DecodeHINTInstruction";
2023 def : InstAlias<"nop$p", (HINT 0, pred:$p)>, Requires<[IsARM, HasV6K]>;
2024 def : InstAlias<"yield$p", (HINT 1, pred:$p)>, Requires<[IsARM, HasV6K]>;
2025 def : InstAlias<"wfe$p", (HINT 2, pred:$p)>, Requires<[IsARM, HasV6K]>;
2026 def : InstAlias<"wfi$p", (HINT 3, pred:$p)>, Requires<[IsARM, HasV6K]>;
2027 def : InstAlias<"sev$p", (HINT 4, pred:$p)>, Requires<[IsARM, HasV6K]>;
2028 def : InstAlias<"sevl$p", (HINT 5, pred:$p)>, Requires<[IsARM, HasV8]>;
2029 def : InstAlias<"esb$p", (HINT 16, pred:$p)>, Requires<[IsARM, HasRAS]>;
2030 def : InstAlias<"csdb$p", (HINT 20, pred:$p)>, Requires<[IsARM, HasV6K]>;
2032 def SEL : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), DPFrm, NoItinerary, "sel",
2034 [(set GPR:$Rd, (int_arm_sel GPR:$Rn, GPR:$Rm))]>,
2035 Requires<[IsARM, HasV6]> {
2040 let Inst{15-12} = Rd;
2041 let Inst{19-16} = Rn;
2042 let Inst{27-20} = 0b01101000;
2043 let Inst{7-4} = 0b1011;
2044 let Inst{11-8} = 0b1111;
2045 let Unpredictable{11-8} = 0b1111;
2048 // The 16-bit operand $val can be used by a debugger to store more information
2049 // about the breakpoint.
2050 def BKPT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
2051 "bkpt", "\t$val", []>, Requires<[IsARM]> {
2053 let Inst{3-0} = val{3-0};
2054 let Inst{19-8} = val{15-4};
2055 let Inst{27-20} = 0b00010010;
2056 let Inst{31-28} = 0xe; // AL
2057 let Inst{7-4} = 0b0111;
2059 // default immediate for breakpoint mnemonic
2060 def : InstAlias<"bkpt", (BKPT 0), 0>, Requires<[IsARM]>;
2062 def HLT : AInoP<(outs), (ins imm0_65535:$val), MiscFrm, NoItinerary,
2063 "hlt", "\t$val", []>, Requires<[IsARM, HasV8]> {
2065 let Inst{3-0} = val{3-0};
2066 let Inst{19-8} = val{15-4};
2067 let Inst{27-20} = 0b00010000;
2068 let Inst{31-28} = 0xe; // AL
2069 let Inst{7-4} = 0b0111;
2072 // Change Processor State
2073 // FIXME: We should use InstAlias to handle the optional operands.
2074 class CPS<dag iops, string asm_ops>
2075 : AXI<(outs), iops, MiscFrm, NoItinerary, !strconcat("cps", asm_ops),
2076 []>, Requires<[IsARM]> {
2082 let Inst{31-28} = 0b1111;
2083 let Inst{27-20} = 0b00010000;
2084 let Inst{19-18} = imod;
2085 let Inst{17} = M; // Enabled if mode is set;
2086 let Inst{16-9} = 0b00000000;
2087 let Inst{8-6} = iflags;
2089 let Inst{4-0} = mode;
2092 let DecoderMethod = "DecodeCPSInstruction" in {
2094 def CPS3p : CPS<(ins imod_op:$imod, iflags_op:$iflags, imm0_31:$mode),
2095 "$imod\t$iflags, $mode">;
2096 let mode = 0, M = 0 in
2097 def CPS2p : CPS<(ins imod_op:$imod, iflags_op:$iflags), "$imod\t$iflags">;
2099 let imod = 0, iflags = 0, M = 1 in
2100 def CPS1p : CPS<(ins imm0_31:$mode), "\t$mode">;
2103 // Preload signals the memory system of possible future data/instruction access.
2104 multiclass APreLoad<bits<1> read, bits<1> data, string opc> {
2106 def i12 : AXIM<(outs), (ins addrmode_imm12:$addr), AddrMode_i12, MiscFrm,
2107 IIC_Preload, !strconcat(opc, "\t$addr"),
2108 [(ARMPreload addrmode_imm12:$addr, (i32 read), (i32 data))]>,
2109 Sched<[WritePreLd]> {
2112 let Inst{31-26} = 0b111101;
2113 let Inst{25} = 0; // 0 for immediate form
2114 let Inst{24} = data;
2115 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2116 let Inst{22} = read;
2117 let Inst{21-20} = 0b01;
2118 let Inst{19-16} = addr{16-13}; // Rn
2119 let Inst{15-12} = 0b1111;
2120 let Inst{11-0} = addr{11-0}; // imm12
2123 def rs : AXI<(outs), (ins ldst_so_reg:$shift), MiscFrm, IIC_Preload,
2124 !strconcat(opc, "\t$shift"),
2125 [(ARMPreload ldst_so_reg:$shift, (i32 read), (i32 data))]>,
2126 Sched<[WritePreLd]> {
2128 let Inst{31-26} = 0b111101;
2129 let Inst{25} = 1; // 1 for register form
2130 let Inst{24} = data;
2131 let Inst{23} = shift{12}; // U (add = ('U' == 1))
2132 let Inst{22} = read;
2133 let Inst{21-20} = 0b01;
2134 let Inst{19-16} = shift{16-13}; // Rn
2135 let Inst{15-12} = 0b1111;
2136 let Inst{11-0} = shift{11-0};
2141 defm PLD : APreLoad<1, 1, "pld">, Requires<[IsARM]>;
2142 defm PLDW : APreLoad<0, 1, "pldw">, Requires<[IsARM,HasV7,HasMP]>;
2143 defm PLI : APreLoad<1, 0, "pli">, Requires<[IsARM,HasV7]>;
2145 def SETEND : AXI<(outs), (ins setend_op:$end), MiscFrm, NoItinerary,
2146 "setend\t$end", []>, Requires<[IsARM]>, Deprecated<HasV8Ops> {
2148 let Inst{31-10} = 0b1111000100000001000000;
2153 def DBG : AI<(outs), (ins imm0_15:$opt), MiscFrm, NoItinerary, "dbg", "\t$opt",
2154 [(int_arm_dbg imm0_15:$opt)]>, Requires<[IsARM, HasV7]> {
2156 let Inst{27-4} = 0b001100100000111100001111;
2157 let Inst{3-0} = opt;
2160 // A8.8.247 UDF - Undefined (Encoding A1)
2161 def UDF : AInoP<(outs), (ins imm0_65535:$imm16), MiscFrm, NoItinerary,
2162 "udf", "\t$imm16", [(int_arm_undefined imm0_65535:$imm16)]> {
2164 let Inst{31-28} = 0b1110; // AL
2165 let Inst{27-25} = 0b011;
2166 let Inst{24-20} = 0b11111;
2167 let Inst{19-8} = imm16{15-4};
2168 let Inst{7-4} = 0b1111;
2169 let Inst{3-0} = imm16{3-0};
2173 * A5.4 Permanently UNDEFINED instructions.
2175 * For most targets use UDF #65006, for which the OS will generate SIGTRAP.
2176 * Other UDF encodings generate SIGILL.
2178 * NaCl's OS instead chooses an ARM UDF encoding that's also a UDF in Thumb.
2180 * 1110 0111 1111 iiii iiii iiii 1111 iiii
2182 * 1101 1110 iiii iiii
2183 * It uses the following encoding:
2184 * 1110 0111 1111 1110 1101 1110 1111 0000
2185 * - In ARM: UDF #60896;
2186 * - In Thumb: UDF #254 followed by a branch-to-self.
2188 let isBarrier = 1, isTerminator = 1 in
2189 def TRAPNaCl : AXI<(outs), (ins), MiscFrm, NoItinerary,
2191 Requires<[IsARM,UseNaClTrap]> {
2192 let Inst = 0xe7fedef0;
2194 let isBarrier = 1, isTerminator = 1 in
2195 def TRAP : AXI<(outs), (ins), MiscFrm, NoItinerary,
2197 Requires<[IsARM,DontUseNaClTrap]> {
2198 let Inst = 0xe7ffdefe;
2201 def : Pat<(debugtrap), (BKPT 0)>, Requires<[IsARM, HasV5T]>;
2202 def : Pat<(debugtrap), (UDF 254)>, Requires<[IsARM, NoV5T]>;
2204 // Address computation and loads and stores in PIC mode.
2205 let isNotDuplicable = 1 in {
2206 def PICADD : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$a, pclabel:$cp, pred:$p),
2208 [(set GPR:$dst, (ARMpic_add GPR:$a, imm:$cp))]>,
2209 Sched<[WriteALU, ReadALU]>;
2211 let AddedComplexity = 10 in {
2212 def PICLDR : ARMPseudoInst<(outs GPR:$dst), (ins addrmodepc:$addr, pred:$p),
2214 [(set GPR:$dst, (load addrmodepc:$addr))]>;
2216 def PICLDRH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2218 [(set GPR:$Rt, (zextloadi16 addrmodepc:$addr))]>;
2220 def PICLDRB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2222 [(set GPR:$Rt, (zextloadi8 addrmodepc:$addr))]>;
2224 def PICLDRSH : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2226 [(set GPR:$Rt, (sextloadi16 addrmodepc:$addr))]>;
2228 def PICLDRSB : ARMPseudoInst<(outs GPR:$Rt), (ins addrmodepc:$addr, pred:$p),
2230 [(set GPR:$Rt, (sextloadi8 addrmodepc:$addr))]>;
2232 let AddedComplexity = 10 in {
2233 def PICSTR : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2234 4, IIC_iStore_r, [(store GPR:$src, addrmodepc:$addr)]>;
2236 def PICSTRH : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2237 4, IIC_iStore_bh_r, [(truncstorei16 GPR:$src,
2238 addrmodepc:$addr)]>;
2240 def PICSTRB : ARMPseudoInst<(outs), (ins GPR:$src, addrmodepc:$addr, pred:$p),
2241 4, IIC_iStore_bh_r, [(truncstorei8 GPR:$src, addrmodepc:$addr)]>;
2243 } // isNotDuplicable = 1
2246 // LEApcrel - Load a pc-relative address into a register without offending the
2248 let hasSideEffects = 0, isReMaterializable = 1 in
2249 // The 'adr' mnemonic encodes differently if the label is before or after
2250 // the instruction. The {24-21} opcode bits are set by the fixup, as we don't
2251 // know until then which form of the instruction will be used.
2252 def ADR : AI1<{0,?,?,0}, (outs GPR:$Rd), (ins adrlabel:$label),
2253 MiscFrm, IIC_iALUi, "adr", "\t$Rd, $label", []>,
2254 Sched<[WriteALU, ReadALU]> {
2257 let Inst{27-25} = 0b001;
2259 let Inst{23-22} = label{13-12};
2262 let Inst{19-16} = 0b1111;
2263 let Inst{15-12} = Rd;
2264 let Inst{11-0} = label{11-0};
2267 let hasSideEffects = 1 in {
2268 def LEApcrel : ARMPseudoInst<(outs GPR:$Rd), (ins i32imm:$label, pred:$p),
2269 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
2271 def LEApcrelJT : ARMPseudoInst<(outs GPR:$Rd),
2272 (ins i32imm:$label, pred:$p),
2273 4, IIC_iALUi, []>, Sched<[WriteALU, ReadALU]>;
2276 //===----------------------------------------------------------------------===//
2277 // Control Flow Instructions.
2280 let isReturn = 1, isTerminator = 1, isBarrier = 1 in {
2282 def BX_RET : AI<(outs), (ins), BrMiscFrm, IIC_Br,
2283 "bx", "\tlr", [(ARMretflag)]>,
2284 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2285 let Inst{27-0} = 0b0001001011111111111100011110;
2289 def MOVPCLR : AI<(outs), (ins), BrMiscFrm, IIC_Br,
2290 "mov", "\tpc, lr", [(ARMretflag)]>,
2291 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]> {
2292 let Inst{27-0} = 0b0001101000001111000000001110;
2295 // Exception return: N.b. doesn't set CPSR as far as we're concerned (it sets
2296 // the user-space one).
2297 def SUBS_PC_LR : ARMPseudoInst<(outs), (ins i32imm:$offset, pred:$p),
2299 [(ARMintretflag imm:$offset)]>;
2302 // Indirect branches
2303 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in {
2305 def BX : AXI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br, "bx\t$dst",
2306 [(brind GPR:$dst)]>,
2307 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2309 let Inst{31-4} = 0b1110000100101111111111110001;
2310 let Inst{3-0} = dst;
2313 def BX_pred : AI<(outs), (ins GPR:$dst), BrMiscFrm, IIC_Br,
2314 "bx", "\t$dst", [/* pattern left blank */]>,
2315 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]> {
2317 let Inst{27-4} = 0b000100101111111111110001;
2318 let Inst{3-0} = dst;
2322 // SP is marked as a use to prevent stack-pointer assignments that appear
2323 // immediately before calls from potentially appearing dead.
2325 // FIXME: Do we really need a non-predicated version? If so, it should
2326 // at least be a pseudo instruction expanding to the predicated version
2327 // at MC lowering time.
2328 Defs = [LR], Uses = [SP] in {
2329 def BL : ABXI<0b1011, (outs), (ins arm_bl_target:$func),
2330 IIC_Br, "bl\t$func",
2331 [(ARMcall tglobaladdr:$func)]>,
2332 Requires<[IsARM]>, Sched<[WriteBrL]> {
2333 let Inst{31-28} = 0b1110;
2335 let Inst{23-0} = func;
2336 let DecoderMethod = "DecodeBranchImmInstruction";
2339 def BL_pred : ABI<0b1011, (outs), (ins arm_bl_target:$func),
2340 IIC_Br, "bl", "\t$func",
2341 [(ARMcall_pred tglobaladdr:$func)]>,
2342 Requires<[IsARM]>, Sched<[WriteBrL]> {
2344 let Inst{23-0} = func;
2345 let DecoderMethod = "DecodeBranchImmInstruction";
2349 def BLX : AXI<(outs), (ins GPR:$func), BrMiscFrm,
2350 IIC_Br, "blx\t$func",
2351 [(ARMcall GPR:$func)]>,
2352 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2354 let Inst{31-4} = 0b1110000100101111111111110011;
2355 let Inst{3-0} = func;
2358 def BLX_pred : AI<(outs), (ins GPR:$func), BrMiscFrm,
2359 IIC_Br, "blx", "\t$func",
2360 [(ARMcall_pred GPR:$func)]>,
2361 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2363 let Inst{27-4} = 0b000100101111111111110011;
2364 let Inst{3-0} = func;
2368 // Note: Restrict $func to the tGPR regclass to prevent it being in LR.
2369 def BX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
2370 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
2371 Requires<[IsARM, HasV4T]>, Sched<[WriteBr]>;
2374 def BMOVPCRX_CALL : ARMPseudoInst<(outs), (ins tGPR:$func),
2375 8, IIC_Br, [(ARMcall_nolink tGPR:$func)]>,
2376 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
2378 // mov lr, pc; b if callee is marked noreturn to avoid confusing the
2379 // return stack predictor.
2380 def BMOVPCB_CALL : ARMPseudoInst<(outs), (ins arm_bl_target:$func),
2381 8, IIC_Br, [(ARMcall_nolink tglobaladdr:$func)]>,
2382 Requires<[IsARM]>, Sched<[WriteBr]>;
2384 // push lr before the call
2385 def BL_PUSHLR : ARMPseudoInst<(outs), (ins GPRlr:$ra, arm_bl_target:$func),
2388 Requires<[IsARM]>, Sched<[WriteBr]>;
2391 let isBranch = 1, isTerminator = 1 in {
2392 // FIXME: should be able to write a pattern for ARMBrcond, but can't use
2393 // a two-value operand where a dag node expects two operands. :(
2394 def Bcc : ABI<0b1010, (outs), (ins arm_br_target:$target),
2395 IIC_Br, "b", "\t$target",
2396 [/*(ARMbrcond bb:$target, imm:$cc, CCR:$ccr)*/]>,
2399 let Inst{23-0} = target;
2400 let DecoderMethod = "DecodeBranchImmInstruction";
2403 let isBarrier = 1 in {
2404 // B is "predicable" since it's just a Bcc with an 'always' condition.
2405 let isPredicable = 1 in
2406 // FIXME: We shouldn't need this pseudo at all. Just using Bcc directly
2407 // should be sufficient.
2408 // FIXME: Is B really a Barrier? That doesn't seem right.
2409 def B : ARMPseudoExpand<(outs), (ins arm_br_target:$target), 4, IIC_Br,
2410 [(br bb:$target)], (Bcc arm_br_target:$target,
2411 (ops 14, zero_reg))>,
2414 let Size = 4, isNotDuplicable = 1, isIndirectBranch = 1 in {
2415 def BR_JTr : ARMPseudoInst<(outs),
2416 (ins GPR:$target, i32imm:$jt),
2418 [(ARMbrjt GPR:$target, tjumptable:$jt)]>,
2420 def BR_JTm_i12 : ARMPseudoInst<(outs),
2421 (ins addrmode_imm12:$target, i32imm:$jt),
2423 [(ARMbrjt (i32 (load addrmode_imm12:$target)),
2424 tjumptable:$jt)]>, Sched<[WriteBrTbl]>;
2425 def BR_JTm_rs : ARMPseudoInst<(outs),
2426 (ins ldst_so_reg:$target, i32imm:$jt),
2428 [(ARMbrjt (i32 (load ldst_so_reg:$target)),
2429 tjumptable:$jt)]>, Sched<[WriteBrTbl]>;
2430 def BR_JTadd : ARMPseudoInst<(outs),
2431 (ins GPR:$target, GPR:$idx, i32imm:$jt),
2433 [(ARMbrjt (add GPR:$target, GPR:$idx), tjumptable:$jt)]>,
2434 Sched<[WriteBrTbl]>;
2435 } // isNotDuplicable = 1, isIndirectBranch = 1
2441 def BLXi : AXI<(outs), (ins arm_blx_target:$target), BrMiscFrm, NoItinerary,
2442 "blx\t$target", []>,
2443 Requires<[IsARM, HasV5T]>, Sched<[WriteBrL]> {
2444 let Inst{31-25} = 0b1111101;
2446 let Inst{23-0} = target{24-1};
2447 let Inst{24} = target{0};
2451 // Branch and Exchange Jazelle
2452 def BXJ : ABI<0b0001, (outs), (ins GPR:$func), NoItinerary, "bxj", "\t$func",
2453 [/* pattern left blank */]>, Sched<[WriteBr]> {
2455 let Inst{23-20} = 0b0010;
2456 let Inst{19-8} = 0xfff;
2457 let Inst{7-4} = 0b0010;
2458 let Inst{3-0} = func;
2464 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in {
2465 def TCRETURNdi : PseudoInst<(outs), (ins i32imm:$dst), IIC_Br, []>,
2468 def TCRETURNri : PseudoInst<(outs), (ins tcGPR:$dst), IIC_Br, []>,
2471 def TAILJMPd : ARMPseudoExpand<(outs), (ins arm_br_target:$dst),
2473 (Bcc arm_br_target:$dst, (ops 14, zero_reg))>,
2474 Requires<[IsARM]>, Sched<[WriteBr]>;
2476 def TAILJMPr : ARMPseudoExpand<(outs), (ins tcGPR:$dst),
2478 (BX GPR:$dst)>, Sched<[WriteBr]>,
2479 Requires<[IsARM, HasV4T]>;
2482 // Secure Monitor Call is a system instruction.
2483 def SMC : ABI<0b0001, (outs), (ins imm0_15:$opt), NoItinerary, "smc", "\t$opt",
2484 []>, Requires<[IsARM, HasTrustZone]> {
2486 let Inst{23-4} = 0b01100000000000000111;
2487 let Inst{3-0} = opt;
2489 def : MnemonicAlias<"smi", "smc">;
2491 // Supervisor Call (Software Interrupt)
2492 let isCall = 1, Uses = [SP] in {
2493 def SVC : ABI<0b1111, (outs), (ins imm24b:$svc), IIC_Br, "svc", "\t$svc", []>,
2496 let Inst{23-0} = svc;
2500 // Store Return State
2501 class SRSI<bit wb, string asm>
2502 : XI<(outs), (ins imm0_31:$mode), AddrModeNone, 4, IndexModeNone, BrFrm,
2503 NoItinerary, asm, "", []> {
2505 let Inst{31-28} = 0b1111;
2506 let Inst{27-25} = 0b100;
2510 let Inst{19-16} = 0b1101; // SP
2511 let Inst{15-5} = 0b00000101000;
2512 let Inst{4-0} = mode;
2515 def SRSDA : SRSI<0, "srsda\tsp, $mode"> {
2516 let Inst{24-23} = 0;
2518 def SRSDA_UPD : SRSI<1, "srsda\tsp!, $mode"> {
2519 let Inst{24-23} = 0;
2521 def SRSDB : SRSI<0, "srsdb\tsp, $mode"> {
2522 let Inst{24-23} = 0b10;
2524 def SRSDB_UPD : SRSI<1, "srsdb\tsp!, $mode"> {
2525 let Inst{24-23} = 0b10;
2527 def SRSIA : SRSI<0, "srsia\tsp, $mode"> {
2528 let Inst{24-23} = 0b01;
2530 def SRSIA_UPD : SRSI<1, "srsia\tsp!, $mode"> {
2531 let Inst{24-23} = 0b01;
2533 def SRSIB : SRSI<0, "srsib\tsp, $mode"> {
2534 let Inst{24-23} = 0b11;
2536 def SRSIB_UPD : SRSI<1, "srsib\tsp!, $mode"> {
2537 let Inst{24-23} = 0b11;
2540 def : ARMInstAlias<"srsda $mode", (SRSDA imm0_31:$mode)>;
2541 def : ARMInstAlias<"srsda $mode!", (SRSDA_UPD imm0_31:$mode)>;
2543 def : ARMInstAlias<"srsdb $mode", (SRSDB imm0_31:$mode)>;
2544 def : ARMInstAlias<"srsdb $mode!", (SRSDB_UPD imm0_31:$mode)>;
2546 def : ARMInstAlias<"srsia $mode", (SRSIA imm0_31:$mode)>;
2547 def : ARMInstAlias<"srsia $mode!", (SRSIA_UPD imm0_31:$mode)>;
2549 def : ARMInstAlias<"srsib $mode", (SRSIB imm0_31:$mode)>;
2550 def : ARMInstAlias<"srsib $mode!", (SRSIB_UPD imm0_31:$mode)>;
2552 // Return From Exception
2553 class RFEI<bit wb, string asm>
2554 : XI<(outs), (ins GPR:$Rn), AddrModeNone, 4, IndexModeNone, BrFrm,
2555 NoItinerary, asm, "", []> {
2557 let Inst{31-28} = 0b1111;
2558 let Inst{27-25} = 0b100;
2562 let Inst{19-16} = Rn;
2563 let Inst{15-0} = 0xa00;
2566 def RFEDA : RFEI<0, "rfeda\t$Rn"> {
2567 let Inst{24-23} = 0;
2569 def RFEDA_UPD : RFEI<1, "rfeda\t$Rn!"> {
2570 let Inst{24-23} = 0;
2572 def RFEDB : RFEI<0, "rfedb\t$Rn"> {
2573 let Inst{24-23} = 0b10;
2575 def RFEDB_UPD : RFEI<1, "rfedb\t$Rn!"> {
2576 let Inst{24-23} = 0b10;
2578 def RFEIA : RFEI<0, "rfeia\t$Rn"> {
2579 let Inst{24-23} = 0b01;
2581 def RFEIA_UPD : RFEI<1, "rfeia\t$Rn!"> {
2582 let Inst{24-23} = 0b01;
2584 def RFEIB : RFEI<0, "rfeib\t$Rn"> {
2585 let Inst{24-23} = 0b11;
2587 def RFEIB_UPD : RFEI<1, "rfeib\t$Rn!"> {
2588 let Inst{24-23} = 0b11;
2591 // Hypervisor Call is a system instruction
2593 def HVC : AInoP< (outs), (ins imm0_65535:$imm), BrFrm, NoItinerary,
2594 "hvc", "\t$imm", []>,
2595 Requires<[IsARM, HasVirtualization]> {
2598 // Even though HVC isn't predicable, it's encoding includes a condition field.
2599 // The instruction is undefined if the condition field is 0xf otherwise it is
2600 // unpredictable if it isn't condition AL (0xe).
2601 let Inst{31-28} = 0b1110;
2602 let Unpredictable{31-28} = 0b1111;
2603 let Inst{27-24} = 0b0001;
2604 let Inst{23-20} = 0b0100;
2605 let Inst{19-8} = imm{15-4};
2606 let Inst{7-4} = 0b0111;
2607 let Inst{3-0} = imm{3-0};
2611 // Return from exception in Hypervisor mode.
2612 let isReturn = 1, isBarrier = 1, isTerminator = 1, Defs = [PC] in
2613 def ERET : ABI<0b0001, (outs), (ins), NoItinerary, "eret", "", []>,
2614 Requires<[IsARM, HasVirtualization]> {
2615 let Inst{23-0} = 0b011000000000000001101110;
2618 //===----------------------------------------------------------------------===//
2619 // Load / Store Instructions.
2625 defm LDR : AI_ldr1<0, "ldr", IIC_iLoad_r, IIC_iLoad_si, load>;
2626 defm LDRB : AI_ldr1nopc<1, "ldrb", IIC_iLoad_bh_r, IIC_iLoad_bh_si,
2628 defm STR : AI_str1<0, "str", IIC_iStore_r, IIC_iStore_si, store>;
2629 defm STRB : AI_str1nopc<1, "strb", IIC_iStore_bh_r, IIC_iStore_bh_si,
2632 // Special LDR for loads from non-pc-relative constpools.
2633 let canFoldAsLoad = 1, mayLoad = 1, hasSideEffects = 0,
2634 isReMaterializable = 1, isCodeGenOnly = 1 in
2635 def LDRcp : AI2ldst<0b010, 1, 0, (outs GPR:$Rt), (ins addrmode_imm12:$addr),
2636 AddrMode_i12, LdFrm, IIC_iLoad_r, "ldr", "\t$Rt, $addr",
2640 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2641 let Inst{19-16} = 0b1111;
2642 let Inst{15-12} = Rt;
2643 let Inst{11-0} = addr{11-0}; // imm12
2646 // Loads with zero extension
2647 def LDRH : AI3ld<0b1011, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2648 IIC_iLoad_bh_r, "ldrh", "\t$Rt, $addr",
2649 [(set GPR:$Rt, (zextloadi16 addrmode3:$addr))]>;
2651 // Loads with sign extension
2652 def LDRSH : AI3ld<0b1111, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2653 IIC_iLoad_bh_r, "ldrsh", "\t$Rt, $addr",
2654 [(set GPR:$Rt, (sextloadi16 addrmode3:$addr))]>;
2656 def LDRSB : AI3ld<0b1101, 1, (outs GPR:$Rt), (ins addrmode3:$addr), LdMiscFrm,
2657 IIC_iLoad_bh_r, "ldrsb", "\t$Rt, $addr",
2658 [(set GPR:$Rt, (sextloadi8 addrmode3:$addr))]>;
2660 let mayLoad = 1, hasSideEffects = 0, hasExtraDefRegAllocReq = 1 in {
2662 def LDRD : AI3ld<0b1101, 0, (outs GPR:$Rt, GPR:$Rt2), (ins addrmode3:$addr),
2663 LdMiscFrm, IIC_iLoad_d_r, "ldrd", "\t$Rt, $Rt2, $addr", []>,
2664 Requires<[IsARM, HasV5TE]>;
2667 def LDA : AIldracq<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2668 NoItinerary, "lda", "\t$Rt, $addr", []>;
2669 def LDAB : AIldracq<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2670 NoItinerary, "ldab", "\t$Rt, $addr", []>;
2671 def LDAH : AIldracq<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
2672 NoItinerary, "ldah", "\t$Rt, $addr", []>;
2675 multiclass AI2_ldridx<bit isByte, string opc,
2676 InstrItinClass iii, InstrItinClass iir> {
2677 def _PRE_IMM : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2678 (ins addrmode_imm12_pre:$addr), IndexModePre, LdFrm, iii,
2679 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2682 let Inst{23} = addr{12};
2683 let Inst{19-16} = addr{16-13};
2684 let Inst{11-0} = addr{11-0};
2685 let DecoderMethod = "DecodeLDRPreImm";
2688 def _PRE_REG : AI2ldstidx<1, isByte, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2689 (ins ldst_so_reg:$addr), IndexModePre, LdFrm, iir,
2690 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2693 let Inst{23} = addr{12};
2694 let Inst{19-16} = addr{16-13};
2695 let Inst{11-0} = addr{11-0};
2697 let DecoderMethod = "DecodeLDRPreReg";
2700 def _POST_REG : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2701 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2702 IndexModePost, LdFrm, iir,
2703 opc, "\t$Rt, $addr, $offset",
2704 "$addr.base = $Rn_wb", []> {
2710 let Inst{23} = offset{12};
2711 let Inst{19-16} = addr;
2712 let Inst{11-0} = offset{11-0};
2715 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2718 def _POST_IMM : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2719 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2720 IndexModePost, LdFrm, iii,
2721 opc, "\t$Rt, $addr, $offset",
2722 "$addr.base = $Rn_wb", []> {
2728 let Inst{23} = offset{12};
2729 let Inst{19-16} = addr;
2730 let Inst{11-0} = offset{11-0};
2732 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2737 let mayLoad = 1, hasSideEffects = 0 in {
2738 // FIXME: for LDR_PRE_REG etc. the itineray should be either IIC_iLoad_ru or
2739 // IIC_iLoad_siu depending on whether it the offset register is shifted.
2740 defm LDR : AI2_ldridx<0, "ldr", IIC_iLoad_iu, IIC_iLoad_ru>;
2741 defm LDRB : AI2_ldridx<1, "ldrb", IIC_iLoad_bh_iu, IIC_iLoad_bh_ru>;
2744 multiclass AI3_ldridx<bits<4> op, string opc, InstrItinClass itin> {
2745 def _PRE : AI3ldstidx<op, 1, 1, (outs GPR:$Rt, GPR:$Rn_wb),
2746 (ins addrmode3_pre:$addr), IndexModePre,
2748 opc, "\t$Rt, $addr!", "$addr.base = $Rn_wb", []> {
2750 let Inst{23} = addr{8}; // U bit
2751 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2752 let Inst{19-16} = addr{12-9}; // Rn
2753 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2754 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2755 let DecoderMethod = "DecodeAddrMode3Instruction";
2757 def _POST : AI3ldstidx<op, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2758 (ins addr_offset_none:$addr, am3offset:$offset),
2759 IndexModePost, LdMiscFrm, itin,
2760 opc, "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb",
2764 let Inst{23} = offset{8}; // U bit
2765 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2766 let Inst{19-16} = addr;
2767 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2768 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2769 let DecoderMethod = "DecodeAddrMode3Instruction";
2773 let mayLoad = 1, hasSideEffects = 0 in {
2774 defm LDRH : AI3_ldridx<0b1011, "ldrh", IIC_iLoad_bh_ru>;
2775 defm LDRSH : AI3_ldridx<0b1111, "ldrsh", IIC_iLoad_bh_ru>;
2776 defm LDRSB : AI3_ldridx<0b1101, "ldrsb", IIC_iLoad_bh_ru>;
2777 let hasExtraDefRegAllocReq = 1 in {
2778 def LDRD_PRE : AI3ldstidx<0b1101, 0, 1, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2779 (ins addrmode3_pre:$addr), IndexModePre,
2780 LdMiscFrm, IIC_iLoad_d_ru,
2781 "ldrd", "\t$Rt, $Rt2, $addr!",
2782 "$addr.base = $Rn_wb", []> {
2784 let Inst{23} = addr{8}; // U bit
2785 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
2786 let Inst{19-16} = addr{12-9}; // Rn
2787 let Inst{11-8} = addr{7-4}; // imm7_4/zero
2788 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
2789 let DecoderMethod = "DecodeAddrMode3Instruction";
2791 def LDRD_POST: AI3ldstidx<0b1101, 0, 0, (outs GPR:$Rt, GPR:$Rt2, GPR:$Rn_wb),
2792 (ins addr_offset_none:$addr, am3offset:$offset),
2793 IndexModePost, LdMiscFrm, IIC_iLoad_d_ru,
2794 "ldrd", "\t$Rt, $Rt2, $addr, $offset",
2795 "$addr.base = $Rn_wb", []> {
2798 let Inst{23} = offset{8}; // U bit
2799 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
2800 let Inst{19-16} = addr;
2801 let Inst{11-8} = offset{7-4}; // imm7_4/zero
2802 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
2803 let DecoderMethod = "DecodeAddrMode3Instruction";
2805 } // hasExtraDefRegAllocReq = 1
2806 } // mayLoad = 1, hasSideEffects = 0
2808 // LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT.
2809 let mayLoad = 1, hasSideEffects = 0 in {
2810 def LDRT_POST_REG : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2811 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2812 IndexModePost, LdFrm, IIC_iLoad_ru,
2813 "ldrt", "\t$Rt, $addr, $offset",
2814 "$addr.base = $Rn_wb", []> {
2820 let Inst{23} = offset{12};
2821 let Inst{21} = 1; // overwrite
2822 let Inst{19-16} = addr;
2823 let Inst{11-5} = offset{11-5};
2825 let Inst{3-0} = offset{3-0};
2826 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2830 : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2831 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2832 IndexModePost, LdFrm, IIC_iLoad_ru,
2833 "ldrt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2839 let Inst{23} = offset{12};
2840 let Inst{21} = 1; // overwrite
2841 let Inst{19-16} = addr;
2842 let Inst{11-0} = offset{11-0};
2843 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2846 def LDRBT_POST_REG : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2847 (ins addr_offset_none:$addr, am2offset_reg:$offset),
2848 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2849 "ldrbt", "\t$Rt, $addr, $offset",
2850 "$addr.base = $Rn_wb", []> {
2856 let Inst{23} = offset{12};
2857 let Inst{21} = 1; // overwrite
2858 let Inst{19-16} = addr;
2859 let Inst{11-5} = offset{11-5};
2861 let Inst{3-0} = offset{3-0};
2862 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2866 : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$Rn_wb),
2867 (ins addr_offset_none:$addr, am2offset_imm:$offset),
2868 IndexModePost, LdFrm, IIC_iLoad_bh_ru,
2869 "ldrbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
2875 let Inst{23} = offset{12};
2876 let Inst{21} = 1; // overwrite
2877 let Inst{19-16} = addr;
2878 let Inst{11-0} = offset{11-0};
2879 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2882 multiclass AI3ldrT<bits<4> op, string opc> {
2883 def i : AI3ldstidxT<op, 1, (outs GPR:$Rt, GPR:$base_wb),
2884 (ins addr_offset_none:$addr, postidx_imm8:$offset),
2885 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2886 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
2888 let Inst{23} = offset{8};
2890 let Inst{11-8} = offset{7-4};
2891 let Inst{3-0} = offset{3-0};
2893 def r : AI3ldstidxT<op, 1, (outs GPRnopc:$Rt, GPRnopc:$base_wb),
2894 (ins addr_offset_none:$addr, postidx_reg:$Rm),
2895 IndexModePost, LdMiscFrm, IIC_iLoad_bh_ru, opc,
2896 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
2898 let Inst{23} = Rm{4};
2901 let Unpredictable{11-8} = 0b1111;
2902 let Inst{3-0} = Rm{3-0};
2903 let DecoderMethod = "DecodeLDR";
2907 defm LDRSBT : AI3ldrT<0b1101, "ldrsbt">;
2908 defm LDRHT : AI3ldrT<0b1011, "ldrht">;
2909 defm LDRSHT : AI3ldrT<0b1111, "ldrsht">;
2913 : ARMAsmPseudo<"ldrt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q),
2917 : ARMAsmPseudo<"ldrbt${q} $Rt, $addr", (ins addr_offset_none:$addr, pred:$q),
2920 // Pseudo instruction ldr Rt, =immediate
2922 : ARMAsmPseudo<"ldr${q} $Rt, $immediate",
2923 (ins const_pool_asm_imm:$immediate, pred:$q),
2928 // Stores with truncate
2929 def STRH : AI3str<0b1011, (outs), (ins GPR:$Rt, addrmode3:$addr), StMiscFrm,
2930 IIC_iStore_bh_r, "strh", "\t$Rt, $addr",
2931 [(truncstorei16 GPR:$Rt, addrmode3:$addr)]>;
2934 let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
2935 def STRD : AI3str<0b1111, (outs), (ins GPR:$Rt, GPR:$Rt2, addrmode3:$addr),
2936 StMiscFrm, IIC_iStore_d_r, "strd", "\t$Rt, $Rt2, $addr", []>,
2937 Requires<[IsARM, HasV5TE]> {
2943 multiclass AI2_stridx<bit isByte, string opc,
2944 InstrItinClass iii, InstrItinClass iir> {
2945 def _PRE_IMM : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2946 (ins GPR:$Rt, addrmode_imm12_pre:$addr), IndexModePre,
2948 opc, "\t$Rt, $addr!",
2949 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2952 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2953 let Inst{19-16} = addr{16-13}; // Rn
2954 let Inst{11-0} = addr{11-0}; // imm12
2955 let DecoderMethod = "DecodeSTRPreImm";
2958 def _PRE_REG : AI2ldstidx<0, isByte, 1, (outs GPR:$Rn_wb),
2959 (ins GPR:$Rt, ldst_so_reg:$addr),
2960 IndexModePre, StFrm, iir,
2961 opc, "\t$Rt, $addr!",
2962 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2965 let Inst{23} = addr{12}; // U (add = ('U' == 1))
2966 let Inst{19-16} = addr{16-13}; // Rn
2967 let Inst{11-0} = addr{11-0};
2968 let Inst{4} = 0; // Inst{4} = 0
2969 let DecoderMethod = "DecodeSTRPreReg";
2971 def _POST_REG : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2972 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
2973 IndexModePost, StFrm, iir,
2974 opc, "\t$Rt, $addr, $offset",
2975 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2981 let Inst{23} = offset{12};
2982 let Inst{19-16} = addr;
2983 let Inst{11-0} = offset{11-0};
2986 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
2989 def _POST_IMM : AI2ldstidx<0, isByte, 0, (outs GPR:$Rn_wb),
2990 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
2991 IndexModePost, StFrm, iii,
2992 opc, "\t$Rt, $addr, $offset",
2993 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
2999 let Inst{23} = offset{12};
3000 let Inst{19-16} = addr;
3001 let Inst{11-0} = offset{11-0};
3003 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3007 let mayStore = 1, hasSideEffects = 0 in {
3008 // FIXME: for STR_PRE_REG etc. the itineray should be either IIC_iStore_ru or
3009 // IIC_iStore_siu depending on whether it the offset register is shifted.
3010 defm STR : AI2_stridx<0, "str", IIC_iStore_iu, IIC_iStore_ru>;
3011 defm STRB : AI2_stridx<1, "strb", IIC_iStore_bh_iu, IIC_iStore_bh_ru>;
3014 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
3015 am2offset_reg:$offset),
3016 (STR_POST_REG GPR:$Rt, addr_offset_none:$addr,
3017 am2offset_reg:$offset)>;
3018 def : ARMPat<(post_store GPR:$Rt, addr_offset_none:$addr,
3019 am2offset_imm:$offset),
3020 (STR_POST_IMM GPR:$Rt, addr_offset_none:$addr,
3021 am2offset_imm:$offset)>;
3022 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
3023 am2offset_reg:$offset),
3024 (STRB_POST_REG GPR:$Rt, addr_offset_none:$addr,
3025 am2offset_reg:$offset)>;
3026 def : ARMPat<(post_truncsti8 GPR:$Rt, addr_offset_none:$addr,
3027 am2offset_imm:$offset),
3028 (STRB_POST_IMM GPR:$Rt, addr_offset_none:$addr,
3029 am2offset_imm:$offset)>;
3031 // Pseudo-instructions for pattern matching the pre-indexed stores. We can't
3032 // put the patterns on the instruction definitions directly as ISel wants
3033 // the address base and offset to be separate operands, not a single
3034 // complex operand like we represent the instructions themselves. The
3035 // pseudos map between the two.
3036 let usesCustomInserter = 1,
3037 Constraints = "$Rn = $Rn_wb,@earlyclobber $Rn_wb" in {
3038 def STRi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3039 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
3042 (pre_store GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
3043 def STRr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3044 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
3047 (pre_store GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
3048 def STRBi_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3049 (ins GPR:$Rt, GPR:$Rn, am2offset_imm:$offset, pred:$p),
3052 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_imm:$offset))]>;
3053 def STRBr_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3054 (ins GPR:$Rt, GPR:$Rn, am2offset_reg:$offset, pred:$p),
3057 (pre_truncsti8 GPR:$Rt, GPR:$Rn, am2offset_reg:$offset))]>;
3058 def STRH_preidx: ARMPseudoInst<(outs GPR:$Rn_wb),
3059 (ins GPR:$Rt, GPR:$Rn, am3offset:$offset, pred:$p),
3062 (pre_truncsti16 GPR:$Rt, GPR:$Rn, am3offset:$offset))]>;
3067 def STRH_PRE : AI3ldstidx<0b1011, 0, 1, (outs GPR:$Rn_wb),
3068 (ins GPR:$Rt, addrmode3_pre:$addr), IndexModePre,
3069 StMiscFrm, IIC_iStore_bh_ru,
3070 "strh", "\t$Rt, $addr!",
3071 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb", []> {
3073 let Inst{23} = addr{8}; // U bit
3074 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
3075 let Inst{19-16} = addr{12-9}; // Rn
3076 let Inst{11-8} = addr{7-4}; // imm7_4/zero
3077 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
3078 let DecoderMethod = "DecodeAddrMode3Instruction";
3081 def STRH_POST : AI3ldstidx<0b1011, 0, 0, (outs GPR:$Rn_wb),
3082 (ins GPR:$Rt, addr_offset_none:$addr, am3offset:$offset),
3083 IndexModePost, StMiscFrm, IIC_iStore_bh_ru,
3084 "strh", "\t$Rt, $addr, $offset",
3085 "$addr.base = $Rn_wb,@earlyclobber $Rn_wb",
3086 [(set GPR:$Rn_wb, (post_truncsti16 GPR:$Rt,
3087 addr_offset_none:$addr,
3088 am3offset:$offset))]> {
3091 let Inst{23} = offset{8}; // U bit
3092 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
3093 let Inst{19-16} = addr;
3094 let Inst{11-8} = offset{7-4}; // imm7_4/zero
3095 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
3096 let DecoderMethod = "DecodeAddrMode3Instruction";
3099 let mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1 in {
3100 def STRD_PRE : AI3ldstidx<0b1111, 0, 1, (outs GPR:$Rn_wb),
3101 (ins GPR:$Rt, GPR:$Rt2, addrmode3_pre:$addr),
3102 IndexModePre, StMiscFrm, IIC_iStore_d_ru,
3103 "strd", "\t$Rt, $Rt2, $addr!",
3104 "$addr.base = $Rn_wb", []> {
3106 let Inst{23} = addr{8}; // U bit
3107 let Inst{22} = addr{13}; // 1 == imm8, 0 == Rm
3108 let Inst{19-16} = addr{12-9}; // Rn
3109 let Inst{11-8} = addr{7-4}; // imm7_4/zero
3110 let Inst{3-0} = addr{3-0}; // imm3_0/Rm
3111 let DecoderMethod = "DecodeAddrMode3Instruction";
3114 def STRD_POST: AI3ldstidx<0b1111, 0, 0, (outs GPR:$Rn_wb),
3115 (ins GPR:$Rt, GPR:$Rt2, addr_offset_none:$addr,
3117 IndexModePost, StMiscFrm, IIC_iStore_d_ru,
3118 "strd", "\t$Rt, $Rt2, $addr, $offset",
3119 "$addr.base = $Rn_wb", []> {
3122 let Inst{23} = offset{8}; // U bit
3123 let Inst{22} = offset{9}; // 1 == imm8, 0 == Rm
3124 let Inst{19-16} = addr;
3125 let Inst{11-8} = offset{7-4}; // imm7_4/zero
3126 let Inst{3-0} = offset{3-0}; // imm3_0/Rm
3127 let DecoderMethod = "DecodeAddrMode3Instruction";
3129 } // mayStore = 1, hasSideEffects = 0, hasExtraSrcRegAllocReq = 1
3131 // STRT, STRBT, and STRHT
3133 def STRBT_POST_REG : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
3134 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
3135 IndexModePost, StFrm, IIC_iStore_bh_ru,
3136 "strbt", "\t$Rt, $addr, $offset",
3137 "$addr.base = $Rn_wb", []> {
3143 let Inst{23} = offset{12};
3144 let Inst{21} = 1; // overwrite
3145 let Inst{19-16} = addr;
3146 let Inst{11-5} = offset{11-5};
3148 let Inst{3-0} = offset{3-0};
3149 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3153 : AI2ldstidx<0, 1, 0, (outs GPR:$Rn_wb),
3154 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
3155 IndexModePost, StFrm, IIC_iStore_bh_ru,
3156 "strbt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
3162 let Inst{23} = offset{12};
3163 let Inst{21} = 1; // overwrite
3164 let Inst{19-16} = addr;
3165 let Inst{11-0} = offset{11-0};
3166 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3170 : ARMAsmPseudo<"strbt${q} $Rt, $addr",
3171 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>;
3173 let mayStore = 1, hasSideEffects = 0 in {
3174 def STRT_POST_REG : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
3175 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_reg:$offset),
3176 IndexModePost, StFrm, IIC_iStore_ru,
3177 "strt", "\t$Rt, $addr, $offset",
3178 "$addr.base = $Rn_wb", []> {
3184 let Inst{23} = offset{12};
3185 let Inst{21} = 1; // overwrite
3186 let Inst{19-16} = addr;
3187 let Inst{11-5} = offset{11-5};
3189 let Inst{3-0} = offset{3-0};
3190 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3194 : AI2ldstidx<0, 0, 0, (outs GPR:$Rn_wb),
3195 (ins GPR:$Rt, addr_offset_none:$addr, am2offset_imm:$offset),
3196 IndexModePost, StFrm, IIC_iStore_ru,
3197 "strt", "\t$Rt, $addr, $offset", "$addr.base = $Rn_wb", []> {
3203 let Inst{23} = offset{12};
3204 let Inst{21} = 1; // overwrite
3205 let Inst{19-16} = addr;
3206 let Inst{11-0} = offset{11-0};
3207 let DecoderMethod = "DecodeAddrMode2IdxInstruction";
3212 : ARMAsmPseudo<"strt${q} $Rt, $addr",
3213 (ins GPR:$Rt, addr_offset_none:$addr, pred:$q)>;
3215 multiclass AI3strT<bits<4> op, string opc> {
3216 def i : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
3217 (ins GPR:$Rt, addr_offset_none:$addr, postidx_imm8:$offset),
3218 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
3219 "\t$Rt, $addr, $offset", "$addr.base = $base_wb", []> {
3221 let Inst{23} = offset{8};
3223 let Inst{11-8} = offset{7-4};
3224 let Inst{3-0} = offset{3-0};
3226 def r : AI3ldstidxT<op, 0, (outs GPR:$base_wb),
3227 (ins GPR:$Rt, addr_offset_none:$addr, postidx_reg:$Rm),
3228 IndexModePost, StMiscFrm, IIC_iStore_bh_ru, opc,
3229 "\t$Rt, $addr, $Rm", "$addr.base = $base_wb", []> {
3231 let Inst{23} = Rm{4};
3234 let Inst{3-0} = Rm{3-0};
3239 defm STRHT : AI3strT<0b1011, "strht">;
3241 def STL : AIstrrel<0b00, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3242 NoItinerary, "stl", "\t$Rt, $addr", []>;
3243 def STLB : AIstrrel<0b10, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3244 NoItinerary, "stlb", "\t$Rt, $addr", []>;
3245 def STLH : AIstrrel<0b11, (outs), (ins GPR:$Rt, addr_offset_none:$addr),
3246 NoItinerary, "stlh", "\t$Rt, $addr", []>;
3248 //===----------------------------------------------------------------------===//
3249 // Load / store multiple Instructions.
3252 multiclass arm_ldst_mult<string asm, string sfx, bit L_bit, bit P_bit, Format f,
3253 InstrItinClass itin, InstrItinClass itin_upd> {
3254 // IA is the default, so no need for an explicit suffix on the
3255 // mnemonic here. Without it is the canonical spelling.
3257 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3258 IndexModeNone, f, itin,
3259 !strconcat(asm, "${p}\t$Rn, $regs", sfx), "", []> {
3260 let Inst{24-23} = 0b01; // Increment After
3261 let Inst{22} = P_bit;
3262 let Inst{21} = 0; // No writeback
3263 let Inst{20} = L_bit;
3266 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3267 IndexModeUpd, f, itin_upd,
3268 !strconcat(asm, "${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3269 let Inst{24-23} = 0b01; // Increment After
3270 let Inst{22} = P_bit;
3271 let Inst{21} = 1; // Writeback
3272 let Inst{20} = L_bit;
3274 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3277 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3278 IndexModeNone, f, itin,
3279 !strconcat(asm, "da${p}\t$Rn, $regs", sfx), "", []> {
3280 let Inst{24-23} = 0b00; // Decrement After
3281 let Inst{22} = P_bit;
3282 let Inst{21} = 0; // No writeback
3283 let Inst{20} = L_bit;
3286 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3287 IndexModeUpd, f, itin_upd,
3288 !strconcat(asm, "da${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3289 let Inst{24-23} = 0b00; // Decrement After
3290 let Inst{22} = P_bit;
3291 let Inst{21} = 1; // Writeback
3292 let Inst{20} = L_bit;
3294 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3297 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3298 IndexModeNone, f, itin,
3299 !strconcat(asm, "db${p}\t$Rn, $regs", sfx), "", []> {
3300 let Inst{24-23} = 0b10; // Decrement Before
3301 let Inst{22} = P_bit;
3302 let Inst{21} = 0; // No writeback
3303 let Inst{20} = L_bit;
3306 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3307 IndexModeUpd, f, itin_upd,
3308 !strconcat(asm, "db${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3309 let Inst{24-23} = 0b10; // Decrement Before
3310 let Inst{22} = P_bit;
3311 let Inst{21} = 1; // Writeback
3312 let Inst{20} = L_bit;
3314 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3317 AXI4<(outs), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3318 IndexModeNone, f, itin,
3319 !strconcat(asm, "ib${p}\t$Rn, $regs", sfx), "", []> {
3320 let Inst{24-23} = 0b11; // Increment Before
3321 let Inst{22} = P_bit;
3322 let Inst{21} = 0; // No writeback
3323 let Inst{20} = L_bit;
3326 AXI4<(outs GPR:$wb), (ins GPR:$Rn, pred:$p, reglist:$regs, variable_ops),
3327 IndexModeUpd, f, itin_upd,
3328 !strconcat(asm, "ib${p}\t$Rn!, $regs", sfx), "$Rn = $wb", []> {
3329 let Inst{24-23} = 0b11; // Increment Before
3330 let Inst{22} = P_bit;
3331 let Inst{21} = 1; // Writeback
3332 let Inst{20} = L_bit;
3334 let DecoderMethod = "DecodeMemMultipleWritebackInstruction";
3338 let hasSideEffects = 0 in {
3340 let mayLoad = 1, hasExtraDefRegAllocReq = 1, variadicOpsAreDefs = 1 in
3341 defm LDM : arm_ldst_mult<"ldm", "", 1, 0, LdStMulFrm, IIC_iLoad_m,
3342 IIC_iLoad_mu>, ComplexDeprecationPredicate<"ARMLoad">;
3344 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
3345 defm STM : arm_ldst_mult<"stm", "", 0, 0, LdStMulFrm, IIC_iStore_m,
3347 ComplexDeprecationPredicate<"ARMStore">;
3351 // FIXME: remove when we have a way to marking a MI with these properties.
3352 // FIXME: Should pc be an implicit operand like PICADD, etc?
3353 let isReturn = 1, isTerminator = 1, isBarrier = 1, mayLoad = 1,
3354 hasExtraDefRegAllocReq = 1, isCodeGenOnly = 1 in
3355 def LDMIA_RET : ARMPseudoExpand<(outs GPR:$wb), (ins GPR:$Rn, pred:$p,
3356 reglist:$regs, variable_ops),
3357 4, IIC_iLoad_mBr, [],
3358 (LDMIA_UPD GPR:$wb, GPR:$Rn, pred:$p, reglist:$regs)>,
3359 RegConstraint<"$Rn = $wb">;
3361 let mayLoad = 1, hasExtraDefRegAllocReq = 1 in
3362 defm sysLDM : arm_ldst_mult<"ldm", " ^", 1, 1, LdStMulFrm, IIC_iLoad_m,
3365 let mayStore = 1, hasExtraSrcRegAllocReq = 1 in
3366 defm sysSTM : arm_ldst_mult<"stm", " ^", 0, 1, LdStMulFrm, IIC_iStore_m,
3371 //===----------------------------------------------------------------------===//
3372 // Move Instructions.
3375 let hasSideEffects = 0, isMoveReg = 1 in
3376 def MOVr : AsI1<0b1101, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMOVr,
3377 "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> {
3381 let Inst{19-16} = 0b0000;
3382 let Inst{11-4} = 0b00000000;
3385 let Inst{15-12} = Rd;
3388 // A version for the smaller set of tail call registers.
3389 let hasSideEffects = 0 in
3390 def MOVr_TC : AsI1<0b1101, (outs tcGPR:$Rd), (ins tcGPR:$Rm), DPFrm,
3391 IIC_iMOVr, "mov", "\t$Rd, $Rm", []>, UnaryDP, Sched<[WriteALU]> {
3395 let Inst{11-4} = 0b00000000;
3398 let Inst{15-12} = Rd;
3401 def MOVsr : AsI1<0b1101, (outs GPRnopc:$Rd), (ins shift_so_reg_reg:$src),
3402 DPSoRegRegFrm, IIC_iMOVsr,
3403 "mov", "\t$Rd, $src",
3404 [(set GPRnopc:$Rd, shift_so_reg_reg:$src)]>, UnaryDP,
3408 let Inst{15-12} = Rd;
3409 let Inst{19-16} = 0b0000;
3410 let Inst{11-8} = src{11-8};
3412 let Inst{6-5} = src{6-5};
3414 let Inst{3-0} = src{3-0};
3418 def MOVsi : AsI1<0b1101, (outs GPR:$Rd), (ins shift_so_reg_imm:$src),
3419 DPSoRegImmFrm, IIC_iMOVsr,
3420 "mov", "\t$Rd, $src", [(set GPR:$Rd, shift_so_reg_imm:$src)]>,
3421 UnaryDP, Sched<[WriteALU]> {
3424 let Inst{15-12} = Rd;
3425 let Inst{19-16} = 0b0000;
3426 let Inst{11-5} = src{11-5};
3428 let Inst{3-0} = src{3-0};
3432 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3433 def MOVi : AsI1<0b1101, (outs GPR:$Rd), (ins mod_imm:$imm), DPFrm, IIC_iMOVi,
3434 "mov", "\t$Rd, $imm", [(set GPR:$Rd, mod_imm:$imm)]>, UnaryDP,
3439 let Inst{15-12} = Rd;
3440 let Inst{19-16} = 0b0000;
3441 let Inst{11-0} = imm;
3444 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
3445 def MOVi16 : AI1<0b1000, (outs GPR:$Rd), (ins imm0_65535_expr:$imm),
3447 "movw", "\t$Rd, $imm",
3448 [(set GPR:$Rd, imm0_65535:$imm)]>,
3449 Requires<[IsARM, HasV6T2]>, UnaryDP, Sched<[WriteALU]> {
3452 let Inst{15-12} = Rd;
3453 let Inst{11-0} = imm{11-0};
3454 let Inst{19-16} = imm{15-12};
3457 let DecoderMethod = "DecodeArmMOVTWInstruction";
3460 def : InstAlias<"mov${p} $Rd, $imm",
3461 (MOVi16 GPR:$Rd, imm0_65535_expr:$imm, pred:$p), 0>,
3462 Requires<[IsARM, HasV6T2]>;
3464 def MOVi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
3465 (ins i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
3468 let Constraints = "$src = $Rd" in {
3469 def MOVTi16 : AI1<0b1010, (outs GPRnopc:$Rd),
3470 (ins GPR:$src, imm0_65535_expr:$imm),
3472 "movt", "\t$Rd, $imm",
3474 (or (and GPR:$src, 0xffff),
3475 lo16AllZero:$imm))]>, UnaryDP,
3476 Requires<[IsARM, HasV6T2]>, Sched<[WriteALU]> {
3479 let Inst{15-12} = Rd;
3480 let Inst{11-0} = imm{11-0};
3481 let Inst{19-16} = imm{15-12};
3484 let DecoderMethod = "DecodeArmMOVTWInstruction";
3487 def MOVTi16_ga_pcrel : PseudoInst<(outs GPR:$Rd),
3488 (ins GPR:$src, i32imm:$addr, pclabel:$id), IIC_iMOVi, []>,
3493 def : ARMPat<(or GPR:$src, 0xffff0000), (MOVTi16 GPR:$src, 0xffff)>,
3494 Requires<[IsARM, HasV6T2]>;
3496 let Uses = [CPSR] in
3497 def RRX: PseudoInst<(outs GPR:$Rd), (ins GPR:$Rm), IIC_iMOVsi,
3498 [(set GPR:$Rd, (ARMrrx GPR:$Rm))]>, UnaryDP,
3499 Requires<[IsARM]>, Sched<[WriteALU]>;
3501 // These aren't really mov instructions, but we have to define them this way
3502 // due to flag operands.
3504 let Defs = [CPSR] in {
3505 def MOVsrl_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3506 [(set GPR:$dst, (ARMsrl_flag GPR:$src))]>, UnaryDP,
3507 Sched<[WriteALU]>, Requires<[IsARM]>;
3508 def MOVsra_flag : PseudoInst<(outs GPR:$dst), (ins GPR:$src), IIC_iMOVsi,
3509 [(set GPR:$dst, (ARMsra_flag GPR:$src))]>, UnaryDP,
3510 Sched<[WriteALU]>, Requires<[IsARM]>;
3513 //===----------------------------------------------------------------------===//
3514 // Extend Instructions.
3519 def SXTB : AI_ext_rrot<0b01101010,
3520 "sxtb", UnOpFrag<(sext_inreg node:$Src, i8)>>;
3521 def SXTH : AI_ext_rrot<0b01101011,
3522 "sxth", UnOpFrag<(sext_inreg node:$Src, i16)>>;
3524 def SXTAB : AI_exta_rrot<0b01101010,
3525 "sxtab", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS, i8))>>;
3526 def SXTAH : AI_exta_rrot<0b01101011,
3527 "sxtah", BinOpFrag<(add node:$LHS, (sext_inreg node:$RHS,i16))>>;
3529 def : ARMV6Pat<(add rGPR:$Rn, (sext_inreg (srl rGPR:$Rm, rot_imm:$rot), i8)),
3530 (SXTAB rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
3531 def : ARMV6Pat<(add rGPR:$Rn, (sext_inreg (srl rGPR:$Rm, imm8_or_16:$rot),
3533 (SXTAH rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
3535 def SXTB16 : AI_ext_rrot_np<0b01101000, "sxtb16">;
3536 def : ARMV6Pat<(int_arm_sxtb16 GPR:$Src),
3537 (SXTB16 GPR:$Src, 0)>;
3538 def : ARMV6Pat<(int_arm_sxtb16 (rotr GPR:$Src, rot_imm:$rot)),
3539 (SXTB16 GPR:$Src, rot_imm:$rot)>;
3541 def SXTAB16 : AI_exta_rrot_np<0b01101000, "sxtab16">;
3542 def : ARMV6Pat<(int_arm_sxtab16 GPR:$LHS, GPR:$RHS),
3543 (SXTAB16 GPR:$LHS, GPR:$RHS, 0)>;
3544 def : ARMV6Pat<(int_arm_sxtab16 GPR:$LHS, (rotr GPR:$RHS, rot_imm:$rot)),
3545 (SXTAB16 GPR:$LHS, GPR:$RHS, rot_imm:$rot)>;
3549 let AddedComplexity = 16 in {
3550 def UXTB : AI_ext_rrot<0b01101110,
3551 "uxtb" , UnOpFrag<(and node:$Src, 0x000000FF)>>;
3552 def UXTH : AI_ext_rrot<0b01101111,
3553 "uxth" , UnOpFrag<(and node:$Src, 0x0000FFFF)>>;
3554 def UXTB16 : AI_ext_rrot<0b01101100,
3555 "uxtb16", UnOpFrag<(and node:$Src, 0x00FF00FF)>>;
3557 // FIXME: This pattern incorrectly assumes the shl operator is a rotate.
3558 // The transformation should probably be done as a combiner action
3559 // instead so we can include a check for masking back in the upper
3560 // eight bits of the source into the lower eight bits of the result.
3561 //def : ARMV6Pat<(and (shl GPR:$Src, (i32 8)), 0xFF00FF),
3562 // (UXTB16r_rot GPR:$Src, 3)>;
3563 def : ARMV6Pat<(and (srl GPR:$Src, (i32 8)), 0xFF00FF),
3564 (UXTB16 GPR:$Src, 1)>;
3565 def : ARMV6Pat<(int_arm_uxtb16 GPR:$Src),
3566 (UXTB16 GPR:$Src, 0)>;
3567 def : ARMV6Pat<(int_arm_uxtb16 (rotr GPR:$Src, rot_imm:$rot)),
3568 (UXTB16 GPR:$Src, rot_imm:$rot)>;
3570 def UXTAB : AI_exta_rrot<0b01101110, "uxtab",
3571 BinOpFrag<(add node:$LHS, (and node:$RHS, 0x00FF))>>;
3572 def UXTAH : AI_exta_rrot<0b01101111, "uxtah",
3573 BinOpFrag<(add node:$LHS, (and node:$RHS, 0xFFFF))>>;
3575 def : ARMV6Pat<(add rGPR:$Rn, (and (srl rGPR:$Rm, rot_imm:$rot), 0xFF)),
3576 (UXTAB rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
3577 def : ARMV6Pat<(add rGPR:$Rn, (and (srl rGPR:$Rm, imm8_or_16:$rot), 0xFFFF)),
3578 (UXTAH rGPR:$Rn, rGPR:$Rm, rot_imm:$rot)>;
3581 // This isn't safe in general, the add is two 16-bit units, not a 32-bit add.
3582 def UXTAB16 : AI_exta_rrot_np<0b01101100, "uxtab16">;
3583 def : ARMV6Pat<(int_arm_uxtab16 GPR:$LHS, GPR:$RHS),
3584 (UXTAB16 GPR:$LHS, GPR:$RHS, 0)>;
3585 def : ARMV6Pat<(int_arm_uxtab16 GPR:$LHS, (rotr GPR:$RHS, rot_imm:$rot)),
3586 (UXTAB16 GPR:$LHS, GPR:$RHS, rot_imm:$rot)>;
3589 def SBFX : I<(outs GPRnopc:$Rd),
3590 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3591 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3592 "sbfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3593 Requires<[IsARM, HasV6T2]> {
3598 let Inst{27-21} = 0b0111101;
3599 let Inst{6-4} = 0b101;
3600 let Inst{20-16} = width;
3601 let Inst{15-12} = Rd;
3602 let Inst{11-7} = lsb;
3606 def UBFX : I<(outs GPRnopc:$Rd),
3607 (ins GPRnopc:$Rn, imm0_31:$lsb, imm1_32:$width),
3608 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3609 "ubfx", "\t$Rd, $Rn, $lsb, $width", "", []>,
3610 Requires<[IsARM, HasV6T2]> {
3615 let Inst{27-21} = 0b0111111;
3616 let Inst{6-4} = 0b101;
3617 let Inst{20-16} = width;
3618 let Inst{15-12} = Rd;
3619 let Inst{11-7} = lsb;
3623 //===----------------------------------------------------------------------===//
3624 // Arithmetic Instructions.
3628 defm ADD : AsI1_bin_irs<0b0100, "add",
3629 IIC_iALUi, IIC_iALUr, IIC_iALUsr, add, 1>;
3630 defm SUB : AsI1_bin_irs<0b0010, "sub",
3631 IIC_iALUi, IIC_iALUr, IIC_iALUsr, sub>;
3633 // ADD and SUB with 's' bit set.
3635 // Currently, ADDS/SUBS are pseudo opcodes that exist only in the
3636 // selection DAG. They are "lowered" to real ADD/SUB opcodes by
3637 // AdjustInstrPostInstrSelection where we determine whether or not to
3638 // set the "s" bit based on CPSR liveness.
3640 // FIXME: Eliminate ADDS/SUBS pseudo opcodes after adding tablegen
3641 // support for an optional CPSR definition that corresponds to the DAG
3642 // node's second value. We can then eliminate the implicit def of CPSR.
3644 defm ADDS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr, ARMaddc, 1>;
3645 defm SUBS : AsI1_bin_s_irs<IIC_iALUi, IIC_iALUr, IIC_iALUsr, ARMsubc>;
3647 def : ARMPat<(ARMsubs GPR:$Rn, mod_imm:$imm), (SUBSri $Rn, mod_imm:$imm)>;
3648 def : ARMPat<(ARMsubs GPR:$Rn, GPR:$Rm), (SUBSrr $Rn, $Rm)>;
3649 def : ARMPat<(ARMsubs GPR:$Rn, so_reg_imm:$shift),
3650 (SUBSrsi $Rn, so_reg_imm:$shift)>;
3651 def : ARMPat<(ARMsubs GPR:$Rn, so_reg_reg:$shift),
3652 (SUBSrsr $Rn, so_reg_reg:$shift)>;
3656 defm ADC : AI1_adde_sube_irs<0b0101, "adc", ARMadde, 1>;
3657 defm SBC : AI1_adde_sube_irs<0b0110, "sbc", ARMsube>;
3659 defm RSB : AsI1_rbin_irs<0b0011, "rsb",
3660 IIC_iALUi, IIC_iALUr, IIC_iALUsr,
3663 // FIXME: Eliminate them if we can write def : Pat patterns which defines
3664 // CPSR and the implicit def of CPSR is not needed.
3665 defm RSBS : AsI1_rbin_s_is<IIC_iALUi, IIC_iALUr, IIC_iALUsr, ARMsubc>;
3667 defm RSC : AI1_rsc_irs<0b0111, "rsc", ARMsube>;
3669 // (sub X, imm) gets canonicalized to (add X, -imm). Match this form.
3670 // The assume-no-carry-in form uses the negation of the input since add/sub
3671 // assume opposite meanings of the carry flag (i.e., carry == !borrow).
3672 // See the definition of AddWithCarry() in the ARM ARM A2.2.1 for the gory
3674 def : ARMPat<(add GPR:$src, mod_imm_neg:$imm),
3675 (SUBri GPR:$src, mod_imm_neg:$imm)>;
3676 def : ARMPat<(ARMaddc GPR:$src, mod_imm_neg:$imm),
3677 (SUBSri GPR:$src, mod_imm_neg:$imm)>;
3679 def : ARMPat<(add GPR:$src, imm0_65535_neg:$imm),
3680 (SUBrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>,
3681 Requires<[IsARM, HasV6T2]>;
3682 def : ARMPat<(ARMaddc GPR:$src, imm0_65535_neg:$imm),
3683 (SUBSrr GPR:$src, (MOVi16 (imm_neg_XFORM imm:$imm)))>,
3684 Requires<[IsARM, HasV6T2]>;
3686 // The with-carry-in form matches bitwise not instead of the negation.
3687 // Effectively, the inverse interpretation of the carry flag already accounts
3688 // for part of the negation.
3689 def : ARMPat<(ARMadde GPR:$src, mod_imm_not:$imm, CPSR),
3690 (SBCri GPR:$src, mod_imm_not:$imm)>;
3691 def : ARMPat<(ARMadde GPR:$src, imm0_65535_neg:$imm, CPSR),
3692 (SBCrr GPR:$src, (MOVi16 (imm_not_XFORM imm:$imm)))>,
3693 Requires<[IsARM, HasV6T2]>;
3695 // Note: These are implemented in C++ code, because they have to generate
3696 // ADD/SUBrs instructions, which use a complex pattern that a xform function
3698 // (mul X, 2^n+1) -> (add (X << n), X)
3699 // (mul X, 2^n-1) -> (rsb X, (X << n))
3701 // ARM Arithmetic Instruction
3702 // GPR:$dst = GPR:$a op GPR:$b
3703 class AAI<bits<8> op27_20, bits<8> op11_4, string opc,
3704 list<dag> pattern = [],
3705 dag iops = (ins GPRnopc:$Rn, GPRnopc:$Rm),
3706 string asm = "\t$Rd, $Rn, $Rm">
3707 : AI<(outs GPRnopc:$Rd), iops, DPFrm, IIC_iALUr, opc, asm, pattern>,
3708 Sched<[WriteALU, ReadALU, ReadALU]> {
3712 let Inst{27-20} = op27_20;
3713 let Inst{11-4} = op11_4;
3714 let Inst{19-16} = Rn;
3715 let Inst{15-12} = Rd;
3718 let Unpredictable{11-8} = 0b1111;
3721 // Wrappers around the AAI class
3722 class AAIRevOpr<bits<8> op27_20, bits<8> op11_4, string opc,
3723 list<dag> pattern = []>
3724 : AAI<op27_20, op11_4, opc,
3726 (ins GPRnopc:$Rm, GPRnopc:$Rn),
3729 class AAIIntrinsic<bits<8> op27_20, bits<8> op11_4, string opc,
3730 Intrinsic intrinsic>
3731 : AAI<op27_20, op11_4, opc,
3732 [(set GPRnopc:$Rd, (intrinsic GPRnopc:$Rn, GPRnopc:$Rm))]>;
3734 // Saturating add/subtract
3735 let hasSideEffects = 1 in {
3736 def QADD8 : AAIIntrinsic<0b01100010, 0b11111001, "qadd8", int_arm_qadd8>;
3737 def QADD16 : AAIIntrinsic<0b01100010, 0b11110001, "qadd16", int_arm_qadd16>;
3738 def QSUB16 : AAIIntrinsic<0b01100010, 0b11110111, "qsub16", int_arm_qsub16>;
3739 def QSUB8 : AAIIntrinsic<0b01100010, 0b11111111, "qsub8", int_arm_qsub8>;
3741 def QDADD : AAIRevOpr<0b00010100, 0b00000101, "qdadd",
3742 [(set GPRnopc:$Rd, (int_arm_qadd (int_arm_qadd GPRnopc:$Rm,
3745 def QDSUB : AAIRevOpr<0b00010110, 0b00000101, "qdsub",
3746 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm,
3747 (int_arm_qadd GPRnopc:$Rn, GPRnopc:$Rn)))]>;
3748 def QSUB : AAIRevOpr<0b00010010, 0b00000101, "qsub",
3749 [(set GPRnopc:$Rd, (int_arm_qsub GPRnopc:$Rm, GPRnopc:$Rn))]>;
3750 let DecoderMethod = "DecodeQADDInstruction" in
3751 def QADD : AAIRevOpr<0b00010000, 0b00000101, "qadd",
3752 [(set GPRnopc:$Rd, (int_arm_qadd GPRnopc:$Rm, GPRnopc:$Rn))]>;
3755 def UQADD16 : AAIIntrinsic<0b01100110, 0b11110001, "uqadd16", int_arm_uqadd16>;
3756 def UQADD8 : AAIIntrinsic<0b01100110, 0b11111001, "uqadd8", int_arm_uqadd8>;
3757 def UQSUB16 : AAIIntrinsic<0b01100110, 0b11110111, "uqsub16", int_arm_uqsub16>;
3758 def UQSUB8 : AAIIntrinsic<0b01100110, 0b11111111, "uqsub8", int_arm_uqsub8>;
3759 def QASX : AAIIntrinsic<0b01100010, 0b11110011, "qasx", int_arm_qasx>;
3760 def QSAX : AAIIntrinsic<0b01100010, 0b11110101, "qsax", int_arm_qsax>;
3761 def UQASX : AAIIntrinsic<0b01100110, 0b11110011, "uqasx", int_arm_uqasx>;
3762 def UQSAX : AAIIntrinsic<0b01100110, 0b11110101, "uqsax", int_arm_uqsax>;
3764 // Signed/Unsigned add/subtract
3766 def SASX : AAIIntrinsic<0b01100001, 0b11110011, "sasx", int_arm_sasx>;
3767 def SADD16 : AAIIntrinsic<0b01100001, 0b11110001, "sadd16", int_arm_sadd16>;
3768 def SADD8 : AAIIntrinsic<0b01100001, 0b11111001, "sadd8", int_arm_sadd8>;
3769 def SSAX : AAIIntrinsic<0b01100001, 0b11110101, "ssax", int_arm_ssax>;
3770 def SSUB16 : AAIIntrinsic<0b01100001, 0b11110111, "ssub16", int_arm_ssub16>;
3771 def SSUB8 : AAIIntrinsic<0b01100001, 0b11111111, "ssub8", int_arm_ssub8>;
3772 def UASX : AAIIntrinsic<0b01100101, 0b11110011, "uasx", int_arm_uasx>;
3773 def UADD16 : AAIIntrinsic<0b01100101, 0b11110001, "uadd16", int_arm_uadd16>;
3774 def UADD8 : AAIIntrinsic<0b01100101, 0b11111001, "uadd8", int_arm_uadd8>;
3775 def USAX : AAIIntrinsic<0b01100101, 0b11110101, "usax", int_arm_usax>;
3776 def USUB16 : AAIIntrinsic<0b01100101, 0b11110111, "usub16", int_arm_usub16>;
3777 def USUB8 : AAIIntrinsic<0b01100101, 0b11111111, "usub8", int_arm_usub8>;
3779 // Signed/Unsigned halving add/subtract
3781 def SHASX : AAIIntrinsic<0b01100011, 0b11110011, "shasx", int_arm_shasx>;
3782 def SHADD16 : AAIIntrinsic<0b01100011, 0b11110001, "shadd16", int_arm_shadd16>;
3783 def SHADD8 : AAIIntrinsic<0b01100011, 0b11111001, "shadd8", int_arm_shadd8>;
3784 def SHSAX : AAIIntrinsic<0b01100011, 0b11110101, "shsax", int_arm_shsax>;
3785 def SHSUB16 : AAIIntrinsic<0b01100011, 0b11110111, "shsub16", int_arm_shsub16>;
3786 def SHSUB8 : AAIIntrinsic<0b01100011, 0b11111111, "shsub8", int_arm_shsub8>;
3787 def UHASX : AAIIntrinsic<0b01100111, 0b11110011, "uhasx", int_arm_uhasx>;
3788 def UHADD16 : AAIIntrinsic<0b01100111, 0b11110001, "uhadd16", int_arm_uhadd16>;
3789 def UHADD8 : AAIIntrinsic<0b01100111, 0b11111001, "uhadd8", int_arm_uhadd8>;
3790 def UHSAX : AAIIntrinsic<0b01100111, 0b11110101, "uhsax", int_arm_uhsax>;
3791 def UHSUB16 : AAIIntrinsic<0b01100111, 0b11110111, "uhsub16", int_arm_uhsub16>;
3792 def UHSUB8 : AAIIntrinsic<0b01100111, 0b11111111, "uhsub8", int_arm_uhsub8>;
3794 // Unsigned Sum of Absolute Differences [and Accumulate].
3796 def USAD8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
3797 MulFrm /* for convenience */, NoItinerary, "usad8",
3799 [(set GPR:$Rd, (int_arm_usad8 GPR:$Rn, GPR:$Rm))]>,
3800 Requires<[IsARM, HasV6]>, Sched<[WriteALU, ReadALU, ReadALU]> {
3804 let Inst{27-20} = 0b01111000;
3805 let Inst{15-12} = 0b1111;
3806 let Inst{7-4} = 0b0001;
3807 let Inst{19-16} = Rd;
3808 let Inst{11-8} = Rm;
3811 def USADA8 : AI<(outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
3812 MulFrm /* for convenience */, NoItinerary, "usada8",
3813 "\t$Rd, $Rn, $Rm, $Ra",
3814 [(set GPR:$Rd, (int_arm_usada8 GPR:$Rn, GPR:$Rm, GPR:$Ra))]>,
3815 Requires<[IsARM, HasV6]>, Sched<[WriteALU, ReadALU, ReadALU]>{
3820 let Inst{27-20} = 0b01111000;
3821 let Inst{7-4} = 0b0001;
3822 let Inst{19-16} = Rd;
3823 let Inst{15-12} = Ra;
3824 let Inst{11-8} = Rm;
3828 // Signed/Unsigned saturate
3829 def SSAT : AI<(outs GPRnopc:$Rd),
3830 (ins imm1_32:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3831 SatFrm, NoItinerary, "ssat", "\t$Rd, $sat_imm, $Rn$sh", []>,
3832 Requires<[IsARM,HasV6]>{
3837 let Inst{27-21} = 0b0110101;
3838 let Inst{5-4} = 0b01;
3839 let Inst{20-16} = sat_imm;
3840 let Inst{15-12} = Rd;
3841 let Inst{11-7} = sh{4-0};
3842 let Inst{6} = sh{5};
3846 def SSAT16 : AI<(outs GPRnopc:$Rd),
3847 (ins imm1_16:$sat_imm, GPRnopc:$Rn), SatFrm,
3848 NoItinerary, "ssat16", "\t$Rd, $sat_imm, $Rn", []>,
3849 Requires<[IsARM,HasV6]>{
3853 let Inst{27-20} = 0b01101010;
3854 let Inst{11-4} = 0b11110011;
3855 let Inst{15-12} = Rd;
3856 let Inst{19-16} = sat_imm;
3860 def USAT : AI<(outs GPRnopc:$Rd),
3861 (ins imm0_31:$sat_imm, GPRnopc:$Rn, shift_imm:$sh),
3862 SatFrm, NoItinerary, "usat", "\t$Rd, $sat_imm, $Rn$sh", []>,
3863 Requires<[IsARM,HasV6]> {
3868 let Inst{27-21} = 0b0110111;
3869 let Inst{5-4} = 0b01;
3870 let Inst{15-12} = Rd;
3871 let Inst{11-7} = sh{4-0};
3872 let Inst{6} = sh{5};
3873 let Inst{20-16} = sat_imm;
3877 def USAT16 : AI<(outs GPRnopc:$Rd),
3878 (ins imm0_15:$sat_imm, GPRnopc:$Rn), SatFrm,
3879 NoItinerary, "usat16", "\t$Rd, $sat_imm, $Rn", []>,
3880 Requires<[IsARM,HasV6]>{
3884 let Inst{27-20} = 0b01101110;
3885 let Inst{11-4} = 0b11110011;
3886 let Inst{15-12} = Rd;
3887 let Inst{19-16} = sat_imm;
3891 def : ARMV6Pat<(int_arm_ssat GPRnopc:$a, imm1_32:$pos),
3892 (SSAT imm1_32:$pos, GPRnopc:$a, 0)>;
3893 def : ARMV6Pat<(int_arm_usat GPRnopc:$a, imm0_31:$pos),
3894 (USAT imm0_31:$pos, GPRnopc:$a, 0)>;
3895 def : ARMPat<(ARMssatnoshift GPRnopc:$Rn, imm0_31:$imm),
3896 (SSAT imm0_31:$imm, GPRnopc:$Rn, 0)>;
3897 def : ARMPat<(ARMusatnoshift GPRnopc:$Rn, imm0_31:$imm),
3898 (USAT imm0_31:$imm, GPRnopc:$Rn, 0)>;
3899 def : ARMV6Pat<(int_arm_ssat16 GPRnopc:$a, imm1_16:$pos),
3900 (SSAT16 imm1_16:$pos, GPRnopc:$a)>;
3901 def : ARMV6Pat<(int_arm_usat16 GPRnopc:$a, imm0_15:$pos),
3902 (USAT16 imm0_15:$pos, GPRnopc:$a)>;
3904 //===----------------------------------------------------------------------===//
3905 // Bitwise Instructions.
3908 defm AND : AsI1_bin_irs<0b0000, "and",
3909 IIC_iBITi, IIC_iBITr, IIC_iBITsr, and, 1>;
3910 defm ORR : AsI1_bin_irs<0b1100, "orr",
3911 IIC_iBITi, IIC_iBITr, IIC_iBITsr, or, 1>;
3912 defm EOR : AsI1_bin_irs<0b0001, "eor",
3913 IIC_iBITi, IIC_iBITr, IIC_iBITsr, xor, 1>;
3914 defm BIC : AsI1_bin_irs<0b1110, "bic",
3915 IIC_iBITi, IIC_iBITr, IIC_iBITsr,
3916 BinOpFrag<(and node:$LHS, (not node:$RHS))>>;
3918 // FIXME: bf_inv_mask_imm should be two operands, the lsb and the msb, just
3919 // like in the actual instruction encoding. The complexity of mapping the mask
3920 // to the lsb/msb pair should be handled by ISel, not encapsulated in the
3921 // instruction description.
3922 def BFC : I<(outs GPR:$Rd), (ins GPR:$src, bf_inv_mask_imm:$imm),
3923 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3924 "bfc", "\t$Rd, $imm", "$src = $Rd",
3925 [(set GPR:$Rd, (and GPR:$src, bf_inv_mask_imm:$imm))]>,
3926 Requires<[IsARM, HasV6T2]> {
3929 let Inst{27-21} = 0b0111110;
3930 let Inst{6-0} = 0b0011111;
3931 let Inst{15-12} = Rd;
3932 let Inst{11-7} = imm{4-0}; // lsb
3933 let Inst{20-16} = imm{9-5}; // msb
3936 // A8.6.18 BFI - Bitfield insert (Encoding A1)
3937 def BFI:I<(outs GPRnopc:$Rd), (ins GPRnopc:$src, GPR:$Rn, bf_inv_mask_imm:$imm),
3938 AddrMode1, 4, IndexModeNone, DPFrm, IIC_iUNAsi,
3939 "bfi", "\t$Rd, $Rn, $imm", "$src = $Rd",
3940 [(set GPRnopc:$Rd, (ARMbfi GPRnopc:$src, GPR:$Rn,
3941 bf_inv_mask_imm:$imm))]>,
3942 Requires<[IsARM, HasV6T2]> {
3946 let Inst{27-21} = 0b0111110;
3947 let Inst{6-4} = 0b001; // Rn: Inst{3-0} != 15
3948 let Inst{15-12} = Rd;
3949 let Inst{11-7} = imm{4-0}; // lsb
3950 let Inst{20-16} = imm{9-5}; // width
3954 def MVNr : AsI1<0b1111, (outs GPR:$Rd), (ins GPR:$Rm), DPFrm, IIC_iMVNr,
3955 "mvn", "\t$Rd, $Rm",
3956 [(set GPR:$Rd, (not GPR:$Rm))]>, UnaryDP, Sched<[WriteALU]> {
3960 let Inst{19-16} = 0b0000;
3961 let Inst{11-4} = 0b00000000;
3962 let Inst{15-12} = Rd;
3965 let Unpredictable{19-16} = 0b1111;
3967 def MVNsi : AsI1<0b1111, (outs GPR:$Rd), (ins so_reg_imm:$shift),
3968 DPSoRegImmFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3969 [(set GPR:$Rd, (not so_reg_imm:$shift))]>, UnaryDP,
3974 let Inst{19-16} = 0b0000;
3975 let Inst{15-12} = Rd;
3976 let Inst{11-5} = shift{11-5};
3978 let Inst{3-0} = shift{3-0};
3980 let Unpredictable{19-16} = 0b1111;
3982 def MVNsr : AsI1<0b1111, (outs GPRnopc:$Rd), (ins so_reg_reg:$shift),
3983 DPSoRegRegFrm, IIC_iMVNsr, "mvn", "\t$Rd, $shift",
3984 [(set GPRnopc:$Rd, (not so_reg_reg:$shift))]>, UnaryDP,
3989 let Inst{19-16} = 0b0000;
3990 let Inst{15-12} = Rd;
3991 let Inst{11-8} = shift{11-8};
3993 let Inst{6-5} = shift{6-5};
3995 let Inst{3-0} = shift{3-0};
3997 let Unpredictable{19-16} = 0b1111;
3999 let isReMaterializable = 1, isAsCheapAsAMove = 1, isMoveImm = 1 in
4000 def MVNi : AsI1<0b1111, (outs GPR:$Rd), (ins mod_imm:$imm), DPFrm,
4001 IIC_iMVNi, "mvn", "\t$Rd, $imm",
4002 [(set GPR:$Rd, mod_imm_not:$imm)]>,UnaryDP, Sched<[WriteALU]> {
4006 let Inst{19-16} = 0b0000;
4007 let Inst{15-12} = Rd;
4008 let Inst{11-0} = imm;
4011 let AddedComplexity = 1 in
4012 def : ARMPat<(and GPR:$src, mod_imm_not:$imm),
4013 (BICri GPR:$src, mod_imm_not:$imm)>;
4015 //===----------------------------------------------------------------------===//
4016 // Multiply Instructions.
4018 class AsMul1I32<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
4019 string opc, string asm, list<dag> pattern>
4020 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
4024 let Inst{19-16} = Rd;
4025 let Inst{11-8} = Rm;
4028 class AsMul1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
4029 string opc, string asm, list<dag> pattern>
4030 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
4035 let Inst{19-16} = RdHi;
4036 let Inst{15-12} = RdLo;
4037 let Inst{11-8} = Rm;
4040 class AsMla1I64<bits<7> opcod, dag oops, dag iops, InstrItinClass itin,
4041 string opc, string asm, list<dag> pattern>
4042 : AsMul1I<opcod, oops, iops, itin, opc, asm, pattern> {
4047 let Inst{19-16} = RdHi;
4048 let Inst{15-12} = RdLo;
4049 let Inst{11-8} = Rm;
4053 // FIXME: The v5 pseudos are only necessary for the additional Constraint
4054 // property. Remove them when it's possible to add those properties
4055 // on an individual MachineInstr, not just an instruction description.
4056 let isCommutable = 1, TwoOperandAliasConstraint = "$Rn = $Rd" in {
4057 def MUL : AsMul1I32<0b0000000, (outs GPRnopc:$Rd),
4058 (ins GPRnopc:$Rn, GPRnopc:$Rm),
4059 IIC_iMUL32, "mul", "\t$Rd, $Rn, $Rm",
4060 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))]>,
4061 Requires<[IsARM, HasV6]>,
4062 Sched<[WriteMUL32, ReadMUL, ReadMUL]> {
4063 let Inst{15-12} = 0b0000;
4064 let Unpredictable{15-12} = 0b1111;
4067 let Constraints = "@earlyclobber $Rd" in
4068 def MULv5: ARMPseudoExpand<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm,
4069 pred:$p, cc_out:$s),
4071 [(set GPRnopc:$Rd, (mul GPRnopc:$Rn, GPRnopc:$Rm))],
4072 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s)>,
4073 Requires<[IsARM, NoV6, UseMulOps]>,
4074 Sched<[WriteMUL32, ReadMUL, ReadMUL]>;
4077 def MLA : AsMul1I32<0b0000001, (outs GPRnopc:$Rd),
4078 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra),
4079 IIC_iMAC32, "mla", "\t$Rd, $Rn, $Rm, $Ra",
4080 [(set GPRnopc:$Rd, (add (mul GPRnopc:$Rn, GPRnopc:$Rm), GPRnopc:$Ra))]>,
4081 Requires<[IsARM, HasV6, UseMulOps]>,
4082 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]> {
4084 let Inst{15-12} = Ra;
4087 let Constraints = "@earlyclobber $Rd" in
4088 def MLAv5: ARMPseudoExpand<(outs GPRnopc:$Rd),
4089 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra,
4090 pred:$p, cc_out:$s), 4, IIC_iMAC32,
4091 [(set GPRnopc:$Rd, (add (mul GPRnopc:$Rn, GPRnopc:$Rm), GPRnopc:$Ra))],
4092 (MLA GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra, pred:$p, cc_out:$s)>,
4093 Requires<[IsARM, NoV6]>,
4094 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4096 def MLS : AMul1I<0b0000011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4097 IIC_iMAC32, "mls", "\t$Rd, $Rn, $Rm, $Ra",
4098 [(set GPR:$Rd, (sub GPR:$Ra, (mul GPR:$Rn, GPR:$Rm)))]>,
4099 Requires<[IsARM, HasV6T2, UseMulOps]>,
4100 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]> {
4105 let Inst{19-16} = Rd;
4106 let Inst{15-12} = Ra;
4107 let Inst{11-8} = Rm;
4111 // Extra precision multiplies with low / high results
4112 let hasSideEffects = 0 in {
4113 let isCommutable = 1 in {
4114 def SMULL : AsMul1I64<0b0000110, (outs GPR:$RdLo, GPR:$RdHi),
4115 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
4116 "smull", "\t$RdLo, $RdHi, $Rn, $Rm",
4117 [(set GPR:$RdLo, GPR:$RdHi,
4118 (smullohi GPR:$Rn, GPR:$Rm))]>,
4119 Requires<[IsARM, HasV6]>,
4120 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>;
4122 def UMULL : AsMul1I64<0b0000100, (outs GPR:$RdLo, GPR:$RdHi),
4123 (ins GPR:$Rn, GPR:$Rm), IIC_iMUL64,
4124 "umull", "\t$RdLo, $RdHi, $Rn, $Rm",
4125 [(set GPR:$RdLo, GPR:$RdHi,
4126 (umullohi GPR:$Rn, GPR:$Rm))]>,
4127 Requires<[IsARM, HasV6]>,
4128 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL]>;
4130 let Constraints = "@earlyclobber $RdLo,@earlyclobber $RdHi" in {
4131 def SMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
4132 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
4134 [(set GPR:$RdLo, GPR:$RdHi,
4135 (smullohi GPR:$Rn, GPR:$Rm))],
4136 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
4137 Requires<[IsARM, NoV6]>,
4138 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>;
4140 def UMULLv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
4141 (ins GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s),
4143 [(set GPR:$RdLo, GPR:$RdHi,
4144 (umullohi GPR:$Rn, GPR:$Rm))],
4145 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s)>,
4146 Requires<[IsARM, NoV6]>,
4147 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>;
4151 // Multiply + accumulate
4152 def SMLAL : AsMla1I64<0b0000111, (outs GPR:$RdLo, GPR:$RdHi),
4153 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64,
4154 "smlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4155 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>,
4156 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4157 def UMLAL : AsMla1I64<0b0000101, (outs GPR:$RdLo, GPR:$RdHi),
4158 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi), IIC_iMAC64,
4159 "umlal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4160 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>,
4161 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4163 def UMAAL : AMul1I <0b0000010, (outs GPR:$RdLo, GPR:$RdHi),
4164 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4166 "umaal", "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4167 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">, Requires<[IsARM, HasV6]>,
4168 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]> {
4173 let Inst{19-16} = RdHi;
4174 let Inst{15-12} = RdLo;
4175 let Inst{11-8} = Rm;
4180 "@earlyclobber $RdLo,@earlyclobber $RdHi,$RLo = $RdLo,$RHi = $RdHi" in {
4181 def SMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
4182 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s),
4184 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi,
4185 pred:$p, cc_out:$s)>,
4186 Requires<[IsARM, NoV6]>,
4187 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4188 def UMLALv5 : ARMPseudoExpand<(outs GPR:$RdLo, GPR:$RdHi),
4189 (ins GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi, pred:$p, cc_out:$s),
4191 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi,
4192 pred:$p, cc_out:$s)>,
4193 Requires<[IsARM, NoV6]>,
4194 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4199 // Most significant word multiply
4200 def SMMUL : AMul2I <0b0111010, 0b0001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4201 IIC_iMUL32, "smmul", "\t$Rd, $Rn, $Rm",
4202 [(set GPR:$Rd, (mulhs GPR:$Rn, GPR:$Rm))]>,
4203 Requires<[IsARM, HasV6]>,
4204 Sched<[WriteMUL32, ReadMUL, ReadMUL]> {
4205 let Inst{15-12} = 0b1111;
4208 def SMMULR : AMul2I <0b0111010, 0b0011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4209 IIC_iMUL32, "smmulr", "\t$Rd, $Rn, $Rm",
4210 [(set GPR:$Rd, (ARMsmmlar GPR:$Rn, GPR:$Rm, (i32 0)))]>,
4211 Requires<[IsARM, HasV6]>,
4212 Sched<[WriteMUL32, ReadMUL, ReadMUL]> {
4213 let Inst{15-12} = 0b1111;
4216 def SMMLA : AMul2Ia <0b0111010, 0b0001, (outs GPR:$Rd),
4217 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4218 IIC_iMAC32, "smmla", "\t$Rd, $Rn, $Rm, $Ra",
4219 [(set GPR:$Rd, (add (mulhs GPR:$Rn, GPR:$Rm), GPR:$Ra))]>,
4220 Requires<[IsARM, HasV6, UseMulOps]>,
4221 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4223 def SMMLAR : AMul2Ia <0b0111010, 0b0011, (outs GPR:$Rd),
4224 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4225 IIC_iMAC32, "smmlar", "\t$Rd, $Rn, $Rm, $Ra",
4226 [(set GPR:$Rd, (ARMsmmlar GPR:$Rn, GPR:$Rm, GPR:$Ra))]>,
4227 Requires<[IsARM, HasV6]>,
4228 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4230 def SMMLS : AMul2Ia <0b0111010, 0b1101, (outs GPR:$Rd),
4231 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4232 IIC_iMAC32, "smmls", "\t$Rd, $Rn, $Rm, $Ra", []>,
4233 Requires<[IsARM, HasV6, UseMulOps]>,
4234 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4236 def SMMLSR : AMul2Ia <0b0111010, 0b1111, (outs GPR:$Rd),
4237 (ins GPR:$Rn, GPR:$Rm, GPR:$Ra),
4238 IIC_iMAC32, "smmlsr", "\t$Rd, $Rn, $Rm, $Ra",
4239 [(set GPR:$Rd, (ARMsmmlsr GPR:$Rn, GPR:$Rm, GPR:$Ra))]>,
4240 Requires<[IsARM, HasV6]>,
4241 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4243 multiclass AI_smul<string opc> {
4244 def BB : AMulxyI<0b0001011, 0b00, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4245 IIC_iMUL16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm",
4246 [(set GPR:$Rd, (bb_mul GPR:$Rn, GPR:$Rm))]>,
4247 Requires<[IsARM, HasV5TE]>,
4248 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4250 def BT : AMulxyI<0b0001011, 0b10, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4251 IIC_iMUL16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm",
4252 [(set GPR:$Rd, (bt_mul GPR:$Rn, GPR:$Rm))]>,
4253 Requires<[IsARM, HasV5TE]>,
4254 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4256 def TB : AMulxyI<0b0001011, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4257 IIC_iMUL16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm",
4258 [(set GPR:$Rd, (tb_mul GPR:$Rn, GPR:$Rm))]>,
4259 Requires<[IsARM, HasV5TE]>,
4260 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4262 def TT : AMulxyI<0b0001011, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4263 IIC_iMUL16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm",
4264 [(set GPR:$Rd, (tt_mul GPR:$Rn, GPR:$Rm))]>,
4265 Requires<[IsARM, HasV5TE]>,
4266 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4268 def WB : AMulxyI<0b0001001, 0b01, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4269 IIC_iMUL16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm",
4270 [(set GPR:$Rd, (ARMsmulwb GPR:$Rn, GPR:$Rm))]>,
4271 Requires<[IsARM, HasV5TE]>,
4272 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4274 def WT : AMulxyI<0b0001001, 0b11, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm),
4275 IIC_iMUL16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm",
4276 [(set GPR:$Rd, (ARMsmulwt GPR:$Rn, GPR:$Rm))]>,
4277 Requires<[IsARM, HasV5TE]>,
4278 Sched<[WriteMUL16, ReadMUL, ReadMUL]>;
4282 multiclass AI_smla<string opc> {
4283 let DecoderMethod = "DecodeSMLAInstruction" in {
4284 def BB : AMulxyIa<0b0001000, 0b00, (outs GPRnopc:$Rd),
4285 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4286 IIC_iMAC16, !strconcat(opc, "bb"), "\t$Rd, $Rn, $Rm, $Ra",
4287 [(set GPRnopc:$Rd, (add GPR:$Ra,
4288 (bb_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4289 Requires<[IsARM, HasV5TE, UseMulOps]>,
4290 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4292 def BT : AMulxyIa<0b0001000, 0b10, (outs GPRnopc:$Rd),
4293 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4294 IIC_iMAC16, !strconcat(opc, "bt"), "\t$Rd, $Rn, $Rm, $Ra",
4295 [(set GPRnopc:$Rd, (add GPR:$Ra,
4296 (bt_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4297 Requires<[IsARM, HasV5TE, UseMulOps]>,
4298 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4300 def TB : AMulxyIa<0b0001000, 0b01, (outs GPRnopc:$Rd),
4301 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4302 IIC_iMAC16, !strconcat(opc, "tb"), "\t$Rd, $Rn, $Rm, $Ra",
4303 [(set GPRnopc:$Rd, (add GPR:$Ra,
4304 (tb_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4305 Requires<[IsARM, HasV5TE, UseMulOps]>,
4306 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4308 def TT : AMulxyIa<0b0001000, 0b11, (outs GPRnopc:$Rd),
4309 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4310 IIC_iMAC16, !strconcat(opc, "tt"), "\t$Rd, $Rn, $Rm, $Ra",
4311 [(set GPRnopc:$Rd, (add GPR:$Ra,
4312 (tt_mul GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4313 Requires<[IsARM, HasV5TE, UseMulOps]>,
4314 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4316 def WB : AMulxyIa<0b0001001, 0b00, (outs GPRnopc:$Rd),
4317 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4318 IIC_iMAC16, !strconcat(opc, "wb"), "\t$Rd, $Rn, $Rm, $Ra",
4320 (add GPR:$Ra, (ARMsmulwb GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4321 Requires<[IsARM, HasV5TE, UseMulOps]>,
4322 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4324 def WT : AMulxyIa<0b0001001, 0b10, (outs GPRnopc:$Rd),
4325 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4326 IIC_iMAC16, !strconcat(opc, "wt"), "\t$Rd, $Rn, $Rm, $Ra",
4328 (add GPR:$Ra, (ARMsmulwt GPRnopc:$Rn, GPRnopc:$Rm)))]>,
4329 Requires<[IsARM, HasV5TE, UseMulOps]>,
4330 Sched<[WriteMAC16, ReadMUL, ReadMUL, ReadMAC]>;
4334 defm SMUL : AI_smul<"smul">;
4335 defm SMLA : AI_smla<"smla">;
4337 // Halfword multiply accumulate long: SMLAL<x><y>.
4338 class SMLAL<bits<2> opc1, string asm>
4339 : AMulxyI64<0b0001010, opc1,
4340 (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4341 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4342 IIC_iMAC64, asm, "\t$RdLo, $RdHi, $Rn, $Rm", []>,
4343 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">,
4344 Requires<[IsARM, HasV5TE]>,
4345 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4347 def SMLALBB : SMLAL<0b00, "smlalbb">;
4348 def SMLALBT : SMLAL<0b10, "smlalbt">;
4349 def SMLALTB : SMLAL<0b01, "smlaltb">;
4350 def SMLALTT : SMLAL<0b11, "smlaltt">;
4352 def : ARMV5TEPat<(ARMsmlalbb GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4353 (SMLALBB $Rn, $Rm, $RLo, $RHi)>;
4354 def : ARMV5TEPat<(ARMsmlalbt GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4355 (SMLALBT $Rn, $Rm, $RLo, $RHi)>;
4356 def : ARMV5TEPat<(ARMsmlaltb GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4357 (SMLALTB $Rn, $Rm, $RLo, $RHi)>;
4358 def : ARMV5TEPat<(ARMsmlaltt GPR:$Rn, GPR:$Rm, GPR:$RLo, GPR:$RHi),
4359 (SMLALTT $Rn, $Rm, $RLo, $RHi)>;
4361 // Helper class for AI_smld.
4362 class AMulDualIbase<bit long, bit sub, bit swap, dag oops, dag iops,
4363 InstrItinClass itin, string opc, string asm>
4364 : AI<oops, iops, MulFrm, itin, opc, asm, []>,
4365 Requires<[IsARM, HasV6]> {
4368 let Inst{27-23} = 0b01110;
4369 let Inst{22} = long;
4370 let Inst{21-20} = 0b00;
4371 let Inst{11-8} = Rm;
4378 class AMulDualI<bit long, bit sub, bit swap, dag oops, dag iops,
4379 InstrItinClass itin, string opc, string asm>
4380 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4382 let Inst{15-12} = 0b1111;
4383 let Inst{19-16} = Rd;
4385 class AMulDualIa<bit long, bit sub, bit swap, dag oops, dag iops,
4386 InstrItinClass itin, string opc, string asm>
4387 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4390 let Inst{19-16} = Rd;
4391 let Inst{15-12} = Ra;
4393 class AMulDualI64<bit long, bit sub, bit swap, dag oops, dag iops,
4394 InstrItinClass itin, string opc, string asm>
4395 : AMulDualIbase<long, sub, swap, oops, iops, itin, opc, asm> {
4398 let Inst{19-16} = RdHi;
4399 let Inst{15-12} = RdLo;
4402 multiclass AI_smld<bit sub, string opc> {
4404 def D : AMulDualIa<0, sub, 0, (outs GPRnopc:$Rd),
4405 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4406 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm, $Ra">,
4407 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4409 def DX: AMulDualIa<0, sub, 1, (outs GPRnopc:$Rd),
4410 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4411 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm, $Ra">,
4412 Sched<[WriteMAC32, ReadMUL, ReadMUL, ReadMAC]>;
4414 def LD: AMulDualI64<1, sub, 0, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4415 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4417 !strconcat(opc, "ld"), "\t$RdLo, $RdHi, $Rn, $Rm">,
4418 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">,
4419 Sched<[WriteMAC64Lo, WriteMAC64Hi, ReadMUL, ReadMUL, ReadMAC, ReadMAC]>;
4421 def LDX : AMulDualI64<1, sub, 1, (outs GPRnopc:$RdLo, GPRnopc:$RdHi),
4422 (ins GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4424 !strconcat(opc, "ldx"),"\t$RdLo, $RdHi, $Rn, $Rm">,
4425 RegConstraint<"$RLo = $RdLo, $RHi = $RdHi">,
4426 Sched<[WriteMUL64Lo, WriteMUL64Hi, ReadMUL, ReadMUL]>;
4429 defm SMLA : AI_smld<0, "smla">;
4430 defm SMLS : AI_smld<1, "smls">;
4432 def : ARMV6Pat<(int_arm_smlad GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4433 (SMLAD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>;
4434 def : ARMV6Pat<(int_arm_smladx GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4435 (SMLADX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>;
4436 def : ARMV6Pat<(int_arm_smlsd GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4437 (SMLSD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>;
4438 def : ARMV6Pat<(int_arm_smlsdx GPRnopc:$Rn, GPRnopc:$Rm, GPR:$Ra),
4439 (SMLSDX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra)>;
4440 def : ARMV6Pat<(ARMSmlald GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4441 (SMLALD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>;
4442 def : ARMV6Pat<(ARMSmlaldx GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4443 (SMLALDX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>;
4444 def : ARMV6Pat<(ARMSmlsld GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4445 (SMLSLD GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>;
4446 def : ARMV6Pat<(ARMSmlsldx GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi),
4447 (SMLSLDX GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$RLo, GPRnopc:$RHi)>;
4449 multiclass AI_sdml<bit sub, string opc> {
4451 def D:AMulDualI<0, sub, 0, (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm),
4452 NoItinerary, !strconcat(opc, "d"), "\t$Rd, $Rn, $Rm">,
4453 Sched<[WriteMUL32, ReadMUL, ReadMUL]>;
4454 def DX:AMulDualI<0, sub, 1, (outs GPRnopc:$Rd),(ins GPRnopc:$Rn, GPRnopc:$Rm),
4455 NoItinerary, !strconcat(opc, "dx"), "\t$Rd, $Rn, $Rm">,
4456 Sched<[WriteMUL32, ReadMUL, ReadMUL]>;
4459 defm SMUA : AI_sdml<0, "smua">;
4460 defm SMUS : AI_sdml<1, "smus">;
4462 def : ARMV6Pat<(int_arm_smuad GPRnopc:$Rn, GPRnopc:$Rm),
4463 (SMUAD GPRnopc:$Rn, GPRnopc:$Rm)>;
4464 def : ARMV6Pat<(int_arm_smuadx GPRnopc:$Rn, GPRnopc:$Rm),
4465 (SMUADX GPRnopc:$Rn, GPRnopc:$Rm)>;
4466 def : ARMV6Pat<(int_arm_smusd GPRnopc:$Rn, GPRnopc:$Rm),
4467 (SMUSD GPRnopc:$Rn, GPRnopc:$Rm)>;
4468 def : ARMV6Pat<(int_arm_smusdx GPRnopc:$Rn, GPRnopc:$Rm),
4469 (SMUSDX GPRnopc:$Rn, GPRnopc:$Rm)>;
4471 //===----------------------------------------------------------------------===//
4472 // Division Instructions (ARMv7-A with virtualization extension)
4474 def SDIV : ADivA1I<0b001, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV,
4475 "sdiv", "\t$Rd, $Rn, $Rm",
4476 [(set GPR:$Rd, (sdiv GPR:$Rn, GPR:$Rm))]>,
4477 Requires<[IsARM, HasDivideInARM]>,
4480 def UDIV : ADivA1I<0b011, (outs GPR:$Rd), (ins GPR:$Rn, GPR:$Rm), IIC_iDIV,
4481 "udiv", "\t$Rd, $Rn, $Rm",
4482 [(set GPR:$Rd, (udiv GPR:$Rn, GPR:$Rm))]>,
4483 Requires<[IsARM, HasDivideInARM]>,
4486 //===----------------------------------------------------------------------===//
4487 // Misc. Arithmetic Instructions.
4490 def CLZ : AMiscA1I<0b00010110, 0b0001, (outs GPR:$Rd), (ins GPR:$Rm),
4491 IIC_iUNAr, "clz", "\t$Rd, $Rm",
4492 [(set GPR:$Rd, (ctlz GPR:$Rm))]>, Requires<[IsARM, HasV5T]>,
4495 def RBIT : AMiscA1I<0b01101111, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
4496 IIC_iUNAr, "rbit", "\t$Rd, $Rm",
4497 [(set GPR:$Rd, (bitreverse GPR:$Rm))]>,
4498 Requires<[IsARM, HasV6T2]>,
4501 def REV : AMiscA1I<0b01101011, 0b0011, (outs GPR:$Rd), (ins GPR:$Rm),
4502 IIC_iUNAr, "rev", "\t$Rd, $Rm",
4503 [(set GPR:$Rd, (bswap GPR:$Rm))]>, Requires<[IsARM, HasV6]>,
4506 let AddedComplexity = 5 in
4507 def REV16 : AMiscA1I<0b01101011, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
4508 IIC_iUNAr, "rev16", "\t$Rd, $Rm",
4509 [(set GPR:$Rd, (rotr (bswap GPR:$Rm), (i32 16)))]>,
4510 Requires<[IsARM, HasV6]>,
4513 def : ARMV6Pat<(srl (bswap (extloadi16 addrmode3:$addr)), (i32 16)),
4514 (REV16 (LDRH addrmode3:$addr))>;
4515 def : ARMV6Pat<(truncstorei16 (srl (bswap GPR:$Rn), (i32 16)), addrmode3:$addr),
4516 (STRH (REV16 GPR:$Rn), addrmode3:$addr)>;
4518 let AddedComplexity = 5 in
4519 def REVSH : AMiscA1I<0b01101111, 0b1011, (outs GPR:$Rd), (ins GPR:$Rm),
4520 IIC_iUNAr, "revsh", "\t$Rd, $Rm",
4521 [(set GPR:$Rd, (sra (bswap GPR:$Rm), (i32 16)))]>,
4522 Requires<[IsARM, HasV6]>,
4525 def : ARMV6Pat<(or (sra (shl GPR:$Rm, (i32 24)), (i32 16)),
4526 (and (srl GPR:$Rm, (i32 8)), 0xFF)),
4529 def PKHBT : APKHI<0b01101000, 0, (outs GPRnopc:$Rd),
4530 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_lsl_amt:$sh),
4531 IIC_iALUsi, "pkhbt", "\t$Rd, $Rn, $Rm$sh",
4532 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF),
4533 (and (shl GPRnopc:$Rm, pkh_lsl_amt:$sh),
4535 Requires<[IsARM, HasV6]>,
4536 Sched<[WriteALUsi, ReadALU]>;
4538 // Alternate cases for PKHBT where identities eliminate some nodes.
4539 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (and GPRnopc:$Rm, 0xFFFF0000)),
4540 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, 0)>;
4541 def : ARMV6Pat<(or (and GPRnopc:$Rn, 0xFFFF), (shl GPRnopc:$Rm, imm16_31:$sh)),
4542 (PKHBT GPRnopc:$Rn, GPRnopc:$Rm, imm16_31:$sh)>;
4544 // Note: Shifts of 1-15 bits will be transformed to srl instead of sra and
4545 // will match the pattern below.
4546 def PKHTB : APKHI<0b01101000, 1, (outs GPRnopc:$Rd),
4547 (ins GPRnopc:$Rn, GPRnopc:$Rm, pkh_asr_amt:$sh),
4548 IIC_iBITsi, "pkhtb", "\t$Rd, $Rn, $Rm$sh",
4549 [(set GPRnopc:$Rd, (or (and GPRnopc:$Rn, 0xFFFF0000),
4550 (and (sra GPRnopc:$Rm, pkh_asr_amt:$sh),
4552 Requires<[IsARM, HasV6]>,
4553 Sched<[WriteALUsi, ReadALU]>;
4555 // Alternate cases for PKHTB where identities eliminate some nodes. Note that
4556 // a shift amount of 0 is *not legal* here, it is PKHBT instead.
4557 // We also can not replace a srl (17..31) by an arithmetic shift we would use in
4558 // pkhtb src1, src2, asr (17..31).
4559 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4560 (srl GPRnopc:$src2, imm16:$sh)),
4561 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16:$sh)>;
4562 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4563 (sra GPRnopc:$src2, imm16_31:$sh)),
4564 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm16_31:$sh)>;
4565 def : ARMV6Pat<(or (and GPRnopc:$src1, 0xFFFF0000),
4566 (and (srl GPRnopc:$src2, imm1_15:$sh), 0xFFFF)),
4567 (PKHTB GPRnopc:$src1, GPRnopc:$src2, imm1_15:$sh)>;
4569 //===----------------------------------------------------------------------===//
4573 // + CRC32{B,H,W} 0x04C11DB7
4574 // + CRC32C{B,H,W} 0x1EDC6F41
4577 class AI_crc32<bit C, bits<2> sz, string suffix, SDPatternOperator builtin>
4578 : AInoP<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, GPRnopc:$Rm), MiscFrm, NoItinerary,
4579 !strconcat("crc32", suffix), "\t$Rd, $Rn, $Rm",
4580 [(set GPRnopc:$Rd, (builtin GPRnopc:$Rn, GPRnopc:$Rm))]>,
4581 Requires<[IsARM, HasV8, HasCRC]> {
4586 let Inst{31-28} = 0b1110;
4587 let Inst{27-23} = 0b00010;
4588 let Inst{22-21} = sz;
4590 let Inst{19-16} = Rn;
4591 let Inst{15-12} = Rd;
4592 let Inst{11-10} = 0b00;
4595 let Inst{7-4} = 0b0100;
4598 let Unpredictable{11-8} = 0b1101;
4601 def CRC32B : AI_crc32<0, 0b00, "b", int_arm_crc32b>;
4602 def CRC32CB : AI_crc32<1, 0b00, "cb", int_arm_crc32cb>;
4603 def CRC32H : AI_crc32<0, 0b01, "h", int_arm_crc32h>;
4604 def CRC32CH : AI_crc32<1, 0b01, "ch", int_arm_crc32ch>;
4605 def CRC32W : AI_crc32<0, 0b10, "w", int_arm_crc32w>;
4606 def CRC32CW : AI_crc32<1, 0b10, "cw", int_arm_crc32cw>;
4608 //===----------------------------------------------------------------------===//
4609 // ARMv8.1a Privilege Access Never extension
4613 def SETPAN : AInoP<(outs), (ins imm0_1:$imm), MiscFrm, NoItinerary, "setpan",
4614 "\t$imm", []>, Requires<[IsARM, HasV8, HasV8_1a]> {
4617 let Inst{31-28} = 0b1111;
4618 let Inst{27-20} = 0b00010001;
4619 let Inst{19-16} = 0b0000;
4620 let Inst{15-10} = 0b000000;
4623 let Inst{7-4} = 0b0000;
4624 let Inst{3-0} = 0b0000;
4626 let Unpredictable{19-16} = 0b1111;
4627 let Unpredictable{15-10} = 0b111111;
4628 let Unpredictable{8} = 0b1;
4629 let Unpredictable{3-0} = 0b1111;
4632 //===----------------------------------------------------------------------===//
4633 // Comparison Instructions...
4636 defm CMP : AI1_cmp_irs<0b1010, "cmp",
4637 IIC_iCMPi, IIC_iCMPr, IIC_iCMPsr, ARMcmp>;
4639 // ARMcmpZ can re-use the above instruction definitions.
4640 def : ARMPat<(ARMcmpZ GPR:$src, mod_imm:$imm),
4641 (CMPri GPR:$src, mod_imm:$imm)>;
4642 def : ARMPat<(ARMcmpZ GPR:$src, GPR:$rhs),
4643 (CMPrr GPR:$src, GPR:$rhs)>;
4644 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_imm:$rhs),
4645 (CMPrsi GPR:$src, so_reg_imm:$rhs)>;
4646 def : ARMPat<(ARMcmpZ GPR:$src, so_reg_reg:$rhs),
4647 (CMPrsr GPR:$src, so_reg_reg:$rhs)>;
4649 // CMN register-integer
4650 let isCompare = 1, Defs = [CPSR] in {
4651 def CMNri : AI1<0b1011, (outs), (ins GPR:$Rn, mod_imm:$imm), DPFrm, IIC_iCMPi,
4652 "cmn", "\t$Rn, $imm",
4653 [(ARMcmn GPR:$Rn, mod_imm:$imm)]>,
4654 Sched<[WriteCMP, ReadALU]> {
4659 let Inst{19-16} = Rn;
4660 let Inst{15-12} = 0b0000;
4661 let Inst{11-0} = imm;
4663 let Unpredictable{15-12} = 0b1111;
4666 // CMN register-register/shift
4667 def CMNzrr : AI1<0b1011, (outs), (ins GPR:$Rn, GPR:$Rm), DPFrm, IIC_iCMPr,
4668 "cmn", "\t$Rn, $Rm",
4669 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4670 GPR:$Rn, GPR:$Rm)]>, Sched<[WriteCMP, ReadALU, ReadALU]> {
4673 let isCommutable = 1;
4676 let Inst{19-16} = Rn;
4677 let Inst{15-12} = 0b0000;
4678 let Inst{11-4} = 0b00000000;
4681 let Unpredictable{15-12} = 0b1111;
4684 def CMNzrsi : AI1<0b1011, (outs),
4685 (ins GPR:$Rn, so_reg_imm:$shift), DPSoRegImmFrm, IIC_iCMPsr,
4686 "cmn", "\t$Rn, $shift",
4687 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4688 GPR:$Rn, so_reg_imm:$shift)]>,
4689 Sched<[WriteCMPsi, ReadALU]> {
4694 let Inst{19-16} = Rn;
4695 let Inst{15-12} = 0b0000;
4696 let Inst{11-5} = shift{11-5};
4698 let Inst{3-0} = shift{3-0};
4700 let Unpredictable{15-12} = 0b1111;
4703 def CMNzrsr : AI1<0b1011, (outs),
4704 (ins GPRnopc:$Rn, so_reg_reg:$shift), DPSoRegRegFrm, IIC_iCMPsr,
4705 "cmn", "\t$Rn, $shift",
4706 [(BinOpFrag<(ARMcmpZ node:$LHS,(ineg node:$RHS))>
4707 GPRnopc:$Rn, so_reg_reg:$shift)]>,
4708 Sched<[WriteCMPsr, ReadALU]> {
4713 let Inst{19-16} = Rn;
4714 let Inst{15-12} = 0b0000;
4715 let Inst{11-8} = shift{11-8};
4717 let Inst{6-5} = shift{6-5};
4719 let Inst{3-0} = shift{3-0};
4721 let Unpredictable{15-12} = 0b1111;
4726 def : ARMPat<(ARMcmp GPR:$src, mod_imm_neg:$imm),
4727 (CMNri GPR:$src, mod_imm_neg:$imm)>;
4729 def : ARMPat<(ARMcmpZ GPR:$src, mod_imm_neg:$imm),
4730 (CMNri GPR:$src, mod_imm_neg:$imm)>;
4732 // Note that TST/TEQ don't set all the same flags that CMP does!
4733 defm TST : AI1_cmp_irs<0b1000, "tst",
4734 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
4735 BinOpFrag<(ARMcmpZ (and_su node:$LHS, node:$RHS), 0)>, 1,
4736 "DecodeTSTInstruction">;
4737 defm TEQ : AI1_cmp_irs<0b1001, "teq",
4738 IIC_iTSTi, IIC_iTSTr, IIC_iTSTsr,
4739 BinOpFrag<(ARMcmpZ (xor_su node:$LHS, node:$RHS), 0)>, 1>;
4741 // Pseudo i64 compares for some floating point compares.
4742 let usesCustomInserter = 1, isBranch = 1, isTerminator = 1,
4744 def BCCi64 : PseudoInst<(outs),
4745 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, brtarget:$dst),
4747 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, GPR:$rhs1, GPR:$rhs2, bb:$dst)]>,
4750 def BCCZi64 : PseudoInst<(outs),
4751 (ins i32imm:$cc, GPR:$lhs1, GPR:$lhs2, brtarget:$dst), IIC_Br,
4752 [(ARMBcci64 imm:$cc, GPR:$lhs1, GPR:$lhs2, 0, 0, bb:$dst)]>,
4754 } // usesCustomInserter
4757 // Conditional moves
4758 let hasSideEffects = 0 in {
4760 let isCommutable = 1, isSelect = 1 in
4761 def MOVCCr : ARMPseudoInst<(outs GPR:$Rd),
4762 (ins GPR:$false, GPR:$Rm, cmovpred:$p),
4764 [(set GPR:$Rd, (ARMcmov GPR:$false, GPR:$Rm,
4766 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4768 def MOVCCsi : ARMPseudoInst<(outs GPR:$Rd),
4769 (ins GPR:$false, so_reg_imm:$shift, cmovpred:$p),
4772 (ARMcmov GPR:$false, so_reg_imm:$shift,
4774 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4775 def MOVCCsr : ARMPseudoInst<(outs GPR:$Rd),
4776 (ins GPR:$false, so_reg_reg:$shift, cmovpred:$p),
4778 [(set GPR:$Rd, (ARMcmov GPR:$false, so_reg_reg:$shift,
4780 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4783 let isMoveImm = 1 in
4785 : ARMPseudoInst<(outs GPR:$Rd),
4786 (ins GPR:$false, imm0_65535_expr:$imm, cmovpred:$p),
4788 [(set GPR:$Rd, (ARMcmov GPR:$false, imm0_65535:$imm,
4790 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>,
4793 let isMoveImm = 1 in
4794 def MOVCCi : ARMPseudoInst<(outs GPR:$Rd),
4795 (ins GPR:$false, mod_imm:$imm, cmovpred:$p),
4797 [(set GPR:$Rd, (ARMcmov GPR:$false, mod_imm:$imm,
4799 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4801 // Two instruction predicate mov immediate.
4802 let isMoveImm = 1 in
4804 : ARMPseudoInst<(outs GPR:$Rd),
4805 (ins GPR:$false, i32imm:$src, cmovpred:$p),
4807 [(set GPR:$Rd, (ARMcmov GPR:$false, imm:$src,
4809 RegConstraint<"$false = $Rd">, Requires<[IsARM, HasV6T2]>;
4811 let isMoveImm = 1 in
4812 def MVNCCi : ARMPseudoInst<(outs GPR:$Rd),
4813 (ins GPR:$false, mod_imm:$imm, cmovpred:$p),
4815 [(set GPR:$Rd, (ARMcmov GPR:$false, mod_imm_not:$imm,
4817 RegConstraint<"$false = $Rd">, Sched<[WriteALU]>;
4822 //===----------------------------------------------------------------------===//
4823 // Atomic operations intrinsics
4826 def MemBarrierOptOperand : AsmOperandClass {
4827 let Name = "MemBarrierOpt";
4828 let ParserMethod = "parseMemBarrierOptOperand";
4830 def memb_opt : Operand<i32> {
4831 let PrintMethod = "printMemBOption";
4832 let ParserMatchClass = MemBarrierOptOperand;
4833 let DecoderMethod = "DecodeMemBarrierOption";
4836 def InstSyncBarrierOptOperand : AsmOperandClass {
4837 let Name = "InstSyncBarrierOpt";
4838 let ParserMethod = "parseInstSyncBarrierOptOperand";
4840 def instsyncb_opt : Operand<i32> {
4841 let PrintMethod = "printInstSyncBOption";
4842 let ParserMatchClass = InstSyncBarrierOptOperand;
4843 let DecoderMethod = "DecodeInstSyncBarrierOption";
4846 def TraceSyncBarrierOptOperand : AsmOperandClass {
4847 let Name = "TraceSyncBarrierOpt";
4848 let ParserMethod = "parseTraceSyncBarrierOptOperand";
4850 def tsb_opt : Operand<i32> {
4851 let PrintMethod = "printTraceSyncBOption";
4852 let ParserMatchClass = TraceSyncBarrierOptOperand;
4855 // Memory barriers protect the atomic sequences
4856 let hasSideEffects = 1 in {
4857 def DMB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4858 "dmb", "\t$opt", [(int_arm_dmb (i32 imm0_15:$opt))]>,
4859 Requires<[IsARM, HasDB]> {
4861 let Inst{31-4} = 0xf57ff05;
4862 let Inst{3-0} = opt;
4865 def DSB : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary,
4866 "dsb", "\t$opt", [(int_arm_dsb (i32 imm0_15:$opt))]>,
4867 Requires<[IsARM, HasDB]> {
4869 let Inst{31-4} = 0xf57ff04;
4870 let Inst{3-0} = opt;
4873 // ISB has only full system option
4874 def ISB : AInoP<(outs), (ins instsyncb_opt:$opt), MiscFrm, NoItinerary,
4875 "isb", "\t$opt", [(int_arm_isb (i32 imm0_15:$opt))]>,
4876 Requires<[IsARM, HasDB]> {
4878 let Inst{31-4} = 0xf57ff06;
4879 let Inst{3-0} = opt;
4882 let hasNoSchedulingInfo = 1 in
4883 def TSB : AInoP<(outs), (ins tsb_opt:$opt), MiscFrm, NoItinerary,
4884 "tsb", "\t$opt", []>, Requires<[IsARM, HasV8_4a]> {
4885 let Inst{31-0} = 0xe320f012;
4890 // Armv8.5-A speculation barrier
4891 def SB : AInoP<(outs), (ins), MiscFrm, NoItinerary, "sb", "", []>,
4892 Requires<[IsARM, HasSB]>, Sched<[]> {
4893 let Inst{31-0} = 0xf57ff070;
4894 let Unpredictable = 0x000fff0f;
4895 let hasSideEffects = 1;
4898 let usesCustomInserter = 1, Defs = [CPSR] in {
4900 // Pseudo instruction that combines movs + predicated rsbmi
4901 // to implement integer ABS
4902 def ABS : ARMPseudoInst<(outs GPR:$dst), (ins GPR:$src), 8, NoItinerary, []>;
4905 let usesCustomInserter = 1, Defs = [CPSR] in {
4906 def COPY_STRUCT_BYVAL_I32 : PseudoInst<
4907 (outs), (ins GPR:$dst, GPR:$src, i32imm:$size, i32imm:$alignment),
4909 [(ARMcopystructbyval GPR:$dst, GPR:$src, imm:$size, imm:$alignment)]>;
4912 let hasPostISelHook = 1, Constraints = "$newdst = $dst, $newsrc = $src" in {
4913 // %newsrc, %newdst = MEMCPY %dst, %src, N, ...N scratch regs...
4914 // Copies N registers worth of memory from address %src to address %dst
4915 // and returns the incremented addresses. N scratch register will
4916 // be attached for the copy to use.
4917 def MEMCPY : PseudoInst<
4918 (outs GPR:$newdst, GPR:$newsrc),
4919 (ins GPR:$dst, GPR:$src, i32imm:$nreg, variable_ops),
4921 [(set GPR:$newdst, GPR:$newsrc,
4922 (ARMmemcopy GPR:$dst, GPR:$src, imm:$nreg))]>;
4925 def ldrex_1 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4926 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4929 def ldrex_2 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4930 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4933 def ldrex_4 : PatFrag<(ops node:$ptr), (int_arm_ldrex node:$ptr), [{
4934 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4937 def strex_1 : PatFrag<(ops node:$val, node:$ptr),
4938 (int_arm_strex node:$val, node:$ptr), [{
4939 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4942 def strex_2 : PatFrag<(ops node:$val, node:$ptr),
4943 (int_arm_strex node:$val, node:$ptr), [{
4944 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4947 def strex_4 : PatFrag<(ops node:$val, node:$ptr),
4948 (int_arm_strex node:$val, node:$ptr), [{
4949 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4952 def ldaex_1 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4953 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4956 def ldaex_2 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4957 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4960 def ldaex_4 : PatFrag<(ops node:$ptr), (int_arm_ldaex node:$ptr), [{
4961 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4964 def stlex_1 : PatFrag<(ops node:$val, node:$ptr),
4965 (int_arm_stlex node:$val, node:$ptr), [{
4966 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i8;
4969 def stlex_2 : PatFrag<(ops node:$val, node:$ptr),
4970 (int_arm_stlex node:$val, node:$ptr), [{
4971 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i16;
4974 def stlex_4 : PatFrag<(ops node:$val, node:$ptr),
4975 (int_arm_stlex node:$val, node:$ptr), [{
4976 return cast<MemIntrinsicSDNode>(N)->getMemoryVT() == MVT::i32;
4979 let mayLoad = 1 in {
4980 def LDREXB : AIldrex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4981 NoItinerary, "ldrexb", "\t$Rt, $addr",
4982 [(set GPR:$Rt, (ldrex_1 addr_offset_none:$addr))]>;
4983 def LDREXH : AIldrex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4984 NoItinerary, "ldrexh", "\t$Rt, $addr",
4985 [(set GPR:$Rt, (ldrex_2 addr_offset_none:$addr))]>;
4986 def LDREX : AIldrex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4987 NoItinerary, "ldrex", "\t$Rt, $addr",
4988 [(set GPR:$Rt, (ldrex_4 addr_offset_none:$addr))]>;
4989 let hasExtraDefRegAllocReq = 1 in
4990 def LDREXD : AIldrex<0b01, (outs GPRPairOp:$Rt),(ins addr_offset_none:$addr),
4991 NoItinerary, "ldrexd", "\t$Rt, $addr", []> {
4992 let DecoderMethod = "DecodeDoubleRegLoad";
4995 def LDAEXB : AIldaex<0b10, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4996 NoItinerary, "ldaexb", "\t$Rt, $addr",
4997 [(set GPR:$Rt, (ldaex_1 addr_offset_none:$addr))]>;
4998 def LDAEXH : AIldaex<0b11, (outs GPR:$Rt), (ins addr_offset_none:$addr),
4999 NoItinerary, "ldaexh", "\t$Rt, $addr",
5000 [(set GPR:$Rt, (ldaex_2 addr_offset_none:$addr))]>;
5001 def LDAEX : AIldaex<0b00, (outs GPR:$Rt), (ins addr_offset_none:$addr),
5002 NoItinerary, "ldaex", "\t$Rt, $addr",
5003 [(set GPR:$Rt, (ldaex_4 addr_offset_none:$addr))]>;
5004 let hasExtraDefRegAllocReq = 1 in
5005 def LDAEXD : AIldaex<0b01, (outs GPRPairOp:$Rt),(ins addr_offset_none:$addr),
5006 NoItinerary, "ldaexd", "\t$Rt, $addr", []> {
5007 let DecoderMethod = "DecodeDoubleRegLoad";
5011 let mayStore = 1, Constraints = "@earlyclobber $Rd" in {
5012 def STREXB: AIstrex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5013 NoItinerary, "strexb", "\t$Rd, $Rt, $addr",
5014 [(set GPR:$Rd, (strex_1 GPR:$Rt,
5015 addr_offset_none:$addr))]>;
5016 def STREXH: AIstrex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5017 NoItinerary, "strexh", "\t$Rd, $Rt, $addr",
5018 [(set GPR:$Rd, (strex_2 GPR:$Rt,
5019 addr_offset_none:$addr))]>;
5020 def STREX : AIstrex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5021 NoItinerary, "strex", "\t$Rd, $Rt, $addr",
5022 [(set GPR:$Rd, (strex_4 GPR:$Rt,
5023 addr_offset_none:$addr))]>;
5024 let hasExtraSrcRegAllocReq = 1 in
5025 def STREXD : AIstrex<0b01, (outs GPR:$Rd),
5026 (ins GPRPairOp:$Rt, addr_offset_none:$addr),
5027 NoItinerary, "strexd", "\t$Rd, $Rt, $addr", []> {
5028 let DecoderMethod = "DecodeDoubleRegStore";
5030 def STLEXB: AIstlex<0b10, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5031 NoItinerary, "stlexb", "\t$Rd, $Rt, $addr",
5033 (stlex_1 GPR:$Rt, addr_offset_none:$addr))]>;
5034 def STLEXH: AIstlex<0b11, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5035 NoItinerary, "stlexh", "\t$Rd, $Rt, $addr",
5037 (stlex_2 GPR:$Rt, addr_offset_none:$addr))]>;
5038 def STLEX : AIstlex<0b00, (outs GPR:$Rd), (ins GPR:$Rt, addr_offset_none:$addr),
5039 NoItinerary, "stlex", "\t$Rd, $Rt, $addr",
5041 (stlex_4 GPR:$Rt, addr_offset_none:$addr))]>;
5042 let hasExtraSrcRegAllocReq = 1 in
5043 def STLEXD : AIstlex<0b01, (outs GPR:$Rd),
5044 (ins GPRPairOp:$Rt, addr_offset_none:$addr),
5045 NoItinerary, "stlexd", "\t$Rd, $Rt, $addr", []> {
5046 let DecoderMethod = "DecodeDoubleRegStore";
5050 def CLREX : AXI<(outs), (ins), MiscFrm, NoItinerary, "clrex",
5052 Requires<[IsARM, HasV6K]> {
5053 let Inst{31-0} = 0b11110101011111111111000000011111;
5056 def : ARMPat<(strex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr),
5057 (STREXB GPR:$Rt, addr_offset_none:$addr)>;
5058 def : ARMPat<(strex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr),
5059 (STREXH GPR:$Rt, addr_offset_none:$addr)>;
5061 def : ARMPat<(stlex_1 (and GPR:$Rt, 0xff), addr_offset_none:$addr),
5062 (STLEXB GPR:$Rt, addr_offset_none:$addr)>;
5063 def : ARMPat<(stlex_2 (and GPR:$Rt, 0xffff), addr_offset_none:$addr),
5064 (STLEXH GPR:$Rt, addr_offset_none:$addr)>;
5066 class acquiring_load<PatFrag base>
5067 : PatFrag<(ops node:$ptr), (base node:$ptr), [{
5068 AtomicOrdering Ordering = cast<AtomicSDNode>(N)->getOrdering();
5069 return isAcquireOrStronger(Ordering);
5072 def atomic_load_acquire_8 : acquiring_load<atomic_load_8>;
5073 def atomic_load_acquire_16 : acquiring_load<atomic_load_16>;
5074 def atomic_load_acquire_32 : acquiring_load<atomic_load_32>;
5076 class releasing_store<PatFrag base>
5077 : PatFrag<(ops node:$ptr, node:$val), (base node:$ptr, node:$val), [{
5078 AtomicOrdering Ordering = cast<AtomicSDNode>(N)->getOrdering();
5079 return isReleaseOrStronger(Ordering);
5082 def atomic_store_release_8 : releasing_store<atomic_store_8>;
5083 def atomic_store_release_16 : releasing_store<atomic_store_16>;
5084 def atomic_store_release_32 : releasing_store<atomic_store_32>;
5086 let AddedComplexity = 8 in {
5087 def : ARMPat<(atomic_load_acquire_8 addr_offset_none:$addr), (LDAB addr_offset_none:$addr)>;
5088 def : ARMPat<(atomic_load_acquire_16 addr_offset_none:$addr), (LDAH addr_offset_none:$addr)>;
5089 def : ARMPat<(atomic_load_acquire_32 addr_offset_none:$addr), (LDA addr_offset_none:$addr)>;
5090 def : ARMPat<(atomic_store_release_8 addr_offset_none:$addr, GPR:$val), (STLB GPR:$val, addr_offset_none:$addr)>;
5091 def : ARMPat<(atomic_store_release_16 addr_offset_none:$addr, GPR:$val), (STLH GPR:$val, addr_offset_none:$addr)>;
5092 def : ARMPat<(atomic_store_release_32 addr_offset_none:$addr, GPR:$val), (STL GPR:$val, addr_offset_none:$addr)>;
5095 // SWP/SWPB are deprecated in V6/V7 and optional in v7VE.
5096 // FIXME Use InstAlias to generate LDREX/STREX pairs instead.
5097 let mayLoad = 1, mayStore = 1 in {
5098 def SWP : AIswp<0, (outs GPRnopc:$Rt),
5099 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swp", []>,
5100 Requires<[IsARM,PreV8]>;
5101 def SWPB: AIswp<1, (outs GPRnopc:$Rt),
5102 (ins GPRnopc:$Rt2, addr_offset_none:$addr), "swpb", []>,
5103 Requires<[IsARM,PreV8]>;
5106 //===----------------------------------------------------------------------===//
5107 // Coprocessor Instructions.
5110 def CDP : ABI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
5111 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
5112 NoItinerary, "cdp", "\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
5113 [(int_arm_cdp imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
5114 imm:$CRm, imm:$opc2)]>,
5115 Requires<[IsARM,PreV8]> {
5123 let Inst{3-0} = CRm;
5125 let Inst{7-5} = opc2;
5126 let Inst{11-8} = cop;
5127 let Inst{15-12} = CRd;
5128 let Inst{19-16} = CRn;
5129 let Inst{23-20} = opc1;
5131 let DecoderNamespace = "CoProc";
5134 def CDP2 : ABXI<0b1110, (outs), (ins p_imm:$cop, imm0_15:$opc1,
5135 c_imm:$CRd, c_imm:$CRn, c_imm:$CRm, imm0_7:$opc2),
5136 NoItinerary, "cdp2\t$cop, $opc1, $CRd, $CRn, $CRm, $opc2",
5137 [(int_arm_cdp2 imm:$cop, imm:$opc1, imm:$CRd, imm:$CRn,
5138 imm:$CRm, imm:$opc2)]>,
5139 Requires<[IsARM,PreV8]> {
5140 let Inst{31-28} = 0b1111;
5148 let Inst{3-0} = CRm;
5150 let Inst{7-5} = opc2;
5151 let Inst{11-8} = cop;
5152 let Inst{15-12} = CRd;
5153 let Inst{19-16} = CRn;
5154 let Inst{23-20} = opc1;
5156 let DecoderNamespace = "CoProc";
5159 class ACI<dag oops, dag iops, string opc, string asm,
5160 list<dag> pattern, IndexMode im = IndexModeNone>
5161 : I<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
5162 opc, asm, "", pattern> {
5163 let Inst{27-25} = 0b110;
5165 class ACInoP<dag oops, dag iops, string opc, string asm,
5166 list<dag> pattern, IndexMode im = IndexModeNone>
5167 : InoP<oops, iops, AddrModeNone, 4, im, BrFrm, NoItinerary,
5168 opc, asm, "", pattern> {
5169 let Inst{31-28} = 0b1111;
5170 let Inst{27-25} = 0b110;
5173 let DecoderNamespace = "CoProc" in {
5174 multiclass LdStCop<bit load, bit Dbit, string asm, list<dag> pattern> {
5175 def _OFFSET : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
5176 asm, "\t$cop, $CRd, $addr", pattern> {
5180 let Inst{24} = 1; // P = 1
5181 let Inst{23} = addr{8};
5182 let Inst{22} = Dbit;
5183 let Inst{21} = 0; // W = 0
5184 let Inst{20} = load;
5185 let Inst{19-16} = addr{12-9};
5186 let Inst{15-12} = CRd;
5187 let Inst{11-8} = cop;
5188 let Inst{7-0} = addr{7-0};
5189 let DecoderMethod = "DecodeCopMemInstruction";
5191 def _PRE : ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr),
5192 asm, "\t$cop, $CRd, $addr!", [], IndexModePre> {
5196 let Inst{24} = 1; // P = 1
5197 let Inst{23} = addr{8};
5198 let Inst{22} = Dbit;
5199 let Inst{21} = 1; // W = 1
5200 let Inst{20} = load;
5201 let Inst{19-16} = addr{12-9};
5202 let Inst{15-12} = CRd;
5203 let Inst{11-8} = cop;
5204 let Inst{7-0} = addr{7-0};
5205 let DecoderMethod = "DecodeCopMemInstruction";
5207 def _POST: ACI<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
5208 postidx_imm8s4:$offset),
5209 asm, "\t$cop, $CRd, $addr, $offset", [], IndexModePost> {
5214 let Inst{24} = 0; // P = 0
5215 let Inst{23} = offset{8};
5216 let Inst{22} = Dbit;
5217 let Inst{21} = 1; // W = 1
5218 let Inst{20} = load;
5219 let Inst{19-16} = addr;
5220 let Inst{15-12} = CRd;
5221 let Inst{11-8} = cop;
5222 let Inst{7-0} = offset{7-0};
5223 let DecoderMethod = "DecodeCopMemInstruction";
5225 def _OPTION : ACI<(outs),
5226 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
5227 coproc_option_imm:$option),
5228 asm, "\t$cop, $CRd, $addr, $option", []> {
5233 let Inst{24} = 0; // P = 0
5234 let Inst{23} = 1; // U = 1
5235 let Inst{22} = Dbit;
5236 let Inst{21} = 0; // W = 0
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} = option;
5242 let DecoderMethod = "DecodeCopMemInstruction";
5245 multiclass LdSt2Cop<bit load, bit Dbit, string asm, list<dag> pattern> {
5246 def _OFFSET : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5:$addr),
5247 asm, "\t$cop, $CRd, $addr", pattern> {
5251 let Inst{24} = 1; // P = 1
5252 let Inst{23} = addr{8};
5253 let Inst{22} = Dbit;
5254 let Inst{21} = 0; // W = 0
5255 let Inst{20} = load;
5256 let Inst{19-16} = addr{12-9};
5257 let Inst{15-12} = CRd;
5258 let Inst{11-8} = cop;
5259 let Inst{7-0} = addr{7-0};
5260 let DecoderMethod = "DecodeCopMemInstruction";
5262 def _PRE : ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addrmode5_pre:$addr),
5263 asm, "\t$cop, $CRd, $addr!", [], IndexModePre> {
5267 let Inst{24} = 1; // P = 1
5268 let Inst{23} = addr{8};
5269 let Inst{22} = Dbit;
5270 let Inst{21} = 1; // W = 1
5271 let Inst{20} = load;
5272 let Inst{19-16} = addr{12-9};
5273 let Inst{15-12} = CRd;
5274 let Inst{11-8} = cop;
5275 let Inst{7-0} = addr{7-0};
5276 let DecoderMethod = "DecodeCopMemInstruction";
5278 def _POST: ACInoP<(outs), (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
5279 postidx_imm8s4:$offset),
5280 asm, "\t$cop, $CRd, $addr, $offset", [], IndexModePost> {
5285 let Inst{24} = 0; // P = 0
5286 let Inst{23} = offset{8};
5287 let Inst{22} = Dbit;
5288 let Inst{21} = 1; // W = 1
5289 let Inst{20} = load;
5290 let Inst{19-16} = addr;
5291 let Inst{15-12} = CRd;
5292 let Inst{11-8} = cop;
5293 let Inst{7-0} = offset{7-0};
5294 let DecoderMethod = "DecodeCopMemInstruction";
5296 def _OPTION : ACInoP<(outs),
5297 (ins p_imm:$cop, c_imm:$CRd, addr_offset_none:$addr,
5298 coproc_option_imm:$option),
5299 asm, "\t$cop, $CRd, $addr, $option", []> {
5304 let Inst{24} = 0; // P = 0
5305 let Inst{23} = 1; // U = 1
5306 let Inst{22} = Dbit;
5307 let Inst{21} = 0; // W = 0
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} = option;
5313 let DecoderMethod = "DecodeCopMemInstruction";
5317 defm LDC : LdStCop <1, 0, "ldc", [(int_arm_ldc imm:$cop, imm:$CRd, addrmode5:$addr)]>;
5318 defm LDCL : LdStCop <1, 1, "ldcl", [(int_arm_ldcl imm:$cop, imm:$CRd, addrmode5:$addr)]>;
5319 defm LDC2 : LdSt2Cop<1, 0, "ldc2", [(int_arm_ldc2 imm:$cop, imm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>;
5320 defm LDC2L : LdSt2Cop<1, 1, "ldc2l", [(int_arm_ldc2l imm:$cop, imm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>;
5322 defm STC : LdStCop <0, 0, "stc", [(int_arm_stc imm:$cop, imm:$CRd, addrmode5:$addr)]>;
5323 defm STCL : LdStCop <0, 1, "stcl", [(int_arm_stcl imm:$cop, imm:$CRd, addrmode5:$addr)]>;
5324 defm STC2 : LdSt2Cop<0, 0, "stc2", [(int_arm_stc2 imm:$cop, imm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>;
5325 defm STC2L : LdSt2Cop<0, 1, "stc2l", [(int_arm_stc2l imm:$cop, imm:$CRd, addrmode5:$addr)]>, Requires<[IsARM,PreV8]>;
5327 } // DecoderNamespace = "CoProc"
5329 //===----------------------------------------------------------------------===//
5330 // Move between coprocessor and ARM core register.
5333 class MovRCopro<string opc, bit direction, dag oops, dag iops,
5335 : ABI<0b1110, oops, iops, NoItinerary, opc,
5336 "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2", pattern> {
5337 let Inst{20} = direction;
5347 let Inst{15-12} = Rt;
5348 let Inst{11-8} = cop;
5349 let Inst{23-21} = opc1;
5350 let Inst{7-5} = opc2;
5351 let Inst{3-0} = CRm;
5352 let Inst{19-16} = CRn;
5354 let DecoderNamespace = "CoProc";
5357 def MCR : MovRCopro<"mcr", 0 /* from ARM core register to coprocessor */,
5359 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5360 c_imm:$CRm, imm0_7:$opc2),
5361 [(int_arm_mcr imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
5362 imm:$CRm, imm:$opc2)]>,
5363 ComplexDeprecationPredicate<"MCR">;
5364 def : ARMInstAlias<"mcr${p} $cop, $opc1, $Rt, $CRn, $CRm",
5365 (MCR p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5366 c_imm:$CRm, 0, pred:$p)>;
5367 def MRC : MovRCopro<"mrc", 1 /* from coprocessor to ARM core register */,
5368 (outs GPRwithAPSR:$Rt),
5369 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
5371 def : ARMInstAlias<"mrc${p} $cop, $opc1, $Rt, $CRn, $CRm",
5372 (MRC GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
5373 c_imm:$CRm, 0, pred:$p)>;
5375 def : ARMPat<(int_arm_mrc imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2),
5376 (MRC imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
5378 class MovRCopro2<string opc, bit direction, dag oops, dag iops,
5380 : ABXI<0b1110, oops, iops, NoItinerary,
5381 !strconcat(opc, "\t$cop, $opc1, $Rt, $CRn, $CRm, $opc2"), pattern> {
5382 let Inst{31-24} = 0b11111110;
5383 let Inst{20} = direction;
5393 let Inst{15-12} = Rt;
5394 let Inst{11-8} = cop;
5395 let Inst{23-21} = opc1;
5396 let Inst{7-5} = opc2;
5397 let Inst{3-0} = CRm;
5398 let Inst{19-16} = CRn;
5400 let DecoderNamespace = "CoProc";
5403 def MCR2 : MovRCopro2<"mcr2", 0 /* from ARM core register to coprocessor */,
5405 (ins p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5406 c_imm:$CRm, imm0_7:$opc2),
5407 [(int_arm_mcr2 imm:$cop, imm:$opc1, GPR:$Rt, imm:$CRn,
5408 imm:$CRm, imm:$opc2)]>,
5409 Requires<[IsARM,PreV8]>;
5410 def : ARMInstAlias<"mcr2 $cop, $opc1, $Rt, $CRn, $CRm",
5411 (MCR2 p_imm:$cop, imm0_7:$opc1, GPR:$Rt, c_imm:$CRn,
5413 def MRC2 : MovRCopro2<"mrc2", 1 /* from coprocessor to ARM core register */,
5414 (outs GPRwithAPSR:$Rt),
5415 (ins p_imm:$cop, imm0_7:$opc1, c_imm:$CRn, c_imm:$CRm,
5417 Requires<[IsARM,PreV8]>;
5418 def : ARMInstAlias<"mrc2 $cop, $opc1, $Rt, $CRn, $CRm",
5419 (MRC2 GPRwithAPSR:$Rt, p_imm:$cop, imm0_7:$opc1, c_imm:$CRn,
5422 def : ARMV5TPat<(int_arm_mrc2 imm:$cop, imm:$opc1, imm:$CRn,
5423 imm:$CRm, imm:$opc2),
5424 (MRC2 imm:$cop, imm:$opc1, imm:$CRn, imm:$CRm, imm:$opc2)>;
5426 class MovRRCopro<string opc, bit direction, dag oops, dag iops, list<dag>
5428 : ABI<0b1100, oops, iops, NoItinerary, opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm",
5431 let Inst{23-21} = 0b010;
5432 let Inst{20} = direction;
5440 let Inst{15-12} = Rt;
5441 let Inst{19-16} = Rt2;
5442 let Inst{11-8} = cop;
5443 let Inst{7-4} = opc1;
5444 let Inst{3-0} = CRm;
5447 def MCRR : MovRRCopro<"mcrr", 0 /* from ARM core register to coprocessor */,
5448 (outs), (ins p_imm:$cop, imm0_15:$opc1, GPRnopc:$Rt,
5449 GPRnopc:$Rt2, c_imm:$CRm),
5450 [(int_arm_mcrr imm:$cop, imm:$opc1, GPRnopc:$Rt,
5451 GPRnopc:$Rt2, imm:$CRm)]>;
5452 def MRRC : MovRRCopro<"mrrc", 1 /* from coprocessor to ARM core register */,
5453 (outs GPRnopc:$Rt, GPRnopc:$Rt2),
5454 (ins p_imm:$cop, imm0_15:$opc1, c_imm:$CRm), []>;
5456 class MovRRCopro2<string opc, bit direction, dag oops, dag iops,
5457 list<dag> pattern = []>
5458 : ABXI<0b1100, oops, iops, NoItinerary,
5459 !strconcat(opc, "\t$cop, $opc1, $Rt, $Rt2, $CRm"), pattern>,
5460 Requires<[IsARM,PreV8]> {
5461 let Inst{31-28} = 0b1111;
5462 let Inst{23-21} = 0b010;
5463 let Inst{20} = direction;
5471 let Inst{15-12} = Rt;
5472 let Inst{19-16} = Rt2;
5473 let Inst{11-8} = cop;
5474 let Inst{7-4} = opc1;
5475 let Inst{3-0} = CRm;
5477 let DecoderMethod = "DecoderForMRRC2AndMCRR2";
5480 def MCRR2 : MovRRCopro2<"mcrr2", 0 /* from ARM core register to coprocessor */,
5481 (outs), (ins p_imm:$cop, imm0_15:$opc1, GPRnopc:$Rt,
5482 GPRnopc:$Rt2, c_imm:$CRm),
5483 [(int_arm_mcrr2 imm:$cop, imm:$opc1, GPRnopc:$Rt,
5484 GPRnopc:$Rt2, imm:$CRm)]>;
5486 def MRRC2 : MovRRCopro2<"mrrc2", 1 /* from coprocessor to ARM core register */,
5487 (outs GPRnopc:$Rt, GPRnopc:$Rt2),
5488 (ins p_imm:$cop, imm0_15:$opc1, c_imm:$CRm), []>;
5490 //===----------------------------------------------------------------------===//
5491 // Move between special register and ARM core register
5494 // Move to ARM core register from Special Register
5495 def MRS : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
5496 "mrs", "\t$Rd, apsr", []> {
5498 let Inst{23-16} = 0b00001111;
5499 let Unpredictable{19-17} = 0b111;
5501 let Inst{15-12} = Rd;
5503 let Inst{11-0} = 0b000000000000;
5504 let Unpredictable{11-0} = 0b110100001111;
5507 def : InstAlias<"mrs${p} $Rd, cpsr", (MRS GPRnopc:$Rd, pred:$p), 0>,
5510 // The MRSsys instruction is the MRS instruction from the ARM ARM,
5511 // section B9.3.9, with the R bit set to 1.
5512 def MRSsys : ABI<0b0001, (outs GPRnopc:$Rd), (ins), NoItinerary,
5513 "mrs", "\t$Rd, spsr", []> {
5515 let Inst{23-16} = 0b01001111;
5516 let Unpredictable{19-16} = 0b1111;
5518 let Inst{15-12} = Rd;
5520 let Inst{11-0} = 0b000000000000;
5521 let Unpredictable{11-0} = 0b110100001111;
5524 // However, the MRS (banked register) system instruction (ARMv7VE) *does* have a
5525 // separate encoding (distinguished by bit 5.
5526 def MRSbanked : ABI<0b0001, (outs GPRnopc:$Rd), (ins banked_reg:$banked),
5527 NoItinerary, "mrs", "\t$Rd, $banked", []>,
5528 Requires<[IsARM, HasVirtualization]> {
5533 let Inst{22} = banked{5}; // R bit
5534 let Inst{21-20} = 0b00;
5535 let Inst{19-16} = banked{3-0};
5536 let Inst{15-12} = Rd;
5537 let Inst{11-9} = 0b001;
5538 let Inst{8} = banked{4};
5539 let Inst{7-0} = 0b00000000;
5542 // Move from ARM core register to Special Register
5544 // No need to have both system and application versions of MSR (immediate) or
5545 // MSR (register), the encodings are the same and the assembly parser has no way
5546 // to distinguish between them. The mask operand contains the special register
5547 // (R Bit) in bit 4 and bits 3-0 contains the mask with the fields to be
5548 // accessed in the special register.
5549 let Defs = [CPSR] in
5550 def MSR : ABI<0b0001, (outs), (ins msr_mask:$mask, GPR:$Rn), NoItinerary,
5551 "msr", "\t$mask, $Rn", []> {
5556 let Inst{22} = mask{4}; // R bit
5557 let Inst{21-20} = 0b10;
5558 let Inst{19-16} = mask{3-0};
5559 let Inst{15-12} = 0b1111;
5560 let Inst{11-4} = 0b00000000;
5564 let Defs = [CPSR] in
5565 def MSRi : ABI<0b0011, (outs), (ins msr_mask:$mask, mod_imm:$imm), NoItinerary,
5566 "msr", "\t$mask, $imm", []> {
5571 let Inst{22} = mask{4}; // R bit
5572 let Inst{21-20} = 0b10;
5573 let Inst{19-16} = mask{3-0};
5574 let Inst{15-12} = 0b1111;
5575 let Inst{11-0} = imm;
5578 // However, the MSR (banked register) system instruction (ARMv7VE) *does* have a
5579 // separate encoding (distinguished by bit 5.
5580 def MSRbanked : ABI<0b0001, (outs), (ins banked_reg:$banked, GPRnopc:$Rn),
5581 NoItinerary, "msr", "\t$banked, $Rn", []>,
5582 Requires<[IsARM, HasVirtualization]> {
5587 let Inst{22} = banked{5}; // R bit
5588 let Inst{21-20} = 0b10;
5589 let Inst{19-16} = banked{3-0};
5590 let Inst{15-12} = 0b1111;
5591 let Inst{11-9} = 0b001;
5592 let Inst{8} = banked{4};
5593 let Inst{7-4} = 0b0000;
5597 // Dynamic stack allocation yields a _chkstk for Windows targets. These calls
5598 // are needed to probe the stack when allocating more than
5599 // 4k bytes in one go. Touching the stack at 4K increments is necessary to
5600 // ensure that the guard pages used by the OS virtual memory manager are
5601 // allocated in correct sequence.
5602 // The main point of having separate instruction are extra unmodelled effects
5603 // (compared to ordinary calls) like stack pointer change.
5605 def win__chkstk : SDNode<"ARMISD::WIN__CHKSTK", SDTNone,
5606 [SDNPHasChain, SDNPSideEffect]>;
5607 let usesCustomInserter = 1, Uses = [R4], Defs = [R4, SP] in
5608 def WIN__CHKSTK : PseudoInst<(outs), (ins), NoItinerary, [(win__chkstk)]>;
5610 def win__dbzchk : SDNode<"ARMISD::WIN__DBZCHK", SDT_WIN__DBZCHK,
5611 [SDNPHasChain, SDNPSideEffect, SDNPOutGlue]>;
5612 let usesCustomInserter = 1, Defs = [CPSR] in
5613 def WIN__DBZCHK : PseudoInst<(outs), (ins tGPR:$divisor), NoItinerary,
5614 [(win__dbzchk tGPR:$divisor)]>;
5616 //===----------------------------------------------------------------------===//
5620 // __aeabi_read_tp preserves the registers r1-r3.
5621 // This is a pseudo inst so that we can get the encoding right,
5622 // complete with fixup for the aeabi_read_tp function.
5623 // TPsoft is valid for ARM mode only, in case of Thumb mode a tTPsoft pattern
5624 // is defined in "ARMInstrThumb.td".
5626 Defs = [R0, R12, LR, CPSR], Uses = [SP] in {
5627 def TPsoft : ARMPseudoInst<(outs), (ins), 4, IIC_Br,
5628 [(set R0, ARMthread_pointer)]>, Sched<[WriteBr]>,
5629 Requires<[IsARM, IsReadTPSoft]>;
5632 // Reading thread pointer from coprocessor register
5633 def : ARMPat<(ARMthread_pointer), (MRC 15, 0, 13, 0, 3)>,
5634 Requires<[IsARM, IsReadTPHard]>;
5636 //===----------------------------------------------------------------------===//
5637 // SJLJ Exception handling intrinsics
5638 // eh_sjlj_setjmp() is an instruction sequence to store the return
5639 // address and save #0 in R0 for the non-longjmp case.
5640 // Since by its nature we may be coming from some other function to get
5641 // here, and we're using the stack frame for the containing function to
5642 // save/restore registers, we can't keep anything live in regs across
5643 // the eh_sjlj_setjmp(), else it will almost certainly have been tromped upon
5644 // when we get here from a longjmp(). We force everything out of registers
5645 // except for our own input by listing the relevant registers in Defs. By
5646 // doing so, we also cause the prologue/epilogue code to actively preserve
5647 // all of the callee-saved resgisters, which is exactly what we want.
5648 // A constant value is passed in $val, and we use the location as a scratch.
5650 // These are pseudo-instructions and are lowered to individual MC-insts, so
5651 // no encoding information is necessary.
5653 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR,
5654 Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, Q10, Q11, Q12, Q13, Q14, Q15 ],
5655 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
5656 def Int_eh_sjlj_setjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
5658 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
5659 Requires<[IsARM, HasVFP2]>;
5663 [ R0, R1, R2, R3, R4, R5, R6, R7, R8, R9, R10, R11, R12, LR, CPSR ],
5664 hasSideEffects = 1, isBarrier = 1, usesCustomInserter = 1 in {
5665 def Int_eh_sjlj_setjmp_nofp : PseudoInst<(outs), (ins GPR:$src, GPR:$val),
5667 [(set R0, (ARMeh_sjlj_setjmp GPR:$src, GPR:$val))]>,
5668 Requires<[IsARM, NoVFP]>;
5671 // FIXME: Non-IOS version(s)
5672 let isBarrier = 1, hasSideEffects = 1, isTerminator = 1,
5673 Defs = [ R7, LR, SP ] in {
5674 def Int_eh_sjlj_longjmp : PseudoInst<(outs), (ins GPR:$src, GPR:$scratch),
5676 [(ARMeh_sjlj_longjmp GPR:$src, GPR:$scratch)]>,
5680 let isBarrier = 1, hasSideEffects = 1, usesCustomInserter = 1 in
5681 def Int_eh_sjlj_setup_dispatch : PseudoInst<(outs), (ins), NoItinerary,
5682 [(ARMeh_sjlj_setup_dispatch)]>;
5684 // eh.sjlj.dispatchsetup pseudo-instruction.
5685 // This pseudo is used for both ARM and Thumb. Any differences are handled when
5686 // the pseudo is expanded (which happens before any passes that need the
5687 // instruction size).
5688 let isBarrier = 1 in
5689 def Int_eh_sjlj_dispatchsetup : PseudoInst<(outs), (ins), NoItinerary, []>;
5692 //===----------------------------------------------------------------------===//
5693 // Non-Instruction Patterns
5696 // ARMv4 indirect branch using (MOVr PC, dst)
5697 let isBranch = 1, isTerminator = 1, isBarrier = 1, isIndirectBranch = 1 in
5698 def MOVPCRX : ARMPseudoExpand<(outs), (ins GPR:$dst),
5699 4, IIC_Br, [(brind GPR:$dst)],
5700 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>,
5701 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
5703 let isCall = 1, isTerminator = 1, isReturn = 1, isBarrier = 1, Uses = [SP] in
5704 def TAILJMPr4 : ARMPseudoExpand<(outs), (ins GPR:$dst),
5706 (MOVr PC, GPR:$dst, (ops 14, zero_reg), zero_reg)>,
5707 Requires<[IsARM, NoV4T]>, Sched<[WriteBr]>;
5709 // Large immediate handling.
5711 // 32-bit immediate using two piece mod_imms or movw + movt.
5712 // This is a single pseudo instruction, the benefit is that it can be remat'd
5713 // as a single unit instead of having to handle reg inputs.
5714 // FIXME: Remove this when we can do generalized remat.
5715 let isReMaterializable = 1, isMoveImm = 1 in
5716 def MOVi32imm : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iMOVix2,
5717 [(set GPR:$dst, (arm_i32imm:$src))]>,
5720 def LDRLIT_ga_abs : PseudoInst<(outs GPR:$dst), (ins i32imm:$src), IIC_iLoad_i,
5721 [(set GPR:$dst, (ARMWrapper tglobaladdr:$src))]>,
5722 Requires<[IsARM, DontUseMovt]>;
5724 // Pseudo instruction that combines movw + movt + add pc (if PIC).
5725 // It also makes it possible to rematerialize the instructions.
5726 // FIXME: Remove this when we can do generalized remat and when machine licm
5727 // can properly the instructions.
5728 let isReMaterializable = 1 in {
5729 def MOV_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5731 [(set GPR:$dst, (ARMWrapperPIC tglobaladdr:$addr))]>,
5732 Requires<[IsARM, UseMovtInPic]>;
5734 def LDRLIT_ga_pcrel : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5737 (ARMWrapperPIC tglobaladdr:$addr))]>,
5738 Requires<[IsARM, DontUseMovtInPic]>;
5740 let AddedComplexity = 10 in
5741 def LDRLIT_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5744 (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
5745 Requires<[IsARM, DontUseMovtInPic]>;
5747 let AddedComplexity = 10 in
5748 def MOV_ga_pcrel_ldr : PseudoInst<(outs GPR:$dst), (ins i32imm:$addr),
5750 [(set GPR:$dst, (load (ARMWrapperPIC tglobaladdr:$addr)))]>,
5751 Requires<[IsARM, UseMovtInPic]>;
5752 } // isReMaterializable
5754 // The many different faces of TLS access.
5755 def : ARMPat<(ARMWrapper tglobaltlsaddr :$dst),
5756 (MOVi32imm tglobaltlsaddr :$dst)>,
5757 Requires<[IsARM, UseMovt]>;
5759 def : Pat<(ARMWrapper tglobaltlsaddr:$src),
5760 (LDRLIT_ga_abs tglobaltlsaddr:$src)>,
5761 Requires<[IsARM, DontUseMovt]>;
5763 def : Pat<(ARMWrapperPIC tglobaltlsaddr:$addr),
5764 (MOV_ga_pcrel tglobaltlsaddr:$addr)>, Requires<[IsARM, UseMovtInPic]>;
5766 def : Pat<(ARMWrapperPIC tglobaltlsaddr:$addr),
5767 (LDRLIT_ga_pcrel tglobaltlsaddr:$addr)>,
5768 Requires<[IsARM, DontUseMovtInPic]>;
5769 let AddedComplexity = 10 in
5770 def : Pat<(load (ARMWrapperPIC tglobaltlsaddr:$addr)),
5771 (MOV_ga_pcrel_ldr tglobaltlsaddr:$addr)>,
5772 Requires<[IsARM, UseMovtInPic]>;
5775 // ConstantPool, GlobalAddress, and JumpTable
5776 def : ARMPat<(ARMWrapper tconstpool :$dst), (LEApcrel tconstpool :$dst)>;
5777 def : ARMPat<(ARMWrapper tglobaladdr :$dst), (MOVi32imm tglobaladdr :$dst)>,
5778 Requires<[IsARM, UseMovt]>;
5779 def : ARMPat<(ARMWrapper texternalsym :$dst), (MOVi32imm texternalsym :$dst)>,
5780 Requires<[IsARM, UseMovt]>;
5781 def : ARMPat<(ARMWrapperJT tjumptable:$dst),
5782 (LEApcrelJT tjumptable:$dst)>;
5784 // TODO: add,sub,and, 3-instr forms?
5786 // Tail calls. These patterns also apply to Thumb mode.
5787 def : Pat<(ARMtcret tcGPR:$dst), (TCRETURNri tcGPR:$dst)>;
5788 def : Pat<(ARMtcret (i32 tglobaladdr:$dst)), (TCRETURNdi texternalsym:$dst)>;
5789 def : Pat<(ARMtcret (i32 texternalsym:$dst)), (TCRETURNdi texternalsym:$dst)>;
5792 def : ARMPat<(ARMcall texternalsym:$func), (BL texternalsym:$func)>;
5793 def : ARMPat<(ARMcall_nolink texternalsym:$func),
5794 (BMOVPCB_CALL texternalsym:$func)>;
5796 // zextload i1 -> zextload i8
5797 def : ARMPat<(zextloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5798 def : ARMPat<(zextloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5800 // extload -> zextload
5801 def : ARMPat<(extloadi1 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5802 def : ARMPat<(extloadi1 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5803 def : ARMPat<(extloadi8 addrmode_imm12:$addr), (LDRBi12 addrmode_imm12:$addr)>;
5804 def : ARMPat<(extloadi8 ldst_so_reg:$addr), (LDRBrs ldst_so_reg:$addr)>;
5806 def : ARMPat<(extloadi16 addrmode3:$addr), (LDRH addrmode3:$addr)>;
5808 def : ARMPat<(extloadi8 addrmodepc:$addr), (PICLDRB addrmodepc:$addr)>;
5809 def : ARMPat<(extloadi16 addrmodepc:$addr), (PICLDRH addrmodepc:$addr)>;
5812 def : ARMV5TEPat<(mul sext_16_node:$a, sext_16_node:$b),
5813 (SMULBB GPR:$a, GPR:$b)>;
5814 def : ARMV5TEPat<(mul sext_16_node:$a, (sext_bottom_16 GPR:$b)),
5815 (SMULBB GPR:$a, GPR:$b)>;
5816 def : ARMV5TEPat<(mul sext_16_node:$a, (sext_top_16 GPR:$b)),
5817 (SMULBT GPR:$a, GPR:$b)>;
5818 def : ARMV5TEPat<(mul (sext_top_16 GPR:$a), sext_16_node:$b),
5819 (SMULTB GPR:$a, GPR:$b)>;
5820 def : ARMV5MOPat<(add GPR:$acc, (mul sext_16_node:$a, sext_16_node:$b)),
5821 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5822 def : ARMV5MOPat<(add GPR:$acc, (mul sext_16_node:$a, (sext_bottom_16 GPR:$b))),
5823 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5824 def : ARMV5MOPat<(add GPR:$acc, (mul sext_16_node:$a, (sext_top_16 GPR:$b))),
5825 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
5826 def : ARMV5MOPat<(add GPR:$acc, (mul (sext_top_16 GPR:$a), sext_16_node:$b)),
5827 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
5829 def : ARMV5TEPat<(int_arm_smulbb GPR:$a, GPR:$b),
5830 (SMULBB GPR:$a, GPR:$b)>;
5831 def : ARMV5TEPat<(int_arm_smulbt GPR:$a, GPR:$b),
5832 (SMULBT GPR:$a, GPR:$b)>;
5833 def : ARMV5TEPat<(int_arm_smultb GPR:$a, GPR:$b),
5834 (SMULTB GPR:$a, GPR:$b)>;
5835 def : ARMV5TEPat<(int_arm_smultt GPR:$a, GPR:$b),
5836 (SMULTT GPR:$a, GPR:$b)>;
5837 def : ARMV5TEPat<(int_arm_smulwb GPR:$a, GPR:$b),
5838 (SMULWB GPR:$a, GPR:$b)>;
5839 def : ARMV5TEPat<(int_arm_smulwt GPR:$a, GPR:$b),
5840 (SMULWT GPR:$a, GPR:$b)>;
5842 def : ARMV5TEPat<(int_arm_smlabb GPR:$a, GPR:$b, GPR:$acc),
5843 (SMLABB GPR:$a, GPR:$b, GPR:$acc)>;
5844 def : ARMV5TEPat<(int_arm_smlabt GPR:$a, GPR:$b, GPR:$acc),
5845 (SMLABT GPR:$a, GPR:$b, GPR:$acc)>;
5846 def : ARMV5TEPat<(int_arm_smlatb GPR:$a, GPR:$b, GPR:$acc),
5847 (SMLATB GPR:$a, GPR:$b, GPR:$acc)>;
5848 def : ARMV5TEPat<(int_arm_smlatt GPR:$a, GPR:$b, GPR:$acc),
5849 (SMLATT GPR:$a, GPR:$b, GPR:$acc)>;
5850 def : ARMV5TEPat<(int_arm_smlawb GPR:$a, GPR:$b, GPR:$acc),
5851 (SMLAWB GPR:$a, GPR:$b, GPR:$acc)>;
5852 def : ARMV5TEPat<(int_arm_smlawt GPR:$a, GPR:$b, GPR:$acc),
5853 (SMLAWT GPR:$a, GPR:$b, GPR:$acc)>;
5855 // Pre-v7 uses MCR for synchronization barriers.
5856 def : ARMPat<(ARMMemBarrierMCR GPR:$zero), (MCR 15, 0, GPR:$zero, 7, 10, 5)>,
5857 Requires<[IsARM, HasV6]>;
5859 // SXT/UXT with no rotate
5860 let AddedComplexity = 16 in {
5861 def : ARMV6Pat<(and GPR:$Src, 0x000000FF), (UXTB GPR:$Src, 0)>;
5862 def : ARMV6Pat<(and GPR:$Src, 0x0000FFFF), (UXTH GPR:$Src, 0)>;
5863 def : ARMV6Pat<(and GPR:$Src, 0x00FF00FF), (UXTB16 GPR:$Src, 0)>;
5864 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0x00FF)),
5865 (UXTAB GPR:$Rn, GPR:$Rm, 0)>;
5866 def : ARMV6Pat<(add GPR:$Rn, (and GPR:$Rm, 0xFFFF)),
5867 (UXTAH GPR:$Rn, GPR:$Rm, 0)>;
5870 def : ARMV6Pat<(sext_inreg GPR:$Src, i8), (SXTB GPR:$Src, 0)>;
5871 def : ARMV6Pat<(sext_inreg GPR:$Src, i16), (SXTH GPR:$Src, 0)>;
5873 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i8)),
5874 (SXTAB GPR:$Rn, GPRnopc:$Rm, 0)>;
5875 def : ARMV6Pat<(add GPR:$Rn, (sext_inreg GPRnopc:$Rm, i16)),
5876 (SXTAH GPR:$Rn, GPRnopc:$Rm, 0)>;
5878 // Atomic load/store patterns
5879 def : ARMPat<(atomic_load_8 ldst_so_reg:$src),
5880 (LDRBrs ldst_so_reg:$src)>;
5881 def : ARMPat<(atomic_load_8 addrmode_imm12:$src),
5882 (LDRBi12 addrmode_imm12:$src)>;
5883 def : ARMPat<(atomic_load_16 addrmode3:$src),
5884 (LDRH addrmode3:$src)>;
5885 def : ARMPat<(atomic_load_32 ldst_so_reg:$src),
5886 (LDRrs ldst_so_reg:$src)>;
5887 def : ARMPat<(atomic_load_32 addrmode_imm12:$src),
5888 (LDRi12 addrmode_imm12:$src)>;
5889 def : ARMPat<(atomic_store_8 ldst_so_reg:$ptr, GPR:$val),
5890 (STRBrs GPR:$val, ldst_so_reg:$ptr)>;
5891 def : ARMPat<(atomic_store_8 addrmode_imm12:$ptr, GPR:$val),
5892 (STRBi12 GPR:$val, addrmode_imm12:$ptr)>;
5893 def : ARMPat<(atomic_store_16 addrmode3:$ptr, GPR:$val),
5894 (STRH GPR:$val, addrmode3:$ptr)>;
5895 def : ARMPat<(atomic_store_32 ldst_so_reg:$ptr, GPR:$val),
5896 (STRrs GPR:$val, ldst_so_reg:$ptr)>;
5897 def : ARMPat<(atomic_store_32 addrmode_imm12:$ptr, GPR:$val),
5898 (STRi12 GPR:$val, addrmode_imm12:$ptr)>;
5901 //===----------------------------------------------------------------------===//
5905 include "ARMInstrThumb.td"
5907 //===----------------------------------------------------------------------===//
5911 include "ARMInstrThumb2.td"
5913 //===----------------------------------------------------------------------===//
5914 // Floating Point Support
5917 include "ARMInstrVFP.td"
5919 //===----------------------------------------------------------------------===//
5920 // Advanced SIMD (NEON) Support
5923 include "ARMInstrNEON.td"
5925 //===----------------------------------------------------------------------===//
5929 include "ARMInstrMVE.td"
5931 //===----------------------------------------------------------------------===//
5932 // Assembler aliases
5936 def : InstAlias<"dmb", (DMB 0xf), 0>, Requires<[IsARM, HasDB]>;
5937 def : InstAlias<"dsb", (DSB 0xf), 0>, Requires<[IsARM, HasDB]>;
5938 def : InstAlias<"ssbb", (DSB 0x0), 1>, Requires<[IsARM, HasDB]>;
5939 def : InstAlias<"pssbb", (DSB 0x4), 1>, Requires<[IsARM, HasDB]>;
5940 def : InstAlias<"isb", (ISB 0xf), 0>, Requires<[IsARM, HasDB]>;
5941 // Armv8-R 'Data Full Barrier'
5942 def : InstAlias<"dfb", (DSB 0xc), 1>, Requires<[IsARM, HasDFB]>;
5944 // System instructions
5945 def : MnemonicAlias<"swi", "svc">;
5947 // Load / Store Multiple
5948 def : MnemonicAlias<"ldmfd", "ldm">;
5949 def : MnemonicAlias<"ldmia", "ldm">;
5950 def : MnemonicAlias<"ldmea", "ldmdb">;
5951 def : MnemonicAlias<"stmfd", "stmdb">;
5952 def : MnemonicAlias<"stmia", "stm">;
5953 def : MnemonicAlias<"stmea", "stm">;
5955 // PKHBT/PKHTB with default shift amount. PKHTB is equivalent to PKHBT with the
5956 // input operands swapped when the shift amount is zero (i.e., unspecified).
5957 def : InstAlias<"pkhbt${p} $Rd, $Rn, $Rm",
5958 (PKHBT GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, 0, pred:$p), 0>,
5959 Requires<[IsARM, HasV6]>;
5960 def : InstAlias<"pkhtb${p} $Rd, $Rn, $Rm",
5961 (PKHBT GPRnopc:$Rd, GPRnopc:$Rm, GPRnopc:$Rn, 0, pred:$p), 0>,
5962 Requires<[IsARM, HasV6]>;
5964 // PUSH/POP aliases for STM/LDM
5965 def : ARMInstAlias<"push${p} $regs", (STMDB_UPD SP, pred:$p, reglist:$regs)>;
5966 def : ARMInstAlias<"pop${p} $regs", (LDMIA_UPD SP, pred:$p, reglist:$regs)>;
5968 // SSAT/USAT optional shift operand.
5969 def : ARMInstAlias<"ssat${p} $Rd, $sat_imm, $Rn",
5970 (SSAT GPRnopc:$Rd, imm1_32:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5971 def : ARMInstAlias<"usat${p} $Rd, $sat_imm, $Rn",
5972 (USAT GPRnopc:$Rd, imm0_31:$sat_imm, GPRnopc:$Rn, 0, pred:$p)>;
5975 // Extend instruction optional rotate operand.
5976 def : ARMInstAlias<"sxtab${p} $Rd, $Rn, $Rm",
5977 (SXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5978 def : ARMInstAlias<"sxtah${p} $Rd, $Rn, $Rm",
5979 (SXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5980 def : ARMInstAlias<"sxtab16${p} $Rd, $Rn, $Rm",
5981 (SXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5982 def : ARMInstAlias<"sxtb${p} $Rd, $Rm",
5983 (SXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5984 def : ARMInstAlias<"sxtb16${p} $Rd, $Rm",
5985 (SXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5986 def : ARMInstAlias<"sxth${p} $Rd, $Rm",
5987 (SXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5989 def : ARMInstAlias<"uxtab${p} $Rd, $Rn, $Rm",
5990 (UXTAB GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5991 def : ARMInstAlias<"uxtah${p} $Rd, $Rn, $Rm",
5992 (UXTAH GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5993 def : ARMInstAlias<"uxtab16${p} $Rd, $Rn, $Rm",
5994 (UXTAB16 GPRnopc:$Rd, GPR:$Rn, GPRnopc:$Rm, 0, pred:$p)>;
5995 def : ARMInstAlias<"uxtb${p} $Rd, $Rm",
5996 (UXTB GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5997 def : ARMInstAlias<"uxtb16${p} $Rd, $Rm",
5998 (UXTB16 GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
5999 def : ARMInstAlias<"uxth${p} $Rd, $Rm",
6000 (UXTH GPRnopc:$Rd, GPRnopc:$Rm, 0, pred:$p)>;
6004 def : MnemonicAlias<"rfefa", "rfeda">;
6005 def : MnemonicAlias<"rfeea", "rfedb">;
6006 def : MnemonicAlias<"rfefd", "rfeia">;
6007 def : MnemonicAlias<"rfeed", "rfeib">;
6008 def : MnemonicAlias<"rfe", "rfeia">;
6011 def : MnemonicAlias<"srsfa", "srsib">;
6012 def : MnemonicAlias<"srsea", "srsia">;
6013 def : MnemonicAlias<"srsfd", "srsdb">;
6014 def : MnemonicAlias<"srsed", "srsda">;
6015 def : MnemonicAlias<"srs", "srsia">;
6018 def : MnemonicAlias<"qsubaddx", "qsax">;
6020 def : MnemonicAlias<"saddsubx", "sasx">;
6021 // SHASX == SHADDSUBX
6022 def : MnemonicAlias<"shaddsubx", "shasx">;
6023 // SHSAX == SHSUBADDX
6024 def : MnemonicAlias<"shsubaddx", "shsax">;
6026 def : MnemonicAlias<"ssubaddx", "ssax">;
6028 def : MnemonicAlias<"uaddsubx", "uasx">;
6029 // UHASX == UHADDSUBX
6030 def : MnemonicAlias<"uhaddsubx", "uhasx">;
6031 // UHSAX == UHSUBADDX
6032 def : MnemonicAlias<"uhsubaddx", "uhsax">;
6033 // UQASX == UQADDSUBX
6034 def : MnemonicAlias<"uqaddsubx", "uqasx">;
6035 // UQSAX == UQSUBADDX
6036 def : MnemonicAlias<"uqsubaddx", "uqsax">;
6038 def : MnemonicAlias<"usubaddx", "usax">;
6040 // "mov Rd, mod_imm_not" can be handled via "mvn" in assembly, just like
6042 def : ARMInstSubst<"mov${s}${p} $Rd, $imm",
6043 (MVNi rGPR:$Rd, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6044 def : ARMInstSubst<"mvn${s}${p} $Rd, $imm",
6045 (MOVi rGPR:$Rd, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6046 // Same for AND <--> BIC
6047 def : ARMInstSubst<"bic${s}${p} $Rd, $Rn, $imm",
6048 (ANDri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm,
6049 pred:$p, cc_out:$s)>;
6050 def : ARMInstSubst<"bic${s}${p} $Rdn, $imm",
6051 (ANDri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm,
6052 pred:$p, cc_out:$s)>;
6053 def : ARMInstSubst<"and${s}${p} $Rd, $Rn, $imm",
6054 (BICri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm,
6055 pred:$p, cc_out:$s)>;
6056 def : ARMInstSubst<"and${s}${p} $Rdn, $imm",
6057 (BICri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm,
6058 pred:$p, cc_out:$s)>;
6060 // Likewise, "add Rd, mod_imm_neg" -> sub
6061 def : ARMInstSubst<"add${s}${p} $Rd, $Rn, $imm",
6062 (SUBri GPR:$Rd, GPR:$Rn, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
6063 def : ARMInstSubst<"add${s}${p} $Rd, $imm",
6064 (SUBri GPR:$Rd, GPR:$Rd, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
6065 // Likewise, "sub Rd, mod_imm_neg" -> add
6066 def : ARMInstSubst<"sub${s}${p} $Rd, $Rn, $imm",
6067 (ADDri GPR:$Rd, GPR:$Rn, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
6068 def : ARMInstSubst<"sub${s}${p} $Rd, $imm",
6069 (ADDri GPR:$Rd, GPR:$Rd, mod_imm_neg:$imm, pred:$p, cc_out:$s)>;
6072 def : ARMInstSubst<"adc${s}${p} $Rd, $Rn, $imm",
6073 (SBCri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6074 def : ARMInstSubst<"adc${s}${p} $Rdn, $imm",
6075 (SBCri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6076 def : ARMInstSubst<"sbc${s}${p} $Rd, $Rn, $imm",
6077 (ADCri GPR:$Rd, GPR:$Rn, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6078 def : ARMInstSubst<"sbc${s}${p} $Rdn, $imm",
6079 (ADCri GPR:$Rdn, GPR:$Rdn, mod_imm_not:$imm, pred:$p, cc_out:$s)>;
6081 // Same for CMP <--> CMN via mod_imm_neg
6082 def : ARMInstSubst<"cmp${p} $Rd, $imm",
6083 (CMNri rGPR:$Rd, mod_imm_neg:$imm, pred:$p)>;
6084 def : ARMInstSubst<"cmn${p} $Rd, $imm",
6085 (CMPri rGPR:$Rd, mod_imm_neg:$imm, pred:$p)>;
6087 // The shifter forms of the MOV instruction are aliased to the ASR, LSL,
6088 // LSR, ROR, and RRX instructions.
6089 // FIXME: We need C++ parser hooks to map the alias to the MOV
6090 // encoding. It seems we should be able to do that sort of thing
6091 // in tblgen, but it could get ugly.
6092 let TwoOperandAliasConstraint = "$Rm = $Rd" in {
6093 def ASRi : ARMAsmPseudo<"asr${s}${p} $Rd, $Rm, $imm",
6094 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
6096 def LSRi : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rm, $imm",
6097 (ins GPR:$Rd, GPR:$Rm, imm0_32:$imm, pred:$p,
6099 def LSLi : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rm, $imm",
6100 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
6102 def RORi : ARMAsmPseudo<"ror${s}${p} $Rd, $Rm, $imm",
6103 (ins GPR:$Rd, GPR:$Rm, imm0_31:$imm, pred:$p,
6106 def RRXi : ARMAsmPseudo<"rrx${s}${p} $Rd, $Rm",
6107 (ins GPR:$Rd, GPR:$Rm, pred:$p, cc_out:$s)>;
6108 let TwoOperandAliasConstraint = "$Rn = $Rd" in {
6109 def ASRr : ARMAsmPseudo<"asr${s}${p} $Rd, $Rn, $Rm",
6110 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
6112 def LSRr : ARMAsmPseudo<"lsr${s}${p} $Rd, $Rn, $Rm",
6113 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
6115 def LSLr : ARMAsmPseudo<"lsl${s}${p} $Rd, $Rn, $Rm",
6116 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
6118 def RORr : ARMAsmPseudo<"ror${s}${p} $Rd, $Rn, $Rm",
6119 (ins GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p,
6123 // "neg" is and alias for "rsb rd, rn, #0"
6124 def : ARMInstAlias<"neg${s}${p} $Rd, $Rm",
6125 (RSBri GPR:$Rd, GPR:$Rm, 0, pred:$p, cc_out:$s)>;
6127 // Pre-v6, 'mov r0, r0' was used as a NOP encoding.
6128 def : InstAlias<"nop${p}", (MOVr R0, R0, pred:$p, zero_reg)>,
6129 Requires<[IsARM, NoV6]>;
6131 // MUL/UMLAL/SMLAL/UMULL/SMULL are available on all arches, but
6132 // the instruction definitions need difference constraints pre-v6.
6133 // Use these aliases for the assembly parsing on pre-v6.
6134 def : InstAlias<"mul${s}${p} $Rd, $Rn, $Rm",
6135 (MUL GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, pred:$p, cc_out:$s), 0>,
6136 Requires<[IsARM, NoV6]>;
6137 def : InstAlias<"mla${s}${p} $Rd, $Rn, $Rm, $Ra",
6138 (MLA GPRnopc:$Rd, GPRnopc:$Rn, GPRnopc:$Rm, GPRnopc:$Ra,
6139 pred:$p, cc_out:$s), 0>,
6140 Requires<[IsARM, NoV6]>;
6141 def : InstAlias<"smlal${s}${p} $RdLo, $RdHi, $Rn, $Rm",
6142 (SMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>,
6143 Requires<[IsARM, NoV6]>;
6144 def : InstAlias<"umlal${s}${p} $RdLo, $RdHi, $Rn, $Rm",
6145 (UMLAL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>,
6146 Requires<[IsARM, NoV6]>;
6147 def : InstAlias<"smull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
6148 (SMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>,
6149 Requires<[IsARM, NoV6]>;
6150 def : InstAlias<"umull${s}${p} $RdLo, $RdHi, $Rn, $Rm",
6151 (UMULL GPR:$RdLo, GPR:$RdHi, GPR:$Rn, GPR:$Rm, pred:$p, cc_out:$s), 0>,
6152 Requires<[IsARM, NoV6]>;
6154 // 'it' blocks in ARM mode just validate the predicates. The IT itself
6156 def ITasm : ARMAsmPseudo<"it$mask $cc", (ins it_pred:$cc, it_mask:$mask)>,
6157 ComplexDeprecationPredicate<"IT">;
6159 let mayLoad = 1, mayStore =1, hasSideEffects = 1 in
6160 def SPACE : PseudoInst<(outs GPR:$Rd), (ins i32imm:$size, GPR:$Rn),
6162 [(set GPR:$Rd, (int_arm_space imm:$size, GPR:$Rn))]>;
6164 //===----------------------------------
6165 // Atomic cmpxchg for -O0
6166 //===----------------------------------
6168 // The fast register allocator used during -O0 inserts spills to cover any VRegs
6169 // live across basic block boundaries. When this happens between an LDXR and an
6170 // STXR it can clear the exclusive monitor, causing all cmpxchg attempts to
6173 // Unfortunately, this means we have to have an alternative (expanded
6174 // post-regalloc) path for -O0 compilations. Fortunately this path can be
6175 // significantly more naive than the standard expansion: we conservatively
6176 // assume seq_cst, strong cmpxchg and omit clrex on failure.
6178 let Constraints = "@earlyclobber $Rd,@earlyclobber $temp",
6179 mayLoad = 1, mayStore = 1 in {
6180 def CMP_SWAP_8 : PseudoInst<(outs GPR:$Rd, GPR:$temp),
6181 (ins GPR:$addr, GPR:$desired, GPR:$new),
6182 NoItinerary, []>, Sched<[]>;
6184 def CMP_SWAP_16 : PseudoInst<(outs GPR:$Rd, GPR:$temp),
6185 (ins GPR:$addr, GPR:$desired, GPR:$new),
6186 NoItinerary, []>, Sched<[]>;
6188 def CMP_SWAP_32 : PseudoInst<(outs GPR:$Rd, GPR:$temp),
6189 (ins GPR:$addr, GPR:$desired, GPR:$new),
6190 NoItinerary, []>, Sched<[]>;
6192 def CMP_SWAP_64 : PseudoInst<(outs GPRPair:$Rd, GPR:$temp),
6193 (ins GPR:$addr, GPRPair:$desired, GPRPair:$new),
6194 NoItinerary, []>, Sched<[]>;
6197 def CompilerBarrier : PseudoInst<(outs), (ins i32imm:$ordering), NoItinerary,
6198 [(atomic_fence imm:$ordering, 0)]> {
6199 let hasSideEffects = 1;
6201 let AsmString = "@ COMPILER BARRIER";